summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorhselasky <hselasky@FreeBSD.org>2018-03-30 18:06:29 +0000
committerhselasky <hselasky@FreeBSD.org>2018-03-30 18:06:29 +0000
commit9201b6f6d363e31c394583faab87ab462e02077a (patch)
tree4d4d0844116e01e2d695e4df4fe649ced1640f1f
parent1ceba5b8ec12236d589d4f245412fbcca7c16e3d (diff)
downloadFreeBSD-src-9201b6f6d363e31c394583faab87ab462e02077a.zip
FreeBSD-src-9201b6f6d363e31c394583faab87ab462e02077a.tar.gz
MFC r303505, r303506, r303512, r303513, r303646, r320418, r323082,
r326169, r326563, r326649, r326716, r326764, r326765 and r329222: RoCE/infiniband/iWarp upgrade to Linux 4.9 for kernel and userspace. This commit merges projects/bsd_rdma_4_9 to 11-stable. Compatibility wrappers have been made for existing 11-stable ibcore APIs, including ib_reg_phys_mr(). Refer to "sys/ofed/include/rdma/ib_verbs_compat.h" for more information. The iw_cxgb driver has not been updated and has been disconnected from the build. Sponsored by: Mellanox Technologies MFC r326169 and r326563: RoCE/infiniband upgrade to Linux v4.9 for kernel and userspace. List of kernel sources used: ============================ 1) kernel sources were cloned from git://github.com/torvalds/linux.git Top commit 69973b830859bc6529a7a0468ba0d80ee5117826 - tag: v4.9, linux-4.9 2) krping was cloned from https://github.com/larrystevenwise/krping Top commit 292a2f1abf0348285e678a82264740d52e4dcfe4 List of userspace sources used: =============================== 1) rdma-core was cloned from https://github.com/linux-rdma/rdma-core.git Top commit d65138ef93af30b3ea249f3a84aa6a24ba7f8a75 2) OpenSM was cloned from git://git.openfabrics.org/~halr/opensm.git Top commit 85f841cf209f791c89a075048a907020e924528d 3) libibmad was cloned from git://git.openfabrics.org/~iraweiny/libibmad.git Tag 1.3.13 with some additional patches from Mellanox. 4) infiniband-diags was cloned from git://git.openfabrics.org/~iraweiny/infiniband-diags.git Tag 1.6.7 with some additional patches from Mellanox. NOTES: ====== 1) The mthca driver has been removed from userspace. 2) All GPLv2 only sources have been removed and where applicable rewritten from scratch under a BSD license. 3) List of fully supported drivers in userspace and kernel: a) iw_cxgbe (Chelsio) b) mlx4ib (Mellanox) c) mlx5ib (Mellanox) 4) WITH_OFED=YES is still required by make in order to build OFED userspace and kernel code. 5) Full support has been added for routable RoCE, RoCE v2. MFC r326649: Disconnect OFED after r326169 broke all DIRDEPS support for it. MFC r326716: Correctly define the unordered_map namespace in ofed/libibnetdisc . This should fix ofed/libibnetdisc compilation with C-compilers different from clang and GCC v4.2.1. Submitted by: kib Sponsored by: Mellanox Technologies MFC r326764: ofed: Remove duplicated symbols from the version file. ld.bfd accepts multiple listing of the same symbol in the version script. lld is stricter and errors out. Since arm64 and sometimes amd64 use lld, we should correct this cosmetic issue. Sponsored by: Mellanox Technologies Reviewed by: hselasky Differential revision: https://reviews.freebsd.org/D13329 MFC r326765: ofed: Define barriers for mips and arm. I used the strongest barriers available on the architectures, so if the future analysis show that it is excessive, the barriers could be relaxed. Still, it is unlikely that it is meaningful to run IB on 32bit ARM or current MIPS machines, so the change is to make WITH_OFED to pass tinderbox. Sponsored by: Mellanox Technologies Reviewed by: hselasky Differential revision: https://reviews.freebsd.org/D13329 MFC r303505: sdp: Use an mbufq for received control packets. This is simpler than the hand-rolled queue, and fixes a use-after-free. Sponsored by: EMC / Isilon Storage Division MFC r303506: sdp: Destroy the PCB lock before freeing to the zone. Sponsored by: EMC / Isilon Storage Division MFC r303512: sdp: Use malloc(9) instead of the Linux compat layer. SDP transmit and receive rings are always created in a sleepable context, so we can use M_WAITOK and remove error checks. Sponsored by: EMC / Isilon Storage Division MFC r303513: sdp: Destroy the RDMA ID after destroying the connection's queue pair. This is the ordering documented by rdma_destroy_qp(). Also add a useful KASSERT to sdp_pcbfree(). Sponsored by: EMC / Isilon Storage Division MFC r303646: ipoib: Bound the number of egress mbufs buffered during pathrec lookups. In pathological situations where the master subnet manager becomes unresponsive for an extended period, we may otherwise end up queuing all of the system's mbufs while waiting for a response to a path record lookup. This addresses the same issue as commit 1e85b806f9 in Linux. Reviewed by: cem, ngie Sponsored by: EMC / Isilon Storage Division MFC r329222: Import the mthca kernel side infiniband driver from Linux 4.9 and fix compilation under FreeBSD. The mthca driver was temporarily removed as part of the Linux 4.9 RoCE/infinband upgrade. Top commit in Linux source tree: 69973b830859bc6529a7a0468ba0d80ee5117826 Sponsored by: Mellanox Technologies MFC r320418. Note that the socket lock _is_ the same as so_rcv's lock in 11 and this is a no-op in this branch. Sponsored by: Chelsio Communications MFC r323082: cxgbe/iw_cxgbe: Set TCP_NODELAY before initiating connection so that t4_tom picks it up right away. This is less work than waiting for the connection to be established before applying the setting. Sponsored by: Chelsio Communications
-rw-r--r--Makefile.inc128
-rw-r--r--contrib/ofed/Makefile9
-rw-r--r--contrib/ofed/include/Makefile192
-rw-r--r--contrib/ofed/include/byteorder.h (renamed from contrib/ofed/include/infiniband/byteorder.h)0
-rw-r--r--contrib/ofed/include/byteswap.h (renamed from contrib/ofed/include/infiniband/byteswap.h)0
-rw-r--r--contrib/ofed/include/endian.h (renamed from contrib/ofed/include/infiniband/endian.h)0
-rw-r--r--contrib/ofed/include/infiniband/Makefile107
-rw-r--r--contrib/ofed/include/infiniband/types.h63
-rw-r--r--contrib/ofed/include/rdma/Makefile10
-rw-r--r--contrib/ofed/include/types.h61
-rw-r--r--contrib/ofed/include/udma_barrier.h277
-rw-r--r--contrib/ofed/infiniband-diags/build/Makefile29
-rw-r--r--contrib/ofed/infiniband-diags/build/Makefile.inc12
-rw-r--r--contrib/ofed/infiniband-diags/build/dump_fts/Makefile8
-rw-r--r--contrib/ofed/infiniband-diags/build/ibaddr/Makefile7
-rw-r--r--contrib/ofed/infiniband-diags/build/ibcacheedit/Makefile8
-rw-r--r--contrib/ofed/infiniband-diags/build/ibccconfig/Makefile7
-rw-r--r--contrib/ofed/infiniband-diags/build/ibccquery/Makefile7
-rw-r--r--contrib/ofed/infiniband-diags/build/iblinkinfo/Makefile8
-rw-r--r--contrib/ofed/infiniband-diags/build/ibmirror/Makefile7
-rw-r--r--contrib/ofed/infiniband-diags/build/ibnetdiscover/Makefile8
-rw-r--r--contrib/ofed/infiniband-diags/build/ibping/Makefile7
-rw-r--r--contrib/ofed/infiniband-diags/build/ibportstate/Makefile7
-rw-r--r--contrib/ofed/infiniband-diags/build/ibqueryerrors/Makefile8
-rw-r--r--contrib/ofed/infiniband-diags/build/ibroute/Makefile7
-rw-r--r--contrib/ofed/infiniband-diags/build/ibstat/Makefile7
-rw-r--r--contrib/ofed/infiniband-diags/build/ibsysstat/Makefile7
-rw-r--r--contrib/ofed/infiniband-diags/build/ibtracert/Makefile7
-rw-r--r--contrib/ofed/infiniband-diags/build/perfquery/Makefile7
-rw-r--r--contrib/ofed/infiniband-diags/build/saquery/Makefile7
-rw-r--r--contrib/ofed/infiniband-diags/build/sminfo/Makefile7
-rw-r--r--contrib/ofed/infiniband-diags/build/smpdump/Makefile7
-rw-r--r--contrib/ofed/infiniband-diags/build/smpquery/Makefile7
-rw-r--r--contrib/ofed/infiniband-diags/build/vendstat/Makefile7
-rw-r--r--contrib/ofed/infiniband-diags/config.h125
-rw-r--r--contrib/ofed/infiniband-diags/man/check_lft_balance.868
-rw-r--r--contrib/ofed/infiniband-diags/man/dump_fts.8235
-rw-r--r--contrib/ofed/infiniband-diags/man/ibaddr.8214
-rw-r--r--contrib/ofed/infiniband-diags/man/ibcacheedit.880
-rw-r--r--contrib/ofed/infiniband-diags/man/ibccconfig.8198
-rw-r--r--contrib/ofed/infiniband-diags/man/ibccquery.8194
-rw-r--r--contrib/ofed/infiniband-diags/man/ibfindnodesusing.8127
-rw-r--r--contrib/ofed/infiniband-diags/man/ibhosts.8184
-rw-r--r--contrib/ofed/infiniband-diags/man/ibidsverify.880
-rw-r--r--contrib/ofed/infiniband-diags/man/iblinkinfo.8319
-rw-r--r--contrib/ofed/infiniband-diags/man/ibnetdiscover.8399
-rw-r--r--contrib/ofed/infiniband-diags/man/ibnodes.8176
-rw-r--r--contrib/ofed/infiniband-diags/man/ibping.8177
-rw-r--r--contrib/ofed/infiniband-diags/man/ibportstate.8259
-rw-r--r--contrib/ofed/infiniband-diags/man/ibqueryerrors.8339
-rw-r--r--contrib/ofed/infiniband-diags/man/ibroute.8291
-rw-r--r--contrib/ofed/infiniband-diags/man/ibrouters.8184
-rw-r--r--contrib/ofed/infiniband-diags/man/ibstat.8118
-rw-r--r--contrib/ofed/infiniband-diags/man/ibstatus.873
-rw-r--r--contrib/ofed/infiniband-diags/man/ibswitches.8184
-rw-r--r--contrib/ofed/infiniband-diags/man/ibsysstat.8188
-rw-r--r--contrib/ofed/infiniband-diags/man/ibtracert.8268
-rw-r--r--contrib/ofed/infiniband-diags/man/infiniband-diags.8452
-rw-r--r--contrib/ofed/infiniband-diags/man/perfquery.8291
-rw-r--r--contrib/ofed/infiniband-diags/man/saquery.8380
-rw-r--r--contrib/ofed/infiniband-diags/man/sminfo.8215
-rw-r--r--contrib/ofed/infiniband-diags/man/smpdump.8207
-rw-r--r--contrib/ofed/infiniband-diags/man/smpquery.8310
-rw-r--r--contrib/ofed/infiniband-diags/man/vendstat.8221
-rw-r--r--contrib/ofed/infiniband-diags/src/dump_fts.c497
-rw-r--r--contrib/ofed/infiniband-diags/src/ibaddr.c168
-rw-r--r--contrib/ofed/infiniband-diags/src/ibcacheedit.c356
-rw-r--r--contrib/ofed/infiniband-diags/src/ibccconfig.c639
-rw-r--r--contrib/ofed/infiniband-diags/src/ibccquery.c427
-rw-r--r--contrib/ofed/infiniband-diags/src/ibdiag_common.c940
-rw-r--r--contrib/ofed/infiniband-diags/src/ibdiag_common.h178
-rw-r--r--contrib/ofed/infiniband-diags/src/ibdiag_sa.c256
-rw-r--r--contrib/ofed/infiniband-diags/src/ibdiag_sa.h94
-rw-r--r--contrib/ofed/infiniband-diags/src/ibdiag_version.h39
-rw-r--r--contrib/ofed/infiniband-diags/src/iblinkinfo.c768
-rw-r--r--contrib/ofed/infiniband-diags/src/ibmirror.c538
-rw-r--r--contrib/ofed/infiniband-diags/src/ibnetdiscover.c1157
-rw-r--r--contrib/ofed/infiniband-diags/src/ibping.c286
-rw-r--r--contrib/ofed/infiniband-diags/src/ibportstate.c767
-rw-r--r--contrib/ofed/infiniband-diags/src/ibqueryerrors.c1126
-rw-r--r--contrib/ofed/infiniband-diags/src/ibroute.c488
-rw-r--r--contrib/ofed/infiniband-diags/src/ibsendtrap.c278
-rw-r--r--contrib/ofed/infiniband-diags/src/ibstat.c335
-rw-r--r--contrib/ofed/infiniband-diags/src/ibsysstat.c367
-rw-r--r--contrib/ofed/infiniband-diags/src/ibtracert.c881
-rw-r--r--contrib/ofed/infiniband-diags/src/mcm_rereg_test.c399
-rw-r--r--contrib/ofed/infiniband-diags/src/perfquery.c1122
-rw-r--r--contrib/ofed/infiniband-diags/src/rdma-ndd.c433
-rw-r--r--contrib/ofed/infiniband-diags/src/saquery.c1984
-rw-r--r--contrib/ofed/infiniband-diags/src/sminfo.c162
-rw-r--r--contrib/ofed/infiniband-diags/src/smpdump.c318
-rw-r--r--contrib/ofed/infiniband-diags/src/smpquery.c509
-rw-r--r--contrib/ofed/infiniband-diags/src/vendstat.c552
-rw-r--r--contrib/ofed/libcxgb4/AUTHORS1
-rw-r--r--contrib/ofed/libcxgb4/COPYING29
-rw-r--r--contrib/ofed/libcxgb4/ChangeLog1054
-rw-r--r--contrib/ofed/libcxgb4/Makefile19
-rw-r--r--contrib/ofed/libcxgb4/README19
-rw-r--r--contrib/ofed/libcxgb4/config.h6
-rw-r--r--contrib/ofed/libcxgb4/cq.c750
-rw-r--r--contrib/ofed/libcxgb4/cxgb4-abi.h96
-rw-r--r--contrib/ofed/libcxgb4/cxgb4.driver1
-rw-r--r--contrib/ofed/libcxgb4/dev.c579
-rw-r--r--contrib/ofed/libcxgb4/libcxgb4.h267
-rw-r--r--contrib/ofed/libcxgb4/qp.c555
-rw-r--r--contrib/ofed/libcxgb4/src/cq.c753
-rw-r--r--contrib/ofed/libcxgb4/src/cxgb4-abi.h95
-rw-r--r--contrib/ofed/libcxgb4/src/cxgb4.map6
-rw-r--r--contrib/ofed/libcxgb4/src/dev.c554
-rw-r--r--contrib/ofed/libcxgb4/src/libcxgb4.h262
-rw-r--r--contrib/ofed/libcxgb4/src/qp.c548
-rw-r--r--contrib/ofed/libcxgb4/src/queue.h650
-rw-r--r--contrib/ofed/libcxgb4/src/t4.h719
-rw-r--r--contrib/ofed/libcxgb4/src/t4_chip_type.h121
-rw-r--r--contrib/ofed/libcxgb4/src/t4_pci_id_tbl.h218
-rw-r--r--contrib/ofed/libcxgb4/src/t4_regs.h62873
-rw-r--r--contrib/ofed/libcxgb4/src/t4fw_interface.h7811
-rw-r--r--contrib/ofed/libcxgb4/src/verbs.c714
-rw-r--r--contrib/ofed/libcxgb4/t4.h735
-rw-r--r--contrib/ofed/libcxgb4/t4_chip_type.h85
-rw-r--r--contrib/ofed/libcxgb4/t4_pci_id_tbl.h189
-rw-r--r--contrib/ofed/libcxgb4/t4_regs.h3125
-rw-r--r--contrib/ofed/libcxgb4/t4fw_api.h3260
-rw-r--r--contrib/ofed/libcxgb4/t4fw_ri_api.h756
-rw-r--r--contrib/ofed/libcxgb4/verbs.c710
-rw-r--r--contrib/ofed/libibcm/AUTHORS2
-rw-r--r--contrib/ofed/libibcm/COPYING378
-rw-r--r--contrib/ofed/libibcm/ChangeLog0
-rw-r--r--contrib/ofed/libibcm/INSTALL0
-rw-r--r--contrib/ofed/libibcm/Makefile15
-rw-r--r--contrib/ofed/libibcm/Makefile.am34
-rw-r--r--contrib/ofed/libibcm/Makefile.in660
-rw-r--r--contrib/ofed/libibcm/NEWS0
-rw-r--r--contrib/ofed/libibcm/README28
-rw-r--r--contrib/ofed/libibcm/aclocal.m47267
-rw-r--r--contrib/ofed/libibcm/cm.c1023
-rw-r--r--contrib/ofed/libibcm/cm.h592
-rw-r--r--contrib/ofed/libibcm/cm_abi.h73
-rw-r--r--contrib/ofed/libibcm/config.h5
-rw-r--r--contrib/ofed/libibcm/config.h.in67
-rwxr-xr-xcontrib/ofed/libibcm/config/compile142
-rwxr-xr-xcontrib/ofed/libibcm/config/config.guess1466
-rwxr-xr-xcontrib/ofed/libibcm/config/config.sub1579
-rwxr-xr-xcontrib/ofed/libibcm/config/depcomp530
-rwxr-xr-xcontrib/ofed/libibcm/config/install-sh323
-rw-r--r--contrib/ofed/libibcm/config/ltmain.sh6871
-rwxr-xr-xcontrib/ofed/libibcm/config/missing360
-rwxr-xr-xcontrib/ofed/libibcm/configure22105
-rw-r--r--contrib/ofed/libibcm/configure.in71
-rw-r--r--contrib/ofed/libibcm/include/infiniband/cm.h586
-rw-r--r--contrib/ofed/libibcm/include/infiniband/cm_abi.h338
-rw-r--r--contrib/ofed/libibcm/libibcm.map26
-rw-r--r--contrib/ofed/libibcm/libibcm.spec53
-rw-r--r--contrib/ofed/libibcm/libibcm.spec.in53
-rw-r--r--contrib/ofed/libibcm/src/cm.c1047
-rw-r--r--contrib/ofed/libibcm/src/libibcm.map25
-rw-r--r--contrib/ofed/libibmad/Makefile32
-rw-r--r--contrib/ofed/libibmad/bm.c107
-rw-r--r--contrib/ofed/libibmad/cc.c119
-rw-r--r--contrib/ofed/libibmad/config.h89
-rw-r--r--contrib/ofed/libibmad/dump.c1221
-rw-r--r--contrib/ofed/libibmad/fields.c1380
-rw-r--r--contrib/ofed/libibmad/gs.c133
-rw-r--r--contrib/ofed/libibmad/libibmad.map160
-rw-r--r--contrib/ofed/libibmad/mad.c211
-rw-r--r--contrib/ofed/libibmad/mad.h1843
-rw-r--r--contrib/ofed/libibmad/mad_internal.h52
-rw-r--r--contrib/ofed/libibmad/mad_osd.h50
-rw-r--r--contrib/ofed/libibmad/portid.c127
-rw-r--r--contrib/ofed/libibmad/register.c178
-rw-r--r--contrib/ofed/libibmad/resolve.c249
-rw-r--r--contrib/ofed/libibmad/rpc.c456
-rw-r--r--contrib/ofed/libibmad/sa.c192
-rw-r--r--contrib/ofed/libibmad/serv.c205
-rw-r--r--contrib/ofed/libibmad/smp.c150
-rw-r--r--contrib/ofed/libibmad/vendor.c112
-rw-r--r--contrib/ofed/libibnetdisc/Makefile38
-rw-r--r--contrib/ofed/libibnetdisc/chassis.c1344
-rw-r--r--contrib/ofed/libibnetdisc/chassis.h95
-rw-r--r--contrib/ofed/libibnetdisc/config.h125
-rw-r--r--contrib/ofed/libibnetdisc/g_hash_table.cpp86
-rw-r--r--contrib/ofed/libibnetdisc/ibnetdisc.c1003
-rw-r--r--contrib/ofed/libibnetdisc/ibnetdisc.h258
-rw-r--r--contrib/ofed/libibnetdisc/ibnetdisc_cache.c967
-rw-r--r--contrib/ofed/libibnetdisc/ibnetdisc_osd.h50
-rw-r--r--contrib/ofed/libibnetdisc/internal.h130
-rw-r--r--contrib/ofed/libibnetdisc/libibnetdisc.map22
-rw-r--r--contrib/ofed/libibnetdisc/man/ibnd_debug.32
-rw-r--r--contrib/ofed/libibnetdisc/man/ibnd_destroy_fabric.32
-rw-r--r--contrib/ofed/libibnetdisc/man/ibnd_discover_fabric.365
-rw-r--r--contrib/ofed/libibnetdisc/man/ibnd_find_node_dr.32
-rw-r--r--contrib/ofed/libibnetdisc/man/ibnd_find_node_guid.321
-rw-r--r--contrib/ofed/libibnetdisc/man/ibnd_iter_nodes.320
-rw-r--r--contrib/ofed/libibnetdisc/man/ibnd_iter_nodes_type.32
-rw-r--r--contrib/ofed/libibnetdisc/man/ibnd_show_progress.32
-rw-r--r--contrib/ofed/libibnetdisc/query_smp.c286
-rw-r--r--contrib/ofed/libibumad/Makefile16
-rw-r--r--contrib/ofed/libibumad/config.h3
-rw-r--r--contrib/ofed/libibumad/libibumad.map41
-rw-r--r--contrib/ofed/libibumad/sysfs.c273
-rw-r--r--contrib/ofed/libibumad/sysfs.h52
-rw-r--r--contrib/ofed/libibumad/umad.c1112
-rw-r--r--contrib/ofed/libibumad/umad.h269
-rw-r--r--contrib/ofed/libibumad/umad_cm.h67
-rw-r--r--contrib/ofed/libibumad/umad_sa.h148
-rw-r--r--contrib/ofed/libibumad/umad_sm.h128
-rw-r--r--contrib/ofed/libibumad/umad_str.c355
-rw-r--r--contrib/ofed/libibumad/umad_str.h57
-rw-r--r--contrib/ofed/libibumad/umad_types.h217
-rw-r--r--contrib/ofed/libibverbs/AUTHORS4
-rw-r--r--contrib/ofed/libibverbs/COPYING378
-rw-r--r--contrib/ofed/libibverbs/ChangeLog583
-rw-r--r--contrib/ofed/libibverbs/Makefile75
-rw-r--r--contrib/ofed/libibverbs/Makefile.am114
-rw-r--r--contrib/ofed/libibverbs/README164
-rw-r--r--contrib/ofed/libibverbs/alloca.h (renamed from contrib/ofed/usr.lib/libibverbs/alloca.h)0
-rw-r--r--contrib/ofed/libibverbs/arch.h51
-rwxr-xr-xcontrib/ofed/libibverbs/autogen.sh8
-rw-r--r--contrib/ofed/libibverbs/cmd.c2090
-rw-r--r--contrib/ofed/libibverbs/compat-1_0.c1009
-rw-r--r--contrib/ofed/libibverbs/config.h41
-rw-r--r--contrib/ofed/libibverbs/configure.in77
-rw-r--r--contrib/ofed/libibverbs/debian/changelog78
-rw-r--r--contrib/ofed/libibverbs/debian/compat1
-rw-r--r--contrib/ofed/libibverbs/debian/control.in80
-rw-r--r--contrib/ofed/libibverbs/debian/copyright49
-rw-r--r--contrib/ofed/libibverbs/debian/ibverbs-utils.install2
-rw-r--r--contrib/ofed/libibverbs/debian/libibverbs-dev.install3
-rw-r--r--contrib/ofed/libibverbs/debian/libibverbs-dev.links16
-rw-r--r--contrib/ofed/libibverbs/debian/libibverbs1.install1
-rw-r--r--contrib/ofed/libibverbs/debian/libibverbs1.postinst12
-rwxr-xr-xcontrib/ofed/libibverbs/debian/rules9
-rw-r--r--contrib/ofed/libibverbs/debian/watch3
-rw-r--r--contrib/ofed/libibverbs/device.c398
-rw-r--r--contrib/ofed/libibverbs/driver.h325
-rw-r--r--contrib/ofed/libibverbs/enum_strs.c130
-rw-r--r--contrib/ofed/libibverbs/examples/asyncwatch.c62
-rw-r--r--contrib/ofed/libibverbs/examples/build/Makefile10
-rw-r--r--contrib/ofed/libibverbs/examples/build/Makefile.inc11
-rw-r--r--contrib/ofed/libibverbs/examples/build/asyncwatch/Makefile9
-rw-r--r--contrib/ofed/libibverbs/examples/build/device_list/Makefile9
-rw-r--r--contrib/ofed/libibverbs/examples/build/devices/Makefile8
-rw-r--r--contrib/ofed/libibverbs/examples/build/devinfo/Makefile9
-rw-r--r--contrib/ofed/libibverbs/examples/build/rc_pingpong/Makefile9
-rw-r--r--contrib/ofed/libibverbs/examples/build/srq_pingpong/Makefile9
-rw-r--r--contrib/ofed/libibverbs/examples/build/uc_pingpong/Makefile9
-rw-r--r--contrib/ofed/libibverbs/examples/build/ud_pingpong/Makefile9
-rw-r--r--contrib/ofed/libibverbs/examples/device_list.c9
-rw-r--r--contrib/ofed/libibverbs/examples/devinfo.c376
-rw-r--r--contrib/ofed/libibverbs/examples/pingpong.c24
-rw-r--r--contrib/ofed/libibverbs/examples/pingpong.h3
-rw-r--r--contrib/ofed/libibverbs/examples/rc_pingpong.c442
-rw-r--r--contrib/ofed/libibverbs/examples/srq_pingpong.c182
-rw-r--r--contrib/ofed/libibverbs/examples/uc_pingpong.c159
-rw-r--r--contrib/ofed/libibverbs/examples/ud_pingpong.c169
-rw-r--r--contrib/ofed/libibverbs/examples/xsrq_pingpong.c1022
-rw-r--r--contrib/ofed/libibverbs/fixes/XRC_RCV_QP.patch702
-rw-r--r--contrib/ofed/libibverbs/fixes/XRC_base_implementation.patch503
-rw-r--r--contrib/ofed/libibverbs/fixes/XRC_man_pages.patch686
-rw-r--r--contrib/ofed/libibverbs/fixes/configure_in-AC_PROG_LIBTOOL-for-automake.patch25
-rw-r--r--contrib/ofed/libibverbs/fixes/pthread_cond_t_fields.patch62
-rw-r--r--contrib/ofed/libibverbs/fixes/qpt_raw_eth.patch28
-rw-r--r--contrib/ofed/libibverbs/fixes/rocee_examples.patch1051
-rw-r--r--contrib/ofed/libibverbs/fixes/rocee_get_mac.patch112
-rw-r--r--contrib/ofed/libibverbs/fixes/rocee_kernel_accept_link_layer.patch50
-rw-r--r--contrib/ofed/libibverbs/fixes/rocee_link_layer.patch70
-rw-r--r--contrib/ofed/libibverbs/fixes/rpm_spec_changelog_fix.patch13
-rw-r--r--contrib/ofed/libibverbs/fixes/series14
-rw-r--r--contrib/ofed/libibverbs/fixes/verbs_man_page.patch242
-rw-r--r--contrib/ofed/libibverbs/ibverbs.h117
-rw-r--r--contrib/ofed/libibverbs/include/infiniband/arch.h129
-rw-r--r--contrib/ofed/libibverbs/include/infiniband/driver.h172
-rw-r--r--contrib/ofed/libibverbs/include/infiniband/kern-abi.h1024
-rw-r--r--contrib/ofed/libibverbs/include/infiniband/marshall.h65
-rw-r--r--contrib/ofed/libibverbs/include/infiniband/sa-kern-abi.h65
-rw-r--r--contrib/ofed/libibverbs/include/infiniband/sa.h135
-rw-r--r--contrib/ofed/libibverbs/include/infiniband/verbs.h1330
-rw-r--r--contrib/ofed/libibverbs/init.c635
-rw-r--r--contrib/ofed/libibverbs/kern-abi.h1339
-rw-r--r--contrib/ofed/libibverbs/libibverbs.map142
-rw-r--r--contrib/ofed/libibverbs/libibverbs.spec.in146
-rw-r--r--contrib/ofed/libibverbs/man/ibv_alloc_mw.355
-rw-r--r--contrib/ofed/libibverbs/man/ibv_alloc_pd.33
-rw-r--r--contrib/ofed/libibverbs/man/ibv_asyncwatch.115
-rw-r--r--contrib/ofed/libibverbs/man/ibv_attach_mcast.33
-rw-r--r--contrib/ofed/libibverbs/man/ibv_bind_mw.393
-rw-r--r--contrib/ofed/libibverbs/man/ibv_create_ah.33
-rw-r--r--contrib/ofed/libibverbs/man/ibv_create_ah_from_wc.33
-rw-r--r--contrib/ofed/libibverbs/man/ibv_create_comp_channel.33
-rw-r--r--contrib/ofed/libibverbs/man/ibv_create_cq.33
-rw-r--r--contrib/ofed/libibverbs/man/ibv_create_cq_ex.3159
-rw-r--r--contrib/ofed/libibverbs/man/ibv_create_flow.3216
-rw-r--r--contrib/ofed/libibverbs/man/ibv_create_qp.36
-rw-r--r--contrib/ofed/libibverbs/man/ibv_create_qp_ex.3105
-rw-r--r--contrib/ofed/libibverbs/man/ibv_create_rwq_ind_table.359
-rw-r--r--contrib/ofed/libibverbs/man/ibv_create_srq.317
-rw-r--r--contrib/ofed/libibverbs/man/ibv_create_srq_ex.372
-rw-r--r--contrib/ofed/libibverbs/man/ibv_create_wq.372
-rw-r--r--contrib/ofed/libibverbs/man/ibv_create_xrc_rcv_qp.370
-rw-r--r--contrib/ofed/libibverbs/man/ibv_devices.11
-rw-r--r--contrib/ofed/libibverbs/man/ibv_devinfo.13
-rw-r--r--contrib/ofed/libibverbs/man/ibv_event_type_str.31
-rw-r--r--contrib/ofed/libibverbs/man/ibv_fork_init.313
-rw-r--r--contrib/ofed/libibverbs/man/ibv_get_async_event.35
-rw-r--r--contrib/ofed/libibverbs/man/ibv_get_cq_event.33
-rw-r--r--contrib/ofed/libibverbs/man/ibv_get_device_guid.33
-rw-r--r--contrib/ofed/libibverbs/man/ibv_get_device_list.39
-rw-r--r--contrib/ofed/libibverbs/man/ibv_get_device_name.33
-rw-r--r--contrib/ofed/libibverbs/man/ibv_get_srq_num.333
-rw-r--r--contrib/ofed/libibverbs/man/ibv_inc_rkey.333
-rw-r--r--contrib/ofed/libibverbs/man/ibv_modify_qp.315
-rw-r--r--contrib/ofed/libibverbs/man/ibv_modify_srq.33
-rw-r--r--contrib/ofed/libibverbs/man/ibv_modify_wq.346
-rw-r--r--contrib/ofed/libibverbs/man/ibv_modify_xrc_rcv_qp.3141
-rw-r--r--contrib/ofed/libibverbs/man/ibv_open_device.33
-rw-r--r--contrib/ofed/libibverbs/man/ibv_open_qp.352
-rw-r--r--contrib/ofed/libibverbs/man/ibv_open_xrc_domain.380
-rw-r--r--contrib/ofed/libibverbs/man/ibv_open_xrcd.377
-rw-r--r--contrib/ofed/libibverbs/man/ibv_poll_cq.317
-rw-r--r--contrib/ofed/libibverbs/man/ibv_post_recv.33
-rw-r--r--contrib/ofed/libibverbs/man/ibv_post_send.374
-rw-r--r--contrib/ofed/libibverbs/man/ibv_post_srq_recv.33
-rw-r--r--contrib/ofed/libibverbs/man/ibv_query_device.37
-rw-r--r--contrib/ofed/libibverbs/man/ibv_query_device_ex.3106
-rw-r--r--contrib/ofed/libibverbs/man/ibv_query_gid.33
-rw-r--r--contrib/ofed/libibverbs/man/ibv_query_pkey.33
-rw-r--r--contrib/ofed/libibverbs/man/ibv_query_port.36
-rw-r--r--contrib/ofed/libibverbs/man/ibv_query_qp.33
-rw-r--r--contrib/ofed/libibverbs/man/ibv_query_rt_values_ex.351
-rw-r--r--contrib/ofed/libibverbs/man/ibv_query_srq.33
-rw-r--r--contrib/ofed/libibverbs/man/ibv_query_xrc_rcv_qp.389
-rw-r--r--contrib/ofed/libibverbs/man/ibv_rate_to_mbps.346
-rw-r--r--contrib/ofed/libibverbs/man/ibv_rate_to_mult.33
-rw-r--r--contrib/ofed/libibverbs/man/ibv_rc_pingpong.126
-rw-r--r--contrib/ofed/libibverbs/man/ibv_reg_mr.35
-rw-r--r--contrib/ofed/libibverbs/man/ibv_reg_xrc_rcv_qp.357
-rw-r--r--contrib/ofed/libibverbs/man/ibv_req_notify_cq.33
-rw-r--r--contrib/ofed/libibverbs/man/ibv_rereg_mr.377
-rw-r--r--contrib/ofed/libibverbs/man/ibv_resize_cq.33
-rw-r--r--contrib/ofed/libibverbs/man/ibv_srq_pingpong.120
-rw-r--r--contrib/ofed/libibverbs/man/ibv_uc_pingpong.119
-rw-r--r--contrib/ofed/libibverbs/man/ibv_ud_pingpong.111
-rw-r--r--contrib/ofed/libibverbs/man/ibv_xsrq_pingpong.175
-rw-r--r--contrib/ofed/libibverbs/man/verbs.7228
-rw-r--r--contrib/ofed/libibverbs/marshall.c140
-rw-r--r--contrib/ofed/libibverbs/marshall.h65
-rw-r--r--contrib/ofed/libibverbs/memory.c704
-rw-r--r--contrib/ofed/libibverbs/neigh.c848
-rw-r--r--contrib/ofed/libibverbs/neigh.h50
-rw-r--r--contrib/ofed/libibverbs/nl1_compat.h78
-rw-r--r--contrib/ofed/libibverbs/opcode.h (renamed from contrib/ofed/libibverbs/include/infiniband/opcode.h)0
-rw-r--r--contrib/ofed/libibverbs/sa-kern-abi.h41
-rw-r--r--contrib/ofed/libibverbs/sa.h136
-rw-r--r--contrib/ofed/libibverbs/src/cmd.c1409
-rw-r--r--contrib/ofed/libibverbs/src/compat-1_0.c898
-rw-r--r--contrib/ofed/libibverbs/src/device.c280
-rw-r--r--contrib/ofed/libibverbs/src/enum_strs.c127
-rw-r--r--contrib/ofed/libibverbs/src/ibverbs.h105
-rw-r--r--contrib/ofed/libibverbs/src/init.c595
-rw-r--r--contrib/ofed/libibverbs/src/kern_abi.h101
-rw-r--r--contrib/ofed/libibverbs/src/libibverbs.map110
-rw-r--r--contrib/ofed/libibverbs/src/marshall.c142
-rw-r--r--contrib/ofed/libibverbs/src/memory.c642
-rw-r--r--contrib/ofed/libibverbs/src/sysfs.c104
-rw-r--r--contrib/ofed/libibverbs/src/verbs.c754
-rw-r--r--contrib/ofed/libibverbs/sysfs.c102
-rw-r--r--contrib/ofed/libibverbs/verbs.c1021
-rw-r--r--contrib/ofed/libibverbs/verbs.h2376
-rw-r--r--contrib/ofed/libmlx4/AUTHORS1
-rw-r--r--contrib/ofed/libmlx4/COPYING378
-rw-r--r--contrib/ofed/libmlx4/Makefile22
-rw-r--r--contrib/ofed/libmlx4/Makefile.am26
-rw-r--r--contrib/ofed/libmlx4/README58
-rwxr-xr-xcontrib/ofed/libmlx4/autogen.sh8
-rw-r--r--contrib/ofed/libmlx4/buf.c64
-rw-r--r--contrib/ofed/libmlx4/config.h13
-rw-r--r--contrib/ofed/libmlx4/configure.in84
-rw-r--r--contrib/ofed/libmlx4/cq.c819
-rw-r--r--contrib/ofed/libmlx4/dbrec.c151
-rw-r--r--contrib/ofed/libmlx4/debian/changelog11
-rw-r--r--contrib/ofed/libmlx4/debian/compat1
-rw-r--r--contrib/ofed/libmlx4/debian/control.in47
-rw-r--r--contrib/ofed/libmlx4/debian/copyright43
-rw-r--r--contrib/ofed/libmlx4/debian/libmlx4-1.install2
-rw-r--r--contrib/ofed/libmlx4/debian/libmlx4-dev.install1
-rwxr-xr-xcontrib/ofed/libmlx4/debian/rules8
-rw-r--r--contrib/ofed/libmlx4/debian/watch3
-rw-r--r--contrib/ofed/libmlx4/doorbell.h70
-rw-r--r--contrib/ofed/libmlx4/fixes/add_supported_devices.patch35
-rw-r--r--contrib/ofed/libmlx4/fixes/fix_inline_size.patch126
-rw-r--r--contrib/ofed/libmlx4/fixes/lim_qp_resources.patch72
-rw-r--r--contrib/ofed/libmlx4/fixes/post_rcv_end_of_sg.patch29
-rw-r--r--contrib/ofed/libmlx4/fixes/rocee_add_support.patch145
-rw-r--r--contrib/ofed/libmlx4/fixes/series10
-rw-r--r--contrib/ofed/libmlx4/fixes/userspace_dev_lims.patch79
-rw-r--r--contrib/ofed/libmlx4/fixes/xrc_consolidated_v2.patch620
-rw-r--r--contrib/ofed/libmlx4/fixes/xrc_fix_close_domain.patch27
-rw-r--r--contrib/ofed/libmlx4/fixes/xrc_kernel_user_mismatch.patch22
-rw-r--r--contrib/ofed/libmlx4/fixes/xrc_rcv_qp_v2.patch113
-rw-r--r--contrib/ofed/libmlx4/libmlx4.spec.in65
-rw-r--r--contrib/ofed/libmlx4/mlx4-abi.h159
-rw-r--r--contrib/ofed/libmlx4/mlx4.c327
-rw-r--r--contrib/ofed/libmlx4/mlx4.driver1
-rw-r--r--contrib/ofed/libmlx4/mlx4.h458
-rw-r--r--contrib/ofed/libmlx4/mmio.h116
-rw-r--r--contrib/ofed/libmlx4/qp.c776
-rw-r--r--contrib/ofed/libmlx4/src/buf.c83
-rw-r--r--contrib/ofed/libmlx4/src/cq.c508
-rw-r--r--contrib/ofed/libmlx4/src/dbrec.c154
-rw-r--r--contrib/ofed/libmlx4/src/doorbell.h62
-rw-r--r--contrib/ofed/libmlx4/src/mlx4-abi.h118
-rw-r--r--contrib/ofed/libmlx4/src/mlx4.c338
-rw-r--r--contrib/ofed/libmlx4/src/mlx4.h457
-rw-r--r--contrib/ofed/libmlx4/src/mlx4.map5
-rw-r--r--contrib/ofed/libmlx4/src/qp.c706
-rw-r--r--contrib/ofed/libmlx4/src/srq.c225
-rw-r--r--contrib/ofed/libmlx4/src/verbs.c901
-rw-r--r--contrib/ofed/libmlx4/src/wqe.h122
-rw-r--r--contrib/ofed/libmlx4/srq.c325
-rw-r--r--contrib/ofed/libmlx4/verbs.c1255
-rw-r--r--contrib/ofed/libmlx4/wqe.h149
-rw-r--r--contrib/ofed/libmlx5/Makefile24
-rw-r--r--contrib/ofed/libmlx5/bitmap.h111
-rw-r--r--contrib/ofed/libmlx5/buf.c571
-rw-r--r--contrib/ofed/libmlx5/config.h20
-rw-r--r--contrib/ofed/libmlx5/cq.c1519
-rw-r--r--contrib/ofed/libmlx5/dbrec.c148
-rw-r--r--contrib/ofed/libmlx5/doorbell.h67
-rw-r--r--contrib/ofed/libmlx5/libmlx5.map13
-rw-r--r--contrib/ofed/libmlx5/mlx5-abi.h288
-rw-r--r--contrib/ofed/libmlx5/mlx5.c1027
-rw-r--r--contrib/ofed/libmlx5/mlx5.h766
-rw-r--r--contrib/ofed/libmlx5/mlx5dv.744
-rw-r--r--contrib/ofed/libmlx5/mlx5dv.h618
-rw-r--r--contrib/ofed/libmlx5/mlx5dv_init_obj.3130
-rw-r--r--contrib/ofed/libmlx5/mlx5dv_query_device.351
-rw-r--r--contrib/ofed/libmlx5/qp.c1262
-rw-r--r--contrib/ofed/libmlx5/srq.c244
-rw-r--r--contrib/ofed/libmlx5/verbs.c2212
-rw-r--r--contrib/ofed/libmlx5/wqe.h190
-rw-r--r--contrib/ofed/libmthca/AUTHORS2
-rw-r--r--contrib/ofed/libmthca/COPYING378
-rw-r--r--contrib/ofed/libmthca/ChangeLog378
-rw-r--r--contrib/ofed/libmthca/Makefile.am29
-rw-r--r--contrib/ofed/libmthca/README59
-rwxr-xr-xcontrib/ofed/libmthca/autogen.sh8
-rw-r--r--contrib/ofed/libmthca/configure.in77
-rw-r--r--contrib/ofed/libmthca/debian/changelog45
-rw-r--r--contrib/ofed/libmthca/debian/compat1
-rw-r--r--contrib/ofed/libmthca/debian/control.in47
-rw-r--r--contrib/ofed/libmthca/debian/copyright44
-rw-r--r--contrib/ofed/libmthca/debian/libmthca-dev.install1
-rw-r--r--contrib/ofed/libmthca/debian/libmthca1.install2
-rwxr-xr-xcontrib/ofed/libmthca/debian/rules8
-rw-r--r--contrib/ofed/libmthca/debian/watch3
-rw-r--r--contrib/ofed/libmthca/libmthca.spec.in94
-rw-r--r--contrib/ofed/libmthca/mthca.driver1
-rw-r--r--contrib/ofed/libmthca/src/ah.c191
-rw-r--r--contrib/ofed/libmthca/src/buf.c82
-rw-r--r--contrib/ofed/libmthca/src/cq.c633
-rw-r--r--contrib/ofed/libmthca/src/doorbell.h107
-rw-r--r--contrib/ofed/libmthca/src/memfree.c204
-rw-r--r--contrib/ofed/libmthca/src/mthca-abi.h109
-rw-r--r--contrib/ofed/libmthca/src/mthca.c326
-rw-r--r--contrib/ofed/libmthca/src/mthca.h378
-rw-r--r--contrib/ofed/libmthca/src/mthca.map5
-rw-r--r--contrib/ofed/libmthca/src/qp.c963
-rw-r--r--contrib/ofed/libmthca/src/srq.c312
-rw-r--r--contrib/ofed/libmthca/src/verbs.c758
-rw-r--r--contrib/ofed/libmthca/src/wqe.h114
-rw-r--r--contrib/ofed/librdmacm/AUTHORS1
-rw-r--r--contrib/ofed/librdmacm/COPYING378
-rw-r--r--contrib/ofed/librdmacm/ChangeLog0
-rw-r--r--contrib/ofed/librdmacm/INSTALL0
-rw-r--r--contrib/ofed/librdmacm/Makefile71
-rw-r--r--contrib/ofed/librdmacm/Makefile.am74
-rw-r--r--contrib/ofed/librdmacm/Makefile.in974
-rw-r--r--contrib/ofed/librdmacm/NEWS0
-rw-r--r--contrib/ofed/librdmacm/README50
-rw-r--r--contrib/ofed/librdmacm/aclocal.m47267
-rw-r--r--contrib/ofed/librdmacm/acm.c443
-rw-r--r--contrib/ofed/librdmacm/addrinfo.c319
-rw-r--r--contrib/ofed/librdmacm/cma.c2460
-rw-r--r--contrib/ofed/librdmacm/cma.h113
-rw-r--r--contrib/ofed/librdmacm/config.h9
-rw-r--r--contrib/ofed/librdmacm/config.h.in67
-rwxr-xr-xcontrib/ofed/librdmacm/config/compile142
-rwxr-xr-xcontrib/ofed/librdmacm/config/config.guess1466
-rwxr-xr-xcontrib/ofed/librdmacm/config/config.sub1579
-rwxr-xr-xcontrib/ofed/librdmacm/config/depcomp530
-rwxr-xr-xcontrib/ofed/librdmacm/config/install-sh323
-rw-r--r--contrib/ofed/librdmacm/config/ltmain.sh6871
-rwxr-xr-xcontrib/ofed/librdmacm/config/missing360
-rwxr-xr-xcontrib/ofed/librdmacm/configure21957
-rw-r--r--contrib/ofed/librdmacm/configure.in66
-rw-r--r--contrib/ofed/librdmacm/examples/build/Makefile6
-rw-r--r--contrib/ofed/librdmacm/examples/build/Makefile.inc14
-rw-r--r--contrib/ofed/librdmacm/examples/build/cmatose/Makefile10
-rw-r--r--contrib/ofed/librdmacm/examples/build/mckey/Makefile9
-rw-r--r--contrib/ofed/librdmacm/examples/build/rping/Makefile13
-rw-r--r--contrib/ofed/librdmacm/examples/build/ucmatose/Makefile9
-rw-r--r--contrib/ofed/librdmacm/examples/build/udaddy/Makefile11
-rw-r--r--contrib/ofed/librdmacm/examples/cmatose.c156
-rw-r--r--contrib/ofed/librdmacm/examples/cmtime.c677
-rw-r--r--contrib/ofed/librdmacm/examples/common.c167
-rw-r--r--contrib/ofed/librdmacm/examples/common.h86
-rw-r--r--contrib/ofed/librdmacm/examples/mckey.c29
-rw-r--r--contrib/ofed/librdmacm/examples/rcopy.c628
-rw-r--r--contrib/ofed/librdmacm/examples/rdma_client.c166
-rw-r--r--contrib/ofed/librdmacm/examples/rdma_server.c182
-rw-r--r--contrib/ofed/librdmacm/examples/rdma_xclient.c178
-rw-r--r--contrib/ofed/librdmacm/examples/rdma_xserver.c190
-rw-r--r--contrib/ofed/librdmacm/examples/riostream.c674
-rw-r--r--contrib/ofed/librdmacm/examples/rping.c158
-rw-r--r--contrib/ofed/librdmacm/examples/rstream.c707
-rw-r--r--contrib/ofed/librdmacm/examples/udaddy.c120
-rw-r--r--contrib/ofed/librdmacm/examples/udpong.c570
-rw-r--r--contrib/ofed/librdmacm/ib.h98
-rw-r--r--contrib/ofed/librdmacm/include/rdma/rdma_cma.h580
-rw-r--r--contrib/ofed/librdmacm/include/rdma/rdma_cma_abi.h235
-rw-r--r--contrib/ofed/librdmacm/indexer.c164
-rw-r--r--contrib/ofed/librdmacm/indexer.h142
-rw-r--r--contrib/ofed/librdmacm/librdmacm.map69
-rw-r--r--contrib/ofed/librdmacm/librdmacm.spec75
-rw-r--r--contrib/ofed/librdmacm/librdmacm.spec.in75
-rw-r--r--contrib/ofed/librdmacm/librspreload.map33
-rw-r--r--contrib/ofed/librdmacm/man/CMakeLists.txt66
-rw-r--r--contrib/ofed/librdmacm/man/cmtime.150
-rw-r--r--contrib/ofed/librdmacm/man/mckey.13
-rw-r--r--contrib/ofed/librdmacm/man/rcopy.138
-rw-r--r--contrib/ofed/librdmacm/man/rdma_accept.316
-rw-r--r--contrib/ofed/librdmacm/man/rdma_ack_cm_event.34
-rw-r--r--contrib/ofed/librdmacm/man/rdma_bind_addr.34
-rw-r--r--contrib/ofed/librdmacm/man/rdma_client.132
-rw-r--r--contrib/ofed/librdmacm/man/rdma_cm.7136
-rw-r--r--contrib/ofed/librdmacm/man/rdma_connect.312
-rw-r--r--contrib/ofed/librdmacm/man/rdma_create_ep.361
-rw-r--r--contrib/ofed/librdmacm/man/rdma_create_event_channel.34
-rw-r--r--contrib/ofed/librdmacm/man/rdma_create_id.322
-rw-r--r--contrib/ofed/librdmacm/man/rdma_create_qp.323
-rw-r--r--contrib/ofed/librdmacm/man/rdma_create_srq.345
-rw-r--r--contrib/ofed/librdmacm/man/rdma_dereg_mr.329
-rw-r--r--contrib/ofed/librdmacm/man/rdma_destroy_ep.320
-rw-r--r--contrib/ofed/librdmacm/man/rdma_destroy_event_channel.34
-rw-r--r--contrib/ofed/librdmacm/man/rdma_destroy_id.38
-rw-r--r--contrib/ofed/librdmacm/man/rdma_destroy_qp.31
-rw-r--r--contrib/ofed/librdmacm/man/rdma_destroy_srq.322
-rw-r--r--contrib/ofed/librdmacm/man/rdma_disconnect.36
-rw-r--r--contrib/ofed/librdmacm/man/rdma_event_str.33
-rw-r--r--contrib/ofed/librdmacm/man/rdma_free_devices.33
-rw-r--r--contrib/ofed/librdmacm/man/rdma_get_cm_event.318
-rw-r--r--contrib/ofed/librdmacm/man/rdma_get_devices.34
-rw-r--r--contrib/ofed/librdmacm/man/rdma_get_dst_port.34
-rw-r--r--contrib/ofed/librdmacm/man/rdma_get_local_addr.35
-rw-r--r--contrib/ofed/librdmacm/man/rdma_get_peer_addr.35
-rw-r--r--contrib/ofed/librdmacm/man/rdma_get_recv_comp.332
-rw-r--r--contrib/ofed/librdmacm/man/rdma_get_request.335
-rw-r--r--contrib/ofed/librdmacm/man/rdma_get_send_comp.332
-rw-r--r--contrib/ofed/librdmacm/man/rdma_get_src_port.34
-rw-r--r--contrib/ofed/librdmacm/man/rdma_getaddrinfo.3105
-rw-r--r--contrib/ofed/librdmacm/man/rdma_join_multicast.313
-rw-r--r--contrib/ofed/librdmacm/man/rdma_leave_multicast.34
-rw-r--r--contrib/ofed/librdmacm/man/rdma_listen.34
-rw-r--r--contrib/ofed/librdmacm/man/rdma_migrate_id.312
-rw-r--r--contrib/ofed/librdmacm/man/rdma_notify.310
-rw-r--r--contrib/ofed/librdmacm/man/rdma_post_read.356
-rw-r--r--contrib/ofed/librdmacm/man/rdma_post_readv.353
-rw-r--r--contrib/ofed/librdmacm/man/rdma_post_recv.351
-rw-r--r--contrib/ofed/librdmacm/man/rdma_post_recvv.348
-rw-r--r--contrib/ofed/librdmacm/man/rdma_post_send.352
-rw-r--r--contrib/ofed/librdmacm/man/rdma_post_sendv.349
-rw-r--r--contrib/ofed/librdmacm/man/rdma_post_ud_send.355
-rw-r--r--contrib/ofed/librdmacm/man/rdma_post_write.356
-rw-r--r--contrib/ofed/librdmacm/man/rdma_post_writev.353
-rw-r--r--contrib/ofed/librdmacm/man/rdma_reg_msgs.343
-rw-r--r--contrib/ofed/librdmacm/man/rdma_reg_read.342
-rw-r--r--contrib/ofed/librdmacm/man/rdma_reg_write.342
-rw-r--r--contrib/ofed/librdmacm/man/rdma_reject.34
-rw-r--r--contrib/ofed/librdmacm/man/rdma_resolve_addr.34
-rw-r--r--contrib/ofed/librdmacm/man/rdma_resolve_route.34
-rw-r--r--contrib/ofed/librdmacm/man/rdma_server.127
-rw-r--r--contrib/ofed/librdmacm/man/rdma_set_option.36
-rw-r--r--contrib/ofed/librdmacm/man/rdma_xclient.137
-rw-r--r--contrib/ofed/librdmacm/man/rdma_xserver.131
-rw-r--r--contrib/ofed/librdmacm/man/riostream.165
-rw-r--r--contrib/ofed/librdmacm/man/rping.18
-rw-r--r--contrib/ofed/librdmacm/man/rsocket.7.in159
-rw-r--r--contrib/ofed/librdmacm/man/rstream.174
-rw-r--r--contrib/ofed/librdmacm/man/ucmatose.124
-rw-r--r--contrib/ofed/librdmacm/man/udaddy.12
-rw-r--r--contrib/ofed/librdmacm/man/udpong.162
-rw-r--r--contrib/ofed/librdmacm/preload.c1186
-rw-r--r--contrib/ofed/librdmacm/rdma_cma.h681
-rw-r--r--contrib/ofed/librdmacm/rdma_cma_abi.h351
-rw-r--r--contrib/ofed/librdmacm/rdma_verbs.h317
-rw-r--r--contrib/ofed/librdmacm/rsocket.c4343
-rw-r--r--contrib/ofed/librdmacm/rsocket.h99
-rw-r--r--contrib/ofed/librdmacm/src/cma.c1518
-rw-r--r--contrib/ofed/librdmacm/src/librdmacm.map32
-rw-r--r--contrib/ofed/libsdp/COPYING36
-rw-r--r--contrib/ofed/libsdp/ChangeLog117
-rw-r--r--contrib/ofed/libsdp/Makefile.am23
-rw-r--r--contrib/ofed/libsdp/NEWS4
-rw-r--r--contrib/ofed/libsdp/README68
-rwxr-xr-xcontrib/ofed/libsdp/autogen.sh8
-rwxr-xr-xcontrib/ofed/libsdp/changelog_from_git.sh3
-rwxr-xr-xcontrib/ofed/libsdp/config/libsdp_indent71
-rw-r--r--contrib/ofed/libsdp/configure.in59
-rw-r--r--contrib/ofed/libsdp/libsdp.conf145
-rw-r--r--contrib/ofed/libsdp/libsdp.spec.in61
-rw-r--r--contrib/ofed/libsdp/scripts/libsdp.logrotate6
-rw-r--r--contrib/ofed/libsdp/src/Makefile.am29
-rw-r--r--contrib/ofed/libsdp/src/config_parser.c1908
-rw-r--r--contrib/ofed/libsdp/src/config_parser.h97
-rw-r--r--contrib/ofed/libsdp/src/config_parser.y359
-rw-r--r--contrib/ofed/libsdp/src/config_scanner.c1932
-rw-r--r--contrib/ofed/libsdp/src/config_scanner.l214
-rw-r--r--contrib/ofed/libsdp/src/libsdp.h124
-rw-r--r--contrib/ofed/libsdp/src/linux/sdp_inet.h56
-rw-r--r--contrib/ofed/libsdp/src/log.c236
-rw-r--r--contrib/ofed/libsdp/src/match.c340
-rw-r--r--contrib/ofed/libsdp/src/port.c2643
-rw-r--r--contrib/ofed/libsdp/src/socket.c167
-rw-r--r--contrib/ofed/management/AUTHORS3
-rw-r--r--contrib/ofed/management/COPYING384
-rw-r--r--contrib/ofed/management/ChangeLog0
-rw-r--r--contrib/ofed/management/INSTALL0
-rw-r--r--contrib/ofed/management/Makefile21
-rw-r--r--contrib/ofed/management/NEWS0
-rw-r--r--contrib/ofed/management/README132
-rw-r--r--contrib/ofed/management/doc/diagtools-proposal.txt169
-rw-r--r--contrib/ofed/management/doc/diagtools.txt565
-rw-r--r--contrib/ofed/management/doc/ibtracer.txt106
-rw-r--r--contrib/ofed/management/doc/libibmad.txt687
-rw-r--r--contrib/ofed/management/doc/libibumad.txt392
-rwxr-xr-xcontrib/ofed/management/gen_chlog.sh74
-rwxr-xr-xcontrib/ofed/management/gen_ver.sh38
-rw-r--r--contrib/ofed/management/infiniband-diags/COPYING384
-rw-r--r--contrib/ofed/management/infiniband-diags/ChangeLog470
-rw-r--r--contrib/ofed/management/infiniband-diags/Makefile.am125
-rw-r--r--contrib/ofed/management/infiniband-diags/README564
-rwxr-xr-xcontrib/ofed/management/infiniband-diags/autogen.sh11
-rw-r--r--contrib/ofed/management/infiniband-diags/configure.in170
-rw-r--r--contrib/ofed/management/infiniband-diags/include/grouping.h113
-rw-r--r--contrib/ofed/management/infiniband-diags/include/ibdiag_common.h62
-rw-r--r--contrib/ofed/management/infiniband-diags/include/ibdiag_version.h39
-rw-r--r--contrib/ofed/management/infiniband-diags/include/ibdiag_version.h.in39
-rw-r--r--contrib/ofed/management/infiniband-diags/include/ibnetdiscover.h107
-rw-r--r--contrib/ofed/management/infiniband-diags/infiniband-diags.spec.in194
-rw-r--r--contrib/ofed/management/infiniband-diags/man/check_lft_balance.842
-rw-r--r--contrib/ofed/management/infiniband-diags/man/dump_lfts.850
-rw-r--r--contrib/ofed/management/infiniband-diags/man/dump_mfts.845
-rw-r--r--contrib/ofed/management/infiniband-diags/man/ibaddr.8109
-rw-r--r--contrib/ofed/management/infiniband-diags/man/ibcheckerrors.841
-rw-r--r--contrib/ofed/management/infiniband-diags/man/ibcheckerrs.859
-rw-r--r--contrib/ofed/management/infiniband-diags/man/ibchecknet.836
-rw-r--r--contrib/ofed/management/infiniband-diags/man/ibchecknode.843
-rw-r--r--contrib/ofed/management/infiniband-diags/man/ibcheckport.843
-rw-r--r--contrib/ofed/management/infiniband-diags/man/ibcheckportstate.844
-rw-r--r--contrib/ofed/management/infiniband-diags/man/ibcheckportwidth.843
-rw-r--r--contrib/ofed/management/infiniband-diags/man/ibcheckstate.836
-rw-r--r--contrib/ofed/management/infiniband-diags/man/ibcheckwidth.836
-rw-r--r--contrib/ofed/management/infiniband-diags/man/ibclearcounters.830
-rw-r--r--contrib/ofed/management/infiniband-diags/man/ibclearerrors.834
-rw-r--r--contrib/ofed/management/infiniband-diags/man/ibdatacounters.838
-rw-r--r--contrib/ofed/management/infiniband-diags/man/ibdatacounts.848
-rw-r--r--contrib/ofed/management/infiniband-diags/man/ibdiscover.850
-rw-r--r--contrib/ofed/management/infiniband-diags/man/ibfindnodesusing.830
-rw-r--r--contrib/ofed/management/infiniband-diags/man/ibhosts.831
-rw-r--r--contrib/ofed/management/infiniband-diags/man/ibidsverify.836
-rw-r--r--contrib/ofed/management/infiniband-diags/man/iblinkinfo.852
-rw-r--r--contrib/ofed/management/infiniband-diags/man/ibnetdiscover.8233
-rw-r--r--contrib/ofed/management/infiniband-diags/man/ibnodes.831
-rw-r--r--contrib/ofed/management/infiniband-diags/man/ibping.884
-rw-r--r--contrib/ofed/management/infiniband-diags/man/ibportstate.8113
-rw-r--r--contrib/ofed/management/infiniband-diags/man/ibprintca.844
-rw-r--r--contrib/ofed/management/infiniband-diags/man/ibprintrt.842
-rw-r--r--contrib/ofed/management/infiniband-diags/man/ibprintswitch.847
-rw-r--r--contrib/ofed/management/infiniband-diags/man/ibqueryerrors.863
-rw-r--r--contrib/ofed/management/infiniband-diags/man/ibroute.8119
-rw-r--r--contrib/ofed/management/infiniband-diags/man/ibrouters.831
-rw-r--r--contrib/ofed/management/infiniband-diags/man/ibstat.8110
-rw-r--r--contrib/ofed/management/infiniband-diags/man/ibstatus.841
-rw-r--r--contrib/ofed/management/infiniband-diags/man/ibswitches.831
-rw-r--r--contrib/ofed/management/infiniband-diags/man/ibswportwatch.835
-rw-r--r--contrib/ofed/management/infiniband-diags/man/ibsysstat.883
-rw-r--r--contrib/ofed/management/infiniband-diags/man/ibtracert.8112
-rw-r--r--contrib/ofed/management/infiniband-diags/man/perfquery.8124
-rw-r--r--contrib/ofed/management/infiniband-diags/man/saquery.8132
-rw-r--r--contrib/ofed/management/infiniband-diags/man/sminfo.8105
-rw-r--r--contrib/ofed/management/infiniband-diags/man/smpdump.898
-rw-r--r--contrib/ofed/management/infiniband-diags/man/smpquery.8113
-rw-r--r--contrib/ofed/management/infiniband-diags/man/vendstat.884
-rwxr-xr-xcontrib/ofed/management/infiniband-diags/perltidy.sh60
-rwxr-xr-xcontrib/ofed/management/infiniband-diags/scripts/IBswcountlimits.pm501
-rwxr-xr-xcontrib/ofed/management/infiniband-diags/scripts/check_lft_balance.pl321
-rwxr-xr-xcontrib/ofed/management/infiniband-diags/scripts/dump_lfts.sh72
-rwxr-xr-xcontrib/ofed/management/infiniband-diags/scripts/dump_mfts.sh72
-rw-r--r--contrib/ofed/management/infiniband-diags/scripts/ibcheckerrors.in133
-rw-r--r--contrib/ofed/management/infiniband-diags/scripts/ibcheckerrs.in223
-rw-r--r--contrib/ofed/management/infiniband-diags/scripts/ibchecknet.in140
-rw-r--r--contrib/ofed/management/infiniband-diags/scripts/ibchecknode.in100
-rw-r--r--contrib/ofed/management/infiniband-diags/scripts/ibcheckport.in144
-rw-r--r--contrib/ofed/management/infiniband-diags/scripts/ibcheckportstate.in136
-rw-r--r--contrib/ofed/management/infiniband-diags/scripts/ibcheckportwidth.in134
-rw-r--r--contrib/ofed/management/infiniband-diags/scripts/ibcheckstate.in135
-rw-r--r--contrib/ofed/management/infiniband-diags/scripts/ibcheckwidth.in135
-rw-r--r--contrib/ofed/management/infiniband-diags/scripts/ibclearcounters.in107
-rw-r--r--contrib/ofed/management/infiniband-diags/scripts/ibclearerrors.in111
-rw-r--r--contrib/ofed/management/infiniband-diags/scripts/ibdatacounters.in129
-rw-r--r--contrib/ofed/management/infiniband-diags/scripts/ibdatacounts.in164
-rw-r--r--contrib/ofed/management/infiniband-diags/scripts/ibdiscover.map6
-rwxr-xr-xcontrib/ofed/management/infiniband-diags/scripts/ibdiscover.pl86
-rwxr-xr-xcontrib/ofed/management/infiniband-diags/scripts/ibfindnodesusing.pl231
-rw-r--r--contrib/ofed/management/infiniband-diags/scripts/ibhosts.in60
-rwxr-xr-xcontrib/ofed/management/infiniband-diags/scripts/ibidsverify.pl254
-rwxr-xr-xcontrib/ofed/management/infiniband-diags/scripts/iblinkinfo.pl327
-rw-r--r--contrib/ofed/management/infiniband-diags/scripts/ibnodes.in5
-rwxr-xr-xcontrib/ofed/management/infiniband-diags/scripts/ibprintca.pl136
-rwxr-xr-xcontrib/ofed/management/infiniband-diags/scripts/ibprintrt.pl136
-rwxr-xr-xcontrib/ofed/management/infiniband-diags/scripts/ibprintswitch.pl135
-rwxr-xr-xcontrib/ofed/management/infiniband-diags/scripts/ibqueryerrors.pl230
-rw-r--r--contrib/ofed/management/infiniband-diags/scripts/ibrouters.in60
-rwxr-xr-xcontrib/ofed/management/infiniband-diags/scripts/ibstatus77
-rw-r--r--contrib/ofed/management/infiniband-diags/scripts/ibswitches.in79
-rwxr-xr-xcontrib/ofed/management/infiniband-diags/scripts/ibswportwatch.pl174
-rwxr-xr-xcontrib/ofed/management/infiniband-diags/scripts/set_nodedesc.sh57
-rw-r--r--contrib/ofed/management/infiniband-diags/src/grouping.c787
-rw-r--r--contrib/ofed/management/infiniband-diags/src/ibaddr.c217
-rw-r--r--contrib/ofed/management/infiniband-diags/src/ibdiag_common.c78
-rw-r--r--contrib/ofed/management/infiniband-diags/src/ibnetdiscover.c1051
-rw-r--r--contrib/ofed/management/infiniband-diags/src/ibping.c331
-rw-r--r--contrib/ofed/management/infiniband-diags/src/ibportstate.c448
-rw-r--r--contrib/ofed/management/infiniband-diags/src/ibroute.c495
-rw-r--r--contrib/ofed/management/infiniband-diags/src/ibsendtrap.c176
-rw-r--r--contrib/ofed/management/infiniband-diags/src/ibstat.c292
-rw-r--r--contrib/ofed/management/infiniband-diags/src/ibsysstat.c354
-rw-r--r--contrib/ofed/management/infiniband-diags/src/ibtracert.c865
-rw-r--r--contrib/ofed/management/infiniband-diags/src/mcm_rereg_test.c489
-rw-r--r--contrib/ofed/management/infiniband-diags/src/perfquery.c512
-rw-r--r--contrib/ofed/management/infiniband-diags/src/saquery.c1891
-rw-r--r--contrib/ofed/management/infiniband-diags/src/sminfo.c206
-rw-r--r--contrib/ofed/management/infiniband-diags/src/smpdump.c354
-rw-r--r--contrib/ofed/management/infiniband-diags/src/smpquery.c538
-rw-r--r--contrib/ofed/management/infiniband-diags/src/vendstat.c308
-rw-r--r--contrib/ofed/management/libibcommon/AUTHORS3
-rw-r--r--contrib/ofed/management/libibcommon/COPYING384
-rw-r--r--contrib/ofed/management/libibcommon/ChangeLog21
-rw-r--r--contrib/ofed/management/libibcommon/Makefile.am32
-rwxr-xr-xcontrib/ofed/management/libibcommon/autogen.sh11
-rw-r--r--contrib/ofed/management/libibcommon/configure.in52
-rw-r--r--contrib/ofed/management/libibcommon/include/infiniband/common.h149
-rw-r--r--contrib/ofed/management/libibcommon/libibcommon.spec.in72
-rw-r--r--contrib/ofed/management/libibcommon/libibcommon.ver9
-rw-r--r--contrib/ofed/management/libibcommon/src/hash.c153
-rw-r--r--contrib/ofed/management/libibcommon/src/libibcommon.map18
-rw-r--r--contrib/ofed/management/libibcommon/src/stack.c178
-rw-r--r--contrib/ofed/management/libibcommon/src/sysfs.c294
-rw-r--r--contrib/ofed/management/libibcommon/src/time.c47
-rw-r--r--contrib/ofed/management/libibcommon/src/util.c132
-rw-r--r--contrib/ofed/management/libibmad/AUTHORS3
-rw-r--r--contrib/ofed/management/libibmad/COPYING384
-rw-r--r--contrib/ofed/management/libibmad/ChangeLog88
-rw-r--r--contrib/ofed/management/libibmad/Makefile.am34
-rwxr-xr-xcontrib/ofed/management/libibmad/autogen.sh11
-rw-r--r--contrib/ofed/management/libibmad/configure.in70
-rw-r--r--contrib/ofed/management/libibmad/include/infiniband/mad.h905
-rw-r--r--contrib/ofed/management/libibmad/libibmad.spec.in73
-rw-r--r--contrib/ofed/management/libibmad/libibmad.ver9
-rw-r--r--contrib/ofed/management/libibmad/src/dump.c782
-rw-r--r--contrib/ofed/management/libibmad/src/fields.c463
-rw-r--r--contrib/ofed/management/libibmad/src/gs.c241
-rw-r--r--contrib/ofed/management/libibmad/src/libibmad.map110
-rw-r--r--contrib/ofed/management/libibmad/src/mad.c214
-rw-r--r--contrib/ofed/management/libibmad/src/portid.c126
-rw-r--r--contrib/ofed/management/libibmad/src/register.c202
-rw-r--r--contrib/ofed/management/libibmad/src/resolve.c186
-rw-r--r--contrib/ofed/management/libibmad/src/rpc.c402
-rw-r--r--contrib/ofed/management/libibmad/src/sa.c152
-rw-r--r--contrib/ofed/management/libibmad/src/serv.c183
-rw-r--r--contrib/ofed/management/libibmad/src/smp.c123
-rw-r--r--contrib/ofed/management/libibmad/src/vendor.c99
-rw-r--r--contrib/ofed/management/libibumad/AUTHORS3
-rw-r--r--contrib/ofed/management/libibumad/COPYING384
-rw-r--r--contrib/ofed/management/libibumad/ChangeLog94
-rw-r--r--contrib/ofed/management/libibumad/Makefile.am56
-rwxr-xr-xcontrib/ofed/management/libibumad/autogen.sh11
-rw-r--r--contrib/ofed/management/libibumad/configure.in90
-rw-r--r--contrib/ofed/management/libibumad/include/infiniband/umad.h211
-rw-r--r--contrib/ofed/management/libibumad/libibumad.spec.in74
-rw-r--r--contrib/ofed/management/libibumad/libibumad.ver9
-rw-r--r--contrib/ofed/management/libibumad/man/umad_addr_dump.345
-rw-r--r--contrib/ofed/management/libibumad/man/umad_alloc.333
-rw-r--r--contrib/ofed/management/libibumad/man/umad_close_port.326
-rw-r--r--contrib/ofed/management/libibumad/man/umad_debug.329
-rw-r--r--contrib/ofed/management/libibumad/man/umad_dump.322
-rw-r--r--contrib/ofed/management/libibumad/man/umad_free.323
-rw-r--r--contrib/ofed/management/libibumad/man/umad_get_ca.365
-rw-r--r--contrib/ofed/management/libibumad/man/umad_get_ca_portguids.339
-rw-r--r--contrib/ofed/management/libibumad/man/umad_get_cas_names.337
-rw-r--r--contrib/ofed/management/libibumad/man/umad_get_fd.325
-rw-r--r--contrib/ofed/management/libibumad/man/umad_get_issm_path.338
-rw-r--r--contrib/ofed/management/libibumad/man/umad_get_mad.324
-rw-r--r--contrib/ofed/management/libibumad/man/umad_get_mad_addr.342
-rw-r--r--contrib/ofed/management/libibumad/man/umad_get_pkey.323
-rw-r--r--contrib/ofed/management/libibumad/man/umad_get_port.382
-rw-r--r--contrib/ofed/management/libibumad/man/umad_init.339
-rw-r--r--contrib/ofed/management/libibumad/man/umad_open_port.337
-rw-r--r--contrib/ofed/management/libibumad/man/umad_poll.340
-rw-r--r--contrib/ofed/management/libibumad/man/umad_recv.340
-rw-r--r--contrib/ofed/management/libibumad/man/umad_register.336
-rw-r--r--contrib/ofed/management/libibumad/man/umad_register_oui.337
-rw-r--r--contrib/ofed/management/libibumad/man/umad_send.337
-rw-r--r--contrib/ofed/management/libibumad/man/umad_set_addr.333
-rw-r--r--contrib/ofed/management/libibumad/man/umad_set_addr_net.333
-rw-r--r--contrib/ofed/management/libibumad/man/umad_set_grh.375
-rw-r--r--contrib/ofed/management/libibumad/man/umad_set_grh_net.376
-rw-r--r--contrib/ofed/management/libibumad/man/umad_set_pkey.322
-rw-r--r--contrib/ofed/management/libibumad/man/umad_size.320
-rw-r--r--contrib/ofed/management/libibumad/man/umad_status.326
-rw-r--r--contrib/ofed/management/libibumad/man/umad_unregister.330
-rw-r--r--contrib/ofed/management/libibumad/src/libibumad.map34
-rw-r--r--contrib/ofed/management/libibumad/src/umad.c1036
-rwxr-xr-xcontrib/ofed/management/make.dist144
-rw-r--r--contrib/ofed/management/opensm/AUTHORS9
-rw-r--r--contrib/ofed/management/opensm/COPYING32
-rw-r--r--contrib/ofed/management/opensm/ChangeLog14
-rw-r--r--contrib/ofed/management/opensm/INSTALL231
-rw-r--r--contrib/ofed/management/opensm/Makefile.am32
-rw-r--r--contrib/ofed/management/opensm/NEWS2
-rw-r--r--contrib/ofed/management/opensm/README25
-rwxr-xr-xcontrib/ofed/management/opensm/autogen.sh57
-rw-r--r--contrib/ofed/management/opensm/complib/ChangeLog96
-rw-r--r--contrib/ofed/management/opensm/complib/Makefile.am81
-rw-r--r--contrib/ofed/management/opensm/complib/cl_complib.c92
-rw-r--r--contrib/ofed/management/opensm/complib/cl_dispatcher.c377
-rw-r--r--contrib/ofed/management/opensm/complib/cl_event.c175
-rw-r--r--contrib/ofed/management/opensm/complib/cl_event_wheel.c573
-rw-r--r--contrib/ofed/management/opensm/complib/cl_list.c581
-rw-r--r--contrib/ofed/management/opensm/complib/cl_log.c118
-rw-r--r--contrib/ofed/management/opensm/complib/cl_map.c1636
-rw-r--r--contrib/ofed/management/opensm/complib/cl_nodenamemap.c194
-rw-r--r--contrib/ofed/management/opensm/complib/cl_pool.c671
-rw-r--r--contrib/ofed/management/opensm/complib/cl_ptr_vector.c319
-rw-r--r--contrib/ofed/management/opensm/complib/cl_thread.c140
-rw-r--r--contrib/ofed/management/opensm/complib/cl_threadpool.c148
-rw-r--r--contrib/ofed/management/opensm/complib/cl_timer.c446
-rw-r--r--contrib/ofed/management/opensm/complib/cl_vector.c561
-rw-r--r--contrib/ofed/management/opensm/complib/libosmcomp.map154
-rw-r--r--contrib/ofed/management/opensm/complib/libosmcomp.ver9
-rw-r--r--contrib/ofed/management/opensm/config/osmvsel.m4259
-rw-r--r--contrib/ofed/management/opensm/configure.in232
-rw-r--r--contrib/ofed/management/opensm/doc/OpenSM_PKey_Mgr.txt78
-rw-r--r--contrib/ofed/management/opensm/doc/OpenSM_RN.pdfbin117072 -> 0 bytes
-rw-r--r--contrib/ofed/management/opensm/doc/OpenSM_UM.pdfbin307923 -> 0 bytes
-rw-r--r--contrib/ofed/management/opensm/doc/QoS_management_in_OpenSM.txt492
-rw-r--r--contrib/ofed/management/opensm/doc/current-routing.txt346
-rw-r--r--contrib/ofed/management/opensm/doc/modular-routing.txt77
-rw-r--r--contrib/ofed/management/opensm/doc/opensm-coding-style.txt34
-rw-r--r--contrib/ofed/management/opensm/doc/opensm_release_notes-3.1.10.txt492
-rw-r--r--contrib/ofed/management/opensm/doc/opensm_release_notes-3.1.11.txt492
-rw-r--r--contrib/ofed/management/opensm/doc/opensm_release_notes-3.2.txt618
-rw-r--r--contrib/ofed/management/opensm/doc/opensm_release_notes_ibg2-2.0.1.txt456
-rw-r--r--contrib/ofed/management/opensm/doc/opensm_release_notes_openib-1.2.1.txt460
-rw-r--r--contrib/ofed/management/opensm/doc/opensm_release_notes_openib-2.0.5.txt486
-rw-r--r--contrib/ofed/management/opensm/doc/opensm_release_notes_openib-3.0.13.txt535
-rw-r--r--contrib/ofed/management/opensm/doc/partition-config.txt110
-rw-r--r--contrib/ofed/management/opensm/doc/perf-manager-arch.txt181
-rw-r--r--contrib/ofed/management/opensm/doc/performance-manager-HOWTO.txt153
-rw-r--r--contrib/ofed/management/opensm/doc/qos-config.txt44
-rw-r--r--contrib/ofed/management/opensm/doc/todo27
-rw-r--r--contrib/ofed/management/opensm/include/Makefile.am33
-rw-r--r--contrib/ofed/management/opensm/include/complib/cl_atomic.h196
-rw-r--r--contrib/ofed/management/opensm/include/complib/cl_atomic_osd.h104
-rw-r--r--contrib/ofed/management/opensm/include/complib/cl_byteswap.h525
-rw-r--r--contrib/ofed/management/opensm/include/complib/cl_byteswap_osd.h75
-rw-r--r--contrib/ofed/management/opensm/include/complib/cl_event_wheel.h457
-rw-r--r--contrib/ofed/management/opensm/include/complib/cl_fleximap.h907
-rw-r--r--contrib/ofed/management/opensm/include/complib/cl_nodenamemap.h65
-rw-r--r--contrib/ofed/management/opensm/include/complib/cl_packon.h83
-rw-r--r--contrib/ofed/management/opensm/include/complib/cl_passivelock.h323
-rw-r--r--contrib/ofed/management/opensm/include/complib/cl_ptr_vector.h825
-rw-r--r--contrib/ofed/management/opensm/include/complib/cl_spinlock.h272
-rw-r--r--contrib/ofed/management/opensm/include/complib/cl_threadpool.h248
-rw-r--r--contrib/ofed/management/opensm/include/complib/cl_types.h472
-rw-r--r--contrib/ofed/management/opensm/include/complib/cl_types_osd.h88
-rw-r--r--contrib/ofed/management/opensm/include/complib/cl_vector.h945
-rw-r--r--contrib/ofed/management/opensm/include/iba/ib_cm_types.h203
-rw-r--r--contrib/ofed/management/opensm/include/iba/ib_types.h10720
-rw-r--r--contrib/ofed/management/opensm/include/opensm/osm_attrib_req.h108
-rw-r--r--contrib/ofed/management/opensm/include/opensm/osm_base.h898
-rw-r--r--contrib/ofed/management/opensm/include/opensm/osm_config.h65
-rw-r--r--contrib/ofed/management/opensm/include/opensm/osm_config.h.in64
-rw-r--r--contrib/ofed/management/opensm/include/opensm/osm_console.h51
-rw-r--r--contrib/ofed/management/opensm/include/opensm/osm_console_io.h90
-rw-r--r--contrib/ofed/management/opensm/include/opensm/osm_db.h427
-rw-r--r--contrib/ofed/management/opensm/include/opensm/osm_db_pack.h243
-rw-r--r--contrib/ofed/management/opensm/include/opensm/osm_event_plugin.h192
-rw-r--r--contrib/ofed/management/opensm/include/opensm/osm_helper.h550
-rw-r--r--contrib/ofed/management/opensm/include/opensm/osm_inform.h238
-rw-r--r--contrib/ofed/management/opensm/include/opensm/osm_lid_mgr.h289
-rw-r--r--contrib/ofed/management/opensm/include/opensm/osm_log.h482
-rw-r--r--contrib/ofed/management/opensm/include/opensm/osm_mad_pool.h372
-rw-r--r--contrib/ofed/management/opensm/include/opensm/osm_madw.h1115
-rw-r--r--contrib/ofed/management/opensm/include/opensm/osm_mcast_tbl.h461
-rw-r--r--contrib/ofed/management/opensm/include/opensm/osm_mcm_info.h136
-rw-r--r--contrib/ofed/management/opensm/include/opensm/osm_mcm_port.h158
-rw-r--r--contrib/ofed/management/opensm/include/opensm/osm_msgdef.h167
-rw-r--r--contrib/ofed/management/opensm/include/opensm/osm_mtree.h274
-rw-r--r--contrib/ofed/management/opensm/include/opensm/osm_multicast.h503
-rw-r--r--contrib/ofed/management/opensm/include/opensm/osm_node.h679
-rw-r--r--contrib/ofed/management/opensm/include/opensm/osm_opensm.h527
-rw-r--r--contrib/ofed/management/opensm/include/opensm/osm_partition.h273
-rw-r--r--contrib/ofed/management/opensm/include/opensm/osm_path.h250
-rw-r--r--contrib/ofed/management/opensm/include/opensm/osm_perfmgr.h250
-rw-r--r--contrib/ofed/management/opensm/include/opensm/osm_perfmgr_db.h209
-rw-r--r--contrib/ofed/management/opensm/include/opensm/osm_pkey.h636
-rw-r--r--contrib/ofed/management/opensm/include/opensm/osm_pkey_mgr.h80
-rw-r--r--contrib/ofed/management/opensm/include/opensm/osm_port.h1591
-rw-r--r--contrib/ofed/management/opensm/include/opensm/osm_port_profile.h207
-rw-r--r--contrib/ofed/management/opensm/include/opensm/osm_qos_policy.h204
-rw-r--r--contrib/ofed/management/opensm/include/opensm/osm_remote_sm.h198
-rw-r--r--contrib/ofed/management/opensm/include/opensm/osm_router.h217
-rw-r--r--contrib/ofed/management/opensm/include/opensm/osm_sa.h496
-rw-r--r--contrib/ofed/management/opensm/include/opensm/osm_sa_mad_ctrl.h338
-rw-r--r--contrib/ofed/management/opensm/include/opensm/osm_service.h194
-rw-r--r--contrib/ofed/management/opensm/include/opensm/osm_sm.h798
-rw-r--r--contrib/ofed/management/opensm/include/opensm/osm_sm_mad_ctrl.h323
-rw-r--r--contrib/ofed/management/opensm/include/opensm/osm_subnet.h1106
-rw-r--r--contrib/ofed/management/opensm/include/opensm/osm_switch.h1152
-rw-r--r--contrib/ofed/management/opensm/include/opensm/osm_ucast_cache.h240
-rw-r--r--contrib/ofed/management/opensm/include/opensm/osm_ucast_mgr.h308
-rw-r--r--contrib/ofed/management/opensm/include/opensm/osm_version.h51
-rw-r--r--contrib/ofed/management/opensm/include/opensm/osm_version.h.in51
-rw-r--r--contrib/ofed/management/opensm/include/opensm/osm_vl15intf.h367
-rw-r--r--contrib/ofed/management/opensm/include/opensm/st.h102
-rw-r--r--contrib/ofed/management/opensm/include/vendor/osm_vendor.h71
-rw-r--r--contrib/ofed/management/opensm/include/vendor/osm_vendor_api.h487
-rw-r--r--contrib/ofed/management/opensm/include/vendor/osm_vendor_ibumad.h181
-rw-r--r--contrib/ofed/management/opensm/include/vendor/osm_vendor_mlx.h96
-rw-r--r--contrib/ofed/management/opensm/include/vendor/osm_vendor_mlx_defs.h103
-rw-r--r--contrib/ofed/management/opensm/include/vendor/osm_vendor_mlx_svc.h201
-rw-r--r--contrib/ofed/management/opensm/include/vendor/osm_vendor_sa_api.h866
-rw-r--r--contrib/ofed/management/opensm/libvendor/ChangeLog64
-rw-r--r--contrib/ofed/management/opensm/libvendor/Makefile.am86
-rw-r--r--contrib/ofed/management/opensm/libvendor/libosmvendor.ver9
-rw-r--r--contrib/ofed/management/opensm/libvendor/osm_pkt_randomizer.c329
-rw-r--r--contrib/ofed/management/opensm/libvendor/osm_vendor_al.c1320
-rw-r--r--contrib/ofed/management/opensm/libvendor/osm_vendor_ibumad.c1154
-rw-r--r--contrib/ofed/management/opensm/libvendor/osm_vendor_ibumad_sa.c736
-rw-r--r--contrib/ofed/management/opensm/libvendor/osm_vendor_mlx.c770
-rw-r--r--contrib/ofed/management/opensm/libvendor/osm_vendor_mlx_anafa.c753
-rw-r--r--contrib/ofed/management/opensm/libvendor/osm_vendor_mlx_dispatcher.c710
-rw-r--r--contrib/ofed/management/opensm/libvendor/osm_vendor_mlx_hca.c524
-rw-r--r--contrib/ofed/management/opensm/libvendor/osm_vendor_mlx_hca_anafa.c194
-rw-r--r--contrib/ofed/management/opensm/libvendor/osm_vendor_mlx_hca_pfs.c751
-rw-r--r--contrib/ofed/management/opensm/libvendor/osm_vendor_mlx_hca_sim.c864
-rw-r--r--contrib/ofed/management/opensm/libvendor/osm_vendor_mlx_rmpp_ctx.c361
-rw-r--r--contrib/ofed/management/opensm/libvendor/osm_vendor_mlx_sa.c834
-rw-r--r--contrib/ofed/management/opensm/libvendor/osm_vendor_mlx_sender.c390
-rw-r--r--contrib/ofed/management/opensm/libvendor/osm_vendor_mlx_txn.c675
-rw-r--r--contrib/ofed/management/opensm/libvendor/osm_vendor_mtl.c1105
-rw-r--r--contrib/ofed/management/opensm/libvendor/osm_vendor_mtl_hca_guid.c635
-rw-r--r--contrib/ofed/management/opensm/libvendor/osm_vendor_mtl_transaction_mgr.c546
-rw-r--r--contrib/ofed/management/opensm/libvendor/osm_vendor_test.c282
-rw-r--r--contrib/ofed/management/opensm/libvendor/osm_vendor_ts.c904
-rw-r--r--contrib/ofed/management/opensm/libvendor/osm_vendor_umadt.c1117
-rw-r--r--contrib/ofed/management/opensm/man/opensm.81012
-rw-r--r--contrib/ofed/management/opensm/man/opensm.8.in1012
-rw-r--r--contrib/ofed/management/opensm/man/osmtest.8190
-rw-r--r--contrib/ofed/management/opensm/opensm.spec.in146
-rw-r--r--contrib/ofed/management/opensm/opensm/ChangeLog115
-rw-r--r--contrib/ofed/management/opensm/opensm/Makefile.am131
-rw-r--r--contrib/ofed/management/opensm/opensm/libopensm.map59
-rw-r--r--contrib/ofed/management/opensm/opensm/libopensm.ver9
-rw-r--r--contrib/ofed/management/opensm/opensm/main.c1027
-rwxr-xr-xcontrib/ofed/management/opensm/opensm/osm_check282
-rwxr-xr-xcontrib/ofed/management/opensm/opensm/osm_check_n_fix517
-rw-r--r--contrib/ofed/management/opensm/opensm/osm_console.c1330
-rw-r--r--contrib/ofed/management/opensm/opensm/osm_console_io.c254
-rw-r--r--contrib/ofed/management/opensm/opensm/osm_db_files.c723
-rw-r--r--contrib/ofed/management/opensm/opensm/osm_db_pack.c157
-rw-r--r--contrib/ofed/management/opensm/opensm/osm_drop_mgr.c516
-rw-r--r--contrib/ofed/management/opensm/opensm/osm_dump.c642
-rw-r--r--contrib/ofed/management/opensm/opensm/osm_event_plugin.c150
-rw-r--r--contrib/ofed/management/opensm/opensm/osm_helper.c2334
-rwxr-xr-xcontrib/ofed/management/opensm/opensm/osm_indent56
-rw-r--r--contrib/ofed/management/opensm/opensm/osm_inform.c616
-rw-r--r--contrib/ofed/management/opensm/opensm/osm_lid_mgr.c1321
-rw-r--r--contrib/ofed/management/opensm/opensm/osm_lin_fwd_rcv.c101
-rw-r--r--contrib/ofed/management/opensm/opensm/osm_link_mgr.c416
-rw-r--r--contrib/ofed/management/opensm/opensm/osm_log.c337
-rw-r--r--contrib/ofed/management/opensm/opensm/osm_mad_pool.c188
-rw-r--r--contrib/ofed/management/opensm/opensm/osm_mcast_fwd_rcv.c121
-rw-r--r--contrib/ofed/management/opensm/opensm/osm_mcast_mgr.c1267
-rw-r--r--contrib/ofed/management/opensm/opensm/osm_mcast_tbl.c284
-rw-r--r--contrib/ofed/management/opensm/opensm/osm_mcm_info.c70
-rw-r--r--contrib/ofed/management/opensm/opensm/osm_mcm_port.c76
-rw-r--r--contrib/ofed/management/opensm/opensm/osm_mtree.c125
-rw-r--r--contrib/ofed/management/opensm/opensm/osm_multicast.c302
-rw-r--r--contrib/ofed/management/opensm/opensm/osm_node.c312
-rw-r--r--contrib/ofed/management/opensm/opensm/osm_node_desc_rcv.c128
-rw-r--r--contrib/ofed/management/opensm/opensm/osm_node_info_rcv.c849
-rw-r--r--contrib/ofed/management/opensm/opensm/osm_opensm.c497
-rw-r--r--contrib/ofed/management/opensm/opensm/osm_perfmgr.c1311
-rw-r--r--contrib/ofed/management/opensm/opensm/osm_perfmgr_db.c807
-rw-r--r--contrib/ofed/management/opensm/opensm/osm_pkey.c467
-rw-r--r--contrib/ofed/management/opensm/opensm/osm_pkey_mgr.c528
-rw-r--r--contrib/ofed/management/opensm/opensm/osm_pkey_rcv.c145
-rw-r--r--contrib/ofed/management/opensm/opensm/osm_port.c780
-rw-r--r--contrib/ofed/management/opensm/opensm/osm_port_info_rcv.c687
-rw-r--r--contrib/ofed/management/opensm/opensm/osm_prtn.c392
-rw-r--r--contrib/ofed/management/opensm/opensm/osm_prtn_config.c462
-rw-r--r--contrib/ofed/management/opensm/opensm/osm_qos.c413
-rw-r--r--contrib/ofed/management/opensm/opensm/osm_qos_parser_l.l394
-rw-r--r--contrib/ofed/management/opensm/opensm/osm_qos_parser_y.y3063
-rw-r--r--contrib/ofed/management/opensm/opensm/osm_qos_policy.c1091
-rw-r--r--contrib/ofed/management/opensm/opensm/osm_remote_sm.c79
-rw-r--r--contrib/ofed/management/opensm/opensm/osm_req.c280
-rw-r--r--contrib/ofed/management/opensm/opensm/osm_resp.c157
-rw-r--r--contrib/ofed/management/opensm/opensm/osm_router.c75
-rw-r--r--contrib/ofed/management/opensm/opensm/osm_sa.c1123
-rw-r--r--contrib/ofed/management/opensm/opensm/osm_sa_class_port_info.c213
-rw-r--r--contrib/ofed/management/opensm/opensm/osm_sa_guidinfo_record.c362
-rw-r--r--contrib/ofed/management/opensm/opensm/osm_sa_informinfo.c626
-rw-r--r--contrib/ofed/management/opensm/opensm/osm_sa_lft_record.c246
-rw-r--r--contrib/ofed/management/opensm/opensm/osm_sa_link_record.c505
-rw-r--r--contrib/ofed/management/opensm/opensm/osm_sa_mad_ctrl.c592
-rw-r--r--contrib/ofed/management/opensm/opensm/osm_sa_mcmember_record.c1735
-rw-r--r--contrib/ofed/management/opensm/opensm/osm_sa_mft_record.c280
-rw-r--r--contrib/ofed/management/opensm/opensm/osm_sa_multipath_record.c1536
-rw-r--r--contrib/ofed/management/opensm/opensm/osm_sa_node_record.c355
-rw-r--r--contrib/ofed/management/opensm/opensm/osm_sa_path_record.c1813
-rw-r--r--contrib/ofed/management/opensm/opensm/osm_sa_pkey_record.c341
-rw-r--r--contrib/ofed/management/opensm/opensm/osm_sa_portinfo_record.c592
-rw-r--r--contrib/ofed/management/opensm/opensm/osm_sa_service_record.c842
-rw-r--r--contrib/ofed/management/opensm/opensm/osm_sa_slvl_record.c313
-rw-r--r--contrib/ofed/management/opensm/opensm/osm_sa_sminfo_record.c331
-rw-r--r--contrib/ofed/management/opensm/opensm/osm_sa_sw_info_record.c273
-rw-r--r--contrib/ofed/management/opensm/opensm/osm_sa_vlarb_record.c330
-rw-r--r--contrib/ofed/management/opensm/opensm/osm_service.c166
-rw-r--r--contrib/ofed/management/opensm/opensm/osm_slvl_map_rcv.c152
-rw-r--r--contrib/ofed/management/opensm/opensm/osm_sm.c655
-rw-r--r--contrib/ofed/management/opensm/opensm/osm_sm_mad_ctrl.c874
-rw-r--r--contrib/ofed/management/opensm/opensm/osm_sm_state_mgr.c551
-rw-r--r--contrib/ofed/management/opensm/opensm/osm_sminfo_rcv.c604
-rw-r--r--contrib/ofed/management/opensm/opensm/osm_state_mgr.c1396
-rw-r--r--contrib/ofed/management/opensm/opensm/osm_subnet.c1719
-rw-r--r--contrib/ofed/management/opensm/opensm/osm_sw_info_rcv.c506
-rw-r--r--contrib/ofed/management/opensm/opensm/osm_switch.c667
-rw-r--r--contrib/ofed/management/opensm/opensm/osm_trap_rcv.c714
-rw-r--r--contrib/ofed/management/opensm/opensm/osm_ucast_cache.c1095
-rw-r--r--contrib/ofed/management/opensm/opensm/osm_ucast_file.c396
-rw-r--r--contrib/ofed/management/opensm/opensm/osm_ucast_ftree.c3673
-rw-r--r--contrib/ofed/management/opensm/opensm/osm_ucast_lash.c1356
-rw-r--r--contrib/ofed/management/opensm/opensm/osm_ucast_mgr.c903
-rw-r--r--contrib/ofed/management/opensm/opensm/osm_ucast_updn.c686
-rw-r--r--contrib/ofed/management/opensm/opensm/osm_vl15intf.c386
-rw-r--r--contrib/ofed/management/opensm/opensm/osm_vl_arb_rcv.c154
-rw-r--r--contrib/ofed/management/opensm/opensm/st.c588
-rw-r--r--contrib/ofed/management/opensm/osmeventplugin/Makefile.am34
-rw-r--r--contrib/ofed/management/opensm/osmeventplugin/libosmeventplugin.map5
-rw-r--r--contrib/ofed/management/opensm/osmeventplugin/libosmeventplugin.ver9
-rw-r--r--contrib/ofed/management/opensm/osmeventplugin/src/osmeventplugin.c188
-rw-r--r--contrib/ofed/management/opensm/osmtest/Makefile.am23
-rw-r--r--contrib/ofed/management/opensm/osmtest/include/osmt_inform.h78
-rw-r--r--contrib/ofed/management/opensm/osmtest/include/osmt_mtl_regular_qp.h162
-rw-r--r--contrib/ofed/management/opensm/osmtest/include/osmtest.h510
-rw-r--r--contrib/ofed/management/opensm/osmtest/include/osmtest_base.h67
-rw-r--r--contrib/ofed/management/opensm/osmtest/include/osmtest_subnet.h326
-rw-r--r--contrib/ofed/management/opensm/osmtest/main.c624
-rw-r--r--contrib/ofed/management/opensm/osmtest/osmt_inform.c767
-rw-r--r--contrib/ofed/management/opensm/osmtest/osmt_mtl_regular_qp.c469
-rw-r--r--contrib/ofed/management/opensm/osmtest/osmt_multicast.c2708
-rw-r--r--contrib/ofed/management/opensm/osmtest/osmt_service.c1616
-rw-r--r--contrib/ofed/management/opensm/osmtest/osmt_slvl_vl_arb.c528
-rw-r--r--contrib/ofed/management/opensm/osmtest/osmtest.c7403
-rw-r--r--contrib/ofed/management/opensm/scripts/opensm.init.in133
-rw-r--r--contrib/ofed/management/opensm/scripts/opensm.logrotate7
-rw-r--r--contrib/ofed/management/opensm/scripts/opensm.sysconfig2
-rwxr-xr-xcontrib/ofed/management/opensm/scripts/redhat-opensm.init.in292
-rwxr-xr-xcontrib/ofed/management/opensm/scripts/sldd.sh.in246
-rw-r--r--contrib/ofed/opensm/complib/Makefile34
-rw-r--r--contrib/ofed/opensm/complib/cl_complib.c90
-rw-r--r--contrib/ofed/opensm/complib/cl_dispatcher.c366
-rw-r--r--contrib/ofed/opensm/complib/cl_event.c175
-rw-r--r--contrib/ofed/opensm/complib/cl_event_wheel.c570
-rw-r--r--contrib/ofed/opensm/complib/cl_list.c564
-rw-r--r--contrib/ofed/opensm/complib/cl_log.c117
-rw-r--r--contrib/ofed/opensm/complib/cl_map.c1622
-rw-r--r--contrib/ofed/opensm/complib/cl_nodenamemap.c229
-rw-r--r--contrib/ofed/opensm/complib/cl_pool.c656
-rw-r--r--contrib/ofed/opensm/complib/cl_ptr_vector.c313
-rw-r--r--contrib/ofed/opensm/complib/cl_spinlock.c (renamed from contrib/ofed/management/opensm/complib/cl_spinlock.c)0
-rw-r--r--contrib/ofed/opensm/complib/cl_statustext.c (renamed from contrib/ofed/management/opensm/complib/cl_statustext.c)0
-rw-r--r--contrib/ofed/opensm/complib/cl_thread.c140
-rw-r--r--contrib/ofed/opensm/complib/cl_threadpool.c150
-rw-r--r--contrib/ofed/opensm/complib/cl_timer.c437
-rw-r--r--contrib/ofed/opensm/complib/cl_vector.c548
-rw-r--r--contrib/ofed/opensm/complib/ib_statustext.c (renamed from contrib/ofed/management/opensm/complib/ib_statustext.c)0
-rw-r--r--contrib/ofed/opensm/complib/libosmcomp.map155
-rw-r--r--contrib/ofed/opensm/complib/libosmcomp.ver9
-rw-r--r--contrib/ofed/opensm/config.h165
-rw-r--r--contrib/ofed/opensm/include/complib/cl_atomic.h192
-rw-r--r--contrib/ofed/opensm/include/complib/cl_atomic_osd.h106
-rw-r--r--contrib/ofed/opensm/include/complib/cl_byteswap.h524
-rw-r--r--contrib/ofed/opensm/include/complib/cl_byteswap_osd.h75
-rw-r--r--contrib/ofed/opensm/include/complib/cl_comppool.h (renamed from contrib/ofed/management/opensm/include/complib/cl_comppool.h)0
-rw-r--r--contrib/ofed/opensm/include/complib/cl_debug.h (renamed from contrib/ofed/management/opensm/include/complib/cl_debug.h)0
-rw-r--r--contrib/ofed/opensm/include/complib/cl_debug_osd.h (renamed from contrib/ofed/management/opensm/include/complib/cl_debug_osd.h)0
-rw-r--r--contrib/ofed/opensm/include/complib/cl_dispatcher.h (renamed from contrib/ofed/management/opensm/include/complib/cl_dispatcher.h)0
-rw-r--r--contrib/ofed/opensm/include/complib/cl_event.h (renamed from contrib/ofed/management/opensm/include/complib/cl_event.h)0
-rw-r--r--contrib/ofed/opensm/include/complib/cl_event_osd.h (renamed from contrib/ofed/management/opensm/include/complib/cl_event_osd.h)0
-rw-r--r--contrib/ofed/opensm/include/complib/cl_event_wheel.h457
-rw-r--r--contrib/ofed/opensm/include/complib/cl_fleximap.h943
-rw-r--r--contrib/ofed/opensm/include/complib/cl_list.h (renamed from contrib/ofed/management/opensm/include/complib/cl_list.h)0
-rw-r--r--contrib/ofed/opensm/include/complib/cl_log.h (renamed from contrib/ofed/management/opensm/include/complib/cl_log.h)0
-rw-r--r--contrib/ofed/opensm/include/complib/cl_map.h (renamed from contrib/ofed/management/opensm/include/complib/cl_map.h)0
-rw-r--r--contrib/ofed/opensm/include/complib/cl_math.h (renamed from contrib/ofed/management/opensm/include/complib/cl_math.h)0
-rw-r--r--contrib/ofed/opensm/include/complib/cl_nodenamemap.h64
-rw-r--r--contrib/ofed/opensm/include/complib/cl_packoff.h (renamed from contrib/ofed/management/opensm/include/complib/cl_packoff.h)0
-rw-r--r--contrib/ofed/opensm/include/complib/cl_packon.h83
-rw-r--r--contrib/ofed/opensm/include/complib/cl_passivelock.h323
-rw-r--r--contrib/ofed/opensm/include/complib/cl_pool.h (renamed from contrib/ofed/management/opensm/include/complib/cl_pool.h)0
-rw-r--r--contrib/ofed/opensm/include/complib/cl_ptr_vector.h825
-rw-r--r--contrib/ofed/opensm/include/complib/cl_qcomppool.h (renamed from contrib/ofed/management/opensm/include/complib/cl_qcomppool.h)0
-rw-r--r--contrib/ofed/opensm/include/complib/cl_qlist.h (renamed from contrib/ofed/management/opensm/include/complib/cl_qlist.h)0
-rw-r--r--contrib/ofed/opensm/include/complib/cl_qmap.h (renamed from contrib/ofed/management/opensm/include/complib/cl_qmap.h)0
-rw-r--r--contrib/ofed/opensm/include/complib/cl_qpool.h (renamed from contrib/ofed/management/opensm/include/complib/cl_qpool.h)0
-rw-r--r--contrib/ofed/opensm/include/complib/cl_spinlock.h217
-rw-r--r--contrib/ofed/opensm/include/complib/cl_spinlock_osd.h (renamed from contrib/ofed/management/opensm/include/complib/cl_spinlock_osd.h)0
-rw-r--r--contrib/ofed/opensm/include/complib/cl_thread.h (renamed from contrib/ofed/management/opensm/include/complib/cl_thread.h)0
-rw-r--r--contrib/ofed/opensm/include/complib/cl_thread_osd.h (renamed from contrib/ofed/management/opensm/include/complib/cl_thread_osd.h)0
-rw-r--r--contrib/ofed/opensm/include/complib/cl_threadpool.h248
-rw-r--r--contrib/ofed/opensm/include/complib/cl_timer.h (renamed from contrib/ofed/management/opensm/include/complib/cl_timer.h)0
-rw-r--r--contrib/ofed/opensm/include/complib/cl_timer_osd.h (renamed from contrib/ofed/management/opensm/include/complib/cl_timer_osd.h)0
-rw-r--r--contrib/ofed/opensm/include/complib/cl_types.h455
-rw-r--r--contrib/ofed/opensm/include/complib/cl_types_osd.h97
-rw-r--r--contrib/ofed/opensm/include/complib/cl_vector.h945
-rw-r--r--contrib/ofed/opensm/include/iba/ib_cm_types.h203
-rw-r--r--contrib/ofed/opensm/include/iba/ib_types.h12047
-rw-r--r--contrib/ofed/opensm/include/opensm/osm_attrib_req.h108
-rw-r--r--contrib/ofed/opensm/include/opensm/osm_base.h1034
-rw-r--r--contrib/ofed/opensm/include/opensm/osm_config.h69
-rw-r--r--contrib/ofed/opensm/include/opensm/osm_congestion_control.h134
-rw-r--r--contrib/ofed/opensm/include/opensm/osm_console.h50
-rw-r--r--contrib/ofed/opensm/include/opensm/osm_console_io.h97
-rw-r--r--contrib/ofed/opensm/include/opensm/osm_db.h430
-rw-r--r--contrib/ofed/opensm/include/opensm/osm_db_pack.h568
-rw-r--r--contrib/ofed/opensm/include/opensm/osm_errors.h (renamed from contrib/ofed/management/opensm/include/opensm/osm_errors.h)0
-rw-r--r--contrib/ofed/opensm/include/opensm/osm_event_plugin.h207
-rw-r--r--contrib/ofed/opensm/include/opensm/osm_file_ids.h157
-rw-r--r--contrib/ofed/opensm/include/opensm/osm_guid.h66
-rw-r--r--contrib/ofed/opensm/include/opensm/osm_helper.h877
-rw-r--r--contrib/ofed/opensm/include/opensm/osm_inform.h265
-rw-r--r--contrib/ofed/opensm/include/opensm/osm_lid_mgr.h283
-rw-r--r--contrib/ofed/opensm/include/opensm/osm_log.h592
-rw-r--r--contrib/ofed/opensm/include/opensm/osm_mad_pool.h370
-rw-r--r--contrib/ofed/opensm/include/opensm/osm_madw.h1209
-rw-r--r--contrib/ofed/opensm/include/opensm/osm_mcast_mgr.h72
-rw-r--r--contrib/ofed/opensm/include/opensm/osm_mcast_tbl.h486
-rw-r--r--contrib/ofed/opensm/include/opensm/osm_mcm_port.h259
-rw-r--r--contrib/ofed/opensm/include/opensm/osm_mesh.h77
-rw-r--r--contrib/ofed/opensm/include/opensm/osm_msgdef.h170
-rw-r--r--contrib/ofed/opensm/include/opensm/osm_mtree.h274
-rw-r--r--contrib/ofed/opensm/include/opensm/osm_multicast.h458
-rw-r--r--contrib/ofed/opensm/include/opensm/osm_node.h674
-rw-r--r--contrib/ofed/opensm/include/opensm/osm_opensm.h670
-rw-r--r--contrib/ofed/opensm/include/opensm/osm_partition.h279
-rw-r--r--contrib/ofed/opensm/include/opensm/osm_path.h219
-rw-r--r--contrib/ofed/opensm/include/opensm/osm_perfmgr.h312
-rw-r--r--contrib/ofed/opensm/include/opensm/osm_perfmgr_db.h221
-rw-r--r--contrib/ofed/opensm/include/opensm/osm_pkey.h730
-rw-r--r--contrib/ofed/opensm/include/opensm/osm_port.h1701
-rw-r--r--contrib/ofed/opensm/include/opensm/osm_port_profile.h206
-rw-r--r--contrib/ofed/opensm/include/opensm/osm_prefix_route.h (renamed from contrib/ofed/management/opensm/include/opensm/osm_prefix_route.h)0
-rw-r--r--contrib/ofed/opensm/include/opensm/osm_qos_policy.h205
-rw-r--r--contrib/ofed/opensm/include/opensm/osm_remote_sm.h194
-rw-r--r--contrib/ofed/opensm/include/opensm/osm_router.h215
-rw-r--r--contrib/ofed/opensm/include/opensm/osm_sa.h617
-rw-r--r--contrib/ofed/opensm/include/opensm/osm_sa_mad_ctrl.h349
-rw-r--r--contrib/ofed/opensm/include/opensm/osm_service.h191
-rw-r--r--contrib/ofed/opensm/include/opensm/osm_sm.h834
-rw-r--r--contrib/ofed/opensm/include/opensm/osm_sm_mad_ctrl.h321
-rw-r--r--contrib/ofed/opensm/include/opensm/osm_stats.h (renamed from contrib/ofed/management/opensm/include/opensm/osm_stats.h)0
-rw-r--r--contrib/ofed/opensm/include/opensm/osm_subnet.h1623
-rw-r--r--contrib/ofed/opensm/include/opensm/osm_switch.h1189
-rw-r--r--contrib/ofed/opensm/include/opensm/osm_ucast_cache.h241
-rw-r--r--contrib/ofed/opensm/include/opensm/osm_ucast_lash.h97
-rw-r--r--contrib/ofed/opensm/include/opensm/osm_ucast_mgr.h302
-rw-r--r--contrib/ofed/opensm/include/opensm/osm_version.h51
-rw-r--r--contrib/ofed/opensm/include/opensm/osm_vl15intf.h388
-rw-r--r--contrib/ofed/opensm/include/opensm/st.h103
-rw-r--r--contrib/ofed/opensm/include/vendor/osm_mtl_bind.h (renamed from contrib/ofed/management/opensm/include/vendor/osm_mtl_bind.h)0
-rw-r--r--contrib/ofed/opensm/include/vendor/osm_pkt_randomizer.h (renamed from contrib/ofed/management/opensm/include/vendor/osm_pkt_randomizer.h)0
-rw-r--r--contrib/ofed/opensm/include/vendor/osm_ts_useraccess.h (renamed from contrib/ofed/management/opensm/include/vendor/osm_ts_useraccess.h)0
-rw-r--r--contrib/ofed/opensm/include/vendor/osm_umadt.h (renamed from contrib/ofed/management/opensm/include/vendor/osm_umadt.h)0
-rw-r--r--contrib/ofed/opensm/include/vendor/osm_vendor.h71
-rw-r--r--contrib/ofed/opensm/include/vendor/osm_vendor_al.h (renamed from contrib/ofed/management/opensm/include/vendor/osm_vendor_al.h)0
-rw-r--r--contrib/ofed/opensm/include/vendor/osm_vendor_api.h487
-rw-r--r--contrib/ofed/opensm/include/vendor/osm_vendor_ibumad.h183
-rw-r--r--contrib/ofed/opensm/include/vendor/osm_vendor_mlx.h99
-rw-r--r--contrib/ofed/opensm/include/vendor/osm_vendor_mlx_defs.h101
-rw-r--r--contrib/ofed/opensm/include/vendor/osm_vendor_mlx_dispatcher.h (renamed from contrib/ofed/management/opensm/include/vendor/osm_vendor_mlx_dispatcher.h)0
-rw-r--r--contrib/ofed/opensm/include/vendor/osm_vendor_mlx_hca.h (renamed from contrib/ofed/management/opensm/include/vendor/osm_vendor_mlx_hca.h)0
-rw-r--r--contrib/ofed/opensm/include/vendor/osm_vendor_mlx_inout.h (renamed from contrib/ofed/management/opensm/include/vendor/osm_vendor_mlx_inout.h)0
-rw-r--r--contrib/ofed/opensm/include/vendor/osm_vendor_mlx_rmpp_ctx.h (renamed from contrib/ofed/management/opensm/include/vendor/osm_vendor_mlx_rmpp_ctx.h)0
-rw-r--r--contrib/ofed/opensm/include/vendor/osm_vendor_mlx_sar.h (renamed from contrib/ofed/management/opensm/include/vendor/osm_vendor_mlx_sar.h)0
-rw-r--r--contrib/ofed/opensm/include/vendor/osm_vendor_mlx_sender.h (renamed from contrib/ofed/management/opensm/include/vendor/osm_vendor_mlx_sender.h)0
-rw-r--r--contrib/ofed/opensm/include/vendor/osm_vendor_mlx_svc.h195
-rw-r--r--contrib/ofed/opensm/include/vendor/osm_vendor_mlx_transport.h (renamed from contrib/ofed/management/opensm/include/vendor/osm_vendor_mlx_transport.h)0
-rw-r--r--contrib/ofed/opensm/include/vendor/osm_vendor_mlx_transport_anafa.h (renamed from contrib/ofed/management/opensm/include/vendor/osm_vendor_mlx_transport_anafa.h)0
-rw-r--r--contrib/ofed/opensm/include/vendor/osm_vendor_mlx_txn.h (renamed from contrib/ofed/management/opensm/include/vendor/osm_vendor_mlx_txn.h)0
-rw-r--r--contrib/ofed/opensm/include/vendor/osm_vendor_mtl.h (renamed from contrib/ofed/management/opensm/include/vendor/osm_vendor_mtl.h)0
-rw-r--r--contrib/ofed/opensm/include/vendor/osm_vendor_mtl_hca_guid.h (renamed from contrib/ofed/management/opensm/include/vendor/osm_vendor_mtl_hca_guid.h)0
-rw-r--r--contrib/ofed/opensm/include/vendor/osm_vendor_mtl_transaction_mgr.h (renamed from contrib/ofed/management/opensm/include/vendor/osm_vendor_mtl_transaction_mgr.h)0
-rw-r--r--contrib/ofed/opensm/include/vendor/osm_vendor_sa_api.h874
-rw-r--r--contrib/ofed/opensm/include/vendor/osm_vendor_test.h (renamed from contrib/ofed/management/opensm/include/vendor/osm_vendor_test.h)0
-rw-r--r--contrib/ofed/opensm/include/vendor/osm_vendor_ts.h (renamed from contrib/ofed/management/opensm/include/vendor/osm_vendor_ts.h)0
-rw-r--r--contrib/ofed/opensm/include/vendor/osm_vendor_umadt.h (renamed from contrib/ofed/management/opensm/include/vendor/osm_vendor_umadt.h)0
-rw-r--r--contrib/ofed/opensm/libopensm/Makefile20
-rw-r--r--contrib/ofed/opensm/libvendor/Makefile19
-rw-r--r--contrib/ofed/opensm/libvendor/libosmvendor.map (renamed from contrib/ofed/management/opensm/libvendor/libosmvendor.map)0
-rw-r--r--contrib/ofed/opensm/libvendor/libosmvendor.ver9
-rw-r--r--contrib/ofed/opensm/libvendor/osm_pkt_randomizer.c322
-rw-r--r--contrib/ofed/opensm/libvendor/osm_vendor_al.c1270
-rw-r--r--contrib/ofed/opensm/libvendor/osm_vendor_ibumad.c1266
-rw-r--r--contrib/ofed/opensm/libvendor/osm_vendor_ibumad_sa.c725
-rw-r--r--contrib/ofed/opensm/libvendor/osm_vendor_mlx.c768
-rw-r--r--contrib/ofed/opensm/libvendor/osm_vendor_mlx_anafa.c751
-rw-r--r--contrib/ofed/opensm/libvendor/osm_vendor_mlx_dispatcher.c710
-rw-r--r--contrib/ofed/opensm/libvendor/osm_vendor_mlx_hca.c522
-rw-r--r--contrib/ofed/opensm/libvendor/osm_vendor_mlx_hca_anafa.c192
-rw-r--r--contrib/ofed/opensm/libvendor/osm_vendor_mlx_hca_pfs.c749
-rw-r--r--contrib/ofed/opensm/libvendor/osm_vendor_mlx_hca_sim.c862
-rw-r--r--contrib/ofed/opensm/libvendor/osm_vendor_mlx_ibmgt.c (renamed from contrib/ofed/management/opensm/libvendor/osm_vendor_mlx_ibmgt.c)0
-rw-r--r--contrib/ofed/opensm/libvendor/osm_vendor_mlx_rmpp_ctx.c361
-rw-r--r--contrib/ofed/opensm/libvendor/osm_vendor_mlx_sa.c800
-rw-r--r--contrib/ofed/opensm/libvendor/osm_vendor_mlx_sar.c (renamed from contrib/ofed/management/opensm/libvendor/osm_vendor_mlx_sar.c)0
-rw-r--r--contrib/ofed/opensm/libvendor/osm_vendor_mlx_sender.c390
-rw-r--r--contrib/ofed/opensm/libvendor/osm_vendor_mlx_sim.c (renamed from contrib/ofed/management/opensm/libvendor/osm_vendor_mlx_sim.c)0
-rw-r--r--contrib/ofed/opensm/libvendor/osm_vendor_mlx_ts.c (renamed from contrib/ofed/management/opensm/libvendor/osm_vendor_mlx_ts.c)0
-rw-r--r--contrib/ofed/opensm/libvendor/osm_vendor_mlx_ts_anafa.c (renamed from contrib/ofed/management/opensm/libvendor/osm_vendor_mlx_ts_anafa.c)0
-rw-r--r--contrib/ofed/opensm/libvendor/osm_vendor_mlx_txn.c680
-rw-r--r--contrib/ofed/opensm/libvendor/osm_vendor_mtl.c1098
-rw-r--r--contrib/ofed/opensm/libvendor/osm_vendor_mtl_hca_guid.c631
-rw-r--r--contrib/ofed/opensm/libvendor/osm_vendor_mtl_transaction_mgr.c546
-rw-r--r--contrib/ofed/opensm/libvendor/osm_vendor_test.c258
-rw-r--r--contrib/ofed/opensm/libvendor/osm_vendor_ts.c897
-rw-r--r--contrib/ofed/opensm/libvendor/osm_vendor_umadt.c1107
-rw-r--r--contrib/ofed/opensm/man/opensm.81561
-rw-r--r--contrib/ofed/opensm/opensm/Makefile101
-rw-r--r--contrib/ofed/opensm/opensm/libopensm.map100
-rw-r--r--contrib/ofed/opensm/opensm/libopensm.ver9
-rw-r--r--contrib/ofed/opensm/opensm/main.c1266
-rw-r--r--contrib/ofed/opensm/opensm/osm_congestion_control.c807
-rw-r--r--contrib/ofed/opensm/opensm/osm_console.c1936
-rw-r--r--contrib/ofed/opensm/opensm/osm_console_io.c266
-rw-r--r--contrib/ofed/opensm/opensm/osm_db_files.c771
-rw-r--r--contrib/ofed/opensm/opensm/osm_db_pack.c333
-rw-r--r--contrib/ofed/opensm/opensm/osm_drop_mgr.c611
-rw-r--r--contrib/ofed/opensm/opensm/osm_dump.c750
-rw-r--r--contrib/ofed/opensm/opensm/osm_event_plugin.c152
-rw-r--r--contrib/ofed/opensm/opensm/osm_guid_info_rcv.c124
-rw-r--r--contrib/ofed/opensm/opensm/osm_guid_mgr.c145
-rw-r--r--contrib/ofed/opensm/opensm/osm_helper.c3332
-rw-r--r--contrib/ofed/opensm/opensm/osm_inform.c822
-rw-r--r--contrib/ofed/opensm/opensm/osm_lid_mgr.c1253
-rw-r--r--contrib/ofed/opensm/opensm/osm_lin_fwd_rcv.c125
-rw-r--r--contrib/ofed/opensm/opensm/osm_link_mgr.c590
-rw-r--r--contrib/ofed/opensm/opensm/osm_log.c518
-rw-r--r--contrib/ofed/opensm/opensm/osm_mad_pool.c175
-rw-r--r--contrib/ofed/opensm/opensm/osm_mcast_fwd_rcv.c130
-rw-r--r--contrib/ofed/opensm/opensm/osm_mcast_mgr.c1225
-rw-r--r--contrib/ofed/opensm/opensm/osm_mcast_tbl.c265
-rw-r--r--contrib/ofed/opensm/opensm/osm_mcm_port.c98
-rw-r--r--contrib/ofed/opensm/opensm/osm_mesh.c1736
-rw-r--r--contrib/ofed/opensm/opensm/osm_mlnx_ext_port_info_rcv.c142
-rw-r--r--contrib/ofed/opensm/opensm/osm_mtree.c106
-rw-r--r--contrib/ofed/opensm/opensm/osm_multicast.c460
-rw-r--r--contrib/ofed/opensm/opensm/osm_node.c272
-rw-r--r--contrib/ofed/opensm/opensm/osm_node_desc_rcv.c136
-rw-r--r--contrib/ofed/opensm/opensm/osm_node_info_rcv.c972
-rw-r--r--contrib/ofed/opensm/opensm/osm_opensm.c579
-rw-r--r--contrib/ofed/opensm/opensm/osm_perfmgr.c2035
-rw-r--r--contrib/ofed/opensm/opensm/osm_perfmgr_db.c1098
-rw-r--r--contrib/ofed/opensm/opensm/osm_pkey.c586
-rw-r--r--contrib/ofed/opensm/opensm/osm_pkey_mgr.c890
-rw-r--r--contrib/ofed/opensm/opensm/osm_pkey_rcv.c152
-rw-r--r--contrib/ofed/opensm/opensm/osm_port.c700
-rw-r--r--contrib/ofed/opensm/opensm/osm_port_info_rcv.c820
-rw-r--r--contrib/ofed/opensm/opensm/osm_prtn.c449
-rw-r--r--contrib/ofed/opensm/opensm/osm_prtn_config.c841
-rw-r--r--contrib/ofed/opensm/opensm/osm_qos.c661
-rw-r--r--contrib/ofed/opensm/opensm/osm_qos_parser_l.l404
-rw-r--r--contrib/ofed/opensm/opensm/osm_qos_parser_y.y3169
-rw-r--r--contrib/ofed/opensm/opensm/osm_qos_policy.c1065
-rw-r--r--contrib/ofed/opensm/opensm/osm_remote_sm.c71
-rw-r--r--contrib/ofed/opensm/opensm/osm_req.c429
-rw-r--r--contrib/ofed/opensm/opensm/osm_resp.c152
-rw-r--r--contrib/ofed/opensm/opensm/osm_router.c73
-rw-r--r--contrib/ofed/opensm/opensm/osm_sa.c1379
-rw-r--r--contrib/ofed/opensm/opensm/osm_sa_class_port_info.c220
-rw-r--r--contrib/ofed/opensm/opensm/osm_sa_guidinfo_record.c844
-rw-r--r--contrib/ofed/opensm/opensm/osm_sa_informinfo.c643
-rw-r--r--contrib/ofed/opensm/opensm/osm_sa_lft_record.c242
-rw-r--r--contrib/ofed/opensm/opensm/osm_sa_link_record.c485
-rw-r--r--contrib/ofed/opensm/opensm/osm_sa_mad_ctrl.c622
-rw-r--r--contrib/ofed/opensm/opensm/osm_sa_mcmember_record.c1791
-rw-r--r--contrib/ofed/opensm/opensm/osm_sa_mft_record.c274
-rw-r--r--contrib/ofed/opensm/opensm/osm_sa_multipath_record.c1673
-rw-r--r--contrib/ofed/opensm/opensm/osm_sa_node_record.c352
-rw-r--r--contrib/ofed/opensm/opensm/osm_sa_path_record.c1971
-rw-r--r--contrib/ofed/opensm/opensm/osm_sa_pkey_record.c316
-rw-r--r--contrib/ofed/opensm/opensm/osm_sa_portinfo_record.c608
-rw-r--r--contrib/ofed/opensm/opensm/osm_sa_service_record.c802
-rw-r--r--contrib/ofed/opensm/opensm/osm_sa_slvl_record.c299
-rw-r--r--contrib/ofed/opensm/opensm/osm_sa_sminfo_record.c328
-rw-r--r--contrib/ofed/opensm/opensm/osm_sa_sw_info_record.c264
-rw-r--r--contrib/ofed/opensm/opensm/osm_sa_vlarb_record.c305
-rw-r--r--contrib/ofed/opensm/opensm/osm_service.c147
-rw-r--r--contrib/ofed/opensm/opensm/osm_slvl_map_rcv.c172
-rw-r--r--contrib/ofed/opensm/opensm/osm_sm.c464
-rw-r--r--contrib/ofed/opensm/opensm/osm_sm_mad_ctrl.c925
-rw-r--r--contrib/ofed/opensm/opensm/osm_sm_state_mgr.c588
-rw-r--r--contrib/ofed/opensm/opensm/osm_sminfo_rcv.c657
-rw-r--r--contrib/ofed/opensm/opensm/osm_state_mgr.c1757
-rw-r--r--contrib/ofed/opensm/opensm/osm_subnet.c3027
-rw-r--r--contrib/ofed/opensm/opensm/osm_sw_info_rcv.c454
-rw-r--r--contrib/ofed/opensm/opensm/osm_switch.c767
-rw-r--r--contrib/ofed/opensm/opensm/osm_torus.c9565
-rw-r--r--contrib/ofed/opensm/opensm/osm_trap_rcv.c689
-rw-r--r--contrib/ofed/opensm/opensm/osm_ucast_cache.c1059
-rw-r--r--contrib/ofed/opensm/opensm/osm_ucast_dfsssp.c2873
-rw-r--r--contrib/ofed/opensm/opensm/osm_ucast_dnup.c499
-rw-r--r--contrib/ofed/opensm/opensm/osm_ucast_file.c406
-rw-r--r--contrib/ofed/opensm/opensm/osm_ucast_ftree.c4340
-rw-r--r--contrib/ofed/opensm/opensm/osm_ucast_lash.c1331
-rw-r--r--contrib/ofed/opensm/opensm/osm_ucast_mgr.c1196
-rw-r--r--contrib/ofed/opensm/opensm/osm_ucast_updn.c677
-rw-r--r--contrib/ofed/opensm/opensm/osm_vl15intf.c401
-rw-r--r--contrib/ofed/opensm/opensm/osm_vl_arb_rcv.c161
-rw-r--r--contrib/ofed/opensm/opensm/st.c591
-rw-r--r--contrib/ofed/usr.bin/Makefile14
-rw-r--r--contrib/ofed/usr.bin/Makefile.inc9
-rw-r--r--contrib/ofed/usr.bin/ibaddr/Makefile14
-rw-r--r--contrib/ofed/usr.bin/ibaddr/Makefile.depend22
-rw-r--r--contrib/ofed/usr.bin/ibnetdiscover/Makefile14
-rw-r--r--contrib/ofed/usr.bin/ibnetdiscover/Makefile.depend23
-rw-r--r--contrib/ofed/usr.bin/ibping/Makefile14
-rw-r--r--contrib/ofed/usr.bin/ibping/Makefile.depend21
-rw-r--r--contrib/ofed/usr.bin/ibportstate/Makefile14
-rw-r--r--contrib/ofed/usr.bin/ibportstate/Makefile.depend21
-rw-r--r--contrib/ofed/usr.bin/ibroute/Makefile14
-rw-r--r--contrib/ofed/usr.bin/ibroute/Makefile.depend23
-rw-r--r--contrib/ofed/usr.bin/ibsendtrap/Makefile14
-rw-r--r--contrib/ofed/usr.bin/ibsendtrap/Makefile.depend21
-rw-r--r--contrib/ofed/usr.bin/ibstat/Makefile14
-rw-r--r--contrib/ofed/usr.bin/ibstat/Makefile.depend20
-rw-r--r--contrib/ofed/usr.bin/ibsysstat/Makefile14
-rw-r--r--contrib/ofed/usr.bin/ibsysstat/Makefile.depend21
-rw-r--r--contrib/ofed/usr.bin/ibtracert/Makefile14
-rw-r--r--contrib/ofed/usr.bin/ibtracert/Makefile.depend23
-rw-r--r--contrib/ofed/usr.bin/opensm/Makefile39
-rw-r--r--contrib/ofed/usr.bin/opensm/Makefile.depend26
-rw-r--r--contrib/ofed/usr.bin/osmtest/Makefile28
-rw-r--r--contrib/ofed/usr.bin/osmtest/Makefile.depend26
-rw-r--r--contrib/ofed/usr.bin/perfquery/Makefile14
-rw-r--r--contrib/ofed/usr.bin/perfquery/Makefile.depend21
-rw-r--r--contrib/ofed/usr.bin/saquery/Makefile15
-rw-r--r--contrib/ofed/usr.bin/saquery/Makefile.depend26
-rw-r--r--contrib/ofed/usr.bin/sminfo/Makefile14
-rw-r--r--contrib/ofed/usr.bin/sminfo/Makefile.depend21
-rw-r--r--contrib/ofed/usr.bin/smpdump/Makefile14
-rw-r--r--contrib/ofed/usr.bin/smpdump/Makefile.depend21
-rw-r--r--contrib/ofed/usr.bin/smpquery/Makefile14
-rw-r--r--contrib/ofed/usr.bin/smpquery/Makefile.depend23
-rw-r--r--contrib/ofed/usr.bin/vendstat/Makefile14
-rw-r--r--contrib/ofed/usr.bin/vendstat/Makefile.depend21
-rw-r--r--contrib/ofed/usr.lib/0/Makefile8
-rw-r--r--contrib/ofed/usr.lib/1/Makefile9
-rw-r--r--contrib/ofed/usr.lib/2/Makefile14
-rw-r--r--contrib/ofed/usr.lib/3/Makefile9
-rw-r--r--contrib/ofed/usr.lib/Makefile16
-rw-r--r--contrib/ofed/usr.lib/Makefile.inc24
-rw-r--r--contrib/ofed/usr.lib/libcxgb4/Makefile25
-rw-r--r--contrib/ofed/usr.lib/libcxgb4/Makefile.depend21
-rw-r--r--contrib/ofed/usr.lib/libcxgb4/config.h4
-rw-r--r--contrib/ofed/usr.lib/libibcm/Makefile24
-rw-r--r--contrib/ofed/usr.lib/libibcm/Makefile.depend19
-rw-r--r--contrib/ofed/usr.lib/libibcommon/Makefile20
-rw-r--r--contrib/ofed/usr.lib/libibcommon/Makefile.depend18
-rw-r--r--contrib/ofed/usr.lib/libibmad/Makefile24
-rw-r--r--contrib/ofed/usr.lib/libibmad/Makefile.depend21
-rw-r--r--contrib/ofed/usr.lib/libibmad/config.h1
-rw-r--r--contrib/ofed/usr.lib/libibumad/Makefile23
-rw-r--r--contrib/ofed/usr.lib/libibumad/Makefile.depend19
-rw-r--r--contrib/ofed/usr.lib/libibumad/config.h1
-rw-r--r--contrib/ofed/usr.lib/libibverbs/Makefile39
-rw-r--r--contrib/ofed/usr.lib/libibverbs/Makefile.depend18
-rw-r--r--contrib/ofed/usr.lib/libibverbs/config.h2
-rw-r--r--contrib/ofed/usr.lib/libmlx4/Makefile25
-rw-r--r--contrib/ofed/usr.lib/libmlx4/Makefile.depend20
-rw-r--r--contrib/ofed/usr.lib/libmlx4/config.h4
-rw-r--r--contrib/ofed/usr.lib/libmthca/Makefile25
-rw-r--r--contrib/ofed/usr.lib/libmthca/Makefile.depend20
-rw-r--r--contrib/ofed/usr.lib/libmthca/config.h9
-rw-r--r--contrib/ofed/usr.lib/libopensm/Makefile20
-rw-r--r--contrib/ofed/usr.lib/libopensm/Makefile.depend20
-rw-r--r--contrib/ofed/usr.lib/libosmcomp/Makefile23
-rw-r--r--contrib/ofed/usr.lib/libosmcomp/Makefile.depend20
-rw-r--r--contrib/ofed/usr.lib/libosmvendor/Makefile21
-rw-r--r--contrib/ofed/usr.lib/libosmvendor/Makefile.depend22
-rw-r--r--contrib/ofed/usr.lib/librdmacm/Makefile34
-rw-r--r--contrib/ofed/usr.lib/librdmacm/Makefile.depend19
-rw-r--r--contrib/ofed/usr.lib/libsdp/Makefile25
-rw-r--r--contrib/ofed/usr.lib/libsdp/Makefile.depend19
-rw-r--r--share/mk/bsd.libnames.mk7
-rw-r--r--share/mk/src.libnames.mk56
-rw-r--r--sys/amd64/conf/NOTES4
-rw-r--r--sys/conf/files190
-rw-r--r--sys/conf/kern.pre.mk5
-rw-r--r--sys/contrib/rdma/krping/krping.c2200
-rw-r--r--sys/contrib/rdma/krping/krping.h3
-rw-r--r--sys/contrib/rdma/krping/krping_dev.c3
-rw-r--r--sys/contrib/rdma/krping_compat/getopt.c78
-rw-r--r--sys/contrib/rdma/krping_compat/getopt.h21
-rw-r--r--sys/contrib/rdma/krping_compat/krping.c3427
-rw-r--r--sys/contrib/rdma/krping_compat/krping.h20
-rw-r--r--sys/contrib/rdma/krping_compat/krping_dev.c220
-rw-r--r--sys/dev/cxgbe/adapter.h1
-rw-r--r--sys/dev/cxgbe/common/common.h8
-rw-r--r--sys/dev/cxgbe/common/t4_hw.c92
-rw-r--r--sys/dev/cxgbe/iw_cxgbe/cm.c1011
-rw-r--r--sys/dev/cxgbe/iw_cxgbe/cq.c131
-rw-r--r--sys/dev/cxgbe/iw_cxgbe/device.c114
-rw-r--r--sys/dev/cxgbe/iw_cxgbe/iw_cxgbe.h136
-rw-r--r--sys/dev/cxgbe/iw_cxgbe/mem.c359
-rw-r--r--sys/dev/cxgbe/iw_cxgbe/provider.c185
-rw-r--r--sys/dev/cxgbe/iw_cxgbe/qp.c690
-rw-r--r--sys/dev/cxgbe/iw_cxgbe/t4.h202
-rw-r--r--sys/dev/cxgbe/iw_cxgbe/user.h8
-rw-r--r--sys/dev/cxgbe/offload.h5
-rw-r--r--sys/dev/cxgbe/t4_main.c6
-rw-r--r--sys/dev/iser/icl_iser.c2
-rw-r--r--sys/dev/iser/icl_iser.h4
-rw-r--r--sys/dev/iser/iser_memory.c111
-rw-r--r--sys/dev/iser/iser_verbs.c49
-rw-r--r--sys/dev/mlx4/device.h8
-rw-r--r--sys/dev/mlx4/mlx4_ib/mlx4_exp.h46
-rw-r--r--sys/dev/mlx4/mlx4_ib/mlx4_ib.h281
-rw-r--r--sys/dev/mlx4/mlx4_ib/mlx4_ib_ah.c55
-rw-r--r--sys/dev/mlx4/mlx4_ib/mlx4_ib_alias_GUID.c477
-rw-r--r--sys/dev/mlx4/mlx4_ib/mlx4_ib_cm.c42
-rw-r--r--sys/dev/mlx4/mlx4_ib/mlx4_ib_cq.c247
-rw-r--r--sys/dev/mlx4/mlx4_ib/mlx4_ib_exp.c116
-rw-r--r--sys/dev/mlx4/mlx4_ib/mlx4_ib_mad.c474
-rw-r--r--sys/dev/mlx4/mlx4_ib/mlx4_ib_main.c2648
-rw-r--r--sys/dev/mlx4/mlx4_ib/mlx4_ib_mcg.c49
-rw-r--r--sys/dev/mlx4/mlx4_ib/mlx4_ib_mr.c899
-rw-r--r--sys/dev/mlx4/mlx4_ib/mlx4_ib_qp.c1826
-rw-r--r--sys/dev/mlx4/mlx4_ib/mlx4_ib_srq.c25
-rw-r--r--sys/dev/mlx4/mlx4_ib/mlx4_ib_sysfs.c176
-rw-r--r--sys/dev/mlx4/mlx4_ib/user.h107
-rw-r--r--sys/dev/mlx5/mlx5_ib/mlx5_ib.h762
-rw-r--r--sys/dev/mlx5/mlx5_ib/mlx5_ib_ah.c44
-rw-r--r--sys/dev/mlx5/mlx5_ib/mlx5_ib_cq.c492
-rw-r--r--sys/dev/mlx5/mlx5_ib/mlx5_ib_doorbell.c4
-rw-r--r--sys/dev/mlx5/mlx5_ib/mlx5_ib_gsi.c536
-rw-r--r--sys/dev/mlx5/mlx5_ib/mlx5_ib_mad.c203
-rw-r--r--sys/dev/mlx5/mlx5_ib/mlx5_ib_main.c2568
-rw-r--r--sys/dev/mlx5/mlx5_ib/mlx5_ib_mem.c73
-rw-r--r--sys/dev/mlx5/mlx5_ib/mlx5_ib_mr.c1833
-rw-r--r--sys/dev/mlx5/mlx5_ib/mlx5_ib_qp.c3407
-rw-r--r--sys/dev/mlx5/mlx5_ib/mlx5_ib_roce.c252
-rw-r--r--sys/dev/mlx5/mlx5_ib/mlx5_ib_srq.c91
-rw-r--r--sys/dev/mlx5/mlx5_ib/mlx5_ib_virt.c54
-rw-r--r--sys/dev/mlx5/mlx5_ib/user.h318
-rw-r--r--sys/dev/mlx5/qp.h8
-rw-r--r--sys/dev/mthca/mthca_allocator.c301
-rw-r--r--sys/dev/mthca/mthca_av.c374
-rw-r--r--sys/dev/mthca/mthca_catas.c202
-rw-r--r--sys/dev/mthca/mthca_cmd.c1968
-rw-r--r--sys/dev/mthca/mthca_cmd.h325
-rw-r--r--sys/dev/mthca/mthca_config_reg.h48
-rw-r--r--sys/dev/mthca/mthca_cq.c981
-rw-r--r--sys/dev/mthca/mthca_dev.h599
-rw-r--r--sys/dev/mthca/mthca_doorbell.h (renamed from sys/ofed/drivers/infiniband/hw/mthca/mthca_doorbell.h)0
-rw-r--r--sys/dev/mthca/mthca_eq.c905
-rw-r--r--sys/dev/mthca/mthca_mad.c350
-rw-r--r--sys/dev/mthca/mthca_main.c1279
-rw-r--r--sys/dev/mthca/mthca_mcg.c335
-rw-r--r--sys/dev/mthca/mthca_memfree.c758
-rw-r--r--sys/dev/mthca/mthca_memfree.h (renamed from sys/ofed/drivers/infiniband/hw/mthca/mthca_memfree.h)0
-rw-r--r--sys/dev/mthca/mthca_mr.c965
-rw-r--r--sys/dev/mthca/mthca_pd.c (renamed from sys/ofed/drivers/infiniband/hw/mthca/mthca_pd.c)0
-rw-r--r--sys/dev/mthca/mthca_profile.c281
-rw-r--r--sys/dev/mthca/mthca_profile.h (renamed from sys/ofed/drivers/infiniband/hw/mthca/mthca_profile.h)0
-rw-r--r--sys/dev/mthca/mthca_provider.c1318
-rw-r--r--sys/dev/mthca/mthca_provider.h346
-rw-r--r--sys/dev/mthca/mthca_qp.c2311
-rw-r--r--sys/dev/mthca/mthca_reset.c (renamed from sys/ofed/drivers/infiniband/hw/mthca/mthca_reset.c)0
-rw-r--r--sys/dev/mthca/mthca_srq.c696
-rw-r--r--sys/dev/mthca/mthca_uar.c76
-rw-r--r--sys/dev/mthca/mthca_user.h (renamed from sys/ofed/drivers/infiniband/hw/mthca/mthca_user.h)0
-rw-r--r--sys/dev/mthca/mthca_wqe.h (renamed from sys/ofed/drivers/infiniband/hw/mthca/mthca_wqe.h)0
-rw-r--r--sys/i386/conf/NOTES4
-rw-r--r--sys/modules/Makefile4
-rw-r--r--sys/modules/cxgb/Makefile8
-rw-r--r--sys/modules/cxgbe/iw_cxgbe/Makefile3
-rw-r--r--sys/modules/ibcore/Makefile45
-rw-r--r--sys/modules/ipoib/Makefile1
-rw-r--r--sys/modules/iser/Makefile1
-rw-r--r--sys/modules/mlx4/Makefile1
-rw-r--r--sys/modules/mlx4ib/Makefile2
-rw-r--r--sys/modules/mlx5ib/Makefile6
-rw-r--r--sys/modules/mthca/Makefile34
-rw-r--r--sys/modules/rdma/krping/Makefile1
-rw-r--r--sys/modules/rdma/krping_compat/Makefile12
-rw-r--r--sys/ofed/drivers/infiniband/Kconfig66
-rw-r--r--sys/ofed/drivers/infiniband/Makefile17
-rw-r--r--sys/ofed/drivers/infiniband/core/addr.c610
-rw-r--r--sys/ofed/drivers/infiniband/core/agent.c217
-rw-r--r--sys/ofed/drivers/infiniband/core/agent.h6
-rw-r--r--sys/ofed/drivers/infiniband/core/cache.c467
-rw-r--r--sys/ofed/drivers/infiniband/core/cm.c3986
-rw-r--r--sys/ofed/drivers/infiniband/core/cm_msgs.h4
-rw-r--r--sys/ofed/drivers/infiniband/core/cma.c3854
-rw-r--r--sys/ofed/drivers/infiniband/core/core_priv.h107
-rw-r--r--sys/ofed/drivers/infiniband/core/device.c791
-rw-r--r--sys/ofed/drivers/infiniband/core/fmr_pool.c545
-rw-r--r--sys/ofed/drivers/infiniband/core/ib_addr.c819
-rw-r--r--sys/ofed/drivers/infiniband/core/ib_agent.c222
-rw-r--r--sys/ofed/drivers/infiniband/core/ib_cache.c1258
-rw-r--r--sys/ofed/drivers/infiniband/core/ib_cm.c4141
-rw-r--r--sys/ofed/drivers/infiniband/core/ib_cma.c4312
-rw-r--r--sys/ofed/drivers/infiniband/core/ib_cq.c154
-rw-r--r--sys/ofed/drivers/infiniband/core/ib_device.c1048
-rw-r--r--sys/ofed/drivers/infiniband/core/ib_fmr_pool.c521
-rw-r--r--sys/ofed/drivers/infiniband/core/ib_iwcm.c1051
-rw-r--r--sys/ofed/drivers/infiniband/core/ib_iwpm_msg.c43
-rw-r--r--sys/ofed/drivers/infiniband/core/ib_iwpm_util.c97
-rw-r--r--sys/ofed/drivers/infiniband/core/ib_mad.c3339
-rw-r--r--sys/ofed/drivers/infiniband/core/ib_mad_rmpp.c968
-rw-r--r--sys/ofed/drivers/infiniband/core/ib_multicast.c900
-rw-r--r--sys/ofed/drivers/infiniband/core/ib_packer.c200
-rw-r--r--sys/ofed/drivers/infiniband/core/ib_roce_gid_mgmt.c447
-rw-r--r--sys/ofed/drivers/infiniband/core/ib_sa_query.c1580
-rw-r--r--sys/ofed/drivers/infiniband/core/ib_smi.c338
-rw-r--r--sys/ofed/drivers/infiniband/core/ib_sysfs.c1327
-rw-r--r--sys/ofed/drivers/infiniband/core/ib_ucm.c1370
-rw-r--r--sys/ofed/drivers/infiniband/core/ib_ucma.c1754
-rw-r--r--sys/ofed/drivers/infiniband/core/ib_ud_header.c551
-rw-r--r--sys/ofed/drivers/infiniband/core/ib_umem.c352
-rw-r--r--sys/ofed/drivers/infiniband/core/ib_umem_odp.c667
-rw-r--r--sys/ofed/drivers/infiniband/core/ib_umem_rbtree.c93
-rw-r--r--sys/ofed/drivers/infiniband/core/ib_user_mad.c1401
-rw-r--r--sys/ofed/drivers/infiniband/core/ib_uverbs_cmd.c4251
-rw-r--r--sys/ofed/drivers/infiniband/core/ib_uverbs_main.c1430
-rw-r--r--sys/ofed/drivers/infiniband/core/ib_uverbs_marshall.c148
-rw-r--r--sys/ofed/drivers/infiniband/core/ib_verbs.c2068
-rw-r--r--sys/ofed/drivers/infiniband/core/iwcm.c1317
-rw-r--r--sys/ofed/drivers/infiniband/core/iwcm.h2
-rw-r--r--sys/ofed/drivers/infiniband/core/iwpm_util.h75
-rw-r--r--sys/ofed/drivers/infiniband/core/mad.c3694
-rw-r--r--sys/ofed/drivers/infiniband/core/mad_priv.h55
-rw-r--r--sys/ofed/drivers/infiniband/core/mad_rmpp.c953
-rw-r--r--sys/ofed/drivers/infiniband/core/multicast.c916
-rw-r--r--sys/ofed/drivers/infiniband/core/opa_smi.h78
-rw-r--r--sys/ofed/drivers/infiniband/core/packer.c203
-rw-r--r--sys/ofed/drivers/infiniband/core/peer_mem.c461
-rw-r--r--sys/ofed/drivers/infiniband/core/sa_query.c1278
-rw-r--r--sys/ofed/drivers/infiniband/core/smi.c253
-rw-r--r--sys/ofed/drivers/infiniband/core/smi.h4
-rw-r--r--sys/ofed/drivers/infiniband/core/sysfs.c1026
-rw-r--r--sys/ofed/drivers/infiniband/core/ucm.c1386
-rw-r--r--sys/ofed/drivers/infiniband/core/ucma.c1415
-rw-r--r--sys/ofed/drivers/infiniband/core/ud_header.c414
-rw-r--r--sys/ofed/drivers/infiniband/core/umem.c446
-rw-r--r--sys/ofed/drivers/infiniband/core/user_mad.c1312
-rw-r--r--sys/ofed/drivers/infiniband/core/uverbs.h81
-rw-r--r--sys/ofed/drivers/infiniband/core/uverbs_cmd.c3924
-rw-r--r--sys/ofed/drivers/infiniband/core/uverbs_main.c1431
-rw-r--r--sys/ofed/drivers/infiniband/core/uverbs_marshall.c144
-rw-r--r--sys/ofed/drivers/infiniband/core/verbs.c1547
-rw-r--r--sys/ofed/drivers/infiniband/debug/Makefile3
-rw-r--r--sys/ofed/drivers/infiniband/debug/memtrack.c960
-rw-r--r--sys/ofed/drivers/infiniband/debug/memtrack.h106
-rw-r--r--sys/ofed/drivers/infiniband/debug/mtrack.h844
-rw-r--r--sys/ofed/drivers/infiniband/hw/mthca/Kconfig17
-rw-r--r--sys/ofed/drivers/infiniband/hw/mthca/Makefile7
-rw-r--r--sys/ofed/drivers/infiniband/hw/mthca/mthca_allocator.c300
-rw-r--r--sys/ofed/drivers/infiniband/hw/mthca/mthca_av.c374
-rw-r--r--sys/ofed/drivers/infiniband/hw/mthca/mthca_catas.c200
-rw-r--r--sys/ofed/drivers/infiniband/hw/mthca/mthca_cmd.c1940
-rw-r--r--sys/ofed/drivers/infiniband/hw/mthca/mthca_cmd.h341
-rw-r--r--sys/ofed/drivers/infiniband/hw/mthca/mthca_config_reg.h50
-rw-r--r--sys/ofed/drivers/infiniband/hw/mthca/mthca_cq.c992
-rw-r--r--sys/ofed/drivers/infiniband/hw/mthca/mthca_dev.h597
-rw-r--r--sys/ofed/drivers/infiniband/hw/mthca/mthca_eq.c920
-rw-r--r--sys/ofed/drivers/infiniband/hw/mthca/mthca_mad.c346
-rw-r--r--sys/ofed/drivers/infiniband/hw/mthca/mthca_main.c1363
-rw-r--r--sys/ofed/drivers/infiniband/hw/mthca/mthca_mcg.c372
-rw-r--r--sys/ofed/drivers/infiniband/hw/mthca/mthca_memfree.c881
-rw-r--r--sys/ofed/drivers/infiniband/hw/mthca/mthca_mr.c985
-rw-r--r--sys/ofed/drivers/infiniband/hw/mthca/mthca_profile.c285
-rw-r--r--sys/ofed/drivers/infiniband/hw/mthca/mthca_provider.c1448
-rw-r--r--sys/ofed/drivers/infiniband/hw/mthca/mthca_provider.h343
-rw-r--r--sys/ofed/drivers/infiniband/hw/mthca/mthca_qp.c2333
-rw-r--r--sys/ofed/drivers/infiniband/hw/mthca/mthca_srq.c715
-rw-r--r--sys/ofed/drivers/infiniband/hw/mthca/mthca_uar.c78
-rw-r--r--sys/ofed/drivers/infiniband/ulp/ipoib/Kconfig50
-rw-r--r--sys/ofed/drivers/infiniband/ulp/ipoib/ipoib.h4
-rw-r--r--sys/ofed/drivers/infiniband/ulp/ipoib/ipoib_cm.c35
-rw-r--r--sys/ofed/drivers/infiniband/ulp/ipoib/ipoib_ib.c27
-rw-r--r--sys/ofed/drivers/infiniband/ulp/ipoib/ipoib_main.c76
-rw-r--r--sys/ofed/drivers/infiniband/ulp/ipoib/ipoib_multicast.c4
-rw-r--r--sys/ofed/drivers/infiniband/ulp/ipoib/ipoib_verbs.c33
-rw-r--r--sys/ofed/drivers/infiniband/ulp/sdp/sdp.h7
-rw-r--r--sys/ofed/drivers/infiniband/ulp/sdp/sdp_cma.c7
-rw-r--r--sys/ofed/drivers/infiniband/ulp/sdp/sdp_main.c35
-rw-r--r--sys/ofed/drivers/infiniband/ulp/sdp/sdp_proc.c1
-rw-r--r--sys/ofed/drivers/infiniband/ulp/sdp/sdp_rx.c75
-rw-r--r--sys/ofed/drivers/infiniband/ulp/sdp/sdp_tx.c27
-rw-r--r--sys/ofed/drivers/infiniband/util/Kconfig6
-rw-r--r--sys/ofed/include/rdma/ib.h120
-rw-r--r--sys/ofed/include/rdma/ib_addr.h109
-rw-r--r--sys/ofed/include/rdma/ib_cache.h40
-rw-r--r--sys/ofed/include/rdma/ib_cm.h26
-rw-r--r--sys/ofed/include/rdma/ib_hdrs.h178
-rw-r--r--sys/ofed/include/rdma/ib_mad.h208
-rw-r--r--sys/ofed/include/rdma/ib_pack.h66
-rw-r--r--sys/ofed/include/rdma/ib_peer_mem.h59
-rw-r--r--sys/ofed/include/rdma/ib_pma.h20
-rw-r--r--sys/ofed/include/rdma/ib_sa.h69
-rw-r--r--sys/ofed/include/rdma/ib_smi.h50
-rw-r--r--sys/ofed/include/rdma/ib_umem.h85
-rw-r--r--sys/ofed/include/rdma/ib_umem_odp.h161
-rw-r--r--sys/ofed/include/rdma/ib_user_cm.h325
-rw-r--r--sys/ofed/include/rdma/ib_user_mad.h202
-rw-r--r--sys/ofed/include/rdma/ib_user_sa.h76
-rw-r--r--sys/ofed/include/rdma/ib_user_verbs.h980
-rw-r--r--sys/ofed/include/rdma/ib_user_verbs_exp.h204
-rw-r--r--sys/ofed/include/rdma/ib_verbs.h1706
-rw-r--r--sys/ofed/include/rdma/ib_verbs_compat.h582
-rw-r--r--sys/ofed/include/rdma/ib_verbs_exp.h100
-rw-r--r--sys/ofed/include/rdma/iw_cm.h24
-rw-r--r--sys/ofed/include/rdma/iw_portmap.h70
-rw-r--r--sys/ofed/include/rdma/opa_port_info.h417
-rw-r--r--sys/ofed/include/rdma/opa_smi.h153
-rw-r--r--sys/ofed/include/rdma/peer_mem.h73
-rw-r--r--sys/ofed/include/rdma/rdma_cm.h60
-rw-r--r--sys/ofed/include/rdma/rdma_user_cm.h251
-rw-r--r--sys/ofed/include/rdma/rdma_vt.h500
-rw-r--r--sys/ofed/include/rdma/rdmavt_cq.h99
-rw-r--r--sys/ofed/include/rdma/rdmavt_mr.h140
-rw-r--r--sys/ofed/include/rdma/rdmavt_qp.h535
-rw-r--r--sys/ofed/include/rdma/sdp_socket.h23
-rw-r--r--sys/ofed/include/uapi/rdma/ib_user_cm.h329
-rw-r--r--sys/ofed/include/uapi/rdma/ib_user_mad.h250
-rw-r--r--sys/ofed/include/uapi/rdma/ib_user_sa.h80
-rw-r--r--sys/ofed/include/uapi/rdma/ib_user_verbs.h1071
-rw-r--r--sys/ofed/include/uapi/rdma/mlx4-abi.h111
-rw-r--r--sys/ofed/include/uapi/rdma/mlx5-abi.h253
-rw-r--r--sys/ofed/include/uapi/rdma/mthca-abi.h111
-rw-r--r--sys/ofed/include/uapi/rdma/rdma_user_cm.h316
-rw-r--r--targets/pseudo/userland/Makefile.depend21
-rw-r--r--targets/pseudo/userland/lib/Makefile.depend17
1668 files changed, 316886 insertions, 434462 deletions
diff --git a/Makefile.inc1 b/Makefile.inc1
index ee61d14..2cbab78 100644
--- a/Makefile.inc1
+++ b/Makefile.inc1
@@ -2141,16 +2141,24 @@ _lib_libradius= lib/libradius
.endif
.if ${MK_OFED} != "no"
-_ofed_lib= contrib/ofed/usr.lib
-_prebuild_libs+= contrib/ofed/usr.lib/libosmcomp
-_prebuild_libs+= contrib/ofed/usr.lib/libopensm
-_prebuild_libs+= contrib/ofed/usr.lib/libibcommon
-_prebuild_libs+= contrib/ofed/usr.lib/libibverbs
-_prebuild_libs+= contrib/ofed/usr.lib/libibumad
-
-contrib/ofed/usr.lib/libopensm__L: lib/libthr__L
-contrib/ofed/usr.lib/libosmcomp__L: lib/libthr__L
-contrib/ofed/usr.lib/libibumad__L: contrib/ofed/usr.lib/libibcommon__L
+#
+# The OFED libraries are built in four steps
+# as reflected below, due to interdependencies.
+#
+# NOTE: Depending on contrib/ofed/include is only needed for
+# the lib32 compat build.
+#
+_ofed_lib= \
+contrib/ofed/include \
+contrib/ofed/usr.lib/0 \
+contrib/ofed/usr.lib/1 \
+contrib/ofed/usr.lib/2 \
+contrib/ofed/usr.lib/3
+
+contrib/ofed/usr.lib/0__L: contrib/ofed/include__L lib/libthr__L
+contrib/ofed/usr.lib/1__L: contrib/ofed/usr.lib/0__L
+contrib/ofed/usr.lib/2__L: contrib/ofed/usr.lib/1__L
+contrib/ofed/usr.lib/3__L: contrib/ofed/usr.lib/2__L
.endif
.if ${MK_CASPER} != "no"
diff --git a/contrib/ofed/Makefile b/contrib/ofed/Makefile
index fe33309..f7a1d55 100644
--- a/contrib/ofed/Makefile
+++ b/contrib/ofed/Makefile
@@ -1,3 +1,10 @@
-SUBDIR = include usr.lib usr.bin
+# $FreeBSD$
+
+# NOTE: Make sure WITH_OFED=YES is set when building this top-level directory.
+
+SUBDIR= \
+include \
+usr.lib \
+usr.bin
.include <bsd.subdir.mk>
diff --git a/contrib/ofed/include/Makefile b/contrib/ofed/include/Makefile
index ccc151c..2941a11 100644
--- a/contrib/ofed/include/Makefile
+++ b/contrib/ofed/include/Makefile
@@ -1,5 +1,191 @@
-.include <bsd.own.mk>
+# $FreeBSD$
-SUBDIR = infiniband rdma
+IBVERBS= ${.CURDIR}/../libibverbs
+IBMAD= ${.CURDIR}/../libibmad
+IBUMAD= ${.CURDIR}/../libibumad
+IBCM= ${.CURDIR}/../libibcm
+IBND= ${.CURDIR}/../libibnetdisc
+RDMACM= ${.CURDIR}/../librdmacm
+RDMA= ${.CURDIR}/../../../sys/ofed/include/uapi/rdma
+OSM= ${.CURDIR}/../opensm/include
-.include <bsd.subdir.mk>
+IBINCS= \
+byteorder.h \
+byteswap.h \
+endian.h \
+types.h \
+udma_barrier.h \
+${IBVERBS}/arch.h \
+${IBVERBS}/driver.h \
+${IBVERBS}/kern-abi.h \
+${IBVERBS}/marshall.h \
+${IBVERBS}/opcode.h \
+${IBVERBS}/sa-kern-abi.h \
+${IBVERBS}/sa.h \
+${IBVERBS}/verbs.h \
+${IBUMAD}/umad.h \
+${IBUMAD}/umad_cm.h \
+${IBUMAD}/umad_sa.h \
+${IBUMAD}/umad_sm.h \
+${IBUMAD}/umad_str.h \
+${IBUMAD}/umad_types.h \
+${IBMAD}/mad.h \
+${IBMAD}/mad_osd.h \
+${IBCM}/cm.h \
+${IBCM}/cm_abi.h \
+${IBND}/ibnetdisc.h \
+${IBND}/ibnetdisc_osd.h \
+${RDMACM}/ib.h
+IBINCSDIR= ${INCLUDEDIR}/infiniband
+
+RDMAINCS= \
+${RDMACM}/rdma_cma.h \
+${RDMACM}/rdma_cma_abi.h \
+${RDMACM}/rdma_verbs.h \
+${RDMACM}/rsocket.h \
+${RDMA}/ib_user_cm.h \
+${RDMA}/ib_user_sa.h \
+${RDMA}/ib_user_verbs.h \
+${RDMA}/rdma_user_cm.h \
+${RDMA}/mlx4-abi.h \
+${RDMA}/mlx5-abi.h
+RDMAINCSDIR= ${INCLUDEDIR}/rdma
+
+COMPINCS= \
+${OSM}/complib/cl_atomic.h \
+${OSM}/complib/cl_atomic_osd.h \
+${OSM}/complib/cl_byteswap.h \
+${OSM}/complib/cl_byteswap_osd.h \
+${OSM}/complib/cl_comppool.h \
+${OSM}/complib/cl_debug.h \
+${OSM}/complib/cl_debug_osd.h \
+${OSM}/complib/cl_dispatcher.h \
+${OSM}/complib/cl_event.h \
+${OSM}/complib/cl_event_osd.h \
+${OSM}/complib/cl_event_wheel.h \
+${OSM}/complib/cl_fleximap.h \
+${OSM}/complib/cl_list.h \
+${OSM}/complib/cl_log.h \
+${OSM}/complib/cl_map.h \
+${OSM}/complib/cl_math.h \
+${OSM}/complib/cl_nodenamemap.h \
+${OSM}/complib/cl_packoff.h \
+${OSM}/complib/cl_packon.h \
+${OSM}/complib/cl_passivelock.h \
+${OSM}/complib/cl_pool.h \
+${OSM}/complib/cl_ptr_vector.h \
+${OSM}/complib/cl_qcomppool.h \
+${OSM}/complib/cl_qlist.h \
+${OSM}/complib/cl_qmap.h \
+${OSM}/complib/cl_qpool.h \
+${OSM}/complib/cl_spinlock.h \
+${OSM}/complib/cl_spinlock_osd.h \
+${OSM}/complib/cl_thread.h \
+${OSM}/complib/cl_thread_osd.h \
+${OSM}/complib/cl_threadpool.h \
+${OSM}/complib/cl_timer.h \
+${OSM}/complib/cl_timer_osd.h \
+${OSM}/complib/cl_types.h \
+${OSM}/complib/cl_types_osd.h \
+${OSM}/complib/cl_vector.h
+COMPINCSDIR= ${INCLUDEDIR}/infiniband/complib
+
+OSMINCS= \
+${OSM}/opensm/osm_attrib_req.h \
+${OSM}/opensm/osm_base.h \
+${OSM}/opensm/osm_config.h \
+${OSM}/opensm/osm_congestion_control.h \
+${OSM}/opensm/osm_console.h \
+${OSM}/opensm/osm_console_io.h \
+${OSM}/opensm/osm_db.h \
+${OSM}/opensm/osm_db_pack.h \
+${OSM}/opensm/osm_errors.h \
+${OSM}/opensm/osm_event_plugin.h \
+${OSM}/opensm/osm_file_ids.h \
+${OSM}/opensm/osm_guid.h \
+${OSM}/opensm/osm_helper.h \
+${OSM}/opensm/osm_inform.h \
+${OSM}/opensm/osm_lid_mgr.h \
+${OSM}/opensm/osm_log.h \
+${OSM}/opensm/osm_mad_pool.h \
+${OSM}/opensm/osm_madw.h \
+${OSM}/opensm/osm_mcast_mgr.h \
+${OSM}/opensm/osm_mcast_tbl.h \
+${OSM}/opensm/osm_mcm_port.h \
+${OSM}/opensm/osm_mesh.h \
+${OSM}/opensm/osm_msgdef.h \
+${OSM}/opensm/osm_mtree.h \
+${OSM}/opensm/osm_multicast.h \
+${OSM}/opensm/osm_node.h \
+${OSM}/opensm/osm_opensm.h \
+${OSM}/opensm/osm_partition.h \
+${OSM}/opensm/osm_path.h \
+${OSM}/opensm/osm_perfmgr.h \
+${OSM}/opensm/osm_perfmgr_db.h \
+${OSM}/opensm/osm_pkey.h \
+${OSM}/opensm/osm_port.h \
+${OSM}/opensm/osm_port_profile.h \
+${OSM}/opensm/osm_prefix_route.h \
+${OSM}/opensm/osm_qos_policy.h \
+${OSM}/opensm/osm_remote_sm.h \
+${OSM}/opensm/osm_router.h \
+${OSM}/opensm/osm_sa.h \
+${OSM}/opensm/osm_sa_mad_ctrl.h \
+${OSM}/opensm/osm_service.h \
+${OSM}/opensm/osm_sm.h \
+${OSM}/opensm/osm_sm_mad_ctrl.h \
+${OSM}/opensm/osm_stats.h \
+${OSM}/opensm/osm_subnet.h \
+${OSM}/opensm/osm_switch.h \
+${OSM}/opensm/osm_ucast_cache.h \
+${OSM}/opensm/osm_ucast_lash.h \
+${OSM}/opensm/osm_ucast_mgr.h \
+${OSM}/opensm/osm_version.h \
+${OSM}/opensm/osm_vl15intf.h \
+${OSM}/opensm/st.h
+OSMINCSDIR= ${INCLUDEDIR}/infiniband/opensm
+
+IBAINCS= \
+${OSM}/iba/ib_cm_types.h \
+${OSM}/iba/ib_types.h
+IBAINCSDIR= ${INCLUDEDIR}/infiniband/iba
+
+VENDORINCS= \
+${OSM}/vendor/osm_mtl_bind.h \
+${OSM}/vendor/osm_pkt_randomizer.h \
+${OSM}/vendor/osm_ts_useraccess.h \
+${OSM}/vendor/osm_umadt.h \
+${OSM}/vendor/osm_vendor.h \
+${OSM}/vendor/osm_vendor_al.h \
+${OSM}/vendor/osm_vendor_api.h \
+${OSM}/vendor/osm_vendor_ibumad.h \
+${OSM}/vendor/osm_vendor_mlx.h \
+${OSM}/vendor/osm_vendor_mlx_defs.h \
+${OSM}/vendor/osm_vendor_mlx_dispatcher.h \
+${OSM}/vendor/osm_vendor_mlx_hca.h \
+${OSM}/vendor/osm_vendor_mlx_inout.h \
+${OSM}/vendor/osm_vendor_mlx_rmpp_ctx.h \
+${OSM}/vendor/osm_vendor_mlx_sar.h \
+${OSM}/vendor/osm_vendor_mlx_sender.h \
+${OSM}/vendor/osm_vendor_mlx_svc.h \
+${OSM}/vendor/osm_vendor_mlx_transport.h \
+${OSM}/vendor/osm_vendor_mlx_transport_anafa.h \
+${OSM}/vendor/osm_vendor_mlx_txn.h \
+${OSM}/vendor/osm_vendor_mtl.h \
+${OSM}/vendor/osm_vendor_mtl_hca_guid.h \
+${OSM}/vendor/osm_vendor_mtl_transaction_mgr.h \
+${OSM}/vendor/osm_vendor_sa_api.h \
+${OSM}/vendor/osm_vendor_test.h \
+${OSM}/vendor/osm_vendor_ts.h \
+${OSM}/vendor/osm_vendor_umadt.h
+VENDORINCSDIR= ${INCLUDEDIR}/infiniband/vendor
+
+INCSGROUPS= \
+IBINCS \
+RDMAINCS \
+COMPINCS \
+OSMINCS \
+IBAINCS \
+VENDORINCS
+
+.include <bsd.prog.mk>
diff --git a/contrib/ofed/include/infiniband/byteorder.h b/contrib/ofed/include/byteorder.h
index a7326e4..a7326e4 100644
--- a/contrib/ofed/include/infiniband/byteorder.h
+++ b/contrib/ofed/include/byteorder.h
diff --git a/contrib/ofed/include/infiniband/byteswap.h b/contrib/ofed/include/byteswap.h
index 29f1004..29f1004 100644
--- a/contrib/ofed/include/infiniband/byteswap.h
+++ b/contrib/ofed/include/byteswap.h
diff --git a/contrib/ofed/include/infiniband/endian.h b/contrib/ofed/include/endian.h
index dd1acdc0..dd1acdc0 100644
--- a/contrib/ofed/include/infiniband/endian.h
+++ b/contrib/ofed/include/endian.h
diff --git a/contrib/ofed/include/infiniband/Makefile b/contrib/ofed/include/infiniband/Makefile
deleted file mode 100644
index 5d48013..0000000
--- a/contrib/ofed/include/infiniband/Makefile
+++ /dev/null
@@ -1,107 +0,0 @@
-.include <bsd.own.mk>
-
-INCS=
-IBINCS= byteorder.h byteswap.h endian.h types.h
-IBINCSDIR= ${INCLUDEDIR}/infiniband
-
-IBVERBS= ${.CURDIR}/../../libibverbs/include/infiniband
-VERBINCS= ${IBVERBS}/arch.h ${IBVERBS}/driver.h ${IBVERBS}/kern-abi.h
-VERBINCS+= ${IBVERBS}/marshall.h ${IBVERBS}/opcode.h
-VERBINCS+= ${IBVERBS}/sa-kern-abi.h ${IBVERBS}/sa.h ${IBVERBS}/verbs.h
-VERBINCSDIR= ${INCLUDEDIR}/infiniband
-
-IBCOMMON= ${.CURDIR}/../../management/libibcommon/include/infiniband
-COMMONINCS= ${IBCOMMON}/common.h
-COMMONINCSDIR= ${INCLUDEDIR}/infiniband
-
-IBMAD= ${.CURDIR}/../../management/libibmad/include/infiniband
-MADINCS= ${IBMAD}/mad.h
-MADINCSDIR= ${INCLUDEDIR}/infiniband
-
-IBUMAD= ${.CURDIR}/../../management/libibumad/include/infiniband
-UMADINCS= ${IBUMAD}/umad.h
-UMADINCSDIR= ${INCLUDEDIR}/infiniband
-
-COMPLIB= ${.CURDIR}/../../management/opensm/include/complib
-COMPLIBINCS= ${COMPLIB}/cl_atomic.h ${COMPLIB}/cl_atomic_osd.h
-COMPLIBINCS+= ${COMPLIB}/cl_byteswap.h ${COMPLIB}/cl_byteswap_osd.h
-COMPLIBINCS+= ${COMPLIB}/cl_comppool.h ${COMPLIB}/cl_debug.h
-COMPLIBINCS+= ${COMPLIB}/cl_debug_osd.h ${COMPLIB}/cl_dispatcher.h
-COMPLIBINCS+= ${COMPLIB}/cl_event.h ${COMPLIB}/cl_event_osd.h
-COMPLIBINCS+= ${COMPLIB}/cl_event_wheel.h ${COMPLIB}/cl_fleximap.h
-COMPLIBINCS+= ${COMPLIB}/cl_list.h ${COMPLIB}/cl_log.h
-COMPLIBINCS+= ${COMPLIB}/cl_map.h ${COMPLIB}/cl_math.h
-COMPLIBINCS+= ${COMPLIB}/cl_nodenamemap.h ${COMPLIB}/cl_packoff.h
-COMPLIBINCS+= ${COMPLIB}/cl_packon.h ${COMPLIB}/cl_passivelock.h
-COMPLIBINCS+= ${COMPLIB}/cl_pool.h ${COMPLIB}/cl_ptr_vector.h
-COMPLIBINCS+= ${COMPLIB}/cl_qcomppool.h ${COMPLIB}/cl_qlist.h
-COMPLIBINCS+= ${COMPLIB}/cl_qmap.h ${COMPLIB}/cl_qpool.h
-COMPLIBINCS+= ${COMPLIB}/cl_spinlock.h ${COMPLIB}/cl_spinlock_osd.h
-COMPLIBINCS+= ${COMPLIB}/cl_thread.h ${COMPLIB}/cl_thread_osd.h
-COMPLIBINCS+= ${COMPLIB}/cl_threadpool.h ${COMPLIB}/cl_timer.h
-COMPLIBINCS+= ${COMPLIB}/cl_timer_osd.h ${COMPLIB}/cl_types.h
-COMPLIBINCS+= ${COMPLIB}/cl_types_osd.h ${COMPLIB}/cl_vector.h
-COMPLIBINCSDIR= ${INCLUDEDIR}/infiniband/complib
-
-IBADIR= ${.CURDIR}/../../management/opensm/include/iba
-IBAINCS= ${IBADIR}/ib_cm_types.h ${IBADIR}/ib_types.h
-IBAINCSDIR= ${INCLUDEDIR}/infiniband/iba
-
-OPENSM= ${.CURDIR}/../../management/opensm/include/opensm
-
-OPENSMINCS= ${OPENSM}/osm_attrib_req.h ${OPENSM}/osm_base.h
-OPENSMINCS+= ${OPENSM}/osm_config.h ${OPENSM}/osm_console.h
-OPENSMINCS+= ${OPENSM}/osm_console_io.h ${OPENSM}/osm_db.h
-OPENSMINCS+= ${OPENSM}/osm_db_pack.h ${OPENSM}/osm_errors.h
-OPENSMINCS+= ${OPENSM}/osm_event_plugin.h ${OPENSM}/osm_helper.h
-OPENSMINCS+= ${OPENSM}/osm_inform.h ${OPENSM}/osm_lid_mgr.h
-OPENSMINCS+= ${OPENSM}/osm_log.h ${OPENSM}/osm_mad_pool.h
-OPENSMINCS+= ${OPENSM}/osm_madw.h ${OPENSM}/osm_mcast_tbl.h
-OPENSMINCS+= ${OPENSM}/osm_mcm_info.h ${OPENSM}/osm_mcm_port.h
-OPENSMINCS+= ${OPENSM}/osm_msgdef.h ${OPENSM}/osm_mtree.h
-OPENSMINCS+= ${OPENSM}/osm_multicast.h ${OPENSM}/osm_node.h
-OPENSMINCS+= ${OPENSM}/osm_opensm.h ${OPENSM}/osm_partition.h
-OPENSMINCS+= ${OPENSM}/osm_path.h ${OPENSM}/osm_perfmgr.h
-OPENSMINCS+= ${OPENSM}/osm_perfmgr_db.h ${OPENSM}/osm_pkey.h
-OPENSMINCS+= ${OPENSM}/osm_pkey_mgr.h ${OPENSM}/osm_port.h
-OPENSMINCS+= ${OPENSM}/osm_port_profile.h ${OPENSM}/osm_prefix_route.h
-OPENSMINCS+= ${OPENSM}/osm_qos_policy.h ${OPENSM}/osm_remote_sm.h
-OPENSMINCS+= ${OPENSM}/osm_router.h ${OPENSM}/osm_sa.h
-OPENSMINCS+= ${OPENSM}/osm_sa_mad_ctrl.h ${OPENSM}/osm_service.h
-OPENSMINCS+= ${OPENSM}/osm_sm.h ${OPENSM}/osm_sm_mad_ctrl.h
-OPENSMINCS+= ${OPENSM}/osm_stats.h ${OPENSM}/osm_subnet.h
-OPENSMINCS+= ${OPENSM}/osm_switch.h ${OPENSM}/osm_ucast_cache.h
-OPENSMINCS+= ${OPENSM}/osm_ucast_mgr.h ${OPENSM}/osm_version.h
-OPENSMINCS+= ${OPENSM}/osm_vl15intf.h ${OPENSM}/st.h
-OPENSMINCSDIR= ${INCLUDEDIR}/infiniband/opensm
-
-VENDOR= ${.CURDIR}/../../management/opensm/include/vendor
-VENDORINCS= ${VENDOR}/osm_mtl_bind.h ${VENDOR}/osm_pkt_randomizer.h
-VENDORINCS+= ${VENDOR}/osm_ts_useraccess.h ${VENDOR}/osm_umadt.h
-VENDORINCS+= ${VENDOR}/osm_vendor.h ${VENDOR}/osm_vendor_al.h
-VENDORINCS+= ${VENDOR}/osm_vendor_api.h ${VENDOR}/osm_vendor_ibumad.h
-VENDORINCS+= ${VENDOR}/osm_vendor_mlx.h ${VENDOR}/osm_vendor_mlx_defs.h
-VENDORINCS+= ${VENDOR}/osm_vendor_mlx_dispatcher.h
-VENDORINCS+= ${VENDOR}/osm_vendor_mlx_hca.h
-VENDORINCS+= ${VENDOR}/osm_vendor_mlx_inout.h
-VENDORINCS+= ${VENDOR}/osm_vendor_mlx_rmpp_ctx.h
-VENDORINCS+= ${VENDOR}/osm_vendor_mlx_sar.h ${VENDOR}/osm_vendor_mlx_sender.h
-VENDORINCS+= ${VENDOR}/osm_vendor_mlx_svc.h
-VENDORINCS+= ${VENDOR}/osm_vendor_mlx_transport.h
-VENDORINCS+= ${VENDOR}/osm_vendor_mlx_transport_anafa.h
-VENDORINCS+= ${VENDOR}/osm_vendor_mlx_txn.h
-VENDORINCS+= ${VENDOR}/osm_vendor_mtl.h ${VENDOR}/osm_vendor_mtl_hca_guid.h
-VENDORINCS+= ${VENDOR}/osm_vendor_mtl_transaction_mgr.h
-VENDORINCS+= ${VENDOR}/osm_vendor_sa_api.h
-VENDORINCS+= ${VENDOR}/osm_vendor_test.h ${VENDOR}/osm_vendor_ts.h
-VENDORINCS+= ${VENDOR}/osm_vendor_umadt.h
-VENDORINCSDIR= ${INCLUDEDIR}/infiniband/vendor
-
-IBCM= ${.CURDIR}/../../libibcm/include/infiniband
-IBCMINCS= ${IBCM}/cm.h ${IBCM}/cm_abi.h
-IBCMINCSDIR= ${INCLUDEDIR}/infiniband
-
-INCSGROUPS= INCS VERBINCS COMMONINCS MADINCS UMADINCS COMPLIBINCS IBAINCS
-INCSGROUPS+= OPENSMINCS VENDORINCS IBCMINCS IBINCS
-
-.include <bsd.prog.mk>
diff --git a/contrib/ofed/include/infiniband/types.h b/contrib/ofed/include/infiniband/types.h
deleted file mode 100644
index ae60fa374..0000000
--- a/contrib/ofed/include/infiniband/types.h
+++ /dev/null
@@ -1,63 +0,0 @@
-/*-
- * Copyright (c) 2010 Isilon Systems, Inc.
- * Copyright (c) 2010 iX Systems, Inc.
- * Copyright (c) 2010 Panasas, Inc.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice unmodified, this list of conditions, and the following
- * disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-#ifndef _INFINIBAND_TYPES_H_
-#define _INFINIBAND_TYPES_H_
-
-#include <sys/cdefs.h>
-#include <sys/types.h>
-
-typedef int8_t s8;
-typedef uint8_t u8;
-typedef int8_t __s8;
-typedef uint8_t __u8;
-
-typedef int16_t s16;
-typedef uint16_t u16;
-typedef int16_t __s16;
-typedef uint16_t __u16;
-
-typedef int32_t s32;
-typedef uint32_t u32;
-typedef int32_t __s32;
-typedef uint32_t __u32;
-
-typedef int64_t s64;
-typedef uint64_t u64;
-typedef int64_t __s64;
-typedef uint64_t __u64;
-
-typedef uint16_t __le16;
-typedef uint16_t __be16;
-typedef uint32_t __le32;
-typedef uint32_t __be32;
-typedef uint64_t __le64;
-typedef uint64_t __be64;
-
-typedef unsigned int uint;
-
-#endif /* _INFINIBAND_TYPES_H_ */
diff --git a/contrib/ofed/include/rdma/Makefile b/contrib/ofed/include/rdma/Makefile
deleted file mode 100644
index 366790f..0000000
--- a/contrib/ofed/include/rdma/Makefile
+++ /dev/null
@@ -1,10 +0,0 @@
-.include <bsd.own.mk>
-
-INCS=
-RDMACM= ${.CURDIR}/../../librdmacm/include/rdma
-RDMACMINCS= ${RDMACM}/rdma_cma.h ${RDMACM}/rdma_cma_abi.h
-RDMACMINCSDIR= ${INCLUDEDIR}/rdma
-
-INCSGROUPS= RDMACMINCS
-
-.include <bsd.prog.mk>
diff --git a/contrib/ofed/include/types.h b/contrib/ofed/include/types.h
new file mode 100644
index 0000000..bdb93b0
--- /dev/null
+++ b/contrib/ofed/include/types.h
@@ -0,0 +1,61 @@
+/*-
+ * Copyright (c) 2010 Isilon Systems, Inc.
+ * Copyright (c) 2010 iX Systems, Inc.
+ * Copyright (c) 2010 Panasas, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice unmodified, this list of conditions, and the following
+ * disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#ifndef _INFINIBAND_TYPES_H_
+#define _INFINIBAND_TYPES_H_
+
+#include <sys/cdefs.h>
+#include <sys/types.h>
+
+typedef int8_t s8;
+typedef uint8_t u8;
+typedef int8_t __s8;
+typedef uint8_t __u8;
+
+typedef int16_t s16;
+typedef uint16_t u16;
+typedef int16_t __s16;
+typedef uint16_t __u16;
+
+typedef int32_t s32;
+typedef uint32_t u32;
+typedef int32_t __s32;
+typedef uint32_t __u32;
+
+typedef int64_t s64;
+typedef uint64_t u64;
+typedef int64_t __s64;
+typedef uint64_t __u64;
+
+typedef uint16_t __le16;
+typedef uint16_t __be16;
+typedef uint32_t __le32;
+typedef uint32_t __be32;
+typedef uint64_t __le64;
+typedef uint64_t __be64;
+
+#endif /* _INFINIBAND_TYPES_H_ */
diff --git a/contrib/ofed/include/udma_barrier.h b/contrib/ofed/include/udma_barrier.h
new file mode 100644
index 0000000..71d264f
--- /dev/null
+++ b/contrib/ofed/include/udma_barrier.h
@@ -0,0 +1,277 @@
+/*
+ * Copyright (c) 2005 Topspin Communications. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#ifndef __UTIL_UDMA_BARRIER_H
+#define __UTIL_UDMA_BARRIER_H
+
+#include <pthread.h>
+
+/* Barriers for DMA.
+
+ These barriers are expliclty only for use with user DMA operations. If you
+ are looking for barriers to use with cache-coherent multi-threaded
+ consitency then look in stdatomic.h. If you need both kinds of synchronicity
+ for the same address then use an atomic operation followed by one
+ of these barriers.
+
+ When reasoning about these barriers there are two objects:
+ - CPU attached address space (the CPU memory could be a range of things:
+ cached/uncached/non-temporal CPU DRAM, uncached MMIO space in another
+ device, pMEM). Generally speaking the ordering is only relative
+ to the local CPU's view of the system. Eg if the local CPU
+ is not guaranteed to see a write from another CPU then it is also
+ OK for the DMA device to also not see the write after the barrier.
+ - A DMA initiator on a bus. For instance a PCI-E device issuing
+ MemRd/MemWr TLPs.
+
+ The ordering guarantee is always stated between those two streams. Eg what
+ happens if a MemRd TLP is sent in via PCI-E relative to a CPU WRITE to the
+ same memory location.
+
+ The providers have a very regular and predictable use of these barriers,
+ to make things very clear each narrow use is given a name and the proper
+ name should be used in the provider as a form of documentation.
+*/
+
+/* Ensure that the device's view of memory matches the CPU's view of memory.
+ This should be placed before any MMIO store that could trigger the device
+ to begin doing DMA, such as a device doorbell ring.
+
+ eg
+ *dma_buf = 1;
+ udma_to_device_barrier();
+ mmio_write(DO_DMA_REG, dma_buf);
+ Must ensure that the device sees the '1'.
+
+ This is required to fence writes created by the libibverbs user. Those
+ writes could be to any CPU mapped memory object with any cachability mode.
+
+ NOTE: x86 has historically used a weaker semantic for this barrier, and
+ only fenced normal stores to normal memory. libibverbs users using other
+ memory types or non-temporal stores are required to use SFENCE in their own
+ code prior to calling verbs to start a DMA.
+*/
+#if defined(__i386__)
+#define udma_to_device_barrier() asm volatile("" ::: "memory")
+#elif defined(__x86_64__)
+#define udma_to_device_barrier() asm volatile("" ::: "memory")
+#elif defined(__PPC64__)
+#define udma_to_device_barrier() asm volatile("sync" ::: "memory")
+#elif defined(__PPC__)
+#define udma_to_device_barrier() asm volatile("sync" ::: "memory")
+#elif defined(__ia64__)
+#define udma_to_device_barrier() asm volatile("mf" ::: "memory")
+#elif defined(__sparc_v9__)
+#define udma_to_device_barrier() asm volatile("membar #StoreStore" ::: "memory")
+#elif defined(__aarch64__)
+#define udma_to_device_barrier() asm volatile("dsb st" ::: "memory");
+#elif defined(__sparc__) || defined(__s390x__)
+#define udma_to_device_barrier() asm volatile("" ::: "memory")
+#elif defined(__mips__)
+#include <sys/types.h>
+#include <machine/atomic.h>
+#define udma_to_device_barrier() mips_sync()
+#elif defined(__arm__)
+#include <sys/types.h>
+#include <machine/atomic.h>
+#define udma_to_device_barrier() dmb()
+#else
+#error No architecture specific memory barrier defines found!
+#endif
+
+/* Ensure that all ordered stores from the device are observable from the
+ CPU. This only makes sense after something that observes an ordered store
+ from the device - eg by reading a MMIO register or seeing that CPU memory is
+ updated.
+
+ This guarantees that all reads that follow the barrier see the ordered
+ stores that preceded the observation.
+
+ For instance, this would be used after testing a valid bit in a memory
+ that is a DMA target, to ensure that the following reads see the
+ data written before the MemWr TLP that set the valid bit.
+*/
+#if defined(__i386__)
+#define udma_from_device_barrier() asm volatile("lock; addl $0,0(%%esp) " ::: "memory")
+#elif defined(__x86_64__)
+#define udma_from_device_barrier() asm volatile("lfence" ::: "memory")
+#elif defined(__PPC64__)
+#define udma_from_device_barrier() asm volatile("lwsync" ::: "memory")
+#elif defined(__PPC__)
+#define udma_from_device_barrier() asm volatile("sync" ::: "memory")
+#elif defined(__ia64__)
+#define udma_from_device_barrier() asm volatile("mf" ::: "memory")
+#elif defined(__sparc_v9__)
+#define udma_from_device_barrier() asm volatile("membar #LoadLoad" ::: "memory")
+#elif defined(__aarch64__)
+#define udma_from_device_barrier() asm volatile("dsb ld" ::: "memory");
+#elif defined(__sparc__) || defined(__s390x__)
+#define udma_from_device_barrier() asm volatile("" ::: "memory")
+#elif defined(__mips__)
+#define udma_from_device_barrier() mips_sync()
+#elif defined(__arm__)
+#define udma_from_device_barrier() dmb()
+#else
+#error No architecture specific memory barrier defines found!
+#endif
+
+/* Order writes to CPU memory so that a DMA device cannot view writes after
+ the barrier without also seeing all writes before the barrier. This does
+ not guarantee any writes are visible to DMA.
+
+ This would be used in cases where a DMA buffer might have a valid bit and
+ data, this barrier is placed after writing the data but before writing the
+ valid bit to ensure the DMA device cannot observe a set valid bit with
+ unwritten data.
+
+ Compared to udma_to_device_barrier() this barrier is not required to fence
+ anything but normal stores to normal malloc memory. Usage should be:
+
+ write_wqe
+ udma_to_device_barrier(); // Get user memory ready for DMA
+ wqe->addr = ...;
+ wqe->flags = ...;
+ udma_ordering_write_barrier(); // Guarantee WQE written in order
+ wqe->valid = 1;
+*/
+#define udma_ordering_write_barrier() udma_to_device_barrier()
+
+/* Promptly flush writes to MMIO Write Cominbing memory.
+ This should be used after a write to WC memory. This is both a barrier
+ and a hint to the CPU to flush any buffers to reduce latency to TLP
+ generation.
+
+ This is not required to have any effect on CPU memory.
+
+ If done while holding a lock then the ordering of MMIO writes across CPUs
+ must be guaranteed to follow the natural ordering implied by the lock.
+
+ This must also act as a barrier that prevents write combining, eg
+ *wc_mem = 1;
+ mmio_flush_writes();
+ *wc_mem = 2;
+ Must always produce two MemWr TLPs, '1' and '2'. Without the barrier
+ the CPU is allowed to produce a single TLP '2'.
+
+ Note that there is no order guarantee for writes to WC memory without
+ barriers.
+
+ This is intended to be used in conjunction with WC memory to generate large
+ PCI-E MemWr TLPs from the CPU.
+*/
+#if defined(__i386__)
+#define mmio_flush_writes() asm volatile("lock; addl $0,0(%%esp) " ::: "memory")
+#elif defined(__x86_64__)
+#define mmio_flush_writes() asm volatile("sfence" ::: "memory")
+#elif defined(__PPC64__)
+#define mmio_flush_writes() asm volatile("sync" ::: "memory")
+#elif defined(__PPC__)
+#define mmio_flush_writes() asm volatile("sync" ::: "memory")
+#elif defined(__ia64__)
+#define mmio_flush_writes() asm volatile("fwb" ::: "memory")
+#elif defined(__sparc_v9__)
+#define mmio_flush_writes() asm volatile("membar #StoreStore" ::: "memory")
+#elif defined(__aarch64__)
+#define mmio_flush_writes() asm volatile("dsb st" ::: "memory");
+#elif defined(__sparc__) || defined(__s390x__)
+#define mmio_flush_writes() asm volatile("" ::: "memory")
+#elif defined(__mips__)
+#define mmio_flush_writes() mips_sync()
+#elif defined(__arm__)
+#define mmio_flush_writes() dmb()
+#else
+#error No architecture specific memory barrier defines found!
+#endif
+
+/* Prevent WC writes from being re-ordered relative to other MMIO
+ writes. This should be used before a write to WC memory.
+
+ This must act as a barrier to prevent write re-ordering from different
+ memory types:
+ *mmio_mem = 1;
+ mmio_flush_writes();
+ *wc_mem = 2;
+ Must always produce a TLP '1' followed by '2'.
+
+ This barrier implies udma_to_device_barrier()
+
+ This is intended to be used in conjunction with WC memory to generate large
+ PCI-E MemWr TLPs from the CPU.
+*/
+#define mmio_wc_start() mmio_flush_writes()
+
+/* Keep MMIO writes in order.
+ Currently we lack writel macros that universally guarantee MMIO
+ writes happen in order, like the kernel does. Even worse many
+ providers haphazardly open code writes to MMIO memory omitting even
+ volatile.
+
+ Until this can be fixed with a proper writel macro, this barrier
+ is a stand in to indicate places where MMIO writes should be switched
+ to some future writel.
+*/
+#define mmio_ordered_writes_hack() mmio_flush_writes()
+
+/* Write Combining Spinlock primitive
+
+ Any access to a multi-value WC region must ensure that multiple cpus do not
+ write to the same values concurrently, these macros make that
+ straightforward and efficient if the choosen exclusion is a spinlock.
+
+ The spinlock guarantees that the WC writes issued within the critical
+ section are made visible as TLP to the device. The TLP must be seen by the
+ device strictly in the order that the spinlocks are acquired, and combining
+ WC writes between different sections is not permitted.
+
+ Use of these macros allow the fencing inside the spinlock to be combined
+ with the fencing required for DMA.
+ */
+static inline void mmio_wc_spinlock(pthread_spinlock_t *lock)
+{
+ pthread_spin_lock(lock);
+#if !defined(__i386__) && !defined(__x86_64__)
+ /* For x86 the serialization within the spin lock is enough to
+ * strongly order WC and other memory types. */
+ mmio_wc_start();
+#endif
+}
+
+static inline void mmio_wc_spinunlock(pthread_spinlock_t *lock)
+{
+ /* It is possible that on x86 the atomic in the lock is strong enough
+ * to force-flush the WC buffers quickly, and this SFENCE can be
+ * omitted too. */
+ mmio_flush_writes();
+ pthread_spin_unlock(lock);
+}
+
+#endif
diff --git a/contrib/ofed/infiniband-diags/build/Makefile b/contrib/ofed/infiniband-diags/build/Makefile
new file mode 100644
index 0000000..8ad5f3b
--- /dev/null
+++ b/contrib/ofed/infiniband-diags/build/Makefile
@@ -0,0 +1,29 @@
+# $FreeBSD$
+
+SUBDIR= \
+dump_fts \
+ibaddr \
+ibcacheedit \
+ibccconfig \
+ibccquery \
+iblinkinfo \
+ibmirror \
+ibnetdiscover \
+ibping \
+ibportstate \
+ibqueryerrors \
+ibroute \
+ibstat \
+ibsysstat \
+ibtracert \
+perfquery \
+saquery \
+sminfo \
+smpdump \
+smpquery \
+vendstat
+
+SUBDIR_PARALLEL=
+
+.include <bsd.subdir.mk>
+
diff --git a/contrib/ofed/infiniband-diags/build/Makefile.inc b/contrib/ofed/infiniband-diags/build/Makefile.inc
new file mode 100644
index 0000000..54b6d80
--- /dev/null
+++ b/contrib/ofed/infiniband-diags/build/Makefile.inc
@@ -0,0 +1,12 @@
+# $FreeBSD$
+
+.PATH: ${.CURDIR}/../../src ${.CURDIR}/../../man
+
+BINDIR?= /usr/bin
+SRCS+= ibdiag_common.c ibdiag_sa.c
+CFLAGS+= -I${SYSROOT:U${DESTDIR}}/${INCLUDEDIR}/infiniband
+CFLAGS+= -DHAVE_CONFIG_H=1
+CFLAGS+= -I${.CURDIR}/../../
+CFLAGS+= -I${.CURDIR}/../../src
+LIBADD+= osmcomp ibmad ibumad
+
diff --git a/contrib/ofed/infiniband-diags/build/dump_fts/Makefile b/contrib/ofed/infiniband-diags/build/dump_fts/Makefile
new file mode 100644
index 0000000..93f09e5
--- /dev/null
+++ b/contrib/ofed/infiniband-diags/build/dump_fts/Makefile
@@ -0,0 +1,8 @@
+# $FreeBSD$
+
+PROG= dump_fts
+SRCS= dump_fts.c
+LIBADD= ibnetdisc
+MAN= dump_fts.8
+
+.include <bsd.prog.mk>
diff --git a/contrib/ofed/infiniband-diags/build/ibaddr/Makefile b/contrib/ofed/infiniband-diags/build/ibaddr/Makefile
new file mode 100644
index 0000000..7aab4c2
--- /dev/null
+++ b/contrib/ofed/infiniband-diags/build/ibaddr/Makefile
@@ -0,0 +1,7 @@
+# $FreeBSD$
+
+PROG= ibaddr
+SRCS= ibaddr.c
+MAN= ibaddr.8
+
+.include <bsd.prog.mk>
diff --git a/contrib/ofed/infiniband-diags/build/ibcacheedit/Makefile b/contrib/ofed/infiniband-diags/build/ibcacheedit/Makefile
new file mode 100644
index 0000000..67225af
--- /dev/null
+++ b/contrib/ofed/infiniband-diags/build/ibcacheedit/Makefile
@@ -0,0 +1,8 @@
+# $FreeBSD$
+
+PROG= ibcacheedit
+SRCS= ibcacheedit.c
+LIBADD= ibnetdisc
+MAN= ibcacheedit.8
+
+.include <bsd.prog.mk>
diff --git a/contrib/ofed/infiniband-diags/build/ibccconfig/Makefile b/contrib/ofed/infiniband-diags/build/ibccconfig/Makefile
new file mode 100644
index 0000000..cfee9bf
--- /dev/null
+++ b/contrib/ofed/infiniband-diags/build/ibccconfig/Makefile
@@ -0,0 +1,7 @@
+# $FreeBSD$
+
+PROG= ibccconfig
+SRCS= ibccconfig.c
+MAN= ibccconfig.8
+
+.include <bsd.prog.mk>
diff --git a/contrib/ofed/infiniband-diags/build/ibccquery/Makefile b/contrib/ofed/infiniband-diags/build/ibccquery/Makefile
new file mode 100644
index 0000000..7d278b1
--- /dev/null
+++ b/contrib/ofed/infiniband-diags/build/ibccquery/Makefile
@@ -0,0 +1,7 @@
+# $FreeBSD$
+
+PROG= ibccquery
+SRCS= ibccquery.c
+MAN= ibccquery.8
+
+.include <bsd.prog.mk>
diff --git a/contrib/ofed/infiniband-diags/build/iblinkinfo/Makefile b/contrib/ofed/infiniband-diags/build/iblinkinfo/Makefile
new file mode 100644
index 0000000..49a0482
--- /dev/null
+++ b/contrib/ofed/infiniband-diags/build/iblinkinfo/Makefile
@@ -0,0 +1,8 @@
+# $FreeBSD$
+
+PROG= iblinkinfo
+SRCS= iblinkinfo.c
+LIBADD= ibnetdisc
+MAN= iblinkinfo.8
+
+.include <bsd.prog.mk>
diff --git a/contrib/ofed/infiniband-diags/build/ibmirror/Makefile b/contrib/ofed/infiniband-diags/build/ibmirror/Makefile
new file mode 100644
index 0000000..4684c20
--- /dev/null
+++ b/contrib/ofed/infiniband-diags/build/ibmirror/Makefile
@@ -0,0 +1,7 @@
+# $FreeBSD$
+
+PROG= ibmirror
+SRCS= ibmirror.c
+MAN=
+
+.include <bsd.prog.mk>
diff --git a/contrib/ofed/infiniband-diags/build/ibnetdiscover/Makefile b/contrib/ofed/infiniband-diags/build/ibnetdiscover/Makefile
new file mode 100644
index 0000000..34090be
--- /dev/null
+++ b/contrib/ofed/infiniband-diags/build/ibnetdiscover/Makefile
@@ -0,0 +1,8 @@
+# $FreeBSD$
+
+PROG= ibnetdiscover
+SRCS= ibnetdiscover.c
+LIBADD= ibnetdisc
+MAN= ibnetdiscover.8
+
+.include <bsd.prog.mk>
diff --git a/contrib/ofed/infiniband-diags/build/ibping/Makefile b/contrib/ofed/infiniband-diags/build/ibping/Makefile
new file mode 100644
index 0000000..e573f78
--- /dev/null
+++ b/contrib/ofed/infiniband-diags/build/ibping/Makefile
@@ -0,0 +1,7 @@
+# $FreeBSD$
+
+PROG= ibping
+SRCS= ibping.c
+MAN= ibping.8
+
+.include <bsd.prog.mk>
diff --git a/contrib/ofed/infiniband-diags/build/ibportstate/Makefile b/contrib/ofed/infiniband-diags/build/ibportstate/Makefile
new file mode 100644
index 0000000..98dc34c
--- /dev/null
+++ b/contrib/ofed/infiniband-diags/build/ibportstate/Makefile
@@ -0,0 +1,7 @@
+# $FreeBSD$
+
+PROG= ibportstate
+SRCS= ibportstate.c
+MAN= ibportstate.8
+
+.include <bsd.prog.mk>
diff --git a/contrib/ofed/infiniband-diags/build/ibqueryerrors/Makefile b/contrib/ofed/infiniband-diags/build/ibqueryerrors/Makefile
new file mode 100644
index 0000000..c4be267
--- /dev/null
+++ b/contrib/ofed/infiniband-diags/build/ibqueryerrors/Makefile
@@ -0,0 +1,8 @@
+# $FreeBSD$
+
+PROG= ibqueryerrors
+SRCS= ibqueryerrors.c
+LIBADD= ibnetdisc
+MAN= ibqueryerrors.8
+
+.include <bsd.prog.mk>
diff --git a/contrib/ofed/infiniband-diags/build/ibroute/Makefile b/contrib/ofed/infiniband-diags/build/ibroute/Makefile
new file mode 100644
index 0000000..1914fca
--- /dev/null
+++ b/contrib/ofed/infiniband-diags/build/ibroute/Makefile
@@ -0,0 +1,7 @@
+# $FreeBSD$
+
+PROG= ibroute
+SRCS= ibroute.c
+MAN= ibroute.8
+
+.include <bsd.prog.mk>
diff --git a/contrib/ofed/infiniband-diags/build/ibstat/Makefile b/contrib/ofed/infiniband-diags/build/ibstat/Makefile
new file mode 100644
index 0000000..812cd03
--- /dev/null
+++ b/contrib/ofed/infiniband-diags/build/ibstat/Makefile
@@ -0,0 +1,7 @@
+# $FreeBSD$
+
+PROG= ibstat
+SRCS= ibstat.c
+MAN= ibstat.8
+
+.include <bsd.prog.mk>
diff --git a/contrib/ofed/infiniband-diags/build/ibsysstat/Makefile b/contrib/ofed/infiniband-diags/build/ibsysstat/Makefile
new file mode 100644
index 0000000..b2f0ab7
--- /dev/null
+++ b/contrib/ofed/infiniband-diags/build/ibsysstat/Makefile
@@ -0,0 +1,7 @@
+# $FreeBSD$
+
+PROG= ibsysstat
+SRCS= ibsysstat.c
+MAN= ibsysstat.8
+
+.include <bsd.prog.mk>
diff --git a/contrib/ofed/infiniband-diags/build/ibtracert/Makefile b/contrib/ofed/infiniband-diags/build/ibtracert/Makefile
new file mode 100644
index 0000000..ea6d66a
--- /dev/null
+++ b/contrib/ofed/infiniband-diags/build/ibtracert/Makefile
@@ -0,0 +1,7 @@
+# $FreeBSD$
+
+PROG= ibtracert
+SRCS= ibtracert.c
+MAN= ibtracert.8
+
+.include <bsd.prog.mk>
diff --git a/contrib/ofed/infiniband-diags/build/perfquery/Makefile b/contrib/ofed/infiniband-diags/build/perfquery/Makefile
new file mode 100644
index 0000000..3b4cb53
--- /dev/null
+++ b/contrib/ofed/infiniband-diags/build/perfquery/Makefile
@@ -0,0 +1,7 @@
+# $FreeBSD$
+
+PROG= perfquery
+SRCS= perfquery.c
+MAN= perfquery.8
+
+.include <bsd.prog.mk>
diff --git a/contrib/ofed/infiniband-diags/build/saquery/Makefile b/contrib/ofed/infiniband-diags/build/saquery/Makefile
new file mode 100644
index 0000000..f330cd3
--- /dev/null
+++ b/contrib/ofed/infiniband-diags/build/saquery/Makefile
@@ -0,0 +1,7 @@
+# $FreeBSD$
+
+PROG= saquery
+SRCS= saquery.c
+MAN= saquery.8
+
+.include <bsd.prog.mk>
diff --git a/contrib/ofed/infiniband-diags/build/sminfo/Makefile b/contrib/ofed/infiniband-diags/build/sminfo/Makefile
new file mode 100644
index 0000000..b83d759
--- /dev/null
+++ b/contrib/ofed/infiniband-diags/build/sminfo/Makefile
@@ -0,0 +1,7 @@
+# $FreeBSD$
+
+PROG= sminfo
+SRCS= sminfo.c
+MAN= sminfo.8
+
+.include <bsd.prog.mk>
diff --git a/contrib/ofed/infiniband-diags/build/smpdump/Makefile b/contrib/ofed/infiniband-diags/build/smpdump/Makefile
new file mode 100644
index 0000000..ae1c680
--- /dev/null
+++ b/contrib/ofed/infiniband-diags/build/smpdump/Makefile
@@ -0,0 +1,7 @@
+# $FreeBSD$
+
+PROG= smpdump
+SRCS= smpdump.c
+MAN= smpdump.8
+
+.include <bsd.prog.mk>
diff --git a/contrib/ofed/infiniband-diags/build/smpquery/Makefile b/contrib/ofed/infiniband-diags/build/smpquery/Makefile
new file mode 100644
index 0000000..4654ce4
--- /dev/null
+++ b/contrib/ofed/infiniband-diags/build/smpquery/Makefile
@@ -0,0 +1,7 @@
+# $FreeBSD$
+
+PROG= smpquery
+SRCS= smpquery.c
+MAN= smpquery.8
+
+.include <bsd.prog.mk>
diff --git a/contrib/ofed/infiniband-diags/build/vendstat/Makefile b/contrib/ofed/infiniband-diags/build/vendstat/Makefile
new file mode 100644
index 0000000..b548537
--- /dev/null
+++ b/contrib/ofed/infiniband-diags/build/vendstat/Makefile
@@ -0,0 +1,7 @@
+# $FreeBSD$
+
+PROG= vendstat
+SRCS= vendstat.c
+MAN= vendstat.8
+
+.include <bsd.prog.mk>
diff --git a/contrib/ofed/infiniband-diags/config.h b/contrib/ofed/infiniband-diags/config.h
new file mode 100644
index 0000000..d203120
--- /dev/null
+++ b/contrib/ofed/infiniband-diags/config.h
@@ -0,0 +1,125 @@
+/* config.h. Generated from config.h.in by configure. */
+/* config.h.in. Generated from configure.ac by autoheader. */
+
+/* Define to 1 if you have the <dlfcn.h> header file. */
+#define HAVE_DLFCN_H 1
+
+/* Define to 1 if you don't have `vprintf' but do have `_doprnt.' */
+/* #undef HAVE_DOPRNT */
+
+/* Define to 1 if you have the <fcntl.h> header file. */
+#define HAVE_FCNTL_H 1
+
+/* Define to 1 to indicate GLIB support */
+/* #undef HAVE_GLIB */
+
+/* Define if IB_PC_QP1_DROP_F exists in mad.h enum MAD_FIELDS. */
+#define HAVE_IB_PC_QP1_DROP_F 1
+
+/* Define to 1 if you have the <inttypes.h> header file. */
+#define HAVE_INTTYPES_H 1
+
+/* Define to 1 if you have the `ibmad' library (-libmad). */
+#define HAVE_LIBIBMAD 1
+
+/* Define to 1 if you have the `ibumad' library (-libumad). */
+#define HAVE_LIBIBUMAD 1
+
+/* Define to 1 if you have the `osmcomp' library (-losmcomp). */
+#define HAVE_LIBOSMCOMP 1
+
+/* Define to 1 if you have the `udev' library (-ludev). */
+/* #undef HAVE_LIBUDEV */
+
+/* Define to 1 if you have the <memory.h> header file. */
+#define HAVE_MEMORY_H 1
+
+/* Define to 1 if you have the `memset' function. */
+#define HAVE_MEMSET 1
+
+/* Define to 1 if you have the <netinet/in.h> header file. */
+#define HAVE_NETINET_IN_H 1
+
+/* Define to 1 if you have the <stdint.h> header file. */
+#define HAVE_STDINT_H 1
+
+/* Define to 1 if you have the <stdlib.h> header file. */
+#define HAVE_STDLIB_H 1
+
+/* Define to 1 if you have the `strchr' function. */
+#define HAVE_STRCHR 1
+
+/* Define to 1 if you have the <strings.h> header file. */
+#define HAVE_STRINGS_H 1
+
+/* Define to 1 if you have the <string.h> header file. */
+#define HAVE_STRING_H 1
+
+/* Define to 1 if you have the `strrchr' function. */
+#define HAVE_STRRCHR 1
+
+/* Define to 1 if you have the `strtol' function. */
+#define HAVE_STRTOL 1
+
+/* Define to 1 if you have the `strtoul' function. */
+#define HAVE_STRTOUL 1
+
+/* Define to 1 if you have the `strtoull' function. */
+#define HAVE_STRTOULL 1
+
+/* Define to 1 if you have the <sys/ioctl.h> header file. */
+#define HAVE_SYS_IOCTL_H 1
+
+/* Define to 1 if you have the <sys/stat.h> header file. */
+#define HAVE_SYS_STAT_H 1
+
+/* Define to 1 if you have the <sys/types.h> header file. */
+#define HAVE_SYS_TYPES_H 1
+
+/* Define to 1 if you have the `udev_get_sys_path' function. */
+/* #undef HAVE_UDEV_GET_SYS_PATH */
+
+/* Define to 1 if struct umad_port has link_layer member */
+#define HAVE_UMAD_PORT_LINK_LAYER 1
+
+/* Define to 1 if you have the <unistd.h> header file. */
+#define HAVE_UNISTD_H 1
+
+/* Define to 1 if you have the `vprintf' function. */
+#define HAVE_VPRINTF 1
+
+/* Define the path to configurations */
+#define IBDIAG_CONFIG_PATH "/etc/infiniband-diags"
+
+/* Define to the sub-directory where libtool stores uninstalled libraries. */
+#define LT_OBJDIR ".libs/"
+
+/* Name of package */
+#define PACKAGE "infiniband-diags"
+
+/* Define to the address where bug reports for this package should be sent. */
+#define PACKAGE_BUGREPORT "linux-rdma@vger.kernel.org"
+
+/* Define to the full name of this package. */
+#define PACKAGE_NAME "infiniband-diags"
+
+/* Define to the full name and version of this package. */
+#define PACKAGE_STRING "infiniband-diags 1.6.7"
+
+/* Define to the one symbol short name of this package. */
+#define PACKAGE_TARNAME "infiniband-diags"
+
+/* Define to the home page for this package. */
+#define PACKAGE_URL ""
+
+/* Define to the version of this package. */
+#define PACKAGE_VERSION "1.6.7"
+
+/* Define to 1 if you have the ANSI C header files. */
+#define STDC_HEADERS 1
+
+/* Version number of package */
+#define VERSION "1.6.7"
+
+/* Define to empty if `const' does not conform to ANSI C. */
+/* #undef const */
diff --git a/contrib/ofed/infiniband-diags/man/check_lft_balance.8 b/contrib/ofed/infiniband-diags/man/check_lft_balance.8
new file mode 100644
index 0000000..af0580f
--- /dev/null
+++ b/contrib/ofed/infiniband-diags/man/check_lft_balance.8
@@ -0,0 +1,68 @@
+.\" Man page generated from reStructuredText.
+.
+.TH CHECK_LFT_BALANCE 8 "" "" "Open IB Diagnostics"
+.SH NAME
+CHECK_LFT_BALANCE \-
+.
+.nr rst2man-indent-level 0
+.
+.de1 rstReportMargin
+\\$1 \\n[an-margin]
+level \\n[rst2man-indent-level]
+level margin: \\n[rst2man-indent\\n[rst2man-indent-level]]
+-
+\\n[rst2man-indent0]
+\\n[rst2man-indent1]
+\\n[rst2man-indent2]
+..
+.de1 INDENT
+.\" .rstReportMargin pre:
+. RS \\$1
+. nr rst2man-indent\\n[rst2man-indent-level] \\n[an-margin]
+. nr rst2man-indent-level +1
+.\" .rstReportMargin post:
+..
+.de UNINDENT
+. RE
+.\" indent \\n[an-margin]
+.\" old: \\n[rst2man-indent\\n[rst2man-indent-level]]
+.nr rst2man-indent-level -1
+.\" new: \\n[rst2man-indent\\n[rst2man-indent-level]]
+.in \\n[rst2man-indent\\n[rst2man-indent-level]]u
+..
+.SH CHECK INFINIBAND UNICAST FORWARDING TABLES BALANCE
+.SS SYNOPSIS
+.sp
+check_lft_balance.sh [\-hRv]
+.SS DESCRIPTION
+.sp
+check_lft_balance.sh is a script which checks for balancing in Infiniband
+unicast forwarding tables. It analyzes the output of
+\fBdump_lfts(8)\fP and \fBiblinkinfo(8)\fP
+.SS OPTIONS
+.INDENT 0.0
+.TP
+.B \fB\-h\fP
+show help
+.TP
+.B \fB\-R\fP
+Recalculate dump_lfts information, ie do not use the cached
+information. This option is slower but should be used if the diag
+tools have not been used for some time or if there are other reasons to
+believe that the fabric has changed.
+.TP
+.B \fB\-v\fP
+verbose output
+.UNINDENT
+.SS SEE ALSO
+.sp
+\fBdump_lfts(8)\fP
+\fBiblinkinfo(8)\fP
+.SS AUTHORS
+.INDENT 0.0
+.TP
+.B Albert Chu
+< \fI\%chu11@llnl.gov\fP >
+.UNINDENT
+.\" Generated by docutils manpage writer.
+.
diff --git a/contrib/ofed/infiniband-diags/man/dump_fts.8 b/contrib/ofed/infiniband-diags/man/dump_fts.8
new file mode 100644
index 0000000..ef77502
--- /dev/null
+++ b/contrib/ofed/infiniband-diags/man/dump_fts.8
@@ -0,0 +1,235 @@
+.\" Man page generated from reStructuredText.
+.
+.TH DUMP_FTS 8 "" "" "OpenIB Diagnostics"
+.SH NAME
+DUMP_FTS \- dump InfiniBand forwarding tables
+.
+.nr rst2man-indent-level 0
+.
+.de1 rstReportMargin
+\\$1 \\n[an-margin]
+level \\n[rst2man-indent-level]
+level margin: \\n[rst2man-indent\\n[rst2man-indent-level]]
+-
+\\n[rst2man-indent0]
+\\n[rst2man-indent1]
+\\n[rst2man-indent2]
+..
+.de1 INDENT
+.\" .rstReportMargin pre:
+. RS \\$1
+. nr rst2man-indent\\n[rst2man-indent-level] \\n[an-margin]
+. nr rst2man-indent-level +1
+.\" .rstReportMargin post:
+..
+.de UNINDENT
+. RE
+.\" indent \\n[an-margin]
+.\" old: \\n[rst2man-indent\\n[rst2man-indent-level]]
+.nr rst2man-indent-level -1
+.\" new: \\n[rst2man-indent\\n[rst2man-indent-level]]
+.in \\n[rst2man-indent\\n[rst2man-indent-level]]u
+..
+.SH SYNOPSIS
+.sp
+dump_fts [options] [<startlid> [<endlid>]]
+.SH DESCRIPTION
+.sp
+dump_fts is similar to ibroute but dumps tables for every switch found in an
+ibnetdiscover scan of the subnet.
+.sp
+The dump file format is compatible with loading into OpenSM using
+the \-R file \-U /path/to/dump\-file syntax.
+.SH OPTIONS
+.INDENT 0.0
+.TP
+.B \fB\-a, \-\-all\fP
+show all lids in range, even invalid entries
+.TP
+.B \fB\-n, \-\-no_dests\fP
+do not try to resolve destinations
+.TP
+.B \fB\-M, \-\-Multicast\fP
+show multicast forwarding tables
+In this case, the range parameters are specifying the mlid range.
+.UNINDENT
+.SS Port Selection flags
+.\" Define the common option -C
+.
+.sp
+\fB\-C, \-\-Ca <ca_name>\fP use the specified ca_name.
+.\" Define the common option -P
+.
+.sp
+\fB\-P, \-\-Port <ca_port>\fP use the specified ca_port.
+.\" Explanation of local port selection
+.
+.SS Local port Selection
+.sp
+Multiple port/Multiple CA support: when no IB device or port is specified
+(see the "local umad parameters" below), the libibumad library
+selects the port to use by the following criteria:
+.INDENT 0.0
+.INDENT 3.5
+.INDENT 0.0
+.IP 1. 3
+the first port that is ACTIVE.
+.IP 2. 3
+if not found, the first port that is UP (physical link up).
+.UNINDENT
+.sp
+If a port and/or CA name is specified, the libibumad library attempts
+to fulfill the user request, and will fail if it is not possible.
+.sp
+For example:
+.INDENT 0.0
+.INDENT 3.5
+.sp
+.nf
+.ft C
+ibaddr # use the first port (criteria #1 above)
+ibaddr \-C mthca1 # pick the best port from "mthca1" only.
+ibaddr \-P 2 # use the second (active/up) port from the first available IB device.
+ibaddr \-C mthca0 \-P 2 # use the specified port only.
+.ft P
+.fi
+.UNINDENT
+.UNINDENT
+.UNINDENT
+.UNINDENT
+.SS Debugging flags
+.\" Define the common option -d
+.
+.INDENT 0.0
+.TP
+.B \-d
+raise the IB debugging level.
+May be used several times (\-ddd or \-d \-d \-d).
+.UNINDENT
+.\" Define the common option -e
+.
+.INDENT 0.0
+.TP
+.B \-e
+show send and receive errors (timeouts and others)
+.UNINDENT
+.\" Define the common option -h
+.
+.sp
+\fB\-h, \-\-help\fP show the usage message
+.\" Define the common option -v
+.
+.INDENT 0.0
+.TP
+.B \fB\-v, \-\-verbose\fP
+increase the application verbosity level.
+May be used several times (\-vv or \-v \-v \-v)
+.UNINDENT
+.\" Define the common option -V
+.
+.sp
+\fB\-V, \-\-version\fP show the version info.
+.SS Configuration flags
+.\" Define the common option -t
+.
+.sp
+\fB\-t, \-\-timeout <timeout_ms>\fP override the default timeout for the solicited mads.
+.\" Define the common option -y
+.
+.INDENT 0.0
+.TP
+.B \fB\-y, \-\-m_key <key>\fP
+use the specified M_key for requests. If non\-numeric value (like \(aqx\(aq)
+is specified then a value will be prompted for.
+.UNINDENT
+.\" Define the common option --node-name-map
+.
+.sp
+\fB\-\-node\-name\-map <node\-name\-map>\fP Specify a node name map.
+.INDENT 0.0
+.INDENT 3.5
+This file maps GUIDs to more user friendly names. See FILES section.
+.UNINDENT
+.UNINDENT
+.\" Define the common option -z
+.
+.sp
+\fB\-\-config, \-z <config_file>\fP Specify alternate config file.
+.INDENT 0.0
+.INDENT 3.5
+Default: /etc/infiniband-diags/ibdiag.conf
+.UNINDENT
+.UNINDENT
+.SH FILES
+.\" Common text for the config file
+.
+.SS CONFIG FILE
+.sp
+/etc/infiniband-diags/ibdiag.conf
+.sp
+A global config file is provided to set some of the common options for all
+tools. See supplied config file for details.
+.\" Common text to describe the node name map file.
+.
+.SS NODE NAME MAP FILE FORMAT
+.sp
+The node name map is used to specify user friendly names for nodes in the
+output. GUIDs are used to perform the lookup.
+.sp
+This functionality is provided by the opensm\-libs package. See \fBopensm(8)\fP
+for the file location for your installation.
+.sp
+\fBGenerically:\fP
+.INDENT 0.0
+.INDENT 3.5
+.sp
+.nf
+.ft C
+# comment
+<guid> "<name>"
+.ft P
+.fi
+.UNINDENT
+.UNINDENT
+.sp
+\fBExample:\fP
+.INDENT 0.0
+.INDENT 3.5
+.sp
+.nf
+.ft C
+# IB1
+# Line cards
+0x0008f104003f125c "IB1 (Rack 11 slot 1 ) ISR9288/ISR9096 Voltaire sLB\-24D"
+0x0008f104003f125d "IB1 (Rack 11 slot 1 ) ISR9288/ISR9096 Voltaire sLB\-24D"
+0x0008f104003f10d2 "IB1 (Rack 11 slot 2 ) ISR9288/ISR9096 Voltaire sLB\-24D"
+0x0008f104003f10d3 "IB1 (Rack 11 slot 2 ) ISR9288/ISR9096 Voltaire sLB\-24D"
+0x0008f104003f10bf "IB1 (Rack 11 slot 12 ) ISR9288/ISR9096 Voltaire sLB\-24D"
+
+# Spines
+0x0008f10400400e2d "IB1 (Rack 11 spine 1 ) ISR9288 Voltaire sFB\-12D"
+0x0008f10400400e2e "IB1 (Rack 11 spine 1 ) ISR9288 Voltaire sFB\-12D"
+0x0008f10400400e2f "IB1 (Rack 11 spine 1 ) ISR9288 Voltaire sFB\-12D"
+0x0008f10400400e31 "IB1 (Rack 11 spine 2 ) ISR9288 Voltaire sFB\-12D"
+0x0008f10400400e32 "IB1 (Rack 11 spine 2 ) ISR9288 Voltaire sFB\-12D"
+
+# GUID Node Name
+0x0008f10400411a08 "SW1 (Rack 3) ISR9024 Voltaire 9024D"
+0x0008f10400411a28 "SW2 (Rack 3) ISR9024 Voltaire 9024D"
+0x0008f10400411a34 "SW3 (Rack 3) ISR9024 Voltaire 9024D"
+0x0008f104004119d0 "SW4 (Rack 3) ISR9024 Voltaire 9024D"
+.ft P
+.fi
+.UNINDENT
+.UNINDENT
+.SH SEE ALSO
+.sp
+\fBdump_lfts(8), dump_mfts(8), ibroute(8), ibswitches(8), opensm(8)\fP
+.SH AUTHORS
+.INDENT 0.0
+.TP
+.B Ira Weiny
+< \fI\%ira.weiny@intel.com\fP >
+.UNINDENT
+.\" Generated by docutils manpage writer.
+.
diff --git a/contrib/ofed/infiniband-diags/man/ibaddr.8 b/contrib/ofed/infiniband-diags/man/ibaddr.8
new file mode 100644
index 0000000..2b476da
--- /dev/null
+++ b/contrib/ofed/infiniband-diags/man/ibaddr.8
@@ -0,0 +1,214 @@
+.\" Man page generated from reStructuredText.
+.
+.TH IBADDR 8 "" "" "OpenIB Diagnostics"
+.SH NAME
+IBADDR \- query InfiniBand address(es)
+.
+.nr rst2man-indent-level 0
+.
+.de1 rstReportMargin
+\\$1 \\n[an-margin]
+level \\n[rst2man-indent-level]
+level margin: \\n[rst2man-indent\\n[rst2man-indent-level]]
+-
+\\n[rst2man-indent0]
+\\n[rst2man-indent1]
+\\n[rst2man-indent2]
+..
+.de1 INDENT
+.\" .rstReportMargin pre:
+. RS \\$1
+. nr rst2man-indent\\n[rst2man-indent-level] \\n[an-margin]
+. nr rst2man-indent-level +1
+.\" .rstReportMargin post:
+..
+.de UNINDENT
+. RE
+.\" indent \\n[an-margin]
+.\" old: \\n[rst2man-indent\\n[rst2man-indent-level]]
+.nr rst2man-indent-level -1
+.\" new: \\n[rst2man-indent\\n[rst2man-indent-level]]
+.in \\n[rst2man-indent\\n[rst2man-indent-level]]u
+..
+.SH SYNOPSIS
+.sp
+ibaddr [options]
+.SH DESCRIPTION
+.sp
+Display the lid (and range) as well as the GID address of the
+port specified (by DR path, lid, or GUID) or the local port by default.
+.sp
+Note: this utility can be used as simple address resolver.
+.SH OPTIONS
+.sp
+\fB\-\-gid_show, \-g\fP
+show gid address only
+.sp
+\fB\-\-lid_show, \-l\fP
+show lid range only
+.sp
+\fB\-\-Lid_show, \-L\fP
+show lid range (in decimal) only
+.SS Addressing Flags
+.\" Define the common option -D for Directed routes
+.
+.sp
+\fB\-D, \-\-Direct\fP The address specified is a directed route
+.INDENT 0.0
+.INDENT 3.5
+.sp
+.nf
+.ft C
+Examples:
+ [options] \-D [options] "0" # self port
+ [options] \-D [options] "0,1,2,1,4" # out via port 1, then 2, ...
+
+ (Note the second number in the path specified must match the port being
+ used. This can be specified using the port selection flag \(aq\-P\(aq or the
+ port found through the automatic selection process.)
+.ft P
+.fi
+.UNINDENT
+.UNINDENT
+.\" Define the common option -G
+.
+.sp
+\fB\-G, \-\-Guid\fP The address specified is a Port GUID
+.\" Define the common option -s
+.
+.sp
+\fB\-s, \-\-sm_port <smlid>\fP use \(aqsmlid\(aq as the target lid for SA queries.
+.SS Debugging flags
+.\" Define the common option -d
+.
+.INDENT 0.0
+.TP
+.B \-d
+raise the IB debugging level.
+May be used several times (\-ddd or \-d \-d \-d).
+.UNINDENT
+.\" Define the common option -e
+.
+.INDENT 0.0
+.TP
+.B \-e
+show send and receive errors (timeouts and others)
+.UNINDENT
+.\" Define the common option -h
+.
+.sp
+\fB\-h, \-\-help\fP show the usage message
+.\" Define the common option -v
+.
+.INDENT 0.0
+.TP
+.B \fB\-v, \-\-verbose\fP
+increase the application verbosity level.
+May be used several times (\-vv or \-v \-v \-v)
+.UNINDENT
+.\" Define the common option -V
+.
+.sp
+\fB\-V, \-\-version\fP show the version info.
+.SS Port Selection flags
+.\" Define the common option -C
+.
+.sp
+\fB\-C, \-\-Ca <ca_name>\fP use the specified ca_name.
+.\" Define the common option -P
+.
+.sp
+\fB\-P, \-\-Port <ca_port>\fP use the specified ca_port.
+.\" Explanation of local port selection
+.
+.SS Local port Selection
+.sp
+Multiple port/Multiple CA support: when no IB device or port is specified
+(see the "local umad parameters" below), the libibumad library
+selects the port to use by the following criteria:
+.INDENT 0.0
+.INDENT 3.5
+.INDENT 0.0
+.IP 1. 3
+the first port that is ACTIVE.
+.IP 2. 3
+if not found, the first port that is UP (physical link up).
+.UNINDENT
+.sp
+If a port and/or CA name is specified, the libibumad library attempts
+to fulfill the user request, and will fail if it is not possible.
+.sp
+For example:
+.INDENT 0.0
+.INDENT 3.5
+.sp
+.nf
+.ft C
+ibaddr # use the first port (criteria #1 above)
+ibaddr \-C mthca1 # pick the best port from "mthca1" only.
+ibaddr \-P 2 # use the second (active/up) port from the first available IB device.
+ibaddr \-C mthca0 \-P 2 # use the specified port only.
+.ft P
+.fi
+.UNINDENT
+.UNINDENT
+.UNINDENT
+.UNINDENT
+.SS Configuration flags
+.\" Define the common option -y
+.
+.INDENT 0.0
+.TP
+.B \fB\-y, \-\-m_key <key>\fP
+use the specified M_key for requests. If non\-numeric value (like \(aqx\(aq)
+is specified then a value will be prompted for.
+.UNINDENT
+.\" Define the common option -t
+.
+.sp
+\fB\-t, \-\-timeout <timeout_ms>\fP override the default timeout for the solicited mads.
+.\" Define the common option -z
+.
+.sp
+\fB\-\-config, \-z <config_file>\fP Specify alternate config file.
+.INDENT 0.0
+.INDENT 3.5
+Default: /etc/infiniband-diags/ibdiag.conf
+.UNINDENT
+.UNINDENT
+.SH FILES
+.\" Common text for the config file
+.
+.SS CONFIG FILE
+.sp
+/etc/infiniband-diags/ibdiag.conf
+.sp
+A global config file is provided to set some of the common options for all
+tools. See supplied config file for details.
+.SH EXAMPLES
+.INDENT 0.0
+.INDENT 3.5
+.sp
+.nf
+.ft C
+ibaddr # local port\e\(aqs address
+ibaddr 32 # show lid range and gid of lid 32
+ibaddr \-G 0x8f1040023 # same but using guid address
+ibaddr \-l 32 # show lid range only
+ibaddr \-L 32 # show decimal lid range only
+ibaddr \-g 32 # show gid address only
+.ft P
+.fi
+.UNINDENT
+.UNINDENT
+.SH SEE ALSO
+.sp
+\fBibroute (8), ibtracert (8)\fP
+.SH AUTHOR
+.INDENT 0.0
+.TP
+.B Hal Rosenstock
+< \fI\%halr@voltaire.com\fP >
+.UNINDENT
+.\" Generated by docutils manpage writer.
+.
diff --git a/contrib/ofed/infiniband-diags/man/ibcacheedit.8 b/contrib/ofed/infiniband-diags/man/ibcacheedit.8
new file mode 100644
index 0000000..7e3830a
--- /dev/null
+++ b/contrib/ofed/infiniband-diags/man/ibcacheedit.8
@@ -0,0 +1,80 @@
+.\" Man page generated from reStructuredText.
+.
+.TH IBCACHEEDIT 8 "" "" "Open IB Diagnostics"
+.SH NAME
+IBCACHEEDIT \-
+.
+.nr rst2man-indent-level 0
+.
+.de1 rstReportMargin
+\\$1 \\n[an-margin]
+level \\n[rst2man-indent-level]
+level margin: \\n[rst2man-indent\\n[rst2man-indent-level]]
+-
+\\n[rst2man-indent0]
+\\n[rst2man-indent1]
+\\n[rst2man-indent2]
+..
+.de1 INDENT
+.\" .rstReportMargin pre:
+. RS \\$1
+. nr rst2man-indent\\n[rst2man-indent-level] \\n[an-margin]
+. nr rst2man-indent-level +1
+.\" .rstReportMargin post:
+..
+.de UNINDENT
+. RE
+.\" indent \\n[an-margin]
+.\" old: \\n[rst2man-indent\\n[rst2man-indent-level]]
+.nr rst2man-indent-level -1
+.\" new: \\n[rst2man-indent\\n[rst2man-indent-level]]
+.in \\n[rst2man-indent\\n[rst2man-indent-level]]u
+..
+.SH EDIT AN IBNETDISCOVER CACHE
+.SS SYNOPSIS
+.sp
+ibcacheedit [options] <orig.cache> <new.cache>
+.SS DESCRIPTION
+.sp
+ibcacheedit allows users to edit an ibnetdiscover cache created through the
+\fB\-\-cache\fP option in \fBibnetdiscover(8)\fP .
+.SS OPTIONS
+.INDENT 0.0
+.TP
+.B \fB\-\-switchguid BEFOREGUID:AFTERGUID\fP
+Specify a switchguid that should be changed. The before and after guid
+should be separated by a colon. On switches, port guids are identical
+to the switch guid, so port guids will be adjusted as well on switches.
+.TP
+.B \fB\-\-caguid BEFOREGUID:AFTERGUID\fP
+Specify a caguid that should be changed. The before and after guid
+should be separated by a colon.
+.TP
+.B \fB\-\-sysimgguid BEFOREGUID:AFTERGUID\fP
+Specify a sysimgguid that should be changed. The before and after guid
+should be spearated by a colon.
+.TP
+.B \fB\-\-portguid NODEGUID:BEFOREGUID:AFTERGUID\fP
+Specify a portguid that should be changed. The nodeguid of the port
+(e.g. switchguid or caguid) should be specified first, followed by a
+colon, the before port guid, another colon, then the after port guid.
+On switches, port guids are identical to the switch guid, so the switch
+guid will be adjusted as well on switches.
+.UNINDENT
+.SS Debugging flags
+.\" Define the common option -h
+.
+.sp
+\fB\-h, \-\-help\fP show the usage message
+.\" Define the common option -V
+.
+.sp
+\fB\-V, \-\-version\fP show the version info.
+.SS AUTHORS
+.INDENT 0.0
+.TP
+.B Albert Chu
+< \fI\%chu11@llnl.gov\fP >
+.UNINDENT
+.\" Generated by docutils manpage writer.
+.
diff --git a/contrib/ofed/infiniband-diags/man/ibccconfig.8 b/contrib/ofed/infiniband-diags/man/ibccconfig.8
new file mode 100644
index 0000000..9d244f2
--- /dev/null
+++ b/contrib/ofed/infiniband-diags/man/ibccconfig.8
@@ -0,0 +1,198 @@
+.\" Man page generated from reStructuredText.
+.
+.TH IBCCCONFIG 8 "" "" "OpenIB Diagnostics"
+.SH NAME
+IBCCCONFIG \- configure congestion control settings
+.
+.nr rst2man-indent-level 0
+.
+.de1 rstReportMargin
+\\$1 \\n[an-margin]
+level \\n[rst2man-indent-level]
+level margin: \\n[rst2man-indent\\n[rst2man-indent-level]]
+-
+\\n[rst2man-indent0]
+\\n[rst2man-indent1]
+\\n[rst2man-indent2]
+..
+.de1 INDENT
+.\" .rstReportMargin pre:
+. RS \\$1
+. nr rst2man-indent\\n[rst2man-indent-level] \\n[an-margin]
+. nr rst2man-indent-level +1
+.\" .rstReportMargin post:
+..
+.de UNINDENT
+. RE
+.\" indent \\n[an-margin]
+.\" old: \\n[rst2man-indent\\n[rst2man-indent-level]]
+.nr rst2man-indent-level -1
+.\" new: \\n[rst2man-indent\\n[rst2man-indent-level]]
+.in \\n[rst2man-indent\\n[rst2man-indent-level]]u
+..
+.SH SYNOPSIS
+.sp
+ibccconfig [common_options] [\-c cckey] [\-\-dgid gid] <op> <lid|guid> [port]
+.SH DESCRIPTION
+.sp
+\fBibccconfig\fP
+supports the configuration of congestion control settings on switches
+and HCAs.
+.sp
+\fBWARNING \-\- You should understand what you are doing before using this tool.
+Misuse of this tool could result in a broken fabric.\fP
+.SH OPTIONS
+.INDENT 0.0
+.TP
+.B Current supported operations and their parameters:
+CongestionKeyInfo (CK) <lid|guid> <cckey> <cckeyprotectbit> <cckeyleaseperiod> <cckeyviolations>
+SwitchCongestionSetting (SS) <lid|guid> <controlmap> <victimmask> <creditmask> <threshold> <packetsize> <csthreshold> <csreturndelay> <markingrate>
+SwitchPortCongestionSetting (SP) <lid|guid> <portnum> <valid> <control_type> <threshold> <packet_size> <cong_parm_marking_rate>
+CACongestionSetting (CS) <lid|guid> <port_control> <control_map> <ccti_timer> <ccti_increase> <trigger_threshold> <ccti_min>
+CongestionControlTable (CT) <lid|guid> <cctilimit> <index> <cctentry> <cctentry> ...
+.UNINDENT
+.sp
+\fB\-\-cckey, \-c, <cckey>\fP
+Specify a congestion control (CC) key. If none is specified, a key of 0 is used.
+.sp
+\fB\-\-dgid <dgid>\fP
+destination GID: use when GRH is required in packets (IPv6 format)
+.SS Debugging flags
+.\" Define the common option -d
+.
+.INDENT 0.0
+.TP
+.B \-d
+raise the IB debugging level.
+May be used several times (\-ddd or \-d \-d \-d).
+.UNINDENT
+.\" Define the common option -e
+.
+.INDENT 0.0
+.TP
+.B \-e
+show send and receive errors (timeouts and others)
+.UNINDENT
+.\" Define the common option -h
+.
+.sp
+\fB\-h, \-\-help\fP show the usage message
+.\" Define the common option -v
+.
+.INDENT 0.0
+.TP
+.B \fB\-v, \-\-verbose\fP
+increase the application verbosity level.
+May be used several times (\-vv or \-v \-v \-v)
+.UNINDENT
+.\" Define the common option -V
+.
+.sp
+\fB\-V, \-\-version\fP show the version info.
+.SS Addressing Flags
+.\" Define the common option -G
+.
+.sp
+\fB\-G, \-\-Guid\fP The address specified is a Port GUID
+.\" Define the common option -L
+.
+.sp
+\fB\-L, \-\-Lid\fP The address specified is a LID
+.\" Define the common option -s
+.
+.sp
+\fB\-s, \-\-sm_port <smlid>\fP use \(aqsmlid\(aq as the target lid for SA queries.
+.SS Port Selection flags
+.\" Define the common option -C
+.
+.sp
+\fB\-C, \-\-Ca <ca_name>\fP use the specified ca_name.
+.\" Define the common option -P
+.
+.sp
+\fB\-P, \-\-Port <ca_port>\fP use the specified ca_port.
+.\" Explanation of local port selection
+.
+.SS Local port Selection
+.sp
+Multiple port/Multiple CA support: when no IB device or port is specified
+(see the "local umad parameters" below), the libibumad library
+selects the port to use by the following criteria:
+.INDENT 0.0
+.INDENT 3.5
+.INDENT 0.0
+.IP 1. 3
+the first port that is ACTIVE.
+.IP 2. 3
+if not found, the first port that is UP (physical link up).
+.UNINDENT
+.sp
+If a port and/or CA name is specified, the libibumad library attempts
+to fulfill the user request, and will fail if it is not possible.
+.sp
+For example:
+.INDENT 0.0
+.INDENT 3.5
+.sp
+.nf
+.ft C
+ibaddr # use the first port (criteria #1 above)
+ibaddr \-C mthca1 # pick the best port from "mthca1" only.
+ibaddr \-P 2 # use the second (active/up) port from the first available IB device.
+ibaddr \-C mthca0 \-P 2 # use the specified port only.
+.ft P
+.fi
+.UNINDENT
+.UNINDENT
+.UNINDENT
+.UNINDENT
+.SS Configuration flags
+.\" Define the common option -y
+.
+.INDENT 0.0
+.TP
+.B \fB\-y, \-\-m_key <key>\fP
+use the specified M_key for requests. If non\-numeric value (like \(aqx\(aq)
+is specified then a value will be prompted for.
+.UNINDENT
+.\" Define the common option -z
+.
+.sp
+\fB\-\-config, \-z <config_file>\fP Specify alternate config file.
+.INDENT 0.0
+.INDENT 3.5
+Default: /etc/infiniband-diags/ibdiag.conf
+.UNINDENT
+.UNINDENT
+.SH EXAMPLES
+.INDENT 0.0
+.INDENT 3.5
+.sp
+.nf
+.ft C
+ibccconfig SwitchCongestionSetting 2 0x1F 0x1FFFFFFFFF 0x0 0xF 8 0 0:0 1 # Configure Switch Congestion Settings
+ibccconfig CACongestionSetting 1 0 0x3 150 1 0 0 # Configure CA Congestion Settings to SL 0 and SL 1
+ibccconfig CACongestionSetting 1 0 0x4 200 1 0 0 # Configure CA Congestion Settings to SL 2
+ibccconfig CongestionControlTable 1 63 0 0:0 0:1 ... # Configure first block of Congestion Control Table
+ibccconfig CongestionControlTable 1 127 0 0:64 0:65 ... # Configure second block of Congestion Control Table
+.ft P
+.fi
+.UNINDENT
+.UNINDENT
+.SH FILES
+.\" Common text for the config file
+.
+.SS CONFIG FILE
+.sp
+/etc/infiniband-diags/ibdiag.conf
+.sp
+A global config file is provided to set some of the common options for all
+tools. See supplied config file for details.
+.SH AUTHOR
+.INDENT 0.0
+.TP
+.B Albert Chu
+< \fI\%chu11@llnl.gov\fP >
+.UNINDENT
+.\" Generated by docutils manpage writer.
+.
diff --git a/contrib/ofed/infiniband-diags/man/ibccquery.8 b/contrib/ofed/infiniband-diags/man/ibccquery.8
new file mode 100644
index 0000000..cae3f33
--- /dev/null
+++ b/contrib/ofed/infiniband-diags/man/ibccquery.8
@@ -0,0 +1,194 @@
+.\" Man page generated from reStructuredText.
+.
+.TH IBCCQUERY 8 "" "" "OpenIB Diagnostics"
+.SH NAME
+IBCCQUERY \- query congestion control settings/info
+.
+.nr rst2man-indent-level 0
+.
+.de1 rstReportMargin
+\\$1 \\n[an-margin]
+level \\n[rst2man-indent-level]
+level margin: \\n[rst2man-indent\\n[rst2man-indent-level]]
+-
+\\n[rst2man-indent0]
+\\n[rst2man-indent1]
+\\n[rst2man-indent2]
+..
+.de1 INDENT
+.\" .rstReportMargin pre:
+. RS \\$1
+. nr rst2man-indent\\n[rst2man-indent-level] \\n[an-margin]
+. nr rst2man-indent-level +1
+.\" .rstReportMargin post:
+..
+.de UNINDENT
+. RE
+.\" indent \\n[an-margin]
+.\" old: \\n[rst2man-indent\\n[rst2man-indent-level]]
+.nr rst2man-indent-level -1
+.\" new: \\n[rst2man-indent\\n[rst2man-indent-level]]
+.in \\n[rst2man-indent\\n[rst2man-indent-level]]u
+..
+.SH SYNOPSIS
+.sp
+ibccquery [common_options] [\-c cckey] [\-\-dgid gid] <op> <lid|guid> [port]
+.SH DESCRIPTION
+.sp
+ibccquery support the querying of settings and other information related
+to congestion control.
+.SH OPTIONS
+.INDENT 0.0
+.TP
+.B Current supported operations and their parameters:
+CongestionInfo (CI) <addr>
+CongestionKeyInfo (CK) <addr>
+CongestionLog (CL) <addr>
+SwitchCongestionSetting (SS) <addr>
+SwitchPortCongestionSetting (SP) <addr> [<portnum>]
+CACongestionSetting (CS) <addr>
+CongestionControlTable (CT) <addr>
+Timestamp (TI) <addr>
+.UNINDENT
+.sp
+\fB\-\-cckey, \-c <cckey>\fP
+Specify a congestion control (CC) key. If none is specified, a key of 0 is used.
+\fB\-\-dgid <gid>\fP
+destination GID: use when GRH is required in packets (IPv6 format)
+.SS Debugging flags
+.\" Define the common option -d
+.
+.INDENT 0.0
+.TP
+.B \-d
+raise the IB debugging level.
+May be used several times (\-ddd or \-d \-d \-d).
+.UNINDENT
+.\" Define the common option -e
+.
+.INDENT 0.0
+.TP
+.B \-e
+show send and receive errors (timeouts and others)
+.UNINDENT
+.\" Define the common option -h
+.
+.sp
+\fB\-h, \-\-help\fP show the usage message
+.\" Define the common option -v
+.
+.INDENT 0.0
+.TP
+.B \fB\-v, \-\-verbose\fP
+increase the application verbosity level.
+May be used several times (\-vv or \-v \-v \-v)
+.UNINDENT
+.\" Define the common option -V
+.
+.sp
+\fB\-V, \-\-version\fP show the version info.
+.SS Addressing Flags
+.\" Define the common option -G
+.
+.sp
+\fB\-G, \-\-Guid\fP The address specified is a Port GUID
+.\" Define the common option -L
+.
+.sp
+\fB\-L, \-\-Lid\fP The address specified is a LID
+.\" Define the common option -s
+.
+.sp
+\fB\-s, \-\-sm_port <smlid>\fP use \(aqsmlid\(aq as the target lid for SA queries.
+.SS Port Selection flags
+.\" Define the common option -C
+.
+.sp
+\fB\-C, \-\-Ca <ca_name>\fP use the specified ca_name.
+.\" Define the common option -P
+.
+.sp
+\fB\-P, \-\-Port <ca_port>\fP use the specified ca_port.
+.\" Explanation of local port selection
+.
+.SS Local port Selection
+.sp
+Multiple port/Multiple CA support: when no IB device or port is specified
+(see the "local umad parameters" below), the libibumad library
+selects the port to use by the following criteria:
+.INDENT 0.0
+.INDENT 3.5
+.INDENT 0.0
+.IP 1. 3
+the first port that is ACTIVE.
+.IP 2. 3
+if not found, the first port that is UP (physical link up).
+.UNINDENT
+.sp
+If a port and/or CA name is specified, the libibumad library attempts
+to fulfill the user request, and will fail if it is not possible.
+.sp
+For example:
+.INDENT 0.0
+.INDENT 3.5
+.sp
+.nf
+.ft C
+ibaddr # use the first port (criteria #1 above)
+ibaddr \-C mthca1 # pick the best port from "mthca1" only.
+ibaddr \-P 2 # use the second (active/up) port from the first available IB device.
+ibaddr \-C mthca0 \-P 2 # use the specified port only.
+.ft P
+.fi
+.UNINDENT
+.UNINDENT
+.UNINDENT
+.UNINDENT
+.SS Configuration flags
+.\" Define the common option -y
+.
+.INDENT 0.0
+.TP
+.B \fB\-y, \-\-m_key <key>\fP
+use the specified M_key for requests. If non\-numeric value (like \(aqx\(aq)
+is specified then a value will be prompted for.
+.UNINDENT
+.\" Define the common option -z
+.
+.sp
+\fB\-\-config, \-z <config_file>\fP Specify alternate config file.
+.INDENT 0.0
+.INDENT 3.5
+Default: /etc/infiniband-diags/ibdiag.conf
+.UNINDENT
+.UNINDENT
+.SH FILES
+.\" Common text for the config file
+.
+.SS CONFIG FILE
+.sp
+/etc/infiniband-diags/ibdiag.conf
+.sp
+A global config file is provided to set some of the common options for all
+tools. See supplied config file for details.
+.SH EXAMPLES
+.INDENT 0.0
+.INDENT 3.5
+.sp
+.nf
+.ft C
+ibccquery CongestionInfo 3 # Congestion Info by lid
+ibccquery SwitchPortCongestionSetting 3 # Query all Switch Port Congestion Settings
+ibccquery SwitchPortCongestionSetting 3 1 # Query Switch Port Congestion Setting for port 1
+.ft P
+.fi
+.UNINDENT
+.UNINDENT
+.SH AUTHOR
+.INDENT 0.0
+.TP
+.B Albert Chu
+< \fI\%chu11@llnl.gov\fP >
+.UNINDENT
+.\" Generated by docutils manpage writer.
+.
diff --git a/contrib/ofed/infiniband-diags/man/ibfindnodesusing.8 b/contrib/ofed/infiniband-diags/man/ibfindnodesusing.8
new file mode 100644
index 0000000..9ff6db8
--- /dev/null
+++ b/contrib/ofed/infiniband-diags/man/ibfindnodesusing.8
@@ -0,0 +1,127 @@
+.\" Man page generated from reStructuredText.
+.
+.TH IBFINDNODESUSING 8 "" "" "Open IB Diagnostics"
+.SH NAME
+IBFINDNODESUSING \-
+.
+.nr rst2man-indent-level 0
+.
+.de1 rstReportMargin
+\\$1 \\n[an-margin]
+level \\n[rst2man-indent-level]
+level margin: \\n[rst2man-indent\\n[rst2man-indent-level]]
+-
+\\n[rst2man-indent0]
+\\n[rst2man-indent1]
+\\n[rst2man-indent2]
+..
+.de1 INDENT
+.\" .rstReportMargin pre:
+. RS \\$1
+. nr rst2man-indent\\n[rst2man-indent-level] \\n[an-margin]
+. nr rst2man-indent-level +1
+.\" .rstReportMargin post:
+..
+.de UNINDENT
+. RE
+.\" indent \\n[an-margin]
+.\" old: \\n[rst2man-indent\\n[rst2man-indent-level]]
+.nr rst2man-indent-level -1
+.\" new: \\n[rst2man-indent\\n[rst2man-indent-level]]
+.in \\n[rst2man-indent\\n[rst2man-indent-level]]u
+..
+.SH FIND A LIST OF END NODES WHICH ARE ROUTED THROUGH THE SPECIFIED SWITCH AND PORT
+.SS SYNOPSIS
+.sp
+ibfindnodesusing.pl [options] <switch_guid|switch_name> <port>
+.SS DESCRIPTION
+.sp
+ibfindnodesusing.pl uses ibroute and detects the current nodes which are routed
+through both directions of the link specified. The link is specified by one
+switch port end; the script finds the remote end automatically.
+.SS OPTIONS
+.INDENT 0.0
+.TP
+.B \fB\-h\fP
+show help
+.TP
+.B \fB\-R\fP
+Recalculate the ibnetdiscover information, ie do not use the cached
+information. This option is slower but should be used if the diag
+tools have not been used for some time or if there are other reasons to
+believe that the fabric has changed.
+.UNINDENT
+.sp
+\fB\-C <ca_name>\fP use the specified ca_name.
+.sp
+\fB\-P <ca_port>\fP use the specified ca_port.
+.SS FILES
+.\" Common text for the config file
+.
+.SS CONFIG FILE
+.sp
+/etc/infiniband-diags/ibdiag.conf
+.sp
+A global config file is provided to set some of the common options for all
+tools. See supplied config file for details.
+.\" Common text to describe the node name map file.
+.
+.SS NODE NAME MAP FILE FORMAT
+.sp
+The node name map is used to specify user friendly names for nodes in the
+output. GUIDs are used to perform the lookup.
+.sp
+This functionality is provided by the opensm\-libs package. See \fBopensm(8)\fP
+for the file location for your installation.
+.sp
+\fBGenerically:\fP
+.INDENT 0.0
+.INDENT 3.5
+.sp
+.nf
+.ft C
+# comment
+<guid> "<name>"
+.ft P
+.fi
+.UNINDENT
+.UNINDENT
+.sp
+\fBExample:\fP
+.INDENT 0.0
+.INDENT 3.5
+.sp
+.nf
+.ft C
+# IB1
+# Line cards
+0x0008f104003f125c "IB1 (Rack 11 slot 1 ) ISR9288/ISR9096 Voltaire sLB\-24D"
+0x0008f104003f125d "IB1 (Rack 11 slot 1 ) ISR9288/ISR9096 Voltaire sLB\-24D"
+0x0008f104003f10d2 "IB1 (Rack 11 slot 2 ) ISR9288/ISR9096 Voltaire sLB\-24D"
+0x0008f104003f10d3 "IB1 (Rack 11 slot 2 ) ISR9288/ISR9096 Voltaire sLB\-24D"
+0x0008f104003f10bf "IB1 (Rack 11 slot 12 ) ISR9288/ISR9096 Voltaire sLB\-24D"
+
+# Spines
+0x0008f10400400e2d "IB1 (Rack 11 spine 1 ) ISR9288 Voltaire sFB\-12D"
+0x0008f10400400e2e "IB1 (Rack 11 spine 1 ) ISR9288 Voltaire sFB\-12D"
+0x0008f10400400e2f "IB1 (Rack 11 spine 1 ) ISR9288 Voltaire sFB\-12D"
+0x0008f10400400e31 "IB1 (Rack 11 spine 2 ) ISR9288 Voltaire sFB\-12D"
+0x0008f10400400e32 "IB1 (Rack 11 spine 2 ) ISR9288 Voltaire sFB\-12D"
+
+# GUID Node Name
+0x0008f10400411a08 "SW1 (Rack 3) ISR9024 Voltaire 9024D"
+0x0008f10400411a28 "SW2 (Rack 3) ISR9024 Voltaire 9024D"
+0x0008f10400411a34 "SW3 (Rack 3) ISR9024 Voltaire 9024D"
+0x0008f104004119d0 "SW4 (Rack 3) ISR9024 Voltaire 9024D"
+.ft P
+.fi
+.UNINDENT
+.UNINDENT
+.SS AUTHOR
+.INDENT 0.0
+.TP
+.B Ira Weiny
+< \fI\%ira.weiny@intel.com\fP >
+.UNINDENT
+.\" Generated by docutils manpage writer.
+.
diff --git a/contrib/ofed/infiniband-diags/man/ibhosts.8 b/contrib/ofed/infiniband-diags/man/ibhosts.8
new file mode 100644
index 0000000..067c363
--- /dev/null
+++ b/contrib/ofed/infiniband-diags/man/ibhosts.8
@@ -0,0 +1,184 @@
+.\" Man page generated from reStructuredText.
+.
+.TH IBHOSTS 8 "" "" "OpenIB Diagnostics"
+.SH NAME
+IBHOSTS \- show InfiniBand host nodes in topology
+.
+.nr rst2man-indent-level 0
+.
+.de1 rstReportMargin
+\\$1 \\n[an-margin]
+level \\n[rst2man-indent-level]
+level margin: \\n[rst2man-indent\\n[rst2man-indent-level]]
+-
+\\n[rst2man-indent0]
+\\n[rst2man-indent1]
+\\n[rst2man-indent2]
+..
+.de1 INDENT
+.\" .rstReportMargin pre:
+. RS \\$1
+. nr rst2man-indent\\n[rst2man-indent-level] \\n[an-margin]
+. nr rst2man-indent-level +1
+.\" .rstReportMargin post:
+..
+.de UNINDENT
+. RE
+.\" indent \\n[an-margin]
+.\" old: \\n[rst2man-indent\\n[rst2man-indent-level]]
+.nr rst2man-indent-level -1
+.\" new: \\n[rst2man-indent\\n[rst2man-indent-level]]
+.in \\n[rst2man-indent\\n[rst2man-indent-level]]u
+..
+.SH SYNOPSIS
+.sp
+ibhosts [options] [<topology\-file>]
+.SH DESCRIPTION
+.sp
+ibhosts is a script which either walks the IB subnet topology or uses an
+already saved topology file and extracts the CA nodes.
+.SH OPTIONS
+.\" Define the common option -C
+.
+.sp
+\fB\-C, \-\-Ca <ca_name>\fP use the specified ca_name.
+.\" Define the common option -P
+.
+.sp
+\fB\-P, \-\-Port <ca_port>\fP use the specified ca_port.
+.\" Define the common option -t
+.
+.sp
+\fB\-t, \-\-timeout <timeout_ms>\fP override the default timeout for the solicited mads.
+.\" Define the common option -y
+.
+.INDENT 0.0
+.TP
+.B \fB\-y, \-\-m_key <key>\fP
+use the specified M_key for requests. If non\-numeric value (like \(aqx\(aq)
+is specified then a value will be prompted for.
+.UNINDENT
+.\" Define the common option -h
+.
+.sp
+\fB\-h, \-\-help\fP show the usage message
+.\" Define the common option -z
+.
+.sp
+\fB\-\-config, \-z <config_file>\fP Specify alternate config file.
+.INDENT 0.0
+.INDENT 3.5
+Default: /etc/infiniband-diags/ibdiag.conf
+.UNINDENT
+.UNINDENT
+.\" Explanation of local port selection
+.
+.SS Local port Selection
+.sp
+Multiple port/Multiple CA support: when no IB device or port is specified
+(see the "local umad parameters" below), the libibumad library
+selects the port to use by the following criteria:
+.INDENT 0.0
+.INDENT 3.5
+.INDENT 0.0
+.IP 1. 3
+the first port that is ACTIVE.
+.IP 2. 3
+if not found, the first port that is UP (physical link up).
+.UNINDENT
+.sp
+If a port and/or CA name is specified, the libibumad library attempts
+to fulfill the user request, and will fail if it is not possible.
+.sp
+For example:
+.INDENT 0.0
+.INDENT 3.5
+.sp
+.nf
+.ft C
+ibaddr # use the first port (criteria #1 above)
+ibaddr \-C mthca1 # pick the best port from "mthca1" only.
+ibaddr \-P 2 # use the second (active/up) port from the first available IB device.
+ibaddr \-C mthca0 \-P 2 # use the specified port only.
+.ft P
+.fi
+.UNINDENT
+.UNINDENT
+.UNINDENT
+.UNINDENT
+.SH FILES
+.\" Common text for the config file
+.
+.SS CONFIG FILE
+.sp
+/etc/infiniband-diags/ibdiag.conf
+.sp
+A global config file is provided to set some of the common options for all
+tools. See supplied config file for details.
+.\" Common text to describe the node name map file.
+.
+.SS NODE NAME MAP FILE FORMAT
+.sp
+The node name map is used to specify user friendly names for nodes in the
+output. GUIDs are used to perform the lookup.
+.sp
+This functionality is provided by the opensm\-libs package. See \fBopensm(8)\fP
+for the file location for your installation.
+.sp
+\fBGenerically:\fP
+.INDENT 0.0
+.INDENT 3.5
+.sp
+.nf
+.ft C
+# comment
+<guid> "<name>"
+.ft P
+.fi
+.UNINDENT
+.UNINDENT
+.sp
+\fBExample:\fP
+.INDENT 0.0
+.INDENT 3.5
+.sp
+.nf
+.ft C
+# IB1
+# Line cards
+0x0008f104003f125c "IB1 (Rack 11 slot 1 ) ISR9288/ISR9096 Voltaire sLB\-24D"
+0x0008f104003f125d "IB1 (Rack 11 slot 1 ) ISR9288/ISR9096 Voltaire sLB\-24D"
+0x0008f104003f10d2 "IB1 (Rack 11 slot 2 ) ISR9288/ISR9096 Voltaire sLB\-24D"
+0x0008f104003f10d3 "IB1 (Rack 11 slot 2 ) ISR9288/ISR9096 Voltaire sLB\-24D"
+0x0008f104003f10bf "IB1 (Rack 11 slot 12 ) ISR9288/ISR9096 Voltaire sLB\-24D"
+
+# Spines
+0x0008f10400400e2d "IB1 (Rack 11 spine 1 ) ISR9288 Voltaire sFB\-12D"
+0x0008f10400400e2e "IB1 (Rack 11 spine 1 ) ISR9288 Voltaire sFB\-12D"
+0x0008f10400400e2f "IB1 (Rack 11 spine 1 ) ISR9288 Voltaire sFB\-12D"
+0x0008f10400400e31 "IB1 (Rack 11 spine 2 ) ISR9288 Voltaire sFB\-12D"
+0x0008f10400400e32 "IB1 (Rack 11 spine 2 ) ISR9288 Voltaire sFB\-12D"
+
+# GUID Node Name
+0x0008f10400411a08 "SW1 (Rack 3) ISR9024 Voltaire 9024D"
+0x0008f10400411a28 "SW2 (Rack 3) ISR9024 Voltaire 9024D"
+0x0008f10400411a34 "SW3 (Rack 3) ISR9024 Voltaire 9024D"
+0x0008f104004119d0 "SW4 (Rack 3) ISR9024 Voltaire 9024D"
+.ft P
+.fi
+.UNINDENT
+.UNINDENT
+.SH SEE ALSO
+.sp
+ibnetdiscover(8)
+.SH DEPENDENCIES
+.sp
+ibnetdiscover, ibnetdiscover format
+.SH AUTHOR
+.INDENT 0.0
+.TP
+.B Hal Rosenstock
+< \fI\%halr@voltaire.com\fP >
+.UNINDENT
+.\" Generated by docutils manpage writer.
+.
diff --git a/contrib/ofed/infiniband-diags/man/ibidsverify.8 b/contrib/ofed/infiniband-diags/man/ibidsverify.8
new file mode 100644
index 0000000..1df287b
--- /dev/null
+++ b/contrib/ofed/infiniband-diags/man/ibidsverify.8
@@ -0,0 +1,80 @@
+.\" Man page generated from reStructuredText.
+.
+.TH IBIDSVERIFY 8 "" "" "Open IB Diagnostics"
+.SH NAME
+IBIDSVERIFY \-
+.
+.nr rst2man-indent-level 0
+.
+.de1 rstReportMargin
+\\$1 \\n[an-margin]
+level \\n[rst2man-indent-level]
+level margin: \\n[rst2man-indent\\n[rst2man-indent-level]]
+-
+\\n[rst2man-indent0]
+\\n[rst2man-indent1]
+\\n[rst2man-indent2]
+..
+.de1 INDENT
+.\" .rstReportMargin pre:
+. RS \\$1
+. nr rst2man-indent\\n[rst2man-indent-level] \\n[an-margin]
+. nr rst2man-indent-level +1
+.\" .rstReportMargin post:
+..
+.de UNINDENT
+. RE
+.\" indent \\n[an-margin]
+.\" old: \\n[rst2man-indent\\n[rst2man-indent-level]]
+.nr rst2man-indent-level -1
+.\" new: \\n[rst2man-indent\\n[rst2man-indent-level]]
+.in \\n[rst2man-indent\\n[rst2man-indent-level]]u
+..
+.SH VALIDATE IB IDENTIFIERS IN SUBNET AND REPORT ERRORS
+.SS SYNOPSIS
+.sp
+ibidsverify.pl [\-h] [\-R]
+.SS DESCRIPTION
+.sp
+ibidsverify.pl is a perl script which uses a full topology file that was
+created by ibnetdiscover, scans the network to validate the LIDs and GUIDs
+in the subnet. The validation consists of checking that there are no zero
+or duplicate identifiers.
+.sp
+Finally, ibidsverify.pl will also reuse the cached ibnetdiscover output from
+some of the other diag tools which makes it a bit faster than running
+ibnetdiscover from scratch.
+.SS OPTIONS
+.sp
+\fB\-R\fP
+Recalculate the ibnetdiscover information, ie do not use the cached
+information. This option is slower but should be used if the diag tools have
+not been used for some time or if there are other reasons to believe the
+fabric has changed.
+.sp
+\fB\-C <ca_name>\fP use the specified ca_name.
+.sp
+\fB\-P <ca_port>\fP use the specified ca_port.
+.SS EXIT STATUS
+.sp
+Exit status is 1 if errors are found, 0 otherwise.
+.SS FILES
+.\" Common text for the config file
+.
+.SS CONFIG FILE
+.sp
+/etc/infiniband-diags/ibdiag.conf
+.sp
+A global config file is provided to set some of the common options for all
+tools. See supplied config file for details.
+.SS SEE ALSO
+.sp
+\fBibnetdiscover(8)\fP
+.SS AUTHOR
+.INDENT 0.0
+.TP
+.B Hal Rosenstock
+< \fI\%halr@voltaire.com\fP >
+.UNINDENT
+.\" Generated by docutils manpage writer.
+.
diff --git a/contrib/ofed/infiniband-diags/man/iblinkinfo.8 b/contrib/ofed/infiniband-diags/man/iblinkinfo.8
new file mode 100644
index 0000000..2a571e3
--- /dev/null
+++ b/contrib/ofed/infiniband-diags/man/iblinkinfo.8
@@ -0,0 +1,319 @@
+.\" Man page generated from reStructuredText.
+.
+.TH IBLINKINFO 8 "" "" "OpenIB Diagnostics"
+.SH NAME
+IBLINKINFO \- report link info for all links in the fabric
+.
+.nr rst2man-indent-level 0
+.
+.de1 rstReportMargin
+\\$1 \\n[an-margin]
+level \\n[rst2man-indent-level]
+level margin: \\n[rst2man-indent\\n[rst2man-indent-level]]
+-
+\\n[rst2man-indent0]
+\\n[rst2man-indent1]
+\\n[rst2man-indent2]
+..
+.de1 INDENT
+.\" .rstReportMargin pre:
+. RS \\$1
+. nr rst2man-indent\\n[rst2man-indent-level] \\n[an-margin]
+. nr rst2man-indent-level +1
+.\" .rstReportMargin post:
+..
+.de UNINDENT
+. RE
+.\" indent \\n[an-margin]
+.\" old: \\n[rst2man-indent\\n[rst2man-indent-level]]
+.nr rst2man-indent-level -1
+.\" new: \\n[rst2man-indent\\n[rst2man-indent-level]]
+.in \\n[rst2man-indent\\n[rst2man-indent-level]]u
+..
+.SH SYNOPSIS
+.sp
+iblinkinfo <options>
+.SH DESCRIPTION
+.sp
+iblinkinfo reports link info for each port in an IB fabric, node by node.
+Optionally, iblinkinfo can do partial scans and limit its output to parts of a
+fabric.
+.SH OPTIONS
+.sp
+\fB\-\-down, \-d\fP
+Print only nodes which have a port in the "Down" state.
+.sp
+\fB\-\-line, \-l\fP
+Print all information for each link on one line. Default is to print a header
+with the node information and then a list for each port (useful for
+grep\(aqing output).
+.sp
+\fB\-\-additional, \-p\fP
+Print additional port settings (<LifeTime>,<HoqLife>,<VLStallCount>)
+.sp
+\fB\-\-switches\-only\fP
+Show only switches in output.
+.sp
+\fB\-\-cas\-only\fP
+Show only CAs in output.
+.SS Partial Scan flags
+.sp
+The node to start a partial scan can be specified with the following addresses.
+.\" Define the common option -G
+.
+.sp
+\fB\-\-port\-guid, \-G <port_guid>\fP Specify a port_guid
+.\" Define the common option -D for Directed routes
+.
+.sp
+\fB\-D, \-\-Direct <dr_path>\fP The address specified is a directed route
+.INDENT 0.0
+.INDENT 3.5
+.sp
+.nf
+.ft C
+Examples:
+ \-D "0" # self port
+ \-D "0,1,2,1,4" # out via port 1, then 2, ...
+
+ (Note the second number in the path specified must match the port being
+ used. This can be specified using the port selection flag \(aq\-P\(aq or the
+ port found through the automatic selection process.)
+.ft P
+.fi
+.UNINDENT
+.UNINDENT
+.sp
+\fBNote:\fP For switches results are printed for all ports not just switch port 0.
+.sp
+\fB\-\-switch, \-S <port_guid>\fP same as "\-G". (provided only for backward compatibility)
+.sp
+How much of the scan to be printed can be controled with the following.
+.sp
+\fB\-\-all, \-a\fP
+Print all nodes found in a partial fabric scan. Normally a
+partial fabric scan will return only the node specified. This option will
+print the other nodes found as well.
+.sp
+\fB\-\-hops, \-n <hops>\fP
+Specify the number of hops away from a specified node to scan. This is useful
+to expand a partial fabric scan beyond the node specified.
+.SS Cache File flags
+.\" Define the common option load-cache
+.
+.sp
+\fB\-\-load\-cache <filename>\fP
+Load and use the cached ibnetdiscover data stored in the specified
+filename. May be useful for outputting and learning about other
+fabrics or a previous state of a fabric.
+.\" Define the common option diff
+.
+.sp
+\fB\-\-diff <filename>\fP
+Load cached ibnetdiscover data and do a diff comparison to the current
+network or another cache. A special diff output for ibnetdiscover
+output will be displayed showing differences between the old and current
+fabric. By default, the following are compared for differences: switches,
+channel adapters, routers, and port connections.
+.\" Define the common option diffcheck
+.
+.sp
+\fB\-\-diffcheck <key(s)>\fP
+Specify what diff checks should be done in the \fB\-\-diff\fP option above.
+Comma separate multiple diff check key(s). The available diff checks
+are: \fBsw = switches\fP, \fBca = channel adapters\fP, \fBrouter\fP = routers,
+\fBport\fP = port connections, \fBlid\fP = lids, \fBnodedesc\fP = node
+descriptions. Note that \fBport\fP, \fBlid\fP, and \fBnodedesc\fP are
+checked only for the node types that are specified (e.g. \fBsw\fP,
+\fBca\fP, \fBrouter\fP). If \fBport\fP is specified alongside \fBlid\fP
+or \fBnodedesc\fP, remote port lids and node descriptions will also be compared.
+.sp
+\fB\-\-filterdownports <filename>\fP
+Filter downports indicated in a ibnetdiscover cache. If a port was previously
+indicated as down in the specified cache, and is still down, do not output it in the
+resulting output. This option may be particularly useful for environments
+where switches are not fully populated, thus much of the default iblinkinfo
+info is considered unuseful. See \fBibnetdiscover\fP for information on caching
+ibnetdiscover output.
+.SS Port Selection flags
+.\" Define the common option -C
+.
+.sp
+\fB\-C, \-\-Ca <ca_name>\fP use the specified ca_name.
+.\" Define the common option -P
+.
+.sp
+\fB\-P, \-\-Port <ca_port>\fP use the specified ca_port.
+.\" Explanation of local port selection
+.
+.SS Local port Selection
+.sp
+Multiple port/Multiple CA support: when no IB device or port is specified
+(see the "local umad parameters" below), the libibumad library
+selects the port to use by the following criteria:
+.INDENT 0.0
+.INDENT 3.5
+.INDENT 0.0
+.IP 1. 3
+the first port that is ACTIVE.
+.IP 2. 3
+if not found, the first port that is UP (physical link up).
+.UNINDENT
+.sp
+If a port and/or CA name is specified, the libibumad library attempts
+to fulfill the user request, and will fail if it is not possible.
+.sp
+For example:
+.INDENT 0.0
+.INDENT 3.5
+.sp
+.nf
+.ft C
+ibaddr # use the first port (criteria #1 above)
+ibaddr \-C mthca1 # pick the best port from "mthca1" only.
+ibaddr \-P 2 # use the second (active/up) port from the first available IB device.
+ibaddr \-C mthca0 \-P 2 # use the specified port only.
+.ft P
+.fi
+.UNINDENT
+.UNINDENT
+.UNINDENT
+.UNINDENT
+.SS Configuration flags
+.\" Define the common option -z
+.
+.sp
+\fB\-\-config, \-z <config_file>\fP Specify alternate config file.
+.INDENT 0.0
+.INDENT 3.5
+Default: /etc/infiniband-diags/ibdiag.conf
+.UNINDENT
+.UNINDENT
+.\" Define the common option -z
+.
+.INDENT 0.0
+.TP
+.B \fB\-\-outstanding_smps, \-o <val>\fP
+Specify the number of outstanding SMP\(aqs which should be issued during the scan
+.sp
+Default: 2
+.UNINDENT
+.\" Define the common option --node-name-map
+.
+.sp
+\fB\-\-node\-name\-map <node\-name\-map>\fP Specify a node name map.
+.INDENT 0.0
+.INDENT 3.5
+This file maps GUIDs to more user friendly names. See FILES section.
+.UNINDENT
+.UNINDENT
+.\" Define the common option -t
+.
+.sp
+\fB\-t, \-\-timeout <timeout_ms>\fP override the default timeout for the solicited mads.
+.\" Define the common option -y
+.
+.INDENT 0.0
+.TP
+.B \fB\-y, \-\-m_key <key>\fP
+use the specified M_key for requests. If non\-numeric value (like \(aqx\(aq)
+is specified then a value will be prompted for.
+.UNINDENT
+.SS Debugging flags
+.\" Define the common option -e
+.
+.INDENT 0.0
+.TP
+.B \-e
+show send and receive errors (timeouts and others)
+.UNINDENT
+.\" Define the common option -h
+.
+.sp
+\fB\-h, \-\-help\fP show the usage message
+.\" Define the common option -v
+.
+.INDENT 0.0
+.TP
+.B \fB\-v, \-\-verbose\fP
+increase the application verbosity level.
+May be used several times (\-vv or \-v \-v \-v)
+.UNINDENT
+.\" Define the common option -V
+.
+.sp
+\fB\-V, \-\-version\fP show the version info.
+.SH EXIT STATUS
+.sp
+0 on success, \-1 on failure to scan the fabric, 1 if check mode is used and
+inconsistencies are found.
+.SH FILES
+.\" Common text for the config file
+.
+.SS CONFIG FILE
+.sp
+/etc/infiniband-diags/ibdiag.conf
+.sp
+A global config file is provided to set some of the common options for all
+tools. See supplied config file for details.
+.\" Common text to describe the node name map file.
+.
+.SS NODE NAME MAP FILE FORMAT
+.sp
+The node name map is used to specify user friendly names for nodes in the
+output. GUIDs are used to perform the lookup.
+.sp
+This functionality is provided by the opensm\-libs package. See \fBopensm(8)\fP
+for the file location for your installation.
+.sp
+\fBGenerically:\fP
+.INDENT 0.0
+.INDENT 3.5
+.sp
+.nf
+.ft C
+# comment
+<guid> "<name>"
+.ft P
+.fi
+.UNINDENT
+.UNINDENT
+.sp
+\fBExample:\fP
+.INDENT 0.0
+.INDENT 3.5
+.sp
+.nf
+.ft C
+# IB1
+# Line cards
+0x0008f104003f125c "IB1 (Rack 11 slot 1 ) ISR9288/ISR9096 Voltaire sLB\-24D"
+0x0008f104003f125d "IB1 (Rack 11 slot 1 ) ISR9288/ISR9096 Voltaire sLB\-24D"
+0x0008f104003f10d2 "IB1 (Rack 11 slot 2 ) ISR9288/ISR9096 Voltaire sLB\-24D"
+0x0008f104003f10d3 "IB1 (Rack 11 slot 2 ) ISR9288/ISR9096 Voltaire sLB\-24D"
+0x0008f104003f10bf "IB1 (Rack 11 slot 12 ) ISR9288/ISR9096 Voltaire sLB\-24D"
+
+# Spines
+0x0008f10400400e2d "IB1 (Rack 11 spine 1 ) ISR9288 Voltaire sFB\-12D"
+0x0008f10400400e2e "IB1 (Rack 11 spine 1 ) ISR9288 Voltaire sFB\-12D"
+0x0008f10400400e2f "IB1 (Rack 11 spine 1 ) ISR9288 Voltaire sFB\-12D"
+0x0008f10400400e31 "IB1 (Rack 11 spine 2 ) ISR9288 Voltaire sFB\-12D"
+0x0008f10400400e32 "IB1 (Rack 11 spine 2 ) ISR9288 Voltaire sFB\-12D"
+
+# GUID Node Name
+0x0008f10400411a08 "SW1 (Rack 3) ISR9024 Voltaire 9024D"
+0x0008f10400411a28 "SW2 (Rack 3) ISR9024 Voltaire 9024D"
+0x0008f10400411a34 "SW3 (Rack 3) ISR9024 Voltaire 9024D"
+0x0008f104004119d0 "SW4 (Rack 3) ISR9024 Voltaire 9024D"
+.ft P
+.fi
+.UNINDENT
+.UNINDENT
+.SH AUTHOR
+.INDENT 0.0
+.TP
+.B Ira Weiny
+< \fI\%ira.weiny@intel.com\fP >
+.UNINDENT
+.\" Generated by docutils manpage writer.
+.
diff --git a/contrib/ofed/infiniband-diags/man/ibnetdiscover.8 b/contrib/ofed/infiniband-diags/man/ibnetdiscover.8
new file mode 100644
index 0000000..4a4d54c
--- /dev/null
+++ b/contrib/ofed/infiniband-diags/man/ibnetdiscover.8
@@ -0,0 +1,399 @@
+.\" Man page generated from reStructuredText.
+.
+.TH IBNETDISCOVER 8 "" "" "Open IB Diagnostics"
+.SH NAME
+IBNETDISCOVER \- discover InfiniBand topology
+.
+.nr rst2man-indent-level 0
+.
+.de1 rstReportMargin
+\\$1 \\n[an-margin]
+level \\n[rst2man-indent-level]
+level margin: \\n[rst2man-indent\\n[rst2man-indent-level]]
+-
+\\n[rst2man-indent0]
+\\n[rst2man-indent1]
+\\n[rst2man-indent2]
+..
+.de1 INDENT
+.\" .rstReportMargin pre:
+. RS \\$1
+. nr rst2man-indent\\n[rst2man-indent-level] \\n[an-margin]
+. nr rst2man-indent-level +1
+.\" .rstReportMargin post:
+..
+.de UNINDENT
+. RE
+.\" indent \\n[an-margin]
+.\" old: \\n[rst2man-indent\\n[rst2man-indent-level]]
+.nr rst2man-indent-level -1
+.\" new: \\n[rst2man-indent\\n[rst2man-indent-level]]
+.in \\n[rst2man-indent\\n[rst2man-indent-level]]u
+..
+.SH SYNOPSIS
+.sp
+ibnetdiscover [options] [<topology\-file>]
+.SH DESCRIPTION
+.sp
+ibnetdiscover performs IB subnet discovery and outputs a human readable
+topology file. GUIDs, node types, and port numbers are displayed
+as well as port LIDs and NodeDescriptions. All nodes (and links) are displayed
+(full topology). Optionally, this utility can be used to list the current
+connected nodes by nodetype. The output is printed to standard output
+unless a topology file is specified.
+.SH OPTIONS
+.sp
+\fB\-l, \-\-list\fP
+List of connected nodes
+.sp
+\fB\-g, \-\-grouping\fP
+Show grouping. Grouping correlates IB nodes by different vendor specific
+schemes. It may also show the switch external ports correspondence.
+.sp
+\fB\-H, \-\-Hca_list\fP
+List of connected CAs
+.sp
+\fB\-S, \-\-Switch_list\fP
+List of connected switches
+.sp
+\fB\-R, \-\-Router_list\fP
+List of connected routers
+.sp
+\fB\-s, \-\-show\fP
+Show progress information during discovery.
+.sp
+\fB\-f, \-\-full\fP
+Show full information (ports\(aq speed and width, vlcap)
+.sp
+\fB\-p, \-\-ports\fP
+Obtain a ports report which is a
+list of connected ports with relevant information (like LID, portnum,
+GUID, width, speed, and NodeDescription).
+.sp
+\fB\-m, \-\-max_hops\fP
+Report max hops discovered.
+.\" Define the common option -z
+.
+.INDENT 0.0
+.TP
+.B \fB\-\-outstanding_smps, \-o <val>\fP
+Specify the number of outstanding SMP\(aqs which should be issued during the scan
+.sp
+Default: 2
+.UNINDENT
+.SS Cache File flags
+.\" Define the common option cache
+.
+.sp
+\fB\-\-cache <filename>\fP
+Cache the ibnetdiscover network data in the specified filename. This
+cache may be used by other tools for later analysis.
+.\" Define the common option load-cache
+.
+.sp
+\fB\-\-load\-cache <filename>\fP
+Load and use the cached ibnetdiscover data stored in the specified
+filename. May be useful for outputting and learning about other
+fabrics or a previous state of a fabric.
+.\" Define the common option diff
+.
+.sp
+\fB\-\-diff <filename>\fP
+Load cached ibnetdiscover data and do a diff comparison to the current
+network or another cache. A special diff output for ibnetdiscover
+output will be displayed showing differences between the old and current
+fabric. By default, the following are compared for differences: switches,
+channel adapters, routers, and port connections.
+.\" Define the common option diffcheck
+.
+.sp
+\fB\-\-diffcheck <key(s)>\fP
+Specify what diff checks should be done in the \fB\-\-diff\fP option above.
+Comma separate multiple diff check key(s). The available diff checks
+are: \fBsw = switches\fP, \fBca = channel adapters\fP, \fBrouter\fP = routers,
+\fBport\fP = port connections, \fBlid\fP = lids, \fBnodedesc\fP = node
+descriptions. Note that \fBport\fP, \fBlid\fP, and \fBnodedesc\fP are
+checked only for the node types that are specified (e.g. \fBsw\fP,
+\fBca\fP, \fBrouter\fP). If \fBport\fP is specified alongside \fBlid\fP
+or \fBnodedesc\fP, remote port lids and node descriptions will also be compared.
+.SS Port Selection flags
+.\" Define the common option -C
+.
+.sp
+\fB\-C, \-\-Ca <ca_name>\fP use the specified ca_name.
+.\" Define the common option -P
+.
+.sp
+\fB\-P, \-\-Port <ca_port>\fP use the specified ca_port.
+.\" Explanation of local port selection
+.
+.SS Local port Selection
+.sp
+Multiple port/Multiple CA support: when no IB device or port is specified
+(see the "local umad parameters" below), the libibumad library
+selects the port to use by the following criteria:
+.INDENT 0.0
+.INDENT 3.5
+.INDENT 0.0
+.IP 1. 3
+the first port that is ACTIVE.
+.IP 2. 3
+if not found, the first port that is UP (physical link up).
+.UNINDENT
+.sp
+If a port and/or CA name is specified, the libibumad library attempts
+to fulfill the user request, and will fail if it is not possible.
+.sp
+For example:
+.INDENT 0.0
+.INDENT 3.5
+.sp
+.nf
+.ft C
+ibaddr # use the first port (criteria #1 above)
+ibaddr \-C mthca1 # pick the best port from "mthca1" only.
+ibaddr \-P 2 # use the second (active/up) port from the first available IB device.
+ibaddr \-C mthca0 \-P 2 # use the specified port only.
+.ft P
+.fi
+.UNINDENT
+.UNINDENT
+.UNINDENT
+.UNINDENT
+.SS Configuration flags
+.\" Define the common option -z
+.
+.sp
+\fB\-\-config, \-z <config_file>\fP Specify alternate config file.
+.INDENT 0.0
+.INDENT 3.5
+Default: /etc/infiniband-diags/ibdiag.conf
+.UNINDENT
+.UNINDENT
+.\" Define the common option -z
+.
+.INDENT 0.0
+.TP
+.B \fB\-\-outstanding_smps, \-o <val>\fP
+Specify the number of outstanding SMP\(aqs which should be issued during the scan
+.sp
+Default: 2
+.UNINDENT
+.\" Define the common option --node-name-map
+.
+.sp
+\fB\-\-node\-name\-map <node\-name\-map>\fP Specify a node name map.
+.INDENT 0.0
+.INDENT 3.5
+This file maps GUIDs to more user friendly names. See FILES section.
+.UNINDENT
+.UNINDENT
+.\" Define the common option -t
+.
+.sp
+\fB\-t, \-\-timeout <timeout_ms>\fP override the default timeout for the solicited mads.
+.\" Define the common option -y
+.
+.INDENT 0.0
+.TP
+.B \fB\-y, \-\-m_key <key>\fP
+use the specified M_key for requests. If non\-numeric value (like \(aqx\(aq)
+is specified then a value will be prompted for.
+.UNINDENT
+.SS Debugging flags
+.\" Define the common option -d
+.
+.INDENT 0.0
+.TP
+.B \-d
+raise the IB debugging level.
+May be used several times (\-ddd or \-d \-d \-d).
+.UNINDENT
+.\" Define the common option -e
+.
+.INDENT 0.0
+.TP
+.B \-e
+show send and receive errors (timeouts and others)
+.UNINDENT
+.\" Define the common option -h
+.
+.sp
+\fB\-h, \-\-help\fP show the usage message
+.\" Define the common option -v
+.
+.INDENT 0.0
+.TP
+.B \fB\-v, \-\-verbose\fP
+increase the application verbosity level.
+May be used several times (\-vv or \-v \-v \-v)
+.UNINDENT
+.\" Define the common option -V
+.
+.sp
+\fB\-V, \-\-version\fP show the version info.
+.SH FILES
+.\" Common text for the config file
+.
+.SS CONFIG FILE
+.sp
+/etc/infiniband-diags/ibdiag.conf
+.sp
+A global config file is provided to set some of the common options for all
+tools. See supplied config file for details.
+.\" Common text to describe the node name map file.
+.
+.SS NODE NAME MAP FILE FORMAT
+.sp
+The node name map is used to specify user friendly names for nodes in the
+output. GUIDs are used to perform the lookup.
+.sp
+This functionality is provided by the opensm\-libs package. See \fBopensm(8)\fP
+for the file location for your installation.
+.sp
+\fBGenerically:\fP
+.INDENT 0.0
+.INDENT 3.5
+.sp
+.nf
+.ft C
+# comment
+<guid> "<name>"
+.ft P
+.fi
+.UNINDENT
+.UNINDENT
+.sp
+\fBExample:\fP
+.INDENT 0.0
+.INDENT 3.5
+.sp
+.nf
+.ft C
+# IB1
+# Line cards
+0x0008f104003f125c "IB1 (Rack 11 slot 1 ) ISR9288/ISR9096 Voltaire sLB\-24D"
+0x0008f104003f125d "IB1 (Rack 11 slot 1 ) ISR9288/ISR9096 Voltaire sLB\-24D"
+0x0008f104003f10d2 "IB1 (Rack 11 slot 2 ) ISR9288/ISR9096 Voltaire sLB\-24D"
+0x0008f104003f10d3 "IB1 (Rack 11 slot 2 ) ISR9288/ISR9096 Voltaire sLB\-24D"
+0x0008f104003f10bf "IB1 (Rack 11 slot 12 ) ISR9288/ISR9096 Voltaire sLB\-24D"
+
+# Spines
+0x0008f10400400e2d "IB1 (Rack 11 spine 1 ) ISR9288 Voltaire sFB\-12D"
+0x0008f10400400e2e "IB1 (Rack 11 spine 1 ) ISR9288 Voltaire sFB\-12D"
+0x0008f10400400e2f "IB1 (Rack 11 spine 1 ) ISR9288 Voltaire sFB\-12D"
+0x0008f10400400e31 "IB1 (Rack 11 spine 2 ) ISR9288 Voltaire sFB\-12D"
+0x0008f10400400e32 "IB1 (Rack 11 spine 2 ) ISR9288 Voltaire sFB\-12D"
+
+# GUID Node Name
+0x0008f10400411a08 "SW1 (Rack 3) ISR9024 Voltaire 9024D"
+0x0008f10400411a28 "SW2 (Rack 3) ISR9024 Voltaire 9024D"
+0x0008f10400411a34 "SW3 (Rack 3) ISR9024 Voltaire 9024D"
+0x0008f104004119d0 "SW4 (Rack 3) ISR9024 Voltaire 9024D"
+.ft P
+.fi
+.UNINDENT
+.UNINDENT
+.\" Common text to describe the Topology file.
+.
+.SS TOPOLOGY FILE FORMAT
+.sp
+The topology file format is human readable and largely intuitive.
+Most identifiers are given textual names like vendor ID (vendid), device ID
+(device ID), GUIDs of various types (sysimgguid, caguid, switchguid, etc.).
+PortGUIDs are shown in parentheses (). For switches, this is shown on the
+switchguid line. For CA and router ports, it is shown on the connectivity
+lines. The IB node is identified followed by the number of ports and a quoted
+the node GUID. On the right of this line is a comment (#) followed by the
+NodeDescription in quotes. If the node is a switch, this line also contains
+whether switch port 0 is base or enhanced, and the LID and LMC of port 0.
+Subsequent lines pertaining to this node show the connectivity. On the
+left is the port number of the current node. On the right is the peer node
+(node at other end of link). It is identified in quotes with nodetype
+followed by \- followed by NodeGUID with the port number in square brackets.
+Further on the right is a comment (#). What follows the comment is
+dependent on the node type. If it it a switch node, it is followed by
+the NodeDescription in quotes and the LID of the peer node. If it is a
+CA or router node, it is followed by the local LID and LMC and then
+followed by the NodeDescription in quotes and the LID of the peer node.
+The active link width and speed are then appended to the end of this
+output line.
+.sp
+An example of this is:
+.INDENT 0.0
+.INDENT 3.5
+.sp
+.nf
+.ft C
+#
+# Topology file: generated on Tue Jun 5 14:15:10 2007
+#
+# Max of 3 hops discovered
+# Initiated from node 0008f10403960558 port 0008f10403960559
+
+Non\-Chassis Nodes
+
+vendid=0x8f1
+devid=0x5a06
+sysimgguid=0x5442ba00003000
+switchguid=0x5442ba00003080(5442ba00003080)
+Switch 24 "S\-005442ba00003080" # "ISR9024 Voltaire" base port 0 lid 6 lmc 0
+[22] "H\-0008f10403961354"[1](8f10403961355) # "MT23108 InfiniHost Mellanox Technologies" lid 4 4xSDR
+[10] "S\-0008f10400410015"[1] # "SW\-6IB4 Voltaire" lid 3 4xSDR
+[8] "H\-0008f10403960558"[2](8f1040396055a) # "MT23108 InfiniHost Mellanox Technologies" lid 14 4xSDR
+[6] "S\-0008f10400410015"[3] # "SW\-6IB4 Voltaire" lid 3 4xSDR
+[12] "H\-0008f10403960558"[1](8f10403960559) # "MT23108 InfiniHost Mellanox Technologies" lid 10 4xSDR
+
+vendid=0x8f1
+devid=0x5a05
+switchguid=0x8f10400410015(8f10400410015)
+Switch 8 "S\-0008f10400410015" # "SW\-6IB4 Voltaire" base port 0 lid 3 lmc 0
+[6] "H\-0008f10403960984"[1](8f10403960985) # "MT23108 InfiniHost Mellanox Technologies" lid 16 4xSDR
+[4] "H\-005442b100004900"[1](5442b100004901) # "MT23108 InfiniHost Mellanox Technologies" lid 12 4xSDR
+[1] "S\-005442ba00003080"[10] # "ISR9024 Voltaire" lid 6 1xSDR
+[3] "S\-005442ba00003080"[6] # "ISR9024 Voltaire" lid 6 4xSDR
+
+vendid=0x2c9
+devid=0x5a44
+caguid=0x8f10403960984
+Ca 2 "H\-0008f10403960984" # "MT23108 InfiniHost Mellanox Technologies"
+[1](8f10403960985) "S\-0008f10400410015"[6] # lid 16 lmc 1 "SW\-6IB4 Voltaire" lid 3 4xSDR
+
+vendid=0x2c9
+devid=0x5a44
+caguid=0x5442b100004900
+Ca 2 "H\-005442b100004900" # "MT23108 InfiniHost Mellanox Technologies"
+[1](5442b100004901) "S\-0008f10400410015"[4] # lid 12 lmc 1 "SW\-6IB4 Voltaire" lid 3 4xSDR
+
+vendid=0x2c9
+devid=0x5a44
+caguid=0x8f10403961354
+Ca 2 "H\-0008f10403961354" # "MT23108 InfiniHost Mellanox Technologies"
+[1](8f10403961355) "S\-005442ba00003080"[22] # lid 4 lmc 1 "ISR9024 Voltaire" lid 6 4xSDR
+
+vendid=0x2c9
+devid=0x5a44
+caguid=0x8f10403960558
+Ca 2 "H\-0008f10403960558" # "MT23108 InfiniHost Mellanox Technologies"
+[2](8f1040396055a) "S\-005442ba00003080"[8] # lid 14 lmc 1 "ISR9024 Voltaire" lid 6 4xSDR
+[1](8f10403960559) "S\-005442ba00003080"[12] # lid 10 lmc 1 "ISR9024 Voltaire" lid 6 1xSDR
+.ft P
+.fi
+.UNINDENT
+.UNINDENT
+.sp
+When grouping is used, IB nodes are organized into chassis which are
+numbered. Nodes which cannot be determined to be in a chassis are
+displayed as "Non\-Chassis Nodes". External ports are also shown on the
+connectivity lines.
+.SH AUTHORS
+.INDENT 0.0
+.TP
+.B Hal Rosenstock
+< \fI\%halr@voltaire.com\fP >
+.TP
+.B Ira Weiny
+< \fI\%ira.weiny@intel.com\fP >
+.UNINDENT
+.\" Generated by docutils manpage writer.
+.
diff --git a/contrib/ofed/infiniband-diags/man/ibnodes.8 b/contrib/ofed/infiniband-diags/man/ibnodes.8
new file mode 100644
index 0000000..03f8c14
--- /dev/null
+++ b/contrib/ofed/infiniband-diags/man/ibnodes.8
@@ -0,0 +1,176 @@
+.\" Man page generated from reStructuredText.
+.
+.TH IBNODES 8 "" "" "OpenIB Diagnostics"
+.SH NAME
+IBNODES \- show InfiniBand nodes in topology
+.
+.nr rst2man-indent-level 0
+.
+.de1 rstReportMargin
+\\$1 \\n[an-margin]
+level \\n[rst2man-indent-level]
+level margin: \\n[rst2man-indent\\n[rst2man-indent-level]]
+-
+\\n[rst2man-indent0]
+\\n[rst2man-indent1]
+\\n[rst2man-indent2]
+..
+.de1 INDENT
+.\" .rstReportMargin pre:
+. RS \\$1
+. nr rst2man-indent\\n[rst2man-indent-level] \\n[an-margin]
+. nr rst2man-indent-level +1
+.\" .rstReportMargin post:
+..
+.de UNINDENT
+. RE
+.\" indent \\n[an-margin]
+.\" old: \\n[rst2man-indent\\n[rst2man-indent-level]]
+.nr rst2man-indent-level -1
+.\" new: \\n[rst2man-indent\\n[rst2man-indent-level]]
+.in \\n[rst2man-indent\\n[rst2man-indent-level]]u
+..
+.SH SYNOPSIS
+.sp
+ibnodes [options] [<topology\-file>]
+.SH DESCRIPTION
+.sp
+ibnodes is a script which either walks the IB subnet topology or uses an
+already saved topology file and extracts the IB nodes (CAs and switches).
+.SH OPTIONS
+.\" Define the common option -C
+.
+.sp
+\fB\-C, \-\-Ca <ca_name>\fP use the specified ca_name.
+.\" Define the common option -P
+.
+.sp
+\fB\-P, \-\-Port <ca_port>\fP use the specified ca_port.
+.\" Define the common option -t
+.
+.sp
+\fB\-t, \-\-timeout <timeout_ms>\fP override the default timeout for the solicited mads.
+.\" Define the common option -h
+.
+.sp
+\fB\-h, \-\-help\fP show the usage message
+.\" Define the common option -z
+.
+.sp
+\fB\-\-config, \-z <config_file>\fP Specify alternate config file.
+.INDENT 0.0
+.INDENT 3.5
+Default: /etc/infiniband-diags/ibdiag.conf
+.UNINDENT
+.UNINDENT
+.\" Explanation of local port selection
+.
+.SS Local port Selection
+.sp
+Multiple port/Multiple CA support: when no IB device or port is specified
+(see the "local umad parameters" below), the libibumad library
+selects the port to use by the following criteria:
+.INDENT 0.0
+.INDENT 3.5
+.INDENT 0.0
+.IP 1. 3
+the first port that is ACTIVE.
+.IP 2. 3
+if not found, the first port that is UP (physical link up).
+.UNINDENT
+.sp
+If a port and/or CA name is specified, the libibumad library attempts
+to fulfill the user request, and will fail if it is not possible.
+.sp
+For example:
+.INDENT 0.0
+.INDENT 3.5
+.sp
+.nf
+.ft C
+ibaddr # use the first port (criteria #1 above)
+ibaddr \-C mthca1 # pick the best port from "mthca1" only.
+ibaddr \-P 2 # use the second (active/up) port from the first available IB device.
+ibaddr \-C mthca0 \-P 2 # use the specified port only.
+.ft P
+.fi
+.UNINDENT
+.UNINDENT
+.UNINDENT
+.UNINDENT
+.SH FILES
+.\" Common text for the config file
+.
+.SS CONFIG FILE
+.sp
+/etc/infiniband-diags/ibdiag.conf
+.sp
+A global config file is provided to set some of the common options for all
+tools. See supplied config file for details.
+.\" Common text to describe the node name map file.
+.
+.SS NODE NAME MAP FILE FORMAT
+.sp
+The node name map is used to specify user friendly names for nodes in the
+output. GUIDs are used to perform the lookup.
+.sp
+This functionality is provided by the opensm\-libs package. See \fBopensm(8)\fP
+for the file location for your installation.
+.sp
+\fBGenerically:\fP
+.INDENT 0.0
+.INDENT 3.5
+.sp
+.nf
+.ft C
+# comment
+<guid> "<name>"
+.ft P
+.fi
+.UNINDENT
+.UNINDENT
+.sp
+\fBExample:\fP
+.INDENT 0.0
+.INDENT 3.5
+.sp
+.nf
+.ft C
+# IB1
+# Line cards
+0x0008f104003f125c "IB1 (Rack 11 slot 1 ) ISR9288/ISR9096 Voltaire sLB\-24D"
+0x0008f104003f125d "IB1 (Rack 11 slot 1 ) ISR9288/ISR9096 Voltaire sLB\-24D"
+0x0008f104003f10d2 "IB1 (Rack 11 slot 2 ) ISR9288/ISR9096 Voltaire sLB\-24D"
+0x0008f104003f10d3 "IB1 (Rack 11 slot 2 ) ISR9288/ISR9096 Voltaire sLB\-24D"
+0x0008f104003f10bf "IB1 (Rack 11 slot 12 ) ISR9288/ISR9096 Voltaire sLB\-24D"
+
+# Spines
+0x0008f10400400e2d "IB1 (Rack 11 spine 1 ) ISR9288 Voltaire sFB\-12D"
+0x0008f10400400e2e "IB1 (Rack 11 spine 1 ) ISR9288 Voltaire sFB\-12D"
+0x0008f10400400e2f "IB1 (Rack 11 spine 1 ) ISR9288 Voltaire sFB\-12D"
+0x0008f10400400e31 "IB1 (Rack 11 spine 2 ) ISR9288 Voltaire sFB\-12D"
+0x0008f10400400e32 "IB1 (Rack 11 spine 2 ) ISR9288 Voltaire sFB\-12D"
+
+# GUID Node Name
+0x0008f10400411a08 "SW1 (Rack 3) ISR9024 Voltaire 9024D"
+0x0008f10400411a28 "SW2 (Rack 3) ISR9024 Voltaire 9024D"
+0x0008f10400411a34 "SW3 (Rack 3) ISR9024 Voltaire 9024D"
+0x0008f104004119d0 "SW4 (Rack 3) ISR9024 Voltaire 9024D"
+.ft P
+.fi
+.UNINDENT
+.UNINDENT
+.SH SEE ALSO
+.sp
+ibnetdiscover(8)
+.SH DEPENDENCIES
+.sp
+ibnetdiscover, ibnetdiscover format
+.SH AUTHOR
+.INDENT 0.0
+.TP
+.B Hal Rosenstock
+< \fI\%halr@voltaire.com\fP >
+.UNINDENT
+.\" Generated by docutils manpage writer.
+.
diff --git a/contrib/ofed/infiniband-diags/man/ibping.8 b/contrib/ofed/infiniband-diags/man/ibping.8
new file mode 100644
index 0000000..1fa53ad
--- /dev/null
+++ b/contrib/ofed/infiniband-diags/man/ibping.8
@@ -0,0 +1,177 @@
+.\" Man page generated from reStructuredText.
+.
+.TH IBPING 8 "" "" "Open IB Diagnostics"
+.SH NAME
+IBPING \- ping an InfiniBand address
+.
+.nr rst2man-indent-level 0
+.
+.de1 rstReportMargin
+\\$1 \\n[an-margin]
+level \\n[rst2man-indent-level]
+level margin: \\n[rst2man-indent\\n[rst2man-indent-level]]
+-
+\\n[rst2man-indent0]
+\\n[rst2man-indent1]
+\\n[rst2man-indent2]
+..
+.de1 INDENT
+.\" .rstReportMargin pre:
+. RS \\$1
+. nr rst2man-indent\\n[rst2man-indent-level] \\n[an-margin]
+. nr rst2man-indent-level +1
+.\" .rstReportMargin post:
+..
+.de UNINDENT
+. RE
+.\" indent \\n[an-margin]
+.\" old: \\n[rst2man-indent\\n[rst2man-indent-level]]
+.nr rst2man-indent-level -1
+.\" new: \\n[rst2man-indent\\n[rst2man-indent-level]]
+.in \\n[rst2man-indent\\n[rst2man-indent-level]]u
+..
+.SH SYNOPSIS
+.sp
+ibping [options] <dest lid | guid>
+.SH DESCRIPTION
+.sp
+ibping uses vendor mads to validate connectivity between IB nodes.
+On exit, (IP) ping like output is show. ibping is run as client/server.
+Default is to run as client. Note also that a default ping server is
+implemented within the kernel.
+.SH OPTIONS
+.sp
+\fB\-c, \-\-count\fP
+stop after count packets
+.sp
+\fB\-f, \-\-flood\fP
+flood destination: send packets back to back without delay
+.sp
+\fB\-o, \-\-oui\fP
+use specified OUI number to multiplex vendor mads
+.sp
+\fB\-S, \-\-Server\fP
+start in server mode (do not return)
+.sp
+\fB\-\-dgid <gid>\fP
+destination GID: use when GRH is required in packets (IPv6 format)
+.SS Addressing Flags
+.\" Define the common option -L
+.
+.sp
+\fB\-L, \-\-Lid\fP The address specified is a LID
+.\" Define the common option -G
+.
+.sp
+\fB\-G, \-\-Guid\fP The address specified is a Port GUID
+.\" Define the common option -s
+.
+.sp
+\fB\-s, \-\-sm_port <smlid>\fP use \(aqsmlid\(aq as the target lid for SA queries.
+.SS Port Selection flags
+.\" Define the common option -C
+.
+.sp
+\fB\-C, \-\-Ca <ca_name>\fP use the specified ca_name.
+.\" Define the common option -P
+.
+.sp
+\fB\-P, \-\-Port <ca_port>\fP use the specified ca_port.
+.\" Explanation of local port selection
+.
+.SS Local port Selection
+.sp
+Multiple port/Multiple CA support: when no IB device or port is specified
+(see the "local umad parameters" below), the libibumad library
+selects the port to use by the following criteria:
+.INDENT 0.0
+.INDENT 3.5
+.INDENT 0.0
+.IP 1. 3
+the first port that is ACTIVE.
+.IP 2. 3
+if not found, the first port that is UP (physical link up).
+.UNINDENT
+.sp
+If a port and/or CA name is specified, the libibumad library attempts
+to fulfill the user request, and will fail if it is not possible.
+.sp
+For example:
+.INDENT 0.0
+.INDENT 3.5
+.sp
+.nf
+.ft C
+ibaddr # use the first port (criteria #1 above)
+ibaddr \-C mthca1 # pick the best port from "mthca1" only.
+ibaddr \-P 2 # use the second (active/up) port from the first available IB device.
+ibaddr \-C mthca0 \-P 2 # use the specified port only.
+.ft P
+.fi
+.UNINDENT
+.UNINDENT
+.UNINDENT
+.UNINDENT
+.SS Configuration flags
+.\" Define the common option -z
+.
+.sp
+\fB\-\-config, \-z <config_file>\fP Specify alternate config file.
+.INDENT 0.0
+.INDENT 3.5
+Default: /etc/infiniband-diags/ibdiag.conf
+.UNINDENT
+.UNINDENT
+.\" Define the common option -t
+.
+.sp
+\fB\-t, \-\-timeout <timeout_ms>\fP override the default timeout for the solicited mads.
+.SS Debugging flags
+.\" Define the common option -h
+.
+.sp
+\fB\-h, \-\-help\fP show the usage message
+.\" Define the common option -d
+.
+.INDENT 0.0
+.TP
+.B \-d
+raise the IB debugging level.
+May be used several times (\-ddd or \-d \-d \-d).
+.UNINDENT
+.\" Define the common option -e
+.
+.INDENT 0.0
+.TP
+.B \-e
+show send and receive errors (timeouts and others)
+.UNINDENT
+.\" Define the common option -v
+.
+.INDENT 0.0
+.TP
+.B \fB\-v, \-\-verbose\fP
+increase the application verbosity level.
+May be used several times (\-vv or \-v \-v \-v)
+.UNINDENT
+.\" Define the common option -V
+.
+.sp
+\fB\-V, \-\-version\fP show the version info.
+.SH FILES
+.\" Common text for the config file
+.
+.SS CONFIG FILE
+.sp
+/etc/infiniband-diags/ibdiag.conf
+.sp
+A global config file is provided to set some of the common options for all
+tools. See supplied config file for details.
+.SH AUTHOR
+.INDENT 0.0
+.TP
+.B Hal Rosenstock
+< \fI\%halr@voltaire.com\fP >
+.UNINDENT
+.\" Generated by docutils manpage writer.
+.
diff --git a/contrib/ofed/infiniband-diags/man/ibportstate.8 b/contrib/ofed/infiniband-diags/man/ibportstate.8
new file mode 100644
index 0000000..2d7c85f
--- /dev/null
+++ b/contrib/ofed/infiniband-diags/man/ibportstate.8
@@ -0,0 +1,259 @@
+.\" Man page generated from reStructuredText.
+.
+.TH IBPORTSTATE 8 "" "" "Open IB Diagnostics"
+.SH NAME
+IBPORTSTATE \- handle port (physical) state and link speed of an InfiniBand port
+.
+.nr rst2man-indent-level 0
+.
+.de1 rstReportMargin
+\\$1 \\n[an-margin]
+level \\n[rst2man-indent-level]
+level margin: \\n[rst2man-indent\\n[rst2man-indent-level]]
+-
+\\n[rst2man-indent0]
+\\n[rst2man-indent1]
+\\n[rst2man-indent2]
+..
+.de1 INDENT
+.\" .rstReportMargin pre:
+. RS \\$1
+. nr rst2man-indent\\n[rst2man-indent-level] \\n[an-margin]
+. nr rst2man-indent-level +1
+.\" .rstReportMargin post:
+..
+.de UNINDENT
+. RE
+.\" indent \\n[an-margin]
+.\" old: \\n[rst2man-indent\\n[rst2man-indent-level]]
+.nr rst2man-indent-level -1
+.\" new: \\n[rst2man-indent\\n[rst2man-indent-level]]
+.in \\n[rst2man-indent\\n[rst2man-indent-level]]u
+..
+.SH SYNOPSIS
+.sp
+ibportstate [options] <dest dr_path|lid|guid> <portnum> [<op>]
+.SH DESCRIPTION
+.sp
+ibportstate allows the port state and port physical state of an IB port
+to be queried (in addition to link width and speed being validated
+relative to the peer port when the port queried is a switch port),
+or a switch port to be disabled, enabled, or reset. It
+also allows the link speed/width enabled on any IB port to be adjusted.
+.SH OPTIONS
+.INDENT 0.0
+.TP
+.B \fB<op>\fP
+.INDENT 7.0
+.TP
+.B Supported ops: enable, disable, reset, speed, espeed, fdr10, width, query,
+on, off, down, arm, active, vls, mtu, lid, smlid, lmc,
+mkey, mkeylease, mkeyprot
+(Default is query)
+.UNINDENT
+.sp
+\fBenable, disable, and reset\fP are only allowed on switch ports (An
+error is indicated if attempted on CA or router ports)
+.sp
+\fBoff\fP change the port state to disable.
+.sp
+\fBon\fP change the port state to enable(only when the current state is disable).
+.sp
+\fBspeed and width\fP are allowed on any port
+.sp
+\fBspeed\fP values are the legal values for PortInfo:LinkSpeedEnabled (An
+error is indicated if PortInfo:LinkSpeedSupported does not support this
+setting)
+.sp
+\fBespeed\fP is allowed on any port supporting extended link speeds
+.sp
+\fBfdr10\fP is allowed on any port supporting fdr10 (An error is
+indicated if port\(aqs capability mask indicates extended link speeds are
+not supported or if PortInfo:LinkSpeedExtSupported does not support
+this setting)
+.sp
+\fBwidth\fP values are legal values for PortInfo:LinkWidthEnabled (An
+error is indicated if PortInfo:LinkWidthSupported does not support this
+setting) (NOTE: Speed and width changes are not effected until the port
+goes through link renegotiation)
+.sp
+\fBquery\fP also validates port characteristics (link width, speed,
+espeed, and fdr10) based on the peer port. This checking is done when
+the port queried is a switch port as it relies on combined routing (an
+initial LID route with directed routing to the peer) which can only be
+done on a switch. This peer port validation feature of query op
+requires LID routing to be functioning in the subnet.
+.sp
+\fBmkey, mkeylease, and mkeyprot\fP are only allowed on CAs, routers, or
+switch port 0 (An error is generated if attempted on external switch
+ports). Hexadecimal and octal mkeys may be specified by prepending the
+key with \(aq0x\(aq or \(aq0\(aq, respectively. If a non\-numeric value (like \(aqx\(aq)
+is specified for the mkey, then ibportstate will prompt for a value.
+.UNINDENT
+.SS Addressing Flags
+.\" Define the common option -L
+.
+.sp
+\fB\-L, \-\-Lid\fP The address specified is a LID
+.\" Define the common option -G
+.
+.sp
+\fB\-G, \-\-Guid\fP The address specified is a Port GUID
+.\" Define the common option -D for Directed routes
+.
+.sp
+\fB\-D, \-\-Direct\fP The address specified is a directed route
+.INDENT 0.0
+.INDENT 3.5
+.sp
+.nf
+.ft C
+Examples:
+ [options] \-D [options] "0" # self port
+ [options] \-D [options] "0,1,2,1,4" # out via port 1, then 2, ...
+
+ (Note the second number in the path specified must match the port being
+ used. This can be specified using the port selection flag \(aq\-P\(aq or the
+ port found through the automatic selection process.)
+.ft P
+.fi
+.UNINDENT
+.UNINDENT
+.\" Define the common option -s
+.
+.sp
+\fB\-s, \-\-sm_port <smlid>\fP use \(aqsmlid\(aq as the target lid for SA queries.
+.SS Port Selection flags
+.\" Define the common option -C
+.
+.sp
+\fB\-C, \-\-Ca <ca_name>\fP use the specified ca_name.
+.\" Define the common option -P
+.
+.sp
+\fB\-P, \-\-Port <ca_port>\fP use the specified ca_port.
+.\" Explanation of local port selection
+.
+.SS Local port Selection
+.sp
+Multiple port/Multiple CA support: when no IB device or port is specified
+(see the "local umad parameters" below), the libibumad library
+selects the port to use by the following criteria:
+.INDENT 0.0
+.INDENT 3.5
+.INDENT 0.0
+.IP 1. 3
+the first port that is ACTIVE.
+.IP 2. 3
+if not found, the first port that is UP (physical link up).
+.UNINDENT
+.sp
+If a port and/or CA name is specified, the libibumad library attempts
+to fulfill the user request, and will fail if it is not possible.
+.sp
+For example:
+.INDENT 0.0
+.INDENT 3.5
+.sp
+.nf
+.ft C
+ibaddr # use the first port (criteria #1 above)
+ibaddr \-C mthca1 # pick the best port from "mthca1" only.
+ibaddr \-P 2 # use the second (active/up) port from the first available IB device.
+ibaddr \-C mthca0 \-P 2 # use the specified port only.
+.ft P
+.fi
+.UNINDENT
+.UNINDENT
+.UNINDENT
+.UNINDENT
+.SS Configuration flags
+.\" Define the common option -z
+.
+.sp
+\fB\-\-config, \-z <config_file>\fP Specify alternate config file.
+.INDENT 0.0
+.INDENT 3.5
+Default: /etc/infiniband-diags/ibdiag.conf
+.UNINDENT
+.UNINDENT
+.\" Define the common option -t
+.
+.sp
+\fB\-t, \-\-timeout <timeout_ms>\fP override the default timeout for the solicited mads.
+.\" Define the common option -y
+.
+.INDENT 0.0
+.TP
+.B \fB\-y, \-\-m_key <key>\fP
+use the specified M_key for requests. If non\-numeric value (like \(aqx\(aq)
+is specified then a value will be prompted for.
+.UNINDENT
+.SS Debugging flags
+.\" Define the common option -h
+.
+.sp
+\fB\-h, \-\-help\fP show the usage message
+.\" Define the common option -d
+.
+.INDENT 0.0
+.TP
+.B \-d
+raise the IB debugging level.
+May be used several times (\-ddd or \-d \-d \-d).
+.UNINDENT
+.\" Define the common option -e
+.
+.INDENT 0.0
+.TP
+.B \-e
+show send and receive errors (timeouts and others)
+.UNINDENT
+.\" Define the common option -K
+.
+.INDENT 0.0
+.TP
+.B \fB\-K, \-\-show_keys\fP
+show security keys (mkey, smkey, etc.) associated with the request.
+.UNINDENT
+.\" Define the common option -v
+.
+.INDENT 0.0
+.TP
+.B \fB\-v, \-\-verbose\fP
+increase the application verbosity level.
+May be used several times (\-vv or \-v \-v \-v)
+.UNINDENT
+.\" Define the common option -V
+.
+.sp
+\fB\-V, \-\-version\fP show the version info.
+.SH FILES
+.\" Common text for the config file
+.
+.SS CONFIG FILE
+.sp
+/etc/infiniband-diags/ibdiag.conf
+.sp
+A global config file is provided to set some of the common options for all
+tools. See supplied config file for details.
+.SH EXAMPLES
+.INDENT 0.0
+.TP
+.B ::
+ibportstate 3 1 disable # by lid
+ibportstate \-G 0x2C9000100D051 1 enable # by guid
+ibportstate \-D 0 1 # (query) by direct route
+ibportstate 3 1 reset # by lid
+ibportstate 3 1 speed 1 # by lid
+ibportstate 3 1 width 1 # by lid
+ibportstate \-D 0 1 lid 0x1234 arm # by direct route
+.UNINDENT
+.SH AUTHOR
+.INDENT 0.0
+.TP
+.B Hal Rosenstock
+< \fI\%hal.rosenstock@gmail.com\fP >
+.UNINDENT
+.\" Generated by docutils manpage writer.
+.
diff --git a/contrib/ofed/infiniband-diags/man/ibqueryerrors.8 b/contrib/ofed/infiniband-diags/man/ibqueryerrors.8
new file mode 100644
index 0000000..be9f3c0
--- /dev/null
+++ b/contrib/ofed/infiniband-diags/man/ibqueryerrors.8
@@ -0,0 +1,339 @@
+.\" Man page generated from reStructuredText.
+.
+.TH IBQUERYERRORS 8 "" "" "OpenIB Diagnostics"
+.SH NAME
+IBQUERYERRORS \- query and report IB port counters
+.
+.nr rst2man-indent-level 0
+.
+.de1 rstReportMargin
+\\$1 \\n[an-margin]
+level \\n[rst2man-indent-level]
+level margin: \\n[rst2man-indent\\n[rst2man-indent-level]]
+-
+\\n[rst2man-indent0]
+\\n[rst2man-indent1]
+\\n[rst2man-indent2]
+..
+.de1 INDENT
+.\" .rstReportMargin pre:
+. RS \\$1
+. nr rst2man-indent\\n[rst2man-indent-level] \\n[an-margin]
+. nr rst2man-indent-level +1
+.\" .rstReportMargin post:
+..
+.de UNINDENT
+. RE
+.\" indent \\n[an-margin]
+.\" old: \\n[rst2man-indent\\n[rst2man-indent-level]]
+.nr rst2man-indent-level -1
+.\" new: \\n[rst2man-indent\\n[rst2man-indent-level]]
+.in \\n[rst2man-indent\\n[rst2man-indent-level]]u
+..
+.SH SYNOPSIS
+.sp
+ibqueryerrors [options]
+.SH DESCRIPTION
+.sp
+The default behavior is to report the port error counters which exceed a
+threshold for each port in the fabric. The default threshold is zero (0).
+Error fields can also be suppressed entirely.
+.sp
+In addition to reporting errors on every port. ibqueryerrors can report the
+port transmit and receive data as well as report full link information to the
+remote port if available.
+.SH OPTIONS
+.sp
+\fB\-s, \-\-suppress <err1,err2,...>\fP
+Suppress the errors listed in the comma separated list provided.
+.sp
+\fB\-c, \-\-suppress\-common\fP
+Suppress some of the common "side effect" counters. These counters usually do
+not indicate an error condition and can be usually be safely ignored.
+.sp
+\fB\-r, \-\-report\-port\fP
+Report the port information. This includes LID, port, external port (if
+applicable), link speed setting, remote GUID, remote port, remote external port
+(if applicable), and remote node description information.
+.sp
+\fB\-\-data\fP
+Include the optional transmit and receive data counters.
+.sp
+\fB\-\-threshold\-file <filename>\fP
+Specify an alternate threshold file. The default is /etc/infiniband-diags/error_thresholds
+.sp
+\fB\-\-switch\fP print data for switch\(aqs only
+.sp
+\fB\-\-ca\fP print data for CA\(aqs only
+.sp
+\fB\-\-skip\-sl\fP Use the default sl for queries. This is not recommended when
+using a QoS aware routing engine as it can cause a credit deadlock.
+.sp
+\fB\-\-router\fP print data for routers only
+.sp
+\fB\-\-clear\-errors \-k\fP Clear error counters after read.
+.sp
+\fB\-\-clear\-counts \-K\fP Clear data counters after read.
+.sp
+\fBCAUTION\fP clearing data or error counters will occur regardless of if they
+are printed or not. See \fB\-\-counters\fP and \fB\-\-data\fP for details on
+controling which counters are printed.
+.sp
+\fB\-\-details\fP include receive error and transmit discard details
+.sp
+\fB\-\-counters\fP print data counters only
+.SS Partial Scan flags
+.sp
+The node to start a partial scan can be specified with the following addresses.
+.\" Define the common option -G
+.
+.sp
+\fB\-\-port\-guid, \-G <port_guid>\fP Specify a port_guid
+.\" Define the common option -D for Directed routes
+.
+.sp
+\fB\-D, \-\-Direct <dr_path>\fP The address specified is a directed route
+.INDENT 0.0
+.INDENT 3.5
+.sp
+.nf
+.ft C
+Examples:
+ \-D "0" # self port
+ \-D "0,1,2,1,4" # out via port 1, then 2, ...
+
+ (Note the second number in the path specified must match the port being
+ used. This can be specified using the port selection flag \(aq\-P\(aq or the
+ port found through the automatic selection process.)
+.ft P
+.fi
+.UNINDENT
+.UNINDENT
+.sp
+\fBNote:\fP For switches results are printed for all ports not just switch port 0.
+.sp
+\fB\-S <port_guid>\fP same as "\-G". (provided only for backward compatibility)
+.SS Cache File flags
+.\" Define the common option load-cache
+.
+.sp
+\fB\-\-load\-cache <filename>\fP
+Load and use the cached ibnetdiscover data stored in the specified
+filename. May be useful for outputting and learning about other
+fabrics or a previous state of a fabric.
+.SS Port Selection flags
+.\" Define the common option -C
+.
+.sp
+\fB\-C, \-\-Ca <ca_name>\fP use the specified ca_name.
+.\" Define the common option -P
+.
+.sp
+\fB\-P, \-\-Port <ca_port>\fP use the specified ca_port.
+.\" Explanation of local port selection
+.
+.SS Local port Selection
+.sp
+Multiple port/Multiple CA support: when no IB device or port is specified
+(see the "local umad parameters" below), the libibumad library
+selects the port to use by the following criteria:
+.INDENT 0.0
+.INDENT 3.5
+.INDENT 0.0
+.IP 1. 3
+the first port that is ACTIVE.
+.IP 2. 3
+if not found, the first port that is UP (physical link up).
+.UNINDENT
+.sp
+If a port and/or CA name is specified, the libibumad library attempts
+to fulfill the user request, and will fail if it is not possible.
+.sp
+For example:
+.INDENT 0.0
+.INDENT 3.5
+.sp
+.nf
+.ft C
+ibaddr # use the first port (criteria #1 above)
+ibaddr \-C mthca1 # pick the best port from "mthca1" only.
+ibaddr \-P 2 # use the second (active/up) port from the first available IB device.
+ibaddr \-C mthca0 \-P 2 # use the specified port only.
+.ft P
+.fi
+.UNINDENT
+.UNINDENT
+.UNINDENT
+.UNINDENT
+.SS Configuration flags
+.\" Define the common option -z
+.
+.sp
+\fB\-\-config, \-z <config_file>\fP Specify alternate config file.
+.INDENT 0.0
+.INDENT 3.5
+Default: /etc/infiniband-diags/ibdiag.conf
+.UNINDENT
+.UNINDENT
+.\" Define the common option -z
+.
+.INDENT 0.0
+.TP
+.B \fB\-\-outstanding_smps, \-o <val>\fP
+Specify the number of outstanding SMP\(aqs which should be issued during the scan
+.sp
+Default: 2
+.UNINDENT
+.\" Define the common option --node-name-map
+.
+.sp
+\fB\-\-node\-name\-map <node\-name\-map>\fP Specify a node name map.
+.INDENT 0.0
+.INDENT 3.5
+This file maps GUIDs to more user friendly names. See FILES section.
+.UNINDENT
+.UNINDENT
+.\" Define the common option -t
+.
+.sp
+\fB\-t, \-\-timeout <timeout_ms>\fP override the default timeout for the solicited mads.
+.\" Define the common option -y
+.
+.INDENT 0.0
+.TP
+.B \fB\-y, \-\-m_key <key>\fP
+use the specified M_key for requests. If non\-numeric value (like \(aqx\(aq)
+is specified then a value will be prompted for.
+.UNINDENT
+.SS Debugging flags
+.\" Define the common option -d
+.
+.INDENT 0.0
+.TP
+.B \-d
+raise the IB debugging level.
+May be used several times (\-ddd or \-d \-d \-d).
+.UNINDENT
+.\" Define the common option -e
+.
+.INDENT 0.0
+.TP
+.B \-e
+show send and receive errors (timeouts and others)
+.UNINDENT
+.\" Define the common option -h
+.
+.sp
+\fB\-h, \-\-help\fP show the usage message
+.\" Define the common option -v
+.
+.INDENT 0.0
+.TP
+.B \fB\-v, \-\-verbose\fP
+increase the application verbosity level.
+May be used several times (\-vv or \-v \-v \-v)
+.UNINDENT
+.\" Define the common option -V
+.
+.sp
+\fB\-V, \-\-version\fP show the version info.
+.sp
+\fB\-R\fP (This option is obsolete and does nothing)
+.SH EXIT STATUS
+.sp
+\fB\-1\fP if scan fails.
+.sp
+\fB0\fP if scan succeeds without errors beyond thresholds
+.sp
+\fB1\fP if errors are found beyond thresholds or inconsistencies are found in check mode.
+.SH FILES
+.SS ERROR THRESHOLD
+.sp
+/etc/infiniband-diags/error_thresholds
+.sp
+Define threshold values for errors. File format is simple "name=val".
+Comments begin with \(aq#\(aq
+.sp
+\fBExample:\fP
+.INDENT 0.0
+.INDENT 3.5
+.sp
+.nf
+.ft C
+# Define thresholds for error counters
+SymbolErrorCounter=10
+LinkErrorRecoveryCounter=10
+VL15Dropped=100
+.ft P
+.fi
+.UNINDENT
+.UNINDENT
+.\" Common text for the config file
+.
+.SS CONFIG FILE
+.sp
+/etc/infiniband-diags/ibdiag.conf
+.sp
+A global config file is provided to set some of the common options for all
+tools. See supplied config file for details.
+.\" Common text to describe the node name map file.
+.
+.SS NODE NAME MAP FILE FORMAT
+.sp
+The node name map is used to specify user friendly names for nodes in the
+output. GUIDs are used to perform the lookup.
+.sp
+This functionality is provided by the opensm\-libs package. See \fBopensm(8)\fP
+for the file location for your installation.
+.sp
+\fBGenerically:\fP
+.INDENT 0.0
+.INDENT 3.5
+.sp
+.nf
+.ft C
+# comment
+<guid> "<name>"
+.ft P
+.fi
+.UNINDENT
+.UNINDENT
+.sp
+\fBExample:\fP
+.INDENT 0.0
+.INDENT 3.5
+.sp
+.nf
+.ft C
+# IB1
+# Line cards
+0x0008f104003f125c "IB1 (Rack 11 slot 1 ) ISR9288/ISR9096 Voltaire sLB\-24D"
+0x0008f104003f125d "IB1 (Rack 11 slot 1 ) ISR9288/ISR9096 Voltaire sLB\-24D"
+0x0008f104003f10d2 "IB1 (Rack 11 slot 2 ) ISR9288/ISR9096 Voltaire sLB\-24D"
+0x0008f104003f10d3 "IB1 (Rack 11 slot 2 ) ISR9288/ISR9096 Voltaire sLB\-24D"
+0x0008f104003f10bf "IB1 (Rack 11 slot 12 ) ISR9288/ISR9096 Voltaire sLB\-24D"
+
+# Spines
+0x0008f10400400e2d "IB1 (Rack 11 spine 1 ) ISR9288 Voltaire sFB\-12D"
+0x0008f10400400e2e "IB1 (Rack 11 spine 1 ) ISR9288 Voltaire sFB\-12D"
+0x0008f10400400e2f "IB1 (Rack 11 spine 1 ) ISR9288 Voltaire sFB\-12D"
+0x0008f10400400e31 "IB1 (Rack 11 spine 2 ) ISR9288 Voltaire sFB\-12D"
+0x0008f10400400e32 "IB1 (Rack 11 spine 2 ) ISR9288 Voltaire sFB\-12D"
+
+# GUID Node Name
+0x0008f10400411a08 "SW1 (Rack 3) ISR9024 Voltaire 9024D"
+0x0008f10400411a28 "SW2 (Rack 3) ISR9024 Voltaire 9024D"
+0x0008f10400411a34 "SW3 (Rack 3) ISR9024 Voltaire 9024D"
+0x0008f104004119d0 "SW4 (Rack 3) ISR9024 Voltaire 9024D"
+.ft P
+.fi
+.UNINDENT
+.UNINDENT
+.SH AUTHOR
+.INDENT 0.0
+.TP
+.B Ira Weiny
+< \fI\%ira.weiny@intel.com\fP >
+.UNINDENT
+.\" Generated by docutils manpage writer.
+.
diff --git a/contrib/ofed/infiniband-diags/man/ibroute.8 b/contrib/ofed/infiniband-diags/man/ibroute.8
new file mode 100644
index 0000000..7c03c12
--- /dev/null
+++ b/contrib/ofed/infiniband-diags/man/ibroute.8
@@ -0,0 +1,291 @@
+.\" Man page generated from reStructuredText.
+.
+.TH IBROUTE 8 "" "" "Open IB Diagnostics"
+.SH NAME
+IBROUTE \-
+.
+.nr rst2man-indent-level 0
+.
+.de1 rstReportMargin
+\\$1 \\n[an-margin]
+level \\n[rst2man-indent-level]
+level margin: \\n[rst2man-indent\\n[rst2man-indent-level]]
+-
+\\n[rst2man-indent0]
+\\n[rst2man-indent1]
+\\n[rst2man-indent2]
+..
+.de1 INDENT
+.\" .rstReportMargin pre:
+. RS \\$1
+. nr rst2man-indent\\n[rst2man-indent-level] \\n[an-margin]
+. nr rst2man-indent-level +1
+.\" .rstReportMargin post:
+..
+.de UNINDENT
+. RE
+.\" indent \\n[an-margin]
+.\" old: \\n[rst2man-indent\\n[rst2man-indent-level]]
+.nr rst2man-indent-level -1
+.\" new: \\n[rst2man-indent\\n[rst2man-indent-level]]
+.in \\n[rst2man-indent\\n[rst2man-indent-level]]u
+..
+.SH QUERY INFINIBAND SWITCH FORWARDING TABLES
+.SS SYNOPSIS
+.sp
+ibroute [options] [<dest dr_path|lid|guid> [<startlid> [<endlid>]]]
+.SS DESCRIPTION
+.sp
+ibroute uses SMPs to display the forwarding tables (unicast
+(LinearForwardingTable or LFT) or multicast (MulticastForwardingTable or MFT))
+for the specified switch LID and the optional lid (mlid) range.
+The default range is all valid entries in the range 1...FDBTop.
+.SS OPTIONS
+.INDENT 0.0
+.TP
+.B \fB\-a, \-\-all\fP
+show all lids in range, even invalid entries
+.TP
+.B \fB\-n, \-\-no_dests\fP
+do not try to resolve destinations
+.TP
+.B \fB\-M, \-\-Multicast\fP
+show multicast forwarding tables
+In this case, the range parameters are specifying the mlid range.
+.UNINDENT
+.SS Addressing Flags
+.\" Define the common option -D for Directed routes
+.
+.sp
+\fB\-D, \-\-Direct\fP The address specified is a directed route
+.INDENT 0.0
+.INDENT 3.5
+.sp
+.nf
+.ft C
+Examples:
+ [options] \-D [options] "0" # self port
+ [options] \-D [options] "0,1,2,1,4" # out via port 1, then 2, ...
+
+ (Note the second number in the path specified must match the port being
+ used. This can be specified using the port selection flag \(aq\-P\(aq or the
+ port found through the automatic selection process.)
+.ft P
+.fi
+.UNINDENT
+.UNINDENT
+.\" Define the common option -G
+.
+.sp
+\fB\-G, \-\-Guid\fP The address specified is a Port GUID
+.\" Define the common option -L
+.
+.sp
+\fB\-L, \-\-Lid\fP The address specified is a LID
+.\" Define the common option -s
+.
+.sp
+\fB\-s, \-\-sm_port <smlid>\fP use \(aqsmlid\(aq as the target lid for SA queries.
+.SS Port Selection flags
+.\" Define the common option -C
+.
+.sp
+\fB\-C, \-\-Ca <ca_name>\fP use the specified ca_name.
+.\" Define the common option -P
+.
+.sp
+\fB\-P, \-\-Port <ca_port>\fP use the specified ca_port.
+.\" Explanation of local port selection
+.
+.SS Local port Selection
+.sp
+Multiple port/Multiple CA support: when no IB device or port is specified
+(see the "local umad parameters" below), the libibumad library
+selects the port to use by the following criteria:
+.INDENT 0.0
+.INDENT 3.5
+.INDENT 0.0
+.IP 1. 3
+the first port that is ACTIVE.
+.IP 2. 3
+if not found, the first port that is UP (physical link up).
+.UNINDENT
+.sp
+If a port and/or CA name is specified, the libibumad library attempts
+to fulfill the user request, and will fail if it is not possible.
+.sp
+For example:
+.INDENT 0.0
+.INDENT 3.5
+.sp
+.nf
+.ft C
+ibaddr # use the first port (criteria #1 above)
+ibaddr \-C mthca1 # pick the best port from "mthca1" only.
+ibaddr \-P 2 # use the second (active/up) port from the first available IB device.
+ibaddr \-C mthca0 \-P 2 # use the specified port only.
+.ft P
+.fi
+.UNINDENT
+.UNINDENT
+.UNINDENT
+.UNINDENT
+.SS Debugging flags
+.\" Define the common option -d
+.
+.INDENT 0.0
+.TP
+.B \-d
+raise the IB debugging level.
+May be used several times (\-ddd or \-d \-d \-d).
+.UNINDENT
+.\" Define the common option -e
+.
+.INDENT 0.0
+.TP
+.B \-e
+show send and receive errors (timeouts and others)
+.UNINDENT
+.\" Define the common option -h
+.
+.sp
+\fB\-h, \-\-help\fP show the usage message
+.\" Define the common option -v
+.
+.INDENT 0.0
+.TP
+.B \fB\-v, \-\-verbose\fP
+increase the application verbosity level.
+May be used several times (\-vv or \-v \-v \-v)
+.UNINDENT
+.\" Define the common option -V
+.
+.sp
+\fB\-V, \-\-version\fP show the version info.
+.SS Configuration flags
+.\" Define the common option -t
+.
+.sp
+\fB\-t, \-\-timeout <timeout_ms>\fP override the default timeout for the solicited mads.
+.\" Define the common option -y
+.
+.INDENT 0.0
+.TP
+.B \fB\-y, \-\-m_key <key>\fP
+use the specified M_key for requests. If non\-numeric value (like \(aqx\(aq)
+is specified then a value will be prompted for.
+.UNINDENT
+.\" Define the common option --node-name-map
+.
+.sp
+\fB\-\-node\-name\-map <node\-name\-map>\fP Specify a node name map.
+.INDENT 0.0
+.INDENT 3.5
+This file maps GUIDs to more user friendly names. See FILES section.
+.UNINDENT
+.UNINDENT
+.\" Define the common option -z
+.
+.sp
+\fB\-\-config, \-z <config_file>\fP Specify alternate config file.
+.INDENT 0.0
+.INDENT 3.5
+Default: /etc/infiniband-diags/ibdiag.conf
+.UNINDENT
+.UNINDENT
+.SS FILES
+.\" Common text for the config file
+.
+.SS CONFIG FILE
+.sp
+/etc/infiniband-diags/ibdiag.conf
+.sp
+A global config file is provided to set some of the common options for all
+tools. See supplied config file for details.
+.\" Common text to describe the node name map file.
+.
+.SS NODE NAME MAP FILE FORMAT
+.sp
+The node name map is used to specify user friendly names for nodes in the
+output. GUIDs are used to perform the lookup.
+.sp
+This functionality is provided by the opensm\-libs package. See \fBopensm(8)\fP
+for the file location for your installation.
+.sp
+\fBGenerically:\fP
+.INDENT 0.0
+.INDENT 3.5
+.sp
+.nf
+.ft C
+# comment
+<guid> "<name>"
+.ft P
+.fi
+.UNINDENT
+.UNINDENT
+.sp
+\fBExample:\fP
+.INDENT 0.0
+.INDENT 3.5
+.sp
+.nf
+.ft C
+# IB1
+# Line cards
+0x0008f104003f125c "IB1 (Rack 11 slot 1 ) ISR9288/ISR9096 Voltaire sLB\-24D"
+0x0008f104003f125d "IB1 (Rack 11 slot 1 ) ISR9288/ISR9096 Voltaire sLB\-24D"
+0x0008f104003f10d2 "IB1 (Rack 11 slot 2 ) ISR9288/ISR9096 Voltaire sLB\-24D"
+0x0008f104003f10d3 "IB1 (Rack 11 slot 2 ) ISR9288/ISR9096 Voltaire sLB\-24D"
+0x0008f104003f10bf "IB1 (Rack 11 slot 12 ) ISR9288/ISR9096 Voltaire sLB\-24D"
+
+# Spines
+0x0008f10400400e2d "IB1 (Rack 11 spine 1 ) ISR9288 Voltaire sFB\-12D"
+0x0008f10400400e2e "IB1 (Rack 11 spine 1 ) ISR9288 Voltaire sFB\-12D"
+0x0008f10400400e2f "IB1 (Rack 11 spine 1 ) ISR9288 Voltaire sFB\-12D"
+0x0008f10400400e31 "IB1 (Rack 11 spine 2 ) ISR9288 Voltaire sFB\-12D"
+0x0008f10400400e32 "IB1 (Rack 11 spine 2 ) ISR9288 Voltaire sFB\-12D"
+
+# GUID Node Name
+0x0008f10400411a08 "SW1 (Rack 3) ISR9024 Voltaire 9024D"
+0x0008f10400411a28 "SW2 (Rack 3) ISR9024 Voltaire 9024D"
+0x0008f10400411a34 "SW3 (Rack 3) ISR9024 Voltaire 9024D"
+0x0008f104004119d0 "SW4 (Rack 3) ISR9024 Voltaire 9024D"
+.ft P
+.fi
+.UNINDENT
+.UNINDENT
+.SS EXAMPLES
+.sp
+Unicast examples
+.INDENT 0.0
+.TP
+.B ::
+ibroute 4 # dump all lids with valid out ports of switch with lid 4
+ibroute \-a 4 # same, but dump all lids, even with invalid out ports
+ibroute \-n 4 # simple dump format \- no destination resolution
+ibroute 4 10 # dump lids starting from 10 (up to FDBTop)
+ibroute 4 0x10 0x20 # dump lid range
+ibroute \-G 0x08f1040023 # resolve switch by GUID
+ibroute \-D 0,1 # resolve switch by direct path
+.UNINDENT
+.sp
+Multicast examples
+.INDENT 0.0
+.TP
+.B ::
+ibroute \-M 4 # dump all non empty mlids of switch with lid 4
+ibroute \-M 4 0xc010 0xc020 # same, but with range
+ibroute \-M \-n 4 # simple dump format
+.UNINDENT
+.SS SEE ALSO
+.sp
+ibtracert (8)
+.SS AUTHOR
+.INDENT 0.0
+.TP
+.B Hal Rosenstock
+< \fI\%halr@voltaire.com\fP >
+.UNINDENT
+.\" Generated by docutils manpage writer.
+.
diff --git a/contrib/ofed/infiniband-diags/man/ibrouters.8 b/contrib/ofed/infiniband-diags/man/ibrouters.8
new file mode 100644
index 0000000..80530c6
--- /dev/null
+++ b/contrib/ofed/infiniband-diags/man/ibrouters.8
@@ -0,0 +1,184 @@
+.\" Man page generated from reStructuredText.
+.
+.TH IBROUTERS 8 "" "" "OpenIB Diagnostics"
+.SH NAME
+IBROUTERS \- show InfiniBand router nodes in topology
+.
+.nr rst2man-indent-level 0
+.
+.de1 rstReportMargin
+\\$1 \\n[an-margin]
+level \\n[rst2man-indent-level]
+level margin: \\n[rst2man-indent\\n[rst2man-indent-level]]
+-
+\\n[rst2man-indent0]
+\\n[rst2man-indent1]
+\\n[rst2man-indent2]
+..
+.de1 INDENT
+.\" .rstReportMargin pre:
+. RS \\$1
+. nr rst2man-indent\\n[rst2man-indent-level] \\n[an-margin]
+. nr rst2man-indent-level +1
+.\" .rstReportMargin post:
+..
+.de UNINDENT
+. RE
+.\" indent \\n[an-margin]
+.\" old: \\n[rst2man-indent\\n[rst2man-indent-level]]
+.nr rst2man-indent-level -1
+.\" new: \\n[rst2man-indent\\n[rst2man-indent-level]]
+.in \\n[rst2man-indent\\n[rst2man-indent-level]]u
+..
+.SH SYNOPSIS
+.sp
+ibrouters [options] [<topology\-file>]
+.SH DESCRIPTION
+.sp
+ibrouters is a script which either walks the IB subnet topology or uses an
+already saved topology file and extracts the router nodes.
+.SH OPTIONS
+.\" Define the common option -C
+.
+.sp
+\fB\-C, \-\-Ca <ca_name>\fP use the specified ca_name.
+.\" Define the common option -P
+.
+.sp
+\fB\-P, \-\-Port <ca_port>\fP use the specified ca_port.
+.\" Define the common option -t
+.
+.sp
+\fB\-t, \-\-timeout <timeout_ms>\fP override the default timeout for the solicited mads.
+.\" Define the common option -y
+.
+.INDENT 0.0
+.TP
+.B \fB\-y, \-\-m_key <key>\fP
+use the specified M_key for requests. If non\-numeric value (like \(aqx\(aq)
+is specified then a value will be prompted for.
+.UNINDENT
+.\" Define the common option -h
+.
+.sp
+\fB\-h, \-\-help\fP show the usage message
+.\" Define the common option -z
+.
+.sp
+\fB\-\-config, \-z <config_file>\fP Specify alternate config file.
+.INDENT 0.0
+.INDENT 3.5
+Default: /etc/infiniband-diags/ibdiag.conf
+.UNINDENT
+.UNINDENT
+.\" Explanation of local port selection
+.
+.SS Local port Selection
+.sp
+Multiple port/Multiple CA support: when no IB device or port is specified
+(see the "local umad parameters" below), the libibumad library
+selects the port to use by the following criteria:
+.INDENT 0.0
+.INDENT 3.5
+.INDENT 0.0
+.IP 1. 3
+the first port that is ACTIVE.
+.IP 2. 3
+if not found, the first port that is UP (physical link up).
+.UNINDENT
+.sp
+If a port and/or CA name is specified, the libibumad library attempts
+to fulfill the user request, and will fail if it is not possible.
+.sp
+For example:
+.INDENT 0.0
+.INDENT 3.5
+.sp
+.nf
+.ft C
+ibaddr # use the first port (criteria #1 above)
+ibaddr \-C mthca1 # pick the best port from "mthca1" only.
+ibaddr \-P 2 # use the second (active/up) port from the first available IB device.
+ibaddr \-C mthca0 \-P 2 # use the specified port only.
+.ft P
+.fi
+.UNINDENT
+.UNINDENT
+.UNINDENT
+.UNINDENT
+.SH FILES
+.\" Common text for the config file
+.
+.SS CONFIG FILE
+.sp
+/etc/infiniband-diags/ibdiag.conf
+.sp
+A global config file is provided to set some of the common options for all
+tools. See supplied config file for details.
+.\" Common text to describe the node name map file.
+.
+.SS NODE NAME MAP FILE FORMAT
+.sp
+The node name map is used to specify user friendly names for nodes in the
+output. GUIDs are used to perform the lookup.
+.sp
+This functionality is provided by the opensm\-libs package. See \fBopensm(8)\fP
+for the file location for your installation.
+.sp
+\fBGenerically:\fP
+.INDENT 0.0
+.INDENT 3.5
+.sp
+.nf
+.ft C
+# comment
+<guid> "<name>"
+.ft P
+.fi
+.UNINDENT
+.UNINDENT
+.sp
+\fBExample:\fP
+.INDENT 0.0
+.INDENT 3.5
+.sp
+.nf
+.ft C
+# IB1
+# Line cards
+0x0008f104003f125c "IB1 (Rack 11 slot 1 ) ISR9288/ISR9096 Voltaire sLB\-24D"
+0x0008f104003f125d "IB1 (Rack 11 slot 1 ) ISR9288/ISR9096 Voltaire sLB\-24D"
+0x0008f104003f10d2 "IB1 (Rack 11 slot 2 ) ISR9288/ISR9096 Voltaire sLB\-24D"
+0x0008f104003f10d3 "IB1 (Rack 11 slot 2 ) ISR9288/ISR9096 Voltaire sLB\-24D"
+0x0008f104003f10bf "IB1 (Rack 11 slot 12 ) ISR9288/ISR9096 Voltaire sLB\-24D"
+
+# Spines
+0x0008f10400400e2d "IB1 (Rack 11 spine 1 ) ISR9288 Voltaire sFB\-12D"
+0x0008f10400400e2e "IB1 (Rack 11 spine 1 ) ISR9288 Voltaire sFB\-12D"
+0x0008f10400400e2f "IB1 (Rack 11 spine 1 ) ISR9288 Voltaire sFB\-12D"
+0x0008f10400400e31 "IB1 (Rack 11 spine 2 ) ISR9288 Voltaire sFB\-12D"
+0x0008f10400400e32 "IB1 (Rack 11 spine 2 ) ISR9288 Voltaire sFB\-12D"
+
+# GUID Node Name
+0x0008f10400411a08 "SW1 (Rack 3) ISR9024 Voltaire 9024D"
+0x0008f10400411a28 "SW2 (Rack 3) ISR9024 Voltaire 9024D"
+0x0008f10400411a34 "SW3 (Rack 3) ISR9024 Voltaire 9024D"
+0x0008f104004119d0 "SW4 (Rack 3) ISR9024 Voltaire 9024D"
+.ft P
+.fi
+.UNINDENT
+.UNINDENT
+.SH SEE ALSO
+.sp
+ibnetdiscover(8)
+.SH DEPENDENCIES
+.sp
+ibnetdiscover, ibnetdiscover format
+.SH AUTHOR
+.INDENT 0.0
+.TP
+.B Hal Rosenstock
+< \fI\%halr@voltaire.com\fP >
+.UNINDENT
+.\" Generated by docutils manpage writer.
+.
diff --git a/contrib/ofed/infiniband-diags/man/ibstat.8 b/contrib/ofed/infiniband-diags/man/ibstat.8
new file mode 100644
index 0000000..4ce3cc8
--- /dev/null
+++ b/contrib/ofed/infiniband-diags/man/ibstat.8
@@ -0,0 +1,118 @@
+.\" Man page generated from reStructuredText.
+.
+.TH IBSTAT 8 "" "" "Open IB Diagnostics"
+.SH NAME
+IBSTAT \-
+.
+.nr rst2man-indent-level 0
+.
+.de1 rstReportMargin
+\\$1 \\n[an-margin]
+level \\n[rst2man-indent-level]
+level margin: \\n[rst2man-indent\\n[rst2man-indent-level]]
+-
+\\n[rst2man-indent0]
+\\n[rst2man-indent1]
+\\n[rst2man-indent2]
+..
+.de1 INDENT
+.\" .rstReportMargin pre:
+. RS \\$1
+. nr rst2man-indent\\n[rst2man-indent-level] \\n[an-margin]
+. nr rst2man-indent-level +1
+.\" .rstReportMargin post:
+..
+.de UNINDENT
+. RE
+.\" indent \\n[an-margin]
+.\" old: \\n[rst2man-indent\\n[rst2man-indent-level]]
+.nr rst2man-indent-level -1
+.\" new: \\n[rst2man-indent\\n[rst2man-indent-level]]
+.in \\n[rst2man-indent\\n[rst2man-indent-level]]u
+..
+.SH QUERY BASIC STATUS OF INFINIBAND DEVICE(S)
+.SS SYNOPSIS
+.sp
+ibstat [options] <ca_name> [portnum]
+.SS DESCRIPTION
+.sp
+ibstat is a binary which displays basic information obtained from the local
+IB driver. Output includes LID, SMLID, port state, link width active, and port
+physical state.
+.sp
+It is similar to the ibstatus utility but implemented as a binary rather
+than a script. It has options to list CAs and/or ports and displays more
+information than ibstatus.
+.SS OPTIONS
+.INDENT 0.0
+.TP
+.B \fB\-l, \-\-list_of_cas\fP
+list all IB devices
+.TP
+.B \fB\-s, \-\-short\fP
+short output
+.TP
+.B \fB\-p, \-\-port_list\fP
+show port list
+.TP
+.B \fBca_name\fP
+InfiniBand device name
+.TP
+.B \fBportnum\fP
+port number of InfiniBand device
+.UNINDENT
+.SS Debugging flags
+.\" Define the common option -d
+.
+.INDENT 0.0
+.TP
+.B \-d
+raise the IB debugging level.
+May be used several times (\-ddd or \-d \-d \-d).
+.UNINDENT
+.\" Define the common option -h
+.
+.sp
+\fB\-h, \-\-help\fP show the usage message
+.\" Define the common option -v
+.
+.INDENT 0.0
+.TP
+.B \fB\-v, \-\-verbose\fP
+increase the application verbosity level.
+May be used several times (\-vv or \-v \-v \-v)
+.UNINDENT
+.\" Define the common option -V
+.
+.sp
+\fB\-V, \-\-version\fP show the version info.
+.SS Configuration flags
+.\" Define the common option -z
+.
+.sp
+\fB\-\-config, \-z <config_file>\fP Specify alternate config file.
+.INDENT 0.0
+.INDENT 3.5
+Default: /etc/infiniband-diags/ibdiag.conf
+.UNINDENT
+.UNINDENT
+.SS EXAMPLES
+.INDENT 0.0
+.TP
+.B ::
+ibstat # display status of all ports on all IB devices
+ibstat \-l # list all IB devices
+ibstat \-p # show port guids
+ibstat mthca0 2 # show status of port 2 of \(aqmthca0\(aq
+.UNINDENT
+.SS SEE ALSO
+.sp
+ibstatus (8)
+.SS AUTHOR
+.INDENT 0.0
+.TP
+.B Hal Rosenstock
+< \fI\%halr@voltaire.com\fP >
+.UNINDENT
+.\" Generated by docutils manpage writer.
+.
diff --git a/contrib/ofed/infiniband-diags/man/ibstatus.8 b/contrib/ofed/infiniband-diags/man/ibstatus.8
new file mode 100644
index 0000000..dcfd269
--- /dev/null
+++ b/contrib/ofed/infiniband-diags/man/ibstatus.8
@@ -0,0 +1,73 @@
+.\" Man page generated from reStructuredText.
+.
+.TH IBSTATUS 8 "" "" "Open IB Diagnostics"
+.SH NAME
+IBSTATUS \-
+.
+.nr rst2man-indent-level 0
+.
+.de1 rstReportMargin
+\\$1 \\n[an-margin]
+level \\n[rst2man-indent-level]
+level margin: \\n[rst2man-indent\\n[rst2man-indent-level]]
+-
+\\n[rst2man-indent0]
+\\n[rst2man-indent1]
+\\n[rst2man-indent2]
+..
+.de1 INDENT
+.\" .rstReportMargin pre:
+. RS \\$1
+. nr rst2man-indent\\n[rst2man-indent-level] \\n[an-margin]
+. nr rst2man-indent-level +1
+.\" .rstReportMargin post:
+..
+.de UNINDENT
+. RE
+.\" indent \\n[an-margin]
+.\" old: \\n[rst2man-indent\\n[rst2man-indent-level]]
+.nr rst2man-indent-level -1
+.\" new: \\n[rst2man-indent\\n[rst2man-indent-level]]
+.in \\n[rst2man-indent\\n[rst2man-indent-level]]u
+..
+.SH QUERY BASIC STATUS OF INFINIBAND DEVICE(S)
+.SS SYNOPSIS
+.sp
+ibstatus [\-h] [devname[:port]]...
+.SS DESCRIPTION
+.sp
+ibstatus is a script which displays basic information obtained from the local
+IB driver. Output includes LID, SMLID, port state, link width active, and port
+physical state.
+.SS OPTIONS
+.\" Define the common option -h
+.
+.sp
+\fB\-h, \-\-help\fP show the usage message
+.INDENT 0.0
+.TP
+.B \fBdevname\fP
+InfiniBand device name
+.TP
+.B \fBportnum\fP
+port number of InfiniBand device
+.UNINDENT
+.SS EXAMPLES
+.INDENT 0.0
+.TP
+.B ::
+ibstatus # display status of all IB ports
+ibstatus mthca1 # status of mthca1 ports
+ibstatus mthca1:1 mthca0:2 # show status of specified ports
+.UNINDENT
+.SS SEE ALSO
+.sp
+\fBibstat (8)\fP
+.SS AUTHOR
+.INDENT 0.0
+.TP
+.B Hal Rosenstock
+< \fI\%halr@voltaire.com\fP >
+.UNINDENT
+.\" Generated by docutils manpage writer.
+.
diff --git a/contrib/ofed/infiniband-diags/man/ibswitches.8 b/contrib/ofed/infiniband-diags/man/ibswitches.8
new file mode 100644
index 0000000..39f3041
--- /dev/null
+++ b/contrib/ofed/infiniband-diags/man/ibswitches.8
@@ -0,0 +1,184 @@
+.\" Man page generated from reStructuredText.
+.
+.TH IBSWITCHES 8 "" "" "OpenIB Diagnostics"
+.SH NAME
+IBSWITCHES \- show InfiniBand switch nodes in topology
+.
+.nr rst2man-indent-level 0
+.
+.de1 rstReportMargin
+\\$1 \\n[an-margin]
+level \\n[rst2man-indent-level]
+level margin: \\n[rst2man-indent\\n[rst2man-indent-level]]
+-
+\\n[rst2man-indent0]
+\\n[rst2man-indent1]
+\\n[rst2man-indent2]
+..
+.de1 INDENT
+.\" .rstReportMargin pre:
+. RS \\$1
+. nr rst2man-indent\\n[rst2man-indent-level] \\n[an-margin]
+. nr rst2man-indent-level +1
+.\" .rstReportMargin post:
+..
+.de UNINDENT
+. RE
+.\" indent \\n[an-margin]
+.\" old: \\n[rst2man-indent\\n[rst2man-indent-level]]
+.nr rst2man-indent-level -1
+.\" new: \\n[rst2man-indent\\n[rst2man-indent-level]]
+.in \\n[rst2man-indent\\n[rst2man-indent-level]]u
+..
+.SH SYNOPSIS
+.sp
+ibswitches [options] [<topology\-file>]
+.SH DESCRIPTION
+.sp
+ibswitches is a script which either walks the IB subnet topology or uses an
+already saved topology file and extracts the switch nodes.
+.SH OPTIONS
+.\" Define the common option -C
+.
+.sp
+\fB\-C, \-\-Ca <ca_name>\fP use the specified ca_name.
+.\" Define the common option -P
+.
+.sp
+\fB\-P, \-\-Port <ca_port>\fP use the specified ca_port.
+.\" Define the common option -t
+.
+.sp
+\fB\-t, \-\-timeout <timeout_ms>\fP override the default timeout for the solicited mads.
+.\" Define the common option -y
+.
+.INDENT 0.0
+.TP
+.B \fB\-y, \-\-m_key <key>\fP
+use the specified M_key for requests. If non\-numeric value (like \(aqx\(aq)
+is specified then a value will be prompted for.
+.UNINDENT
+.\" Define the common option -h
+.
+.sp
+\fB\-h, \-\-help\fP show the usage message
+.\" Define the common option -z
+.
+.sp
+\fB\-\-config, \-z <config_file>\fP Specify alternate config file.
+.INDENT 0.0
+.INDENT 3.5
+Default: /etc/infiniband-diags/ibdiag.conf
+.UNINDENT
+.UNINDENT
+.\" Explanation of local port selection
+.
+.SS Local port Selection
+.sp
+Multiple port/Multiple CA support: when no IB device or port is specified
+(see the "local umad parameters" below), the libibumad library
+selects the port to use by the following criteria:
+.INDENT 0.0
+.INDENT 3.5
+.INDENT 0.0
+.IP 1. 3
+the first port that is ACTIVE.
+.IP 2. 3
+if not found, the first port that is UP (physical link up).
+.UNINDENT
+.sp
+If a port and/or CA name is specified, the libibumad library attempts
+to fulfill the user request, and will fail if it is not possible.
+.sp
+For example:
+.INDENT 0.0
+.INDENT 3.5
+.sp
+.nf
+.ft C
+ibaddr # use the first port (criteria #1 above)
+ibaddr \-C mthca1 # pick the best port from "mthca1" only.
+ibaddr \-P 2 # use the second (active/up) port from the first available IB device.
+ibaddr \-C mthca0 \-P 2 # use the specified port only.
+.ft P
+.fi
+.UNINDENT
+.UNINDENT
+.UNINDENT
+.UNINDENT
+.SH FILES
+.\" Common text for the config file
+.
+.SS CONFIG FILE
+.sp
+/etc/infiniband-diags/ibdiag.conf
+.sp
+A global config file is provided to set some of the common options for all
+tools. See supplied config file for details.
+.\" Common text to describe the node name map file.
+.
+.SS NODE NAME MAP FILE FORMAT
+.sp
+The node name map is used to specify user friendly names for nodes in the
+output. GUIDs are used to perform the lookup.
+.sp
+This functionality is provided by the opensm\-libs package. See \fBopensm(8)\fP
+for the file location for your installation.
+.sp
+\fBGenerically:\fP
+.INDENT 0.0
+.INDENT 3.5
+.sp
+.nf
+.ft C
+# comment
+<guid> "<name>"
+.ft P
+.fi
+.UNINDENT
+.UNINDENT
+.sp
+\fBExample:\fP
+.INDENT 0.0
+.INDENT 3.5
+.sp
+.nf
+.ft C
+# IB1
+# Line cards
+0x0008f104003f125c "IB1 (Rack 11 slot 1 ) ISR9288/ISR9096 Voltaire sLB\-24D"
+0x0008f104003f125d "IB1 (Rack 11 slot 1 ) ISR9288/ISR9096 Voltaire sLB\-24D"
+0x0008f104003f10d2 "IB1 (Rack 11 slot 2 ) ISR9288/ISR9096 Voltaire sLB\-24D"
+0x0008f104003f10d3 "IB1 (Rack 11 slot 2 ) ISR9288/ISR9096 Voltaire sLB\-24D"
+0x0008f104003f10bf "IB1 (Rack 11 slot 12 ) ISR9288/ISR9096 Voltaire sLB\-24D"
+
+# Spines
+0x0008f10400400e2d "IB1 (Rack 11 spine 1 ) ISR9288 Voltaire sFB\-12D"
+0x0008f10400400e2e "IB1 (Rack 11 spine 1 ) ISR9288 Voltaire sFB\-12D"
+0x0008f10400400e2f "IB1 (Rack 11 spine 1 ) ISR9288 Voltaire sFB\-12D"
+0x0008f10400400e31 "IB1 (Rack 11 spine 2 ) ISR9288 Voltaire sFB\-12D"
+0x0008f10400400e32 "IB1 (Rack 11 spine 2 ) ISR9288 Voltaire sFB\-12D"
+
+# GUID Node Name
+0x0008f10400411a08 "SW1 (Rack 3) ISR9024 Voltaire 9024D"
+0x0008f10400411a28 "SW2 (Rack 3) ISR9024 Voltaire 9024D"
+0x0008f10400411a34 "SW3 (Rack 3) ISR9024 Voltaire 9024D"
+0x0008f104004119d0 "SW4 (Rack 3) ISR9024 Voltaire 9024D"
+.ft P
+.fi
+.UNINDENT
+.UNINDENT
+.SH SEE ALSO
+.sp
+ibnetdiscover(8)
+.SH DEPENDENCIES
+.sp
+ibnetdiscover, ibnetdiscover format
+.SH AUTHOR
+.INDENT 0.0
+.TP
+.B Hal Rosenstock
+< \fI\%halr@voltaire.com\fP >
+.UNINDENT
+.\" Generated by docutils manpage writer.
+.
diff --git a/contrib/ofed/infiniband-diags/man/ibsysstat.8 b/contrib/ofed/infiniband-diags/man/ibsysstat.8
new file mode 100644
index 0000000..126be4e
--- /dev/null
+++ b/contrib/ofed/infiniband-diags/man/ibsysstat.8
@@ -0,0 +1,188 @@
+.\" Man page generated from reStructuredText.
+.
+.TH IBSYSSTAT 8 "" "" "Open IB Diagnostics"
+.SH NAME
+IBSYSSTAT \-
+.
+.nr rst2man-indent-level 0
+.
+.de1 rstReportMargin
+\\$1 \\n[an-margin]
+level \\n[rst2man-indent-level]
+level margin: \\n[rst2man-indent\\n[rst2man-indent-level]]
+-
+\\n[rst2man-indent0]
+\\n[rst2man-indent1]
+\\n[rst2man-indent2]
+..
+.de1 INDENT
+.\" .rstReportMargin pre:
+. RS \\$1
+. nr rst2man-indent\\n[rst2man-indent-level] \\n[an-margin]
+. nr rst2man-indent-level +1
+.\" .rstReportMargin post:
+..
+.de UNINDENT
+. RE
+.\" indent \\n[an-margin]
+.\" old: \\n[rst2man-indent\\n[rst2man-indent-level]]
+.nr rst2man-indent-level -1
+.\" new: \\n[rst2man-indent\\n[rst2man-indent-level]]
+.in \\n[rst2man-indent\\n[rst2man-indent-level]]u
+..
+.SH SYSTEM STATUS ON AN INFINIBAND ADDRESS
+.SS SYNOPSIS
+.sp
+ibsysstat [options] <dest lid | guid> [<op>]
+.SS DESCRIPTION
+.sp
+ibsysstat uses vendor mads to validate connectivity between IB nodes
+and obtain other information about the IB node. ibsysstat is run as
+client/server. Default is to run as client.
+.SS OPTIONS
+.sp
+Current supported operations:
+.INDENT 0.0
+.INDENT 3.5
+.sp
+.nf
+.ft C
+ping \e\- verify connectivity to server (default)
+host \e\- obtain host information from server
+cpu \e\- obtain cpu information from server
+.ft P
+.fi
+.UNINDENT
+.UNINDENT
+.INDENT 0.0
+.TP
+.B \fB\-o, \-\-oui\fP
+use specified OUI number to multiplex vendor mads
+.TP
+.B \fB\-S, \-\-Server\fP
+start in server mode (do not return)
+.TP
+.B .sp
+\fB\-\-dgid <gid>\fP
+destination GID: use when GRH is required in packets (IPv6 format)
+.UNINDENT
+.SS Addressing Flags
+.\" Define the common option -G
+.
+.sp
+\fB\-G, \-\-Guid\fP The address specified is a Port GUID
+.\" Define the common option -L
+.
+.sp
+\fB\-L, \-\-Lid\fP The address specified is a LID
+.\" Define the common option -s
+.
+.sp
+\fB\-s, \-\-sm_port <smlid>\fP use \(aqsmlid\(aq as the target lid for SA queries.
+.SS Port Selection flags
+.\" Define the common option -C
+.
+.sp
+\fB\-C, \-\-Ca <ca_name>\fP use the specified ca_name.
+.\" Define the common option -P
+.
+.sp
+\fB\-P, \-\-Port <ca_port>\fP use the specified ca_port.
+.\" Explanation of local port selection
+.
+.SS Local port Selection
+.sp
+Multiple port/Multiple CA support: when no IB device or port is specified
+(see the "local umad parameters" below), the libibumad library
+selects the port to use by the following criteria:
+.INDENT 0.0
+.INDENT 3.5
+.INDENT 0.0
+.IP 1. 3
+the first port that is ACTIVE.
+.IP 2. 3
+if not found, the first port that is UP (physical link up).
+.UNINDENT
+.sp
+If a port and/or CA name is specified, the libibumad library attempts
+to fulfill the user request, and will fail if it is not possible.
+.sp
+For example:
+.INDENT 0.0
+.INDENT 3.5
+.sp
+.nf
+.ft C
+ibaddr # use the first port (criteria #1 above)
+ibaddr \-C mthca1 # pick the best port from "mthca1" only.
+ibaddr \-P 2 # use the second (active/up) port from the first available IB device.
+ibaddr \-C mthca0 \-P 2 # use the specified port only.
+.ft P
+.fi
+.UNINDENT
+.UNINDENT
+.UNINDENT
+.UNINDENT
+.SS Debugging flags
+.\" Define the common option -d
+.
+.INDENT 0.0
+.TP
+.B \-d
+raise the IB debugging level.
+May be used several times (\-ddd or \-d \-d \-d).
+.UNINDENT
+.\" Define the common option -e
+.
+.INDENT 0.0
+.TP
+.B \-e
+show send and receive errors (timeouts and others)
+.UNINDENT
+.\" Define the common option -h
+.
+.sp
+\fB\-h, \-\-help\fP show the usage message
+.\" Define the common option -v
+.
+.INDENT 0.0
+.TP
+.B \fB\-v, \-\-verbose\fP
+increase the application verbosity level.
+May be used several times (\-vv or \-v \-v \-v)
+.UNINDENT
+.\" Define the common option -V
+.
+.sp
+\fB\-V, \-\-version\fP show the version info.
+.SS Configuration flags
+.\" Define the common option -t
+.
+.sp
+\fB\-t, \-\-timeout <timeout_ms>\fP override the default timeout for the solicited mads.
+.\" Define the common option -z
+.
+.sp
+\fB\-\-config, \-z <config_file>\fP Specify alternate config file.
+.INDENT 0.0
+.INDENT 3.5
+Default: /etc/infiniband-diags/ibdiag.conf
+.UNINDENT
+.UNINDENT
+.SS FILES
+.\" Common text for the config file
+.
+.SS CONFIG FILE
+.sp
+/etc/infiniband-diags/ibdiag.conf
+.sp
+A global config file is provided to set some of the common options for all
+tools. See supplied config file for details.
+.SS AUTHOR
+.INDENT 0.0
+.TP
+.B Hal Rosenstock
+< \fI\%halr@voltaire.com\fP >
+.UNINDENT
+.\" Generated by docutils manpage writer.
+.
diff --git a/contrib/ofed/infiniband-diags/man/ibtracert.8 b/contrib/ofed/infiniband-diags/man/ibtracert.8
new file mode 100644
index 0000000..21ad340
--- /dev/null
+++ b/contrib/ofed/infiniband-diags/man/ibtracert.8
@@ -0,0 +1,268 @@
+.\" Man page generated from reStructuredText.
+.
+.TH IBTRACERT 8 "" "" "Open IB Diagnostics"
+.SH NAME
+IBTRACERT \-
+.
+.nr rst2man-indent-level 0
+.
+.de1 rstReportMargin
+\\$1 \\n[an-margin]
+level \\n[rst2man-indent-level]
+level margin: \\n[rst2man-indent\\n[rst2man-indent-level]]
+-
+\\n[rst2man-indent0]
+\\n[rst2man-indent1]
+\\n[rst2man-indent2]
+..
+.de1 INDENT
+.\" .rstReportMargin pre:
+. RS \\$1
+. nr rst2man-indent\\n[rst2man-indent-level] \\n[an-margin]
+. nr rst2man-indent-level +1
+.\" .rstReportMargin post:
+..
+.de UNINDENT
+. RE
+.\" indent \\n[an-margin]
+.\" old: \\n[rst2man-indent\\n[rst2man-indent-level]]
+.nr rst2man-indent-level -1
+.\" new: \\n[rst2man-indent\\n[rst2man-indent-level]]
+.in \\n[rst2man-indent\\n[rst2man-indent-level]]u
+..
+.SH TRACE INFINIBAND PATH
+.SS SYNOPSIS
+.sp
+ibtracert [options] [<lid|guid> [<startlid> [<endlid>]]]
+.SS DESCRIPTION
+.sp
+ibtracert uses SMPs to trace the path from a source GID/LID to a
+destination GID/LID. Each hop along the path is displayed until
+the destination is reached or a hop does not respond. By using
+the \-m option, multicast path tracing can be performed between source
+and destination nodes.
+.SS OPTIONS
+.INDENT 0.0
+.TP
+.B \fB\-n, \-\-no_info\fP
+simple format; don\(aqt show additional information
+.TP
+.B \fB\-m\fP
+show the multicast trace of the specified mlid
+.TP
+.B \fB\-f, \-\-force\fP
+force route to destination port
+.UNINDENT
+.SS Addressing Flags
+.\" Define the common option -G
+.
+.sp
+\fB\-G, \-\-Guid\fP The address specified is a Port GUID
+.\" Define the common option -L
+.
+.sp
+\fB\-L, \-\-Lid\fP The address specified is a LID
+.\" Define the common option -s
+.
+.sp
+\fB\-s, \-\-sm_port <smlid>\fP use \(aqsmlid\(aq as the target lid for SA queries.
+.SS Port Selection flags
+.\" Define the common option -C
+.
+.sp
+\fB\-C, \-\-Ca <ca_name>\fP use the specified ca_name.
+.\" Define the common option -P
+.
+.sp
+\fB\-P, \-\-Port <ca_port>\fP use the specified ca_port.
+.\" Explanation of local port selection
+.
+.SS Local port Selection
+.sp
+Multiple port/Multiple CA support: when no IB device or port is specified
+(see the "local umad parameters" below), the libibumad library
+selects the port to use by the following criteria:
+.INDENT 0.0
+.INDENT 3.5
+.INDENT 0.0
+.IP 1. 3
+the first port that is ACTIVE.
+.IP 2. 3
+if not found, the first port that is UP (physical link up).
+.UNINDENT
+.sp
+If a port and/or CA name is specified, the libibumad library attempts
+to fulfill the user request, and will fail if it is not possible.
+.sp
+For example:
+.INDENT 0.0
+.INDENT 3.5
+.sp
+.nf
+.ft C
+ibaddr # use the first port (criteria #1 above)
+ibaddr \-C mthca1 # pick the best port from "mthca1" only.
+ibaddr \-P 2 # use the second (active/up) port from the first available IB device.
+ibaddr \-C mthca0 \-P 2 # use the specified port only.
+.ft P
+.fi
+.UNINDENT
+.UNINDENT
+.UNINDENT
+.UNINDENT
+.SS Debugging flags
+.\" Define the common option -d
+.
+.INDENT 0.0
+.TP
+.B \-d
+raise the IB debugging level.
+May be used several times (\-ddd or \-d \-d \-d).
+.UNINDENT
+.\" Define the common option -e
+.
+.INDENT 0.0
+.TP
+.B \-e
+show send and receive errors (timeouts and others)
+.UNINDENT
+.\" Define the common option -h
+.
+.sp
+\fB\-h, \-\-help\fP show the usage message
+.\" Define the common option -v
+.
+.INDENT 0.0
+.TP
+.B \fB\-v, \-\-verbose\fP
+increase the application verbosity level.
+May be used several times (\-vv or \-v \-v \-v)
+.UNINDENT
+.\" Define the common option -V
+.
+.sp
+\fB\-V, \-\-version\fP show the version info.
+.SS Configuration flags
+.\" Define the common option -t
+.
+.sp
+\fB\-t, \-\-timeout <timeout_ms>\fP override the default timeout for the solicited mads.
+.\" Define the common option --node-name-map
+.
+.sp
+\fB\-\-node\-name\-map <node\-name\-map>\fP Specify a node name map.
+.INDENT 0.0
+.INDENT 3.5
+This file maps GUIDs to more user friendly names. See FILES section.
+.UNINDENT
+.UNINDENT
+.\" Define the common option -y
+.
+.INDENT 0.0
+.TP
+.B \fB\-y, \-\-m_key <key>\fP
+use the specified M_key for requests. If non\-numeric value (like \(aqx\(aq)
+is specified then a value will be prompted for.
+.UNINDENT
+.\" Define the common option -z
+.
+.sp
+\fB\-\-config, \-z <config_file>\fP Specify alternate config file.
+.INDENT 0.0
+.INDENT 3.5
+Default: /etc/infiniband-diags/ibdiag.conf
+.UNINDENT
+.UNINDENT
+.SS FILES
+.\" Common text for the config file
+.
+.SS CONFIG FILE
+.sp
+/etc/infiniband-diags/ibdiag.conf
+.sp
+A global config file is provided to set some of the common options for all
+tools. See supplied config file for details.
+.\" Common text to describe the node name map file.
+.
+.SS NODE NAME MAP FILE FORMAT
+.sp
+The node name map is used to specify user friendly names for nodes in the
+output. GUIDs are used to perform the lookup.
+.sp
+This functionality is provided by the opensm\-libs package. See \fBopensm(8)\fP
+for the file location for your installation.
+.sp
+\fBGenerically:\fP
+.INDENT 0.0
+.INDENT 3.5
+.sp
+.nf
+.ft C
+# comment
+<guid> "<name>"
+.ft P
+.fi
+.UNINDENT
+.UNINDENT
+.sp
+\fBExample:\fP
+.INDENT 0.0
+.INDENT 3.5
+.sp
+.nf
+.ft C
+# IB1
+# Line cards
+0x0008f104003f125c "IB1 (Rack 11 slot 1 ) ISR9288/ISR9096 Voltaire sLB\-24D"
+0x0008f104003f125d "IB1 (Rack 11 slot 1 ) ISR9288/ISR9096 Voltaire sLB\-24D"
+0x0008f104003f10d2 "IB1 (Rack 11 slot 2 ) ISR9288/ISR9096 Voltaire sLB\-24D"
+0x0008f104003f10d3 "IB1 (Rack 11 slot 2 ) ISR9288/ISR9096 Voltaire sLB\-24D"
+0x0008f104003f10bf "IB1 (Rack 11 slot 12 ) ISR9288/ISR9096 Voltaire sLB\-24D"
+
+# Spines
+0x0008f10400400e2d "IB1 (Rack 11 spine 1 ) ISR9288 Voltaire sFB\-12D"
+0x0008f10400400e2e "IB1 (Rack 11 spine 1 ) ISR9288 Voltaire sFB\-12D"
+0x0008f10400400e2f "IB1 (Rack 11 spine 1 ) ISR9288 Voltaire sFB\-12D"
+0x0008f10400400e31 "IB1 (Rack 11 spine 2 ) ISR9288 Voltaire sFB\-12D"
+0x0008f10400400e32 "IB1 (Rack 11 spine 2 ) ISR9288 Voltaire sFB\-12D"
+
+# GUID Node Name
+0x0008f10400411a08 "SW1 (Rack 3) ISR9024 Voltaire 9024D"
+0x0008f10400411a28 "SW2 (Rack 3) ISR9024 Voltaire 9024D"
+0x0008f10400411a34 "SW3 (Rack 3) ISR9024 Voltaire 9024D"
+0x0008f104004119d0 "SW4 (Rack 3) ISR9024 Voltaire 9024D"
+.ft P
+.fi
+.UNINDENT
+.UNINDENT
+.SS EXAMPLES
+.sp
+Unicast examples
+.INDENT 0.0
+.TP
+.B ::
+ibtracert 4 16 # show path between lids 4 and 16
+ibtracert \-n 4 16 # same, but using simple output format
+ibtracert \-G 0x8f1040396522d 0x002c9000100d051 # use guid addresses
+.UNINDENT
+.sp
+Multicast example
+.INDENT 0.0
+.TP
+.B ::
+ibtracert \-m 0xc000 4 16 # show multicast path of mlid 0xc000 between lids 4 and 16
+.UNINDENT
+.SS SEE ALSO
+.sp
+ibroute (8)
+.SS AUTHOR
+.INDENT 0.0
+.TP
+.B Hal Rosenstock
+<\fI\%hal.rosenstock@gmail.com\fP>
+.TP
+.B Ira Weiny
+< \fI\%ira.weiny@intel.com\fP >
+.UNINDENT
+.\" Generated by docutils manpage writer.
+.
diff --git a/contrib/ofed/infiniband-diags/man/infiniband-diags.8 b/contrib/ofed/infiniband-diags/man/infiniband-diags.8
new file mode 100644
index 0000000..d2d95c6
--- /dev/null
+++ b/contrib/ofed/infiniband-diags/man/infiniband-diags.8
@@ -0,0 +1,452 @@
+.\" Man page generated from reStructuredText.
+.
+.TH INFINIBAND-DIAGS 8 "" "" "Open IB Diagnostics"
+.SH NAME
+INFINIBAND-DIAGS \-
+.
+.nr rst2man-indent-level 0
+.
+.de1 rstReportMargin
+\\$1 \\n[an-margin]
+level \\n[rst2man-indent-level]
+level margin: \\n[rst2man-indent\\n[rst2man-indent-level]]
+-
+\\n[rst2man-indent0]
+\\n[rst2man-indent1]
+\\n[rst2man-indent2]
+..
+.de1 INDENT
+.\" .rstReportMargin pre:
+. RS \\$1
+. nr rst2man-indent\\n[rst2man-indent-level] \\n[an-margin]
+. nr rst2man-indent-level +1
+.\" .rstReportMargin post:
+..
+.de UNINDENT
+. RE
+.\" indent \\n[an-margin]
+.\" old: \\n[rst2man-indent\\n[rst2man-indent-level]]
+.nr rst2man-indent-level -1
+.\" new: \\n[rst2man-indent\\n[rst2man-indent-level]]
+.in \\n[rst2man-indent\\n[rst2man-indent-level]]u
+..
+.SH DIAGNOSTICS FOR INFINIBAND FABRICS
+.SS DESCRIPTION
+.sp
+infiniband\-diags is a set of utilities designed to help configure, debug, and
+maintain infiniband fabrics. Many tools and utilities are provided. Some with
+similar functionality.
+.sp
+The base utilities use directed route MAD\(aqs to perform their operations. They
+may therefore work even in unconfigured subnets. Other, higher level
+utilities, require LID routed MAD\(aqs and to some extent SA/SM access.
+.SS THE USE OF SMPs (QP0)
+.sp
+Many of the tools in this package rely on the use of SMPs via QP0 to acquire
+data directly from the SMA. While this mode of operation is not technically in
+compliance with the InfiniBand specification, practical experience has found
+that this level of diagnostics is valuable when working with a fabric which is
+broken or only partially configured. For this reason many of these tools may
+require the use of an MKey or operation from Virtual Machines may be restricted
+for security reasons.
+.SS COMMON OPTIONS
+.sp
+Most OpenIB diagnostics take some of the following common flags. The exact list
+of supported flags per utility can be found in the documentation for those
+commands.
+.SS Addressing Flags
+.sp
+The \-D and \-G option have two forms:
+.\" Define the common option -D for Directed routes
+.
+.sp
+\fB\-D, \-\-Direct\fP The address specified is a directed route
+.INDENT 0.0
+.INDENT 3.5
+.sp
+.nf
+.ft C
+Examples:
+ [options] \-D [options] "0" # self port
+ [options] \-D [options] "0,1,2,1,4" # out via port 1, then 2, ...
+
+ (Note the second number in the path specified must match the port being
+ used. This can be specified using the port selection flag \(aq\-P\(aq or the
+ port found through the automatic selection process.)
+.ft P
+.fi
+.UNINDENT
+.UNINDENT
+.\" Define the common option -D for Directed routes
+.
+.sp
+\fB\-D, \-\-Direct <dr_path>\fP The address specified is a directed route
+.INDENT 0.0
+.INDENT 3.5
+.sp
+.nf
+.ft C
+Examples:
+ \-D "0" # self port
+ \-D "0,1,2,1,4" # out via port 1, then 2, ...
+
+ (Note the second number in the path specified must match the port being
+ used. This can be specified using the port selection flag \(aq\-P\(aq or the
+ port found through the automatic selection process.)
+.ft P
+.fi
+.UNINDENT
+.UNINDENT
+.\" Define the common option -G
+.
+.sp
+\fB\-G, \-\-Guid\fP The address specified is a Port GUID
+.\" Define the common option -G
+.
+.sp
+\fB\-\-port\-guid, \-G <port_guid>\fP Specify a port_guid
+.\" Define the common option -L
+.
+.sp
+\fB\-L, \-\-Lid\fP The address specified is a LID
+.\" Define the common option -s
+.
+.sp
+\fB\-s, \-\-sm_port <smlid>\fP use \(aqsmlid\(aq as the target lid for SA queries.
+.SS Port Selection flags
+.\" Define the common option -C
+.
+.sp
+\fB\-C, \-\-Ca <ca_name>\fP use the specified ca_name.
+.\" Define the common option -P
+.
+.sp
+\fB\-P, \-\-Port <ca_port>\fP use the specified ca_port.
+.\" Explanation of local port selection
+.
+.SS Local port Selection
+.sp
+Multiple port/Multiple CA support: when no IB device or port is specified
+(see the "local umad parameters" below), the libibumad library
+selects the port to use by the following criteria:
+.INDENT 0.0
+.INDENT 3.5
+.INDENT 0.0
+.IP 1. 3
+the first port that is ACTIVE.
+.IP 2. 3
+if not found, the first port that is UP (physical link up).
+.UNINDENT
+.sp
+If a port and/or CA name is specified, the libibumad library attempts
+to fulfill the user request, and will fail if it is not possible.
+.sp
+For example:
+.INDENT 0.0
+.INDENT 3.5
+.sp
+.nf
+.ft C
+ibaddr # use the first port (criteria #1 above)
+ibaddr \-C mthca1 # pick the best port from "mthca1" only.
+ibaddr \-P 2 # use the second (active/up) port from the first available IB device.
+ibaddr \-C mthca0 \-P 2 # use the specified port only.
+.ft P
+.fi
+.UNINDENT
+.UNINDENT
+.UNINDENT
+.UNINDENT
+.SS Debugging flags
+.\" Define the common option -d
+.
+.INDENT 0.0
+.TP
+.B \-d
+raise the IB debugging level.
+May be used several times (\-ddd or \-d \-d \-d).
+.UNINDENT
+.\" Define the common option -e
+.
+.INDENT 0.0
+.TP
+.B \-e
+show send and receive errors (timeouts and others)
+.UNINDENT
+.\" Define the common option -h
+.
+.sp
+\fB\-h, \-\-help\fP show the usage message
+.\" Define the common option -v
+.
+.INDENT 0.0
+.TP
+.B \fB\-v, \-\-verbose\fP
+increase the application verbosity level.
+May be used several times (\-vv or \-v \-v \-v)
+.UNINDENT
+.\" Define the common option -V
+.
+.sp
+\fB\-V, \-\-version\fP show the version info.
+.SS Configuration flags
+.\" Define the common option -t
+.
+.sp
+\fB\-t, \-\-timeout <timeout_ms>\fP override the default timeout for the solicited mads.
+.\" Define the common option -z
+.
+.INDENT 0.0
+.TP
+.B \fB\-\-outstanding_smps, \-o <val>\fP
+Specify the number of outstanding SMP\(aqs which should be issued during the scan
+.sp
+Default: 2
+.UNINDENT
+.\" Define the common option --node-name-map
+.
+.sp
+\fB\-\-node\-name\-map <node\-name\-map>\fP Specify a node name map.
+.INDENT 0.0
+.INDENT 3.5
+This file maps GUIDs to more user friendly names. See FILES section.
+.UNINDENT
+.UNINDENT
+.\" Define the common option -z
+.
+.sp
+\fB\-\-config, \-z <config_file>\fP Specify alternate config file.
+.INDENT 0.0
+.INDENT 3.5
+Default: /etc/infiniband-diags/ibdiag.conf
+.UNINDENT
+.UNINDENT
+.SS COMMON FILES
+.sp
+The following config files are common amongst many of the utilities.
+.\" Common text for the config file
+.
+.SS CONFIG FILE
+.sp
+/etc/infiniband-diags/ibdiag.conf
+.sp
+A global config file is provided to set some of the common options for all
+tools. See supplied config file for details.
+.\" Common text to describe the node name map file.
+.
+.SS NODE NAME MAP FILE FORMAT
+.sp
+The node name map is used to specify user friendly names for nodes in the
+output. GUIDs are used to perform the lookup.
+.sp
+This functionality is provided by the opensm\-libs package. See \fBopensm(8)\fP
+for the file location for your installation.
+.sp
+\fBGenerically:\fP
+.INDENT 0.0
+.INDENT 3.5
+.sp
+.nf
+.ft C
+# comment
+<guid> "<name>"
+.ft P
+.fi
+.UNINDENT
+.UNINDENT
+.sp
+\fBExample:\fP
+.INDENT 0.0
+.INDENT 3.5
+.sp
+.nf
+.ft C
+# IB1
+# Line cards
+0x0008f104003f125c "IB1 (Rack 11 slot 1 ) ISR9288/ISR9096 Voltaire sLB\-24D"
+0x0008f104003f125d "IB1 (Rack 11 slot 1 ) ISR9288/ISR9096 Voltaire sLB\-24D"
+0x0008f104003f10d2 "IB1 (Rack 11 slot 2 ) ISR9288/ISR9096 Voltaire sLB\-24D"
+0x0008f104003f10d3 "IB1 (Rack 11 slot 2 ) ISR9288/ISR9096 Voltaire sLB\-24D"
+0x0008f104003f10bf "IB1 (Rack 11 slot 12 ) ISR9288/ISR9096 Voltaire sLB\-24D"
+
+# Spines
+0x0008f10400400e2d "IB1 (Rack 11 spine 1 ) ISR9288 Voltaire sFB\-12D"
+0x0008f10400400e2e "IB1 (Rack 11 spine 1 ) ISR9288 Voltaire sFB\-12D"
+0x0008f10400400e2f "IB1 (Rack 11 spine 1 ) ISR9288 Voltaire sFB\-12D"
+0x0008f10400400e31 "IB1 (Rack 11 spine 2 ) ISR9288 Voltaire sFB\-12D"
+0x0008f10400400e32 "IB1 (Rack 11 spine 2 ) ISR9288 Voltaire sFB\-12D"
+
+# GUID Node Name
+0x0008f10400411a08 "SW1 (Rack 3) ISR9024 Voltaire 9024D"
+0x0008f10400411a28 "SW2 (Rack 3) ISR9024 Voltaire 9024D"
+0x0008f10400411a34 "SW3 (Rack 3) ISR9024 Voltaire 9024D"
+0x0008f104004119d0 "SW4 (Rack 3) ISR9024 Voltaire 9024D"
+.ft P
+.fi
+.UNINDENT
+.UNINDENT
+.\" Common text to describe the Topology file.
+.
+.SS TOPOLOGY FILE FORMAT
+.sp
+The topology file format is human readable and largely intuitive.
+Most identifiers are given textual names like vendor ID (vendid), device ID
+(device ID), GUIDs of various types (sysimgguid, caguid, switchguid, etc.).
+PortGUIDs are shown in parentheses (). For switches, this is shown on the
+switchguid line. For CA and router ports, it is shown on the connectivity
+lines. The IB node is identified followed by the number of ports and a quoted
+the node GUID. On the right of this line is a comment (#) followed by the
+NodeDescription in quotes. If the node is a switch, this line also contains
+whether switch port 0 is base or enhanced, and the LID and LMC of port 0.
+Subsequent lines pertaining to this node show the connectivity. On the
+left is the port number of the current node. On the right is the peer node
+(node at other end of link). It is identified in quotes with nodetype
+followed by \- followed by NodeGUID with the port number in square brackets.
+Further on the right is a comment (#). What follows the comment is
+dependent on the node type. If it it a switch node, it is followed by
+the NodeDescription in quotes and the LID of the peer node. If it is a
+CA or router node, it is followed by the local LID and LMC and then
+followed by the NodeDescription in quotes and the LID of the peer node.
+The active link width and speed are then appended to the end of this
+output line.
+.sp
+An example of this is:
+.INDENT 0.0
+.INDENT 3.5
+.sp
+.nf
+.ft C
+#
+# Topology file: generated on Tue Jun 5 14:15:10 2007
+#
+# Max of 3 hops discovered
+# Initiated from node 0008f10403960558 port 0008f10403960559
+
+Non\-Chassis Nodes
+
+vendid=0x8f1
+devid=0x5a06
+sysimgguid=0x5442ba00003000
+switchguid=0x5442ba00003080(5442ba00003080)
+Switch 24 "S\-005442ba00003080" # "ISR9024 Voltaire" base port 0 lid 6 lmc 0
+[22] "H\-0008f10403961354"[1](8f10403961355) # "MT23108 InfiniHost Mellanox Technologies" lid 4 4xSDR
+[10] "S\-0008f10400410015"[1] # "SW\-6IB4 Voltaire" lid 3 4xSDR
+[8] "H\-0008f10403960558"[2](8f1040396055a) # "MT23108 InfiniHost Mellanox Technologies" lid 14 4xSDR
+[6] "S\-0008f10400410015"[3] # "SW\-6IB4 Voltaire" lid 3 4xSDR
+[12] "H\-0008f10403960558"[1](8f10403960559) # "MT23108 InfiniHost Mellanox Technologies" lid 10 4xSDR
+
+vendid=0x8f1
+devid=0x5a05
+switchguid=0x8f10400410015(8f10400410015)
+Switch 8 "S\-0008f10400410015" # "SW\-6IB4 Voltaire" base port 0 lid 3 lmc 0
+[6] "H\-0008f10403960984"[1](8f10403960985) # "MT23108 InfiniHost Mellanox Technologies" lid 16 4xSDR
+[4] "H\-005442b100004900"[1](5442b100004901) # "MT23108 InfiniHost Mellanox Technologies" lid 12 4xSDR
+[1] "S\-005442ba00003080"[10] # "ISR9024 Voltaire" lid 6 1xSDR
+[3] "S\-005442ba00003080"[6] # "ISR9024 Voltaire" lid 6 4xSDR
+
+vendid=0x2c9
+devid=0x5a44
+caguid=0x8f10403960984
+Ca 2 "H\-0008f10403960984" # "MT23108 InfiniHost Mellanox Technologies"
+[1](8f10403960985) "S\-0008f10400410015"[6] # lid 16 lmc 1 "SW\-6IB4 Voltaire" lid 3 4xSDR
+
+vendid=0x2c9
+devid=0x5a44
+caguid=0x5442b100004900
+Ca 2 "H\-005442b100004900" # "MT23108 InfiniHost Mellanox Technologies"
+[1](5442b100004901) "S\-0008f10400410015"[4] # lid 12 lmc 1 "SW\-6IB4 Voltaire" lid 3 4xSDR
+
+vendid=0x2c9
+devid=0x5a44
+caguid=0x8f10403961354
+Ca 2 "H\-0008f10403961354" # "MT23108 InfiniHost Mellanox Technologies"
+[1](8f10403961355) "S\-005442ba00003080"[22] # lid 4 lmc 1 "ISR9024 Voltaire" lid 6 4xSDR
+
+vendid=0x2c9
+devid=0x5a44
+caguid=0x8f10403960558
+Ca 2 "H\-0008f10403960558" # "MT23108 InfiniHost Mellanox Technologies"
+[2](8f1040396055a) "S\-005442ba00003080"[8] # lid 14 lmc 1 "ISR9024 Voltaire" lid 6 4xSDR
+[1](8f10403960559) "S\-005442ba00003080"[12] # lid 10 lmc 1 "ISR9024 Voltaire" lid 6 1xSDR
+.ft P
+.fi
+.UNINDENT
+.UNINDENT
+.sp
+When grouping is used, IB nodes are organized into chassis which are
+numbered. Nodes which cannot be determined to be in a chassis are
+displayed as "Non\-Chassis Nodes". External ports are also shown on the
+connectivity lines.
+.SS Utilities list
+.SS Basic fabric conectivity
+.INDENT 0.0
+.INDENT 3.5
+See: ibnetdiscover, iblinkinfo
+.UNINDENT
+.UNINDENT
+.SS Node information
+.INDENT 0.0
+.INDENT 3.5
+See: ibnodes, ibswitches, ibhosts, ibrouters
+.UNINDENT
+.UNINDENT
+.SS Port information
+.INDENT 0.0
+.INDENT 3.5
+See: ibportstate, ibaddr
+.UNINDENT
+.UNINDENT
+.SS Switch Forwarding Table info
+.INDENT 0.0
+.INDENT 3.5
+See: ibtracert, ibroute, dump_lfts, dump_mfts, check_lft_balance, ibfindnodesusing
+.UNINDENT
+.UNINDENT
+.SS Peformance counters
+.INDENT 0.0
+.INDENT 3.5
+See: ibqueryerrors, perfquery
+.UNINDENT
+.UNINDENT
+.SS Local HCA info
+.INDENT 0.0
+.INDENT 3.5
+See: ibstat, ibstatus
+.UNINDENT
+.UNINDENT
+.SS Connectivity check
+.INDENT 0.0
+.INDENT 3.5
+See: ibping, ibsysstat
+.UNINDENT
+.UNINDENT
+.SS Low level query tools
+.INDENT 0.0
+.INDENT 3.5
+See: smpquery, smpdump, saquery, sminfo
+.UNINDENT
+.UNINDENT
+.SS Fabric verification tools
+.INDENT 0.0
+.INDENT 3.5
+See: ibidsverify
+.UNINDENT
+.UNINDENT
+.SS Backwards compatibility scripts
+.sp
+The following scripts have been identified as redundant and/or lower performing
+as compared to the above scripts. They are provided as legacy scripts when
+\-\-enable\-compat\-utils is specified at build time.
+.sp
+ibcheckerrors, ibclearcounters, ibclearerrors, ibdatacounters
+ibchecknet, ibchecknode, ibcheckport, ibcheckportstate,
+ibcheckportwidth, ibcheckstate, ibcheckwidth, ibswportwatch,
+ibprintca, ibprintrt, ibprintswitch, set_nodedesc.sh
+.SS AUTHORS
+.INDENT 0.0
+.TP
+.B Ira Weiny
+< \fI\%ira.weiny@intel.com\fP >
+.UNINDENT
+.\" Generated by docutils manpage writer.
+.
diff --git a/contrib/ofed/infiniband-diags/man/perfquery.8 b/contrib/ofed/infiniband-diags/man/perfquery.8
new file mode 100644
index 0000000..236ad73
--- /dev/null
+++ b/contrib/ofed/infiniband-diags/man/perfquery.8
@@ -0,0 +1,291 @@
+.\" Man page generated from reStructuredText.
+.
+.TH PERFQUERY 8 "" "" "Open IB Diagnostics"
+.SH NAME
+PERFQUERY \-
+.
+.nr rst2man-indent-level 0
+.
+.de1 rstReportMargin
+\\$1 \\n[an-margin]
+level \\n[rst2man-indent-level]
+level margin: \\n[rst2man-indent\\n[rst2man-indent-level]]
+-
+\\n[rst2man-indent0]
+\\n[rst2man-indent1]
+\\n[rst2man-indent2]
+..
+.de1 INDENT
+.\" .rstReportMargin pre:
+. RS \\$1
+. nr rst2man-indent\\n[rst2man-indent-level] \\n[an-margin]
+. nr rst2man-indent-level +1
+.\" .rstReportMargin post:
+..
+.de UNINDENT
+. RE
+.\" indent \\n[an-margin]
+.\" old: \\n[rst2man-indent\\n[rst2man-indent-level]]
+.nr rst2man-indent-level -1
+.\" new: \\n[rst2man-indent\\n[rst2man-indent-level]]
+.in \\n[rst2man-indent\\n[rst2man-indent-level]]u
+..
+.SH QUERY INFINIBAND PORT COUNTERS ON A SINGLE PORT
+.SS SYNOPSIS
+.sp
+perfquery [options] [<lid|guid> [[port(s)] [reset_mask]]]
+.SS DESCRIPTION
+.sp
+perfquery uses PerfMgt GMPs to obtain the PortCounters (basic performance and
+error counters), PortExtendedCounters, PortXmitDataSL, PortRcvDataSL,
+PortRcvErrorDetails, PortXmitDiscardDetails, PortExtendedSpeedsCounters, or
+PortSamplesControl from the PMA at the node/port specified. Optionally shows
+aggregated counters for all ports of node. Finally it can, reset after read,
+or just reset the counters.
+.sp
+Note: In PortCounters, PortCountersExtended, PortXmitDataSL, and PortRcvDataSL,
+components that represent Data (e.g. PortXmitData and PortRcvData) indicate
+octets divided by 4 rather than just octets.
+.sp
+Note: Inputting a port of 255 indicates an operation be performed on all ports.
+.sp
+Note: For PortCounters, ExtendedCounters, and resets, multiple ports can be
+specified by either a comma separated list or a port range. See examples below.
+.SS OPTIONS
+.INDENT 0.0
+.TP
+.B \fB\-x, \-\-extended\fP
+show extended port counters rather than (basic) port counters.
+Note that extended port counters attribute is optional.
+.TP
+.B \fB\-X, \-\-xmtsl\fP
+show transmit data SL counter. This is an optional counter for QoS.
+.TP
+.B \fB\-S, \-\-rcvsl\fP
+show receive data SL counter. This is an optional counter for QoS.
+.TP
+.B \fB\-D, \-\-xmtdisc\fP
+show transmit discard details. This is an optional counter.
+.TP
+.B \fB\-E, \-\-rcverr\fP
+show receive error details. This is an optional counter.
+.TP
+.B \fB\-D, \-\-xmtdisc\fP
+show transmit discard details. This is an optional counter.
+.TP
+.B \fB\-T, \-\-extended_speeds\fP
+show extended speeds port counters. This is an optional counter.
+.TP
+.B \fB\-\-oprcvcounters\fP
+show Rcv Counters per Op code. This is an optional counter.
+.TP
+.B \fB\-\-flowctlcounters\fP
+show flow control counters. This is an optional counter.
+.TP
+.B \fB\-\-vloppackets\fP
+show packets received per Op code per VL. This is an optional counter.
+.TP
+.B \fB\-\-vlopdata\fP
+show data received per Op code per VL. This is an optional counter.
+.TP
+.B \fB\-\-vlxmitflowctlerrors\fP
+show flow control update errors per VL. This is an optional counter.
+.TP
+.B \fB\-\-vlxmitcounters\fP
+show ticks waiting to transmit counters per VL. This is an optional counter.
+.TP
+.B \fB\-\-swportvlcong\fP
+show sw port VL congestion. This is an optional counter.
+.TP
+.B \fB\-\-rcvcc\fP
+show Rcv congestion control counters. This is an optional counter.
+.TP
+.B \fB\-\-slrcvfecn\fP
+show SL Rcv FECN counters. This is an optional counter.
+.TP
+.B \fB\-\-slrcvbecn\fP
+show SL Rcv BECN counters. This is an optional counter.
+.TP
+.B \fB\-\-xmitcc\fP
+show Xmit congestion control counters. This is an optional counter.
+.TP
+.B \fB\-\-vlxmittimecc\fP
+show VL Xmit Time congestion control counters. This is an optional counter.
+.TP
+.B \fB\-c, \-\-smplctl\fP
+show port samples control.
+.TP
+.B \fB\-a, \-\-all_ports\fP
+show aggregated counters for all ports of the destination lid, reset
+all counters for all ports, or if multiple ports are specified, aggregate
+the counters of the specified ports. If the destination lid does not support
+the AllPortSelect flag, all ports will be iterated through to emulate
+AllPortSelect behavior.
+.TP
+.B \fB\-l, \-\-loop_ports\fP
+If all ports are selected by the user (either through the \fB\-a\fP option
+or port 255) or multiple ports are specified iterate through each port rather
+than doing than aggregate operation.
+.TP
+.B \fB\-r, \-\-reset_after_read\fP
+reset counters after read
+.TP
+.B \fB\-R, \-\-Reset_only\fP
+only reset counters
+.TP
+.B \fB\-\-dgid <gid>\fP
+destination GID: use when GRH is required in packets (IPv6 format)
+.UNINDENT
+.SS Addressing Flags
+.\" Define the common option -G
+.
+.sp
+\fB\-G, \-\-Guid\fP The address specified is a Port GUID
+.\" Define the common option -L
+.
+.sp
+\fB\-L, \-\-Lid\fP The address specified is a LID
+.\" Define the common option -s
+.
+.sp
+\fB\-s, \-\-sm_port <smlid>\fP use \(aqsmlid\(aq as the target lid for SA queries.
+.SS Port Selection flags
+.\" Define the common option -C
+.
+.sp
+\fB\-C, \-\-Ca <ca_name>\fP use the specified ca_name.
+.\" Define the common option -P
+.
+.sp
+\fB\-P, \-\-Port <ca_port>\fP use the specified ca_port.
+.\" Explanation of local port selection
+.
+.SS Local port Selection
+.sp
+Multiple port/Multiple CA support: when no IB device or port is specified
+(see the "local umad parameters" below), the libibumad library
+selects the port to use by the following criteria:
+.INDENT 0.0
+.INDENT 3.5
+.INDENT 0.0
+.IP 1. 3
+the first port that is ACTIVE.
+.IP 2. 3
+if not found, the first port that is UP (physical link up).
+.UNINDENT
+.sp
+If a port and/or CA name is specified, the libibumad library attempts
+to fulfill the user request, and will fail if it is not possible.
+.sp
+For example:
+.INDENT 0.0
+.INDENT 3.5
+.sp
+.nf
+.ft C
+ibaddr # use the first port (criteria #1 above)
+ibaddr \-C mthca1 # pick the best port from "mthca1" only.
+ibaddr \-P 2 # use the second (active/up) port from the first available IB device.
+ibaddr \-C mthca0 \-P 2 # use the specified port only.
+.ft P
+.fi
+.UNINDENT
+.UNINDENT
+.UNINDENT
+.UNINDENT
+.SS Debugging flags
+.\" Define the common option -d
+.
+.INDENT 0.0
+.TP
+.B \-d
+raise the IB debugging level.
+May be used several times (\-ddd or \-d \-d \-d).
+.UNINDENT
+.\" Define the common option -e
+.
+.INDENT 0.0
+.TP
+.B \-e
+show send and receive errors (timeouts and others)
+.UNINDENT
+.\" Define the common option -h
+.
+.sp
+\fB\-h, \-\-help\fP show the usage message
+.\" Define the common option -v
+.
+.INDENT 0.0
+.TP
+.B \fB\-v, \-\-verbose\fP
+increase the application verbosity level.
+May be used several times (\-vv or \-v \-v \-v)
+.UNINDENT
+.\" Define the common option -V
+.
+.sp
+\fB\-V, \-\-version\fP show the version info.
+.SS Configuration flags
+.\" Define the common option -t
+.
+.sp
+\fB\-t, \-\-timeout <timeout_ms>\fP override the default timeout for the solicited mads.
+.\" Define the common option -y
+.
+.INDENT 0.0
+.TP
+.B \fB\-y, \-\-m_key <key>\fP
+use the specified M_key for requests. If non\-numeric value (like \(aqx\(aq)
+is specified then a value will be prompted for.
+.UNINDENT
+.\" Define the common option -z
+.
+.sp
+\fB\-\-config, \-z <config_file>\fP Specify alternate config file.
+.INDENT 0.0
+.INDENT 3.5
+Default: /etc/infiniband-diags/ibdiag.conf
+.UNINDENT
+.UNINDENT
+.SS FILES
+.\" Common text for the config file
+.
+.SS CONFIG FILE
+.sp
+/etc/infiniband-diags/ibdiag.conf
+.sp
+A global config file is provided to set some of the common options for all
+tools. See supplied config file for details.
+.SS EXAMPLES
+.INDENT 0.0
+.INDENT 3.5
+.sp
+.nf
+.ft C
+perfquery # read local port performance counters
+perfquery 32 1 # read performance counters from lid 32, port 1
+perfquery \-x 32 1 # read extended performance counters from lid 32, port 1
+perfquery \-a 32 # read perf counters from lid 32, all ports
+perfquery \-r 32 1 # read performance counters and reset
+perfquery \-x \-r 32 1 # read extended performance counters and reset
+perfquery \-R 0x20 1 # reset performance counters of port 1 only
+perfquery \-x \-R 0x20 1 # reset extended performance counters of port 1 only
+perfquery \-R \-a 32 # reset performance counters of all ports
+perfquery \-R 32 2 0x0fff # reset only error counters of port 2
+perfquery \-R 32 2 0xf000 # reset only non\-error counters of port 2
+perfquery \-a 32 1\-10 # read performance counters from lid 32, port 1\-10, aggregate output
+perfquery \-l 32 1\-10 # read performance counters from lid 32, port 1\-10, output each port
+perfquery \-a 32 1,4,8 # read performance counters from lid 32, port 1, 4, and 8, aggregate output
+perfquery \-l 32 1,4,8 # read performance counters from lid 32, port 1, 4, and 8, output each port
+.ft P
+.fi
+.UNINDENT
+.UNINDENT
+.SS AUTHOR
+.INDENT 0.0
+.TP
+.B Hal Rosenstock
+< \fI\%hal.rosenstock@gmail.com\fP >
+.UNINDENT
+.\" Generated by docutils manpage writer.
+.
diff --git a/contrib/ofed/infiniband-diags/man/saquery.8 b/contrib/ofed/infiniband-diags/man/saquery.8
new file mode 100644
index 0000000..82f20f7
--- /dev/null
+++ b/contrib/ofed/infiniband-diags/man/saquery.8
@@ -0,0 +1,380 @@
+.\" Man page generated from reStructuredText.
+.
+.TH SAQUERY 8 "" "" "Open IB Diagnostics"
+.SH NAME
+SAQUERY \-
+.
+.nr rst2man-indent-level 0
+.
+.de1 rstReportMargin
+\\$1 \\n[an-margin]
+level \\n[rst2man-indent-level]
+level margin: \\n[rst2man-indent\\n[rst2man-indent-level]]
+-
+\\n[rst2man-indent0]
+\\n[rst2man-indent1]
+\\n[rst2man-indent2]
+..
+.de1 INDENT
+.\" .rstReportMargin pre:
+. RS \\$1
+. nr rst2man-indent\\n[rst2man-indent-level] \\n[an-margin]
+. nr rst2man-indent-level +1
+.\" .rstReportMargin post:
+..
+.de UNINDENT
+. RE
+.\" indent \\n[an-margin]
+.\" old: \\n[rst2man-indent\\n[rst2man-indent-level]]
+.nr rst2man-indent-level -1
+.\" new: \\n[rst2man-indent\\n[rst2man-indent-level]]
+.in \\n[rst2man-indent\\n[rst2man-indent-level]]u
+..
+.SH QUERY INFINIBAND SUBNET ADMINISTRATION ATTRIBUTES
+.SS SYNOPSIS
+.sp
+saquery [options] [<name> | <lid> | <guid>]
+.SS DESCRIPTION
+.sp
+saquery issues the selected SA query. Node records are queried by default.
+.SS OPTIONS
+.INDENT 0.0
+.TP
+.B \fB\-p\fP
+get PathRecord info
+.TP
+.B \fB\-N\fP
+get NodeRecord info
+.TP
+.B \fB\-D, \-\-list\fP
+get NodeDescriptions of CAs only
+.TP
+.B \fB\-S\fP
+get ServiceRecord info
+.TP
+.B \fB\-I\fP
+get InformInfoRecord (subscription) info
+.TP
+.B \fB\-L\fP
+return the Lids of the name specified
+.TP
+.B \fB\-l\fP
+return the unique Lid of the name specified
+.TP
+.B \fB\-G\fP
+return the Guids of the name specified
+.TP
+.B \fB\-O\fP
+return the name for the Lid specified
+.TP
+.B \fB\-U\fP
+return the name for the Guid specified
+.TP
+.B \fB\-c\fP
+get the SA\(aqs class port info
+.TP
+.B \fB\-s\fP
+return the PortInfoRecords with isSM or isSMdisabled capability mask bit on
+.TP
+.B \fB\-g\fP
+get multicast group info
+.TP
+.B \fB\-m\fP
+get multicast member info. If a group is specified, limit the output
+to the group specified and print one line containing only the GUID and
+node description for each entry. Example: saquery \-m 0xc000
+.TP
+.B \fB\-x\fP
+get LinkRecord info
+.TP
+.B \fB\-\-src\-to\-dst <src:dst>\fP
+get a PathRecord for <src:dst>
+where src and dst are either node names or LIDs
+.TP
+.B \fB\-\-sgid\-to\-dgid <sgid:dgid>\fP
+get a PathRecord for \fBsgid\fP to \fBdgid\fP
+where both GIDs are in an IPv6 format acceptable to \fBinet_pton (3)\fP
+.TP
+.B \fB\-\-smkey <val>\fP
+use SM_Key value for the query. Will be used only with "trusted"
+queries. If non\-numeric value (like \(aqx\(aq) is specified then saquery
+will prompt for a value.
+Default (when not specified here or in
+/etc/infiniband-diags/ibdiag.conf) is to use SM_Key == 0 (or
+"untrusted")
+.TP
+.B \fB\-\-sa-dgid <gid>\fP
+Set the destination GID (in IPv6 format) of the SA in the GRH of the request.
+Either the actual SM GID or the SA well known GID (0::2) can be used to include
+in the GRH of the SA queries.
+.UNINDENT
+.\" Define the common option -K
+.
+.INDENT 0.0
+.TP
+.B \fB\-K, \-\-show_keys\fP
+show security keys (mkey, smkey, etc.) associated with the request.
+.UNINDENT
+.sp
+\fB\-\-slid <lid>\fP Source LID (PathRecord)
+.sp
+\fB\-\-dlid <lid>\fP Destination LID (PathRecord)
+.sp
+\fB\-\-mlid <lid>\fP Multicast LID (MCMemberRecord)
+.sp
+\fB\-\-sgid <gid>\fP Source GID (IPv6 format) (PathRecord)
+.sp
+\fB\-\-dgid <gid>\fP Destination GID (IPv6 format) (PathRecord)
+.sp
+\fB\-\-gid <gid>\fP Port GID (MCMemberRecord)
+.sp
+\fB\-\-mgid <gid>\fP Multicast GID (MCMemberRecord)
+.sp
+\fB\-\-reversible\fP Reversible path (PathRecord)
+.sp
+\fB\-\-numb_path\fP Number of paths (PathRecord)
+.INDENT 0.0
+.TP
+.B \fB\-\-pkey\fP P_Key (PathRecord, MCMemberRecord). If non\-numeric value (like \(aqx\(aq)
+is specified then saquery will prompt for a value
+.UNINDENT
+.sp
+\fB\-\-qos_class\fP QoS Class (PathRecord)
+.sp
+\fB\-\-sl\fP Service level (PathRecord, MCMemberRecord)
+.sp
+\fB\-\-mtu\fP MTU and selector (PathRecord, MCMemberRecord)
+.sp
+\fB\-\-rate\fP Rate and selector (PathRecord, MCMemberRecord)
+.sp
+\fB\-\-pkt_lifetime\fP Packet lifetime and selector (PathRecord, MCMemberRecord)
+.INDENT 0.0
+.TP
+.B \fB\-\-qkey\fP Q_Key (MCMemberRecord). If non\-numeric value (like \(aqx\(aq) is specified
+then saquery will prompt for a value
+.UNINDENT
+.sp
+\fB\-\-tclass\fP Traffic Class (PathRecord, MCMemberRecord)
+.sp
+\fB\-\-flow_label\fP Flow Label (PathRecord, MCMemberRecord)
+.sp
+\fB\-\-hop_limit\fP Hop limit (PathRecord, MCMemberRecord)
+.sp
+\fB\-\-scope\fP Scope (MCMemberRecord)
+.sp
+\fB\-\-join_state\fP Join state (MCMemberRecord)
+.sp
+\fB\-\-proxy_join\fP Proxy join (MCMemberRecord)
+.sp
+\fB\-\-service_id\fP ServiceID (PathRecord)
+.sp
+Supported query names (and aliases):
+.INDENT 0.0
+.INDENT 3.5
+.sp
+.nf
+.ft C
+ClassPortInfo (CPI)
+NodeRecord (NR) [lid]
+PortInfoRecord (PIR) [[lid]/[port]/[options]]
+SL2VLTableRecord (SL2VL) [[lid]/[in_port]/[out_port]]
+PKeyTableRecord (PKTR) [[lid]/[port]/[block]]
+VLArbitrationTableRecord (VLAR) [[lid]/[port]/[block]]
+InformInfoRecord (IIR)
+LinkRecord (LR) [[from_lid]/[from_port]] [[to_lid]/[to_port]]
+ServiceRecord (SR)
+PathRecord (PR)
+MCMemberRecord (MCMR)
+LFTRecord (LFTR) [[lid]/[block]]
+MFTRecord (MFTR) [[mlid]/[position]/[block]]
+GUIDInfoRecord (GIR) [[lid]/[block]]
+SwitchInfoRecord (SWIR) [lid]
+SMInfoRecord (SMIR) [lid]
+.ft P
+.fi
+.UNINDENT
+.UNINDENT
+.SS Port Selection flags
+.\" Define the common option -C
+.
+.sp
+\fB\-C, \-\-Ca <ca_name>\fP use the specified ca_name.
+.\" Define the common option -P
+.
+.sp
+\fB\-P, \-\-Port <ca_port>\fP use the specified ca_port.
+.\" Explanation of local port selection
+.
+.SS Local port Selection
+.sp
+Multiple port/Multiple CA support: when no IB device or port is specified
+(see the "local umad parameters" below), the libibumad library
+selects the port to use by the following criteria:
+.INDENT 0.0
+.INDENT 3.5
+.INDENT 0.0
+.IP 1. 3
+the first port that is ACTIVE.
+.IP 2. 3
+if not found, the first port that is UP (physical link up).
+.UNINDENT
+.sp
+If a port and/or CA name is specified, the libibumad library attempts
+to fulfill the user request, and will fail if it is not possible.
+.sp
+For example:
+.INDENT 0.0
+.INDENT 3.5
+.sp
+.nf
+.ft C
+ibaddr # use the first port (criteria #1 above)
+ibaddr \-C mthca1 # pick the best port from "mthca1" only.
+ibaddr \-P 2 # use the second (active/up) port from the first available IB device.
+ibaddr \-C mthca0 \-P 2 # use the specified port only.
+.ft P
+.fi
+.UNINDENT
+.UNINDENT
+.UNINDENT
+.UNINDENT
+.SS Debugging flags
+.\" Define the common option -d
+.
+.INDENT 0.0
+.TP
+.B \-d
+raise the IB debugging level.
+May be used several times (\-ddd or \-d \-d \-d).
+.UNINDENT
+.\" Define the common option -e
+.
+.INDENT 0.0
+.TP
+.B \-e
+show send and receive errors (timeouts and others)
+.UNINDENT
+.\" Define the common option -h
+.
+.sp
+\fB\-h, \-\-help\fP show the usage message
+.\" Define the common option -v
+.
+.INDENT 0.0
+.TP
+.B \fB\-v, \-\-verbose\fP
+increase the application verbosity level.
+May be used several times (\-vv or \-v \-v \-v)
+.UNINDENT
+.\" Define the common option -V
+.
+.sp
+\fB\-V, \-\-version\fP show the version info.
+.SS Configuration flags
+.\" Define the common option -t
+.
+.sp
+\fB\-t, \-\-timeout <timeout_ms>\fP override the default timeout for the solicited mads.
+.\" Define the common option -z
+.
+.INDENT 0.0
+.TP
+.B \fB\-\-outstanding_smps, \-o <val>\fP
+Specify the number of outstanding SMP\(aqs which should be issued during the scan
+.sp
+Default: 2
+.UNINDENT
+.\" Define the common option --node-name-map
+.
+.sp
+\fB\-\-node\-name\-map <node\-name\-map>\fP Specify a node name map.
+.INDENT 0.0
+.INDENT 3.5
+This file maps GUIDs to more user friendly names. See FILES section.
+.UNINDENT
+.UNINDENT
+.\" Define the common option -z
+.
+.sp
+\fB\-\-config, \-z <config_file>\fP Specify alternate config file.
+.INDENT 0.0
+.INDENT 3.5
+Default: /etc/infiniband-diags/ibdiag.conf
+.UNINDENT
+.UNINDENT
+.SS COMMON FILES
+.\" Common text for the config file
+.
+.SS CONFIG FILE
+.sp
+/etc/infiniband-diags/ibdiag.conf
+.sp
+A global config file is provided to set some of the common options for all
+tools. See supplied config file for details.
+.\" Common text to describe the node name map file.
+.
+.SS NODE NAME MAP FILE FORMAT
+.sp
+The node name map is used to specify user friendly names for nodes in the
+output. GUIDs are used to perform the lookup.
+.sp
+This functionality is provided by the opensm\-libs package. See \fBopensm(8)\fP
+for the file location for your installation.
+.sp
+\fBGenerically:\fP
+.INDENT 0.0
+.INDENT 3.5
+.sp
+.nf
+.ft C
+# comment
+<guid> "<name>"
+.ft P
+.fi
+.UNINDENT
+.UNINDENT
+.sp
+\fBExample:\fP
+.INDENT 0.0
+.INDENT 3.5
+.sp
+.nf
+.ft C
+# IB1
+# Line cards
+0x0008f104003f125c "IB1 (Rack 11 slot 1 ) ISR9288/ISR9096 Voltaire sLB\-24D"
+0x0008f104003f125d "IB1 (Rack 11 slot 1 ) ISR9288/ISR9096 Voltaire sLB\-24D"
+0x0008f104003f10d2 "IB1 (Rack 11 slot 2 ) ISR9288/ISR9096 Voltaire sLB\-24D"
+0x0008f104003f10d3 "IB1 (Rack 11 slot 2 ) ISR9288/ISR9096 Voltaire sLB\-24D"
+0x0008f104003f10bf "IB1 (Rack 11 slot 12 ) ISR9288/ISR9096 Voltaire sLB\-24D"
+
+# Spines
+0x0008f10400400e2d "IB1 (Rack 11 spine 1 ) ISR9288 Voltaire sFB\-12D"
+0x0008f10400400e2e "IB1 (Rack 11 spine 1 ) ISR9288 Voltaire sFB\-12D"
+0x0008f10400400e2f "IB1 (Rack 11 spine 1 ) ISR9288 Voltaire sFB\-12D"
+0x0008f10400400e31 "IB1 (Rack 11 spine 2 ) ISR9288 Voltaire sFB\-12D"
+0x0008f10400400e32 "IB1 (Rack 11 spine 2 ) ISR9288 Voltaire sFB\-12D"
+
+# GUID Node Name
+0x0008f10400411a08 "SW1 (Rack 3) ISR9024 Voltaire 9024D"
+0x0008f10400411a28 "SW2 (Rack 3) ISR9024 Voltaire 9024D"
+0x0008f10400411a34 "SW3 (Rack 3) ISR9024 Voltaire 9024D"
+0x0008f104004119d0 "SW4 (Rack 3) ISR9024 Voltaire 9024D"
+.ft P
+.fi
+.UNINDENT
+.UNINDENT
+.SS DEPENDENCIES
+.sp
+OpenSM (or other running SM/SA), libosmcomp, libibumad, libibmad
+.SS AUTHORS
+.INDENT 0.0
+.TP
+.B Ira Weiny
+< \fI\%ira.weiny@intel.com\fP >
+.TP
+.B Hal Rosenstock
+< \fI\%halr@mellanox.com\fP >
+.UNINDENT
+.\" Generated by docutils manpage writer.
+.
diff --git a/contrib/ofed/infiniband-diags/man/sminfo.8 b/contrib/ofed/infiniband-diags/man/sminfo.8
new file mode 100644
index 0000000..1ab235e
--- /dev/null
+++ b/contrib/ofed/infiniband-diags/man/sminfo.8
@@ -0,0 +1,215 @@
+.\" Man page generated from reStructuredText.
+.
+.TH SMINFO 8 "" "" "Open IB Diagnostics"
+.SH NAME
+SMINFO \-
+.
+.nr rst2man-indent-level 0
+.
+.de1 rstReportMargin
+\\$1 \\n[an-margin]
+level \\n[rst2man-indent-level]
+level margin: \\n[rst2man-indent\\n[rst2man-indent-level]]
+-
+\\n[rst2man-indent0]
+\\n[rst2man-indent1]
+\\n[rst2man-indent2]
+..
+.de1 INDENT
+.\" .rstReportMargin pre:
+. RS \\$1
+. nr rst2man-indent\\n[rst2man-indent-level] \\n[an-margin]
+. nr rst2man-indent-level +1
+.\" .rstReportMargin post:
+..
+.de UNINDENT
+. RE
+.\" indent \\n[an-margin]
+.\" old: \\n[rst2man-indent\\n[rst2man-indent-level]]
+.nr rst2man-indent-level -1
+.\" new: \\n[rst2man-indent\\n[rst2man-indent-level]]
+.in \\n[rst2man-indent\\n[rst2man-indent-level]]u
+..
+.SH QUERY INFINIBAND SMINFO ATTRIBUTE
+.SS SYNOPSIS
+.sp
+sminfo [options] sm_lid | sm_dr_path [modifier]
+.SS DESCRIPTION
+.sp
+Optionally set and display the output of a sminfo query in human readable
+format. The target SM is the one listed in the local port info, or the SM
+specified by the optional SM lid or by the SM direct routed path.
+.sp
+Note: using sminfo for any purposes other then simple query may be very
+dangerous, and may result in a malfunction of the target SM.
+.SS OPTIONS
+.INDENT 0.0
+.TP
+.B \fB\-s, \-\-state <state>\fP set SM state
+0 not active
+.sp
+1 discovering
+.sp
+2 standby
+.sp
+3 master
+.UNINDENT
+.sp
+\fB\-p, \-\-priority <priority>\fP set priority (0\-15)
+.sp
+\fB\-a, \-\-activity <val>\fP set activity count
+.SS Addressing Flags
+.\" Define the common option -D for Directed routes
+.
+.sp
+\fB\-D, \-\-Direct\fP The address specified is a directed route
+.INDENT 0.0
+.INDENT 3.5
+.sp
+.nf
+.ft C
+Examples:
+ [options] \-D [options] "0" # self port
+ [options] \-D [options] "0,1,2,1,4" # out via port 1, then 2, ...
+
+ (Note the second number in the path specified must match the port being
+ used. This can be specified using the port selection flag \(aq\-P\(aq or the
+ port found through the automatic selection process.)
+.ft P
+.fi
+.UNINDENT
+.UNINDENT
+.\" Define the common option -G
+.
+.sp
+\fB\-G, \-\-Guid\fP The address specified is a Port GUID
+.\" Define the common option -L
+.
+.sp
+\fB\-L, \-\-Lid\fP The address specified is a LID
+.SS Port Selection flags
+.\" Define the common option -C
+.
+.sp
+\fB\-C, \-\-Ca <ca_name>\fP use the specified ca_name.
+.\" Define the common option -P
+.
+.sp
+\fB\-P, \-\-Port <ca_port>\fP use the specified ca_port.
+.\" Explanation of local port selection
+.
+.SS Local port Selection
+.sp
+Multiple port/Multiple CA support: when no IB device or port is specified
+(see the "local umad parameters" below), the libibumad library
+selects the port to use by the following criteria:
+.INDENT 0.0
+.INDENT 3.5
+.INDENT 0.0
+.IP 1. 3
+the first port that is ACTIVE.
+.IP 2. 3
+if not found, the first port that is UP (physical link up).
+.UNINDENT
+.sp
+If a port and/or CA name is specified, the libibumad library attempts
+to fulfill the user request, and will fail if it is not possible.
+.sp
+For example:
+.INDENT 0.0
+.INDENT 3.5
+.sp
+.nf
+.ft C
+ibaddr # use the first port (criteria #1 above)
+ibaddr \-C mthca1 # pick the best port from "mthca1" only.
+ibaddr \-P 2 # use the second (active/up) port from the first available IB device.
+ibaddr \-C mthca0 \-P 2 # use the specified port only.
+.ft P
+.fi
+.UNINDENT
+.UNINDENT
+.UNINDENT
+.UNINDENT
+.SS Debugging flags
+.\" Define the common option -d
+.
+.INDENT 0.0
+.TP
+.B \-d
+raise the IB debugging level.
+May be used several times (\-ddd or \-d \-d \-d).
+.UNINDENT
+.\" Define the common option -e
+.
+.INDENT 0.0
+.TP
+.B \-e
+show send and receive errors (timeouts and others)
+.UNINDENT
+.\" Define the common option -h
+.
+.sp
+\fB\-h, \-\-help\fP show the usage message
+.\" Define the common option -v
+.
+.INDENT 0.0
+.TP
+.B \fB\-v, \-\-verbose\fP
+increase the application verbosity level.
+May be used several times (\-vv or \-v \-v \-v)
+.UNINDENT
+.\" Define the common option -V
+.
+.sp
+\fB\-V, \-\-version\fP show the version info.
+.SS Configuration flags
+.\" Define the common option -t
+.
+.sp
+\fB\-t, \-\-timeout <timeout_ms>\fP override the default timeout for the solicited mads.
+.\" Define the common option -y
+.
+.INDENT 0.0
+.TP
+.B \fB\-y, \-\-m_key <key>\fP
+use the specified M_key for requests. If non\-numeric value (like \(aqx\(aq)
+is specified then a value will be prompted for.
+.UNINDENT
+.\" Define the common option -z
+.
+.sp
+\fB\-\-config, \-z <config_file>\fP Specify alternate config file.
+.INDENT 0.0
+.INDENT 3.5
+Default: /etc/infiniband-diags/ibdiag.conf
+.UNINDENT
+.UNINDENT
+.SS FILES
+.\" Common text for the config file
+.
+.SS CONFIG FILE
+.sp
+/etc/infiniband-diags/ibdiag.conf
+.sp
+A global config file is provided to set some of the common options for all
+tools. See supplied config file for details.
+.SS EXAMPLES
+.INDENT 0.0
+.TP
+.B ::
+sminfo # local port\(aqs sminfo
+sminfo 32 # show sminfo of lid 32
+sminfo \-G 0x8f1040023 # same but using guid address
+.UNINDENT
+.SS SEE ALSO
+.sp
+smpdump (8)
+.SS AUTHOR
+.INDENT 0.0
+.TP
+.B Hal Rosenstock
+< \fI\%halr@voltaire.com\fP >
+.UNINDENT
+.\" Generated by docutils manpage writer.
+.
diff --git a/contrib/ofed/infiniband-diags/man/smpdump.8 b/contrib/ofed/infiniband-diags/man/smpdump.8
new file mode 100644
index 0000000..8225f63
--- /dev/null
+++ b/contrib/ofed/infiniband-diags/man/smpdump.8
@@ -0,0 +1,207 @@
+.\" Man page generated from reStructuredText.
+.
+.TH SMPDUMP 8 "" "" "Open IB Diagnostics"
+.SH NAME
+SMPDUMP \-
+.
+.nr rst2man-indent-level 0
+.
+.de1 rstReportMargin
+\\$1 \\n[an-margin]
+level \\n[rst2man-indent-level]
+level margin: \\n[rst2man-indent\\n[rst2man-indent-level]]
+-
+\\n[rst2man-indent0]
+\\n[rst2man-indent1]
+\\n[rst2man-indent2]
+..
+.de1 INDENT
+.\" .rstReportMargin pre:
+. RS \\$1
+. nr rst2man-indent\\n[rst2man-indent-level] \\n[an-margin]
+. nr rst2man-indent-level +1
+.\" .rstReportMargin post:
+..
+.de UNINDENT
+. RE
+.\" indent \\n[an-margin]
+.\" old: \\n[rst2man-indent\\n[rst2man-indent-level]]
+.nr rst2man-indent-level -1
+.\" new: \\n[rst2man-indent\\n[rst2man-indent-level]]
+.in \\n[rst2man-indent\\n[rst2man-indent-level]]u
+..
+.SH DUMP INFINIBAND SUBNET MANAGEMENT ATTRIBUTES
+.SS SYNOPSIS
+.sp
+smpdump [options] <dlid|dr_path> <attribute> [attribute_modifier]
+.SS DESCRIPTION
+.sp
+smpdump is a general purpose SMP utility which gets SM attributes from a
+specified SMA. The result is dumped in hex by default.
+.SS OPTIONS
+.INDENT 0.0
+.TP
+.B \fBdlid|drpath\fP
+LID or DR path to SMA
+.TP
+.B \fBattribute\fP
+IBA attribute ID for SM attribute
+.TP
+.B \fBattribute_modifier\fP
+IBA modifier for SM attribute
+.TP
+.B \fB\-s, \-\-string\fP
+Print strings in packet if possible
+.UNINDENT
+.SS Addressing Flags
+.\" Define the common option -D for Directed routes
+.
+.sp
+\fB\-D, \-\-Direct\fP The address specified is a directed route
+.INDENT 0.0
+.INDENT 3.5
+.sp
+.nf
+.ft C
+Examples:
+ [options] \-D [options] "0" # self port
+ [options] \-D [options] "0,1,2,1,4" # out via port 1, then 2, ...
+
+ (Note the second number in the path specified must match the port being
+ used. This can be specified using the port selection flag \(aq\-P\(aq or the
+ port found through the automatic selection process.)
+.ft P
+.fi
+.UNINDENT
+.UNINDENT
+.\" Define the common option -L
+.
+.sp
+\fB\-L, \-\-Lid\fP The address specified is a LID
+.SS Port Selection flags
+.\" Define the common option -C
+.
+.sp
+\fB\-C, \-\-Ca <ca_name>\fP use the specified ca_name.
+.\" Define the common option -P
+.
+.sp
+\fB\-P, \-\-Port <ca_port>\fP use the specified ca_port.
+.\" Explanation of local port selection
+.
+.SS Local port Selection
+.sp
+Multiple port/Multiple CA support: when no IB device or port is specified
+(see the "local umad parameters" below), the libibumad library
+selects the port to use by the following criteria:
+.INDENT 0.0
+.INDENT 3.5
+.INDENT 0.0
+.IP 1. 3
+the first port that is ACTIVE.
+.IP 2. 3
+if not found, the first port that is UP (physical link up).
+.UNINDENT
+.sp
+If a port and/or CA name is specified, the libibumad library attempts
+to fulfill the user request, and will fail if it is not possible.
+.sp
+For example:
+.INDENT 0.0
+.INDENT 3.5
+.sp
+.nf
+.ft C
+ibaddr # use the first port (criteria #1 above)
+ibaddr \-C mthca1 # pick the best port from "mthca1" only.
+ibaddr \-P 2 # use the second (active/up) port from the first available IB device.
+ibaddr \-C mthca0 \-P 2 # use the specified port only.
+.ft P
+.fi
+.UNINDENT
+.UNINDENT
+.UNINDENT
+.UNINDENT
+.SS Debugging flags
+.\" Define the common option -d
+.
+.INDENT 0.0
+.TP
+.B \-d
+raise the IB debugging level.
+May be used several times (\-ddd or \-d \-d \-d).
+.UNINDENT
+.\" Define the common option -e
+.
+.INDENT 0.0
+.TP
+.B \-e
+show send and receive errors (timeouts and others)
+.UNINDENT
+.\" Define the common option -h
+.
+.sp
+\fB\-h, \-\-help\fP show the usage message
+.\" Define the common option -v
+.
+.INDENT 0.0
+.TP
+.B \fB\-v, \-\-verbose\fP
+increase the application verbosity level.
+May be used several times (\-vv or \-v \-v \-v)
+.UNINDENT
+.\" Define the common option -V
+.
+.sp
+\fB\-V, \-\-version\fP show the version info.
+.SS Configuration flags
+.\" Define the common option -t
+.
+.sp
+\fB\-t, \-\-timeout <timeout_ms>\fP override the default timeout for the solicited mads.
+.\" Define the common option -z
+.
+.sp
+\fB\-\-config, \-z <config_file>\fP Specify alternate config file.
+.INDENT 0.0
+.INDENT 3.5
+Default: /etc/infiniband-diags/ibdiag.conf
+.UNINDENT
+.UNINDENT
+.SS FILES
+.\" Common text for the config file
+.
+.SS CONFIG FILE
+.sp
+/etc/infiniband-diags/ibdiag.conf
+.sp
+A global config file is provided to set some of the common options for all
+tools. See supplied config file for details.
+.SS EXAMPLES
+.sp
+Direct Routed Examples
+.INDENT 0.0
+.TP
+.B ::
+smpdump \-D 0,1,2,3,5 16 # NODE DESC
+smpdump \-D 0,1,2 0x15 2 # PORT INFO, port 2
+.UNINDENT
+.sp
+LID Routed Examples
+.INDENT 0.0
+.TP
+.B ::
+smpdump 3 0x15 2 # PORT INFO, lid 3 port 2
+smpdump 0xa0 0x11 # NODE INFO, lid 0xa0
+.UNINDENT
+.SS SEE ALSO
+.sp
+smpquery (8)
+.SS AUTHOR
+.INDENT 0.0
+.TP
+.B Hal Rosenstock
+< \fI\%halr@voltaire.com\fP >
+.UNINDENT
+.\" Generated by docutils manpage writer.
+.
diff --git a/contrib/ofed/infiniband-diags/man/smpquery.8 b/contrib/ofed/infiniband-diags/man/smpquery.8
new file mode 100644
index 0000000..c4dd24f
--- /dev/null
+++ b/contrib/ofed/infiniband-diags/man/smpquery.8
@@ -0,0 +1,310 @@
+.\" Man page generated from reStructuredText.
+.
+.TH SMPQUERY 8 "" "" "Open IB Diagnostics"
+.SH NAME
+SMPQUERY \-
+.
+.nr rst2man-indent-level 0
+.
+.de1 rstReportMargin
+\\$1 \\n[an-margin]
+level \\n[rst2man-indent-level]
+level margin: \\n[rst2man-indent\\n[rst2man-indent-level]]
+-
+\\n[rst2man-indent0]
+\\n[rst2man-indent1]
+\\n[rst2man-indent2]
+..
+.de1 INDENT
+.\" .rstReportMargin pre:
+. RS \\$1
+. nr rst2man-indent\\n[rst2man-indent-level] \\n[an-margin]
+. nr rst2man-indent-level +1
+.\" .rstReportMargin post:
+..
+.de UNINDENT
+. RE
+.\" indent \\n[an-margin]
+.\" old: \\n[rst2man-indent\\n[rst2man-indent-level]]
+.nr rst2man-indent-level -1
+.\" new: \\n[rst2man-indent\\n[rst2man-indent-level]]
+.in \\n[rst2man-indent\\n[rst2man-indent-level]]u
+..
+.SH QUERY INFINIBAND SUBNET MANAGEMENT ATTRIBUTES
+.SS SYNOPSIS
+.sp
+smpquery [options] <op> <dest dr_path|lid|guid> [op params]
+.SS DESCRIPTION
+.sp
+smpquery allows a basic subset of standard SMP queries including the following:
+node info, node description, switch info, port info. Fields are displayed in
+human readable format.
+.SS OPTIONS
+.sp
+Current supported operations (case insensitive) and their parameters:
+.INDENT 0.0
+.INDENT 3.5
+.sp
+.nf
+.ft C
+Nodeinfo (NI) <addr>
+
+Nodedesc (ND) <addr>
+
+Portinfo (PI) <addr> [<portnum>] # default port is zero
+
+PortInfoExtended (PIE) <addr> [<portnum>]
+
+Switchinfo (SI) <addr>
+
+PKeyTable (PKeys) <addr> [<portnum>]
+
+SL2VLTable (SL2VL) <addr> [<portnum>]
+
+VLArbitration (VLArb) <addr> [<portnum>]
+
+GUIDInfo (GI) <addr>
+
+MlnxExtPortInfo (MEPI) <addr> [<portnum>] # default port is zero
+.ft P
+.fi
+.UNINDENT
+.UNINDENT
+.INDENT 0.0
+.TP
+.B \fB\-c, \-\-combined\fP
+Use Combined route address argument \fB<lid> <DR_Path>\fP
+.TP
+.B \fB\-x, \-\-extended\fP
+Set SMSupportsExtendedSpeeds bit 31 in AttributeModifier
+(only impacts PortInfo queries).
+.UNINDENT
+.\" Define the common option -K
+.
+.INDENT 0.0
+.TP
+.B \fB\-K, \-\-show_keys\fP
+show security keys (mkey, smkey, etc.) associated with the request.
+.UNINDENT
+.SS Addressing Flags
+.\" Define the common option -D for Directed routes
+.
+.sp
+\fB\-D, \-\-Direct\fP The address specified is a directed route
+.INDENT 0.0
+.INDENT 3.5
+.sp
+.nf
+.ft C
+Examples:
+ [options] \-D [options] "0" # self port
+ [options] \-D [options] "0,1,2,1,4" # out via port 1, then 2, ...
+
+ (Note the second number in the path specified must match the port being
+ used. This can be specified using the port selection flag \(aq\-P\(aq or the
+ port found through the automatic selection process.)
+.ft P
+.fi
+.UNINDENT
+.UNINDENT
+.\" Define the common option -G
+.
+.sp
+\fB\-G, \-\-Guid\fP The address specified is a Port GUID
+.\" Define the common option -L
+.
+.sp
+\fB\-L, \-\-Lid\fP The address specified is a LID
+.\" Define the common option -s
+.
+.sp
+\fB\-s, \-\-sm_port <smlid>\fP use \(aqsmlid\(aq as the target lid for SA queries.
+.SS Port Selection flags
+.\" Define the common option -C
+.
+.sp
+\fB\-C, \-\-Ca <ca_name>\fP use the specified ca_name.
+.\" Define the common option -P
+.
+.sp
+\fB\-P, \-\-Port <ca_port>\fP use the specified ca_port.
+.\" Explanation of local port selection
+.
+.SS Local port Selection
+.sp
+Multiple port/Multiple CA support: when no IB device or port is specified
+(see the "local umad parameters" below), the libibumad library
+selects the port to use by the following criteria:
+.INDENT 0.0
+.INDENT 3.5
+.INDENT 0.0
+.IP 1. 3
+the first port that is ACTIVE.
+.IP 2. 3
+if not found, the first port that is UP (physical link up).
+.UNINDENT
+.sp
+If a port and/or CA name is specified, the libibumad library attempts
+to fulfill the user request, and will fail if it is not possible.
+.sp
+For example:
+.INDENT 0.0
+.INDENT 3.5
+.sp
+.nf
+.ft C
+ibaddr # use the first port (criteria #1 above)
+ibaddr \-C mthca1 # pick the best port from "mthca1" only.
+ibaddr \-P 2 # use the second (active/up) port from the first available IB device.
+ibaddr \-C mthca0 \-P 2 # use the specified port only.
+.ft P
+.fi
+.UNINDENT
+.UNINDENT
+.UNINDENT
+.UNINDENT
+.SS Debugging flags
+.\" Define the common option -d
+.
+.INDENT 0.0
+.TP
+.B \-d
+raise the IB debugging level.
+May be used several times (\-ddd or \-d \-d \-d).
+.UNINDENT
+.\" Define the common option -e
+.
+.INDENT 0.0
+.TP
+.B \-e
+show send and receive errors (timeouts and others)
+.UNINDENT
+.\" Define the common option -h
+.
+.sp
+\fB\-h, \-\-help\fP show the usage message
+.\" Define the common option -v
+.
+.INDENT 0.0
+.TP
+.B \fB\-v, \-\-verbose\fP
+increase the application verbosity level.
+May be used several times (\-vv or \-v \-v \-v)
+.UNINDENT
+.\" Define the common option -V
+.
+.sp
+\fB\-V, \-\-version\fP show the version info.
+.SS Configuration flags
+.\" Define the common option -t
+.
+.sp
+\fB\-t, \-\-timeout <timeout_ms>\fP override the default timeout for the solicited mads.
+.\" Define the common option --node-name-map
+.
+.sp
+\fB\-\-node\-name\-map <node\-name\-map>\fP Specify a node name map.
+.INDENT 0.0
+.INDENT 3.5
+This file maps GUIDs to more user friendly names. See FILES section.
+.UNINDENT
+.UNINDENT
+.\" Define the common option -y
+.
+.INDENT 0.0
+.TP
+.B \fB\-y, \-\-m_key <key>\fP
+use the specified M_key for requests. If non\-numeric value (like \(aqx\(aq)
+is specified then a value will be prompted for.
+.UNINDENT
+.\" Define the common option -z
+.
+.sp
+\fB\-\-config, \-z <config_file>\fP Specify alternate config file.
+.INDENT 0.0
+.INDENT 3.5
+Default: /etc/infiniband-diags/ibdiag.conf
+.UNINDENT
+.UNINDENT
+.SS FILES
+.\" Common text for the config file
+.
+.SS CONFIG FILE
+.sp
+/etc/infiniband-diags/ibdiag.conf
+.sp
+A global config file is provided to set some of the common options for all
+tools. See supplied config file for details.
+.\" Common text to describe the node name map file.
+.
+.SS NODE NAME MAP FILE FORMAT
+.sp
+The node name map is used to specify user friendly names for nodes in the
+output. GUIDs are used to perform the lookup.
+.sp
+This functionality is provided by the opensm\-libs package. See \fBopensm(8)\fP
+for the file location for your installation.
+.sp
+\fBGenerically:\fP
+.INDENT 0.0
+.INDENT 3.5
+.sp
+.nf
+.ft C
+# comment
+<guid> "<name>"
+.ft P
+.fi
+.UNINDENT
+.UNINDENT
+.sp
+\fBExample:\fP
+.INDENT 0.0
+.INDENT 3.5
+.sp
+.nf
+.ft C
+# IB1
+# Line cards
+0x0008f104003f125c "IB1 (Rack 11 slot 1 ) ISR9288/ISR9096 Voltaire sLB\-24D"
+0x0008f104003f125d "IB1 (Rack 11 slot 1 ) ISR9288/ISR9096 Voltaire sLB\-24D"
+0x0008f104003f10d2 "IB1 (Rack 11 slot 2 ) ISR9288/ISR9096 Voltaire sLB\-24D"
+0x0008f104003f10d3 "IB1 (Rack 11 slot 2 ) ISR9288/ISR9096 Voltaire sLB\-24D"
+0x0008f104003f10bf "IB1 (Rack 11 slot 12 ) ISR9288/ISR9096 Voltaire sLB\-24D"
+
+# Spines
+0x0008f10400400e2d "IB1 (Rack 11 spine 1 ) ISR9288 Voltaire sFB\-12D"
+0x0008f10400400e2e "IB1 (Rack 11 spine 1 ) ISR9288 Voltaire sFB\-12D"
+0x0008f10400400e2f "IB1 (Rack 11 spine 1 ) ISR9288 Voltaire sFB\-12D"
+0x0008f10400400e31 "IB1 (Rack 11 spine 2 ) ISR9288 Voltaire sFB\-12D"
+0x0008f10400400e32 "IB1 (Rack 11 spine 2 ) ISR9288 Voltaire sFB\-12D"
+
+# GUID Node Name
+0x0008f10400411a08 "SW1 (Rack 3) ISR9024 Voltaire 9024D"
+0x0008f10400411a28 "SW2 (Rack 3) ISR9024 Voltaire 9024D"
+0x0008f10400411a34 "SW3 (Rack 3) ISR9024 Voltaire 9024D"
+0x0008f104004119d0 "SW4 (Rack 3) ISR9024 Voltaire 9024D"
+.ft P
+.fi
+.UNINDENT
+.UNINDENT
+.SS EXAMPLES
+.INDENT 0.0
+.TP
+.B ::
+smpquery portinfo 3 1 # portinfo by lid, with port modifier
+smpquery \-G switchinfo 0x2C9000100D051 1 # switchinfo by guid
+smpquery \-D nodeinfo 0 # nodeinfo by direct route
+smpquery \-c nodeinfo 6 0,12 # nodeinfo by combined route
+.UNINDENT
+.SS SEE ALSO
+.sp
+smpdump (8)
+.SS AUTHOR
+.INDENT 0.0
+.TP
+.B Hal Rosenstock
+< \fI\%hal@mellanox.com\fP >
+.UNINDENT
+.\" Generated by docutils manpage writer.
+.
diff --git a/contrib/ofed/infiniband-diags/man/vendstat.8 b/contrib/ofed/infiniband-diags/man/vendstat.8
new file mode 100644
index 0000000..a9ede4d
--- /dev/null
+++ b/contrib/ofed/infiniband-diags/man/vendstat.8
@@ -0,0 +1,221 @@
+.\" Man page generated from reStructuredText.
+.
+.TH VENDSTAT 8 "" "" "Open IB Diagnostics"
+.SH NAME
+VENDSTAT \-
+.
+.nr rst2man-indent-level 0
+.
+.de1 rstReportMargin
+\\$1 \\n[an-margin]
+level \\n[rst2man-indent-level]
+level margin: \\n[rst2man-indent\\n[rst2man-indent-level]]
+-
+\\n[rst2man-indent0]
+\\n[rst2man-indent1]
+\\n[rst2man-indent2]
+..
+.de1 INDENT
+.\" .rstReportMargin pre:
+. RS \\$1
+. nr rst2man-indent\\n[rst2man-indent-level] \\n[an-margin]
+. nr rst2man-indent-level +1
+.\" .rstReportMargin post:
+..
+.de UNINDENT
+. RE
+.\" indent \\n[an-margin]
+.\" old: \\n[rst2man-indent\\n[rst2man-indent-level]]
+.nr rst2man-indent-level -1
+.\" new: \\n[rst2man-indent\\n[rst2man-indent-level]]
+.in \\n[rst2man-indent\\n[rst2man-indent-level]]u
+..
+.SH QUERY INFINIBAND VENDOR SPECIFIC FUNCTIONS
+.SS SYNOPSIS
+.sp
+vendstat [options] <lid|guid>
+.SS DESCRIPTION
+.sp
+vendstat uses vendor specific MADs to access beyond the IB spec
+vendor specific functionality. Currently, there is support for
+Mellanox InfiniSwitch\-III (IS3) and InfiniSwitch\-IV (IS4).
+.SS OPTIONS
+.INDENT 0.0
+.TP
+.B \fB\-N\fP
+show IS3 or IS4 general information.
+.TP
+.B \fB\-w\fP
+show IS3 port xmit wait counters.
+.TP
+.B \fB\-i\fP
+show IS4 counter group info.
+.TP
+.B \fB\-c <num,num>\fP
+configure IS4 counter groups.
+.sp
+Configure IS4 counter groups 0 and 1. Such configuration is not
+persistent across IS4 reboot. First number is for counter group 0 and
+second is for counter group 1.
+.sp
+Group 0 counter config values:
+.UNINDENT
+.INDENT 0.0
+.TP
+.B ::
+.INDENT 7.0
+.INDENT 3.5
+0 \- PortXmitDataSL0\-7
+1 \- PortXmitDataSL8\-15
+2 \- PortRcvDataSL0\-7
+.UNINDENT
+.UNINDENT
+.sp
+Group 1 counter config values:
+.UNINDENT
+.INDENT 0.0
+.TP
+.B ::
+1 \- PortXmitDataSL8\-15
+2 \- PortRcvDataSL0\-7
+8 \- PortRcvDataSL8\-15
+.TP
+.B \fB\-R, \-\-Read <addr,mask>\fP
+Read configuration space record at addr
+.TP
+.B \fB\-W, \-\-Write <addr,val,mask>\fP
+Write configuration space record at addr
+.TP
+.B \fB\-\-dgid <gid>\fP
+destination GID: use when GRH is required in packets (IPv6 format)
+.UNINDENT
+.SS Addressing Flags
+.\" Define the common option -G
+.
+.sp
+\fB\-G, \-\-Guid\fP The address specified is a Port GUID
+.\" Define the common option -L
+.
+.sp
+\fB\-L, \-\-Lid\fP The address specified is a LID
+.\" Define the common option -s
+.
+.sp
+\fB\-s, \-\-sm_port <smlid>\fP use \(aqsmlid\(aq as the target lid for SA queries.
+.SS Port Selection flags
+.\" Define the common option -C
+.
+.sp
+\fB\-C, \-\-Ca <ca_name>\fP use the specified ca_name.
+.\" Define the common option -P
+.
+.sp
+\fB\-P, \-\-Port <ca_port>\fP use the specified ca_port.
+.\" Explanation of local port selection
+.
+.SS Local port Selection
+.sp
+Multiple port/Multiple CA support: when no IB device or port is specified
+(see the "local umad parameters" below), the libibumad library
+selects the port to use by the following criteria:
+.INDENT 0.0
+.INDENT 3.5
+.INDENT 0.0
+.IP 1. 3
+the first port that is ACTIVE.
+.IP 2. 3
+if not found, the first port that is UP (physical link up).
+.UNINDENT
+.sp
+If a port and/or CA name is specified, the libibumad library attempts
+to fulfill the user request, and will fail if it is not possible.
+.sp
+For example:
+.INDENT 0.0
+.INDENT 3.5
+.sp
+.nf
+.ft C
+ibaddr # use the first port (criteria #1 above)
+ibaddr \-C mthca1 # pick the best port from "mthca1" only.
+ibaddr \-P 2 # use the second (active/up) port from the first available IB device.
+ibaddr \-C mthca0 \-P 2 # use the specified port only.
+.ft P
+.fi
+.UNINDENT
+.UNINDENT
+.UNINDENT
+.UNINDENT
+.SS Debugging flags
+.\" Define the common option -d
+.
+.INDENT 0.0
+.TP
+.B \-d
+raise the IB debugging level.
+May be used several times (\-ddd or \-d \-d \-d).
+.UNINDENT
+.\" Define the common option -e
+.
+.INDENT 0.0
+.TP
+.B \-e
+show send and receive errors (timeouts and others)
+.UNINDENT
+.\" Define the common option -h
+.
+.sp
+\fB\-h, \-\-help\fP show the usage message
+.\" Define the common option -v
+.
+.INDENT 0.0
+.TP
+.B \fB\-v, \-\-verbose\fP
+increase the application verbosity level.
+May be used several times (\-vv or \-v \-v \-v)
+.UNINDENT
+.\" Define the common option -V
+.
+.sp
+\fB\-V, \-\-version\fP show the version info.
+.SS Configuration flags
+.\" Define the common option -t
+.
+.sp
+\fB\-t, \-\-timeout <timeout_ms>\fP override the default timeout for the solicited mads.
+.\" Define the common option -z
+.
+.sp
+\fB\-\-config, \-z <config_file>\fP Specify alternate config file.
+.INDENT 0.0
+.INDENT 3.5
+Default: /etc/infiniband-diags/ibdiag.conf
+.UNINDENT
+.UNINDENT
+.SS FILES
+.\" Common text for the config file
+.
+.SS CONFIG FILE
+.sp
+/etc/infiniband-diags/ibdiag.conf
+.sp
+A global config file is provided to set some of the common options for all
+tools. See supplied config file for details.
+.SS EXAMPLES
+.INDENT 0.0
+.TP
+.B ::
+vendstat \-N 6 # read IS3 or IS4 general information
+vendstat \-w 6 # read IS3 port xmit wait counters
+vendstat \-i 6 12 # read IS4 port 12 counter group info
+vendstat \-c 0,1 6 12 # configure IS4 port 12 counter groups for PortXmitDataSL
+vendstat \-c 2,8 6 12 # configure IS4 port 12 counter groups for PortRcvDataSL
+.UNINDENT
+.SS AUTHOR
+.INDENT 0.0
+.TP
+.B Hal Rosenstock
+< \fI\%hal.rosenstock@gmail.com\fP >
+.UNINDENT
+.\" Generated by docutils manpage writer.
+.
diff --git a/contrib/ofed/infiniband-diags/src/dump_fts.c b/contrib/ofed/infiniband-diags/src/dump_fts.c
new file mode 100644
index 0000000..387211f
--- /dev/null
+++ b/contrib/ofed/infiniband-diags/src/dump_fts.c
@@ -0,0 +1,497 @@
+/*
+ * Copyright (c) 2004-2009 Voltaire Inc. All rights reserved.
+ * Copyright (c) 2009-2011 Mellanox Technologies LTD. All rights reserved.
+ * Copyright (c) 2013 Lawrence Livermore National Security. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+#if HAVE_CONFIG_H
+# include <config.h>
+#endif /* HAVE_CONFIG_H */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <string.h>
+#include <inttypes.h>
+#include <getopt.h>
+#include <netinet/in.h>
+#include <assert.h>
+
+#include <infiniband/umad.h>
+#include <infiniband/mad.h>
+#include <complib/cl_nodenamemap.h>
+
+#include <infiniband/ibnetdisc.h>
+
+#include "ibdiag_common.h"
+
+struct ibmad_port *srcport;
+
+unsigned startlid = 0, endlid = 0;
+
+static int brief, dump_all, multicast;
+
+static char *node_name_map_file = NULL;
+static nn_map_t *node_name_map = NULL;
+
+#define IB_MLIDS_IN_BLOCK (IB_SMP_DATA_SIZE/2)
+
+int dump_mlid(char *str, int strlen, unsigned mlid, unsigned nports,
+ uint16_t mft[16][IB_MLIDS_IN_BLOCK])
+{
+ uint16_t mask;
+ unsigned i, chunk, bit, nonzero = 0;
+
+ if (brief) {
+ int n = 0;
+ unsigned chunks = ALIGN(nports + 1, 16) / 16;
+ for (i = 0; i < chunks; i++) {
+ mask = ntohs(mft[i][mlid % IB_MLIDS_IN_BLOCK]);
+ if (mask)
+ nonzero++;
+ n += snprintf(str + n, strlen - n, "%04hx", mask);
+ if (n >= strlen) {
+ n = strlen;
+ break;
+ }
+ }
+ if (!nonzero && !dump_all) {
+ str[0] = 0;
+ return 0;
+ }
+ return n;
+ }
+ for (i = 0; i <= nports; i++) {
+ chunk = i / 16;
+ bit = i % 16;
+
+ mask = ntohs(mft[chunk][mlid % IB_MLIDS_IN_BLOCK]);
+ if (mask)
+ nonzero++;
+ str[i * 2] = (mask & (1 << bit)) ? 'x' : ' ';
+ str[i * 2 + 1] = ' ';
+ }
+ if (!nonzero && !dump_all) {
+ str[0] = 0;
+ return 0;
+ }
+ str[i * 2] = 0;
+ return i * 2;
+}
+
+uint16_t mft[16][IB_MLIDS_IN_BLOCK] = { { 0 }, { 0 }, { 0 }, { 0 }, { 0 }, { 0 }, { 0 }, { 0 }, { 0 }, { 0 }, { 0 }, { 0 }, { 0 }, { 0}, { 0 }, { 0 } };
+
+void dump_multicast_tables(ibnd_node_t * node, unsigned startlid,
+ unsigned endlid, struct ibmad_port * mad_port)
+{
+ ib_portid_t *portid = &node->path_portid;
+ char nd[IB_SMP_DATA_SIZE] = { 0 };
+ char str[512];
+ char *s;
+ uint64_t nodeguid;
+ uint32_t mod;
+ unsigned block, i, j, e, nports, cap, chunks, startblock, lastblock,
+ top;
+ char *mapnd = NULL;
+ int n = 0;
+
+ memcpy(nd, node->nodedesc, strlen(node->nodedesc));
+ nports = node->numports;
+ nodeguid = node->guid;
+
+ mad_decode_field(node->switchinfo, IB_SW_MCAST_FDB_CAP_F, &cap);
+ mad_decode_field(node->switchinfo, IB_SW_MCAST_FDB_TOP_F, &top);
+
+ if (!endlid || endlid > IB_MIN_MCAST_LID + cap - 1)
+ endlid = IB_MIN_MCAST_LID + cap - 1;
+ if (!dump_all && top && top < endlid) {
+ if (top < IB_MIN_MCAST_LID - 1)
+ IBWARN("illegal top mlid %x", top);
+ else
+ endlid = top;
+ }
+
+ if (!startlid)
+ startlid = IB_MIN_MCAST_LID;
+ else if (startlid < IB_MIN_MCAST_LID) {
+ IBWARN("illegal start mlid %x, set to %x", startlid,
+ IB_MIN_MCAST_LID);
+ startlid = IB_MIN_MCAST_LID;
+ }
+
+ if (endlid > IB_MAX_MCAST_LID) {
+ IBWARN("illegal end mlid %x, truncate to %x", endlid,
+ IB_MAX_MCAST_LID);
+ endlid = IB_MAX_MCAST_LID;
+ }
+
+ mapnd = remap_node_name(node_name_map, nodeguid, nd);
+
+ printf("Multicast mlids [0x%x-0x%x] of switch %s guid 0x%016" PRIx64
+ " (%s):\n", startlid, endlid, portid2str(portid), nodeguid,
+ mapnd);
+
+ if (brief)
+ printf(" MLid Port Mask\n");
+ else {
+ if (nports > 9) {
+ for (i = 0, s = str; i <= nports; i++) {
+ *s++ = (i % 10) ? ' ' : '0' + i / 10;
+ *s++ = ' ';
+ }
+ *s = 0;
+ printf(" %s\n", str);
+ }
+ for (i = 0, s = str; i <= nports; i++)
+ s += sprintf(s, "%d ", i % 10);
+ printf(" Ports: %s\n", str);
+ printf(" MLid\n");
+ }
+ if (ibverbose)
+ printf("Switch multicast mlid capability is %d top is 0x%x\n",
+ cap, top);
+
+ chunks = ALIGN(nports + 1, 16) / 16;
+
+ startblock = startlid / IB_MLIDS_IN_BLOCK;
+ lastblock = endlid / IB_MLIDS_IN_BLOCK;
+ for (block = startblock; block <= lastblock; block++) {
+ for (j = 0; j < chunks; j++) {
+ int status;
+ mod = (block - IB_MIN_MCAST_LID / IB_MLIDS_IN_BLOCK)
+ | (j << 28);
+
+ DEBUG("reading block %x chunk %d mod %x", block, j,
+ mod);
+ if (!smp_query_status_via
+ (mft + j, portid, IB_ATTR_MULTICASTFORWTBL, mod, 0,
+ &status, mad_port)) {
+ fprintf(stderr, "SubnGet(MFT) failed on switch "
+ "'%s' %s Node GUID 0x%"PRIx64
+ " SMA LID %d; MAD status 0x%x "
+ "AM 0x%x\n",
+ mapnd, portid2str(portid),
+ node->guid, node->smalid,
+ status, mod);
+ }
+ }
+
+ i = block * IB_MLIDS_IN_BLOCK;
+ e = i + IB_MLIDS_IN_BLOCK;
+ if (i < startlid)
+ i = startlid;
+ if (e > endlid + 1)
+ e = endlid + 1;
+
+ for (; i < e; i++) {
+ if (dump_mlid(str, sizeof str, i, nports, mft) == 0)
+ continue;
+ printf("0x%04x %s\n", i, str);
+ n++;
+ }
+ }
+
+ printf("%d %smlids dumped \n", n, dump_all ? "" : "valid ");
+
+ free(mapnd);
+}
+
+int dump_lid(char *str, int str_len, int lid, int valid,
+ ibnd_fabric_t *fabric,
+ int * last_port_lid, int * base_port_lid,
+ uint64_t * portguid)
+{
+ char nd[IB_SMP_DATA_SIZE] = { 0 };
+
+ ibnd_port_t *port = NULL;
+
+ char ntype[50], sguid[30];
+ uint64_t nodeguid;
+ int baselid, lmc, type;
+ char *mapnd = NULL;
+ int rc;
+
+ if (brief) {
+ str[0] = 0;
+ return 0;
+ }
+
+ if (lid <= *last_port_lid) {
+ if (!valid)
+ return snprintf(str, str_len,
+ ": (path #%d - illegal port)",
+ lid - *base_port_lid);
+ else if (!*portguid)
+ return snprintf(str, str_len,
+ ": (path #%d out of %d)",
+ lid - *base_port_lid + 1,
+ *last_port_lid - *base_port_lid + 1);
+ else {
+ return snprintf(str, str_len,
+ ": (path #%d out of %d: portguid %s)",
+ lid - *base_port_lid + 1,
+ *last_port_lid - *base_port_lid + 1,
+ mad_dump_val(IB_NODE_PORT_GUID_F, sguid,
+ sizeof sguid, portguid));
+ }
+ }
+
+ if (!valid)
+ return snprintf(str, str_len, ": (illegal port)");
+
+ *portguid = 0;
+
+ port = ibnd_find_port_lid(fabric, lid);
+ if (!port) {
+ return snprintf(str, str_len, ": (node info not available fabric scan)");
+ }
+
+ nodeguid = port->node->guid;
+ *portguid = port->guid;
+ type = port->node->type;
+
+ baselid = port->base_lid;
+ lmc = port->lmc;
+
+ memcpy(nd, port->node->nodedesc, strlen(port->node->nodedesc));
+
+ if (lmc > 0) {
+ *base_port_lid = baselid;
+ *last_port_lid = baselid + (1 << lmc) - 1;
+ }
+
+ mapnd = remap_node_name(node_name_map, nodeguid, nd);
+
+ rc = snprintf(str, str_len, ": (%s portguid %s: '%s')",
+ mad_dump_val(IB_NODE_TYPE_F, ntype, sizeof ntype,
+ &type), mad_dump_val(IB_NODE_PORT_GUID_F,
+ sguid, sizeof sguid,
+ portguid),
+ mapnd);
+
+ free(mapnd);
+ return rc;
+}
+
+void dump_unicast_tables(ibnd_node_t * node, int startlid, int endlid,
+ struct ibmad_port *mad_port, ibnd_fabric_t *fabric)
+{
+ ib_portid_t * portid = &node->path_portid;
+ char lft[IB_SMP_DATA_SIZE] = { 0 };
+ char nd[IB_SMP_DATA_SIZE] = { 0 };
+ char str[200];
+ uint64_t nodeguid;
+ int block, i, e, top;
+ unsigned nports;
+ int n = 0, startblock, endblock;
+ char *mapnd = NULL;
+ int last_port_lid = 0, base_port_lid = 0;
+ uint64_t portguid = 0;
+
+ mad_decode_field(node->switchinfo, IB_SW_LINEAR_FDB_TOP_F, &top);
+ nodeguid = node->guid;
+ nports = node->numports;
+ memcpy(nd, node->nodedesc, strlen(node->nodedesc));
+
+ if (!endlid || endlid > top)
+ endlid = top;
+
+ if (endlid > IB_MAX_UCAST_LID) {
+ IBWARN("illegal lft top %d, truncate to %d", endlid,
+ IB_MAX_UCAST_LID);
+ endlid = IB_MAX_UCAST_LID;
+ }
+
+ mapnd = remap_node_name(node_name_map, nodeguid, nd);
+
+ printf("Unicast lids [0x%x-0x%x] of switch %s guid 0x%016" PRIx64
+ " (%s):\n", startlid, endlid, portid2str(portid), nodeguid,
+ mapnd);
+
+ DEBUG("Switch top is 0x%x\n", top);
+
+ printf(" Lid Out Destination\n");
+ printf(" Port Info \n");
+ startblock = startlid / IB_SMP_DATA_SIZE;
+ endblock = ALIGN(endlid, IB_SMP_DATA_SIZE) / IB_SMP_DATA_SIZE;
+ for (block = startblock; block < endblock; block++) {
+ int status;
+ DEBUG("reading block %d", block);
+ if (!smp_query_status_via(lft, portid, IB_ATTR_LINEARFORWTBL, block,
+ 0, &status, mad_port)) {
+ fprintf(stderr, "SubnGet(LFT) failed on switch "
+ "'%s' %s Node GUID 0x%"PRIx64
+ " SMA LID %d; MAD status 0x%x AM 0x%x\n",
+ mapnd, portid2str(portid),
+ node->guid, node->smalid,
+ status, block);
+ }
+ i = block * IB_SMP_DATA_SIZE;
+ e = i + IB_SMP_DATA_SIZE;
+ if (i < startlid)
+ i = startlid;
+ if (e > endlid + 1)
+ e = endlid + 1;
+
+ for (; i < e; i++) {
+ unsigned outport = lft[i % IB_SMP_DATA_SIZE];
+ unsigned valid = (outport <= nports);
+
+ if (!valid && !dump_all)
+ continue;
+ dump_lid(str, sizeof str, i, valid, fabric,
+ &last_port_lid, &base_port_lid, &portguid);
+ printf("0x%04x %03u %s\n", i, outport & 0xff, str);
+ n++;
+ }
+ }
+
+ printf("%d %slids dumped \n", n, dump_all ? "" : "valid ");
+ free(mapnd);
+}
+
+void dump_node(ibnd_node_t *node, struct ibmad_port *mad_port,
+ ibnd_fabric_t *fabric)
+{
+ if (multicast)
+ dump_multicast_tables(node, startlid, endlid, mad_port);
+ else
+ dump_unicast_tables(node, startlid, endlid,
+ mad_port, fabric);
+}
+
+void process_switch(ibnd_node_t * node, void *fabric)
+{
+ dump_node(node, srcport, (ibnd_fabric_t *)fabric);
+}
+
+static int process_opt(void *context, int ch, char *optarg)
+{
+ switch (ch) {
+ case 'a':
+ dump_all++;
+ break;
+ case 'M':
+ multicast++;
+ break;
+ case 'n':
+ brief++;
+ break;
+ case 1:
+ node_name_map_file = strdup(optarg);
+ break;
+ default:
+ return -1;
+ }
+ return 0;
+}
+
+int main(int argc, char **argv)
+{
+ int rc = 0;
+ int mgmt_classes[3] =
+ { IB_SMI_CLASS, IB_SMI_DIRECT_CLASS, IB_SA_CLASS };
+
+ struct ibnd_config config = { 0 };
+ ibnd_fabric_t *fabric = NULL;
+
+ const struct ibdiag_opt opts[] = {
+ {"all", 'a', 0, NULL, "show all lids, even invalid entries"},
+ {"no_dests", 'n', 0, NULL,
+ "do not try to resolve destinations"},
+ {"Multicast", 'M', 0, NULL, "show multicast forwarding tables"},
+ {"node-name-map", 1, 1, "<file>", "node name map file"},
+ {0}
+ };
+ char usage_args[] = "[<dest dr_path|lid|guid> [<startlid> [<endlid>]]]";
+ const char *usage_examples[] = {
+ " -- Unicast examples:",
+ "-a\t# same, but dump all lids, even with invalid out ports",
+ "-n\t# simple dump format - no destination resolving",
+ "10\t# dump lids starting from 10",
+ "0x10 0x20\t# dump lid range",
+ " -- Multicast examples:",
+ "-M\t# dump all non empty mlids of switch with lid 4",
+ "-M 0xc010 0xc020\t# same, but with range",
+ "-M -n\t# simple dump format",
+ NULL,
+ };
+
+ ibdiag_process_opts(argc, argv, &config, "KGDLs", opts, process_opt,
+ usage_args, usage_examples);
+
+ argc -= optind;
+ argv += optind;
+
+ if (argc > 0)
+ startlid = strtoul(argv[0], 0, 0);
+ if (argc > 1)
+ endlid = strtoul(argv[1], 0, 0);
+
+ node_name_map = open_node_name_map(node_name_map_file);
+
+ if (ibd_timeout)
+ config.timeout_ms = ibd_timeout;
+
+ config.flags = ibd_ibnetdisc_flags;
+ config.mkey = ibd_mkey;
+
+ if ((fabric = ibnd_discover_fabric(ibd_ca, ibd_ca_port, NULL,
+ &config)) != NULL) {
+
+ srcport = mad_rpc_open_port(ibd_ca, ibd_ca_port, mgmt_classes, 3);
+ if (!srcport) {
+ fprintf(stderr,
+ "Failed to open '%s' port '%d'\n", ibd_ca, ibd_ca_port);
+ rc = -1;
+ goto Exit;
+ }
+ smp_mkey_set(srcport, ibd_mkey);
+
+ if (ibd_timeout) {
+ mad_rpc_set_timeout(srcport, ibd_timeout);
+ }
+
+ ibnd_iter_nodes_type(fabric, process_switch, IB_NODE_SWITCH, fabric);
+
+ mad_rpc_close_port(srcport);
+
+ } else {
+ fprintf(stderr, "Failed to discover fabric\n");
+ rc = -1;
+ }
+Exit:
+ ibnd_destroy_fabric(fabric);
+
+ close_node_name_map(node_name_map);
+ exit(rc);
+}
diff --git a/contrib/ofed/infiniband-diags/src/ibaddr.c b/contrib/ofed/infiniband-diags/src/ibaddr.c
new file mode 100644
index 0000000..1a721d0
--- /dev/null
+++ b/contrib/ofed/infiniband-diags/src/ibaddr.c
@@ -0,0 +1,168 @@
+/*
+ * Copyright (c) 2004-2009 Voltaire Inc. All rights reserved.
+ * Copyright (c) 2011 Mellanox Technologies LTD. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+#if HAVE_CONFIG_H
+# include <config.h>
+#endif /* HAVE_CONFIG_H */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <getopt.h>
+#include <arpa/inet.h>
+
+#include <infiniband/umad.h>
+#include <infiniband/mad.h>
+
+#include "ibdiag_common.h"
+
+struct ibmad_port *srcport;
+
+static int ib_resolve_addr(ib_portid_t * portid, int portnum, int show_lid,
+ int show_gid)
+{
+ char gid_str[INET6_ADDRSTRLEN];
+ uint8_t portinfo[IB_SMP_DATA_SIZE] = { 0 };
+ uint8_t nodeinfo[IB_SMP_DATA_SIZE] = { 0 };
+ uint64_t guid, prefix;
+ ibmad_gid_t gid;
+ int lmc;
+
+ if (!smp_query_via(nodeinfo, portid, IB_ATTR_NODE_INFO, 0, 0, srcport))
+ return -1;
+
+ if (!smp_query_via(portinfo, portid, IB_ATTR_PORT_INFO, portnum, 0,
+ srcport))
+ return -1;
+
+ mad_decode_field(portinfo, IB_PORT_LID_F, &portid->lid);
+ mad_decode_field(portinfo, IB_PORT_GID_PREFIX_F, &prefix);
+ mad_decode_field(portinfo, IB_PORT_LMC_F, &lmc);
+ mad_decode_field(nodeinfo, IB_NODE_PORT_GUID_F, &guid);
+
+ mad_encode_field(gid, IB_GID_PREFIX_F, &prefix);
+ mad_encode_field(gid, IB_GID_GUID_F, &guid);
+
+ if (show_gid) {
+ printf("GID %s ", inet_ntop(AF_INET6, gid, gid_str,
+ sizeof gid_str));
+ }
+
+ if (show_lid > 0)
+ printf("LID start 0x%x end 0x%x", portid->lid,
+ portid->lid + (1 << lmc) - 1);
+ else if (show_lid < 0)
+ printf("LID start %u end %u", portid->lid,
+ portid->lid + (1 << lmc) - 1);
+ printf("\n");
+ return 0;
+}
+
+static int show_lid, show_gid;
+
+static int process_opt(void *context, int ch, char *optarg)
+{
+ switch (ch) {
+ case 'g':
+ show_gid = 1;
+ break;
+ case 'l':
+ show_lid++;
+ break;
+ case 'L':
+ show_lid = -100;
+ break;
+ default:
+ return -1;
+ }
+ return 0;
+}
+
+int main(int argc, char **argv)
+{
+ int mgmt_classes[3] =
+ { IB_SMI_CLASS, IB_SMI_DIRECT_CLASS, IB_SA_CLASS };
+ ib_portid_t portid = { 0 };
+ int port = 0;
+
+ const struct ibdiag_opt opts[] = {
+ {"gid_show", 'g', 0, NULL, "show gid address only"},
+ {"lid_show", 'l', 0, NULL, "show lid range only"},
+ {"Lid_show", 'L', 0, NULL, "show lid range (in decimal) only"},
+ {0}
+ };
+ char usage_args[] = "[<lid|dr_path|guid>]";
+ const char *usage_examples[] = {
+ "\t\t# local port's address",
+ "32\t\t# show lid range and gid of lid 32",
+ "-G 0x8f1040023\t# same but using guid address",
+ "-l 32\t\t# show lid range only",
+ "-L 32\t\t# show decimal lid range only",
+ "-g 32\t\t# show gid address only",
+ NULL
+ };
+
+ ibdiag_process_opts(argc, argv, NULL, "KL", opts, process_opt,
+ usage_args, usage_examples);
+
+ argc -= optind;
+ argv += optind;
+
+ if (argc > 1)
+ port = strtoul(argv[1], 0, 0);
+
+ if (!show_lid && !show_gid)
+ show_lid = show_gid = 1;
+
+ srcport = mad_rpc_open_port(ibd_ca, ibd_ca_port, mgmt_classes, 3);
+ if (!srcport)
+ IBEXIT("Failed to open '%s' port '%d'", ibd_ca, ibd_ca_port);
+
+ smp_mkey_set(srcport, ibd_mkey);
+
+ if (argc) {
+ if (resolve_portid_str(ibd_ca, ibd_ca_port, &portid, argv[0],
+ ibd_dest_type, ibd_sm_id, srcport) < 0)
+ IBEXIT("can't resolve destination port %s", argv[0]);
+ } else {
+ if (resolve_self(ibd_ca, ibd_ca_port, &portid, &port, NULL) < 0)
+ IBEXIT("can't resolve self port %s", argv[0]);
+ }
+
+ if (ib_resolve_addr(&portid, port, show_lid, show_gid) < 0)
+ IBEXIT("can't resolve requested address");
+
+ mad_rpc_close_port(srcport);
+ exit(0);
+}
diff --git a/contrib/ofed/infiniband-diags/src/ibcacheedit.c b/contrib/ofed/infiniband-diags/src/ibcacheedit.c
new file mode 100644
index 0000000..b520839
--- /dev/null
+++ b/contrib/ofed/infiniband-diags/src/ibcacheedit.c
@@ -0,0 +1,356 @@
+/*
+ * Copyright (c) 2010 Lawrence Livermore National Lab. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+#if HAVE_CONFIG_H
+# include <config.h>
+#endif /* HAVE_CONFIG_H */
+
+#define _GNU_SOURCE
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <getopt.h>
+#include <inttypes.h>
+
+#include <infiniband/mad.h>
+#include <infiniband/ibnetdisc.h>
+
+#include "ibdiag_common.h"
+
+uint64_t switchguid_before = 0;
+uint64_t switchguid_after = 0;
+int switchguid_flag = 0;
+
+uint64_t caguid_before = 0;
+uint64_t caguid_after = 0;
+int caguid_flag = 0;
+
+uint64_t sysimgguid_before = 0;
+uint64_t sysimgguid_after = 0;
+int sysimgguid_flag = 0;
+
+uint64_t portguid_nodeguid = 0;
+uint64_t portguid_before = 0;
+uint64_t portguid_after = 0;
+int portguid_flag = 0;
+
+struct guids {
+ uint64_t searchguid;
+ int searchguid_found;
+ uint64_t before;
+ uint64_t after;
+ int found;
+};
+
+static int parse_beforeafter(char *arg, uint64_t *before, uint64_t *after)
+{
+ char *ptr;
+ char *before_str;
+ char *after_str;
+
+ ptr = strchr(optarg, ':');
+ if (!ptr || !(*(ptr + 1))) {
+ fprintf(stderr, "invalid input '%s'\n", arg);
+ return -1;
+ }
+ (*ptr) = '\0';
+ before_str = arg;
+ after_str = ptr + 1;
+
+ (*before) = strtoull(before_str, 0, 0);
+ (*after) = strtoull(after_str, 0, 0);
+ return 0;
+}
+
+static int parse_guidbeforeafter(char *arg,
+ uint64_t *guid,
+ uint64_t *before,
+ uint64_t *after)
+{
+ char *ptr1;
+ char *ptr2;
+ char *guid_str;
+ char *before_str;
+ char *after_str;
+
+ ptr1 = strchr(optarg, ':');
+ if (!ptr1 || !(*(ptr1 + 1))) {
+ fprintf(stderr, "invalid input '%s'\n", arg);
+ return -1;
+ }
+ guid_str = arg;
+ before_str = ptr1 + 1;
+
+ ptr2 = strchr(before_str, ':');
+ if (!ptr2 || !(*(ptr2 + 1))) {
+ fprintf(stderr, "invalid input '%s'\n", arg);
+ return -1;
+ }
+ (*ptr1) = '\0';
+ (*ptr2) = '\0';
+ after_str = ptr2 + 1;
+
+ (*guid) = strtoull(guid_str, 0, 0);
+ (*before) = strtoull(before_str, 0, 0);
+ (*after) = strtoull(after_str, 0, 0);
+ return 0;
+}
+
+static int process_opt(void *context, int ch, char *optarg)
+{
+ switch (ch) {
+ case 1:
+ if (parse_beforeafter(optarg,
+ &switchguid_before,
+ &switchguid_after) < 0)
+ return -1;
+ switchguid_flag++;
+ break;
+ case 2:
+ if (parse_beforeafter(optarg,
+ &caguid_before,
+ &caguid_after) < 0)
+ return -1;
+ caguid_flag++;
+ break;
+ case 3:
+ if (parse_beforeafter(optarg,
+ &sysimgguid_before,
+ &sysimgguid_after) < 0)
+ return -1;
+ sysimgguid_flag++;
+ break;
+ case 4:
+ if (parse_guidbeforeafter(optarg,
+ &portguid_nodeguid,
+ &portguid_before,
+ &portguid_after) < 0)
+ return -1;
+ portguid_flag++;
+ break;
+ default:
+ return -1;
+ }
+
+ return 0;
+}
+
+static void update_switchportguids(ibnd_node_t *node)
+{
+ ibnd_port_t *port;
+ int p;
+
+ for (p = 0; p <= node->numports; p++) {
+ port = node->ports[p];
+ if (port)
+ port->guid = node->guid;
+ }
+}
+
+static void replace_node_guid(ibnd_node_t *node, void *user_data)
+{
+ struct guids *guids;
+
+ guids = (struct guids *)user_data;
+
+ if (node->guid == guids->before) {
+
+ node->guid = guids->after;
+
+ /* port guids are identical to switch guids on
+ * switches, so update port guids too
+ */
+ if (node->type == IB_NODE_SWITCH)
+ update_switchportguids(node);
+
+ guids->found++;
+ }
+}
+
+static void replace_sysimgguid(ibnd_node_t *node, void *user_data)
+{
+ struct guids *guids;
+ uint64_t sysimgguid;
+
+ guids = (struct guids *)user_data;
+
+ sysimgguid = mad_get_field64(node->info, 0, IB_NODE_SYSTEM_GUID_F);
+ if (sysimgguid == guids->before) {
+ mad_set_field64(node->info, 0, IB_NODE_SYSTEM_GUID_F,
+ guids->after);
+ guids->found++;
+ }
+}
+
+static void replace_portguid(ibnd_node_t *node, void *user_data)
+{
+ struct guids *guids;
+
+ guids = (struct guids *)user_data;
+
+ if (node->guid != guids->searchguid)
+ return;
+
+ guids->searchguid_found++;
+
+ if (node->type == IB_NODE_SWITCH) {
+ /* port guids are identical to switch guids on
+ * switches, so update switch guid too
+ */
+ if (node->guid == guids->before) {
+ node->guid = guids->after;
+ update_switchportguids(node);
+ guids->found++;
+ }
+ }
+ else {
+ ibnd_port_t *port;
+ int p;
+
+ for (p = 1; p <= node->numports; p++) {
+ port = node->ports[p];
+ if (port
+ && port->guid == guids->before) {
+ port->guid = guids->after;
+ guids->found++;
+ break;
+ }
+ }
+ }
+}
+
+int main(int argc, char **argv)
+{
+ ibnd_fabric_t *fabric = NULL;
+ char *orig_cache_file = NULL;
+ char *new_cache_file = NULL;
+ struct guids guids;
+
+ const struct ibdiag_opt opts[] = {
+ {"switchguid", 1, 1, "BEFOREGUID:AFTERGUID",
+ "Specify before and after switchguid to edit"},
+ {"caguid", 2, 1, "BEFOREGUID:AFTERGUID",
+ "Specify before and after caguid to edit"},
+ {"sysimgguid", 3, 1, "BEFOREGUID:AFTERGUID",
+ "Specify before and after sysimgguid to edit"},
+ {"portguid", 4, 1, "NODEGUID:BEFOREGUID:AFTERGUID",
+ "Specify before and after port guid to edit"},
+ {0}
+ };
+ char *usage_args = "<orig.cache> <new.cache>";
+
+ ibdiag_process_opts(argc, argv, NULL, "CDdeGKLPstvy",
+ opts, process_opt, usage_args,
+ NULL);
+
+ argc -= optind;
+ argv += optind;
+
+ orig_cache_file = argv[0];
+ new_cache_file = argv[1];
+
+ if (!orig_cache_file)
+ IBEXIT("original cache file not specified");
+
+ if (!new_cache_file)
+ IBEXIT("new cache file not specified");
+
+ if ((fabric = ibnd_load_fabric(orig_cache_file, 0)) == NULL)
+ IBEXIT("loading original cached fabric failed");
+
+ if (switchguid_flag) {
+ guids.before = switchguid_before;
+ guids.after = switchguid_after;
+ guids.found = 0;
+ ibnd_iter_nodes_type(fabric,
+ replace_node_guid,
+ IB_NODE_SWITCH,
+ &guids);
+
+ if (!guids.found)
+ IBEXIT("switchguid = %" PRIx64 " not found",
+ switchguid_before);
+ }
+
+ if (caguid_flag) {
+ guids.before = caguid_before;
+ guids.after = caguid_after;
+ guids.found = 0;
+ ibnd_iter_nodes_type(fabric,
+ replace_node_guid,
+ IB_NODE_CA,
+ &guids);
+
+ if (!guids.found)
+ IBEXIT("caguid = %" PRIx64 " not found",
+ caguid_before);
+ }
+
+ if (sysimgguid_flag) {
+ guids.before = sysimgguid_before;
+ guids.after = sysimgguid_after;
+ guids.found = 0;
+ ibnd_iter_nodes(fabric,
+ replace_sysimgguid,
+ &guids);
+
+ if (!guids.found)
+ IBEXIT("sysimgguid = %" PRIx64 " not found",
+ sysimgguid_before);
+ }
+
+ if (portguid_flag) {
+ guids.searchguid = portguid_nodeguid;
+ guids.searchguid_found = 0;
+ guids.before = portguid_before;
+ guids.after = portguid_after;
+ guids.found = 0;
+ ibnd_iter_nodes(fabric,
+ replace_portguid,
+ &guids);
+
+ if (!guids.searchguid_found)
+ IBEXIT("nodeguid = %" PRIx64 " not found",
+ portguid_nodeguid);
+
+ if (!guids.found)
+ IBEXIT("portguid = %" PRIx64 " not found",
+ portguid_before);
+ }
+
+ if (ibnd_cache_fabric(fabric, new_cache_file, 0) < 0)
+ IBEXIT("caching new cache data failed");
+
+ ibnd_destroy_fabric(fabric);
+ exit(0);
+}
diff --git a/contrib/ofed/infiniband-diags/src/ibccconfig.c b/contrib/ofed/infiniband-diags/src/ibccconfig.c
new file mode 100644
index 0000000..4b68591
--- /dev/null
+++ b/contrib/ofed/infiniband-diags/src/ibccconfig.c
@@ -0,0 +1,639 @@
+/*
+ * Copyright (c) 2004-2009 Voltaire Inc. All rights reserved.
+ * Copyright (c) 2011 Mellanox Technologies LTD. All rights reserved.
+ * Copyright (c) 2011 Lawrence Livermore National Lab. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+#if HAVE_CONFIG_H
+# include <config.h>
+#endif /* HAVE_CONFIG_H */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <string.h>
+#include <getopt.h>
+#include <errno.h>
+#include <netinet/in.h>
+#include <limits.h>
+#include <ctype.h>
+
+#define __STDC_FORMAT_MACROS
+#include <inttypes.h>
+
+#include <infiniband/mad.h>
+
+#include "ibdiag_common.h"
+
+struct ibmad_port *srcport;
+
+static ibmad_gid_t dgid;
+static int with_grh;
+
+static op_fn_t congestion_key_info;
+static op_fn_t switch_congestion_setting;
+static op_fn_t switch_port_congestion_setting;
+static op_fn_t ca_congestion_setting;
+static op_fn_t congestion_control_table;
+
+static const match_rec_t match_tbl[] = {
+ {"CongestionKeyInfo", "CK", congestion_key_info, 0,
+ "<cckey> <cckeyprotectbit> <cckeyleaseperiod> <cckeyviolations>"},
+ {"SwitchCongestionSetting", "SS", switch_congestion_setting, 0,
+ "<controlmap> <victimmask> <creditmask> <threshold> <packetsize> "
+ "<csthreshold> <csreturndelay> <markingrate>"},
+ {"SwitchPortCongestionSetting", "SP", switch_port_congestion_setting, 1,
+ "<valid> <control_type> <threshold> <packet_size> <cong_parm_marking_rate>"},
+ {"CACongestionSetting", "CS", ca_congestion_setting, 0,
+ "<port_control> <control_map> <ccti_timer> <ccti_increase> "
+ "<trigger_threshold> <ccti_min>"},
+ {"CongestionControlTable", "CT", congestion_control_table, 0,
+ "<cctilimit> <index> <cctentry> <cctentry> ..."},
+ {0}
+};
+
+uint64_t cckey = 0;
+
+/*******************************************/
+static char *parselonglongint(char *arg, uint64_t *val)
+{
+ char *endptr = NULL;
+
+ errno = 0;
+ *val = strtoull(arg, &endptr, 0);
+ if ((endptr && *endptr != '\0')
+ || errno != 0) {
+ if (errno == ERANGE)
+ return "value out of range";
+ return "invalid integer input";
+ }
+
+ return NULL;
+}
+
+static char *parseint(char *arg, uint32_t *val, int hexonly)
+{
+ char *endptr = NULL;
+
+ errno = 0;
+ *val = strtoul(arg, &endptr, hexonly ? 16 : 0);
+ if ((endptr && *endptr != '\0')
+ || errno != 0) {
+ if (errno == ERANGE)
+ return "value out of range";
+ return "invalid integer input";
+ }
+
+ return NULL;
+}
+
+static char *congestion_key_info(ib_portid_t * dest, char **argv, int argc)
+{
+ uint8_t rcv[IB_CC_DATA_SZ] = { 0 };
+ uint8_t payload[IB_CC_DATA_SZ] = { 0 };
+ uint64_t cc_key;
+ uint32_t cc_keyprotectbit;
+ uint32_t cc_keyleaseperiod;
+ uint32_t cc_keyviolations;
+ char *errstr;
+
+ if (argc != 4)
+ return "invalid number of parameters for CongestionKeyInfo";
+
+ if ((errstr = parselonglongint(argv[0], &cc_key)))
+ return errstr;
+ if ((errstr = parseint(argv[1], &cc_keyprotectbit, 0)))
+ return errstr;
+ if ((errstr = parseint(argv[2], &cc_keyleaseperiod, 0)))
+ return errstr;
+ if ((errstr = parseint(argv[3], &cc_keyviolations, 0)))
+ return errstr;
+
+ if (cc_keyprotectbit != 0 && cc_keyprotectbit != 1)
+ return "invalid cc_keyprotectbit value";
+
+ if (cc_keyleaseperiod > USHRT_MAX)
+ return "invalid cc_keyleaseperiod value";
+
+ if (cc_keyviolations > USHRT_MAX)
+ return "invalid cc_keyviolations value";
+
+ mad_set_field64(payload,
+ 0,
+ IB_CC_CONGESTION_KEY_INFO_CC_KEY_F,
+ cc_key);
+
+ mad_encode_field(payload,
+ IB_CC_CONGESTION_KEY_INFO_CC_KEY_PROTECT_BIT_F,
+ &cc_keyprotectbit);
+
+ mad_encode_field(payload,
+ IB_CC_CONGESTION_KEY_INFO_CC_KEY_LEASE_PERIOD_F,
+ &cc_keyleaseperiod);
+
+ /* spec says "setting the counter to a value other than zero results
+ * in the counter being left unchanged. So if user wants no change,
+ * they gotta input non-zero
+ */
+ mad_encode_field(payload,
+ IB_CC_CONGESTION_KEY_INFO_CC_KEY_VIOLATIONS_F,
+ &cc_keyviolations);
+
+ if (!cc_config_status_via(payload, rcv, dest, IB_CC_ATTR_CONGESTION_KEY_INFO,
+ 0, 0, NULL, srcport, cckey))
+ return "congestion key info config failed";
+
+ return NULL;
+}
+
+
+/* parse like it's a hypothetical 256 bit hex code */
+static char *parse256(char *arg, uint8_t *buf)
+{
+ int numdigits = 0;
+ int startindex;
+ char *ptr;
+ int i;
+
+ if (!strncmp(arg, "0x", 2) || !strncmp(arg, "0X", 2))
+ arg += 2;
+
+ for (ptr = arg; *ptr; ptr++) {
+ if (!isxdigit(*ptr))
+ return "invalid hex digit read";
+ numdigits++;
+ }
+
+ if (numdigits > 64)
+ return "hex code too long";
+
+ /* we need to imagine that this is like a 256-bit int stored
+ * in big endian. So we need to find the first index
+ * point where the user's input would start in our array.
+ */
+ startindex = 32 - ((numdigits - 1) / 2) - 1;
+
+ for (i = startindex; i <= 31; i++) {
+ char tmp[3] = { 0 };
+ uint32_t tmpint;
+ char *errstr;
+
+ /* I can't help but think there is a strtoX that
+ * will do this for me, but I can't find it.
+ */
+ if (i == startindex && numdigits % 2) {
+ memcpy(tmp, arg, 1);
+ arg++;
+ }
+ else {
+ memcpy(tmp, arg, 2);
+ arg += 2;
+ }
+
+ if ((errstr = parseint(tmp, &tmpint, 1)))
+ return errstr;
+ buf[i] = tmpint;
+ }
+
+ return NULL;
+}
+
+static char *parsecct(char *arg, uint32_t *shift, uint32_t *multiplier)
+{
+ char buf[1024] = { 0 };
+ char *errstr;
+ char *ptr;
+
+ strcpy(buf, arg);
+
+ if (!(ptr = strchr(buf, ':')))
+ return "ccts are formatted shift:multiplier";
+
+ *ptr = '\0';
+ ptr++;
+
+ if ((errstr = parseint(buf, shift, 0)))
+ return errstr;
+
+ if ((errstr = parseint(ptr, multiplier, 0)))
+ return errstr;
+
+ return NULL;
+}
+
+static char *switch_congestion_setting(ib_portid_t * dest, char **argv, int argc)
+{
+ uint8_t rcv[IB_CC_DATA_SZ] = { 0 };
+ uint8_t payload[IB_CC_DATA_SZ] = { 0 };
+ uint32_t control_map;
+ uint8_t victim_mask[32] = { 0 };
+ uint8_t credit_mask[32] = { 0 };
+ uint32_t threshold;
+ uint32_t packet_size;
+ uint32_t cs_threshold;
+ uint32_t cs_returndelay_s;
+ uint32_t cs_returndelay_m;
+ uint32_t cs_returndelay;
+ uint32_t marking_rate;
+ char *errstr;
+
+ if (argc != 8)
+ return "invalid number of parameters for SwitchCongestionSetting";
+
+ if ((errstr = parseint(argv[0], &control_map, 0)))
+ return errstr;
+
+ if ((errstr = parse256(argv[1], victim_mask)))
+ return errstr;
+
+ if ((errstr = parse256(argv[2], credit_mask)))
+ return errstr;
+
+ if ((errstr = parseint(argv[3], &threshold, 0)))
+ return errstr;
+
+ if ((errstr = parseint(argv[4], &packet_size, 0)))
+ return errstr;
+
+ if ((errstr = parseint(argv[5], &cs_threshold, 0)))
+ return errstr;
+
+ if ((errstr = parsecct(argv[6], &cs_returndelay_s, &cs_returndelay_m)))
+ return errstr;
+
+ cs_returndelay = cs_returndelay_m;
+ cs_returndelay |= (cs_returndelay_s << 14);
+
+ if ((errstr = parseint(argv[7], &marking_rate, 0)))
+ return errstr;
+
+ mad_encode_field(payload,
+ IB_CC_SWITCH_CONGESTION_SETTING_CONTROL_MAP_F,
+ &control_map);
+
+ mad_set_array(payload,
+ 0,
+ IB_CC_SWITCH_CONGESTION_SETTING_VICTIM_MASK_F,
+ victim_mask);
+
+ mad_set_array(payload,
+ 0,
+ IB_CC_SWITCH_CONGESTION_SETTING_CREDIT_MASK_F,
+ credit_mask);
+
+ mad_encode_field(payload,
+ IB_CC_SWITCH_CONGESTION_SETTING_THRESHOLD_F,
+ &threshold);
+
+ mad_encode_field(payload,
+ IB_CC_SWITCH_CONGESTION_SETTING_PACKET_SIZE_F,
+ &packet_size);
+
+ mad_encode_field(payload,
+ IB_CC_SWITCH_CONGESTION_SETTING_CS_THRESHOLD_F,
+ &cs_threshold);
+
+ mad_encode_field(payload,
+ IB_CC_SWITCH_CONGESTION_SETTING_CS_RETURN_DELAY_F,
+ &cs_returndelay);
+
+ mad_encode_field(payload,
+ IB_CC_SWITCH_CONGESTION_SETTING_MARKING_RATE_F,
+ &marking_rate);
+
+ if (!cc_config_status_via(payload, rcv, dest, IB_CC_ATTR_SWITCH_CONGESTION_SETTING,
+ 0, 0, NULL, srcport, cckey))
+ return "switch congestion setting config failed";
+
+ return NULL;
+}
+
+static char *switch_port_congestion_setting(ib_portid_t * dest, char **argv, int argc)
+{
+ uint8_t rcv[IB_CC_DATA_SZ] = { 0 };
+ uint8_t payload[IB_CC_DATA_SZ] = { 0 };
+ uint8_t data[IB_CC_DATA_SZ] = { 0 };
+ uint32_t portnum;
+ uint32_t valid;
+ uint32_t control_type;
+ uint32_t threshold;
+ uint32_t packet_size;
+ uint32_t cong_parm_marking_rate;
+ uint32_t type;
+ uint32_t numports;
+ uint8_t *ptr;
+ char *errstr;
+
+ if (argc != 6)
+ return "invalid number of parameters for SwitchPortCongestion";
+
+ if ((errstr = parseint(argv[0], &portnum, 0)))
+ return errstr;
+
+ if ((errstr = parseint(argv[1], &valid, 0)))
+ return errstr;
+
+ if ((errstr = parseint(argv[2], &control_type, 0)))
+ return errstr;
+
+ if ((errstr = parseint(argv[3], &threshold, 0)))
+ return errstr;
+
+ if ((errstr = parseint(argv[4], &packet_size, 0)))
+ return errstr;
+
+ if ((errstr = parseint(argv[5], &cong_parm_marking_rate, 0)))
+ return errstr;
+
+ /* Figure out number of ports first */
+ if (!smp_query_via(data, dest, IB_ATTR_NODE_INFO, 0, 0, srcport))
+ return "node info config failed";
+
+ mad_decode_field((uint8_t *)data, IB_NODE_TYPE_F, &type);
+ mad_decode_field((uint8_t *)data, IB_NODE_NPORTS_F, &numports);
+
+ if (type != IB_NODE_SWITCH)
+ return "destination not a switch";
+
+ if (portnum > numports)
+ return "invalid port number specified";
+
+ /* We are modifying only 1 port, so get the current config */
+ if (!cc_query_status_via(payload, dest, IB_CC_ATTR_SWITCH_PORT_CONGESTION_SETTING,
+ portnum / 32, 0, NULL, srcport, cckey))
+ return "switch port congestion setting query failed";
+
+ ptr = payload + (((portnum % 32) * 4));
+
+ mad_encode_field(ptr,
+ IB_CC_SWITCH_PORT_CONGESTION_SETTING_ELEMENT_VALID_F,
+ &valid);
+
+ mad_encode_field(ptr,
+ IB_CC_SWITCH_PORT_CONGESTION_SETTING_ELEMENT_CONTROL_TYPE_F,
+ &control_type);
+
+ mad_encode_field(ptr,
+ IB_CC_SWITCH_PORT_CONGESTION_SETTING_ELEMENT_THRESHOLD_F,
+ &threshold);
+
+ mad_encode_field(ptr,
+ IB_CC_SWITCH_PORT_CONGESTION_SETTING_ELEMENT_PACKET_SIZE_F,
+ &packet_size);
+
+ mad_encode_field(ptr,
+ IB_CC_SWITCH_PORT_CONGESTION_SETTING_ELEMENT_CONG_PARM_MARKING_RATE_F,
+ &cong_parm_marking_rate);
+
+ if (!cc_config_status_via(payload, rcv, dest, IB_CC_ATTR_SWITCH_PORT_CONGESTION_SETTING,
+ portnum / 32, 0, NULL, srcport, cckey))
+ return "switch port congestion setting config failed";
+
+ return NULL;
+}
+
+static char *ca_congestion_setting(ib_portid_t * dest, char **argv, int argc)
+{
+ uint8_t rcv[IB_CC_DATA_SZ] = { 0 };
+ uint8_t payload[IB_CC_DATA_SZ] = { 0 };
+ uint32_t port_control;
+ uint32_t control_map;
+ uint32_t ccti_timer;
+ uint32_t ccti_increase;
+ uint32_t trigger_threshold;
+ uint32_t ccti_min;
+ char *errstr;
+ int i;
+
+ if (argc != 6)
+ return "invalid number of parameters for CACongestionSetting";
+
+ if ((errstr = parseint(argv[0], &port_control, 0)))
+ return errstr;
+
+ if ((errstr = parseint(argv[1], &control_map, 0)))
+ return errstr;
+
+ if ((errstr = parseint(argv[2], &ccti_timer, 0)))
+ return errstr;
+
+ if ((errstr = parseint(argv[3], &ccti_increase, 0)))
+ return errstr;
+
+ if ((errstr = parseint(argv[4], &trigger_threshold, 0)))
+ return errstr;
+
+ if ((errstr = parseint(argv[5], &ccti_min, 0)))
+ return errstr;
+
+ mad_encode_field(payload,
+ IB_CC_CA_CONGESTION_SETTING_PORT_CONTROL_F,
+ &port_control);
+
+ mad_encode_field(payload,
+ IB_CC_CA_CONGESTION_SETTING_CONTROL_MAP_F,
+ &control_map);
+
+ for (i = 0; i < 16; i++) {
+ uint8_t *ptr;
+
+ if (!(control_map & (0x1 << i)))
+ continue;
+
+ ptr = payload + 2 + 2 + i * 8;
+
+ mad_encode_field(ptr,
+ IB_CC_CA_CONGESTION_ENTRY_CCTI_TIMER_F,
+ &ccti_timer);
+
+ mad_encode_field(ptr,
+ IB_CC_CA_CONGESTION_ENTRY_CCTI_INCREASE_F,
+ &ccti_increase);
+
+ mad_encode_field(ptr,
+ IB_CC_CA_CONGESTION_ENTRY_TRIGGER_THRESHOLD_F,
+ &trigger_threshold);
+
+ mad_encode_field(ptr,
+ IB_CC_CA_CONGESTION_ENTRY_CCTI_MIN_F,
+ &ccti_min);
+ }
+
+ if (!cc_config_status_via(payload, rcv, dest, IB_CC_ATTR_CA_CONGESTION_SETTING,
+ 0, 0, NULL, srcport, cckey))
+ return "ca congestion setting config failed";
+
+ return NULL;
+}
+
+static char *congestion_control_table(ib_portid_t * dest, char **argv, int argc)
+{
+ uint8_t rcv[IB_CC_DATA_SZ] = { 0 };
+ uint8_t payload[IB_CC_DATA_SZ] = { 0 };
+ uint32_t ccti_limit;
+ uint32_t index;
+ uint32_t cctshifts[64];
+ uint32_t cctmults[64];
+ char *errstr;
+ int i;
+
+ if (argc < 2 || argc > 66)
+ return "invalid number of parameters for CongestionControlTable";
+
+ if ((errstr = parseint(argv[0], &ccti_limit, 0)))
+ return errstr;
+
+ if ((errstr = parseint(argv[1], &index, 0)))
+ return errstr;
+
+ if (ccti_limit && (ccti_limit + 1) != (index * 64 + (argc - 2)))
+ return "invalid number of cct entries input given ccti_limit and index";
+
+ for (i = 0; i < (argc - 2); i++) {
+ if ((errstr = parsecct(argv[i + 2], &cctshifts[i], &cctmults[i])))
+ return errstr;
+ }
+
+ mad_encode_field(payload,
+ IB_CC_CONGESTION_CONTROL_TABLE_CCTI_LIMIT_F,
+ &ccti_limit);
+
+ for (i = 0; i < (argc - 2); i++) {
+ mad_encode_field(payload + 4 + i * 2,
+ IB_CC_CONGESTION_CONTROL_TABLE_ENTRY_CCT_SHIFT_F,
+ &cctshifts[i]);
+
+ mad_encode_field(payload + 4 + i * 2,
+ IB_CC_CONGESTION_CONTROL_TABLE_ENTRY_CCT_MULTIPLIER_F,
+ &cctmults[i]);
+ }
+
+ if (!cc_config_status_via(payload, rcv, dest, IB_CC_ATTR_CONGESTION_CONTROL_TABLE,
+ index, 0, NULL, srcport, cckey))
+ return "congestion control table config failed";
+
+ return NULL;
+}
+
+static int process_opt(void *context, int ch, char *optarg)
+{
+ switch (ch) {
+ case 'c':
+ cckey = (uint64_t) strtoull(optarg, 0, 0);
+ break;
+ case 25:
+ if (!inet_pton(AF_INET6, optarg, &dgid)) {
+ fprintf(stderr, "dgid format is wrong!\n");
+ ibdiag_show_usage();
+ return 1;
+ }
+ with_grh = 1;
+ break;
+ default:
+ return -1;
+ }
+ return 0;
+}
+
+int main(int argc, char **argv)
+{
+ char usage_args[1024];
+ int mgmt_classes[3] = { IB_SMI_CLASS, IB_SA_CLASS, IB_CC_CLASS };
+ ib_portid_t portid = { 0 };
+ char *err;
+ op_fn_t *fn;
+ const match_rec_t *r;
+ int n;
+
+ const struct ibdiag_opt opts[] = {
+ {"cckey", 'c', 1, "<key>", "CC key"},
+ {"dgid", 25, 1, NULL, "remote gid (IPv6 format)"},
+ {0}
+ };
+ const char *usage_examples[] = {
+ "SwitchCongestionSetting 2 0x1F 0x1FFFFFFFFF 0x0 0xF 8 0 0:0 1\t# Configure Switch Congestion Settings",
+ "CACongestionSetting 1 0 0x3 150 1 0 0\t\t# Configure CA Congestion Settings to SL 0 and SL 1",
+ "CACongestionSetting 1 0 0x4 200 1 0 0\t\t# Configure CA Congestion Settings to SL 2",
+ "CongestionControlTable 1 63 0 0:0 0:1 ...\t# Configure first block of Congestion Control Table",
+ "CongestionControlTable 1 127 0 0:64 0:65 ...\t# Configure second block of Congestion Control Table",
+ NULL
+ };
+
+ n = sprintf(usage_args, "[-c key] <op> <lid|guid>\n"
+ "\nWARNING -- You should understand what you are "
+ "doing before using this tool. Misuse of this "
+ "tool could result in a broken fabric.\n"
+ "\nSupported ops (and aliases, case insensitive):\n");
+ for (r = match_tbl; r->name; r++) {
+ n += snprintf(usage_args + n, sizeof(usage_args) - n,
+ " %s (%s) <lid|guid>%s%s%s\n", r->name,
+ r->alias ? r->alias : "",
+ r->opt_portnum ? " <portnum>" : "",
+ r->ops_extra ? " " : "",
+ r->ops_extra ? r->ops_extra : "");
+ if (n >= sizeof(usage_args))
+ exit(-1);
+ }
+
+ ibdiag_process_opts(argc, argv, NULL, "DK", opts, process_opt,
+ usage_args, usage_examples);
+
+ argc -= optind;
+ argv += optind;
+
+ if (argc < 2)
+ ibdiag_show_usage();
+
+ if (!(fn = match_op(match_tbl, argv[0])))
+ IBEXIT("operation '%s' not supported", argv[0]);
+
+ srcport = mad_rpc_open_port(ibd_ca, ibd_ca_port, mgmt_classes, 3);
+ if (!srcport)
+ IBEXIT("Failed to open '%s' port '%d'", ibd_ca, ibd_ca_port);
+
+ smp_mkey_set(srcport, ibd_mkey);
+
+ if (with_grh && ibd_dest_type != IB_DEST_LID)
+ IBEXIT("When using GRH, LID should be provided");
+ if (resolve_portid_str(ibd_ca, ibd_ca_port, &portid, argv[1],
+ ibd_dest_type, ibd_sm_id, srcport) < 0)
+ IBEXIT("can't resolve destination %s", argv[1]);
+ if (with_grh) {
+ portid.grh_present = 1;
+ memcpy(&portid.gid, &dgid, sizeof(portid.gid));
+ }
+ if ((err = fn(&portid, argv + 2, argc - 2)))
+ IBEXIT("operation %s: %s", argv[0], err);
+
+ mad_rpc_close_port(srcport);
+ exit(0);
+}
diff --git a/contrib/ofed/infiniband-diags/src/ibccquery.c b/contrib/ofed/infiniband-diags/src/ibccquery.c
new file mode 100644
index 0000000..ed77dc5
--- /dev/null
+++ b/contrib/ofed/infiniband-diags/src/ibccquery.c
@@ -0,0 +1,427 @@
+/*
+ * Copyright (c) 2004-2009 Voltaire Inc. All rights reserved.
+ * Copyright (c) 2011 Mellanox Technologies LTD. All rights reserved.
+ * Copyright (c) 2011 Lawrence Livermore National Lab. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+#if HAVE_CONFIG_H
+# include <config.h>
+#endif /* HAVE_CONFIG_H */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <string.h>
+#include <getopt.h>
+#include <netinet/in.h>
+
+#define __STDC_FORMAT_MACROS
+#include <inttypes.h>
+
+#include <infiniband/mad.h>
+
+#include "ibdiag_common.h"
+
+struct ibmad_port *srcport;
+
+static ibmad_gid_t dgid;
+static int with_grh;
+
+static op_fn_t class_port_info;
+static op_fn_t congestion_info;
+static op_fn_t congestion_key_info;
+static op_fn_t congestion_log;
+static op_fn_t switch_congestion_setting;
+static op_fn_t switch_port_congestion_setting;
+static op_fn_t ca_congestion_setting;
+static op_fn_t congestion_control_table;
+static op_fn_t timestamp_dump;
+
+static const match_rec_t match_tbl[] = {
+ {"ClassPortInfo", "CP", class_port_info, 0, ""},
+ {"CongestionInfo", "CI", congestion_info, 0, ""},
+ {"CongestionKeyInfo", "CK", congestion_key_info, 0, ""},
+ {"CongestionLog", "CL", congestion_log, 0, ""},
+ {"SwitchCongestionSetting", "SS", switch_congestion_setting, 0, ""},
+ {"SwitchPortCongestionSetting", "SP", switch_port_congestion_setting, 1, ""},
+ {"CACongestionSetting", "CS", ca_congestion_setting, 0, ""},
+ {"CongestionControlTable", "CT", congestion_control_table, 0, ""},
+ {"Timestamp", "TI", timestamp_dump, 0, ""},
+ {0}
+};
+
+uint64_t cckey = 0;
+
+/*******************************************/
+static char *class_port_info(ib_portid_t * dest, char **argv, int argc)
+{
+ char buf[2048];
+ char data[IB_CC_DATA_SZ] = { 0 };
+
+ if (!cc_query_status_via(data, dest, CLASS_PORT_INFO,
+ 0, 0, NULL, srcport, cckey))
+ return "class port info query failed";
+
+ mad_dump_classportinfo(buf, sizeof buf, data, sizeof data);
+
+ printf("# ClassPortInfo: %s\n%s", portid2str(dest), buf);
+ return NULL;
+}
+
+static char *congestion_info(ib_portid_t * dest, char **argv, int argc)
+{
+ char buf[2048];
+ char data[IB_CC_DATA_SZ] = { 0 };
+
+ if (!cc_query_status_via(data, dest, IB_CC_ATTR_CONGESTION_INFO,
+ 0, 0, NULL, srcport, cckey))
+ return "congestion info query failed";
+
+ mad_dump_cc_congestioninfo(buf, sizeof buf, data, sizeof data);
+
+ printf("# CongestionInfo: %s\n%s", portid2str(dest), buf);
+ return NULL;
+}
+
+static char *congestion_key_info(ib_portid_t * dest, char **argv, int argc)
+{
+ char buf[2048];
+ char data[IB_CC_DATA_SZ] = { 0 };
+
+ if (!cc_query_status_via(data, dest, IB_CC_ATTR_CONGESTION_KEY_INFO,
+ 0, 0, NULL, srcport, cckey))
+ return "congestion key info query failed";
+
+ mad_dump_cc_congestionkeyinfo(buf, sizeof buf, data, sizeof data);
+
+ printf("# CongestionKeyInfo: %s\n%s", portid2str(dest), buf);
+ return NULL;
+}
+
+static char *congestion_log(ib_portid_t * dest, char **argv, int argc)
+{
+ char buf[2048];
+ char data[IB_CC_LOG_DATA_SZ] = { 0 };
+ char emptybuf[16] = { 0 };
+ int i, type;
+
+ if (!cc_query_status_via(data, dest, IB_CC_ATTR_CONGESTION_LOG,
+ 0, 0, NULL, srcport, cckey))
+ return "congestion log query failed";
+
+ mad_decode_field((uint8_t *)data, IB_CC_CONGESTION_LOG_LOGTYPE_F, &type);
+
+ if (type != 1 && type != 2)
+ return "unrecognized log type";
+
+ mad_dump_cc_congestionlog(buf, sizeof buf, data, sizeof data);
+
+ printf("# CongestionLog: %s\n%s", portid2str(dest), buf);
+
+ if (type == 1) {
+ mad_dump_cc_congestionlogswitch(buf, sizeof buf, data, sizeof data);
+ printf("%s\n", buf);
+ for (i = 0; i < 15; i++) {
+ /* output only if entry not 0 */
+ if (memcmp(data + 40 + i * 12, emptybuf, 12)) {
+ mad_dump_cc_congestionlogentryswitch(buf, sizeof buf,
+ data + 40 + i * 12,
+ 12);
+ printf("%s\n", buf);
+ }
+ }
+ }
+ else {
+ /* XXX: Q3/2010 errata lists first entry offset at 80, but we assume
+ * will be updated to 96 once CurrentTimeStamp field is word aligned.
+ * In addition, assume max 13 log events instead of 16. Due to
+ * errata changes increasing size of CA log event, 16 log events is
+ * no longer possible to fit in max MAD size.
+ */
+ mad_dump_cc_congestionlogca(buf, sizeof buf, data, sizeof data);
+ printf("%s\n", buf);
+ for (i = 0; i < 13; i++) {
+ /* output only if entry not 0 */
+ if (memcmp(data + 12 + i * 16, emptybuf, 16)) {
+ mad_dump_cc_congestionlogentryca(buf, sizeof buf,
+ data + 12 + i * 16,
+ 16);
+ printf("%s\n", buf);
+ }
+ }
+ }
+
+ return NULL;
+}
+
+static char *switch_congestion_setting(ib_portid_t * dest, char **argv, int argc)
+{
+ char buf[2048];
+ char data[IB_CC_DATA_SZ] = { 0 };
+
+ if (!cc_query_status_via(data, dest, IB_CC_ATTR_SWITCH_CONGESTION_SETTING,
+ 0, 0, NULL, srcport, cckey))
+ return "switch congestion setting query failed";
+
+ mad_dump_cc_switchcongestionsetting(buf, sizeof buf, data, sizeof data);
+
+ printf("# SwitchCongestionSetting: %s\n%s", portid2str(dest), buf);
+ return NULL;
+}
+
+static char *switch_port_congestion_setting(ib_portid_t * dest, char **argv, int argc)
+{
+ char buf[2048];
+ char data[IB_CC_DATA_SZ] = { 0 };
+ int type, numports, maxblocks, i, j;
+ int portnum = 0;
+ int outputcount = 0;
+
+ if (argc > 0)
+ portnum = strtol(argv[0], 0, 0);
+
+ /* Figure out number of ports first */
+ if (!smp_query_via(data, dest, IB_ATTR_NODE_INFO, 0, 0, srcport))
+ return "node info query failed";
+
+ mad_decode_field((uint8_t *)data, IB_NODE_TYPE_F, &type);
+ mad_decode_field((uint8_t *)data, IB_NODE_NPORTS_F, &numports);
+
+ if (type != IB_NODE_SWITCH)
+ return "destination not a switch";
+
+ printf("# SwitchPortCongestionSetting: %s\n", portid2str(dest));
+
+ if (portnum) {
+ if (portnum > numports)
+ return "invalid port number specified";
+
+ memset(data, '\0', sizeof data);
+ if (!cc_query_status_via(data, dest, IB_CC_ATTR_SWITCH_PORT_CONGESTION_SETTING,
+ portnum / 32, 0, NULL, srcport, cckey))
+ return "switch port congestion setting query failed";
+
+ mad_dump_cc_switchportcongestionsettingelement(buf, sizeof buf,
+ data + ((portnum % 32) * 4),
+ 4);
+ printf("%s", buf);
+ return NULL;
+ }
+
+ /* else get all port info */
+
+ maxblocks = numports / 32 + 1;
+
+ for (i = 0; i < maxblocks; i++) {
+ memset(data, '\0', sizeof data);
+ if (!cc_query_status_via(data, dest, IB_CC_ATTR_SWITCH_PORT_CONGESTION_SETTING,
+ i, 0, NULL, srcport, cckey))
+ return "switch port congestion setting query failed";
+
+ for (j = 0; j < 32 && outputcount <= numports; j++) {
+ printf("Port:............................%u\n", i * 32 + j);
+ mad_dump_cc_switchportcongestionsettingelement(buf, sizeof buf,
+ data + j * 4,
+ 4);
+ printf("%s\n", buf);
+ outputcount++;
+ }
+ }
+
+ return NULL;
+}
+
+static char *ca_congestion_setting(ib_portid_t * dest, char **argv, int argc)
+{
+ char buf[2048];
+ char data[IB_CC_DATA_SZ] = { 0 };
+ int i;
+
+ if (!cc_query_status_via(data, dest, IB_CC_ATTR_CA_CONGESTION_SETTING,
+ 0, 0, NULL, srcport, cckey))
+ return "ca congestion setting query failed";
+
+ mad_dump_cc_cacongestionsetting(buf, sizeof buf, data, sizeof data);
+
+ printf("# CACongestionSetting: %s\n%s\n", portid2str(dest), buf);
+
+ for (i = 0; i < 16; i++) {
+ printf("SL:..............................%u\n", i);
+ mad_dump_cc_cacongestionentry(buf, sizeof buf,
+ data + 4 + i * 8,
+ 8);
+ printf("%s\n", buf);
+ }
+ return NULL;
+}
+
+static char *congestion_control_table(ib_portid_t * dest, char **argv, int argc)
+{
+ char buf[2048];
+ char data[IB_CC_DATA_SZ] = { 0 };
+ int limit, outputcount = 0;
+ int i, j;
+
+ if (!cc_query_status_via(data, dest, IB_CC_ATTR_CONGESTION_CONTROL_TABLE,
+ 0, 0, NULL, srcport, cckey))
+ return "congestion control table query failed";
+
+ mad_decode_field((uint8_t *)data, IB_CC_CONGESTION_CONTROL_TABLE_CCTI_LIMIT_F, &limit);
+
+ mad_dump_cc_congestioncontroltable(buf, sizeof buf, data, sizeof data);
+
+ printf("# CongestionControlTable: %s\n%s\n", portid2str(dest), buf);
+
+ if (!limit)
+ return NULL;
+
+ for (i = 0; i < (limit/64) + 1; i++) {
+
+ /* first query done */
+ if (i)
+ if (!cc_query_status_via(data, dest, IB_CC_ATTR_CONGESTION_CONTROL_TABLE,
+ i, 0, NULL, srcport, cckey))
+ return "congestion control table query failed";
+
+ for (j = 0; j < 64 && outputcount <= limit; j++) {
+ printf("Entry:...........................%u\n", i*64 + j);
+ mad_dump_cc_congestioncontroltableentry(buf, sizeof buf,
+ data + 4 + j * 2,
+ sizeof data - 4 - j * 2);
+ printf("%s\n", buf);
+ outputcount++;
+ }
+ }
+ return NULL;
+}
+
+static char *timestamp_dump(ib_portid_t * dest, char **argv, int argc)
+{
+ char buf[2048];
+ char data[IB_CC_DATA_SZ] = { 0 };
+
+ if (!cc_query_status_via(data, dest, IB_CC_ATTR_TIMESTAMP,
+ 0, 0, NULL, srcport, cckey))
+ return "timestamp query failed";
+
+ mad_dump_cc_timestamp(buf, sizeof buf, data, sizeof data);
+
+ printf("# Timestamp: %s\n%s", portid2str(dest), buf);
+ return NULL;
+}
+
+static int process_opt(void *context, int ch, char *optarg)
+{
+ switch (ch) {
+ case 'c':
+ cckey = (uint64_t) strtoull(optarg, 0, 0);
+ break;
+ case 25:
+ if (!inet_pton(AF_INET6, optarg, &dgid)) {
+ fprintf(stderr, "dgid format is wrong!\n");
+ ibdiag_show_usage();
+ return 1;
+ }
+ with_grh = 1;
+ break;
+ default:
+ return -1;
+ }
+ return 0;
+}
+
+int main(int argc, char **argv)
+{
+ char usage_args[1024];
+ int mgmt_classes[3] = { IB_SMI_CLASS, IB_SA_CLASS, IB_CC_CLASS };
+ ib_portid_t portid = { 0 };
+ char *err;
+ op_fn_t *fn;
+ const match_rec_t *r;
+ int n;
+
+ const struct ibdiag_opt opts[] = {
+ {"cckey", 'c', 1, "<key>", "CC key"},
+ {"dgid", 25, 1, NULL, "remote gid (IPv6 format)"},
+ {0}
+ };
+ const char *usage_examples[] = {
+ "CongestionInfo 3\t\t\t# Congestion Info by lid",
+ "SwitchPortCongestionSetting 3\t# Query all Switch Port Congestion Settings",
+ "SwitchPortCongestionSetting 3 1\t# Query Switch Port Congestion Setting for port 1",
+ NULL
+ };
+
+ n = sprintf(usage_args, "[-c key] <op> <lid|guid>\n"
+ "\nSupported ops (and aliases, case insensitive):\n");
+ for (r = match_tbl; r->name; r++) {
+ n += snprintf(usage_args + n, sizeof(usage_args) - n,
+ " %s (%s) <lid|guid>%s\n", r->name,
+ r->alias ? r->alias : "",
+ r->opt_portnum ? " [<portnum>]" : "");
+ if (n >= sizeof(usage_args))
+ exit(-1);
+ }
+
+ ibdiag_process_opts(argc, argv, NULL, "DK", opts, process_opt,
+ usage_args, usage_examples);
+
+ argc -= optind;
+ argv += optind;
+
+ if (argc < 2)
+ ibdiag_show_usage();
+
+ if (!(fn = match_op(match_tbl, argv[0])))
+ IBEXIT("operation '%s' not supported", argv[0]);
+
+ srcport = mad_rpc_open_port(ibd_ca, ibd_ca_port, mgmt_classes, 3);
+ if (!srcport)
+ IBEXIT("Failed to open '%s' port '%d'", ibd_ca, ibd_ca_port);
+
+ smp_mkey_set(srcport, ibd_mkey);
+
+ if (with_grh && ibd_dest_type != IB_DEST_LID)
+ IBEXIT("When using GRH, LID should be provided");
+ if (resolve_portid_str(ibd_ca, ibd_ca_port, &portid, argv[1],
+ ibd_dest_type, ibd_sm_id, srcport) < 0)
+ IBEXIT("can't resolve destination %s", argv[1]);
+ if (with_grh) {
+ portid.grh_present = 1;
+ memcpy(&portid.gid, &dgid, sizeof(portid.gid));
+ }
+ if ((err = fn(&portid, argv + 2, argc - 2)))
+ IBEXIT("operation %s: %s", argv[0], err);
+
+ mad_rpc_close_port(srcport);
+ exit(0);
+}
diff --git a/contrib/ofed/infiniband-diags/src/ibdiag_common.c b/contrib/ofed/infiniband-diags/src/ibdiag_common.c
new file mode 100644
index 0000000..d668b7e
--- /dev/null
+++ b/contrib/ofed/infiniband-diags/src/ibdiag_common.c
@@ -0,0 +1,940 @@
+/*
+ * Copyright (c) 2006-2007 The Regents of the University of California.
+ * Copyright (c) 2004-2009 Voltaire, Inc. All rights reserved.
+ * Copyright (c) 2002-2010 Mellanox Technologies LTD. All rights reserved.
+ * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
+ * Copyright (c) 2009 HNR Consulting. All rights reserved.
+ * Copyright (c) 2011 Lawrence Livermore National Security. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+/**
+ * Define common functions which can be included in the various C based diags.
+ */
+
+#define _GNU_SOURCE
+#include <stdio.h>
+#include <errno.h>
+#include <string.h>
+#include <stdlib.h>
+#include <stdarg.h>
+#include <sys/types.h>
+#include <unistd.h>
+#include <ctype.h>
+#include <config.h>
+#include <getopt.h>
+#include <limits.h>
+#include <sys/stat.h>
+#include <stdarg.h>
+
+#include <infiniband/umad.h>
+#include <infiniband/mad.h>
+#include <ibdiag_common.h>
+#include <ibdiag_version.h>
+
+int ibverbose;
+enum MAD_DEST ibd_dest_type = IB_DEST_LID;
+ib_portid_t *ibd_sm_id;
+static ib_portid_t sm_portid = { 0 };
+
+/* general config options */
+#define IBDIAG_CONFIG_GENERAL IBDIAG_CONFIG_PATH"/ibdiag.conf"
+char *ibd_ca = NULL;
+int ibd_ca_port = 0;
+int ibd_timeout = 0;
+uint32_t ibd_ibnetdisc_flags = IBND_CONFIG_MLX_EPI;
+uint64_t ibd_mkey;
+uint64_t ibd_sakey = 0;
+int show_keys = 0;
+char *ibd_nd_format = NULL;
+
+static const char *prog_name;
+static const char *prog_args;
+static const char **prog_examples;
+static struct option *long_opts = NULL;
+static const struct ibdiag_opt *opts_map[256];
+
+static const char *get_build_version(void)
+{
+ return "BUILD VERSION: " IBDIAG_VERSION " Build date: " __DATE__ " "
+ __TIME__;
+}
+
+static void pretty_print(int start, int width, const char *str)
+{
+ int len = width - start;
+ const char *p, *e;
+
+ while (1) {
+ while (isspace(*str))
+ str++;
+ p = str;
+ do {
+ e = p + 1;
+ p = strchr(e, ' ');
+ } while (p && p - str < len);
+ if (!p) {
+ fprintf(stderr, "%s", str);
+ break;
+ }
+ if (e - str == 1)
+ e = p;
+ fprintf(stderr, "%.*s\n%*s", (int)(e - str), str, start, "");
+ str = e;
+ }
+}
+
+static inline int val_str_true(const char *val_str)
+{
+ return ((strncmp(val_str, "TRUE", strlen("TRUE")) == 0) ||
+ (strncmp(val_str, "true", strlen("true")) == 0));
+}
+
+void read_ibdiag_config(const char *file)
+{
+ char buf[1024];
+ FILE *config_fd = NULL;
+ char *p_prefix, *p_last;
+ char *name;
+ char *val_str;
+ struct stat statbuf;
+
+ /* silently ignore missing config file */
+ if (stat(file, &statbuf))
+ return;
+
+ config_fd = fopen(file, "r");
+ if (!config_fd)
+ return;
+
+ while (fgets(buf, sizeof buf, config_fd) != NULL) {
+ p_prefix = strtok_r(buf, "\n", &p_last);
+ if (!p_prefix)
+ continue; /* ignore blank lines */
+
+ if (*p_prefix == '#')
+ continue; /* ignore comment lines */
+
+ name = strtok_r(p_prefix, "=", &p_last);
+ val_str = strtok_r(NULL, "\n", &p_last);
+
+ if (strncmp(name, "CA", strlen("CA")) == 0) {
+ free(ibd_ca);
+ ibd_ca = strdup(val_str);
+ } else if (strncmp(name, "Port", strlen("Port")) == 0) {
+ ibd_ca_port = strtoul(val_str, NULL, 0);
+ } else if (strncmp(name, "timeout", strlen("timeout")) == 0) {
+ ibd_timeout = strtoul(val_str, NULL, 0);
+ } else if (strncmp(name, "MLX_EPI", strlen("MLX_EPI")) == 0) {
+ if (val_str_true(val_str)) {
+ ibd_ibnetdisc_flags |= IBND_CONFIG_MLX_EPI;
+ } else {
+ ibd_ibnetdisc_flags &= ~IBND_CONFIG_MLX_EPI;
+ }
+ } else if (strncmp(name, "m_key", strlen("m_key")) == 0) {
+ ibd_mkey = strtoull(val_str, 0, 0);
+ } else if (strncmp(name, "sa_key",
+ strlen("sa_key")) == 0) {
+ ibd_sakey = strtoull(val_str, 0, 0);
+ } else if (strncmp(name, "nd_format",
+ strlen("nd_format")) == 0) {
+ ibd_nd_format = strdup(val_str);
+ }
+ }
+
+ fclose(config_fd);
+}
+
+
+void ibdiag_show_usage()
+{
+ struct option *o = long_opts;
+ int n;
+
+ fprintf(stderr, "\nUsage: %s [options] %s\n\n", prog_name,
+ prog_args ? prog_args : "");
+
+ if (long_opts[0].name)
+ fprintf(stderr, "Options:\n");
+ for (o = long_opts; o->name; o++) {
+ const struct ibdiag_opt *io = opts_map[o->val];
+ n = fprintf(stderr, " --%s", io->name);
+ if (isprint(io->letter))
+ n += fprintf(stderr, ", -%c", io->letter);
+ if (io->has_arg)
+ n += fprintf(stderr, " %s",
+ io->arg_tmpl ? io->arg_tmpl : "<val>");
+ if (io->description && *io->description) {
+ n += fprintf(stderr, "%*s ", 24 - n > 0 ? 24 - n : 0,
+ "");
+ pretty_print(n, 74, io->description);
+ }
+ fprintf(stderr, "\n");
+ }
+
+ if (prog_examples) {
+ const char **p;
+ fprintf(stderr, "\nExamples:\n");
+ for (p = prog_examples; *p && **p; p++)
+ fprintf(stderr, " %s %s\n", prog_name, *p);
+ }
+
+ fprintf(stderr, "\n");
+
+ exit(2);
+}
+
+static int process_opt(int ch, char *optarg)
+{
+ char *endp;
+ long val;
+
+ switch (ch) {
+ case 'z':
+ read_ibdiag_config(optarg);
+ break;
+ case 'h':
+ ibdiag_show_usage();
+ break;
+ case 'V':
+ fprintf(stderr, "%s %s\n", prog_name, get_build_version());
+ exit(0);
+ case 'e':
+ madrpc_show_errors(1);
+ break;
+ case 'v':
+ ibverbose++;
+ break;
+ case 'd':
+ ibdebug++;
+ madrpc_show_errors(1);
+ umad_debug(ibdebug - 1);
+ break;
+ case 'C':
+ ibd_ca = optarg;
+ break;
+ case 'P':
+ ibd_ca_port = strtoul(optarg, 0, 0);
+ if (ibd_ca_port < 0)
+ IBEXIT("cannot resolve CA port %d", ibd_ca_port);
+ break;
+ case 'D':
+ ibd_dest_type = IB_DEST_DRPATH;
+ break;
+ case 'L':
+ ibd_dest_type = IB_DEST_LID;
+ break;
+ case 'G':
+ ibd_dest_type = IB_DEST_GUID;
+ break;
+ case 't':
+ errno = 0;
+ val = strtol(optarg, &endp, 0);
+ if (errno || (endp && *endp != '\0') || val <= 0 ||
+ val > INT_MAX)
+ IBEXIT("Invalid timeout \"%s\". Timeout requires a "
+ "positive integer value < %d.", optarg, INT_MAX);
+ else {
+ madrpc_set_timeout((int)val);
+ ibd_timeout = (int)val;
+ }
+ break;
+ case 's':
+ /* srcport is not required when resolving via IB_DEST_LID */
+ if (resolve_portid_str(ibd_ca, ibd_ca_port, &sm_portid, optarg,
+ IB_DEST_LID, 0, NULL) < 0)
+ IBEXIT("cannot resolve SM destination port %s",
+ optarg);
+ ibd_sm_id = &sm_portid;
+ break;
+ case 'K':
+ show_keys = 1;
+ break;
+ case 'y':
+ errno = 0;
+ ibd_mkey = strtoull(optarg, &endp, 0);
+ if (errno || *endp != '\0') {
+ errno = 0;
+ ibd_mkey = strtoull(getpass("M_Key: "), &endp, 0);
+ if (errno || *endp != '\0') {
+ IBEXIT("Bad M_Key");
+ }
+ }
+ break;
+ default:
+ return -1;
+ }
+
+ return 0;
+}
+
+static const struct ibdiag_opt common_opts[] = {
+ {"config", 'z', 1, "<config>", "use config file, default: " IBDIAG_CONFIG_GENERAL},
+ {"Ca", 'C', 1, "<ca>", "Ca name to use"},
+ {"Port", 'P', 1, "<port>", "Ca port number to use"},
+ {"Direct", 'D', 0, NULL, "use Direct address argument"},
+ {"Lid", 'L', 0, NULL, "use LID address argument"},
+ {"Guid", 'G', 0, NULL, "use GUID address argument"},
+ {"timeout", 't', 1, "<ms>", "timeout in ms"},
+ {"sm_port", 's', 1, "<lid>", "SM port lid"},
+ {"show_keys", 'K', 0, NULL, "display security keys in output"},
+ {"m_key", 'y', 1, "<key>", "M_Key to use in request"},
+ {"errors", 'e', 0, NULL, "show send and receive errors"},
+ {"verbose", 'v', 0, NULL, "increase verbosity level"},
+ {"debug", 'd', 0, NULL, "raise debug level"},
+ {"help", 'h', 0, NULL, "help message"},
+ {"version", 'V', 0, NULL, "show version"},
+ {0}
+};
+
+static void make_opt(struct option *l, const struct ibdiag_opt *o,
+ const struct ibdiag_opt *map[])
+{
+ l->name = o->name;
+ l->has_arg = o->has_arg;
+ l->flag = NULL;
+ l->val = o->letter;
+ if (!map[l->val])
+ map[l->val] = o;
+}
+
+static struct option *make_long_opts(const char *exclude_str,
+ const struct ibdiag_opt *custom_opts,
+ const struct ibdiag_opt *map[])
+{
+ struct option *long_opts, *l;
+ const struct ibdiag_opt *o;
+ unsigned n = 0;
+
+ if (custom_opts)
+ for (o = custom_opts; o->name; o++)
+ n++;
+
+ long_opts = malloc((sizeof(common_opts) / sizeof(common_opts[0]) + n) *
+ sizeof(*long_opts));
+ if (!long_opts)
+ return NULL;
+
+ l = long_opts;
+
+ if (custom_opts)
+ for (o = custom_opts; o->name; o++)
+ make_opt(l++, o, map);
+
+ for (o = common_opts; o->name; o++) {
+ if (exclude_str && strchr(exclude_str, o->letter))
+ continue;
+ make_opt(l++, o, map);
+ }
+
+ memset(l, 0, sizeof(*l));
+
+ return long_opts;
+}
+
+static void make_str_opts(const struct option *o, char *p, unsigned size)
+{
+ unsigned i, n = 0;
+
+ for (n = 0; o->name && n + 2 + o->has_arg < size; o++) {
+ p[n++] = (char)o->val;
+ for (i = 0; i < (unsigned)o->has_arg; i++)
+ p[n++] = ':';
+ }
+ p[n] = '\0';
+}
+
+int ibdiag_process_opts(int argc, char *const argv[], void *cxt,
+ const char *exclude_common_str,
+ const struct ibdiag_opt custom_opts[],
+ int (*custom_handler) (void *cxt, int val,
+ char *optarg),
+ const char *usage_args, const char *usage_examples[])
+{
+ char str_opts[1024];
+ const struct ibdiag_opt *o;
+
+ prog_name = argv[0];
+ prog_args = usage_args;
+ prog_examples = usage_examples;
+
+ if (long_opts)
+ free(long_opts);
+
+ long_opts = make_long_opts(exclude_common_str, custom_opts, opts_map);
+ if (!long_opts)
+ return -1;
+
+ read_ibdiag_config(IBDIAG_CONFIG_GENERAL);
+
+ make_str_opts(long_opts, str_opts, sizeof(str_opts));
+
+ while (1) {
+ int ch = getopt_long(argc, argv, str_opts, long_opts, NULL);
+ if (ch == -1)
+ break;
+ o = opts_map[ch];
+ if (!o)
+ ibdiag_show_usage();
+ if (custom_handler) {
+ if (custom_handler(cxt, ch, optarg) &&
+ process_opt(ch, optarg))
+ ibdiag_show_usage();
+ } else if (process_opt(ch, optarg))
+ ibdiag_show_usage();
+ }
+
+ return 0;
+}
+
+void ibexit(const char *fn, char *msg, ...)
+{
+ char buf[512];
+ va_list va;
+ int n;
+
+ va_start(va, msg);
+ n = vsprintf(buf, msg, va);
+ va_end(va);
+ buf[n] = 0;
+
+ if (ibdebug)
+ printf("%s: iberror: [pid %d] %s: failed: %s\n",
+ prog_name ? prog_name : "", getpid(), fn, buf);
+ else
+ printf("%s: iberror: failed: %s\n",
+ prog_name ? prog_name : "", buf);
+
+ exit(-1);
+}
+
+char *
+conv_cnt_human_readable(uint64_t val64, float *val, int data)
+{
+ uint64_t tmp = val64;
+ int ui = 0;
+ int div = 1;
+
+ tmp /= 1024;
+ while (tmp) {
+ ui++;
+ tmp /= 1024;
+ div *= 1024;
+ }
+
+ *val = (float)(val64);
+ if (data) {
+ *val *= 4;
+ if (*val/div > 1024) {
+ ui++;
+ div *= 1024;
+ }
+ }
+ *val /= div;
+
+ if (data) {
+ switch (ui) {
+ case 0:
+ return ("B");
+ case 1:
+ return ("KB");
+ case 2:
+ return ("MB");
+ case 3:
+ return ("GB");
+ case 4:
+ return ("TB");
+ case 5:
+ return ("PB");
+ case 6:
+ return ("EB");
+ default:
+ return ("");
+ }
+ } else {
+ switch (ui) {
+ case 0:
+ return ("");
+ case 1:
+ return ("K");
+ case 2:
+ return ("M");
+ case 3:
+ return ("G");
+ case 4:
+ return ("T");
+ case 5:
+ return ("P");
+ case 6:
+ return ("E");
+ default:
+ return ("");
+ }
+ }
+ return ("");
+}
+
+int is_port_info_extended_supported(ib_portid_t * dest, int port,
+ struct ibmad_port *srcport)
+{
+ uint8_t data[IB_SMP_DATA_SIZE] = { 0 };
+ uint32_t cap_mask;
+ uint16_t cap_mask2;
+
+ if (!smp_query_via(data, dest, IB_ATTR_PORT_INFO, port, 0, srcport))
+ IBEXIT("port info query failed");
+
+ mad_decode_field(data, IB_PORT_CAPMASK_F, &cap_mask);
+ if (cap_mask & CL_NTOH32(IB_PORT_CAP_HAS_CAP_MASK2)) {
+ mad_decode_field(data, IB_PORT_CAPMASK2_F, &cap_mask2);
+ if (!(cap_mask2 &
+ CL_NTOH16(IB_PORT_CAP2_IS_PORT_INFO_EXT_SUPPORTED))) {
+ IBWARN("port info capability mask2 = 0x%x doesn't"
+ " indicate PortInfoExtended support", cap_mask2);
+ return 0;
+ }
+ } else {
+ IBWARN("port info capability mask2 not supported");
+ return 0;
+ }
+
+ return 1;
+}
+
+int is_mlnx_ext_port_info_supported(uint32_t vendorid,
+ uint16_t devid)
+{
+ if (ibd_ibnetdisc_flags & IBND_CONFIG_MLX_EPI) {
+
+ if ((devid >= 0xc738 && devid <= 0xc73b) || devid == 0xcb20 || devid == 0xcf08 ||
+ ((vendorid == 0x119f) &&
+ /* Bull SwitchX */
+ (devid == 0x1b02 || devid == 0x1b50 ||
+ /* Bull SwitchIB and SwitchIB2 */
+ devid == 0x1ba0 ||
+ (devid >= 0x1bd0 && devid <= 0x1bd5))))
+ return 1;
+ if ((devid >= 0x1003 && devid <= 0x1017) ||
+ ((vendorid == 0x119f) &&
+ /* Bull ConnectX3 */
+ (devid == 0x1b33 || devid == 0x1b73 ||
+ devid == 0x1b40 || devid == 0x1b41 ||
+ devid == 0x1b60 || devid == 0x1b61 ||
+ /* Bull ConnectIB */
+ devid == 0x1b83 ||
+ devid == 0x1b93 || devid == 0x1b94 ||
+ /* Bull ConnectX4 */
+ devid == 0x1bb4 || devid == 0x1bb5 ||
+ devid == 0x1bc4)))
+ return 1;
+ }
+
+ return 0;
+}
+
+/** =========================================================================
+ * Resolve the SM portid using the umad layer rather than using
+ * ib_resolve_smlid_via which requires a PortInfo query on the local port.
+ */
+int resolve_sm_portid(char *ca_name, uint8_t portnum, ib_portid_t *sm_id)
+{
+ umad_port_t port;
+ int rc;
+
+ if (!sm_id)
+ return (-1);
+
+ if ((rc = umad_get_port(ca_name, portnum, &port)) < 0)
+ return rc;
+
+ memset(sm_id, 0, sizeof(*sm_id));
+ sm_id->lid = port.sm_lid;
+ sm_id->sl = port.sm_sl;
+
+ umad_release_port(&port);
+
+ return 0;
+}
+
+/** =========================================================================
+ * Resolve local CA characteristics using the umad layer rather than using
+ * ib_resolve_self_via which requires SMP queries on the local port.
+ */
+int resolve_self(char *ca_name, uint8_t ca_port, ib_portid_t *portid,
+ int *portnum, ibmad_gid_t *gid)
+{
+ umad_port_t port;
+ uint64_t prefix, guid;
+ int rc;
+
+ if (!(portid || portnum || gid))
+ return (-1);
+
+ if ((rc = umad_get_port(ca_name, ca_port, &port)) < 0)
+ return rc;
+
+ if (portid) {
+ memset(portid, 0, sizeof(*portid));
+ portid->lid = port.base_lid;
+ portid->sl = port.sm_sl;
+ }
+ if (portnum)
+ *portnum = port.portnum;
+ if (gid) {
+ memset(gid, 0, sizeof(*gid));
+ prefix = cl_ntoh64(port.gid_prefix);
+ guid = cl_ntoh64(port.port_guid);
+ mad_encode_field(*gid, IB_GID_PREFIX_F, &prefix);
+ mad_encode_field(*gid, IB_GID_GUID_F, &guid);
+ }
+
+ umad_release_port(&port);
+
+ return 0;
+}
+
+int resolve_gid(char *ca_name, uint8_t ca_port, ib_portid_t * portid,
+ ibmad_gid_t gid, ib_portid_t * sm_id,
+ const struct ibmad_port *srcport)
+{
+ ib_portid_t sm_portid;
+ char buf[IB_SA_DATA_SIZE] = { 0 };
+
+ if (!sm_id) {
+ sm_id = &sm_portid;
+ if (resolve_sm_portid(ca_name, ca_port, sm_id) < 0)
+ return -1;
+ }
+
+ if ((portid->lid =
+ ib_path_query_via(srcport, gid, gid, sm_id, buf)) < 0)
+ return -1;
+
+ return 0;
+}
+
+int resolve_guid(char *ca_name, uint8_t ca_port, ib_portid_t *portid,
+ uint64_t *guid, ib_portid_t *sm_id,
+ const struct ibmad_port *srcport)
+{
+ ib_portid_t sm_portid;
+ uint8_t buf[IB_SA_DATA_SIZE] = { 0 };
+ uint64_t prefix;
+ ibmad_gid_t selfgid;
+
+ if (!sm_id) {
+ sm_id = &sm_portid;
+ if (resolve_sm_portid(ca_name, ca_port, sm_id) < 0)
+ return -1;
+ }
+
+ if (resolve_self(ca_name, ca_port, NULL, NULL, &selfgid) < 0)
+ return -1;
+
+ memcpy(&prefix, portid->gid, sizeof(prefix));
+ if (!prefix)
+ mad_set_field64(portid->gid, 0, IB_GID_PREFIX_F,
+ IB_DEFAULT_SUBN_PREFIX);
+ if (guid)
+ mad_set_field64(portid->gid, 0, IB_GID_GUID_F, *guid);
+
+ if ((portid->lid =
+ ib_path_query_via(srcport, selfgid, portid->gid, sm_id, buf)) < 0)
+ return -1;
+
+ mad_decode_field(buf, IB_SA_PR_SL_F, &portid->sl);
+ return 0;
+}
+
+/*
+ * Callers of this function should ensure their ibmad_port has been opened with
+ * IB_SA_CLASS as this function may require the SA to resolve addresses.
+ */
+int resolve_portid_str(char *ca_name, uint8_t ca_port, ib_portid_t * portid,
+ char *addr_str, enum MAD_DEST dest_type,
+ ib_portid_t *sm_id, const struct ibmad_port *srcport)
+{
+ ibmad_gid_t gid;
+ uint64_t guid;
+ int lid;
+ char *routepath;
+ ib_portid_t selfportid = { 0 };
+ int selfport = 0;
+
+ memset(portid, 0, sizeof *portid);
+
+ switch (dest_type) {
+ case IB_DEST_LID:
+ lid = strtol(addr_str, 0, 0);
+ if (!IB_LID_VALID(lid))
+ return -1;
+ return ib_portid_set(portid, lid, 0, 0);
+
+ case IB_DEST_DRPATH:
+ if (str2drpath(&portid->drpath, addr_str, 0, 0) < 0)
+ return -1;
+ return 0;
+
+ case IB_DEST_GUID:
+ if (!(guid = strtoull(addr_str, 0, 0)))
+ return -1;
+
+ /* keep guid in portid? */
+ return resolve_guid(ca_name, ca_port, portid, &guid, sm_id,
+ srcport);
+
+ case IB_DEST_DRSLID:
+ lid = strtol(addr_str, &routepath, 0);
+ routepath++;
+ if (!IB_LID_VALID(lid))
+ return -1;
+ ib_portid_set(portid, lid, 0, 0);
+
+ /* handle DR parsing and set DrSLID to local lid */
+ if (resolve_self(ca_name, ca_port, &selfportid, &selfport,
+ NULL) < 0)
+ return -1;
+ if (str2drpath(&portid->drpath, routepath, selfportid.lid, 0) <
+ 0)
+ return -1;
+ return 0;
+
+ case IB_DEST_GID:
+ if (inet_pton(AF_INET6, addr_str, &gid) <= 0)
+ return -1;
+ return resolve_gid(ca_name, ca_port, portid, gid, sm_id,
+ srcport);
+ default:
+ IBWARN("bad dest_type %d", dest_type);
+ }
+
+ return -1;
+}
+
+static unsigned int get_max_width(unsigned int num)
+{
+ unsigned r = 0; /* 1x */
+
+ if (num & 8)
+ r = 3; /* 12x */
+ else {
+ if (num & 4)
+ r = 2; /* 8x */
+ else if (num & 2)
+ r = 1; /* 4x */
+ else if (num & 0x10)
+ r = 4; /* 2x */
+ }
+
+ return (1 << r);
+}
+
+static unsigned int get_max(unsigned int num)
+{
+ unsigned r = 0; // r will be lg(num)
+
+ while (num >>= 1) // unroll for more speed...
+ r++;
+
+ return (1 << r);
+}
+
+void get_max_msg(char *width_msg, char *speed_msg, int msg_size, ibnd_port_t * port)
+{
+ char buf[64];
+ uint32_t max_speed = 0;
+ uint32_t cap_mask, rem_cap_mask, fdr10;
+ uint8_t *info = NULL;
+
+ uint32_t max_width = get_max_width(mad_get_field(port->info, 0,
+ IB_PORT_LINK_WIDTH_SUPPORTED_F)
+ & mad_get_field(port->remoteport->info, 0,
+ IB_PORT_LINK_WIDTH_SUPPORTED_F));
+ if ((max_width & mad_get_field(port->info, 0,
+ IB_PORT_LINK_WIDTH_ACTIVE_F)) == 0)
+ // we are not at the max supported width
+ // print what we could be at.
+ snprintf(width_msg, msg_size, "Could be %s",
+ mad_dump_val(IB_PORT_LINK_WIDTH_ACTIVE_F,
+ buf, 64, &max_width));
+
+ if (port->node->type == IB_NODE_SWITCH) {
+ if (port->node->ports[0])
+ info = (uint8_t *)&port->node->ports[0]->info;
+ }
+ else
+ info = (uint8_t *)&port->info;
+
+ if (info)
+ cap_mask = mad_get_field(info, 0, IB_PORT_CAPMASK_F);
+ else
+ cap_mask = 0;
+
+ info = NULL;
+ if (port->remoteport->node->type == IB_NODE_SWITCH) {
+ if (port->remoteport->node->ports[0])
+ info = (uint8_t *)&port->remoteport->node->ports[0]->info;
+ } else
+ info = (uint8_t *)&port->remoteport->info;
+
+ if (info)
+ rem_cap_mask = mad_get_field(info, 0, IB_PORT_CAPMASK_F);
+ else
+ rem_cap_mask = 0;
+ if (cap_mask & CL_NTOH32(IB_PORT_CAP_HAS_EXT_SPEEDS) &&
+ rem_cap_mask & CL_NTOH32(IB_PORT_CAP_HAS_EXT_SPEEDS))
+ goto check_ext_speed;
+check_fdr10_supp:
+ fdr10 = (mad_get_field(port->ext_info, 0,
+ IB_MLNX_EXT_PORT_LINK_SPEED_SUPPORTED_F) & FDR10)
+ && (mad_get_field(port->remoteport->ext_info, 0,
+ IB_MLNX_EXT_PORT_LINK_SPEED_SUPPORTED_F) & FDR10);
+ if (fdr10)
+ goto check_fdr10_active;
+
+ max_speed = get_max(mad_get_field(port->info, 0,
+ IB_PORT_LINK_SPEED_SUPPORTED_F)
+ & mad_get_field(port->remoteport->info, 0,
+ IB_PORT_LINK_SPEED_SUPPORTED_F));
+ if ((max_speed & mad_get_field(port->info, 0,
+ IB_PORT_LINK_SPEED_ACTIVE_F)) == 0)
+ // we are not at the max supported speed
+ // print what we could be at.
+ snprintf(speed_msg, msg_size, "Could be %s",
+ mad_dump_val(IB_PORT_LINK_SPEED_ACTIVE_F,
+ buf, 64, &max_speed));
+ return;
+
+check_ext_speed:
+ if (mad_get_field(port->info, 0,
+ IB_PORT_LINK_SPEED_EXT_SUPPORTED_F) == 0 ||
+ mad_get_field(port->remoteport->info, 0,
+ IB_PORT_LINK_SPEED_EXT_SUPPORTED_F) == 0)
+ goto check_fdr10_supp;
+ max_speed = get_max(mad_get_field(port->info, 0,
+ IB_PORT_LINK_SPEED_EXT_SUPPORTED_F)
+ & mad_get_field(port->remoteport->info, 0,
+ IB_PORT_LINK_SPEED_EXT_SUPPORTED_F));
+ if ((max_speed & mad_get_field(port->info, 0,
+ IB_PORT_LINK_SPEED_EXT_ACTIVE_F)) == 0)
+ // we are not at the max supported extended speed
+ // print what we could be at.
+ snprintf(speed_msg, msg_size, "Could be %s",
+ mad_dump_val(IB_PORT_LINK_SPEED_EXT_ACTIVE_F,
+ buf, 64, &max_speed));
+ return;
+
+check_fdr10_active:
+ if ((mad_get_field(port->ext_info, 0,
+ IB_MLNX_EXT_PORT_LINK_SPEED_ACTIVE_F) & FDR10) == 0) {
+ /* Special case QDR to try to avoid confusion with FDR10 */
+ if (mad_get_field(port->info, 0, IB_PORT_LINK_SPEED_ACTIVE_F) == 4) /* QDR (10.0 Gbps) */
+ snprintf(speed_msg, msg_size,
+ "Could be FDR10 (Found link at QDR but expected speed is FDR10)");
+ else
+ snprintf(speed_msg, msg_size, "Could be FDR10");
+ }
+}
+
+int vsnprint_field(char *buf, size_t n, enum MAD_FIELDS f, int spacing,
+ const char *format, va_list va_args)
+{
+ int len, i, ret;
+
+ len = strlen(mad_field_name(f));
+ if (len + 2 > n || spacing + 1 > n)
+ return 0;
+
+ strncpy(buf, mad_field_name(f), n);
+ buf[len] = ':';
+ for (i = len+1; i < spacing+1; i++) {
+ buf[i] = '.';
+ }
+
+ ret = vsnprintf(&buf[spacing+1], n - spacing, format, va_args);
+ if (ret >= n - spacing)
+ buf[n] = '\0';
+
+ return ret + spacing;
+}
+
+int snprint_field(char *buf, size_t n, enum MAD_FIELDS f, int spacing,
+ const char *format, ...)
+{
+ va_list val;
+ int ret;
+
+ va_start(val, format);
+ ret = vsnprint_field(buf, n, f, spacing, format, val);
+ va_end(val);
+
+ return ret;
+}
+
+void dump_portinfo(void *pi, int tabs)
+{
+ int field, i;
+ char val[64];
+ char buf[1024];
+
+ for (field = IB_PORT_FIRST_F; field < IB_PORT_LAST_F; field++) {
+ for (i=0;i<tabs;i++)
+ printf("\t");
+ if (field == IB_PORT_MKEY_F && show_keys == 0) {
+ snprint_field(buf, 1024, field, 32, NOT_DISPLAYED_STR);
+ } else {
+ mad_decode_field(pi, field, val);
+ if (!mad_dump_field(field, buf, 1024, val))
+ return;
+ }
+ printf("%s\n", buf);
+ }
+
+ for (field = IB_PORT_CAPMASK2_F;
+ field < IB_PORT_LINK_SPEED_EXT_LAST_F; field++) {
+ for (i=0;i<tabs;i++)
+ printf("\t");
+ mad_decode_field(pi, field, val);
+ if (!mad_dump_field(field, buf, 1024, val))
+ return;
+ printf("%s\n", buf);
+ }
+}
+
+op_fn_t *match_op(const match_rec_t match_tbl[], char *name)
+{
+ const match_rec_t *r;
+ for (r = match_tbl; r->name; r++)
+ if (!strcasecmp(r->name, name) ||
+ (r->alias && !strcasecmp(r->alias, name)))
+ return r->fn;
+ return NULL;
+}
diff --git a/contrib/ofed/infiniband-diags/src/ibdiag_common.h b/contrib/ofed/infiniband-diags/src/ibdiag_common.h
new file mode 100644
index 0000000..08bbf6b
--- /dev/null
+++ b/contrib/ofed/infiniband-diags/src/ibdiag_common.h
@@ -0,0 +1,178 @@
+/*
+ * Copyright (c) 2006-2007 The Regents of the University of California.
+ * Copyright (c) 2004-2009 Voltaire Inc. All rights reserved.
+ * Copyright (c) 2002-2010 Mellanox Technologies LTD. All rights reserved.
+ * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
+ * Copyright (c) 2009 HNR Consulting. All rights reserved.
+ * Copyright (c) 2011 Lawrence Livermore National Security. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+#ifndef _IBDIAG_COMMON_H_
+#define _IBDIAG_COMMON_H_
+
+#include <stdarg.h>
+#include <infiniband/mad.h>
+#include <infiniband/iba/ib_types.h>
+#include <infiniband/ibnetdisc.h>
+
+extern int ibverbose;
+extern char *ibd_ca;
+extern int ibd_ca_port;
+extern enum MAD_DEST ibd_dest_type;
+extern ib_portid_t *ibd_sm_id;
+extern int ibd_timeout;
+extern uint32_t ibd_ibnetdisc_flags;
+extern uint64_t ibd_mkey;
+extern uint64_t ibd_sakey;
+extern int show_keys;
+extern char *ibd_nd_format;
+
+/*========================================================*/
+/* External interface */
+/*========================================================*/
+
+#undef DEBUG
+#define DEBUG(fmt, ...) do { \
+ if (ibdebug) IBDEBUG(fmt, ## __VA_ARGS__); \
+} while (0)
+#define VERBOSE(fmt, ...) do { \
+ if (ibverbose) IBVERBOSE(fmt, ## __VA_ARGS__); \
+} while (0)
+#define IBEXIT(fmt, ...) ibexit(__FUNCTION__, fmt, ## __VA_ARGS__)
+
+#define NOT_DISPLAYED_STR "<not displayed>"
+
+/* not all versions of ib_types.h will have this define */
+#ifndef IB_PM_PC_XMIT_WAIT_SUP
+#define IB_PM_PC_XMIT_WAIT_SUP (CL_HTON16(((uint16_t)1)<<12))
+#endif
+
+/* PM ClassPortInfo CapabilityMask Bits */
+#ifndef IS_PM_RSFEC_COUNTERS_SUP
+#define IS_PM_RSFEC_COUNTERS_SUP (CL_HTON16(((uint16_t)1)<<14))
+#endif
+
+#ifndef IB_PM_IS_QP1_DROP_SUP
+#define IB_PM_IS_QP1_DROP_SUP (CL_HTON16(((uint16_t)1)<<15))
+#endif
+
+/* PM ClassPortInfo CapabilityMask2 Bits */
+#ifndef IB_PM_IS_ADDL_PORT_CTRS_EXT_SUP
+#define IB_PM_IS_ADDL_PORT_CTRS_EXT_SUP (CL_HTON32(((uint32_t)1)<<1))
+#endif
+
+/* SM PortInfo CapabilityMask2 Bits */
+#ifndef IB_PORT_CAP2_IS_PORT_INFO_EXT_SUPPORTED
+#define IB_PORT_CAP2_IS_PORT_INFO_EXT_SUPPORTED (CL_HTON16(0x0002))
+#endif
+
+/* SM PortInfoExtended Fec Mode Bits */
+#ifndef IB_PORT_EXT_NO_FEC_MODE_ACTIVE
+#define IB_PORT_EXT_NO_FEC_MODE_ACTIVE 0
+#endif
+
+#ifndef IB_PORT_EXT_FIRE_CODE_FEC_MODE_ACTIVE
+#define IB_PORT_EXT_FIRE_CODE_FEC_MODE_ACTIVE (CL_HTON16(0x0001))
+#endif
+
+#ifndef IB_PORT_EXT_RS_FEC_MODE_ACTIVE
+#define IB_PORT_EXT_RS_FEC_MODE_ACTIVE (CL_HTON16(0x0002))
+#endif
+
+#ifndef IB_PORT_EXT_LOW_LATENCY_RS_FEC_MODE_ACTIVE
+#define IB_PORT_EXT_LOW_LATENCY_RS_FEC_MODE_ACTIVE (CL_HTON16(0x0003))
+#endif
+
+/* SM PortInfoExtended CapabilityMask Bits */
+#ifndef IB_PORT_EXT_CAP_IS_FEC_MODE_SUPPORTED
+#define IB_PORT_EXT_CAP_IS_FEC_MODE_SUPPORTED (CL_HTON32(0x00000001))
+#endif
+
+struct ibdiag_opt {
+ const char *name;
+ char letter;
+ unsigned has_arg;
+ const char *arg_tmpl;
+ const char *description;
+};
+
+extern int ibdiag_process_opts(int argc, char *const argv[], void *context,
+ const char *exclude_common_str,
+ const struct ibdiag_opt custom_opts[],
+ int (*custom_handler) (void *cxt, int val,
+ char *optarg),
+ const char *usage_args,
+ const char *usage_examples[]);
+extern void ibdiag_show_usage();
+extern void ibexit(const char *fn, char *msg, ...);
+
+/* convert counter values to a float with a unit specifier returned (using
+ * binary prefix)
+ * "data" is a flag indicating this counter is a byte counter multiplied by 4
+ * as per PortCounters[Extended]
+ */
+extern char *conv_cnt_human_readable(uint64_t val64, float *val, int data);
+
+int is_mlnx_ext_port_info_supported(uint32_t vendorid, uint16_t devid);
+
+int is_port_info_extended_supported(ib_portid_t * dest, int port,
+ struct ibmad_port *srcport);
+void get_max_msg(char *width_msg, char *speed_msg, int msg_size,
+ ibnd_port_t * port);
+
+int resolve_sm_portid(char *ca_name, uint8_t portnum, ib_portid_t *sm_id);
+int resolve_self(char *ca_name, uint8_t ca_port, ib_portid_t *portid,
+ int *port, ibmad_gid_t *gid);
+int resolve_portid_str(char *ca_name, uint8_t ca_port, ib_portid_t * portid,
+ char *addr_str, enum MAD_DEST dest_type,
+ ib_portid_t *sm_id, const struct ibmad_port *srcport);
+int vsnprint_field(char *buf, size_t n, enum MAD_FIELDS f, int spacing,
+ const char *format, va_list va_args);
+int snprint_field(char *buf, size_t n, enum MAD_FIELDS f, int spacing,
+ const char *format, ...);
+void dump_portinfo(void *pi, int tabs);
+
+/**
+ * Some common command line parsing
+ */
+typedef char *(op_fn_t) (ib_portid_t * dest, char **argv, int argc);
+
+typedef struct match_rec {
+ const char *name, *alias;
+ op_fn_t *fn;
+ unsigned opt_portnum;
+ char *ops_extra;
+} match_rec_t;
+
+op_fn_t *match_op(const match_rec_t match_tbl[], char *name);
+
+#endif /* _IBDIAG_COMMON_H_ */
diff --git a/contrib/ofed/infiniband-diags/src/ibdiag_sa.c b/contrib/ofed/infiniband-diags/src/ibdiag_sa.c
new file mode 100644
index 0000000..ea272a9
--- /dev/null
+++ b/contrib/ofed/infiniband-diags/src/ibdiag_sa.c
@@ -0,0 +1,256 @@
+/*
+ * Copyright (c) 2006-2007 The Regents of the University of California.
+ * Copyright (c) 2004-2009 Voltaire, Inc. All rights reserved.
+ * Copyright (c) 2002-2010 Mellanox Technologies LTD. All rights reserved.
+ * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
+ * Copyright (c) 2009 HNR Consulting. All rights reserved.
+ * Copyright (c) 2011 Lawrence Livermore National Security. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+
+#include <errno.h>
+#include <infiniband/umad.h>
+
+#include "ibdiag_common.h"
+#include "ibdiag_sa.h"
+
+/* define a common SA query structure
+ * This is by no means optimal but it moves the saquery functionality out of
+ * the saquery tool and provides it to other utilities.
+ */
+
+struct sa_handle * sa_get_handle(void)
+{
+ struct sa_handle * handle;
+ handle = calloc(1, sizeof(*handle));
+ if (!handle)
+ IBPANIC("calloc failed");
+
+ resolve_sm_portid(ibd_ca, ibd_ca_port, &handle->dport);
+ if (!handle->dport.lid) {
+ IBWARN("No SM/SA found on port %s:%d",
+ ibd_ca ? "" : ibd_ca,
+ ibd_ca_port);
+ free(handle);
+ return (NULL);
+ }
+
+ handle->dport.qp = 1;
+ if (!handle->dport.qkey)
+ handle->dport.qkey = IB_DEFAULT_QP1_QKEY;
+
+ handle->fd = umad_open_port(ibd_ca, ibd_ca_port);
+ handle->agent = umad_register(handle->fd, IB_SA_CLASS, 2, 1, NULL);
+
+ return handle;
+}
+
+int sa_set_handle(struct sa_handle * handle, int grh_present, ibmad_gid_t *gid)
+{
+ if (grh_present) {
+ if (gid == NULL) {
+ return -1;
+ } else {
+ handle->dport.grh_present = 1;
+ memcpy(handle->dport.gid, gid, 16);
+ }
+ }
+ return 0;
+}
+
+void sa_free_handle(struct sa_handle * h)
+{
+ umad_unregister(h->fd, h->agent);
+ umad_close_port(h->fd);
+ free(h);
+}
+
+int sa_query(struct sa_handle * h, uint8_t method,
+ uint16_t attr, uint32_t mod, uint64_t comp_mask,
+ uint64_t sm_key, void *data, size_t datasz,
+ struct sa_query_result *result)
+{
+ ib_rpc_t rpc;
+ void *umad, *mad;
+ int ret, offset, len = 256;
+
+ memset(&rpc, 0, sizeof(rpc));
+ rpc.mgtclass = IB_SA_CLASS;
+ rpc.method = method;
+ rpc.attr.id = attr;
+ rpc.attr.mod = mod;
+ rpc.mask = comp_mask;
+ rpc.datasz = datasz;
+ rpc.dataoffs = IB_SA_DATA_OFFS;
+
+ umad = calloc(1, len + umad_size());
+ if (!umad)
+ IBPANIC("cannot alloc mem for umad: %s\n", strerror(errno));
+
+ mad_build_pkt(umad, &rpc, &h->dport, NULL, data);
+
+ mad_set_field64(umad_get_mad(umad), 0, IB_SA_MKEY_F, sm_key);
+
+ if (ibdebug > 1)
+ xdump(stdout, "SA Request:\n", umad_get_mad(umad), len);
+
+ if (h->dport.grh_present) {
+ ib_mad_addr_t *p_mad_addr = umad_get_mad_addr(umad);
+ p_mad_addr->grh_present = 1;
+ p_mad_addr->gid_index = 0;
+ p_mad_addr->hop_limit = 0;
+ p_mad_addr->traffic_class = 0;
+ memcpy(p_mad_addr->gid, h->dport.gid, 16);
+ }
+
+ ret = umad_send(h->fd, h->agent, umad, len, ibd_timeout, 0);
+ if (ret < 0) {
+ IBWARN("umad_send failed: attr 0x%x: %s\n",
+ attr, strerror(errno));
+ free(umad);
+ return (-ret);
+ }
+
+recv_mad:
+ ret = umad_recv(h->fd, umad, &len, ibd_timeout);
+ if (ret < 0) {
+ if (errno == ENOSPC) {
+ umad = realloc(umad, umad_size() + len);
+ goto recv_mad;
+ }
+ IBWARN("umad_recv failed: attr 0x%x: %s\n", attr,
+ strerror(errno));
+ free(umad);
+ return (-ret);
+ }
+
+ if ((ret = umad_status(umad)))
+ return ret;
+
+ mad = umad_get_mad(umad);
+
+ if (ibdebug > 1)
+ xdump(stdout, "SA Response:\n", mad, len);
+
+ method = (uint8_t) mad_get_field(mad, 0, IB_MAD_METHOD_F);
+ offset = mad_get_field(mad, 0, IB_SA_ATTROFFS_F);
+ result->status = mad_get_field(mad, 0, IB_MAD_STATUS_F);
+ result->p_result_madw = mad;
+ if (result->status != IB_SA_MAD_STATUS_SUCCESS)
+ result->result_cnt = 0;
+ else if (method != IB_MAD_METHOD_GET_TABLE)
+ result->result_cnt = 1;
+ else if (!offset)
+ result->result_cnt = 0;
+ else
+ result->result_cnt = (len - IB_SA_DATA_OFFS) / (offset << 3);
+
+ return 0;
+}
+
+void sa_free_result_mad(struct sa_query_result *result)
+{
+ if (result->p_result_madw) {
+ free((uint8_t *) result->p_result_madw - umad_size());
+ result->p_result_madw = NULL;
+ }
+}
+
+void *sa_get_query_rec(void *mad, unsigned i)
+{
+ int offset = mad_get_field(mad, 0, IB_SA_ATTROFFS_F);
+ return (uint8_t *) mad + IB_SA_DATA_OFFS + i * (offset << 3);
+}
+
+static const char *ib_sa_error_str[] = {
+ "SA_NO_ERROR",
+ "SA_ERR_NO_RESOURCES",
+ "SA_ERR_REQ_INVALID",
+ "SA_ERR_NO_RECORDS",
+ "SA_ERR_TOO_MANY_RECORDS",
+ "SA_ERR_REQ_INVALID_GID",
+ "SA_ERR_REQ_INSUFFICIENT_COMPONENTS",
+ "SA_ERR_REQ_DENIED",
+ "SA_ERR_STATUS_PRIO_SUGGESTED",
+ "SA_ERR_UNKNOWN"
+};
+
+#define ARR_SIZE(a) (sizeof(a)/sizeof((a)[0]))
+#define SA_ERR_UNKNOWN (ARR_SIZE(ib_sa_error_str) - 1)
+
+static inline const char *ib_sa_err_str(IN uint8_t status)
+{
+ if (status > SA_ERR_UNKNOWN)
+ status = SA_ERR_UNKNOWN;
+ return (ib_sa_error_str[status]);
+}
+
+static const char *ib_mad_inv_field_str[] = {
+ "MAD No invalid fields",
+ "MAD Bad version",
+ "MAD Method specified is not supported",
+ "MAD Method/Attribute combination is not supported",
+ "MAD Reserved",
+ "MAD Reserved",
+ "MAD Reserved",
+ "MAD Invalid value in Attribute field(s) or Attribute Modifier"
+ "MAD UNKNOWN ERROR"
+};
+#define MAD_ERR_UNKNOWN (ARR_SIZE(ib_mad_inv_field_str) - 1)
+
+static inline const char *ib_mad_inv_field_err_str(IN uint8_t f)
+{
+ if (f > MAD_ERR_UNKNOWN)
+ f = MAD_ERR_UNKNOWN;
+ return (ib_mad_inv_field_str[f]);
+}
+
+void sa_report_err(int status)
+{
+ int st = status & 0xff;
+ char mad_err_str[64] = { 0 };
+ char sa_err_str[64] = { 0 };
+
+ if (st)
+ sprintf(mad_err_str, " (%s; %s; %s)",
+ (st & 0x1) ? "BUSY" : "",
+ (st & 0x2) ? "Redirection Required" : "",
+ ib_mad_inv_field_err_str(st>>2));
+
+
+ st = status >> 8;
+ if (st)
+ sprintf(sa_err_str, " SA(%s)", ib_sa_err_str((uint8_t) st));
+
+ fprintf(stderr, "ERROR: Query result returned 0x%04x, %s%s\n",
+ status, mad_err_str, sa_err_str);
+}
diff --git a/contrib/ofed/infiniband-diags/src/ibdiag_sa.h b/contrib/ofed/infiniband-diags/src/ibdiag_sa.h
new file mode 100644
index 0000000..537fcfe
--- /dev/null
+++ b/contrib/ofed/infiniband-diags/src/ibdiag_sa.h
@@ -0,0 +1,94 @@
+/*
+ * Copyright (c) 2006-2007 The Regents of the University of California.
+ * Copyright (c) 2004-2009 Voltaire Inc. All rights reserved.
+ * Copyright (c) 2002-2010 Mellanox Technologies LTD. All rights reserved.
+ * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
+ * Copyright (c) 2009 HNR Consulting. All rights reserved.
+ * Copyright (c) 2012 Lawrence Livermore National Security. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+#ifndef _IBDIAG_SA_H_
+#define _IBDIAG_SA_H_
+
+#include <infiniband/mad.h>
+#include <infiniband/iba/ib_types.h>
+
+/* define an SA query structure to be common
+ * This is by no means optimal but it moves the saquery functionality out of
+ * the saquery tool and provides it to other utilities.
+ */
+struct sa_handle {
+ int fd, agent;
+ ib_portid_t dport;
+ struct ibmad_port *srcport;
+};
+
+struct sa_query_result {
+ uint32_t status;
+ unsigned result_cnt;
+ void *p_result_madw;
+};
+
+/* NOTE: umad_init must be called prior to sa_get_handle */
+struct sa_handle * sa_get_handle(void);
+int sa_set_handle(struct sa_handle * handle, int grh_present, ibmad_gid_t *gid);
+void sa_free_handle(struct sa_handle * h);
+
+int sa_query(struct sa_handle *h, uint8_t method,
+ uint16_t attr, uint32_t mod, uint64_t comp_mask, uint64_t sm_key,
+ void *data, size_t datasz, struct sa_query_result *result);
+void sa_free_result_mad(struct sa_query_result *result);
+void *sa_get_query_rec(void *mad, unsigned i);
+void sa_report_err(int status);
+
+/* Macros for setting query values and ComponentMasks */
+#define cl_hton8(x) (x)
+#define CHECK_AND_SET_VAL(val, size, comp_with, target, name, mask) \
+ if ((int##size##_t) val != (int##size##_t) comp_with) { \
+ target = cl_hton##size((uint##size##_t) val); \
+ comp_mask |= IB_##name##_COMPMASK_##mask; \
+ }
+
+#define CHECK_AND_SET_GID(val, target, name, mask) \
+ if (valid_gid(&(val))) { \
+ memcpy(&(target), &(val), sizeof(val)); \
+ comp_mask |= IB_##name##_COMPMASK_##mask; \
+ }
+
+#define CHECK_AND_SET_VAL_AND_SEL(val, target, name, mask, sel) \
+ if (val) { \
+ target = val; \
+ comp_mask |= IB_##name##_COMPMASK_##mask##sel; \
+ comp_mask |= IB_##name##_COMPMASK_##mask; \
+ }
+
+#endif /* _IBDIAG_SA_H_ */
diff --git a/contrib/ofed/infiniband-diags/src/ibdiag_version.h b/contrib/ofed/infiniband-diags/src/ibdiag_version.h
new file mode 100644
index 0000000..142d718
--- /dev/null
+++ b/contrib/ofed/infiniband-diags/src/ibdiag_version.h
@@ -0,0 +1,39 @@
+/*
+ * Copyright (c) 2008 Voltaire Inc. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+#ifndef _IBDIAG_VERSION_H_
+#define _IBDIAG_VERSION_H_
+
+#define IBDIAG_VERSION "1.6.7"
+
+#endif /* _IBDIAG_VERSION_H_ */
diff --git a/contrib/ofed/infiniband-diags/src/iblinkinfo.c b/contrib/ofed/infiniband-diags/src/iblinkinfo.c
new file mode 100644
index 0000000..40e012d
--- /dev/null
+++ b/contrib/ofed/infiniband-diags/src/iblinkinfo.c
@@ -0,0 +1,768 @@
+/*
+ * Copyright (c) 2004-2009 Voltaire Inc. All rights reserved.
+ * Copyright (c) 2007 Xsigo Systems Inc. All rights reserved.
+ * Copyright (c) 2008 Lawrence Livermore National Lab. All rights reserved.
+ * Copyright (c) 2010,2011 Mellanox Technologies LTD. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+#if HAVE_CONFIG_H
+# include <config.h>
+#endif /* HAVE_CONFIG_H */
+
+#define _GNU_SOURCE
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <stdarg.h>
+#include <time.h>
+#include <string.h>
+#include <getopt.h>
+#include <errno.h>
+#include <inttypes.h>
+
+#include <complib/cl_nodenamemap.h>
+#include <infiniband/ibnetdisc.h>
+
+#include "ibdiag_common.h"
+
+#define DIFF_FLAG_PORT_CONNECTION 0x01
+#define DIFF_FLAG_PORT_STATE 0x02
+#define DIFF_FLAG_LID 0x04
+#define DIFF_FLAG_NODE_DESCRIPTION 0x08
+
+#define DIFF_FLAG_DEFAULT (DIFF_FLAG_PORT_CONNECTION | DIFF_FLAG_PORT_STATE)
+
+static char *node_name_map_file = NULL;
+static nn_map_t *node_name_map = NULL;
+static char *load_cache_file = NULL;
+static char *diff_cache_file = NULL;
+static unsigned diffcheck_flags = DIFF_FLAG_DEFAULT;
+static char *filterdownports_cache_file = NULL;
+static ibnd_fabric_t *filterdownports_fabric = NULL;
+
+static uint64_t guid = 0;
+static char *guid_str = NULL;
+static char *dr_path = NULL;
+static int all = 0;
+
+static int down_links_only = 0;
+static int line_mode = 0;
+static int add_sw_settings = 0;
+static int only_flag = 0;
+static int only_type = 0;
+
+int filterdownport_check(ibnd_node_t * node, ibnd_port_t * port)
+{
+ ibnd_node_t *fsw;
+ ibnd_port_t *fport;
+ int fistate;
+
+ fsw = ibnd_find_node_guid(filterdownports_fabric, node->guid);
+
+ if (!fsw)
+ return 0;
+
+ if (port->portnum > fsw->numports)
+ return 0;
+
+ fport = fsw->ports[port->portnum];
+
+ if (!fport)
+ return 0;
+
+ fistate = mad_get_field(fport->info, 0, IB_PORT_STATE_F);
+
+ return (fistate == IB_LINK_DOWN) ? 1 : 0;
+}
+
+void print_port(ibnd_node_t * node, ibnd_port_t * port, char *out_prefix)
+{
+ char width[64], speed[64], state[64], physstate[64];
+ char remote_guid_str[256];
+ char remote_str[256];
+ char link_str[256];
+ char width_msg[256];
+ char speed_msg[256];
+ char ext_port_str[256];
+ int iwidth, ispeed, fdr10, espeed, istate, iphystate, cap_mask;
+ int n = 0;
+ uint8_t *info = NULL;
+
+ if (!port)
+ return;
+
+ iwidth = mad_get_field(port->info, 0, IB_PORT_LINK_WIDTH_ACTIVE_F);
+ ispeed = mad_get_field(port->info, 0, IB_PORT_LINK_SPEED_ACTIVE_F);
+ fdr10 = mad_get_field(port->ext_info, 0,
+ IB_MLNX_EXT_PORT_LINK_SPEED_ACTIVE_F) & FDR10;
+
+ if (port->node->type == IB_NODE_SWITCH) {
+ if (port->node->ports[0])
+ info = (uint8_t *)&port->node->ports[0]->info;
+ }
+ else
+ info = (uint8_t *)&port->info;
+
+ if (info) {
+ cap_mask = mad_get_field(info, 0, IB_PORT_CAPMASK_F);
+ if (cap_mask & CL_NTOH32(IB_PORT_CAP_HAS_EXT_SPEEDS))
+ espeed = mad_get_field(port->info, 0,
+ IB_PORT_LINK_SPEED_EXT_ACTIVE_F);
+ else
+ espeed = 0;
+ } else {
+ ispeed = 0;
+ iwidth = 0;
+ espeed = 0;
+ }
+
+ istate = mad_get_field(port->info, 0, IB_PORT_STATE_F);
+ iphystate = mad_get_field(port->info, 0, IB_PORT_PHYS_STATE_F);
+
+ remote_guid_str[0] = '\0';
+ remote_str[0] = '\0';
+ link_str[0] = '\0';
+ width_msg[0] = '\0';
+ speed_msg[0] = '\0';
+
+ if (istate == IB_LINK_DOWN
+ && filterdownports_fabric
+ && filterdownport_check(node, port))
+ return;
+
+ /* C14-24.2.1 states that a down port allows for invalid data to be
+ * returned for all PortInfo components except PortState and
+ * PortPhysicalState */
+ if (istate != IB_LINK_DOWN) {
+ if (!espeed) {
+ if (fdr10)
+ sprintf(speed, "10.0 Gbps (FDR10)");
+ else
+ mad_dump_val(IB_PORT_LINK_SPEED_ACTIVE_F, speed,
+ 64, &ispeed);
+ } else
+ mad_dump_val(IB_PORT_LINK_SPEED_EXT_ACTIVE_F, speed,
+ 64, &espeed);
+
+ n = snprintf(link_str, 256, "(%3s %18s %6s/%8s)",
+ mad_dump_val(IB_PORT_LINK_WIDTH_ACTIVE_F, width, 64,
+ &iwidth),
+ speed,
+ mad_dump_val(IB_PORT_STATE_F, state, 64, &istate),
+ mad_dump_val(IB_PORT_PHYS_STATE_F, physstate, 64,
+ &iphystate));
+ } else {
+ n = snprintf(link_str, 256, "( %6s/%8s)",
+ mad_dump_val(IB_PORT_STATE_F, state, 64, &istate),
+ mad_dump_val(IB_PORT_PHYS_STATE_F, physstate, 64,
+ &iphystate));
+ }
+
+ /* again default values due to C14-24.2.1 */
+ if (add_sw_settings && istate != IB_LINK_DOWN) {
+ snprintf(link_str + n, 256 - n,
+ " (HOQ:%d VL_Stall:%d)",
+ mad_get_field(port->info, 0,
+ IB_PORT_HOQ_LIFE_F),
+ mad_get_field(port->info, 0,
+ IB_PORT_VL_STALL_COUNT_F));
+ }
+
+ if (port->remoteport) {
+ char *remap =
+ remap_node_name(node_name_map, port->remoteport->node->guid,
+ port->remoteport->node->nodedesc);
+
+ if (port->remoteport->ext_portnum)
+ snprintf(ext_port_str, 256, "%d",
+ port->remoteport->ext_portnum);
+ else
+ ext_port_str[0] = '\0';
+
+ get_max_msg(width_msg, speed_msg, 256, port);
+
+ if (line_mode) {
+ snprintf(remote_guid_str, 256,
+ "0x%016" PRIx64 " ",
+ port->remoteport->guid);
+ }
+
+ snprintf(remote_str, 256, "%s%6d %4d[%2s] \"%s\" (%s %s)\n",
+ remote_guid_str, port->remoteport->base_lid ?
+ port->remoteport->base_lid :
+ port->remoteport->node->smalid,
+ port->remoteport->portnum, ext_port_str, remap,
+ width_msg, speed_msg);
+ free(remap);
+ } else {
+ if (istate == IB_LINK_DOWN)
+ snprintf(remote_str, 256, " [ ] \"\" ( )\n");
+ else
+ snprintf(remote_str, 256, " \"Port not available\"\n");
+ }
+
+ if (port->ext_portnum)
+ snprintf(ext_port_str, 256, "%d", port->ext_portnum);
+ else
+ ext_port_str[0] = '\0';
+
+ if (line_mode) {
+ char *remap = remap_node_name(node_name_map, node->guid,
+ node->nodedesc);
+ printf("%s0x%016" PRIx64 " \"%30s\" ",
+ out_prefix ? out_prefix : "",
+ port->guid, remap);
+ free(remap);
+ } else
+ printf("%s ", out_prefix ? out_prefix : "");
+
+ if (port->node->type != IB_NODE_SWITCH) {
+ if (!line_mode)
+ printf("0x%016" PRIx64 " ", port->guid);
+
+ printf("%6d %4d[%2s] ==%s==> %s",
+ port->base_lid,
+ port->portnum, ext_port_str, link_str, remote_str);
+ } else
+ printf("%6d %4d[%2s] ==%s==> %s",
+ node->smalid, port->portnum, ext_port_str,
+ link_str, remote_str);
+}
+
+static inline const char *nodetype_str(ibnd_node_t * node)
+{
+ switch (node->type) {
+ case IB_NODE_SWITCH:
+ return "Switch";
+ case IB_NODE_CA:
+ return "CA";
+ case IB_NODE_ROUTER:
+ return "Router";
+ }
+ return "??";
+}
+
+void print_node_header(ibnd_node_t *node, int *out_header_flag,
+ char *out_prefix)
+{
+ uint64_t guid = 0;
+ if ((!out_header_flag || !(*out_header_flag)) && !line_mode) {
+ char *remap =
+ remap_node_name(node_name_map, node->guid, node->nodedesc);
+ if (node->type == IB_NODE_SWITCH) {
+ if (node->ports[0])
+ guid = node->ports[0]->guid;
+ else /* if (node->info) */
+ guid = mad_get_field64(node->info, 0, IB_NODE_PORT_GUID_F);
+
+ printf("%s%s: 0x%016" PRIx64 " %s:\n",
+ out_prefix ? out_prefix : "",
+ nodetype_str(node),
+ guid,
+ remap);
+ } else
+ printf("%s%s: %s:\n",
+ out_prefix ? out_prefix : "",
+ nodetype_str(node), remap);
+ (*out_header_flag)++;
+ free(remap);
+ }
+}
+
+void print_node(ibnd_node_t * node, void *user_data)
+{
+ int i = 0;
+ int head_print = 0;
+ char *out_prefix = (char *)user_data;
+
+ for (i = 1; i <= node->numports; i++) {
+ ibnd_port_t *port = node->ports[i];
+ if (!port)
+ continue;
+ if (!down_links_only ||
+ mad_get_field(port->info, 0,
+ IB_PORT_STATE_F) == IB_LINK_DOWN) {
+ print_node_header(node, &head_print, out_prefix);
+ print_port(node, port, out_prefix);
+ }
+ }
+}
+
+struct iter_diff_data {
+ uint32_t diff_flags;
+ ibnd_fabric_t *fabric1;
+ ibnd_fabric_t *fabric2;
+ char *fabric1_prefix;
+ char *fabric2_prefix;
+};
+
+void diff_node_ports(ibnd_node_t * fabric1_node, ibnd_node_t * fabric2_node,
+ int *head_print, struct iter_diff_data *data)
+{
+ int i = 0;
+
+ for (i = 1; i <= fabric1_node->numports; i++) {
+ ibnd_port_t *fabric1_port, *fabric2_port;
+ int output_diff = 0;
+
+ fabric1_port = fabric1_node->ports[i];
+ fabric2_port = fabric2_node->ports[i];
+
+ if (!fabric1_port && !fabric2_port)
+ continue;
+
+ if (data->diff_flags & DIFF_FLAG_PORT_CONNECTION) {
+ if ((fabric1_port && !fabric2_port)
+ || (!fabric1_port && fabric2_port)
+ || (fabric1_port->remoteport
+ && !fabric2_port->remoteport)
+ || (!fabric1_port->remoteport
+ && fabric2_port->remoteport)
+ || (fabric1_port->remoteport
+ && fabric2_port->remoteport
+ && fabric1_port->remoteport->guid !=
+ fabric2_port->remoteport->guid))
+ output_diff++;
+ }
+
+ /* if either fabric1_port or fabric2_port NULL, should be
+ * handled by port connection diff code
+ */
+ if (data->diff_flags & DIFF_FLAG_PORT_STATE
+ && fabric1_port
+ && fabric2_port) {
+ int state1, state2;
+
+ state1 = mad_get_field(fabric1_port->info, 0,
+ IB_PORT_STATE_F);
+ state2 = mad_get_field(fabric2_port->info, 0,
+ IB_PORT_STATE_F);
+
+ if (state1 != state2)
+ output_diff++;
+ }
+
+ if (data->diff_flags & DIFF_FLAG_PORT_CONNECTION
+ && data->diff_flags & DIFF_FLAG_LID
+ && fabric1_port && fabric2_port
+ && fabric1_port->remoteport && fabric2_port->remoteport
+ && fabric1_port->remoteport->base_lid != fabric2_port->remoteport->base_lid)
+ output_diff++;
+
+ if (data->diff_flags & DIFF_FLAG_PORT_CONNECTION
+ && data->diff_flags & DIFF_FLAG_NODE_DESCRIPTION
+ && fabric1_port && fabric2_port
+ && fabric1_port->remoteport && fabric2_port->remoteport
+ && memcmp(fabric1_port->remoteport->node->nodedesc,
+ fabric2_port->remoteport->node->nodedesc,
+ IB_SMP_DATA_SIZE))
+ output_diff++;
+
+ if (output_diff && fabric1_port) {
+ print_node_header(fabric1_node,
+ head_print,
+ NULL);
+ print_port(fabric1_node,
+ fabric1_port,
+ data->fabric1_prefix);
+ }
+
+ if (output_diff && fabric2_port) {
+ print_node_header(fabric1_node,
+ head_print,
+ NULL);
+ print_port(fabric2_node,
+ fabric2_port,
+ data->fabric2_prefix);
+ }
+ }
+}
+
+void diff_node_iter(ibnd_node_t * fabric1_node, void *iter_user_data)
+{
+ struct iter_diff_data *data = iter_user_data;
+ ibnd_node_t *fabric2_node;
+ int head_print = 0;
+
+ DEBUG("DEBUG: fabric1_node %p\n", fabric1_node);
+
+ fabric2_node = ibnd_find_node_guid(data->fabric2, fabric1_node->guid);
+ if (!fabric2_node)
+ print_node(fabric1_node, data->fabric1_prefix);
+ else if (data->diff_flags &
+ (DIFF_FLAG_PORT_CONNECTION | DIFF_FLAG_PORT_STATE
+ | DIFF_FLAG_LID | DIFF_FLAG_NODE_DESCRIPTION)) {
+
+ if ((fabric1_node->type == IB_NODE_SWITCH
+ && data->diff_flags & DIFF_FLAG_LID
+ && fabric1_node->smalid != fabric2_node->smalid) ||
+ (data->diff_flags & DIFF_FLAG_NODE_DESCRIPTION
+ && memcmp(fabric1_node->nodedesc, fabric2_node->nodedesc,
+ IB_SMP_DATA_SIZE))) {
+ print_node_header(fabric1_node,
+ NULL,
+ data->fabric1_prefix);
+ print_node_header(fabric2_node,
+ NULL,
+ data->fabric2_prefix);
+ head_print++;
+ }
+
+ if (fabric1_node->numports != fabric2_node->numports) {
+ print_node_header(fabric1_node,
+ &head_print,
+ NULL);
+ printf("%snumports = %d\n", data->fabric1_prefix,
+ fabric1_node->numports);
+ printf("%snumports = %d\n", data->fabric2_prefix,
+ fabric2_node->numports);
+ return;
+ }
+
+ diff_node_ports(fabric1_node, fabric2_node,
+ &head_print, data);
+ }
+}
+
+int diff_node(ibnd_node_t * node, ibnd_fabric_t * orig_fabric,
+ ibnd_fabric_t * new_fabric)
+{
+ struct iter_diff_data iter_diff_data;
+
+ iter_diff_data.diff_flags = diffcheck_flags;
+ iter_diff_data.fabric1 = orig_fabric;
+ iter_diff_data.fabric2 = new_fabric;
+ iter_diff_data.fabric1_prefix = "< ";
+ iter_diff_data.fabric2_prefix = "> ";
+ if (node)
+ diff_node_iter(node, &iter_diff_data);
+ else {
+ if (only_flag)
+ ibnd_iter_nodes_type(orig_fabric, diff_node_iter,
+ only_type, &iter_diff_data);
+ else
+ ibnd_iter_nodes(orig_fabric, diff_node_iter,
+ &iter_diff_data);
+ }
+
+ /* Do opposite diff to find existence of node types
+ * in new_fabric but not in orig_fabric.
+ *
+ * In this diff, we don't need to check port connections,
+ * port state, lids, or node descriptions since it has already
+ * been done (i.e. checks are only done when guid exists on both
+ * orig and new).
+ */
+ iter_diff_data.diff_flags = diffcheck_flags & ~DIFF_FLAG_PORT_CONNECTION;
+ iter_diff_data.diff_flags &= ~DIFF_FLAG_PORT_STATE;
+ iter_diff_data.diff_flags &= ~DIFF_FLAG_LID;
+ iter_diff_data.diff_flags &= ~DIFF_FLAG_NODE_DESCRIPTION;
+ iter_diff_data.fabric1 = new_fabric;
+ iter_diff_data.fabric2 = orig_fabric;
+ iter_diff_data.fabric1_prefix = "> ";
+ iter_diff_data.fabric2_prefix = "< ";
+ if (node)
+ diff_node_iter(node, &iter_diff_data);
+ else {
+ if (only_flag)
+ ibnd_iter_nodes_type(new_fabric, diff_node_iter,
+ only_type, &iter_diff_data);
+ else
+ ibnd_iter_nodes(new_fabric, diff_node_iter,
+ &iter_diff_data);
+ }
+
+ return 0;
+}
+
+static int process_opt(void *context, int ch, char *optarg)
+{
+ struct ibnd_config *cfg = context;
+ char *p;
+
+ switch (ch) {
+ case 1:
+ node_name_map_file = strdup(optarg);
+ break;
+ case 2:
+ load_cache_file = strdup(optarg);
+ break;
+ case 3:
+ diff_cache_file = strdup(optarg);
+ break;
+ case 4:
+ diffcheck_flags = 0;
+ p = strtok(optarg, ",");
+ while (p) {
+ if (!strcasecmp(p, "port"))
+ diffcheck_flags |= DIFF_FLAG_PORT_CONNECTION;
+ else if (!strcasecmp(p, "state"))
+ diffcheck_flags |= DIFF_FLAG_PORT_STATE;
+ else if (!strcasecmp(p, "lid"))
+ diffcheck_flags |= DIFF_FLAG_LID;
+ else if (!strcasecmp(p, "nodedesc"))
+ diffcheck_flags |= DIFF_FLAG_NODE_DESCRIPTION;
+ else {
+ fprintf(stderr, "invalid diff check key: %s\n",
+ p);
+ return -1;
+ }
+ p = strtok(NULL, ",");
+ }
+ break;
+ case 5:
+ filterdownports_cache_file = strdup(optarg);
+ break;
+ case 6:
+ only_flag = 1;
+ only_type = IB_NODE_SWITCH;
+ break;
+ case 7:
+ only_flag = 1;
+ only_type = IB_NODE_CA;
+ break;
+ case 'S':
+ case 'G':
+ guid_str = optarg;
+ guid = (uint64_t) strtoull(guid_str, 0, 0);
+ break;
+ case 'D':
+ dr_path = strdup(optarg);
+ break;
+ case 'a':
+ all = 1;
+ break;
+ case 'n':
+ cfg->max_hops = strtoul(optarg, NULL, 0);
+ break;
+ case 'd':
+ down_links_only = 1;
+ break;
+ case 'l':
+ line_mode = 1;
+ break;
+ case 'p':
+ add_sw_settings = 1;
+ break;
+ case 'R': /* nop */
+ break;
+ case 'o':
+ cfg->max_smps = strtoul(optarg, NULL, 0);
+ break;
+ default:
+ return -1;
+ }
+
+ return 0;
+}
+
+int main(int argc, char **argv)
+{
+ struct ibnd_config config = { 0 };
+ int rc = 0;
+ int resolved = -1;
+ ibnd_fabric_t *fabric = NULL;
+ ibnd_fabric_t *diff_fabric = NULL;
+ struct ibmad_port *ibmad_port;
+ ib_portid_t port_id = { 0 };
+ uint8_t ni[IB_SMP_DATA_SIZE] = { 0 };
+ int mgmt_classes[3] =
+ { IB_SMI_CLASS, IB_SMI_DIRECT_CLASS, IB_SA_CLASS };
+
+ const struct ibdiag_opt opts[] = {
+ {"node-name-map", 1, 1, "<file>", "node name map file"},
+ {"switch", 'S', 1, "<port_guid>",
+ "start partial scan at the port specified by <port_guid> (hex format)"},
+ {"port-guid", 'G', 1, "<port_guid>",
+ "(same as -S)"},
+ {"Direct", 'D', 1, "<dr_path>",
+ "start partial scan at the port specified by <dr_path>"},
+ {"all", 'a', 0, NULL,
+ "print all nodes found in a partial fabric scan"},
+ {"hops", 'n', 1, "<hops>",
+ "Number of hops to include away from specified node"},
+ {"down", 'd', 0, NULL, "print only down links"},
+ {"line", 'l', 0, NULL,
+ "(line mode) print all information for each link on a single line"},
+ {"additional", 'p', 0, NULL,
+ "print additional port settings (PktLifeTime, HoqLife, VLStallCount)"},
+ {"load-cache", 2, 1, "<file>",
+ "filename of ibnetdiscover cache to load"},
+ {"diff", 3, 1, "<file>",
+ "filename of ibnetdiscover cache to diff"},
+ {"diffcheck", 4, 1, "<key(s)>",
+ "specify checks to execute for --diff"},
+ {"filterdownports", 5, 1, "<file>",
+ "filename of ibnetdiscover cache to filter downports"},
+ {"outstanding_smps", 'o', 1, NULL,
+ "specify the number of outstanding SMP's which should be "
+ "issued during the scan"},
+ {"switches-only", 6, 0, NULL,
+ "Output only switches"},
+ {"cas-only", 7, 0, NULL,
+ "Output only CAs"},
+ {0}
+ };
+ char usage_args[] = "";
+
+ ibdiag_process_opts(argc, argv, &config, "aDdGgKLlnpRS", opts,
+ process_opt, usage_args, NULL);
+
+ argc -= optind;
+ argv += optind;
+
+ ibmad_port = mad_rpc_open_port(ibd_ca, ibd_ca_port, mgmt_classes, 3);
+ if (!ibmad_port) {
+ fprintf(stderr, "Failed to open %s port %d\n", ibd_ca,
+ ibd_ca_port);
+ exit(1);
+ }
+
+ smp_mkey_set(ibmad_port, ibd_mkey);
+
+ if (ibd_timeout) {
+ mad_rpc_set_timeout(ibmad_port, ibd_timeout);
+ config.timeout_ms = ibd_timeout;
+ }
+
+ config.flags = ibd_ibnetdisc_flags;
+ config.mkey = ibd_mkey;
+
+ node_name_map = open_node_name_map(node_name_map_file);
+
+ if (dr_path && load_cache_file) {
+ mad_rpc_close_port(ibmad_port);
+ fprintf(stderr, "Cannot specify cache and direct route path\n");
+ exit(1);
+ }
+
+ if (dr_path) {
+ /* only scan part of the fabric */
+ if ((resolved =
+ resolve_portid_str(ibd_ca, ibd_ca_port, &port_id, dr_path,
+ IB_DEST_DRPATH, NULL, ibmad_port)) < 0)
+ IBWARN("Failed to resolve %s; attempting full scan",
+ dr_path);
+ } else if (guid_str) {
+ if ((resolved =
+ resolve_portid_str(ibd_ca, ibd_ca_port, &port_id,
+ guid_str, IB_DEST_GUID, NULL,
+ ibmad_port)) < 0)
+ IBWARN("Failed to resolve %s; attempting full scan\n",
+ guid_str);
+ }
+
+ if (!smp_query_via(ni, &port_id, IB_ATTR_NODE_INFO, 0,
+ ibd_timeout, ibmad_port)){
+ mad_rpc_close_port(ibmad_port);
+ fprintf(stderr,
+ "Failed to get local Node Info\n");
+ exit(1);
+ }
+ mad_rpc_close_port(ibmad_port);
+
+ if (diff_cache_file &&
+ !(diff_fabric = ibnd_load_fabric(diff_cache_file, 0)))
+ IBEXIT("loading cached fabric for diff failed\n");
+
+ if (filterdownports_cache_file &&
+ !(filterdownports_fabric = ibnd_load_fabric(filterdownports_cache_file, 0)))
+ IBEXIT("loading cached fabric for filterdownports failed\n");
+
+ if (load_cache_file) {
+ if ((fabric = ibnd_load_fabric(load_cache_file, 0)) == NULL) {
+ fprintf(stderr, "loading cached fabric failed\n");
+ exit(1);
+ }
+ } else {
+ if (resolved >= 0) {
+ if (!config.max_hops)
+ config.max_hops = 1;
+ if (!(fabric =
+ ibnd_discover_fabric(ibd_ca, ibd_ca_port, &port_id, &config)))
+ IBWARN("Partial fabric scan failed;"
+ " attempting full scan\n");
+ }
+
+ if (!fabric &&
+ !(fabric = ibnd_discover_fabric(ibd_ca, ibd_ca_port, NULL, &config))) {
+ fprintf(stderr, "discover failed\n");
+ rc = 1;
+ goto close_port;
+ }
+ }
+
+ if (!all && guid_str) {
+ ibnd_port_t *p = ibnd_find_port_guid(fabric, guid);
+ if (p && (!only_flag || p->node->type == only_type)) {
+ ibnd_node_t *n = p->node;
+ if (diff_fabric)
+ diff_node(n, diff_fabric, fabric);
+ else
+ print_node(n, NULL);
+ }
+ else
+ fprintf(stderr, "Failed to find port: %s\n", guid_str);
+ } else if (!all && dr_path) {
+ ibnd_port_t *p = NULL;
+ mad_decode_field(ni, IB_NODE_PORT_GUID_F, &(guid));
+
+ p = ibnd_find_port_guid(fabric, guid);
+ if (p && (!only_flag || p->node->type == only_type)) {
+ ibnd_node_t *n = p->node;
+ if (diff_fabric)
+ diff_node(n, diff_fabric, fabric);
+ else
+ print_node(n, NULL);
+ }
+ else
+ fprintf(stderr, "Failed to find port: %s\n", dr_path);
+ } else {
+ if (diff_fabric)
+ diff_node(NULL, diff_fabric, fabric);
+ else {
+ if (only_flag)
+ ibnd_iter_nodes_type(fabric, print_node,
+ only_type, NULL);
+ else
+ ibnd_iter_nodes(fabric, print_node, NULL);
+ }
+ }
+
+ ibnd_destroy_fabric(fabric);
+ if (diff_fabric)
+ ibnd_destroy_fabric(diff_fabric);
+
+close_port:
+ close_node_name_map(node_name_map);
+ exit(rc);
+}
diff --git a/contrib/ofed/infiniband-diags/src/ibmirror.c b/contrib/ofed/infiniband-diags/src/ibmirror.c
new file mode 100644
index 0000000..3dec71c
--- /dev/null
+++ b/contrib/ofed/infiniband-diags/src/ibmirror.c
@@ -0,0 +1,538 @@
+/*
+ * Copyright (c) 2004-2009 Voltaire Inc. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+#if HAVE_CONFIG_H
+# include <config.h>
+#endif /* HAVE_CONFIG_H */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <getopt.h>
+#include <netinet/in.h>
+
+#include <infiniband/umad.h>
+#include <infiniband/mad.h>
+
+#include "ibdiag_common.h"
+
+#define IB_MLX_VENDOR_CLASS 10
+
+/* Vendor specific Attribute IDs */
+#define IB_MLX_IS3_GENERAL_INFO 0x17
+
+#define MAX_SWITCH_PORTS (36+1)
+static char mtx_ports[MAX_SWITCH_PORTS] = {0};
+static char mrx_ports[MAX_SWITCH_PORTS] = {0};
+static char str[4096];
+static uint8_t buf[256];
+
+#define ATTRID_PM_ROUTE 0xff30
+#define ATTRID_PM_FILTER 0xff31
+#define ATTRID_PM_PORTS 0xff32
+#define ATTRID_LOSSY_CFG 0xff80
+
+enum mirror_type {
+ MT_DISABLED = 0,
+ MT_MIRROR_NATIVE = 2,
+ MT_DROP = 5,
+ MT_MIRROR_ENCAP = 6,
+ MT_MIRROR_DROP = 7
+};
+
+enum mirror_port {
+ MP_DISABLED = 0,
+ MP_MIRROR_FILTER = 1,
+ MP_MIRROR_ALWAYS = 2,
+ MP_MIRROR_FILTER_NOT = 3,
+ MT_MIRROR_AS_RX = 1
+};
+
+#define PM_ENCAP_ETHERTYPE 0x1123
+
+struct ibmad_port *srcport;
+
+typedef struct {
+ uint16_t hw_revision;
+ uint16_t device_id;
+ uint8_t reserved[24];
+ uint32_t uptime;
+} is3_hw_info_t;
+
+typedef struct {
+ uint8_t resv1;
+ uint8_t major;
+ uint8_t minor;
+ uint8_t sub_minor;
+ uint32_t build_id;
+ uint8_t month;
+ uint8_t day;
+ uint16_t year;
+ uint16_t resv2;
+ uint16_t hour;
+ uint8_t psid[16];
+ uint32_t ini_file_version;
+} is3_fw_info_t;
+
+typedef struct {
+ uint8_t resv1;
+ uint8_t major;
+ uint8_t minor;
+ uint8_t sub_minor;
+ uint8_t resv2[28];
+} is3_sw_info_t;
+
+typedef struct {
+ uint8_t reserved[8];
+ is3_hw_info_t hw_info;
+ is3_fw_info_t fw_info;
+ is3_sw_info_t sw_info;
+} is3_general_info_t;
+
+typedef struct {
+ uint16_t ignore_buffer_mask;
+ uint16_t ignore_credit_mask;
+} lossy_config_t;
+
+static int mirror_query, mirror_dport, mirror_dlid, mirror_clear, mirror_sl, lossy_set;
+static int set_mtx, set_mrx, packet_size = 0xfff;
+
+static int parse_ports(char *ports_str, char *ports_array)
+{
+ int num, i;
+ char *str = strdup(ports_str);
+ char *token = strtok(str, ",");
+ for (i = 0; i < MAX_SWITCH_PORTS && token; i++) {
+ num = strtoul(token, NULL, 0);
+ if (num > 0 && num < MAX_SWITCH_PORTS)
+ ports_array[num] = 1;
+
+ token = strtok(NULL, ",");
+ }
+ free(str);
+ return 0;
+}
+
+void port_mirror_route(ib_portid_t * portid, int query, int clear)
+{
+ int mirror_type;
+
+ memset(&buf, 0, sizeof(buf));
+
+ if (clear) {
+ if (!smp_set_via(buf, portid, ATTRID_PM_ROUTE, 0, 0, srcport))
+ IBEXIT("Clear port mirror route set failed");
+ return;
+ }
+
+ if (query) {
+ if (!smp_query_via(buf, portid, ATTRID_PM_ROUTE, 0, 0, srcport))
+ IBEXIT("Read port mirror route get failed");
+ mad_decode_field(buf, IB_PMR_MT_F, &mirror_type);
+ if (mirror_type == MT_MIRROR_ENCAP && mirror_dlid == 0)
+ mad_decode_field(buf, IB_PMR_LRH_DLID_F, &mirror_dlid);
+ if (mirror_type == MT_MIRROR_NATIVE && mirror_dport == 0)
+ mad_decode_field(buf, IB_PMR_NM_PORT_F, &mirror_dport);
+ goto Exit;
+ }
+
+ /* Port Mirror Route */
+ mad_set_field(buf, 0, IB_PMR_ENCAP_RAW_ETH_TYPE_F, PM_ENCAP_ETHERTYPE);
+
+ if (mirror_dlid == 0) {
+ /* Can not truncate mirrored packets in local mode */
+ mad_set_field(buf, 0, IB_PMR_MAX_MIRROR_LEN_F, 0xfff);
+ mad_set_field(buf, 0, IB_PMR_MT_F, MT_MIRROR_NATIVE);
+ mad_set_field(buf, 0, IB_PMR_NM_PORT_F, mirror_dport);
+ }
+ else { /* remote mirror */
+ /* convert size to dwords */
+ packet_size = packet_size / 4 + 1;
+ mad_set_field(buf, 0, IB_PMR_MAX_MIRROR_LEN_F, packet_size);
+ mad_set_field(buf, 0, IB_PMR_MT_F, MT_MIRROR_ENCAP);
+ mad_set_field(buf, 0, IB_PMR_LRH_SL_F, mirror_sl);
+ mad_set_field(buf, 0, IB_PMR_LRH_DLID_F, mirror_dlid);
+ mad_set_field(buf, 0, IB_PMR_LRH_SLID_F, portid->lid);
+ }
+
+ if (!smp_set_via(buf, portid, ATTRID_PM_ROUTE, 0, 0, srcport))
+ IBEXIT("port mirror route set failed");
+
+Exit:
+ mad_dump_portmirror_route(str, sizeof str, buf, sizeof buf);
+ printf("Port Mirror Route\n%s", str);
+}
+
+void port_mirror_ports(ib_portid_t * portid, int query, int clear)
+{
+ int p, rqf, tqf, rqv, tqv;
+
+ memset(&buf, 0, sizeof(buf));
+
+ if (clear) {
+ if (!smp_set_via(buf, portid, ATTRID_PM_PORTS, 0, 0, srcport))
+ IBEXIT("Clear port mirror ports set failed");
+ return;
+ }
+
+ if (query) {
+ if (!smp_query_via(buf, portid, ATTRID_PM_PORTS, 0, 0, srcport))
+ IBEXIT("Read port mirror ports get failed");
+ goto Exit;
+ }
+
+ /* Port Mirror Ports */
+ rqf = IB_PMP_RQ_1_F;
+ tqf = IB_PMP_TQ_1_F;
+
+ for (p = 1; p < MAX_SWITCH_PORTS; p++) {
+ rqv = mrx_ports[p] ? MP_MIRROR_ALWAYS : MP_DISABLED;
+ tqv = mtx_ports[p] ? MP_MIRROR_ALWAYS : MT_MIRROR_AS_RX;
+ mad_set_field(buf, 0, rqf, rqv);
+ mad_set_field(buf, 0, tqf, tqv);
+ rqf += 2;
+ tqf += 2;
+ }
+
+ if (!smp_set_via(buf, portid, ATTRID_PM_PORTS, 0, 0, srcport))
+ IBEXIT("port mirror ports set failed");
+
+Exit:
+ mad_dump_portmirror_ports(str, sizeof str, buf, sizeof buf);
+ printf("Port Mirror Ports\n%s", str);
+}
+
+int get_out_port(ib_portid_t* portid)
+{
+ int block;
+ int offset;
+
+ if (mirror_dlid) {
+ block = mirror_dlid / IB_SMP_DATA_SIZE;
+ offset = mirror_dlid - block * IB_SMP_DATA_SIZE;
+ /* get out port from lft */
+ if (!smp_query_via(buf, portid, IB_ATTR_LINEARFORWTBL, block, 0, srcport))
+ IBEXIT("linear forwarding table get failed");
+ block = mirror_dlid / IB_SMP_DATA_SIZE;
+ offset = mirror_dlid - block * IB_SMP_DATA_SIZE;
+ return buf[offset];
+ }
+ else
+ return mirror_dport;
+}
+
+int get_peer(ib_portid_t* portid, int outport, int* peerlid, int* peerport)
+{
+ ib_portid_t selfportid = { 0 };
+ ib_portid_t peerportid = { 0 };
+ int selfport = 0;
+
+ /* set peerportid for peer port */
+ memcpy(&peerportid, portid, sizeof(peerportid));
+ peerportid.drpath.cnt = 1;
+ peerportid.drpath.p[1] = outport;
+ if (ib_resolve_self_via(&selfportid, &selfport, 0, srcport) < 0)
+ IBEXIT("failed to resolve self portid");
+ peerportid.drpath.drslid = (uint16_t) selfportid.lid;
+ peerportid.drpath.drdlid = 0xffff;
+ if (!smp_query_via(buf, &peerportid, IB_ATTR_PORT_INFO, 0, 0, srcport))
+ IBEXIT("get peer portinfo failed - unable to configure lossy\n");
+
+ mad_decode_field(buf, IB_PORT_LID_F, peerlid);
+ mad_decode_field(buf, IB_PORT_LOCAL_PORT_F, peerport);
+
+ return 0;
+}
+
+int get_mirror_vl(ib_portid_t* portid, int outport)
+{
+ ib_slvl_table_t * p_slvl_tbl;
+ int portnum;
+ int vl;
+
+ /* hack; assume all sl2vl mappings are the same for any in port and outport */
+ portnum = (1 << 8) | outport;
+
+ /* get sl2vl mapping */
+ if (!smp_query_via(buf, portid, IB_ATTR_SLVL_TABLE, portnum, 0, srcport))
+ IBEXIT("slvl query failed");
+
+ p_slvl_tbl = (ib_slvl_table_t *) buf;
+ vl = ib_slvl_table_get(p_slvl_tbl, mirror_sl);
+ printf("mirror_sl %d, mirror_vl %d\n", mirror_sl, vl);
+ return vl;
+}
+
+int lossy_config(ib_portid_t* portid, int query, int clear)
+{
+ int outport;
+ int peerport;
+ int attr_mod;
+ uint8_t mirror_vl;
+ ib_portid_t peerportid = { 0 };
+ ib_portid_t * p_portid;
+ lossy_config_t local_lossy_cfg;
+ lossy_config_t peer_lossy_cfg;
+ lossy_config_t lossy_cfg;
+
+ outport = get_out_port(portid);
+ if (outport == 0)
+ IBEXIT("get_out_port failed, mirror_dlid and mirror_dport are 0");
+
+ get_peer(portid, outport, &peerportid.lid, &peerport);
+
+ printf("local lid %d / port %d\n", portid->lid, outport);
+ printf("peer lid %d / port %d\n", peerportid.lid, peerport);
+
+ mirror_vl = get_mirror_vl(portid, outport);
+
+ /* read local lossy configuration */
+ if (!smp_query_via(buf, portid, ATTRID_LOSSY_CFG, outport, 0, srcport))
+ IBEXIT("get lossy config from lid %d port %d failed - not supported\n",
+ portid->lid, outport);
+ memcpy(&local_lossy_cfg, buf, sizeof(local_lossy_cfg));
+
+ /* read peer lossy configuration */
+ if (!smp_query_via(buf, &peerportid, ATTRID_LOSSY_CFG, peerport, 0, srcport))
+ IBEXIT("get lossy config from lid %d port %d failed - not supported\n",
+ peerportid.lid, peerport);
+ memcpy(&peer_lossy_cfg, buf, sizeof(peer_lossy_cfg));
+
+ if (query) {
+ printf("local port lid %d port %d ignore_buffer 0x%04x, ignore_credit 0x%04x\n",
+ portid->lid, outport,
+ ntohs(local_lossy_cfg.ignore_buffer_mask), ntohs(local_lossy_cfg.ignore_credit_mask));
+ printf("peer port lid %d port %d ignore_buffer 0x%04x, ignore_credit 0x%04x\n",
+ peerportid.lid, peerport,
+ ntohs(peer_lossy_cfg.ignore_buffer_mask), ntohs(peer_lossy_cfg.ignore_credit_mask));
+ return 0;
+ }
+
+ /* VLs 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 */
+ /* ignore Buf Overrun ignore Credits */
+ /* when mirror activated set ignore buffer overrun on peer port */
+ /* when mirror is de-activated clear ignore credits on local port */
+ memset(&buf, 0, sizeof(buf));
+ if (clear) {
+ p_portid = portid;
+ attr_mod = outport;
+ } else {
+ /* set buffer overrun on peer port */
+ p_portid = &peerportid;
+ attr_mod = peerport;
+ lossy_cfg.ignore_buffer_mask = htons(1<<mirror_vl);
+ lossy_cfg.ignore_credit_mask = 0;
+ memcpy(&buf, &lossy_cfg, sizeof(lossy_cfg));
+ }
+ if (!smp_set_via(buf, p_portid, ATTRID_LOSSY_CFG, attr_mod, 0, srcport))
+ IBEXIT("%s lossy config on lid %d failed\n", clear?"clear":"set", p_portid->lid);
+
+ /* when mirror activated set ignore credit on local port */
+ /* when mirror de-activated clear buffer overrun on peer */
+ memset(&buf, 0, sizeof(buf));
+ if (clear) {
+ p_portid = &peerportid;
+ attr_mod = peerport;
+ } else {
+ /* set ignore credit on local port */
+ p_portid = portid;
+ attr_mod = outport;
+ lossy_cfg.ignore_credit_mask = htons(1<<mirror_vl);
+ lossy_cfg.ignore_buffer_mask = 0;
+ memcpy(&buf, &lossy_cfg, sizeof(lossy_cfg));
+ }
+ if (!smp_set_via(buf, p_portid, ATTRID_LOSSY_CFG, attr_mod, 0, srcport))
+ IBEXIT("%s lossy config on lid %d failed\n", clear?"clear":"set", p_portid->lid);
+
+ return 0;
+}
+
+int mirror_config(ib_portid_t* portid, int query, int clear)
+{
+ port_mirror_route(portid, query, clear);
+ /* port_mirror_filter(portid, query, clear); */
+ port_mirror_ports(portid, query, clear);
+
+ return 0;
+}
+
+static int process_opt(void *context, int ch, char *optarg)
+{
+ switch (ch) {
+ case 'p':
+ mirror_dport = strtoul(optarg, NULL, 0);
+ break;
+ case 'S':
+ packet_size = strtoul(optarg, NULL, 0);
+ break;
+ case 'l':
+ mirror_sl = strtoul(optarg, NULL, 0);
+ break;
+ case 'L':
+ mirror_dlid = strtoul(optarg, NULL, 0);
+ break;
+ case 'R':
+ set_mrx = 1;
+ if (-1 == parse_ports(optarg, mrx_ports))
+ return -1;
+ break;
+ case 'T':
+ set_mtx = 1;
+ if (-1 == parse_ports(optarg, mtx_ports))
+ return -1;
+ break;
+ case 'D':
+ mirror_clear = 1;
+ break;
+ case 'Q':
+ mirror_query = 1;
+ break;
+ case 'y':
+ lossy_set = 1;
+ break;
+ default:
+ return -1;
+ }
+ return 0;
+}
+
+int main(int argc, char **argv)
+{
+ int mgmt_classes[4] = { IB_SMI_CLASS, IB_SMI_DIRECT_CLASS, IB_SA_CLASS,
+ IB_MLX_VENDOR_CLASS
+ };
+ ib_portid_t portid = { 0 };
+ int port = 0;
+ ib_vendor_call_t call;
+ is3_general_info_t *gi;
+ uint32_t fw_ver;
+ char op_str[32];
+
+ const struct ibdiag_opt opts[] = {
+ {"dport", 'p', 1, "<port>", "set mirror destination port"},
+ {"dlid", 'L', 1, "<dlid>", "set mirror destination LID"},
+ {"sl", 'l', 1, "<sl>", "set mirror SL"},
+ {"size", 'S', 1, "<size>", "set packet size"},
+ {"rxports", 'R', 1, NULL, "mirror receive port list"},
+ {"txports", 'T', 1, NULL, "mirror transmit port list"},
+ {"clear", 'D', 0, NULL, "clear ports mirroring"},
+ {"query", 'Q', 0, NULL, "read mirror configuration"},
+ {"lossy", 'y', 0, NULL, "set lossy configuration on out port"},
+ {0}
+ };
+
+ char usage_args[] = "<lid>";
+ const char *usage_examples[] = {
+ "-R 1,2,3 -T 2,5 -l1 -L25 -S100 <lid>\t# configure mirror ports",
+ "-D <lid> \t# clear mirror configuration",
+ "-Q <lid>\t# read mirror configuration",
+ NULL
+ };
+
+ ibdiag_process_opts(argc, argv, NULL, "GDLs", opts, process_opt,
+ usage_args, usage_examples);
+
+ argc -= optind;
+ argv += optind;
+
+ if (argc == 0)
+ ibdiag_show_usage();
+
+ srcport = mad_rpc_open_port(ibd_ca, ibd_ca_port, mgmt_classes, 4);
+ if (!srcport)
+ IBEXIT("Failed to open '%s' port '%d'", ibd_ca, ibd_ca_port);
+
+ if (argc) {
+ if (ib_resolve_portid_str_via(&portid, argv[0], ibd_dest_type,
+ ibd_sm_id, srcport) < 0)
+ IBEXIT("can't resolve destination port %s", argv[0]);
+ }
+
+
+ memset(&buf, 0, sizeof(buf));
+ memset(&call, 0, sizeof(call));
+ call.mgmt_class = IB_MLX_VENDOR_CLASS;
+ call.method = IB_MAD_METHOD_GET;
+ call.timeout = ibd_timeout;
+ call.attrid = IB_MLX_IS3_GENERAL_INFO;
+ if (!ib_vendor_call_via(&buf, &portid, &call, srcport))
+ IBEXIT("failed to read vendor info");
+ gi = (is3_general_info_t *) & buf;
+ if (ntohs(gi->hw_info.device_id) != 0x1b3)
+ IBEXIT("device id 0x%x does not support mirroring", ntohs(gi->hw_info.device_id));
+
+ fw_ver = gi->fw_info.major * 100000 + gi->fw_info.minor * 1000 + gi->fw_info.sub_minor;
+ printf("FW version %08d\n", fw_ver);
+ if (lossy_set && fw_ver < 704000)
+ IBEXIT("FW version %d.%d.%d does not support lossy config",
+ gi->fw_info.major, gi->fw_info.minor, gi->fw_info.sub_minor);
+
+ if (ibdebug) {
+ printf( "switch_lid = %d\n"
+ "mirror_clear = %d\n"
+ "mirror_dlid = %d\n"
+ "mirror_sl = %d\n"
+ "mirror_port = %d\n",
+ portid.lid, mirror_clear, mirror_dlid,
+ mirror_sl, mirror_dport);
+
+ for (port = 1; port < MAX_SWITCH_PORTS; port++) {
+ if (mtx_ports[port])
+ printf("TX: %d\n",port);
+ else if(mrx_ports[port])
+ printf("RX: %d\n",port);
+ }
+ }
+
+ if (mirror_clear)
+ strcpy(op_str, "Clear");
+ else if (mirror_query)
+ strcpy(op_str, "Read");
+ else if (!mirror_dport && !mirror_dlid)
+ IBEXIT("Mirror remote LID and local port are zero");
+ else if (!set_mtx && !set_mrx)
+ IBEXIT("Mirror Rx and Tx ports not selected");
+ else
+ strcpy(op_str, "Set");
+
+ printf("\n%s Mirror Configuration\n", op_str);
+ mirror_config(&portid, mirror_query, mirror_clear);
+
+ if (lossy_set) {
+ printf("%s Lossy Configuration\n", op_str);
+ lossy_config(&portid, mirror_query, mirror_clear);
+ }
+
+ mad_rpc_close_port(srcport);
+ exit(0);
+}
diff --git a/contrib/ofed/infiniband-diags/src/ibnetdiscover.c b/contrib/ofed/infiniband-diags/src/ibnetdiscover.c
new file mode 100644
index 0000000..f81d03b
--- /dev/null
+++ b/contrib/ofed/infiniband-diags/src/ibnetdiscover.c
@@ -0,0 +1,1157 @@
+/*
+ * Copyright (c) 2004-2009 Voltaire Inc. All rights reserved.
+ * Copyright (c) 2007 Xsigo Systems Inc. All rights reserved.
+ * Copyright (c) 2008 Lawrence Livermore National Lab. All rights reserved.
+ * Copyright (c) 2010,2011 Mellanox Technologies LTD. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+#if HAVE_CONFIG_H
+#include <config.h>
+#endif /* HAVE_CONFIG_H */
+
+#define _GNU_SOURCE
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <time.h>
+#include <string.h>
+#include <getopt.h>
+#include <inttypes.h>
+
+#include <infiniband/umad.h>
+#include <infiniband/mad.h>
+#include <complib/cl_nodenamemap.h>
+#include <infiniband/ibnetdisc.h>
+
+#include "ibdiag_common.h"
+
+#define LIST_CA_NODE (1 << IB_NODE_CA)
+#define LIST_SWITCH_NODE (1 << IB_NODE_SWITCH)
+#define LIST_ROUTER_NODE (1 << IB_NODE_ROUTER)
+
+#define DIFF_FLAG_SWITCH 0x01
+#define DIFF_FLAG_CA 0x02
+#define DIFF_FLAG_ROUTER 0x04
+#define DIFF_FLAG_PORT_CONNECTION 0x08
+#define DIFF_FLAG_LID 0x10
+#define DIFF_FLAG_NODE_DESCRIPTION 0x20
+
+#define DIFF_FLAG_DEFAULT (DIFF_FLAG_SWITCH | DIFF_FLAG_CA | DIFF_FLAG_ROUTER \
+ | DIFF_FLAG_PORT_CONNECTION)
+
+static FILE *f;
+
+static char *node_name_map_file = NULL;
+static nn_map_t *node_name_map = NULL;
+static char *cache_file = NULL;
+static char *load_cache_file = NULL;
+static char *diff_cache_file = NULL;
+static unsigned diffcheck_flags = DIFF_FLAG_DEFAULT;
+
+static int report_max_hops = 0;
+static int full_info;
+
+/**
+ * Define our own conversion functions to maintain compatibility with the old
+ * ibnetdiscover which did not use the ibmad conversion functions.
+ */
+char *dump_linkspeed_compat(uint32_t speed)
+{
+ switch (speed) {
+ case 1:
+ return ("SDR");
+ break;
+ case 2:
+ return ("DDR");
+ break;
+ case 4:
+ return ("QDR");
+ break;
+ }
+ return ("???");
+}
+
+char *dump_linkspeedext_compat(uint32_t espeed, uint32_t speed, uint32_t fdr10)
+{
+ switch (espeed) {
+ case 0:
+ if (fdr10 & FDR10)
+ return ("FDR10");
+ else
+ return dump_linkspeed_compat(speed);
+ break;
+ case 1:
+ return ("FDR");
+ break;
+ case 2:
+ return ("EDR");
+ break;
+ }
+ return ("???");
+}
+
+char *dump_linkwidth_compat(uint32_t width)
+{
+ switch (width) {
+ case 1:
+ return ("1x");
+ break;
+ case 2:
+ return ("4x");
+ break;
+ case 4:
+ return ("8x");
+ break;
+ case 8:
+ return ("12x");
+ break;
+ case 16:
+ return ("2x");
+ break;
+ }
+ return ("??");
+}
+
+static inline const char *ports_nt_str_compat(ibnd_node_t * node)
+{
+ switch (node->type) {
+ case IB_NODE_SWITCH:
+ return "SW";
+ case IB_NODE_CA:
+ return "CA";
+ case IB_NODE_ROUTER:
+ return "RT";
+ }
+ return "??";
+}
+
+char *node_name(ibnd_node_t * node)
+{
+ static char buf[256];
+
+ switch (node->type) {
+ case IB_NODE_SWITCH:
+ sprintf(buf, "\"%s", "S");
+ break;
+ case IB_NODE_CA:
+ sprintf(buf, "\"%s", "H");
+ break;
+ case IB_NODE_ROUTER:
+ sprintf(buf, "\"%s", "R");
+ break;
+ default:
+ sprintf(buf, "\"%s", "?");
+ break;
+ }
+ sprintf(buf + 2, "-%016" PRIx64 "\"", node->guid);
+
+ return buf;
+}
+
+void list_node(ibnd_node_t * node, void *user_data)
+{
+ char *node_type;
+ char *nodename = remap_node_name(node_name_map, node->guid,
+ node->nodedesc);
+
+ switch (node->type) {
+ case IB_NODE_SWITCH:
+ node_type = "Switch";
+ break;
+ case IB_NODE_CA:
+ node_type = "Ca";
+ break;
+ case IB_NODE_ROUTER:
+ node_type = "Router";
+ break;
+ default:
+ node_type = "???";
+ break;
+ }
+ fprintf(f,
+ "%s\t : 0x%016" PRIx64
+ " ports %d devid 0x%x vendid 0x%x \"%s\"\n", node_type,
+ node->guid, node->numports, mad_get_field(node->info, 0,
+ IB_NODE_DEVID_F),
+ mad_get_field(node->info, 0, IB_NODE_VENDORID_F), nodename);
+
+ free(nodename);
+}
+
+void list_nodes(ibnd_fabric_t * fabric, int list)
+{
+ if (list & LIST_CA_NODE)
+ ibnd_iter_nodes_type(fabric, list_node, IB_NODE_CA, NULL);
+ if (list & LIST_SWITCH_NODE)
+ ibnd_iter_nodes_type(fabric, list_node, IB_NODE_SWITCH, NULL);
+ if (list & LIST_ROUTER_NODE)
+ ibnd_iter_nodes_type(fabric, list_node, IB_NODE_ROUTER, NULL);
+}
+
+void out_ids(ibnd_node_t * node, int group, char *chname, char *out_prefix)
+{
+ uint64_t sysimgguid =
+ mad_get_field64(node->info, 0, IB_NODE_SYSTEM_GUID_F);
+
+ fprintf(f, "\n%svendid=0x%x\n", out_prefix ? out_prefix : "",
+ mad_get_field(node->info, 0, IB_NODE_VENDORID_F));
+ fprintf(f, "%sdevid=0x%x\n", out_prefix ? out_prefix : "",
+ mad_get_field(node->info, 0, IB_NODE_DEVID_F));
+ if (sysimgguid)
+ fprintf(f, "%ssysimgguid=0x%" PRIx64,
+ out_prefix ? out_prefix : "", sysimgguid);
+ if (group && node->chassis && node->chassis->chassisnum) {
+ fprintf(f, "\t\t# Chassis %d", node->chassis->chassisnum);
+ if (chname)
+ fprintf(f, " (%s)", clean_nodedesc(chname));
+ if (ibnd_is_xsigo_tca(node->guid) && node->ports[1] &&
+ node->ports[1]->remoteport)
+ fprintf(f, " slot %d",
+ node->ports[1]->remoteport->portnum);
+ }
+ if (sysimgguid ||
+ (group && node->chassis && node->chassis->chassisnum))
+ fprintf(f, "\n");
+}
+
+uint64_t out_chassis(ibnd_fabric_t * fabric, unsigned char chassisnum)
+{
+ uint64_t guid;
+
+ fprintf(f, "\nChassis %u", chassisnum);
+ guid = ibnd_get_chassis_guid(fabric, chassisnum);
+ if (guid)
+ fprintf(f, " (guid 0x%" PRIx64 ")", guid);
+ fprintf(f, "\n");
+ return guid;
+}
+
+void out_switch_detail(ibnd_node_t * node, char *sw_prefix)
+{
+ char *nodename = NULL;
+
+ nodename = remap_node_name(node_name_map, node->guid, node->nodedesc);
+
+ fprintf(f, "%sSwitch\t%d %s\t\t# \"%s\" %s port 0 lid %d lmc %d",
+ sw_prefix ? sw_prefix : "", node->numports, node_name(node),
+ nodename, node->smaenhsp0 ? "enhanced" : "base",
+ node->smalid, node->smalmc);
+
+ free(nodename);
+}
+
+void out_switch(ibnd_node_t * node, int group, char *chname, char *id_prefix,
+ char *sw_prefix)
+{
+ char *str;
+ char str2[256];
+
+ out_ids(node, group, chname, id_prefix);
+ fprintf(f, "%sswitchguid=0x%" PRIx64,
+ id_prefix ? id_prefix : "", node->guid);
+ fprintf(f, "(%" PRIx64 ")",
+ mad_get_field64(node->info, 0, IB_NODE_PORT_GUID_F));
+ if (group) {
+ fprintf(f, "\t# ");
+ str = ibnd_get_chassis_type(node);
+ if (str)
+ fprintf(f, "%s ", str);
+ str = ibnd_get_chassis_slot_str(node, str2, 256);
+ if (str)
+ fprintf(f, "%s", str);
+ }
+ fprintf(f, "\n");
+
+ out_switch_detail(node, sw_prefix);
+ fprintf(f, "\n");
+}
+
+void out_ca_detail(ibnd_node_t * node, char *ca_prefix)
+{
+ char *node_type;
+
+ switch (node->type) {
+ case IB_NODE_CA:
+ node_type = "Ca";
+ break;
+ case IB_NODE_ROUTER:
+ node_type = "Rt";
+ break;
+ default:
+ node_type = "???";
+ break;
+ }
+
+ fprintf(f, "%s%s\t%d %s\t\t# \"%s\"", ca_prefix ? ca_prefix : "",
+ node_type, node->numports, node_name(node),
+ clean_nodedesc(node->nodedesc));
+}
+
+void out_ca(ibnd_node_t * node, int group, char *chname, char *id_prefix,
+ char *ca_prefix)
+{
+ char *node_type;
+
+ out_ids(node, group, chname, id_prefix);
+ switch (node->type) {
+ case IB_NODE_CA:
+ node_type = "ca";
+ break;
+ case IB_NODE_ROUTER:
+ node_type = "rt";
+ break;
+ default:
+ node_type = "???";
+ break;
+ }
+
+ fprintf(f, "%s%sguid=0x%" PRIx64 "\n",
+ id_prefix ? id_prefix : "", node_type, node->guid);
+ out_ca_detail(node, ca_prefix);
+ if (group && ibnd_is_xsigo_hca(node->guid))
+ fprintf(f, " (scp)");
+ fprintf(f, "\n");
+}
+
+#define OUT_BUFFER_SIZE 16
+static char *out_ext_port(ibnd_port_t * port, int group)
+{
+ static char mapping[OUT_BUFFER_SIZE];
+
+ if (group && port->ext_portnum != 0) {
+ snprintf(mapping, OUT_BUFFER_SIZE,
+ "[ext %d]", port->ext_portnum);
+ return (mapping);
+ }
+
+ return (NULL);
+}
+
+void out_switch_port(ibnd_port_t * port, int group, char *out_prefix)
+{
+ char *ext_port_str = NULL;
+ char *rem_nodename = NULL;
+ uint32_t iwidth = mad_get_field(port->info, 0,
+ IB_PORT_LINK_WIDTH_ACTIVE_F);
+ uint32_t ispeed = mad_get_field(port->info, 0,
+ IB_PORT_LINK_SPEED_ACTIVE_F);
+ uint32_t vlcap = mad_get_field(port->info, 0,
+ IB_PORT_VL_CAP_F);
+ uint32_t fdr10 = mad_get_field(port->ext_info, 0,
+ IB_MLNX_EXT_PORT_LINK_SPEED_ACTIVE_F);
+ uint32_t cap_mask, espeed;
+
+ DEBUG("port %p:%d remoteport %p\n", port, port->portnum,
+ port->remoteport);
+ fprintf(f, "%s[%d]", out_prefix ? out_prefix : "", port->portnum);
+
+ ext_port_str = out_ext_port(port, group);
+ if (ext_port_str)
+ fprintf(f, "%s", ext_port_str);
+
+ rem_nodename = remap_node_name(node_name_map,
+ port->remoteport->node->guid,
+ port->remoteport->node->nodedesc);
+
+ ext_port_str = out_ext_port(port->remoteport, group);
+
+ if (!port->node->ports[0]) {
+ cap_mask = 0;
+ ispeed = 0;
+ espeed = 0;
+ } else {
+ cap_mask = mad_get_field(port->node->ports[0]->info, 0,
+ IB_PORT_CAPMASK_F);
+ if (cap_mask & CL_NTOH32(IB_PORT_CAP_HAS_EXT_SPEEDS))
+ espeed = mad_get_field(port->info, 0,
+ IB_PORT_LINK_SPEED_EXT_ACTIVE_F);
+ else
+ espeed = 0;
+ }
+ fprintf(f, "\t%s[%d]%s",
+ node_name(port->remoteport->node), port->remoteport->portnum,
+ ext_port_str ? ext_port_str : "");
+ if (port->remoteport->node->type != IB_NODE_SWITCH)
+ fprintf(f, "(%" PRIx64 ") ", port->remoteport->guid);
+ fprintf(f, "\t\t# \"%s\" lid %d %s%s",
+ rem_nodename,
+ port->remoteport->node->type == IB_NODE_SWITCH ?
+ port->remoteport->node->smalid :
+ port->remoteport->base_lid,
+ dump_linkwidth_compat(iwidth),
+ (ispeed != 4 && !espeed) ?
+ dump_linkspeed_compat(ispeed) :
+ dump_linkspeedext_compat(espeed, ispeed, fdr10));
+
+ if (full_info) {
+ fprintf(f, " s=%d w=%d v=%d", ispeed, iwidth, vlcap);
+ if (espeed)
+ fprintf(f, " e=%d", espeed);
+ }
+
+ if (ibnd_is_xsigo_tca(port->remoteport->guid))
+ fprintf(f, " slot %d", port->portnum);
+ else if (ibnd_is_xsigo_hca(port->remoteport->guid))
+ fprintf(f, " (scp)");
+ fprintf(f, "\n");
+
+ free(rem_nodename);
+}
+
+void out_ca_port(ibnd_port_t * port, int group, char *out_prefix)
+{
+ char *str = NULL;
+ char *rem_nodename = NULL;
+ uint32_t iwidth = mad_get_field(port->info, 0,
+ IB_PORT_LINK_WIDTH_ACTIVE_F);
+ uint32_t ispeed = mad_get_field(port->info, 0,
+ IB_PORT_LINK_SPEED_ACTIVE_F);
+ uint32_t vlcap = mad_get_field(port->info, 0,
+ IB_PORT_VL_CAP_F);
+ uint32_t fdr10 = mad_get_field(port->ext_info, 0,
+ IB_MLNX_EXT_PORT_LINK_SPEED_ACTIVE_F);
+ uint32_t cap_mask, espeed;
+
+ fprintf(f, "%s[%d]", out_prefix ? out_prefix : "", port->portnum);
+ if (port->node->type != IB_NODE_SWITCH)
+ fprintf(f, "(%" PRIx64 ") ", port->guid);
+ fprintf(f, "\t%s[%d]",
+ node_name(port->remoteport->node), port->remoteport->portnum);
+ str = out_ext_port(port->remoteport, group);
+ if (str)
+ fprintf(f, "%s", str);
+ if (port->remoteport->node->type != IB_NODE_SWITCH)
+ fprintf(f, " (%" PRIx64 ") ", port->remoteport->guid);
+
+ rem_nodename = remap_node_name(node_name_map,
+ port->remoteport->node->guid,
+ port->remoteport->node->nodedesc);
+
+ cap_mask = mad_get_field(port->info, 0, IB_PORT_CAPMASK_F);
+ if (cap_mask & CL_NTOH32(IB_PORT_CAP_HAS_EXT_SPEEDS))
+ espeed = mad_get_field(port->info, 0,
+ IB_PORT_LINK_SPEED_EXT_ACTIVE_F);
+ else
+ espeed = 0;
+
+ fprintf(f, "\t\t# lid %d lmc %d \"%s\" lid %d %s%s",
+ port->base_lid, port->lmc, rem_nodename,
+ port->remoteport->node->type == IB_NODE_SWITCH ?
+ port->remoteport->node->smalid :
+ port->remoteport->base_lid,
+ dump_linkwidth_compat(iwidth),
+ (ispeed != 4 && !espeed) ?
+ dump_linkspeed_compat(ispeed) :
+ dump_linkspeedext_compat(espeed, ispeed, fdr10));
+
+ if (full_info) {
+ fprintf(f, " s=%d w=%d v=%d", ispeed, iwidth, vlcap);
+ if (espeed)
+ fprintf(f, " e=%d", espeed);
+ }
+
+ fprintf(f, "\n");
+
+ free(rem_nodename);
+}
+
+struct iter_user_data {
+ int group;
+ int skip_chassis_nodes;
+};
+
+static void switch_iter_func(ibnd_node_t * node, void *iter_user_data)
+{
+ ibnd_port_t *port;
+ int p = 0;
+ struct iter_user_data *data = (struct iter_user_data *)iter_user_data;
+
+ DEBUG("SWITCH: node %p\n", node);
+
+ /* skip chassis based switches if flagged */
+ if (data->skip_chassis_nodes && node->chassis
+ && node->chassis->chassisnum)
+ return;
+
+ out_switch(node, data->group, NULL, NULL, NULL);
+ for (p = 1; p <= node->numports; p++) {
+ port = node->ports[p];
+ if (port && port->remoteport)
+ out_switch_port(port, data->group, NULL);
+ }
+}
+
+static void ca_iter_func(ibnd_node_t * node, void *iter_user_data)
+{
+ ibnd_port_t *port;
+ int p = 0;
+ struct iter_user_data *data = (struct iter_user_data *)iter_user_data;
+
+ DEBUG("CA: node %p\n", node);
+ /* Now, skip chassis based CAs */
+ if (data->group && node->chassis && node->chassis->chassisnum)
+ return;
+ out_ca(node, data->group, NULL, NULL, NULL);
+
+ for (p = 1; p <= node->numports; p++) {
+ port = node->ports[p];
+ if (port && port->remoteport)
+ out_ca_port(port, data->group, NULL);
+ }
+}
+
+static void router_iter_func(ibnd_node_t * node, void *iter_user_data)
+{
+ ibnd_port_t *port;
+ int p = 0;
+ struct iter_user_data *data = (struct iter_user_data *)iter_user_data;
+
+ DEBUG("RT: node %p\n", node);
+ /* Now, skip chassis based RTs */
+ if (data->group && node->chassis && node->chassis->chassisnum)
+ return;
+ out_ca(node, data->group, NULL, NULL, NULL);
+ for (p = 1; p <= node->numports; p++) {
+ port = node->ports[p];
+ if (port && port->remoteport)
+ out_ca_port(port, data->group, NULL);
+ }
+}
+
+int dump_topology(int group, ibnd_fabric_t * fabric)
+{
+ ibnd_node_t *node;
+ ibnd_port_t *port;
+ int i = 0, p = 0;
+ time_t t = time(0);
+ uint64_t chguid;
+ char *chname = NULL;
+ struct iter_user_data iter_user_data;
+
+ fprintf(f, "#\n# Topology file: generated on %s#\n", ctime(&t));
+ if (report_max_hops)
+ fprintf(f, "# Reported max hops discovered: %u\n"
+ "# Total MADs used: %u\n",
+ fabric->maxhops_discovered, fabric->total_mads_used);
+ fprintf(f, "# Initiated from node %016" PRIx64 " port %016" PRIx64 "\n",
+ fabric->from_node->guid,
+ mad_get_field64(fabric->from_node->info, 0,
+ IB_NODE_PORT_GUID_F));
+
+ /* Make pass on switches */
+ if (group) {
+ ibnd_chassis_t *ch = NULL;
+
+ /* Chassis based switches first */
+ for (ch = fabric->chassis; ch; ch = ch->next) {
+ int n = 0;
+
+ if (!ch->chassisnum)
+ continue;
+ chguid = out_chassis(fabric, ch->chassisnum);
+ chname = NULL;
+ if (ibnd_is_xsigo_guid(chguid)) {
+ for (node = ch->nodes; node;
+ node = node->next_chassis_node) {
+ if (ibnd_is_xsigo_hca(node->guid)) {
+ chname = node->nodedesc;
+ fprintf(f, "Hostname: %s\n",
+ clean_nodedesc
+ (node->nodedesc));
+ }
+ }
+ }
+
+ fprintf(f, "\n# Spine Nodes");
+ for (n = 1; n <= SPINES_MAX_NUM; n++) {
+ if (ch->spinenode[n]) {
+ out_switch(ch->spinenode[n], group,
+ chname, NULL, NULL);
+ for (p = 1;
+ p <= ch->spinenode[n]->numports;
+ p++) {
+ port =
+ ch->spinenode[n]->ports[p];
+ if (port && port->remoteport)
+ out_switch_port(port,
+ group,
+ NULL);
+ }
+ }
+ }
+ fprintf(f, "\n# Line Nodes");
+ for (n = 1; n <= LINES_MAX_NUM; n++) {
+ if (ch->linenode[n]) {
+ out_switch(ch->linenode[n], group,
+ chname, NULL, NULL);
+ for (p = 1;
+ p <= ch->linenode[n]->numports;
+ p++) {
+ port =
+ ch->linenode[n]->ports[p];
+ if (port && port->remoteport)
+ out_switch_port(port,
+ group,
+ NULL);
+ }
+ }
+ }
+
+ fprintf(f, "\n# Chassis Switches");
+ for (node = ch->nodes; node;
+ node = node->next_chassis_node) {
+ if (node->type == IB_NODE_SWITCH) {
+ out_switch(node, group, chname, NULL,
+ NULL);
+ for (p = 1; p <= node->numports; p++) {
+ port = node->ports[p];
+ if (port && port->remoteport)
+ out_switch_port(port,
+ group,
+ NULL);
+ }
+ }
+
+ }
+
+ fprintf(f, "\n# Chassis CAs");
+ for (node = ch->nodes; node;
+ node = node->next_chassis_node) {
+ if (node->type == IB_NODE_CA) {
+ out_ca(node, group, chname, NULL, NULL);
+ for (p = 1; p <= node->numports; p++) {
+ port = node->ports[p];
+ if (port && port->remoteport)
+ out_ca_port(port, group,
+ NULL);
+ }
+ }
+ }
+
+ }
+
+ } else { /* !group */
+ iter_user_data.group = group;
+ iter_user_data.skip_chassis_nodes = 0;
+ ibnd_iter_nodes_type(fabric, switch_iter_func, IB_NODE_SWITCH,
+ &iter_user_data);
+ }
+
+ chname = NULL;
+ if (group) {
+ iter_user_data.group = group;
+ iter_user_data.skip_chassis_nodes = 1;
+
+ fprintf(f, "\nNon-Chassis Nodes\n");
+
+ ibnd_iter_nodes_type(fabric, switch_iter_func, IB_NODE_SWITCH,
+ &iter_user_data);
+ }
+
+ iter_user_data.group = group;
+ iter_user_data.skip_chassis_nodes = 0;
+ /* Make pass on CAs */
+ ibnd_iter_nodes_type(fabric, ca_iter_func, IB_NODE_CA, &iter_user_data);
+
+ /* Make pass on routers */
+ ibnd_iter_nodes_type(fabric, router_iter_func, IB_NODE_ROUTER,
+ &iter_user_data);
+
+ return i;
+}
+
+void dump_ports_report(ibnd_node_t * node, void *user_data)
+{
+ int p = 0;
+ ibnd_port_t *port = NULL;
+ char *nodename = NULL;
+ char *rem_nodename = NULL;
+
+ /* for each port */
+ for (p = node->numports, port = node->ports[p]; p > 0;
+ port = node->ports[--p]) {
+ uint32_t iwidth, ispeed, fdr10, espeed, cap_mask;
+ uint8_t *info = NULL;
+ if (port == NULL)
+ continue;
+ iwidth =
+ mad_get_field(port->info, 0, IB_PORT_LINK_WIDTH_ACTIVE_F);
+ ispeed =
+ mad_get_field(port->info, 0, IB_PORT_LINK_SPEED_ACTIVE_F);
+ if (port->node->type == IB_NODE_SWITCH) {
+ if (port->node->ports[0])
+ info = (uint8_t *)&port->node->ports[0]->info;
+ }
+ else
+ info = (uint8_t *)&port->info;
+ if (info) {
+ cap_mask = mad_get_field(info, 0, IB_PORT_CAPMASK_F);
+ if (cap_mask & CL_NTOH32(IB_PORT_CAP_HAS_EXT_SPEEDS))
+ espeed = mad_get_field(port->info, 0,
+ IB_PORT_LINK_SPEED_EXT_ACTIVE_F);
+ else
+ espeed = 0;
+ } else {
+ ispeed = 0;
+ iwidth = 0;
+ espeed = 0;
+ }
+ fdr10 = mad_get_field(port->ext_info, 0,
+ IB_MLNX_EXT_PORT_LINK_SPEED_ACTIVE_F);
+ nodename = remap_node_name(node_name_map,
+ port->node->guid,
+ port->node->nodedesc);
+ fprintf(stdout, "%2s %5d %2d 0x%016" PRIx64 " %s %s",
+ ports_nt_str_compat(node),
+ node->type ==
+ IB_NODE_SWITCH ? node->smalid : port->base_lid,
+ port->portnum, port->guid,
+ dump_linkwidth_compat(iwidth),
+ (ispeed != 4 && !espeed) ?
+ dump_linkspeed_compat(ispeed) :
+ dump_linkspeedext_compat(espeed, ispeed, fdr10));
+ if (port->remoteport) {
+ rem_nodename = remap_node_name(node_name_map,
+ port->remoteport->node->guid,
+ port->remoteport->node->nodedesc);
+ fprintf(stdout,
+ " - %2s %5d %2d 0x%016" PRIx64
+ " ( '%s' - '%s' )\n",
+ ports_nt_str_compat(port->remoteport->node),
+ port->remoteport->node->type == IB_NODE_SWITCH ?
+ port->remoteport->node->smalid :
+ port->remoteport->base_lid,
+ port->remoteport->portnum,
+ port->remoteport->guid, nodename, rem_nodename);
+ free(rem_nodename);
+ } else
+ fprintf(stdout, "%36s'%s'\n", "", nodename);
+
+ free(nodename);
+ }
+}
+
+struct iter_diff_data {
+ uint32_t diff_flags;
+ ibnd_fabric_t *fabric1;
+ ibnd_fabric_t *fabric2;
+ char *fabric1_prefix;
+ char *fabric2_prefix;
+ void (*out_header) (ibnd_node_t *, int, char *, char *, char *);
+ void (*out_header_detail) (ibnd_node_t *, char *);
+ void (*out_port) (ibnd_port_t *, int, char *);
+};
+
+static void diff_iter_out_header(ibnd_node_t * node,
+ struct iter_diff_data *data,
+ int *out_header_flag)
+{
+ if (!(*out_header_flag)) {
+ (*data->out_header) (node, 0, NULL, NULL, NULL);
+ (*out_header_flag)++;
+ }
+}
+
+static void diff_ports(ibnd_node_t * fabric1_node, ibnd_node_t * fabric2_node,
+ int *out_header_flag, struct iter_diff_data *data)
+{
+ ibnd_port_t *fabric1_port;
+ ibnd_port_t *fabric2_port;
+ int p;
+
+ for (p = 1; p <= fabric1_node->numports; p++) {
+ int fabric1_out = 0, fabric2_out = 0;
+
+ fabric1_port = fabric1_node->ports[p];
+ fabric2_port = fabric2_node->ports[p];
+
+ if (data->diff_flags & DIFF_FLAG_PORT_CONNECTION) {
+ if ((fabric1_port && !fabric2_port)
+ || ((fabric1_port && fabric2_port)
+ && (fabric1_port->remoteport
+ && !fabric2_port->remoteport)))
+ fabric1_out++;
+ else if ((!fabric1_port && fabric2_port)
+ || ((fabric1_port && fabric2_port)
+ && (!fabric1_port->remoteport
+ && fabric2_port->remoteport)))
+ fabric2_out++;
+ else if ((fabric1_port && fabric2_port)
+ && ((fabric1_port->guid != fabric2_port->guid)
+ ||
+ ((fabric1_port->remoteport
+ && fabric2_port->remoteport)
+ && (fabric1_port->remoteport->guid !=
+ fabric2_port->remoteport->guid)))) {
+ fabric1_out++;
+ fabric2_out++;
+ }
+ }
+
+ if ((data->diff_flags & DIFF_FLAG_LID)
+ && fabric1_port && fabric2_port
+ && fabric1_port->base_lid != fabric2_port->base_lid) {
+ fabric1_out++;
+ fabric2_out++;
+ }
+
+ if (data->diff_flags & DIFF_FLAG_PORT_CONNECTION
+ && data->diff_flags & DIFF_FLAG_NODE_DESCRIPTION
+ && fabric1_port && fabric2_port
+ && fabric1_port->remoteport && fabric2_port->remoteport
+ && memcmp(fabric1_port->remoteport->node->nodedesc,
+ fabric2_port->remoteport->node->nodedesc,
+ IB_SMP_DATA_SIZE)) {
+ fabric1_out++;
+ fabric2_out++;
+ }
+
+ if (data->diff_flags & DIFF_FLAG_PORT_CONNECTION
+ && data->diff_flags & DIFF_FLAG_NODE_DESCRIPTION
+ && fabric1_port && fabric2_port
+ && fabric1_port->remoteport && fabric2_port->remoteport
+ && memcmp(fabric1_port->remoteport->node->nodedesc,
+ fabric2_port->remoteport->node->nodedesc,
+ IB_SMP_DATA_SIZE)) {
+ fabric1_out++;
+ fabric2_out++;
+ }
+
+ if (data->diff_flags & DIFF_FLAG_PORT_CONNECTION
+ && data->diff_flags & DIFF_FLAG_LID
+ && fabric1_port && fabric2_port
+ && fabric1_port->remoteport && fabric2_port->remoteport
+ && fabric1_port->remoteport->base_lid != fabric2_port->remoteport->base_lid) {
+ fabric1_out++;
+ fabric2_out++;
+ }
+
+ if (fabric1_out) {
+ diff_iter_out_header(fabric1_node, data,
+ out_header_flag);
+ (*data->out_port) (fabric1_port, 0,
+ data->fabric1_prefix);
+ }
+ if (fabric2_out) {
+ diff_iter_out_header(fabric1_node, data,
+ out_header_flag);
+ (*data->out_port) (fabric2_port, 0,
+ data->fabric2_prefix);
+ }
+ }
+}
+
+static void diff_iter_func(ibnd_node_t * fabric1_node, void *iter_user_data)
+{
+ struct iter_diff_data *data = iter_user_data;
+ ibnd_node_t *fabric2_node;
+ ibnd_port_t *fabric1_port;
+ int p;
+
+ DEBUG("DEBUG: fabric1_node %p\n", fabric1_node);
+
+ fabric2_node = ibnd_find_node_guid(data->fabric2, fabric1_node->guid);
+ if (!fabric2_node) {
+ (*data->out_header) (fabric1_node, 0, NULL,
+ data->fabric1_prefix,
+ data->fabric1_prefix);
+ for (p = 1; p <= fabric1_node->numports; p++) {
+ fabric1_port = fabric1_node->ports[p];
+ if (fabric1_port && fabric1_port->remoteport)
+ (*data->out_port) (fabric1_port, 0,
+ data->fabric1_prefix);
+ }
+ } else if (data->diff_flags &
+ (DIFF_FLAG_PORT_CONNECTION | DIFF_FLAG_LID
+ | DIFF_FLAG_NODE_DESCRIPTION)) {
+ int out_header_flag = 0;
+
+ if ((data->diff_flags & DIFF_FLAG_LID
+ && fabric1_node->smalid != fabric2_node->smalid) ||
+ (data->diff_flags & DIFF_FLAG_NODE_DESCRIPTION
+ && memcmp(fabric1_node->nodedesc, fabric2_node->nodedesc,
+ IB_SMP_DATA_SIZE))) {
+ (*data->out_header) (fabric1_node, 0, NULL, NULL,
+ data->fabric1_prefix);
+ (*data->out_header_detail) (fabric2_node,
+ data->fabric2_prefix);
+ fprintf(f, "\n");
+ out_header_flag++;
+ }
+
+ if (fabric1_node->numports != fabric2_node->numports) {
+ diff_iter_out_header(fabric1_node, data,
+ &out_header_flag);
+ fprintf(f, "%snumports = %d\n", data->fabric1_prefix,
+ fabric1_node->numports);
+ fprintf(f, "%snumports = %d\n", data->fabric2_prefix,
+ fabric2_node->numports);
+ return;
+ }
+
+ if (data->diff_flags & DIFF_FLAG_PORT_CONNECTION
+ || data->diff_flags & DIFF_FLAG_LID)
+ diff_ports(fabric1_node, fabric2_node, &out_header_flag,
+ data);
+ }
+}
+
+static int diff_common(ibnd_fabric_t * orig_fabric, ibnd_fabric_t * new_fabric,
+ int node_type, uint32_t diff_flags,
+ void (*out_header) (ibnd_node_t *, int, char *, char *,
+ char *),
+ void (*out_header_detail) (ibnd_node_t *, char *),
+ void (*out_port) (ibnd_port_t *, int, char *))
+{
+ struct iter_diff_data iter_diff_data;
+
+ iter_diff_data.diff_flags = diff_flags;
+ iter_diff_data.fabric1 = orig_fabric;
+ iter_diff_data.fabric2 = new_fabric;
+ iter_diff_data.fabric1_prefix = "< ";
+ iter_diff_data.fabric2_prefix = "> ";
+ iter_diff_data.out_header = out_header;
+ iter_diff_data.out_header_detail = out_header_detail;
+ iter_diff_data.out_port = out_port;
+ ibnd_iter_nodes_type(orig_fabric, diff_iter_func, node_type,
+ &iter_diff_data);
+
+ /* Do opposite diff to find existence of node types
+ * in new_fabric but not in orig_fabric.
+ *
+ * In this diff, we don't need to check port connections,
+ * lids, or node descriptions since it has already been
+ * done (i.e. checks are only done when guid exists on both
+ * orig and new).
+ */
+ iter_diff_data.diff_flags = diff_flags & ~DIFF_FLAG_PORT_CONNECTION;
+ iter_diff_data.diff_flags &= ~DIFF_FLAG_LID;
+ iter_diff_data.diff_flags &= ~DIFF_FLAG_NODE_DESCRIPTION;
+ iter_diff_data.fabric1 = new_fabric;
+ iter_diff_data.fabric2 = orig_fabric;
+ iter_diff_data.fabric1_prefix = "> ";
+ iter_diff_data.fabric2_prefix = "< ";
+ iter_diff_data.out_header = out_header;
+ iter_diff_data.out_header_detail = out_header_detail;
+ iter_diff_data.out_port = out_port;
+ ibnd_iter_nodes_type(new_fabric, diff_iter_func, node_type,
+ &iter_diff_data);
+
+ return 0;
+}
+
+int diff(ibnd_fabric_t * orig_fabric, ibnd_fabric_t * new_fabric)
+{
+ if (diffcheck_flags & DIFF_FLAG_SWITCH)
+ diff_common(orig_fabric, new_fabric, IB_NODE_SWITCH,
+ diffcheck_flags, out_switch, out_switch_detail,
+ out_switch_port);
+
+ if (diffcheck_flags & DIFF_FLAG_CA)
+ diff_common(orig_fabric, new_fabric, IB_NODE_CA,
+ diffcheck_flags, out_ca, out_ca_detail,
+ out_ca_port);
+
+ if (diffcheck_flags & DIFF_FLAG_ROUTER)
+ diff_common(orig_fabric, new_fabric, IB_NODE_ROUTER,
+ diffcheck_flags, out_ca, out_ca_detail,
+ out_ca_port);
+
+ return 0;
+}
+
+static int list, group, ports_report;
+
+static int process_opt(void *context, int ch, char *optarg)
+{
+ struct ibnd_config *cfg = context;
+ char *p;
+
+ switch (ch) {
+ case 1:
+ node_name_map_file = strdup(optarg);
+ break;
+ case 2:
+ cache_file = strdup(optarg);
+ break;
+ case 3:
+ load_cache_file = strdup(optarg);
+ break;
+ case 4:
+ diff_cache_file = strdup(optarg);
+ break;
+ case 5:
+ diffcheck_flags = 0;
+ p = strtok(optarg, ",");
+ while (p) {
+ if (!strcasecmp(p, "sw"))
+ diffcheck_flags |= DIFF_FLAG_SWITCH;
+ else if (!strcasecmp(p, "ca"))
+ diffcheck_flags |= DIFF_FLAG_CA;
+ else if (!strcasecmp(p, "router"))
+ diffcheck_flags |= DIFF_FLAG_ROUTER;
+ else if (!strcasecmp(p, "port"))
+ diffcheck_flags |= DIFF_FLAG_PORT_CONNECTION;
+ else if (!strcasecmp(p, "lid"))
+ diffcheck_flags |= DIFF_FLAG_LID;
+ else if (!strcasecmp(p, "nodedesc"))
+ diffcheck_flags |= DIFF_FLAG_NODE_DESCRIPTION;
+ else {
+ fprintf(stderr, "invalid diff check key: %s\n",
+ p);
+ return -1;
+ }
+ p = strtok(NULL, ",");
+ }
+ break;
+ case 's':
+ cfg->show_progress = 1;
+ break;
+ case 'f':
+ full_info = 1;
+ break;
+ case 'l':
+ list = LIST_CA_NODE | LIST_SWITCH_NODE | LIST_ROUTER_NODE;
+ break;
+ case 'g':
+ group = 1;
+ break;
+ case 'S':
+ list = LIST_SWITCH_NODE;
+ break;
+ case 'H':
+ list = LIST_CA_NODE;
+ break;
+ case 'R':
+ list = LIST_ROUTER_NODE;
+ break;
+ case 'p':
+ ports_report = 1;
+ break;
+ case 'm':
+ report_max_hops = 1;
+ break;
+ case 'o':
+ cfg->max_smps = strtoul(optarg, NULL, 0);
+ break;
+ default:
+ return -1;
+ }
+
+ return 0;
+}
+
+int main(int argc, char **argv)
+{
+ struct ibnd_config config = { 0 };
+ ibnd_fabric_t *fabric = NULL;
+ ibnd_fabric_t *diff_fabric = NULL;
+
+ const struct ibdiag_opt opts[] = {
+ {"full", 'f', 0, NULL, "show full information (ports' speed and width, vlcap)"},
+ {"show", 's', 0, NULL, "show more information"},
+ {"list", 'l', 0, NULL, "list of connected nodes"},
+ {"grouping", 'g', 0, NULL, "show grouping"},
+ {"Hca_list", 'H', 0, NULL, "list of connected CAs"},
+ {"Switch_list", 'S', 0, NULL, "list of connected switches"},
+ {"Router_list", 'R', 0, NULL, "list of connected routers"},
+ {"node-name-map", 1, 1, "<file>", "node name map file"},
+ {"cache", 2, 1, "<file>",
+ "filename to cache ibnetdiscover data to"},
+ {"load-cache", 3, 1, "<file>",
+ "filename of ibnetdiscover cache to load"},
+ {"diff", 4, 1, "<file>",
+ "filename of ibnetdiscover cache to diff"},
+ {"diffcheck", 5, 1, "<key(s)>",
+ "specify checks to execute for --diff"},
+ {"ports", 'p', 0, NULL, "obtain a ports report"},
+ {"max_hops", 'm', 0, NULL,
+ "report max hops discovered by the library"},
+ {"outstanding_smps", 'o', 1, NULL,
+ "specify the number of outstanding SMP's which should be "
+ "issued during the scan"},
+ {0}
+ };
+ char usage_args[] = "[topology-file]";
+
+ ibdiag_process_opts(argc, argv, &config, "DGKLs", opts, process_opt,
+ usage_args, NULL);
+
+ f = stdout;
+
+ argc -= optind;
+ argv += optind;
+
+ if (ibd_timeout)
+ config.timeout_ms = ibd_timeout;
+
+ config.flags = ibd_ibnetdisc_flags;
+
+ if (argc && !(f = fopen(argv[0], "w")))
+ IBEXIT("can't open file %s for writing", argv[0]);
+
+ config.mkey = ibd_mkey;
+
+ node_name_map = open_node_name_map(node_name_map_file);
+
+ if (diff_cache_file &&
+ !(diff_fabric = ibnd_load_fabric(diff_cache_file, 0)))
+ IBEXIT("loading cached fabric for diff failed\n");
+
+ if (load_cache_file) {
+ if ((fabric = ibnd_load_fabric(load_cache_file, 0)) == NULL)
+ IBEXIT("loading cached fabric failed\n");
+ } else {
+ if ((fabric =
+ ibnd_discover_fabric(ibd_ca, ibd_ca_port, NULL, &config)) == NULL)
+ IBEXIT("discover failed\n");
+ }
+
+ if (ports_report)
+ ibnd_iter_nodes(fabric, dump_ports_report, NULL);
+ else if (list)
+ list_nodes(fabric, list);
+ else if (diff_fabric)
+ diff(diff_fabric, fabric);
+ else
+ dump_topology(group, fabric);
+
+ if (cache_file)
+ if (ibnd_cache_fabric(fabric, cache_file, 0) < 0)
+ IBEXIT("caching ibnetdiscover data failed\n");
+
+ ibnd_destroy_fabric(fabric);
+ if (diff_fabric)
+ ibnd_destroy_fabric(diff_fabric);
+ close_node_name_map(node_name_map);
+ exit(0);
+}
diff --git a/contrib/ofed/infiniband-diags/src/ibping.c b/contrib/ofed/infiniband-diags/src/ibping.c
new file mode 100644
index 0000000..b371e1e
--- /dev/null
+++ b/contrib/ofed/infiniband-diags/src/ibping.c
@@ -0,0 +1,286 @@
+/*
+ * Copyright (c) 2004-2009 Voltaire Inc. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+#if HAVE_CONFIG_H
+# include <config.h>
+#endif /* HAVE_CONFIG_H */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <string.h>
+#include <signal.h>
+#include <getopt.h>
+
+#include <infiniband/umad.h>
+#include <infiniband/mad.h>
+#include <complib/cl_timer.h>
+
+#include "ibdiag_common.h"
+
+struct ibmad_port *srcport;
+
+static char host_and_domain[IB_VENDOR_RANGE2_DATA_SIZE];
+static char last_host[IB_VENDOR_RANGE2_DATA_SIZE];
+static ibmad_gid_t dgid;
+static int with_grh;
+
+static void get_host_and_domain(char *data, int sz)
+{
+ char *s = data;
+ int n;
+
+ if (gethostname(s, sz) < 0)
+ snprintf(s, sz, "?hostname?");
+
+ s[sz - 1] = 0;
+ if ((n = strlen(s)) >= sz)
+ return;
+ s[n] = '.';
+ s += n + 1;
+ sz -= n + 1;
+
+ if (getdomainname(s, sz) < 0)
+ snprintf(s, sz, "?domainname?");
+ if (strlen(s) == 0)
+ s[-1] = 0; /* no domain */
+}
+
+static char *ibping_serv(void)
+{
+ void *umad;
+ void *mad;
+ char *data;
+
+ DEBUG("starting to serve...");
+
+ while ((umad = mad_receive_via(0, -1, srcport))) {
+
+ if (umad_status(umad) == 0) {
+ mad = umad_get_mad(umad);
+ data = (char *)mad + IB_VENDOR_RANGE2_DATA_OFFS;
+
+ memcpy(data, host_and_domain, IB_VENDOR_RANGE2_DATA_SIZE);
+
+ DEBUG("Pong: %s", data);
+
+ if (mad_respond_via(umad, 0, 0, srcport) < 0)
+ DEBUG("respond failed");
+
+ }
+ mad_free(umad);
+ }
+
+ DEBUG("server out");
+ return 0;
+}
+
+static int oui = IB_OPENIB_OUI;
+
+static uint64_t ibping(ib_portid_t * portid, int quiet)
+{
+ char data[IB_VENDOR_RANGE2_DATA_SIZE] = { 0 };
+ ib_vendor_call_t call;
+ uint64_t start, rtt;
+
+ DEBUG("Ping..");
+
+ start = cl_get_time_stamp();
+
+ call.method = IB_MAD_METHOD_GET;
+ call.mgmt_class = IB_VENDOR_OPENIB_PING_CLASS;
+ call.attrid = 0;
+ call.mod = 0;
+ call.oui = oui;
+ call.timeout = 0;
+ memset(&call.rmpp, 0, sizeof call.rmpp);
+
+ if (!ib_vendor_call_via(data, portid, &call, srcport))
+ return ~0ull;
+
+ rtt = cl_get_time_stamp() - start;
+
+ if (!last_host[0])
+ memcpy(last_host, data, sizeof last_host);
+
+ if (!quiet)
+ printf("Pong from %s (%s): time %" PRIu64 ".%03" PRIu64 " ms\n",
+ data, portid2str(portid), rtt / 1000, rtt % 1000);
+
+ return rtt;
+}
+
+static uint64_t minrtt = ~0ull, maxrtt, total_rtt;
+static uint64_t start, total_time, replied, lost, ntrans;
+static ib_portid_t portid = { 0 };
+
+void report(int sig)
+{
+ total_time = cl_get_time_stamp() - start;
+
+ DEBUG("out due signal %d", sig);
+
+ printf("\n--- %s (%s) ibping statistics ---\n", last_host,
+ portid2str(&portid));
+ printf("%" PRIu64 " packets transmitted, %" PRIu64 " received, %" PRIu64
+ "%% packet loss, time %" PRIu64 " ms\n", ntrans, replied,
+ (lost != 0) ? lost * 100 / ntrans : 0, total_time / 1000);
+ printf("rtt min/avg/max = %" PRIu64 ".%03" PRIu64 "/%" PRIu64 ".%03"
+ PRIu64 "/%" PRIu64 ".%03" PRIu64 " ms\n",
+ minrtt == ~0ull ? 0 : minrtt / 1000,
+ minrtt == ~0ull ? 0 : minrtt % 1000,
+ replied ? total_rtt / replied / 1000 : 0,
+ replied ? (total_rtt / replied) % 1000 : 0, maxrtt / 1000,
+ maxrtt % 1000);
+
+ exit(0);
+}
+
+static int server = 0, flood = 0;
+static unsigned count = ~0;
+
+static int process_opt(void *context, int ch, char *optarg)
+{
+ switch (ch) {
+ case 'c':
+ count = strtoul(optarg, 0, 0);
+ break;
+ case 'f':
+ flood++;
+ break;
+ case 'o':
+ oui = strtoul(optarg, 0, 0);
+ break;
+ case 'S':
+ server++;
+ break;
+ case 25:
+ if (!inet_pton(AF_INET6, optarg, &dgid)) {
+ printf("dgid format is wrong!\n");
+ ibdiag_show_usage();
+ return 1;
+ }
+ with_grh = 1;
+ break;
+ default:
+ return -1;
+ }
+ return 0;
+}
+
+int main(int argc, char **argv)
+{
+ int mgmt_classes[1] = { IB_SA_CLASS };
+ int ping_class = IB_VENDOR_OPENIB_PING_CLASS;
+ uint64_t rtt;
+ char *err;
+
+ const struct ibdiag_opt opts[] = {
+ {"count", 'c', 1, "<num>", "stop after count packets"},
+ {"flood", 'f', 0, NULL, "flood destination"},
+ {"oui", 'o', 1, NULL, "use specified OUI number"},
+ {"Server", 'S', 0, NULL, "start in server mode"},
+ {"dgid", 25, 1, NULL, "remote gid (IPv6 format)"},
+ {0}
+ };
+ char usage_args[] = "<dest lid|guid>";
+
+ ibdiag_process_opts(argc, argv, NULL, "DKy", opts, process_opt,
+ usage_args, NULL);
+
+ argc -= optind;
+ argv += optind;
+
+ if (!argc && !server)
+ ibdiag_show_usage();
+
+ srcport = mad_rpc_open_port(ibd_ca, ibd_ca_port, mgmt_classes, 1);
+ if (!srcport)
+ IBEXIT("Failed to open '%s' port '%d'", ibd_ca, ibd_ca_port);
+
+ if (server) {
+ if (mad_register_server_via(ping_class, 0, 0, oui, srcport) < 0)
+ IBEXIT("can't serve class %d on this port",
+ ping_class);
+
+ get_host_and_domain(host_and_domain, sizeof host_and_domain);
+
+ if ((err = ibping_serv()))
+ IBEXIT("ibping to %s: %s", portid2str(&portid), err);
+ exit(0);
+ }
+
+ if (mad_register_client_via(ping_class, 0, srcport) < 0)
+ IBEXIT("can't register ping class %d on this port",
+ ping_class);
+
+ if (with_grh && ibd_dest_type != IB_DEST_LID)
+ IBEXIT("When using GRH, LID should be provided");
+ if (resolve_portid_str(ibd_ca, ibd_ca_port, &portid, argv[0],
+ ibd_dest_type, ibd_sm_id, srcport) < 0)
+ IBEXIT("can't resolve destination port %s", argv[0]);
+
+ if (with_grh) {
+ portid.grh_present = 1;
+ memcpy(&portid.gid, &dgid, sizeof(portid.gid));
+ }
+
+ signal(SIGINT, report);
+ signal(SIGTERM, report);
+
+ start = cl_get_time_stamp();
+
+ while (count-- > 0) {
+ ntrans++;
+ if ((rtt = ibping(&portid, flood)) == ~0ull) {
+ DEBUG("ibping to %s failed", portid2str(&portid));
+ lost++;
+ } else {
+ if (rtt < minrtt)
+ minrtt = rtt;
+ if (rtt > maxrtt)
+ maxrtt = rtt;
+ total_rtt += rtt;
+ replied++;
+ }
+
+ if (!flood)
+ sleep(1);
+ }
+
+ report(0);
+
+ mad_rpc_close_port(srcport);
+
+ exit(-1);
+}
diff --git a/contrib/ofed/infiniband-diags/src/ibportstate.c b/contrib/ofed/infiniband-diags/src/ibportstate.c
new file mode 100644
index 0000000..06bd5d2
--- /dev/null
+++ b/contrib/ofed/infiniband-diags/src/ibportstate.c
@@ -0,0 +1,767 @@
+/*
+ * Copyright (c) 2004-2009 Voltaire Inc. All rights reserved.
+ * Copyright (c) 2010,2011 Mellanox Technologies LTD. All rights reserved.
+ * Copyright (c) 2011,2016 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+#if HAVE_CONFIG_H
+# include <config.h>
+#endif /* HAVE_CONFIG_H */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <string.h>
+#include <getopt.h>
+#include <errno.h>
+
+#include <infiniband/umad.h>
+#include <infiniband/mad.h>
+
+#include "ibdiag_common.h"
+
+enum port_ops {
+ QUERY,
+ ENABLE,
+ RESET,
+ DISABLE,
+ SPEED,
+ ESPEED,
+ FDR10SPEED,
+ WIDTH,
+ DOWN,
+ ARM,
+ ACTIVE,
+ VLS,
+ MTU,
+ LID,
+ SMLID,
+ LMC,
+ MKEY,
+ MKEYLEASE,
+ MKEYPROT,
+ ON,
+ OFF
+};
+
+struct ibmad_port *srcport;
+uint64_t speed = 0; /* no state change */
+uint64_t espeed = 0; /* no state change */
+uint64_t fdr10 = 0; /* no state change */
+uint64_t width = 0; /* no state change */
+uint64_t lid;
+uint64_t smlid;
+uint64_t lmc;
+uint64_t mtu;
+uint64_t vls = 0; /* no state change */
+uint64_t mkey;
+uint64_t mkeylease;
+uint64_t mkeyprot;
+
+struct {
+ const char *name;
+ uint64_t *val;
+ int set;
+} port_args[] = {
+ {"query", NULL, 0}, /* QUERY */
+ {"enable", NULL, 0}, /* ENABLE */
+ {"reset", NULL, 0}, /* RESET */
+ {"disable", NULL, 0}, /* DISABLE */
+ {"speed", &speed, 0}, /* SPEED */
+ {"espeed", &espeed, 0}, /* EXTENDED SPEED */
+ {"fdr10", &fdr10, 0}, /* FDR10 SPEED */
+ {"width", &width, 0}, /* WIDTH */
+ {"down", NULL, 0}, /* DOWN */
+ {"arm", NULL, 0}, /* ARM */
+ {"active", NULL, 0}, /* ACTIVE */
+ {"vls", &vls, 0}, /* VLS */
+ {"mtu", &mtu, 0}, /* MTU */
+ {"lid", &lid, 0}, /* LID */
+ {"smlid", &smlid, 0}, /* SMLID */
+ {"lmc", &lmc, 0}, /* LMC */
+ {"mkey", &mkey, 0}, /* MKEY */
+ {"mkeylease", &mkeylease, 0}, /* MKEY LEASE */
+ {"mkeyprot", &mkeyprot, 0}, /* MKEY PROTECT BITS */
+ {"on", NULL, 0}, /* ON */
+ {"off", NULL, 0}, /* OFF */
+};
+
+#define NPORT_ARGS (sizeof(port_args) / sizeof(port_args[0]))
+
+/*******************************************/
+
+/*
+ * Return 1 if node is a switch, else zero.
+ */
+static int get_node_info(ib_portid_t * dest, uint8_t * data)
+{
+ int node_type;
+
+ if (!smp_query_via(data, dest, IB_ATTR_NODE_INFO, 0, 0, srcport))
+ IBEXIT("smp query nodeinfo failed");
+
+ node_type = mad_get_field(data, 0, IB_NODE_TYPE_F);
+ if (node_type == IB_NODE_SWITCH) /* Switch NodeType ? */
+ return 1;
+ else
+ return 0;
+}
+
+static int get_port_info(ib_portid_t * dest, uint8_t * data, int portnum,
+ int is_switch)
+{
+ uint8_t smp[IB_SMP_DATA_SIZE];
+ uint8_t *info;
+ int cap_mask;
+
+ if (is_switch) {
+ if (!smp_query_via(smp, dest, IB_ATTR_PORT_INFO, 0, 0, srcport))
+ IBEXIT("smp query port 0 portinfo failed");
+ info = smp;
+ } else
+ info = data;
+
+ if (!smp_query_via(data, dest, IB_ATTR_PORT_INFO, portnum, 0, srcport))
+ IBEXIT("smp query portinfo failed");
+ cap_mask = mad_get_field(info, 0, IB_PORT_CAPMASK_F);
+ return (cap_mask & CL_NTOH32(IB_PORT_CAP_HAS_EXT_SPEEDS));
+}
+
+static void show_port_info(ib_portid_t * dest, uint8_t * data, int portnum,
+ int espeed_cap, int is_switch)
+{
+ char buf[2300];
+ char val[64];
+
+ mad_dump_portstates(buf, sizeof buf, data, sizeof *data);
+ mad_decode_field(data, IB_PORT_LID_F, val);
+ mad_dump_field(IB_PORT_LID_F, buf + strlen(buf),
+ sizeof buf - strlen(buf), val);
+ sprintf(buf + strlen(buf), "%s", "\n");
+ mad_decode_field(data, IB_PORT_SMLID_F, val);
+ mad_dump_field(IB_PORT_SMLID_F, buf + strlen(buf),
+ sizeof buf - strlen(buf), val);
+ sprintf(buf + strlen(buf), "%s", "\n");
+ mad_decode_field(data, IB_PORT_LMC_F, val);
+ mad_dump_field(IB_PORT_LMC_F, buf + strlen(buf),
+ sizeof buf - strlen(buf), val);
+ sprintf(buf + strlen(buf), "%s", "\n");
+ mad_decode_field(data, IB_PORT_LINK_WIDTH_SUPPORTED_F, val);
+ mad_dump_field(IB_PORT_LINK_WIDTH_SUPPORTED_F, buf + strlen(buf),
+ sizeof buf - strlen(buf), val);
+ sprintf(buf + strlen(buf), "%s", "\n");
+ mad_decode_field(data, IB_PORT_LINK_WIDTH_ENABLED_F, val);
+ mad_dump_field(IB_PORT_LINK_WIDTH_ENABLED_F, buf + strlen(buf),
+ sizeof buf - strlen(buf), val);
+ sprintf(buf + strlen(buf), "%s", "\n");
+ mad_decode_field(data, IB_PORT_LINK_WIDTH_ACTIVE_F, val);
+ mad_dump_field(IB_PORT_LINK_WIDTH_ACTIVE_F, buf + strlen(buf),
+ sizeof buf - strlen(buf), val);
+ sprintf(buf + strlen(buf), "%s", "\n");
+ mad_decode_field(data, IB_PORT_LINK_SPEED_SUPPORTED_F, val);
+ mad_dump_field(IB_PORT_LINK_SPEED_SUPPORTED_F, buf + strlen(buf),
+ sizeof buf - strlen(buf), val);
+ sprintf(buf + strlen(buf), "%s", "\n");
+ mad_decode_field(data, IB_PORT_LINK_SPEED_ENABLED_F, val);
+ mad_dump_field(IB_PORT_LINK_SPEED_ENABLED_F, buf + strlen(buf),
+ sizeof buf - strlen(buf), val);
+ sprintf(buf + strlen(buf), "%s", "\n");
+ mad_decode_field(data, IB_PORT_LINK_SPEED_ACTIVE_F, val);
+ mad_dump_field(IB_PORT_LINK_SPEED_ACTIVE_F, buf + strlen(buf),
+ sizeof buf - strlen(buf), val);
+ sprintf(buf + strlen(buf), "%s", "\n");
+ if (espeed_cap) {
+ mad_decode_field(data, IB_PORT_LINK_SPEED_EXT_SUPPORTED_F, val);
+ mad_dump_field(IB_PORT_LINK_SPEED_EXT_SUPPORTED_F,
+ buf + strlen(buf), sizeof buf - strlen(buf),
+ val);
+ sprintf(buf + strlen(buf), "%s", "\n");
+ mad_decode_field(data, IB_PORT_LINK_SPEED_EXT_ENABLED_F, val);
+ mad_dump_field(IB_PORT_LINK_SPEED_EXT_ENABLED_F,
+ buf + strlen(buf), sizeof buf - strlen(buf),
+ val);
+ sprintf(buf + strlen(buf), "%s", "\n");
+ mad_decode_field(data, IB_PORT_LINK_SPEED_EXT_ACTIVE_F, val);
+ mad_dump_field(IB_PORT_LINK_SPEED_EXT_ACTIVE_F,
+ buf + strlen(buf), sizeof buf - strlen(buf),
+ val);
+ sprintf(buf + strlen(buf), "%s", "\n");
+ }
+ if (!is_switch || portnum == 0) {
+ if (show_keys) {
+ mad_decode_field(data, IB_PORT_MKEY_F, val);
+ mad_dump_field(IB_PORT_MKEY_F, buf + strlen(buf),
+ sizeof buf - strlen(buf), val);
+ } else
+ snprint_field(buf+strlen(buf), sizeof(buf)-strlen(buf),
+ IB_PORT_MKEY_F, 32, NOT_DISPLAYED_STR);
+ sprintf(buf+strlen(buf), "%s", "\n");
+ mad_decode_field(data, IB_PORT_MKEY_LEASE_F, val);
+ mad_dump_field(IB_PORT_MKEY_LEASE_F, buf + strlen(buf),
+ sizeof buf - strlen(buf), val);
+ sprintf(buf+strlen(buf), "%s", "\n");
+ mad_decode_field(data, IB_PORT_MKEY_PROT_BITS_F, val);
+ mad_dump_field(IB_PORT_MKEY_PROT_BITS_F, buf + strlen(buf),
+ sizeof buf - strlen(buf), val);
+ sprintf(buf+strlen(buf), "%s", "\n");
+ }
+
+ printf("# Port info: %s port %d\n%s", portid2str(dest), portnum, buf);
+}
+
+static void set_port_info(ib_portid_t * dest, uint8_t * data, int portnum,
+ int espeed_cap, int is_switch)
+{
+ unsigned mod;
+
+ mod = portnum;
+ if (espeed_cap)
+ mod |= 1<<31;
+ if (!smp_set_via(data, dest, IB_ATTR_PORT_INFO, mod, 0, srcport))
+ IBEXIT("smp set portinfo failed");
+
+ printf("\nAfter PortInfo set:\n");
+ show_port_info(dest, data, portnum, espeed_cap, is_switch);
+}
+
+static void get_mlnx_ext_port_info(ib_portid_t * dest, uint8_t * data, int portnum)
+{
+ if (!smp_query_via(data, dest, IB_ATTR_MLNX_EXT_PORT_INFO,
+ portnum, 0, srcport))
+ IBEXIT("smp query ext portinfo failed");
+}
+
+static void show_mlnx_ext_port_info(ib_portid_t * dest, uint8_t * data, int portnum)
+{
+ char buf[256];
+
+ mad_dump_mlnx_ext_port_info(buf, sizeof buf, data, IB_SMP_DATA_SIZE);
+
+ printf("# MLNX ext Port info: %s port %d\n%s", portid2str(dest),
+ portnum, buf);
+}
+
+static void set_mlnx_ext_port_info(ib_portid_t * dest, uint8_t * data, int portnum)
+{
+ if (!smp_set_via(data, dest, IB_ATTR_MLNX_EXT_PORT_INFO,
+ portnum, 0, srcport))
+ IBEXIT("smp set MLNX ext portinfo failed");
+
+ printf("\nAfter MLNXExtendedPortInfo set:\n");
+ show_mlnx_ext_port_info(dest, data, portnum);
+}
+
+static int get_link_width(int lwe, int lws)
+{
+ if (lwe == 255)
+ return lws;
+ else
+ return lwe;
+}
+
+static int get_link_speed(int lse, int lss)
+{
+ if (lse == 15)
+ return lss;
+ else
+ return lse;
+}
+
+static int get_link_speed_ext(int lsee, int lses)
+{
+ if (lsee == 31)
+ return lses;
+ else
+ return lsee;
+}
+
+static void validate_width(int width, int peerwidth, int lwa)
+{
+ if ((width & peerwidth & 0x8)) {
+ if (lwa != 8)
+ IBWARN
+ ("Peer ports operating at active width %d rather than 8 (12x)",
+ lwa);
+ } else if ((width & peerwidth & 0x4)) {
+ if (lwa != 4)
+ IBWARN
+ ("Peer ports operating at active width %d rather than 4 (8x)",
+ lwa);
+ } else if ((width & peerwidth & 0x2)) {
+ if (lwa != 2)
+ IBWARN
+ ("Peer ports operating at active width %d rather than 2 (4x)",
+ lwa);
+ } else if ((width & peerwidth & 0x10)) {
+ if (lwa != 16)
+ IBWARN
+ ("Peer ports operating at active width %d rather than 16 (2x)",
+ lwa);
+ } else if ((width & peerwidth & 0x1)) {
+ if (lwa != 1)
+ IBWARN
+ ("Peer ports operating at active width %d rather than 1 (1x)",
+ lwa);
+ }
+}
+
+static void validate_speed(int speed, int peerspeed, int lsa)
+{
+ if ((speed & peerspeed & 0x4)) {
+ if (lsa != 4)
+ IBWARN
+ ("Peer ports operating at active speed %d rather than 4 (10.0 Gbps)",
+ lsa);
+ } else if ((speed & peerspeed & 0x2)) {
+ if (lsa != 2)
+ IBWARN
+ ("Peer ports operating at active speed %d rather than 2 (5.0 Gbps)",
+ lsa);
+ } else if ((speed & peerspeed & 0x1)) {
+ if (lsa != 1)
+ IBWARN
+ ("Peer ports operating at active speed %d rather than 1 (2.5 Gbps)",
+ lsa);
+ }
+}
+
+static void validate_extended_speed(int espeed, int peerespeed, int lsea)
+{
+ if ((espeed & peerespeed & 0x2)) {
+ if (lsea != 2)
+ IBWARN
+ ("Peer ports operating at active extended speed %d rather than 2 (25.78125 Gbps)",
+ lsea);
+ } else if ((espeed & peerespeed & 0x1)) {
+ if (lsea != 1)
+ IBWARN
+ ("Peer ports operating at active extended speed %d rather than 1 (14.0625 Gbps)",
+ lsea);
+ }
+}
+
+int main(int argc, char **argv)
+{
+ int mgmt_classes[3] =
+ { IB_SMI_CLASS, IB_SMI_DIRECT_CLASS, IB_SA_CLASS };
+ ib_portid_t portid = { 0 };
+ int port_op = -1;
+ int is_switch, is_peer_switch, espeed_cap, peer_espeed_cap;
+ int state, physstate, lwe, lws, lwa, lse, lss, lsa, lsee, lses, lsea,
+ fdr10s, fdr10e, fdr10a;
+ int peerlocalportnum, peerlwe, peerlws, peerlwa, peerlse, peerlss,
+ peerlsa, peerlsee, peerlses, peerlsea, peerfdr10s, peerfdr10e,
+ peerfdr10a;
+ int peerwidth, peerspeed, peerespeed;
+ uint8_t data[IB_SMP_DATA_SIZE] = { 0 };
+ uint8_t data2[IB_SMP_DATA_SIZE] = { 0 };
+ ib_portid_t peerportid = { 0 };
+ int portnum = 0;
+ ib_portid_t selfportid = { 0 };
+ int selfport = 0;
+ int changed = 0;
+ int i;
+ uint32_t vendorid, rem_vendorid;
+ uint16_t devid, rem_devid;
+ uint64_t val;
+ char *endp;
+ char usage_args[] = "<dest dr_path|lid|guid> <portnum> [<op>]\n"
+ "\nSupported ops: enable, disable, on, off, reset, speed, espeed, fdr10,\n"
+ "\twidth, query, down, arm, active, vls, mtu, lid, smlid, lmc,\n"
+ "\tmkey, mkeylease, mkeyprot\n";
+ const char *usage_examples[] = {
+ "3 1 disable\t\t\t# by lid",
+ "-G 0x2C9000100D051 1 enable\t# by guid",
+ "-D 0 1\t\t\t# (query) by direct route",
+ "3 1 reset\t\t\t# by lid",
+ "3 1 speed 1\t\t\t# by lid",
+ "3 1 width 1\t\t\t# by lid",
+ "-D 0 1 lid 0x1234 arm\t\t# by direct route",
+ NULL
+ };
+
+ ibdiag_process_opts(argc, argv, NULL, NULL, NULL, NULL,
+ usage_args, usage_examples);
+
+ argc -= optind;
+ argv += optind;
+
+ if (argc < 2)
+ ibdiag_show_usage();
+
+ srcport = mad_rpc_open_port(ibd_ca, ibd_ca_port, mgmt_classes, 3);
+ if (!srcport)
+ IBEXIT("Failed to open '%s' port '%d'", ibd_ca, ibd_ca_port);
+
+ smp_mkey_set(srcport, ibd_mkey);
+
+ if (resolve_portid_str(ibd_ca, ibd_ca_port, &portid, argv[0],
+ ibd_dest_type, ibd_sm_id, srcport) < 0)
+ IBEXIT("can't resolve destination port %s", argv[0]);
+
+ if (argc > 1)
+ portnum = strtol(argv[1], 0, 0);
+
+ for (i = 2; i < argc; i++) {
+ int j;
+
+ for (j = 0; j < NPORT_ARGS; j++) {
+ if (strcmp(argv[i], port_args[j].name))
+ continue;
+ port_args[j].set = 1;
+ if (!port_args[j].val) {
+ if (port_op >= 0)
+ IBEXIT("%s only one of: ",
+ "query, enable, disable, "
+ "reset, down, arm, active, "
+ "can be specified",
+ port_args[j].name);
+ port_op = j;
+ break;
+ }
+ if (++i >= argc)
+ IBEXIT("%s requires an additional parameter",
+ port_args[j].name);
+ val = strtoull(argv[i], 0, 0);
+ switch (j) {
+ case SPEED:
+ if (val > 15)
+ IBEXIT("invalid speed value %ld", val);
+ break;
+ case ESPEED:
+ if (val > 31)
+ IBEXIT("invalid extended speed value %ld", val);
+ break;
+ case FDR10SPEED:
+ if (val > 1)
+ IBEXIT("invalid fdr10 speed value %ld", val);
+ break;
+ case WIDTH:
+ if ((val > 31 && val != 255))
+ IBEXIT("invalid width value %ld", val);
+ break;
+ case VLS:
+ if (val == 0 || val > 5)
+ IBEXIT("invalid vls value %ld", val);
+ break;
+ case MTU:
+ if (val == 0 || val > 5)
+ IBEXIT("invalid mtu value %ld", val);
+ break;
+ case LID:
+ if (val == 0 || val >= 0xC000)
+ IBEXIT("invalid lid value 0x%lx", val);
+ break;
+ case SMLID:
+ if (val == 0 || val >= 0xC000)
+ IBEXIT("invalid smlid value 0x%lx",
+ val);
+ break;
+ case LMC:
+ if (val > 7)
+ IBEXIT("invalid lmc value %ld", val);
+ break;
+ case MKEY:
+ errno = 0;
+ val = strtoull(argv[i], &endp, 0);
+ if (errno || *endp != '\0') {
+ errno = 0;
+ val = strtoull(getpass("New M_Key: "),
+ &endp, 0);
+ if (errno || *endp != '\0') {
+ IBEXIT("Bad new M_Key\n");
+ }
+ }
+ /* All 64-bit values are legal */
+ break;
+ case MKEYLEASE:
+ if (val > 0xFFFF)
+ IBEXIT("invalid mkey lease time %ld", val);
+ break;
+ case MKEYPROT:
+ if (val > 3)
+ IBEXIT("invalid mkey protection bit setting %ld", val);
+ }
+ *port_args[j].val = val;
+ changed = 1;
+ break;
+ }
+ if (j == NPORT_ARGS)
+ IBEXIT("invalid operation: %s", argv[i]);
+ }
+ if (port_op < 0)
+ port_op = QUERY;
+
+ is_switch = get_node_info(&portid, data);
+ vendorid = (uint32_t) mad_get_field(data, 0, IB_NODE_VENDORID_F);
+ devid = (uint16_t) mad_get_field(data, 0, IB_NODE_DEVID_F);
+
+ if ((port_args[MKEY].set || port_args[MKEYLEASE].set ||
+ port_args[MKEYPROT].set) && is_switch && portnum != 0)
+ IBEXIT("Can't set M_Key fields on switch port != 0");
+
+ if (port_op != QUERY || changed)
+ printf("Initial %s PortInfo:\n", is_switch ? "Switch" : "CA/RT");
+ else
+ printf("%s PortInfo:\n", is_switch ? "Switch" : "CA/RT");
+ espeed_cap = get_port_info(&portid, data, portnum, is_switch);
+ show_port_info(&portid, data, portnum, espeed_cap, is_switch);
+ if (is_mlnx_ext_port_info_supported(vendorid, devid)) {
+ get_mlnx_ext_port_info(&portid, data2, portnum);
+ show_mlnx_ext_port_info(&portid, data2, portnum);
+ }
+
+ if (port_op != QUERY || changed) {
+ /*
+ * If we aren't setting the LID and the LID is the default,
+ * the SMA command will fail due to an invalid LID.
+ * Set it to something unlikely but valid.
+ */
+ physstate = mad_get_field(data, 0, IB_PORT_PHYS_STATE_F);
+
+ val = mad_get_field(data, 0, IB_PORT_LID_F);
+ if (!port_args[LID].set && (!val || val == 0xFFFF))
+ mad_set_field(data, 0, IB_PORT_LID_F, 0x1234);
+ val = mad_get_field(data, 0, IB_PORT_SMLID_F);
+ if (!port_args[SMLID].set && (!val || val == 0xFFFF))
+ mad_set_field(data, 0, IB_PORT_SMLID_F, 0x1234);
+ mad_set_field(data, 0, IB_PORT_STATE_F, 0); /* NOP */
+ mad_set_field(data, 0, IB_PORT_PHYS_STATE_F, 0); /* NOP */
+
+ switch (port_op) {
+ case ON:
+ /* Enable only if state is Disable */
+ if(physstate != 3) {
+ printf("Port is already in enable state\n");
+ goto close_port;
+ }
+ case ENABLE:
+ case RESET:
+ /* Polling */
+ mad_set_field(data, 0, IB_PORT_PHYS_STATE_F, 2);
+ break;
+ case OFF:
+ case DISABLE:
+ printf("Disable may be irreversible\n");
+ mad_set_field(data, 0, IB_PORT_PHYS_STATE_F, 3);
+ break;
+ case DOWN:
+ mad_set_field(data, 0, IB_PORT_STATE_F, 1);
+ break;
+ case ARM:
+ mad_set_field(data, 0, IB_PORT_STATE_F, 3);
+ break;
+ case ACTIVE:
+ mad_set_field(data, 0, IB_PORT_STATE_F, 4);
+ break;
+ }
+
+ /* always set enabled speeds/width - defaults to NOP */
+ mad_set_field(data, 0, IB_PORT_LINK_SPEED_ENABLED_F, speed);
+ mad_set_field(data, 0, IB_PORT_LINK_SPEED_EXT_ENABLED_F, espeed);
+ mad_set_field(data, 0, IB_PORT_LINK_WIDTH_ENABLED_F, width);
+
+ if (port_args[VLS].set)
+ mad_set_field(data, 0, IB_PORT_OPER_VLS_F, vls);
+ if (port_args[MTU].set)
+ mad_set_field(data, 0, IB_PORT_NEIGHBOR_MTU_F, mtu);
+ if (port_args[LID].set)
+ mad_set_field(data, 0, IB_PORT_LID_F, lid);
+ if (port_args[SMLID].set)
+ mad_set_field(data, 0, IB_PORT_SMLID_F, smlid);
+ if (port_args[LMC].set)
+ mad_set_field(data, 0, IB_PORT_LMC_F, lmc);
+
+ if (port_args[FDR10SPEED].set) {
+ mad_set_field(data2, 0,
+ IB_MLNX_EXT_PORT_STATE_CHG_ENABLE_F,
+ FDR10);
+ mad_set_field(data2, 0,
+ IB_MLNX_EXT_PORT_LINK_SPEED_ENABLED_F,
+ fdr10);
+ set_mlnx_ext_port_info(&portid, data2, portnum);
+ }
+
+ if (port_args[MKEY].set)
+ mad_set_field64(data, 0, IB_PORT_MKEY_F, mkey);
+ if (port_args[MKEYLEASE].set)
+ mad_set_field(data, 0, IB_PORT_MKEY_LEASE_F,
+ mkeylease);
+ if (port_args[MKEYPROT].set)
+ mad_set_field(data, 0, IB_PORT_MKEY_PROT_BITS_F,
+ mkeyprot);
+
+ set_port_info(&portid, data, portnum, espeed_cap, is_switch);
+
+ } else if (is_switch && portnum) {
+ /* Now, make sure PortState is Active */
+ /* Or is PortPhysicalState LinkUp sufficient ? */
+ mad_decode_field(data, IB_PORT_STATE_F, &state);
+ mad_decode_field(data, IB_PORT_PHYS_STATE_F, &physstate);
+ if (state == 4) { /* Active */
+ mad_decode_field(data, IB_PORT_LINK_WIDTH_ENABLED_F,
+ &lwe);
+ mad_decode_field(data, IB_PORT_LINK_WIDTH_SUPPORTED_F,
+ &lws);
+ mad_decode_field(data, IB_PORT_LINK_WIDTH_ACTIVE_F,
+ &lwa);
+ mad_decode_field(data, IB_PORT_LINK_SPEED_SUPPORTED_F,
+ &lss);
+ mad_decode_field(data, IB_PORT_LINK_SPEED_ACTIVE_F,
+ &lsa);
+ mad_decode_field(data, IB_PORT_LINK_SPEED_ENABLED_F,
+ &lse);
+ mad_decode_field(data2,
+ IB_MLNX_EXT_PORT_LINK_SPEED_SUPPORTED_F,
+ &fdr10s);
+ mad_decode_field(data2,
+ IB_MLNX_EXT_PORT_LINK_SPEED_ENABLED_F,
+ &fdr10e);
+ mad_decode_field(data2,
+ IB_MLNX_EXT_PORT_LINK_SPEED_ACTIVE_F,
+ &fdr10a);
+ if (espeed_cap) {
+ mad_decode_field(data,
+ IB_PORT_LINK_SPEED_EXT_SUPPORTED_F,
+ &lses);
+ mad_decode_field(data,
+ IB_PORT_LINK_SPEED_EXT_ACTIVE_F,
+ &lsea);
+ mad_decode_field(data,
+ IB_PORT_LINK_SPEED_EXT_ENABLED_F,
+ &lsee);
+ }
+
+ /* Setup portid for peer port */
+ memcpy(&peerportid, &portid, sizeof(peerportid));
+ if (portid.lid == 0) {
+ peerportid.drpath.cnt++;
+ if (peerportid.drpath.cnt == IB_SUBNET_PATH_HOPS_MAX) {
+ IBEXIT("Too many hops");
+ }
+ } else {
+ peerportid.drpath.cnt = 1;
+
+ /* Set DrSLID to local lid */
+ if (resolve_self(ibd_ca, ibd_ca_port, &selfportid,
+ &selfport, 0) < 0)
+ IBEXIT("could not resolve self");
+ peerportid.drpath.drslid = (uint16_t) selfportid.lid;
+ peerportid.drpath.drdlid = 0xffff;
+ }
+ peerportid.drpath.p[peerportid.drpath.cnt] = (uint8_t) portnum;
+
+ /* Get peer port NodeInfo to obtain peer port number */
+ is_peer_switch = get_node_info(&peerportid, data);
+ rem_vendorid = (uint32_t) mad_get_field(data, 0, IB_NODE_VENDORID_F);
+ rem_devid = (uint16_t) mad_get_field(data, 0, IB_NODE_DEVID_F);
+
+ mad_decode_field(data, IB_NODE_LOCAL_PORT_F,
+ &peerlocalportnum);
+
+ printf("Peer PortInfo:\n");
+ /* Get peer port characteristics */
+ peer_espeed_cap = get_port_info(&peerportid, data,
+ peerlocalportnum,
+ is_peer_switch);
+ if (is_mlnx_ext_port_info_supported(rem_vendorid, rem_devid))
+ get_mlnx_ext_port_info(&peerportid, data2,
+ peerlocalportnum);
+ show_port_info(&peerportid, data, peerlocalportnum,
+ peer_espeed_cap, is_peer_switch);
+ if (is_mlnx_ext_port_info_supported(rem_vendorid, rem_devid))
+ show_mlnx_ext_port_info(&peerportid, data2,
+ peerlocalportnum);
+
+ mad_decode_field(data, IB_PORT_LINK_WIDTH_ENABLED_F,
+ &peerlwe);
+ mad_decode_field(data, IB_PORT_LINK_WIDTH_SUPPORTED_F,
+ &peerlws);
+ mad_decode_field(data, IB_PORT_LINK_WIDTH_ACTIVE_F,
+ &peerlwa);
+ mad_decode_field(data, IB_PORT_LINK_SPEED_SUPPORTED_F,
+ &peerlss);
+ mad_decode_field(data, IB_PORT_LINK_SPEED_ACTIVE_F,
+ &peerlsa);
+ mad_decode_field(data, IB_PORT_LINK_SPEED_ENABLED_F,
+ &peerlse);
+ mad_decode_field(data2,
+ IB_MLNX_EXT_PORT_LINK_SPEED_SUPPORTED_F,
+ &peerfdr10s);
+ mad_decode_field(data2,
+ IB_MLNX_EXT_PORT_LINK_SPEED_ENABLED_F,
+ &peerfdr10e);
+ mad_decode_field(data2,
+ IB_MLNX_EXT_PORT_LINK_SPEED_ACTIVE_F,
+ &peerfdr10a);
+ if (peer_espeed_cap) {
+ mad_decode_field(data,
+ IB_PORT_LINK_SPEED_EXT_SUPPORTED_F,
+ &peerlses);
+ mad_decode_field(data,
+ IB_PORT_LINK_SPEED_EXT_ACTIVE_F,
+ &peerlsea);
+ mad_decode_field(data,
+ IB_PORT_LINK_SPEED_EXT_ENABLED_F,
+ &peerlsee);
+ }
+
+ /* Now validate peer port characteristics */
+ /* Examine Link Width */
+ width = get_link_width(lwe, lws);
+ peerwidth = get_link_width(peerlwe, peerlws);
+ validate_width(width, peerwidth, lwa);
+
+ /* Examine Link Speeds */
+ speed = get_link_speed(lse, lss);
+ peerspeed = get_link_speed(peerlse, peerlss);
+ validate_speed(speed, peerspeed, lsa);
+
+ if (espeed_cap && peer_espeed_cap) {
+ espeed = get_link_speed_ext(lsee, lses);
+ peerespeed = get_link_speed_ext(peerlsee,
+ peerlses);
+ validate_extended_speed(espeed, peerespeed,
+ lsea);
+ } else {
+ if (fdr10e & FDR10 && peerfdr10e & FDR10) {
+ if (!(fdr10a & FDR10))
+ IBWARN("Peer ports operating at active speed %d rather than FDR10", lsa);
+ }
+ }
+ }
+ }
+
+close_port:
+ mad_rpc_close_port(srcport);
+ exit(0);
+}
diff --git a/contrib/ofed/infiniband-diags/src/ibqueryerrors.c b/contrib/ofed/infiniband-diags/src/ibqueryerrors.c
new file mode 100644
index 0000000..2329f91
--- /dev/null
+++ b/contrib/ofed/infiniband-diags/src/ibqueryerrors.c
@@ -0,0 +1,1126 @@
+/*
+ * Copyright (c) 2004-2009 Voltaire Inc. All rights reserved.
+ * Copyright (c) 2007 Xsigo Systems Inc. All rights reserved.
+ * Copyright (c) 2008 Lawrence Livermore National Lab. All rights reserved.
+ * Copyright (c) 2009 HNR Consulting. All rights reserved.
+ * Copyright (c) 2010,2011 Mellanox Technologies LTD. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+#if HAVE_CONFIG_H
+# include <config.h>
+#endif /* HAVE_CONFIG_H */
+
+#define _GNU_SOURCE
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <stdarg.h>
+#include <time.h>
+#include <string.h>
+#include <getopt.h>
+#include <errno.h>
+#include <inttypes.h>
+
+#include <complib/cl_nodenamemap.h>
+#include <infiniband/ibnetdisc.h>
+#include <infiniband/mad.h>
+
+#include "ibdiag_common.h"
+#include "ibdiag_sa.h"
+
+struct ibmad_port *ibmad_port;
+static char *node_name_map_file = NULL;
+static nn_map_t *node_name_map = NULL;
+static char *load_cache_file = NULL;
+static uint16_t lid2sl_table[sizeof(uint8_t) * 1024 * 48] = { 0 };
+static int obtain_sl = 1;
+
+int data_counters = 0;
+int data_counters_only = 0;
+int port_config = 0;
+uint64_t port_guid = 0;
+char *port_guid_str = NULL;
+#define SUP_MAX 64
+int sup_total = 0;
+enum MAD_FIELDS suppressed_fields[SUP_MAX];
+char *dr_path = NULL;
+uint8_t node_type_to_print = 0;
+unsigned clear_errors = 0, clear_counts = 0, details = 0;
+
+#define PRINT_SWITCH 0x1
+#define PRINT_CA 0x2
+#define PRINT_ROUTER 0x4
+#define PRINT_ALL 0xFF /* all nodes default flag */
+
+#define DEFAULT_HALF_WORLD_PR_TIMEOUT (3000)
+
+struct {
+ int nodes_checked;
+ int bad_nodes;
+ int ports_checked;
+ int bad_ports;
+ int pma_query_failures;
+} summary = { 0 };
+
+#define DEF_THRES_FILE IBDIAG_CONFIG_PATH"/error_thresholds"
+static char *threshold_file = DEF_THRES_FILE;
+
+/* define a "packet" with threshold values in it */
+uint8_t thresholds[1204] = { 0 };
+char * threshold_str = "";
+
+static unsigned valid_gid(ib_gid_t * gid)
+{
+ ib_gid_t zero_gid;
+ memset(&zero_gid, 0, sizeof zero_gid);
+ return memcmp(&zero_gid, gid, sizeof(*gid));
+}
+
+static void set_thres(char *name, uint32_t val)
+{
+ int f;
+ int n;
+ char tmp[256];
+ for (f = IB_PC_FIRST_F; f <= IB_PC_LAST_F; f++) {
+ if (strcmp(name, mad_field_name(f)) == 0) {
+ mad_encode_field(thresholds, f, &val);
+ snprintf(tmp, 255, "[%s = %u]", name, val);
+ threshold_str = realloc(threshold_str,
+ strlen(threshold_str)+strlen(tmp)+1);
+ if (!threshold_str) {
+ fprintf(stderr, "Failed to allocate memory: "
+ "%s\n", strerror(errno));
+ exit(1);
+ }
+ n = strlen(threshold_str);
+ strcpy(threshold_str+n, tmp);
+ }
+ }
+}
+
+static void set_thresholds(char *threshold_file)
+{
+ char buf[1024];
+ int val = 0;
+ FILE *thresf = fopen(threshold_file, "r");
+ char *p_prefix, *p_last;
+ char *name;
+ char *val_str;
+ char str[64];
+
+ if (!thresf)
+ return;
+
+ snprintf(str, 63, "Thresholds: ");
+ threshold_str = malloc(strlen(str)+1);
+ if (!threshold_str) {
+ fprintf(stderr, "Failed to allocate memory: %s\n",
+ strerror(errno));
+ exit(1);
+ }
+ strcpy(threshold_str, str);
+ while (fgets(buf, sizeof buf, thresf) != NULL) {
+ p_prefix = strtok_r(buf, "\n", &p_last);
+ if (!p_prefix)
+ continue; /* ignore blank lines */
+
+ if (*p_prefix == '#')
+ continue; /* ignore comment lines */
+
+ name = strtok_r(p_prefix, "=", &p_last);
+ val_str = strtok_r(NULL, "\n", &p_last);
+
+ val = strtoul(val_str, NULL, 0);
+ set_thres(name, val);
+ }
+
+ fclose(thresf);
+}
+
+static int exceeds_threshold(int field, unsigned val)
+{
+ uint32_t thres = 0;
+ mad_decode_field(thresholds, field, &thres);
+ return (val > thres);
+}
+
+static void print_port_config(ibnd_node_t * node, int portnum)
+{
+ char width[64], speed[64], state[64], physstate[64];
+ char remote_str[256];
+ char link_str[256];
+ char width_msg[256];
+ char speed_msg[256];
+ char ext_port_str[256];
+ int iwidth, ispeed, fdr10, espeed, istate, iphystate, cap_mask;
+ uint8_t *info;
+
+ ibnd_port_t *port = node->ports[portnum];
+
+ if (!port)
+ return;
+
+ iwidth = mad_get_field(port->info, 0, IB_PORT_LINK_WIDTH_ACTIVE_F);
+ ispeed = mad_get_field(port->info, 0, IB_PORT_LINK_SPEED_ACTIVE_F);
+ fdr10 = mad_get_field(port->ext_info, 0,
+ IB_MLNX_EXT_PORT_LINK_SPEED_ACTIVE_F) & FDR10;
+
+ if (port->node->type == IB_NODE_SWITCH)
+ info = (uint8_t *)&port->node->ports[0]->info;
+ else
+ info = (uint8_t *)&port->info;
+ cap_mask = mad_get_field(info, 0, IB_PORT_CAPMASK_F);
+ if (cap_mask & CL_NTOH32(IB_PORT_CAP_HAS_EXT_SPEEDS))
+ espeed = mad_get_field(port->info, 0,
+ IB_PORT_LINK_SPEED_EXT_ACTIVE_F);
+ else
+ espeed = 0;
+ istate = mad_get_field(port->info, 0, IB_PORT_STATE_F);
+ iphystate = mad_get_field(port->info, 0, IB_PORT_PHYS_STATE_F);
+
+ remote_str[0] = '\0';
+ link_str[0] = '\0';
+ width_msg[0] = '\0';
+ speed_msg[0] = '\0';
+
+ /* C14-24.2.1 states that a down port allows for invalid data to be
+ * returned for all PortInfo components except PortState and
+ * PortPhysicalState */
+ if (istate != IB_LINK_DOWN) {
+ if (!espeed) {
+ if (fdr10)
+ sprintf(speed, "10.0 Gbps (FDR10)");
+ else
+ mad_dump_val(IB_PORT_LINK_SPEED_ACTIVE_F, speed,
+ 64, &ispeed);
+ } else
+ mad_dump_val(IB_PORT_LINK_SPEED_EXT_ACTIVE_F, speed,
+ 64, &espeed);
+
+ snprintf(link_str, 256, "(%3s %18s %6s/%8s)",
+ mad_dump_val(IB_PORT_LINK_WIDTH_ACTIVE_F, width, 64, &iwidth),
+ speed,
+ mad_dump_val(IB_PORT_STATE_F, state, 64, &istate),
+ mad_dump_val(IB_PORT_PHYS_STATE_F, physstate, 64, &iphystate));
+ } else {
+ snprintf(link_str, 256, "( %6s/%8s)",
+ mad_dump_val(IB_PORT_STATE_F, state, 64, &istate),
+ mad_dump_val(IB_PORT_PHYS_STATE_F, physstate, 64, &iphystate));
+ }
+
+ if (port->remoteport) {
+ char *rem_node_name = NULL;
+
+ if (port->remoteport->ext_portnum)
+ snprintf(ext_port_str, 256, "%d",
+ port->remoteport->ext_portnum);
+ else
+ ext_port_str[0] = '\0';
+
+ get_max_msg(width_msg, speed_msg, 256, port);
+
+ rem_node_name = remap_node_name(node_name_map,
+ port->remoteport->node->guid,
+ port->remoteport->node->
+ nodedesc);
+
+ snprintf(remote_str, 256,
+ "0x%016" PRIx64 " %6d %4d[%2s] \"%s\" (%s %s)\n",
+ port->remoteport->guid,
+ port->remoteport->base_lid ? port->remoteport->
+ base_lid : port->remoteport->node->smalid,
+ port->remoteport->portnum, ext_port_str, rem_node_name,
+ width_msg, speed_msg);
+
+ free(rem_node_name);
+ } else
+ snprintf(remote_str, 256, " [ ] \"\" ( )\n");
+
+ if (port->ext_portnum)
+ snprintf(ext_port_str, 256, "%d", port->ext_portnum);
+ else
+ ext_port_str[0] = '\0';
+
+ if (node->type == IB_NODE_SWITCH)
+ printf(" Link info: %6d", node->smalid);
+ else
+ printf(" Link info: %6d", port->base_lid);
+
+ printf("%4d[%2s] ==%s==> %s",
+ port->portnum, ext_port_str, link_str, remote_str);
+}
+
+static int suppress(enum MAD_FIELDS field)
+{
+ int i = 0;
+ for (i = 0; i < sup_total; i++)
+ if (field == suppressed_fields[i])
+ return 1;
+ return 0;
+}
+
+static void report_suppressed(void)
+{
+ int i = 0;
+ printf("## Suppressed:");
+ for (i = 0; i < sup_total; i++)
+ printf(" %s", mad_field_name(suppressed_fields[i]));
+ printf("\n");
+}
+
+static int print_summary(void)
+{
+ printf("\n## Summary: %d nodes checked, %d bad nodes found\n",
+ summary.nodes_checked, summary.bad_nodes);
+ printf("## %d ports checked, %d ports have errors beyond threshold\n",
+ summary.ports_checked, summary.bad_ports);
+ printf("## %s\n", threshold_str);
+ if (summary.pma_query_failures)
+ printf("## %d PMA query failures\n", summary.pma_query_failures);
+ report_suppressed();
+ return (summary.bad_ports);
+}
+
+static void insert_lid2sl_table(struct sa_query_result *r)
+{
+ unsigned int i;
+ for (i = 0; i < r->result_cnt; i++) {
+ ib_path_rec_t *p_pr = (ib_path_rec_t *)sa_get_query_rec(r->p_result_madw, i);
+ lid2sl_table[cl_ntoh16(p_pr->dlid)] = ib_path_rec_sl(p_pr);
+ }
+}
+
+static int path_record_query(ib_gid_t sgid,uint64_t dguid)
+{
+ ib_path_rec_t pr;
+ ib_net64_t comp_mask = 0;
+ uint8_t reversible = 0;
+ struct sa_handle * h;
+
+ if (!(h = sa_get_handle()))
+ return -1;
+
+ ibd_timeout = DEFAULT_HALF_WORLD_PR_TIMEOUT;
+ memset(&pr, 0, sizeof(pr));
+
+ CHECK_AND_SET_GID(sgid, pr.sgid, PR, SGID);
+ if(dguid) {
+ mad_encode_field(sgid.raw, IB_GID_GUID_F, &dguid);
+ CHECK_AND_SET_GID(sgid, pr.dgid, PR, DGID);
+ }
+
+ CHECK_AND_SET_VAL(1, 8, -1, pr.num_path, PR, NUMBPATH);/*to get only one PathRecord for each source and destination pair*/
+ CHECK_AND_SET_VAL(1, 8, -1, reversible, PR, REVERSIBLE);/*for a reversible path*/
+ pr.num_path |= reversible << 7;
+ struct sa_query_result result;
+ int ret = sa_query(h, IB_MAD_METHOD_GET_TABLE,
+ (uint16_t)IB_SA_ATTR_PATHRECORD,0,cl_ntoh64(comp_mask),ibd_sakey,
+ &pr, sizeof(pr), &result);
+ if (ret) {
+ sa_free_handle(h);
+ fprintf(stderr, "Query SA failed: %s; sa call path_query failed\n", strerror(ret));
+ return ret;
+ }
+ if (result.status != IB_SA_MAD_STATUS_SUCCESS) {
+ sa_report_err(result.status);
+ ret = EIO;
+ goto Exit;
+ }
+
+ insert_lid2sl_table(&result);
+Exit:
+ sa_free_handle(h);
+ sa_free_result_mad(&result);
+ return ret;
+}
+
+static int query_and_dump(char *buf, size_t size, ib_portid_t * portid,
+ char *node_name, int portnum,
+ const char *attr_name, uint16_t attr_id,
+ int start_field, int end_field)
+{
+ uint8_t pc[1024];
+ uint32_t val = 0;
+ int i, n;
+
+ memset(pc, 0, sizeof(pc));
+
+ if (!pma_query_via(pc, portid, portnum, ibd_timeout, attr_id,
+ ibmad_port)) {
+ IBWARN("%s query failed on %s, %s port %d", attr_name,
+ node_name, portid2str(portid), portnum);
+ summary.pma_query_failures++;
+ return 0;
+ }
+
+ for (n = 0, i = start_field; i < end_field; i++) {
+ mad_decode_field(pc, i, (void *)&val);
+ if (val)
+ n += snprintf(buf + n, size - n, " [%s == %u]",
+ mad_field_name(i), val);
+ }
+
+ return n;
+}
+
+
+static int print_results(ib_portid_t * portid, char *node_name,
+ ibnd_node_t * node, uint8_t * pc, int portnum,
+ int *header_printed, uint8_t *pce, uint16_t cap_mask)
+{
+ char buf[1024];
+ char *str = buf;
+ uint32_t val = 0;
+ int i, n;
+
+ for (n = 0, i = IB_PC_ERR_SYM_F; i <= IB_PC_VL15_DROPPED_F; i++) {
+ if (suppress(i))
+ continue;
+
+ /* this is not a counter, skip it */
+ if (i == IB_PC_COUNTER_SELECT2_F)
+ continue;
+
+ mad_decode_field(pc, i, (void *)&val);
+ if (exceeds_threshold(i, val)) {
+ n += snprintf(str + n, 1024 - n, " [%s == %u]",
+ mad_field_name(i), val);
+
+ /* If there are PortXmitDiscards, get details (if supported) */
+ if (i == IB_PC_XMT_DISCARDS_F && details) {
+ n += query_and_dump(str + n, sizeof(buf) - n, portid,
+ node_name, portnum,
+ "PortXmitDiscardDetails",
+ IB_GSI_PORT_XMIT_DISCARD_DETAILS,
+ IB_PC_RCV_LOCAL_PHY_ERR_F,
+ IB_PC_RCV_ERR_LAST_F);
+ /* If there are PortRcvErrors, get details (if supported) */
+ } else if (i == IB_PC_ERR_RCV_F && details) {
+ n += query_and_dump(str + n, sizeof(buf) - n, portid,
+ node_name, portnum,
+ "PortRcvErrorDetails",
+ IB_GSI_PORT_RCV_ERROR_DETAILS,
+ IB_PC_XMT_INACT_DISC_F,
+ IB_PC_XMT_DISC_LAST_F);
+ }
+ }
+ }
+
+ if (!suppress(IB_PC_XMT_WAIT_F)) {
+ mad_decode_field(pc, IB_PC_XMT_WAIT_F, (void *)&val);
+ if (exceeds_threshold(IB_PC_XMT_WAIT_F, val))
+ n += snprintf(str + n, 1024 - n, " [%s == %u]",
+ mad_field_name(IB_PC_XMT_WAIT_F), val);
+ }
+
+ /* if we found errors. */
+ if (n != 0) {
+ if (data_counters) {
+ uint8_t *pkt = pc;
+ int start_field = IB_PC_XMT_BYTES_F;
+ int end_field = IB_PC_RCV_PKTS_F;
+
+ if (pce) {
+ pkt = pce;
+ start_field = IB_PC_EXT_XMT_BYTES_F;
+ if (cap_mask & IB_PM_EXT_WIDTH_SUPPORTED)
+ end_field = IB_PC_EXT_RCV_MPKTS_F;
+ else
+ end_field = IB_PC_EXT_RCV_PKTS_F;
+ }
+
+ for (i = start_field; i <= end_field; i++) {
+ uint64_t val64 = 0;
+ float val = 0;
+ char *unit = "";
+ mad_decode_field(pkt, i, (void *)&val64);
+ if (val64) {
+ int data = 0;
+ if (i == IB_PC_EXT_XMT_BYTES_F ||
+ i == IB_PC_EXT_RCV_BYTES_F ||
+ i == IB_PC_XMT_BYTES_F ||
+ i == IB_PC_RCV_BYTES_F)
+ data = 1;
+ unit = conv_cnt_human_readable(val64,
+ &val, data);
+ n += snprintf(str + n, 1024 - n,
+ " [%s == %" PRIu64
+ " (%5.3f%s)]",
+ mad_field_name(i), val64, val,
+ unit);
+ }
+ }
+ }
+
+ if (!*header_printed) {
+ if (node->type == IB_NODE_SWITCH)
+ printf("Errors for 0x%" PRIx64 " \"%s\"\n",
+ node->ports[0]->guid, node_name);
+ else
+ printf("Errors for \"%s\"\n", node_name);
+ *header_printed = 1;
+ summary.bad_nodes++;
+ }
+
+ if (portnum == 0xFF) {
+ if (node->type == IB_NODE_SWITCH)
+ printf(" GUID 0x%" PRIx64 " port ALL:%s\n",
+ node->ports[0]->guid, str);
+ } else {
+ printf(" GUID 0x%" PRIx64 " port %d:%s\n",
+ node->ports[portnum]->guid, portnum, str);
+ if (port_config)
+ print_port_config(node, portnum);
+ summary.bad_ports++;
+ }
+ }
+ return (n);
+}
+
+static int query_cap_mask(ib_portid_t * portid, char *node_name, int portnum,
+ uint16_t * cap_mask)
+{
+ uint8_t pc[1024] = { 0 };
+ uint16_t rc_cap_mask;
+
+ portid->sl = lid2sl_table[portid->lid];
+
+ /* PerfMgt ClassPortInfo is a required attribute */
+ if (!pma_query_via(pc, portid, portnum, ibd_timeout, CLASS_PORT_INFO,
+ ibmad_port)) {
+ IBWARN("classportinfo query failed on %s, %s port %d",
+ node_name, portid2str(portid), portnum);
+ summary.pma_query_failures++;
+ return -1;
+ }
+
+ /* ClassPortInfo should be supported as part of libibmad */
+ memcpy(&rc_cap_mask, pc + 2, sizeof(rc_cap_mask)); /* CapabilityMask */
+
+ *cap_mask = rc_cap_mask;
+ return 0;
+}
+
+static int print_data_cnts(ib_portid_t * portid, uint16_t cap_mask,
+ char *node_name, ibnd_node_t * node, int portnum,
+ int *header_printed)
+{
+ uint8_t pc[1024];
+ int i;
+ int start_field = IB_PC_XMT_BYTES_F;
+ int end_field = IB_PC_RCV_PKTS_F;
+
+ memset(pc, 0, 1024);
+
+ portid->sl = lid2sl_table[portid->lid];
+
+ if (cap_mask & (IB_PM_EXT_WIDTH_SUPPORTED | IB_PM_EXT_WIDTH_NOIETF_SUP)) {
+ if (!pma_query_via(pc, portid, portnum, ibd_timeout,
+ IB_GSI_PORT_COUNTERS_EXT, ibmad_port)) {
+ IBWARN("IB_GSI_PORT_COUNTERS_EXT query failed on %s, %s port %d",
+ node_name, portid2str(portid), portnum);
+ summary.pma_query_failures++;
+ return (1);
+ }
+ start_field = IB_PC_EXT_XMT_BYTES_F;
+ if (cap_mask & IB_PM_EXT_WIDTH_SUPPORTED)
+ end_field = IB_PC_EXT_RCV_MPKTS_F;
+ else
+ end_field = IB_PC_EXT_RCV_PKTS_F;
+ } else {
+ if (!pma_query_via(pc, portid, portnum, ibd_timeout,
+ IB_GSI_PORT_COUNTERS, ibmad_port)) {
+ IBWARN("IB_GSI_PORT_COUNTERS query failed on %s, %s port %d",
+ node_name, portid2str(portid), portnum);
+ summary.pma_query_failures++;
+ return (1);
+ }
+ start_field = IB_PC_XMT_BYTES_F;
+ end_field = IB_PC_RCV_PKTS_F;
+ }
+
+ if (!*header_printed) {
+ printf("Data Counters for 0x%" PRIx64 " \"%s\"\n", node->guid,
+ node_name);
+ *header_printed = 1;
+ }
+
+ if (portnum == 0xFF)
+ printf(" GUID 0x%" PRIx64 " port ALL:", node->guid);
+ else
+ printf(" GUID 0x%" PRIx64 " port %d:",
+ node->guid, portnum);
+
+ for (i = start_field; i <= end_field; i++) {
+ uint64_t val64 = 0;
+ float val = 0;
+ char *unit = "";
+ int data = 0;
+ mad_decode_field(pc, i, (void *)&val64);
+ if (i == IB_PC_EXT_XMT_BYTES_F || i == IB_PC_EXT_RCV_BYTES_F ||
+ i == IB_PC_XMT_BYTES_F || i == IB_PC_RCV_BYTES_F)
+ data = 1;
+ unit = conv_cnt_human_readable(val64, &val, data);
+ printf(" [%s == %" PRIu64 " (%5.3f%s)]", mad_field_name(i),
+ val64, val, unit);
+ }
+ printf("\n");
+
+ if (portnum != 0xFF && port_config)
+ print_port_config(node, portnum);
+
+ return (0);
+}
+
+static int print_errors(ib_portid_t * portid, uint16_t cap_mask,
+ char *node_name, ibnd_node_t * node, int portnum,
+ int *header_printed)
+{
+ uint8_t pc[1024];
+ uint8_t pce[1024];
+ uint8_t *pc_ext = NULL;
+
+ memset(pc, 0, 1024);
+ memset(pce, 0, 1024);
+
+ portid->sl = lid2sl_table[portid->lid];
+
+ if (!pma_query_via(pc, portid, portnum, ibd_timeout,
+ IB_GSI_PORT_COUNTERS, ibmad_port)) {
+ IBWARN("IB_GSI_PORT_COUNTERS query failed on %s, %s port %d",
+ node_name, portid2str(portid), portnum);
+ summary.pma_query_failures++;
+ return (0);
+ }
+
+ if (cap_mask & (IB_PM_EXT_WIDTH_SUPPORTED | IB_PM_EXT_WIDTH_NOIETF_SUP)) {
+ if (!pma_query_via(pce, portid, portnum, ibd_timeout,
+ IB_GSI_PORT_COUNTERS_EXT, ibmad_port)) {
+ IBWARN("IB_GSI_PORT_COUNTERS_EXT query failed on %s, %s port %d",
+ node_name, portid2str(portid), portnum);
+ summary.pma_query_failures++;
+ return (0);
+ }
+ pc_ext = pce;
+ }
+
+ if (!(cap_mask & IB_PM_PC_XMIT_WAIT_SUP)) {
+ /* if PortCounters:PortXmitWait not supported clear this counter */
+ uint32_t foo = 0;
+ mad_encode_field(pc, IB_PC_XMT_WAIT_F, &foo);
+ }
+ return (print_results(portid, node_name, node, pc, portnum,
+ header_printed, pc_ext, cap_mask));
+}
+
+uint8_t *reset_pc_ext(void *rcvbuf, ib_portid_t * dest,
+ int port, unsigned mask, unsigned timeout,
+ const struct ibmad_port * srcport)
+{
+ ib_rpc_t rpc = { 0 };
+ int lid = dest->lid;
+
+ DEBUG("lid %u port %d mask 0x%x", lid, port, mask);
+
+ if (lid == -1) {
+ IBWARN("only lid routed is supported");
+ return NULL;
+ }
+
+ if (!mask)
+ mask = ~0;
+
+ rpc.mgtclass = IB_PERFORMANCE_CLASS;
+ rpc.method = IB_MAD_METHOD_SET;
+ rpc.attr.id = IB_GSI_PORT_COUNTERS_EXT;
+
+ memset(rcvbuf, 0, IB_MAD_SIZE);
+
+ /* Same for attribute IDs */
+ mad_set_field(rcvbuf, 0, IB_PC_EXT_PORT_SELECT_F, port);
+ mad_set_field(rcvbuf, 0, IB_PC_EXT_COUNTER_SELECT_F, mask);
+ rpc.attr.mod = 0;
+ rpc.timeout = timeout;
+ rpc.datasz = IB_PC_DATA_SZ;
+ rpc.dataoffs = IB_PC_DATA_OFFS;
+ if (!dest->qp)
+ dest->qp = 1;
+ if (!dest->qkey)
+ dest->qkey = IB_DEFAULT_QP1_QKEY;
+
+ return mad_rpc(srcport, &rpc, dest, rcvbuf, rcvbuf);
+}
+
+static void clear_port(ib_portid_t * portid, uint16_t cap_mask,
+ char *node_name, int port)
+{
+ uint8_t pc[1024] = { 0 };
+ /* bits defined in Table 228 PortCounters CounterSelect and
+ * CounterSelect2
+ */
+ uint32_t mask = 0;
+
+ if (clear_errors) {
+ mask |= 0xFFF;
+ if (cap_mask & IB_PM_PC_XMIT_WAIT_SUP)
+ mask |= 0x10000;
+ }
+ if (clear_counts)
+ mask |= 0xF000;
+
+ if (mask)
+ if (!performance_reset_via(pc, portid, port, mask, ibd_timeout,
+ IB_GSI_PORT_COUNTERS, ibmad_port))
+ fprintf(stderr, "Failed to reset errors %s port %d\n", node_name,
+ port);
+
+ if (clear_errors && details) {
+ memset(pc, 0, 1024);
+ performance_reset_via(pc, portid, port, 0xf, ibd_timeout,
+ IB_GSI_PORT_XMIT_DISCARD_DETAILS,
+ ibmad_port);
+ memset(pc, 0, 1024);
+ performance_reset_via(pc, portid, port, 0x3f, ibd_timeout,
+ IB_GSI_PORT_RCV_ERROR_DETAILS,
+ ibmad_port);
+ }
+
+ if (clear_counts &&
+ (cap_mask &
+ (IB_PM_EXT_WIDTH_SUPPORTED | IB_PM_EXT_WIDTH_NOIETF_SUP))) {
+ if (cap_mask & IB_PM_EXT_WIDTH_SUPPORTED)
+ mask = 0xFF;
+ else
+ mask = 0x0F;
+
+ if (!reset_pc_ext(pc, portid, port, mask, ibd_timeout,
+ ibmad_port))
+ fprintf(stderr, "Failed to reset extended data counters %s, "
+ "%s port %d\n", node_name, portid2str(portid),
+ port);
+ }
+}
+
+void print_node(ibnd_node_t * node, void *user_data)
+{
+ int header_printed = 0;
+ int p = 0;
+ int startport = 1;
+ int type = 0;
+ int all_port_sup = 0;
+ ib_portid_t portid = { 0 };
+ uint16_t cap_mask = 0;
+ char *node_name = NULL;
+
+ switch (node->type) {
+ case IB_NODE_SWITCH:
+ type = PRINT_SWITCH;
+ break;
+ case IB_NODE_CA:
+ type = PRINT_CA;
+ break;
+ case IB_NODE_ROUTER:
+ type = PRINT_ROUTER;
+ break;
+ }
+
+ if ((type & node_type_to_print) == 0)
+ return;
+
+ if (node->type == IB_NODE_SWITCH && node->smaenhsp0)
+ startport = 0;
+
+ node_name = remap_node_name(node_name_map, node->guid, node->nodedesc);
+
+ if (node->type == IB_NODE_SWITCH) {
+ ib_portid_set(&portid, node->smalid, 0, 0);
+ p = 0;
+ } else {
+ for (p = 1; p <= node->numports; p++) {
+ if (node->ports[p]) {
+ ib_portid_set(&portid,
+ node->ports[p]->base_lid,
+ 0, 0);
+ break;
+ }
+ }
+ }
+
+ if ((query_cap_mask(&portid, node_name, p, &cap_mask) == 0) &&
+ (cap_mask & IB_PM_ALL_PORT_SELECT))
+ all_port_sup = 1;
+
+ if (data_counters_only) {
+ for (p = startport; p <= node->numports; p++) {
+ if (node->ports[p]) {
+ if (node->type == IB_NODE_SWITCH)
+ ib_portid_set(&portid, node->smalid, 0, 0);
+ else
+ ib_portid_set(&portid, node->ports[p]->base_lid,
+ 0, 0);
+
+ print_data_cnts(&portid, cap_mask, node_name, node, p,
+ &header_printed);
+ summary.ports_checked++;
+ if (!all_port_sup)
+ clear_port(&portid, cap_mask, node_name, p);
+ }
+ }
+ } else {
+ if (all_port_sup)
+ if (!print_errors(&portid, cap_mask, node_name, node,
+ 0xFF, &header_printed)) {
+ summary.ports_checked += node->numports;
+ goto clear;
+ }
+
+ for (p = startport; p <= node->numports; p++) {
+ if (node->ports[p]) {
+ if (node->type == IB_NODE_SWITCH)
+ ib_portid_set(&portid, node->smalid, 0, 0);
+ else
+ ib_portid_set(&portid, node->ports[p]->base_lid,
+ 0, 0);
+
+ print_errors(&portid, cap_mask, node_name, node, p,
+ &header_printed);
+ summary.ports_checked++;
+ if (!all_port_sup)
+ clear_port(&portid, cap_mask, node_name, p);
+ }
+ }
+ }
+
+clear:
+ summary.nodes_checked++;
+ if (all_port_sup)
+ clear_port(&portid, cap_mask, node_name, 0xFF);
+
+ free(node_name);
+}
+
+static void add_suppressed(enum MAD_FIELDS field)
+{
+ if (sup_total >= SUP_MAX) {
+ IBWARN("Maximum (%d) fields have been suppressed; skipping %s",
+ sup_total, mad_field_name(field));
+ return;
+ }
+ suppressed_fields[sup_total++] = field;
+}
+
+static void calculate_suppressed_fields(char *str)
+{
+ enum MAD_FIELDS f;
+ char *val, *lasts = NULL;
+ char *tmp = strdup(str);
+
+ val = strtok_r(tmp, ",", &lasts);
+ while (val) {
+ for (f = IB_PC_FIRST_F; f <= IB_PC_LAST_F; f++)
+ if (strcmp(val, mad_field_name(f)) == 0)
+ add_suppressed(f);
+ val = strtok_r(NULL, ",", &lasts);
+ }
+
+ free(tmp);
+}
+
+static int process_opt(void *context, int ch, char *optarg)
+{
+ struct ibnd_config *cfg = context;
+ switch (ch) {
+ case 's':
+ calculate_suppressed_fields(optarg);
+ break;
+ case 'c':
+ /* Right now this is the only "common" error */
+ add_suppressed(IB_PC_ERR_SWITCH_REL_F);
+ break;
+ case 1:
+ node_name_map_file = strdup(optarg);
+ break;
+ case 2:
+ data_counters++;
+ break;
+ case 3:
+ node_type_to_print |= PRINT_SWITCH;
+ break;
+ case 4:
+ node_type_to_print |= PRINT_CA;
+ break;
+ case 5:
+ node_type_to_print |= PRINT_ROUTER;
+ break;
+ case 6:
+ details = 1;
+ break;
+ case 7:
+ load_cache_file = strdup(optarg);
+ break;
+ case 8:
+ threshold_file = strdup(optarg);
+ break;
+ case 9:
+ data_counters_only = 1;
+ break;
+ case 10:
+ obtain_sl = 0;
+ break;
+ case 'G':
+ case 'S':
+ port_guid_str = optarg;
+ port_guid = strtoull(optarg, 0, 0);
+ break;
+ case 'D':
+ dr_path = strdup(optarg);
+ break;
+ case 'r':
+ port_config++;
+ break;
+ case 'R': /* nop */
+ break;
+ case 'k':
+ clear_errors = 1;
+ break;
+ case 'K':
+ clear_counts = 1;
+ break;
+ case 'o':
+ cfg->max_smps = strtoul(optarg, NULL, 0);
+ break;
+ default:
+ return -1;
+ }
+
+ return 0;
+}
+
+int main(int argc, char **argv)
+{
+ struct ibnd_config config = { 0 };
+ int resolved = -1;
+ ib_portid_t portid = { 0 };
+ ib_portid_t self_portid = { 0 };
+ int rc = 0;
+ ibnd_fabric_t *fabric = NULL;
+ ib_gid_t self_gid;
+ int port = 0;
+
+ int mgmt_classes[4] = { IB_SMI_CLASS, IB_SMI_DIRECT_CLASS, IB_SA_CLASS,
+ IB_PERFORMANCE_CLASS
+ };
+
+ const struct ibdiag_opt opts[] = {
+ {"suppress", 's', 1, "<err1,err2,...>",
+ "suppress errors listed"},
+ {"suppress-common", 'c', 0, NULL,
+ "suppress some of the common counters"},
+ {"node-name-map", 1, 1, "<file>", "node name map file"},
+ {"port-guid", 'G', 1, "<port_guid>",
+ "report the node containing the port specified by <port_guid>"},
+ {"", 'S', 1, "<port_guid>",
+ "Same as \"-G\" for backward compatibility"},
+ {"Direct", 'D', 1, "<dr_path>",
+ "report the node containing the port specified by <dr_path>"},
+ {"skip-sl", 10, 0, NULL,"don't obtain SL to all destinations"},
+ {"report-port", 'r', 0, NULL,
+ "report port link information"},
+ {"threshold-file", 8, 1, NULL,
+ "specify an alternate threshold file, default: " DEF_THRES_FILE},
+ {"GNDN", 'R', 0, NULL,
+ "(This option is obsolete and does nothing)"},
+ {"data", 2, 0, NULL, "include data counters for ports with errors"},
+ {"switch", 3, 0, NULL, "print data for switches only"},
+ {"ca", 4, 0, NULL, "print data for CA's only"},
+ {"router", 5, 0, NULL, "print data for routers only"},
+ {"details", 6, 0, NULL, "include transmit discard details"},
+ {"counters", 9, 0, NULL, "print data counters only"},
+ {"clear-errors", 'k', 0, NULL,
+ "Clear error counters after read"},
+ {"clear-counts", 'K', 0, NULL,
+ "Clear data counters after read"},
+ {"load-cache", 7, 1, "<file>",
+ "filename of ibnetdiscover cache to load"},
+ {"outstanding_smps", 'o', 1, NULL,
+ "specify the number of outstanding SMP's which should be "
+ "issued during the scan"},
+ {0}
+ };
+ char usage_args[] = "";
+
+ memset(suppressed_fields, 0, sizeof suppressed_fields);
+ ibdiag_process_opts(argc, argv, &config, "cDGKLnRrSs", opts, process_opt,
+ usage_args, NULL);
+
+ argc -= optind;
+ argv += optind;
+
+ if (!node_type_to_print)
+ node_type_to_print = PRINT_ALL;
+
+ ibmad_port = mad_rpc_open_port(ibd_ca, ibd_ca_port, mgmt_classes, 4);
+ if (!ibmad_port)
+ IBEXIT("Failed to open port; %s:%d\n", ibd_ca, ibd_ca_port);
+
+ smp_mkey_set(ibmad_port, ibd_mkey);
+
+ if (ibd_timeout) {
+ mad_rpc_set_timeout(ibmad_port, ibd_timeout);
+ config.timeout_ms = ibd_timeout;
+ }
+
+ config.flags = ibd_ibnetdisc_flags;
+ config.mkey = ibd_mkey;
+
+ if (dr_path && load_cache_file) {
+ mad_rpc_close_port(ibmad_port);
+ fprintf(stderr, "Cannot specify cache and direct route path\n");
+ exit(-1);
+ }
+
+ if (resolve_self(ibd_ca, ibd_ca_port, &self_portid, &port, &self_gid.raw) < 0) {
+ mad_rpc_close_port(ibmad_port);
+ IBEXIT("can't resolve self port %s", argv[0]);
+ }
+
+ node_name_map = open_node_name_map(node_name_map_file);
+
+ /* limit the scan the fabric around the target */
+ if (dr_path) {
+ if ((resolved =
+ resolve_portid_str(ibd_ca, ibd_ca_port, &portid, dr_path,
+ IB_DEST_DRPATH, NULL, ibmad_port)) < 0)
+ IBWARN("Failed to resolve %s; attempting full scan",
+ dr_path);
+ } else if (port_guid_str) {
+ if ((resolved =
+ resolve_portid_str(ibd_ca, ibd_ca_port, &portid,
+ port_guid_str, IB_DEST_GUID, ibd_sm_id,
+ ibmad_port)) < 0)
+ IBWARN("Failed to resolve %s; attempting full scan",
+ port_guid_str);
+ if(obtain_sl)
+ lid2sl_table[portid.lid] = portid.sl;
+ }
+
+ mad_rpc_close_port(ibmad_port);
+
+ if (load_cache_file) {
+ if ((fabric = ibnd_load_fabric(load_cache_file, 0)) == NULL) {
+ fprintf(stderr, "loading cached fabric failed\n");
+ rc = -1;
+ goto close_port;
+ }
+ } else {
+ if (resolved >= 0) {
+ if (!config.max_hops)
+ config.max_hops = 1;
+ if (!(fabric = ibnd_discover_fabric(ibd_ca, ibd_ca_port,
+ &portid, &config)))
+ IBWARN("Single node discover failed;"
+ " attempting full scan");
+ }
+
+ if (!fabric && !(fabric = ibnd_discover_fabric(ibd_ca,
+ ibd_ca_port,
+ NULL,
+ &config))) {
+ fprintf(stderr, "discover failed\n");
+ rc = -1;
+ goto close_port;
+ }
+ }
+
+ set_thresholds(threshold_file);
+
+ /* reopen the global ibmad_port */
+ ibmad_port = mad_rpc_open_port(ibd_ca, ibd_ca_port,
+ mgmt_classes, 4);
+ if (!ibmad_port) {
+ ibnd_destroy_fabric(fabric);
+ close_node_name_map(node_name_map);
+ IBEXIT("Failed to reopen port: %s:%d\n",
+ ibd_ca, ibd_ca_port);
+ }
+
+ smp_mkey_set(ibmad_port, ibd_mkey);
+
+ if (ibd_timeout)
+ mad_rpc_set_timeout(ibmad_port, ibd_timeout);
+
+ if (port_guid_str) {
+ ibnd_port_t *port = ibnd_find_port_guid(fabric, port_guid);
+ if (port)
+ print_node(port->node, NULL);
+ else
+ fprintf(stderr, "Failed to find node: %s\n",
+ port_guid_str);
+ } else if (dr_path) {
+ ibnd_port_t *port;
+ uint8_t ni[IB_SMP_DATA_SIZE] = { 0 };
+ if (!smp_query_via(ni, &portid, IB_ATTR_NODE_INFO, 0,
+ ibd_timeout, ibmad_port)) {
+ fprintf(stderr, "Failed to query local Node Info\n");
+ goto destroy_fabric;
+ }
+
+ mad_decode_field(ni, IB_NODE_PORT_GUID_F, &(port_guid));
+
+ port = ibnd_find_port_guid(fabric, port_guid);
+ if (port) {
+ if(obtain_sl)
+ if(path_record_query(self_gid,port->guid))
+ goto destroy_fabric;
+ print_node(port->node, NULL);
+ } else
+ fprintf(stderr, "Failed to find node: %s\n", dr_path);
+ } else {
+ if(obtain_sl)
+ if(path_record_query(self_gid,0))
+ goto destroy_fabric;
+
+ ibnd_iter_nodes(fabric, print_node, NULL);
+ }
+
+ rc = print_summary();
+ if (rc)
+ rc = 1;
+
+destroy_fabric:
+ mad_rpc_close_port(ibmad_port);
+ ibnd_destroy_fabric(fabric);
+
+close_port:
+ close_node_name_map(node_name_map);
+ exit(rc);
+}
diff --git a/contrib/ofed/infiniband-diags/src/ibroute.c b/contrib/ofed/infiniband-diags/src/ibroute.c
new file mode 100644
index 0000000..8e4544e
--- /dev/null
+++ b/contrib/ofed/infiniband-diags/src/ibroute.c
@@ -0,0 +1,488 @@
+/*
+ * Copyright (c) 2004-2009 Voltaire Inc. All rights reserved.
+ * Copyright (c) 2009-2011 Mellanox Technologies LTD. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+#if HAVE_CONFIG_H
+# include <config.h>
+#endif /* HAVE_CONFIG_H */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <string.h>
+#include <inttypes.h>
+#include <getopt.h>
+#include <netinet/in.h>
+
+#include <infiniband/umad.h>
+#include <infiniband/mad.h>
+#include <complib/cl_nodenamemap.h>
+
+#include "ibdiag_common.h"
+
+struct ibmad_port *srcport;
+
+static int brief, dump_all, multicast;
+
+static char *node_name_map_file = NULL;
+static nn_map_t *node_name_map = NULL;
+
+/*******************************************/
+
+char *check_switch(ib_portid_t * portid, unsigned int *nports, uint64_t * guid,
+ uint8_t * sw, char *nd)
+{
+ uint8_t ni[IB_SMP_DATA_SIZE] = { 0 };
+ int type;
+
+ DEBUG("checking node type");
+ if (!smp_query_via(ni, portid, IB_ATTR_NODE_INFO, 0, 0, srcport)) {
+ xdump(stderr, "nodeinfo\n", ni, sizeof ni);
+ return "node info failed: valid addr?";
+ }
+
+ if (!smp_query_via(nd, portid, IB_ATTR_NODE_DESC, 0, 0, srcport))
+ return "node desc failed";
+
+ mad_decode_field(ni, IB_NODE_TYPE_F, &type);
+ if (type != IB_NODE_SWITCH)
+ return "not a switch";
+
+ DEBUG("Gathering information about switch");
+ mad_decode_field(ni, IB_NODE_NPORTS_F, nports);
+ mad_decode_field(ni, IB_NODE_GUID_F, guid);
+
+ if (!smp_query_via(sw, portid, IB_ATTR_SWITCH_INFO, 0, 0, srcport))
+ return "switch info failed: is a switch node?";
+
+ return 0;
+}
+
+#define IB_MLIDS_IN_BLOCK (IB_SMP_DATA_SIZE/2)
+
+int dump_mlid(char *str, int strlen, unsigned mlid, unsigned nports,
+ uint16_t mft[16][IB_MLIDS_IN_BLOCK])
+{
+ uint16_t mask;
+ unsigned i, chunk, bit, nonzero = 0;
+
+ if (brief) {
+ int n = 0;
+ unsigned chunks = ALIGN(nports + 1, 16) / 16;
+ for (i = 0; i < chunks; i++) {
+ mask = ntohs(mft[i][mlid % IB_MLIDS_IN_BLOCK]);
+ if (mask)
+ nonzero++;
+ n += snprintf(str + n, strlen - n, "%04hx", mask);
+ if (n >= strlen) {
+ n = strlen;
+ break;
+ }
+ }
+ if (!nonzero && !dump_all) {
+ str[0] = 0;
+ return 0;
+ }
+ return n;
+ }
+ for (i = 0; i <= nports; i++) {
+ chunk = i / 16;
+ bit = i % 16;
+
+ mask = ntohs(mft[chunk][mlid % IB_MLIDS_IN_BLOCK]);
+ if (mask)
+ nonzero++;
+ str[i * 2] = (mask & (1 << bit)) ? 'x' : ' ';
+ str[i * 2 + 1] = ' ';
+ }
+ if (!nonzero && !dump_all) {
+ str[0] = 0;
+ return 0;
+ }
+ str[i * 2] = 0;
+ return i * 2;
+}
+
+uint16_t mft[16][IB_MLIDS_IN_BLOCK] = { { 0 }, { 0 }, { 0 }, { 0 }, { 0 }, { 0 }, { 0 }, { 0 }, { 0 }, { 0 }, { 0 }, { 0 }, { 0 }, { 0}, { 0 }, { 0 } };
+
+char *dump_multicast_tables(ib_portid_t * portid, unsigned startlid,
+ unsigned endlid)
+{
+ char nd[IB_SMP_DATA_SIZE] = { 0 };
+ uint8_t sw[IB_SMP_DATA_SIZE] = { 0 };
+ char str[512];
+ char *s;
+ uint64_t nodeguid;
+ uint32_t mod;
+ unsigned block, i, j, e, nports, cap, chunks, startblock, lastblock,
+ top;
+ char *mapnd = NULL;
+ int n = 0;
+
+ if ((s = check_switch(portid, &nports, &nodeguid, sw, nd)))
+ return s;
+
+ mad_decode_field(sw, IB_SW_MCAST_FDB_CAP_F, &cap);
+ mad_decode_field(sw, IB_SW_MCAST_FDB_TOP_F, &top);
+
+ if (!endlid || endlid > IB_MIN_MCAST_LID + cap - 1)
+ endlid = IB_MIN_MCAST_LID + cap - 1;
+ if (!dump_all && top && top < endlid) {
+ if (top < IB_MIN_MCAST_LID - 1)
+ IBWARN("illegal top mlid %x", top);
+ else
+ endlid = top;
+ }
+
+ if (!startlid)
+ startlid = IB_MIN_MCAST_LID;
+ else if (startlid < IB_MIN_MCAST_LID) {
+ IBWARN("illegal start mlid %x, set to %x", startlid,
+ IB_MIN_MCAST_LID);
+ startlid = IB_MIN_MCAST_LID;
+ }
+
+ if (endlid > IB_MAX_MCAST_LID) {
+ IBWARN("illegal end mlid %x, truncate to %x", endlid,
+ IB_MAX_MCAST_LID);
+ endlid = IB_MAX_MCAST_LID;
+ }
+
+ mapnd = remap_node_name(node_name_map, nodeguid, nd);
+
+ printf("Multicast mlids [0x%x-0x%x] of switch %s guid 0x%016" PRIx64
+ " (%s):\n", startlid, endlid, portid2str(portid), nodeguid,
+ mapnd);
+
+ if (brief)
+ printf(" MLid Port Mask\n");
+ else {
+ if (nports > 9) {
+ for (i = 0, s = str; i <= nports; i++) {
+ *s++ = (i % 10) ? ' ' : '0' + i / 10;
+ *s++ = ' ';
+ }
+ *s = 0;
+ printf(" %s\n", str);
+ }
+ for (i = 0, s = str; i <= nports; i++)
+ s += sprintf(s, "%d ", i % 10);
+ printf(" Ports: %s\n", str);
+ printf(" MLid\n");
+ }
+ if (ibverbose)
+ printf("Switch multicast mlid capability is %d top is 0x%x\n",
+ cap, top);
+
+ chunks = ALIGN(nports + 1, 16) / 16;
+
+ startblock = startlid / IB_MLIDS_IN_BLOCK;
+ lastblock = endlid / IB_MLIDS_IN_BLOCK;
+ for (block = startblock; block <= lastblock; block++) {
+ for (j = 0; j < chunks; j++) {
+ int status;
+ mod = (block - IB_MIN_MCAST_LID / IB_MLIDS_IN_BLOCK)
+ | (j << 28);
+
+ DEBUG("reading block %x chunk %d mod %x", block, j,
+ mod);
+ if (!smp_query_status_via
+ (mft + j, portid, IB_ATTR_MULTICASTFORWTBL, mod, 0,
+ &status, srcport)) {
+ fprintf(stderr, "SubnGet() failed"
+ "; MAD status 0x%x AM 0x%x\n",
+ status, mod);
+ return NULL;
+ }
+ }
+
+ i = block * IB_MLIDS_IN_BLOCK;
+ e = i + IB_MLIDS_IN_BLOCK;
+ if (i < startlid)
+ i = startlid;
+ if (e > endlid + 1)
+ e = endlid + 1;
+
+ for (; i < e; i++) {
+ if (dump_mlid(str, sizeof str, i, nports, mft) == 0)
+ continue;
+ printf("0x%04x %s\n", i, str);
+ n++;
+ }
+ }
+
+ printf("%d %smlids dumped \n", n, dump_all ? "" : "valid ");
+
+ free(mapnd);
+ return 0;
+}
+
+int dump_lid(char *str, int strlen, int lid, int valid)
+{
+ char nd[IB_SMP_DATA_SIZE] = { 0 };
+ uint8_t ni[IB_SMP_DATA_SIZE] = { 0 };
+ uint8_t pi[IB_SMP_DATA_SIZE] = { 0 };
+ ib_portid_t lidport = { 0 };
+ static int last_port_lid, base_port_lid;
+ char ntype[50], sguid[30];
+ static uint64_t portguid;
+ uint64_t nodeguid;
+ int baselid, lmc, type;
+ char *mapnd = NULL;
+ int rc;
+
+ if (brief) {
+ str[0] = 0;
+ return 0;
+ }
+
+ if (lid <= last_port_lid) {
+ if (!valid)
+ return snprintf(str, strlen,
+ ": (path #%d - illegal port)",
+ lid - base_port_lid);
+ else if (!portguid)
+ return snprintf(str, strlen,
+ ": (path #%d out of %d)",
+ lid - base_port_lid + 1,
+ last_port_lid - base_port_lid + 1);
+ else {
+ return snprintf(str, strlen,
+ ": (path #%d out of %d: portguid %s)",
+ lid - base_port_lid + 1,
+ last_port_lid - base_port_lid + 1,
+ mad_dump_val(IB_NODE_PORT_GUID_F, sguid,
+ sizeof sguid, &portguid));
+ }
+ }
+
+ if (!valid)
+ return snprintf(str, strlen, ": (illegal port)");
+
+ portguid = 0;
+ lidport.lid = lid;
+
+ if (!smp_query_via(nd, &lidport, IB_ATTR_NODE_DESC, 0, 100, srcport) ||
+ !smp_query_via(pi, &lidport, IB_ATTR_PORT_INFO, 0, 100, srcport) ||
+ !smp_query_via(ni, &lidport, IB_ATTR_NODE_INFO, 0, 100, srcport))
+ return snprintf(str, strlen, ": (unknown node and type)");
+
+ mad_decode_field(ni, IB_NODE_GUID_F, &nodeguid);
+ mad_decode_field(ni, IB_NODE_PORT_GUID_F, &portguid);
+ mad_decode_field(ni, IB_NODE_TYPE_F, &type);
+
+ mad_decode_field(pi, IB_PORT_LID_F, &baselid);
+ mad_decode_field(pi, IB_PORT_LMC_F, &lmc);
+
+ if (lmc > 0) {
+ base_port_lid = baselid;
+ last_port_lid = baselid + (1 << lmc) - 1;
+ }
+
+ mapnd = remap_node_name(node_name_map, nodeguid, nd);
+
+ rc = snprintf(str, strlen, ": (%s portguid %s: '%s')",
+ mad_dump_val(IB_NODE_TYPE_F, ntype, sizeof ntype,
+ &type), mad_dump_val(IB_NODE_PORT_GUID_F,
+ sguid, sizeof sguid,
+ &portguid),
+ mapnd);
+
+ free(mapnd);
+ return rc;
+}
+
+char *dump_unicast_tables(ib_portid_t * portid, int startlid, int endlid)
+{
+ char lft[IB_SMP_DATA_SIZE] = { 0 };
+ char nd[IB_SMP_DATA_SIZE] = { 0 };
+ uint8_t sw[IB_SMP_DATA_SIZE] = { 0 };
+ char str[200], *s;
+ uint64_t nodeguid;
+ int block, i, e, top;
+ unsigned nports;
+ int n = 0, startblock, endblock;
+ char *mapnd = NULL;
+
+ if ((s = check_switch(portid, &nports, &nodeguid, sw, nd)))
+ return s;
+
+ mad_decode_field(sw, IB_SW_LINEAR_FDB_TOP_F, &top);
+
+ if (!endlid || endlid > top)
+ endlid = top;
+
+ if (endlid > IB_MAX_UCAST_LID) {
+ IBWARN("illegal lft top %d, truncate to %d", endlid,
+ IB_MAX_UCAST_LID);
+ endlid = IB_MAX_UCAST_LID;
+ }
+
+ mapnd = remap_node_name(node_name_map, nodeguid, nd);
+
+ printf("Unicast lids [0x%x-0x%x] of switch %s guid 0x%016" PRIx64
+ " (%s):\n", startlid, endlid, portid2str(portid), nodeguid,
+ mapnd);
+
+ DEBUG("Switch top is 0x%x\n", top);
+
+ printf(" Lid Out Destination\n");
+ printf(" Port Info \n");
+ startblock = startlid / IB_SMP_DATA_SIZE;
+ endblock = ALIGN(endlid, IB_SMP_DATA_SIZE) / IB_SMP_DATA_SIZE;
+ for (block = startblock; block < endblock; block++) {
+ int status;
+ DEBUG("reading block %d", block);
+ if (!smp_query_status_via(lft, portid, IB_ATTR_LINEARFORWTBL, block,
+ 0, &status, srcport)) {
+ fprintf(stderr, "SubnGet() failed"
+ "; MAD status 0x%x AM 0x%x\n",
+ status, block);
+ return NULL;
+ }
+ i = block * IB_SMP_DATA_SIZE;
+ e = i + IB_SMP_DATA_SIZE;
+ if (i < startlid)
+ i = startlid;
+ if (e > endlid + 1)
+ e = endlid + 1;
+
+ for (; i < e; i++) {
+ unsigned outport = lft[i % IB_SMP_DATA_SIZE];
+ unsigned valid = (outport <= nports);
+
+ if (!valid && !dump_all)
+ continue;
+ dump_lid(str, sizeof str, i, valid);
+ printf("0x%04x %03u %s\n", i, outport & 0xff, str);
+ n++;
+ }
+ }
+
+ printf("%d %slids dumped \n", n, dump_all ? "" : "valid ");
+ free(mapnd);
+ return 0;
+}
+
+static int process_opt(void *context, int ch, char *optarg)
+{
+ switch (ch) {
+ case 'a':
+ dump_all++;
+ break;
+ case 'M':
+ multicast++;
+ break;
+ case 'n':
+ brief++;
+ break;
+ case 1:
+ node_name_map_file = strdup(optarg);
+ break;
+ default:
+ return -1;
+ }
+ return 0;
+}
+
+int main(int argc, char **argv)
+{
+ int mgmt_classes[3] =
+ { IB_SMI_CLASS, IB_SMI_DIRECT_CLASS, IB_SA_CLASS };
+ ib_portid_t portid = { 0 };
+ unsigned startlid = 0, endlid = 0;
+ char *err;
+
+ const struct ibdiag_opt opts[] = {
+ {"all", 'a', 0, NULL, "show all lids, even invalid entries"},
+ {"no_dests", 'n', 0, NULL,
+ "do not try to resolve destinations"},
+ {"Multicast", 'M', 0, NULL, "show multicast forwarding tables"},
+ {"node-name-map", 1, 1, "<file>", "node name map file"},
+ {0}
+ };
+ char usage_args[] = "[<dest dr_path|lid|guid> [<startlid> [<endlid>]]]";
+ const char *usage_examples[] = {
+ " -- Unicast examples:",
+ "4\t# dump all lids with valid out ports of switch with lid 4",
+ "-a 4\t# same, but dump all lids, even with invalid out ports",
+ "-n 4\t# simple dump format - no destination resolving",
+ "4 10\t# dump lids starting from 10",
+ "4 0x10 0x20\t# dump lid range",
+ "-G 0x08f1040023\t# resolve switch by GUID",
+ "-D 0,1\t# resolve switch by direct path",
+ " -- Multicast examples:",
+ "-M 4\t# dump all non empty mlids of switch with lid 4",
+ "-M 4 0xc010 0xc020\t# same, but with range",
+ "-M -n 4\t# simple dump format",
+ NULL,
+ };
+
+ ibdiag_process_opts(argc, argv, NULL, "K", opts, process_opt,
+ usage_args, usage_examples);
+
+ argc -= optind;
+ argv += optind;
+
+ if (!argc)
+ ibdiag_show_usage();
+
+ if (argc > 1)
+ startlid = strtoul(argv[1], 0, 0);
+ if (argc > 2)
+ endlid = strtoul(argv[2], 0, 0);
+
+ node_name_map = open_node_name_map(node_name_map_file);
+
+ srcport = mad_rpc_open_port(ibd_ca, ibd_ca_port, mgmt_classes, 3);
+ if (!srcport)
+ IBEXIT("Failed to open '%s' port '%d'", ibd_ca, ibd_ca_port);
+
+ smp_mkey_set(srcport, ibd_mkey);
+
+ if (resolve_portid_str(ibd_ca, ibd_ca_port, &portid, argv[0],
+ ibd_dest_type, ibd_sm_id, srcport) < 0)
+ IBEXIT("can't resolve destination port %s", argv[0]);
+
+ if (multicast)
+ err = dump_multicast_tables(&portid, startlid, endlid);
+ else
+ err = dump_unicast_tables(&portid, startlid, endlid);
+
+ if (err)
+ IBEXIT("dump tables: %s", err);
+
+ mad_rpc_close_port(srcport);
+ close_node_name_map(node_name_map);
+ exit(0);
+}
diff --git a/contrib/ofed/infiniband-diags/src/ibsendtrap.c b/contrib/ofed/infiniband-diags/src/ibsendtrap.c
new file mode 100644
index 0000000..7044deb
--- /dev/null
+++ b/contrib/ofed/infiniband-diags/src/ibsendtrap.c
@@ -0,0 +1,278 @@
+/*
+ * Copyright (c) 2008 Lawrence Livermore National Security
+ * Copyright (c) 2008-2009 Voltaire Inc. All rights reserved.
+ * Copyright (c) 2009 HNR Consulting. All rights reserved.
+ * Copyright (c) 2011 Mellanox Technologies LTD. All rights reserved.
+ *
+ * Produced at Lawrence Livermore National Laboratory.
+ * Written by Ira Weiny <weiny2@llnl.gov>.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <unistd.h>
+#include <string.h>
+
+#define _GNU_SOURCE
+#include <getopt.h>
+
+#include <infiniband/mad.h>
+#include <iba/ib_types.h>
+
+#include "ibdiag_common.h"
+
+struct ibmad_port *srcport;
+/* for local link integrity */
+int error_port = 1;
+
+static uint16_t get_node_type(ib_portid_t * port)
+{
+ uint16_t node_type = IB_NODE_TYPE_CA;
+ uint8_t data[IB_SMP_DATA_SIZE] = { 0 };
+
+ if (smp_query_via(data, port, IB_ATTR_NODE_INFO, 0, 0, srcport))
+ node_type = (uint16_t) mad_get_field(data, 0, IB_NODE_TYPE_F);
+ return node_type;
+}
+
+static uint32_t get_cap_mask(ib_portid_t * port)
+{
+ uint8_t data[IB_SMP_DATA_SIZE] = { 0 };
+ uint32_t cap_mask = 0;
+
+ if (smp_query_via(data, port, IB_ATTR_PORT_INFO, 0, 0, srcport))
+ cap_mask = (uint32_t) mad_get_field(data, 0, IB_PORT_CAPMASK_F);
+ return cap_mask;
+}
+
+static void build_trap145(ib_mad_notice_attr_t * n, ib_portid_t * port)
+{
+ n->generic_type = 0x80 | IB_NOTICE_TYPE_INFO;
+ n->g_or_v.generic.prod_type_lsb = cl_hton16(get_node_type(port));
+ n->g_or_v.generic.trap_num = cl_hton16(145);
+ n->issuer_lid = cl_hton16((uint16_t) port->lid);
+ n->data_details.ntc_145.new_sys_guid = cl_hton64(0x1234567812345678);
+}
+
+static void build_trap144_local(ib_mad_notice_attr_t * n, ib_portid_t * port)
+{
+ n->generic_type = 0x80 | IB_NOTICE_TYPE_INFO;
+ n->g_or_v.generic.prod_type_lsb = cl_hton16(get_node_type(port));
+ n->g_or_v.generic.trap_num = cl_hton16(144);
+ n->issuer_lid = cl_hton16((uint16_t) port->lid);
+ n->data_details.ntc_144.lid = n->issuer_lid;
+ n->data_details.ntc_144.new_cap_mask = cl_hton32(get_cap_mask(port));
+ n->data_details.ntc_144.local_changes =
+ TRAP_144_MASK_OTHER_LOCAL_CHANGES;
+}
+
+static void build_trap144_nodedesc(ib_mad_notice_attr_t * n, ib_portid_t * port)
+{
+ build_trap144_local(n, port);
+ n->data_details.ntc_144.change_flgs =
+ TRAP_144_MASK_NODE_DESCRIPTION_CHANGE;
+}
+
+static void build_trap144_linkspeed(ib_mad_notice_attr_t * n,
+ ib_portid_t * port)
+{
+ build_trap144_local(n, port);
+ n->data_details.ntc_144.change_flgs =
+ TRAP_144_MASK_LINK_SPEED_ENABLE_CHANGE;
+}
+
+static void build_trap129(ib_mad_notice_attr_t * n, ib_portid_t * port)
+{
+ n->generic_type = 0x80 | IB_NOTICE_TYPE_URGENT;
+ n->g_or_v.generic.prod_type_lsb = cl_hton16(get_node_type(port));
+ n->g_or_v.generic.trap_num = cl_hton16(129);
+ n->issuer_lid = cl_hton16((uint16_t) port->lid);
+ n->data_details.ntc_129_131.lid = n->issuer_lid;
+ n->data_details.ntc_129_131.pad = 0;
+ n->data_details.ntc_129_131.port_num = (uint8_t) error_port;
+}
+
+static void build_trap256_local(ib_mad_notice_attr_t * n, ib_portid_t * port)
+{
+ n->generic_type = 0x80 | IB_NOTICE_TYPE_SECURITY;
+ n->g_or_v.generic.prod_type_lsb = cl_hton16(get_node_type(port));
+ n->g_or_v.generic.trap_num = cl_hton16(256);
+ n->issuer_lid = cl_hton16((uint16_t) port->lid);
+ n->data_details.ntc_256.lid = n->issuer_lid;
+ n->data_details.ntc_256.dr_slid = 0xffff;
+ n->data_details.ntc_256.method = 1;
+ n->data_details.ntc_256.attr_id = cl_ntoh16(0x15);
+ n->data_details.ntc_256.attr_mod = cl_ntoh32(0x12);
+ n->data_details.ntc_256.mkey = cl_ntoh64(0x1234567812345678);
+}
+
+static void build_trap256_lid(ib_mad_notice_attr_t * n, ib_portid_t * port)
+{
+ build_trap256_local(n, port);
+ n->data_details.ntc_256.dr_trunc_hop = 0;
+}
+
+static void build_trap256_dr(ib_mad_notice_attr_t * n, ib_portid_t * port)
+{
+ build_trap256_local(n, port);
+ n->data_details.ntc_256.dr_trunc_hop = 0x80 | 0x4;
+ n->data_details.ntc_256.dr_rtn_path[0] = 5;
+ n->data_details.ntc_256.dr_rtn_path[1] = 6;
+ n->data_details.ntc_256.dr_rtn_path[2] = 7;
+ n->data_details.ntc_256.dr_rtn_path[3] = 8;
+}
+
+static void build_trap257_258(ib_mad_notice_attr_t * n, ib_portid_t * port,
+ uint16_t trap_num)
+{
+ n->generic_type = 0x80 | IB_NOTICE_TYPE_SECURITY;
+ n->g_or_v.generic.prod_type_lsb = cl_hton16(get_node_type(port));
+ n->g_or_v.generic.trap_num = cl_hton16(trap_num);
+ n->issuer_lid = cl_hton16((uint16_t) port->lid);
+ n->data_details.ntc_257_258.lid1 = cl_hton16(1);
+ n->data_details.ntc_257_258.lid2 = cl_hton16(2);
+ n->data_details.ntc_257_258.key = cl_hton32(0x12345678);
+ n->data_details.ntc_257_258.qp1 = cl_hton32(0x010101);
+ n->data_details.ntc_257_258.qp2 = cl_hton32(0x020202);
+ n->data_details.ntc_257_258.gid1.unicast.prefix = cl_ntoh64(0xf8c0000000000001);
+ n->data_details.ntc_257_258.gid1.unicast.interface_id = cl_ntoh64(0x1111222233334444);
+ n->data_details.ntc_257_258.gid2.unicast.prefix = cl_ntoh64(0xf8c0000000000001);
+ n->data_details.ntc_257_258.gid2.unicast.interface_id = cl_ntoh64(0x5678567812341234);
+}
+
+static void build_trap257(ib_mad_notice_attr_t * n, ib_portid_t * port)
+{
+ build_trap257_258(n, port, 257);
+}
+
+static void build_trap258(ib_mad_notice_attr_t * n, ib_portid_t * port)
+{
+ build_trap257_258(n, port, 258);
+}
+
+static int send_trap(void (*build) (ib_mad_notice_attr_t *, ib_portid_t *))
+{
+ ib_portid_t sm_port;
+ ib_portid_t selfportid;
+ int selfport;
+ ib_rpc_t trap_rpc;
+ ib_mad_notice_attr_t notice;
+
+ if (resolve_self(ibd_ca, ibd_ca_port, &selfportid, &selfport, NULL))
+ IBEXIT("can't resolve self");
+
+ if (resolve_sm_portid(ibd_ca, ibd_ca_port, &sm_port))
+ IBEXIT("can't resolve SM destination port");
+
+ memset(&trap_rpc, 0, sizeof(trap_rpc));
+ trap_rpc.mgtclass = IB_SMI_CLASS;
+ trap_rpc.method = IB_MAD_METHOD_TRAP;
+ trap_rpc.trid = mad_trid();
+ trap_rpc.attr.id = NOTICE;
+ trap_rpc.datasz = IB_SMP_DATA_SIZE;
+ trap_rpc.dataoffs = IB_SMP_DATA_OFFS;
+
+ memset(&notice, 0, sizeof(notice));
+ build(&notice, &selfportid);
+
+ return mad_send_via(&trap_rpc, &sm_port, NULL, &notice, srcport);
+}
+
+typedef struct _trap_def {
+ char *trap_name;
+ void (*build_func) (ib_mad_notice_attr_t *, ib_portid_t *);
+} trap_def_t;
+
+static const trap_def_t traps[] = {
+ {"node_desc_change", build_trap144_nodedesc},
+ {"link_speed_enabled_change", build_trap144_linkspeed},
+ {"local_link_integrity", build_trap129},
+ {"sys_image_guid_change", build_trap145},
+ {"mkey_lid", build_trap256_lid},
+ {"mkey_dr", build_trap256_dr},
+ {"pkey", build_trap257},
+ {"qkey", build_trap258},
+ {NULL, NULL}
+};
+
+int process_send_trap(char *trap_name)
+{
+ int i;
+
+ for (i = 0; traps[i].trap_name; i++)
+ if (strcmp(traps[i].trap_name, trap_name) == 0)
+ return send_trap(traps[i].build_func);
+ ibdiag_show_usage();
+ return 1;
+}
+
+int main(int argc, char **argv)
+{
+ char usage_args[1024];
+ int mgmt_classes[2] = { IB_SMI_CLASS, IB_SMI_DIRECT_CLASS };
+ char *trap_name = NULL;
+ int i, n, rc;
+
+ n = sprintf(usage_args, "[<trap_name>] [<error_port>]\n"
+ "\nArgument <trap_name> can be one of the following:\n");
+ for (i = 0; traps[i].trap_name; i++) {
+ n += snprintf(usage_args + n, sizeof(usage_args) - n,
+ " %s\n", traps[i].trap_name);
+ if (n >= sizeof(usage_args))
+ exit(-1);
+ }
+ snprintf(usage_args + n, sizeof(usage_args) - n,
+ "\n default behavior is to send \"%s\"", traps[0].trap_name);
+
+ ibdiag_process_opts(argc, argv, NULL, "DGKL", NULL, NULL,
+ usage_args, NULL);
+
+ argc -= optind;
+ argv += optind;
+
+ trap_name = argv[0] ? argv[0] : traps[0].trap_name;
+
+ if (argc > 1)
+ error_port = atoi(argv[1]);
+
+ madrpc_show_errors(1);
+
+ srcport = mad_rpc_open_port(ibd_ca, ibd_ca_port, mgmt_classes, 2);
+ if (!srcport)
+ IBEXIT("Failed to open '%s' port '%d'", ibd_ca, ibd_ca_port);
+
+ smp_mkey_set(srcport, ibd_mkey);
+
+ rc = process_send_trap(trap_name);
+ mad_rpc_close_port(srcport);
+ return rc;
+}
diff --git a/contrib/ofed/infiniband-diags/src/ibstat.c b/contrib/ofed/infiniband-diags/src/ibstat.c
new file mode 100644
index 0000000..6e08fad
--- /dev/null
+++ b/contrib/ofed/infiniband-diags/src/ibstat.c
@@ -0,0 +1,335 @@
+/*
+ * Copyright (c) 2004-2009 Voltaire Inc. All rights reserved.
+ * Copyright (c) 2011 Mellanox Technologies LTD. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+#define _GNU_SOURCE
+
+#if HAVE_CONFIG_H
+# include <config.h>
+#endif /* HAVE_CONFIG_H */
+
+#include <inttypes.h>
+#include <string.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <getopt.h>
+#include <netinet/in.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <errno.h>
+
+#include <infiniband/umad.h>
+
+#include <ibdiag_common.h>
+
+static char *node_type_str[] = {
+ "???",
+ "CA",
+ "Switch",
+ "Router",
+ "iWARP RNIC"
+};
+
+static void ca_dump(umad_ca_t * ca)
+{
+ if (!ca->node_type)
+ return;
+ printf("%s '%s'\n",
+ ((unsigned)ca->node_type <=
+ IB_NODE_MAX ? node_type_str[ca->node_type] : "???"),
+ ca->ca_name);
+ printf("\t%s type: %s\n",
+ ((unsigned)ca->node_type <=
+ IB_NODE_MAX ? node_type_str[ca->node_type] : "???"),
+ ca->ca_type);
+ printf("\tNumber of ports: %d\n", ca->numports);
+ printf("\tFirmware version: %s\n", ca->fw_ver);
+ printf("\tHardware version: %s\n", ca->hw_ver);
+ printf("\tNode GUID: 0x%016" PRIx64 "\n", ntohll(ca->node_guid));
+ printf("\tSystem image GUID: 0x%016" PRIx64 "\n",
+ ntohll(ca->system_guid));
+}
+
+static char *port_state_str[] = {
+ "???",
+ "Down",
+ "Initializing",
+ "Armed",
+ "Active"
+};
+
+static char *port_phy_state_str[] = {
+ "No state change",
+ "Sleep",
+ "Polling",
+ "Disabled",
+ "PortConfigurationTraining",
+ "LinkUp",
+ "LinkErrorRecovery",
+ "PhyTest"
+};
+
+static int ret_code(void)
+{
+ int e = errno;
+
+ if (e > 0)
+ return -e;
+ return e;
+}
+
+int sys_read_string(const char *dir_name, const char *file_name, char *str, int max_len)
+{
+ char path[256], *s;
+ size_t len;
+
+ snprintf(path, sizeof(path), "%s/%s", dir_name, file_name);
+
+ for (s = &path[0]; *s != '\0'; s++)
+ if (*s == '/')
+ *s = '.';
+
+ len = max_len;
+ if (sysctlbyname(&path[1], str, &len, NULL, 0) == -1)
+ return ret_code();
+
+ str[(len < max_len) ? len : max_len - 1] = 0;
+
+ if ((s = strrchr(str, '\n')))
+ *s = 0;
+
+ return 0;
+}
+
+static int is_fdr10(umad_port_t *port)
+{
+ char port_dir[256];
+ char rate[32];
+ int len, fdr10 = 0;
+ char *p;
+
+ len = snprintf(port_dir, sizeof(port_dir), "%s/%s/%s/%d",
+ SYS_INFINIBAND, port->ca_name, SYS_CA_PORTS_DIR,
+ port->portnum);
+ if (len < 0 || len > sizeof(port_dir))
+ goto done;
+
+ if (sys_read_string(port_dir, SYS_PORT_RATE, rate, sizeof(rate)) == 0) {
+ if ((p = strchr(rate, ')'))) {
+ if (!strncasecmp(p - 5, "fdr10", 5))
+ fdr10 = 1;
+ }
+ }
+
+done:
+ return fdr10;
+}
+
+static int port_dump(umad_port_t * port, int alone)
+{
+ char *pre = "";
+ char *hdrpre = "";
+
+ if (!port)
+ return -1;
+
+ if (!alone) {
+ pre = " ";
+ hdrpre = " ";
+ }
+
+ printf("%sPort %d:\n", hdrpre, port->portnum);
+ printf("%sState: %s\n", pre,
+ (unsigned)port->state <=
+ 4 ? port_state_str[port->state] : "???");
+ printf("%sPhysical state: %s\n", pre,
+ (unsigned)port->phys_state <=
+ 7 ? port_phy_state_str[port->phys_state] : "???");
+ if (is_fdr10(port))
+ printf("%sRate: %d (FDR10)\n", pre, port->rate);
+ else
+ if (port->rate != 2)
+ printf("%sRate: %d\n", pre, port->rate);
+ else
+ printf("%sRate: 2.5\n", pre);
+ printf("%sBase lid: %d\n", pre, port->base_lid);
+ printf("%sLMC: %d\n", pre, port->lmc);
+ printf("%sSM lid: %d\n", pre, port->sm_lid);
+ printf("%sCapability mask: 0x%08x\n", pre, ntohl(port->capmask));
+ printf("%sPort GUID: 0x%016" PRIx64 "\n", pre, ntohll(port->port_guid));
+#ifdef HAVE_UMAD_PORT_LINK_LAYER
+ printf("%sLink layer: %s\n", pre, port->link_layer);
+#endif
+ return 0;
+}
+
+static int ca_stat(char *ca_name, int portnum, int no_ports)
+{
+ umad_ca_t ca;
+ int r;
+
+ if ((r = umad_get_ca(ca_name, &ca)) < 0)
+ return r;
+
+ if (!ca.node_type)
+ return 0;
+
+ if (!no_ports && portnum >= 0) {
+ if (portnum > ca.numports || !ca.ports[portnum]) {
+ IBWARN("%s: '%s' has no port number %d - max (%d)",
+ ((unsigned)ca.node_type <=
+ IB_NODE_MAX ? node_type_str[ca.node_type] :
+ "???"), ca_name, portnum, ca.numports);
+ return -1;
+ }
+ printf("%s: '%s'\n",
+ ((unsigned)ca.node_type <=
+ IB_NODE_MAX ? node_type_str[ca.node_type] : "???"),
+ ca.ca_name);
+ port_dump(ca.ports[portnum], 1);
+ return 0;
+ }
+
+ /* print ca header */
+ ca_dump(&ca);
+
+ if (no_ports)
+ return 0;
+
+ for (portnum = 0; portnum <= ca.numports; portnum++)
+ port_dump(ca.ports[portnum], 0);
+
+ return 0;
+}
+
+static int ports_list(char names[][UMAD_CA_NAME_LEN], int n)
+{
+ uint64_t guids[64];
+ int found, ports, i;
+
+ for (i = 0, found = 0; i < n && found < 64; i++) {
+ if ((ports =
+ umad_get_ca_portguids(names[i], guids + found,
+ 64 - found)) < 0)
+ return -1;
+ found += ports;
+ }
+
+ for (i = 0; i < found; i++)
+ if (guids[i])
+ printf("0x%016" PRIx64 "\n", ntohll(guids[i]));
+ return found;
+}
+
+static int list_only, short_format, list_ports;
+
+static int process_opt(void *context, int ch, char *optarg)
+{
+ switch (ch) {
+ case 'l':
+ list_only++;
+ break;
+ case 's':
+ short_format++;
+ break;
+ case 'p':
+ list_ports++;
+ break;
+ default:
+ return -1;
+ }
+ return 0;
+}
+
+int main(int argc, char *argv[])
+{
+ char names[UMAD_MAX_DEVICES][UMAD_CA_NAME_LEN];
+ int dev_port = -1;
+ int n, i;
+
+ const struct ibdiag_opt opts[] = {
+ {"list_of_cas", 'l', 0, NULL, "list all IB devices"},
+ {"short", 's', 0, NULL, "short output"},
+ {"port_list", 'p', 0, NULL, "show port list"},
+ {0}
+ };
+ char usage_args[] = "<ca_name> [portnum]";
+ const char *usage_examples[] = {
+ "-l # list all IB devices",
+ "mthca0 2 # stat port 2 of 'mthca0'",
+ NULL
+ };
+
+ ibdiag_process_opts(argc, argv, NULL, "CDeGKLPsty", opts, process_opt,
+ usage_args, usage_examples);
+
+ argc -= optind;
+ argv += optind;
+
+ if (argc > 1)
+ dev_port = strtol(argv[1], 0, 0);
+
+ if (umad_init() < 0)
+ IBPANIC("can't init UMAD library");
+
+ if ((n = umad_get_cas_names(names, UMAD_MAX_DEVICES)) < 0)
+ IBPANIC("can't list IB device names");
+
+ if (argc) {
+ for (i = 0; i < n; i++)
+ if (!strncmp(names[i], argv[0], sizeof names[i]))
+ break;
+ if (i >= n)
+ IBPANIC("'%s' IB device can't be found", argv[0]);
+
+ strncpy(names[0], argv[0], sizeof(names[0])-1);
+ names[0][sizeof(names[0])-1] = '\0';
+ n = 1;
+ }
+
+ if (list_ports) {
+ if (ports_list(names, n) < 0)
+ IBPANIC("can't list ports");
+ return 0;
+ }
+
+ for (i = 0; i < n; i++) {
+ if (list_only)
+ printf("%s\n", names[i]);
+ else if (ca_stat(names[i], dev_port, short_format) < 0)
+ IBPANIC("stat of IB device '%s' failed", names[i]);
+ }
+
+ return 0;
+}
diff --git a/contrib/ofed/infiniband-diags/src/ibsysstat.c b/contrib/ofed/infiniband-diags/src/ibsysstat.c
new file mode 100644
index 0000000..104306d
--- /dev/null
+++ b/contrib/ofed/infiniband-diags/src/ibsysstat.c
@@ -0,0 +1,367 @@
+/*
+ * Copyright (c) 2004-2009 Voltaire Inc. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+#if HAVE_CONFIG_H
+# include <config.h>
+#endif /* HAVE_CONFIG_H */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <string.h>
+#include <getopt.h>
+
+#include <infiniband/umad.h>
+#include <infiniband/mad.h>
+
+#include <sys/sysctl.h>
+
+#include "ibdiag_common.h"
+
+#define MAX_CPUS 8
+
+struct ibmad_port *srcport;
+
+static ibmad_gid_t dgid;
+static int with_grh;
+
+enum ib_sysstat_attr_t {
+ IB_PING_ATTR = 0x10,
+ IB_HOSTINFO_ATTR = 0x11,
+ IB_CPUINFO_ATTR = 0x12,
+};
+
+typedef struct cpu_info {
+ char *model;
+ char *mhz;
+} cpu_info;
+
+static cpu_info cpus[MAX_CPUS];
+static int host_ncpu;
+static int server = 0, oui = IB_OPENIB_OUI;
+
+static int server_respond(void *umad, int size)
+{
+ ib_rpc_t rpc = { 0 };
+ ib_rmpp_hdr_t rmpp = { 0 };
+ ib_portid_t rport;
+ uint8_t *mad = umad_get_mad(umad);
+ ib_mad_addr_t *mad_addr;
+
+ if (!(mad_addr = umad_get_mad_addr(umad)))
+ return -1;
+
+ memset(&rport, 0, sizeof(rport));
+
+ rport.lid = ntohs(mad_addr->lid);
+ rport.qp = ntohl(mad_addr->qpn);
+ rport.qkey = ntohl(mad_addr->qkey);
+ rport.sl = mad_addr->sl;
+ if (!rport.qkey && rport.qp == 1)
+ rport.qkey = IB_DEFAULT_QP1_QKEY;
+ rport.grh_present = mad_addr->grh_present;
+ if (rport.grh_present)
+ memcpy(rport.gid, mad_addr->gid, 16);
+
+ rpc.mgtclass = mad_get_field(mad, 0, IB_MAD_MGMTCLASS_F);
+ rpc.method = IB_MAD_METHOD_GET | IB_MAD_RESPONSE;
+ rpc.attr.id = mad_get_field(mad, 0, IB_MAD_ATTRID_F);
+ rpc.attr.mod = mad_get_field(mad, 0, IB_MAD_ATTRMOD_F);
+ rpc.oui = mad_get_field(mad, 0, IB_VEND2_OUI_F);
+ rpc.trid = mad_get_field64(mad, 0, IB_MAD_TRID_F);
+
+ if (size > IB_MAD_SIZE)
+ rmpp.flags = IB_RMPP_FLAG_ACTIVE;
+
+ DEBUG("responding %d bytes to %s, attr 0x%x mod 0x%x qkey %x",
+ size, portid2str(&rport), rpc.attr.id, rpc.attr.mod, rport.qkey);
+
+ if (mad_build_pkt(umad, &rpc, &rport, &rmpp, 0) < 0)
+ return -1;
+
+ if (ibdebug > 1)
+ xdump(stderr, "mad respond pkt\n", mad, IB_MAD_SIZE);
+
+ if (umad_send(mad_rpc_portid(srcport),
+ mad_rpc_class_agent(srcport, rpc.mgtclass), umad, size,
+ rpc.timeout, 0) < 0) {
+ DEBUG("send failed; %m");
+ return -1;
+ }
+
+ return 0;
+}
+
+static int mk_reply(int attr, void *data, int sz)
+{
+ char *s = data;
+ int n, i, ret = 0;
+
+ switch (attr) {
+ case IB_PING_ATTR:
+ break; /* nothing to do here, just reply */
+ case IB_HOSTINFO_ATTR:
+ if (gethostname(s, sz) < 0)
+ snprintf(s, sz, "?hostname?");
+ s[sz - 1] = 0;
+ if ((n = strlen(s)) >= sz - 1) {
+ ret = sz;
+ break;
+ }
+ s[n] = '.';
+ s += n + 1;
+ sz -= n + 1;
+ ret += n + 1;
+ if (getdomainname(s, sz) < 0)
+ snprintf(s, sz, "?domainname?");
+ if ((n = strlen(s)) == 0)
+ s[-1] = 0; /* no domain */
+ else
+ ret += n;
+ break;
+ case IB_CPUINFO_ATTR:
+ s[0] = '\0';
+ for (i = 0; i < host_ncpu && sz > 0; i++) {
+ n = snprintf(s, sz, "cpu %d: model %s MHZ %s\n",
+ i, cpus[i].model, cpus[i].mhz);
+ if (n >= sz) {
+ IBWARN("cpuinfo truncated");
+ ret = sz;
+ break;
+ }
+ sz -= n;
+ s += n;
+ ret += n;
+ }
+ ret++;
+ break;
+ default:
+ DEBUG("unknown attr %d", attr);
+ }
+ return ret;
+}
+
+static uint8_t buf[2048];
+
+static char *ibsystat_serv(void)
+{
+ void *umad;
+ void *mad;
+ int attr, mod, size;
+
+ DEBUG("starting to serve...");
+
+ while ((umad = mad_receive_via(buf, -1, srcport))) {
+ if (umad_status(buf)) {
+ DEBUG("drop mad with status %x: %s", umad_status(buf),
+ strerror(umad_status(buf)));
+ continue;
+ }
+
+ mad = umad_get_mad(umad);
+
+ attr = mad_get_field(mad, 0, IB_MAD_ATTRID_F);
+ mod = mad_get_field(mad, 0, IB_MAD_ATTRMOD_F);
+
+ DEBUG("got packet: attr 0x%x mod 0x%x", attr, mod);
+
+ size =
+ mk_reply(attr, (uint8_t *) mad + IB_VENDOR_RANGE2_DATA_OFFS,
+ sizeof(buf) - umad_size() -
+ IB_VENDOR_RANGE2_DATA_OFFS);
+
+ if (server_respond(umad, IB_VENDOR_RANGE2_DATA_OFFS + size) < 0)
+ DEBUG("respond failed");
+ }
+
+ DEBUG("server out");
+ return 0;
+}
+
+static int match_attr(char *str)
+{
+ if (!strcmp(str, "ping"))
+ return IB_PING_ATTR;
+ if (!strcmp(str, "host"))
+ return IB_HOSTINFO_ATTR;
+ if (!strcmp(str, "cpu"))
+ return IB_CPUINFO_ATTR;
+ return -1;
+}
+
+static char *ibsystat(ib_portid_t * portid, int attr)
+{
+ ib_rpc_t rpc = { 0 };
+ int fd, agent, timeout, len;
+ void *data = (uint8_t *) umad_get_mad(buf) + IB_VENDOR_RANGE2_DATA_OFFS;
+
+ DEBUG("Sysstat ping..");
+
+ rpc.mgtclass = IB_VENDOR_OPENIB_SYSSTAT_CLASS;
+ rpc.method = IB_MAD_METHOD_GET;
+ rpc.attr.id = attr;
+ rpc.attr.mod = 0;
+ rpc.oui = oui;
+ rpc.timeout = 0;
+ rpc.datasz = IB_VENDOR_RANGE2_DATA_SIZE;
+ rpc.dataoffs = IB_VENDOR_RANGE2_DATA_OFFS;
+
+ portid->qp = 1;
+ if (!portid->qkey)
+ portid->qkey = IB_DEFAULT_QP1_QKEY;
+
+ if ((len = mad_build_pkt(buf, &rpc, portid, NULL, NULL)) < 0)
+ IBPANIC("cannot build packet.");
+
+ fd = mad_rpc_portid(srcport);
+ agent = mad_rpc_class_agent(srcport, rpc.mgtclass);
+ timeout = ibd_timeout ? ibd_timeout : MAD_DEF_TIMEOUT_MS;
+
+ if (umad_send(fd, agent, buf, len, timeout, 0) < 0)
+ IBPANIC("umad_send failed.");
+
+ len = sizeof(buf) - umad_size();
+ if (umad_recv(fd, buf, &len, timeout) < 0)
+ IBPANIC("umad_recv failed.");
+
+ if (umad_status(buf))
+ return strerror(umad_status(buf));
+
+ DEBUG("Got sysstat pong..");
+ if (attr != IB_PING_ATTR)
+ puts(data);
+ else
+ printf("sysstat ping succeeded\n");
+ return 0;
+}
+
+int build_cpuinfo(void)
+{
+ int ret;
+ size_t size = sizeof(ret);
+
+ if (sysctlbyname("hw.ncpu", &ret, &size, NULL, 0) != 0 || ret < 1)
+ ret = 1;
+ return ret;
+
+ DEBUG("ncpu %d", ret);
+}
+
+static int process_opt(void *context, int ch, char *optarg)
+{
+ switch (ch) {
+ case 'o':
+ oui = strtoul(optarg, 0, 0);
+ break;
+ case 'S':
+ server++;
+ break;
+ case 25:
+ if (!inet_pton(AF_INET6, optarg, &dgid)) {
+ fprintf(stderr, "dgid format is wrong!\n");
+ ibdiag_show_usage();
+ return 1;
+ }
+ with_grh = 1;
+ break;
+ default:
+ return -1;
+ }
+ return 0;
+}
+
+int main(int argc, char **argv)
+{
+ int mgmt_classes[3] =
+ { IB_SMI_CLASS, IB_SMI_DIRECT_CLASS, IB_SA_CLASS };
+ int sysstat_class = IB_VENDOR_OPENIB_SYSSTAT_CLASS;
+ ib_portid_t portid = { 0 };
+ int attr = IB_PING_ATTR;
+ char *err;
+
+ const struct ibdiag_opt opts[] = {
+ {"oui", 'o', 1, NULL, "use specified OUI number"},
+ {"Server", 'S', 0, NULL, "start in server mode"},
+ {"dgid", 25, 1, NULL, "remote gid (IPv6 format)"},
+ {0}
+ };
+ char usage_args[] = "<dest lid|guid> [<op>]";
+
+ ibdiag_process_opts(argc, argv, NULL, "DKy", opts, process_opt,
+ usage_args, NULL);
+
+ argc -= optind;
+ argv += optind;
+
+ if (!argc && !server)
+ ibdiag_show_usage();
+
+ if (argc > 1 && (attr = match_attr(argv[1])) < 0)
+ ibdiag_show_usage();
+
+ srcport = mad_rpc_open_port(ibd_ca, ibd_ca_port, mgmt_classes, 3);
+ if (!srcport)
+ IBEXIT("Failed to open '%s' port '%d'", ibd_ca, ibd_ca_port);
+
+ if (server) {
+ if (mad_register_server_via(sysstat_class, 1, 0, oui, srcport) <
+ 0)
+ IBEXIT("can't serve class %d", sysstat_class);
+
+ host_ncpu = build_cpuinfo();
+
+ if ((err = ibsystat_serv()))
+ IBEXIT("ibssystat to %s: %s", portid2str(&portid),
+ err);
+ exit(0);
+ }
+
+ if (mad_register_client_via(sysstat_class, 1, srcport) < 0)
+ IBEXIT("can't register to sysstat class %d", sysstat_class);
+
+ if (with_grh && ibd_dest_type != IB_DEST_LID)
+ IBEXIT("When using GRH, LID should be provided");
+ if (resolve_portid_str(ibd_ca, ibd_ca_port, &portid, argv[0],
+ ibd_dest_type, ibd_sm_id, srcport) < 0)
+ IBEXIT("can't resolve destination port %s", argv[0]);
+ if (with_grh) {
+ portid.grh_present = 1;
+ memcpy(&portid.gid, &dgid, sizeof(portid.gid));
+ }
+
+ if ((err = ibsystat(&portid, attr)))
+ IBEXIT("ibsystat to %s: %s", portid2str(&portid), err);
+
+ mad_rpc_close_port(srcport);
+ exit(0);
+}
diff --git a/contrib/ofed/infiniband-diags/src/ibtracert.c b/contrib/ofed/infiniband-diags/src/ibtracert.c
new file mode 100644
index 0000000..1da3d62
--- /dev/null
+++ b/contrib/ofed/infiniband-diags/src/ibtracert.c
@@ -0,0 +1,881 @@
+/*
+ * Copyright (c) 2004-2009 Voltaire Inc. All rights reserved.
+ * Copyright (c) 2009 HNR Consulting. All rights reserved.
+ * Copyright (c) 2010,2011 Mellanox Technologies LTD. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+#if HAVE_CONFIG_H
+# include <config.h>
+#endif /* HAVE_CONFIG_H */
+
+#define _GNU_SOURCE
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <ctype.h>
+#include <getopt.h>
+#include <netinet/in.h>
+#include <inttypes.h>
+
+#include <infiniband/umad.h>
+#include <infiniband/mad.h>
+#include <complib/cl_nodenamemap.h>
+
+#include "ibdiag_common.h"
+
+struct ibmad_port *srcport;
+
+#define MAXHOPS 63
+
+static char *node_type_str[] = {
+ "???",
+ "ca",
+ "switch",
+ "router",
+ "iwarp rnic"
+};
+
+static int timeout = 0; /* ms */
+static int force;
+static FILE *f;
+
+static char *node_name_map_file = NULL;
+static nn_map_t *node_name_map = NULL;
+
+typedef struct Port Port;
+typedef struct Switch Switch;
+typedef struct Node Node;
+
+struct Port {
+ Port *next;
+ Port *remoteport;
+ uint64_t portguid;
+ int portnum;
+ int lid;
+ int lmc;
+ int state;
+ int physstate;
+ char portinfo[64];
+};
+
+struct Switch {
+ int linearcap;
+ int mccap;
+ int linearFDBtop;
+ int fdb_base;
+ int enhsp0;
+ int8_t fdb[64];
+ char switchinfo[64];
+};
+
+struct Node {
+ Node *htnext;
+ Node *dnext;
+ Port *ports;
+ ib_portid_t path;
+ int type;
+ int dist;
+ int numports;
+ int upport;
+ Node *upnode;
+ uint64_t nodeguid; /* also portguid */
+ char nodedesc[64];
+ char nodeinfo[64];
+};
+
+Node *nodesdist[MAXHOPS];
+uint64_t target_portguid;
+
+/*
+ * is_port_inactive
+ * Checks whether or not the port state is other than active.
+ * The "sw" argument is only relevant when the port is on a
+ * switch; for HCAs and routers, this argument is ignored.
+ * Returns 1 when port is not active and 0 when active.
+ * Base switch port 0 is considered always active.
+ */
+static int is_port_inactive(Node * node, Port * port, Switch * sw)
+{
+ int res = 0;
+ if (port->state != 4 &&
+ (node->type != IB_NODE_SWITCH ||
+ (node->type == IB_NODE_SWITCH && sw->enhsp0)))
+ res = 1;
+ return res;
+}
+
+static int get_node(Node * node, Port * port, ib_portid_t * portid)
+{
+ void *pi = port->portinfo, *ni = node->nodeinfo, *nd = node->nodedesc;
+ char *s, *e;
+
+ memset(ni, 0, sizeof(node->nodeinfo));
+ if (!smp_query_via(ni, portid, IB_ATTR_NODE_INFO, 0, timeout, srcport))
+ return -1;
+
+ memset(nd, 0, sizeof(node->nodedesc));
+ if (!smp_query_via(nd, portid, IB_ATTR_NODE_DESC, 0, timeout, srcport))
+ return -1;
+
+ for (s = nd, e = s + 64; s < e; s++) {
+ if (!*s)
+ break;
+ if (!isprint(*s))
+ *s = ' ';
+ }
+
+ memset(pi, 0, sizeof(port->portinfo));
+ if (!smp_query_via(pi, portid, IB_ATTR_PORT_INFO, 0, timeout, srcport))
+ return -1;
+
+ mad_decode_field(ni, IB_NODE_GUID_F, &node->nodeguid);
+ mad_decode_field(ni, IB_NODE_TYPE_F, &node->type);
+ mad_decode_field(ni, IB_NODE_NPORTS_F, &node->numports);
+
+ mad_decode_field(ni, IB_NODE_PORT_GUID_F, &port->portguid);
+ mad_decode_field(ni, IB_NODE_LOCAL_PORT_F, &port->portnum);
+ mad_decode_field(pi, IB_PORT_LID_F, &port->lid);
+ mad_decode_field(pi, IB_PORT_LMC_F, &port->lmc);
+ mad_decode_field(pi, IB_PORT_STATE_F, &port->state);
+
+ DEBUG("portid %s: got node %" PRIx64 " '%s'", portid2str(portid),
+ node->nodeguid, node->nodedesc);
+ return 0;
+}
+
+static int switch_lookup(Switch * sw, ib_portid_t * portid, int lid)
+{
+ void *si = sw->switchinfo, *fdb = sw->fdb;
+
+ memset(si, 0, sizeof(sw->switchinfo));
+ if (!smp_query_via(si, portid, IB_ATTR_SWITCH_INFO, 0, timeout,
+ srcport))
+ return -1;
+
+ mad_decode_field(si, IB_SW_LINEAR_FDB_CAP_F, &sw->linearcap);
+ mad_decode_field(si, IB_SW_LINEAR_FDB_TOP_F, &sw->linearFDBtop);
+ mad_decode_field(si, IB_SW_ENHANCED_PORT0_F, &sw->enhsp0);
+
+ if (lid >= sw->linearcap && lid > sw->linearFDBtop)
+ return -1;
+
+ memset(fdb, 0, sizeof(sw->fdb));
+ if (!smp_query_via(fdb, portid, IB_ATTR_LINEARFORWTBL, lid / 64,
+ timeout, srcport))
+ return -1;
+
+ DEBUG("portid %s: forward lid %d to port %d",
+ portid2str(portid), lid, sw->fdb[lid % 64]);
+ return sw->fdb[lid % 64];
+}
+
+static int sameport(Port * a, Port * b)
+{
+ return a->portguid == b->portguid || (force && a->lid == b->lid);
+}
+
+static int extend_dpath(ib_dr_path_t * path, int nextport)
+{
+ if (path->cnt + 2 >= sizeof(path->p))
+ return -1;
+ ++path->cnt;
+ path->p[path->cnt] = (uint8_t) nextport;
+ return path->cnt;
+}
+
+static void dump_endnode(int dump, char *prompt, Node * node, Port * port)
+{
+ char *nodename = NULL;
+
+ if (!dump)
+ return;
+ if (dump == 1) {
+ fprintf(f, "%s {0x%016" PRIx64 "}[%d]\n",
+ prompt, node->nodeguid,
+ node->type == IB_NODE_SWITCH ? 0 : port->portnum);
+ return;
+ }
+
+ nodename =
+ remap_node_name(node_name_map, node->nodeguid, node->nodedesc);
+
+ fprintf(f, "%s %s {0x%016" PRIx64 "} portnum %d lid %u-%u \"%s\"\n",
+ prompt,
+ (node->type <= IB_NODE_MAX ? node_type_str[node->type] : "???"),
+ node->nodeguid,
+ node->type == IB_NODE_SWITCH ? 0 : port->portnum, port->lid,
+ port->lid + (1 << port->lmc) - 1, nodename);
+
+ free(nodename);
+}
+
+static void dump_route(int dump, Node * node, int outport, Port * port)
+{
+ char *nodename = NULL;
+
+ if (!dump && !ibverbose)
+ return;
+
+ nodename =
+ remap_node_name(node_name_map, node->nodeguid, node->nodedesc);
+
+ if (dump == 1)
+ fprintf(f, "[%d] -> {0x%016" PRIx64 "}[%d]\n",
+ outport, port->portguid, port->portnum);
+ else
+ fprintf(f, "[%d] -> %s port {0x%016" PRIx64
+ "}[%d] lid %u-%u \"%s\"\n", outport,
+ (node->type <=
+ IB_NODE_MAX ? node_type_str[node->type] : "???"),
+ port->portguid, port->portnum, port->lid,
+ port->lid + (1 << port->lmc) - 1, nodename);
+
+ free(nodename);
+}
+
+static int find_route(ib_portid_t * from, ib_portid_t * to, int dump)
+{
+ Node *node, fromnode, tonode, nextnode;
+ Port *port, fromport, toport, nextport;
+ Switch sw;
+ int maxhops = MAXHOPS;
+ int portnum, outport = 255, next_sw_outport = 255;
+
+ memset(&fromnode,0,sizeof(Node));
+ memset(&tonode,0,sizeof(Node));
+ memset(&nextnode,0,sizeof(Node));
+ memset(&fromport,0,sizeof(Port));
+ memset(&toport,0,sizeof(Port));
+ memset(&nextport,0,sizeof(Port));
+
+ DEBUG("from %s", portid2str(from));
+
+ if (get_node(&fromnode, &fromport, from) < 0 ||
+ get_node(&tonode, &toport, to) < 0) {
+ IBWARN("can't reach to/from ports");
+ if (!force)
+ return -1;
+ if (to->lid > 0)
+ toport.lid = to->lid;
+ IBWARN("Force: look for lid %d", to->lid);
+ }
+
+ node = &fromnode;
+ port = &fromport;
+ portnum = port->portnum;
+
+ dump_endnode(dump, "From", node, port);
+ if (node->type == IB_NODE_SWITCH) {
+ next_sw_outport = switch_lookup(&sw, from, to->lid);
+ if (next_sw_outport < 0 || next_sw_outport > node->numports) {
+ /* Need to print the port in badtbl */
+ outport = next_sw_outport;
+ goto badtbl;
+ }
+ }
+
+ while (maxhops--) {
+ if (is_port_inactive(node, port, &sw))
+ goto badport;
+
+ if (sameport(port, &toport))
+ break; /* found */
+
+ if (node->type == IB_NODE_SWITCH) {
+ DEBUG("switch node");
+ outport = next_sw_outport;
+
+ if (extend_dpath(&from->drpath, outport) < 0)
+ goto badpath;
+
+ if (get_node(&nextnode, &nextport, from) < 0) {
+ IBWARN("can't reach port at %s",
+ portid2str(from));
+ return -1;
+ }
+ if (outport == 0) {
+ if (!sameport(&nextport, &toport))
+ goto badtbl;
+ else
+ break; /* found SMA port */
+ }
+ } else if ((node->type == IB_NODE_CA) ||
+ (node->type == IB_NODE_ROUTER)) {
+ int ca_src = 0;
+
+ outport = portnum;
+ DEBUG("ca or router node");
+ if (!sameport(port, &fromport)) {
+ IBWARN
+ ("can't continue: reached CA or router port %"
+ PRIx64 ", lid %d", port->portguid,
+ port->lid);
+ return -1;
+ }
+ /* we are at CA or router "from" - go one hop back to (hopefully) a switch */
+ if (from->drpath.cnt > 0) {
+ DEBUG("ca or router node - return back 1 hop");
+ from->drpath.cnt--;
+ } else {
+ ca_src = 1;
+ if (portnum
+ && extend_dpath(&from->drpath, portnum) < 0)
+ goto badpath;
+ }
+ if (get_node(&nextnode, &nextport, from) < 0) {
+ IBWARN("can't reach port at %s",
+ portid2str(from));
+ return -1;
+ }
+ /* fix port num to be seen from the CA or router side */
+ if (!ca_src)
+ nextport.portnum =
+ from->drpath.p[from->drpath.cnt + 1];
+ }
+ /* only if the next node is a switch, get switch info */
+ if (nextnode.type == IB_NODE_SWITCH) {
+ next_sw_outport = switch_lookup(&sw, from, to->lid);
+ if (next_sw_outport < 0 ||
+ next_sw_outport > nextnode.numports) {
+ /* needed to print the port in badtbl */
+ outport = next_sw_outport;
+ goto badtbl;
+ }
+ }
+
+ port = &nextport;
+ if (is_port_inactive(&nextnode, port, &sw))
+ goto badoutport;
+ node = &nextnode;
+ portnum = port->portnum;
+ dump_route(dump, node, outport, port);
+ }
+
+ if (maxhops <= 0) {
+ IBWARN("no route found after %d hops", MAXHOPS);
+ return -1;
+ }
+ dump_endnode(dump, "To", node, port);
+ return 0;
+
+badport:
+ IBWARN("Bad port state found: node \"%s\" port %d state %d",
+ clean_nodedesc(node->nodedesc), portnum, port->state);
+ return -1;
+badoutport:
+ IBWARN("Bad out port state found: node \"%s\" outport %d state %d",
+ clean_nodedesc(node->nodedesc), outport, port->state);
+ return -1;
+badtbl:
+ IBWARN
+ ("Bad forwarding table entry found at: node \"%s\" lid entry %d is %d (top %d)",
+ clean_nodedesc(node->nodedesc), to->lid, outport, sw.linearFDBtop);
+ return -1;
+badpath:
+ IBWARN("Direct path too long!");
+ return -1;
+}
+
+/**************************
+ * MC span part
+ */
+
+#define HASHGUID(guid) ((uint32_t)(((uint32_t)(guid) * 101) ^ ((uint32_t)((guid) >> 32) * 103)))
+#define HTSZ 137
+
+static int insert_node(Node * new)
+{
+ static Node *nodestbl[HTSZ];
+ int hash = HASHGUID(new->nodeguid) % HTSZ;
+ Node *node;
+
+ for (node = nodestbl[hash]; node; node = node->htnext)
+ if (node->nodeguid == new->nodeguid) {
+ DEBUG("node %" PRIx64 " already exists", new->nodeguid);
+ return -1;
+ }
+
+ new->htnext = nodestbl[hash];
+ nodestbl[hash] = new;
+
+ return 0;
+}
+
+static int get_port(Port * port, int portnum, ib_portid_t * portid)
+{
+ char portinfo[64] = { 0 };
+ void *pi = portinfo;
+
+ port->portnum = portnum;
+
+ if (!smp_query_via(pi, portid, IB_ATTR_PORT_INFO, portnum, timeout,
+ srcport))
+ return -1;
+
+ mad_decode_field(pi, IB_PORT_LID_F, &port->lid);
+ mad_decode_field(pi, IB_PORT_LMC_F, &port->lmc);
+ mad_decode_field(pi, IB_PORT_STATE_F, &port->state);
+ mad_decode_field(pi, IB_PORT_PHYS_STATE_F, &port->physstate);
+
+ VERBOSE("portid %s portnum %d: lid %d state %d physstate %d",
+ portid2str(portid), portnum, port->lid, port->state,
+ port->physstate);
+ return 1;
+}
+
+static void link_port(Port * port, Node * node)
+{
+ port->next = node->ports;
+ node->ports = port;
+}
+
+static int new_node(Node * node, Port * port, ib_portid_t * path, int dist)
+{
+ if (port->portguid == target_portguid) {
+ node->dist = -1; /* tag as target */
+ link_port(port, node);
+ dump_endnode(ibverbose, "found target", node, port);
+ return 1; /* found; */
+ }
+
+ /* BFS search start with my self */
+ if (insert_node(node) < 0)
+ return -1; /* known switch */
+
+ VERBOSE("insert dist %d node %p port %d lid %d", dist, node,
+ port->portnum, port->lid);
+
+ link_port(port, node);
+
+ node->dist = dist;
+ node->path = *path;
+ node->dnext = nodesdist[dist];
+ nodesdist[dist] = node;
+
+ return 0;
+}
+
+static int switch_mclookup(Node * node, ib_portid_t * portid, int mlid,
+ char *map)
+{
+ Switch sw;
+ char mdb[64];
+ void *si = sw.switchinfo;
+ uint16_t *msets = (uint16_t *) mdb;
+ int maxsets, block, i, set;
+
+ memset(map, 0, 256);
+
+ memset(si, 0, sizeof(sw.switchinfo));
+ if (!smp_query_via(si, portid, IB_ATTR_SWITCH_INFO, 0, timeout,
+ srcport))
+ return -1;
+
+ mlid -= 0xc000;
+
+ mad_decode_field(si, IB_SW_MCAST_FDB_CAP_F, &sw.mccap);
+
+ if (mlid >= sw.mccap)
+ return -1;
+
+ block = mlid / 32;
+ maxsets = (node->numports + 15) / 16; /* round up */
+
+ for (set = 0; set < maxsets; set++) {
+ memset(mdb, 0, sizeof(mdb));
+ if (!smp_query_via(mdb, portid, IB_ATTR_MULTICASTFORWTBL,
+ block | (set << 28), timeout, srcport))
+ return -1;
+
+ for (i = 0; i < 16; i++, map++) {
+ uint16_t mask = ntohs(msets[mlid % 32]);
+ if (mask & (1 << i))
+ *map = 1;
+ else
+ continue;
+ VERBOSE("Switch guid 0x%" PRIx64
+ ": mlid 0x%x is forwarded to port %d",
+ node->nodeguid, mlid + 0xc000, i + set * 16);
+ }
+ }
+
+ return 0;
+}
+
+/*
+ * Return 1 if found, 0 if not, -1 on errors.
+ */
+static Node *find_mcpath(ib_portid_t * from, int mlid)
+{
+ Node *node, *remotenode;
+ Port *port, *remoteport;
+ char map[256];
+ int r, i;
+ int dist = 0, leafport = 0;
+ ib_portid_t *path;
+
+ DEBUG("from %s", portid2str(from));
+
+ if (!(node = calloc(1, sizeof(Node))))
+ IBEXIT("out of memory");
+
+ if (!(port = calloc(1, sizeof(Port))))
+ IBEXIT("out of memory");
+
+ if (get_node(node, port, from) < 0) {
+ IBWARN("can't reach node %s", portid2str(from));
+ return 0;
+ }
+
+ node->upnode = 0; /* root */
+ if ((r = new_node(node, port, from, 0)) > 0) {
+ if (node->type != IB_NODE_SWITCH) {
+ IBWARN("ibtracert from CA to CA is unsupported");
+ return 0; /* ibtracert from host to itself is unsupported */
+ }
+
+ if (switch_mclookup(node, from, mlid, map) < 0 || !map[0])
+ return 0;
+ return node;
+ }
+
+ for (dist = 0; dist < MAXHOPS; dist++) {
+
+ for (node = nodesdist[dist]; node; node = node->dnext) {
+
+ path = &node->path;
+
+ VERBOSE("dist %d node %p", dist, node);
+ dump_endnode(ibverbose, "processing", node,
+ node->ports);
+
+ memset(map, 0, sizeof(map));
+
+ if (node->type != IB_NODE_SWITCH) {
+ if (dist)
+ continue;
+ leafport = path->drpath.p[path->drpath.cnt];
+ map[port->portnum] = 1;
+ node->upport = 0; /* starting here */
+ DEBUG("Starting from CA 0x%" PRIx64
+ " lid %d port %d (leafport %d)",
+ node->nodeguid, port->lid, port->portnum,
+ leafport);
+ } else { /* switch */
+
+ /* if starting from a leaf port fix up port (up port) */
+ if (dist == 1 && leafport)
+ node->upport = leafport;
+
+ if (switch_mclookup(node, path, mlid, map) < 0) {
+ IBWARN("skipping bad Switch 0x%" PRIx64
+ "", node->nodeguid);
+ continue;
+ }
+ }
+
+ for (i = 1; i <= node->numports; i++) {
+ if (!map[i] || i == node->upport)
+ continue;
+
+ if (dist == 0 && leafport) {
+ if (from->drpath.cnt > 0)
+ path->drpath.cnt--;
+ } else {
+ if (!(port = calloc(1, sizeof(Port))))
+ IBEXIT("out of memory");
+
+ if (get_port(port, i, path) < 0) {
+ IBWARN
+ ("can't reach node %s port %d",
+ portid2str(path), i);
+ free(port);
+ return 0;
+ }
+
+ if (port->physstate != 5) { /* LinkUP */
+ free(port);
+ continue;
+ }
+#if 0
+ link_port(port, node);
+#endif
+
+ if (extend_dpath(&path->drpath, i) < 0) {
+ free(port);
+ return 0;
+ }
+ }
+
+ if (!(remotenode = calloc(1, sizeof(Node))))
+ IBEXIT("out of memory");
+
+ if (!(remoteport = calloc(1, sizeof(Port))))
+ IBEXIT("out of memory");
+
+ if (get_node(remotenode, remoteport, path) < 0) {
+ IBWARN
+ ("NodeInfo on %s port %d failed, skipping port",
+ portid2str(path), i);
+ path->drpath.cnt--; /* restore path */
+ free(remotenode);
+ free(remoteport);
+ continue;
+ }
+
+ remotenode->upnode = node;
+ remotenode->upport = remoteport->portnum;
+ remoteport->remoteport = port;
+
+ if ((r = new_node(remotenode, remoteport, path,
+ dist + 1)) > 0)
+ return remotenode;
+
+ if (r == 0)
+ dump_endnode(ibverbose, "new remote",
+ remotenode, remoteport);
+ else if (remotenode->type == IB_NODE_SWITCH)
+ dump_endnode(2,
+ "ERR: circle discovered at",
+ remotenode, remoteport);
+
+ path->drpath.cnt--; /* restore path */
+ }
+ }
+ }
+
+ return 0; /* not found */
+}
+
+static uint64_t find_target_portguid(ib_portid_t * to)
+{
+ Node tonode;
+ Port toport;
+
+ if (get_node(&tonode, &toport, to) < 0) {
+ IBWARN("can't find to port\n");
+ return -1;
+ }
+
+ return toport.portguid;
+}
+
+static void dump_mcpath(Node * node, int dumplevel)
+{
+ char *nodename = NULL;
+
+ if (node->upnode)
+ dump_mcpath(node->upnode, dumplevel);
+
+ nodename =
+ remap_node_name(node_name_map, node->nodeguid, node->nodedesc);
+
+ if (!node->dist) {
+ printf("From %s 0x%" PRIx64 " port %d lid %u-%u \"%s\"\n",
+ (node->type <=
+ IB_NODE_MAX ? node_type_str[node->type] : "???"),
+ node->nodeguid, node->ports->portnum, node->ports->lid,
+ node->ports->lid + (1 << node->ports->lmc) - 1,
+ nodename);
+ goto free_name;
+ }
+
+ if (node->dist) {
+ if (dumplevel == 1)
+ printf("[%d] -> %s {0x%016" PRIx64 "}[%d]\n",
+ node->ports->remoteport->portnum,
+ (node->type <=
+ IB_NODE_MAX ? node_type_str[node->type] :
+ "???"), node->nodeguid, node->upport);
+ else
+ printf("[%d] -> %s 0x%" PRIx64 "[%d] lid %u \"%s\"\n",
+ node->ports->remoteport->portnum,
+ (node->type <=
+ IB_NODE_MAX ? node_type_str[node->type] :
+ "???"), node->nodeguid, node->upport,
+ node->ports->lid, nodename);
+ }
+
+ if (node->dist < 0)
+ /* target node */
+ printf("To %s 0x%" PRIx64 " port %d lid %u-%u \"%s\"\n",
+ (node->type <=
+ IB_NODE_MAX ? node_type_str[node->type] : "???"),
+ node->nodeguid, node->ports->portnum, node->ports->lid,
+ node->ports->lid + (1 << node->ports->lmc) - 1,
+ nodename);
+
+free_name:
+ free(nodename);
+}
+
+static int resolve_lid(ib_portid_t * portid, const void *srcport)
+{
+ uint8_t portinfo[64] = { 0 };
+ uint16_t lid;
+
+ if (!smp_query_via(portinfo, portid, IB_ATTR_PORT_INFO, 0, 0, srcport))
+ return -1;
+ mad_decode_field(portinfo, IB_PORT_LID_F, &lid);
+
+ ib_portid_set(portid, lid, 0, 0);
+
+ return 0;
+}
+
+static int dumplevel = 2, multicast, mlid;
+
+static int process_opt(void *context, int ch, char *optarg)
+{
+ switch (ch) {
+ case 1:
+ node_name_map_file = strdup(optarg);
+ break;
+ case 'm':
+ multicast++;
+ mlid = strtoul(optarg, 0, 0);
+ break;
+ case 'f':
+ force++;
+ break;
+ case 'n':
+ dumplevel = 1;
+ break;
+ default:
+ return -1;
+ }
+ return 0;
+}
+
+int main(int argc, char **argv)
+{
+ int mgmt_classes[3] =
+ { IB_SMI_CLASS, IB_SMI_DIRECT_CLASS, IB_SA_CLASS };
+ ib_portid_t my_portid = { 0 };
+ ib_portid_t src_portid = { 0 };
+ ib_portid_t dest_portid = { 0 };
+ Node *endnode;
+
+ const struct ibdiag_opt opts[] = {
+ {"force", 'f', 0, NULL, "force"},
+ {"no_info", 'n', 0, NULL, "simple format"},
+ {"mlid", 'm', 1, "<mlid>", "multicast trace of the mlid"},
+ {"node-name-map", 1, 1, "<file>", "node name map file"},
+ {0}
+ };
+ char usage_args[] = "<src-addr> <dest-addr>";
+ const char *usage_examples[] = {
+ "- Unicast examples:",
+ "4 16\t\t\t# show path between lids 4 and 16",
+ "-n 4 16\t\t# same, but using simple output format",
+ "-G 0x8f1040396522d 0x002c9000100d051\t# use guid addresses",
+
+ " - Multicast examples:",
+ "-m 0xc000 4 16\t# show multicast path of mlid 0xc000 between lids 4 and 16",
+ NULL,
+ };
+
+ ibdiag_process_opts(argc, argv, NULL, "DK", opts, process_opt,
+ usage_args, usage_examples);
+
+ f = stdout;
+ argc -= optind;
+ argv += optind;
+
+ if (argc < 2)
+ ibdiag_show_usage();
+
+ if (ibd_timeout)
+ timeout = ibd_timeout;
+
+ srcport = mad_rpc_open_port(ibd_ca, ibd_ca_port, mgmt_classes, 3);
+ if (!srcport)
+ IBEXIT("Failed to open '%s' port '%d'", ibd_ca, ibd_ca_port);
+
+ smp_mkey_set(srcport, ibd_mkey);
+
+ node_name_map = open_node_name_map(node_name_map_file);
+
+ if (resolve_portid_str(ibd_ca, ibd_ca_port, &src_portid, argv[0],
+ ibd_dest_type, ibd_sm_id, srcport) < 0)
+ IBEXIT("can't resolve source port %s", argv[0]);
+
+ if (resolve_portid_str(ibd_ca, ibd_ca_port, &dest_portid, argv[1],
+ ibd_dest_type, ibd_sm_id, srcport) < 0)
+ IBEXIT("can't resolve destination port %s", argv[1]);
+
+ if (ibd_dest_type == IB_DEST_DRPATH) {
+ if (resolve_lid(&src_portid, NULL) < 0)
+ IBEXIT("cannot resolve lid for port \'%s\'",
+ portid2str(&src_portid));
+ if (resolve_lid(&dest_portid, NULL) < 0)
+ IBEXIT("cannot resolve lid for port \'%s\'",
+ portid2str(&dest_portid));
+ }
+
+ if (dest_portid.lid == 0 || src_portid.lid == 0) {
+ IBWARN("bad src/dest lid");
+ ibdiag_show_usage();
+ }
+
+ if (ibd_dest_type != IB_DEST_DRPATH) {
+ /* first find a direct path to the src port */
+ if (find_route(&my_portid, &src_portid, 0) < 0)
+ IBEXIT("can't find a route to the src port");
+
+ src_portid = my_portid;
+ }
+
+ if (!multicast) {
+ if (find_route(&src_portid, &dest_portid, dumplevel) < 0)
+ IBEXIT("can't find a route from src to dest");
+ exit(0);
+ } else {
+ if (mlid < 0xc000)
+ IBWARN("invalid MLID; must be 0xc000 or larger");
+ }
+
+ if (!(target_portguid = find_target_portguid(&dest_portid)))
+ IBEXIT("can't reach target lid %d", dest_portid.lid);
+
+ if (!(endnode = find_mcpath(&src_portid, mlid)))
+ IBEXIT("can't find a multicast route from src to dest");
+
+ /* dump multicast path */
+ dump_mcpath(endnode, dumplevel);
+
+ close_node_name_map(node_name_map);
+
+ mad_rpc_close_port(srcport);
+
+ exit(0);
+}
diff --git a/contrib/ofed/infiniband-diags/src/mcm_rereg_test.c b/contrib/ofed/infiniband-diags/src/mcm_rereg_test.c
new file mode 100644
index 0000000..a8cce8b
--- /dev/null
+++ b/contrib/ofed/infiniband-diags/src/mcm_rereg_test.c
@@ -0,0 +1,399 @@
+/*
+ * Copyright (c) 2006-2009 Voltaire, Inc. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+#if HAVE_CONFIG_H
+# include <config.h>
+#endif /* HAVE_CONFIG_H */
+
+#include <stdio.h>
+#include <string.h>
+#include <errno.h>
+#include <inttypes.h>
+
+#include <infiniband/umad.h>
+#include <infiniband/mad.h>
+#include <infiniband/iba/ib_types.h>
+
+#include "ibdiag_common.h"
+
+#define info(fmt, ...) fprintf(stderr, "INFO: " fmt, ## __VA_ARGS__ )
+#define err(fmt, ...) fprintf(stderr, "ERR: " fmt, ## __VA_ARGS__ )
+#ifdef NOISY_DEBUG
+#define dbg(fmt, ...) fprintf(stderr, "DBG: " fmt, ## __VA_ARGS__ )
+#else
+#define dbg(fmt, ...)
+#endif
+
+#define TMO 100
+
+static ibmad_gid_t mgid_ipoib = {
+ 0xff, 0x12, 0x40, 0x1b, 0xff, 0xff, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff
+};
+
+struct ibmad_port *srcport;
+
+uint64_t build_mcm_rec(uint8_t * data, ibmad_gid_t mgid, ibmad_gid_t port_gid)
+{
+ memset(data, 0, IB_SA_DATA_SIZE);
+ mad_set_array(data, 0, IB_SA_MCM_MGID_F, mgid);
+ mad_set_array(data, 0, IB_SA_MCM_PORTGID_F, port_gid);
+ mad_set_field(data, 0, IB_SA_MCM_JOIN_STATE_F, 1);
+
+ return IB_MCR_COMPMASK_MGID | IB_MCR_COMPMASK_PORT_GID |
+ IB_MCR_COMPMASK_JOIN_STATE;
+}
+
+static void build_mcm_rec_umad(void *umad, ib_portid_t * dport, int method,
+ uint64_t comp_mask, uint8_t * data)
+{
+ ib_rpc_t rpc;
+
+ memset(&rpc, 0, sizeof(rpc));
+ rpc.mgtclass = IB_SA_CLASS;
+ rpc.method = method;
+ rpc.attr.id = IB_SA_ATTR_MCRECORD;
+ rpc.attr.mod = 0; // ???
+ rpc.mask = comp_mask;
+ rpc.datasz = IB_SA_DATA_SIZE;
+ rpc.dataoffs = IB_SA_DATA_OFFS;
+
+ mad_build_pkt(umad, &rpc, dport, NULL, data);
+}
+
+static int rereg_send(int port, int agent, ib_portid_t * dport,
+ uint8_t * umad, int len, int method, ibmad_gid_t port_gid)
+{
+ uint8_t data[IB_SA_DATA_SIZE];
+ uint64_t comp_mask;
+
+ comp_mask = build_mcm_rec(data, mgid_ipoib, port_gid);
+
+ build_mcm_rec_umad(umad, dport, method, comp_mask, data);
+ if (umad_send(port, agent, umad, len, TMO, 0) < 0) {
+ err("umad_send %s failed: %s\n",
+ (method == IB_MAD_METHOD_GET) ? "query" : "non query",
+ strerror(errno));
+ return -1;
+ }
+ dbg("umad_send %d: tid = 0x%016" PRIx64 "\n", method,
+ mad_get_field64(umad_get_mad(umad), 0, IB_MAD_TRID_F));
+
+ return 0;
+}
+
+static int rereg_port_gid(int port, int agent, ib_portid_t * dport,
+ uint8_t * umad, int len, ibmad_gid_t port_gid)
+{
+ uint8_t data[IB_SA_DATA_SIZE];
+ uint64_t comp_mask;
+
+ comp_mask = build_mcm_rec(data, mgid_ipoib, port_gid);
+
+ build_mcm_rec_umad(umad, dport, IB_MAD_METHOD_DELETE, comp_mask, data);
+ if (umad_send(port, agent, umad, len, TMO, 0) < 0) {
+ err("umad_send leave failed: %s\n", strerror(errno));
+ return -1;
+ }
+ dbg("umad_send leave: tid = 0x%016" PRIx64 "\n",
+ mad_get_field64(umad_get_mad(umad), 0, IB_MAD_TRID_F));
+
+ build_mcm_rec_umad(umad, dport, IB_MAD_METHOD_SET, comp_mask, data);
+ if (umad_send(port, agent, umad, len, TMO, 0) < 0) {
+ err("umad_send join failed: %s\n", strerror(errno));
+ return -1;
+ }
+ dbg("umad_send join: tid = 0x%016" PRIx64 "\n",
+ mad_get_field64(umad_get_mad(umad), 0, IB_MAD_TRID_F));
+
+ return 0;
+}
+
+struct guid_trid {
+ ibmad_gid_t gid;
+ uint64_t guid;
+ uint64_t trid;
+};
+
+static int rereg_send_all(int port, int agent, ib_portid_t * dport,
+ struct guid_trid *list, unsigned cnt)
+{
+ uint8_t *umad;
+ int len = umad_size() + 256;
+ unsigned i;
+ int ret;
+
+ info("rereg_send_all... cnt = %u\n", cnt);
+
+ umad = calloc(1, len);
+ if (!umad) {
+ err("cannot alloc mem for umad: %s\n", strerror(errno));
+ return -1;
+ }
+
+ for (i = 0; i < cnt; i++) {
+ ret =
+ rereg_port_gid(port, agent, dport, umad, len, list[i].gid);
+ if (ret < 0) {
+ err("rereg_send_all: rereg_port_gid 0x%016" PRIx64
+ " failed\n", ntohll(list[i].guid));
+ continue;
+ }
+ list[i].trid = mad_get_field64(umad_get_mad(umad), 0,
+ IB_MAD_TRID_F);
+ }
+
+ info("rereg_send_all: sent %u requests\n", cnt * 2);
+
+ free(umad);
+
+ return 0;
+}
+
+static int rereg_recv(int port, int agent, ib_portid_t * dport,
+ uint8_t * umad, int length, int tmo)
+{
+ int ret, retry = 0;
+ int len = length;
+
+ while ((ret = umad_recv(port, umad, &len, tmo)) < 0 &&
+ errno == ETIMEDOUT) {
+ if (retry++ > 3)
+ return 0;
+ }
+ if (ret < 0) {
+ err("umad_recv %d failed: %s\n", ret, strerror(errno));
+ return -1;
+ }
+ dbg("umad_recv (retries %d), tid = 0x%016" PRIx64
+ ": len = %d, status = %d\n", retry,
+ mad_get_field64(umad_get_mad(umad), 0, IB_MAD_TRID_F), len,
+ umad_status(umad));
+
+ return 1;
+}
+
+static int rereg_recv_all(int port, int agent, ib_portid_t * dport,
+ struct guid_trid *list, unsigned cnt)
+{
+ uint8_t *umad, *mad;
+ int len = umad_size() + 256;
+ uint64_t trid;
+ unsigned n, method, status;
+ unsigned i;
+
+ info("rereg_recv_all...\n");
+
+ umad = calloc(1, len);
+ if (!umad) {
+ err("cannot alloc mem for umad: %s\n", strerror(errno));
+ return -1;
+ }
+
+ n = 0;
+ while (rereg_recv(port, agent, dport, umad, len, TMO) > 0) {
+ dbg("rereg_recv_all: done %d\n", n);
+ n++;
+ mad = umad_get_mad(umad);
+
+ method = mad_get_field(mad, 0, IB_MAD_METHOD_F);
+ status = mad_get_field(mad, 0, IB_MAD_STATUS_F);
+
+ if (status)
+ dbg("MAD status %x, method %x\n", status, method);
+
+ if (status &&
+ (method & 0x7f) == (IB_MAD_METHOD_GET_RESPONSE & 0x7f)) {
+ trid = mad_get_field64(mad, 0, IB_MAD_TRID_F);
+ for (i = 0; i < cnt; i++)
+ if (trid == list[i].trid)
+ break;
+ if (i == cnt) {
+ err("cannot find trid 0x%016" PRIx64 "\n",
+ trid);
+ continue;
+ }
+ info("guid 0x%016" PRIx64
+ ": method = %x status = %x. Resending\n",
+ ntohll(list[i].guid), method, status);
+ rereg_port_gid(port, agent, dport, umad, len,
+ list[i].gid);
+ list[i].trid =
+ mad_get_field64(umad_get_mad(umad), 0,
+ IB_MAD_TRID_F);
+ }
+ }
+
+ info("rereg_recv_all: got %u responses\n", n);
+
+ free(umad);
+ return 0;
+}
+
+static int rereg_query_all(int port, int agent, ib_portid_t * dport,
+ struct guid_trid *list, unsigned cnt)
+{
+ uint8_t *umad, *mad;
+ int len = umad_size() + 256;
+ unsigned method, status;
+ unsigned i;
+ int ret;
+
+ info("rereg_query_all...\n");
+
+ umad = calloc(1, len);
+ if (!umad) {
+ err("cannot alloc mem for umad: %s\n", strerror(errno));
+ return -1;
+ }
+
+ for (i = 0; i < cnt; i++) {
+ ret = rereg_send(port, agent, dport, umad, len,
+ IB_MAD_METHOD_GET, list[i].gid);
+ if (ret < 0) {
+ err("query_all: rereg_send failed.\n");
+ continue;
+ }
+
+ ret = rereg_recv(port, agent, dport, umad, len, TMO);
+ if (ret < 0) {
+ err("query_all: rereg_recv failed.\n");
+ continue;
+ }
+
+ mad = umad_get_mad(umad);
+
+ method = mad_get_field(mad, 0, IB_MAD_METHOD_F);
+ status = mad_get_field(mad, 0, IB_MAD_STATUS_F);
+
+ if (status)
+ info("guid 0x%016" PRIx64 ": status %x, method %x\n",
+ ntohll(list[i].guid), status, method);
+ }
+
+ info("rereg_query_all: %u queried.\n", cnt);
+
+ free(umad);
+ return 0;
+}
+
+#define MAX_CLIENTS 50
+
+static int rereg_and_test_port(char *guid_file, int port, int agent,
+ ib_portid_t * dport, int timeout)
+{
+ char line[256];
+ FILE *f;
+ ibmad_gid_t port_gid;
+ uint64_t prefix = htonll(0xfe80000000000000ull);
+ uint64_t guid = htonll(0x0002c90200223825ull);
+ struct guid_trid *list;
+ int i = 0;
+
+ list = calloc(MAX_CLIENTS, sizeof(*list));
+ if (!list) {
+ err("cannot alloc mem for guid/trid list: %s\n",
+ strerror(errno));
+ return -1;
+ }
+
+ f = fopen(guid_file, "r");
+ if (!f) {
+ err("cannot open %s: %s\n", guid_file, strerror(errno));
+ return -1;
+ }
+
+ while (fgets(line, sizeof(line), f)) {
+ guid = strtoull(line, NULL, 0);
+ guid = htonll(guid);
+ memcpy(&port_gid[0], &prefix, 8);
+ memcpy(&port_gid[8], &guid, 8);
+
+ list[i].guid = guid;
+ memcpy(list[i].gid, port_gid, sizeof(list[i].gid));
+ list[i].trid = 0;
+ if (++i >= MAX_CLIENTS)
+ break;
+ }
+ fclose(f);
+
+ rereg_send_all(port, agent, dport, list, i);
+ rereg_recv_all(port, agent, dport, list, i);
+
+ rereg_query_all(port, agent, dport, list, i);
+
+ free(list);
+ return 0;
+}
+
+int main(int argc, char **argv)
+{
+ char *guid_file = "port_guids.list";
+ int mgmt_classes[2] = { IB_SMI_CLASS, IB_SMI_DIRECT_CLASS };
+ ib_portid_t dport_id;
+ int port, agent;
+ uint8_t *umad, *mad;
+ int len;
+
+ if (argc > 1)
+ guid_file = argv[1];
+
+ srcport = mad_rpc_open_port(NULL, 0, mgmt_classes, 2);
+ if (!srcport)
+ err("Failed to open port");
+
+ resolve_sm_portid(NULL, 0, &dport_id);
+ dport_id.qp = 1;
+ if (!dport_id.qkey)
+ dport_id.qkey = IB_DEFAULT_QP1_QKEY;
+
+ len = umad_size() + 256;
+ umad = calloc(1, len);
+ if (!umad) {
+ err("cannot alloc mem for umad: %s\n", strerror(errno));
+ return -1;
+ }
+ port = mad_rpc_portid(srcport);
+
+ agent = umad_register(port, IB_SA_CLASS, 2, 0, NULL);
+
+ rereg_and_test_port(guid_file, port, agent, &dport_id, TMO);
+ mad = umad_get_mad(umad);
+
+ free(umad);
+ umad_unregister(port, agent);
+ umad_close_port(port);
+ umad_done();
+
+ return 0;
+}
diff --git a/contrib/ofed/infiniband-diags/src/perfquery.c b/contrib/ofed/infiniband-diags/src/perfquery.c
new file mode 100644
index 0000000..55d65de
--- /dev/null
+++ b/contrib/ofed/infiniband-diags/src/perfquery.c
@@ -0,0 +1,1122 @@
+/*
+ * Copyright (c) 2004-2009 Voltaire Inc. All rights reserved.
+ * Copyright (c) 2007 Xsigo Systems Inc. All rights reserved.
+ * Copyright (c) 2009 HNR Consulting. All rights reserved.
+ * Copyright (c) 2011 Mellanox Technologies LTD. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+#if HAVE_CONFIG_H
+# include <config.h>
+#endif /* HAVE_CONFIG_H */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <getopt.h>
+#include <netinet/in.h>
+
+#include <infiniband/umad.h>
+#include <infiniband/mad.h>
+#include <infiniband/iba/ib_types.h>
+
+#include "ibdiag_common.h"
+
+struct ibmad_port *srcport;
+
+static ibmad_gid_t dgid;
+static int with_grh;
+
+struct perf_count {
+ uint32_t portselect;
+ uint32_t counterselect;
+ uint32_t symbolerrors;
+ uint32_t linkrecovers;
+ uint32_t linkdowned;
+ uint32_t rcverrors;
+ uint32_t rcvremotephyerrors;
+ uint32_t rcvswrelayerrors;
+ uint32_t xmtdiscards;
+ uint32_t xmtconstrainterrors;
+ uint32_t rcvconstrainterrors;
+ uint32_t linkintegrityerrors;
+ uint32_t excbufoverrunerrors;
+ uint32_t qp1dropped;
+ uint32_t vl15dropped;
+ uint32_t xmtdata;
+ uint32_t rcvdata;
+ uint32_t xmtpkts;
+ uint32_t rcvpkts;
+ uint32_t xmtwait;
+};
+
+struct perf_count_ext {
+ uint32_t portselect;
+ uint32_t counterselect;
+ uint64_t portxmitdata;
+ uint64_t portrcvdata;
+ uint64_t portxmitpkts;
+ uint64_t portrcvpkts;
+ uint64_t portunicastxmitpkts;
+ uint64_t portunicastrcvpkts;
+ uint64_t portmulticastxmitpkits;
+ uint64_t portmulticastrcvpkts;
+
+ uint32_t counterSelect2;
+ uint64_t symbolErrorCounter;
+ uint64_t linkErrorRecoveryCounter;
+ uint64_t linkDownedCounter;
+ uint64_t portRcvErrors;
+ uint64_t portRcvRemotePhysicalErrors;
+ uint64_t portRcvSwitchRelayErrors;
+ uint64_t portXmitDiscards;
+ uint64_t portXmitConstraintErrors;
+ uint64_t portRcvConstraintErrors;
+ uint64_t localLinkIntegrityErrors;
+ uint64_t excessiveBufferOverrunErrors;
+ uint64_t VL15Dropped;
+ uint64_t portXmitWait;
+ uint64_t QP1Dropped;
+};
+
+static uint8_t pc[1024];
+
+struct perf_count perf_count = {0};
+struct perf_count_ext perf_count_ext = {0};
+
+#define ALL_PORTS 0xFF
+#define MAX_PORTS 255
+
+/* Notes: IB semantics is to cap counters if count has exceeded limits.
+ * Therefore we must check for overflows and cap the counters if necessary.
+ *
+ * mad_decode_field and mad_encode_field assume 32 bit integers passed in
+ * for fields < 32 bits in length.
+ */
+
+static void aggregate_4bit(uint32_t * dest, uint32_t val)
+{
+ if ((((*dest) + val) < (*dest)) || ((*dest) + val) > 0xf)
+ (*dest) = 0xf;
+ else
+ (*dest) = (*dest) + val;
+}
+
+static void aggregate_8bit(uint32_t * dest, uint32_t val)
+{
+ if ((((*dest) + val) < (*dest))
+ || ((*dest) + val) > 0xff)
+ (*dest) = 0xff;
+ else
+ (*dest) = (*dest) + val;
+}
+
+static void aggregate_16bit(uint32_t * dest, uint32_t val)
+{
+ if ((((*dest) + val) < (*dest))
+ || ((*dest) + val) > 0xffff)
+ (*dest) = 0xffff;
+ else
+ (*dest) = (*dest) + val;
+}
+
+static void aggregate_32bit(uint32_t * dest, uint32_t val)
+{
+ if (((*dest) + val) < (*dest))
+ (*dest) = 0xffffffff;
+ else
+ (*dest) = (*dest) + val;
+}
+
+static void aggregate_64bit(uint64_t * dest, uint64_t val)
+{
+ if (((*dest) + val) < (*dest))
+ (*dest) = 0xffffffffffffffffULL;
+ else
+ (*dest) = (*dest) + val;
+}
+
+static void aggregate_perfcounters(void)
+{
+ uint32_t val;
+
+ mad_decode_field(pc, IB_PC_PORT_SELECT_F, &val);
+ perf_count.portselect = val;
+ mad_decode_field(pc, IB_PC_COUNTER_SELECT_F, &val);
+ perf_count.counterselect = val;
+ mad_decode_field(pc, IB_PC_ERR_SYM_F, &val);
+ aggregate_16bit(&perf_count.symbolerrors, val);
+ mad_decode_field(pc, IB_PC_LINK_RECOVERS_F, &val);
+ aggregate_8bit(&perf_count.linkrecovers, val);
+ mad_decode_field(pc, IB_PC_LINK_DOWNED_F, &val);
+ aggregate_8bit(&perf_count.linkdowned, val);
+ mad_decode_field(pc, IB_PC_ERR_RCV_F, &val);
+ aggregate_16bit(&perf_count.rcverrors, val);
+ mad_decode_field(pc, IB_PC_ERR_PHYSRCV_F, &val);
+ aggregate_16bit(&perf_count.rcvremotephyerrors, val);
+ mad_decode_field(pc, IB_PC_ERR_SWITCH_REL_F, &val);
+ aggregate_16bit(&perf_count.rcvswrelayerrors, val);
+ mad_decode_field(pc, IB_PC_XMT_DISCARDS_F, &val);
+ aggregate_16bit(&perf_count.xmtdiscards, val);
+ mad_decode_field(pc, IB_PC_ERR_XMTCONSTR_F, &val);
+ aggregate_8bit(&perf_count.xmtconstrainterrors, val);
+ mad_decode_field(pc, IB_PC_ERR_RCVCONSTR_F, &val);
+ aggregate_8bit(&perf_count.rcvconstrainterrors, val);
+ mad_decode_field(pc, IB_PC_ERR_LOCALINTEG_F, &val);
+ aggregate_4bit(&perf_count.linkintegrityerrors, val);
+ mad_decode_field(pc, IB_PC_ERR_EXCESS_OVR_F, &val);
+ aggregate_4bit(&perf_count.excbufoverrunerrors, val);
+#ifdef HAVE_IB_PC_QP1_DROP_F
+ mad_decode_field(pc, IB_PC_QP1_DROP_F, &val);
+ aggregate_16bit(&perf_count.qp1dropped, val);
+#endif
+ mad_decode_field(pc, IB_PC_VL15_DROPPED_F, &val);
+ aggregate_16bit(&perf_count.vl15dropped, val);
+ mad_decode_field(pc, IB_PC_XMT_BYTES_F, &val);
+ aggregate_32bit(&perf_count.xmtdata, val);
+ mad_decode_field(pc, IB_PC_RCV_BYTES_F, &val);
+ aggregate_32bit(&perf_count.rcvdata, val);
+ mad_decode_field(pc, IB_PC_XMT_PKTS_F, &val);
+ aggregate_32bit(&perf_count.xmtpkts, val);
+ mad_decode_field(pc, IB_PC_RCV_PKTS_F, &val);
+ aggregate_32bit(&perf_count.rcvpkts, val);
+ mad_decode_field(pc, IB_PC_XMT_WAIT_F, &val);
+ aggregate_32bit(&perf_count.xmtwait, val);
+}
+
+static void output_aggregate_perfcounters(ib_portid_t * portid,
+ uint16_t cap_mask)
+{
+ char buf[1024];
+ uint32_t val = ALL_PORTS;
+
+ /* set port_select to 255 to emulate AllPortSelect */
+ mad_encode_field(pc, IB_PC_PORT_SELECT_F, &val);
+ mad_encode_field(pc, IB_PC_COUNTER_SELECT_F, &perf_count.counterselect);
+ mad_encode_field(pc, IB_PC_ERR_SYM_F, &perf_count.symbolerrors);
+ mad_encode_field(pc, IB_PC_LINK_RECOVERS_F, &perf_count.linkrecovers);
+ mad_encode_field(pc, IB_PC_LINK_DOWNED_F, &perf_count.linkdowned);
+ mad_encode_field(pc, IB_PC_ERR_RCV_F, &perf_count.rcverrors);
+ mad_encode_field(pc, IB_PC_ERR_PHYSRCV_F,
+ &perf_count.rcvremotephyerrors);
+ mad_encode_field(pc, IB_PC_ERR_SWITCH_REL_F,
+ &perf_count.rcvswrelayerrors);
+ mad_encode_field(pc, IB_PC_XMT_DISCARDS_F, &perf_count.xmtdiscards);
+ mad_encode_field(pc, IB_PC_ERR_XMTCONSTR_F,
+ &perf_count.xmtconstrainterrors);
+ mad_encode_field(pc, IB_PC_ERR_RCVCONSTR_F,
+ &perf_count.rcvconstrainterrors);
+ mad_encode_field(pc, IB_PC_ERR_LOCALINTEG_F,
+ &perf_count.linkintegrityerrors);
+ mad_encode_field(pc, IB_PC_ERR_EXCESS_OVR_F,
+ &perf_count.excbufoverrunerrors);
+#ifdef HAVE_IB_PC_QP1_DROP_F
+ mad_encode_field(pc, IB_PC_QP1_DROP_F, &perf_count.qp1dropped);
+#endif
+ mad_encode_field(pc, IB_PC_VL15_DROPPED_F, &perf_count.vl15dropped);
+ mad_encode_field(pc, IB_PC_XMT_BYTES_F, &perf_count.xmtdata);
+ mad_encode_field(pc, IB_PC_RCV_BYTES_F, &perf_count.rcvdata);
+ mad_encode_field(pc, IB_PC_XMT_PKTS_F, &perf_count.xmtpkts);
+ mad_encode_field(pc, IB_PC_RCV_PKTS_F, &perf_count.rcvpkts);
+ mad_encode_field(pc, IB_PC_XMT_WAIT_F, &perf_count.xmtwait);
+
+ mad_dump_perfcounters(buf, sizeof buf, pc, sizeof pc);
+
+ printf("# Port counters: %s port %d (CapMask: 0x%02X)\n%s",
+ portid2str(portid), ALL_PORTS, ntohs(cap_mask), buf);
+}
+
+static void aggregate_perfcounters_ext(uint16_t cap_mask, uint32_t cap_mask2)
+{
+ uint32_t val;
+ uint64_t val64;
+
+ mad_decode_field(pc, IB_PC_EXT_PORT_SELECT_F, &val);
+ perf_count_ext.portselect = val;
+ mad_decode_field(pc, IB_PC_EXT_COUNTER_SELECT_F, &val);
+ perf_count_ext.counterselect = val;
+ mad_decode_field(pc, IB_PC_EXT_XMT_BYTES_F, &val64);
+ aggregate_64bit(&perf_count_ext.portxmitdata, val64);
+ mad_decode_field(pc, IB_PC_EXT_RCV_BYTES_F, &val64);
+ aggregate_64bit(&perf_count_ext.portrcvdata, val64);
+ mad_decode_field(pc, IB_PC_EXT_XMT_PKTS_F, &val64);
+ aggregate_64bit(&perf_count_ext.portxmitpkts, val64);
+ mad_decode_field(pc, IB_PC_EXT_RCV_PKTS_F, &val64);
+ aggregate_64bit(&perf_count_ext.portrcvpkts, val64);
+
+ if (cap_mask & IB_PM_EXT_WIDTH_SUPPORTED) {
+ mad_decode_field(pc, IB_PC_EXT_XMT_UPKTS_F, &val64);
+ aggregate_64bit(&perf_count_ext.portunicastxmitpkts, val64);
+ mad_decode_field(pc, IB_PC_EXT_RCV_UPKTS_F, &val64);
+ aggregate_64bit(&perf_count_ext.portunicastrcvpkts, val64);
+ mad_decode_field(pc, IB_PC_EXT_XMT_MPKTS_F, &val64);
+ aggregate_64bit(&perf_count_ext.portmulticastxmitpkits, val64);
+ mad_decode_field(pc, IB_PC_EXT_RCV_MPKTS_F, &val64);
+ aggregate_64bit(&perf_count_ext.portmulticastrcvpkts, val64);
+ }
+
+ if (htonl(cap_mask2) & IB_PM_IS_ADDL_PORT_CTRS_EXT_SUP) {
+ mad_decode_field(pc, IB_PC_EXT_COUNTER_SELECT2_F, &val);
+ perf_count_ext.counterSelect2 = val;
+ mad_decode_field(pc, IB_PC_EXT_ERR_SYM_F, &val64);
+ aggregate_64bit(&perf_count_ext.symbolErrorCounter, val64);
+ mad_decode_field(pc, IB_PC_EXT_LINK_RECOVERS_F, &val64);
+ aggregate_64bit(&perf_count_ext.linkErrorRecoveryCounter, val64);
+ mad_decode_field(pc, IB_PC_EXT_LINK_DOWNED_F, &val64);
+ aggregate_64bit(&perf_count_ext.linkDownedCounter, val64);
+ mad_decode_field(pc, IB_PC_EXT_ERR_RCV_F, &val64);
+ aggregate_64bit(&perf_count_ext.portRcvErrors, val64);
+ mad_decode_field(pc, IB_PC_EXT_ERR_PHYSRCV_F, &val64);
+ aggregate_64bit(&perf_count_ext.portRcvRemotePhysicalErrors, val64);
+ mad_decode_field(pc, IB_PC_EXT_ERR_SWITCH_REL_F, &val64);
+ aggregate_64bit(&perf_count_ext.portRcvSwitchRelayErrors, val64);
+ mad_decode_field(pc, IB_PC_EXT_XMT_DISCARDS_F, &val64);
+ aggregate_64bit(&perf_count_ext.portXmitDiscards, val64);
+ mad_decode_field(pc, IB_PC_EXT_ERR_XMTCONSTR_F, &val64);
+ aggregate_64bit(&perf_count_ext.portXmitConstraintErrors, val64);
+ mad_decode_field(pc, IB_PC_EXT_ERR_RCVCONSTR_F, &val64);
+ aggregate_64bit(&perf_count_ext.portRcvConstraintErrors, val64);
+ mad_decode_field(pc, IB_PC_EXT_ERR_LOCALINTEG_F, &val64);
+ aggregate_64bit(&perf_count_ext.localLinkIntegrityErrors, val64);
+ mad_decode_field(pc, IB_PC_EXT_ERR_EXCESS_OVR_F, &val64);
+ aggregate_64bit(&perf_count_ext.excessiveBufferOverrunErrors, val64);
+ mad_decode_field(pc, IB_PC_EXT_VL15_DROPPED_F, &val64);
+ aggregate_64bit(&perf_count_ext.VL15Dropped, val64);
+ mad_decode_field(pc, IB_PC_EXT_XMT_WAIT_F, &val64);
+ aggregate_64bit(&perf_count_ext.portXmitWait, val64);
+ mad_decode_field(pc, IB_PC_EXT_QP1_DROP_F, &val64);
+ aggregate_64bit(&perf_count_ext.QP1Dropped, val64);
+ }
+}
+
+static void output_aggregate_perfcounters_ext(ib_portid_t * portid,
+ uint16_t cap_mask, uint32_t cap_mask2)
+{
+ char buf[1536];
+ uint32_t val = ALL_PORTS;
+
+ memset(buf, 0, sizeof(buf));
+
+ /* set port_select to 255 to emulate AllPortSelect */
+ mad_encode_field(pc, IB_PC_EXT_PORT_SELECT_F, &val);
+ mad_encode_field(pc, IB_PC_EXT_COUNTER_SELECT_F,
+ &perf_count_ext.counterselect);
+ mad_encode_field(pc, IB_PC_EXT_XMT_BYTES_F,
+ &perf_count_ext.portxmitdata);
+ mad_encode_field(pc, IB_PC_EXT_RCV_BYTES_F,
+ &perf_count_ext.portrcvdata);
+ mad_encode_field(pc, IB_PC_EXT_XMT_PKTS_F,
+ &perf_count_ext.portxmitpkts);
+ mad_encode_field(pc, IB_PC_EXT_RCV_PKTS_F, &perf_count_ext.portrcvpkts);
+
+ if (cap_mask & IB_PM_EXT_WIDTH_SUPPORTED) {
+ mad_encode_field(pc, IB_PC_EXT_XMT_UPKTS_F,
+ &perf_count_ext.portunicastxmitpkts);
+ mad_encode_field(pc, IB_PC_EXT_RCV_UPKTS_F,
+ &perf_count_ext.portunicastrcvpkts);
+ mad_encode_field(pc, IB_PC_EXT_XMT_MPKTS_F,
+ &perf_count_ext.portmulticastxmitpkits);
+ mad_encode_field(pc, IB_PC_EXT_RCV_MPKTS_F,
+ &perf_count_ext.portmulticastrcvpkts);
+ }
+
+ if (htonl(cap_mask2) & IB_PM_IS_ADDL_PORT_CTRS_EXT_SUP) {
+ mad_encode_field(pc, IB_PC_EXT_COUNTER_SELECT2_F,
+ &perf_count_ext.counterSelect2);
+ mad_encode_field(pc, IB_PC_EXT_ERR_SYM_F,
+ &perf_count_ext.symbolErrorCounter);
+ mad_encode_field(pc, IB_PC_EXT_LINK_RECOVERS_F,
+ &perf_count_ext.linkErrorRecoveryCounter);
+ mad_encode_field(pc, IB_PC_EXT_LINK_DOWNED_F,
+ &perf_count_ext.linkDownedCounter);
+ mad_encode_field(pc, IB_PC_EXT_ERR_RCV_F,
+ &perf_count_ext.portRcvErrors);
+ mad_encode_field(pc, IB_PC_EXT_ERR_PHYSRCV_F,
+ &perf_count_ext.portRcvRemotePhysicalErrors);
+ mad_encode_field(pc, IB_PC_EXT_ERR_SWITCH_REL_F,
+ &perf_count_ext.portRcvSwitchRelayErrors);
+ mad_encode_field(pc, IB_PC_EXT_XMT_DISCARDS_F,
+ &perf_count_ext.portXmitDiscards);
+ mad_encode_field(pc, IB_PC_EXT_ERR_XMTCONSTR_F,
+ &perf_count_ext.portXmitConstraintErrors);
+ mad_encode_field(pc, IB_PC_EXT_ERR_RCVCONSTR_F,
+ &perf_count_ext.portRcvConstraintErrors);
+ mad_encode_field(pc, IB_PC_EXT_ERR_LOCALINTEG_F,
+ &perf_count_ext.localLinkIntegrityErrors);
+ mad_encode_field(pc, IB_PC_EXT_ERR_EXCESS_OVR_F,
+ &perf_count_ext.excessiveBufferOverrunErrors);
+ mad_encode_field(pc, IB_PC_EXT_VL15_DROPPED_F,
+ &perf_count_ext.VL15Dropped);
+ mad_encode_field(pc, IB_PC_EXT_XMT_WAIT_F,
+ &perf_count_ext.portXmitWait);
+ mad_encode_field(pc, IB_PC_EXT_QP1_DROP_F,
+ &perf_count_ext.QP1Dropped);
+ }
+
+ mad_dump_perfcounters_ext(buf, sizeof buf, pc, sizeof pc);
+
+ printf("# Port extended counters: %s port %d (CapMask: 0x%02X CapMask2: 0x%07X)\n%s",
+ portid2str(portid), ALL_PORTS, ntohs(cap_mask), cap_mask2, buf);
+}
+
+static void dump_perfcounters(int extended, int timeout, uint16_t cap_mask,
+ uint32_t cap_mask2, ib_portid_t * portid,
+ int port, int aggregate)
+{
+ char buf[1536];
+
+ if (extended != 1) {
+ memset(pc, 0, sizeof(pc));
+ if (!pma_query_via(pc, portid, port, timeout,
+ IB_GSI_PORT_COUNTERS, srcport))
+ IBEXIT("perfquery");
+ if (!(cap_mask & IB_PM_PC_XMIT_WAIT_SUP)) {
+ /* if PortCounters:PortXmitWait not supported clear this counter */
+ VERBOSE("PortXmitWait not indicated"
+ " so ignore this counter");
+ perf_count.xmtwait = 0;
+ mad_encode_field(pc, IB_PC_XMT_WAIT_F,
+ &perf_count.xmtwait);
+ }
+ if (aggregate)
+ aggregate_perfcounters();
+ else {
+#ifdef HAVE_IB_PC_QP1_DROP_F
+ mad_dump_perfcounters(buf, sizeof buf, pc, sizeof pc);
+#else
+ mad_dump_fields(buf, sizeof buf, pc, sizeof pc,
+ IB_PC_FIRST_F,
+ (cap_mask & IB_PM_PC_XMIT_WAIT_SUP)?IB_PC_LAST_F:(IB_PC_RCV_PKTS_F+1));
+#endif
+ }
+ } else {
+ /* 1.2 errata: bit 9 is extended counter support
+ * bit 10 is extended counter NoIETF
+ */
+ if (!(cap_mask & IB_PM_EXT_WIDTH_SUPPORTED) &&
+ !(cap_mask & IB_PM_EXT_WIDTH_NOIETF_SUP))
+ IBWARN
+ ("PerfMgt ClassPortInfo CapMask 0x%02X; No extended counter support indicated\n",
+ ntohs(cap_mask));
+
+ memset(pc, 0, sizeof(pc));
+ if (!pma_query_via(pc, portid, port, timeout,
+ IB_GSI_PORT_COUNTERS_EXT, srcport))
+ IBEXIT("perfextquery");
+ if (aggregate)
+ aggregate_perfcounters_ext(cap_mask, cap_mask2);
+ else
+ mad_dump_perfcounters_ext(buf, sizeof buf, pc,
+ sizeof pc);
+ }
+
+ if (!aggregate) {
+ if (extended)
+ printf("# Port extended counters: %s port %d "
+ "(CapMask: 0x%02X CapMask2: 0x%07X)\n%s",
+ portid2str(portid), port, ntohs(cap_mask),
+ cap_mask2, buf);
+ else
+ printf("# Port counters: %s port %d "
+ "(CapMask: 0x%02X)\n%s",
+ portid2str(portid), port, ntohs(cap_mask), buf);
+ }
+}
+
+static void reset_counters(int extended, int timeout, int mask,
+ ib_portid_t * portid, int port)
+{
+ memset(pc, 0, sizeof(pc));
+ if (extended != 1) {
+ if (!performance_reset_via(pc, portid, port, mask, timeout,
+ IB_GSI_PORT_COUNTERS, srcport))
+ IBEXIT("perf reset");
+ } else {
+ if (!performance_reset_via(pc, portid, port, mask, timeout,
+ IB_GSI_PORT_COUNTERS_EXT, srcport))
+ IBEXIT("perf ext reset");
+ }
+}
+
+static int reset, reset_only, all_ports, loop_ports, port, extended, xmt_sl,
+ rcv_sl, xmt_disc, rcv_err, extended_speeds, smpl_ctl, oprcvcounters, flowctlcounters,
+ vloppackets, vlopdata, vlxmitflowctlerrors, vlxmitcounters, swportvlcong,
+ rcvcc, slrcvfecn, slrcvbecn, xmitcc, vlxmittimecc;
+static int ports[MAX_PORTS];
+static int ports_count;
+
+static void common_func(ib_portid_t * portid, int port_num, int mask,
+ unsigned query, unsigned reset,
+ const char *name, uint16_t attr,
+ void dump_func(char *, int, void *, int))
+{
+ char buf[1536];
+
+ if (query) {
+ memset(pc, 0, sizeof(pc));
+ if (!pma_query_via(pc, portid, port_num, ibd_timeout, attr,
+ srcport))
+ IBEXIT("cannot query %s", name);
+
+ dump_func(buf, sizeof(buf), pc, sizeof(pc));
+
+ printf("# %s counters: %s port %d\n%s", name,
+ portid2str(portid), port_num, buf);
+ }
+
+ memset(pc, 0, sizeof(pc));
+ if (reset && !performance_reset_via(pc, portid, port, mask, ibd_timeout,
+ attr, srcport))
+ IBEXIT("cannot reset %s", name);
+}
+
+static void xmt_sl_query(ib_portid_t * portid, int port, int mask)
+{
+ common_func(portid, port, mask, !reset_only, (reset_only || reset),
+ "PortXmitDataSL", IB_GSI_PORT_XMIT_DATA_SL,
+ mad_dump_perfcounters_xmt_sl);
+}
+
+static void rcv_sl_query(ib_portid_t * portid, int port, int mask)
+{
+ common_func(portid, port, mask, !reset_only, (reset_only || reset),
+ "PortRcvDataSL", IB_GSI_PORT_RCV_DATA_SL,
+ mad_dump_perfcounters_rcv_sl);
+}
+
+static void xmt_disc_query(ib_portid_t * portid, int port, int mask)
+{
+ common_func(portid, port, mask, !reset_only, (reset_only || reset),
+ "PortXmitDiscardDetails", IB_GSI_PORT_XMIT_DISCARD_DETAILS,
+ mad_dump_perfcounters_xmt_disc);
+}
+
+static void rcv_err_query(ib_portid_t * portid, int port, int mask)
+{
+ common_func(portid, port, mask, !reset_only, (reset_only || reset),
+ "PortRcvErrorDetails", IB_GSI_PORT_RCV_ERROR_DETAILS,
+ mad_dump_perfcounters_rcv_err);
+}
+
+static uint8_t *ext_speeds_reset_via(void *rcvbuf, ib_portid_t * dest,
+ int port, uint64_t mask, unsigned timeout,
+ const struct ibmad_port * srcport)
+{
+ ib_rpc_t rpc = { 0 };
+ int lid = dest->lid;
+
+ DEBUG("lid %u port %d mask 0x%" PRIx64, lid, port, mask);
+
+ if (lid == -1) {
+ IBWARN("only lid routed is supported");
+ return NULL;
+ }
+
+ if (!mask)
+ mask = ~0;
+
+ rpc.mgtclass = IB_PERFORMANCE_CLASS;
+ rpc.method = IB_MAD_METHOD_SET;
+ rpc.attr.id = IB_GSI_PORT_EXT_SPEEDS_COUNTERS;
+
+ memset(rcvbuf, 0, IB_MAD_SIZE);
+
+ mad_set_field(rcvbuf, 0, IB_PESC_PORT_SELECT_F, port);
+ mad_set_field64(rcvbuf, 0, IB_PESC_COUNTER_SELECT_F, mask);
+ rpc.attr.mod = 0;
+ rpc.timeout = timeout;
+ rpc.datasz = IB_PC_DATA_SZ;
+ rpc.dataoffs = IB_PC_DATA_OFFS;
+ if (!dest->qp)
+ dest->qp = 1;
+ if (!dest->qkey)
+ dest->qkey = IB_DEFAULT_QP1_QKEY;
+
+ return mad_rpc(srcport, &rpc, dest, rcvbuf, rcvbuf);
+}
+
+static uint8_t is_rsfec_mode_active(ib_portid_t * portid, int port,
+ uint16_t cap_mask)
+{
+ uint8_t data[IB_SMP_DATA_SIZE] = { 0 };
+ uint32_t fec_mode_active = 0;
+ uint32_t pie_capmask = 0;
+ if (cap_mask & IS_PM_RSFEC_COUNTERS_SUP) {
+ if (!is_port_info_extended_supported(portid, port, srcport)) {
+ IBWARN("Port Info Extended not supported");
+ return 0;
+ }
+
+ if (!smp_query_via(data, portid, IB_ATTR_PORT_INFO_EXT, port, 0,
+ srcport))
+ IBEXIT("smp query portinfo extended failed");
+
+ mad_decode_field(data, IB_PORT_EXT_CAPMASK_F, &pie_capmask);
+ mad_decode_field(data, IB_PORT_EXT_FEC_MODE_ACTIVE_F,
+ &fec_mode_active);
+ if((pie_capmask &
+ CL_NTOH32(IB_PORT_EXT_CAP_IS_FEC_MODE_SUPPORTED)) &&
+ (CL_NTOH16(IB_PORT_EXT_RS_FEC_MODE_ACTIVE) == (fec_mode_active & 0xffff)))
+ return 1;
+ }
+
+ return 0;
+}
+
+static void extended_speeds_query(ib_portid_t * portid, int port,
+ uint64_t ext_mask, uint16_t cap_mask)
+{
+ int mask = ext_mask;
+
+ if (!reset_only) {
+ if (is_rsfec_mode_active(portid, port, cap_mask))
+ common_func(portid, port, mask, 1, 0,
+ "PortExtendedSpeedsCounters with RS-FEC Active",
+ IB_GSI_PORT_EXT_SPEEDS_COUNTERS,
+ mad_dump_port_ext_speeds_counters_rsfec_active);
+ else
+ common_func(portid, port, mask, 1, 0,
+ "PortExtendedSpeedsCounters",
+ IB_GSI_PORT_EXT_SPEEDS_COUNTERS,
+ mad_dump_port_ext_speeds_counters);
+ }
+
+ if ((reset_only || reset) &&
+ !ext_speeds_reset_via(pc, portid, port, ext_mask, ibd_timeout, srcport))
+ IBEXIT("cannot reset PortExtendedSpeedsCounters");
+}
+
+static void oprcvcounters_query(ib_portid_t * portid, int port, int mask)
+{
+ common_func(portid, port, mask, !reset_only, (reset_only || reset),
+ "PortOpRcvCounters", IB_GSI_PORT_PORT_OP_RCV_COUNTERS,
+ mad_dump_perfcounters_port_op_rcv_counters);
+}
+
+static void flowctlcounters_query(ib_portid_t * portid, int port, int mask)
+{
+ common_func(portid, port, mask, !reset_only, (reset_only || reset),
+ "PortFlowCtlCounters", IB_GSI_PORT_PORT_FLOW_CTL_COUNTERS,
+ mad_dump_perfcounters_port_flow_ctl_counters);
+}
+
+static void vloppackets_query(ib_portid_t * portid, int port, int mask)
+{
+ common_func(portid, port, mask, !reset_only, (reset_only || reset),
+ "PortVLOpPackets", IB_GSI_PORT_PORT_VL_OP_PACKETS,
+ mad_dump_perfcounters_port_vl_op_packet);
+}
+
+static void vlopdata_query(ib_portid_t * portid, int port, int mask)
+{
+ common_func(portid, port, mask, !reset_only, (reset_only || reset),
+ "PortVLOpData", IB_GSI_PORT_PORT_VL_OP_DATA,
+ mad_dump_perfcounters_port_vl_op_data);
+}
+
+static void vlxmitflowctlerrors_query(ib_portid_t * portid, int port, int mask)
+{
+ common_func(portid, port, mask, !reset_only, (reset_only || reset),
+ "PortVLXmitFlowCtlUpdateErrors", IB_GSI_PORT_PORT_VL_XMIT_FLOW_CTL_UPDATE_ERRORS,
+ mad_dump_perfcounters_port_vl_xmit_flow_ctl_update_errors);
+}
+
+static void vlxmitcounters_query(ib_portid_t * portid, int port, int mask)
+{
+ common_func(portid, port, mask, !reset_only, (reset_only || reset),
+ "PortVLXmitWaitCounters", IB_GSI_PORT_PORT_VL_XMIT_WAIT_COUNTERS,
+ mad_dump_perfcounters_port_vl_xmit_wait_counters);
+}
+
+static void swportvlcong_query(ib_portid_t * portid, int port, int mask)
+{
+ common_func(portid, port, mask, !reset_only, (reset_only || reset),
+ "SwPortVLCongestion", IB_GSI_SW_PORT_VL_CONGESTION,
+ mad_dump_perfcounters_sw_port_vl_congestion);
+}
+
+static void rcvcc_query(ib_portid_t * portid, int port, int mask)
+{
+ common_func(portid, port, mask, !reset_only, (reset_only || reset),
+ "PortRcvConCtrl", IB_GSI_PORT_RCV_CON_CTRL,
+ mad_dump_perfcounters_rcv_con_ctrl);
+}
+
+static void slrcvfecn_query(ib_portid_t * portid, int port, int mask)
+{
+ common_func(portid, port, mask, !reset_only, (reset_only || reset),
+ "PortSLRcvFECN", IB_GSI_PORT_SL_RCV_FECN,
+ mad_dump_perfcounters_sl_rcv_fecn);
+}
+
+static void slrcvbecn_query(ib_portid_t * portid, int port, int mask)
+{
+ common_func(portid, port, mask, !reset_only, (reset_only || reset),
+ "PortSLRcvBECN", IB_GSI_PORT_SL_RCV_BECN,
+ mad_dump_perfcounters_sl_rcv_becn);
+}
+
+static void xmitcc_query(ib_portid_t * portid, int port, int mask)
+{
+ common_func(portid, port, mask, !reset_only, (reset_only || reset),
+ "PortXmitConCtrl", IB_GSI_PORT_XMIT_CON_CTRL,
+ mad_dump_perfcounters_xmit_con_ctrl);
+}
+
+static void vlxmittimecc_query(ib_portid_t * portid, int port, int mask)
+{
+ common_func(portid, port, mask, !reset_only, (reset_only || reset),
+ "PortVLXmitTimeCong", IB_GSI_PORT_VL_XMIT_TIME_CONG,
+ mad_dump_perfcounters_vl_xmit_time_cong);
+}
+
+void dump_portsamples_control(ib_portid_t * portid, int port)
+{
+ char buf[1280];
+
+ memset(pc, 0, sizeof(pc));
+ if (!pma_query_via(pc, portid, port, ibd_timeout,
+ IB_GSI_PORT_SAMPLES_CONTROL, srcport))
+ IBEXIT("sampctlquery");
+
+ mad_dump_portsamples_control(buf, sizeof buf, pc, sizeof pc);
+ printf("# PortSamplesControl: %s port %d\n%s", portid2str(portid),
+ port, buf);
+}
+
+static int process_opt(void *context, int ch, char *optarg)
+{
+ switch (ch) {
+ case 'x':
+ extended = 1;
+ break;
+ case 'X':
+ xmt_sl = 1;
+ break;
+ case 'S':
+ rcv_sl = 1;
+ break;
+ case 'D':
+ xmt_disc = 1;
+ break;
+ case 'E':
+ rcv_err = 1;
+ break;
+ case 'T':
+ extended_speeds = 1;
+ break;
+ case 'c':
+ smpl_ctl = 1;
+ break;
+ case 1:
+ oprcvcounters = 1;
+ break;
+ case 2:
+ flowctlcounters = 1;
+ break;
+ case 3:
+ vloppackets = 1;
+ break;
+ case 4:
+ vlopdata = 1;
+ break;
+ case 5:
+ vlxmitflowctlerrors = 1;
+ break;
+ case 6:
+ vlxmitcounters = 1;
+ break;
+ case 7:
+ swportvlcong = 1;
+ break;
+ case 8:
+ rcvcc = 1;
+ break;
+ case 9:
+ slrcvfecn = 1;
+ break;
+ case 10:
+ slrcvbecn = 1;
+ break;
+ case 11:
+ xmitcc = 1;
+ break;
+ case 12:
+ vlxmittimecc = 1;
+ break;
+ case 'a':
+ all_ports++;
+ port = ALL_PORTS;
+ break;
+ case 'l':
+ loop_ports++;
+ break;
+ case 'r':
+ reset++;
+ break;
+ case 'R':
+ reset_only++;
+ break;
+ case 25:
+ if (!inet_pton(AF_INET6, optarg, &dgid)) {
+ fprintf(stderr, "dgid format is wrong!\n");
+ ibdiag_show_usage();
+ return 1;
+ }
+ with_grh = 1;
+ break;
+ default:
+ return -1;
+ }
+ return 0;
+}
+
+int main(int argc, char **argv)
+{
+ int mgmt_classes[3] = { IB_SMI_CLASS, IB_SA_CLASS, IB_PERFORMANCE_CLASS };
+ ib_portid_t portid = { 0 };
+ int mask = 0xffff;
+ uint64_t ext_mask = 0xffffffffffffffffULL;
+ uint32_t cap_mask2;
+ uint16_t cap_mask;
+ int all_ports_loop = 0;
+ int node_type, num_ports = 0;
+ uint8_t data[IB_SMP_DATA_SIZE] = { 0 };
+ int start_port = 1;
+ int enhancedport0;
+ char *tmpstr;
+ int i;
+
+ const struct ibdiag_opt opts[] = {
+ {"extended", 'x', 0, NULL, "show extended port counters"},
+ {"xmtsl", 'X', 0, NULL, "show Xmt SL port counters"},
+ {"rcvsl", 'S', 0, NULL, "show Rcv SL port counters"},
+ {"xmtdisc", 'D', 0, NULL, "show Xmt Discard Details"},
+ {"rcverr", 'E', 0, NULL, "show Rcv Error Details"},
+ {"extended_speeds", 'T', 0, NULL, "show port extended speeds counters"},
+ {"oprcvcounters", 1, 0, NULL, "show Rcv Counters per Op code"},
+ {"flowctlcounters", 2, 0, NULL, "show flow control counters"},
+ {"vloppackets", 3, 0, NULL, "show packets received per Op code per VL"},
+ {"vlopdata", 4, 0, NULL, "show data received per Op code per VL"},
+ {"vlxmitflowctlerrors", 5, 0, NULL, "show flow control update errors per VL"},
+ {"vlxmitcounters", 6, 0, NULL, "show ticks waiting to transmit counters per VL"},
+ {"swportvlcong", 7, 0, NULL, "show sw port VL congestion"},
+ {"rcvcc", 8, 0, NULL, "show Rcv congestion control counters"},
+ {"slrcvfecn", 9, 0, NULL, "show SL Rcv FECN counters"},
+ {"slrcvbecn", 10, 0, NULL, "show SL Rcv BECN counters"},
+ {"xmitcc", 11, 0, NULL, "show Xmit congestion control counters"},
+ {"vlxmittimecc", 12, 0, NULL, "show VL Xmit Time congestion control counters"},
+ {"smplctl", 'c', 0, NULL, "show samples control"},
+ {"all_ports", 'a', 0, NULL, "show aggregated counters"},
+ {"loop_ports", 'l', 0, NULL, "iterate through each port"},
+ {"reset_after_read", 'r', 0, NULL, "reset counters after read"},
+ {"Reset_only", 'R', 0, NULL, "only reset counters"},
+ {"dgid", 25, 1, NULL, "remote gid (IPv6 format)"},
+ {0}
+ };
+ char usage_args[] = " [<lid|guid> [[port(s)] [reset_mask]]]";
+ const char *usage_examples[] = {
+ "\t\t# read local port's performance counters",
+ "32 1\t\t# read performance counters from lid 32, port 1",
+ "-x 32 1\t# read extended performance counters from lid 32, port 1",
+ "-a 32\t\t# read performance counters from lid 32, all ports",
+ "-r 32 1\t# read performance counters and reset",
+ "-x -r 32 1\t# read extended performance counters and reset",
+ "-R 0x20 1\t# reset performance counters of port 1 only",
+ "-x -R 0x20 1\t# reset extended performance counters of port 1 only",
+ "-R -a 32\t# reset performance counters of all ports",
+ "-R 32 2 0x0fff\t# reset only error counters of port 2",
+ "-R 32 2 0xf000\t# reset only non-error counters of port 2",
+ "-a 32 1-10\t# read performance counters from lid 32, port 1-10, aggregate output",
+ "-l 32 1-10\t# read performance counters from lid 32, port 1-10, output each port",
+ "-a 32 1,4,8\t# read performance counters from lid 32, port 1, 4, and 8, aggregate output",
+ "-l 32 1,4,8\t# read performance counters from lid 32, port 1, 4, and 8, output each port",
+ NULL,
+ };
+
+ ibdiag_process_opts(argc, argv, NULL, "DK", opts, process_opt,
+ usage_args, usage_examples);
+
+ argc -= optind;
+ argv += optind;
+
+ if (argc > 1) {
+ if (strchr(argv[1], ',')) {
+ tmpstr = strtok(argv[1], ",");
+ while (tmpstr) {
+ ports[ports_count++] = strtoul(tmpstr, 0, 0);
+ tmpstr = strtok(NULL, ",");
+ }
+ port = ports[0];
+ }
+ else if ((tmpstr = strchr(argv[1], '-'))) {
+ int pmin, pmax;
+
+ *tmpstr = '\0';
+ tmpstr++;
+
+ pmin = strtoul(argv[1], 0, 0);
+ pmax = strtoul(tmpstr, 0, 0);
+
+ if (pmin >= pmax)
+ IBEXIT("max port must be greater than min port in range");
+
+ while (pmin <= pmax)
+ ports[ports_count++] = pmin++;
+
+ port = ports[0];
+ }
+ else
+ port = strtoul(argv[1], 0, 0);
+ }
+ if (argc > 2) {
+ ext_mask = strtoull(argv[2], 0, 0);
+ mask = ext_mask;
+ }
+
+ srcport = mad_rpc_open_port(ibd_ca, ibd_ca_port, mgmt_classes, 3);
+ if (!srcport)
+ IBEXIT("Failed to open '%s' port '%d'", ibd_ca, ibd_ca_port);
+
+ smp_mkey_set(srcport, ibd_mkey);
+
+ if (argc) {
+ if (with_grh && ibd_dest_type != IB_DEST_LID)
+ IBEXIT("When using GRH, LID should be provided");
+ if (resolve_portid_str(ibd_ca, ibd_ca_port, &portid, argv[0],
+ ibd_dest_type, ibd_sm_id, srcport) < 0)
+ IBEXIT("can't resolve destination port %s", argv[0]);
+ if (with_grh) {
+ portid.grh_present = 1;
+ memcpy(&portid.gid, &dgid, sizeof(portid.gid));
+ }
+ } else {
+ if (resolve_self(ibd_ca, ibd_ca_port, &portid, &port, 0) < 0)
+ IBEXIT("can't resolve self port %s", argv[0]);
+ }
+
+ /* PerfMgt ClassPortInfo is a required attribute */
+ memset(pc, 0, sizeof(pc));
+ if (!pma_query_via(pc, &portid, port, ibd_timeout, CLASS_PORT_INFO,
+ srcport))
+ IBEXIT("classportinfo query");
+ /* ClassPortInfo should be supported as part of libibmad */
+ memcpy(&cap_mask, pc + 2, sizeof(cap_mask)); /* CapabilityMask */
+ memcpy(&cap_mask2, pc + 4, sizeof(cap_mask2)); /* CapabilityMask2 */
+ cap_mask2 = ntohl(cap_mask2) >> 5;
+
+ if (!(cap_mask & IB_PM_ALL_PORT_SELECT)) { /* bit 8 is AllPortSelect */
+ if (!all_ports && port == ALL_PORTS)
+ IBEXIT("AllPortSelect not supported");
+ if (all_ports && port == ALL_PORTS)
+ all_ports_loop = 1;
+ }
+
+ if (xmt_sl) {
+ xmt_sl_query(&portid, port, mask);
+ goto done;
+ }
+
+ if (rcv_sl) {
+ rcv_sl_query(&portid, port, mask);
+ goto done;
+ }
+
+ if (xmt_disc) {
+ xmt_disc_query(&portid, port, mask);
+ goto done;
+ }
+
+ if (rcv_err) {
+ rcv_err_query(&portid, port, mask);
+ goto done;
+ }
+
+ if (extended_speeds) {
+ extended_speeds_query(&portid, port, ext_mask, cap_mask);
+ goto done;
+ }
+
+ if (oprcvcounters) {
+ oprcvcounters_query(&portid, port, mask);
+ goto done;
+ }
+
+ if (flowctlcounters) {
+ flowctlcounters_query(&portid, port, mask);
+ goto done;
+ }
+
+ if (vloppackets) {
+ vloppackets_query(&portid, port, mask);
+ goto done;
+ }
+
+ if (vlopdata) {
+ vlopdata_query(&portid, port, mask);
+ goto done;
+ }
+
+ if (vlxmitflowctlerrors) {
+ vlxmitflowctlerrors_query(&portid, port, mask);
+ goto done;
+ }
+
+ if (vlxmitcounters) {
+ vlxmitcounters_query(&portid, port, mask);
+ goto done;
+ }
+
+ if (swportvlcong) {
+ swportvlcong_query(&portid, port, mask);
+ goto done;
+ }
+
+ if (rcvcc) {
+ rcvcc_query(&portid, port, mask);
+ goto done;
+ }
+
+ if (slrcvfecn) {
+ slrcvfecn_query(&portid, port, mask);
+ goto done;
+ }
+
+ if (slrcvbecn) {
+ slrcvbecn_query(&portid, port, mask);
+ goto done;
+ }
+
+ if (xmitcc) {
+ xmitcc_query(&portid, port, mask);
+ goto done;
+ }
+
+ if (vlxmittimecc) {
+ vlxmittimecc_query(&portid, port, mask);
+ goto done;
+ }
+
+ if (smpl_ctl) {
+ dump_portsamples_control(&portid, port);
+ goto done;
+ }
+
+
+ if (all_ports_loop || (loop_ports && (all_ports || port == ALL_PORTS))) {
+ if (!smp_query_via(data, &portid, IB_ATTR_NODE_INFO, 0, 0,
+ srcport))
+ IBEXIT("smp query nodeinfo failed");
+ node_type = mad_get_field(data, 0, IB_NODE_TYPE_F);
+ mad_decode_field(data, IB_NODE_NPORTS_F, &num_ports);
+ if (!num_ports)
+ IBEXIT("smp query nodeinfo: num ports invalid");
+
+ if (node_type == IB_NODE_SWITCH) {
+ if (!smp_query_via(data, &portid, IB_ATTR_SWITCH_INFO,
+ 0, 0, srcport))
+ IBEXIT("smp query nodeinfo failed");
+ enhancedport0 =
+ mad_get_field(data, 0, IB_SW_ENHANCED_PORT0_F);
+ if (enhancedport0)
+ start_port = 0;
+ }
+ if (all_ports_loop && !loop_ports)
+ IBWARN
+ ("Emulating AllPortSelect by iterating through all ports");
+ }
+
+ if (reset_only)
+ goto do_reset;
+
+ if (all_ports_loop || (loop_ports && (all_ports || port == ALL_PORTS))) {
+ for (i = start_port; i <= num_ports; i++)
+ dump_perfcounters(extended, ibd_timeout,
+ cap_mask, cap_mask2,
+ &portid, i, (all_ports_loop
+ && !loop_ports));
+ if (all_ports_loop && !loop_ports) {
+ if (extended != 1)
+ output_aggregate_perfcounters(&portid,
+ cap_mask);
+ else
+ output_aggregate_perfcounters_ext(&portid,
+ cap_mask, cap_mask2);
+ }
+ } else if (ports_count > 1) {
+ for (i = 0; i < ports_count; i++)
+ dump_perfcounters(extended, ibd_timeout, cap_mask,
+ cap_mask2, &portid, ports[i],
+ (all_ports && !loop_ports));
+ if (all_ports && !loop_ports) {
+ if (extended != 1)
+ output_aggregate_perfcounters(&portid,
+ cap_mask);
+ else
+ output_aggregate_perfcounters_ext(&portid,
+ cap_mask, cap_mask2);
+ }
+ } else
+ dump_perfcounters(extended, ibd_timeout, cap_mask, cap_mask2,
+ &portid, port, 0);
+
+ if (!reset)
+ goto done;
+
+do_reset:
+ if (argc <= 2 && !extended) {
+ if (cap_mask & IB_PM_PC_XMIT_WAIT_SUP)
+ mask |= (1 << 16); /* reset portxmitwait */
+ if (cap_mask & IB_PM_IS_QP1_DROP_SUP)
+ mask |= (1 << 17); /* reset qp1dropped */
+ }
+
+ if (extended) {
+ mask |= 0xfff0000;
+ if (cap_mask & IB_PM_PC_XMIT_WAIT_SUP)
+ mask |= (1 << 28);
+ if (cap_mask & IB_PM_IS_QP1_DROP_SUP)
+ mask |= (1 << 29);
+ }
+
+ if (all_ports_loop || (loop_ports && (all_ports || port == ALL_PORTS))) {
+ for (i = start_port; i <= num_ports; i++)
+ reset_counters(extended, ibd_timeout, mask, &portid, i);
+ } else if (ports_count > 1) {
+ for (i = 0; i < ports_count; i++)
+ reset_counters(extended, ibd_timeout, mask, &portid, ports[i]);
+ } else
+ reset_counters(extended, ibd_timeout, mask, &portid, port);
+
+done:
+ mad_rpc_close_port(srcport);
+ exit(0);
+}
diff --git a/contrib/ofed/infiniband-diags/src/rdma-ndd.c b/contrib/ofed/infiniband-diags/src/rdma-ndd.c
new file mode 100644
index 0000000..194c2cd
--- /dev/null
+++ b/contrib/ofed/infiniband-diags/src/rdma-ndd.c
@@ -0,0 +1,433 @@
+/*
+ * Copyright (c) 2014 Intel Corporation. All Rights Reserved
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+#if HAVE_CONFIG_H
+# include <config.h>
+#endif /* HAVE_CONFIG_H */
+
+#include <poll.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <assert.h>
+#include <string.h>
+#include <limits.h>
+#include <stdio.h>
+#include <syslog.h>
+#include <dirent.h>
+#include <errno.h>
+#include <unistd.h>
+#include <getopt.h>
+#include <stdlib.h>
+
+#include <libudev.h>
+
+struct udev *udev;
+struct udev_monitor *mon;
+
+#include "ibdiag_common.h"
+
+#define SYS_HOSTNAME "/proc/sys/kernel/hostname"
+#define DEF_SYS_DIR "/sys"
+char *sys_dir = DEF_SYS_DIR;
+#define SYS_INFINIBAND "class/infiniband"
+#define DEFAULT_RETRY_RATE 60
+#define DEFAULT_RETRY_COUNT 0
+#define DEFAULT_ND_FORMAT "%h %d"
+
+int failure_retry_rate = DEFAULT_RETRY_RATE;
+int set_retry_cnt = DEFAULT_RETRY_COUNT;
+int foreground = 0;
+char *pidfile = NULL;
+
+static void newline_to_null(char *str)
+{
+ char *term = index(str, '\n');
+ if (term)
+ *term = '\0';
+}
+
+static void strip_domain(char *str)
+{
+ char *term = index(str, '.');
+ if (term)
+ *term = '\0';
+}
+
+static void build_node_desc(char *dest, size_t len,
+ const char *device, const char *hostname)
+{
+ char *end = dest + len-1;
+ const char *field;
+ char *src = ibd_nd_format;
+
+ while (*src && (dest < end)) {
+ if (*src != '%') {
+ *dest++ = *src++;
+ } else {
+ src++;
+ switch (*src) {
+ case 'h':
+ field = hostname;
+ while (*field && (*field != '.') && (dest < end))
+ *dest++ = *field++;
+ break;
+ case 'd':
+ field = device;
+ while (*field && (dest < end))
+ *dest++ = *field++;
+ break;
+ }
+ src++;
+ }
+ }
+ *dest = 0;
+}
+
+static int update_node_desc(const char *device, const char *hostname, int force)
+{
+ int rc;
+ char nd[128];
+ char new_nd[64];
+ char nd_file[PATH_MAX];
+ FILE *f;
+
+ snprintf(nd_file, sizeof(nd_file), "%s/%s/%s/node_desc",
+ sys_dir, SYS_INFINIBAND, device);
+ nd_file[sizeof(nd_file)-1] = '\0';
+
+ f = fopen(nd_file, "r+");
+ if (!f) {
+ syslog(LOG_ERR, "Failed to open %s\n", nd_file);
+ return -EIO;
+ }
+
+ if (!fgets(nd, sizeof(nd), f)) {
+ syslog(LOG_ERR, "Failed to read %s\n", nd_file);
+ rc = -EIO;
+ goto error;
+ }
+ newline_to_null(nd);
+
+ build_node_desc(new_nd, sizeof(new_nd), device, hostname);
+
+ if (!force && strncmp(new_nd, nd, sizeof(new_nd)) == 0) {
+ syslog(LOG_INFO, "%s: no change (%s)\n", device, new_nd);
+ } else {
+ syslog(LOG_INFO, "%s: change (%s) -> (%s)\n",
+ device, nd, new_nd);
+ rewind(f);
+ fprintf(f, new_nd);
+ }
+
+ rc = 0;
+error:
+ fclose(f);
+ return rc;
+}
+
+static int set_rdma_node_desc(const char *hostname, int force)
+{
+ DIR *class_dir;
+ struct dirent *dent;
+ char dev_dir[PATH_MAX];
+
+ snprintf(dev_dir, sizeof(dev_dir), "%s/%s", sys_dir, SYS_INFINIBAND);
+ dev_dir[sizeof(dev_dir)-1] = '\0';
+
+ class_dir = opendir(dev_dir);
+ if (!class_dir) {
+ syslog(LOG_INFO, "Failed to open %s", dev_dir);
+ return -ENOSYS;
+ }
+
+ while ((dent = readdir(class_dir))) {
+ int retry = set_retry_cnt;
+ if (dent->d_name[0] == '.')
+ continue;
+
+ while (update_node_desc(dent->d_name, hostname, force) && retry > 0) {
+ syslog(LOG_ERR, "retrying set Node Description on %s\n",
+ dent->d_name);
+ retry--;
+ }
+ }
+
+ closedir(class_dir);
+ return 0;
+}
+
+static int read_hostname(int fd, char *name, size_t len)
+{
+ int rc;
+ memset(name, 0, len);
+ if (read(fd, name, len-1) >= 0) {
+ newline_to_null(name);
+ strip_domain(name);
+ rc = 0;
+ } else {
+ syslog(LOG_ERR, "Read %s Failed\n", SYS_HOSTNAME);
+ rc = -EIO;
+ }
+ return rc;
+}
+
+static int process_opts(void *context, int ch, char *optarg)
+{
+ unsigned long tmp;
+ switch (ch) {
+ case 0:
+ pidfile = optarg;
+ break;
+ case 'f':
+ foreground = 1;
+ break;
+ case 't':
+ tmp = strtoul(optarg, NULL, 0);
+ if (tmp >= INT_MAX) {
+ syslog(LOG_ERR,
+ "Invalid retry rate specified: %lu s\n",
+ tmp);
+ } else {
+ failure_retry_rate = (int)tmp;
+ }
+ break;
+ case 'r':
+ tmp = strtoul(optarg, NULL, 0);
+ if (tmp >= INT_MAX) {
+ syslog(LOG_ERR,
+ "Invalid retry count specified: %lu\n",
+ tmp);
+ } else {
+ set_retry_cnt = (int)tmp;
+ }
+ break;
+ default:
+ return -1;
+ }
+ return 0;
+}
+
+#define MSG_MAX 2048
+static void udev_log_fn(struct udev *ud, int priority, const char *file, int line,
+ const char *fn, const char *format, va_list args)
+{
+ int off = 0;
+ char msg[MSG_MAX];
+ off = snprintf(msg, MSG_MAX, "libudev: %s:%d %s",
+ file, line, fn);
+ if (off < MSG_MAX-1)
+ vsnprintf(msg+off, MSG_MAX-off, format, args);
+ syslog(LOG_ERR, msg);
+}
+
+static void setup_udev(void)
+{
+ udev = udev_new();
+ if (!udev) {
+ syslog(LOG_ERR, "udev_new failed\n");
+ return;
+ }
+
+ udev_set_log_fn(udev, udev_log_fn);
+ udev_set_log_priority(udev, LOG_INFO);
+#if HAVE_UDEV_GET_SYS_PATH
+ sys_dir = (char *)udev_get_sys_path(udev);
+#endif
+}
+
+static int get_udev_fd(void)
+{
+ mon = udev_monitor_new_from_netlink(udev, "udev");
+ if (!mon) {
+ syslog(LOG_ERR, "udev monitoring failed\n");
+ return -1;
+ }
+
+ udev_monitor_filter_add_match_subsystem_devtype(mon, "infiniband", NULL);
+ udev_monitor_enable_receiving(mon);
+ return udev_monitor_get_fd(mon);
+}
+
+static void process_udev_event(int ud_fd, const char *hostname)
+{
+ struct udev_device *dev;
+
+ dev = udev_monitor_receive_device(mon);
+ if (dev) {
+ const char *device = udev_device_get_sysname(dev);
+ const char *action = udev_device_get_action(dev);
+
+ syslog(LOG_INFO, "Device event: %s, %s, %s\n",
+ udev_device_get_subsystem(dev),
+ device, action);
+
+ if (device && action
+ && strncmp(action, "add", sizeof("add")) == 0)
+ update_node_desc(device, hostname, 1);
+
+ udev_device_unref(dev);
+ }
+}
+
+static void monitor(void)
+{
+ char hostname[128];
+ int hn_fd;
+ int rc;
+ struct pollfd fds[2];
+ int numfds = 1;
+ int ud_fd;
+
+ ud_fd = get_udev_fd();
+ if (ud_fd >= 0)
+ numfds = 2;
+
+ while (1) {
+ hn_fd = open(SYS_HOSTNAME, O_RDONLY);
+ if (hn_fd < 0) {
+ syslog(LOG_ERR,
+ "Open %s Failed: retry in %d seconds\n",
+ SYS_HOSTNAME, failure_retry_rate);
+ sleep(failure_retry_rate);
+ continue;
+ }
+
+ fds[0].fd = hn_fd;
+ fds[0].events = 0;
+ fds[0].revents = 0;
+
+ fds[1].fd = ud_fd;
+ fds[1].events = POLLIN;
+ fds[1].revents = 0;
+
+ rc = poll(fds, numfds, -1);
+
+ if (rc > 0) {
+ if (read_hostname(hn_fd, hostname, sizeof(hostname)) != 0)
+ hostname[0] = '\0';
+
+ if (fds[0].revents != 0)
+ syslog(LOG_ERR, "Hostname change: %s\n", hostname);
+
+ if (fds[1].revents != 0)
+ process_udev_event(ud_fd, hostname);
+
+ rc = set_rdma_node_desc((const char *)hostname, 0);
+ } else {
+ syslog(LOG_ERR, "Poll %s Failed\n", SYS_HOSTNAME);
+ rc = -EIO;
+ }
+
+ close(hn_fd);
+
+ if (rc)
+ sleep(failure_retry_rate);
+ }
+}
+
+static void remove_pidfile(void)
+{
+ if (pidfile)
+ unlink(pidfile);
+}
+
+static void write_pidfile(void)
+{
+ FILE *f;
+ if (pidfile) {
+ remove_pidfile();
+ f = fopen(pidfile, "w");
+ if (f) {
+ fprintf(f, "%d\n", getpid());
+ fclose(f);
+ } else {
+ syslog(LOG_ERR, "Failed to write pidfile : %s\n",
+ pidfile);
+ exit(errno);
+ }
+ }
+}
+
+int main(int argc, char *argv[])
+{
+ int fd;
+ char hostname[128];
+
+ openlog("rdma-ndd", LOG_PID | LOG_PERROR, LOG_DAEMON);
+
+ const struct ibdiag_opt opts[] = {
+ {"retry_timer", 't', 1, "<retry_timer>",
+ "Length of time to sleep when system errors occur "
+ "when attempting to poll and or read the hostname "
+ "from the system.\n"},
+ {"retry_count", 'r', 1, "<retry_count>",
+ "Number of times to attempt to retry setting "
+ "of the node description on failure\n"},
+ {"foreground", 'f', 0, NULL, "run in the foreground instead of as a daemon\n"},
+ {"pidfile", 0, 1, "<pidfile>", "specify a pid file (daemon mode only)\n"},
+ {0}
+ };
+
+ ibdiag_process_opts(argc, argv, NULL, "CPDLGtsKyevd", opts,
+ process_opts, "", NULL);
+
+ if (!ibd_nd_format)
+ ibd_nd_format = DEFAULT_ND_FORMAT;
+
+ if (!foreground) {
+ closelog();
+ openlog("rdma-ndd", LOG_PID, LOG_DAEMON);
+ if (daemon(0, 0) != 0) {
+ syslog(LOG_ERR, "Failed to daemonize\n");
+ exit(errno);
+ }
+ write_pidfile();
+ }
+
+ setup_udev();
+
+ syslog(LOG_INFO, "Node Descriptor format (%s)\n", ibd_nd_format);
+
+ fd = open(SYS_HOSTNAME, O_RDONLY);
+ if (read_hostname(fd, hostname, sizeof(hostname)) != 0)
+ hostname[0] = '\0';
+ set_rdma_node_desc((const char *)hostname, 1);
+ close(fd);
+
+ monitor();
+
+ remove_pidfile();
+
+ return 0;
+}
diff --git a/contrib/ofed/infiniband-diags/src/saquery.c b/contrib/ofed/infiniband-diags/src/saquery.c
new file mode 100644
index 0000000..a4cc3c0
--- /dev/null
+++ b/contrib/ofed/infiniband-diags/src/saquery.c
@@ -0,0 +1,1984 @@
+/*
+ * Copyright (c) 2006,2007 The Regents of the University of California.
+ * Copyright (c) 2004-2009 Voltaire, Inc. All rights reserved.
+ * Copyright (c) 2002-2013 Mellanox Technologies LTD. All rights reserved.
+ * Copyright (c) 1996-2013 Intel Corporation. All rights reserved.
+ * Copyright (c) 2009 HNR Consulting. All rights reserved.
+ *
+ * Produced at Lawrence Livermore National Laboratory.
+ * Written by Ira Weiny <weiny2@llnl.gov>.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+#if HAVE_CONFIG_H
+# include <config.h>
+#endif /* HAVE_CONFIG_H */
+
+#include <unistd.h>
+#include <stdio.h>
+#include <arpa/inet.h>
+#include <ctype.h>
+#include <string.h>
+#include <errno.h>
+
+#define _GNU_SOURCE
+#include <getopt.h>
+
+#include <infiniband/umad.h>
+#include <infiniband/mad.h>
+#include <iba/ib_types.h>
+#include <complib/cl_nodenamemap.h>
+
+#include "ibdiag_common.h"
+#include "ibdiag_sa.h"
+
+#ifndef IB_PR_COMPMASK_SERVICEID
+#define IB_PR_COMPMASK_SERVICEID (IB_PR_COMPMASK_SERVICEID_MSB | \
+ IB_PR_COMPMASK_SERVICEID_LSB)
+#endif
+
+#define UMAD_SA_CAP_MASK2_IS_MCAST_TOP_SUP (1 << 3)
+
+struct query_params {
+ uint64_t service_id;
+ ib_gid_t sgid, dgid, gid, mgid;
+ uint16_t slid, dlid, mlid;
+ uint32_t flow_label;
+ int hop_limit;
+ uint8_t tclass;
+ int reversible, numb_path;
+ uint16_t pkey;
+ int qos_class, sl;
+ uint8_t mtu, rate, pkt_life;
+ uint32_t qkey;
+ uint8_t scope;
+ uint8_t join_state;
+ int proxy_join;
+ ib_class_port_info_t cpi;
+ uint8_t with_grh;
+ ibmad_gid_t sa_dgid;
+};
+
+struct query_cmd {
+ const char *name, *alias;
+ uint16_t query_type;
+ const char *usage;
+ int (*handler) (const struct query_cmd * q, struct sa_handle * h,
+ struct query_params * p, int argc, char *argv[]);
+};
+
+static char *node_name_map_file = NULL;
+static nn_map_t *node_name_map = NULL;
+
+/**
+ * Declare some globals because I don't want this to be too complex.
+ */
+#define MAX_PORTS (8)
+#define DEFAULT_SA_TIMEOUT_MS (1000)
+
+enum {
+ ALL,
+ LID_ONLY,
+ UNIQUE_LID_ONLY,
+ GUID_ONLY,
+ ALL_DESC,
+ NAME_OF_LID,
+ NAME_OF_GUID,
+} node_print_desc = ALL;
+
+char *requested_name = NULL;
+uint16_t requested_lid = 0;
+int requested_lid_flag = 0;
+uint64_t requested_guid = 0;
+int requested_guid_flag = 0;
+
+static unsigned valid_gid(ib_gid_t * gid)
+{
+ ib_gid_t zero_gid;
+ memset(&zero_gid, 0, sizeof zero_gid);
+ return memcmp(&zero_gid, gid, sizeof(*gid));
+}
+
+static void print_node_desc(ib_node_record_t * node_record)
+{
+ ib_node_info_t *p_ni = &(node_record->node_info);
+ ib_node_desc_t *p_nd = &(node_record->node_desc);
+ char *name;
+
+ if (p_ni->node_type == IB_NODE_TYPE_CA) {
+ name = remap_node_name(node_name_map,
+ node_record->node_info.node_guid,
+ (char *)p_nd->description);
+ printf("%6d \"%s\"\n", cl_ntoh16(node_record->lid), name);
+ free(name);
+ }
+}
+
+static void dump_node_record(void *data, struct query_params *p)
+{
+ ib_node_record_t *nr = data;
+ ib_node_info_t *ni = &nr->node_info;
+ char *name = remap_node_name(node_name_map,
+ cl_ntoh64(ni->node_guid),
+ (char *)nr->node_desc.description);
+
+ printf("NodeRecord dump:\n"
+ "\t\tlid.....................%u\n"
+ "\t\treserved................0x%X\n"
+ "\t\tbase_version............0x%X\n"
+ "\t\tclass_version...........0x%X\n"
+ "\t\tnode_type...............%s\n"
+ "\t\tnum_ports...............%u\n"
+ "\t\tsys_guid................0x%016" PRIx64 "\n"
+ "\t\tnode_guid...............0x%016" PRIx64 "\n"
+ "\t\tport_guid...............0x%016" PRIx64 "\n"
+ "\t\tpartition_cap...........0x%X\n"
+ "\t\tdevice_id...............0x%X\n"
+ "\t\trevision................0x%X\n"
+ "\t\tport_num................%u\n"
+ "\t\tvendor_id...............0x%X\n"
+ "\t\tNodeDescription.........%s\n",
+ cl_ntoh16(nr->lid), cl_ntoh16(nr->resv),
+ ni->base_version, ni->class_version,
+ ib_get_node_type_str(ni->node_type), ni->num_ports,
+ cl_ntoh64(ni->sys_guid), cl_ntoh64(ni->node_guid),
+ cl_ntoh64(ni->port_guid), cl_ntoh16(ni->partition_cap),
+ cl_ntoh16(ni->device_id), cl_ntoh32(ni->revision),
+ ib_node_info_get_local_port_num(ni),
+ cl_ntoh32(ib_node_info_get_vendor_id(ni)),
+ name);
+
+ free(name);
+}
+
+static void print_node_record(ib_node_record_t * node_record)
+{
+ ib_node_info_t *p_ni = &node_record->node_info;
+ ib_node_desc_t *p_nd = &node_record->node_desc;
+ char *name;
+
+ switch (node_print_desc) {
+ case LID_ONLY:
+ case UNIQUE_LID_ONLY:
+ printf("%u\n", cl_ntoh16(node_record->lid));
+ return;
+ case GUID_ONLY:
+ printf("0x%016" PRIx64 "\n", cl_ntoh64(p_ni->port_guid));
+ return;
+ case NAME_OF_LID:
+ case NAME_OF_GUID:
+ name = remap_node_name(node_name_map,
+ cl_ntoh64(p_ni->node_guid),
+ (char *)p_nd->description);
+ printf("%s\n", name);
+ free(name);
+ return;
+ case ALL:
+ default:
+ break;
+ }
+
+ dump_node_record(node_record, 0);
+}
+
+static void dump_path_record(void *data, struct query_params *p)
+{
+ char gid_str[INET6_ADDRSTRLEN];
+ char gid_str2[INET6_ADDRSTRLEN];
+ ib_path_rec_t *p_pr = data;
+ printf("PathRecord dump:\n"
+ "\t\tservice_id..............0x%016" PRIx64 "\n"
+ "\t\tdgid....................%s\n"
+ "\t\tsgid....................%s\n"
+ "\t\tdlid....................%u\n"
+ "\t\tslid....................%u\n"
+ "\t\thop_flow_raw............0x%X\n"
+ "\t\ttclass..................0x%X\n"
+ "\t\tnum_path_revers.........0x%X\n"
+ "\t\tpkey....................0x%X\n"
+ "\t\tqos_class...............0x%X\n"
+ "\t\tsl......................0x%X\n"
+ "\t\tmtu.....................0x%X\n"
+ "\t\trate....................0x%X\n"
+ "\t\tpkt_life................0x%X\n"
+ "\t\tpreference..............0x%X\n"
+ "\t\tresv2...................0x%02X%02X%02X%02X%02X%02X\n",
+ cl_ntoh64(p_pr->service_id),
+ inet_ntop(AF_INET6, p_pr->dgid.raw, gid_str, sizeof gid_str),
+ inet_ntop(AF_INET6, p_pr->sgid.raw, gid_str2, sizeof gid_str2),
+ cl_ntoh16(p_pr->dlid), cl_ntoh16(p_pr->slid),
+ cl_ntoh32(p_pr->hop_flow_raw), p_pr->tclass, p_pr->num_path,
+ cl_ntoh16(p_pr->pkey), ib_path_rec_qos_class(p_pr),
+ ib_path_rec_sl(p_pr), p_pr->mtu, p_pr->rate, p_pr->pkt_life,
+ p_pr->preference,
+ p_pr->resv2[0], p_pr->resv2[1], p_pr->resv2[2],
+ p_pr->resv2[3], p_pr->resv2[4], p_pr->resv2[5]);
+}
+
+static void dump_class_port_info(ib_class_port_info_t *cpi)
+{
+ char gid_str[INET6_ADDRSTRLEN];
+ char gid_str2[INET6_ADDRSTRLEN];
+
+ printf("SA ClassPortInfo:\n"
+ "\t\tBase version.............%d\n"
+ "\t\tClass version............%d\n"
+ "\t\tCapability mask..........0x%04X\n"
+ "\t\tCapability mask 2........0x%08X\n"
+ "\t\tResponse time value......0x%02X\n"
+ "\t\tRedirect GID.............%s\n"
+ "\t\tRedirect TC/SL/FL........0x%08X\n"
+ "\t\tRedirect LID.............%u\n"
+ "\t\tRedirect PKey............0x%04X\n"
+ "\t\tRedirect QP..............0x%08X\n"
+ "\t\tRedirect QKey............0x%08X\n"
+ "\t\tTrap GID.................%s\n"
+ "\t\tTrap TC/SL/FL............0x%08X\n"
+ "\t\tTrap LID.................%u\n"
+ "\t\tTrap PKey................0x%04X\n"
+ "\t\tTrap HL/QP...............0x%08X\n"
+ "\t\tTrap QKey................0x%08X\n",
+ cpi->base_ver, cpi->class_ver, cl_ntoh16(cpi->cap_mask),
+ ib_class_cap_mask2(cpi), ib_class_resp_time_val(cpi),
+ inet_ntop(AF_INET6, &(cpi->redir_gid), gid_str, sizeof gid_str),
+ cl_ntoh32(cpi->redir_tc_sl_fl), cl_ntoh16(cpi->redir_lid),
+ cl_ntoh16(cpi->redir_pkey), cl_ntoh32(cpi->redir_qp),
+ cl_ntoh32(cpi->redir_qkey),
+ inet_ntop(AF_INET6, &(cpi->trap_gid), gid_str2, sizeof gid_str2),
+ cl_ntoh32(cpi->trap_tc_sl_fl), cl_ntoh16(cpi->trap_lid),
+ cl_ntoh16(cpi->trap_pkey), cl_ntoh32(cpi->trap_hop_qp),
+ cl_ntoh32(cpi->trap_qkey));
+}
+
+static void dump_portinfo_record(void *data, struct query_params *p)
+{
+ ib_portinfo_record_t *p_pir = data;
+ const ib_port_info_t *const p_pi = &p_pir->port_info;
+
+ printf("PortInfoRecord dump:\n"
+ "\t\tEndPortLid..............%u\n"
+ "\t\tPortNum.................%u\n"
+ "\t\tbase_lid................%u\n"
+ "\t\tmaster_sm_base_lid......%u\n"
+ "\t\tcapability_mask.........0x%X\n",
+ cl_ntoh16(p_pir->lid), p_pir->port_num,
+ cl_ntoh16(p_pi->base_lid), cl_ntoh16(p_pi->master_sm_base_lid),
+ cl_ntoh32(p_pi->capability_mask));
+}
+
+static void dump_one_portinfo_record(void *data, struct query_params *p)
+{
+ ib_portinfo_record_t *pir = data;
+ ib_port_info_t *pi = &pir->port_info;
+
+ printf("PortInfoRecord dump:\n"
+ "\tRID\n"
+ "\t\tEndPortLid..............%u\n"
+ "\t\tPortNum.................%u\n"
+ "\t\tOptions.................0x%x\n"
+ "\tPortInfo dump:\n",
+ cl_ntoh16(pir->lid), pir->port_num, pir->options);
+ dump_portinfo(pi, 2);
+}
+
+static void dump_one_mcmember_record(void *data, struct query_params *p)
+{
+ char mgid[INET6_ADDRSTRLEN], gid[INET6_ADDRSTRLEN];
+ ib_member_rec_t *mr = data;
+ uint32_t flow;
+ uint8_t sl, hop, scope, join;
+ ib_member_get_sl_flow_hop(mr->sl_flow_hop, &sl, &flow, &hop);
+ ib_member_get_scope_state(mr->scope_state, &scope, &join);
+ printf("MCMember Record dump:\n"
+ "\t\tMGID....................%s\n"
+ "\t\tPortGid.................%s\n"
+ "\t\tqkey....................0x%x\n"
+ "\t\tmlid....................0x%x\n"
+ "\t\tmtu.....................0x%x\n"
+ "\t\tTClass..................0x%x\n"
+ "\t\tpkey....................0x%x\n"
+ "\t\trate....................0x%x\n"
+ "\t\tpkt_life................0x%x\n"
+ "\t\tSL......................0x%x\n"
+ "\t\tFlowLabel...............0x%x\n"
+ "\t\tHopLimit................0x%x\n"
+ "\t\tScope...................0x%x\n"
+ "\t\tJoinState...............0x%x\n"
+ "\t\tProxyJoin...............0x%x\n",
+ inet_ntop(AF_INET6, mr->mgid.raw, mgid, sizeof(mgid)),
+ inet_ntop(AF_INET6, mr->port_gid.raw, gid, sizeof(gid)),
+ cl_ntoh32(mr->qkey), cl_ntoh16(mr->mlid), mr->mtu, mr->tclass,
+ cl_ntoh16(mr->pkey), mr->rate, mr->pkt_life, sl,
+ flow, hop, scope, join, mr->proxy_join);
+}
+
+static void dump_multicast_group_record(void *data, struct query_params *p)
+{
+ char gid_str[INET6_ADDRSTRLEN];
+ ib_member_rec_t *p_mcmr = data;
+ uint8_t sl;
+ ib_member_get_sl_flow_hop(p_mcmr->sl_flow_hop, &sl, NULL, NULL);
+ printf("MCMemberRecord group dump:\n"
+ "\t\tMGID....................%s\n"
+ "\t\tMlid....................0x%X\n"
+ "\t\tMtu.....................0x%X\n"
+ "\t\tpkey....................0x%X\n"
+ "\t\tRate....................0x%X\n"
+ "\t\tSL......................0x%X\n",
+ inet_ntop(AF_INET6, p_mcmr->mgid.raw, gid_str, sizeof gid_str),
+ cl_ntoh16(p_mcmr->mlid),
+ p_mcmr->mtu, cl_ntoh16(p_mcmr->pkey), p_mcmr->rate, sl);
+}
+
+static void dump_multicast_member_record(ib_member_rec_t *p_mcmr,
+ struct sa_query_result *nr_result,
+ struct query_params *params)
+{
+ char gid_str[INET6_ADDRSTRLEN];
+ char gid_str2[INET6_ADDRSTRLEN];
+ uint16_t mlid = cl_ntoh16(p_mcmr->mlid);
+ unsigned i = 0;
+ char *node_name = strdup("<unknown>");
+
+ /* go through the node records searching for a port guid which matches
+ * this port gid interface id.
+ * This gives us a node name to print, if available.
+ */
+ for (i = 0; i < nr_result->result_cnt; i++) {
+ ib_node_record_t *nr = sa_get_query_rec(nr_result->p_result_madw, i);
+ if (nr->node_info.port_guid ==
+ p_mcmr->port_gid.unicast.interface_id) {
+ if(node_name != NULL)
+ free(node_name);
+ node_name = remap_node_name(node_name_map,
+ nr->node_info.node_guid,
+ (char *)nr->node_desc.description);
+ break;
+ }
+ }
+
+ if (requested_name) {
+ if (strtol(requested_name, NULL, 0) == mlid)
+ printf("\t\tPortGid.................%s (%s)\n",
+ inet_ntop(AF_INET6, p_mcmr->port_gid.raw,
+ gid_str, sizeof gid_str), node_name);
+ } else {
+ printf("MCMemberRecord member dump:\n"
+ "\t\tMGID....................%s\n"
+ "\t\tMlid....................0x%X\n"
+ "\t\tPortGid.................%s\n"
+ "\t\tScopeState..............0x%X\n"
+ "\t\tProxyJoin...............0x%X\n"
+ "\t\tNodeDescription.........%s\n",
+ inet_ntop(AF_INET6, p_mcmr->mgid.raw, gid_str,
+ sizeof gid_str),
+ cl_ntoh16(p_mcmr->mlid),
+ inet_ntop(AF_INET6, p_mcmr->port_gid.raw,
+ gid_str2, sizeof gid_str2),
+ p_mcmr->scope_state, p_mcmr->proxy_join, node_name);
+ }
+ free(node_name);
+}
+
+static void dump_service_record(void *data, struct query_params *p)
+{
+ char gid[INET6_ADDRSTRLEN];
+ char buf_service_key[35];
+ char buf_service_name[65];
+ ib_service_record_t *p_sr = data;
+
+ sprintf(buf_service_key,
+ "0x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x",
+ p_sr->service_key[0], p_sr->service_key[1],
+ p_sr->service_key[2], p_sr->service_key[3],
+ p_sr->service_key[4], p_sr->service_key[5],
+ p_sr->service_key[6], p_sr->service_key[7],
+ p_sr->service_key[8], p_sr->service_key[9],
+ p_sr->service_key[10], p_sr->service_key[11],
+ p_sr->service_key[12], p_sr->service_key[13],
+ p_sr->service_key[14], p_sr->service_key[15]);
+ strncpy(buf_service_name, (char *)p_sr->service_name, 64);
+ buf_service_name[64] = '\0';
+
+ printf("ServiceRecord dump:\n"
+ "\t\tServiceID...............0x%016" PRIx64 "\n"
+ "\t\tServiceGID..............%s\n"
+ "\t\tServiceP_Key............0x%X\n"
+ "\t\tServiceLease............0x%X\n"
+ "\t\tServiceKey..............%s\n"
+ "\t\tServiceName.............%s\n"
+ "\t\tServiceData8.1..........0x%X\n"
+ "\t\tServiceData8.2..........0x%X\n"
+ "\t\tServiceData8.3..........0x%X\n"
+ "\t\tServiceData8.4..........0x%X\n"
+ "\t\tServiceData8.5..........0x%X\n"
+ "\t\tServiceData8.6..........0x%X\n"
+ "\t\tServiceData8.7..........0x%X\n"
+ "\t\tServiceData8.8..........0x%X\n"
+ "\t\tServiceData8.9..........0x%X\n"
+ "\t\tServiceData8.10.........0x%X\n"
+ "\t\tServiceData8.11.........0x%X\n"
+ "\t\tServiceData8.12.........0x%X\n"
+ "\t\tServiceData8.13.........0x%X\n"
+ "\t\tServiceData8.14.........0x%X\n"
+ "\t\tServiceData8.15.........0x%X\n"
+ "\t\tServiceData8.16.........0x%X\n"
+ "\t\tServiceData16.1.........0x%X\n"
+ "\t\tServiceData16.2.........0x%X\n"
+ "\t\tServiceData16.3.........0x%X\n"
+ "\t\tServiceData16.4.........0x%X\n"
+ "\t\tServiceData16.5.........0x%X\n"
+ "\t\tServiceData16.6.........0x%X\n"
+ "\t\tServiceData16.7.........0x%X\n"
+ "\t\tServiceData16.8.........0x%X\n"
+ "\t\tServiceData32.1.........0x%X\n"
+ "\t\tServiceData32.2.........0x%X\n"
+ "\t\tServiceData32.3.........0x%X\n"
+ "\t\tServiceData32.4.........0x%X\n"
+ "\t\tServiceData64.1.........0x%016" PRIx64 "\n"
+ "\t\tServiceData64.2.........0x%016" PRIx64 "\n",
+ cl_ntoh64(p_sr->service_id),
+ inet_ntop(AF_INET6, p_sr->service_gid.raw, gid, sizeof gid),
+ cl_ntoh16(p_sr->service_pkey), cl_ntoh32(p_sr->service_lease),
+ (show_keys ? buf_service_key : NOT_DISPLAYED_STR),
+ buf_service_name,
+ p_sr->service_data8[0], p_sr->service_data8[1],
+ p_sr->service_data8[2], p_sr->service_data8[3],
+ p_sr->service_data8[4], p_sr->service_data8[5],
+ p_sr->service_data8[6], p_sr->service_data8[7],
+ p_sr->service_data8[8], p_sr->service_data8[9],
+ p_sr->service_data8[10], p_sr->service_data8[11],
+ p_sr->service_data8[12], p_sr->service_data8[13],
+ p_sr->service_data8[14], p_sr->service_data8[15],
+ cl_ntoh16(p_sr->service_data16[0]),
+ cl_ntoh16(p_sr->service_data16[1]),
+ cl_ntoh16(p_sr->service_data16[2]),
+ cl_ntoh16(p_sr->service_data16[3]),
+ cl_ntoh16(p_sr->service_data16[4]),
+ cl_ntoh16(p_sr->service_data16[5]),
+ cl_ntoh16(p_sr->service_data16[6]),
+ cl_ntoh16(p_sr->service_data16[7]),
+ cl_ntoh32(p_sr->service_data32[0]),
+ cl_ntoh32(p_sr->service_data32[1]),
+ cl_ntoh32(p_sr->service_data32[2]),
+ cl_ntoh32(p_sr->service_data32[3]),
+ cl_ntoh64(p_sr->service_data64[0]),
+ cl_ntoh64(p_sr->service_data64[1]));
+}
+
+static void dump_sm_info_record(void *data, struct query_params *p)
+{
+ ib_sminfo_record_t *p_smr = data;
+ const ib_sm_info_t *const p_smi = &p_smr->sm_info;
+ uint8_t priority, state;
+ priority = ib_sminfo_get_priority(p_smi);
+ state = ib_sminfo_get_state(p_smi);
+
+ printf("SMInfoRecord dump:\n"
+ "\t\tRID\n"
+ "\t\tLID...................%u\n"
+ "\t\tSMInfo dump:\n"
+ "\t\tGUID..................0x%016" PRIx64 "\n"
+ "\t\tSM_Key................0x%016" PRIx64 "\n"
+ "\t\tActCount..............%u\n"
+ "\t\tPriority..............%u\n"
+ "\t\tSMState...............%u\n",
+ cl_ntoh16(p_smr->lid),
+ cl_ntoh64(p_smr->sm_info.guid),
+ cl_ntoh64(p_smr->sm_info.sm_key),
+ cl_ntoh32(p_smr->sm_info.act_count),
+ priority, state);
+}
+
+static void dump_switch_info_record(void *data, struct query_params *p)
+{
+ ib_switch_info_record_t *p_sir = data;
+ uint32_t sa_cap_mask2 = ib_class_cap_mask2(&p->cpi);
+
+ printf("SwitchInfoRecord dump:\n"
+ "\t\tRID\n"
+ "\t\tLID.....................................%u\n"
+ "\t\tSwitchInfo dump:\n"
+ "\t\tLinearFDBCap............................0x%X\n"
+ "\t\tRandomFDBCap............................0x%X\n"
+ "\t\tMulticastFDBCap.........................0x%X\n"
+ "\t\tLinearFDBTop............................0x%X\n"
+ "\t\tDefaultPort.............................%u\n"
+ "\t\tDefaultMulticastPrimaryPort.............%u\n"
+ "\t\tDefaultMulticastNotPrimaryPort..........%u\n"
+ "\t\tLifeTimeValue/PortStateChange/OpSL2VL...0x%X\n"
+ "\t\tLIDsPerPort.............................0x%X\n"
+ "\t\tPartitionEnforcementCap.................0x%X\n"
+ "\t\tflags...................................0x%X\n",
+ cl_ntoh16(p_sir->lid),
+ cl_ntoh16(p_sir->switch_info.lin_cap),
+ cl_ntoh16(p_sir->switch_info.rand_cap),
+ cl_ntoh16(p_sir->switch_info.mcast_cap),
+ cl_ntoh16(p_sir->switch_info.lin_top),
+ p_sir->switch_info.def_port,
+ p_sir->switch_info.def_mcast_pri_port,
+ p_sir->switch_info.def_mcast_not_port,
+ p_sir->switch_info.life_state,
+ cl_ntoh16(p_sir->switch_info.lids_per_port),
+ cl_ntoh16(p_sir->switch_info.enforce_cap),
+ p_sir->switch_info.flags);
+ if (sa_cap_mask2 & UMAD_SA_CAP_MASK2_IS_MCAST_TOP_SUP)
+ printf("\t\tMulticastFDBTop.........................0x%X\n",
+ cl_ntoh16(p_sir->switch_info.mcast_top));
+}
+
+static void dump_inform_info_record(void *data, struct query_params *p)
+{
+ char gid_str[INET6_ADDRSTRLEN];
+ char gid_str2[INET6_ADDRSTRLEN];
+ ib_inform_info_record_t *p_iir = data;
+ uint32_t qpn;
+ uint8_t resp_time_val;
+
+ ib_inform_info_get_qpn_resp_time(p_iir->inform_info.g_or_v.
+ generic.qpn_resp_time_val, &qpn,
+ &resp_time_val);
+ if (p_iir->inform_info.is_generic) {
+ printf("InformInfoRecord dump:\n"
+ "\t\tRID\n"
+ "\t\tSubscriberGID...........%s\n"
+ "\t\tSubscriberEnum..........0x%X\n"
+ "\t\tInformInfo dump:\n"
+ "\t\tgid.....................%s\n"
+ "\t\tlid_range_begin.........%u\n"
+ "\t\tlid_range_end...........%u\n"
+ "\t\tis_generic..............0x%X\n"
+ "\t\tsubscribe...............0x%X\n"
+ "\t\ttrap_type...............0x%X\n"
+ "\t\ttrap_num................%u\n",
+ inet_ntop(AF_INET6, p_iir->subscriber_gid.raw, gid_str,
+ sizeof gid_str),
+ cl_ntoh16(p_iir->subscriber_enum),
+ inet_ntop(AF_INET6, p_iir->inform_info.gid.raw, gid_str2,
+ sizeof gid_str2),
+ cl_ntoh16(p_iir->inform_info.lid_range_begin),
+ cl_ntoh16(p_iir->inform_info.lid_range_end),
+ p_iir->inform_info.is_generic,
+ p_iir->inform_info.subscribe,
+ cl_ntoh16(p_iir->inform_info.trap_type),
+ cl_ntoh16(p_iir->inform_info.g_or_v.generic.trap_num));
+ if (show_keys) {
+ printf("\t\tqpn.....................0x%06X\n",
+ cl_ntoh32(qpn));
+ } else {
+ printf("\t\tqpn....................."
+ NOT_DISPLAYED_STR "\n");
+ }
+ printf("\t\tresp_time_val...........0x%X\n"
+ "\t\tnode_type...............0x%06X\n",
+ resp_time_val,
+ cl_ntoh32(ib_inform_info_get_prod_type
+ (&p_iir->inform_info)));
+ } else {
+ printf("InformInfoRecord dump:\n"
+ "\t\tRID\n"
+ "\t\tSubscriberGID...........%s\n"
+ "\t\tSubscriberEnum..........0x%X\n"
+ "\t\tInformInfo dump:\n"
+ "\t\tgid.....................%s\n"
+ "\t\tlid_range_begin.........%u\n"
+ "\t\tlid_range_end...........%u\n"
+ "\t\tis_generic..............0x%X\n"
+ "\t\tsubscribe...............0x%X\n"
+ "\t\ttrap_type...............0x%X\n"
+ "\t\tdev_id..................0x%X\n",
+ inet_ntop(AF_INET6, p_iir->subscriber_gid.raw, gid_str,
+ sizeof gid_str),
+ cl_ntoh16(p_iir->subscriber_enum),
+ inet_ntop(AF_INET6, p_iir->inform_info.gid.raw,
+ gid_str2, sizeof gid_str2),
+ cl_ntoh16(p_iir->inform_info.lid_range_begin),
+ cl_ntoh16(p_iir->inform_info.lid_range_end),
+ p_iir->inform_info.is_generic,
+ p_iir->inform_info.subscribe,
+ cl_ntoh16(p_iir->inform_info.trap_type),
+ cl_ntoh16(p_iir->inform_info.g_or_v.vend.dev_id));
+ if (show_keys) {
+ printf("\t\tqpn.....................0x%06X\n",
+ cl_ntoh32(qpn));
+ } else {
+ printf("\t\tqpn....................."
+ NOT_DISPLAYED_STR "\n");
+ }
+ printf("\t\tresp_time_val...........0x%X\n"
+ "\t\tvendor_id...............0x%06X\n",
+ resp_time_val,
+ cl_ntoh32(ib_inform_info_get_prod_type
+ (&p_iir->inform_info)));
+ }
+}
+
+static void dump_one_link_record(void *data, struct query_params *p)
+{
+ ib_link_record_t *lr = data;
+ printf("LinkRecord dump:\n"
+ "\t\tFromLID....................%u\n"
+ "\t\tFromPort...................%u\n"
+ "\t\tToPort.....................%u\n"
+ "\t\tToLID......................%u\n",
+ cl_ntoh16(lr->from_lid), lr->from_port_num,
+ lr->to_port_num, cl_ntoh16(lr->to_lid));
+}
+
+static void dump_one_slvl_record(void *data, struct query_params *p)
+{
+ ib_slvl_table_record_t *slvl = data;
+ ib_slvl_table_t *t = &slvl->slvl_tbl;
+ printf("SL2VLTableRecord dump:\n"
+ "\t\tLID........................%u\n"
+ "\t\tInPort.....................%u\n"
+ "\t\tOutPort....................%u\n"
+ "\t\tSL: 0| 1| 2| 3| 4| 5| 6| 7| 8| 9|10|11|12|13|14|15|\n"
+ "\t\tVL:%2u|%2u|%2u|%2u|%2u|%2u|%2u|%2u|%2u|%2u|%2u|%2u|%2u"
+ "|%2u|%2u|%2u|\n",
+ cl_ntoh16(slvl->lid), slvl->in_port_num, slvl->out_port_num,
+ ib_slvl_table_get(t, 0), ib_slvl_table_get(t, 1),
+ ib_slvl_table_get(t, 2), ib_slvl_table_get(t, 3),
+ ib_slvl_table_get(t, 4), ib_slvl_table_get(t, 5),
+ ib_slvl_table_get(t, 6), ib_slvl_table_get(t, 7),
+ ib_slvl_table_get(t, 8), ib_slvl_table_get(t, 9),
+ ib_slvl_table_get(t, 10), ib_slvl_table_get(t, 11),
+ ib_slvl_table_get(t, 12), ib_slvl_table_get(t, 13),
+ ib_slvl_table_get(t, 14), ib_slvl_table_get(t, 15));
+}
+
+static void dump_one_vlarb_record(void *data, struct query_params *p)
+{
+ ib_vl_arb_table_record_t *vlarb = data;
+ ib_vl_arb_element_t *e = vlarb->vl_arb_tbl.vl_entry;
+ int i;
+ printf("VLArbTableRecord dump:\n"
+ "\t\tLID........................%u\n"
+ "\t\tPort.......................%u\n"
+ "\t\tBlock......................%u\n",
+ cl_ntoh16(vlarb->lid), vlarb->port_num, vlarb->block_num);
+ for (i = 0; i < 32; i += 16)
+ printf("\t\tVL :%2u|%2u|%2u|%2u|%2u|%2u|%2u|%2u|"
+ "%2u|%2u|%2u|%2u|%2u|%2u|%2u|%2u|\n"
+ "\t\tWeight:%2u|%2u|%2u|%2u|%2u|%2u|%2u|%2u|"
+ "%2u|%2u|%2u|%2u|%2u|%2u|%2u|%2u|\n",
+ e[i + 0].vl, e[i + 1].vl, e[i + 2].vl, e[i + 3].vl,
+ e[i + 4].vl, e[i + 5].vl, e[i + 6].vl, e[i + 7].vl,
+ e[i + 8].vl, e[i + 9].vl, e[i + 10].vl, e[i + 11].vl,
+ e[i + 12].vl, e[i + 13].vl, e[i + 14].vl, e[i + 15].vl,
+ e[i + 0].weight, e[i + 1].weight, e[i + 2].weight,
+ e[i + 3].weight, e[i + 4].weight, e[i + 5].weight,
+ e[i + 6].weight, e[i + 7].weight, e[i + 8].weight,
+ e[i + 9].weight, e[i + 10].weight, e[i + 11].weight,
+ e[i + 12].weight, e[i + 13].weight, e[i + 14].weight,
+ e[i + 15].weight);
+}
+
+static void dump_one_pkey_tbl_record(void *data, struct query_params *params)
+{
+ ib_pkey_table_record_t *pktr = data;
+ ib_net16_t *p = pktr->pkey_tbl.pkey_entry;
+ int i;
+ printf("PKeyTableRecord dump:\n"
+ "\t\tLID........................%u\n"
+ "\t\tPort.......................%u\n"
+ "\t\tBlock......................%u\n"
+ "\t\tPKey Table:\n",
+ cl_ntoh16(pktr->lid), pktr->port_num, pktr->block_num);
+ for (i = 0; i < 32; i += 8)
+ printf("\t\t0x%04x 0x%04x 0x%04x 0x%04x"
+ " 0x%04x 0x%04x 0x%04x 0x%04x\n",
+ cl_ntoh16(p[i + 0]), cl_ntoh16(p[i + 1]),
+ cl_ntoh16(p[i + 2]), cl_ntoh16(p[i + 3]),
+ cl_ntoh16(p[i + 4]), cl_ntoh16(p[i + 5]),
+ cl_ntoh16(p[i + 6]), cl_ntoh16(p[i + 7]));
+ printf("\n");
+}
+
+static void dump_one_lft_record(void *data, struct query_params *p)
+{
+ ib_lft_record_t *lftr = data;
+ unsigned block = cl_ntoh16(lftr->block_num);
+ int i;
+ printf("LFT Record dump:\n"
+ "\t\tLID........................%u\n"
+ "\t\tBlock......................%u\n"
+ "\t\tLFT:\n\t\tLID\tPort Number\n", cl_ntoh16(lftr->lid), block);
+ for (i = 0; i < 64; i++)
+ printf("\t\t%u\t%u\n", block * 64 + i, lftr->lft[i]);
+ printf("\n");
+}
+
+static void dump_one_guidinfo_record(void *data, struct query_params *p)
+{
+ ib_guidinfo_record_t *gir = data;
+ printf("GUIDInfo Record dump:\n"
+ "\t\tLID........................%u\n"
+ "\t\tBlock......................%u\n"
+ "\t\tGUID 0.....................0x%016" PRIx64 "\n"
+ "\t\tGUID 1.....................0x%016" PRIx64 "\n"
+ "\t\tGUID 2.....................0x%016" PRIx64 "\n"
+ "\t\tGUID 3.....................0x%016" PRIx64 "\n"
+ "\t\tGUID 4.....................0x%016" PRIx64 "\n"
+ "\t\tGUID 5.....................0x%016" PRIx64 "\n"
+ "\t\tGUID 6.....................0x%016" PRIx64 "\n"
+ "\t\tGUID 7.....................0x%016" PRIx64 "\n",
+ cl_ntoh16(gir->lid), gir->block_num,
+ cl_ntoh64(gir->guid_info.guid[0]),
+ cl_ntoh64(gir->guid_info.guid[1]),
+ cl_ntoh64(gir->guid_info.guid[2]),
+ cl_ntoh64(gir->guid_info.guid[3]),
+ cl_ntoh64(gir->guid_info.guid[4]),
+ cl_ntoh64(gir->guid_info.guid[5]),
+ cl_ntoh64(gir->guid_info.guid[6]),
+ cl_ntoh64(gir->guid_info.guid[7]));
+}
+
+static void dump_one_mft_record(void *data, struct query_params *p)
+{
+ ib_mft_record_t *mftr = data;
+ unsigned position = cl_ntoh16(mftr->position_block_num) >> 12;
+ unsigned block = cl_ntoh16(mftr->position_block_num) &
+ IB_MCAST_BLOCK_ID_MASK_HO;
+ int i;
+ unsigned offset;
+
+ printf("MFT Record dump:\n"
+ "\t\tLID........................%u\n"
+ "\t\tPosition...................%u\n"
+ "\t\tBlock......................%u\n"
+ "\t\tMFT:\n\t\tMLID\tPort Mask\n",
+ cl_ntoh16(mftr->lid), position, block);
+ offset = IB_LID_MCAST_START_HO + block * 32;
+ for (i = 0; i < IB_MCAST_BLOCK_SIZE; i++)
+ printf("\t\t0x%04x\t0x%04x\n",
+ offset + i, cl_ntoh16(mftr->mft[i]));
+ printf("\n");
+}
+
+static void dump_results(struct sa_query_result *r,
+ void (*dump_func) (void *, struct query_params *),
+ struct query_params *p)
+{
+ unsigned i;
+ for (i = 0; i < r->result_cnt; i++) {
+ void *data = sa_get_query_rec(r->p_result_madw, i);
+ dump_func(data, p);
+ }
+}
+
+/**
+ * Get any record(s)
+ */
+static int get_any_records(struct sa_handle * h,
+ uint16_t attr_id, uint32_t attr_mod,
+ ib_net64_t comp_mask, void *attr,
+ size_t attr_size,
+ struct sa_query_result *result)
+{
+ int ret = sa_query(h, IB_MAD_METHOD_GET_TABLE, attr_id, attr_mod,
+ cl_ntoh64(comp_mask), ibd_sakey, attr, attr_size, result);
+ if (ret) {
+ fprintf(stderr, "Query SA failed: %s\n", strerror(ret));
+ return ret;
+ }
+
+ if (result->status != IB_SA_MAD_STATUS_SUCCESS) {
+ sa_report_err(result->status);
+ return EIO;
+ }
+
+ return ret;
+}
+
+static int get_and_dump_any_records(struct sa_handle * h, uint16_t attr_id,
+ uint32_t attr_mod, ib_net64_t comp_mask,
+ void *attr,
+ size_t attr_size,
+ void (*dump_func) (void *,
+ struct query_params *),
+ struct query_params *p)
+{
+ struct sa_query_result result;
+ int ret = get_any_records(h, attr_id, attr_mod, comp_mask, attr,
+ attr_size, &result);
+ if (ret)
+ return ret;
+
+ dump_results(&result, dump_func, p);
+ sa_free_result_mad(&result);
+ return 0;
+}
+
+/**
+ * Get all the records available for requested query type.
+ */
+static int get_all_records(struct sa_handle * h, uint16_t attr_id,
+ struct sa_query_result *result)
+{
+ return get_any_records(h, attr_id, 0, 0, NULL, 0, result);
+}
+
+static int get_and_dump_all_records(struct sa_handle * h, uint16_t attr_id,
+ void (*dump_func) (void *,
+ struct query_params *p),
+ struct query_params *p)
+{
+ struct sa_query_result result;
+ int ret = get_all_records(h, attr_id, &result);
+ if (ret)
+ return ret;
+
+ dump_results(&result, dump_func, p);
+ sa_free_result_mad(&result);
+ return ret;
+}
+
+/**
+ * return the lid from the node descriptor (name) supplied
+ */
+static int get_lid_from_name(struct sa_handle * h, const char *name, uint16_t * lid)
+{
+ ib_node_record_t *node_record = NULL;
+ unsigned i;
+ int ret;
+ struct sa_query_result result;
+
+ ret = get_all_records(h, IB_SA_ATTR_NODERECORD, &result);
+ if (ret)
+ return ret;
+
+ ret = EHOSTDOWN;
+ for (i = 0; i < result.result_cnt; i++) {
+ node_record = sa_get_query_rec(result.p_result_madw, i);
+ if (name
+ && strncmp(name, (char *)node_record->node_desc.description,
+ sizeof(node_record->node_desc.description)) ==
+ 0) {
+ *lid = cl_ntoh16(node_record->lid);
+ ret = 0;
+ break;
+ }
+ }
+ sa_free_result_mad(&result);
+ return ret;
+}
+
+static uint16_t get_lid(struct sa_handle * h, const char *name)
+{
+ int rc = 0;
+ uint16_t rc_lid = 0;
+
+ if (!name)
+ return 0;
+ if (isalpha(name[0])) {
+ if ((rc = get_lid_from_name(h, name, &rc_lid)) != 0) {
+ fprintf(stderr, "Failed to find lid for \"%s\": %s\n",
+ name, strerror(rc));
+ exit(rc);
+ }
+ } else {
+ long val;
+ errno = 0;
+ val = strtol(name, NULL, 0);
+ if (errno != 0 || val <= 0 || val > UINT16_MAX) {
+ fprintf(stderr, "Invalid lid specified: \"%s\"\n", name);
+ exit(EINVAL);
+ }
+ rc_lid = (uint16_t)val;
+ }
+
+ return rc_lid;
+}
+
+static int parse_iir_subscriber_gid(char *str, ib_inform_info_record_t *ir)
+{
+ int rc = inet_pton(AF_INET6,str,&(ir->subscriber_gid.raw));
+ if(rc < 1){
+ fprintf(stderr, "Invalid SubscriberGID specified: \"%s\"\n",str);
+ exit(EINVAL);
+ }
+ return rc;
+}
+
+static int parse_lid_and_ports(struct sa_handle * h,
+ char *str, int *lid, int *port1, int *port2)
+{
+ char *p, *e;
+
+ if (port1)
+ *port1 = -1;
+ if (port2)
+ *port2 = -1;
+
+ p = strchr(str, '/');
+ if (p)
+ *p = '\0';
+ if (lid)
+ *lid = get_lid(h, str);
+
+ if (!p)
+ return 0;
+ str = p + 1;
+ p = strchr(str, '/');
+ if (p)
+ *p = '\0';
+ if (port1) {
+ *port1 = strtoul(str, &e, 0);
+ if (e == str)
+ *port1 = -1;
+ }
+
+ if (!p)
+ return 0;
+ str = p + 1;
+ if (port2) {
+ *port2 = strtoul(str, &e, 0);
+ if (e == str)
+ *port2 = -1;
+ }
+
+ return 0;
+}
+
+/*
+ * Get the portinfo records available with IsSM or IsSMdisabled CapabilityMask bit on.
+ */
+static int get_issm_records(struct sa_handle * h, ib_net32_t capability_mask,
+ struct sa_query_result *result)
+{
+ ib_portinfo_record_t attr;
+
+ memset(&attr, 0, sizeof(attr));
+ attr.port_info.capability_mask = capability_mask;
+
+ return get_any_records(h, IB_SA_ATTR_PORTINFORECORD, 1 << 31,
+ IB_PIR_COMPMASK_CAPMASK, &attr, sizeof(attr), result);
+}
+
+static int print_node_records(struct sa_handle * h, struct query_params *p)
+{
+ unsigned i;
+ int ret;
+ struct sa_query_result result;
+
+ ret = get_all_records(h, IB_SA_ATTR_NODERECORD, &result);
+ if (ret)
+ return ret;
+
+ if (node_print_desc == ALL_DESC) {
+ printf(" LID \"name\"\n");
+ printf("================\n");
+ }
+ for (i = 0; i < result.result_cnt; i++) {
+ ib_node_record_t *node_record;
+ node_record = sa_get_query_rec(result.p_result_madw, i);
+ if (node_print_desc == ALL_DESC) {
+ print_node_desc(node_record);
+ } else if (node_print_desc == NAME_OF_LID) {
+ if (requested_lid == cl_ntoh16(node_record->lid))
+ print_node_record(node_record);
+ } else if (node_print_desc == NAME_OF_GUID) {
+ ib_node_info_t *p_ni = &(node_record->node_info);
+
+ if (requested_guid == cl_ntoh64(p_ni->port_guid))
+ print_node_record(node_record);
+ } else {
+ ib_node_info_t *p_ni = &(node_record->node_info);
+ ib_node_desc_t *p_nd = &(node_record->node_desc);
+ char *name;
+
+ name = remap_node_name (node_name_map,
+ cl_ntoh64(p_ni->node_guid),
+ (char *)p_nd->description);
+
+ if (!requested_name ||
+ (strncmp(requested_name,
+ (char *)node_record->node_desc.description,
+ sizeof(node_record->
+ node_desc.description)) == 0) ||
+ (strncmp(requested_name,
+ name,
+ sizeof(node_record->
+ node_desc.description)) == 0)) {
+ print_node_record(node_record);
+ if (node_print_desc == UNIQUE_LID_ONLY) {
+ sa_free_result_mad(&result);
+ exit(0);
+ }
+ }
+
+ free(name);
+ }
+ }
+ sa_free_result_mad(&result);
+ return ret;
+}
+
+static int sm_pr_query(struct sa_handle * h, ibmad_gid_t *gid, int srclid, int destlid) {
+
+ ib_path_rec_t pr;
+ ib_net64_t comp_mask = 0;
+ struct sa_query_result result;
+ int ret;
+ ib_path_rec_t *p_pr;
+
+ memset(&pr, 0, sizeof(pr));
+ CHECK_AND_SET_VAL(srclid, 16, 0, pr.slid, PR, SLID);
+ CHECK_AND_SET_VAL(destlid, 16, 0, pr.dlid, PR, DLID);
+
+ ret = get_any_records(h, IB_SA_ATTR_PATHRECORD, 0, comp_mask, &pr, sizeof(pr), &result);
+ if (ret)
+ return ret;
+
+ p_pr = sa_get_query_rec(result.p_result_madw, 0);
+ memcpy(gid, &p_pr->dgid, 16);
+ sa_free_result_mad(&result);
+ return ret;
+}
+
+static int query_path_records(const struct query_cmd *q, struct sa_handle * h,
+ struct query_params *p, int argc, char *argv[])
+{
+ ib_path_rec_t pr;
+ ib_net64_t comp_mask = 0;
+ uint32_t flow = 0;
+ uint16_t qos_class = 0;
+ uint8_t reversible = 0;
+
+ memset(&pr, 0, sizeof(pr));
+ CHECK_AND_SET_VAL(p->service_id, 64, 0, pr.service_id, PR, SERVICEID);
+ CHECK_AND_SET_GID(p->sgid, pr.sgid, PR, SGID);
+ CHECK_AND_SET_GID(p->dgid, pr.dgid, PR, DGID);
+ CHECK_AND_SET_VAL(p->slid, 16, 0, pr.slid, PR, SLID);
+ CHECK_AND_SET_VAL(p->dlid, 16, 0, pr.dlid, PR, DLID);
+ CHECK_AND_SET_VAL(p->hop_limit, 32, -1, pr.hop_flow_raw, PR, HOPLIMIT);
+ CHECK_AND_SET_VAL((p->flow_label << 8), 32, 0, flow, PR, FLOWLABEL);
+ pr.hop_flow_raw =
+ (pr.hop_flow_raw & cl_hton32(~0x0FFFFF00)) | flow;
+ CHECK_AND_SET_VAL(p->tclass, 8, 0, pr.tclass, PR, TCLASS);
+ CHECK_AND_SET_VAL(p->reversible, 8, -1, reversible, PR, REVERSIBLE);
+ CHECK_AND_SET_VAL(p->numb_path, 8, -1, pr.num_path, PR, NUMBPATH);
+ pr.num_path |= reversible << 7;
+ CHECK_AND_SET_VAL(p->pkey, 16, 0, pr.pkey, PR, PKEY);
+ CHECK_AND_SET_VAL(p->sl, 16, -1, pr.qos_class_sl, PR, SL);
+ CHECK_AND_SET_VAL((p->qos_class << 4), 16, -1, qos_class, PR, QOS_CLASS);
+ pr.qos_class_sl = (pr.qos_class_sl & CL_HTON16(IB_PATH_REC_SL_MASK)) |
+ qos_class;
+ CHECK_AND_SET_VAL_AND_SEL(p->mtu, pr.mtu, PR, MTU, SELEC);
+ CHECK_AND_SET_VAL_AND_SEL(p->rate, pr.rate, PR, RATE, SELEC);
+ CHECK_AND_SET_VAL_AND_SEL(p->pkt_life, pr.pkt_life, PR, PKTLIFETIME,
+ SELEC);
+
+ return get_and_dump_any_records(h, IB_SA_ATTR_PATHRECORD, 0, comp_mask,
+ &pr, sizeof(pr), dump_path_record, p);
+}
+
+static int print_issm_records(struct sa_handle * h, struct query_params *p)
+{
+ struct sa_query_result result;
+ int ret = 0;
+
+ /* First, get IsSM records */
+ ret = get_issm_records(h, IB_PORT_CAP_IS_SM, &result);
+ if (ret != 0)
+ return (ret);
+
+ printf("IsSM ports\n");
+ dump_results(&result, dump_portinfo_record, p);
+ sa_free_result_mad(&result);
+
+ /* Now, get IsSMdisabled records */
+ ret = get_issm_records(h, IB_PORT_CAP_SM_DISAB, &result);
+ if (ret != 0)
+ return (ret);
+
+ printf("\nIsSMdisabled ports\n");
+ dump_results(&result, dump_portinfo_record, p);
+ sa_free_result_mad(&result);
+
+ return (ret);
+}
+
+static int print_multicast_member_records(struct sa_handle * h,
+ struct query_params *params)
+{
+ struct sa_query_result mc_group_result;
+ struct sa_query_result nr_result;
+ int ret;
+ unsigned i;
+
+ ret = get_all_records(h, IB_SA_ATTR_MCRECORD, &mc_group_result);
+ if (ret)
+ return ret;
+
+ ret = get_all_records(h, IB_SA_ATTR_NODERECORD, &nr_result);
+ if (ret)
+ goto return_mc;
+
+ for (i = 0; i < mc_group_result.result_cnt; i++) {
+ ib_member_rec_t *rec = (ib_member_rec_t *)
+ sa_get_query_rec(mc_group_result.p_result_madw,
+ i);
+ dump_multicast_member_record(rec, &nr_result, params);
+ }
+
+ sa_free_result_mad(&nr_result);
+
+return_mc:
+ sa_free_result_mad(&mc_group_result);
+
+ return ret;
+}
+
+static int print_multicast_group_records(struct sa_handle * h,
+ struct query_params *p)
+{
+ return get_and_dump_all_records(h, IB_SA_ATTR_MCRECORD,
+ dump_multicast_group_record, p);
+}
+
+static int query_class_port_info(const struct query_cmd *q, struct sa_handle * h,
+ struct query_params *p, int argc, char *argv[])
+{
+ dump_class_port_info(&p->cpi);
+ return (0);
+}
+
+static int query_node_records(const struct query_cmd *q, struct sa_handle * h,
+ struct query_params *p, int argc, char *argv[])
+{
+ ib_node_record_t nr;
+ ib_net64_t comp_mask = 0;
+ int lid = 0;
+
+ if (argc > 0)
+ parse_lid_and_ports(h, argv[0], &lid, NULL, NULL);
+
+ memset(&nr, 0, sizeof(nr));
+ CHECK_AND_SET_VAL(lid, 16, 0, nr.lid, NR, LID);
+
+ return get_and_dump_any_records(h, IB_SA_ATTR_NODERECORD, 0, comp_mask,
+ &nr, sizeof(nr), dump_node_record, p);
+}
+
+static int query_portinfo_records(const struct query_cmd *q,
+ struct sa_handle * h, struct query_params *p,
+ int argc, char *argv[])
+{
+ ib_portinfo_record_t pir;
+ ib_net64_t comp_mask = 0;
+ int lid = 0, port = -1, options = -1;
+
+ if (argc > 0)
+ parse_lid_and_ports(h, argv[0], &lid, &port, &options);
+
+ memset(&pir, 0, sizeof(pir));
+ CHECK_AND_SET_VAL(lid, 16, 0, pir.lid, PIR, LID);
+ CHECK_AND_SET_VAL(port, 8, -1, pir.port_num, PIR, PORTNUM);
+ CHECK_AND_SET_VAL(options, 8, -1, pir.options, PIR, OPTIONS);
+
+ return get_and_dump_any_records(h, IB_SA_ATTR_PORTINFORECORD, 0,
+ comp_mask, &pir, sizeof(pir),
+ dump_one_portinfo_record, p);
+}
+
+static int query_mcmember_records(const struct query_cmd *q,
+ struct sa_handle * h, struct query_params *p,
+ int argc, char *argv[])
+{
+ ib_member_rec_t mr;
+ ib_net64_t comp_mask = 0;
+ uint32_t flow = 0;
+ uint8_t sl = 0, hop = 0, scope = 0;
+
+ memset(&mr, 0, sizeof(mr));
+ CHECK_AND_SET_GID(p->mgid, mr.mgid, MCR, MGID);
+ CHECK_AND_SET_GID(p->gid, mr.port_gid, MCR, PORT_GID);
+ CHECK_AND_SET_VAL(p->mlid, 16, 0, mr.mlid, MCR, MLID);
+ CHECK_AND_SET_VAL(p->qkey, 32, 0, mr.qkey, MCR, QKEY);
+ CHECK_AND_SET_VAL_AND_SEL(p->mtu, mr.mtu, MCR, MTU, _SEL);
+ CHECK_AND_SET_VAL_AND_SEL(p->rate, mr.rate, MCR, RATE, _SEL);
+ CHECK_AND_SET_VAL_AND_SEL(p->pkt_life, mr.pkt_life, MCR, LIFE, _SEL);
+ CHECK_AND_SET_VAL(p->tclass, 8, 0, mr.tclass, MCR, TCLASS);
+ CHECK_AND_SET_VAL(p->pkey, 16, 0, mr.pkey, MCR, PKEY);
+ CHECK_AND_SET_VAL(p->sl, 8, -1, sl, MCR, SL);
+ CHECK_AND_SET_VAL(p->flow_label, 32, 0, flow, MCR, FLOW);
+ CHECK_AND_SET_VAL(p->hop_limit, 8, 0, hop, MCR, HOP);
+ /* pass flow in host order as expected by function */
+ mr.sl_flow_hop = ib_member_set_sl_flow_hop(sl, cl_ntoh32(flow), hop);
+ CHECK_AND_SET_VAL(p->scope, 8, 0, scope, MCR, SCOPE);
+ CHECK_AND_SET_VAL(p->join_state, 8, 0, mr.scope_state, MCR, JOIN_STATE);
+ mr.scope_state |= scope << 4;
+ CHECK_AND_SET_VAL(p->proxy_join, 8, -1, mr.proxy_join, MCR, PROXY);
+
+ return get_and_dump_any_records(h, IB_SA_ATTR_MCRECORD, 0, comp_mask,
+ &mr, sizeof(mr), dump_one_mcmember_record, p);
+}
+
+static int query_service_records(const struct query_cmd *q, struct sa_handle * h,
+ struct query_params *p, int argc, char *argv[])
+{
+ return get_and_dump_all_records(h, IB_SA_ATTR_SERVICERECORD,
+ dump_service_record, p);
+}
+
+static int query_sm_info_records(const struct query_cmd *q,
+ struct sa_handle * h, struct query_params *p,
+ int argc, char *argv[])
+{
+ ib_sminfo_record_t smir;
+ ib_net64_t comp_mask = 0;
+ int lid = 0;
+
+ if (argc > 0)
+ parse_lid_and_ports(h, argv[0], &lid, NULL, NULL);
+
+ memset(&smir, 0, sizeof(smir));
+ CHECK_AND_SET_VAL(lid, 16, 0, smir.lid, SMIR, LID);
+
+ return get_and_dump_any_records(h, IB_SA_ATTR_SMINFORECORD, 0,
+ comp_mask, &smir, sizeof(smir),
+ dump_sm_info_record, p);
+}
+
+static int query_switchinfo_records(const struct query_cmd *q,
+ struct sa_handle * h, struct query_params *p,
+ int argc, char *argv[])
+{
+ ib_switch_info_record_t swir;
+ ib_net64_t comp_mask = 0;
+ int lid = 0;
+
+ if (argc > 0)
+ parse_lid_and_ports(h, argv[0], &lid, NULL, NULL);
+
+ memset(&swir, 0, sizeof(swir));
+ CHECK_AND_SET_VAL(lid, 16, 0, swir.lid, SWIR, LID);
+
+ return get_and_dump_any_records(h, IB_SA_ATTR_SWITCHINFORECORD, 0,
+ comp_mask, &swir, sizeof(swir),
+ dump_switch_info_record, p);
+}
+
+static int query_inform_info_records(const struct query_cmd *q,
+ struct sa_handle * h, struct query_params *p,
+ int argc, char *argv[])
+{
+ int rc = 0;
+ ib_inform_info_record_t ir;
+ ib_net64_t comp_mask = 0;
+ memset(&ir, 0, sizeof(ir));
+
+ if (argc > 0) {
+ comp_mask = IB_IIR_COMPMASK_SUBSCRIBERGID;
+ if((rc = parse_iir_subscriber_gid(argv[0], &ir)) < 1)
+ return rc;
+ }
+
+ return get_and_dump_any_records(h, IB_SA_ATTR_INFORMINFORECORD, 0, comp_mask,
+ &ir, sizeof(ir), dump_inform_info_record, p);
+
+}
+
+static int query_link_records(const struct query_cmd *q, struct sa_handle * h,
+ struct query_params *p, int argc, char *argv[])
+{
+ ib_link_record_t lr;
+ ib_net64_t comp_mask = 0;
+ int from_lid = 0, to_lid = 0, from_port = -1, to_port = -1;
+
+ if (argc > 0)
+ parse_lid_and_ports(h, argv[0], &from_lid, &from_port, NULL);
+
+ if (argc > 1)
+ parse_lid_and_ports(h, argv[1], &to_lid, &to_port, NULL);
+
+ memset(&lr, 0, sizeof(lr));
+ CHECK_AND_SET_VAL(from_lid, 16, 0, lr.from_lid, LR, FROM_LID);
+ CHECK_AND_SET_VAL(from_port, 8, -1, lr.from_port_num, LR, FROM_PORT);
+ CHECK_AND_SET_VAL(to_lid, 16, 0, lr.to_lid, LR, TO_LID);
+ CHECK_AND_SET_VAL(to_port, 8, -1, lr.to_port_num, LR, TO_PORT);
+
+ return get_and_dump_any_records(h, IB_SA_ATTR_LINKRECORD, 0, comp_mask,
+ &lr, sizeof(lr), dump_one_link_record, p);
+}
+
+static int query_sl2vl_records(const struct query_cmd *q, struct sa_handle * h,
+ struct query_params *p, int argc, char *argv[])
+{
+ ib_slvl_table_record_t slvl;
+ ib_net64_t comp_mask = 0;
+ int lid = 0, in_port = -1, out_port = -1;
+
+ if (argc > 0)
+ parse_lid_and_ports(h, argv[0], &lid, &in_port, &out_port);
+
+ memset(&slvl, 0, sizeof(slvl));
+ CHECK_AND_SET_VAL(lid, 16, 0, slvl.lid, SLVL, LID);
+ CHECK_AND_SET_VAL(in_port, 8, -1, slvl.in_port_num, SLVL, IN_PORT);
+ CHECK_AND_SET_VAL(out_port, 8, -1, slvl.out_port_num, SLVL, OUT_PORT);
+
+ return get_and_dump_any_records(h, IB_SA_ATTR_SL2VLTABLERECORD, 0,
+ comp_mask, &slvl, sizeof(slvl),
+ dump_one_slvl_record, p);
+}
+
+static int query_vlarb_records(const struct query_cmd *q, struct sa_handle * h,
+ struct query_params *p, int argc, char *argv[])
+{
+ ib_vl_arb_table_record_t vlarb;
+ ib_net64_t comp_mask = 0;
+ int lid = 0, port = -1, block = -1;
+
+ if (argc > 0)
+ parse_lid_and_ports(h, argv[0], &lid, &port, &block);
+
+ memset(&vlarb, 0, sizeof(vlarb));
+ CHECK_AND_SET_VAL(lid, 16, 0, vlarb.lid, VLA, LID);
+ CHECK_AND_SET_VAL(port, 8, -1, vlarb.port_num, VLA, OUT_PORT);
+ CHECK_AND_SET_VAL(block, 8, -1, vlarb.block_num, VLA, BLOCK);
+
+ return get_and_dump_any_records(h, IB_SA_ATTR_VLARBTABLERECORD, 0,
+ comp_mask, &vlarb, sizeof(vlarb),
+ dump_one_vlarb_record, p);
+}
+
+static int query_pkey_tbl_records(const struct query_cmd *q,
+ struct sa_handle * h, struct query_params *p,
+ int argc, char *argv[])
+{
+ ib_pkey_table_record_t pktr;
+ ib_net64_t comp_mask = 0;
+ int lid = 0, port = -1, block = -1;
+
+ if (argc > 0)
+ parse_lid_and_ports(h, argv[0], &lid, &port, &block);
+
+ memset(&pktr, 0, sizeof(pktr));
+ CHECK_AND_SET_VAL(lid, 16, 0, pktr.lid, PKEY, LID);
+ CHECK_AND_SET_VAL(port, 8, -1, pktr.port_num, PKEY, PORT);
+ CHECK_AND_SET_VAL(block, 16, -1, pktr.block_num, PKEY, BLOCK);
+
+ return get_and_dump_any_records(h, IB_SA_ATTR_PKEYTABLERECORD, 0,
+ comp_mask, &pktr, sizeof(pktr),
+ dump_one_pkey_tbl_record, p);
+}
+
+static int query_lft_records(const struct query_cmd *q, struct sa_handle * h,
+ struct query_params *p, int argc, char *argv[])
+{
+ ib_lft_record_t lftr;
+ ib_net64_t comp_mask = 0;
+ int lid = 0, block = -1;
+
+ if (argc > 0)
+ parse_lid_and_ports(h, argv[0], &lid, &block, NULL);
+
+ memset(&lftr, 0, sizeof(lftr));
+ CHECK_AND_SET_VAL(lid, 16, 0, lftr.lid, LFTR, LID);
+ CHECK_AND_SET_VAL(block, 16, -1, lftr.block_num, LFTR, BLOCK);
+
+ return get_and_dump_any_records(h, IB_SA_ATTR_LFTRECORD, 0, comp_mask,
+ &lftr, sizeof(lftr), dump_one_lft_record, p);
+}
+
+static int query_guidinfo_records(const struct query_cmd *q, struct sa_handle * h,
+ struct query_params *p, int argc, char *argv[])
+{
+ ib_guidinfo_record_t gir;
+ ib_net64_t comp_mask = 0;
+ int lid = 0, block = -1;
+
+ if (argc > 0)
+ parse_lid_and_ports(h, argv[0], &lid, &block, NULL);
+
+ memset(&gir, 0, sizeof(gir));
+ CHECK_AND_SET_VAL(lid, 16, 0, gir.lid, GIR, LID);
+ CHECK_AND_SET_VAL(block, 8, -1, gir.block_num, GIR, BLOCKNUM);
+
+ return get_and_dump_any_records(h, IB_SA_ATTR_GUIDINFORECORD, 0,
+ comp_mask, &gir, sizeof(gir),
+ dump_one_guidinfo_record, p);
+}
+
+static int query_mft_records(const struct query_cmd *q, struct sa_handle * h,
+ struct query_params *p, int argc, char *argv[])
+{
+ ib_mft_record_t mftr;
+ ib_net64_t comp_mask = 0;
+ int lid = 0, block = -1, position = -1;
+ uint16_t pos = 0;
+
+ if (argc > 0)
+ parse_lid_and_ports(h, argv[0], &lid, &position, &block);
+
+ memset(&mftr, 0, sizeof(mftr));
+ CHECK_AND_SET_VAL(lid, 16, 0, mftr.lid, MFTR, LID);
+ CHECK_AND_SET_VAL(block, 16, -1, mftr.position_block_num, MFTR, BLOCK);
+ mftr.position_block_num &= cl_hton16(IB_MCAST_BLOCK_ID_MASK_HO);
+ CHECK_AND_SET_VAL(position, 8, -1, pos, MFTR, POSITION);
+ mftr.position_block_num |= cl_hton16(pos << 12);
+
+ return get_and_dump_any_records(h, IB_SA_ATTR_MFTRECORD, 0, comp_mask,
+ &mftr, sizeof(mftr), dump_one_mft_record, p);
+}
+
+static int query_sa_cpi(struct sa_handle *h, struct query_params *query_params)
+{
+ ib_class_port_info_t *cpi;
+ struct sa_query_result result;
+ int ret = sa_query(h, IB_MAD_METHOD_GET, CLASS_PORT_INFO, 0, 0,
+ ibd_sakey, NULL, 0, &result);
+ if (ret) {
+ fprintf(stderr, "Query SA failed: %s\n", strerror(ret));
+ return ret;
+ }
+
+ if (result.status != IB_SA_MAD_STATUS_SUCCESS) {
+ sa_report_err(result.status);
+ ret = EIO;
+ goto Exit;
+ }
+ cpi = sa_get_query_rec(result.p_result_madw, 0);
+ memcpy(&query_params->cpi, cpi, sizeof(query_params->cpi));
+Exit:
+ sa_free_result_mad(&result);
+ return (0);
+}
+
+static const struct query_cmd query_cmds[] = {
+ {"ClassPortInfo", "CPI", CLASS_PORT_INFO,
+ NULL, query_class_port_info},
+ {"NodeRecord", "NR", IB_SA_ATTR_NODERECORD,
+ "[lid]", query_node_records},
+ {"PortInfoRecord", "PIR", IB_SA_ATTR_PORTINFORECORD,
+ "[[lid]/[port]/[options]]", query_portinfo_records},
+ {"SL2VLTableRecord", "SL2VL", IB_SA_ATTR_SL2VLTABLERECORD,
+ "[[lid]/[in_port]/[out_port]]", query_sl2vl_records},
+ {"PKeyTableRecord", "PKTR", IB_SA_ATTR_PKEYTABLERECORD,
+ "[[lid]/[port]/[block]]", query_pkey_tbl_records},
+ {"VLArbitrationTableRecord", "VLAR", IB_SA_ATTR_VLARBTABLERECORD,
+ "[[lid]/[port]/[block]]", query_vlarb_records},
+ {"InformInfoRecord", "IIR", IB_SA_ATTR_INFORMINFORECORD,
+ "[subscriber_gid]", query_inform_info_records},
+ {"LinkRecord", "LR", IB_SA_ATTR_LINKRECORD,
+ "[[from_lid]/[from_port]] [[to_lid]/[to_port]]", query_link_records},
+ {"ServiceRecord", "SR", IB_SA_ATTR_SERVICERECORD,
+ NULL, query_service_records},
+ {"PathRecord", "PR", IB_SA_ATTR_PATHRECORD,
+ NULL, query_path_records},
+ {"MCMemberRecord", "MCMR", IB_SA_ATTR_MCRECORD,
+ NULL, query_mcmember_records},
+ {"LFTRecord", "LFTR", IB_SA_ATTR_LFTRECORD,
+ "[[lid]/[block]]", query_lft_records},
+ {"MFTRecord", "MFTR", IB_SA_ATTR_MFTRECORD,
+ "[[mlid]/[position]/[block]]", query_mft_records},
+ {"GUIDInfoRecord", "GIR", IB_SA_ATTR_GUIDINFORECORD,
+ "[[lid]/[block]]", query_guidinfo_records},
+ {"SwitchInfoRecord", "SWIR", IB_SA_ATTR_SWITCHINFORECORD,
+ "[lid]", query_switchinfo_records},
+ {"SMInfoRecord", "SMIR", IB_SA_ATTR_SMINFORECORD,
+ "[lid]", query_sm_info_records},
+ {0}
+};
+
+static const struct query_cmd *find_query(const char *name)
+{
+ const struct query_cmd *q;
+
+ for (q = query_cmds; q->name; q++)
+ if (!strcasecmp(name, q->name) ||
+ (q->alias && !strcasecmp(name, q->alias)))
+ return q;
+
+ return NULL;
+}
+
+static const struct query_cmd *find_query_by_type(uint16_t type)
+{
+ const struct query_cmd *q;
+
+ for (q = query_cmds; q->name; q++)
+ if (q->query_type == type)
+ return q;
+
+ return NULL;
+}
+
+enum saquery_command {
+ SAQUERY_CMD_QUERY,
+ SAQUERY_CMD_NODE_RECORD,
+ SAQUERY_CMD_CLASS_PORT_INFO,
+ SAQUERY_CMD_ISSM,
+ SAQUERY_CMD_MCGROUPS,
+ SAQUERY_CMD_MCMEMBERS,
+};
+
+static enum saquery_command command = SAQUERY_CMD_QUERY;
+static uint16_t query_type;
+static char *src_lid, *dst_lid;
+
+static int process_opt(void *context, int ch, char *optarg)
+{
+ struct query_params *p = context;
+
+ switch (ch) {
+ case 1:
+ {
+ src_lid = strdup(optarg);
+ dst_lid = strchr(src_lid, ':');
+ if (!dst_lid)
+ ibdiag_show_usage();
+ *dst_lid++ = '\0';
+ }
+ p->numb_path = 0x7f;
+ query_type = IB_SA_ATTR_PATHRECORD;
+ break;
+ case 2:
+ {
+ char *src_addr = strdup(optarg);
+ char *dst_addr = strchr(src_addr, '-');
+ if (!dst_addr)
+ ibdiag_show_usage();
+ *dst_addr++ = '\0';
+ if (inet_pton(AF_INET6, src_addr, &p->sgid) <= 0)
+ ibdiag_show_usage();
+ if (inet_pton(AF_INET6, dst_addr, &p->dgid) <= 0)
+ ibdiag_show_usage();
+ free(src_addr);
+ }
+ p->numb_path = 0x7f;
+ query_type = IB_SA_ATTR_PATHRECORD;
+ break;
+ case 3:
+ node_name_map_file = strdup(optarg);
+ break;
+ case 4:
+ if (!isxdigit(*optarg) && !(optarg = getpass("SM_Key: "))) {
+ fprintf(stderr, "cannot get SM_Key\n");
+ ibdiag_show_usage();
+ }
+ ibd_sakey = strtoull(optarg, NULL, 0);
+ break;
+ case 'p':
+ query_type = IB_SA_ATTR_PATHRECORD;
+ break;
+ case 'D':
+ node_print_desc = ALL_DESC;
+ command = SAQUERY_CMD_NODE_RECORD;
+ break;
+ case 'c':
+ command = SAQUERY_CMD_CLASS_PORT_INFO;
+ break;
+ case 'S':
+ query_type = IB_SA_ATTR_SERVICERECORD;
+ break;
+ case 'I':
+ query_type = IB_SA_ATTR_INFORMINFORECORD;
+ break;
+ case 'N':
+ command = SAQUERY_CMD_NODE_RECORD;
+ break;
+ case 'L':
+ node_print_desc = LID_ONLY;
+ command = SAQUERY_CMD_NODE_RECORD;
+ break;
+ case 'l':
+ node_print_desc = UNIQUE_LID_ONLY;
+ command = SAQUERY_CMD_NODE_RECORD;
+ break;
+ case 'G':
+ node_print_desc = GUID_ONLY;
+ command = SAQUERY_CMD_NODE_RECORD;
+ break;
+ case 'O':
+ node_print_desc = NAME_OF_LID;
+ command = SAQUERY_CMD_NODE_RECORD;
+ break;
+ case 'U':
+ node_print_desc = NAME_OF_GUID;
+ command = SAQUERY_CMD_NODE_RECORD;
+ break;
+ case 's':
+ command = SAQUERY_CMD_ISSM;
+ break;
+ case 'g':
+ command = SAQUERY_CMD_MCGROUPS;
+ break;
+ case 'm':
+ command = SAQUERY_CMD_MCMEMBERS;
+ break;
+ case 'x':
+ query_type = IB_SA_ATTR_LINKRECORD;
+ break;
+ case 5:
+ p->slid = (uint16_t) strtoul(optarg, NULL, 0);
+ break;
+ case 6:
+ p->dlid = (uint16_t) strtoul(optarg, NULL, 0);
+ break;
+ case 7:
+ p->mlid = (uint16_t) strtoul(optarg, NULL, 0);
+ break;
+ case 14:
+ if (inet_pton(AF_INET6, optarg, &p->sgid) <= 0)
+ ibdiag_show_usage();
+ break;
+ case 15:
+ if (inet_pton(AF_INET6, optarg, &p->dgid) <= 0)
+ ibdiag_show_usage();
+ break;
+ case 16:
+ if (inet_pton(AF_INET6, optarg, &p->gid) <= 0)
+ ibdiag_show_usage();
+ break;
+ case 17:
+ if (inet_pton(AF_INET6, optarg, &p->mgid) <= 0)
+ ibdiag_show_usage();
+ break;
+ case 'r':
+ p->reversible = strtoul(optarg, NULL, 0);
+ break;
+ case 'n':
+ p->numb_path = strtoul(optarg, NULL, 0);
+ break;
+ case 18:
+ if (!isxdigit(*optarg) && !(optarg = getpass("P_Key: "))) {
+ fprintf(stderr, "cannot get P_Key\n");
+ ibdiag_show_usage();
+ }
+ p->pkey = (uint16_t) strtoul(optarg, NULL, 0);
+ break;
+ case 'Q':
+ p->qos_class = strtoul(optarg, NULL, 0);
+ break;
+ case 19:
+ p->sl = strtoul(optarg, NULL, 0);
+ break;
+ case 'M':
+ p->mtu = (uint8_t) strtoul(optarg, NULL, 0);
+ break;
+ case 'R':
+ p->rate = (uint8_t) strtoul(optarg, NULL, 0);
+ break;
+ case 20:
+ p->pkt_life = (uint8_t) strtoul(optarg, NULL, 0);
+ break;
+ case 'q':
+ if (!isxdigit(*optarg) && !(optarg = getpass("Q_Key: "))) {
+ fprintf(stderr, "cannot get Q_Key\n");
+ ibdiag_show_usage();
+ }
+ p->qkey = strtoul(optarg, NULL, 0);
+ break;
+ case 'T':
+ p->tclass = (uint8_t) strtoul(optarg, NULL, 0);
+ break;
+ case 'F':
+ p->flow_label = strtoul(optarg, NULL, 0);
+ break;
+ case 'H':
+ p->hop_limit = strtoul(optarg, NULL, 0);
+ break;
+ case 21:
+ p->scope = (uint8_t) strtoul(optarg, NULL, 0);
+ break;
+ case 'J':
+ p->join_state = (uint8_t) strtoul(optarg, NULL, 0);
+ break;
+ case 'X':
+ p->proxy_join = strtoul(optarg, NULL, 0);
+ break;
+ case 22:
+ p->service_id = strtoull(optarg, NULL, 0);
+ break;
+ case 23:
+ p->with_grh = TRUE;
+ break;
+ case 24:
+ p->with_grh = TRUE;
+ if (inet_pton(AF_INET6, optarg, &p->sa_dgid) <= 0)
+ ibdiag_show_usage();
+ break;
+ default:
+ return -1;
+ }
+ return 0;
+}
+
+int main(int argc, char **argv)
+{
+ ib_portid_t portid = { 0 };
+ int port = 0;
+ int sa_cpi_required = 0;
+ char usage_args[1024];
+ struct sa_handle * h;
+ struct query_params params;
+ const struct query_cmd *q;
+ int status;
+ int n;
+
+ const struct ibdiag_opt opts[] = {
+ {"p", 'p', 0, NULL, "get PathRecord info"},
+ {"N", 'N', 0, NULL, "get NodeRecord info"},
+ {"L", 'L', 0, NULL, "return the Lids of the name specified"},
+ {"l", 'l', 0, NULL,
+ "return the unique Lid of the name specified"},
+ {"G", 'G', 0, NULL, "return the Guids of the name specified"},
+ {"O", 'O', 0, NULL, "return name for the Lid specified"},
+ {"U", 'U', 0, NULL, "return name for the Guid specified"},
+ {"s", 's', 0, NULL, "return the PortInfoRecords with isSM or"
+ " isSMdisabled capability mask bit on"},
+ {"g", 'g', 0, NULL, "get multicast group info"},
+ {"m", 'm', 0, NULL, "get multicast member info (if multicast"
+ " group specified, list member GIDs only for group specified,"
+ " for example 'saquery -m 0xC000')"},
+ {"x", 'x', 0, NULL, "get LinkRecord info"},
+ {"c", 'c', 0, NULL, "get the SA's class port info"},
+ {"S", 'S', 0, NULL, "get ServiceRecord info"},
+ {"I", 'I', 0, NULL, "get InformInfoRecord (subscription) info"},
+ {"list", 'D', 0, NULL, "the node desc of the CA's"},
+ {"with-grh", 23, 0, NULL, "add GRH to path record query"},
+ {"sa-dgid", 24, 1, "<gid>",
+ "Set destination GID (in IPv6 format) in the GRH"},
+ {"src-to-dst", 1, 1, "<src:dst>", "get a PathRecord for"
+ " <src:dst> where src and dst are either node names or LIDs"},
+ {"sgid-to-dgid", 2, 1, "<sgid-dgid>", "get a PathRecord for"
+ " <sgid-dgid> where sgid and dgid are addresses in IPv6 format"},
+ {"node-name-map", 3, 1, "<file>",
+ "specify a node name map file"},
+ {"smkey", 4, 1, "<val>",
+ "SA SM_Key value for the query."
+ " If non-numeric value (like 'x') is specified then"
+ " saquery will prompt for a value. "
+ " Default (when not specified here or in ibdiag.conf) is to "
+ " use SM_Key == 0 (or \"untrusted\")"},
+ {"slid", 5, 1, "<lid>", "Source LID (PathRecord)"},
+ {"dlid", 6, 1, "<lid>", "Destination LID (PathRecord)"},
+ {"mlid", 7, 1, "<lid>", "Multicast LID (MCMemberRecord)"},
+ {"sgid", 14, 1, "<gid>",
+ "Source GID (IPv6 format) (PathRecord)"},
+ {"dgid", 15, 1, "<gid>",
+ "Destination GID (IPv6 format) (PathRecord)"},
+ {"gid", 16, 1, "<gid>", "Port GID (MCMemberRecord)"},
+ {"mgid", 17, 1, "<gid>", "Multicast GID (MCMemberRecord)"},
+ {"reversible", 'r', 1, NULL, "Reversible path (PathRecord)"},
+ {"numb_path", 'n', 1, NULL, "Number of paths (PathRecord)"},
+ {"pkey", 18, 1, NULL, "P_Key (PathRecord, MCMemberRecord)."
+ " If non-numeric value (like 'x') is specified then"
+ " saquery will prompt for a value"},
+ {"qos_class", 'Q', 1, NULL, "QoS Class (PathRecord)"},
+ {"sl", 19, 1, NULL,
+ "Service level (PathRecord, MCMemberRecord)"},
+ {"mtu", 'M', 1, NULL,
+ "MTU and selector (PathRecord, MCMemberRecord)"},
+ {"rate", 'R', 1, NULL,
+ "Rate and selector (PathRecord, MCMemberRecord)"},
+ {"pkt_lifetime", 20, 1, NULL,
+ "Packet lifetime and selector (PathRecord, MCMemberRecord)"},
+ {"qkey", 'q', 1, NULL, "Q_Key (MCMemberRecord)."
+ " If non-numeric value (like 'x') is specified then"
+ " saquery will prompt for a value"},
+ {"tclass", 'T', 1, NULL,
+ "Traffic Class (PathRecord, MCMemberRecord)"},
+ {"flow_label", 'F', 1, NULL,
+ "Flow Label (PathRecord, MCMemberRecord)"},
+ {"hop_limit", 'H', 1, NULL,
+ "Hop limit (PathRecord, MCMemberRecord)"},
+ {"scope", 21, 1, NULL, "Scope (MCMemberRecord)"},
+ {"join_state", 'J', 1, NULL, "Join state (MCMemberRecord)"},
+ {"proxy_join", 'X', 1, NULL, "Proxy join (MCMemberRecord)"},
+ {"service_id", 22, 1, NULL, "ServiceID (PathRecord)"},
+ {0}
+ };
+
+ memset(&params, 0, sizeof params);
+ params.hop_limit = 0;
+ params.reversible = -1;
+ params.numb_path = -1;
+ params.qos_class = -1;
+ params.sl = -1;
+ params.proxy_join = -1;
+
+ n = sprintf(usage_args, "[query-name] [<name> | <lid> | <guid>]\n"
+ "\nSupported query names (and aliases):\n");
+ for (q = query_cmds; q->name; q++) {
+ n += snprintf(usage_args + n, sizeof(usage_args) - n,
+ " %s (%s) %s\n", q->name,
+ q->alias ? q->alias : "",
+ q->usage ? q->usage : "");
+ if (n >= sizeof(usage_args))
+ exit(-1);
+ }
+ snprintf(usage_args + n, sizeof(usage_args) - n,
+ "\n Queries node records by default.");
+
+ q = NULL;
+ ibd_timeout = DEFAULT_SA_TIMEOUT_MS;
+
+ ibdiag_process_opts(argc, argv, &params, "DGLsy", opts, process_opt,
+ usage_args, NULL);
+
+ argc -= optind;
+ argv += optind;
+
+ if (!query_type && command == SAQUERY_CMD_QUERY) {
+ if (!argc || !(q = find_query(argv[0])))
+ query_type = IB_SA_ATTR_NODERECORD;
+ else {
+ query_type = q->query_type;
+ argc--;
+ argv++;
+ }
+ }
+
+ if (argc) {
+ if (node_print_desc == NAME_OF_LID) {
+ requested_lid = (uint16_t) strtoul(argv[0], NULL, 0);
+ requested_lid_flag++;
+ } else if (node_print_desc == NAME_OF_GUID) {
+ requested_guid = strtoul(argv[0], NULL, 0);
+ requested_guid_flag++;
+ } else
+ requested_name = argv[0];
+ }
+
+ if ((node_print_desc == LID_ONLY ||
+ node_print_desc == UNIQUE_LID_ONLY ||
+ node_print_desc == GUID_ONLY) && !requested_name) {
+ fprintf(stderr, "ERROR: name not specified\n");
+ ibdiag_show_usage();
+ }
+
+ if (node_print_desc == NAME_OF_LID && !requested_lid_flag) {
+ fprintf(stderr, "ERROR: lid not specified\n");
+ ibdiag_show_usage();
+ }
+
+ if (node_print_desc == NAME_OF_GUID && !requested_guid_flag) {
+ fprintf(stderr, "ERROR: guid not specified\n");
+ ibdiag_show_usage();
+ }
+
+ /* Note: lid cannot be 0; see infiniband spec 4.1.3 */
+ if (node_print_desc == NAME_OF_LID && !requested_lid) {
+ fprintf(stderr, "ERROR: lid invalid\n");
+ ibdiag_show_usage();
+ }
+
+ if (umad_init())
+ IBEXIT("Failed to initialized umad library");
+ h = sa_get_handle();
+ if (!h)
+ IBPANIC("Failed to bind to the SA");
+
+ if (params.with_grh) {
+ ibmad_gid_t gid = { 0 };
+ /*
+ * If GRH destination GID is not specified, try to get it by
+ * querying the SA.
+ */
+ if (!memcmp(&gid, &params.sa_dgid, sizeof(ibmad_gid_t))) {
+ if ((status = resolve_self(ibd_ca, ibd_ca_port, &portid,
+ &port, 0)) < 0) {
+ fprintf(stderr, "can't resolve self port %s\n",
+ argv[0]);
+ goto error;
+ }
+ if ((status = sm_pr_query(h, &gid, portid.lid,
+ h->dport.lid)) > 0) {
+ fprintf(stderr,
+ "Failed to query SA:PathRecord\n");
+ goto error;
+ }
+ } else
+ memcpy(&gid, &params.sa_dgid, sizeof(ibmad_gid_t));
+
+ if ((status = sa_set_handle(h, 1, &gid)) < 0) {
+ fprintf(stderr, "Failed to set GRH\n");
+ goto error;
+ }
+ }
+
+ node_name_map = open_node_name_map(node_name_map_file);
+
+ if (src_lid && *src_lid)
+ params.slid = get_lid(h, src_lid);
+ if (dst_lid && *dst_lid)
+ params.dlid = get_lid(h, dst_lid);
+
+ if (command == SAQUERY_CMD_CLASS_PORT_INFO ||
+ query_type == CLASS_PORT_INFO ||
+ query_type == IB_SA_ATTR_SWITCHINFORECORD)
+ sa_cpi_required = 1;
+
+ if (sa_cpi_required && (status = query_sa_cpi(h, &params)) != 0) {
+ fprintf(stderr, "Failed to query SA:ClassPortInfo\n");
+ goto error;
+ }
+
+ switch (command) {
+ case SAQUERY_CMD_NODE_RECORD:
+ status = print_node_records(h, &params);
+ break;
+ case SAQUERY_CMD_CLASS_PORT_INFO:
+ dump_class_port_info(&params.cpi);
+ status = 0;
+ break;
+ case SAQUERY_CMD_ISSM:
+ status = print_issm_records(h, &params);
+ break;
+ case SAQUERY_CMD_MCGROUPS:
+ status = print_multicast_group_records(h, &params);
+ break;
+ case SAQUERY_CMD_MCMEMBERS:
+ status = print_multicast_member_records(h, &params);
+ break;
+ default:
+ if ((!q && !(q = find_query_by_type(query_type)))
+ || !q->handler) {
+ fprintf(stderr, "Unknown query type %d\n",
+ ntohs(query_type));
+ status = EINVAL;
+ } else
+ status = q->handler(q, h, &params, argc, argv);
+ break;
+ }
+
+error:
+ if (src_lid)
+ free(src_lid);
+ sa_free_handle(h);
+ umad_done();
+ close_node_name_map(node_name_map);
+ return (status);
+}
diff --git a/contrib/ofed/infiniband-diags/src/sminfo.c b/contrib/ofed/infiniband-diags/src/sminfo.c
new file mode 100644
index 0000000..894d9fc
--- /dev/null
+++ b/contrib/ofed/infiniband-diags/src/sminfo.c
@@ -0,0 +1,162 @@
+/*
+ * Copyright (c) 2004-2009 Voltaire Inc. All rights reserved.
+ * Copyright (c) 2011 Mellanox Technologies LTD. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+#if HAVE_CONFIG_H
+# include <config.h>
+#endif /* HAVE_CONFIG_H */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <inttypes.h>
+#include <getopt.h>
+
+#include <infiniband/umad.h>
+#include <infiniband/mad.h>
+
+#include "ibdiag_common.h"
+
+static uint8_t sminfo[1024] = { 0 };
+
+struct ibmad_port *srcport;
+
+int strdata, xdata = 1, bindata;
+
+enum {
+ SMINFO_NOTACT,
+ SMINFO_DISCOVER,
+ SMINFO_STANDBY,
+ SMINFO_MASTER,
+
+ SMINFO_STATE_LAST,
+};
+
+char *statestr[] = {
+ "SMINFO_NOTACT",
+ "SMINFO_DISCOVER",
+ "SMINFO_STANDBY",
+ "SMINFO_MASTER",
+};
+
+#define STATESTR(s) (((unsigned)(s)) < SMINFO_STATE_LAST ? statestr[s] : "???")
+
+static unsigned act;
+static int prio, state = SMINFO_STANDBY;
+
+static int process_opt(void *context, int ch, char *optarg)
+{
+ switch (ch) {
+ case 'a':
+ act = strtoul(optarg, 0, 0);
+ break;
+ case 's':
+ state = strtoul(optarg, 0, 0);
+ break;
+ case 'p':
+ prio = strtoul(optarg, 0, 0);
+ break;
+ default:
+ return -1;
+ }
+ return 0;
+}
+
+int main(int argc, char **argv)
+{
+ int mgmt_classes[3] =
+ { IB_SMI_CLASS, IB_SMI_DIRECT_CLASS, IB_SA_CLASS };
+ int mod = 0;
+ ib_portid_t portid = { 0 };
+ uint8_t *p;
+ uint64_t guid = 0, key = 0;
+
+ const struct ibdiag_opt opts[] = {
+ {"state", 's', 1, "<0-3>", "set SM state"},
+ {"priority", 'p', 1, "<0-15>", "set SM priority"},
+ {"activity", 'a', 1, NULL, "set activity count"},
+ {0}
+ };
+ char usage_args[] = "<sm_lid|sm_dr_path> [modifier]";
+
+ ibdiag_process_opts(argc, argv, NULL, "sK", opts, process_opt,
+ usage_args, NULL);
+
+ argc -= optind;
+ argv += optind;
+
+ if (argc > 1)
+ mod = atoi(argv[1]);
+
+ srcport = mad_rpc_open_port(ibd_ca, ibd_ca_port, mgmt_classes, 3);
+ if (!srcport)
+ IBEXIT("Failed to open '%s' port '%d'", ibd_ca, ibd_ca_port);
+
+ smp_mkey_set(srcport, ibd_mkey);
+
+ if (argc) {
+ if (resolve_portid_str(ibd_ca, ibd_ca_port, &portid, argv[0],
+ ibd_dest_type, 0, srcport) < 0)
+ IBEXIT("can't resolve destination port %s", argv[0]);
+ } else {
+ if (resolve_sm_portid(ibd_ca, ibd_ca_port, &portid) < 0)
+ IBEXIT("can't resolve sm port %s", argv[0]);
+ }
+
+ mad_encode_field(sminfo, IB_SMINFO_GUID_F, &guid);
+ mad_encode_field(sminfo, IB_SMINFO_ACT_F, &act);
+ mad_encode_field(sminfo, IB_SMINFO_KEY_F, &key);
+ mad_encode_field(sminfo, IB_SMINFO_PRIO_F, &prio);
+ mad_encode_field(sminfo, IB_SMINFO_STATE_F, &state);
+
+ if (mod) {
+ if (!(p = smp_set_via(sminfo, &portid, IB_ATTR_SMINFO, mod,
+ ibd_timeout, srcport)))
+ IBEXIT("query");
+ } else if (!(p = smp_query_via(sminfo, &portid, IB_ATTR_SMINFO, 0,
+ ibd_timeout, srcport)))
+ IBEXIT("query");
+
+ mad_decode_field(sminfo, IB_SMINFO_GUID_F, &guid);
+ mad_decode_field(sminfo, IB_SMINFO_ACT_F, &act);
+ mad_decode_field(sminfo, IB_SMINFO_KEY_F, &key);
+ mad_decode_field(sminfo, IB_SMINFO_PRIO_F, &prio);
+ mad_decode_field(sminfo, IB_SMINFO_STATE_F, &state);
+
+ printf("sminfo: sm lid %d sm guid 0x%" PRIx64
+ ", activity count %u priority %d state %d %s\n", portid.lid,
+ guid, act, prio, state, STATESTR(state));
+
+ mad_rpc_close_port(srcport);
+ exit(0);
+}
diff --git a/contrib/ofed/infiniband-diags/src/smpdump.c b/contrib/ofed/infiniband-diags/src/smpdump.c
new file mode 100644
index 0000000..1c37765
--- /dev/null
+++ b/contrib/ofed/infiniband-diags/src/smpdump.c
@@ -0,0 +1,318 @@
+/*
+ * Copyright (c) 2004-2009 Voltaire Inc. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+#define _GNU_SOURCE
+
+#if HAVE_CONFIG_H
+# include <config.h>
+#endif /* HAVE_CONFIG_H */
+
+#include <inttypes.h>
+#include <string.h>
+#include <errno.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <getopt.h>
+#include <netinet/in.h>
+
+#include <infiniband/mad.h>
+#include <infiniband/umad.h>
+
+#include <ibdiag_common.h>
+
+static int mad_agent;
+static int drmad_tid = 0x123;
+
+typedef struct {
+ char path[64];
+ int hop_cnt;
+} DRPath;
+
+struct drsmp {
+ uint8_t base_version;
+ uint8_t mgmt_class;
+ uint8_t class_version;
+ uint8_t method;
+ uint16_t status;
+ uint8_t hop_ptr;
+ uint8_t hop_cnt;
+ uint64_t tid;
+ uint16_t attr_id;
+ uint16_t resv;
+ uint32_t attr_mod;
+ uint64_t mkey;
+ uint16_t dr_slid;
+ uint16_t dr_dlid;
+ uint8_t reserved[28];
+ uint8_t data[64];
+ uint8_t initial_path[64];
+ uint8_t return_path[64];
+};
+
+void drsmp_get_init(void *umad, DRPath * path, int attr, int mod)
+{
+ struct drsmp *smp = (struct drsmp *)(umad_get_mad(umad));
+
+ memset(smp, 0, sizeof(*smp));
+
+ smp->base_version = 1;
+ smp->mgmt_class = IB_SMI_DIRECT_CLASS;
+ smp->class_version = 1;
+
+ smp->method = 1;
+ smp->attr_id = (uint16_t) htons((uint16_t) attr);
+ smp->attr_mod = htonl(mod);
+ smp->tid = htonll(drmad_tid++);
+ smp->dr_slid = 0xffff;
+ smp->dr_dlid = 0xffff;
+
+ umad_set_addr(umad, 0xffff, 0, 0, 0);
+
+ if (path)
+ memcpy(smp->initial_path, path->path, path->hop_cnt + 1);
+
+ smp->hop_cnt = (uint8_t) path->hop_cnt;
+}
+
+void smp_get_init(void *umad, int lid, int attr, int mod)
+{
+ struct drsmp *smp = (struct drsmp *)(umad_get_mad(umad));
+
+ memset(smp, 0, sizeof(*smp));
+
+ smp->base_version = 1;
+ smp->mgmt_class = IB_SMI_CLASS;
+ smp->class_version = 1;
+
+ smp->method = 1;
+ smp->attr_id = (uint16_t) htons((uint16_t) attr);
+ smp->attr_mod = htonl(mod);
+ smp->tid = htonll(drmad_tid++);
+
+ umad_set_addr(umad, lid, 0, 0, 0);
+}
+
+void drsmp_set_init(void *umad, DRPath * path, int attr, int mod, void *data)
+{
+ struct drsmp *smp = (struct drsmp *)(umad_get_mad(umad));
+
+ memset(smp, 0, sizeof(*smp));
+
+ smp->method = 2; /* SET */
+ smp->attr_id = (uint16_t) htons((uint16_t) attr);
+ smp->attr_mod = htonl(mod);
+ smp->tid = htonll(drmad_tid++);
+ smp->dr_slid = 0xffff;
+ smp->dr_dlid = 0xffff;
+
+ umad_set_addr(umad, 0xffff, 0, 0, 0);
+
+ if (path)
+ memcpy(smp->initial_path, path->path, path->hop_cnt + 1);
+
+ if (data)
+ memcpy(smp->data, data, sizeof smp->data);
+
+ smp->hop_cnt = (uint8_t) path->hop_cnt;
+}
+
+char *drmad_status_str(struct drsmp *drsmp)
+{
+ switch (drsmp->status) {
+ case 0:
+ return "success";
+ case ETIMEDOUT:
+ return "timeout";
+ }
+ return "unknown error";
+}
+
+int str2DRPath(char *str, DRPath * path)
+{
+ char *s;
+
+ path->hop_cnt = -1;
+
+ DEBUG("DR str: %s", str);
+ while (str && *str) {
+ if ((s = strchr(str, ',')))
+ *s = 0;
+ path->path[++path->hop_cnt] = (char)atoi(str);
+ if (!s)
+ break;
+ str = s + 1;
+ }
+
+#if 0
+ if (path->path[0] != 0 ||
+ (path->hop_cnt > 0 && dev_port && path->path[1] != dev_port)) {
+ DEBUG("hop 0 != 0 or hop 1 != dev_port");
+ return -1;
+ }
+#endif
+
+ return path->hop_cnt;
+}
+
+static int dump_char, mgmt_class = IB_SMI_CLASS;
+
+static int process_opt(void *context, int ch, char *optarg)
+{
+ switch (ch) {
+ case 's':
+ dump_char++;
+ break;
+ case 'D':
+ mgmt_class = IB_SMI_DIRECT_CLASS;
+ break;
+ case 'L':
+ mgmt_class = IB_SMI_CLASS;
+ break;
+ default:
+ return -1;
+ }
+ return 0;
+}
+
+#ifndef strdupa
+#define strdupa(_s) \
+({ \
+ char *_d; \
+ int _len; \
+ \
+ _len = strlen(_s) + 1; \
+ _d = alloca(_len); \
+ if (_d) \
+ memcpy(_d, _s, _len); \
+ _d; \
+})
+#endif
+
+int main(int argc, char *argv[])
+{
+ int dlid = 0;
+ void *umad;
+ struct drsmp *smp;
+ int i, portid, mod = 0, attr;
+ DRPath path;
+ uint8_t *desc;
+ int length;
+
+ const struct ibdiag_opt opts[] = {
+ {"string", 's', 0, NULL, ""},
+ {0}
+ };
+ char usage_args[] = "<dlid|dr_path> <attr> [mod]";
+ const char *usage_examples[] = {
+ " -- DR routed examples:",
+ "-D 0,1,2,3,5 16 # NODE DESC",
+ "-D 0,1,2 0x15 2 # PORT INFO, port 2",
+ " -- LID routed examples:",
+ "3 0x15 2 # PORT INFO, lid 3 port 2",
+ "0xa0 0x11 # NODE INFO, lid 0xa0",
+ NULL
+ };
+
+ ibd_timeout = 1000;
+
+ ibdiag_process_opts(argc, argv, NULL, "GKs", opts, process_opt,
+ usage_args, usage_examples);
+
+ argc -= optind;
+ argv += optind;
+
+ if (argc < 2)
+ ibdiag_show_usage();
+
+ if (mgmt_class == IB_SMI_DIRECT_CLASS &&
+ str2DRPath(strdupa(argv[0]), &path) < 0)
+ IBPANIC("bad path str '%s'", argv[0]);
+
+ if (mgmt_class == IB_SMI_CLASS)
+ dlid = strtoul(argv[0], 0, 0);
+
+ attr = strtoul(argv[1], 0, 0);
+ if (argc > 2)
+ mod = strtoul(argv[2], 0, 0);
+
+ if (umad_init() < 0)
+ IBPANIC("can't init UMAD library");
+
+ if ((portid = umad_open_port(ibd_ca, ibd_ca_port)) < 0)
+ IBPANIC("can't open UMAD port (%s:%d)", ibd_ca, ibd_ca_port);
+
+ if ((mad_agent = umad_register(portid, mgmt_class, 1, 0, 0)) < 0)
+ IBPANIC("Couldn't register agent for SMPs");
+
+ if (!(umad = umad_alloc(1, umad_size() + IB_MAD_SIZE)))
+ IBPANIC("can't alloc MAD");
+
+ smp = umad_get_mad(umad);
+
+ if (mgmt_class == IB_SMI_DIRECT_CLASS)
+ drsmp_get_init(umad, &path, attr, mod);
+ else
+ smp_get_init(umad, dlid, attr, mod);
+
+ if (ibdebug > 1)
+ xdump(stderr, "before send:\n", smp, 256);
+
+ length = IB_MAD_SIZE;
+ if (umad_send(portid, mad_agent, umad, length, ibd_timeout, 0) < 0)
+ IBPANIC("send failed");
+
+ if (umad_recv(portid, umad, &length, -1) != mad_agent)
+ IBPANIC("recv error: %s", drmad_status_str(smp));
+
+ if (!dump_char) {
+ xdump(stdout, 0, smp->data, 64);
+ if (smp->status)
+ fprintf(stdout, "SMP status: 0x%x\n",
+ ntohs(smp->status));
+ goto exit;
+ }
+
+ desc = smp->data;
+ for (i = 0; i < 64; ++i) {
+ if (!desc[i])
+ break;
+ putchar(desc[i]);
+ }
+ putchar('\n');
+ if (smp->status)
+ fprintf(stdout, "SMP status: 0x%x\n", ntohs(smp->status));
+
+exit:
+ umad_free(umad);
+ return 0;
+}
diff --git a/contrib/ofed/infiniband-diags/src/smpquery.c b/contrib/ofed/infiniband-diags/src/smpquery.c
new file mode 100644
index 0000000..2bd7132
--- /dev/null
+++ b/contrib/ofed/infiniband-diags/src/smpquery.c
@@ -0,0 +1,509 @@
+/*
+ * Copyright (c) 2004-2009 Voltaire Inc. All rights reserved.
+ * Copyright (c) 2011 Mellanox Technologies LTD. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+#if HAVE_CONFIG_H
+# include <config.h>
+#endif /* HAVE_CONFIG_H */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <string.h>
+#include <getopt.h>
+#include <netinet/in.h>
+
+#define __STDC_FORMAT_MACROS
+#include <inttypes.h>
+
+#include <infiniband/umad.h>
+#include <infiniband/mad.h>
+#include <complib/cl_nodenamemap.h>
+
+#include "ibdiag_common.h"
+
+struct ibmad_port *srcport;
+
+static op_fn_t node_desc, node_info, port_info, switch_info, pkey_table,
+ sl2vl_table, vlarb_table, guid_info, mlnx_ext_port_info, port_info_extended;
+
+static const match_rec_t match_tbl[] = {
+ {"NodeInfo", "NI", node_info, 0, ""},
+ {"NodeDesc", "ND", node_desc, 0, ""},
+ {"PortInfo", "PI", port_info, 1, ""},
+ {"PortInfoExtended", "PIE", port_info_extended, 1, ""},
+ {"SwitchInfo", "SI", switch_info, 0, ""},
+ {"PKeyTable", "PKeys", pkey_table, 1, ""},
+ {"SL2VLTable", "SL2VL", sl2vl_table, 1, ""},
+ {"VLArbitration", "VLArb", vlarb_table, 1, ""},
+ {"GUIDInfo", "GI", guid_info, 0, ""},
+ {"MlnxExtPortInfo", "MEPI", mlnx_ext_port_info, 1, ""},
+ {0}
+};
+
+static char *node_name_map_file = NULL;
+static nn_map_t *node_name_map = NULL;
+static int extended_speeds = 0;
+
+/*******************************************/
+static char *node_desc(ib_portid_t * dest, char **argv, int argc)
+{
+ int node_type, l;
+ uint64_t node_guid;
+ char nd[IB_SMP_DATA_SIZE] = { 0 };
+ uint8_t data[IB_SMP_DATA_SIZE] = { 0 };
+ char dots[128];
+ char *nodename = NULL;
+
+ if (!smp_query_via(data, dest, IB_ATTR_NODE_INFO, 0, 0, srcport))
+ return "node info query failed";
+
+ mad_decode_field(data, IB_NODE_TYPE_F, &node_type);
+ mad_decode_field(data, IB_NODE_GUID_F, &node_guid);
+
+ if (!smp_query_via(nd, dest, IB_ATTR_NODE_DESC, 0, 0, srcport))
+ return "node desc query failed";
+
+ nodename = remap_node_name(node_name_map, node_guid, nd);
+
+ l = strlen(nodename);
+ if (l < 32) {
+ memset(dots, '.', 32 - l);
+ dots[32 - l] = '\0';
+ } else {
+ dots[0] = '.';
+ dots[1] = '\0';
+ }
+
+ printf("Node Description:%s%s\n", dots, nodename);
+ free(nodename);
+ return 0;
+}
+
+static char *node_info(ib_portid_t * dest, char **argv, int argc)
+{
+ char buf[2048];
+ char data[IB_SMP_DATA_SIZE] = { 0 };
+
+ if (!smp_query_via(data, dest, IB_ATTR_NODE_INFO, 0, 0, srcport))
+ return "node info query failed";
+
+ mad_dump_nodeinfo(buf, sizeof buf, data, sizeof data);
+
+ printf("# Node info: %s\n%s", portid2str(dest), buf);
+ return 0;
+}
+
+static char *port_info_extended(ib_portid_t * dest, char **argv, int argc)
+{
+ char buf[2048];
+ uint8_t data[IB_SMP_DATA_SIZE] = { 0 };
+ int portnum = 0;
+
+ if (argc > 0)
+ portnum = strtol(argv[0], 0, 0);
+
+ if (!is_port_info_extended_supported(dest, portnum, srcport))
+ return "port info extended not supported";
+
+ if (!smp_query_via(data, dest, IB_ATTR_PORT_INFO_EXT, portnum, 0,
+ srcport))
+ return "port info extended query failed";
+
+ mad_dump_portinfo_ext(buf, sizeof buf, data, sizeof data);
+ printf("# Port info Extended: %s port %d\n%s", portid2str(dest),
+ portnum, buf);
+ return 0;
+}
+
+static char *port_info(ib_portid_t * dest, char **argv, int argc)
+{
+ char data[IB_SMP_DATA_SIZE] = { 0 };
+ int portnum = 0, orig_portnum;
+
+ if (argc > 0)
+ portnum = strtol(argv[0], 0, 0);
+ orig_portnum = portnum;
+ if (extended_speeds)
+ portnum |= 1 << 31;
+
+ if (!smp_query_via(data, dest, IB_ATTR_PORT_INFO, portnum, 0, srcport))
+ return "port info query failed";
+
+ printf("# Port info: %s port %d\n", portid2str(dest), orig_portnum);
+ dump_portinfo(data, 0);
+ return 0;
+}
+
+static char *mlnx_ext_port_info(ib_portid_t * dest, char **argv, int argc)
+{
+ char buf[2300];
+ char data[IB_SMP_DATA_SIZE];
+ int portnum = 0;
+
+ if (argc > 0)
+ portnum = strtol(argv[0], 0, 0);
+
+ if (!smp_query_via(data, dest, IB_ATTR_MLNX_EXT_PORT_INFO, portnum, 0, srcport))
+ return "Mellanox ext port info query failed";
+
+ mad_dump_mlnx_ext_port_info(buf, sizeof buf, data, sizeof data);
+
+ printf("# MLNX ext Port info: %s port %d\n%s", portid2str(dest), portnum, buf);
+ return 0;
+}
+
+static char *switch_info(ib_portid_t * dest, char **argv, int argc)
+{
+ char buf[2048];
+ char data[IB_SMP_DATA_SIZE] = { 0 };
+
+ if (!smp_query_via(data, dest, IB_ATTR_SWITCH_INFO, 0, 0, srcport))
+ return "switch info query failed";
+
+ mad_dump_switchinfo(buf, sizeof buf, data, sizeof data);
+
+ printf("# Switch info: %s\n%s", portid2str(dest), buf);
+ return 0;
+}
+
+static char *pkey_table(ib_portid_t * dest, char **argv, int argc)
+{
+ uint8_t data[IB_SMP_DATA_SIZE] = { 0 };
+ int i, j, k;
+ uint16_t *p;
+ unsigned mod;
+ int n, t, phy_ports;
+ int portnum = 0;
+
+ if (argc > 0)
+ portnum = strtol(argv[0], 0, 0);
+
+ /* Get the partition capacity */
+ if (!smp_query_via(data, dest, IB_ATTR_NODE_INFO, 0, 0, srcport))
+ return "node info query failed";
+
+ mad_decode_field(data, IB_NODE_TYPE_F, &t);
+ mad_decode_field(data, IB_NODE_NPORTS_F, &phy_ports);
+ if (portnum > phy_ports)
+ return "invalid port number";
+
+ if ((t == IB_NODE_SWITCH) && (portnum != 0)) {
+ if (!smp_query_via(data, dest, IB_ATTR_SWITCH_INFO, 0, 0,
+ srcport))
+ return "switch info failed";
+ mad_decode_field(data, IB_SW_PARTITION_ENFORCE_CAP_F, &n);
+ } else
+ mad_decode_field(data, IB_NODE_PARTITION_CAP_F, &n);
+
+ for (i = 0; i < (n + 31) / 32; i++) {
+ mod = i | (portnum << 16);
+ if (!smp_query_via(data, dest, IB_ATTR_PKEY_TBL, mod, 0,
+ srcport))
+ return "pkey table query failed";
+ if (i + 1 == (n + 31) / 32)
+ k = ((n + 7 - i * 32) / 8) * 8;
+ else
+ k = 32;
+ p = (uint16_t *) data;
+ for (j = 0; j < k; j += 8, p += 8) {
+ printf
+ ("%4u: 0x%04x 0x%04x 0x%04x 0x%04x 0x%04x 0x%04x 0x%04x 0x%04x\n",
+ (i * 32) + j, ntohs(p[0]), ntohs(p[1]),
+ ntohs(p[2]), ntohs(p[3]), ntohs(p[4]), ntohs(p[5]),
+ ntohs(p[6]), ntohs(p[7]));
+ }
+ }
+ printf("%d pkeys capacity for this port\n", n);
+
+ return 0;
+}
+
+static char *sl2vl_dump_table_entry(ib_portid_t * dest, int in, int out)
+{
+ char buf[2048];
+ char data[IB_SMP_DATA_SIZE] = { 0 };
+ int portnum = (in << 8) | out;
+
+ if (!smp_query_via(data, dest, IB_ATTR_SLVL_TABLE, portnum, 0, srcport))
+ return "slvl query failed";
+
+ mad_dump_sltovl(buf, sizeof buf, data, sizeof data);
+ printf("ports: in %2d, out %2d: ", in, out);
+ printf("%s", buf);
+ return 0;
+}
+
+static char *sl2vl_table(ib_portid_t * dest, char **argv, int argc)
+{
+ uint8_t data[IB_SMP_DATA_SIZE] = { 0 };
+ int type, num_ports, portnum = 0;
+ int i;
+ char *ret;
+
+ if (argc > 0)
+ portnum = strtol(argv[0], 0, 0);
+
+ if (!smp_query_via(data, dest, IB_ATTR_NODE_INFO, 0, 0, srcport))
+ return "node info query failed";
+
+ mad_decode_field(data, IB_NODE_TYPE_F, &type);
+ mad_decode_field(data, IB_NODE_NPORTS_F, &num_ports);
+ if (portnum > num_ports)
+ return "invalid port number";
+
+ printf("# SL2VL table: %s\n", portid2str(dest));
+ printf("# SL: |");
+ for (i = 0; i < 16; i++)
+ printf("%2d|", i);
+ printf("\n");
+
+ if (type != IB_NODE_SWITCH)
+ return sl2vl_dump_table_entry(dest, 0, 0);
+
+ for (i = 0; i <= num_ports; i++) {
+ ret = sl2vl_dump_table_entry(dest, i, portnum);
+ if (ret)
+ return ret;
+ }
+ return 0;
+}
+
+static char *vlarb_dump_table_entry(ib_portid_t * dest, int portnum, int offset,
+ unsigned cap)
+{
+ char buf[2048];
+ char data[IB_SMP_DATA_SIZE] = { 0 };
+
+ if (!smp_query_via(data, dest, IB_ATTR_VL_ARBITRATION,
+ (offset << 16) | portnum, 0, srcport))
+ return "vl arb query failed";
+ mad_dump_vlarbitration(buf, sizeof(buf), data, cap * 2);
+ printf("%s", buf);
+ return 0;
+}
+
+static char *vlarb_dump_table(ib_portid_t * dest, int portnum,
+ char *name, int offset, int cap)
+{
+ char *ret;
+
+ printf("# %s priority VL Arbitration Table:", name);
+ ret = vlarb_dump_table_entry(dest, portnum, offset,
+ cap < 32 ? cap : 32);
+ if (!ret && cap > 32)
+ ret = vlarb_dump_table_entry(dest, portnum, offset + 1,
+ cap - 32);
+ return ret;
+}
+
+static char *vlarb_table(ib_portid_t * dest, char **argv, int argc)
+{
+ uint8_t data[IB_SMP_DATA_SIZE] = { 0 };
+ int portnum = 0;
+ int type, enhsp0, lowcap, highcap;
+ char *ret = 0;
+
+ if (argc > 0)
+ portnum = strtol(argv[0], 0, 0);
+
+ /* port number of 0 could mean SP0 or port MAD arrives on */
+ if (portnum == 0) {
+ if (!smp_query_via(data, dest, IB_ATTR_NODE_INFO, 0, 0,
+ srcport))
+ return "node info query failed";
+
+ mad_decode_field(data, IB_NODE_TYPE_F, &type);
+ if (type == IB_NODE_SWITCH) {
+ memset(data, 0, sizeof(data));
+ if (!smp_query_via(data, dest, IB_ATTR_SWITCH_INFO, 0,
+ 0, srcport))
+ return "switch info query failed";
+ mad_decode_field(data, IB_SW_ENHANCED_PORT0_F, &enhsp0);
+ if (!enhsp0) {
+ printf
+ ("# No VLArbitration tables (BSP0): %s port %d\n",
+ portid2str(dest), 0);
+ return 0;
+ }
+ memset(data, 0, sizeof(data));
+ }
+ }
+
+ if (!smp_query_via(data, dest, IB_ATTR_PORT_INFO, portnum, 0, srcport))
+ return "port info query failed";
+
+ mad_decode_field(data, IB_PORT_VL_ARBITRATION_LOW_CAP_F, &lowcap);
+ mad_decode_field(data, IB_PORT_VL_ARBITRATION_HIGH_CAP_F, &highcap);
+
+ printf("# VLArbitration tables: %s port %d LowCap %d HighCap %d\n",
+ portid2str(dest), portnum, lowcap, highcap);
+
+ if (lowcap > 0)
+ ret = vlarb_dump_table(dest, portnum, "Low", 1, lowcap);
+
+ if (!ret && highcap > 0)
+ ret = vlarb_dump_table(dest, portnum, "High", 3, highcap);
+
+ return ret;
+}
+
+static char *guid_info(ib_portid_t * dest, char **argv, int argc)
+{
+ uint8_t data[IB_SMP_DATA_SIZE] = { 0 };
+ int i, j, k;
+ uint64_t *p;
+ unsigned mod;
+ int n;
+
+ /* Get the guid capacity */
+ if (!smp_query_via(data, dest, IB_ATTR_PORT_INFO, 0, 0, srcport))
+ return "port info failed";
+ mad_decode_field(data, IB_PORT_GUID_CAP_F, &n);
+
+ for (i = 0; i < (n + 7) / 8; i++) {
+ mod = i;
+ if (!smp_query_via(data, dest, IB_ATTR_GUID_INFO, mod, 0,
+ srcport))
+ return "guid info query failed";
+ if (i + 1 == (n + 7) / 8)
+ k = ((n + 1 - i * 8) / 2) * 2;
+ else
+ k = 8;
+ p = (uint64_t *) data;
+ for (j = 0; j < k; j += 2, p += 2) {
+ printf("%4u: 0x%016" PRIx64 " 0x%016" PRIx64 "\n",
+ (i * 8) + j, ntohll(p[0]), ntohll(p[1]));
+ }
+ }
+ printf("%d guids capacity for this port\n", n);
+
+ return 0;
+}
+
+static int process_opt(void *context, int ch, char *optarg)
+{
+ switch (ch) {
+ case 1:
+ node_name_map_file = strdup(optarg);
+ break;
+ case 'c':
+ ibd_dest_type = IB_DEST_DRSLID;
+ break;
+ case 'x':
+ extended_speeds = 1;
+ break;
+ default:
+ return -1;
+ }
+ return 0;
+}
+
+int main(int argc, char **argv)
+{
+ char usage_args[1024];
+ int mgmt_classes[3] =
+ { IB_SMI_CLASS, IB_SMI_DIRECT_CLASS, IB_SA_CLASS };
+ ib_portid_t portid = { 0 };
+ char *err;
+ op_fn_t *fn;
+ const match_rec_t *r;
+ int n;
+
+ const struct ibdiag_opt opts[] = {
+ {"combined", 'c', 0, NULL,
+ "use Combined route address argument"},
+ {"node-name-map", 1, 1, "<file>", "node name map file"},
+ {"extended", 'x', 0, NULL, "use extended speeds"},
+ {0}
+ };
+ const char *usage_examples[] = {
+ "portinfo 3 1\t\t\t\t# portinfo by lid, with port modifier",
+ "-G switchinfo 0x2C9000100D051 1\t# switchinfo by guid",
+ "-D nodeinfo 0\t\t\t\t# nodeinfo by direct route",
+ "-c nodeinfo 6 0,12\t\t\t# nodeinfo by combined route",
+ NULL
+ };
+
+ n = sprintf(usage_args, "<op> <dest dr_path|lid|guid> [op params]\n"
+ "\nSupported ops (and aliases, case insensitive):\n");
+ for (r = match_tbl; r->name; r++) {
+ n += snprintf(usage_args + n, sizeof(usage_args) - n,
+ " %s (%s) <addr>%s\n", r->name,
+ r->alias ? r->alias : "",
+ r->opt_portnum ? " [<portnum>]" : "");
+ if (n >= sizeof(usage_args))
+ exit(-1);
+ }
+
+ ibdiag_process_opts(argc, argv, NULL, NULL, opts, process_opt,
+ usage_args, usage_examples);
+
+ argc -= optind;
+ argv += optind;
+
+ if (argc < 2)
+ ibdiag_show_usage();
+
+ if (!(fn = match_op(match_tbl, argv[0])))
+ IBEXIT("operation '%s' not supported", argv[0]);
+
+ srcport = mad_rpc_open_port(ibd_ca, ibd_ca_port, mgmt_classes, 3);
+ if (!srcport)
+ IBEXIT("Failed to open '%s' port '%d'", ibd_ca, ibd_ca_port);
+
+ smp_mkey_set(srcport, ibd_mkey);
+
+ node_name_map = open_node_name_map(node_name_map_file);
+
+ if (ibd_dest_type != IB_DEST_DRSLID) {
+ if (resolve_portid_str(ibd_ca, ibd_ca_port, &portid, argv[1],
+ ibd_dest_type, ibd_sm_id, srcport) < 0)
+ IBEXIT("can't resolve destination port %s", argv[1]);
+ if ((err = fn(&portid, argv + 2, argc - 2)))
+ IBEXIT("operation %s: %s", argv[0], err);
+ } else {
+ char concat[64];
+
+ memset(concat, 0, 64);
+ snprintf(concat, sizeof(concat), "%s %s", argv[1], argv[2]);
+ if (resolve_portid_str(ibd_ca, ibd_ca_port, &portid, concat,
+ ibd_dest_type, ibd_sm_id, srcport) < 0)
+ IBEXIT("can't resolve destination port %s", concat);
+ if ((err = fn(&portid, argv + 3, argc - 3)))
+ IBEXIT("operation %s: %s", argv[0], err);
+ }
+ close_node_name_map(node_name_map);
+ mad_rpc_close_port(srcport);
+ exit(0);
+}
diff --git a/contrib/ofed/infiniband-diags/src/vendstat.c b/contrib/ofed/infiniband-diags/src/vendstat.c
new file mode 100644
index 0000000..9cef104
--- /dev/null
+++ b/contrib/ofed/infiniband-diags/src/vendstat.c
@@ -0,0 +1,552 @@
+/*
+ * Copyright (c) 2012 Mellanox Technologies LTD. All rights reserved.
+ * Copyright (c) 2004-2009 Voltaire Inc. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+#if HAVE_CONFIG_H
+# include <config.h>
+#endif /* HAVE_CONFIG_H */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <getopt.h>
+#include <netinet/in.h>
+
+#include <infiniband/umad.h>
+#include <infiniband/mad.h>
+
+#include "ibdiag_common.h"
+
+#define IS3_DEVICE_ID 47396
+
+#define IB_MLX_VENDOR_CLASS 10
+/* Vendor specific Attribute IDs */
+#define IB_MLX_IS3_GENERAL_INFO 0x17
+#define IB_MLX_IS3_CONFIG_SPACE_ACCESS 0x50
+#define IB_MLX_IS4_COUNTER_GROUP_INFO 0x90
+#define IB_MLX_IS4_CONFIG_COUNTER_GROUP 0x91
+/* Config space addresses */
+#define IB_MLX_IS3_PORT_XMIT_WAIT 0x10013C
+
+
+struct ibmad_port *srcport;
+
+static ibmad_gid_t dgid;
+static int with_grh;
+
+typedef struct {
+ uint16_t hw_revision;
+ uint16_t device_id;
+ uint8_t reserved[24];
+ uint32_t uptime;
+} is3_hw_info_t;
+
+typedef struct {
+ uint8_t resv1;
+ uint8_t major;
+ uint8_t minor;
+ uint8_t sub_minor;
+ uint32_t build_id;
+ uint8_t month;
+ uint8_t day;
+ uint16_t year;
+ uint16_t resv2;
+ uint16_t hour;
+ uint8_t psid[16];
+ uint32_t ini_file_version;
+} is3_fw_info_t;
+
+typedef struct {
+ uint32_t ext_major;
+ uint32_t ext_minor;
+ uint32_t ext_sub_minor;
+ uint32_t reserved[4];
+} is4_fw_ext_info_t;
+
+typedef struct {
+ uint8_t resv1;
+ uint8_t major;
+ uint8_t minor;
+ uint8_t sub_minor;
+ uint8_t resv2[28];
+} is3_sw_info_t;
+
+typedef struct {
+ uint8_t reserved[8];
+ is3_hw_info_t hw_info;
+ is3_fw_info_t fw_info;
+ is3_sw_info_t sw_info;
+} is3_general_info_t;
+
+typedef struct {
+ uint8_t reserved[8];
+ is3_hw_info_t hw_info;
+ is3_fw_info_t fw_info;
+ is4_fw_ext_info_t ext_fw_info;
+ is3_sw_info_t sw_info;
+} is4_general_info_t;
+
+typedef struct {
+ uint8_t reserved[8];
+ struct is3_record {
+ uint32_t address;
+ uint32_t data;
+ uint32_t mask;
+ } record[18];
+} is3_config_space_t;
+
+#define COUNTER_GROUPS_NUM 2
+
+typedef struct {
+ uint8_t reserved1[8];
+ uint8_t reserved[3];
+ uint8_t num_of_counter_groups;
+ uint32_t group_masks[COUNTER_GROUPS_NUM];
+} is4_counter_group_info_t;
+
+typedef struct {
+ uint8_t reserved[3];
+ uint8_t group_select;
+} is4_group_select_t;
+
+typedef struct {
+ uint8_t reserved1[8];
+ uint8_t reserved[4];
+ is4_group_select_t group_selects[COUNTER_GROUPS_NUM];
+} is4_config_counter_groups_t;
+
+static uint16_t ext_fw_info_device[][2] = {
+ {0x0245, 0x0245}, /* Switch-X */
+ {0xc738, 0xc73b}, /* Switch-X */
+ {0xcb20, 0xcb20}, /* Switch-IB */
+ {0xcf08, 0xcf08}, /* Switch-IB2*/
+ {0x01b3, 0x01b3}, /* IS-4 */
+ {0x1003, 0x1017}, /* Connect-X */
+ {0x1b02, 0x1b02}, /* Bull SwitchX */
+ {0x1b50, 0x1b50}, /* Bull SwitchX */
+ {0x1ba0, 0x1ba0}, /* Bull SwitchIB */
+ {0x1bd0, 0x1bd5}, /* Bull SwitchIB and SwitchIB2 */
+ {0x1b33, 0x1b33}, /* Bull ConnectX3 */
+ {0x1b73, 0x1b73}, /* Bull ConnectX3 */
+ {0x1b40, 0x1b41}, /* Bull ConnectX3 */
+ {0x1b60, 0x1b61}, /* Bull ConnectX3 */
+ {0x1b83, 0x1b83}, /* Bull ConnectIB */
+ {0x1b93, 0x1b94}, /* Bull ConnectIB */
+ {0x1bb4, 0x1bb5}, /* Bull ConnectX4 */
+ {0x1bc4, 0x1bc4}, /* Bull ConnectX4 */
+ {0x0000, 0x0000}};
+
+static int is_ext_fw_info_supported(uint16_t device_id) {
+ int i;
+ for (i = 0; ext_fw_info_device[i][0]; i++)
+ if (ext_fw_info_device[i][0] <= device_id &&
+ device_id <= ext_fw_info_device[i][1])
+ return 1;
+ return 0;
+}
+
+static int do_vendor(ib_portid_t *portid, struct ibmad_port *srcport,
+ uint8_t class, uint8_t method, uint16_t attr_id,
+ uint32_t attr_mod, void *data)
+{
+ ib_vendor_call_t call;
+
+ memset(&call, 0, sizeof(call));
+ call.mgmt_class = class;
+ call.method = method;
+ call.timeout = ibd_timeout;
+ call.attrid = attr_id;
+ call.mod = attr_mod;
+
+ if (!ib_vendor_call_via(data, portid, &call, srcport)) {
+ fprintf(stderr,"vendstat: method %u, attribute %u failure\n", method, attr_id);
+ return -1;
+ }
+ return 0;
+}
+
+static int do_config_space_records(ib_portid_t *portid, unsigned set,
+ is3_config_space_t *cs, unsigned records)
+{
+ unsigned i;
+
+ if (records > 18)
+ records = 18;
+ for (i = 0; i < records; i++) {
+ cs->record[i].address = htonl(cs->record[i].address);
+ cs->record[i].data = htonl(cs->record[i].data);
+ cs->record[i].mask = htonl(cs->record[i].mask);
+ }
+
+ if (do_vendor(portid, srcport, IB_MLX_VENDOR_CLASS,
+ set ? IB_MAD_METHOD_SET : IB_MAD_METHOD_GET,
+ IB_MLX_IS3_CONFIG_SPACE_ACCESS, 2 << 22 | records << 16,
+ cs)) {
+ fprintf(stderr,"cannot %s config space records\n", set ? "set" : "get");
+ return -1;
+ }
+ for (i = 0; i < records; i++) {
+ printf("Config space record at 0x%x: 0x%x\n",
+ ntohl(cs->record[i].address),
+ ntohl(cs->record[i].data & cs->record[i].mask));
+ }
+ return 0;
+}
+
+static int counter_groups_info(ib_portid_t * portid, int port)
+{
+ char buf[1024];
+ is4_counter_group_info_t *cg_info;
+ int i, num_cg;
+
+ /* Counter Group Info */
+ memset(&buf, 0, sizeof(buf));
+ if (do_vendor(portid, srcport, IB_MLX_VENDOR_CLASS, IB_MAD_METHOD_GET,
+ IB_MLX_IS4_COUNTER_GROUP_INFO, port, buf)) {
+ fprintf(stderr,"counter group info query failure\n");
+ return -1;
+ }
+ cg_info = (is4_counter_group_info_t *) & buf;
+ num_cg = cg_info->num_of_counter_groups;
+ printf("counter_group_info:\n");
+ printf("%d counter groups\n", num_cg);
+ for (i = 0; i < num_cg; i++)
+ printf("group%d mask %#x\n", i, ntohl(cg_info->group_masks[i]));
+ return 0;
+}
+
+/* Group0 counter config values */
+#define IS4_G0_PortXmtDataSL_0_7 0
+#define IS4_G0_PortXmtDataSL_8_15 1
+#define IS4_G0_PortRcvDataSL_0_7 2
+
+/* Group1 counter config values */
+#define IS4_G1_PortXmtDataSL_8_15 1
+#define IS4_G1_PortRcvDataSL_0_7 2
+#define IS4_G1_PortRcvDataSL_8_15 8
+
+static int cg0, cg1;
+
+static int config_counter_groups(ib_portid_t * portid, int port)
+{
+ char buf[1024];
+ is4_config_counter_groups_t *cg_config;
+
+ /* configure counter groups for groups 0 and 1 */
+ memset(&buf, 0, sizeof(buf));
+ cg_config = (is4_config_counter_groups_t *) & buf;
+
+ printf("counter_groups_config: configuring group0 %d group1 %d\n", cg0,
+ cg1);
+ cg_config->group_selects[0].group_select = (uint8_t) cg0;
+ cg_config->group_selects[1].group_select = (uint8_t) cg1;
+
+ if (do_vendor(portid, srcport, IB_MLX_VENDOR_CLASS, IB_MAD_METHOD_SET,
+ IB_MLX_IS4_CONFIG_COUNTER_GROUP, port, buf)) {
+ fprintf(stderr, "config counter group set failure\n");
+ return -1;
+ }
+ /* get config counter groups */
+ memset(&buf, 0, sizeof(buf));
+
+ if (do_vendor(portid, srcport, IB_MLX_VENDOR_CLASS, IB_MAD_METHOD_GET,
+ IB_MLX_IS4_CONFIG_COUNTER_GROUP, port, buf)) {
+ fprintf(stderr, "config counter group query failure\n");
+ return -1;
+ }
+ return 0;
+}
+
+static int general_info, xmit_wait, counter_group_info, config_counter_group;
+static is3_config_space_t write_cs, read_cs;
+static unsigned write_cs_records, read_cs_records;
+
+
+static int process_opt(void *context, int ch, char *optarg)
+{
+ int ret;
+ switch (ch) {
+ case 'N':
+ general_info = 1;
+ break;
+ case 'w':
+ xmit_wait = 1;
+ break;
+ case 'i':
+ counter_group_info = 1;
+ break;
+ case 'c':
+ config_counter_group = 1;
+ ret = sscanf(optarg, "%d,%d", &cg0, &cg1);
+ if (ret != 2)
+ return -1;
+ break;
+ case 'R':
+ if (read_cs_records >= 18)
+ break;
+ ret = sscanf(optarg, "%x,%x",
+ &read_cs.record[read_cs_records].address,
+ &read_cs.record[read_cs_records].mask);
+ if (ret < 1)
+ return -1;
+ else if (ret == 1)
+ read_cs.record[read_cs_records].mask = 0xffffffff;
+ read_cs_records++;
+ break;
+ case 'W':
+ if (write_cs_records >= 18)
+ break;
+ ret = sscanf(optarg, "%x,%x,%x",
+ &write_cs.record[write_cs_records].address,
+ &write_cs.record[write_cs_records].data,
+ &write_cs.record[write_cs_records].mask);
+ if (ret < 2)
+ return -1;
+ else if (ret == 2)
+ write_cs.record[write_cs_records].mask = 0xffffffff;
+ write_cs_records++;
+ break;
+ case 25:
+ if (!inet_pton(AF_INET6, optarg, &dgid)) {
+ fprintf(stderr, "dgid format is wrong!\n");
+ ibdiag_show_usage();
+ return 1;
+ }
+ with_grh = 1;
+ break;
+ default:
+ return -1;
+ }
+ return 0;
+}
+
+int main(int argc, char **argv)
+{
+ int mgmt_classes[2] = { IB_SA_CLASS, IB_MLX_VENDOR_CLASS };
+ ib_portid_t portid = { 0 };
+ int port = 0;
+ char buf[1024];
+ uint32_t fw_ver_major = 0;
+ uint32_t fw_ver_minor = 0;
+ uint32_t fw_ver_sub_minor = 0;
+ uint8_t sw_ver_major = 0, sw_ver_minor = 0, sw_ver_sub_minor = 0;
+ is3_general_info_t *gi_is3;
+ is4_general_info_t *gi_is4;
+ const struct ibdiag_opt opts[] = {
+ {"N", 'N', 0, NULL, "show IS3 or IS4 general information"},
+ {"w", 'w', 0, NULL, "show IS3 port xmit wait counters"},
+ {"i", 'i', 0, NULL, "show IS4 counter group info"},
+ {"c", 'c', 1, "<num,num>", "configure IS4 counter groups"},
+ {"Read", 'R', 1, "<addr,mask>", "Read configuration space record at addr"},
+ {"Write", 'W', 1, "<addr,val,mask>", "Write configuration space record at addr"},
+ {"dgid", 25, 1, NULL, "remote gid (IPv6 format)"},
+ {0}
+ };
+
+ char usage_args[] = "<lid|guid> [port]";
+ const char *usage_examples[] = {
+ "-N 6\t\t# read IS3 or IS4 general information",
+ "-w 6\t\t# read IS3 port xmit wait counters",
+ "-i 6 12\t# read IS4 port 12 counter group info",
+ "-c 0,1 6 12\t# configure IS4 port 12 counter groups for PortXmitDataSL",
+ "-c 2,8 6 12\t# configure IS4 port 12 counter groups for PortRcvDataSL",
+ NULL
+ };
+
+ ibdiag_process_opts(argc, argv, NULL, "DKy", opts, process_opt,
+ usage_args, usage_examples);
+
+ argc -= optind;
+ argv += optind;
+
+ if (argc > 1)
+ port = strtoul(argv[1], 0, 0);
+
+ srcport = mad_rpc_open_port(ibd_ca, ibd_ca_port, mgmt_classes, 2);
+ if (!srcport)
+ IBEXIT("Failed to open '%s' port '%d'", ibd_ca, ibd_ca_port);
+
+ if (argc) {
+ if (with_grh && ibd_dest_type != IB_DEST_LID) {
+ mad_rpc_close_port(srcport);
+ IBEXIT("When using GRH, LID should be provided");
+ }
+ if (resolve_portid_str(ibd_ca, ibd_ca_port, &portid, argv[0],
+ ibd_dest_type, ibd_sm_id, srcport) < 0) {
+ mad_rpc_close_port(srcport);
+ IBEXIT("can't resolve destination port %s", argv[0]);
+ }
+ if (with_grh) {
+ portid.grh_present = 1;
+ memcpy(&portid.gid, &dgid, sizeof(portid.gid));
+ }
+ } else {
+ if (resolve_self(ibd_ca, ibd_ca_port, &portid, &port, 0) < 0) {
+ mad_rpc_close_port(srcport);
+ IBEXIT("can't resolve self port %s", argv[0]);
+ }
+ }
+
+ if (counter_group_info) {
+ counter_groups_info(&portid, port);
+ mad_rpc_close_port(srcport);
+ exit(0);
+ }
+
+ if (config_counter_group) {
+ config_counter_groups(&portid, port);
+ mad_rpc_close_port(srcport);
+ exit(0);
+ }
+
+ if (read_cs_records || write_cs_records) {
+ if (read_cs_records)
+ do_config_space_records(&portid, 0, &read_cs,
+ read_cs_records);
+ if (write_cs_records)
+ do_config_space_records(&portid, 1, &write_cs,
+ write_cs_records);
+ mad_rpc_close_port(srcport);
+ exit(0);
+ }
+
+ /* These are Mellanox specific vendor MADs */
+ /* but vendors change the VendorId so how know for sure ? */
+ /* Only General Info and Port Xmit Wait Counters */
+ /* queries are currently supported */
+ if (!general_info && !xmit_wait) {
+ mad_rpc_close_port(srcport);
+ IBEXIT("at least one of -N and -w must be specified");
+ }
+ /* Would need a list of these and it might not be complete */
+ /* so for right now, punt on this */
+
+ /* vendor ClassPortInfo is required attribute if class supported */
+ memset(&buf, 0, sizeof(buf));
+ if (do_vendor(&portid, srcport, IB_MLX_VENDOR_CLASS, IB_MAD_METHOD_GET,
+ CLASS_PORT_INFO, 0, buf)) {
+ mad_rpc_close_port(srcport);
+ IBEXIT("classportinfo query");
+ }
+ memset(&buf, 0, sizeof(buf));
+ gi_is3 = (is3_general_info_t *) &buf;
+ if (do_vendor(&portid, srcport, IB_MLX_VENDOR_CLASS, IB_MAD_METHOD_GET,
+ IB_MLX_IS3_GENERAL_INFO, 0, gi_is3)) {
+ mad_rpc_close_port(srcport);
+ IBEXIT("generalinfo query");
+ }
+
+ if (is_ext_fw_info_supported(ntohs(gi_is3->hw_info.device_id))) {
+ gi_is4 = (is4_general_info_t *) &buf;
+ fw_ver_major = ntohl(gi_is4->ext_fw_info.ext_major);
+ fw_ver_minor = ntohl(gi_is4->ext_fw_info.ext_minor);
+ fw_ver_sub_minor = ntohl(gi_is4->ext_fw_info.ext_sub_minor);
+ sw_ver_major = gi_is4->sw_info.major;
+ sw_ver_minor = gi_is4->sw_info.minor;
+ sw_ver_sub_minor = gi_is4->sw_info.sub_minor;
+ } else {
+ fw_ver_major = gi_is3->fw_info.major;
+ fw_ver_minor = gi_is3->fw_info.minor;
+ fw_ver_sub_minor = gi_is3->fw_info.sub_minor;
+ sw_ver_major = gi_is3->sw_info.major;
+ sw_ver_minor = gi_is3->sw_info.minor;
+ sw_ver_sub_minor = gi_is3->sw_info.sub_minor;
+ }
+
+ if (general_info) {
+ /* dump IS3 or IS4 general info here */
+ printf("hw_dev_rev: 0x%04x\n", ntohs(gi_is3->hw_info.hw_revision));
+ printf("hw_dev_id: 0x%04x\n", ntohs(gi_is3->hw_info.device_id));
+ printf("hw_uptime: 0x%08x\n", ntohl(gi_is3->hw_info.uptime));
+ printf("fw_version: %02d.%02d.%02d\n",
+ fw_ver_major, fw_ver_minor, fw_ver_sub_minor);
+ printf("fw_build_id: 0x%04x\n", ntohl(gi_is3->fw_info.build_id));
+ printf("fw_date: %02x/%02x/%04x\n",
+ gi_is3->fw_info.month, gi_is3->fw_info.day,
+ ntohs(gi_is3->fw_info.year));
+ printf("fw_psid: '%s'\n", gi_is3->fw_info.psid);
+ printf("fw_ini_ver: %d\n",
+ ntohl(gi_is3->fw_info.ini_file_version));
+ printf("sw_version: %02d.%02d.%02d\n", sw_ver_major,
+ sw_ver_minor, sw_ver_sub_minor);
+ }
+
+ if (xmit_wait) {
+ is3_config_space_t *cs;
+ unsigned i;
+
+ if (ntohs(gi_is3->hw_info.device_id) != IS3_DEVICE_ID) {
+ mad_rpc_close_port(srcport);
+ IBEXIT("Unsupported device ID 0x%x",
+ ntohs(gi_is3->hw_info.device_id));
+ }
+ memset(&buf, 0, sizeof(buf));
+ /* Set record addresses for each port */
+ cs = (is3_config_space_t *) & buf;
+ for (i = 0; i < 16; i++)
+ cs->record[i].address =
+ htonl(IB_MLX_IS3_PORT_XMIT_WAIT + ((i + 1) << 12));
+ if (do_vendor(&portid, srcport, IB_MLX_VENDOR_CLASS,
+ IB_MAD_METHOD_GET, IB_MLX_IS3_CONFIG_SPACE_ACCESS,
+ 2 << 22 | 16 << 16, cs)) {
+ mad_rpc_close_port(srcport);
+ IBEXIT("vendstat");
+ }
+ for (i = 0; i < 16; i++)
+ if (cs->record[i].data) /* PortXmitWait is 32 bit counter */
+ printf("Port %d: PortXmitWait 0x%x\n", i + 4, ntohl(cs->record[i].data)); /* port 4 is first port */
+
+ /* Last 8 ports is another query */
+ memset(&buf, 0, sizeof(buf));
+ /* Set record addresses for each port */
+ cs = (is3_config_space_t *) & buf;
+ for (i = 0; i < 8; i++)
+ cs->record[i].address =
+ htonl(IB_MLX_IS3_PORT_XMIT_WAIT + ((i + 17) << 12));
+ if (do_vendor(&portid, srcport, IB_MLX_VENDOR_CLASS,
+ IB_MAD_METHOD_GET, IB_MLX_IS3_CONFIG_SPACE_ACCESS,
+ 2 << 22 | 8 << 16, cs)) {
+ mad_rpc_close_port(srcport);
+ IBEXIT("vendstat");
+ }
+
+ for (i = 0; i < 8; i++)
+ if (cs->record[i].data) /* PortXmitWait is 32 bit counter */
+ printf("Port %d: PortXmitWait 0x%x\n",
+ i < 4 ? i + 21 : i - 3,
+ ntohl(cs->record[i].data));
+ }
+
+ mad_rpc_close_port(srcport);
+ exit(0);
+}
diff --git a/contrib/ofed/libcxgb4/AUTHORS b/contrib/ofed/libcxgb4/AUTHORS
deleted file mode 100644
index 5d9d2e2..0000000
--- a/contrib/ofed/libcxgb4/AUTHORS
+++ /dev/null
@@ -1 +0,0 @@
-Chelsio Communications, Inc.
diff --git a/contrib/ofed/libcxgb4/COPYING b/contrib/ofed/libcxgb4/COPYING
deleted file mode 100644
index 93b666f..0000000
--- a/contrib/ofed/libcxgb4/COPYING
+++ /dev/null
@@ -1,29 +0,0 @@
-Copyright (c) 2010-2013. Chelsio Communications. All rights reserved.
-
-This software is available to you under a choice of one of two
-licenses. You may choose to be licensed under the terms of the GNU
-General Public License (GPL) Version 2, available from the file
-COPYING in the main directory of this source tree, or the
-OpenIB.org BSD license below:
-
- Redistribution and use in source and binary forms, with or
- without modification, are permitted provided that the following
- conditions are met:
-
- - Redistributions of source code must retain the above
- copyright notice, this list of conditions and the following
- disclaimer.
-
- - Redistributions in binary form must reproduce the above
- copyright notice, this list of conditions and the following
- disclaimer in the documentation and/or other materials
- provided with the distribution.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
-BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
-ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
-CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-SOFTWARE.
diff --git a/contrib/ofed/libcxgb4/ChangeLog b/contrib/ofed/libcxgb4/ChangeLog
deleted file mode 100644
index 0c83c24..0000000
--- a/contrib/ofed/libcxgb4/ChangeLog
+++ /dev/null
@@ -1,1054 +0,0 @@
-commit 6a417d903b9add7c8ab2b71ac11c85c46671e020
-Author: Steve Wise <swise@opengridcomputing.com>
-Date: Thu Jul 31 11:25:22 2014 -0500
-
- Spin release 1.3.5.
-
- Signed-off-by: Steve Wise <swise@opengridcomputing.com>
-
-commit 52ecbea1b908d3b449022e2d75ebe0ca3885bcf2
-Author: Steve Wise <swise@opengridcomputing.com>
-Date: Thu Jul 31 11:14:05 2014 -0500
-
- libcxb4: use wc_wmb() instead of wmb().
-
- The user mode RDMA macro for wmb() is not sufficient to provide the
- fencing needed. This was causing corrupted packets when running multiple
- WD-UDP sockperf processes. The correct "sfence" instruction is provided
- with the wc_wmb() macro. See /usr/include/infiniband/arch.h.
-
- Note: The kernel implementation of wmb() is sufficient. This is a
- libcxgb4 issue only...
-
- Signed-off-by: Steve Wise <swise@opengridcomputing.com>
-
-commit 242c29715372bf6999aa343a5aad5654da3ecf3a
-Author: Steve Wise <swise@opengridcomputing.com>
-Date: Wed Jun 18 10:17:00 2014 -0500
-
- Spin release 1.3.4
-
- Signed-off-by: Steve Wise <swise@opengridcomputing.com>
-
-commit 2d54f4c5604cae24caac493aaf6d8b0907ac2ed2
-Author: Steve Wise <swise@opengridcomputing.com>
-Date: Wed Jun 18 10:16:52 2014 -0500
-
- Support the query_qp() verb
-
- Signed-off-by: Steve Wise <swise@opengridcomputing.com>
-
-commit f80159d12148774646ad65d03cd070f6d5f86eb4
-Author: Steve Wise <swise@opengridcomputing.com>
-Date: Mon Jun 9 15:20:47 2014 -0500
-
- Account for the full qid range.
-
- The total qid range is should really be based on the max_cq attribute.
-
- Signed-off-by: Steve Wise <swise@opengridcomputing.com>
-
-commit 5aaf5e7277a1c12964aac11a4cff94520717e805
-Author: Yann Droneaud <ydroneaud@opteya.com>
-Date: Mon May 5 12:59:23 2014 -0500
-
- kernel abi: adds explicit padding in struct c4iw_alloc_ucontext_resp
-
- i386 ABI disagree with most other ABIs regarding alignment
- of data type larger than 4 bytes: on most ABIs a padding must
- be added at end of the structures, while it is not
- required on i386.
-
- Such ABI disagreement will make an x86_64 kernel try to write past
- the struct c4iw_alloc_ucontext_resp buffer provided by an i386
- userspace binary. As struct c4iw_alloc_ucontext_resp is likely
- on stack, see function c4iw_alloc_context(), side effects are
- expected.
-
- On kernel side, this structure was modified for kernel v3.15-rc1
- by following commit:
-
- Commit 05eb23893c2cf9502a9cec0c32e7f1d1ed2895c8
- Author: Steve Wise <swise@opengridcomputing.com>
- Date: Fri Mar 14 21:52:08 2014 +0530
-
- cxgb4/iw_cxgb4: Doorbell Drop Avoidance Bug Fixes
-
- If boundary check is implemented on kernel side, the x86_64
- kernel will instead refuse to write past the i386 userspace
- provided buffer and the uverbs will fail.
-
- To fix these issues, this patch adds an explicit padding at end
- of structure so that i386 and others ABI share the same structure
- layout. This patch makes c4iw_alloc_context() check for a value
- in the padding field to detect newer kernel using the field for
- a future purpose (only activated in debug).
-
- With this patch, libcxgb4 will work against older kernel and
- newer patched kernel.
-
- Link: http://marc.info/?i=cover.1399216475.git.ydroneaud@opteya.com
- Signed-off-by: Yann Droneaud <ydroneaud@opteya.com>
- Signed-off-by: Steve Wise <swise@opengridcomputing.com>
-
-commit 5c65bf17913949368db8802656dc7dbc291271ed
-Author: Yann Droneaud <ydroneaud@opteya.com>
-Date: Mon May 5 12:59:23 2014 -0500
-
- kernel abi: adds explicit padding in struct c4iw_create_cq_resp
-
- i386 ABI disagree with most other ABIs regarding alignment
- of data type larger than 4 bytes: on most ABIs a padding must
- be added at end of the structures, while it is not required
- on i386.
-
- Such ABI disagreement will make an x86_64 kernel try to write past
- the struct c4iw_create_cq_resp buffer provided by an i386
- userspace binary. As struct c4iw_create_cq_resp is likely
- on stack, see function c4iw_create_cq(), side effects are
- expected.
-
- On kernel side, this structure was added for kernel v2.6.35-rc1
- by following commit.
-
- Commit cfdda9d764362ab77b11a410bb928400e6520d57
- Author: Steve Wise <swise@opengridcomputing.com>
- Date: Wed Apr 21 15:30:06 2010 -0700
-
- RDMA/cxgb4: Add driver for Chelsio T4 RNIC
-
- If boundary check is implemented on kernel side, the x86_64 kernel
- will refuse to write past the i386 userspace provided buffer and the
- uverbs will fail.
-
- To fix these issues, this patch adds an explicit padding at end
- of structure so that i386 and others ABI share the same structure
- layout. This patch makes c4iw_create_cq() check for a value in the
- padding field to detect newer kernel using the field for a future
- purpose (only activated in debug).
-
- With this patch, libcxgb4 will work against older kernel and
- newer patched kernel.
-
- Link: http://marc.info/?i=cover.1399216475.git.ydroneaud@opteya.com
-
- Signed-off-by: Yann Droneaud <ydroneaud@opteya.com>
- Signed-off-by: Steve Wise <swise@opengridcomputing.com>
-
-commit 4f334446f63e3a34006f504f7c89075423c412b4
-Author: Steve Wise <swise@opengridcomputing.com>
-Date: Tue Mar 11 11:47:19 2014 -0500
-
- Spin release 1.3.3.
-
- Signed-off-by: Steve Wise <swise@opengridcomputing.com>
-
-commit 98cea522707232b99ff5c07dd9f57937aa8a7d91
-Author: Steve Wise <swise@opengridcomputing.com>
-Date: Tue Mar 11 11:44:16 2014 -0500
-
- Zero the status_page_size before calling get_context.
-
- Signed-off-by: Steve Wise <swise@opengridcomuting.com>
-
-commit a373e16a94524e20492301b0e97f53930133739b
-Author: Steve Wise <swise@opengridcomputing.com>
-Date: Tue Feb 18 12:07:19 2014 -0600
-
- Spin release 1.3.2.
-
- Signed-off-by: Steve Wise <swise@opengridcomputing.com>
-
-commit a2f25730971e8b76033e283f03e79ef4c5dbc4bc
-Author: Steve Wise <swise@opengridcomputing.com>
-Date: Tue Feb 18 11:29:50 2014 -0600
-
- Fixed compilation error with debug enabled.
-
- Signed-off-by: Steve Wise <swise@opengridcomputing.com>
-
-commit f484e0f4c5a4cb249f86a050efd659be37a51204
-Author: Steve Wise <swise@opengridcomputing.com>
-Date: Tue Feb 18 11:24:06 2014 -0600
-
- Use V_PIDX_T5() for T5 devices in ring_db funcs.
-
- Signed-off-by: Steve Wise <swise@opengridcomputing.com>
-
-commit 32b74074808da51e5918295bfc63d347548478a0
-Author: Steve Wise <swise@opengridcomputing.com>
-Date: Tue Feb 18 11:24:05 2014 -0600
-
- Call wc_wmb() needed after DB writes.
-
- Need to do an sfence after botht he WC and regular PIDX DB write.
- Otherwise the host might reorder things and cause work request corruption
- (seen with NFSRDMA).
-
- Signed-off-by: Steve Wise <swise@opengridcomputing.com>
-
-commit c078eed091a32b930f5bbdf0a12a3be0d0a79cf0
-Author: Steve Wise <swise@opengridcomputing.com>
-Date: Tue Feb 18 11:23:57 2014 -0600
-
- Call rmb() after reading valid gen bit.
-
- Some HW platforms can reorder read operations, so we must rmb() after
- we see a valid gen bit in a CQE but before we read any other fields
- from the CQE.
-
- Signed-off-by: Steve Wise <swise@opengridcomputing.com>
-
-commit 7b482dcdbbd187fd8372f744157ac2b323d32f45
-Author: Steve Wise <swise@opengridcomputing.com>
-Date: Tue Feb 18 11:12:06 2014 -0600
-
- Update copyrights.
-
- Signed-off-by: Steve Wise <swise@opengridcomputing.com>
-
-commit f74316373c0b2a2bd2872ae38f7be516a10503c9
-Author: Steve Wise <swise@opengridcomputing.com>
-Date: Tue Feb 18 11:12:06 2014 -0600
-
- Refresh t4 fw/hw reg files.
-
- Signed-off-by: Steve Wise <swise@opengridcomputing.com>
-
-commit 1b8434f22deb30f700246dd2f474eaa2512e4867
-Author: Steve Wise <swise@opengridcomputing.com>
-Date: Tue Feb 18 11:12:03 2014 -0600
-
- Add common device id table and chip types.
-
- This will make it easier to merge in new devices.
-
-commit 18e5bc32bbe7e19eb9ea5a34d8b2f7d1e6355105
-Author: Steve Wise <swise@opengridcomputing.com>
-Date: Tue Feb 18 10:25:33 2014 -0600
-
- Remove dead SIM code.
-
- Signed-off-by: Steve Wise <swise@opengridcomputing.com>
-
-commit c8c793385de1d3e9c1edeb7b13cbc964049b8362
-Author: Steve Wise <swise@opengridcomputing.com>
-Date: Tue Feb 18 10:23:05 2014 -0600
-
- Remove dead raw qp code.
-
- Signed-off-by: Steve Wise <swise@opengridcomputing.com>
-
-commit 9302c092d46e4c40cbf6b2189aeda08e5ca3fea4
-Author: Steve Wise <swise@opengridcomputing.com>
-Date: Tue Feb 18 10:17:52 2014 -0600
-
- iw_cxgb4/libcxgb4: swsq "signaled" state needs to mind sq_sig_all.
-
- When a qp is created, the ULP can request that all sq wrs be signaled.
- The swsqe entries need to take this into account when marking the entry
- as signaled.
-
- This bug will cause read request CQEs to be silently discarded, and can
- cause flush problems because the swsqe entry will be mismarked for qps
- created with sq_sig_all set in the qp init attributes.
-
- Signed-off-by: Steve Wise <swise@opengridcomputing.com>
-
-commit 48c6633d4a6510a8c1832ac800f45c2099eb28b4
-Author: Steve Wise <swise@opengridcomputing.com>
-Date: Tue Feb 18 10:17:52 2014 -0600
-
- never consume a pending wr in sq flush.
-
- There is a race when moving a QP from RTS->CLOSING where a SQ work
- request could be posted after the FW receives the RDMA_RI/FINI WR.
- The SQ work request will never get processed, and should be completed
- with FLUSHED status. Function c4iw_flush_sq(), however was dropping
- the oldest SQ work request when in CLOSING or IDLE states, instead of
- completing the pending work request. If that oldest pending work request
- was actually complete and has a CQE in the CQ, then when that CQE is
- proceessed in poll_cq, we'll BUG_ON() due to the inconsistent SQ/CQ state.
-
- This is a very small timing hole and has only been hit once so far.
-
- c4iw_flush_sq() MUST always flush all non-completed WRs with FLUSHED
- status regardless of the QP state.
-
- Signed-off-by: Steve Wise <swise@opengridcomputing.com>
-
-commit 1a3a3e8e8da7463e59b74d5c5396e7bd5e303cd4
-Author: Steve Wise <swise@opengridcomputing.com>
-Date: Tue Feb 18 10:11:35 2014 -0600
-
- unmap status page when freeing the context.
-
- Signed-off-by: Steve Wise <swise@opengridcomputing.com>
-
-commit 81e83780e44af2ff25c2572b15fe7e8b8cc6e134
-Author: Steve Wise <swise@opengridcomputing.com>
-Date: Tue Feb 18 10:05:54 2014 -0600
-
- DB Drop Avoidance, Version 2.
-
- Add support for the device status page mapped per device that is used
- to enable/disable user db usage.
-
- Signed-off-by: Steve Wise <swise@opengridcomputing.com>
-
-commit 5830447cef866432c4d3e65f7e58c51a0c687798
-Author: Steve Wise <swise@opengridcomputing.com>
-Date: Tue Feb 18 09:40:39 2014 -0600
-
- Fix DEBUG code in c4iw_flush_hw_cq().
-
- Signed-off-by: Steve Wise <swise@opengridcomputing.com>
-
-commit 127bc437797ca34e14b261fa653c1d0524d07272
-Author: Steve Wise <swise@opengridcomputing.com>
-Date: Tue Feb 18 09:40:38 2014 -0600
-
- T4 onchip workaround: do the 16 4B MA writes just before DB ring.
-
- This is a merge of sw repo changesets 1576, 2149, and 2246.
-
- Signed-off-by: Steve Wise <swise@opengridcomputing.com>
-
-commit ac38281728d12a91725aa67e0273dc26976598fb
-Author: Steve Wise <swise@opengridcomputing.com>
-Date: Fri Jul 19 09:37:10 2013 -0500
-
- Spin release 1.3.1.
-
- Signed-off-by: Steve Wise <swise@opengridcomputing.com>
-
-commit 272fcac194318e13f563b46463726cc03ae83dbe
-Author: Steve Wise <swise@opengridcomputing.com>
-Date: Fri Jul 19 09:36:35 2013 -0500
-
- Update copyright.
-
- Signed-off-by: Steve Wise <swise@opengridcomputing.com>
-
-commit ba3183d18168f764700ded52651033a79d2a9a86
-Author: Steve Wise <swise@opengridcomputing.com>
-Date: Mon Jun 10 14:10:02 2013 -0500
-
- get rid of hard coded queue iqs.
-
- Since we now get the number of queues available from the driver,
- we shouldn't be using the hard coded defines anymore.
-
- Signed-off-by: Steve Wise <swise@opengridcomputing.com>
-
-commit 2095e0a04bc5357da1b9d346e00d52cf7c236cf6
-Author: Steve Wise <swise@opengridcomputing.com>
-Date: Mon Jun 10 14:09:35 2013 -0500
-
- update configure.in
-
- Signed-off-by: Steve Wise <swise@opengridcomputing.com>
-
-commit a7a4de4f37a60ffbd8addd8f9ab5505adb86c63f
-Author: Steve Wise <swise@opengridcomputing.com>
-Date: Mon Jun 10 14:09:34 2013 -0500
-
- Mind the sq_sig_all/sq_sig_type QP attributes.
-
- Signed-off-by: Steve Wise <swise@opengridcomputing.com>
-
-commit 4a485c8dc1c7c70ab85c708bb4c530eef385424d
-Author: Steve Wise <swise@opengridcomputing.com>
-Date: Mon Jun 10 14:09:34 2013 -0500
-
- always do GTS write if cidx_inc == M_CIDXINC.
-
- When polling, we do a GTS update if the accumulated cidx_inc == the cq
- depth / 16. This works around a T4 bug. However, if the cq is large
- enough, cq depth / 16 exceeds the size of the field in the GTS word.
- So we also need to update if cidx_inc hits M_CIDXINC to avoid overflowing
- the field.
-
- Signed-off-by: Steve Wise <swise@opengridcomputing.com>
-
-commit a276f65add45933cf8b16bb09361786cf1932c4b
-Author: Steve Wise <swise@opengridcomputing.com>
-Date: Mon Jun 10 14:09:34 2013 -0500
-
- fixed bug where sq.udb was getting overwritten.
-
- There was an erroneous statement in create_rc_qp() which caused the
- sq.udb va to be overwritten with the rq.udb va only for on-chip queues.
- This error only affected unmapping of that mapped va when destroying
- a qp. In the presence of multiple threads creating/destroying qps, the
- erroneously unmapped va could have been assigned to another qp mapping.
- This causes intermittent seg faults as libcxgb4 tries to access memory
- that has been unmapped in error.
-
- Signed-off-by: Steve Wise <swise@opengridcomputing.com>
-
-commit 1cb6249cf722e265d8e2364de0ee5b0d59a8e4cd
-Author: Steve Wise <swise@opengridcomputing.com>
-Date: Mon Jun 10 14:09:34 2013 -0500
-
- flush problem with unsignaled wrs.
-
- c4iw_flush_sq() should only flush wrs that have not already been
- flushed. Since we already track where in the sq we've flushed via
- sq.cidx_flush, just start at that point and flush any remaining. This bug
- only caused a problem in the presence of unsignaled work requests.
-
- Signed-off-by: Steve Wise <swise@opengridcomputing.com>
-
-commit 4132e3434d8ffc2b92055649f42c56be77111216
-Author: Steve Wise <swise@opengridcomputing.com>
-Date: Mon Jun 10 14:09:31 2013 -0500
-
- clean up queue dump logic.
-
- Signed-off-by: Steve Wise <swise@opengridcomputing.com>
-
-commit a5e390613548f1dc62d9fe142b6a30a943fc56cf
-Author: Steve Wise <swise@opengridcomputing.com>
-Date: Tue Jun 4 12:09:21 2013 -0500
-
- accounting for unsignled sq wrs fails to deal with wrap.
-
- When determining how many wrs are completed with a signaled cqe,
- correctly deal with queue wraps.
-
- Signed-off-by: Steve Wise <swise@opengridcomputing.com>
-
-commit 0c1906cec82443e2323dc69dd5c23ae4314087c0
-Author: Steve Wise <swise@opengridcomputing.com>
-Date: Tue Jun 4 12:09:19 2013 -0500
-
- Handle qp flushes with pending sw cqes.
-
- The flush and out of order completion logic has a bug: If out of order
- completions are flushed but not yet polled by the consumer and the qp
- is then flushed, we end up inserting duplicate completions.
-
- Signed-off-by: Steve Wise <swise@opengridcomputing.com>
-
-commit 26a19bf6d020dbaab8c6cf13396b39a64f952dba
-Author: Steve Wise <swise@opengridcomputing.com>
-Date: Tue Jun 4 11:57:00 2013 -0500
-
- fixed false uninitialized var warning.
-
- Signed-off-by: Steve Wise <swise@opengridcomputing.com>
-
-commit 119e11e72d20a07a806c3385b8cfa6de93f7d114
-Author: Steve Wise <swise@opengridcomputing.com>
-Date: Thu Mar 28 15:15:39 2013 -0500
-
- Spin release 1.3.0
-
- Signed-off-by: Steve Wise <swise@opengridcomputing.com>
-
-commit a4a0d3fe768ffa33a75ab3df4bd8c678e7f7180b
-Author: Steve Wise <swise@opengridcomputing.com>
-Date: Thu Mar 28 15:15:38 2013 -0500
-
- Remove aclocal.m4.
-
- Signed-off-by: Steve Wise <swise@opengridcomputing.com>
-
-commit 3c22ddca7cf627d62d06b0ff374fa04192a8cc4c
-Author: Steve Wise <swise@opengridcomputing.com>
-Date: Thu Mar 28 15:15:37 2013 -0500
-
- libcxgb4: unmap the correct udb/ugts address.
-
- The various db and gts variables holding the mapped bar2 pointer
- get incremented at creation time as a normal part of object creation.
- However this causes the wrong address to get unmapped when the object is
- destroyed. The result is a mapping leak because the munmap() fails.
- So align them back to their proper page boundary when calling munmap().
-
- Singed-off-by: Steve Wise <swise@opengridcomputing.com>
-
-commit 9b2d3af5735e4067b83cde79e08a37142e8fb895
-Author: Steve Wise <swise@opengridcomputing.com>
-Date: Thu Mar 28 15:15:35 2013 -0500
-
- Query device to get the max supported stags, qps, and cqs.
-
- Signed-off-by: Steve Wise <swise@opengridcomputing.com>
-
-commit e8a595da9129d650caf162b7103368af03e07fcc
-Author: Steve Wise <swise@opengridcomputing.com>
-Date: Thu Mar 28 15:15:33 2013 -0500
-
- Add T5 support.
-
- This commit is composed of a series of patches to enable T5 support. I
- folded them into one commit for simplicity. Plus intermittent patches
- caused problems/regressions/etc, so its cleaner to have 1 commit to enable
- the new device.
-
- Signed-off-by: Vipul Pandya <vipul@chelsio.com>
- Signed-off-by: Steve Wise <swise@opengridcomputing.com>
-
-commit 7cb73aba54eb47d6902c9a3f952c0e37500cac8f
-Author: Steve Wise <swise@opengridcomputing.com>
-Date: Mon Mar 4 10:28:32 2013 -0600
-
- zero out r3 and r4 fields of fw_ri_send_wr messages.
-
- Signed-off-by: Steve Wise <swise@opengridcomputing.com>
-
-commit f61c762e82b3e6e1c27496eecaf2bf8d00f009e3
-Author: Steve Wise <swise@opengridcomputing.com>
-Date: Mon Mar 4 10:21:39 2013 -0600
-
- Add new T4 device IDs.
-
- Signed-off-by: Steve Wise <swise@opengridcomputing.com>
-
-commit c66a627e1e964bad794e9dc40e9a39dc6977aa1e
-Author: Steve Wise <swise@opengridcomputing.com>
-Date: Mon Mar 4 10:08:59 2013 -0600
-
- flush bug can cause application crash
-
- This fixes a problem in the flush logic that could occur if the
- current position is near the end of the queue and the 'count' being
- retired plus this position was greater than the queue size. In this
- case the index wasn't being wrapped and the associated swcqe pointer
- would point past the end of the CQ.
-
- Asserts were added to check other possible wrap-error paths.
-
- This bug was causing mbw to occasionally crash when flushing the qp.
-
- Signed-off-by: Steve Wise <swise@opengridcomputing.com>
-
-commit c5cdab8ad79cecc996d735011b210729fcc95ecd
-Author: Steve Wise <swise@opengridcomputing.com>
-Date: Mon Mar 4 10:08:58 2013 -0600
-
- Silently eat unsignaled read response cqes.
-
- Terminator HW always generates read response cqes. We need to silently
- eat them vs returning them to the user. The perftest benchmark ib_read_bw
- relies on unsignaled work requests and will crash with this fix.
-
- Signed-off-by: Steve Wise <swise@opengridcomputing.com>
-
-commit 1eefdaae19110deae2c20a08ea53cab451fc00bb
-Author: Steve Wise <swise@opengridcomputing.com>
-Date: Fri Feb 8 13:51:37 2013 -0600
-
- Remove useless dma_addr_t define.
-
- Signed-off-by: Steve Wise <swise@opengridcomputing.com>
-
-commit c551f4632cfcd284ad82d1d9b36d1449d109a5de
-Author: Steve Wise <swise@opengridcomputing.com>
-Date: Fri Feb 8 13:51:00 2013 -0600
-
- Disable strict aliasing warnings.
-
- Signed-off-by: Steve Wise <swise@opengridcomputing.com>
-
-commit 695a5a4be21f44d49999c83e6ac0699ce90d97c7
-Author: Steve Wise <swise@opengridcomputing.com>
-Date: Wed Nov 9 09:50:32 2011 -0600
-
- Spin release 1.2.0.
-
- Signed-off-by: Steve Wise <swise@opengridcomputing.com>
-
-commit 721cfb11ca5697d017bc60167805aea9bbb13ba0
-Author: Vipul Pandya <vipul@chelsio.com>
-Date: Mon Nov 7 15:08:45 2011 +0530
-
- libcxgb4: Reset flush_cidx before incrementing cidx.
-
- Signed-off-by: Vipul Pandya <vipul@chelsio.com>
-
-commit db4fe38c7ee2b3ad9dc8c33f2b54f0c8cdf8b4d2
-Author: Vipul Pandya <vipul@chelsio.com>
-Date: Mon Nov 7 15:06:29 2011 +0530
-
- libcxgb4: Fix multi-flush logic path....again
-
- Signed-off-by: Vipul Pandya <vipul@chelsio.com>
-
-commit 19198bdc2f7feb05babcc2a544ae8b48e4943c41
-Author: Vipul Pandya <vipul@chelsio.com>
-Date: Mon Nov 7 15:02:57 2011 +0530
-
- libcxgb4: Reset cidx_flush if a active queue starts getting hw cqes
-
- Signed-off-by: Vipul Pandya <vipul@chelsio.com>
-
-commit 98545f3a8cbe1670efad080cf908db42269f76ff
-Author: Vipul Pandya <vipul@chelsio.com>
-Date: Mon Nov 7 14:56:44 2011 +0530
-
- libcxgb4: Support for flushing a CQ bound to multiple QPs
-
- Signed-off-by: Vipul Pandya <vipul@chelsio.com>
-
-commit 86ba968706b3dc8cb232a303201bb03a2d919c88
-Author: Vipul Pandya <vipul@chelsio.com>
-Date: Mon Nov 7 13:06:43 2011 +0530
-
- libcxgb4: Checks iw_cxgb4 ABI version to know door bell drop recovery support
-
- Store iw_cxgb4 ABI version in a global state. Read that global state in
- t4_wq_db_enabled to know if iw_cxgb4 driver supports door bell drop recovery.
-
- Signed-off-by: Vipul Pandya <vipul@chelsio.com>
-
-commit 2b6563ed5b377dac56c218b809d387089d70312d
-Author: Vipul Pandya <vipul@chelsio.com>
-Date: Sun Oct 23 16:50:16 2011 +0530
-
- libcxgb4: fixed compilation warnings
-
- Signed-off-by: Vipul Pandya <vipul@chelsio.com>
-
-commit c5c120969c22a04d34adc566085192afc99d0db9
-Author: Vipul Pandya <vipul@chelsio.com>
-Date: Fri Oct 21 19:05:20 2011 +0530
-
- libcxgb4: Bug Fix#4410 - Fix 3 segfaults
-
- This patch fixes 3 segfaults with below signatures:
- ----
- 1)
- Program received signal SIGSEGV, Segmentation fault.
- [Switching to Thread 0x7ffff7fef710 (LWP 22624)]
- 0x00007ffff75613e4 in create_read_req_cqe (wq=0x7fffe800ada0,
- hw_cqe=0x7ffff7fc7880, read_cqe=0x7ffff7fee860) at src/cq.c:162
- 162 read_cqe->u.rdma.u.scqe.cidx = wq->sq.oldest_read->idx;
- (gdb) bt
- hw_cqe=0x7ffff7fc7880, read_cqe=0x7ffff7fee860) at src/cq.c:162
- attr=0x7ffff7feeae0, attr_mask=1) at src/verbs.c:691
- src/verbs.c:721
-
- 2)
- Program received signal SIGSEGV, Segmentation fault.
- [Switching to Thread 0x7ffff6e07710 (LWP 22218)]
- 0x00007ffff71563e4 in create_read_req_cqe (wq=0x7fffe800ada0,
- hw_cqe=0x7ffff7fc7880, read_cqe=0x7ffff6e02b70) at src/cq.c:162
- 162 read_cqe->u.rdma.u.scqe.cidx = wq->sq.oldest_read->idx;
- (gdb) bt
- hw_cqe=0x7ffff7fc7880, read_cqe=0x7ffff6e02b70) at src/cq.c:162
- src/verbs.c:887
-
- 3)
- (gdb) bt
- wc=0x7ffff51378d0) at src/cq.c:776
- evd_ptr=<value optimized out>, wc_ptr=<value optimized out>)
- at /usr/include/infiniband/verbs.h:957
- ----
-
- Signed-off-by: Vipul Pandya <vipul@chelsio.com>
-
-commit 075adec1159606303b40f4b29ef3cea7ab780ac2
-Author: Vipul Pandya <vipul@chelsio.com>
-Date: Fri Oct 21 18:59:16 2011 +0530
-
- libcxgb4: return -ENOSYS in c4iw_resize_cq().
-
- I fixed a "bug" in c4iw_resize_cq() in an earlier commit which regressed
- us. c4iw_resize_cq() was returning 0 always even though we don't support
- resizing the CQ. So I change libcxgb4 to return whatever errno is
- returned by the kernel driver. However, because the driver didn't set
- the uverbs capabilities for resize_cq, uverbs returned EINVAL. The OMPI
- code checks for -ENOSYS and handles providers that don't support it.
- If, however, ibv_resize_cq() returns any other error, OMPI bails out.
- So we need to return -ENOSYS.
-
- I didn't see this error, however, running NP192 OMPI/IMB all night long.
- So it must only try to resize for small jobs and thus I missed the
- regression.
-
- Signed-off-by: Vipul Pandya <vipul@chelsio.com>
-
-commit 320285a3a3a93a614e24a78f7a68780d7791e3c5
-Author: Vipul Pandya <vipul@chelsio.com>
-Date: Fri Oct 21 18:53:47 2011 +0530
-
- libcxgb4: Don't flush unsignaled WRs if the QP closed normally
-
- - add query_qp support in driver to query the qp state before flushing.
-
- - fixed flush logic (again).
-
- - don't flush unsignaled WRs is QP had a normal close.
-
- - support up to 64K QIDs.
-
- Signed-off-by: Vipul Pandya <vipul@chelsio.com>
-
-commit 4c98bebe97aeef1c5cda2f071eb9c1d4fa29c37e
-Author: Vipul Pandya <vipul@chelsio.com>
-Date: Fri Oct 21 17:58:38 2011 +0530
-
- libcxgb4: Correctly flush unsignaled WRs followed by a signaled WR.
-
- The cq flush logic was not accounting for unsignaled SQ WRs followed by
- a signaled WR. The result was too many flushed CQEs causing application
- faults or assert() failures in libcxgb4 because the SQ state is corrupted.
-
- Signed-off-by: Vipul Pandya <vipul@chelsio.com>
-
-commit 8196f85bdefb1511d6d834240a92fdaf815834b8
-Author: Vipul Pandya <vipul@chelsio.com>
-Date: Fri Oct 21 17:31:03 2011 +0530
-
- libcxgb4: Remove auto generated ltmain.sh file.
-
- Signed-off-by: Vipul Pandya <vipul@chelsio.com>
-
-commit 230d12f42d143eeb53d8c4935ba27620c13e6165
-Author: Vipul Pandya <vipul@chelsio.com>
-Date: Fri Oct 21 17:20:37 2011 +0530
-
- libcxgb4: Add debug code to dump state on a stall condition.
-
- Signed-off-by: Vipul Pandya <vipul@chelsio.com>
-
-commit 2df0677b22aebb7a22d0e8ca11beb90250b363c7
-Author: Vipul Pandya <vipul@chelsio.com>
-Date: Fri Oct 21 15:04:46 2011 +0530
-
- libcxgb4: don't write host idx values when wq is in error.
-
- This fixes a regression introduced by the db recovery changes. The host
- idx shadow fields at the end of the wq should only be written if the wq
- is not in error. Otherwise, a seg fault can occur.
-
- Signed-off-by: Vipul Pandya <vipul@chelsio.com>
-
-commit 4eaf4b9added6ca660ef2f9363b24d754185fddf
-Author: Vipul Pandya <vipul@chelsio.com>
-Date: Thu Oct 20 19:55:57 2011 +0530
-
- libcxgb4: cq debug changes
-
- - turn on cq overflow detection by default
-
- - shadow cq->cidx in the cq status page
-
- Signed-off-by: Vipul Pandya <vipul@chelsio.com>
-
-commit b15d02248dd1029706d07fa229767d8b68d16c65
-Author: Vipul Pandya <vipul@chelsio.com>
-Date: Thu Oct 20 19:43:07 2011 +0530
-
- libcxgb4: DB Drop Recovery for RDMA and LLD queues.
-
- Signed-off-by: Vipul Pandya <vipul@chelsio.com>
-
-commit b2c7499eab73cf28cbd9cf86f6ea134e2450cdd3
-Author: Vipul Pandya <vipul@chelsio.com>
-Date: Sun Oct 23 12:59:24 2011 +0530
-
- libcxgb4: put queue idx values in status page for debug.
-
- Signed-off-by: Vipul Pandya <vipul@chelsio.com>
-
-commit 60a30673a4072b6727e7266f7782607ddcbc8de7
-Author: Vipul Pandya <vipul@chelsio.com>
-Date: Thu Oct 20 18:07:13 2011 +0530
-
- libcxgb4: DB Overflow Avoidance.
-
- - when user dbs are disabled, call into the kernel driver via modify_qp()
- to ring the dbs.
-
- Signed-off-by: Vipul Pandya <vipul@chelsio.com>
-
-commit c8651d01a2d69d83caff8c01b32be0b23624d8da
-Author: Steve Wise <swise@opengridcomputing.com>
-Date: Thu Mar 10 09:45:00 2011 -0600
-
- Spin release 1.1.1.
-
- Signed-off-by: Steve Wise <swise@opengridcomputing.com>
-
-commit ace467085deb7327522faeb19e20e13d691f66a2
-Author: Steve Wise <swise@opengridcomputing.com>
-Date: Thu Mar 10 09:34:11 2011 -0600
-
- Flush MA FIFO for on-chip queues.
-
- Signed-off-by: Steve Wise <swise@opengridcomputing.com>
-
-commit 7cb87f46c1784c791d29646104ab355ed920747d
-Author: Steve Wise <swise@opengridcomputing.com>
-Date: Thu Mar 10 09:27:57 2011 -0600
-
- increase the frequency of CIDX-INC updates.
-
- Heavy IMB loads reveal that my current algorithm of doing CIDX-INC
- GTS writes every 1/2 the CQ depth was not sufficient. This patch
- increases the frequency to 1/16.
-
- Signed-off-by: Steve Wise <swise@opengridcomputing.com>
-
-commit 7652d71daadda0c3aba9b96311ea623a1e324d77
-Author: Steve Wise <swise@opengridcomputing.com>
-Date: Wed Sep 15 16:57:04 2010 -0500
-
- Spin release 1.1.0.
-
- Signed-off-by: Steve Wise <swise@opengridcomputing.com>
-
-commit ed05d22592bc96987635b2c255a99663f286b812
-Author: Steve Wise <swise@opengridcomputing.com>
-Date: Wed Sep 15 16:56:51 2010 -0500
-
- Support all T4 device IDs.
-
- Signed-off-by: Steve Wise <swise@opengridcomputing.com>
-
-commit b051a2ea9dc7b6ffa08f955e60b331e42fec8672
-Author: Steve Wise <swise@opengridcomputing.com>
-Date: Wed Sep 15 15:54:35 2010 -0500
-
- Support ABI 0 and 1 versions of the iwarp driver.
-
- Signed-off-by: Steve Wise <swise@opengridcomputing.com>
-
-commit 62f1363bb716e2283f9e2b885e5f02a6d5c692d1
-Author: Steve Wise <swise@opengridcomputing.com>
-Date: Wed Sep 15 14:06:17 2010 -0500
-
- Bump the slots per SQ to 5 to allow up to 128MB fast registers.
-
- Signed-off-by: Steve Wise <swise@opengridcomputing.com>
-
-commit d51e041839254d656cc260dba3f26a7c9d73aa56
-Author: Steve Wise <swise@opengridcomputing.com>
-Date: Wed Sep 15 14:06:16 2010 -0500
-
- Raw QP implementation
-
- Signed-off-by: Steve Wise <swise@opengridcomputing.com>
-
-commit 8f55539d0b8aea70084edf31687e590cf5a57221
-Author: Steve Wise <swise@opengridcomputing.com>
-Date: Wed Sep 15 14:03:55 2010 -0500
-
- Add compile-time user mode rdma stats.
-
- Signed-off-by: Steve Wise <swise@opengridcomputing.com>
-
-commit 2e3531bbd91d7a6f057b3503132aef5e64adb548
-Author: Steve Wise <swise@opengridcomputing.com>
-Date: Wed Sep 15 13:57:03 2010 -0500
-
- Support on-chip SQs.
-
- Signed-off-by: Steve Wise <swise@opengridcomputing.com>
-
-commit 65bb173b86c2e0a9ff5f877e4d3951cb8daa6e97
-Author: Steve Wise <swise@opengridcomputing.com>
-Date: Wed Sep 15 13:54:44 2010 -0500
-
- Work around TERM CQE hw bug.
-
- Signed-off-by: Steve Wise <swise@opengridcomputing.com>
-
-commit 6bb37d1f72652d4ed0c1972bc673f4418cc7a856
-Author: Steve Wise <swise@opengridcomputing.com>
-Date: Wed Sep 15 13:54:44 2010 -0500
-
- Zero out padding in iSGLs.
-
- Signed-off-by: Steve Wise <swise@opengridcomputing.com>
-
-commit aad128404c494ec4779055b5e550c2d7de7d5ca9
-Author: Steve Wise <swise@opengridcomputing.com>
-Date: Thu Jul 22 14:58:51 2010 -0500
-
- Spin release 1.0.4
-
- Signed-off-by: Steve Wise <swise@opengridcomputing.com>
-
-commit 07ac253a8a479fd59fe654baf5a94ffc1de13765
-Author: Steve Wise <swise@opengridcomputing.com>
-Date: Thu Jul 22 14:57:27 2010 -0500
-
- Do GTS/CIDX_INC writes in the poll path to avoid drops.
-
- With T4 asic, we still see the CIDX_INC overflow/drops.
-
- Signed-off-by: Steve Wise <swise@opengridcomputing.com>
-
-commit 3394198639f811c86ab519c43197a9b724435cb0
-Author: Steve Wise <swise@opengridcomputing.com>
-Date: Thu Jul 22 14:56:53 2010 -0500
-
- Support T420 and T440 cards.
-
- Signed-off-by: Steve Wise <swise@opengridcomputing.com>
-
-commit 311dd1c8ec3e38287895053dce52dfef5ed5f0b1
-Author: Steve Wise <swise@opengridcomputing.com>
-Date: Fri Jun 11 10:40:53 2010 -0500
-
- Spin release 1.0.3.
-
- Signed-off-by: Steve Wise <swise@opengridcomputing.com>
-
-commit a62d7cf38f7b6c731486ff969ee7e3a4238ebc3f
-Author: Steve Wise <swise@opengridcomputing.com>
-Date: Fri Jun 11 10:37:17 2010 -0500
-
- Support variable sized work requests.
-
- T4 EQ entries are in multiples of 64B. Currently the RDMA SQ and RQ
- use fixed sized entries composed of 4 EQ entries for the SQ and 2 EQ
- entries for the RQ. For optimial latency with small IO, we need to
- change this so the HW only needs to DMA the EQ entries actually used by
- a given work request.
-
- Implementation:
-
- - add wq_pidx counter to track where we are in the EQ. cidx/pidx are
- used for the sw sq/rq tracking and flow control.
-
- - the variable part of work requests is the SGL. Add new functions to
- build the SGL and/or immediate data directly in the EQ memory wrapping
- when needed.
-
- - adjust the min burst size for the EQ contexts to 64B.
-
-commit 3be829d117a8ca7957370b09b477fe551de0cea5
-Author: Steve Wise <swise@opengridcomputing.com>
-Date: Thu May 20 15:52:59 2010 -0500
-
- Spin release 1.0.2.
-
- Signed-off-by: Steve Wise <swise@opengridcomputing.com>
-
-commit dc1ea232e8ece4ba53d2496befad14bd433e2e3e
-Author: Steve Wise <swise@opengridcomputing.com>
-Date: Thu May 20 15:48:37 2010 -0500
-
- only insert sq qid in lookup tables.
-
- Signed-off-by: Steve Wise <swise@opengridcomputing.com>
-
-commit 00c60fd47b71dac42d864662567701e2618ff45d
-Author: Steve Wise <swise@opengridcomputing.com>
-Date: Thu May 20 15:47:37 2010 -0500
-
- Update some driver limits.
-
- Signed-off-by: Steve Wise <swise@opengridcomputing.com>
-
-commit f25661e19d728a0a33a221c0646a9fce9b160f8b
-Author: Steve Wise <swise@opengridcomputing.com>
-Date: Thu May 20 15:46:38 2010 -0500
-
- Fix cq arm overflow.
-
- - wrap cq->cqidx_inc based on cq size
- - optimize t4_arm_cq() logic
-
- Signed-off-by: Steve Wise <swise@opengridcomputing.com>
-
-commit 8c224aca8f1acd219010e46da538ae4c9a4f9d1a
-Author: Steve Wise <swise@opengridcomputing.com>
-Date: Thu May 20 15:45:54 2010 -0500
-
- Optimize cq overflow detection.
-
- 1) save the timestamp flit in the cq when we consume a CQE
-
- 2) always compare the saved flit with the previous entry flit when reading
- the next CQE entry. If the flits don't compare, then we've overflowed.
-
- Signed-off-by: Steve Wise <swise@opengridcomputing.com>
-
-commit 0c0cfbdbeb32548994d94a6278c74e2a4f11d9ba
-Author: Steve Wise <swise@opengridcomputing.com>
-Date: Thu May 6 17:57:56 2010 -0500
-
- Spin release 1.0.1.
-
- Signed-off-by: Steve Wise <swise@opengridcomputing.com>
-
-commit 5b9ebdfbcd6df0f02375717aff20400ac33dc47f
-Author: Steve Wise <swise@opengridcomputing.com>
-Date: Thu May 6 17:34:07 2010 -0500
-
- Update code with new t4fw interface.
-
- Signed-off-by: Steve Wise <swise@opengridcomputing.com>
-
-commit 0116d75d8dcc2f4018d0c0074728ca7d127a5065
-Author: Steve Wise <swise@opengridcomputing.com>
-Date: Thu May 6 17:32:10 2010 -0500
-
- Refresh t4fw-interface.h
-
- Signed-off-by: Steve Wise <swise@opengridcomputing.com>
-
-commit ad7a3f8dea2873a3a600859cfe8eb10ad979ddb1
-Author: Steve Wise <swise@opengridcomputing.com>
-Date: Thu May 6 17:30:42 2010 -0500
-
- Avoid CQ arm overflows.
-
- There are 2 limits that need to be taken into account when arming the CQ.
- 1) the GTS register limits the delta idx to <= M_CIDXINC.
- 2) T4 HW limits it to < cq size.
-
- Update t4_arm_cq() to account for these limits.
-
-commit 2905808680aad82b4f295850551bbe15711c2f42
-Author: Steve Wise <swise@opengridcomputing.com>
-Date: Thu May 6 17:30:12 2010 -0500
-
- Poll fixes.
-
- - when synthesizing CQEs for the SWCQ, always use SQ QID.
- - when flushing, ignore target side read response errors.
-
- Signed-off-by: Steve Wise <swise@opengridcomputing.com>
-
-commit 7a7962e856eb606e25a1529bc7f2945e639042b7
-Author: Steve Wise <swise@opengridcomputing.com>
-Date: Thu May 6 17:24:07 2010 -0500
-
- Fix CQ overflow detection.
-
- CQ overflow detection needs to read the gen bit and the timestamp in
- one read operation. Otherwise false overflows can result.
-
- Signed-off-by: Steve Wise <swise@opengridcomputing.com>
-
-commit 5ca340c298c61c9019d8593ee7acdbda93fdd498
-Author: Steve Wise <swise@opengridcomputing.com>
-Date: Thu May 6 17:23:53 2010 -0500
-
- libcxgb3: create_read_req_cqe() needs to swap read length.
-
- Signed-off-by: Steve Wise <swise@opengridcomputing.com>
-
-commit 9bd1e60d3aea10dbe7cb9920363e485b845d85a3
-Author: Steve Wise <swise@opengridcomputing.com>
-Date: Wed Apr 14 10:36:41 2010 -0500
-
- Refresh t4fw_interface.h
-
- Signed-off-by: Steve Wise <swise@opengridcomputing.com>
-
-commit d6e6ae69be5edffc566178e1b7e6402d61a5a786
-Author: Steve Wise <swise@opengridcomputing.com>
-Date: Fri Apr 2 16:01:31 2010 -0500
-
- Add libcxgb4 files.
-
- Signed-off-by: Steve Wise <swise@opengridcomputing.com>
diff --git a/contrib/ofed/libcxgb4/Makefile b/contrib/ofed/libcxgb4/Makefile
new file mode 100644
index 0000000..98196ea
--- /dev/null
+++ b/contrib/ofed/libcxgb4/Makefile
@@ -0,0 +1,19 @@
+# $FreeBSD$
+
+.PATH: ${.CURDIR}
+
+SHLIBDIR?= /usr/lib
+LIB= cxgb4
+SHLIB_MAJOR= 1
+MK_PROFILE= no
+
+SRCS= \
+cq.c \
+dev.c \
+qp.c \
+verbs.c
+
+LIBADD= ibverbs pthread
+CFLAGS+= -I${.CURDIR}
+
+.include <bsd.lib.mk>
diff --git a/contrib/ofed/libcxgb4/README b/contrib/ofed/libcxgb4/README
deleted file mode 100644
index 5f73aef..0000000
--- a/contrib/ofed/libcxgb4/README
+++ /dev/null
@@ -1,19 +0,0 @@
-Introduction
-============
-
-libcxgb4 is a userspace driver for the Chelsio T5 iWARP RNICs. It works
-as a plug-in module for libibverbs that allows programs to use Chelsio
-RNICs directly from userspace. See the libibverbs package for more
-information.
-
-Using libcxgb4
-===================
-
-libcxgb4 will be loaded and used automatically by programs linked with
-libibverbs. The iw_cxgbe kernel module must be loaded for Chelsio RNIC
-devices to be detected and used.
-
-Supported Hardware
-==================
-
-libcxgb4 supports the Chelsio T5 family of adapters.
diff --git a/contrib/ofed/libcxgb4/config.h b/contrib/ofed/libcxgb4/config.h
new file mode 100644
index 0000000..5479189
--- /dev/null
+++ b/contrib/ofed/libcxgb4/config.h
@@ -0,0 +1,6 @@
+/* $FreeBSD$ */
+
+#define ENODATA ECONNREFUSED
+#define likely(x) __predict_true(x)
+#define unlikely(x) __predict_false(x)
+
diff --git a/contrib/ofed/libcxgb4/cq.c b/contrib/ofed/libcxgb4/cq.c
new file mode 100644
index 0000000..1b79cb5
--- /dev/null
+++ b/contrib/ofed/libcxgb4/cq.c
@@ -0,0 +1,750 @@
+/*
+ * Copyright (c) 2006-2016 Chelsio, Inc. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+#include <config.h>
+
+#include <stdio.h>
+#include <syslog.h>
+#include <pthread.h>
+#include <sys/errno.h>
+#include <infiniband/opcode.h>
+#include "libcxgb4.h"
+#include "cxgb4-abi.h"
+
+static void insert_recv_cqe(struct t4_wq *wq, struct t4_cq *cq)
+{
+ struct t4_cqe cqe;
+
+ PDBG("%s wq %p cq %p sw_cidx %u sw_pidx %u\n", __func__,
+ wq, cq, cq->sw_cidx, cq->sw_pidx);
+ memset(&cqe, 0, sizeof(cqe));
+ cqe.header = htobe32(V_CQE_STATUS(T4_ERR_SWFLUSH) |
+ V_CQE_OPCODE(FW_RI_SEND) |
+ V_CQE_TYPE(0) |
+ V_CQE_SWCQE(1) |
+ V_CQE_QPID(wq->sq.qid));
+ cqe.bits_type_ts = htobe64(V_CQE_GENBIT((u64)cq->gen));
+ cq->sw_queue[cq->sw_pidx] = cqe;
+ t4_swcq_produce(cq);
+}
+
+int c4iw_flush_rq(struct t4_wq *wq, struct t4_cq *cq, int count)
+{
+ int flushed = 0;
+ int in_use = wq->rq.in_use - count;
+
+ BUG_ON(in_use < 0);
+ PDBG("%s wq %p cq %p rq.in_use %u skip count %u\n", __func__,
+ wq, cq, wq->rq.in_use, count);
+ while (in_use--) {
+ insert_recv_cqe(wq, cq);
+ flushed++;
+ }
+ return flushed;
+}
+
+static void insert_sq_cqe(struct t4_wq *wq, struct t4_cq *cq,
+ struct t4_swsqe *swcqe)
+{
+ struct t4_cqe cqe;
+
+ PDBG("%s wq %p cq %p sw_cidx %u sw_pidx %u\n", __func__,
+ wq, cq, cq->sw_cidx, cq->sw_pidx);
+ memset(&cqe, 0, sizeof(cqe));
+ cqe.header = htobe32(V_CQE_STATUS(T4_ERR_SWFLUSH) |
+ V_CQE_OPCODE(swcqe->opcode) |
+ V_CQE_TYPE(1) |
+ V_CQE_SWCQE(1) |
+ V_CQE_QPID(wq->sq.qid));
+ CQE_WRID_SQ_IDX(&cqe) = swcqe->idx;
+ cqe.bits_type_ts = htobe64(V_CQE_GENBIT((u64)cq->gen));
+ cq->sw_queue[cq->sw_pidx] = cqe;
+ t4_swcq_produce(cq);
+}
+
+static void advance_oldest_read(struct t4_wq *wq);
+
+void c4iw_flush_sq(struct c4iw_qp *qhp)
+{
+ unsigned short flushed = 0;
+ struct t4_wq *wq = &qhp->wq;
+ struct c4iw_cq *chp = to_c4iw_cq(qhp->ibv_qp.send_cq);
+ struct t4_cq *cq = &chp->cq;
+ int idx;
+ struct t4_swsqe *swsqe;
+
+ if (wq->sq.flush_cidx == -1)
+ wq->sq.flush_cidx = wq->sq.cidx;
+ idx = wq->sq.flush_cidx;
+ BUG_ON(idx >= wq->sq.size);
+ while (idx != wq->sq.pidx) {
+ swsqe = &wq->sq.sw_sq[idx];
+ BUG_ON(swsqe->flushed);
+ swsqe->flushed = 1;
+ insert_sq_cqe(wq, cq, swsqe);
+ if (wq->sq.oldest_read == swsqe) {
+ BUG_ON(swsqe->opcode != FW_RI_READ_REQ);
+ advance_oldest_read(wq);
+ }
+ flushed++;
+ if (++idx == wq->sq.size)
+ idx = 0;
+ }
+ wq->sq.flush_cidx += flushed;
+ if (wq->sq.flush_cidx >= wq->sq.size)
+ wq->sq.flush_cidx -= wq->sq.size;
+}
+
+static void flush_completed_wrs(struct t4_wq *wq, struct t4_cq *cq)
+{
+ struct t4_swsqe *swsqe;
+ unsigned short cidx;
+
+ if (wq->sq.flush_cidx == -1)
+ wq->sq.flush_cidx = wq->sq.cidx;
+ cidx = wq->sq.flush_cidx;
+ BUG_ON(cidx >= wq->sq.size);
+
+ while (cidx != wq->sq.pidx) {
+ swsqe = &wq->sq.sw_sq[cidx];
+ if (!swsqe->signaled) {
+ if (++cidx == wq->sq.size)
+ cidx = 0;
+ } else if (swsqe->complete) {
+
+ BUG_ON(swsqe->flushed);
+
+ /*
+ * Insert this completed cqe into the swcq.
+ */
+ PDBG("%s moving cqe into swcq sq idx %u cq idx %u\n",
+ __func__, cidx, cq->sw_pidx);
+
+ swsqe->cqe.header |= htobe32(V_CQE_SWCQE(1));
+ cq->sw_queue[cq->sw_pidx] = swsqe->cqe;
+ t4_swcq_produce(cq);
+ swsqe->flushed = 1;
+ if (++cidx == wq->sq.size)
+ cidx = 0;
+ wq->sq.flush_cidx = cidx;
+ } else
+ break;
+ }
+}
+
+static void create_read_req_cqe(struct t4_wq *wq, struct t4_cqe *hw_cqe,
+ struct t4_cqe *read_cqe)
+{
+ read_cqe->u.scqe.cidx = wq->sq.oldest_read->idx;
+ read_cqe->len = be32toh(wq->sq.oldest_read->read_len);
+ read_cqe->header = htobe32(V_CQE_QPID(CQE_QPID(hw_cqe)) |
+ V_CQE_SWCQE(SW_CQE(hw_cqe)) |
+ V_CQE_OPCODE(FW_RI_READ_REQ) |
+ V_CQE_TYPE(1));
+ read_cqe->bits_type_ts = hw_cqe->bits_type_ts;
+}
+
+static void advance_oldest_read(struct t4_wq *wq)
+{
+
+ u32 rptr = wq->sq.oldest_read - wq->sq.sw_sq + 1;
+
+ if (rptr == wq->sq.size)
+ rptr = 0;
+ while (rptr != wq->sq.pidx) {
+ wq->sq.oldest_read = &wq->sq.sw_sq[rptr];
+
+ if (wq->sq.oldest_read->opcode == FW_RI_READ_REQ)
+ return;
+ if (++rptr == wq->sq.size)
+ rptr = 0;
+ }
+ wq->sq.oldest_read = NULL;
+}
+
+/*
+ * Move all CQEs from the HWCQ into the SWCQ.
+ * Deal with out-of-order and/or completions that complete
+ * prior unsignalled WRs.
+ */
+void c4iw_flush_hw_cq(struct c4iw_cq *chp)
+{
+ struct t4_cqe *hw_cqe, *swcqe, read_cqe;
+ struct c4iw_qp *qhp;
+ struct t4_swsqe *swsqe;
+ int ret;
+
+ PDBG("%s cqid 0x%x\n", __func__, chp->cq.cqid);
+ ret = t4_next_hw_cqe(&chp->cq, &hw_cqe);
+
+ /*
+ * This logic is similar to poll_cq(), but not quite the same
+ * unfortunately. Need to move pertinent HW CQEs to the SW CQ but
+ * also do any translation magic that poll_cq() normally does.
+ */
+ while (!ret) {
+ qhp = get_qhp(chp->rhp, CQE_QPID(hw_cqe));
+
+ /*
+ * drop CQEs with no associated QP
+ */
+ if (qhp == NULL)
+ goto next_cqe;
+
+ if (CQE_OPCODE(hw_cqe) == FW_RI_TERMINATE)
+ goto next_cqe;
+
+ if (CQE_OPCODE(hw_cqe) == FW_RI_READ_RESP) {
+
+ /*
+ * If we have reached here because of async
+ * event or other error, and have egress error
+ * then drop
+ */
+ if (CQE_TYPE(hw_cqe) == 1) {
+ syslog(LOG_CRIT, "%s: got egress error in \
+ read-response, dropping!\n", __func__);
+ goto next_cqe;
+ }
+
+ /*
+ * drop peer2peer RTR reads.
+ */
+ if (CQE_WRID_STAG(hw_cqe) == 1)
+ goto next_cqe;
+
+ /*
+ * Eat completions for unsignaled read WRs.
+ */
+ if (!qhp->wq.sq.oldest_read->signaled) {
+ advance_oldest_read(&qhp->wq);
+ goto next_cqe;
+ }
+
+ /*
+ * Don't write to the HWCQ, create a new read req CQE
+ * in local memory and move it into the swcq.
+ */
+ create_read_req_cqe(&qhp->wq, hw_cqe, &read_cqe);
+ hw_cqe = &read_cqe;
+ advance_oldest_read(&qhp->wq);
+ }
+
+ /* if its a SQ completion, then do the magic to move all the
+ * unsignaled and now in-order completions into the swcq.
+ */
+ if (SQ_TYPE(hw_cqe)) {
+ int idx = CQE_WRID_SQ_IDX(hw_cqe);
+
+ BUG_ON(idx >= qhp->wq.sq.size);
+ swsqe = &qhp->wq.sq.sw_sq[idx];
+ swsqe->cqe = *hw_cqe;
+ swsqe->complete = 1;
+ flush_completed_wrs(&qhp->wq, &chp->cq);
+ } else {
+ swcqe = &chp->cq.sw_queue[chp->cq.sw_pidx];
+ *swcqe = *hw_cqe;
+ swcqe->header |= htobe32(V_CQE_SWCQE(1));
+ t4_swcq_produce(&chp->cq);
+ }
+next_cqe:
+ t4_hwcq_consume(&chp->cq);
+ ret = t4_next_hw_cqe(&chp->cq, &hw_cqe);
+ }
+}
+
+static int cqe_completes_wr(struct t4_cqe *cqe, struct t4_wq *wq)
+{
+ if (CQE_OPCODE(cqe) == FW_RI_TERMINATE)
+ return 0;
+
+ if ((CQE_OPCODE(cqe) == FW_RI_RDMA_WRITE) && RQ_TYPE(cqe))
+ return 0;
+
+ if ((CQE_OPCODE(cqe) == FW_RI_READ_RESP) && SQ_TYPE(cqe))
+ return 0;
+
+ if (CQE_SEND_OPCODE(cqe) && RQ_TYPE(cqe) && t4_rq_empty(wq))
+ return 0;
+ return 1;
+}
+
+void c4iw_count_rcqes(struct t4_cq *cq, struct t4_wq *wq, int *count)
+{
+ struct t4_cqe *cqe;
+ u32 ptr;
+
+ *count = 0;
+ ptr = cq->sw_cidx;
+ BUG_ON(ptr >= cq->size);
+ while (ptr != cq->sw_pidx) {
+ cqe = &cq->sw_queue[ptr];
+ if (RQ_TYPE(cqe) && (CQE_OPCODE(cqe) != FW_RI_READ_RESP) &&
+ (CQE_QPID(cqe) == wq->sq.qid) && cqe_completes_wr(cqe, wq))
+ (*count)++;
+ if (++ptr == cq->size)
+ ptr = 0;
+ }
+ PDBG("%s cq %p count %d\n", __func__, cq, *count);
+}
+
+static void dump_cqe(void *arg)
+{
+ u64 *p = arg;
+ syslog(LOG_NOTICE, "cxgb4 err cqe %016llx %016llx %016llx %016llx\n",
+ (long long)be64toh(p[0]),
+ (long long)be64toh(p[1]),
+ (long long)be64toh(p[2]),
+ (long long)be64toh(p[3]));
+}
+
+/*
+ * poll_cq
+ *
+ * Caller must:
+ * check the validity of the first CQE,
+ * supply the wq assicated with the qpid.
+ *
+ * credit: cq credit to return to sge.
+ * cqe_flushed: 1 iff the CQE is flushed.
+ * cqe: copy of the polled CQE.
+ *
+ * return value:
+ * 0 CQE returned ok.
+ * -EAGAIN CQE skipped, try again.
+ * -EOVERFLOW CQ overflow detected.
+ */
+static int poll_cq(struct t4_wq *wq, struct t4_cq *cq, struct t4_cqe *cqe,
+ u8 *cqe_flushed, u64 *cookie, u32 *credit)
+{
+ int ret = 0;
+ struct t4_cqe *hw_cqe, read_cqe;
+
+ *cqe_flushed = 0;
+ *credit = 0;
+
+ ret = t4_next_cqe(cq, &hw_cqe);
+ if (ret)
+ return ret;
+
+ PDBG("%s CQE OVF %u qpid 0x%0x genbit %u type %u status 0x%0x"
+ " opcode 0x%0x len 0x%0x wrid_hi_stag 0x%x wrid_low_msn 0x%x\n",
+ __func__, CQE_OVFBIT(hw_cqe), CQE_QPID(hw_cqe),
+ CQE_GENBIT(hw_cqe), CQE_TYPE(hw_cqe), CQE_STATUS(hw_cqe),
+ CQE_OPCODE(hw_cqe), CQE_LEN(hw_cqe), CQE_WRID_HI(hw_cqe),
+ CQE_WRID_LOW(hw_cqe));
+
+ /*
+ * skip cqe's not affiliated with a QP.
+ */
+ if (wq == NULL) {
+ ret = -EAGAIN;
+ goto skip_cqe;
+ }
+
+ /*
+ * Gotta tweak READ completions:
+ * 1) the cqe doesn't contain the sq_wptr from the wr.
+ * 2) opcode not reflected from the wr.
+ * 3) read_len not reflected from the wr.
+ * 4) T4 HW (for now) inserts target read response failures which
+ * need to be skipped.
+ */
+ if (CQE_OPCODE(hw_cqe) == FW_RI_READ_RESP) {
+
+ /*
+ * If we have reached here because of async
+ * event or other error, and have egress error
+ * then drop
+ */
+ if (CQE_TYPE(hw_cqe) == 1) {
+ syslog(LOG_CRIT, "%s: got egress error in \
+ read-response, dropping!\n", __func__);
+ if (CQE_STATUS(hw_cqe))
+ t4_set_wq_in_error(wq);
+ ret = -EAGAIN;
+ goto skip_cqe;
+ }
+
+ /*
+ * If this is an unsolicited read response, then the read
+ * was generated by the kernel driver as part of peer-2-peer
+ * connection setup, or a target read response failure.
+ * So skip the completion.
+ */
+ if (CQE_WRID_STAG(hw_cqe) == 1) {
+ if (CQE_STATUS(hw_cqe))
+ t4_set_wq_in_error(wq);
+ ret = -EAGAIN;
+ goto skip_cqe;
+ }
+
+ /*
+ * Eat completions for unsignaled read WRs.
+ */
+ if (!wq->sq.oldest_read->signaled) {
+ advance_oldest_read(wq);
+ ret = -EAGAIN;
+ goto skip_cqe;
+ }
+
+ /*
+ * Don't write to the HWCQ, so create a new read req CQE
+ * in local memory.
+ */
+ create_read_req_cqe(wq, hw_cqe, &read_cqe);
+ hw_cqe = &read_cqe;
+ advance_oldest_read(wq);
+ }
+
+ if (CQE_OPCODE(hw_cqe) == FW_RI_TERMINATE) {
+ ret = -EAGAIN;
+ goto skip_cqe;
+ }
+
+ if (CQE_STATUS(hw_cqe) || t4_wq_in_error(wq)) {
+ *cqe_flushed = (CQE_STATUS(hw_cqe) == T4_ERR_SWFLUSH);
+ wq->error = 1;
+
+ if (!*cqe_flushed && CQE_STATUS(hw_cqe))
+ dump_cqe(hw_cqe);
+
+ BUG_ON((cqe_flushed == 0) && !SW_CQE(hw_cqe));
+ goto proc_cqe;
+ }
+
+ /*
+ * RECV completion.
+ */
+ if (RQ_TYPE(hw_cqe)) {
+
+ /*
+ * HW only validates 4 bits of MSN. So we must validate that
+ * the MSN in the SEND is the next expected MSN. If its not,
+ * then we complete this with T4_ERR_MSN and mark the wq in
+ * error.
+ */
+
+ if (t4_rq_empty(wq)) {
+ t4_set_wq_in_error(wq);
+ ret = -EAGAIN;
+ goto skip_cqe;
+ }
+ if (unlikely((CQE_WRID_MSN(hw_cqe) != (wq->rq.msn)))) {
+ t4_set_wq_in_error(wq);
+ hw_cqe->header |= htobe32(V_CQE_STATUS(T4_ERR_MSN));
+ goto proc_cqe;
+ }
+ goto proc_cqe;
+ }
+
+ /*
+ * If we get here its a send completion.
+ *
+ * Handle out of order completion. These get stuffed
+ * in the SW SQ. Then the SW SQ is walked to move any
+ * now in-order completions into the SW CQ. This handles
+ * 2 cases:
+ * 1) reaping unsignaled WRs when the first subsequent
+ * signaled WR is completed.
+ * 2) out of order read completions.
+ */
+ if (!SW_CQE(hw_cqe) && (CQE_WRID_SQ_IDX(hw_cqe) != wq->sq.cidx)) {
+ struct t4_swsqe *swsqe;
+ int idx = CQE_WRID_SQ_IDX(hw_cqe);
+
+ PDBG("%s out of order completion going in sw_sq at idx %u\n",
+ __func__, idx);
+ BUG_ON(idx >= wq->sq.size);
+ swsqe = &wq->sq.sw_sq[idx];
+ swsqe->cqe = *hw_cqe;
+ swsqe->complete = 1;
+ ret = -EAGAIN;
+ goto flush_wq;
+ }
+
+proc_cqe:
+ *cqe = *hw_cqe;
+
+ /*
+ * Reap the associated WR(s) that are freed up with this
+ * completion.
+ */
+ if (SQ_TYPE(hw_cqe)) {
+ int idx = CQE_WRID_SQ_IDX(hw_cqe);
+ BUG_ON(idx >= wq->sq.size);
+
+ /*
+ * Account for any unsignaled completions completed by
+ * this signaled completion. In this case, cidx points
+ * to the first unsignaled one, and idx points to the
+ * signaled one. So adjust in_use based on this delta.
+ * if this is not completing any unsigned wrs, then the
+ * delta will be 0. Handle wrapping also!
+ */
+ if (idx < wq->sq.cidx)
+ wq->sq.in_use -= wq->sq.size + idx - wq->sq.cidx;
+ else
+ wq->sq.in_use -= idx - wq->sq.cidx;
+ BUG_ON(wq->sq.in_use <= 0 || wq->sq.in_use >= wq->sq.size);
+
+ wq->sq.cidx = (u16)idx;
+ PDBG("%s completing sq idx %u\n", __func__, wq->sq.cidx);
+ *cookie = wq->sq.sw_sq[wq->sq.cidx].wr_id;
+ t4_sq_consume(wq);
+ } else {
+ PDBG("%s completing rq idx %u\n", __func__, wq->rq.cidx);
+ BUG_ON(wq->rq.cidx >= wq->rq.size);
+ *cookie = wq->rq.sw_rq[wq->rq.cidx].wr_id;
+ BUG_ON(t4_rq_empty(wq));
+ t4_rq_consume(wq);
+ goto skip_cqe;
+ }
+
+flush_wq:
+ /*
+ * Flush any completed cqes that are now in-order.
+ */
+ flush_completed_wrs(wq, cq);
+
+skip_cqe:
+ if (SW_CQE(hw_cqe)) {
+ PDBG("%s cq %p cqid 0x%x skip sw cqe cidx %u\n",
+ __func__, cq, cq->cqid, cq->sw_cidx);
+ t4_swcq_consume(cq);
+ } else {
+ PDBG("%s cq %p cqid 0x%x skip hw cqe cidx %u\n",
+ __func__, cq, cq->cqid, cq->cidx);
+ t4_hwcq_consume(cq);
+ }
+ return ret;
+}
+
+/*
+ * Get one cq entry from c4iw and map it to openib.
+ *
+ * Returns:
+ * 0 cqe returned
+ * -ENODATA EMPTY;
+ * -EAGAIN caller must try again
+ * any other -errno fatal error
+ */
+static int c4iw_poll_cq_one(struct c4iw_cq *chp, struct ibv_wc *wc)
+{
+ struct c4iw_qp *qhp = NULL;
+ struct t4_cqe cqe, *rd_cqe;
+ struct t4_wq *wq;
+ u32 credit = 0;
+ u8 cqe_flushed;
+ u64 cookie = 0;
+ int ret;
+
+ ret = t4_next_cqe(&chp->cq, &rd_cqe);
+
+ if (ret) {
+#ifdef STALL_DETECTION
+ if (ret == -ENODATA && stall_to && !chp->dumped) {
+ struct timeval t;
+
+ gettimeofday(&t, NULL);
+ if ((t.tv_sec - chp->time.tv_sec) > stall_to) {
+ dump_state();
+ chp->dumped = 1;
+ }
+ }
+#endif
+ return ret;
+ }
+
+#ifdef STALL_DETECTION
+ gettimeofday(&chp->time, NULL);
+#endif
+
+ qhp = get_qhp(chp->rhp, CQE_QPID(rd_cqe));
+ if (!qhp)
+ wq = NULL;
+ else {
+ pthread_spin_lock(&qhp->lock);
+ wq = &(qhp->wq);
+ }
+ ret = poll_cq(wq, &(chp->cq), &cqe, &cqe_flushed, &cookie, &credit);
+ if (ret)
+ goto out;
+
+ INC_STAT(cqe);
+ wc->wr_id = cookie;
+ wc->qp_num = qhp->wq.sq.qid;
+ wc->vendor_err = CQE_STATUS(&cqe);
+ wc->wc_flags = 0;
+
+ PDBG("%s qpid 0x%x type %d opcode %d status 0x%x wrid hi 0x%x "
+ "lo 0x%x cookie 0x%llx\n", __func__,
+ CQE_QPID(&cqe), CQE_TYPE(&cqe),
+ CQE_OPCODE(&cqe), CQE_STATUS(&cqe), CQE_WRID_HI(&cqe),
+ CQE_WRID_LOW(&cqe), (unsigned long long)cookie);
+
+ if (CQE_TYPE(&cqe) == 0) {
+ if (!CQE_STATUS(&cqe))
+ wc->byte_len = CQE_LEN(&cqe);
+ else
+ wc->byte_len = 0;
+ wc->opcode = IBV_WC_RECV;
+ } else {
+ switch (CQE_OPCODE(&cqe)) {
+ case FW_RI_RDMA_WRITE:
+ wc->opcode = IBV_WC_RDMA_WRITE;
+ break;
+ case FW_RI_READ_REQ:
+ wc->opcode = IBV_WC_RDMA_READ;
+ wc->byte_len = CQE_LEN(&cqe);
+ break;
+ case FW_RI_SEND:
+ case FW_RI_SEND_WITH_SE:
+ case FW_RI_SEND_WITH_INV:
+ case FW_RI_SEND_WITH_SE_INV:
+ wc->opcode = IBV_WC_SEND;
+ break;
+ case FW_RI_BIND_MW:
+ wc->opcode = IBV_WC_BIND_MW;
+ break;
+ default:
+ PDBG("Unexpected opcode %d "
+ "in the CQE received for QPID=0x%0x\n",
+ CQE_OPCODE(&cqe), CQE_QPID(&cqe));
+ ret = -EINVAL;
+ goto out;
+ }
+ }
+
+ if (cqe_flushed)
+ wc->status = IBV_WC_WR_FLUSH_ERR;
+ else {
+
+ switch (CQE_STATUS(&cqe)) {
+ case T4_ERR_SUCCESS:
+ wc->status = IBV_WC_SUCCESS;
+ break;
+ case T4_ERR_STAG:
+ wc->status = IBV_WC_LOC_ACCESS_ERR;
+ break;
+ case T4_ERR_PDID:
+ wc->status = IBV_WC_LOC_PROT_ERR;
+ break;
+ case T4_ERR_QPID:
+ case T4_ERR_ACCESS:
+ wc->status = IBV_WC_LOC_ACCESS_ERR;
+ break;
+ case T4_ERR_WRAP:
+ wc->status = IBV_WC_GENERAL_ERR;
+ break;
+ case T4_ERR_BOUND:
+ wc->status = IBV_WC_LOC_LEN_ERR;
+ break;
+ case T4_ERR_INVALIDATE_SHARED_MR:
+ case T4_ERR_INVALIDATE_MR_WITH_MW_BOUND:
+ wc->status = IBV_WC_MW_BIND_ERR;
+ break;
+ case T4_ERR_CRC:
+ case T4_ERR_MARKER:
+ case T4_ERR_PDU_LEN_ERR:
+ case T4_ERR_OUT_OF_RQE:
+ case T4_ERR_DDP_VERSION:
+ case T4_ERR_RDMA_VERSION:
+ case T4_ERR_DDP_QUEUE_NUM:
+ case T4_ERR_MSN:
+ case T4_ERR_TBIT:
+ case T4_ERR_MO:
+ case T4_ERR_MSN_RANGE:
+ case T4_ERR_IRD_OVERFLOW:
+ case T4_ERR_OPCODE:
+ case T4_ERR_INTERNAL_ERR:
+ wc->status = IBV_WC_FATAL_ERR;
+ break;
+ case T4_ERR_SWFLUSH:
+ wc->status = IBV_WC_WR_FLUSH_ERR;
+ break;
+ default:
+ PDBG("Unexpected cqe_status 0x%x for QPID=0x%0x\n",
+ CQE_STATUS(&cqe), CQE_QPID(&cqe));
+ wc->status = IBV_WC_FATAL_ERR;
+ }
+ }
+ if (wc->status && wc->status != IBV_WC_WR_FLUSH_ERR)
+ syslog(LOG_NOTICE, "cxgb4 app err cqid %u qpid %u "
+ "type %u opcode %u status 0x%x\n",
+ chp->cq.cqid, CQE_QPID(&cqe), CQE_TYPE(&cqe),
+ CQE_OPCODE(&cqe), CQE_STATUS(&cqe));
+out:
+ if (wq)
+ pthread_spin_unlock(&qhp->lock);
+ return ret;
+}
+
+int c4iw_poll_cq(struct ibv_cq *ibcq, int num_entries, struct ibv_wc *wc)
+{
+ struct c4iw_cq *chp;
+ int npolled;
+ int err = 0;
+
+ chp = to_c4iw_cq(ibcq);
+
+ if (t4_cq_in_error(&chp->cq)) {
+ t4_reset_cq_in_error(&chp->cq);
+ c4iw_flush_qps(chp->rhp);
+ }
+
+ if (!num_entries)
+ return t4_cq_notempty(&chp->cq);
+
+ pthread_spin_lock(&chp->lock);
+ for (npolled = 0; npolled < num_entries; ++npolled) {
+ do {
+ err = c4iw_poll_cq_one(chp, wc + npolled);
+ } while (err == -EAGAIN);
+ if (err)
+ break;
+ }
+ pthread_spin_unlock(&chp->lock);
+ return !err || err == -ENODATA ? npolled : err;
+}
+
+int c4iw_arm_cq(struct ibv_cq *ibcq, int solicited)
+{
+ struct c4iw_cq *chp;
+ int ret;
+
+ INC_STAT(arm);
+ chp = to_c4iw_cq(ibcq);
+ pthread_spin_lock(&chp->lock);
+ ret = t4_arm_cq(&chp->cq, solicited);
+ pthread_spin_unlock(&chp->lock);
+ return ret;
+}
diff --git a/contrib/ofed/libcxgb4/cxgb4-abi.h b/contrib/ofed/libcxgb4/cxgb4-abi.h
new file mode 100644
index 0000000..91e68d5
--- /dev/null
+++ b/contrib/ofed/libcxgb4/cxgb4-abi.h
@@ -0,0 +1,96 @@
+/*
+ * Copyright (c) 2006-2016 Chelsio, Inc. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+#ifndef IWCH_ABI_H
+#define IWCH_ABI_H
+
+#include <stdint.h>
+#include <infiniband/kern-abi.h>
+
+struct c4iw_alloc_ucontext_resp {
+ struct ibv_get_context_resp ibv_resp;
+ __u64 status_page_key;
+ __u32 status_page_size;
+ __u32 reserved;
+};
+
+struct c4iw_alloc_pd_resp {
+ struct ibv_alloc_pd_resp ibv_resp;
+ uint32_t pdid;
+};
+
+struct c4iw_create_cq_resp {
+ struct ibv_create_cq_resp ibv_resp;
+ __u64 key;
+ __u64 gts_key;
+ __u64 memsize;
+ __u32 cqid;
+ __u32 size;
+ __u32 qid_mask;
+ __u32 reserved;
+};
+
+enum {
+ C4IW_QPF_ONCHIP = (1<<0),
+};
+
+struct c4iw_create_qp_resp_v0 {
+ struct ibv_create_qp_resp ibv_resp;
+ __u64 sq_key;
+ __u64 rq_key;
+ __u64 sq_db_gts_key;
+ __u64 rq_db_gts_key;
+ __u64 sq_memsize;
+ __u64 rq_memsize;
+ __u32 sqid;
+ __u32 rqid;
+ __u32 sq_size;
+ __u32 rq_size;
+ __u32 qid_mask;
+};
+
+struct c4iw_create_qp_resp {
+ struct ibv_create_qp_resp ibv_resp;
+ __u64 ma_sync_key;
+ __u64 sq_key;
+ __u64 rq_key;
+ __u64 sq_db_gts_key;
+ __u64 rq_db_gts_key;
+ __u64 sq_memsize;
+ __u64 rq_memsize;
+ __u32 sqid;
+ __u32 rqid;
+ __u32 sq_size;
+ __u32 rq_size;
+ __u32 qid_mask;
+ __u32 flags;
+};
+#endif /* IWCH_ABI_H */
diff --git a/contrib/ofed/libcxgb4/cxgb4.driver b/contrib/ofed/libcxgb4/cxgb4.driver
deleted file mode 100644
index 0ee45f1..0000000
--- a/contrib/ofed/libcxgb4/cxgb4.driver
+++ /dev/null
@@ -1 +0,0 @@
-driver cxgb4
diff --git a/contrib/ofed/libcxgb4/dev.c b/contrib/ofed/libcxgb4/dev.c
new file mode 100644
index 0000000..1e48478
--- /dev/null
+++ b/contrib/ofed/libcxgb4/dev.c
@@ -0,0 +1,579 @@
+/*
+ * Copyright (c) 2006-2016 Chelsio, Inc. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+#include <config.h>
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <errno.h>
+#include <sys/mman.h>
+#include <pthread.h>
+#include <string.h>
+#include <signal.h>
+#include <stdbool.h>
+
+#include "libcxgb4.h"
+#include "cxgb4-abi.h"
+
+#define PCI_VENDOR_ID_CHELSIO 0x1425
+
+/*
+ * Macros needed to support the PCI Device ID Table ...
+ */
+#define CH_PCI_DEVICE_ID_TABLE_DEFINE_BEGIN \
+ static struct { \
+ unsigned vendor; \
+ unsigned device; \
+ } hca_table[] = {
+
+#define CH_PCI_DEVICE_ID_FUNCTION \
+ 0x4
+
+#define CH_PCI_ID_TABLE_ENTRY(__DeviceID) \
+ { \
+ .vendor = PCI_VENDOR_ID_CHELSIO, \
+ .device = (__DeviceID), \
+ }
+
+#define CH_PCI_DEVICE_ID_TABLE_DEFINE_END \
+ }
+
+#include "t4_chip_type.h"
+#include "t4_pci_id_tbl.h"
+
+unsigned long c4iw_page_size;
+unsigned long c4iw_page_shift;
+unsigned long c4iw_page_mask;
+int ma_wr;
+int t5_en_wc = 1;
+
+static TAILQ_HEAD(,c4iw_dev) devices = TAILQ_HEAD_INITIALIZER(devices);
+
+static struct ibv_context_ops c4iw_ctx_ops = {
+ .query_device = c4iw_query_device,
+ .query_port = c4iw_query_port,
+ .alloc_pd = c4iw_alloc_pd,
+ .dealloc_pd = c4iw_free_pd,
+ .reg_mr = c4iw_reg_mr,
+ .dereg_mr = c4iw_dereg_mr,
+ .create_cq = c4iw_create_cq,
+ .resize_cq = c4iw_resize_cq,
+ .destroy_cq = c4iw_destroy_cq,
+ .create_srq = c4iw_create_srq,
+ .modify_srq = c4iw_modify_srq,
+ .destroy_srq = c4iw_destroy_srq,
+ .create_qp = c4iw_create_qp,
+ .modify_qp = c4iw_modify_qp,
+ .destroy_qp = c4iw_destroy_qp,
+ .query_qp = c4iw_query_qp,
+ .create_ah = c4iw_create_ah,
+ .destroy_ah = c4iw_destroy_ah,
+ .attach_mcast = c4iw_attach_mcast,
+ .detach_mcast = c4iw_detach_mcast,
+ .post_srq_recv = c4iw_post_srq_recv,
+ .req_notify_cq = c4iw_arm_cq,
+};
+
+static struct ibv_context *c4iw_alloc_context(struct ibv_device *ibdev,
+ int cmd_fd)
+{
+ struct c4iw_context *context;
+ struct ibv_get_context cmd;
+ struct c4iw_alloc_ucontext_resp resp;
+ struct c4iw_dev *rhp = to_c4iw_dev(ibdev);
+ struct ibv_query_device qcmd;
+ uint64_t raw_fw_ver;
+ struct ibv_device_attr attr;
+
+ context = malloc(sizeof *context);
+ if (!context)
+ return NULL;
+
+ memset(context, 0, sizeof *context);
+ context->ibv_ctx.cmd_fd = cmd_fd;
+
+ resp.status_page_size = 0;
+ resp.reserved = 0;
+ if (ibv_cmd_get_context(&context->ibv_ctx, &cmd, sizeof cmd,
+ &resp.ibv_resp, sizeof resp))
+ goto err_free;
+
+ if (resp.reserved)
+ PDBG("%s c4iw_alloc_ucontext_resp reserved field modified by kernel\n",
+ __FUNCTION__);
+
+ context->status_page_size = resp.status_page_size;
+ if (resp.status_page_size) {
+ context->status_page = mmap(NULL, resp.status_page_size,
+ PROT_READ, MAP_SHARED, cmd_fd,
+ resp.status_page_key);
+ if (context->status_page == MAP_FAILED)
+ goto err_free;
+ }
+
+ context->ibv_ctx.device = ibdev;
+ context->ibv_ctx.ops = c4iw_ctx_ops;
+
+ switch (rhp->chip_version) {
+ case CHELSIO_T6:
+ PDBG("%s T6/T5/T4 device\n", __FUNCTION__);
+ case CHELSIO_T5:
+ PDBG("%s T5/T4 device\n", __FUNCTION__);
+ case CHELSIO_T4:
+ PDBG("%s T4 device\n", __FUNCTION__);
+ context->ibv_ctx.ops.async_event = c4iw_async_event;
+ context->ibv_ctx.ops.post_send = c4iw_post_send;
+ context->ibv_ctx.ops.post_recv = c4iw_post_receive;
+ context->ibv_ctx.ops.poll_cq = c4iw_poll_cq;
+ context->ibv_ctx.ops.req_notify_cq = c4iw_arm_cq;
+ break;
+ default:
+ PDBG("%s unknown hca type %d\n", __FUNCTION__,
+ rhp->chip_version);
+ goto err_unmap;
+ break;
+ }
+
+ if (!rhp->mmid2ptr) {
+ int ret;
+
+ ret = ibv_cmd_query_device(&context->ibv_ctx, &attr, &raw_fw_ver, &qcmd,
+ sizeof qcmd);
+ if (ret)
+ goto err_unmap;
+ rhp->max_mr = attr.max_mr;
+ rhp->mmid2ptr = calloc(attr.max_mr, sizeof(void *));
+ if (!rhp->mmid2ptr) {
+ goto err_unmap;
+ }
+ if (rhp->abi_version < 3) {
+ fprintf(stderr, "Warning: iw_cxgb4 driver is of older version"
+ " than libcxgb4:: %d\n", rhp->abi_version);
+ rhp->max_qp = T4_QID_BASE + attr.max_qp;
+ } else {
+ rhp->max_qp = context->status_page->qp_start +
+ context->status_page->qp_size;
+ }
+ rhp->qpid2ptr = calloc(rhp->max_qp, sizeof(void *));
+ if (!rhp->qpid2ptr) {
+ goto err_unmap;
+ }
+ if (rhp->abi_version < 3)
+ rhp->max_cq = T4_QID_BASE + attr.max_cq;
+ else
+ rhp->max_cq = context->status_page->cq_start +
+ context->status_page->cq_size;
+ rhp->cqid2ptr = calloc(rhp->max_cq, sizeof(void *));
+ if (!rhp->cqid2ptr)
+ goto err_unmap;
+
+ /* Disable userspace WC if architecture/adapter does not
+ * support WC.
+ * Note: To forcefully disable WC in kernel driver use the
+ * loader tunable "hw.cxl.write_combine=0"
+ */
+ if (t5_en_wc && !context->status_page->wc_supported) {
+ fprintf(stderr, "iw_cxgb4 driver doesn't support Write "
+ "Combine, so regular DB writes will be used\n");
+ t5_en_wc = 0;
+ }
+ }
+
+ return &context->ibv_ctx;
+
+err_unmap:
+ munmap(context->status_page, context->status_page_size);
+err_free:
+ if (rhp->cqid2ptr)
+ free(rhp->cqid2ptr);
+ if (rhp->qpid2ptr)
+ free(rhp->cqid2ptr);
+ if (rhp->mmid2ptr)
+ free(rhp->cqid2ptr);
+ free(context);
+ return NULL;
+}
+
+static void c4iw_free_context(struct ibv_context *ibctx)
+{
+ struct c4iw_context *context = to_c4iw_context(ibctx);
+
+ if (context->status_page_size)
+ munmap(context->status_page, context->status_page_size);
+ free(context);
+}
+
+static struct verbs_device_ops c4iw_dev_ops = {
+ .alloc_context = c4iw_alloc_context,
+ .free_context = c4iw_free_context
+};
+
+#ifdef STALL_DETECTION
+
+int stall_to;
+
+static void dump_cq(struct c4iw_cq *chp)
+{
+ int i;
+
+ fprintf(stderr,
+ "CQ: %p id %u queue %p cidx 0x%08x sw_queue %p sw_cidx %d sw_pidx %d sw_in_use %d depth %u error %u gen %d "
+ "cidx_inc %d bits_type_ts %016" PRIx64 " notempty %d\n", chp,
+ chp->cq.cqid, chp->cq.queue, chp->cq.cidx,
+ chp->cq.sw_queue, chp->cq.sw_cidx, chp->cq.sw_pidx, chp->cq.sw_in_use,
+ chp->cq.size, chp->cq.error, chp->cq.gen, chp->cq.cidx_inc, be64toh(chp->cq.bits_type_ts),
+ t4_cq_notempty(&chp->cq));
+
+ for (i=0; i < chp->cq.size; i++) {
+ u64 *p = (u64 *)(chp->cq.queue + i);
+
+ fprintf(stderr, "%02x: %016" PRIx64 " %016" PRIx64, i, be64toh(p[0]), be64toh(p[1]));
+ if (i == chp->cq.cidx)
+ fprintf(stderr, " <-- cidx\n");
+ else
+ fprintf(stderr, "\n");
+ p+= 2;
+ fprintf(stderr, "%02x: %016" PRIx64 " %016" PRIx64 "\n", i, be64toh(p[0]), be64toh(p[1]));
+ p+= 2;
+ fprintf(stderr, "%02x: %016" PRIx64 " %016" PRIx64 "\n", i, be64toh(p[0]), be64toh(p[1]));
+ p+= 2;
+ fprintf(stderr, "%02x: %016" PRIx64 " %016" PRIx64 "\n", i, be64toh(p[0]), be64toh(p[1]));
+ p+= 2;
+ }
+}
+
+static void dump_qp(struct c4iw_qp *qhp)
+{
+ int i;
+ int j;
+ struct t4_swsqe *swsqe;
+ struct t4_swrqe *swrqe;
+ u16 cidx, pidx;
+ u64 *p;
+
+ fprintf(stderr,
+ "QP: %p id %u error %d flushed %d qid_mask 0x%x\n"
+ " SQ: id %u queue %p sw_queue %p cidx %u pidx %u in_use %u wq_pidx %u depth %u flags 0x%x flush_cidx %d\n"
+ " RQ: id %u queue %p sw_queue %p cidx %u pidx %u in_use %u depth %u\n",
+ qhp,
+ qhp->wq.sq.qid,
+ qhp->wq.error,
+ qhp->wq.flushed,
+ qhp->wq.qid_mask,
+ qhp->wq.sq.qid,
+ qhp->wq.sq.queue,
+ qhp->wq.sq.sw_sq,
+ qhp->wq.sq.cidx,
+ qhp->wq.sq.pidx,
+ qhp->wq.sq.in_use,
+ qhp->wq.sq.wq_pidx,
+ qhp->wq.sq.size,
+ qhp->wq.sq.flags,
+ qhp->wq.sq.flush_cidx,
+ qhp->wq.rq.qid,
+ qhp->wq.rq.queue,
+ qhp->wq.rq.sw_rq,
+ qhp->wq.rq.cidx,
+ qhp->wq.rq.pidx,
+ qhp->wq.rq.in_use,
+ qhp->wq.rq.size);
+ cidx = qhp->wq.sq.cidx;
+ pidx = qhp->wq.sq.pidx;
+ if (cidx != pidx)
+ fprintf(stderr, "SQ: \n");
+ while (cidx != pidx) {
+ swsqe = &qhp->wq.sq.sw_sq[cidx];
+ fprintf(stderr, "%04u: wr_id %016" PRIx64
+ " sq_wptr %08x read_len %u opcode 0x%x "
+ "complete %u signaled %u cqe %016" PRIx64 " %016" PRIx64 " %016" PRIx64 " %016" PRIx64 "\n",
+ cidx,
+ swsqe->wr_id,
+ swsqe->idx,
+ swsqe->read_len,
+ swsqe->opcode,
+ swsqe->complete,
+ swsqe->signaled,
+ htobe64(((uint64_t *)&swsqe->cqe)[0]),
+ htobe64(((uint64_t *)&swsqe->cqe)[1]),
+ htobe64(((uint64_t *)&swsqe->cqe)[2]),
+ htobe64(((uint64_t *)&swsqe->cqe)[3]));
+ if (++cidx == qhp->wq.sq.size)
+ cidx = 0;
+ }
+
+ fprintf(stderr, "SQ WQ: \n");
+ p = (u64 *)qhp->wq.sq.queue;
+ for (i=0; i < qhp->wq.sq.size * T4_SQ_NUM_SLOTS; i++) {
+ for (j=0; j < T4_EQ_ENTRY_SIZE / 16; j++) {
+ fprintf(stderr, "%04u %016" PRIx64 " %016" PRIx64 " ",
+ i, be64toh(p[0]), be64toh(p[1]));
+ if (j == 0 && i == qhp->wq.sq.wq_pidx)
+ fprintf(stderr, " <-- pidx");
+ fprintf(stderr, "\n");
+ p += 2;
+ }
+ }
+ cidx = qhp->wq.rq.cidx;
+ pidx = qhp->wq.rq.pidx;
+ if (cidx != pidx)
+ fprintf(stderr, "RQ: \n");
+ while (cidx != pidx) {
+ swrqe = &qhp->wq.rq.sw_rq[cidx];
+ fprintf(stderr, "%04u: wr_id %016" PRIx64 "\n",
+ cidx,
+ swrqe->wr_id );
+ if (++cidx == qhp->wq.rq.size)
+ cidx = 0;
+ }
+
+ fprintf(stderr, "RQ WQ: \n");
+ p = (u64 *)qhp->wq.rq.queue;
+ for (i=0; i < qhp->wq.rq.size * T4_RQ_NUM_SLOTS; i++) {
+ for (j=0; j < T4_EQ_ENTRY_SIZE / 16; j++) {
+ fprintf(stderr, "%04u %016" PRIx64 " %016" PRIx64 " ",
+ i, be64toh(p[0]), be64toh(p[1]));
+ if (j == 0 && i == qhp->wq.rq.pidx)
+ fprintf(stderr, " <-- pidx");
+ if (j == 0 && i == qhp->wq.rq.cidx)
+ fprintf(stderr, " <-- cidx");
+ fprintf(stderr, "\n");
+ p+=2;
+ }
+ }
+}
+
+void dump_state(void)
+{
+ struct c4iw_dev *dev;
+ int i;
+
+ fprintf(stderr, "STALL DETECTED:\n");
+ TAILQ_FOREACH(dev, &devices, list) {
+ //pthread_spin_lock(&dev->lock);
+ fprintf(stderr, "Device %s\n", dev->ibv_dev.name);
+ for (i=0; i < dev->max_cq; i++) {
+ if (dev->cqid2ptr[i]) {
+ struct c4iw_cq *chp = dev->cqid2ptr[i];
+ //pthread_spin_lock(&chp->lock);
+ dump_cq(chp);
+ //pthread_spin_unlock(&chp->lock);
+ }
+ }
+ for (i=0; i < dev->max_qp; i++) {
+ if (dev->qpid2ptr[i]) {
+ struct c4iw_qp *qhp = dev->qpid2ptr[i];
+ //pthread_spin_lock(&qhp->lock);
+ dump_qp(qhp);
+ //pthread_spin_unlock(&qhp->lock);
+ }
+ }
+ //pthread_spin_unlock(&dev->lock);
+ }
+ fprintf(stderr, "DUMP COMPLETE:\n");
+ fflush(stderr);
+}
+#endif /* end of STALL_DETECTION */
+
+/*
+ * c4iw_abi_version is used to store ABI for iw_cxgb4 so the user mode library
+ * can know if the driver supports the kernel mode db ringing.
+ */
+int c4iw_abi_version = 1;
+
+static struct verbs_device *cxgb4_driver_init(const char *uverbs_sys_path,
+ int abi_version)
+{
+ char devstr[IBV_SYSFS_PATH_MAX], ibdev[16], value[128], *cp;
+ char dev_str[IBV_SYSFS_PATH_MAX];
+ struct c4iw_dev *dev;
+ unsigned vendor, device, fw_maj, fw_min;
+ int i;
+ char devnum;
+ char ib_param[16];
+
+#ifndef __linux__
+ if (ibv_read_sysfs_file(uverbs_sys_path, "ibdev",
+ ibdev, sizeof ibdev) < 0)
+ return NULL;
+
+ devnum = atoi(&ibdev[5]);
+
+ if (ibdev[0] == 't' && ibdev[1] >= '4' && ibdev[1] <= '6' &&
+ strstr(&ibdev[2], "nex") && devnum >= 0) {
+ snprintf(dev_str, sizeof(dev_str), "/dev/t%cnex/%d", ibdev[1],
+ devnum);
+ } else
+ return NULL;
+
+ if (ibv_read_sysfs_file(dev_str, "\%pnpinfo", value, sizeof value) < 0)
+ return NULL;
+ else {
+ if (strstr(value, "vendor=")) {
+ strncpy(ib_param, strstr(value, "vendor=") +
+ strlen("vendor="), 6);
+ sscanf(ib_param, "%i", &vendor);
+ }
+
+ if (strstr(value, "device=")) {
+ strncpy(ib_param, strstr(value, "device=") +
+ strlen("device="), 6);
+ sscanf(ib_param, "%i", &device);
+ }
+ }
+#else
+ if (ibv_read_sysfs_file(uverbs_sys_path, "device/vendor",
+ value, sizeof value) < 0)
+ return NULL;
+ sscanf(value, "%i", &vendor);
+
+ if (ibv_read_sysfs_file(uverbs_sys_path, "device/device",
+ value, sizeof value) < 0)
+ return NULL;
+ sscanf(value, "%i", &device);
+#endif
+
+ for (i = 0; i < sizeof hca_table / sizeof hca_table[0]; ++i)
+ if (vendor == hca_table[i].vendor &&
+ device == hca_table[i].device)
+ goto found;
+
+ return NULL;
+
+found:
+ c4iw_abi_version = abi_version;
+
+#ifndef __linux__
+ if (ibv_read_sysfs_file(dev_str, "firmware_version",
+ value, sizeof value) < 0)
+ return NULL;
+#else
+ /*
+ * Verify that the firmware major number matches. Major number
+ * mismatches are fatal. Minor number mismatches are tolerated.
+ */
+ if (ibv_read_sysfs_file(uverbs_sys_path, "ibdev",
+ ibdev, sizeof ibdev) < 0)
+ return NULL;
+
+ memset(devstr, 0, sizeof devstr);
+ snprintf(devstr, sizeof devstr, "%s/class/infiniband/%s",
+ ibv_get_sysfs_path(), ibdev);
+ if (ibv_read_sysfs_file(devstr, "fw_ver", value, sizeof value) < 0)
+ return NULL;
+#endif
+
+ cp = strtok(value+1, ".");
+ sscanf(cp, "%i", &fw_maj);
+ cp = strtok(NULL, ".");
+ sscanf(cp, "%i", &fw_min);
+
+ if ((signed int)fw_maj < FW_MAJ) {
+ fprintf(stderr, "libcxgb4: Fatal firmware version mismatch. "
+ "Firmware major number is %u and libcxgb4 needs %u.\n",
+ fw_maj, FW_MAJ);
+ fflush(stderr);
+ return NULL;
+ }
+
+ DBGLOG("libcxgb4");
+
+ if ((signed int)fw_min < FW_MIN) {
+ PDBG("libcxgb4: non-fatal firmware version mismatch. "
+ "Firmware minor number is %u and libcxgb4 needs %u.\n",
+ fw_min, FW_MIN);
+ fflush(stderr);
+ }
+
+ PDBG("%s found vendor %d device %d type %d\n",
+ __FUNCTION__, vendor, device, CHELSIO_CHIP_VERSION(hca_table[i].device >> 8));
+
+ dev = calloc(1, sizeof *dev);
+ if (!dev) {
+ return NULL;
+ }
+
+ pthread_spin_init(&dev->lock, PTHREAD_PROCESS_PRIVATE);
+ dev->ibv_dev.ops = &c4iw_dev_ops;
+ dev->chip_version = CHELSIO_CHIP_VERSION(hca_table[i].device >> 8);
+ dev->abi_version = abi_version;
+
+ PDBG("%s device claimed\n", __FUNCTION__);
+ TAILQ_INSERT_TAIL(&devices, dev, list);
+#ifdef STALL_DETECTION
+{
+ char *c = getenv("CXGB4_STALL_TIMEOUT");
+ if (c) {
+ stall_to = strtol(c, NULL, 0);
+ if (errno || stall_to < 0)
+ stall_to = 0;
+ }
+}
+#endif
+{
+ char *c = getenv("CXGB4_MA_WR");
+ if (c) {
+ ma_wr = strtol(c, NULL, 0);
+ if (ma_wr != 1)
+ ma_wr = 0;
+ }
+}
+{
+ char *c = getenv("T5_ENABLE_WC");
+ if (c) {
+ t5_en_wc = strtol(c, NULL, 0);
+ if (t5_en_wc != 1)
+ t5_en_wc = 0;
+ }
+}
+
+ return &dev->ibv_dev;
+}
+
+static __attribute__((constructor)) void cxgb4_register_driver(void)
+{
+ c4iw_page_size = sysconf(_SC_PAGESIZE);
+ c4iw_page_shift = long_log2(c4iw_page_size);
+ c4iw_page_mask = ~(c4iw_page_size - 1);
+ verbs_register_driver("cxgb4", cxgb4_driver_init);
+}
+
+#ifdef STATS
+void __attribute__ ((destructor)) cs_fini(void);
+void __attribute__ ((destructor)) cs_fini(void)
+{
+ syslog(LOG_NOTICE, "cxgb4 stats - sends %lu recv %lu read %lu "
+ "write %lu arm %lu cqe %lu mr %lu qp %lu cq %lu\n",
+ c4iw_stats.send, c4iw_stats.recv, c4iw_stats.read,
+ c4iw_stats.write, c4iw_stats.arm, c4iw_stats.cqe,
+ c4iw_stats.mr, c4iw_stats.qp, c4iw_stats.cq);
+}
+#endif
diff --git a/contrib/ofed/libcxgb4/libcxgb4.h b/contrib/ofed/libcxgb4/libcxgb4.h
new file mode 100644
index 0000000..b891e8b
--- /dev/null
+++ b/contrib/ofed/libcxgb4/libcxgb4.h
@@ -0,0 +1,267 @@
+/*
+ * Copyright (c) 2006-2016 Chelsio, Inc. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+#ifndef IWCH_H
+#define IWCH_H
+
+#include <pthread.h>
+#include <inttypes.h>
+#include <stddef.h>
+#include <string.h>
+#include <syslog.h>
+#include <sys/errno.h>
+#include <sys/time.h>
+#include <infiniband/driver.h>
+#include <infiniband/udma_barrier.h>
+#include <sys/queue.h>
+#include "t4.h"
+
+extern unsigned long c4iw_page_size;
+extern unsigned long c4iw_page_shift;
+extern unsigned long c4iw_page_mask;
+
+struct c4iw_mr;
+
+struct c4iw_dev {
+ struct verbs_device ibv_dev;
+ unsigned chip_version;
+ int max_mr;
+ struct c4iw_mr **mmid2ptr;
+ int max_qp;
+ struct c4iw_qp **qpid2ptr;
+ int max_cq;
+ struct c4iw_cq **cqid2ptr;
+ pthread_spinlock_t lock;
+ TAILQ_ENTRY(c4iw_dev) list;
+ int abi_version;
+};
+
+static inline int dev_is_t6(struct c4iw_dev *dev)
+{
+ return dev->chip_version == CHELSIO_T6;
+}
+
+static inline int dev_is_t5(struct c4iw_dev *dev)
+{
+ return dev->chip_version == CHELSIO_T5;
+}
+
+static inline int dev_is_t4(struct c4iw_dev *dev)
+{
+ return dev->chip_version == CHELSIO_T4;
+}
+
+struct c4iw_context {
+ struct ibv_context ibv_ctx;
+ struct t4_dev_status_page *status_page;
+ int status_page_size;
+};
+
+struct c4iw_pd {
+ struct ibv_pd ibv_pd;
+};
+
+struct c4iw_mr {
+ struct ibv_mr ibv_mr;
+ uint64_t va_fbo;
+ uint32_t len;
+};
+
+static inline u32 c4iw_mmid(u32 stag)
+{
+ return (stag >> 8);
+}
+
+struct c4iw_cq {
+ struct ibv_cq ibv_cq;
+ struct c4iw_dev *rhp;
+ struct t4_cq cq;
+ pthread_spinlock_t lock;
+#ifdef STALL_DETECTION
+ struct timeval time;
+ int dumped;
+#endif
+};
+
+struct c4iw_qp {
+ struct ibv_qp ibv_qp;
+ struct c4iw_dev *rhp;
+ struct t4_wq wq;
+ pthread_spinlock_t lock;
+ int sq_sig_all;
+};
+
+#define to_c4iw_xxx(xxx, type) \
+ ((struct c4iw_##type *) \
+ ((void *) ib##xxx - offsetof(struct c4iw_##type, ibv_##xxx)))
+
+static inline struct c4iw_dev *to_c4iw_dev(struct ibv_device *ibdev)
+{
+ return to_c4iw_xxx(dev, dev);
+}
+
+static inline struct c4iw_context *to_c4iw_context(struct ibv_context *ibctx)
+{
+ return to_c4iw_xxx(ctx, context);
+}
+
+static inline struct c4iw_pd *to_c4iw_pd(struct ibv_pd *ibpd)
+{
+ return to_c4iw_xxx(pd, pd);
+}
+
+static inline struct c4iw_cq *to_c4iw_cq(struct ibv_cq *ibcq)
+{
+ return to_c4iw_xxx(cq, cq);
+}
+
+static inline struct c4iw_qp *to_c4iw_qp(struct ibv_qp *ibqp)
+{
+ return to_c4iw_xxx(qp, qp);
+}
+
+static inline struct c4iw_mr *to_c4iw_mr(struct ibv_mr *ibmr)
+{
+ return to_c4iw_xxx(mr, mr);
+}
+
+static inline struct c4iw_qp *get_qhp(struct c4iw_dev *rhp, u32 qid)
+{
+ return rhp->qpid2ptr[qid];
+}
+
+static inline struct c4iw_cq *get_chp(struct c4iw_dev *rhp, u32 qid)
+{
+ return rhp->cqid2ptr[qid];
+}
+
+static inline unsigned long_log2(unsigned long x)
+{
+ unsigned r = 0;
+ for (x >>= 1; x > 0; x >>= 1)
+ r++;
+ return r;
+}
+
+int c4iw_query_device(struct ibv_context *context,
+ struct ibv_device_attr *attr);
+int c4iw_query_port(struct ibv_context *context, uint8_t port,
+ struct ibv_port_attr *attr);
+
+struct ibv_pd *c4iw_alloc_pd(struct ibv_context *context);
+int c4iw_free_pd(struct ibv_pd *pd);
+
+struct ibv_mr *c4iw_reg_mr(struct ibv_pd *pd, void *addr,
+ size_t length, int access);
+int c4iw_dereg_mr(struct ibv_mr *mr);
+
+struct ibv_cq *c4iw_create_cq(struct ibv_context *context, int cqe,
+ struct ibv_comp_channel *channel,
+ int comp_vector);
+int c4iw_resize_cq(struct ibv_cq *cq, int cqe);
+int c4iw_destroy_cq(struct ibv_cq *cq);
+int c4iw_poll_cq(struct ibv_cq *cq, int ne, struct ibv_wc *wc);
+int c4iw_arm_cq(struct ibv_cq *cq, int solicited);
+void c4iw_cq_event(struct ibv_cq *cq);
+void c4iw_init_cq_buf(struct c4iw_cq *cq, int nent);
+
+struct ibv_srq *c4iw_create_srq(struct ibv_pd *pd,
+ struct ibv_srq_init_attr *attr);
+int c4iw_modify_srq(struct ibv_srq *srq,
+ struct ibv_srq_attr *attr,
+ int mask);
+int c4iw_destroy_srq(struct ibv_srq *srq);
+int c4iw_post_srq_recv(struct ibv_srq *ibsrq,
+ struct ibv_recv_wr *wr,
+ struct ibv_recv_wr **bad_wr);
+
+struct ibv_qp *c4iw_create_qp(struct ibv_pd *pd,
+ struct ibv_qp_init_attr *attr);
+int c4iw_modify_qp(struct ibv_qp *qp, struct ibv_qp_attr *attr,
+ int attr_mask);
+int c4iw_destroy_qp(struct ibv_qp *qp);
+int c4iw_query_qp(struct ibv_qp *qp,
+ struct ibv_qp_attr *attr,
+ int attr_mask,
+ struct ibv_qp_init_attr *init_attr);
+void c4iw_flush_qp(struct c4iw_qp *qhp);
+void c4iw_flush_qps(struct c4iw_dev *dev);
+int c4iw_post_send(struct ibv_qp *ibqp, struct ibv_send_wr *wr,
+ struct ibv_send_wr **bad_wr);
+int c4iw_post_receive(struct ibv_qp *ibqp, struct ibv_recv_wr *wr,
+ struct ibv_recv_wr **bad_wr);
+struct ibv_ah *c4iw_create_ah(struct ibv_pd *pd,
+ struct ibv_ah_attr *ah_attr);
+int c4iw_destroy_ah(struct ibv_ah *ah);
+int c4iw_attach_mcast(struct ibv_qp *qp, const union ibv_gid *gid,
+ uint16_t lid);
+int c4iw_detach_mcast(struct ibv_qp *qp, const union ibv_gid *gid,
+ uint16_t lid);
+void c4iw_async_event(struct ibv_async_event *event);
+void c4iw_flush_hw_cq(struct c4iw_cq *chp);
+int c4iw_flush_rq(struct t4_wq *wq, struct t4_cq *cq, int count);
+void c4iw_flush_sq(struct c4iw_qp *qhp);
+void c4iw_count_rcqes(struct t4_cq *cq, struct t4_wq *wq, int *count);
+
+#define FW_MAJ 0
+#define FW_MIN 0
+
+static inline unsigned long align(unsigned long val, unsigned long align)
+{
+ return (val + align - 1) & ~(align - 1);
+}
+
+#ifdef STATS
+
+#define INC_STAT(a) { c4iw_stats.a++; }
+
+struct c4iw_stats {
+ unsigned long send;
+ unsigned long recv;
+ unsigned long read;
+ unsigned long write;
+ unsigned long arm;
+ unsigned long cqe;
+ unsigned long mr;
+ unsigned long qp;
+ unsigned long cq;
+};
+extern struct c4iw_stats c4iw_stats;
+#else
+#define INC_STAT(a)
+#endif
+
+#ifdef STALL_DETECTION
+void dump_state(void);
+extern int stall_to;
+#endif
+
+#endif /* IWCH_H */
diff --git a/contrib/ofed/libcxgb4/qp.c b/contrib/ofed/libcxgb4/qp.c
new file mode 100644
index 0000000..bd2c385
--- /dev/null
+++ b/contrib/ofed/libcxgb4/qp.c
@@ -0,0 +1,555 @@
+/*
+ * Copyright (c) 2006-2016 Chelsio, Inc. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+#include <config.h>
+
+#include <assert.h>
+#include <stdlib.h>
+#include <pthread.h>
+#include <string.h>
+#include <stdio.h>
+#include "libcxgb4.h"
+
+#ifdef STATS
+struct c4iw_stats c4iw_stats;
+#endif
+
+static void copy_wr_to_sq(struct t4_wq *wq, union t4_wr *wqe, u8 len16)
+{
+ void *src, *dst;
+ uintptr_t end;
+ int total, len;
+
+ src = &wqe->flits[0];
+ dst = &wq->sq.queue->flits[wq->sq.wq_pidx *
+ (T4_EQ_ENTRY_SIZE / sizeof(__be64))];
+ if (t4_sq_onchip(wq)) {
+ len16 = align(len16, 4);
+
+ /* In onchip mode the copy below will be made to WC memory and
+ * could trigger DMA. In offchip mode the copy below only
+ * queues the WQE, DMA cannot start until t4_ring_sq_db
+ * happens */
+ mmio_wc_start();
+ }
+
+ /* NOTE len16 cannot be large enough to write to the
+ same sq.queue memory twice in this loop */
+ total = len16 * 16;
+ end = (uintptr_t)&wq->sq.queue[wq->sq.size];
+ if (__predict_true((uintptr_t)dst + total <= end)) {
+ /* Won't wrap around. */
+ memcpy(dst, src, total);
+ } else {
+ len = end - (uintptr_t)dst;
+ memcpy(dst, src, len);
+ memcpy(wq->sq.queue, src + len, total - len);
+ }
+
+ if (t4_sq_onchip(wq))
+ mmio_flush_writes();
+}
+
+static void copy_wr_to_rq(struct t4_wq *wq, union t4_recv_wr *wqe, u8 len16)
+{
+ void *src, *dst;
+ uintptr_t end;
+ int total, len;
+
+ src = &wqe->flits[0];
+ dst = &wq->rq.queue->flits[wq->rq.wq_pidx *
+ (T4_EQ_ENTRY_SIZE / sizeof(__be64))];
+
+ total = len16 * 16;
+ end = (uintptr_t)&wq->rq.queue[wq->rq.size];
+ if (__predict_true((uintptr_t)dst + total <= end)) {
+ /* Won't wrap around. */
+ memcpy(dst, src, total);
+ } else {
+ len = end - (uintptr_t)dst;
+ memcpy(dst, src, len);
+ memcpy(wq->rq.queue, src + len, total - len);
+ }
+}
+
+static int build_immd(struct t4_sq *sq, struct fw_ri_immd *immdp,
+ struct ibv_send_wr *wr, int max, u32 *plenp)
+{
+ u8 *dstp, *srcp;
+ u32 plen = 0;
+ int i;
+ int len;
+
+ dstp = (u8 *)immdp->data;
+ for (i = 0; i < wr->num_sge; i++) {
+ if ((plen + wr->sg_list[i].length) > max)
+ return -EMSGSIZE;
+ srcp = (u8 *)(unsigned long)wr->sg_list[i].addr;
+ plen += wr->sg_list[i].length;
+ len = wr->sg_list[i].length;
+ memcpy(dstp, srcp, len);
+ dstp += len;
+ srcp += len;
+ }
+ len = ROUND_UP(plen + 8, 16) - (plen + 8);
+ if (len)
+ memset(dstp, 0, len);
+ immdp->op = FW_RI_DATA_IMMD;
+ immdp->r1 = 0;
+ immdp->r2 = 0;
+ immdp->immdlen = htobe32(plen);
+ *plenp = plen;
+ return 0;
+}
+
+static int build_isgl(struct fw_ri_isgl *isglp, struct ibv_sge *sg_list,
+ int num_sge, u32 *plenp)
+{
+ int i;
+ u32 plen = 0;
+ __be64 *flitp = (__be64 *)isglp->sge;
+
+ for (i = 0; i < num_sge; i++) {
+ if ((plen + sg_list[i].length) < plen)
+ return -EMSGSIZE;
+ plen += sg_list[i].length;
+ *flitp++ = htobe64(((u64)sg_list[i].lkey << 32) |
+ sg_list[i].length);
+ *flitp++ = htobe64(sg_list[i].addr);
+ }
+ *flitp = 0;
+ isglp->op = FW_RI_DATA_ISGL;
+ isglp->r1 = 0;
+ isglp->nsge = htobe16(num_sge);
+ isglp->r2 = 0;
+ if (plenp)
+ *plenp = plen;
+ return 0;
+}
+
+static int build_rdma_send(struct t4_sq *sq, union t4_wr *wqe,
+ struct ibv_send_wr *wr, u8 *len16)
+{
+ u32 plen;
+ int size;
+ int ret;
+
+ if (wr->num_sge > T4_MAX_SEND_SGE)
+ return -EINVAL;
+ if (wr->send_flags & IBV_SEND_SOLICITED)
+ wqe->send.sendop_pkd = htobe32(
+ FW_RI_SEND_WR_SENDOP_V(FW_RI_SEND_WITH_SE));
+ else
+ wqe->send.sendop_pkd = htobe32(
+ FW_RI_SEND_WR_SENDOP_V(FW_RI_SEND));
+ wqe->send.stag_inv = 0;
+ wqe->send.r3 = 0;
+ wqe->send.r4 = 0;
+
+ plen = 0;
+ if (wr->num_sge) {
+ if (wr->send_flags & IBV_SEND_INLINE) {
+ ret = build_immd(sq, wqe->send.u.immd_src, wr,
+ T4_MAX_SEND_INLINE, &plen);
+ if (ret)
+ return ret;
+ size = sizeof wqe->send + sizeof(struct fw_ri_immd) +
+ plen;
+ } else {
+ ret = build_isgl(wqe->send.u.isgl_src,
+ wr->sg_list, wr->num_sge, &plen);
+ if (ret)
+ return ret;
+ size = sizeof wqe->send + sizeof(struct fw_ri_isgl) +
+ wr->num_sge * sizeof (struct fw_ri_sge);
+ }
+ } else {
+ wqe->send.u.immd_src[0].op = FW_RI_DATA_IMMD;
+ wqe->send.u.immd_src[0].r1 = 0;
+ wqe->send.u.immd_src[0].r2 = 0;
+ wqe->send.u.immd_src[0].immdlen = 0;
+ size = sizeof wqe->send + sizeof(struct fw_ri_immd);
+ plen = 0;
+ }
+ *len16 = DIV_ROUND_UP(size, 16);
+ wqe->send.plen = htobe32(plen);
+ return 0;
+}
+
+static int build_rdma_write(struct t4_sq *sq, union t4_wr *wqe,
+ struct ibv_send_wr *wr, u8 *len16)
+{
+ u32 plen;
+ int size;
+ int ret;
+
+ if (wr->num_sge > T4_MAX_SEND_SGE)
+ return -EINVAL;
+ wqe->write.r2 = 0;
+ wqe->write.stag_sink = htobe32(wr->wr.rdma.rkey);
+ wqe->write.to_sink = htobe64(wr->wr.rdma.remote_addr);
+ if (wr->num_sge) {
+ if (wr->send_flags & IBV_SEND_INLINE) {
+ ret = build_immd(sq, wqe->write.u.immd_src, wr,
+ T4_MAX_WRITE_INLINE, &plen);
+ if (ret)
+ return ret;
+ size = sizeof wqe->write + sizeof(struct fw_ri_immd) +
+ plen;
+ } else {
+ ret = build_isgl(wqe->write.u.isgl_src,
+ wr->sg_list, wr->num_sge, &plen);
+ if (ret)
+ return ret;
+ size = sizeof wqe->write + sizeof(struct fw_ri_isgl) +
+ wr->num_sge * sizeof (struct fw_ri_sge);
+ }
+ } else {
+ wqe->write.u.immd_src[0].op = FW_RI_DATA_IMMD;
+ wqe->write.u.immd_src[0].r1 = 0;
+ wqe->write.u.immd_src[0].r2 = 0;
+ wqe->write.u.immd_src[0].immdlen = 0;
+ size = sizeof wqe->write + sizeof(struct fw_ri_immd);
+ plen = 0;
+ }
+ *len16 = DIV_ROUND_UP(size, 16);
+ wqe->write.plen = htobe32(plen);
+ return 0;
+}
+
+static int build_rdma_read(union t4_wr *wqe, struct ibv_send_wr *wr, u8 *len16)
+{
+ if (wr->num_sge > 1)
+ return -EINVAL;
+ if (wr->num_sge) {
+ wqe->read.stag_src = htobe32(wr->wr.rdma.rkey);
+ wqe->read.to_src_hi = htobe32((u32)(wr->wr.rdma.remote_addr >>32));
+ wqe->read.to_src_lo = htobe32((u32)wr->wr.rdma.remote_addr);
+ wqe->read.stag_sink = htobe32(wr->sg_list[0].lkey);
+ wqe->read.plen = htobe32(wr->sg_list[0].length);
+ wqe->read.to_sink_hi = htobe32((u32)(wr->sg_list[0].addr >> 32));
+ wqe->read.to_sink_lo = htobe32((u32)(wr->sg_list[0].addr));
+ } else {
+ wqe->read.stag_src = htobe32(2);
+ wqe->read.to_src_hi = 0;
+ wqe->read.to_src_lo = 0;
+ wqe->read.stag_sink = htobe32(2);
+ wqe->read.plen = 0;
+ wqe->read.to_sink_hi = 0;
+ wqe->read.to_sink_lo = 0;
+ }
+ wqe->read.r2 = 0;
+ wqe->read.r5 = 0;
+ *len16 = DIV_ROUND_UP(sizeof wqe->read, 16);
+ return 0;
+}
+
+static int build_rdma_recv(struct c4iw_qp *qhp, union t4_recv_wr *wqe,
+ struct ibv_recv_wr *wr, u8 *len16)
+{
+ int ret;
+
+ ret = build_isgl(&wqe->recv.isgl, wr->sg_list, wr->num_sge, NULL);
+ if (ret)
+ return ret;
+ *len16 = DIV_ROUND_UP(sizeof wqe->recv +
+ wr->num_sge * sizeof(struct fw_ri_sge), 16);
+ return 0;
+}
+
+static void ring_kernel_db(struct c4iw_qp *qhp, u32 qid, u16 idx)
+{
+ struct ibv_modify_qp cmd = {};
+ struct ibv_qp_attr attr;
+ int mask;
+ int __attribute__((unused)) ret;
+
+ /* FIXME: Why do we need this barrier if the kernel is going to
+ trigger the DMA? */
+ udma_to_device_barrier();
+ if (qid == qhp->wq.sq.qid) {
+ attr.sq_psn = idx;
+ mask = IBV_QP_SQ_PSN;
+ } else {
+ attr.rq_psn = idx;
+ mask = IBV_QP_RQ_PSN;
+ }
+ ret = ibv_cmd_modify_qp(&qhp->ibv_qp, &attr, mask, &cmd, sizeof cmd);
+ assert(!ret);
+}
+
+int c4iw_post_send(struct ibv_qp *ibqp, struct ibv_send_wr *wr,
+ struct ibv_send_wr **bad_wr)
+{
+ int err = 0;
+ u8 len16 = 0;
+ enum fw_wr_opcodes fw_opcode;
+ enum fw_ri_wr_flags fw_flags;
+ struct c4iw_qp *qhp;
+ union t4_wr *wqe, lwqe;
+ u32 num_wrs;
+ struct t4_swsqe *swsqe;
+ u16 idx = 0;
+
+ qhp = to_c4iw_qp(ibqp);
+ pthread_spin_lock(&qhp->lock);
+ if (t4_wq_in_error(&qhp->wq)) {
+ pthread_spin_unlock(&qhp->lock);
+ *bad_wr = wr;
+ return -EINVAL;
+ }
+ num_wrs = t4_sq_avail(&qhp->wq);
+ if (num_wrs == 0) {
+ pthread_spin_unlock(&qhp->lock);
+ *bad_wr = wr;
+ return -ENOMEM;
+ }
+ while (wr) {
+ if (num_wrs == 0) {
+ err = -ENOMEM;
+ *bad_wr = wr;
+ break;
+ }
+
+ wqe = &lwqe;
+ fw_flags = 0;
+ if (wr->send_flags & IBV_SEND_SOLICITED)
+ fw_flags |= FW_RI_SOLICITED_EVENT_FLAG;
+ if (wr->send_flags & IBV_SEND_SIGNALED || qhp->sq_sig_all)
+ fw_flags |= FW_RI_COMPLETION_FLAG;
+ swsqe = &qhp->wq.sq.sw_sq[qhp->wq.sq.pidx];
+ switch (wr->opcode) {
+ case IBV_WR_SEND:
+ INC_STAT(send);
+ if (wr->send_flags & IBV_SEND_FENCE)
+ fw_flags |= FW_RI_READ_FENCE_FLAG;
+ fw_opcode = FW_RI_SEND_WR;
+ swsqe->opcode = FW_RI_SEND;
+ err = build_rdma_send(&qhp->wq.sq, wqe, wr, &len16);
+ break;
+ case IBV_WR_RDMA_WRITE:
+ INC_STAT(write);
+ fw_opcode = FW_RI_RDMA_WRITE_WR;
+ swsqe->opcode = FW_RI_RDMA_WRITE;
+ err = build_rdma_write(&qhp->wq.sq, wqe, wr, &len16);
+ break;
+ case IBV_WR_RDMA_READ:
+ INC_STAT(read);
+ fw_opcode = FW_RI_RDMA_READ_WR;
+ swsqe->opcode = FW_RI_READ_REQ;
+ fw_flags = 0;
+ err = build_rdma_read(wqe, wr, &len16);
+ if (err)
+ break;
+ swsqe->read_len = wr->sg_list ? wr->sg_list[0].length :
+ 0;
+ if (!qhp->wq.sq.oldest_read)
+ qhp->wq.sq.oldest_read = swsqe;
+ break;
+ default:
+ PDBG("%s post of type=%d TBD!\n", __func__,
+ wr->opcode);
+ err = -EINVAL;
+ }
+ if (err) {
+ *bad_wr = wr;
+ break;
+ }
+ swsqe->idx = qhp->wq.sq.pidx;
+ swsqe->complete = 0;
+ swsqe->signaled = (wr->send_flags & IBV_SEND_SIGNALED) ||
+ qhp->sq_sig_all;
+ swsqe->flushed = 0;
+ swsqe->wr_id = wr->wr_id;
+
+ init_wr_hdr(wqe, qhp->wq.sq.pidx, fw_opcode, fw_flags, len16);
+ PDBG("%s cookie 0x%llx pidx 0x%x opcode 0x%x\n",
+ __func__, (unsigned long long)wr->wr_id, qhp->wq.sq.pidx,
+ swsqe->opcode);
+ wr = wr->next;
+ num_wrs--;
+ copy_wr_to_sq(&qhp->wq, wqe, len16);
+ t4_sq_produce(&qhp->wq, len16);
+ idx += DIV_ROUND_UP(len16*16, T4_EQ_ENTRY_SIZE);
+ }
+ if (t4_wq_db_enabled(&qhp->wq)) {
+ t4_ring_sq_db(&qhp->wq, idx, dev_is_t4(qhp->rhp),
+ len16, wqe);
+ } else
+ ring_kernel_db(qhp, qhp->wq.sq.qid, idx);
+ /* This write is only for debugging, the value does not matter for DMA
+ */
+ qhp->wq.sq.queue[qhp->wq.sq.size].status.host_wq_pidx = \
+ (qhp->wq.sq.wq_pidx);
+
+ pthread_spin_unlock(&qhp->lock);
+ return err;
+}
+
+int c4iw_post_receive(struct ibv_qp *ibqp, struct ibv_recv_wr *wr,
+ struct ibv_recv_wr **bad_wr)
+{
+ int err = 0;
+ struct c4iw_qp *qhp;
+ union t4_recv_wr *wqe, lwqe;
+ u32 num_wrs;
+ u8 len16 = 0;
+ u16 idx = 0;
+
+ qhp = to_c4iw_qp(ibqp);
+ pthread_spin_lock(&qhp->lock);
+ if (t4_wq_in_error(&qhp->wq)) {
+ pthread_spin_unlock(&qhp->lock);
+ *bad_wr = wr;
+ return -EINVAL;
+ }
+ INC_STAT(recv);
+ num_wrs = t4_rq_avail(&qhp->wq);
+ if (num_wrs == 0) {
+ pthread_spin_unlock(&qhp->lock);
+ *bad_wr = wr;
+ return -ENOMEM;
+ }
+ while (wr) {
+ if (wr->num_sge > T4_MAX_RECV_SGE) {
+ err = -EINVAL;
+ *bad_wr = wr;
+ break;
+ }
+ wqe = &lwqe;
+ if (num_wrs)
+ err = build_rdma_recv(qhp, wqe, wr, &len16);
+ else
+ err = -ENOMEM;
+ if (err) {
+ *bad_wr = wr;
+ break;
+ }
+
+ qhp->wq.rq.sw_rq[qhp->wq.rq.pidx].wr_id = wr->wr_id;
+
+ wqe->recv.opcode = FW_RI_RECV_WR;
+ wqe->recv.r1 = 0;
+ wqe->recv.wrid = qhp->wq.rq.pidx;
+ wqe->recv.r2[0] = 0;
+ wqe->recv.r2[1] = 0;
+ wqe->recv.r2[2] = 0;
+ wqe->recv.len16 = len16;
+ PDBG("%s cookie 0x%llx pidx %u\n", __func__,
+ (unsigned long long) wr->wr_id, qhp->wq.rq.pidx);
+ copy_wr_to_rq(&qhp->wq, wqe, len16);
+ t4_rq_produce(&qhp->wq, len16);
+ idx += DIV_ROUND_UP(len16*16, T4_EQ_ENTRY_SIZE);
+ wr = wr->next;
+ num_wrs--;
+ }
+ if (t4_wq_db_enabled(&qhp->wq))
+ t4_ring_rq_db(&qhp->wq, idx, dev_is_t4(qhp->rhp),
+ len16, wqe);
+ else
+ ring_kernel_db(qhp, qhp->wq.rq.qid, idx);
+ qhp->wq.rq.queue[qhp->wq.rq.size].status.host_wq_pidx = \
+ (qhp->wq.rq.wq_pidx);
+ pthread_spin_unlock(&qhp->lock);
+ return err;
+}
+
+static void update_qp_state(struct c4iw_qp *qhp)
+{
+ struct ibv_query_qp cmd;
+ struct ibv_qp_attr attr;
+ struct ibv_qp_init_attr iattr;
+ int ret;
+
+ ret = ibv_cmd_query_qp(&qhp->ibv_qp, &attr, IBV_QP_STATE, &iattr,
+ &cmd, sizeof cmd);
+ assert(!ret);
+ if (!ret)
+ qhp->ibv_qp.state = attr.qp_state;
+}
+
+/*
+ * Assumes qhp lock is held.
+ */
+void c4iw_flush_qp(struct c4iw_qp *qhp)
+{
+ struct c4iw_cq *rchp, *schp;
+ int count;
+
+ if (qhp->wq.flushed)
+ return;
+
+ update_qp_state(qhp);
+
+ rchp = to_c4iw_cq(qhp->ibv_qp.recv_cq);
+ schp = to_c4iw_cq(qhp->ibv_qp.send_cq);
+
+ PDBG("%s qhp %p rchp %p schp %p\n", __func__, qhp, rchp, schp);
+ qhp->wq.flushed = 1;
+ pthread_spin_unlock(&qhp->lock);
+
+ /* locking heirarchy: cq lock first, then qp lock. */
+ pthread_spin_lock(&rchp->lock);
+ pthread_spin_lock(&qhp->lock);
+ c4iw_flush_hw_cq(rchp);
+ c4iw_count_rcqes(&rchp->cq, &qhp->wq, &count);
+ c4iw_flush_rq(&qhp->wq, &rchp->cq, count);
+ pthread_spin_unlock(&qhp->lock);
+ pthread_spin_unlock(&rchp->lock);
+
+ /* locking heirarchy: cq lock first, then qp lock. */
+ pthread_spin_lock(&schp->lock);
+ pthread_spin_lock(&qhp->lock);
+ if (schp != rchp)
+ c4iw_flush_hw_cq(schp);
+ c4iw_flush_sq(qhp);
+ pthread_spin_unlock(&qhp->lock);
+ pthread_spin_unlock(&schp->lock);
+ pthread_spin_lock(&qhp->lock);
+}
+
+void c4iw_flush_qps(struct c4iw_dev *dev)
+{
+ int i;
+
+ pthread_spin_lock(&dev->lock);
+ for (i=0; i < dev->max_qp; i++) {
+ struct c4iw_qp *qhp = dev->qpid2ptr[i];
+ if (qhp) {
+ if (!qhp->wq.flushed && t4_wq_in_error(&qhp->wq)) {
+ pthread_spin_lock(&qhp->lock);
+ c4iw_flush_qp(qhp);
+ pthread_spin_unlock(&qhp->lock);
+ }
+ }
+ }
+ pthread_spin_unlock(&dev->lock);
+}
diff --git a/contrib/ofed/libcxgb4/src/cq.c b/contrib/ofed/libcxgb4/src/cq.c
deleted file mode 100644
index ed5b66b..0000000
--- a/contrib/ofed/libcxgb4/src/cq.c
+++ /dev/null
@@ -1,753 +0,0 @@
-/*
- * Copyright (c) 2006-2014 Chelsio, Inc. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-#if HAVE_CONFIG_H
-# include <config.h>
-#endif /* HAVE_CONFIG_H */
-
-#include <stdio.h>
-#include <syslog.h>
-#include <pthread.h>
-#include <sys/errno.h>
-#include <netinet/in.h>
-#include <infiniband/opcode.h>
-#include "libcxgb4.h"
-#include "cxgb4-abi.h"
-
-static void insert_recv_cqe(struct t4_wq *wq, struct t4_cq *cq)
-{
- struct t4_cqe cqe;
-
- PDBG("%s wq %p cq %p sw_cidx %u sw_pidx %u\n", __func__,
- wq, cq, cq->sw_cidx, cq->sw_pidx);
- memset(&cqe, 0, sizeof(cqe));
- cqe.header = cpu_to_be32(V_CQE_STATUS(T4_ERR_SWFLUSH) |
- V_CQE_OPCODE(FW_RI_SEND) |
- V_CQE_TYPE(0) |
- V_CQE_SWCQE(1) |
- V_CQE_QPID(wq->sq.qid));
- cqe.bits_type_ts = cpu_to_be64(V_CQE_GENBIT((u64)cq->gen));
- cq->sw_queue[cq->sw_pidx] = cqe;
- t4_swcq_produce(cq);
-}
-
-int c4iw_flush_rq(struct t4_wq *wq, struct t4_cq *cq, int count)
-{
- int flushed = 0;
- int in_use = wq->rq.in_use - count;
-
- BUG_ON(in_use < 0);
- PDBG("%s wq %p cq %p rq.in_use %u skip count %u\n", __func__,
- wq, cq, wq->rq.in_use, count);
- while (in_use--) {
- insert_recv_cqe(wq, cq);
- flushed++;
- }
- return flushed;
-}
-
-static void insert_sq_cqe(struct t4_wq *wq, struct t4_cq *cq,
- struct t4_swsqe *swcqe)
-{
- struct t4_cqe cqe;
-
- PDBG("%s wq %p cq %p sw_cidx %u sw_pidx %u\n", __func__,
- wq, cq, cq->sw_cidx, cq->sw_pidx);
- memset(&cqe, 0, sizeof(cqe));
- cqe.header = cpu_to_be32(V_CQE_STATUS(T4_ERR_SWFLUSH) |
- V_CQE_OPCODE(swcqe->opcode) |
- V_CQE_TYPE(1) |
- V_CQE_SWCQE(1) |
- V_CQE_QPID(wq->sq.qid));
- CQE_WRID_SQ_IDX(&cqe) = swcqe->idx;
- cqe.bits_type_ts = cpu_to_be64(V_CQE_GENBIT((u64)cq->gen));
- cq->sw_queue[cq->sw_pidx] = cqe;
- t4_swcq_produce(cq);
-}
-
-static void advance_oldest_read(struct t4_wq *wq);
-
-void c4iw_flush_sq(struct c4iw_qp *qhp)
-{
- unsigned short flushed = 0;
- struct t4_wq *wq = &qhp->wq;
- struct c4iw_cq *chp = to_c4iw_cq(qhp->ibv_qp.send_cq);
- struct t4_cq *cq = &chp->cq;
- int idx;
- struct t4_swsqe *swsqe;
-
- if (wq->sq.flush_cidx == -1)
- wq->sq.flush_cidx = wq->sq.cidx;
- idx = wq->sq.flush_cidx;
- BUG_ON(idx >= wq->sq.size);
- while (idx != wq->sq.pidx) {
- swsqe = &wq->sq.sw_sq[idx];
- BUG_ON(swsqe->flushed);
- swsqe->flushed = 1;
- insert_sq_cqe(wq, cq, swsqe);
- if (wq->sq.oldest_read == swsqe) {
- BUG_ON(swsqe->opcode != FW_RI_READ_REQ);
- advance_oldest_read(wq);
- }
- flushed++;
- if (++idx == wq->sq.size)
- idx = 0;
- }
- wq->sq.flush_cidx += flushed;
- if (wq->sq.flush_cidx >= wq->sq.size)
- wq->sq.flush_cidx -= wq->sq.size;
-}
-
-static void flush_completed_wrs(struct t4_wq *wq, struct t4_cq *cq)
-{
- struct t4_swsqe *swsqe;
- unsigned short cidx;
-
- if (wq->sq.flush_cidx == -1)
- wq->sq.flush_cidx = wq->sq.cidx;
- cidx = wq->sq.flush_cidx;
- BUG_ON(cidx >= wq->sq.size);
-
- while (cidx != wq->sq.pidx) {
- swsqe = &wq->sq.sw_sq[cidx];
- if (!swsqe->signaled) {
- if (++cidx == wq->sq.size)
- cidx = 0;
- } else if (swsqe->complete) {
-
- BUG_ON(swsqe->flushed);
-
- /*
- * Insert this completed cqe into the swcq.
- */
- PDBG("%s moving cqe into swcq sq idx %u cq idx %u\n",
- __func__, cidx, cq->sw_pidx);
-
- swsqe->cqe.header |= htonl(V_CQE_SWCQE(1));
- cq->sw_queue[cq->sw_pidx] = swsqe->cqe;
- t4_swcq_produce(cq);
- swsqe->flushed = 1;
- if (++cidx == wq->sq.size)
- cidx = 0;
- wq->sq.flush_cidx = cidx;
- } else
- break;
- }
-}
-
-static void create_read_req_cqe(struct t4_wq *wq, struct t4_cqe *hw_cqe,
- struct t4_cqe *read_cqe)
-{
- read_cqe->u.scqe.cidx = wq->sq.oldest_read->idx;
- read_cqe->len = ntohl(wq->sq.oldest_read->read_len);
- read_cqe->header = htonl(V_CQE_QPID(CQE_QPID(hw_cqe)) |
- V_CQE_SWCQE(SW_CQE(hw_cqe)) |
- V_CQE_OPCODE(FW_RI_READ_REQ) |
- V_CQE_TYPE(1));
- read_cqe->bits_type_ts = hw_cqe->bits_type_ts;
-}
-
-static void advance_oldest_read(struct t4_wq *wq)
-{
-
- u32 rptr = wq->sq.oldest_read - wq->sq.sw_sq + 1;
-
- if (rptr == wq->sq.size)
- rptr = 0;
- while (rptr != wq->sq.pidx) {
- wq->sq.oldest_read = &wq->sq.sw_sq[rptr];
-
- if (wq->sq.oldest_read->opcode == FW_RI_READ_REQ)
- return;
- if (++rptr == wq->sq.size)
- rptr = 0;
- }
- wq->sq.oldest_read = NULL;
-}
-
-/*
- * Move all CQEs from the HWCQ into the SWCQ.
- * Deal with out-of-order and/or completions that complete
- * prior unsignalled WRs.
- */
-void c4iw_flush_hw_cq(struct c4iw_cq *chp)
-{
- struct t4_cqe *hw_cqe, *swcqe, read_cqe;
- struct c4iw_qp *qhp;
- struct t4_swsqe *swsqe;
- int ret;
-
- PDBG("%s cqid 0x%x\n", __func__, chp->cq.cqid);
- ret = t4_next_hw_cqe(&chp->cq, &hw_cqe);
-
- /*
- * This logic is similar to poll_cq(), but not quite the same
- * unfortunately. Need to move pertinent HW CQEs to the SW CQ but
- * also do any translation magic that poll_cq() normally does.
- */
- while (!ret) {
- qhp = get_qhp(chp->rhp, CQE_QPID(hw_cqe));
-
- /*
- * drop CQEs with no associated QP
- */
- if (qhp == NULL)
- goto next_cqe;
-
- if (CQE_OPCODE(hw_cqe) == FW_RI_TERMINATE)
- goto next_cqe;
-
- if (CQE_OPCODE(hw_cqe) == FW_RI_READ_RESP) {
-
- /*
- * If we have reached here because of async
- * event or other error, and have egress error
- * then drop
- */
- if (CQE_TYPE(hw_cqe) == 1) {
- syslog(LOG_CRIT, "%s: got egress error in \
- read-response, dropping!\n", __func__);
- goto next_cqe;
- }
-
- /*
- * drop peer2peer RTR reads.
- */
- if (CQE_WRID_STAG(hw_cqe) == 1)
- goto next_cqe;
-
- /*
- * Eat completions for unsignaled read WRs.
- */
- if (!qhp->wq.sq.oldest_read->signaled) {
- advance_oldest_read(&qhp->wq);
- goto next_cqe;
- }
-
- /*
- * Don't write to the HWCQ, create a new read req CQE
- * in local memory and move it into the swcq.
- */
- create_read_req_cqe(&qhp->wq, hw_cqe, &read_cqe);
- hw_cqe = &read_cqe;
- advance_oldest_read(&qhp->wq);
- }
-
- /* if its a SQ completion, then do the magic to move all the
- * unsignaled and now in-order completions into the swcq.
- */
- if (SQ_TYPE(hw_cqe)) {
- int idx = CQE_WRID_SQ_IDX(hw_cqe);
-
- BUG_ON(idx >= qhp->wq.sq.size);
- swsqe = &qhp->wq.sq.sw_sq[idx];
- swsqe->cqe = *hw_cqe;
- swsqe->complete = 1;
- flush_completed_wrs(&qhp->wq, &chp->cq);
- } else {
- swcqe = &chp->cq.sw_queue[chp->cq.sw_pidx];
- *swcqe = *hw_cqe;
- swcqe->header |= cpu_to_be32(V_CQE_SWCQE(1));
- t4_swcq_produce(&chp->cq);
- }
-next_cqe:
- t4_hwcq_consume(&chp->cq);
- ret = t4_next_hw_cqe(&chp->cq, &hw_cqe);
- }
-}
-
-static int cqe_completes_wr(struct t4_cqe *cqe, struct t4_wq *wq)
-{
- if (CQE_OPCODE(cqe) == FW_RI_TERMINATE)
- return 0;
-
- if ((CQE_OPCODE(cqe) == FW_RI_RDMA_WRITE) && RQ_TYPE(cqe))
- return 0;
-
- if ((CQE_OPCODE(cqe) == FW_RI_READ_RESP) && SQ_TYPE(cqe))
- return 0;
-
- if (CQE_SEND_OPCODE(cqe) && RQ_TYPE(cqe) && t4_rq_empty(wq))
- return 0;
- return 1;
-}
-
-void c4iw_count_rcqes(struct t4_cq *cq, struct t4_wq *wq, int *count)
-{
- struct t4_cqe *cqe;
- u32 ptr;
-
- *count = 0;
- ptr = cq->sw_cidx;
- BUG_ON(ptr >= cq->size);
- while (ptr != cq->sw_pidx) {
- cqe = &cq->sw_queue[ptr];
- if (RQ_TYPE(cqe) && (CQE_OPCODE(cqe) != FW_RI_READ_RESP) &&
- (CQE_QPID(cqe) == wq->sq.qid) && cqe_completes_wr(cqe, wq))
- (*count)++;
- if (++ptr == cq->size)
- ptr = 0;
- }
- PDBG("%s cq %p count %d\n", __func__, cq, *count);
-}
-
-static void dump_cqe(void *arg)
-{
- u64 *p = arg;
- syslog(LOG_NOTICE, "cxgb4 err cqe %016lx %016lx %016lx %016lx\n",
- be64_to_cpu(p[0]),
- be64_to_cpu(p[1]),
- be64_to_cpu(p[2]),
- be64_to_cpu(p[3]));
-}
-
-/*
- * poll_cq
- *
- * Caller must:
- * check the validity of the first CQE,
- * supply the wq assicated with the qpid.
- *
- * credit: cq credit to return to sge.
- * cqe_flushed: 1 iff the CQE is flushed.
- * cqe: copy of the polled CQE.
- *
- * return value:
- * 0 CQE returned ok.
- * -EAGAIN CQE skipped, try again.
- * -EOVERFLOW CQ overflow detected.
- */
-static int poll_cq(struct t4_wq *wq, struct t4_cq *cq, struct t4_cqe *cqe,
- u8 *cqe_flushed, u64 *cookie, u32 *credit)
-{
- int ret = 0;
- struct t4_cqe *hw_cqe, read_cqe;
-
- *cqe_flushed = 0;
- *credit = 0;
-
- ret = t4_next_cqe(cq, &hw_cqe);
- if (ret)
- return ret;
-
- PDBG("%s CQE OVF %u qpid 0x%0x genbit %u type %u status 0x%0x"
- " opcode 0x%0x len 0x%0x wrid_hi_stag 0x%x wrid_low_msn 0x%x\n",
- __func__, CQE_OVFBIT(hw_cqe), CQE_QPID(hw_cqe),
- CQE_GENBIT(hw_cqe), CQE_TYPE(hw_cqe), CQE_STATUS(hw_cqe),
- CQE_OPCODE(hw_cqe), CQE_LEN(hw_cqe), CQE_WRID_HI(hw_cqe),
- CQE_WRID_LOW(hw_cqe));
-
- /*
- * skip cqe's not affiliated with a QP.
- */
- if (wq == NULL) {
- ret = -EAGAIN;
- goto skip_cqe;
- }
-
- /*
- * Gotta tweak READ completions:
- * 1) the cqe doesn't contain the sq_wptr from the wr.
- * 2) opcode not reflected from the wr.
- * 3) read_len not reflected from the wr.
- * 4) T4 HW (for now) inserts target read response failures which
- * need to be skipped.
- */
- if (CQE_OPCODE(hw_cqe) == FW_RI_READ_RESP) {
-
- /*
- * If we have reached here because of async
- * event or other error, and have egress error
- * then drop
- */
- if (CQE_TYPE(hw_cqe) == 1) {
- syslog(LOG_CRIT, "%s: got egress error in \
- read-response, dropping!\n", __func__);
- if (CQE_STATUS(hw_cqe))
- t4_set_wq_in_error(wq);
- ret = -EAGAIN;
- goto skip_cqe;
- }
-
- /*
- * If this is an unsolicited read response, then the read
- * was generated by the kernel driver as part of peer-2-peer
- * connection setup, or a target read response failure.
- * So skip the completion.
- */
- if (CQE_WRID_STAG(hw_cqe) == 1) {
- if (CQE_STATUS(hw_cqe))
- t4_set_wq_in_error(wq);
- ret = -EAGAIN;
- goto skip_cqe;
- }
-
- /*
- * Eat completions for unsignaled read WRs.
- */
- if (!wq->sq.oldest_read->signaled) {
- advance_oldest_read(wq);
- ret = -EAGAIN;
- goto skip_cqe;
- }
-
- /*
- * Don't write to the HWCQ, so create a new read req CQE
- * in local memory.
- */
- create_read_req_cqe(wq, hw_cqe, &read_cqe);
- hw_cqe = &read_cqe;
- advance_oldest_read(wq);
- }
-
- if (CQE_STATUS(hw_cqe) || t4_wq_in_error(wq)) {
- *cqe_flushed = (CQE_STATUS(hw_cqe) == T4_ERR_SWFLUSH);
- wq->error = 1;
-
- if (!*cqe_flushed && CQE_STATUS(hw_cqe))
- dump_cqe(hw_cqe);
-
- BUG_ON((cqe_flushed == 0) && !SW_CQE(hw_cqe));
- goto proc_cqe;
- }
-
- if (CQE_OPCODE(hw_cqe) == FW_RI_TERMINATE) {
- ret = -EAGAIN;
- goto skip_cqe;
- }
-
- /*
- * RECV completion.
- */
- if (RQ_TYPE(hw_cqe)) {
-
- /*
- * HW only validates 4 bits of MSN. So we must validate that
- * the MSN in the SEND is the next expected MSN. If its not,
- * then we complete this with T4_ERR_MSN and mark the wq in
- * error.
- */
-
- if (t4_rq_empty(wq)) {
- t4_set_wq_in_error(wq);
- ret = -EAGAIN;
- goto skip_cqe;
- }
- if (unlikely((CQE_WRID_MSN(hw_cqe) != (wq->rq.msn)))) {
- t4_set_wq_in_error(wq);
- hw_cqe->header |= htonl(V_CQE_STATUS(T4_ERR_MSN));
- goto proc_cqe;
- }
- goto proc_cqe;
- }
-
- /*
- * If we get here its a send completion.
- *
- * Handle out of order completion. These get stuffed
- * in the SW SQ. Then the SW SQ is walked to move any
- * now in-order completions into the SW CQ. This handles
- * 2 cases:
- * 1) reaping unsignaled WRs when the first subsequent
- * signaled WR is completed.
- * 2) out of order read completions.
- */
- if (!SW_CQE(hw_cqe) && (CQE_WRID_SQ_IDX(hw_cqe) != wq->sq.cidx)) {
- struct t4_swsqe *swsqe;
- int idx = CQE_WRID_SQ_IDX(hw_cqe);
-
- PDBG("%s out of order completion going in sw_sq at idx %u\n",
- __func__, idx);
- BUG_ON(idx >= wq->sq.size);
- swsqe = &wq->sq.sw_sq[idx];
- swsqe->cqe = *hw_cqe;
- swsqe->complete = 1;
- ret = -EAGAIN;
- goto flush_wq;
- }
-
-proc_cqe:
- *cqe = *hw_cqe;
-
- /*
- * Reap the associated WR(s) that are freed up with this
- * completion.
- */
- if (SQ_TYPE(hw_cqe)) {
- int idx = CQE_WRID_SQ_IDX(hw_cqe);
- BUG_ON(idx >= wq->sq.size);
-
- /*
- * Account for any unsignaled completions completed by
- * this signaled completion. In this case, cidx points
- * to the first unsignaled one, and idx points to the
- * signaled one. So adjust in_use based on this delta.
- * if this is not completing any unsigned wrs, then the
- * delta will be 0. Handle wrapping also!
- */
- if (idx < wq->sq.cidx)
- wq->sq.in_use -= wq->sq.size + idx - wq->sq.cidx;
- else
- wq->sq.in_use -= idx - wq->sq.cidx;
- BUG_ON(wq->sq.in_use <= 0 || wq->sq.in_use >= wq->sq.size);
-
- wq->sq.cidx = (u16)idx;
- PDBG("%s completing sq idx %u\n", __func__, wq->sq.cidx);
- *cookie = wq->sq.sw_sq[wq->sq.cidx].wr_id;
- t4_sq_consume(wq);
- } else {
- PDBG("%s completing rq idx %u\n", __func__, wq->rq.cidx);
- BUG_ON(wq->rq.cidx >= wq->rq.size);
- *cookie = wq->rq.sw_rq[wq->rq.cidx].wr_id;
- BUG_ON(t4_rq_empty(wq));
- t4_rq_consume(wq);
- goto skip_cqe;
- }
-
-flush_wq:
- /*
- * Flush any completed cqes that are now in-order.
- */
- flush_completed_wrs(wq, cq);
-
-skip_cqe:
- if (SW_CQE(hw_cqe)) {
- PDBG("%s cq %p cqid 0x%x skip sw cqe cidx %u\n",
- __func__, cq, cq->cqid, cq->sw_cidx);
- t4_swcq_consume(cq);
- } else {
- PDBG("%s cq %p cqid 0x%x skip hw cqe cidx %u\n",
- __func__, cq, cq->cqid, cq->cidx);
- t4_hwcq_consume(cq);
- }
- return ret;
-}
-
-/*
- * Get one cq entry from c4iw and map it to openib.
- *
- * Returns:
- * 0 cqe returned
- * -ENODATA EMPTY;
- * -EAGAIN caller must try again
- * any other -errno fatal error
- */
-static int c4iw_poll_cq_one(struct c4iw_cq *chp, struct ibv_wc *wc)
-{
- struct c4iw_qp *qhp = NULL;
- struct t4_cqe cqe, *rd_cqe;
- struct t4_wq *wq;
- u32 credit = 0;
- u8 cqe_flushed;
- u64 cookie = 0;
- int ret;
-
- ret = t4_next_cqe(&chp->cq, &rd_cqe);
-
- if (ret) {
-#ifdef STALL_DETECTION
- if (ret == -ENODATA && stall_to && !chp->dumped) {
- struct timeval t;
-
- gettimeofday(&t, NULL);
- if ((t.tv_sec - chp->time.tv_sec) > stall_to) {
- dump_state();
- chp->dumped = 1;
- }
- }
-#endif
- return ret;
- }
-
-#ifdef STALL_DETECTION
- gettimeofday(&chp->time, NULL);
-#endif
-
- qhp = get_qhp(chp->rhp, CQE_QPID(rd_cqe));
- if (!qhp)
- wq = NULL;
- else {
- pthread_spin_lock(&qhp->lock);
- wq = &(qhp->wq);
- }
- ret = poll_cq(wq, &(chp->cq), &cqe, &cqe_flushed, &cookie, &credit);
- if (ret)
- goto out;
-
- INC_STAT(cqe);
- wc->wr_id = cookie;
- wc->qp_num = qhp->wq.sq.qid;
- wc->vendor_err = CQE_STATUS(&cqe);
- wc->wc_flags = 0;
-
- PDBG("%s qpid 0x%x type %d opcode %d status 0x%x wrid hi 0x%x "
- "lo 0x%x cookie 0x%llx\n", __func__,
- CQE_QPID(&cqe), CQE_TYPE(&cqe),
- CQE_OPCODE(&cqe), CQE_STATUS(&cqe), CQE_WRID_HI(&cqe),
- CQE_WRID_LOW(&cqe), (unsigned long long)cookie);
-
- if (CQE_TYPE(&cqe) == 0) {
- if (!CQE_STATUS(&cqe))
- wc->byte_len = CQE_LEN(&cqe);
- else
- wc->byte_len = 0;
- wc->opcode = IBV_WC_RECV;
- } else {
- switch (CQE_OPCODE(&cqe)) {
- case FW_RI_RDMA_WRITE:
- wc->opcode = IBV_WC_RDMA_WRITE;
- break;
- case FW_RI_READ_REQ:
- wc->opcode = IBV_WC_RDMA_READ;
- wc->byte_len = CQE_LEN(&cqe);
- break;
- case FW_RI_SEND:
- case FW_RI_SEND_WITH_SE:
- case FW_RI_SEND_WITH_INV:
- case FW_RI_SEND_WITH_SE_INV:
- wc->opcode = IBV_WC_SEND;
- break;
- case FW_RI_BIND_MW:
- wc->opcode = IBV_WC_BIND_MW;
- break;
- default:
- PDBG("Unexpected opcode %d "
- "in the CQE received for QPID=0x%0x\n",
- CQE_OPCODE(&cqe), CQE_QPID(&cqe));
- ret = -EINVAL;
- goto out;
- }
- }
-
- if (cqe_flushed)
- wc->status = IBV_WC_WR_FLUSH_ERR;
- else {
-
- switch (CQE_STATUS(&cqe)) {
- case T4_ERR_SUCCESS:
- wc->status = IBV_WC_SUCCESS;
- break;
- case T4_ERR_STAG:
- wc->status = IBV_WC_LOC_ACCESS_ERR;
- break;
- case T4_ERR_PDID:
- wc->status = IBV_WC_LOC_PROT_ERR;
- break;
- case T4_ERR_QPID:
- case T4_ERR_ACCESS:
- wc->status = IBV_WC_LOC_ACCESS_ERR;
- break;
- case T4_ERR_WRAP:
- wc->status = IBV_WC_GENERAL_ERR;
- break;
- case T4_ERR_BOUND:
- wc->status = IBV_WC_LOC_LEN_ERR;
- break;
- case T4_ERR_INVALIDATE_SHARED_MR:
- case T4_ERR_INVALIDATE_MR_WITH_MW_BOUND:
- wc->status = IBV_WC_MW_BIND_ERR;
- break;
- case T4_ERR_CRC:
- case T4_ERR_MARKER:
- case T4_ERR_PDU_LEN_ERR:
- case T4_ERR_OUT_OF_RQE:
- case T4_ERR_DDP_VERSION:
- case T4_ERR_RDMA_VERSION:
- case T4_ERR_DDP_QUEUE_NUM:
- case T4_ERR_MSN:
- case T4_ERR_TBIT:
- case T4_ERR_MO:
- case T4_ERR_MSN_RANGE:
- case T4_ERR_IRD_OVERFLOW:
- case T4_ERR_OPCODE:
- case T4_ERR_INTERNAL_ERR:
- wc->status = IBV_WC_FATAL_ERR;
- break;
- case T4_ERR_SWFLUSH:
- wc->status = IBV_WC_WR_FLUSH_ERR;
- break;
- default:
- PDBG("Unexpected cqe_status 0x%x for QPID=0x%0x\n",
- CQE_STATUS(&cqe), CQE_QPID(&cqe));
- wc->status = IBV_WC_FATAL_ERR;
- }
- }
- if (wc->status && wc->status != IBV_WC_WR_FLUSH_ERR)
- syslog(LOG_NOTICE, "cxgb4 app err cqid %u qpid %u "
- "type %u opcode %u status 0x%x\n",
- chp->cq.cqid, CQE_QPID(&cqe), CQE_TYPE(&cqe),
- CQE_OPCODE(&cqe), CQE_STATUS(&cqe));
-out:
- if (wq)
- pthread_spin_unlock(&qhp->lock);
- return ret;
-}
-
-int c4iw_poll_cq(struct ibv_cq *ibcq, int num_entries, struct ibv_wc *wc)
-{
- struct c4iw_cq *chp;
- int npolled;
- int err = 0;
-
- chp = to_c4iw_cq(ibcq);
-
- if (t4_cq_in_error(&chp->cq)) {
- t4_reset_cq_in_error(&chp->cq);
- c4iw_flush_qps(chp->rhp);
- }
-
- if (!num_entries)
- return t4_cq_notempty(&chp->cq);
-
- pthread_spin_lock(&chp->lock);
- for (npolled = 0; npolled < num_entries; ++npolled) {
- do {
- err = c4iw_poll_cq_one(chp, wc + npolled);
- } while (err == -EAGAIN);
- if (err)
- break;
- }
- pthread_spin_unlock(&chp->lock);
- return !err || err == -ENODATA ? npolled : err;
-}
-
-int c4iw_arm_cq(struct ibv_cq *ibcq, int solicited)
-{
- struct c4iw_cq *chp;
- int ret;
-
- INC_STAT(arm);
- chp = to_c4iw_cq(ibcq);
- pthread_spin_lock(&chp->lock);
- ret = t4_arm_cq(&chp->cq, solicited);
- pthread_spin_unlock(&chp->lock);
- return ret;
-}
diff --git a/contrib/ofed/libcxgb4/src/cxgb4-abi.h b/contrib/ofed/libcxgb4/src/cxgb4-abi.h
deleted file mode 100644
index 0b9f4d9..0000000
--- a/contrib/ofed/libcxgb4/src/cxgb4-abi.h
+++ /dev/null
@@ -1,95 +0,0 @@
-/*
- * Copyright (c) 2006-2014 Chelsio, Inc. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-#ifndef IWCH_ABI_H
-#define IWCH_ABI_H
-
-#include <infiniband/kern-abi.h>
-
-struct c4iw_alloc_ucontext_resp {
- struct ibv_get_context_resp ibv_resp;
- __u64 status_page_key;
- __u32 status_page_size;
- __u32 reserved;
-};
-
-struct c4iw_alloc_pd_resp {
- struct ibv_alloc_pd_resp ibv_resp;
- uint32_t pdid;
-};
-
-struct c4iw_create_cq_resp {
- struct ibv_create_cq_resp ibv_resp;
- __u64 key;
- __u64 gts_key;
- __u64 memsize;
- __u32 cqid;
- __u32 size;
- __u32 qid_mask;
- __u32 reserved;
-};
-
-enum {
- C4IW_QPF_ONCHIP = (1<<0),
-};
-
-struct c4iw_create_qp_resp_v0 {
- struct ibv_create_qp_resp ibv_resp;
- __u64 sq_key;
- __u64 rq_key;
- __u64 sq_db_gts_key;
- __u64 rq_db_gts_key;
- __u64 sq_memsize;
- __u64 rq_memsize;
- __u32 sqid;
- __u32 rqid;
- __u32 sq_size;
- __u32 rq_size;
- __u32 qid_mask;
-};
-
-struct c4iw_create_qp_resp {
- struct ibv_create_qp_resp ibv_resp;
- __u64 ma_sync_key;
- __u64 sq_key;
- __u64 rq_key;
- __u64 sq_db_gts_key;
- __u64 rq_db_gts_key;
- __u64 sq_memsize;
- __u64 rq_memsize;
- __u32 sqid;
- __u32 rqid;
- __u32 sq_size;
- __u32 rq_size;
- __u32 qid_mask;
- __u32 flags;
-};
-#endif /* IWCH_ABI_H */
diff --git a/contrib/ofed/libcxgb4/src/cxgb4.map b/contrib/ofed/libcxgb4/src/cxgb4.map
deleted file mode 100644
index 59a8bae..0000000
--- a/contrib/ofed/libcxgb4/src/cxgb4.map
+++ /dev/null
@@ -1,6 +0,0 @@
-{
- global:
- ibv_driver_init;
- openib_driver_init;
- local: *;
-};
diff --git a/contrib/ofed/libcxgb4/src/dev.c b/contrib/ofed/libcxgb4/src/dev.c
deleted file mode 100644
index 2d84719..0000000
--- a/contrib/ofed/libcxgb4/src/dev.c
+++ /dev/null
@@ -1,554 +0,0 @@
-/*
- * Copyright (c) 2006-2014 Chelsio, Inc. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-#if HAVE_CONFIG_H
-# include <config.h>
-#endif /* HAVE_CONFIG_H */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <errno.h>
-#include <sys/mman.h>
-#include <pthread.h>
-#include <string.h>
-#include <signal.h>
-
-#include "libcxgb4.h"
-#include "cxgb4-abi.h"
-
-#define PCI_VENDOR_ID_CHELSIO 0x1425
-
-/*
- * Macros needed to support the PCI Device ID Table ...
- */
-#define CH_PCI_DEVICE_ID_TABLE_DEFINE_BEGIN \
- struct { \
- unsigned vendor; \
- unsigned device; \
- } hca_table[] = {
-
-#define CH_PCI_DEVICE_ID_FUNCTION \
- 0x4
-
-#define CH_PCI_ID_TABLE_ENTRY(__DeviceID) \
- { \
- .vendor = PCI_VENDOR_ID_CHELSIO, \
- .device = (__DeviceID), \
- }
-
-#define CH_PCI_DEVICE_ID_TABLE_DEFINE_END \
- }
-
-#include "t4_chip_type.h"
-#include "t4_pci_id_tbl.h"
-
-unsigned long c4iw_page_size;
-unsigned long c4iw_page_shift;
-unsigned long c4iw_page_mask;
-int ma_wr;
-int t5_en_wc = 1;
-
-SLIST_HEAD(devices_struct, c4iw_dev) devices;
-
-static struct ibv_context_ops c4iw_ctx_ops = {
- .query_device = c4iw_query_device,
- .query_port = c4iw_query_port,
- .alloc_pd = c4iw_alloc_pd,
- .dealloc_pd = c4iw_free_pd,
- .reg_mr = c4iw_reg_mr,
- .dereg_mr = c4iw_dereg_mr,
- .create_cq = c4iw_create_cq,
- .resize_cq = c4iw_resize_cq,
- .destroy_cq = c4iw_destroy_cq,
- .create_srq = c4iw_create_srq,
- .modify_srq = c4iw_modify_srq,
- .destroy_srq = c4iw_destroy_srq,
- .create_qp = c4iw_create_qp,
- .modify_qp = c4iw_modify_qp,
- .destroy_qp = c4iw_destroy_qp,
- .query_qp = c4iw_query_qp,
- .create_ah = c4iw_create_ah,
- .destroy_ah = c4iw_destroy_ah,
- .attach_mcast = c4iw_attach_mcast,
- .detach_mcast = c4iw_detach_mcast,
- .post_srq_recv = c4iw_post_srq_recv,
- .req_notify_cq = c4iw_arm_cq,
-};
-
-static struct ibv_context *c4iw_alloc_context(struct ibv_device *ibdev,
- int cmd_fd)
-{
- struct c4iw_context *context;
- struct ibv_get_context cmd;
- struct c4iw_alloc_ucontext_resp resp;
- struct c4iw_dev *rhp = to_c4iw_dev(ibdev);
- struct ibv_query_device qcmd;
- uint64_t raw_fw_ver;
- struct ibv_device_attr attr;
-
- context = malloc(sizeof *context);
- if (!context)
- return NULL;
-
- memset(context, 0, sizeof *context);
- context->ibv_ctx.cmd_fd = cmd_fd;
-
- resp.status_page_size = 0;
- resp.reserved = 0;
- if (ibv_cmd_get_context(&context->ibv_ctx, &cmd, sizeof cmd,
- &resp.ibv_resp, sizeof resp))
- goto err_free;
-
- if (resp.reserved)
- PDBG("%s c4iw_alloc_ucontext_resp reserved field modified by kernel\n",
- __FUNCTION__);
-
- context->status_page_size = resp.status_page_size;
- if (resp.status_page_size) {
- context->status_page = mmap(NULL, resp.status_page_size,
- PROT_READ, MAP_SHARED, cmd_fd,
- resp.status_page_key);
- if (context->status_page == MAP_FAILED)
- goto err_free;
- }
-
- context->ibv_ctx.device = ibdev;
- context->ibv_ctx.ops = c4iw_ctx_ops;
-
- switch (rhp->chip_version) {
- case CHELSIO_T6:
- case CHELSIO_T5:
- case CHELSIO_T4:
- PDBG("%s T%d device\n", __FUNCTION__, rhp->chip_version);
- context->ibv_ctx.ops.async_event = c4iw_async_event;
- context->ibv_ctx.ops.post_send = c4iw_post_send;
- context->ibv_ctx.ops.post_recv = c4iw_post_receive;
- context->ibv_ctx.ops.poll_cq = c4iw_poll_cq;
- context->ibv_ctx.ops.req_notify_cq = c4iw_arm_cq;
- break;
- default:
- PDBG("%s unknown hca type %d\n", __FUNCTION__,
- rhp->chip_version);
- goto err_unmap;
- break;
- }
-
- if (!rhp->mmid2ptr) {
- int ret;
-
- ret = ibv_cmd_query_device(&context->ibv_ctx, &attr, &raw_fw_ver, &qcmd,
- sizeof qcmd);
- if (ret)
- goto err_unmap;
- rhp->max_mr = attr.max_mr;
- rhp->mmid2ptr = calloc(attr.max_mr, sizeof(void *));
- if (!rhp->mmid2ptr) {
- goto err_unmap;
- }
- rhp->max_qp = T4_QID_BASE + attr.max_cq;
- rhp->qpid2ptr = calloc(T4_QID_BASE + attr.max_cq, sizeof(void *));
- if (!rhp->qpid2ptr) {
- goto err_unmap;
- }
- rhp->max_cq = T4_QID_BASE + attr.max_cq;
- rhp->cqid2ptr = calloc(T4_QID_BASE + attr.max_cq, sizeof(void *));
- if (!rhp->cqid2ptr)
- goto err_unmap;
- }
-
- return &context->ibv_ctx;
-
-err_unmap:
- munmap(context->status_page, context->status_page_size);
-err_free:
- if (rhp->cqid2ptr)
- free(rhp->cqid2ptr);
- if (rhp->qpid2ptr)
- free(rhp->cqid2ptr);
- if (rhp->mmid2ptr)
- free(rhp->cqid2ptr);
- free(context);
- return NULL;
-}
-
-static void c4iw_free_context(struct ibv_context *ibctx)
-{
- struct c4iw_context *context = to_c4iw_context(ibctx);
-
- if (context->status_page_size)
- munmap(context->status_page, context->status_page_size);
- free(context);
-}
-
-static struct ibv_device_ops c4iw_dev_ops = {
- .alloc_context = c4iw_alloc_context,
- .free_context = c4iw_free_context
-};
-
-#ifdef STALL_DETECTION
-
-int stall_to;
-
-static void dump_cq(struct c4iw_cq *chp)
-{
- int i;
-
- fprintf(stderr,
- "CQ: %p id %u queue %p cidx 0x%08x sw_queue %p sw_cidx %d sw_pidx %d sw_in_use %d depth %u error %u gen %d "
- "cidx_inc %d bits_type_ts %016" PRIx64 " notempty %d\n", chp,
- chp->cq.cqid, chp->cq.queue, chp->cq.cidx,
- chp->cq.sw_queue, chp->cq.sw_cidx, chp->cq.sw_pidx, chp->cq.sw_in_use,
- chp->cq.size, chp->cq.error, chp->cq.gen, chp->cq.cidx_inc, be64_to_cpu(chp->cq.bits_type_ts),
- t4_cq_notempty(&chp->cq) || (chp->iq ? t4_iq_notempty(chp->iq) : 0));
-
- for (i=0; i < chp->cq.size; i++) {
- u64 *p = (u64 *)(chp->cq.queue + i);
-
- fprintf(stderr, "%02x: %016" PRIx64 " %016" PRIx64, i, be64_to_cpu(p[0]), be64_to_cpu(p[1]));
- if (i == chp->cq.cidx)
- fprintf(stderr, " <-- cidx\n");
- else
- fprintf(stderr, "\n");
- p+= 2;
- fprintf(stderr, "%02x: %016" PRIx64 " %016" PRIx64 "\n", i, be64_to_cpu(p[0]), be64_to_cpu(p[1]));
- p+= 2;
- fprintf(stderr, "%02x: %016" PRIx64 " %016" PRIx64 "\n", i, be64_to_cpu(p[0]), be64_to_cpu(p[1]));
- p+= 2;
- fprintf(stderr, "%02x: %016" PRIx64 " %016" PRIx64 "\n", i, be64_to_cpu(p[0]), be64_to_cpu(p[1]));
- p+= 2;
- }
-}
-
-static void dump_qp(struct c4iw_qp *qhp)
-{
- int i;
- int j;
- struct t4_swsqe *swsqe;
- struct t4_swrqe *swrqe;
- u16 cidx, pidx;
- u64 *p;
-
- fprintf(stderr,
- "QP: %p id %u error %d flushed %d qid_mask 0x%x\n"
- " SQ: id %u queue %p sw_queue %p cidx %u pidx %u in_use %u wq_pidx %u depth %u flags 0x%x flush_cidx %d\n"
- " RQ: id %u queue %p sw_queue %p cidx %u pidx %u in_use %u depth %u\n",
- qhp,
- qhp->wq.sq.qid,
- qhp->wq.error,
- qhp->wq.flushed,
- qhp->wq.qid_mask,
- qhp->wq.sq.qid,
- qhp->wq.sq.queue,
- qhp->wq.sq.sw_sq,
- qhp->wq.sq.cidx,
- qhp->wq.sq.pidx,
- qhp->wq.sq.in_use,
- qhp->wq.sq.wq_pidx,
- qhp->wq.sq.size,
- qhp->wq.sq.flags,
- qhp->wq.sq.flush_cidx,
- qhp->wq.rq.qid,
- qhp->wq.rq.queue,
- qhp->wq.rq.sw_rq,
- qhp->wq.rq.cidx,
- qhp->wq.rq.pidx,
- qhp->wq.rq.in_use,
- qhp->wq.rq.size);
- cidx = qhp->wq.sq.cidx;
- pidx = qhp->wq.sq.pidx;
- if (cidx != pidx)
- fprintf(stderr, "SQ: \n");
- while (cidx != pidx) {
- swsqe = &qhp->wq.sq.sw_sq[cidx];
- fprintf(stderr, "%04u: wr_id %016" PRIx64
- " sq_wptr %08x read_len %u opcode 0x%x "
- "complete %u signaled %u cqe %016" PRIx64 " %016" PRIx64 " %016" PRIx64 " %016" PRIx64 "\n",
- cidx,
- swsqe->wr_id,
- swsqe->idx,
- swsqe->read_len,
- swsqe->opcode,
- swsqe->complete,
- swsqe->signaled,
- cpu_to_be64(swsqe->cqe.u.flits[0]),
- cpu_to_be64(swsqe->cqe.u.flits[1]),
- cpu_to_be64((u64)swsqe->cqe.reserved),
- cpu_to_be64(swsqe->cqe.bits_type_ts));
- if (++cidx == qhp->wq.sq.size)
- cidx = 0;
- }
-
- fprintf(stderr, "SQ WQ: \n");
- p = (u64 *)qhp->wq.sq.queue;
- for (i=0; i < qhp->wq.sq.size * T4_SQ_NUM_SLOTS; i++) {
- for (j=0; j < T4_EQ_ENTRY_SIZE / 16; j++) {
- fprintf(stderr, "%04u %016" PRIx64 " %016" PRIx64 " ",
- i, ntohll(p[0]), ntohll(p[1]));
- if (j == 0 && i == qhp->wq.sq.wq_pidx)
- fprintf(stderr, " <-- pidx");
- fprintf(stderr, "\n");
- p += 2;
- }
- }
- cidx = qhp->wq.rq.cidx;
- pidx = qhp->wq.rq.pidx;
- if (cidx != pidx)
- fprintf(stderr, "RQ: \n");
- while (cidx != pidx) {
- swrqe = &qhp->wq.rq.sw_rq[cidx];
- fprintf(stderr, "%04u: wr_id %016" PRIx64 "\n",
- cidx,
- swrqe->wr_id );
- if (++cidx == qhp->wq.rq.size)
- cidx = 0;
- }
-
- fprintf(stderr, "RQ WQ: \n");
- p = (u64 *)qhp->wq.rq.queue;
- for (i=0; i < qhp->wq.rq.size * T4_RQ_NUM_SLOTS; i++) {
- for (j=0; j < T4_EQ_ENTRY_SIZE / 16; j++) {
- fprintf(stderr, "%04u %016" PRIx64 " %016" PRIx64 " ",
- i, ntohll(p[0]), ntohll(p[1]));
- if (j == 0 && i == qhp->wq.rq.pidx)
- fprintf(stderr, " <-- pidx");
- if (j == 0 && i == qhp->wq.rq.cidx)
- fprintf(stderr, " <-- cidx");
- fprintf(stderr, "\n");
- p+=2;
- }
- }
-}
-
-void dump_state()
-{
- struct c4iw_dev *dev;
- int i;
-
- fprintf(stderr, "STALL DETECTED:\n");
- SLIST_FOREACH(dev, &devices, list) {
- //pthread_spin_lock(&dev->lock);
- fprintf(stderr, "Device %s\n", dev->ibv_dev.name);
- for (i=0; i < dev->max_cq; i++) {
- if (dev->cqid2ptr[i]) {
- struct c4iw_cq *chp = dev->cqid2ptr[i];
- //pthread_spin_lock(&chp->lock);
- dump_cq(chp);
- //pthread_spin_unlock(&chp->lock);
- }
- }
- for (i=0; i < dev->max_qp; i++) {
- if (dev->qpid2ptr[i]) {
- struct c4iw_qp *qhp = dev->qpid2ptr[i];
- //pthread_spin_lock(&qhp->lock);
- dump_qp(qhp);
- //pthread_spin_unlock(&qhp->lock);
- }
- }
- //pthread_spin_unlock(&dev->lock);
- }
- fprintf(stderr, "DUMP COMPLETE:\n");
- fflush(stderr);
-}
-#endif /* end of STALL_DETECTION */
-
-/*
- * c4iw_abi_version is used to store ABI for iw_cxgb4 so the user mode library
- * can know if the driver supports the kernel mode db ringing.
- */
-int c4iw_abi_version = 1;
-
-static struct ibv_device *cxgb4_driver_init(const char *uverbs_sys_path,
- int abi_version)
-{
- char devstr[IBV_SYSFS_PATH_MAX], ibdev[16], value[128], *cp;
- char dev_str[IBV_SYSFS_PATH_MAX];
- struct c4iw_dev *dev;
- unsigned vendor, device, fw_maj, fw_min;
- int i;
- char devnum;
- char ib_param[16];
-
-#ifndef __linux__
- if (ibv_read_sysfs_file(uverbs_sys_path, "ibdev",
- ibdev, sizeof ibdev) < 0)
- return NULL;
-
- if (ibdev[0] == 't' && ibdev[1] >= '4' && ibdev[1] <= '6' &&
- strstr(&ibdev[2], "nex") && (devnum = atoi(&ibdev[5])) >= 0) {
- snprintf(dev_str, sizeof(dev_str), "/dev/t%cnex/%d", ibdev[1],
- devnum);
- } else
- return NULL;
-
- if (ibv_read_sysfs_file(dev_str, "\%pnpinfo", value, sizeof value) < 0)
- return NULL;
- else {
- if (strstr(value,"vendor=")) {
- strncpy(ib_param, strstr(value,"vendor=")+strlen("vendor="),6);
- sscanf(ib_param,"%i",&vendor);
- }
-
- if (strstr(value,"device=")) {
- strncpy(ib_param, strstr(value,"device=")+strlen("device="),6);
- sscanf(ib_param,"%i",&device);
- }
- }
-#else
- if (ibv_read_sysfs_file(uverbs_sys_path, "device/vendor",
- value, sizeof value) < 0)
- return NULL;
- sscanf(value, "%i", &vendor);
-
- if (ibv_read_sysfs_file(uverbs_sys_path, "device/device",
- value, sizeof value) < 0)
- return NULL;
- sscanf(value, "%i", &device);
-#endif
-
- for (i = 0; i < sizeof hca_table / sizeof hca_table[0]; ++i)
- if (vendor == hca_table[i].vendor &&
- device == hca_table[i].device)
- goto found;
-
- return NULL;
-
-found:
- c4iw_abi_version = abi_version;
-
-
-#ifndef __linux__
- if (ibv_read_sysfs_file(dev_str, "firmware_version",
- value, sizeof value) < 0)
- return NULL;
-#else
- /*
- * Verify that the firmware major number matches. Major number
- * mismatches are fatal. Minor number mismatches are tolerated.
- */
- if (ibv_read_sysfs_file(uverbs_sys_path, "ibdev",
- ibdev, sizeof ibdev) < 0)
- return NULL;
-
- memset(devstr, 0, sizeof devstr);
- snprintf(devstr, sizeof devstr, "%s/class/infiniband/%s",
- ibv_get_sysfs_path(), ibdev);
- if (ibv_read_sysfs_file(devstr, "fw_ver", value, sizeof value) < 0)
- return NULL;
-#endif
-
- cp = strtok(value+1, ".");
- sscanf(cp, "%i", &fw_maj);
- cp = strtok(NULL, ".");
- sscanf(cp, "%i", &fw_min);
-
- if (fw_maj < FW_MAJ) {
- fprintf(stderr, "libcxgb4: Fatal firmware version mismatch. "
- "Firmware major number is %u and libcxgb4 needs %u.\n",
- fw_maj, FW_MAJ);
- fflush(stderr);
- return NULL;
- }
-
- DBGLOG("libcxgb4");
-
- if (fw_min < FW_MIN) {
- PDBG("libcxgb4: non-fatal firmware version mismatch. "
- "Firmware minor number is %u and libcxgb4 needs %u.\n",
- fw_maj, FW_MAJ);
- fflush(stderr);
- }
-
- PDBG("%s found vendor %d device %d type %d\n",
- __FUNCTION__, vendor, device,
- CHELSIO_PCI_ID_CHIP_VERSION(hca_table[i].device));
-
- dev = calloc(1, sizeof *dev);
- if (!dev) {
- return NULL;
- }
-
- pthread_spin_init(&dev->lock, PTHREAD_PROCESS_PRIVATE);
- dev->ibv_dev.ops = c4iw_dev_ops;
- dev->chip_version = CHELSIO_PCI_ID_CHIP_VERSION(hca_table[i].device);
- dev->abi_version = abi_version;
-
- PDBG("%s device claimed\n", __FUNCTION__);
- SLIST_INSERT_HEAD(&devices, dev, list);
-#ifdef STALL_DETECTION
-{
- char *c = getenv("CXGB4_STALL_TIMEOUT");
- if (c) {
- stall_to = strtol(c, NULL, 0);
- if (errno || stall_to < 0)
- stall_to = 0;
- }
-}
-#endif
-{
- char *c = getenv("CXGB4_MA_WR");
- if (c) {
- ma_wr = strtol(c, NULL, 0);
- if (ma_wr != 1)
- ma_wr = 0;
- }
-}
-{
- char *c = getenv("T5_ENABLE_WC");
- if (c) {
- t5_en_wc = strtol(c, NULL, 0);
- if (t5_en_wc != 1)
- t5_en_wc = 0;
- }
-}
-
- return &dev->ibv_dev;
-}
-
-static __attribute__((constructor)) void cxgb4_register_driver(void)
-{
- c4iw_page_size = sysconf(_SC_PAGESIZE);
- c4iw_page_shift = long_log2(c4iw_page_size);
- c4iw_page_mask = ~(c4iw_page_size - 1);
- ibv_register_driver("cxgb4", cxgb4_driver_init);
-}
-
-#ifdef STATS
-void __attribute__ ((destructor)) cs_fini(void);
-void __attribute__ ((destructor)) cs_fini(void)
-{
- syslog(LOG_NOTICE, "cxgb4 stats - sends %lu recv %lu read %lu "
- "write %lu arm %lu cqe %lu mr %lu qp %lu cq %lu\n",
- c4iw_stats.send, c4iw_stats.recv, c4iw_stats.read,
- c4iw_stats.write, c4iw_stats.arm, c4iw_stats.cqe,
- c4iw_stats.mr, c4iw_stats.qp, c4iw_stats.cq);
-}
-#endif
diff --git a/contrib/ofed/libcxgb4/src/libcxgb4.h b/contrib/ofed/libcxgb4/src/libcxgb4.h
deleted file mode 100644
index 30afcf3..0000000
--- a/contrib/ofed/libcxgb4/src/libcxgb4.h
+++ /dev/null
@@ -1,262 +0,0 @@
-/*
- * Copyright (c) 2006-2014 Chelsio, Inc. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-#ifndef IWCH_H
-#define IWCH_H
-
-#include <pthread.h>
-#include <inttypes.h>
-#include <stddef.h>
-#include <string.h>
-#include <syslog.h>
-#include <sys/errno.h>
-#include <sys/time.h>
-#include <infiniband/driver.h>
-#include <infiniband/arch.h>
-#include "queue.h"
-#include "t4.h"
-
-extern unsigned long c4iw_page_size;
-extern unsigned long c4iw_page_shift;
-extern unsigned long c4iw_page_mask;
-
-struct c4iw_mr;
-
-struct c4iw_dev {
- struct ibv_device ibv_dev;
- unsigned chip_version;
- int max_mr;
- struct c4iw_mr **mmid2ptr;
- int max_qp;
- struct c4iw_qp **qpid2ptr;
- int max_cq;
- struct c4iw_cq **cqid2ptr;
- pthread_spinlock_t lock;
- SLIST_ENTRY(c4iw_dev) list;
- int abi_version;
-};
-
-static inline int dev_is_t5(struct c4iw_dev *dev)
-{
- return dev->chip_version == CHELSIO_T5;
-}
-
-static inline int dev_is_t4(struct c4iw_dev *dev)
-{
- return dev->chip_version == CHELSIO_T4;
-}
-
-struct c4iw_context {
- struct ibv_context ibv_ctx;
- struct t4_dev_status_page *status_page;
- int status_page_size;
-};
-
-struct c4iw_pd {
- struct ibv_pd ibv_pd;
-};
-
-struct c4iw_mr {
- struct ibv_mr ibv_mr;
- uint64_t va_fbo;
- uint32_t len;
-};
-
-static inline u32 c4iw_mmid(u32 stag)
-{
- return (stag >> 8);
-}
-
-struct c4iw_cq {
- struct ibv_cq ibv_cq;
- struct c4iw_dev *rhp;
- struct t4_cq cq;
- pthread_spinlock_t lock;
-#ifdef STALL_DETECTION
- struct timeval time;
- int dumped;
-#endif
-};
-
-struct c4iw_qp {
- struct ibv_qp ibv_qp;
- struct c4iw_dev *rhp;
- struct t4_wq wq;
- pthread_spinlock_t lock;
- int sq_sig_all;
-};
-
-#define to_c4iw_xxx(xxx, type) \
- ((struct c4iw_##type *) \
- ((void *) ib##xxx - offsetof(struct c4iw_##type, ibv_##xxx)))
-
-static inline struct c4iw_dev *to_c4iw_dev(struct ibv_device *ibdev)
-{
- return to_c4iw_xxx(dev, dev);
-}
-
-static inline struct c4iw_context *to_c4iw_context(struct ibv_context *ibctx)
-{
- return to_c4iw_xxx(ctx, context);
-}
-
-static inline struct c4iw_pd *to_c4iw_pd(struct ibv_pd *ibpd)
-{
- return to_c4iw_xxx(pd, pd);
-}
-
-static inline struct c4iw_cq *to_c4iw_cq(struct ibv_cq *ibcq)
-{
- return to_c4iw_xxx(cq, cq);
-}
-
-static inline struct c4iw_qp *to_c4iw_qp(struct ibv_qp *ibqp)
-{
- return to_c4iw_xxx(qp, qp);
-}
-
-static inline struct c4iw_mr *to_c4iw_mr(struct ibv_mr *ibmr)
-{
- return to_c4iw_xxx(mr, mr);
-}
-
-static inline struct c4iw_qp *get_qhp(struct c4iw_dev *rhp, u32 qid)
-{
- return rhp->qpid2ptr[qid];
-}
-
-static inline struct c4iw_cq *get_chp(struct c4iw_dev *rhp, u32 qid)
-{
- return rhp->cqid2ptr[qid];
-}
-
-static inline unsigned long_log2(unsigned long x)
-{
- unsigned r = 0;
- for (x >>= 1; x > 0; x >>= 1)
- r++;
- return r;
-}
-
-int c4iw_query_device(struct ibv_context *context,
- struct ibv_device_attr *attr);
-int c4iw_query_port(struct ibv_context *context, uint8_t port,
- struct ibv_port_attr *attr);
-
-struct ibv_pd *c4iw_alloc_pd(struct ibv_context *context);
-int c4iw_free_pd(struct ibv_pd *pd);
-
-struct ibv_mr *c4iw_reg_mr(struct ibv_pd *pd, void *addr,
- size_t length, int access);
-int c4iw_dereg_mr(struct ibv_mr *mr);
-
-struct ibv_cq *c4iw_create_cq(struct ibv_context *context, int cqe,
- struct ibv_comp_channel *channel,
- int comp_vector);
-int c4iw_resize_cq(struct ibv_cq *cq, int cqe);
-int c4iw_destroy_cq(struct ibv_cq *cq);
-int c4iw_poll_cq(struct ibv_cq *cq, int ne, struct ibv_wc *wc);
-int c4iw_arm_cq(struct ibv_cq *cq, int solicited);
-void c4iw_cq_event(struct ibv_cq *cq);
-void c4iw_init_cq_buf(struct c4iw_cq *cq, int nent);
-
-struct ibv_srq *c4iw_create_srq(struct ibv_pd *pd,
- struct ibv_srq_init_attr *attr);
-int c4iw_modify_srq(struct ibv_srq *srq,
- struct ibv_srq_attr *attr,
- int mask);
-int c4iw_destroy_srq(struct ibv_srq *srq);
-int c4iw_post_srq_recv(struct ibv_srq *ibsrq,
- struct ibv_recv_wr *wr,
- struct ibv_recv_wr **bad_wr);
-
-struct ibv_qp *c4iw_create_qp(struct ibv_pd *pd,
- struct ibv_qp_init_attr *attr);
-int c4iw_modify_qp(struct ibv_qp *qp, struct ibv_qp_attr *attr,
- int attr_mask);
-int c4iw_destroy_qp(struct ibv_qp *qp);
-int c4iw_query_qp(struct ibv_qp *qp,
- struct ibv_qp_attr *attr,
- int attr_mask,
- struct ibv_qp_init_attr *init_attr);
-void c4iw_flush_qp(struct c4iw_qp *qhp);
-void c4iw_flush_qps(struct c4iw_dev *dev);
-int c4iw_post_send(struct ibv_qp *ibqp, struct ibv_send_wr *wr,
- struct ibv_send_wr **bad_wr);
-int c4iw_post_receive(struct ibv_qp *ibqp, struct ibv_recv_wr *wr,
- struct ibv_recv_wr **bad_wr);
-struct ibv_ah *c4iw_create_ah(struct ibv_pd *pd,
- struct ibv_ah_attr *ah_attr);
-int c4iw_destroy_ah(struct ibv_ah *ah);
-int c4iw_attach_mcast(struct ibv_qp *qp, const union ibv_gid *gid,
- uint16_t lid);
-int c4iw_detach_mcast(struct ibv_qp *qp, const union ibv_gid *gid,
- uint16_t lid);
-void c4iw_async_event(struct ibv_async_event *event);
-void c4iw_flush_hw_cq(struct c4iw_cq *chp);
-int c4iw_flush_rq(struct t4_wq *wq, struct t4_cq *cq, int count);
-void c4iw_flush_sq(struct c4iw_qp *qhp);
-void c4iw_count_rcqes(struct t4_cq *cq, struct t4_wq *wq, int *count);
-
-#define FW_MAJ 0
-#define FW_MIN 0
-
-static inline unsigned long align(unsigned long val, unsigned long align)
-{
- return (val + align - 1) & ~(align - 1);
-}
-
-#ifdef STATS
-
-#define INC_STAT(a) { c4iw_stats.a++; }
-
-struct c4iw_stats {
- unsigned long send;
- unsigned long recv;
- unsigned long read;
- unsigned long write;
- unsigned long arm;
- unsigned long cqe;
- unsigned long mr;
- unsigned long qp;
- unsigned long cq;
-};
-extern struct c4iw_stats c4iw_stats;
-#else
-#define INC_STAT(a)
-#endif
-
-#ifdef STALL_DETECTION
-void dump_state();
-extern int stall_to;
-#endif
-
-#endif /* IWCH_H */
diff --git a/contrib/ofed/libcxgb4/src/qp.c b/contrib/ofed/libcxgb4/src/qp.c
deleted file mode 100644
index fced0f9..0000000
--- a/contrib/ofed/libcxgb4/src/qp.c
+++ /dev/null
@@ -1,548 +0,0 @@
-/*
- * Copyright (c) 2006-2014 Chelsio, Inc. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-#if HAVE_CONFIG_H
-# include <config.h>
-#endif /* HAVE_CONFIG_H */
-
-#include <assert.h>
-#include <stdlib.h>
-#include <pthread.h>
-#include <string.h>
-#include <stdio.h>
-#include <netinet/in.h>
-#include "libcxgb4.h"
-
-#ifdef STATS
-struct c4iw_stats c4iw_stats;
-#endif
-
-static void copy_wr_to_sq(struct t4_wq *wq, union t4_wr *wqe, u8 len16)
-{
- void *src, *dst;
- uintptr_t end;
- int total, len;
-
- src = &wqe->flits[0];
- dst = &wq->sq.queue->flits[wq->sq.wq_pidx *
- (T4_EQ_ENTRY_SIZE / sizeof(__be64))];
- if (t4_sq_onchip(wq)) {
- len16 = align(len16, 4);
- wc_wmb();
- }
-
- total = len16 * 16;
- end = (uintptr_t)&wq->sq.queue[wq->sq.size];
- if (__predict_true((uintptr_t)dst + total <= end)) {
- /* Won't wrap around. */
- memcpy(dst, src, total);
- } else {
- len = end - (uintptr_t)dst;
- memcpy(dst, src, len);
- memcpy(wq->sq.queue, src + len, total - len);
- }
-}
-
-static void copy_wr_to_rq(struct t4_wq *wq, union t4_recv_wr *wqe, u8 len16)
-{
- void *src, *dst;
- uintptr_t end;
- int total, len;
-
- src = &wqe->flits[0];
- dst = &wq->rq.queue->flits[wq->rq.wq_pidx *
- (T4_EQ_ENTRY_SIZE / sizeof(__be64))];
-
- total = len16 * 16;
- end = (uintptr_t)&wq->rq.queue[wq->rq.size];
- if (__predict_true((uintptr_t)dst + total <= end)) {
- /* Won't wrap around. */
- memcpy(dst, src, total);
- } else {
- len = end - (uintptr_t)dst;
- memcpy(dst, src, len);
- memcpy(wq->rq.queue, src + len, total - len);
- }
-}
-
-static int build_immd(struct t4_sq *sq, struct fw_ri_immd *immdp,
- struct ibv_send_wr *wr, int max, u32 *plenp)
-{
- u8 *dstp, *srcp;
- u32 plen = 0;
- int i;
- int len;
-
- dstp = (u8 *)immdp->data;
- for (i = 0; i < wr->num_sge; i++) {
- if ((plen + wr->sg_list[i].length) > max)
- return -EMSGSIZE;
- srcp = (u8 *)(unsigned long)wr->sg_list[i].addr;
- plen += wr->sg_list[i].length;
- len = wr->sg_list[i].length;
- memcpy(dstp, srcp, len);
- dstp += len;
- srcp += len;
- }
- len = ROUND_UP(plen + 8, 16) - (plen + 8);
- if (len)
- memset(dstp, 0, len);
- immdp->op = FW_RI_DATA_IMMD;
- immdp->r1 = 0;
- immdp->r2 = 0;
- immdp->immdlen = cpu_to_be32(plen);
- *plenp = plen;
- return 0;
-}
-
-static int build_isgl(struct fw_ri_isgl *isglp, struct ibv_sge *sg_list,
- int num_sge, u32 *plenp)
-{
- int i;
- u32 plen = 0;
- __be64 *flitp = (__be64 *)isglp->sge;
-
- for (i = 0; i < num_sge; i++) {
- if ((plen + sg_list[i].length) < plen)
- return -EMSGSIZE;
- plen += sg_list[i].length;
- *flitp++ = cpu_to_be64(((u64)sg_list[i].lkey << 32) |
- sg_list[i].length);
- *flitp++ = cpu_to_be64(sg_list[i].addr);
- }
- *flitp = 0;
- isglp->op = FW_RI_DATA_ISGL;
- isglp->r1 = 0;
- isglp->nsge = cpu_to_be16(num_sge);
- isglp->r2 = 0;
- if (plenp)
- *plenp = plen;
- return 0;
-}
-
-static int build_rdma_send(struct t4_sq *sq, union t4_wr *wqe,
- struct ibv_send_wr *wr, u8 *len16)
-{
- u32 plen;
- int size;
- int ret;
-
- if (wr->num_sge > T4_MAX_SEND_SGE)
- return -EINVAL;
- if (wr->send_flags & IBV_SEND_SOLICITED)
- wqe->send.sendop_pkd = cpu_to_be32(
- V_FW_RI_SEND_WR_SENDOP(FW_RI_SEND_WITH_SE));
- else
- wqe->send.sendop_pkd = cpu_to_be32(
- V_FW_RI_SEND_WR_SENDOP(FW_RI_SEND));
- wqe->send.stag_inv = 0;
- wqe->send.r3 = 0;
- wqe->send.r4 = 0;
-
- plen = 0;
- if (wr->num_sge) {
- if (wr->send_flags & IBV_SEND_INLINE) {
- ret = build_immd(sq, wqe->send.u.immd_src, wr,
- T4_MAX_SEND_INLINE, &plen);
- if (ret)
- return ret;
- size = sizeof wqe->send + sizeof(struct fw_ri_immd) +
- plen;
- } else {
- ret = build_isgl(wqe->send.u.isgl_src,
- wr->sg_list, wr->num_sge, &plen);
- if (ret)
- return ret;
- size = sizeof wqe->send + sizeof(struct fw_ri_isgl) +
- wr->num_sge * sizeof (struct fw_ri_sge);
- }
- } else {
- wqe->send.u.immd_src[0].op = FW_RI_DATA_IMMD;
- wqe->send.u.immd_src[0].r1 = 0;
- wqe->send.u.immd_src[0].r2 = 0;
- wqe->send.u.immd_src[0].immdlen = 0;
- size = sizeof wqe->send + sizeof(struct fw_ri_immd);
- plen = 0;
- }
- *len16 = DIV_ROUND_UP(size, 16);
- wqe->send.plen = cpu_to_be32(plen);
- return 0;
-}
-
-static int build_rdma_write(struct t4_sq *sq, union t4_wr *wqe,
- struct ibv_send_wr *wr, u8 *len16)
-{
- u32 plen;
- int size;
- int ret;
-
- if (wr->num_sge > T4_MAX_SEND_SGE)
- return -EINVAL;
- wqe->write.r2 = 0;
- wqe->write.stag_sink = cpu_to_be32(wr->wr.rdma.rkey);
- wqe->write.to_sink = cpu_to_be64(wr->wr.rdma.remote_addr);
- if (wr->num_sge) {
- if (wr->send_flags & IBV_SEND_INLINE) {
- ret = build_immd(sq, wqe->write.u.immd_src, wr,
- T4_MAX_WRITE_INLINE, &plen);
- if (ret)
- return ret;
- size = sizeof wqe->write + sizeof(struct fw_ri_immd) +
- plen;
- } else {
- ret = build_isgl(wqe->write.u.isgl_src,
- wr->sg_list, wr->num_sge, &plen);
- if (ret)
- return ret;
- size = sizeof wqe->write + sizeof(struct fw_ri_isgl) +
- wr->num_sge * sizeof (struct fw_ri_sge);
- }
- } else {
- wqe->write.u.immd_src[0].op = FW_RI_DATA_IMMD;
- wqe->write.u.immd_src[0].r1 = 0;
- wqe->write.u.immd_src[0].r2 = 0;
- wqe->write.u.immd_src[0].immdlen = 0;
- size = sizeof wqe->write + sizeof(struct fw_ri_immd);
- plen = 0;
- }
- *len16 = DIV_ROUND_UP(size, 16);
- wqe->write.plen = cpu_to_be32(plen);
- return 0;
-}
-
-static int build_rdma_read(union t4_wr *wqe, struct ibv_send_wr *wr, u8 *len16)
-{
- if (wr->num_sge > 1)
- return -EINVAL;
- if (wr->num_sge) {
- wqe->read.stag_src = cpu_to_be32(wr->wr.rdma.rkey);
- wqe->read.to_src_hi = cpu_to_be32((u32)(wr->wr.rdma.remote_addr >>32));
- wqe->read.to_src_lo = cpu_to_be32((u32)wr->wr.rdma.remote_addr);
- wqe->read.stag_sink = cpu_to_be32(wr->sg_list[0].lkey);
- wqe->read.plen = cpu_to_be32(wr->sg_list[0].length);
- wqe->read.to_sink_hi = cpu_to_be32((u32)(wr->sg_list[0].addr >> 32));
- wqe->read.to_sink_lo = cpu_to_be32((u32)(wr->sg_list[0].addr));
- } else {
- wqe->read.stag_src = cpu_to_be32(2);
- wqe->read.to_src_hi = 0;
- wqe->read.to_src_lo = 0;
- wqe->read.stag_sink = cpu_to_be32(2);
- wqe->read.plen = 0;
- wqe->read.to_sink_hi = 0;
- wqe->read.to_sink_lo = 0;
- }
- wqe->read.r2 = 0;
- wqe->read.r5 = 0;
- *len16 = DIV_ROUND_UP(sizeof wqe->read, 16);
- return 0;
-}
-
-static int build_rdma_recv(struct c4iw_qp *qhp, union t4_recv_wr *wqe,
- struct ibv_recv_wr *wr, u8 *len16)
-{
- int ret;
-
- ret = build_isgl(&wqe->recv.isgl, wr->sg_list, wr->num_sge, NULL);
- if (ret)
- return ret;
- *len16 = DIV_ROUND_UP(sizeof wqe->recv +
- wr->num_sge * sizeof(struct fw_ri_sge), 16);
- return 0;
-}
-
-void dump_wqe(void *arg)
-{
- u64 *p = arg;
- int len16;
-
- len16 = be64_to_cpu(*p) & 0xff;
- while (len16--) {
- printf("%02x: %016lx ", (u8)(unsigned long)p, be64_to_cpu(*p));
- p++;
- printf("%016lx\n", be64_to_cpu(*p));
- p++;
- }
-}
-
-static void ring_kernel_db(struct c4iw_qp *qhp, u32 qid, u16 idx)
-{
- struct ibv_modify_qp cmd;
- struct ibv_qp_attr attr;
- int mask;
- int ret;
-
- wc_wmb();
- if (qid == qhp->wq.sq.qid) {
- attr.sq_psn = idx;
- mask = IBV_QP_SQ_PSN;
- } else {
- attr.rq_psn = idx;
- mask = IBV_QP_RQ_PSN;
- }
- ret = ibv_cmd_modify_qp(&qhp->ibv_qp, &attr, mask, &cmd, sizeof cmd);
- assert(!ret);
-}
-
-int c4iw_post_send(struct ibv_qp *ibqp, struct ibv_send_wr *wr,
- struct ibv_send_wr **bad_wr)
-{
- int err = 0;
- u8 len16;
- enum fw_wr_opcodes fw_opcode;
- enum fw_ri_wr_flags fw_flags;
- struct c4iw_qp *qhp;
- union t4_wr *wqe, lwqe;
- u32 num_wrs;
- struct t4_swsqe *swsqe;
- u16 idx = 0;
-
- qhp = to_c4iw_qp(ibqp);
- pthread_spin_lock(&qhp->lock);
- if (t4_wq_in_error(&qhp->wq)) {
- pthread_spin_unlock(&qhp->lock);
- return -EINVAL;
- }
- num_wrs = t4_sq_avail(&qhp->wq);
- if (num_wrs == 0) {
- pthread_spin_unlock(&qhp->lock);
- return -ENOMEM;
- }
- while (wr) {
- if (num_wrs == 0) {
- err = -ENOMEM;
- *bad_wr = wr;
- break;
- }
-
- wqe = &lwqe;
- fw_flags = 0;
- if (wr->send_flags & IBV_SEND_SOLICITED)
- fw_flags |= FW_RI_SOLICITED_EVENT_FLAG;
- if (wr->send_flags & IBV_SEND_SIGNALED || qhp->sq_sig_all)
- fw_flags |= FW_RI_COMPLETION_FLAG;
- swsqe = &qhp->wq.sq.sw_sq[qhp->wq.sq.pidx];
- switch (wr->opcode) {
- case IBV_WR_SEND:
- INC_STAT(send);
- if (wr->send_flags & IBV_SEND_FENCE)
- fw_flags |= FW_RI_READ_FENCE_FLAG;
- fw_opcode = FW_RI_SEND_WR;
- swsqe->opcode = FW_RI_SEND;
- err = build_rdma_send(&qhp->wq.sq, wqe, wr, &len16);
- break;
- case IBV_WR_RDMA_WRITE:
- INC_STAT(write);
- fw_opcode = FW_RI_RDMA_WRITE_WR;
- swsqe->opcode = FW_RI_RDMA_WRITE;
- err = build_rdma_write(&qhp->wq.sq, wqe, wr, &len16);
- break;
- case IBV_WR_RDMA_READ:
- INC_STAT(read);
- fw_opcode = FW_RI_RDMA_READ_WR;
- swsqe->opcode = FW_RI_READ_REQ;
- fw_flags = 0;
- err = build_rdma_read(wqe, wr, &len16);
- if (err)
- break;
- swsqe->read_len = wr->sg_list ? wr->sg_list[0].length : 0;
- if (!qhp->wq.sq.oldest_read)
- qhp->wq.sq.oldest_read = swsqe;
- break;
- default:
- PDBG("%s post of type=%d TBD!\n", __func__,
- wr->opcode);
- err = -EINVAL;
- }
- if (err) {
- *bad_wr = wr;
- break;
- }
- swsqe->idx = qhp->wq.sq.pidx;
- swsqe->complete = 0;
- swsqe->signaled = (wr->send_flags & IBV_SEND_SIGNALED) ||
- qhp->sq_sig_all;
- swsqe->flushed = 0;
- swsqe->wr_id = wr->wr_id;
-
- init_wr_hdr(wqe, qhp->wq.sq.pidx, fw_opcode, fw_flags, len16);
- PDBG("%s cookie 0x%llx pidx 0x%x opcode 0x%x\n",
- __func__, (unsigned long long)wr->wr_id, qhp->wq.sq.pidx,
- swsqe->opcode);
- wr = wr->next;
- num_wrs--;
- copy_wr_to_sq(&qhp->wq, wqe, len16);
- t4_sq_produce(&qhp->wq, len16);
- idx += DIV_ROUND_UP(len16*16, T4_EQ_ENTRY_SIZE);
- }
-
- t4_ring_sq_db(&qhp->wq, idx, dev_is_t4(qhp->rhp),
- len16, wqe);
- qhp->wq.sq.queue[qhp->wq.sq.size].status.host_wq_pidx = \
- (qhp->wq.sq.wq_pidx);
- pthread_spin_unlock(&qhp->lock);
- return err;
-}
-
-int c4iw_post_receive(struct ibv_qp *ibqp, struct ibv_recv_wr *wr,
- struct ibv_recv_wr **bad_wr)
-{
- int err = 0;
- struct c4iw_qp *qhp;
- union t4_recv_wr *wqe, lwqe;
- u32 num_wrs;
- u8 len16 = 0;
- u16 idx = 0;
-
- qhp = to_c4iw_qp(ibqp);
- pthread_spin_lock(&qhp->lock);
- if (t4_wq_in_error(&qhp->wq)) {
- pthread_spin_unlock(&qhp->lock);
- return -EINVAL;
- }
- INC_STAT(recv);
- num_wrs = t4_rq_avail(&qhp->wq);
- if (num_wrs == 0) {
- pthread_spin_unlock(&qhp->lock);
- return -ENOMEM;
- }
- while (wr) {
- if (wr->num_sge > T4_MAX_RECV_SGE) {
- err = -EINVAL;
- *bad_wr = wr;
- break;
- }
- wqe = &lwqe;
- if (num_wrs)
- err = build_rdma_recv(qhp, wqe, wr, &len16);
- else
- err = -ENOMEM;
- if (err) {
- *bad_wr = wr;
- break;
- }
-
- qhp->wq.rq.sw_rq[qhp->wq.rq.pidx].wr_id = wr->wr_id;
-
- wqe->recv.opcode = FW_RI_RECV_WR;
- wqe->recv.r1 = 0;
- wqe->recv.wrid = qhp->wq.rq.pidx;
- wqe->recv.r2[0] = 0;
- wqe->recv.r2[1] = 0;
- wqe->recv.r2[2] = 0;
- wqe->recv.len16 = len16;
- PDBG("%s cookie 0x%llx pidx %u\n", __func__,
- (unsigned long long) wr->wr_id, qhp->wq.rq.pidx);
- copy_wr_to_rq(&qhp->wq, wqe, len16);
- t4_rq_produce(&qhp->wq, len16);
- idx += DIV_ROUND_UP(len16*16, T4_EQ_ENTRY_SIZE);
- wr = wr->next;
- num_wrs--;
- }
-
- t4_ring_rq_db(&qhp->wq, idx, dev_is_t4(qhp->rhp),
- len16, wqe);
- qhp->wq.rq.queue[qhp->wq.rq.size].status.host_wq_pidx = \
- (qhp->wq.rq.wq_pidx);
- pthread_spin_unlock(&qhp->lock);
- return err;
-}
-
-static void update_qp_state(struct c4iw_qp *qhp)
-{
- struct ibv_query_qp cmd;
- struct ibv_qp_attr attr;
- struct ibv_qp_init_attr iattr;
- int ret;
-
- ret = ibv_cmd_query_qp(&qhp->ibv_qp, &attr, IBV_QP_STATE, &iattr,
- &cmd, sizeof cmd);
- assert(!ret);
- if (!ret)
- qhp->ibv_qp.state = attr.qp_state;
-}
-
-/*
- * Assumes qhp lock is held.
- */
-void c4iw_flush_qp(struct c4iw_qp *qhp)
-{
- struct c4iw_cq *rchp, *schp;
- int count;
-
- if (qhp->wq.flushed)
- return;
-
- update_qp_state(qhp);
-
- rchp = to_c4iw_cq(qhp->ibv_qp.recv_cq);
- schp = to_c4iw_cq(qhp->ibv_qp.send_cq);
-
- PDBG("%s qhp %p rchp %p schp %p\n", __func__, qhp, rchp, schp);
- qhp->wq.flushed = 1;
- pthread_spin_unlock(&qhp->lock);
-
- /* locking heirarchy: cq lock first, then qp lock. */
- pthread_spin_lock(&rchp->lock);
- pthread_spin_lock(&qhp->lock);
- c4iw_flush_hw_cq(rchp);
- c4iw_count_rcqes(&rchp->cq, &qhp->wq, &count);
- c4iw_flush_rq(&qhp->wq, &rchp->cq, count);
- pthread_spin_unlock(&qhp->lock);
- pthread_spin_unlock(&rchp->lock);
-
- /* locking heirarchy: cq lock first, then qp lock. */
- pthread_spin_lock(&schp->lock);
- pthread_spin_lock(&qhp->lock);
- if (schp != rchp)
- c4iw_flush_hw_cq(schp);
- c4iw_flush_sq(qhp);
- pthread_spin_unlock(&qhp->lock);
- pthread_spin_unlock(&schp->lock);
- pthread_spin_lock(&qhp->lock);
-}
-
-void c4iw_flush_qps(struct c4iw_dev *dev)
-{
- int i;
-
- pthread_spin_lock(&dev->lock);
- for (i=0; i < dev->max_qp; i++) {
- struct c4iw_qp *qhp = dev->qpid2ptr[i];
- if (qhp) {
- if (!qhp->wq.flushed && t4_wq_in_error(&qhp->wq)) {
- pthread_spin_lock(&qhp->lock);
- c4iw_flush_qp(qhp);
- pthread_spin_unlock(&qhp->lock);
- }
- }
- }
- pthread_spin_unlock(&dev->lock);
-}
diff --git a/contrib/ofed/libcxgb4/src/queue.h b/contrib/ofed/libcxgb4/src/queue.h
deleted file mode 100644
index c97b6f4..0000000
--- a/contrib/ofed/libcxgb4/src/queue.h
+++ /dev/null
@@ -1,650 +0,0 @@
-/*
- * Copyright (c) 2014 Chelsio, Inc. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-/*-
- * Copyright (c) 1991, 1993
- * The Regents of the University of California. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * @(#)queue.h 8.5 (Berkeley) 8/20/94
- * $FreeBSD$
- */
-
-#ifndef _SYS_QUEUE_H_
-#define _SYS_QUEUE_H_
-
-#include <sys/cdefs.h>
-
-/*
- * This file defines four types of data structures: singly-linked lists,
- * singly-linked tail queues, lists and tail queues.
- *
- * A singly-linked list is headed by a single forward pointer. The elements
- * are singly linked for minimum space and pointer manipulation overhead at
- * the expense of O(n) removal for arbitrary elements. New elements can be
- * added to the list after an existing element or at the head of the list.
- * Elements being removed from the head of the list should use the explicit
- * macro for this purpose for optimum efficiency. A singly-linked list may
- * only be traversed in the forward direction. Singly-linked lists are ideal
- * for applications with large datasets and few or no removals or for
- * implementing a LIFO queue.
- *
- * A singly-linked tail queue is headed by a pair of pointers, one to the
- * head of the list and the other to the tail of the list. The elements are
- * singly linked for minimum space and pointer manipulation overhead at the
- * expense of O(n) removal for arbitrary elements. New elements can be added
- * to the list after an existing element, at the head of the list, or at the
- * end of the list. Elements being removed from the head of the tail queue
- * should use the explicit macro for this purpose for optimum efficiency.
- * A singly-linked tail queue may only be traversed in the forward direction.
- * Singly-linked tail queues are ideal for applications with large datasets
- * and few or no removals or for implementing a FIFO queue.
- *
- * A list is headed by a single forward pointer (or an array of forward
- * pointers for a hash table header). The elements are doubly linked
- * so that an arbitrary element can be removed without a need to
- * traverse the list. New elements can be added to the list before
- * or after an existing element or at the head of the list. A list
- * may only be traversed in the forward direction.
- *
- * A tail queue is headed by a pair of pointers, one to the head of the
- * list and the other to the tail of the list. The elements are doubly
- * linked so that an arbitrary element can be removed without a need to
- * traverse the list. New elements can be added to the list before or
- * after an existing element, at the head of the list, or at the end of
- * the list. A tail queue may be traversed in either direction.
- *
- * For details on the use of these macros, see the queue(3) manual page.
- *
- *
- * SLIST LIST STAILQ TAILQ
- * _HEAD + + + +
- * _HEAD_INITIALIZER + + + +
- * _ENTRY + + + +
- * _INIT + + + +
- * _EMPTY + + + +
- * _FIRST + + + +
- * _NEXT + + + +
- * _PREV - - - +
- * _LAST - - + +
- * _FOREACH + + + +
- * _FOREACH_SAFE + + + +
- * _FOREACH_REVERSE - - - +
- * _FOREACH_REVERSE_SAFE - - - +
- * _INSERT_HEAD + + + +
- * _INSERT_BEFORE - + - +
- * _INSERT_AFTER + + + +
- * _INSERT_TAIL - - + +
- * _CONCAT - - + +
- * _REMOVE_HEAD + - + -
- * _REMOVE + + + +
- *
- */
-#ifdef QUEUE_MACRO_DEBUG
-/* Store the last 2 places the queue element or head was altered */
-struct qm_trace {
- char * lastfile;
- int lastline;
- char * prevfile;
- int prevline;
-};
-
-#define TRACEBUF struct qm_trace trace;
-#define TRASHIT(x) do {(x) = (void *)-1;} while (0)
-
-#define QMD_TRACE_HEAD(head) do { \
- (head)->trace.prevline = (head)->trace.lastline; \
- (head)->trace.prevfile = (head)->trace.lastfile; \
- (head)->trace.lastline = __LINE__; \
- (head)->trace.lastfile = __FILE__; \
-} while (0)
-
-#define QMD_TRACE_ELEM(elem) do { \
- (elem)->trace.prevline = (elem)->trace.lastline; \
- (elem)->trace.prevfile = (elem)->trace.lastfile; \
- (elem)->trace.lastline = __LINE__; \
- (elem)->trace.lastfile = __FILE__; \
-} while (0)
-
-#else
-#define QMD_TRACE_ELEM(elem)
-#define QMD_TRACE_HEAD(head)
-#define TRACEBUF
-#define TRASHIT(x)
-#endif /* QUEUE_MACRO_DEBUG */
-
-/*
- * Singly-linked List declarations.
- */
-#define SLIST_HEAD(name, type) \
-struct name { \
- struct type *slh_first; /* first element */ \
-}
-
-#define SLIST_HEAD_INITIALIZER(head) \
- { NULL }
-
-#define SLIST_ENTRY(type) \
-struct { \
- struct type *sle_next; /* next element */ \
-}
-
-/*
- * Singly-linked List functions.
- */
-#define SLIST_EMPTY(head) ((head)->slh_first == NULL)
-
-#define SLIST_FIRST(head) ((head)->slh_first)
-
-#define SLIST_FOREACH(var, head, field) \
- for ((var) = SLIST_FIRST((head)); \
- (var); \
- (var) = SLIST_NEXT((var), field))
-
-#define SLIST_FOREACH_SAFE(var, head, field, tvar) \
- for ((var) = SLIST_FIRST((head)); \
- (var) && ((tvar) = SLIST_NEXT((var), field), 1); \
- (var) = (tvar))
-
-#define SLIST_FOREACH_PREVPTR(var, varp, head, field) \
- for ((varp) = &SLIST_FIRST((head)); \
- ((var) = *(varp)) != NULL; \
- (varp) = &SLIST_NEXT((var), field))
-
-#define SLIST_INIT(head) do { \
- SLIST_FIRST((head)) = NULL; \
-} while (0)
-
-#define SLIST_INSERT_AFTER(slistelm, elm, field) do { \
- SLIST_NEXT((elm), field) = SLIST_NEXT((slistelm), field); \
- SLIST_NEXT((slistelm), field) = (elm); \
-} while (0)
-
-#define SLIST_INSERT_HEAD(head, elm, field) do { \
- SLIST_NEXT((elm), field) = SLIST_FIRST((head)); \
- SLIST_FIRST((head)) = (elm); \
-} while (0)
-
-#define SLIST_NEXT(elm, field) ((elm)->field.sle_next)
-
-#define SLIST_REMOVE(head, elm, type, field) do { \
- if (SLIST_FIRST((head)) == (elm)) { \
- SLIST_REMOVE_HEAD((head), field); \
- } \
- else { \
- struct type *curelm = SLIST_FIRST((head)); \
- while (SLIST_NEXT(curelm, field) != (elm)) \
- curelm = SLIST_NEXT(curelm, field); \
- SLIST_NEXT(curelm, field) = \
- SLIST_NEXT(SLIST_NEXT(curelm, field), field); \
- } \
- TRASHIT((elm)->field.sle_next); \
-} while (0)
-
-#define SLIST_REMOVE_HEAD(head, field) do { \
- SLIST_FIRST((head)) = SLIST_NEXT(SLIST_FIRST((head)), field); \
-} while (0)
-
-/*
- * Singly-linked Tail queue declarations.
- */
-#define STAILQ_HEAD(name, type) \
-struct name { \
- struct type *stqh_first;/* first element */ \
- struct type **stqh_last;/* addr of last next element */ \
-}
-
-#define STAILQ_HEAD_INITIALIZER(head) \
- { NULL, &(head).stqh_first }
-
-#define STAILQ_ENTRY(type) \
-struct { \
- struct type *stqe_next; /* next element */ \
-}
-
-/*
- * Singly-linked Tail queue functions.
- */
-#define STAILQ_CONCAT(head1, head2) do { \
- if (!STAILQ_EMPTY((head2))) { \
- *(head1)->stqh_last = (head2)->stqh_first; \
- (head1)->stqh_last = (head2)->stqh_last; \
- STAILQ_INIT((head2)); \
- } \
-} while (0)
-
-#define STAILQ_EMPTY(head) ((head)->stqh_first == NULL)
-
-#define STAILQ_FIRST(head) ((head)->stqh_first)
-
-#define STAILQ_FOREACH(var, head, field) \
- for((var) = STAILQ_FIRST((head)); \
- (var); \
- (var) = STAILQ_NEXT((var), field))
-
-
-#define STAILQ_FOREACH_SAFE(var, head, field, tvar) \
- for ((var) = STAILQ_FIRST((head)); \
- (var) && ((tvar) = STAILQ_NEXT((var), field), 1); \
- (var) = (tvar))
-
-#define STAILQ_INIT(head) do { \
- STAILQ_FIRST((head)) = NULL; \
- (head)->stqh_last = &STAILQ_FIRST((head)); \
-} while (0)
-
-#define STAILQ_INSERT_AFTER(head, tqelm, elm, field) do { \
- if ((STAILQ_NEXT((elm), field) = STAILQ_NEXT((tqelm), field)) == NULL)\
- (head)->stqh_last = &STAILQ_NEXT((elm), field); \
- STAILQ_NEXT((tqelm), field) = (elm); \
-} while (0)
-
-#define STAILQ_INSERT_HEAD(head, elm, field) do { \
- if ((STAILQ_NEXT((elm), field) = STAILQ_FIRST((head))) == NULL) \
- (head)->stqh_last = &STAILQ_NEXT((elm), field); \
- STAILQ_FIRST((head)) = (elm); \
-} while (0)
-
-#define STAILQ_INSERT_TAIL(head, elm, field) do { \
- STAILQ_NEXT((elm), field) = NULL; \
- *(head)->stqh_last = (elm); \
- (head)->stqh_last = &STAILQ_NEXT((elm), field); \
-} while (0)
-
-#define STAILQ_LAST(head, type, field) \
- (STAILQ_EMPTY((head)) ? \
- NULL : \
- ((struct type *)(void *) \
- ((char *)((head)->stqh_last) - __offsetof(struct type, field))))
-
-#define STAILQ_NEXT(elm, field) ((elm)->field.stqe_next)
-
-#define STAILQ_REMOVE(head, elm, type, field) do { \
- if (STAILQ_FIRST((head)) == (elm)) { \
- STAILQ_REMOVE_HEAD((head), field); \
- } \
- else { \
- struct type *curelm = STAILQ_FIRST((head)); \
- while (STAILQ_NEXT(curelm, field) != (elm)) \
- curelm = STAILQ_NEXT(curelm, field); \
- if ((STAILQ_NEXT(curelm, field) = \
- STAILQ_NEXT(STAILQ_NEXT(curelm, field), field)) == NULL)\
- (head)->stqh_last = &STAILQ_NEXT((curelm), field);\
- } \
- TRASHIT((elm)->field.stqe_next); \
-} while (0)
-
-#define STAILQ_REMOVE_HEAD(head, field) do { \
- if ((STAILQ_FIRST((head)) = \
- STAILQ_NEXT(STAILQ_FIRST((head)), field)) == NULL) \
- (head)->stqh_last = &STAILQ_FIRST((head)); \
-} while (0)
-
-/*
- * List declarations.
- */
-#define LIST_HEAD(name, type) \
-struct name { \
- struct type *lh_first; /* first element */ \
-}
-
-#define LIST_HEAD_INITIALIZER(head) \
- { NULL }
-
-#define LIST_ENTRY(type) \
-struct { \
- struct type *le_next; /* next element */ \
- struct type **le_prev; /* address of previous next element */ \
-}
-
-/*
- * List functions.
- */
-
-#if (defined(_KERNEL) && defined(INVARIANTS))
-#define QMD_LIST_CHECK_HEAD(head, field) do { \
- if (LIST_FIRST((head)) != NULL && \
- LIST_FIRST((head))->field.le_prev != \
- &LIST_FIRST((head))) \
- panic("Bad list head %p first->prev != head", (head)); \
-} while (0)
-
-#define QMD_LIST_CHECK_NEXT(elm, field) do { \
- if (LIST_NEXT((elm), field) != NULL && \
- LIST_NEXT((elm), field)->field.le_prev != \
- &((elm)->field.le_next)) \
- panic("Bad link elm %p next->prev != elm", (elm)); \
-} while (0)
-
-#define QMD_LIST_CHECK_PREV(elm, field) do { \
- if (*(elm)->field.le_prev != (elm)) \
- panic("Bad link elm %p prev->next != elm", (elm)); \
-} while (0)
-#else
-#define QMD_LIST_CHECK_HEAD(head, field)
-#define QMD_LIST_CHECK_NEXT(elm, field)
-#define QMD_LIST_CHECK_PREV(elm, field)
-#endif /* (_KERNEL && INVARIANTS) */
-
-#define LIST_EMPTY(head) ((head)->lh_first == NULL)
-
-#define LIST_FIRST(head) ((head)->lh_first)
-
-#define LIST_FOREACH(var, head, field) \
- for ((var) = LIST_FIRST((head)); \
- (var); \
- (var) = LIST_NEXT((var), field))
-
-#define LIST_FOREACH_SAFE(var, head, field, tvar) \
- for ((var) = LIST_FIRST((head)); \
- (var) && ((tvar) = LIST_NEXT((var), field), 1); \
- (var) = (tvar))
-
-#define LIST_INIT(head) do { \
- LIST_FIRST((head)) = NULL; \
-} while (0)
-
-#define LIST_INSERT_AFTER(listelm, elm, field) do { \
- QMD_LIST_CHECK_NEXT(listelm, field); \
- if ((LIST_NEXT((elm), field) = LIST_NEXT((listelm), field)) != NULL)\
- LIST_NEXT((listelm), field)->field.le_prev = \
- &LIST_NEXT((elm), field); \
- LIST_NEXT((listelm), field) = (elm); \
- (elm)->field.le_prev = &LIST_NEXT((listelm), field); \
-} while (0)
-
-#define LIST_INSERT_BEFORE(listelm, elm, field) do { \
- QMD_LIST_CHECK_PREV(listelm, field); \
- (elm)->field.le_prev = (listelm)->field.le_prev; \
- LIST_NEXT((elm), field) = (listelm); \
- *(listelm)->field.le_prev = (elm); \
- (listelm)->field.le_prev = &LIST_NEXT((elm), field); \
-} while (0)
-
-#define LIST_INSERT_HEAD(head, elm, field) do { \
- QMD_LIST_CHECK_HEAD((head), field); \
- if ((LIST_NEXT((elm), field) = LIST_FIRST((head))) != NULL) \
- LIST_FIRST((head))->field.le_prev = &LIST_NEXT((elm), field);\
- LIST_FIRST((head)) = (elm); \
- (elm)->field.le_prev = &LIST_FIRST((head)); \
-} while (0)
-
-#define LIST_NEXT(elm, field) ((elm)->field.le_next)
-
-#define LIST_REMOVE(elm, field) do { \
- QMD_LIST_CHECK_NEXT(elm, field); \
- QMD_LIST_CHECK_PREV(elm, field); \
- if (LIST_NEXT((elm), field) != NULL) \
- LIST_NEXT((elm), field)->field.le_prev = \
- (elm)->field.le_prev; \
- *(elm)->field.le_prev = LIST_NEXT((elm), field); \
- TRASHIT((elm)->field.le_next); \
- TRASHIT((elm)->field.le_prev); \
-} while (0)
-
-/*
- * Tail queue declarations.
- */
-#define TAILQ_HEAD(name, type) \
-struct name { \
- struct type *tqh_first; /* first element */ \
- struct type **tqh_last; /* addr of last next element */ \
- TRACEBUF \
-}
-
-#define TAILQ_HEAD_INITIALIZER(head) \
- { NULL, &(head).tqh_first }
-
-#define TAILQ_ENTRY(type) \
-struct { \
- struct type *tqe_next; /* next element */ \
- struct type **tqe_prev; /* address of previous next element */ \
- TRACEBUF \
-}
-
-/*
- * Tail queue functions.
- */
-#if (defined(_KERNEL) && defined(INVARIANTS))
-#define QMD_TAILQ_CHECK_HEAD(head, field) do { \
- if (!TAILQ_EMPTY(head) && \
- TAILQ_FIRST((head))->field.tqe_prev != \
- &TAILQ_FIRST((head))) \
- panic("Bad tailq head %p first->prev != head", (head)); \
-} while (0)
-
-#define QMD_TAILQ_CHECK_TAIL(head, field) do { \
- if (*(head)->tqh_last != NULL) \
- panic("Bad tailq NEXT(%p->tqh_last) != NULL", (head)); \
-} while (0)
-
-#define QMD_TAILQ_CHECK_NEXT(elm, field) do { \
- if (TAILQ_NEXT((elm), field) != NULL && \
- TAILQ_NEXT((elm), field)->field.tqe_prev != \
- &((elm)->field.tqe_next)) \
- panic("Bad link elm %p next->prev != elm", (elm)); \
-} while (0)
-
-#define QMD_TAILQ_CHECK_PREV(elm, field) do { \
- if (*(elm)->field.tqe_prev != (elm)) \
- panic("Bad link elm %p prev->next != elm", (elm)); \
-} while (0)
-#else
-#define QMD_TAILQ_CHECK_HEAD(head, field)
-#define QMD_TAILQ_CHECK_TAIL(head, headname)
-#define QMD_TAILQ_CHECK_NEXT(elm, field)
-#define QMD_TAILQ_CHECK_PREV(elm, field)
-#endif /* (_KERNEL && INVARIANTS) */
-
-#define TAILQ_CONCAT(head1, head2, field) do { \
- if (!TAILQ_EMPTY(head2)) { \
- *(head1)->tqh_last = (head2)->tqh_first; \
- (head2)->tqh_first->field.tqe_prev = (head1)->tqh_last; \
- (head1)->tqh_last = (head2)->tqh_last; \
- TAILQ_INIT((head2)); \
- QMD_TRACE_HEAD(head1); \
- QMD_TRACE_HEAD(head2); \
- } \
-} while (0)
-
-#define TAILQ_EMPTY(head) ((head)->tqh_first == NULL)
-
-#define TAILQ_FIRST(head) ((head)->tqh_first)
-
-#define TAILQ_FOREACH(var, head, field) \
- for ((var) = TAILQ_FIRST((head)); \
- (var); \
- (var) = TAILQ_NEXT((var), field))
-
-#define TAILQ_FOREACH_SAFE(var, head, field, tvar) \
- for ((var) = TAILQ_FIRST((head)); \
- (var) && ((tvar) = TAILQ_NEXT((var), field), 1); \
- (var) = (tvar))
-
-#define TAILQ_FOREACH_REVERSE(var, head, headname, field) \
- for ((var) = TAILQ_LAST((head), headname); \
- (var); \
- (var) = TAILQ_PREV((var), headname, field))
-
-#define TAILQ_FOREACH_REVERSE_SAFE(var, head, headname, field, tvar) \
- for ((var) = TAILQ_LAST((head), headname); \
- (var) && ((tvar) = TAILQ_PREV((var), headname, field), 1); \
- (var) = (tvar))
-
-#define TAILQ_INIT(head) do { \
- TAILQ_FIRST((head)) = NULL; \
- (head)->tqh_last = &TAILQ_FIRST((head)); \
- QMD_TRACE_HEAD(head); \
-} while (0)
-
-#define TAILQ_INSERT_AFTER(head, listelm, elm, field) do { \
- QMD_TAILQ_CHECK_NEXT(listelm, field); \
- if ((TAILQ_NEXT((elm), field) = TAILQ_NEXT((listelm), field)) != NULL)\
- TAILQ_NEXT((elm), field)->field.tqe_prev = \
- &TAILQ_NEXT((elm), field); \
- else { \
- (head)->tqh_last = &TAILQ_NEXT((elm), field); \
- QMD_TRACE_HEAD(head); \
- } \
- TAILQ_NEXT((listelm), field) = (elm); \
- (elm)->field.tqe_prev = &TAILQ_NEXT((listelm), field); \
- QMD_TRACE_ELEM(&(elm)->field); \
- QMD_TRACE_ELEM(&listelm->field); \
-} while (0)
-
-#define TAILQ_INSERT_BEFORE(listelm, elm, field) do { \
- QMD_TAILQ_CHECK_PREV(listelm, field); \
- (elm)->field.tqe_prev = (listelm)->field.tqe_prev; \
- TAILQ_NEXT((elm), field) = (listelm); \
- *(listelm)->field.tqe_prev = (elm); \
- (listelm)->field.tqe_prev = &TAILQ_NEXT((elm), field); \
- QMD_TRACE_ELEM(&(elm)->field); \
- QMD_TRACE_ELEM(&listelm->field); \
-} while (0)
-
-#define TAILQ_INSERT_HEAD(head, elm, field) do { \
- QMD_TAILQ_CHECK_HEAD(head, field); \
- if ((TAILQ_NEXT((elm), field) = TAILQ_FIRST((head))) != NULL) \
- TAILQ_FIRST((head))->field.tqe_prev = \
- &TAILQ_NEXT((elm), field); \
- else \
- (head)->tqh_last = &TAILQ_NEXT((elm), field); \
- TAILQ_FIRST((head)) = (elm); \
- (elm)->field.tqe_prev = &TAILQ_FIRST((head)); \
- QMD_TRACE_HEAD(head); \
- QMD_TRACE_ELEM(&(elm)->field); \
-} while (0)
-
-#define TAILQ_INSERT_TAIL(head, elm, field) do { \
- QMD_TAILQ_CHECK_TAIL(head, field); \
- TAILQ_NEXT((elm), field) = NULL; \
- (elm)->field.tqe_prev = (head)->tqh_last; \
- *(head)->tqh_last = (elm); \
- (head)->tqh_last = &TAILQ_NEXT((elm), field); \
- QMD_TRACE_HEAD(head); \
- QMD_TRACE_ELEM(&(elm)->field); \
-} while (0)
-
-#define TAILQ_LAST(head, headname) \
- (*(((struct headname *)((head)->tqh_last))->tqh_last))
-
-#define TAILQ_NEXT(elm, field) ((elm)->field.tqe_next)
-
-#define TAILQ_PREV(elm, headname, field) \
- (*(((struct headname *)((elm)->field.tqe_prev))->tqh_last))
-
-#define TAILQ_REMOVE(head, elm, field) do { \
- QMD_TAILQ_CHECK_NEXT(elm, field); \
- QMD_TAILQ_CHECK_PREV(elm, field); \
- if ((TAILQ_NEXT((elm), field)) != NULL) \
- TAILQ_NEXT((elm), field)->field.tqe_prev = \
- (elm)->field.tqe_prev; \
- else { \
- (head)->tqh_last = (elm)->field.tqe_prev; \
- QMD_TRACE_HEAD(head); \
- } \
- *(elm)->field.tqe_prev = TAILQ_NEXT((elm), field); \
- TRASHIT((elm)->field.tqe_next); \
- TRASHIT((elm)->field.tqe_prev); \
- QMD_TRACE_ELEM(&(elm)->field); \
-} while (0)
-
-
-#ifdef _KERNEL
-
-/*
- * XXX insque() and remque() are an old way of handling certain queues.
- * They bogusly assumes that all queue heads look alike.
- */
-
-struct quehead {
- struct quehead *qh_link;
- struct quehead *qh_rlink;
-};
-
-#ifdef __CC_SUPPORTS___INLINE
-
-static __inline void
-insque(void *a, void *b)
-{
- struct quehead *element = (struct quehead *)a,
- *head = (struct quehead *)b;
-
- element->qh_link = head->qh_link;
- element->qh_rlink = head;
- head->qh_link = element;
- element->qh_link->qh_rlink = element;
-}
-
-static __inline void
-remque(void *a)
-{
- struct quehead *element = (struct quehead *)a;
-
- element->qh_link->qh_rlink = element->qh_rlink;
- element->qh_rlink->qh_link = element->qh_link;
- element->qh_rlink = 0;
-}
-
-#else /* !__CC_SUPPORTS___INLINE */
-
-void insque(void *a, void *b);
-void remque(void *a);
-
-#endif /* __CC_SUPPORTS___INLINE */
-
-#endif /* _KERNEL */
-
-#endif /* !_SYS_QUEUE_H_ */
diff --git a/contrib/ofed/libcxgb4/src/t4.h b/contrib/ofed/libcxgb4/src/t4.h
deleted file mode 100644
index 2ac4fe8..0000000
--- a/contrib/ofed/libcxgb4/src/t4.h
+++ /dev/null
@@ -1,719 +0,0 @@
-/*
- * Copyright (c) 2006-2014 Chelsio, Inc. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-#ifndef __T4_H__
-#define __T4_H__
-
-#include <stdint.h>
-#include <assert.h>
-#include <syslog.h>
-
-#define ENODATA 95
-#undef ELAST
-#define ELAST ENODATA
-
-/*
- * Try and minimize the changes from the kernel code that is pull in
- * here for kernel bypass ops.
- */
-#define __u8 uint8_t
-#define u8 uint8_t
-#define __u16 uint16_t
-#define __be16 uint16_t
-#define u16 uint16_t
-#define __u32 uint32_t
-#define __be32 uint32_t
-#define u32 uint32_t
-#define __u64 uint64_t
-#define __be64 uint64_t
-#define u64 uint64_t
-#define DECLARE_PCI_UNMAP_ADDR(a)
-#define __iomem
-#define cpu_to_be16 htons
-#define cpu_to_be32 htonl
-#define cpu_to_be64 htonll
-#define be16_to_cpu ntohs
-#define be32_to_cpu ntohl
-#define be64_to_cpu ntohll
-#define BUG_ON(c) assert(!(c))
-#define unlikely
-#define ROUND_UP(x, n) (((x) + (n) - 1u) & ~((n) - 1u))
-#define DIV_ROUND_UP(n,d) (((n) + (d) - 1) / (d))
-#if __BYTE_ORDER == __LITTLE_ENDIAN
-# define cpu_to_pci32(val) ((val))
-#elif __BYTE_ORDER == __BIG_ENDIAN
-# define cpu_to_pci32(val) (__bswap_32((val)))
-#else
-# error __BYTE_ORDER not defined
-#endif
-
-#define writel(v, a) do { *((volatile u32 *)(a)) = cpu_to_pci32(v); } while (0)
-
-#include <arpa/inet.h> /* For htonl() and friends */
-#include "t4_regs.h"
-#include "t4_chip_type.h"
-#include "t4fw_interface.h"
-
-#ifdef DEBUG
-#define DBGLOG(s)
-#define PDBG(fmt, args...) do {syslog(LOG_DEBUG, fmt, ##args); } while (0)
-#else
-#define DBGLOG(s)
-#define PDBG(fmt, args...) do {} while (0)
-#endif
-
-#define T4_MAX_READ_DEPTH 16
-#define T4_QID_BASE 1024
-#define T4_MAX_QIDS 256
-#define T4_MAX_NUM_PD 65536
-#define T4_EQ_STATUS_ENTRIES (L1_CACHE_BYTES > 64 ? 2 : 1)
-#define T4_MAX_EQ_SIZE (65520 - T4_EQ_STATUS_ENTRIES)
-#define T4_MAX_IQ_SIZE (65520 - 1)
-#define T4_MAX_RQ_SIZE (8192 - T4_EQ_STATUS_ENTRIES)
-#define T4_MAX_SQ_SIZE (T4_MAX_EQ_SIZE - 1)
-#define T4_MAX_QP_DEPTH (T4_MAX_RQ_SIZE - 1)
-#define T4_MAX_CQ_DEPTH (T4_MAX_IQ_SIZE - 1)
-#define T4_MAX_NUM_STAG (1<<15)
-#define T4_MAX_MR_SIZE (~0ULL - 1)
-#define T4_PAGESIZE_MASK 0xffffffff000 /* 4KB-8TB */
-#define T4_STAG_UNSET 0xffffffff
-#define T4_FW_MAJ 0
-
-struct t4_status_page {
- __be32 rsvd1; /* flit 0 - hw owns */
- __be16 rsvd2;
- __be16 qid;
- __be16 cidx;
- __be16 pidx;
- u8 qp_err; /* flit 1 - sw owns */
- u8 db_off;
- u8 pad;
- u16 host_wq_pidx;
- u16 host_cidx;
- u16 host_pidx;
-};
-
-#define T4_EQ_ENTRY_SIZE 64
-
-#define T4_SQ_NUM_SLOTS 5
-#define T4_SQ_NUM_BYTES (T4_EQ_ENTRY_SIZE * T4_SQ_NUM_SLOTS)
-#define T4_MAX_SEND_SGE ((T4_SQ_NUM_BYTES - sizeof(struct fw_ri_send_wr) - sizeof(struct fw_ri_isgl)) / sizeof (struct fw_ri_sge))
-#define T4_MAX_SEND_INLINE ((T4_SQ_NUM_BYTES - sizeof(struct fw_ri_send_wr) - sizeof(struct fw_ri_immd)))
-#define T4_MAX_WRITE_INLINE ((T4_SQ_NUM_BYTES - sizeof(struct fw_ri_rdma_write_wr) - sizeof(struct fw_ri_immd)))
-#define T4_MAX_WRITE_SGE ((T4_SQ_NUM_BYTES - sizeof(struct fw_ri_rdma_write_wr) - sizeof(struct fw_ri_isgl)) / sizeof (struct fw_ri_sge))
-#define T4_MAX_FR_IMMD ((T4_SQ_NUM_BYTES - sizeof(struct fw_ri_fr_nsmr_wr) - sizeof(struct fw_ri_immd)))
-#define T4_MAX_FR_DEPTH 255
-
-#define T4_RQ_NUM_SLOTS 2
-#define T4_RQ_NUM_BYTES (T4_EQ_ENTRY_SIZE * T4_RQ_NUM_SLOTS)
-#define T4_MAX_RECV_SGE 4
-
-union t4_wr {
- struct fw_ri_res_wr res;
- struct fw_ri_wr init;
- struct fw_ri_rdma_write_wr write;
- struct fw_ri_send_wr send;
- struct fw_ri_rdma_read_wr read;
- struct fw_ri_bind_mw_wr bind;
- struct fw_ri_fr_nsmr_wr fr;
- struct fw_ri_inv_lstag_wr inv;
- struct t4_status_page status;
- __be64 flits[T4_EQ_ENTRY_SIZE / sizeof(__be64) * T4_SQ_NUM_SLOTS];
-};
-
-union t4_recv_wr {
- struct fw_ri_recv_wr recv;
- struct t4_status_page status;
- __be64 flits[T4_EQ_ENTRY_SIZE / sizeof(__be64) * T4_RQ_NUM_SLOTS];
-};
-
-static inline void init_wr_hdr(union t4_wr *wqe, u16 wrid,
- enum fw_wr_opcodes opcode, u8 flags, u8 len16)
-{
- wqe->send.opcode = (u8)opcode;
- wqe->send.flags = flags;
- wqe->send.wrid = wrid;
- wqe->send.r1[0] = 0;
- wqe->send.r1[1] = 0;
- wqe->send.r1[2] = 0;
- wqe->send.len16 = len16;
-}
-
-/* CQE/AE status codes */
-#define T4_ERR_SUCCESS 0x0
-#define T4_ERR_STAG 0x1 /* STAG invalid: either the */
- /* STAG is offlimt, being 0, */
- /* or STAG_key mismatch */
-#define T4_ERR_PDID 0x2 /* PDID mismatch */
-#define T4_ERR_QPID 0x3 /* QPID mismatch */
-#define T4_ERR_ACCESS 0x4 /* Invalid access right */
-#define T4_ERR_WRAP 0x5 /* Wrap error */
-#define T4_ERR_BOUND 0x6 /* base and bounds voilation */
-#define T4_ERR_INVALIDATE_SHARED_MR 0x7 /* attempt to invalidate a */
- /* shared memory region */
-#define T4_ERR_INVALIDATE_MR_WITH_MW_BOUND 0x8 /* attempt to invalidate a */
- /* shared memory region */
-#define T4_ERR_ECC 0x9 /* ECC error detected */
-#define T4_ERR_ECC_PSTAG 0xA /* ECC error detected when */
- /* reading PSTAG for a MW */
- /* Invalidate */
-#define T4_ERR_PBL_ADDR_BOUND 0xB /* pbl addr out of bounds: */
- /* software error */
-#define T4_ERR_SWFLUSH 0xC /* SW FLUSHED */
-#define T4_ERR_CRC 0x10 /* CRC error */
-#define T4_ERR_MARKER 0x11 /* Marker error */
-#define T4_ERR_PDU_LEN_ERR 0x12 /* invalid PDU length */
-#define T4_ERR_OUT_OF_RQE 0x13 /* out of RQE */
-#define T4_ERR_DDP_VERSION 0x14 /* wrong DDP version */
-#define T4_ERR_RDMA_VERSION 0x15 /* wrong RDMA version */
-#define T4_ERR_OPCODE 0x16 /* invalid rdma opcode */
-#define T4_ERR_DDP_QUEUE_NUM 0x17 /* invalid ddp queue number */
-#define T4_ERR_MSN 0x18 /* MSN error */
-#define T4_ERR_TBIT 0x19 /* tag bit not set correctly */
-#define T4_ERR_MO 0x1A /* MO not 0 for TERMINATE */
- /* or READ_REQ */
-#define T4_ERR_MSN_GAP 0x1B
-#define T4_ERR_MSN_RANGE 0x1C
-#define T4_ERR_IRD_OVERFLOW 0x1D
-#define T4_ERR_RQE_ADDR_BOUND 0x1E /* RQE addr out of bounds: */
- /* software error */
-#define T4_ERR_INTERNAL_ERR 0x1F /* internal error (opcode */
- /* mismatch) */
-/*
- * CQE defs
- */
-struct t4_cqe {
- __be32 header;
- __be32 len;
- union {
- struct {
- __be32 stag;
- __be32 msn;
- } rcqe;
- struct {
- u32 nada1;
- u16 nada2;
- u16 cidx;
- } scqe;
- struct {
- __be32 wrid_hi;
- __be32 wrid_low;
- } gen;
- } u;
- __be64 reserved;
- __be64 bits_type_ts;
-};
-
-/* macros for flit 0 of the cqe */
-
-#define S_CQE_QPID 12
-#define M_CQE_QPID 0xFFFFF
-#define G_CQE_QPID(x) ((((x) >> S_CQE_QPID)) & M_CQE_QPID)
-#define V_CQE_QPID(x) ((x)<<S_CQE_QPID)
-
-#define S_CQE_SWCQE 11
-#define M_CQE_SWCQE 0x1
-#define G_CQE_SWCQE(x) ((((x) >> S_CQE_SWCQE)) & M_CQE_SWCQE)
-#define V_CQE_SWCQE(x) ((x)<<S_CQE_SWCQE)
-
-#define S_CQE_STATUS 5
-#define M_CQE_STATUS 0x1F
-#define G_CQE_STATUS(x) ((((x) >> S_CQE_STATUS)) & M_CQE_STATUS)
-#define V_CQE_STATUS(x) ((x)<<S_CQE_STATUS)
-
-#define S_CQE_TYPE 4
-#define M_CQE_TYPE 0x1
-#define G_CQE_TYPE(x) ((((x) >> S_CQE_TYPE)) & M_CQE_TYPE)
-#define V_CQE_TYPE(x) ((x)<<S_CQE_TYPE)
-
-#define S_CQE_OPCODE 0
-#define M_CQE_OPCODE 0xF
-#define G_CQE_OPCODE(x) ((((x) >> S_CQE_OPCODE)) & M_CQE_OPCODE)
-#define V_CQE_OPCODE(x) ((x)<<S_CQE_OPCODE)
-
-#define SW_CQE(x) (G_CQE_SWCQE(be32_to_cpu((x)->header)))
-#define CQE_QPID(x) (G_CQE_QPID(be32_to_cpu((x)->header)))
-#define CQE_TYPE(x) (G_CQE_TYPE(be32_to_cpu((x)->header)))
-#define SQ_TYPE(x) (CQE_TYPE((x)))
-#define RQ_TYPE(x) (!CQE_TYPE((x)))
-#define CQE_STATUS(x) (G_CQE_STATUS(be32_to_cpu((x)->header)))
-#define CQE_OPCODE(x) (G_CQE_OPCODE(be32_to_cpu((x)->header)))
-
-#define CQE_SEND_OPCODE(x)( \
- (G_CQE_OPCODE(be32_to_cpu((x)->header)) == FW_RI_SEND) || \
- (G_CQE_OPCODE(be32_to_cpu((x)->header)) == FW_RI_SEND_WITH_SE) || \
- (G_CQE_OPCODE(be32_to_cpu((x)->header)) == FW_RI_SEND_WITH_INV) || \
- (G_CQE_OPCODE(be32_to_cpu((x)->header)) == FW_RI_SEND_WITH_SE_INV))
-
-#define CQE_LEN(x) (be32_to_cpu((x)->len))
-
-/* used for RQ completion processing */
-#define CQE_WRID_STAG(x) (be32_to_cpu((x)->u.rcqe.stag))
-#define CQE_WRID_MSN(x) (be32_to_cpu((x)->u.rcqe.msn))
-
-/* used for SQ completion processing */
-#define CQE_WRID_SQ_IDX(x) (x)->u.scqe.cidx
-
-/* generic accessor macros */
-#define CQE_WRID_HI(x) ((x)->u.gen.wrid_hi)
-#define CQE_WRID_LOW(x) ((x)->u.gen.wrid_low)
-
-/* macros for flit 3 of the cqe */
-#define S_CQE_GENBIT 63
-#define M_CQE_GENBIT 0x1
-#define G_CQE_GENBIT(x) (((x) >> S_CQE_GENBIT) & M_CQE_GENBIT)
-#define V_CQE_GENBIT(x) ((x)<<S_CQE_GENBIT)
-
-#define S_CQE_OVFBIT 62
-#define M_CQE_OVFBIT 0x1
-#define G_CQE_OVFBIT(x) ((((x) >> S_CQE_OVFBIT)) & M_CQE_OVFBIT)
-
-#define S_CQE_IQTYPE 60
-#define M_CQE_IQTYPE 0x3
-#define G_CQE_IQTYPE(x) ((((x) >> S_CQE_IQTYPE)) & M_CQE_IQTYPE)
-
-#define M_CQE_TS 0x0fffffffffffffffULL
-#define G_CQE_TS(x) ((x) & M_CQE_TS)
-
-#define CQE_OVFBIT(x) ((unsigned)G_CQE_OVFBIT(be64_to_cpu((x)->bits_type_ts)))
-#define CQE_GENBIT(x) ((unsigned)G_CQE_GENBIT(be64_to_cpu((x)->bits_type_ts)))
-#define CQE_TS(x) (G_CQE_TS(be64_to_cpu((x)->bits_type_ts)))
-
-struct t4_swsqe {
- u64 wr_id;
- struct t4_cqe cqe;
- __be32 read_len;
- int opcode;
- int complete;
- int signaled;
- u16 idx;
- int flushed;
-};
-
-enum {
- T4_SQ_ONCHIP = (1<<0),
-};
-
-struct t4_sq {
- union t4_wr *queue;
- struct t4_swsqe *sw_sq;
- struct t4_swsqe *oldest_read;
- volatile u32 *udb;
- size_t memsize;
- u32 qid;
- u32 bar2_qid;
- void *ma_sync;
- u16 in_use;
- u16 size;
- u16 cidx;
- u16 pidx;
- u16 wq_pidx;
- u16 flags;
- short flush_cidx;
- int wc_reg_available;
-};
-
-struct t4_swrqe {
- u64 wr_id;
-};
-
-struct t4_rq {
- union t4_recv_wr *queue;
- struct t4_swrqe *sw_rq;
- volatile u32 *udb;
- size_t memsize;
- u32 qid;
- u32 bar2_qid;
- u32 msn;
- u32 rqt_hwaddr;
- u16 rqt_size;
- u16 in_use;
- u16 size;
- u16 cidx;
- u16 pidx;
- u16 wq_pidx;
- int wc_reg_available;
-};
-
-struct t4_wq {
- struct t4_sq sq;
- struct t4_rq rq;
- struct c4iw_rdev *rdev;
- u32 qid_mask;
- int error;
- int flushed;
- u8 *db_offp;
-};
-
-static inline void t4_ma_sync(struct t4_wq *wq, int page_size)
-{
- wc_wmb();
- *((volatile u32 *)wq->sq.ma_sync) = 1;
-}
-
-static inline int t4_rqes_posted(struct t4_wq *wq)
-{
- return wq->rq.in_use;
-}
-
-static inline int t4_rq_empty(struct t4_wq *wq)
-{
- return wq->rq.in_use == 0;
-}
-
-static inline int t4_rq_full(struct t4_wq *wq)
-{
- return wq->rq.in_use == (wq->rq.size - 1);
-}
-
-static inline u32 t4_rq_avail(struct t4_wq *wq)
-{
- return wq->rq.size - 1 - wq->rq.in_use;
-}
-
-static inline void t4_rq_produce(struct t4_wq *wq, u8 len16)
-{
- wq->rq.in_use++;
- if (++wq->rq.pidx == wq->rq.size)
- wq->rq.pidx = 0;
- wq->rq.wq_pidx += DIV_ROUND_UP(len16*16, T4_EQ_ENTRY_SIZE);
- if (wq->rq.wq_pidx >= wq->rq.size * T4_RQ_NUM_SLOTS)
- wq->rq.wq_pidx %= wq->rq.size * T4_RQ_NUM_SLOTS;
- if (!wq->error)
- wq->rq.queue[wq->rq.size].status.host_pidx = wq->rq.pidx;
-}
-
-static inline void t4_rq_consume(struct t4_wq *wq)
-{
- wq->rq.in_use--;
- wq->rq.msn++;
- if (++wq->rq.cidx == wq->rq.size)
- wq->rq.cidx = 0;
- assert((wq->rq.cidx != wq->rq.pidx) || wq->rq.in_use == 0);
- if (!wq->error)
- wq->rq.queue[wq->rq.size].status.host_cidx = wq->rq.cidx;
-}
-
-static inline int t4_sq_empty(struct t4_wq *wq)
-{
- return wq->sq.in_use == 0;
-}
-
-static inline int t4_sq_full(struct t4_wq *wq)
-{
- return wq->sq.in_use == (wq->sq.size - 1);
-}
-
-static inline u32 t4_sq_avail(struct t4_wq *wq)
-{
- return wq->sq.size - 1 - wq->sq.in_use;
-}
-
-static inline int t4_sq_onchip(struct t4_wq *wq)
-{
- return wq->sq.flags & T4_SQ_ONCHIP;
-}
-
-static inline void t4_sq_produce(struct t4_wq *wq, u8 len16)
-{
- wq->sq.in_use++;
- if (++wq->sq.pidx == wq->sq.size)
- wq->sq.pidx = 0;
- wq->sq.wq_pidx += DIV_ROUND_UP(len16*16, T4_EQ_ENTRY_SIZE);
- if (wq->sq.wq_pidx >= wq->sq.size * T4_SQ_NUM_SLOTS)
- wq->sq.wq_pidx %= wq->sq.size * T4_SQ_NUM_SLOTS;
- if (!wq->error)
- wq->sq.queue[wq->sq.size].status.host_pidx = (wq->sq.pidx);
-}
-
-static inline void t4_sq_consume(struct t4_wq *wq)
-{
- assert(wq->sq.in_use >= 1);
- if (wq->sq.cidx == wq->sq.flush_cidx)
- wq->sq.flush_cidx = -1;
- wq->sq.in_use--;
- if (++wq->sq.cidx == wq->sq.size)
- wq->sq.cidx = 0;
- assert((wq->sq.cidx != wq->sq.pidx) || wq->sq.in_use == 0);
- if (!wq->error)
- wq->sq.queue[wq->sq.size].status.host_cidx = wq->sq.cidx;
-}
-
-static void copy_wqe_to_udb(volatile u32 *udb_offset, void *wqe)
-{
- u64 *src, *dst;
- int len16 = 4;
-
- src = (u64 *)wqe;
- dst = (u64 *)udb_offset;
-
- while (len16) {
- *dst++ = *src++;
- *dst++ = *src++;
- len16--;
- }
-}
-
-extern int ma_wr;
-extern int t5_en_wc;
-
-static inline void t4_ring_sq_db(struct t4_wq *wq, u16 inc, u8 t4, u8 len16,
- union t4_wr *wqe)
-{
- wc_wmb();
- if (!t4) {
- if (t5_en_wc && inc == 1 && wq->sq.wc_reg_available) {
- PDBG("%s: WC wq->sq.pidx = %d; len16=%d\n",
- __func__, wq->sq.pidx, len16);
- copy_wqe_to_udb(wq->sq.udb + 14, wqe);
- } else {
- PDBG("%s: DB wq->sq.pidx = %d; len16=%d\n",
- __func__, wq->sq.pidx, len16);
- writel(V_QID(wq->sq.bar2_qid) | V_PIDX_T5(inc), wq->sq.udb);
- }
- wc_wmb();
- return;
- }
- if (ma_wr) {
- if (t4_sq_onchip(wq)) {
- int i;
- for (i = 0; i < 16; i++)
- *(volatile u32 *)&wq->sq.queue[wq->sq.size].flits[2+i] = i;
- }
- } else {
- if (t4_sq_onchip(wq)) {
- int i;
- for (i = 0; i < 16; i++)
- *(u32 *)&wq->sq.queue[wq->sq.size].flits[2] = i;
- }
- }
- writel(V_QID(wq->sq.qid & wq->qid_mask) | V_PIDX(inc), wq->sq.udb);
-}
-
-static inline void t4_ring_rq_db(struct t4_wq *wq, u16 inc, u8 t4, u8 len16,
- union t4_recv_wr *wqe)
-{
- wc_wmb();
- if (!t4) {
- if (t5_en_wc && inc == 1 && wq->sq.wc_reg_available) {
- PDBG("%s: WC wq->rq.pidx = %d; len16=%d\n",
- __func__, wq->rq.pidx, len16);
- copy_wqe_to_udb(wq->rq.udb + 14, wqe);
- } else {
- PDBG("%s: DB wq->rq.pidx = %d; len16=%d\n",
- __func__, wq->rq.pidx, len16);
- writel(V_QID(wq->rq.bar2_qid) | V_PIDX_T5(inc), wq->rq.udb);
- }
- wc_wmb();
- return;
- }
- writel(V_QID(wq->rq.qid & wq->qid_mask) | V_PIDX(inc), wq->rq.udb);
-}
-
-static inline int t4_wq_in_error(struct t4_wq *wq)
-{
- return wq->error || wq->rq.queue[wq->rq.size].status.qp_err;
-}
-
-static inline void t4_set_wq_in_error(struct t4_wq *wq)
-{
- wq->rq.queue[wq->rq.size].status.qp_err = 1;
-}
-
-extern int c4iw_abi_version;
-
-static inline int t4_wq_db_enabled(struct t4_wq *wq)
-{
- /*
- * If iw_cxgb4 driver supports door bell drop recovery then its
- * c4iw_abi_version would be greater than or equal to 2. In such
- * case return the status of db_off flag to ring the kernel mode
- * DB from user mode library.
- */
- if ( c4iw_abi_version >= 2 )
- return ! *wq->db_offp;
- else
- return 1;
-}
-
-struct t4_cq {
- struct t4_cqe *queue;
- struct t4_cqe *sw_queue;
- struct c4iw_rdev *rdev;
- volatile u32 *ugts;
- size_t memsize;
- u64 bits_type_ts;
- u32 cqid;
- u32 qid_mask;
- u16 size; /* including status page */
- u16 cidx;
- u16 sw_pidx;
- u16 sw_cidx;
- u16 sw_in_use;
- u16 cidx_inc;
- u8 gen;
- u8 error;
-};
-
-static inline int t4_arm_cq(struct t4_cq *cq, int se)
-{
- u32 val;
-
- while (cq->cidx_inc > M_CIDXINC) {
- val = V_SEINTARM(0) | V_CIDXINC(M_CIDXINC) | V_TIMERREG(7) |
- V_INGRESSQID(cq->cqid & cq->qid_mask);
- writel(val, cq->ugts);
- cq->cidx_inc -= M_CIDXINC;
- }
- val = V_SEINTARM(se) | V_CIDXINC(cq->cidx_inc) | V_TIMERREG(6) |
- V_INGRESSQID(cq->cqid & cq->qid_mask);
- writel(val, cq->ugts);
- cq->cidx_inc = 0;
- return 0;
-}
-
-static inline void t4_swcq_produce(struct t4_cq *cq)
-{
- cq->sw_in_use++;
- if (cq->sw_in_use == cq->size) {
- syslog(LOG_NOTICE, "cxgb4 sw cq overflow cqid %u\n", cq->cqid);
- cq->error = 1;
- assert(0);
- }
- if (++cq->sw_pidx == cq->size)
- cq->sw_pidx = 0;
-}
-
-static inline void t4_swcq_consume(struct t4_cq *cq)
-{
- assert(cq->sw_in_use >= 1);
- cq->sw_in_use--;
- if (++cq->sw_cidx == cq->size)
- cq->sw_cidx = 0;
-}
-
-static inline void t4_hwcq_consume(struct t4_cq *cq)
-{
- cq->bits_type_ts = cq->queue[cq->cidx].bits_type_ts;
- if (++cq->cidx_inc == (cq->size >> 4) || cq->cidx_inc == M_CIDXINC) {
- uint32_t val;
-
- val = V_SEINTARM(0) | V_CIDXINC(cq->cidx_inc) | V_TIMERREG(7) |
- V_INGRESSQID(cq->cqid & cq->qid_mask);
- writel(val, cq->ugts);
- cq->cidx_inc = 0;
- }
- if (++cq->cidx == cq->size) {
- cq->cidx = 0;
- cq->gen ^= 1;
- }
- ((struct t4_status_page *)&cq->queue[cq->size])->host_cidx = cq->cidx;
-}
-
-static inline int t4_valid_cqe(struct t4_cq *cq, struct t4_cqe *cqe)
-{
- return (CQE_GENBIT(cqe) == cq->gen);
-}
-
-static inline int t4_next_hw_cqe(struct t4_cq *cq, struct t4_cqe **cqe)
-{
- int ret;
- u16 prev_cidx;
-
- if (cq->cidx == 0)
- prev_cidx = cq->size - 1;
- else
- prev_cidx = cq->cidx - 1;
-
- if (cq->queue[prev_cidx].bits_type_ts != cq->bits_type_ts) {
- ret = -EOVERFLOW;
- syslog(LOG_NOTICE, "cxgb4 cq overflow cqid %u\n", cq->cqid);
- cq->error = 1;
- assert(0);
- } else if (t4_valid_cqe(cq, &cq->queue[cq->cidx])) {
- rmb();
- *cqe = &cq->queue[cq->cidx];
- ret = 0;
- } else
- ret = -ENODATA;
- return ret;
-}
-
-static inline struct t4_cqe *t4_next_sw_cqe(struct t4_cq *cq)
-{
- if (cq->sw_in_use == cq->size) {
- syslog(LOG_NOTICE, "cxgb4 sw cq overflow cqid %u\n", cq->cqid);
- cq->error = 1;
- assert(0);
- return NULL;
- }
- if (cq->sw_in_use)
- return &cq->sw_queue[cq->sw_cidx];
- return NULL;
-}
-
-static inline int t4_cq_notempty(struct t4_cq *cq)
-{
- return cq->sw_in_use || t4_valid_cqe(cq, &cq->queue[cq->cidx]);
-}
-
-static inline int t4_next_cqe(struct t4_cq *cq, struct t4_cqe **cqe)
-{
- int ret = 0;
-
- if (cq->error)
- ret = -ENODATA;
- else if (cq->sw_in_use)
- *cqe = &cq->sw_queue[cq->sw_cidx];
- else ret = t4_next_hw_cqe(cq, cqe);
- return ret;
-}
-
-static inline int t4_cq_in_error(struct t4_cq *cq)
-{
- return ((struct t4_status_page *)&cq->queue[cq->size])->qp_err;
-}
-
-static inline void t4_set_cq_in_error(struct t4_cq *cq)
-{
- ((struct t4_status_page *)&cq->queue[cq->size])->qp_err = 1;
-}
-
-static inline void t4_reset_cq_in_error(struct t4_cq *cq)
-{
- ((struct t4_status_page *)&cq->queue[cq->size])->qp_err = 0;
-}
-
-struct t4_dev_status_page
-{
- u8 db_off;
-};
-
-#endif
diff --git a/contrib/ofed/libcxgb4/src/t4_chip_type.h b/contrib/ofed/libcxgb4/src/t4_chip_type.h
deleted file mode 100644
index 59c4a24..0000000
--- a/contrib/ofed/libcxgb4/src/t4_chip_type.h
+++ /dev/null
@@ -1,121 +0,0 @@
-/*
- * This file is part of the Chelsio T4/T5/T6 Ethernet driver.
- *
- * Copyright (C) 2003-2016 Chelsio Communications. All rights reserved.
- *
- * This program 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 LICENSE file included in this
- * release for licensing terms and conditions.
- */
-#ifndef __T4_CHIP_TYPE_H__
-#define __T4_CHIP_TYPE_H__
-
-/*
- * All T4 and later chips have their PCI-E Device IDs encoded as 0xVFPP where:
- *
- * V = "4" for T4; "5" for T5, etc. or
- * = "a" for T4 FPGA; "b" for T4 FPGA, etc.
- * F = "0" for PF 0..3; "4".."7" for PF4..7; and "8" for VFs
- * PP = adapter product designation
- *
- * We use the "version" (V) of the adpater to code the Chip Version above
- * but separate out the FPGA as a separate boolean as per above.
- */
-#define CHELSIO_PCI_ID_VER(__DeviceID) ((__DeviceID) >> 12)
-#define CHELSIO_PCI_ID_FUNC(__DeviceID) (((__DeviceID) >> 8) & 0xf)
-#define CHELSIO_PCI_ID_PROD(__DeviceID) ((__DeviceID) & 0xff)
-
-#define CHELSIO_T4 0x4
-#define CHELSIO_T4_FPGA 0xa
-#define CHELSIO_T5 0x5
-#define CHELSIO_T5_FPGA 0xb
-#define CHELSIO_T6 0x6
-#define CHELSIO_T6_FPGA 0xc
-
-/*
- * Translate a PCI Device ID to a base Chelsio Chip Version -- CHELSIO_T4,
- * CHELSIO_T5, etc. If it weren't for the screwed up numbering of the FPGAs
- * we could do this simply as DeviceID >> 12 (because we know the real
- * encoding oc CHELSIO_Tx identifiers). However, the FPGAs _do_ have weird
- * Device IDs so we need to do this translation here. Note that only constant
- * arithmetic and comparisons can be done here since this is being used to
- * initialize static tables, etc.
- *
- * Finally: This will of course need to be expanded as future chips are
- * developed.
- */
-static inline unsigned int
-CHELSIO_PCI_ID_CHIP_VERSION(unsigned int DeviceID)
-{
- switch (CHELSIO_PCI_ID_VER(DeviceID)) {
- case CHELSIO_T4:
- case CHELSIO_T4_FPGA:
- return CHELSIO_T4;
-
- case CHELSIO_T5:
- case CHELSIO_T5_FPGA:
- return CHELSIO_T5;
-
- case CHELSIO_T6:
- case CHELSIO_T6_FPGA:
- return CHELSIO_T6;
- }
-
- return 0;
-}
-
-/*
- * Internally we code the Chelsio T4 Family "Chip Code" as a tuple:
- *
- * (Is FPGA, Chip Version, Chip Revision)
- *
- * where:
- *
- * Is FPGA: is 0/1 indicating whether we're working with an FPGA
- * Chip Version: is T4, T5, etc.
- * Chip Revision: is the FAB "spin" of the Chip Version.
- */
-#define CHELSIO_CHIP_CODE(version, revision) (((version) << 4) | (revision))
-#define CHELSIO_CHIP_FPGA 0x100
-#define CHELSIO_CHIP_VERSION(code) (((code) >> 4) & 0xf)
-#define CHELSIO_CHIP_RELEASE(code) ((code) & 0xf)
-
-enum chip_type {
- T4_A1 = CHELSIO_CHIP_CODE(CHELSIO_T4, 1),
- T4_A2 = CHELSIO_CHIP_CODE(CHELSIO_T4, 2),
- T4_FIRST_REV = T4_A1,
- T4_LAST_REV = T4_A2,
-
- T5_A0 = CHELSIO_CHIP_CODE(CHELSIO_T5, 0),
- T5_A1 = CHELSIO_CHIP_CODE(CHELSIO_T5, 1),
- T5_FIRST_REV = T5_A0,
- T5_LAST_REV = T5_A1,
-
- T6_A0 = CHELSIO_CHIP_CODE(CHELSIO_T6, 0),
- T6_FIRST_REV = T6_A0,
- T6_LAST_REV = T6_A0,
-};
-
-static inline int is_t4(enum chip_type chip)
-{
- return (CHELSIO_CHIP_VERSION(chip) == CHELSIO_T4);
-}
-
-static inline int is_t5(enum chip_type chip)
-{
-
- return (CHELSIO_CHIP_VERSION(chip) == CHELSIO_T5);
-}
-
-static inline int is_t6(enum chip_type chip)
-{
- return (CHELSIO_CHIP_VERSION(chip) == CHELSIO_T6);
-}
-
-static inline int is_fpga(enum chip_type chip)
-{
- return chip & CHELSIO_CHIP_FPGA;
-}
-
-#endif /* __T4_CHIP_TYPE_H__ */
diff --git a/contrib/ofed/libcxgb4/src/t4_pci_id_tbl.h b/contrib/ofed/libcxgb4/src/t4_pci_id_tbl.h
deleted file mode 100644
index 9a7c91b..0000000
--- a/contrib/ofed/libcxgb4/src/t4_pci_id_tbl.h
+++ /dev/null
@@ -1,218 +0,0 @@
-/*
- * This file is part of the Chelsio T4/T5/T6 Ethernet driver.
- *
- * Copyright (C) 2003-2017 Chelsio Communications. All rights reserved.
- *
- * This program 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 LICENSE file included in this
- * release for licensing terms and conditions.
- */
-#ifndef __T4_PCI_ID_TBL_H__
-#define __T4_PCI_ID_TBL_H__
-
-/*
- * The Os-Dependent code can defined cpp macros for creating a PCI Device ID
- * Table. This is useful because it allows the PCI ID Table to be maintained
- * in a single place and all supporting OSes to get new PCI Device IDs
- * automatically.
- *
- * The macros are:
- *
- * CH_PCI_DEVICE_ID_TABLE_DEFINE_BEGIN
- * -- Used to start the definition of the PCI ID Table.
- *
- * CH_PCI_DEVICE_ID_FUNCTION
- * -- The PCI Function Number to use in the PCI Device ID Table. "0"
- * -- for drivers attaching to PF0-3, "4" for drivers attaching to PF4,
- * -- "8" for drivers attaching to SR-IOV Virtual Functions, etc.
- *
- * CH_PCI_DEVICE_ID_FUNCTION2 [optional]
- * -- If defined, create a PCI Device ID Table with both
- * -- CH_PCI_DEVICE_ID_FUNCTION and CH_PCI_DEVICE_ID_FUNCTION2 populated.
- *
- * CH_PCI_ID_TABLE_ENTRY(DeviceID)
- * -- Used for the individual PCI Device ID entries. Note that we will
- * -- be adding a trailing comma (",") after all of the entries (and
- * -- between the pairs of entries if CH_PCI_DEVICE_ID_FUNCTION2 is defined).
- *
- * CH_PCI_DEVICE_ID_TABLE_DEFINE_END
- * -- Used to finish the definition of the PCI ID Table. Note that we
- * -- will be adding a trailing semi-colon (";") here.
- *
- * CH_PCI_DEVICE_ID_BYPASS_SUPPORTED [optional]
- * -- If defined, indicates that the OS Driver has support for Bypass
- * -- Adapters.
- */
-
-/*
- * Some sanity checks ...
- */
-#ifndef CH_PCI_DEVICE_ID_FUNCTION
-#error CH_PCI_DEVICE_ID_FUNCTION not defined!
-#endif
-#ifndef CH_PCI_ID_TABLE_ENTRY
-#error CH_PCI_ID_TABLE_ENTRY not defined!
-#endif
-#ifndef CH_PCI_DEVICE_ID_TABLE_DEFINE_END
-#error CH_PCI_DEVICE_ID_TABLE_DEFINE_END not defined!
-#endif
-
-/*
- * T4 and later ASICs use a PCI Device ID scheme of 0xVFPP where:
- *
- * V = "4" for T4; "5" for T5, etc.
- * F = "0" for PF 0..3; "4".."7" for PF4..7; and "8" for VFs
- * PP = adapter product designation
- *
- * We use this consistency in order to create the proper PCI Device IDs
- * for the specified CH_PCI_DEVICE_ID_FUNCTION.
- */
-#ifndef CH_PCI_DEVICE_ID_FUNCTION2
-#define CH_PCI_ID_TABLE_FENTRY(__DeviceID) \
- CH_PCI_ID_TABLE_ENTRY((__DeviceID) | \
- ((CH_PCI_DEVICE_ID_FUNCTION) << 8))
-#else
-#define CH_PCI_ID_TABLE_FENTRY(__DeviceID) \
- CH_PCI_ID_TABLE_ENTRY((__DeviceID) | \
- ((CH_PCI_DEVICE_ID_FUNCTION) << 8)), \
- CH_PCI_ID_TABLE_ENTRY((__DeviceID) | \
- ((CH_PCI_DEVICE_ID_FUNCTION2) << 8))
-#endif
-
-/* Note : The comments against each entry are used by the scripts in the vmware drivers
- * to correctly generate the pciid xml file, do not change the format currently used.
- */
-
-CH_PCI_DEVICE_ID_TABLE_DEFINE_BEGIN
- /*
- * FPGAs:
- *
- * Unfortunately the FPGA PCI Device IDs don't follow the ASIC PCI
- * Device ID numbering convetions for the Physical Functions.
- */
-#if CH_PCI_DEVICE_ID_FUNCTION != 8
- CH_PCI_ID_TABLE_ENTRY(0xa000), /* PE10K FPGA */
- CH_PCI_ID_TABLE_ENTRY(0xb000), /* PF0 T5 PE10K5 FPGA */
- CH_PCI_ID_TABLE_ENTRY(0xb001), /* PF0 T5 PE10K FPGA */
- CH_PCI_ID_TABLE_ENTRY(0xc006), /* PF0 T6 PE10K6 FPGA */
-#else
- CH_PCI_ID_TABLE_FENTRY(0xa000), /* PE10K FPGA */
- CH_PCI_ID_TABLE_FENTRY(0xb000), /* PF0 T5 PE10K5 FPGA */
- CH_PCI_ID_TABLE_FENTRY(0xb001), /* PF0 T5 PE10K FPGA */
- CH_PCI_ID_TABLE_FENTRY(0xc006), /* PF0 T6 PE10K6 FPGA */
- CH_PCI_ID_TABLE_FENTRY(0xc106), /* PF1 T6 PE10K6 FPGA */
-#endif
-
- /*
- * These FPGAs seem to be used only by the csiostor driver
- */
-#if ((CH_PCI_DEVICE_ID_FUNCTION == 5) || (CH_PCI_DEVICE_ID_FUNCTION == 6))
- CH_PCI_ID_TABLE_ENTRY(0xa001), /* PF1 PE10K FPGA FCOE */
- CH_PCI_ID_TABLE_ENTRY(0xa002), /* PE10K FPGA iSCSI */
- CH_PCI_ID_TABLE_ENTRY(0xc106), /* PF1 T6 PE10K6 FPGA */
-#endif
-
- /*
- * T4 adapters:
- */
- CH_PCI_ID_TABLE_FENTRY(0x4000), /* T440-dbg */
- CH_PCI_ID_TABLE_FENTRY(0x4001), /* T420-cr */
- CH_PCI_ID_TABLE_FENTRY(0x4002), /* T422-cr */
- CH_PCI_ID_TABLE_FENTRY(0x4003), /* T440-cr */
- CH_PCI_ID_TABLE_FENTRY(0x4004), /* T420-bch */
- CH_PCI_ID_TABLE_FENTRY(0x4005), /* T440-bch */
- CH_PCI_ID_TABLE_FENTRY(0x4006), /* T440-ch */
- CH_PCI_ID_TABLE_FENTRY(0x4007), /* T420-so */
- CH_PCI_ID_TABLE_FENTRY(0x4008), /* T420-cx */
- CH_PCI_ID_TABLE_FENTRY(0x4009), /* T420-bt */
- CH_PCI_ID_TABLE_FENTRY(0x400a), /* T404-bt */
-#ifdef CH_PCI_DEVICE_ID_BYPASS_SUPPORTED
- CH_PCI_ID_TABLE_FENTRY(0x400b), /* B420-sr */
- CH_PCI_ID_TABLE_FENTRY(0x400c), /* B404-bt */
-#endif
- CH_PCI_ID_TABLE_FENTRY(0x400d), /* T480-cr */
- CH_PCI_ID_TABLE_FENTRY(0x400e), /* T440-LP-cr */
- CH_PCI_ID_TABLE_FENTRY(0x4080), /* Custom T480-cr */
- CH_PCI_ID_TABLE_FENTRY(0x4081), /* Custom T440-cr */
- CH_PCI_ID_TABLE_FENTRY(0x4082), /* Custom T420-cr */
- CH_PCI_ID_TABLE_FENTRY(0x4083), /* Custom T420-xaui */
- CH_PCI_ID_TABLE_FENTRY(0x4084), /* Custom T440-cr */
- CH_PCI_ID_TABLE_FENTRY(0x4085), /* Custom T420-cr */
- CH_PCI_ID_TABLE_FENTRY(0x4086), /* Custom T440-bt */
- CH_PCI_ID_TABLE_FENTRY(0x4087), /* Custom T440-cr */
- CH_PCI_ID_TABLE_FENTRY(0x4088), /* Custom T440 2-xaui, 2-xfi */
-
- /*
- * T5 adapters:
- */
- CH_PCI_ID_TABLE_FENTRY(0x5000), /* T580-dbg */
- CH_PCI_ID_TABLE_FENTRY(0x5001), /* T520-cr */
- CH_PCI_ID_TABLE_FENTRY(0x5002), /* T522-cr */
- CH_PCI_ID_TABLE_FENTRY(0x5003), /* T540-cr */
- CH_PCI_ID_TABLE_FENTRY(0x5004), /* T520-bch */
- CH_PCI_ID_TABLE_FENTRY(0x5005), /* T540-bch */
- CH_PCI_ID_TABLE_FENTRY(0x5006), /* T540-ch */
- CH_PCI_ID_TABLE_FENTRY(0x5007), /* T520-so */
- CH_PCI_ID_TABLE_FENTRY(0x5008), /* T520-cx */
- CH_PCI_ID_TABLE_FENTRY(0x5009), /* T520-bt */
- CH_PCI_ID_TABLE_FENTRY(0x500a), /* T504-bt */
-#ifdef CH_PCI_DEVICE_ID_BYPASS_SUPPORTED
- CH_PCI_ID_TABLE_FENTRY(0x500b), /* B520-sr */
- CH_PCI_ID_TABLE_FENTRY(0x500c), /* B504-bt */
-#endif
- CH_PCI_ID_TABLE_FENTRY(0x500d), /* T580-cr */
- CH_PCI_ID_TABLE_FENTRY(0x500e), /* T540-LP-cr */
- CH_PCI_ID_TABLE_FENTRY(0x5010), /* T580-LP-cr */
- CH_PCI_ID_TABLE_FENTRY(0x5011), /* T520-LL-cr */
- CH_PCI_ID_TABLE_FENTRY(0x5012), /* T560-cr */
- CH_PCI_ID_TABLE_FENTRY(0x5013), /* T580-chr */
- CH_PCI_ID_TABLE_FENTRY(0x5014), /* T580-so */
- CH_PCI_ID_TABLE_FENTRY(0x5015), /* T502-bt */
- CH_PCI_ID_TABLE_FENTRY(0x5016), /* T580-OCP-SO */
- CH_PCI_ID_TABLE_FENTRY(0x5017), /* T520-OCP-SO */
- CH_PCI_ID_TABLE_FENTRY(0x5018), /* T540-BT */
- CH_PCI_ID_TABLE_FENTRY(0x5080), /* Custom T540-cr */
- CH_PCI_ID_TABLE_FENTRY(0x5081), /* Custom T540-LL-cr */
- CH_PCI_ID_TABLE_FENTRY(0x5082), /* Custom T504-cr */
- CH_PCI_ID_TABLE_FENTRY(0x5083), /* Custom T540-CR */
- CH_PCI_ID_TABLE_FENTRY(0x5084), /* Custom T580-cr */
- CH_PCI_ID_TABLE_FENTRY(0x5085), /* Custom 3x T580-CR */
- CH_PCI_ID_TABLE_FENTRY(0x5086), /* Custom 2x T580-CR */
- CH_PCI_ID_TABLE_FENTRY(0x5087), /* Custom T580-CR */
- CH_PCI_ID_TABLE_FENTRY(0x5088), /* Custom T570-CR */
- CH_PCI_ID_TABLE_FENTRY(0x5089), /* Custom T520-CR */
- CH_PCI_ID_TABLE_FENTRY(0x5090), /* Custom T540-CR */
- CH_PCI_ID_TABLE_FENTRY(0x5091), /* Custom T522-CR */
- CH_PCI_ID_TABLE_FENTRY(0x5092), /* Custom T520-CR */
- CH_PCI_ID_TABLE_FENTRY(0x5093), /* Custom SECA */
- CH_PCI_ID_TABLE_FENTRY(0x5094), /* Custom T540-CR */
- CH_PCI_ID_TABLE_FENTRY(0x5095), /* Custom T540-CR-SO */
- CH_PCI_ID_TABLE_FENTRY(0x5096), /* Custom T580-CR */
- CH_PCI_ID_TABLE_FENTRY(0x5097), /* Custom T520-KR */
- CH_PCI_ID_TABLE_FENTRY(0x5098), /* Custom 2x40G QSFP */
- CH_PCI_ID_TABLE_FENTRY(0x5099), /* Custom 2x40G QSFP */
- CH_PCI_ID_TABLE_FENTRY(0x509A), /* Custom T520-CR */
- CH_PCI_ID_TABLE_FENTRY(0x509B), /* Custom T540-CR LOM */
- CH_PCI_ID_TABLE_FENTRY(0x509c), /* Custom T520-CR SFP+ LOM */
- CH_PCI_ID_TABLE_FENTRY(0x509d), /* Custom T540-CR SFP+ */
-
- /* T6 adapter */
- CH_PCI_ID_TABLE_FENTRY(0x6000),
- CH_PCI_ID_TABLE_FENTRY(0x6001),
- CH_PCI_ID_TABLE_FENTRY(0x6002),
- CH_PCI_ID_TABLE_FENTRY(0x6003),
- CH_PCI_ID_TABLE_FENTRY(0x6004),
- CH_PCI_ID_TABLE_FENTRY(0x6005),
- CH_PCI_ID_TABLE_FENTRY(0x6006),
- CH_PCI_ID_TABLE_FENTRY(0x6007),
- CH_PCI_ID_TABLE_FENTRY(0x6008),
- CH_PCI_ID_TABLE_FENTRY(0x6009),
- CH_PCI_ID_TABLE_FENTRY(0x600d),
- CH_PCI_ID_TABLE_FENTRY(0x6010),
- CH_PCI_ID_TABLE_FENTRY(0x6011),
- CH_PCI_ID_TABLE_FENTRY(0x6014),
- CH_PCI_ID_TABLE_FENTRY(0x6015),
-CH_PCI_DEVICE_ID_TABLE_DEFINE_END;
-
-#endif /* __T4_PCI_ID_TBL_H__ */
diff --git a/contrib/ofed/libcxgb4/src/t4_regs.h b/contrib/ofed/libcxgb4/src/t4_regs.h
deleted file mode 100644
index d001d8c..0000000
--- a/contrib/ofed/libcxgb4/src/t4_regs.h
+++ /dev/null
@@ -1,62873 +0,0 @@
-/* This file is automatically generated --- changes will be lost */
-/* Generation Date : Fri Oct 28 19:22:40 IST 2016 */
-/* Directory name: t4_reg.txt, Changeset: */
-/* Directory name: t5_reg.txt, Changeset: 6938:9111c5bdce6e */
-/* Directory name: t6_reg.txt, Changeset: 4252:437fb8972e44 */
-
-#define MYPF_BASE 0x1b000
-#define MYPF_REG(reg_addr) (MYPF_BASE + (reg_addr))
-
-#define PF0_BASE 0x1e000
-#define PF0_REG(reg_addr) (PF0_BASE + (reg_addr))
-
-#define PF1_BASE 0x1e400
-#define PF1_REG(reg_addr) (PF1_BASE + (reg_addr))
-
-#define PF2_BASE 0x1e800
-#define PF2_REG(reg_addr) (PF2_BASE + (reg_addr))
-
-#define PF3_BASE 0x1ec00
-#define PF3_REG(reg_addr) (PF3_BASE + (reg_addr))
-
-#define PF4_BASE 0x1f000
-#define PF4_REG(reg_addr) (PF4_BASE + (reg_addr))
-
-#define PF5_BASE 0x1f400
-#define PF5_REG(reg_addr) (PF5_BASE + (reg_addr))
-
-#define PF6_BASE 0x1f800
-#define PF6_REG(reg_addr) (PF6_BASE + (reg_addr))
-
-#define PF7_BASE 0x1fc00
-#define PF7_REG(reg_addr) (PF7_BASE + (reg_addr))
-
-#define PF_STRIDE 0x400
-#define PF_BASE(idx) (PF0_BASE + (idx) * PF_STRIDE)
-#define PF_REG(idx, reg) (PF_BASE(idx) + (reg))
-
-#define VF_SGE_BASE 0x0
-#define VF_SGE_REG(reg_addr) (VF_SGE_BASE + (reg_addr))
-
-#define VF_MPS_BASE 0x100
-#define VF_MPS_REG(reg_addr) (VF_MPS_BASE + (reg_addr))
-
-#define VF_PL_BASE 0x200
-#define VF_PL_REG(reg_addr) (VF_PL_BASE + (reg_addr))
-
-#define VF_MBDATA_BASE 0x240
-#define VF_MBDATA_REG(reg_addr) (VF_MBDATA_BASE + (reg_addr))
-
-#define VF_CIM_BASE 0x300
-#define VF_CIM_REG(reg_addr) (VF_CIM_BASE + (reg_addr))
-
-#define MYPORT_BASE 0x1c000
-#define MYPORT_REG(reg_addr) (MYPORT_BASE + (reg_addr))
-
-#define PORT0_BASE 0x20000
-#define PORT0_REG(reg_addr) (PORT0_BASE + (reg_addr))
-
-#define PORT1_BASE 0x22000
-#define PORT1_REG(reg_addr) (PORT1_BASE + (reg_addr))
-
-#define PORT2_BASE 0x24000
-#define PORT2_REG(reg_addr) (PORT2_BASE + (reg_addr))
-
-#define PORT3_BASE 0x26000
-#define PORT3_REG(reg_addr) (PORT3_BASE + (reg_addr))
-
-#define PORT_STRIDE 0x2000
-#define PORT_BASE(idx) (PORT0_BASE + (idx) * PORT_STRIDE)
-#define PORT_REG(idx, reg) (PORT_BASE(idx) + (reg))
-
-#define SGE_QUEUE_BASE_MAP_HIGH(idx) (A_SGE_QUEUE_BASE_MAP_HIGH + (idx) * 8)
-#define NUM_SGE_QUEUE_BASE_MAP_HIGH_INSTANCES 136
-
-#define SGE_QUEUE_BASE_MAP_LOW(idx) (A_SGE_QUEUE_BASE_MAP_LOW + (idx) * 8)
-#define NUM_SGE_QUEUE_BASE_MAP_LOW_INSTANCES 136
-
-#define PCIE_DMA_REG(reg_addr, idx) ((reg_addr) + (idx) * 8)
-#define NUM_PCIE_DMA_INSTANCES 4
-
-#define PCIE_CMD_REG(reg_addr, idx) ((reg_addr) + (idx) * 8)
-#define NUM_PCIE_CMD_INSTANCES 2
-
-#define PCIE_HMA_REG(reg_addr, idx) ((reg_addr) + (idx) * 8)
-#define NUM_PCIE_HMA_INSTANCES 1
-
-#define PCIE_MEM_ACCESS_REG(reg_addr, idx) ((reg_addr) + (idx) * 8)
-#define NUM_PCIE_MEM_ACCESS_INSTANCES 8
-
-#define PCIE_MAILBOX_REG(reg_addr, idx) ((reg_addr) + (idx) * 8)
-#define NUM_PCIE_MAILBOX_INSTANCES 1
-
-#define PCIE_FW_REG(reg_addr, idx) ((reg_addr) + (idx) * 4)
-#define NUM_PCIE_FW_INSTANCES 8
-
-#define PCIE_FUNC_REG(reg_addr, idx) ((reg_addr) + (idx) * 8)
-#define NUM_PCIE_FUNC_INSTANCES 256
-
-#define PCIE_FID(idx) (A_PCIE_FID + (idx) * 4)
-#define NUM_PCIE_FID_INSTANCES 2048
-
-#define PCIE_DMA_BUF_REG(reg_addr, idx) ((reg_addr) + (idx) * 8)
-#define NUM_PCIE_DMA_BUF_INSTANCES 4
-
-#define MC_DDR3PHYDATX8_REG(reg_addr, idx) ((reg_addr) + (idx) * 256)
-#define NUM_MC_DDR3PHYDATX8_INSTANCES 9
-
-#define MC_BIST_STATUS_REG(reg_addr, idx) ((reg_addr) + (idx) * 4)
-#define NUM_MC_BIST_STATUS_INSTANCES 18
-
-#define EDC_BIST_STATUS_REG(reg_addr, idx) ((reg_addr) + (idx) * 4)
-#define NUM_EDC_BIST_STATUS_INSTANCES 18
-
-#define CIM_PF_MAILBOX_DATA(idx) (A_CIM_PF_MAILBOX_DATA + (idx) * 4)
-#define NUM_CIM_PF_MAILBOX_DATA_INSTANCES 16
-
-#define MPS_TRC_FILTER_MATCH_CTL_A(idx) (A_MPS_TRC_FILTER_MATCH_CTL_A + (idx) * 4)
-#define NUM_MPS_TRC_FILTER_MATCH_CTL_A_INSTANCES 4
-
-#define MPS_TRC_FILTER_MATCH_CTL_B(idx) (A_MPS_TRC_FILTER_MATCH_CTL_B + (idx) * 4)
-#define NUM_MPS_TRC_FILTER_MATCH_CTL_B_INSTANCES 4
-
-#define MPS_TRC_FILTER_RUNT_CTL(idx) (A_MPS_TRC_FILTER_RUNT_CTL + (idx) * 4)
-#define NUM_MPS_TRC_FILTER_RUNT_CTL_INSTANCES 4
-
-#define MPS_TRC_FILTER_DROP(idx) (A_MPS_TRC_FILTER_DROP + (idx) * 4)
-#define NUM_MPS_TRC_FILTER_DROP_INSTANCES 4
-
-#define MPS_TRC_FILTER0_MATCH(idx) (A_MPS_TRC_FILTER0_MATCH + (idx) * 4)
-#define NUM_MPS_TRC_FILTER0_MATCH_INSTANCES 28
-
-#define MPS_TRC_FILTER0_DONT_CARE(idx) (A_MPS_TRC_FILTER0_DONT_CARE + (idx) * 4)
-#define NUM_MPS_TRC_FILTER0_DONT_CARE_INSTANCES 28
-
-#define MPS_TRC_FILTER1_MATCH(idx) (A_MPS_TRC_FILTER1_MATCH + (idx) * 4)
-#define NUM_MPS_TRC_FILTER1_MATCH_INSTANCES 28
-
-#define MPS_TRC_FILTER1_DONT_CARE(idx) (A_MPS_TRC_FILTER1_DONT_CARE + (idx) * 4)
-#define NUM_MPS_TRC_FILTER1_DONT_CARE_INSTANCES 28
-
-#define MPS_TRC_FILTER2_MATCH(idx) (A_MPS_TRC_FILTER2_MATCH + (idx) * 4)
-#define NUM_MPS_TRC_FILTER2_MATCH_INSTANCES 28
-
-#define MPS_TRC_FILTER2_DONT_CARE(idx) (A_MPS_TRC_FILTER2_DONT_CARE + (idx) * 4)
-#define NUM_MPS_TRC_FILTER2_DONT_CARE_INSTANCES 28
-
-#define MPS_TRC_FILTER3_MATCH(idx) (A_MPS_TRC_FILTER3_MATCH + (idx) * 4)
-#define NUM_MPS_TRC_FILTER3_MATCH_INSTANCES 28
-
-#define MPS_TRC_FILTER3_DONT_CARE(idx) (A_MPS_TRC_FILTER3_DONT_CARE + (idx) * 4)
-#define NUM_MPS_TRC_FILTER3_DONT_CARE_INSTANCES 28
-
-#define MPS_PORT_CLS_HASH_SRAM(idx) (A_MPS_PORT_CLS_HASH_SRAM + (idx) * 4)
-#define NUM_MPS_PORT_CLS_HASH_SRAM_INSTANCES 65
-
-#define MPS_CLS_VLAN_TABLE(idx) (A_MPS_CLS_VLAN_TABLE + (idx) * 4)
-#define NUM_MPS_CLS_VLAN_TABLE_INSTANCES 9
-
-#define MPS_CLS_SRAM_L(idx) (A_MPS_CLS_SRAM_L + (idx) * 8)
-#define NUM_MPS_CLS_SRAM_L_INSTANCES 336
-
-#define MPS_CLS_SRAM_H(idx) (A_MPS_CLS_SRAM_H + (idx) * 8)
-#define NUM_MPS_CLS_SRAM_H_INSTANCES 336
-
-#define MPS_CLS_TCAM_Y_L(idx) (A_MPS_CLS_TCAM_Y_L + (idx) * 16)
-#define NUM_MPS_CLS_TCAM_Y_L_INSTANCES 512
-
-#define MPS_CLS_TCAM_Y_H(idx) (A_MPS_CLS_TCAM_Y_H + (idx) * 16)
-#define NUM_MPS_CLS_TCAM_Y_H_INSTANCES 512
-
-#define MPS_CLS_TCAM_X_L(idx) (A_MPS_CLS_TCAM_X_L + (idx) * 16)
-#define NUM_MPS_CLS_TCAM_X_L_INSTANCES 512
-
-#define MPS_CLS_TCAM_X_H(idx) (A_MPS_CLS_TCAM_X_H + (idx) * 16)
-#define NUM_MPS_CLS_TCAM_X_H_INSTANCES 512
-
-#define PL_SEMAPHORE_LOCK(idx) (A_PL_SEMAPHORE_LOCK + (idx) * 4)
-#define NUM_PL_SEMAPHORE_LOCK_INSTANCES 8
-
-#define PL_VF_SLICE_L(idx) (A_PL_VF_SLICE_L + (idx) * 8)
-#define NUM_PL_VF_SLICE_L_INSTANCES 8
-
-#define PL_VF_SLICE_H(idx) (A_PL_VF_SLICE_H + (idx) * 8)
-#define NUM_PL_VF_SLICE_H_INSTANCES 8
-
-#define PL_FLR_VF_STATUS(idx) (A_PL_FLR_VF_STATUS + (idx) * 4)
-#define NUM_PL_FLR_VF_STATUS_INSTANCES 4
-
-#define PL_VFID_MAP(idx) (A_PL_VFID_MAP + (idx) * 4)
-#define NUM_PL_VFID_MAP_INSTANCES 256
-
-#define LE_DB_MASK_IPV4(idx) (A_LE_DB_MASK_IPV4 + (idx) * 4)
-#define NUM_LE_DB_MASK_IPV4_INSTANCES 17
-
-#define LE_DB_MASK_IPV6(idx) (A_LE_DB_MASK_IPV6 + (idx) * 4)
-#define NUM_LE_DB_MASK_IPV6_INSTANCES 17
-
-#define LE_DB_DBGI_REQ_DATA(idx) (A_LE_DB_DBGI_REQ_DATA + (idx) * 4)
-#define NUM_LE_DB_DBGI_REQ_DATA_INSTANCES 17
-
-#define LE_DB_DBGI_REQ_MASK(idx) (A_LE_DB_DBGI_REQ_MASK + (idx) * 4)
-#define NUM_LE_DB_DBGI_REQ_MASK_INSTANCES 17
-
-#define LE_DB_DBGI_RSP_DATA(idx) (A_LE_DB_DBGI_RSP_DATA + (idx) * 4)
-#define NUM_LE_DB_DBGI_RSP_DATA_INSTANCES 17
-
-#define LE_DB_ACTIVE_MASK_IPV4(idx) (A_LE_DB_ACTIVE_MASK_IPV4 + (idx) * 4)
-#define NUM_LE_DB_ACTIVE_MASK_IPV4_INSTANCES 17
-
-#define LE_DB_ACTIVE_MASK_IPV6(idx) (A_LE_DB_ACTIVE_MASK_IPV6 + (idx) * 4)
-#define NUM_LE_DB_ACTIVE_MASK_IPV6_INSTANCES 17
-
-#define LE_HASH_MASK_GEN_IPV4(idx) (A_LE_HASH_MASK_GEN_IPV4 + (idx) * 4)
-#define NUM_LE_HASH_MASK_GEN_IPV4_INSTANCES 4
-
-#define LE_HASH_MASK_GEN_IPV6(idx) (A_LE_HASH_MASK_GEN_IPV6 + (idx) * 4)
-#define NUM_LE_HASH_MASK_GEN_IPV6_INSTANCES 12
-
-#define LE_HASH_MASK_CMP_IPV4(idx) (A_LE_HASH_MASK_CMP_IPV4 + (idx) * 4)
-#define NUM_LE_HASH_MASK_CMP_IPV4_INSTANCES 4
-
-#define LE_HASH_MASK_CMP_IPV6(idx) (A_LE_HASH_MASK_CMP_IPV6 + (idx) * 4)
-#define NUM_LE_HASH_MASK_CMP_IPV6_INSTANCES 12
-
-#define UP_TSCH_CHANNEL_REG(reg_addr, idx) ((reg_addr) + (idx) * 16)
-#define NUM_UP_TSCH_CHANNEL_INSTANCES 4
-
-#define CIM_CTL_MAILBOX_VF_STATUS(idx) (A_CIM_CTL_MAILBOX_VF_STATUS + (idx) * 4)
-#define NUM_CIM_CTL_MAILBOX_VF_STATUS_INSTANCES 4
-
-#define CIM_CTL_MAILBOX_VFN_CTL(idx) (A_CIM_CTL_MAILBOX_VFN_CTL + (idx) * 16)
-#define NUM_CIM_CTL_MAILBOX_VFN_CTL_INSTANCES 128
-
-#define CIM_CTL_TSCH_CHANNEL_REG(reg_addr, idx) ((reg_addr) + (idx) * 288)
-#define NUM_CIM_CTL_TSCH_CHANNEL_INSTANCES 4
-
-#define CIM_CTL_TSCH_CHANNEL_TSCH_CLASS_REG(reg_addr, idx) ((reg_addr) + (idx) * 16)
-#define NUM_CIM_CTL_TSCH_CHANNEL_TSCH_CLASS_INSTANCES 16
-
-#define T5_MYPORT_BASE 0x2c000
-#define T5_MYPORT_REG(reg_addr) (T5_MYPORT_BASE + (reg_addr))
-
-#define T5_PORT0_BASE 0x30000
-#define T5_PORT0_REG(reg_addr) (T5_PORT0_BASE + (reg_addr))
-
-#define T5_PORT1_BASE 0x34000
-#define T5_PORT1_REG(reg_addr) (T5_PORT1_BASE + (reg_addr))
-
-#define T5_PORT2_BASE 0x38000
-#define T5_PORT2_REG(reg_addr) (T5_PORT2_BASE + (reg_addr))
-
-#define T5_PORT3_BASE 0x3c000
-#define T5_PORT3_REG(reg_addr) (T5_PORT3_BASE + (reg_addr))
-
-#define T5_PORT_STRIDE 0x4000
-#define T5_PORT_BASE(idx) (T5_PORT0_BASE + (idx) * T5_PORT_STRIDE)
-#define T5_PORT_REG(idx, reg) (T5_PORT_BASE(idx) + (reg))
-
-#define MC_STRIDE (MC_1_BASE_ADDR - MC_0_BASE_ADDR)
-#define MC_REG(reg, idx) (reg + MC_STRIDE * idx)
-
-#define PCIE_PF_INT_REG(reg_addr, idx) ((reg_addr) + (idx) * 8)
-#define NUM_PCIE_PF_INT_INSTANCES 8
-
-#define PCIE_VF_INT_REG(reg_addr, idx) ((reg_addr) + (idx) * 8)
-#define NUM_PCIE_VF_INT_INSTANCES 128
-
-#define PCIE_FID_VFID(idx) (A_PCIE_FID_VFID + (idx) * 4)
-#define NUM_PCIE_FID_VFID_INSTANCES 2048
-
-#define PCIE_COOKIE_REG(reg_addr, idx) ((reg_addr) + (idx) * 4)
-#define NUM_PCIE_COOKIE_INSTANCES 8
-
-#define PCIE_T5_DMA_REG(reg_addr, idx) ((reg_addr) + (idx) * 16)
-#define NUM_PCIE_T5_DMA_INSTANCES 4
-
-#define PCIE_T5_CMD_REG(reg_addr, idx) ((reg_addr) + (idx) * 16)
-#define NUM_PCIE_T5_CMD_INSTANCES 3
-
-#define PCIE_T5_HMA_REG(reg_addr, idx) ((reg_addr) + (idx) * 16)
-#define NUM_PCIE_T5_HMA_INSTANCES 1
-
-#define PCIE_PHY_PRESET_REG(reg_addr, idx) ((reg_addr) + (idx) * 4)
-#define NUM_PCIE_PHY_PRESET_INSTANCES 11
-
-#define MPS_T5_CLS_SRAM_L(idx) (A_MPS_T5_CLS_SRAM_L + (idx) * 8)
-#define NUM_MPS_T5_CLS_SRAM_L_INSTANCES 512
-
-#define MPS_T5_CLS_SRAM_H(idx) (A_MPS_T5_CLS_SRAM_H + (idx) * 8)
-#define NUM_MPS_T5_CLS_SRAM_H_INSTANCES 512
-
-#define LE_T5_DB_MASK_IPV4(idx) (A_LE_T5_DB_MASK_IPV4 + (idx) * 4)
-#define NUM_LE_T5_DB_MASK_IPV4_INSTANCES 5
-
-#define LE_T5_DB_ACTIVE_MASK_IPV4(idx) (A_LE_T5_DB_ACTIVE_MASK_IPV4 + (idx) * 4)
-#define NUM_LE_T5_DB_ACTIVE_MASK_IPV4_INSTANCES 5
-
-#define LE_HASH_MASK_GEN_IPV4T5(idx) (A_LE_HASH_MASK_GEN_IPV4T5 + (idx) * 4)
-#define NUM_LE_HASH_MASK_GEN_IPV4T5_INSTANCES 5
-
-#define LE_HASH_MASK_GEN_IPV6T5(idx) (A_LE_HASH_MASK_GEN_IPV6T5 + (idx) * 4)
-#define NUM_LE_HASH_MASK_GEN_IPV6T5_INSTANCES 12
-
-#define LE_HASH_MASK_CMP_IPV4T5(idx) (A_LE_HASH_MASK_CMP_IPV4T5 + (idx) * 4)
-#define NUM_LE_HASH_MASK_CMP_IPV4T5_INSTANCES 5
-
-#define LE_HASH_MASK_CMP_IPV6T5(idx) (A_LE_HASH_MASK_CMP_IPV6T5 + (idx) * 4)
-#define NUM_LE_HASH_MASK_CMP_IPV6T5_INSTANCES 12
-
-#define LE_DB_SECOND_ACTIVE_MASK_IPV4(idx) (A_LE_DB_SECOND_ACTIVE_MASK_IPV4 + (idx) * 4)
-#define NUM_LE_DB_SECOND_ACTIVE_MASK_IPV4_INSTANCES 5
-
-#define LE_DB_SECOND_GEN_HASH_MASK_IPV4(idx) (A_LE_DB_SECOND_GEN_HASH_MASK_IPV4 + (idx) * 4)
-#define NUM_LE_DB_SECOND_GEN_HASH_MASK_IPV4_INSTANCES 5
-
-#define LE_DB_SECOND_CMP_HASH_MASK_IPV4(idx) (A_LE_DB_SECOND_CMP_HASH_MASK_IPV4 + (idx) * 4)
-#define NUM_LE_DB_SECOND_CMP_HASH_MASK_IPV4_INSTANCES 5
-
-#define MC_ADR_REG(reg_addr, idx) ((reg_addr) + (idx) * 512)
-#define NUM_MC_ADR_INSTANCES 2
-
-#define MC_DDRPHY_DP18_REG(reg_addr, idx) ((reg_addr) + (idx) * 512)
-#define NUM_MC_DDRPHY_DP18_INSTANCES 5
-
-#define MC_CE_ERR_DATA_REG(reg_addr, idx) ((reg_addr) + (idx) * 4)
-#define NUM_MC_CE_ERR_DATA_INSTANCES 8
-
-#define MC_CE_COR_DATA_REG(reg_addr, idx) ((reg_addr) + (idx) * 4)
-#define NUM_MC_CE_COR_DATA_INSTANCES 8
-
-#define MC_UE_ERR_DATA_REG(reg_addr, idx) ((reg_addr) + (idx) * 4)
-#define NUM_MC_UE_ERR_DATA_INSTANCES 8
-
-#define MC_UE_COR_DATA_REG(reg_addr, idx) ((reg_addr) + (idx) * 4)
-#define NUM_MC_UE_COR_DATA_INSTANCES 8
-
-#define MC_P_BIST_STATUS_REG(reg_addr, idx) ((reg_addr) + (idx) * 4)
-#define NUM_MC_P_BIST_STATUS_INSTANCES 18
-
-#define EDC_H_BIST_STATUS_REG(reg_addr, idx) ((reg_addr) + (idx) * 4)
-#define NUM_EDC_H_BIST_STATUS_INSTANCES 18
-
-#define EDC_H_ECC_ERR_DATA_REG(reg_addr, idx) ((reg_addr) + (idx) * 4)
-#define NUM_EDC_H_ECC_ERR_DATA_INSTANCES 16
-
-#define SGE_DEBUG1_DBP_THREAD(idx) (A_SGE_DEBUG1_DBP_THREAD + (idx) * 4)
-#define NUM_SGE_DEBUG1_DBP_THREAD_INSTANCES 4
-
-#define SGE_DEBUG0_DBP_THREAD(idx) (A_SGE_DEBUG0_DBP_THREAD + (idx) * 4)
-#define NUM_SGE_DEBUG0_DBP_THREAD_INSTANCES 5
-
-#define SGE_WC_EGRS_BAR2_OFF_PF(idx) (A_SGE_WC_EGRS_BAR2_OFF_PF + (idx) * 4)
-#define NUM_SGE_WC_EGRS_BAR2_OFF_PF_INSTANCES 8
-
-#define SGE_WC_EGRS_BAR2_OFF_VF(idx) (A_SGE_WC_EGRS_BAR2_OFF_VF + (idx) * 4)
-#define NUM_SGE_WC_EGRS_BAR2_OFF_VF_INSTANCES 8
-
-#define PCIE_T6_DMA_REG(reg_addr, idx) ((reg_addr) + (idx) * 16)
-#define NUM_PCIE_T6_DMA_INSTANCES 2
-
-#define PCIE_T6_CMD_REG(reg_addr, idx) ((reg_addr) + (idx) * 16)
-#define NUM_PCIE_T6_CMD_INSTANCES 1
-
-#define PCIE_VF_256_INT_REG(reg_addr, idx) ((reg_addr) + (idx) * 4)
-#define NUM_PCIE_VF_256_INT_INSTANCES 128
-
-#define MPS_CLS_REQUEST_TRACE_MAC_DA_L(idx) (A_MPS_CLS_REQUEST_TRACE_MAC_DA_L + (idx) * 32)
-#define NUM_MPS_CLS_REQUEST_TRACE_MAC_DA_L_INSTANCES 8
-
-#define MPS_CLS_REQUEST_TRACE_MAC_DA_H(idx) (A_MPS_CLS_REQUEST_TRACE_MAC_DA_H + (idx) * 32)
-#define NUM_MPS_CLS_REQUEST_TRACE_MAC_DA_H_INSTANCES 8
-
-#define MPS_CLS_REQUEST_TRACE_MAC_SA_L(idx) (A_MPS_CLS_REQUEST_TRACE_MAC_SA_L + (idx) * 32)
-#define NUM_MPS_CLS_REQUEST_TRACE_MAC_SA_L_INSTANCES 8
-
-#define MPS_CLS_REQUEST_TRACE_MAC_SA_H(idx) (A_MPS_CLS_REQUEST_TRACE_MAC_SA_H + (idx) * 32)
-#define NUM_MPS_CLS_REQUEST_TRACE_MAC_SA_H_INSTANCES 8
-
-#define MPS_CLS_REQUEST_TRACE_PORT_VLAN(idx) (A_MPS_CLS_REQUEST_TRACE_PORT_VLAN + (idx) * 32)
-#define NUM_MPS_CLS_REQUEST_TRACE_PORT_VLAN_INSTANCES 8
-
-#define MPS_CLS_REQUEST_TRACE_ENCAP(idx) (A_MPS_CLS_REQUEST_TRACE_ENCAP + (idx) * 32)
-#define NUM_MPS_CLS_REQUEST_TRACE_ENCAP_INSTANCES 8
-
-#define MPS_CLS_RESULT_TRACE(idx) (A_MPS_CLS_RESULT_TRACE + (idx) * 4)
-#define NUM_MPS_CLS_RESULT_TRACE_INSTANCES 8
-
-#define MPS_CLS_DIPIPV4_ID_TABLE(idx) (A_MPS_CLS_DIPIPV4_ID_TABLE + (idx) * 8)
-#define NUM_MPS_CLS_DIPIPV4_ID_TABLE_INSTANCES 4
-
-#define MPS_CLS_DIPIPV4_MASK_TABLE(idx) (A_MPS_CLS_DIPIPV4_MASK_TABLE + (idx) * 8)
-#define NUM_MPS_CLS_DIPIPV4_MASK_TABLE_INSTANCES 4
-
-#define MPS_CLS_DIPIPV6ID_0_TABLE(idx) (A_MPS_CLS_DIPIPV6ID_0_TABLE + (idx) * 32)
-#define NUM_MPS_CLS_DIPIPV6ID_0_TABLE_INSTANCES 2
-
-#define MPS_CLS_DIPIPV6ID_1_TABLE(idx) (A_MPS_CLS_DIPIPV6ID_1_TABLE + (idx) * 32)
-#define NUM_MPS_CLS_DIPIPV6ID_1_TABLE_INSTANCES 2
-
-#define MPS_CLS_DIPIPV6ID_2_TABLE(idx) (A_MPS_CLS_DIPIPV6ID_2_TABLE + (idx) * 32)
-#define NUM_MPS_CLS_DIPIPV6ID_2_TABLE_INSTANCES 2
-
-#define MPS_CLS_DIPIPV6ID_3_TABLE(idx) (A_MPS_CLS_DIPIPV6ID_3_TABLE + (idx) * 32)
-#define NUM_MPS_CLS_DIPIPV6ID_3_TABLE_INSTANCES 2
-
-#define MPS_CLS_DIPIPV6MASK_0_TABLE(idx) (A_MPS_CLS_DIPIPV6MASK_0_TABLE + (idx) * 32)
-#define NUM_MPS_CLS_DIPIPV6MASK_0_TABLE_INSTANCES 2
-
-#define MPS_CLS_DIPIPV6MASK_1_TABLE(idx) (A_MPS_CLS_DIPIPV6MASK_1_TABLE + (idx) * 32)
-#define NUM_MPS_CLS_DIPIPV6MASK_1_TABLE_INSTANCES 2
-
-#define MPS_CLS_DIPIPV6MASK_2_TABLE(idx) (A_MPS_CLS_DIPIPV6MASK_2_TABLE + (idx) * 32)
-#define NUM_MPS_CLS_DIPIPV6MASK_2_TABLE_INSTANCES 2
-
-#define MPS_CLS_DIPIPV6MASK_3_TABLE(idx) (A_MPS_CLS_DIPIPV6MASK_3_TABLE + (idx) * 32)
-#define NUM_MPS_CLS_DIPIPV6MASK_3_TABLE_INSTANCES 2
-
-#define MPS_RX_HASH_LKP_TABLE(idx) (A_MPS_RX_HASH_LKP_TABLE + (idx) * 4)
-#define NUM_MPS_RX_HASH_LKP_TABLE_INSTANCES 4
-
-#define LE_DB_DBG_MATCH_DATA_MASK(idx) (A_LE_DB_DBG_MATCH_DATA_MASK + (idx) * 4)
-#define NUM_LE_DB_DBG_MATCH_DATA_MASK_INSTANCES 8
-
-#define LE_DB_DBG_MATCH_DATA(idx) (A_LE_DB_DBG_MATCH_DATA + (idx) * 4)
-#define NUM_LE_DB_DBG_MATCH_DATA_INSTANCES 8
-
-#define LE_DB_DBGI_REQ_DATA_T6(idx) (A_LE_DB_DBGI_REQ_DATA + (idx) * 4)
-#define NUM_LE_DB_DBGI_REQ_DATA_T6_INSTANCES 11
-
-#define LE_DB_DBGI_REQ_MASK_T6(idx) (A_LE_DB_DBGI_REQ_MASK + (idx) * 4)
-#define NUM_LE_DB_DBGI_REQ_MASK_T6_INSTANCES 11
-
-#define LE_DB_DBGI_RSP_DATA_T6(idx) (A_LE_DB_DBGI_RSP_DATA + (idx) * 4)
-#define NUM_LE_DB_DBGI_RSP_DATA_T6_INSTANCES 11
-
-#define LE_DB_ACTIVE_MASK_IPV6_T6(idx) (A_LE_DB_ACTIVE_MASK_IPV6 + (idx) * 4)
-#define NUM_LE_DB_ACTIVE_MASK_IPV6_T6_INSTANCES 8
-
-#define LE_HASH_MASK_GEN_IPV4T6(idx) (A_LE_HASH_MASK_GEN_IPV4T5 + (idx) * 4)
-#define NUM_LE_HASH_MASK_GEN_IPV4T6_INSTANCES 8
-
-#define T6_LE_HASH_MASK_GEN_IPV6T5(idx) (A_T6_LE_HASH_MASK_GEN_IPV6T5 + (idx) * 4)
-#define NUM_T6_LE_HASH_MASK_GEN_IPV6T5_INSTANCES 8
-
-#define LE_DB_PSV_FILTER_MASK_TUP_IPV4(idx) (A_LE_DB_PSV_FILTER_MASK_TUP_IPV4 + (idx) * 4)
-#define NUM_LE_DB_PSV_FILTER_MASK_TUP_IPV4_INSTANCES 3
-
-#define LE_DB_PSV_FILTER_MASK_FLT_IPV4(idx) (A_LE_DB_PSV_FILTER_MASK_FLT_IPV4 + (idx) * 4)
-#define NUM_LE_DB_PSV_FILTER_MASK_FLT_IPV4_INSTANCES 2
-
-#define LE_DB_PSV_FILTER_MASK_TUP_IPV6(idx) (A_LE_DB_PSV_FILTER_MASK_TUP_IPV6 + (idx) * 4)
-#define NUM_LE_DB_PSV_FILTER_MASK_TUP_IPV6_INSTANCES 9
-
-#define LE_DB_PSV_FILTER_MASK_FLT_IPV6(idx) (A_LE_DB_PSV_FILTER_MASK_FLT_IPV6 + (idx) * 4)
-#define NUM_LE_DB_PSV_FILTER_MASK_FLT_IPV6_INSTANCES 2
-
-#define LE_DB_SECOND_GEN_HASH_MASK_IPV4_T6(idx) (A_LE_DB_SECOND_GEN_HASH_MASK_IPV4 + (idx) * 4)
-#define NUM_LE_DB_SECOND_GEN_HASH_MASK_IPV4_T6_INSTANCES 8
-
-#define MC_DDRPHY_DP18_T6_REG(reg_addr, idx) ((reg_addr) + (idx) * 512)
-#define NUM_MC_DDRPHY_DP18_T6_INSTANCES 9
-
-#define MC_CE_ERR_DATA_T6_REG(reg_addr, idx) ((reg_addr) + (idx) * 4)
-#define NUM_MC_CE_ERR_DATA_T6_INSTANCES 16
-
-#define MC_UE_ERR_DATA_T6_REG(reg_addr, idx) ((reg_addr) + (idx) * 4)
-#define NUM_MC_UE_ERR_DATA_T6_INSTANCES 16
-
-#define CIM_CTL_MAILBOX_VF_STATUS_T6(idx) (A_CIM_CTL_MAILBOX_VF_STATUS + (idx) * 4)
-#define NUM_CIM_CTL_MAILBOX_VF_STATUS_T6_INSTANCES 8
-
-#define CIM_CTL_MAILBOX_VFN_CTL_T6(idx) (A_CIM_CTL_MAILBOX_VFN_CTL + (idx) * 4)
-#define NUM_CIM_CTL_MAILBOX_VFN_CTL_T6_INSTANCES 256
-
-#define EDC_STRIDE (EDC_1_BASE_ADDR - EDC_0_BASE_ADDR)
-#define EDC_REG(reg, idx) (reg + EDC_STRIDE * idx)
-
-#define EDC_T5_STRIDE (EDC_T51_BASE_ADDR - EDC_T50_BASE_ADDR)
-#define EDC_T5_REG(reg, idx) (reg + EDC_T5_STRIDE * idx)
-
-/* registers for module SGE */
-#define SGE_BASE_ADDR 0x1000
-
-#define A_SGE_PF_KDOORBELL 0x0
-
-#define S_QID 15
-#define M_QID 0x1ffffU
-#define V_QID(x) ((x) << S_QID)
-#define G_QID(x) (((x) >> S_QID) & M_QID)
-
-#define S_DBPRIO 14
-#define V_DBPRIO(x) ((x) << S_DBPRIO)
-#define F_DBPRIO V_DBPRIO(1U)
-
-#define S_PIDX 0
-#define M_PIDX 0x3fffU
-#define V_PIDX(x) ((x) << S_PIDX)
-#define G_PIDX(x) (((x) >> S_PIDX) & M_PIDX)
-
-#define A_SGE_VF_KDOORBELL 0x0
-
-#define S_DBTYPE 13
-#define V_DBTYPE(x) ((x) << S_DBTYPE)
-#define F_DBTYPE V_DBTYPE(1U)
-
-#define S_PIDX_T5 0
-#define M_PIDX_T5 0x1fffU
-#define V_PIDX_T5(x) ((x) << S_PIDX_T5)
-#define G_PIDX_T5(x) (((x) >> S_PIDX_T5) & M_PIDX_T5)
-
-#define S_SYNC_T6 14
-#define V_SYNC_T6(x) ((x) << S_SYNC_T6)
-#define F_SYNC_T6 V_SYNC_T6(1U)
-
-#define A_SGE_PF_GTS 0x4
-
-#define S_INGRESSQID 16
-#define M_INGRESSQID 0xffffU
-#define V_INGRESSQID(x) ((x) << S_INGRESSQID)
-#define G_INGRESSQID(x) (((x) >> S_INGRESSQID) & M_INGRESSQID)
-
-#define S_TIMERREG 13
-#define M_TIMERREG 0x7U
-#define V_TIMERREG(x) ((x) << S_TIMERREG)
-#define G_TIMERREG(x) (((x) >> S_TIMERREG) & M_TIMERREG)
-
-#define S_SEINTARM 12
-#define V_SEINTARM(x) ((x) << S_SEINTARM)
-#define F_SEINTARM V_SEINTARM(1U)
-
-#define S_CIDXINC 0
-#define M_CIDXINC 0xfffU
-#define V_CIDXINC(x) ((x) << S_CIDXINC)
-#define G_CIDXINC(x) (((x) >> S_CIDXINC) & M_CIDXINC)
-
-#define A_SGE_VF_GTS 0x4
-#define A_SGE_PF_KTIMESTAMP_LO 0x8
-#define A_SGE_VF_KTIMESTAMP_LO 0x8
-#define A_SGE_PF_KTIMESTAMP_HI 0xc
-
-#define S_TSTAMPVAL 0
-#define M_TSTAMPVAL 0xfffffffU
-#define V_TSTAMPVAL(x) ((x) << S_TSTAMPVAL)
-#define G_TSTAMPVAL(x) (((x) >> S_TSTAMPVAL) & M_TSTAMPVAL)
-
-#define A_SGE_VF_KTIMESTAMP_HI 0xc
-#define A_SGE_CONTROL 0x1008
-
-#define S_IGRALLCPLTOFL 31
-#define V_IGRALLCPLTOFL(x) ((x) << S_IGRALLCPLTOFL)
-#define F_IGRALLCPLTOFL V_IGRALLCPLTOFL(1U)
-
-#define S_FLSPLITMIN 22
-#define M_FLSPLITMIN 0x1ffU
-#define V_FLSPLITMIN(x) ((x) << S_FLSPLITMIN)
-#define G_FLSPLITMIN(x) (((x) >> S_FLSPLITMIN) & M_FLSPLITMIN)
-
-#define S_FLSPLITMODE 20
-#define M_FLSPLITMODE 0x3U
-#define V_FLSPLITMODE(x) ((x) << S_FLSPLITMODE)
-#define G_FLSPLITMODE(x) (((x) >> S_FLSPLITMODE) & M_FLSPLITMODE)
-
-#define S_DCASYSTYPE 19
-#define V_DCASYSTYPE(x) ((x) << S_DCASYSTYPE)
-#define F_DCASYSTYPE V_DCASYSTYPE(1U)
-
-#define S_RXPKTCPLMODE 18
-#define V_RXPKTCPLMODE(x) ((x) << S_RXPKTCPLMODE)
-#define F_RXPKTCPLMODE V_RXPKTCPLMODE(1U)
-
-#define S_EGRSTATUSPAGESIZE 17
-#define V_EGRSTATUSPAGESIZE(x) ((x) << S_EGRSTATUSPAGESIZE)
-#define F_EGRSTATUSPAGESIZE V_EGRSTATUSPAGESIZE(1U)
-
-#define S_INGHINTENABLE1 15
-#define V_INGHINTENABLE1(x) ((x) << S_INGHINTENABLE1)
-#define F_INGHINTENABLE1 V_INGHINTENABLE1(1U)
-
-#define S_INGHINTENABLE0 14
-#define V_INGHINTENABLE0(x) ((x) << S_INGHINTENABLE0)
-#define F_INGHINTENABLE0 V_INGHINTENABLE0(1U)
-
-#define S_INGINTCOMPAREIDX 13
-#define V_INGINTCOMPAREIDX(x) ((x) << S_INGINTCOMPAREIDX)
-#define F_INGINTCOMPAREIDX V_INGINTCOMPAREIDX(1U)
-
-#define S_PKTSHIFT 10
-#define M_PKTSHIFT 0x7U
-#define V_PKTSHIFT(x) ((x) << S_PKTSHIFT)
-#define G_PKTSHIFT(x) (((x) >> S_PKTSHIFT) & M_PKTSHIFT)
-
-#define S_INGPCIEBOUNDARY 7
-#define M_INGPCIEBOUNDARY 0x7U
-#define V_INGPCIEBOUNDARY(x) ((x) << S_INGPCIEBOUNDARY)
-#define G_INGPCIEBOUNDARY(x) (((x) >> S_INGPCIEBOUNDARY) & M_INGPCIEBOUNDARY)
-
-#define S_INGPADBOUNDARY 4
-#define M_INGPADBOUNDARY 0x7U
-#define V_INGPADBOUNDARY(x) ((x) << S_INGPADBOUNDARY)
-#define G_INGPADBOUNDARY(x) (((x) >> S_INGPADBOUNDARY) & M_INGPADBOUNDARY)
-
-#define S_EGRPCIEBOUNDARY 1
-#define M_EGRPCIEBOUNDARY 0x7U
-#define V_EGRPCIEBOUNDARY(x) ((x) << S_EGRPCIEBOUNDARY)
-#define G_EGRPCIEBOUNDARY(x) (((x) >> S_EGRPCIEBOUNDARY) & M_EGRPCIEBOUNDARY)
-
-#define S_GLOBALENABLE 0
-#define V_GLOBALENABLE(x) ((x) << S_GLOBALENABLE)
-#define F_GLOBALENABLE V_GLOBALENABLE(1U)
-
-#define A_SGE_HOST_PAGE_SIZE 0x100c
-
-#define S_HOSTPAGESIZEPF7 28
-#define M_HOSTPAGESIZEPF7 0xfU
-#define V_HOSTPAGESIZEPF7(x) ((x) << S_HOSTPAGESIZEPF7)
-#define G_HOSTPAGESIZEPF7(x) (((x) >> S_HOSTPAGESIZEPF7) & M_HOSTPAGESIZEPF7)
-
-#define S_HOSTPAGESIZEPF6 24
-#define M_HOSTPAGESIZEPF6 0xfU
-#define V_HOSTPAGESIZEPF6(x) ((x) << S_HOSTPAGESIZEPF6)
-#define G_HOSTPAGESIZEPF6(x) (((x) >> S_HOSTPAGESIZEPF6) & M_HOSTPAGESIZEPF6)
-
-#define S_HOSTPAGESIZEPF5 20
-#define M_HOSTPAGESIZEPF5 0xfU
-#define V_HOSTPAGESIZEPF5(x) ((x) << S_HOSTPAGESIZEPF5)
-#define G_HOSTPAGESIZEPF5(x) (((x) >> S_HOSTPAGESIZEPF5) & M_HOSTPAGESIZEPF5)
-
-#define S_HOSTPAGESIZEPF4 16
-#define M_HOSTPAGESIZEPF4 0xfU
-#define V_HOSTPAGESIZEPF4(x) ((x) << S_HOSTPAGESIZEPF4)
-#define G_HOSTPAGESIZEPF4(x) (((x) >> S_HOSTPAGESIZEPF4) & M_HOSTPAGESIZEPF4)
-
-#define S_HOSTPAGESIZEPF3 12
-#define M_HOSTPAGESIZEPF3 0xfU
-#define V_HOSTPAGESIZEPF3(x) ((x) << S_HOSTPAGESIZEPF3)
-#define G_HOSTPAGESIZEPF3(x) (((x) >> S_HOSTPAGESIZEPF3) & M_HOSTPAGESIZEPF3)
-
-#define S_HOSTPAGESIZEPF2 8
-#define M_HOSTPAGESIZEPF2 0xfU
-#define V_HOSTPAGESIZEPF2(x) ((x) << S_HOSTPAGESIZEPF2)
-#define G_HOSTPAGESIZEPF2(x) (((x) >> S_HOSTPAGESIZEPF2) & M_HOSTPAGESIZEPF2)
-
-#define S_HOSTPAGESIZEPF1 4
-#define M_HOSTPAGESIZEPF1 0xfU
-#define V_HOSTPAGESIZEPF1(x) ((x) << S_HOSTPAGESIZEPF1)
-#define G_HOSTPAGESIZEPF1(x) (((x) >> S_HOSTPAGESIZEPF1) & M_HOSTPAGESIZEPF1)
-
-#define S_HOSTPAGESIZEPF0 0
-#define M_HOSTPAGESIZEPF0 0xfU
-#define V_HOSTPAGESIZEPF0(x) ((x) << S_HOSTPAGESIZEPF0)
-#define G_HOSTPAGESIZEPF0(x) (((x) >> S_HOSTPAGESIZEPF0) & M_HOSTPAGESIZEPF0)
-
-#define A_SGE_EGRESS_QUEUES_PER_PAGE_PF 0x1010
-
-#define S_QUEUESPERPAGEPF7 28
-#define M_QUEUESPERPAGEPF7 0xfU
-#define V_QUEUESPERPAGEPF7(x) ((x) << S_QUEUESPERPAGEPF7)
-#define G_QUEUESPERPAGEPF7(x) (((x) >> S_QUEUESPERPAGEPF7) & M_QUEUESPERPAGEPF7)
-
-#define S_QUEUESPERPAGEPF6 24
-#define M_QUEUESPERPAGEPF6 0xfU
-#define V_QUEUESPERPAGEPF6(x) ((x) << S_QUEUESPERPAGEPF6)
-#define G_QUEUESPERPAGEPF6(x) (((x) >> S_QUEUESPERPAGEPF6) & M_QUEUESPERPAGEPF6)
-
-#define S_QUEUESPERPAGEPF5 20
-#define M_QUEUESPERPAGEPF5 0xfU
-#define V_QUEUESPERPAGEPF5(x) ((x) << S_QUEUESPERPAGEPF5)
-#define G_QUEUESPERPAGEPF5(x) (((x) >> S_QUEUESPERPAGEPF5) & M_QUEUESPERPAGEPF5)
-
-#define S_QUEUESPERPAGEPF4 16
-#define M_QUEUESPERPAGEPF4 0xfU
-#define V_QUEUESPERPAGEPF4(x) ((x) << S_QUEUESPERPAGEPF4)
-#define G_QUEUESPERPAGEPF4(x) (((x) >> S_QUEUESPERPAGEPF4) & M_QUEUESPERPAGEPF4)
-
-#define S_QUEUESPERPAGEPF3 12
-#define M_QUEUESPERPAGEPF3 0xfU
-#define V_QUEUESPERPAGEPF3(x) ((x) << S_QUEUESPERPAGEPF3)
-#define G_QUEUESPERPAGEPF3(x) (((x) >> S_QUEUESPERPAGEPF3) & M_QUEUESPERPAGEPF3)
-
-#define S_QUEUESPERPAGEPF2 8
-#define M_QUEUESPERPAGEPF2 0xfU
-#define V_QUEUESPERPAGEPF2(x) ((x) << S_QUEUESPERPAGEPF2)
-#define G_QUEUESPERPAGEPF2(x) (((x) >> S_QUEUESPERPAGEPF2) & M_QUEUESPERPAGEPF2)
-
-#define S_QUEUESPERPAGEPF1 4
-#define M_QUEUESPERPAGEPF1 0xfU
-#define V_QUEUESPERPAGEPF1(x) ((x) << S_QUEUESPERPAGEPF1)
-#define G_QUEUESPERPAGEPF1(x) (((x) >> S_QUEUESPERPAGEPF1) & M_QUEUESPERPAGEPF1)
-
-#define S_QUEUESPERPAGEPF0 0
-#define M_QUEUESPERPAGEPF0 0xfU
-#define V_QUEUESPERPAGEPF0(x) ((x) << S_QUEUESPERPAGEPF0)
-#define G_QUEUESPERPAGEPF0(x) (((x) >> S_QUEUESPERPAGEPF0) & M_QUEUESPERPAGEPF0)
-
-#define A_SGE_EGRESS_QUEUES_PER_PAGE_VF 0x1014
-
-#define S_QUEUESPERPAGEVFPF7 28
-#define M_QUEUESPERPAGEVFPF7 0xfU
-#define V_QUEUESPERPAGEVFPF7(x) ((x) << S_QUEUESPERPAGEVFPF7)
-#define G_QUEUESPERPAGEVFPF7(x) (((x) >> S_QUEUESPERPAGEVFPF7) & M_QUEUESPERPAGEVFPF7)
-
-#define S_QUEUESPERPAGEVFPF6 24
-#define M_QUEUESPERPAGEVFPF6 0xfU
-#define V_QUEUESPERPAGEVFPF6(x) ((x) << S_QUEUESPERPAGEVFPF6)
-#define G_QUEUESPERPAGEVFPF6(x) (((x) >> S_QUEUESPERPAGEVFPF6) & M_QUEUESPERPAGEVFPF6)
-
-#define S_QUEUESPERPAGEVFPF5 20
-#define M_QUEUESPERPAGEVFPF5 0xfU
-#define V_QUEUESPERPAGEVFPF5(x) ((x) << S_QUEUESPERPAGEVFPF5)
-#define G_QUEUESPERPAGEVFPF5(x) (((x) >> S_QUEUESPERPAGEVFPF5) & M_QUEUESPERPAGEVFPF5)
-
-#define S_QUEUESPERPAGEVFPF4 16
-#define M_QUEUESPERPAGEVFPF4 0xfU
-#define V_QUEUESPERPAGEVFPF4(x) ((x) << S_QUEUESPERPAGEVFPF4)
-#define G_QUEUESPERPAGEVFPF4(x) (((x) >> S_QUEUESPERPAGEVFPF4) & M_QUEUESPERPAGEVFPF4)
-
-#define S_QUEUESPERPAGEVFPF3 12
-#define M_QUEUESPERPAGEVFPF3 0xfU
-#define V_QUEUESPERPAGEVFPF3(x) ((x) << S_QUEUESPERPAGEVFPF3)
-#define G_QUEUESPERPAGEVFPF3(x) (((x) >> S_QUEUESPERPAGEVFPF3) & M_QUEUESPERPAGEVFPF3)
-
-#define S_QUEUESPERPAGEVFPF2 8
-#define M_QUEUESPERPAGEVFPF2 0xfU
-#define V_QUEUESPERPAGEVFPF2(x) ((x) << S_QUEUESPERPAGEVFPF2)
-#define G_QUEUESPERPAGEVFPF2(x) (((x) >> S_QUEUESPERPAGEVFPF2) & M_QUEUESPERPAGEVFPF2)
-
-#define S_QUEUESPERPAGEVFPF1 4
-#define M_QUEUESPERPAGEVFPF1 0xfU
-#define V_QUEUESPERPAGEVFPF1(x) ((x) << S_QUEUESPERPAGEVFPF1)
-#define G_QUEUESPERPAGEVFPF1(x) (((x) >> S_QUEUESPERPAGEVFPF1) & M_QUEUESPERPAGEVFPF1)
-
-#define S_QUEUESPERPAGEVFPF0 0
-#define M_QUEUESPERPAGEVFPF0 0xfU
-#define V_QUEUESPERPAGEVFPF0(x) ((x) << S_QUEUESPERPAGEVFPF0)
-#define G_QUEUESPERPAGEVFPF0(x) (((x) >> S_QUEUESPERPAGEVFPF0) & M_QUEUESPERPAGEVFPF0)
-
-#define A_SGE_USER_MODE_LIMITS 0x1018
-
-#define S_OPCODE_MIN 24
-#define M_OPCODE_MIN 0xffU
-#define V_OPCODE_MIN(x) ((x) << S_OPCODE_MIN)
-#define G_OPCODE_MIN(x) (((x) >> S_OPCODE_MIN) & M_OPCODE_MIN)
-
-#define S_OPCODE_MAX 16
-#define M_OPCODE_MAX 0xffU
-#define V_OPCODE_MAX(x) ((x) << S_OPCODE_MAX)
-#define G_OPCODE_MAX(x) (((x) >> S_OPCODE_MAX) & M_OPCODE_MAX)
-
-#define S_LENGTH_MIN 8
-#define M_LENGTH_MIN 0xffU
-#define V_LENGTH_MIN(x) ((x) << S_LENGTH_MIN)
-#define G_LENGTH_MIN(x) (((x) >> S_LENGTH_MIN) & M_LENGTH_MIN)
-
-#define S_LENGTH_MAX 0
-#define M_LENGTH_MAX 0xffU
-#define V_LENGTH_MAX(x) ((x) << S_LENGTH_MAX)
-#define G_LENGTH_MAX(x) (((x) >> S_LENGTH_MAX) & M_LENGTH_MAX)
-
-#define A_SGE_WR_ERROR 0x101c
-
-#define S_WR_ERROR_OPCODE 0
-#define M_WR_ERROR_OPCODE 0xffU
-#define V_WR_ERROR_OPCODE(x) ((x) << S_WR_ERROR_OPCODE)
-#define G_WR_ERROR_OPCODE(x) (((x) >> S_WR_ERROR_OPCODE) & M_WR_ERROR_OPCODE)
-
-#define A_SGE_PERR_INJECT 0x1020
-
-#define S_MEMSEL 1
-#define M_MEMSEL 0x1fU
-#define V_MEMSEL(x) ((x) << S_MEMSEL)
-#define G_MEMSEL(x) (((x) >> S_MEMSEL) & M_MEMSEL)
-
-#define S_INJECTDATAERR 0
-#define V_INJECTDATAERR(x) ((x) << S_INJECTDATAERR)
-#define F_INJECTDATAERR V_INJECTDATAERR(1U)
-
-#define A_SGE_INT_CAUSE1 0x1024
-
-#define S_PERR_FLM_CREDITFIFO 30
-#define V_PERR_FLM_CREDITFIFO(x) ((x) << S_PERR_FLM_CREDITFIFO)
-#define F_PERR_FLM_CREDITFIFO V_PERR_FLM_CREDITFIFO(1U)
-
-#define S_PERR_IMSG_HINT_FIFO 29
-#define V_PERR_IMSG_HINT_FIFO(x) ((x) << S_PERR_IMSG_HINT_FIFO)
-#define F_PERR_IMSG_HINT_FIFO V_PERR_IMSG_HINT_FIFO(1U)
-
-#define S_PERR_MC_PC 28
-#define V_PERR_MC_PC(x) ((x) << S_PERR_MC_PC)
-#define F_PERR_MC_PC V_PERR_MC_PC(1U)
-
-#define S_PERR_MC_IGR_CTXT 27
-#define V_PERR_MC_IGR_CTXT(x) ((x) << S_PERR_MC_IGR_CTXT)
-#define F_PERR_MC_IGR_CTXT V_PERR_MC_IGR_CTXT(1U)
-
-#define S_PERR_MC_EGR_CTXT 26
-#define V_PERR_MC_EGR_CTXT(x) ((x) << S_PERR_MC_EGR_CTXT)
-#define F_PERR_MC_EGR_CTXT V_PERR_MC_EGR_CTXT(1U)
-
-#define S_PERR_MC_FLM 25
-#define V_PERR_MC_FLM(x) ((x) << S_PERR_MC_FLM)
-#define F_PERR_MC_FLM V_PERR_MC_FLM(1U)
-
-#define S_PERR_PC_MCTAG 24
-#define V_PERR_PC_MCTAG(x) ((x) << S_PERR_PC_MCTAG)
-#define F_PERR_PC_MCTAG V_PERR_PC_MCTAG(1U)
-
-#define S_PERR_PC_CHPI_RSP1 23
-#define V_PERR_PC_CHPI_RSP1(x) ((x) << S_PERR_PC_CHPI_RSP1)
-#define F_PERR_PC_CHPI_RSP1 V_PERR_PC_CHPI_RSP1(1U)
-
-#define S_PERR_PC_CHPI_RSP0 22
-#define V_PERR_PC_CHPI_RSP0(x) ((x) << S_PERR_PC_CHPI_RSP0)
-#define F_PERR_PC_CHPI_RSP0 V_PERR_PC_CHPI_RSP0(1U)
-
-#define S_PERR_DBP_PC_RSP_FIFO3 21
-#define V_PERR_DBP_PC_RSP_FIFO3(x) ((x) << S_PERR_DBP_PC_RSP_FIFO3)
-#define F_PERR_DBP_PC_RSP_FIFO3 V_PERR_DBP_PC_RSP_FIFO3(1U)
-
-#define S_PERR_DBP_PC_RSP_FIFO2 20
-#define V_PERR_DBP_PC_RSP_FIFO2(x) ((x) << S_PERR_DBP_PC_RSP_FIFO2)
-#define F_PERR_DBP_PC_RSP_FIFO2 V_PERR_DBP_PC_RSP_FIFO2(1U)
-
-#define S_PERR_DBP_PC_RSP_FIFO1 19
-#define V_PERR_DBP_PC_RSP_FIFO1(x) ((x) << S_PERR_DBP_PC_RSP_FIFO1)
-#define F_PERR_DBP_PC_RSP_FIFO1 V_PERR_DBP_PC_RSP_FIFO1(1U)
-
-#define S_PERR_DBP_PC_RSP_FIFO0 18
-#define V_PERR_DBP_PC_RSP_FIFO0(x) ((x) << S_PERR_DBP_PC_RSP_FIFO0)
-#define F_PERR_DBP_PC_RSP_FIFO0 V_PERR_DBP_PC_RSP_FIFO0(1U)
-
-#define S_PERR_DMARBT 17
-#define V_PERR_DMARBT(x) ((x) << S_PERR_DMARBT)
-#define F_PERR_DMARBT V_PERR_DMARBT(1U)
-
-#define S_PERR_FLM_DBPFIFO 16
-#define V_PERR_FLM_DBPFIFO(x) ((x) << S_PERR_FLM_DBPFIFO)
-#define F_PERR_FLM_DBPFIFO V_PERR_FLM_DBPFIFO(1U)
-
-#define S_PERR_FLM_MCREQ_FIFO 15
-#define V_PERR_FLM_MCREQ_FIFO(x) ((x) << S_PERR_FLM_MCREQ_FIFO)
-#define F_PERR_FLM_MCREQ_FIFO V_PERR_FLM_MCREQ_FIFO(1U)
-
-#define S_PERR_FLM_HINTFIFO 14
-#define V_PERR_FLM_HINTFIFO(x) ((x) << S_PERR_FLM_HINTFIFO)
-#define F_PERR_FLM_HINTFIFO V_PERR_FLM_HINTFIFO(1U)
-
-#define S_PERR_ALIGN_CTL_FIFO3 13
-#define V_PERR_ALIGN_CTL_FIFO3(x) ((x) << S_PERR_ALIGN_CTL_FIFO3)
-#define F_PERR_ALIGN_CTL_FIFO3 V_PERR_ALIGN_CTL_FIFO3(1U)
-
-#define S_PERR_ALIGN_CTL_FIFO2 12
-#define V_PERR_ALIGN_CTL_FIFO2(x) ((x) << S_PERR_ALIGN_CTL_FIFO2)
-#define F_PERR_ALIGN_CTL_FIFO2 V_PERR_ALIGN_CTL_FIFO2(1U)
-
-#define S_PERR_ALIGN_CTL_FIFO1 11
-#define V_PERR_ALIGN_CTL_FIFO1(x) ((x) << S_PERR_ALIGN_CTL_FIFO1)
-#define F_PERR_ALIGN_CTL_FIFO1 V_PERR_ALIGN_CTL_FIFO1(1U)
-
-#define S_PERR_ALIGN_CTL_FIFO0 10
-#define V_PERR_ALIGN_CTL_FIFO0(x) ((x) << S_PERR_ALIGN_CTL_FIFO0)
-#define F_PERR_ALIGN_CTL_FIFO0 V_PERR_ALIGN_CTL_FIFO0(1U)
-
-#define S_PERR_EDMA_FIFO3 9
-#define V_PERR_EDMA_FIFO3(x) ((x) << S_PERR_EDMA_FIFO3)
-#define F_PERR_EDMA_FIFO3 V_PERR_EDMA_FIFO3(1U)
-
-#define S_PERR_EDMA_FIFO2 8
-#define V_PERR_EDMA_FIFO2(x) ((x) << S_PERR_EDMA_FIFO2)
-#define F_PERR_EDMA_FIFO2 V_PERR_EDMA_FIFO2(1U)
-
-#define S_PERR_EDMA_FIFO1 7
-#define V_PERR_EDMA_FIFO1(x) ((x) << S_PERR_EDMA_FIFO1)
-#define F_PERR_EDMA_FIFO1 V_PERR_EDMA_FIFO1(1U)
-
-#define S_PERR_EDMA_FIFO0 6
-#define V_PERR_EDMA_FIFO0(x) ((x) << S_PERR_EDMA_FIFO0)
-#define F_PERR_EDMA_FIFO0 V_PERR_EDMA_FIFO0(1U)
-
-#define S_PERR_PD_FIFO3 5
-#define V_PERR_PD_FIFO3(x) ((x) << S_PERR_PD_FIFO3)
-#define F_PERR_PD_FIFO3 V_PERR_PD_FIFO3(1U)
-
-#define S_PERR_PD_FIFO2 4
-#define V_PERR_PD_FIFO2(x) ((x) << S_PERR_PD_FIFO2)
-#define F_PERR_PD_FIFO2 V_PERR_PD_FIFO2(1U)
-
-#define S_PERR_PD_FIFO1 3
-#define V_PERR_PD_FIFO1(x) ((x) << S_PERR_PD_FIFO1)
-#define F_PERR_PD_FIFO1 V_PERR_PD_FIFO1(1U)
-
-#define S_PERR_PD_FIFO0 2
-#define V_PERR_PD_FIFO0(x) ((x) << S_PERR_PD_FIFO0)
-#define F_PERR_PD_FIFO0 V_PERR_PD_FIFO0(1U)
-
-#define S_PERR_ING_CTXT_MIFRSP 1
-#define V_PERR_ING_CTXT_MIFRSP(x) ((x) << S_PERR_ING_CTXT_MIFRSP)
-#define F_PERR_ING_CTXT_MIFRSP V_PERR_ING_CTXT_MIFRSP(1U)
-
-#define S_PERR_EGR_CTXT_MIFRSP 0
-#define V_PERR_EGR_CTXT_MIFRSP(x) ((x) << S_PERR_EGR_CTXT_MIFRSP)
-#define F_PERR_EGR_CTXT_MIFRSP V_PERR_EGR_CTXT_MIFRSP(1U)
-
-#define S_PERR_PC_CHPI_RSP2 31
-#define V_PERR_PC_CHPI_RSP2(x) ((x) << S_PERR_PC_CHPI_RSP2)
-#define F_PERR_PC_CHPI_RSP2 V_PERR_PC_CHPI_RSP2(1U)
-
-#define S_PERR_PC_RSP 23
-#define V_PERR_PC_RSP(x) ((x) << S_PERR_PC_RSP)
-#define F_PERR_PC_RSP V_PERR_PC_RSP(1U)
-
-#define S_PERR_PC_REQ 22
-#define V_PERR_PC_REQ(x) ((x) << S_PERR_PC_REQ)
-#define F_PERR_PC_REQ V_PERR_PC_REQ(1U)
-
-#define A_SGE_INT_ENABLE1 0x1028
-#define A_SGE_PERR_ENABLE1 0x102c
-#define A_SGE_INT_CAUSE2 0x1030
-
-#define S_PERR_HINT_DELAY_FIFO1 30
-#define V_PERR_HINT_DELAY_FIFO1(x) ((x) << S_PERR_HINT_DELAY_FIFO1)
-#define F_PERR_HINT_DELAY_FIFO1 V_PERR_HINT_DELAY_FIFO1(1U)
-
-#define S_PERR_HINT_DELAY_FIFO0 29
-#define V_PERR_HINT_DELAY_FIFO0(x) ((x) << S_PERR_HINT_DELAY_FIFO0)
-#define F_PERR_HINT_DELAY_FIFO0 V_PERR_HINT_DELAY_FIFO0(1U)
-
-#define S_PERR_IMSG_PD_FIFO 28
-#define V_PERR_IMSG_PD_FIFO(x) ((x) << S_PERR_IMSG_PD_FIFO)
-#define F_PERR_IMSG_PD_FIFO V_PERR_IMSG_PD_FIFO(1U)
-
-#define S_PERR_ULPTX_FIFO1 27
-#define V_PERR_ULPTX_FIFO1(x) ((x) << S_PERR_ULPTX_FIFO1)
-#define F_PERR_ULPTX_FIFO1 V_PERR_ULPTX_FIFO1(1U)
-
-#define S_PERR_ULPTX_FIFO0 26
-#define V_PERR_ULPTX_FIFO0(x) ((x) << S_PERR_ULPTX_FIFO0)
-#define F_PERR_ULPTX_FIFO0 V_PERR_ULPTX_FIFO0(1U)
-
-#define S_PERR_IDMA2IMSG_FIFO1 25
-#define V_PERR_IDMA2IMSG_FIFO1(x) ((x) << S_PERR_IDMA2IMSG_FIFO1)
-#define F_PERR_IDMA2IMSG_FIFO1 V_PERR_IDMA2IMSG_FIFO1(1U)
-
-#define S_PERR_IDMA2IMSG_FIFO0 24
-#define V_PERR_IDMA2IMSG_FIFO0(x) ((x) << S_PERR_IDMA2IMSG_FIFO0)
-#define F_PERR_IDMA2IMSG_FIFO0 V_PERR_IDMA2IMSG_FIFO0(1U)
-
-#define S_PERR_HEADERSPLIT_FIFO1 23
-#define V_PERR_HEADERSPLIT_FIFO1(x) ((x) << S_PERR_HEADERSPLIT_FIFO1)
-#define F_PERR_HEADERSPLIT_FIFO1 V_PERR_HEADERSPLIT_FIFO1(1U)
-
-#define S_PERR_HEADERSPLIT_FIFO0 22
-#define V_PERR_HEADERSPLIT_FIFO0(x) ((x) << S_PERR_HEADERSPLIT_FIFO0)
-#define F_PERR_HEADERSPLIT_FIFO0 V_PERR_HEADERSPLIT_FIFO0(1U)
-
-#define S_PERR_ESWITCH_FIFO3 21
-#define V_PERR_ESWITCH_FIFO3(x) ((x) << S_PERR_ESWITCH_FIFO3)
-#define F_PERR_ESWITCH_FIFO3 V_PERR_ESWITCH_FIFO3(1U)
-
-#define S_PERR_ESWITCH_FIFO2 20
-#define V_PERR_ESWITCH_FIFO2(x) ((x) << S_PERR_ESWITCH_FIFO2)
-#define F_PERR_ESWITCH_FIFO2 V_PERR_ESWITCH_FIFO2(1U)
-
-#define S_PERR_ESWITCH_FIFO1 19
-#define V_PERR_ESWITCH_FIFO1(x) ((x) << S_PERR_ESWITCH_FIFO1)
-#define F_PERR_ESWITCH_FIFO1 V_PERR_ESWITCH_FIFO1(1U)
-
-#define S_PERR_ESWITCH_FIFO0 18
-#define V_PERR_ESWITCH_FIFO0(x) ((x) << S_PERR_ESWITCH_FIFO0)
-#define F_PERR_ESWITCH_FIFO0 V_PERR_ESWITCH_FIFO0(1U)
-
-#define S_PERR_PC_DBP1 17
-#define V_PERR_PC_DBP1(x) ((x) << S_PERR_PC_DBP1)
-#define F_PERR_PC_DBP1 V_PERR_PC_DBP1(1U)
-
-#define S_PERR_PC_DBP0 16
-#define V_PERR_PC_DBP0(x) ((x) << S_PERR_PC_DBP0)
-#define F_PERR_PC_DBP0 V_PERR_PC_DBP0(1U)
-
-#define S_PERR_IMSG_OB_FIFO 15
-#define V_PERR_IMSG_OB_FIFO(x) ((x) << S_PERR_IMSG_OB_FIFO)
-#define F_PERR_IMSG_OB_FIFO V_PERR_IMSG_OB_FIFO(1U)
-
-#define S_PERR_CONM_SRAM 14
-#define V_PERR_CONM_SRAM(x) ((x) << S_PERR_CONM_SRAM)
-#define F_PERR_CONM_SRAM V_PERR_CONM_SRAM(1U)
-
-#define S_PERR_PC_MC_RSP 13
-#define V_PERR_PC_MC_RSP(x) ((x) << S_PERR_PC_MC_RSP)
-#define F_PERR_PC_MC_RSP V_PERR_PC_MC_RSP(1U)
-
-#define S_PERR_ISW_IDMA0_FIFO 12
-#define V_PERR_ISW_IDMA0_FIFO(x) ((x) << S_PERR_ISW_IDMA0_FIFO)
-#define F_PERR_ISW_IDMA0_FIFO V_PERR_ISW_IDMA0_FIFO(1U)
-
-#define S_PERR_ISW_IDMA1_FIFO 11
-#define V_PERR_ISW_IDMA1_FIFO(x) ((x) << S_PERR_ISW_IDMA1_FIFO)
-#define F_PERR_ISW_IDMA1_FIFO V_PERR_ISW_IDMA1_FIFO(1U)
-
-#define S_PERR_ISW_DBP_FIFO 10
-#define V_PERR_ISW_DBP_FIFO(x) ((x) << S_PERR_ISW_DBP_FIFO)
-#define F_PERR_ISW_DBP_FIFO V_PERR_ISW_DBP_FIFO(1U)
-
-#define S_PERR_ISW_GTS_FIFO 9
-#define V_PERR_ISW_GTS_FIFO(x) ((x) << S_PERR_ISW_GTS_FIFO)
-#define F_PERR_ISW_GTS_FIFO V_PERR_ISW_GTS_FIFO(1U)
-
-#define S_PERR_ITP_EVR 8
-#define V_PERR_ITP_EVR(x) ((x) << S_PERR_ITP_EVR)
-#define F_PERR_ITP_EVR V_PERR_ITP_EVR(1U)
-
-#define S_PERR_FLM_CNTXMEM 7
-#define V_PERR_FLM_CNTXMEM(x) ((x) << S_PERR_FLM_CNTXMEM)
-#define F_PERR_FLM_CNTXMEM V_PERR_FLM_CNTXMEM(1U)
-
-#define S_PERR_FLM_L1CACHE 6
-#define V_PERR_FLM_L1CACHE(x) ((x) << S_PERR_FLM_L1CACHE)
-#define F_PERR_FLM_L1CACHE V_PERR_FLM_L1CACHE(1U)
-
-#define S_PERR_DBP_HINT_FIFO 5
-#define V_PERR_DBP_HINT_FIFO(x) ((x) << S_PERR_DBP_HINT_FIFO)
-#define F_PERR_DBP_HINT_FIFO V_PERR_DBP_HINT_FIFO(1U)
-
-#define S_PERR_DBP_HP_FIFO 4
-#define V_PERR_DBP_HP_FIFO(x) ((x) << S_PERR_DBP_HP_FIFO)
-#define F_PERR_DBP_HP_FIFO V_PERR_DBP_HP_FIFO(1U)
-
-#define S_PERR_DBP_LP_FIFO 3
-#define V_PERR_DBP_LP_FIFO(x) ((x) << S_PERR_DBP_LP_FIFO)
-#define F_PERR_DBP_LP_FIFO V_PERR_DBP_LP_FIFO(1U)
-
-#define S_PERR_ING_CTXT_CACHE 2
-#define V_PERR_ING_CTXT_CACHE(x) ((x) << S_PERR_ING_CTXT_CACHE)
-#define F_PERR_ING_CTXT_CACHE V_PERR_ING_CTXT_CACHE(1U)
-
-#define S_PERR_EGR_CTXT_CACHE 1
-#define V_PERR_EGR_CTXT_CACHE(x) ((x) << S_PERR_EGR_CTXT_CACHE)
-#define F_PERR_EGR_CTXT_CACHE V_PERR_EGR_CTXT_CACHE(1U)
-
-#define S_PERR_BASE_SIZE 0
-#define V_PERR_BASE_SIZE(x) ((x) << S_PERR_BASE_SIZE)
-#define F_PERR_BASE_SIZE V_PERR_BASE_SIZE(1U)
-
-#define S_PERR_DBP_HINT_FL_FIFO 24
-#define V_PERR_DBP_HINT_FL_FIFO(x) ((x) << S_PERR_DBP_HINT_FL_FIFO)
-#define F_PERR_DBP_HINT_FL_FIFO V_PERR_DBP_HINT_FL_FIFO(1U)
-
-#define S_PERR_EGR_DBP_TX_COAL 23
-#define V_PERR_EGR_DBP_TX_COAL(x) ((x) << S_PERR_EGR_DBP_TX_COAL)
-#define F_PERR_EGR_DBP_TX_COAL V_PERR_EGR_DBP_TX_COAL(1U)
-
-#define S_PERR_DBP_FL_FIFO 22
-#define V_PERR_DBP_FL_FIFO(x) ((x) << S_PERR_DBP_FL_FIFO)
-#define F_PERR_DBP_FL_FIFO V_PERR_DBP_FL_FIFO(1U)
-
-#define S_PERR_PC_DBP2 15
-#define V_PERR_PC_DBP2(x) ((x) << S_PERR_PC_DBP2)
-#define F_PERR_PC_DBP2 V_PERR_PC_DBP2(1U)
-
-#define S_DEQ_LL_PERR 21
-#define V_DEQ_LL_PERR(x) ((x) << S_DEQ_LL_PERR)
-#define F_DEQ_LL_PERR V_DEQ_LL_PERR(1U)
-
-#define S_ENQ_PERR 20
-#define V_ENQ_PERR(x) ((x) << S_ENQ_PERR)
-#define F_ENQ_PERR V_ENQ_PERR(1U)
-
-#define S_DEQ_OUT_PERR 19
-#define V_DEQ_OUT_PERR(x) ((x) << S_DEQ_OUT_PERR)
-#define F_DEQ_OUT_PERR V_DEQ_OUT_PERR(1U)
-
-#define S_BUF_PERR 18
-#define V_BUF_PERR(x) ((x) << S_BUF_PERR)
-#define F_BUF_PERR V_BUF_PERR(1U)
-
-#define S_PERR_DB_FIFO 3
-#define V_PERR_DB_FIFO(x) ((x) << S_PERR_DB_FIFO)
-#define F_PERR_DB_FIFO V_PERR_DB_FIFO(1U)
-
-#define A_SGE_INT_ENABLE2 0x1034
-#define A_SGE_PERR_ENABLE2 0x1038
-#define A_SGE_INT_CAUSE3 0x103c
-
-#define S_ERR_FLM_DBP 31
-#define V_ERR_FLM_DBP(x) ((x) << S_ERR_FLM_DBP)
-#define F_ERR_FLM_DBP V_ERR_FLM_DBP(1U)
-
-#define S_ERR_FLM_IDMA1 30
-#define V_ERR_FLM_IDMA1(x) ((x) << S_ERR_FLM_IDMA1)
-#define F_ERR_FLM_IDMA1 V_ERR_FLM_IDMA1(1U)
-
-#define S_ERR_FLM_IDMA0 29
-#define V_ERR_FLM_IDMA0(x) ((x) << S_ERR_FLM_IDMA0)
-#define F_ERR_FLM_IDMA0 V_ERR_FLM_IDMA0(1U)
-
-#define S_ERR_FLM_HINT 28
-#define V_ERR_FLM_HINT(x) ((x) << S_ERR_FLM_HINT)
-#define F_ERR_FLM_HINT V_ERR_FLM_HINT(1U)
-
-#define S_ERR_PCIE_ERROR3 27
-#define V_ERR_PCIE_ERROR3(x) ((x) << S_ERR_PCIE_ERROR3)
-#define F_ERR_PCIE_ERROR3 V_ERR_PCIE_ERROR3(1U)
-
-#define S_ERR_PCIE_ERROR2 26
-#define V_ERR_PCIE_ERROR2(x) ((x) << S_ERR_PCIE_ERROR2)
-#define F_ERR_PCIE_ERROR2 V_ERR_PCIE_ERROR2(1U)
-
-#define S_ERR_PCIE_ERROR1 25
-#define V_ERR_PCIE_ERROR1(x) ((x) << S_ERR_PCIE_ERROR1)
-#define F_ERR_PCIE_ERROR1 V_ERR_PCIE_ERROR1(1U)
-
-#define S_ERR_PCIE_ERROR0 24
-#define V_ERR_PCIE_ERROR0(x) ((x) << S_ERR_PCIE_ERROR0)
-#define F_ERR_PCIE_ERROR0 V_ERR_PCIE_ERROR0(1U)
-
-#define S_ERR_TIMER_ABOVE_MAX_QID 23
-#define V_ERR_TIMER_ABOVE_MAX_QID(x) ((x) << S_ERR_TIMER_ABOVE_MAX_QID)
-#define F_ERR_TIMER_ABOVE_MAX_QID V_ERR_TIMER_ABOVE_MAX_QID(1U)
-
-#define S_ERR_CPL_EXCEED_IQE_SIZE 22
-#define V_ERR_CPL_EXCEED_IQE_SIZE(x) ((x) << S_ERR_CPL_EXCEED_IQE_SIZE)
-#define F_ERR_CPL_EXCEED_IQE_SIZE V_ERR_CPL_EXCEED_IQE_SIZE(1U)
-
-#define S_ERR_INVALID_CIDX_INC 21
-#define V_ERR_INVALID_CIDX_INC(x) ((x) << S_ERR_INVALID_CIDX_INC)
-#define F_ERR_INVALID_CIDX_INC V_ERR_INVALID_CIDX_INC(1U)
-
-#define S_ERR_ITP_TIME_PAUSED 20
-#define V_ERR_ITP_TIME_PAUSED(x) ((x) << S_ERR_ITP_TIME_PAUSED)
-#define F_ERR_ITP_TIME_PAUSED V_ERR_ITP_TIME_PAUSED(1U)
-
-#define S_ERR_CPL_OPCODE_0 19
-#define V_ERR_CPL_OPCODE_0(x) ((x) << S_ERR_CPL_OPCODE_0)
-#define F_ERR_CPL_OPCODE_0 V_ERR_CPL_OPCODE_0(1U)
-
-#define S_ERR_DROPPED_DB 18
-#define V_ERR_DROPPED_DB(x) ((x) << S_ERR_DROPPED_DB)
-#define F_ERR_DROPPED_DB V_ERR_DROPPED_DB(1U)
-
-#define S_ERR_DATA_CPL_ON_HIGH_QID1 17
-#define V_ERR_DATA_CPL_ON_HIGH_QID1(x) ((x) << S_ERR_DATA_CPL_ON_HIGH_QID1)
-#define F_ERR_DATA_CPL_ON_HIGH_QID1 V_ERR_DATA_CPL_ON_HIGH_QID1(1U)
-
-#define S_ERR_DATA_CPL_ON_HIGH_QID0 16
-#define V_ERR_DATA_CPL_ON_HIGH_QID0(x) ((x) << S_ERR_DATA_CPL_ON_HIGH_QID0)
-#define F_ERR_DATA_CPL_ON_HIGH_QID0 V_ERR_DATA_CPL_ON_HIGH_QID0(1U)
-
-#define S_ERR_BAD_DB_PIDX3 15
-#define V_ERR_BAD_DB_PIDX3(x) ((x) << S_ERR_BAD_DB_PIDX3)
-#define F_ERR_BAD_DB_PIDX3 V_ERR_BAD_DB_PIDX3(1U)
-
-#define S_ERR_BAD_DB_PIDX2 14
-#define V_ERR_BAD_DB_PIDX2(x) ((x) << S_ERR_BAD_DB_PIDX2)
-#define F_ERR_BAD_DB_PIDX2 V_ERR_BAD_DB_PIDX2(1U)
-
-#define S_ERR_BAD_DB_PIDX1 13
-#define V_ERR_BAD_DB_PIDX1(x) ((x) << S_ERR_BAD_DB_PIDX1)
-#define F_ERR_BAD_DB_PIDX1 V_ERR_BAD_DB_PIDX1(1U)
-
-#define S_ERR_BAD_DB_PIDX0 12
-#define V_ERR_BAD_DB_PIDX0(x) ((x) << S_ERR_BAD_DB_PIDX0)
-#define F_ERR_BAD_DB_PIDX0 V_ERR_BAD_DB_PIDX0(1U)
-
-#define S_ERR_ING_PCIE_CHAN 11
-#define V_ERR_ING_PCIE_CHAN(x) ((x) << S_ERR_ING_PCIE_CHAN)
-#define F_ERR_ING_PCIE_CHAN V_ERR_ING_PCIE_CHAN(1U)
-
-#define S_ERR_ING_CTXT_PRIO 10
-#define V_ERR_ING_CTXT_PRIO(x) ((x) << S_ERR_ING_CTXT_PRIO)
-#define F_ERR_ING_CTXT_PRIO V_ERR_ING_CTXT_PRIO(1U)
-
-#define S_ERR_EGR_CTXT_PRIO 9
-#define V_ERR_EGR_CTXT_PRIO(x) ((x) << S_ERR_EGR_CTXT_PRIO)
-#define F_ERR_EGR_CTXT_PRIO V_ERR_EGR_CTXT_PRIO(1U)
-
-#define S_DBFIFO_HP_INT 8
-#define V_DBFIFO_HP_INT(x) ((x) << S_DBFIFO_HP_INT)
-#define F_DBFIFO_HP_INT V_DBFIFO_HP_INT(1U)
-
-#define S_DBFIFO_LP_INT 7
-#define V_DBFIFO_LP_INT(x) ((x) << S_DBFIFO_LP_INT)
-#define F_DBFIFO_LP_INT V_DBFIFO_LP_INT(1U)
-
-#define S_REG_ADDRESS_ERR 6
-#define V_REG_ADDRESS_ERR(x) ((x) << S_REG_ADDRESS_ERR)
-#define F_REG_ADDRESS_ERR V_REG_ADDRESS_ERR(1U)
-
-#define S_INGRESS_SIZE_ERR 5
-#define V_INGRESS_SIZE_ERR(x) ((x) << S_INGRESS_SIZE_ERR)
-#define F_INGRESS_SIZE_ERR V_INGRESS_SIZE_ERR(1U)
-
-#define S_EGRESS_SIZE_ERR 4
-#define V_EGRESS_SIZE_ERR(x) ((x) << S_EGRESS_SIZE_ERR)
-#define F_EGRESS_SIZE_ERR V_EGRESS_SIZE_ERR(1U)
-
-#define S_ERR_INV_CTXT3 3
-#define V_ERR_INV_CTXT3(x) ((x) << S_ERR_INV_CTXT3)
-#define F_ERR_INV_CTXT3 V_ERR_INV_CTXT3(1U)
-
-#define S_ERR_INV_CTXT2 2
-#define V_ERR_INV_CTXT2(x) ((x) << S_ERR_INV_CTXT2)
-#define F_ERR_INV_CTXT2 V_ERR_INV_CTXT2(1U)
-
-#define S_ERR_INV_CTXT1 1
-#define V_ERR_INV_CTXT1(x) ((x) << S_ERR_INV_CTXT1)
-#define F_ERR_INV_CTXT1 V_ERR_INV_CTXT1(1U)
-
-#define S_ERR_INV_CTXT0 0
-#define V_ERR_INV_CTXT0(x) ((x) << S_ERR_INV_CTXT0)
-#define F_ERR_INV_CTXT0 V_ERR_INV_CTXT0(1U)
-
-#define S_DBP_TBUF_FULL 8
-#define V_DBP_TBUF_FULL(x) ((x) << S_DBP_TBUF_FULL)
-#define F_DBP_TBUF_FULL V_DBP_TBUF_FULL(1U)
-
-#define S_FATAL_WRE_LEN 7
-#define V_FATAL_WRE_LEN(x) ((x) << S_FATAL_WRE_LEN)
-#define F_FATAL_WRE_LEN V_FATAL_WRE_LEN(1U)
-
-#define A_SGE_INT_ENABLE3 0x1040
-#define A_SGE_FL_BUFFER_SIZE0 0x1044
-
-#define S_SIZE 4
-#define M_SIZE 0xfffffffU
-#define V_SIZE(x) ((x) << S_SIZE)
-#define G_SIZE(x) (((x) >> S_SIZE) & M_SIZE)
-
-#define S_T6_SIZE 4
-#define M_T6_SIZE 0xfffffU
-#define V_T6_SIZE(x) ((x) << S_T6_SIZE)
-#define G_T6_SIZE(x) (((x) >> S_T6_SIZE) & M_T6_SIZE)
-
-#define A_SGE_FL_BUFFER_SIZE1 0x1048
-
-#define S_T6_SIZE 4
-#define M_T6_SIZE 0xfffffU
-#define V_T6_SIZE(x) ((x) << S_T6_SIZE)
-#define G_T6_SIZE(x) (((x) >> S_T6_SIZE) & M_T6_SIZE)
-
-#define A_SGE_FL_BUFFER_SIZE2 0x104c
-
-#define S_T6_SIZE 4
-#define M_T6_SIZE 0xfffffU
-#define V_T6_SIZE(x) ((x) << S_T6_SIZE)
-#define G_T6_SIZE(x) (((x) >> S_T6_SIZE) & M_T6_SIZE)
-
-#define A_SGE_FL_BUFFER_SIZE3 0x1050
-
-#define S_T6_SIZE 4
-#define M_T6_SIZE 0xfffffU
-#define V_T6_SIZE(x) ((x) << S_T6_SIZE)
-#define G_T6_SIZE(x) (((x) >> S_T6_SIZE) & M_T6_SIZE)
-
-#define A_SGE_FL_BUFFER_SIZE4 0x1054
-
-#define S_T6_SIZE 4
-#define M_T6_SIZE 0xfffffU
-#define V_T6_SIZE(x) ((x) << S_T6_SIZE)
-#define G_T6_SIZE(x) (((x) >> S_T6_SIZE) & M_T6_SIZE)
-
-#define A_SGE_FL_BUFFER_SIZE5 0x1058
-
-#define S_T6_SIZE 4
-#define M_T6_SIZE 0xfffffU
-#define V_T6_SIZE(x) ((x) << S_T6_SIZE)
-#define G_T6_SIZE(x) (((x) >> S_T6_SIZE) & M_T6_SIZE)
-
-#define A_SGE_FL_BUFFER_SIZE6 0x105c
-
-#define S_T6_SIZE 4
-#define M_T6_SIZE 0xfffffU
-#define V_T6_SIZE(x) ((x) << S_T6_SIZE)
-#define G_T6_SIZE(x) (((x) >> S_T6_SIZE) & M_T6_SIZE)
-
-#define A_SGE_FL_BUFFER_SIZE7 0x1060
-
-#define S_T6_SIZE 4
-#define M_T6_SIZE 0xfffffU
-#define V_T6_SIZE(x) ((x) << S_T6_SIZE)
-#define G_T6_SIZE(x) (((x) >> S_T6_SIZE) & M_T6_SIZE)
-
-#define A_SGE_FL_BUFFER_SIZE8 0x1064
-
-#define S_T6_SIZE 4
-#define M_T6_SIZE 0xfffffU
-#define V_T6_SIZE(x) ((x) << S_T6_SIZE)
-#define G_T6_SIZE(x) (((x) >> S_T6_SIZE) & M_T6_SIZE)
-
-#define A_SGE_FL_BUFFER_SIZE9 0x1068
-
-#define S_T6_SIZE 4
-#define M_T6_SIZE 0xfffffU
-#define V_T6_SIZE(x) ((x) << S_T6_SIZE)
-#define G_T6_SIZE(x) (((x) >> S_T6_SIZE) & M_T6_SIZE)
-
-#define A_SGE_FL_BUFFER_SIZE10 0x106c
-
-#define S_T6_SIZE 4
-#define M_T6_SIZE 0xfffffU
-#define V_T6_SIZE(x) ((x) << S_T6_SIZE)
-#define G_T6_SIZE(x) (((x) >> S_T6_SIZE) & M_T6_SIZE)
-
-#define A_SGE_FL_BUFFER_SIZE11 0x1070
-
-#define S_T6_SIZE 4
-#define M_T6_SIZE 0xfffffU
-#define V_T6_SIZE(x) ((x) << S_T6_SIZE)
-#define G_T6_SIZE(x) (((x) >> S_T6_SIZE) & M_T6_SIZE)
-
-#define A_SGE_FL_BUFFER_SIZE12 0x1074
-
-#define S_T6_SIZE 4
-#define M_T6_SIZE 0xfffffU
-#define V_T6_SIZE(x) ((x) << S_T6_SIZE)
-#define G_T6_SIZE(x) (((x) >> S_T6_SIZE) & M_T6_SIZE)
-
-#define A_SGE_FL_BUFFER_SIZE13 0x1078
-
-#define S_T6_SIZE 4
-#define M_T6_SIZE 0xfffffU
-#define V_T6_SIZE(x) ((x) << S_T6_SIZE)
-#define G_T6_SIZE(x) (((x) >> S_T6_SIZE) & M_T6_SIZE)
-
-#define A_SGE_FL_BUFFER_SIZE14 0x107c
-
-#define S_T6_SIZE 4
-#define M_T6_SIZE 0xfffffU
-#define V_T6_SIZE(x) ((x) << S_T6_SIZE)
-#define G_T6_SIZE(x) (((x) >> S_T6_SIZE) & M_T6_SIZE)
-
-#define A_SGE_FL_BUFFER_SIZE15 0x1080
-
-#define S_T6_SIZE 4
-#define M_T6_SIZE 0xfffffU
-#define V_T6_SIZE(x) ((x) << S_T6_SIZE)
-#define G_T6_SIZE(x) (((x) >> S_T6_SIZE) & M_T6_SIZE)
-
-#define A_SGE_DBQ_CTXT_BADDR 0x1084
-
-#define S_BASEADDR 3
-#define M_BASEADDR 0x1fffffffU
-#define V_BASEADDR(x) ((x) << S_BASEADDR)
-#define G_BASEADDR(x) (((x) >> S_BASEADDR) & M_BASEADDR)
-
-#define A_SGE_IMSG_CTXT_BADDR 0x1088
-#define A_SGE_FLM_CACHE_BADDR 0x108c
-#define A_SGE_FLM_CFG 0x1090
-
-#define S_OPMODE 26
-#define M_OPMODE 0x3fU
-#define V_OPMODE(x) ((x) << S_OPMODE)
-#define G_OPMODE(x) (((x) >> S_OPMODE) & M_OPMODE)
-
-#define S_NOHDR 18
-#define V_NOHDR(x) ((x) << S_NOHDR)
-#define F_NOHDR V_NOHDR(1U)
-
-#define S_CACHEPTRCNT 16
-#define M_CACHEPTRCNT 0x3U
-#define V_CACHEPTRCNT(x) ((x) << S_CACHEPTRCNT)
-#define G_CACHEPTRCNT(x) (((x) >> S_CACHEPTRCNT) & M_CACHEPTRCNT)
-
-#define S_EDRAMPTRCNT 14
-#define M_EDRAMPTRCNT 0x3U
-#define V_EDRAMPTRCNT(x) ((x) << S_EDRAMPTRCNT)
-#define G_EDRAMPTRCNT(x) (((x) >> S_EDRAMPTRCNT) & M_EDRAMPTRCNT)
-
-#define S_HDRSTARTFLQ 11
-#define M_HDRSTARTFLQ 0x7U
-#define V_HDRSTARTFLQ(x) ((x) << S_HDRSTARTFLQ)
-#define G_HDRSTARTFLQ(x) (((x) >> S_HDRSTARTFLQ) & M_HDRSTARTFLQ)
-
-#define S_FETCHTHRESH 6
-#define M_FETCHTHRESH 0x1fU
-#define V_FETCHTHRESH(x) ((x) << S_FETCHTHRESH)
-#define G_FETCHTHRESH(x) (((x) >> S_FETCHTHRESH) & M_FETCHTHRESH)
-
-#define S_CREDITCNT 4
-#define M_CREDITCNT 0x3U
-#define V_CREDITCNT(x) ((x) << S_CREDITCNT)
-#define G_CREDITCNT(x) (((x) >> S_CREDITCNT) & M_CREDITCNT)
-
-#define S_NOEDRAM 0
-#define V_NOEDRAM(x) ((x) << S_NOEDRAM)
-#define F_NOEDRAM V_NOEDRAM(1U)
-
-#define S_CREDITCNTPACKING 2
-#define M_CREDITCNTPACKING 0x3U
-#define V_CREDITCNTPACKING(x) ((x) << S_CREDITCNTPACKING)
-#define G_CREDITCNTPACKING(x) (((x) >> S_CREDITCNTPACKING) & M_CREDITCNTPACKING)
-
-#define S_NULLPTR 20
-#define M_NULLPTR 0xfU
-#define V_NULLPTR(x) ((x) << S_NULLPTR)
-#define G_NULLPTR(x) (((x) >> S_NULLPTR) & M_NULLPTR)
-
-#define S_NULLPTREN 19
-#define V_NULLPTREN(x) ((x) << S_NULLPTREN)
-#define F_NULLPTREN V_NULLPTREN(1U)
-
-#define A_SGE_CONM_CTRL 0x1094
-
-#define S_EGRTHRESHOLD 8
-#define M_EGRTHRESHOLD 0x3fU
-#define V_EGRTHRESHOLD(x) ((x) << S_EGRTHRESHOLD)
-#define G_EGRTHRESHOLD(x) (((x) >> S_EGRTHRESHOLD) & M_EGRTHRESHOLD)
-
-#define S_INGTHRESHOLD 2
-#define M_INGTHRESHOLD 0x3fU
-#define V_INGTHRESHOLD(x) ((x) << S_INGTHRESHOLD)
-#define G_INGTHRESHOLD(x) (((x) >> S_INGTHRESHOLD) & M_INGTHRESHOLD)
-
-#define S_MPS_ENABLE 1
-#define V_MPS_ENABLE(x) ((x) << S_MPS_ENABLE)
-#define F_MPS_ENABLE V_MPS_ENABLE(1U)
-
-#define S_TP_ENABLE 0
-#define V_TP_ENABLE(x) ((x) << S_TP_ENABLE)
-#define F_TP_ENABLE V_TP_ENABLE(1U)
-
-#define S_EGRTHRESHOLDPACKING 14
-#define M_EGRTHRESHOLDPACKING 0x3fU
-#define V_EGRTHRESHOLDPACKING(x) ((x) << S_EGRTHRESHOLDPACKING)
-#define G_EGRTHRESHOLDPACKING(x) (((x) >> S_EGRTHRESHOLDPACKING) & M_EGRTHRESHOLDPACKING)
-
-#define S_T6_EGRTHRESHOLDPACKING 16
-#define M_T6_EGRTHRESHOLDPACKING 0xffU
-#define V_T6_EGRTHRESHOLDPACKING(x) ((x) << S_T6_EGRTHRESHOLDPACKING)
-#define G_T6_EGRTHRESHOLDPACKING(x) (((x) >> S_T6_EGRTHRESHOLDPACKING) & M_T6_EGRTHRESHOLDPACKING)
-
-#define S_T6_EGRTHRESHOLD 8
-#define M_T6_EGRTHRESHOLD 0xffU
-#define V_T6_EGRTHRESHOLD(x) ((x) << S_T6_EGRTHRESHOLD)
-#define G_T6_EGRTHRESHOLD(x) (((x) >> S_T6_EGRTHRESHOLD) & M_T6_EGRTHRESHOLD)
-
-#define A_SGE_TIMESTAMP_LO 0x1098
-#define A_SGE_TIMESTAMP_HI 0x109c
-
-#define S_TSOP 28
-#define M_TSOP 0x3U
-#define V_TSOP(x) ((x) << S_TSOP)
-#define G_TSOP(x) (((x) >> S_TSOP) & M_TSOP)
-
-#define S_TSVAL 0
-#define M_TSVAL 0xfffffffU
-#define V_TSVAL(x) ((x) << S_TSVAL)
-#define G_TSVAL(x) (((x) >> S_TSVAL) & M_TSVAL)
-
-#define A_SGE_INGRESS_RX_THRESHOLD 0x10a0
-
-#define S_THRESHOLD_0 24
-#define M_THRESHOLD_0 0x3fU
-#define V_THRESHOLD_0(x) ((x) << S_THRESHOLD_0)
-#define G_THRESHOLD_0(x) (((x) >> S_THRESHOLD_0) & M_THRESHOLD_0)
-
-#define S_THRESHOLD_1 16
-#define M_THRESHOLD_1 0x3fU
-#define V_THRESHOLD_1(x) ((x) << S_THRESHOLD_1)
-#define G_THRESHOLD_1(x) (((x) >> S_THRESHOLD_1) & M_THRESHOLD_1)
-
-#define S_THRESHOLD_2 8
-#define M_THRESHOLD_2 0x3fU
-#define V_THRESHOLD_2(x) ((x) << S_THRESHOLD_2)
-#define G_THRESHOLD_2(x) (((x) >> S_THRESHOLD_2) & M_THRESHOLD_2)
-
-#define S_THRESHOLD_3 0
-#define M_THRESHOLD_3 0x3fU
-#define V_THRESHOLD_3(x) ((x) << S_THRESHOLD_3)
-#define G_THRESHOLD_3(x) (((x) >> S_THRESHOLD_3) & M_THRESHOLD_3)
-
-#define A_SGE_DBFIFO_STATUS 0x10a4
-
-#define S_HP_INT_THRESH 28
-#define M_HP_INT_THRESH 0xfU
-#define V_HP_INT_THRESH(x) ((x) << S_HP_INT_THRESH)
-#define G_HP_INT_THRESH(x) (((x) >> S_HP_INT_THRESH) & M_HP_INT_THRESH)
-
-#define S_HP_COUNT 16
-#define M_HP_COUNT 0x7ffU
-#define V_HP_COUNT(x) ((x) << S_HP_COUNT)
-#define G_HP_COUNT(x) (((x) >> S_HP_COUNT) & M_HP_COUNT)
-
-#define S_LP_INT_THRESH 12
-#define M_LP_INT_THRESH 0xfU
-#define V_LP_INT_THRESH(x) ((x) << S_LP_INT_THRESH)
-#define G_LP_INT_THRESH(x) (((x) >> S_LP_INT_THRESH) & M_LP_INT_THRESH)
-
-#define S_LP_COUNT 0
-#define M_LP_COUNT 0x7ffU
-#define V_LP_COUNT(x) ((x) << S_LP_COUNT)
-#define G_LP_COUNT(x) (((x) >> S_LP_COUNT) & M_LP_COUNT)
-
-#define S_BAR2VALID 31
-#define V_BAR2VALID(x) ((x) << S_BAR2VALID)
-#define F_BAR2VALID V_BAR2VALID(1U)
-
-#define S_BAR2FULL 30
-#define V_BAR2FULL(x) ((x) << S_BAR2FULL)
-#define F_BAR2FULL V_BAR2FULL(1U)
-
-#define S_LP_INT_THRESH_T5 18
-#define M_LP_INT_THRESH_T5 0xfffU
-#define V_LP_INT_THRESH_T5(x) ((x) << S_LP_INT_THRESH_T5)
-#define G_LP_INT_THRESH_T5(x) (((x) >> S_LP_INT_THRESH_T5) & M_LP_INT_THRESH_T5)
-
-#define S_LP_COUNT_T5 0
-#define M_LP_COUNT_T5 0x3ffffU
-#define V_LP_COUNT_T5(x) ((x) << S_LP_COUNT_T5)
-#define G_LP_COUNT_T5(x) (((x) >> S_LP_COUNT_T5) & M_LP_COUNT_T5)
-
-#define S_VFIFO_CNT 15
-#define M_VFIFO_CNT 0x1ffffU
-#define V_VFIFO_CNT(x) ((x) << S_VFIFO_CNT)
-#define G_VFIFO_CNT(x) (((x) >> S_VFIFO_CNT) & M_VFIFO_CNT)
-
-#define S_COAL_CTL_FIFO_CNT 8
-#define M_COAL_CTL_FIFO_CNT 0x3fU
-#define V_COAL_CTL_FIFO_CNT(x) ((x) << S_COAL_CTL_FIFO_CNT)
-#define G_COAL_CTL_FIFO_CNT(x) (((x) >> S_COAL_CTL_FIFO_CNT) & M_COAL_CTL_FIFO_CNT)
-
-#define S_MERGE_FIFO_CNT 0
-#define M_MERGE_FIFO_CNT 0x3fU
-#define V_MERGE_FIFO_CNT(x) ((x) << S_MERGE_FIFO_CNT)
-#define G_MERGE_FIFO_CNT(x) (((x) >> S_MERGE_FIFO_CNT) & M_MERGE_FIFO_CNT)
-
-#define A_SGE_DOORBELL_CONTROL 0x10a8
-
-#define S_HINTDEPTHCTL 27
-#define M_HINTDEPTHCTL 0x1fU
-#define V_HINTDEPTHCTL(x) ((x) << S_HINTDEPTHCTL)
-#define G_HINTDEPTHCTL(x) (((x) >> S_HINTDEPTHCTL) & M_HINTDEPTHCTL)
-
-#define S_NOCOALESCE 26
-#define V_NOCOALESCE(x) ((x) << S_NOCOALESCE)
-#define F_NOCOALESCE V_NOCOALESCE(1U)
-
-#define S_HP_WEIGHT 24
-#define M_HP_WEIGHT 0x3U
-#define V_HP_WEIGHT(x) ((x) << S_HP_WEIGHT)
-#define G_HP_WEIGHT(x) (((x) >> S_HP_WEIGHT) & M_HP_WEIGHT)
-
-#define S_HP_DISABLE 23
-#define V_HP_DISABLE(x) ((x) << S_HP_DISABLE)
-#define F_HP_DISABLE V_HP_DISABLE(1U)
-
-#define S_FORCEUSERDBTOLP 22
-#define V_FORCEUSERDBTOLP(x) ((x) << S_FORCEUSERDBTOLP)
-#define F_FORCEUSERDBTOLP V_FORCEUSERDBTOLP(1U)
-
-#define S_FORCEVFPF0DBTOLP 21
-#define V_FORCEVFPF0DBTOLP(x) ((x) << S_FORCEVFPF0DBTOLP)
-#define F_FORCEVFPF0DBTOLP V_FORCEVFPF0DBTOLP(1U)
-
-#define S_FORCEVFPF1DBTOLP 20
-#define V_FORCEVFPF1DBTOLP(x) ((x) << S_FORCEVFPF1DBTOLP)
-#define F_FORCEVFPF1DBTOLP V_FORCEVFPF1DBTOLP(1U)
-
-#define S_FORCEVFPF2DBTOLP 19
-#define V_FORCEVFPF2DBTOLP(x) ((x) << S_FORCEVFPF2DBTOLP)
-#define F_FORCEVFPF2DBTOLP V_FORCEVFPF2DBTOLP(1U)
-
-#define S_FORCEVFPF3DBTOLP 18
-#define V_FORCEVFPF3DBTOLP(x) ((x) << S_FORCEVFPF3DBTOLP)
-#define F_FORCEVFPF3DBTOLP V_FORCEVFPF3DBTOLP(1U)
-
-#define S_FORCEVFPF4DBTOLP 17
-#define V_FORCEVFPF4DBTOLP(x) ((x) << S_FORCEVFPF4DBTOLP)
-#define F_FORCEVFPF4DBTOLP V_FORCEVFPF4DBTOLP(1U)
-
-#define S_FORCEVFPF5DBTOLP 16
-#define V_FORCEVFPF5DBTOLP(x) ((x) << S_FORCEVFPF5DBTOLP)
-#define F_FORCEVFPF5DBTOLP V_FORCEVFPF5DBTOLP(1U)
-
-#define S_FORCEVFPF6DBTOLP 15
-#define V_FORCEVFPF6DBTOLP(x) ((x) << S_FORCEVFPF6DBTOLP)
-#define F_FORCEVFPF6DBTOLP V_FORCEVFPF6DBTOLP(1U)
-
-#define S_FORCEVFPF7DBTOLP 14
-#define V_FORCEVFPF7DBTOLP(x) ((x) << S_FORCEVFPF7DBTOLP)
-#define F_FORCEVFPF7DBTOLP V_FORCEVFPF7DBTOLP(1U)
-
-#define S_ENABLE_DROP 13
-#define V_ENABLE_DROP(x) ((x) << S_ENABLE_DROP)
-#define F_ENABLE_DROP V_ENABLE_DROP(1U)
-
-#define S_DROP_TIMEOUT 1
-#define M_DROP_TIMEOUT 0xfffU
-#define V_DROP_TIMEOUT(x) ((x) << S_DROP_TIMEOUT)
-#define G_DROP_TIMEOUT(x) (((x) >> S_DROP_TIMEOUT) & M_DROP_TIMEOUT)
-
-#define S_DROPPED_DB 0
-#define V_DROPPED_DB(x) ((x) << S_DROPPED_DB)
-#define F_DROPPED_DB V_DROPPED_DB(1U)
-
-#define S_T6_DROP_TIMEOUT 7
-#define M_T6_DROP_TIMEOUT 0x3fU
-#define V_T6_DROP_TIMEOUT(x) ((x) << S_T6_DROP_TIMEOUT)
-#define G_T6_DROP_TIMEOUT(x) (((x) >> S_T6_DROP_TIMEOUT) & M_T6_DROP_TIMEOUT)
-
-#define S_INVONDBSYNC 6
-#define V_INVONDBSYNC(x) ((x) << S_INVONDBSYNC)
-#define F_INVONDBSYNC V_INVONDBSYNC(1U)
-
-#define S_INVONGTSSYNC 5
-#define V_INVONGTSSYNC(x) ((x) << S_INVONGTSSYNC)
-#define F_INVONGTSSYNC V_INVONGTSSYNC(1U)
-
-#define S_DB_DBG_EN 4
-#define V_DB_DBG_EN(x) ((x) << S_DB_DBG_EN)
-#define F_DB_DBG_EN V_DB_DBG_EN(1U)
-
-#define S_GTS_DBG_TIMER_REG 1
-#define M_GTS_DBG_TIMER_REG 0x7U
-#define V_GTS_DBG_TIMER_REG(x) ((x) << S_GTS_DBG_TIMER_REG)
-#define G_GTS_DBG_TIMER_REG(x) (((x) >> S_GTS_DBG_TIMER_REG) & M_GTS_DBG_TIMER_REG)
-
-#define S_GTS_DBG_EN 0
-#define V_GTS_DBG_EN(x) ((x) << S_GTS_DBG_EN)
-#define F_GTS_DBG_EN V_GTS_DBG_EN(1U)
-
-#define A_SGE_DROPPED_DOORBELL 0x10ac
-#define A_SGE_DOORBELL_THROTTLE_CONTROL 0x10b0
-
-#define S_THROTTLE_COUNT 1
-#define M_THROTTLE_COUNT 0xfffU
-#define V_THROTTLE_COUNT(x) ((x) << S_THROTTLE_COUNT)
-#define G_THROTTLE_COUNT(x) (((x) >> S_THROTTLE_COUNT) & M_THROTTLE_COUNT)
-
-#define S_THROTTLE_ENABLE 0
-#define V_THROTTLE_ENABLE(x) ((x) << S_THROTTLE_ENABLE)
-#define F_THROTTLE_ENABLE V_THROTTLE_ENABLE(1U)
-
-#define S_BAR2THROTTLECOUNT 16
-#define M_BAR2THROTTLECOUNT 0xffU
-#define V_BAR2THROTTLECOUNT(x) ((x) << S_BAR2THROTTLECOUNT)
-#define G_BAR2THROTTLECOUNT(x) (((x) >> S_BAR2THROTTLECOUNT) & M_BAR2THROTTLECOUNT)
-
-#define S_CLRCOALESCEDISABLE 15
-#define V_CLRCOALESCEDISABLE(x) ((x) << S_CLRCOALESCEDISABLE)
-#define F_CLRCOALESCEDISABLE V_CLRCOALESCEDISABLE(1U)
-
-#define S_OPENBAR2GATEONCE 14
-#define V_OPENBAR2GATEONCE(x) ((x) << S_OPENBAR2GATEONCE)
-#define F_OPENBAR2GATEONCE V_OPENBAR2GATEONCE(1U)
-
-#define S_FORCEOPENBAR2GATE 13
-#define V_FORCEOPENBAR2GATE(x) ((x) << S_FORCEOPENBAR2GATE)
-#define F_FORCEOPENBAR2GATE V_FORCEOPENBAR2GATE(1U)
-
-#define A_SGE_ITP_CONTROL 0x10b4
-
-#define S_CRITICAL_TIME 10
-#define M_CRITICAL_TIME 0x7fffU
-#define V_CRITICAL_TIME(x) ((x) << S_CRITICAL_TIME)
-#define G_CRITICAL_TIME(x) (((x) >> S_CRITICAL_TIME) & M_CRITICAL_TIME)
-
-#define S_LL_EMPTY 4
-#define M_LL_EMPTY 0x3fU
-#define V_LL_EMPTY(x) ((x) << S_LL_EMPTY)
-#define G_LL_EMPTY(x) (((x) >> S_LL_EMPTY) & M_LL_EMPTY)
-
-#define S_LL_READ_WAIT_DISABLE 0
-#define V_LL_READ_WAIT_DISABLE(x) ((x) << S_LL_READ_WAIT_DISABLE)
-#define F_LL_READ_WAIT_DISABLE V_LL_READ_WAIT_DISABLE(1U)
-
-#define S_TSCALE 28
-#define M_TSCALE 0xfU
-#define V_TSCALE(x) ((x) << S_TSCALE)
-#define G_TSCALE(x) (((x) >> S_TSCALE) & M_TSCALE)
-
-#define A_SGE_TIMER_VALUE_0_AND_1 0x10b8
-
-#define S_TIMERVALUE0 16
-#define M_TIMERVALUE0 0xffffU
-#define V_TIMERVALUE0(x) ((x) << S_TIMERVALUE0)
-#define G_TIMERVALUE0(x) (((x) >> S_TIMERVALUE0) & M_TIMERVALUE0)
-
-#define S_TIMERVALUE1 0
-#define M_TIMERVALUE1 0xffffU
-#define V_TIMERVALUE1(x) ((x) << S_TIMERVALUE1)
-#define G_TIMERVALUE1(x) (((x) >> S_TIMERVALUE1) & M_TIMERVALUE1)
-
-#define A_SGE_TIMER_VALUE_2_AND_3 0x10bc
-
-#define S_TIMERVALUE2 16
-#define M_TIMERVALUE2 0xffffU
-#define V_TIMERVALUE2(x) ((x) << S_TIMERVALUE2)
-#define G_TIMERVALUE2(x) (((x) >> S_TIMERVALUE2) & M_TIMERVALUE2)
-
-#define S_TIMERVALUE3 0
-#define M_TIMERVALUE3 0xffffU
-#define V_TIMERVALUE3(x) ((x) << S_TIMERVALUE3)
-#define G_TIMERVALUE3(x) (((x) >> S_TIMERVALUE3) & M_TIMERVALUE3)
-
-#define A_SGE_TIMER_VALUE_4_AND_5 0x10c0
-
-#define S_TIMERVALUE4 16
-#define M_TIMERVALUE4 0xffffU
-#define V_TIMERVALUE4(x) ((x) << S_TIMERVALUE4)
-#define G_TIMERVALUE4(x) (((x) >> S_TIMERVALUE4) & M_TIMERVALUE4)
-
-#define S_TIMERVALUE5 0
-#define M_TIMERVALUE5 0xffffU
-#define V_TIMERVALUE5(x) ((x) << S_TIMERVALUE5)
-#define G_TIMERVALUE5(x) (((x) >> S_TIMERVALUE5) & M_TIMERVALUE5)
-
-#define A_SGE_PD_RSP_CREDIT01 0x10c4
-
-#define S_RSPCREDITEN0 31
-#define V_RSPCREDITEN0(x) ((x) << S_RSPCREDITEN0)
-#define F_RSPCREDITEN0 V_RSPCREDITEN0(1U)
-
-#define S_MAXTAG0 24
-#define M_MAXTAG0 0x7fU
-#define V_MAXTAG0(x) ((x) << S_MAXTAG0)
-#define G_MAXTAG0(x) (((x) >> S_MAXTAG0) & M_MAXTAG0)
-
-#define S_MAXRSPCNT0 16
-#define M_MAXRSPCNT0 0xffU
-#define V_MAXRSPCNT0(x) ((x) << S_MAXRSPCNT0)
-#define G_MAXRSPCNT0(x) (((x) >> S_MAXRSPCNT0) & M_MAXRSPCNT0)
-
-#define S_RSPCREDITEN1 15
-#define V_RSPCREDITEN1(x) ((x) << S_RSPCREDITEN1)
-#define F_RSPCREDITEN1 V_RSPCREDITEN1(1U)
-
-#define S_MAXTAG1 8
-#define M_MAXTAG1 0x7fU
-#define V_MAXTAG1(x) ((x) << S_MAXTAG1)
-#define G_MAXTAG1(x) (((x) >> S_MAXTAG1) & M_MAXTAG1)
-
-#define S_MAXRSPCNT1 0
-#define M_MAXRSPCNT1 0xffU
-#define V_MAXRSPCNT1(x) ((x) << S_MAXRSPCNT1)
-#define G_MAXRSPCNT1(x) (((x) >> S_MAXRSPCNT1) & M_MAXRSPCNT1)
-
-#define A_SGE_GK_CONTROL 0x10c4
-
-#define S_EN_FLM_FIFTH 29
-#define V_EN_FLM_FIFTH(x) ((x) << S_EN_FLM_FIFTH)
-#define F_EN_FLM_FIFTH V_EN_FLM_FIFTH(1U)
-
-#define S_FL_PROG_THRESH 20
-#define M_FL_PROG_THRESH 0x1ffU
-#define V_FL_PROG_THRESH(x) ((x) << S_FL_PROG_THRESH)
-#define G_FL_PROG_THRESH(x) (((x) >> S_FL_PROG_THRESH) & M_FL_PROG_THRESH)
-
-#define S_COAL_ALL_THREAD 19
-#define V_COAL_ALL_THREAD(x) ((x) << S_COAL_ALL_THREAD)
-#define F_COAL_ALL_THREAD V_COAL_ALL_THREAD(1U)
-
-#define S_EN_PSHB 18
-#define V_EN_PSHB(x) ((x) << S_EN_PSHB)
-#define F_EN_PSHB V_EN_PSHB(1U)
-
-#define S_EN_DB_FIFTH 17
-#define V_EN_DB_FIFTH(x) ((x) << S_EN_DB_FIFTH)
-#define F_EN_DB_FIFTH V_EN_DB_FIFTH(1U)
-
-#define S_DB_PROG_THRESH 8
-#define M_DB_PROG_THRESH 0x1ffU
-#define V_DB_PROG_THRESH(x) ((x) << S_DB_PROG_THRESH)
-#define G_DB_PROG_THRESH(x) (((x) >> S_DB_PROG_THRESH) & M_DB_PROG_THRESH)
-
-#define S_100NS_TIMER 0
-#define M_100NS_TIMER 0xffU
-#define V_100NS_TIMER(x) ((x) << S_100NS_TIMER)
-#define G_100NS_TIMER(x) (((x) >> S_100NS_TIMER) & M_100NS_TIMER)
-
-#define A_SGE_PD_RSP_CREDIT23 0x10c8
-
-#define S_RSPCREDITEN2 31
-#define V_RSPCREDITEN2(x) ((x) << S_RSPCREDITEN2)
-#define F_RSPCREDITEN2 V_RSPCREDITEN2(1U)
-
-#define S_MAXTAG2 24
-#define M_MAXTAG2 0x7fU
-#define V_MAXTAG2(x) ((x) << S_MAXTAG2)
-#define G_MAXTAG2(x) (((x) >> S_MAXTAG2) & M_MAXTAG2)
-
-#define S_MAXRSPCNT2 16
-#define M_MAXRSPCNT2 0xffU
-#define V_MAXRSPCNT2(x) ((x) << S_MAXRSPCNT2)
-#define G_MAXRSPCNT2(x) (((x) >> S_MAXRSPCNT2) & M_MAXRSPCNT2)
-
-#define S_RSPCREDITEN3 15
-#define V_RSPCREDITEN3(x) ((x) << S_RSPCREDITEN3)
-#define F_RSPCREDITEN3 V_RSPCREDITEN3(1U)
-
-#define S_MAXTAG3 8
-#define M_MAXTAG3 0x7fU
-#define V_MAXTAG3(x) ((x) << S_MAXTAG3)
-#define G_MAXTAG3(x) (((x) >> S_MAXTAG3) & M_MAXTAG3)
-
-#define S_MAXRSPCNT3 0
-#define M_MAXRSPCNT3 0xffU
-#define V_MAXRSPCNT3(x) ((x) << S_MAXRSPCNT3)
-#define G_MAXRSPCNT3(x) (((x) >> S_MAXRSPCNT3) & M_MAXRSPCNT3)
-
-#define A_SGE_GK_CONTROL2 0x10c8
-
-#define S_DBQ_TIMER_TICK 16
-#define M_DBQ_TIMER_TICK 0xffffU
-#define V_DBQ_TIMER_TICK(x) ((x) << S_DBQ_TIMER_TICK)
-#define G_DBQ_TIMER_TICK(x) (((x) >> S_DBQ_TIMER_TICK) & M_DBQ_TIMER_TICK)
-
-#define S_FL_MERGE_CNT_THRESH 8
-#define M_FL_MERGE_CNT_THRESH 0xfU
-#define V_FL_MERGE_CNT_THRESH(x) ((x) << S_FL_MERGE_CNT_THRESH)
-#define G_FL_MERGE_CNT_THRESH(x) (((x) >> S_FL_MERGE_CNT_THRESH) & M_FL_MERGE_CNT_THRESH)
-
-#define S_MERGE_CNT_THRESH 0
-#define M_MERGE_CNT_THRESH 0x3fU
-#define V_MERGE_CNT_THRESH(x) ((x) << S_MERGE_CNT_THRESH)
-#define G_MERGE_CNT_THRESH(x) (((x) >> S_MERGE_CNT_THRESH) & M_MERGE_CNT_THRESH)
-
-#define A_SGE_DEBUG_INDEX 0x10cc
-#define A_SGE_DEBUG_DATA_HIGH 0x10d0
-#define A_SGE_DEBUG_DATA_LOW 0x10d4
-#define A_SGE_REVISION 0x10d8
-#define A_SGE_INT_CAUSE4 0x10dc
-
-#define S_ERR_BAD_UPFL_INC_CREDIT3 8
-#define V_ERR_BAD_UPFL_INC_CREDIT3(x) ((x) << S_ERR_BAD_UPFL_INC_CREDIT3)
-#define F_ERR_BAD_UPFL_INC_CREDIT3 V_ERR_BAD_UPFL_INC_CREDIT3(1U)
-
-#define S_ERR_BAD_UPFL_INC_CREDIT2 7
-#define V_ERR_BAD_UPFL_INC_CREDIT2(x) ((x) << S_ERR_BAD_UPFL_INC_CREDIT2)
-#define F_ERR_BAD_UPFL_INC_CREDIT2 V_ERR_BAD_UPFL_INC_CREDIT2(1U)
-
-#define S_ERR_BAD_UPFL_INC_CREDIT1 6
-#define V_ERR_BAD_UPFL_INC_CREDIT1(x) ((x) << S_ERR_BAD_UPFL_INC_CREDIT1)
-#define F_ERR_BAD_UPFL_INC_CREDIT1 V_ERR_BAD_UPFL_INC_CREDIT1(1U)
-
-#define S_ERR_BAD_UPFL_INC_CREDIT0 5
-#define V_ERR_BAD_UPFL_INC_CREDIT0(x) ((x) << S_ERR_BAD_UPFL_INC_CREDIT0)
-#define F_ERR_BAD_UPFL_INC_CREDIT0 V_ERR_BAD_UPFL_INC_CREDIT0(1U)
-
-#define S_ERR_PHYSADDR_LEN0_IDMA1 4
-#define V_ERR_PHYSADDR_LEN0_IDMA1(x) ((x) << S_ERR_PHYSADDR_LEN0_IDMA1)
-#define F_ERR_PHYSADDR_LEN0_IDMA1 V_ERR_PHYSADDR_LEN0_IDMA1(1U)
-
-#define S_ERR_PHYSADDR_LEN0_IDMA0 3
-#define V_ERR_PHYSADDR_LEN0_IDMA0(x) ((x) << S_ERR_PHYSADDR_LEN0_IDMA0)
-#define F_ERR_PHYSADDR_LEN0_IDMA0 V_ERR_PHYSADDR_LEN0_IDMA0(1U)
-
-#define S_ERR_FLM_INVALID_PKT_DROP1 2
-#define V_ERR_FLM_INVALID_PKT_DROP1(x) ((x) << S_ERR_FLM_INVALID_PKT_DROP1)
-#define F_ERR_FLM_INVALID_PKT_DROP1 V_ERR_FLM_INVALID_PKT_DROP1(1U)
-
-#define S_ERR_FLM_INVALID_PKT_DROP0 1
-#define V_ERR_FLM_INVALID_PKT_DROP0(x) ((x) << S_ERR_FLM_INVALID_PKT_DROP0)
-#define F_ERR_FLM_INVALID_PKT_DROP0 V_ERR_FLM_INVALID_PKT_DROP0(1U)
-
-#define S_ERR_UNEXPECTED_TIMER 0
-#define V_ERR_UNEXPECTED_TIMER(x) ((x) << S_ERR_UNEXPECTED_TIMER)
-#define F_ERR_UNEXPECTED_TIMER V_ERR_UNEXPECTED_TIMER(1U)
-
-#define S_BAR2_EGRESS_LEN_OR_ADDR_ERR 29
-#define V_BAR2_EGRESS_LEN_OR_ADDR_ERR(x) ((x) << S_BAR2_EGRESS_LEN_OR_ADDR_ERR)
-#define F_BAR2_EGRESS_LEN_OR_ADDR_ERR V_BAR2_EGRESS_LEN_OR_ADDR_ERR(1U)
-
-#define S_ERR_CPL_EXCEED_MAX_IQE_SIZE1 28
-#define V_ERR_CPL_EXCEED_MAX_IQE_SIZE1(x) ((x) << S_ERR_CPL_EXCEED_MAX_IQE_SIZE1)
-#define F_ERR_CPL_EXCEED_MAX_IQE_SIZE1 V_ERR_CPL_EXCEED_MAX_IQE_SIZE1(1U)
-
-#define S_ERR_CPL_EXCEED_MAX_IQE_SIZE0 27
-#define V_ERR_CPL_EXCEED_MAX_IQE_SIZE0(x) ((x) << S_ERR_CPL_EXCEED_MAX_IQE_SIZE0)
-#define F_ERR_CPL_EXCEED_MAX_IQE_SIZE0 V_ERR_CPL_EXCEED_MAX_IQE_SIZE0(1U)
-
-#define S_ERR_WR_LEN_TOO_LARGE3 26
-#define V_ERR_WR_LEN_TOO_LARGE3(x) ((x) << S_ERR_WR_LEN_TOO_LARGE3)
-#define F_ERR_WR_LEN_TOO_LARGE3 V_ERR_WR_LEN_TOO_LARGE3(1U)
-
-#define S_ERR_WR_LEN_TOO_LARGE2 25
-#define V_ERR_WR_LEN_TOO_LARGE2(x) ((x) << S_ERR_WR_LEN_TOO_LARGE2)
-#define F_ERR_WR_LEN_TOO_LARGE2 V_ERR_WR_LEN_TOO_LARGE2(1U)
-
-#define S_ERR_WR_LEN_TOO_LARGE1 24
-#define V_ERR_WR_LEN_TOO_LARGE1(x) ((x) << S_ERR_WR_LEN_TOO_LARGE1)
-#define F_ERR_WR_LEN_TOO_LARGE1 V_ERR_WR_LEN_TOO_LARGE1(1U)
-
-#define S_ERR_WR_LEN_TOO_LARGE0 23
-#define V_ERR_WR_LEN_TOO_LARGE0(x) ((x) << S_ERR_WR_LEN_TOO_LARGE0)
-#define F_ERR_WR_LEN_TOO_LARGE0 V_ERR_WR_LEN_TOO_LARGE0(1U)
-
-#define S_ERR_LARGE_MINFETCH_WITH_TXCOAL3 22
-#define V_ERR_LARGE_MINFETCH_WITH_TXCOAL3(x) ((x) << S_ERR_LARGE_MINFETCH_WITH_TXCOAL3)
-#define F_ERR_LARGE_MINFETCH_WITH_TXCOAL3 V_ERR_LARGE_MINFETCH_WITH_TXCOAL3(1U)
-
-#define S_ERR_LARGE_MINFETCH_WITH_TXCOAL2 21
-#define V_ERR_LARGE_MINFETCH_WITH_TXCOAL2(x) ((x) << S_ERR_LARGE_MINFETCH_WITH_TXCOAL2)
-#define F_ERR_LARGE_MINFETCH_WITH_TXCOAL2 V_ERR_LARGE_MINFETCH_WITH_TXCOAL2(1U)
-
-#define S_ERR_LARGE_MINFETCH_WITH_TXCOAL1 20
-#define V_ERR_LARGE_MINFETCH_WITH_TXCOAL1(x) ((x) << S_ERR_LARGE_MINFETCH_WITH_TXCOAL1)
-#define F_ERR_LARGE_MINFETCH_WITH_TXCOAL1 V_ERR_LARGE_MINFETCH_WITH_TXCOAL1(1U)
-
-#define S_ERR_LARGE_MINFETCH_WITH_TXCOAL0 19
-#define V_ERR_LARGE_MINFETCH_WITH_TXCOAL0(x) ((x) << S_ERR_LARGE_MINFETCH_WITH_TXCOAL0)
-#define F_ERR_LARGE_MINFETCH_WITH_TXCOAL0 V_ERR_LARGE_MINFETCH_WITH_TXCOAL0(1U)
-
-#define S_COAL_WITH_HP_DISABLE_ERR 18
-#define V_COAL_WITH_HP_DISABLE_ERR(x) ((x) << S_COAL_WITH_HP_DISABLE_ERR)
-#define F_COAL_WITH_HP_DISABLE_ERR V_COAL_WITH_HP_DISABLE_ERR(1U)
-
-#define S_BAR2_EGRESS_COAL0_ERR 17
-#define V_BAR2_EGRESS_COAL0_ERR(x) ((x) << S_BAR2_EGRESS_COAL0_ERR)
-#define F_BAR2_EGRESS_COAL0_ERR V_BAR2_EGRESS_COAL0_ERR(1U)
-
-#define S_BAR2_EGRESS_SIZE_ERR 16
-#define V_BAR2_EGRESS_SIZE_ERR(x) ((x) << S_BAR2_EGRESS_SIZE_ERR)
-#define F_BAR2_EGRESS_SIZE_ERR V_BAR2_EGRESS_SIZE_ERR(1U)
-
-#define S_FLM_PC_RSP_ERR 15
-#define V_FLM_PC_RSP_ERR(x) ((x) << S_FLM_PC_RSP_ERR)
-#define F_FLM_PC_RSP_ERR V_FLM_PC_RSP_ERR(1U)
-
-#define S_DBFIFO_HP_INT_LOW 14
-#define V_DBFIFO_HP_INT_LOW(x) ((x) << S_DBFIFO_HP_INT_LOW)
-#define F_DBFIFO_HP_INT_LOW V_DBFIFO_HP_INT_LOW(1U)
-
-#define S_DBFIFO_LP_INT_LOW 13
-#define V_DBFIFO_LP_INT_LOW(x) ((x) << S_DBFIFO_LP_INT_LOW)
-#define F_DBFIFO_LP_INT_LOW V_DBFIFO_LP_INT_LOW(1U)
-
-#define S_DBFIFO_FL_INT_LOW 12
-#define V_DBFIFO_FL_INT_LOW(x) ((x) << S_DBFIFO_FL_INT_LOW)
-#define F_DBFIFO_FL_INT_LOW V_DBFIFO_FL_INT_LOW(1U)
-
-#define S_DBFIFO_FL_INT 11
-#define V_DBFIFO_FL_INT(x) ((x) << S_DBFIFO_FL_INT)
-#define F_DBFIFO_FL_INT V_DBFIFO_FL_INT(1U)
-
-#define S_ERR_RX_CPL_PACKET_SIZE1 10
-#define V_ERR_RX_CPL_PACKET_SIZE1(x) ((x) << S_ERR_RX_CPL_PACKET_SIZE1)
-#define F_ERR_RX_CPL_PACKET_SIZE1 V_ERR_RX_CPL_PACKET_SIZE1(1U)
-
-#define S_ERR_RX_CPL_PACKET_SIZE0 9
-#define V_ERR_RX_CPL_PACKET_SIZE0(x) ((x) << S_ERR_RX_CPL_PACKET_SIZE0)
-#define F_ERR_RX_CPL_PACKET_SIZE0 V_ERR_RX_CPL_PACKET_SIZE0(1U)
-
-#define S_ERR_ISHIFT_UR1 31
-#define V_ERR_ISHIFT_UR1(x) ((x) << S_ERR_ISHIFT_UR1)
-#define F_ERR_ISHIFT_UR1 V_ERR_ISHIFT_UR1(1U)
-
-#define S_ERR_ISHIFT_UR0 30
-#define V_ERR_ISHIFT_UR0(x) ((x) << S_ERR_ISHIFT_UR0)
-#define F_ERR_ISHIFT_UR0 V_ERR_ISHIFT_UR0(1U)
-
-#define S_ERR_TH3_MAX_FETCH 14
-#define V_ERR_TH3_MAX_FETCH(x) ((x) << S_ERR_TH3_MAX_FETCH)
-#define F_ERR_TH3_MAX_FETCH V_ERR_TH3_MAX_FETCH(1U)
-
-#define S_ERR_TH2_MAX_FETCH 13
-#define V_ERR_TH2_MAX_FETCH(x) ((x) << S_ERR_TH2_MAX_FETCH)
-#define F_ERR_TH2_MAX_FETCH V_ERR_TH2_MAX_FETCH(1U)
-
-#define S_ERR_TH1_MAX_FETCH 12
-#define V_ERR_TH1_MAX_FETCH(x) ((x) << S_ERR_TH1_MAX_FETCH)
-#define F_ERR_TH1_MAX_FETCH V_ERR_TH1_MAX_FETCH(1U)
-
-#define S_ERR_TH0_MAX_FETCH 11
-#define V_ERR_TH0_MAX_FETCH(x) ((x) << S_ERR_TH0_MAX_FETCH)
-#define F_ERR_TH0_MAX_FETCH V_ERR_TH0_MAX_FETCH(1U)
-
-#define A_SGE_INT_ENABLE4 0x10e0
-#define A_SGE_STAT_TOTAL 0x10e4
-#define A_SGE_STAT_MATCH 0x10e8
-#define A_SGE_STAT_CFG 0x10ec
-
-#define S_ITPOPMODE 8
-#define V_ITPOPMODE(x) ((x) << S_ITPOPMODE)
-#define F_ITPOPMODE V_ITPOPMODE(1U)
-
-#define S_EGRCTXTOPMODE 6
-#define M_EGRCTXTOPMODE 0x3U
-#define V_EGRCTXTOPMODE(x) ((x) << S_EGRCTXTOPMODE)
-#define G_EGRCTXTOPMODE(x) (((x) >> S_EGRCTXTOPMODE) & M_EGRCTXTOPMODE)
-
-#define S_INGCTXTOPMODE 4
-#define M_INGCTXTOPMODE 0x3U
-#define V_INGCTXTOPMODE(x) ((x) << S_INGCTXTOPMODE)
-#define G_INGCTXTOPMODE(x) (((x) >> S_INGCTXTOPMODE) & M_INGCTXTOPMODE)
-
-#define S_STATMODE 2
-#define M_STATMODE 0x3U
-#define V_STATMODE(x) ((x) << S_STATMODE)
-#define G_STATMODE(x) (((x) >> S_STATMODE) & M_STATMODE)
-
-#define S_STATSOURCE 0
-#define M_STATSOURCE 0x3U
-#define V_STATSOURCE(x) ((x) << S_STATSOURCE)
-#define G_STATSOURCE(x) (((x) >> S_STATSOURCE) & M_STATSOURCE)
-
-#define S_STATSOURCE_T5 9
-#define M_STATSOURCE_T5 0xfU
-#define V_STATSOURCE_T5(x) ((x) << S_STATSOURCE_T5)
-#define G_STATSOURCE_T5(x) (((x) >> S_STATSOURCE_T5) & M_STATSOURCE_T5)
-
-#define S_T6_STATMODE 0
-#define M_T6_STATMODE 0xfU
-#define V_T6_STATMODE(x) ((x) << S_T6_STATMODE)
-#define G_T6_STATMODE(x) (((x) >> S_T6_STATMODE) & M_T6_STATMODE)
-
-#define A_SGE_HINT_CFG 0x10f0
-
-#define S_HINTSALLOWEDNOHDR 6
-#define M_HINTSALLOWEDNOHDR 0x3fU
-#define V_HINTSALLOWEDNOHDR(x) ((x) << S_HINTSALLOWEDNOHDR)
-#define G_HINTSALLOWEDNOHDR(x) (((x) >> S_HINTSALLOWEDNOHDR) & M_HINTSALLOWEDNOHDR)
-
-#define S_HINTSALLOWEDHDR 0
-#define M_HINTSALLOWEDHDR 0x3fU
-#define V_HINTSALLOWEDHDR(x) ((x) << S_HINTSALLOWEDHDR)
-#define G_HINTSALLOWEDHDR(x) (((x) >> S_HINTSALLOWEDHDR) & M_HINTSALLOWEDHDR)
-
-#define S_UPCUTOFFTHRESHLP 12
-#define M_UPCUTOFFTHRESHLP 0x7ffU
-#define V_UPCUTOFFTHRESHLP(x) ((x) << S_UPCUTOFFTHRESHLP)
-#define G_UPCUTOFFTHRESHLP(x) (((x) >> S_UPCUTOFFTHRESHLP) & M_UPCUTOFFTHRESHLP)
-
-#define A_SGE_INGRESS_QUEUES_PER_PAGE_PF 0x10f4
-#define A_SGE_INGRESS_QUEUES_PER_PAGE_VF 0x10f8
-#define A_SGE_PD_WRR_CONFIG 0x10fc
-
-#define S_EDMA_WEIGHT 0
-#define M_EDMA_WEIGHT 0x3fU
-#define V_EDMA_WEIGHT(x) ((x) << S_EDMA_WEIGHT)
-#define G_EDMA_WEIGHT(x) (((x) >> S_EDMA_WEIGHT) & M_EDMA_WEIGHT)
-
-#define A_SGE_ERROR_STATS 0x1100
-
-#define S_UNCAPTURED_ERROR 18
-#define V_UNCAPTURED_ERROR(x) ((x) << S_UNCAPTURED_ERROR)
-#define F_UNCAPTURED_ERROR V_UNCAPTURED_ERROR(1U)
-
-#define S_ERROR_QID_VALID 17
-#define V_ERROR_QID_VALID(x) ((x) << S_ERROR_QID_VALID)
-#define F_ERROR_QID_VALID V_ERROR_QID_VALID(1U)
-
-#define S_ERROR_QID 0
-#define M_ERROR_QID 0x1ffffU
-#define V_ERROR_QID(x) ((x) << S_ERROR_QID)
-#define G_ERROR_QID(x) (((x) >> S_ERROR_QID) & M_ERROR_QID)
-
-#define S_CAUSE_REGISTER 24
-#define M_CAUSE_REGISTER 0x7U
-#define V_CAUSE_REGISTER(x) ((x) << S_CAUSE_REGISTER)
-#define G_CAUSE_REGISTER(x) (((x) >> S_CAUSE_REGISTER) & M_CAUSE_REGISTER)
-
-#define S_CAUSE_BIT 19
-#define M_CAUSE_BIT 0x1fU
-#define V_CAUSE_BIT(x) ((x) << S_CAUSE_BIT)
-#define G_CAUSE_BIT(x) (((x) >> S_CAUSE_BIT) & M_CAUSE_BIT)
-
-#define A_SGE_SHARED_TAG_CHAN_CFG 0x1104
-
-#define S_MINTAG3 24
-#define M_MINTAG3 0xffU
-#define V_MINTAG3(x) ((x) << S_MINTAG3)
-#define G_MINTAG3(x) (((x) >> S_MINTAG3) & M_MINTAG3)
-
-#define S_MINTAG2 16
-#define M_MINTAG2 0xffU
-#define V_MINTAG2(x) ((x) << S_MINTAG2)
-#define G_MINTAG2(x) (((x) >> S_MINTAG2) & M_MINTAG2)
-
-#define S_MINTAG1 8
-#define M_MINTAG1 0xffU
-#define V_MINTAG1(x) ((x) << S_MINTAG1)
-#define G_MINTAG1(x) (((x) >> S_MINTAG1) & M_MINTAG1)
-
-#define S_MINTAG0 0
-#define M_MINTAG0 0xffU
-#define V_MINTAG0(x) ((x) << S_MINTAG0)
-#define G_MINTAG0(x) (((x) >> S_MINTAG0) & M_MINTAG0)
-
-#define A_SGE_IDMA0_DROP_CNT 0x1104
-#define A_SGE_SHARED_TAG_POOL_CFG 0x1108
-
-#define S_TAGPOOLTOTAL 0
-#define M_TAGPOOLTOTAL 0xffU
-#define V_TAGPOOLTOTAL(x) ((x) << S_TAGPOOLTOTAL)
-#define G_TAGPOOLTOTAL(x) (((x) >> S_TAGPOOLTOTAL) & M_TAGPOOLTOTAL)
-
-#define A_SGE_IDMA1_DROP_CNT 0x1108
-#define A_SGE_INT_CAUSE5 0x110c
-
-#define S_ERR_T_RXCRC 31
-#define V_ERR_T_RXCRC(x) ((x) << S_ERR_T_RXCRC)
-#define F_ERR_T_RXCRC V_ERR_T_RXCRC(1U)
-
-#define S_PERR_MC_RSPDATA 30
-#define V_PERR_MC_RSPDATA(x) ((x) << S_PERR_MC_RSPDATA)
-#define F_PERR_MC_RSPDATA V_PERR_MC_RSPDATA(1U)
-
-#define S_PERR_PC_RSPDATA 29
-#define V_PERR_PC_RSPDATA(x) ((x) << S_PERR_PC_RSPDATA)
-#define F_PERR_PC_RSPDATA V_PERR_PC_RSPDATA(1U)
-
-#define S_PERR_PD_RDRSPDATA 28
-#define V_PERR_PD_RDRSPDATA(x) ((x) << S_PERR_PD_RDRSPDATA)
-#define F_PERR_PD_RDRSPDATA V_PERR_PD_RDRSPDATA(1U)
-
-#define S_PERR_U_RXDATA 27
-#define V_PERR_U_RXDATA(x) ((x) << S_PERR_U_RXDATA)
-#define F_PERR_U_RXDATA V_PERR_U_RXDATA(1U)
-
-#define S_PERR_UD_RXDATA 26
-#define V_PERR_UD_RXDATA(x) ((x) << S_PERR_UD_RXDATA)
-#define F_PERR_UD_RXDATA V_PERR_UD_RXDATA(1U)
-
-#define S_PERR_UP_DATA 25
-#define V_PERR_UP_DATA(x) ((x) << S_PERR_UP_DATA)
-#define F_PERR_UP_DATA V_PERR_UP_DATA(1U)
-
-#define S_PERR_CIM2SGE_RXDATA 24
-#define V_PERR_CIM2SGE_RXDATA(x) ((x) << S_PERR_CIM2SGE_RXDATA)
-#define F_PERR_CIM2SGE_RXDATA V_PERR_CIM2SGE_RXDATA(1U)
-
-#define S_PERR_HINT_DELAY_FIFO1_T5 23
-#define V_PERR_HINT_DELAY_FIFO1_T5(x) ((x) << S_PERR_HINT_DELAY_FIFO1_T5)
-#define F_PERR_HINT_DELAY_FIFO1_T5 V_PERR_HINT_DELAY_FIFO1_T5(1U)
-
-#define S_PERR_HINT_DELAY_FIFO0_T5 22
-#define V_PERR_HINT_DELAY_FIFO0_T5(x) ((x) << S_PERR_HINT_DELAY_FIFO0_T5)
-#define F_PERR_HINT_DELAY_FIFO0_T5 V_PERR_HINT_DELAY_FIFO0_T5(1U)
-
-#define S_PERR_IMSG_PD_FIFO_T5 21
-#define V_PERR_IMSG_PD_FIFO_T5(x) ((x) << S_PERR_IMSG_PD_FIFO_T5)
-#define F_PERR_IMSG_PD_FIFO_T5 V_PERR_IMSG_PD_FIFO_T5(1U)
-
-#define S_PERR_ULPTX_FIFO1_T5 20
-#define V_PERR_ULPTX_FIFO1_T5(x) ((x) << S_PERR_ULPTX_FIFO1_T5)
-#define F_PERR_ULPTX_FIFO1_T5 V_PERR_ULPTX_FIFO1_T5(1U)
-
-#define S_PERR_ULPTX_FIFO0_T5 19
-#define V_PERR_ULPTX_FIFO0_T5(x) ((x) << S_PERR_ULPTX_FIFO0_T5)
-#define F_PERR_ULPTX_FIFO0_T5 V_PERR_ULPTX_FIFO0_T5(1U)
-
-#define S_PERR_IDMA2IMSG_FIFO1_T5 18
-#define V_PERR_IDMA2IMSG_FIFO1_T5(x) ((x) << S_PERR_IDMA2IMSG_FIFO1_T5)
-#define F_PERR_IDMA2IMSG_FIFO1_T5 V_PERR_IDMA2IMSG_FIFO1_T5(1U)
-
-#define S_PERR_IDMA2IMSG_FIFO0_T5 17
-#define V_PERR_IDMA2IMSG_FIFO0_T5(x) ((x) << S_PERR_IDMA2IMSG_FIFO0_T5)
-#define F_PERR_IDMA2IMSG_FIFO0_T5 V_PERR_IDMA2IMSG_FIFO0_T5(1U)
-
-#define S_PERR_POINTER_DATA_FIFO0 16
-#define V_PERR_POINTER_DATA_FIFO0(x) ((x) << S_PERR_POINTER_DATA_FIFO0)
-#define F_PERR_POINTER_DATA_FIFO0 V_PERR_POINTER_DATA_FIFO0(1U)
-
-#define S_PERR_POINTER_DATA_FIFO1 15
-#define V_PERR_POINTER_DATA_FIFO1(x) ((x) << S_PERR_POINTER_DATA_FIFO1)
-#define F_PERR_POINTER_DATA_FIFO1 V_PERR_POINTER_DATA_FIFO1(1U)
-
-#define S_PERR_POINTER_HDR_FIFO0 14
-#define V_PERR_POINTER_HDR_FIFO0(x) ((x) << S_PERR_POINTER_HDR_FIFO0)
-#define F_PERR_POINTER_HDR_FIFO0 V_PERR_POINTER_HDR_FIFO0(1U)
-
-#define S_PERR_POINTER_HDR_FIFO1 13
-#define V_PERR_POINTER_HDR_FIFO1(x) ((x) << S_PERR_POINTER_HDR_FIFO1)
-#define F_PERR_POINTER_HDR_FIFO1 V_PERR_POINTER_HDR_FIFO1(1U)
-
-#define S_PERR_PAYLOAD_FIFO0 12
-#define V_PERR_PAYLOAD_FIFO0(x) ((x) << S_PERR_PAYLOAD_FIFO0)
-#define F_PERR_PAYLOAD_FIFO0 V_PERR_PAYLOAD_FIFO0(1U)
-
-#define S_PERR_PAYLOAD_FIFO1 11
-#define V_PERR_PAYLOAD_FIFO1(x) ((x) << S_PERR_PAYLOAD_FIFO1)
-#define F_PERR_PAYLOAD_FIFO1 V_PERR_PAYLOAD_FIFO1(1U)
-
-#define S_PERR_EDMA_INPUT_FIFO3 10
-#define V_PERR_EDMA_INPUT_FIFO3(x) ((x) << S_PERR_EDMA_INPUT_FIFO3)
-#define F_PERR_EDMA_INPUT_FIFO3 V_PERR_EDMA_INPUT_FIFO3(1U)
-
-#define S_PERR_EDMA_INPUT_FIFO2 9
-#define V_PERR_EDMA_INPUT_FIFO2(x) ((x) << S_PERR_EDMA_INPUT_FIFO2)
-#define F_PERR_EDMA_INPUT_FIFO2 V_PERR_EDMA_INPUT_FIFO2(1U)
-
-#define S_PERR_EDMA_INPUT_FIFO1 8
-#define V_PERR_EDMA_INPUT_FIFO1(x) ((x) << S_PERR_EDMA_INPUT_FIFO1)
-#define F_PERR_EDMA_INPUT_FIFO1 V_PERR_EDMA_INPUT_FIFO1(1U)
-
-#define S_PERR_EDMA_INPUT_FIFO0 7
-#define V_PERR_EDMA_INPUT_FIFO0(x) ((x) << S_PERR_EDMA_INPUT_FIFO0)
-#define F_PERR_EDMA_INPUT_FIFO0 V_PERR_EDMA_INPUT_FIFO0(1U)
-
-#define S_PERR_MGT_BAR2_FIFO 6
-#define V_PERR_MGT_BAR2_FIFO(x) ((x) << S_PERR_MGT_BAR2_FIFO)
-#define F_PERR_MGT_BAR2_FIFO V_PERR_MGT_BAR2_FIFO(1U)
-
-#define S_PERR_HEADERSPLIT_FIFO1_T5 5
-#define V_PERR_HEADERSPLIT_FIFO1_T5(x) ((x) << S_PERR_HEADERSPLIT_FIFO1_T5)
-#define F_PERR_HEADERSPLIT_FIFO1_T5 V_PERR_HEADERSPLIT_FIFO1_T5(1U)
-
-#define S_PERR_HEADERSPLIT_FIFO0_T5 4
-#define V_PERR_HEADERSPLIT_FIFO0_T5(x) ((x) << S_PERR_HEADERSPLIT_FIFO0_T5)
-#define F_PERR_HEADERSPLIT_FIFO0_T5 V_PERR_HEADERSPLIT_FIFO0_T5(1U)
-
-#define S_PERR_CIM_FIFO1 3
-#define V_PERR_CIM_FIFO1(x) ((x) << S_PERR_CIM_FIFO1)
-#define F_PERR_CIM_FIFO1 V_PERR_CIM_FIFO1(1U)
-
-#define S_PERR_CIM_FIFO0 2
-#define V_PERR_CIM_FIFO0(x) ((x) << S_PERR_CIM_FIFO0)
-#define F_PERR_CIM_FIFO0 V_PERR_CIM_FIFO0(1U)
-
-#define S_PERR_IDMA_SWITCH_OUTPUT_FIFO1 1
-#define V_PERR_IDMA_SWITCH_OUTPUT_FIFO1(x) ((x) << S_PERR_IDMA_SWITCH_OUTPUT_FIFO1)
-#define F_PERR_IDMA_SWITCH_OUTPUT_FIFO1 V_PERR_IDMA_SWITCH_OUTPUT_FIFO1(1U)
-
-#define S_PERR_IDMA_SWITCH_OUTPUT_FIFO0 0
-#define V_PERR_IDMA_SWITCH_OUTPUT_FIFO0(x) ((x) << S_PERR_IDMA_SWITCH_OUTPUT_FIFO0)
-#define F_PERR_IDMA_SWITCH_OUTPUT_FIFO0 V_PERR_IDMA_SWITCH_OUTPUT_FIFO0(1U)
-
-#define A_SGE_INT_ENABLE5 0x1110
-#define A_SGE_PERR_ENABLE5 0x1114
-#define A_SGE_DBFIFO_STATUS2 0x1118
-
-#define S_FL_INT_THRESH 24
-#define M_FL_INT_THRESH 0xfU
-#define V_FL_INT_THRESH(x) ((x) << S_FL_INT_THRESH)
-#define G_FL_INT_THRESH(x) (((x) >> S_FL_INT_THRESH) & M_FL_INT_THRESH)
-
-#define S_FL_COUNT 14
-#define M_FL_COUNT 0x3ffU
-#define V_FL_COUNT(x) ((x) << S_FL_COUNT)
-#define G_FL_COUNT(x) (((x) >> S_FL_COUNT) & M_FL_COUNT)
-
-#define S_HP_INT_THRESH_T5 10
-#define M_HP_INT_THRESH_T5 0xfU
-#define V_HP_INT_THRESH_T5(x) ((x) << S_HP_INT_THRESH_T5)
-#define G_HP_INT_THRESH_T5(x) (((x) >> S_HP_INT_THRESH_T5) & M_HP_INT_THRESH_T5)
-
-#define S_HP_COUNT_T5 0
-#define M_HP_COUNT_T5 0x3ffU
-#define V_HP_COUNT_T5(x) ((x) << S_HP_COUNT_T5)
-#define G_HP_COUNT_T5(x) (((x) >> S_HP_COUNT_T5) & M_HP_COUNT_T5)
-
-#define A_SGE_FETCH_BURST_MAX_0_AND_1 0x111c
-
-#define S_FETCHBURSTMAX0 16
-#define M_FETCHBURSTMAX0 0x3ffU
-#define V_FETCHBURSTMAX0(x) ((x) << S_FETCHBURSTMAX0)
-#define G_FETCHBURSTMAX0(x) (((x) >> S_FETCHBURSTMAX0) & M_FETCHBURSTMAX0)
-
-#define S_FETCHBURSTMAX1 0
-#define M_FETCHBURSTMAX1 0x3ffU
-#define V_FETCHBURSTMAX1(x) ((x) << S_FETCHBURSTMAX1)
-#define G_FETCHBURSTMAX1(x) (((x) >> S_FETCHBURSTMAX1) & M_FETCHBURSTMAX1)
-
-#define A_SGE_FETCH_BURST_MAX_2_AND_3 0x1120
-
-#define S_FETCHBURSTMAX2 16
-#define M_FETCHBURSTMAX2 0x3ffU
-#define V_FETCHBURSTMAX2(x) ((x) << S_FETCHBURSTMAX2)
-#define G_FETCHBURSTMAX2(x) (((x) >> S_FETCHBURSTMAX2) & M_FETCHBURSTMAX2)
-
-#define S_FETCHBURSTMAX3 0
-#define M_FETCHBURSTMAX3 0x3ffU
-#define V_FETCHBURSTMAX3(x) ((x) << S_FETCHBURSTMAX3)
-#define G_FETCHBURSTMAX3(x) (((x) >> S_FETCHBURSTMAX3) & M_FETCHBURSTMAX3)
-
-#define A_SGE_CONTROL2 0x1124
-
-#define S_UPFLCUTOFFDIS 21
-#define V_UPFLCUTOFFDIS(x) ((x) << S_UPFLCUTOFFDIS)
-#define F_UPFLCUTOFFDIS V_UPFLCUTOFFDIS(1U)
-
-#define S_RXCPLSIZEAUTOCORRECT 20
-#define V_RXCPLSIZEAUTOCORRECT(x) ((x) << S_RXCPLSIZEAUTOCORRECT)
-#define F_RXCPLSIZEAUTOCORRECT V_RXCPLSIZEAUTOCORRECT(1U)
-
-#define S_IDMAARBROUNDROBIN 19
-#define V_IDMAARBROUNDROBIN(x) ((x) << S_IDMAARBROUNDROBIN)
-#define F_IDMAARBROUNDROBIN V_IDMAARBROUNDROBIN(1U)
-
-#define S_INGPACKBOUNDARY 16
-#define M_INGPACKBOUNDARY 0x7U
-#define V_INGPACKBOUNDARY(x) ((x) << S_INGPACKBOUNDARY)
-#define G_INGPACKBOUNDARY(x) (((x) >> S_INGPACKBOUNDARY) & M_INGPACKBOUNDARY)
-
-#define S_CGEN_EGRESS_CONTEXT 15
-#define V_CGEN_EGRESS_CONTEXT(x) ((x) << S_CGEN_EGRESS_CONTEXT)
-#define F_CGEN_EGRESS_CONTEXT V_CGEN_EGRESS_CONTEXT(1U)
-
-#define S_CGEN_INGRESS_CONTEXT 14
-#define V_CGEN_INGRESS_CONTEXT(x) ((x) << S_CGEN_INGRESS_CONTEXT)
-#define F_CGEN_INGRESS_CONTEXT V_CGEN_INGRESS_CONTEXT(1U)
-
-#define S_CGEN_IDMA 13
-#define V_CGEN_IDMA(x) ((x) << S_CGEN_IDMA)
-#define F_CGEN_IDMA V_CGEN_IDMA(1U)
-
-#define S_CGEN_DBP 12
-#define V_CGEN_DBP(x) ((x) << S_CGEN_DBP)
-#define F_CGEN_DBP V_CGEN_DBP(1U)
-
-#define S_CGEN_EDMA 11
-#define V_CGEN_EDMA(x) ((x) << S_CGEN_EDMA)
-#define F_CGEN_EDMA V_CGEN_EDMA(1U)
-
-#define S_VFIFO_ENABLE 10
-#define V_VFIFO_ENABLE(x) ((x) << S_VFIFO_ENABLE)
-#define F_VFIFO_ENABLE V_VFIFO_ENABLE(1U)
-
-#define S_FLM_RESCHEDULE_MODE 9
-#define V_FLM_RESCHEDULE_MODE(x) ((x) << S_FLM_RESCHEDULE_MODE)
-#define F_FLM_RESCHEDULE_MODE V_FLM_RESCHEDULE_MODE(1U)
-
-#define S_HINTDEPTHCTLFL 4
-#define M_HINTDEPTHCTLFL 0x1fU
-#define V_HINTDEPTHCTLFL(x) ((x) << S_HINTDEPTHCTLFL)
-#define G_HINTDEPTHCTLFL(x) (((x) >> S_HINTDEPTHCTLFL) & M_HINTDEPTHCTLFL)
-
-#define S_FORCE_ORDERING 3
-#define V_FORCE_ORDERING(x) ((x) << S_FORCE_ORDERING)
-#define F_FORCE_ORDERING V_FORCE_ORDERING(1U)
-
-#define S_TX_COALESCE_SIZE 2
-#define V_TX_COALESCE_SIZE(x) ((x) << S_TX_COALESCE_SIZE)
-#define F_TX_COALESCE_SIZE V_TX_COALESCE_SIZE(1U)
-
-#define S_COAL_STRICT_CIM_PRI 1
-#define V_COAL_STRICT_CIM_PRI(x) ((x) << S_COAL_STRICT_CIM_PRI)
-#define F_COAL_STRICT_CIM_PRI V_COAL_STRICT_CIM_PRI(1U)
-
-#define S_TX_COALESCE_PRI 0
-#define V_TX_COALESCE_PRI(x) ((x) << S_TX_COALESCE_PRI)
-#define F_TX_COALESCE_PRI V_TX_COALESCE_PRI(1U)
-
-#define A_SGE_DEEP_SLEEP 0x1128
-
-#define S_IDMA1_SLEEP_STATUS 11
-#define V_IDMA1_SLEEP_STATUS(x) ((x) << S_IDMA1_SLEEP_STATUS)
-#define F_IDMA1_SLEEP_STATUS V_IDMA1_SLEEP_STATUS(1U)
-
-#define S_IDMA0_SLEEP_STATUS 10
-#define V_IDMA0_SLEEP_STATUS(x) ((x) << S_IDMA0_SLEEP_STATUS)
-#define F_IDMA0_SLEEP_STATUS V_IDMA0_SLEEP_STATUS(1U)
-
-#define S_IDMA1_SLEEP_REQ 9
-#define V_IDMA1_SLEEP_REQ(x) ((x) << S_IDMA1_SLEEP_REQ)
-#define F_IDMA1_SLEEP_REQ V_IDMA1_SLEEP_REQ(1U)
-
-#define S_IDMA0_SLEEP_REQ 8
-#define V_IDMA0_SLEEP_REQ(x) ((x) << S_IDMA0_SLEEP_REQ)
-#define F_IDMA0_SLEEP_REQ V_IDMA0_SLEEP_REQ(1U)
-
-#define S_EDMA3_SLEEP_STATUS 7
-#define V_EDMA3_SLEEP_STATUS(x) ((x) << S_EDMA3_SLEEP_STATUS)
-#define F_EDMA3_SLEEP_STATUS V_EDMA3_SLEEP_STATUS(1U)
-
-#define S_EDMA2_SLEEP_STATUS 6
-#define V_EDMA2_SLEEP_STATUS(x) ((x) << S_EDMA2_SLEEP_STATUS)
-#define F_EDMA2_SLEEP_STATUS V_EDMA2_SLEEP_STATUS(1U)
-
-#define S_EDMA1_SLEEP_STATUS 5
-#define V_EDMA1_SLEEP_STATUS(x) ((x) << S_EDMA1_SLEEP_STATUS)
-#define F_EDMA1_SLEEP_STATUS V_EDMA1_SLEEP_STATUS(1U)
-
-#define S_EDMA0_SLEEP_STATUS 4
-#define V_EDMA0_SLEEP_STATUS(x) ((x) << S_EDMA0_SLEEP_STATUS)
-#define F_EDMA0_SLEEP_STATUS V_EDMA0_SLEEP_STATUS(1U)
-
-#define S_EDMA3_SLEEP_REQ 3
-#define V_EDMA3_SLEEP_REQ(x) ((x) << S_EDMA3_SLEEP_REQ)
-#define F_EDMA3_SLEEP_REQ V_EDMA3_SLEEP_REQ(1U)
-
-#define S_EDMA2_SLEEP_REQ 2
-#define V_EDMA2_SLEEP_REQ(x) ((x) << S_EDMA2_SLEEP_REQ)
-#define F_EDMA2_SLEEP_REQ V_EDMA2_SLEEP_REQ(1U)
-
-#define S_EDMA1_SLEEP_REQ 1
-#define V_EDMA1_SLEEP_REQ(x) ((x) << S_EDMA1_SLEEP_REQ)
-#define F_EDMA1_SLEEP_REQ V_EDMA1_SLEEP_REQ(1U)
-
-#define S_EDMA0_SLEEP_REQ 0
-#define V_EDMA0_SLEEP_REQ(x) ((x) << S_EDMA0_SLEEP_REQ)
-#define F_EDMA0_SLEEP_REQ V_EDMA0_SLEEP_REQ(1U)
-
-#define A_SGE_INT_CAUSE6 0x1128
-
-#define S_ERR_DB_SYNC 21
-#define V_ERR_DB_SYNC(x) ((x) << S_ERR_DB_SYNC)
-#define F_ERR_DB_SYNC V_ERR_DB_SYNC(1U)
-
-#define S_ERR_GTS_SYNC 20
-#define V_ERR_GTS_SYNC(x) ((x) << S_ERR_GTS_SYNC)
-#define F_ERR_GTS_SYNC V_ERR_GTS_SYNC(1U)
-
-#define S_FATAL_LARGE_COAL 19
-#define V_FATAL_LARGE_COAL(x) ((x) << S_FATAL_LARGE_COAL)
-#define F_FATAL_LARGE_COAL V_FATAL_LARGE_COAL(1U)
-
-#define S_PL_BAR2_FRM_ERR 18
-#define V_PL_BAR2_FRM_ERR(x) ((x) << S_PL_BAR2_FRM_ERR)
-#define F_PL_BAR2_FRM_ERR V_PL_BAR2_FRM_ERR(1U)
-
-#define S_SILENT_DROP_TX_COAL 17
-#define V_SILENT_DROP_TX_COAL(x) ((x) << S_SILENT_DROP_TX_COAL)
-#define F_SILENT_DROP_TX_COAL V_SILENT_DROP_TX_COAL(1U)
-
-#define S_ERR_INV_CTXT4 16
-#define V_ERR_INV_CTXT4(x) ((x) << S_ERR_INV_CTXT4)
-#define F_ERR_INV_CTXT4 V_ERR_INV_CTXT4(1U)
-
-#define S_ERR_BAD_DB_PIDX4 15
-#define V_ERR_BAD_DB_PIDX4(x) ((x) << S_ERR_BAD_DB_PIDX4)
-#define F_ERR_BAD_DB_PIDX4 V_ERR_BAD_DB_PIDX4(1U)
-
-#define S_ERR_BAD_UPFL_INC_CREDIT4 14
-#define V_ERR_BAD_UPFL_INC_CREDIT4(x) ((x) << S_ERR_BAD_UPFL_INC_CREDIT4)
-#define F_ERR_BAD_UPFL_INC_CREDIT4 V_ERR_BAD_UPFL_INC_CREDIT4(1U)
-
-#define S_FATAL_TAG_MISMATCH 13
-#define V_FATAL_TAG_MISMATCH(x) ((x) << S_FATAL_TAG_MISMATCH)
-#define F_FATAL_TAG_MISMATCH V_FATAL_TAG_MISMATCH(1U)
-
-#define S_FATAL_ENQ_CTL_RDY 12
-#define V_FATAL_ENQ_CTL_RDY(x) ((x) << S_FATAL_ENQ_CTL_RDY)
-#define F_FATAL_ENQ_CTL_RDY V_FATAL_ENQ_CTL_RDY(1U)
-
-#define S_ERR_PC_RSP_LEN3 11
-#define V_ERR_PC_RSP_LEN3(x) ((x) << S_ERR_PC_RSP_LEN3)
-#define F_ERR_PC_RSP_LEN3 V_ERR_PC_RSP_LEN3(1U)
-
-#define S_ERR_PC_RSP_LEN2 10
-#define V_ERR_PC_RSP_LEN2(x) ((x) << S_ERR_PC_RSP_LEN2)
-#define F_ERR_PC_RSP_LEN2 V_ERR_PC_RSP_LEN2(1U)
-
-#define S_ERR_PC_RSP_LEN1 9
-#define V_ERR_PC_RSP_LEN1(x) ((x) << S_ERR_PC_RSP_LEN1)
-#define F_ERR_PC_RSP_LEN1 V_ERR_PC_RSP_LEN1(1U)
-
-#define S_ERR_PC_RSP_LEN0 8
-#define V_ERR_PC_RSP_LEN0(x) ((x) << S_ERR_PC_RSP_LEN0)
-#define F_ERR_PC_RSP_LEN0 V_ERR_PC_RSP_LEN0(1U)
-
-#define S_FATAL_ENQ2LL_VLD 7
-#define V_FATAL_ENQ2LL_VLD(x) ((x) << S_FATAL_ENQ2LL_VLD)
-#define F_FATAL_ENQ2LL_VLD V_FATAL_ENQ2LL_VLD(1U)
-
-#define S_FATAL_LL_EMPTY 6
-#define V_FATAL_LL_EMPTY(x) ((x) << S_FATAL_LL_EMPTY)
-#define F_FATAL_LL_EMPTY V_FATAL_LL_EMPTY(1U)
-
-#define S_FATAL_OFF_WDENQ 5
-#define V_FATAL_OFF_WDENQ(x) ((x) << S_FATAL_OFF_WDENQ)
-#define F_FATAL_OFF_WDENQ V_FATAL_OFF_WDENQ(1U)
-
-#define S_FATAL_DEQ_DRDY 3
-#define M_FATAL_DEQ_DRDY 0x3U
-#define V_FATAL_DEQ_DRDY(x) ((x) << S_FATAL_DEQ_DRDY)
-#define G_FATAL_DEQ_DRDY(x) (((x) >> S_FATAL_DEQ_DRDY) & M_FATAL_DEQ_DRDY)
-
-#define S_FATAL_OUTP_DRDY 1
-#define M_FATAL_OUTP_DRDY 0x3U
-#define V_FATAL_OUTP_DRDY(x) ((x) << S_FATAL_OUTP_DRDY)
-#define G_FATAL_OUTP_DRDY(x) (((x) >> S_FATAL_OUTP_DRDY) & M_FATAL_OUTP_DRDY)
-
-#define S_FATAL_DEQ 0
-#define V_FATAL_DEQ(x) ((x) << S_FATAL_DEQ)
-#define F_FATAL_DEQ V_FATAL_DEQ(1U)
-
-#define A_SGE_DOORBELL_THROTTLE_THRESHOLD 0x112c
-
-#define S_THROTTLE_THRESHOLD_FL 16
-#define M_THROTTLE_THRESHOLD_FL 0xfU
-#define V_THROTTLE_THRESHOLD_FL(x) ((x) << S_THROTTLE_THRESHOLD_FL)
-#define G_THROTTLE_THRESHOLD_FL(x) (((x) >> S_THROTTLE_THRESHOLD_FL) & M_THROTTLE_THRESHOLD_FL)
-
-#define S_THROTTLE_THRESHOLD_HP 12
-#define M_THROTTLE_THRESHOLD_HP 0xfU
-#define V_THROTTLE_THRESHOLD_HP(x) ((x) << S_THROTTLE_THRESHOLD_HP)
-#define G_THROTTLE_THRESHOLD_HP(x) (((x) >> S_THROTTLE_THRESHOLD_HP) & M_THROTTLE_THRESHOLD_HP)
-
-#define S_THROTTLE_THRESHOLD_LP 0
-#define M_THROTTLE_THRESHOLD_LP 0xfffU
-#define V_THROTTLE_THRESHOLD_LP(x) ((x) << S_THROTTLE_THRESHOLD_LP)
-#define G_THROTTLE_THRESHOLD_LP(x) (((x) >> S_THROTTLE_THRESHOLD_LP) & M_THROTTLE_THRESHOLD_LP)
-
-#define A_SGE_INT_ENABLE6 0x112c
-#define A_SGE_DBP_FETCH_THRESHOLD 0x1130
-
-#define S_DBP_FETCH_THRESHOLD_FL 21
-#define M_DBP_FETCH_THRESHOLD_FL 0xfU
-#define V_DBP_FETCH_THRESHOLD_FL(x) ((x) << S_DBP_FETCH_THRESHOLD_FL)
-#define G_DBP_FETCH_THRESHOLD_FL(x) (((x) >> S_DBP_FETCH_THRESHOLD_FL) & M_DBP_FETCH_THRESHOLD_FL)
-
-#define S_DBP_FETCH_THRESHOLD_HP 17
-#define M_DBP_FETCH_THRESHOLD_HP 0xfU
-#define V_DBP_FETCH_THRESHOLD_HP(x) ((x) << S_DBP_FETCH_THRESHOLD_HP)
-#define G_DBP_FETCH_THRESHOLD_HP(x) (((x) >> S_DBP_FETCH_THRESHOLD_HP) & M_DBP_FETCH_THRESHOLD_HP)
-
-#define S_DBP_FETCH_THRESHOLD_LP 5
-#define M_DBP_FETCH_THRESHOLD_LP 0xfffU
-#define V_DBP_FETCH_THRESHOLD_LP(x) ((x) << S_DBP_FETCH_THRESHOLD_LP)
-#define G_DBP_FETCH_THRESHOLD_LP(x) (((x) >> S_DBP_FETCH_THRESHOLD_LP) & M_DBP_FETCH_THRESHOLD_LP)
-
-#define S_DBP_FETCH_THRESHOLD_MODE 4
-#define V_DBP_FETCH_THRESHOLD_MODE(x) ((x) << S_DBP_FETCH_THRESHOLD_MODE)
-#define F_DBP_FETCH_THRESHOLD_MODE V_DBP_FETCH_THRESHOLD_MODE(1U)
-
-#define S_DBP_FETCH_THRESHOLD_EN3 3
-#define V_DBP_FETCH_THRESHOLD_EN3(x) ((x) << S_DBP_FETCH_THRESHOLD_EN3)
-#define F_DBP_FETCH_THRESHOLD_EN3 V_DBP_FETCH_THRESHOLD_EN3(1U)
-
-#define S_DBP_FETCH_THRESHOLD_EN2 2
-#define V_DBP_FETCH_THRESHOLD_EN2(x) ((x) << S_DBP_FETCH_THRESHOLD_EN2)
-#define F_DBP_FETCH_THRESHOLD_EN2 V_DBP_FETCH_THRESHOLD_EN2(1U)
-
-#define S_DBP_FETCH_THRESHOLD_EN1 1
-#define V_DBP_FETCH_THRESHOLD_EN1(x) ((x) << S_DBP_FETCH_THRESHOLD_EN1)
-#define F_DBP_FETCH_THRESHOLD_EN1 V_DBP_FETCH_THRESHOLD_EN1(1U)
-
-#define S_DBP_FETCH_THRESHOLD_EN0 0
-#define V_DBP_FETCH_THRESHOLD_EN0(x) ((x) << S_DBP_FETCH_THRESHOLD_EN0)
-#define F_DBP_FETCH_THRESHOLD_EN0 V_DBP_FETCH_THRESHOLD_EN0(1U)
-
-#define A_SGE_DBP_FETCH_THRESHOLD_QUEUE 0x1134
-
-#define S_DBP_FETCH_THRESHOLD_IQ1 16
-#define M_DBP_FETCH_THRESHOLD_IQ1 0xffffU
-#define V_DBP_FETCH_THRESHOLD_IQ1(x) ((x) << S_DBP_FETCH_THRESHOLD_IQ1)
-#define G_DBP_FETCH_THRESHOLD_IQ1(x) (((x) >> S_DBP_FETCH_THRESHOLD_IQ1) & M_DBP_FETCH_THRESHOLD_IQ1)
-
-#define S_DBP_FETCH_THRESHOLD_IQ0 0
-#define M_DBP_FETCH_THRESHOLD_IQ0 0xffffU
-#define V_DBP_FETCH_THRESHOLD_IQ0(x) ((x) << S_DBP_FETCH_THRESHOLD_IQ0)
-#define G_DBP_FETCH_THRESHOLD_IQ0(x) (((x) >> S_DBP_FETCH_THRESHOLD_IQ0) & M_DBP_FETCH_THRESHOLD_IQ0)
-
-#define A_SGE_DBVFIFO_BADDR 0x1138
-#define A_SGE_DBVFIFO_SIZE 0x113c
-
-#define S_DBVFIFO_SIZE 6
-#define M_DBVFIFO_SIZE 0xfffU
-#define V_DBVFIFO_SIZE(x) ((x) << S_DBVFIFO_SIZE)
-#define G_DBVFIFO_SIZE(x) (((x) >> S_DBVFIFO_SIZE) & M_DBVFIFO_SIZE)
-
-#define S_T6_DBVFIFO_SIZE 0
-#define M_T6_DBVFIFO_SIZE 0x1fffU
-#define V_T6_DBVFIFO_SIZE(x) ((x) << S_T6_DBVFIFO_SIZE)
-#define G_T6_DBVFIFO_SIZE(x) (((x) >> S_T6_DBVFIFO_SIZE) & M_T6_DBVFIFO_SIZE)
-
-#define A_SGE_DBFIFO_STATUS3 0x1140
-
-#define S_LP_PTRS_EQUAL 21
-#define V_LP_PTRS_EQUAL(x) ((x) << S_LP_PTRS_EQUAL)
-#define F_LP_PTRS_EQUAL V_LP_PTRS_EQUAL(1U)
-
-#define S_LP_SNAPHOT 20
-#define V_LP_SNAPHOT(x) ((x) << S_LP_SNAPHOT)
-#define F_LP_SNAPHOT V_LP_SNAPHOT(1U)
-
-#define S_FL_INT_THRESH_LOW 16
-#define M_FL_INT_THRESH_LOW 0xfU
-#define V_FL_INT_THRESH_LOW(x) ((x) << S_FL_INT_THRESH_LOW)
-#define G_FL_INT_THRESH_LOW(x) (((x) >> S_FL_INT_THRESH_LOW) & M_FL_INT_THRESH_LOW)
-
-#define S_HP_INT_THRESH_LOW 12
-#define M_HP_INT_THRESH_LOW 0xfU
-#define V_HP_INT_THRESH_LOW(x) ((x) << S_HP_INT_THRESH_LOW)
-#define G_HP_INT_THRESH_LOW(x) (((x) >> S_HP_INT_THRESH_LOW) & M_HP_INT_THRESH_LOW)
-
-#define S_LP_INT_THRESH_LOW 0
-#define M_LP_INT_THRESH_LOW 0xfffU
-#define V_LP_INT_THRESH_LOW(x) ((x) << S_LP_INT_THRESH_LOW)
-#define G_LP_INT_THRESH_LOW(x) (((x) >> S_LP_INT_THRESH_LOW) & M_LP_INT_THRESH_LOW)
-
-#define A_SGE_CHANGESET 0x1144
-#define A_SGE_PC_RSP_ERROR 0x1148
-#define A_SGE_TBUF_CONTROL 0x114c
-
-#define S_DBPTBUFRSV1 9
-#define M_DBPTBUFRSV1 0x1ffU
-#define V_DBPTBUFRSV1(x) ((x) << S_DBPTBUFRSV1)
-#define G_DBPTBUFRSV1(x) (((x) >> S_DBPTBUFRSV1) & M_DBPTBUFRSV1)
-
-#define S_DBPTBUFRSV0 0
-#define M_DBPTBUFRSV0 0x1ffU
-#define V_DBPTBUFRSV0(x) ((x) << S_DBPTBUFRSV0)
-#define G_DBPTBUFRSV0(x) (((x) >> S_DBPTBUFRSV0) & M_DBPTBUFRSV0)
-
-#define A_SGE_PC0_REQ_BIST_CMD 0x1180
-#define A_SGE_PC0_REQ_BIST_ERROR_CNT 0x1184
-#define A_SGE_PC1_REQ_BIST_CMD 0x1190
-#define A_SGE_PC1_REQ_BIST_ERROR_CNT 0x1194
-#define A_SGE_PC0_RSP_BIST_CMD 0x11a0
-#define A_SGE_PC0_RSP_BIST_ERROR_CNT 0x11a4
-#define A_SGE_PC1_RSP_BIST_CMD 0x11b0
-#define A_SGE_PC1_RSP_BIST_ERROR_CNT 0x11b4
-#define A_SGE_CTXT_CMD 0x11fc
-
-#define S_BUSY 31
-#define V_BUSY(x) ((x) << S_BUSY)
-#define F_BUSY V_BUSY(1U)
-
-#define S_CTXTOP 28
-#define M_CTXTOP 0x3U
-#define V_CTXTOP(x) ((x) << S_CTXTOP)
-#define G_CTXTOP(x) (((x) >> S_CTXTOP) & M_CTXTOP)
-
-#define S_CTXTTYPE 24
-#define M_CTXTTYPE 0x3U
-#define V_CTXTTYPE(x) ((x) << S_CTXTTYPE)
-#define G_CTXTTYPE(x) (((x) >> S_CTXTTYPE) & M_CTXTTYPE)
-
-#define S_CTXTQID 0
-#define M_CTXTQID 0x1ffffU
-#define V_CTXTQID(x) ((x) << S_CTXTQID)
-#define G_CTXTQID(x) (((x) >> S_CTXTQID) & M_CTXTQID)
-
-#define A_SGE_CTXT_DATA0 0x1200
-#define A_SGE_CTXT_DATA1 0x1204
-#define A_SGE_CTXT_DATA2 0x1208
-#define A_SGE_CTXT_DATA3 0x120c
-#define A_SGE_CTXT_DATA4 0x1210
-#define A_SGE_CTXT_DATA5 0x1214
-#define A_SGE_CTXT_DATA6 0x1218
-#define A_SGE_CTXT_DATA7 0x121c
-#define A_SGE_CTXT_MASK0 0x1220
-#define A_SGE_CTXT_MASK1 0x1224
-#define A_SGE_CTXT_MASK2 0x1228
-#define A_SGE_CTXT_MASK3 0x122c
-#define A_SGE_CTXT_MASK4 0x1230
-#define A_SGE_CTXT_MASK5 0x1234
-#define A_SGE_CTXT_MASK6 0x1238
-#define A_SGE_CTXT_MASK7 0x123c
-#define A_SGE_QBASE_MAP0 0x1240
-
-#define S_EGRESS0_SIZE 24
-#define M_EGRESS0_SIZE 0x1fU
-#define V_EGRESS0_SIZE(x) ((x) << S_EGRESS0_SIZE)
-#define G_EGRESS0_SIZE(x) (((x) >> S_EGRESS0_SIZE) & M_EGRESS0_SIZE)
-
-#define S_EGRESS1_SIZE 16
-#define M_EGRESS1_SIZE 0x1fU
-#define V_EGRESS1_SIZE(x) ((x) << S_EGRESS1_SIZE)
-#define G_EGRESS1_SIZE(x) (((x) >> S_EGRESS1_SIZE) & M_EGRESS1_SIZE)
-
-#define S_INGRESS0_SIZE 8
-#define M_INGRESS0_SIZE 0x1fU
-#define V_INGRESS0_SIZE(x) ((x) << S_INGRESS0_SIZE)
-#define G_INGRESS0_SIZE(x) (((x) >> S_INGRESS0_SIZE) & M_INGRESS0_SIZE)
-
-#define A_SGE_QBASE_MAP1 0x1244
-
-#define S_EGRESS0_BASE 0
-#define M_EGRESS0_BASE 0x1ffffU
-#define V_EGRESS0_BASE(x) ((x) << S_EGRESS0_BASE)
-#define G_EGRESS0_BASE(x) (((x) >> S_EGRESS0_BASE) & M_EGRESS0_BASE)
-
-#define A_SGE_QBASE_MAP2 0x1248
-
-#define S_EGRESS1_BASE 0
-#define M_EGRESS1_BASE 0x1ffffU
-#define V_EGRESS1_BASE(x) ((x) << S_EGRESS1_BASE)
-#define G_EGRESS1_BASE(x) (((x) >> S_EGRESS1_BASE) & M_EGRESS1_BASE)
-
-#define A_SGE_QBASE_MAP3 0x124c
-
-#define S_INGRESS1_BASE_256VF 16
-#define M_INGRESS1_BASE_256VF 0xffffU
-#define V_INGRESS1_BASE_256VF(x) ((x) << S_INGRESS1_BASE_256VF)
-#define G_INGRESS1_BASE_256VF(x) (((x) >> S_INGRESS1_BASE_256VF) & M_INGRESS1_BASE_256VF)
-
-#define S_INGRESS0_BASE 0
-#define M_INGRESS0_BASE 0xffffU
-#define V_INGRESS0_BASE(x) ((x) << S_INGRESS0_BASE)
-#define G_INGRESS0_BASE(x) (((x) >> S_INGRESS0_BASE) & M_INGRESS0_BASE)
-
-#define A_SGE_QBASE_INDEX 0x1250
-
-#define S_QIDX 0
-#define M_QIDX 0x1ffU
-#define V_QIDX(x) ((x) << S_QIDX)
-#define G_QIDX(x) (((x) >> S_QIDX) & M_QIDX)
-
-#define A_SGE_CONM_CTRL2 0x1254
-
-#define S_FLMTHRESHPACK 8
-#define M_FLMTHRESHPACK 0x7fU
-#define V_FLMTHRESHPACK(x) ((x) << S_FLMTHRESHPACK)
-#define G_FLMTHRESHPACK(x) (((x) >> S_FLMTHRESHPACK) & M_FLMTHRESHPACK)
-
-#define S_FLMTHRESH 0
-#define M_FLMTHRESH 0x7fU
-#define V_FLMTHRESH(x) ((x) << S_FLMTHRESH)
-#define G_FLMTHRESH(x) (((x) >> S_FLMTHRESH) & M_FLMTHRESH)
-
-#define A_SGE_DEBUG_CONM 0x1258
-
-#define S_MPS_CH_CNG 16
-#define M_MPS_CH_CNG 0xffffU
-#define V_MPS_CH_CNG(x) ((x) << S_MPS_CH_CNG)
-#define G_MPS_CH_CNG(x) (((x) >> S_MPS_CH_CNG) & M_MPS_CH_CNG)
-
-#define S_TP_CH_CNG 14
-#define M_TP_CH_CNG 0x3U
-#define V_TP_CH_CNG(x) ((x) << S_TP_CH_CNG)
-#define G_TP_CH_CNG(x) (((x) >> S_TP_CH_CNG) & M_TP_CH_CNG)
-
-#define S_ST_CONG 12
-#define M_ST_CONG 0x3U
-#define V_ST_CONG(x) ((x) << S_ST_CONG)
-#define G_ST_CONG(x) (((x) >> S_ST_CONG) & M_ST_CONG)
-
-#define S_LAST_XOFF 10
-#define V_LAST_XOFF(x) ((x) << S_LAST_XOFF)
-#define F_LAST_XOFF V_LAST_XOFF(1U)
-
-#define S_LAST_QID 0
-#define M_LAST_QID 0x3ffU
-#define V_LAST_QID(x) ((x) << S_LAST_QID)
-#define G_LAST_QID(x) (((x) >> S_LAST_QID) & M_LAST_QID)
-
-#define A_SGE_DBG_QUEUE_STAT0_CTRL 0x125c
-
-#define S_IMSG_GTS_SEL 18
-#define V_IMSG_GTS_SEL(x) ((x) << S_IMSG_GTS_SEL)
-#define F_IMSG_GTS_SEL V_IMSG_GTS_SEL(1U)
-
-#define S_MGT_SEL 17
-#define V_MGT_SEL(x) ((x) << S_MGT_SEL)
-#define F_MGT_SEL V_MGT_SEL(1U)
-
-#define S_DB_GTS_QID 0
-#define M_DB_GTS_QID 0x1ffffU
-#define V_DB_GTS_QID(x) ((x) << S_DB_GTS_QID)
-#define G_DB_GTS_QID(x) (((x) >> S_DB_GTS_QID) & M_DB_GTS_QID)
-
-#define A_SGE_DBG_QUEUE_STAT1_CTRL 0x1260
-#define A_SGE_DBG_QUEUE_STAT0 0x1264
-#define A_SGE_DBG_QUEUE_STAT1 0x1268
-#define A_SGE_DBG_BAR2_PKT_CNT 0x126c
-#define A_SGE_DBG_DB_PKT_CNT 0x1270
-#define A_SGE_DBG_GTS_PKT_CNT 0x1274
-#define A_SGE_DEBUG_DATA_HIGH_INDEX_0 0x1280
-
-#define S_CIM_WM 24
-#define M_CIM_WM 0x3U
-#define V_CIM_WM(x) ((x) << S_CIM_WM)
-#define G_CIM_WM(x) (((x) >> S_CIM_WM) & M_CIM_WM)
-
-#define S_DEBUG_UP_SOP_CNT 20
-#define M_DEBUG_UP_SOP_CNT 0xfU
-#define V_DEBUG_UP_SOP_CNT(x) ((x) << S_DEBUG_UP_SOP_CNT)
-#define G_DEBUG_UP_SOP_CNT(x) (((x) >> S_DEBUG_UP_SOP_CNT) & M_DEBUG_UP_SOP_CNT)
-
-#define S_DEBUG_UP_EOP_CNT 16
-#define M_DEBUG_UP_EOP_CNT 0xfU
-#define V_DEBUG_UP_EOP_CNT(x) ((x) << S_DEBUG_UP_EOP_CNT)
-#define G_DEBUG_UP_EOP_CNT(x) (((x) >> S_DEBUG_UP_EOP_CNT) & M_DEBUG_UP_EOP_CNT)
-
-#define S_DEBUG_CIM_SOP1_CNT 12
-#define M_DEBUG_CIM_SOP1_CNT 0xfU
-#define V_DEBUG_CIM_SOP1_CNT(x) ((x) << S_DEBUG_CIM_SOP1_CNT)
-#define G_DEBUG_CIM_SOP1_CNT(x) (((x) >> S_DEBUG_CIM_SOP1_CNT) & M_DEBUG_CIM_SOP1_CNT)
-
-#define S_DEBUG_CIM_EOP1_CNT 8
-#define M_DEBUG_CIM_EOP1_CNT 0xfU
-#define V_DEBUG_CIM_EOP1_CNT(x) ((x) << S_DEBUG_CIM_EOP1_CNT)
-#define G_DEBUG_CIM_EOP1_CNT(x) (((x) >> S_DEBUG_CIM_EOP1_CNT) & M_DEBUG_CIM_EOP1_CNT)
-
-#define S_DEBUG_CIM_SOP0_CNT 4
-#define M_DEBUG_CIM_SOP0_CNT 0xfU
-#define V_DEBUG_CIM_SOP0_CNT(x) ((x) << S_DEBUG_CIM_SOP0_CNT)
-#define G_DEBUG_CIM_SOP0_CNT(x) (((x) >> S_DEBUG_CIM_SOP0_CNT) & M_DEBUG_CIM_SOP0_CNT)
-
-#define S_DEBUG_CIM_EOP0_CNT 0
-#define M_DEBUG_CIM_EOP0_CNT 0xfU
-#define V_DEBUG_CIM_EOP0_CNT(x) ((x) << S_DEBUG_CIM_EOP0_CNT)
-#define G_DEBUG_CIM_EOP0_CNT(x) (((x) >> S_DEBUG_CIM_EOP0_CNT) & M_DEBUG_CIM_EOP0_CNT)
-
-#define S_DEBUG_BAR2_SOP_CNT 28
-#define M_DEBUG_BAR2_SOP_CNT 0xfU
-#define V_DEBUG_BAR2_SOP_CNT(x) ((x) << S_DEBUG_BAR2_SOP_CNT)
-#define G_DEBUG_BAR2_SOP_CNT(x) (((x) >> S_DEBUG_BAR2_SOP_CNT) & M_DEBUG_BAR2_SOP_CNT)
-
-#define S_DEBUG_BAR2_EOP_CNT 24
-#define M_DEBUG_BAR2_EOP_CNT 0xfU
-#define V_DEBUG_BAR2_EOP_CNT(x) ((x) << S_DEBUG_BAR2_EOP_CNT)
-#define G_DEBUG_BAR2_EOP_CNT(x) (((x) >> S_DEBUG_BAR2_EOP_CNT) & M_DEBUG_BAR2_EOP_CNT)
-
-#define A_SGE_DEBUG_DATA_HIGH_INDEX_1 0x1284
-
-#define S_DEBUG_T_RX_SOP1_CNT 28
-#define M_DEBUG_T_RX_SOP1_CNT 0xfU
-#define V_DEBUG_T_RX_SOP1_CNT(x) ((x) << S_DEBUG_T_RX_SOP1_CNT)
-#define G_DEBUG_T_RX_SOP1_CNT(x) (((x) >> S_DEBUG_T_RX_SOP1_CNT) & M_DEBUG_T_RX_SOP1_CNT)
-
-#define S_DEBUG_T_RX_EOP1_CNT 24
-#define M_DEBUG_T_RX_EOP1_CNT 0xfU
-#define V_DEBUG_T_RX_EOP1_CNT(x) ((x) << S_DEBUG_T_RX_EOP1_CNT)
-#define G_DEBUG_T_RX_EOP1_CNT(x) (((x) >> S_DEBUG_T_RX_EOP1_CNT) & M_DEBUG_T_RX_EOP1_CNT)
-
-#define S_DEBUG_T_RX_SOP0_CNT 20
-#define M_DEBUG_T_RX_SOP0_CNT 0xfU
-#define V_DEBUG_T_RX_SOP0_CNT(x) ((x) << S_DEBUG_T_RX_SOP0_CNT)
-#define G_DEBUG_T_RX_SOP0_CNT(x) (((x) >> S_DEBUG_T_RX_SOP0_CNT) & M_DEBUG_T_RX_SOP0_CNT)
-
-#define S_DEBUG_T_RX_EOP0_CNT 16
-#define M_DEBUG_T_RX_EOP0_CNT 0xfU
-#define V_DEBUG_T_RX_EOP0_CNT(x) ((x) << S_DEBUG_T_RX_EOP0_CNT)
-#define G_DEBUG_T_RX_EOP0_CNT(x) (((x) >> S_DEBUG_T_RX_EOP0_CNT) & M_DEBUG_T_RX_EOP0_CNT)
-
-#define S_DEBUG_U_RX_SOP1_CNT 12
-#define M_DEBUG_U_RX_SOP1_CNT 0xfU
-#define V_DEBUG_U_RX_SOP1_CNT(x) ((x) << S_DEBUG_U_RX_SOP1_CNT)
-#define G_DEBUG_U_RX_SOP1_CNT(x) (((x) >> S_DEBUG_U_RX_SOP1_CNT) & M_DEBUG_U_RX_SOP1_CNT)
-
-#define S_DEBUG_U_RX_EOP1_CNT 8
-#define M_DEBUG_U_RX_EOP1_CNT 0xfU
-#define V_DEBUG_U_RX_EOP1_CNT(x) ((x) << S_DEBUG_U_RX_EOP1_CNT)
-#define G_DEBUG_U_RX_EOP1_CNT(x) (((x) >> S_DEBUG_U_RX_EOP1_CNT) & M_DEBUG_U_RX_EOP1_CNT)
-
-#define S_DEBUG_U_RX_SOP0_CNT 4
-#define M_DEBUG_U_RX_SOP0_CNT 0xfU
-#define V_DEBUG_U_RX_SOP0_CNT(x) ((x) << S_DEBUG_U_RX_SOP0_CNT)
-#define G_DEBUG_U_RX_SOP0_CNT(x) (((x) >> S_DEBUG_U_RX_SOP0_CNT) & M_DEBUG_U_RX_SOP0_CNT)
-
-#define S_DEBUG_U_RX_EOP0_CNT 0
-#define M_DEBUG_U_RX_EOP0_CNT 0xfU
-#define V_DEBUG_U_RX_EOP0_CNT(x) ((x) << S_DEBUG_U_RX_EOP0_CNT)
-#define G_DEBUG_U_RX_EOP0_CNT(x) (((x) >> S_DEBUG_U_RX_EOP0_CNT) & M_DEBUG_U_RX_EOP0_CNT)
-
-#define A_SGE_DEBUG_DATA_HIGH_INDEX_2 0x1288
-
-#define S_DEBUG_UD_RX_SOP3_CNT 28
-#define M_DEBUG_UD_RX_SOP3_CNT 0xfU
-#define V_DEBUG_UD_RX_SOP3_CNT(x) ((x) << S_DEBUG_UD_RX_SOP3_CNT)
-#define G_DEBUG_UD_RX_SOP3_CNT(x) (((x) >> S_DEBUG_UD_RX_SOP3_CNT) & M_DEBUG_UD_RX_SOP3_CNT)
-
-#define S_DEBUG_UD_RX_EOP3_CNT 24
-#define M_DEBUG_UD_RX_EOP3_CNT 0xfU
-#define V_DEBUG_UD_RX_EOP3_CNT(x) ((x) << S_DEBUG_UD_RX_EOP3_CNT)
-#define G_DEBUG_UD_RX_EOP3_CNT(x) (((x) >> S_DEBUG_UD_RX_EOP3_CNT) & M_DEBUG_UD_RX_EOP3_CNT)
-
-#define S_DEBUG_UD_RX_SOP2_CNT 20
-#define M_DEBUG_UD_RX_SOP2_CNT 0xfU
-#define V_DEBUG_UD_RX_SOP2_CNT(x) ((x) << S_DEBUG_UD_RX_SOP2_CNT)
-#define G_DEBUG_UD_RX_SOP2_CNT(x) (((x) >> S_DEBUG_UD_RX_SOP2_CNT) & M_DEBUG_UD_RX_SOP2_CNT)
-
-#define S_DEBUG_UD_RX_EOP2_CNT 16
-#define M_DEBUG_UD_RX_EOP2_CNT 0xfU
-#define V_DEBUG_UD_RX_EOP2_CNT(x) ((x) << S_DEBUG_UD_RX_EOP2_CNT)
-#define G_DEBUG_UD_RX_EOP2_CNT(x) (((x) >> S_DEBUG_UD_RX_EOP2_CNT) & M_DEBUG_UD_RX_EOP2_CNT)
-
-#define S_DEBUG_UD_RX_SOP1_CNT 12
-#define M_DEBUG_UD_RX_SOP1_CNT 0xfU
-#define V_DEBUG_UD_RX_SOP1_CNT(x) ((x) << S_DEBUG_UD_RX_SOP1_CNT)
-#define G_DEBUG_UD_RX_SOP1_CNT(x) (((x) >> S_DEBUG_UD_RX_SOP1_CNT) & M_DEBUG_UD_RX_SOP1_CNT)
-
-#define S_DEBUG_UD_RX_EOP1_CNT 8
-#define M_DEBUG_UD_RX_EOP1_CNT 0xfU
-#define V_DEBUG_UD_RX_EOP1_CNT(x) ((x) << S_DEBUG_UD_RX_EOP1_CNT)
-#define G_DEBUG_UD_RX_EOP1_CNT(x) (((x) >> S_DEBUG_UD_RX_EOP1_CNT) & M_DEBUG_UD_RX_EOP1_CNT)
-
-#define S_DEBUG_UD_RX_SOP0_CNT 4
-#define M_DEBUG_UD_RX_SOP0_CNT 0xfU
-#define V_DEBUG_UD_RX_SOP0_CNT(x) ((x) << S_DEBUG_UD_RX_SOP0_CNT)
-#define G_DEBUG_UD_RX_SOP0_CNT(x) (((x) >> S_DEBUG_UD_RX_SOP0_CNT) & M_DEBUG_UD_RX_SOP0_CNT)
-
-#define S_DEBUG_UD_RX_EOP0_CNT 0
-#define M_DEBUG_UD_RX_EOP0_CNT 0xfU
-#define V_DEBUG_UD_RX_EOP0_CNT(x) ((x) << S_DEBUG_UD_RX_EOP0_CNT)
-#define G_DEBUG_UD_RX_EOP0_CNT(x) (((x) >> S_DEBUG_UD_RX_EOP0_CNT) & M_DEBUG_UD_RX_EOP0_CNT)
-
-#define S_DBG_TBUF_USED1 9
-#define M_DBG_TBUF_USED1 0x1ffU
-#define V_DBG_TBUF_USED1(x) ((x) << S_DBG_TBUF_USED1)
-#define G_DBG_TBUF_USED1(x) (((x) >> S_DBG_TBUF_USED1) & M_DBG_TBUF_USED1)
-
-#define S_DBG_TBUF_USED0 0
-#define M_DBG_TBUF_USED0 0x1ffU
-#define V_DBG_TBUF_USED0(x) ((x) << S_DBG_TBUF_USED0)
-#define G_DBG_TBUF_USED0(x) (((x) >> S_DBG_TBUF_USED0) & M_DBG_TBUF_USED0)
-
-#define A_SGE_DEBUG_DATA_HIGH_INDEX_3 0x128c
-
-#define S_DEBUG_U_TX_SOP3_CNT 28
-#define M_DEBUG_U_TX_SOP3_CNT 0xfU
-#define V_DEBUG_U_TX_SOP3_CNT(x) ((x) << S_DEBUG_U_TX_SOP3_CNT)
-#define G_DEBUG_U_TX_SOP3_CNT(x) (((x) >> S_DEBUG_U_TX_SOP3_CNT) & M_DEBUG_U_TX_SOP3_CNT)
-
-#define S_DEBUG_U_TX_EOP3_CNT 24
-#define M_DEBUG_U_TX_EOP3_CNT 0xfU
-#define V_DEBUG_U_TX_EOP3_CNT(x) ((x) << S_DEBUG_U_TX_EOP3_CNT)
-#define G_DEBUG_U_TX_EOP3_CNT(x) (((x) >> S_DEBUG_U_TX_EOP3_CNT) & M_DEBUG_U_TX_EOP3_CNT)
-
-#define S_DEBUG_U_TX_SOP2_CNT 20
-#define M_DEBUG_U_TX_SOP2_CNT 0xfU
-#define V_DEBUG_U_TX_SOP2_CNT(x) ((x) << S_DEBUG_U_TX_SOP2_CNT)
-#define G_DEBUG_U_TX_SOP2_CNT(x) (((x) >> S_DEBUG_U_TX_SOP2_CNT) & M_DEBUG_U_TX_SOP2_CNT)
-
-#define S_DEBUG_U_TX_EOP2_CNT 16
-#define M_DEBUG_U_TX_EOP2_CNT 0xfU
-#define V_DEBUG_U_TX_EOP2_CNT(x) ((x) << S_DEBUG_U_TX_EOP2_CNT)
-#define G_DEBUG_U_TX_EOP2_CNT(x) (((x) >> S_DEBUG_U_TX_EOP2_CNT) & M_DEBUG_U_TX_EOP2_CNT)
-
-#define S_DEBUG_U_TX_SOP1_CNT 12
-#define M_DEBUG_U_TX_SOP1_CNT 0xfU
-#define V_DEBUG_U_TX_SOP1_CNT(x) ((x) << S_DEBUG_U_TX_SOP1_CNT)
-#define G_DEBUG_U_TX_SOP1_CNT(x) (((x) >> S_DEBUG_U_TX_SOP1_CNT) & M_DEBUG_U_TX_SOP1_CNT)
-
-#define S_DEBUG_U_TX_EOP1_CNT 8
-#define M_DEBUG_U_TX_EOP1_CNT 0xfU
-#define V_DEBUG_U_TX_EOP1_CNT(x) ((x) << S_DEBUG_U_TX_EOP1_CNT)
-#define G_DEBUG_U_TX_EOP1_CNT(x) (((x) >> S_DEBUG_U_TX_EOP1_CNT) & M_DEBUG_U_TX_EOP1_CNT)
-
-#define S_DEBUG_U_TX_SOP0_CNT 4
-#define M_DEBUG_U_TX_SOP0_CNT 0xfU
-#define V_DEBUG_U_TX_SOP0_CNT(x) ((x) << S_DEBUG_U_TX_SOP0_CNT)
-#define G_DEBUG_U_TX_SOP0_CNT(x) (((x) >> S_DEBUG_U_TX_SOP0_CNT) & M_DEBUG_U_TX_SOP0_CNT)
-
-#define S_DEBUG_U_TX_EOP0_CNT 0
-#define M_DEBUG_U_TX_EOP0_CNT 0xfU
-#define V_DEBUG_U_TX_EOP0_CNT(x) ((x) << S_DEBUG_U_TX_EOP0_CNT)
-#define G_DEBUG_U_TX_EOP0_CNT(x) (((x) >> S_DEBUG_U_TX_EOP0_CNT) & M_DEBUG_U_TX_EOP0_CNT)
-
-#define A_SGE_DEBUG1_DBP_THREAD 0x128c
-
-#define S_WR_DEQ_CNT 12
-#define M_WR_DEQ_CNT 0xfU
-#define V_WR_DEQ_CNT(x) ((x) << S_WR_DEQ_CNT)
-#define G_WR_DEQ_CNT(x) (((x) >> S_WR_DEQ_CNT) & M_WR_DEQ_CNT)
-
-#define S_WR_ENQ_CNT 8
-#define M_WR_ENQ_CNT 0xfU
-#define V_WR_ENQ_CNT(x) ((x) << S_WR_ENQ_CNT)
-#define G_WR_ENQ_CNT(x) (((x) >> S_WR_ENQ_CNT) & M_WR_ENQ_CNT)
-
-#define S_FL_DEQ_CNT 4
-#define M_FL_DEQ_CNT 0xfU
-#define V_FL_DEQ_CNT(x) ((x) << S_FL_DEQ_CNT)
-#define G_FL_DEQ_CNT(x) (((x) >> S_FL_DEQ_CNT) & M_FL_DEQ_CNT)
-
-#define S_FL_ENQ_CNT 0
-#define M_FL_ENQ_CNT 0xfU
-#define V_FL_ENQ_CNT(x) ((x) << S_FL_ENQ_CNT)
-#define G_FL_ENQ_CNT(x) (((x) >> S_FL_ENQ_CNT) & M_FL_ENQ_CNT)
-
-#define A_SGE_DEBUG_DATA_HIGH_INDEX_4 0x1290
-
-#define S_DEBUG_PC_RSP_SOP1_CNT 28
-#define M_DEBUG_PC_RSP_SOP1_CNT 0xfU
-#define V_DEBUG_PC_RSP_SOP1_CNT(x) ((x) << S_DEBUG_PC_RSP_SOP1_CNT)
-#define G_DEBUG_PC_RSP_SOP1_CNT(x) (((x) >> S_DEBUG_PC_RSP_SOP1_CNT) & M_DEBUG_PC_RSP_SOP1_CNT)
-
-#define S_DEBUG_PC_RSP_EOP1_CNT 24
-#define M_DEBUG_PC_RSP_EOP1_CNT 0xfU
-#define V_DEBUG_PC_RSP_EOP1_CNT(x) ((x) << S_DEBUG_PC_RSP_EOP1_CNT)
-#define G_DEBUG_PC_RSP_EOP1_CNT(x) (((x) >> S_DEBUG_PC_RSP_EOP1_CNT) & M_DEBUG_PC_RSP_EOP1_CNT)
-
-#define S_DEBUG_PC_RSP_SOP0_CNT 20
-#define M_DEBUG_PC_RSP_SOP0_CNT 0xfU
-#define V_DEBUG_PC_RSP_SOP0_CNT(x) ((x) << S_DEBUG_PC_RSP_SOP0_CNT)
-#define G_DEBUG_PC_RSP_SOP0_CNT(x) (((x) >> S_DEBUG_PC_RSP_SOP0_CNT) & M_DEBUG_PC_RSP_SOP0_CNT)
-
-#define S_DEBUG_PC_RSP_EOP0_CNT 16
-#define M_DEBUG_PC_RSP_EOP0_CNT 0xfU
-#define V_DEBUG_PC_RSP_EOP0_CNT(x) ((x) << S_DEBUG_PC_RSP_EOP0_CNT)
-#define G_DEBUG_PC_RSP_EOP0_CNT(x) (((x) >> S_DEBUG_PC_RSP_EOP0_CNT) & M_DEBUG_PC_RSP_EOP0_CNT)
-
-#define S_DEBUG_PC_REQ_SOP1_CNT 12
-#define M_DEBUG_PC_REQ_SOP1_CNT 0xfU
-#define V_DEBUG_PC_REQ_SOP1_CNT(x) ((x) << S_DEBUG_PC_REQ_SOP1_CNT)
-#define G_DEBUG_PC_REQ_SOP1_CNT(x) (((x) >> S_DEBUG_PC_REQ_SOP1_CNT) & M_DEBUG_PC_REQ_SOP1_CNT)
-
-#define S_DEBUG_PC_REQ_EOP1_CNT 8
-#define M_DEBUG_PC_REQ_EOP1_CNT 0xfU
-#define V_DEBUG_PC_REQ_EOP1_CNT(x) ((x) << S_DEBUG_PC_REQ_EOP1_CNT)
-#define G_DEBUG_PC_REQ_EOP1_CNT(x) (((x) >> S_DEBUG_PC_REQ_EOP1_CNT) & M_DEBUG_PC_REQ_EOP1_CNT)
-
-#define S_DEBUG_PC_REQ_SOP0_CNT 4
-#define M_DEBUG_PC_REQ_SOP0_CNT 0xfU
-#define V_DEBUG_PC_REQ_SOP0_CNT(x) ((x) << S_DEBUG_PC_REQ_SOP0_CNT)
-#define G_DEBUG_PC_REQ_SOP0_CNT(x) (((x) >> S_DEBUG_PC_REQ_SOP0_CNT) & M_DEBUG_PC_REQ_SOP0_CNT)
-
-#define S_DEBUG_PC_REQ_EOP0_CNT 0
-#define M_DEBUG_PC_REQ_EOP0_CNT 0xfU
-#define V_DEBUG_PC_REQ_EOP0_CNT(x) ((x) << S_DEBUG_PC_REQ_EOP0_CNT)
-#define G_DEBUG_PC_REQ_EOP0_CNT(x) (((x) >> S_DEBUG_PC_REQ_EOP0_CNT) & M_DEBUG_PC_REQ_EOP0_CNT)
-
-#define A_SGE_DEBUG_DATA_HIGH_INDEX_5 0x1294
-
-#define S_DEBUG_PD_RDREQ_SOP3_CNT 28
-#define M_DEBUG_PD_RDREQ_SOP3_CNT 0xfU
-#define V_DEBUG_PD_RDREQ_SOP3_CNT(x) ((x) << S_DEBUG_PD_RDREQ_SOP3_CNT)
-#define G_DEBUG_PD_RDREQ_SOP3_CNT(x) (((x) >> S_DEBUG_PD_RDREQ_SOP3_CNT) & M_DEBUG_PD_RDREQ_SOP3_CNT)
-
-#define S_DEBUG_PD_RDREQ_EOP3_CNT 24
-#define M_DEBUG_PD_RDREQ_EOP3_CNT 0xfU
-#define V_DEBUG_PD_RDREQ_EOP3_CNT(x) ((x) << S_DEBUG_PD_RDREQ_EOP3_CNT)
-#define G_DEBUG_PD_RDREQ_EOP3_CNT(x) (((x) >> S_DEBUG_PD_RDREQ_EOP3_CNT) & M_DEBUG_PD_RDREQ_EOP3_CNT)
-
-#define S_DEBUG_PD_RDREQ_SOP2_CNT 20
-#define M_DEBUG_PD_RDREQ_SOP2_CNT 0xfU
-#define V_DEBUG_PD_RDREQ_SOP2_CNT(x) ((x) << S_DEBUG_PD_RDREQ_SOP2_CNT)
-#define G_DEBUG_PD_RDREQ_SOP2_CNT(x) (((x) >> S_DEBUG_PD_RDREQ_SOP2_CNT) & M_DEBUG_PD_RDREQ_SOP2_CNT)
-
-#define S_DEBUG_PD_RDREQ_EOP2_CNT 16
-#define M_DEBUG_PD_RDREQ_EOP2_CNT 0xfU
-#define V_DEBUG_PD_RDREQ_EOP2_CNT(x) ((x) << S_DEBUG_PD_RDREQ_EOP2_CNT)
-#define G_DEBUG_PD_RDREQ_EOP2_CNT(x) (((x) >> S_DEBUG_PD_RDREQ_EOP2_CNT) & M_DEBUG_PD_RDREQ_EOP2_CNT)
-
-#define S_DEBUG_PD_RDREQ_SOP1_CNT 12
-#define M_DEBUG_PD_RDREQ_SOP1_CNT 0xfU
-#define V_DEBUG_PD_RDREQ_SOP1_CNT(x) ((x) << S_DEBUG_PD_RDREQ_SOP1_CNT)
-#define G_DEBUG_PD_RDREQ_SOP1_CNT(x) (((x) >> S_DEBUG_PD_RDREQ_SOP1_CNT) & M_DEBUG_PD_RDREQ_SOP1_CNT)
-
-#define S_DEBUG_PD_RDREQ_EOP1_CNT 8
-#define M_DEBUG_PD_RDREQ_EOP1_CNT 0xfU
-#define V_DEBUG_PD_RDREQ_EOP1_CNT(x) ((x) << S_DEBUG_PD_RDREQ_EOP1_CNT)
-#define G_DEBUG_PD_RDREQ_EOP1_CNT(x) (((x) >> S_DEBUG_PD_RDREQ_EOP1_CNT) & M_DEBUG_PD_RDREQ_EOP1_CNT)
-
-#define S_DEBUG_PD_RDREQ_SOP0_CNT 4
-#define M_DEBUG_PD_RDREQ_SOP0_CNT 0xfU
-#define V_DEBUG_PD_RDREQ_SOP0_CNT(x) ((x) << S_DEBUG_PD_RDREQ_SOP0_CNT)
-#define G_DEBUG_PD_RDREQ_SOP0_CNT(x) (((x) >> S_DEBUG_PD_RDREQ_SOP0_CNT) & M_DEBUG_PD_RDREQ_SOP0_CNT)
-
-#define S_DEBUG_PD_RDREQ_EOP0_CNT 0
-#define M_DEBUG_PD_RDREQ_EOP0_CNT 0xfU
-#define V_DEBUG_PD_RDREQ_EOP0_CNT(x) ((x) << S_DEBUG_PD_RDREQ_EOP0_CNT)
-#define G_DEBUG_PD_RDREQ_EOP0_CNT(x) (((x) >> S_DEBUG_PD_RDREQ_EOP0_CNT) & M_DEBUG_PD_RDREQ_EOP0_CNT)
-
-#define A_SGE_DEBUG_DATA_HIGH_INDEX_6 0x1298
-
-#define S_DEBUG_PD_RDRSP_SOP3_CNT 28
-#define M_DEBUG_PD_RDRSP_SOP3_CNT 0xfU
-#define V_DEBUG_PD_RDRSP_SOP3_CNT(x) ((x) << S_DEBUG_PD_RDRSP_SOP3_CNT)
-#define G_DEBUG_PD_RDRSP_SOP3_CNT(x) (((x) >> S_DEBUG_PD_RDRSP_SOP3_CNT) & M_DEBUG_PD_RDRSP_SOP3_CNT)
-
-#define S_DEBUG_PD_RDRSP_EOP3_CNT 24
-#define M_DEBUG_PD_RDRSP_EOP3_CNT 0xfU
-#define V_DEBUG_PD_RDRSP_EOP3_CNT(x) ((x) << S_DEBUG_PD_RDRSP_EOP3_CNT)
-#define G_DEBUG_PD_RDRSP_EOP3_CNT(x) (((x) >> S_DEBUG_PD_RDRSP_EOP3_CNT) & M_DEBUG_PD_RDRSP_EOP3_CNT)
-
-#define S_DEBUG_PD_RDRSP_SOP2_CNT 20
-#define M_DEBUG_PD_RDRSP_SOP2_CNT 0xfU
-#define V_DEBUG_PD_RDRSP_SOP2_CNT(x) ((x) << S_DEBUG_PD_RDRSP_SOP2_CNT)
-#define G_DEBUG_PD_RDRSP_SOP2_CNT(x) (((x) >> S_DEBUG_PD_RDRSP_SOP2_CNT) & M_DEBUG_PD_RDRSP_SOP2_CNT)
-
-#define S_DEBUG_PD_RDRSP_EOP2_CNT 16
-#define M_DEBUG_PD_RDRSP_EOP2_CNT 0xfU
-#define V_DEBUG_PD_RDRSP_EOP2_CNT(x) ((x) << S_DEBUG_PD_RDRSP_EOP2_CNT)
-#define G_DEBUG_PD_RDRSP_EOP2_CNT(x) (((x) >> S_DEBUG_PD_RDRSP_EOP2_CNT) & M_DEBUG_PD_RDRSP_EOP2_CNT)
-
-#define S_DEBUG_PD_RDRSP_SOP1_CNT 12
-#define M_DEBUG_PD_RDRSP_SOP1_CNT 0xfU
-#define V_DEBUG_PD_RDRSP_SOP1_CNT(x) ((x) << S_DEBUG_PD_RDRSP_SOP1_CNT)
-#define G_DEBUG_PD_RDRSP_SOP1_CNT(x) (((x) >> S_DEBUG_PD_RDRSP_SOP1_CNT) & M_DEBUG_PD_RDRSP_SOP1_CNT)
-
-#define S_DEBUG_PD_RDRSP_EOP1_CNT 8
-#define M_DEBUG_PD_RDRSP_EOP1_CNT 0xfU
-#define V_DEBUG_PD_RDRSP_EOP1_CNT(x) ((x) << S_DEBUG_PD_RDRSP_EOP1_CNT)
-#define G_DEBUG_PD_RDRSP_EOP1_CNT(x) (((x) >> S_DEBUG_PD_RDRSP_EOP1_CNT) & M_DEBUG_PD_RDRSP_EOP1_CNT)
-
-#define S_DEBUG_PD_RDRSP_SOP0_CNT 4
-#define M_DEBUG_PD_RDRSP_SOP0_CNT 0xfU
-#define V_DEBUG_PD_RDRSP_SOP0_CNT(x) ((x) << S_DEBUG_PD_RDRSP_SOP0_CNT)
-#define G_DEBUG_PD_RDRSP_SOP0_CNT(x) (((x) >> S_DEBUG_PD_RDRSP_SOP0_CNT) & M_DEBUG_PD_RDRSP_SOP0_CNT)
-
-#define S_DEBUG_PD_RDRSP_EOP0_CNT 0
-#define M_DEBUG_PD_RDRSP_EOP0_CNT 0xfU
-#define V_DEBUG_PD_RDRSP_EOP0_CNT(x) ((x) << S_DEBUG_PD_RDRSP_EOP0_CNT)
-#define G_DEBUG_PD_RDRSP_EOP0_CNT(x) (((x) >> S_DEBUG_PD_RDRSP_EOP0_CNT) & M_DEBUG_PD_RDRSP_EOP0_CNT)
-
-#define A_SGE_DEBUG_DATA_HIGH_INDEX_7 0x129c
-
-#define S_DEBUG_PD_WRREQ_SOP3_CNT 28
-#define M_DEBUG_PD_WRREQ_SOP3_CNT 0xfU
-#define V_DEBUG_PD_WRREQ_SOP3_CNT(x) ((x) << S_DEBUG_PD_WRREQ_SOP3_CNT)
-#define G_DEBUG_PD_WRREQ_SOP3_CNT(x) (((x) >> S_DEBUG_PD_WRREQ_SOP3_CNT) & M_DEBUG_PD_WRREQ_SOP3_CNT)
-
-#define S_DEBUG_PD_WRREQ_EOP3_CNT 24
-#define M_DEBUG_PD_WRREQ_EOP3_CNT 0xfU
-#define V_DEBUG_PD_WRREQ_EOP3_CNT(x) ((x) << S_DEBUG_PD_WRREQ_EOP3_CNT)
-#define G_DEBUG_PD_WRREQ_EOP3_CNT(x) (((x) >> S_DEBUG_PD_WRREQ_EOP3_CNT) & M_DEBUG_PD_WRREQ_EOP3_CNT)
-
-#define S_DEBUG_PD_WRREQ_SOP2_CNT 20
-#define M_DEBUG_PD_WRREQ_SOP2_CNT 0xfU
-#define V_DEBUG_PD_WRREQ_SOP2_CNT(x) ((x) << S_DEBUG_PD_WRREQ_SOP2_CNT)
-#define G_DEBUG_PD_WRREQ_SOP2_CNT(x) (((x) >> S_DEBUG_PD_WRREQ_SOP2_CNT) & M_DEBUG_PD_WRREQ_SOP2_CNT)
-
-#define S_DEBUG_PD_WRREQ_EOP2_CNT 16
-#define M_DEBUG_PD_WRREQ_EOP2_CNT 0xfU
-#define V_DEBUG_PD_WRREQ_EOP2_CNT(x) ((x) << S_DEBUG_PD_WRREQ_EOP2_CNT)
-#define G_DEBUG_PD_WRREQ_EOP2_CNT(x) (((x) >> S_DEBUG_PD_WRREQ_EOP2_CNT) & M_DEBUG_PD_WRREQ_EOP2_CNT)
-
-#define S_DEBUG_PD_WRREQ_SOP1_CNT 12
-#define M_DEBUG_PD_WRREQ_SOP1_CNT 0xfU
-#define V_DEBUG_PD_WRREQ_SOP1_CNT(x) ((x) << S_DEBUG_PD_WRREQ_SOP1_CNT)
-#define G_DEBUG_PD_WRREQ_SOP1_CNT(x) (((x) >> S_DEBUG_PD_WRREQ_SOP1_CNT) & M_DEBUG_PD_WRREQ_SOP1_CNT)
-
-#define S_DEBUG_PD_WRREQ_EOP1_CNT 8
-#define M_DEBUG_PD_WRREQ_EOP1_CNT 0xfU
-#define V_DEBUG_PD_WRREQ_EOP1_CNT(x) ((x) << S_DEBUG_PD_WRREQ_EOP1_CNT)
-#define G_DEBUG_PD_WRREQ_EOP1_CNT(x) (((x) >> S_DEBUG_PD_WRREQ_EOP1_CNT) & M_DEBUG_PD_WRREQ_EOP1_CNT)
-
-#define S_DEBUG_PD_WRREQ_SOP0_CNT 4
-#define M_DEBUG_PD_WRREQ_SOP0_CNT 0xfU
-#define V_DEBUG_PD_WRREQ_SOP0_CNT(x) ((x) << S_DEBUG_PD_WRREQ_SOP0_CNT)
-#define G_DEBUG_PD_WRREQ_SOP0_CNT(x) (((x) >> S_DEBUG_PD_WRREQ_SOP0_CNT) & M_DEBUG_PD_WRREQ_SOP0_CNT)
-
-#define S_DEBUG_PD_WRREQ_EOP0_CNT 0
-#define M_DEBUG_PD_WRREQ_EOP0_CNT 0xfU
-#define V_DEBUG_PD_WRREQ_EOP0_CNT(x) ((x) << S_DEBUG_PD_WRREQ_EOP0_CNT)
-#define G_DEBUG_PD_WRREQ_EOP0_CNT(x) (((x) >> S_DEBUG_PD_WRREQ_EOP0_CNT) & M_DEBUG_PD_WRREQ_EOP0_CNT)
-
-#define S_DEBUG_PC_RSP_SOP_CNT 28
-#define M_DEBUG_PC_RSP_SOP_CNT 0xfU
-#define V_DEBUG_PC_RSP_SOP_CNT(x) ((x) << S_DEBUG_PC_RSP_SOP_CNT)
-#define G_DEBUG_PC_RSP_SOP_CNT(x) (((x) >> S_DEBUG_PC_RSP_SOP_CNT) & M_DEBUG_PC_RSP_SOP_CNT)
-
-#define S_DEBUG_PC_RSP_EOP_CNT 24
-#define M_DEBUG_PC_RSP_EOP_CNT 0xfU
-#define V_DEBUG_PC_RSP_EOP_CNT(x) ((x) << S_DEBUG_PC_RSP_EOP_CNT)
-#define G_DEBUG_PC_RSP_EOP_CNT(x) (((x) >> S_DEBUG_PC_RSP_EOP_CNT) & M_DEBUG_PC_RSP_EOP_CNT)
-
-#define S_DEBUG_PC_REQ_SOP_CNT 20
-#define M_DEBUG_PC_REQ_SOP_CNT 0xfU
-#define V_DEBUG_PC_REQ_SOP_CNT(x) ((x) << S_DEBUG_PC_REQ_SOP_CNT)
-#define G_DEBUG_PC_REQ_SOP_CNT(x) (((x) >> S_DEBUG_PC_REQ_SOP_CNT) & M_DEBUG_PC_REQ_SOP_CNT)
-
-#define S_DEBUG_PC_REQ_EOP_CNT 16
-#define M_DEBUG_PC_REQ_EOP_CNT 0xfU
-#define V_DEBUG_PC_REQ_EOP_CNT(x) ((x) << S_DEBUG_PC_REQ_EOP_CNT)
-#define G_DEBUG_PC_REQ_EOP_CNT(x) (((x) >> S_DEBUG_PC_REQ_EOP_CNT) & M_DEBUG_PC_REQ_EOP_CNT)
-
-#define A_SGE_DEBUG_DATA_HIGH_INDEX_8 0x12a0
-
-#define S_GLOBALENABLE_OFF 29
-#define V_GLOBALENABLE_OFF(x) ((x) << S_GLOBALENABLE_OFF)
-#define F_GLOBALENABLE_OFF V_GLOBALENABLE_OFF(1U)
-
-#define S_DEBUG_CIM2SGE_RXAFULL_D 27
-#define M_DEBUG_CIM2SGE_RXAFULL_D 0x3U
-#define V_DEBUG_CIM2SGE_RXAFULL_D(x) ((x) << S_DEBUG_CIM2SGE_RXAFULL_D)
-#define G_DEBUG_CIM2SGE_RXAFULL_D(x) (((x) >> S_DEBUG_CIM2SGE_RXAFULL_D) & M_DEBUG_CIM2SGE_RXAFULL_D)
-
-#define S_DEBUG_CPLSW_CIM_TXAFULL_D 25
-#define M_DEBUG_CPLSW_CIM_TXAFULL_D 0x3U
-#define V_DEBUG_CPLSW_CIM_TXAFULL_D(x) ((x) << S_DEBUG_CPLSW_CIM_TXAFULL_D)
-#define G_DEBUG_CPLSW_CIM_TXAFULL_D(x) (((x) >> S_DEBUG_CPLSW_CIM_TXAFULL_D) & M_DEBUG_CPLSW_CIM_TXAFULL_D)
-
-#define S_DEBUG_UP_FULL 24
-#define V_DEBUG_UP_FULL(x) ((x) << S_DEBUG_UP_FULL)
-#define F_DEBUG_UP_FULL V_DEBUG_UP_FULL(1U)
-
-#define S_DEBUG_M_RD_REQ_OUTSTANDING_PC 23
-#define V_DEBUG_M_RD_REQ_OUTSTANDING_PC(x) ((x) << S_DEBUG_M_RD_REQ_OUTSTANDING_PC)
-#define F_DEBUG_M_RD_REQ_OUTSTANDING_PC V_DEBUG_M_RD_REQ_OUTSTANDING_PC(1U)
-
-#define S_DEBUG_M_RD_REQ_OUTSTANDING_VFIFO 22
-#define V_DEBUG_M_RD_REQ_OUTSTANDING_VFIFO(x) ((x) << S_DEBUG_M_RD_REQ_OUTSTANDING_VFIFO)
-#define F_DEBUG_M_RD_REQ_OUTSTANDING_VFIFO V_DEBUG_M_RD_REQ_OUTSTANDING_VFIFO(1U)
-
-#define S_DEBUG_M_RD_REQ_OUTSTANDING_IMSG 21
-#define V_DEBUG_M_RD_REQ_OUTSTANDING_IMSG(x) ((x) << S_DEBUG_M_RD_REQ_OUTSTANDING_IMSG)
-#define F_DEBUG_M_RD_REQ_OUTSTANDING_IMSG V_DEBUG_M_RD_REQ_OUTSTANDING_IMSG(1U)
-
-#define S_DEBUG_M_RD_REQ_OUTSTANDING_CMARB 20
-#define V_DEBUG_M_RD_REQ_OUTSTANDING_CMARB(x) ((x) << S_DEBUG_M_RD_REQ_OUTSTANDING_CMARB)
-#define F_DEBUG_M_RD_REQ_OUTSTANDING_CMARB V_DEBUG_M_RD_REQ_OUTSTANDING_CMARB(1U)
-
-#define S_DEBUG_M_RD_REQ_OUTSTANDING_FLM 19
-#define V_DEBUG_M_RD_REQ_OUTSTANDING_FLM(x) ((x) << S_DEBUG_M_RD_REQ_OUTSTANDING_FLM)
-#define F_DEBUG_M_RD_REQ_OUTSTANDING_FLM V_DEBUG_M_RD_REQ_OUTSTANDING_FLM(1U)
-
-#define S_DEBUG_M_REQVLD 18
-#define V_DEBUG_M_REQVLD(x) ((x) << S_DEBUG_M_REQVLD)
-#define F_DEBUG_M_REQVLD V_DEBUG_M_REQVLD(1U)
-
-#define S_DEBUG_M_REQRDY 17
-#define V_DEBUG_M_REQRDY(x) ((x) << S_DEBUG_M_REQRDY)
-#define F_DEBUG_M_REQRDY V_DEBUG_M_REQRDY(1U)
-
-#define S_DEBUG_M_RSPVLD 16
-#define V_DEBUG_M_RSPVLD(x) ((x) << S_DEBUG_M_RSPVLD)
-#define F_DEBUG_M_RSPVLD V_DEBUG_M_RSPVLD(1U)
-
-#define S_DEBUG_PD_WRREQ_INT3_CNT 12
-#define M_DEBUG_PD_WRREQ_INT3_CNT 0xfU
-#define V_DEBUG_PD_WRREQ_INT3_CNT(x) ((x) << S_DEBUG_PD_WRREQ_INT3_CNT)
-#define G_DEBUG_PD_WRREQ_INT3_CNT(x) (((x) >> S_DEBUG_PD_WRREQ_INT3_CNT) & M_DEBUG_PD_WRREQ_INT3_CNT)
-
-#define S_DEBUG_PD_WRREQ_INT2_CNT 8
-#define M_DEBUG_PD_WRREQ_INT2_CNT 0xfU
-#define V_DEBUG_PD_WRREQ_INT2_CNT(x) ((x) << S_DEBUG_PD_WRREQ_INT2_CNT)
-#define G_DEBUG_PD_WRREQ_INT2_CNT(x) (((x) >> S_DEBUG_PD_WRREQ_INT2_CNT) & M_DEBUG_PD_WRREQ_INT2_CNT)
-
-#define S_DEBUG_PD_WRREQ_INT1_CNT 4
-#define M_DEBUG_PD_WRREQ_INT1_CNT 0xfU
-#define V_DEBUG_PD_WRREQ_INT1_CNT(x) ((x) << S_DEBUG_PD_WRREQ_INT1_CNT)
-#define G_DEBUG_PD_WRREQ_INT1_CNT(x) (((x) >> S_DEBUG_PD_WRREQ_INT1_CNT) & M_DEBUG_PD_WRREQ_INT1_CNT)
-
-#define S_DEBUG_PD_WRREQ_INT0_CNT 0
-#define M_DEBUG_PD_WRREQ_INT0_CNT 0xfU
-#define V_DEBUG_PD_WRREQ_INT0_CNT(x) ((x) << S_DEBUG_PD_WRREQ_INT0_CNT)
-#define G_DEBUG_PD_WRREQ_INT0_CNT(x) (((x) >> S_DEBUG_PD_WRREQ_INT0_CNT) & M_DEBUG_PD_WRREQ_INT0_CNT)
-
-#define S_DEBUG_PL_BAR2_REQVLD 31
-#define V_DEBUG_PL_BAR2_REQVLD(x) ((x) << S_DEBUG_PL_BAR2_REQVLD)
-#define F_DEBUG_PL_BAR2_REQVLD V_DEBUG_PL_BAR2_REQVLD(1U)
-
-#define S_DEBUG_PL_BAR2_REQFULL 30
-#define V_DEBUG_PL_BAR2_REQFULL(x) ((x) << S_DEBUG_PL_BAR2_REQFULL)
-#define F_DEBUG_PL_BAR2_REQFULL V_DEBUG_PL_BAR2_REQFULL(1U)
-
-#define A_SGE_DEBUG_DATA_HIGH_INDEX_9 0x12a4
-
-#define S_DEBUG_CPLSW_TP_RX_SOP1_CNT 28
-#define M_DEBUG_CPLSW_TP_RX_SOP1_CNT 0xfU
-#define V_DEBUG_CPLSW_TP_RX_SOP1_CNT(x) ((x) << S_DEBUG_CPLSW_TP_RX_SOP1_CNT)
-#define G_DEBUG_CPLSW_TP_RX_SOP1_CNT(x) (((x) >> S_DEBUG_CPLSW_TP_RX_SOP1_CNT) & M_DEBUG_CPLSW_TP_RX_SOP1_CNT)
-
-#define S_DEBUG_CPLSW_TP_RX_EOP1_CNT 24
-#define M_DEBUG_CPLSW_TP_RX_EOP1_CNT 0xfU
-#define V_DEBUG_CPLSW_TP_RX_EOP1_CNT(x) ((x) << S_DEBUG_CPLSW_TP_RX_EOP1_CNT)
-#define G_DEBUG_CPLSW_TP_RX_EOP1_CNT(x) (((x) >> S_DEBUG_CPLSW_TP_RX_EOP1_CNT) & M_DEBUG_CPLSW_TP_RX_EOP1_CNT)
-
-#define S_DEBUG_CPLSW_TP_RX_SOP0_CNT 20
-#define M_DEBUG_CPLSW_TP_RX_SOP0_CNT 0xfU
-#define V_DEBUG_CPLSW_TP_RX_SOP0_CNT(x) ((x) << S_DEBUG_CPLSW_TP_RX_SOP0_CNT)
-#define G_DEBUG_CPLSW_TP_RX_SOP0_CNT(x) (((x) >> S_DEBUG_CPLSW_TP_RX_SOP0_CNT) & M_DEBUG_CPLSW_TP_RX_SOP0_CNT)
-
-#define S_DEBUG_CPLSW_TP_RX_EOP0_CNT 16
-#define M_DEBUG_CPLSW_TP_RX_EOP0_CNT 0xfU
-#define V_DEBUG_CPLSW_TP_RX_EOP0_CNT(x) ((x) << S_DEBUG_CPLSW_TP_RX_EOP0_CNT)
-#define G_DEBUG_CPLSW_TP_RX_EOP0_CNT(x) (((x) >> S_DEBUG_CPLSW_TP_RX_EOP0_CNT) & M_DEBUG_CPLSW_TP_RX_EOP0_CNT)
-
-#define S_DEBUG_CPLSW_CIM_SOP1_CNT 12
-#define M_DEBUG_CPLSW_CIM_SOP1_CNT 0xfU
-#define V_DEBUG_CPLSW_CIM_SOP1_CNT(x) ((x) << S_DEBUG_CPLSW_CIM_SOP1_CNT)
-#define G_DEBUG_CPLSW_CIM_SOP1_CNT(x) (((x) >> S_DEBUG_CPLSW_CIM_SOP1_CNT) & M_DEBUG_CPLSW_CIM_SOP1_CNT)
-
-#define S_DEBUG_CPLSW_CIM_EOP1_CNT 8
-#define M_DEBUG_CPLSW_CIM_EOP1_CNT 0xfU
-#define V_DEBUG_CPLSW_CIM_EOP1_CNT(x) ((x) << S_DEBUG_CPLSW_CIM_EOP1_CNT)
-#define G_DEBUG_CPLSW_CIM_EOP1_CNT(x) (((x) >> S_DEBUG_CPLSW_CIM_EOP1_CNT) & M_DEBUG_CPLSW_CIM_EOP1_CNT)
-
-#define S_DEBUG_CPLSW_CIM_SOP0_CNT 4
-#define M_DEBUG_CPLSW_CIM_SOP0_CNT 0xfU
-#define V_DEBUG_CPLSW_CIM_SOP0_CNT(x) ((x) << S_DEBUG_CPLSW_CIM_SOP0_CNT)
-#define G_DEBUG_CPLSW_CIM_SOP0_CNT(x) (((x) >> S_DEBUG_CPLSW_CIM_SOP0_CNT) & M_DEBUG_CPLSW_CIM_SOP0_CNT)
-
-#define S_DEBUG_CPLSW_CIM_EOP0_CNT 0
-#define M_DEBUG_CPLSW_CIM_EOP0_CNT 0xfU
-#define V_DEBUG_CPLSW_CIM_EOP0_CNT(x) ((x) << S_DEBUG_CPLSW_CIM_EOP0_CNT)
-#define G_DEBUG_CPLSW_CIM_EOP0_CNT(x) (((x) >> S_DEBUG_CPLSW_CIM_EOP0_CNT) & M_DEBUG_CPLSW_CIM_EOP0_CNT)
-
-#define A_SGE_DEBUG_DATA_HIGH_INDEX_10 0x12a8
-
-#define S_DEBUG_T_RXAFULL_D 30
-#define M_DEBUG_T_RXAFULL_D 0x3U
-#define V_DEBUG_T_RXAFULL_D(x) ((x) << S_DEBUG_T_RXAFULL_D)
-#define G_DEBUG_T_RXAFULL_D(x) (((x) >> S_DEBUG_T_RXAFULL_D) & M_DEBUG_T_RXAFULL_D)
-
-#define S_DEBUG_PD_RDRSPAFULL_D 26
-#define M_DEBUG_PD_RDRSPAFULL_D 0xfU
-#define V_DEBUG_PD_RDRSPAFULL_D(x) ((x) << S_DEBUG_PD_RDRSPAFULL_D)
-#define G_DEBUG_PD_RDRSPAFULL_D(x) (((x) >> S_DEBUG_PD_RDRSPAFULL_D) & M_DEBUG_PD_RDRSPAFULL_D)
-
-#define S_DEBUG_PD_RDREQAFULL_D 22
-#define M_DEBUG_PD_RDREQAFULL_D 0xfU
-#define V_DEBUG_PD_RDREQAFULL_D(x) ((x) << S_DEBUG_PD_RDREQAFULL_D)
-#define G_DEBUG_PD_RDREQAFULL_D(x) (((x) >> S_DEBUG_PD_RDREQAFULL_D) & M_DEBUG_PD_RDREQAFULL_D)
-
-#define S_DEBUG_PD_WRREQAFULL_D 18
-#define M_DEBUG_PD_WRREQAFULL_D 0xfU
-#define V_DEBUG_PD_WRREQAFULL_D(x) ((x) << S_DEBUG_PD_WRREQAFULL_D)
-#define G_DEBUG_PD_WRREQAFULL_D(x) (((x) >> S_DEBUG_PD_WRREQAFULL_D) & M_DEBUG_PD_WRREQAFULL_D)
-
-#define S_DEBUG_PC_RSPAFULL_D 15
-#define M_DEBUG_PC_RSPAFULL_D 0x7U
-#define V_DEBUG_PC_RSPAFULL_D(x) ((x) << S_DEBUG_PC_RSPAFULL_D)
-#define G_DEBUG_PC_RSPAFULL_D(x) (((x) >> S_DEBUG_PC_RSPAFULL_D) & M_DEBUG_PC_RSPAFULL_D)
-
-#define S_DEBUG_PC_REQAFULL_D 12
-#define M_DEBUG_PC_REQAFULL_D 0x7U
-#define V_DEBUG_PC_REQAFULL_D(x) ((x) << S_DEBUG_PC_REQAFULL_D)
-#define G_DEBUG_PC_REQAFULL_D(x) (((x) >> S_DEBUG_PC_REQAFULL_D) & M_DEBUG_PC_REQAFULL_D)
-
-#define S_DEBUG_U_TXAFULL_D 8
-#define M_DEBUG_U_TXAFULL_D 0xfU
-#define V_DEBUG_U_TXAFULL_D(x) ((x) << S_DEBUG_U_TXAFULL_D)
-#define G_DEBUG_U_TXAFULL_D(x) (((x) >> S_DEBUG_U_TXAFULL_D) & M_DEBUG_U_TXAFULL_D)
-
-#define S_DEBUG_UD_RXAFULL_D 4
-#define M_DEBUG_UD_RXAFULL_D 0xfU
-#define V_DEBUG_UD_RXAFULL_D(x) ((x) << S_DEBUG_UD_RXAFULL_D)
-#define G_DEBUG_UD_RXAFULL_D(x) (((x) >> S_DEBUG_UD_RXAFULL_D) & M_DEBUG_UD_RXAFULL_D)
-
-#define S_DEBUG_U_RXAFULL_D 2
-#define M_DEBUG_U_RXAFULL_D 0x3U
-#define V_DEBUG_U_RXAFULL_D(x) ((x) << S_DEBUG_U_RXAFULL_D)
-#define G_DEBUG_U_RXAFULL_D(x) (((x) >> S_DEBUG_U_RXAFULL_D) & M_DEBUG_U_RXAFULL_D)
-
-#define S_DEBUG_CIM_AFULL_D 0
-#define M_DEBUG_CIM_AFULL_D 0x3U
-#define V_DEBUG_CIM_AFULL_D(x) ((x) << S_DEBUG_CIM_AFULL_D)
-#define G_DEBUG_CIM_AFULL_D(x) (((x) >> S_DEBUG_CIM_AFULL_D) & M_DEBUG_CIM_AFULL_D)
-
-#define S_DEBUG_IDMA1_S_CPL_FLIT_REMAINING 28
-#define M_DEBUG_IDMA1_S_CPL_FLIT_REMAINING 0xfU
-#define V_DEBUG_IDMA1_S_CPL_FLIT_REMAINING(x) ((x) << S_DEBUG_IDMA1_S_CPL_FLIT_REMAINING)
-#define G_DEBUG_IDMA1_S_CPL_FLIT_REMAINING(x) (((x) >> S_DEBUG_IDMA1_S_CPL_FLIT_REMAINING) & M_DEBUG_IDMA1_S_CPL_FLIT_REMAINING)
-
-#define S_DEBUG_IDMA1_IDMA2IMSG_CMP_OUT_SRDY 27
-#define V_DEBUG_IDMA1_IDMA2IMSG_CMP_OUT_SRDY(x) ((x) << S_DEBUG_IDMA1_IDMA2IMSG_CMP_OUT_SRDY)
-#define F_DEBUG_IDMA1_IDMA2IMSG_CMP_OUT_SRDY V_DEBUG_IDMA1_IDMA2IMSG_CMP_OUT_SRDY(1U)
-
-#define S_DEBUG_IDMA1_IDMA2IMSG_CMP_OUT_RSS 26
-#define V_DEBUG_IDMA1_IDMA2IMSG_CMP_OUT_RSS(x) ((x) << S_DEBUG_IDMA1_IDMA2IMSG_CMP_OUT_RSS)
-#define F_DEBUG_IDMA1_IDMA2IMSG_CMP_OUT_RSS V_DEBUG_IDMA1_IDMA2IMSG_CMP_OUT_RSS(1U)
-
-#define S_DEBUG_IDMA1_IDMA2IMSG_CMP_OUT_NOCPL 25
-#define V_DEBUG_IDMA1_IDMA2IMSG_CMP_OUT_NOCPL(x) ((x) << S_DEBUG_IDMA1_IDMA2IMSG_CMP_OUT_NOCPL)
-#define F_DEBUG_IDMA1_IDMA2IMSG_CMP_OUT_NOCPL V_DEBUG_IDMA1_IDMA2IMSG_CMP_OUT_NOCPL(1U)
-
-#define S_DEBUG_IDMA1_IDMA2IMSG_FULL 24
-#define V_DEBUG_IDMA1_IDMA2IMSG_FULL(x) ((x) << S_DEBUG_IDMA1_IDMA2IMSG_FULL)
-#define F_DEBUG_IDMA1_IDMA2IMSG_FULL V_DEBUG_IDMA1_IDMA2IMSG_FULL(1U)
-
-#define S_DEBUG_IDMA1_IDMA2IMSG_EOP 23
-#define V_DEBUG_IDMA1_IDMA2IMSG_EOP(x) ((x) << S_DEBUG_IDMA1_IDMA2IMSG_EOP)
-#define F_DEBUG_IDMA1_IDMA2IMSG_EOP V_DEBUG_IDMA1_IDMA2IMSG_EOP(1U)
-
-#define S_DEBUG_IDMA1_IDMA2IMSG_FIFO_IN_DRDY 22
-#define V_DEBUG_IDMA1_IDMA2IMSG_FIFO_IN_DRDY(x) ((x) << S_DEBUG_IDMA1_IDMA2IMSG_FIFO_IN_DRDY)
-#define F_DEBUG_IDMA1_IDMA2IMSG_FIFO_IN_DRDY V_DEBUG_IDMA1_IDMA2IMSG_FIFO_IN_DRDY(1U)
-
-#define S_DEBUG_IDMA1_IDMA2IMSG_CMP_IN_DRDY 21
-#define V_DEBUG_IDMA1_IDMA2IMSG_CMP_IN_DRDY(x) ((x) << S_DEBUG_IDMA1_IDMA2IMSG_CMP_IN_DRDY)
-#define F_DEBUG_IDMA1_IDMA2IMSG_CMP_IN_DRDY V_DEBUG_IDMA1_IDMA2IMSG_CMP_IN_DRDY(1U)
-
-#define S_DEBUG_IDMA0_S_CPL_FLIT_REMAINING 17
-#define M_DEBUG_IDMA0_S_CPL_FLIT_REMAINING 0xfU
-#define V_DEBUG_IDMA0_S_CPL_FLIT_REMAINING(x) ((x) << S_DEBUG_IDMA0_S_CPL_FLIT_REMAINING)
-#define G_DEBUG_IDMA0_S_CPL_FLIT_REMAINING(x) (((x) >> S_DEBUG_IDMA0_S_CPL_FLIT_REMAINING) & M_DEBUG_IDMA0_S_CPL_FLIT_REMAINING)
-
-#define S_DEBUG_IDMA0_IDMA2IMSG_CMP_OUT_SRDY 16
-#define V_DEBUG_IDMA0_IDMA2IMSG_CMP_OUT_SRDY(x) ((x) << S_DEBUG_IDMA0_IDMA2IMSG_CMP_OUT_SRDY)
-#define F_DEBUG_IDMA0_IDMA2IMSG_CMP_OUT_SRDY V_DEBUG_IDMA0_IDMA2IMSG_CMP_OUT_SRDY(1U)
-
-#define S_DEBUG_IDMA0_IDMA2IMSG_CMP_OUT_RSS 15
-#define V_DEBUG_IDMA0_IDMA2IMSG_CMP_OUT_RSS(x) ((x) << S_DEBUG_IDMA0_IDMA2IMSG_CMP_OUT_RSS)
-#define F_DEBUG_IDMA0_IDMA2IMSG_CMP_OUT_RSS V_DEBUG_IDMA0_IDMA2IMSG_CMP_OUT_RSS(1U)
-
-#define S_DEBUG_IDMA0_IDMA2IMSG_CMP_OUT_NOCPL 14
-#define V_DEBUG_IDMA0_IDMA2IMSG_CMP_OUT_NOCPL(x) ((x) << S_DEBUG_IDMA0_IDMA2IMSG_CMP_OUT_NOCPL)
-#define F_DEBUG_IDMA0_IDMA2IMSG_CMP_OUT_NOCPL V_DEBUG_IDMA0_IDMA2IMSG_CMP_OUT_NOCPL(1U)
-
-#define S_DEBUG_IDMA0_IDMA2IMSG_FULL 13
-#define V_DEBUG_IDMA0_IDMA2IMSG_FULL(x) ((x) << S_DEBUG_IDMA0_IDMA2IMSG_FULL)
-#define F_DEBUG_IDMA0_IDMA2IMSG_FULL V_DEBUG_IDMA0_IDMA2IMSG_FULL(1U)
-
-#define S_DEBUG_IDMA0_IDMA2IMSG_EOP 12
-#define V_DEBUG_IDMA0_IDMA2IMSG_EOP(x) ((x) << S_DEBUG_IDMA0_IDMA2IMSG_EOP)
-#define F_DEBUG_IDMA0_IDMA2IMSG_EOP V_DEBUG_IDMA0_IDMA2IMSG_EOP(1U)
-
-#define S_DEBUG_IDMA0_IDMA2IMSG_CMP_IN_DRDY 11
-#define V_DEBUG_IDMA0_IDMA2IMSG_CMP_IN_DRDY(x) ((x) << S_DEBUG_IDMA0_IDMA2IMSG_CMP_IN_DRDY)
-#define F_DEBUG_IDMA0_IDMA2IMSG_CMP_IN_DRDY V_DEBUG_IDMA0_IDMA2IMSG_CMP_IN_DRDY(1U)
-
-#define S_DEBUG_IDMA0_IDMA2IMSG_FIFO_IN_DRDY 10
-#define V_DEBUG_IDMA0_IDMA2IMSG_FIFO_IN_DRDY(x) ((x) << S_DEBUG_IDMA0_IDMA2IMSG_FIFO_IN_DRDY)
-#define F_DEBUG_IDMA0_IDMA2IMSG_FIFO_IN_DRDY V_DEBUG_IDMA0_IDMA2IMSG_FIFO_IN_DRDY(1U)
-
-#define S_T6_DEBUG_T_RXAFULL_D 8
-#define M_T6_DEBUG_T_RXAFULL_D 0x3U
-#define V_T6_DEBUG_T_RXAFULL_D(x) ((x) << S_T6_DEBUG_T_RXAFULL_D)
-#define G_T6_DEBUG_T_RXAFULL_D(x) (((x) >> S_T6_DEBUG_T_RXAFULL_D) & M_T6_DEBUG_T_RXAFULL_D)
-
-#define S_T6_DEBUG_PD_WRREQAFULL_D 6
-#define M_T6_DEBUG_PD_WRREQAFULL_D 0x3U
-#define V_T6_DEBUG_PD_WRREQAFULL_D(x) ((x) << S_T6_DEBUG_PD_WRREQAFULL_D)
-#define G_T6_DEBUG_PD_WRREQAFULL_D(x) (((x) >> S_T6_DEBUG_PD_WRREQAFULL_D) & M_T6_DEBUG_PD_WRREQAFULL_D)
-
-#define S_T6_DEBUG_PC_RSPAFULL_D 5
-#define V_T6_DEBUG_PC_RSPAFULL_D(x) ((x) << S_T6_DEBUG_PC_RSPAFULL_D)
-#define F_T6_DEBUG_PC_RSPAFULL_D V_T6_DEBUG_PC_RSPAFULL_D(1U)
-
-#define S_T6_DEBUG_PC_REQAFULL_D 4
-#define V_T6_DEBUG_PC_REQAFULL_D(x) ((x) << S_T6_DEBUG_PC_REQAFULL_D)
-#define F_T6_DEBUG_PC_REQAFULL_D V_T6_DEBUG_PC_REQAFULL_D(1U)
-
-#define S_T6_DEBUG_CIM_AFULL_D 0
-#define V_T6_DEBUG_CIM_AFULL_D(x) ((x) << S_T6_DEBUG_CIM_AFULL_D)
-#define F_T6_DEBUG_CIM_AFULL_D V_T6_DEBUG_CIM_AFULL_D(1U)
-
-#define A_SGE_DEBUG_DATA_HIGH_INDEX_11 0x12ac
-
-#define S_DEBUG_FLM_IDMA1_CACHE_DATA_ACTIVE 24
-#define V_DEBUG_FLM_IDMA1_CACHE_DATA_ACTIVE(x) ((x) << S_DEBUG_FLM_IDMA1_CACHE_DATA_ACTIVE)
-#define F_DEBUG_FLM_IDMA1_CACHE_DATA_ACTIVE V_DEBUG_FLM_IDMA1_CACHE_DATA_ACTIVE(1U)
-
-#define S_DEBUG_FLM_IDMA1_CACHE_HDR_ACTIVE 23
-#define V_DEBUG_FLM_IDMA1_CACHE_HDR_ACTIVE(x) ((x) << S_DEBUG_FLM_IDMA1_CACHE_HDR_ACTIVE)
-#define F_DEBUG_FLM_IDMA1_CACHE_HDR_ACTIVE V_DEBUG_FLM_IDMA1_CACHE_HDR_ACTIVE(1U)
-
-#define S_DEBUG_FLM_IDMA1_CTXT_DATA_ACTIVE 22
-#define V_DEBUG_FLM_IDMA1_CTXT_DATA_ACTIVE(x) ((x) << S_DEBUG_FLM_IDMA1_CTXT_DATA_ACTIVE)
-#define F_DEBUG_FLM_IDMA1_CTXT_DATA_ACTIVE V_DEBUG_FLM_IDMA1_CTXT_DATA_ACTIVE(1U)
-
-#define S_DEBUG_FLM_IDMA1_CTXT_HDR_ACTIVE 21
-#define V_DEBUG_FLM_IDMA1_CTXT_HDR_ACTIVE(x) ((x) << S_DEBUG_FLM_IDMA1_CTXT_HDR_ACTIVE)
-#define F_DEBUG_FLM_IDMA1_CTXT_HDR_ACTIVE V_DEBUG_FLM_IDMA1_CTXT_HDR_ACTIVE(1U)
-
-#define S_DEBUG_ST_FLM_IDMA1_CACHE 19
-#define M_DEBUG_ST_FLM_IDMA1_CACHE 0x3U
-#define V_DEBUG_ST_FLM_IDMA1_CACHE(x) ((x) << S_DEBUG_ST_FLM_IDMA1_CACHE)
-#define G_DEBUG_ST_FLM_IDMA1_CACHE(x) (((x) >> S_DEBUG_ST_FLM_IDMA1_CACHE) & M_DEBUG_ST_FLM_IDMA1_CACHE)
-
-#define S_DEBUG_ST_FLM_IDMA1_CTXT 16
-#define M_DEBUG_ST_FLM_IDMA1_CTXT 0x7U
-#define V_DEBUG_ST_FLM_IDMA1_CTXT(x) ((x) << S_DEBUG_ST_FLM_IDMA1_CTXT)
-#define G_DEBUG_ST_FLM_IDMA1_CTXT(x) (((x) >> S_DEBUG_ST_FLM_IDMA1_CTXT) & M_DEBUG_ST_FLM_IDMA1_CTXT)
-
-#define S_DEBUG_FLM_IDMA0_CACHE_DATA_ACTIVE 8
-#define V_DEBUG_FLM_IDMA0_CACHE_DATA_ACTIVE(x) ((x) << S_DEBUG_FLM_IDMA0_CACHE_DATA_ACTIVE)
-#define F_DEBUG_FLM_IDMA0_CACHE_DATA_ACTIVE V_DEBUG_FLM_IDMA0_CACHE_DATA_ACTIVE(1U)
-
-#define S_DEBUG_FLM_IDMA0_CACHE_HDR_ACTIVE 7
-#define V_DEBUG_FLM_IDMA0_CACHE_HDR_ACTIVE(x) ((x) << S_DEBUG_FLM_IDMA0_CACHE_HDR_ACTIVE)
-#define F_DEBUG_FLM_IDMA0_CACHE_HDR_ACTIVE V_DEBUG_FLM_IDMA0_CACHE_HDR_ACTIVE(1U)
-
-#define S_DEBUG_FLM_IDMA0_CTXT_DATA_ACTIVE 6
-#define V_DEBUG_FLM_IDMA0_CTXT_DATA_ACTIVE(x) ((x) << S_DEBUG_FLM_IDMA0_CTXT_DATA_ACTIVE)
-#define F_DEBUG_FLM_IDMA0_CTXT_DATA_ACTIVE V_DEBUG_FLM_IDMA0_CTXT_DATA_ACTIVE(1U)
-
-#define S_DEBUG_FLM_IDMA0_CTXT_HDR_ACTIVE 5
-#define V_DEBUG_FLM_IDMA0_CTXT_HDR_ACTIVE(x) ((x) << S_DEBUG_FLM_IDMA0_CTXT_HDR_ACTIVE)
-#define F_DEBUG_FLM_IDMA0_CTXT_HDR_ACTIVE V_DEBUG_FLM_IDMA0_CTXT_HDR_ACTIVE(1U)
-
-#define S_DEBUG_ST_FLM_IDMA0_CACHE 3
-#define M_DEBUG_ST_FLM_IDMA0_CACHE 0x3U
-#define V_DEBUG_ST_FLM_IDMA0_CACHE(x) ((x) << S_DEBUG_ST_FLM_IDMA0_CACHE)
-#define G_DEBUG_ST_FLM_IDMA0_CACHE(x) (((x) >> S_DEBUG_ST_FLM_IDMA0_CACHE) & M_DEBUG_ST_FLM_IDMA0_CACHE)
-
-#define S_DEBUG_ST_FLM_IDMA0_CTXT 0
-#define M_DEBUG_ST_FLM_IDMA0_CTXT 0x7U
-#define V_DEBUG_ST_FLM_IDMA0_CTXT(x) ((x) << S_DEBUG_ST_FLM_IDMA0_CTXT)
-#define G_DEBUG_ST_FLM_IDMA0_CTXT(x) (((x) >> S_DEBUG_ST_FLM_IDMA0_CTXT) & M_DEBUG_ST_FLM_IDMA0_CTXT)
-
-#define A_SGE_DEBUG_DATA_HIGH_INDEX_12 0x12b0
-
-#define S_DEBUG_CPLSW_SOP1_CNT 28
-#define M_DEBUG_CPLSW_SOP1_CNT 0xfU
-#define V_DEBUG_CPLSW_SOP1_CNT(x) ((x) << S_DEBUG_CPLSW_SOP1_CNT)
-#define G_DEBUG_CPLSW_SOP1_CNT(x) (((x) >> S_DEBUG_CPLSW_SOP1_CNT) & M_DEBUG_CPLSW_SOP1_CNT)
-
-#define S_DEBUG_CPLSW_EOP1_CNT 24
-#define M_DEBUG_CPLSW_EOP1_CNT 0xfU
-#define V_DEBUG_CPLSW_EOP1_CNT(x) ((x) << S_DEBUG_CPLSW_EOP1_CNT)
-#define G_DEBUG_CPLSW_EOP1_CNT(x) (((x) >> S_DEBUG_CPLSW_EOP1_CNT) & M_DEBUG_CPLSW_EOP1_CNT)
-
-#define S_DEBUG_CPLSW_SOP0_CNT 20
-#define M_DEBUG_CPLSW_SOP0_CNT 0xfU
-#define V_DEBUG_CPLSW_SOP0_CNT(x) ((x) << S_DEBUG_CPLSW_SOP0_CNT)
-#define G_DEBUG_CPLSW_SOP0_CNT(x) (((x) >> S_DEBUG_CPLSW_SOP0_CNT) & M_DEBUG_CPLSW_SOP0_CNT)
-
-#define S_DEBUG_CPLSW_EOP0_CNT 16
-#define M_DEBUG_CPLSW_EOP0_CNT 0xfU
-#define V_DEBUG_CPLSW_EOP0_CNT(x) ((x) << S_DEBUG_CPLSW_EOP0_CNT)
-#define G_DEBUG_CPLSW_EOP0_CNT(x) (((x) >> S_DEBUG_CPLSW_EOP0_CNT) & M_DEBUG_CPLSW_EOP0_CNT)
-
-#define S_DEBUG_PC_RSP_SOP2_CNT 12
-#define M_DEBUG_PC_RSP_SOP2_CNT 0xfU
-#define V_DEBUG_PC_RSP_SOP2_CNT(x) ((x) << S_DEBUG_PC_RSP_SOP2_CNT)
-#define G_DEBUG_PC_RSP_SOP2_CNT(x) (((x) >> S_DEBUG_PC_RSP_SOP2_CNT) & M_DEBUG_PC_RSP_SOP2_CNT)
-
-#define S_DEBUG_PC_RSP_EOP2_CNT 8
-#define M_DEBUG_PC_RSP_EOP2_CNT 0xfU
-#define V_DEBUG_PC_RSP_EOP2_CNT(x) ((x) << S_DEBUG_PC_RSP_EOP2_CNT)
-#define G_DEBUG_PC_RSP_EOP2_CNT(x) (((x) >> S_DEBUG_PC_RSP_EOP2_CNT) & M_DEBUG_PC_RSP_EOP2_CNT)
-
-#define S_DEBUG_PC_REQ_SOP2_CNT 4
-#define M_DEBUG_PC_REQ_SOP2_CNT 0xfU
-#define V_DEBUG_PC_REQ_SOP2_CNT(x) ((x) << S_DEBUG_PC_REQ_SOP2_CNT)
-#define G_DEBUG_PC_REQ_SOP2_CNT(x) (((x) >> S_DEBUG_PC_REQ_SOP2_CNT) & M_DEBUG_PC_REQ_SOP2_CNT)
-
-#define S_DEBUG_PC_REQ_EOP2_CNT 0
-#define M_DEBUG_PC_REQ_EOP2_CNT 0xfU
-#define V_DEBUG_PC_REQ_EOP2_CNT(x) ((x) << S_DEBUG_PC_REQ_EOP2_CNT)
-#define G_DEBUG_PC_REQ_EOP2_CNT(x) (((x) >> S_DEBUG_PC_REQ_EOP2_CNT) & M_DEBUG_PC_REQ_EOP2_CNT)
-
-#define S_DEBUG_IDMA1_ISHIFT_TX_SIZE 8
-#define M_DEBUG_IDMA1_ISHIFT_TX_SIZE 0x7fU
-#define V_DEBUG_IDMA1_ISHIFT_TX_SIZE(x) ((x) << S_DEBUG_IDMA1_ISHIFT_TX_SIZE)
-#define G_DEBUG_IDMA1_ISHIFT_TX_SIZE(x) (((x) >> S_DEBUG_IDMA1_ISHIFT_TX_SIZE) & M_DEBUG_IDMA1_ISHIFT_TX_SIZE)
-
-#define S_DEBUG_IDMA0_ISHIFT_TX_SIZE 0
-#define M_DEBUG_IDMA0_ISHIFT_TX_SIZE 0x7fU
-#define V_DEBUG_IDMA0_ISHIFT_TX_SIZE(x) ((x) << S_DEBUG_IDMA0_ISHIFT_TX_SIZE)
-#define G_DEBUG_IDMA0_ISHIFT_TX_SIZE(x) (((x) >> S_DEBUG_IDMA0_ISHIFT_TX_SIZE) & M_DEBUG_IDMA0_ISHIFT_TX_SIZE)
-
-#define A_SGE_DEBUG_DATA_HIGH_INDEX_13 0x12b4
-#define A_SGE_DEBUG_DATA_HIGH_INDEX_14 0x12b8
-#define A_SGE_DEBUG_DATA_HIGH_INDEX_15 0x12bc
-#define A_SGE_DEBUG_DATA_LOW_INDEX_0 0x12c0
-
-#define S_DEBUG_ST_IDMA1_FLM_REQ 29
-#define M_DEBUG_ST_IDMA1_FLM_REQ 0x7U
-#define V_DEBUG_ST_IDMA1_FLM_REQ(x) ((x) << S_DEBUG_ST_IDMA1_FLM_REQ)
-#define G_DEBUG_ST_IDMA1_FLM_REQ(x) (((x) >> S_DEBUG_ST_IDMA1_FLM_REQ) & M_DEBUG_ST_IDMA1_FLM_REQ)
-
-#define S_DEBUG_ST_IDMA0_FLM_REQ 26
-#define M_DEBUG_ST_IDMA0_FLM_REQ 0x7U
-#define V_DEBUG_ST_IDMA0_FLM_REQ(x) ((x) << S_DEBUG_ST_IDMA0_FLM_REQ)
-#define G_DEBUG_ST_IDMA0_FLM_REQ(x) (((x) >> S_DEBUG_ST_IDMA0_FLM_REQ) & M_DEBUG_ST_IDMA0_FLM_REQ)
-
-#define S_DEBUG_ST_IMSG_CTXT 23
-#define M_DEBUG_ST_IMSG_CTXT 0x7U
-#define V_DEBUG_ST_IMSG_CTXT(x) ((x) << S_DEBUG_ST_IMSG_CTXT)
-#define G_DEBUG_ST_IMSG_CTXT(x) (((x) >> S_DEBUG_ST_IMSG_CTXT) & M_DEBUG_ST_IMSG_CTXT)
-
-#define S_DEBUG_ST_IMSG 18
-#define M_DEBUG_ST_IMSG 0x1fU
-#define V_DEBUG_ST_IMSG(x) ((x) << S_DEBUG_ST_IMSG)
-#define G_DEBUG_ST_IMSG(x) (((x) >> S_DEBUG_ST_IMSG) & M_DEBUG_ST_IMSG)
-
-#define S_DEBUG_ST_IDMA1_IALN 16
-#define M_DEBUG_ST_IDMA1_IALN 0x3U
-#define V_DEBUG_ST_IDMA1_IALN(x) ((x) << S_DEBUG_ST_IDMA1_IALN)
-#define G_DEBUG_ST_IDMA1_IALN(x) (((x) >> S_DEBUG_ST_IDMA1_IALN) & M_DEBUG_ST_IDMA1_IALN)
-
-#define S_DEBUG_ST_IDMA1_IDMA_SM 9
-#define M_DEBUG_ST_IDMA1_IDMA_SM 0x3fU
-#define V_DEBUG_ST_IDMA1_IDMA_SM(x) ((x) << S_DEBUG_ST_IDMA1_IDMA_SM)
-#define G_DEBUG_ST_IDMA1_IDMA_SM(x) (((x) >> S_DEBUG_ST_IDMA1_IDMA_SM) & M_DEBUG_ST_IDMA1_IDMA_SM)
-
-#define S_DEBUG_ST_IDMA0_IALN 7
-#define M_DEBUG_ST_IDMA0_IALN 0x3U
-#define V_DEBUG_ST_IDMA0_IALN(x) ((x) << S_DEBUG_ST_IDMA0_IALN)
-#define G_DEBUG_ST_IDMA0_IALN(x) (((x) >> S_DEBUG_ST_IDMA0_IALN) & M_DEBUG_ST_IDMA0_IALN)
-
-#define S_DEBUG_ST_IDMA0_IDMA_SM 0
-#define M_DEBUG_ST_IDMA0_IDMA_SM 0x3fU
-#define V_DEBUG_ST_IDMA0_IDMA_SM(x) ((x) << S_DEBUG_ST_IDMA0_IDMA_SM)
-#define G_DEBUG_ST_IDMA0_IDMA_SM(x) (((x) >> S_DEBUG_ST_IDMA0_IDMA_SM) & M_DEBUG_ST_IDMA0_IDMA_SM)
-
-#define S_DEBUG_ST_IDMA1_IDMA2IMSG 15
-#define V_DEBUG_ST_IDMA1_IDMA2IMSG(x) ((x) << S_DEBUG_ST_IDMA1_IDMA2IMSG)
-#define F_DEBUG_ST_IDMA1_IDMA2IMSG V_DEBUG_ST_IDMA1_IDMA2IMSG(1U)
-
-#define S_DEBUG_ST_IDMA0_IDMA2IMSG 6
-#define V_DEBUG_ST_IDMA0_IDMA2IMSG(x) ((x) << S_DEBUG_ST_IDMA0_IDMA2IMSG)
-#define F_DEBUG_ST_IDMA0_IDMA2IMSG V_DEBUG_ST_IDMA0_IDMA2IMSG(1U)
-
-#define A_SGE_DEBUG_DATA_LOW_INDEX_1 0x12c4
-
-#define S_DEBUG_ITP_EMPTY 12
-#define M_DEBUG_ITP_EMPTY 0x3fU
-#define V_DEBUG_ITP_EMPTY(x) ((x) << S_DEBUG_ITP_EMPTY)
-#define G_DEBUG_ITP_EMPTY(x) (((x) >> S_DEBUG_ITP_EMPTY) & M_DEBUG_ITP_EMPTY)
-
-#define S_DEBUG_ITP_EXPIRED 6
-#define M_DEBUG_ITP_EXPIRED 0x3fU
-#define V_DEBUG_ITP_EXPIRED(x) ((x) << S_DEBUG_ITP_EXPIRED)
-#define G_DEBUG_ITP_EXPIRED(x) (((x) >> S_DEBUG_ITP_EXPIRED) & M_DEBUG_ITP_EXPIRED)
-
-#define S_DEBUG_ITP_PAUSE 5
-#define V_DEBUG_ITP_PAUSE(x) ((x) << S_DEBUG_ITP_PAUSE)
-#define F_DEBUG_ITP_PAUSE V_DEBUG_ITP_PAUSE(1U)
-
-#define S_DEBUG_ITP_DEL_DONE 4
-#define V_DEBUG_ITP_DEL_DONE(x) ((x) << S_DEBUG_ITP_DEL_DONE)
-#define F_DEBUG_ITP_DEL_DONE V_DEBUG_ITP_DEL_DONE(1U)
-
-#define S_DEBUG_ITP_ADD_DONE 3
-#define V_DEBUG_ITP_ADD_DONE(x) ((x) << S_DEBUG_ITP_ADD_DONE)
-#define F_DEBUG_ITP_ADD_DONE V_DEBUG_ITP_ADD_DONE(1U)
-
-#define S_DEBUG_ITP_EVR_STATE 0
-#define M_DEBUG_ITP_EVR_STATE 0x7U
-#define V_DEBUG_ITP_EVR_STATE(x) ((x) << S_DEBUG_ITP_EVR_STATE)
-#define G_DEBUG_ITP_EVR_STATE(x) (((x) >> S_DEBUG_ITP_EVR_STATE) & M_DEBUG_ITP_EVR_STATE)
-
-#define A_SGE_DEBUG_DATA_LOW_INDEX_2 0x12c8
-
-#define S_DEBUG_ST_DBP_THREAD2_CIMFL 25
-#define M_DEBUG_ST_DBP_THREAD2_CIMFL 0x1fU
-#define V_DEBUG_ST_DBP_THREAD2_CIMFL(x) ((x) << S_DEBUG_ST_DBP_THREAD2_CIMFL)
-#define G_DEBUG_ST_DBP_THREAD2_CIMFL(x) (((x) >> S_DEBUG_ST_DBP_THREAD2_CIMFL) & M_DEBUG_ST_DBP_THREAD2_CIMFL)
-
-#define S_DEBUG_ST_DBP_THREAD2_MAIN 20
-#define M_DEBUG_ST_DBP_THREAD2_MAIN 0x1fU
-#define V_DEBUG_ST_DBP_THREAD2_MAIN(x) ((x) << S_DEBUG_ST_DBP_THREAD2_MAIN)
-#define G_DEBUG_ST_DBP_THREAD2_MAIN(x) (((x) >> S_DEBUG_ST_DBP_THREAD2_MAIN) & M_DEBUG_ST_DBP_THREAD2_MAIN)
-
-#define S_DEBUG_ST_DBP_THREAD1_CIMFL 15
-#define M_DEBUG_ST_DBP_THREAD1_CIMFL 0x1fU
-#define V_DEBUG_ST_DBP_THREAD1_CIMFL(x) ((x) << S_DEBUG_ST_DBP_THREAD1_CIMFL)
-#define G_DEBUG_ST_DBP_THREAD1_CIMFL(x) (((x) >> S_DEBUG_ST_DBP_THREAD1_CIMFL) & M_DEBUG_ST_DBP_THREAD1_CIMFL)
-
-#define S_DEBUG_ST_DBP_THREAD1_MAIN 10
-#define M_DEBUG_ST_DBP_THREAD1_MAIN 0x1fU
-#define V_DEBUG_ST_DBP_THREAD1_MAIN(x) ((x) << S_DEBUG_ST_DBP_THREAD1_MAIN)
-#define G_DEBUG_ST_DBP_THREAD1_MAIN(x) (((x) >> S_DEBUG_ST_DBP_THREAD1_MAIN) & M_DEBUG_ST_DBP_THREAD1_MAIN)
-
-#define S_DEBUG_ST_DBP_THREAD0_CIMFL 5
-#define M_DEBUG_ST_DBP_THREAD0_CIMFL 0x1fU
-#define V_DEBUG_ST_DBP_THREAD0_CIMFL(x) ((x) << S_DEBUG_ST_DBP_THREAD0_CIMFL)
-#define G_DEBUG_ST_DBP_THREAD0_CIMFL(x) (((x) >> S_DEBUG_ST_DBP_THREAD0_CIMFL) & M_DEBUG_ST_DBP_THREAD0_CIMFL)
-
-#define S_DEBUG_ST_DBP_THREAD0_MAIN 0
-#define M_DEBUG_ST_DBP_THREAD0_MAIN 0x1fU
-#define V_DEBUG_ST_DBP_THREAD0_MAIN(x) ((x) << S_DEBUG_ST_DBP_THREAD0_MAIN)
-#define G_DEBUG_ST_DBP_THREAD0_MAIN(x) (((x) >> S_DEBUG_ST_DBP_THREAD0_MAIN) & M_DEBUG_ST_DBP_THREAD0_MAIN)
-
-#define S_T6_DEBUG_ST_DBP_UPCP_MAIN 14
-#define M_T6_DEBUG_ST_DBP_UPCP_MAIN 0x7U
-#define V_T6_DEBUG_ST_DBP_UPCP_MAIN(x) ((x) << S_T6_DEBUG_ST_DBP_UPCP_MAIN)
-#define G_T6_DEBUG_ST_DBP_UPCP_MAIN(x) (((x) >> S_T6_DEBUG_ST_DBP_UPCP_MAIN) & M_T6_DEBUG_ST_DBP_UPCP_MAIN)
-
-#define A_SGE_DEBUG_DATA_LOW_INDEX_3 0x12cc
-
-#define S_DEBUG_ST_DBP_UPCP_MAIN 14
-#define M_DEBUG_ST_DBP_UPCP_MAIN 0x1fU
-#define V_DEBUG_ST_DBP_UPCP_MAIN(x) ((x) << S_DEBUG_ST_DBP_UPCP_MAIN)
-#define G_DEBUG_ST_DBP_UPCP_MAIN(x) (((x) >> S_DEBUG_ST_DBP_UPCP_MAIN) & M_DEBUG_ST_DBP_UPCP_MAIN)
-
-#define S_DEBUG_ST_DBP_DBFIFO_MAIN 13
-#define V_DEBUG_ST_DBP_DBFIFO_MAIN(x) ((x) << S_DEBUG_ST_DBP_DBFIFO_MAIN)
-#define F_DEBUG_ST_DBP_DBFIFO_MAIN V_DEBUG_ST_DBP_DBFIFO_MAIN(1U)
-
-#define S_DEBUG_ST_DBP_CTXT 10
-#define M_DEBUG_ST_DBP_CTXT 0x7U
-#define V_DEBUG_ST_DBP_CTXT(x) ((x) << S_DEBUG_ST_DBP_CTXT)
-#define G_DEBUG_ST_DBP_CTXT(x) (((x) >> S_DEBUG_ST_DBP_CTXT) & M_DEBUG_ST_DBP_CTXT)
-
-#define S_DEBUG_ST_DBP_THREAD3_CIMFL 5
-#define M_DEBUG_ST_DBP_THREAD3_CIMFL 0x1fU
-#define V_DEBUG_ST_DBP_THREAD3_CIMFL(x) ((x) << S_DEBUG_ST_DBP_THREAD3_CIMFL)
-#define G_DEBUG_ST_DBP_THREAD3_CIMFL(x) (((x) >> S_DEBUG_ST_DBP_THREAD3_CIMFL) & M_DEBUG_ST_DBP_THREAD3_CIMFL)
-
-#define S_DEBUG_ST_DBP_THREAD3_MAIN 0
-#define M_DEBUG_ST_DBP_THREAD3_MAIN 0x1fU
-#define V_DEBUG_ST_DBP_THREAD3_MAIN(x) ((x) << S_DEBUG_ST_DBP_THREAD3_MAIN)
-#define G_DEBUG_ST_DBP_THREAD3_MAIN(x) (((x) >> S_DEBUG_ST_DBP_THREAD3_MAIN) & M_DEBUG_ST_DBP_THREAD3_MAIN)
-
-#define A_SGE_DEBUG_DATA_LOW_INDEX_4 0x12d0
-
-#define S_DEBUG_ST_EDMA3_ALIGN_SUB 29
-#define M_DEBUG_ST_EDMA3_ALIGN_SUB 0x7U
-#define V_DEBUG_ST_EDMA3_ALIGN_SUB(x) ((x) << S_DEBUG_ST_EDMA3_ALIGN_SUB)
-#define G_DEBUG_ST_EDMA3_ALIGN_SUB(x) (((x) >> S_DEBUG_ST_EDMA3_ALIGN_SUB) & M_DEBUG_ST_EDMA3_ALIGN_SUB)
-
-#define S_DEBUG_ST_EDMA3_ALIGN 27
-#define M_DEBUG_ST_EDMA3_ALIGN 0x3U
-#define V_DEBUG_ST_EDMA3_ALIGN(x) ((x) << S_DEBUG_ST_EDMA3_ALIGN)
-#define G_DEBUG_ST_EDMA3_ALIGN(x) (((x) >> S_DEBUG_ST_EDMA3_ALIGN) & M_DEBUG_ST_EDMA3_ALIGN)
-
-#define S_DEBUG_ST_EDMA3_REQ 24
-#define M_DEBUG_ST_EDMA3_REQ 0x7U
-#define V_DEBUG_ST_EDMA3_REQ(x) ((x) << S_DEBUG_ST_EDMA3_REQ)
-#define G_DEBUG_ST_EDMA3_REQ(x) (((x) >> S_DEBUG_ST_EDMA3_REQ) & M_DEBUG_ST_EDMA3_REQ)
-
-#define S_DEBUG_ST_EDMA2_ALIGN_SUB 21
-#define M_DEBUG_ST_EDMA2_ALIGN_SUB 0x7U
-#define V_DEBUG_ST_EDMA2_ALIGN_SUB(x) ((x) << S_DEBUG_ST_EDMA2_ALIGN_SUB)
-#define G_DEBUG_ST_EDMA2_ALIGN_SUB(x) (((x) >> S_DEBUG_ST_EDMA2_ALIGN_SUB) & M_DEBUG_ST_EDMA2_ALIGN_SUB)
-
-#define S_DEBUG_ST_EDMA2_ALIGN 19
-#define M_DEBUG_ST_EDMA2_ALIGN 0x3U
-#define V_DEBUG_ST_EDMA2_ALIGN(x) ((x) << S_DEBUG_ST_EDMA2_ALIGN)
-#define G_DEBUG_ST_EDMA2_ALIGN(x) (((x) >> S_DEBUG_ST_EDMA2_ALIGN) & M_DEBUG_ST_EDMA2_ALIGN)
-
-#define S_DEBUG_ST_EDMA2_REQ 16
-#define M_DEBUG_ST_EDMA2_REQ 0x7U
-#define V_DEBUG_ST_EDMA2_REQ(x) ((x) << S_DEBUG_ST_EDMA2_REQ)
-#define G_DEBUG_ST_EDMA2_REQ(x) (((x) >> S_DEBUG_ST_EDMA2_REQ) & M_DEBUG_ST_EDMA2_REQ)
-
-#define S_DEBUG_ST_EDMA1_ALIGN_SUB 13
-#define M_DEBUG_ST_EDMA1_ALIGN_SUB 0x7U
-#define V_DEBUG_ST_EDMA1_ALIGN_SUB(x) ((x) << S_DEBUG_ST_EDMA1_ALIGN_SUB)
-#define G_DEBUG_ST_EDMA1_ALIGN_SUB(x) (((x) >> S_DEBUG_ST_EDMA1_ALIGN_SUB) & M_DEBUG_ST_EDMA1_ALIGN_SUB)
-
-#define S_DEBUG_ST_EDMA1_ALIGN 11
-#define M_DEBUG_ST_EDMA1_ALIGN 0x3U
-#define V_DEBUG_ST_EDMA1_ALIGN(x) ((x) << S_DEBUG_ST_EDMA1_ALIGN)
-#define G_DEBUG_ST_EDMA1_ALIGN(x) (((x) >> S_DEBUG_ST_EDMA1_ALIGN) & M_DEBUG_ST_EDMA1_ALIGN)
-
-#define S_DEBUG_ST_EDMA1_REQ 8
-#define M_DEBUG_ST_EDMA1_REQ 0x7U
-#define V_DEBUG_ST_EDMA1_REQ(x) ((x) << S_DEBUG_ST_EDMA1_REQ)
-#define G_DEBUG_ST_EDMA1_REQ(x) (((x) >> S_DEBUG_ST_EDMA1_REQ) & M_DEBUG_ST_EDMA1_REQ)
-
-#define S_DEBUG_ST_EDMA0_ALIGN_SUB 5
-#define M_DEBUG_ST_EDMA0_ALIGN_SUB 0x7U
-#define V_DEBUG_ST_EDMA0_ALIGN_SUB(x) ((x) << S_DEBUG_ST_EDMA0_ALIGN_SUB)
-#define G_DEBUG_ST_EDMA0_ALIGN_SUB(x) (((x) >> S_DEBUG_ST_EDMA0_ALIGN_SUB) & M_DEBUG_ST_EDMA0_ALIGN_SUB)
-
-#define S_DEBUG_ST_EDMA0_ALIGN 3
-#define M_DEBUG_ST_EDMA0_ALIGN 0x3U
-#define V_DEBUG_ST_EDMA0_ALIGN(x) ((x) << S_DEBUG_ST_EDMA0_ALIGN)
-#define G_DEBUG_ST_EDMA0_ALIGN(x) (((x) >> S_DEBUG_ST_EDMA0_ALIGN) & M_DEBUG_ST_EDMA0_ALIGN)
-
-#define S_DEBUG_ST_EDMA0_REQ 0
-#define M_DEBUG_ST_EDMA0_REQ 0x7U
-#define V_DEBUG_ST_EDMA0_REQ(x) ((x) << S_DEBUG_ST_EDMA0_REQ)
-#define G_DEBUG_ST_EDMA0_REQ(x) (((x) >> S_DEBUG_ST_EDMA0_REQ) & M_DEBUG_ST_EDMA0_REQ)
-
-#define A_SGE_DEBUG_DATA_LOW_INDEX_5 0x12d4
-
-#define S_DEBUG_ST_FLM_DBPTR 30
-#define M_DEBUG_ST_FLM_DBPTR 0x3U
-#define V_DEBUG_ST_FLM_DBPTR(x) ((x) << S_DEBUG_ST_FLM_DBPTR)
-#define G_DEBUG_ST_FLM_DBPTR(x) (((x) >> S_DEBUG_ST_FLM_DBPTR) & M_DEBUG_ST_FLM_DBPTR)
-
-#define S_DEBUG_FLM_CACHE_LOCKED_COUNT 23
-#define M_DEBUG_FLM_CACHE_LOCKED_COUNT 0x7fU
-#define V_DEBUG_FLM_CACHE_LOCKED_COUNT(x) ((x) << S_DEBUG_FLM_CACHE_LOCKED_COUNT)
-#define G_DEBUG_FLM_CACHE_LOCKED_COUNT(x) (((x) >> S_DEBUG_FLM_CACHE_LOCKED_COUNT) & M_DEBUG_FLM_CACHE_LOCKED_COUNT)
-
-#define S_DEBUG_FLM_CACHE_AGENT 20
-#define M_DEBUG_FLM_CACHE_AGENT 0x7U
-#define V_DEBUG_FLM_CACHE_AGENT(x) ((x) << S_DEBUG_FLM_CACHE_AGENT)
-#define G_DEBUG_FLM_CACHE_AGENT(x) (((x) >> S_DEBUG_FLM_CACHE_AGENT) & M_DEBUG_FLM_CACHE_AGENT)
-
-#define S_DEBUG_ST_FLM_CACHE 16
-#define M_DEBUG_ST_FLM_CACHE 0xfU
-#define V_DEBUG_ST_FLM_CACHE(x) ((x) << S_DEBUG_ST_FLM_CACHE)
-#define G_DEBUG_ST_FLM_CACHE(x) (((x) >> S_DEBUG_ST_FLM_CACHE) & M_DEBUG_ST_FLM_CACHE)
-
-#define S_DEBUG_FLM_DBPTR_CIDX_STALL 12
-#define V_DEBUG_FLM_DBPTR_CIDX_STALL(x) ((x) << S_DEBUG_FLM_DBPTR_CIDX_STALL)
-#define F_DEBUG_FLM_DBPTR_CIDX_STALL V_DEBUG_FLM_DBPTR_CIDX_STALL(1U)
-
-#define S_DEBUG_FLM_DBPTR_QID 0
-#define M_DEBUG_FLM_DBPTR_QID 0xfffU
-#define V_DEBUG_FLM_DBPTR_QID(x) ((x) << S_DEBUG_FLM_DBPTR_QID)
-#define G_DEBUG_FLM_DBPTR_QID(x) (((x) >> S_DEBUG_FLM_DBPTR_QID) & M_DEBUG_FLM_DBPTR_QID)
-
-#define A_SGE_DEBUG0_DBP_THREAD 0x12d4
-
-#define S_THREAD_ST_MAIN 25
-#define M_THREAD_ST_MAIN 0x3fU
-#define V_THREAD_ST_MAIN(x) ((x) << S_THREAD_ST_MAIN)
-#define G_THREAD_ST_MAIN(x) (((x) >> S_THREAD_ST_MAIN) & M_THREAD_ST_MAIN)
-
-#define S_THREAD_ST_CIMFL 21
-#define M_THREAD_ST_CIMFL 0xfU
-#define V_THREAD_ST_CIMFL(x) ((x) << S_THREAD_ST_CIMFL)
-#define G_THREAD_ST_CIMFL(x) (((x) >> S_THREAD_ST_CIMFL) & M_THREAD_ST_CIMFL)
-
-#define S_THREAD_CMDOP 17
-#define M_THREAD_CMDOP 0xfU
-#define V_THREAD_CMDOP(x) ((x) << S_THREAD_CMDOP)
-#define G_THREAD_CMDOP(x) (((x) >> S_THREAD_CMDOP) & M_THREAD_CMDOP)
-
-#define S_THREAD_QID 0
-#define M_THREAD_QID 0x1ffffU
-#define V_THREAD_QID(x) ((x) << S_THREAD_QID)
-#define G_THREAD_QID(x) (((x) >> S_THREAD_QID) & M_THREAD_QID)
-
-#define A_SGE_DEBUG_DATA_LOW_INDEX_6 0x12d8
-
-#define S_DEBUG_DBP_THREAD0_QID 0
-#define M_DEBUG_DBP_THREAD0_QID 0x1ffffU
-#define V_DEBUG_DBP_THREAD0_QID(x) ((x) << S_DEBUG_DBP_THREAD0_QID)
-#define G_DEBUG_DBP_THREAD0_QID(x) (((x) >> S_DEBUG_DBP_THREAD0_QID) & M_DEBUG_DBP_THREAD0_QID)
-
-#define A_SGE_DEBUG_DATA_LOW_INDEX_7 0x12dc
-
-#define S_DEBUG_DBP_THREAD1_QID 0
-#define M_DEBUG_DBP_THREAD1_QID 0x1ffffU
-#define V_DEBUG_DBP_THREAD1_QID(x) ((x) << S_DEBUG_DBP_THREAD1_QID)
-#define G_DEBUG_DBP_THREAD1_QID(x) (((x) >> S_DEBUG_DBP_THREAD1_QID) & M_DEBUG_DBP_THREAD1_QID)
-
-#define A_SGE_DEBUG_DATA_LOW_INDEX_8 0x12e0
-
-#define S_DEBUG_DBP_THREAD2_QID 0
-#define M_DEBUG_DBP_THREAD2_QID 0x1ffffU
-#define V_DEBUG_DBP_THREAD2_QID(x) ((x) << S_DEBUG_DBP_THREAD2_QID)
-#define G_DEBUG_DBP_THREAD2_QID(x) (((x) >> S_DEBUG_DBP_THREAD2_QID) & M_DEBUG_DBP_THREAD2_QID)
-
-#define A_SGE_DEBUG_DATA_LOW_INDEX_9 0x12e4
-
-#define S_DEBUG_DBP_THREAD3_QID 0
-#define M_DEBUG_DBP_THREAD3_QID 0x1ffffU
-#define V_DEBUG_DBP_THREAD3_QID(x) ((x) << S_DEBUG_DBP_THREAD3_QID)
-#define G_DEBUG_DBP_THREAD3_QID(x) (((x) >> S_DEBUG_DBP_THREAD3_QID) & M_DEBUG_DBP_THREAD3_QID)
-
-#define A_SGE_DEBUG_DATA_LOW_INDEX_10 0x12e8
-
-#define S_DEBUG_IMSG_CPL 16
-#define M_DEBUG_IMSG_CPL 0xffU
-#define V_DEBUG_IMSG_CPL(x) ((x) << S_DEBUG_IMSG_CPL)
-#define G_DEBUG_IMSG_CPL(x) (((x) >> S_DEBUG_IMSG_CPL) & M_DEBUG_IMSG_CPL)
-
-#define S_DEBUG_IMSG_QID 0
-#define M_DEBUG_IMSG_QID 0xffffU
-#define V_DEBUG_IMSG_QID(x) ((x) << S_DEBUG_IMSG_QID)
-#define G_DEBUG_IMSG_QID(x) (((x) >> S_DEBUG_IMSG_QID) & M_DEBUG_IMSG_QID)
-
-#define A_SGE_DEBUG_DATA_LOW_INDEX_11 0x12ec
-
-#define S_DEBUG_IDMA1_QID 16
-#define M_DEBUG_IDMA1_QID 0xffffU
-#define V_DEBUG_IDMA1_QID(x) ((x) << S_DEBUG_IDMA1_QID)
-#define G_DEBUG_IDMA1_QID(x) (((x) >> S_DEBUG_IDMA1_QID) & M_DEBUG_IDMA1_QID)
-
-#define S_DEBUG_IDMA0_QID 0
-#define M_DEBUG_IDMA0_QID 0xffffU
-#define V_DEBUG_IDMA0_QID(x) ((x) << S_DEBUG_IDMA0_QID)
-#define G_DEBUG_IDMA0_QID(x) (((x) >> S_DEBUG_IDMA0_QID) & M_DEBUG_IDMA0_QID)
-
-#define A_SGE_DEBUG_DATA_LOW_INDEX_12 0x12f0
-
-#define S_DEBUG_IDMA1_FLM_REQ_QID 16
-#define M_DEBUG_IDMA1_FLM_REQ_QID 0xffffU
-#define V_DEBUG_IDMA1_FLM_REQ_QID(x) ((x) << S_DEBUG_IDMA1_FLM_REQ_QID)
-#define G_DEBUG_IDMA1_FLM_REQ_QID(x) (((x) >> S_DEBUG_IDMA1_FLM_REQ_QID) & M_DEBUG_IDMA1_FLM_REQ_QID)
-
-#define S_DEBUG_IDMA0_FLM_REQ_QID 0
-#define M_DEBUG_IDMA0_FLM_REQ_QID 0xffffU
-#define V_DEBUG_IDMA0_FLM_REQ_QID(x) ((x) << S_DEBUG_IDMA0_FLM_REQ_QID)
-#define G_DEBUG_IDMA0_FLM_REQ_QID(x) (((x) >> S_DEBUG_IDMA0_FLM_REQ_QID) & M_DEBUG_IDMA0_FLM_REQ_QID)
-
-#define A_SGE_DEBUG_DATA_LOW_INDEX_13 0x12f4
-#define A_SGE_DEBUG_DATA_LOW_INDEX_14 0x12f8
-#define A_SGE_DEBUG_DATA_LOW_INDEX_15 0x12fc
-#define A_SGE_QUEUE_BASE_MAP_HIGH 0x1300
-
-#define S_EGRESS_LOG2SIZE 27
-#define M_EGRESS_LOG2SIZE 0x1fU
-#define V_EGRESS_LOG2SIZE(x) ((x) << S_EGRESS_LOG2SIZE)
-#define G_EGRESS_LOG2SIZE(x) (((x) >> S_EGRESS_LOG2SIZE) & M_EGRESS_LOG2SIZE)
-
-#define S_EGRESS_BASE 10
-#define M_EGRESS_BASE 0x1ffffU
-#define V_EGRESS_BASE(x) ((x) << S_EGRESS_BASE)
-#define G_EGRESS_BASE(x) (((x) >> S_EGRESS_BASE) & M_EGRESS_BASE)
-
-#define S_INGRESS2_LOG2SIZE 5
-#define M_INGRESS2_LOG2SIZE 0x1fU
-#define V_INGRESS2_LOG2SIZE(x) ((x) << S_INGRESS2_LOG2SIZE)
-#define G_INGRESS2_LOG2SIZE(x) (((x) >> S_INGRESS2_LOG2SIZE) & M_INGRESS2_LOG2SIZE)
-
-#define S_INGRESS1_LOG2SIZE 0
-#define M_INGRESS1_LOG2SIZE 0x1fU
-#define V_INGRESS1_LOG2SIZE(x) ((x) << S_INGRESS1_LOG2SIZE)
-#define G_INGRESS1_LOG2SIZE(x) (((x) >> S_INGRESS1_LOG2SIZE) & M_INGRESS1_LOG2SIZE)
-
-#define S_EGRESS_SIZE 27
-#define M_EGRESS_SIZE 0x1fU
-#define V_EGRESS_SIZE(x) ((x) << S_EGRESS_SIZE)
-#define G_EGRESS_SIZE(x) (((x) >> S_EGRESS_SIZE) & M_EGRESS_SIZE)
-
-#define S_INGRESS2_SIZE 5
-#define M_INGRESS2_SIZE 0x1fU
-#define V_INGRESS2_SIZE(x) ((x) << S_INGRESS2_SIZE)
-#define G_INGRESS2_SIZE(x) (((x) >> S_INGRESS2_SIZE) & M_INGRESS2_SIZE)
-
-#define S_INGRESS1_SIZE 0
-#define M_INGRESS1_SIZE 0x1fU
-#define V_INGRESS1_SIZE(x) ((x) << S_INGRESS1_SIZE)
-#define G_INGRESS1_SIZE(x) (((x) >> S_INGRESS1_SIZE) & M_INGRESS1_SIZE)
-
-#define A_SGE_WC_EGRS_BAR2_OFF_PF 0x1300
-
-#define S_PFIQSPERPAGE 28
-#define M_PFIQSPERPAGE 0xfU
-#define V_PFIQSPERPAGE(x) ((x) << S_PFIQSPERPAGE)
-#define G_PFIQSPERPAGE(x) (((x) >> S_PFIQSPERPAGE) & M_PFIQSPERPAGE)
-
-#define S_PFEQSPERPAGE 24
-#define M_PFEQSPERPAGE 0xfU
-#define V_PFEQSPERPAGE(x) ((x) << S_PFEQSPERPAGE)
-#define G_PFEQSPERPAGE(x) (((x) >> S_PFEQSPERPAGE) & M_PFEQSPERPAGE)
-
-#define S_PFWCQSPERPAGE 20
-#define M_PFWCQSPERPAGE 0xfU
-#define V_PFWCQSPERPAGE(x) ((x) << S_PFWCQSPERPAGE)
-#define G_PFWCQSPERPAGE(x) (((x) >> S_PFWCQSPERPAGE) & M_PFWCQSPERPAGE)
-
-#define S_PFWCOFFEN 19
-#define V_PFWCOFFEN(x) ((x) << S_PFWCOFFEN)
-#define F_PFWCOFFEN V_PFWCOFFEN(1U)
-
-#define S_PFMAXWCSIZE 17
-#define M_PFMAXWCSIZE 0x3U
-#define V_PFMAXWCSIZE(x) ((x) << S_PFMAXWCSIZE)
-#define G_PFMAXWCSIZE(x) (((x) >> S_PFMAXWCSIZE) & M_PFMAXWCSIZE)
-
-#define S_PFWCOFFSET 0
-#define M_PFWCOFFSET 0x1ffffU
-#define V_PFWCOFFSET(x) ((x) << S_PFWCOFFSET)
-#define G_PFWCOFFSET(x) (((x) >> S_PFWCOFFSET) & M_PFWCOFFSET)
-
-#define A_SGE_QUEUE_BASE_MAP_LOW 0x1304
-
-#define S_INGRESS2_BASE 16
-#define M_INGRESS2_BASE 0xffffU
-#define V_INGRESS2_BASE(x) ((x) << S_INGRESS2_BASE)
-#define G_INGRESS2_BASE(x) (((x) >> S_INGRESS2_BASE) & M_INGRESS2_BASE)
-
-#define S_INGRESS1_BASE 0
-#define M_INGRESS1_BASE 0xffffU
-#define V_INGRESS1_BASE(x) ((x) << S_INGRESS1_BASE)
-#define G_INGRESS1_BASE(x) (((x) >> S_INGRESS1_BASE) & M_INGRESS1_BASE)
-
-#define A_SGE_WC_EGRS_BAR2_OFF_VF 0x1320
-
-#define S_VFIQSPERPAGE 28
-#define M_VFIQSPERPAGE 0xfU
-#define V_VFIQSPERPAGE(x) ((x) << S_VFIQSPERPAGE)
-#define G_VFIQSPERPAGE(x) (((x) >> S_VFIQSPERPAGE) & M_VFIQSPERPAGE)
-
-#define S_VFEQSPERPAGE 24
-#define M_VFEQSPERPAGE 0xfU
-#define V_VFEQSPERPAGE(x) ((x) << S_VFEQSPERPAGE)
-#define G_VFEQSPERPAGE(x) (((x) >> S_VFEQSPERPAGE) & M_VFEQSPERPAGE)
-
-#define S_VFWCQSPERPAGE 20
-#define M_VFWCQSPERPAGE 0xfU
-#define V_VFWCQSPERPAGE(x) ((x) << S_VFWCQSPERPAGE)
-#define G_VFWCQSPERPAGE(x) (((x) >> S_VFWCQSPERPAGE) & M_VFWCQSPERPAGE)
-
-#define S_VFWCOFFEN 19
-#define V_VFWCOFFEN(x) ((x) << S_VFWCOFFEN)
-#define F_VFWCOFFEN V_VFWCOFFEN(1U)
-
-#define S_VFMAXWCSIZE 17
-#define M_VFMAXWCSIZE 0x3U
-#define V_VFMAXWCSIZE(x) ((x) << S_VFMAXWCSIZE)
-#define G_VFMAXWCSIZE(x) (((x) >> S_VFMAXWCSIZE) & M_VFMAXWCSIZE)
-
-#define S_VFWCOFFSET 0
-#define M_VFWCOFFSET 0x1ffffU
-#define V_VFWCOFFSET(x) ((x) << S_VFWCOFFSET)
-#define G_VFWCOFFSET(x) (((x) >> S_VFWCOFFSET) & M_VFWCOFFSET)
-
-#define A_SGE_LA_RDPTR_0 0x1800
-#define A_SGE_LA_RDDATA_0 0x1804
-#define A_SGE_LA_WRPTR_0 0x1808
-#define A_SGE_LA_RESERVED_0 0x180c
-#define A_SGE_LA_RDPTR_1 0x1810
-#define A_SGE_LA_RDDATA_1 0x1814
-#define A_SGE_LA_WRPTR_1 0x1818
-#define A_SGE_LA_RESERVED_1 0x181c
-#define A_SGE_LA_RDPTR_2 0x1820
-#define A_SGE_LA_RDDATA_2 0x1824
-#define A_SGE_LA_WRPTR_2 0x1828
-#define A_SGE_LA_RESERVED_2 0x182c
-#define A_SGE_LA_RDPTR_3 0x1830
-#define A_SGE_LA_RDDATA_3 0x1834
-#define A_SGE_LA_WRPTR_3 0x1838
-#define A_SGE_LA_RESERVED_3 0x183c
-#define A_SGE_LA_RDPTR_4 0x1840
-#define A_SGE_LA_RDDATA_4 0x1844
-#define A_SGE_LA_WRPTR_4 0x1848
-#define A_SGE_LA_RESERVED_4 0x184c
-#define A_SGE_LA_RDPTR_5 0x1850
-#define A_SGE_LA_RDDATA_5 0x1854
-#define A_SGE_LA_WRPTR_5 0x1858
-#define A_SGE_LA_RESERVED_5 0x185c
-#define A_SGE_LA_RDPTR_6 0x1860
-#define A_SGE_LA_RDDATA_6 0x1864
-#define A_SGE_LA_WRPTR_6 0x1868
-#define A_SGE_LA_RESERVED_6 0x186c
-#define A_SGE_LA_RDPTR_7 0x1870
-#define A_SGE_LA_RDDATA_7 0x1874
-#define A_SGE_LA_WRPTR_7 0x1878
-#define A_SGE_LA_RESERVED_7 0x187c
-#define A_SGE_LA_RDPTR_8 0x1880
-#define A_SGE_LA_RDDATA_8 0x1884
-#define A_SGE_LA_WRPTR_8 0x1888
-#define A_SGE_LA_RESERVED_8 0x188c
-#define A_SGE_LA_RDPTR_9 0x1890
-#define A_SGE_LA_RDDATA_9 0x1894
-#define A_SGE_LA_WRPTR_9 0x1898
-#define A_SGE_LA_RESERVED_9 0x189c
-#define A_SGE_LA_RDPTR_10 0x18a0
-#define A_SGE_LA_RDDATA_10 0x18a4
-#define A_SGE_LA_WRPTR_10 0x18a8
-#define A_SGE_LA_RESERVED_10 0x18ac
-#define A_SGE_LA_RDPTR_11 0x18b0
-#define A_SGE_LA_RDDATA_11 0x18b4
-#define A_SGE_LA_WRPTR_11 0x18b8
-#define A_SGE_LA_RESERVED_11 0x18bc
-#define A_SGE_LA_RDPTR_12 0x18c0
-#define A_SGE_LA_RDDATA_12 0x18c4
-#define A_SGE_LA_WRPTR_12 0x18c8
-#define A_SGE_LA_RESERVED_12 0x18cc
-#define A_SGE_LA_RDPTR_13 0x18d0
-#define A_SGE_LA_RDDATA_13 0x18d4
-#define A_SGE_LA_WRPTR_13 0x18d8
-#define A_SGE_LA_RESERVED_13 0x18dc
-#define A_SGE_LA_RDPTR_14 0x18e0
-#define A_SGE_LA_RDDATA_14 0x18e4
-#define A_SGE_LA_WRPTR_14 0x18e8
-#define A_SGE_LA_RESERVED_14 0x18ec
-#define A_SGE_LA_RDPTR_15 0x18f0
-#define A_SGE_LA_RDDATA_15 0x18f4
-#define A_SGE_LA_WRPTR_15 0x18f8
-#define A_SGE_LA_RESERVED_15 0x18fc
-
-/* registers for module PCIE */
-#define PCIE_BASE_ADDR 0x3000
-
-#define A_PCIE_PF_CFG 0x40
-
-#define S_INTXSTAT 16
-#define V_INTXSTAT(x) ((x) << S_INTXSTAT)
-#define F_INTXSTAT V_INTXSTAT(1U)
-
-#define S_AUXPWRPMEN 15
-#define V_AUXPWRPMEN(x) ((x) << S_AUXPWRPMEN)
-#define F_AUXPWRPMEN V_AUXPWRPMEN(1U)
-
-#define S_NOSOFTRESET 14
-#define V_NOSOFTRESET(x) ((x) << S_NOSOFTRESET)
-#define F_NOSOFTRESET V_NOSOFTRESET(1U)
-
-#define S_AIVEC 4
-#define M_AIVEC 0x3ffU
-#define V_AIVEC(x) ((x) << S_AIVEC)
-#define G_AIVEC(x) (((x) >> S_AIVEC) & M_AIVEC)
-
-#define S_INTXTYPE 2
-#define M_INTXTYPE 0x3U
-#define V_INTXTYPE(x) ((x) << S_INTXTYPE)
-#define G_INTXTYPE(x) (((x) >> S_INTXTYPE) & M_INTXTYPE)
-
-#define S_D3HOTEN 1
-#define V_D3HOTEN(x) ((x) << S_D3HOTEN)
-#define F_D3HOTEN V_D3HOTEN(1U)
-
-#define S_CLIDECEN 0
-#define V_CLIDECEN(x) ((x) << S_CLIDECEN)
-#define F_CLIDECEN V_CLIDECEN(1U)
-
-#define A_PCIE_PF_CLI 0x44
-#define A_PCIE_PF_GEN_MSG 0x48
-
-#define S_MSGTYPE 0
-#define M_MSGTYPE 0xffU
-#define V_MSGTYPE(x) ((x) << S_MSGTYPE)
-#define G_MSGTYPE(x) (((x) >> S_MSGTYPE) & M_MSGTYPE)
-
-#define A_PCIE_PF_EXPROM_OFST 0x4c
-
-#define S_OFFSET 10
-#define M_OFFSET 0x3fffU
-#define V_OFFSET(x) ((x) << S_OFFSET)
-#define G_OFFSET(x) (((x) >> S_OFFSET) & M_OFFSET)
-
-#define A_PCIE_INT_ENABLE 0x3000
-
-#define S_NONFATALERR 30
-#define V_NONFATALERR(x) ((x) << S_NONFATALERR)
-#define F_NONFATALERR V_NONFATALERR(1U)
-
-#define S_UNXSPLCPLERR 29
-#define V_UNXSPLCPLERR(x) ((x) << S_UNXSPLCPLERR)
-#define F_UNXSPLCPLERR V_UNXSPLCPLERR(1U)
-
-#define S_PCIEPINT 28
-#define V_PCIEPINT(x) ((x) << S_PCIEPINT)
-#define F_PCIEPINT V_PCIEPINT(1U)
-
-#define S_PCIESINT 27
-#define V_PCIESINT(x) ((x) << S_PCIESINT)
-#define F_PCIESINT V_PCIESINT(1U)
-
-#define S_RPLPERR 26
-#define V_RPLPERR(x) ((x) << S_RPLPERR)
-#define F_RPLPERR V_RPLPERR(1U)
-
-#define S_RXWRPERR 25
-#define V_RXWRPERR(x) ((x) << S_RXWRPERR)
-#define F_RXWRPERR V_RXWRPERR(1U)
-
-#define S_RXCPLPERR 24
-#define V_RXCPLPERR(x) ((x) << S_RXCPLPERR)
-#define F_RXCPLPERR V_RXCPLPERR(1U)
-
-#define S_PIOTAGPERR 23
-#define V_PIOTAGPERR(x) ((x) << S_PIOTAGPERR)
-#define F_PIOTAGPERR V_PIOTAGPERR(1U)
-
-#define S_MATAGPERR 22
-#define V_MATAGPERR(x) ((x) << S_MATAGPERR)
-#define F_MATAGPERR V_MATAGPERR(1U)
-
-#define S_INTXCLRPERR 21
-#define V_INTXCLRPERR(x) ((x) << S_INTXCLRPERR)
-#define F_INTXCLRPERR V_INTXCLRPERR(1U)
-
-#define S_FIDPERR 20
-#define V_FIDPERR(x) ((x) << S_FIDPERR)
-#define F_FIDPERR V_FIDPERR(1U)
-
-#define S_CFGSNPPERR 19
-#define V_CFGSNPPERR(x) ((x) << S_CFGSNPPERR)
-#define F_CFGSNPPERR V_CFGSNPPERR(1U)
-
-#define S_HRSPPERR 18
-#define V_HRSPPERR(x) ((x) << S_HRSPPERR)
-#define F_HRSPPERR V_HRSPPERR(1U)
-
-#define S_HREQPERR 17
-#define V_HREQPERR(x) ((x) << S_HREQPERR)
-#define F_HREQPERR V_HREQPERR(1U)
-
-#define S_HCNTPERR 16
-#define V_HCNTPERR(x) ((x) << S_HCNTPERR)
-#define F_HCNTPERR V_HCNTPERR(1U)
-
-#define S_DRSPPERR 15
-#define V_DRSPPERR(x) ((x) << S_DRSPPERR)
-#define F_DRSPPERR V_DRSPPERR(1U)
-
-#define S_DREQPERR 14
-#define V_DREQPERR(x) ((x) << S_DREQPERR)
-#define F_DREQPERR V_DREQPERR(1U)
-
-#define S_DCNTPERR 13
-#define V_DCNTPERR(x) ((x) << S_DCNTPERR)
-#define F_DCNTPERR V_DCNTPERR(1U)
-
-#define S_CRSPPERR 12
-#define V_CRSPPERR(x) ((x) << S_CRSPPERR)
-#define F_CRSPPERR V_CRSPPERR(1U)
-
-#define S_CREQPERR 11
-#define V_CREQPERR(x) ((x) << S_CREQPERR)
-#define F_CREQPERR V_CREQPERR(1U)
-
-#define S_CCNTPERR 10
-#define V_CCNTPERR(x) ((x) << S_CCNTPERR)
-#define F_CCNTPERR V_CCNTPERR(1U)
-
-#define S_TARTAGPERR 9
-#define V_TARTAGPERR(x) ((x) << S_TARTAGPERR)
-#define F_TARTAGPERR V_TARTAGPERR(1U)
-
-#define S_PIOREQPERR 8
-#define V_PIOREQPERR(x) ((x) << S_PIOREQPERR)
-#define F_PIOREQPERR V_PIOREQPERR(1U)
-
-#define S_PIOCPLPERR 7
-#define V_PIOCPLPERR(x) ((x) << S_PIOCPLPERR)
-#define F_PIOCPLPERR V_PIOCPLPERR(1U)
-
-#define S_MSIXDIPERR 6
-#define V_MSIXDIPERR(x) ((x) << S_MSIXDIPERR)
-#define F_MSIXDIPERR V_MSIXDIPERR(1U)
-
-#define S_MSIXDATAPERR 5
-#define V_MSIXDATAPERR(x) ((x) << S_MSIXDATAPERR)
-#define F_MSIXDATAPERR V_MSIXDATAPERR(1U)
-
-#define S_MSIXADDRHPERR 4
-#define V_MSIXADDRHPERR(x) ((x) << S_MSIXADDRHPERR)
-#define F_MSIXADDRHPERR V_MSIXADDRHPERR(1U)
-
-#define S_MSIXADDRLPERR 3
-#define V_MSIXADDRLPERR(x) ((x) << S_MSIXADDRLPERR)
-#define F_MSIXADDRLPERR V_MSIXADDRLPERR(1U)
-
-#define S_MSIDATAPERR 2
-#define V_MSIDATAPERR(x) ((x) << S_MSIDATAPERR)
-#define F_MSIDATAPERR V_MSIDATAPERR(1U)
-
-#define S_MSIADDRHPERR 1
-#define V_MSIADDRHPERR(x) ((x) << S_MSIADDRHPERR)
-#define F_MSIADDRHPERR V_MSIADDRHPERR(1U)
-
-#define S_MSIADDRLPERR 0
-#define V_MSIADDRLPERR(x) ((x) << S_MSIADDRLPERR)
-#define F_MSIADDRLPERR V_MSIADDRLPERR(1U)
-
-#define S_IPGRPPERR 31
-#define V_IPGRPPERR(x) ((x) << S_IPGRPPERR)
-#define F_IPGRPPERR V_IPGRPPERR(1U)
-
-#define S_READRSPERR 29
-#define V_READRSPERR(x) ((x) << S_READRSPERR)
-#define F_READRSPERR V_READRSPERR(1U)
-
-#define S_TRGT1GRPPERR 28
-#define V_TRGT1GRPPERR(x) ((x) << S_TRGT1GRPPERR)
-#define F_TRGT1GRPPERR V_TRGT1GRPPERR(1U)
-
-#define S_IPSOTPERR 27
-#define V_IPSOTPERR(x) ((x) << S_IPSOTPERR)
-#define F_IPSOTPERR V_IPSOTPERR(1U)
-
-#define S_IPRETRYPERR 26
-#define V_IPRETRYPERR(x) ((x) << S_IPRETRYPERR)
-#define F_IPRETRYPERR V_IPRETRYPERR(1U)
-
-#define S_IPRXDATAGRPPERR 25
-#define V_IPRXDATAGRPPERR(x) ((x) << S_IPRXDATAGRPPERR)
-#define F_IPRXDATAGRPPERR V_IPRXDATAGRPPERR(1U)
-
-#define S_IPRXHDRGRPPERR 24
-#define V_IPRXHDRGRPPERR(x) ((x) << S_IPRXHDRGRPPERR)
-#define F_IPRXHDRGRPPERR V_IPRXHDRGRPPERR(1U)
-
-#define S_PIOTAGQPERR 23
-#define V_PIOTAGQPERR(x) ((x) << S_PIOTAGQPERR)
-#define F_PIOTAGQPERR V_PIOTAGQPERR(1U)
-
-#define S_MAGRPPERR 22
-#define V_MAGRPPERR(x) ((x) << S_MAGRPPERR)
-#define F_MAGRPPERR V_MAGRPPERR(1U)
-
-#define S_VFIDPERR 21
-#define V_VFIDPERR(x) ((x) << S_VFIDPERR)
-#define F_VFIDPERR V_VFIDPERR(1U)
-
-#define S_HREQRDPERR 17
-#define V_HREQRDPERR(x) ((x) << S_HREQRDPERR)
-#define F_HREQRDPERR V_HREQRDPERR(1U)
-
-#define S_HREQWRPERR 16
-#define V_HREQWRPERR(x) ((x) << S_HREQWRPERR)
-#define F_HREQWRPERR V_HREQWRPERR(1U)
-
-#define S_DREQRDPERR 14
-#define V_DREQRDPERR(x) ((x) << S_DREQRDPERR)
-#define F_DREQRDPERR V_DREQRDPERR(1U)
-
-#define S_DREQWRPERR 13
-#define V_DREQWRPERR(x) ((x) << S_DREQWRPERR)
-#define F_DREQWRPERR V_DREQWRPERR(1U)
-
-#define S_CREQRDPERR 11
-#define V_CREQRDPERR(x) ((x) << S_CREQRDPERR)
-#define F_CREQRDPERR V_CREQRDPERR(1U)
-
-#define S_MSTTAGQPERR 10
-#define V_MSTTAGQPERR(x) ((x) << S_MSTTAGQPERR)
-#define F_MSTTAGQPERR V_MSTTAGQPERR(1U)
-
-#define S_TGTTAGQPERR 9
-#define V_TGTTAGQPERR(x) ((x) << S_TGTTAGQPERR)
-#define F_TGTTAGQPERR V_TGTTAGQPERR(1U)
-
-#define S_PIOREQGRPPERR 8
-#define V_PIOREQGRPPERR(x) ((x) << S_PIOREQGRPPERR)
-#define F_PIOREQGRPPERR V_PIOREQGRPPERR(1U)
-
-#define S_PIOCPLGRPPERR 7
-#define V_PIOCPLGRPPERR(x) ((x) << S_PIOCPLGRPPERR)
-#define F_PIOCPLGRPPERR V_PIOCPLGRPPERR(1U)
-
-#define S_MSIXSTIPERR 2
-#define V_MSIXSTIPERR(x) ((x) << S_MSIXSTIPERR)
-#define F_MSIXSTIPERR V_MSIXSTIPERR(1U)
-
-#define S_MSTTIMEOUTPERR 1
-#define V_MSTTIMEOUTPERR(x) ((x) << S_MSTTIMEOUTPERR)
-#define F_MSTTIMEOUTPERR V_MSTTIMEOUTPERR(1U)
-
-#define S_MSTGRPPERR 0
-#define V_MSTGRPPERR(x) ((x) << S_MSTGRPPERR)
-#define F_MSTGRPPERR V_MSTGRPPERR(1U)
-
-#define A_PCIE_INT_CAUSE 0x3004
-#define A_PCIE_PERR_ENABLE 0x3008
-#define A_PCIE_PERR_INJECT 0x300c
-
-#define S_IDE 0
-#define V_IDE(x) ((x) << S_IDE)
-#define F_IDE V_IDE(1U)
-
-#define S_MEMSEL_PCIE 1
-#define M_MEMSEL_PCIE 0x1fU
-#define V_MEMSEL_PCIE(x) ((x) << S_MEMSEL_PCIE)
-#define G_MEMSEL_PCIE(x) (((x) >> S_MEMSEL_PCIE) & M_MEMSEL_PCIE)
-
-#define A_PCIE_NONFAT_ERR 0x3010
-
-#define S_RDRSPERR 9
-#define V_RDRSPERR(x) ((x) << S_RDRSPERR)
-#define F_RDRSPERR V_RDRSPERR(1U)
-
-#define S_VPDRSPERR 8
-#define V_VPDRSPERR(x) ((x) << S_VPDRSPERR)
-#define F_VPDRSPERR V_VPDRSPERR(1U)
-
-#define S_POPD 7
-#define V_POPD(x) ((x) << S_POPD)
-#define F_POPD V_POPD(1U)
-
-#define S_POPH 6
-#define V_POPH(x) ((x) << S_POPH)
-#define F_POPH V_POPH(1U)
-
-#define S_POPC 5
-#define V_POPC(x) ((x) << S_POPC)
-#define F_POPC V_POPC(1U)
-
-#define S_MEMREQ 4
-#define V_MEMREQ(x) ((x) << S_MEMREQ)
-#define F_MEMREQ V_MEMREQ(1U)
-
-#define S_PIOREQ 3
-#define V_PIOREQ(x) ((x) << S_PIOREQ)
-#define F_PIOREQ V_PIOREQ(1U)
-
-#define S_TAGDROP 2
-#define V_TAGDROP(x) ((x) << S_TAGDROP)
-#define F_TAGDROP V_TAGDROP(1U)
-
-#define S_TAGCPL 1
-#define V_TAGCPL(x) ((x) << S_TAGCPL)
-#define F_TAGCPL V_TAGCPL(1U)
-
-#define S_CFGSNP 0
-#define V_CFGSNP(x) ((x) << S_CFGSNP)
-#define F_CFGSNP V_CFGSNP(1U)
-
-#define S_MAREQTIMEOUT 29
-#define V_MAREQTIMEOUT(x) ((x) << S_MAREQTIMEOUT)
-#define F_MAREQTIMEOUT V_MAREQTIMEOUT(1U)
-
-#define S_TRGT1BARTYPEERR 28
-#define V_TRGT1BARTYPEERR(x) ((x) << S_TRGT1BARTYPEERR)
-#define F_TRGT1BARTYPEERR V_TRGT1BARTYPEERR(1U)
-
-#define S_MAEXTRARSPERR 27
-#define V_MAEXTRARSPERR(x) ((x) << S_MAEXTRARSPERR)
-#define F_MAEXTRARSPERR V_MAEXTRARSPERR(1U)
-
-#define S_MARSPTIMEOUT 26
-#define V_MARSPTIMEOUT(x) ((x) << S_MARSPTIMEOUT)
-#define F_MARSPTIMEOUT V_MARSPTIMEOUT(1U)
-
-#define S_INTVFALLMSIDISERR 25
-#define V_INTVFALLMSIDISERR(x) ((x) << S_INTVFALLMSIDISERR)
-#define F_INTVFALLMSIDISERR V_INTVFALLMSIDISERR(1U)
-
-#define S_INTVFRANGEERR 24
-#define V_INTVFRANGEERR(x) ((x) << S_INTVFRANGEERR)
-#define F_INTVFRANGEERR V_INTVFRANGEERR(1U)
-
-#define S_INTPLIRSPERR 23
-#define V_INTPLIRSPERR(x) ((x) << S_INTPLIRSPERR)
-#define F_INTPLIRSPERR V_INTPLIRSPERR(1U)
-
-#define S_MEMREQRDTAGERR 22
-#define V_MEMREQRDTAGERR(x) ((x) << S_MEMREQRDTAGERR)
-#define F_MEMREQRDTAGERR V_MEMREQRDTAGERR(1U)
-
-#define S_CFGINITDONEERR 21
-#define V_CFGINITDONEERR(x) ((x) << S_CFGINITDONEERR)
-#define F_CFGINITDONEERR V_CFGINITDONEERR(1U)
-
-#define S_BAR2TIMEOUT 20
-#define V_BAR2TIMEOUT(x) ((x) << S_BAR2TIMEOUT)
-#define F_BAR2TIMEOUT V_BAR2TIMEOUT(1U)
-
-#define S_VPDTIMEOUT 19
-#define V_VPDTIMEOUT(x) ((x) << S_VPDTIMEOUT)
-#define F_VPDTIMEOUT V_VPDTIMEOUT(1U)
-
-#define S_MEMRSPRDTAGERR 18
-#define V_MEMRSPRDTAGERR(x) ((x) << S_MEMRSPRDTAGERR)
-#define F_MEMRSPRDTAGERR V_MEMRSPRDTAGERR(1U)
-
-#define S_MEMRSPWRTAGERR 17
-#define V_MEMRSPWRTAGERR(x) ((x) << S_MEMRSPWRTAGERR)
-#define F_MEMRSPWRTAGERR V_MEMRSPWRTAGERR(1U)
-
-#define S_PIORSPRDTAGERR 16
-#define V_PIORSPRDTAGERR(x) ((x) << S_PIORSPRDTAGERR)
-#define F_PIORSPRDTAGERR V_PIORSPRDTAGERR(1U)
-
-#define S_PIORSPWRTAGERR 15
-#define V_PIORSPWRTAGERR(x) ((x) << S_PIORSPWRTAGERR)
-#define F_PIORSPWRTAGERR V_PIORSPWRTAGERR(1U)
-
-#define S_DBITIMEOUT 14
-#define V_DBITIMEOUT(x) ((x) << S_DBITIMEOUT)
-#define F_DBITIMEOUT V_DBITIMEOUT(1U)
-
-#define S_PIOUNALINDWR 13
-#define V_PIOUNALINDWR(x) ((x) << S_PIOUNALINDWR)
-#define F_PIOUNALINDWR V_PIOUNALINDWR(1U)
-
-#define S_BAR2RDERR 12
-#define V_BAR2RDERR(x) ((x) << S_BAR2RDERR)
-#define F_BAR2RDERR V_BAR2RDERR(1U)
-
-#define S_MAWREOPERR 11
-#define V_MAWREOPERR(x) ((x) << S_MAWREOPERR)
-#define F_MAWREOPERR V_MAWREOPERR(1U)
-
-#define S_MARDEOPERR 10
-#define V_MARDEOPERR(x) ((x) << S_MARDEOPERR)
-#define F_MARDEOPERR V_MARDEOPERR(1U)
-
-#define S_BAR2REQ 2
-#define V_BAR2REQ(x) ((x) << S_BAR2REQ)
-#define F_BAR2REQ V_BAR2REQ(1U)
-
-#define S_MARSPUE 30
-#define V_MARSPUE(x) ((x) << S_MARSPUE)
-#define F_MARSPUE V_MARSPUE(1U)
-
-#define S_KDBEOPERR 7
-#define V_KDBEOPERR(x) ((x) << S_KDBEOPERR)
-#define F_KDBEOPERR V_KDBEOPERR(1U)
-
-#define A_PCIE_CFG 0x3014
-
-#define S_CFGDMAXPYLDSZRX 26
-#define M_CFGDMAXPYLDSZRX 0x7U
-#define V_CFGDMAXPYLDSZRX(x) ((x) << S_CFGDMAXPYLDSZRX)
-#define G_CFGDMAXPYLDSZRX(x) (((x) >> S_CFGDMAXPYLDSZRX) & M_CFGDMAXPYLDSZRX)
-
-#define S_CFGDMAXPYLDSZTX 23
-#define M_CFGDMAXPYLDSZTX 0x7U
-#define V_CFGDMAXPYLDSZTX(x) ((x) << S_CFGDMAXPYLDSZTX)
-#define G_CFGDMAXPYLDSZTX(x) (((x) >> S_CFGDMAXPYLDSZTX) & M_CFGDMAXPYLDSZTX)
-
-#define S_CFGDMAXRDREQSZ 20
-#define M_CFGDMAXRDREQSZ 0x7U
-#define V_CFGDMAXRDREQSZ(x) ((x) << S_CFGDMAXRDREQSZ)
-#define G_CFGDMAXRDREQSZ(x) (((x) >> S_CFGDMAXRDREQSZ) & M_CFGDMAXRDREQSZ)
-
-#define S_MASYNCEN 19
-#define V_MASYNCEN(x) ((x) << S_MASYNCEN)
-#define F_MASYNCEN V_MASYNCEN(1U)
-
-#define S_DCAENDMA 18
-#define V_DCAENDMA(x) ((x) << S_DCAENDMA)
-#define F_DCAENDMA V_DCAENDMA(1U)
-
-#define S_DCAENCMD 17
-#define V_DCAENCMD(x) ((x) << S_DCAENCMD)
-#define F_DCAENCMD V_DCAENCMD(1U)
-
-#define S_VFMSIPNDEN 16
-#define V_VFMSIPNDEN(x) ((x) << S_VFMSIPNDEN)
-#define F_VFMSIPNDEN V_VFMSIPNDEN(1U)
-
-#define S_FORCETXERROR 15
-#define V_FORCETXERROR(x) ((x) << S_FORCETXERROR)
-#define F_FORCETXERROR V_FORCETXERROR(1U)
-
-#define S_VPDREQPROTECT 14
-#define V_VPDREQPROTECT(x) ((x) << S_VPDREQPROTECT)
-#define F_VPDREQPROTECT V_VPDREQPROTECT(1U)
-
-#define S_FIDTABLEINVALID 13
-#define V_FIDTABLEINVALID(x) ((x) << S_FIDTABLEINVALID)
-#define F_FIDTABLEINVALID V_FIDTABLEINVALID(1U)
-
-#define S_BYPASSMSIXCACHE 12
-#define V_BYPASSMSIXCACHE(x) ((x) << S_BYPASSMSIXCACHE)
-#define F_BYPASSMSIXCACHE V_BYPASSMSIXCACHE(1U)
-
-#define S_BYPASSMSICACHE 11
-#define V_BYPASSMSICACHE(x) ((x) << S_BYPASSMSICACHE)
-#define F_BYPASSMSICACHE V_BYPASSMSICACHE(1U)
-
-#define S_SIMSPEED 10
-#define V_SIMSPEED(x) ((x) << S_SIMSPEED)
-#define F_SIMSPEED V_SIMSPEED(1U)
-
-#define S_TC0_STAMP 9
-#define V_TC0_STAMP(x) ((x) << S_TC0_STAMP)
-#define F_TC0_STAMP V_TC0_STAMP(1U)
-
-#define S_AI_TCVAL 6
-#define M_AI_TCVAL 0x7U
-#define V_AI_TCVAL(x) ((x) << S_AI_TCVAL)
-#define G_AI_TCVAL(x) (((x) >> S_AI_TCVAL) & M_AI_TCVAL)
-
-#define S_DMASTOPEN 5
-#define V_DMASTOPEN(x) ((x) << S_DMASTOPEN)
-#define F_DMASTOPEN V_DMASTOPEN(1U)
-
-#define S_DEVSTATERSTMODE 4
-#define V_DEVSTATERSTMODE(x) ((x) << S_DEVSTATERSTMODE)
-#define F_DEVSTATERSTMODE V_DEVSTATERSTMODE(1U)
-
-#define S_HOTRSTPCIECRSTMODE 3
-#define V_HOTRSTPCIECRSTMODE(x) ((x) << S_HOTRSTPCIECRSTMODE)
-#define F_HOTRSTPCIECRSTMODE V_HOTRSTPCIECRSTMODE(1U)
-
-#define S_DLDNPCIECRSTMODE 2
-#define V_DLDNPCIECRSTMODE(x) ((x) << S_DLDNPCIECRSTMODE)
-#define F_DLDNPCIECRSTMODE V_DLDNPCIECRSTMODE(1U)
-
-#define S_DLDNPCIEPRECRSTMODE 1
-#define V_DLDNPCIEPRECRSTMODE(x) ((x) << S_DLDNPCIEPRECRSTMODE)
-#define F_DLDNPCIEPRECRSTMODE V_DLDNPCIEPRECRSTMODE(1U)
-
-#define S_LINKDNRSTEN 0
-#define V_LINKDNRSTEN(x) ((x) << S_LINKDNRSTEN)
-#define F_LINKDNRSTEN V_LINKDNRSTEN(1U)
-
-#define S_T5_PIOSTOPEN 31
-#define V_T5_PIOSTOPEN(x) ((x) << S_T5_PIOSTOPEN)
-#define F_T5_PIOSTOPEN V_T5_PIOSTOPEN(1U)
-
-#define S_DIAGCTRLBUS 28
-#define M_DIAGCTRLBUS 0x7U
-#define V_DIAGCTRLBUS(x) ((x) << S_DIAGCTRLBUS)
-#define G_DIAGCTRLBUS(x) (((x) >> S_DIAGCTRLBUS) & M_DIAGCTRLBUS)
-
-#define S_IPPERREN 27
-#define V_IPPERREN(x) ((x) << S_IPPERREN)
-#define F_IPPERREN V_IPPERREN(1U)
-
-#define S_CFGDEXTTAGEN 26
-#define V_CFGDEXTTAGEN(x) ((x) << S_CFGDEXTTAGEN)
-#define F_CFGDEXTTAGEN V_CFGDEXTTAGEN(1U)
-
-#define S_CFGDMAXPYLDSZ 23
-#define M_CFGDMAXPYLDSZ 0x7U
-#define V_CFGDMAXPYLDSZ(x) ((x) << S_CFGDMAXPYLDSZ)
-#define G_CFGDMAXPYLDSZ(x) (((x) >> S_CFGDMAXPYLDSZ) & M_CFGDMAXPYLDSZ)
-
-#define S_DCAEN 17
-#define V_DCAEN(x) ((x) << S_DCAEN)
-#define F_DCAEN V_DCAEN(1U)
-
-#define S_T5CMDREQPRIORITY 16
-#define V_T5CMDREQPRIORITY(x) ((x) << S_T5CMDREQPRIORITY)
-#define F_T5CMDREQPRIORITY V_T5CMDREQPRIORITY(1U)
-
-#define S_T5VPDREQPROTECT 14
-#define M_T5VPDREQPROTECT 0x3U
-#define V_T5VPDREQPROTECT(x) ((x) << S_T5VPDREQPROTECT)
-#define G_T5VPDREQPROTECT(x) (((x) >> S_T5VPDREQPROTECT) & M_T5VPDREQPROTECT)
-
-#define S_DROPPEDRDRSPDATA 12
-#define V_DROPPEDRDRSPDATA(x) ((x) << S_DROPPEDRDRSPDATA)
-#define F_DROPPEDRDRSPDATA V_DROPPEDRDRSPDATA(1U)
-
-#define S_AI_INTX_REASSERTEN 11
-#define V_AI_INTX_REASSERTEN(x) ((x) << S_AI_INTX_REASSERTEN)
-#define F_AI_INTX_REASSERTEN V_AI_INTX_REASSERTEN(1U)
-
-#define S_AUTOTXNDISABLE 10
-#define V_AUTOTXNDISABLE(x) ((x) << S_AUTOTXNDISABLE)
-#define F_AUTOTXNDISABLE V_AUTOTXNDISABLE(1U)
-
-#define S_LINKREQRSTPCIECRSTMODE 3
-#define V_LINKREQRSTPCIECRSTMODE(x) ((x) << S_LINKREQRSTPCIECRSTMODE)
-#define F_LINKREQRSTPCIECRSTMODE V_LINKREQRSTPCIECRSTMODE(1U)
-
-#define S_T6_PIOSTOPEN 31
-#define V_T6_PIOSTOPEN(x) ((x) << S_T6_PIOSTOPEN)
-#define F_T6_PIOSTOPEN V_T6_PIOSTOPEN(1U)
-
-#define A_PCIE_DMA_CTRL 0x3018
-
-#define S_LITTLEENDIAN 7
-#define V_LITTLEENDIAN(x) ((x) << S_LITTLEENDIAN)
-#define F_LITTLEENDIAN V_LITTLEENDIAN(1U)
-
-#define A_PCIE_CFG2 0x3018
-
-#define S_VPDTIMER 16
-#define M_VPDTIMER 0xffffU
-#define V_VPDTIMER(x) ((x) << S_VPDTIMER)
-#define G_VPDTIMER(x) (((x) >> S_VPDTIMER) & M_VPDTIMER)
-
-#define S_BAR2TIMER 4
-#define M_BAR2TIMER 0xfffU
-#define V_BAR2TIMER(x) ((x) << S_BAR2TIMER)
-#define G_BAR2TIMER(x) (((x) >> S_BAR2TIMER) & M_BAR2TIMER)
-
-#define S_MSTREQRDRRASIMPLE 3
-#define V_MSTREQRDRRASIMPLE(x) ((x) << S_MSTREQRDRRASIMPLE)
-#define F_MSTREQRDRRASIMPLE V_MSTREQRDRRASIMPLE(1U)
-
-#define S_TOTMAXTAG 0
-#define M_TOTMAXTAG 0x3U
-#define V_TOTMAXTAG(x) ((x) << S_TOTMAXTAG)
-#define G_TOTMAXTAG(x) (((x) >> S_TOTMAXTAG) & M_TOTMAXTAG)
-
-#define S_T6_TOTMAXTAG 0
-#define M_T6_TOTMAXTAG 0x7U
-#define V_T6_TOTMAXTAG(x) ((x) << S_T6_TOTMAXTAG)
-#define G_T6_TOTMAXTAG(x) (((x) >> S_T6_TOTMAXTAG) & M_T6_TOTMAXTAG)
-
-#define A_PCIE_DMA_CFG 0x301c
-
-#define S_MAXPYLDSIZE 28
-#define M_MAXPYLDSIZE 0x7U
-#define V_MAXPYLDSIZE(x) ((x) << S_MAXPYLDSIZE)
-#define G_MAXPYLDSIZE(x) (((x) >> S_MAXPYLDSIZE) & M_MAXPYLDSIZE)
-
-#define S_MAXRDREQSIZE 25
-#define M_MAXRDREQSIZE 0x7U
-#define V_MAXRDREQSIZE(x) ((x) << S_MAXRDREQSIZE)
-#define G_MAXRDREQSIZE(x) (((x) >> S_MAXRDREQSIZE) & M_MAXRDREQSIZE)
-
-#define S_DMA_MAXRSPCNT 16
-#define M_DMA_MAXRSPCNT 0x1ffU
-#define V_DMA_MAXRSPCNT(x) ((x) << S_DMA_MAXRSPCNT)
-#define G_DMA_MAXRSPCNT(x) (((x) >> S_DMA_MAXRSPCNT) & M_DMA_MAXRSPCNT)
-
-#define S_DMA_MAXREQCNT 8
-#define M_DMA_MAXREQCNT 0xffU
-#define V_DMA_MAXREQCNT(x) ((x) << S_DMA_MAXREQCNT)
-#define G_DMA_MAXREQCNT(x) (((x) >> S_DMA_MAXREQCNT) & M_DMA_MAXREQCNT)
-
-#define S_MAXTAG 0
-#define M_MAXTAG 0x7fU
-#define V_MAXTAG(x) ((x) << S_MAXTAG)
-#define G_MAXTAG(x) (((x) >> S_MAXTAG) & M_MAXTAG)
-
-#define A_PCIE_CFG3 0x301c
-
-#define S_AUTOPIOCOOKIEMATCH 6
-#define V_AUTOPIOCOOKIEMATCH(x) ((x) << S_AUTOPIOCOOKIEMATCH)
-#define F_AUTOPIOCOOKIEMATCH V_AUTOPIOCOOKIEMATCH(1U)
-
-#define S_FLRPNDCPLMODE 4
-#define M_FLRPNDCPLMODE 0x3U
-#define V_FLRPNDCPLMODE(x) ((x) << S_FLRPNDCPLMODE)
-#define G_FLRPNDCPLMODE(x) (((x) >> S_FLRPNDCPLMODE) & M_FLRPNDCPLMODE)
-
-#define S_HMADCASTFIRSTONLY 2
-#define V_HMADCASTFIRSTONLY(x) ((x) << S_HMADCASTFIRSTONLY)
-#define F_HMADCASTFIRSTONLY V_HMADCASTFIRSTONLY(1U)
-
-#define S_CMDDCASTFIRSTONLY 1
-#define V_CMDDCASTFIRSTONLY(x) ((x) << S_CMDDCASTFIRSTONLY)
-#define F_CMDDCASTFIRSTONLY V_CMDDCASTFIRSTONLY(1U)
-
-#define S_DMADCASTFIRSTONLY 0
-#define V_DMADCASTFIRSTONLY(x) ((x) << S_DMADCASTFIRSTONLY)
-#define F_DMADCASTFIRSTONLY V_DMADCASTFIRSTONLY(1U)
-
-#define A_PCIE_DMA_STAT 0x3020
-
-#define S_STATEREQ 28
-#define M_STATEREQ 0xfU
-#define V_STATEREQ(x) ((x) << S_STATEREQ)
-#define G_STATEREQ(x) (((x) >> S_STATEREQ) & M_STATEREQ)
-
-#define S_DMA_RSPCNT 16
-#define M_DMA_RSPCNT 0xfffU
-#define V_DMA_RSPCNT(x) ((x) << S_DMA_RSPCNT)
-#define G_DMA_RSPCNT(x) (((x) >> S_DMA_RSPCNT) & M_DMA_RSPCNT)
-
-#define S_STATEAREQ 13
-#define M_STATEAREQ 0x7U
-#define V_STATEAREQ(x) ((x) << S_STATEAREQ)
-#define G_STATEAREQ(x) (((x) >> S_STATEAREQ) & M_STATEAREQ)
-
-#define S_TAGFREE 12
-#define V_TAGFREE(x) ((x) << S_TAGFREE)
-#define F_TAGFREE V_TAGFREE(1U)
-
-#define S_DMA_REQCNT 0
-#define M_DMA_REQCNT 0x7ffU
-#define V_DMA_REQCNT(x) ((x) << S_DMA_REQCNT)
-#define G_DMA_REQCNT(x) (((x) >> S_DMA_REQCNT) & M_DMA_REQCNT)
-
-#define A_PCIE_CFG4 0x3020
-
-#define S_L1CLKREMOVALEN 17
-#define V_L1CLKREMOVALEN(x) ((x) << S_L1CLKREMOVALEN)
-#define F_L1CLKREMOVALEN V_L1CLKREMOVALEN(1U)
-
-#define S_READYENTERL23 16
-#define V_READYENTERL23(x) ((x) << S_READYENTERL23)
-#define F_READYENTERL23 V_READYENTERL23(1U)
-
-#define S_EXITL1 12
-#define V_EXITL1(x) ((x) << S_EXITL1)
-#define F_EXITL1 V_EXITL1(1U)
-
-#define S_ENTERL1 8
-#define V_ENTERL1(x) ((x) << S_ENTERL1)
-#define F_ENTERL1 V_ENTERL1(1U)
-
-#define S_GENPME 0
-#define M_GENPME 0xffU
-#define V_GENPME(x) ((x) << S_GENPME)
-#define G_GENPME(x) (((x) >> S_GENPME) & M_GENPME)
-
-#define A_PCIE_CFG5 0x3024
-
-#define S_ENABLESKPPARITYFIX 2
-#define V_ENABLESKPPARITYFIX(x) ((x) << S_ENABLESKPPARITYFIX)
-#define F_ENABLESKPPARITYFIX V_ENABLESKPPARITYFIX(1U)
-
-#define S_ENABLEL2ENTRYINL1 1
-#define V_ENABLEL2ENTRYINL1(x) ((x) << S_ENABLEL2ENTRYINL1)
-#define F_ENABLEL2ENTRYINL1 V_ENABLEL2ENTRYINL1(1U)
-
-#define S_HOLDCPLENTERINGL1 0
-#define V_HOLDCPLENTERINGL1(x) ((x) << S_HOLDCPLENTERINGL1)
-#define F_HOLDCPLENTERINGL1 V_HOLDCPLENTERINGL1(1U)
-
-#define A_PCIE_CFG6 0x3028
-
-#define S_PERSTTIMERCOUNT 12
-#define M_PERSTTIMERCOUNT 0x3fffU
-#define V_PERSTTIMERCOUNT(x) ((x) << S_PERSTTIMERCOUNT)
-#define G_PERSTTIMERCOUNT(x) (((x) >> S_PERSTTIMERCOUNT) & M_PERSTTIMERCOUNT)
-
-#define S_PERSTTIMEOUT 8
-#define V_PERSTTIMEOUT(x) ((x) << S_PERSTTIMEOUT)
-#define F_PERSTTIMEOUT V_PERSTTIMEOUT(1U)
-
-#define S_PERSTTIMER 0
-#define M_PERSTTIMER 0xfU
-#define V_PERSTTIMER(x) ((x) << S_PERSTTIMER)
-#define G_PERSTTIMER(x) (((x) >> S_PERSTTIMER) & M_PERSTTIMER)
-
-#define A_PCIE_CFG7 0x302c
-#define A_PCIE_CMD_CTRL 0x303c
-#define A_PCIE_CMD_CFG 0x3040
-
-#define S_MAXRSPCNT 16
-#define M_MAXRSPCNT 0xfU
-#define V_MAXRSPCNT(x) ((x) << S_MAXRSPCNT)
-#define G_MAXRSPCNT(x) (((x) >> S_MAXRSPCNT) & M_MAXRSPCNT)
-
-#define S_MAXREQCNT 8
-#define M_MAXREQCNT 0x1fU
-#define V_MAXREQCNT(x) ((x) << S_MAXREQCNT)
-#define G_MAXREQCNT(x) (((x) >> S_MAXREQCNT) & M_MAXREQCNT)
-
-#define A_PCIE_CMD_STAT 0x3044
-
-#define S_RSPCNT 16
-#define M_RSPCNT 0x7fU
-#define V_RSPCNT(x) ((x) << S_RSPCNT)
-#define G_RSPCNT(x) (((x) >> S_RSPCNT) & M_RSPCNT)
-
-#define S_REQCNT 0
-#define M_REQCNT 0xffU
-#define V_REQCNT(x) ((x) << S_REQCNT)
-#define G_REQCNT(x) (((x) >> S_REQCNT) & M_REQCNT)
-
-#define A_PCIE_HMA_CTRL 0x3050
-
-#define S_IPLTSSM 12
-#define M_IPLTSSM 0xfU
-#define V_IPLTSSM(x) ((x) << S_IPLTSSM)
-#define G_IPLTSSM(x) (((x) >> S_IPLTSSM) & M_IPLTSSM)
-
-#define S_IPCONFIGDOWN 8
-#define M_IPCONFIGDOWN 0x7U
-#define V_IPCONFIGDOWN(x) ((x) << S_IPCONFIGDOWN)
-#define G_IPCONFIGDOWN(x) (((x) >> S_IPCONFIGDOWN) & M_IPCONFIGDOWN)
-
-#define A_PCIE_HMA_CFG 0x3054
-
-#define S_HMA_MAXRSPCNT 16
-#define M_HMA_MAXRSPCNT 0x1fU
-#define V_HMA_MAXRSPCNT(x) ((x) << S_HMA_MAXRSPCNT)
-#define G_HMA_MAXRSPCNT(x) (((x) >> S_HMA_MAXRSPCNT) & M_HMA_MAXRSPCNT)
-
-#define A_PCIE_HMA_STAT 0x3058
-
-#define S_HMA_RSPCNT 16
-#define M_HMA_RSPCNT 0xffU
-#define V_HMA_RSPCNT(x) ((x) << S_HMA_RSPCNT)
-#define G_HMA_RSPCNT(x) (((x) >> S_HMA_RSPCNT) & M_HMA_RSPCNT)
-
-#define A_PCIE_PIO_FIFO_CFG 0x305c
-
-#define S_CPLCONFIG 16
-#define M_CPLCONFIG 0xffffU
-#define V_CPLCONFIG(x) ((x) << S_CPLCONFIG)
-#define G_CPLCONFIG(x) (((x) >> S_CPLCONFIG) & M_CPLCONFIG)
-
-#define S_PIOSTOPEN 12
-#define V_PIOSTOPEN(x) ((x) << S_PIOSTOPEN)
-#define F_PIOSTOPEN V_PIOSTOPEN(1U)
-
-#define S_IPLANESWAP 11
-#define V_IPLANESWAP(x) ((x) << S_IPLANESWAP)
-#define F_IPLANESWAP V_IPLANESWAP(1U)
-
-#define S_FORCESTRICTTS1 10
-#define V_FORCESTRICTTS1(x) ((x) << S_FORCESTRICTTS1)
-#define F_FORCESTRICTTS1 V_FORCESTRICTTS1(1U)
-
-#define S_FORCEPROGRESSCNT 0
-#define M_FORCEPROGRESSCNT 0x3ffU
-#define V_FORCEPROGRESSCNT(x) ((x) << S_FORCEPROGRESSCNT)
-#define G_FORCEPROGRESSCNT(x) (((x) >> S_FORCEPROGRESSCNT) & M_FORCEPROGRESSCNT)
-
-#define A_PCIE_CFG_SPACE_REQ 0x3060
-
-#define S_ENABLE 30
-#define V_ENABLE(x) ((x) << S_ENABLE)
-#define F_ENABLE V_ENABLE(1U)
-
-#define S_AI 29
-#define V_AI(x) ((x) << S_AI)
-#define F_AI V_AI(1U)
-
-#define S_LOCALCFG 28
-#define V_LOCALCFG(x) ((x) << S_LOCALCFG)
-#define F_LOCALCFG V_LOCALCFG(1U)
-
-#define S_BUS 20
-#define M_BUS 0xffU
-#define V_BUS(x) ((x) << S_BUS)
-#define G_BUS(x) (((x) >> S_BUS) & M_BUS)
-
-#define S_DEVICE 15
-#define M_DEVICE 0x1fU
-#define V_DEVICE(x) ((x) << S_DEVICE)
-#define G_DEVICE(x) (((x) >> S_DEVICE) & M_DEVICE)
-
-#define S_FUNCTION 12
-#define M_FUNCTION 0x7U
-#define V_FUNCTION(x) ((x) << S_FUNCTION)
-#define G_FUNCTION(x) (((x) >> S_FUNCTION) & M_FUNCTION)
-
-#define S_EXTREGISTER 8
-#define M_EXTREGISTER 0xfU
-#define V_EXTREGISTER(x) ((x) << S_EXTREGISTER)
-#define G_EXTREGISTER(x) (((x) >> S_EXTREGISTER) & M_EXTREGISTER)
-
-#define S_REGISTER 0
-#define M_REGISTER 0xffU
-#define V_REGISTER(x) ((x) << S_REGISTER)
-#define G_REGISTER(x) (((x) >> S_REGISTER) & M_REGISTER)
-
-#define S_CS2 28
-#define V_CS2(x) ((x) << S_CS2)
-#define F_CS2 V_CS2(1U)
-
-#define S_WRBE 24
-#define M_WRBE 0xfU
-#define V_WRBE(x) ((x) << S_WRBE)
-#define G_WRBE(x) (((x) >> S_WRBE) & M_WRBE)
-
-#define S_CFG_SPACE_VFVLD 23
-#define V_CFG_SPACE_VFVLD(x) ((x) << S_CFG_SPACE_VFVLD)
-#define F_CFG_SPACE_VFVLD V_CFG_SPACE_VFVLD(1U)
-
-#define S_CFG_SPACE_RVF 16
-#define M_CFG_SPACE_RVF 0x7fU
-#define V_CFG_SPACE_RVF(x) ((x) << S_CFG_SPACE_RVF)
-#define G_CFG_SPACE_RVF(x) (((x) >> S_CFG_SPACE_RVF) & M_CFG_SPACE_RVF)
-
-#define S_CFG_SPACE_PF 12
-#define M_CFG_SPACE_PF 0x7U
-#define V_CFG_SPACE_PF(x) ((x) << S_CFG_SPACE_PF)
-#define G_CFG_SPACE_PF(x) (((x) >> S_CFG_SPACE_PF) & M_CFG_SPACE_PF)
-
-#define S_T6_ENABLE 31
-#define V_T6_ENABLE(x) ((x) << S_T6_ENABLE)
-#define F_T6_ENABLE V_T6_ENABLE(1U)
-
-#define S_T6_AI 30
-#define V_T6_AI(x) ((x) << S_T6_AI)
-#define F_T6_AI V_T6_AI(1U)
-
-#define S_T6_CS2 29
-#define V_T6_CS2(x) ((x) << S_T6_CS2)
-#define F_T6_CS2 V_T6_CS2(1U)
-
-#define S_T6_WRBE 25
-#define M_T6_WRBE 0xfU
-#define V_T6_WRBE(x) ((x) << S_T6_WRBE)
-#define G_T6_WRBE(x) (((x) >> S_T6_WRBE) & M_T6_WRBE)
-
-#define S_T6_CFG_SPACE_VFVLD 24
-#define V_T6_CFG_SPACE_VFVLD(x) ((x) << S_T6_CFG_SPACE_VFVLD)
-#define F_T6_CFG_SPACE_VFVLD V_T6_CFG_SPACE_VFVLD(1U)
-
-#define S_T6_CFG_SPACE_RVF 16
-#define M_T6_CFG_SPACE_RVF 0xffU
-#define V_T6_CFG_SPACE_RVF(x) ((x) << S_T6_CFG_SPACE_RVF)
-#define G_T6_CFG_SPACE_RVF(x) (((x) >> S_T6_CFG_SPACE_RVF) & M_T6_CFG_SPACE_RVF)
-
-#define A_PCIE_CFG_SPACE_DATA 0x3064
-#define A_PCIE_MEM_ACCESS_BASE_WIN 0x3068
-
-#define S_PCIEOFST 10
-#define M_PCIEOFST 0x3fffffU
-#define V_PCIEOFST(x) ((x) << S_PCIEOFST)
-#define G_PCIEOFST(x) (((x) >> S_PCIEOFST) & M_PCIEOFST)
-
-#define S_BIR 8
-#define M_BIR 0x3U
-#define V_BIR(x) ((x) << S_BIR)
-#define G_BIR(x) (((x) >> S_BIR) & M_BIR)
-
-#define S_WINDOW 0
-#define M_WINDOW 0xffU
-#define V_WINDOW(x) ((x) << S_WINDOW)
-#define G_WINDOW(x) (((x) >> S_WINDOW) & M_WINDOW)
-
-#define A_PCIE_MEM_ACCESS_OFFSET 0x306c
-
-#define S_MEMOFST 7
-#define M_MEMOFST 0x1ffffffU
-#define V_MEMOFST(x) ((x) << S_MEMOFST)
-#define G_MEMOFST(x) (((x) >> S_MEMOFST) & M_MEMOFST)
-
-#define A_PCIE_MAILBOX_BASE_WIN 0x30a8
-
-#define S_MBOXPCIEOFST 6
-#define M_MBOXPCIEOFST 0x3ffffffU
-#define V_MBOXPCIEOFST(x) ((x) << S_MBOXPCIEOFST)
-#define G_MBOXPCIEOFST(x) (((x) >> S_MBOXPCIEOFST) & M_MBOXPCIEOFST)
-
-#define S_MBOXBIR 4
-#define M_MBOXBIR 0x3U
-#define V_MBOXBIR(x) ((x) << S_MBOXBIR)
-#define G_MBOXBIR(x) (((x) >> S_MBOXBIR) & M_MBOXBIR)
-
-#define S_MBOXWIN 0
-#define M_MBOXWIN 0x3U
-#define V_MBOXWIN(x) ((x) << S_MBOXWIN)
-#define G_MBOXWIN(x) (((x) >> S_MBOXWIN) & M_MBOXWIN)
-
-#define A_PCIE_MAILBOX_OFFSET 0x30ac
-#define A_PCIE_MA_CTRL 0x30b0
-
-#define S_MA_TAGFREE 29
-#define V_MA_TAGFREE(x) ((x) << S_MA_TAGFREE)
-#define F_MA_TAGFREE V_MA_TAGFREE(1U)
-
-#define S_MA_MAXRSPCNT 24
-#define M_MA_MAXRSPCNT 0x1fU
-#define V_MA_MAXRSPCNT(x) ((x) << S_MA_MAXRSPCNT)
-#define G_MA_MAXRSPCNT(x) (((x) >> S_MA_MAXRSPCNT) & M_MA_MAXRSPCNT)
-
-#define S_MA_MAXREQCNT 16
-#define M_MA_MAXREQCNT 0x1fU
-#define V_MA_MAXREQCNT(x) ((x) << S_MA_MAXREQCNT)
-#define G_MA_MAXREQCNT(x) (((x) >> S_MA_MAXREQCNT) & M_MA_MAXREQCNT)
-
-#define S_MA_LE 15
-#define V_MA_LE(x) ((x) << S_MA_LE)
-#define F_MA_LE V_MA_LE(1U)
-
-#define S_MA_MAXPYLDSIZE 12
-#define M_MA_MAXPYLDSIZE 0x7U
-#define V_MA_MAXPYLDSIZE(x) ((x) << S_MA_MAXPYLDSIZE)
-#define G_MA_MAXPYLDSIZE(x) (((x) >> S_MA_MAXPYLDSIZE) & M_MA_MAXPYLDSIZE)
-
-#define S_MA_MAXRDREQSIZE 8
-#define M_MA_MAXRDREQSIZE 0x7U
-#define V_MA_MAXRDREQSIZE(x) ((x) << S_MA_MAXRDREQSIZE)
-#define G_MA_MAXRDREQSIZE(x) (((x) >> S_MA_MAXRDREQSIZE) & M_MA_MAXRDREQSIZE)
-
-#define S_MA_MAXTAG 0
-#define M_MA_MAXTAG 0x1fU
-#define V_MA_MAXTAG(x) ((x) << S_MA_MAXTAG)
-#define G_MA_MAXTAG(x) (((x) >> S_MA_MAXTAG) & M_MA_MAXTAG)
-
-#define S_T5_MA_MAXREQCNT 16
-#define M_T5_MA_MAXREQCNT 0x7fU
-#define V_T5_MA_MAXREQCNT(x) ((x) << S_T5_MA_MAXREQCNT)
-#define G_T5_MA_MAXREQCNT(x) (((x) >> S_T5_MA_MAXREQCNT) & M_T5_MA_MAXREQCNT)
-
-#define S_MA_MAXREQSIZE 8
-#define M_MA_MAXREQSIZE 0x7U
-#define V_MA_MAXREQSIZE(x) ((x) << S_MA_MAXREQSIZE)
-#define G_MA_MAXREQSIZE(x) (((x) >> S_MA_MAXREQSIZE) & M_MA_MAXREQSIZE)
-
-#define A_PCIE_MA_SYNC 0x30b4
-#define A_PCIE_FW 0x30b8
-#define A_PCIE_FW_PF 0x30bc
-#define A_PCIE_PIO_PAUSE 0x30dc
-
-#define S_PIOPAUSEDONE 31
-#define V_PIOPAUSEDONE(x) ((x) << S_PIOPAUSEDONE)
-#define F_PIOPAUSEDONE V_PIOPAUSEDONE(1U)
-
-#define S_PIOPAUSETIME 4
-#define M_PIOPAUSETIME 0xffffffU
-#define V_PIOPAUSETIME(x) ((x) << S_PIOPAUSETIME)
-#define G_PIOPAUSETIME(x) (((x) >> S_PIOPAUSETIME) & M_PIOPAUSETIME)
-
-#define S_PIOPAUSE 0
-#define V_PIOPAUSE(x) ((x) << S_PIOPAUSE)
-#define F_PIOPAUSE V_PIOPAUSE(1U)
-
-#define S_MSTPAUSEDONE 30
-#define V_MSTPAUSEDONE(x) ((x) << S_MSTPAUSEDONE)
-#define F_MSTPAUSEDONE V_MSTPAUSEDONE(1U)
-
-#define S_MSTPAUSE 1
-#define V_MSTPAUSE(x) ((x) << S_MSTPAUSE)
-#define F_MSTPAUSE V_MSTPAUSE(1U)
-
-#define A_PCIE_SYS_CFG_READY 0x30e0
-#define A_PCIE_MA_STAT 0x30e0
-#define A_PCIE_STATIC_CFG1 0x30e4
-
-#define S_LINKDOWN_RESET_EN 26
-#define V_LINKDOWN_RESET_EN(x) ((x) << S_LINKDOWN_RESET_EN)
-#define F_LINKDOWN_RESET_EN V_LINKDOWN_RESET_EN(1U)
-
-#define S_IN_WR_DISCONTIG 25
-#define V_IN_WR_DISCONTIG(x) ((x) << S_IN_WR_DISCONTIG)
-#define F_IN_WR_DISCONTIG V_IN_WR_DISCONTIG(1U)
-
-#define S_IN_RD_CPLSIZE 22
-#define M_IN_RD_CPLSIZE 0x7U
-#define V_IN_RD_CPLSIZE(x) ((x) << S_IN_RD_CPLSIZE)
-#define G_IN_RD_CPLSIZE(x) (((x) >> S_IN_RD_CPLSIZE) & M_IN_RD_CPLSIZE)
-
-#define S_IN_RD_BUFMODE 20
-#define M_IN_RD_BUFMODE 0x3U
-#define V_IN_RD_BUFMODE(x) ((x) << S_IN_RD_BUFMODE)
-#define G_IN_RD_BUFMODE(x) (((x) >> S_IN_RD_BUFMODE) & M_IN_RD_BUFMODE)
-
-#define S_GBIF_NPTRANS_TOT 18
-#define M_GBIF_NPTRANS_TOT 0x3U
-#define V_GBIF_NPTRANS_TOT(x) ((x) << S_GBIF_NPTRANS_TOT)
-#define G_GBIF_NPTRANS_TOT(x) (((x) >> S_GBIF_NPTRANS_TOT) & M_GBIF_NPTRANS_TOT)
-
-#define S_IN_PDAT_TOT 15
-#define M_IN_PDAT_TOT 0x7U
-#define V_IN_PDAT_TOT(x) ((x) << S_IN_PDAT_TOT)
-#define G_IN_PDAT_TOT(x) (((x) >> S_IN_PDAT_TOT) & M_IN_PDAT_TOT)
-
-#define S_PCIE_NPTRANS_TOT 12
-#define M_PCIE_NPTRANS_TOT 0x7U
-#define V_PCIE_NPTRANS_TOT(x) ((x) << S_PCIE_NPTRANS_TOT)
-#define G_PCIE_NPTRANS_TOT(x) (((x) >> S_PCIE_NPTRANS_TOT) & M_PCIE_NPTRANS_TOT)
-
-#define S_OUT_PDAT_TOT 9
-#define M_OUT_PDAT_TOT 0x7U
-#define V_OUT_PDAT_TOT(x) ((x) << S_OUT_PDAT_TOT)
-#define G_OUT_PDAT_TOT(x) (((x) >> S_OUT_PDAT_TOT) & M_OUT_PDAT_TOT)
-
-#define S_GBIF_MAX_WRSIZE 6
-#define M_GBIF_MAX_WRSIZE 0x7U
-#define V_GBIF_MAX_WRSIZE(x) ((x) << S_GBIF_MAX_WRSIZE)
-#define G_GBIF_MAX_WRSIZE(x) (((x) >> S_GBIF_MAX_WRSIZE) & M_GBIF_MAX_WRSIZE)
-
-#define S_GBIF_MAX_RDSIZE 3
-#define M_GBIF_MAX_RDSIZE 0x7U
-#define V_GBIF_MAX_RDSIZE(x) ((x) << S_GBIF_MAX_RDSIZE)
-#define G_GBIF_MAX_RDSIZE(x) (((x) >> S_GBIF_MAX_RDSIZE) & M_GBIF_MAX_RDSIZE)
-
-#define S_PCIE_MAX_RDSIZE 0
-#define M_PCIE_MAX_RDSIZE 0x7U
-#define V_PCIE_MAX_RDSIZE(x) ((x) << S_PCIE_MAX_RDSIZE)
-#define G_PCIE_MAX_RDSIZE(x) (((x) >> S_PCIE_MAX_RDSIZE) & M_PCIE_MAX_RDSIZE)
-
-#define S_AUXPOWER_DETECTED 27
-#define V_AUXPOWER_DETECTED(x) ((x) << S_AUXPOWER_DETECTED)
-#define F_AUXPOWER_DETECTED V_AUXPOWER_DETECTED(1U)
-
-#define A_PCIE_STATIC_CFG2 0x30e8
-
-#define S_PL_CONTROL 16
-#define M_PL_CONTROL 0xffffU
-#define V_PL_CONTROL(x) ((x) << S_PL_CONTROL)
-#define G_PL_CONTROL(x) (((x) >> S_PL_CONTROL) & M_PL_CONTROL)
-
-#define S_STATIC_SPARE3 0
-#define M_STATIC_SPARE3 0x3fffU
-#define V_STATIC_SPARE3(x) ((x) << S_STATIC_SPARE3)
-#define G_STATIC_SPARE3(x) (((x) >> S_STATIC_SPARE3) & M_STATIC_SPARE3)
-
-#define A_PCIE_DBG_INDIR_REQ 0x30ec
-
-#define S_DBGENABLE 31
-#define V_DBGENABLE(x) ((x) << S_DBGENABLE)
-#define F_DBGENABLE V_DBGENABLE(1U)
-
-#define S_DBGAUTOINC 30
-#define V_DBGAUTOINC(x) ((x) << S_DBGAUTOINC)
-#define F_DBGAUTOINC V_DBGAUTOINC(1U)
-
-#define S_POINTER 8
-#define M_POINTER 0xffffU
-#define V_POINTER(x) ((x) << S_POINTER)
-#define G_POINTER(x) (((x) >> S_POINTER) & M_POINTER)
-
-#define S_SELECT 0
-#define M_SELECT 0xfU
-#define V_SELECT(x) ((x) << S_SELECT)
-#define G_SELECT(x) (((x) >> S_SELECT) & M_SELECT)
-
-#define A_PCIE_DBG_INDIR_DATA_0 0x30f0
-#define A_PCIE_DBG_INDIR_DATA_1 0x30f4
-#define A_PCIE_DBG_INDIR_DATA_2 0x30f8
-#define A_PCIE_DBG_INDIR_DATA_3 0x30fc
-#define A_PCIE_FUNC_INT_CFG 0x3100
-
-#define S_PBAOFST 28
-#define M_PBAOFST 0xfU
-#define V_PBAOFST(x) ((x) << S_PBAOFST)
-#define G_PBAOFST(x) (((x) >> S_PBAOFST) & M_PBAOFST)
-
-#define S_TABOFST 24
-#define M_TABOFST 0xfU
-#define V_TABOFST(x) ((x) << S_TABOFST)
-#define G_TABOFST(x) (((x) >> S_TABOFST) & M_TABOFST)
-
-#define S_VECNUM 12
-#define M_VECNUM 0x3ffU
-#define V_VECNUM(x) ((x) << S_VECNUM)
-#define G_VECNUM(x) (((x) >> S_VECNUM) & M_VECNUM)
-
-#define S_VECBASE 0
-#define M_VECBASE 0x7ffU
-#define V_VECBASE(x) ((x) << S_VECBASE)
-#define G_VECBASE(x) (((x) >> S_VECBASE) & M_VECBASE)
-
-#define A_PCIE_FUNC_CTL_STAT 0x3104
-
-#define S_SENDFLRRSP 31
-#define V_SENDFLRRSP(x) ((x) << S_SENDFLRRSP)
-#define F_SENDFLRRSP V_SENDFLRRSP(1U)
-
-#define S_IMMFLRRSP 24
-#define V_IMMFLRRSP(x) ((x) << S_IMMFLRRSP)
-#define F_IMMFLRRSP V_IMMFLRRSP(1U)
-
-#define S_TXNDISABLE 20
-#define V_TXNDISABLE(x) ((x) << S_TXNDISABLE)
-#define F_TXNDISABLE V_TXNDISABLE(1U)
-
-#define S_PNDTXNS 8
-#define M_PNDTXNS 0x3ffU
-#define V_PNDTXNS(x) ((x) << S_PNDTXNS)
-#define G_PNDTXNS(x) (((x) >> S_PNDTXNS) & M_PNDTXNS)
-
-#define S_VFVLD 3
-#define V_VFVLD(x) ((x) << S_VFVLD)
-#define F_VFVLD V_VFVLD(1U)
-
-#define S_PFNUM 0
-#define M_PFNUM 0x7U
-#define V_PFNUM(x) ((x) << S_PFNUM)
-#define G_PFNUM(x) (((x) >> S_PFNUM) & M_PFNUM)
-
-#define A_PCIE_PF_INT_CFG 0x3140
-#define A_PCIE_PF_INT_CFG2 0x3144
-#define A_PCIE_VF_INT_CFG 0x3180
-#define A_PCIE_VF_INT_CFG2 0x3184
-#define A_PCIE_PF_MSI_EN 0x35a8
-
-#define S_PFMSIEN_7_0 0
-#define M_PFMSIEN_7_0 0xffU
-#define V_PFMSIEN_7_0(x) ((x) << S_PFMSIEN_7_0)
-#define G_PFMSIEN_7_0(x) (((x) >> S_PFMSIEN_7_0) & M_PFMSIEN_7_0)
-
-#define A_PCIE_VF_MSI_EN_0 0x35ac
-#define A_PCIE_VF_MSI_EN_1 0x35b0
-#define A_PCIE_VF_MSI_EN_2 0x35b4
-#define A_PCIE_VF_MSI_EN_3 0x35b8
-#define A_PCIE_PF_MSIX_EN 0x35bc
-
-#define S_PFMSIXEN_7_0 0
-#define M_PFMSIXEN_7_0 0xffU
-#define V_PFMSIXEN_7_0(x) ((x) << S_PFMSIXEN_7_0)
-#define G_PFMSIXEN_7_0(x) (((x) >> S_PFMSIXEN_7_0) & M_PFMSIXEN_7_0)
-
-#define A_PCIE_VF_MSIX_EN_0 0x35c0
-#define A_PCIE_VF_MSIX_EN_1 0x35c4
-#define A_PCIE_VF_MSIX_EN_2 0x35c8
-#define A_PCIE_VF_MSIX_EN_3 0x35cc
-#define A_PCIE_FID_VFID_SEL 0x35ec
-
-#define S_FID_VFID_SEL_SELECT 0
-#define M_FID_VFID_SEL_SELECT 0x3U
-#define V_FID_VFID_SEL_SELECT(x) ((x) << S_FID_VFID_SEL_SELECT)
-#define G_FID_VFID_SEL_SELECT(x) (((x) >> S_FID_VFID_SEL_SELECT) & M_FID_VFID_SEL_SELECT)
-
-#define A_PCIE_FID_VFID 0x3600
-
-#define S_FID_VFID_SELECT 30
-#define M_FID_VFID_SELECT 0x3U
-#define V_FID_VFID_SELECT(x) ((x) << S_FID_VFID_SELECT)
-#define G_FID_VFID_SELECT(x) (((x) >> S_FID_VFID_SELECT) & M_FID_VFID_SELECT)
-
-#define S_IDO 24
-#define V_IDO(x) ((x) << S_IDO)
-#define F_IDO V_IDO(1U)
-
-#define S_FID_VFID_VFID 16
-#define M_FID_VFID_VFID 0xffU
-#define V_FID_VFID_VFID(x) ((x) << S_FID_VFID_VFID)
-#define G_FID_VFID_VFID(x) (((x) >> S_FID_VFID_VFID) & M_FID_VFID_VFID)
-
-#define S_FID_VFID_TC 11
-#define M_FID_VFID_TC 0x7U
-#define V_FID_VFID_TC(x) ((x) << S_FID_VFID_TC)
-#define G_FID_VFID_TC(x) (((x) >> S_FID_VFID_TC) & M_FID_VFID_TC)
-
-#define S_FID_VFID_VFVLD 10
-#define V_FID_VFID_VFVLD(x) ((x) << S_FID_VFID_VFVLD)
-#define F_FID_VFID_VFVLD V_FID_VFID_VFVLD(1U)
-
-#define S_FID_VFID_PF 7
-#define M_FID_VFID_PF 0x7U
-#define V_FID_VFID_PF(x) ((x) << S_FID_VFID_PF)
-#define G_FID_VFID_PF(x) (((x) >> S_FID_VFID_PF) & M_FID_VFID_PF)
-
-#define S_FID_VFID_RVF 0
-#define M_FID_VFID_RVF 0x7fU
-#define V_FID_VFID_RVF(x) ((x) << S_FID_VFID_RVF)
-#define G_FID_VFID_RVF(x) (((x) >> S_FID_VFID_RVF) & M_FID_VFID_RVF)
-
-#define S_T6_FID_VFID_VFID 15
-#define M_T6_FID_VFID_VFID 0x1ffU
-#define V_T6_FID_VFID_VFID(x) ((x) << S_T6_FID_VFID_VFID)
-#define G_T6_FID_VFID_VFID(x) (((x) >> S_T6_FID_VFID_VFID) & M_T6_FID_VFID_VFID)
-
-#define S_T6_FID_VFID_TC 12
-#define M_T6_FID_VFID_TC 0x7U
-#define V_T6_FID_VFID_TC(x) ((x) << S_T6_FID_VFID_TC)
-#define G_T6_FID_VFID_TC(x) (((x) >> S_T6_FID_VFID_TC) & M_T6_FID_VFID_TC)
-
-#define S_T6_FID_VFID_VFVLD 11
-#define V_T6_FID_VFID_VFVLD(x) ((x) << S_T6_FID_VFID_VFVLD)
-#define F_T6_FID_VFID_VFVLD V_T6_FID_VFID_VFVLD(1U)
-
-#define S_T6_FID_VFID_PF 8
-#define M_T6_FID_VFID_PF 0x7U
-#define V_T6_FID_VFID_PF(x) ((x) << S_T6_FID_VFID_PF)
-#define G_T6_FID_VFID_PF(x) (((x) >> S_T6_FID_VFID_PF) & M_T6_FID_VFID_PF)
-
-#define S_T6_FID_VFID_RVF 0
-#define M_T6_FID_VFID_RVF 0xffU
-#define V_T6_FID_VFID_RVF(x) ((x) << S_T6_FID_VFID_RVF)
-#define G_T6_FID_VFID_RVF(x) (((x) >> S_T6_FID_VFID_RVF) & M_T6_FID_VFID_RVF)
-
-#define A_PCIE_FID 0x3900
-
-#define S_PAD 11
-#define V_PAD(x) ((x) << S_PAD)
-#define F_PAD V_PAD(1U)
-
-#define S_TC 8
-#define M_TC 0x7U
-#define V_TC(x) ((x) << S_TC)
-#define G_TC(x) (((x) >> S_TC) & M_TC)
-
-#define S_FUNC 0
-#define M_FUNC 0xffU
-#define V_FUNC(x) ((x) << S_FUNC)
-#define G_FUNC(x) (((x) >> S_FUNC) & M_FUNC)
-
-#define A_PCIE_COOKIE_STAT 0x5600
-
-#define S_COOKIEB 16
-#define M_COOKIEB 0x3ffU
-#define V_COOKIEB(x) ((x) << S_COOKIEB)
-#define G_COOKIEB(x) (((x) >> S_COOKIEB) & M_COOKIEB)
-
-#define S_COOKIEA 0
-#define M_COOKIEA 0x3ffU
-#define V_COOKIEA(x) ((x) << S_COOKIEA)
-#define G_COOKIEA(x) (((x) >> S_COOKIEA) & M_COOKIEA)
-
-#define A_PCIE_FLR_PIO 0x5620
-
-#define S_RCVDBAR2COOKIE 24
-#define M_RCVDBAR2COOKIE 0xffU
-#define V_RCVDBAR2COOKIE(x) ((x) << S_RCVDBAR2COOKIE)
-#define G_RCVDBAR2COOKIE(x) (((x) >> S_RCVDBAR2COOKIE) & M_RCVDBAR2COOKIE)
-
-#define S_RCVDMARSPCOOKIE 16
-#define M_RCVDMARSPCOOKIE 0xffU
-#define V_RCVDMARSPCOOKIE(x) ((x) << S_RCVDMARSPCOOKIE)
-#define G_RCVDMARSPCOOKIE(x) (((x) >> S_RCVDMARSPCOOKIE) & M_RCVDMARSPCOOKIE)
-
-#define S_RCVDPIORSPCOOKIE 8
-#define M_RCVDPIORSPCOOKIE 0xffU
-#define V_RCVDPIORSPCOOKIE(x) ((x) << S_RCVDPIORSPCOOKIE)
-#define G_RCVDPIORSPCOOKIE(x) (((x) >> S_RCVDPIORSPCOOKIE) & M_RCVDPIORSPCOOKIE)
-
-#define S_EXPDCOOKIE 0
-#define M_EXPDCOOKIE 0xffU
-#define V_EXPDCOOKIE(x) ((x) << S_EXPDCOOKIE)
-#define G_EXPDCOOKIE(x) (((x) >> S_EXPDCOOKIE) & M_EXPDCOOKIE)
-
-#define A_PCIE_FLR_PIO2 0x5624
-
-#define S_RCVDMAREQCOOKIE 16
-#define M_RCVDMAREQCOOKIE 0xffU
-#define V_RCVDMAREQCOOKIE(x) ((x) << S_RCVDMAREQCOOKIE)
-#define G_RCVDMAREQCOOKIE(x) (((x) >> S_RCVDMAREQCOOKIE) & M_RCVDMAREQCOOKIE)
-
-#define S_RCVDPIOREQCOOKIE 8
-#define M_RCVDPIOREQCOOKIE 0xffU
-#define V_RCVDPIOREQCOOKIE(x) ((x) << S_RCVDPIOREQCOOKIE)
-#define G_RCVDPIOREQCOOKIE(x) (((x) >> S_RCVDPIOREQCOOKIE) & M_RCVDPIOREQCOOKIE)
-
-#define S_RCVDVDMRXCOOKIE 24
-#define M_RCVDVDMRXCOOKIE 0xffU
-#define V_RCVDVDMRXCOOKIE(x) ((x) << S_RCVDVDMRXCOOKIE)
-#define G_RCVDVDMRXCOOKIE(x) (((x) >> S_RCVDVDMRXCOOKIE) & M_RCVDVDMRXCOOKIE)
-
-#define S_RCVDVDMTXCOOKIE 16
-#define M_RCVDVDMTXCOOKIE 0xffU
-#define V_RCVDVDMTXCOOKIE(x) ((x) << S_RCVDVDMTXCOOKIE)
-#define G_RCVDVDMTXCOOKIE(x) (((x) >> S_RCVDVDMTXCOOKIE) & M_RCVDVDMTXCOOKIE)
-
-#define S_T6_RCVDMAREQCOOKIE 8
-#define M_T6_RCVDMAREQCOOKIE 0xffU
-#define V_T6_RCVDMAREQCOOKIE(x) ((x) << S_T6_RCVDMAREQCOOKIE)
-#define G_T6_RCVDMAREQCOOKIE(x) (((x) >> S_T6_RCVDMAREQCOOKIE) & M_T6_RCVDMAREQCOOKIE)
-
-#define S_T6_RCVDPIOREQCOOKIE 0
-#define M_T6_RCVDPIOREQCOOKIE 0xffU
-#define V_T6_RCVDPIOREQCOOKIE(x) ((x) << S_T6_RCVDPIOREQCOOKIE)
-#define G_T6_RCVDPIOREQCOOKIE(x) (((x) >> S_T6_RCVDPIOREQCOOKIE) & M_T6_RCVDPIOREQCOOKIE)
-
-#define A_PCIE_VC0_CDTS0 0x56cc
-
-#define S_CPLD0 20
-#define M_CPLD0 0xfffU
-#define V_CPLD0(x) ((x) << S_CPLD0)
-#define G_CPLD0(x) (((x) >> S_CPLD0) & M_CPLD0)
-
-#define S_PH0 12
-#define M_PH0 0xffU
-#define V_PH0(x) ((x) << S_PH0)
-#define G_PH0(x) (((x) >> S_PH0) & M_PH0)
-
-#define S_PD0 0
-#define M_PD0 0xfffU
-#define V_PD0(x) ((x) << S_PD0)
-#define G_PD0(x) (((x) >> S_PD0) & M_PD0)
-
-#define A_PCIE_VC0_CDTS1 0x56d0
-
-#define S_CPLH0 20
-#define M_CPLH0 0xffU
-#define V_CPLH0(x) ((x) << S_CPLH0)
-#define G_CPLH0(x) (((x) >> S_CPLH0) & M_CPLH0)
-
-#define S_NPH0 12
-#define M_NPH0 0xffU
-#define V_NPH0(x) ((x) << S_NPH0)
-#define G_NPH0(x) (((x) >> S_NPH0) & M_NPH0)
-
-#define S_NPD0 0
-#define M_NPD0 0xfffU
-#define V_NPD0(x) ((x) << S_NPD0)
-#define G_NPD0(x) (((x) >> S_NPD0) & M_NPD0)
-
-#define A_PCIE_VC1_CDTS0 0x56d4
-
-#define S_CPLD1 20
-#define M_CPLD1 0xfffU
-#define V_CPLD1(x) ((x) << S_CPLD1)
-#define G_CPLD1(x) (((x) >> S_CPLD1) & M_CPLD1)
-
-#define S_PH1 12
-#define M_PH1 0xffU
-#define V_PH1(x) ((x) << S_PH1)
-#define G_PH1(x) (((x) >> S_PH1) & M_PH1)
-
-#define S_PD1 0
-#define M_PD1 0xfffU
-#define V_PD1(x) ((x) << S_PD1)
-#define G_PD1(x) (((x) >> S_PD1) & M_PD1)
-
-#define A_PCIE_VC1_CDTS1 0x56d8
-
-#define S_CPLH1 20
-#define M_CPLH1 0xffU
-#define V_CPLH1(x) ((x) << S_CPLH1)
-#define G_CPLH1(x) (((x) >> S_CPLH1) & M_CPLH1)
-
-#define S_NPH1 12
-#define M_NPH1 0xffU
-#define V_NPH1(x) ((x) << S_NPH1)
-#define G_NPH1(x) (((x) >> S_NPH1) & M_NPH1)
-
-#define S_NPD1 0
-#define M_NPD1 0xfffU
-#define V_NPD1(x) ((x) << S_NPD1)
-#define G_NPD1(x) (((x) >> S_NPD1) & M_NPD1)
-
-#define A_PCIE_FLR_PF_STATUS 0x56dc
-#define A_PCIE_FLR_VF0_STATUS 0x56e0
-#define A_PCIE_FLR_VF1_STATUS 0x56e4
-#define A_PCIE_FLR_VF2_STATUS 0x56e8
-#define A_PCIE_FLR_VF3_STATUS 0x56ec
-#define A_PCIE_STAT 0x56f4
-
-#define S_PM_STATUS 24
-#define M_PM_STATUS 0xffU
-#define V_PM_STATUS(x) ((x) << S_PM_STATUS)
-#define G_PM_STATUS(x) (((x) >> S_PM_STATUS) & M_PM_STATUS)
-
-#define S_PM_CURRENTSTATE 20
-#define M_PM_CURRENTSTATE 0x7U
-#define V_PM_CURRENTSTATE(x) ((x) << S_PM_CURRENTSTATE)
-#define G_PM_CURRENTSTATE(x) (((x) >> S_PM_CURRENTSTATE) & M_PM_CURRENTSTATE)
-
-#define S_LTSSMENABLE 12
-#define V_LTSSMENABLE(x) ((x) << S_LTSSMENABLE)
-#define F_LTSSMENABLE V_LTSSMENABLE(1U)
-
-#define S_STATECFGINITF 4
-#define M_STATECFGINITF 0x7fU
-#define V_STATECFGINITF(x) ((x) << S_STATECFGINITF)
-#define G_STATECFGINITF(x) (((x) >> S_STATECFGINITF) & M_STATECFGINITF)
-
-#define S_STATECFGINIT 0
-#define M_STATECFGINIT 0xfU
-#define V_STATECFGINIT(x) ((x) << S_STATECFGINIT)
-#define G_STATECFGINIT(x) (((x) >> S_STATECFGINIT) & M_STATECFGINIT)
-
-#define S_LTSSMENABLE_PCIE 12
-#define V_LTSSMENABLE_PCIE(x) ((x) << S_LTSSMENABLE_PCIE)
-#define F_LTSSMENABLE_PCIE V_LTSSMENABLE_PCIE(1U)
-
-#define S_STATECFGINITF_PCIE 4
-#define M_STATECFGINITF_PCIE 0xffU
-#define V_STATECFGINITF_PCIE(x) ((x) << S_STATECFGINITF_PCIE)
-#define G_STATECFGINITF_PCIE(x) (((x) >> S_STATECFGINITF_PCIE) & M_STATECFGINITF_PCIE)
-
-#define S_STATECFGINIT_PCIE 0
-#define M_STATECFGINIT_PCIE 0xfU
-#define V_STATECFGINIT_PCIE(x) ((x) << S_STATECFGINIT_PCIE)
-#define G_STATECFGINIT_PCIE(x) (((x) >> S_STATECFGINIT_PCIE) & M_STATECFGINIT_PCIE)
-
-#define A_PCIE_CRS 0x56f8
-
-#define S_CRS_ENABLE 0
-#define V_CRS_ENABLE(x) ((x) << S_CRS_ENABLE)
-#define F_CRS_ENABLE V_CRS_ENABLE(1U)
-
-#define A_PCIE_LTSSM 0x56fc
-
-#define S_LTSSM_ENABLE 0
-#define V_LTSSM_ENABLE(x) ((x) << S_LTSSM_ENABLE)
-#define F_LTSSM_ENABLE V_LTSSM_ENABLE(1U)
-
-#define S_LTSSM_STALL_DISABLE 1
-#define V_LTSSM_STALL_DISABLE(x) ((x) << S_LTSSM_STALL_DISABLE)
-#define F_LTSSM_STALL_DISABLE V_LTSSM_STALL_DISABLE(1U)
-
-#define A_PCIE_CORE_ACK_LATENCY_TIMER_REPLAY_TIMER 0x5700
-
-#define S_REPLAY_TIME_LIMIT 16
-#define M_REPLAY_TIME_LIMIT 0xffffU
-#define V_REPLAY_TIME_LIMIT(x) ((x) << S_REPLAY_TIME_LIMIT)
-#define G_REPLAY_TIME_LIMIT(x) (((x) >> S_REPLAY_TIME_LIMIT) & M_REPLAY_TIME_LIMIT)
-
-#define S_ACK_LATENCY_TIMER_LIMIT 0
-#define M_ACK_LATENCY_TIMER_LIMIT 0xffffU
-#define V_ACK_LATENCY_TIMER_LIMIT(x) ((x) << S_ACK_LATENCY_TIMER_LIMIT)
-#define G_ACK_LATENCY_TIMER_LIMIT(x) (((x) >> S_ACK_LATENCY_TIMER_LIMIT) & M_ACK_LATENCY_TIMER_LIMIT)
-
-#define A_PCIE_CORE_VENDOR_SPECIFIC_DLLP 0x5704
-#define A_PCIE_CORE_PORT_FORCE_LINK 0x5708
-
-#define S_LOW_POWER_ENTRANCE_COUNT 24
-#define M_LOW_POWER_ENTRANCE_COUNT 0xffU
-#define V_LOW_POWER_ENTRANCE_COUNT(x) ((x) << S_LOW_POWER_ENTRANCE_COUNT)
-#define G_LOW_POWER_ENTRANCE_COUNT(x) (((x) >> S_LOW_POWER_ENTRANCE_COUNT) & M_LOW_POWER_ENTRANCE_COUNT)
-
-#define S_LINK_STATE 16
-#define M_LINK_STATE 0x3fU
-#define V_LINK_STATE(x) ((x) << S_LINK_STATE)
-#define G_LINK_STATE(x) (((x) >> S_LINK_STATE) & M_LINK_STATE)
-
-#define S_FORCE_LINK 15
-#define V_FORCE_LINK(x) ((x) << S_FORCE_LINK)
-#define F_FORCE_LINK V_FORCE_LINK(1U)
-
-#define S_LINK_NUMBER 0
-#define M_LINK_NUMBER 0xffU
-#define V_LINK_NUMBER(x) ((x) << S_LINK_NUMBER)
-#define G_LINK_NUMBER(x) (((x) >> S_LINK_NUMBER) & M_LINK_NUMBER)
-
-#define A_PCIE_CORE_ACK_FREQUENCY_L0L1_ASPM_CONTROL 0x570c
-
-#define S_ENTER_ASPM_L1_WO_L0S 30
-#define V_ENTER_ASPM_L1_WO_L0S(x) ((x) << S_ENTER_ASPM_L1_WO_L0S)
-#define F_ENTER_ASPM_L1_WO_L0S V_ENTER_ASPM_L1_WO_L0S(1U)
-
-#define S_L1_ENTRANCE_LATENCY 27
-#define M_L1_ENTRANCE_LATENCY 0x7U
-#define V_L1_ENTRANCE_LATENCY(x) ((x) << S_L1_ENTRANCE_LATENCY)
-#define G_L1_ENTRANCE_LATENCY(x) (((x) >> S_L1_ENTRANCE_LATENCY) & M_L1_ENTRANCE_LATENCY)
-
-#define S_L0S_ENTRANCE_LATENCY 24
-#define M_L0S_ENTRANCE_LATENCY 0x7U
-#define V_L0S_ENTRANCE_LATENCY(x) ((x) << S_L0S_ENTRANCE_LATENCY)
-#define G_L0S_ENTRANCE_LATENCY(x) (((x) >> S_L0S_ENTRANCE_LATENCY) & M_L0S_ENTRANCE_LATENCY)
-
-#define S_COMMON_CLOCK_N_FTS 16
-#define M_COMMON_CLOCK_N_FTS 0xffU
-#define V_COMMON_CLOCK_N_FTS(x) ((x) << S_COMMON_CLOCK_N_FTS)
-#define G_COMMON_CLOCK_N_FTS(x) (((x) >> S_COMMON_CLOCK_N_FTS) & M_COMMON_CLOCK_N_FTS)
-
-#define S_N_FTS 8
-#define M_N_FTS 0xffU
-#define V_N_FTS(x) ((x) << S_N_FTS)
-#define G_N_FTS(x) (((x) >> S_N_FTS) & M_N_FTS)
-
-#define S_ACK_FREQUENCY 0
-#define M_ACK_FREQUENCY 0xffU
-#define V_ACK_FREQUENCY(x) ((x) << S_ACK_FREQUENCY)
-#define G_ACK_FREQUENCY(x) (((x) >> S_ACK_FREQUENCY) & M_ACK_FREQUENCY)
-
-#define A_PCIE_CORE_PORT_LINK_CONTROL 0x5710
-
-#define S_CROSSLINK_ACTIVE 23
-#define V_CROSSLINK_ACTIVE(x) ((x) << S_CROSSLINK_ACTIVE)
-#define F_CROSSLINK_ACTIVE V_CROSSLINK_ACTIVE(1U)
-
-#define S_CROSSLINK_ENABLE 22
-#define V_CROSSLINK_ENABLE(x) ((x) << S_CROSSLINK_ENABLE)
-#define F_CROSSLINK_ENABLE V_CROSSLINK_ENABLE(1U)
-
-#define S_LINK_MODE_ENABLE 16
-#define M_LINK_MODE_ENABLE 0x3fU
-#define V_LINK_MODE_ENABLE(x) ((x) << S_LINK_MODE_ENABLE)
-#define G_LINK_MODE_ENABLE(x) (((x) >> S_LINK_MODE_ENABLE) & M_LINK_MODE_ENABLE)
-
-#define S_FAST_LINK_MODE 7
-#define V_FAST_LINK_MODE(x) ((x) << S_FAST_LINK_MODE)
-#define F_FAST_LINK_MODE V_FAST_LINK_MODE(1U)
-
-#define S_DLL_LINK_ENABLE 5
-#define V_DLL_LINK_ENABLE(x) ((x) << S_DLL_LINK_ENABLE)
-#define F_DLL_LINK_ENABLE V_DLL_LINK_ENABLE(1U)
-
-#define S_RESET_ASSERT 3
-#define V_RESET_ASSERT(x) ((x) << S_RESET_ASSERT)
-#define F_RESET_ASSERT V_RESET_ASSERT(1U)
-
-#define S_LOOPBACK_ENABLE 2
-#define V_LOOPBACK_ENABLE(x) ((x) << S_LOOPBACK_ENABLE)
-#define F_LOOPBACK_ENABLE V_LOOPBACK_ENABLE(1U)
-
-#define S_SCRAMBLE_DISABLE 1
-#define V_SCRAMBLE_DISABLE(x) ((x) << S_SCRAMBLE_DISABLE)
-#define F_SCRAMBLE_DISABLE V_SCRAMBLE_DISABLE(1U)
-
-#define S_VENDOR_SPECIFIC_DLLP_REQUEST 0
-#define V_VENDOR_SPECIFIC_DLLP_REQUEST(x) ((x) << S_VENDOR_SPECIFIC_DLLP_REQUEST)
-#define F_VENDOR_SPECIFIC_DLLP_REQUEST V_VENDOR_SPECIFIC_DLLP_REQUEST(1U)
-
-#define A_PCIE_CORE_LANE_SKEW 0x5714
-
-#define S_DISABLE_DESKEW 31
-#define V_DISABLE_DESKEW(x) ((x) << S_DISABLE_DESKEW)
-#define F_DISABLE_DESKEW V_DISABLE_DESKEW(1U)
-
-#define S_ACK_NAK_DISABLE 25
-#define V_ACK_NAK_DISABLE(x) ((x) << S_ACK_NAK_DISABLE)
-#define F_ACK_NAK_DISABLE V_ACK_NAK_DISABLE(1U)
-
-#define S_FLOW_CONTROL_DISABLE 24
-#define V_FLOW_CONTROL_DISABLE(x) ((x) << S_FLOW_CONTROL_DISABLE)
-#define F_FLOW_CONTROL_DISABLE V_FLOW_CONTROL_DISABLE(1U)
-
-#define S_INSERT_TXSKEW 0
-#define M_INSERT_TXSKEW 0xffffffU
-#define V_INSERT_TXSKEW(x) ((x) << S_INSERT_TXSKEW)
-#define G_INSERT_TXSKEW(x) (((x) >> S_INSERT_TXSKEW) & M_INSERT_TXSKEW)
-
-#define A_PCIE_CORE_SYMBOL_NUMBER 0x5718
-
-#define S_FLOW_CONTROL_TIMER_MODIFIER 24
-#define M_FLOW_CONTROL_TIMER_MODIFIER 0x1fU
-#define V_FLOW_CONTROL_TIMER_MODIFIER(x) ((x) << S_FLOW_CONTROL_TIMER_MODIFIER)
-#define G_FLOW_CONTROL_TIMER_MODIFIER(x) (((x) >> S_FLOW_CONTROL_TIMER_MODIFIER) & M_FLOW_CONTROL_TIMER_MODIFIER)
-
-#define S_ACK_NAK_TIMER_MODIFIER 19
-#define M_ACK_NAK_TIMER_MODIFIER 0x1fU
-#define V_ACK_NAK_TIMER_MODIFIER(x) ((x) << S_ACK_NAK_TIMER_MODIFIER)
-#define G_ACK_NAK_TIMER_MODIFIER(x) (((x) >> S_ACK_NAK_TIMER_MODIFIER) & M_ACK_NAK_TIMER_MODIFIER)
-
-#define S_REPLAY_TIMER_MODIFIER 14
-#define M_REPLAY_TIMER_MODIFIER 0x1fU
-#define V_REPLAY_TIMER_MODIFIER(x) ((x) << S_REPLAY_TIMER_MODIFIER)
-#define G_REPLAY_TIMER_MODIFIER(x) (((x) >> S_REPLAY_TIMER_MODIFIER) & M_REPLAY_TIMER_MODIFIER)
-
-#define S_MAXFUNC 0
-#define M_MAXFUNC 0x7U
-#define V_MAXFUNC(x) ((x) << S_MAXFUNC)
-#define G_MAXFUNC(x) (((x) >> S_MAXFUNC) & M_MAXFUNC)
-
-#define A_PCIE_CORE_SYMBOL_TIMER_FILTER_MASK1 0x571c
-
-#define S_MASK_RADM_FILTER 16
-#define M_MASK_RADM_FILTER 0xffffU
-#define V_MASK_RADM_FILTER(x) ((x) << S_MASK_RADM_FILTER)
-#define G_MASK_RADM_FILTER(x) (((x) >> S_MASK_RADM_FILTER) & M_MASK_RADM_FILTER)
-
-#define S_DISABLE_FC_WATCHDOG 15
-#define V_DISABLE_FC_WATCHDOG(x) ((x) << S_DISABLE_FC_WATCHDOG)
-#define F_DISABLE_FC_WATCHDOG V_DISABLE_FC_WATCHDOG(1U)
-
-#define S_SKP_INTERVAL 0
-#define M_SKP_INTERVAL 0x7ffU
-#define V_SKP_INTERVAL(x) ((x) << S_SKP_INTERVAL)
-#define G_SKP_INTERVAL(x) (((x) >> S_SKP_INTERVAL) & M_SKP_INTERVAL)
-
-#define A_PCIE_CORE_FILTER_MASK2 0x5720
-#define A_PCIE_CORE_DEBUG_0 0x5728
-#define A_PCIE_CORE_DEBUG_1 0x572c
-#define A_PCIE_CORE_TRANSMIT_POSTED_FC_CREDIT_STATUS 0x5730
-
-#define S_TXPH_FC 12
-#define M_TXPH_FC 0xffU
-#define V_TXPH_FC(x) ((x) << S_TXPH_FC)
-#define G_TXPH_FC(x) (((x) >> S_TXPH_FC) & M_TXPH_FC)
-
-#define S_TXPD_FC 0
-#define M_TXPD_FC 0xfffU
-#define V_TXPD_FC(x) ((x) << S_TXPD_FC)
-#define G_TXPD_FC(x) (((x) >> S_TXPD_FC) & M_TXPD_FC)
-
-#define A_PCIE_CORE_TRANSMIT_NONPOSTED_FC_CREDIT_STATUS 0x5734
-
-#define S_TXNPH_FC 12
-#define M_TXNPH_FC 0xffU
-#define V_TXNPH_FC(x) ((x) << S_TXNPH_FC)
-#define G_TXNPH_FC(x) (((x) >> S_TXNPH_FC) & M_TXNPH_FC)
-
-#define S_TXNPD_FC 0
-#define M_TXNPD_FC 0xfffU
-#define V_TXNPD_FC(x) ((x) << S_TXNPD_FC)
-#define G_TXNPD_FC(x) (((x) >> S_TXNPD_FC) & M_TXNPD_FC)
-
-#define A_PCIE_CORE_TRANSMIT_COMPLETION_FC_CREDIT_STATUS 0x5738
-
-#define S_TXCPLH_FC 12
-#define M_TXCPLH_FC 0xffU
-#define V_TXCPLH_FC(x) ((x) << S_TXCPLH_FC)
-#define G_TXCPLH_FC(x) (((x) >> S_TXCPLH_FC) & M_TXCPLH_FC)
-
-#define S_TXCPLD_FC 0
-#define M_TXCPLD_FC 0xfffU
-#define V_TXCPLD_FC(x) ((x) << S_TXCPLD_FC)
-#define G_TXCPLD_FC(x) (((x) >> S_TXCPLD_FC) & M_TXCPLD_FC)
-
-#define A_PCIE_CORE_QUEUE_STATUS 0x573c
-
-#define S_RXQUEUE_NOT_EMPTY 2
-#define V_RXQUEUE_NOT_EMPTY(x) ((x) << S_RXQUEUE_NOT_EMPTY)
-#define F_RXQUEUE_NOT_EMPTY V_RXQUEUE_NOT_EMPTY(1U)
-
-#define S_TXRETRYBUF_NOT_EMPTY 1
-#define V_TXRETRYBUF_NOT_EMPTY(x) ((x) << S_TXRETRYBUF_NOT_EMPTY)
-#define F_TXRETRYBUF_NOT_EMPTY V_TXRETRYBUF_NOT_EMPTY(1U)
-
-#define S_RXTLP_FC_NOT_RETURNED 0
-#define V_RXTLP_FC_NOT_RETURNED(x) ((x) << S_RXTLP_FC_NOT_RETURNED)
-#define F_RXTLP_FC_NOT_RETURNED V_RXTLP_FC_NOT_RETURNED(1U)
-
-#define A_PCIE_CORE_VC_TRANSMIT_ARBITRATION_1 0x5740
-
-#define S_VC3_WRR 24
-#define M_VC3_WRR 0xffU
-#define V_VC3_WRR(x) ((x) << S_VC3_WRR)
-#define G_VC3_WRR(x) (((x) >> S_VC3_WRR) & M_VC3_WRR)
-
-#define S_VC2_WRR 16
-#define M_VC2_WRR 0xffU
-#define V_VC2_WRR(x) ((x) << S_VC2_WRR)
-#define G_VC2_WRR(x) (((x) >> S_VC2_WRR) & M_VC2_WRR)
-
-#define S_VC1_WRR 8
-#define M_VC1_WRR 0xffU
-#define V_VC1_WRR(x) ((x) << S_VC1_WRR)
-#define G_VC1_WRR(x) (((x) >> S_VC1_WRR) & M_VC1_WRR)
-
-#define S_VC0_WRR 0
-#define M_VC0_WRR 0xffU
-#define V_VC0_WRR(x) ((x) << S_VC0_WRR)
-#define G_VC0_WRR(x) (((x) >> S_VC0_WRR) & M_VC0_WRR)
-
-#define A_PCIE_CORE_VC_TRANSMIT_ARBITRATION_2 0x5744
-
-#define S_VC7_WRR 24
-#define M_VC7_WRR 0xffU
-#define V_VC7_WRR(x) ((x) << S_VC7_WRR)
-#define G_VC7_WRR(x) (((x) >> S_VC7_WRR) & M_VC7_WRR)
-
-#define S_VC6_WRR 16
-#define M_VC6_WRR 0xffU
-#define V_VC6_WRR(x) ((x) << S_VC6_WRR)
-#define G_VC6_WRR(x) (((x) >> S_VC6_WRR) & M_VC6_WRR)
-
-#define S_VC5_WRR 8
-#define M_VC5_WRR 0xffU
-#define V_VC5_WRR(x) ((x) << S_VC5_WRR)
-#define G_VC5_WRR(x) (((x) >> S_VC5_WRR) & M_VC5_WRR)
-
-#define S_VC4_WRR 0
-#define M_VC4_WRR 0xffU
-#define V_VC4_WRR(x) ((x) << S_VC4_WRR)
-#define G_VC4_WRR(x) (((x) >> S_VC4_WRR) & M_VC4_WRR)
-
-#define A_PCIE_CORE_VC0_POSTED_RECEIVE_QUEUE_CONTROL 0x5748
-
-#define S_VC0_RX_ORDERING 31
-#define V_VC0_RX_ORDERING(x) ((x) << S_VC0_RX_ORDERING)
-#define F_VC0_RX_ORDERING V_VC0_RX_ORDERING(1U)
-
-#define S_VC0_TLP_ORDERING 30
-#define V_VC0_TLP_ORDERING(x) ((x) << S_VC0_TLP_ORDERING)
-#define F_VC0_TLP_ORDERING V_VC0_TLP_ORDERING(1U)
-
-#define S_VC0_PTLP_QUEUE_MODE 21
-#define M_VC0_PTLP_QUEUE_MODE 0x7U
-#define V_VC0_PTLP_QUEUE_MODE(x) ((x) << S_VC0_PTLP_QUEUE_MODE)
-#define G_VC0_PTLP_QUEUE_MODE(x) (((x) >> S_VC0_PTLP_QUEUE_MODE) & M_VC0_PTLP_QUEUE_MODE)
-
-#define S_VC0_PH_CREDITS 12
-#define M_VC0_PH_CREDITS 0xffU
-#define V_VC0_PH_CREDITS(x) ((x) << S_VC0_PH_CREDITS)
-#define G_VC0_PH_CREDITS(x) (((x) >> S_VC0_PH_CREDITS) & M_VC0_PH_CREDITS)
-
-#define S_VC0_PD_CREDITS 0
-#define M_VC0_PD_CREDITS 0xfffU
-#define V_VC0_PD_CREDITS(x) ((x) << S_VC0_PD_CREDITS)
-#define G_VC0_PD_CREDITS(x) (((x) >> S_VC0_PD_CREDITS) & M_VC0_PD_CREDITS)
-
-#define A_PCIE_CORE_VC0_NONPOSTED_RECEIVE_QUEUE_CONTROL 0x574c
-
-#define S_VC0_NPTLP_QUEUE_MODE 21
-#define M_VC0_NPTLP_QUEUE_MODE 0x7U
-#define V_VC0_NPTLP_QUEUE_MODE(x) ((x) << S_VC0_NPTLP_QUEUE_MODE)
-#define G_VC0_NPTLP_QUEUE_MODE(x) (((x) >> S_VC0_NPTLP_QUEUE_MODE) & M_VC0_NPTLP_QUEUE_MODE)
-
-#define S_VC0_NPH_CREDITS 12
-#define M_VC0_NPH_CREDITS 0xffU
-#define V_VC0_NPH_CREDITS(x) ((x) << S_VC0_NPH_CREDITS)
-#define G_VC0_NPH_CREDITS(x) (((x) >> S_VC0_NPH_CREDITS) & M_VC0_NPH_CREDITS)
-
-#define S_VC0_NPD_CREDITS 0
-#define M_VC0_NPD_CREDITS 0xfffU
-#define V_VC0_NPD_CREDITS(x) ((x) << S_VC0_NPD_CREDITS)
-#define G_VC0_NPD_CREDITS(x) (((x) >> S_VC0_NPD_CREDITS) & M_VC0_NPD_CREDITS)
-
-#define A_PCIE_CORE_VC0_COMPLETION_RECEIVE_QUEUE_CONTROL 0x5750
-
-#define S_VC0_CPLTLP_QUEUE_MODE 21
-#define M_VC0_CPLTLP_QUEUE_MODE 0x7U
-#define V_VC0_CPLTLP_QUEUE_MODE(x) ((x) << S_VC0_CPLTLP_QUEUE_MODE)
-#define G_VC0_CPLTLP_QUEUE_MODE(x) (((x) >> S_VC0_CPLTLP_QUEUE_MODE) & M_VC0_CPLTLP_QUEUE_MODE)
-
-#define S_VC0_CPLH_CREDITS 12
-#define M_VC0_CPLH_CREDITS 0xffU
-#define V_VC0_CPLH_CREDITS(x) ((x) << S_VC0_CPLH_CREDITS)
-#define G_VC0_CPLH_CREDITS(x) (((x) >> S_VC0_CPLH_CREDITS) & M_VC0_CPLH_CREDITS)
-
-#define S_VC0_CPLD_CREDITS 0
-#define M_VC0_CPLD_CREDITS 0xfffU
-#define V_VC0_CPLD_CREDITS(x) ((x) << S_VC0_CPLD_CREDITS)
-#define G_VC0_CPLD_CREDITS(x) (((x) >> S_VC0_CPLD_CREDITS) & M_VC0_CPLD_CREDITS)
-
-#define A_PCIE_CORE_VC1_POSTED_RECEIVE_QUEUE_CONTROL 0x5754
-
-#define S_VC1_TLP_ORDERING 30
-#define V_VC1_TLP_ORDERING(x) ((x) << S_VC1_TLP_ORDERING)
-#define F_VC1_TLP_ORDERING V_VC1_TLP_ORDERING(1U)
-
-#define S_VC1_PTLP_QUEUE_MODE 21
-#define M_VC1_PTLP_QUEUE_MODE 0x7U
-#define V_VC1_PTLP_QUEUE_MODE(x) ((x) << S_VC1_PTLP_QUEUE_MODE)
-#define G_VC1_PTLP_QUEUE_MODE(x) (((x) >> S_VC1_PTLP_QUEUE_MODE) & M_VC1_PTLP_QUEUE_MODE)
-
-#define S_VC1_PH_CREDITS 12
-#define M_VC1_PH_CREDITS 0xffU
-#define V_VC1_PH_CREDITS(x) ((x) << S_VC1_PH_CREDITS)
-#define G_VC1_PH_CREDITS(x) (((x) >> S_VC1_PH_CREDITS) & M_VC1_PH_CREDITS)
-
-#define S_VC1_PD_CREDITS 0
-#define M_VC1_PD_CREDITS 0xfffU
-#define V_VC1_PD_CREDITS(x) ((x) << S_VC1_PD_CREDITS)
-#define G_VC1_PD_CREDITS(x) (((x) >> S_VC1_PD_CREDITS) & M_VC1_PD_CREDITS)
-
-#define A_PCIE_CORE_VC1_NONPOSTED_RECEIVE_QUEUE_CONTROL 0x5758
-
-#define S_VC1_NPTLP_QUEUE_MODE 21
-#define M_VC1_NPTLP_QUEUE_MODE 0x7U
-#define V_VC1_NPTLP_QUEUE_MODE(x) ((x) << S_VC1_NPTLP_QUEUE_MODE)
-#define G_VC1_NPTLP_QUEUE_MODE(x) (((x) >> S_VC1_NPTLP_QUEUE_MODE) & M_VC1_NPTLP_QUEUE_MODE)
-
-#define S_VC1_NPH_CREDITS 12
-#define M_VC1_NPH_CREDITS 0xffU
-#define V_VC1_NPH_CREDITS(x) ((x) << S_VC1_NPH_CREDITS)
-#define G_VC1_NPH_CREDITS(x) (((x) >> S_VC1_NPH_CREDITS) & M_VC1_NPH_CREDITS)
-
-#define S_VC1_NPD_CREDITS 0
-#define M_VC1_NPD_CREDITS 0xfffU
-#define V_VC1_NPD_CREDITS(x) ((x) << S_VC1_NPD_CREDITS)
-#define G_VC1_NPD_CREDITS(x) (((x) >> S_VC1_NPD_CREDITS) & M_VC1_NPD_CREDITS)
-
-#define A_PCIE_CORE_VC1_COMPLETION_RECEIVE_QUEUE_CONTROL 0x575c
-
-#define S_VC1_CPLTLP_QUEUE_MODE 21
-#define M_VC1_CPLTLP_QUEUE_MODE 0x7U
-#define V_VC1_CPLTLP_QUEUE_MODE(x) ((x) << S_VC1_CPLTLP_QUEUE_MODE)
-#define G_VC1_CPLTLP_QUEUE_MODE(x) (((x) >> S_VC1_CPLTLP_QUEUE_MODE) & M_VC1_CPLTLP_QUEUE_MODE)
-
-#define S_VC1_CPLH_CREDITS 12
-#define M_VC1_CPLH_CREDITS 0xffU
-#define V_VC1_CPLH_CREDITS(x) ((x) << S_VC1_CPLH_CREDITS)
-#define G_VC1_CPLH_CREDITS(x) (((x) >> S_VC1_CPLH_CREDITS) & M_VC1_CPLH_CREDITS)
-
-#define S_VC1_CPLD_CREDITS 0
-#define M_VC1_CPLD_CREDITS 0xfffU
-#define V_VC1_CPLD_CREDITS(x) ((x) << S_VC1_CPLD_CREDITS)
-#define G_VC1_CPLD_CREDITS(x) (((x) >> S_VC1_CPLD_CREDITS) & M_VC1_CPLD_CREDITS)
-
-#define A_PCIE_CORE_LINK_WIDTH_SPEED_CHANGE 0x580c
-
-#define S_SEL_DEEMPHASIS 20
-#define V_SEL_DEEMPHASIS(x) ((x) << S_SEL_DEEMPHASIS)
-#define F_SEL_DEEMPHASIS V_SEL_DEEMPHASIS(1U)
-
-#define S_TXCMPLRCV 19
-#define V_TXCMPLRCV(x) ((x) << S_TXCMPLRCV)
-#define F_TXCMPLRCV V_TXCMPLRCV(1U)
-
-#define S_PHYTXSWING 18
-#define V_PHYTXSWING(x) ((x) << S_PHYTXSWING)
-#define F_PHYTXSWING V_PHYTXSWING(1U)
-
-#define S_DIRSPDCHANGE 17
-#define V_DIRSPDCHANGE(x) ((x) << S_DIRSPDCHANGE)
-#define F_DIRSPDCHANGE V_DIRSPDCHANGE(1U)
-
-#define S_NUM_LANES 8
-#define M_NUM_LANES 0x1ffU
-#define V_NUM_LANES(x) ((x) << S_NUM_LANES)
-#define G_NUM_LANES(x) (((x) >> S_NUM_LANES) & M_NUM_LANES)
-
-#define S_NFTS_GEN2_3 0
-#define M_NFTS_GEN2_3 0xffU
-#define V_NFTS_GEN2_3(x) ((x) << S_NFTS_GEN2_3)
-#define G_NFTS_GEN2_3(x) (((x) >> S_NFTS_GEN2_3) & M_NFTS_GEN2_3)
-
-#define S_AUTO_LANE_FLIP_CTRL_EN 16
-#define V_AUTO_LANE_FLIP_CTRL_EN(x) ((x) << S_AUTO_LANE_FLIP_CTRL_EN)
-#define F_AUTO_LANE_FLIP_CTRL_EN V_AUTO_LANE_FLIP_CTRL_EN(1U)
-
-#define S_T6_NUM_LANES 8
-#define M_T6_NUM_LANES 0x1fU
-#define V_T6_NUM_LANES(x) ((x) << S_T6_NUM_LANES)
-#define G_T6_NUM_LANES(x) (((x) >> S_T6_NUM_LANES) & M_T6_NUM_LANES)
-
-#define A_PCIE_CORE_PHY_STATUS 0x5810
-#define A_PCIE_CORE_PHY_CONTROL 0x5814
-#define A_PCIE_CORE_GEN3_CONTROL 0x5890
-
-#define S_DC_BALANCE_DISABLE 18
-#define V_DC_BALANCE_DISABLE(x) ((x) << S_DC_BALANCE_DISABLE)
-#define F_DC_BALANCE_DISABLE V_DC_BALANCE_DISABLE(1U)
-
-#define S_DLLP_DELAY_DISABLE 17
-#define V_DLLP_DELAY_DISABLE(x) ((x) << S_DLLP_DELAY_DISABLE)
-#define F_DLLP_DELAY_DISABLE V_DLLP_DELAY_DISABLE(1U)
-
-#define S_EQL_DISABLE 16
-#define V_EQL_DISABLE(x) ((x) << S_EQL_DISABLE)
-#define F_EQL_DISABLE V_EQL_DISABLE(1U)
-
-#define S_EQL_REDO_DISABLE 11
-#define V_EQL_REDO_DISABLE(x) ((x) << S_EQL_REDO_DISABLE)
-#define F_EQL_REDO_DISABLE V_EQL_REDO_DISABLE(1U)
-
-#define S_EQL_EIEOS_CNTRST_DISABLE 10
-#define V_EQL_EIEOS_CNTRST_DISABLE(x) ((x) << S_EQL_EIEOS_CNTRST_DISABLE)
-#define F_EQL_EIEOS_CNTRST_DISABLE V_EQL_EIEOS_CNTRST_DISABLE(1U)
-
-#define S_EQL_PH2_PH3_DISABLE 9
-#define V_EQL_PH2_PH3_DISABLE(x) ((x) << S_EQL_PH2_PH3_DISABLE)
-#define F_EQL_PH2_PH3_DISABLE V_EQL_PH2_PH3_DISABLE(1U)
-
-#define S_DISABLE_SCRAMBLER 8
-#define V_DISABLE_SCRAMBLER(x) ((x) << S_DISABLE_SCRAMBLER)
-#define F_DISABLE_SCRAMBLER V_DISABLE_SCRAMBLER(1U)
-
-#define A_PCIE_CORE_GEN3_EQ_FS_LF 0x5894
-
-#define S_FULL_SWING 6
-#define M_FULL_SWING 0x3fU
-#define V_FULL_SWING(x) ((x) << S_FULL_SWING)
-#define G_FULL_SWING(x) (((x) >> S_FULL_SWING) & M_FULL_SWING)
-
-#define S_LOW_FREQUENCY 0
-#define M_LOW_FREQUENCY 0x3fU
-#define V_LOW_FREQUENCY(x) ((x) << S_LOW_FREQUENCY)
-#define G_LOW_FREQUENCY(x) (((x) >> S_LOW_FREQUENCY) & M_LOW_FREQUENCY)
-
-#define A_PCIE_CORE_GEN3_EQ_PRESET_COEFF 0x5898
-
-#define S_POSTCURSOR 12
-#define M_POSTCURSOR 0x3fU
-#define V_POSTCURSOR(x) ((x) << S_POSTCURSOR)
-#define G_POSTCURSOR(x) (((x) >> S_POSTCURSOR) & M_POSTCURSOR)
-
-#define S_CURSOR 6
-#define M_CURSOR 0x3fU
-#define V_CURSOR(x) ((x) << S_CURSOR)
-#define G_CURSOR(x) (((x) >> S_CURSOR) & M_CURSOR)
-
-#define S_PRECURSOR 0
-#define M_PRECURSOR 0x3fU
-#define V_PRECURSOR(x) ((x) << S_PRECURSOR)
-#define G_PRECURSOR(x) (((x) >> S_PRECURSOR) & M_PRECURSOR)
-
-#define A_PCIE_CORE_GEN3_EQ_PRESET_INDEX 0x589c
-
-#define S_INDEX 0
-#define M_INDEX 0xfU
-#define V_INDEX(x) ((x) << S_INDEX)
-#define G_INDEX(x) (((x) >> S_INDEX) & M_INDEX)
-
-#define A_PCIE_CORE_GEN3_EQ_STATUS 0x58a4
-
-#define S_LEGALITY_STATUS 0
-#define V_LEGALITY_STATUS(x) ((x) << S_LEGALITY_STATUS)
-#define F_LEGALITY_STATUS V_LEGALITY_STATUS(1U)
-
-#define A_PCIE_CORE_GEN3_EQ_CONTROL 0x58a8
-
-#define S_INCLUDE_INITIAL_FOM 24
-#define V_INCLUDE_INITIAL_FOM(x) ((x) << S_INCLUDE_INITIAL_FOM)
-#define F_INCLUDE_INITIAL_FOM V_INCLUDE_INITIAL_FOM(1U)
-
-#define S_PRESET_REQUEST_VECTOR 8
-#define M_PRESET_REQUEST_VECTOR 0xffffU
-#define V_PRESET_REQUEST_VECTOR(x) ((x) << S_PRESET_REQUEST_VECTOR)
-#define G_PRESET_REQUEST_VECTOR(x) (((x) >> S_PRESET_REQUEST_VECTOR) & M_PRESET_REQUEST_VECTOR)
-
-#define S_PHASE23_2MS_TIMEOUT_DISABLE 5
-#define V_PHASE23_2MS_TIMEOUT_DISABLE(x) ((x) << S_PHASE23_2MS_TIMEOUT_DISABLE)
-#define F_PHASE23_2MS_TIMEOUT_DISABLE V_PHASE23_2MS_TIMEOUT_DISABLE(1U)
-
-#define S_AFTER24MS 4
-#define V_AFTER24MS(x) ((x) << S_AFTER24MS)
-#define F_AFTER24MS V_AFTER24MS(1U)
-
-#define S_FEEDBACK_MODE 0
-#define M_FEEDBACK_MODE 0xfU
-#define V_FEEDBACK_MODE(x) ((x) << S_FEEDBACK_MODE)
-#define G_FEEDBACK_MODE(x) (((x) >> S_FEEDBACK_MODE) & M_FEEDBACK_MODE)
-
-#define A_PCIE_CORE_GEN3_EQ_DIRCHANGE_FEEDBACK 0x58ac
-
-#define S_WINAPERTURE_CPLUS1 14
-#define M_WINAPERTURE_CPLUS1 0xfU
-#define V_WINAPERTURE_CPLUS1(x) ((x) << S_WINAPERTURE_CPLUS1)
-#define G_WINAPERTURE_CPLUS1(x) (((x) >> S_WINAPERTURE_CPLUS1) & M_WINAPERTURE_CPLUS1)
-
-#define S_WINAPERTURE_CMINS1 10
-#define M_WINAPERTURE_CMINS1 0xfU
-#define V_WINAPERTURE_CMINS1(x) ((x) << S_WINAPERTURE_CMINS1)
-#define G_WINAPERTURE_CMINS1(x) (((x) >> S_WINAPERTURE_CMINS1) & M_WINAPERTURE_CMINS1)
-
-#define S_CONVERGENCE_WINDEPTH 5
-#define M_CONVERGENCE_WINDEPTH 0x1fU
-#define V_CONVERGENCE_WINDEPTH(x) ((x) << S_CONVERGENCE_WINDEPTH)
-#define G_CONVERGENCE_WINDEPTH(x) (((x) >> S_CONVERGENCE_WINDEPTH) & M_CONVERGENCE_WINDEPTH)
-
-#define S_EQMASTERPHASE_MINTIME 0
-#define M_EQMASTERPHASE_MINTIME 0x1fU
-#define V_EQMASTERPHASE_MINTIME(x) ((x) << S_EQMASTERPHASE_MINTIME)
-#define G_EQMASTERPHASE_MINTIME(x) (((x) >> S_EQMASTERPHASE_MINTIME) & M_EQMASTERPHASE_MINTIME)
-
-#define A_PCIE_CORE_PIPE_CONTROL 0x58b8
-
-#define S_PIPE_LOOPBACK_EN 0
-#define V_PIPE_LOOPBACK_EN(x) ((x) << S_PIPE_LOOPBACK_EN)
-#define F_PIPE_LOOPBACK_EN V_PIPE_LOOPBACK_EN(1U)
-
-#define S_T6_PIPE_LOOPBACK_EN 31
-#define V_T6_PIPE_LOOPBACK_EN(x) ((x) << S_T6_PIPE_LOOPBACK_EN)
-#define F_T6_PIPE_LOOPBACK_EN V_T6_PIPE_LOOPBACK_EN(1U)
-
-#define A_PCIE_CORE_DBI_RO_WE 0x58bc
-
-#define S_READONLY_WRITEEN 0
-#define V_READONLY_WRITEEN(x) ((x) << S_READONLY_WRITEEN)
-#define F_READONLY_WRITEEN V_READONLY_WRITEEN(1U)
-
-#define A_PCIE_CORE_UTL_SYSTEM_BUS_CONTROL 0x5900
-
-#define S_SMTD 27
-#define V_SMTD(x) ((x) << S_SMTD)
-#define F_SMTD V_SMTD(1U)
-
-#define S_SSTD 26
-#define V_SSTD(x) ((x) << S_SSTD)
-#define F_SSTD V_SSTD(1U)
-
-#define S_SWD0 23
-#define V_SWD0(x) ((x) << S_SWD0)
-#define F_SWD0 V_SWD0(1U)
-
-#define S_SWD1 22
-#define V_SWD1(x) ((x) << S_SWD1)
-#define F_SWD1 V_SWD1(1U)
-
-#define S_SWD2 21
-#define V_SWD2(x) ((x) << S_SWD2)
-#define F_SWD2 V_SWD2(1U)
-
-#define S_SWD3 20
-#define V_SWD3(x) ((x) << S_SWD3)
-#define F_SWD3 V_SWD3(1U)
-
-#define S_SWD4 19
-#define V_SWD4(x) ((x) << S_SWD4)
-#define F_SWD4 V_SWD4(1U)
-
-#define S_SWD5 18
-#define V_SWD5(x) ((x) << S_SWD5)
-#define F_SWD5 V_SWD5(1U)
-
-#define S_SWD6 17
-#define V_SWD6(x) ((x) << S_SWD6)
-#define F_SWD6 V_SWD6(1U)
-
-#define S_SWD7 16
-#define V_SWD7(x) ((x) << S_SWD7)
-#define F_SWD7 V_SWD7(1U)
-
-#define S_SWD8 15
-#define V_SWD8(x) ((x) << S_SWD8)
-#define F_SWD8 V_SWD8(1U)
-
-#define S_SRD0 13
-#define V_SRD0(x) ((x) << S_SRD0)
-#define F_SRD0 V_SRD0(1U)
-
-#define S_SRD1 12
-#define V_SRD1(x) ((x) << S_SRD1)
-#define F_SRD1 V_SRD1(1U)
-
-#define S_SRD2 11
-#define V_SRD2(x) ((x) << S_SRD2)
-#define F_SRD2 V_SRD2(1U)
-
-#define S_SRD3 10
-#define V_SRD3(x) ((x) << S_SRD3)
-#define F_SRD3 V_SRD3(1U)
-
-#define S_SRD4 9
-#define V_SRD4(x) ((x) << S_SRD4)
-#define F_SRD4 V_SRD4(1U)
-
-#define S_SRD5 8
-#define V_SRD5(x) ((x) << S_SRD5)
-#define F_SRD5 V_SRD5(1U)
-
-#define S_SRD6 7
-#define V_SRD6(x) ((x) << S_SRD6)
-#define F_SRD6 V_SRD6(1U)
-
-#define S_SRD7 6
-#define V_SRD7(x) ((x) << S_SRD7)
-#define F_SRD7 V_SRD7(1U)
-
-#define S_SRD8 5
-#define V_SRD8(x) ((x) << S_SRD8)
-#define F_SRD8 V_SRD8(1U)
-
-#define S_CRRE 3
-#define V_CRRE(x) ((x) << S_CRRE)
-#define F_CRRE V_CRRE(1U)
-
-#define S_CRMC 0
-#define M_CRMC 0x7U
-#define V_CRMC(x) ((x) << S_CRMC)
-#define G_CRMC(x) (((x) >> S_CRMC) & M_CRMC)
-
-#define A_PCIE_CORE_UTL_STATUS 0x5904
-
-#define S_USBP 31
-#define V_USBP(x) ((x) << S_USBP)
-#define F_USBP V_USBP(1U)
-
-#define S_UPEP 30
-#define V_UPEP(x) ((x) << S_UPEP)
-#define F_UPEP V_UPEP(1U)
-
-#define S_RCEP 29
-#define V_RCEP(x) ((x) << S_RCEP)
-#define F_RCEP V_RCEP(1U)
-
-#define S_EPEP 28
-#define V_EPEP(x) ((x) << S_EPEP)
-#define F_EPEP V_EPEP(1U)
-
-#define S_USBS 27
-#define V_USBS(x) ((x) << S_USBS)
-#define F_USBS V_USBS(1U)
-
-#define S_UPES 26
-#define V_UPES(x) ((x) << S_UPES)
-#define F_UPES V_UPES(1U)
-
-#define S_RCES 25
-#define V_RCES(x) ((x) << S_RCES)
-#define F_RCES V_RCES(1U)
-
-#define S_EPES 24
-#define V_EPES(x) ((x) << S_EPES)
-#define F_EPES V_EPES(1U)
-
-#define A_PCIE_CORE_UTL_SYSTEM_BUS_AGENT_STATUS 0x5908
-
-#define S_RNPP 31
-#define V_RNPP(x) ((x) << S_RNPP)
-#define F_RNPP V_RNPP(1U)
-
-#define S_RPCP 29
-#define V_RPCP(x) ((x) << S_RPCP)
-#define F_RPCP V_RPCP(1U)
-
-#define S_RCIP 27
-#define V_RCIP(x) ((x) << S_RCIP)
-#define F_RCIP V_RCIP(1U)
-
-#define S_RCCP 26
-#define V_RCCP(x) ((x) << S_RCCP)
-#define F_RCCP V_RCCP(1U)
-
-#define S_RFTP 23
-#define V_RFTP(x) ((x) << S_RFTP)
-#define F_RFTP V_RFTP(1U)
-
-#define S_PTRP 20
-#define V_PTRP(x) ((x) << S_PTRP)
-#define F_PTRP V_PTRP(1U)
-
-#define A_PCIE_CORE_UTL_SYSTEM_BUS_AGENT_ERROR_SEVERITY 0x590c
-
-#define S_RNPS 31
-#define V_RNPS(x) ((x) << S_RNPS)
-#define F_RNPS V_RNPS(1U)
-
-#define S_RPCS 29
-#define V_RPCS(x) ((x) << S_RPCS)
-#define F_RPCS V_RPCS(1U)
-
-#define S_RCIS 27
-#define V_RCIS(x) ((x) << S_RCIS)
-#define F_RCIS V_RCIS(1U)
-
-#define S_RCCS 26
-#define V_RCCS(x) ((x) << S_RCCS)
-#define F_RCCS V_RCCS(1U)
-
-#define S_RFTS 23
-#define V_RFTS(x) ((x) << S_RFTS)
-#define F_RFTS V_RFTS(1U)
-
-#define A_PCIE_CORE_UTL_SYSTEM_BUS_AGENT_INTERRUPT_ENABLE 0x5910
-
-#define S_RNPI 31
-#define V_RNPI(x) ((x) << S_RNPI)
-#define F_RNPI V_RNPI(1U)
-
-#define S_RPCI 29
-#define V_RPCI(x) ((x) << S_RPCI)
-#define F_RPCI V_RPCI(1U)
-
-#define S_RCII 27
-#define V_RCII(x) ((x) << S_RCII)
-#define F_RCII V_RCII(1U)
-
-#define S_RCCI 26
-#define V_RCCI(x) ((x) << S_RCCI)
-#define F_RCCI V_RCCI(1U)
-
-#define S_RFTI 23
-#define V_RFTI(x) ((x) << S_RFTI)
-#define F_RFTI V_RFTI(1U)
-
-#define A_PCIE_CORE_SYSTEM_BUS_BURST_SIZE_CONFIGURATION 0x5920
-
-#define S_SBRS 28
-#define M_SBRS 0x7U
-#define V_SBRS(x) ((x) << S_SBRS)
-#define G_SBRS(x) (((x) >> S_SBRS) & M_SBRS)
-
-#define S_OTWS 20
-#define M_OTWS 0x7U
-#define V_OTWS(x) ((x) << S_OTWS)
-#define G_OTWS(x) (((x) >> S_OTWS) & M_OTWS)
-
-#define A_PCIE_CORE_REVISION_ID 0x5924
-
-#define S_RVID 20
-#define M_RVID 0xfffU
-#define V_RVID(x) ((x) << S_RVID)
-#define G_RVID(x) (((x) >> S_RVID) & M_RVID)
-
-#define S_BRVN 12
-#define M_BRVN 0xffU
-#define V_BRVN(x) ((x) << S_BRVN)
-#define G_BRVN(x) (((x) >> S_BRVN) & M_BRVN)
-
-#define A_PCIE_T5_DMA_CFG 0x5940
-
-#define S_T5_DMA_MAXREQCNT 20
-#define M_T5_DMA_MAXREQCNT 0xffU
-#define V_T5_DMA_MAXREQCNT(x) ((x) << S_T5_DMA_MAXREQCNT)
-#define G_T5_DMA_MAXREQCNT(x) (((x) >> S_T5_DMA_MAXREQCNT) & M_T5_DMA_MAXREQCNT)
-
-#define S_T5_DMA_MAXRDREQSIZE 17
-#define M_T5_DMA_MAXRDREQSIZE 0x7U
-#define V_T5_DMA_MAXRDREQSIZE(x) ((x) << S_T5_DMA_MAXRDREQSIZE)
-#define G_T5_DMA_MAXRDREQSIZE(x) (((x) >> S_T5_DMA_MAXRDREQSIZE) & M_T5_DMA_MAXRDREQSIZE)
-
-#define S_T5_DMA_MAXRSPCNT 8
-#define M_T5_DMA_MAXRSPCNT 0x1ffU
-#define V_T5_DMA_MAXRSPCNT(x) ((x) << S_T5_DMA_MAXRSPCNT)
-#define G_T5_DMA_MAXRSPCNT(x) (((x) >> S_T5_DMA_MAXRSPCNT) & M_T5_DMA_MAXRSPCNT)
-
-#define S_SEQCHKDIS 7
-#define V_SEQCHKDIS(x) ((x) << S_SEQCHKDIS)
-#define F_SEQCHKDIS V_SEQCHKDIS(1U)
-
-#define S_MINTAG 0
-#define M_MINTAG 0x7fU
-#define V_MINTAG(x) ((x) << S_MINTAG)
-#define G_MINTAG(x) (((x) >> S_MINTAG) & M_MINTAG)
-
-#define S_T6_T5_DMA_MAXREQCNT 20
-#define M_T6_T5_DMA_MAXREQCNT 0x7fU
-#define V_T6_T5_DMA_MAXREQCNT(x) ((x) << S_T6_T5_DMA_MAXREQCNT)
-#define G_T6_T5_DMA_MAXREQCNT(x) (((x) >> S_T6_T5_DMA_MAXREQCNT) & M_T6_T5_DMA_MAXREQCNT)
-
-#define S_T6_T5_DMA_MAXRSPCNT 9
-#define M_T6_T5_DMA_MAXRSPCNT 0xffU
-#define V_T6_T5_DMA_MAXRSPCNT(x) ((x) << S_T6_T5_DMA_MAXRSPCNT)
-#define G_T6_T5_DMA_MAXRSPCNT(x) (((x) >> S_T6_T5_DMA_MAXRSPCNT) & M_T6_T5_DMA_MAXRSPCNT)
-
-#define S_T6_SEQCHKDIS 8
-#define V_T6_SEQCHKDIS(x) ((x) << S_T6_SEQCHKDIS)
-#define F_T6_SEQCHKDIS V_T6_SEQCHKDIS(1U)
-
-#define S_T6_MINTAG 0
-#define M_T6_MINTAG 0xffU
-#define V_T6_MINTAG(x) ((x) << S_T6_MINTAG)
-#define G_T6_MINTAG(x) (((x) >> S_T6_MINTAG) & M_T6_MINTAG)
-
-#define A_PCIE_T5_DMA_STAT 0x5944
-
-#define S_DMA_RESPCNT 20
-#define M_DMA_RESPCNT 0xfffU
-#define V_DMA_RESPCNT(x) ((x) << S_DMA_RESPCNT)
-#define G_DMA_RESPCNT(x) (((x) >> S_DMA_RESPCNT) & M_DMA_RESPCNT)
-
-#define S_DMA_RDREQCNT 12
-#define M_DMA_RDREQCNT 0xffU
-#define V_DMA_RDREQCNT(x) ((x) << S_DMA_RDREQCNT)
-#define G_DMA_RDREQCNT(x) (((x) >> S_DMA_RDREQCNT) & M_DMA_RDREQCNT)
-
-#define S_DMA_WRREQCNT 0
-#define M_DMA_WRREQCNT 0x7ffU
-#define V_DMA_WRREQCNT(x) ((x) << S_DMA_WRREQCNT)
-#define G_DMA_WRREQCNT(x) (((x) >> S_DMA_WRREQCNT) & M_DMA_WRREQCNT)
-
-#define S_T6_DMA_RESPCNT 20
-#define M_T6_DMA_RESPCNT 0x3ffU
-#define V_T6_DMA_RESPCNT(x) ((x) << S_T6_DMA_RESPCNT)
-#define G_T6_DMA_RESPCNT(x) (((x) >> S_T6_DMA_RESPCNT) & M_T6_DMA_RESPCNT)
-
-#define S_T6_DMA_RDREQCNT 12
-#define M_T6_DMA_RDREQCNT 0x3fU
-#define V_T6_DMA_RDREQCNT(x) ((x) << S_T6_DMA_RDREQCNT)
-#define G_T6_DMA_RDREQCNT(x) (((x) >> S_T6_DMA_RDREQCNT) & M_T6_DMA_RDREQCNT)
-
-#define S_T6_DMA_WRREQCNT 0
-#define M_T6_DMA_WRREQCNT 0x1ffU
-#define V_T6_DMA_WRREQCNT(x) ((x) << S_T6_DMA_WRREQCNT)
-#define G_T6_DMA_WRREQCNT(x) (((x) >> S_T6_DMA_WRREQCNT) & M_T6_DMA_WRREQCNT)
-
-#define A_PCIE_T5_DMA_STAT2 0x5948
-
-#define S_COOKIECNT 24
-#define M_COOKIECNT 0xfU
-#define V_COOKIECNT(x) ((x) << S_COOKIECNT)
-#define G_COOKIECNT(x) (((x) >> S_COOKIECNT) & M_COOKIECNT)
-
-#define S_RDSEQNUMUPDCNT 20
-#define M_RDSEQNUMUPDCNT 0xfU
-#define V_RDSEQNUMUPDCNT(x) ((x) << S_RDSEQNUMUPDCNT)
-#define G_RDSEQNUMUPDCNT(x) (((x) >> S_RDSEQNUMUPDCNT) & M_RDSEQNUMUPDCNT)
-
-#define S_SIREQCNT 16
-#define M_SIREQCNT 0xfU
-#define V_SIREQCNT(x) ((x) << S_SIREQCNT)
-#define G_SIREQCNT(x) (((x) >> S_SIREQCNT) & M_SIREQCNT)
-
-#define S_WREOPMATCHSOP 12
-#define V_WREOPMATCHSOP(x) ((x) << S_WREOPMATCHSOP)
-#define F_WREOPMATCHSOP V_WREOPMATCHSOP(1U)
-
-#define S_WRSOPCNT 8
-#define M_WRSOPCNT 0xfU
-#define V_WRSOPCNT(x) ((x) << S_WRSOPCNT)
-#define G_WRSOPCNT(x) (((x) >> S_WRSOPCNT) & M_WRSOPCNT)
-
-#define S_RDSOPCNT 0
-#define M_RDSOPCNT 0xffU
-#define V_RDSOPCNT(x) ((x) << S_RDSOPCNT)
-#define G_RDSOPCNT(x) (((x) >> S_RDSOPCNT) & M_RDSOPCNT)
-
-#define A_PCIE_T5_DMA_STAT3 0x594c
-
-#define S_ATMREQSOPCNT 24
-#define M_ATMREQSOPCNT 0xffU
-#define V_ATMREQSOPCNT(x) ((x) << S_ATMREQSOPCNT)
-#define G_ATMREQSOPCNT(x) (((x) >> S_ATMREQSOPCNT) & M_ATMREQSOPCNT)
-
-#define S_ATMEOPMATCHSOP 17
-#define V_ATMEOPMATCHSOP(x) ((x) << S_ATMEOPMATCHSOP)
-#define F_ATMEOPMATCHSOP V_ATMEOPMATCHSOP(1U)
-
-#define S_RSPEOPMATCHSOP 16
-#define V_RSPEOPMATCHSOP(x) ((x) << S_RSPEOPMATCHSOP)
-#define F_RSPEOPMATCHSOP V_RSPEOPMATCHSOP(1U)
-
-#define S_RSPERRCNT 8
-#define M_RSPERRCNT 0xffU
-#define V_RSPERRCNT(x) ((x) << S_RSPERRCNT)
-#define G_RSPERRCNT(x) (((x) >> S_RSPERRCNT) & M_RSPERRCNT)
-
-#define S_RSPSOPCNT 0
-#define M_RSPSOPCNT 0xffU
-#define V_RSPSOPCNT(x) ((x) << S_RSPSOPCNT)
-#define G_RSPSOPCNT(x) (((x) >> S_RSPSOPCNT) & M_RSPSOPCNT)
-
-#define A_PCIE_CORE_OUTBOUND_POSTED_HEADER_BUFFER_ALLOCATION 0x5960
-
-#define S_OP0H 24
-#define M_OP0H 0xfU
-#define V_OP0H(x) ((x) << S_OP0H)
-#define G_OP0H(x) (((x) >> S_OP0H) & M_OP0H)
-
-#define S_OP1H 16
-#define M_OP1H 0xfU
-#define V_OP1H(x) ((x) << S_OP1H)
-#define G_OP1H(x) (((x) >> S_OP1H) & M_OP1H)
-
-#define S_OP2H 8
-#define M_OP2H 0xfU
-#define V_OP2H(x) ((x) << S_OP2H)
-#define G_OP2H(x) (((x) >> S_OP2H) & M_OP2H)
-
-#define S_OP3H 0
-#define M_OP3H 0xfU
-#define V_OP3H(x) ((x) << S_OP3H)
-#define G_OP3H(x) (((x) >> S_OP3H) & M_OP3H)
-
-#define A_PCIE_CORE_OUTBOUND_POSTED_DATA_BUFFER_ALLOCATION 0x5968
-
-#define S_OP0D 24
-#define M_OP0D 0x7fU
-#define V_OP0D(x) ((x) << S_OP0D)
-#define G_OP0D(x) (((x) >> S_OP0D) & M_OP0D)
-
-#define S_OP1D 16
-#define M_OP1D 0x7fU
-#define V_OP1D(x) ((x) << S_OP1D)
-#define G_OP1D(x) (((x) >> S_OP1D) & M_OP1D)
-
-#define S_OP2D 8
-#define M_OP2D 0x7fU
-#define V_OP2D(x) ((x) << S_OP2D)
-#define G_OP2D(x) (((x) >> S_OP2D) & M_OP2D)
-
-#define S_OP3D 0
-#define M_OP3D 0x7fU
-#define V_OP3D(x) ((x) << S_OP3D)
-#define G_OP3D(x) (((x) >> S_OP3D) & M_OP3D)
-
-#define A_PCIE_CORE_INBOUND_POSTED_HEADER_BUFFER_ALLOCATION 0x5970
-
-#define S_IP0H 24
-#define M_IP0H 0x3fU
-#define V_IP0H(x) ((x) << S_IP0H)
-#define G_IP0H(x) (((x) >> S_IP0H) & M_IP0H)
-
-#define S_IP1H 16
-#define M_IP1H 0x3fU
-#define V_IP1H(x) ((x) << S_IP1H)
-#define G_IP1H(x) (((x) >> S_IP1H) & M_IP1H)
-
-#define S_IP2H 8
-#define M_IP2H 0x3fU
-#define V_IP2H(x) ((x) << S_IP2H)
-#define G_IP2H(x) (((x) >> S_IP2H) & M_IP2H)
-
-#define S_IP3H 0
-#define M_IP3H 0x3fU
-#define V_IP3H(x) ((x) << S_IP3H)
-#define G_IP3H(x) (((x) >> S_IP3H) & M_IP3H)
-
-#define A_PCIE_CORE_INBOUND_POSTED_DATA_BUFFER_ALLOCATION 0x5978
-
-#define S_IP0D 24
-#define M_IP0D 0xffU
-#define V_IP0D(x) ((x) << S_IP0D)
-#define G_IP0D(x) (((x) >> S_IP0D) & M_IP0D)
-
-#define S_IP1D 16
-#define M_IP1D 0xffU
-#define V_IP1D(x) ((x) << S_IP1D)
-#define G_IP1D(x) (((x) >> S_IP1D) & M_IP1D)
-
-#define S_IP2D 8
-#define M_IP2D 0xffU
-#define V_IP2D(x) ((x) << S_IP2D)
-#define G_IP2D(x) (((x) >> S_IP2D) & M_IP2D)
-
-#define S_IP3D 0
-#define M_IP3D 0xffU
-#define V_IP3D(x) ((x) << S_IP3D)
-#define G_IP3D(x) (((x) >> S_IP3D) & M_IP3D)
-
-#define A_PCIE_CORE_OUTBOUND_NON_POSTED_BUFFER_ALLOCATION 0x5980
-
-#define S_ON0H 24
-#define M_ON0H 0xfU
-#define V_ON0H(x) ((x) << S_ON0H)
-#define G_ON0H(x) (((x) >> S_ON0H) & M_ON0H)
-
-#define S_ON1H 16
-#define M_ON1H 0xfU
-#define V_ON1H(x) ((x) << S_ON1H)
-#define G_ON1H(x) (((x) >> S_ON1H) & M_ON1H)
-
-#define S_ON2H 8
-#define M_ON2H 0xfU
-#define V_ON2H(x) ((x) << S_ON2H)
-#define G_ON2H(x) (((x) >> S_ON2H) & M_ON2H)
-
-#define S_ON3H 0
-#define M_ON3H 0xfU
-#define V_ON3H(x) ((x) << S_ON3H)
-#define G_ON3H(x) (((x) >> S_ON3H) & M_ON3H)
-
-#define A_PCIE_T5_CMD_CFG 0x5980
-
-#define S_T5_CMD_MAXRDREQSIZE 17
-#define M_T5_CMD_MAXRDREQSIZE 0x7U
-#define V_T5_CMD_MAXRDREQSIZE(x) ((x) << S_T5_CMD_MAXRDREQSIZE)
-#define G_T5_CMD_MAXRDREQSIZE(x) (((x) >> S_T5_CMD_MAXRDREQSIZE) & M_T5_CMD_MAXRDREQSIZE)
-
-#define S_T5_CMD_MAXRSPCNT 8
-#define M_T5_CMD_MAXRSPCNT 0xffU
-#define V_T5_CMD_MAXRSPCNT(x) ((x) << S_T5_CMD_MAXRSPCNT)
-#define G_T5_CMD_MAXRSPCNT(x) (((x) >> S_T5_CMD_MAXRSPCNT) & M_T5_CMD_MAXRSPCNT)
-
-#define S_USECMDPOOL 7
-#define V_USECMDPOOL(x) ((x) << S_USECMDPOOL)
-#define F_USECMDPOOL V_USECMDPOOL(1U)
-
-#define S_T6_T5_CMD_MAXRSPCNT 9
-#define M_T6_T5_CMD_MAXRSPCNT 0x3fU
-#define V_T6_T5_CMD_MAXRSPCNT(x) ((x) << S_T6_T5_CMD_MAXRSPCNT)
-#define G_T6_T5_CMD_MAXRSPCNT(x) (((x) >> S_T6_T5_CMD_MAXRSPCNT) & M_T6_T5_CMD_MAXRSPCNT)
-
-#define S_T6_USECMDPOOL 8
-#define V_T6_USECMDPOOL(x) ((x) << S_T6_USECMDPOOL)
-#define F_T6_USECMDPOOL V_T6_USECMDPOOL(1U)
-
-#define S_T6_MINTAG 0
-#define M_T6_MINTAG 0xffU
-#define V_T6_MINTAG(x) ((x) << S_T6_MINTAG)
-#define G_T6_MINTAG(x) (((x) >> S_T6_MINTAG) & M_T6_MINTAG)
-
-#define A_PCIE_T5_CMD_STAT 0x5984
-
-#define S_T5_STAT_RSPCNT 20
-#define M_T5_STAT_RSPCNT 0x7ffU
-#define V_T5_STAT_RSPCNT(x) ((x) << S_T5_STAT_RSPCNT)
-#define G_T5_STAT_RSPCNT(x) (((x) >> S_T5_STAT_RSPCNT) & M_T5_STAT_RSPCNT)
-
-#define S_RDREQCNT 12
-#define M_RDREQCNT 0x1fU
-#define V_RDREQCNT(x) ((x) << S_RDREQCNT)
-#define G_RDREQCNT(x) (((x) >> S_RDREQCNT) & M_RDREQCNT)
-
-#define S_T6_T5_STAT_RSPCNT 20
-#define M_T6_T5_STAT_RSPCNT 0xffU
-#define V_T6_T5_STAT_RSPCNT(x) ((x) << S_T6_T5_STAT_RSPCNT)
-#define G_T6_T5_STAT_RSPCNT(x) (((x) >> S_T6_T5_STAT_RSPCNT) & M_T6_T5_STAT_RSPCNT)
-
-#define S_T6_RDREQCNT 12
-#define M_T6_RDREQCNT 0xfU
-#define V_T6_RDREQCNT(x) ((x) << S_T6_RDREQCNT)
-#define G_T6_RDREQCNT(x) (((x) >> S_T6_RDREQCNT) & M_T6_RDREQCNT)
-
-#define A_PCIE_CORE_INBOUND_NON_POSTED_REQUESTS_BUFFER_ALLOCATION 0x5988
-
-#define S_IN0H 24
-#define M_IN0H 0x3fU
-#define V_IN0H(x) ((x) << S_IN0H)
-#define G_IN0H(x) (((x) >> S_IN0H) & M_IN0H)
-
-#define S_IN1H 16
-#define M_IN1H 0x3fU
-#define V_IN1H(x) ((x) << S_IN1H)
-#define G_IN1H(x) (((x) >> S_IN1H) & M_IN1H)
-
-#define S_IN2H 8
-#define M_IN2H 0x3fU
-#define V_IN2H(x) ((x) << S_IN2H)
-#define G_IN2H(x) (((x) >> S_IN2H) & M_IN2H)
-
-#define S_IN3H 0
-#define M_IN3H 0x3fU
-#define V_IN3H(x) ((x) << S_IN3H)
-#define G_IN3H(x) (((x) >> S_IN3H) & M_IN3H)
-
-#define A_PCIE_T5_CMD_STAT2 0x5988
-#define A_PCIE_T5_CMD_STAT3 0x598c
-#define A_PCIE_CORE_PCI_EXPRESS_TAGS_ALLOCATION 0x5990
-
-#define S_OC0T 24
-#define M_OC0T 0xffU
-#define V_OC0T(x) ((x) << S_OC0T)
-#define G_OC0T(x) (((x) >> S_OC0T) & M_OC0T)
-
-#define S_OC1T 16
-#define M_OC1T 0xffU
-#define V_OC1T(x) ((x) << S_OC1T)
-#define G_OC1T(x) (((x) >> S_OC1T) & M_OC1T)
-
-#define S_OC2T 8
-#define M_OC2T 0xffU
-#define V_OC2T(x) ((x) << S_OC2T)
-#define G_OC2T(x) (((x) >> S_OC2T) & M_OC2T)
-
-#define S_OC3T 0
-#define M_OC3T 0xffU
-#define V_OC3T(x) ((x) << S_OC3T)
-#define G_OC3T(x) (((x) >> S_OC3T) & M_OC3T)
-
-#define A_PCIE_CORE_GBIF_READ_TAGS_ALLOCATION 0x5998
-
-#define S_IC0T 24
-#define M_IC0T 0x3fU
-#define V_IC0T(x) ((x) << S_IC0T)
-#define G_IC0T(x) (((x) >> S_IC0T) & M_IC0T)
-
-#define S_IC1T 16
-#define M_IC1T 0x3fU
-#define V_IC1T(x) ((x) << S_IC1T)
-#define G_IC1T(x) (((x) >> S_IC1T) & M_IC1T)
-
-#define S_IC2T 8
-#define M_IC2T 0x3fU
-#define V_IC2T(x) ((x) << S_IC2T)
-#define G_IC2T(x) (((x) >> S_IC2T) & M_IC2T)
-
-#define S_IC3T 0
-#define M_IC3T 0x3fU
-#define V_IC3T(x) ((x) << S_IC3T)
-#define G_IC3T(x) (((x) >> S_IC3T) & M_IC3T)
-
-#define A_PCIE_CORE_UTL_PCI_EXPRESS_PORT_CONTROL 0x59a0
-
-#define S_VRB0 31
-#define V_VRB0(x) ((x) << S_VRB0)
-#define F_VRB0 V_VRB0(1U)
-
-#define S_VRB1 30
-#define V_VRB1(x) ((x) << S_VRB1)
-#define F_VRB1 V_VRB1(1U)
-
-#define S_VRB2 29
-#define V_VRB2(x) ((x) << S_VRB2)
-#define F_VRB2 V_VRB2(1U)
-
-#define S_VRB3 28
-#define V_VRB3(x) ((x) << S_VRB3)
-#define F_VRB3 V_VRB3(1U)
-
-#define S_PSFE 26
-#define V_PSFE(x) ((x) << S_PSFE)
-#define F_PSFE V_PSFE(1U)
-
-#define S_RVDE 25
-#define V_RVDE(x) ((x) << S_RVDE)
-#define F_RVDE V_RVDE(1U)
-
-#define S_TXE0 23
-#define V_TXE0(x) ((x) << S_TXE0)
-#define F_TXE0 V_TXE0(1U)
-
-#define S_TXE1 22
-#define V_TXE1(x) ((x) << S_TXE1)
-#define F_TXE1 V_TXE1(1U)
-
-#define S_TXE2 21
-#define V_TXE2(x) ((x) << S_TXE2)
-#define F_TXE2 V_TXE2(1U)
-
-#define S_TXE3 20
-#define V_TXE3(x) ((x) << S_TXE3)
-#define F_TXE3 V_TXE3(1U)
-
-#define S_RPAM 13
-#define V_RPAM(x) ((x) << S_RPAM)
-#define F_RPAM V_RPAM(1U)
-
-#define S_RTOS 4
-#define M_RTOS 0xfU
-#define V_RTOS(x) ((x) << S_RTOS)
-#define G_RTOS(x) (((x) >> S_RTOS) & M_RTOS)
-
-#define A_PCIE_CORE_UTL_PCI_EXPRESS_PORT_STATUS 0x59a4
-
-#define S_TPCP 30
-#define V_TPCP(x) ((x) << S_TPCP)
-#define F_TPCP V_TPCP(1U)
-
-#define S_TNPP 29
-#define V_TNPP(x) ((x) << S_TNPP)
-#define F_TNPP V_TNPP(1U)
-
-#define S_TFTP 28
-#define V_TFTP(x) ((x) << S_TFTP)
-#define F_TFTP V_TFTP(1U)
-
-#define S_TCAP 27
-#define V_TCAP(x) ((x) << S_TCAP)
-#define F_TCAP V_TCAP(1U)
-
-#define S_TCIP 26
-#define V_TCIP(x) ((x) << S_TCIP)
-#define F_TCIP V_TCIP(1U)
-
-#define S_RCAP 25
-#define V_RCAP(x) ((x) << S_RCAP)
-#define F_RCAP V_RCAP(1U)
-
-#define S_PLUP 23
-#define V_PLUP(x) ((x) << S_PLUP)
-#define F_PLUP V_PLUP(1U)
-
-#define S_PLDN 22
-#define V_PLDN(x) ((x) << S_PLDN)
-#define F_PLDN V_PLDN(1U)
-
-#define S_OTDD 21
-#define V_OTDD(x) ((x) << S_OTDD)
-#define F_OTDD V_OTDD(1U)
-
-#define S_GTRP 20
-#define V_GTRP(x) ((x) << S_GTRP)
-#define F_GTRP V_GTRP(1U)
-
-#define S_RDPE 18
-#define V_RDPE(x) ((x) << S_RDPE)
-#define F_RDPE V_RDPE(1U)
-
-#define S_TDCE 17
-#define V_TDCE(x) ((x) << S_TDCE)
-#define F_TDCE V_TDCE(1U)
-
-#define S_TDUE 16
-#define V_TDUE(x) ((x) << S_TDUE)
-#define F_TDUE V_TDUE(1U)
-
-#define A_PCIE_CORE_UTL_PCI_EXPRESS_PORT_ERROR_SEVERITY 0x59a8
-
-#define S_TPCS 30
-#define V_TPCS(x) ((x) << S_TPCS)
-#define F_TPCS V_TPCS(1U)
-
-#define S_TNPS 29
-#define V_TNPS(x) ((x) << S_TNPS)
-#define F_TNPS V_TNPS(1U)
-
-#define S_TFTS 28
-#define V_TFTS(x) ((x) << S_TFTS)
-#define F_TFTS V_TFTS(1U)
-
-#define S_TCAS 27
-#define V_TCAS(x) ((x) << S_TCAS)
-#define F_TCAS V_TCAS(1U)
-
-#define S_TCIS 26
-#define V_TCIS(x) ((x) << S_TCIS)
-#define F_TCIS V_TCIS(1U)
-
-#define S_RCAS 25
-#define V_RCAS(x) ((x) << S_RCAS)
-#define F_RCAS V_RCAS(1U)
-
-#define S_PLUS 23
-#define V_PLUS(x) ((x) << S_PLUS)
-#define F_PLUS V_PLUS(1U)
-
-#define S_PLDS 22
-#define V_PLDS(x) ((x) << S_PLDS)
-#define F_PLDS V_PLDS(1U)
-
-#define S_OTDS 21
-#define V_OTDS(x) ((x) << S_OTDS)
-#define F_OTDS V_OTDS(1U)
-
-#define S_RDPS 18
-#define V_RDPS(x) ((x) << S_RDPS)
-#define F_RDPS V_RDPS(1U)
-
-#define S_TDCS 17
-#define V_TDCS(x) ((x) << S_TDCS)
-#define F_TDCS V_TDCS(1U)
-
-#define S_TDUS 16
-#define V_TDUS(x) ((x) << S_TDUS)
-#define F_TDUS V_TDUS(1U)
-
-#define A_PCIE_CORE_UTL_PCI_EXPRESS_PORT_INTERRUPT_ENABLE 0x59ac
-
-#define S_TPCI 30
-#define V_TPCI(x) ((x) << S_TPCI)
-#define F_TPCI V_TPCI(1U)
-
-#define S_TNPI 29
-#define V_TNPI(x) ((x) << S_TNPI)
-#define F_TNPI V_TNPI(1U)
-
-#define S_TFTI 28
-#define V_TFTI(x) ((x) << S_TFTI)
-#define F_TFTI V_TFTI(1U)
-
-#define S_TCAI 27
-#define V_TCAI(x) ((x) << S_TCAI)
-#define F_TCAI V_TCAI(1U)
-
-#define S_TCII 26
-#define V_TCII(x) ((x) << S_TCII)
-#define F_TCII V_TCII(1U)
-
-#define S_RCAI 25
-#define V_RCAI(x) ((x) << S_RCAI)
-#define F_RCAI V_RCAI(1U)
-
-#define S_PLUI 23
-#define V_PLUI(x) ((x) << S_PLUI)
-#define F_PLUI V_PLUI(1U)
-
-#define S_PLDI 22
-#define V_PLDI(x) ((x) << S_PLDI)
-#define F_PLDI V_PLDI(1U)
-
-#define S_OTDI 21
-#define V_OTDI(x) ((x) << S_OTDI)
-#define F_OTDI V_OTDI(1U)
-
-#define A_PCIE_CORE_ROOT_COMPLEX_STATUS 0x59b0
-
-#define S_RLCE 31
-#define V_RLCE(x) ((x) << S_RLCE)
-#define F_RLCE V_RLCE(1U)
-
-#define S_RLNE 30
-#define V_RLNE(x) ((x) << S_RLNE)
-#define F_RLNE V_RLNE(1U)
-
-#define S_RLFE 29
-#define V_RLFE(x) ((x) << S_RLFE)
-#define F_RLFE V_RLFE(1U)
-
-#define S_RCPE 25
-#define V_RCPE(x) ((x) << S_RCPE)
-#define F_RCPE V_RCPE(1U)
-
-#define S_RCTO 24
-#define V_RCTO(x) ((x) << S_RCTO)
-#define F_RCTO V_RCTO(1U)
-
-#define S_PINA 23
-#define V_PINA(x) ((x) << S_PINA)
-#define F_PINA V_PINA(1U)
-
-#define S_PINB 22
-#define V_PINB(x) ((x) << S_PINB)
-#define F_PINB V_PINB(1U)
-
-#define S_PINC 21
-#define V_PINC(x) ((x) << S_PINC)
-#define F_PINC V_PINC(1U)
-
-#define S_PIND 20
-#define V_PIND(x) ((x) << S_PIND)
-#define F_PIND V_PIND(1U)
-
-#define S_ALER 19
-#define V_ALER(x) ((x) << S_ALER)
-#define F_ALER V_ALER(1U)
-
-#define S_CRSE 18
-#define V_CRSE(x) ((x) << S_CRSE)
-#define F_CRSE V_CRSE(1U)
-
-#define A_PCIE_T5_HMA_CFG 0x59b0
-
-#define S_HMA_MAXREQCNT 20
-#define M_HMA_MAXREQCNT 0x1fU
-#define V_HMA_MAXREQCNT(x) ((x) << S_HMA_MAXREQCNT)
-#define G_HMA_MAXREQCNT(x) (((x) >> S_HMA_MAXREQCNT) & M_HMA_MAXREQCNT)
-
-#define S_T5_HMA_MAXRDREQSIZE 17
-#define M_T5_HMA_MAXRDREQSIZE 0x7U
-#define V_T5_HMA_MAXRDREQSIZE(x) ((x) << S_T5_HMA_MAXRDREQSIZE)
-#define G_T5_HMA_MAXRDREQSIZE(x) (((x) >> S_T5_HMA_MAXRDREQSIZE) & M_T5_HMA_MAXRDREQSIZE)
-
-#define S_T5_HMA_MAXRSPCNT 8
-#define M_T5_HMA_MAXRSPCNT 0x1fU
-#define V_T5_HMA_MAXRSPCNT(x) ((x) << S_T5_HMA_MAXRSPCNT)
-#define G_T5_HMA_MAXRSPCNT(x) (((x) >> S_T5_HMA_MAXRSPCNT) & M_T5_HMA_MAXRSPCNT)
-
-#define S_T6_HMA_MAXREQCNT 20
-#define M_T6_HMA_MAXREQCNT 0x7fU
-#define V_T6_HMA_MAXREQCNT(x) ((x) << S_T6_HMA_MAXREQCNT)
-#define G_T6_HMA_MAXREQCNT(x) (((x) >> S_T6_HMA_MAXREQCNT) & M_T6_HMA_MAXREQCNT)
-
-#define S_T6_T5_HMA_MAXRSPCNT 9
-#define M_T6_T5_HMA_MAXRSPCNT 0xffU
-#define V_T6_T5_HMA_MAXRSPCNT(x) ((x) << S_T6_T5_HMA_MAXRSPCNT)
-#define G_T6_T5_HMA_MAXRSPCNT(x) (((x) >> S_T6_T5_HMA_MAXRSPCNT) & M_T6_T5_HMA_MAXRSPCNT)
-
-#define S_T6_SEQCHKDIS 8
-#define V_T6_SEQCHKDIS(x) ((x) << S_T6_SEQCHKDIS)
-#define F_T6_SEQCHKDIS V_T6_SEQCHKDIS(1U)
-
-#define S_T6_MINTAG 0
-#define M_T6_MINTAG 0xffU
-#define V_T6_MINTAG(x) ((x) << S_T6_MINTAG)
-#define G_T6_MINTAG(x) (((x) >> S_T6_MINTAG) & M_T6_MINTAG)
-
-#define A_PCIE_CORE_ROOT_COMPLEX_ERROR_SEVERITY 0x59b4
-
-#define S_RLCS 31
-#define V_RLCS(x) ((x) << S_RLCS)
-#define F_RLCS V_RLCS(1U)
-
-#define S_RLNS 30
-#define V_RLNS(x) ((x) << S_RLNS)
-#define F_RLNS V_RLNS(1U)
-
-#define S_RLFS 29
-#define V_RLFS(x) ((x) << S_RLFS)
-#define F_RLFS V_RLFS(1U)
-
-#define S_RCPS 25
-#define V_RCPS(x) ((x) << S_RCPS)
-#define F_RCPS V_RCPS(1U)
-
-#define S_RCTS 24
-#define V_RCTS(x) ((x) << S_RCTS)
-#define F_RCTS V_RCTS(1U)
-
-#define S_PAAS 23
-#define V_PAAS(x) ((x) << S_PAAS)
-#define F_PAAS V_PAAS(1U)
-
-#define S_PABS 22
-#define V_PABS(x) ((x) << S_PABS)
-#define F_PABS V_PABS(1U)
-
-#define S_PACS 21
-#define V_PACS(x) ((x) << S_PACS)
-#define F_PACS V_PACS(1U)
-
-#define S_PADS 20
-#define V_PADS(x) ((x) << S_PADS)
-#define F_PADS V_PADS(1U)
-
-#define S_ALES 19
-#define V_ALES(x) ((x) << S_ALES)
-#define F_ALES V_ALES(1U)
-
-#define S_CRSS 18
-#define V_CRSS(x) ((x) << S_CRSS)
-#define F_CRSS V_CRSS(1U)
-
-#define A_PCIE_T5_HMA_STAT 0x59b4
-
-#define S_HMA_RESPCNT 20
-#define M_HMA_RESPCNT 0x1ffU
-#define V_HMA_RESPCNT(x) ((x) << S_HMA_RESPCNT)
-#define G_HMA_RESPCNT(x) (((x) >> S_HMA_RESPCNT) & M_HMA_RESPCNT)
-
-#define S_HMA_RDREQCNT 12
-#define M_HMA_RDREQCNT 0x3fU
-#define V_HMA_RDREQCNT(x) ((x) << S_HMA_RDREQCNT)
-#define G_HMA_RDREQCNT(x) (((x) >> S_HMA_RDREQCNT) & M_HMA_RDREQCNT)
-
-#define S_HMA_WRREQCNT 0
-#define M_HMA_WRREQCNT 0x1ffU
-#define V_HMA_WRREQCNT(x) ((x) << S_HMA_WRREQCNT)
-#define G_HMA_WRREQCNT(x) (((x) >> S_HMA_WRREQCNT) & M_HMA_WRREQCNT)
-
-#define S_T6_HMA_RESPCNT 20
-#define M_T6_HMA_RESPCNT 0x3ffU
-#define V_T6_HMA_RESPCNT(x) ((x) << S_T6_HMA_RESPCNT)
-#define G_T6_HMA_RESPCNT(x) (((x) >> S_T6_HMA_RESPCNT) & M_T6_HMA_RESPCNT)
-
-#define A_PCIE_CORE_ROOT_COMPLEX_INTERRUPT_ENABLE 0x59b8
-
-#define S_RLCI 31
-#define V_RLCI(x) ((x) << S_RLCI)
-#define F_RLCI V_RLCI(1U)
-
-#define S_RLNI 30
-#define V_RLNI(x) ((x) << S_RLNI)
-#define F_RLNI V_RLNI(1U)
-
-#define S_RLFI 29
-#define V_RLFI(x) ((x) << S_RLFI)
-#define F_RLFI V_RLFI(1U)
-
-#define S_RCPI 25
-#define V_RCPI(x) ((x) << S_RCPI)
-#define F_RCPI V_RCPI(1U)
-
-#define S_RCTI 24
-#define V_RCTI(x) ((x) << S_RCTI)
-#define F_RCTI V_RCTI(1U)
-
-#define S_PAAI 23
-#define V_PAAI(x) ((x) << S_PAAI)
-#define F_PAAI V_PAAI(1U)
-
-#define S_PABI 22
-#define V_PABI(x) ((x) << S_PABI)
-#define F_PABI V_PABI(1U)
-
-#define S_PACI 21
-#define V_PACI(x) ((x) << S_PACI)
-#define F_PACI V_PACI(1U)
-
-#define S_PADI 20
-#define V_PADI(x) ((x) << S_PADI)
-#define F_PADI V_PADI(1U)
-
-#define S_ALEI 19
-#define V_ALEI(x) ((x) << S_ALEI)
-#define F_ALEI V_ALEI(1U)
-
-#define S_CRSI 18
-#define V_CRSI(x) ((x) << S_CRSI)
-#define F_CRSI V_CRSI(1U)
-
-#define A_PCIE_T5_HMA_STAT2 0x59b8
-#define A_PCIE_CORE_ENDPOINT_STATUS 0x59bc
-
-#define S_PTOM 31
-#define V_PTOM(x) ((x) << S_PTOM)
-#define F_PTOM V_PTOM(1U)
-
-#define S_ALEA 29
-#define V_ALEA(x) ((x) << S_ALEA)
-#define F_ALEA V_ALEA(1U)
-
-#define S_PMC0 23
-#define V_PMC0(x) ((x) << S_PMC0)
-#define F_PMC0 V_PMC0(1U)
-
-#define S_PMC1 22
-#define V_PMC1(x) ((x) << S_PMC1)
-#define F_PMC1 V_PMC1(1U)
-
-#define S_PMC2 21
-#define V_PMC2(x) ((x) << S_PMC2)
-#define F_PMC2 V_PMC2(1U)
-
-#define S_PMC3 20
-#define V_PMC3(x) ((x) << S_PMC3)
-#define F_PMC3 V_PMC3(1U)
-
-#define S_PMC4 19
-#define V_PMC4(x) ((x) << S_PMC4)
-#define F_PMC4 V_PMC4(1U)
-
-#define S_PMC5 18
-#define V_PMC5(x) ((x) << S_PMC5)
-#define F_PMC5 V_PMC5(1U)
-
-#define S_PMC6 17
-#define V_PMC6(x) ((x) << S_PMC6)
-#define F_PMC6 V_PMC6(1U)
-
-#define S_PMC7 16
-#define V_PMC7(x) ((x) << S_PMC7)
-#define F_PMC7 V_PMC7(1U)
-
-#define A_PCIE_T5_HMA_STAT3 0x59bc
-#define A_PCIE_CORE_ENDPOINT_ERROR_SEVERITY 0x59c0
-
-#define S_PTOS 31
-#define V_PTOS(x) ((x) << S_PTOS)
-#define F_PTOS V_PTOS(1U)
-
-#define S_AENS 29
-#define V_AENS(x) ((x) << S_AENS)
-#define F_AENS V_AENS(1U)
-
-#define S_PC0S 23
-#define V_PC0S(x) ((x) << S_PC0S)
-#define F_PC0S V_PC0S(1U)
-
-#define S_PC1S 22
-#define V_PC1S(x) ((x) << S_PC1S)
-#define F_PC1S V_PC1S(1U)
-
-#define S_PC2S 21
-#define V_PC2S(x) ((x) << S_PC2S)
-#define F_PC2S V_PC2S(1U)
-
-#define S_PC3S 20
-#define V_PC3S(x) ((x) << S_PC3S)
-#define F_PC3S V_PC3S(1U)
-
-#define S_PC4S 19
-#define V_PC4S(x) ((x) << S_PC4S)
-#define F_PC4S V_PC4S(1U)
-
-#define S_PC5S 18
-#define V_PC5S(x) ((x) << S_PC5S)
-#define F_PC5S V_PC5S(1U)
-
-#define S_PC6S 17
-#define V_PC6S(x) ((x) << S_PC6S)
-#define F_PC6S V_PC6S(1U)
-
-#define S_PC7S 16
-#define V_PC7S(x) ((x) << S_PC7S)
-#define F_PC7S V_PC7S(1U)
-
-#define S_PME0 15
-#define V_PME0(x) ((x) << S_PME0)
-#define F_PME0 V_PME0(1U)
-
-#define S_PME1 14
-#define V_PME1(x) ((x) << S_PME1)
-#define F_PME1 V_PME1(1U)
-
-#define S_PME2 13
-#define V_PME2(x) ((x) << S_PME2)
-#define F_PME2 V_PME2(1U)
-
-#define S_PME3 12
-#define V_PME3(x) ((x) << S_PME3)
-#define F_PME3 V_PME3(1U)
-
-#define S_PME4 11
-#define V_PME4(x) ((x) << S_PME4)
-#define F_PME4 V_PME4(1U)
-
-#define S_PME5 10
-#define V_PME5(x) ((x) << S_PME5)
-#define F_PME5 V_PME5(1U)
-
-#define S_PME6 9
-#define V_PME6(x) ((x) << S_PME6)
-#define F_PME6 V_PME6(1U)
-
-#define S_PME7 8
-#define V_PME7(x) ((x) << S_PME7)
-#define F_PME7 V_PME7(1U)
-
-#define A_PCIE_CGEN 0x59c0
-
-#define S_VPD_DYNAMIC_CGEN 26
-#define V_VPD_DYNAMIC_CGEN(x) ((x) << S_VPD_DYNAMIC_CGEN)
-#define F_VPD_DYNAMIC_CGEN V_VPD_DYNAMIC_CGEN(1U)
-
-#define S_MA_DYNAMIC_CGEN 25
-#define V_MA_DYNAMIC_CGEN(x) ((x) << S_MA_DYNAMIC_CGEN)
-#define F_MA_DYNAMIC_CGEN V_MA_DYNAMIC_CGEN(1U)
-
-#define S_TAGQ_DYNAMIC_CGEN 24
-#define V_TAGQ_DYNAMIC_CGEN(x) ((x) << S_TAGQ_DYNAMIC_CGEN)
-#define F_TAGQ_DYNAMIC_CGEN V_TAGQ_DYNAMIC_CGEN(1U)
-
-#define S_REQCTL_DYNAMIC_CGEN 23
-#define V_REQCTL_DYNAMIC_CGEN(x) ((x) << S_REQCTL_DYNAMIC_CGEN)
-#define F_REQCTL_DYNAMIC_CGEN V_REQCTL_DYNAMIC_CGEN(1U)
-
-#define S_RSPDATAPROC_DYNAMIC_CGEN 22
-#define V_RSPDATAPROC_DYNAMIC_CGEN(x) ((x) << S_RSPDATAPROC_DYNAMIC_CGEN)
-#define F_RSPDATAPROC_DYNAMIC_CGEN V_RSPDATAPROC_DYNAMIC_CGEN(1U)
-
-#define S_RSPRDQ_DYNAMIC_CGEN 21
-#define V_RSPRDQ_DYNAMIC_CGEN(x) ((x) << S_RSPRDQ_DYNAMIC_CGEN)
-#define F_RSPRDQ_DYNAMIC_CGEN V_RSPRDQ_DYNAMIC_CGEN(1U)
-
-#define S_RSPIPIF_DYNAMIC_CGEN 20
-#define V_RSPIPIF_DYNAMIC_CGEN(x) ((x) << S_RSPIPIF_DYNAMIC_CGEN)
-#define F_RSPIPIF_DYNAMIC_CGEN V_RSPIPIF_DYNAMIC_CGEN(1U)
-
-#define S_HMA_STATIC_CGEN 19
-#define V_HMA_STATIC_CGEN(x) ((x) << S_HMA_STATIC_CGEN)
-#define F_HMA_STATIC_CGEN V_HMA_STATIC_CGEN(1U)
-
-#define S_HMA_DYNAMIC_CGEN 18
-#define V_HMA_DYNAMIC_CGEN(x) ((x) << S_HMA_DYNAMIC_CGEN)
-#define F_HMA_DYNAMIC_CGEN V_HMA_DYNAMIC_CGEN(1U)
-
-#define S_CMD_STATIC_CGEN 16
-#define V_CMD_STATIC_CGEN(x) ((x) << S_CMD_STATIC_CGEN)
-#define F_CMD_STATIC_CGEN V_CMD_STATIC_CGEN(1U)
-
-#define S_CMD_DYNAMIC_CGEN 15
-#define V_CMD_DYNAMIC_CGEN(x) ((x) << S_CMD_DYNAMIC_CGEN)
-#define F_CMD_DYNAMIC_CGEN V_CMD_DYNAMIC_CGEN(1U)
-
-#define S_DMA_STATIC_CGEN 13
-#define V_DMA_STATIC_CGEN(x) ((x) << S_DMA_STATIC_CGEN)
-#define F_DMA_STATIC_CGEN V_DMA_STATIC_CGEN(1U)
-
-#define S_DMA_DYNAMIC_CGEN 12
-#define V_DMA_DYNAMIC_CGEN(x) ((x) << S_DMA_DYNAMIC_CGEN)
-#define F_DMA_DYNAMIC_CGEN V_DMA_DYNAMIC_CGEN(1U)
-
-#define S_VFID_SLEEPSTATUS 10
-#define V_VFID_SLEEPSTATUS(x) ((x) << S_VFID_SLEEPSTATUS)
-#define F_VFID_SLEEPSTATUS V_VFID_SLEEPSTATUS(1U)
-
-#define S_VC1_SLEEPSTATUS 9
-#define V_VC1_SLEEPSTATUS(x) ((x) << S_VC1_SLEEPSTATUS)
-#define F_VC1_SLEEPSTATUS V_VC1_SLEEPSTATUS(1U)
-
-#define S_STI_SLEEPSTATUS 8
-#define V_STI_SLEEPSTATUS(x) ((x) << S_STI_SLEEPSTATUS)
-#define F_STI_SLEEPSTATUS V_STI_SLEEPSTATUS(1U)
-
-#define S_VFID_SLEEPREQ 2
-#define V_VFID_SLEEPREQ(x) ((x) << S_VFID_SLEEPREQ)
-#define F_VFID_SLEEPREQ V_VFID_SLEEPREQ(1U)
-
-#define S_VC1_SLEEPREQ 1
-#define V_VC1_SLEEPREQ(x) ((x) << S_VC1_SLEEPREQ)
-#define F_VC1_SLEEPREQ V_VC1_SLEEPREQ(1U)
-
-#define S_STI_SLEEPREQ 0
-#define V_STI_SLEEPREQ(x) ((x) << S_STI_SLEEPREQ)
-#define F_STI_SLEEPREQ V_STI_SLEEPREQ(1U)
-
-#define A_PCIE_CORE_ENDPOINT_INTERRUPT_ENABLE 0x59c4
-
-#define S_PTOI 31
-#define V_PTOI(x) ((x) << S_PTOI)
-#define F_PTOI V_PTOI(1U)
-
-#define S_AENI 29
-#define V_AENI(x) ((x) << S_AENI)
-#define F_AENI V_AENI(1U)
-
-#define S_PC0I 23
-#define V_PC0I(x) ((x) << S_PC0I)
-#define F_PC0I V_PC0I(1U)
-
-#define S_PC1I 22
-#define V_PC1I(x) ((x) << S_PC1I)
-#define F_PC1I V_PC1I(1U)
-
-#define S_PC2I 21
-#define V_PC2I(x) ((x) << S_PC2I)
-#define F_PC2I V_PC2I(1U)
-
-#define S_PC3I 20
-#define V_PC3I(x) ((x) << S_PC3I)
-#define F_PC3I V_PC3I(1U)
-
-#define S_PC4I 19
-#define V_PC4I(x) ((x) << S_PC4I)
-#define F_PC4I V_PC4I(1U)
-
-#define S_PC5I 18
-#define V_PC5I(x) ((x) << S_PC5I)
-#define F_PC5I V_PC5I(1U)
-
-#define S_PC6I 17
-#define V_PC6I(x) ((x) << S_PC6I)
-#define F_PC6I V_PC6I(1U)
-
-#define S_PC7I 16
-#define V_PC7I(x) ((x) << S_PC7I)
-#define F_PC7I V_PC7I(1U)
-
-#define A_PCIE_MA_RSP 0x59c4
-
-#define S_TIMERVALUE 8
-#define M_TIMERVALUE 0xffffffU
-#define V_TIMERVALUE(x) ((x) << S_TIMERVALUE)
-#define G_TIMERVALUE(x) (((x) >> S_TIMERVALUE) & M_TIMERVALUE)
-
-#define S_MAREQTIMEREN 1
-#define V_MAREQTIMEREN(x) ((x) << S_MAREQTIMEREN)
-#define F_MAREQTIMEREN V_MAREQTIMEREN(1U)
-
-#define S_MARSPTIMEREN 0
-#define V_MARSPTIMEREN(x) ((x) << S_MARSPTIMEREN)
-#define F_MARSPTIMEREN V_MARSPTIMEREN(1U)
-
-#define A_PCIE_CORE_PCI_POWER_MANAGEMENT_CONTROL_1 0x59c8
-
-#define S_TOAK 31
-#define V_TOAK(x) ((x) << S_TOAK)
-#define F_TOAK V_TOAK(1U)
-
-#define S_L1RS 23
-#define V_L1RS(x) ((x) << S_L1RS)
-#define F_L1RS V_L1RS(1U)
-
-#define S_L23S 22
-#define V_L23S(x) ((x) << S_L23S)
-#define F_L23S V_L23S(1U)
-
-#define S_AL1S 21
-#define V_AL1S(x) ((x) << S_AL1S)
-#define F_AL1S V_AL1S(1U)
-
-#define S_ALET 19
-#define V_ALET(x) ((x) << S_ALET)
-#define F_ALET V_ALET(1U)
-
-#define A_PCIE_HPRD 0x59c8
-
-#define S_NPH_CREDITSAVAILVC0 19
-#define M_NPH_CREDITSAVAILVC0 0x3U
-#define V_NPH_CREDITSAVAILVC0(x) ((x) << S_NPH_CREDITSAVAILVC0)
-#define G_NPH_CREDITSAVAILVC0(x) (((x) >> S_NPH_CREDITSAVAILVC0) & M_NPH_CREDITSAVAILVC0)
-
-#define S_NPD_CREDITSAVAILVC0 17
-#define M_NPD_CREDITSAVAILVC0 0x3U
-#define V_NPD_CREDITSAVAILVC0(x) ((x) << S_NPD_CREDITSAVAILVC0)
-#define G_NPD_CREDITSAVAILVC0(x) (((x) >> S_NPD_CREDITSAVAILVC0) & M_NPD_CREDITSAVAILVC0)
-
-#define S_NPH_CREDITSAVAILVC1 15
-#define M_NPH_CREDITSAVAILVC1 0x3U
-#define V_NPH_CREDITSAVAILVC1(x) ((x) << S_NPH_CREDITSAVAILVC1)
-#define G_NPH_CREDITSAVAILVC1(x) (((x) >> S_NPH_CREDITSAVAILVC1) & M_NPH_CREDITSAVAILVC1)
-
-#define S_NPD_CREDITSAVAILVC1 13
-#define M_NPD_CREDITSAVAILVC1 0x3U
-#define V_NPD_CREDITSAVAILVC1(x) ((x) << S_NPD_CREDITSAVAILVC1)
-#define G_NPD_CREDITSAVAILVC1(x) (((x) >> S_NPD_CREDITSAVAILVC1) & M_NPD_CREDITSAVAILVC1)
-
-#define S_NPH_CREDITSREQUIRED 11
-#define M_NPH_CREDITSREQUIRED 0x3U
-#define V_NPH_CREDITSREQUIRED(x) ((x) << S_NPH_CREDITSREQUIRED)
-#define G_NPH_CREDITSREQUIRED(x) (((x) >> S_NPH_CREDITSREQUIRED) & M_NPH_CREDITSREQUIRED)
-
-#define S_NPD_CREDITSREQUIRED 9
-#define M_NPD_CREDITSREQUIRED 0x3U
-#define V_NPD_CREDITSREQUIRED(x) ((x) << S_NPD_CREDITSREQUIRED)
-#define G_NPD_CREDITSREQUIRED(x) (((x) >> S_NPD_CREDITSREQUIRED) & M_NPD_CREDITSREQUIRED)
-
-#define S_REQBURSTCOUNT 5
-#define M_REQBURSTCOUNT 0xfU
-#define V_REQBURSTCOUNT(x) ((x) << S_REQBURSTCOUNT)
-#define G_REQBURSTCOUNT(x) (((x) >> S_REQBURSTCOUNT) & M_REQBURSTCOUNT)
-
-#define S_REQBURSTFREQUENCY 1
-#define M_REQBURSTFREQUENCY 0xfU
-#define V_REQBURSTFREQUENCY(x) ((x) << S_REQBURSTFREQUENCY)
-#define G_REQBURSTFREQUENCY(x) (((x) >> S_REQBURSTFREQUENCY) & M_REQBURSTFREQUENCY)
-
-#define S_ENABLEVC1 0
-#define V_ENABLEVC1(x) ((x) << S_ENABLEVC1)
-#define F_ENABLEVC1 V_ENABLEVC1(1U)
-
-#define A_PCIE_CORE_PCI_POWER_MANAGEMENT_CONTROL_2 0x59cc
-
-#define S_CPM0 30
-#define M_CPM0 0x3U
-#define V_CPM0(x) ((x) << S_CPM0)
-#define G_CPM0(x) (((x) >> S_CPM0) & M_CPM0)
-
-#define S_CPM1 28
-#define M_CPM1 0x3U
-#define V_CPM1(x) ((x) << S_CPM1)
-#define G_CPM1(x) (((x) >> S_CPM1) & M_CPM1)
-
-#define S_CPM2 26
-#define M_CPM2 0x3U
-#define V_CPM2(x) ((x) << S_CPM2)
-#define G_CPM2(x) (((x) >> S_CPM2) & M_CPM2)
-
-#define S_CPM3 24
-#define M_CPM3 0x3U
-#define V_CPM3(x) ((x) << S_CPM3)
-#define G_CPM3(x) (((x) >> S_CPM3) & M_CPM3)
-
-#define S_CPM4 22
-#define M_CPM4 0x3U
-#define V_CPM4(x) ((x) << S_CPM4)
-#define G_CPM4(x) (((x) >> S_CPM4) & M_CPM4)
-
-#define S_CPM5 20
-#define M_CPM5 0x3U
-#define V_CPM5(x) ((x) << S_CPM5)
-#define G_CPM5(x) (((x) >> S_CPM5) & M_CPM5)
-
-#define S_CPM6 18
-#define M_CPM6 0x3U
-#define V_CPM6(x) ((x) << S_CPM6)
-#define G_CPM6(x) (((x) >> S_CPM6) & M_CPM6)
-
-#define S_CPM7 16
-#define M_CPM7 0x3U
-#define V_CPM7(x) ((x) << S_CPM7)
-#define G_CPM7(x) (((x) >> S_CPM7) & M_CPM7)
-
-#define S_OPM0 14
-#define M_OPM0 0x3U
-#define V_OPM0(x) ((x) << S_OPM0)
-#define G_OPM0(x) (((x) >> S_OPM0) & M_OPM0)
-
-#define S_OPM1 12
-#define M_OPM1 0x3U
-#define V_OPM1(x) ((x) << S_OPM1)
-#define G_OPM1(x) (((x) >> S_OPM1) & M_OPM1)
-
-#define S_OPM2 10
-#define M_OPM2 0x3U
-#define V_OPM2(x) ((x) << S_OPM2)
-#define G_OPM2(x) (((x) >> S_OPM2) & M_OPM2)
-
-#define S_OPM3 8
-#define M_OPM3 0x3U
-#define V_OPM3(x) ((x) << S_OPM3)
-#define G_OPM3(x) (((x) >> S_OPM3) & M_OPM3)
-
-#define S_OPM4 6
-#define M_OPM4 0x3U
-#define V_OPM4(x) ((x) << S_OPM4)
-#define G_OPM4(x) (((x) >> S_OPM4) & M_OPM4)
-
-#define S_OPM5 4
-#define M_OPM5 0x3U
-#define V_OPM5(x) ((x) << S_OPM5)
-#define G_OPM5(x) (((x) >> S_OPM5) & M_OPM5)
-
-#define S_OPM6 2
-#define M_OPM6 0x3U
-#define V_OPM6(x) ((x) << S_OPM6)
-#define G_OPM6(x) (((x) >> S_OPM6) & M_OPM6)
-
-#define S_OPM7 0
-#define M_OPM7 0x3U
-#define V_OPM7(x) ((x) << S_OPM7)
-#define G_OPM7(x) (((x) >> S_OPM7) & M_OPM7)
-
-#define A_PCIE_CORE_GENERAL_PURPOSE_CONTROL_1 0x59d0
-#define A_PCIE_PERR_GROUP 0x59d0
-
-#define S_MST_DATAPATHPERR 25
-#define V_MST_DATAPATHPERR(x) ((x) << S_MST_DATAPATHPERR)
-#define F_MST_DATAPATHPERR V_MST_DATAPATHPERR(1U)
-
-#define S_MST_RSPRDQPERR 24
-#define V_MST_RSPRDQPERR(x) ((x) << S_MST_RSPRDQPERR)
-#define F_MST_RSPRDQPERR V_MST_RSPRDQPERR(1U)
-
-#define S_IP_RXPERR 23
-#define V_IP_RXPERR(x) ((x) << S_IP_RXPERR)
-#define F_IP_RXPERR V_IP_RXPERR(1U)
-
-#define S_IP_BACKTXPERR 22
-#define V_IP_BACKTXPERR(x) ((x) << S_IP_BACKTXPERR)
-#define F_IP_BACKTXPERR V_IP_BACKTXPERR(1U)
-
-#define S_IP_FRONTTXPERR 21
-#define V_IP_FRONTTXPERR(x) ((x) << S_IP_FRONTTXPERR)
-#define F_IP_FRONTTXPERR V_IP_FRONTTXPERR(1U)
-
-#define S_TRGT1_FIDLKUPHDRPERR 20
-#define V_TRGT1_FIDLKUPHDRPERR(x) ((x) << S_TRGT1_FIDLKUPHDRPERR)
-#define F_TRGT1_FIDLKUPHDRPERR V_TRGT1_FIDLKUPHDRPERR(1U)
-
-#define S_TRGT1_ALINDDATAPERR 19
-#define V_TRGT1_ALINDDATAPERR(x) ((x) << S_TRGT1_ALINDDATAPERR)
-#define F_TRGT1_ALINDDATAPERR V_TRGT1_ALINDDATAPERR(1U)
-
-#define S_TRGT1_UNALINDATAPERR 18
-#define V_TRGT1_UNALINDATAPERR(x) ((x) << S_TRGT1_UNALINDATAPERR)
-#define F_TRGT1_UNALINDATAPERR V_TRGT1_UNALINDATAPERR(1U)
-
-#define S_TRGT1_REQDATAPERR 17
-#define V_TRGT1_REQDATAPERR(x) ((x) << S_TRGT1_REQDATAPERR)
-#define F_TRGT1_REQDATAPERR V_TRGT1_REQDATAPERR(1U)
-
-#define S_TRGT1_REQHDRPERR 16
-#define V_TRGT1_REQHDRPERR(x) ((x) << S_TRGT1_REQHDRPERR)
-#define F_TRGT1_REQHDRPERR V_TRGT1_REQHDRPERR(1U)
-
-#define S_IPRXDATA_VC1PERR 15
-#define V_IPRXDATA_VC1PERR(x) ((x) << S_IPRXDATA_VC1PERR)
-#define F_IPRXDATA_VC1PERR V_IPRXDATA_VC1PERR(1U)
-
-#define S_IPRXDATA_VC0PERR 14
-#define V_IPRXDATA_VC0PERR(x) ((x) << S_IPRXDATA_VC0PERR)
-#define F_IPRXDATA_VC0PERR V_IPRXDATA_VC0PERR(1U)
-
-#define S_IPRXHDR_VC1PERR 13
-#define V_IPRXHDR_VC1PERR(x) ((x) << S_IPRXHDR_VC1PERR)
-#define F_IPRXHDR_VC1PERR V_IPRXHDR_VC1PERR(1U)
-
-#define S_IPRXHDR_VC0PERR 12
-#define V_IPRXHDR_VC0PERR(x) ((x) << S_IPRXHDR_VC0PERR)
-#define F_IPRXHDR_VC0PERR V_IPRXHDR_VC0PERR(1U)
-
-#define S_MA_RSPDATAPERR 11
-#define V_MA_RSPDATAPERR(x) ((x) << S_MA_RSPDATAPERR)
-#define F_MA_RSPDATAPERR V_MA_RSPDATAPERR(1U)
-
-#define S_MA_CPLTAGQPERR 10
-#define V_MA_CPLTAGQPERR(x) ((x) << S_MA_CPLTAGQPERR)
-#define F_MA_CPLTAGQPERR V_MA_CPLTAGQPERR(1U)
-
-#define S_MA_REQTAGQPERR 9
-#define V_MA_REQTAGQPERR(x) ((x) << S_MA_REQTAGQPERR)
-#define F_MA_REQTAGQPERR V_MA_REQTAGQPERR(1U)
-
-#define S_PIOREQ_BAR2CTLPERR 8
-#define V_PIOREQ_BAR2CTLPERR(x) ((x) << S_PIOREQ_BAR2CTLPERR)
-#define F_PIOREQ_BAR2CTLPERR V_PIOREQ_BAR2CTLPERR(1U)
-
-#define S_PIOREQ_MEMCTLPERR 7
-#define V_PIOREQ_MEMCTLPERR(x) ((x) << S_PIOREQ_MEMCTLPERR)
-#define F_PIOREQ_MEMCTLPERR V_PIOREQ_MEMCTLPERR(1U)
-
-#define S_PIOREQ_PLMCTLPERR 6
-#define V_PIOREQ_PLMCTLPERR(x) ((x) << S_PIOREQ_PLMCTLPERR)
-#define F_PIOREQ_PLMCTLPERR V_PIOREQ_PLMCTLPERR(1U)
-
-#define S_PIOREQ_BAR2DATAPERR 5
-#define V_PIOREQ_BAR2DATAPERR(x) ((x) << S_PIOREQ_BAR2DATAPERR)
-#define F_PIOREQ_BAR2DATAPERR V_PIOREQ_BAR2DATAPERR(1U)
-
-#define S_PIOREQ_MEMDATAPERR 4
-#define V_PIOREQ_MEMDATAPERR(x) ((x) << S_PIOREQ_MEMDATAPERR)
-#define F_PIOREQ_MEMDATAPERR V_PIOREQ_MEMDATAPERR(1U)
-
-#define S_PIOREQ_PLMDATAPERR 3
-#define V_PIOREQ_PLMDATAPERR(x) ((x) << S_PIOREQ_PLMDATAPERR)
-#define F_PIOREQ_PLMDATAPERR V_PIOREQ_PLMDATAPERR(1U)
-
-#define S_PIOCPL_CTLPERR 2
-#define V_PIOCPL_CTLPERR(x) ((x) << S_PIOCPL_CTLPERR)
-#define F_PIOCPL_CTLPERR V_PIOCPL_CTLPERR(1U)
-
-#define S_PIOCPL_DATAPERR 1
-#define V_PIOCPL_DATAPERR(x) ((x) << S_PIOCPL_DATAPERR)
-#define F_PIOCPL_DATAPERR V_PIOCPL_DATAPERR(1U)
-
-#define S_PIOCPL_PLMRSPPERR 0
-#define V_PIOCPL_PLMRSPPERR(x) ((x) << S_PIOCPL_PLMRSPPERR)
-#define F_PIOCPL_PLMRSPPERR V_PIOCPL_PLMRSPPERR(1U)
-
-#define S_MA_RSPCTLPERR 26
-#define V_MA_RSPCTLPERR(x) ((x) << S_MA_RSPCTLPERR)
-#define F_MA_RSPCTLPERR V_MA_RSPCTLPERR(1U)
-
-#define S_T6_IPRXDATA_VC0PERR 15
-#define V_T6_IPRXDATA_VC0PERR(x) ((x) << S_T6_IPRXDATA_VC0PERR)
-#define F_T6_IPRXDATA_VC0PERR V_T6_IPRXDATA_VC0PERR(1U)
-
-#define S_T6_IPRXHDR_VC0PERR 14
-#define V_T6_IPRXHDR_VC0PERR(x) ((x) << S_T6_IPRXHDR_VC0PERR)
-#define F_T6_IPRXHDR_VC0PERR V_T6_IPRXHDR_VC0PERR(1U)
-
-#define S_PIOCPL_VDMTXCTLPERR 13
-#define V_PIOCPL_VDMTXCTLPERR(x) ((x) << S_PIOCPL_VDMTXCTLPERR)
-#define F_PIOCPL_VDMTXCTLPERR V_PIOCPL_VDMTXCTLPERR(1U)
-
-#define S_PIOCPL_VDMTXDATAPERR 12
-#define V_PIOCPL_VDMTXDATAPERR(x) ((x) << S_PIOCPL_VDMTXDATAPERR)
-#define F_PIOCPL_VDMTXDATAPERR V_PIOCPL_VDMTXDATAPERR(1U)
-
-#define A_PCIE_CORE_GENERAL_PURPOSE_CONTROL_2 0x59d4
-#define A_PCIE_RSP_ERR_INT_LOG_EN 0x59d4
-
-#define S_CPLSTATUSINTEN 12
-#define V_CPLSTATUSINTEN(x) ((x) << S_CPLSTATUSINTEN)
-#define F_CPLSTATUSINTEN V_CPLSTATUSINTEN(1U)
-
-#define S_REQTIMEOUTINTEN 11
-#define V_REQTIMEOUTINTEN(x) ((x) << S_REQTIMEOUTINTEN)
-#define F_REQTIMEOUTINTEN V_REQTIMEOUTINTEN(1U)
-
-#define S_DISABLEDINTEN 10
-#define V_DISABLEDINTEN(x) ((x) << S_DISABLEDINTEN)
-#define F_DISABLEDINTEN V_DISABLEDINTEN(1U)
-
-#define S_RSPDROPFLRINTEN 9
-#define V_RSPDROPFLRINTEN(x) ((x) << S_RSPDROPFLRINTEN)
-#define F_RSPDROPFLRINTEN V_RSPDROPFLRINTEN(1U)
-
-#define S_REQUNDERFLRINTEN 8
-#define V_REQUNDERFLRINTEN(x) ((x) << S_REQUNDERFLRINTEN)
-#define F_REQUNDERFLRINTEN V_REQUNDERFLRINTEN(1U)
-
-#define S_CPLSTATUSLOGEN 4
-#define V_CPLSTATUSLOGEN(x) ((x) << S_CPLSTATUSLOGEN)
-#define F_CPLSTATUSLOGEN V_CPLSTATUSLOGEN(1U)
-
-#define S_TIMEOUTLOGEN 3
-#define V_TIMEOUTLOGEN(x) ((x) << S_TIMEOUTLOGEN)
-#define F_TIMEOUTLOGEN V_TIMEOUTLOGEN(1U)
-
-#define S_DISABLEDLOGEN 2
-#define V_DISABLEDLOGEN(x) ((x) << S_DISABLEDLOGEN)
-#define F_DISABLEDLOGEN V_DISABLEDLOGEN(1U)
-
-#define S_RSPDROPFLRLOGEN 1
-#define V_RSPDROPFLRLOGEN(x) ((x) << S_RSPDROPFLRLOGEN)
-#define F_RSPDROPFLRLOGEN V_RSPDROPFLRLOGEN(1U)
-
-#define S_REQUNDERFLRLOGEN 0
-#define V_REQUNDERFLRLOGEN(x) ((x) << S_REQUNDERFLRLOGEN)
-#define F_REQUNDERFLRLOGEN V_REQUNDERFLRLOGEN(1U)
-
-#define A_PCIE_RSP_ERR_LOG1 0x59d8
-
-#define S_REQTAG 25
-#define M_REQTAG 0x7fU
-#define V_REQTAG(x) ((x) << S_REQTAG)
-#define G_REQTAG(x) (((x) >> S_REQTAG) & M_REQTAG)
-
-#define S_CID 22
-#define M_CID 0x7U
-#define V_CID(x) ((x) << S_CID)
-#define G_CID(x) (((x) >> S_CID) & M_CID)
-
-#define S_CHNUM 19
-#define M_CHNUM 0x7U
-#define V_CHNUM(x) ((x) << S_CHNUM)
-#define G_CHNUM(x) (((x) >> S_CHNUM) & M_CHNUM)
-
-#define S_BYTELEN 6
-#define M_BYTELEN 0x1fffU
-#define V_BYTELEN(x) ((x) << S_BYTELEN)
-#define G_BYTELEN(x) (((x) >> S_BYTELEN) & M_BYTELEN)
-
-#define S_REASON 3
-#define M_REASON 0x7U
-#define V_REASON(x) ((x) << S_REASON)
-#define G_REASON(x) (((x) >> S_REASON) & M_REASON)
-
-#define S_CPLSTATUS 0
-#define M_CPLSTATUS 0x7U
-#define V_CPLSTATUS(x) ((x) << S_CPLSTATUS)
-#define G_CPLSTATUS(x) (((x) >> S_CPLSTATUS) & M_CPLSTATUS)
-
-#define A_PCIE_RSP_ERR_LOG2 0x59dc
-
-#define S_LOGVALID 31
-#define V_LOGVALID(x) ((x) << S_LOGVALID)
-#define F_LOGVALID V_LOGVALID(1U)
-
-#define S_ADDR10B 8
-#define M_ADDR10B 0x3ffU
-#define V_ADDR10B(x) ((x) << S_ADDR10B)
-#define G_ADDR10B(x) (((x) >> S_ADDR10B) & M_ADDR10B)
-
-#define S_REQVFID 0
-#define M_REQVFID 0xffU
-#define V_REQVFID(x) ((x) << S_REQVFID)
-#define G_REQVFID(x) (((x) >> S_REQVFID) & M_REQVFID)
-
-#define S_T6_ADDR10B 9
-#define M_T6_ADDR10B 0x3ffU
-#define V_T6_ADDR10B(x) ((x) << S_T6_ADDR10B)
-#define G_T6_ADDR10B(x) (((x) >> S_T6_ADDR10B) & M_T6_ADDR10B)
-
-#define S_T6_REQVFID 0
-#define M_T6_REQVFID 0x1ffU
-#define V_T6_REQVFID(x) ((x) << S_T6_REQVFID)
-#define G_T6_REQVFID(x) (((x) >> S_T6_REQVFID) & M_T6_REQVFID)
-
-#define A_PCIE_CHANGESET 0x59fc
-#define A_PCIE_REVISION 0x5a00
-#define A_PCIE_PDEBUG_INDEX 0x5a04
-
-#define S_PDEBUGSELH 16
-#define M_PDEBUGSELH 0x3fU
-#define V_PDEBUGSELH(x) ((x) << S_PDEBUGSELH)
-#define G_PDEBUGSELH(x) (((x) >> S_PDEBUGSELH) & M_PDEBUGSELH)
-
-#define S_PDEBUGSELL 0
-#define M_PDEBUGSELL 0x3fU
-#define V_PDEBUGSELL(x) ((x) << S_PDEBUGSELL)
-#define G_PDEBUGSELL(x) (((x) >> S_PDEBUGSELL) & M_PDEBUGSELL)
-
-#define S_T6_PDEBUGSELH 16
-#define M_T6_PDEBUGSELH 0x7fU
-#define V_T6_PDEBUGSELH(x) ((x) << S_T6_PDEBUGSELH)
-#define G_T6_PDEBUGSELH(x) (((x) >> S_T6_PDEBUGSELH) & M_T6_PDEBUGSELH)
-
-#define S_T6_PDEBUGSELL 0
-#define M_T6_PDEBUGSELL 0x7fU
-#define V_T6_PDEBUGSELL(x) ((x) << S_T6_PDEBUGSELL)
-#define G_T6_PDEBUGSELL(x) (((x) >> S_T6_PDEBUGSELL) & M_T6_PDEBUGSELL)
-
-#define A_PCIE_PDEBUG_DATA_HIGH 0x5a08
-#define A_PCIE_PDEBUG_DATA_LOW 0x5a0c
-#define A_PCIE_CDEBUG_INDEX 0x5a10
-
-#define S_CDEBUGSELH 16
-#define M_CDEBUGSELH 0xffU
-#define V_CDEBUGSELH(x) ((x) << S_CDEBUGSELH)
-#define G_CDEBUGSELH(x) (((x) >> S_CDEBUGSELH) & M_CDEBUGSELH)
-
-#define S_CDEBUGSELL 0
-#define M_CDEBUGSELL 0xffU
-#define V_CDEBUGSELL(x) ((x) << S_CDEBUGSELL)
-#define G_CDEBUGSELL(x) (((x) >> S_CDEBUGSELL) & M_CDEBUGSELL)
-
-#define A_PCIE_CDEBUG_DATA_HIGH 0x5a14
-#define A_PCIE_CDEBUG_DATA_LOW 0x5a18
-#define A_PCIE_DMAW_SOP_CNT 0x5a1c
-
-#define S_CH3 24
-#define M_CH3 0xffU
-#define V_CH3(x) ((x) << S_CH3)
-#define G_CH3(x) (((x) >> S_CH3) & M_CH3)
-
-#define S_CH2 16
-#define M_CH2 0xffU
-#define V_CH2(x) ((x) << S_CH2)
-#define G_CH2(x) (((x) >> S_CH2) & M_CH2)
-
-#define S_CH1 8
-#define M_CH1 0xffU
-#define V_CH1(x) ((x) << S_CH1)
-#define G_CH1(x) (((x) >> S_CH1) & M_CH1)
-
-#define S_CH0 0
-#define M_CH0 0xffU
-#define V_CH0(x) ((x) << S_CH0)
-#define G_CH0(x) (((x) >> S_CH0) & M_CH0)
-
-#define A_PCIE_DMAW_EOP_CNT 0x5a20
-#define A_PCIE_DMAR_REQ_CNT 0x5a24
-#define A_PCIE_DMAR_RSP_SOP_CNT 0x5a28
-#define A_PCIE_DMAR_RSP_EOP_CNT 0x5a2c
-#define A_PCIE_DMAR_RSP_ERR_CNT 0x5a30
-#define A_PCIE_DMAI_CNT 0x5a34
-#define A_PCIE_CMDW_CNT 0x5a38
-
-#define S_CH1_EOP 24
-#define M_CH1_EOP 0xffU
-#define V_CH1_EOP(x) ((x) << S_CH1_EOP)
-#define G_CH1_EOP(x) (((x) >> S_CH1_EOP) & M_CH1_EOP)
-
-#define S_CH1_SOP 16
-#define M_CH1_SOP 0xffU
-#define V_CH1_SOP(x) ((x) << S_CH1_SOP)
-#define G_CH1_SOP(x) (((x) >> S_CH1_SOP) & M_CH1_SOP)
-
-#define S_CH0_EOP 8
-#define M_CH0_EOP 0xffU
-#define V_CH0_EOP(x) ((x) << S_CH0_EOP)
-#define G_CH0_EOP(x) (((x) >> S_CH0_EOP) & M_CH0_EOP)
-
-#define S_CH0_SOP 0
-#define M_CH0_SOP 0xffU
-#define V_CH0_SOP(x) ((x) << S_CH0_SOP)
-#define G_CH0_SOP(x) (((x) >> S_CH0_SOP) & M_CH0_SOP)
-
-#define A_PCIE_CMDR_REQ_CNT 0x5a3c
-#define A_PCIE_CMDR_RSP_CNT 0x5a40
-#define A_PCIE_CMDR_RSP_ERR_CNT 0x5a44
-#define A_PCIE_HMA_REQ_CNT 0x5a48
-
-#define S_CH0_READ 16
-#define M_CH0_READ 0xffU
-#define V_CH0_READ(x) ((x) << S_CH0_READ)
-#define G_CH0_READ(x) (((x) >> S_CH0_READ) & M_CH0_READ)
-
-#define S_CH0_WEOP 8
-#define M_CH0_WEOP 0xffU
-#define V_CH0_WEOP(x) ((x) << S_CH0_WEOP)
-#define G_CH0_WEOP(x) (((x) >> S_CH0_WEOP) & M_CH0_WEOP)
-
-#define S_CH0_WSOP 0
-#define M_CH0_WSOP 0xffU
-#define V_CH0_WSOP(x) ((x) << S_CH0_WSOP)
-#define G_CH0_WSOP(x) (((x) >> S_CH0_WSOP) & M_CH0_WSOP)
-
-#define A_PCIE_HMA_RSP_CNT 0x5a4c
-#define A_PCIE_DMA10_RSP_FREE 0x5a50
-
-#define S_CH1_RSP_FREE 16
-#define M_CH1_RSP_FREE 0xfffU
-#define V_CH1_RSP_FREE(x) ((x) << S_CH1_RSP_FREE)
-#define G_CH1_RSP_FREE(x) (((x) >> S_CH1_RSP_FREE) & M_CH1_RSP_FREE)
-
-#define S_CH0_RSP_FREE 0
-#define M_CH0_RSP_FREE 0xfffU
-#define V_CH0_RSP_FREE(x) ((x) << S_CH0_RSP_FREE)
-#define G_CH0_RSP_FREE(x) (((x) >> S_CH0_RSP_FREE) & M_CH0_RSP_FREE)
-
-#define A_PCIE_DMA32_RSP_FREE 0x5a54
-
-#define S_CH3_RSP_FREE 16
-#define M_CH3_RSP_FREE 0xfffU
-#define V_CH3_RSP_FREE(x) ((x) << S_CH3_RSP_FREE)
-#define G_CH3_RSP_FREE(x) (((x) >> S_CH3_RSP_FREE) & M_CH3_RSP_FREE)
-
-#define S_CH2_RSP_FREE 0
-#define M_CH2_RSP_FREE 0xfffU
-#define V_CH2_RSP_FREE(x) ((x) << S_CH2_RSP_FREE)
-#define G_CH2_RSP_FREE(x) (((x) >> S_CH2_RSP_FREE) & M_CH2_RSP_FREE)
-
-#define A_PCIE_CMD_RSP_FREE 0x5a58
-
-#define S_CMD_CH1_RSP_FREE 16
-#define M_CMD_CH1_RSP_FREE 0x7fU
-#define V_CMD_CH1_RSP_FREE(x) ((x) << S_CMD_CH1_RSP_FREE)
-#define G_CMD_CH1_RSP_FREE(x) (((x) >> S_CMD_CH1_RSP_FREE) & M_CMD_CH1_RSP_FREE)
-
-#define S_CMD_CH0_RSP_FREE 0
-#define M_CMD_CH0_RSP_FREE 0x7fU
-#define V_CMD_CH0_RSP_FREE(x) ((x) << S_CMD_CH0_RSP_FREE)
-#define G_CMD_CH0_RSP_FREE(x) (((x) >> S_CMD_CH0_RSP_FREE) & M_CMD_CH0_RSP_FREE)
-
-#define A_PCIE_HMA_RSP_FREE 0x5a5c
-#define A_PCIE_BUS_MST_STAT_0 0x5a60
-#define A_PCIE_BUS_MST_STAT_1 0x5a64
-#define A_PCIE_BUS_MST_STAT_2 0x5a68
-#define A_PCIE_BUS_MST_STAT_3 0x5a6c
-#define A_PCIE_BUS_MST_STAT_4 0x5a70
-
-#define S_BUSMST_135_128 0
-#define M_BUSMST_135_128 0xffU
-#define V_BUSMST_135_128(x) ((x) << S_BUSMST_135_128)
-#define G_BUSMST_135_128(x) (((x) >> S_BUSMST_135_128) & M_BUSMST_135_128)
-
-#define A_PCIE_BUS_MST_STAT_5 0x5a74
-#define A_PCIE_BUS_MST_STAT_6 0x5a78
-#define A_PCIE_BUS_MST_STAT_7 0x5a7c
-#define A_PCIE_RSP_ERR_STAT_0 0x5a80
-#define A_PCIE_RSP_ERR_STAT_1 0x5a84
-#define A_PCIE_RSP_ERR_STAT_2 0x5a88
-#define A_PCIE_RSP_ERR_STAT_3 0x5a8c
-#define A_PCIE_RSP_ERR_STAT_4 0x5a90
-
-#define S_RSPERR_135_128 0
-#define M_RSPERR_135_128 0xffU
-#define V_RSPERR_135_128(x) ((x) << S_RSPERR_135_128)
-#define G_RSPERR_135_128(x) (((x) >> S_RSPERR_135_128) & M_RSPERR_135_128)
-
-#define A_PCIE_RSP_ERR_STAT_5 0x5a94
-#define A_PCIE_DBI_TIMEOUT_CTL 0x5a94
-
-#define S_DBI_TIMER 0
-#define M_DBI_TIMER 0xffffU
-#define V_DBI_TIMER(x) ((x) << S_DBI_TIMER)
-#define G_DBI_TIMER(x) (((x) >> S_DBI_TIMER) & M_DBI_TIMER)
-
-#define A_PCIE_RSP_ERR_STAT_6 0x5a98
-#define A_PCIE_DBI_TIMEOUT_STATUS0 0x5a98
-#define A_PCIE_RSP_ERR_STAT_7 0x5a9c
-#define A_PCIE_DBI_TIMEOUT_STATUS1 0x5a9c
-
-#define S_SOURCE 16
-#define M_SOURCE 0x3U
-#define V_SOURCE(x) ((x) << S_SOURCE)
-#define G_SOURCE(x) (((x) >> S_SOURCE) & M_SOURCE)
-
-#define S_DBI_WRITE 12
-#define M_DBI_WRITE 0xfU
-#define V_DBI_WRITE(x) ((x) << S_DBI_WRITE)
-#define G_DBI_WRITE(x) (((x) >> S_DBI_WRITE) & M_DBI_WRITE)
-
-#define S_DBI_CS2 11
-#define V_DBI_CS2(x) ((x) << S_DBI_CS2)
-#define F_DBI_CS2 V_DBI_CS2(1U)
-
-#define S_DBI_PF 8
-#define M_DBI_PF 0x7U
-#define V_DBI_PF(x) ((x) << S_DBI_PF)
-#define G_DBI_PF(x) (((x) >> S_DBI_PF) & M_DBI_PF)
-
-#define S_PL_TOVFVLD 7
-#define V_PL_TOVFVLD(x) ((x) << S_PL_TOVFVLD)
-#define F_PL_TOVFVLD V_PL_TOVFVLD(1U)
-
-#define S_PL_TOVF 0
-#define M_PL_TOVF 0x7fU
-#define V_PL_TOVF(x) ((x) << S_PL_TOVF)
-#define G_PL_TOVF(x) (((x) >> S_PL_TOVF) & M_PL_TOVF)
-
-#define S_T6_SOURCE 17
-#define M_T6_SOURCE 0x3U
-#define V_T6_SOURCE(x) ((x) << S_T6_SOURCE)
-#define G_T6_SOURCE(x) (((x) >> S_T6_SOURCE) & M_T6_SOURCE)
-
-#define S_T6_DBI_WRITE 13
-#define M_T6_DBI_WRITE 0xfU
-#define V_T6_DBI_WRITE(x) ((x) << S_T6_DBI_WRITE)
-#define G_T6_DBI_WRITE(x) (((x) >> S_T6_DBI_WRITE) & M_T6_DBI_WRITE)
-
-#define S_T6_DBI_CS2 12
-#define V_T6_DBI_CS2(x) ((x) << S_T6_DBI_CS2)
-#define F_T6_DBI_CS2 V_T6_DBI_CS2(1U)
-
-#define S_T6_DBI_PF 9
-#define M_T6_DBI_PF 0x7U
-#define V_T6_DBI_PF(x) ((x) << S_T6_DBI_PF)
-#define G_T6_DBI_PF(x) (((x) >> S_T6_DBI_PF) & M_T6_DBI_PF)
-
-#define S_T6_PL_TOVFVLD 8
-#define V_T6_PL_TOVFVLD(x) ((x) << S_T6_PL_TOVFVLD)
-#define F_T6_PL_TOVFVLD V_T6_PL_TOVFVLD(1U)
-
-#define S_T6_PL_TOVF 0
-#define M_T6_PL_TOVF 0xffU
-#define V_T6_PL_TOVF(x) ((x) << S_T6_PL_TOVF)
-#define G_T6_PL_TOVF(x) (((x) >> S_T6_PL_TOVF) & M_T6_PL_TOVF)
-
-#define A_PCIE_MSI_EN_0 0x5aa0
-#define A_PCIE_MSI_EN_1 0x5aa4
-#define A_PCIE_MSI_EN_2 0x5aa8
-#define A_PCIE_MSI_EN_3 0x5aac
-#define A_PCIE_MSI_EN_4 0x5ab0
-#define A_PCIE_MSI_EN_5 0x5ab4
-#define A_PCIE_MSI_EN_6 0x5ab8
-#define A_PCIE_MSI_EN_7 0x5abc
-#define A_PCIE_MSIX_EN_0 0x5ac0
-#define A_PCIE_MSIX_EN_1 0x5ac4
-#define A_PCIE_MSIX_EN_2 0x5ac8
-#define A_PCIE_MSIX_EN_3 0x5acc
-#define A_PCIE_MSIX_EN_4 0x5ad0
-#define A_PCIE_MSIX_EN_5 0x5ad4
-#define A_PCIE_MSIX_EN_6 0x5ad8
-#define A_PCIE_MSIX_EN_7 0x5adc
-#define A_PCIE_DMA_BUF_CTL 0x5ae0
-
-#define S_BUFRDCNT 18
-#define M_BUFRDCNT 0x3fffU
-#define V_BUFRDCNT(x) ((x) << S_BUFRDCNT)
-#define G_BUFRDCNT(x) (((x) >> S_BUFRDCNT) & M_BUFRDCNT)
-
-#define S_BUFWRCNT 9
-#define M_BUFWRCNT 0x1ffU
-#define V_BUFWRCNT(x) ((x) << S_BUFWRCNT)
-#define G_BUFWRCNT(x) (((x) >> S_BUFWRCNT) & M_BUFWRCNT)
-
-#define S_MAXBUFWRREQ 0
-#define M_MAXBUFWRREQ 0x1ffU
-#define V_MAXBUFWRREQ(x) ((x) << S_MAXBUFWRREQ)
-#define G_MAXBUFWRREQ(x) (((x) >> S_MAXBUFWRREQ) & M_MAXBUFWRREQ)
-
-#define A_PCIE_PB_CTL 0x5b94
-
-#define S_PB_SEL 16
-#define M_PB_SEL 0xffU
-#define V_PB_SEL(x) ((x) << S_PB_SEL)
-#define G_PB_SEL(x) (((x) >> S_PB_SEL) & M_PB_SEL)
-
-#define S_PB_SELREG 8
-#define M_PB_SELREG 0xffU
-#define V_PB_SELREG(x) ((x) << S_PB_SELREG)
-#define G_PB_SELREG(x) (((x) >> S_PB_SELREG) & M_PB_SELREG)
-
-#define S_PB_FUNC 0
-#define M_PB_FUNC 0x7U
-#define V_PB_FUNC(x) ((x) << S_PB_FUNC)
-#define G_PB_FUNC(x) (((x) >> S_PB_FUNC) & M_PB_FUNC)
-
-#define A_PCIE_PB_DATA 0x5b98
-#define A_PCIE_CUR_LINK 0x5b9c
-
-#define S_CFGINITCOEFFDONESEEN 22
-#define V_CFGINITCOEFFDONESEEN(x) ((x) << S_CFGINITCOEFFDONESEEN)
-#define F_CFGINITCOEFFDONESEEN V_CFGINITCOEFFDONESEEN(1U)
-
-#define S_CFGINITCOEFFDONE 21
-#define V_CFGINITCOEFFDONE(x) ((x) << S_CFGINITCOEFFDONE)
-#define F_CFGINITCOEFFDONE V_CFGINITCOEFFDONE(1U)
-
-#define S_XMLH_LINK_UP 20
-#define V_XMLH_LINK_UP(x) ((x) << S_XMLH_LINK_UP)
-#define F_XMLH_LINK_UP V_XMLH_LINK_UP(1U)
-
-#define S_PM_LINKST_IN_L0S 19
-#define V_PM_LINKST_IN_L0S(x) ((x) << S_PM_LINKST_IN_L0S)
-#define F_PM_LINKST_IN_L0S V_PM_LINKST_IN_L0S(1U)
-
-#define S_PM_LINKST_IN_L1 18
-#define V_PM_LINKST_IN_L1(x) ((x) << S_PM_LINKST_IN_L1)
-#define F_PM_LINKST_IN_L1 V_PM_LINKST_IN_L1(1U)
-
-#define S_PM_LINKST_IN_L2 17
-#define V_PM_LINKST_IN_L2(x) ((x) << S_PM_LINKST_IN_L2)
-#define F_PM_LINKST_IN_L2 V_PM_LINKST_IN_L2(1U)
-
-#define S_PM_LINKST_L2_EXIT 16
-#define V_PM_LINKST_L2_EXIT(x) ((x) << S_PM_LINKST_L2_EXIT)
-#define F_PM_LINKST_L2_EXIT V_PM_LINKST_L2_EXIT(1U)
-
-#define S_XMLH_IN_RL0S 15
-#define V_XMLH_IN_RL0S(x) ((x) << S_XMLH_IN_RL0S)
-#define F_XMLH_IN_RL0S V_XMLH_IN_RL0S(1U)
-
-#define S_XMLH_LTSSM_STATE_RCVRY_EQ 14
-#define V_XMLH_LTSSM_STATE_RCVRY_EQ(x) ((x) << S_XMLH_LTSSM_STATE_RCVRY_EQ)
-#define F_XMLH_LTSSM_STATE_RCVRY_EQ V_XMLH_LTSSM_STATE_RCVRY_EQ(1U)
-
-#define S_NEGOTIATEDWIDTH 8
-#define M_NEGOTIATEDWIDTH 0x3fU
-#define V_NEGOTIATEDWIDTH(x) ((x) << S_NEGOTIATEDWIDTH)
-#define G_NEGOTIATEDWIDTH(x) (((x) >> S_NEGOTIATEDWIDTH) & M_NEGOTIATEDWIDTH)
-
-#define S_ACTIVELANES 0
-#define M_ACTIVELANES 0xffU
-#define V_ACTIVELANES(x) ((x) << S_ACTIVELANES)
-#define G_ACTIVELANES(x) (((x) >> S_ACTIVELANES) & M_ACTIVELANES)
-
-#define A_PCIE_PHY_REQRXPWR 0x5ba0
-
-#define S_LNH_RXSTATEDONE 31
-#define V_LNH_RXSTATEDONE(x) ((x) << S_LNH_RXSTATEDONE)
-#define F_LNH_RXSTATEDONE V_LNH_RXSTATEDONE(1U)
-
-#define S_LNH_RXSTATEREQ 30
-#define V_LNH_RXSTATEREQ(x) ((x) << S_LNH_RXSTATEREQ)
-#define F_LNH_RXSTATEREQ V_LNH_RXSTATEREQ(1U)
-
-#define S_LNH_RXPWRSTATE 28
-#define M_LNH_RXPWRSTATE 0x3U
-#define V_LNH_RXPWRSTATE(x) ((x) << S_LNH_RXPWRSTATE)
-#define G_LNH_RXPWRSTATE(x) (((x) >> S_LNH_RXPWRSTATE) & M_LNH_RXPWRSTATE)
-
-#define S_LNG_RXSTATEDONE 27
-#define V_LNG_RXSTATEDONE(x) ((x) << S_LNG_RXSTATEDONE)
-#define F_LNG_RXSTATEDONE V_LNG_RXSTATEDONE(1U)
-
-#define S_LNG_RXSTATEREQ 26
-#define V_LNG_RXSTATEREQ(x) ((x) << S_LNG_RXSTATEREQ)
-#define F_LNG_RXSTATEREQ V_LNG_RXSTATEREQ(1U)
-
-#define S_LNG_RXPWRSTATE 24
-#define M_LNG_RXPWRSTATE 0x3U
-#define V_LNG_RXPWRSTATE(x) ((x) << S_LNG_RXPWRSTATE)
-#define G_LNG_RXPWRSTATE(x) (((x) >> S_LNG_RXPWRSTATE) & M_LNG_RXPWRSTATE)
-
-#define S_LNF_RXSTATEDONE 23
-#define V_LNF_RXSTATEDONE(x) ((x) << S_LNF_RXSTATEDONE)
-#define F_LNF_RXSTATEDONE V_LNF_RXSTATEDONE(1U)
-
-#define S_LNF_RXSTATEREQ 22
-#define V_LNF_RXSTATEREQ(x) ((x) << S_LNF_RXSTATEREQ)
-#define F_LNF_RXSTATEREQ V_LNF_RXSTATEREQ(1U)
-
-#define S_LNF_RXPWRSTATE 20
-#define M_LNF_RXPWRSTATE 0x3U
-#define V_LNF_RXPWRSTATE(x) ((x) << S_LNF_RXPWRSTATE)
-#define G_LNF_RXPWRSTATE(x) (((x) >> S_LNF_RXPWRSTATE) & M_LNF_RXPWRSTATE)
-
-#define S_LNE_RXSTATEDONE 19
-#define V_LNE_RXSTATEDONE(x) ((x) << S_LNE_RXSTATEDONE)
-#define F_LNE_RXSTATEDONE V_LNE_RXSTATEDONE(1U)
-
-#define S_LNE_RXSTATEREQ 18
-#define V_LNE_RXSTATEREQ(x) ((x) << S_LNE_RXSTATEREQ)
-#define F_LNE_RXSTATEREQ V_LNE_RXSTATEREQ(1U)
-
-#define S_LNE_RXPWRSTATE 16
-#define M_LNE_RXPWRSTATE 0x3U
-#define V_LNE_RXPWRSTATE(x) ((x) << S_LNE_RXPWRSTATE)
-#define G_LNE_RXPWRSTATE(x) (((x) >> S_LNE_RXPWRSTATE) & M_LNE_RXPWRSTATE)
-
-#define S_LND_RXSTATEDONE 15
-#define V_LND_RXSTATEDONE(x) ((x) << S_LND_RXSTATEDONE)
-#define F_LND_RXSTATEDONE V_LND_RXSTATEDONE(1U)
-
-#define S_LND_RXSTATEREQ 14
-#define V_LND_RXSTATEREQ(x) ((x) << S_LND_RXSTATEREQ)
-#define F_LND_RXSTATEREQ V_LND_RXSTATEREQ(1U)
-
-#define S_LND_RXPWRSTATE 12
-#define M_LND_RXPWRSTATE 0x3U
-#define V_LND_RXPWRSTATE(x) ((x) << S_LND_RXPWRSTATE)
-#define G_LND_RXPWRSTATE(x) (((x) >> S_LND_RXPWRSTATE) & M_LND_RXPWRSTATE)
-
-#define S_LNC_RXSTATEDONE 11
-#define V_LNC_RXSTATEDONE(x) ((x) << S_LNC_RXSTATEDONE)
-#define F_LNC_RXSTATEDONE V_LNC_RXSTATEDONE(1U)
-
-#define S_LNC_RXSTATEREQ 10
-#define V_LNC_RXSTATEREQ(x) ((x) << S_LNC_RXSTATEREQ)
-#define F_LNC_RXSTATEREQ V_LNC_RXSTATEREQ(1U)
-
-#define S_LNC_RXPWRSTATE 8
-#define M_LNC_RXPWRSTATE 0x3U
-#define V_LNC_RXPWRSTATE(x) ((x) << S_LNC_RXPWRSTATE)
-#define G_LNC_RXPWRSTATE(x) (((x) >> S_LNC_RXPWRSTATE) & M_LNC_RXPWRSTATE)
-
-#define S_LNB_RXSTATEDONE 7
-#define V_LNB_RXSTATEDONE(x) ((x) << S_LNB_RXSTATEDONE)
-#define F_LNB_RXSTATEDONE V_LNB_RXSTATEDONE(1U)
-
-#define S_LNB_RXSTATEREQ 6
-#define V_LNB_RXSTATEREQ(x) ((x) << S_LNB_RXSTATEREQ)
-#define F_LNB_RXSTATEREQ V_LNB_RXSTATEREQ(1U)
-
-#define S_LNB_RXPWRSTATE 4
-#define M_LNB_RXPWRSTATE 0x3U
-#define V_LNB_RXPWRSTATE(x) ((x) << S_LNB_RXPWRSTATE)
-#define G_LNB_RXPWRSTATE(x) (((x) >> S_LNB_RXPWRSTATE) & M_LNB_RXPWRSTATE)
-
-#define S_LNA_RXSTATEDONE 3
-#define V_LNA_RXSTATEDONE(x) ((x) << S_LNA_RXSTATEDONE)
-#define F_LNA_RXSTATEDONE V_LNA_RXSTATEDONE(1U)
-
-#define S_LNA_RXSTATEREQ 2
-#define V_LNA_RXSTATEREQ(x) ((x) << S_LNA_RXSTATEREQ)
-#define F_LNA_RXSTATEREQ V_LNA_RXSTATEREQ(1U)
-
-#define S_LNA_RXPWRSTATE 0
-#define M_LNA_RXPWRSTATE 0x3U
-#define V_LNA_RXPWRSTATE(x) ((x) << S_LNA_RXPWRSTATE)
-#define G_LNA_RXPWRSTATE(x) (((x) >> S_LNA_RXPWRSTATE) & M_LNA_RXPWRSTATE)
-
-#define S_REQ_LNH_RXSTATEDONE 31
-#define V_REQ_LNH_RXSTATEDONE(x) ((x) << S_REQ_LNH_RXSTATEDONE)
-#define F_REQ_LNH_RXSTATEDONE V_REQ_LNH_RXSTATEDONE(1U)
-
-#define S_REQ_LNH_RXSTATEREQ 30
-#define V_REQ_LNH_RXSTATEREQ(x) ((x) << S_REQ_LNH_RXSTATEREQ)
-#define F_REQ_LNH_RXSTATEREQ V_REQ_LNH_RXSTATEREQ(1U)
-
-#define S_REQ_LNH_RXPWRSTATE 28
-#define M_REQ_LNH_RXPWRSTATE 0x3U
-#define V_REQ_LNH_RXPWRSTATE(x) ((x) << S_REQ_LNH_RXPWRSTATE)
-#define G_REQ_LNH_RXPWRSTATE(x) (((x) >> S_REQ_LNH_RXPWRSTATE) & M_REQ_LNH_RXPWRSTATE)
-
-#define S_REQ_LNG_RXSTATEDONE 27
-#define V_REQ_LNG_RXSTATEDONE(x) ((x) << S_REQ_LNG_RXSTATEDONE)
-#define F_REQ_LNG_RXSTATEDONE V_REQ_LNG_RXSTATEDONE(1U)
-
-#define S_REQ_LNG_RXSTATEREQ 26
-#define V_REQ_LNG_RXSTATEREQ(x) ((x) << S_REQ_LNG_RXSTATEREQ)
-#define F_REQ_LNG_RXSTATEREQ V_REQ_LNG_RXSTATEREQ(1U)
-
-#define S_REQ_LNG_RXPWRSTATE 24
-#define M_REQ_LNG_RXPWRSTATE 0x3U
-#define V_REQ_LNG_RXPWRSTATE(x) ((x) << S_REQ_LNG_RXPWRSTATE)
-#define G_REQ_LNG_RXPWRSTATE(x) (((x) >> S_REQ_LNG_RXPWRSTATE) & M_REQ_LNG_RXPWRSTATE)
-
-#define S_REQ_LNF_RXSTATEDONE 23
-#define V_REQ_LNF_RXSTATEDONE(x) ((x) << S_REQ_LNF_RXSTATEDONE)
-#define F_REQ_LNF_RXSTATEDONE V_REQ_LNF_RXSTATEDONE(1U)
-
-#define S_REQ_LNF_RXSTATEREQ 22
-#define V_REQ_LNF_RXSTATEREQ(x) ((x) << S_REQ_LNF_RXSTATEREQ)
-#define F_REQ_LNF_RXSTATEREQ V_REQ_LNF_RXSTATEREQ(1U)
-
-#define S_REQ_LNF_RXPWRSTATE 20
-#define M_REQ_LNF_RXPWRSTATE 0x3U
-#define V_REQ_LNF_RXPWRSTATE(x) ((x) << S_REQ_LNF_RXPWRSTATE)
-#define G_REQ_LNF_RXPWRSTATE(x) (((x) >> S_REQ_LNF_RXPWRSTATE) & M_REQ_LNF_RXPWRSTATE)
-
-#define S_REQ_LNE_RXSTATEDONE 19
-#define V_REQ_LNE_RXSTATEDONE(x) ((x) << S_REQ_LNE_RXSTATEDONE)
-#define F_REQ_LNE_RXSTATEDONE V_REQ_LNE_RXSTATEDONE(1U)
-
-#define S_REQ_LNE_RXSTATEREQ 18
-#define V_REQ_LNE_RXSTATEREQ(x) ((x) << S_REQ_LNE_RXSTATEREQ)
-#define F_REQ_LNE_RXSTATEREQ V_REQ_LNE_RXSTATEREQ(1U)
-
-#define S_REQ_LNE_RXPWRSTATE 16
-#define M_REQ_LNE_RXPWRSTATE 0x3U
-#define V_REQ_LNE_RXPWRSTATE(x) ((x) << S_REQ_LNE_RXPWRSTATE)
-#define G_REQ_LNE_RXPWRSTATE(x) (((x) >> S_REQ_LNE_RXPWRSTATE) & M_REQ_LNE_RXPWRSTATE)
-
-#define S_REQ_LND_RXSTATEDONE 15
-#define V_REQ_LND_RXSTATEDONE(x) ((x) << S_REQ_LND_RXSTATEDONE)
-#define F_REQ_LND_RXSTATEDONE V_REQ_LND_RXSTATEDONE(1U)
-
-#define S_REQ_LND_RXSTATEREQ 14
-#define V_REQ_LND_RXSTATEREQ(x) ((x) << S_REQ_LND_RXSTATEREQ)
-#define F_REQ_LND_RXSTATEREQ V_REQ_LND_RXSTATEREQ(1U)
-
-#define S_REQ_LND_RXPWRSTATE 12
-#define M_REQ_LND_RXPWRSTATE 0x3U
-#define V_REQ_LND_RXPWRSTATE(x) ((x) << S_REQ_LND_RXPWRSTATE)
-#define G_REQ_LND_RXPWRSTATE(x) (((x) >> S_REQ_LND_RXPWRSTATE) & M_REQ_LND_RXPWRSTATE)
-
-#define S_REQ_LNC_RXSTATEDONE 11
-#define V_REQ_LNC_RXSTATEDONE(x) ((x) << S_REQ_LNC_RXSTATEDONE)
-#define F_REQ_LNC_RXSTATEDONE V_REQ_LNC_RXSTATEDONE(1U)
-
-#define S_REQ_LNC_RXSTATEREQ 10
-#define V_REQ_LNC_RXSTATEREQ(x) ((x) << S_REQ_LNC_RXSTATEREQ)
-#define F_REQ_LNC_RXSTATEREQ V_REQ_LNC_RXSTATEREQ(1U)
-
-#define S_REQ_LNC_RXPWRSTATE 8
-#define M_REQ_LNC_RXPWRSTATE 0x3U
-#define V_REQ_LNC_RXPWRSTATE(x) ((x) << S_REQ_LNC_RXPWRSTATE)
-#define G_REQ_LNC_RXPWRSTATE(x) (((x) >> S_REQ_LNC_RXPWRSTATE) & M_REQ_LNC_RXPWRSTATE)
-
-#define S_REQ_LNB_RXSTATEDONE 7
-#define V_REQ_LNB_RXSTATEDONE(x) ((x) << S_REQ_LNB_RXSTATEDONE)
-#define F_REQ_LNB_RXSTATEDONE V_REQ_LNB_RXSTATEDONE(1U)
-
-#define S_REQ_LNB_RXSTATEREQ 6
-#define V_REQ_LNB_RXSTATEREQ(x) ((x) << S_REQ_LNB_RXSTATEREQ)
-#define F_REQ_LNB_RXSTATEREQ V_REQ_LNB_RXSTATEREQ(1U)
-
-#define S_REQ_LNB_RXPWRSTATE 4
-#define M_REQ_LNB_RXPWRSTATE 0x3U
-#define V_REQ_LNB_RXPWRSTATE(x) ((x) << S_REQ_LNB_RXPWRSTATE)
-#define G_REQ_LNB_RXPWRSTATE(x) (((x) >> S_REQ_LNB_RXPWRSTATE) & M_REQ_LNB_RXPWRSTATE)
-
-#define S_REQ_LNA_RXSTATEDONE 3
-#define V_REQ_LNA_RXSTATEDONE(x) ((x) << S_REQ_LNA_RXSTATEDONE)
-#define F_REQ_LNA_RXSTATEDONE V_REQ_LNA_RXSTATEDONE(1U)
-
-#define S_REQ_LNA_RXSTATEREQ 2
-#define V_REQ_LNA_RXSTATEREQ(x) ((x) << S_REQ_LNA_RXSTATEREQ)
-#define F_REQ_LNA_RXSTATEREQ V_REQ_LNA_RXSTATEREQ(1U)
-
-#define S_REQ_LNA_RXPWRSTATE 0
-#define M_REQ_LNA_RXPWRSTATE 0x3U
-#define V_REQ_LNA_RXPWRSTATE(x) ((x) << S_REQ_LNA_RXPWRSTATE)
-#define G_REQ_LNA_RXPWRSTATE(x) (((x) >> S_REQ_LNA_RXPWRSTATE) & M_REQ_LNA_RXPWRSTATE)
-
-#define A_PCIE_PHY_CURRXPWR 0x5ba4
-
-#define S_T5_LNH_RXPWRSTATE 28
-#define M_T5_LNH_RXPWRSTATE 0x7U
-#define V_T5_LNH_RXPWRSTATE(x) ((x) << S_T5_LNH_RXPWRSTATE)
-#define G_T5_LNH_RXPWRSTATE(x) (((x) >> S_T5_LNH_RXPWRSTATE) & M_T5_LNH_RXPWRSTATE)
-
-#define S_T5_LNG_RXPWRSTATE 24
-#define M_T5_LNG_RXPWRSTATE 0x7U
-#define V_T5_LNG_RXPWRSTATE(x) ((x) << S_T5_LNG_RXPWRSTATE)
-#define G_T5_LNG_RXPWRSTATE(x) (((x) >> S_T5_LNG_RXPWRSTATE) & M_T5_LNG_RXPWRSTATE)
-
-#define S_T5_LNF_RXPWRSTATE 20
-#define M_T5_LNF_RXPWRSTATE 0x7U
-#define V_T5_LNF_RXPWRSTATE(x) ((x) << S_T5_LNF_RXPWRSTATE)
-#define G_T5_LNF_RXPWRSTATE(x) (((x) >> S_T5_LNF_RXPWRSTATE) & M_T5_LNF_RXPWRSTATE)
-
-#define S_T5_LNE_RXPWRSTATE 16
-#define M_T5_LNE_RXPWRSTATE 0x7U
-#define V_T5_LNE_RXPWRSTATE(x) ((x) << S_T5_LNE_RXPWRSTATE)
-#define G_T5_LNE_RXPWRSTATE(x) (((x) >> S_T5_LNE_RXPWRSTATE) & M_T5_LNE_RXPWRSTATE)
-
-#define S_T5_LND_RXPWRSTATE 12
-#define M_T5_LND_RXPWRSTATE 0x7U
-#define V_T5_LND_RXPWRSTATE(x) ((x) << S_T5_LND_RXPWRSTATE)
-#define G_T5_LND_RXPWRSTATE(x) (((x) >> S_T5_LND_RXPWRSTATE) & M_T5_LND_RXPWRSTATE)
-
-#define S_T5_LNC_RXPWRSTATE 8
-#define M_T5_LNC_RXPWRSTATE 0x7U
-#define V_T5_LNC_RXPWRSTATE(x) ((x) << S_T5_LNC_RXPWRSTATE)
-#define G_T5_LNC_RXPWRSTATE(x) (((x) >> S_T5_LNC_RXPWRSTATE) & M_T5_LNC_RXPWRSTATE)
-
-#define S_T5_LNB_RXPWRSTATE 4
-#define M_T5_LNB_RXPWRSTATE 0x7U
-#define V_T5_LNB_RXPWRSTATE(x) ((x) << S_T5_LNB_RXPWRSTATE)
-#define G_T5_LNB_RXPWRSTATE(x) (((x) >> S_T5_LNB_RXPWRSTATE) & M_T5_LNB_RXPWRSTATE)
-
-#define S_T5_LNA_RXPWRSTATE 0
-#define M_T5_LNA_RXPWRSTATE 0x7U
-#define V_T5_LNA_RXPWRSTATE(x) ((x) << S_T5_LNA_RXPWRSTATE)
-#define G_T5_LNA_RXPWRSTATE(x) (((x) >> S_T5_LNA_RXPWRSTATE) & M_T5_LNA_RXPWRSTATE)
-
-#define S_CUR_LNH_RXPWRSTATE 28
-#define M_CUR_LNH_RXPWRSTATE 0x7U
-#define V_CUR_LNH_RXPWRSTATE(x) ((x) << S_CUR_LNH_RXPWRSTATE)
-#define G_CUR_LNH_RXPWRSTATE(x) (((x) >> S_CUR_LNH_RXPWRSTATE) & M_CUR_LNH_RXPWRSTATE)
-
-#define S_CUR_LNG_RXPWRSTATE 24
-#define M_CUR_LNG_RXPWRSTATE 0x7U
-#define V_CUR_LNG_RXPWRSTATE(x) ((x) << S_CUR_LNG_RXPWRSTATE)
-#define G_CUR_LNG_RXPWRSTATE(x) (((x) >> S_CUR_LNG_RXPWRSTATE) & M_CUR_LNG_RXPWRSTATE)
-
-#define S_CUR_LNF_RXPWRSTATE 20
-#define M_CUR_LNF_RXPWRSTATE 0x7U
-#define V_CUR_LNF_RXPWRSTATE(x) ((x) << S_CUR_LNF_RXPWRSTATE)
-#define G_CUR_LNF_RXPWRSTATE(x) (((x) >> S_CUR_LNF_RXPWRSTATE) & M_CUR_LNF_RXPWRSTATE)
-
-#define S_CUR_LNE_RXPWRSTATE 16
-#define M_CUR_LNE_RXPWRSTATE 0x7U
-#define V_CUR_LNE_RXPWRSTATE(x) ((x) << S_CUR_LNE_RXPWRSTATE)
-#define G_CUR_LNE_RXPWRSTATE(x) (((x) >> S_CUR_LNE_RXPWRSTATE) & M_CUR_LNE_RXPWRSTATE)
-
-#define S_CUR_LND_RXPWRSTATE 12
-#define M_CUR_LND_RXPWRSTATE 0x7U
-#define V_CUR_LND_RXPWRSTATE(x) ((x) << S_CUR_LND_RXPWRSTATE)
-#define G_CUR_LND_RXPWRSTATE(x) (((x) >> S_CUR_LND_RXPWRSTATE) & M_CUR_LND_RXPWRSTATE)
-
-#define S_CUR_LNC_RXPWRSTATE 8
-#define M_CUR_LNC_RXPWRSTATE 0x7U
-#define V_CUR_LNC_RXPWRSTATE(x) ((x) << S_CUR_LNC_RXPWRSTATE)
-#define G_CUR_LNC_RXPWRSTATE(x) (((x) >> S_CUR_LNC_RXPWRSTATE) & M_CUR_LNC_RXPWRSTATE)
-
-#define S_CUR_LNB_RXPWRSTATE 4
-#define M_CUR_LNB_RXPWRSTATE 0x7U
-#define V_CUR_LNB_RXPWRSTATE(x) ((x) << S_CUR_LNB_RXPWRSTATE)
-#define G_CUR_LNB_RXPWRSTATE(x) (((x) >> S_CUR_LNB_RXPWRSTATE) & M_CUR_LNB_RXPWRSTATE)
-
-#define S_CUR_LNA_RXPWRSTATE 0
-#define M_CUR_LNA_RXPWRSTATE 0x7U
-#define V_CUR_LNA_RXPWRSTATE(x) ((x) << S_CUR_LNA_RXPWRSTATE)
-#define G_CUR_LNA_RXPWRSTATE(x) (((x) >> S_CUR_LNA_RXPWRSTATE) & M_CUR_LNA_RXPWRSTATE)
-
-#define A_PCIE_PHY_GEN3_AE0 0x5ba8
-
-#define S_LND_STAT 28
-#define M_LND_STAT 0x7U
-#define V_LND_STAT(x) ((x) << S_LND_STAT)
-#define G_LND_STAT(x) (((x) >> S_LND_STAT) & M_LND_STAT)
-
-#define S_LND_CMD 24
-#define M_LND_CMD 0x7U
-#define V_LND_CMD(x) ((x) << S_LND_CMD)
-#define G_LND_CMD(x) (((x) >> S_LND_CMD) & M_LND_CMD)
-
-#define S_LNC_STAT 20
-#define M_LNC_STAT 0x7U
-#define V_LNC_STAT(x) ((x) << S_LNC_STAT)
-#define G_LNC_STAT(x) (((x) >> S_LNC_STAT) & M_LNC_STAT)
-
-#define S_LNC_CMD 16
-#define M_LNC_CMD 0x7U
-#define V_LNC_CMD(x) ((x) << S_LNC_CMD)
-#define G_LNC_CMD(x) (((x) >> S_LNC_CMD) & M_LNC_CMD)
-
-#define S_LNB_STAT 12
-#define M_LNB_STAT 0x7U
-#define V_LNB_STAT(x) ((x) << S_LNB_STAT)
-#define G_LNB_STAT(x) (((x) >> S_LNB_STAT) & M_LNB_STAT)
-
-#define S_LNB_CMD 8
-#define M_LNB_CMD 0x7U
-#define V_LNB_CMD(x) ((x) << S_LNB_CMD)
-#define G_LNB_CMD(x) (((x) >> S_LNB_CMD) & M_LNB_CMD)
-
-#define S_LNA_STAT 4
-#define M_LNA_STAT 0x7U
-#define V_LNA_STAT(x) ((x) << S_LNA_STAT)
-#define G_LNA_STAT(x) (((x) >> S_LNA_STAT) & M_LNA_STAT)
-
-#define S_LNA_CMD 0
-#define M_LNA_CMD 0x7U
-#define V_LNA_CMD(x) ((x) << S_LNA_CMD)
-#define G_LNA_CMD(x) (((x) >> S_LNA_CMD) & M_LNA_CMD)
-
-#define A_PCIE_PHY_GEN3_AE1 0x5bac
-
-#define S_LNH_STAT 28
-#define M_LNH_STAT 0x7U
-#define V_LNH_STAT(x) ((x) << S_LNH_STAT)
-#define G_LNH_STAT(x) (((x) >> S_LNH_STAT) & M_LNH_STAT)
-
-#define S_LNH_CMD 24
-#define M_LNH_CMD 0x7U
-#define V_LNH_CMD(x) ((x) << S_LNH_CMD)
-#define G_LNH_CMD(x) (((x) >> S_LNH_CMD) & M_LNH_CMD)
-
-#define S_LNG_STAT 20
-#define M_LNG_STAT 0x7U
-#define V_LNG_STAT(x) ((x) << S_LNG_STAT)
-#define G_LNG_STAT(x) (((x) >> S_LNG_STAT) & M_LNG_STAT)
-
-#define S_LNG_CMD 16
-#define M_LNG_CMD 0x7U
-#define V_LNG_CMD(x) ((x) << S_LNG_CMD)
-#define G_LNG_CMD(x) (((x) >> S_LNG_CMD) & M_LNG_CMD)
-
-#define S_LNF_STAT 12
-#define M_LNF_STAT 0x7U
-#define V_LNF_STAT(x) ((x) << S_LNF_STAT)
-#define G_LNF_STAT(x) (((x) >> S_LNF_STAT) & M_LNF_STAT)
-
-#define S_LNF_CMD 8
-#define M_LNF_CMD 0x7U
-#define V_LNF_CMD(x) ((x) << S_LNF_CMD)
-#define G_LNF_CMD(x) (((x) >> S_LNF_CMD) & M_LNF_CMD)
-
-#define S_LNE_STAT 4
-#define M_LNE_STAT 0x7U
-#define V_LNE_STAT(x) ((x) << S_LNE_STAT)
-#define G_LNE_STAT(x) (((x) >> S_LNE_STAT) & M_LNE_STAT)
-
-#define S_LNE_CMD 0
-#define M_LNE_CMD 0x7U
-#define V_LNE_CMD(x) ((x) << S_LNE_CMD)
-#define G_LNE_CMD(x) (((x) >> S_LNE_CMD) & M_LNE_CMD)
-
-#define A_PCIE_PHY_FS_LF0 0x5bb0
-
-#define S_LANE1LF 24
-#define M_LANE1LF 0x3fU
-#define V_LANE1LF(x) ((x) << S_LANE1LF)
-#define G_LANE1LF(x) (((x) >> S_LANE1LF) & M_LANE1LF)
-
-#define S_LANE1FS 16
-#define M_LANE1FS 0x3fU
-#define V_LANE1FS(x) ((x) << S_LANE1FS)
-#define G_LANE1FS(x) (((x) >> S_LANE1FS) & M_LANE1FS)
-
-#define S_LANE0LF 8
-#define M_LANE0LF 0x3fU
-#define V_LANE0LF(x) ((x) << S_LANE0LF)
-#define G_LANE0LF(x) (((x) >> S_LANE0LF) & M_LANE0LF)
-
-#define S_LANE0FS 0
-#define M_LANE0FS 0x3fU
-#define V_LANE0FS(x) ((x) << S_LANE0FS)
-#define G_LANE0FS(x) (((x) >> S_LANE0FS) & M_LANE0FS)
-
-#define A_PCIE_PHY_FS_LF1 0x5bb4
-
-#define S_LANE3LF 24
-#define M_LANE3LF 0x3fU
-#define V_LANE3LF(x) ((x) << S_LANE3LF)
-#define G_LANE3LF(x) (((x) >> S_LANE3LF) & M_LANE3LF)
-
-#define S_LANE3FS 16
-#define M_LANE3FS 0x3fU
-#define V_LANE3FS(x) ((x) << S_LANE3FS)
-#define G_LANE3FS(x) (((x) >> S_LANE3FS) & M_LANE3FS)
-
-#define S_LANE2LF 8
-#define M_LANE2LF 0x3fU
-#define V_LANE2LF(x) ((x) << S_LANE2LF)
-#define G_LANE2LF(x) (((x) >> S_LANE2LF) & M_LANE2LF)
-
-#define S_LANE2FS 0
-#define M_LANE2FS 0x3fU
-#define V_LANE2FS(x) ((x) << S_LANE2FS)
-#define G_LANE2FS(x) (((x) >> S_LANE2FS) & M_LANE2FS)
-
-#define A_PCIE_PHY_FS_LF2 0x5bb8
-
-#define S_LANE5LF 24
-#define M_LANE5LF 0x3fU
-#define V_LANE5LF(x) ((x) << S_LANE5LF)
-#define G_LANE5LF(x) (((x) >> S_LANE5LF) & M_LANE5LF)
-
-#define S_LANE5FS 16
-#define M_LANE5FS 0x3fU
-#define V_LANE5FS(x) ((x) << S_LANE5FS)
-#define G_LANE5FS(x) (((x) >> S_LANE5FS) & M_LANE5FS)
-
-#define S_LANE4LF 8
-#define M_LANE4LF 0x3fU
-#define V_LANE4LF(x) ((x) << S_LANE4LF)
-#define G_LANE4LF(x) (((x) >> S_LANE4LF) & M_LANE4LF)
-
-#define S_LANE4FS 0
-#define M_LANE4FS 0x3fU
-#define V_LANE4FS(x) ((x) << S_LANE4FS)
-#define G_LANE4FS(x) (((x) >> S_LANE4FS) & M_LANE4FS)
-
-#define A_PCIE_PHY_FS_LF3 0x5bbc
-
-#define S_LANE7LF 24
-#define M_LANE7LF 0x3fU
-#define V_LANE7LF(x) ((x) << S_LANE7LF)
-#define G_LANE7LF(x) (((x) >> S_LANE7LF) & M_LANE7LF)
-
-#define S_LANE7FS 16
-#define M_LANE7FS 0x3fU
-#define V_LANE7FS(x) ((x) << S_LANE7FS)
-#define G_LANE7FS(x) (((x) >> S_LANE7FS) & M_LANE7FS)
-
-#define S_LANE6LF 8
-#define M_LANE6LF 0x3fU
-#define V_LANE6LF(x) ((x) << S_LANE6LF)
-#define G_LANE6LF(x) (((x) >> S_LANE6LF) & M_LANE6LF)
-
-#define S_LANE6FS 0
-#define M_LANE6FS 0x3fU
-#define V_LANE6FS(x) ((x) << S_LANE6FS)
-#define G_LANE6FS(x) (((x) >> S_LANE6FS) & M_LANE6FS)
-
-#define A_PCIE_PHY_PRESET_REQ 0x5bc0
-
-#define S_COEFFDONE 16
-#define V_COEFFDONE(x) ((x) << S_COEFFDONE)
-#define F_COEFFDONE V_COEFFDONE(1U)
-
-#define S_COEFFLANE 8
-#define M_COEFFLANE 0x7U
-#define V_COEFFLANE(x) ((x) << S_COEFFLANE)
-#define G_COEFFLANE(x) (((x) >> S_COEFFLANE) & M_COEFFLANE)
-
-#define S_COEFFSTART 0
-#define V_COEFFSTART(x) ((x) << S_COEFFSTART)
-#define F_COEFFSTART V_COEFFSTART(1U)
-
-#define S_T6_COEFFLANE 8
-#define M_T6_COEFFLANE 0xfU
-#define V_T6_COEFFLANE(x) ((x) << S_T6_COEFFLANE)
-#define G_T6_COEFFLANE(x) (((x) >> S_T6_COEFFLANE) & M_T6_COEFFLANE)
-
-#define A_PCIE_PHY_PRESET_COEFF 0x5bc4
-
-#define S_COEFF 0
-#define M_COEFF 0x3ffffU
-#define V_COEFF(x) ((x) << S_COEFF)
-#define G_COEFF(x) (((x) >> S_COEFF) & M_COEFF)
-
-#define A_PCIE_PHY_INDIR_REQ 0x5bf0
-
-#define S_PHYENABLE 31
-#define V_PHYENABLE(x) ((x) << S_PHYENABLE)
-#define F_PHYENABLE V_PHYENABLE(1U)
-
-#define S_PCIE_PHY_REGADDR 0
-#define M_PCIE_PHY_REGADDR 0xffffU
-#define V_PCIE_PHY_REGADDR(x) ((x) << S_PCIE_PHY_REGADDR)
-#define G_PCIE_PHY_REGADDR(x) (((x) >> S_PCIE_PHY_REGADDR) & M_PCIE_PHY_REGADDR)
-
-#define A_PCIE_PHY_INDIR_DATA 0x5bf4
-#define A_PCIE_STATIC_SPARE1 0x5bf8
-#define A_PCIE_STATIC_SPARE2 0x5bfc
-#define A_PCIE_KDOORBELL_GTS_PF_BASE_LEN 0x5c10
-
-#define S_KDB_PF_LEN 24
-#define M_KDB_PF_LEN 0x1fU
-#define V_KDB_PF_LEN(x) ((x) << S_KDB_PF_LEN)
-#define G_KDB_PF_LEN(x) (((x) >> S_KDB_PF_LEN) & M_KDB_PF_LEN)
-
-#define S_KDB_PF_BASEADDR 0
-#define M_KDB_PF_BASEADDR 0xfffffU
-#define V_KDB_PF_BASEADDR(x) ((x) << S_KDB_PF_BASEADDR)
-#define G_KDB_PF_BASEADDR(x) (((x) >> S_KDB_PF_BASEADDR) & M_KDB_PF_BASEADDR)
-
-#define A_PCIE_KDOORBELL_GTS_VF_BASE_LEN 0x5c14
-
-#define S_KDB_VF_LEN 24
-#define M_KDB_VF_LEN 0x1fU
-#define V_KDB_VF_LEN(x) ((x) << S_KDB_VF_LEN)
-#define G_KDB_VF_LEN(x) (((x) >> S_KDB_VF_LEN) & M_KDB_VF_LEN)
-
-#define S_KDB_VF_BASEADDR 0
-#define M_KDB_VF_BASEADDR 0xfffffU
-#define V_KDB_VF_BASEADDR(x) ((x) << S_KDB_VF_BASEADDR)
-#define G_KDB_VF_BASEADDR(x) (((x) >> S_KDB_VF_BASEADDR) & M_KDB_VF_BASEADDR)
-
-#define A_PCIE_KDOORBELL_GTS_VF_OFFSET 0x5c18
-
-#define S_KDB_VF_MODOFST 0
-#define M_KDB_VF_MODOFST 0xfffU
-#define V_KDB_VF_MODOFST(x) ((x) << S_KDB_VF_MODOFST)
-#define G_KDB_VF_MODOFST(x) (((x) >> S_KDB_VF_MODOFST) & M_KDB_VF_MODOFST)
-
-#define A_PCIE_PHY_REQRXPWR1 0x5c1c
-
-#define S_REQ_LNP_RXSTATEDONE 31
-#define V_REQ_LNP_RXSTATEDONE(x) ((x) << S_REQ_LNP_RXSTATEDONE)
-#define F_REQ_LNP_RXSTATEDONE V_REQ_LNP_RXSTATEDONE(1U)
-
-#define S_REQ_LNP_RXSTATEREQ 30
-#define V_REQ_LNP_RXSTATEREQ(x) ((x) << S_REQ_LNP_RXSTATEREQ)
-#define F_REQ_LNP_RXSTATEREQ V_REQ_LNP_RXSTATEREQ(1U)
-
-#define S_REQ_LNP_RXPWRSTATE 28
-#define M_REQ_LNP_RXPWRSTATE 0x3U
-#define V_REQ_LNP_RXPWRSTATE(x) ((x) << S_REQ_LNP_RXPWRSTATE)
-#define G_REQ_LNP_RXPWRSTATE(x) (((x) >> S_REQ_LNP_RXPWRSTATE) & M_REQ_LNP_RXPWRSTATE)
-
-#define S_REQ_LNO_RXSTATEDONE 27
-#define V_REQ_LNO_RXSTATEDONE(x) ((x) << S_REQ_LNO_RXSTATEDONE)
-#define F_REQ_LNO_RXSTATEDONE V_REQ_LNO_RXSTATEDONE(1U)
-
-#define S_REQ_LNO_RXSTATEREQ 26
-#define V_REQ_LNO_RXSTATEREQ(x) ((x) << S_REQ_LNO_RXSTATEREQ)
-#define F_REQ_LNO_RXSTATEREQ V_REQ_LNO_RXSTATEREQ(1U)
-
-#define S_REQ_LNO_RXPWRSTATE 24
-#define M_REQ_LNO_RXPWRSTATE 0x3U
-#define V_REQ_LNO_RXPWRSTATE(x) ((x) << S_REQ_LNO_RXPWRSTATE)
-#define G_REQ_LNO_RXPWRSTATE(x) (((x) >> S_REQ_LNO_RXPWRSTATE) & M_REQ_LNO_RXPWRSTATE)
-
-#define S_REQ_LNN_RXSTATEDONE 23
-#define V_REQ_LNN_RXSTATEDONE(x) ((x) << S_REQ_LNN_RXSTATEDONE)
-#define F_REQ_LNN_RXSTATEDONE V_REQ_LNN_RXSTATEDONE(1U)
-
-#define S_REQ_LNN_RXSTATEREQ 22
-#define V_REQ_LNN_RXSTATEREQ(x) ((x) << S_REQ_LNN_RXSTATEREQ)
-#define F_REQ_LNN_RXSTATEREQ V_REQ_LNN_RXSTATEREQ(1U)
-
-#define S_REQ_LNN_RXPWRSTATE 20
-#define M_REQ_LNN_RXPWRSTATE 0x3U
-#define V_REQ_LNN_RXPWRSTATE(x) ((x) << S_REQ_LNN_RXPWRSTATE)
-#define G_REQ_LNN_RXPWRSTATE(x) (((x) >> S_REQ_LNN_RXPWRSTATE) & M_REQ_LNN_RXPWRSTATE)
-
-#define S_REQ_LNM_RXSTATEDONE 19
-#define V_REQ_LNM_RXSTATEDONE(x) ((x) << S_REQ_LNM_RXSTATEDONE)
-#define F_REQ_LNM_RXSTATEDONE V_REQ_LNM_RXSTATEDONE(1U)
-
-#define S_REQ_LNM_RXSTATEREQ 18
-#define V_REQ_LNM_RXSTATEREQ(x) ((x) << S_REQ_LNM_RXSTATEREQ)
-#define F_REQ_LNM_RXSTATEREQ V_REQ_LNM_RXSTATEREQ(1U)
-
-#define S_REQ_LNM_RXPWRSTATE 16
-#define M_REQ_LNM_RXPWRSTATE 0x3U
-#define V_REQ_LNM_RXPWRSTATE(x) ((x) << S_REQ_LNM_RXPWRSTATE)
-#define G_REQ_LNM_RXPWRSTATE(x) (((x) >> S_REQ_LNM_RXPWRSTATE) & M_REQ_LNM_RXPWRSTATE)
-
-#define S_REQ_LNL_RXSTATEDONE 15
-#define V_REQ_LNL_RXSTATEDONE(x) ((x) << S_REQ_LNL_RXSTATEDONE)
-#define F_REQ_LNL_RXSTATEDONE V_REQ_LNL_RXSTATEDONE(1U)
-
-#define S_REQ_LNL_RXSTATEREQ 14
-#define V_REQ_LNL_RXSTATEREQ(x) ((x) << S_REQ_LNL_RXSTATEREQ)
-#define F_REQ_LNL_RXSTATEREQ V_REQ_LNL_RXSTATEREQ(1U)
-
-#define S_REQ_LNL_RXPWRSTATE 12
-#define M_REQ_LNL_RXPWRSTATE 0x3U
-#define V_REQ_LNL_RXPWRSTATE(x) ((x) << S_REQ_LNL_RXPWRSTATE)
-#define G_REQ_LNL_RXPWRSTATE(x) (((x) >> S_REQ_LNL_RXPWRSTATE) & M_REQ_LNL_RXPWRSTATE)
-
-#define S_REQ_LNK_RXSTATEDONE 11
-#define V_REQ_LNK_RXSTATEDONE(x) ((x) << S_REQ_LNK_RXSTATEDONE)
-#define F_REQ_LNK_RXSTATEDONE V_REQ_LNK_RXSTATEDONE(1U)
-
-#define S_REQ_LNK_RXSTATEREQ 10
-#define V_REQ_LNK_RXSTATEREQ(x) ((x) << S_REQ_LNK_RXSTATEREQ)
-#define F_REQ_LNK_RXSTATEREQ V_REQ_LNK_RXSTATEREQ(1U)
-
-#define S_REQ_LNK_RXPWRSTATE 8
-#define M_REQ_LNK_RXPWRSTATE 0x3U
-#define V_REQ_LNK_RXPWRSTATE(x) ((x) << S_REQ_LNK_RXPWRSTATE)
-#define G_REQ_LNK_RXPWRSTATE(x) (((x) >> S_REQ_LNK_RXPWRSTATE) & M_REQ_LNK_RXPWRSTATE)
-
-#define S_REQ_LNJ_RXSTATEDONE 7
-#define V_REQ_LNJ_RXSTATEDONE(x) ((x) << S_REQ_LNJ_RXSTATEDONE)
-#define F_REQ_LNJ_RXSTATEDONE V_REQ_LNJ_RXSTATEDONE(1U)
-
-#define S_REQ_LNJ_RXSTATEREQ 6
-#define V_REQ_LNJ_RXSTATEREQ(x) ((x) << S_REQ_LNJ_RXSTATEREQ)
-#define F_REQ_LNJ_RXSTATEREQ V_REQ_LNJ_RXSTATEREQ(1U)
-
-#define S_REQ_LNJ_RXPWRSTATE 4
-#define M_REQ_LNJ_RXPWRSTATE 0x3U
-#define V_REQ_LNJ_RXPWRSTATE(x) ((x) << S_REQ_LNJ_RXPWRSTATE)
-#define G_REQ_LNJ_RXPWRSTATE(x) (((x) >> S_REQ_LNJ_RXPWRSTATE) & M_REQ_LNJ_RXPWRSTATE)
-
-#define S_REQ_LNI_RXSTATEDONE 3
-#define V_REQ_LNI_RXSTATEDONE(x) ((x) << S_REQ_LNI_RXSTATEDONE)
-#define F_REQ_LNI_RXSTATEDONE V_REQ_LNI_RXSTATEDONE(1U)
-
-#define S_REQ_LNI_RXSTATEREQ 2
-#define V_REQ_LNI_RXSTATEREQ(x) ((x) << S_REQ_LNI_RXSTATEREQ)
-#define F_REQ_LNI_RXSTATEREQ V_REQ_LNI_RXSTATEREQ(1U)
-
-#define S_REQ_LNI_RXPWRSTATE 0
-#define M_REQ_LNI_RXPWRSTATE 0x3U
-#define V_REQ_LNI_RXPWRSTATE(x) ((x) << S_REQ_LNI_RXPWRSTATE)
-#define G_REQ_LNI_RXPWRSTATE(x) (((x) >> S_REQ_LNI_RXPWRSTATE) & M_REQ_LNI_RXPWRSTATE)
-
-#define A_PCIE_PHY_CURRXPWR1 0x5c20
-
-#define S_CUR_LNP_RXPWRSTATE 28
-#define M_CUR_LNP_RXPWRSTATE 0x7U
-#define V_CUR_LNP_RXPWRSTATE(x) ((x) << S_CUR_LNP_RXPWRSTATE)
-#define G_CUR_LNP_RXPWRSTATE(x) (((x) >> S_CUR_LNP_RXPWRSTATE) & M_CUR_LNP_RXPWRSTATE)
-
-#define S_CUR_LNO_RXPWRSTATE 24
-#define M_CUR_LNO_RXPWRSTATE 0x7U
-#define V_CUR_LNO_RXPWRSTATE(x) ((x) << S_CUR_LNO_RXPWRSTATE)
-#define G_CUR_LNO_RXPWRSTATE(x) (((x) >> S_CUR_LNO_RXPWRSTATE) & M_CUR_LNO_RXPWRSTATE)
-
-#define S_CUR_LNN_RXPWRSTATE 20
-#define M_CUR_LNN_RXPWRSTATE 0x7U
-#define V_CUR_LNN_RXPWRSTATE(x) ((x) << S_CUR_LNN_RXPWRSTATE)
-#define G_CUR_LNN_RXPWRSTATE(x) (((x) >> S_CUR_LNN_RXPWRSTATE) & M_CUR_LNN_RXPWRSTATE)
-
-#define S_CUR_LNM_RXPWRSTATE 16
-#define M_CUR_LNM_RXPWRSTATE 0x7U
-#define V_CUR_LNM_RXPWRSTATE(x) ((x) << S_CUR_LNM_RXPWRSTATE)
-#define G_CUR_LNM_RXPWRSTATE(x) (((x) >> S_CUR_LNM_RXPWRSTATE) & M_CUR_LNM_RXPWRSTATE)
-
-#define S_CUR_LNL_RXPWRSTATE 12
-#define M_CUR_LNL_RXPWRSTATE 0x7U
-#define V_CUR_LNL_RXPWRSTATE(x) ((x) << S_CUR_LNL_RXPWRSTATE)
-#define G_CUR_LNL_RXPWRSTATE(x) (((x) >> S_CUR_LNL_RXPWRSTATE) & M_CUR_LNL_RXPWRSTATE)
-
-#define S_CUR_LNK_RXPWRSTATE 8
-#define M_CUR_LNK_RXPWRSTATE 0x7U
-#define V_CUR_LNK_RXPWRSTATE(x) ((x) << S_CUR_LNK_RXPWRSTATE)
-#define G_CUR_LNK_RXPWRSTATE(x) (((x) >> S_CUR_LNK_RXPWRSTATE) & M_CUR_LNK_RXPWRSTATE)
-
-#define S_CUR_LNJ_RXPWRSTATE 4
-#define M_CUR_LNJ_RXPWRSTATE 0x7U
-#define V_CUR_LNJ_RXPWRSTATE(x) ((x) << S_CUR_LNJ_RXPWRSTATE)
-#define G_CUR_LNJ_RXPWRSTATE(x) (((x) >> S_CUR_LNJ_RXPWRSTATE) & M_CUR_LNJ_RXPWRSTATE)
-
-#define S_CUR_LNI_RXPWRSTATE 0
-#define M_CUR_LNI_RXPWRSTATE 0x7U
-#define V_CUR_LNI_RXPWRSTATE(x) ((x) << S_CUR_LNI_RXPWRSTATE)
-#define G_CUR_LNI_RXPWRSTATE(x) (((x) >> S_CUR_LNI_RXPWRSTATE) & M_CUR_LNI_RXPWRSTATE)
-
-#define A_PCIE_PHY_GEN3_AE2 0x5c24
-
-#define S_LNL_STAT 28
-#define M_LNL_STAT 0x7U
-#define V_LNL_STAT(x) ((x) << S_LNL_STAT)
-#define G_LNL_STAT(x) (((x) >> S_LNL_STAT) & M_LNL_STAT)
-
-#define S_LNL_CMD 24
-#define M_LNL_CMD 0x7U
-#define V_LNL_CMD(x) ((x) << S_LNL_CMD)
-#define G_LNL_CMD(x) (((x) >> S_LNL_CMD) & M_LNL_CMD)
-
-#define S_LNK_STAT 20
-#define M_LNK_STAT 0x7U
-#define V_LNK_STAT(x) ((x) << S_LNK_STAT)
-#define G_LNK_STAT(x) (((x) >> S_LNK_STAT) & M_LNK_STAT)
-
-#define S_LNK_CMD 16
-#define M_LNK_CMD 0x7U
-#define V_LNK_CMD(x) ((x) << S_LNK_CMD)
-#define G_LNK_CMD(x) (((x) >> S_LNK_CMD) & M_LNK_CMD)
-
-#define S_LNJ_STAT 12
-#define M_LNJ_STAT 0x7U
-#define V_LNJ_STAT(x) ((x) << S_LNJ_STAT)
-#define G_LNJ_STAT(x) (((x) >> S_LNJ_STAT) & M_LNJ_STAT)
-
-#define S_LNJ_CMD 8
-#define M_LNJ_CMD 0x7U
-#define V_LNJ_CMD(x) ((x) << S_LNJ_CMD)
-#define G_LNJ_CMD(x) (((x) >> S_LNJ_CMD) & M_LNJ_CMD)
-
-#define S_LNI_STAT 4
-#define M_LNI_STAT 0x7U
-#define V_LNI_STAT(x) ((x) << S_LNI_STAT)
-#define G_LNI_STAT(x) (((x) >> S_LNI_STAT) & M_LNI_STAT)
-
-#define S_LNI_CMD 0
-#define M_LNI_CMD 0x7U
-#define V_LNI_CMD(x) ((x) << S_LNI_CMD)
-#define G_LNI_CMD(x) (((x) >> S_LNI_CMD) & M_LNI_CMD)
-
-#define A_PCIE_PHY_GEN3_AE3 0x5c28
-
-#define S_LNP_STAT 28
-#define M_LNP_STAT 0x7U
-#define V_LNP_STAT(x) ((x) << S_LNP_STAT)
-#define G_LNP_STAT(x) (((x) >> S_LNP_STAT) & M_LNP_STAT)
-
-#define S_LNP_CMD 24
-#define M_LNP_CMD 0x7U
-#define V_LNP_CMD(x) ((x) << S_LNP_CMD)
-#define G_LNP_CMD(x) (((x) >> S_LNP_CMD) & M_LNP_CMD)
-
-#define S_LNO_STAT 20
-#define M_LNO_STAT 0x7U
-#define V_LNO_STAT(x) ((x) << S_LNO_STAT)
-#define G_LNO_STAT(x) (((x) >> S_LNO_STAT) & M_LNO_STAT)
-
-#define S_LNO_CMD 16
-#define M_LNO_CMD 0x7U
-#define V_LNO_CMD(x) ((x) << S_LNO_CMD)
-#define G_LNO_CMD(x) (((x) >> S_LNO_CMD) & M_LNO_CMD)
-
-#define S_LNN_STAT 12
-#define M_LNN_STAT 0x7U
-#define V_LNN_STAT(x) ((x) << S_LNN_STAT)
-#define G_LNN_STAT(x) (((x) >> S_LNN_STAT) & M_LNN_STAT)
-
-#define S_LNN_CMD 8
-#define M_LNN_CMD 0x7U
-#define V_LNN_CMD(x) ((x) << S_LNN_CMD)
-#define G_LNN_CMD(x) (((x) >> S_LNN_CMD) & M_LNN_CMD)
-
-#define S_LNM_STAT 4
-#define M_LNM_STAT 0x7U
-#define V_LNM_STAT(x) ((x) << S_LNM_STAT)
-#define G_LNM_STAT(x) (((x) >> S_LNM_STAT) & M_LNM_STAT)
-
-#define S_LNM_CMD 0
-#define M_LNM_CMD 0x7U
-#define V_LNM_CMD(x) ((x) << S_LNM_CMD)
-#define G_LNM_CMD(x) (((x) >> S_LNM_CMD) & M_LNM_CMD)
-
-#define A_PCIE_PHY_FS_LF4 0x5c2c
-
-#define S_LANE9LF 24
-#define M_LANE9LF 0x3fU
-#define V_LANE9LF(x) ((x) << S_LANE9LF)
-#define G_LANE9LF(x) (((x) >> S_LANE9LF) & M_LANE9LF)
-
-#define S_LANE9FS 16
-#define M_LANE9FS 0x3fU
-#define V_LANE9FS(x) ((x) << S_LANE9FS)
-#define G_LANE9FS(x) (((x) >> S_LANE9FS) & M_LANE9FS)
-
-#define S_LANE8LF 8
-#define M_LANE8LF 0x3fU
-#define V_LANE8LF(x) ((x) << S_LANE8LF)
-#define G_LANE8LF(x) (((x) >> S_LANE8LF) & M_LANE8LF)
-
-#define S_LANE8FS 0
-#define M_LANE8FS 0x3fU
-#define V_LANE8FS(x) ((x) << S_LANE8FS)
-#define G_LANE8FS(x) (((x) >> S_LANE8FS) & M_LANE8FS)
-
-#define A_PCIE_PHY_FS_LF5 0x5c30
-
-#define S_LANE11LF 24
-#define M_LANE11LF 0x3fU
-#define V_LANE11LF(x) ((x) << S_LANE11LF)
-#define G_LANE11LF(x) (((x) >> S_LANE11LF) & M_LANE11LF)
-
-#define S_LANE11FS 16
-#define M_LANE11FS 0x3fU
-#define V_LANE11FS(x) ((x) << S_LANE11FS)
-#define G_LANE11FS(x) (((x) >> S_LANE11FS) & M_LANE11FS)
-
-#define S_LANE10LF 8
-#define M_LANE10LF 0x3fU
-#define V_LANE10LF(x) ((x) << S_LANE10LF)
-#define G_LANE10LF(x) (((x) >> S_LANE10LF) & M_LANE10LF)
-
-#define S_LANE10FS 0
-#define M_LANE10FS 0x3fU
-#define V_LANE10FS(x) ((x) << S_LANE10FS)
-#define G_LANE10FS(x) (((x) >> S_LANE10FS) & M_LANE10FS)
-
-#define A_PCIE_PHY_FS_LF6 0x5c34
-
-#define S_LANE13LF 24
-#define M_LANE13LF 0x3fU
-#define V_LANE13LF(x) ((x) << S_LANE13LF)
-#define G_LANE13LF(x) (((x) >> S_LANE13LF) & M_LANE13LF)
-
-#define S_LANE13FS 16
-#define M_LANE13FS 0x3fU
-#define V_LANE13FS(x) ((x) << S_LANE13FS)
-#define G_LANE13FS(x) (((x) >> S_LANE13FS) & M_LANE13FS)
-
-#define S_LANE12LF 8
-#define M_LANE12LF 0x3fU
-#define V_LANE12LF(x) ((x) << S_LANE12LF)
-#define G_LANE12LF(x) (((x) >> S_LANE12LF) & M_LANE12LF)
-
-#define S_LANE12FS 0
-#define M_LANE12FS 0x3fU
-#define V_LANE12FS(x) ((x) << S_LANE12FS)
-#define G_LANE12FS(x) (((x) >> S_LANE12FS) & M_LANE12FS)
-
-#define A_PCIE_PHY_FS_LF7 0x5c38
-
-#define S_LANE15LF 24
-#define M_LANE15LF 0x3fU
-#define V_LANE15LF(x) ((x) << S_LANE15LF)
-#define G_LANE15LF(x) (((x) >> S_LANE15LF) & M_LANE15LF)
-
-#define S_LANE15FS 16
-#define M_LANE15FS 0x3fU
-#define V_LANE15FS(x) ((x) << S_LANE15FS)
-#define G_LANE15FS(x) (((x) >> S_LANE15FS) & M_LANE15FS)
-
-#define S_LANE14LF 8
-#define M_LANE14LF 0x3fU
-#define V_LANE14LF(x) ((x) << S_LANE14LF)
-#define G_LANE14LF(x) (((x) >> S_LANE14LF) & M_LANE14LF)
-
-#define S_LANE14FS 0
-#define M_LANE14FS 0x3fU
-#define V_LANE14FS(x) ((x) << S_LANE14FS)
-#define G_LANE14FS(x) (((x) >> S_LANE14FS) & M_LANE14FS)
-
-#define A_PCIE_MULTI_PHY_INDIR_REQ 0x5c3c
-
-#define S_PHY_REG_ENABLE 31
-#define V_PHY_REG_ENABLE(x) ((x) << S_PHY_REG_ENABLE)
-#define F_PHY_REG_ENABLE V_PHY_REG_ENABLE(1U)
-
-#define S_PHY_REG_SELECT 22
-#define M_PHY_REG_SELECT 0x3U
-#define V_PHY_REG_SELECT(x) ((x) << S_PHY_REG_SELECT)
-#define G_PHY_REG_SELECT(x) (((x) >> S_PHY_REG_SELECT) & M_PHY_REG_SELECT)
-
-#define S_PHY_REG_REGADDR 0
-#define M_PHY_REG_REGADDR 0xffffU
-#define V_PHY_REG_REGADDR(x) ((x) << S_PHY_REG_REGADDR)
-#define G_PHY_REG_REGADDR(x) (((x) >> S_PHY_REG_REGADDR) & M_PHY_REG_REGADDR)
-
-#define A_PCIE_MULTI_PHY_INDIR_DATA 0x5c40
-
-#define S_PHY_REG_DATA 0
-#define M_PHY_REG_DATA 0xffffU
-#define V_PHY_REG_DATA(x) ((x) << S_PHY_REG_DATA)
-#define G_PHY_REG_DATA(x) (((x) >> S_PHY_REG_DATA) & M_PHY_REG_DATA)
-
-#define A_PCIE_VF_INT_INDIR_REQ 0x5c44
-
-#define S_ENABLE_VF 24
-#define V_ENABLE_VF(x) ((x) << S_ENABLE_VF)
-#define F_ENABLE_VF V_ENABLE_VF(1U)
-
-#define S_AI_VF 23
-#define V_AI_VF(x) ((x) << S_AI_VF)
-#define F_AI_VF V_AI_VF(1U)
-
-#define S_VFID_PCIE 0
-#define M_VFID_PCIE 0x3ffU
-#define V_VFID_PCIE(x) ((x) << S_VFID_PCIE)
-#define G_VFID_PCIE(x) (((x) >> S_VFID_PCIE) & M_VFID_PCIE)
-
-#define A_PCIE_VF_INT_INDIR_DATA 0x5c48
-#define A_PCIE_VF_256_INT_CFG2 0x5c4c
-#define A_PCIE_VF_MSI_EN_4 0x5e50
-#define A_PCIE_VF_MSI_EN_5 0x5e54
-#define A_PCIE_VF_MSI_EN_6 0x5e58
-#define A_PCIE_VF_MSI_EN_7 0x5e5c
-#define A_PCIE_VF_MSIX_EN_4 0x5e60
-#define A_PCIE_VF_MSIX_EN_5 0x5e64
-#define A_PCIE_VF_MSIX_EN_6 0x5e68
-#define A_PCIE_VF_MSIX_EN_7 0x5e6c
-#define A_PCIE_FLR_VF4_STATUS 0x5e70
-#define A_PCIE_FLR_VF5_STATUS 0x5e74
-#define A_PCIE_FLR_VF6_STATUS 0x5e78
-#define A_PCIE_FLR_VF7_STATUS 0x5e7c
-#define A_T6_PCIE_BUS_MST_STAT_4 0x5e80
-#define A_T6_PCIE_BUS_MST_STAT_5 0x5e84
-#define A_T6_PCIE_BUS_MST_STAT_6 0x5e88
-#define A_T6_PCIE_BUS_MST_STAT_7 0x5e8c
-#define A_PCIE_BUS_MST_STAT_8 0x5e90
-
-#define S_BUSMST_263_256 0
-#define M_BUSMST_263_256 0xffU
-#define V_BUSMST_263_256(x) ((x) << S_BUSMST_263_256)
-#define G_BUSMST_263_256(x) (((x) >> S_BUSMST_263_256) & M_BUSMST_263_256)
-
-#define A_PCIE_TGT_SKID_FIFO 0x5e94
-
-#define S_HDRFREECNT 16
-#define M_HDRFREECNT 0xfffU
-#define V_HDRFREECNT(x) ((x) << S_HDRFREECNT)
-#define G_HDRFREECNT(x) (((x) >> S_HDRFREECNT) & M_HDRFREECNT)
-
-#define S_DATAFREECNT 0
-#define M_DATAFREECNT 0xfffU
-#define V_DATAFREECNT(x) ((x) << S_DATAFREECNT)
-#define G_DATAFREECNT(x) (((x) >> S_DATAFREECNT) & M_DATAFREECNT)
-
-#define A_T6_PCIE_RSP_ERR_STAT_4 0x5ea0
-#define A_T6_PCIE_RSP_ERR_STAT_5 0x5ea4
-#define A_T6_PCIE_RSP_ERR_STAT_6 0x5ea8
-#define A_T6_PCIE_RSP_ERR_STAT_7 0x5eac
-#define A_PCIE_RSP_ERR_STAT_8 0x5eb0
-
-#define S_RSPERR_263_256 0
-#define M_RSPERR_263_256 0xffU
-#define V_RSPERR_263_256(x) ((x) << S_RSPERR_263_256)
-#define G_RSPERR_263_256(x) (((x) >> S_RSPERR_263_256) & M_RSPERR_263_256)
-
-#define A_PCIE_PHY_STAT1 0x5ec0
-
-#define S_PHY0_RTUNE_ACK 31
-#define V_PHY0_RTUNE_ACK(x) ((x) << S_PHY0_RTUNE_ACK)
-#define F_PHY0_RTUNE_ACK V_PHY0_RTUNE_ACK(1U)
-
-#define S_PHY1_RTUNE_ACK 30
-#define V_PHY1_RTUNE_ACK(x) ((x) << S_PHY1_RTUNE_ACK)
-#define F_PHY1_RTUNE_ACK V_PHY1_RTUNE_ACK(1U)
-
-#define A_PCIE_PHY_CTRL1 0x5ec4
-
-#define S_PHY0_RTUNE_REQ 31
-#define V_PHY0_RTUNE_REQ(x) ((x) << S_PHY0_RTUNE_REQ)
-#define F_PHY0_RTUNE_REQ V_PHY0_RTUNE_REQ(1U)
-
-#define S_PHY1_RTUNE_REQ 30
-#define V_PHY1_RTUNE_REQ(x) ((x) << S_PHY1_RTUNE_REQ)
-#define F_PHY1_RTUNE_REQ V_PHY1_RTUNE_REQ(1U)
-
-#define S_TXDEEMPH_GEN1 16
-#define M_TXDEEMPH_GEN1 0xffU
-#define V_TXDEEMPH_GEN1(x) ((x) << S_TXDEEMPH_GEN1)
-#define G_TXDEEMPH_GEN1(x) (((x) >> S_TXDEEMPH_GEN1) & M_TXDEEMPH_GEN1)
-
-#define S_TXDEEMPH_GEN2_3P5DB 8
-#define M_TXDEEMPH_GEN2_3P5DB 0xffU
-#define V_TXDEEMPH_GEN2_3P5DB(x) ((x) << S_TXDEEMPH_GEN2_3P5DB)
-#define G_TXDEEMPH_GEN2_3P5DB(x) (((x) >> S_TXDEEMPH_GEN2_3P5DB) & M_TXDEEMPH_GEN2_3P5DB)
-
-#define S_TXDEEMPH_GEN2_6DB 0
-#define M_TXDEEMPH_GEN2_6DB 0xffU
-#define V_TXDEEMPH_GEN2_6DB(x) ((x) << S_TXDEEMPH_GEN2_6DB)
-#define G_TXDEEMPH_GEN2_6DB(x) (((x) >> S_TXDEEMPH_GEN2_6DB) & M_TXDEEMPH_GEN2_6DB)
-
-#define A_PCIE_PCIE_SPARE0 0x5ec8
-#define A_PCIE_RESET_STAT 0x5ecc
-
-#define S_PON_RST_STATE_FLAG 11
-#define V_PON_RST_STATE_FLAG(x) ((x) << S_PON_RST_STATE_FLAG)
-#define F_PON_RST_STATE_FLAG V_PON_RST_STATE_FLAG(1U)
-
-#define S_BUS_RST_STATE_FLAG 10
-#define V_BUS_RST_STATE_FLAG(x) ((x) << S_BUS_RST_STATE_FLAG)
-#define F_BUS_RST_STATE_FLAG V_BUS_RST_STATE_FLAG(1U)
-
-#define S_DL_DOWN_PCIECRST_MODE0_STATE_FLAG 9
-#define V_DL_DOWN_PCIECRST_MODE0_STATE_FLAG(x) ((x) << S_DL_DOWN_PCIECRST_MODE0_STATE_FLAG)
-#define F_DL_DOWN_PCIECRST_MODE0_STATE_FLAG V_DL_DOWN_PCIECRST_MODE0_STATE_FLAG(1U)
-
-#define S_DL_DOWN_PCIECRST_MODE1_STATE_FLAG 8
-#define V_DL_DOWN_PCIECRST_MODE1_STATE_FLAG(x) ((x) << S_DL_DOWN_PCIECRST_MODE1_STATE_FLAG)
-#define F_DL_DOWN_PCIECRST_MODE1_STATE_FLAG V_DL_DOWN_PCIECRST_MODE1_STATE_FLAG(1U)
-
-#define S_PCIE_WARM_RST_MODE0_STATE_FLAG 7
-#define V_PCIE_WARM_RST_MODE0_STATE_FLAG(x) ((x) << S_PCIE_WARM_RST_MODE0_STATE_FLAG)
-#define F_PCIE_WARM_RST_MODE0_STATE_FLAG V_PCIE_WARM_RST_MODE0_STATE_FLAG(1U)
-
-#define S_PCIE_WARM_RST_MODE1_STATE_FLAG 6
-#define V_PCIE_WARM_RST_MODE1_STATE_FLAG(x) ((x) << S_PCIE_WARM_RST_MODE1_STATE_FLAG)
-#define F_PCIE_WARM_RST_MODE1_STATE_FLAG V_PCIE_WARM_RST_MODE1_STATE_FLAG(1U)
-
-#define S_PIO_WARM_RST_MODE0_STATE_FLAG 5
-#define V_PIO_WARM_RST_MODE0_STATE_FLAG(x) ((x) << S_PIO_WARM_RST_MODE0_STATE_FLAG)
-#define F_PIO_WARM_RST_MODE0_STATE_FLAG V_PIO_WARM_RST_MODE0_STATE_FLAG(1U)
-
-#define S_PIO_WARM_RST_MODE1_STATE_FLAG 4
-#define V_PIO_WARM_RST_MODE1_STATE_FLAG(x) ((x) << S_PIO_WARM_RST_MODE1_STATE_FLAG)
-#define F_PIO_WARM_RST_MODE1_STATE_FLAG V_PIO_WARM_RST_MODE1_STATE_FLAG(1U)
-
-#define S_LASTRESETSTATE 0
-#define M_LASTRESETSTATE 0x7U
-#define V_LASTRESETSTATE(x) ((x) << S_LASTRESETSTATE)
-#define G_LASTRESETSTATE(x) (((x) >> S_LASTRESETSTATE) & M_LASTRESETSTATE)
-
-#define A_PCIE_FUNC_DSTATE 0x5ed0
-
-#define S_PF7_DSTATE 21
-#define M_PF7_DSTATE 0x7U
-#define V_PF7_DSTATE(x) ((x) << S_PF7_DSTATE)
-#define G_PF7_DSTATE(x) (((x) >> S_PF7_DSTATE) & M_PF7_DSTATE)
-
-#define S_PF6_DSTATE 18
-#define M_PF6_DSTATE 0x7U
-#define V_PF6_DSTATE(x) ((x) << S_PF6_DSTATE)
-#define G_PF6_DSTATE(x) (((x) >> S_PF6_DSTATE) & M_PF6_DSTATE)
-
-#define S_PF5_DSTATE 15
-#define M_PF5_DSTATE 0x7U
-#define V_PF5_DSTATE(x) ((x) << S_PF5_DSTATE)
-#define G_PF5_DSTATE(x) (((x) >> S_PF5_DSTATE) & M_PF5_DSTATE)
-
-#define S_PF4_DSTATE 12
-#define M_PF4_DSTATE 0x7U
-#define V_PF4_DSTATE(x) ((x) << S_PF4_DSTATE)
-#define G_PF4_DSTATE(x) (((x) >> S_PF4_DSTATE) & M_PF4_DSTATE)
-
-#define S_PF3_DSTATE 9
-#define M_PF3_DSTATE 0x7U
-#define V_PF3_DSTATE(x) ((x) << S_PF3_DSTATE)
-#define G_PF3_DSTATE(x) (((x) >> S_PF3_DSTATE) & M_PF3_DSTATE)
-
-#define S_PF2_DSTATE 6
-#define M_PF2_DSTATE 0x7U
-#define V_PF2_DSTATE(x) ((x) << S_PF2_DSTATE)
-#define G_PF2_DSTATE(x) (((x) >> S_PF2_DSTATE) & M_PF2_DSTATE)
-
-#define S_PF1_DSTATE 3
-#define M_PF1_DSTATE 0x7U
-#define V_PF1_DSTATE(x) ((x) << S_PF1_DSTATE)
-#define G_PF1_DSTATE(x) (((x) >> S_PF1_DSTATE) & M_PF1_DSTATE)
-
-#define S_PF0_DSTATE 0
-#define M_PF0_DSTATE 0x7U
-#define V_PF0_DSTATE(x) ((x) << S_PF0_DSTATE)
-#define G_PF0_DSTATE(x) (((x) >> S_PF0_DSTATE) & M_PF0_DSTATE)
-
-#define A_PCIE_DEBUG_ADDR_RANGE1 0x5ee0
-#define A_PCIE_DEBUG_ADDR_RANGE2 0x5ef0
-#define A_PCIE_DEBUG_ADDR_RANGE_CNT 0x5f00
-#define A_PCIE_PDEBUG_REG_0X0 0x0
-#define A_PCIE_PDEBUG_REG_0X1 0x1
-#define A_PCIE_PDEBUG_REG_0X2 0x2
-
-#define S_TAGQ_CH0_TAGS_USED 11
-#define M_TAGQ_CH0_TAGS_USED 0xffU
-#define V_TAGQ_CH0_TAGS_USED(x) ((x) << S_TAGQ_CH0_TAGS_USED)
-#define G_TAGQ_CH0_TAGS_USED(x) (((x) >> S_TAGQ_CH0_TAGS_USED) & M_TAGQ_CH0_TAGS_USED)
-
-#define S_REQ_CH0_DATA_EMPTY 10
-#define V_REQ_CH0_DATA_EMPTY(x) ((x) << S_REQ_CH0_DATA_EMPTY)
-#define F_REQ_CH0_DATA_EMPTY V_REQ_CH0_DATA_EMPTY(1U)
-
-#define S_RDQ_CH0_REQ_EMPTY 9
-#define V_RDQ_CH0_REQ_EMPTY(x) ((x) << S_RDQ_CH0_REQ_EMPTY)
-#define F_RDQ_CH0_REQ_EMPTY V_RDQ_CH0_REQ_EMPTY(1U)
-
-#define S_REQ_CTL_RD_CH0_WAIT_FOR_TAGTQ 8
-#define V_REQ_CTL_RD_CH0_WAIT_FOR_TAGTQ(x) ((x) << S_REQ_CTL_RD_CH0_WAIT_FOR_TAGTQ)
-#define F_REQ_CTL_RD_CH0_WAIT_FOR_TAGTQ V_REQ_CTL_RD_CH0_WAIT_FOR_TAGTQ(1U)
-
-#define S_REQ_CTL_RD_CH0_WAIT_FOR_CMD 7
-#define V_REQ_CTL_RD_CH0_WAIT_FOR_CMD(x) ((x) << S_REQ_CTL_RD_CH0_WAIT_FOR_CMD)
-#define F_REQ_CTL_RD_CH0_WAIT_FOR_CMD V_REQ_CTL_RD_CH0_WAIT_FOR_CMD(1U)
-
-#define S_REQ_CTL_RD_CH0_WAIT_FOR_DATA_MEM 6
-#define V_REQ_CTL_RD_CH0_WAIT_FOR_DATA_MEM(x) ((x) << S_REQ_CTL_RD_CH0_WAIT_FOR_DATA_MEM)
-#define F_REQ_CTL_RD_CH0_WAIT_FOR_DATA_MEM V_REQ_CTL_RD_CH0_WAIT_FOR_DATA_MEM(1U)
-
-#define S_REQ_CTL_RD_CH0_WAIT_FOR_RDQ 5
-#define V_REQ_CTL_RD_CH0_WAIT_FOR_RDQ(x) ((x) << S_REQ_CTL_RD_CH0_WAIT_FOR_RDQ)
-#define F_REQ_CTL_RD_CH0_WAIT_FOR_RDQ V_REQ_CTL_RD_CH0_WAIT_FOR_RDQ(1U)
-
-#define S_REQ_CTL_RD_CH0_WAIT_FOR_TXN_DISABLE_FIFO 4
-#define V_REQ_CTL_RD_CH0_WAIT_FOR_TXN_DISABLE_FIFO(x) ((x) << S_REQ_CTL_RD_CH0_WAIT_FOR_TXN_DISABLE_FIFO)
-#define F_REQ_CTL_RD_CH0_WAIT_FOR_TXN_DISABLE_FIFO V_REQ_CTL_RD_CH0_WAIT_FOR_TXN_DISABLE_FIFO(1U)
-
-#define S_REQ_CTL_RD_CH0_EXIT_BOT_VLD_STARTED 3
-#define V_REQ_CTL_RD_CH0_EXIT_BOT_VLD_STARTED(x) ((x) << S_REQ_CTL_RD_CH0_EXIT_BOT_VLD_STARTED)
-#define F_REQ_CTL_RD_CH0_EXIT_BOT_VLD_STARTED V_REQ_CTL_RD_CH0_EXIT_BOT_VLD_STARTED(1U)
-
-#define S_REQ_CTL_RD_CH0_EXIT_TOP_VLD_STARTED 2
-#define V_REQ_CTL_RD_CH0_EXIT_TOP_VLD_STARTED(x) ((x) << S_REQ_CTL_RD_CH0_EXIT_TOP_VLD_STARTED)
-#define F_REQ_CTL_RD_CH0_EXIT_TOP_VLD_STARTED V_REQ_CTL_RD_CH0_EXIT_TOP_VLD_STARTED(1U)
-
-#define S_REQ_CTL_RD_CH0_WAIT_FOR_PAUSE 1
-#define V_REQ_CTL_RD_CH0_WAIT_FOR_PAUSE(x) ((x) << S_REQ_CTL_RD_CH0_WAIT_FOR_PAUSE)
-#define F_REQ_CTL_RD_CH0_WAIT_FOR_PAUSE V_REQ_CTL_RD_CH0_WAIT_FOR_PAUSE(1U)
-
-#define S_REQ_CTL_RD_CH0_WAIT_FOR_FIFO_DATA 0
-#define V_REQ_CTL_RD_CH0_WAIT_FOR_FIFO_DATA(x) ((x) << S_REQ_CTL_RD_CH0_WAIT_FOR_FIFO_DATA)
-#define F_REQ_CTL_RD_CH0_WAIT_FOR_FIFO_DATA V_REQ_CTL_RD_CH0_WAIT_FOR_FIFO_DATA(1U)
-
-#define A_PCIE_PDEBUG_REG_0X3 0x3
-
-#define S_TAGQ_CH1_TAGS_USED 11
-#define M_TAGQ_CH1_TAGS_USED 0xffU
-#define V_TAGQ_CH1_TAGS_USED(x) ((x) << S_TAGQ_CH1_TAGS_USED)
-#define G_TAGQ_CH1_TAGS_USED(x) (((x) >> S_TAGQ_CH1_TAGS_USED) & M_TAGQ_CH1_TAGS_USED)
-
-#define S_REQ_CH1_DATA_EMPTY 10
-#define V_REQ_CH1_DATA_EMPTY(x) ((x) << S_REQ_CH1_DATA_EMPTY)
-#define F_REQ_CH1_DATA_EMPTY V_REQ_CH1_DATA_EMPTY(1U)
-
-#define S_RDQ_CH1_REQ_EMPTY 9
-#define V_RDQ_CH1_REQ_EMPTY(x) ((x) << S_RDQ_CH1_REQ_EMPTY)
-#define F_RDQ_CH1_REQ_EMPTY V_RDQ_CH1_REQ_EMPTY(1U)
-
-#define S_REQ_CTL_RD_CH1_WAIT_FOR_TAGTQ 8
-#define V_REQ_CTL_RD_CH1_WAIT_FOR_TAGTQ(x) ((x) << S_REQ_CTL_RD_CH1_WAIT_FOR_TAGTQ)
-#define F_REQ_CTL_RD_CH1_WAIT_FOR_TAGTQ V_REQ_CTL_RD_CH1_WAIT_FOR_TAGTQ(1U)
-
-#define S_REQ_CTL_RD_CH1_WAIT_FOR_CMD 7
-#define V_REQ_CTL_RD_CH1_WAIT_FOR_CMD(x) ((x) << S_REQ_CTL_RD_CH1_WAIT_FOR_CMD)
-#define F_REQ_CTL_RD_CH1_WAIT_FOR_CMD V_REQ_CTL_RD_CH1_WAIT_FOR_CMD(1U)
-
-#define S_REQ_CTL_RD_CH1_WAIT_FOR_DATA_MEM 6
-#define V_REQ_CTL_RD_CH1_WAIT_FOR_DATA_MEM(x) ((x) << S_REQ_CTL_RD_CH1_WAIT_FOR_DATA_MEM)
-#define F_REQ_CTL_RD_CH1_WAIT_FOR_DATA_MEM V_REQ_CTL_RD_CH1_WAIT_FOR_DATA_MEM(1U)
-
-#define S_REQ_CTL_RD_CH1_WAIT_FOR_RDQ 5
-#define V_REQ_CTL_RD_CH1_WAIT_FOR_RDQ(x) ((x) << S_REQ_CTL_RD_CH1_WAIT_FOR_RDQ)
-#define F_REQ_CTL_RD_CH1_WAIT_FOR_RDQ V_REQ_CTL_RD_CH1_WAIT_FOR_RDQ(1U)
-
-#define S_REQ_CTL_RD_CH1_WAIT_FOR_TXN_DISABLE_FIFO 4
-#define V_REQ_CTL_RD_CH1_WAIT_FOR_TXN_DISABLE_FIFO(x) ((x) << S_REQ_CTL_RD_CH1_WAIT_FOR_TXN_DISABLE_FIFO)
-#define F_REQ_CTL_RD_CH1_WAIT_FOR_TXN_DISABLE_FIFO V_REQ_CTL_RD_CH1_WAIT_FOR_TXN_DISABLE_FIFO(1U)
-
-#define S_REQ_CTL_RD_CH1_EXIT_BOT_VLD_STARTED 3
-#define V_REQ_CTL_RD_CH1_EXIT_BOT_VLD_STARTED(x) ((x) << S_REQ_CTL_RD_CH1_EXIT_BOT_VLD_STARTED)
-#define F_REQ_CTL_RD_CH1_EXIT_BOT_VLD_STARTED V_REQ_CTL_RD_CH1_EXIT_BOT_VLD_STARTED(1U)
-
-#define S_REQ_CTL_RD_CH1_EXIT_TOP_VLD_STARTED 2
-#define V_REQ_CTL_RD_CH1_EXIT_TOP_VLD_STARTED(x) ((x) << S_REQ_CTL_RD_CH1_EXIT_TOP_VLD_STARTED)
-#define F_REQ_CTL_RD_CH1_EXIT_TOP_VLD_STARTED V_REQ_CTL_RD_CH1_EXIT_TOP_VLD_STARTED(1U)
-
-#define S_REQ_CTL_RD_CH1_WAIT_FOR_PAUSE 1
-#define V_REQ_CTL_RD_CH1_WAIT_FOR_PAUSE(x) ((x) << S_REQ_CTL_RD_CH1_WAIT_FOR_PAUSE)
-#define F_REQ_CTL_RD_CH1_WAIT_FOR_PAUSE V_REQ_CTL_RD_CH1_WAIT_FOR_PAUSE(1U)
-
-#define S_REQ_CTL_RD_CH1_WAIT_FOR_FIFO_DATA 0
-#define V_REQ_CTL_RD_CH1_WAIT_FOR_FIFO_DATA(x) ((x) << S_REQ_CTL_RD_CH1_WAIT_FOR_FIFO_DATA)
-#define F_REQ_CTL_RD_CH1_WAIT_FOR_FIFO_DATA V_REQ_CTL_RD_CH1_WAIT_FOR_FIFO_DATA(1U)
-
-#define A_PCIE_PDEBUG_REG_0X4 0x4
-
-#define S_TAGQ_CH2_TAGS_USED 11
-#define M_TAGQ_CH2_TAGS_USED 0xffU
-#define V_TAGQ_CH2_TAGS_USED(x) ((x) << S_TAGQ_CH2_TAGS_USED)
-#define G_TAGQ_CH2_TAGS_USED(x) (((x) >> S_TAGQ_CH2_TAGS_USED) & M_TAGQ_CH2_TAGS_USED)
-
-#define S_REQ_CH2_DATA_EMPTY 10
-#define V_REQ_CH2_DATA_EMPTY(x) ((x) << S_REQ_CH2_DATA_EMPTY)
-#define F_REQ_CH2_DATA_EMPTY V_REQ_CH2_DATA_EMPTY(1U)
-
-#define S_RDQ_CH2_REQ_EMPTY 9
-#define V_RDQ_CH2_REQ_EMPTY(x) ((x) << S_RDQ_CH2_REQ_EMPTY)
-#define F_RDQ_CH2_REQ_EMPTY V_RDQ_CH2_REQ_EMPTY(1U)
-
-#define S_REQ_CTL_RD_CH2_WAIT_FOR_TAGTQ 8
-#define V_REQ_CTL_RD_CH2_WAIT_FOR_TAGTQ(x) ((x) << S_REQ_CTL_RD_CH2_WAIT_FOR_TAGTQ)
-#define F_REQ_CTL_RD_CH2_WAIT_FOR_TAGTQ V_REQ_CTL_RD_CH2_WAIT_FOR_TAGTQ(1U)
-
-#define S_REQ_CTL_RD_CH2_WAIT_FOR_CMD 7
-#define V_REQ_CTL_RD_CH2_WAIT_FOR_CMD(x) ((x) << S_REQ_CTL_RD_CH2_WAIT_FOR_CMD)
-#define F_REQ_CTL_RD_CH2_WAIT_FOR_CMD V_REQ_CTL_RD_CH2_WAIT_FOR_CMD(1U)
-
-#define S_REQ_CTL_RD_CH2_WAIT_FOR_DATA_MEM 6
-#define V_REQ_CTL_RD_CH2_WAIT_FOR_DATA_MEM(x) ((x) << S_REQ_CTL_RD_CH2_WAIT_FOR_DATA_MEM)
-#define F_REQ_CTL_RD_CH2_WAIT_FOR_DATA_MEM V_REQ_CTL_RD_CH2_WAIT_FOR_DATA_MEM(1U)
-
-#define S_REQ_CTL_RD_CH2_WAIT_FOR_RDQ 5
-#define V_REQ_CTL_RD_CH2_WAIT_FOR_RDQ(x) ((x) << S_REQ_CTL_RD_CH2_WAIT_FOR_RDQ)
-#define F_REQ_CTL_RD_CH2_WAIT_FOR_RDQ V_REQ_CTL_RD_CH2_WAIT_FOR_RDQ(1U)
-
-#define S_REQ_CTL_RD_CH2_WAIT_FOR_TXN_DISABLE_FIFO 4
-#define V_REQ_CTL_RD_CH2_WAIT_FOR_TXN_DISABLE_FIFO(x) ((x) << S_REQ_CTL_RD_CH2_WAIT_FOR_TXN_DISABLE_FIFO)
-#define F_REQ_CTL_RD_CH2_WAIT_FOR_TXN_DISABLE_FIFO V_REQ_CTL_RD_CH2_WAIT_FOR_TXN_DISABLE_FIFO(1U)
-
-#define S_REQ_CTL_RD_CH2_EXIT_BOT_VLD_STARTED 3
-#define V_REQ_CTL_RD_CH2_EXIT_BOT_VLD_STARTED(x) ((x) << S_REQ_CTL_RD_CH2_EXIT_BOT_VLD_STARTED)
-#define F_REQ_CTL_RD_CH2_EXIT_BOT_VLD_STARTED V_REQ_CTL_RD_CH2_EXIT_BOT_VLD_STARTED(1U)
-
-#define S_REQ_CTL_RD_CH2_EXIT_TOP_VLD_STARTED 2
-#define V_REQ_CTL_RD_CH2_EXIT_TOP_VLD_STARTED(x) ((x) << S_REQ_CTL_RD_CH2_EXIT_TOP_VLD_STARTED)
-#define F_REQ_CTL_RD_CH2_EXIT_TOP_VLD_STARTED V_REQ_CTL_RD_CH2_EXIT_TOP_VLD_STARTED(1U)
-
-#define S_REQ_CTL_RD_CH2_WAIT_FOR_PAUSE 1
-#define V_REQ_CTL_RD_CH2_WAIT_FOR_PAUSE(x) ((x) << S_REQ_CTL_RD_CH2_WAIT_FOR_PAUSE)
-#define F_REQ_CTL_RD_CH2_WAIT_FOR_PAUSE V_REQ_CTL_RD_CH2_WAIT_FOR_PAUSE(1U)
-
-#define S_REQ_CTL_RD_CH2_WAIT_FOR_FIFO_DATA 0
-#define V_REQ_CTL_RD_CH2_WAIT_FOR_FIFO_DATA(x) ((x) << S_REQ_CTL_RD_CH2_WAIT_FOR_FIFO_DATA)
-#define F_REQ_CTL_RD_CH2_WAIT_FOR_FIFO_DATA V_REQ_CTL_RD_CH2_WAIT_FOR_FIFO_DATA(1U)
-
-#define A_PCIE_PDEBUG_REG_0X5 0x5
-
-#define S_TAGQ_CH3_TAGS_USED 11
-#define M_TAGQ_CH3_TAGS_USED 0xffU
-#define V_TAGQ_CH3_TAGS_USED(x) ((x) << S_TAGQ_CH3_TAGS_USED)
-#define G_TAGQ_CH3_TAGS_USED(x) (((x) >> S_TAGQ_CH3_TAGS_USED) & M_TAGQ_CH3_TAGS_USED)
-
-#define S_REQ_CH3_DATA_EMPTY 10
-#define V_REQ_CH3_DATA_EMPTY(x) ((x) << S_REQ_CH3_DATA_EMPTY)
-#define F_REQ_CH3_DATA_EMPTY V_REQ_CH3_DATA_EMPTY(1U)
-
-#define S_RDQ_CH3_REQ_EMPTY 9
-#define V_RDQ_CH3_REQ_EMPTY(x) ((x) << S_RDQ_CH3_REQ_EMPTY)
-#define F_RDQ_CH3_REQ_EMPTY V_RDQ_CH3_REQ_EMPTY(1U)
-
-#define S_REQ_CTL_RD_CH3_WAIT_FOR_TAGTQ 8
-#define V_REQ_CTL_RD_CH3_WAIT_FOR_TAGTQ(x) ((x) << S_REQ_CTL_RD_CH3_WAIT_FOR_TAGTQ)
-#define F_REQ_CTL_RD_CH3_WAIT_FOR_TAGTQ V_REQ_CTL_RD_CH3_WAIT_FOR_TAGTQ(1U)
-
-#define S_REQ_CTL_RD_CH3_WAIT_FOR_CMD 7
-#define V_REQ_CTL_RD_CH3_WAIT_FOR_CMD(x) ((x) << S_REQ_CTL_RD_CH3_WAIT_FOR_CMD)
-#define F_REQ_CTL_RD_CH3_WAIT_FOR_CMD V_REQ_CTL_RD_CH3_WAIT_FOR_CMD(1U)
-
-#define S_REQ_CTL_RD_CH3_WAIT_FOR_DATA_MEM 6
-#define V_REQ_CTL_RD_CH3_WAIT_FOR_DATA_MEM(x) ((x) << S_REQ_CTL_RD_CH3_WAIT_FOR_DATA_MEM)
-#define F_REQ_CTL_RD_CH3_WAIT_FOR_DATA_MEM V_REQ_CTL_RD_CH3_WAIT_FOR_DATA_MEM(1U)
-
-#define S_REQ_CTL_RD_CH3_WAIT_FOR_RDQ 5
-#define V_REQ_CTL_RD_CH3_WAIT_FOR_RDQ(x) ((x) << S_REQ_CTL_RD_CH3_WAIT_FOR_RDQ)
-#define F_REQ_CTL_RD_CH3_WAIT_FOR_RDQ V_REQ_CTL_RD_CH3_WAIT_FOR_RDQ(1U)
-
-#define S_REQ_CTL_RD_CH3_WAIT_FOR_TXN_DISABLE_FIFO 4
-#define V_REQ_CTL_RD_CH3_WAIT_FOR_TXN_DISABLE_FIFO(x) ((x) << S_REQ_CTL_RD_CH3_WAIT_FOR_TXN_DISABLE_FIFO)
-#define F_REQ_CTL_RD_CH3_WAIT_FOR_TXN_DISABLE_FIFO V_REQ_CTL_RD_CH3_WAIT_FOR_TXN_DISABLE_FIFO(1U)
-
-#define S_REQ_CTL_RD_CH3_EXIT_BOT_VLD_STARTED 3
-#define V_REQ_CTL_RD_CH3_EXIT_BOT_VLD_STARTED(x) ((x) << S_REQ_CTL_RD_CH3_EXIT_BOT_VLD_STARTED)
-#define F_REQ_CTL_RD_CH3_EXIT_BOT_VLD_STARTED V_REQ_CTL_RD_CH3_EXIT_BOT_VLD_STARTED(1U)
-
-#define S_REQ_CTL_RD_CH3_EXIT_TOP_VLD_STARTED 2
-#define V_REQ_CTL_RD_CH3_EXIT_TOP_VLD_STARTED(x) ((x) << S_REQ_CTL_RD_CH3_EXIT_TOP_VLD_STARTED)
-#define F_REQ_CTL_RD_CH3_EXIT_TOP_VLD_STARTED V_REQ_CTL_RD_CH3_EXIT_TOP_VLD_STARTED(1U)
-
-#define S_REQ_CTL_RD_CH3_WAIT_FOR_PAUSE 1
-#define V_REQ_CTL_RD_CH3_WAIT_FOR_PAUSE(x) ((x) << S_REQ_CTL_RD_CH3_WAIT_FOR_PAUSE)
-#define F_REQ_CTL_RD_CH3_WAIT_FOR_PAUSE V_REQ_CTL_RD_CH3_WAIT_FOR_PAUSE(1U)
-
-#define S_REQ_CTL_RD_CH3_WAIT_FOR_FIFO_DATA 0
-#define V_REQ_CTL_RD_CH3_WAIT_FOR_FIFO_DATA(x) ((x) << S_REQ_CTL_RD_CH3_WAIT_FOR_FIFO_DATA)
-#define F_REQ_CTL_RD_CH3_WAIT_FOR_FIFO_DATA V_REQ_CTL_RD_CH3_WAIT_FOR_FIFO_DATA(1U)
-
-#define A_PCIE_PDEBUG_REG_0X6 0x6
-
-#define S_TAGQ_CH4_TAGS_USED 11
-#define M_TAGQ_CH4_TAGS_USED 0xffU
-#define V_TAGQ_CH4_TAGS_USED(x) ((x) << S_TAGQ_CH4_TAGS_USED)
-#define G_TAGQ_CH4_TAGS_USED(x) (((x) >> S_TAGQ_CH4_TAGS_USED) & M_TAGQ_CH4_TAGS_USED)
-
-#define S_REQ_CH4_DATA_EMPTY 10
-#define V_REQ_CH4_DATA_EMPTY(x) ((x) << S_REQ_CH4_DATA_EMPTY)
-#define F_REQ_CH4_DATA_EMPTY V_REQ_CH4_DATA_EMPTY(1U)
-
-#define S_RDQ_CH4_REQ_EMPTY 9
-#define V_RDQ_CH4_REQ_EMPTY(x) ((x) << S_RDQ_CH4_REQ_EMPTY)
-#define F_RDQ_CH4_REQ_EMPTY V_RDQ_CH4_REQ_EMPTY(1U)
-
-#define S_REQ_CTL_RD_CH4_WAIT_FOR_TAGTQ 8
-#define V_REQ_CTL_RD_CH4_WAIT_FOR_TAGTQ(x) ((x) << S_REQ_CTL_RD_CH4_WAIT_FOR_TAGTQ)
-#define F_REQ_CTL_RD_CH4_WAIT_FOR_TAGTQ V_REQ_CTL_RD_CH4_WAIT_FOR_TAGTQ(1U)
-
-#define S_REQ_CTL_RD_CH4_WAIT_FOR_CMD 7
-#define V_REQ_CTL_RD_CH4_WAIT_FOR_CMD(x) ((x) << S_REQ_CTL_RD_CH4_WAIT_FOR_CMD)
-#define F_REQ_CTL_RD_CH4_WAIT_FOR_CMD V_REQ_CTL_RD_CH4_WAIT_FOR_CMD(1U)
-
-#define S_REQ_CTL_RD_CH4_WAIT_FOR_DATA_MEM 6
-#define V_REQ_CTL_RD_CH4_WAIT_FOR_DATA_MEM(x) ((x) << S_REQ_CTL_RD_CH4_WAIT_FOR_DATA_MEM)
-#define F_REQ_CTL_RD_CH4_WAIT_FOR_DATA_MEM V_REQ_CTL_RD_CH4_WAIT_FOR_DATA_MEM(1U)
-
-#define S_REQ_CTL_RD_CH4_WAIT_FOR_RDQ 5
-#define V_REQ_CTL_RD_CH4_WAIT_FOR_RDQ(x) ((x) << S_REQ_CTL_RD_CH4_WAIT_FOR_RDQ)
-#define F_REQ_CTL_RD_CH4_WAIT_FOR_RDQ V_REQ_CTL_RD_CH4_WAIT_FOR_RDQ(1U)
-
-#define S_REQ_CTL_RD_CH4_WAIT_FOR_TXN_DISABLE_FIFO 4
-#define V_REQ_CTL_RD_CH4_WAIT_FOR_TXN_DISABLE_FIFO(x) ((x) << S_REQ_CTL_RD_CH4_WAIT_FOR_TXN_DISABLE_FIFO)
-#define F_REQ_CTL_RD_CH4_WAIT_FOR_TXN_DISABLE_FIFO V_REQ_CTL_RD_CH4_WAIT_FOR_TXN_DISABLE_FIFO(1U)
-
-#define S_REQ_CTL_RD_CH4_EXIT_BOT_VLD_STARTED 3
-#define V_REQ_CTL_RD_CH4_EXIT_BOT_VLD_STARTED(x) ((x) << S_REQ_CTL_RD_CH4_EXIT_BOT_VLD_STARTED)
-#define F_REQ_CTL_RD_CH4_EXIT_BOT_VLD_STARTED V_REQ_CTL_RD_CH4_EXIT_BOT_VLD_STARTED(1U)
-
-#define S_REQ_CTL_RD_CH4_EXIT_TOP_VLD_STARTED 2
-#define V_REQ_CTL_RD_CH4_EXIT_TOP_VLD_STARTED(x) ((x) << S_REQ_CTL_RD_CH4_EXIT_TOP_VLD_STARTED)
-#define F_REQ_CTL_RD_CH4_EXIT_TOP_VLD_STARTED V_REQ_CTL_RD_CH4_EXIT_TOP_VLD_STARTED(1U)
-
-#define S_REQ_CTL_RD_CH4_WAIT_FOR_PAUSE 1
-#define V_REQ_CTL_RD_CH4_WAIT_FOR_PAUSE(x) ((x) << S_REQ_CTL_RD_CH4_WAIT_FOR_PAUSE)
-#define F_REQ_CTL_RD_CH4_WAIT_FOR_PAUSE V_REQ_CTL_RD_CH4_WAIT_FOR_PAUSE(1U)
-
-#define S_REQ_CTL_RD_CH4_WAIT_FOR_FIFO_DATA 0
-#define V_REQ_CTL_RD_CH4_WAIT_FOR_FIFO_DATA(x) ((x) << S_REQ_CTL_RD_CH4_WAIT_FOR_FIFO_DATA)
-#define F_REQ_CTL_RD_CH4_WAIT_FOR_FIFO_DATA V_REQ_CTL_RD_CH4_WAIT_FOR_FIFO_DATA(1U)
-
-#define A_PCIE_PDEBUG_REG_0X7 0x7
-
-#define S_TAGQ_CH5_TAGS_USED 11
-#define M_TAGQ_CH5_TAGS_USED 0xffU
-#define V_TAGQ_CH5_TAGS_USED(x) ((x) << S_TAGQ_CH5_TAGS_USED)
-#define G_TAGQ_CH5_TAGS_USED(x) (((x) >> S_TAGQ_CH5_TAGS_USED) & M_TAGQ_CH5_TAGS_USED)
-
-#define S_REQ_CH5_DATA_EMPTY 10
-#define V_REQ_CH5_DATA_EMPTY(x) ((x) << S_REQ_CH5_DATA_EMPTY)
-#define F_REQ_CH5_DATA_EMPTY V_REQ_CH5_DATA_EMPTY(1U)
-
-#define S_RDQ_CH5_REQ_EMPTY 9
-#define V_RDQ_CH5_REQ_EMPTY(x) ((x) << S_RDQ_CH5_REQ_EMPTY)
-#define F_RDQ_CH5_REQ_EMPTY V_RDQ_CH5_REQ_EMPTY(1U)
-
-#define S_REQ_CTL_RD_CH5_WAIT_FOR_TAGTQ 8
-#define V_REQ_CTL_RD_CH5_WAIT_FOR_TAGTQ(x) ((x) << S_REQ_CTL_RD_CH5_WAIT_FOR_TAGTQ)
-#define F_REQ_CTL_RD_CH5_WAIT_FOR_TAGTQ V_REQ_CTL_RD_CH5_WAIT_FOR_TAGTQ(1U)
-
-#define S_REQ_CTL_RD_CH5_WAIT_FOR_CMD 7
-#define V_REQ_CTL_RD_CH5_WAIT_FOR_CMD(x) ((x) << S_REQ_CTL_RD_CH5_WAIT_FOR_CMD)
-#define F_REQ_CTL_RD_CH5_WAIT_FOR_CMD V_REQ_CTL_RD_CH5_WAIT_FOR_CMD(1U)
-
-#define S_REQ_CTL_RD_CH5_WAIT_FOR_DATA_MEM 6
-#define V_REQ_CTL_RD_CH5_WAIT_FOR_DATA_MEM(x) ((x) << S_REQ_CTL_RD_CH5_WAIT_FOR_DATA_MEM)
-#define F_REQ_CTL_RD_CH5_WAIT_FOR_DATA_MEM V_REQ_CTL_RD_CH5_WAIT_FOR_DATA_MEM(1U)
-
-#define S_REQ_CTL_RD_CH5_WAIT_FOR_RDQ 5
-#define V_REQ_CTL_RD_CH5_WAIT_FOR_RDQ(x) ((x) << S_REQ_CTL_RD_CH5_WAIT_FOR_RDQ)
-#define F_REQ_CTL_RD_CH5_WAIT_FOR_RDQ V_REQ_CTL_RD_CH5_WAIT_FOR_RDQ(1U)
-
-#define S_REQ_CTL_RD_CH5_WAIT_FOR_TXN_DISABLE_FIFO 4
-#define V_REQ_CTL_RD_CH5_WAIT_FOR_TXN_DISABLE_FIFO(x) ((x) << S_REQ_CTL_RD_CH5_WAIT_FOR_TXN_DISABLE_FIFO)
-#define F_REQ_CTL_RD_CH5_WAIT_FOR_TXN_DISABLE_FIFO V_REQ_CTL_RD_CH5_WAIT_FOR_TXN_DISABLE_FIFO(1U)
-
-#define S_REQ_CTL_RD_CH5_EXIT_BOT_VLD_STARTED 3
-#define V_REQ_CTL_RD_CH5_EXIT_BOT_VLD_STARTED(x) ((x) << S_REQ_CTL_RD_CH5_EXIT_BOT_VLD_STARTED)
-#define F_REQ_CTL_RD_CH5_EXIT_BOT_VLD_STARTED V_REQ_CTL_RD_CH5_EXIT_BOT_VLD_STARTED(1U)
-
-#define S_REQ_CTL_RD_CH5_EXIT_TOP_VLD_STARTED 2
-#define V_REQ_CTL_RD_CH5_EXIT_TOP_VLD_STARTED(x) ((x) << S_REQ_CTL_RD_CH5_EXIT_TOP_VLD_STARTED)
-#define F_REQ_CTL_RD_CH5_EXIT_TOP_VLD_STARTED V_REQ_CTL_RD_CH5_EXIT_TOP_VLD_STARTED(1U)
-
-#define S_REQ_CTL_RD_CH5_WAIT_FOR_PAUSE 1
-#define V_REQ_CTL_RD_CH5_WAIT_FOR_PAUSE(x) ((x) << S_REQ_CTL_RD_CH5_WAIT_FOR_PAUSE)
-#define F_REQ_CTL_RD_CH5_WAIT_FOR_PAUSE V_REQ_CTL_RD_CH5_WAIT_FOR_PAUSE(1U)
-
-#define S_REQ_CTL_RD_CH5_WAIT_FOR_FIFO_DATA 0
-#define V_REQ_CTL_RD_CH5_WAIT_FOR_FIFO_DATA(x) ((x) << S_REQ_CTL_RD_CH5_WAIT_FOR_FIFO_DATA)
-#define F_REQ_CTL_RD_CH5_WAIT_FOR_FIFO_DATA V_REQ_CTL_RD_CH5_WAIT_FOR_FIFO_DATA(1U)
-
-#define A_PCIE_PDEBUG_REG_0X8 0x8
-
-#define S_TAGQ_CH6_TAGS_USED 11
-#define M_TAGQ_CH6_TAGS_USED 0xffU
-#define V_TAGQ_CH6_TAGS_USED(x) ((x) << S_TAGQ_CH6_TAGS_USED)
-#define G_TAGQ_CH6_TAGS_USED(x) (((x) >> S_TAGQ_CH6_TAGS_USED) & M_TAGQ_CH6_TAGS_USED)
-
-#define S_REQ_CH6_DATA_EMPTY 10
-#define V_REQ_CH6_DATA_EMPTY(x) ((x) << S_REQ_CH6_DATA_EMPTY)
-#define F_REQ_CH6_DATA_EMPTY V_REQ_CH6_DATA_EMPTY(1U)
-
-#define S_RDQ_CH6_REQ_EMPTY 9
-#define V_RDQ_CH6_REQ_EMPTY(x) ((x) << S_RDQ_CH6_REQ_EMPTY)
-#define F_RDQ_CH6_REQ_EMPTY V_RDQ_CH6_REQ_EMPTY(1U)
-
-#define S_REQ_CTL_RD_CH6_WAIT_FOR_TAGTQ 8
-#define V_REQ_CTL_RD_CH6_WAIT_FOR_TAGTQ(x) ((x) << S_REQ_CTL_RD_CH6_WAIT_FOR_TAGTQ)
-#define F_REQ_CTL_RD_CH6_WAIT_FOR_TAGTQ V_REQ_CTL_RD_CH6_WAIT_FOR_TAGTQ(1U)
-
-#define S_REQ_CTL_RD_CH6_WAIT_FOR_CMD 7
-#define V_REQ_CTL_RD_CH6_WAIT_FOR_CMD(x) ((x) << S_REQ_CTL_RD_CH6_WAIT_FOR_CMD)
-#define F_REQ_CTL_RD_CH6_WAIT_FOR_CMD V_REQ_CTL_RD_CH6_WAIT_FOR_CMD(1U)
-
-#define S_REQ_CTL_RD_CH6_WAIT_FOR_DATA_MEM 6
-#define V_REQ_CTL_RD_CH6_WAIT_FOR_DATA_MEM(x) ((x) << S_REQ_CTL_RD_CH6_WAIT_FOR_DATA_MEM)
-#define F_REQ_CTL_RD_CH6_WAIT_FOR_DATA_MEM V_REQ_CTL_RD_CH6_WAIT_FOR_DATA_MEM(1U)
-
-#define S_REQ_CTL_RD_CH6_WAIT_FOR_RDQ 5
-#define V_REQ_CTL_RD_CH6_WAIT_FOR_RDQ(x) ((x) << S_REQ_CTL_RD_CH6_WAIT_FOR_RDQ)
-#define F_REQ_CTL_RD_CH6_WAIT_FOR_RDQ V_REQ_CTL_RD_CH6_WAIT_FOR_RDQ(1U)
-
-#define S_REQ_CTL_RD_CH6_WAIT_FOR_TXN_DISABLE_FIFO 4
-#define V_REQ_CTL_RD_CH6_WAIT_FOR_TXN_DISABLE_FIFO(x) ((x) << S_REQ_CTL_RD_CH6_WAIT_FOR_TXN_DISABLE_FIFO)
-#define F_REQ_CTL_RD_CH6_WAIT_FOR_TXN_DISABLE_FIFO V_REQ_CTL_RD_CH6_WAIT_FOR_TXN_DISABLE_FIFO(1U)
-
-#define S_REQ_CTL_RD_CH6_EXIT_BOT_VLD_STARTED 3
-#define V_REQ_CTL_RD_CH6_EXIT_BOT_VLD_STARTED(x) ((x) << S_REQ_CTL_RD_CH6_EXIT_BOT_VLD_STARTED)
-#define F_REQ_CTL_RD_CH6_EXIT_BOT_VLD_STARTED V_REQ_CTL_RD_CH6_EXIT_BOT_VLD_STARTED(1U)
-
-#define S_REQ_CTL_RD_CH6_EXIT_TOP_VLD_STARTED 2
-#define V_REQ_CTL_RD_CH6_EXIT_TOP_VLD_STARTED(x) ((x) << S_REQ_CTL_RD_CH6_EXIT_TOP_VLD_STARTED)
-#define F_REQ_CTL_RD_CH6_EXIT_TOP_VLD_STARTED V_REQ_CTL_RD_CH6_EXIT_TOP_VLD_STARTED(1U)
-
-#define S_REQ_CTL_RD_CH6_WAIT_FOR_PAUSE 1
-#define V_REQ_CTL_RD_CH6_WAIT_FOR_PAUSE(x) ((x) << S_REQ_CTL_RD_CH6_WAIT_FOR_PAUSE)
-#define F_REQ_CTL_RD_CH6_WAIT_FOR_PAUSE V_REQ_CTL_RD_CH6_WAIT_FOR_PAUSE(1U)
-
-#define S_REQ_CTL_RD_CH6_WAIT_FOR_FIFO_DATA 0
-#define V_REQ_CTL_RD_CH6_WAIT_FOR_FIFO_DATA(x) ((x) << S_REQ_CTL_RD_CH6_WAIT_FOR_FIFO_DATA)
-#define F_REQ_CTL_RD_CH6_WAIT_FOR_FIFO_DATA V_REQ_CTL_RD_CH6_WAIT_FOR_FIFO_DATA(1U)
-
-#define A_PCIE_PDEBUG_REG_0X9 0x9
-
-#define S_TAGQ_CH7_TAGS_USED 11
-#define M_TAGQ_CH7_TAGS_USED 0xffU
-#define V_TAGQ_CH7_TAGS_USED(x) ((x) << S_TAGQ_CH7_TAGS_USED)
-#define G_TAGQ_CH7_TAGS_USED(x) (((x) >> S_TAGQ_CH7_TAGS_USED) & M_TAGQ_CH7_TAGS_USED)
-
-#define S_REQ_CH7_DATA_EMPTY 10
-#define V_REQ_CH7_DATA_EMPTY(x) ((x) << S_REQ_CH7_DATA_EMPTY)
-#define F_REQ_CH7_DATA_EMPTY V_REQ_CH7_DATA_EMPTY(1U)
-
-#define S_RDQ_CH7_REQ_EMPTY 9
-#define V_RDQ_CH7_REQ_EMPTY(x) ((x) << S_RDQ_CH7_REQ_EMPTY)
-#define F_RDQ_CH7_REQ_EMPTY V_RDQ_CH7_REQ_EMPTY(1U)
-
-#define S_REQ_CTL_RD_CH7_WAIT_FOR_TAGTQ 8
-#define V_REQ_CTL_RD_CH7_WAIT_FOR_TAGTQ(x) ((x) << S_REQ_CTL_RD_CH7_WAIT_FOR_TAGTQ)
-#define F_REQ_CTL_RD_CH7_WAIT_FOR_TAGTQ V_REQ_CTL_RD_CH7_WAIT_FOR_TAGTQ(1U)
-
-#define S_REQ_CTL_RD_CH7_WAIT_FOR_CMD 7
-#define V_REQ_CTL_RD_CH7_WAIT_FOR_CMD(x) ((x) << S_REQ_CTL_RD_CH7_WAIT_FOR_CMD)
-#define F_REQ_CTL_RD_CH7_WAIT_FOR_CMD V_REQ_CTL_RD_CH7_WAIT_FOR_CMD(1U)
-
-#define S_REQ_CTL_RD_CH7_WAIT_FOR_DATA_MEM 6
-#define V_REQ_CTL_RD_CH7_WAIT_FOR_DATA_MEM(x) ((x) << S_REQ_CTL_RD_CH7_WAIT_FOR_DATA_MEM)
-#define F_REQ_CTL_RD_CH7_WAIT_FOR_DATA_MEM V_REQ_CTL_RD_CH7_WAIT_FOR_DATA_MEM(1U)
-
-#define S_REQ_CTL_RD_CH7_WAIT_FOR_RDQ 5
-#define V_REQ_CTL_RD_CH7_WAIT_FOR_RDQ(x) ((x) << S_REQ_CTL_RD_CH7_WAIT_FOR_RDQ)
-#define F_REQ_CTL_RD_CH7_WAIT_FOR_RDQ V_REQ_CTL_RD_CH7_WAIT_FOR_RDQ(1U)
-
-#define S_REQ_CTL_RD_CH7_WAIT_FOR_TXN_DISABLE_FIFO 4
-#define V_REQ_CTL_RD_CH7_WAIT_FOR_TXN_DISABLE_FIFO(x) ((x) << S_REQ_CTL_RD_CH7_WAIT_FOR_TXN_DISABLE_FIFO)
-#define F_REQ_CTL_RD_CH7_WAIT_FOR_TXN_DISABLE_FIFO V_REQ_CTL_RD_CH7_WAIT_FOR_TXN_DISABLE_FIFO(1U)
-
-#define S_REQ_CTL_RD_CH7_EXIT_BOT_VLD_STARTED 3
-#define V_REQ_CTL_RD_CH7_EXIT_BOT_VLD_STARTED(x) ((x) << S_REQ_CTL_RD_CH7_EXIT_BOT_VLD_STARTED)
-#define F_REQ_CTL_RD_CH7_EXIT_BOT_VLD_STARTED V_REQ_CTL_RD_CH7_EXIT_BOT_VLD_STARTED(1U)
-
-#define S_REQ_CTL_RD_CH7_EXIT_TOP_VLD_STARTED 2
-#define V_REQ_CTL_RD_CH7_EXIT_TOP_VLD_STARTED(x) ((x) << S_REQ_CTL_RD_CH7_EXIT_TOP_VLD_STARTED)
-#define F_REQ_CTL_RD_CH7_EXIT_TOP_VLD_STARTED V_REQ_CTL_RD_CH7_EXIT_TOP_VLD_STARTED(1U)
-
-#define S_REQ_CTL_RD_CH7_WAIT_FOR_PAUSE 1
-#define V_REQ_CTL_RD_CH7_WAIT_FOR_PAUSE(x) ((x) << S_REQ_CTL_RD_CH7_WAIT_FOR_PAUSE)
-#define F_REQ_CTL_RD_CH7_WAIT_FOR_PAUSE V_REQ_CTL_RD_CH7_WAIT_FOR_PAUSE(1U)
-
-#define S_REQ_CTL_RD_CH7_WAIT_FOR_FIFO_DATA 0
-#define V_REQ_CTL_RD_CH7_WAIT_FOR_FIFO_DATA(x) ((x) << S_REQ_CTL_RD_CH7_WAIT_FOR_FIFO_DATA)
-#define F_REQ_CTL_RD_CH7_WAIT_FOR_FIFO_DATA V_REQ_CTL_RD_CH7_WAIT_FOR_FIFO_DATA(1U)
-
-#define A_PCIE_PDEBUG_REG_0XA 0xa
-
-#define S_REQ_CTL_RD_CH0_WAIT_FOR_SEQNUM 27
-#define V_REQ_CTL_RD_CH0_WAIT_FOR_SEQNUM(x) ((x) << S_REQ_CTL_RD_CH0_WAIT_FOR_SEQNUM)
-#define F_REQ_CTL_RD_CH0_WAIT_FOR_SEQNUM V_REQ_CTL_RD_CH0_WAIT_FOR_SEQNUM(1U)
-
-#define S_REQ_CTL_WR_CH0_SEQNUM 19
-#define M_REQ_CTL_WR_CH0_SEQNUM 0xffU
-#define V_REQ_CTL_WR_CH0_SEQNUM(x) ((x) << S_REQ_CTL_WR_CH0_SEQNUM)
-#define G_REQ_CTL_WR_CH0_SEQNUM(x) (((x) >> S_REQ_CTL_WR_CH0_SEQNUM) & M_REQ_CTL_WR_CH0_SEQNUM)
-
-#define S_REQ_CTL_RD_CH0_SEQNUM 11
-#define M_REQ_CTL_RD_CH0_SEQNUM 0xffU
-#define V_REQ_CTL_RD_CH0_SEQNUM(x) ((x) << S_REQ_CTL_RD_CH0_SEQNUM)
-#define G_REQ_CTL_RD_CH0_SEQNUM(x) (((x) >> S_REQ_CTL_RD_CH0_SEQNUM) & M_REQ_CTL_RD_CH0_SEQNUM)
-
-#define S_REQ_CTL_WR_CH0_WAIT_FOR_SI_FIFO 4
-#define V_REQ_CTL_WR_CH0_WAIT_FOR_SI_FIFO(x) ((x) << S_REQ_CTL_WR_CH0_WAIT_FOR_SI_FIFO)
-#define F_REQ_CTL_WR_CH0_WAIT_FOR_SI_FIFO V_REQ_CTL_WR_CH0_WAIT_FOR_SI_FIFO(1U)
-
-#define S_REQ_CTL_WR_CH0_EXIT_BOT_VLD_STARTED 3
-#define V_REQ_CTL_WR_CH0_EXIT_BOT_VLD_STARTED(x) ((x) << S_REQ_CTL_WR_CH0_EXIT_BOT_VLD_STARTED)
-#define F_REQ_CTL_WR_CH0_EXIT_BOT_VLD_STARTED V_REQ_CTL_WR_CH0_EXIT_BOT_VLD_STARTED(1U)
-
-#define S_REQ_CTL_WR_CH0_EXIT_TOP_VLD_STARTED 2
-#define V_REQ_CTL_WR_CH0_EXIT_TOP_VLD_STARTED(x) ((x) << S_REQ_CTL_WR_CH0_EXIT_TOP_VLD_STARTED)
-#define F_REQ_CTL_WR_CH0_EXIT_TOP_VLD_STARTED V_REQ_CTL_WR_CH0_EXIT_TOP_VLD_STARTED(1U)
-
-#define S_REQ_CTL_WR_CH0_WAIT_FOR_PAUSE 1
-#define V_REQ_CTL_WR_CH0_WAIT_FOR_PAUSE(x) ((x) << S_REQ_CTL_WR_CH0_WAIT_FOR_PAUSE)
-#define F_REQ_CTL_WR_CH0_WAIT_FOR_PAUSE V_REQ_CTL_WR_CH0_WAIT_FOR_PAUSE(1U)
-
-#define S_REQ_CTL_WR_CH0_WAIT_FOR_FIFO_DATA 0
-#define V_REQ_CTL_WR_CH0_WAIT_FOR_FIFO_DATA(x) ((x) << S_REQ_CTL_WR_CH0_WAIT_FOR_FIFO_DATA)
-#define F_REQ_CTL_WR_CH0_WAIT_FOR_FIFO_DATA V_REQ_CTL_WR_CH0_WAIT_FOR_FIFO_DATA(1U)
-
-#define A_PCIE_PDEBUG_REG_0XB 0xb
-
-#define S_REQ_CTL_RD_CH1_WAIT_FOR_SEQNUM 27
-#define V_REQ_CTL_RD_CH1_WAIT_FOR_SEQNUM(x) ((x) << S_REQ_CTL_RD_CH1_WAIT_FOR_SEQNUM)
-#define F_REQ_CTL_RD_CH1_WAIT_FOR_SEQNUM V_REQ_CTL_RD_CH1_WAIT_FOR_SEQNUM(1U)
-
-#define S_REQ_CTL_WR_CH1_SEQNUM 19
-#define M_REQ_CTL_WR_CH1_SEQNUM 0xffU
-#define V_REQ_CTL_WR_CH1_SEQNUM(x) ((x) << S_REQ_CTL_WR_CH1_SEQNUM)
-#define G_REQ_CTL_WR_CH1_SEQNUM(x) (((x) >> S_REQ_CTL_WR_CH1_SEQNUM) & M_REQ_CTL_WR_CH1_SEQNUM)
-
-#define S_REQ_CTL_RD_CH1_SEQNUM 11
-#define M_REQ_CTL_RD_CH1_SEQNUM 0xffU
-#define V_REQ_CTL_RD_CH1_SEQNUM(x) ((x) << S_REQ_CTL_RD_CH1_SEQNUM)
-#define G_REQ_CTL_RD_CH1_SEQNUM(x) (((x) >> S_REQ_CTL_RD_CH1_SEQNUM) & M_REQ_CTL_RD_CH1_SEQNUM)
-
-#define S_REQ_CTL_WR_CH1_WAIT_FOR_SI_FIFO 4
-#define V_REQ_CTL_WR_CH1_WAIT_FOR_SI_FIFO(x) ((x) << S_REQ_CTL_WR_CH1_WAIT_FOR_SI_FIFO)
-#define F_REQ_CTL_WR_CH1_WAIT_FOR_SI_FIFO V_REQ_CTL_WR_CH1_WAIT_FOR_SI_FIFO(1U)
-
-#define S_REQ_CTL_WR_CH1_EXIT_BOT_VLD_STARTED 3
-#define V_REQ_CTL_WR_CH1_EXIT_BOT_VLD_STARTED(x) ((x) << S_REQ_CTL_WR_CH1_EXIT_BOT_VLD_STARTED)
-#define F_REQ_CTL_WR_CH1_EXIT_BOT_VLD_STARTED V_REQ_CTL_WR_CH1_EXIT_BOT_VLD_STARTED(1U)
-
-#define S_REQ_CTL_WR_CH1_EXIT_TOP_VLD_STARTED 2
-#define V_REQ_CTL_WR_CH1_EXIT_TOP_VLD_STARTED(x) ((x) << S_REQ_CTL_WR_CH1_EXIT_TOP_VLD_STARTED)
-#define F_REQ_CTL_WR_CH1_EXIT_TOP_VLD_STARTED V_REQ_CTL_WR_CH1_EXIT_TOP_VLD_STARTED(1U)
-
-#define S_REQ_CTL_WR_CH1_WAIT_FOR_PAUSE 1
-#define V_REQ_CTL_WR_CH1_WAIT_FOR_PAUSE(x) ((x) << S_REQ_CTL_WR_CH1_WAIT_FOR_PAUSE)
-#define F_REQ_CTL_WR_CH1_WAIT_FOR_PAUSE V_REQ_CTL_WR_CH1_WAIT_FOR_PAUSE(1U)
-
-#define S_REQ_CTL_WR_CH1_WAIT_FOR_FIFO_DATA 0
-#define V_REQ_CTL_WR_CH1_WAIT_FOR_FIFO_DATA(x) ((x) << S_REQ_CTL_WR_CH1_WAIT_FOR_FIFO_DATA)
-#define F_REQ_CTL_WR_CH1_WAIT_FOR_FIFO_DATA V_REQ_CTL_WR_CH1_WAIT_FOR_FIFO_DATA(1U)
-
-#define A_PCIE_PDEBUG_REG_0XC 0xc
-
-#define S_REQ_CTL_RD_CH2_WAIT_FOR_SEQNUM 27
-#define V_REQ_CTL_RD_CH2_WAIT_FOR_SEQNUM(x) ((x) << S_REQ_CTL_RD_CH2_WAIT_FOR_SEQNUM)
-#define F_REQ_CTL_RD_CH2_WAIT_FOR_SEQNUM V_REQ_CTL_RD_CH2_WAIT_FOR_SEQNUM(1U)
-
-#define S_REQ_CTL_WR_CH2_SEQNUM 19
-#define M_REQ_CTL_WR_CH2_SEQNUM 0xffU
-#define V_REQ_CTL_WR_CH2_SEQNUM(x) ((x) << S_REQ_CTL_WR_CH2_SEQNUM)
-#define G_REQ_CTL_WR_CH2_SEQNUM(x) (((x) >> S_REQ_CTL_WR_CH2_SEQNUM) & M_REQ_CTL_WR_CH2_SEQNUM)
-
-#define S_REQ_CTL_RD_CH2_SEQNUM 11
-#define M_REQ_CTL_RD_CH2_SEQNUM 0xffU
-#define V_REQ_CTL_RD_CH2_SEQNUM(x) ((x) << S_REQ_CTL_RD_CH2_SEQNUM)
-#define G_REQ_CTL_RD_CH2_SEQNUM(x) (((x) >> S_REQ_CTL_RD_CH2_SEQNUM) & M_REQ_CTL_RD_CH2_SEQNUM)
-
-#define S_REQ_CTL_WR_CH2_WAIT_FOR_SI_FIFO 4
-#define V_REQ_CTL_WR_CH2_WAIT_FOR_SI_FIFO(x) ((x) << S_REQ_CTL_WR_CH2_WAIT_FOR_SI_FIFO)
-#define F_REQ_CTL_WR_CH2_WAIT_FOR_SI_FIFO V_REQ_CTL_WR_CH2_WAIT_FOR_SI_FIFO(1U)
-
-#define S_REQ_CTL_WR_CH2_EXIT_BOT_VLD_STARTED 3
-#define V_REQ_CTL_WR_CH2_EXIT_BOT_VLD_STARTED(x) ((x) << S_REQ_CTL_WR_CH2_EXIT_BOT_VLD_STARTED)
-#define F_REQ_CTL_WR_CH2_EXIT_BOT_VLD_STARTED V_REQ_CTL_WR_CH2_EXIT_BOT_VLD_STARTED(1U)
-
-#define S_REQ_CTL_WR_CH2_EXIT_TOP_VLD_STARTED 2
-#define V_REQ_CTL_WR_CH2_EXIT_TOP_VLD_STARTED(x) ((x) << S_REQ_CTL_WR_CH2_EXIT_TOP_VLD_STARTED)
-#define F_REQ_CTL_WR_CH2_EXIT_TOP_VLD_STARTED V_REQ_CTL_WR_CH2_EXIT_TOP_VLD_STARTED(1U)
-
-#define S_REQ_CTL_WR_CH2_WAIT_FOR_PAUSE 1
-#define V_REQ_CTL_WR_CH2_WAIT_FOR_PAUSE(x) ((x) << S_REQ_CTL_WR_CH2_WAIT_FOR_PAUSE)
-#define F_REQ_CTL_WR_CH2_WAIT_FOR_PAUSE V_REQ_CTL_WR_CH2_WAIT_FOR_PAUSE(1U)
-
-#define S_REQ_CTL_WR_CH2_WAIT_FOR_FIFO_DATA 0
-#define V_REQ_CTL_WR_CH2_WAIT_FOR_FIFO_DATA(x) ((x) << S_REQ_CTL_WR_CH2_WAIT_FOR_FIFO_DATA)
-#define F_REQ_CTL_WR_CH2_WAIT_FOR_FIFO_DATA V_REQ_CTL_WR_CH2_WAIT_FOR_FIFO_DATA(1U)
-
-#define A_PCIE_PDEBUG_REG_0XD 0xd
-
-#define S_REQ_CTL_RD_CH3_WAIT_FOR_SEQNUM 27
-#define V_REQ_CTL_RD_CH3_WAIT_FOR_SEQNUM(x) ((x) << S_REQ_CTL_RD_CH3_WAIT_FOR_SEQNUM)
-#define F_REQ_CTL_RD_CH3_WAIT_FOR_SEQNUM V_REQ_CTL_RD_CH3_WAIT_FOR_SEQNUM(1U)
-
-#define S_REQ_CTL_WR_CH3_SEQNUM 19
-#define M_REQ_CTL_WR_CH3_SEQNUM 0xffU
-#define V_REQ_CTL_WR_CH3_SEQNUM(x) ((x) << S_REQ_CTL_WR_CH3_SEQNUM)
-#define G_REQ_CTL_WR_CH3_SEQNUM(x) (((x) >> S_REQ_CTL_WR_CH3_SEQNUM) & M_REQ_CTL_WR_CH3_SEQNUM)
-
-#define S_REQ_CTL_RD_CH3_SEQNUM 11
-#define M_REQ_CTL_RD_CH3_SEQNUM 0xffU
-#define V_REQ_CTL_RD_CH3_SEQNUM(x) ((x) << S_REQ_CTL_RD_CH3_SEQNUM)
-#define G_REQ_CTL_RD_CH3_SEQNUM(x) (((x) >> S_REQ_CTL_RD_CH3_SEQNUM) & M_REQ_CTL_RD_CH3_SEQNUM)
-
-#define S_REQ_CTL_WR_CH3_WAIT_FOR_SI_FIFO 4
-#define V_REQ_CTL_WR_CH3_WAIT_FOR_SI_FIFO(x) ((x) << S_REQ_CTL_WR_CH3_WAIT_FOR_SI_FIFO)
-#define F_REQ_CTL_WR_CH3_WAIT_FOR_SI_FIFO V_REQ_CTL_WR_CH3_WAIT_FOR_SI_FIFO(1U)
-
-#define S_REQ_CTL_WR_CH3_EXIT_BOT_VLD_STARTED 3
-#define V_REQ_CTL_WR_CH3_EXIT_BOT_VLD_STARTED(x) ((x) << S_REQ_CTL_WR_CH3_EXIT_BOT_VLD_STARTED)
-#define F_REQ_CTL_WR_CH3_EXIT_BOT_VLD_STARTED V_REQ_CTL_WR_CH3_EXIT_BOT_VLD_STARTED(1U)
-
-#define S_REQ_CTL_WR_CH3_EXIT_TOP_VLD_STARTED 2
-#define V_REQ_CTL_WR_CH3_EXIT_TOP_VLD_STARTED(x) ((x) << S_REQ_CTL_WR_CH3_EXIT_TOP_VLD_STARTED)
-#define F_REQ_CTL_WR_CH3_EXIT_TOP_VLD_STARTED V_REQ_CTL_WR_CH3_EXIT_TOP_VLD_STARTED(1U)
-
-#define S_REQ_CTL_WR_CH3_WAIT_FOR_PAUSE 1
-#define V_REQ_CTL_WR_CH3_WAIT_FOR_PAUSE(x) ((x) << S_REQ_CTL_WR_CH3_WAIT_FOR_PAUSE)
-#define F_REQ_CTL_WR_CH3_WAIT_FOR_PAUSE V_REQ_CTL_WR_CH3_WAIT_FOR_PAUSE(1U)
-
-#define S_REQ_CTL_WR_CH3_WAIT_FOR_FIFO_DATA 0
-#define V_REQ_CTL_WR_CH3_WAIT_FOR_FIFO_DATA(x) ((x) << S_REQ_CTL_WR_CH3_WAIT_FOR_FIFO_DATA)
-#define F_REQ_CTL_WR_CH3_WAIT_FOR_FIFO_DATA V_REQ_CTL_WR_CH3_WAIT_FOR_FIFO_DATA(1U)
-
-#define A_PCIE_PDEBUG_REG_0XE 0xe
-
-#define S_REQ_CTL_RD_CH4_WAIT_FOR_SEQNUM 27
-#define V_REQ_CTL_RD_CH4_WAIT_FOR_SEQNUM(x) ((x) << S_REQ_CTL_RD_CH4_WAIT_FOR_SEQNUM)
-#define F_REQ_CTL_RD_CH4_WAIT_FOR_SEQNUM V_REQ_CTL_RD_CH4_WAIT_FOR_SEQNUM(1U)
-
-#define S_REQ_CTL_WR_CH4_SEQNUM 19
-#define M_REQ_CTL_WR_CH4_SEQNUM 0xffU
-#define V_REQ_CTL_WR_CH4_SEQNUM(x) ((x) << S_REQ_CTL_WR_CH4_SEQNUM)
-#define G_REQ_CTL_WR_CH4_SEQNUM(x) (((x) >> S_REQ_CTL_WR_CH4_SEQNUM) & M_REQ_CTL_WR_CH4_SEQNUM)
-
-#define S_REQ_CTL_RD_CH4_SEQNUM 11
-#define M_REQ_CTL_RD_CH4_SEQNUM 0xffU
-#define V_REQ_CTL_RD_CH4_SEQNUM(x) ((x) << S_REQ_CTL_RD_CH4_SEQNUM)
-#define G_REQ_CTL_RD_CH4_SEQNUM(x) (((x) >> S_REQ_CTL_RD_CH4_SEQNUM) & M_REQ_CTL_RD_CH4_SEQNUM)
-
-#define S_REQ_CTL_WR_CH4_WAIT_FOR_SI_FIFO 4
-#define V_REQ_CTL_WR_CH4_WAIT_FOR_SI_FIFO(x) ((x) << S_REQ_CTL_WR_CH4_WAIT_FOR_SI_FIFO)
-#define F_REQ_CTL_WR_CH4_WAIT_FOR_SI_FIFO V_REQ_CTL_WR_CH4_WAIT_FOR_SI_FIFO(1U)
-
-#define S_REQ_CTL_WR_CH4_EXIT_BOT_VLD_STARTED 3
-#define V_REQ_CTL_WR_CH4_EXIT_BOT_VLD_STARTED(x) ((x) << S_REQ_CTL_WR_CH4_EXIT_BOT_VLD_STARTED)
-#define F_REQ_CTL_WR_CH4_EXIT_BOT_VLD_STARTED V_REQ_CTL_WR_CH4_EXIT_BOT_VLD_STARTED(1U)
-
-#define S_REQ_CTL_WR_CH4_EXIT_TOP_VLD_STARTED 2
-#define V_REQ_CTL_WR_CH4_EXIT_TOP_VLD_STARTED(x) ((x) << S_REQ_CTL_WR_CH4_EXIT_TOP_VLD_STARTED)
-#define F_REQ_CTL_WR_CH4_EXIT_TOP_VLD_STARTED V_REQ_CTL_WR_CH4_EXIT_TOP_VLD_STARTED(1U)
-
-#define S_REQ_CTL_WR_CH4_WAIT_FOR_PAUSE 1
-#define V_REQ_CTL_WR_CH4_WAIT_FOR_PAUSE(x) ((x) << S_REQ_CTL_WR_CH4_WAIT_FOR_PAUSE)
-#define F_REQ_CTL_WR_CH4_WAIT_FOR_PAUSE V_REQ_CTL_WR_CH4_WAIT_FOR_PAUSE(1U)
-
-#define S_REQ_CTL_WR_CH4_WAIT_FOR_FIFO_DATA 0
-#define V_REQ_CTL_WR_CH4_WAIT_FOR_FIFO_DATA(x) ((x) << S_REQ_CTL_WR_CH4_WAIT_FOR_FIFO_DATA)
-#define F_REQ_CTL_WR_CH4_WAIT_FOR_FIFO_DATA V_REQ_CTL_WR_CH4_WAIT_FOR_FIFO_DATA(1U)
-
-#define A_PCIE_PDEBUG_REG_0XF 0xf
-#define A_PCIE_PDEBUG_REG_0X10 0x10
-
-#define S_PIPE0_TX3_DATAK_0 31
-#define V_PIPE0_TX3_DATAK_0(x) ((x) << S_PIPE0_TX3_DATAK_0)
-#define F_PIPE0_TX3_DATAK_0 V_PIPE0_TX3_DATAK_0(1U)
-
-#define S_PIPE0_TX3_DATA_6_0 24
-#define M_PIPE0_TX3_DATA_6_0 0x7fU
-#define V_PIPE0_TX3_DATA_6_0(x) ((x) << S_PIPE0_TX3_DATA_6_0)
-#define G_PIPE0_TX3_DATA_6_0(x) (((x) >> S_PIPE0_TX3_DATA_6_0) & M_PIPE0_TX3_DATA_6_0)
-
-#define S_PIPE0_TX2_DATA_7_0 16
-#define M_PIPE0_TX2_DATA_7_0 0xffU
-#define V_PIPE0_TX2_DATA_7_0(x) ((x) << S_PIPE0_TX2_DATA_7_0)
-#define G_PIPE0_TX2_DATA_7_0(x) (((x) >> S_PIPE0_TX2_DATA_7_0) & M_PIPE0_TX2_DATA_7_0)
-
-#define S_PIPE0_TX1_DATA_7_0 8
-#define M_PIPE0_TX1_DATA_7_0 0xffU
-#define V_PIPE0_TX1_DATA_7_0(x) ((x) << S_PIPE0_TX1_DATA_7_0)
-#define G_PIPE0_TX1_DATA_7_0(x) (((x) >> S_PIPE0_TX1_DATA_7_0) & M_PIPE0_TX1_DATA_7_0)
-
-#define S_PIPE0_TX0_DATAK_0 7
-#define V_PIPE0_TX0_DATAK_0(x) ((x) << S_PIPE0_TX0_DATAK_0)
-#define F_PIPE0_TX0_DATAK_0 V_PIPE0_TX0_DATAK_0(1U)
-
-#define S_PIPE0_TX0_DATA_6_0 0
-#define M_PIPE0_TX0_DATA_6_0 0x7fU
-#define V_PIPE0_TX0_DATA_6_0(x) ((x) << S_PIPE0_TX0_DATA_6_0)
-#define G_PIPE0_TX0_DATA_6_0(x) (((x) >> S_PIPE0_TX0_DATA_6_0) & M_PIPE0_TX0_DATA_6_0)
-
-#define A_PCIE_PDEBUG_REG_0X11 0x11
-
-#define S_PIPE0_TX3_DATAK_1 31
-#define V_PIPE0_TX3_DATAK_1(x) ((x) << S_PIPE0_TX3_DATAK_1)
-#define F_PIPE0_TX3_DATAK_1 V_PIPE0_TX3_DATAK_1(1U)
-
-#define S_PIPE0_TX3_DATA_14_8 24
-#define M_PIPE0_TX3_DATA_14_8 0x7fU
-#define V_PIPE0_TX3_DATA_14_8(x) ((x) << S_PIPE0_TX3_DATA_14_8)
-#define G_PIPE0_TX3_DATA_14_8(x) (((x) >> S_PIPE0_TX3_DATA_14_8) & M_PIPE0_TX3_DATA_14_8)
-
-#define S_PIPE0_TX2_DATA_15_8 16
-#define M_PIPE0_TX2_DATA_15_8 0xffU
-#define V_PIPE0_TX2_DATA_15_8(x) ((x) << S_PIPE0_TX2_DATA_15_8)
-#define G_PIPE0_TX2_DATA_15_8(x) (((x) >> S_PIPE0_TX2_DATA_15_8) & M_PIPE0_TX2_DATA_15_8)
-
-#define S_PIPE0_TX1_DATA_15_8 8
-#define M_PIPE0_TX1_DATA_15_8 0xffU
-#define V_PIPE0_TX1_DATA_15_8(x) ((x) << S_PIPE0_TX1_DATA_15_8)
-#define G_PIPE0_TX1_DATA_15_8(x) (((x) >> S_PIPE0_TX1_DATA_15_8) & M_PIPE0_TX1_DATA_15_8)
-
-#define S_PIPE0_TX0_DATAK_1 7
-#define V_PIPE0_TX0_DATAK_1(x) ((x) << S_PIPE0_TX0_DATAK_1)
-#define F_PIPE0_TX0_DATAK_1 V_PIPE0_TX0_DATAK_1(1U)
-
-#define S_PIPE0_TX0_DATA_14_8 0
-#define M_PIPE0_TX0_DATA_14_8 0x7fU
-#define V_PIPE0_TX0_DATA_14_8(x) ((x) << S_PIPE0_TX0_DATA_14_8)
-#define G_PIPE0_TX0_DATA_14_8(x) (((x) >> S_PIPE0_TX0_DATA_14_8) & M_PIPE0_TX0_DATA_14_8)
-
-#define A_PCIE_PDEBUG_REG_0X12 0x12
-
-#define S_PIPE0_TX7_DATAK_0 31
-#define V_PIPE0_TX7_DATAK_0(x) ((x) << S_PIPE0_TX7_DATAK_0)
-#define F_PIPE0_TX7_DATAK_0 V_PIPE0_TX7_DATAK_0(1U)
-
-#define S_PIPE0_TX7_DATA_6_0 24
-#define M_PIPE0_TX7_DATA_6_0 0x7fU
-#define V_PIPE0_TX7_DATA_6_0(x) ((x) << S_PIPE0_TX7_DATA_6_0)
-#define G_PIPE0_TX7_DATA_6_0(x) (((x) >> S_PIPE0_TX7_DATA_6_0) & M_PIPE0_TX7_DATA_6_0)
-
-#define S_PIPE0_TX6_DATA_7_0 16
-#define M_PIPE0_TX6_DATA_7_0 0xffU
-#define V_PIPE0_TX6_DATA_7_0(x) ((x) << S_PIPE0_TX6_DATA_7_0)
-#define G_PIPE0_TX6_DATA_7_0(x) (((x) >> S_PIPE0_TX6_DATA_7_0) & M_PIPE0_TX6_DATA_7_0)
-
-#define S_PIPE0_TX5_DATA_7_0 8
-#define M_PIPE0_TX5_DATA_7_0 0xffU
-#define V_PIPE0_TX5_DATA_7_0(x) ((x) << S_PIPE0_TX5_DATA_7_0)
-#define G_PIPE0_TX5_DATA_7_0(x) (((x) >> S_PIPE0_TX5_DATA_7_0) & M_PIPE0_TX5_DATA_7_0)
-
-#define S_PIPE0_TX4_DATAK_0 7
-#define V_PIPE0_TX4_DATAK_0(x) ((x) << S_PIPE0_TX4_DATAK_0)
-#define F_PIPE0_TX4_DATAK_0 V_PIPE0_TX4_DATAK_0(1U)
-
-#define S_PIPE0_TX4_DATA_6_0 0
-#define M_PIPE0_TX4_DATA_6_0 0x7fU
-#define V_PIPE0_TX4_DATA_6_0(x) ((x) << S_PIPE0_TX4_DATA_6_0)
-#define G_PIPE0_TX4_DATA_6_0(x) (((x) >> S_PIPE0_TX4_DATA_6_0) & M_PIPE0_TX4_DATA_6_0)
-
-#define A_PCIE_PDEBUG_REG_0X13 0x13
-
-#define S_PIPE0_TX7_DATAK_1 31
-#define V_PIPE0_TX7_DATAK_1(x) ((x) << S_PIPE0_TX7_DATAK_1)
-#define F_PIPE0_TX7_DATAK_1 V_PIPE0_TX7_DATAK_1(1U)
-
-#define S_PIPE0_TX7_DATA_14_8 24
-#define M_PIPE0_TX7_DATA_14_8 0x7fU
-#define V_PIPE0_TX7_DATA_14_8(x) ((x) << S_PIPE0_TX7_DATA_14_8)
-#define G_PIPE0_TX7_DATA_14_8(x) (((x) >> S_PIPE0_TX7_DATA_14_8) & M_PIPE0_TX7_DATA_14_8)
-
-#define S_PIPE0_TX6_DATA_15_8 16
-#define M_PIPE0_TX6_DATA_15_8 0xffU
-#define V_PIPE0_TX6_DATA_15_8(x) ((x) << S_PIPE0_TX6_DATA_15_8)
-#define G_PIPE0_TX6_DATA_15_8(x) (((x) >> S_PIPE0_TX6_DATA_15_8) & M_PIPE0_TX6_DATA_15_8)
-
-#define S_PIPE0_TX5_DATA_15_8 8
-#define M_PIPE0_TX5_DATA_15_8 0xffU
-#define V_PIPE0_TX5_DATA_15_8(x) ((x) << S_PIPE0_TX5_DATA_15_8)
-#define G_PIPE0_TX5_DATA_15_8(x) (((x) >> S_PIPE0_TX5_DATA_15_8) & M_PIPE0_TX5_DATA_15_8)
-
-#define S_PIPE0_TX4_DATAK_1 7
-#define V_PIPE0_TX4_DATAK_1(x) ((x) << S_PIPE0_TX4_DATAK_1)
-#define F_PIPE0_TX4_DATAK_1 V_PIPE0_TX4_DATAK_1(1U)
-
-#define S_PIPE0_TX4_DATA_14_8 0
-#define M_PIPE0_TX4_DATA_14_8 0x7fU
-#define V_PIPE0_TX4_DATA_14_8(x) ((x) << S_PIPE0_TX4_DATA_14_8)
-#define G_PIPE0_TX4_DATA_14_8(x) (((x) >> S_PIPE0_TX4_DATA_14_8) & M_PIPE0_TX4_DATA_14_8)
-
-#define A_PCIE_PDEBUG_REG_0X14 0x14
-
-#define S_PIPE0_RX3_VALID_14 31
-#define V_PIPE0_RX3_VALID_14(x) ((x) << S_PIPE0_RX3_VALID_14)
-#define F_PIPE0_RX3_VALID_14 V_PIPE0_RX3_VALID_14(1U)
-
-#define S_PIPE0_RX3_VALID2_14 24
-#define M_PIPE0_RX3_VALID2_14 0x7fU
-#define V_PIPE0_RX3_VALID2_14(x) ((x) << S_PIPE0_RX3_VALID2_14)
-#define G_PIPE0_RX3_VALID2_14(x) (((x) >> S_PIPE0_RX3_VALID2_14) & M_PIPE0_RX3_VALID2_14)
-
-#define S_PIPE0_RX2_VALID_14 16
-#define M_PIPE0_RX2_VALID_14 0xffU
-#define V_PIPE0_RX2_VALID_14(x) ((x) << S_PIPE0_RX2_VALID_14)
-#define G_PIPE0_RX2_VALID_14(x) (((x) >> S_PIPE0_RX2_VALID_14) & M_PIPE0_RX2_VALID_14)
-
-#define S_PIPE0_RX1_VALID_14 8
-#define M_PIPE0_RX1_VALID_14 0xffU
-#define V_PIPE0_RX1_VALID_14(x) ((x) << S_PIPE0_RX1_VALID_14)
-#define G_PIPE0_RX1_VALID_14(x) (((x) >> S_PIPE0_RX1_VALID_14) & M_PIPE0_RX1_VALID_14)
-
-#define S_PIPE0_RX0_VALID_14 7
-#define V_PIPE0_RX0_VALID_14(x) ((x) << S_PIPE0_RX0_VALID_14)
-#define F_PIPE0_RX0_VALID_14 V_PIPE0_RX0_VALID_14(1U)
-
-#define S_PIPE0_RX0_VALID2_14 0
-#define M_PIPE0_RX0_VALID2_14 0x7fU
-#define V_PIPE0_RX0_VALID2_14(x) ((x) << S_PIPE0_RX0_VALID2_14)
-#define G_PIPE0_RX0_VALID2_14(x) (((x) >> S_PIPE0_RX0_VALID2_14) & M_PIPE0_RX0_VALID2_14)
-
-#define A_PCIE_PDEBUG_REG_0X15 0x15
-
-#define S_PIPE0_RX3_VALID_15 31
-#define V_PIPE0_RX3_VALID_15(x) ((x) << S_PIPE0_RX3_VALID_15)
-#define F_PIPE0_RX3_VALID_15 V_PIPE0_RX3_VALID_15(1U)
-
-#define S_PIPE0_RX3_VALID2_15 24
-#define M_PIPE0_RX3_VALID2_15 0x7fU
-#define V_PIPE0_RX3_VALID2_15(x) ((x) << S_PIPE0_RX3_VALID2_15)
-#define G_PIPE0_RX3_VALID2_15(x) (((x) >> S_PIPE0_RX3_VALID2_15) & M_PIPE0_RX3_VALID2_15)
-
-#define S_PIPE0_RX2_VALID_15 16
-#define M_PIPE0_RX2_VALID_15 0xffU
-#define V_PIPE0_RX2_VALID_15(x) ((x) << S_PIPE0_RX2_VALID_15)
-#define G_PIPE0_RX2_VALID_15(x) (((x) >> S_PIPE0_RX2_VALID_15) & M_PIPE0_RX2_VALID_15)
-
-#define S_PIPE0_RX1_VALID_15 8
-#define M_PIPE0_RX1_VALID_15 0xffU
-#define V_PIPE0_RX1_VALID_15(x) ((x) << S_PIPE0_RX1_VALID_15)
-#define G_PIPE0_RX1_VALID_15(x) (((x) >> S_PIPE0_RX1_VALID_15) & M_PIPE0_RX1_VALID_15)
-
-#define S_PIPE0_RX0_VALID_15 7
-#define V_PIPE0_RX0_VALID_15(x) ((x) << S_PIPE0_RX0_VALID_15)
-#define F_PIPE0_RX0_VALID_15 V_PIPE0_RX0_VALID_15(1U)
-
-#define S_PIPE0_RX0_VALID2_15 0
-#define M_PIPE0_RX0_VALID2_15 0x7fU
-#define V_PIPE0_RX0_VALID2_15(x) ((x) << S_PIPE0_RX0_VALID2_15)
-#define G_PIPE0_RX0_VALID2_15(x) (((x) >> S_PIPE0_RX0_VALID2_15) & M_PIPE0_RX0_VALID2_15)
-
-#define A_PCIE_PDEBUG_REG_0X16 0x16
-
-#define S_PIPE0_RX7_VALID_16 31
-#define V_PIPE0_RX7_VALID_16(x) ((x) << S_PIPE0_RX7_VALID_16)
-#define F_PIPE0_RX7_VALID_16 V_PIPE0_RX7_VALID_16(1U)
-
-#define S_PIPE0_RX7_VALID2_16 24
-#define M_PIPE0_RX7_VALID2_16 0x7fU
-#define V_PIPE0_RX7_VALID2_16(x) ((x) << S_PIPE0_RX7_VALID2_16)
-#define G_PIPE0_RX7_VALID2_16(x) (((x) >> S_PIPE0_RX7_VALID2_16) & M_PIPE0_RX7_VALID2_16)
-
-#define S_PIPE0_RX6_VALID_16 16
-#define M_PIPE0_RX6_VALID_16 0xffU
-#define V_PIPE0_RX6_VALID_16(x) ((x) << S_PIPE0_RX6_VALID_16)
-#define G_PIPE0_RX6_VALID_16(x) (((x) >> S_PIPE0_RX6_VALID_16) & M_PIPE0_RX6_VALID_16)
-
-#define S_PIPE0_RX5_VALID_16 8
-#define M_PIPE0_RX5_VALID_16 0xffU
-#define V_PIPE0_RX5_VALID_16(x) ((x) << S_PIPE0_RX5_VALID_16)
-#define G_PIPE0_RX5_VALID_16(x) (((x) >> S_PIPE0_RX5_VALID_16) & M_PIPE0_RX5_VALID_16)
-
-#define S_PIPE0_RX4_VALID_16 7
-#define V_PIPE0_RX4_VALID_16(x) ((x) << S_PIPE0_RX4_VALID_16)
-#define F_PIPE0_RX4_VALID_16 V_PIPE0_RX4_VALID_16(1U)
-
-#define S_PIPE0_RX4_VALID2_16 0
-#define M_PIPE0_RX4_VALID2_16 0x7fU
-#define V_PIPE0_RX4_VALID2_16(x) ((x) << S_PIPE0_RX4_VALID2_16)
-#define G_PIPE0_RX4_VALID2_16(x) (((x) >> S_PIPE0_RX4_VALID2_16) & M_PIPE0_RX4_VALID2_16)
-
-#define A_PCIE_PDEBUG_REG_0X17 0x17
-
-#define S_PIPE0_RX7_VALID_17 31
-#define V_PIPE0_RX7_VALID_17(x) ((x) << S_PIPE0_RX7_VALID_17)
-#define F_PIPE0_RX7_VALID_17 V_PIPE0_RX7_VALID_17(1U)
-
-#define S_PIPE0_RX7_VALID2_17 24
-#define M_PIPE0_RX7_VALID2_17 0x7fU
-#define V_PIPE0_RX7_VALID2_17(x) ((x) << S_PIPE0_RX7_VALID2_17)
-#define G_PIPE0_RX7_VALID2_17(x) (((x) >> S_PIPE0_RX7_VALID2_17) & M_PIPE0_RX7_VALID2_17)
-
-#define S_PIPE0_RX6_VALID_17 16
-#define M_PIPE0_RX6_VALID_17 0xffU
-#define V_PIPE0_RX6_VALID_17(x) ((x) << S_PIPE0_RX6_VALID_17)
-#define G_PIPE0_RX6_VALID_17(x) (((x) >> S_PIPE0_RX6_VALID_17) & M_PIPE0_RX6_VALID_17)
-
-#define S_PIPE0_RX5_VALID_17 8
-#define M_PIPE0_RX5_VALID_17 0xffU
-#define V_PIPE0_RX5_VALID_17(x) ((x) << S_PIPE0_RX5_VALID_17)
-#define G_PIPE0_RX5_VALID_17(x) (((x) >> S_PIPE0_RX5_VALID_17) & M_PIPE0_RX5_VALID_17)
-
-#define S_PIPE0_RX4_VALID_17 7
-#define V_PIPE0_RX4_VALID_17(x) ((x) << S_PIPE0_RX4_VALID_17)
-#define F_PIPE0_RX4_VALID_17 V_PIPE0_RX4_VALID_17(1U)
-
-#define S_PIPE0_RX4_VALID2_17 0
-#define M_PIPE0_RX4_VALID2_17 0x7fU
-#define V_PIPE0_RX4_VALID2_17(x) ((x) << S_PIPE0_RX4_VALID2_17)
-#define G_PIPE0_RX4_VALID2_17(x) (((x) >> S_PIPE0_RX4_VALID2_17) & M_PIPE0_RX4_VALID2_17)
-
-#define A_PCIE_PDEBUG_REG_0X18 0x18
-
-#define S_PIPE0_RX7_POLARITY 31
-#define V_PIPE0_RX7_POLARITY(x) ((x) << S_PIPE0_RX7_POLARITY)
-#define F_PIPE0_RX7_POLARITY V_PIPE0_RX7_POLARITY(1U)
-
-#define S_PIPE0_RX7_STATUS 28
-#define M_PIPE0_RX7_STATUS 0x7U
-#define V_PIPE0_RX7_STATUS(x) ((x) << S_PIPE0_RX7_STATUS)
-#define G_PIPE0_RX7_STATUS(x) (((x) >> S_PIPE0_RX7_STATUS) & M_PIPE0_RX7_STATUS)
-
-#define S_PIPE0_RX6_POLARITY 27
-#define V_PIPE0_RX6_POLARITY(x) ((x) << S_PIPE0_RX6_POLARITY)
-#define F_PIPE0_RX6_POLARITY V_PIPE0_RX6_POLARITY(1U)
-
-#define S_PIPE0_RX6_STATUS 24
-#define M_PIPE0_RX6_STATUS 0x7U
-#define V_PIPE0_RX6_STATUS(x) ((x) << S_PIPE0_RX6_STATUS)
-#define G_PIPE0_RX6_STATUS(x) (((x) >> S_PIPE0_RX6_STATUS) & M_PIPE0_RX6_STATUS)
-
-#define S_PIPE0_RX5_POLARITY 23
-#define V_PIPE0_RX5_POLARITY(x) ((x) << S_PIPE0_RX5_POLARITY)
-#define F_PIPE0_RX5_POLARITY V_PIPE0_RX5_POLARITY(1U)
-
-#define S_PIPE0_RX5_STATUS 20
-#define M_PIPE0_RX5_STATUS 0x7U
-#define V_PIPE0_RX5_STATUS(x) ((x) << S_PIPE0_RX5_STATUS)
-#define G_PIPE0_RX5_STATUS(x) (((x) >> S_PIPE0_RX5_STATUS) & M_PIPE0_RX5_STATUS)
-
-#define S_PIPE0_RX4_POLARITY 19
-#define V_PIPE0_RX4_POLARITY(x) ((x) << S_PIPE0_RX4_POLARITY)
-#define F_PIPE0_RX4_POLARITY V_PIPE0_RX4_POLARITY(1U)
-
-#define S_PIPE0_RX4_STATUS 16
-#define M_PIPE0_RX4_STATUS 0x7U
-#define V_PIPE0_RX4_STATUS(x) ((x) << S_PIPE0_RX4_STATUS)
-#define G_PIPE0_RX4_STATUS(x) (((x) >> S_PIPE0_RX4_STATUS) & M_PIPE0_RX4_STATUS)
-
-#define S_PIPE0_RX3_POLARITY 15
-#define V_PIPE0_RX3_POLARITY(x) ((x) << S_PIPE0_RX3_POLARITY)
-#define F_PIPE0_RX3_POLARITY V_PIPE0_RX3_POLARITY(1U)
-
-#define S_PIPE0_RX3_STATUS 12
-#define M_PIPE0_RX3_STATUS 0x7U
-#define V_PIPE0_RX3_STATUS(x) ((x) << S_PIPE0_RX3_STATUS)
-#define G_PIPE0_RX3_STATUS(x) (((x) >> S_PIPE0_RX3_STATUS) & M_PIPE0_RX3_STATUS)
-
-#define S_PIPE0_RX2_POLARITY 11
-#define V_PIPE0_RX2_POLARITY(x) ((x) << S_PIPE0_RX2_POLARITY)
-#define F_PIPE0_RX2_POLARITY V_PIPE0_RX2_POLARITY(1U)
-
-#define S_PIPE0_RX2_STATUS 8
-#define M_PIPE0_RX2_STATUS 0x7U
-#define V_PIPE0_RX2_STATUS(x) ((x) << S_PIPE0_RX2_STATUS)
-#define G_PIPE0_RX2_STATUS(x) (((x) >> S_PIPE0_RX2_STATUS) & M_PIPE0_RX2_STATUS)
-
-#define S_PIPE0_RX1_POLARITY 7
-#define V_PIPE0_RX1_POLARITY(x) ((x) << S_PIPE0_RX1_POLARITY)
-#define F_PIPE0_RX1_POLARITY V_PIPE0_RX1_POLARITY(1U)
-
-#define S_PIPE0_RX1_STATUS 4
-#define M_PIPE0_RX1_STATUS 0x7U
-#define V_PIPE0_RX1_STATUS(x) ((x) << S_PIPE0_RX1_STATUS)
-#define G_PIPE0_RX1_STATUS(x) (((x) >> S_PIPE0_RX1_STATUS) & M_PIPE0_RX1_STATUS)
-
-#define S_PIPE0_RX0_POLARITY 3
-#define V_PIPE0_RX0_POLARITY(x) ((x) << S_PIPE0_RX0_POLARITY)
-#define F_PIPE0_RX0_POLARITY V_PIPE0_RX0_POLARITY(1U)
-
-#define S_PIPE0_RX0_STATUS 0
-#define M_PIPE0_RX0_STATUS 0x7U
-#define V_PIPE0_RX0_STATUS(x) ((x) << S_PIPE0_RX0_STATUS)
-#define G_PIPE0_RX0_STATUS(x) (((x) >> S_PIPE0_RX0_STATUS) & M_PIPE0_RX0_STATUS)
-
-#define A_PCIE_PDEBUG_REG_0X19 0x19
-
-#define S_PIPE0_TX7_COMPLIANCE 31
-#define V_PIPE0_TX7_COMPLIANCE(x) ((x) << S_PIPE0_TX7_COMPLIANCE)
-#define F_PIPE0_TX7_COMPLIANCE V_PIPE0_TX7_COMPLIANCE(1U)
-
-#define S_PIPE0_TX6_COMPLIANCE 30
-#define V_PIPE0_TX6_COMPLIANCE(x) ((x) << S_PIPE0_TX6_COMPLIANCE)
-#define F_PIPE0_TX6_COMPLIANCE V_PIPE0_TX6_COMPLIANCE(1U)
-
-#define S_PIPE0_TX5_COMPLIANCE 29
-#define V_PIPE0_TX5_COMPLIANCE(x) ((x) << S_PIPE0_TX5_COMPLIANCE)
-#define F_PIPE0_TX5_COMPLIANCE V_PIPE0_TX5_COMPLIANCE(1U)
-
-#define S_PIPE0_TX4_COMPLIANCE 28
-#define V_PIPE0_TX4_COMPLIANCE(x) ((x) << S_PIPE0_TX4_COMPLIANCE)
-#define F_PIPE0_TX4_COMPLIANCE V_PIPE0_TX4_COMPLIANCE(1U)
-
-#define S_PIPE0_TX3_COMPLIANCE 27
-#define V_PIPE0_TX3_COMPLIANCE(x) ((x) << S_PIPE0_TX3_COMPLIANCE)
-#define F_PIPE0_TX3_COMPLIANCE V_PIPE0_TX3_COMPLIANCE(1U)
-
-#define S_PIPE0_TX2_COMPLIANCE 26
-#define V_PIPE0_TX2_COMPLIANCE(x) ((x) << S_PIPE0_TX2_COMPLIANCE)
-#define F_PIPE0_TX2_COMPLIANCE V_PIPE0_TX2_COMPLIANCE(1U)
-
-#define S_PIPE0_TX1_COMPLIANCE 25
-#define V_PIPE0_TX1_COMPLIANCE(x) ((x) << S_PIPE0_TX1_COMPLIANCE)
-#define F_PIPE0_TX1_COMPLIANCE V_PIPE0_TX1_COMPLIANCE(1U)
-
-#define S_PIPE0_TX0_COMPLIANCE 24
-#define V_PIPE0_TX0_COMPLIANCE(x) ((x) << S_PIPE0_TX0_COMPLIANCE)
-#define F_PIPE0_TX0_COMPLIANCE V_PIPE0_TX0_COMPLIANCE(1U)
-
-#define S_PIPE0_TX7_ELECIDLE 23
-#define V_PIPE0_TX7_ELECIDLE(x) ((x) << S_PIPE0_TX7_ELECIDLE)
-#define F_PIPE0_TX7_ELECIDLE V_PIPE0_TX7_ELECIDLE(1U)
-
-#define S_PIPE0_TX6_ELECIDLE 22
-#define V_PIPE0_TX6_ELECIDLE(x) ((x) << S_PIPE0_TX6_ELECIDLE)
-#define F_PIPE0_TX6_ELECIDLE V_PIPE0_TX6_ELECIDLE(1U)
-
-#define S_PIPE0_TX5_ELECIDLE 21
-#define V_PIPE0_TX5_ELECIDLE(x) ((x) << S_PIPE0_TX5_ELECIDLE)
-#define F_PIPE0_TX5_ELECIDLE V_PIPE0_TX5_ELECIDLE(1U)
-
-#define S_PIPE0_TX4_ELECIDLE 20
-#define V_PIPE0_TX4_ELECIDLE(x) ((x) << S_PIPE0_TX4_ELECIDLE)
-#define F_PIPE0_TX4_ELECIDLE V_PIPE0_TX4_ELECIDLE(1U)
-
-#define S_PIPE0_TX3_ELECIDLE 19
-#define V_PIPE0_TX3_ELECIDLE(x) ((x) << S_PIPE0_TX3_ELECIDLE)
-#define F_PIPE0_TX3_ELECIDLE V_PIPE0_TX3_ELECIDLE(1U)
-
-#define S_PIPE0_TX2_ELECIDLE 18
-#define V_PIPE0_TX2_ELECIDLE(x) ((x) << S_PIPE0_TX2_ELECIDLE)
-#define F_PIPE0_TX2_ELECIDLE V_PIPE0_TX2_ELECIDLE(1U)
-
-#define S_PIPE0_TX1_ELECIDLE 17
-#define V_PIPE0_TX1_ELECIDLE(x) ((x) << S_PIPE0_TX1_ELECIDLE)
-#define F_PIPE0_TX1_ELECIDLE V_PIPE0_TX1_ELECIDLE(1U)
-
-#define S_PIPE0_TX0_ELECIDLE 16
-#define V_PIPE0_TX0_ELECIDLE(x) ((x) << S_PIPE0_TX0_ELECIDLE)
-#define F_PIPE0_TX0_ELECIDLE V_PIPE0_TX0_ELECIDLE(1U)
-
-#define S_PIPE0_RX7_POLARITY_19 15
-#define V_PIPE0_RX7_POLARITY_19(x) ((x) << S_PIPE0_RX7_POLARITY_19)
-#define F_PIPE0_RX7_POLARITY_19 V_PIPE0_RX7_POLARITY_19(1U)
-
-#define S_PIPE0_RX6_POLARITY_19 14
-#define V_PIPE0_RX6_POLARITY_19(x) ((x) << S_PIPE0_RX6_POLARITY_19)
-#define F_PIPE0_RX6_POLARITY_19 V_PIPE0_RX6_POLARITY_19(1U)
-
-#define S_PIPE0_RX5_POLARITY_19 13
-#define V_PIPE0_RX5_POLARITY_19(x) ((x) << S_PIPE0_RX5_POLARITY_19)
-#define F_PIPE0_RX5_POLARITY_19 V_PIPE0_RX5_POLARITY_19(1U)
-
-#define S_PIPE0_RX4_POLARITY_19 12
-#define V_PIPE0_RX4_POLARITY_19(x) ((x) << S_PIPE0_RX4_POLARITY_19)
-#define F_PIPE0_RX4_POLARITY_19 V_PIPE0_RX4_POLARITY_19(1U)
-
-#define S_PIPE0_RX3_POLARITY_19 11
-#define V_PIPE0_RX3_POLARITY_19(x) ((x) << S_PIPE0_RX3_POLARITY_19)
-#define F_PIPE0_RX3_POLARITY_19 V_PIPE0_RX3_POLARITY_19(1U)
-
-#define S_PIPE0_RX2_POLARITY_19 10
-#define V_PIPE0_RX2_POLARITY_19(x) ((x) << S_PIPE0_RX2_POLARITY_19)
-#define F_PIPE0_RX2_POLARITY_19 V_PIPE0_RX2_POLARITY_19(1U)
-
-#define S_PIPE0_RX1_POLARITY_19 9
-#define V_PIPE0_RX1_POLARITY_19(x) ((x) << S_PIPE0_RX1_POLARITY_19)
-#define F_PIPE0_RX1_POLARITY_19 V_PIPE0_RX1_POLARITY_19(1U)
-
-#define S_PIPE0_RX0_POLARITY_19 8
-#define V_PIPE0_RX0_POLARITY_19(x) ((x) << S_PIPE0_RX0_POLARITY_19)
-#define F_PIPE0_RX0_POLARITY_19 V_PIPE0_RX0_POLARITY_19(1U)
-
-#define S_PIPE0_RX7_ELECIDLE 7
-#define V_PIPE0_RX7_ELECIDLE(x) ((x) << S_PIPE0_RX7_ELECIDLE)
-#define F_PIPE0_RX7_ELECIDLE V_PIPE0_RX7_ELECIDLE(1U)
-
-#define S_PIPE0_RX6_ELECIDLE 6
-#define V_PIPE0_RX6_ELECIDLE(x) ((x) << S_PIPE0_RX6_ELECIDLE)
-#define F_PIPE0_RX6_ELECIDLE V_PIPE0_RX6_ELECIDLE(1U)
-
-#define S_PIPE0_RX5_ELECIDLE 5
-#define V_PIPE0_RX5_ELECIDLE(x) ((x) << S_PIPE0_RX5_ELECIDLE)
-#define F_PIPE0_RX5_ELECIDLE V_PIPE0_RX5_ELECIDLE(1U)
-
-#define S_PIPE0_RX4_ELECIDLE 4
-#define V_PIPE0_RX4_ELECIDLE(x) ((x) << S_PIPE0_RX4_ELECIDLE)
-#define F_PIPE0_RX4_ELECIDLE V_PIPE0_RX4_ELECIDLE(1U)
-
-#define S_PIPE0_RX3_ELECIDLE 3
-#define V_PIPE0_RX3_ELECIDLE(x) ((x) << S_PIPE0_RX3_ELECIDLE)
-#define F_PIPE0_RX3_ELECIDLE V_PIPE0_RX3_ELECIDLE(1U)
-
-#define S_PIPE0_RX2_ELECIDLE 2
-#define V_PIPE0_RX2_ELECIDLE(x) ((x) << S_PIPE0_RX2_ELECIDLE)
-#define F_PIPE0_RX2_ELECIDLE V_PIPE0_RX2_ELECIDLE(1U)
-
-#define S_PIPE0_RX1_ELECIDLE 1
-#define V_PIPE0_RX1_ELECIDLE(x) ((x) << S_PIPE0_RX1_ELECIDLE)
-#define F_PIPE0_RX1_ELECIDLE V_PIPE0_RX1_ELECIDLE(1U)
-
-#define S_PIPE0_RX0_ELECIDLE 0
-#define V_PIPE0_RX0_ELECIDLE(x) ((x) << S_PIPE0_RX0_ELECIDLE)
-#define F_PIPE0_RX0_ELECIDLE V_PIPE0_RX0_ELECIDLE(1U)
-
-#define A_PCIE_PDEBUG_REG_0X1A 0x1a
-
-#define S_PIPE0_RESET_N 21
-#define V_PIPE0_RESET_N(x) ((x) << S_PIPE0_RESET_N)
-#define F_PIPE0_RESET_N V_PIPE0_RESET_N(1U)
-
-#define S_PCS_COMMON_CLOCKS 20
-#define V_PCS_COMMON_CLOCKS(x) ((x) << S_PCS_COMMON_CLOCKS)
-#define F_PCS_COMMON_CLOCKS V_PCS_COMMON_CLOCKS(1U)
-
-#define S_PCS_CLK_REQ 19
-#define V_PCS_CLK_REQ(x) ((x) << S_PCS_CLK_REQ)
-#define F_PCS_CLK_REQ V_PCS_CLK_REQ(1U)
-
-#define S_PIPE_CLKREQ_N 18
-#define V_PIPE_CLKREQ_N(x) ((x) << S_PIPE_CLKREQ_N)
-#define F_PIPE_CLKREQ_N V_PIPE_CLKREQ_N(1U)
-
-#define S_MAC_CLKREQ_N_TO_MUX 17
-#define V_MAC_CLKREQ_N_TO_MUX(x) ((x) << S_MAC_CLKREQ_N_TO_MUX)
-#define F_MAC_CLKREQ_N_TO_MUX V_MAC_CLKREQ_N_TO_MUX(1U)
-
-#define S_PIPE0_TX2RX_LOOPBK 16
-#define V_PIPE0_TX2RX_LOOPBK(x) ((x) << S_PIPE0_TX2RX_LOOPBK)
-#define F_PIPE0_TX2RX_LOOPBK V_PIPE0_TX2RX_LOOPBK(1U)
-
-#define S_PIPE0_TX_SWING 15
-#define V_PIPE0_TX_SWING(x) ((x) << S_PIPE0_TX_SWING)
-#define F_PIPE0_TX_SWING V_PIPE0_TX_SWING(1U)
-
-#define S_PIPE0_TX_MARGIN 12
-#define M_PIPE0_TX_MARGIN 0x7U
-#define V_PIPE0_TX_MARGIN(x) ((x) << S_PIPE0_TX_MARGIN)
-#define G_PIPE0_TX_MARGIN(x) (((x) >> S_PIPE0_TX_MARGIN) & M_PIPE0_TX_MARGIN)
-
-#define S_PIPE0_TX_DEEMPH 11
-#define V_PIPE0_TX_DEEMPH(x) ((x) << S_PIPE0_TX_DEEMPH)
-#define F_PIPE0_TX_DEEMPH V_PIPE0_TX_DEEMPH(1U)
-
-#define S_PIPE0_TX_DETECTRX 10
-#define V_PIPE0_TX_DETECTRX(x) ((x) << S_PIPE0_TX_DETECTRX)
-#define F_PIPE0_TX_DETECTRX V_PIPE0_TX_DETECTRX(1U)
-
-#define S_PIPE0_POWERDOWN 8
-#define M_PIPE0_POWERDOWN 0x3U
-#define V_PIPE0_POWERDOWN(x) ((x) << S_PIPE0_POWERDOWN)
-#define G_PIPE0_POWERDOWN(x) (((x) >> S_PIPE0_POWERDOWN) & M_PIPE0_POWERDOWN)
-
-#define S_PHY_MAC_PHYSTATUS 0
-#define M_PHY_MAC_PHYSTATUS 0xffU
-#define V_PHY_MAC_PHYSTATUS(x) ((x) << S_PHY_MAC_PHYSTATUS)
-#define G_PHY_MAC_PHYSTATUS(x) (((x) >> S_PHY_MAC_PHYSTATUS) & M_PHY_MAC_PHYSTATUS)
-
-#define A_PCIE_PDEBUG_REG_0X1B 0x1b
-
-#define S_PIPE0_RX7_EQ_IN_PROG 31
-#define V_PIPE0_RX7_EQ_IN_PROG(x) ((x) << S_PIPE0_RX7_EQ_IN_PROG)
-#define F_PIPE0_RX7_EQ_IN_PROG V_PIPE0_RX7_EQ_IN_PROG(1U)
-
-#define S_PIPE0_RX7_EQ_INVLD_REQ 30
-#define V_PIPE0_RX7_EQ_INVLD_REQ(x) ((x) << S_PIPE0_RX7_EQ_INVLD_REQ)
-#define F_PIPE0_RX7_EQ_INVLD_REQ V_PIPE0_RX7_EQ_INVLD_REQ(1U)
-
-#define S_PIPE0_RX7_SYNCHEADER 28
-#define M_PIPE0_RX7_SYNCHEADER 0x3U
-#define V_PIPE0_RX7_SYNCHEADER(x) ((x) << S_PIPE0_RX7_SYNCHEADER)
-#define G_PIPE0_RX7_SYNCHEADER(x) (((x) >> S_PIPE0_RX7_SYNCHEADER) & M_PIPE0_RX7_SYNCHEADER)
-
-#define S_PIPE0_RX6_EQ_IN_PROG 27
-#define V_PIPE0_RX6_EQ_IN_PROG(x) ((x) << S_PIPE0_RX6_EQ_IN_PROG)
-#define F_PIPE0_RX6_EQ_IN_PROG V_PIPE0_RX6_EQ_IN_PROG(1U)
-
-#define S_PIPE0_RX6_EQ_INVLD_REQ 26
-#define V_PIPE0_RX6_EQ_INVLD_REQ(x) ((x) << S_PIPE0_RX6_EQ_INVLD_REQ)
-#define F_PIPE0_RX6_EQ_INVLD_REQ V_PIPE0_RX6_EQ_INVLD_REQ(1U)
-
-#define S_PIPE0_RX6_SYNCHEADER 24
-#define M_PIPE0_RX6_SYNCHEADER 0x3U
-#define V_PIPE0_RX6_SYNCHEADER(x) ((x) << S_PIPE0_RX6_SYNCHEADER)
-#define G_PIPE0_RX6_SYNCHEADER(x) (((x) >> S_PIPE0_RX6_SYNCHEADER) & M_PIPE0_RX6_SYNCHEADER)
-
-#define S_PIPE0_RX5_EQ_IN_PROG 23
-#define V_PIPE0_RX5_EQ_IN_PROG(x) ((x) << S_PIPE0_RX5_EQ_IN_PROG)
-#define F_PIPE0_RX5_EQ_IN_PROG V_PIPE0_RX5_EQ_IN_PROG(1U)
-
-#define S_PIPE0_RX5_EQ_INVLD_REQ 22
-#define V_PIPE0_RX5_EQ_INVLD_REQ(x) ((x) << S_PIPE0_RX5_EQ_INVLD_REQ)
-#define F_PIPE0_RX5_EQ_INVLD_REQ V_PIPE0_RX5_EQ_INVLD_REQ(1U)
-
-#define S_PIPE0_RX5_SYNCHEADER 20
-#define M_PIPE0_RX5_SYNCHEADER 0x3U
-#define V_PIPE0_RX5_SYNCHEADER(x) ((x) << S_PIPE0_RX5_SYNCHEADER)
-#define G_PIPE0_RX5_SYNCHEADER(x) (((x) >> S_PIPE0_RX5_SYNCHEADER) & M_PIPE0_RX5_SYNCHEADER)
-
-#define S_PIPE0_RX4_EQ_IN_PROG 19
-#define V_PIPE0_RX4_EQ_IN_PROG(x) ((x) << S_PIPE0_RX4_EQ_IN_PROG)
-#define F_PIPE0_RX4_EQ_IN_PROG V_PIPE0_RX4_EQ_IN_PROG(1U)
-
-#define S_PIPE0_RX4_EQ_INVLD_REQ 18
-#define V_PIPE0_RX4_EQ_INVLD_REQ(x) ((x) << S_PIPE0_RX4_EQ_INVLD_REQ)
-#define F_PIPE0_RX4_EQ_INVLD_REQ V_PIPE0_RX4_EQ_INVLD_REQ(1U)
-
-#define S_PIPE0_RX4_SYNCHEADER 16
-#define M_PIPE0_RX4_SYNCHEADER 0x3U
-#define V_PIPE0_RX4_SYNCHEADER(x) ((x) << S_PIPE0_RX4_SYNCHEADER)
-#define G_PIPE0_RX4_SYNCHEADER(x) (((x) >> S_PIPE0_RX4_SYNCHEADER) & M_PIPE0_RX4_SYNCHEADER)
-
-#define S_PIPE0_RX3_EQ_IN_PROG 15
-#define V_PIPE0_RX3_EQ_IN_PROG(x) ((x) << S_PIPE0_RX3_EQ_IN_PROG)
-#define F_PIPE0_RX3_EQ_IN_PROG V_PIPE0_RX3_EQ_IN_PROG(1U)
-
-#define S_PIPE0_RX3_EQ_INVLD_REQ 14
-#define V_PIPE0_RX3_EQ_INVLD_REQ(x) ((x) << S_PIPE0_RX3_EQ_INVLD_REQ)
-#define F_PIPE0_RX3_EQ_INVLD_REQ V_PIPE0_RX3_EQ_INVLD_REQ(1U)
-
-#define S_PIPE0_RX3_SYNCHEADER 12
-#define M_PIPE0_RX3_SYNCHEADER 0x3U
-#define V_PIPE0_RX3_SYNCHEADER(x) ((x) << S_PIPE0_RX3_SYNCHEADER)
-#define G_PIPE0_RX3_SYNCHEADER(x) (((x) >> S_PIPE0_RX3_SYNCHEADER) & M_PIPE0_RX3_SYNCHEADER)
-
-#define S_PIPE0_RX2_EQ_IN_PROG 11
-#define V_PIPE0_RX2_EQ_IN_PROG(x) ((x) << S_PIPE0_RX2_EQ_IN_PROG)
-#define F_PIPE0_RX2_EQ_IN_PROG V_PIPE0_RX2_EQ_IN_PROG(1U)
-
-#define S_PIPE0_RX2_EQ_INVLD_REQ 10
-#define V_PIPE0_RX2_EQ_INVLD_REQ(x) ((x) << S_PIPE0_RX2_EQ_INVLD_REQ)
-#define F_PIPE0_RX2_EQ_INVLD_REQ V_PIPE0_RX2_EQ_INVLD_REQ(1U)
-
-#define S_PIPE0_RX2_SYNCHEADER 8
-#define M_PIPE0_RX2_SYNCHEADER 0x3U
-#define V_PIPE0_RX2_SYNCHEADER(x) ((x) << S_PIPE0_RX2_SYNCHEADER)
-#define G_PIPE0_RX2_SYNCHEADER(x) (((x) >> S_PIPE0_RX2_SYNCHEADER) & M_PIPE0_RX2_SYNCHEADER)
-
-#define S_PIPE0_RX1_EQ_IN_PROG 7
-#define V_PIPE0_RX1_EQ_IN_PROG(x) ((x) << S_PIPE0_RX1_EQ_IN_PROG)
-#define F_PIPE0_RX1_EQ_IN_PROG V_PIPE0_RX1_EQ_IN_PROG(1U)
-
-#define S_PIPE0_RX1_EQ_INVLD_REQ 6
-#define V_PIPE0_RX1_EQ_INVLD_REQ(x) ((x) << S_PIPE0_RX1_EQ_INVLD_REQ)
-#define F_PIPE0_RX1_EQ_INVLD_REQ V_PIPE0_RX1_EQ_INVLD_REQ(1U)
-
-#define S_PIPE0_RX1_SYNCHEADER 4
-#define M_PIPE0_RX1_SYNCHEADER 0x3U
-#define V_PIPE0_RX1_SYNCHEADER(x) ((x) << S_PIPE0_RX1_SYNCHEADER)
-#define G_PIPE0_RX1_SYNCHEADER(x) (((x) >> S_PIPE0_RX1_SYNCHEADER) & M_PIPE0_RX1_SYNCHEADER)
-
-#define S_PIPE0_RX0_EQ_IN_PROG 3
-#define V_PIPE0_RX0_EQ_IN_PROG(x) ((x) << S_PIPE0_RX0_EQ_IN_PROG)
-#define F_PIPE0_RX0_EQ_IN_PROG V_PIPE0_RX0_EQ_IN_PROG(1U)
-
-#define S_PIPE0_RX0_EQ_INVLD_REQ 2
-#define V_PIPE0_RX0_EQ_INVLD_REQ(x) ((x) << S_PIPE0_RX0_EQ_INVLD_REQ)
-#define F_PIPE0_RX0_EQ_INVLD_REQ V_PIPE0_RX0_EQ_INVLD_REQ(1U)
-
-#define S_PIPE0_RX0_SYNCHEADER 0
-#define M_PIPE0_RX0_SYNCHEADER 0x3U
-#define V_PIPE0_RX0_SYNCHEADER(x) ((x) << S_PIPE0_RX0_SYNCHEADER)
-#define G_PIPE0_RX0_SYNCHEADER(x) (((x) >> S_PIPE0_RX0_SYNCHEADER) & M_PIPE0_RX0_SYNCHEADER)
-
-#define A_PCIE_PDEBUG_REG_0X1C 0x1c
-
-#define S_SI_REQVFID 24
-#define M_SI_REQVFID 0xffU
-#define V_SI_REQVFID(x) ((x) << S_SI_REQVFID)
-#define G_SI_REQVFID(x) (((x) >> S_SI_REQVFID) & M_SI_REQVFID)
-
-#define S_SI_REQVEC 13
-#define M_SI_REQVEC 0x7ffU
-#define V_SI_REQVEC(x) ((x) << S_SI_REQVEC)
-#define G_SI_REQVEC(x) (((x) >> S_SI_REQVEC) & M_SI_REQVEC)
-
-#define S_SI_REQTCVAL 10
-#define M_SI_REQTCVAL 0x7U
-#define V_SI_REQTCVAL(x) ((x) << S_SI_REQTCVAL)
-#define G_SI_REQTCVAL(x) (((x) >> S_SI_REQTCVAL) & M_SI_REQTCVAL)
-
-#define S_SI_REQRDY 9
-#define V_SI_REQRDY(x) ((x) << S_SI_REQRDY)
-#define F_SI_REQRDY V_SI_REQRDY(1U)
-
-#define S_SI_REQVLD 8
-#define V_SI_REQVLD(x) ((x) << S_SI_REQVLD)
-#define F_SI_REQVLD V_SI_REQVLD(1U)
-
-#define S_T5_AI 0
-#define M_T5_AI 0xffU
-#define V_T5_AI(x) ((x) << S_T5_AI)
-#define G_T5_AI(x) (((x) >> S_T5_AI) & M_T5_AI)
-
-#define A_PCIE_PDEBUG_REG_0X1D 0x1d
-
-#define S_GNTSI 31
-#define V_GNTSI(x) ((x) << S_GNTSI)
-#define F_GNTSI V_GNTSI(1U)
-
-#define S_DROPINTFORFLR 30
-#define V_DROPINTFORFLR(x) ((x) << S_DROPINTFORFLR)
-#define F_DROPINTFORFLR V_DROPINTFORFLR(1U)
-
-#define S_SMARB 27
-#define M_SMARB 0x7U
-#define V_SMARB(x) ((x) << S_SMARB)
-#define G_SMARB(x) (((x) >> S_SMARB) & M_SMARB)
-
-#define S_SMDEFR 24
-#define M_SMDEFR 0x7U
-#define V_SMDEFR(x) ((x) << S_SMDEFR)
-#define G_SMDEFR(x) (((x) >> S_SMDEFR) & M_SMDEFR)
-
-#define S_SYS_INT 16
-#define M_SYS_INT 0xffU
-#define V_SYS_INT(x) ((x) << S_SYS_INT)
-#define G_SYS_INT(x) (((x) >> S_SYS_INT) & M_SYS_INT)
-
-#define S_CFG_INTXCLR 8
-#define M_CFG_INTXCLR 0xffU
-#define V_CFG_INTXCLR(x) ((x) << S_CFG_INTXCLR)
-#define G_CFG_INTXCLR(x) (((x) >> S_CFG_INTXCLR) & M_CFG_INTXCLR)
-
-#define S_PIO_INTXCLR 0
-#define M_PIO_INTXCLR 0xffU
-#define V_PIO_INTXCLR(x) ((x) << S_PIO_INTXCLR)
-#define G_PIO_INTXCLR(x) (((x) >> S_PIO_INTXCLR) & M_PIO_INTXCLR)
-
-#define A_PCIE_PDEBUG_REG_0X1E 0x1e
-
-#define S_PLI_TABDATWREN 31
-#define V_PLI_TABDATWREN(x) ((x) << S_PLI_TABDATWREN)
-#define F_PLI_TABDATWREN V_PLI_TABDATWREN(1U)
-
-#define S_TAB_RDENA 30
-#define V_TAB_RDENA(x) ((x) << S_TAB_RDENA)
-#define F_TAB_RDENA V_TAB_RDENA(1U)
-
-#define S_TAB_RDENA2 19
-#define M_TAB_RDENA2 0x7ffU
-#define V_TAB_RDENA2(x) ((x) << S_TAB_RDENA2)
-#define G_TAB_RDENA2(x) (((x) >> S_TAB_RDENA2) & M_TAB_RDENA2)
-
-#define S_PLI_REQADDR 10
-#define M_PLI_REQADDR 0x1ffU
-#define V_PLI_REQADDR(x) ((x) << S_PLI_REQADDR)
-#define G_PLI_REQADDR(x) (((x) >> S_PLI_REQADDR) & M_PLI_REQADDR)
-
-#define S_PLI_REQVFID 2
-#define M_PLI_REQVFID 0xffU
-#define V_PLI_REQVFID(x) ((x) << S_PLI_REQVFID)
-#define G_PLI_REQVFID(x) (((x) >> S_PLI_REQVFID) & M_PLI_REQVFID)
-
-#define S_PLI_REQTABHIT 1
-#define V_PLI_REQTABHIT(x) ((x) << S_PLI_REQTABHIT)
-#define F_PLI_REQTABHIT V_PLI_REQTABHIT(1U)
-
-#define S_PLI_REQRDVLD 0
-#define V_PLI_REQRDVLD(x) ((x) << S_PLI_REQRDVLD)
-#define F_PLI_REQRDVLD V_PLI_REQRDVLD(1U)
-
-#define A_PCIE_PDEBUG_REG_0X1F 0x1f
-#define A_PCIE_PDEBUG_REG_0X20 0x20
-#define A_PCIE_PDEBUG_REG_0X21 0x21
-
-#define S_PLI_REQPBASTART 20
-#define M_PLI_REQPBASTART 0xfffU
-#define V_PLI_REQPBASTART(x) ((x) << S_PLI_REQPBASTART)
-#define G_PLI_REQPBASTART(x) (((x) >> S_PLI_REQPBASTART) & M_PLI_REQPBASTART)
-
-#define S_PLI_REQPBAEND 9
-#define M_PLI_REQPBAEND 0x7ffU
-#define V_PLI_REQPBAEND(x) ((x) << S_PLI_REQPBAEND)
-#define G_PLI_REQPBAEND(x) (((x) >> S_PLI_REQPBAEND) & M_PLI_REQPBAEND)
-
-#define S_T5_PLI_REQVFID 2
-#define M_T5_PLI_REQVFID 0x7fU
-#define V_T5_PLI_REQVFID(x) ((x) << S_T5_PLI_REQVFID)
-#define G_T5_PLI_REQVFID(x) (((x) >> S_T5_PLI_REQVFID) & M_T5_PLI_REQVFID)
-
-#define S_PLI_REQPBAHIT 1
-#define V_PLI_REQPBAHIT(x) ((x) << S_PLI_REQPBAHIT)
-#define F_PLI_REQPBAHIT V_PLI_REQPBAHIT(1U)
-
-#define A_PCIE_PDEBUG_REG_0X22 0x22
-
-#define S_GNTSI1 31
-#define V_GNTSI1(x) ((x) << S_GNTSI1)
-#define F_GNTSI1 V_GNTSI1(1U)
-
-#define S_GNTSI2 30
-#define V_GNTSI2(x) ((x) << S_GNTSI2)
-#define F_GNTSI2 V_GNTSI2(1U)
-
-#define S_GNTSI3 27
-#define M_GNTSI3 0x7U
-#define V_GNTSI3(x) ((x) << S_GNTSI3)
-#define G_GNTSI3(x) (((x) >> S_GNTSI3) & M_GNTSI3)
-
-#define S_GNTSI4 16
-#define M_GNTSI4 0x7ffU
-#define V_GNTSI4(x) ((x) << S_GNTSI4)
-#define G_GNTSI4(x) (((x) >> S_GNTSI4) & M_GNTSI4)
-
-#define S_GNTSI5 8
-#define M_GNTSI5 0xffU
-#define V_GNTSI5(x) ((x) << S_GNTSI5)
-#define G_GNTSI5(x) (((x) >> S_GNTSI5) & M_GNTSI5)
-
-#define S_GNTSI6 7
-#define V_GNTSI6(x) ((x) << S_GNTSI6)
-#define F_GNTSI6 V_GNTSI6(1U)
-
-#define S_GNTSI7 6
-#define V_GNTSI7(x) ((x) << S_GNTSI7)
-#define F_GNTSI7 V_GNTSI7(1U)
-
-#define S_GNTSI8 5
-#define V_GNTSI8(x) ((x) << S_GNTSI8)
-#define F_GNTSI8 V_GNTSI8(1U)
-
-#define S_GNTSI9 4
-#define V_GNTSI9(x) ((x) << S_GNTSI9)
-#define F_GNTSI9 V_GNTSI9(1U)
-
-#define S_GNTSIA 3
-#define V_GNTSIA(x) ((x) << S_GNTSIA)
-#define F_GNTSIA V_GNTSIA(1U)
-
-#define S_GNTAI 2
-#define V_GNTAI(x) ((x) << S_GNTAI)
-#define F_GNTAI V_GNTAI(1U)
-
-#define S_GNTDB 1
-#define V_GNTDB(x) ((x) << S_GNTDB)
-#define F_GNTDB V_GNTDB(1U)
-
-#define S_GNTDI 0
-#define V_GNTDI(x) ((x) << S_GNTDI)
-#define F_GNTDI V_GNTDI(1U)
-
-#define A_PCIE_PDEBUG_REG_0X23 0x23
-
-#define S_DI_REQVLD 31
-#define V_DI_REQVLD(x) ((x) << S_DI_REQVLD)
-#define F_DI_REQVLD V_DI_REQVLD(1U)
-
-#define S_DI_REQRDY 30
-#define V_DI_REQRDY(x) ((x) << S_DI_REQRDY)
-#define F_DI_REQRDY V_DI_REQRDY(1U)
-
-#define S_DI_REQWREN 19
-#define M_DI_REQWREN 0x7ffU
-#define V_DI_REQWREN(x) ((x) << S_DI_REQWREN)
-#define G_DI_REQWREN(x) (((x) >> S_DI_REQWREN) & M_DI_REQWREN)
-
-#define S_DI_REQMSIEN 18
-#define V_DI_REQMSIEN(x) ((x) << S_DI_REQMSIEN)
-#define F_DI_REQMSIEN V_DI_REQMSIEN(1U)
-
-#define S_DI_REQMSXEN 17
-#define V_DI_REQMSXEN(x) ((x) << S_DI_REQMSXEN)
-#define F_DI_REQMSXEN V_DI_REQMSXEN(1U)
-
-#define S_DI_REQMSXVFIDMSK 16
-#define V_DI_REQMSXVFIDMSK(x) ((x) << S_DI_REQMSXVFIDMSK)
-#define F_DI_REQMSXVFIDMSK V_DI_REQMSXVFIDMSK(1U)
-
-#define S_DI_REQWREN2 2
-#define M_DI_REQWREN2 0x3fffU
-#define V_DI_REQWREN2(x) ((x) << S_DI_REQWREN2)
-#define G_DI_REQWREN2(x) (((x) >> S_DI_REQWREN2) & M_DI_REQWREN2)
-
-#define S_DI_REQRDEN 1
-#define V_DI_REQRDEN(x) ((x) << S_DI_REQRDEN)
-#define F_DI_REQRDEN V_DI_REQRDEN(1U)
-
-#define S_DI_REQWREN3 0
-#define V_DI_REQWREN3(x) ((x) << S_DI_REQWREN3)
-#define F_DI_REQWREN3 V_DI_REQWREN3(1U)
-
-#define A_PCIE_PDEBUG_REG_0X24 0x24
-#define A_PCIE_PDEBUG_REG_0X25 0x25
-#define A_PCIE_PDEBUG_REG_0X26 0x26
-#define A_PCIE_PDEBUG_REG_0X27 0x27
-
-#define S_FID_STI_RSPVLD 31
-#define V_FID_STI_RSPVLD(x) ((x) << S_FID_STI_RSPVLD)
-#define F_FID_STI_RSPVLD V_FID_STI_RSPVLD(1U)
-
-#define S_TAB_STIRDENA 30
-#define V_TAB_STIRDENA(x) ((x) << S_TAB_STIRDENA)
-#define F_TAB_STIRDENA V_TAB_STIRDENA(1U)
-
-#define S_TAB_STIWRENA 29
-#define V_TAB_STIWRENA(x) ((x) << S_TAB_STIWRENA)
-#define F_TAB_STIWRENA V_TAB_STIWRENA(1U)
-
-#define S_TAB_STIRDENA2 18
-#define M_TAB_STIRDENA2 0x7ffU
-#define V_TAB_STIRDENA2(x) ((x) << S_TAB_STIRDENA2)
-#define G_TAB_STIRDENA2(x) (((x) >> S_TAB_STIRDENA2) & M_TAB_STIRDENA2)
-
-#define S_T5_PLI_REQTABHIT 7
-#define M_T5_PLI_REQTABHIT 0x7ffU
-#define V_T5_PLI_REQTABHIT(x) ((x) << S_T5_PLI_REQTABHIT)
-#define G_T5_PLI_REQTABHIT(x) (((x) >> S_T5_PLI_REQTABHIT) & M_T5_PLI_REQTABHIT)
-
-#define S_T5_GNTSI 0
-#define M_T5_GNTSI 0x7fU
-#define V_T5_GNTSI(x) ((x) << S_T5_GNTSI)
-#define G_T5_GNTSI(x) (((x) >> S_T5_GNTSI) & M_T5_GNTSI)
-
-#define A_PCIE_PDEBUG_REG_0X28 0x28
-
-#define S_PLI_REQWRVLD 31
-#define V_PLI_REQWRVLD(x) ((x) << S_PLI_REQWRVLD)
-#define F_PLI_REQWRVLD V_PLI_REQWRVLD(1U)
-
-#define S_T5_PLI_REQPBAHIT 30
-#define V_T5_PLI_REQPBAHIT(x) ((x) << S_T5_PLI_REQPBAHIT)
-#define F_T5_PLI_REQPBAHIT V_T5_PLI_REQPBAHIT(1U)
-
-#define S_PLI_TABADDRLWREN 29
-#define V_PLI_TABADDRLWREN(x) ((x) << S_PLI_TABADDRLWREN)
-#define F_PLI_TABADDRLWREN V_PLI_TABADDRLWREN(1U)
-
-#define S_PLI_TABADDRHWREN 28
-#define V_PLI_TABADDRHWREN(x) ((x) << S_PLI_TABADDRHWREN)
-#define F_PLI_TABADDRHWREN V_PLI_TABADDRHWREN(1U)
-
-#define S_T5_PLI_TABDATWREN 27
-#define V_T5_PLI_TABDATWREN(x) ((x) << S_T5_PLI_TABDATWREN)
-#define F_T5_PLI_TABDATWREN V_T5_PLI_TABDATWREN(1U)
-
-#define S_PLI_TABMSKWREN 26
-#define V_PLI_TABMSKWREN(x) ((x) << S_PLI_TABMSKWREN)
-#define F_PLI_TABMSKWREN V_PLI_TABMSKWREN(1U)
-
-#define S_AI_REQVLD 23
-#define M_AI_REQVLD 0x7U
-#define V_AI_REQVLD(x) ((x) << S_AI_REQVLD)
-#define G_AI_REQVLD(x) (((x) >> S_AI_REQVLD) & M_AI_REQVLD)
-
-#define S_AI_REQVLD2 22
-#define V_AI_REQVLD2(x) ((x) << S_AI_REQVLD2)
-#define F_AI_REQVLD2 V_AI_REQVLD2(1U)
-
-#define S_AI_REQRDY 21
-#define V_AI_REQRDY(x) ((x) << S_AI_REQRDY)
-#define F_AI_REQRDY V_AI_REQRDY(1U)
-
-#define S_VEN_MSI_REQ_28 18
-#define M_VEN_MSI_REQ_28 0x7U
-#define V_VEN_MSI_REQ_28(x) ((x) << S_VEN_MSI_REQ_28)
-#define G_VEN_MSI_REQ_28(x) (((x) >> S_VEN_MSI_REQ_28) & M_VEN_MSI_REQ_28)
-
-#define S_VEN_MSI_REQ2 11
-#define M_VEN_MSI_REQ2 0x7fU
-#define V_VEN_MSI_REQ2(x) ((x) << S_VEN_MSI_REQ2)
-#define G_VEN_MSI_REQ2(x) (((x) >> S_VEN_MSI_REQ2) & M_VEN_MSI_REQ2)
-
-#define S_VEN_MSI_REQ3 6
-#define M_VEN_MSI_REQ3 0x1fU
-#define V_VEN_MSI_REQ3(x) ((x) << S_VEN_MSI_REQ3)
-#define G_VEN_MSI_REQ3(x) (((x) >> S_VEN_MSI_REQ3) & M_VEN_MSI_REQ3)
-
-#define S_VEN_MSI_REQ4 3
-#define M_VEN_MSI_REQ4 0x7U
-#define V_VEN_MSI_REQ4(x) ((x) << S_VEN_MSI_REQ4)
-#define G_VEN_MSI_REQ4(x) (((x) >> S_VEN_MSI_REQ4) & M_VEN_MSI_REQ4)
-
-#define S_VEN_MSI_REQ5 2
-#define V_VEN_MSI_REQ5(x) ((x) << S_VEN_MSI_REQ5)
-#define F_VEN_MSI_REQ5 V_VEN_MSI_REQ5(1U)
-
-#define S_VEN_MSI_GRANT 1
-#define V_VEN_MSI_GRANT(x) ((x) << S_VEN_MSI_GRANT)
-#define F_VEN_MSI_GRANT V_VEN_MSI_GRANT(1U)
-
-#define S_VEN_MSI_REQ6 0
-#define V_VEN_MSI_REQ6(x) ((x) << S_VEN_MSI_REQ6)
-#define F_VEN_MSI_REQ6 V_VEN_MSI_REQ6(1U)
-
-#define A_PCIE_PDEBUG_REG_0X29 0x29
-
-#define S_TRGT1_REQDATAVLD 16
-#define M_TRGT1_REQDATAVLD 0xffffU
-#define V_TRGT1_REQDATAVLD(x) ((x) << S_TRGT1_REQDATAVLD)
-#define G_TRGT1_REQDATAVLD(x) (((x) >> S_TRGT1_REQDATAVLD) & M_TRGT1_REQDATAVLD)
-
-#define S_TRGT1_REQDATAVLD2 12
-#define M_TRGT1_REQDATAVLD2 0xfU
-#define V_TRGT1_REQDATAVLD2(x) ((x) << S_TRGT1_REQDATAVLD2)
-#define G_TRGT1_REQDATAVLD2(x) (((x) >> S_TRGT1_REQDATAVLD2) & M_TRGT1_REQDATAVLD2)
-
-#define S_TRGT1_REQDATAVLD3 11
-#define V_TRGT1_REQDATAVLD3(x) ((x) << S_TRGT1_REQDATAVLD3)
-#define F_TRGT1_REQDATAVLD3 V_TRGT1_REQDATAVLD3(1U)
-
-#define S_TRGT1_REQDATAVLD4 10
-#define V_TRGT1_REQDATAVLD4(x) ((x) << S_TRGT1_REQDATAVLD4)
-#define F_TRGT1_REQDATAVLD4 V_TRGT1_REQDATAVLD4(1U)
-
-#define S_TRGT1_REQDATAVLD5 9
-#define V_TRGT1_REQDATAVLD5(x) ((x) << S_TRGT1_REQDATAVLD5)
-#define F_TRGT1_REQDATAVLD5 V_TRGT1_REQDATAVLD5(1U)
-
-#define S_TRGT1_REQDATAVLD6 8
-#define V_TRGT1_REQDATAVLD6(x) ((x) << S_TRGT1_REQDATAVLD6)
-#define F_TRGT1_REQDATAVLD6 V_TRGT1_REQDATAVLD6(1U)
-
-#define S_TRGT1_REQDATAVLD7 4
-#define M_TRGT1_REQDATAVLD7 0xfU
-#define V_TRGT1_REQDATAVLD7(x) ((x) << S_TRGT1_REQDATAVLD7)
-#define G_TRGT1_REQDATAVLD7(x) (((x) >> S_TRGT1_REQDATAVLD7) & M_TRGT1_REQDATAVLD7)
-
-#define S_TRGT1_REQDATAVLD8 2
-#define M_TRGT1_REQDATAVLD8 0x3U
-#define V_TRGT1_REQDATAVLD8(x) ((x) << S_TRGT1_REQDATAVLD8)
-#define G_TRGT1_REQDATAVLD8(x) (((x) >> S_TRGT1_REQDATAVLD8) & M_TRGT1_REQDATAVLD8)
-
-#define S_TRGT1_REQDATARDY 1
-#define V_TRGT1_REQDATARDY(x) ((x) << S_TRGT1_REQDATARDY)
-#define F_TRGT1_REQDATARDY V_TRGT1_REQDATARDY(1U)
-
-#define S_TRGT1_REQDATAVLD0 0
-#define V_TRGT1_REQDATAVLD0(x) ((x) << S_TRGT1_REQDATAVLD0)
-#define F_TRGT1_REQDATAVLD0 V_TRGT1_REQDATAVLD0(1U)
-
-#define A_PCIE_PDEBUG_REG_0X2A 0x2a
-#define A_PCIE_PDEBUG_REG_0X2B 0x2b
-
-#define S_RADM_TRGT1_ADDR 20
-#define M_RADM_TRGT1_ADDR 0xfffU
-#define V_RADM_TRGT1_ADDR(x) ((x) << S_RADM_TRGT1_ADDR)
-#define G_RADM_TRGT1_ADDR(x) (((x) >> S_RADM_TRGT1_ADDR) & M_RADM_TRGT1_ADDR)
-
-#define S_RADM_TRGT1_DWEN 16
-#define M_RADM_TRGT1_DWEN 0xfU
-#define V_RADM_TRGT1_DWEN(x) ((x) << S_RADM_TRGT1_DWEN)
-#define G_RADM_TRGT1_DWEN(x) (((x) >> S_RADM_TRGT1_DWEN) & M_RADM_TRGT1_DWEN)
-
-#define S_RADM_TRGT1_FMT 14
-#define M_RADM_TRGT1_FMT 0x3U
-#define V_RADM_TRGT1_FMT(x) ((x) << S_RADM_TRGT1_FMT)
-#define G_RADM_TRGT1_FMT(x) (((x) >> S_RADM_TRGT1_FMT) & M_RADM_TRGT1_FMT)
-
-#define S_RADM_TRGT1_TYPE 9
-#define M_RADM_TRGT1_TYPE 0x1fU
-#define V_RADM_TRGT1_TYPE(x) ((x) << S_RADM_TRGT1_TYPE)
-#define G_RADM_TRGT1_TYPE(x) (((x) >> S_RADM_TRGT1_TYPE) & M_RADM_TRGT1_TYPE)
-
-#define S_RADM_TRGT1_IN_MEMBAR_RANGE 6
-#define M_RADM_TRGT1_IN_MEMBAR_RANGE 0x7U
-#define V_RADM_TRGT1_IN_MEMBAR_RANGE(x) ((x) << S_RADM_TRGT1_IN_MEMBAR_RANGE)
-#define G_RADM_TRGT1_IN_MEMBAR_RANGE(x) (((x) >> S_RADM_TRGT1_IN_MEMBAR_RANGE) & M_RADM_TRGT1_IN_MEMBAR_RANGE)
-
-#define S_RADM_TRGT1_ECRC_ERR 5
-#define V_RADM_TRGT1_ECRC_ERR(x) ((x) << S_RADM_TRGT1_ECRC_ERR)
-#define F_RADM_TRGT1_ECRC_ERR V_RADM_TRGT1_ECRC_ERR(1U)
-
-#define S_RADM_TRGT1_DLLP_ABORT 4
-#define V_RADM_TRGT1_DLLP_ABORT(x) ((x) << S_RADM_TRGT1_DLLP_ABORT)
-#define F_RADM_TRGT1_DLLP_ABORT V_RADM_TRGT1_DLLP_ABORT(1U)
-
-#define S_RADM_TRGT1_TLP_ABORT 3
-#define V_RADM_TRGT1_TLP_ABORT(x) ((x) << S_RADM_TRGT1_TLP_ABORT)
-#define F_RADM_TRGT1_TLP_ABORT V_RADM_TRGT1_TLP_ABORT(1U)
-
-#define S_RADM_TRGT1_EOT 2
-#define V_RADM_TRGT1_EOT(x) ((x) << S_RADM_TRGT1_EOT)
-#define F_RADM_TRGT1_EOT V_RADM_TRGT1_EOT(1U)
-
-#define S_RADM_TRGT1_DV_2B 1
-#define V_RADM_TRGT1_DV_2B(x) ((x) << S_RADM_TRGT1_DV_2B)
-#define F_RADM_TRGT1_DV_2B V_RADM_TRGT1_DV_2B(1U)
-
-#define S_RADM_TRGT1_HV_2B 0
-#define V_RADM_TRGT1_HV_2B(x) ((x) << S_RADM_TRGT1_HV_2B)
-#define F_RADM_TRGT1_HV_2B V_RADM_TRGT1_HV_2B(1U)
-
-#define A_PCIE_PDEBUG_REG_0X2C 0x2c
-
-#define S_STATEMPIO 29
-#define M_STATEMPIO 0x7U
-#define V_STATEMPIO(x) ((x) << S_STATEMPIO)
-#define G_STATEMPIO(x) (((x) >> S_STATEMPIO) & M_STATEMPIO)
-
-#define S_STATECPL 25
-#define M_STATECPL 0xfU
-#define V_STATECPL(x) ((x) << S_STATECPL)
-#define G_STATECPL(x) (((x) >> S_STATECPL) & M_STATECPL)
-
-#define S_STATEALIN 22
-#define M_STATEALIN 0x7U
-#define V_STATEALIN(x) ((x) << S_STATEALIN)
-#define G_STATEALIN(x) (((x) >> S_STATEALIN) & M_STATEALIN)
-
-#define S_STATEPL 19
-#define M_STATEPL 0x7U
-#define V_STATEPL(x) ((x) << S_STATEPL)
-#define G_STATEPL(x) (((x) >> S_STATEPL) & M_STATEPL)
-
-#define S_STATEMARSP 18
-#define V_STATEMARSP(x) ((x) << S_STATEMARSP)
-#define F_STATEMARSP V_STATEMARSP(1U)
-
-#define S_MA_TAGSINUSE 11
-#define M_MA_TAGSINUSE 0x7fU
-#define V_MA_TAGSINUSE(x) ((x) << S_MA_TAGSINUSE)
-#define G_MA_TAGSINUSE(x) (((x) >> S_MA_TAGSINUSE) & M_MA_TAGSINUSE)
-
-#define S_RADM_TRGT1_HSRDY 10
-#define V_RADM_TRGT1_HSRDY(x) ((x) << S_RADM_TRGT1_HSRDY)
-#define F_RADM_TRGT1_HSRDY V_RADM_TRGT1_HSRDY(1U)
-
-#define S_RADM_TRGT1_DSRDY 9
-#define V_RADM_TRGT1_DSRDY(x) ((x) << S_RADM_TRGT1_DSRDY)
-#define F_RADM_TRGT1_DSRDY V_RADM_TRGT1_DSRDY(1U)
-
-#define S_ALIND_REQWRDATAVLD 8
-#define V_ALIND_REQWRDATAVLD(x) ((x) << S_ALIND_REQWRDATAVLD)
-#define F_ALIND_REQWRDATAVLD V_ALIND_REQWRDATAVLD(1U)
-
-#define S_FID_LKUPWRHDRVLD 7
-#define V_FID_LKUPWRHDRVLD(x) ((x) << S_FID_LKUPWRHDRVLD)
-#define F_FID_LKUPWRHDRVLD V_FID_LKUPWRHDRVLD(1U)
-
-#define S_MPIO_WRVLD 6
-#define V_MPIO_WRVLD(x) ((x) << S_MPIO_WRVLD)
-#define F_MPIO_WRVLD V_MPIO_WRVLD(1U)
-
-#define S_TRGT1_RADM_HALT 5
-#define V_TRGT1_RADM_HALT(x) ((x) << S_TRGT1_RADM_HALT)
-#define F_TRGT1_RADM_HALT V_TRGT1_RADM_HALT(1U)
-
-#define S_RADM_TRGT1_DV_2C 4
-#define V_RADM_TRGT1_DV_2C(x) ((x) << S_RADM_TRGT1_DV_2C)
-#define F_RADM_TRGT1_DV_2C V_RADM_TRGT1_DV_2C(1U)
-
-#define S_RADM_TRGT1_DV_2C_2 3
-#define V_RADM_TRGT1_DV_2C_2(x) ((x) << S_RADM_TRGT1_DV_2C_2)
-#define F_RADM_TRGT1_DV_2C_2 V_RADM_TRGT1_DV_2C_2(1U)
-
-#define S_RADM_TRGT1_TLP_ABORT_2C 2
-#define V_RADM_TRGT1_TLP_ABORT_2C(x) ((x) << S_RADM_TRGT1_TLP_ABORT_2C)
-#define F_RADM_TRGT1_TLP_ABORT_2C V_RADM_TRGT1_TLP_ABORT_2C(1U)
-
-#define S_RADM_TRGT1_DLLP_ABORT_2C 1
-#define V_RADM_TRGT1_DLLP_ABORT_2C(x) ((x) << S_RADM_TRGT1_DLLP_ABORT_2C)
-#define F_RADM_TRGT1_DLLP_ABORT_2C V_RADM_TRGT1_DLLP_ABORT_2C(1U)
-
-#define S_RADM_TRGT1_ECRC_ERR_2C 0
-#define V_RADM_TRGT1_ECRC_ERR_2C(x) ((x) << S_RADM_TRGT1_ECRC_ERR_2C)
-#define F_RADM_TRGT1_ECRC_ERR_2C V_RADM_TRGT1_ECRC_ERR_2C(1U)
-
-#define A_PCIE_PDEBUG_REG_0X2D 0x2d
-
-#define S_RADM_TRGT1_HV_2D 31
-#define V_RADM_TRGT1_HV_2D(x) ((x) << S_RADM_TRGT1_HV_2D)
-#define F_RADM_TRGT1_HV_2D V_RADM_TRGT1_HV_2D(1U)
-
-#define S_RADM_TRGT1_DV_2D 30
-#define V_RADM_TRGT1_DV_2D(x) ((x) << S_RADM_TRGT1_DV_2D)
-#define F_RADM_TRGT1_DV_2D V_RADM_TRGT1_DV_2D(1U)
-
-#define S_RADM_TRGT1_HV2 23
-#define M_RADM_TRGT1_HV2 0x7fU
-#define V_RADM_TRGT1_HV2(x) ((x) << S_RADM_TRGT1_HV2)
-#define G_RADM_TRGT1_HV2(x) (((x) >> S_RADM_TRGT1_HV2) & M_RADM_TRGT1_HV2)
-
-#define S_RADM_TRGT1_HV3 20
-#define M_RADM_TRGT1_HV3 0x7U
-#define V_RADM_TRGT1_HV3(x) ((x) << S_RADM_TRGT1_HV3)
-#define G_RADM_TRGT1_HV3(x) (((x) >> S_RADM_TRGT1_HV3) & M_RADM_TRGT1_HV3)
-
-#define S_RADM_TRGT1_HV4 16
-#define M_RADM_TRGT1_HV4 0xfU
-#define V_RADM_TRGT1_HV4(x) ((x) << S_RADM_TRGT1_HV4)
-#define G_RADM_TRGT1_HV4(x) (((x) >> S_RADM_TRGT1_HV4) & M_RADM_TRGT1_HV4)
-
-#define S_RADM_TRGT1_HV5 12
-#define M_RADM_TRGT1_HV5 0xfU
-#define V_RADM_TRGT1_HV5(x) ((x) << S_RADM_TRGT1_HV5)
-#define G_RADM_TRGT1_HV5(x) (((x) >> S_RADM_TRGT1_HV5) & M_RADM_TRGT1_HV5)
-
-#define S_RADM_TRGT1_HV6 11
-#define V_RADM_TRGT1_HV6(x) ((x) << S_RADM_TRGT1_HV6)
-#define F_RADM_TRGT1_HV6 V_RADM_TRGT1_HV6(1U)
-
-#define S_RADM_TRGT1_HV7 10
-#define V_RADM_TRGT1_HV7(x) ((x) << S_RADM_TRGT1_HV7)
-#define F_RADM_TRGT1_HV7 V_RADM_TRGT1_HV7(1U)
-
-#define S_RADM_TRGT1_HV8 7
-#define M_RADM_TRGT1_HV8 0x7U
-#define V_RADM_TRGT1_HV8(x) ((x) << S_RADM_TRGT1_HV8)
-#define G_RADM_TRGT1_HV8(x) (((x) >> S_RADM_TRGT1_HV8) & M_RADM_TRGT1_HV8)
-
-#define S_RADM_TRGT1_HV9 6
-#define V_RADM_TRGT1_HV9(x) ((x) << S_RADM_TRGT1_HV9)
-#define F_RADM_TRGT1_HV9 V_RADM_TRGT1_HV9(1U)
-
-#define S_RADM_TRGT1_HVA 5
-#define V_RADM_TRGT1_HVA(x) ((x) << S_RADM_TRGT1_HVA)
-#define F_RADM_TRGT1_HVA V_RADM_TRGT1_HVA(1U)
-
-#define S_RADM_TRGT1_DSRDY_2D 4
-#define V_RADM_TRGT1_DSRDY_2D(x) ((x) << S_RADM_TRGT1_DSRDY_2D)
-#define F_RADM_TRGT1_DSRDY_2D V_RADM_TRGT1_DSRDY_2D(1U)
-
-#define S_RADM_TRGT1_WRCNT 0
-#define M_RADM_TRGT1_WRCNT 0xfU
-#define V_RADM_TRGT1_WRCNT(x) ((x) << S_RADM_TRGT1_WRCNT)
-#define G_RADM_TRGT1_WRCNT(x) (((x) >> S_RADM_TRGT1_WRCNT) & M_RADM_TRGT1_WRCNT)
-
-#define A_PCIE_PDEBUG_REG_0X2E 0x2e
-
-#define S_RADM_TRGT1_HV_2E 30
-#define M_RADM_TRGT1_HV_2E 0x3U
-#define V_RADM_TRGT1_HV_2E(x) ((x) << S_RADM_TRGT1_HV_2E)
-#define G_RADM_TRGT1_HV_2E(x) (((x) >> S_RADM_TRGT1_HV_2E) & M_RADM_TRGT1_HV_2E)
-
-#define S_RADM_TRGT1_HV_2E_2 20
-#define M_RADM_TRGT1_HV_2E_2 0x3ffU
-#define V_RADM_TRGT1_HV_2E_2(x) ((x) << S_RADM_TRGT1_HV_2E_2)
-#define G_RADM_TRGT1_HV_2E_2(x) (((x) >> S_RADM_TRGT1_HV_2E_2) & M_RADM_TRGT1_HV_2E_2)
-
-#define S_RADM_TRGT1_HV_WE_3 12
-#define M_RADM_TRGT1_HV_WE_3 0xffU
-#define V_RADM_TRGT1_HV_WE_3(x) ((x) << S_RADM_TRGT1_HV_WE_3)
-#define G_RADM_TRGT1_HV_WE_3(x) (((x) >> S_RADM_TRGT1_HV_WE_3) & M_RADM_TRGT1_HV_WE_3)
-
-#define S_ALIN_REQDATAVLD4 8
-#define M_ALIN_REQDATAVLD4 0xfU
-#define V_ALIN_REQDATAVLD4(x) ((x) << S_ALIN_REQDATAVLD4)
-#define G_ALIN_REQDATAVLD4(x) (((x) >> S_ALIN_REQDATAVLD4) & M_ALIN_REQDATAVLD4)
-
-#define S_ALIN_REQDATAVLD5 7
-#define V_ALIN_REQDATAVLD5(x) ((x) << S_ALIN_REQDATAVLD5)
-#define F_ALIN_REQDATAVLD5 V_ALIN_REQDATAVLD5(1U)
-
-#define S_ALIN_REQDATAVLD6 6
-#define V_ALIN_REQDATAVLD6(x) ((x) << S_ALIN_REQDATAVLD6)
-#define F_ALIN_REQDATAVLD6 V_ALIN_REQDATAVLD6(1U)
-
-#define S_ALIN_REQDATAVLD7 4
-#define M_ALIN_REQDATAVLD7 0x3U
-#define V_ALIN_REQDATAVLD7(x) ((x) << S_ALIN_REQDATAVLD7)
-#define G_ALIN_REQDATAVLD7(x) (((x) >> S_ALIN_REQDATAVLD7) & M_ALIN_REQDATAVLD7)
-
-#define S_ALIN_REQDATAVLD8 3
-#define V_ALIN_REQDATAVLD8(x) ((x) << S_ALIN_REQDATAVLD8)
-#define F_ALIN_REQDATAVLD8 V_ALIN_REQDATAVLD8(1U)
-
-#define S_ALIN_REQDATAVLD9 2
-#define V_ALIN_REQDATAVLD9(x) ((x) << S_ALIN_REQDATAVLD9)
-#define F_ALIN_REQDATAVLD9 V_ALIN_REQDATAVLD9(1U)
-
-#define S_ALIN_REQDATARDY 1
-#define V_ALIN_REQDATARDY(x) ((x) << S_ALIN_REQDATARDY)
-#define F_ALIN_REQDATARDY V_ALIN_REQDATARDY(1U)
-
-#define S_ALIN_REQDATAVLDA 0
-#define V_ALIN_REQDATAVLDA(x) ((x) << S_ALIN_REQDATAVLDA)
-#define F_ALIN_REQDATAVLDA V_ALIN_REQDATAVLDA(1U)
-
-#define A_PCIE_PDEBUG_REG_0X2F 0x2f
-#define A_PCIE_PDEBUG_REG_0X30 0x30
-
-#define S_RADM_TRGT1_HV_30 25
-#define M_RADM_TRGT1_HV_30 0x7fU
-#define V_RADM_TRGT1_HV_30(x) ((x) << S_RADM_TRGT1_HV_30)
-#define G_RADM_TRGT1_HV_30(x) (((x) >> S_RADM_TRGT1_HV_30) & M_RADM_TRGT1_HV_30)
-
-#define S_PIO_WRCNT 15
-#define M_PIO_WRCNT 0x3ffU
-#define V_PIO_WRCNT(x) ((x) << S_PIO_WRCNT)
-#define G_PIO_WRCNT(x) (((x) >> S_PIO_WRCNT) & M_PIO_WRCNT)
-
-#define S_ALIND_REQWRCNT 12
-#define M_ALIND_REQWRCNT 0x7U
-#define V_ALIND_REQWRCNT(x) ((x) << S_ALIND_REQWRCNT)
-#define G_ALIND_REQWRCNT(x) (((x) >> S_ALIND_REQWRCNT) & M_ALIND_REQWRCNT)
-
-#define S_FID_LKUPWRCNT 9
-#define M_FID_LKUPWRCNT 0x7U
-#define V_FID_LKUPWRCNT(x) ((x) << S_FID_LKUPWRCNT)
-#define G_FID_LKUPWRCNT(x) (((x) >> S_FID_LKUPWRCNT) & M_FID_LKUPWRCNT)
-
-#define S_ALIND_REQRDDATAVLD 8
-#define V_ALIND_REQRDDATAVLD(x) ((x) << S_ALIND_REQRDDATAVLD)
-#define F_ALIND_REQRDDATAVLD V_ALIND_REQRDDATAVLD(1U)
-
-#define S_ALIND_REQRDDATARDY 7
-#define V_ALIND_REQRDDATARDY(x) ((x) << S_ALIND_REQRDDATARDY)
-#define F_ALIND_REQRDDATARDY V_ALIND_REQRDDATARDY(1U)
-
-#define S_ALIND_REQRDDATAVLD2 6
-#define V_ALIND_REQRDDATAVLD2(x) ((x) << S_ALIND_REQRDDATAVLD2)
-#define F_ALIND_REQRDDATAVLD2 V_ALIND_REQRDDATAVLD2(1U)
-
-#define S_ALIND_REQWRDATAVLD3 3
-#define M_ALIND_REQWRDATAVLD3 0x7U
-#define V_ALIND_REQWRDATAVLD3(x) ((x) << S_ALIND_REQWRDATAVLD3)
-#define G_ALIND_REQWRDATAVLD3(x) (((x) >> S_ALIND_REQWRDATAVLD3) & M_ALIND_REQWRDATAVLD3)
-
-#define S_ALIND_REQWRDATAVLD4 2
-#define V_ALIND_REQWRDATAVLD4(x) ((x) << S_ALIND_REQWRDATAVLD4)
-#define F_ALIND_REQWRDATAVLD4 V_ALIND_REQWRDATAVLD4(1U)
-
-#define S_ALIND_REQWRDATARDYOPEN 1
-#define V_ALIND_REQWRDATARDYOPEN(x) ((x) << S_ALIND_REQWRDATARDYOPEN)
-#define F_ALIND_REQWRDATARDYOPEN V_ALIND_REQWRDATARDYOPEN(1U)
-
-#define S_ALIND_REQWRDATAVLD5 0
-#define V_ALIND_REQWRDATAVLD5(x) ((x) << S_ALIND_REQWRDATAVLD5)
-#define F_ALIND_REQWRDATAVLD5 V_ALIND_REQWRDATAVLD5(1U)
-
-#define A_PCIE_PDEBUG_REG_0X31 0x31
-#define A_PCIE_PDEBUG_REG_0X32 0x32
-#define A_PCIE_PDEBUG_REG_0X33 0x33
-#define A_PCIE_PDEBUG_REG_0X34 0x34
-#define A_PCIE_PDEBUG_REG_0X35 0x35
-
-#define S_T5_MPIO_WRVLD 19
-#define M_T5_MPIO_WRVLD 0x1fffU
-#define V_T5_MPIO_WRVLD(x) ((x) << S_T5_MPIO_WRVLD)
-#define G_T5_MPIO_WRVLD(x) (((x) >> S_T5_MPIO_WRVLD) & M_T5_MPIO_WRVLD)
-
-#define S_FID_LKUPRDHDRVLD 18
-#define V_FID_LKUPRDHDRVLD(x) ((x) << S_FID_LKUPRDHDRVLD)
-#define F_FID_LKUPRDHDRVLD V_FID_LKUPRDHDRVLD(1U)
-
-#define S_FID_LKUPRDHDRVLD2 17
-#define V_FID_LKUPRDHDRVLD2(x) ((x) << S_FID_LKUPRDHDRVLD2)
-#define F_FID_LKUPRDHDRVLD2 V_FID_LKUPRDHDRVLD2(1U)
-
-#define S_FID_LKUPRDHDRVLD3 16
-#define V_FID_LKUPRDHDRVLD3(x) ((x) << S_FID_LKUPRDHDRVLD3)
-#define F_FID_LKUPRDHDRVLD3 V_FID_LKUPRDHDRVLD3(1U)
-
-#define S_FID_LKUPRDHDRVLD4 15
-#define V_FID_LKUPRDHDRVLD4(x) ((x) << S_FID_LKUPRDHDRVLD4)
-#define F_FID_LKUPRDHDRVLD4 V_FID_LKUPRDHDRVLD4(1U)
-
-#define S_FID_LKUPRDHDRVLD5 14
-#define V_FID_LKUPRDHDRVLD5(x) ((x) << S_FID_LKUPRDHDRVLD5)
-#define F_FID_LKUPRDHDRVLD5 V_FID_LKUPRDHDRVLD5(1U)
-
-#define S_FID_LKUPRDHDRVLD6 13
-#define V_FID_LKUPRDHDRVLD6(x) ((x) << S_FID_LKUPRDHDRVLD6)
-#define F_FID_LKUPRDHDRVLD6 V_FID_LKUPRDHDRVLD6(1U)
-
-#define S_FID_LKUPRDHDRVLD7 12
-#define V_FID_LKUPRDHDRVLD7(x) ((x) << S_FID_LKUPRDHDRVLD7)
-#define F_FID_LKUPRDHDRVLD7 V_FID_LKUPRDHDRVLD7(1U)
-
-#define S_FID_LKUPRDHDRVLD8 11
-#define V_FID_LKUPRDHDRVLD8(x) ((x) << S_FID_LKUPRDHDRVLD8)
-#define F_FID_LKUPRDHDRVLD8 V_FID_LKUPRDHDRVLD8(1U)
-
-#define S_FID_LKUPRDHDRVLD9 10
-#define V_FID_LKUPRDHDRVLD9(x) ((x) << S_FID_LKUPRDHDRVLD9)
-#define F_FID_LKUPRDHDRVLD9 V_FID_LKUPRDHDRVLD9(1U)
-
-#define S_FID_LKUPRDHDRVLDA 9
-#define V_FID_LKUPRDHDRVLDA(x) ((x) << S_FID_LKUPRDHDRVLDA)
-#define F_FID_LKUPRDHDRVLDA V_FID_LKUPRDHDRVLDA(1U)
-
-#define S_FID_LKUPRDHDRVLDB 8
-#define V_FID_LKUPRDHDRVLDB(x) ((x) << S_FID_LKUPRDHDRVLDB)
-#define F_FID_LKUPRDHDRVLDB V_FID_LKUPRDHDRVLDB(1U)
-
-#define S_FID_LKUPRDHDRVLDC 7
-#define V_FID_LKUPRDHDRVLDC(x) ((x) << S_FID_LKUPRDHDRVLDC)
-#define F_FID_LKUPRDHDRVLDC V_FID_LKUPRDHDRVLDC(1U)
-
-#define S_MPIO_WRVLD1 6
-#define V_MPIO_WRVLD1(x) ((x) << S_MPIO_WRVLD1)
-#define F_MPIO_WRVLD1 V_MPIO_WRVLD1(1U)
-
-#define S_MPIO_WRVLD2 5
-#define V_MPIO_WRVLD2(x) ((x) << S_MPIO_WRVLD2)
-#define F_MPIO_WRVLD2 V_MPIO_WRVLD2(1U)
-
-#define S_MPIO_WRVLD3 4
-#define V_MPIO_WRVLD3(x) ((x) << S_MPIO_WRVLD3)
-#define F_MPIO_WRVLD3 V_MPIO_WRVLD3(1U)
-
-#define S_MPIO_WRVLD4 0
-#define M_MPIO_WRVLD4 0xfU
-#define V_MPIO_WRVLD4(x) ((x) << S_MPIO_WRVLD4)
-#define G_MPIO_WRVLD4(x) (((x) >> S_MPIO_WRVLD4) & M_MPIO_WRVLD4)
-
-#define A_PCIE_PDEBUG_REG_0X36 0x36
-#define A_PCIE_PDEBUG_REG_0X37 0x37
-#define A_PCIE_PDEBUG_REG_0X38 0x38
-#define A_PCIE_PDEBUG_REG_0X39 0x39
-#define A_PCIE_PDEBUG_REG_0X3A 0x3a
-
-#define S_CLIENT0_TLP_VFUNC_ACTIVE 31
-#define V_CLIENT0_TLP_VFUNC_ACTIVE(x) ((x) << S_CLIENT0_TLP_VFUNC_ACTIVE)
-#define F_CLIENT0_TLP_VFUNC_ACTIVE V_CLIENT0_TLP_VFUNC_ACTIVE(1U)
-
-#define S_CLIENT0_TLP_VFUNC_NUM 24
-#define M_CLIENT0_TLP_VFUNC_NUM 0x7fU
-#define V_CLIENT0_TLP_VFUNC_NUM(x) ((x) << S_CLIENT0_TLP_VFUNC_NUM)
-#define G_CLIENT0_TLP_VFUNC_NUM(x) (((x) >> S_CLIENT0_TLP_VFUNC_NUM) & M_CLIENT0_TLP_VFUNC_NUM)
-
-#define S_CLIENT0_TLP_FUNC_NUM 21
-#define M_CLIENT0_TLP_FUNC_NUM 0x7U
-#define V_CLIENT0_TLP_FUNC_NUM(x) ((x) << S_CLIENT0_TLP_FUNC_NUM)
-#define G_CLIENT0_TLP_FUNC_NUM(x) (((x) >> S_CLIENT0_TLP_FUNC_NUM) & M_CLIENT0_TLP_FUNC_NUM)
-
-#define S_CLIENT0_TLP_BYTE_EN 13
-#define M_CLIENT0_TLP_BYTE_EN 0xffU
-#define V_CLIENT0_TLP_BYTE_EN(x) ((x) << S_CLIENT0_TLP_BYTE_EN)
-#define G_CLIENT0_TLP_BYTE_EN(x) (((x) >> S_CLIENT0_TLP_BYTE_EN) & M_CLIENT0_TLP_BYTE_EN)
-
-#define S_CLIENT0_TLP_BYTE_LEN 0
-#define M_CLIENT0_TLP_BYTE_LEN 0x1fffU
-#define V_CLIENT0_TLP_BYTE_LEN(x) ((x) << S_CLIENT0_TLP_BYTE_LEN)
-#define G_CLIENT0_TLP_BYTE_LEN(x) (((x) >> S_CLIENT0_TLP_BYTE_LEN) & M_CLIENT0_TLP_BYTE_LEN)
-
-#define A_PCIE_PDEBUG_REG_0X3B 0x3b
-
-#define S_XADM_CLIENT0_HALT 31
-#define V_XADM_CLIENT0_HALT(x) ((x) << S_XADM_CLIENT0_HALT)
-#define F_XADM_CLIENT0_HALT V_XADM_CLIENT0_HALT(1U)
-
-#define S_CLIENT0_TLP_DV 30
-#define V_CLIENT0_TLP_DV(x) ((x) << S_CLIENT0_TLP_DV)
-#define F_CLIENT0_TLP_DV V_CLIENT0_TLP_DV(1U)
-
-#define S_CLIENT0_ADDR_ALIGN_EN 29
-#define V_CLIENT0_ADDR_ALIGN_EN(x) ((x) << S_CLIENT0_ADDR_ALIGN_EN)
-#define F_CLIENT0_ADDR_ALIGN_EN V_CLIENT0_ADDR_ALIGN_EN(1U)
-
-#define S_CLIENT0_CPL_BCM 28
-#define V_CLIENT0_CPL_BCM(x) ((x) << S_CLIENT0_CPL_BCM)
-#define F_CLIENT0_CPL_BCM V_CLIENT0_CPL_BCM(1U)
-
-#define S_CLIENT0_TLP_EP 27
-#define V_CLIENT0_TLP_EP(x) ((x) << S_CLIENT0_TLP_EP)
-#define F_CLIENT0_TLP_EP V_CLIENT0_TLP_EP(1U)
-
-#define S_CLIENT0_CPL_STATUS 24
-#define M_CLIENT0_CPL_STATUS 0x7U
-#define V_CLIENT0_CPL_STATUS(x) ((x) << S_CLIENT0_CPL_STATUS)
-#define G_CLIENT0_CPL_STATUS(x) (((x) >> S_CLIENT0_CPL_STATUS) & M_CLIENT0_CPL_STATUS)
-
-#define S_CLIENT0_TLP_TD 23
-#define V_CLIENT0_TLP_TD(x) ((x) << S_CLIENT0_TLP_TD)
-#define F_CLIENT0_TLP_TD V_CLIENT0_TLP_TD(1U)
-
-#define S_CLIENT0_TLP_TYPE 18
-#define M_CLIENT0_TLP_TYPE 0x1fU
-#define V_CLIENT0_TLP_TYPE(x) ((x) << S_CLIENT0_TLP_TYPE)
-#define G_CLIENT0_TLP_TYPE(x) (((x) >> S_CLIENT0_TLP_TYPE) & M_CLIENT0_TLP_TYPE)
-
-#define S_CLIENT0_TLP_FMT 16
-#define M_CLIENT0_TLP_FMT 0x3U
-#define V_CLIENT0_TLP_FMT(x) ((x) << S_CLIENT0_TLP_FMT)
-#define G_CLIENT0_TLP_FMT(x) (((x) >> S_CLIENT0_TLP_FMT) & M_CLIENT0_TLP_FMT)
-
-#define S_CLIENT0_TLP_BAD_EOT 15
-#define V_CLIENT0_TLP_BAD_EOT(x) ((x) << S_CLIENT0_TLP_BAD_EOT)
-#define F_CLIENT0_TLP_BAD_EOT V_CLIENT0_TLP_BAD_EOT(1U)
-
-#define S_CLIENT0_TLP_EOT 14
-#define V_CLIENT0_TLP_EOT(x) ((x) << S_CLIENT0_TLP_EOT)
-#define F_CLIENT0_TLP_EOT V_CLIENT0_TLP_EOT(1U)
-
-#define S_CLIENT0_TLP_ATTR 11
-#define M_CLIENT0_TLP_ATTR 0x7U
-#define V_CLIENT0_TLP_ATTR(x) ((x) << S_CLIENT0_TLP_ATTR)
-#define G_CLIENT0_TLP_ATTR(x) (((x) >> S_CLIENT0_TLP_ATTR) & M_CLIENT0_TLP_ATTR)
-
-#define S_CLIENT0_TLP_TC 8
-#define M_CLIENT0_TLP_TC 0x7U
-#define V_CLIENT0_TLP_TC(x) ((x) << S_CLIENT0_TLP_TC)
-#define G_CLIENT0_TLP_TC(x) (((x) >> S_CLIENT0_TLP_TC) & M_CLIENT0_TLP_TC)
-
-#define S_CLIENT0_TLP_TID 0
-#define M_CLIENT0_TLP_TID 0xffU
-#define V_CLIENT0_TLP_TID(x) ((x) << S_CLIENT0_TLP_TID)
-#define G_CLIENT0_TLP_TID(x) (((x) >> S_CLIENT0_TLP_TID) & M_CLIENT0_TLP_TID)
-
-#define A_PCIE_PDEBUG_REG_0X3C 0x3c
-
-#define S_MEM_RSPRRAVLD 31
-#define V_MEM_RSPRRAVLD(x) ((x) << S_MEM_RSPRRAVLD)
-#define F_MEM_RSPRRAVLD V_MEM_RSPRRAVLD(1U)
-
-#define S_MEM_RSPRRARDY 30
-#define V_MEM_RSPRRARDY(x) ((x) << S_MEM_RSPRRARDY)
-#define F_MEM_RSPRRARDY V_MEM_RSPRRARDY(1U)
-
-#define S_PIO_RSPRRAVLD 29
-#define V_PIO_RSPRRAVLD(x) ((x) << S_PIO_RSPRRAVLD)
-#define F_PIO_RSPRRAVLD V_PIO_RSPRRAVLD(1U)
-
-#define S_PIO_RSPRRARDY 28
-#define V_PIO_RSPRRARDY(x) ((x) << S_PIO_RSPRRARDY)
-#define F_PIO_RSPRRARDY V_PIO_RSPRRARDY(1U)
-
-#define S_MEM_RSPRDVLD 27
-#define V_MEM_RSPRDVLD(x) ((x) << S_MEM_RSPRDVLD)
-#define F_MEM_RSPRDVLD V_MEM_RSPRDVLD(1U)
-
-#define S_MEM_RSPRDRRARDY 26
-#define V_MEM_RSPRDRRARDY(x) ((x) << S_MEM_RSPRDRRARDY)
-#define F_MEM_RSPRDRRARDY V_MEM_RSPRDRRARDY(1U)
-
-#define S_PIO_RSPRDVLD 25
-#define V_PIO_RSPRDVLD(x) ((x) << S_PIO_RSPRDVLD)
-#define F_PIO_RSPRDVLD V_PIO_RSPRDVLD(1U)
-
-#define S_PIO_RSPRDRRARDY 24
-#define V_PIO_RSPRDRRARDY(x) ((x) << S_PIO_RSPRDRRARDY)
-#define F_PIO_RSPRDRRARDY V_PIO_RSPRDRRARDY(1U)
-
-#define S_TGT_TAGQ_RDVLD 16
-#define M_TGT_TAGQ_RDVLD 0xffU
-#define V_TGT_TAGQ_RDVLD(x) ((x) << S_TGT_TAGQ_RDVLD)
-#define G_TGT_TAGQ_RDVLD(x) (((x) >> S_TGT_TAGQ_RDVLD) & M_TGT_TAGQ_RDVLD)
-
-#define S_CPLTXNDISABLE 8
-#define M_CPLTXNDISABLE 0xffU
-#define V_CPLTXNDISABLE(x) ((x) << S_CPLTXNDISABLE)
-#define G_CPLTXNDISABLE(x) (((x) >> S_CPLTXNDISABLE) & M_CPLTXNDISABLE)
-
-#define S_CPLTXNDISABLE2 7
-#define V_CPLTXNDISABLE2(x) ((x) << S_CPLTXNDISABLE2)
-#define F_CPLTXNDISABLE2 V_CPLTXNDISABLE2(1U)
-
-#define S_CLIENT0_TLP_HV 0
-#define M_CLIENT0_TLP_HV 0x7fU
-#define V_CLIENT0_TLP_HV(x) ((x) << S_CLIENT0_TLP_HV)
-#define G_CLIENT0_TLP_HV(x) (((x) >> S_CLIENT0_TLP_HV) & M_CLIENT0_TLP_HV)
-
-#define A_PCIE_PDEBUG_REG_0X3D 0x3d
-#define A_PCIE_PDEBUG_REG_0X3E 0x3e
-#define A_PCIE_PDEBUG_REG_0X3F 0x3f
-#define A_PCIE_PDEBUG_REG_0X40 0x40
-#define A_PCIE_PDEBUG_REG_0X41 0x41
-#define A_PCIE_PDEBUG_REG_0X42 0x42
-#define A_PCIE_PDEBUG_REG_0X43 0x43
-#define A_PCIE_PDEBUG_REG_0X44 0x44
-#define A_PCIE_PDEBUG_REG_0X45 0x45
-#define A_PCIE_PDEBUG_REG_0X46 0x46
-#define A_PCIE_PDEBUG_REG_0X47 0x47
-#define A_PCIE_PDEBUG_REG_0X48 0x48
-#define A_PCIE_PDEBUG_REG_0X49 0x49
-#define A_PCIE_PDEBUG_REG_0X4A 0x4a
-#define A_PCIE_PDEBUG_REG_0X4B 0x4b
-#define A_PCIE_PDEBUG_REG_0X4C 0x4c
-#define A_PCIE_PDEBUG_REG_0X4D 0x4d
-#define A_PCIE_PDEBUG_REG_0X4E 0x4e
-#define A_PCIE_PDEBUG_REG_0X4F 0x4f
-#define A_PCIE_PDEBUG_REG_0X50 0x50
-#define A_PCIE_CDEBUG_REG_0X0 0x0
-#define A_PCIE_CDEBUG_REG_0X1 0x1
-#define A_PCIE_CDEBUG_REG_0X2 0x2
-
-#define S_FLR_REQVLD 31
-#define V_FLR_REQVLD(x) ((x) << S_FLR_REQVLD)
-#define F_FLR_REQVLD V_FLR_REQVLD(1U)
-
-#define S_D_RSPVLD 28
-#define M_D_RSPVLD 0x7U
-#define V_D_RSPVLD(x) ((x) << S_D_RSPVLD)
-#define G_D_RSPVLD(x) (((x) >> S_D_RSPVLD) & M_D_RSPVLD)
-
-#define S_D_RSPVLD2 27
-#define V_D_RSPVLD2(x) ((x) << S_D_RSPVLD2)
-#define F_D_RSPVLD2 V_D_RSPVLD2(1U)
-
-#define S_D_RSPVLD3 26
-#define V_D_RSPVLD3(x) ((x) << S_D_RSPVLD3)
-#define F_D_RSPVLD3 V_D_RSPVLD3(1U)
-
-#define S_D_RSPVLD4 25
-#define V_D_RSPVLD4(x) ((x) << S_D_RSPVLD4)
-#define F_D_RSPVLD4 V_D_RSPVLD4(1U)
-
-#define S_D_RSPVLD5 24
-#define V_D_RSPVLD5(x) ((x) << S_D_RSPVLD5)
-#define F_D_RSPVLD5 V_D_RSPVLD5(1U)
-
-#define S_D_RSPVLD6 20
-#define M_D_RSPVLD6 0xfU
-#define V_D_RSPVLD6(x) ((x) << S_D_RSPVLD6)
-#define G_D_RSPVLD6(x) (((x) >> S_D_RSPVLD6) & M_D_RSPVLD6)
-
-#define S_D_RSPAFULL 16
-#define M_D_RSPAFULL 0xfU
-#define V_D_RSPAFULL(x) ((x) << S_D_RSPAFULL)
-#define G_D_RSPAFULL(x) (((x) >> S_D_RSPAFULL) & M_D_RSPAFULL)
-
-#define S_D_RDREQVLD 12
-#define M_D_RDREQVLD 0xfU
-#define V_D_RDREQVLD(x) ((x) << S_D_RDREQVLD)
-#define G_D_RDREQVLD(x) (((x) >> S_D_RDREQVLD) & M_D_RDREQVLD)
-
-#define S_D_RDREQAFULL 8
-#define M_D_RDREQAFULL 0xfU
-#define V_D_RDREQAFULL(x) ((x) << S_D_RDREQAFULL)
-#define G_D_RDREQAFULL(x) (((x) >> S_D_RDREQAFULL) & M_D_RDREQAFULL)
-
-#define S_D_WRREQVLD 4
-#define M_D_WRREQVLD 0xfU
-#define V_D_WRREQVLD(x) ((x) << S_D_WRREQVLD)
-#define G_D_WRREQVLD(x) (((x) >> S_D_WRREQVLD) & M_D_WRREQVLD)
-
-#define S_D_WRREQAFULL 0
-#define M_D_WRREQAFULL 0xfU
-#define V_D_WRREQAFULL(x) ((x) << S_D_WRREQAFULL)
-#define G_D_WRREQAFULL(x) (((x) >> S_D_WRREQAFULL) & M_D_WRREQAFULL)
-
-#define A_PCIE_CDEBUG_REG_0X3 0x3
-
-#define S_C_REQVLD 19
-#define M_C_REQVLD 0x1fffU
-#define V_C_REQVLD(x) ((x) << S_C_REQVLD)
-#define G_C_REQVLD(x) (((x) >> S_C_REQVLD) & M_C_REQVLD)
-
-#define S_C_RSPVLD2 16
-#define M_C_RSPVLD2 0x7U
-#define V_C_RSPVLD2(x) ((x) << S_C_RSPVLD2)
-#define G_C_RSPVLD2(x) (((x) >> S_C_RSPVLD2) & M_C_RSPVLD2)
-
-#define S_C_RSPVLD3 15
-#define V_C_RSPVLD3(x) ((x) << S_C_RSPVLD3)
-#define F_C_RSPVLD3 V_C_RSPVLD3(1U)
-
-#define S_C_RSPVLD4 14
-#define V_C_RSPVLD4(x) ((x) << S_C_RSPVLD4)
-#define F_C_RSPVLD4 V_C_RSPVLD4(1U)
-
-#define S_C_RSPVLD5 13
-#define V_C_RSPVLD5(x) ((x) << S_C_RSPVLD5)
-#define F_C_RSPVLD5 V_C_RSPVLD5(1U)
-
-#define S_C_RSPVLD6 12
-#define V_C_RSPVLD6(x) ((x) << S_C_RSPVLD6)
-#define F_C_RSPVLD6 V_C_RSPVLD6(1U)
-
-#define S_C_RSPVLD7 9
-#define M_C_RSPVLD7 0x7U
-#define V_C_RSPVLD7(x) ((x) << S_C_RSPVLD7)
-#define G_C_RSPVLD7(x) (((x) >> S_C_RSPVLD7) & M_C_RSPVLD7)
-
-#define S_C_RSPAFULL 6
-#define M_C_RSPAFULL 0x7U
-#define V_C_RSPAFULL(x) ((x) << S_C_RSPAFULL)
-#define G_C_RSPAFULL(x) (((x) >> S_C_RSPAFULL) & M_C_RSPAFULL)
-
-#define S_C_REQVLD8 3
-#define M_C_REQVLD8 0x7U
-#define V_C_REQVLD8(x) ((x) << S_C_REQVLD8)
-#define G_C_REQVLD8(x) (((x) >> S_C_REQVLD8) & M_C_REQVLD8)
-
-#define S_C_REQAFULL 0
-#define M_C_REQAFULL 0x7U
-#define V_C_REQAFULL(x) ((x) << S_C_REQAFULL)
-#define G_C_REQAFULL(x) (((x) >> S_C_REQAFULL) & M_C_REQAFULL)
-
-#define A_PCIE_CDEBUG_REG_0X4 0x4
-
-#define S_H_REQVLD 7
-#define M_H_REQVLD 0x1ffffffU
-#define V_H_REQVLD(x) ((x) << S_H_REQVLD)
-#define G_H_REQVLD(x) (((x) >> S_H_REQVLD) & M_H_REQVLD)
-
-#define S_H_RSPVLD 6
-#define V_H_RSPVLD(x) ((x) << S_H_RSPVLD)
-#define F_H_RSPVLD V_H_RSPVLD(1U)
-
-#define S_H_RSPVLD2 5
-#define V_H_RSPVLD2(x) ((x) << S_H_RSPVLD2)
-#define F_H_RSPVLD2 V_H_RSPVLD2(1U)
-
-#define S_H_RSPVLD3 4
-#define V_H_RSPVLD3(x) ((x) << S_H_RSPVLD3)
-#define F_H_RSPVLD3 V_H_RSPVLD3(1U)
-
-#define S_H_RSPVLD4 3
-#define V_H_RSPVLD4(x) ((x) << S_H_RSPVLD4)
-#define F_H_RSPVLD4 V_H_RSPVLD4(1U)
-
-#define S_H_RSPAFULL 2
-#define V_H_RSPAFULL(x) ((x) << S_H_RSPAFULL)
-#define F_H_RSPAFULL V_H_RSPAFULL(1U)
-
-#define S_H_REQVLD2 1
-#define V_H_REQVLD2(x) ((x) << S_H_REQVLD2)
-#define F_H_REQVLD2 V_H_REQVLD2(1U)
-
-#define S_H_REQAFULL 0
-#define V_H_REQAFULL(x) ((x) << S_H_REQAFULL)
-#define F_H_REQAFULL V_H_REQAFULL(1U)
-
-#define A_PCIE_CDEBUG_REG_0X5 0x5
-
-#define S_ER_RSPVLD 16
-#define M_ER_RSPVLD 0xffffU
-#define V_ER_RSPVLD(x) ((x) << S_ER_RSPVLD)
-#define G_ER_RSPVLD(x) (((x) >> S_ER_RSPVLD) & M_ER_RSPVLD)
-
-#define S_ER_REQVLD2 5
-#define M_ER_REQVLD2 0x7ffU
-#define V_ER_REQVLD2(x) ((x) << S_ER_REQVLD2)
-#define G_ER_REQVLD2(x) (((x) >> S_ER_REQVLD2) & M_ER_REQVLD2)
-
-#define S_ER_REQVLD3 2
-#define M_ER_REQVLD3 0x7U
-#define V_ER_REQVLD3(x) ((x) << S_ER_REQVLD3)
-#define G_ER_REQVLD3(x) (((x) >> S_ER_REQVLD3) & M_ER_REQVLD3)
-
-#define S_ER_RSPVLD4 1
-#define V_ER_RSPVLD4(x) ((x) << S_ER_RSPVLD4)
-#define F_ER_RSPVLD4 V_ER_RSPVLD4(1U)
-
-#define S_ER_REQVLD5 0
-#define V_ER_REQVLD5(x) ((x) << S_ER_REQVLD5)
-#define F_ER_REQVLD5 V_ER_REQVLD5(1U)
-
-#define A_PCIE_CDEBUG_REG_0X6 0x6
-
-#define S_PL_BAR2_REQVLD 4
-#define M_PL_BAR2_REQVLD 0xfffffffU
-#define V_PL_BAR2_REQVLD(x) ((x) << S_PL_BAR2_REQVLD)
-#define G_PL_BAR2_REQVLD(x) (((x) >> S_PL_BAR2_REQVLD) & M_PL_BAR2_REQVLD)
-
-#define S_PL_BAR2_REQVLD2 3
-#define V_PL_BAR2_REQVLD2(x) ((x) << S_PL_BAR2_REQVLD2)
-#define F_PL_BAR2_REQVLD2 V_PL_BAR2_REQVLD2(1U)
-
-#define S_PL_BAR2_REQVLDE 2
-#define V_PL_BAR2_REQVLDE(x) ((x) << S_PL_BAR2_REQVLDE)
-#define F_PL_BAR2_REQVLDE V_PL_BAR2_REQVLDE(1U)
-
-#define S_PL_BAR2_REQFULL 1
-#define V_PL_BAR2_REQFULL(x) ((x) << S_PL_BAR2_REQFULL)
-#define F_PL_BAR2_REQFULL V_PL_BAR2_REQFULL(1U)
-
-#define S_PL_BAR2_REQVLD4 0
-#define V_PL_BAR2_REQVLD4(x) ((x) << S_PL_BAR2_REQVLD4)
-#define F_PL_BAR2_REQVLD4 V_PL_BAR2_REQVLD4(1U)
-
-#define A_PCIE_CDEBUG_REG_0X7 0x7
-#define A_PCIE_CDEBUG_REG_0X8 0x8
-#define A_PCIE_CDEBUG_REG_0X9 0x9
-#define A_PCIE_CDEBUG_REG_0XA 0xa
-
-#define S_VPD_RSPVLD 20
-#define M_VPD_RSPVLD 0xfffU
-#define V_VPD_RSPVLD(x) ((x) << S_VPD_RSPVLD)
-#define G_VPD_RSPVLD(x) (((x) >> S_VPD_RSPVLD) & M_VPD_RSPVLD)
-
-#define S_VPD_REQVLD2 9
-#define M_VPD_REQVLD2 0x7ffU
-#define V_VPD_REQVLD2(x) ((x) << S_VPD_REQVLD2)
-#define G_VPD_REQVLD2(x) (((x) >> S_VPD_REQVLD2) & M_VPD_REQVLD2)
-
-#define S_VPD_REQVLD3 6
-#define M_VPD_REQVLD3 0x7U
-#define V_VPD_REQVLD3(x) ((x) << S_VPD_REQVLD3)
-#define G_VPD_REQVLD3(x) (((x) >> S_VPD_REQVLD3) & M_VPD_REQVLD3)
-
-#define S_VPD_REQVLD4 5
-#define V_VPD_REQVLD4(x) ((x) << S_VPD_REQVLD4)
-#define F_VPD_REQVLD4 V_VPD_REQVLD4(1U)
-
-#define S_VPD_REQVLD5 3
-#define M_VPD_REQVLD5 0x3U
-#define V_VPD_REQVLD5(x) ((x) << S_VPD_REQVLD5)
-#define G_VPD_REQVLD5(x) (((x) >> S_VPD_REQVLD5) & M_VPD_REQVLD5)
-
-#define S_VPD_RSPVLD2 2
-#define V_VPD_RSPVLD2(x) ((x) << S_VPD_RSPVLD2)
-#define F_VPD_RSPVLD2 V_VPD_RSPVLD2(1U)
-
-#define S_VPD_RSPVLD3 1
-#define V_VPD_RSPVLD3(x) ((x) << S_VPD_RSPVLD3)
-#define F_VPD_RSPVLD3 V_VPD_RSPVLD3(1U)
-
-#define S_VPD_REQVLD6 0
-#define V_VPD_REQVLD6(x) ((x) << S_VPD_REQVLD6)
-#define F_VPD_REQVLD6 V_VPD_REQVLD6(1U)
-
-#define A_PCIE_CDEBUG_REG_0XB 0xb
-
-#define S_MA_REQDATAVLD 28
-#define M_MA_REQDATAVLD 0xfU
-#define V_MA_REQDATAVLD(x) ((x) << S_MA_REQDATAVLD)
-#define G_MA_REQDATAVLD(x) (((x) >> S_MA_REQDATAVLD) & M_MA_REQDATAVLD)
-
-#define S_MA_REQADDRVLD 27
-#define V_MA_REQADDRVLD(x) ((x) << S_MA_REQADDRVLD)
-#define F_MA_REQADDRVLD V_MA_REQADDRVLD(1U)
-
-#define S_MA_REQADDRVLD2 26
-#define V_MA_REQADDRVLD2(x) ((x) << S_MA_REQADDRVLD2)
-#define F_MA_REQADDRVLD2 V_MA_REQADDRVLD2(1U)
-
-#define S_MA_RSPDATAVLD2 22
-#define M_MA_RSPDATAVLD2 0xfU
-#define V_MA_RSPDATAVLD2(x) ((x) << S_MA_RSPDATAVLD2)
-#define G_MA_RSPDATAVLD2(x) (((x) >> S_MA_RSPDATAVLD2) & M_MA_RSPDATAVLD2)
-
-#define S_MA_REQADDRVLD3 20
-#define M_MA_REQADDRVLD3 0x3U
-#define V_MA_REQADDRVLD3(x) ((x) << S_MA_REQADDRVLD3)
-#define G_MA_REQADDRVLD3(x) (((x) >> S_MA_REQADDRVLD3) & M_MA_REQADDRVLD3)
-
-#define S_MA_REQADDRVLD4 4
-#define M_MA_REQADDRVLD4 0xffffU
-#define V_MA_REQADDRVLD4(x) ((x) << S_MA_REQADDRVLD4)
-#define G_MA_REQADDRVLD4(x) (((x) >> S_MA_REQADDRVLD4) & M_MA_REQADDRVLD4)
-
-#define S_MA_REQADDRVLD5 3
-#define V_MA_REQADDRVLD5(x) ((x) << S_MA_REQADDRVLD5)
-#define F_MA_REQADDRVLD5 V_MA_REQADDRVLD5(1U)
-
-#define S_MA_REQADDRVLD6 2
-#define V_MA_REQADDRVLD6(x) ((x) << S_MA_REQADDRVLD6)
-#define F_MA_REQADDRVLD6 V_MA_REQADDRVLD6(1U)
-
-#define S_MA_REQADDRRDY 1
-#define V_MA_REQADDRRDY(x) ((x) << S_MA_REQADDRRDY)
-#define F_MA_REQADDRRDY V_MA_REQADDRRDY(1U)
-
-#define S_MA_REQADDRVLD7 0
-#define V_MA_REQADDRVLD7(x) ((x) << S_MA_REQADDRVLD7)
-#define F_MA_REQADDRVLD7 V_MA_REQADDRVLD7(1U)
-
-#define A_PCIE_CDEBUG_REG_0XC 0xc
-#define A_PCIE_CDEBUG_REG_0XD 0xd
-#define A_PCIE_CDEBUG_REG_0XE 0xe
-#define A_PCIE_CDEBUG_REG_0XF 0xf
-#define A_PCIE_CDEBUG_REG_0X10 0x10
-#define A_PCIE_CDEBUG_REG_0X11 0x11
-#define A_PCIE_CDEBUG_REG_0X12 0x12
-#define A_PCIE_CDEBUG_REG_0X13 0x13
-#define A_PCIE_CDEBUG_REG_0X14 0x14
-#define A_PCIE_CDEBUG_REG_0X15 0x15
-
-#define S_PLM_REQVLD 19
-#define M_PLM_REQVLD 0x1fffU
-#define V_PLM_REQVLD(x) ((x) << S_PLM_REQVLD)
-#define G_PLM_REQVLD(x) (((x) >> S_PLM_REQVLD) & M_PLM_REQVLD)
-
-#define S_PLM_REQVLD2 18
-#define V_PLM_REQVLD2(x) ((x) << S_PLM_REQVLD2)
-#define F_PLM_REQVLD2 V_PLM_REQVLD2(1U)
-
-#define S_PLM_RSPVLD3 17
-#define V_PLM_RSPVLD3(x) ((x) << S_PLM_RSPVLD3)
-#define F_PLM_RSPVLD3 V_PLM_RSPVLD3(1U)
-
-#define S_PLM_REQVLD4 16
-#define V_PLM_REQVLD4(x) ((x) << S_PLM_REQVLD4)
-#define F_PLM_REQVLD4 V_PLM_REQVLD4(1U)
-
-#define S_PLM_REQVLD5 15
-#define V_PLM_REQVLD5(x) ((x) << S_PLM_REQVLD5)
-#define F_PLM_REQVLD5 V_PLM_REQVLD5(1U)
-
-#define S_PLM_REQVLD6 14
-#define V_PLM_REQVLD6(x) ((x) << S_PLM_REQVLD6)
-#define F_PLM_REQVLD6 V_PLM_REQVLD6(1U)
-
-#define S_PLM_REQVLD7 13
-#define V_PLM_REQVLD7(x) ((x) << S_PLM_REQVLD7)
-#define F_PLM_REQVLD7 V_PLM_REQVLD7(1U)
-
-#define S_PLM_REQVLD8 12
-#define V_PLM_REQVLD8(x) ((x) << S_PLM_REQVLD8)
-#define F_PLM_REQVLD8 V_PLM_REQVLD8(1U)
-
-#define S_PLM_REQVLD9 4
-#define M_PLM_REQVLD9 0xffU
-#define V_PLM_REQVLD9(x) ((x) << S_PLM_REQVLD9)
-#define G_PLM_REQVLD9(x) (((x) >> S_PLM_REQVLD9) & M_PLM_REQVLD9)
-
-#define S_PLM_REQVLDA 1
-#define M_PLM_REQVLDA 0x7U
-#define V_PLM_REQVLDA(x) ((x) << S_PLM_REQVLDA)
-#define G_PLM_REQVLDA(x) (((x) >> S_PLM_REQVLDA) & M_PLM_REQVLDA)
-
-#define S_PLM_REQVLDB 0
-#define V_PLM_REQVLDB(x) ((x) << S_PLM_REQVLDB)
-#define F_PLM_REQVLDB V_PLM_REQVLDB(1U)
-
-#define A_PCIE_CDEBUG_REG_0X16 0x16
-#define A_PCIE_CDEBUG_REG_0X17 0x17
-#define A_PCIE_CDEBUG_REG_0X18 0x18
-#define A_PCIE_CDEBUG_REG_0X19 0x19
-#define A_PCIE_CDEBUG_REG_0X1A 0x1a
-#define A_PCIE_CDEBUG_REG_0X1B 0x1b
-#define A_PCIE_CDEBUG_REG_0X1C 0x1c
-#define A_PCIE_CDEBUG_REG_0X1D 0x1d
-#define A_PCIE_CDEBUG_REG_0X1E 0x1e
-#define A_PCIE_CDEBUG_REG_0X1F 0x1f
-#define A_PCIE_CDEBUG_REG_0X20 0x20
-#define A_PCIE_CDEBUG_REG_0X21 0x21
-#define A_PCIE_CDEBUG_REG_0X22 0x22
-#define A_PCIE_CDEBUG_REG_0X23 0x23
-#define A_PCIE_CDEBUG_REG_0X24 0x24
-#define A_PCIE_CDEBUG_REG_0X25 0x25
-#define A_PCIE_CDEBUG_REG_0X26 0x26
-#define A_PCIE_CDEBUG_REG_0X27 0x27
-#define A_PCIE_CDEBUG_REG_0X28 0x28
-#define A_PCIE_CDEBUG_REG_0X29 0x29
-#define A_PCIE_CDEBUG_REG_0X2A 0x2a
-#define A_PCIE_CDEBUG_REG_0X2B 0x2b
-#define A_PCIE_CDEBUG_REG_0X2C 0x2c
-#define A_PCIE_CDEBUG_REG_0X2D 0x2d
-#define A_PCIE_CDEBUG_REG_0X2E 0x2e
-#define A_PCIE_CDEBUG_REG_0X2F 0x2f
-#define A_PCIE_CDEBUG_REG_0X30 0x30
-#define A_PCIE_CDEBUG_REG_0X31 0x31
-#define A_PCIE_CDEBUG_REG_0X32 0x32
-#define A_PCIE_CDEBUG_REG_0X33 0x33
-#define A_PCIE_CDEBUG_REG_0X34 0x34
-#define A_PCIE_CDEBUG_REG_0X35 0x35
-#define A_PCIE_CDEBUG_REG_0X36 0x36
-#define A_PCIE_CDEBUG_REG_0X37 0x37
-
-/* registers for module DBG */
-#define DBG_BASE_ADDR 0x6000
-
-#define A_DBG_DBG0_CFG 0x6000
-
-#define S_MODULESELECT 12
-#define M_MODULESELECT 0xffU
-#define V_MODULESELECT(x) ((x) << S_MODULESELECT)
-#define G_MODULESELECT(x) (((x) >> S_MODULESELECT) & M_MODULESELECT)
-
-#define S_REGSELECT 4
-#define M_REGSELECT 0xffU
-#define V_REGSELECT(x) ((x) << S_REGSELECT)
-#define G_REGSELECT(x) (((x) >> S_REGSELECT) & M_REGSELECT)
-
-#define S_CLKSELECT 0
-#define M_CLKSELECT 0xfU
-#define V_CLKSELECT(x) ((x) << S_CLKSELECT)
-#define G_CLKSELECT(x) (((x) >> S_CLKSELECT) & M_CLKSELECT)
-
-#define A_DBG_DBG0_EN 0x6004
-
-#define S_PORTEN_PONR 16
-#define V_PORTEN_PONR(x) ((x) << S_PORTEN_PONR)
-#define F_PORTEN_PONR V_PORTEN_PONR(1U)
-
-#define S_PORTEN_POND 12
-#define V_PORTEN_POND(x) ((x) << S_PORTEN_POND)
-#define F_PORTEN_POND V_PORTEN_POND(1U)
-
-#define S_SDRHALFWORD0 8
-#define V_SDRHALFWORD0(x) ((x) << S_SDRHALFWORD0)
-#define F_SDRHALFWORD0 V_SDRHALFWORD0(1U)
-
-#define S_DDREN 4
-#define V_DDREN(x) ((x) << S_DDREN)
-#define F_DDREN V_DDREN(1U)
-
-#define S_DBG_PORTEN 0
-#define V_DBG_PORTEN(x) ((x) << S_DBG_PORTEN)
-#define F_DBG_PORTEN V_DBG_PORTEN(1U)
-
-#define A_DBG_DBG1_CFG 0x6008
-#define A_DBG_DBG1_EN 0x600c
-
-#define S_CLK_EN_ON_DBG1 20
-#define V_CLK_EN_ON_DBG1(x) ((x) << S_CLK_EN_ON_DBG1)
-#define F_CLK_EN_ON_DBG1 V_CLK_EN_ON_DBG1(1U)
-
-#define A_DBG_GPIO_EN 0x6010
-
-#define S_GPIO15_OEN 31
-#define V_GPIO15_OEN(x) ((x) << S_GPIO15_OEN)
-#define F_GPIO15_OEN V_GPIO15_OEN(1U)
-
-#define S_GPIO14_OEN 30
-#define V_GPIO14_OEN(x) ((x) << S_GPIO14_OEN)
-#define F_GPIO14_OEN V_GPIO14_OEN(1U)
-
-#define S_GPIO13_OEN 29
-#define V_GPIO13_OEN(x) ((x) << S_GPIO13_OEN)
-#define F_GPIO13_OEN V_GPIO13_OEN(1U)
-
-#define S_GPIO12_OEN 28
-#define V_GPIO12_OEN(x) ((x) << S_GPIO12_OEN)
-#define F_GPIO12_OEN V_GPIO12_OEN(1U)
-
-#define S_GPIO11_OEN 27
-#define V_GPIO11_OEN(x) ((x) << S_GPIO11_OEN)
-#define F_GPIO11_OEN V_GPIO11_OEN(1U)
-
-#define S_GPIO10_OEN 26
-#define V_GPIO10_OEN(x) ((x) << S_GPIO10_OEN)
-#define F_GPIO10_OEN V_GPIO10_OEN(1U)
-
-#define S_GPIO9_OEN 25
-#define V_GPIO9_OEN(x) ((x) << S_GPIO9_OEN)
-#define F_GPIO9_OEN V_GPIO9_OEN(1U)
-
-#define S_GPIO8_OEN 24
-#define V_GPIO8_OEN(x) ((x) << S_GPIO8_OEN)
-#define F_GPIO8_OEN V_GPIO8_OEN(1U)
-
-#define S_GPIO7_OEN 23
-#define V_GPIO7_OEN(x) ((x) << S_GPIO7_OEN)
-#define F_GPIO7_OEN V_GPIO7_OEN(1U)
-
-#define S_GPIO6_OEN 22
-#define V_GPIO6_OEN(x) ((x) << S_GPIO6_OEN)
-#define F_GPIO6_OEN V_GPIO6_OEN(1U)
-
-#define S_GPIO5_OEN 21
-#define V_GPIO5_OEN(x) ((x) << S_GPIO5_OEN)
-#define F_GPIO5_OEN V_GPIO5_OEN(1U)
-
-#define S_GPIO4_OEN 20
-#define V_GPIO4_OEN(x) ((x) << S_GPIO4_OEN)
-#define F_GPIO4_OEN V_GPIO4_OEN(1U)
-
-#define S_GPIO3_OEN 19
-#define V_GPIO3_OEN(x) ((x) << S_GPIO3_OEN)
-#define F_GPIO3_OEN V_GPIO3_OEN(1U)
-
-#define S_GPIO2_OEN 18
-#define V_GPIO2_OEN(x) ((x) << S_GPIO2_OEN)
-#define F_GPIO2_OEN V_GPIO2_OEN(1U)
-
-#define S_GPIO1_OEN 17
-#define V_GPIO1_OEN(x) ((x) << S_GPIO1_OEN)
-#define F_GPIO1_OEN V_GPIO1_OEN(1U)
-
-#define S_GPIO0_OEN 16
-#define V_GPIO0_OEN(x) ((x) << S_GPIO0_OEN)
-#define F_GPIO0_OEN V_GPIO0_OEN(1U)
-
-#define S_GPIO15_OUT_VAL 15
-#define V_GPIO15_OUT_VAL(x) ((x) << S_GPIO15_OUT_VAL)
-#define F_GPIO15_OUT_VAL V_GPIO15_OUT_VAL(1U)
-
-#define S_GPIO14_OUT_VAL 14
-#define V_GPIO14_OUT_VAL(x) ((x) << S_GPIO14_OUT_VAL)
-#define F_GPIO14_OUT_VAL V_GPIO14_OUT_VAL(1U)
-
-#define S_GPIO13_OUT_VAL 13
-#define V_GPIO13_OUT_VAL(x) ((x) << S_GPIO13_OUT_VAL)
-#define F_GPIO13_OUT_VAL V_GPIO13_OUT_VAL(1U)
-
-#define S_GPIO12_OUT_VAL 12
-#define V_GPIO12_OUT_VAL(x) ((x) << S_GPIO12_OUT_VAL)
-#define F_GPIO12_OUT_VAL V_GPIO12_OUT_VAL(1U)
-
-#define S_GPIO11_OUT_VAL 11
-#define V_GPIO11_OUT_VAL(x) ((x) << S_GPIO11_OUT_VAL)
-#define F_GPIO11_OUT_VAL V_GPIO11_OUT_VAL(1U)
-
-#define S_GPIO10_OUT_VAL 10
-#define V_GPIO10_OUT_VAL(x) ((x) << S_GPIO10_OUT_VAL)
-#define F_GPIO10_OUT_VAL V_GPIO10_OUT_VAL(1U)
-
-#define S_GPIO9_OUT_VAL 9
-#define V_GPIO9_OUT_VAL(x) ((x) << S_GPIO9_OUT_VAL)
-#define F_GPIO9_OUT_VAL V_GPIO9_OUT_VAL(1U)
-
-#define S_GPIO8_OUT_VAL 8
-#define V_GPIO8_OUT_VAL(x) ((x) << S_GPIO8_OUT_VAL)
-#define F_GPIO8_OUT_VAL V_GPIO8_OUT_VAL(1U)
-
-#define S_GPIO7_OUT_VAL 7
-#define V_GPIO7_OUT_VAL(x) ((x) << S_GPIO7_OUT_VAL)
-#define F_GPIO7_OUT_VAL V_GPIO7_OUT_VAL(1U)
-
-#define S_GPIO6_OUT_VAL 6
-#define V_GPIO6_OUT_VAL(x) ((x) << S_GPIO6_OUT_VAL)
-#define F_GPIO6_OUT_VAL V_GPIO6_OUT_VAL(1U)
-
-#define S_GPIO5_OUT_VAL 5
-#define V_GPIO5_OUT_VAL(x) ((x) << S_GPIO5_OUT_VAL)
-#define F_GPIO5_OUT_VAL V_GPIO5_OUT_VAL(1U)
-
-#define S_GPIO4_OUT_VAL 4
-#define V_GPIO4_OUT_VAL(x) ((x) << S_GPIO4_OUT_VAL)
-#define F_GPIO4_OUT_VAL V_GPIO4_OUT_VAL(1U)
-
-#define S_GPIO3_OUT_VAL 3
-#define V_GPIO3_OUT_VAL(x) ((x) << S_GPIO3_OUT_VAL)
-#define F_GPIO3_OUT_VAL V_GPIO3_OUT_VAL(1U)
-
-#define S_GPIO2_OUT_VAL 2
-#define V_GPIO2_OUT_VAL(x) ((x) << S_GPIO2_OUT_VAL)
-#define F_GPIO2_OUT_VAL V_GPIO2_OUT_VAL(1U)
-
-#define S_GPIO1_OUT_VAL 1
-#define V_GPIO1_OUT_VAL(x) ((x) << S_GPIO1_OUT_VAL)
-#define F_GPIO1_OUT_VAL V_GPIO1_OUT_VAL(1U)
-
-#define S_GPIO0_OUT_VAL 0
-#define V_GPIO0_OUT_VAL(x) ((x) << S_GPIO0_OUT_VAL)
-#define F_GPIO0_OUT_VAL V_GPIO0_OUT_VAL(1U)
-
-#define A_DBG_GPIO_IN 0x6014
-
-#define S_GPIO15_CHG_DET 31
-#define V_GPIO15_CHG_DET(x) ((x) << S_GPIO15_CHG_DET)
-#define F_GPIO15_CHG_DET V_GPIO15_CHG_DET(1U)
-
-#define S_GPIO14_CHG_DET 30
-#define V_GPIO14_CHG_DET(x) ((x) << S_GPIO14_CHG_DET)
-#define F_GPIO14_CHG_DET V_GPIO14_CHG_DET(1U)
-
-#define S_GPIO13_CHG_DET 29
-#define V_GPIO13_CHG_DET(x) ((x) << S_GPIO13_CHG_DET)
-#define F_GPIO13_CHG_DET V_GPIO13_CHG_DET(1U)
-
-#define S_GPIO12_CHG_DET 28
-#define V_GPIO12_CHG_DET(x) ((x) << S_GPIO12_CHG_DET)
-#define F_GPIO12_CHG_DET V_GPIO12_CHG_DET(1U)
-
-#define S_GPIO11_CHG_DET 27
-#define V_GPIO11_CHG_DET(x) ((x) << S_GPIO11_CHG_DET)
-#define F_GPIO11_CHG_DET V_GPIO11_CHG_DET(1U)
-
-#define S_GPIO10_CHG_DET 26
-#define V_GPIO10_CHG_DET(x) ((x) << S_GPIO10_CHG_DET)
-#define F_GPIO10_CHG_DET V_GPIO10_CHG_DET(1U)
-
-#define S_GPIO9_CHG_DET 25
-#define V_GPIO9_CHG_DET(x) ((x) << S_GPIO9_CHG_DET)
-#define F_GPIO9_CHG_DET V_GPIO9_CHG_DET(1U)
-
-#define S_GPIO8_CHG_DET 24
-#define V_GPIO8_CHG_DET(x) ((x) << S_GPIO8_CHG_DET)
-#define F_GPIO8_CHG_DET V_GPIO8_CHG_DET(1U)
-
-#define S_GPIO7_CHG_DET 23
-#define V_GPIO7_CHG_DET(x) ((x) << S_GPIO7_CHG_DET)
-#define F_GPIO7_CHG_DET V_GPIO7_CHG_DET(1U)
-
-#define S_GPIO6_CHG_DET 22
-#define V_GPIO6_CHG_DET(x) ((x) << S_GPIO6_CHG_DET)
-#define F_GPIO6_CHG_DET V_GPIO6_CHG_DET(1U)
-
-#define S_GPIO5_CHG_DET 21
-#define V_GPIO5_CHG_DET(x) ((x) << S_GPIO5_CHG_DET)
-#define F_GPIO5_CHG_DET V_GPIO5_CHG_DET(1U)
-
-#define S_GPIO4_CHG_DET 20
-#define V_GPIO4_CHG_DET(x) ((x) << S_GPIO4_CHG_DET)
-#define F_GPIO4_CHG_DET V_GPIO4_CHG_DET(1U)
-
-#define S_GPIO3_CHG_DET 19
-#define V_GPIO3_CHG_DET(x) ((x) << S_GPIO3_CHG_DET)
-#define F_GPIO3_CHG_DET V_GPIO3_CHG_DET(1U)
-
-#define S_GPIO2_CHG_DET 18
-#define V_GPIO2_CHG_DET(x) ((x) << S_GPIO2_CHG_DET)
-#define F_GPIO2_CHG_DET V_GPIO2_CHG_DET(1U)
-
-#define S_GPIO1_CHG_DET 17
-#define V_GPIO1_CHG_DET(x) ((x) << S_GPIO1_CHG_DET)
-#define F_GPIO1_CHG_DET V_GPIO1_CHG_DET(1U)
-
-#define S_GPIO0_CHG_DET 16
-#define V_GPIO0_CHG_DET(x) ((x) << S_GPIO0_CHG_DET)
-#define F_GPIO0_CHG_DET V_GPIO0_CHG_DET(1U)
-
-#define S_GPIO15_IN 15
-#define V_GPIO15_IN(x) ((x) << S_GPIO15_IN)
-#define F_GPIO15_IN V_GPIO15_IN(1U)
-
-#define S_GPIO14_IN 14
-#define V_GPIO14_IN(x) ((x) << S_GPIO14_IN)
-#define F_GPIO14_IN V_GPIO14_IN(1U)
-
-#define S_GPIO13_IN 13
-#define V_GPIO13_IN(x) ((x) << S_GPIO13_IN)
-#define F_GPIO13_IN V_GPIO13_IN(1U)
-
-#define S_GPIO12_IN 12
-#define V_GPIO12_IN(x) ((x) << S_GPIO12_IN)
-#define F_GPIO12_IN V_GPIO12_IN(1U)
-
-#define S_GPIO11_IN 11
-#define V_GPIO11_IN(x) ((x) << S_GPIO11_IN)
-#define F_GPIO11_IN V_GPIO11_IN(1U)
-
-#define S_GPIO10_IN 10
-#define V_GPIO10_IN(x) ((x) << S_GPIO10_IN)
-#define F_GPIO10_IN V_GPIO10_IN(1U)
-
-#define S_GPIO9_IN 9
-#define V_GPIO9_IN(x) ((x) << S_GPIO9_IN)
-#define F_GPIO9_IN V_GPIO9_IN(1U)
-
-#define S_GPIO8_IN 8
-#define V_GPIO8_IN(x) ((x) << S_GPIO8_IN)
-#define F_GPIO8_IN V_GPIO8_IN(1U)
-
-#define S_GPIO7_IN 7
-#define V_GPIO7_IN(x) ((x) << S_GPIO7_IN)
-#define F_GPIO7_IN V_GPIO7_IN(1U)
-
-#define S_GPIO6_IN 6
-#define V_GPIO6_IN(x) ((x) << S_GPIO6_IN)
-#define F_GPIO6_IN V_GPIO6_IN(1U)
-
-#define S_GPIO5_IN 5
-#define V_GPIO5_IN(x) ((x) << S_GPIO5_IN)
-#define F_GPIO5_IN V_GPIO5_IN(1U)
-
-#define S_GPIO4_IN 4
-#define V_GPIO4_IN(x) ((x) << S_GPIO4_IN)
-#define F_GPIO4_IN V_GPIO4_IN(1U)
-
-#define S_GPIO3_IN 3
-#define V_GPIO3_IN(x) ((x) << S_GPIO3_IN)
-#define F_GPIO3_IN V_GPIO3_IN(1U)
-
-#define S_GPIO2_IN 2
-#define V_GPIO2_IN(x) ((x) << S_GPIO2_IN)
-#define F_GPIO2_IN V_GPIO2_IN(1U)
-
-#define S_GPIO1_IN 1
-#define V_GPIO1_IN(x) ((x) << S_GPIO1_IN)
-#define F_GPIO1_IN V_GPIO1_IN(1U)
-
-#define S_GPIO0_IN 0
-#define V_GPIO0_IN(x) ((x) << S_GPIO0_IN)
-#define F_GPIO0_IN V_GPIO0_IN(1U)
-
-#define A_DBG_INT_ENABLE 0x6018
-
-#define S_IBM_FDL_FAIL_INT_ENBL 25
-#define V_IBM_FDL_FAIL_INT_ENBL(x) ((x) << S_IBM_FDL_FAIL_INT_ENBL)
-#define F_IBM_FDL_FAIL_INT_ENBL V_IBM_FDL_FAIL_INT_ENBL(1U)
-
-#define S_ARM_FAIL_INT_ENBL 24
-#define V_ARM_FAIL_INT_ENBL(x) ((x) << S_ARM_FAIL_INT_ENBL)
-#define F_ARM_FAIL_INT_ENBL V_ARM_FAIL_INT_ENBL(1U)
-
-#define S_ARM_ERROR_OUT_INT_ENBL 23
-#define V_ARM_ERROR_OUT_INT_ENBL(x) ((x) << S_ARM_ERROR_OUT_INT_ENBL)
-#define F_ARM_ERROR_OUT_INT_ENBL V_ARM_ERROR_OUT_INT_ENBL(1U)
-
-#define S_PLL_LOCK_LOST_INT_ENBL 22
-#define V_PLL_LOCK_LOST_INT_ENBL(x) ((x) << S_PLL_LOCK_LOST_INT_ENBL)
-#define F_PLL_LOCK_LOST_INT_ENBL V_PLL_LOCK_LOST_INT_ENBL(1U)
-
-#define S_C_LOCK 21
-#define V_C_LOCK(x) ((x) << S_C_LOCK)
-#define F_C_LOCK V_C_LOCK(1U)
-
-#define S_M_LOCK 20
-#define V_M_LOCK(x) ((x) << S_M_LOCK)
-#define F_M_LOCK V_M_LOCK(1U)
-
-#define S_U_LOCK 19
-#define V_U_LOCK(x) ((x) << S_U_LOCK)
-#define F_U_LOCK V_U_LOCK(1U)
-
-#define S_PCIE_LOCK 18
-#define V_PCIE_LOCK(x) ((x) << S_PCIE_LOCK)
-#define F_PCIE_LOCK V_PCIE_LOCK(1U)
-
-#define S_KX_LOCK 17
-#define V_KX_LOCK(x) ((x) << S_KX_LOCK)
-#define F_KX_LOCK V_KX_LOCK(1U)
-
-#define S_KR_LOCK 16
-#define V_KR_LOCK(x) ((x) << S_KR_LOCK)
-#define F_KR_LOCK V_KR_LOCK(1U)
-
-#define S_GPIO15 15
-#define V_GPIO15(x) ((x) << S_GPIO15)
-#define F_GPIO15 V_GPIO15(1U)
-
-#define S_GPIO14 14
-#define V_GPIO14(x) ((x) << S_GPIO14)
-#define F_GPIO14 V_GPIO14(1U)
-
-#define S_GPIO13 13
-#define V_GPIO13(x) ((x) << S_GPIO13)
-#define F_GPIO13 V_GPIO13(1U)
-
-#define S_GPIO12 12
-#define V_GPIO12(x) ((x) << S_GPIO12)
-#define F_GPIO12 V_GPIO12(1U)
-
-#define S_GPIO11 11
-#define V_GPIO11(x) ((x) << S_GPIO11)
-#define F_GPIO11 V_GPIO11(1U)
-
-#define S_GPIO10 10
-#define V_GPIO10(x) ((x) << S_GPIO10)
-#define F_GPIO10 V_GPIO10(1U)
-
-#define S_GPIO9 9
-#define V_GPIO9(x) ((x) << S_GPIO9)
-#define F_GPIO9 V_GPIO9(1U)
-
-#define S_GPIO8 8
-#define V_GPIO8(x) ((x) << S_GPIO8)
-#define F_GPIO8 V_GPIO8(1U)
-
-#define S_GPIO7 7
-#define V_GPIO7(x) ((x) << S_GPIO7)
-#define F_GPIO7 V_GPIO7(1U)
-
-#define S_GPIO6 6
-#define V_GPIO6(x) ((x) << S_GPIO6)
-#define F_GPIO6 V_GPIO6(1U)
-
-#define S_GPIO5 5
-#define V_GPIO5(x) ((x) << S_GPIO5)
-#define F_GPIO5 V_GPIO5(1U)
-
-#define S_GPIO4 4
-#define V_GPIO4(x) ((x) << S_GPIO4)
-#define F_GPIO4 V_GPIO4(1U)
-
-#define S_GPIO3 3
-#define V_GPIO3(x) ((x) << S_GPIO3)
-#define F_GPIO3 V_GPIO3(1U)
-
-#define S_GPIO2 2
-#define V_GPIO2(x) ((x) << S_GPIO2)
-#define F_GPIO2 V_GPIO2(1U)
-
-#define S_GPIO1 1
-#define V_GPIO1(x) ((x) << S_GPIO1)
-#define F_GPIO1 V_GPIO1(1U)
-
-#define S_GPIO0 0
-#define V_GPIO0(x) ((x) << S_GPIO0)
-#define F_GPIO0 V_GPIO0(1U)
-
-#define S_GPIO19 29
-#define V_GPIO19(x) ((x) << S_GPIO19)
-#define F_GPIO19 V_GPIO19(1U)
-
-#define S_GPIO18 28
-#define V_GPIO18(x) ((x) << S_GPIO18)
-#define F_GPIO18 V_GPIO18(1U)
-
-#define S_GPIO17 27
-#define V_GPIO17(x) ((x) << S_GPIO17)
-#define F_GPIO17 V_GPIO17(1U)
-
-#define S_GPIO16 26
-#define V_GPIO16(x) ((x) << S_GPIO16)
-#define F_GPIO16 V_GPIO16(1U)
-
-#define A_DBG_INT_CAUSE 0x601c
-
-#define S_IBM_FDL_FAIL_INT_CAUSE 25
-#define V_IBM_FDL_FAIL_INT_CAUSE(x) ((x) << S_IBM_FDL_FAIL_INT_CAUSE)
-#define F_IBM_FDL_FAIL_INT_CAUSE V_IBM_FDL_FAIL_INT_CAUSE(1U)
-
-#define S_ARM_FAIL_INT_CAUSE 24
-#define V_ARM_FAIL_INT_CAUSE(x) ((x) << S_ARM_FAIL_INT_CAUSE)
-#define F_ARM_FAIL_INT_CAUSE V_ARM_FAIL_INT_CAUSE(1U)
-
-#define S_ARM_ERROR_OUT_INT_CAUSE 23
-#define V_ARM_ERROR_OUT_INT_CAUSE(x) ((x) << S_ARM_ERROR_OUT_INT_CAUSE)
-#define F_ARM_ERROR_OUT_INT_CAUSE V_ARM_ERROR_OUT_INT_CAUSE(1U)
-
-#define S_PLL_LOCK_LOST_INT_CAUSE 22
-#define V_PLL_LOCK_LOST_INT_CAUSE(x) ((x) << S_PLL_LOCK_LOST_INT_CAUSE)
-#define F_PLL_LOCK_LOST_INT_CAUSE V_PLL_LOCK_LOST_INT_CAUSE(1U)
-
-#define A_DBG_DBG0_RST_VALUE 0x6020
-
-#define S_DEBUGDATA 0
-#define M_DEBUGDATA 0xffffU
-#define V_DEBUGDATA(x) ((x) << S_DEBUGDATA)
-#define G_DEBUGDATA(x) (((x) >> S_DEBUGDATA) & M_DEBUGDATA)
-
-#define A_DBG_OVERWRSERCFG_EN 0x6024
-
-#define S_OVERWRSERCFG_EN 0
-#define V_OVERWRSERCFG_EN(x) ((x) << S_OVERWRSERCFG_EN)
-#define F_OVERWRSERCFG_EN V_OVERWRSERCFG_EN(1U)
-
-#define A_DBG_PLL_OCLK_PAD_EN 0x6028
-
-#define S_PCIE_OCLK_EN 20
-#define V_PCIE_OCLK_EN(x) ((x) << S_PCIE_OCLK_EN)
-#define F_PCIE_OCLK_EN V_PCIE_OCLK_EN(1U)
-
-#define S_KX_OCLK_EN 16
-#define V_KX_OCLK_EN(x) ((x) << S_KX_OCLK_EN)
-#define F_KX_OCLK_EN V_KX_OCLK_EN(1U)
-
-#define S_U_OCLK_EN 12
-#define V_U_OCLK_EN(x) ((x) << S_U_OCLK_EN)
-#define F_U_OCLK_EN V_U_OCLK_EN(1U)
-
-#define S_KR_OCLK_EN 8
-#define V_KR_OCLK_EN(x) ((x) << S_KR_OCLK_EN)
-#define F_KR_OCLK_EN V_KR_OCLK_EN(1U)
-
-#define S_M_OCLK_EN 4
-#define V_M_OCLK_EN(x) ((x) << S_M_OCLK_EN)
-#define F_M_OCLK_EN V_M_OCLK_EN(1U)
-
-#define S_C_OCLK_EN 0
-#define V_C_OCLK_EN(x) ((x) << S_C_OCLK_EN)
-#define F_C_OCLK_EN V_C_OCLK_EN(1U)
-
-#define A_DBG_PLL_LOCK 0x602c
-
-#define S_PLL_P_LOCK 20
-#define V_PLL_P_LOCK(x) ((x) << S_PLL_P_LOCK)
-#define F_PLL_P_LOCK V_PLL_P_LOCK(1U)
-
-#define S_PLL_KX_LOCK 16
-#define V_PLL_KX_LOCK(x) ((x) << S_PLL_KX_LOCK)
-#define F_PLL_KX_LOCK V_PLL_KX_LOCK(1U)
-
-#define S_PLL_U_LOCK 12
-#define V_PLL_U_LOCK(x) ((x) << S_PLL_U_LOCK)
-#define F_PLL_U_LOCK V_PLL_U_LOCK(1U)
-
-#define S_PLL_KR_LOCK 8
-#define V_PLL_KR_LOCK(x) ((x) << S_PLL_KR_LOCK)
-#define F_PLL_KR_LOCK V_PLL_KR_LOCK(1U)
-
-#define S_PLL_M_LOCK 4
-#define V_PLL_M_LOCK(x) ((x) << S_PLL_M_LOCK)
-#define F_PLL_M_LOCK V_PLL_M_LOCK(1U)
-
-#define S_PLL_C_LOCK 0
-#define V_PLL_C_LOCK(x) ((x) << S_PLL_C_LOCK)
-#define F_PLL_C_LOCK V_PLL_C_LOCK(1U)
-
-#define A_DBG_GPIO_ACT_LOW 0x6030
-
-#define S_P_LOCK_ACT_LOW 21
-#define V_P_LOCK_ACT_LOW(x) ((x) << S_P_LOCK_ACT_LOW)
-#define F_P_LOCK_ACT_LOW V_P_LOCK_ACT_LOW(1U)
-
-#define S_C_LOCK_ACT_LOW 20
-#define V_C_LOCK_ACT_LOW(x) ((x) << S_C_LOCK_ACT_LOW)
-#define F_C_LOCK_ACT_LOW V_C_LOCK_ACT_LOW(1U)
-
-#define S_M_LOCK_ACT_LOW 19
-#define V_M_LOCK_ACT_LOW(x) ((x) << S_M_LOCK_ACT_LOW)
-#define F_M_LOCK_ACT_LOW V_M_LOCK_ACT_LOW(1U)
-
-#define S_U_LOCK_ACT_LOW 18
-#define V_U_LOCK_ACT_LOW(x) ((x) << S_U_LOCK_ACT_LOW)
-#define F_U_LOCK_ACT_LOW V_U_LOCK_ACT_LOW(1U)
-
-#define S_KR_LOCK_ACT_LOW 17
-#define V_KR_LOCK_ACT_LOW(x) ((x) << S_KR_LOCK_ACT_LOW)
-#define F_KR_LOCK_ACT_LOW V_KR_LOCK_ACT_LOW(1U)
-
-#define S_KX_LOCK_ACT_LOW 16
-#define V_KX_LOCK_ACT_LOW(x) ((x) << S_KX_LOCK_ACT_LOW)
-#define F_KX_LOCK_ACT_LOW V_KX_LOCK_ACT_LOW(1U)
-
-#define S_GPIO15_ACT_LOW 15
-#define V_GPIO15_ACT_LOW(x) ((x) << S_GPIO15_ACT_LOW)
-#define F_GPIO15_ACT_LOW V_GPIO15_ACT_LOW(1U)
-
-#define S_GPIO14_ACT_LOW 14
-#define V_GPIO14_ACT_LOW(x) ((x) << S_GPIO14_ACT_LOW)
-#define F_GPIO14_ACT_LOW V_GPIO14_ACT_LOW(1U)
-
-#define S_GPIO13_ACT_LOW 13
-#define V_GPIO13_ACT_LOW(x) ((x) << S_GPIO13_ACT_LOW)
-#define F_GPIO13_ACT_LOW V_GPIO13_ACT_LOW(1U)
-
-#define S_GPIO12_ACT_LOW 12
-#define V_GPIO12_ACT_LOW(x) ((x) << S_GPIO12_ACT_LOW)
-#define F_GPIO12_ACT_LOW V_GPIO12_ACT_LOW(1U)
-
-#define S_GPIO11_ACT_LOW 11
-#define V_GPIO11_ACT_LOW(x) ((x) << S_GPIO11_ACT_LOW)
-#define F_GPIO11_ACT_LOW V_GPIO11_ACT_LOW(1U)
-
-#define S_GPIO10_ACT_LOW 10
-#define V_GPIO10_ACT_LOW(x) ((x) << S_GPIO10_ACT_LOW)
-#define F_GPIO10_ACT_LOW V_GPIO10_ACT_LOW(1U)
-
-#define S_GPIO9_ACT_LOW 9
-#define V_GPIO9_ACT_LOW(x) ((x) << S_GPIO9_ACT_LOW)
-#define F_GPIO9_ACT_LOW V_GPIO9_ACT_LOW(1U)
-
-#define S_GPIO8_ACT_LOW 8
-#define V_GPIO8_ACT_LOW(x) ((x) << S_GPIO8_ACT_LOW)
-#define F_GPIO8_ACT_LOW V_GPIO8_ACT_LOW(1U)
-
-#define S_GPIO7_ACT_LOW 7
-#define V_GPIO7_ACT_LOW(x) ((x) << S_GPIO7_ACT_LOW)
-#define F_GPIO7_ACT_LOW V_GPIO7_ACT_LOW(1U)
-
-#define S_GPIO6_ACT_LOW 6
-#define V_GPIO6_ACT_LOW(x) ((x) << S_GPIO6_ACT_LOW)
-#define F_GPIO6_ACT_LOW V_GPIO6_ACT_LOW(1U)
-
-#define S_GPIO5_ACT_LOW 5
-#define V_GPIO5_ACT_LOW(x) ((x) << S_GPIO5_ACT_LOW)
-#define F_GPIO5_ACT_LOW V_GPIO5_ACT_LOW(1U)
-
-#define S_GPIO4_ACT_LOW 4
-#define V_GPIO4_ACT_LOW(x) ((x) << S_GPIO4_ACT_LOW)
-#define F_GPIO4_ACT_LOW V_GPIO4_ACT_LOW(1U)
-
-#define S_GPIO3_ACT_LOW 3
-#define V_GPIO3_ACT_LOW(x) ((x) << S_GPIO3_ACT_LOW)
-#define F_GPIO3_ACT_LOW V_GPIO3_ACT_LOW(1U)
-
-#define S_GPIO2_ACT_LOW 2
-#define V_GPIO2_ACT_LOW(x) ((x) << S_GPIO2_ACT_LOW)
-#define F_GPIO2_ACT_LOW V_GPIO2_ACT_LOW(1U)
-
-#define S_GPIO1_ACT_LOW 1
-#define V_GPIO1_ACT_LOW(x) ((x) << S_GPIO1_ACT_LOW)
-#define F_GPIO1_ACT_LOW V_GPIO1_ACT_LOW(1U)
-
-#define S_GPIO0_ACT_LOW 0
-#define V_GPIO0_ACT_LOW(x) ((x) << S_GPIO0_ACT_LOW)
-#define F_GPIO0_ACT_LOW V_GPIO0_ACT_LOW(1U)
-
-#define S_GPIO19_ACT_LOW 25
-#define V_GPIO19_ACT_LOW(x) ((x) << S_GPIO19_ACT_LOW)
-#define F_GPIO19_ACT_LOW V_GPIO19_ACT_LOW(1U)
-
-#define S_GPIO18_ACT_LOW 24
-#define V_GPIO18_ACT_LOW(x) ((x) << S_GPIO18_ACT_LOW)
-#define F_GPIO18_ACT_LOW V_GPIO18_ACT_LOW(1U)
-
-#define S_GPIO17_ACT_LOW 23
-#define V_GPIO17_ACT_LOW(x) ((x) << S_GPIO17_ACT_LOW)
-#define F_GPIO17_ACT_LOW V_GPIO17_ACT_LOW(1U)
-
-#define S_GPIO16_ACT_LOW 22
-#define V_GPIO16_ACT_LOW(x) ((x) << S_GPIO16_ACT_LOW)
-#define F_GPIO16_ACT_LOW V_GPIO16_ACT_LOW(1U)
-
-#define A_DBG_EFUSE_BYTE0_3 0x6034
-#define A_DBG_EFUSE_BYTE4_7 0x6038
-#define A_DBG_EFUSE_BYTE8_11 0x603c
-#define A_DBG_EFUSE_BYTE12_15 0x6040
-#define A_DBG_STATIC_U_PLL_CONF 0x6044
-
-#define S_STATIC_U_PLL_MULT 23
-#define M_STATIC_U_PLL_MULT 0x1ffU
-#define V_STATIC_U_PLL_MULT(x) ((x) << S_STATIC_U_PLL_MULT)
-#define G_STATIC_U_PLL_MULT(x) (((x) >> S_STATIC_U_PLL_MULT) & M_STATIC_U_PLL_MULT)
-
-#define S_STATIC_U_PLL_PREDIV 18
-#define M_STATIC_U_PLL_PREDIV 0x1fU
-#define V_STATIC_U_PLL_PREDIV(x) ((x) << S_STATIC_U_PLL_PREDIV)
-#define G_STATIC_U_PLL_PREDIV(x) (((x) >> S_STATIC_U_PLL_PREDIV) & M_STATIC_U_PLL_PREDIV)
-
-#define S_STATIC_U_PLL_RANGEA 14
-#define M_STATIC_U_PLL_RANGEA 0xfU
-#define V_STATIC_U_PLL_RANGEA(x) ((x) << S_STATIC_U_PLL_RANGEA)
-#define G_STATIC_U_PLL_RANGEA(x) (((x) >> S_STATIC_U_PLL_RANGEA) & M_STATIC_U_PLL_RANGEA)
-
-#define S_STATIC_U_PLL_RANGEB 10
-#define M_STATIC_U_PLL_RANGEB 0xfU
-#define V_STATIC_U_PLL_RANGEB(x) ((x) << S_STATIC_U_PLL_RANGEB)
-#define G_STATIC_U_PLL_RANGEB(x) (((x) >> S_STATIC_U_PLL_RANGEB) & M_STATIC_U_PLL_RANGEB)
-
-#define S_STATIC_U_PLL_TUNE 0
-#define M_STATIC_U_PLL_TUNE 0x3ffU
-#define V_STATIC_U_PLL_TUNE(x) ((x) << S_STATIC_U_PLL_TUNE)
-#define G_STATIC_U_PLL_TUNE(x) (((x) >> S_STATIC_U_PLL_TUNE) & M_STATIC_U_PLL_TUNE)
-
-#define A_DBG_STATIC_C_PLL_CONF 0x6048
-
-#define S_STATIC_C_PLL_MULT 23
-#define M_STATIC_C_PLL_MULT 0x1ffU
-#define V_STATIC_C_PLL_MULT(x) ((x) << S_STATIC_C_PLL_MULT)
-#define G_STATIC_C_PLL_MULT(x) (((x) >> S_STATIC_C_PLL_MULT) & M_STATIC_C_PLL_MULT)
-
-#define S_STATIC_C_PLL_PREDIV 18
-#define M_STATIC_C_PLL_PREDIV 0x1fU
-#define V_STATIC_C_PLL_PREDIV(x) ((x) << S_STATIC_C_PLL_PREDIV)
-#define G_STATIC_C_PLL_PREDIV(x) (((x) >> S_STATIC_C_PLL_PREDIV) & M_STATIC_C_PLL_PREDIV)
-
-#define S_STATIC_C_PLL_RANGEA 14
-#define M_STATIC_C_PLL_RANGEA 0xfU
-#define V_STATIC_C_PLL_RANGEA(x) ((x) << S_STATIC_C_PLL_RANGEA)
-#define G_STATIC_C_PLL_RANGEA(x) (((x) >> S_STATIC_C_PLL_RANGEA) & M_STATIC_C_PLL_RANGEA)
-
-#define S_STATIC_C_PLL_RANGEB 10
-#define M_STATIC_C_PLL_RANGEB 0xfU
-#define V_STATIC_C_PLL_RANGEB(x) ((x) << S_STATIC_C_PLL_RANGEB)
-#define G_STATIC_C_PLL_RANGEB(x) (((x) >> S_STATIC_C_PLL_RANGEB) & M_STATIC_C_PLL_RANGEB)
-
-#define S_STATIC_C_PLL_TUNE 0
-#define M_STATIC_C_PLL_TUNE 0x3ffU
-#define V_STATIC_C_PLL_TUNE(x) ((x) << S_STATIC_C_PLL_TUNE)
-#define G_STATIC_C_PLL_TUNE(x) (((x) >> S_STATIC_C_PLL_TUNE) & M_STATIC_C_PLL_TUNE)
-
-#define A_DBG_STATIC_M_PLL_CONF 0x604c
-
-#define S_STATIC_M_PLL_MULT 23
-#define M_STATIC_M_PLL_MULT 0x1ffU
-#define V_STATIC_M_PLL_MULT(x) ((x) << S_STATIC_M_PLL_MULT)
-#define G_STATIC_M_PLL_MULT(x) (((x) >> S_STATIC_M_PLL_MULT) & M_STATIC_M_PLL_MULT)
-
-#define S_STATIC_M_PLL_PREDIV 18
-#define M_STATIC_M_PLL_PREDIV 0x1fU
-#define V_STATIC_M_PLL_PREDIV(x) ((x) << S_STATIC_M_PLL_PREDIV)
-#define G_STATIC_M_PLL_PREDIV(x) (((x) >> S_STATIC_M_PLL_PREDIV) & M_STATIC_M_PLL_PREDIV)
-
-#define S_STATIC_M_PLL_RANGEA 14
-#define M_STATIC_M_PLL_RANGEA 0xfU
-#define V_STATIC_M_PLL_RANGEA(x) ((x) << S_STATIC_M_PLL_RANGEA)
-#define G_STATIC_M_PLL_RANGEA(x) (((x) >> S_STATIC_M_PLL_RANGEA) & M_STATIC_M_PLL_RANGEA)
-
-#define S_STATIC_M_PLL_RANGEB 10
-#define M_STATIC_M_PLL_RANGEB 0xfU
-#define V_STATIC_M_PLL_RANGEB(x) ((x) << S_STATIC_M_PLL_RANGEB)
-#define G_STATIC_M_PLL_RANGEB(x) (((x) >> S_STATIC_M_PLL_RANGEB) & M_STATIC_M_PLL_RANGEB)
-
-#define S_STATIC_M_PLL_TUNE 0
-#define M_STATIC_M_PLL_TUNE 0x3ffU
-#define V_STATIC_M_PLL_TUNE(x) ((x) << S_STATIC_M_PLL_TUNE)
-#define G_STATIC_M_PLL_TUNE(x) (((x) >> S_STATIC_M_PLL_TUNE) & M_STATIC_M_PLL_TUNE)
-
-#define A_DBG_STATIC_KX_PLL_CONF 0x6050
-
-#define S_STATIC_KX_PLL_C 21
-#define M_STATIC_KX_PLL_C 0xffU
-#define V_STATIC_KX_PLL_C(x) ((x) << S_STATIC_KX_PLL_C)
-#define G_STATIC_KX_PLL_C(x) (((x) >> S_STATIC_KX_PLL_C) & M_STATIC_KX_PLL_C)
-
-#define S_STATIC_KX_PLL_M 15
-#define M_STATIC_KX_PLL_M 0x3fU
-#define V_STATIC_KX_PLL_M(x) ((x) << S_STATIC_KX_PLL_M)
-#define G_STATIC_KX_PLL_M(x) (((x) >> S_STATIC_KX_PLL_M) & M_STATIC_KX_PLL_M)
-
-#define S_STATIC_KX_PLL_N1 11
-#define M_STATIC_KX_PLL_N1 0xfU
-#define V_STATIC_KX_PLL_N1(x) ((x) << S_STATIC_KX_PLL_N1)
-#define G_STATIC_KX_PLL_N1(x) (((x) >> S_STATIC_KX_PLL_N1) & M_STATIC_KX_PLL_N1)
-
-#define S_STATIC_KX_PLL_N2 7
-#define M_STATIC_KX_PLL_N2 0xfU
-#define V_STATIC_KX_PLL_N2(x) ((x) << S_STATIC_KX_PLL_N2)
-#define G_STATIC_KX_PLL_N2(x) (((x) >> S_STATIC_KX_PLL_N2) & M_STATIC_KX_PLL_N2)
-
-#define S_STATIC_KX_PLL_N3 3
-#define M_STATIC_KX_PLL_N3 0xfU
-#define V_STATIC_KX_PLL_N3(x) ((x) << S_STATIC_KX_PLL_N3)
-#define G_STATIC_KX_PLL_N3(x) (((x) >> S_STATIC_KX_PLL_N3) & M_STATIC_KX_PLL_N3)
-
-#define S_STATIC_KX_PLL_P 0
-#define M_STATIC_KX_PLL_P 0x7U
-#define V_STATIC_KX_PLL_P(x) ((x) << S_STATIC_KX_PLL_P)
-#define G_STATIC_KX_PLL_P(x) (((x) >> S_STATIC_KX_PLL_P) & M_STATIC_KX_PLL_P)
-
-#define A_DBG_STATIC_KR_PLL_CONF 0x6054
-
-#define S_STATIC_KR_PLL_C 21
-#define M_STATIC_KR_PLL_C 0xffU
-#define V_STATIC_KR_PLL_C(x) ((x) << S_STATIC_KR_PLL_C)
-#define G_STATIC_KR_PLL_C(x) (((x) >> S_STATIC_KR_PLL_C) & M_STATIC_KR_PLL_C)
-
-#define S_STATIC_KR_PLL_M 15
-#define M_STATIC_KR_PLL_M 0x3fU
-#define V_STATIC_KR_PLL_M(x) ((x) << S_STATIC_KR_PLL_M)
-#define G_STATIC_KR_PLL_M(x) (((x) >> S_STATIC_KR_PLL_M) & M_STATIC_KR_PLL_M)
-
-#define S_STATIC_KR_PLL_N1 11
-#define M_STATIC_KR_PLL_N1 0xfU
-#define V_STATIC_KR_PLL_N1(x) ((x) << S_STATIC_KR_PLL_N1)
-#define G_STATIC_KR_PLL_N1(x) (((x) >> S_STATIC_KR_PLL_N1) & M_STATIC_KR_PLL_N1)
-
-#define S_STATIC_KR_PLL_N2 7
-#define M_STATIC_KR_PLL_N2 0xfU
-#define V_STATIC_KR_PLL_N2(x) ((x) << S_STATIC_KR_PLL_N2)
-#define G_STATIC_KR_PLL_N2(x) (((x) >> S_STATIC_KR_PLL_N2) & M_STATIC_KR_PLL_N2)
-
-#define S_STATIC_KR_PLL_N3 3
-#define M_STATIC_KR_PLL_N3 0xfU
-#define V_STATIC_KR_PLL_N3(x) ((x) << S_STATIC_KR_PLL_N3)
-#define G_STATIC_KR_PLL_N3(x) (((x) >> S_STATIC_KR_PLL_N3) & M_STATIC_KR_PLL_N3)
-
-#define S_STATIC_KR_PLL_P 0
-#define M_STATIC_KR_PLL_P 0x7U
-#define V_STATIC_KR_PLL_P(x) ((x) << S_STATIC_KR_PLL_P)
-#define G_STATIC_KR_PLL_P(x) (((x) >> S_STATIC_KR_PLL_P) & M_STATIC_KR_PLL_P)
-
-#define A_DBG_EXTRA_STATIC_BITS_CONF 0x6058
-
-#define S_STATIC_M_PLL_RESET 30
-#define V_STATIC_M_PLL_RESET(x) ((x) << S_STATIC_M_PLL_RESET)
-#define F_STATIC_M_PLL_RESET V_STATIC_M_PLL_RESET(1U)
-
-#define S_STATIC_M_PLL_SLEEP 29
-#define V_STATIC_M_PLL_SLEEP(x) ((x) << S_STATIC_M_PLL_SLEEP)
-#define F_STATIC_M_PLL_SLEEP V_STATIC_M_PLL_SLEEP(1U)
-
-#define S_STATIC_M_PLL_BYPASS 28
-#define V_STATIC_M_PLL_BYPASS(x) ((x) << S_STATIC_M_PLL_BYPASS)
-#define F_STATIC_M_PLL_BYPASS V_STATIC_M_PLL_BYPASS(1U)
-
-#define S_STATIC_MPLL_CLK_SEL 27
-#define V_STATIC_MPLL_CLK_SEL(x) ((x) << S_STATIC_MPLL_CLK_SEL)
-#define F_STATIC_MPLL_CLK_SEL V_STATIC_MPLL_CLK_SEL(1U)
-
-#define S_STATIC_U_PLL_SLEEP 26
-#define V_STATIC_U_PLL_SLEEP(x) ((x) << S_STATIC_U_PLL_SLEEP)
-#define F_STATIC_U_PLL_SLEEP V_STATIC_U_PLL_SLEEP(1U)
-
-#define S_STATIC_C_PLL_SLEEP 25
-#define V_STATIC_C_PLL_SLEEP(x) ((x) << S_STATIC_C_PLL_SLEEP)
-#define F_STATIC_C_PLL_SLEEP V_STATIC_C_PLL_SLEEP(1U)
-
-#define S_STATIC_LVDS_CLKOUT_SEL 23
-#define M_STATIC_LVDS_CLKOUT_SEL 0x3U
-#define V_STATIC_LVDS_CLKOUT_SEL(x) ((x) << S_STATIC_LVDS_CLKOUT_SEL)
-#define G_STATIC_LVDS_CLKOUT_SEL(x) (((x) >> S_STATIC_LVDS_CLKOUT_SEL) & M_STATIC_LVDS_CLKOUT_SEL)
-
-#define S_STATIC_LVDS_CLKOUT_EN 22
-#define V_STATIC_LVDS_CLKOUT_EN(x) ((x) << S_STATIC_LVDS_CLKOUT_EN)
-#define F_STATIC_LVDS_CLKOUT_EN V_STATIC_LVDS_CLKOUT_EN(1U)
-
-#define S_STATIC_CCLK_FREQ_SEL 20
-#define M_STATIC_CCLK_FREQ_SEL 0x3U
-#define V_STATIC_CCLK_FREQ_SEL(x) ((x) << S_STATIC_CCLK_FREQ_SEL)
-#define G_STATIC_CCLK_FREQ_SEL(x) (((x) >> S_STATIC_CCLK_FREQ_SEL) & M_STATIC_CCLK_FREQ_SEL)
-
-#define S_STATIC_UCLK_FREQ_SEL 18
-#define M_STATIC_UCLK_FREQ_SEL 0x3U
-#define V_STATIC_UCLK_FREQ_SEL(x) ((x) << S_STATIC_UCLK_FREQ_SEL)
-#define G_STATIC_UCLK_FREQ_SEL(x) (((x) >> S_STATIC_UCLK_FREQ_SEL) & M_STATIC_UCLK_FREQ_SEL)
-
-#define S_EXPHYCLK_SEL_EN 17
-#define V_EXPHYCLK_SEL_EN(x) ((x) << S_EXPHYCLK_SEL_EN)
-#define F_EXPHYCLK_SEL_EN V_EXPHYCLK_SEL_EN(1U)
-
-#define S_EXPHYCLK_SEL 15
-#define M_EXPHYCLK_SEL 0x3U
-#define V_EXPHYCLK_SEL(x) ((x) << S_EXPHYCLK_SEL)
-#define G_EXPHYCLK_SEL(x) (((x) >> S_EXPHYCLK_SEL) & M_EXPHYCLK_SEL)
-
-#define S_STATIC_U_PLL_BYPASS 14
-#define V_STATIC_U_PLL_BYPASS(x) ((x) << S_STATIC_U_PLL_BYPASS)
-#define F_STATIC_U_PLL_BYPASS V_STATIC_U_PLL_BYPASS(1U)
-
-#define S_STATIC_C_PLL_BYPASS 13
-#define V_STATIC_C_PLL_BYPASS(x) ((x) << S_STATIC_C_PLL_BYPASS)
-#define F_STATIC_C_PLL_BYPASS V_STATIC_C_PLL_BYPASS(1U)
-
-#define S_STATIC_KR_PLL_BYPASS 12
-#define V_STATIC_KR_PLL_BYPASS(x) ((x) << S_STATIC_KR_PLL_BYPASS)
-#define F_STATIC_KR_PLL_BYPASS V_STATIC_KR_PLL_BYPASS(1U)
-
-#define S_STATIC_KX_PLL_BYPASS 11
-#define V_STATIC_KX_PLL_BYPASS(x) ((x) << S_STATIC_KX_PLL_BYPASS)
-#define F_STATIC_KX_PLL_BYPASS V_STATIC_KX_PLL_BYPASS(1U)
-
-#define S_STATIC_KX_PLL_V 7
-#define M_STATIC_KX_PLL_V 0xfU
-#define V_STATIC_KX_PLL_V(x) ((x) << S_STATIC_KX_PLL_V)
-#define G_STATIC_KX_PLL_V(x) (((x) >> S_STATIC_KX_PLL_V) & M_STATIC_KX_PLL_V)
-
-#define S_STATIC_KR_PLL_V 3
-#define M_STATIC_KR_PLL_V 0xfU
-#define V_STATIC_KR_PLL_V(x) ((x) << S_STATIC_KR_PLL_V)
-#define G_STATIC_KR_PLL_V(x) (((x) >> S_STATIC_KR_PLL_V) & M_STATIC_KR_PLL_V)
-
-#define S_PSRO_SEL 0
-#define M_PSRO_SEL 0x7U
-#define V_PSRO_SEL(x) ((x) << S_PSRO_SEL)
-#define G_PSRO_SEL(x) (((x) >> S_PSRO_SEL) & M_PSRO_SEL)
-
-#define A_DBG_STATIC_OCLK_MUXSEL_CONF 0x605c
-
-#define S_M_OCLK_MUXSEL 12
-#define V_M_OCLK_MUXSEL(x) ((x) << S_M_OCLK_MUXSEL)
-#define F_M_OCLK_MUXSEL V_M_OCLK_MUXSEL(1U)
-
-#define S_C_OCLK_MUXSEL 10
-#define M_C_OCLK_MUXSEL 0x3U
-#define V_C_OCLK_MUXSEL(x) ((x) << S_C_OCLK_MUXSEL)
-#define G_C_OCLK_MUXSEL(x) (((x) >> S_C_OCLK_MUXSEL) & M_C_OCLK_MUXSEL)
-
-#define S_U_OCLK_MUXSEL 8
-#define M_U_OCLK_MUXSEL 0x3U
-#define V_U_OCLK_MUXSEL(x) ((x) << S_U_OCLK_MUXSEL)
-#define G_U_OCLK_MUXSEL(x) (((x) >> S_U_OCLK_MUXSEL) & M_U_OCLK_MUXSEL)
-
-#define S_P_OCLK_MUXSEL 6
-#define M_P_OCLK_MUXSEL 0x3U
-#define V_P_OCLK_MUXSEL(x) ((x) << S_P_OCLK_MUXSEL)
-#define G_P_OCLK_MUXSEL(x) (((x) >> S_P_OCLK_MUXSEL) & M_P_OCLK_MUXSEL)
-
-#define S_KX_OCLK_MUXSEL 3
-#define M_KX_OCLK_MUXSEL 0x7U
-#define V_KX_OCLK_MUXSEL(x) ((x) << S_KX_OCLK_MUXSEL)
-#define G_KX_OCLK_MUXSEL(x) (((x) >> S_KX_OCLK_MUXSEL) & M_KX_OCLK_MUXSEL)
-
-#define S_KR_OCLK_MUXSEL 0
-#define M_KR_OCLK_MUXSEL 0x7U
-#define V_KR_OCLK_MUXSEL(x) ((x) << S_KR_OCLK_MUXSEL)
-#define G_KR_OCLK_MUXSEL(x) (((x) >> S_KR_OCLK_MUXSEL) & M_KR_OCLK_MUXSEL)
-
-#define S_T5_P_OCLK_MUXSEL 13
-#define M_T5_P_OCLK_MUXSEL 0xfU
-#define V_T5_P_OCLK_MUXSEL(x) ((x) << S_T5_P_OCLK_MUXSEL)
-#define G_T5_P_OCLK_MUXSEL(x) (((x) >> S_T5_P_OCLK_MUXSEL) & M_T5_P_OCLK_MUXSEL)
-
-#define S_T6_P_OCLK_MUXSEL 13
-#define M_T6_P_OCLK_MUXSEL 0xfU
-#define V_T6_P_OCLK_MUXSEL(x) ((x) << S_T6_P_OCLK_MUXSEL)
-#define G_T6_P_OCLK_MUXSEL(x) (((x) >> S_T6_P_OCLK_MUXSEL) & M_T6_P_OCLK_MUXSEL)
-
-#define A_DBG_TRACE0_CONF_COMPREG0 0x6060
-#define A_DBG_TRACE0_CONF_COMPREG1 0x6064
-#define A_DBG_TRACE1_CONF_COMPREG0 0x6068
-#define A_DBG_TRACE1_CONF_COMPREG1 0x606c
-#define A_DBG_TRACE0_CONF_MASKREG0 0x6070
-#define A_DBG_TRACE0_CONF_MASKREG1 0x6074
-#define A_DBG_TRACE1_CONF_MASKREG0 0x6078
-#define A_DBG_TRACE1_CONF_MASKREG1 0x607c
-#define A_DBG_TRACE_COUNTER 0x6080
-
-#define S_COUNTER1 16
-#define M_COUNTER1 0xffffU
-#define V_COUNTER1(x) ((x) << S_COUNTER1)
-#define G_COUNTER1(x) (((x) >> S_COUNTER1) & M_COUNTER1)
-
-#define S_COUNTER0 0
-#define M_COUNTER0 0xffffU
-#define V_COUNTER0(x) ((x) << S_COUNTER0)
-#define G_COUNTER0(x) (((x) >> S_COUNTER0) & M_COUNTER0)
-
-#define A_DBG_STATIC_REFCLK_PERIOD 0x6084
-
-#define S_STATIC_REFCLK_PERIOD 0
-#define M_STATIC_REFCLK_PERIOD 0xffffU
-#define V_STATIC_REFCLK_PERIOD(x) ((x) << S_STATIC_REFCLK_PERIOD)
-#define G_STATIC_REFCLK_PERIOD(x) (((x) >> S_STATIC_REFCLK_PERIOD) & M_STATIC_REFCLK_PERIOD)
-
-#define A_DBG_TRACE_CONF 0x6088
-
-#define S_DBG_TRACE_OPERATE_WITH_TRG 5
-#define V_DBG_TRACE_OPERATE_WITH_TRG(x) ((x) << S_DBG_TRACE_OPERATE_WITH_TRG)
-#define F_DBG_TRACE_OPERATE_WITH_TRG V_DBG_TRACE_OPERATE_WITH_TRG(1U)
-
-#define S_DBG_TRACE_OPERATE_EN 4
-#define V_DBG_TRACE_OPERATE_EN(x) ((x) << S_DBG_TRACE_OPERATE_EN)
-#define F_DBG_TRACE_OPERATE_EN V_DBG_TRACE_OPERATE_EN(1U)
-
-#define S_DBG_OPERATE_INDV_COMBINED 3
-#define V_DBG_OPERATE_INDV_COMBINED(x) ((x) << S_DBG_OPERATE_INDV_COMBINED)
-#define F_DBG_OPERATE_INDV_COMBINED V_DBG_OPERATE_INDV_COMBINED(1U)
-
-#define S_DBG_OPERATE_ORDER_OF_TRIGGER 2
-#define V_DBG_OPERATE_ORDER_OF_TRIGGER(x) ((x) << S_DBG_OPERATE_ORDER_OF_TRIGGER)
-#define F_DBG_OPERATE_ORDER_OF_TRIGGER V_DBG_OPERATE_ORDER_OF_TRIGGER(1U)
-
-#define S_DBG_OPERATE_SGL_DBL_TRIGGER 1
-#define V_DBG_OPERATE_SGL_DBL_TRIGGER(x) ((x) << S_DBG_OPERATE_SGL_DBL_TRIGGER)
-#define F_DBG_OPERATE_SGL_DBL_TRIGGER V_DBG_OPERATE_SGL_DBL_TRIGGER(1U)
-
-#define S_DBG_OPERATE0_OR_1 0
-#define V_DBG_OPERATE0_OR_1(x) ((x) << S_DBG_OPERATE0_OR_1)
-#define F_DBG_OPERATE0_OR_1 V_DBG_OPERATE0_OR_1(1U)
-
-#define A_DBG_TRACE_RDEN 0x608c
-
-#define S_RD_ADDR1 10
-#define M_RD_ADDR1 0xffU
-#define V_RD_ADDR1(x) ((x) << S_RD_ADDR1)
-#define G_RD_ADDR1(x) (((x) >> S_RD_ADDR1) & M_RD_ADDR1)
-
-#define S_RD_ADDR0 2
-#define M_RD_ADDR0 0xffU
-#define V_RD_ADDR0(x) ((x) << S_RD_ADDR0)
-#define G_RD_ADDR0(x) (((x) >> S_RD_ADDR0) & M_RD_ADDR0)
-
-#define S_RD_EN1 1
-#define V_RD_EN1(x) ((x) << S_RD_EN1)
-#define F_RD_EN1 V_RD_EN1(1U)
-
-#define S_RD_EN0 0
-#define V_RD_EN0(x) ((x) << S_RD_EN0)
-#define F_RD_EN0 V_RD_EN0(1U)
-
-#define S_T5_RD_ADDR1 11
-#define M_T5_RD_ADDR1 0x1ffU
-#define V_T5_RD_ADDR1(x) ((x) << S_T5_RD_ADDR1)
-#define G_T5_RD_ADDR1(x) (((x) >> S_T5_RD_ADDR1) & M_T5_RD_ADDR1)
-
-#define S_T5_RD_ADDR0 2
-#define M_T5_RD_ADDR0 0x1ffU
-#define V_T5_RD_ADDR0(x) ((x) << S_T5_RD_ADDR0)
-#define G_T5_RD_ADDR0(x) (((x) >> S_T5_RD_ADDR0) & M_T5_RD_ADDR0)
-
-#define S_T6_RD_ADDR1 11
-#define M_T6_RD_ADDR1 0x1ffU
-#define V_T6_RD_ADDR1(x) ((x) << S_T6_RD_ADDR1)
-#define G_T6_RD_ADDR1(x) (((x) >> S_T6_RD_ADDR1) & M_T6_RD_ADDR1)
-
-#define S_T6_RD_ADDR0 2
-#define M_T6_RD_ADDR0 0x1ffU
-#define V_T6_RD_ADDR0(x) ((x) << S_T6_RD_ADDR0)
-#define G_T6_RD_ADDR0(x) (((x) >> S_T6_RD_ADDR0) & M_T6_RD_ADDR0)
-
-#define A_DBG_TRACE_WRADDR 0x6090
-
-#define S_WR_POINTER_ADDR1 16
-#define M_WR_POINTER_ADDR1 0xffU
-#define V_WR_POINTER_ADDR1(x) ((x) << S_WR_POINTER_ADDR1)
-#define G_WR_POINTER_ADDR1(x) (((x) >> S_WR_POINTER_ADDR1) & M_WR_POINTER_ADDR1)
-
-#define S_WR_POINTER_ADDR0 0
-#define M_WR_POINTER_ADDR0 0xffU
-#define V_WR_POINTER_ADDR0(x) ((x) << S_WR_POINTER_ADDR0)
-#define G_WR_POINTER_ADDR0(x) (((x) >> S_WR_POINTER_ADDR0) & M_WR_POINTER_ADDR0)
-
-#define S_T5_WR_POINTER_ADDR1 16
-#define M_T5_WR_POINTER_ADDR1 0x1ffU
-#define V_T5_WR_POINTER_ADDR1(x) ((x) << S_T5_WR_POINTER_ADDR1)
-#define G_T5_WR_POINTER_ADDR1(x) (((x) >> S_T5_WR_POINTER_ADDR1) & M_T5_WR_POINTER_ADDR1)
-
-#define S_T5_WR_POINTER_ADDR0 0
-#define M_T5_WR_POINTER_ADDR0 0x1ffU
-#define V_T5_WR_POINTER_ADDR0(x) ((x) << S_T5_WR_POINTER_ADDR0)
-#define G_T5_WR_POINTER_ADDR0(x) (((x) >> S_T5_WR_POINTER_ADDR0) & M_T5_WR_POINTER_ADDR0)
-
-#define S_T6_WR_POINTER_ADDR1 16
-#define M_T6_WR_POINTER_ADDR1 0x1ffU
-#define V_T6_WR_POINTER_ADDR1(x) ((x) << S_T6_WR_POINTER_ADDR1)
-#define G_T6_WR_POINTER_ADDR1(x) (((x) >> S_T6_WR_POINTER_ADDR1) & M_T6_WR_POINTER_ADDR1)
-
-#define S_T6_WR_POINTER_ADDR0 0
-#define M_T6_WR_POINTER_ADDR0 0x1ffU
-#define V_T6_WR_POINTER_ADDR0(x) ((x) << S_T6_WR_POINTER_ADDR0)
-#define G_T6_WR_POINTER_ADDR0(x) (((x) >> S_T6_WR_POINTER_ADDR0) & M_T6_WR_POINTER_ADDR0)
-
-#define A_DBG_TRACE0_DATA_OUT 0x6094
-#define A_DBG_TRACE1_DATA_OUT 0x6098
-#define A_DBG_FUSE_SENSE_DONE 0x609c
-
-#define S_STATIC_JTAG_VERSIONNR 5
-#define M_STATIC_JTAG_VERSIONNR 0xfU
-#define V_STATIC_JTAG_VERSIONNR(x) ((x) << S_STATIC_JTAG_VERSIONNR)
-#define G_STATIC_JTAG_VERSIONNR(x) (((x) >> S_STATIC_JTAG_VERSIONNR) & M_STATIC_JTAG_VERSIONNR)
-
-#define S_UNQ0 1
-#define M_UNQ0 0xfU
-#define V_UNQ0(x) ((x) << S_UNQ0)
-#define G_UNQ0(x) (((x) >> S_UNQ0) & M_UNQ0)
-
-#define S_FUSE_DONE_SENSE 0
-#define V_FUSE_DONE_SENSE(x) ((x) << S_FUSE_DONE_SENSE)
-#define F_FUSE_DONE_SENSE V_FUSE_DONE_SENSE(1U)
-
-#define A_DBG_TVSENSE_EN 0x60a8
-
-#define S_MCIMPED1_OUT 29
-#define V_MCIMPED1_OUT(x) ((x) << S_MCIMPED1_OUT)
-#define F_MCIMPED1_OUT V_MCIMPED1_OUT(1U)
-
-#define S_MCIMPED2_OUT 28
-#define V_MCIMPED2_OUT(x) ((x) << S_MCIMPED2_OUT)
-#define F_MCIMPED2_OUT V_MCIMPED2_OUT(1U)
-
-#define S_TVSENSE_SNSOUT 17
-#define M_TVSENSE_SNSOUT 0x1ffU
-#define V_TVSENSE_SNSOUT(x) ((x) << S_TVSENSE_SNSOUT)
-#define G_TVSENSE_SNSOUT(x) (((x) >> S_TVSENSE_SNSOUT) & M_TVSENSE_SNSOUT)
-
-#define S_TVSENSE_OUTPUTVALID 16
-#define V_TVSENSE_OUTPUTVALID(x) ((x) << S_TVSENSE_OUTPUTVALID)
-#define F_TVSENSE_OUTPUTVALID V_TVSENSE_OUTPUTVALID(1U)
-
-#define S_TVSENSE_SLEEP 10
-#define V_TVSENSE_SLEEP(x) ((x) << S_TVSENSE_SLEEP)
-#define F_TVSENSE_SLEEP V_TVSENSE_SLEEP(1U)
-
-#define S_TVSENSE_SENSV 9
-#define V_TVSENSE_SENSV(x) ((x) << S_TVSENSE_SENSV)
-#define F_TVSENSE_SENSV V_TVSENSE_SENSV(1U)
-
-#define S_TVSENSE_RST 8
-#define V_TVSENSE_RST(x) ((x) << S_TVSENSE_RST)
-#define F_TVSENSE_RST V_TVSENSE_RST(1U)
-
-#define S_TVSENSE_RATIO 0
-#define M_TVSENSE_RATIO 0xffU
-#define V_TVSENSE_RATIO(x) ((x) << S_TVSENSE_RATIO)
-#define G_TVSENSE_RATIO(x) (((x) >> S_TVSENSE_RATIO) & M_TVSENSE_RATIO)
-
-#define S_T6_TVSENSE_SLEEP 11
-#define V_T6_TVSENSE_SLEEP(x) ((x) << S_T6_TVSENSE_SLEEP)
-#define F_T6_TVSENSE_SLEEP V_T6_TVSENSE_SLEEP(1U)
-
-#define S_T6_TVSENSE_SENSV 10
-#define V_T6_TVSENSE_SENSV(x) ((x) << S_T6_TVSENSE_SENSV)
-#define F_T6_TVSENSE_SENSV V_T6_TVSENSE_SENSV(1U)
-
-#define S_T6_TVSENSE_RST 9
-#define V_T6_TVSENSE_RST(x) ((x) << S_T6_TVSENSE_RST)
-#define F_T6_TVSENSE_RST V_T6_TVSENSE_RST(1U)
-
-#define A_DBG_CUST_EFUSE_OUT_EN 0x60ac
-#define A_DBG_CUST_EFUSE_SEL1_EN 0x60b0
-#define A_DBG_CUST_EFUSE_SEL2_EN 0x60b4
-
-#define S_DBG_FEENABLE 29
-#define V_DBG_FEENABLE(x) ((x) << S_DBG_FEENABLE)
-#define F_DBG_FEENABLE V_DBG_FEENABLE(1U)
-
-#define S_DBG_FEF 23
-#define M_DBG_FEF 0x3fU
-#define V_DBG_FEF(x) ((x) << S_DBG_FEF)
-#define G_DBG_FEF(x) (((x) >> S_DBG_FEF) & M_DBG_FEF)
-
-#define S_DBG_FEMIMICN 22
-#define V_DBG_FEMIMICN(x) ((x) << S_DBG_FEMIMICN)
-#define F_DBG_FEMIMICN V_DBG_FEMIMICN(1U)
-
-#define S_DBG_FEGATEC 21
-#define V_DBG_FEGATEC(x) ((x) << S_DBG_FEGATEC)
-#define F_DBG_FEGATEC V_DBG_FEGATEC(1U)
-
-#define S_DBG_FEPROGP 20
-#define V_DBG_FEPROGP(x) ((x) << S_DBG_FEPROGP)
-#define F_DBG_FEPROGP V_DBG_FEPROGP(1U)
-
-#define S_DBG_FEREADCLK 19
-#define V_DBG_FEREADCLK(x) ((x) << S_DBG_FEREADCLK)
-#define F_DBG_FEREADCLK V_DBG_FEREADCLK(1U)
-
-#define S_DBG_FERSEL 3
-#define M_DBG_FERSEL 0xffffU
-#define V_DBG_FERSEL(x) ((x) << S_DBG_FERSEL)
-#define G_DBG_FERSEL(x) (((x) >> S_DBG_FERSEL) & M_DBG_FERSEL)
-
-#define S_DBG_FETIME 0
-#define M_DBG_FETIME 0x7U
-#define V_DBG_FETIME(x) ((x) << S_DBG_FETIME)
-#define G_DBG_FETIME(x) (((x) >> S_DBG_FETIME) & M_DBG_FETIME)
-
-#define A_DBG_T5_STATIC_M_PLL_CONF1 0x60b8
-
-#define S_T5_STATIC_M_PLL_MULTFRAC 8
-#define M_T5_STATIC_M_PLL_MULTFRAC 0xffffffU
-#define V_T5_STATIC_M_PLL_MULTFRAC(x) ((x) << S_T5_STATIC_M_PLL_MULTFRAC)
-#define G_T5_STATIC_M_PLL_MULTFRAC(x) (((x) >> S_T5_STATIC_M_PLL_MULTFRAC) & M_T5_STATIC_M_PLL_MULTFRAC)
-
-#define S_T5_STATIC_M_PLL_FFSLEWRATE 0
-#define M_T5_STATIC_M_PLL_FFSLEWRATE 0xffU
-#define V_T5_STATIC_M_PLL_FFSLEWRATE(x) ((x) << S_T5_STATIC_M_PLL_FFSLEWRATE)
-#define G_T5_STATIC_M_PLL_FFSLEWRATE(x) (((x) >> S_T5_STATIC_M_PLL_FFSLEWRATE) & M_T5_STATIC_M_PLL_FFSLEWRATE)
-
-#define A_DBG_STATIC_M_PLL_CONF1 0x60b8
-
-#define S_STATIC_M_PLL_MULTFRAC 8
-#define M_STATIC_M_PLL_MULTFRAC 0xffffffU
-#define V_STATIC_M_PLL_MULTFRAC(x) ((x) << S_STATIC_M_PLL_MULTFRAC)
-#define G_STATIC_M_PLL_MULTFRAC(x) (((x) >> S_STATIC_M_PLL_MULTFRAC) & M_STATIC_M_PLL_MULTFRAC)
-
-#define S_STATIC_M_PLL_FFSLEWRATE 0
-#define M_STATIC_M_PLL_FFSLEWRATE 0xffU
-#define V_STATIC_M_PLL_FFSLEWRATE(x) ((x) << S_STATIC_M_PLL_FFSLEWRATE)
-#define G_STATIC_M_PLL_FFSLEWRATE(x) (((x) >> S_STATIC_M_PLL_FFSLEWRATE) & M_STATIC_M_PLL_FFSLEWRATE)
-
-#define A_DBG_T5_STATIC_M_PLL_CONF2 0x60bc
-
-#define S_T5_STATIC_M_PLL_DCO_BYPASS 23
-#define V_T5_STATIC_M_PLL_DCO_BYPASS(x) ((x) << S_T5_STATIC_M_PLL_DCO_BYPASS)
-#define F_T5_STATIC_M_PLL_DCO_BYPASS V_T5_STATIC_M_PLL_DCO_BYPASS(1U)
-
-#define S_T5_STATIC_M_PLL_SDORDER 21
-#define M_T5_STATIC_M_PLL_SDORDER 0x3U
-#define V_T5_STATIC_M_PLL_SDORDER(x) ((x) << S_T5_STATIC_M_PLL_SDORDER)
-#define G_T5_STATIC_M_PLL_SDORDER(x) (((x) >> S_T5_STATIC_M_PLL_SDORDER) & M_T5_STATIC_M_PLL_SDORDER)
-
-#define S_T5_STATIC_M_PLL_FFENABLE 20
-#define V_T5_STATIC_M_PLL_FFENABLE(x) ((x) << S_T5_STATIC_M_PLL_FFENABLE)
-#define F_T5_STATIC_M_PLL_FFENABLE V_T5_STATIC_M_PLL_FFENABLE(1U)
-
-#define S_T5_STATIC_M_PLL_STOPCLKB 19
-#define V_T5_STATIC_M_PLL_STOPCLKB(x) ((x) << S_T5_STATIC_M_PLL_STOPCLKB)
-#define F_T5_STATIC_M_PLL_STOPCLKB V_T5_STATIC_M_PLL_STOPCLKB(1U)
-
-#define S_T5_STATIC_M_PLL_STOPCLKA 18
-#define V_T5_STATIC_M_PLL_STOPCLKA(x) ((x) << S_T5_STATIC_M_PLL_STOPCLKA)
-#define F_T5_STATIC_M_PLL_STOPCLKA V_T5_STATIC_M_PLL_STOPCLKA(1U)
-
-#define S_T5_STATIC_M_PLL_SLEEP 17
-#define V_T5_STATIC_M_PLL_SLEEP(x) ((x) << S_T5_STATIC_M_PLL_SLEEP)
-#define F_T5_STATIC_M_PLL_SLEEP V_T5_STATIC_M_PLL_SLEEP(1U)
-
-#define S_T5_STATIC_M_PLL_BYPASS 16
-#define V_T5_STATIC_M_PLL_BYPASS(x) ((x) << S_T5_STATIC_M_PLL_BYPASS)
-#define F_T5_STATIC_M_PLL_BYPASS V_T5_STATIC_M_PLL_BYPASS(1U)
-
-#define S_T5_STATIC_M_PLL_LOCKTUNE 0
-#define M_T5_STATIC_M_PLL_LOCKTUNE 0xffffU
-#define V_T5_STATIC_M_PLL_LOCKTUNE(x) ((x) << S_T5_STATIC_M_PLL_LOCKTUNE)
-#define G_T5_STATIC_M_PLL_LOCKTUNE(x) (((x) >> S_T5_STATIC_M_PLL_LOCKTUNE) & M_T5_STATIC_M_PLL_LOCKTUNE)
-
-#define A_DBG_STATIC_M_PLL_CONF2 0x60bc
-
-#define S_T6_STATIC_M_PLL_PREDIV 24
-#define M_T6_STATIC_M_PLL_PREDIV 0x3fU
-#define V_T6_STATIC_M_PLL_PREDIV(x) ((x) << S_T6_STATIC_M_PLL_PREDIV)
-#define G_T6_STATIC_M_PLL_PREDIV(x) (((x) >> S_T6_STATIC_M_PLL_PREDIV) & M_T6_STATIC_M_PLL_PREDIV)
-
-#define S_STATIC_M_PLL_DCO_BYPASS 23
-#define V_STATIC_M_PLL_DCO_BYPASS(x) ((x) << S_STATIC_M_PLL_DCO_BYPASS)
-#define F_STATIC_M_PLL_DCO_BYPASS V_STATIC_M_PLL_DCO_BYPASS(1U)
-
-#define S_STATIC_M_PLL_SDORDER 21
-#define M_STATIC_M_PLL_SDORDER 0x3U
-#define V_STATIC_M_PLL_SDORDER(x) ((x) << S_STATIC_M_PLL_SDORDER)
-#define G_STATIC_M_PLL_SDORDER(x) (((x) >> S_STATIC_M_PLL_SDORDER) & M_STATIC_M_PLL_SDORDER)
-
-#define S_STATIC_M_PLL_FFENABLE 20
-#define V_STATIC_M_PLL_FFENABLE(x) ((x) << S_STATIC_M_PLL_FFENABLE)
-#define F_STATIC_M_PLL_FFENABLE V_STATIC_M_PLL_FFENABLE(1U)
-
-#define S_STATIC_M_PLL_STOPCLKB 19
-#define V_STATIC_M_PLL_STOPCLKB(x) ((x) << S_STATIC_M_PLL_STOPCLKB)
-#define F_STATIC_M_PLL_STOPCLKB V_STATIC_M_PLL_STOPCLKB(1U)
-
-#define S_STATIC_M_PLL_STOPCLKA 18
-#define V_STATIC_M_PLL_STOPCLKA(x) ((x) << S_STATIC_M_PLL_STOPCLKA)
-#define F_STATIC_M_PLL_STOPCLKA V_STATIC_M_PLL_STOPCLKA(1U)
-
-#define S_T6_STATIC_M_PLL_SLEEP 17
-#define V_T6_STATIC_M_PLL_SLEEP(x) ((x) << S_T6_STATIC_M_PLL_SLEEP)
-#define F_T6_STATIC_M_PLL_SLEEP V_T6_STATIC_M_PLL_SLEEP(1U)
-
-#define S_T6_STATIC_M_PLL_BYPASS 16
-#define V_T6_STATIC_M_PLL_BYPASS(x) ((x) << S_T6_STATIC_M_PLL_BYPASS)
-#define F_T6_STATIC_M_PLL_BYPASS V_T6_STATIC_M_PLL_BYPASS(1U)
-
-#define S_STATIC_M_PLL_LOCKTUNE 0
-#define M_STATIC_M_PLL_LOCKTUNE 0x1fU
-#define V_STATIC_M_PLL_LOCKTUNE(x) ((x) << S_STATIC_M_PLL_LOCKTUNE)
-#define G_STATIC_M_PLL_LOCKTUNE(x) (((x) >> S_STATIC_M_PLL_LOCKTUNE) & M_STATIC_M_PLL_LOCKTUNE)
-
-#define A_DBG_T5_STATIC_M_PLL_CONF3 0x60c0
-
-#define S_T5_STATIC_M_PLL_MULTPRE 30
-#define M_T5_STATIC_M_PLL_MULTPRE 0x3U
-#define V_T5_STATIC_M_PLL_MULTPRE(x) ((x) << S_T5_STATIC_M_PLL_MULTPRE)
-#define G_T5_STATIC_M_PLL_MULTPRE(x) (((x) >> S_T5_STATIC_M_PLL_MULTPRE) & M_T5_STATIC_M_PLL_MULTPRE)
-
-#define S_T5_STATIC_M_PLL_LOCKSEL 28
-#define M_T5_STATIC_M_PLL_LOCKSEL 0x3U
-#define V_T5_STATIC_M_PLL_LOCKSEL(x) ((x) << S_T5_STATIC_M_PLL_LOCKSEL)
-#define G_T5_STATIC_M_PLL_LOCKSEL(x) (((x) >> S_T5_STATIC_M_PLL_LOCKSEL) & M_T5_STATIC_M_PLL_LOCKSEL)
-
-#define S_T5_STATIC_M_PLL_FFTUNE 12
-#define M_T5_STATIC_M_PLL_FFTUNE 0xffffU
-#define V_T5_STATIC_M_PLL_FFTUNE(x) ((x) << S_T5_STATIC_M_PLL_FFTUNE)
-#define G_T5_STATIC_M_PLL_FFTUNE(x) (((x) >> S_T5_STATIC_M_PLL_FFTUNE) & M_T5_STATIC_M_PLL_FFTUNE)
-
-#define S_T5_STATIC_M_PLL_RANGEPRE 10
-#define M_T5_STATIC_M_PLL_RANGEPRE 0x3U
-#define V_T5_STATIC_M_PLL_RANGEPRE(x) ((x) << S_T5_STATIC_M_PLL_RANGEPRE)
-#define G_T5_STATIC_M_PLL_RANGEPRE(x) (((x) >> S_T5_STATIC_M_PLL_RANGEPRE) & M_T5_STATIC_M_PLL_RANGEPRE)
-
-#define S_T5_STATIC_M_PLL_RANGEB 5
-#define M_T5_STATIC_M_PLL_RANGEB 0x1fU
-#define V_T5_STATIC_M_PLL_RANGEB(x) ((x) << S_T5_STATIC_M_PLL_RANGEB)
-#define G_T5_STATIC_M_PLL_RANGEB(x) (((x) >> S_T5_STATIC_M_PLL_RANGEB) & M_T5_STATIC_M_PLL_RANGEB)
-
-#define S_T5_STATIC_M_PLL_RANGEA 0
-#define M_T5_STATIC_M_PLL_RANGEA 0x1fU
-#define V_T5_STATIC_M_PLL_RANGEA(x) ((x) << S_T5_STATIC_M_PLL_RANGEA)
-#define G_T5_STATIC_M_PLL_RANGEA(x) (((x) >> S_T5_STATIC_M_PLL_RANGEA) & M_T5_STATIC_M_PLL_RANGEA)
-
-#define A_DBG_STATIC_M_PLL_CONF3 0x60c0
-
-#define S_STATIC_M_PLL_MULTPRE 30
-#define M_STATIC_M_PLL_MULTPRE 0x3U
-#define V_STATIC_M_PLL_MULTPRE(x) ((x) << S_STATIC_M_PLL_MULTPRE)
-#define G_STATIC_M_PLL_MULTPRE(x) (((x) >> S_STATIC_M_PLL_MULTPRE) & M_STATIC_M_PLL_MULTPRE)
-
-#define S_STATIC_M_PLL_LOCKSEL 28
-#define V_STATIC_M_PLL_LOCKSEL(x) ((x) << S_STATIC_M_PLL_LOCKSEL)
-#define F_STATIC_M_PLL_LOCKSEL V_STATIC_M_PLL_LOCKSEL(1U)
-
-#define S_STATIC_M_PLL_FFTUNE 12
-#define M_STATIC_M_PLL_FFTUNE 0xffffU
-#define V_STATIC_M_PLL_FFTUNE(x) ((x) << S_STATIC_M_PLL_FFTUNE)
-#define G_STATIC_M_PLL_FFTUNE(x) (((x) >> S_STATIC_M_PLL_FFTUNE) & M_STATIC_M_PLL_FFTUNE)
-
-#define S_STATIC_M_PLL_RANGEPRE 10
-#define M_STATIC_M_PLL_RANGEPRE 0x3U
-#define V_STATIC_M_PLL_RANGEPRE(x) ((x) << S_STATIC_M_PLL_RANGEPRE)
-#define G_STATIC_M_PLL_RANGEPRE(x) (((x) >> S_STATIC_M_PLL_RANGEPRE) & M_STATIC_M_PLL_RANGEPRE)
-
-#define S_T6_STATIC_M_PLL_RANGEB 5
-#define M_T6_STATIC_M_PLL_RANGEB 0x1fU
-#define V_T6_STATIC_M_PLL_RANGEB(x) ((x) << S_T6_STATIC_M_PLL_RANGEB)
-#define G_T6_STATIC_M_PLL_RANGEB(x) (((x) >> S_T6_STATIC_M_PLL_RANGEB) & M_T6_STATIC_M_PLL_RANGEB)
-
-#define S_T6_STATIC_M_PLL_RANGEA 0
-#define M_T6_STATIC_M_PLL_RANGEA 0x1fU
-#define V_T6_STATIC_M_PLL_RANGEA(x) ((x) << S_T6_STATIC_M_PLL_RANGEA)
-#define G_T6_STATIC_M_PLL_RANGEA(x) (((x) >> S_T6_STATIC_M_PLL_RANGEA) & M_T6_STATIC_M_PLL_RANGEA)
-
-#define A_DBG_T5_STATIC_M_PLL_CONF4 0x60c4
-#define A_DBG_STATIC_M_PLL_CONF4 0x60c4
-#define A_DBG_T5_STATIC_M_PLL_CONF5 0x60c8
-
-#define S_T5_STATIC_M_PLL_VCVTUNE 24
-#define M_T5_STATIC_M_PLL_VCVTUNE 0x7U
-#define V_T5_STATIC_M_PLL_VCVTUNE(x) ((x) << S_T5_STATIC_M_PLL_VCVTUNE)
-#define G_T5_STATIC_M_PLL_VCVTUNE(x) (((x) >> S_T5_STATIC_M_PLL_VCVTUNE) & M_T5_STATIC_M_PLL_VCVTUNE)
-
-#define S_T5_STATIC_M_PLL_RESET 23
-#define V_T5_STATIC_M_PLL_RESET(x) ((x) << S_T5_STATIC_M_PLL_RESET)
-#define F_T5_STATIC_M_PLL_RESET V_T5_STATIC_M_PLL_RESET(1U)
-
-#define S_T5_STATIC_MPLL_REFCLK_SEL 22
-#define V_T5_STATIC_MPLL_REFCLK_SEL(x) ((x) << S_T5_STATIC_MPLL_REFCLK_SEL)
-#define F_T5_STATIC_MPLL_REFCLK_SEL V_T5_STATIC_MPLL_REFCLK_SEL(1U)
-
-#define S_T5_STATIC_M_PLL_LFTUNE_32_40 13
-#define M_T5_STATIC_M_PLL_LFTUNE_32_40 0x1ffU
-#define V_T5_STATIC_M_PLL_LFTUNE_32_40(x) ((x) << S_T5_STATIC_M_PLL_LFTUNE_32_40)
-#define G_T5_STATIC_M_PLL_LFTUNE_32_40(x) (((x) >> S_T5_STATIC_M_PLL_LFTUNE_32_40) & M_T5_STATIC_M_PLL_LFTUNE_32_40)
-
-#define S_T5_STATIC_M_PLL_PREDIV 8
-#define M_T5_STATIC_M_PLL_PREDIV 0x1fU
-#define V_T5_STATIC_M_PLL_PREDIV(x) ((x) << S_T5_STATIC_M_PLL_PREDIV)
-#define G_T5_STATIC_M_PLL_PREDIV(x) (((x) >> S_T5_STATIC_M_PLL_PREDIV) & M_T5_STATIC_M_PLL_PREDIV)
-
-#define S_T5_STATIC_M_PLL_MULT 0
-#define M_T5_STATIC_M_PLL_MULT 0xffU
-#define V_T5_STATIC_M_PLL_MULT(x) ((x) << S_T5_STATIC_M_PLL_MULT)
-#define G_T5_STATIC_M_PLL_MULT(x) (((x) >> S_T5_STATIC_M_PLL_MULT) & M_T5_STATIC_M_PLL_MULT)
-
-#define A_DBG_STATIC_M_PLL_CONF5 0x60c8
-
-#define S_STATIC_M_PLL_VCVTUNE 24
-#define M_STATIC_M_PLL_VCVTUNE 0x7U
-#define V_STATIC_M_PLL_VCVTUNE(x) ((x) << S_STATIC_M_PLL_VCVTUNE)
-#define G_STATIC_M_PLL_VCVTUNE(x) (((x) >> S_STATIC_M_PLL_VCVTUNE) & M_STATIC_M_PLL_VCVTUNE)
-
-#define S_T6_STATIC_M_PLL_RESET 23
-#define V_T6_STATIC_M_PLL_RESET(x) ((x) << S_T6_STATIC_M_PLL_RESET)
-#define F_T6_STATIC_M_PLL_RESET V_T6_STATIC_M_PLL_RESET(1U)
-
-#define S_STATIC_MPLL_REFCLK_SEL 22
-#define V_STATIC_MPLL_REFCLK_SEL(x) ((x) << S_STATIC_MPLL_REFCLK_SEL)
-#define F_STATIC_MPLL_REFCLK_SEL V_STATIC_MPLL_REFCLK_SEL(1U)
-
-#define S_STATIC_M_PLL_LFTUNE_32_40 13
-#define M_STATIC_M_PLL_LFTUNE_32_40 0x1ffU
-#define V_STATIC_M_PLL_LFTUNE_32_40(x) ((x) << S_STATIC_M_PLL_LFTUNE_32_40)
-#define G_STATIC_M_PLL_LFTUNE_32_40(x) (((x) >> S_STATIC_M_PLL_LFTUNE_32_40) & M_STATIC_M_PLL_LFTUNE_32_40)
-
-#define S_T6_STATIC_M_PLL_MULT 0
-#define M_T6_STATIC_M_PLL_MULT 0xffU
-#define V_T6_STATIC_M_PLL_MULT(x) ((x) << S_T6_STATIC_M_PLL_MULT)
-#define G_T6_STATIC_M_PLL_MULT(x) (((x) >> S_T6_STATIC_M_PLL_MULT) & M_T6_STATIC_M_PLL_MULT)
-
-#define A_DBG_T5_STATIC_M_PLL_CONF6 0x60cc
-
-#define S_T5_STATIC_PHY0RECRST_ 5
-#define V_T5_STATIC_PHY0RECRST_(x) ((x) << S_T5_STATIC_PHY0RECRST_)
-#define F_T5_STATIC_PHY0RECRST_ V_T5_STATIC_PHY0RECRST_(1U)
-
-#define S_T5_STATIC_PHY1RECRST_ 4
-#define V_T5_STATIC_PHY1RECRST_(x) ((x) << S_T5_STATIC_PHY1RECRST_)
-#define F_T5_STATIC_PHY1RECRST_ V_T5_STATIC_PHY1RECRST_(1U)
-
-#define S_T5_STATIC_SWMC0RST_ 3
-#define V_T5_STATIC_SWMC0RST_(x) ((x) << S_T5_STATIC_SWMC0RST_)
-#define F_T5_STATIC_SWMC0RST_ V_T5_STATIC_SWMC0RST_(1U)
-
-#define S_T5_STATIC_SWMC0CFGRST_ 2
-#define V_T5_STATIC_SWMC0CFGRST_(x) ((x) << S_T5_STATIC_SWMC0CFGRST_)
-#define F_T5_STATIC_SWMC0CFGRST_ V_T5_STATIC_SWMC0CFGRST_(1U)
-
-#define S_T5_STATIC_SWMC1RST_ 1
-#define V_T5_STATIC_SWMC1RST_(x) ((x) << S_T5_STATIC_SWMC1RST_)
-#define F_T5_STATIC_SWMC1RST_ V_T5_STATIC_SWMC1RST_(1U)
-
-#define S_T5_STATIC_SWMC1CFGRST_ 0
-#define V_T5_STATIC_SWMC1CFGRST_(x) ((x) << S_T5_STATIC_SWMC1CFGRST_)
-#define F_T5_STATIC_SWMC1CFGRST_ V_T5_STATIC_SWMC1CFGRST_(1U)
-
-#define A_DBG_STATIC_M_PLL_CONF6 0x60cc
-
-#define S_STATIC_M_PLL_DIVCHANGE 30
-#define V_STATIC_M_PLL_DIVCHANGE(x) ((x) << S_STATIC_M_PLL_DIVCHANGE)
-#define F_STATIC_M_PLL_DIVCHANGE V_STATIC_M_PLL_DIVCHANGE(1U)
-
-#define S_STATIC_M_PLL_FRAMESTOP 29
-#define V_STATIC_M_PLL_FRAMESTOP(x) ((x) << S_STATIC_M_PLL_FRAMESTOP)
-#define F_STATIC_M_PLL_FRAMESTOP V_STATIC_M_PLL_FRAMESTOP(1U)
-
-#define S_STATIC_M_PLL_FASTSTOP 28
-#define V_STATIC_M_PLL_FASTSTOP(x) ((x) << S_STATIC_M_PLL_FASTSTOP)
-#define F_STATIC_M_PLL_FASTSTOP V_STATIC_M_PLL_FASTSTOP(1U)
-
-#define S_STATIC_M_PLL_FFBYPASS 27
-#define V_STATIC_M_PLL_FFBYPASS(x) ((x) << S_STATIC_M_PLL_FFBYPASS)
-#define F_STATIC_M_PLL_FFBYPASS V_STATIC_M_PLL_FFBYPASS(1U)
-
-#define S_STATIC_M_PLL_STARTUP 25
-#define M_STATIC_M_PLL_STARTUP 0x3U
-#define V_STATIC_M_PLL_STARTUP(x) ((x) << S_STATIC_M_PLL_STARTUP)
-#define G_STATIC_M_PLL_STARTUP(x) (((x) >> S_STATIC_M_PLL_STARTUP) & M_STATIC_M_PLL_STARTUP)
-
-#define S_STATIC_M_PLL_VREGTUNE 6
-#define M_STATIC_M_PLL_VREGTUNE 0x7ffffU
-#define V_STATIC_M_PLL_VREGTUNE(x) ((x) << S_STATIC_M_PLL_VREGTUNE)
-#define G_STATIC_M_PLL_VREGTUNE(x) (((x) >> S_STATIC_M_PLL_VREGTUNE) & M_STATIC_M_PLL_VREGTUNE)
-
-#define S_STATIC_PHY0RECRST_ 5
-#define V_STATIC_PHY0RECRST_(x) ((x) << S_STATIC_PHY0RECRST_)
-#define F_STATIC_PHY0RECRST_ V_STATIC_PHY0RECRST_(1U)
-
-#define S_STATIC_PHY1RECRST_ 4
-#define V_STATIC_PHY1RECRST_(x) ((x) << S_STATIC_PHY1RECRST_)
-#define F_STATIC_PHY1RECRST_ V_STATIC_PHY1RECRST_(1U)
-
-#define S_STATIC_SWMC0RST_ 3
-#define V_STATIC_SWMC0RST_(x) ((x) << S_STATIC_SWMC0RST_)
-#define F_STATIC_SWMC0RST_ V_STATIC_SWMC0RST_(1U)
-
-#define S_STATIC_SWMC0CFGRST_ 2
-#define V_STATIC_SWMC0CFGRST_(x) ((x) << S_STATIC_SWMC0CFGRST_)
-#define F_STATIC_SWMC0CFGRST_ V_STATIC_SWMC0CFGRST_(1U)
-
-#define S_STATIC_SWMC1RST_ 1
-#define V_STATIC_SWMC1RST_(x) ((x) << S_STATIC_SWMC1RST_)
-#define F_STATIC_SWMC1RST_ V_STATIC_SWMC1RST_(1U)
-
-#define S_STATIC_SWMC1CFGRST_ 0
-#define V_STATIC_SWMC1CFGRST_(x) ((x) << S_STATIC_SWMC1CFGRST_)
-#define F_STATIC_SWMC1CFGRST_ V_STATIC_SWMC1CFGRST_(1U)
-
-#define A_DBG_T5_STATIC_C_PLL_CONF1 0x60d0
-
-#define S_T5_STATIC_C_PLL_MULTFRAC 8
-#define M_T5_STATIC_C_PLL_MULTFRAC 0xffffffU
-#define V_T5_STATIC_C_PLL_MULTFRAC(x) ((x) << S_T5_STATIC_C_PLL_MULTFRAC)
-#define G_T5_STATIC_C_PLL_MULTFRAC(x) (((x) >> S_T5_STATIC_C_PLL_MULTFRAC) & M_T5_STATIC_C_PLL_MULTFRAC)
-
-#define S_T5_STATIC_C_PLL_FFSLEWRATE 0
-#define M_T5_STATIC_C_PLL_FFSLEWRATE 0xffU
-#define V_T5_STATIC_C_PLL_FFSLEWRATE(x) ((x) << S_T5_STATIC_C_PLL_FFSLEWRATE)
-#define G_T5_STATIC_C_PLL_FFSLEWRATE(x) (((x) >> S_T5_STATIC_C_PLL_FFSLEWRATE) & M_T5_STATIC_C_PLL_FFSLEWRATE)
-
-#define A_DBG_STATIC_C_PLL_CONF1 0x60d0
-
-#define S_STATIC_C_PLL_MULTFRAC 8
-#define M_STATIC_C_PLL_MULTFRAC 0xffffffU
-#define V_STATIC_C_PLL_MULTFRAC(x) ((x) << S_STATIC_C_PLL_MULTFRAC)
-#define G_STATIC_C_PLL_MULTFRAC(x) (((x) >> S_STATIC_C_PLL_MULTFRAC) & M_STATIC_C_PLL_MULTFRAC)
-
-#define S_STATIC_C_PLL_FFSLEWRATE 0
-#define M_STATIC_C_PLL_FFSLEWRATE 0xffU
-#define V_STATIC_C_PLL_FFSLEWRATE(x) ((x) << S_STATIC_C_PLL_FFSLEWRATE)
-#define G_STATIC_C_PLL_FFSLEWRATE(x) (((x) >> S_STATIC_C_PLL_FFSLEWRATE) & M_STATIC_C_PLL_FFSLEWRATE)
-
-#define A_DBG_T5_STATIC_C_PLL_CONF2 0x60d4
-
-#define S_T5_STATIC_C_PLL_DCO_BYPASS 23
-#define V_T5_STATIC_C_PLL_DCO_BYPASS(x) ((x) << S_T5_STATIC_C_PLL_DCO_BYPASS)
-#define F_T5_STATIC_C_PLL_DCO_BYPASS V_T5_STATIC_C_PLL_DCO_BYPASS(1U)
-
-#define S_T5_STATIC_C_PLL_SDORDER 21
-#define M_T5_STATIC_C_PLL_SDORDER 0x3U
-#define V_T5_STATIC_C_PLL_SDORDER(x) ((x) << S_T5_STATIC_C_PLL_SDORDER)
-#define G_T5_STATIC_C_PLL_SDORDER(x) (((x) >> S_T5_STATIC_C_PLL_SDORDER) & M_T5_STATIC_C_PLL_SDORDER)
-
-#define S_T5_STATIC_C_PLL_FFENABLE 20
-#define V_T5_STATIC_C_PLL_FFENABLE(x) ((x) << S_T5_STATIC_C_PLL_FFENABLE)
-#define F_T5_STATIC_C_PLL_FFENABLE V_T5_STATIC_C_PLL_FFENABLE(1U)
-
-#define S_T5_STATIC_C_PLL_STOPCLKB 19
-#define V_T5_STATIC_C_PLL_STOPCLKB(x) ((x) << S_T5_STATIC_C_PLL_STOPCLKB)
-#define F_T5_STATIC_C_PLL_STOPCLKB V_T5_STATIC_C_PLL_STOPCLKB(1U)
-
-#define S_T5_STATIC_C_PLL_STOPCLKA 18
-#define V_T5_STATIC_C_PLL_STOPCLKA(x) ((x) << S_T5_STATIC_C_PLL_STOPCLKA)
-#define F_T5_STATIC_C_PLL_STOPCLKA V_T5_STATIC_C_PLL_STOPCLKA(1U)
-
-#define S_T5_STATIC_C_PLL_SLEEP 17
-#define V_T5_STATIC_C_PLL_SLEEP(x) ((x) << S_T5_STATIC_C_PLL_SLEEP)
-#define F_T5_STATIC_C_PLL_SLEEP V_T5_STATIC_C_PLL_SLEEP(1U)
-
-#define S_T5_STATIC_C_PLL_BYPASS 16
-#define V_T5_STATIC_C_PLL_BYPASS(x) ((x) << S_T5_STATIC_C_PLL_BYPASS)
-#define F_T5_STATIC_C_PLL_BYPASS V_T5_STATIC_C_PLL_BYPASS(1U)
-
-#define S_T5_STATIC_C_PLL_LOCKTUNE 0
-#define M_T5_STATIC_C_PLL_LOCKTUNE 0xffffU
-#define V_T5_STATIC_C_PLL_LOCKTUNE(x) ((x) << S_T5_STATIC_C_PLL_LOCKTUNE)
-#define G_T5_STATIC_C_PLL_LOCKTUNE(x) (((x) >> S_T5_STATIC_C_PLL_LOCKTUNE) & M_T5_STATIC_C_PLL_LOCKTUNE)
-
-#define A_DBG_STATIC_C_PLL_CONF2 0x60d4
-
-#define S_T6_STATIC_C_PLL_PREDIV 26
-#define M_T6_STATIC_C_PLL_PREDIV 0x3fU
-#define V_T6_STATIC_C_PLL_PREDIV(x) ((x) << S_T6_STATIC_C_PLL_PREDIV)
-#define G_T6_STATIC_C_PLL_PREDIV(x) (((x) >> S_T6_STATIC_C_PLL_PREDIV) & M_T6_STATIC_C_PLL_PREDIV)
-
-#define S_STATIC_C_PLL_STARTUP 24
-#define M_STATIC_C_PLL_STARTUP 0x3U
-#define V_STATIC_C_PLL_STARTUP(x) ((x) << S_STATIC_C_PLL_STARTUP)
-#define G_STATIC_C_PLL_STARTUP(x) (((x) >> S_STATIC_C_PLL_STARTUP) & M_STATIC_C_PLL_STARTUP)
-
-#define S_STATIC_C_PLL_DCO_BYPASS 23
-#define V_STATIC_C_PLL_DCO_BYPASS(x) ((x) << S_STATIC_C_PLL_DCO_BYPASS)
-#define F_STATIC_C_PLL_DCO_BYPASS V_STATIC_C_PLL_DCO_BYPASS(1U)
-
-#define S_STATIC_C_PLL_SDORDER 21
-#define M_STATIC_C_PLL_SDORDER 0x3U
-#define V_STATIC_C_PLL_SDORDER(x) ((x) << S_STATIC_C_PLL_SDORDER)
-#define G_STATIC_C_PLL_SDORDER(x) (((x) >> S_STATIC_C_PLL_SDORDER) & M_STATIC_C_PLL_SDORDER)
-
-#define S_STATIC_C_PLL_DIVCHANGE 20
-#define V_STATIC_C_PLL_DIVCHANGE(x) ((x) << S_STATIC_C_PLL_DIVCHANGE)
-#define F_STATIC_C_PLL_DIVCHANGE V_STATIC_C_PLL_DIVCHANGE(1U)
-
-#define S_STATIC_C_PLL_STOPCLKB 19
-#define V_STATIC_C_PLL_STOPCLKB(x) ((x) << S_STATIC_C_PLL_STOPCLKB)
-#define F_STATIC_C_PLL_STOPCLKB V_STATIC_C_PLL_STOPCLKB(1U)
-
-#define S_STATIC_C_PLL_STOPCLKA 18
-#define V_STATIC_C_PLL_STOPCLKA(x) ((x) << S_STATIC_C_PLL_STOPCLKA)
-#define F_STATIC_C_PLL_STOPCLKA V_STATIC_C_PLL_STOPCLKA(1U)
-
-#define S_T6_STATIC_C_PLL_SLEEP 17
-#define V_T6_STATIC_C_PLL_SLEEP(x) ((x) << S_T6_STATIC_C_PLL_SLEEP)
-#define F_T6_STATIC_C_PLL_SLEEP V_T6_STATIC_C_PLL_SLEEP(1U)
-
-#define S_T6_STATIC_C_PLL_BYPASS 16
-#define V_T6_STATIC_C_PLL_BYPASS(x) ((x) << S_T6_STATIC_C_PLL_BYPASS)
-#define F_T6_STATIC_C_PLL_BYPASS V_T6_STATIC_C_PLL_BYPASS(1U)
-
-#define S_STATIC_C_PLL_LOCKTUNE 0
-#define M_STATIC_C_PLL_LOCKTUNE 0x1fU
-#define V_STATIC_C_PLL_LOCKTUNE(x) ((x) << S_STATIC_C_PLL_LOCKTUNE)
-#define G_STATIC_C_PLL_LOCKTUNE(x) (((x) >> S_STATIC_C_PLL_LOCKTUNE) & M_STATIC_C_PLL_LOCKTUNE)
-
-#define A_DBG_T5_STATIC_C_PLL_CONF3 0x60d8
-
-#define S_T5_STATIC_C_PLL_MULTPRE 30
-#define M_T5_STATIC_C_PLL_MULTPRE 0x3U
-#define V_T5_STATIC_C_PLL_MULTPRE(x) ((x) << S_T5_STATIC_C_PLL_MULTPRE)
-#define G_T5_STATIC_C_PLL_MULTPRE(x) (((x) >> S_T5_STATIC_C_PLL_MULTPRE) & M_T5_STATIC_C_PLL_MULTPRE)
-
-#define S_T5_STATIC_C_PLL_LOCKSEL 28
-#define M_T5_STATIC_C_PLL_LOCKSEL 0x3U
-#define V_T5_STATIC_C_PLL_LOCKSEL(x) ((x) << S_T5_STATIC_C_PLL_LOCKSEL)
-#define G_T5_STATIC_C_PLL_LOCKSEL(x) (((x) >> S_T5_STATIC_C_PLL_LOCKSEL) & M_T5_STATIC_C_PLL_LOCKSEL)
-
-#define S_T5_STATIC_C_PLL_FFTUNE 12
-#define M_T5_STATIC_C_PLL_FFTUNE 0xffffU
-#define V_T5_STATIC_C_PLL_FFTUNE(x) ((x) << S_T5_STATIC_C_PLL_FFTUNE)
-#define G_T5_STATIC_C_PLL_FFTUNE(x) (((x) >> S_T5_STATIC_C_PLL_FFTUNE) & M_T5_STATIC_C_PLL_FFTUNE)
-
-#define S_T5_STATIC_C_PLL_RANGEPRE 10
-#define M_T5_STATIC_C_PLL_RANGEPRE 0x3U
-#define V_T5_STATIC_C_PLL_RANGEPRE(x) ((x) << S_T5_STATIC_C_PLL_RANGEPRE)
-#define G_T5_STATIC_C_PLL_RANGEPRE(x) (((x) >> S_T5_STATIC_C_PLL_RANGEPRE) & M_T5_STATIC_C_PLL_RANGEPRE)
-
-#define S_T5_STATIC_C_PLL_RANGEB 5
-#define M_T5_STATIC_C_PLL_RANGEB 0x1fU
-#define V_T5_STATIC_C_PLL_RANGEB(x) ((x) << S_T5_STATIC_C_PLL_RANGEB)
-#define G_T5_STATIC_C_PLL_RANGEB(x) (((x) >> S_T5_STATIC_C_PLL_RANGEB) & M_T5_STATIC_C_PLL_RANGEB)
-
-#define S_T5_STATIC_C_PLL_RANGEA 0
-#define M_T5_STATIC_C_PLL_RANGEA 0x1fU
-#define V_T5_STATIC_C_PLL_RANGEA(x) ((x) << S_T5_STATIC_C_PLL_RANGEA)
-#define G_T5_STATIC_C_PLL_RANGEA(x) (((x) >> S_T5_STATIC_C_PLL_RANGEA) & M_T5_STATIC_C_PLL_RANGEA)
-
-#define A_DBG_STATIC_C_PLL_CONF3 0x60d8
-
-#define S_STATIC_C_PLL_MULTPRE 30
-#define M_STATIC_C_PLL_MULTPRE 0x3U
-#define V_STATIC_C_PLL_MULTPRE(x) ((x) << S_STATIC_C_PLL_MULTPRE)
-#define G_STATIC_C_PLL_MULTPRE(x) (((x) >> S_STATIC_C_PLL_MULTPRE) & M_STATIC_C_PLL_MULTPRE)
-
-#define S_STATIC_C_PLL_LOCKSEL 28
-#define V_STATIC_C_PLL_LOCKSEL(x) ((x) << S_STATIC_C_PLL_LOCKSEL)
-#define F_STATIC_C_PLL_LOCKSEL V_STATIC_C_PLL_LOCKSEL(1U)
-
-#define S_STATIC_C_PLL_FFTUNE 12
-#define M_STATIC_C_PLL_FFTUNE 0xffffU
-#define V_STATIC_C_PLL_FFTUNE(x) ((x) << S_STATIC_C_PLL_FFTUNE)
-#define G_STATIC_C_PLL_FFTUNE(x) (((x) >> S_STATIC_C_PLL_FFTUNE) & M_STATIC_C_PLL_FFTUNE)
-
-#define S_STATIC_C_PLL_RANGEPRE 10
-#define M_STATIC_C_PLL_RANGEPRE 0x3U
-#define V_STATIC_C_PLL_RANGEPRE(x) ((x) << S_STATIC_C_PLL_RANGEPRE)
-#define G_STATIC_C_PLL_RANGEPRE(x) (((x) >> S_STATIC_C_PLL_RANGEPRE) & M_STATIC_C_PLL_RANGEPRE)
-
-#define S_T6_STATIC_C_PLL_RANGEB 5
-#define M_T6_STATIC_C_PLL_RANGEB 0x1fU
-#define V_T6_STATIC_C_PLL_RANGEB(x) ((x) << S_T6_STATIC_C_PLL_RANGEB)
-#define G_T6_STATIC_C_PLL_RANGEB(x) (((x) >> S_T6_STATIC_C_PLL_RANGEB) & M_T6_STATIC_C_PLL_RANGEB)
-
-#define S_T6_STATIC_C_PLL_RANGEA 0
-#define M_T6_STATIC_C_PLL_RANGEA 0x1fU
-#define V_T6_STATIC_C_PLL_RANGEA(x) ((x) << S_T6_STATIC_C_PLL_RANGEA)
-#define G_T6_STATIC_C_PLL_RANGEA(x) (((x) >> S_T6_STATIC_C_PLL_RANGEA) & M_T6_STATIC_C_PLL_RANGEA)
-
-#define A_DBG_T5_STATIC_C_PLL_CONF4 0x60dc
-#define A_DBG_STATIC_C_PLL_CONF4 0x60dc
-#define A_DBG_T5_STATIC_C_PLL_CONF5 0x60e0
-
-#define S_T5_STATIC_C_PLL_VCVTUNE 22
-#define M_T5_STATIC_C_PLL_VCVTUNE 0x7U
-#define V_T5_STATIC_C_PLL_VCVTUNE(x) ((x) << S_T5_STATIC_C_PLL_VCVTUNE)
-#define G_T5_STATIC_C_PLL_VCVTUNE(x) (((x) >> S_T5_STATIC_C_PLL_VCVTUNE) & M_T5_STATIC_C_PLL_VCVTUNE)
-
-#define S_T5_STATIC_C_PLL_LFTUNE_32_40 13
-#define M_T5_STATIC_C_PLL_LFTUNE_32_40 0x1ffU
-#define V_T5_STATIC_C_PLL_LFTUNE_32_40(x) ((x) << S_T5_STATIC_C_PLL_LFTUNE_32_40)
-#define G_T5_STATIC_C_PLL_LFTUNE_32_40(x) (((x) >> S_T5_STATIC_C_PLL_LFTUNE_32_40) & M_T5_STATIC_C_PLL_LFTUNE_32_40)
-
-#define S_T5_STATIC_C_PLL_PREDIV 8
-#define M_T5_STATIC_C_PLL_PREDIV 0x1fU
-#define V_T5_STATIC_C_PLL_PREDIV(x) ((x) << S_T5_STATIC_C_PLL_PREDIV)
-#define G_T5_STATIC_C_PLL_PREDIV(x) (((x) >> S_T5_STATIC_C_PLL_PREDIV) & M_T5_STATIC_C_PLL_PREDIV)
-
-#define S_T5_STATIC_C_PLL_MULT 0
-#define M_T5_STATIC_C_PLL_MULT 0xffU
-#define V_T5_STATIC_C_PLL_MULT(x) ((x) << S_T5_STATIC_C_PLL_MULT)
-#define G_T5_STATIC_C_PLL_MULT(x) (((x) >> S_T5_STATIC_C_PLL_MULT) & M_T5_STATIC_C_PLL_MULT)
-
-#define A_DBG_STATIC_C_PLL_CONF5 0x60e0
-
-#define S_STATIC_C_PLL_FFBYPASS 27
-#define V_STATIC_C_PLL_FFBYPASS(x) ((x) << S_STATIC_C_PLL_FFBYPASS)
-#define F_STATIC_C_PLL_FFBYPASS V_STATIC_C_PLL_FFBYPASS(1U)
-
-#define S_STATIC_C_PLL_FASTSTOP 26
-#define V_STATIC_C_PLL_FASTSTOP(x) ((x) << S_STATIC_C_PLL_FASTSTOP)
-#define F_STATIC_C_PLL_FASTSTOP V_STATIC_C_PLL_FASTSTOP(1U)
-
-#define S_STATIC_C_PLL_FRAMESTOP 25
-#define V_STATIC_C_PLL_FRAMESTOP(x) ((x) << S_STATIC_C_PLL_FRAMESTOP)
-#define F_STATIC_C_PLL_FRAMESTOP V_STATIC_C_PLL_FRAMESTOP(1U)
-
-#define S_STATIC_C_PLL_VCVTUNE 22
-#define M_STATIC_C_PLL_VCVTUNE 0x7U
-#define V_STATIC_C_PLL_VCVTUNE(x) ((x) << S_STATIC_C_PLL_VCVTUNE)
-#define G_STATIC_C_PLL_VCVTUNE(x) (((x) >> S_STATIC_C_PLL_VCVTUNE) & M_STATIC_C_PLL_VCVTUNE)
-
-#define S_STATIC_C_PLL_LFTUNE_32_40 13
-#define M_STATIC_C_PLL_LFTUNE_32_40 0x1ffU
-#define V_STATIC_C_PLL_LFTUNE_32_40(x) ((x) << S_STATIC_C_PLL_LFTUNE_32_40)
-#define G_STATIC_C_PLL_LFTUNE_32_40(x) (((x) >> S_STATIC_C_PLL_LFTUNE_32_40) & M_STATIC_C_PLL_LFTUNE_32_40)
-
-#define S_STATIC_C_PLL_PREDIV_CNF5 8
-#define M_STATIC_C_PLL_PREDIV_CNF5 0x1fU
-#define V_STATIC_C_PLL_PREDIV_CNF5(x) ((x) << S_STATIC_C_PLL_PREDIV_CNF5)
-#define G_STATIC_C_PLL_PREDIV_CNF5(x) (((x) >> S_STATIC_C_PLL_PREDIV_CNF5) & M_STATIC_C_PLL_PREDIV_CNF5)
-
-#define S_T6_STATIC_C_PLL_MULT 0
-#define M_T6_STATIC_C_PLL_MULT 0xffU
-#define V_T6_STATIC_C_PLL_MULT(x) ((x) << S_T6_STATIC_C_PLL_MULT)
-#define G_T6_STATIC_C_PLL_MULT(x) (((x) >> S_T6_STATIC_C_PLL_MULT) & M_T6_STATIC_C_PLL_MULT)
-
-#define A_DBG_T5_STATIC_U_PLL_CONF1 0x60e4
-
-#define S_T5_STATIC_U_PLL_MULTFRAC 8
-#define M_T5_STATIC_U_PLL_MULTFRAC 0xffffffU
-#define V_T5_STATIC_U_PLL_MULTFRAC(x) ((x) << S_T5_STATIC_U_PLL_MULTFRAC)
-#define G_T5_STATIC_U_PLL_MULTFRAC(x) (((x) >> S_T5_STATIC_U_PLL_MULTFRAC) & M_T5_STATIC_U_PLL_MULTFRAC)
-
-#define S_T5_STATIC_U_PLL_FFSLEWRATE 0
-#define M_T5_STATIC_U_PLL_FFSLEWRATE 0xffU
-#define V_T5_STATIC_U_PLL_FFSLEWRATE(x) ((x) << S_T5_STATIC_U_PLL_FFSLEWRATE)
-#define G_T5_STATIC_U_PLL_FFSLEWRATE(x) (((x) >> S_T5_STATIC_U_PLL_FFSLEWRATE) & M_T5_STATIC_U_PLL_FFSLEWRATE)
-
-#define A_DBG_STATIC_U_PLL_CONF1 0x60e4
-
-#define S_STATIC_U_PLL_MULTFRAC 8
-#define M_STATIC_U_PLL_MULTFRAC 0xffffffU
-#define V_STATIC_U_PLL_MULTFRAC(x) ((x) << S_STATIC_U_PLL_MULTFRAC)
-#define G_STATIC_U_PLL_MULTFRAC(x) (((x) >> S_STATIC_U_PLL_MULTFRAC) & M_STATIC_U_PLL_MULTFRAC)
-
-#define S_STATIC_U_PLL_FFSLEWRATE 0
-#define M_STATIC_U_PLL_FFSLEWRATE 0xffU
-#define V_STATIC_U_PLL_FFSLEWRATE(x) ((x) << S_STATIC_U_PLL_FFSLEWRATE)
-#define G_STATIC_U_PLL_FFSLEWRATE(x) (((x) >> S_STATIC_U_PLL_FFSLEWRATE) & M_STATIC_U_PLL_FFSLEWRATE)
-
-#define A_DBG_T5_STATIC_U_PLL_CONF2 0x60e8
-
-#define S_T5_STATIC_U_PLL_DCO_BYPASS 23
-#define V_T5_STATIC_U_PLL_DCO_BYPASS(x) ((x) << S_T5_STATIC_U_PLL_DCO_BYPASS)
-#define F_T5_STATIC_U_PLL_DCO_BYPASS V_T5_STATIC_U_PLL_DCO_BYPASS(1U)
-
-#define S_T5_STATIC_U_PLL_SDORDER 21
-#define M_T5_STATIC_U_PLL_SDORDER 0x3U
-#define V_T5_STATIC_U_PLL_SDORDER(x) ((x) << S_T5_STATIC_U_PLL_SDORDER)
-#define G_T5_STATIC_U_PLL_SDORDER(x) (((x) >> S_T5_STATIC_U_PLL_SDORDER) & M_T5_STATIC_U_PLL_SDORDER)
-
-#define S_T5_STATIC_U_PLL_FFENABLE 20
-#define V_T5_STATIC_U_PLL_FFENABLE(x) ((x) << S_T5_STATIC_U_PLL_FFENABLE)
-#define F_T5_STATIC_U_PLL_FFENABLE V_T5_STATIC_U_PLL_FFENABLE(1U)
-
-#define S_T5_STATIC_U_PLL_STOPCLKB 19
-#define V_T5_STATIC_U_PLL_STOPCLKB(x) ((x) << S_T5_STATIC_U_PLL_STOPCLKB)
-#define F_T5_STATIC_U_PLL_STOPCLKB V_T5_STATIC_U_PLL_STOPCLKB(1U)
-
-#define S_T5_STATIC_U_PLL_STOPCLKA 18
-#define V_T5_STATIC_U_PLL_STOPCLKA(x) ((x) << S_T5_STATIC_U_PLL_STOPCLKA)
-#define F_T5_STATIC_U_PLL_STOPCLKA V_T5_STATIC_U_PLL_STOPCLKA(1U)
-
-#define S_T5_STATIC_U_PLL_SLEEP 17
-#define V_T5_STATIC_U_PLL_SLEEP(x) ((x) << S_T5_STATIC_U_PLL_SLEEP)
-#define F_T5_STATIC_U_PLL_SLEEP V_T5_STATIC_U_PLL_SLEEP(1U)
-
-#define S_T5_STATIC_U_PLL_BYPASS 16
-#define V_T5_STATIC_U_PLL_BYPASS(x) ((x) << S_T5_STATIC_U_PLL_BYPASS)
-#define F_T5_STATIC_U_PLL_BYPASS V_T5_STATIC_U_PLL_BYPASS(1U)
-
-#define S_T5_STATIC_U_PLL_LOCKTUNE 0
-#define M_T5_STATIC_U_PLL_LOCKTUNE 0xffffU
-#define V_T5_STATIC_U_PLL_LOCKTUNE(x) ((x) << S_T5_STATIC_U_PLL_LOCKTUNE)
-#define G_T5_STATIC_U_PLL_LOCKTUNE(x) (((x) >> S_T5_STATIC_U_PLL_LOCKTUNE) & M_T5_STATIC_U_PLL_LOCKTUNE)
-
-#define A_DBG_STATIC_U_PLL_CONF2 0x60e8
-
-#define S_T6_STATIC_U_PLL_PREDIV 26
-#define M_T6_STATIC_U_PLL_PREDIV 0x3fU
-#define V_T6_STATIC_U_PLL_PREDIV(x) ((x) << S_T6_STATIC_U_PLL_PREDIV)
-#define G_T6_STATIC_U_PLL_PREDIV(x) (((x) >> S_T6_STATIC_U_PLL_PREDIV) & M_T6_STATIC_U_PLL_PREDIV)
-
-#define S_STATIC_U_PLL_STARTUP 24
-#define M_STATIC_U_PLL_STARTUP 0x3U
-#define V_STATIC_U_PLL_STARTUP(x) ((x) << S_STATIC_U_PLL_STARTUP)
-#define G_STATIC_U_PLL_STARTUP(x) (((x) >> S_STATIC_U_PLL_STARTUP) & M_STATIC_U_PLL_STARTUP)
-
-#define S_STATIC_U_PLL_DCO_BYPASS 23
-#define V_STATIC_U_PLL_DCO_BYPASS(x) ((x) << S_STATIC_U_PLL_DCO_BYPASS)
-#define F_STATIC_U_PLL_DCO_BYPASS V_STATIC_U_PLL_DCO_BYPASS(1U)
-
-#define S_STATIC_U_PLL_SDORDER 21
-#define M_STATIC_U_PLL_SDORDER 0x3U
-#define V_STATIC_U_PLL_SDORDER(x) ((x) << S_STATIC_U_PLL_SDORDER)
-#define G_STATIC_U_PLL_SDORDER(x) (((x) >> S_STATIC_U_PLL_SDORDER) & M_STATIC_U_PLL_SDORDER)
-
-#define S_STATIC_U_PLL_DIVCHANGE 20
-#define V_STATIC_U_PLL_DIVCHANGE(x) ((x) << S_STATIC_U_PLL_DIVCHANGE)
-#define F_STATIC_U_PLL_DIVCHANGE V_STATIC_U_PLL_DIVCHANGE(1U)
-
-#define S_STATIC_U_PLL_STOPCLKB 19
-#define V_STATIC_U_PLL_STOPCLKB(x) ((x) << S_STATIC_U_PLL_STOPCLKB)
-#define F_STATIC_U_PLL_STOPCLKB V_STATIC_U_PLL_STOPCLKB(1U)
-
-#define S_STATIC_U_PLL_STOPCLKA 18
-#define V_STATIC_U_PLL_STOPCLKA(x) ((x) << S_STATIC_U_PLL_STOPCLKA)
-#define F_STATIC_U_PLL_STOPCLKA V_STATIC_U_PLL_STOPCLKA(1U)
-
-#define S_T6_STATIC_U_PLL_SLEEP 17
-#define V_T6_STATIC_U_PLL_SLEEP(x) ((x) << S_T6_STATIC_U_PLL_SLEEP)
-#define F_T6_STATIC_U_PLL_SLEEP V_T6_STATIC_U_PLL_SLEEP(1U)
-
-#define S_T6_STATIC_U_PLL_BYPASS 16
-#define V_T6_STATIC_U_PLL_BYPASS(x) ((x) << S_T6_STATIC_U_PLL_BYPASS)
-#define F_T6_STATIC_U_PLL_BYPASS V_T6_STATIC_U_PLL_BYPASS(1U)
-
-#define S_STATIC_U_PLL_LOCKTUNE 0
-#define M_STATIC_U_PLL_LOCKTUNE 0x1fU
-#define V_STATIC_U_PLL_LOCKTUNE(x) ((x) << S_STATIC_U_PLL_LOCKTUNE)
-#define G_STATIC_U_PLL_LOCKTUNE(x) (((x) >> S_STATIC_U_PLL_LOCKTUNE) & M_STATIC_U_PLL_LOCKTUNE)
-
-#define A_DBG_T5_STATIC_U_PLL_CONF3 0x60ec
-
-#define S_T5_STATIC_U_PLL_MULTPRE 30
-#define M_T5_STATIC_U_PLL_MULTPRE 0x3U
-#define V_T5_STATIC_U_PLL_MULTPRE(x) ((x) << S_T5_STATIC_U_PLL_MULTPRE)
-#define G_T5_STATIC_U_PLL_MULTPRE(x) (((x) >> S_T5_STATIC_U_PLL_MULTPRE) & M_T5_STATIC_U_PLL_MULTPRE)
-
-#define S_T5_STATIC_U_PLL_LOCKSEL 28
-#define M_T5_STATIC_U_PLL_LOCKSEL 0x3U
-#define V_T5_STATIC_U_PLL_LOCKSEL(x) ((x) << S_T5_STATIC_U_PLL_LOCKSEL)
-#define G_T5_STATIC_U_PLL_LOCKSEL(x) (((x) >> S_T5_STATIC_U_PLL_LOCKSEL) & M_T5_STATIC_U_PLL_LOCKSEL)
-
-#define S_T5_STATIC_U_PLL_FFTUNE 12
-#define M_T5_STATIC_U_PLL_FFTUNE 0xffffU
-#define V_T5_STATIC_U_PLL_FFTUNE(x) ((x) << S_T5_STATIC_U_PLL_FFTUNE)
-#define G_T5_STATIC_U_PLL_FFTUNE(x) (((x) >> S_T5_STATIC_U_PLL_FFTUNE) & M_T5_STATIC_U_PLL_FFTUNE)
-
-#define S_T5_STATIC_U_PLL_RANGEPRE 10
-#define M_T5_STATIC_U_PLL_RANGEPRE 0x3U
-#define V_T5_STATIC_U_PLL_RANGEPRE(x) ((x) << S_T5_STATIC_U_PLL_RANGEPRE)
-#define G_T5_STATIC_U_PLL_RANGEPRE(x) (((x) >> S_T5_STATIC_U_PLL_RANGEPRE) & M_T5_STATIC_U_PLL_RANGEPRE)
-
-#define S_T5_STATIC_U_PLL_RANGEB 5
-#define M_T5_STATIC_U_PLL_RANGEB 0x1fU
-#define V_T5_STATIC_U_PLL_RANGEB(x) ((x) << S_T5_STATIC_U_PLL_RANGEB)
-#define G_T5_STATIC_U_PLL_RANGEB(x) (((x) >> S_T5_STATIC_U_PLL_RANGEB) & M_T5_STATIC_U_PLL_RANGEB)
-
-#define S_T5_STATIC_U_PLL_RANGEA 0
-#define M_T5_STATIC_U_PLL_RANGEA 0x1fU
-#define V_T5_STATIC_U_PLL_RANGEA(x) ((x) << S_T5_STATIC_U_PLL_RANGEA)
-#define G_T5_STATIC_U_PLL_RANGEA(x) (((x) >> S_T5_STATIC_U_PLL_RANGEA) & M_T5_STATIC_U_PLL_RANGEA)
-
-#define A_DBG_STATIC_U_PLL_CONF3 0x60ec
-
-#define S_STATIC_U_PLL_MULTPRE 30
-#define M_STATIC_U_PLL_MULTPRE 0x3U
-#define V_STATIC_U_PLL_MULTPRE(x) ((x) << S_STATIC_U_PLL_MULTPRE)
-#define G_STATIC_U_PLL_MULTPRE(x) (((x) >> S_STATIC_U_PLL_MULTPRE) & M_STATIC_U_PLL_MULTPRE)
-
-#define S_STATIC_U_PLL_LOCKSEL 28
-#define V_STATIC_U_PLL_LOCKSEL(x) ((x) << S_STATIC_U_PLL_LOCKSEL)
-#define F_STATIC_U_PLL_LOCKSEL V_STATIC_U_PLL_LOCKSEL(1U)
-
-#define S_STATIC_U_PLL_FFTUNE 12
-#define M_STATIC_U_PLL_FFTUNE 0xffffU
-#define V_STATIC_U_PLL_FFTUNE(x) ((x) << S_STATIC_U_PLL_FFTUNE)
-#define G_STATIC_U_PLL_FFTUNE(x) (((x) >> S_STATIC_U_PLL_FFTUNE) & M_STATIC_U_PLL_FFTUNE)
-
-#define S_STATIC_U_PLL_RANGEPRE 10
-#define M_STATIC_U_PLL_RANGEPRE 0x3U
-#define V_STATIC_U_PLL_RANGEPRE(x) ((x) << S_STATIC_U_PLL_RANGEPRE)
-#define G_STATIC_U_PLL_RANGEPRE(x) (((x) >> S_STATIC_U_PLL_RANGEPRE) & M_STATIC_U_PLL_RANGEPRE)
-
-#define S_T6_STATIC_U_PLL_RANGEB 5
-#define M_T6_STATIC_U_PLL_RANGEB 0x1fU
-#define V_T6_STATIC_U_PLL_RANGEB(x) ((x) << S_T6_STATIC_U_PLL_RANGEB)
-#define G_T6_STATIC_U_PLL_RANGEB(x) (((x) >> S_T6_STATIC_U_PLL_RANGEB) & M_T6_STATIC_U_PLL_RANGEB)
-
-#define S_T6_STATIC_U_PLL_RANGEA 0
-#define M_T6_STATIC_U_PLL_RANGEA 0x1fU
-#define V_T6_STATIC_U_PLL_RANGEA(x) ((x) << S_T6_STATIC_U_PLL_RANGEA)
-#define G_T6_STATIC_U_PLL_RANGEA(x) (((x) >> S_T6_STATIC_U_PLL_RANGEA) & M_T6_STATIC_U_PLL_RANGEA)
-
-#define A_DBG_T5_STATIC_U_PLL_CONF4 0x60f0
-#define A_DBG_STATIC_U_PLL_CONF4 0x60f0
-#define A_DBG_T5_STATIC_U_PLL_CONF5 0x60f4
-
-#define S_T5_STATIC_U_PLL_VCVTUNE 22
-#define M_T5_STATIC_U_PLL_VCVTUNE 0x7U
-#define V_T5_STATIC_U_PLL_VCVTUNE(x) ((x) << S_T5_STATIC_U_PLL_VCVTUNE)
-#define G_T5_STATIC_U_PLL_VCVTUNE(x) (((x) >> S_T5_STATIC_U_PLL_VCVTUNE) & M_T5_STATIC_U_PLL_VCVTUNE)
-
-#define S_T5_STATIC_U_PLL_LFTUNE_32_40 13
-#define M_T5_STATIC_U_PLL_LFTUNE_32_40 0x1ffU
-#define V_T5_STATIC_U_PLL_LFTUNE_32_40(x) ((x) << S_T5_STATIC_U_PLL_LFTUNE_32_40)
-#define G_T5_STATIC_U_PLL_LFTUNE_32_40(x) (((x) >> S_T5_STATIC_U_PLL_LFTUNE_32_40) & M_T5_STATIC_U_PLL_LFTUNE_32_40)
-
-#define S_T5_STATIC_U_PLL_PREDIV 8
-#define M_T5_STATIC_U_PLL_PREDIV 0x1fU
-#define V_T5_STATIC_U_PLL_PREDIV(x) ((x) << S_T5_STATIC_U_PLL_PREDIV)
-#define G_T5_STATIC_U_PLL_PREDIV(x) (((x) >> S_T5_STATIC_U_PLL_PREDIV) & M_T5_STATIC_U_PLL_PREDIV)
-
-#define S_T5_STATIC_U_PLL_MULT 0
-#define M_T5_STATIC_U_PLL_MULT 0xffU
-#define V_T5_STATIC_U_PLL_MULT(x) ((x) << S_T5_STATIC_U_PLL_MULT)
-#define G_T5_STATIC_U_PLL_MULT(x) (((x) >> S_T5_STATIC_U_PLL_MULT) & M_T5_STATIC_U_PLL_MULT)
-
-#define A_DBG_STATIC_U_PLL_CONF5 0x60f4
-
-#define S_STATIC_U_PLL_FFBYPASS 27
-#define V_STATIC_U_PLL_FFBYPASS(x) ((x) << S_STATIC_U_PLL_FFBYPASS)
-#define F_STATIC_U_PLL_FFBYPASS V_STATIC_U_PLL_FFBYPASS(1U)
-
-#define S_STATIC_U_PLL_FASTSTOP 26
-#define V_STATIC_U_PLL_FASTSTOP(x) ((x) << S_STATIC_U_PLL_FASTSTOP)
-#define F_STATIC_U_PLL_FASTSTOP V_STATIC_U_PLL_FASTSTOP(1U)
-
-#define S_STATIC_U_PLL_FRAMESTOP 25
-#define V_STATIC_U_PLL_FRAMESTOP(x) ((x) << S_STATIC_U_PLL_FRAMESTOP)
-#define F_STATIC_U_PLL_FRAMESTOP V_STATIC_U_PLL_FRAMESTOP(1U)
-
-#define S_STATIC_U_PLL_VCVTUNE 22
-#define M_STATIC_U_PLL_VCVTUNE 0x7U
-#define V_STATIC_U_PLL_VCVTUNE(x) ((x) << S_STATIC_U_PLL_VCVTUNE)
-#define G_STATIC_U_PLL_VCVTUNE(x) (((x) >> S_STATIC_U_PLL_VCVTUNE) & M_STATIC_U_PLL_VCVTUNE)
-
-#define S_STATIC_U_PLL_LFTUNE_32_40 13
-#define M_STATIC_U_PLL_LFTUNE_32_40 0x1ffU
-#define V_STATIC_U_PLL_LFTUNE_32_40(x) ((x) << S_STATIC_U_PLL_LFTUNE_32_40)
-#define G_STATIC_U_PLL_LFTUNE_32_40(x) (((x) >> S_STATIC_U_PLL_LFTUNE_32_40) & M_STATIC_U_PLL_LFTUNE_32_40)
-
-#define S_STATIC_U_PLL_PREDIV_CNF5 8
-#define M_STATIC_U_PLL_PREDIV_CNF5 0x1fU
-#define V_STATIC_U_PLL_PREDIV_CNF5(x) ((x) << S_STATIC_U_PLL_PREDIV_CNF5)
-#define G_STATIC_U_PLL_PREDIV_CNF5(x) (((x) >> S_STATIC_U_PLL_PREDIV_CNF5) & M_STATIC_U_PLL_PREDIV_CNF5)
-
-#define S_T6_STATIC_U_PLL_MULT 0
-#define M_T6_STATIC_U_PLL_MULT 0xffU
-#define V_T6_STATIC_U_PLL_MULT(x) ((x) << S_T6_STATIC_U_PLL_MULT)
-#define G_T6_STATIC_U_PLL_MULT(x) (((x) >> S_T6_STATIC_U_PLL_MULT) & M_T6_STATIC_U_PLL_MULT)
-
-#define A_DBG_T5_STATIC_KR_PLL_CONF1 0x60f8
-
-#define S_T5_STATIC_KR_PLL_BYPASS 30
-#define V_T5_STATIC_KR_PLL_BYPASS(x) ((x) << S_T5_STATIC_KR_PLL_BYPASS)
-#define F_T5_STATIC_KR_PLL_BYPASS V_T5_STATIC_KR_PLL_BYPASS(1U)
-
-#define S_T5_STATIC_KR_PLL_VBOOSTDIV 27
-#define M_T5_STATIC_KR_PLL_VBOOSTDIV 0x7U
-#define V_T5_STATIC_KR_PLL_VBOOSTDIV(x) ((x) << S_T5_STATIC_KR_PLL_VBOOSTDIV)
-#define G_T5_STATIC_KR_PLL_VBOOSTDIV(x) (((x) >> S_T5_STATIC_KR_PLL_VBOOSTDIV) & M_T5_STATIC_KR_PLL_VBOOSTDIV)
-
-#define S_T5_STATIC_KR_PLL_CPISEL 24
-#define M_T5_STATIC_KR_PLL_CPISEL 0x7U
-#define V_T5_STATIC_KR_PLL_CPISEL(x) ((x) << S_T5_STATIC_KR_PLL_CPISEL)
-#define G_T5_STATIC_KR_PLL_CPISEL(x) (((x) >> S_T5_STATIC_KR_PLL_CPISEL) & M_T5_STATIC_KR_PLL_CPISEL)
-
-#define S_T5_STATIC_KR_PLL_CCALMETHOD 23
-#define V_T5_STATIC_KR_PLL_CCALMETHOD(x) ((x) << S_T5_STATIC_KR_PLL_CCALMETHOD)
-#define F_T5_STATIC_KR_PLL_CCALMETHOD V_T5_STATIC_KR_PLL_CCALMETHOD(1U)
-
-#define S_T5_STATIC_KR_PLL_CCALLOAD 22
-#define V_T5_STATIC_KR_PLL_CCALLOAD(x) ((x) << S_T5_STATIC_KR_PLL_CCALLOAD)
-#define F_T5_STATIC_KR_PLL_CCALLOAD V_T5_STATIC_KR_PLL_CCALLOAD(1U)
-
-#define S_T5_STATIC_KR_PLL_CCALFMIN 21
-#define V_T5_STATIC_KR_PLL_CCALFMIN(x) ((x) << S_T5_STATIC_KR_PLL_CCALFMIN)
-#define F_T5_STATIC_KR_PLL_CCALFMIN V_T5_STATIC_KR_PLL_CCALFMIN(1U)
-
-#define S_T5_STATIC_KR_PLL_CCALFMAX 20
-#define V_T5_STATIC_KR_PLL_CCALFMAX(x) ((x) << S_T5_STATIC_KR_PLL_CCALFMAX)
-#define F_T5_STATIC_KR_PLL_CCALFMAX V_T5_STATIC_KR_PLL_CCALFMAX(1U)
-
-#define S_T5_STATIC_KR_PLL_CCALCVHOLD 19
-#define V_T5_STATIC_KR_PLL_CCALCVHOLD(x) ((x) << S_T5_STATIC_KR_PLL_CCALCVHOLD)
-#define F_T5_STATIC_KR_PLL_CCALCVHOLD V_T5_STATIC_KR_PLL_CCALCVHOLD(1U)
-
-#define S_T5_STATIC_KR_PLL_CCALBANDSEL 15
-#define M_T5_STATIC_KR_PLL_CCALBANDSEL 0xfU
-#define V_T5_STATIC_KR_PLL_CCALBANDSEL(x) ((x) << S_T5_STATIC_KR_PLL_CCALBANDSEL)
-#define G_T5_STATIC_KR_PLL_CCALBANDSEL(x) (((x) >> S_T5_STATIC_KR_PLL_CCALBANDSEL) & M_T5_STATIC_KR_PLL_CCALBANDSEL)
-
-#define S_T5_STATIC_KR_PLL_BGOFFSET 11
-#define M_T5_STATIC_KR_PLL_BGOFFSET 0xfU
-#define V_T5_STATIC_KR_PLL_BGOFFSET(x) ((x) << S_T5_STATIC_KR_PLL_BGOFFSET)
-#define G_T5_STATIC_KR_PLL_BGOFFSET(x) (((x) >> S_T5_STATIC_KR_PLL_BGOFFSET) & M_T5_STATIC_KR_PLL_BGOFFSET)
-
-#define S_T5_STATIC_KR_PLL_P 8
-#define M_T5_STATIC_KR_PLL_P 0x7U
-#define V_T5_STATIC_KR_PLL_P(x) ((x) << S_T5_STATIC_KR_PLL_P)
-#define G_T5_STATIC_KR_PLL_P(x) (((x) >> S_T5_STATIC_KR_PLL_P) & M_T5_STATIC_KR_PLL_P)
-
-#define S_T5_STATIC_KR_PLL_N2 4
-#define M_T5_STATIC_KR_PLL_N2 0xfU
-#define V_T5_STATIC_KR_PLL_N2(x) ((x) << S_T5_STATIC_KR_PLL_N2)
-#define G_T5_STATIC_KR_PLL_N2(x) (((x) >> S_T5_STATIC_KR_PLL_N2) & M_T5_STATIC_KR_PLL_N2)
-
-#define S_T5_STATIC_KR_PLL_N1 0
-#define M_T5_STATIC_KR_PLL_N1 0xfU
-#define V_T5_STATIC_KR_PLL_N1(x) ((x) << S_T5_STATIC_KR_PLL_N1)
-#define G_T5_STATIC_KR_PLL_N1(x) (((x) >> S_T5_STATIC_KR_PLL_N1) & M_T5_STATIC_KR_PLL_N1)
-
-#define A_DBG_STATIC_KR_PLL_CONF1 0x60f8
-
-#define S_T6_STATIC_KR_PLL_BYPASS 30
-#define V_T6_STATIC_KR_PLL_BYPASS(x) ((x) << S_T6_STATIC_KR_PLL_BYPASS)
-#define F_T6_STATIC_KR_PLL_BYPASS V_T6_STATIC_KR_PLL_BYPASS(1U)
-
-#define S_STATIC_KR_PLL_VBOOSTDIV 27
-#define M_STATIC_KR_PLL_VBOOSTDIV 0x7U
-#define V_STATIC_KR_PLL_VBOOSTDIV(x) ((x) << S_STATIC_KR_PLL_VBOOSTDIV)
-#define G_STATIC_KR_PLL_VBOOSTDIV(x) (((x) >> S_STATIC_KR_PLL_VBOOSTDIV) & M_STATIC_KR_PLL_VBOOSTDIV)
-
-#define S_STATIC_KR_PLL_CPISEL 24
-#define M_STATIC_KR_PLL_CPISEL 0x7U
-#define V_STATIC_KR_PLL_CPISEL(x) ((x) << S_STATIC_KR_PLL_CPISEL)
-#define G_STATIC_KR_PLL_CPISEL(x) (((x) >> S_STATIC_KR_PLL_CPISEL) & M_STATIC_KR_PLL_CPISEL)
-
-#define S_STATIC_KR_PLL_CCALMETHOD 23
-#define V_STATIC_KR_PLL_CCALMETHOD(x) ((x) << S_STATIC_KR_PLL_CCALMETHOD)
-#define F_STATIC_KR_PLL_CCALMETHOD V_STATIC_KR_PLL_CCALMETHOD(1U)
-
-#define S_STATIC_KR_PLL_CCALLOAD 22
-#define V_STATIC_KR_PLL_CCALLOAD(x) ((x) << S_STATIC_KR_PLL_CCALLOAD)
-#define F_STATIC_KR_PLL_CCALLOAD V_STATIC_KR_PLL_CCALLOAD(1U)
-
-#define S_STATIC_KR_PLL_CCALFMIN 21
-#define V_STATIC_KR_PLL_CCALFMIN(x) ((x) << S_STATIC_KR_PLL_CCALFMIN)
-#define F_STATIC_KR_PLL_CCALFMIN V_STATIC_KR_PLL_CCALFMIN(1U)
-
-#define S_STATIC_KR_PLL_CCALFMAX 20
-#define V_STATIC_KR_PLL_CCALFMAX(x) ((x) << S_STATIC_KR_PLL_CCALFMAX)
-#define F_STATIC_KR_PLL_CCALFMAX V_STATIC_KR_PLL_CCALFMAX(1U)
-
-#define S_STATIC_KR_PLL_CCALCVHOLD 19
-#define V_STATIC_KR_PLL_CCALCVHOLD(x) ((x) << S_STATIC_KR_PLL_CCALCVHOLD)
-#define F_STATIC_KR_PLL_CCALCVHOLD V_STATIC_KR_PLL_CCALCVHOLD(1U)
-
-#define S_STATIC_KR_PLL_CCALBANDSEL 15
-#define M_STATIC_KR_PLL_CCALBANDSEL 0xfU
-#define V_STATIC_KR_PLL_CCALBANDSEL(x) ((x) << S_STATIC_KR_PLL_CCALBANDSEL)
-#define G_STATIC_KR_PLL_CCALBANDSEL(x) (((x) >> S_STATIC_KR_PLL_CCALBANDSEL) & M_STATIC_KR_PLL_CCALBANDSEL)
-
-#define S_STATIC_KR_PLL_BGOFFSET 11
-#define M_STATIC_KR_PLL_BGOFFSET 0xfU
-#define V_STATIC_KR_PLL_BGOFFSET(x) ((x) << S_STATIC_KR_PLL_BGOFFSET)
-#define G_STATIC_KR_PLL_BGOFFSET(x) (((x) >> S_STATIC_KR_PLL_BGOFFSET) & M_STATIC_KR_PLL_BGOFFSET)
-
-#define S_T6_STATIC_KR_PLL_P 8
-#define M_T6_STATIC_KR_PLL_P 0x7U
-#define V_T6_STATIC_KR_PLL_P(x) ((x) << S_T6_STATIC_KR_PLL_P)
-#define G_T6_STATIC_KR_PLL_P(x) (((x) >> S_T6_STATIC_KR_PLL_P) & M_T6_STATIC_KR_PLL_P)
-
-#define S_T6_STATIC_KR_PLL_N2 4
-#define M_T6_STATIC_KR_PLL_N2 0xfU
-#define V_T6_STATIC_KR_PLL_N2(x) ((x) << S_T6_STATIC_KR_PLL_N2)
-#define G_T6_STATIC_KR_PLL_N2(x) (((x) >> S_T6_STATIC_KR_PLL_N2) & M_T6_STATIC_KR_PLL_N2)
-
-#define S_T6_STATIC_KR_PLL_N1 0
-#define M_T6_STATIC_KR_PLL_N1 0xfU
-#define V_T6_STATIC_KR_PLL_N1(x) ((x) << S_T6_STATIC_KR_PLL_N1)
-#define G_T6_STATIC_KR_PLL_N1(x) (((x) >> S_T6_STATIC_KR_PLL_N1) & M_T6_STATIC_KR_PLL_N1)
-
-#define A_DBG_T5_STATIC_KR_PLL_CONF2 0x60fc
-
-#define S_T5_STATIC_KR_PLL_M 11
-#define M_T5_STATIC_KR_PLL_M 0x1ffU
-#define V_T5_STATIC_KR_PLL_M(x) ((x) << S_T5_STATIC_KR_PLL_M)
-#define G_T5_STATIC_KR_PLL_M(x) (((x) >> S_T5_STATIC_KR_PLL_M) & M_T5_STATIC_KR_PLL_M)
-
-#define S_T5_STATIC_KR_PLL_ANALOGTUNE 0
-#define M_T5_STATIC_KR_PLL_ANALOGTUNE 0x7ffU
-#define V_T5_STATIC_KR_PLL_ANALOGTUNE(x) ((x) << S_T5_STATIC_KR_PLL_ANALOGTUNE)
-#define G_T5_STATIC_KR_PLL_ANALOGTUNE(x) (((x) >> S_T5_STATIC_KR_PLL_ANALOGTUNE) & M_T5_STATIC_KR_PLL_ANALOGTUNE)
-
-#define A_DBG_STATIC_KR_PLL_CONF2 0x60fc
-
-#define S_T6_STATIC_KR_PLL_M 11
-#define M_T6_STATIC_KR_PLL_M 0x1ffU
-#define V_T6_STATIC_KR_PLL_M(x) ((x) << S_T6_STATIC_KR_PLL_M)
-#define G_T6_STATIC_KR_PLL_M(x) (((x) >> S_T6_STATIC_KR_PLL_M) & M_T6_STATIC_KR_PLL_M)
-
-#define S_STATIC_KR_PLL_ANALOGTUNE 0
-#define M_STATIC_KR_PLL_ANALOGTUNE 0x7ffU
-#define V_STATIC_KR_PLL_ANALOGTUNE(x) ((x) << S_STATIC_KR_PLL_ANALOGTUNE)
-#define G_STATIC_KR_PLL_ANALOGTUNE(x) (((x) >> S_STATIC_KR_PLL_ANALOGTUNE) & M_STATIC_KR_PLL_ANALOGTUNE)
-
-#define A_DBG_PVT_REG_CALIBRATE_CTL 0x6100
-
-#define S_HALT_CALIBRATE 1
-#define V_HALT_CALIBRATE(x) ((x) << S_HALT_CALIBRATE)
-#define F_HALT_CALIBRATE V_HALT_CALIBRATE(1U)
-
-#define S_RESET_CALIBRATE 0
-#define V_RESET_CALIBRATE(x) ((x) << S_RESET_CALIBRATE)
-#define F_RESET_CALIBRATE V_RESET_CALIBRATE(1U)
-
-#define A_DBG_GPIO_EN_NEW 0x6100
-
-#define S_GPIO16_OEN 7
-#define V_GPIO16_OEN(x) ((x) << S_GPIO16_OEN)
-#define F_GPIO16_OEN V_GPIO16_OEN(1U)
-
-#define S_GPIO17_OEN 6
-#define V_GPIO17_OEN(x) ((x) << S_GPIO17_OEN)
-#define F_GPIO17_OEN V_GPIO17_OEN(1U)
-
-#define S_GPIO18_OEN 5
-#define V_GPIO18_OEN(x) ((x) << S_GPIO18_OEN)
-#define F_GPIO18_OEN V_GPIO18_OEN(1U)
-
-#define S_GPIO19_OEN 4
-#define V_GPIO19_OEN(x) ((x) << S_GPIO19_OEN)
-#define F_GPIO19_OEN V_GPIO19_OEN(1U)
-
-#define S_GPIO16_OUT_VAL 3
-#define V_GPIO16_OUT_VAL(x) ((x) << S_GPIO16_OUT_VAL)
-#define F_GPIO16_OUT_VAL V_GPIO16_OUT_VAL(1U)
-
-#define S_GPIO17_OUT_VAL 2
-#define V_GPIO17_OUT_VAL(x) ((x) << S_GPIO17_OUT_VAL)
-#define F_GPIO17_OUT_VAL V_GPIO17_OUT_VAL(1U)
-
-#define S_GPIO18_OUT_VAL 1
-#define V_GPIO18_OUT_VAL(x) ((x) << S_GPIO18_OUT_VAL)
-#define F_GPIO18_OUT_VAL V_GPIO18_OUT_VAL(1U)
-
-#define S_GPIO19_OUT_VAL 0
-#define V_GPIO19_OUT_VAL(x) ((x) << S_GPIO19_OUT_VAL)
-#define F_GPIO19_OUT_VAL V_GPIO19_OUT_VAL(1U)
-
-#define A_DBG_PVT_REG_UPDATE_CTL 0x6104
-
-#define S_FAST_UPDATE 8
-#define V_FAST_UPDATE(x) ((x) << S_FAST_UPDATE)
-#define F_FAST_UPDATE V_FAST_UPDATE(1U)
-
-#define S_FORCE_REG_IN_VALUE 2
-#define V_FORCE_REG_IN_VALUE(x) ((x) << S_FORCE_REG_IN_VALUE)
-#define F_FORCE_REG_IN_VALUE V_FORCE_REG_IN_VALUE(1U)
-
-#define S_HALT_UPDATE 1
-#define V_HALT_UPDATE(x) ((x) << S_HALT_UPDATE)
-#define F_HALT_UPDATE V_HALT_UPDATE(1U)
-
-#define A_DBG_GPIO_IN_NEW 0x6104
-
-#define S_GPIO16_CHG_DET 7
-#define V_GPIO16_CHG_DET(x) ((x) << S_GPIO16_CHG_DET)
-#define F_GPIO16_CHG_DET V_GPIO16_CHG_DET(1U)
-
-#define S_GPIO17_CHG_DET 6
-#define V_GPIO17_CHG_DET(x) ((x) << S_GPIO17_CHG_DET)
-#define F_GPIO17_CHG_DET V_GPIO17_CHG_DET(1U)
-
-#define S_GPIO18_CHG_DET 5
-#define V_GPIO18_CHG_DET(x) ((x) << S_GPIO18_CHG_DET)
-#define F_GPIO18_CHG_DET V_GPIO18_CHG_DET(1U)
-
-#define S_GPIO19_CHG_DET 4
-#define V_GPIO19_CHG_DET(x) ((x) << S_GPIO19_CHG_DET)
-#define F_GPIO19_CHG_DET V_GPIO19_CHG_DET(1U)
-
-#define S_GPIO19_IN 3
-#define V_GPIO19_IN(x) ((x) << S_GPIO19_IN)
-#define F_GPIO19_IN V_GPIO19_IN(1U)
-
-#define S_GPIO18_IN 2
-#define V_GPIO18_IN(x) ((x) << S_GPIO18_IN)
-#define F_GPIO18_IN V_GPIO18_IN(1U)
-
-#define S_GPIO17_IN 1
-#define V_GPIO17_IN(x) ((x) << S_GPIO17_IN)
-#define F_GPIO17_IN V_GPIO17_IN(1U)
-
-#define S_GPIO16_IN 0
-#define V_GPIO16_IN(x) ((x) << S_GPIO16_IN)
-#define F_GPIO16_IN V_GPIO16_IN(1U)
-
-#define A_DBG_PVT_REG_LAST_MEASUREMENT 0x6108
-
-#define S_LAST_MEASUREMENT_SELECT 8
-#define M_LAST_MEASUREMENT_SELECT 0x3U
-#define V_LAST_MEASUREMENT_SELECT(x) ((x) << S_LAST_MEASUREMENT_SELECT)
-#define G_LAST_MEASUREMENT_SELECT(x) (((x) >> S_LAST_MEASUREMENT_SELECT) & M_LAST_MEASUREMENT_SELECT)
-
-#define S_LAST_MEASUREMENT_RESULT_BANK_B 4
-#define M_LAST_MEASUREMENT_RESULT_BANK_B 0xfU
-#define V_LAST_MEASUREMENT_RESULT_BANK_B(x) ((x) << S_LAST_MEASUREMENT_RESULT_BANK_B)
-#define G_LAST_MEASUREMENT_RESULT_BANK_B(x) (((x) >> S_LAST_MEASUREMENT_RESULT_BANK_B) & M_LAST_MEASUREMENT_RESULT_BANK_B)
-
-#define S_LAST_MEASUREMENT_RESULT_BANK_A 0
-#define M_LAST_MEASUREMENT_RESULT_BANK_A 0xfU
-#define V_LAST_MEASUREMENT_RESULT_BANK_A(x) ((x) << S_LAST_MEASUREMENT_RESULT_BANK_A)
-#define G_LAST_MEASUREMENT_RESULT_BANK_A(x) (((x) >> S_LAST_MEASUREMENT_RESULT_BANK_A) & M_LAST_MEASUREMENT_RESULT_BANK_A)
-
-#define A_DBG_T5_STATIC_KX_PLL_CONF1 0x6108
-
-#define S_T5_STATIC_KX_PLL_BYPASS 30
-#define V_T5_STATIC_KX_PLL_BYPASS(x) ((x) << S_T5_STATIC_KX_PLL_BYPASS)
-#define F_T5_STATIC_KX_PLL_BYPASS V_T5_STATIC_KX_PLL_BYPASS(1U)
-
-#define S_T5_STATIC_KX_PLL_VBOOSTDIV 27
-#define M_T5_STATIC_KX_PLL_VBOOSTDIV 0x7U
-#define V_T5_STATIC_KX_PLL_VBOOSTDIV(x) ((x) << S_T5_STATIC_KX_PLL_VBOOSTDIV)
-#define G_T5_STATIC_KX_PLL_VBOOSTDIV(x) (((x) >> S_T5_STATIC_KX_PLL_VBOOSTDIV) & M_T5_STATIC_KX_PLL_VBOOSTDIV)
-
-#define S_T5_STATIC_KX_PLL_CPISEL 24
-#define M_T5_STATIC_KX_PLL_CPISEL 0x7U
-#define V_T5_STATIC_KX_PLL_CPISEL(x) ((x) << S_T5_STATIC_KX_PLL_CPISEL)
-#define G_T5_STATIC_KX_PLL_CPISEL(x) (((x) >> S_T5_STATIC_KX_PLL_CPISEL) & M_T5_STATIC_KX_PLL_CPISEL)
-
-#define S_T5_STATIC_KX_PLL_CCALMETHOD 23
-#define V_T5_STATIC_KX_PLL_CCALMETHOD(x) ((x) << S_T5_STATIC_KX_PLL_CCALMETHOD)
-#define F_T5_STATIC_KX_PLL_CCALMETHOD V_T5_STATIC_KX_PLL_CCALMETHOD(1U)
-
-#define S_T5_STATIC_KX_PLL_CCALLOAD 22
-#define V_T5_STATIC_KX_PLL_CCALLOAD(x) ((x) << S_T5_STATIC_KX_PLL_CCALLOAD)
-#define F_T5_STATIC_KX_PLL_CCALLOAD V_T5_STATIC_KX_PLL_CCALLOAD(1U)
-
-#define S_T5_STATIC_KX_PLL_CCALFMIN 21
-#define V_T5_STATIC_KX_PLL_CCALFMIN(x) ((x) << S_T5_STATIC_KX_PLL_CCALFMIN)
-#define F_T5_STATIC_KX_PLL_CCALFMIN V_T5_STATIC_KX_PLL_CCALFMIN(1U)
-
-#define S_T5_STATIC_KX_PLL_CCALFMAX 20
-#define V_T5_STATIC_KX_PLL_CCALFMAX(x) ((x) << S_T5_STATIC_KX_PLL_CCALFMAX)
-#define F_T5_STATIC_KX_PLL_CCALFMAX V_T5_STATIC_KX_PLL_CCALFMAX(1U)
-
-#define S_T5_STATIC_KX_PLL_CCALCVHOLD 19
-#define V_T5_STATIC_KX_PLL_CCALCVHOLD(x) ((x) << S_T5_STATIC_KX_PLL_CCALCVHOLD)
-#define F_T5_STATIC_KX_PLL_CCALCVHOLD V_T5_STATIC_KX_PLL_CCALCVHOLD(1U)
-
-#define S_T5_STATIC_KX_PLL_CCALBANDSEL 15
-#define M_T5_STATIC_KX_PLL_CCALBANDSEL 0xfU
-#define V_T5_STATIC_KX_PLL_CCALBANDSEL(x) ((x) << S_T5_STATIC_KX_PLL_CCALBANDSEL)
-#define G_T5_STATIC_KX_PLL_CCALBANDSEL(x) (((x) >> S_T5_STATIC_KX_PLL_CCALBANDSEL) & M_T5_STATIC_KX_PLL_CCALBANDSEL)
-
-#define S_T5_STATIC_KX_PLL_BGOFFSET 11
-#define M_T5_STATIC_KX_PLL_BGOFFSET 0xfU
-#define V_T5_STATIC_KX_PLL_BGOFFSET(x) ((x) << S_T5_STATIC_KX_PLL_BGOFFSET)
-#define G_T5_STATIC_KX_PLL_BGOFFSET(x) (((x) >> S_T5_STATIC_KX_PLL_BGOFFSET) & M_T5_STATIC_KX_PLL_BGOFFSET)
-
-#define S_T5_STATIC_KX_PLL_P 8
-#define M_T5_STATIC_KX_PLL_P 0x7U
-#define V_T5_STATIC_KX_PLL_P(x) ((x) << S_T5_STATIC_KX_PLL_P)
-#define G_T5_STATIC_KX_PLL_P(x) (((x) >> S_T5_STATIC_KX_PLL_P) & M_T5_STATIC_KX_PLL_P)
-
-#define S_T5_STATIC_KX_PLL_N2 4
-#define M_T5_STATIC_KX_PLL_N2 0xfU
-#define V_T5_STATIC_KX_PLL_N2(x) ((x) << S_T5_STATIC_KX_PLL_N2)
-#define G_T5_STATIC_KX_PLL_N2(x) (((x) >> S_T5_STATIC_KX_PLL_N2) & M_T5_STATIC_KX_PLL_N2)
-
-#define S_T5_STATIC_KX_PLL_N1 0
-#define M_T5_STATIC_KX_PLL_N1 0xfU
-#define V_T5_STATIC_KX_PLL_N1(x) ((x) << S_T5_STATIC_KX_PLL_N1)
-#define G_T5_STATIC_KX_PLL_N1(x) (((x) >> S_T5_STATIC_KX_PLL_N1) & M_T5_STATIC_KX_PLL_N1)
-
-#define A_DBG_STATIC_KX_PLL_CONF1 0x6108
-
-#define S_T6_STATIC_KX_PLL_BYPASS 30
-#define V_T6_STATIC_KX_PLL_BYPASS(x) ((x) << S_T6_STATIC_KX_PLL_BYPASS)
-#define F_T6_STATIC_KX_PLL_BYPASS V_T6_STATIC_KX_PLL_BYPASS(1U)
-
-#define S_STATIC_KX_PLL_VBOOSTDIV 27
-#define M_STATIC_KX_PLL_VBOOSTDIV 0x7U
-#define V_STATIC_KX_PLL_VBOOSTDIV(x) ((x) << S_STATIC_KX_PLL_VBOOSTDIV)
-#define G_STATIC_KX_PLL_VBOOSTDIV(x) (((x) >> S_STATIC_KX_PLL_VBOOSTDIV) & M_STATIC_KX_PLL_VBOOSTDIV)
-
-#define S_STATIC_KX_PLL_CPISEL 24
-#define M_STATIC_KX_PLL_CPISEL 0x7U
-#define V_STATIC_KX_PLL_CPISEL(x) ((x) << S_STATIC_KX_PLL_CPISEL)
-#define G_STATIC_KX_PLL_CPISEL(x) (((x) >> S_STATIC_KX_PLL_CPISEL) & M_STATIC_KX_PLL_CPISEL)
-
-#define S_STATIC_KX_PLL_CCALMETHOD 23
-#define V_STATIC_KX_PLL_CCALMETHOD(x) ((x) << S_STATIC_KX_PLL_CCALMETHOD)
-#define F_STATIC_KX_PLL_CCALMETHOD V_STATIC_KX_PLL_CCALMETHOD(1U)
-
-#define S_STATIC_KX_PLL_CCALLOAD 22
-#define V_STATIC_KX_PLL_CCALLOAD(x) ((x) << S_STATIC_KX_PLL_CCALLOAD)
-#define F_STATIC_KX_PLL_CCALLOAD V_STATIC_KX_PLL_CCALLOAD(1U)
-
-#define S_STATIC_KX_PLL_CCALFMIN 21
-#define V_STATIC_KX_PLL_CCALFMIN(x) ((x) << S_STATIC_KX_PLL_CCALFMIN)
-#define F_STATIC_KX_PLL_CCALFMIN V_STATIC_KX_PLL_CCALFMIN(1U)
-
-#define S_STATIC_KX_PLL_CCALFMAX 20
-#define V_STATIC_KX_PLL_CCALFMAX(x) ((x) << S_STATIC_KX_PLL_CCALFMAX)
-#define F_STATIC_KX_PLL_CCALFMAX V_STATIC_KX_PLL_CCALFMAX(1U)
-
-#define S_STATIC_KX_PLL_CCALCVHOLD 19
-#define V_STATIC_KX_PLL_CCALCVHOLD(x) ((x) << S_STATIC_KX_PLL_CCALCVHOLD)
-#define F_STATIC_KX_PLL_CCALCVHOLD V_STATIC_KX_PLL_CCALCVHOLD(1U)
-
-#define S_STATIC_KX_PLL_CCALBANDSEL 15
-#define M_STATIC_KX_PLL_CCALBANDSEL 0xfU
-#define V_STATIC_KX_PLL_CCALBANDSEL(x) ((x) << S_STATIC_KX_PLL_CCALBANDSEL)
-#define G_STATIC_KX_PLL_CCALBANDSEL(x) (((x) >> S_STATIC_KX_PLL_CCALBANDSEL) & M_STATIC_KX_PLL_CCALBANDSEL)
-
-#define S_STATIC_KX_PLL_BGOFFSET 11
-#define M_STATIC_KX_PLL_BGOFFSET 0xfU
-#define V_STATIC_KX_PLL_BGOFFSET(x) ((x) << S_STATIC_KX_PLL_BGOFFSET)
-#define G_STATIC_KX_PLL_BGOFFSET(x) (((x) >> S_STATIC_KX_PLL_BGOFFSET) & M_STATIC_KX_PLL_BGOFFSET)
-
-#define S_T6_STATIC_KX_PLL_P 8
-#define M_T6_STATIC_KX_PLL_P 0x7U
-#define V_T6_STATIC_KX_PLL_P(x) ((x) << S_T6_STATIC_KX_PLL_P)
-#define G_T6_STATIC_KX_PLL_P(x) (((x) >> S_T6_STATIC_KX_PLL_P) & M_T6_STATIC_KX_PLL_P)
-
-#define S_T6_STATIC_KX_PLL_N2 4
-#define M_T6_STATIC_KX_PLL_N2 0xfU
-#define V_T6_STATIC_KX_PLL_N2(x) ((x) << S_T6_STATIC_KX_PLL_N2)
-#define G_T6_STATIC_KX_PLL_N2(x) (((x) >> S_T6_STATIC_KX_PLL_N2) & M_T6_STATIC_KX_PLL_N2)
-
-#define S_T6_STATIC_KX_PLL_N1 0
-#define M_T6_STATIC_KX_PLL_N1 0xfU
-#define V_T6_STATIC_KX_PLL_N1(x) ((x) << S_T6_STATIC_KX_PLL_N1)
-#define G_T6_STATIC_KX_PLL_N1(x) (((x) >> S_T6_STATIC_KX_PLL_N1) & M_T6_STATIC_KX_PLL_N1)
-
-#define A_DBG_PVT_REG_DRVN 0x610c
-
-#define S_PVT_REG_DRVN_EN 8
-#define V_PVT_REG_DRVN_EN(x) ((x) << S_PVT_REG_DRVN_EN)
-#define F_PVT_REG_DRVN_EN V_PVT_REG_DRVN_EN(1U)
-
-#define S_PVT_REG_DRVN_B 4
-#define M_PVT_REG_DRVN_B 0xfU
-#define V_PVT_REG_DRVN_B(x) ((x) << S_PVT_REG_DRVN_B)
-#define G_PVT_REG_DRVN_B(x) (((x) >> S_PVT_REG_DRVN_B) & M_PVT_REG_DRVN_B)
-
-#define S_PVT_REG_DRVN_A 0
-#define M_PVT_REG_DRVN_A 0xfU
-#define V_PVT_REG_DRVN_A(x) ((x) << S_PVT_REG_DRVN_A)
-#define G_PVT_REG_DRVN_A(x) (((x) >> S_PVT_REG_DRVN_A) & M_PVT_REG_DRVN_A)
-
-#define A_DBG_T5_STATIC_KX_PLL_CONF2 0x610c
-
-#define S_T5_STATIC_KX_PLL_M 11
-#define M_T5_STATIC_KX_PLL_M 0x1ffU
-#define V_T5_STATIC_KX_PLL_M(x) ((x) << S_T5_STATIC_KX_PLL_M)
-#define G_T5_STATIC_KX_PLL_M(x) (((x) >> S_T5_STATIC_KX_PLL_M) & M_T5_STATIC_KX_PLL_M)
-
-#define S_T5_STATIC_KX_PLL_ANALOGTUNE 0
-#define M_T5_STATIC_KX_PLL_ANALOGTUNE 0x7ffU
-#define V_T5_STATIC_KX_PLL_ANALOGTUNE(x) ((x) << S_T5_STATIC_KX_PLL_ANALOGTUNE)
-#define G_T5_STATIC_KX_PLL_ANALOGTUNE(x) (((x) >> S_T5_STATIC_KX_PLL_ANALOGTUNE) & M_T5_STATIC_KX_PLL_ANALOGTUNE)
-
-#define A_DBG_STATIC_KX_PLL_CONF2 0x610c
-
-#define S_T6_STATIC_KX_PLL_M 11
-#define M_T6_STATIC_KX_PLL_M 0x1ffU
-#define V_T6_STATIC_KX_PLL_M(x) ((x) << S_T6_STATIC_KX_PLL_M)
-#define G_T6_STATIC_KX_PLL_M(x) (((x) >> S_T6_STATIC_KX_PLL_M) & M_T6_STATIC_KX_PLL_M)
-
-#define S_STATIC_KX_PLL_ANALOGTUNE 0
-#define M_STATIC_KX_PLL_ANALOGTUNE 0x7ffU
-#define V_STATIC_KX_PLL_ANALOGTUNE(x) ((x) << S_STATIC_KX_PLL_ANALOGTUNE)
-#define G_STATIC_KX_PLL_ANALOGTUNE(x) (((x) >> S_STATIC_KX_PLL_ANALOGTUNE) & M_STATIC_KX_PLL_ANALOGTUNE)
-
-#define A_DBG_PVT_REG_DRVP 0x6110
-
-#define S_PVT_REG_DRVP_EN 8
-#define V_PVT_REG_DRVP_EN(x) ((x) << S_PVT_REG_DRVP_EN)
-#define F_PVT_REG_DRVP_EN V_PVT_REG_DRVP_EN(1U)
-
-#define S_PVT_REG_DRVP_B 4
-#define M_PVT_REG_DRVP_B 0xfU
-#define V_PVT_REG_DRVP_B(x) ((x) << S_PVT_REG_DRVP_B)
-#define G_PVT_REG_DRVP_B(x) (((x) >> S_PVT_REG_DRVP_B) & M_PVT_REG_DRVP_B)
-
-#define S_PVT_REG_DRVP_A 0
-#define M_PVT_REG_DRVP_A 0xfU
-#define V_PVT_REG_DRVP_A(x) ((x) << S_PVT_REG_DRVP_A)
-#define G_PVT_REG_DRVP_A(x) (((x) >> S_PVT_REG_DRVP_A) & M_PVT_REG_DRVP_A)
-
-#define A_DBG_T5_STATIC_C_DFS_CONF 0x6110
-
-#define S_STATIC_C_DFS_RANGEA 8
-#define M_STATIC_C_DFS_RANGEA 0x1fU
-#define V_STATIC_C_DFS_RANGEA(x) ((x) << S_STATIC_C_DFS_RANGEA)
-#define G_STATIC_C_DFS_RANGEA(x) (((x) >> S_STATIC_C_DFS_RANGEA) & M_STATIC_C_DFS_RANGEA)
-
-#define S_STATIC_C_DFS_RANGEB 3
-#define M_STATIC_C_DFS_RANGEB 0x1fU
-#define V_STATIC_C_DFS_RANGEB(x) ((x) << S_STATIC_C_DFS_RANGEB)
-#define G_STATIC_C_DFS_RANGEB(x) (((x) >> S_STATIC_C_DFS_RANGEB) & M_STATIC_C_DFS_RANGEB)
-
-#define S_STATIC_C_DFS_FFTUNE4 2
-#define V_STATIC_C_DFS_FFTUNE4(x) ((x) << S_STATIC_C_DFS_FFTUNE4)
-#define F_STATIC_C_DFS_FFTUNE4 V_STATIC_C_DFS_FFTUNE4(1U)
-
-#define S_STATIC_C_DFS_FFTUNE5 1
-#define V_STATIC_C_DFS_FFTUNE5(x) ((x) << S_STATIC_C_DFS_FFTUNE5)
-#define F_STATIC_C_DFS_FFTUNE5 V_STATIC_C_DFS_FFTUNE5(1U)
-
-#define S_STATIC_C_DFS_ENABLE 0
-#define V_STATIC_C_DFS_ENABLE(x) ((x) << S_STATIC_C_DFS_ENABLE)
-#define F_STATIC_C_DFS_ENABLE V_STATIC_C_DFS_ENABLE(1U)
-
-#define A_DBG_STATIC_C_DFS_CONF 0x6110
-#define A_DBG_PVT_REG_TERMN 0x6114
-
-#define S_PVT_REG_TERMN_EN 8
-#define V_PVT_REG_TERMN_EN(x) ((x) << S_PVT_REG_TERMN_EN)
-#define F_PVT_REG_TERMN_EN V_PVT_REG_TERMN_EN(1U)
-
-#define S_PVT_REG_TERMN_B 4
-#define M_PVT_REG_TERMN_B 0xfU
-#define V_PVT_REG_TERMN_B(x) ((x) << S_PVT_REG_TERMN_B)
-#define G_PVT_REG_TERMN_B(x) (((x) >> S_PVT_REG_TERMN_B) & M_PVT_REG_TERMN_B)
-
-#define S_PVT_REG_TERMN_A 0
-#define M_PVT_REG_TERMN_A 0xfU
-#define V_PVT_REG_TERMN_A(x) ((x) << S_PVT_REG_TERMN_A)
-#define G_PVT_REG_TERMN_A(x) (((x) >> S_PVT_REG_TERMN_A) & M_PVT_REG_TERMN_A)
-
-#define A_DBG_T5_STATIC_U_DFS_CONF 0x6114
-
-#define S_STATIC_U_DFS_RANGEA 8
-#define M_STATIC_U_DFS_RANGEA 0x1fU
-#define V_STATIC_U_DFS_RANGEA(x) ((x) << S_STATIC_U_DFS_RANGEA)
-#define G_STATIC_U_DFS_RANGEA(x) (((x) >> S_STATIC_U_DFS_RANGEA) & M_STATIC_U_DFS_RANGEA)
-
-#define S_STATIC_U_DFS_RANGEB 3
-#define M_STATIC_U_DFS_RANGEB 0x1fU
-#define V_STATIC_U_DFS_RANGEB(x) ((x) << S_STATIC_U_DFS_RANGEB)
-#define G_STATIC_U_DFS_RANGEB(x) (((x) >> S_STATIC_U_DFS_RANGEB) & M_STATIC_U_DFS_RANGEB)
-
-#define S_STATIC_U_DFS_FFTUNE4 2
-#define V_STATIC_U_DFS_FFTUNE4(x) ((x) << S_STATIC_U_DFS_FFTUNE4)
-#define F_STATIC_U_DFS_FFTUNE4 V_STATIC_U_DFS_FFTUNE4(1U)
-
-#define S_STATIC_U_DFS_FFTUNE5 1
-#define V_STATIC_U_DFS_FFTUNE5(x) ((x) << S_STATIC_U_DFS_FFTUNE5)
-#define F_STATIC_U_DFS_FFTUNE5 V_STATIC_U_DFS_FFTUNE5(1U)
-
-#define S_STATIC_U_DFS_ENABLE 0
-#define V_STATIC_U_DFS_ENABLE(x) ((x) << S_STATIC_U_DFS_ENABLE)
-#define F_STATIC_U_DFS_ENABLE V_STATIC_U_DFS_ENABLE(1U)
-
-#define A_DBG_STATIC_U_DFS_CONF 0x6114
-#define A_DBG_PVT_REG_TERMP 0x6118
-
-#define S_PVT_REG_TERMP_EN 8
-#define V_PVT_REG_TERMP_EN(x) ((x) << S_PVT_REG_TERMP_EN)
-#define F_PVT_REG_TERMP_EN V_PVT_REG_TERMP_EN(1U)
-
-#define S_PVT_REG_TERMP_B 4
-#define M_PVT_REG_TERMP_B 0xfU
-#define V_PVT_REG_TERMP_B(x) ((x) << S_PVT_REG_TERMP_B)
-#define G_PVT_REG_TERMP_B(x) (((x) >> S_PVT_REG_TERMP_B) & M_PVT_REG_TERMP_B)
-
-#define S_PVT_REG_TERMP_A 0
-#define M_PVT_REG_TERMP_A 0xfU
-#define V_PVT_REG_TERMP_A(x) ((x) << S_PVT_REG_TERMP_A)
-#define G_PVT_REG_TERMP_A(x) (((x) >> S_PVT_REG_TERMP_A) & M_PVT_REG_TERMP_A)
-
-#define A_DBG_GPIO_PE_EN 0x6118
-
-#define S_GPIO19_PE_EN 19
-#define V_GPIO19_PE_EN(x) ((x) << S_GPIO19_PE_EN)
-#define F_GPIO19_PE_EN V_GPIO19_PE_EN(1U)
-
-#define S_GPIO18_PE_EN 18
-#define V_GPIO18_PE_EN(x) ((x) << S_GPIO18_PE_EN)
-#define F_GPIO18_PE_EN V_GPIO18_PE_EN(1U)
-
-#define S_GPIO17_PE_EN 17
-#define V_GPIO17_PE_EN(x) ((x) << S_GPIO17_PE_EN)
-#define F_GPIO17_PE_EN V_GPIO17_PE_EN(1U)
-
-#define S_GPIO16_PE_EN 16
-#define V_GPIO16_PE_EN(x) ((x) << S_GPIO16_PE_EN)
-#define F_GPIO16_PE_EN V_GPIO16_PE_EN(1U)
-
-#define S_GPIO15_PE_EN 15
-#define V_GPIO15_PE_EN(x) ((x) << S_GPIO15_PE_EN)
-#define F_GPIO15_PE_EN V_GPIO15_PE_EN(1U)
-
-#define S_GPIO14_PE_EN 14
-#define V_GPIO14_PE_EN(x) ((x) << S_GPIO14_PE_EN)
-#define F_GPIO14_PE_EN V_GPIO14_PE_EN(1U)
-
-#define S_GPIO13_PE_EN 13
-#define V_GPIO13_PE_EN(x) ((x) << S_GPIO13_PE_EN)
-#define F_GPIO13_PE_EN V_GPIO13_PE_EN(1U)
-
-#define S_GPIO12_PE_EN 12
-#define V_GPIO12_PE_EN(x) ((x) << S_GPIO12_PE_EN)
-#define F_GPIO12_PE_EN V_GPIO12_PE_EN(1U)
-
-#define S_GPIO11_PE_EN 11
-#define V_GPIO11_PE_EN(x) ((x) << S_GPIO11_PE_EN)
-#define F_GPIO11_PE_EN V_GPIO11_PE_EN(1U)
-
-#define S_GPIO10_PE_EN 10
-#define V_GPIO10_PE_EN(x) ((x) << S_GPIO10_PE_EN)
-#define F_GPIO10_PE_EN V_GPIO10_PE_EN(1U)
-
-#define S_GPIO9_PE_EN 9
-#define V_GPIO9_PE_EN(x) ((x) << S_GPIO9_PE_EN)
-#define F_GPIO9_PE_EN V_GPIO9_PE_EN(1U)
-
-#define S_GPIO8_PE_EN 8
-#define V_GPIO8_PE_EN(x) ((x) << S_GPIO8_PE_EN)
-#define F_GPIO8_PE_EN V_GPIO8_PE_EN(1U)
-
-#define S_GPIO7_PE_EN 7
-#define V_GPIO7_PE_EN(x) ((x) << S_GPIO7_PE_EN)
-#define F_GPIO7_PE_EN V_GPIO7_PE_EN(1U)
-
-#define S_GPIO6_PE_EN 6
-#define V_GPIO6_PE_EN(x) ((x) << S_GPIO6_PE_EN)
-#define F_GPIO6_PE_EN V_GPIO6_PE_EN(1U)
-
-#define S_GPIO5_PE_EN 5
-#define V_GPIO5_PE_EN(x) ((x) << S_GPIO5_PE_EN)
-#define F_GPIO5_PE_EN V_GPIO5_PE_EN(1U)
-
-#define S_GPIO4_PE_EN 4
-#define V_GPIO4_PE_EN(x) ((x) << S_GPIO4_PE_EN)
-#define F_GPIO4_PE_EN V_GPIO4_PE_EN(1U)
-
-#define S_GPIO3_PE_EN 3
-#define V_GPIO3_PE_EN(x) ((x) << S_GPIO3_PE_EN)
-#define F_GPIO3_PE_EN V_GPIO3_PE_EN(1U)
-
-#define S_GPIO2_PE_EN 2
-#define V_GPIO2_PE_EN(x) ((x) << S_GPIO2_PE_EN)
-#define F_GPIO2_PE_EN V_GPIO2_PE_EN(1U)
-
-#define S_GPIO1_PE_EN 1
-#define V_GPIO1_PE_EN(x) ((x) << S_GPIO1_PE_EN)
-#define F_GPIO1_PE_EN V_GPIO1_PE_EN(1U)
-
-#define S_GPIO0_PE_EN 0
-#define V_GPIO0_PE_EN(x) ((x) << S_GPIO0_PE_EN)
-#define F_GPIO0_PE_EN V_GPIO0_PE_EN(1U)
-
-#define A_DBG_PVT_REG_THRESHOLD 0x611c
-
-#define S_PVT_CALIBRATION_DONE 8
-#define V_PVT_CALIBRATION_DONE(x) ((x) << S_PVT_CALIBRATION_DONE)
-#define F_PVT_CALIBRATION_DONE V_PVT_CALIBRATION_DONE(1U)
-
-#define S_THRESHOLD_TERMP_MAX_SYNC 7
-#define V_THRESHOLD_TERMP_MAX_SYNC(x) ((x) << S_THRESHOLD_TERMP_MAX_SYNC)
-#define F_THRESHOLD_TERMP_MAX_SYNC V_THRESHOLD_TERMP_MAX_SYNC(1U)
-
-#define S_THRESHOLD_TERMP_MIN_SYNC 6
-#define V_THRESHOLD_TERMP_MIN_SYNC(x) ((x) << S_THRESHOLD_TERMP_MIN_SYNC)
-#define F_THRESHOLD_TERMP_MIN_SYNC V_THRESHOLD_TERMP_MIN_SYNC(1U)
-
-#define S_THRESHOLD_TERMN_MAX_SYNC 5
-#define V_THRESHOLD_TERMN_MAX_SYNC(x) ((x) << S_THRESHOLD_TERMN_MAX_SYNC)
-#define F_THRESHOLD_TERMN_MAX_SYNC V_THRESHOLD_TERMN_MAX_SYNC(1U)
-
-#define S_THRESHOLD_TERMN_MIN_SYNC 4
-#define V_THRESHOLD_TERMN_MIN_SYNC(x) ((x) << S_THRESHOLD_TERMN_MIN_SYNC)
-#define F_THRESHOLD_TERMN_MIN_SYNC V_THRESHOLD_TERMN_MIN_SYNC(1U)
-
-#define S_THRESHOLD_DRVP_MAX_SYNC 3
-#define V_THRESHOLD_DRVP_MAX_SYNC(x) ((x) << S_THRESHOLD_DRVP_MAX_SYNC)
-#define F_THRESHOLD_DRVP_MAX_SYNC V_THRESHOLD_DRVP_MAX_SYNC(1U)
-
-#define S_THRESHOLD_DRVP_MIN_SYNC 2
-#define V_THRESHOLD_DRVP_MIN_SYNC(x) ((x) << S_THRESHOLD_DRVP_MIN_SYNC)
-#define F_THRESHOLD_DRVP_MIN_SYNC V_THRESHOLD_DRVP_MIN_SYNC(1U)
-
-#define S_THRESHOLD_DRVN_MAX_SYNC 1
-#define V_THRESHOLD_DRVN_MAX_SYNC(x) ((x) << S_THRESHOLD_DRVN_MAX_SYNC)
-#define F_THRESHOLD_DRVN_MAX_SYNC V_THRESHOLD_DRVN_MAX_SYNC(1U)
-
-#define S_THRESHOLD_DRVN_MIN_SYNC 0
-#define V_THRESHOLD_DRVN_MIN_SYNC(x) ((x) << S_THRESHOLD_DRVN_MIN_SYNC)
-#define F_THRESHOLD_DRVN_MIN_SYNC V_THRESHOLD_DRVN_MIN_SYNC(1U)
-
-#define A_DBG_GPIO_PS_EN 0x611c
-
-#define S_GPIO19_PS_EN 19
-#define V_GPIO19_PS_EN(x) ((x) << S_GPIO19_PS_EN)
-#define F_GPIO19_PS_EN V_GPIO19_PS_EN(1U)
-
-#define S_GPIO18_PS_EN 18
-#define V_GPIO18_PS_EN(x) ((x) << S_GPIO18_PS_EN)
-#define F_GPIO18_PS_EN V_GPIO18_PS_EN(1U)
-
-#define S_GPIO17_PS_EN 17
-#define V_GPIO17_PS_EN(x) ((x) << S_GPIO17_PS_EN)
-#define F_GPIO17_PS_EN V_GPIO17_PS_EN(1U)
-
-#define S_GPIO16_PS_EN 16
-#define V_GPIO16_PS_EN(x) ((x) << S_GPIO16_PS_EN)
-#define F_GPIO16_PS_EN V_GPIO16_PS_EN(1U)
-
-#define S_GPIO15_PS_EN 15
-#define V_GPIO15_PS_EN(x) ((x) << S_GPIO15_PS_EN)
-#define F_GPIO15_PS_EN V_GPIO15_PS_EN(1U)
-
-#define S_GPIO14_PS_EN 14
-#define V_GPIO14_PS_EN(x) ((x) << S_GPIO14_PS_EN)
-#define F_GPIO14_PS_EN V_GPIO14_PS_EN(1U)
-
-#define S_GPIO13_PS_EN 13
-#define V_GPIO13_PS_EN(x) ((x) << S_GPIO13_PS_EN)
-#define F_GPIO13_PS_EN V_GPIO13_PS_EN(1U)
-
-#define S_GPIO12_PS_EN 12
-#define V_GPIO12_PS_EN(x) ((x) << S_GPIO12_PS_EN)
-#define F_GPIO12_PS_EN V_GPIO12_PS_EN(1U)
-
-#define S_GPIO11_PS_EN 11
-#define V_GPIO11_PS_EN(x) ((x) << S_GPIO11_PS_EN)
-#define F_GPIO11_PS_EN V_GPIO11_PS_EN(1U)
-
-#define S_GPIO10_PS_EN 10
-#define V_GPIO10_PS_EN(x) ((x) << S_GPIO10_PS_EN)
-#define F_GPIO10_PS_EN V_GPIO10_PS_EN(1U)
-
-#define S_GPIO9_PS_EN 9
-#define V_GPIO9_PS_EN(x) ((x) << S_GPIO9_PS_EN)
-#define F_GPIO9_PS_EN V_GPIO9_PS_EN(1U)
-
-#define S_GPIO8_PS_EN 8
-#define V_GPIO8_PS_EN(x) ((x) << S_GPIO8_PS_EN)
-#define F_GPIO8_PS_EN V_GPIO8_PS_EN(1U)
-
-#define S_GPIO7_PS_EN 7
-#define V_GPIO7_PS_EN(x) ((x) << S_GPIO7_PS_EN)
-#define F_GPIO7_PS_EN V_GPIO7_PS_EN(1U)
-
-#define S_GPIO6_PS_EN 6
-#define V_GPIO6_PS_EN(x) ((x) << S_GPIO6_PS_EN)
-#define F_GPIO6_PS_EN V_GPIO6_PS_EN(1U)
-
-#define S_GPIO5_PS_EN 5
-#define V_GPIO5_PS_EN(x) ((x) << S_GPIO5_PS_EN)
-#define F_GPIO5_PS_EN V_GPIO5_PS_EN(1U)
-
-#define S_GPIO4_PS_EN 4
-#define V_GPIO4_PS_EN(x) ((x) << S_GPIO4_PS_EN)
-#define F_GPIO4_PS_EN V_GPIO4_PS_EN(1U)
-
-#define S_GPIO3_PS_EN 3
-#define V_GPIO3_PS_EN(x) ((x) << S_GPIO3_PS_EN)
-#define F_GPIO3_PS_EN V_GPIO3_PS_EN(1U)
-
-#define S_GPIO2_PS_EN 2
-#define V_GPIO2_PS_EN(x) ((x) << S_GPIO2_PS_EN)
-#define F_GPIO2_PS_EN V_GPIO2_PS_EN(1U)
-
-#define S_GPIO1_PS_EN 1
-#define V_GPIO1_PS_EN(x) ((x) << S_GPIO1_PS_EN)
-#define F_GPIO1_PS_EN V_GPIO1_PS_EN(1U)
-
-#define S_GPIO0_PS_EN 0
-#define V_GPIO0_PS_EN(x) ((x) << S_GPIO0_PS_EN)
-#define F_GPIO0_PS_EN V_GPIO0_PS_EN(1U)
-
-#define A_DBG_PVT_REG_IN_TERMP 0x6120
-
-#define S_REG_IN_TERMP_B 4
-#define M_REG_IN_TERMP_B 0xfU
-#define V_REG_IN_TERMP_B(x) ((x) << S_REG_IN_TERMP_B)
-#define G_REG_IN_TERMP_B(x) (((x) >> S_REG_IN_TERMP_B) & M_REG_IN_TERMP_B)
-
-#define S_REG_IN_TERMP_A 0
-#define M_REG_IN_TERMP_A 0xfU
-#define V_REG_IN_TERMP_A(x) ((x) << S_REG_IN_TERMP_A)
-#define G_REG_IN_TERMP_A(x) (((x) >> S_REG_IN_TERMP_A) & M_REG_IN_TERMP_A)
-
-#define A_DBG_EFUSE_BYTE16_19 0x6120
-#define A_DBG_PVT_REG_IN_TERMN 0x6124
-
-#define S_REG_IN_TERMN_B 4
-#define M_REG_IN_TERMN_B 0xfU
-#define V_REG_IN_TERMN_B(x) ((x) << S_REG_IN_TERMN_B)
-#define G_REG_IN_TERMN_B(x) (((x) >> S_REG_IN_TERMN_B) & M_REG_IN_TERMN_B)
-
-#define S_REG_IN_TERMN_A 0
-#define M_REG_IN_TERMN_A 0xfU
-#define V_REG_IN_TERMN_A(x) ((x) << S_REG_IN_TERMN_A)
-#define G_REG_IN_TERMN_A(x) (((x) >> S_REG_IN_TERMN_A) & M_REG_IN_TERMN_A)
-
-#define A_DBG_EFUSE_BYTE20_23 0x6124
-#define A_DBG_PVT_REG_IN_DRVP 0x6128
-
-#define S_REG_IN_DRVP_B 4
-#define M_REG_IN_DRVP_B 0xfU
-#define V_REG_IN_DRVP_B(x) ((x) << S_REG_IN_DRVP_B)
-#define G_REG_IN_DRVP_B(x) (((x) >> S_REG_IN_DRVP_B) & M_REG_IN_DRVP_B)
-
-#define S_REG_IN_DRVP_A 0
-#define M_REG_IN_DRVP_A 0xfU
-#define V_REG_IN_DRVP_A(x) ((x) << S_REG_IN_DRVP_A)
-#define G_REG_IN_DRVP_A(x) (((x) >> S_REG_IN_DRVP_A) & M_REG_IN_DRVP_A)
-
-#define A_DBG_EFUSE_BYTE24_27 0x6128
-#define A_DBG_PVT_REG_IN_DRVN 0x612c
-
-#define S_REG_IN_DRVN_B 4
-#define M_REG_IN_DRVN_B 0xfU
-#define V_REG_IN_DRVN_B(x) ((x) << S_REG_IN_DRVN_B)
-#define G_REG_IN_DRVN_B(x) (((x) >> S_REG_IN_DRVN_B) & M_REG_IN_DRVN_B)
-
-#define S_REG_IN_DRVN_A 0
-#define M_REG_IN_DRVN_A 0xfU
-#define V_REG_IN_DRVN_A(x) ((x) << S_REG_IN_DRVN_A)
-#define G_REG_IN_DRVN_A(x) (((x) >> S_REG_IN_DRVN_A) & M_REG_IN_DRVN_A)
-
-#define A_DBG_EFUSE_BYTE28_31 0x612c
-#define A_DBG_PVT_REG_OUT_TERMP 0x6130
-
-#define S_REG_OUT_TERMP_B 4
-#define M_REG_OUT_TERMP_B 0xfU
-#define V_REG_OUT_TERMP_B(x) ((x) << S_REG_OUT_TERMP_B)
-#define G_REG_OUT_TERMP_B(x) (((x) >> S_REG_OUT_TERMP_B) & M_REG_OUT_TERMP_B)
-
-#define S_REG_OUT_TERMP_A 0
-#define M_REG_OUT_TERMP_A 0xfU
-#define V_REG_OUT_TERMP_A(x) ((x) << S_REG_OUT_TERMP_A)
-#define G_REG_OUT_TERMP_A(x) (((x) >> S_REG_OUT_TERMP_A) & M_REG_OUT_TERMP_A)
-
-#define A_DBG_EFUSE_BYTE32_35 0x6130
-#define A_DBG_PVT_REG_OUT_TERMN 0x6134
-
-#define S_REG_OUT_TERMN_B 4
-#define M_REG_OUT_TERMN_B 0xfU
-#define V_REG_OUT_TERMN_B(x) ((x) << S_REG_OUT_TERMN_B)
-#define G_REG_OUT_TERMN_B(x) (((x) >> S_REG_OUT_TERMN_B) & M_REG_OUT_TERMN_B)
-
-#define S_REG_OUT_TERMN_A 0
-#define M_REG_OUT_TERMN_A 0xfU
-#define V_REG_OUT_TERMN_A(x) ((x) << S_REG_OUT_TERMN_A)
-#define G_REG_OUT_TERMN_A(x) (((x) >> S_REG_OUT_TERMN_A) & M_REG_OUT_TERMN_A)
-
-#define A_DBG_EFUSE_BYTE36_39 0x6134
-#define A_DBG_PVT_REG_OUT_DRVP 0x6138
-
-#define S_REG_OUT_DRVP_B 4
-#define M_REG_OUT_DRVP_B 0xfU
-#define V_REG_OUT_DRVP_B(x) ((x) << S_REG_OUT_DRVP_B)
-#define G_REG_OUT_DRVP_B(x) (((x) >> S_REG_OUT_DRVP_B) & M_REG_OUT_DRVP_B)
-
-#define S_REG_OUT_DRVP_A 0
-#define M_REG_OUT_DRVP_A 0xfU
-#define V_REG_OUT_DRVP_A(x) ((x) << S_REG_OUT_DRVP_A)
-#define G_REG_OUT_DRVP_A(x) (((x) >> S_REG_OUT_DRVP_A) & M_REG_OUT_DRVP_A)
-
-#define A_DBG_EFUSE_BYTE40_43 0x6138
-#define A_DBG_PVT_REG_OUT_DRVN 0x613c
-
-#define S_REG_OUT_DRVN_B 4
-#define M_REG_OUT_DRVN_B 0xfU
-#define V_REG_OUT_DRVN_B(x) ((x) << S_REG_OUT_DRVN_B)
-#define G_REG_OUT_DRVN_B(x) (((x) >> S_REG_OUT_DRVN_B) & M_REG_OUT_DRVN_B)
-
-#define S_REG_OUT_DRVN_A 0
-#define M_REG_OUT_DRVN_A 0xfU
-#define V_REG_OUT_DRVN_A(x) ((x) << S_REG_OUT_DRVN_A)
-#define G_REG_OUT_DRVN_A(x) (((x) >> S_REG_OUT_DRVN_A) & M_REG_OUT_DRVN_A)
-
-#define A_DBG_EFUSE_BYTE44_47 0x613c
-#define A_DBG_PVT_REG_HISTORY_TERMP 0x6140
-
-#define S_TERMP_B_HISTORY 4
-#define M_TERMP_B_HISTORY 0xfU
-#define V_TERMP_B_HISTORY(x) ((x) << S_TERMP_B_HISTORY)
-#define G_TERMP_B_HISTORY(x) (((x) >> S_TERMP_B_HISTORY) & M_TERMP_B_HISTORY)
-
-#define S_TERMP_A_HISTORY 0
-#define M_TERMP_A_HISTORY 0xfU
-#define V_TERMP_A_HISTORY(x) ((x) << S_TERMP_A_HISTORY)
-#define G_TERMP_A_HISTORY(x) (((x) >> S_TERMP_A_HISTORY) & M_TERMP_A_HISTORY)
-
-#define A_DBG_EFUSE_BYTE48_51 0x6140
-#define A_DBG_PVT_REG_HISTORY_TERMN 0x6144
-
-#define S_TERMN_B_HISTORY 4
-#define M_TERMN_B_HISTORY 0xfU
-#define V_TERMN_B_HISTORY(x) ((x) << S_TERMN_B_HISTORY)
-#define G_TERMN_B_HISTORY(x) (((x) >> S_TERMN_B_HISTORY) & M_TERMN_B_HISTORY)
-
-#define S_TERMN_A_HISTORY 0
-#define M_TERMN_A_HISTORY 0xfU
-#define V_TERMN_A_HISTORY(x) ((x) << S_TERMN_A_HISTORY)
-#define G_TERMN_A_HISTORY(x) (((x) >> S_TERMN_A_HISTORY) & M_TERMN_A_HISTORY)
-
-#define A_DBG_EFUSE_BYTE52_55 0x6144
-#define A_DBG_PVT_REG_HISTORY_DRVP 0x6148
-
-#define S_DRVP_B_HISTORY 4
-#define M_DRVP_B_HISTORY 0xfU
-#define V_DRVP_B_HISTORY(x) ((x) << S_DRVP_B_HISTORY)
-#define G_DRVP_B_HISTORY(x) (((x) >> S_DRVP_B_HISTORY) & M_DRVP_B_HISTORY)
-
-#define S_DRVP_A_HISTORY 0
-#define M_DRVP_A_HISTORY 0xfU
-#define V_DRVP_A_HISTORY(x) ((x) << S_DRVP_A_HISTORY)
-#define G_DRVP_A_HISTORY(x) (((x) >> S_DRVP_A_HISTORY) & M_DRVP_A_HISTORY)
-
-#define A_DBG_EFUSE_BYTE56_59 0x6148
-#define A_DBG_PVT_REG_HISTORY_DRVN 0x614c
-
-#define S_DRVN_B_HISTORY 4
-#define M_DRVN_B_HISTORY 0xfU
-#define V_DRVN_B_HISTORY(x) ((x) << S_DRVN_B_HISTORY)
-#define G_DRVN_B_HISTORY(x) (((x) >> S_DRVN_B_HISTORY) & M_DRVN_B_HISTORY)
-
-#define S_DRVN_A_HISTORY 0
-#define M_DRVN_A_HISTORY 0xfU
-#define V_DRVN_A_HISTORY(x) ((x) << S_DRVN_A_HISTORY)
-#define G_DRVN_A_HISTORY(x) (((x) >> S_DRVN_A_HISTORY) & M_DRVN_A_HISTORY)
-
-#define A_DBG_EFUSE_BYTE60_63 0x614c
-#define A_DBG_PVT_REG_SAMPLE_WAIT_CLKS 0x6150
-
-#define S_SAMPLE_WAIT_CLKS 0
-#define M_SAMPLE_WAIT_CLKS 0x1fU
-#define V_SAMPLE_WAIT_CLKS(x) ((x) << S_SAMPLE_WAIT_CLKS)
-#define G_SAMPLE_WAIT_CLKS(x) (((x) >> S_SAMPLE_WAIT_CLKS) & M_SAMPLE_WAIT_CLKS)
-
-#define A_DBG_STATIC_U_PLL_CONF6 0x6150
-
-#define S_STATIC_U_PLL_VREGTUNE 0
-#define M_STATIC_U_PLL_VREGTUNE 0x7ffffU
-#define V_STATIC_U_PLL_VREGTUNE(x) ((x) << S_STATIC_U_PLL_VREGTUNE)
-#define G_STATIC_U_PLL_VREGTUNE(x) (((x) >> S_STATIC_U_PLL_VREGTUNE) & M_STATIC_U_PLL_VREGTUNE)
-
-#define A_DBG_STATIC_C_PLL_CONF6 0x6154
-
-#define S_STATIC_C_PLL_VREGTUNE 0
-#define M_STATIC_C_PLL_VREGTUNE 0x7ffffU
-#define V_STATIC_C_PLL_VREGTUNE(x) ((x) << S_STATIC_C_PLL_VREGTUNE)
-#define G_STATIC_C_PLL_VREGTUNE(x) (((x) >> S_STATIC_C_PLL_VREGTUNE) & M_STATIC_C_PLL_VREGTUNE)
-
-#define A_DBG_CUST_EFUSE_PROGRAM 0x6158
-
-#define S_EFUSE_PROG_PERIOD 16
-#define M_EFUSE_PROG_PERIOD 0xffffU
-#define V_EFUSE_PROG_PERIOD(x) ((x) << S_EFUSE_PROG_PERIOD)
-#define G_EFUSE_PROG_PERIOD(x) (((x) >> S_EFUSE_PROG_PERIOD) & M_EFUSE_PROG_PERIOD)
-
-#define S_EFUSE_OPER_TYP 14
-#define M_EFUSE_OPER_TYP 0x3U
-#define V_EFUSE_OPER_TYP(x) ((x) << S_EFUSE_OPER_TYP)
-#define G_EFUSE_OPER_TYP(x) (((x) >> S_EFUSE_OPER_TYP) & M_EFUSE_OPER_TYP)
-
-#define S_EFUSE_ADDR 8
-#define M_EFUSE_ADDR 0x3fU
-#define V_EFUSE_ADDR(x) ((x) << S_EFUSE_ADDR)
-#define G_EFUSE_ADDR(x) (((x) >> S_EFUSE_ADDR) & M_EFUSE_ADDR)
-
-#define S_EFUSE_DIN 0
-#define M_EFUSE_DIN 0xffU
-#define V_EFUSE_DIN(x) ((x) << S_EFUSE_DIN)
-#define G_EFUSE_DIN(x) (((x) >> S_EFUSE_DIN) & M_EFUSE_DIN)
-
-#define A_DBG_CUST_EFUSE_OUT 0x615c
-
-#define S_EFUSE_OPER_DONE 8
-#define V_EFUSE_OPER_DONE(x) ((x) << S_EFUSE_OPER_DONE)
-#define F_EFUSE_OPER_DONE V_EFUSE_OPER_DONE(1U)
-
-#define S_EFUSE_DOUT 0
-#define M_EFUSE_DOUT 0xffU
-#define V_EFUSE_DOUT(x) ((x) << S_EFUSE_DOUT)
-#define G_EFUSE_DOUT(x) (((x) >> S_EFUSE_DOUT) & M_EFUSE_DOUT)
-
-#define A_DBG_CUST_EFUSE_BYTE0_3 0x6160
-#define A_DBG_CUST_EFUSE_BYTE4_7 0x6164
-#define A_DBG_CUST_EFUSE_BYTE8_11 0x6168
-#define A_DBG_CUST_EFUSE_BYTE12_15 0x616c
-#define A_DBG_CUST_EFUSE_BYTE16_19 0x6170
-#define A_DBG_CUST_EFUSE_BYTE20_23 0x6174
-#define A_DBG_CUST_EFUSE_BYTE24_27 0x6178
-#define A_DBG_CUST_EFUSE_BYTE28_31 0x617c
-#define A_DBG_CUST_EFUSE_BYTE32_35 0x6180
-#define A_DBG_CUST_EFUSE_BYTE36_39 0x6184
-#define A_DBG_CUST_EFUSE_BYTE40_43 0x6188
-#define A_DBG_CUST_EFUSE_BYTE44_47 0x618c
-#define A_DBG_CUST_EFUSE_BYTE48_51 0x6190
-#define A_DBG_CUST_EFUSE_BYTE52_55 0x6194
-#define A_DBG_CUST_EFUSE_BYTE56_59 0x6198
-#define A_DBG_CUST_EFUSE_BYTE60_63 0x619c
-
-/* registers for module MC */
-#define MC_BASE_ADDR 0x6200
-
-#define A_MC_PCTL_SCFG 0x6200
-
-#define S_RKINF_EN 5
-#define V_RKINF_EN(x) ((x) << S_RKINF_EN)
-#define F_RKINF_EN V_RKINF_EN(1U)
-
-#define S_DUAL_PCTL_EN 4
-#define V_DUAL_PCTL_EN(x) ((x) << S_DUAL_PCTL_EN)
-#define F_DUAL_PCTL_EN V_DUAL_PCTL_EN(1U)
-
-#define S_SLAVE_MODE 3
-#define V_SLAVE_MODE(x) ((x) << S_SLAVE_MODE)
-#define F_SLAVE_MODE V_SLAVE_MODE(1U)
-
-#define S_LOOPBACK_EN 1
-#define V_LOOPBACK_EN(x) ((x) << S_LOOPBACK_EN)
-#define F_LOOPBACK_EN V_LOOPBACK_EN(1U)
-
-#define S_HW_LOW_POWER_EN 0
-#define V_HW_LOW_POWER_EN(x) ((x) << S_HW_LOW_POWER_EN)
-#define F_HW_LOW_POWER_EN V_HW_LOW_POWER_EN(1U)
-
-#define A_MC_PCTL_SCTL 0x6204
-
-#define S_STATE_CMD 0
-#define M_STATE_CMD 0x7U
-#define V_STATE_CMD(x) ((x) << S_STATE_CMD)
-#define G_STATE_CMD(x) (((x) >> S_STATE_CMD) & M_STATE_CMD)
-
-#define A_MC_PCTL_STAT 0x6208
-
-#define S_CTL_STAT 0
-#define M_CTL_STAT 0x7U
-#define V_CTL_STAT(x) ((x) << S_CTL_STAT)
-#define G_CTL_STAT(x) (((x) >> S_CTL_STAT) & M_CTL_STAT)
-
-#define A_MC_PCTL_MCMD 0x6240
-
-#define S_START_CMD 31
-#define V_START_CMD(x) ((x) << S_START_CMD)
-#define F_START_CMD V_START_CMD(1U)
-
-#define S_CMD_ADD_DEL 24
-#define M_CMD_ADD_DEL 0xfU
-#define V_CMD_ADD_DEL(x) ((x) << S_CMD_ADD_DEL)
-#define G_CMD_ADD_DEL(x) (((x) >> S_CMD_ADD_DEL) & M_CMD_ADD_DEL)
-
-#define S_RANK_SEL 20
-#define M_RANK_SEL 0xfU
-#define V_RANK_SEL(x) ((x) << S_RANK_SEL)
-#define G_RANK_SEL(x) (((x) >> S_RANK_SEL) & M_RANK_SEL)
-
-#define S_BANK_ADDR 17
-#define M_BANK_ADDR 0x7U
-#define V_BANK_ADDR(x) ((x) << S_BANK_ADDR)
-#define G_BANK_ADDR(x) (((x) >> S_BANK_ADDR) & M_BANK_ADDR)
-
-#define S_CMD_ADDR 4
-#define M_CMD_ADDR 0x1fffU
-#define V_CMD_ADDR(x) ((x) << S_CMD_ADDR)
-#define G_CMD_ADDR(x) (((x) >> S_CMD_ADDR) & M_CMD_ADDR)
-
-#define S_CMD_OPCODE 0
-#define M_CMD_OPCODE 0x7U
-#define V_CMD_OPCODE(x) ((x) << S_CMD_OPCODE)
-#define G_CMD_OPCODE(x) (((x) >> S_CMD_OPCODE) & M_CMD_OPCODE)
-
-#define A_MC_PCTL_POWCTL 0x6244
-
-#define S_POWER_UP_START 0
-#define V_POWER_UP_START(x) ((x) << S_POWER_UP_START)
-#define F_POWER_UP_START V_POWER_UP_START(1U)
-
-#define A_MC_PCTL_POWSTAT 0x6248
-
-#define S_PHY_CALIBDONE 1
-#define V_PHY_CALIBDONE(x) ((x) << S_PHY_CALIBDONE)
-#define F_PHY_CALIBDONE V_PHY_CALIBDONE(1U)
-
-#define S_POWER_UP_DONE 0
-#define V_POWER_UP_DONE(x) ((x) << S_POWER_UP_DONE)
-#define F_POWER_UP_DONE V_POWER_UP_DONE(1U)
-
-#define A_MC_PCTL_MCFG 0x6280
-
-#define S_TFAW_CFG 18
-#define M_TFAW_CFG 0x3U
-#define V_TFAW_CFG(x) ((x) << S_TFAW_CFG)
-#define G_TFAW_CFG(x) (((x) >> S_TFAW_CFG) & M_TFAW_CFG)
-
-#define S_PD_EXIT_MODE 17
-#define V_PD_EXIT_MODE(x) ((x) << S_PD_EXIT_MODE)
-#define F_PD_EXIT_MODE V_PD_EXIT_MODE(1U)
-
-#define S_PD_TYPE 16
-#define V_PD_TYPE(x) ((x) << S_PD_TYPE)
-#define F_PD_TYPE V_PD_TYPE(1U)
-
-#define S_PD_IDLE 8
-#define M_PD_IDLE 0xffU
-#define V_PD_IDLE(x) ((x) << S_PD_IDLE)
-#define G_PD_IDLE(x) (((x) >> S_PD_IDLE) & M_PD_IDLE)
-
-#define S_PAGE_POLICY 6
-#define M_PAGE_POLICY 0x3U
-#define V_PAGE_POLICY(x) ((x) << S_PAGE_POLICY)
-#define G_PAGE_POLICY(x) (((x) >> S_PAGE_POLICY) & M_PAGE_POLICY)
-
-#define S_DDR3_EN 5
-#define V_DDR3_EN(x) ((x) << S_DDR3_EN)
-#define F_DDR3_EN V_DDR3_EN(1U)
-
-#define S_TWO_T_EN 3
-#define V_TWO_T_EN(x) ((x) << S_TWO_T_EN)
-#define F_TWO_T_EN V_TWO_T_EN(1U)
-
-#define S_BL8INT_EN 2
-#define V_BL8INT_EN(x) ((x) << S_BL8INT_EN)
-#define F_BL8INT_EN V_BL8INT_EN(1U)
-
-#define S_MEM_BL 0
-#define V_MEM_BL(x) ((x) << S_MEM_BL)
-#define F_MEM_BL V_MEM_BL(1U)
-
-#define A_MC_PCTL_PPCFG 0x6284
-
-#define S_RPMEM_DIS 1
-#define M_RPMEM_DIS 0xffU
-#define V_RPMEM_DIS(x) ((x) << S_RPMEM_DIS)
-#define G_RPMEM_DIS(x) (((x) >> S_RPMEM_DIS) & M_RPMEM_DIS)
-
-#define S_PPMEM_EN 0
-#define V_PPMEM_EN(x) ((x) << S_PPMEM_EN)
-#define F_PPMEM_EN V_PPMEM_EN(1U)
-
-#define A_MC_PCTL_MSTAT 0x6288
-
-#define S_POWER_DOWN 0
-#define V_POWER_DOWN(x) ((x) << S_POWER_DOWN)
-#define F_POWER_DOWN V_POWER_DOWN(1U)
-
-#define A_MC_PCTL_ODTCFG 0x628c
-
-#define S_RANK3_ODT_DEFAULT 28
-#define V_RANK3_ODT_DEFAULT(x) ((x) << S_RANK3_ODT_DEFAULT)
-#define F_RANK3_ODT_DEFAULT V_RANK3_ODT_DEFAULT(1U)
-
-#define S_RANK3_ODT_WRITE_SEL 27
-#define V_RANK3_ODT_WRITE_SEL(x) ((x) << S_RANK3_ODT_WRITE_SEL)
-#define F_RANK3_ODT_WRITE_SEL V_RANK3_ODT_WRITE_SEL(1U)
-
-#define S_RANK3_ODT_WRITE_NSE 26
-#define V_RANK3_ODT_WRITE_NSE(x) ((x) << S_RANK3_ODT_WRITE_NSE)
-#define F_RANK3_ODT_WRITE_NSE V_RANK3_ODT_WRITE_NSE(1U)
-
-#define S_RANK3_ODT_READ_SEL 25
-#define V_RANK3_ODT_READ_SEL(x) ((x) << S_RANK3_ODT_READ_SEL)
-#define F_RANK3_ODT_READ_SEL V_RANK3_ODT_READ_SEL(1U)
-
-#define S_RANK3_ODT_READ_NSEL 24
-#define V_RANK3_ODT_READ_NSEL(x) ((x) << S_RANK3_ODT_READ_NSEL)
-#define F_RANK3_ODT_READ_NSEL V_RANK3_ODT_READ_NSEL(1U)
-
-#define S_RANK2_ODT_DEFAULT 20
-#define V_RANK2_ODT_DEFAULT(x) ((x) << S_RANK2_ODT_DEFAULT)
-#define F_RANK2_ODT_DEFAULT V_RANK2_ODT_DEFAULT(1U)
-
-#define S_RANK2_ODT_WRITE_SEL 19
-#define V_RANK2_ODT_WRITE_SEL(x) ((x) << S_RANK2_ODT_WRITE_SEL)
-#define F_RANK2_ODT_WRITE_SEL V_RANK2_ODT_WRITE_SEL(1U)
-
-#define S_RANK2_ODT_WRITE_NSEL 18
-#define V_RANK2_ODT_WRITE_NSEL(x) ((x) << S_RANK2_ODT_WRITE_NSEL)
-#define F_RANK2_ODT_WRITE_NSEL V_RANK2_ODT_WRITE_NSEL(1U)
-
-#define S_RANK2_ODT_READ_SEL 17
-#define V_RANK2_ODT_READ_SEL(x) ((x) << S_RANK2_ODT_READ_SEL)
-#define F_RANK2_ODT_READ_SEL V_RANK2_ODT_READ_SEL(1U)
-
-#define S_RANK2_ODT_READ_NSEL 16
-#define V_RANK2_ODT_READ_NSEL(x) ((x) << S_RANK2_ODT_READ_NSEL)
-#define F_RANK2_ODT_READ_NSEL V_RANK2_ODT_READ_NSEL(1U)
-
-#define S_RANK1_ODT_DEFAULT 12
-#define V_RANK1_ODT_DEFAULT(x) ((x) << S_RANK1_ODT_DEFAULT)
-#define F_RANK1_ODT_DEFAULT V_RANK1_ODT_DEFAULT(1U)
-
-#define S_RANK1_ODT_WRITE_SEL 11
-#define V_RANK1_ODT_WRITE_SEL(x) ((x) << S_RANK1_ODT_WRITE_SEL)
-#define F_RANK1_ODT_WRITE_SEL V_RANK1_ODT_WRITE_SEL(1U)
-
-#define S_RANK1_ODT_WRITE_NSEL 10
-#define V_RANK1_ODT_WRITE_NSEL(x) ((x) << S_RANK1_ODT_WRITE_NSEL)
-#define F_RANK1_ODT_WRITE_NSEL V_RANK1_ODT_WRITE_NSEL(1U)
-
-#define S_RANK1_ODT_READ_SEL 9
-#define V_RANK1_ODT_READ_SEL(x) ((x) << S_RANK1_ODT_READ_SEL)
-#define F_RANK1_ODT_READ_SEL V_RANK1_ODT_READ_SEL(1U)
-
-#define S_RANK1_ODT_READ_NSEL 8
-#define V_RANK1_ODT_READ_NSEL(x) ((x) << S_RANK1_ODT_READ_NSEL)
-#define F_RANK1_ODT_READ_NSEL V_RANK1_ODT_READ_NSEL(1U)
-
-#define S_RANK0_ODT_DEFAULT 4
-#define V_RANK0_ODT_DEFAULT(x) ((x) << S_RANK0_ODT_DEFAULT)
-#define F_RANK0_ODT_DEFAULT V_RANK0_ODT_DEFAULT(1U)
-
-#define S_RANK0_ODT_WRITE_SEL 3
-#define V_RANK0_ODT_WRITE_SEL(x) ((x) << S_RANK0_ODT_WRITE_SEL)
-#define F_RANK0_ODT_WRITE_SEL V_RANK0_ODT_WRITE_SEL(1U)
-
-#define S_RANK0_ODT_WRITE_NSEL 2
-#define V_RANK0_ODT_WRITE_NSEL(x) ((x) << S_RANK0_ODT_WRITE_NSEL)
-#define F_RANK0_ODT_WRITE_NSEL V_RANK0_ODT_WRITE_NSEL(1U)
-
-#define S_RANK0_ODT_READ_SEL 1
-#define V_RANK0_ODT_READ_SEL(x) ((x) << S_RANK0_ODT_READ_SEL)
-#define F_RANK0_ODT_READ_SEL V_RANK0_ODT_READ_SEL(1U)
-
-#define S_RANK0_ODT_READ_NSEL 0
-#define V_RANK0_ODT_READ_NSEL(x) ((x) << S_RANK0_ODT_READ_NSEL)
-#define F_RANK0_ODT_READ_NSEL V_RANK0_ODT_READ_NSEL(1U)
-
-#define A_MC_PCTL_DQSECFG 0x6290
-
-#define S_DV_ALAT 20
-#define M_DV_ALAT 0xfU
-#define V_DV_ALAT(x) ((x) << S_DV_ALAT)
-#define G_DV_ALAT(x) (((x) >> S_DV_ALAT) & M_DV_ALAT)
-
-#define S_DV_ALEN 16
-#define M_DV_ALEN 0x3U
-#define V_DV_ALEN(x) ((x) << S_DV_ALEN)
-#define G_DV_ALEN(x) (((x) >> S_DV_ALEN) & M_DV_ALEN)
-
-#define S_DSE_ALAT 12
-#define M_DSE_ALAT 0xfU
-#define V_DSE_ALAT(x) ((x) << S_DSE_ALAT)
-#define G_DSE_ALAT(x) (((x) >> S_DSE_ALAT) & M_DSE_ALAT)
-
-#define S_DSE_ALEN 8
-#define M_DSE_ALEN 0x3U
-#define V_DSE_ALEN(x) ((x) << S_DSE_ALEN)
-#define G_DSE_ALEN(x) (((x) >> S_DSE_ALEN) & M_DSE_ALEN)
-
-#define S_QSE_ALAT 4
-#define M_QSE_ALAT 0xfU
-#define V_QSE_ALAT(x) ((x) << S_QSE_ALAT)
-#define G_QSE_ALAT(x) (((x) >> S_QSE_ALAT) & M_QSE_ALAT)
-
-#define S_QSE_ALEN 0
-#define M_QSE_ALEN 0x3U
-#define V_QSE_ALEN(x) ((x) << S_QSE_ALEN)
-#define G_QSE_ALEN(x) (((x) >> S_QSE_ALEN) & M_QSE_ALEN)
-
-#define A_MC_PCTL_DTUPDES 0x6294
-
-#define S_DTU_RD_MISSING 13
-#define V_DTU_RD_MISSING(x) ((x) << S_DTU_RD_MISSING)
-#define F_DTU_RD_MISSING V_DTU_RD_MISSING(1U)
-
-#define S_DTU_EAFFL 9
-#define M_DTU_EAFFL 0xfU
-#define V_DTU_EAFFL(x) ((x) << S_DTU_EAFFL)
-#define G_DTU_EAFFL(x) (((x) >> S_DTU_EAFFL) & M_DTU_EAFFL)
-
-#define S_DTU_RANDOM_ERROR 8
-#define V_DTU_RANDOM_ERROR(x) ((x) << S_DTU_RANDOM_ERROR)
-#define F_DTU_RANDOM_ERROR V_DTU_RANDOM_ERROR(1U)
-
-#define S_DTU_ERROR_B7 7
-#define V_DTU_ERROR_B7(x) ((x) << S_DTU_ERROR_B7)
-#define F_DTU_ERROR_B7 V_DTU_ERROR_B7(1U)
-
-#define S_DTU_ERR_B6 6
-#define V_DTU_ERR_B6(x) ((x) << S_DTU_ERR_B6)
-#define F_DTU_ERR_B6 V_DTU_ERR_B6(1U)
-
-#define S_DTU_ERR_B5 5
-#define V_DTU_ERR_B5(x) ((x) << S_DTU_ERR_B5)
-#define F_DTU_ERR_B5 V_DTU_ERR_B5(1U)
-
-#define S_DTU_ERR_B4 4
-#define V_DTU_ERR_B4(x) ((x) << S_DTU_ERR_B4)
-#define F_DTU_ERR_B4 V_DTU_ERR_B4(1U)
-
-#define S_DTU_ERR_B3 3
-#define V_DTU_ERR_B3(x) ((x) << S_DTU_ERR_B3)
-#define F_DTU_ERR_B3 V_DTU_ERR_B3(1U)
-
-#define S_DTU_ERR_B2 2
-#define V_DTU_ERR_B2(x) ((x) << S_DTU_ERR_B2)
-#define F_DTU_ERR_B2 V_DTU_ERR_B2(1U)
-
-#define S_DTU_ERR_B1 1
-#define V_DTU_ERR_B1(x) ((x) << S_DTU_ERR_B1)
-#define F_DTU_ERR_B1 V_DTU_ERR_B1(1U)
-
-#define S_DTU_ERR_B0 0
-#define V_DTU_ERR_B0(x) ((x) << S_DTU_ERR_B0)
-#define F_DTU_ERR_B0 V_DTU_ERR_B0(1U)
-
-#define A_MC_PCTL_DTUNA 0x6298
-#define A_MC_PCTL_DTUNE 0x629c
-#define A_MC_PCTL_DTUPRDO 0x62a0
-
-#define S_DTU_ALLBITS_1 16
-#define M_DTU_ALLBITS_1 0xffffU
-#define V_DTU_ALLBITS_1(x) ((x) << S_DTU_ALLBITS_1)
-#define G_DTU_ALLBITS_1(x) (((x) >> S_DTU_ALLBITS_1) & M_DTU_ALLBITS_1)
-
-#define S_DTU_ALLBITS_0 0
-#define M_DTU_ALLBITS_0 0xffffU
-#define V_DTU_ALLBITS_0(x) ((x) << S_DTU_ALLBITS_0)
-#define G_DTU_ALLBITS_0(x) (((x) >> S_DTU_ALLBITS_0) & M_DTU_ALLBITS_0)
-
-#define A_MC_PCTL_DTUPRD1 0x62a4
-
-#define S_DTU_ALLBITS_3 16
-#define M_DTU_ALLBITS_3 0xffffU
-#define V_DTU_ALLBITS_3(x) ((x) << S_DTU_ALLBITS_3)
-#define G_DTU_ALLBITS_3(x) (((x) >> S_DTU_ALLBITS_3) & M_DTU_ALLBITS_3)
-
-#define S_DTU_ALLBITS_2 0
-#define M_DTU_ALLBITS_2 0xffffU
-#define V_DTU_ALLBITS_2(x) ((x) << S_DTU_ALLBITS_2)
-#define G_DTU_ALLBITS_2(x) (((x) >> S_DTU_ALLBITS_2) & M_DTU_ALLBITS_2)
-
-#define A_MC_PCTL_DTUPRD2 0x62a8
-
-#define S_DTU_ALLBITS_5 16
-#define M_DTU_ALLBITS_5 0xffffU
-#define V_DTU_ALLBITS_5(x) ((x) << S_DTU_ALLBITS_5)
-#define G_DTU_ALLBITS_5(x) (((x) >> S_DTU_ALLBITS_5) & M_DTU_ALLBITS_5)
-
-#define S_DTU_ALLBITS_4 0
-#define M_DTU_ALLBITS_4 0xffffU
-#define V_DTU_ALLBITS_4(x) ((x) << S_DTU_ALLBITS_4)
-#define G_DTU_ALLBITS_4(x) (((x) >> S_DTU_ALLBITS_4) & M_DTU_ALLBITS_4)
-
-#define A_MC_PCTL_DTUPRD3 0x62ac
-
-#define S_DTU_ALLBITS_7 16
-#define M_DTU_ALLBITS_7 0xffffU
-#define V_DTU_ALLBITS_7(x) ((x) << S_DTU_ALLBITS_7)
-#define G_DTU_ALLBITS_7(x) (((x) >> S_DTU_ALLBITS_7) & M_DTU_ALLBITS_7)
-
-#define S_DTU_ALLBITS_6 0
-#define M_DTU_ALLBITS_6 0xffffU
-#define V_DTU_ALLBITS_6(x) ((x) << S_DTU_ALLBITS_6)
-#define G_DTU_ALLBITS_6(x) (((x) >> S_DTU_ALLBITS_6) & M_DTU_ALLBITS_6)
-
-#define A_MC_PCTL_DTUAWDT 0x62b0
-
-#define S_NUMBER_RANKS 9
-#define M_NUMBER_RANKS 0x3U
-#define V_NUMBER_RANKS(x) ((x) << S_NUMBER_RANKS)
-#define G_NUMBER_RANKS(x) (((x) >> S_NUMBER_RANKS) & M_NUMBER_RANKS)
-
-#define S_ROW_ADDR_WIDTH 6
-#define M_ROW_ADDR_WIDTH 0x3U
-#define V_ROW_ADDR_WIDTH(x) ((x) << S_ROW_ADDR_WIDTH)
-#define G_ROW_ADDR_WIDTH(x) (((x) >> S_ROW_ADDR_WIDTH) & M_ROW_ADDR_WIDTH)
-
-#define S_BANK_ADDR_WIDTH 3
-#define M_BANK_ADDR_WIDTH 0x3U
-#define V_BANK_ADDR_WIDTH(x) ((x) << S_BANK_ADDR_WIDTH)
-#define G_BANK_ADDR_WIDTH(x) (((x) >> S_BANK_ADDR_WIDTH) & M_BANK_ADDR_WIDTH)
-
-#define S_COLUMN_ADDR_WIDTH 0
-#define M_COLUMN_ADDR_WIDTH 0x3U
-#define V_COLUMN_ADDR_WIDTH(x) ((x) << S_COLUMN_ADDR_WIDTH)
-#define G_COLUMN_ADDR_WIDTH(x) (((x) >> S_COLUMN_ADDR_WIDTH) & M_COLUMN_ADDR_WIDTH)
-
-#define A_MC_PCTL_TOGCNT1U 0x62c0
-
-#define S_TOGGLE_COUNTER_1U 0
-#define M_TOGGLE_COUNTER_1U 0x3ffU
-#define V_TOGGLE_COUNTER_1U(x) ((x) << S_TOGGLE_COUNTER_1U)
-#define G_TOGGLE_COUNTER_1U(x) (((x) >> S_TOGGLE_COUNTER_1U) & M_TOGGLE_COUNTER_1U)
-
-#define A_MC_PCTL_TINIT 0x62c4
-
-#define S_T_INIT 0
-#define M_T_INIT 0x1ffU
-#define V_T_INIT(x) ((x) << S_T_INIT)
-#define G_T_INIT(x) (((x) >> S_T_INIT) & M_T_INIT)
-
-#define A_MC_PCTL_TRSTH 0x62c8
-
-#define S_T_RSTH 0
-#define M_T_RSTH 0x3ffU
-#define V_T_RSTH(x) ((x) << S_T_RSTH)
-#define G_T_RSTH(x) (((x) >> S_T_RSTH) & M_T_RSTH)
-
-#define A_MC_PCTL_TOGCNT100N 0x62cc
-
-#define S_TOGGLE_COUNTER_100N 0
-#define M_TOGGLE_COUNTER_100N 0x7fU
-#define V_TOGGLE_COUNTER_100N(x) ((x) << S_TOGGLE_COUNTER_100N)
-#define G_TOGGLE_COUNTER_100N(x) (((x) >> S_TOGGLE_COUNTER_100N) & M_TOGGLE_COUNTER_100N)
-
-#define A_MC_PCTL_TREFI 0x62d0
-
-#define S_T_REFI 0
-#define M_T_REFI 0xffU
-#define V_T_REFI(x) ((x) << S_T_REFI)
-#define G_T_REFI(x) (((x) >> S_T_REFI) & M_T_REFI)
-
-#define A_MC_PCTL_TMRD 0x62d4
-
-#define S_T_MRD 0
-#define M_T_MRD 0x7U
-#define V_T_MRD(x) ((x) << S_T_MRD)
-#define G_T_MRD(x) (((x) >> S_T_MRD) & M_T_MRD)
-
-#define A_MC_PCTL_TRFC 0x62d8
-
-#define S_T_RFC 0
-#define M_T_RFC 0xffU
-#define V_T_RFC(x) ((x) << S_T_RFC)
-#define G_T_RFC(x) (((x) >> S_T_RFC) & M_T_RFC)
-
-#define A_MC_PCTL_TRP 0x62dc
-
-#define S_T_RP 0
-#define M_T_RP 0xfU
-#define V_T_RP(x) ((x) << S_T_RP)
-#define G_T_RP(x) (((x) >> S_T_RP) & M_T_RP)
-
-#define A_MC_PCTL_TRTW 0x62e0
-
-#define S_T_RTW 0
-#define M_T_RTW 0x7U
-#define V_T_RTW(x) ((x) << S_T_RTW)
-#define G_T_RTW(x) (((x) >> S_T_RTW) & M_T_RTW)
-
-#define A_MC_PCTL_TAL 0x62e4
-
-#define S_T_AL 0
-#define M_T_AL 0xfU
-#define V_T_AL(x) ((x) << S_T_AL)
-#define G_T_AL(x) (((x) >> S_T_AL) & M_T_AL)
-
-#define A_MC_PCTL_TCL 0x62e8
-
-#define S_T_CL 0
-#define M_T_CL 0xfU
-#define V_T_CL(x) ((x) << S_T_CL)
-#define G_T_CL(x) (((x) >> S_T_CL) & M_T_CL)
-
-#define A_MC_PCTL_TCWL 0x62ec
-
-#define S_T_CWL 0
-#define M_T_CWL 0xfU
-#define V_T_CWL(x) ((x) << S_T_CWL)
-#define G_T_CWL(x) (((x) >> S_T_CWL) & M_T_CWL)
-
-#define A_MC_PCTL_TRAS 0x62f0
-
-#define S_T_RAS 0
-#define M_T_RAS 0x3fU
-#define V_T_RAS(x) ((x) << S_T_RAS)
-#define G_T_RAS(x) (((x) >> S_T_RAS) & M_T_RAS)
-
-#define A_MC_PCTL_TRC 0x62f4
-
-#define S_T_RC 0
-#define M_T_RC 0x3fU
-#define V_T_RC(x) ((x) << S_T_RC)
-#define G_T_RC(x) (((x) >> S_T_RC) & M_T_RC)
-
-#define A_MC_PCTL_TRCD 0x62f8
-
-#define S_T_RCD 0
-#define M_T_RCD 0xfU
-#define V_T_RCD(x) ((x) << S_T_RCD)
-#define G_T_RCD(x) (((x) >> S_T_RCD) & M_T_RCD)
-
-#define A_MC_PCTL_TRRD 0x62fc
-
-#define S_T_RRD 0
-#define M_T_RRD 0xfU
-#define V_T_RRD(x) ((x) << S_T_RRD)
-#define G_T_RRD(x) (((x) >> S_T_RRD) & M_T_RRD)
-
-#define A_MC_PCTL_TRTP 0x6300
-
-#define S_T_RTP 0
-#define M_T_RTP 0x7U
-#define V_T_RTP(x) ((x) << S_T_RTP)
-#define G_T_RTP(x) (((x) >> S_T_RTP) & M_T_RTP)
-
-#define A_MC_PCTL_TWR 0x6304
-
-#define S_T_WR 0
-#define M_T_WR 0x7U
-#define V_T_WR(x) ((x) << S_T_WR)
-#define G_T_WR(x) (((x) >> S_T_WR) & M_T_WR)
-
-#define A_MC_PCTL_TWTR 0x6308
-
-#define S_T_WTR 0
-#define M_T_WTR 0x7U
-#define V_T_WTR(x) ((x) << S_T_WTR)
-#define G_T_WTR(x) (((x) >> S_T_WTR) & M_T_WTR)
-
-#define A_MC_PCTL_TEXSR 0x630c
-
-#define S_T_EXSR 0
-#define M_T_EXSR 0x3ffU
-#define V_T_EXSR(x) ((x) << S_T_EXSR)
-#define G_T_EXSR(x) (((x) >> S_T_EXSR) & M_T_EXSR)
-
-#define A_MC_PCTL_TXP 0x6310
-
-#define S_T_XP 0
-#define M_T_XP 0x7U
-#define V_T_XP(x) ((x) << S_T_XP)
-#define G_T_XP(x) (((x) >> S_T_XP) & M_T_XP)
-
-#define A_MC_PCTL_TXPDLL 0x6314
-
-#define S_T_XPDLL 0
-#define M_T_XPDLL 0x3fU
-#define V_T_XPDLL(x) ((x) << S_T_XPDLL)
-#define G_T_XPDLL(x) (((x) >> S_T_XPDLL) & M_T_XPDLL)
-
-#define A_MC_PCTL_TZQCS 0x6318
-
-#define S_T_ZQCS 0
-#define M_T_ZQCS 0x7fU
-#define V_T_ZQCS(x) ((x) << S_T_ZQCS)
-#define G_T_ZQCS(x) (((x) >> S_T_ZQCS) & M_T_ZQCS)
-
-#define A_MC_PCTL_TZQCSI 0x631c
-
-#define S_T_ZQCSI 0
-#define M_T_ZQCSI 0xfffU
-#define V_T_ZQCSI(x) ((x) << S_T_ZQCSI)
-#define G_T_ZQCSI(x) (((x) >> S_T_ZQCSI) & M_T_ZQCSI)
-
-#define A_MC_PCTL_TDQS 0x6320
-
-#define S_T_DQS 0
-#define M_T_DQS 0x7U
-#define V_T_DQS(x) ((x) << S_T_DQS)
-#define G_T_DQS(x) (((x) >> S_T_DQS) & M_T_DQS)
-
-#define A_MC_PCTL_TCKSRE 0x6324
-
-#define S_T_CKSRE 0
-#define M_T_CKSRE 0xfU
-#define V_T_CKSRE(x) ((x) << S_T_CKSRE)
-#define G_T_CKSRE(x) (((x) >> S_T_CKSRE) & M_T_CKSRE)
-
-#define A_MC_PCTL_TCKSRX 0x6328
-
-#define S_T_CKSRX 0
-#define M_T_CKSRX 0xfU
-#define V_T_CKSRX(x) ((x) << S_T_CKSRX)
-#define G_T_CKSRX(x) (((x) >> S_T_CKSRX) & M_T_CKSRX)
-
-#define A_MC_PCTL_TCKE 0x632c
-
-#define S_T_CKE 0
-#define M_T_CKE 0x7U
-#define V_T_CKE(x) ((x) << S_T_CKE)
-#define G_T_CKE(x) (((x) >> S_T_CKE) & M_T_CKE)
-
-#define A_MC_PCTL_TMOD 0x6330
-
-#define S_T_MOD 0
-#define M_T_MOD 0xfU
-#define V_T_MOD(x) ((x) << S_T_MOD)
-#define G_T_MOD(x) (((x) >> S_T_MOD) & M_T_MOD)
-
-#define A_MC_PCTL_TRSTL 0x6334
-
-#define S_RSTHOLD 0
-#define M_RSTHOLD 0x7fU
-#define V_RSTHOLD(x) ((x) << S_RSTHOLD)
-#define G_RSTHOLD(x) (((x) >> S_RSTHOLD) & M_RSTHOLD)
-
-#define A_MC_PCTL_TZQCL 0x6338
-
-#define S_T_ZQCL 0
-#define M_T_ZQCL 0x3ffU
-#define V_T_ZQCL(x) ((x) << S_T_ZQCL)
-#define G_T_ZQCL(x) (((x) >> S_T_ZQCL) & M_T_ZQCL)
-
-#define A_MC_PCTL_DWLCFG0 0x6370
-
-#define S_T_ADWL_VEC 0
-#define M_T_ADWL_VEC 0x1ffU
-#define V_T_ADWL_VEC(x) ((x) << S_T_ADWL_VEC)
-#define G_T_ADWL_VEC(x) (((x) >> S_T_ADWL_VEC) & M_T_ADWL_VEC)
-
-#define A_MC_PCTL_DWLCFG1 0x6374
-#define A_MC_PCTL_DWLCFG2 0x6378
-#define A_MC_PCTL_DWLCFG3 0x637c
-#define A_MC_PCTL_ECCCFG 0x6380
-
-#define S_INLINE_SYN_EN 4
-#define V_INLINE_SYN_EN(x) ((x) << S_INLINE_SYN_EN)
-#define F_INLINE_SYN_EN V_INLINE_SYN_EN(1U)
-
-#define S_ECC_EN 3
-#define V_ECC_EN(x) ((x) << S_ECC_EN)
-#define F_ECC_EN V_ECC_EN(1U)
-
-#define S_ECC_INTR_EN 2
-#define V_ECC_INTR_EN(x) ((x) << S_ECC_INTR_EN)
-#define F_ECC_INTR_EN V_ECC_INTR_EN(1U)
-
-#define A_MC_PCTL_ECCTST 0x6384
-
-#define S_ECC_TEST_MASK 0
-#define M_ECC_TEST_MASK 0xffU
-#define V_ECC_TEST_MASK(x) ((x) << S_ECC_TEST_MASK)
-#define G_ECC_TEST_MASK(x) (((x) >> S_ECC_TEST_MASK) & M_ECC_TEST_MASK)
-
-#define A_MC_PCTL_ECCCLR 0x6388
-
-#define S_CLR_ECC_LOG 1
-#define V_CLR_ECC_LOG(x) ((x) << S_CLR_ECC_LOG)
-#define F_CLR_ECC_LOG V_CLR_ECC_LOG(1U)
-
-#define S_CLR_ECC_INTR 0
-#define V_CLR_ECC_INTR(x) ((x) << S_CLR_ECC_INTR)
-#define F_CLR_ECC_INTR V_CLR_ECC_INTR(1U)
-
-#define A_MC_PCTL_ECCLOG 0x638c
-#define A_MC_PCTL_DTUWACTL 0x6400
-
-#define S_DTU_WR_RANK 30
-#define M_DTU_WR_RANK 0x3U
-#define V_DTU_WR_RANK(x) ((x) << S_DTU_WR_RANK)
-#define G_DTU_WR_RANK(x) (((x) >> S_DTU_WR_RANK) & M_DTU_WR_RANK)
-
-#define S_DTU_WR_ROW 13
-#define M_DTU_WR_ROW 0x1ffffU
-#define V_DTU_WR_ROW(x) ((x) << S_DTU_WR_ROW)
-#define G_DTU_WR_ROW(x) (((x) >> S_DTU_WR_ROW) & M_DTU_WR_ROW)
-
-#define S_DTU_WR_BANK 10
-#define M_DTU_WR_BANK 0x7U
-#define V_DTU_WR_BANK(x) ((x) << S_DTU_WR_BANK)
-#define G_DTU_WR_BANK(x) (((x) >> S_DTU_WR_BANK) & M_DTU_WR_BANK)
-
-#define S_DTU_WR_COL 0
-#define M_DTU_WR_COL 0x3ffU
-#define V_DTU_WR_COL(x) ((x) << S_DTU_WR_COL)
-#define G_DTU_WR_COL(x) (((x) >> S_DTU_WR_COL) & M_DTU_WR_COL)
-
-#define A_MC_PCTL_DTURACTL 0x6404
-
-#define S_DTU_RD_RANK 30
-#define M_DTU_RD_RANK 0x3U
-#define V_DTU_RD_RANK(x) ((x) << S_DTU_RD_RANK)
-#define G_DTU_RD_RANK(x) (((x) >> S_DTU_RD_RANK) & M_DTU_RD_RANK)
-
-#define S_DTU_RD_ROW 13
-#define M_DTU_RD_ROW 0x1ffffU
-#define V_DTU_RD_ROW(x) ((x) << S_DTU_RD_ROW)
-#define G_DTU_RD_ROW(x) (((x) >> S_DTU_RD_ROW) & M_DTU_RD_ROW)
-
-#define S_DTU_RD_BANK 10
-#define M_DTU_RD_BANK 0x7U
-#define V_DTU_RD_BANK(x) ((x) << S_DTU_RD_BANK)
-#define G_DTU_RD_BANK(x) (((x) >> S_DTU_RD_BANK) & M_DTU_RD_BANK)
-
-#define S_DTU_RD_COL 0
-#define M_DTU_RD_COL 0x3ffU
-#define V_DTU_RD_COL(x) ((x) << S_DTU_RD_COL)
-#define G_DTU_RD_COL(x) (((x) >> S_DTU_RD_COL) & M_DTU_RD_COL)
-
-#define A_MC_PCTL_DTUCFG 0x6408
-
-#define S_DTU_ROW_INCREMENTS 16
-#define M_DTU_ROW_INCREMENTS 0x7fU
-#define V_DTU_ROW_INCREMENTS(x) ((x) << S_DTU_ROW_INCREMENTS)
-#define G_DTU_ROW_INCREMENTS(x) (((x) >> S_DTU_ROW_INCREMENTS) & M_DTU_ROW_INCREMENTS)
-
-#define S_DTU_WR_MULTI_RD 15
-#define V_DTU_WR_MULTI_RD(x) ((x) << S_DTU_WR_MULTI_RD)
-#define F_DTU_WR_MULTI_RD V_DTU_WR_MULTI_RD(1U)
-
-#define S_DTU_DATA_MASK_EN 14
-#define V_DTU_DATA_MASK_EN(x) ((x) << S_DTU_DATA_MASK_EN)
-#define F_DTU_DATA_MASK_EN V_DTU_DATA_MASK_EN(1U)
-
-#define S_DTU_TARGET_LANE 10
-#define M_DTU_TARGET_LANE 0xfU
-#define V_DTU_TARGET_LANE(x) ((x) << S_DTU_TARGET_LANE)
-#define G_DTU_TARGET_LANE(x) (((x) >> S_DTU_TARGET_LANE) & M_DTU_TARGET_LANE)
-
-#define S_DTU_GENERATE_RANDOM 9
-#define V_DTU_GENERATE_RANDOM(x) ((x) << S_DTU_GENERATE_RANDOM)
-#define F_DTU_GENERATE_RANDOM V_DTU_GENERATE_RANDOM(1U)
-
-#define S_DTU_INCR_BANKS 8
-#define V_DTU_INCR_BANKS(x) ((x) << S_DTU_INCR_BANKS)
-#define F_DTU_INCR_BANKS V_DTU_INCR_BANKS(1U)
-
-#define S_DTU_INCR_COLS 7
-#define V_DTU_INCR_COLS(x) ((x) << S_DTU_INCR_COLS)
-#define F_DTU_INCR_COLS V_DTU_INCR_COLS(1U)
-
-#define S_DTU_NALEN 1
-#define M_DTU_NALEN 0x3fU
-#define V_DTU_NALEN(x) ((x) << S_DTU_NALEN)
-#define G_DTU_NALEN(x) (((x) >> S_DTU_NALEN) & M_DTU_NALEN)
-
-#define S_DTU_ENABLE 0
-#define V_DTU_ENABLE(x) ((x) << S_DTU_ENABLE)
-#define F_DTU_ENABLE V_DTU_ENABLE(1U)
-
-#define A_MC_PCTL_DTUECTL 0x640c
-
-#define S_WR_MULTI_RD_RST 2
-#define V_WR_MULTI_RD_RST(x) ((x) << S_WR_MULTI_RD_RST)
-#define F_WR_MULTI_RD_RST V_WR_MULTI_RD_RST(1U)
-
-#define S_RUN_ERROR_REPORTS 1
-#define V_RUN_ERROR_REPORTS(x) ((x) << S_RUN_ERROR_REPORTS)
-#define F_RUN_ERROR_REPORTS V_RUN_ERROR_REPORTS(1U)
-
-#define S_RUN_DTU 0
-#define V_RUN_DTU(x) ((x) << S_RUN_DTU)
-#define F_RUN_DTU V_RUN_DTU(1U)
-
-#define A_MC_PCTL_DTUWD0 0x6410
-
-#define S_DTU_WR_BYTE3 24
-#define M_DTU_WR_BYTE3 0xffU
-#define V_DTU_WR_BYTE3(x) ((x) << S_DTU_WR_BYTE3)
-#define G_DTU_WR_BYTE3(x) (((x) >> S_DTU_WR_BYTE3) & M_DTU_WR_BYTE3)
-
-#define S_DTU_WR_BYTE2 16
-#define M_DTU_WR_BYTE2 0xffU
-#define V_DTU_WR_BYTE2(x) ((x) << S_DTU_WR_BYTE2)
-#define G_DTU_WR_BYTE2(x) (((x) >> S_DTU_WR_BYTE2) & M_DTU_WR_BYTE2)
-
-#define S_DTU_WR_BYTE1 8
-#define M_DTU_WR_BYTE1 0xffU
-#define V_DTU_WR_BYTE1(x) ((x) << S_DTU_WR_BYTE1)
-#define G_DTU_WR_BYTE1(x) (((x) >> S_DTU_WR_BYTE1) & M_DTU_WR_BYTE1)
-
-#define S_DTU_WR_BYTE0 0
-#define M_DTU_WR_BYTE0 0xffU
-#define V_DTU_WR_BYTE0(x) ((x) << S_DTU_WR_BYTE0)
-#define G_DTU_WR_BYTE0(x) (((x) >> S_DTU_WR_BYTE0) & M_DTU_WR_BYTE0)
-
-#define A_MC_PCTL_DTUWD1 0x6414
-
-#define S_DTU_WR_BYTE7 24
-#define M_DTU_WR_BYTE7 0xffU
-#define V_DTU_WR_BYTE7(x) ((x) << S_DTU_WR_BYTE7)
-#define G_DTU_WR_BYTE7(x) (((x) >> S_DTU_WR_BYTE7) & M_DTU_WR_BYTE7)
-
-#define S_DTU_WR_BYTE6 16
-#define M_DTU_WR_BYTE6 0xffU
-#define V_DTU_WR_BYTE6(x) ((x) << S_DTU_WR_BYTE6)
-#define G_DTU_WR_BYTE6(x) (((x) >> S_DTU_WR_BYTE6) & M_DTU_WR_BYTE6)
-
-#define S_DTU_WR_BYTE5 8
-#define M_DTU_WR_BYTE5 0xffU
-#define V_DTU_WR_BYTE5(x) ((x) << S_DTU_WR_BYTE5)
-#define G_DTU_WR_BYTE5(x) (((x) >> S_DTU_WR_BYTE5) & M_DTU_WR_BYTE5)
-
-#define S_DTU_WR_BYTE4 0
-#define M_DTU_WR_BYTE4 0xffU
-#define V_DTU_WR_BYTE4(x) ((x) << S_DTU_WR_BYTE4)
-#define G_DTU_WR_BYTE4(x) (((x) >> S_DTU_WR_BYTE4) & M_DTU_WR_BYTE4)
-
-#define A_MC_PCTL_DTUWD2 0x6418
-
-#define S_DTU_WR_BYTE11 24
-#define M_DTU_WR_BYTE11 0xffU
-#define V_DTU_WR_BYTE11(x) ((x) << S_DTU_WR_BYTE11)
-#define G_DTU_WR_BYTE11(x) (((x) >> S_DTU_WR_BYTE11) & M_DTU_WR_BYTE11)
-
-#define S_DTU_WR_BYTE10 16
-#define M_DTU_WR_BYTE10 0xffU
-#define V_DTU_WR_BYTE10(x) ((x) << S_DTU_WR_BYTE10)
-#define G_DTU_WR_BYTE10(x) (((x) >> S_DTU_WR_BYTE10) & M_DTU_WR_BYTE10)
-
-#define S_DTU_WR_BYTE9 8
-#define M_DTU_WR_BYTE9 0xffU
-#define V_DTU_WR_BYTE9(x) ((x) << S_DTU_WR_BYTE9)
-#define G_DTU_WR_BYTE9(x) (((x) >> S_DTU_WR_BYTE9) & M_DTU_WR_BYTE9)
-
-#define S_DTU_WR_BYTE8 0
-#define M_DTU_WR_BYTE8 0xffU
-#define V_DTU_WR_BYTE8(x) ((x) << S_DTU_WR_BYTE8)
-#define G_DTU_WR_BYTE8(x) (((x) >> S_DTU_WR_BYTE8) & M_DTU_WR_BYTE8)
-
-#define A_MC_PCTL_DTUWD3 0x641c
-
-#define S_DTU_WR_BYTE15 24
-#define M_DTU_WR_BYTE15 0xffU
-#define V_DTU_WR_BYTE15(x) ((x) << S_DTU_WR_BYTE15)
-#define G_DTU_WR_BYTE15(x) (((x) >> S_DTU_WR_BYTE15) & M_DTU_WR_BYTE15)
-
-#define S_DTU_WR_BYTE14 16
-#define M_DTU_WR_BYTE14 0xffU
-#define V_DTU_WR_BYTE14(x) ((x) << S_DTU_WR_BYTE14)
-#define G_DTU_WR_BYTE14(x) (((x) >> S_DTU_WR_BYTE14) & M_DTU_WR_BYTE14)
-
-#define S_DTU_WR_BYTE13 8
-#define M_DTU_WR_BYTE13 0xffU
-#define V_DTU_WR_BYTE13(x) ((x) << S_DTU_WR_BYTE13)
-#define G_DTU_WR_BYTE13(x) (((x) >> S_DTU_WR_BYTE13) & M_DTU_WR_BYTE13)
-
-#define S_DTU_WR_BYTE12 0
-#define M_DTU_WR_BYTE12 0xffU
-#define V_DTU_WR_BYTE12(x) ((x) << S_DTU_WR_BYTE12)
-#define G_DTU_WR_BYTE12(x) (((x) >> S_DTU_WR_BYTE12) & M_DTU_WR_BYTE12)
-
-#define A_MC_PCTL_DTUWDM 0x6420
-
-#define S_DM_WR_BYTE0 0
-#define M_DM_WR_BYTE0 0xffffU
-#define V_DM_WR_BYTE0(x) ((x) << S_DM_WR_BYTE0)
-#define G_DM_WR_BYTE0(x) (((x) >> S_DM_WR_BYTE0) & M_DM_WR_BYTE0)
-
-#define A_MC_PCTL_DTURD0 0x6424
-
-#define S_DTU_RD_BYTE3 24
-#define M_DTU_RD_BYTE3 0xffU
-#define V_DTU_RD_BYTE3(x) ((x) << S_DTU_RD_BYTE3)
-#define G_DTU_RD_BYTE3(x) (((x) >> S_DTU_RD_BYTE3) & M_DTU_RD_BYTE3)
-
-#define S_DTU_RD_BYTE2 16
-#define M_DTU_RD_BYTE2 0xffU
-#define V_DTU_RD_BYTE2(x) ((x) << S_DTU_RD_BYTE2)
-#define G_DTU_RD_BYTE2(x) (((x) >> S_DTU_RD_BYTE2) & M_DTU_RD_BYTE2)
-
-#define S_DTU_RD_BYTE1 8
-#define M_DTU_RD_BYTE1 0xffU
-#define V_DTU_RD_BYTE1(x) ((x) << S_DTU_RD_BYTE1)
-#define G_DTU_RD_BYTE1(x) (((x) >> S_DTU_RD_BYTE1) & M_DTU_RD_BYTE1)
-
-#define S_DTU_RD_BYTE0 0
-#define M_DTU_RD_BYTE0 0xffU
-#define V_DTU_RD_BYTE0(x) ((x) << S_DTU_RD_BYTE0)
-#define G_DTU_RD_BYTE0(x) (((x) >> S_DTU_RD_BYTE0) & M_DTU_RD_BYTE0)
-
-#define A_MC_PCTL_DTURD1 0x6428
-
-#define S_DTU_RD_BYTE7 24
-#define M_DTU_RD_BYTE7 0xffU
-#define V_DTU_RD_BYTE7(x) ((x) << S_DTU_RD_BYTE7)
-#define G_DTU_RD_BYTE7(x) (((x) >> S_DTU_RD_BYTE7) & M_DTU_RD_BYTE7)
-
-#define S_DTU_RD_BYTE6 16
-#define M_DTU_RD_BYTE6 0xffU
-#define V_DTU_RD_BYTE6(x) ((x) << S_DTU_RD_BYTE6)
-#define G_DTU_RD_BYTE6(x) (((x) >> S_DTU_RD_BYTE6) & M_DTU_RD_BYTE6)
-
-#define S_DTU_RD_BYTE5 8
-#define M_DTU_RD_BYTE5 0xffU
-#define V_DTU_RD_BYTE5(x) ((x) << S_DTU_RD_BYTE5)
-#define G_DTU_RD_BYTE5(x) (((x) >> S_DTU_RD_BYTE5) & M_DTU_RD_BYTE5)
-
-#define S_DTU_RD_BYTE4 0
-#define M_DTU_RD_BYTE4 0xffU
-#define V_DTU_RD_BYTE4(x) ((x) << S_DTU_RD_BYTE4)
-#define G_DTU_RD_BYTE4(x) (((x) >> S_DTU_RD_BYTE4) & M_DTU_RD_BYTE4)
-
-#define A_MC_PCTL_DTURD2 0x642c
-
-#define S_DTU_RD_BYTE11 24
-#define M_DTU_RD_BYTE11 0xffU
-#define V_DTU_RD_BYTE11(x) ((x) << S_DTU_RD_BYTE11)
-#define G_DTU_RD_BYTE11(x) (((x) >> S_DTU_RD_BYTE11) & M_DTU_RD_BYTE11)
-
-#define S_DTU_RD_BYTE10 16
-#define M_DTU_RD_BYTE10 0xffU
-#define V_DTU_RD_BYTE10(x) ((x) << S_DTU_RD_BYTE10)
-#define G_DTU_RD_BYTE10(x) (((x) >> S_DTU_RD_BYTE10) & M_DTU_RD_BYTE10)
-
-#define S_DTU_RD_BYTE9 8
-#define M_DTU_RD_BYTE9 0xffU
-#define V_DTU_RD_BYTE9(x) ((x) << S_DTU_RD_BYTE9)
-#define G_DTU_RD_BYTE9(x) (((x) >> S_DTU_RD_BYTE9) & M_DTU_RD_BYTE9)
-
-#define S_DTU_RD_BYTE8 0
-#define M_DTU_RD_BYTE8 0xffU
-#define V_DTU_RD_BYTE8(x) ((x) << S_DTU_RD_BYTE8)
-#define G_DTU_RD_BYTE8(x) (((x) >> S_DTU_RD_BYTE8) & M_DTU_RD_BYTE8)
-
-#define A_MC_PCTL_DTURD3 0x6430
-
-#define S_DTU_RD_BYTE15 24
-#define M_DTU_RD_BYTE15 0xffU
-#define V_DTU_RD_BYTE15(x) ((x) << S_DTU_RD_BYTE15)
-#define G_DTU_RD_BYTE15(x) (((x) >> S_DTU_RD_BYTE15) & M_DTU_RD_BYTE15)
-
-#define S_DTU_RD_BYTE14 16
-#define M_DTU_RD_BYTE14 0xffU
-#define V_DTU_RD_BYTE14(x) ((x) << S_DTU_RD_BYTE14)
-#define G_DTU_RD_BYTE14(x) (((x) >> S_DTU_RD_BYTE14) & M_DTU_RD_BYTE14)
-
-#define S_DTU_RD_BYTE13 8
-#define M_DTU_RD_BYTE13 0xffU
-#define V_DTU_RD_BYTE13(x) ((x) << S_DTU_RD_BYTE13)
-#define G_DTU_RD_BYTE13(x) (((x) >> S_DTU_RD_BYTE13) & M_DTU_RD_BYTE13)
-
-#define S_DTU_RD_BYTE12 0
-#define M_DTU_RD_BYTE12 0xffU
-#define V_DTU_RD_BYTE12(x) ((x) << S_DTU_RD_BYTE12)
-#define G_DTU_RD_BYTE12(x) (((x) >> S_DTU_RD_BYTE12) & M_DTU_RD_BYTE12)
-
-#define A_MC_DTULFSRWD 0x6434
-#define A_MC_PCTL_DTULFSRRD 0x6438
-#define A_MC_PCTL_DTUEAF 0x643c
-
-#define S_EA_RANK 30
-#define M_EA_RANK 0x3U
-#define V_EA_RANK(x) ((x) << S_EA_RANK)
-#define G_EA_RANK(x) (((x) >> S_EA_RANK) & M_EA_RANK)
-
-#define S_EA_ROW 13
-#define M_EA_ROW 0x1ffffU
-#define V_EA_ROW(x) ((x) << S_EA_ROW)
-#define G_EA_ROW(x) (((x) >> S_EA_ROW) & M_EA_ROW)
-
-#define S_EA_BANK 10
-#define M_EA_BANK 0x7U
-#define V_EA_BANK(x) ((x) << S_EA_BANK)
-#define G_EA_BANK(x) (((x) >> S_EA_BANK) & M_EA_BANK)
-
-#define S_EA_COLUMN 0
-#define M_EA_COLUMN 0x3ffU
-#define V_EA_COLUMN(x) ((x) << S_EA_COLUMN)
-#define G_EA_COLUMN(x) (((x) >> S_EA_COLUMN) & M_EA_COLUMN)
-
-#define A_MC_PCTL_PHYPVTCFG 0x6500
-
-#define S_PVT_UPD_REQ_EN 15
-#define V_PVT_UPD_REQ_EN(x) ((x) << S_PVT_UPD_REQ_EN)
-#define F_PVT_UPD_REQ_EN V_PVT_UPD_REQ_EN(1U)
-
-#define S_PVT_UPD_TRIG_POL 14
-#define V_PVT_UPD_TRIG_POL(x) ((x) << S_PVT_UPD_TRIG_POL)
-#define F_PVT_UPD_TRIG_POL V_PVT_UPD_TRIG_POL(1U)
-
-#define S_PVT_UPD_TRIG_TYPE 12
-#define V_PVT_UPD_TRIG_TYPE(x) ((x) << S_PVT_UPD_TRIG_TYPE)
-#define F_PVT_UPD_TRIG_TYPE V_PVT_UPD_TRIG_TYPE(1U)
-
-#define S_PVT_UPD_DONE_POL 10
-#define V_PVT_UPD_DONE_POL(x) ((x) << S_PVT_UPD_DONE_POL)
-#define F_PVT_UPD_DONE_POL V_PVT_UPD_DONE_POL(1U)
-
-#define S_PVT_UPD_DONE_TYPE 8
-#define M_PVT_UPD_DONE_TYPE 0x3U
-#define V_PVT_UPD_DONE_TYPE(x) ((x) << S_PVT_UPD_DONE_TYPE)
-#define G_PVT_UPD_DONE_TYPE(x) (((x) >> S_PVT_UPD_DONE_TYPE) & M_PVT_UPD_DONE_TYPE)
-
-#define S_PHY_UPD_REQ_EN 7
-#define V_PHY_UPD_REQ_EN(x) ((x) << S_PHY_UPD_REQ_EN)
-#define F_PHY_UPD_REQ_EN V_PHY_UPD_REQ_EN(1U)
-
-#define S_PHY_UPD_TRIG_POL 6
-#define V_PHY_UPD_TRIG_POL(x) ((x) << S_PHY_UPD_TRIG_POL)
-#define F_PHY_UPD_TRIG_POL V_PHY_UPD_TRIG_POL(1U)
-
-#define S_PHY_UPD_TRIG_TYPE 4
-#define V_PHY_UPD_TRIG_TYPE(x) ((x) << S_PHY_UPD_TRIG_TYPE)
-#define F_PHY_UPD_TRIG_TYPE V_PHY_UPD_TRIG_TYPE(1U)
-
-#define S_PHY_UPD_DONE_POL 2
-#define V_PHY_UPD_DONE_POL(x) ((x) << S_PHY_UPD_DONE_POL)
-#define F_PHY_UPD_DONE_POL V_PHY_UPD_DONE_POL(1U)
-
-#define S_PHY_UPD_DONE_TYPE 0
-#define M_PHY_UPD_DONE_TYPE 0x3U
-#define V_PHY_UPD_DONE_TYPE(x) ((x) << S_PHY_UPD_DONE_TYPE)
-#define G_PHY_UPD_DONE_TYPE(x) (((x) >> S_PHY_UPD_DONE_TYPE) & M_PHY_UPD_DONE_TYPE)
-
-#define A_MC_PCTL_PHYPVTSTAT 0x6504
-
-#define S_I_PVT_UPD_TRIG 5
-#define V_I_PVT_UPD_TRIG(x) ((x) << S_I_PVT_UPD_TRIG)
-#define F_I_PVT_UPD_TRIG V_I_PVT_UPD_TRIG(1U)
-
-#define S_I_PVT_UPD_DONE 4
-#define V_I_PVT_UPD_DONE(x) ((x) << S_I_PVT_UPD_DONE)
-#define F_I_PVT_UPD_DONE V_I_PVT_UPD_DONE(1U)
-
-#define S_I_PHY_UPD_TRIG 1
-#define V_I_PHY_UPD_TRIG(x) ((x) << S_I_PHY_UPD_TRIG)
-#define F_I_PHY_UPD_TRIG V_I_PHY_UPD_TRIG(1U)
-
-#define S_I_PHY_UPD_DONE 0
-#define V_I_PHY_UPD_DONE(x) ((x) << S_I_PHY_UPD_DONE)
-#define F_I_PHY_UPD_DONE V_I_PHY_UPD_DONE(1U)
-
-#define A_MC_PCTL_PHYTUPDON 0x6508
-
-#define S_PHY_T_UPDON 0
-#define M_PHY_T_UPDON 0xffU
-#define V_PHY_T_UPDON(x) ((x) << S_PHY_T_UPDON)
-#define G_PHY_T_UPDON(x) (((x) >> S_PHY_T_UPDON) & M_PHY_T_UPDON)
-
-#define A_MC_PCTL_PHYTUPDDLY 0x650c
-
-#define S_PHY_T_UPDDLY 0
-#define M_PHY_T_UPDDLY 0xfU
-#define V_PHY_T_UPDDLY(x) ((x) << S_PHY_T_UPDDLY)
-#define G_PHY_T_UPDDLY(x) (((x) >> S_PHY_T_UPDDLY) & M_PHY_T_UPDDLY)
-
-#define A_MC_PCTL_PVTTUPON 0x6510
-
-#define S_PVT_T_UPDON 0
-#define M_PVT_T_UPDON 0xffU
-#define V_PVT_T_UPDON(x) ((x) << S_PVT_T_UPDON)
-#define G_PVT_T_UPDON(x) (((x) >> S_PVT_T_UPDON) & M_PVT_T_UPDON)
-
-#define A_MC_PCTL_PVTTUPDDLY 0x6514
-
-#define S_PVT_T_UPDDLY 0
-#define M_PVT_T_UPDDLY 0xfU
-#define V_PVT_T_UPDDLY(x) ((x) << S_PVT_T_UPDDLY)
-#define G_PVT_T_UPDDLY(x) (((x) >> S_PVT_T_UPDDLY) & M_PVT_T_UPDDLY)
-
-#define A_MC_PCTL_PHYPVTUPDI 0x6518
-
-#define S_PHYPVT_T_UPDI 0
-#define M_PHYPVT_T_UPDI 0xffU
-#define V_PHYPVT_T_UPDI(x) ((x) << S_PHYPVT_T_UPDI)
-#define G_PHYPVT_T_UPDI(x) (((x) >> S_PHYPVT_T_UPDI) & M_PHYPVT_T_UPDI)
-
-#define A_MC_PCTL_PHYIOCRV1 0x651c
-
-#define S_BYTE_OE_CTL 16
-#define M_BYTE_OE_CTL 0x3U
-#define V_BYTE_OE_CTL(x) ((x) << S_BYTE_OE_CTL)
-#define G_BYTE_OE_CTL(x) (((x) >> S_BYTE_OE_CTL) & M_BYTE_OE_CTL)
-
-#define S_DYN_SOC_ODT_ALAT 12
-#define M_DYN_SOC_ODT_ALAT 0xfU
-#define V_DYN_SOC_ODT_ALAT(x) ((x) << S_DYN_SOC_ODT_ALAT)
-#define G_DYN_SOC_ODT_ALAT(x) (((x) >> S_DYN_SOC_ODT_ALAT) & M_DYN_SOC_ODT_ALAT)
-
-#define S_DYN_SOC_ODT_ATEN 8
-#define M_DYN_SOC_ODT_ATEN 0x3U
-#define V_DYN_SOC_ODT_ATEN(x) ((x) << S_DYN_SOC_ODT_ATEN)
-#define G_DYN_SOC_ODT_ATEN(x) (((x) >> S_DYN_SOC_ODT_ATEN) & M_DYN_SOC_ODT_ATEN)
-
-#define S_DYN_SOC_ODT 2
-#define V_DYN_SOC_ODT(x) ((x) << S_DYN_SOC_ODT)
-#define F_DYN_SOC_ODT V_DYN_SOC_ODT(1U)
-
-#define S_SOC_ODT_EN 0
-#define V_SOC_ODT_EN(x) ((x) << S_SOC_ODT_EN)
-#define F_SOC_ODT_EN V_SOC_ODT_EN(1U)
-
-#define A_MC_PCTL_PHYTUPDWAIT 0x6520
-
-#define S_PHY_T_UPDWAIT 0
-#define M_PHY_T_UPDWAIT 0x3fU
-#define V_PHY_T_UPDWAIT(x) ((x) << S_PHY_T_UPDWAIT)
-#define G_PHY_T_UPDWAIT(x) (((x) >> S_PHY_T_UPDWAIT) & M_PHY_T_UPDWAIT)
-
-#define A_MC_PCTL_PVTTUPDWAIT 0x6524
-
-#define S_PVT_T_UPDWAIT 0
-#define M_PVT_T_UPDWAIT 0x3fU
-#define V_PVT_T_UPDWAIT(x) ((x) << S_PVT_T_UPDWAIT)
-#define G_PVT_T_UPDWAIT(x) (((x) >> S_PVT_T_UPDWAIT) & M_PVT_T_UPDWAIT)
-
-#define A_MC_DDR3PHYAC_GCR 0x6a00
-
-#define S_WLRANK 8
-#define M_WLRANK 0x3U
-#define V_WLRANK(x) ((x) << S_WLRANK)
-#define G_WLRANK(x) (((x) >> S_WLRANK) & M_WLRANK)
-
-#define S_FDEPTH 6
-#define M_FDEPTH 0x3U
-#define V_FDEPTH(x) ((x) << S_FDEPTH)
-#define G_FDEPTH(x) (((x) >> S_FDEPTH) & M_FDEPTH)
-
-#define S_LPFDEPTH 4
-#define M_LPFDEPTH 0x3U
-#define V_LPFDEPTH(x) ((x) << S_LPFDEPTH)
-#define G_LPFDEPTH(x) (((x) >> S_LPFDEPTH) & M_LPFDEPTH)
-
-#define S_LPFEN 3
-#define V_LPFEN(x) ((x) << S_LPFEN)
-#define F_LPFEN V_LPFEN(1U)
-
-#define S_WL 2
-#define V_WL(x) ((x) << S_WL)
-#define F_WL V_WL(1U)
-
-#define S_CAL 1
-#define V_CAL(x) ((x) << S_CAL)
-#define F_CAL V_CAL(1U)
-
-#define S_MDLEN 0
-#define V_MDLEN(x) ((x) << S_MDLEN)
-#define F_MDLEN V_MDLEN(1U)
-
-#define A_MC_DDR3PHYAC_RCR0 0x6a04
-
-#define S_OCPONR 8
-#define V_OCPONR(x) ((x) << S_OCPONR)
-#define F_OCPONR V_OCPONR(1U)
-
-#define S_OCPOND 7
-#define V_OCPOND(x) ((x) << S_OCPOND)
-#define F_OCPOND V_OCPOND(1U)
-
-#define S_OCOEN 6
-#define V_OCOEN(x) ((x) << S_OCOEN)
-#define F_OCOEN V_OCOEN(1U)
-
-#define S_CKEPONR 5
-#define V_CKEPONR(x) ((x) << S_CKEPONR)
-#define F_CKEPONR V_CKEPONR(1U)
-
-#define S_CKEPOND 4
-#define V_CKEPOND(x) ((x) << S_CKEPOND)
-#define F_CKEPOND V_CKEPOND(1U)
-
-#define S_CKEOEN 3
-#define V_CKEOEN(x) ((x) << S_CKEOEN)
-#define F_CKEOEN V_CKEOEN(1U)
-
-#define S_CKPONR 2
-#define V_CKPONR(x) ((x) << S_CKPONR)
-#define F_CKPONR V_CKPONR(1U)
-
-#define S_CKPOND 1
-#define V_CKPOND(x) ((x) << S_CKPOND)
-#define F_CKPOND V_CKPOND(1U)
-
-#define S_CKOEN 0
-#define V_CKOEN(x) ((x) << S_CKOEN)
-#define F_CKOEN V_CKOEN(1U)
-
-#define A_MC_DDR3PHYAC_ACCR 0x6a14
-
-#define S_ACPONR 8
-#define V_ACPONR(x) ((x) << S_ACPONR)
-#define F_ACPONR V_ACPONR(1U)
-
-#define S_ACPOND 7
-#define V_ACPOND(x) ((x) << S_ACPOND)
-#define F_ACPOND V_ACPOND(1U)
-
-#define S_ACOEN 6
-#define V_ACOEN(x) ((x) << S_ACOEN)
-#define F_ACOEN V_ACOEN(1U)
-
-#define S_CK5PONR 5
-#define V_CK5PONR(x) ((x) << S_CK5PONR)
-#define F_CK5PONR V_CK5PONR(1U)
-
-#define S_CK5POND 4
-#define V_CK5POND(x) ((x) << S_CK5POND)
-#define F_CK5POND V_CK5POND(1U)
-
-#define S_CK5OEN 3
-#define V_CK5OEN(x) ((x) << S_CK5OEN)
-#define F_CK5OEN V_CK5OEN(1U)
-
-#define S_CK4PONR 2
-#define V_CK4PONR(x) ((x) << S_CK4PONR)
-#define F_CK4PONR V_CK4PONR(1U)
-
-#define S_CK4POND 1
-#define V_CK4POND(x) ((x) << S_CK4POND)
-#define F_CK4POND V_CK4POND(1U)
-
-#define S_CK4OEN 0
-#define V_CK4OEN(x) ((x) << S_CK4OEN)
-#define F_CK4OEN V_CK4OEN(1U)
-
-#define A_MC_DDR3PHYAC_GSR 0x6a18
-
-#define S_WLERR 4
-#define V_WLERR(x) ((x) << S_WLERR)
-#define F_WLERR V_WLERR(1U)
-
-#define S_INIT 3
-#define V_INIT(x) ((x) << S_INIT)
-#define F_INIT V_INIT(1U)
-
-#define S_ACCAL 0
-#define V_ACCAL(x) ((x) << S_ACCAL)
-#define F_ACCAL V_ACCAL(1U)
-
-#define A_MC_DDR3PHYAC_ECSR 0x6a1c
-
-#define S_WLDEC 1
-#define V_WLDEC(x) ((x) << S_WLDEC)
-#define F_WLDEC V_WLDEC(1U)
-
-#define S_WLINC 0
-#define V_WLINC(x) ((x) << S_WLINC)
-#define F_WLINC V_WLINC(1U)
-
-#define A_MC_DDR3PHYAC_OCSR 0x6a20
-#define A_MC_DDR3PHYAC_MDIPR 0x6a24
-
-#define S_PRD 0
-#define M_PRD 0x3ffU
-#define V_PRD(x) ((x) << S_PRD)
-#define G_PRD(x) (((x) >> S_PRD) & M_PRD)
-
-#define A_MC_DDR3PHYAC_MDTPR 0x6a28
-#define A_MC_DDR3PHYAC_MDPPR0 0x6a2c
-#define A_MC_DDR3PHYAC_MDPPR1 0x6a30
-#define A_MC_DDR3PHYAC_PMBDR0 0x6a34
-
-#define S_DFLTDLY 0
-#define M_DFLTDLY 0x7fU
-#define V_DFLTDLY(x) ((x) << S_DFLTDLY)
-#define G_DFLTDLY(x) (((x) >> S_DFLTDLY) & M_DFLTDLY)
-
-#define A_MC_DDR3PHYAC_PMBDR1 0x6a38
-#define A_MC_DDR3PHYAC_ACR 0x6a60
-
-#define S_TSEL 9
-#define V_TSEL(x) ((x) << S_TSEL)
-#define F_TSEL V_TSEL(1U)
-
-#define S_ISEL 7
-#define M_ISEL 0x3U
-#define V_ISEL(x) ((x) << S_ISEL)
-#define G_ISEL(x) (((x) >> S_ISEL) & M_ISEL)
-
-#define S_CALBYP 2
-#define V_CALBYP(x) ((x) << S_CALBYP)
-#define F_CALBYP V_CALBYP(1U)
-
-#define S_SDRSELINV 1
-#define V_SDRSELINV(x) ((x) << S_SDRSELINV)
-#define F_SDRSELINV V_SDRSELINV(1U)
-
-#define S_CKINV 0
-#define V_CKINV(x) ((x) << S_CKINV)
-#define F_CKINV V_CKINV(1U)
-
-#define A_MC_DDR3PHYAC_PSCR 0x6a64
-
-#define S_PSCALE 0
-#define M_PSCALE 0x3ffU
-#define V_PSCALE(x) ((x) << S_PSCALE)
-#define G_PSCALE(x) (((x) >> S_PSCALE) & M_PSCALE)
-
-#define A_MC_DDR3PHYAC_PRCR 0x6a68
-
-#define S_PHYINIT 9
-#define V_PHYINIT(x) ((x) << S_PHYINIT)
-#define F_PHYINIT V_PHYINIT(1U)
-
-#define S_PHYHRST 7
-#define V_PHYHRST(x) ((x) << S_PHYHRST)
-#define F_PHYHRST V_PHYHRST(1U)
-
-#define S_RSTCLKS 3
-#define M_RSTCLKS 0xfU
-#define V_RSTCLKS(x) ((x) << S_RSTCLKS)
-#define G_RSTCLKS(x) (((x) >> S_RSTCLKS) & M_RSTCLKS)
-
-#define S_PLLPD 2
-#define V_PLLPD(x) ((x) << S_PLLPD)
-#define F_PLLPD V_PLLPD(1U)
-
-#define S_PLLRST 1
-#define V_PLLRST(x) ((x) << S_PLLRST)
-#define F_PLLRST V_PLLRST(1U)
-
-#define S_PHYRST 0
-#define V_PHYRST(x) ((x) << S_PHYRST)
-#define F_PHYRST V_PHYRST(1U)
-
-#define A_MC_DDR3PHYAC_PLLCR0 0x6a6c
-
-#define S_RSTCXKS 4
-#define M_RSTCXKS 0x1fU
-#define V_RSTCXKS(x) ((x) << S_RSTCXKS)
-#define G_RSTCXKS(x) (((x) >> S_RSTCXKS) & M_RSTCXKS)
-
-#define S_ICPSEL 3
-#define V_ICPSEL(x) ((x) << S_ICPSEL)
-#define F_ICPSEL V_ICPSEL(1U)
-
-#define S_TESTA 0
-#define M_TESTA 0x7U
-#define V_TESTA(x) ((x) << S_TESTA)
-#define G_TESTA(x) (((x) >> S_TESTA) & M_TESTA)
-
-#define A_MC_DDR3PHYAC_PLLCR1 0x6a70
-
-#define S_BYPASS 9
-#define V_BYPASS(x) ((x) << S_BYPASS)
-#define F_BYPASS V_BYPASS(1U)
-
-#define S_BDIV 3
-#define M_BDIV 0x3U
-#define V_BDIV(x) ((x) << S_BDIV)
-#define G_BDIV(x) (((x) >> S_BDIV) & M_BDIV)
-
-#define S_TESTD 0
-#define M_TESTD 0x7U
-#define V_TESTD(x) ((x) << S_TESTD)
-#define G_TESTD(x) (((x) >> S_TESTD) & M_TESTD)
-
-#define A_MC_DDR3PHYAC_CLKENR 0x6a78
-
-#define S_CKCLKEN 3
-#define M_CKCLKEN 0x3fU
-#define V_CKCLKEN(x) ((x) << S_CKCLKEN)
-#define G_CKCLKEN(x) (((x) >> S_CKCLKEN) & M_CKCLKEN)
-
-#define S_HDRCLKEN 2
-#define V_HDRCLKEN(x) ((x) << S_HDRCLKEN)
-#define F_HDRCLKEN V_HDRCLKEN(1U)
-
-#define S_SDRCLKEN 1
-#define V_SDRCLKEN(x) ((x) << S_SDRCLKEN)
-#define F_SDRCLKEN V_SDRCLKEN(1U)
-
-#define S_DDRCLKEN 0
-#define V_DDRCLKEN(x) ((x) << S_DDRCLKEN)
-#define F_DDRCLKEN V_DDRCLKEN(1U)
-
-#define A_MC_DDR3PHYDATX8_GCR 0x6b00
-
-#define S_PONR 6
-#define V_PONR(x) ((x) << S_PONR)
-#define F_PONR V_PONR(1U)
-
-#define S_POND 5
-#define V_POND(x) ((x) << S_POND)
-#define F_POND V_POND(1U)
-
-#define S_RDBDVT 4
-#define V_RDBDVT(x) ((x) << S_RDBDVT)
-#define F_RDBDVT V_RDBDVT(1U)
-
-#define S_WDBDVT 3
-#define V_WDBDVT(x) ((x) << S_WDBDVT)
-#define F_WDBDVT V_WDBDVT(1U)
-
-#define S_RDSDVT 2
-#define V_RDSDVT(x) ((x) << S_RDSDVT)
-#define F_RDSDVT V_RDSDVT(1U)
-
-#define S_WDSDVT 1
-#define V_WDSDVT(x) ((x) << S_WDSDVT)
-#define F_WDSDVT V_WDSDVT(1U)
-
-#define S_WLSDVT 0
-#define V_WLSDVT(x) ((x) << S_WLSDVT)
-#define F_WLSDVT V_WLSDVT(1U)
-
-#define A_MC_DDR3PHYDATX8_WDSDR 0x6b04
-
-#define S_WDSDR_DLY 0
-#define M_WDSDR_DLY 0x3ffU
-#define V_WDSDR_DLY(x) ((x) << S_WDSDR_DLY)
-#define G_WDSDR_DLY(x) (((x) >> S_WDSDR_DLY) & M_WDSDR_DLY)
-
-#define A_MC_DDR3PHYDATX8_WLDPR 0x6b08
-#define A_MC_DDR3PHYDATX8_WLDR 0x6b0c
-
-#define S_WL_DLY 0
-#define M_WL_DLY 0x3ffU
-#define V_WL_DLY(x) ((x) << S_WL_DLY)
-#define G_WL_DLY(x) (((x) >> S_WL_DLY) & M_WL_DLY)
-
-#define A_MC_DDR3PHYDATX8_WDBDR0 0x6b1c
-
-#define S_DLY 0
-#define M_DLY 0x7fU
-#define V_DLY(x) ((x) << S_DLY)
-#define G_DLY(x) (((x) >> S_DLY) & M_DLY)
-
-#define A_MC_DDR3PHYDATX8_WDBDR1 0x6b20
-#define A_MC_DDR3PHYDATX8_WDBDR2 0x6b24
-#define A_MC_DDR3PHYDATX8_WDBDR3 0x6b28
-#define A_MC_DDR3PHYDATX8_WDBDR4 0x6b2c
-#define A_MC_DDR3PHYDATX8_WDBDR5 0x6b30
-#define A_MC_DDR3PHYDATX8_WDBDR6 0x6b34
-#define A_MC_DDR3PHYDATX8_WDBDR7 0x6b38
-#define A_MC_DDR3PHYDATX8_WDBDR8 0x6b3c
-#define A_MC_DDR3PHYDATX8_WDBDMR 0x6b40
-
-#define S_MAXDLY 0
-#define M_MAXDLY 0x7fU
-#define V_MAXDLY(x) ((x) << S_MAXDLY)
-#define G_MAXDLY(x) (((x) >> S_MAXDLY) & M_MAXDLY)
-
-#define A_MC_DDR3PHYDATX8_RDSDR 0x6b44
-
-#define S_RDSDR_DLY 0
-#define M_RDSDR_DLY 0x3ffU
-#define V_RDSDR_DLY(x) ((x) << S_RDSDR_DLY)
-#define G_RDSDR_DLY(x) (((x) >> S_RDSDR_DLY) & M_RDSDR_DLY)
-
-#define A_MC_DDR3PHYDATX8_RDBDR0 0x6b48
-#define A_MC_DDR3PHYDATX8_RDBDR1 0x6b4c
-#define A_MC_DDR3PHYDATX8_RDBDR2 0x6b50
-#define A_MC_DDR3PHYDATX8_RDBDR3 0x6b54
-#define A_MC_DDR3PHYDATX8_RDBDR4 0x6b58
-#define A_MC_DDR3PHYDATX8_RDBDR5 0x6b5c
-#define A_MC_DDR3PHYDATX8_RDBDR6 0x6b60
-#define A_MC_DDR3PHYDATX8_RDBDR7 0x6b64
-#define A_MC_DDR3PHYDATX8_RDBDMR 0x6b68
-#define A_MC_DDR3PHYDATX8_PMBDR0 0x6b6c
-#define A_MC_DDR3PHYDATX8_PMBDR1 0x6b70
-#define A_MC_DDR3PHYDATX8_PMBDR2 0x6b74
-#define A_MC_DDR3PHYDATX8_PMBDR3 0x6b78
-#define A_MC_DDR3PHYDATX8_WDBDPR 0x6b7c
-
-#define S_DP_DLY 0
-#define M_DP_DLY 0x1ffU
-#define V_DP_DLY(x) ((x) << S_DP_DLY)
-#define G_DP_DLY(x) (((x) >> S_DP_DLY) & M_DP_DLY)
-
-#define A_MC_DDR3PHYDATX8_RDBDPR 0x6b80
-#define A_MC_DDR3PHYDATX8_GSR 0x6b84
-
-#define S_WLDONE 3
-#define V_WLDONE(x) ((x) << S_WLDONE)
-#define F_WLDONE V_WLDONE(1U)
-
-#define S_WLCAL 2
-#define V_WLCAL(x) ((x) << S_WLCAL)
-#define F_WLCAL V_WLCAL(1U)
-
-#define S_READ 1
-#define V_READ(x) ((x) << S_READ)
-#define F_READ V_READ(1U)
-
-#define S_RDQSCAL 0
-#define V_RDQSCAL(x) ((x) << S_RDQSCAL)
-#define F_RDQSCAL V_RDQSCAL(1U)
-
-#define A_MC_DDR3PHYDATX8_ACR 0x6bf0
-
-#define S_PHYHSRST 9
-#define V_PHYHSRST(x) ((x) << S_PHYHSRST)
-#define F_PHYHSRST V_PHYHSRST(1U)
-
-#define S_WLSTEP 8
-#define V_WLSTEP(x) ((x) << S_WLSTEP)
-#define F_WLSTEP V_WLSTEP(1U)
-
-#define S_SDR_SEL_INV 2
-#define V_SDR_SEL_INV(x) ((x) << S_SDR_SEL_INV)
-#define F_SDR_SEL_INV V_SDR_SEL_INV(1U)
-
-#define S_DDRSELINV 1
-#define V_DDRSELINV(x) ((x) << S_DDRSELINV)
-#define F_DDRSELINV V_DDRSELINV(1U)
-
-#define S_DSINV 0
-#define V_DSINV(x) ((x) << S_DSINV)
-#define F_DSINV V_DSINV(1U)
-
-#define A_MC_DDR3PHYDATX8_RSR 0x6bf4
-
-#define S_WLRANKSEL 9
-#define V_WLRANKSEL(x) ((x) << S_WLRANKSEL)
-#define F_WLRANKSEL V_WLRANKSEL(1U)
-
-#define S_RANK 0
-#define M_RANK 0x3U
-#define V_RANK(x) ((x) << S_RANK)
-#define G_RANK(x) (((x) >> S_RANK) & M_RANK)
-
-#define A_MC_DDR3PHYDATX8_CLKENR 0x6bf8
-
-#define S_DTOSEL 8
-#define M_DTOSEL 0x3U
-#define V_DTOSEL(x) ((x) << S_DTOSEL)
-#define G_DTOSEL(x) (((x) >> S_DTOSEL) & M_DTOSEL)
-
-#define A_MC_PVT_REG_CALIBRATE_CTL 0x7400
-#define A_MC_PVT_REG_UPDATE_CTL 0x7404
-#define A_MC_PVT_REG_LAST_MEASUREMENT 0x7408
-#define A_MC_PVT_REG_DRVN 0x740c
-#define A_MC_PVT_REG_DRVP 0x7410
-#define A_MC_PVT_REG_TERMN 0x7414
-#define A_MC_PVT_REG_TERMP 0x7418
-#define A_MC_PVT_REG_THRESHOLD 0x741c
-#define A_MC_PVT_REG_IN_TERMP 0x7420
-#define A_MC_PVT_REG_IN_TERMN 0x7424
-#define A_MC_PVT_REG_IN_DRVP 0x7428
-#define A_MC_PVT_REG_IN_DRVN 0x742c
-#define A_MC_PVT_REG_OUT_TERMP 0x7430
-#define A_MC_PVT_REG_OUT_TERMN 0x7434
-#define A_MC_PVT_REG_OUT_DRVP 0x7438
-#define A_MC_PVT_REG_OUT_DRVN 0x743c
-#define A_MC_PVT_REG_HISTORY_TERMP 0x7440
-#define A_MC_PVT_REG_HISTORY_TERMN 0x7444
-#define A_MC_PVT_REG_HISTORY_DRVP 0x7448
-#define A_MC_PVT_REG_HISTORY_DRVN 0x744c
-#define A_MC_PVT_REG_SAMPLE_WAIT_CLKS 0x7450
-#define A_MC_DDRPHY_RST_CTRL 0x7500
-
-#define S_DDRIO_ENABLE 1
-#define V_DDRIO_ENABLE(x) ((x) << S_DDRIO_ENABLE)
-#define F_DDRIO_ENABLE V_DDRIO_ENABLE(1U)
-
-#define S_PHY_RST_N 0
-#define V_PHY_RST_N(x) ((x) << S_PHY_RST_N)
-#define F_PHY_RST_N V_PHY_RST_N(1U)
-
-#define A_MC_PERFORMANCE_CTRL 0x7504
-
-#define S_STALL_CHK_BIT 2
-#define V_STALL_CHK_BIT(x) ((x) << S_STALL_CHK_BIT)
-#define F_STALL_CHK_BIT V_STALL_CHK_BIT(1U)
-
-#define S_DDR3_BRC_MODE 1
-#define V_DDR3_BRC_MODE(x) ((x) << S_DDR3_BRC_MODE)
-#define F_DDR3_BRC_MODE V_DDR3_BRC_MODE(1U)
-
-#define S_RMW_PERF_CTRL 0
-#define V_RMW_PERF_CTRL(x) ((x) << S_RMW_PERF_CTRL)
-#define F_RMW_PERF_CTRL V_RMW_PERF_CTRL(1U)
-
-#define A_MC_ECC_CTRL 0x7508
-
-#define S_ECC_BYPASS_BIST 1
-#define V_ECC_BYPASS_BIST(x) ((x) << S_ECC_BYPASS_BIST)
-#define F_ECC_BYPASS_BIST V_ECC_BYPASS_BIST(1U)
-
-#define S_ECC_DISABLE 0
-#define V_ECC_DISABLE(x) ((x) << S_ECC_DISABLE)
-#define F_ECC_DISABLE V_ECC_DISABLE(1U)
-
-#define A_MC_PAR_ENABLE 0x750c
-
-#define S_ECC_UE_PAR_ENABLE 3
-#define V_ECC_UE_PAR_ENABLE(x) ((x) << S_ECC_UE_PAR_ENABLE)
-#define F_ECC_UE_PAR_ENABLE V_ECC_UE_PAR_ENABLE(1U)
-
-#define S_ECC_CE_PAR_ENABLE 2
-#define V_ECC_CE_PAR_ENABLE(x) ((x) << S_ECC_CE_PAR_ENABLE)
-#define F_ECC_CE_PAR_ENABLE V_ECC_CE_PAR_ENABLE(1U)
-
-#define S_PERR_REG_INT_ENABLE 1
-#define V_PERR_REG_INT_ENABLE(x) ((x) << S_PERR_REG_INT_ENABLE)
-#define F_PERR_REG_INT_ENABLE V_PERR_REG_INT_ENABLE(1U)
-
-#define S_PERR_BLK_INT_ENABLE 0
-#define V_PERR_BLK_INT_ENABLE(x) ((x) << S_PERR_BLK_INT_ENABLE)
-#define F_PERR_BLK_INT_ENABLE V_PERR_BLK_INT_ENABLE(1U)
-
-#define A_MC_PAR_CAUSE 0x7510
-
-#define S_ECC_UE_PAR_CAUSE 3
-#define V_ECC_UE_PAR_CAUSE(x) ((x) << S_ECC_UE_PAR_CAUSE)
-#define F_ECC_UE_PAR_CAUSE V_ECC_UE_PAR_CAUSE(1U)
-
-#define S_ECC_CE_PAR_CAUSE 2
-#define V_ECC_CE_PAR_CAUSE(x) ((x) << S_ECC_CE_PAR_CAUSE)
-#define F_ECC_CE_PAR_CAUSE V_ECC_CE_PAR_CAUSE(1U)
-
-#define S_FIFOR_PAR_CAUSE 1
-#define V_FIFOR_PAR_CAUSE(x) ((x) << S_FIFOR_PAR_CAUSE)
-#define F_FIFOR_PAR_CAUSE V_FIFOR_PAR_CAUSE(1U)
-
-#define S_RDATA_FIFOR_PAR_CAUSE 0
-#define V_RDATA_FIFOR_PAR_CAUSE(x) ((x) << S_RDATA_FIFOR_PAR_CAUSE)
-#define F_RDATA_FIFOR_PAR_CAUSE V_RDATA_FIFOR_PAR_CAUSE(1U)
-
-#define A_MC_INT_ENABLE 0x7514
-
-#define S_ECC_UE_INT_ENABLE 2
-#define V_ECC_UE_INT_ENABLE(x) ((x) << S_ECC_UE_INT_ENABLE)
-#define F_ECC_UE_INT_ENABLE V_ECC_UE_INT_ENABLE(1U)
-
-#define S_ECC_CE_INT_ENABLE 1
-#define V_ECC_CE_INT_ENABLE(x) ((x) << S_ECC_CE_INT_ENABLE)
-#define F_ECC_CE_INT_ENABLE V_ECC_CE_INT_ENABLE(1U)
-
-#define S_PERR_INT_ENABLE 0
-#define V_PERR_INT_ENABLE(x) ((x) << S_PERR_INT_ENABLE)
-#define F_PERR_INT_ENABLE V_PERR_INT_ENABLE(1U)
-
-#define A_MC_INT_CAUSE 0x7518
-
-#define S_ECC_UE_INT_CAUSE 2
-#define V_ECC_UE_INT_CAUSE(x) ((x) << S_ECC_UE_INT_CAUSE)
-#define F_ECC_UE_INT_CAUSE V_ECC_UE_INT_CAUSE(1U)
-
-#define S_ECC_CE_INT_CAUSE 1
-#define V_ECC_CE_INT_CAUSE(x) ((x) << S_ECC_CE_INT_CAUSE)
-#define F_ECC_CE_INT_CAUSE V_ECC_CE_INT_CAUSE(1U)
-
-#define S_PERR_INT_CAUSE 0
-#define V_PERR_INT_CAUSE(x) ((x) << S_PERR_INT_CAUSE)
-#define F_PERR_INT_CAUSE V_PERR_INT_CAUSE(1U)
-
-#define A_MC_ECC_STATUS 0x751c
-
-#define S_ECC_CECNT 16
-#define M_ECC_CECNT 0xffffU
-#define V_ECC_CECNT(x) ((x) << S_ECC_CECNT)
-#define G_ECC_CECNT(x) (((x) >> S_ECC_CECNT) & M_ECC_CECNT)
-
-#define S_ECC_UECNT 0
-#define M_ECC_UECNT 0xffffU
-#define V_ECC_UECNT(x) ((x) << S_ECC_UECNT)
-#define G_ECC_UECNT(x) (((x) >> S_ECC_UECNT) & M_ECC_UECNT)
-
-#define A_MC_PHY_CTRL 0x7520
-
-#define S_CTLPHYRR 0
-#define V_CTLPHYRR(x) ((x) << S_CTLPHYRR)
-#define F_CTLPHYRR V_CTLPHYRR(1U)
-
-#define A_MC_STATIC_CFG_STATUS 0x7524
-
-#define S_STATIC_MODE 9
-#define V_STATIC_MODE(x) ((x) << S_STATIC_MODE)
-#define F_STATIC_MODE V_STATIC_MODE(1U)
-
-#define S_STATIC_DEN 6
-#define M_STATIC_DEN 0x7U
-#define V_STATIC_DEN(x) ((x) << S_STATIC_DEN)
-#define G_STATIC_DEN(x) (((x) >> S_STATIC_DEN) & M_STATIC_DEN)
-
-#define S_STATIC_ORG 5
-#define V_STATIC_ORG(x) ((x) << S_STATIC_ORG)
-#define F_STATIC_ORG V_STATIC_ORG(1U)
-
-#define S_STATIC_RKS 4
-#define V_STATIC_RKS(x) ((x) << S_STATIC_RKS)
-#define F_STATIC_RKS V_STATIC_RKS(1U)
-
-#define S_STATIC_WIDTH 1
-#define M_STATIC_WIDTH 0x7U
-#define V_STATIC_WIDTH(x) ((x) << S_STATIC_WIDTH)
-#define G_STATIC_WIDTH(x) (((x) >> S_STATIC_WIDTH) & M_STATIC_WIDTH)
-
-#define S_STATIC_SLOW 0
-#define V_STATIC_SLOW(x) ((x) << S_STATIC_SLOW)
-#define F_STATIC_SLOW V_STATIC_SLOW(1U)
-
-#define A_MC_CORE_PCTL_STAT 0x7528
-
-#define S_PCTL_ACCESS_STAT 0
-#define M_PCTL_ACCESS_STAT 0x7U
-#define V_PCTL_ACCESS_STAT(x) ((x) << S_PCTL_ACCESS_STAT)
-#define G_PCTL_ACCESS_STAT(x) (((x) >> S_PCTL_ACCESS_STAT) & M_PCTL_ACCESS_STAT)
-
-#define A_MC_DEBUG_CNT 0x752c
-
-#define S_WDATA_OCNT 8
-#define M_WDATA_OCNT 0x1fU
-#define V_WDATA_OCNT(x) ((x) << S_WDATA_OCNT)
-#define G_WDATA_OCNT(x) (((x) >> S_WDATA_OCNT) & M_WDATA_OCNT)
-
-#define S_RDATA_OCNT 0
-#define M_RDATA_OCNT 0x1fU
-#define V_RDATA_OCNT(x) ((x) << S_RDATA_OCNT)
-#define G_RDATA_OCNT(x) (((x) >> S_RDATA_OCNT) & M_RDATA_OCNT)
-
-#define A_MC_BONUS 0x7530
-#define A_MC_BIST_CMD 0x7600
-
-#define S_START_BIST 31
-#define V_START_BIST(x) ((x) << S_START_BIST)
-#define F_START_BIST V_START_BIST(1U)
-
-#define S_BIST_CMD_GAP 8
-#define M_BIST_CMD_GAP 0xffU
-#define V_BIST_CMD_GAP(x) ((x) << S_BIST_CMD_GAP)
-#define G_BIST_CMD_GAP(x) (((x) >> S_BIST_CMD_GAP) & M_BIST_CMD_GAP)
-
-#define S_BIST_OPCODE 0
-#define M_BIST_OPCODE 0x3U
-#define V_BIST_OPCODE(x) ((x) << S_BIST_OPCODE)
-#define G_BIST_OPCODE(x) (((x) >> S_BIST_OPCODE) & M_BIST_OPCODE)
-
-#define A_MC_BIST_CMD_ADDR 0x7604
-#define A_MC_BIST_CMD_LEN 0x7608
-#define A_MC_BIST_DATA_PATTERN 0x760c
-
-#define S_BIST_DATA_TYPE 0
-#define M_BIST_DATA_TYPE 0xfU
-#define V_BIST_DATA_TYPE(x) ((x) << S_BIST_DATA_TYPE)
-#define G_BIST_DATA_TYPE(x) (((x) >> S_BIST_DATA_TYPE) & M_BIST_DATA_TYPE)
-
-#define A_MC_BIST_USER_WDATA0 0x7614
-#define A_MC_BIST_USER_WDATA1 0x7618
-#define A_MC_BIST_USER_WDATA2 0x761c
-
-#define S_USER_DATA2 0
-#define M_USER_DATA2 0xffU
-#define V_USER_DATA2(x) ((x) << S_USER_DATA2)
-#define G_USER_DATA2(x) (((x) >> S_USER_DATA2) & M_USER_DATA2)
-
-#define A_MC_BIST_NUM_ERR 0x7680
-#define A_MC_BIST_ERR_FIRST_ADDR 0x7684
-#define A_MC_BIST_STATUS_RDATA 0x7688
-
-/* registers for module MA */
-#define MA_BASE_ADDR 0x7700
-
-#define A_MA_CLIENT0_RD_LATENCY_THRESHOLD 0x7700
-
-#define S_THRESHOLD1 17
-#define M_THRESHOLD1 0x7fffU
-#define V_THRESHOLD1(x) ((x) << S_THRESHOLD1)
-#define G_THRESHOLD1(x) (((x) >> S_THRESHOLD1) & M_THRESHOLD1)
-
-#define S_THRESHOLD1_EN 16
-#define V_THRESHOLD1_EN(x) ((x) << S_THRESHOLD1_EN)
-#define F_THRESHOLD1_EN V_THRESHOLD1_EN(1U)
-
-#define S_THRESHOLD0 1
-#define M_THRESHOLD0 0x7fffU
-#define V_THRESHOLD0(x) ((x) << S_THRESHOLD0)
-#define G_THRESHOLD0(x) (((x) >> S_THRESHOLD0) & M_THRESHOLD0)
-
-#define S_THRESHOLD0_EN 0
-#define V_THRESHOLD0_EN(x) ((x) << S_THRESHOLD0_EN)
-#define F_THRESHOLD0_EN V_THRESHOLD0_EN(1U)
-
-#define A_MA_CLIENT0_WR_LATENCY_THRESHOLD 0x7704
-#define A_MA_CLIENT1_RD_LATENCY_THRESHOLD 0x7708
-#define A_MA_CLIENT1_WR_LATENCY_THRESHOLD 0x770c
-#define A_MA_CLIENT2_RD_LATENCY_THRESHOLD 0x7710
-#define A_MA_CLIENT2_WR_LATENCY_THRESHOLD 0x7714
-#define A_MA_CLIENT3_RD_LATENCY_THRESHOLD 0x7718
-#define A_MA_CLIENT3_WR_LATENCY_THRESHOLD 0x771c
-#define A_MA_CLIENT4_RD_LATENCY_THRESHOLD 0x7720
-#define A_MA_CLIENT4_WR_LATENCY_THRESHOLD 0x7724
-#define A_MA_CLIENT5_RD_LATENCY_THRESHOLD 0x7728
-#define A_MA_CLIENT5_WR_LATENCY_THRESHOLD 0x772c
-#define A_MA_CLIENT6_RD_LATENCY_THRESHOLD 0x7730
-#define A_MA_CLIENT6_WR_LATENCY_THRESHOLD 0x7734
-#define A_MA_CLIENT7_RD_LATENCY_THRESHOLD 0x7738
-#define A_MA_CLIENT7_WR_LATENCY_THRESHOLD 0x773c
-#define A_MA_CLIENT8_RD_LATENCY_THRESHOLD 0x7740
-#define A_MA_CLIENT8_WR_LATENCY_THRESHOLD 0x7744
-#define A_MA_CLIENT9_RD_LATENCY_THRESHOLD 0x7748
-#define A_MA_CLIENT9_WR_LATENCY_THRESHOLD 0x774c
-#define A_MA_CLIENT10_RD_LATENCY_THRESHOLD 0x7750
-#define A_MA_CLIENT10_WR_LATENCY_THRESHOLD 0x7754
-#define A_MA_CLIENT11_RD_LATENCY_THRESHOLD 0x7758
-#define A_MA_CLIENT11_WR_LATENCY_THRESHOLD 0x775c
-#define A_MA_CLIENT12_RD_LATENCY_THRESHOLD 0x7760
-#define A_MA_CLIENT12_WR_LATENCY_THRESHOLD 0x7764
-#define A_MA_SGE_TH0_DEBUG_CNT 0x7768
-
-#define S_DBG_READ_DATA_CNT 24
-#define M_DBG_READ_DATA_CNT 0xffU
-#define V_DBG_READ_DATA_CNT(x) ((x) << S_DBG_READ_DATA_CNT)
-#define G_DBG_READ_DATA_CNT(x) (((x) >> S_DBG_READ_DATA_CNT) & M_DBG_READ_DATA_CNT)
-
-#define S_DBG_READ_REQ_CNT 16
-#define M_DBG_READ_REQ_CNT 0xffU
-#define V_DBG_READ_REQ_CNT(x) ((x) << S_DBG_READ_REQ_CNT)
-#define G_DBG_READ_REQ_CNT(x) (((x) >> S_DBG_READ_REQ_CNT) & M_DBG_READ_REQ_CNT)
-
-#define S_DBG_WRITE_DATA_CNT 8
-#define M_DBG_WRITE_DATA_CNT 0xffU
-#define V_DBG_WRITE_DATA_CNT(x) ((x) << S_DBG_WRITE_DATA_CNT)
-#define G_DBG_WRITE_DATA_CNT(x) (((x) >> S_DBG_WRITE_DATA_CNT) & M_DBG_WRITE_DATA_CNT)
-
-#define S_DBG_WRITE_REQ_CNT 0
-#define M_DBG_WRITE_REQ_CNT 0xffU
-#define V_DBG_WRITE_REQ_CNT(x) ((x) << S_DBG_WRITE_REQ_CNT)
-#define G_DBG_WRITE_REQ_CNT(x) (((x) >> S_DBG_WRITE_REQ_CNT) & M_DBG_WRITE_REQ_CNT)
-
-#define A_MA_SGE_TH1_DEBUG_CNT 0x776c
-#define A_MA_ULPTX_DEBUG_CNT 0x7770
-#define A_MA_ULPRX_DEBUG_CNT 0x7774
-#define A_MA_ULPTXRX_DEBUG_CNT 0x7778
-#define A_MA_TP_TH0_DEBUG_CNT 0x777c
-#define A_MA_TP_TH1_DEBUG_CNT 0x7780
-#define A_MA_LE_DEBUG_CNT 0x7784
-#define A_MA_CIM_DEBUG_CNT 0x7788
-#define A_MA_PCIE_DEBUG_CNT 0x778c
-#define A_MA_PMTX_DEBUG_CNT 0x7790
-#define A_MA_PMRX_DEBUG_CNT 0x7794
-#define A_MA_HMA_DEBUG_CNT 0x7798
-#define A_MA_EDRAM0_BAR 0x77c0
-
-#define S_EDRAM0_BASE 16
-#define M_EDRAM0_BASE 0xfffU
-#define V_EDRAM0_BASE(x) ((x) << S_EDRAM0_BASE)
-#define G_EDRAM0_BASE(x) (((x) >> S_EDRAM0_BASE) & M_EDRAM0_BASE)
-
-#define S_EDRAM0_SIZE 0
-#define M_EDRAM0_SIZE 0xfffU
-#define V_EDRAM0_SIZE(x) ((x) << S_EDRAM0_SIZE)
-#define G_EDRAM0_SIZE(x) (((x) >> S_EDRAM0_SIZE) & M_EDRAM0_SIZE)
-
-#define A_MA_EDRAM1_BAR 0x77c4
-
-#define S_EDRAM1_BASE 16
-#define M_EDRAM1_BASE 0xfffU
-#define V_EDRAM1_BASE(x) ((x) << S_EDRAM1_BASE)
-#define G_EDRAM1_BASE(x) (((x) >> S_EDRAM1_BASE) & M_EDRAM1_BASE)
-
-#define S_EDRAM1_SIZE 0
-#define M_EDRAM1_SIZE 0xfffU
-#define V_EDRAM1_SIZE(x) ((x) << S_EDRAM1_SIZE)
-#define G_EDRAM1_SIZE(x) (((x) >> S_EDRAM1_SIZE) & M_EDRAM1_SIZE)
-
-#define A_MA_EXT_MEMORY_BAR 0x77c8
-
-#define S_EXT_MEM_BASE 16
-#define M_EXT_MEM_BASE 0xfffU
-#define V_EXT_MEM_BASE(x) ((x) << S_EXT_MEM_BASE)
-#define G_EXT_MEM_BASE(x) (((x) >> S_EXT_MEM_BASE) & M_EXT_MEM_BASE)
-
-#define S_EXT_MEM_SIZE 0
-#define M_EXT_MEM_SIZE 0xfffU
-#define V_EXT_MEM_SIZE(x) ((x) << S_EXT_MEM_SIZE)
-#define G_EXT_MEM_SIZE(x) (((x) >> S_EXT_MEM_SIZE) & M_EXT_MEM_SIZE)
-
-#define A_MA_EXT_MEMORY0_BAR 0x77c8
-
-#define S_EXT_MEM0_BASE 16
-#define M_EXT_MEM0_BASE 0xfffU
-#define V_EXT_MEM0_BASE(x) ((x) << S_EXT_MEM0_BASE)
-#define G_EXT_MEM0_BASE(x) (((x) >> S_EXT_MEM0_BASE) & M_EXT_MEM0_BASE)
-
-#define S_EXT_MEM0_SIZE 0
-#define M_EXT_MEM0_SIZE 0xfffU
-#define V_EXT_MEM0_SIZE(x) ((x) << S_EXT_MEM0_SIZE)
-#define G_EXT_MEM0_SIZE(x) (((x) >> S_EXT_MEM0_SIZE) & M_EXT_MEM0_SIZE)
-
-#define A_MA_HOST_MEMORY_BAR 0x77cc
-
-#define S_HMA_BASE 16
-#define M_HMA_BASE 0xfffU
-#define V_HMA_BASE(x) ((x) << S_HMA_BASE)
-#define G_HMA_BASE(x) (((x) >> S_HMA_BASE) & M_HMA_BASE)
-
-#define S_HMA_SIZE 0
-#define M_HMA_SIZE 0xfffU
-#define V_HMA_SIZE(x) ((x) << S_HMA_SIZE)
-#define G_HMA_SIZE(x) (((x) >> S_HMA_SIZE) & M_HMA_SIZE)
-
-#define A_MA_EXT_MEM_PAGE_SIZE 0x77d0
-
-#define S_BRC_MODE 2
-#define V_BRC_MODE(x) ((x) << S_BRC_MODE)
-#define F_BRC_MODE V_BRC_MODE(1U)
-
-#define S_EXT_MEM_PAGE_SIZE 0
-#define M_EXT_MEM_PAGE_SIZE 0x3U
-#define V_EXT_MEM_PAGE_SIZE(x) ((x) << S_EXT_MEM_PAGE_SIZE)
-#define G_EXT_MEM_PAGE_SIZE(x) (((x) >> S_EXT_MEM_PAGE_SIZE) & M_EXT_MEM_PAGE_SIZE)
-
-#define S_BRC_MODE1 6
-#define V_BRC_MODE1(x) ((x) << S_BRC_MODE1)
-#define F_BRC_MODE1 V_BRC_MODE1(1U)
-
-#define S_EXT_MEM_PAGE_SIZE1 4
-#define M_EXT_MEM_PAGE_SIZE1 0x3U
-#define V_EXT_MEM_PAGE_SIZE1(x) ((x) << S_EXT_MEM_PAGE_SIZE1)
-#define G_EXT_MEM_PAGE_SIZE1(x) (((x) >> S_EXT_MEM_PAGE_SIZE1) & M_EXT_MEM_PAGE_SIZE1)
-
-#define S_BRBC_MODE 4
-#define V_BRBC_MODE(x) ((x) << S_BRBC_MODE)
-#define F_BRBC_MODE V_BRBC_MODE(1U)
-
-#define S_T6_BRC_MODE 3
-#define V_T6_BRC_MODE(x) ((x) << S_T6_BRC_MODE)
-#define F_T6_BRC_MODE V_T6_BRC_MODE(1U)
-
-#define S_T6_EXT_MEM_PAGE_SIZE 0
-#define M_T6_EXT_MEM_PAGE_SIZE 0x7U
-#define V_T6_EXT_MEM_PAGE_SIZE(x) ((x) << S_T6_EXT_MEM_PAGE_SIZE)
-#define G_T6_EXT_MEM_PAGE_SIZE(x) (((x) >> S_T6_EXT_MEM_PAGE_SIZE) & M_T6_EXT_MEM_PAGE_SIZE)
-
-#define A_MA_ARB_CTRL 0x77d4
-
-#define S_DIS_PAGE_HINT 1
-#define V_DIS_PAGE_HINT(x) ((x) << S_DIS_PAGE_HINT)
-#define F_DIS_PAGE_HINT V_DIS_PAGE_HINT(1U)
-
-#define S_DIS_ADV_ARB 0
-#define V_DIS_ADV_ARB(x) ((x) << S_DIS_ADV_ARB)
-#define F_DIS_ADV_ARB V_DIS_ADV_ARB(1U)
-
-#define S_DIS_BANK_FAIR 2
-#define V_DIS_BANK_FAIR(x) ((x) << S_DIS_BANK_FAIR)
-#define F_DIS_BANK_FAIR V_DIS_BANK_FAIR(1U)
-
-#define S_HMA_WRT_EN 26
-#define V_HMA_WRT_EN(x) ((x) << S_HMA_WRT_EN)
-#define F_HMA_WRT_EN V_HMA_WRT_EN(1U)
-
-#define S_HMA_NUM_PG_128B_FDBK 21
-#define M_HMA_NUM_PG_128B_FDBK 0x1fU
-#define V_HMA_NUM_PG_128B_FDBK(x) ((x) << S_HMA_NUM_PG_128B_FDBK)
-#define G_HMA_NUM_PG_128B_FDBK(x) (((x) >> S_HMA_NUM_PG_128B_FDBK) & M_HMA_NUM_PG_128B_FDBK)
-
-#define S_HMA_DIS_128B_PG_CNT_FDBK 20
-#define V_HMA_DIS_128B_PG_CNT_FDBK(x) ((x) << S_HMA_DIS_128B_PG_CNT_FDBK)
-#define F_HMA_DIS_128B_PG_CNT_FDBK V_HMA_DIS_128B_PG_CNT_FDBK(1U)
-
-#define S_HMA_DIS_BG_ARB 19
-#define V_HMA_DIS_BG_ARB(x) ((x) << S_HMA_DIS_BG_ARB)
-#define F_HMA_DIS_BG_ARB V_HMA_DIS_BG_ARB(1U)
-
-#define S_HMA_DIS_BANK_FAIR 18
-#define V_HMA_DIS_BANK_FAIR(x) ((x) << S_HMA_DIS_BANK_FAIR)
-#define F_HMA_DIS_BANK_FAIR V_HMA_DIS_BANK_FAIR(1U)
-
-#define S_HMA_DIS_PAGE_HINT 17
-#define V_HMA_DIS_PAGE_HINT(x) ((x) << S_HMA_DIS_PAGE_HINT)
-#define F_HMA_DIS_PAGE_HINT V_HMA_DIS_PAGE_HINT(1U)
-
-#define S_HMA_DIS_ADV_ARB 16
-#define V_HMA_DIS_ADV_ARB(x) ((x) << S_HMA_DIS_ADV_ARB)
-#define F_HMA_DIS_ADV_ARB V_HMA_DIS_ADV_ARB(1U)
-
-#define S_NUM_PG_128B_FDBK 5
-#define M_NUM_PG_128B_FDBK 0x1fU
-#define V_NUM_PG_128B_FDBK(x) ((x) << S_NUM_PG_128B_FDBK)
-#define G_NUM_PG_128B_FDBK(x) (((x) >> S_NUM_PG_128B_FDBK) & M_NUM_PG_128B_FDBK)
-
-#define S_DIS_128B_PG_CNT_FDBK 4
-#define V_DIS_128B_PG_CNT_FDBK(x) ((x) << S_DIS_128B_PG_CNT_FDBK)
-#define F_DIS_128B_PG_CNT_FDBK V_DIS_128B_PG_CNT_FDBK(1U)
-
-#define S_DIS_BG_ARB 3
-#define V_DIS_BG_ARB(x) ((x) << S_DIS_BG_ARB)
-#define F_DIS_BG_ARB V_DIS_BG_ARB(1U)
-
-#define A_MA_TARGET_MEM_ENABLE 0x77d8
-
-#define S_HMA_ENABLE 3
-#define V_HMA_ENABLE(x) ((x) << S_HMA_ENABLE)
-#define F_HMA_ENABLE V_HMA_ENABLE(1U)
-
-#define S_EXT_MEM_ENABLE 2
-#define V_EXT_MEM_ENABLE(x) ((x) << S_EXT_MEM_ENABLE)
-#define F_EXT_MEM_ENABLE V_EXT_MEM_ENABLE(1U)
-
-#define S_EDRAM1_ENABLE 1
-#define V_EDRAM1_ENABLE(x) ((x) << S_EDRAM1_ENABLE)
-#define F_EDRAM1_ENABLE V_EDRAM1_ENABLE(1U)
-
-#define S_EDRAM0_ENABLE 0
-#define V_EDRAM0_ENABLE(x) ((x) << S_EDRAM0_ENABLE)
-#define F_EDRAM0_ENABLE V_EDRAM0_ENABLE(1U)
-
-#define S_HMA_MUX 5
-#define V_HMA_MUX(x) ((x) << S_HMA_MUX)
-#define F_HMA_MUX V_HMA_MUX(1U)
-
-#define S_EXT_MEM1_ENABLE 4
-#define V_EXT_MEM1_ENABLE(x) ((x) << S_EXT_MEM1_ENABLE)
-#define F_EXT_MEM1_ENABLE V_EXT_MEM1_ENABLE(1U)
-
-#define S_EXT_MEM0_ENABLE 2
-#define V_EXT_MEM0_ENABLE(x) ((x) << S_EXT_MEM0_ENABLE)
-#define F_EXT_MEM0_ENABLE V_EXT_MEM0_ENABLE(1U)
-
-#define S_MC_SPLIT 6
-#define V_MC_SPLIT(x) ((x) << S_MC_SPLIT)
-#define F_MC_SPLIT V_MC_SPLIT(1U)
-
-#define A_MA_INT_ENABLE 0x77dc
-
-#define S_MEM_PERR_INT_ENABLE 1
-#define V_MEM_PERR_INT_ENABLE(x) ((x) << S_MEM_PERR_INT_ENABLE)
-#define F_MEM_PERR_INT_ENABLE V_MEM_PERR_INT_ENABLE(1U)
-
-#define S_MEM_WRAP_INT_ENABLE 0
-#define V_MEM_WRAP_INT_ENABLE(x) ((x) << S_MEM_WRAP_INT_ENABLE)
-#define F_MEM_WRAP_INT_ENABLE V_MEM_WRAP_INT_ENABLE(1U)
-
-#define S_MEM_TO_INT_ENABLE 2
-#define V_MEM_TO_INT_ENABLE(x) ((x) << S_MEM_TO_INT_ENABLE)
-#define F_MEM_TO_INT_ENABLE V_MEM_TO_INT_ENABLE(1U)
-
-#define A_MA_INT_CAUSE 0x77e0
-
-#define S_MEM_PERR_INT_CAUSE 1
-#define V_MEM_PERR_INT_CAUSE(x) ((x) << S_MEM_PERR_INT_CAUSE)
-#define F_MEM_PERR_INT_CAUSE V_MEM_PERR_INT_CAUSE(1U)
-
-#define S_MEM_WRAP_INT_CAUSE 0
-#define V_MEM_WRAP_INT_CAUSE(x) ((x) << S_MEM_WRAP_INT_CAUSE)
-#define F_MEM_WRAP_INT_CAUSE V_MEM_WRAP_INT_CAUSE(1U)
-
-#define S_MEM_TO_INT_CAUSE 2
-#define V_MEM_TO_INT_CAUSE(x) ((x) << S_MEM_TO_INT_CAUSE)
-#define F_MEM_TO_INT_CAUSE V_MEM_TO_INT_CAUSE(1U)
-
-#define A_MA_INT_WRAP_STATUS 0x77e4
-
-#define S_MEM_WRAP_ADDRESS 4
-#define M_MEM_WRAP_ADDRESS 0xfffffffU
-#define V_MEM_WRAP_ADDRESS(x) ((x) << S_MEM_WRAP_ADDRESS)
-#define G_MEM_WRAP_ADDRESS(x) (((x) >> S_MEM_WRAP_ADDRESS) & M_MEM_WRAP_ADDRESS)
-
-#define S_MEM_WRAP_CLIENT_NUM 0
-#define M_MEM_WRAP_CLIENT_NUM 0xfU
-#define V_MEM_WRAP_CLIENT_NUM(x) ((x) << S_MEM_WRAP_CLIENT_NUM)
-#define G_MEM_WRAP_CLIENT_NUM(x) (((x) >> S_MEM_WRAP_CLIENT_NUM) & M_MEM_WRAP_CLIENT_NUM)
-
-#define A_MA_TP_THREAD1_MAPPER 0x77e8
-
-#define S_TP_THREAD1_EN 0
-#define M_TP_THREAD1_EN 0xffU
-#define V_TP_THREAD1_EN(x) ((x) << S_TP_THREAD1_EN)
-#define G_TP_THREAD1_EN(x) (((x) >> S_TP_THREAD1_EN) & M_TP_THREAD1_EN)
-
-#define A_MA_SGE_THREAD1_MAPPER 0x77ec
-
-#define S_SGE_THREAD1_EN 0
-#define M_SGE_THREAD1_EN 0xffU
-#define V_SGE_THREAD1_EN(x) ((x) << S_SGE_THREAD1_EN)
-#define G_SGE_THREAD1_EN(x) (((x) >> S_SGE_THREAD1_EN) & M_SGE_THREAD1_EN)
-
-#define A_MA_PARITY_ERROR_ENABLE 0x77f0
-
-#define S_TP_DMARBT_PAR_ERROR_EN 31
-#define V_TP_DMARBT_PAR_ERROR_EN(x) ((x) << S_TP_DMARBT_PAR_ERROR_EN)
-#define F_TP_DMARBT_PAR_ERROR_EN V_TP_DMARBT_PAR_ERROR_EN(1U)
-
-#define S_LOGIC_FIFO_PAR_ERROR_EN 30
-#define V_LOGIC_FIFO_PAR_ERROR_EN(x) ((x) << S_LOGIC_FIFO_PAR_ERROR_EN)
-#define F_LOGIC_FIFO_PAR_ERROR_EN V_LOGIC_FIFO_PAR_ERROR_EN(1U)
-
-#define S_ARB3_PAR_WRQUEUE_ERROR_EN 29
-#define V_ARB3_PAR_WRQUEUE_ERROR_EN(x) ((x) << S_ARB3_PAR_WRQUEUE_ERROR_EN)
-#define F_ARB3_PAR_WRQUEUE_ERROR_EN V_ARB3_PAR_WRQUEUE_ERROR_EN(1U)
-
-#define S_ARB2_PAR_WRQUEUE_ERROR_EN 28
-#define V_ARB2_PAR_WRQUEUE_ERROR_EN(x) ((x) << S_ARB2_PAR_WRQUEUE_ERROR_EN)
-#define F_ARB2_PAR_WRQUEUE_ERROR_EN V_ARB2_PAR_WRQUEUE_ERROR_EN(1U)
-
-#define S_ARB1_PAR_WRQUEUE_ERROR_EN 27
-#define V_ARB1_PAR_WRQUEUE_ERROR_EN(x) ((x) << S_ARB1_PAR_WRQUEUE_ERROR_EN)
-#define F_ARB1_PAR_WRQUEUE_ERROR_EN V_ARB1_PAR_WRQUEUE_ERROR_EN(1U)
-
-#define S_ARB0_PAR_WRQUEUE_ERROR_EN 26
-#define V_ARB0_PAR_WRQUEUE_ERROR_EN(x) ((x) << S_ARB0_PAR_WRQUEUE_ERROR_EN)
-#define F_ARB0_PAR_WRQUEUE_ERROR_EN V_ARB0_PAR_WRQUEUE_ERROR_EN(1U)
-
-#define S_ARB3_PAR_RDQUEUE_ERROR_EN 25
-#define V_ARB3_PAR_RDQUEUE_ERROR_EN(x) ((x) << S_ARB3_PAR_RDQUEUE_ERROR_EN)
-#define F_ARB3_PAR_RDQUEUE_ERROR_EN V_ARB3_PAR_RDQUEUE_ERROR_EN(1U)
-
-#define S_ARB2_PAR_RDQUEUE_ERROR_EN 24
-#define V_ARB2_PAR_RDQUEUE_ERROR_EN(x) ((x) << S_ARB2_PAR_RDQUEUE_ERROR_EN)
-#define F_ARB2_PAR_RDQUEUE_ERROR_EN V_ARB2_PAR_RDQUEUE_ERROR_EN(1U)
-
-#define S_ARB1_PAR_RDQUEUE_ERROR_EN 23
-#define V_ARB1_PAR_RDQUEUE_ERROR_EN(x) ((x) << S_ARB1_PAR_RDQUEUE_ERROR_EN)
-#define F_ARB1_PAR_RDQUEUE_ERROR_EN V_ARB1_PAR_RDQUEUE_ERROR_EN(1U)
-
-#define S_ARB0_PAR_RDQUEUE_ERROR_EN 22
-#define V_ARB0_PAR_RDQUEUE_ERROR_EN(x) ((x) << S_ARB0_PAR_RDQUEUE_ERROR_EN)
-#define F_ARB0_PAR_RDQUEUE_ERROR_EN V_ARB0_PAR_RDQUEUE_ERROR_EN(1U)
-
-#define S_CL10_PAR_WRQUEUE_ERROR_EN 21
-#define V_CL10_PAR_WRQUEUE_ERROR_EN(x) ((x) << S_CL10_PAR_WRQUEUE_ERROR_EN)
-#define F_CL10_PAR_WRQUEUE_ERROR_EN V_CL10_PAR_WRQUEUE_ERROR_EN(1U)
-
-#define S_CL9_PAR_WRQUEUE_ERROR_EN 20
-#define V_CL9_PAR_WRQUEUE_ERROR_EN(x) ((x) << S_CL9_PAR_WRQUEUE_ERROR_EN)
-#define F_CL9_PAR_WRQUEUE_ERROR_EN V_CL9_PAR_WRQUEUE_ERROR_EN(1U)
-
-#define S_CL8_PAR_WRQUEUE_ERROR_EN 19
-#define V_CL8_PAR_WRQUEUE_ERROR_EN(x) ((x) << S_CL8_PAR_WRQUEUE_ERROR_EN)
-#define F_CL8_PAR_WRQUEUE_ERROR_EN V_CL8_PAR_WRQUEUE_ERROR_EN(1U)
-
-#define S_CL7_PAR_WRQUEUE_ERROR_EN 18
-#define V_CL7_PAR_WRQUEUE_ERROR_EN(x) ((x) << S_CL7_PAR_WRQUEUE_ERROR_EN)
-#define F_CL7_PAR_WRQUEUE_ERROR_EN V_CL7_PAR_WRQUEUE_ERROR_EN(1U)
-
-#define S_CL6_PAR_WRQUEUE_ERROR_EN 17
-#define V_CL6_PAR_WRQUEUE_ERROR_EN(x) ((x) << S_CL6_PAR_WRQUEUE_ERROR_EN)
-#define F_CL6_PAR_WRQUEUE_ERROR_EN V_CL6_PAR_WRQUEUE_ERROR_EN(1U)
-
-#define S_CL5_PAR_WRQUEUE_ERROR_EN 16
-#define V_CL5_PAR_WRQUEUE_ERROR_EN(x) ((x) << S_CL5_PAR_WRQUEUE_ERROR_EN)
-#define F_CL5_PAR_WRQUEUE_ERROR_EN V_CL5_PAR_WRQUEUE_ERROR_EN(1U)
-
-#define S_CL4_PAR_WRQUEUE_ERROR_EN 15
-#define V_CL4_PAR_WRQUEUE_ERROR_EN(x) ((x) << S_CL4_PAR_WRQUEUE_ERROR_EN)
-#define F_CL4_PAR_WRQUEUE_ERROR_EN V_CL4_PAR_WRQUEUE_ERROR_EN(1U)
-
-#define S_CL3_PAR_WRQUEUE_ERROR_EN 14
-#define V_CL3_PAR_WRQUEUE_ERROR_EN(x) ((x) << S_CL3_PAR_WRQUEUE_ERROR_EN)
-#define F_CL3_PAR_WRQUEUE_ERROR_EN V_CL3_PAR_WRQUEUE_ERROR_EN(1U)
-
-#define S_CL2_PAR_WRQUEUE_ERROR_EN 13
-#define V_CL2_PAR_WRQUEUE_ERROR_EN(x) ((x) << S_CL2_PAR_WRQUEUE_ERROR_EN)
-#define F_CL2_PAR_WRQUEUE_ERROR_EN V_CL2_PAR_WRQUEUE_ERROR_EN(1U)
-
-#define S_CL1_PAR_WRQUEUE_ERROR_EN 12
-#define V_CL1_PAR_WRQUEUE_ERROR_EN(x) ((x) << S_CL1_PAR_WRQUEUE_ERROR_EN)
-#define F_CL1_PAR_WRQUEUE_ERROR_EN V_CL1_PAR_WRQUEUE_ERROR_EN(1U)
-
-#define S_CL0_PAR_WRQUEUE_ERROR_EN 11
-#define V_CL0_PAR_WRQUEUE_ERROR_EN(x) ((x) << S_CL0_PAR_WRQUEUE_ERROR_EN)
-#define F_CL0_PAR_WRQUEUE_ERROR_EN V_CL0_PAR_WRQUEUE_ERROR_EN(1U)
-
-#define S_CL10_PAR_RDQUEUE_ERROR_EN 10
-#define V_CL10_PAR_RDQUEUE_ERROR_EN(x) ((x) << S_CL10_PAR_RDQUEUE_ERROR_EN)
-#define F_CL10_PAR_RDQUEUE_ERROR_EN V_CL10_PAR_RDQUEUE_ERROR_EN(1U)
-
-#define S_CL9_PAR_RDQUEUE_ERROR_EN 9
-#define V_CL9_PAR_RDQUEUE_ERROR_EN(x) ((x) << S_CL9_PAR_RDQUEUE_ERROR_EN)
-#define F_CL9_PAR_RDQUEUE_ERROR_EN V_CL9_PAR_RDQUEUE_ERROR_EN(1U)
-
-#define S_CL8_PAR_RDQUEUE_ERROR_EN 8
-#define V_CL8_PAR_RDQUEUE_ERROR_EN(x) ((x) << S_CL8_PAR_RDQUEUE_ERROR_EN)
-#define F_CL8_PAR_RDQUEUE_ERROR_EN V_CL8_PAR_RDQUEUE_ERROR_EN(1U)
-
-#define S_CL7_PAR_RDQUEUE_ERROR_EN 7
-#define V_CL7_PAR_RDQUEUE_ERROR_EN(x) ((x) << S_CL7_PAR_RDQUEUE_ERROR_EN)
-#define F_CL7_PAR_RDQUEUE_ERROR_EN V_CL7_PAR_RDQUEUE_ERROR_EN(1U)
-
-#define S_CL6_PAR_RDQUEUE_ERROR_EN 6
-#define V_CL6_PAR_RDQUEUE_ERROR_EN(x) ((x) << S_CL6_PAR_RDQUEUE_ERROR_EN)
-#define F_CL6_PAR_RDQUEUE_ERROR_EN V_CL6_PAR_RDQUEUE_ERROR_EN(1U)
-
-#define S_CL5_PAR_RDQUEUE_ERROR_EN 5
-#define V_CL5_PAR_RDQUEUE_ERROR_EN(x) ((x) << S_CL5_PAR_RDQUEUE_ERROR_EN)
-#define F_CL5_PAR_RDQUEUE_ERROR_EN V_CL5_PAR_RDQUEUE_ERROR_EN(1U)
-
-#define S_CL4_PAR_RDQUEUE_ERROR_EN 4
-#define V_CL4_PAR_RDQUEUE_ERROR_EN(x) ((x) << S_CL4_PAR_RDQUEUE_ERROR_EN)
-#define F_CL4_PAR_RDQUEUE_ERROR_EN V_CL4_PAR_RDQUEUE_ERROR_EN(1U)
-
-#define S_CL3_PAR_RDQUEUE_ERROR_EN 3
-#define V_CL3_PAR_RDQUEUE_ERROR_EN(x) ((x) << S_CL3_PAR_RDQUEUE_ERROR_EN)
-#define F_CL3_PAR_RDQUEUE_ERROR_EN V_CL3_PAR_RDQUEUE_ERROR_EN(1U)
-
-#define S_CL2_PAR_RDQUEUE_ERROR_EN 2
-#define V_CL2_PAR_RDQUEUE_ERROR_EN(x) ((x) << S_CL2_PAR_RDQUEUE_ERROR_EN)
-#define F_CL2_PAR_RDQUEUE_ERROR_EN V_CL2_PAR_RDQUEUE_ERROR_EN(1U)
-
-#define S_CL1_PAR_RDQUEUE_ERROR_EN 1
-#define V_CL1_PAR_RDQUEUE_ERROR_EN(x) ((x) << S_CL1_PAR_RDQUEUE_ERROR_EN)
-#define F_CL1_PAR_RDQUEUE_ERROR_EN V_CL1_PAR_RDQUEUE_ERROR_EN(1U)
-
-#define S_CL0_PAR_RDQUEUE_ERROR_EN 0
-#define V_CL0_PAR_RDQUEUE_ERROR_EN(x) ((x) << S_CL0_PAR_RDQUEUE_ERROR_EN)
-#define F_CL0_PAR_RDQUEUE_ERROR_EN V_CL0_PAR_RDQUEUE_ERROR_EN(1U)
-
-#define A_MA_PARITY_ERROR_ENABLE1 0x77f0
-#define A_MA_PARITY_ERROR_STATUS 0x77f4
-
-#define S_TP_DMARBT_PAR_ERROR 31
-#define V_TP_DMARBT_PAR_ERROR(x) ((x) << S_TP_DMARBT_PAR_ERROR)
-#define F_TP_DMARBT_PAR_ERROR V_TP_DMARBT_PAR_ERROR(1U)
-
-#define S_LOGIC_FIFO_PAR_ERROR 30
-#define V_LOGIC_FIFO_PAR_ERROR(x) ((x) << S_LOGIC_FIFO_PAR_ERROR)
-#define F_LOGIC_FIFO_PAR_ERROR V_LOGIC_FIFO_PAR_ERROR(1U)
-
-#define S_ARB3_PAR_WRQUEUE_ERROR 29
-#define V_ARB3_PAR_WRQUEUE_ERROR(x) ((x) << S_ARB3_PAR_WRQUEUE_ERROR)
-#define F_ARB3_PAR_WRQUEUE_ERROR V_ARB3_PAR_WRQUEUE_ERROR(1U)
-
-#define S_ARB2_PAR_WRQUEUE_ERROR 28
-#define V_ARB2_PAR_WRQUEUE_ERROR(x) ((x) << S_ARB2_PAR_WRQUEUE_ERROR)
-#define F_ARB2_PAR_WRQUEUE_ERROR V_ARB2_PAR_WRQUEUE_ERROR(1U)
-
-#define S_ARB1_PAR_WRQUEUE_ERROR 27
-#define V_ARB1_PAR_WRQUEUE_ERROR(x) ((x) << S_ARB1_PAR_WRQUEUE_ERROR)
-#define F_ARB1_PAR_WRQUEUE_ERROR V_ARB1_PAR_WRQUEUE_ERROR(1U)
-
-#define S_ARB0_PAR_WRQUEUE_ERROR 26
-#define V_ARB0_PAR_WRQUEUE_ERROR(x) ((x) << S_ARB0_PAR_WRQUEUE_ERROR)
-#define F_ARB0_PAR_WRQUEUE_ERROR V_ARB0_PAR_WRQUEUE_ERROR(1U)
-
-#define S_ARB3_PAR_RDQUEUE_ERROR 25
-#define V_ARB3_PAR_RDQUEUE_ERROR(x) ((x) << S_ARB3_PAR_RDQUEUE_ERROR)
-#define F_ARB3_PAR_RDQUEUE_ERROR V_ARB3_PAR_RDQUEUE_ERROR(1U)
-
-#define S_ARB2_PAR_RDQUEUE_ERROR 24
-#define V_ARB2_PAR_RDQUEUE_ERROR(x) ((x) << S_ARB2_PAR_RDQUEUE_ERROR)
-#define F_ARB2_PAR_RDQUEUE_ERROR V_ARB2_PAR_RDQUEUE_ERROR(1U)
-
-#define S_ARB1_PAR_RDQUEUE_ERROR 23
-#define V_ARB1_PAR_RDQUEUE_ERROR(x) ((x) << S_ARB1_PAR_RDQUEUE_ERROR)
-#define F_ARB1_PAR_RDQUEUE_ERROR V_ARB1_PAR_RDQUEUE_ERROR(1U)
-
-#define S_ARB0_PAR_RDQUEUE_ERROR 22
-#define V_ARB0_PAR_RDQUEUE_ERROR(x) ((x) << S_ARB0_PAR_RDQUEUE_ERROR)
-#define F_ARB0_PAR_RDQUEUE_ERROR V_ARB0_PAR_RDQUEUE_ERROR(1U)
-
-#define S_CL10_PAR_WRQUEUE_ERROR 21
-#define V_CL10_PAR_WRQUEUE_ERROR(x) ((x) << S_CL10_PAR_WRQUEUE_ERROR)
-#define F_CL10_PAR_WRQUEUE_ERROR V_CL10_PAR_WRQUEUE_ERROR(1U)
-
-#define S_CL9_PAR_WRQUEUE_ERROR 20
-#define V_CL9_PAR_WRQUEUE_ERROR(x) ((x) << S_CL9_PAR_WRQUEUE_ERROR)
-#define F_CL9_PAR_WRQUEUE_ERROR V_CL9_PAR_WRQUEUE_ERROR(1U)
-
-#define S_CL8_PAR_WRQUEUE_ERROR 19
-#define V_CL8_PAR_WRQUEUE_ERROR(x) ((x) << S_CL8_PAR_WRQUEUE_ERROR)
-#define F_CL8_PAR_WRQUEUE_ERROR V_CL8_PAR_WRQUEUE_ERROR(1U)
-
-#define S_CL7_PAR_WRQUEUE_ERROR 18
-#define V_CL7_PAR_WRQUEUE_ERROR(x) ((x) << S_CL7_PAR_WRQUEUE_ERROR)
-#define F_CL7_PAR_WRQUEUE_ERROR V_CL7_PAR_WRQUEUE_ERROR(1U)
-
-#define S_CL6_PAR_WRQUEUE_ERROR 17
-#define V_CL6_PAR_WRQUEUE_ERROR(x) ((x) << S_CL6_PAR_WRQUEUE_ERROR)
-#define F_CL6_PAR_WRQUEUE_ERROR V_CL6_PAR_WRQUEUE_ERROR(1U)
-
-#define S_CL5_PAR_WRQUEUE_ERROR 16
-#define V_CL5_PAR_WRQUEUE_ERROR(x) ((x) << S_CL5_PAR_WRQUEUE_ERROR)
-#define F_CL5_PAR_WRQUEUE_ERROR V_CL5_PAR_WRQUEUE_ERROR(1U)
-
-#define S_CL4_PAR_WRQUEUE_ERROR 15
-#define V_CL4_PAR_WRQUEUE_ERROR(x) ((x) << S_CL4_PAR_WRQUEUE_ERROR)
-#define F_CL4_PAR_WRQUEUE_ERROR V_CL4_PAR_WRQUEUE_ERROR(1U)
-
-#define S_CL3_PAR_WRQUEUE_ERROR 14
-#define V_CL3_PAR_WRQUEUE_ERROR(x) ((x) << S_CL3_PAR_WRQUEUE_ERROR)
-#define F_CL3_PAR_WRQUEUE_ERROR V_CL3_PAR_WRQUEUE_ERROR(1U)
-
-#define S_CL2_PAR_WRQUEUE_ERROR 13
-#define V_CL2_PAR_WRQUEUE_ERROR(x) ((x) << S_CL2_PAR_WRQUEUE_ERROR)
-#define F_CL2_PAR_WRQUEUE_ERROR V_CL2_PAR_WRQUEUE_ERROR(1U)
-
-#define S_CL1_PAR_WRQUEUE_ERROR 12
-#define V_CL1_PAR_WRQUEUE_ERROR(x) ((x) << S_CL1_PAR_WRQUEUE_ERROR)
-#define F_CL1_PAR_WRQUEUE_ERROR V_CL1_PAR_WRQUEUE_ERROR(1U)
-
-#define S_CL0_PAR_WRQUEUE_ERROR 11
-#define V_CL0_PAR_WRQUEUE_ERROR(x) ((x) << S_CL0_PAR_WRQUEUE_ERROR)
-#define F_CL0_PAR_WRQUEUE_ERROR V_CL0_PAR_WRQUEUE_ERROR(1U)
-
-#define S_CL10_PAR_RDQUEUE_ERROR 10
-#define V_CL10_PAR_RDQUEUE_ERROR(x) ((x) << S_CL10_PAR_RDQUEUE_ERROR)
-#define F_CL10_PAR_RDQUEUE_ERROR V_CL10_PAR_RDQUEUE_ERROR(1U)
-
-#define S_CL9_PAR_RDQUEUE_ERROR 9
-#define V_CL9_PAR_RDQUEUE_ERROR(x) ((x) << S_CL9_PAR_RDQUEUE_ERROR)
-#define F_CL9_PAR_RDQUEUE_ERROR V_CL9_PAR_RDQUEUE_ERROR(1U)
-
-#define S_CL8_PAR_RDQUEUE_ERROR 8
-#define V_CL8_PAR_RDQUEUE_ERROR(x) ((x) << S_CL8_PAR_RDQUEUE_ERROR)
-#define F_CL8_PAR_RDQUEUE_ERROR V_CL8_PAR_RDQUEUE_ERROR(1U)
-
-#define S_CL7_PAR_RDQUEUE_ERROR 7
-#define V_CL7_PAR_RDQUEUE_ERROR(x) ((x) << S_CL7_PAR_RDQUEUE_ERROR)
-#define F_CL7_PAR_RDQUEUE_ERROR V_CL7_PAR_RDQUEUE_ERROR(1U)
-
-#define S_CL6_PAR_RDQUEUE_ERROR 6
-#define V_CL6_PAR_RDQUEUE_ERROR(x) ((x) << S_CL6_PAR_RDQUEUE_ERROR)
-#define F_CL6_PAR_RDQUEUE_ERROR V_CL6_PAR_RDQUEUE_ERROR(1U)
-
-#define S_CL5_PAR_RDQUEUE_ERROR 5
-#define V_CL5_PAR_RDQUEUE_ERROR(x) ((x) << S_CL5_PAR_RDQUEUE_ERROR)
-#define F_CL5_PAR_RDQUEUE_ERROR V_CL5_PAR_RDQUEUE_ERROR(1U)
-
-#define S_CL4_PAR_RDQUEUE_ERROR 4
-#define V_CL4_PAR_RDQUEUE_ERROR(x) ((x) << S_CL4_PAR_RDQUEUE_ERROR)
-#define F_CL4_PAR_RDQUEUE_ERROR V_CL4_PAR_RDQUEUE_ERROR(1U)
-
-#define S_CL3_PAR_RDQUEUE_ERROR 3
-#define V_CL3_PAR_RDQUEUE_ERROR(x) ((x) << S_CL3_PAR_RDQUEUE_ERROR)
-#define F_CL3_PAR_RDQUEUE_ERROR V_CL3_PAR_RDQUEUE_ERROR(1U)
-
-#define S_CL2_PAR_RDQUEUE_ERROR 2
-#define V_CL2_PAR_RDQUEUE_ERROR(x) ((x) << S_CL2_PAR_RDQUEUE_ERROR)
-#define F_CL2_PAR_RDQUEUE_ERROR V_CL2_PAR_RDQUEUE_ERROR(1U)
-
-#define S_CL1_PAR_RDQUEUE_ERROR 1
-#define V_CL1_PAR_RDQUEUE_ERROR(x) ((x) << S_CL1_PAR_RDQUEUE_ERROR)
-#define F_CL1_PAR_RDQUEUE_ERROR V_CL1_PAR_RDQUEUE_ERROR(1U)
-
-#define S_CL0_PAR_RDQUEUE_ERROR 0
-#define V_CL0_PAR_RDQUEUE_ERROR(x) ((x) << S_CL0_PAR_RDQUEUE_ERROR)
-#define F_CL0_PAR_RDQUEUE_ERROR V_CL0_PAR_RDQUEUE_ERROR(1U)
-
-#define A_MA_PARITY_ERROR_STATUS1 0x77f4
-#define A_MA_SGE_PCIE_COHERANCY_CTRL 0x77f8
-
-#define S_BONUS_REG 6
-#define M_BONUS_REG 0x3ffffffU
-#define V_BONUS_REG(x) ((x) << S_BONUS_REG)
-#define G_BONUS_REG(x) (((x) >> S_BONUS_REG) & M_BONUS_REG)
-
-#define S_COHERANCY_CMD_TYPE 4
-#define M_COHERANCY_CMD_TYPE 0x3U
-#define V_COHERANCY_CMD_TYPE(x) ((x) << S_COHERANCY_CMD_TYPE)
-#define G_COHERANCY_CMD_TYPE(x) (((x) >> S_COHERANCY_CMD_TYPE) & M_COHERANCY_CMD_TYPE)
-
-#define S_COHERANCY_THREAD_NUM 1
-#define M_COHERANCY_THREAD_NUM 0x7U
-#define V_COHERANCY_THREAD_NUM(x) ((x) << S_COHERANCY_THREAD_NUM)
-#define G_COHERANCY_THREAD_NUM(x) (((x) >> S_COHERANCY_THREAD_NUM) & M_COHERANCY_THREAD_NUM)
-
-#define S_COHERANCY_ENABLE 0
-#define V_COHERANCY_ENABLE(x) ((x) << S_COHERANCY_ENABLE)
-#define F_COHERANCY_ENABLE V_COHERANCY_ENABLE(1U)
-
-#define A_MA_ERROR_ENABLE 0x77fc
-
-#define S_UE_ENABLE 0
-#define V_UE_ENABLE(x) ((x) << S_UE_ENABLE)
-#define F_UE_ENABLE V_UE_ENABLE(1U)
-
-#define S_FUTURE_EXPANSION 1
-#define M_FUTURE_EXPANSION 0x7fffffffU
-#define V_FUTURE_EXPANSION(x) ((x) << S_FUTURE_EXPANSION)
-#define G_FUTURE_EXPANSION(x) (((x) >> S_FUTURE_EXPANSION) & M_FUTURE_EXPANSION)
-
-#define S_FUTURE_EXPANSION_EE 1
-#define M_FUTURE_EXPANSION_EE 0x7fffffffU
-#define V_FUTURE_EXPANSION_EE(x) ((x) << S_FUTURE_EXPANSION_EE)
-#define G_FUTURE_EXPANSION_EE(x) (((x) >> S_FUTURE_EXPANSION_EE) & M_FUTURE_EXPANSION_EE)
-
-#define A_MA_PARITY_ERROR_ENABLE2 0x7800
-
-#define S_ARB4_PAR_WRQUEUE_ERROR_EN 1
-#define V_ARB4_PAR_WRQUEUE_ERROR_EN(x) ((x) << S_ARB4_PAR_WRQUEUE_ERROR_EN)
-#define F_ARB4_PAR_WRQUEUE_ERROR_EN V_ARB4_PAR_WRQUEUE_ERROR_EN(1U)
-
-#define S_ARB4_PAR_RDQUEUE_ERROR_EN 0
-#define V_ARB4_PAR_RDQUEUE_ERROR_EN(x) ((x) << S_ARB4_PAR_RDQUEUE_ERROR_EN)
-#define F_ARB4_PAR_RDQUEUE_ERROR_EN V_ARB4_PAR_RDQUEUE_ERROR_EN(1U)
-
-#define A_MA_PARITY_ERROR_STATUS2 0x7804
-
-#define S_ARB4_PAR_WRQUEUE_ERROR 1
-#define V_ARB4_PAR_WRQUEUE_ERROR(x) ((x) << S_ARB4_PAR_WRQUEUE_ERROR)
-#define F_ARB4_PAR_WRQUEUE_ERROR V_ARB4_PAR_WRQUEUE_ERROR(1U)
-
-#define S_ARB4_PAR_RDQUEUE_ERROR 0
-#define V_ARB4_PAR_RDQUEUE_ERROR(x) ((x) << S_ARB4_PAR_RDQUEUE_ERROR)
-#define F_ARB4_PAR_RDQUEUE_ERROR V_ARB4_PAR_RDQUEUE_ERROR(1U)
-
-#define A_MA_EXT_MEMORY1_BAR 0x7808
-
-#define S_EXT_MEM1_BASE 16
-#define M_EXT_MEM1_BASE 0xfffU
-#define V_EXT_MEM1_BASE(x) ((x) << S_EXT_MEM1_BASE)
-#define G_EXT_MEM1_BASE(x) (((x) >> S_EXT_MEM1_BASE) & M_EXT_MEM1_BASE)
-
-#define S_EXT_MEM1_SIZE 0
-#define M_EXT_MEM1_SIZE 0xfffU
-#define V_EXT_MEM1_SIZE(x) ((x) << S_EXT_MEM1_SIZE)
-#define G_EXT_MEM1_SIZE(x) (((x) >> S_EXT_MEM1_SIZE) & M_EXT_MEM1_SIZE)
-
-#define A_MA_PMTX_THROTTLE 0x780c
-
-#define S_FL_ENABLE 31
-#define V_FL_ENABLE(x) ((x) << S_FL_ENABLE)
-#define F_FL_ENABLE V_FL_ENABLE(1U)
-
-#define S_FL_LIMIT 0
-#define M_FL_LIMIT 0xffU
-#define V_FL_LIMIT(x) ((x) << S_FL_LIMIT)
-#define G_FL_LIMIT(x) (((x) >> S_FL_LIMIT) & M_FL_LIMIT)
-
-#define A_MA_PMRX_THROTTLE 0x7810
-#define A_MA_SGE_TH0_WRDATA_CNT 0x7814
-#define A_MA_SGE_TH1_WRDATA_CNT 0x7818
-#define A_MA_ULPTX_WRDATA_CNT 0x781c
-#define A_MA_ULPRX_WRDATA_CNT 0x7820
-#define A_MA_ULPTXRX_WRDATA_CNT 0x7824
-#define A_MA_TP_TH0_WRDATA_CNT 0x7828
-#define A_MA_TP_TH1_WRDATA_CNT 0x782c
-#define A_MA_LE_WRDATA_CNT 0x7830
-#define A_MA_CIM_WRDATA_CNT 0x7834
-#define A_MA_PCIE_WRDATA_CNT 0x7838
-#define A_MA_PMTX_WRDATA_CNT 0x783c
-#define A_MA_PMRX_WRDATA_CNT 0x7840
-#define A_MA_HMA_WRDATA_CNT 0x7844
-#define A_MA_SGE_TH0_RDDATA_CNT 0x7848
-#define A_MA_SGE_TH1_RDDATA_CNT 0x784c
-#define A_MA_ULPTX_RDDATA_CNT 0x7850
-#define A_MA_ULPRX_RDDATA_CNT 0x7854
-#define A_MA_ULPTXRX_RDDATA_CNT 0x7858
-#define A_MA_TP_TH0_RDDATA_CNT 0x785c
-#define A_MA_TP_TH1_RDDATA_CNT 0x7860
-#define A_MA_LE_RDDATA_CNT 0x7864
-#define A_MA_CIM_RDDATA_CNT 0x7868
-#define A_MA_PCIE_RDDATA_CNT 0x786c
-#define A_MA_PMTX_RDDATA_CNT 0x7870
-#define A_MA_PMRX_RDDATA_CNT 0x7874
-#define A_MA_HMA_RDDATA_CNT 0x7878
-#define A_MA_EDRAM0_WRDATA_CNT1 0x787c
-#define A_MA_EXIT_ADDR_FAULT 0x787c
-
-#define S_EXIT_ADDR_FAULT 0
-#define V_EXIT_ADDR_FAULT(x) ((x) << S_EXIT_ADDR_FAULT)
-#define F_EXIT_ADDR_FAULT V_EXIT_ADDR_FAULT(1U)
-
-#define A_MA_EDRAM0_WRDATA_CNT0 0x7880
-#define A_MA_DDR_DEVICE_CFG 0x7880
-
-#define S_MEM_WIDTH 1
-#define M_MEM_WIDTH 0x7U
-#define V_MEM_WIDTH(x) ((x) << S_MEM_WIDTH)
-#define G_MEM_WIDTH(x) (((x) >> S_MEM_WIDTH) & M_MEM_WIDTH)
-
-#define S_DDR_MODE 0
-#define V_DDR_MODE(x) ((x) << S_DDR_MODE)
-#define F_DDR_MODE V_DDR_MODE(1U)
-
-#define A_MA_EDRAM1_WRDATA_CNT1 0x7884
-#define A_MA_EDRAM1_WRDATA_CNT0 0x7888
-#define A_MA_EXT_MEMORY0_WRDATA_CNT1 0x788c
-#define A_MA_EXT_MEMORY0_WRDATA_CNT0 0x7890
-#define A_MA_HOST_MEMORY_WRDATA_CNT1 0x7894
-#define A_MA_HOST_MEMORY_WRDATA_CNT0 0x7898
-#define A_MA_EXT_MEMORY1_WRDATA_CNT1 0x789c
-#define A_MA_EXT_MEMORY1_WRDATA_CNT0 0x78a0
-#define A_MA_EDRAM0_RDDATA_CNT1 0x78a4
-#define A_MA_EDRAM0_RDDATA_CNT0 0x78a8
-#define A_MA_EDRAM1_RDDATA_CNT1 0x78ac
-#define A_MA_EDRAM1_RDDATA_CNT0 0x78b0
-#define A_MA_EXT_MEMORY0_RDDATA_CNT1 0x78b4
-#define A_MA_EXT_MEMORY0_RDDATA_CNT0 0x78b8
-#define A_MA_HOST_MEMORY_RDDATA_CNT1 0x78bc
-#define A_MA_HOST_MEMORY_RDDATA_CNT0 0x78c0
-#define A_MA_EXT_MEMORY1_RDDATA_CNT1 0x78c4
-#define A_MA_EXT_MEMORY1_RDDATA_CNT0 0x78c8
-#define A_MA_TIMEOUT_CFG 0x78cc
-
-#define S_CLR 31
-#define V_CLR(x) ((x) << S_CLR)
-#define F_CLR V_CLR(1U)
-
-#define S_CNT_LOCK 30
-#define V_CNT_LOCK(x) ((x) << S_CNT_LOCK)
-#define F_CNT_LOCK V_CNT_LOCK(1U)
-
-#define S_WRN 24
-#define V_WRN(x) ((x) << S_WRN)
-#define F_WRN V_WRN(1U)
-
-#define S_DIR 23
-#define V_DIR(x) ((x) << S_DIR)
-#define F_DIR V_DIR(1U)
-
-#define S_TO_BUS 22
-#define V_TO_BUS(x) ((x) << S_TO_BUS)
-#define F_TO_BUS V_TO_BUS(1U)
-
-#define S_CLIENT 16
-#define M_CLIENT 0xfU
-#define V_CLIENT(x) ((x) << S_CLIENT)
-#define G_CLIENT(x) (((x) >> S_CLIENT) & M_CLIENT)
-
-#define S_DELAY 0
-#define M_DELAY 0xffffU
-#define V_DELAY(x) ((x) << S_DELAY)
-#define G_DELAY(x) (((x) >> S_DELAY) & M_DELAY)
-
-#define A_MA_TIMEOUT_CNT 0x78d0
-
-#define S_CNT_VAL 0
-#define M_CNT_VAL 0xffffU
-#define V_CNT_VAL(x) ((x) << S_CNT_VAL)
-#define G_CNT_VAL(x) (((x) >> S_CNT_VAL) & M_CNT_VAL)
-
-#define A_MA_WRITE_TIMEOUT_ERROR_ENABLE 0x78d4
-
-#define S_FUTURE_CEXPANSION 29
-#define M_FUTURE_CEXPANSION 0x7U
-#define V_FUTURE_CEXPANSION(x) ((x) << S_FUTURE_CEXPANSION)
-#define G_FUTURE_CEXPANSION(x) (((x) >> S_FUTURE_CEXPANSION) & M_FUTURE_CEXPANSION)
-
-#define S_CL12_WR_CMD_TO_EN 28
-#define V_CL12_WR_CMD_TO_EN(x) ((x) << S_CL12_WR_CMD_TO_EN)
-#define F_CL12_WR_CMD_TO_EN V_CL12_WR_CMD_TO_EN(1U)
-
-#define S_CL11_WR_CMD_TO_EN 27
-#define V_CL11_WR_CMD_TO_EN(x) ((x) << S_CL11_WR_CMD_TO_EN)
-#define F_CL11_WR_CMD_TO_EN V_CL11_WR_CMD_TO_EN(1U)
-
-#define S_CL10_WR_CMD_TO_EN 26
-#define V_CL10_WR_CMD_TO_EN(x) ((x) << S_CL10_WR_CMD_TO_EN)
-#define F_CL10_WR_CMD_TO_EN V_CL10_WR_CMD_TO_EN(1U)
-
-#define S_CL9_WR_CMD_TO_EN 25
-#define V_CL9_WR_CMD_TO_EN(x) ((x) << S_CL9_WR_CMD_TO_EN)
-#define F_CL9_WR_CMD_TO_EN V_CL9_WR_CMD_TO_EN(1U)
-
-#define S_CL8_WR_CMD_TO_EN 24
-#define V_CL8_WR_CMD_TO_EN(x) ((x) << S_CL8_WR_CMD_TO_EN)
-#define F_CL8_WR_CMD_TO_EN V_CL8_WR_CMD_TO_EN(1U)
-
-#define S_CL7_WR_CMD_TO_EN 23
-#define V_CL7_WR_CMD_TO_EN(x) ((x) << S_CL7_WR_CMD_TO_EN)
-#define F_CL7_WR_CMD_TO_EN V_CL7_WR_CMD_TO_EN(1U)
-
-#define S_CL6_WR_CMD_TO_EN 22
-#define V_CL6_WR_CMD_TO_EN(x) ((x) << S_CL6_WR_CMD_TO_EN)
-#define F_CL6_WR_CMD_TO_EN V_CL6_WR_CMD_TO_EN(1U)
-
-#define S_CL5_WR_CMD_TO_EN 21
-#define V_CL5_WR_CMD_TO_EN(x) ((x) << S_CL5_WR_CMD_TO_EN)
-#define F_CL5_WR_CMD_TO_EN V_CL5_WR_CMD_TO_EN(1U)
-
-#define S_CL4_WR_CMD_TO_EN 20
-#define V_CL4_WR_CMD_TO_EN(x) ((x) << S_CL4_WR_CMD_TO_EN)
-#define F_CL4_WR_CMD_TO_EN V_CL4_WR_CMD_TO_EN(1U)
-
-#define S_CL3_WR_CMD_TO_EN 19
-#define V_CL3_WR_CMD_TO_EN(x) ((x) << S_CL3_WR_CMD_TO_EN)
-#define F_CL3_WR_CMD_TO_EN V_CL3_WR_CMD_TO_EN(1U)
-
-#define S_CL2_WR_CMD_TO_EN 18
-#define V_CL2_WR_CMD_TO_EN(x) ((x) << S_CL2_WR_CMD_TO_EN)
-#define F_CL2_WR_CMD_TO_EN V_CL2_WR_CMD_TO_EN(1U)
-
-#define S_CL1_WR_CMD_TO_EN 17
-#define V_CL1_WR_CMD_TO_EN(x) ((x) << S_CL1_WR_CMD_TO_EN)
-#define F_CL1_WR_CMD_TO_EN V_CL1_WR_CMD_TO_EN(1U)
-
-#define S_CL0_WR_CMD_TO_EN 16
-#define V_CL0_WR_CMD_TO_EN(x) ((x) << S_CL0_WR_CMD_TO_EN)
-#define F_CL0_WR_CMD_TO_EN V_CL0_WR_CMD_TO_EN(1U)
-
-#define S_FUTURE_DEXPANSION 13
-#define M_FUTURE_DEXPANSION 0x7U
-#define V_FUTURE_DEXPANSION(x) ((x) << S_FUTURE_DEXPANSION)
-#define G_FUTURE_DEXPANSION(x) (((x) >> S_FUTURE_DEXPANSION) & M_FUTURE_DEXPANSION)
-
-#define S_CL12_WR_DATA_TO_EN 12
-#define V_CL12_WR_DATA_TO_EN(x) ((x) << S_CL12_WR_DATA_TO_EN)
-#define F_CL12_WR_DATA_TO_EN V_CL12_WR_DATA_TO_EN(1U)
-
-#define S_CL11_WR_DATA_TO_EN 11
-#define V_CL11_WR_DATA_TO_EN(x) ((x) << S_CL11_WR_DATA_TO_EN)
-#define F_CL11_WR_DATA_TO_EN V_CL11_WR_DATA_TO_EN(1U)
-
-#define S_CL10_WR_DATA_TO_EN 10
-#define V_CL10_WR_DATA_TO_EN(x) ((x) << S_CL10_WR_DATA_TO_EN)
-#define F_CL10_WR_DATA_TO_EN V_CL10_WR_DATA_TO_EN(1U)
-
-#define S_CL9_WR_DATA_TO_EN 9
-#define V_CL9_WR_DATA_TO_EN(x) ((x) << S_CL9_WR_DATA_TO_EN)
-#define F_CL9_WR_DATA_TO_EN V_CL9_WR_DATA_TO_EN(1U)
-
-#define S_CL8_WR_DATA_TO_EN 8
-#define V_CL8_WR_DATA_TO_EN(x) ((x) << S_CL8_WR_DATA_TO_EN)
-#define F_CL8_WR_DATA_TO_EN V_CL8_WR_DATA_TO_EN(1U)
-
-#define S_CL7_WR_DATA_TO_EN 7
-#define V_CL7_WR_DATA_TO_EN(x) ((x) << S_CL7_WR_DATA_TO_EN)
-#define F_CL7_WR_DATA_TO_EN V_CL7_WR_DATA_TO_EN(1U)
-
-#define S_CL6_WR_DATA_TO_EN 6
-#define V_CL6_WR_DATA_TO_EN(x) ((x) << S_CL6_WR_DATA_TO_EN)
-#define F_CL6_WR_DATA_TO_EN V_CL6_WR_DATA_TO_EN(1U)
-
-#define S_CL5_WR_DATA_TO_EN 5
-#define V_CL5_WR_DATA_TO_EN(x) ((x) << S_CL5_WR_DATA_TO_EN)
-#define F_CL5_WR_DATA_TO_EN V_CL5_WR_DATA_TO_EN(1U)
-
-#define S_CL4_WR_DATA_TO_EN 4
-#define V_CL4_WR_DATA_TO_EN(x) ((x) << S_CL4_WR_DATA_TO_EN)
-#define F_CL4_WR_DATA_TO_EN V_CL4_WR_DATA_TO_EN(1U)
-
-#define S_CL3_WR_DATA_TO_EN 3
-#define V_CL3_WR_DATA_TO_EN(x) ((x) << S_CL3_WR_DATA_TO_EN)
-#define F_CL3_WR_DATA_TO_EN V_CL3_WR_DATA_TO_EN(1U)
-
-#define S_CL2_WR_DATA_TO_EN 2
-#define V_CL2_WR_DATA_TO_EN(x) ((x) << S_CL2_WR_DATA_TO_EN)
-#define F_CL2_WR_DATA_TO_EN V_CL2_WR_DATA_TO_EN(1U)
-
-#define S_CL1_WR_DATA_TO_EN 1
-#define V_CL1_WR_DATA_TO_EN(x) ((x) << S_CL1_WR_DATA_TO_EN)
-#define F_CL1_WR_DATA_TO_EN V_CL1_WR_DATA_TO_EN(1U)
-
-#define S_CL0_WR_DATA_TO_EN 0
-#define V_CL0_WR_DATA_TO_EN(x) ((x) << S_CL0_WR_DATA_TO_EN)
-#define F_CL0_WR_DATA_TO_EN V_CL0_WR_DATA_TO_EN(1U)
-
-#define S_FUTURE_CEXPANSION_WTE 29
-#define M_FUTURE_CEXPANSION_WTE 0x7U
-#define V_FUTURE_CEXPANSION_WTE(x) ((x) << S_FUTURE_CEXPANSION_WTE)
-#define G_FUTURE_CEXPANSION_WTE(x) (((x) >> S_FUTURE_CEXPANSION_WTE) & M_FUTURE_CEXPANSION_WTE)
-
-#define S_FUTURE_DEXPANSION_WTE 13
-#define M_FUTURE_DEXPANSION_WTE 0x7U
-#define V_FUTURE_DEXPANSION_WTE(x) ((x) << S_FUTURE_DEXPANSION_WTE)
-#define G_FUTURE_DEXPANSION_WTE(x) (((x) >> S_FUTURE_DEXPANSION_WTE) & M_FUTURE_DEXPANSION_WTE)
-
-#define A_MA_WRITE_TIMEOUT_ERROR_STATUS 0x78d8
-
-#define S_CL12_WR_CMD_TO_ERROR 28
-#define V_CL12_WR_CMD_TO_ERROR(x) ((x) << S_CL12_WR_CMD_TO_ERROR)
-#define F_CL12_WR_CMD_TO_ERROR V_CL12_WR_CMD_TO_ERROR(1U)
-
-#define S_CL11_WR_CMD_TO_ERROR 27
-#define V_CL11_WR_CMD_TO_ERROR(x) ((x) << S_CL11_WR_CMD_TO_ERROR)
-#define F_CL11_WR_CMD_TO_ERROR V_CL11_WR_CMD_TO_ERROR(1U)
-
-#define S_CL10_WR_CMD_TO_ERROR 26
-#define V_CL10_WR_CMD_TO_ERROR(x) ((x) << S_CL10_WR_CMD_TO_ERROR)
-#define F_CL10_WR_CMD_TO_ERROR V_CL10_WR_CMD_TO_ERROR(1U)
-
-#define S_CL9_WR_CMD_TO_ERROR 25
-#define V_CL9_WR_CMD_TO_ERROR(x) ((x) << S_CL9_WR_CMD_TO_ERROR)
-#define F_CL9_WR_CMD_TO_ERROR V_CL9_WR_CMD_TO_ERROR(1U)
-
-#define S_CL8_WR_CMD_TO_ERROR 24
-#define V_CL8_WR_CMD_TO_ERROR(x) ((x) << S_CL8_WR_CMD_TO_ERROR)
-#define F_CL8_WR_CMD_TO_ERROR V_CL8_WR_CMD_TO_ERROR(1U)
-
-#define S_CL7_WR_CMD_TO_ERROR 23
-#define V_CL7_WR_CMD_TO_ERROR(x) ((x) << S_CL7_WR_CMD_TO_ERROR)
-#define F_CL7_WR_CMD_TO_ERROR V_CL7_WR_CMD_TO_ERROR(1U)
-
-#define S_CL6_WR_CMD_TO_ERROR 22
-#define V_CL6_WR_CMD_TO_ERROR(x) ((x) << S_CL6_WR_CMD_TO_ERROR)
-#define F_CL6_WR_CMD_TO_ERROR V_CL6_WR_CMD_TO_ERROR(1U)
-
-#define S_CL5_WR_CMD_TO_ERROR 21
-#define V_CL5_WR_CMD_TO_ERROR(x) ((x) << S_CL5_WR_CMD_TO_ERROR)
-#define F_CL5_WR_CMD_TO_ERROR V_CL5_WR_CMD_TO_ERROR(1U)
-
-#define S_CL4_WR_CMD_TO_ERROR 20
-#define V_CL4_WR_CMD_TO_ERROR(x) ((x) << S_CL4_WR_CMD_TO_ERROR)
-#define F_CL4_WR_CMD_TO_ERROR V_CL4_WR_CMD_TO_ERROR(1U)
-
-#define S_CL3_WR_CMD_TO_ERROR 19
-#define V_CL3_WR_CMD_TO_ERROR(x) ((x) << S_CL3_WR_CMD_TO_ERROR)
-#define F_CL3_WR_CMD_TO_ERROR V_CL3_WR_CMD_TO_ERROR(1U)
-
-#define S_CL2_WR_CMD_TO_ERROR 18
-#define V_CL2_WR_CMD_TO_ERROR(x) ((x) << S_CL2_WR_CMD_TO_ERROR)
-#define F_CL2_WR_CMD_TO_ERROR V_CL2_WR_CMD_TO_ERROR(1U)
-
-#define S_CL1_WR_CMD_TO_ERROR 17
-#define V_CL1_WR_CMD_TO_ERROR(x) ((x) << S_CL1_WR_CMD_TO_ERROR)
-#define F_CL1_WR_CMD_TO_ERROR V_CL1_WR_CMD_TO_ERROR(1U)
-
-#define S_CL0_WR_CMD_TO_ERROR 16
-#define V_CL0_WR_CMD_TO_ERROR(x) ((x) << S_CL0_WR_CMD_TO_ERROR)
-#define F_CL0_WR_CMD_TO_ERROR V_CL0_WR_CMD_TO_ERROR(1U)
-
-#define S_CL12_WR_DATA_TO_ERROR 12
-#define V_CL12_WR_DATA_TO_ERROR(x) ((x) << S_CL12_WR_DATA_TO_ERROR)
-#define F_CL12_WR_DATA_TO_ERROR V_CL12_WR_DATA_TO_ERROR(1U)
-
-#define S_CL11_WR_DATA_TO_ERROR 11
-#define V_CL11_WR_DATA_TO_ERROR(x) ((x) << S_CL11_WR_DATA_TO_ERROR)
-#define F_CL11_WR_DATA_TO_ERROR V_CL11_WR_DATA_TO_ERROR(1U)
-
-#define S_CL10_WR_DATA_TO_ERROR 10
-#define V_CL10_WR_DATA_TO_ERROR(x) ((x) << S_CL10_WR_DATA_TO_ERROR)
-#define F_CL10_WR_DATA_TO_ERROR V_CL10_WR_DATA_TO_ERROR(1U)
-
-#define S_CL9_WR_DATA_TO_ERROR 9
-#define V_CL9_WR_DATA_TO_ERROR(x) ((x) << S_CL9_WR_DATA_TO_ERROR)
-#define F_CL9_WR_DATA_TO_ERROR V_CL9_WR_DATA_TO_ERROR(1U)
-
-#define S_CL8_WR_DATA_TO_ERROR 8
-#define V_CL8_WR_DATA_TO_ERROR(x) ((x) << S_CL8_WR_DATA_TO_ERROR)
-#define F_CL8_WR_DATA_TO_ERROR V_CL8_WR_DATA_TO_ERROR(1U)
-
-#define S_CL7_WR_DATA_TO_ERROR 7
-#define V_CL7_WR_DATA_TO_ERROR(x) ((x) << S_CL7_WR_DATA_TO_ERROR)
-#define F_CL7_WR_DATA_TO_ERROR V_CL7_WR_DATA_TO_ERROR(1U)
-
-#define S_CL6_WR_DATA_TO_ERROR 6
-#define V_CL6_WR_DATA_TO_ERROR(x) ((x) << S_CL6_WR_DATA_TO_ERROR)
-#define F_CL6_WR_DATA_TO_ERROR V_CL6_WR_DATA_TO_ERROR(1U)
-
-#define S_CL5_WR_DATA_TO_ERROR 5
-#define V_CL5_WR_DATA_TO_ERROR(x) ((x) << S_CL5_WR_DATA_TO_ERROR)
-#define F_CL5_WR_DATA_TO_ERROR V_CL5_WR_DATA_TO_ERROR(1U)
-
-#define S_CL4_WR_DATA_TO_ERROR 4
-#define V_CL4_WR_DATA_TO_ERROR(x) ((x) << S_CL4_WR_DATA_TO_ERROR)
-#define F_CL4_WR_DATA_TO_ERROR V_CL4_WR_DATA_TO_ERROR(1U)
-
-#define S_CL3_WR_DATA_TO_ERROR 3
-#define V_CL3_WR_DATA_TO_ERROR(x) ((x) << S_CL3_WR_DATA_TO_ERROR)
-#define F_CL3_WR_DATA_TO_ERROR V_CL3_WR_DATA_TO_ERROR(1U)
-
-#define S_CL2_WR_DATA_TO_ERROR 2
-#define V_CL2_WR_DATA_TO_ERROR(x) ((x) << S_CL2_WR_DATA_TO_ERROR)
-#define F_CL2_WR_DATA_TO_ERROR V_CL2_WR_DATA_TO_ERROR(1U)
-
-#define S_CL1_WR_DATA_TO_ERROR 1
-#define V_CL1_WR_DATA_TO_ERROR(x) ((x) << S_CL1_WR_DATA_TO_ERROR)
-#define F_CL1_WR_DATA_TO_ERROR V_CL1_WR_DATA_TO_ERROR(1U)
-
-#define S_CL0_WR_DATA_TO_ERROR 0
-#define V_CL0_WR_DATA_TO_ERROR(x) ((x) << S_CL0_WR_DATA_TO_ERROR)
-#define F_CL0_WR_DATA_TO_ERROR V_CL0_WR_DATA_TO_ERROR(1U)
-
-#define S_FUTURE_CEXPANSION_WTS 29
-#define M_FUTURE_CEXPANSION_WTS 0x7U
-#define V_FUTURE_CEXPANSION_WTS(x) ((x) << S_FUTURE_CEXPANSION_WTS)
-#define G_FUTURE_CEXPANSION_WTS(x) (((x) >> S_FUTURE_CEXPANSION_WTS) & M_FUTURE_CEXPANSION_WTS)
-
-#define S_FUTURE_DEXPANSION_WTS 13
-#define M_FUTURE_DEXPANSION_WTS 0x7U
-#define V_FUTURE_DEXPANSION_WTS(x) ((x) << S_FUTURE_DEXPANSION_WTS)
-#define G_FUTURE_DEXPANSION_WTS(x) (((x) >> S_FUTURE_DEXPANSION_WTS) & M_FUTURE_DEXPANSION_WTS)
-
-#define A_MA_READ_TIMEOUT_ERROR_ENABLE 0x78dc
-
-#define S_CL12_RD_CMD_TO_EN 28
-#define V_CL12_RD_CMD_TO_EN(x) ((x) << S_CL12_RD_CMD_TO_EN)
-#define F_CL12_RD_CMD_TO_EN V_CL12_RD_CMD_TO_EN(1U)
-
-#define S_CL11_RD_CMD_TO_EN 27
-#define V_CL11_RD_CMD_TO_EN(x) ((x) << S_CL11_RD_CMD_TO_EN)
-#define F_CL11_RD_CMD_TO_EN V_CL11_RD_CMD_TO_EN(1U)
-
-#define S_CL10_RD_CMD_TO_EN 26
-#define V_CL10_RD_CMD_TO_EN(x) ((x) << S_CL10_RD_CMD_TO_EN)
-#define F_CL10_RD_CMD_TO_EN V_CL10_RD_CMD_TO_EN(1U)
-
-#define S_CL9_RD_CMD_TO_EN 25
-#define V_CL9_RD_CMD_TO_EN(x) ((x) << S_CL9_RD_CMD_TO_EN)
-#define F_CL9_RD_CMD_TO_EN V_CL9_RD_CMD_TO_EN(1U)
-
-#define S_CL8_RD_CMD_TO_EN 24
-#define V_CL8_RD_CMD_TO_EN(x) ((x) << S_CL8_RD_CMD_TO_EN)
-#define F_CL8_RD_CMD_TO_EN V_CL8_RD_CMD_TO_EN(1U)
-
-#define S_CL7_RD_CMD_TO_EN 23
-#define V_CL7_RD_CMD_TO_EN(x) ((x) << S_CL7_RD_CMD_TO_EN)
-#define F_CL7_RD_CMD_TO_EN V_CL7_RD_CMD_TO_EN(1U)
-
-#define S_CL6_RD_CMD_TO_EN 22
-#define V_CL6_RD_CMD_TO_EN(x) ((x) << S_CL6_RD_CMD_TO_EN)
-#define F_CL6_RD_CMD_TO_EN V_CL6_RD_CMD_TO_EN(1U)
-
-#define S_CL5_RD_CMD_TO_EN 21
-#define V_CL5_RD_CMD_TO_EN(x) ((x) << S_CL5_RD_CMD_TO_EN)
-#define F_CL5_RD_CMD_TO_EN V_CL5_RD_CMD_TO_EN(1U)
-
-#define S_CL4_RD_CMD_TO_EN 20
-#define V_CL4_RD_CMD_TO_EN(x) ((x) << S_CL4_RD_CMD_TO_EN)
-#define F_CL4_RD_CMD_TO_EN V_CL4_RD_CMD_TO_EN(1U)
-
-#define S_CL3_RD_CMD_TO_EN 19
-#define V_CL3_RD_CMD_TO_EN(x) ((x) << S_CL3_RD_CMD_TO_EN)
-#define F_CL3_RD_CMD_TO_EN V_CL3_RD_CMD_TO_EN(1U)
-
-#define S_CL2_RD_CMD_TO_EN 18
-#define V_CL2_RD_CMD_TO_EN(x) ((x) << S_CL2_RD_CMD_TO_EN)
-#define F_CL2_RD_CMD_TO_EN V_CL2_RD_CMD_TO_EN(1U)
-
-#define S_CL1_RD_CMD_TO_EN 17
-#define V_CL1_RD_CMD_TO_EN(x) ((x) << S_CL1_RD_CMD_TO_EN)
-#define F_CL1_RD_CMD_TO_EN V_CL1_RD_CMD_TO_EN(1U)
-
-#define S_CL0_RD_CMD_TO_EN 16
-#define V_CL0_RD_CMD_TO_EN(x) ((x) << S_CL0_RD_CMD_TO_EN)
-#define F_CL0_RD_CMD_TO_EN V_CL0_RD_CMD_TO_EN(1U)
-
-#define S_CL12_RD_DATA_TO_EN 12
-#define V_CL12_RD_DATA_TO_EN(x) ((x) << S_CL12_RD_DATA_TO_EN)
-#define F_CL12_RD_DATA_TO_EN V_CL12_RD_DATA_TO_EN(1U)
-
-#define S_CL11_RD_DATA_TO_EN 11
-#define V_CL11_RD_DATA_TO_EN(x) ((x) << S_CL11_RD_DATA_TO_EN)
-#define F_CL11_RD_DATA_TO_EN V_CL11_RD_DATA_TO_EN(1U)
-
-#define S_CL10_RD_DATA_TO_EN 10
-#define V_CL10_RD_DATA_TO_EN(x) ((x) << S_CL10_RD_DATA_TO_EN)
-#define F_CL10_RD_DATA_TO_EN V_CL10_RD_DATA_TO_EN(1U)
-
-#define S_CL9_RD_DATA_TO_EN 9
-#define V_CL9_RD_DATA_TO_EN(x) ((x) << S_CL9_RD_DATA_TO_EN)
-#define F_CL9_RD_DATA_TO_EN V_CL9_RD_DATA_TO_EN(1U)
-
-#define S_CL8_RD_DATA_TO_EN 8
-#define V_CL8_RD_DATA_TO_EN(x) ((x) << S_CL8_RD_DATA_TO_EN)
-#define F_CL8_RD_DATA_TO_EN V_CL8_RD_DATA_TO_EN(1U)
-
-#define S_CL7_RD_DATA_TO_EN 7
-#define V_CL7_RD_DATA_TO_EN(x) ((x) << S_CL7_RD_DATA_TO_EN)
-#define F_CL7_RD_DATA_TO_EN V_CL7_RD_DATA_TO_EN(1U)
-
-#define S_CL6_RD_DATA_TO_EN 6
-#define V_CL6_RD_DATA_TO_EN(x) ((x) << S_CL6_RD_DATA_TO_EN)
-#define F_CL6_RD_DATA_TO_EN V_CL6_RD_DATA_TO_EN(1U)
-
-#define S_CL5_RD_DATA_TO_EN 5
-#define V_CL5_RD_DATA_TO_EN(x) ((x) << S_CL5_RD_DATA_TO_EN)
-#define F_CL5_RD_DATA_TO_EN V_CL5_RD_DATA_TO_EN(1U)
-
-#define S_CL4_RD_DATA_TO_EN 4
-#define V_CL4_RD_DATA_TO_EN(x) ((x) << S_CL4_RD_DATA_TO_EN)
-#define F_CL4_RD_DATA_TO_EN V_CL4_RD_DATA_TO_EN(1U)
-
-#define S_CL3_RD_DATA_TO_EN 3
-#define V_CL3_RD_DATA_TO_EN(x) ((x) << S_CL3_RD_DATA_TO_EN)
-#define F_CL3_RD_DATA_TO_EN V_CL3_RD_DATA_TO_EN(1U)
-
-#define S_CL2_RD_DATA_TO_EN 2
-#define V_CL2_RD_DATA_TO_EN(x) ((x) << S_CL2_RD_DATA_TO_EN)
-#define F_CL2_RD_DATA_TO_EN V_CL2_RD_DATA_TO_EN(1U)
-
-#define S_CL1_RD_DATA_TO_EN 1
-#define V_CL1_RD_DATA_TO_EN(x) ((x) << S_CL1_RD_DATA_TO_EN)
-#define F_CL1_RD_DATA_TO_EN V_CL1_RD_DATA_TO_EN(1U)
-
-#define S_CL0_RD_DATA_TO_EN 0
-#define V_CL0_RD_DATA_TO_EN(x) ((x) << S_CL0_RD_DATA_TO_EN)
-#define F_CL0_RD_DATA_TO_EN V_CL0_RD_DATA_TO_EN(1U)
-
-#define S_FUTURE_CEXPANSION_RTE 29
-#define M_FUTURE_CEXPANSION_RTE 0x7U
-#define V_FUTURE_CEXPANSION_RTE(x) ((x) << S_FUTURE_CEXPANSION_RTE)
-#define G_FUTURE_CEXPANSION_RTE(x) (((x) >> S_FUTURE_CEXPANSION_RTE) & M_FUTURE_CEXPANSION_RTE)
-
-#define S_FUTURE_DEXPANSION_RTE 13
-#define M_FUTURE_DEXPANSION_RTE 0x7U
-#define V_FUTURE_DEXPANSION_RTE(x) ((x) << S_FUTURE_DEXPANSION_RTE)
-#define G_FUTURE_DEXPANSION_RTE(x) (((x) >> S_FUTURE_DEXPANSION_RTE) & M_FUTURE_DEXPANSION_RTE)
-
-#define A_MA_READ_TIMEOUT_ERROR_STATUS 0x78e0
-
-#define S_CL12_RD_CMD_TO_ERROR 28
-#define V_CL12_RD_CMD_TO_ERROR(x) ((x) << S_CL12_RD_CMD_TO_ERROR)
-#define F_CL12_RD_CMD_TO_ERROR V_CL12_RD_CMD_TO_ERROR(1U)
-
-#define S_CL11_RD_CMD_TO_ERROR 27
-#define V_CL11_RD_CMD_TO_ERROR(x) ((x) << S_CL11_RD_CMD_TO_ERROR)
-#define F_CL11_RD_CMD_TO_ERROR V_CL11_RD_CMD_TO_ERROR(1U)
-
-#define S_CL10_RD_CMD_TO_ERROR 26
-#define V_CL10_RD_CMD_TO_ERROR(x) ((x) << S_CL10_RD_CMD_TO_ERROR)
-#define F_CL10_RD_CMD_TO_ERROR V_CL10_RD_CMD_TO_ERROR(1U)
-
-#define S_CL9_RD_CMD_TO_ERROR 25
-#define V_CL9_RD_CMD_TO_ERROR(x) ((x) << S_CL9_RD_CMD_TO_ERROR)
-#define F_CL9_RD_CMD_TO_ERROR V_CL9_RD_CMD_TO_ERROR(1U)
-
-#define S_CL8_RD_CMD_TO_ERROR 24
-#define V_CL8_RD_CMD_TO_ERROR(x) ((x) << S_CL8_RD_CMD_TO_ERROR)
-#define F_CL8_RD_CMD_TO_ERROR V_CL8_RD_CMD_TO_ERROR(1U)
-
-#define S_CL7_RD_CMD_TO_ERROR 23
-#define V_CL7_RD_CMD_TO_ERROR(x) ((x) << S_CL7_RD_CMD_TO_ERROR)
-#define F_CL7_RD_CMD_TO_ERROR V_CL7_RD_CMD_TO_ERROR(1U)
-
-#define S_CL6_RD_CMD_TO_ERROR 22
-#define V_CL6_RD_CMD_TO_ERROR(x) ((x) << S_CL6_RD_CMD_TO_ERROR)
-#define F_CL6_RD_CMD_TO_ERROR V_CL6_RD_CMD_TO_ERROR(1U)
-
-#define S_CL5_RD_CMD_TO_ERROR 21
-#define V_CL5_RD_CMD_TO_ERROR(x) ((x) << S_CL5_RD_CMD_TO_ERROR)
-#define F_CL5_RD_CMD_TO_ERROR V_CL5_RD_CMD_TO_ERROR(1U)
-
-#define S_CL4_RD_CMD_TO_ERROR 20
-#define V_CL4_RD_CMD_TO_ERROR(x) ((x) << S_CL4_RD_CMD_TO_ERROR)
-#define F_CL4_RD_CMD_TO_ERROR V_CL4_RD_CMD_TO_ERROR(1U)
-
-#define S_CL3_RD_CMD_TO_ERROR 19
-#define V_CL3_RD_CMD_TO_ERROR(x) ((x) << S_CL3_RD_CMD_TO_ERROR)
-#define F_CL3_RD_CMD_TO_ERROR V_CL3_RD_CMD_TO_ERROR(1U)
-
-#define S_CL2_RD_CMD_TO_ERROR 18
-#define V_CL2_RD_CMD_TO_ERROR(x) ((x) << S_CL2_RD_CMD_TO_ERROR)
-#define F_CL2_RD_CMD_TO_ERROR V_CL2_RD_CMD_TO_ERROR(1U)
-
-#define S_CL1_RD_CMD_TO_ERROR 17
-#define V_CL1_RD_CMD_TO_ERROR(x) ((x) << S_CL1_RD_CMD_TO_ERROR)
-#define F_CL1_RD_CMD_TO_ERROR V_CL1_RD_CMD_TO_ERROR(1U)
-
-#define S_CL0_RD_CMD_TO_ERROR 16
-#define V_CL0_RD_CMD_TO_ERROR(x) ((x) << S_CL0_RD_CMD_TO_ERROR)
-#define F_CL0_RD_CMD_TO_ERROR V_CL0_RD_CMD_TO_ERROR(1U)
-
-#define S_CL12_RD_DATA_TO_ERROR 12
-#define V_CL12_RD_DATA_TO_ERROR(x) ((x) << S_CL12_RD_DATA_TO_ERROR)
-#define F_CL12_RD_DATA_TO_ERROR V_CL12_RD_DATA_TO_ERROR(1U)
-
-#define S_CL11_RD_DATA_TO_ERROR 11
-#define V_CL11_RD_DATA_TO_ERROR(x) ((x) << S_CL11_RD_DATA_TO_ERROR)
-#define F_CL11_RD_DATA_TO_ERROR V_CL11_RD_DATA_TO_ERROR(1U)
-
-#define S_CL10_RD_DATA_TO_ERROR 10
-#define V_CL10_RD_DATA_TO_ERROR(x) ((x) << S_CL10_RD_DATA_TO_ERROR)
-#define F_CL10_RD_DATA_TO_ERROR V_CL10_RD_DATA_TO_ERROR(1U)
-
-#define S_CL9_RD_DATA_TO_ERROR 9
-#define V_CL9_RD_DATA_TO_ERROR(x) ((x) << S_CL9_RD_DATA_TO_ERROR)
-#define F_CL9_RD_DATA_TO_ERROR V_CL9_RD_DATA_TO_ERROR(1U)
-
-#define S_CL8_RD_DATA_TO_ERROR 8
-#define V_CL8_RD_DATA_TO_ERROR(x) ((x) << S_CL8_RD_DATA_TO_ERROR)
-#define F_CL8_RD_DATA_TO_ERROR V_CL8_RD_DATA_TO_ERROR(1U)
-
-#define S_CL7_RD_DATA_TO_ERROR 7
-#define V_CL7_RD_DATA_TO_ERROR(x) ((x) << S_CL7_RD_DATA_TO_ERROR)
-#define F_CL7_RD_DATA_TO_ERROR V_CL7_RD_DATA_TO_ERROR(1U)
-
-#define S_CL6_RD_DATA_TO_ERROR 6
-#define V_CL6_RD_DATA_TO_ERROR(x) ((x) << S_CL6_RD_DATA_TO_ERROR)
-#define F_CL6_RD_DATA_TO_ERROR V_CL6_RD_DATA_TO_ERROR(1U)
-
-#define S_CL5_RD_DATA_TO_ERROR 5
-#define V_CL5_RD_DATA_TO_ERROR(x) ((x) << S_CL5_RD_DATA_TO_ERROR)
-#define F_CL5_RD_DATA_TO_ERROR V_CL5_RD_DATA_TO_ERROR(1U)
-
-#define S_CL4_RD_DATA_TO_ERROR 4
-#define V_CL4_RD_DATA_TO_ERROR(x) ((x) << S_CL4_RD_DATA_TO_ERROR)
-#define F_CL4_RD_DATA_TO_ERROR V_CL4_RD_DATA_TO_ERROR(1U)
-
-#define S_CL3_RD_DATA_TO_ERROR 3
-#define V_CL3_RD_DATA_TO_ERROR(x) ((x) << S_CL3_RD_DATA_TO_ERROR)
-#define F_CL3_RD_DATA_TO_ERROR V_CL3_RD_DATA_TO_ERROR(1U)
-
-#define S_CL2_RD_DATA_TO_ERROR 2
-#define V_CL2_RD_DATA_TO_ERROR(x) ((x) << S_CL2_RD_DATA_TO_ERROR)
-#define F_CL2_RD_DATA_TO_ERROR V_CL2_RD_DATA_TO_ERROR(1U)
-
-#define S_CL1_RD_DATA_TO_ERROR 1
-#define V_CL1_RD_DATA_TO_ERROR(x) ((x) << S_CL1_RD_DATA_TO_ERROR)
-#define F_CL1_RD_DATA_TO_ERROR V_CL1_RD_DATA_TO_ERROR(1U)
-
-#define S_CL0_RD_DATA_TO_ERROR 0
-#define V_CL0_RD_DATA_TO_ERROR(x) ((x) << S_CL0_RD_DATA_TO_ERROR)
-#define F_CL0_RD_DATA_TO_ERROR V_CL0_RD_DATA_TO_ERROR(1U)
-
-#define S_FUTURE_CEXPANSION_RTS 29
-#define M_FUTURE_CEXPANSION_RTS 0x7U
-#define V_FUTURE_CEXPANSION_RTS(x) ((x) << S_FUTURE_CEXPANSION_RTS)
-#define G_FUTURE_CEXPANSION_RTS(x) (((x) >> S_FUTURE_CEXPANSION_RTS) & M_FUTURE_CEXPANSION_RTS)
-
-#define S_FUTURE_DEXPANSION_RTS 13
-#define M_FUTURE_DEXPANSION_RTS 0x7U
-#define V_FUTURE_DEXPANSION_RTS(x) ((x) << S_FUTURE_DEXPANSION_RTS)
-#define G_FUTURE_DEXPANSION_RTS(x) (((x) >> S_FUTURE_DEXPANSION_RTS) & M_FUTURE_DEXPANSION_RTS)
-
-#define A_MA_BKP_CNT_SEL 0x78e4
-
-#define S_BKP_CNT_TYPE 30
-#define M_BKP_CNT_TYPE 0x3U
-#define V_BKP_CNT_TYPE(x) ((x) << S_BKP_CNT_TYPE)
-#define G_BKP_CNT_TYPE(x) (((x) >> S_BKP_CNT_TYPE) & M_BKP_CNT_TYPE)
-
-#define S_BKP_CLIENT 24
-#define M_BKP_CLIENT 0xfU
-#define V_BKP_CLIENT(x) ((x) << S_BKP_CLIENT)
-#define G_BKP_CLIENT(x) (((x) >> S_BKP_CLIENT) & M_BKP_CLIENT)
-
-#define A_MA_BKP_CNT 0x78e8
-#define A_MA_WRT_ARB 0x78ec
-
-#define S_WRT_EN 31
-#define V_WRT_EN(x) ((x) << S_WRT_EN)
-#define F_WRT_EN V_WRT_EN(1U)
-
-#define S_WR_TIM 16
-#define M_WR_TIM 0xffU
-#define V_WR_TIM(x) ((x) << S_WR_TIM)
-#define G_WR_TIM(x) (((x) >> S_WR_TIM) & M_WR_TIM)
-
-#define S_RD_WIN 8
-#define M_RD_WIN 0xffU
-#define V_RD_WIN(x) ((x) << S_RD_WIN)
-#define G_RD_WIN(x) (((x) >> S_RD_WIN) & M_RD_WIN)
-
-#define S_WR_WIN 0
-#define M_WR_WIN 0xffU
-#define V_WR_WIN(x) ((x) << S_WR_WIN)
-#define G_WR_WIN(x) (((x) >> S_WR_WIN) & M_WR_WIN)
-
-#define A_MA_IF_PARITY_ERROR_ENABLE 0x78f0
-
-#define S_T5_FUTURE_DEXPANSION 13
-#define M_T5_FUTURE_DEXPANSION 0x7ffffU
-#define V_T5_FUTURE_DEXPANSION(x) ((x) << S_T5_FUTURE_DEXPANSION)
-#define G_T5_FUTURE_DEXPANSION(x) (((x) >> S_T5_FUTURE_DEXPANSION) & M_T5_FUTURE_DEXPANSION)
-
-#define S_CL12_IF_PAR_EN 12
-#define V_CL12_IF_PAR_EN(x) ((x) << S_CL12_IF_PAR_EN)
-#define F_CL12_IF_PAR_EN V_CL12_IF_PAR_EN(1U)
-
-#define S_CL11_IF_PAR_EN 11
-#define V_CL11_IF_PAR_EN(x) ((x) << S_CL11_IF_PAR_EN)
-#define F_CL11_IF_PAR_EN V_CL11_IF_PAR_EN(1U)
-
-#define S_CL10_IF_PAR_EN 10
-#define V_CL10_IF_PAR_EN(x) ((x) << S_CL10_IF_PAR_EN)
-#define F_CL10_IF_PAR_EN V_CL10_IF_PAR_EN(1U)
-
-#define S_CL9_IF_PAR_EN 9
-#define V_CL9_IF_PAR_EN(x) ((x) << S_CL9_IF_PAR_EN)
-#define F_CL9_IF_PAR_EN V_CL9_IF_PAR_EN(1U)
-
-#define S_CL8_IF_PAR_EN 8
-#define V_CL8_IF_PAR_EN(x) ((x) << S_CL8_IF_PAR_EN)
-#define F_CL8_IF_PAR_EN V_CL8_IF_PAR_EN(1U)
-
-#define S_CL7_IF_PAR_EN 7
-#define V_CL7_IF_PAR_EN(x) ((x) << S_CL7_IF_PAR_EN)
-#define F_CL7_IF_PAR_EN V_CL7_IF_PAR_EN(1U)
-
-#define S_CL6_IF_PAR_EN 6
-#define V_CL6_IF_PAR_EN(x) ((x) << S_CL6_IF_PAR_EN)
-#define F_CL6_IF_PAR_EN V_CL6_IF_PAR_EN(1U)
-
-#define S_CL5_IF_PAR_EN 5
-#define V_CL5_IF_PAR_EN(x) ((x) << S_CL5_IF_PAR_EN)
-#define F_CL5_IF_PAR_EN V_CL5_IF_PAR_EN(1U)
-
-#define S_CL4_IF_PAR_EN 4
-#define V_CL4_IF_PAR_EN(x) ((x) << S_CL4_IF_PAR_EN)
-#define F_CL4_IF_PAR_EN V_CL4_IF_PAR_EN(1U)
-
-#define S_CL3_IF_PAR_EN 3
-#define V_CL3_IF_PAR_EN(x) ((x) << S_CL3_IF_PAR_EN)
-#define F_CL3_IF_PAR_EN V_CL3_IF_PAR_EN(1U)
-
-#define S_CL2_IF_PAR_EN 2
-#define V_CL2_IF_PAR_EN(x) ((x) << S_CL2_IF_PAR_EN)
-#define F_CL2_IF_PAR_EN V_CL2_IF_PAR_EN(1U)
-
-#define S_CL1_IF_PAR_EN 1
-#define V_CL1_IF_PAR_EN(x) ((x) << S_CL1_IF_PAR_EN)
-#define F_CL1_IF_PAR_EN V_CL1_IF_PAR_EN(1U)
-
-#define S_CL0_IF_PAR_EN 0
-#define V_CL0_IF_PAR_EN(x) ((x) << S_CL0_IF_PAR_EN)
-#define F_CL0_IF_PAR_EN V_CL0_IF_PAR_EN(1U)
-
-#define S_FUTURE_DEXPANSION_IPE 13
-#define M_FUTURE_DEXPANSION_IPE 0x7ffffU
-#define V_FUTURE_DEXPANSION_IPE(x) ((x) << S_FUTURE_DEXPANSION_IPE)
-#define G_FUTURE_DEXPANSION_IPE(x) (((x) >> S_FUTURE_DEXPANSION_IPE) & M_FUTURE_DEXPANSION_IPE)
-
-#define A_MA_IF_PARITY_ERROR_STATUS 0x78f4
-
-#define S_T5_FUTURE_DEXPANSION 13
-#define M_T5_FUTURE_DEXPANSION 0x7ffffU
-#define V_T5_FUTURE_DEXPANSION(x) ((x) << S_T5_FUTURE_DEXPANSION)
-#define G_T5_FUTURE_DEXPANSION(x) (((x) >> S_T5_FUTURE_DEXPANSION) & M_T5_FUTURE_DEXPANSION)
-
-#define S_CL12_IF_PAR_ERROR 12
-#define V_CL12_IF_PAR_ERROR(x) ((x) << S_CL12_IF_PAR_ERROR)
-#define F_CL12_IF_PAR_ERROR V_CL12_IF_PAR_ERROR(1U)
-
-#define S_CL11_IF_PAR_ERROR 11
-#define V_CL11_IF_PAR_ERROR(x) ((x) << S_CL11_IF_PAR_ERROR)
-#define F_CL11_IF_PAR_ERROR V_CL11_IF_PAR_ERROR(1U)
-
-#define S_CL10_IF_PAR_ERROR 10
-#define V_CL10_IF_PAR_ERROR(x) ((x) << S_CL10_IF_PAR_ERROR)
-#define F_CL10_IF_PAR_ERROR V_CL10_IF_PAR_ERROR(1U)
-
-#define S_CL9_IF_PAR_ERROR 9
-#define V_CL9_IF_PAR_ERROR(x) ((x) << S_CL9_IF_PAR_ERROR)
-#define F_CL9_IF_PAR_ERROR V_CL9_IF_PAR_ERROR(1U)
-
-#define S_CL8_IF_PAR_ERROR 8
-#define V_CL8_IF_PAR_ERROR(x) ((x) << S_CL8_IF_PAR_ERROR)
-#define F_CL8_IF_PAR_ERROR V_CL8_IF_PAR_ERROR(1U)
-
-#define S_CL7_IF_PAR_ERROR 7
-#define V_CL7_IF_PAR_ERROR(x) ((x) << S_CL7_IF_PAR_ERROR)
-#define F_CL7_IF_PAR_ERROR V_CL7_IF_PAR_ERROR(1U)
-
-#define S_CL6_IF_PAR_ERROR 6
-#define V_CL6_IF_PAR_ERROR(x) ((x) << S_CL6_IF_PAR_ERROR)
-#define F_CL6_IF_PAR_ERROR V_CL6_IF_PAR_ERROR(1U)
-
-#define S_CL5_IF_PAR_ERROR 5
-#define V_CL5_IF_PAR_ERROR(x) ((x) << S_CL5_IF_PAR_ERROR)
-#define F_CL5_IF_PAR_ERROR V_CL5_IF_PAR_ERROR(1U)
-
-#define S_CL4_IF_PAR_ERROR 4
-#define V_CL4_IF_PAR_ERROR(x) ((x) << S_CL4_IF_PAR_ERROR)
-#define F_CL4_IF_PAR_ERROR V_CL4_IF_PAR_ERROR(1U)
-
-#define S_CL3_IF_PAR_ERROR 3
-#define V_CL3_IF_PAR_ERROR(x) ((x) << S_CL3_IF_PAR_ERROR)
-#define F_CL3_IF_PAR_ERROR V_CL3_IF_PAR_ERROR(1U)
-
-#define S_CL2_IF_PAR_ERROR 2
-#define V_CL2_IF_PAR_ERROR(x) ((x) << S_CL2_IF_PAR_ERROR)
-#define F_CL2_IF_PAR_ERROR V_CL2_IF_PAR_ERROR(1U)
-
-#define S_CL1_IF_PAR_ERROR 1
-#define V_CL1_IF_PAR_ERROR(x) ((x) << S_CL1_IF_PAR_ERROR)
-#define F_CL1_IF_PAR_ERROR V_CL1_IF_PAR_ERROR(1U)
-
-#define S_CL0_IF_PAR_ERROR 0
-#define V_CL0_IF_PAR_ERROR(x) ((x) << S_CL0_IF_PAR_ERROR)
-#define F_CL0_IF_PAR_ERROR V_CL0_IF_PAR_ERROR(1U)
-
-#define S_FUTURE_DEXPANSION_IPS 13
-#define M_FUTURE_DEXPANSION_IPS 0x7ffffU
-#define V_FUTURE_DEXPANSION_IPS(x) ((x) << S_FUTURE_DEXPANSION_IPS)
-#define G_FUTURE_DEXPANSION_IPS(x) (((x) >> S_FUTURE_DEXPANSION_IPS) & M_FUTURE_DEXPANSION_IPS)
-
-#define A_MA_LOCAL_DEBUG_CFG 0x78f8
-
-#define S_DEBUG_OR 15
-#define V_DEBUG_OR(x) ((x) << S_DEBUG_OR)
-#define F_DEBUG_OR V_DEBUG_OR(1U)
-
-#define S_DEBUG_HI 14
-#define V_DEBUG_HI(x) ((x) << S_DEBUG_HI)
-#define F_DEBUG_HI V_DEBUG_HI(1U)
-
-#define S_DEBUG_RPT 13
-#define V_DEBUG_RPT(x) ((x) << S_DEBUG_RPT)
-#define F_DEBUG_RPT V_DEBUG_RPT(1U)
-
-#define S_DEBUGPAGE 10
-#define M_DEBUGPAGE 0x7U
-#define V_DEBUGPAGE(x) ((x) << S_DEBUGPAGE)
-#define G_DEBUGPAGE(x) (((x) >> S_DEBUGPAGE) & M_DEBUGPAGE)
-
-#define A_MA_LOCAL_DEBUG_RPT 0x78fc
-#define A_MA_SGE_THREAD_0_CLIENT_INTERFACE_EXTERNAL 0xa000
-
-#define S_CMDVLD0 31
-#define V_CMDVLD0(x) ((x) << S_CMDVLD0)
-#define F_CMDVLD0 V_CMDVLD0(1U)
-
-#define S_CMDRDY0 30
-#define V_CMDRDY0(x) ((x) << S_CMDRDY0)
-#define F_CMDRDY0 V_CMDRDY0(1U)
-
-#define S_CMDTYPE0 29
-#define V_CMDTYPE0(x) ((x) << S_CMDTYPE0)
-#define F_CMDTYPE0 V_CMDTYPE0(1U)
-
-#define S_CMDLEN0 21
-#define M_CMDLEN0 0xffU
-#define V_CMDLEN0(x) ((x) << S_CMDLEN0)
-#define G_CMDLEN0(x) (((x) >> S_CMDLEN0) & M_CMDLEN0)
-
-#define S_CMDADDR0 8
-#define M_CMDADDR0 0x1fffU
-#define V_CMDADDR0(x) ((x) << S_CMDADDR0)
-#define G_CMDADDR0(x) (((x) >> S_CMDADDR0) & M_CMDADDR0)
-
-#define S_WRDATAVLD0 7
-#define V_WRDATAVLD0(x) ((x) << S_WRDATAVLD0)
-#define F_WRDATAVLD0 V_WRDATAVLD0(1U)
-
-#define S_WRDATARDY0 6
-#define V_WRDATARDY0(x) ((x) << S_WRDATARDY0)
-#define F_WRDATARDY0 V_WRDATARDY0(1U)
-
-#define S_RDDATARDY0 5
-#define V_RDDATARDY0(x) ((x) << S_RDDATARDY0)
-#define F_RDDATARDY0 V_RDDATARDY0(1U)
-
-#define S_RDDATAVLD0 4
-#define V_RDDATAVLD0(x) ((x) << S_RDDATAVLD0)
-#define F_RDDATAVLD0 V_RDDATAVLD0(1U)
-
-#define S_RDDATA0 0
-#define M_RDDATA0 0xfU
-#define V_RDDATA0(x) ((x) << S_RDDATA0)
-#define G_RDDATA0(x) (((x) >> S_RDDATA0) & M_RDDATA0)
-
-#define A_MA_SGE_THREAD_1_CLIENT_INTERFACE_EXTERNAL 0xa001
-
-#define S_CMDVLD1 31
-#define V_CMDVLD1(x) ((x) << S_CMDVLD1)
-#define F_CMDVLD1 V_CMDVLD1(1U)
-
-#define S_CMDRDY1 30
-#define V_CMDRDY1(x) ((x) << S_CMDRDY1)
-#define F_CMDRDY1 V_CMDRDY1(1U)
-
-#define S_CMDTYPE1 29
-#define V_CMDTYPE1(x) ((x) << S_CMDTYPE1)
-#define F_CMDTYPE1 V_CMDTYPE1(1U)
-
-#define S_CMDLEN1 21
-#define M_CMDLEN1 0xffU
-#define V_CMDLEN1(x) ((x) << S_CMDLEN1)
-#define G_CMDLEN1(x) (((x) >> S_CMDLEN1) & M_CMDLEN1)
-
-#define S_CMDADDR1 8
-#define M_CMDADDR1 0x1fffU
-#define V_CMDADDR1(x) ((x) << S_CMDADDR1)
-#define G_CMDADDR1(x) (((x) >> S_CMDADDR1) & M_CMDADDR1)
-
-#define S_WRDATAVLD1 7
-#define V_WRDATAVLD1(x) ((x) << S_WRDATAVLD1)
-#define F_WRDATAVLD1 V_WRDATAVLD1(1U)
-
-#define S_WRDATARDY1 6
-#define V_WRDATARDY1(x) ((x) << S_WRDATARDY1)
-#define F_WRDATARDY1 V_WRDATARDY1(1U)
-
-#define S_RDDATARDY1 5
-#define V_RDDATARDY1(x) ((x) << S_RDDATARDY1)
-#define F_RDDATARDY1 V_RDDATARDY1(1U)
-
-#define S_RDDATAVLD1 4
-#define V_RDDATAVLD1(x) ((x) << S_RDDATAVLD1)
-#define F_RDDATAVLD1 V_RDDATAVLD1(1U)
-
-#define S_RDDATA1 0
-#define M_RDDATA1 0xfU
-#define V_RDDATA1(x) ((x) << S_RDDATA1)
-#define G_RDDATA1(x) (((x) >> S_RDDATA1) & M_RDDATA1)
-
-#define A_MA_ULP_TX_CLIENT_INTERFACE_EXTERNAL 0xa002
-
-#define S_CMDVLD2 31
-#define V_CMDVLD2(x) ((x) << S_CMDVLD2)
-#define F_CMDVLD2 V_CMDVLD2(1U)
-
-#define S_CMDRDY2 30
-#define V_CMDRDY2(x) ((x) << S_CMDRDY2)
-#define F_CMDRDY2 V_CMDRDY2(1U)
-
-#define S_CMDTYPE2 29
-#define V_CMDTYPE2(x) ((x) << S_CMDTYPE2)
-#define F_CMDTYPE2 V_CMDTYPE2(1U)
-
-#define S_CMDLEN2 21
-#define M_CMDLEN2 0xffU
-#define V_CMDLEN2(x) ((x) << S_CMDLEN2)
-#define G_CMDLEN2(x) (((x) >> S_CMDLEN2) & M_CMDLEN2)
-
-#define S_CMDADDR2 8
-#define M_CMDADDR2 0x1fffU
-#define V_CMDADDR2(x) ((x) << S_CMDADDR2)
-#define G_CMDADDR2(x) (((x) >> S_CMDADDR2) & M_CMDADDR2)
-
-#define S_WRDATAVLD2 7
-#define V_WRDATAVLD2(x) ((x) << S_WRDATAVLD2)
-#define F_WRDATAVLD2 V_WRDATAVLD2(1U)
-
-#define S_WRDATARDY2 6
-#define V_WRDATARDY2(x) ((x) << S_WRDATARDY2)
-#define F_WRDATARDY2 V_WRDATARDY2(1U)
-
-#define S_RDDATARDY2 5
-#define V_RDDATARDY2(x) ((x) << S_RDDATARDY2)
-#define F_RDDATARDY2 V_RDDATARDY2(1U)
-
-#define S_RDDATAVLD2 4
-#define V_RDDATAVLD2(x) ((x) << S_RDDATAVLD2)
-#define F_RDDATAVLD2 V_RDDATAVLD2(1U)
-
-#define S_RDDATA2 0
-#define M_RDDATA2 0xfU
-#define V_RDDATA2(x) ((x) << S_RDDATA2)
-#define G_RDDATA2(x) (((x) >> S_RDDATA2) & M_RDDATA2)
-
-#define A_MA_ULP_RX_CLIENT_INTERFACE_EXTERNAL 0xa003
-
-#define S_CMDVLD3 31
-#define V_CMDVLD3(x) ((x) << S_CMDVLD3)
-#define F_CMDVLD3 V_CMDVLD3(1U)
-
-#define S_CMDRDY3 30
-#define V_CMDRDY3(x) ((x) << S_CMDRDY3)
-#define F_CMDRDY3 V_CMDRDY3(1U)
-
-#define S_CMDTYPE3 29
-#define V_CMDTYPE3(x) ((x) << S_CMDTYPE3)
-#define F_CMDTYPE3 V_CMDTYPE3(1U)
-
-#define S_CMDLEN3 21
-#define M_CMDLEN3 0xffU
-#define V_CMDLEN3(x) ((x) << S_CMDLEN3)
-#define G_CMDLEN3(x) (((x) >> S_CMDLEN3) & M_CMDLEN3)
-
-#define S_CMDADDR3 8
-#define M_CMDADDR3 0x1fffU
-#define V_CMDADDR3(x) ((x) << S_CMDADDR3)
-#define G_CMDADDR3(x) (((x) >> S_CMDADDR3) & M_CMDADDR3)
-
-#define S_WRDATAVLD3 7
-#define V_WRDATAVLD3(x) ((x) << S_WRDATAVLD3)
-#define F_WRDATAVLD3 V_WRDATAVLD3(1U)
-
-#define S_WRDATARDY3 6
-#define V_WRDATARDY3(x) ((x) << S_WRDATARDY3)
-#define F_WRDATARDY3 V_WRDATARDY3(1U)
-
-#define S_RDDATARDY3 5
-#define V_RDDATARDY3(x) ((x) << S_RDDATARDY3)
-#define F_RDDATARDY3 V_RDDATARDY3(1U)
-
-#define S_RDDATAVLD3 4
-#define V_RDDATAVLD3(x) ((x) << S_RDDATAVLD3)
-#define F_RDDATAVLD3 V_RDDATAVLD3(1U)
-
-#define S_RDDATA3 0
-#define M_RDDATA3 0xfU
-#define V_RDDATA3(x) ((x) << S_RDDATA3)
-#define G_RDDATA3(x) (((x) >> S_RDDATA3) & M_RDDATA3)
-
-#define A_MA_ULP_TX_RX_CLIENT_INTERFACE_EXTERNAL 0xa004
-
-#define S_CMDVLD4 31
-#define V_CMDVLD4(x) ((x) << S_CMDVLD4)
-#define F_CMDVLD4 V_CMDVLD4(1U)
-
-#define S_CMDRDY4 30
-#define V_CMDRDY4(x) ((x) << S_CMDRDY4)
-#define F_CMDRDY4 V_CMDRDY4(1U)
-
-#define S_CMDTYPE4 29
-#define V_CMDTYPE4(x) ((x) << S_CMDTYPE4)
-#define F_CMDTYPE4 V_CMDTYPE4(1U)
-
-#define S_CMDLEN4 21
-#define M_CMDLEN4 0xffU
-#define V_CMDLEN4(x) ((x) << S_CMDLEN4)
-#define G_CMDLEN4(x) (((x) >> S_CMDLEN4) & M_CMDLEN4)
-
-#define S_CMDADDR4 8
-#define M_CMDADDR4 0x1fffU
-#define V_CMDADDR4(x) ((x) << S_CMDADDR4)
-#define G_CMDADDR4(x) (((x) >> S_CMDADDR4) & M_CMDADDR4)
-
-#define S_WRDATAVLD4 7
-#define V_WRDATAVLD4(x) ((x) << S_WRDATAVLD4)
-#define F_WRDATAVLD4 V_WRDATAVLD4(1U)
-
-#define S_WRDATARDY4 6
-#define V_WRDATARDY4(x) ((x) << S_WRDATARDY4)
-#define F_WRDATARDY4 V_WRDATARDY4(1U)
-
-#define S_RDDATARDY4 5
-#define V_RDDATARDY4(x) ((x) << S_RDDATARDY4)
-#define F_RDDATARDY4 V_RDDATARDY4(1U)
-
-#define S_RDDATAVLD4 4
-#define V_RDDATAVLD4(x) ((x) << S_RDDATAVLD4)
-#define F_RDDATAVLD4 V_RDDATAVLD4(1U)
-
-#define S_RDDATA4 0
-#define M_RDDATA4 0xfU
-#define V_RDDATA4(x) ((x) << S_RDDATA4)
-#define G_RDDATA4(x) (((x) >> S_RDDATA4) & M_RDDATA4)
-
-#define A_MA_TP_THREAD_0_CLIENT_INTERFACE_EXTERNAL 0xa005
-
-#define S_CMDVLD5 31
-#define V_CMDVLD5(x) ((x) << S_CMDVLD5)
-#define F_CMDVLD5 V_CMDVLD5(1U)
-
-#define S_CMDRDY5 30
-#define V_CMDRDY5(x) ((x) << S_CMDRDY5)
-#define F_CMDRDY5 V_CMDRDY5(1U)
-
-#define S_CMDTYPE5 29
-#define V_CMDTYPE5(x) ((x) << S_CMDTYPE5)
-#define F_CMDTYPE5 V_CMDTYPE5(1U)
-
-#define S_CMDLEN5 21
-#define M_CMDLEN5 0xffU
-#define V_CMDLEN5(x) ((x) << S_CMDLEN5)
-#define G_CMDLEN5(x) (((x) >> S_CMDLEN5) & M_CMDLEN5)
-
-#define S_CMDADDR5 8
-#define M_CMDADDR5 0x1fffU
-#define V_CMDADDR5(x) ((x) << S_CMDADDR5)
-#define G_CMDADDR5(x) (((x) >> S_CMDADDR5) & M_CMDADDR5)
-
-#define S_WRDATAVLD5 7
-#define V_WRDATAVLD5(x) ((x) << S_WRDATAVLD5)
-#define F_WRDATAVLD5 V_WRDATAVLD5(1U)
-
-#define S_WRDATARDY5 6
-#define V_WRDATARDY5(x) ((x) << S_WRDATARDY5)
-#define F_WRDATARDY5 V_WRDATARDY5(1U)
-
-#define S_RDDATARDY5 5
-#define V_RDDATARDY5(x) ((x) << S_RDDATARDY5)
-#define F_RDDATARDY5 V_RDDATARDY5(1U)
-
-#define S_RDDATAVLD5 4
-#define V_RDDATAVLD5(x) ((x) << S_RDDATAVLD5)
-#define F_RDDATAVLD5 V_RDDATAVLD5(1U)
-
-#define S_RDDATA5 0
-#define M_RDDATA5 0xfU
-#define V_RDDATA5(x) ((x) << S_RDDATA5)
-#define G_RDDATA5(x) (((x) >> S_RDDATA5) & M_RDDATA5)
-
-#define A_MA_TP_THREAD_1_CLIENT_INTERFACE_EXTERNAL 0xa006
-
-#define S_CMDVLD6 31
-#define V_CMDVLD6(x) ((x) << S_CMDVLD6)
-#define F_CMDVLD6 V_CMDVLD6(1U)
-
-#define S_CMDRDY6 30
-#define V_CMDRDY6(x) ((x) << S_CMDRDY6)
-#define F_CMDRDY6 V_CMDRDY6(1U)
-
-#define S_CMDTYPE6 29
-#define V_CMDTYPE6(x) ((x) << S_CMDTYPE6)
-#define F_CMDTYPE6 V_CMDTYPE6(1U)
-
-#define S_CMDLEN6 21
-#define M_CMDLEN6 0xffU
-#define V_CMDLEN6(x) ((x) << S_CMDLEN6)
-#define G_CMDLEN6(x) (((x) >> S_CMDLEN6) & M_CMDLEN6)
-
-#define S_CMDADDR6 8
-#define M_CMDADDR6 0x1fffU
-#define V_CMDADDR6(x) ((x) << S_CMDADDR6)
-#define G_CMDADDR6(x) (((x) >> S_CMDADDR6) & M_CMDADDR6)
-
-#define S_WRDATAVLD6 7
-#define V_WRDATAVLD6(x) ((x) << S_WRDATAVLD6)
-#define F_WRDATAVLD6 V_WRDATAVLD6(1U)
-
-#define S_WRDATARDY6 6
-#define V_WRDATARDY6(x) ((x) << S_WRDATARDY6)
-#define F_WRDATARDY6 V_WRDATARDY6(1U)
-
-#define S_RDDATARDY6 5
-#define V_RDDATARDY6(x) ((x) << S_RDDATARDY6)
-#define F_RDDATARDY6 V_RDDATARDY6(1U)
-
-#define S_RDDATAVLD6 4
-#define V_RDDATAVLD6(x) ((x) << S_RDDATAVLD6)
-#define F_RDDATAVLD6 V_RDDATAVLD6(1U)
-
-#define S_RDDATA6 0
-#define M_RDDATA6 0xfU
-#define V_RDDATA6(x) ((x) << S_RDDATA6)
-#define G_RDDATA6(x) (((x) >> S_RDDATA6) & M_RDDATA6)
-
-#define A_MA_LE_CLIENT_INTERFACE_EXTERNAL 0xa007
-
-#define S_CMDVLD7 31
-#define V_CMDVLD7(x) ((x) << S_CMDVLD7)
-#define F_CMDVLD7 V_CMDVLD7(1U)
-
-#define S_CMDRDY7 30
-#define V_CMDRDY7(x) ((x) << S_CMDRDY7)
-#define F_CMDRDY7 V_CMDRDY7(1U)
-
-#define S_CMDTYPE7 29
-#define V_CMDTYPE7(x) ((x) << S_CMDTYPE7)
-#define F_CMDTYPE7 V_CMDTYPE7(1U)
-
-#define S_CMDLEN7 21
-#define M_CMDLEN7 0xffU
-#define V_CMDLEN7(x) ((x) << S_CMDLEN7)
-#define G_CMDLEN7(x) (((x) >> S_CMDLEN7) & M_CMDLEN7)
-
-#define S_CMDADDR7 8
-#define M_CMDADDR7 0x1fffU
-#define V_CMDADDR7(x) ((x) << S_CMDADDR7)
-#define G_CMDADDR7(x) (((x) >> S_CMDADDR7) & M_CMDADDR7)
-
-#define S_WRDATAVLD7 7
-#define V_WRDATAVLD7(x) ((x) << S_WRDATAVLD7)
-#define F_WRDATAVLD7 V_WRDATAVLD7(1U)
-
-#define S_WRDATARDY7 6
-#define V_WRDATARDY7(x) ((x) << S_WRDATARDY7)
-#define F_WRDATARDY7 V_WRDATARDY7(1U)
-
-#define S_RDDATARDY7 5
-#define V_RDDATARDY7(x) ((x) << S_RDDATARDY7)
-#define F_RDDATARDY7 V_RDDATARDY7(1U)
-
-#define S_RDDATAVLD7 4
-#define V_RDDATAVLD7(x) ((x) << S_RDDATAVLD7)
-#define F_RDDATAVLD7 V_RDDATAVLD7(1U)
-
-#define S_RDDATA7 0
-#define M_RDDATA7 0xfU
-#define V_RDDATA7(x) ((x) << S_RDDATA7)
-#define G_RDDATA7(x) (((x) >> S_RDDATA7) & M_RDDATA7)
-
-#define A_MA_CIM_CLIENT_INTERFACE_EXTERNAL 0xa008
-
-#define S_CMDVLD8 31
-#define V_CMDVLD8(x) ((x) << S_CMDVLD8)
-#define F_CMDVLD8 V_CMDVLD8(1U)
-
-#define S_CMDRDY8 30
-#define V_CMDRDY8(x) ((x) << S_CMDRDY8)
-#define F_CMDRDY8 V_CMDRDY8(1U)
-
-#define S_CMDTYPE8 29
-#define V_CMDTYPE8(x) ((x) << S_CMDTYPE8)
-#define F_CMDTYPE8 V_CMDTYPE8(1U)
-
-#define S_CMDLEN8 21
-#define M_CMDLEN8 0xffU
-#define V_CMDLEN8(x) ((x) << S_CMDLEN8)
-#define G_CMDLEN8(x) (((x) >> S_CMDLEN8) & M_CMDLEN8)
-
-#define S_CMDADDR8 8
-#define M_CMDADDR8 0x1fffU
-#define V_CMDADDR8(x) ((x) << S_CMDADDR8)
-#define G_CMDADDR8(x) (((x) >> S_CMDADDR8) & M_CMDADDR8)
-
-#define S_WRDATAVLD8 7
-#define V_WRDATAVLD8(x) ((x) << S_WRDATAVLD8)
-#define F_WRDATAVLD8 V_WRDATAVLD8(1U)
-
-#define S_WRDATARDY8 6
-#define V_WRDATARDY8(x) ((x) << S_WRDATARDY8)
-#define F_WRDATARDY8 V_WRDATARDY8(1U)
-
-#define S_RDDATARDY8 5
-#define V_RDDATARDY8(x) ((x) << S_RDDATARDY8)
-#define F_RDDATARDY8 V_RDDATARDY8(1U)
-
-#define S_RDDATAVLD8 4
-#define V_RDDATAVLD8(x) ((x) << S_RDDATAVLD8)
-#define F_RDDATAVLD8 V_RDDATAVLD8(1U)
-
-#define S_RDDATA8 0
-#define M_RDDATA8 0xfU
-#define V_RDDATA8(x) ((x) << S_RDDATA8)
-#define G_RDDATA8(x) (((x) >> S_RDDATA8) & M_RDDATA8)
-
-#define A_MA_PCIE_CLIENT_INTERFACE_EXTERNAL 0xa009
-
-#define S_CMDVLD9 31
-#define V_CMDVLD9(x) ((x) << S_CMDVLD9)
-#define F_CMDVLD9 V_CMDVLD9(1U)
-
-#define S_CMDRDY9 30
-#define V_CMDRDY9(x) ((x) << S_CMDRDY9)
-#define F_CMDRDY9 V_CMDRDY9(1U)
-
-#define S_CMDTYPE9 29
-#define V_CMDTYPE9(x) ((x) << S_CMDTYPE9)
-#define F_CMDTYPE9 V_CMDTYPE9(1U)
-
-#define S_CMDLEN9 21
-#define M_CMDLEN9 0xffU
-#define V_CMDLEN9(x) ((x) << S_CMDLEN9)
-#define G_CMDLEN9(x) (((x) >> S_CMDLEN9) & M_CMDLEN9)
-
-#define S_CMDADDR9 8
-#define M_CMDADDR9 0x1fffU
-#define V_CMDADDR9(x) ((x) << S_CMDADDR9)
-#define G_CMDADDR9(x) (((x) >> S_CMDADDR9) & M_CMDADDR9)
-
-#define S_WRDATAVLD9 7
-#define V_WRDATAVLD9(x) ((x) << S_WRDATAVLD9)
-#define F_WRDATAVLD9 V_WRDATAVLD9(1U)
-
-#define S_WRDATARDY9 6
-#define V_WRDATARDY9(x) ((x) << S_WRDATARDY9)
-#define F_WRDATARDY9 V_WRDATARDY9(1U)
-
-#define S_RDDATARDY9 5
-#define V_RDDATARDY9(x) ((x) << S_RDDATARDY9)
-#define F_RDDATARDY9 V_RDDATARDY9(1U)
-
-#define S_RDDATAVLD9 4
-#define V_RDDATAVLD9(x) ((x) << S_RDDATAVLD9)
-#define F_RDDATAVLD9 V_RDDATAVLD9(1U)
-
-#define S_RDDATA9 0
-#define M_RDDATA9 0xfU
-#define V_RDDATA9(x) ((x) << S_RDDATA9)
-#define G_RDDATA9(x) (((x) >> S_RDDATA9) & M_RDDATA9)
-
-#define A_MA_PM_TX_CLIENT_INTERFACE_EXTERNAL 0xa00a
-
-#define S_CMDVLD10 31
-#define V_CMDVLD10(x) ((x) << S_CMDVLD10)
-#define F_CMDVLD10 V_CMDVLD10(1U)
-
-#define S_CMDRDY10 30
-#define V_CMDRDY10(x) ((x) << S_CMDRDY10)
-#define F_CMDRDY10 V_CMDRDY10(1U)
-
-#define S_CMDTYPE10 29
-#define V_CMDTYPE10(x) ((x) << S_CMDTYPE10)
-#define F_CMDTYPE10 V_CMDTYPE10(1U)
-
-#define S_CMDLEN10 21
-#define M_CMDLEN10 0xffU
-#define V_CMDLEN10(x) ((x) << S_CMDLEN10)
-#define G_CMDLEN10(x) (((x) >> S_CMDLEN10) & M_CMDLEN10)
-
-#define S_CMDADDR10 8
-#define M_CMDADDR10 0x1fffU
-#define V_CMDADDR10(x) ((x) << S_CMDADDR10)
-#define G_CMDADDR10(x) (((x) >> S_CMDADDR10) & M_CMDADDR10)
-
-#define S_WRDATAVLD10 7
-#define V_WRDATAVLD10(x) ((x) << S_WRDATAVLD10)
-#define F_WRDATAVLD10 V_WRDATAVLD10(1U)
-
-#define S_WRDATARDY10 6
-#define V_WRDATARDY10(x) ((x) << S_WRDATARDY10)
-#define F_WRDATARDY10 V_WRDATARDY10(1U)
-
-#define S_RDDATARDY10 5
-#define V_RDDATARDY10(x) ((x) << S_RDDATARDY10)
-#define F_RDDATARDY10 V_RDDATARDY10(1U)
-
-#define S_RDDATAVLD10 4
-#define V_RDDATAVLD10(x) ((x) << S_RDDATAVLD10)
-#define F_RDDATAVLD10 V_RDDATAVLD10(1U)
-
-#define S_RDDATA10 0
-#define M_RDDATA10 0xfU
-#define V_RDDATA10(x) ((x) << S_RDDATA10)
-#define G_RDDATA10(x) (((x) >> S_RDDATA10) & M_RDDATA10)
-
-#define A_MA_PM_RX_CLIENT_INTERFACE_EXTERNAL 0xa00b
-
-#define S_CMDVLD11 31
-#define V_CMDVLD11(x) ((x) << S_CMDVLD11)
-#define F_CMDVLD11 V_CMDVLD11(1U)
-
-#define S_CMDRDY11 30
-#define V_CMDRDY11(x) ((x) << S_CMDRDY11)
-#define F_CMDRDY11 V_CMDRDY11(1U)
-
-#define S_CMDTYPE11 29
-#define V_CMDTYPE11(x) ((x) << S_CMDTYPE11)
-#define F_CMDTYPE11 V_CMDTYPE11(1U)
-
-#define S_CMDLEN11 21
-#define M_CMDLEN11 0xffU
-#define V_CMDLEN11(x) ((x) << S_CMDLEN11)
-#define G_CMDLEN11(x) (((x) >> S_CMDLEN11) & M_CMDLEN11)
-
-#define S_CMDADDR11 8
-#define M_CMDADDR11 0x1fffU
-#define V_CMDADDR11(x) ((x) << S_CMDADDR11)
-#define G_CMDADDR11(x) (((x) >> S_CMDADDR11) & M_CMDADDR11)
-
-#define S_WRDATAVLD11 7
-#define V_WRDATAVLD11(x) ((x) << S_WRDATAVLD11)
-#define F_WRDATAVLD11 V_WRDATAVLD11(1U)
-
-#define S_WRDATARDY11 6
-#define V_WRDATARDY11(x) ((x) << S_WRDATARDY11)
-#define F_WRDATARDY11 V_WRDATARDY11(1U)
-
-#define S_RDDATARDY11 5
-#define V_RDDATARDY11(x) ((x) << S_RDDATARDY11)
-#define F_RDDATARDY11 V_RDDATARDY11(1U)
-
-#define S_RDDATAVLD11 4
-#define V_RDDATAVLD11(x) ((x) << S_RDDATAVLD11)
-#define F_RDDATAVLD11 V_RDDATAVLD11(1U)
-
-#define S_RDDATA11 0
-#define M_RDDATA11 0xfU
-#define V_RDDATA11(x) ((x) << S_RDDATA11)
-#define G_RDDATA11(x) (((x) >> S_RDDATA11) & M_RDDATA11)
-
-#define A_MA_HMA_CLIENT_INTERFACE_EXTERNAL 0xa00c
-
-#define S_CMDVLD12 31
-#define V_CMDVLD12(x) ((x) << S_CMDVLD12)
-#define F_CMDVLD12 V_CMDVLD12(1U)
-
-#define S_CMDRDY12 30
-#define V_CMDRDY12(x) ((x) << S_CMDRDY12)
-#define F_CMDRDY12 V_CMDRDY12(1U)
-
-#define S_CMDTYPE12 29
-#define V_CMDTYPE12(x) ((x) << S_CMDTYPE12)
-#define F_CMDTYPE12 V_CMDTYPE12(1U)
-
-#define S_CMDLEN12 21
-#define M_CMDLEN12 0xffU
-#define V_CMDLEN12(x) ((x) << S_CMDLEN12)
-#define G_CMDLEN12(x) (((x) >> S_CMDLEN12) & M_CMDLEN12)
-
-#define S_CMDADDR12 8
-#define M_CMDADDR12 0x1fffU
-#define V_CMDADDR12(x) ((x) << S_CMDADDR12)
-#define G_CMDADDR12(x) (((x) >> S_CMDADDR12) & M_CMDADDR12)
-
-#define S_WRDATAVLD12 7
-#define V_WRDATAVLD12(x) ((x) << S_WRDATAVLD12)
-#define F_WRDATAVLD12 V_WRDATAVLD12(1U)
-
-#define S_WRDATARDY12 6
-#define V_WRDATARDY12(x) ((x) << S_WRDATARDY12)
-#define F_WRDATARDY12 V_WRDATARDY12(1U)
-
-#define S_RDDATARDY12 5
-#define V_RDDATARDY12(x) ((x) << S_RDDATARDY12)
-#define F_RDDATARDY12 V_RDDATARDY12(1U)
-
-#define S_RDDATAVLD12 4
-#define V_RDDATAVLD12(x) ((x) << S_RDDATAVLD12)
-#define F_RDDATAVLD12 V_RDDATAVLD12(1U)
-
-#define S_RDDATA12 0
-#define M_RDDATA12 0xfU
-#define V_RDDATA12(x) ((x) << S_RDDATA12)
-#define G_RDDATA12(x) (((x) >> S_RDDATA12) & M_RDDATA12)
-
-#define A_MA_TARGET_0_ARBITER_INTERFACE_EXTERNAL_REG0 0xa00d
-
-#define S_CI0_ARB0_REQ 31
-#define V_CI0_ARB0_REQ(x) ((x) << S_CI0_ARB0_REQ)
-#define F_CI0_ARB0_REQ V_CI0_ARB0_REQ(1U)
-
-#define S_ARB0_CI0_GNT 30
-#define V_ARB0_CI0_GNT(x) ((x) << S_ARB0_CI0_GNT)
-#define F_ARB0_CI0_GNT V_ARB0_CI0_GNT(1U)
-
-#define S_CI0_DM0_WDATA_VLD 29
-#define V_CI0_DM0_WDATA_VLD(x) ((x) << S_CI0_DM0_WDATA_VLD)
-#define F_CI0_DM0_WDATA_VLD V_CI0_DM0_WDATA_VLD(1U)
-
-#define S_DM0_CI0_RDATA_VLD 28
-#define V_DM0_CI0_RDATA_VLD(x) ((x) << S_DM0_CI0_RDATA_VLD)
-#define F_DM0_CI0_RDATA_VLD V_DM0_CI0_RDATA_VLD(1U)
-
-#define S_CI1_ARB0_REQ 27
-#define V_CI1_ARB0_REQ(x) ((x) << S_CI1_ARB0_REQ)
-#define F_CI1_ARB0_REQ V_CI1_ARB0_REQ(1U)
-
-#define S_ARB0_CI1_GNT 26
-#define V_ARB0_CI1_GNT(x) ((x) << S_ARB0_CI1_GNT)
-#define F_ARB0_CI1_GNT V_ARB0_CI1_GNT(1U)
-
-#define S_CI1_DM0_WDATA_VLD 25
-#define V_CI1_DM0_WDATA_VLD(x) ((x) << S_CI1_DM0_WDATA_VLD)
-#define F_CI1_DM0_WDATA_VLD V_CI1_DM0_WDATA_VLD(1U)
-
-#define S_DM0_CI1_RDATA_VLD 24
-#define V_DM0_CI1_RDATA_VLD(x) ((x) << S_DM0_CI1_RDATA_VLD)
-#define F_DM0_CI1_RDATA_VLD V_DM0_CI1_RDATA_VLD(1U)
-
-#define S_CI2_ARB0_REQ 23
-#define V_CI2_ARB0_REQ(x) ((x) << S_CI2_ARB0_REQ)
-#define F_CI2_ARB0_REQ V_CI2_ARB0_REQ(1U)
-
-#define S_ARB0_CI2_GNT 22
-#define V_ARB0_CI2_GNT(x) ((x) << S_ARB0_CI2_GNT)
-#define F_ARB0_CI2_GNT V_ARB0_CI2_GNT(1U)
-
-#define S_CI2_DM0_WDATA_VLD 21
-#define V_CI2_DM0_WDATA_VLD(x) ((x) << S_CI2_DM0_WDATA_VLD)
-#define F_CI2_DM0_WDATA_VLD V_CI2_DM0_WDATA_VLD(1U)
-
-#define S_DM0_CI2_RDATA_VLD 20
-#define V_DM0_CI2_RDATA_VLD(x) ((x) << S_DM0_CI2_RDATA_VLD)
-#define F_DM0_CI2_RDATA_VLD V_DM0_CI2_RDATA_VLD(1U)
-
-#define S_CI3_ARB0_REQ 19
-#define V_CI3_ARB0_REQ(x) ((x) << S_CI3_ARB0_REQ)
-#define F_CI3_ARB0_REQ V_CI3_ARB0_REQ(1U)
-
-#define S_ARB0_CI3_GNT 18
-#define V_ARB0_CI3_GNT(x) ((x) << S_ARB0_CI3_GNT)
-#define F_ARB0_CI3_GNT V_ARB0_CI3_GNT(1U)
-
-#define S_CI3_DM0_WDATA_VLD 17
-#define V_CI3_DM0_WDATA_VLD(x) ((x) << S_CI3_DM0_WDATA_VLD)
-#define F_CI3_DM0_WDATA_VLD V_CI3_DM0_WDATA_VLD(1U)
-
-#define S_DM0_CI3_RDATA_VLD 16
-#define V_DM0_CI3_RDATA_VLD(x) ((x) << S_DM0_CI3_RDATA_VLD)
-#define F_DM0_CI3_RDATA_VLD V_DM0_CI3_RDATA_VLD(1U)
-
-#define S_CI4_ARB0_REQ 15
-#define V_CI4_ARB0_REQ(x) ((x) << S_CI4_ARB0_REQ)
-#define F_CI4_ARB0_REQ V_CI4_ARB0_REQ(1U)
-
-#define S_ARB0_CI4_GNT 14
-#define V_ARB0_CI4_GNT(x) ((x) << S_ARB0_CI4_GNT)
-#define F_ARB0_CI4_GNT V_ARB0_CI4_GNT(1U)
-
-#define S_CI4_DM0_WDATA_VLD 13
-#define V_CI4_DM0_WDATA_VLD(x) ((x) << S_CI4_DM0_WDATA_VLD)
-#define F_CI4_DM0_WDATA_VLD V_CI4_DM0_WDATA_VLD(1U)
-
-#define S_DM0_CI4_RDATA_VLD 12
-#define V_DM0_CI4_RDATA_VLD(x) ((x) << S_DM0_CI4_RDATA_VLD)
-#define F_DM0_CI4_RDATA_VLD V_DM0_CI4_RDATA_VLD(1U)
-
-#define S_CI5_ARB0_REQ 11
-#define V_CI5_ARB0_REQ(x) ((x) << S_CI5_ARB0_REQ)
-#define F_CI5_ARB0_REQ V_CI5_ARB0_REQ(1U)
-
-#define S_ARB0_CI5_GNT 10
-#define V_ARB0_CI5_GNT(x) ((x) << S_ARB0_CI5_GNT)
-#define F_ARB0_CI5_GNT V_ARB0_CI5_GNT(1U)
-
-#define S_CI5_DM0_WDATA_VLD 9
-#define V_CI5_DM0_WDATA_VLD(x) ((x) << S_CI5_DM0_WDATA_VLD)
-#define F_CI5_DM0_WDATA_VLD V_CI5_DM0_WDATA_VLD(1U)
-
-#define S_DM0_CI5_RDATA_VLD 8
-#define V_DM0_CI5_RDATA_VLD(x) ((x) << S_DM0_CI5_RDATA_VLD)
-#define F_DM0_CI5_RDATA_VLD V_DM0_CI5_RDATA_VLD(1U)
-
-#define S_CI6_ARB0_REQ 7
-#define V_CI6_ARB0_REQ(x) ((x) << S_CI6_ARB0_REQ)
-#define F_CI6_ARB0_REQ V_CI6_ARB0_REQ(1U)
-
-#define S_ARB0_CI6_GNT 6
-#define V_ARB0_CI6_GNT(x) ((x) << S_ARB0_CI6_GNT)
-#define F_ARB0_CI6_GNT V_ARB0_CI6_GNT(1U)
-
-#define S_CI6_DM0_WDATA_VLD 5
-#define V_CI6_DM0_WDATA_VLD(x) ((x) << S_CI6_DM0_WDATA_VLD)
-#define F_CI6_DM0_WDATA_VLD V_CI6_DM0_WDATA_VLD(1U)
-
-#define S_DM0_CI6_RDATA_VLD 4
-#define V_DM0_CI6_RDATA_VLD(x) ((x) << S_DM0_CI6_RDATA_VLD)
-#define F_DM0_CI6_RDATA_VLD V_DM0_CI6_RDATA_VLD(1U)
-
-#define S_CI7_ARB0_REQ 3
-#define V_CI7_ARB0_REQ(x) ((x) << S_CI7_ARB0_REQ)
-#define F_CI7_ARB0_REQ V_CI7_ARB0_REQ(1U)
-
-#define S_ARB0_CI7_GNT 2
-#define V_ARB0_CI7_GNT(x) ((x) << S_ARB0_CI7_GNT)
-#define F_ARB0_CI7_GNT V_ARB0_CI7_GNT(1U)
-
-#define S_CI7_DM0_WDATA_VLD 1
-#define V_CI7_DM0_WDATA_VLD(x) ((x) << S_CI7_DM0_WDATA_VLD)
-#define F_CI7_DM0_WDATA_VLD V_CI7_DM0_WDATA_VLD(1U)
-
-#define S_DM0_CI7_RDATA_VLD 0
-#define V_DM0_CI7_RDATA_VLD(x) ((x) << S_DM0_CI7_RDATA_VLD)
-#define F_DM0_CI7_RDATA_VLD V_DM0_CI7_RDATA_VLD(1U)
-
-#define A_MA_TARGET_1_ARBITER_INTERFACE_EXTERNAL_REG0 0xa00e
-
-#define S_CI0_ARB1_REQ 31
-#define V_CI0_ARB1_REQ(x) ((x) << S_CI0_ARB1_REQ)
-#define F_CI0_ARB1_REQ V_CI0_ARB1_REQ(1U)
-
-#define S_ARB1_CI0_GNT 30
-#define V_ARB1_CI0_GNT(x) ((x) << S_ARB1_CI0_GNT)
-#define F_ARB1_CI0_GNT V_ARB1_CI0_GNT(1U)
-
-#define S_CI0_DM1_WDATA_VLD 29
-#define V_CI0_DM1_WDATA_VLD(x) ((x) << S_CI0_DM1_WDATA_VLD)
-#define F_CI0_DM1_WDATA_VLD V_CI0_DM1_WDATA_VLD(1U)
-
-#define S_DM1_CI0_RDATA_VLD 28
-#define V_DM1_CI0_RDATA_VLD(x) ((x) << S_DM1_CI0_RDATA_VLD)
-#define F_DM1_CI0_RDATA_VLD V_DM1_CI0_RDATA_VLD(1U)
-
-#define S_CI1_ARB1_REQ 27
-#define V_CI1_ARB1_REQ(x) ((x) << S_CI1_ARB1_REQ)
-#define F_CI1_ARB1_REQ V_CI1_ARB1_REQ(1U)
-
-#define S_ARB1_CI1_GNT 26
-#define V_ARB1_CI1_GNT(x) ((x) << S_ARB1_CI1_GNT)
-#define F_ARB1_CI1_GNT V_ARB1_CI1_GNT(1U)
-
-#define S_CI1_DM1_WDATA_VLD 25
-#define V_CI1_DM1_WDATA_VLD(x) ((x) << S_CI1_DM1_WDATA_VLD)
-#define F_CI1_DM1_WDATA_VLD V_CI1_DM1_WDATA_VLD(1U)
-
-#define S_DM1_CI1_RDATA_VLD 24
-#define V_DM1_CI1_RDATA_VLD(x) ((x) << S_DM1_CI1_RDATA_VLD)
-#define F_DM1_CI1_RDATA_VLD V_DM1_CI1_RDATA_VLD(1U)
-
-#define S_CI2_ARB1_REQ 23
-#define V_CI2_ARB1_REQ(x) ((x) << S_CI2_ARB1_REQ)
-#define F_CI2_ARB1_REQ V_CI2_ARB1_REQ(1U)
-
-#define S_ARB1_CI2_GNT 22
-#define V_ARB1_CI2_GNT(x) ((x) << S_ARB1_CI2_GNT)
-#define F_ARB1_CI2_GNT V_ARB1_CI2_GNT(1U)
-
-#define S_CI2_DM1_WDATA_VLD 21
-#define V_CI2_DM1_WDATA_VLD(x) ((x) << S_CI2_DM1_WDATA_VLD)
-#define F_CI2_DM1_WDATA_VLD V_CI2_DM1_WDATA_VLD(1U)
-
-#define S_DM1_CI2_RDATA_VLD 20
-#define V_DM1_CI2_RDATA_VLD(x) ((x) << S_DM1_CI2_RDATA_VLD)
-#define F_DM1_CI2_RDATA_VLD V_DM1_CI2_RDATA_VLD(1U)
-
-#define S_CI3_ARB1_REQ 19
-#define V_CI3_ARB1_REQ(x) ((x) << S_CI3_ARB1_REQ)
-#define F_CI3_ARB1_REQ V_CI3_ARB1_REQ(1U)
-
-#define S_ARB1_CI3_GNT 18
-#define V_ARB1_CI3_GNT(x) ((x) << S_ARB1_CI3_GNT)
-#define F_ARB1_CI3_GNT V_ARB1_CI3_GNT(1U)
-
-#define S_CI3_DM1_WDATA_VLD 17
-#define V_CI3_DM1_WDATA_VLD(x) ((x) << S_CI3_DM1_WDATA_VLD)
-#define F_CI3_DM1_WDATA_VLD V_CI3_DM1_WDATA_VLD(1U)
-
-#define S_DM1_CI3_RDATA_VLD 16
-#define V_DM1_CI3_RDATA_VLD(x) ((x) << S_DM1_CI3_RDATA_VLD)
-#define F_DM1_CI3_RDATA_VLD V_DM1_CI3_RDATA_VLD(1U)
-
-#define S_CI4_ARB1_REQ 15
-#define V_CI4_ARB1_REQ(x) ((x) << S_CI4_ARB1_REQ)
-#define F_CI4_ARB1_REQ V_CI4_ARB1_REQ(1U)
-
-#define S_ARB1_CI4_GNT 14
-#define V_ARB1_CI4_GNT(x) ((x) << S_ARB1_CI4_GNT)
-#define F_ARB1_CI4_GNT V_ARB1_CI4_GNT(1U)
-
-#define S_CI4_DM1_WDATA_VLD 13
-#define V_CI4_DM1_WDATA_VLD(x) ((x) << S_CI4_DM1_WDATA_VLD)
-#define F_CI4_DM1_WDATA_VLD V_CI4_DM1_WDATA_VLD(1U)
-
-#define S_DM1_CI4_RDATA_VLD 12
-#define V_DM1_CI4_RDATA_VLD(x) ((x) << S_DM1_CI4_RDATA_VLD)
-#define F_DM1_CI4_RDATA_VLD V_DM1_CI4_RDATA_VLD(1U)
-
-#define S_CI5_ARB1_REQ 11
-#define V_CI5_ARB1_REQ(x) ((x) << S_CI5_ARB1_REQ)
-#define F_CI5_ARB1_REQ V_CI5_ARB1_REQ(1U)
-
-#define S_ARB1_CI5_GNT 10
-#define V_ARB1_CI5_GNT(x) ((x) << S_ARB1_CI5_GNT)
-#define F_ARB1_CI5_GNT V_ARB1_CI5_GNT(1U)
-
-#define S_CI5_DM1_WDATA_VLD 9
-#define V_CI5_DM1_WDATA_VLD(x) ((x) << S_CI5_DM1_WDATA_VLD)
-#define F_CI5_DM1_WDATA_VLD V_CI5_DM1_WDATA_VLD(1U)
-
-#define S_DM1_CI5_RDATA_VLD 8
-#define V_DM1_CI5_RDATA_VLD(x) ((x) << S_DM1_CI5_RDATA_VLD)
-#define F_DM1_CI5_RDATA_VLD V_DM1_CI5_RDATA_VLD(1U)
-
-#define S_CI6_ARB1_REQ 7
-#define V_CI6_ARB1_REQ(x) ((x) << S_CI6_ARB1_REQ)
-#define F_CI6_ARB1_REQ V_CI6_ARB1_REQ(1U)
-
-#define S_ARB1_CI6_GNT 6
-#define V_ARB1_CI6_GNT(x) ((x) << S_ARB1_CI6_GNT)
-#define F_ARB1_CI6_GNT V_ARB1_CI6_GNT(1U)
-
-#define S_CI6_DM1_WDATA_VLD 5
-#define V_CI6_DM1_WDATA_VLD(x) ((x) << S_CI6_DM1_WDATA_VLD)
-#define F_CI6_DM1_WDATA_VLD V_CI6_DM1_WDATA_VLD(1U)
-
-#define S_DM1_CI6_RDATA_VLD 4
-#define V_DM1_CI6_RDATA_VLD(x) ((x) << S_DM1_CI6_RDATA_VLD)
-#define F_DM1_CI6_RDATA_VLD V_DM1_CI6_RDATA_VLD(1U)
-
-#define S_CI7_ARB1_REQ 3
-#define V_CI7_ARB1_REQ(x) ((x) << S_CI7_ARB1_REQ)
-#define F_CI7_ARB1_REQ V_CI7_ARB1_REQ(1U)
-
-#define S_ARB1_CI7_GNT 2
-#define V_ARB1_CI7_GNT(x) ((x) << S_ARB1_CI7_GNT)
-#define F_ARB1_CI7_GNT V_ARB1_CI7_GNT(1U)
-
-#define S_CI7_DM1_WDATA_VLD 1
-#define V_CI7_DM1_WDATA_VLD(x) ((x) << S_CI7_DM1_WDATA_VLD)
-#define F_CI7_DM1_WDATA_VLD V_CI7_DM1_WDATA_VLD(1U)
-
-#define S_DM1_CI7_RDATA_VLD 0
-#define V_DM1_CI7_RDATA_VLD(x) ((x) << S_DM1_CI7_RDATA_VLD)
-#define F_DM1_CI7_RDATA_VLD V_DM1_CI7_RDATA_VLD(1U)
-
-#define A_MA_TARGET_2_ARBITER_INTERFACE_EXTERNAL_REG0 0xa00f
-
-#define S_CI0_ARB2_REQ 31
-#define V_CI0_ARB2_REQ(x) ((x) << S_CI0_ARB2_REQ)
-#define F_CI0_ARB2_REQ V_CI0_ARB2_REQ(1U)
-
-#define S_ARB2_CI0_GNT 30
-#define V_ARB2_CI0_GNT(x) ((x) << S_ARB2_CI0_GNT)
-#define F_ARB2_CI0_GNT V_ARB2_CI0_GNT(1U)
-
-#define S_CI0_DM2_WDATA_VLD 29
-#define V_CI0_DM2_WDATA_VLD(x) ((x) << S_CI0_DM2_WDATA_VLD)
-#define F_CI0_DM2_WDATA_VLD V_CI0_DM2_WDATA_VLD(1U)
-
-#define S_DM2_CI0_RDATA_VLD 28
-#define V_DM2_CI0_RDATA_VLD(x) ((x) << S_DM2_CI0_RDATA_VLD)
-#define F_DM2_CI0_RDATA_VLD V_DM2_CI0_RDATA_VLD(1U)
-
-#define S_CI1_ARB2_REQ 27
-#define V_CI1_ARB2_REQ(x) ((x) << S_CI1_ARB2_REQ)
-#define F_CI1_ARB2_REQ V_CI1_ARB2_REQ(1U)
-
-#define S_ARB2_CI1_GNT 26
-#define V_ARB2_CI1_GNT(x) ((x) << S_ARB2_CI1_GNT)
-#define F_ARB2_CI1_GNT V_ARB2_CI1_GNT(1U)
-
-#define S_CI1_DM2_WDATA_VLD 25
-#define V_CI1_DM2_WDATA_VLD(x) ((x) << S_CI1_DM2_WDATA_VLD)
-#define F_CI1_DM2_WDATA_VLD V_CI1_DM2_WDATA_VLD(1U)
-
-#define S_DM2_CI1_RDATA_VLD 24
-#define V_DM2_CI1_RDATA_VLD(x) ((x) << S_DM2_CI1_RDATA_VLD)
-#define F_DM2_CI1_RDATA_VLD V_DM2_CI1_RDATA_VLD(1U)
-
-#define S_CI2_ARB2_REQ 23
-#define V_CI2_ARB2_REQ(x) ((x) << S_CI2_ARB2_REQ)
-#define F_CI2_ARB2_REQ V_CI2_ARB2_REQ(1U)
-
-#define S_ARB2_CI2_GNT 22
-#define V_ARB2_CI2_GNT(x) ((x) << S_ARB2_CI2_GNT)
-#define F_ARB2_CI2_GNT V_ARB2_CI2_GNT(1U)
-
-#define S_CI2_DM2_WDATA_VLD 21
-#define V_CI2_DM2_WDATA_VLD(x) ((x) << S_CI2_DM2_WDATA_VLD)
-#define F_CI2_DM2_WDATA_VLD V_CI2_DM2_WDATA_VLD(1U)
-
-#define S_DM2_CI2_RDATA_VLD 20
-#define V_DM2_CI2_RDATA_VLD(x) ((x) << S_DM2_CI2_RDATA_VLD)
-#define F_DM2_CI2_RDATA_VLD V_DM2_CI2_RDATA_VLD(1U)
-
-#define S_CI3_ARB2_REQ 19
-#define V_CI3_ARB2_REQ(x) ((x) << S_CI3_ARB2_REQ)
-#define F_CI3_ARB2_REQ V_CI3_ARB2_REQ(1U)
-
-#define S_ARB2_CI3_GNT 18
-#define V_ARB2_CI3_GNT(x) ((x) << S_ARB2_CI3_GNT)
-#define F_ARB2_CI3_GNT V_ARB2_CI3_GNT(1U)
-
-#define S_CI3_DM2_WDATA_VLD 17
-#define V_CI3_DM2_WDATA_VLD(x) ((x) << S_CI3_DM2_WDATA_VLD)
-#define F_CI3_DM2_WDATA_VLD V_CI3_DM2_WDATA_VLD(1U)
-
-#define S_DM2_CI3_RDATA_VLD 16
-#define V_DM2_CI3_RDATA_VLD(x) ((x) << S_DM2_CI3_RDATA_VLD)
-#define F_DM2_CI3_RDATA_VLD V_DM2_CI3_RDATA_VLD(1U)
-
-#define S_CI4_ARB2_REQ 15
-#define V_CI4_ARB2_REQ(x) ((x) << S_CI4_ARB2_REQ)
-#define F_CI4_ARB2_REQ V_CI4_ARB2_REQ(1U)
-
-#define S_ARB2_CI4_GNT 14
-#define V_ARB2_CI4_GNT(x) ((x) << S_ARB2_CI4_GNT)
-#define F_ARB2_CI4_GNT V_ARB2_CI4_GNT(1U)
-
-#define S_CI4_DM2_WDATA_VLD 13
-#define V_CI4_DM2_WDATA_VLD(x) ((x) << S_CI4_DM2_WDATA_VLD)
-#define F_CI4_DM2_WDATA_VLD V_CI4_DM2_WDATA_VLD(1U)
-
-#define S_DM2_CI4_RDATA_VLD 12
-#define V_DM2_CI4_RDATA_VLD(x) ((x) << S_DM2_CI4_RDATA_VLD)
-#define F_DM2_CI4_RDATA_VLD V_DM2_CI4_RDATA_VLD(1U)
-
-#define S_CI5_ARB2_REQ 11
-#define V_CI5_ARB2_REQ(x) ((x) << S_CI5_ARB2_REQ)
-#define F_CI5_ARB2_REQ V_CI5_ARB2_REQ(1U)
-
-#define S_ARB2_CI5_GNT 10
-#define V_ARB2_CI5_GNT(x) ((x) << S_ARB2_CI5_GNT)
-#define F_ARB2_CI5_GNT V_ARB2_CI5_GNT(1U)
-
-#define S_CI5_DM2_WDATA_VLD 9
-#define V_CI5_DM2_WDATA_VLD(x) ((x) << S_CI5_DM2_WDATA_VLD)
-#define F_CI5_DM2_WDATA_VLD V_CI5_DM2_WDATA_VLD(1U)
-
-#define S_DM2_CI5_RDATA_VLD 8
-#define V_DM2_CI5_RDATA_VLD(x) ((x) << S_DM2_CI5_RDATA_VLD)
-#define F_DM2_CI5_RDATA_VLD V_DM2_CI5_RDATA_VLD(1U)
-
-#define S_CI6_ARB2_REQ 7
-#define V_CI6_ARB2_REQ(x) ((x) << S_CI6_ARB2_REQ)
-#define F_CI6_ARB2_REQ V_CI6_ARB2_REQ(1U)
-
-#define S_ARB2_CI6_GNT 6
-#define V_ARB2_CI6_GNT(x) ((x) << S_ARB2_CI6_GNT)
-#define F_ARB2_CI6_GNT V_ARB2_CI6_GNT(1U)
-
-#define S_CI6_DM2_WDATA_VLD 5
-#define V_CI6_DM2_WDATA_VLD(x) ((x) << S_CI6_DM2_WDATA_VLD)
-#define F_CI6_DM2_WDATA_VLD V_CI6_DM2_WDATA_VLD(1U)
-
-#define S_DM2_CI6_RDATA_VLD 4
-#define V_DM2_CI6_RDATA_VLD(x) ((x) << S_DM2_CI6_RDATA_VLD)
-#define F_DM2_CI6_RDATA_VLD V_DM2_CI6_RDATA_VLD(1U)
-
-#define S_CI7_ARB2_REQ 3
-#define V_CI7_ARB2_REQ(x) ((x) << S_CI7_ARB2_REQ)
-#define F_CI7_ARB2_REQ V_CI7_ARB2_REQ(1U)
-
-#define S_ARB2_CI7_GNT 2
-#define V_ARB2_CI7_GNT(x) ((x) << S_ARB2_CI7_GNT)
-#define F_ARB2_CI7_GNT V_ARB2_CI7_GNT(1U)
-
-#define S_CI7_DM2_WDATA_VLD 1
-#define V_CI7_DM2_WDATA_VLD(x) ((x) << S_CI7_DM2_WDATA_VLD)
-#define F_CI7_DM2_WDATA_VLD V_CI7_DM2_WDATA_VLD(1U)
-
-#define S_DM2_CI7_RDATA_VLD 0
-#define V_DM2_CI7_RDATA_VLD(x) ((x) << S_DM2_CI7_RDATA_VLD)
-#define F_DM2_CI7_RDATA_VLD V_DM2_CI7_RDATA_VLD(1U)
-
-#define A_MA_TARGET_3_ARBITER_INTERFACE_EXTERNAL_REG0 0xa010
-
-#define S_CI0_ARB3_REQ 31
-#define V_CI0_ARB3_REQ(x) ((x) << S_CI0_ARB3_REQ)
-#define F_CI0_ARB3_REQ V_CI0_ARB3_REQ(1U)
-
-#define S_ARB3_CI0_GNT 30
-#define V_ARB3_CI0_GNT(x) ((x) << S_ARB3_CI0_GNT)
-#define F_ARB3_CI0_GNT V_ARB3_CI0_GNT(1U)
-
-#define S_CI0_DM3_WDATA_VLD 29
-#define V_CI0_DM3_WDATA_VLD(x) ((x) << S_CI0_DM3_WDATA_VLD)
-#define F_CI0_DM3_WDATA_VLD V_CI0_DM3_WDATA_VLD(1U)
-
-#define S_DM3_CI0_RDATA_VLD 28
-#define V_DM3_CI0_RDATA_VLD(x) ((x) << S_DM3_CI0_RDATA_VLD)
-#define F_DM3_CI0_RDATA_VLD V_DM3_CI0_RDATA_VLD(1U)
-
-#define S_CI1_ARB3_REQ 27
-#define V_CI1_ARB3_REQ(x) ((x) << S_CI1_ARB3_REQ)
-#define F_CI1_ARB3_REQ V_CI1_ARB3_REQ(1U)
-
-#define S_ARB3_CI1_GNT 26
-#define V_ARB3_CI1_GNT(x) ((x) << S_ARB3_CI1_GNT)
-#define F_ARB3_CI1_GNT V_ARB3_CI1_GNT(1U)
-
-#define S_CI1_DM3_WDATA_VLD 25
-#define V_CI1_DM3_WDATA_VLD(x) ((x) << S_CI1_DM3_WDATA_VLD)
-#define F_CI1_DM3_WDATA_VLD V_CI1_DM3_WDATA_VLD(1U)
-
-#define S_DM3_CI1_RDATA_VLD 24
-#define V_DM3_CI1_RDATA_VLD(x) ((x) << S_DM3_CI1_RDATA_VLD)
-#define F_DM3_CI1_RDATA_VLD V_DM3_CI1_RDATA_VLD(1U)
-
-#define S_CI2_ARB3_REQ 23
-#define V_CI2_ARB3_REQ(x) ((x) << S_CI2_ARB3_REQ)
-#define F_CI2_ARB3_REQ V_CI2_ARB3_REQ(1U)
-
-#define S_ARB3_CI2_GNT 22
-#define V_ARB3_CI2_GNT(x) ((x) << S_ARB3_CI2_GNT)
-#define F_ARB3_CI2_GNT V_ARB3_CI2_GNT(1U)
-
-#define S_CI2_DM3_WDATA_VLD 21
-#define V_CI2_DM3_WDATA_VLD(x) ((x) << S_CI2_DM3_WDATA_VLD)
-#define F_CI2_DM3_WDATA_VLD V_CI2_DM3_WDATA_VLD(1U)
-
-#define S_DM3_CI2_RDATA_VLD 20
-#define V_DM3_CI2_RDATA_VLD(x) ((x) << S_DM3_CI2_RDATA_VLD)
-#define F_DM3_CI2_RDATA_VLD V_DM3_CI2_RDATA_VLD(1U)
-
-#define S_CI3_ARB3_REQ 19
-#define V_CI3_ARB3_REQ(x) ((x) << S_CI3_ARB3_REQ)
-#define F_CI3_ARB3_REQ V_CI3_ARB3_REQ(1U)
-
-#define S_ARB3_CI3_GNT 18
-#define V_ARB3_CI3_GNT(x) ((x) << S_ARB3_CI3_GNT)
-#define F_ARB3_CI3_GNT V_ARB3_CI3_GNT(1U)
-
-#define S_CI3_DM3_WDATA_VLD 17
-#define V_CI3_DM3_WDATA_VLD(x) ((x) << S_CI3_DM3_WDATA_VLD)
-#define F_CI3_DM3_WDATA_VLD V_CI3_DM3_WDATA_VLD(1U)
-
-#define S_DM3_CI3_RDATA_VLD 16
-#define V_DM3_CI3_RDATA_VLD(x) ((x) << S_DM3_CI3_RDATA_VLD)
-#define F_DM3_CI3_RDATA_VLD V_DM3_CI3_RDATA_VLD(1U)
-
-#define S_CI4_ARB3_REQ 15
-#define V_CI4_ARB3_REQ(x) ((x) << S_CI4_ARB3_REQ)
-#define F_CI4_ARB3_REQ V_CI4_ARB3_REQ(1U)
-
-#define S_ARB3_CI4_GNT 14
-#define V_ARB3_CI4_GNT(x) ((x) << S_ARB3_CI4_GNT)
-#define F_ARB3_CI4_GNT V_ARB3_CI4_GNT(1U)
-
-#define S_CI4_DM3_WDATA_VLD 13
-#define V_CI4_DM3_WDATA_VLD(x) ((x) << S_CI4_DM3_WDATA_VLD)
-#define F_CI4_DM3_WDATA_VLD V_CI4_DM3_WDATA_VLD(1U)
-
-#define S_DM3_CI4_RDATA_VLD 12
-#define V_DM3_CI4_RDATA_VLD(x) ((x) << S_DM3_CI4_RDATA_VLD)
-#define F_DM3_CI4_RDATA_VLD V_DM3_CI4_RDATA_VLD(1U)
-
-#define S_CI5_ARB3_REQ 11
-#define V_CI5_ARB3_REQ(x) ((x) << S_CI5_ARB3_REQ)
-#define F_CI5_ARB3_REQ V_CI5_ARB3_REQ(1U)
-
-#define S_ARB3_CI5_GNT 10
-#define V_ARB3_CI5_GNT(x) ((x) << S_ARB3_CI5_GNT)
-#define F_ARB3_CI5_GNT V_ARB3_CI5_GNT(1U)
-
-#define S_CI5_DM3_WDATA_VLD 9
-#define V_CI5_DM3_WDATA_VLD(x) ((x) << S_CI5_DM3_WDATA_VLD)
-#define F_CI5_DM3_WDATA_VLD V_CI5_DM3_WDATA_VLD(1U)
-
-#define S_DM3_CI5_RDATA_VLD 8
-#define V_DM3_CI5_RDATA_VLD(x) ((x) << S_DM3_CI5_RDATA_VLD)
-#define F_DM3_CI5_RDATA_VLD V_DM3_CI5_RDATA_VLD(1U)
-
-#define S_CI6_ARB3_REQ 7
-#define V_CI6_ARB3_REQ(x) ((x) << S_CI6_ARB3_REQ)
-#define F_CI6_ARB3_REQ V_CI6_ARB3_REQ(1U)
-
-#define S_ARB3_CI6_GNT 6
-#define V_ARB3_CI6_GNT(x) ((x) << S_ARB3_CI6_GNT)
-#define F_ARB3_CI6_GNT V_ARB3_CI6_GNT(1U)
-
-#define S_CI6_DM3_WDATA_VLD 5
-#define V_CI6_DM3_WDATA_VLD(x) ((x) << S_CI6_DM3_WDATA_VLD)
-#define F_CI6_DM3_WDATA_VLD V_CI6_DM3_WDATA_VLD(1U)
-
-#define S_DM3_CI6_RDATA_VLD 4
-#define V_DM3_CI6_RDATA_VLD(x) ((x) << S_DM3_CI6_RDATA_VLD)
-#define F_DM3_CI6_RDATA_VLD V_DM3_CI6_RDATA_VLD(1U)
-
-#define S_CI7_ARB3_REQ 3
-#define V_CI7_ARB3_REQ(x) ((x) << S_CI7_ARB3_REQ)
-#define F_CI7_ARB3_REQ V_CI7_ARB3_REQ(1U)
-
-#define S_ARB3_CI7_GNT 2
-#define V_ARB3_CI7_GNT(x) ((x) << S_ARB3_CI7_GNT)
-#define F_ARB3_CI7_GNT V_ARB3_CI7_GNT(1U)
-
-#define S_CI7_DM3_WDATA_VLD 1
-#define V_CI7_DM3_WDATA_VLD(x) ((x) << S_CI7_DM3_WDATA_VLD)
-#define F_CI7_DM3_WDATA_VLD V_CI7_DM3_WDATA_VLD(1U)
-
-#define S_DM3_CI7_RDATA_VLD 0
-#define V_DM3_CI7_RDATA_VLD(x) ((x) << S_DM3_CI7_RDATA_VLD)
-#define F_DM3_CI7_RDATA_VLD V_DM3_CI7_RDATA_VLD(1U)
-
-#define A_MA_MA_DEBUG_SIGNATURE_LTL_END 0xa011
-#define A_MA_MA_DEBUG_SIGNATURE_BIG_END_INVERSE 0xa012
-#define A_MA_TARGET_0_ARBITER_INTERFACE_EXTERNAL_REG1 0xa013
-
-#define S_CI8_ARB0_REQ 31
-#define V_CI8_ARB0_REQ(x) ((x) << S_CI8_ARB0_REQ)
-#define F_CI8_ARB0_REQ V_CI8_ARB0_REQ(1U)
-
-#define S_ARB0_CI8_GNT 30
-#define V_ARB0_CI8_GNT(x) ((x) << S_ARB0_CI8_GNT)
-#define F_ARB0_CI8_GNT V_ARB0_CI8_GNT(1U)
-
-#define S_CI8_DM0_WDATA_VLD 29
-#define V_CI8_DM0_WDATA_VLD(x) ((x) << S_CI8_DM0_WDATA_VLD)
-#define F_CI8_DM0_WDATA_VLD V_CI8_DM0_WDATA_VLD(1U)
-
-#define S_DM0_CI8_RDATA_VLD 28
-#define V_DM0_CI8_RDATA_VLD(x) ((x) << S_DM0_CI8_RDATA_VLD)
-#define F_DM0_CI8_RDATA_VLD V_DM0_CI8_RDATA_VLD(1U)
-
-#define S_CI9_ARB0_REQ 27
-#define V_CI9_ARB0_REQ(x) ((x) << S_CI9_ARB0_REQ)
-#define F_CI9_ARB0_REQ V_CI9_ARB0_REQ(1U)
-
-#define S_ARB0_CI9_GNT 26
-#define V_ARB0_CI9_GNT(x) ((x) << S_ARB0_CI9_GNT)
-#define F_ARB0_CI9_GNT V_ARB0_CI9_GNT(1U)
-
-#define S_CI9_DM0_WDATA_VLD 25
-#define V_CI9_DM0_WDATA_VLD(x) ((x) << S_CI9_DM0_WDATA_VLD)
-#define F_CI9_DM0_WDATA_VLD V_CI9_DM0_WDATA_VLD(1U)
-
-#define S_DM0_CI9_RDATA_VLD 24
-#define V_DM0_CI9_RDATA_VLD(x) ((x) << S_DM0_CI9_RDATA_VLD)
-#define F_DM0_CI9_RDATA_VLD V_DM0_CI9_RDATA_VLD(1U)
-
-#define S_CI10_ARB0_REQ 23
-#define V_CI10_ARB0_REQ(x) ((x) << S_CI10_ARB0_REQ)
-#define F_CI10_ARB0_REQ V_CI10_ARB0_REQ(1U)
-
-#define S_ARB0_CI10_GNT 22
-#define V_ARB0_CI10_GNT(x) ((x) << S_ARB0_CI10_GNT)
-#define F_ARB0_CI10_GNT V_ARB0_CI10_GNT(1U)
-
-#define S_CI10_DM0_WDATA_VLD 21
-#define V_CI10_DM0_WDATA_VLD(x) ((x) << S_CI10_DM0_WDATA_VLD)
-#define F_CI10_DM0_WDATA_VLD V_CI10_DM0_WDATA_VLD(1U)
-
-#define S_DM0_CI10_RDATA_VLD 20
-#define V_DM0_CI10_RDATA_VLD(x) ((x) << S_DM0_CI10_RDATA_VLD)
-#define F_DM0_CI10_RDATA_VLD V_DM0_CI10_RDATA_VLD(1U)
-
-#define S_CI11_ARB0_REQ 19
-#define V_CI11_ARB0_REQ(x) ((x) << S_CI11_ARB0_REQ)
-#define F_CI11_ARB0_REQ V_CI11_ARB0_REQ(1U)
-
-#define S_ARB0_CI11_GNT 18
-#define V_ARB0_CI11_GNT(x) ((x) << S_ARB0_CI11_GNT)
-#define F_ARB0_CI11_GNT V_ARB0_CI11_GNT(1U)
-
-#define S_CI11_DM0_WDATA_VLD 17
-#define V_CI11_DM0_WDATA_VLD(x) ((x) << S_CI11_DM0_WDATA_VLD)
-#define F_CI11_DM0_WDATA_VLD V_CI11_DM0_WDATA_VLD(1U)
-
-#define S_DM0_CI11_RDATA_VLD 16
-#define V_DM0_CI11_RDATA_VLD(x) ((x) << S_DM0_CI11_RDATA_VLD)
-#define F_DM0_CI11_RDATA_VLD V_DM0_CI11_RDATA_VLD(1U)
-
-#define S_CI12_ARB0_REQ 15
-#define V_CI12_ARB0_REQ(x) ((x) << S_CI12_ARB0_REQ)
-#define F_CI12_ARB0_REQ V_CI12_ARB0_REQ(1U)
-
-#define S_ARB0_CI12_GNT 14
-#define V_ARB0_CI12_GNT(x) ((x) << S_ARB0_CI12_GNT)
-#define F_ARB0_CI12_GNT V_ARB0_CI12_GNT(1U)
-
-#define S_CI12_DM0_WDATA_VLD 13
-#define V_CI12_DM0_WDATA_VLD(x) ((x) << S_CI12_DM0_WDATA_VLD)
-#define F_CI12_DM0_WDATA_VLD V_CI12_DM0_WDATA_VLD(1U)
-
-#define S_DM0_CI12_RDATA_VLD 12
-#define V_DM0_CI12_RDATA_VLD(x) ((x) << S_DM0_CI12_RDATA_VLD)
-#define F_DM0_CI12_RDATA_VLD V_DM0_CI12_RDATA_VLD(1U)
-
-#define A_MA_TARGET_1_ARBITER_INTERFACE_EXTERNAL_REG1 0xa014
-
-#define S_CI8_ARB1_REQ 31
-#define V_CI8_ARB1_REQ(x) ((x) << S_CI8_ARB1_REQ)
-#define F_CI8_ARB1_REQ V_CI8_ARB1_REQ(1U)
-
-#define S_ARB1_CI8_GNT 30
-#define V_ARB1_CI8_GNT(x) ((x) << S_ARB1_CI8_GNT)
-#define F_ARB1_CI8_GNT V_ARB1_CI8_GNT(1U)
-
-#define S_CI8_DM1_WDATA_VLD 29
-#define V_CI8_DM1_WDATA_VLD(x) ((x) << S_CI8_DM1_WDATA_VLD)
-#define F_CI8_DM1_WDATA_VLD V_CI8_DM1_WDATA_VLD(1U)
-
-#define S_DM1_CI8_RDATA_VLD 28
-#define V_DM1_CI8_RDATA_VLD(x) ((x) << S_DM1_CI8_RDATA_VLD)
-#define F_DM1_CI8_RDATA_VLD V_DM1_CI8_RDATA_VLD(1U)
-
-#define S_CI9_ARB1_REQ 27
-#define V_CI9_ARB1_REQ(x) ((x) << S_CI9_ARB1_REQ)
-#define F_CI9_ARB1_REQ V_CI9_ARB1_REQ(1U)
-
-#define S_ARB1_CI9_GNT 26
-#define V_ARB1_CI9_GNT(x) ((x) << S_ARB1_CI9_GNT)
-#define F_ARB1_CI9_GNT V_ARB1_CI9_GNT(1U)
-
-#define S_CI9_DM1_WDATA_VLD 25
-#define V_CI9_DM1_WDATA_VLD(x) ((x) << S_CI9_DM1_WDATA_VLD)
-#define F_CI9_DM1_WDATA_VLD V_CI9_DM1_WDATA_VLD(1U)
-
-#define S_DM1_CI9_RDATA_VLD 24
-#define V_DM1_CI9_RDATA_VLD(x) ((x) << S_DM1_CI9_RDATA_VLD)
-#define F_DM1_CI9_RDATA_VLD V_DM1_CI9_RDATA_VLD(1U)
-
-#define S_CI10_ARB1_REQ 23
-#define V_CI10_ARB1_REQ(x) ((x) << S_CI10_ARB1_REQ)
-#define F_CI10_ARB1_REQ V_CI10_ARB1_REQ(1U)
-
-#define S_ARB1_CI10_GNT 22
-#define V_ARB1_CI10_GNT(x) ((x) << S_ARB1_CI10_GNT)
-#define F_ARB1_CI10_GNT V_ARB1_CI10_GNT(1U)
-
-#define S_CI10_DM1_WDATA_VLD 21
-#define V_CI10_DM1_WDATA_VLD(x) ((x) << S_CI10_DM1_WDATA_VLD)
-#define F_CI10_DM1_WDATA_VLD V_CI10_DM1_WDATA_VLD(1U)
-
-#define S_DM1_CI10_RDATA_VLD 20
-#define V_DM1_CI10_RDATA_VLD(x) ((x) << S_DM1_CI10_RDATA_VLD)
-#define F_DM1_CI10_RDATA_VLD V_DM1_CI10_RDATA_VLD(1U)
-
-#define S_CI11_ARB1_REQ 19
-#define V_CI11_ARB1_REQ(x) ((x) << S_CI11_ARB1_REQ)
-#define F_CI11_ARB1_REQ V_CI11_ARB1_REQ(1U)
-
-#define S_ARB1_CI11_GNT 18
-#define V_ARB1_CI11_GNT(x) ((x) << S_ARB1_CI11_GNT)
-#define F_ARB1_CI11_GNT V_ARB1_CI11_GNT(1U)
-
-#define S_CI11_DM1_WDATA_VLD 17
-#define V_CI11_DM1_WDATA_VLD(x) ((x) << S_CI11_DM1_WDATA_VLD)
-#define F_CI11_DM1_WDATA_VLD V_CI11_DM1_WDATA_VLD(1U)
-
-#define S_DM1_CI11_RDATA_VLD 16
-#define V_DM1_CI11_RDATA_VLD(x) ((x) << S_DM1_CI11_RDATA_VLD)
-#define F_DM1_CI11_RDATA_VLD V_DM1_CI11_RDATA_VLD(1U)
-
-#define S_CI12_ARB1_REQ 15
-#define V_CI12_ARB1_REQ(x) ((x) << S_CI12_ARB1_REQ)
-#define F_CI12_ARB1_REQ V_CI12_ARB1_REQ(1U)
-
-#define S_ARB1_CI12_GNT 14
-#define V_ARB1_CI12_GNT(x) ((x) << S_ARB1_CI12_GNT)
-#define F_ARB1_CI12_GNT V_ARB1_CI12_GNT(1U)
-
-#define S_CI12_DM1_WDATA_VLD 13
-#define V_CI12_DM1_WDATA_VLD(x) ((x) << S_CI12_DM1_WDATA_VLD)
-#define F_CI12_DM1_WDATA_VLD V_CI12_DM1_WDATA_VLD(1U)
-
-#define S_DM1_CI12_RDATA_VLD 12
-#define V_DM1_CI12_RDATA_VLD(x) ((x) << S_DM1_CI12_RDATA_VLD)
-#define F_DM1_CI12_RDATA_VLD V_DM1_CI12_RDATA_VLD(1U)
-
-#define A_MA_TARGET_2_ARBITER_INTERFACE_EXTERNAL_REG1 0xa015
-
-#define S_CI8_ARB2_REQ 31
-#define V_CI8_ARB2_REQ(x) ((x) << S_CI8_ARB2_REQ)
-#define F_CI8_ARB2_REQ V_CI8_ARB2_REQ(1U)
-
-#define S_ARB2_CI8_GNT 30
-#define V_ARB2_CI8_GNT(x) ((x) << S_ARB2_CI8_GNT)
-#define F_ARB2_CI8_GNT V_ARB2_CI8_GNT(1U)
-
-#define S_CI8_DM2_WDATA_VLD 29
-#define V_CI8_DM2_WDATA_VLD(x) ((x) << S_CI8_DM2_WDATA_VLD)
-#define F_CI8_DM2_WDATA_VLD V_CI8_DM2_WDATA_VLD(1U)
-
-#define S_DM2_CI8_RDATA_VLD 28
-#define V_DM2_CI8_RDATA_VLD(x) ((x) << S_DM2_CI8_RDATA_VLD)
-#define F_DM2_CI8_RDATA_VLD V_DM2_CI8_RDATA_VLD(1U)
-
-#define S_CI9_ARB2_REQ 27
-#define V_CI9_ARB2_REQ(x) ((x) << S_CI9_ARB2_REQ)
-#define F_CI9_ARB2_REQ V_CI9_ARB2_REQ(1U)
-
-#define S_ARB2_CI9_GNT 26
-#define V_ARB2_CI9_GNT(x) ((x) << S_ARB2_CI9_GNT)
-#define F_ARB2_CI9_GNT V_ARB2_CI9_GNT(1U)
-
-#define S_CI9_DM2_WDATA_VLD 25
-#define V_CI9_DM2_WDATA_VLD(x) ((x) << S_CI9_DM2_WDATA_VLD)
-#define F_CI9_DM2_WDATA_VLD V_CI9_DM2_WDATA_VLD(1U)
-
-#define S_DM2_CI9_RDATA_VLD 24
-#define V_DM2_CI9_RDATA_VLD(x) ((x) << S_DM2_CI9_RDATA_VLD)
-#define F_DM2_CI9_RDATA_VLD V_DM2_CI9_RDATA_VLD(1U)
-
-#define S_CI10_ARB2_REQ 23
-#define V_CI10_ARB2_REQ(x) ((x) << S_CI10_ARB2_REQ)
-#define F_CI10_ARB2_REQ V_CI10_ARB2_REQ(1U)
-
-#define S_ARB2_CI10_GNT 22
-#define V_ARB2_CI10_GNT(x) ((x) << S_ARB2_CI10_GNT)
-#define F_ARB2_CI10_GNT V_ARB2_CI10_GNT(1U)
-
-#define S_CI10_DM2_WDATA_VLD 21
-#define V_CI10_DM2_WDATA_VLD(x) ((x) << S_CI10_DM2_WDATA_VLD)
-#define F_CI10_DM2_WDATA_VLD V_CI10_DM2_WDATA_VLD(1U)
-
-#define S_DM2_CI10_RDATA_VLD 20
-#define V_DM2_CI10_RDATA_VLD(x) ((x) << S_DM2_CI10_RDATA_VLD)
-#define F_DM2_CI10_RDATA_VLD V_DM2_CI10_RDATA_VLD(1U)
-
-#define S_CI11_ARB2_REQ 19
-#define V_CI11_ARB2_REQ(x) ((x) << S_CI11_ARB2_REQ)
-#define F_CI11_ARB2_REQ V_CI11_ARB2_REQ(1U)
-
-#define S_ARB2_CI11_GNT 18
-#define V_ARB2_CI11_GNT(x) ((x) << S_ARB2_CI11_GNT)
-#define F_ARB2_CI11_GNT V_ARB2_CI11_GNT(1U)
-
-#define S_CI11_DM2_WDATA_VLD 17
-#define V_CI11_DM2_WDATA_VLD(x) ((x) << S_CI11_DM2_WDATA_VLD)
-#define F_CI11_DM2_WDATA_VLD V_CI11_DM2_WDATA_VLD(1U)
-
-#define S_DM2_CI11_RDATA_VLD 16
-#define V_DM2_CI11_RDATA_VLD(x) ((x) << S_DM2_CI11_RDATA_VLD)
-#define F_DM2_CI11_RDATA_VLD V_DM2_CI11_RDATA_VLD(1U)
-
-#define S_CI12_ARB2_REQ 15
-#define V_CI12_ARB2_REQ(x) ((x) << S_CI12_ARB2_REQ)
-#define F_CI12_ARB2_REQ V_CI12_ARB2_REQ(1U)
-
-#define S_ARB2_CI12_GNT 14
-#define V_ARB2_CI12_GNT(x) ((x) << S_ARB2_CI12_GNT)
-#define F_ARB2_CI12_GNT V_ARB2_CI12_GNT(1U)
-
-#define S_CI12_DM2_WDATA_VLD 13
-#define V_CI12_DM2_WDATA_VLD(x) ((x) << S_CI12_DM2_WDATA_VLD)
-#define F_CI12_DM2_WDATA_VLD V_CI12_DM2_WDATA_VLD(1U)
-
-#define S_DM2_CI12_RDATA_VLD 12
-#define V_DM2_CI12_RDATA_VLD(x) ((x) << S_DM2_CI12_RDATA_VLD)
-#define F_DM2_CI12_RDATA_VLD V_DM2_CI12_RDATA_VLD(1U)
-
-#define A_MA_TARGET_3_ARBITER_INTERFACE_EXTERNAL_REG1 0xa016
-
-#define S_CI8_ARB3_REQ 31
-#define V_CI8_ARB3_REQ(x) ((x) << S_CI8_ARB3_REQ)
-#define F_CI8_ARB3_REQ V_CI8_ARB3_REQ(1U)
-
-#define S_ARB3_CI8_GNT 30
-#define V_ARB3_CI8_GNT(x) ((x) << S_ARB3_CI8_GNT)
-#define F_ARB3_CI8_GNT V_ARB3_CI8_GNT(1U)
-
-#define S_CI8_DM3_WDATA_VLD 29
-#define V_CI8_DM3_WDATA_VLD(x) ((x) << S_CI8_DM3_WDATA_VLD)
-#define F_CI8_DM3_WDATA_VLD V_CI8_DM3_WDATA_VLD(1U)
-
-#define S_DM3_CI8_RDATA_VLD 28
-#define V_DM3_CI8_RDATA_VLD(x) ((x) << S_DM3_CI8_RDATA_VLD)
-#define F_DM3_CI8_RDATA_VLD V_DM3_CI8_RDATA_VLD(1U)
-
-#define S_CI9_ARB3_REQ 27
-#define V_CI9_ARB3_REQ(x) ((x) << S_CI9_ARB3_REQ)
-#define F_CI9_ARB3_REQ V_CI9_ARB3_REQ(1U)
-
-#define S_ARB3_CI9_GNT 26
-#define V_ARB3_CI9_GNT(x) ((x) << S_ARB3_CI9_GNT)
-#define F_ARB3_CI9_GNT V_ARB3_CI9_GNT(1U)
-
-#define S_CI9_DM3_WDATA_VLD 25
-#define V_CI9_DM3_WDATA_VLD(x) ((x) << S_CI9_DM3_WDATA_VLD)
-#define F_CI9_DM3_WDATA_VLD V_CI9_DM3_WDATA_VLD(1U)
-
-#define S_DM3_CI9_RDATA_VLD 24
-#define V_DM3_CI9_RDATA_VLD(x) ((x) << S_DM3_CI9_RDATA_VLD)
-#define F_DM3_CI9_RDATA_VLD V_DM3_CI9_RDATA_VLD(1U)
-
-#define S_CI10_ARB3_REQ 23
-#define V_CI10_ARB3_REQ(x) ((x) << S_CI10_ARB3_REQ)
-#define F_CI10_ARB3_REQ V_CI10_ARB3_REQ(1U)
-
-#define S_ARB3_CI10_GNT 22
-#define V_ARB3_CI10_GNT(x) ((x) << S_ARB3_CI10_GNT)
-#define F_ARB3_CI10_GNT V_ARB3_CI10_GNT(1U)
-
-#define S_CI10_DM3_WDATA_VLD 21
-#define V_CI10_DM3_WDATA_VLD(x) ((x) << S_CI10_DM3_WDATA_VLD)
-#define F_CI10_DM3_WDATA_VLD V_CI10_DM3_WDATA_VLD(1U)
-
-#define S_DM3_CI10_RDATA_VLD 20
-#define V_DM3_CI10_RDATA_VLD(x) ((x) << S_DM3_CI10_RDATA_VLD)
-#define F_DM3_CI10_RDATA_VLD V_DM3_CI10_RDATA_VLD(1U)
-
-#define S_CI11_ARB3_REQ 19
-#define V_CI11_ARB3_REQ(x) ((x) << S_CI11_ARB3_REQ)
-#define F_CI11_ARB3_REQ V_CI11_ARB3_REQ(1U)
-
-#define S_ARB3_CI11_GNT 18
-#define V_ARB3_CI11_GNT(x) ((x) << S_ARB3_CI11_GNT)
-#define F_ARB3_CI11_GNT V_ARB3_CI11_GNT(1U)
-
-#define S_CI11_DM3_WDATA_VLD 17
-#define V_CI11_DM3_WDATA_VLD(x) ((x) << S_CI11_DM3_WDATA_VLD)
-#define F_CI11_DM3_WDATA_VLD V_CI11_DM3_WDATA_VLD(1U)
-
-#define S_DM3_CI11_RDATA_VLD 16
-#define V_DM3_CI11_RDATA_VLD(x) ((x) << S_DM3_CI11_RDATA_VLD)
-#define F_DM3_CI11_RDATA_VLD V_DM3_CI11_RDATA_VLD(1U)
-
-#define S_CI12_ARB3_REQ 15
-#define V_CI12_ARB3_REQ(x) ((x) << S_CI12_ARB3_REQ)
-#define F_CI12_ARB3_REQ V_CI12_ARB3_REQ(1U)
-
-#define S_ARB3_CI12_GNT 14
-#define V_ARB3_CI12_GNT(x) ((x) << S_ARB3_CI12_GNT)
-#define F_ARB3_CI12_GNT V_ARB3_CI12_GNT(1U)
-
-#define S_CI12_DM3_WDATA_VLD 13
-#define V_CI12_DM3_WDATA_VLD(x) ((x) << S_CI12_DM3_WDATA_VLD)
-#define F_CI12_DM3_WDATA_VLD V_CI12_DM3_WDATA_VLD(1U)
-
-#define S_DM3_CI12_RDATA_VLD 12
-#define V_DM3_CI12_RDATA_VLD(x) ((x) << S_DM3_CI12_RDATA_VLD)
-#define F_DM3_CI12_RDATA_VLD V_DM3_CI12_RDATA_VLD(1U)
-
-#define A_MA_SGE_THREAD_0_CLIENT_INTERFACE_INTERNAL_REG0 0xa400
-
-#define S_CMD_IN_FIFO_CNT0 30
-#define M_CMD_IN_FIFO_CNT0 0x3U
-#define V_CMD_IN_FIFO_CNT0(x) ((x) << S_CMD_IN_FIFO_CNT0)
-#define G_CMD_IN_FIFO_CNT0(x) (((x) >> S_CMD_IN_FIFO_CNT0) & M_CMD_IN_FIFO_CNT0)
-
-#define S_CMD_SPLIT_FIFO_CNT0 28
-#define M_CMD_SPLIT_FIFO_CNT0 0x3U
-#define V_CMD_SPLIT_FIFO_CNT0(x) ((x) << S_CMD_SPLIT_FIFO_CNT0)
-#define G_CMD_SPLIT_FIFO_CNT0(x) (((x) >> S_CMD_SPLIT_FIFO_CNT0) & M_CMD_SPLIT_FIFO_CNT0)
-
-#define S_CMD_THROTTLE_FIFO_CNT0 22
-#define M_CMD_THROTTLE_FIFO_CNT0 0x3fU
-#define V_CMD_THROTTLE_FIFO_CNT0(x) ((x) << S_CMD_THROTTLE_FIFO_CNT0)
-#define G_CMD_THROTTLE_FIFO_CNT0(x) (((x) >> S_CMD_THROTTLE_FIFO_CNT0) & M_CMD_THROTTLE_FIFO_CNT0)
-
-#define S_RD_CHNL_FIFO_CNT0 15
-#define M_RD_CHNL_FIFO_CNT0 0x7fU
-#define V_RD_CHNL_FIFO_CNT0(x) ((x) << S_RD_CHNL_FIFO_CNT0)
-#define G_RD_CHNL_FIFO_CNT0(x) (((x) >> S_RD_CHNL_FIFO_CNT0) & M_RD_CHNL_FIFO_CNT0)
-
-#define S_RD_DATA_EXT_FIFO_CNT0 13
-#define M_RD_DATA_EXT_FIFO_CNT0 0x3U
-#define V_RD_DATA_EXT_FIFO_CNT0(x) ((x) << S_RD_DATA_EXT_FIFO_CNT0)
-#define G_RD_DATA_EXT_FIFO_CNT0(x) (((x) >> S_RD_DATA_EXT_FIFO_CNT0) & M_RD_DATA_EXT_FIFO_CNT0)
-
-#define S_RD_DATA_512B_FIFO_CNT0 5
-#define M_RD_DATA_512B_FIFO_CNT0 0xffU
-#define V_RD_DATA_512B_FIFO_CNT0(x) ((x) << S_RD_DATA_512B_FIFO_CNT0)
-#define G_RD_DATA_512B_FIFO_CNT0(x) (((x) >> S_RD_DATA_512B_FIFO_CNT0) & M_RD_DATA_512B_FIFO_CNT0)
-
-#define S_RD_REQ_TAG_FIFO_CNT0 1
-#define M_RD_REQ_TAG_FIFO_CNT0 0xfU
-#define V_RD_REQ_TAG_FIFO_CNT0(x) ((x) << S_RD_REQ_TAG_FIFO_CNT0)
-#define G_RD_REQ_TAG_FIFO_CNT0(x) (((x) >> S_RD_REQ_TAG_FIFO_CNT0) & M_RD_REQ_TAG_FIFO_CNT0)
-
-#define A_MA_SGE_THREAD_1_CLIENT_INTERFACE_INTERNAL_REG0 0xa401
-
-#define S_CMD_IN_FIFO_CNT1 30
-#define M_CMD_IN_FIFO_CNT1 0x3U
-#define V_CMD_IN_FIFO_CNT1(x) ((x) << S_CMD_IN_FIFO_CNT1)
-#define G_CMD_IN_FIFO_CNT1(x) (((x) >> S_CMD_IN_FIFO_CNT1) & M_CMD_IN_FIFO_CNT1)
-
-#define S_CMD_SPLIT_FIFO_CNT1 28
-#define M_CMD_SPLIT_FIFO_CNT1 0x3U
-#define V_CMD_SPLIT_FIFO_CNT1(x) ((x) << S_CMD_SPLIT_FIFO_CNT1)
-#define G_CMD_SPLIT_FIFO_CNT1(x) (((x) >> S_CMD_SPLIT_FIFO_CNT1) & M_CMD_SPLIT_FIFO_CNT1)
-
-#define S_CMD_THROTTLE_FIFO_CNT1 22
-#define M_CMD_THROTTLE_FIFO_CNT1 0x3fU
-#define V_CMD_THROTTLE_FIFO_CNT1(x) ((x) << S_CMD_THROTTLE_FIFO_CNT1)
-#define G_CMD_THROTTLE_FIFO_CNT1(x) (((x) >> S_CMD_THROTTLE_FIFO_CNT1) & M_CMD_THROTTLE_FIFO_CNT1)
-
-#define S_RD_CHNL_FIFO_CNT1 15
-#define M_RD_CHNL_FIFO_CNT1 0x7fU
-#define V_RD_CHNL_FIFO_CNT1(x) ((x) << S_RD_CHNL_FIFO_CNT1)
-#define G_RD_CHNL_FIFO_CNT1(x) (((x) >> S_RD_CHNL_FIFO_CNT1) & M_RD_CHNL_FIFO_CNT1)
-
-#define S_RD_DATA_EXT_FIFO_CNT1 13
-#define M_RD_DATA_EXT_FIFO_CNT1 0x3U
-#define V_RD_DATA_EXT_FIFO_CNT1(x) ((x) << S_RD_DATA_EXT_FIFO_CNT1)
-#define G_RD_DATA_EXT_FIFO_CNT1(x) (((x) >> S_RD_DATA_EXT_FIFO_CNT1) & M_RD_DATA_EXT_FIFO_CNT1)
-
-#define S_RD_DATA_512B_FIFO_CNT1 5
-#define M_RD_DATA_512B_FIFO_CNT1 0xffU
-#define V_RD_DATA_512B_FIFO_CNT1(x) ((x) << S_RD_DATA_512B_FIFO_CNT1)
-#define G_RD_DATA_512B_FIFO_CNT1(x) (((x) >> S_RD_DATA_512B_FIFO_CNT1) & M_RD_DATA_512B_FIFO_CNT1)
-
-#define S_RD_REQ_TAG_FIFO_CNT1 1
-#define M_RD_REQ_TAG_FIFO_CNT1 0xfU
-#define V_RD_REQ_TAG_FIFO_CNT1(x) ((x) << S_RD_REQ_TAG_FIFO_CNT1)
-#define G_RD_REQ_TAG_FIFO_CNT1(x) (((x) >> S_RD_REQ_TAG_FIFO_CNT1) & M_RD_REQ_TAG_FIFO_CNT1)
-
-#define A_MA_ULP_TX_CLIENT_INTERFACE_INTERNAL_REG0 0xa402
-
-#define S_CMD_IN_FIFO_CNT2 30
-#define M_CMD_IN_FIFO_CNT2 0x3U
-#define V_CMD_IN_FIFO_CNT2(x) ((x) << S_CMD_IN_FIFO_CNT2)
-#define G_CMD_IN_FIFO_CNT2(x) (((x) >> S_CMD_IN_FIFO_CNT2) & M_CMD_IN_FIFO_CNT2)
-
-#define S_CMD_SPLIT_FIFO_CNT2 28
-#define M_CMD_SPLIT_FIFO_CNT2 0x3U
-#define V_CMD_SPLIT_FIFO_CNT2(x) ((x) << S_CMD_SPLIT_FIFO_CNT2)
-#define G_CMD_SPLIT_FIFO_CNT2(x) (((x) >> S_CMD_SPLIT_FIFO_CNT2) & M_CMD_SPLIT_FIFO_CNT2)
-
-#define S_CMD_THROTTLE_FIFO_CNT2 22
-#define M_CMD_THROTTLE_FIFO_CNT2 0x3fU
-#define V_CMD_THROTTLE_FIFO_CNT2(x) ((x) << S_CMD_THROTTLE_FIFO_CNT2)
-#define G_CMD_THROTTLE_FIFO_CNT2(x) (((x) >> S_CMD_THROTTLE_FIFO_CNT2) & M_CMD_THROTTLE_FIFO_CNT2)
-
-#define S_RD_CHNL_FIFO_CNT2 15
-#define M_RD_CHNL_FIFO_CNT2 0x7fU
-#define V_RD_CHNL_FIFO_CNT2(x) ((x) << S_RD_CHNL_FIFO_CNT2)
-#define G_RD_CHNL_FIFO_CNT2(x) (((x) >> S_RD_CHNL_FIFO_CNT2) & M_RD_CHNL_FIFO_CNT2)
-
-#define S_RD_DATA_EXT_FIFO_CNT2 13
-#define M_RD_DATA_EXT_FIFO_CNT2 0x3U
-#define V_RD_DATA_EXT_FIFO_CNT2(x) ((x) << S_RD_DATA_EXT_FIFO_CNT2)
-#define G_RD_DATA_EXT_FIFO_CNT2(x) (((x) >> S_RD_DATA_EXT_FIFO_CNT2) & M_RD_DATA_EXT_FIFO_CNT2)
-
-#define S_RD_DATA_512B_FIFO_CNT2 5
-#define M_RD_DATA_512B_FIFO_CNT2 0xffU
-#define V_RD_DATA_512B_FIFO_CNT2(x) ((x) << S_RD_DATA_512B_FIFO_CNT2)
-#define G_RD_DATA_512B_FIFO_CNT2(x) (((x) >> S_RD_DATA_512B_FIFO_CNT2) & M_RD_DATA_512B_FIFO_CNT2)
-
-#define S_RD_REQ_TAG_FIFO_CNT2 1
-#define M_RD_REQ_TAG_FIFO_CNT2 0xfU
-#define V_RD_REQ_TAG_FIFO_CNT2(x) ((x) << S_RD_REQ_TAG_FIFO_CNT2)
-#define G_RD_REQ_TAG_FIFO_CNT2(x) (((x) >> S_RD_REQ_TAG_FIFO_CNT2) & M_RD_REQ_TAG_FIFO_CNT2)
-
-#define A_MA_ULP_RX_CLIENT_INTERFACE_INTERNAL_REG0 0xa403
-
-#define S_CMD_IN_FIFO_CNT3 30
-#define M_CMD_IN_FIFO_CNT3 0x3U
-#define V_CMD_IN_FIFO_CNT3(x) ((x) << S_CMD_IN_FIFO_CNT3)
-#define G_CMD_IN_FIFO_CNT3(x) (((x) >> S_CMD_IN_FIFO_CNT3) & M_CMD_IN_FIFO_CNT3)
-
-#define S_CMD_SPLIT_FIFO_CNT3 28
-#define M_CMD_SPLIT_FIFO_CNT3 0x3U
-#define V_CMD_SPLIT_FIFO_CNT3(x) ((x) << S_CMD_SPLIT_FIFO_CNT3)
-#define G_CMD_SPLIT_FIFO_CNT3(x) (((x) >> S_CMD_SPLIT_FIFO_CNT3) & M_CMD_SPLIT_FIFO_CNT3)
-
-#define S_CMD_THROTTLE_FIFO_CNT3 22
-#define M_CMD_THROTTLE_FIFO_CNT3 0x3fU
-#define V_CMD_THROTTLE_FIFO_CNT3(x) ((x) << S_CMD_THROTTLE_FIFO_CNT3)
-#define G_CMD_THROTTLE_FIFO_CNT3(x) (((x) >> S_CMD_THROTTLE_FIFO_CNT3) & M_CMD_THROTTLE_FIFO_CNT3)
-
-#define S_RD_CHNL_FIFO_CNT3 15
-#define M_RD_CHNL_FIFO_CNT3 0x7fU
-#define V_RD_CHNL_FIFO_CNT3(x) ((x) << S_RD_CHNL_FIFO_CNT3)
-#define G_RD_CHNL_FIFO_CNT3(x) (((x) >> S_RD_CHNL_FIFO_CNT3) & M_RD_CHNL_FIFO_CNT3)
-
-#define S_RD_DATA_EXT_FIFO_CNT3 13
-#define M_RD_DATA_EXT_FIFO_CNT3 0x3U
-#define V_RD_DATA_EXT_FIFO_CNT3(x) ((x) << S_RD_DATA_EXT_FIFO_CNT3)
-#define G_RD_DATA_EXT_FIFO_CNT3(x) (((x) >> S_RD_DATA_EXT_FIFO_CNT3) & M_RD_DATA_EXT_FIFO_CNT3)
-
-#define S_RD_DATA_512B_FIFO_CNT3 5
-#define M_RD_DATA_512B_FIFO_CNT3 0xffU
-#define V_RD_DATA_512B_FIFO_CNT3(x) ((x) << S_RD_DATA_512B_FIFO_CNT3)
-#define G_RD_DATA_512B_FIFO_CNT3(x) (((x) >> S_RD_DATA_512B_FIFO_CNT3) & M_RD_DATA_512B_FIFO_CNT3)
-
-#define S_RD_REQ_TAG_FIFO_CNT3 1
-#define M_RD_REQ_TAG_FIFO_CNT3 0xfU
-#define V_RD_REQ_TAG_FIFO_CNT3(x) ((x) << S_RD_REQ_TAG_FIFO_CNT3)
-#define G_RD_REQ_TAG_FIFO_CNT3(x) (((x) >> S_RD_REQ_TAG_FIFO_CNT3) & M_RD_REQ_TAG_FIFO_CNT3)
-
-#define A_MA_ULP_TX_RX_CLIENT_INTERFACE_INTERNAL_REG0 0xa404
-
-#define S_CMD_IN_FIFO_CNT4 30
-#define M_CMD_IN_FIFO_CNT4 0x3U
-#define V_CMD_IN_FIFO_CNT4(x) ((x) << S_CMD_IN_FIFO_CNT4)
-#define G_CMD_IN_FIFO_CNT4(x) (((x) >> S_CMD_IN_FIFO_CNT4) & M_CMD_IN_FIFO_CNT4)
-
-#define S_CMD_SPLIT_FIFO_CNT4 28
-#define M_CMD_SPLIT_FIFO_CNT4 0x3U
-#define V_CMD_SPLIT_FIFO_CNT4(x) ((x) << S_CMD_SPLIT_FIFO_CNT4)
-#define G_CMD_SPLIT_FIFO_CNT4(x) (((x) >> S_CMD_SPLIT_FIFO_CNT4) & M_CMD_SPLIT_FIFO_CNT4)
-
-#define S_CMD_THROTTLE_FIFO_CNT4 22
-#define M_CMD_THROTTLE_FIFO_CNT4 0x3fU
-#define V_CMD_THROTTLE_FIFO_CNT4(x) ((x) << S_CMD_THROTTLE_FIFO_CNT4)
-#define G_CMD_THROTTLE_FIFO_CNT4(x) (((x) >> S_CMD_THROTTLE_FIFO_CNT4) & M_CMD_THROTTLE_FIFO_CNT4)
-
-#define S_RD_CHNL_FIFO_CNT4 15
-#define M_RD_CHNL_FIFO_CNT4 0x7fU
-#define V_RD_CHNL_FIFO_CNT4(x) ((x) << S_RD_CHNL_FIFO_CNT4)
-#define G_RD_CHNL_FIFO_CNT4(x) (((x) >> S_RD_CHNL_FIFO_CNT4) & M_RD_CHNL_FIFO_CNT4)
-
-#define S_RD_DATA_EXT_FIFO_CNT4 13
-#define M_RD_DATA_EXT_FIFO_CNT4 0x3U
-#define V_RD_DATA_EXT_FIFO_CNT4(x) ((x) << S_RD_DATA_EXT_FIFO_CNT4)
-#define G_RD_DATA_EXT_FIFO_CNT4(x) (((x) >> S_RD_DATA_EXT_FIFO_CNT4) & M_RD_DATA_EXT_FIFO_CNT4)
-
-#define S_RD_DATA_512B_FIFO_CNT4 5
-#define M_RD_DATA_512B_FIFO_CNT4 0xffU
-#define V_RD_DATA_512B_FIFO_CNT4(x) ((x) << S_RD_DATA_512B_FIFO_CNT4)
-#define G_RD_DATA_512B_FIFO_CNT4(x) (((x) >> S_RD_DATA_512B_FIFO_CNT4) & M_RD_DATA_512B_FIFO_CNT4)
-
-#define S_RD_REQ_TAG_FIFO_CNT4 1
-#define M_RD_REQ_TAG_FIFO_CNT4 0xfU
-#define V_RD_REQ_TAG_FIFO_CNT4(x) ((x) << S_RD_REQ_TAG_FIFO_CNT4)
-#define G_RD_REQ_TAG_FIFO_CNT4(x) (((x) >> S_RD_REQ_TAG_FIFO_CNT4) & M_RD_REQ_TAG_FIFO_CNT4)
-
-#define A_MA_TP_THREAD_0_CLIENT_INTERFACE_INTERNAL_REG0 0xa405
-
-#define S_CMD_IN_FIFO_CNT5 30
-#define M_CMD_IN_FIFO_CNT5 0x3U
-#define V_CMD_IN_FIFO_CNT5(x) ((x) << S_CMD_IN_FIFO_CNT5)
-#define G_CMD_IN_FIFO_CNT5(x) (((x) >> S_CMD_IN_FIFO_CNT5) & M_CMD_IN_FIFO_CNT5)
-
-#define S_CMD_SPLIT_FIFO_CNT5 28
-#define M_CMD_SPLIT_FIFO_CNT5 0x3U
-#define V_CMD_SPLIT_FIFO_CNT5(x) ((x) << S_CMD_SPLIT_FIFO_CNT5)
-#define G_CMD_SPLIT_FIFO_CNT5(x) (((x) >> S_CMD_SPLIT_FIFO_CNT5) & M_CMD_SPLIT_FIFO_CNT5)
-
-#define S_CMD_THROTTLE_FIFO_CNT5 22
-#define M_CMD_THROTTLE_FIFO_CNT5 0x3fU
-#define V_CMD_THROTTLE_FIFO_CNT5(x) ((x) << S_CMD_THROTTLE_FIFO_CNT5)
-#define G_CMD_THROTTLE_FIFO_CNT5(x) (((x) >> S_CMD_THROTTLE_FIFO_CNT5) & M_CMD_THROTTLE_FIFO_CNT5)
-
-#define S_RD_CHNL_FIFO_CNT5 15
-#define M_RD_CHNL_FIFO_CNT5 0x7fU
-#define V_RD_CHNL_FIFO_CNT5(x) ((x) << S_RD_CHNL_FIFO_CNT5)
-#define G_RD_CHNL_FIFO_CNT5(x) (((x) >> S_RD_CHNL_FIFO_CNT5) & M_RD_CHNL_FIFO_CNT5)
-
-#define S_RD_DATA_EXT_FIFO_CNT5 13
-#define M_RD_DATA_EXT_FIFO_CNT5 0x3U
-#define V_RD_DATA_EXT_FIFO_CNT5(x) ((x) << S_RD_DATA_EXT_FIFO_CNT5)
-#define G_RD_DATA_EXT_FIFO_CNT5(x) (((x) >> S_RD_DATA_EXT_FIFO_CNT5) & M_RD_DATA_EXT_FIFO_CNT5)
-
-#define S_RD_DATA_512B_FIFO_CNT5 5
-#define M_RD_DATA_512B_FIFO_CNT5 0xffU
-#define V_RD_DATA_512B_FIFO_CNT5(x) ((x) << S_RD_DATA_512B_FIFO_CNT5)
-#define G_RD_DATA_512B_FIFO_CNT5(x) (((x) >> S_RD_DATA_512B_FIFO_CNT5) & M_RD_DATA_512B_FIFO_CNT5)
-
-#define S_RD_REQ_TAG_FIFO_CNT5 1
-#define M_RD_REQ_TAG_FIFO_CNT5 0xfU
-#define V_RD_REQ_TAG_FIFO_CNT5(x) ((x) << S_RD_REQ_TAG_FIFO_CNT5)
-#define G_RD_REQ_TAG_FIFO_CNT5(x) (((x) >> S_RD_REQ_TAG_FIFO_CNT5) & M_RD_REQ_TAG_FIFO_CNT5)
-
-#define A_MA_TP_THREAD_1_CLIENT_INTERFACE_INTERNAL_REG0 0xa406
-
-#define S_CMD_IN_FIFO_CNT6 30
-#define M_CMD_IN_FIFO_CNT6 0x3U
-#define V_CMD_IN_FIFO_CNT6(x) ((x) << S_CMD_IN_FIFO_CNT6)
-#define G_CMD_IN_FIFO_CNT6(x) (((x) >> S_CMD_IN_FIFO_CNT6) & M_CMD_IN_FIFO_CNT6)
-
-#define S_CMD_SPLIT_FIFO_CNT6 28
-#define M_CMD_SPLIT_FIFO_CNT6 0x3U
-#define V_CMD_SPLIT_FIFO_CNT6(x) ((x) << S_CMD_SPLIT_FIFO_CNT6)
-#define G_CMD_SPLIT_FIFO_CNT6(x) (((x) >> S_CMD_SPLIT_FIFO_CNT6) & M_CMD_SPLIT_FIFO_CNT6)
-
-#define S_CMD_THROTTLE_FIFO_CNT6 22
-#define M_CMD_THROTTLE_FIFO_CNT6 0x3fU
-#define V_CMD_THROTTLE_FIFO_CNT6(x) ((x) << S_CMD_THROTTLE_FIFO_CNT6)
-#define G_CMD_THROTTLE_FIFO_CNT6(x) (((x) >> S_CMD_THROTTLE_FIFO_CNT6) & M_CMD_THROTTLE_FIFO_CNT6)
-
-#define S_RD_CHNL_FIFO_CNT6 15
-#define M_RD_CHNL_FIFO_CNT6 0x7fU
-#define V_RD_CHNL_FIFO_CNT6(x) ((x) << S_RD_CHNL_FIFO_CNT6)
-#define G_RD_CHNL_FIFO_CNT6(x) (((x) >> S_RD_CHNL_FIFO_CNT6) & M_RD_CHNL_FIFO_CNT6)
-
-#define S_RD_DATA_EXT_FIFO_CNT6 13
-#define M_RD_DATA_EXT_FIFO_CNT6 0x3U
-#define V_RD_DATA_EXT_FIFO_CNT6(x) ((x) << S_RD_DATA_EXT_FIFO_CNT6)
-#define G_RD_DATA_EXT_FIFO_CNT6(x) (((x) >> S_RD_DATA_EXT_FIFO_CNT6) & M_RD_DATA_EXT_FIFO_CNT6)
-
-#define S_RD_DATA_512B_FIFO_CNT6 5
-#define M_RD_DATA_512B_FIFO_CNT6 0xffU
-#define V_RD_DATA_512B_FIFO_CNT6(x) ((x) << S_RD_DATA_512B_FIFO_CNT6)
-#define G_RD_DATA_512B_FIFO_CNT6(x) (((x) >> S_RD_DATA_512B_FIFO_CNT6) & M_RD_DATA_512B_FIFO_CNT6)
-
-#define S_RD_REQ_TAG_FIFO_CNT6 1
-#define M_RD_REQ_TAG_FIFO_CNT6 0xfU
-#define V_RD_REQ_TAG_FIFO_CNT6(x) ((x) << S_RD_REQ_TAG_FIFO_CNT6)
-#define G_RD_REQ_TAG_FIFO_CNT6(x) (((x) >> S_RD_REQ_TAG_FIFO_CNT6) & M_RD_REQ_TAG_FIFO_CNT6)
-
-#define A_MA_LE_CLIENT_INTERFACE_INTERNAL_REG0 0xa407
-
-#define S_CMD_IN_FIFO_CNT7 30
-#define M_CMD_IN_FIFO_CNT7 0x3U
-#define V_CMD_IN_FIFO_CNT7(x) ((x) << S_CMD_IN_FIFO_CNT7)
-#define G_CMD_IN_FIFO_CNT7(x) (((x) >> S_CMD_IN_FIFO_CNT7) & M_CMD_IN_FIFO_CNT7)
-
-#define S_CMD_SPLIT_FIFO_CNT7 28
-#define M_CMD_SPLIT_FIFO_CNT7 0x3U
-#define V_CMD_SPLIT_FIFO_CNT7(x) ((x) << S_CMD_SPLIT_FIFO_CNT7)
-#define G_CMD_SPLIT_FIFO_CNT7(x) (((x) >> S_CMD_SPLIT_FIFO_CNT7) & M_CMD_SPLIT_FIFO_CNT7)
-
-#define S_CMD_THROTTLE_FIFO_CNT7 22
-#define M_CMD_THROTTLE_FIFO_CNT7 0x3fU
-#define V_CMD_THROTTLE_FIFO_CNT7(x) ((x) << S_CMD_THROTTLE_FIFO_CNT7)
-#define G_CMD_THROTTLE_FIFO_CNT7(x) (((x) >> S_CMD_THROTTLE_FIFO_CNT7) & M_CMD_THROTTLE_FIFO_CNT7)
-
-#define S_RD_CHNL_FIFO_CNT7 15
-#define M_RD_CHNL_FIFO_CNT7 0x7fU
-#define V_RD_CHNL_FIFO_CNT7(x) ((x) << S_RD_CHNL_FIFO_CNT7)
-#define G_RD_CHNL_FIFO_CNT7(x) (((x) >> S_RD_CHNL_FIFO_CNT7) & M_RD_CHNL_FIFO_CNT7)
-
-#define S_RD_DATA_EXT_FIFO_CNT7 13
-#define M_RD_DATA_EXT_FIFO_CNT7 0x3U
-#define V_RD_DATA_EXT_FIFO_CNT7(x) ((x) << S_RD_DATA_EXT_FIFO_CNT7)
-#define G_RD_DATA_EXT_FIFO_CNT7(x) (((x) >> S_RD_DATA_EXT_FIFO_CNT7) & M_RD_DATA_EXT_FIFO_CNT7)
-
-#define S_RD_DATA_512B_FIFO_CNT7 5
-#define M_RD_DATA_512B_FIFO_CNT7 0xffU
-#define V_RD_DATA_512B_FIFO_CNT7(x) ((x) << S_RD_DATA_512B_FIFO_CNT7)
-#define G_RD_DATA_512B_FIFO_CNT7(x) (((x) >> S_RD_DATA_512B_FIFO_CNT7) & M_RD_DATA_512B_FIFO_CNT7)
-
-#define S_RD_REQ_TAG_FIFO_CNT7 1
-#define M_RD_REQ_TAG_FIFO_CNT7 0xfU
-#define V_RD_REQ_TAG_FIFO_CNT7(x) ((x) << S_RD_REQ_TAG_FIFO_CNT7)
-#define G_RD_REQ_TAG_FIFO_CNT7(x) (((x) >> S_RD_REQ_TAG_FIFO_CNT7) & M_RD_REQ_TAG_FIFO_CNT7)
-
-#define A_MA_CIM_CLIENT_INTERFACE_INTERNAL_REG0 0xa408
-
-#define S_CMD_IN_FIFO_CNT8 30
-#define M_CMD_IN_FIFO_CNT8 0x3U
-#define V_CMD_IN_FIFO_CNT8(x) ((x) << S_CMD_IN_FIFO_CNT8)
-#define G_CMD_IN_FIFO_CNT8(x) (((x) >> S_CMD_IN_FIFO_CNT8) & M_CMD_IN_FIFO_CNT8)
-
-#define S_CMD_SPLIT_FIFO_CNT8 28
-#define M_CMD_SPLIT_FIFO_CNT8 0x3U
-#define V_CMD_SPLIT_FIFO_CNT8(x) ((x) << S_CMD_SPLIT_FIFO_CNT8)
-#define G_CMD_SPLIT_FIFO_CNT8(x) (((x) >> S_CMD_SPLIT_FIFO_CNT8) & M_CMD_SPLIT_FIFO_CNT8)
-
-#define S_CMD_THROTTLE_FIFO_CNT8 22
-#define M_CMD_THROTTLE_FIFO_CNT8 0x3fU
-#define V_CMD_THROTTLE_FIFO_CNT8(x) ((x) << S_CMD_THROTTLE_FIFO_CNT8)
-#define G_CMD_THROTTLE_FIFO_CNT8(x) (((x) >> S_CMD_THROTTLE_FIFO_CNT8) & M_CMD_THROTTLE_FIFO_CNT8)
-
-#define S_RD_CHNL_FIFO_CNT8 15
-#define M_RD_CHNL_FIFO_CNT8 0x7fU
-#define V_RD_CHNL_FIFO_CNT8(x) ((x) << S_RD_CHNL_FIFO_CNT8)
-#define G_RD_CHNL_FIFO_CNT8(x) (((x) >> S_RD_CHNL_FIFO_CNT8) & M_RD_CHNL_FIFO_CNT8)
-
-#define S_RD_DATA_EXT_FIFO_CNT8 13
-#define M_RD_DATA_EXT_FIFO_CNT8 0x3U
-#define V_RD_DATA_EXT_FIFO_CNT8(x) ((x) << S_RD_DATA_EXT_FIFO_CNT8)
-#define G_RD_DATA_EXT_FIFO_CNT8(x) (((x) >> S_RD_DATA_EXT_FIFO_CNT8) & M_RD_DATA_EXT_FIFO_CNT8)
-
-#define S_RD_DATA_512B_FIFO_CNT8 5
-#define M_RD_DATA_512B_FIFO_CNT8 0xffU
-#define V_RD_DATA_512B_FIFO_CNT8(x) ((x) << S_RD_DATA_512B_FIFO_CNT8)
-#define G_RD_DATA_512B_FIFO_CNT8(x) (((x) >> S_RD_DATA_512B_FIFO_CNT8) & M_RD_DATA_512B_FIFO_CNT8)
-
-#define S_RD_REQ_TAG_FIFO_CNT8 1
-#define M_RD_REQ_TAG_FIFO_CNT8 0xfU
-#define V_RD_REQ_TAG_FIFO_CNT8(x) ((x) << S_RD_REQ_TAG_FIFO_CNT8)
-#define G_RD_REQ_TAG_FIFO_CNT8(x) (((x) >> S_RD_REQ_TAG_FIFO_CNT8) & M_RD_REQ_TAG_FIFO_CNT8)
-
-#define A_MA_PCIE_CLIENT_INTERFACE_INTERNAL_REG0 0xa409
-
-#define S_CMD_IN_FIFO_CNT9 30
-#define M_CMD_IN_FIFO_CNT9 0x3U
-#define V_CMD_IN_FIFO_CNT9(x) ((x) << S_CMD_IN_FIFO_CNT9)
-#define G_CMD_IN_FIFO_CNT9(x) (((x) >> S_CMD_IN_FIFO_CNT9) & M_CMD_IN_FIFO_CNT9)
-
-#define S_CMD_SPLIT_FIFO_CNT9 28
-#define M_CMD_SPLIT_FIFO_CNT9 0x3U
-#define V_CMD_SPLIT_FIFO_CNT9(x) ((x) << S_CMD_SPLIT_FIFO_CNT9)
-#define G_CMD_SPLIT_FIFO_CNT9(x) (((x) >> S_CMD_SPLIT_FIFO_CNT9) & M_CMD_SPLIT_FIFO_CNT9)
-
-#define S_CMD_THROTTLE_FIFO_CNT9 22
-#define M_CMD_THROTTLE_FIFO_CNT9 0x3fU
-#define V_CMD_THROTTLE_FIFO_CNT9(x) ((x) << S_CMD_THROTTLE_FIFO_CNT9)
-#define G_CMD_THROTTLE_FIFO_CNT9(x) (((x) >> S_CMD_THROTTLE_FIFO_CNT9) & M_CMD_THROTTLE_FIFO_CNT9)
-
-#define S_RD_CHNL_FIFO_CNT9 15
-#define M_RD_CHNL_FIFO_CNT9 0x7fU
-#define V_RD_CHNL_FIFO_CNT9(x) ((x) << S_RD_CHNL_FIFO_CNT9)
-#define G_RD_CHNL_FIFO_CNT9(x) (((x) >> S_RD_CHNL_FIFO_CNT9) & M_RD_CHNL_FIFO_CNT9)
-
-#define S_RD_DATA_EXT_FIFO_CNT9 13
-#define M_RD_DATA_EXT_FIFO_CNT9 0x3U
-#define V_RD_DATA_EXT_FIFO_CNT9(x) ((x) << S_RD_DATA_EXT_FIFO_CNT9)
-#define G_RD_DATA_EXT_FIFO_CNT9(x) (((x) >> S_RD_DATA_EXT_FIFO_CNT9) & M_RD_DATA_EXT_FIFO_CNT9)
-
-#define S_RD_DATA_512B_FIFO_CNT9 5
-#define M_RD_DATA_512B_FIFO_CNT9 0xffU
-#define V_RD_DATA_512B_FIFO_CNT9(x) ((x) << S_RD_DATA_512B_FIFO_CNT9)
-#define G_RD_DATA_512B_FIFO_CNT9(x) (((x) >> S_RD_DATA_512B_FIFO_CNT9) & M_RD_DATA_512B_FIFO_CNT9)
-
-#define S_RD_REQ_TAG_FIFO_CNT9 1
-#define M_RD_REQ_TAG_FIFO_CNT9 0xfU
-#define V_RD_REQ_TAG_FIFO_CNT9(x) ((x) << S_RD_REQ_TAG_FIFO_CNT9)
-#define G_RD_REQ_TAG_FIFO_CNT9(x) (((x) >> S_RD_REQ_TAG_FIFO_CNT9) & M_RD_REQ_TAG_FIFO_CNT9)
-
-#define A_MA_PM_TX_CLIENT_INTERFACE_INTERNAL_REG0 0xa40a
-
-#define S_CMD_IN_FIFO_CNT10 30
-#define M_CMD_IN_FIFO_CNT10 0x3U
-#define V_CMD_IN_FIFO_CNT10(x) ((x) << S_CMD_IN_FIFO_CNT10)
-#define G_CMD_IN_FIFO_CNT10(x) (((x) >> S_CMD_IN_FIFO_CNT10) & M_CMD_IN_FIFO_CNT10)
-
-#define S_CMD_SPLIT_FIFO_CNT10 28
-#define M_CMD_SPLIT_FIFO_CNT10 0x3U
-#define V_CMD_SPLIT_FIFO_CNT10(x) ((x) << S_CMD_SPLIT_FIFO_CNT10)
-#define G_CMD_SPLIT_FIFO_CNT10(x) (((x) >> S_CMD_SPLIT_FIFO_CNT10) & M_CMD_SPLIT_FIFO_CNT10)
-
-#define S_CMD_THROTTLE_FIFO_CNT10 22
-#define M_CMD_THROTTLE_FIFO_CNT10 0x3fU
-#define V_CMD_THROTTLE_FIFO_CNT10(x) ((x) << S_CMD_THROTTLE_FIFO_CNT10)
-#define G_CMD_THROTTLE_FIFO_CNT10(x) (((x) >> S_CMD_THROTTLE_FIFO_CNT10) & M_CMD_THROTTLE_FIFO_CNT10)
-
-#define S_RD_CHNL_FIFO_CNT10 15
-#define M_RD_CHNL_FIFO_CNT10 0x7fU
-#define V_RD_CHNL_FIFO_CNT10(x) ((x) << S_RD_CHNL_FIFO_CNT10)
-#define G_RD_CHNL_FIFO_CNT10(x) (((x) >> S_RD_CHNL_FIFO_CNT10) & M_RD_CHNL_FIFO_CNT10)
-
-#define S_RD_DATA_EXT_FIFO_CNT10 13
-#define M_RD_DATA_EXT_FIFO_CNT10 0x3U
-#define V_RD_DATA_EXT_FIFO_CNT10(x) ((x) << S_RD_DATA_EXT_FIFO_CNT10)
-#define G_RD_DATA_EXT_FIFO_CNT10(x) (((x) >> S_RD_DATA_EXT_FIFO_CNT10) & M_RD_DATA_EXT_FIFO_CNT10)
-
-#define S_RD_DATA_512B_FIFO_CNT10 5
-#define M_RD_DATA_512B_FIFO_CNT10 0xffU
-#define V_RD_DATA_512B_FIFO_CNT10(x) ((x) << S_RD_DATA_512B_FIFO_CNT10)
-#define G_RD_DATA_512B_FIFO_CNT10(x) (((x) >> S_RD_DATA_512B_FIFO_CNT10) & M_RD_DATA_512B_FIFO_CNT10)
-
-#define S_RD_REQ_TAG_FIFO_CNT10 1
-#define M_RD_REQ_TAG_FIFO_CNT10 0xfU
-#define V_RD_REQ_TAG_FIFO_CNT10(x) ((x) << S_RD_REQ_TAG_FIFO_CNT10)
-#define G_RD_REQ_TAG_FIFO_CNT10(x) (((x) >> S_RD_REQ_TAG_FIFO_CNT10) & M_RD_REQ_TAG_FIFO_CNT10)
-
-#define A_MA_PM_RX_CLIENT_INTERFACE_INTERNAL_REG0 0xa40b
-
-#define S_CMD_IN_FIFO_CNT11 30
-#define M_CMD_IN_FIFO_CNT11 0x3U
-#define V_CMD_IN_FIFO_CNT11(x) ((x) << S_CMD_IN_FIFO_CNT11)
-#define G_CMD_IN_FIFO_CNT11(x) (((x) >> S_CMD_IN_FIFO_CNT11) & M_CMD_IN_FIFO_CNT11)
-
-#define S_CMD_SPLIT_FIFO_CNT11 28
-#define M_CMD_SPLIT_FIFO_CNT11 0x3U
-#define V_CMD_SPLIT_FIFO_CNT11(x) ((x) << S_CMD_SPLIT_FIFO_CNT11)
-#define G_CMD_SPLIT_FIFO_CNT11(x) (((x) >> S_CMD_SPLIT_FIFO_CNT11) & M_CMD_SPLIT_FIFO_CNT11)
-
-#define S_CMD_THROTTLE_FIFO_CNT11 22
-#define M_CMD_THROTTLE_FIFO_CNT11 0x3fU
-#define V_CMD_THROTTLE_FIFO_CNT11(x) ((x) << S_CMD_THROTTLE_FIFO_CNT11)
-#define G_CMD_THROTTLE_FIFO_CNT11(x) (((x) >> S_CMD_THROTTLE_FIFO_CNT11) & M_CMD_THROTTLE_FIFO_CNT11)
-
-#define S_RD_CHNL_FIFO_CNT11 15
-#define M_RD_CHNL_FIFO_CNT11 0x7fU
-#define V_RD_CHNL_FIFO_CNT11(x) ((x) << S_RD_CHNL_FIFO_CNT11)
-#define G_RD_CHNL_FIFO_CNT11(x) (((x) >> S_RD_CHNL_FIFO_CNT11) & M_RD_CHNL_FIFO_CNT11)
-
-#define S_RD_DATA_EXT_FIFO_CNT11 13
-#define M_RD_DATA_EXT_FIFO_CNT11 0x3U
-#define V_RD_DATA_EXT_FIFO_CNT11(x) ((x) << S_RD_DATA_EXT_FIFO_CNT11)
-#define G_RD_DATA_EXT_FIFO_CNT11(x) (((x) >> S_RD_DATA_EXT_FIFO_CNT11) & M_RD_DATA_EXT_FIFO_CNT11)
-
-#define S_RD_DATA_512B_FIFO_CNT11 5
-#define M_RD_DATA_512B_FIFO_CNT11 0xffU
-#define V_RD_DATA_512B_FIFO_CNT11(x) ((x) << S_RD_DATA_512B_FIFO_CNT11)
-#define G_RD_DATA_512B_FIFO_CNT11(x) (((x) >> S_RD_DATA_512B_FIFO_CNT11) & M_RD_DATA_512B_FIFO_CNT11)
-
-#define S_RD_REQ_TAG_FIFO_CNT11 1
-#define M_RD_REQ_TAG_FIFO_CNT11 0xfU
-#define V_RD_REQ_TAG_FIFO_CNT11(x) ((x) << S_RD_REQ_TAG_FIFO_CNT11)
-#define G_RD_REQ_TAG_FIFO_CNT11(x) (((x) >> S_RD_REQ_TAG_FIFO_CNT11) & M_RD_REQ_TAG_FIFO_CNT11)
-
-#define A_MA_HMA_CLIENT_INTERFACE_INTERNAL_REG0 0xa40c
-
-#define S_CMD_IN_FIFO_CNT12 30
-#define M_CMD_IN_FIFO_CNT12 0x3U
-#define V_CMD_IN_FIFO_CNT12(x) ((x) << S_CMD_IN_FIFO_CNT12)
-#define G_CMD_IN_FIFO_CNT12(x) (((x) >> S_CMD_IN_FIFO_CNT12) & M_CMD_IN_FIFO_CNT12)
-
-#define S_CMD_SPLIT_FIFO_CNT12 28
-#define M_CMD_SPLIT_FIFO_CNT12 0x3U
-#define V_CMD_SPLIT_FIFO_CNT12(x) ((x) << S_CMD_SPLIT_FIFO_CNT12)
-#define G_CMD_SPLIT_FIFO_CNT12(x) (((x) >> S_CMD_SPLIT_FIFO_CNT12) & M_CMD_SPLIT_FIFO_CNT12)
-
-#define S_CMD_THROTTLE_FIFO_CNT12 22
-#define M_CMD_THROTTLE_FIFO_CNT12 0x3fU
-#define V_CMD_THROTTLE_FIFO_CNT12(x) ((x) << S_CMD_THROTTLE_FIFO_CNT12)
-#define G_CMD_THROTTLE_FIFO_CNT12(x) (((x) >> S_CMD_THROTTLE_FIFO_CNT12) & M_CMD_THROTTLE_FIFO_CNT12)
-
-#define S_RD_CHNL_FIFO_CNT12 15
-#define M_RD_CHNL_FIFO_CNT12 0x7fU
-#define V_RD_CHNL_FIFO_CNT12(x) ((x) << S_RD_CHNL_FIFO_CNT12)
-#define G_RD_CHNL_FIFO_CNT12(x) (((x) >> S_RD_CHNL_FIFO_CNT12) & M_RD_CHNL_FIFO_CNT12)
-
-#define S_RD_DATA_EXT_FIFO_CNT12 13
-#define M_RD_DATA_EXT_FIFO_CNT12 0x3U
-#define V_RD_DATA_EXT_FIFO_CNT12(x) ((x) << S_RD_DATA_EXT_FIFO_CNT12)
-#define G_RD_DATA_EXT_FIFO_CNT12(x) (((x) >> S_RD_DATA_EXT_FIFO_CNT12) & M_RD_DATA_EXT_FIFO_CNT12)
-
-#define S_RD_DATA_512B_FIFO_CNT12 5
-#define M_RD_DATA_512B_FIFO_CNT12 0xffU
-#define V_RD_DATA_512B_FIFO_CNT12(x) ((x) << S_RD_DATA_512B_FIFO_CNT12)
-#define G_RD_DATA_512B_FIFO_CNT12(x) (((x) >> S_RD_DATA_512B_FIFO_CNT12) & M_RD_DATA_512B_FIFO_CNT12)
-
-#define S_RD_REQ_TAG_FIFO_CNT12 1
-#define M_RD_REQ_TAG_FIFO_CNT12 0xfU
-#define V_RD_REQ_TAG_FIFO_CNT12(x) ((x) << S_RD_REQ_TAG_FIFO_CNT12)
-#define G_RD_REQ_TAG_FIFO_CNT12(x) (((x) >> S_RD_REQ_TAG_FIFO_CNT12) & M_RD_REQ_TAG_FIFO_CNT12)
-
-#define A_MA_TARGET_0_ARBITER_INTERFACE_INTERNAL_REG0 0xa40d
-
-#define S_WR_DATA_FSM0 23
-#define V_WR_DATA_FSM0(x) ((x) << S_WR_DATA_FSM0)
-#define F_WR_DATA_FSM0 V_WR_DATA_FSM0(1U)
-
-#define S_RD_DATA_FSM0 22
-#define V_RD_DATA_FSM0(x) ((x) << S_RD_DATA_FSM0)
-#define F_RD_DATA_FSM0 V_RD_DATA_FSM0(1U)
-
-#define S_TGT_CMD_FIFO_CNT0 19
-#define M_TGT_CMD_FIFO_CNT0 0x7U
-#define V_TGT_CMD_FIFO_CNT0(x) ((x) << S_TGT_CMD_FIFO_CNT0)
-#define G_TGT_CMD_FIFO_CNT0(x) (((x) >> S_TGT_CMD_FIFO_CNT0) & M_TGT_CMD_FIFO_CNT0)
-
-#define S_CLNT_NUM_FIFO_CNT0 16
-#define M_CLNT_NUM_FIFO_CNT0 0x7U
-#define V_CLNT_NUM_FIFO_CNT0(x) ((x) << S_CLNT_NUM_FIFO_CNT0)
-#define G_CLNT_NUM_FIFO_CNT0(x) (((x) >> S_CLNT_NUM_FIFO_CNT0) & M_CLNT_NUM_FIFO_CNT0)
-
-#define S_WR_CMD_TAG_FIFO_CNT_TGT0 8
-#define M_WR_CMD_TAG_FIFO_CNT_TGT0 0xffU
-#define V_WR_CMD_TAG_FIFO_CNT_TGT0(x) ((x) << S_WR_CMD_TAG_FIFO_CNT_TGT0)
-#define G_WR_CMD_TAG_FIFO_CNT_TGT0(x) (((x) >> S_WR_CMD_TAG_FIFO_CNT_TGT0) & M_WR_CMD_TAG_FIFO_CNT_TGT0)
-
-#define S_WR_DATA_512B_FIFO_CNT_TGT0 0
-#define M_WR_DATA_512B_FIFO_CNT_TGT0 0xffU
-#define V_WR_DATA_512B_FIFO_CNT_TGT0(x) ((x) << S_WR_DATA_512B_FIFO_CNT_TGT0)
-#define G_WR_DATA_512B_FIFO_CNT_TGT0(x) (((x) >> S_WR_DATA_512B_FIFO_CNT_TGT0) & M_WR_DATA_512B_FIFO_CNT_TGT0)
-
-#define A_MA_TARGET_1_ARBITER_INTERFACE_INTERNAL_REG0 0xa40e
-
-#define S_WR_DATA_FSM1 23
-#define V_WR_DATA_FSM1(x) ((x) << S_WR_DATA_FSM1)
-#define F_WR_DATA_FSM1 V_WR_DATA_FSM1(1U)
-
-#define S_RD_DATA_FSM1 22
-#define V_RD_DATA_FSM1(x) ((x) << S_RD_DATA_FSM1)
-#define F_RD_DATA_FSM1 V_RD_DATA_FSM1(1U)
-
-#define S_TGT_CMD_FIFO_CNT1 19
-#define M_TGT_CMD_FIFO_CNT1 0x7U
-#define V_TGT_CMD_FIFO_CNT1(x) ((x) << S_TGT_CMD_FIFO_CNT1)
-#define G_TGT_CMD_FIFO_CNT1(x) (((x) >> S_TGT_CMD_FIFO_CNT1) & M_TGT_CMD_FIFO_CNT1)
-
-#define S_CLNT_NUM_FIFO_CNT1 16
-#define M_CLNT_NUM_FIFO_CNT1 0x7U
-#define V_CLNT_NUM_FIFO_CNT1(x) ((x) << S_CLNT_NUM_FIFO_CNT1)
-#define G_CLNT_NUM_FIFO_CNT1(x) (((x) >> S_CLNT_NUM_FIFO_CNT1) & M_CLNT_NUM_FIFO_CNT1)
-
-#define S_WR_CMD_TAG_FIFO_CNT_TGT1 8
-#define M_WR_CMD_TAG_FIFO_CNT_TGT1 0xffU
-#define V_WR_CMD_TAG_FIFO_CNT_TGT1(x) ((x) << S_WR_CMD_TAG_FIFO_CNT_TGT1)
-#define G_WR_CMD_TAG_FIFO_CNT_TGT1(x) (((x) >> S_WR_CMD_TAG_FIFO_CNT_TGT1) & M_WR_CMD_TAG_FIFO_CNT_TGT1)
-
-#define S_WR_DATA_512B_FIFO_CNT_TGT1 0
-#define M_WR_DATA_512B_FIFO_CNT_TGT1 0xffU
-#define V_WR_DATA_512B_FIFO_CNT_TGT1(x) ((x) << S_WR_DATA_512B_FIFO_CNT_TGT1)
-#define G_WR_DATA_512B_FIFO_CNT_TGT1(x) (((x) >> S_WR_DATA_512B_FIFO_CNT_TGT1) & M_WR_DATA_512B_FIFO_CNT_TGT1)
-
-#define A_MA_TARGET_2_ARBITER_INTERFACE_INTERNAL_REG0 0xa40f
-
-#define S_WR_DATA_FSM2 23
-#define V_WR_DATA_FSM2(x) ((x) << S_WR_DATA_FSM2)
-#define F_WR_DATA_FSM2 V_WR_DATA_FSM2(1U)
-
-#define S_RD_DATA_FSM2 22
-#define V_RD_DATA_FSM2(x) ((x) << S_RD_DATA_FSM2)
-#define F_RD_DATA_FSM2 V_RD_DATA_FSM2(1U)
-
-#define S_TGT_CMD_FIFO_CNT2 19
-#define M_TGT_CMD_FIFO_CNT2 0x7U
-#define V_TGT_CMD_FIFO_CNT2(x) ((x) << S_TGT_CMD_FIFO_CNT2)
-#define G_TGT_CMD_FIFO_CNT2(x) (((x) >> S_TGT_CMD_FIFO_CNT2) & M_TGT_CMD_FIFO_CNT2)
-
-#define S_CLNT_NUM_FIFO_CNT2 16
-#define M_CLNT_NUM_FIFO_CNT2 0x7U
-#define V_CLNT_NUM_FIFO_CNT2(x) ((x) << S_CLNT_NUM_FIFO_CNT2)
-#define G_CLNT_NUM_FIFO_CNT2(x) (((x) >> S_CLNT_NUM_FIFO_CNT2) & M_CLNT_NUM_FIFO_CNT2)
-
-#define S_WR_CMD_TAG_FIFO_CNT_TGT2 8
-#define M_WR_CMD_TAG_FIFO_CNT_TGT2 0xffU
-#define V_WR_CMD_TAG_FIFO_CNT_TGT2(x) ((x) << S_WR_CMD_TAG_FIFO_CNT_TGT2)
-#define G_WR_CMD_TAG_FIFO_CNT_TGT2(x) (((x) >> S_WR_CMD_TAG_FIFO_CNT_TGT2) & M_WR_CMD_TAG_FIFO_CNT_TGT2)
-
-#define S_WR_DATA_512B_FIFO_CNT_TGT2 0
-#define M_WR_DATA_512B_FIFO_CNT_TGT2 0xffU
-#define V_WR_DATA_512B_FIFO_CNT_TGT2(x) ((x) << S_WR_DATA_512B_FIFO_CNT_TGT2)
-#define G_WR_DATA_512B_FIFO_CNT_TGT2(x) (((x) >> S_WR_DATA_512B_FIFO_CNT_TGT2) & M_WR_DATA_512B_FIFO_CNT_TGT2)
-
-#define A_MA_TARGET_3_ARBITER_INTERFACE_INTERNAL_REG0 0xa410
-
-#define S_WR_DATA_FSM3 23
-#define V_WR_DATA_FSM3(x) ((x) << S_WR_DATA_FSM3)
-#define F_WR_DATA_FSM3 V_WR_DATA_FSM3(1U)
-
-#define S_RD_DATA_FSM3 22
-#define V_RD_DATA_FSM3(x) ((x) << S_RD_DATA_FSM3)
-#define F_RD_DATA_FSM3 V_RD_DATA_FSM3(1U)
-
-#define S_TGT_CMD_FIFO_CNT3 19
-#define M_TGT_CMD_FIFO_CNT3 0x7U
-#define V_TGT_CMD_FIFO_CNT3(x) ((x) << S_TGT_CMD_FIFO_CNT3)
-#define G_TGT_CMD_FIFO_CNT3(x) (((x) >> S_TGT_CMD_FIFO_CNT3) & M_TGT_CMD_FIFO_CNT3)
-
-#define S_CLNT_NUM_FIFO_CNT3 16
-#define M_CLNT_NUM_FIFO_CNT3 0x7U
-#define V_CLNT_NUM_FIFO_CNT3(x) ((x) << S_CLNT_NUM_FIFO_CNT3)
-#define G_CLNT_NUM_FIFO_CNT3(x) (((x) >> S_CLNT_NUM_FIFO_CNT3) & M_CLNT_NUM_FIFO_CNT3)
-
-#define S_WR_CMD_TAG_FIFO_CNT_TGT3 8
-#define M_WR_CMD_TAG_FIFO_CNT_TGT3 0xffU
-#define V_WR_CMD_TAG_FIFO_CNT_TGT3(x) ((x) << S_WR_CMD_TAG_FIFO_CNT_TGT3)
-#define G_WR_CMD_TAG_FIFO_CNT_TGT3(x) (((x) >> S_WR_CMD_TAG_FIFO_CNT_TGT3) & M_WR_CMD_TAG_FIFO_CNT_TGT3)
-
-#define S_WR_DATA_512B_FIFO_CNT_TGT 0
-#define M_WR_DATA_512B_FIFO_CNT_TGT 0xffU
-#define V_WR_DATA_512B_FIFO_CNT_TGT(x) ((x) << S_WR_DATA_512B_FIFO_CNT_TGT)
-#define G_WR_DATA_512B_FIFO_CNT_TGT(x) (((x) >> S_WR_DATA_512B_FIFO_CNT_TGT) & M_WR_DATA_512B_FIFO_CNT_TGT)
-
-#define A_MA_SGE_THREAD_0_CLNT_EXP_RD_CYC_CNT_LO 0xa412
-#define A_MA_SGE_THREAD_1_CLNT_EXP_RD_CYC_CNT_LO 0xa413
-#define A_MA_ULP_TX_CLNT_EXP_RD_CYC_CNT_LO 0xa414
-#define A_MA_ULP_RX_CLNT_EXP_RD_CYC_CNT_LO 0xa415
-#define A_MA_ULP_TX_RX_CLNT_EXP_RD_CYC_CNT_LO 0xa416
-#define A_MA_TP_THREAD_0_CLNT_EXP_RD_CYC_CNT_LO 0xa417
-#define A_MA_TP_THREAD_1_CLNT_EXP_RD_CYC_CNT_LO 0xa418
-#define A_MA_LE_CLNT_EXP_RD_CYC_CNT_LO 0xa419
-#define A_MA_CIM_CLNT_EXP_RD_CYC_CNT_LO 0xa41a
-#define A_MA_PCIE_CLNT_EXP_RD_CYC_CNT_LO 0xa41b
-#define A_MA_PM_TX_CLNT_EXP_RD_CYC_CNT_LO 0xa41c
-#define A_MA_PM_RX_CLNT_EXP_RD_CYC_CNT_LO 0xa41d
-#define A_MA_HMA_CLNT_EXP_RD_CYC_CNT_LO 0xa41e
-#define A_T6_MA_EDRAM0_WRDATA_CNT1 0xa800
-#define A_T6_MA_EDRAM0_WRDATA_CNT0 0xa801
-#define A_T6_MA_EDRAM1_WRDATA_CNT1 0xa802
-#define A_T6_MA_EDRAM1_WRDATA_CNT0 0xa803
-#define A_T6_MA_EXT_MEMORY0_WRDATA_CNT1 0xa804
-#define A_T6_MA_EXT_MEMORY0_WRDATA_CNT0 0xa805
-#define A_T6_MA_HOST_MEMORY_WRDATA_CNT1 0xa806
-#define A_T6_MA_HOST_MEMORY_WRDATA_CNT0 0xa807
-#define A_T6_MA_EXT_MEMORY1_WRDATA_CNT1 0xa808
-#define A_T6_MA_EXT_MEMORY1_WRDATA_CNT0 0xa809
-#define A_T6_MA_EDRAM0_RDDATA_CNT1 0xa80a
-#define A_T6_MA_EDRAM0_RDDATA_CNT0 0xa80b
-#define A_T6_MA_EDRAM1_RDDATA_CNT1 0xa80c
-#define A_T6_MA_EDRAM1_RDDATA_CNT0 0xa80d
-#define A_T6_MA_EXT_MEMORY0_RDDATA_CNT1 0xa80e
-#define A_T6_MA_EXT_MEMORY0_RDDATA_CNT0 0xa80f
-#define A_T6_MA_HOST_MEMORY_RDDATA_CNT1 0xa810
-#define A_T6_MA_HOST_MEMORY_RDDATA_CNT0 0xa811
-#define A_T6_MA_EXT_MEMORY1_RDDATA_CNT1 0xa812
-#define A_T6_MA_EXT_MEMORY1_RDDATA_CNT0 0xa813
-#define A_MA_SGE_THREAD_0_CLNT_ACT_WR_CYC_CNT_HI 0xac00
-#define A_MA_SGE_THREAD_0_CLNT_ACT_WR_CYC_CNT_LO 0xac01
-#define A_MA_SGE_THREAD_1_CLNT_ACT_WR_CYC_CNT_HI 0xac02
-#define A_MA_SGE_THREAD_1_CLNT_ACT_WR_CYC_CNT_LO 0xac03
-#define A_MA_ULP_TX_CLNT_ACT_WR_CYC_CNT_HI 0xac04
-#define A_MA_ULP_TX_CLNT_ACT_WR_CYC_CNT_LO 0xac05
-#define A_MA_ULP_RX_CLNT_ACT_WR_CYC_CNT_HI 0xac06
-#define A_MA_ULP_RX_CLNT_ACT_WR_CYC_CNT_LO 0xac07
-#define A_MA_ULP_TX_RX_CLNT_ACT_WR_CYC_CNT_HI 0xac08
-#define A_MA_ULP_TX_RX_CLNT_ACT_WR_CYC_CNT_LO 0xac09
-#define A_MA_TP_THREAD_0_CLNT_ACT_WR_CYC_CNT_HI 0xac0a
-#define A_MA_TP_THREAD_0_CLNT_ACT_WR_CYC_CNT_LO 0xac0b
-#define A_MA_TP_THREAD_1_CLNT_ACT_WR_CYC_CNT_HI 0xac0c
-#define A_MA_TP_THREAD_1_CLNT_ACT_WR_CYC_CNT_LO 0xac0d
-#define A_MA_LE_CLNT_ACT_WR_CYC_CNT_HI 0xac0e
-#define A_MA_LE_CLNT_ACT_WR_CYC_CNT_LO 0xac0f
-#define A_MA_CIM_CLNT_ACT_WR_CYC_CNT_HI 0xac10
-#define A_MA_CIM_CLNT_ACT_WR_CYC_CNT_LO 0xac11
-#define A_MA_PCIE_CLNT_ACT_WR_CYC_CNT_HI 0xac12
-#define A_MA_PCIE_CLNT_ACT_WR_CYC_CNT_LO 0xac13
-#define A_MA_PM_TX_CLNT_ACT_WR_CYC_CNT_HI 0xac14
-#define A_MA_PM_TX_CLNT_ACT_WR_CYC_CNT_LO 0xac15
-#define A_MA_PM_RX_CLNT_ACT_WR_CYC_CNT_HI 0xac16
-#define A_MA_PM_RX_CLNT_ACT_WR_CYC_CNT_LO 0xac17
-#define A_MA_HMA_CLNT_ACT_WR_CYC_CNT_HI 0xac18
-#define A_MA_HMA_CLNT_ACT_WR_CYC_CNT_LO 0xac19
-#define A_MA_SGE_THREAD_0_CLNT_WR_REQ_CNT 0xb000
-#define A_MA_SGE_THREAD_1_CLNT_WR_REQ_CNT 0xb001
-#define A_MA_ULP_TX_CLNT_WR_REQ_CNT 0xb002
-#define A_MA_ULP_RX_CLNT_WR_REQ_CNT 0xb003
-#define A_MA_ULP_TX_RX_CLNT_WR_REQ_CNT 0xb004
-#define A_MA_TP_THREAD_0_CLNT_WR_REQ_CNT 0xb005
-#define A_MA_TP_THREAD_1_CLNT_WR_REQ_CNT 0xb006
-#define A_MA_LE_CLNT_WR_REQ_CNT 0xb007
-#define A_MA_CIM_CLNT_WR_REQ_CNT 0xb008
-#define A_MA_PCIE_CLNT_WR_REQ_CNT 0xb009
-#define A_MA_PM_TX_CLNT_WR_REQ_CNT 0xb00a
-#define A_MA_PM_RX_CLNT_WR_REQ_CNT 0xb00b
-#define A_MA_HMA_CLNT_WR_REQ_CNT 0xb00c
-#define A_MA_SGE_THREAD_0_CLNT_RD_REQ_CNT 0xb00d
-#define A_MA_SGE_THREAD_1_CLNT_RD_REQ_CNT 0xb00e
-#define A_MA_ULP_TX_CLNT_RD_REQ_CNT 0xb00f
-#define A_MA_ULP_RX_CLNT_RD_REQ_CNT 0xb010
-#define A_MA_ULP_TX_RX_CLNT_RD_REQ_CNT 0xb011
-#define A_MA_TP_THREAD_0_CLNT_RD_REQ_CNT 0xb012
-#define A_MA_TP_THREAD_1_CLNT_RD_REQ_CNT 0xb013
-#define A_MA_LE_CLNT_RD_REQ_CNT 0xb014
-#define A_MA_CIM_CLNT_RD_REQ_CNT 0xb015
-#define A_MA_PCIE_CLNT_RD_REQ_CNT 0xb016
-#define A_MA_PM_TX_CLNT_RD_REQ_CNT 0xb017
-#define A_MA_PM_RX_CLNT_RD_REQ_CNT 0xb018
-#define A_MA_HMA_CLNT_RD_REQ_CNT 0xb019
-#define A_MA_SGE_THREAD_0_CLNT_EXP_RD_CYC_CNT_HI 0xb400
-#define A_MA_SGE_THREAD_1_CLNT_EXP_RD_CYC_CNT_HI 0xb401
-#define A_MA_ULP_TX_CLNT_EXP_RD_CYC_CNT_HI 0xb402
-#define A_MA_ULP_RX_CLNT_EXP_RD_CYC_CNT_HI 0xb403
-#define A_MA_ULP_TX_RX_CLNT_EXP_RD_CYC_CNT_HI 0xb404
-#define A_MA_TP_THREAD_0_CLNT_EXP_RD_CYC_CNT_HI 0xb405
-#define A_MA_TP_THREAD_1_CLNT_EXP_RD_CYC_CNT_HI 0xb406
-#define A_MA_LE_CLNT_EXP_RD_CYC_CNT_HI 0xb407
-#define A_MA_CIM_CLNT_EXP_RD_CYC_CNT_HI 0xb408
-#define A_MA_PCIE_CLNT_EXP_RD_CYC_CNT_HI 0xb409
-#define A_MA_PM_TX_CLNT_EXP_RD_CYC_CNT_HI 0xb40a
-#define A_MA_PM_RX_CLNT_EXP_RD_CYC_CNT_HI 0xb40b
-#define A_MA_HMA_CLNT_EXP_RD_CYC_CNT_HI 0xb40c
-#define A_MA_SGE_THREAD_0_CLNT_EXP_WR_CYC_CNT_HI 0xb40d
-#define A_MA_SGE_THREAD_1_CLNT_EXP_WR_CYC_CNT_HI 0xb40e
-#define A_MA_ULP_TX_CLNT_EXP_WR_CYC_CNT_HI 0xb40f
-#define A_MA_ULP_RX_CLNT_EXP_WR_CYC_CNT_HI 0xb410
-#define A_MA_ULP_TX_RX_CLNT_EXP_WR_CYC_CNT_HI 0xb411
-#define A_MA_TP_THREAD_0_CLNT_EXP_WR_CYC_CNT_HI 0xb412
-#define A_MA_TP_THREAD_1_CLNT_EXP_WR_CYC_CNT_HI 0xb413
-#define A_MA_LE_CLNT_EXP_WR_CYC_CNT_HI 0xb414
-#define A_MA_CIM_CLNT_EXP_WR_CYC_CNT_HI 0xb415
-#define A_MA_PCIE_CLNT_EXP_WR_CYC_CNT_HI 0xb416
-#define A_MA_PM_TX_CLNT_EXP_WR_CYC_CNT_HI 0xb417
-#define A_MA_PM_RX_CLNT_EXP_WR_CYC_CNT_HI 0xb418
-#define A_MA_HMA_CLNT_EXP_WR_CYC_CNT_HI 0xb419
-#define A_MA_SGE_THREAD_0_CLIENT_INTERFACE_INTERNAL_REG1 0xe400
-
-#define S_WR_DATA_EXT_FIFO_CNT0 30
-#define M_WR_DATA_EXT_FIFO_CNT0 0x3U
-#define V_WR_DATA_EXT_FIFO_CNT0(x) ((x) << S_WR_DATA_EXT_FIFO_CNT0)
-#define G_WR_DATA_EXT_FIFO_CNT0(x) (((x) >> S_WR_DATA_EXT_FIFO_CNT0) & M_WR_DATA_EXT_FIFO_CNT0)
-
-#define S_WR_CMD_TAG_FIFO_CNT0 26
-#define M_WR_CMD_TAG_FIFO_CNT0 0xfU
-#define V_WR_CMD_TAG_FIFO_CNT0(x) ((x) << S_WR_CMD_TAG_FIFO_CNT0)
-#define G_WR_CMD_TAG_FIFO_CNT0(x) (((x) >> S_WR_CMD_TAG_FIFO_CNT0) & M_WR_CMD_TAG_FIFO_CNT0)
-
-#define S_WR_DATA_512B_FIFO_CNT0 18
-#define M_WR_DATA_512B_FIFO_CNT0 0xffU
-#define V_WR_DATA_512B_FIFO_CNT0(x) ((x) << S_WR_DATA_512B_FIFO_CNT0)
-#define G_WR_DATA_512B_FIFO_CNT0(x) (((x) >> S_WR_DATA_512B_FIFO_CNT0) & M_WR_DATA_512B_FIFO_CNT0)
-
-#define S_RD_DATA_ALIGN_FSM0 17
-#define V_RD_DATA_ALIGN_FSM0(x) ((x) << S_RD_DATA_ALIGN_FSM0)
-#define F_RD_DATA_ALIGN_FSM0 V_RD_DATA_ALIGN_FSM0(1U)
-
-#define S_RD_DATA_FETCH_FSM0 16
-#define V_RD_DATA_FETCH_FSM0(x) ((x) << S_RD_DATA_FETCH_FSM0)
-#define F_RD_DATA_FETCH_FSM0 V_RD_DATA_FETCH_FSM0(1U)
-
-#define S_COHERENCY_TX_FSM0 15
-#define V_COHERENCY_TX_FSM0(x) ((x) << S_COHERENCY_TX_FSM0)
-#define F_COHERENCY_TX_FSM0 V_COHERENCY_TX_FSM0(1U)
-
-#define S_COHERENCY_RX_FSM0 14
-#define V_COHERENCY_RX_FSM0(x) ((x) << S_COHERENCY_RX_FSM0)
-#define F_COHERENCY_RX_FSM0 V_COHERENCY_RX_FSM0(1U)
-
-#define S_ARB_REQ_FSM0 13
-#define V_ARB_REQ_FSM0(x) ((x) << S_ARB_REQ_FSM0)
-#define F_ARB_REQ_FSM0 V_ARB_REQ_FSM0(1U)
-
-#define S_CMD_SPLIT_FSM0 10
-#define M_CMD_SPLIT_FSM0 0x7U
-#define V_CMD_SPLIT_FSM0(x) ((x) << S_CMD_SPLIT_FSM0)
-#define G_CMD_SPLIT_FSM0(x) (((x) >> S_CMD_SPLIT_FSM0) & M_CMD_SPLIT_FSM0)
-
-#define A_MA_SGE_THREAD_1_CLIENT_INTERFACE_INTERNAL_REG1 0xe420
-
-#define S_WR_DATA_EXT_FIFO_CNT1 30
-#define M_WR_DATA_EXT_FIFO_CNT1 0x3U
-#define V_WR_DATA_EXT_FIFO_CNT1(x) ((x) << S_WR_DATA_EXT_FIFO_CNT1)
-#define G_WR_DATA_EXT_FIFO_CNT1(x) (((x) >> S_WR_DATA_EXT_FIFO_CNT1) & M_WR_DATA_EXT_FIFO_CNT1)
-
-#define S_WR_CMD_TAG_FIFO_CNT1 26
-#define M_WR_CMD_TAG_FIFO_CNT1 0xfU
-#define V_WR_CMD_TAG_FIFO_CNT1(x) ((x) << S_WR_CMD_TAG_FIFO_CNT1)
-#define G_WR_CMD_TAG_FIFO_CNT1(x) (((x) >> S_WR_CMD_TAG_FIFO_CNT1) & M_WR_CMD_TAG_FIFO_CNT1)
-
-#define S_WR_DATA_512B_FIFO_CNT1 18
-#define M_WR_DATA_512B_FIFO_CNT1 0xffU
-#define V_WR_DATA_512B_FIFO_CNT1(x) ((x) << S_WR_DATA_512B_FIFO_CNT1)
-#define G_WR_DATA_512B_FIFO_CNT1(x) (((x) >> S_WR_DATA_512B_FIFO_CNT1) & M_WR_DATA_512B_FIFO_CNT1)
-
-#define S_RD_DATA_ALIGN_FSM1 17
-#define V_RD_DATA_ALIGN_FSM1(x) ((x) << S_RD_DATA_ALIGN_FSM1)
-#define F_RD_DATA_ALIGN_FSM1 V_RD_DATA_ALIGN_FSM1(1U)
-
-#define S_RD_DATA_FETCH_FSM1 16
-#define V_RD_DATA_FETCH_FSM1(x) ((x) << S_RD_DATA_FETCH_FSM1)
-#define F_RD_DATA_FETCH_FSM1 V_RD_DATA_FETCH_FSM1(1U)
-
-#define S_COHERENCY_TX_FSM1 15
-#define V_COHERENCY_TX_FSM1(x) ((x) << S_COHERENCY_TX_FSM1)
-#define F_COHERENCY_TX_FSM1 V_COHERENCY_TX_FSM1(1U)
-
-#define S_COHERENCY_RX_FSM1 14
-#define V_COHERENCY_RX_FSM1(x) ((x) << S_COHERENCY_RX_FSM1)
-#define F_COHERENCY_RX_FSM1 V_COHERENCY_RX_FSM1(1U)
-
-#define S_ARB_REQ_FSM1 13
-#define V_ARB_REQ_FSM1(x) ((x) << S_ARB_REQ_FSM1)
-#define F_ARB_REQ_FSM1 V_ARB_REQ_FSM1(1U)
-
-#define S_CMD_SPLIT_FSM1 10
-#define M_CMD_SPLIT_FSM1 0x7U
-#define V_CMD_SPLIT_FSM1(x) ((x) << S_CMD_SPLIT_FSM1)
-#define G_CMD_SPLIT_FSM1(x) (((x) >> S_CMD_SPLIT_FSM1) & M_CMD_SPLIT_FSM1)
-
-#define A_MA_ULP_TX_CLIENT_INTERFACE_INTERNAL_REG1 0xe440
-
-#define S_WR_DATA_EXT_FIFO_CNT2 30
-#define M_WR_DATA_EXT_FIFO_CNT2 0x3U
-#define V_WR_DATA_EXT_FIFO_CNT2(x) ((x) << S_WR_DATA_EXT_FIFO_CNT2)
-#define G_WR_DATA_EXT_FIFO_CNT2(x) (((x) >> S_WR_DATA_EXT_FIFO_CNT2) & M_WR_DATA_EXT_FIFO_CNT2)
-
-#define S_WR_CMD_TAG_FIFO_CNT2 26
-#define M_WR_CMD_TAG_FIFO_CNT2 0xfU
-#define V_WR_CMD_TAG_FIFO_CNT2(x) ((x) << S_WR_CMD_TAG_FIFO_CNT2)
-#define G_WR_CMD_TAG_FIFO_CNT2(x) (((x) >> S_WR_CMD_TAG_FIFO_CNT2) & M_WR_CMD_TAG_FIFO_CNT2)
-
-#define S_WR_DATA_512B_FIFO_CNT2 18
-#define M_WR_DATA_512B_FIFO_CNT2 0xffU
-#define V_WR_DATA_512B_FIFO_CNT2(x) ((x) << S_WR_DATA_512B_FIFO_CNT2)
-#define G_WR_DATA_512B_FIFO_CNT2(x) (((x) >> S_WR_DATA_512B_FIFO_CNT2) & M_WR_DATA_512B_FIFO_CNT2)
-
-#define S_RD_DATA_ALIGN_FSM2 17
-#define V_RD_DATA_ALIGN_FSM2(x) ((x) << S_RD_DATA_ALIGN_FSM2)
-#define F_RD_DATA_ALIGN_FSM2 V_RD_DATA_ALIGN_FSM2(1U)
-
-#define S_RD_DATA_FETCH_FSM2 16
-#define V_RD_DATA_FETCH_FSM2(x) ((x) << S_RD_DATA_FETCH_FSM2)
-#define F_RD_DATA_FETCH_FSM2 V_RD_DATA_FETCH_FSM2(1U)
-
-#define S_COHERENCY_TX_FSM2 15
-#define V_COHERENCY_TX_FSM2(x) ((x) << S_COHERENCY_TX_FSM2)
-#define F_COHERENCY_TX_FSM2 V_COHERENCY_TX_FSM2(1U)
-
-#define S_COHERENCY_RX_FSM2 14
-#define V_COHERENCY_RX_FSM2(x) ((x) << S_COHERENCY_RX_FSM2)
-#define F_COHERENCY_RX_FSM2 V_COHERENCY_RX_FSM2(1U)
-
-#define S_ARB_REQ_FSM2 13
-#define V_ARB_REQ_FSM2(x) ((x) << S_ARB_REQ_FSM2)
-#define F_ARB_REQ_FSM2 V_ARB_REQ_FSM2(1U)
-
-#define S_CMD_SPLIT_FSM2 10
-#define M_CMD_SPLIT_FSM2 0x7U
-#define V_CMD_SPLIT_FSM2(x) ((x) << S_CMD_SPLIT_FSM2)
-#define G_CMD_SPLIT_FSM2(x) (((x) >> S_CMD_SPLIT_FSM2) & M_CMD_SPLIT_FSM2)
-
-#define A_MA_ULP_RX_CLIENT_INTERFACE_INTERNAL_REG1 0xe460
-
-#define S_WR_DATA_EXT_FIFO_CNT3 30
-#define M_WR_DATA_EXT_FIFO_CNT3 0x3U
-#define V_WR_DATA_EXT_FIFO_CNT3(x) ((x) << S_WR_DATA_EXT_FIFO_CNT3)
-#define G_WR_DATA_EXT_FIFO_CNT3(x) (((x) >> S_WR_DATA_EXT_FIFO_CNT3) & M_WR_DATA_EXT_FIFO_CNT3)
-
-#define S_WR_CMD_TAG_FIFO_CNT3 26
-#define M_WR_CMD_TAG_FIFO_CNT3 0xfU
-#define V_WR_CMD_TAG_FIFO_CNT3(x) ((x) << S_WR_CMD_TAG_FIFO_CNT3)
-#define G_WR_CMD_TAG_FIFO_CNT3(x) (((x) >> S_WR_CMD_TAG_FIFO_CNT3) & M_WR_CMD_TAG_FIFO_CNT3)
-
-#define S_WR_DATA_512B_FIFO_CNT3 18
-#define M_WR_DATA_512B_FIFO_CNT3 0xffU
-#define V_WR_DATA_512B_FIFO_CNT3(x) ((x) << S_WR_DATA_512B_FIFO_CNT3)
-#define G_WR_DATA_512B_FIFO_CNT3(x) (((x) >> S_WR_DATA_512B_FIFO_CNT3) & M_WR_DATA_512B_FIFO_CNT3)
-
-#define S_RD_DATA_ALIGN_FSM3 17
-#define V_RD_DATA_ALIGN_FSM3(x) ((x) << S_RD_DATA_ALIGN_FSM3)
-#define F_RD_DATA_ALIGN_FSM3 V_RD_DATA_ALIGN_FSM3(1U)
-
-#define S_RD_DATA_FETCH_FSM3 16
-#define V_RD_DATA_FETCH_FSM3(x) ((x) << S_RD_DATA_FETCH_FSM3)
-#define F_RD_DATA_FETCH_FSM3 V_RD_DATA_FETCH_FSM3(1U)
-
-#define S_COHERENCY_TX_FSM3 15
-#define V_COHERENCY_TX_FSM3(x) ((x) << S_COHERENCY_TX_FSM3)
-#define F_COHERENCY_TX_FSM3 V_COHERENCY_TX_FSM3(1U)
-
-#define S_COHERENCY_RX_FSM3 14
-#define V_COHERENCY_RX_FSM3(x) ((x) << S_COHERENCY_RX_FSM3)
-#define F_COHERENCY_RX_FSM3 V_COHERENCY_RX_FSM3(1U)
-
-#define S_ARB_REQ_FSM3 13
-#define V_ARB_REQ_FSM3(x) ((x) << S_ARB_REQ_FSM3)
-#define F_ARB_REQ_FSM3 V_ARB_REQ_FSM3(1U)
-
-#define S_CMD_SPLIT_FSM3 10
-#define M_CMD_SPLIT_FSM3 0x7U
-#define V_CMD_SPLIT_FSM3(x) ((x) << S_CMD_SPLIT_FSM3)
-#define G_CMD_SPLIT_FSM3(x) (((x) >> S_CMD_SPLIT_FSM3) & M_CMD_SPLIT_FSM3)
-
-#define A_MA_ULP_TX_RX_CLIENT_INTERFACE_INTERNAL_REG1 0xe480
-
-#define S_WR_DATA_EXT_FIFO_CNT4 30
-#define M_WR_DATA_EXT_FIFO_CNT4 0x3U
-#define V_WR_DATA_EXT_FIFO_CNT4(x) ((x) << S_WR_DATA_EXT_FIFO_CNT4)
-#define G_WR_DATA_EXT_FIFO_CNT4(x) (((x) >> S_WR_DATA_EXT_FIFO_CNT4) & M_WR_DATA_EXT_FIFO_CNT4)
-
-#define S_WR_CMD_TAG_FIFO_CNT4 26
-#define M_WR_CMD_TAG_FIFO_CNT4 0xfU
-#define V_WR_CMD_TAG_FIFO_CNT4(x) ((x) << S_WR_CMD_TAG_FIFO_CNT4)
-#define G_WR_CMD_TAG_FIFO_CNT4(x) (((x) >> S_WR_CMD_TAG_FIFO_CNT4) & M_WR_CMD_TAG_FIFO_CNT4)
-
-#define S_WR_DATA_512B_FIFO_CNT4 18
-#define M_WR_DATA_512B_FIFO_CNT4 0xffU
-#define V_WR_DATA_512B_FIFO_CNT4(x) ((x) << S_WR_DATA_512B_FIFO_CNT4)
-#define G_WR_DATA_512B_FIFO_CNT4(x) (((x) >> S_WR_DATA_512B_FIFO_CNT4) & M_WR_DATA_512B_FIFO_CNT4)
-
-#define S_RD_DATA_ALIGN_FSM4 17
-#define V_RD_DATA_ALIGN_FSM4(x) ((x) << S_RD_DATA_ALIGN_FSM4)
-#define F_RD_DATA_ALIGN_FSM4 V_RD_DATA_ALIGN_FSM4(1U)
-
-#define S_RD_DATA_FETCH_FSM4 16
-#define V_RD_DATA_FETCH_FSM4(x) ((x) << S_RD_DATA_FETCH_FSM4)
-#define F_RD_DATA_FETCH_FSM4 V_RD_DATA_FETCH_FSM4(1U)
-
-#define S_COHERENCY_TX_FSM4 15
-#define V_COHERENCY_TX_FSM4(x) ((x) << S_COHERENCY_TX_FSM4)
-#define F_COHERENCY_TX_FSM4 V_COHERENCY_TX_FSM4(1U)
-
-#define S_COHERENCY_RX_FSM4 14
-#define V_COHERENCY_RX_FSM4(x) ((x) << S_COHERENCY_RX_FSM4)
-#define F_COHERENCY_RX_FSM4 V_COHERENCY_RX_FSM4(1U)
-
-#define S_ARB_REQ_FSM4 13
-#define V_ARB_REQ_FSM4(x) ((x) << S_ARB_REQ_FSM4)
-#define F_ARB_REQ_FSM4 V_ARB_REQ_FSM4(1U)
-
-#define S_CMD_SPLIT_FSM4 10
-#define M_CMD_SPLIT_FSM4 0x7U
-#define V_CMD_SPLIT_FSM4(x) ((x) << S_CMD_SPLIT_FSM4)
-#define G_CMD_SPLIT_FSM4(x) (((x) >> S_CMD_SPLIT_FSM4) & M_CMD_SPLIT_FSM4)
-
-#define A_MA_TP_THREAD_0_CLIENT_INTERFACE_INTERNAL_REG1 0xe4a0
-
-#define S_WR_DATA_EXT_FIFO_CNT5 30
-#define M_WR_DATA_EXT_FIFO_CNT5 0x3U
-#define V_WR_DATA_EXT_FIFO_CNT5(x) ((x) << S_WR_DATA_EXT_FIFO_CNT5)
-#define G_WR_DATA_EXT_FIFO_CNT5(x) (((x) >> S_WR_DATA_EXT_FIFO_CNT5) & M_WR_DATA_EXT_FIFO_CNT5)
-
-#define S_WR_CMD_TAG_FIFO_CNT5 26
-#define M_WR_CMD_TAG_FIFO_CNT5 0xfU
-#define V_WR_CMD_TAG_FIFO_CNT5(x) ((x) << S_WR_CMD_TAG_FIFO_CNT5)
-#define G_WR_CMD_TAG_FIFO_CNT5(x) (((x) >> S_WR_CMD_TAG_FIFO_CNT5) & M_WR_CMD_TAG_FIFO_CNT5)
-
-#define S_WR_DATA_512B_FIFO_CNT5 18
-#define M_WR_DATA_512B_FIFO_CNT5 0xffU
-#define V_WR_DATA_512B_FIFO_CNT5(x) ((x) << S_WR_DATA_512B_FIFO_CNT5)
-#define G_WR_DATA_512B_FIFO_CNT5(x) (((x) >> S_WR_DATA_512B_FIFO_CNT5) & M_WR_DATA_512B_FIFO_CNT5)
-
-#define S_RD_DATA_ALIGN_FSM5 17
-#define V_RD_DATA_ALIGN_FSM5(x) ((x) << S_RD_DATA_ALIGN_FSM5)
-#define F_RD_DATA_ALIGN_FSM5 V_RD_DATA_ALIGN_FSM5(1U)
-
-#define S_RD_DATA_FETCH_FSM5 16
-#define V_RD_DATA_FETCH_FSM5(x) ((x) << S_RD_DATA_FETCH_FSM5)
-#define F_RD_DATA_FETCH_FSM5 V_RD_DATA_FETCH_FSM5(1U)
-
-#define S_COHERENCY_TX_FSM5 15
-#define V_COHERENCY_TX_FSM5(x) ((x) << S_COHERENCY_TX_FSM5)
-#define F_COHERENCY_TX_FSM5 V_COHERENCY_TX_FSM5(1U)
-
-#define S_COHERENCY_RX_FSM5 14
-#define V_COHERENCY_RX_FSM5(x) ((x) << S_COHERENCY_RX_FSM5)
-#define F_COHERENCY_RX_FSM5 V_COHERENCY_RX_FSM5(1U)
-
-#define S_ARB_REQ_FSM5 13
-#define V_ARB_REQ_FSM5(x) ((x) << S_ARB_REQ_FSM5)
-#define F_ARB_REQ_FSM5 V_ARB_REQ_FSM5(1U)
-
-#define S_CMD_SPLIT_FSM5 10
-#define M_CMD_SPLIT_FSM5 0x7U
-#define V_CMD_SPLIT_FSM5(x) ((x) << S_CMD_SPLIT_FSM5)
-#define G_CMD_SPLIT_FSM5(x) (((x) >> S_CMD_SPLIT_FSM5) & M_CMD_SPLIT_FSM5)
-
-#define A_MA_TP_THREAD_1_CLIENT_INTERFACE_INTERNAL_REG1 0xe4c0
-
-#define S_WR_DATA_EXT_FIFO_CNT6 30
-#define M_WR_DATA_EXT_FIFO_CNT6 0x3U
-#define V_WR_DATA_EXT_FIFO_CNT6(x) ((x) << S_WR_DATA_EXT_FIFO_CNT6)
-#define G_WR_DATA_EXT_FIFO_CNT6(x) (((x) >> S_WR_DATA_EXT_FIFO_CNT6) & M_WR_DATA_EXT_FIFO_CNT6)
-
-#define S_WR_CMD_TAG_FIFO_CNT6 26
-#define M_WR_CMD_TAG_FIFO_CNT6 0xfU
-#define V_WR_CMD_TAG_FIFO_CNT6(x) ((x) << S_WR_CMD_TAG_FIFO_CNT6)
-#define G_WR_CMD_TAG_FIFO_CNT6(x) (((x) >> S_WR_CMD_TAG_FIFO_CNT6) & M_WR_CMD_TAG_FIFO_CNT6)
-
-#define S_WR_DATA_512B_FIFO_CNT6 18
-#define M_WR_DATA_512B_FIFO_CNT6 0xffU
-#define V_WR_DATA_512B_FIFO_CNT6(x) ((x) << S_WR_DATA_512B_FIFO_CNT6)
-#define G_WR_DATA_512B_FIFO_CNT6(x) (((x) >> S_WR_DATA_512B_FIFO_CNT6) & M_WR_DATA_512B_FIFO_CNT6)
-
-#define S_RD_DATA_ALIGN_FSM6 17
-#define V_RD_DATA_ALIGN_FSM6(x) ((x) << S_RD_DATA_ALIGN_FSM6)
-#define F_RD_DATA_ALIGN_FSM6 V_RD_DATA_ALIGN_FSM6(1U)
-
-#define S_RD_DATA_FETCH_FSM6 16
-#define V_RD_DATA_FETCH_FSM6(x) ((x) << S_RD_DATA_FETCH_FSM6)
-#define F_RD_DATA_FETCH_FSM6 V_RD_DATA_FETCH_FSM6(1U)
-
-#define S_COHERENCY_TX_FSM6 15
-#define V_COHERENCY_TX_FSM6(x) ((x) << S_COHERENCY_TX_FSM6)
-#define F_COHERENCY_TX_FSM6 V_COHERENCY_TX_FSM6(1U)
-
-#define S_COHERENCY_RX_FSM6 14
-#define V_COHERENCY_RX_FSM6(x) ((x) << S_COHERENCY_RX_FSM6)
-#define F_COHERENCY_RX_FSM6 V_COHERENCY_RX_FSM6(1U)
-
-#define S_ARB_REQ_FSM6 13
-#define V_ARB_REQ_FSM6(x) ((x) << S_ARB_REQ_FSM6)
-#define F_ARB_REQ_FSM6 V_ARB_REQ_FSM6(1U)
-
-#define S_CMD_SPLIT_FSM6 10
-#define M_CMD_SPLIT_FSM6 0x7U
-#define V_CMD_SPLIT_FSM6(x) ((x) << S_CMD_SPLIT_FSM6)
-#define G_CMD_SPLIT_FSM6(x) (((x) >> S_CMD_SPLIT_FSM6) & M_CMD_SPLIT_FSM6)
-
-#define A_MA_LE_CLIENT_INTERFACE_INTERNAL_REG1 0xe4e0
-
-#define S_WR_DATA_EXT_FIFO_CNT7 30
-#define M_WR_DATA_EXT_FIFO_CNT7 0x3U
-#define V_WR_DATA_EXT_FIFO_CNT7(x) ((x) << S_WR_DATA_EXT_FIFO_CNT7)
-#define G_WR_DATA_EXT_FIFO_CNT7(x) (((x) >> S_WR_DATA_EXT_FIFO_CNT7) & M_WR_DATA_EXT_FIFO_CNT7)
-
-#define S_WR_CMD_TAG_FIFO_CNT7 26
-#define M_WR_CMD_TAG_FIFO_CNT7 0xfU
-#define V_WR_CMD_TAG_FIFO_CNT7(x) ((x) << S_WR_CMD_TAG_FIFO_CNT7)
-#define G_WR_CMD_TAG_FIFO_CNT7(x) (((x) >> S_WR_CMD_TAG_FIFO_CNT7) & M_WR_CMD_TAG_FIFO_CNT7)
-
-#define S_WR_DATA_512B_FIFO_CNT7 18
-#define M_WR_DATA_512B_FIFO_CNT7 0xffU
-#define V_WR_DATA_512B_FIFO_CNT7(x) ((x) << S_WR_DATA_512B_FIFO_CNT7)
-#define G_WR_DATA_512B_FIFO_CNT7(x) (((x) >> S_WR_DATA_512B_FIFO_CNT7) & M_WR_DATA_512B_FIFO_CNT7)
-
-#define S_RD_DATA_ALIGN_FSM7 17
-#define V_RD_DATA_ALIGN_FSM7(x) ((x) << S_RD_DATA_ALIGN_FSM7)
-#define F_RD_DATA_ALIGN_FSM7 V_RD_DATA_ALIGN_FSM7(1U)
-
-#define S_RD_DATA_FETCH_FSM7 16
-#define V_RD_DATA_FETCH_FSM7(x) ((x) << S_RD_DATA_FETCH_FSM7)
-#define F_RD_DATA_FETCH_FSM7 V_RD_DATA_FETCH_FSM7(1U)
-
-#define S_COHERENCY_TX_FSM7 15
-#define V_COHERENCY_TX_FSM7(x) ((x) << S_COHERENCY_TX_FSM7)
-#define F_COHERENCY_TX_FSM7 V_COHERENCY_TX_FSM7(1U)
-
-#define S_COHERENCY_RX_FSM7 14
-#define V_COHERENCY_RX_FSM7(x) ((x) << S_COHERENCY_RX_FSM7)
-#define F_COHERENCY_RX_FSM7 V_COHERENCY_RX_FSM7(1U)
-
-#define S_ARB_REQ_FSM7 13
-#define V_ARB_REQ_FSM7(x) ((x) << S_ARB_REQ_FSM7)
-#define F_ARB_REQ_FSM7 V_ARB_REQ_FSM7(1U)
-
-#define S_CMD_SPLIT_FSM7 10
-#define M_CMD_SPLIT_FSM7 0x7U
-#define V_CMD_SPLIT_FSM7(x) ((x) << S_CMD_SPLIT_FSM7)
-#define G_CMD_SPLIT_FSM7(x) (((x) >> S_CMD_SPLIT_FSM7) & M_CMD_SPLIT_FSM7)
-
-#define A_MA_CIM_CLIENT_INTERFACE_INTERNAL_REG1 0xe500
-
-#define S_WR_DATA_EXT_FIFO_CNT8 30
-#define M_WR_DATA_EXT_FIFO_CNT8 0x3U
-#define V_WR_DATA_EXT_FIFO_CNT8(x) ((x) << S_WR_DATA_EXT_FIFO_CNT8)
-#define G_WR_DATA_EXT_FIFO_CNT8(x) (((x) >> S_WR_DATA_EXT_FIFO_CNT8) & M_WR_DATA_EXT_FIFO_CNT8)
-
-#define S_WR_CMD_TAG_FIFO_CNT8 26
-#define M_WR_CMD_TAG_FIFO_CNT8 0xfU
-#define V_WR_CMD_TAG_FIFO_CNT8(x) ((x) << S_WR_CMD_TAG_FIFO_CNT8)
-#define G_WR_CMD_TAG_FIFO_CNT8(x) (((x) >> S_WR_CMD_TAG_FIFO_CNT8) & M_WR_CMD_TAG_FIFO_CNT8)
-
-#define S_WR_DATA_512B_FIFO_CNT8 18
-#define M_WR_DATA_512B_FIFO_CNT8 0xffU
-#define V_WR_DATA_512B_FIFO_CNT8(x) ((x) << S_WR_DATA_512B_FIFO_CNT8)
-#define G_WR_DATA_512B_FIFO_CNT8(x) (((x) >> S_WR_DATA_512B_FIFO_CNT8) & M_WR_DATA_512B_FIFO_CNT8)
-
-#define S_RD_DATA_ALIGN_FSM8 17
-#define V_RD_DATA_ALIGN_FSM8(x) ((x) << S_RD_DATA_ALIGN_FSM8)
-#define F_RD_DATA_ALIGN_FSM8 V_RD_DATA_ALIGN_FSM8(1U)
-
-#define S_RD_DATA_FETCH_FSM8 16
-#define V_RD_DATA_FETCH_FSM8(x) ((x) << S_RD_DATA_FETCH_FSM8)
-#define F_RD_DATA_FETCH_FSM8 V_RD_DATA_FETCH_FSM8(1U)
-
-#define S_COHERENCY_TX_FSM8 15
-#define V_COHERENCY_TX_FSM8(x) ((x) << S_COHERENCY_TX_FSM8)
-#define F_COHERENCY_TX_FSM8 V_COHERENCY_TX_FSM8(1U)
-
-#define S_COHERENCY_RX_FSM8 14
-#define V_COHERENCY_RX_FSM8(x) ((x) << S_COHERENCY_RX_FSM8)
-#define F_COHERENCY_RX_FSM8 V_COHERENCY_RX_FSM8(1U)
-
-#define S_ARB_REQ_FSM8 13
-#define V_ARB_REQ_FSM8(x) ((x) << S_ARB_REQ_FSM8)
-#define F_ARB_REQ_FSM8 V_ARB_REQ_FSM8(1U)
-
-#define S_CMD_SPLIT_FSM8 10
-#define M_CMD_SPLIT_FSM8 0x7U
-#define V_CMD_SPLIT_FSM8(x) ((x) << S_CMD_SPLIT_FSM8)
-#define G_CMD_SPLIT_FSM8(x) (((x) >> S_CMD_SPLIT_FSM8) & M_CMD_SPLIT_FSM8)
-
-#define A_MA_PCIE_CLIENT_INTERFACE_INTERNAL_REG1 0xe520
-
-#define S_WR_DATA_EXT_FIFO_CNT9 30
-#define M_WR_DATA_EXT_FIFO_CNT9 0x3U
-#define V_WR_DATA_EXT_FIFO_CNT9(x) ((x) << S_WR_DATA_EXT_FIFO_CNT9)
-#define G_WR_DATA_EXT_FIFO_CNT9(x) (((x) >> S_WR_DATA_EXT_FIFO_CNT9) & M_WR_DATA_EXT_FIFO_CNT9)
-
-#define S_WR_CMD_TAG_FIFO_CNT9 26
-#define M_WR_CMD_TAG_FIFO_CNT9 0xfU
-#define V_WR_CMD_TAG_FIFO_CNT9(x) ((x) << S_WR_CMD_TAG_FIFO_CNT9)
-#define G_WR_CMD_TAG_FIFO_CNT9(x) (((x) >> S_WR_CMD_TAG_FIFO_CNT9) & M_WR_CMD_TAG_FIFO_CNT9)
-
-#define S_WR_DATA_512B_FIFO_CNT9 18
-#define M_WR_DATA_512B_FIFO_CNT9 0xffU
-#define V_WR_DATA_512B_FIFO_CNT9(x) ((x) << S_WR_DATA_512B_FIFO_CNT9)
-#define G_WR_DATA_512B_FIFO_CNT9(x) (((x) >> S_WR_DATA_512B_FIFO_CNT9) & M_WR_DATA_512B_FIFO_CNT9)
-
-#define S_RD_DATA_ALIGN_FSM9 17
-#define V_RD_DATA_ALIGN_FSM9(x) ((x) << S_RD_DATA_ALIGN_FSM9)
-#define F_RD_DATA_ALIGN_FSM9 V_RD_DATA_ALIGN_FSM9(1U)
-
-#define S_RD_DATA_FETCH_FSM9 16
-#define V_RD_DATA_FETCH_FSM9(x) ((x) << S_RD_DATA_FETCH_FSM9)
-#define F_RD_DATA_FETCH_FSM9 V_RD_DATA_FETCH_FSM9(1U)
-
-#define S_COHERENCY_TX_FSM9 15
-#define V_COHERENCY_TX_FSM9(x) ((x) << S_COHERENCY_TX_FSM9)
-#define F_COHERENCY_TX_FSM9 V_COHERENCY_TX_FSM9(1U)
-
-#define S_COHERENCY_RX_FSM9 14
-#define V_COHERENCY_RX_FSM9(x) ((x) << S_COHERENCY_RX_FSM9)
-#define F_COHERENCY_RX_FSM9 V_COHERENCY_RX_FSM9(1U)
-
-#define S_ARB_REQ_FSM9 13
-#define V_ARB_REQ_FSM9(x) ((x) << S_ARB_REQ_FSM9)
-#define F_ARB_REQ_FSM9 V_ARB_REQ_FSM9(1U)
-
-#define S_CMD_SPLIT_FSM9 10
-#define M_CMD_SPLIT_FSM9 0x7U
-#define V_CMD_SPLIT_FSM9(x) ((x) << S_CMD_SPLIT_FSM9)
-#define G_CMD_SPLIT_FSM9(x) (((x) >> S_CMD_SPLIT_FSM9) & M_CMD_SPLIT_FSM9)
-
-#define A_MA_PM_TX_CLIENT_INTERFACE_INTERNAL_REG1 0xe540
-
-#define S_WR_DATA_EXT_FIFO_CNT10 30
-#define M_WR_DATA_EXT_FIFO_CNT10 0x3U
-#define V_WR_DATA_EXT_FIFO_CNT10(x) ((x) << S_WR_DATA_EXT_FIFO_CNT10)
-#define G_WR_DATA_EXT_FIFO_CNT10(x) (((x) >> S_WR_DATA_EXT_FIFO_CNT10) & M_WR_DATA_EXT_FIFO_CNT10)
-
-#define S_WR_CMD_TAG_FIFO_CNT10 26
-#define M_WR_CMD_TAG_FIFO_CNT10 0xfU
-#define V_WR_CMD_TAG_FIFO_CNT10(x) ((x) << S_WR_CMD_TAG_FIFO_CNT10)
-#define G_WR_CMD_TAG_FIFO_CNT10(x) (((x) >> S_WR_CMD_TAG_FIFO_CNT10) & M_WR_CMD_TAG_FIFO_CNT10)
-
-#define S_WR_DATA_512B_FIFO_CNT10 18
-#define M_WR_DATA_512B_FIFO_CNT10 0xffU
-#define V_WR_DATA_512B_FIFO_CNT10(x) ((x) << S_WR_DATA_512B_FIFO_CNT10)
-#define G_WR_DATA_512B_FIFO_CNT10(x) (((x) >> S_WR_DATA_512B_FIFO_CNT10) & M_WR_DATA_512B_FIFO_CNT10)
-
-#define S_RD_DATA_ALIGN_FSM10 17
-#define V_RD_DATA_ALIGN_FSM10(x) ((x) << S_RD_DATA_ALIGN_FSM10)
-#define F_RD_DATA_ALIGN_FSM10 V_RD_DATA_ALIGN_FSM10(1U)
-
-#define S_RD_DATA_FETCH_FSM10 16
-#define V_RD_DATA_FETCH_FSM10(x) ((x) << S_RD_DATA_FETCH_FSM10)
-#define F_RD_DATA_FETCH_FSM10 V_RD_DATA_FETCH_FSM10(1U)
-
-#define S_COHERENCY_TX_FSM10 15
-#define V_COHERENCY_TX_FSM10(x) ((x) << S_COHERENCY_TX_FSM10)
-#define F_COHERENCY_TX_FSM10 V_COHERENCY_TX_FSM10(1U)
-
-#define S_COHERENCY_RX_FSM10 14
-#define V_COHERENCY_RX_FSM10(x) ((x) << S_COHERENCY_RX_FSM10)
-#define F_COHERENCY_RX_FSM10 V_COHERENCY_RX_FSM10(1U)
-
-#define S_ARB_REQ_FSM10 13
-#define V_ARB_REQ_FSM10(x) ((x) << S_ARB_REQ_FSM10)
-#define F_ARB_REQ_FSM10 V_ARB_REQ_FSM10(1U)
-
-#define S_CMD_SPLIT_FSM10 10
-#define M_CMD_SPLIT_FSM10 0x7U
-#define V_CMD_SPLIT_FSM10(x) ((x) << S_CMD_SPLIT_FSM10)
-#define G_CMD_SPLIT_FSM10(x) (((x) >> S_CMD_SPLIT_FSM10) & M_CMD_SPLIT_FSM10)
-
-#define A_MA_PM_RX_CLIENT_INTERFACE_INTERNAL_REG1 0xe560
-
-#define S_WR_DATA_EXT_FIFO_CNT11 30
-#define M_WR_DATA_EXT_FIFO_CNT11 0x3U
-#define V_WR_DATA_EXT_FIFO_CNT11(x) ((x) << S_WR_DATA_EXT_FIFO_CNT11)
-#define G_WR_DATA_EXT_FIFO_CNT11(x) (((x) >> S_WR_DATA_EXT_FIFO_CNT11) & M_WR_DATA_EXT_FIFO_CNT11)
-
-#define S_WR_CMD_TAG_FIFO_CNT11 26
-#define M_WR_CMD_TAG_FIFO_CNT11 0xfU
-#define V_WR_CMD_TAG_FIFO_CNT11(x) ((x) << S_WR_CMD_TAG_FIFO_CNT11)
-#define G_WR_CMD_TAG_FIFO_CNT11(x) (((x) >> S_WR_CMD_TAG_FIFO_CNT11) & M_WR_CMD_TAG_FIFO_CNT11)
-
-#define S_WR_DATA_512B_FIFO_CNT11 18
-#define M_WR_DATA_512B_FIFO_CNT11 0xffU
-#define V_WR_DATA_512B_FIFO_CNT11(x) ((x) << S_WR_DATA_512B_FIFO_CNT11)
-#define G_WR_DATA_512B_FIFO_CNT11(x) (((x) >> S_WR_DATA_512B_FIFO_CNT11) & M_WR_DATA_512B_FIFO_CNT11)
-
-#define S_RD_DATA_ALIGN_FSM11 17
-#define V_RD_DATA_ALIGN_FSM11(x) ((x) << S_RD_DATA_ALIGN_FSM11)
-#define F_RD_DATA_ALIGN_FSM11 V_RD_DATA_ALIGN_FSM11(1U)
-
-#define S_RD_DATA_FETCH_FSM11 16
-#define V_RD_DATA_FETCH_FSM11(x) ((x) << S_RD_DATA_FETCH_FSM11)
-#define F_RD_DATA_FETCH_FSM11 V_RD_DATA_FETCH_FSM11(1U)
-
-#define S_COHERENCY_TX_FSM11 15
-#define V_COHERENCY_TX_FSM11(x) ((x) << S_COHERENCY_TX_FSM11)
-#define F_COHERENCY_TX_FSM11 V_COHERENCY_TX_FSM11(1U)
-
-#define S_COHERENCY_RX_FSM11 14
-#define V_COHERENCY_RX_FSM11(x) ((x) << S_COHERENCY_RX_FSM11)
-#define F_COHERENCY_RX_FSM11 V_COHERENCY_RX_FSM11(1U)
-
-#define S_ARB_REQ_FSM11 13
-#define V_ARB_REQ_FSM11(x) ((x) << S_ARB_REQ_FSM11)
-#define F_ARB_REQ_FSM11 V_ARB_REQ_FSM11(1U)
-
-#define S_CMD_SPLIT_FSM11 10
-#define M_CMD_SPLIT_FSM11 0x7U
-#define V_CMD_SPLIT_FSM11(x) ((x) << S_CMD_SPLIT_FSM11)
-#define G_CMD_SPLIT_FSM11(x) (((x) >> S_CMD_SPLIT_FSM11) & M_CMD_SPLIT_FSM11)
-
-#define A_MA_HMA_CLIENT_INTERFACE_INTERNAL_REG1 0xe580
-
-#define S_WR_DATA_EXT_FIFO_CNT12 30
-#define M_WR_DATA_EXT_FIFO_CNT12 0x3U
-#define V_WR_DATA_EXT_FIFO_CNT12(x) ((x) << S_WR_DATA_EXT_FIFO_CNT12)
-#define G_WR_DATA_EXT_FIFO_CNT12(x) (((x) >> S_WR_DATA_EXT_FIFO_CNT12) & M_WR_DATA_EXT_FIFO_CNT12)
-
-#define S_WR_CMD_TAG_FIFO_CNT12 26
-#define M_WR_CMD_TAG_FIFO_CNT12 0xfU
-#define V_WR_CMD_TAG_FIFO_CNT12(x) ((x) << S_WR_CMD_TAG_FIFO_CNT12)
-#define G_WR_CMD_TAG_FIFO_CNT12(x) (((x) >> S_WR_CMD_TAG_FIFO_CNT12) & M_WR_CMD_TAG_FIFO_CNT12)
-
-#define S_WR_DATA_512B_FIFO_CNT12 18
-#define M_WR_DATA_512B_FIFO_CNT12 0xffU
-#define V_WR_DATA_512B_FIFO_CNT12(x) ((x) << S_WR_DATA_512B_FIFO_CNT12)
-#define G_WR_DATA_512B_FIFO_CNT12(x) (((x) >> S_WR_DATA_512B_FIFO_CNT12) & M_WR_DATA_512B_FIFO_CNT12)
-
-#define S_RD_DATA_ALIGN_FSM12 17
-#define V_RD_DATA_ALIGN_FSM12(x) ((x) << S_RD_DATA_ALIGN_FSM12)
-#define F_RD_DATA_ALIGN_FSM12 V_RD_DATA_ALIGN_FSM12(1U)
-
-#define S_RD_DATA_FETCH_FSM12 16
-#define V_RD_DATA_FETCH_FSM12(x) ((x) << S_RD_DATA_FETCH_FSM12)
-#define F_RD_DATA_FETCH_FSM12 V_RD_DATA_FETCH_FSM12(1U)
-
-#define S_COHERENCY_TX_FSM12 15
-#define V_COHERENCY_TX_FSM12(x) ((x) << S_COHERENCY_TX_FSM12)
-#define F_COHERENCY_TX_FSM12 V_COHERENCY_TX_FSM12(1U)
-
-#define S_COHERENCY_RX_FSM12 14
-#define V_COHERENCY_RX_FSM12(x) ((x) << S_COHERENCY_RX_FSM12)
-#define F_COHERENCY_RX_FSM12 V_COHERENCY_RX_FSM12(1U)
-
-#define S_ARB_REQ_FSM12 13
-#define V_ARB_REQ_FSM12(x) ((x) << S_ARB_REQ_FSM12)
-#define F_ARB_REQ_FSM12 V_ARB_REQ_FSM12(1U)
-
-#define S_CMD_SPLIT_FSM12 10
-#define M_CMD_SPLIT_FSM12 0x7U
-#define V_CMD_SPLIT_FSM12(x) ((x) << S_CMD_SPLIT_FSM12)
-#define G_CMD_SPLIT_FSM12(x) (((x) >> S_CMD_SPLIT_FSM12) & M_CMD_SPLIT_FSM12)
-
-#define A_MA_TARGET_0_ARBITER_INTERFACE_INTERNAL_REG1 0xe5a0
-
-#define S_RD_CMD_TAG_FIFO_CNT0 8
-#define M_RD_CMD_TAG_FIFO_CNT0 0xffU
-#define V_RD_CMD_TAG_FIFO_CNT0(x) ((x) << S_RD_CMD_TAG_FIFO_CNT0)
-#define G_RD_CMD_TAG_FIFO_CNT0(x) (((x) >> S_RD_CMD_TAG_FIFO_CNT0) & M_RD_CMD_TAG_FIFO_CNT0)
-
-#define S_RD_DATA_FIFO_CNT0 0
-#define M_RD_DATA_FIFO_CNT0 0xffU
-#define V_RD_DATA_FIFO_CNT0(x) ((x) << S_RD_DATA_FIFO_CNT0)
-#define G_RD_DATA_FIFO_CNT0(x) (((x) >> S_RD_DATA_FIFO_CNT0) & M_RD_DATA_FIFO_CNT0)
-
-#define A_MA_TARGET_1_ARBITER_INTERFACE_INTERNAL_REG1 0xe5c0
-
-#define S_RD_CMD_TAG_FIFO_CNT1 8
-#define M_RD_CMD_TAG_FIFO_CNT1 0xffU
-#define V_RD_CMD_TAG_FIFO_CNT1(x) ((x) << S_RD_CMD_TAG_FIFO_CNT1)
-#define G_RD_CMD_TAG_FIFO_CNT1(x) (((x) >> S_RD_CMD_TAG_FIFO_CNT1) & M_RD_CMD_TAG_FIFO_CNT1)
-
-#define S_RD_DATA_FIFO_CNT1 0
-#define M_RD_DATA_FIFO_CNT1 0xffU
-#define V_RD_DATA_FIFO_CNT1(x) ((x) << S_RD_DATA_FIFO_CNT1)
-#define G_RD_DATA_FIFO_CNT1(x) (((x) >> S_RD_DATA_FIFO_CNT1) & M_RD_DATA_FIFO_CNT1)
-
-#define A_MA_TARGET_2_ARBITER_INTERFACE_INTERNAL_REG1 0xe5e0
-
-#define S_RD_CMD_TAG_FIFO_CNT2 8
-#define M_RD_CMD_TAG_FIFO_CNT2 0xffU
-#define V_RD_CMD_TAG_FIFO_CNT2(x) ((x) << S_RD_CMD_TAG_FIFO_CNT2)
-#define G_RD_CMD_TAG_FIFO_CNT2(x) (((x) >> S_RD_CMD_TAG_FIFO_CNT2) & M_RD_CMD_TAG_FIFO_CNT2)
-
-#define S_RD_DATA_FIFO_CNT2 0
-#define M_RD_DATA_FIFO_CNT2 0xffU
-#define V_RD_DATA_FIFO_CNT2(x) ((x) << S_RD_DATA_FIFO_CNT2)
-#define G_RD_DATA_FIFO_CNT2(x) (((x) >> S_RD_DATA_FIFO_CNT2) & M_RD_DATA_FIFO_CNT2)
-
-#define A_MA_TARGET_3_ARBITER_INTERFACE_INTERNAL_REG1 0xe600
-
-#define S_RD_CMD_TAG_FIFO_CNT3 8
-#define M_RD_CMD_TAG_FIFO_CNT3 0xffU
-#define V_RD_CMD_TAG_FIFO_CNT3(x) ((x) << S_RD_CMD_TAG_FIFO_CNT3)
-#define G_RD_CMD_TAG_FIFO_CNT3(x) (((x) >> S_RD_CMD_TAG_FIFO_CNT3) & M_RD_CMD_TAG_FIFO_CNT3)
-
-#define S_RD_DATA_FIFO_CNT3 0
-#define M_RD_DATA_FIFO_CNT3 0xffU
-#define V_RD_DATA_FIFO_CNT3(x) ((x) << S_RD_DATA_FIFO_CNT3)
-#define G_RD_DATA_FIFO_CNT3(x) (((x) >> S_RD_DATA_FIFO_CNT3) & M_RD_DATA_FIFO_CNT3)
-
-#define A_MA_SGE_THREAD_0_CLNT_EXP_WR_CYC_CNT_LO 0xe640
-#define A_MA_SGE_THREAD_1_CLNT_EXP_WR_CYC_CNT_LO 0xe660
-#define A_MA_ULP_TX_CLNT_EXP_WR_CYC_CNT_LO 0xe680
-#define A_MA_ULP_RX_CLNT_EXP_WR_CYC_CNT_LO 0xe6a0
-#define A_MA_ULP_TX_RX_CLNT_EXP_WR_CYC_CNT_LO 0xe6c0
-#define A_MA_TP_THREAD_0_CLNT_EXP_WR_CYC_CNT_LO 0xe6e0
-#define A_MA_TP_THREAD_1_CLNT_EXP_WR_CYC_CNT_LO 0xe700
-#define A_MA_LE_CLNT_EXP_WR_CYC_CNT_LO 0xe720
-#define A_MA_CIM_CLNT_EXP_WR_CYC_CNT_LO 0xe740
-#define A_MA_PCIE_CLNT_EXP_WR_CYC_CNT_LO 0xe760
-#define A_MA_PM_TX_CLNT_EXP_WR_CYC_CNT_LO 0xe780
-#define A_MA_PM_RX_CLNT_EXP_WR_CYC_CNT_LO 0xe7a0
-#define A_MA_HMA_CLNT_EXP_WR_CYC_CNT_LO 0xe7c0
-#define A_MA_EDRAM0_WR_REQ_CNT_HI 0xe800
-#define A_MA_EDRAM0_WR_REQ_CNT_LO 0xe820
-#define A_MA_EDRAM1_WR_REQ_CNT_HI 0xe840
-#define A_MA_EDRAM1_WR_REQ_CNT_LO 0xe860
-#define A_MA_EXT_MEMORY0_WR_REQ_CNT_HI 0xe880
-#define A_MA_EXT_MEMORY0_WR_REQ_CNT_LO 0xe8a0
-#define A_MA_EXT_MEMORY1_WR_REQ_CNT_HI 0xe8c0
-#define A_MA_EXT_MEMORY1_WR_REQ_CNT_LO 0xe8e0
-#define A_MA_EDRAM0_RD_REQ_CNT_HI 0xe900
-#define A_MA_EDRAM0_RD_REQ_CNT_LO 0xe920
-#define A_MA_EDRAM1_RD_REQ_CNT_HI 0xe940
-#define A_MA_EDRAM1_RD_REQ_CNT_LO 0xe960
-#define A_MA_EXT_MEMORY0_RD_REQ_CNT_HI 0xe980
-#define A_MA_EXT_MEMORY0_RD_REQ_CNT_LO 0xe9a0
-#define A_MA_EXT_MEMORY1_RD_REQ_CNT_HI 0xe9c0
-#define A_MA_EXT_MEMORY1_RD_REQ_CNT_LO 0xe9e0
-#define A_MA_SGE_THREAD_0_CLNT_ACT_RD_CYC_CNT_HI 0xec00
-#define A_MA_SGE_THREAD_0_CLNT_ACT_RD_CYC_CNT_LO 0xec20
-#define A_MA_SGE_THREAD_1_CLNT_ACT_RD_CYC_CNT_HI 0xec40
-#define A_MA_SGE_THREAD_1_CLNT_ACT_RD_CYC_CNT_LO 0xec60
-#define A_MA_ULP_TX_CLNT_ACT_RD_CYC_CNT_HI 0xec80
-#define A_MA_ULP_TX_CLNT_ACT_RD_CYC_CNT_LO 0xeca0
-#define A_MA_ULP_RX_CLNT_ACT_RD_CYC_CNT_HI 0xecc0
-#define A_MA_ULP_RX_CLNT_ACT_RD_CYC_CNT_LO 0xece0
-#define A_MA_ULP_TX_RX_CLNT_ACT_RD_CYC_CNT_HI 0xed00
-#define A_MA_ULP_TX_RX_CLNT_ACT_RD_CYC_CNT_LO 0xed20
-#define A_MA_TP_THREAD_0_CLNT_ACT_RD_CYC_CNT_HI 0xed40
-#define A_MA_TP_THREAD_0_CLNT_ACT_RD_CYC_CNT_LO 0xed60
-#define A_MA_TP_THREAD_1_CLNT_ACT_RD_CYC_CNT_HI 0xed80
-#define A_MA_TP_THREAD_1_CLNT_ACT_RD_CYC_CNT_LO 0xeda0
-#define A_MA_LE_CLNT_ACT_RD_CYC_CNT_HI 0xedc0
-#define A_MA_LE_CLNT_ACT_RD_CYC_CNT_LO 0xede0
-#define A_MA_CIM_CLNT_ACT_RD_CYC_CNT_HI 0xee00
-#define A_MA_CIM_CLNT_ACT_RD_CYC_CNT_LO 0xee20
-#define A_MA_PCIE_CLNT_ACT_RD_CYC_CNT_HI 0xee40
-#define A_MA_PCIE_CLNT_ACT_RD_CYC_CNT_LO 0xee60
-#define A_MA_PM_TX_CLNT_ACT_RD_CYC_CNT_HI 0xee80
-#define A_MA_PM_TX_CLNT_ACT_RD_CYC_CNT_LO 0xeea0
-#define A_MA_PM_RX_CLNT_ACT_RD_CYC_CNT_HI 0xeec0
-#define A_MA_PM_RX_CLNT_ACT_RD_CYC_CNT_LO 0xeee0
-#define A_MA_HMA_CLNT_ACT_RD_CYC_CNT_HI 0xef00
-#define A_MA_HMA_CLNT_ACT_RD_CYC_CNT_LO 0xef20
-#define A_MA_PM_TX_RD_THROTTLE_STATUS 0xf000
-
-#define S_PTMAXTRANS 16
-#define V_PTMAXTRANS(x) ((x) << S_PTMAXTRANS)
-#define F_PTMAXTRANS V_PTMAXTRANS(1U)
-
-#define S_PTFLITCNT 0
-#define M_PTFLITCNT 0xffU
-#define V_PTFLITCNT(x) ((x) << S_PTFLITCNT)
-#define G_PTFLITCNT(x) (((x) >> S_PTFLITCNT) & M_PTFLITCNT)
-
-#define A_MA_PM_RX_RD_THROTTLE_STATUS 0xf020
-
-#define S_PRMAXTRANS 16
-#define V_PRMAXTRANS(x) ((x) << S_PRMAXTRANS)
-#define F_PRMAXTRANS V_PRMAXTRANS(1U)
-
-#define S_PRFLITCNT 0
-#define M_PRFLITCNT 0xffU
-#define V_PRFLITCNT(x) ((x) << S_PRFLITCNT)
-#define G_PRFLITCNT(x) (((x) >> S_PRFLITCNT) & M_PRFLITCNT)
-
-/* registers for module EDC_0 */
-#define EDC_0_BASE_ADDR 0x7900
-
-#define A_EDC_REF 0x7900
-
-#define S_EDC_INST_NUM 18
-#define V_EDC_INST_NUM(x) ((x) << S_EDC_INST_NUM)
-#define F_EDC_INST_NUM V_EDC_INST_NUM(1U)
-
-#define S_ENABLE_PERF 17
-#define V_ENABLE_PERF(x) ((x) << S_ENABLE_PERF)
-#define F_ENABLE_PERF V_ENABLE_PERF(1U)
-
-#define S_ECC_BYPASS 16
-#define V_ECC_BYPASS(x) ((x) << S_ECC_BYPASS)
-#define F_ECC_BYPASS V_ECC_BYPASS(1U)
-
-#define S_REFFREQ 0
-#define M_REFFREQ 0xffffU
-#define V_REFFREQ(x) ((x) << S_REFFREQ)
-#define G_REFFREQ(x) (((x) >> S_REFFREQ) & M_REFFREQ)
-
-#define A_EDC_BIST_CMD 0x7904
-#define A_EDC_BIST_CMD_ADDR 0x7908
-#define A_EDC_BIST_CMD_LEN 0x790c
-#define A_EDC_BIST_DATA_PATTERN 0x7910
-#define A_EDC_BIST_USER_WDATA0 0x7914
-#define A_EDC_BIST_USER_WDATA1 0x7918
-#define A_EDC_BIST_USER_WDATA2 0x791c
-#define A_EDC_BIST_NUM_ERR 0x7920
-#define A_EDC_BIST_ERR_FIRST_ADDR 0x7924
-#define A_EDC_BIST_STATUS_RDATA 0x7928
-#define A_EDC_PAR_ENABLE 0x7970
-
-#define S_ECC_UE 2
-#define V_ECC_UE(x) ((x) << S_ECC_UE)
-#define F_ECC_UE V_ECC_UE(1U)
-
-#define S_ECC_CE 1
-#define V_ECC_CE(x) ((x) << S_ECC_CE)
-#define F_ECC_CE V_ECC_CE(1U)
-
-#define A_EDC_INT_ENABLE 0x7974
-#define A_EDC_INT_CAUSE 0x7978
-
-#define S_ECC_UE_PAR 5
-#define V_ECC_UE_PAR(x) ((x) << S_ECC_UE_PAR)
-#define F_ECC_UE_PAR V_ECC_UE_PAR(1U)
-
-#define S_ECC_CE_PAR 4
-#define V_ECC_CE_PAR(x) ((x) << S_ECC_CE_PAR)
-#define F_ECC_CE_PAR V_ECC_CE_PAR(1U)
-
-#define S_PERR_PAR_CAUSE 3
-#define V_PERR_PAR_CAUSE(x) ((x) << S_PERR_PAR_CAUSE)
-#define F_PERR_PAR_CAUSE V_PERR_PAR_CAUSE(1U)
-
-#define A_EDC_ECC_STATUS 0x797c
-
-/* registers for module EDC_1 */
-#define EDC_1_BASE_ADDR 0x7980
-
-/* registers for module HMA */
-#define HMA_BASE_ADDR 0x7a00
-
-/* registers for module CIM */
-#define CIM_BASE_ADDR 0x7b00
-
-#define A_CIM_VF_EXT_MAILBOX_CTRL 0x0
-
-#define S_VFMBGENERIC 4
-#define M_VFMBGENERIC 0xfU
-#define V_VFMBGENERIC(x) ((x) << S_VFMBGENERIC)
-#define G_VFMBGENERIC(x) (((x) >> S_VFMBGENERIC) & M_VFMBGENERIC)
-
-#define A_CIM_VF_EXT_MAILBOX_STATUS 0x4
-
-#define S_MBVFREADY 0
-#define V_MBVFREADY(x) ((x) << S_MBVFREADY)
-#define F_MBVFREADY V_MBVFREADY(1U)
-
-#define A_CIM_PF_MAILBOX_DATA 0x240
-#define A_CIM_PF_MAILBOX_CTRL 0x280
-
-#define S_MBGENERIC 4
-#define M_MBGENERIC 0xfffffffU
-#define V_MBGENERIC(x) ((x) << S_MBGENERIC)
-#define G_MBGENERIC(x) (((x) >> S_MBGENERIC) & M_MBGENERIC)
-
-#define S_MBMSGVALID 3
-#define V_MBMSGVALID(x) ((x) << S_MBMSGVALID)
-#define F_MBMSGVALID V_MBMSGVALID(1U)
-
-#define S_MBINTREQ 2
-#define V_MBINTREQ(x) ((x) << S_MBINTREQ)
-#define F_MBINTREQ V_MBINTREQ(1U)
-
-#define S_MBOWNER 0
-#define M_MBOWNER 0x3U
-#define V_MBOWNER(x) ((x) << S_MBOWNER)
-#define G_MBOWNER(x) (((x) >> S_MBOWNER) & M_MBOWNER)
-
-#define A_CIM_PF_MAILBOX_ACC_STATUS 0x284
-
-#define S_MBWRBUSY 31
-#define V_MBWRBUSY(x) ((x) << S_MBWRBUSY)
-#define F_MBWRBUSY V_MBWRBUSY(1U)
-
-#define A_CIM_PF_HOST_INT_ENABLE 0x288
-
-#define S_MBMSGRDYINTEN 19
-#define V_MBMSGRDYINTEN(x) ((x) << S_MBMSGRDYINTEN)
-#define F_MBMSGRDYINTEN V_MBMSGRDYINTEN(1U)
-
-#define A_CIM_PF_HOST_INT_CAUSE 0x28c
-
-#define S_MBMSGRDYINT 19
-#define V_MBMSGRDYINT(x) ((x) << S_MBMSGRDYINT)
-#define F_MBMSGRDYINT V_MBMSGRDYINT(1U)
-
-#define A_CIM_PF_MAILBOX_CTRL_SHADOW_COPY 0x290
-#define A_CIM_BOOT_CFG 0x7b00
-
-#define S_BOOTADDR 8
-#define M_BOOTADDR 0xffffffU
-#define V_BOOTADDR(x) ((x) << S_BOOTADDR)
-#define G_BOOTADDR(x) (((x) >> S_BOOTADDR) & M_BOOTADDR)
-
-#define S_UPGEN 2
-#define M_UPGEN 0x3fU
-#define V_UPGEN(x) ((x) << S_UPGEN)
-#define G_UPGEN(x) (((x) >> S_UPGEN) & M_UPGEN)
-
-#define S_BOOTSDRAM 1
-#define V_BOOTSDRAM(x) ((x) << S_BOOTSDRAM)
-#define F_BOOTSDRAM V_BOOTSDRAM(1U)
-
-#define S_UPCRST 0
-#define V_UPCRST(x) ((x) << S_UPCRST)
-#define F_UPCRST V_UPCRST(1U)
-
-#define A_CIM_FLASH_BASE_ADDR 0x7b04
-
-#define S_FLASHBASEADDR 6
-#define M_FLASHBASEADDR 0x3ffffU
-#define V_FLASHBASEADDR(x) ((x) << S_FLASHBASEADDR)
-#define G_FLASHBASEADDR(x) (((x) >> S_FLASHBASEADDR) & M_FLASHBASEADDR)
-
-#define A_CIM_FLASH_ADDR_SIZE 0x7b08
-
-#define S_FLASHADDRSIZE 4
-#define M_FLASHADDRSIZE 0xfffffU
-#define V_FLASHADDRSIZE(x) ((x) << S_FLASHADDRSIZE)
-#define G_FLASHADDRSIZE(x) (((x) >> S_FLASHADDRSIZE) & M_FLASHADDRSIZE)
-
-#define A_CIM_EEPROM_BASE_ADDR 0x7b0c
-
-#define S_EEPROMBASEADDR 6
-#define M_EEPROMBASEADDR 0x3ffffU
-#define V_EEPROMBASEADDR(x) ((x) << S_EEPROMBASEADDR)
-#define G_EEPROMBASEADDR(x) (((x) >> S_EEPROMBASEADDR) & M_EEPROMBASEADDR)
-
-#define A_CIM_EEPROM_ADDR_SIZE 0x7b10
-
-#define S_EEPROMADDRSIZE 4
-#define M_EEPROMADDRSIZE 0xfffffU
-#define V_EEPROMADDRSIZE(x) ((x) << S_EEPROMADDRSIZE)
-#define G_EEPROMADDRSIZE(x) (((x) >> S_EEPROMADDRSIZE) & M_EEPROMADDRSIZE)
-
-#define A_CIM_SDRAM_BASE_ADDR 0x7b14
-
-#define S_SDRAMBASEADDR 6
-#define M_SDRAMBASEADDR 0x3ffffffU
-#define V_SDRAMBASEADDR(x) ((x) << S_SDRAMBASEADDR)
-#define G_SDRAMBASEADDR(x) (((x) >> S_SDRAMBASEADDR) & M_SDRAMBASEADDR)
-
-#define A_CIM_SDRAM_ADDR_SIZE 0x7b18
-
-#define S_SDRAMADDRSIZE 4
-#define M_SDRAMADDRSIZE 0xfffffffU
-#define V_SDRAMADDRSIZE(x) ((x) << S_SDRAMADDRSIZE)
-#define G_SDRAMADDRSIZE(x) (((x) >> S_SDRAMADDRSIZE) & M_SDRAMADDRSIZE)
-
-#define A_CIM_EXTMEM2_BASE_ADDR 0x7b1c
-
-#define S_EXTMEM2BASEADDR 6
-#define M_EXTMEM2BASEADDR 0x3ffffffU
-#define V_EXTMEM2BASEADDR(x) ((x) << S_EXTMEM2BASEADDR)
-#define G_EXTMEM2BASEADDR(x) (((x) >> S_EXTMEM2BASEADDR) & M_EXTMEM2BASEADDR)
-
-#define A_CIM_EXTMEM2_ADDR_SIZE 0x7b20
-
-#define S_EXTMEM2ADDRSIZE 4
-#define M_EXTMEM2ADDRSIZE 0xfffffffU
-#define V_EXTMEM2ADDRSIZE(x) ((x) << S_EXTMEM2ADDRSIZE)
-#define G_EXTMEM2ADDRSIZE(x) (((x) >> S_EXTMEM2ADDRSIZE) & M_EXTMEM2ADDRSIZE)
-
-#define A_CIM_UP_SPARE_INT 0x7b24
-
-#define S_TDEBUGINT 4
-#define V_TDEBUGINT(x) ((x) << S_TDEBUGINT)
-#define F_TDEBUGINT V_TDEBUGINT(1U)
-
-#define S_BOOTVECSEL 3
-#define V_BOOTVECSEL(x) ((x) << S_BOOTVECSEL)
-#define F_BOOTVECSEL V_BOOTVECSEL(1U)
-
-#define S_UPSPAREINT 0
-#define M_UPSPAREINT 0x7U
-#define V_UPSPAREINT(x) ((x) << S_UPSPAREINT)
-#define G_UPSPAREINT(x) (((x) >> S_UPSPAREINT) & M_UPSPAREINT)
-
-#define A_CIM_HOST_INT_ENABLE 0x7b28
-
-#define S_TIEQOUTPARERRINTEN 20
-#define V_TIEQOUTPARERRINTEN(x) ((x) << S_TIEQOUTPARERRINTEN)
-#define F_TIEQOUTPARERRINTEN V_TIEQOUTPARERRINTEN(1U)
-
-#define S_TIEQINPARERRINTEN 19
-#define V_TIEQINPARERRINTEN(x) ((x) << S_TIEQINPARERRINTEN)
-#define F_TIEQINPARERRINTEN V_TIEQINPARERRINTEN(1U)
-
-#define S_MBHOSTPARERR 18
-#define V_MBHOSTPARERR(x) ((x) << S_MBHOSTPARERR)
-#define F_MBHOSTPARERR V_MBHOSTPARERR(1U)
-
-#define S_MBUPPARERR 17
-#define V_MBUPPARERR(x) ((x) << S_MBUPPARERR)
-#define F_MBUPPARERR V_MBUPPARERR(1U)
-
-#define S_IBQTP0PARERR 16
-#define V_IBQTP0PARERR(x) ((x) << S_IBQTP0PARERR)
-#define F_IBQTP0PARERR V_IBQTP0PARERR(1U)
-
-#define S_IBQTP1PARERR 15
-#define V_IBQTP1PARERR(x) ((x) << S_IBQTP1PARERR)
-#define F_IBQTP1PARERR V_IBQTP1PARERR(1U)
-
-#define S_IBQULPPARERR 14
-#define V_IBQULPPARERR(x) ((x) << S_IBQULPPARERR)
-#define F_IBQULPPARERR V_IBQULPPARERR(1U)
-
-#define S_IBQSGELOPARERR 13
-#define V_IBQSGELOPARERR(x) ((x) << S_IBQSGELOPARERR)
-#define F_IBQSGELOPARERR V_IBQSGELOPARERR(1U)
-
-#define S_IBQSGEHIPARERR 12
-#define V_IBQSGEHIPARERR(x) ((x) << S_IBQSGEHIPARERR)
-#define F_IBQSGEHIPARERR V_IBQSGEHIPARERR(1U)
-
-#define S_IBQNCSIPARERR 11
-#define V_IBQNCSIPARERR(x) ((x) << S_IBQNCSIPARERR)
-#define F_IBQNCSIPARERR V_IBQNCSIPARERR(1U)
-
-#define S_OBQULP0PARERR 10
-#define V_OBQULP0PARERR(x) ((x) << S_OBQULP0PARERR)
-#define F_OBQULP0PARERR V_OBQULP0PARERR(1U)
-
-#define S_OBQULP1PARERR 9
-#define V_OBQULP1PARERR(x) ((x) << S_OBQULP1PARERR)
-#define F_OBQULP1PARERR V_OBQULP1PARERR(1U)
-
-#define S_OBQULP2PARERR 8
-#define V_OBQULP2PARERR(x) ((x) << S_OBQULP2PARERR)
-#define F_OBQULP2PARERR V_OBQULP2PARERR(1U)
-
-#define S_OBQULP3PARERR 7
-#define V_OBQULP3PARERR(x) ((x) << S_OBQULP3PARERR)
-#define F_OBQULP3PARERR V_OBQULP3PARERR(1U)
-
-#define S_OBQSGEPARERR 6
-#define V_OBQSGEPARERR(x) ((x) << S_OBQSGEPARERR)
-#define F_OBQSGEPARERR V_OBQSGEPARERR(1U)
-
-#define S_OBQNCSIPARERR 5
-#define V_OBQNCSIPARERR(x) ((x) << S_OBQNCSIPARERR)
-#define F_OBQNCSIPARERR V_OBQNCSIPARERR(1U)
-
-#define S_TIMER1INTEN 3
-#define V_TIMER1INTEN(x) ((x) << S_TIMER1INTEN)
-#define F_TIMER1INTEN V_TIMER1INTEN(1U)
-
-#define S_TIMER0INTEN 2
-#define V_TIMER0INTEN(x) ((x) << S_TIMER0INTEN)
-#define F_TIMER0INTEN V_TIMER0INTEN(1U)
-
-#define S_PREFDROPINTEN 1
-#define V_PREFDROPINTEN(x) ((x) << S_PREFDROPINTEN)
-#define F_PREFDROPINTEN V_PREFDROPINTEN(1U)
-
-#define S_MA_CIM_INTFPERR 28
-#define V_MA_CIM_INTFPERR(x) ((x) << S_MA_CIM_INTFPERR)
-#define F_MA_CIM_INTFPERR V_MA_CIM_INTFPERR(1U)
-
-#define S_PLCIM_MSTRSPDATAPARERR 27
-#define V_PLCIM_MSTRSPDATAPARERR(x) ((x) << S_PLCIM_MSTRSPDATAPARERR)
-#define F_PLCIM_MSTRSPDATAPARERR V_PLCIM_MSTRSPDATAPARERR(1U)
-
-#define S_NCSI2CIMINTFPARERR 26
-#define V_NCSI2CIMINTFPARERR(x) ((x) << S_NCSI2CIMINTFPARERR)
-#define F_NCSI2CIMINTFPARERR V_NCSI2CIMINTFPARERR(1U)
-
-#define S_SGE2CIMINTFPARERR 25
-#define V_SGE2CIMINTFPARERR(x) ((x) << S_SGE2CIMINTFPARERR)
-#define F_SGE2CIMINTFPARERR V_SGE2CIMINTFPARERR(1U)
-
-#define S_ULP2CIMINTFPARERR 24
-#define V_ULP2CIMINTFPARERR(x) ((x) << S_ULP2CIMINTFPARERR)
-#define F_ULP2CIMINTFPARERR V_ULP2CIMINTFPARERR(1U)
-
-#define S_TP2CIMINTFPARERR 23
-#define V_TP2CIMINTFPARERR(x) ((x) << S_TP2CIMINTFPARERR)
-#define F_TP2CIMINTFPARERR V_TP2CIMINTFPARERR(1U)
-
-#define S_OBQSGERX1PARERR 22
-#define V_OBQSGERX1PARERR(x) ((x) << S_OBQSGERX1PARERR)
-#define F_OBQSGERX1PARERR V_OBQSGERX1PARERR(1U)
-
-#define S_OBQSGERX0PARERR 21
-#define V_OBQSGERX0PARERR(x) ((x) << S_OBQSGERX0PARERR)
-#define F_OBQSGERX0PARERR V_OBQSGERX0PARERR(1U)
-
-#define S_PCIE2CIMINTFPARERR 29
-#define V_PCIE2CIMINTFPARERR(x) ((x) << S_PCIE2CIMINTFPARERR)
-#define F_PCIE2CIMINTFPARERR V_PCIE2CIMINTFPARERR(1U)
-
-#define S_IBQPCIEPARERR 12
-#define V_IBQPCIEPARERR(x) ((x) << S_IBQPCIEPARERR)
-#define F_IBQPCIEPARERR V_IBQPCIEPARERR(1U)
-
-#define A_CIM_HOST_INT_CAUSE 0x7b2c
-
-#define S_TIEQOUTPARERRINT 20
-#define V_TIEQOUTPARERRINT(x) ((x) << S_TIEQOUTPARERRINT)
-#define F_TIEQOUTPARERRINT V_TIEQOUTPARERRINT(1U)
-
-#define S_TIEQINPARERRINT 19
-#define V_TIEQINPARERRINT(x) ((x) << S_TIEQINPARERRINT)
-#define F_TIEQINPARERRINT V_TIEQINPARERRINT(1U)
-
-#define S_TIMER1INT 3
-#define V_TIMER1INT(x) ((x) << S_TIMER1INT)
-#define F_TIMER1INT V_TIMER1INT(1U)
-
-#define S_TIMER0INT 2
-#define V_TIMER0INT(x) ((x) << S_TIMER0INT)
-#define F_TIMER0INT V_TIMER0INT(1U)
-
-#define S_PREFDROPINT 1
-#define V_PREFDROPINT(x) ((x) << S_PREFDROPINT)
-#define F_PREFDROPINT V_PREFDROPINT(1U)
-
-#define S_UPACCNONZERO 0
-#define V_UPACCNONZERO(x) ((x) << S_UPACCNONZERO)
-#define F_UPACCNONZERO V_UPACCNONZERO(1U)
-
-#define A_CIM_HOST_UPACC_INT_ENABLE 0x7b30
-
-#define S_EEPROMWRINTEN 30
-#define V_EEPROMWRINTEN(x) ((x) << S_EEPROMWRINTEN)
-#define F_EEPROMWRINTEN V_EEPROMWRINTEN(1U)
-
-#define S_TIMEOUTMAINTEN 29
-#define V_TIMEOUTMAINTEN(x) ((x) << S_TIMEOUTMAINTEN)
-#define F_TIMEOUTMAINTEN V_TIMEOUTMAINTEN(1U)
-
-#define S_TIMEOUTINTEN 28
-#define V_TIMEOUTINTEN(x) ((x) << S_TIMEOUTINTEN)
-#define F_TIMEOUTINTEN V_TIMEOUTINTEN(1U)
-
-#define S_RSPOVRLOOKUPINTEN 27
-#define V_RSPOVRLOOKUPINTEN(x) ((x) << S_RSPOVRLOOKUPINTEN)
-#define F_RSPOVRLOOKUPINTEN V_RSPOVRLOOKUPINTEN(1U)
-
-#define S_REQOVRLOOKUPINTEN 26
-#define V_REQOVRLOOKUPINTEN(x) ((x) << S_REQOVRLOOKUPINTEN)
-#define F_REQOVRLOOKUPINTEN V_REQOVRLOOKUPINTEN(1U)
-
-#define S_BLKWRPLINTEN 25
-#define V_BLKWRPLINTEN(x) ((x) << S_BLKWRPLINTEN)
-#define F_BLKWRPLINTEN V_BLKWRPLINTEN(1U)
-
-#define S_BLKRDPLINTEN 24
-#define V_BLKRDPLINTEN(x) ((x) << S_BLKRDPLINTEN)
-#define F_BLKRDPLINTEN V_BLKRDPLINTEN(1U)
-
-#define S_SGLWRPLINTEN 23
-#define V_SGLWRPLINTEN(x) ((x) << S_SGLWRPLINTEN)
-#define F_SGLWRPLINTEN V_SGLWRPLINTEN(1U)
-
-#define S_SGLRDPLINTEN 22
-#define V_SGLRDPLINTEN(x) ((x) << S_SGLRDPLINTEN)
-#define F_SGLRDPLINTEN V_SGLRDPLINTEN(1U)
-
-#define S_BLKWRCTLINTEN 21
-#define V_BLKWRCTLINTEN(x) ((x) << S_BLKWRCTLINTEN)
-#define F_BLKWRCTLINTEN V_BLKWRCTLINTEN(1U)
-
-#define S_BLKRDCTLINTEN 20
-#define V_BLKRDCTLINTEN(x) ((x) << S_BLKRDCTLINTEN)
-#define F_BLKRDCTLINTEN V_BLKRDCTLINTEN(1U)
-
-#define S_SGLWRCTLINTEN 19
-#define V_SGLWRCTLINTEN(x) ((x) << S_SGLWRCTLINTEN)
-#define F_SGLWRCTLINTEN V_SGLWRCTLINTEN(1U)
-
-#define S_SGLRDCTLINTEN 18
-#define V_SGLRDCTLINTEN(x) ((x) << S_SGLRDCTLINTEN)
-#define F_SGLRDCTLINTEN V_SGLRDCTLINTEN(1U)
-
-#define S_BLKWREEPROMINTEN 17
-#define V_BLKWREEPROMINTEN(x) ((x) << S_BLKWREEPROMINTEN)
-#define F_BLKWREEPROMINTEN V_BLKWREEPROMINTEN(1U)
-
-#define S_BLKRDEEPROMINTEN 16
-#define V_BLKRDEEPROMINTEN(x) ((x) << S_BLKRDEEPROMINTEN)
-#define F_BLKRDEEPROMINTEN V_BLKRDEEPROMINTEN(1U)
-
-#define S_SGLWREEPROMINTEN 15
-#define V_SGLWREEPROMINTEN(x) ((x) << S_SGLWREEPROMINTEN)
-#define F_SGLWREEPROMINTEN V_SGLWREEPROMINTEN(1U)
-
-#define S_SGLRDEEPROMINTEN 14
-#define V_SGLRDEEPROMINTEN(x) ((x) << S_SGLRDEEPROMINTEN)
-#define F_SGLRDEEPROMINTEN V_SGLRDEEPROMINTEN(1U)
-
-#define S_BLKWRFLASHINTEN 13
-#define V_BLKWRFLASHINTEN(x) ((x) << S_BLKWRFLASHINTEN)
-#define F_BLKWRFLASHINTEN V_BLKWRFLASHINTEN(1U)
-
-#define S_BLKRDFLASHINTEN 12
-#define V_BLKRDFLASHINTEN(x) ((x) << S_BLKRDFLASHINTEN)
-#define F_BLKRDFLASHINTEN V_BLKRDFLASHINTEN(1U)
-
-#define S_SGLWRFLASHINTEN 11
-#define V_SGLWRFLASHINTEN(x) ((x) << S_SGLWRFLASHINTEN)
-#define F_SGLWRFLASHINTEN V_SGLWRFLASHINTEN(1U)
-
-#define S_SGLRDFLASHINTEN 10
-#define V_SGLRDFLASHINTEN(x) ((x) << S_SGLRDFLASHINTEN)
-#define F_SGLRDFLASHINTEN V_SGLRDFLASHINTEN(1U)
-
-#define S_BLKWRBOOTINTEN 9
-#define V_BLKWRBOOTINTEN(x) ((x) << S_BLKWRBOOTINTEN)
-#define F_BLKWRBOOTINTEN V_BLKWRBOOTINTEN(1U)
-
-#define S_BLKRDBOOTINTEN 8
-#define V_BLKRDBOOTINTEN(x) ((x) << S_BLKRDBOOTINTEN)
-#define F_BLKRDBOOTINTEN V_BLKRDBOOTINTEN(1U)
-
-#define S_SGLWRBOOTINTEN 7
-#define V_SGLWRBOOTINTEN(x) ((x) << S_SGLWRBOOTINTEN)
-#define F_SGLWRBOOTINTEN V_SGLWRBOOTINTEN(1U)
-
-#define S_SGLRDBOOTINTEN 6
-#define V_SGLRDBOOTINTEN(x) ((x) << S_SGLRDBOOTINTEN)
-#define F_SGLRDBOOTINTEN V_SGLRDBOOTINTEN(1U)
-
-#define S_ILLWRBEINTEN 5
-#define V_ILLWRBEINTEN(x) ((x) << S_ILLWRBEINTEN)
-#define F_ILLWRBEINTEN V_ILLWRBEINTEN(1U)
-
-#define S_ILLRDBEINTEN 4
-#define V_ILLRDBEINTEN(x) ((x) << S_ILLRDBEINTEN)
-#define F_ILLRDBEINTEN V_ILLRDBEINTEN(1U)
-
-#define S_ILLRDINTEN 3
-#define V_ILLRDINTEN(x) ((x) << S_ILLRDINTEN)
-#define F_ILLRDINTEN V_ILLRDINTEN(1U)
-
-#define S_ILLWRINTEN 2
-#define V_ILLWRINTEN(x) ((x) << S_ILLWRINTEN)
-#define F_ILLWRINTEN V_ILLWRINTEN(1U)
-
-#define S_ILLTRANSINTEN 1
-#define V_ILLTRANSINTEN(x) ((x) << S_ILLTRANSINTEN)
-#define F_ILLTRANSINTEN V_ILLTRANSINTEN(1U)
-
-#define S_RSVDSPACEINTEN 0
-#define V_RSVDSPACEINTEN(x) ((x) << S_RSVDSPACEINTEN)
-#define F_RSVDSPACEINTEN V_RSVDSPACEINTEN(1U)
-
-#define A_CIM_HOST_UPACC_INT_CAUSE 0x7b34
-
-#define S_EEPROMWRINT 30
-#define V_EEPROMWRINT(x) ((x) << S_EEPROMWRINT)
-#define F_EEPROMWRINT V_EEPROMWRINT(1U)
-
-#define S_TIMEOUTMAINT 29
-#define V_TIMEOUTMAINT(x) ((x) << S_TIMEOUTMAINT)
-#define F_TIMEOUTMAINT V_TIMEOUTMAINT(1U)
-
-#define S_TIMEOUTINT 28
-#define V_TIMEOUTINT(x) ((x) << S_TIMEOUTINT)
-#define F_TIMEOUTINT V_TIMEOUTINT(1U)
-
-#define S_RSPOVRLOOKUPINT 27
-#define V_RSPOVRLOOKUPINT(x) ((x) << S_RSPOVRLOOKUPINT)
-#define F_RSPOVRLOOKUPINT V_RSPOVRLOOKUPINT(1U)
-
-#define S_REQOVRLOOKUPINT 26
-#define V_REQOVRLOOKUPINT(x) ((x) << S_REQOVRLOOKUPINT)
-#define F_REQOVRLOOKUPINT V_REQOVRLOOKUPINT(1U)
-
-#define S_BLKWRPLINT 25
-#define V_BLKWRPLINT(x) ((x) << S_BLKWRPLINT)
-#define F_BLKWRPLINT V_BLKWRPLINT(1U)
-
-#define S_BLKRDPLINT 24
-#define V_BLKRDPLINT(x) ((x) << S_BLKRDPLINT)
-#define F_BLKRDPLINT V_BLKRDPLINT(1U)
-
-#define S_SGLWRPLINT 23
-#define V_SGLWRPLINT(x) ((x) << S_SGLWRPLINT)
-#define F_SGLWRPLINT V_SGLWRPLINT(1U)
-
-#define S_SGLRDPLINT 22
-#define V_SGLRDPLINT(x) ((x) << S_SGLRDPLINT)
-#define F_SGLRDPLINT V_SGLRDPLINT(1U)
-
-#define S_BLKWRCTLINT 21
-#define V_BLKWRCTLINT(x) ((x) << S_BLKWRCTLINT)
-#define F_BLKWRCTLINT V_BLKWRCTLINT(1U)
-
-#define S_BLKRDCTLINT 20
-#define V_BLKRDCTLINT(x) ((x) << S_BLKRDCTLINT)
-#define F_BLKRDCTLINT V_BLKRDCTLINT(1U)
-
-#define S_SGLWRCTLINT 19
-#define V_SGLWRCTLINT(x) ((x) << S_SGLWRCTLINT)
-#define F_SGLWRCTLINT V_SGLWRCTLINT(1U)
-
-#define S_SGLRDCTLINT 18
-#define V_SGLRDCTLINT(x) ((x) << S_SGLRDCTLINT)
-#define F_SGLRDCTLINT V_SGLRDCTLINT(1U)
-
-#define S_BLKWREEPROMINT 17
-#define V_BLKWREEPROMINT(x) ((x) << S_BLKWREEPROMINT)
-#define F_BLKWREEPROMINT V_BLKWREEPROMINT(1U)
-
-#define S_BLKRDEEPROMINT 16
-#define V_BLKRDEEPROMINT(x) ((x) << S_BLKRDEEPROMINT)
-#define F_BLKRDEEPROMINT V_BLKRDEEPROMINT(1U)
-
-#define S_SGLWREEPROMINT 15
-#define V_SGLWREEPROMINT(x) ((x) << S_SGLWREEPROMINT)
-#define F_SGLWREEPROMINT V_SGLWREEPROMINT(1U)
-
-#define S_SGLRDEEPROMINT 14
-#define V_SGLRDEEPROMINT(x) ((x) << S_SGLRDEEPROMINT)
-#define F_SGLRDEEPROMINT V_SGLRDEEPROMINT(1U)
-
-#define S_BLKWRFLASHINT 13
-#define V_BLKWRFLASHINT(x) ((x) << S_BLKWRFLASHINT)
-#define F_BLKWRFLASHINT V_BLKWRFLASHINT(1U)
-
-#define S_BLKRDFLASHINT 12
-#define V_BLKRDFLASHINT(x) ((x) << S_BLKRDFLASHINT)
-#define F_BLKRDFLASHINT V_BLKRDFLASHINT(1U)
-
-#define S_SGLWRFLASHINT 11
-#define V_SGLWRFLASHINT(x) ((x) << S_SGLWRFLASHINT)
-#define F_SGLWRFLASHINT V_SGLWRFLASHINT(1U)
-
-#define S_SGLRDFLASHINT 10
-#define V_SGLRDFLASHINT(x) ((x) << S_SGLRDFLASHINT)
-#define F_SGLRDFLASHINT V_SGLRDFLASHINT(1U)
-
-#define S_BLKWRBOOTINT 9
-#define V_BLKWRBOOTINT(x) ((x) << S_BLKWRBOOTINT)
-#define F_BLKWRBOOTINT V_BLKWRBOOTINT(1U)
-
-#define S_BLKRDBOOTINT 8
-#define V_BLKRDBOOTINT(x) ((x) << S_BLKRDBOOTINT)
-#define F_BLKRDBOOTINT V_BLKRDBOOTINT(1U)
-
-#define S_SGLWRBOOTINT 7
-#define V_SGLWRBOOTINT(x) ((x) << S_SGLWRBOOTINT)
-#define F_SGLWRBOOTINT V_SGLWRBOOTINT(1U)
-
-#define S_SGLRDBOOTINT 6
-#define V_SGLRDBOOTINT(x) ((x) << S_SGLRDBOOTINT)
-#define F_SGLRDBOOTINT V_SGLRDBOOTINT(1U)
-
-#define S_ILLWRBEINT 5
-#define V_ILLWRBEINT(x) ((x) << S_ILLWRBEINT)
-#define F_ILLWRBEINT V_ILLWRBEINT(1U)
-
-#define S_ILLRDBEINT 4
-#define V_ILLRDBEINT(x) ((x) << S_ILLRDBEINT)
-#define F_ILLRDBEINT V_ILLRDBEINT(1U)
-
-#define S_ILLRDINT 3
-#define V_ILLRDINT(x) ((x) << S_ILLRDINT)
-#define F_ILLRDINT V_ILLRDINT(1U)
-
-#define S_ILLWRINT 2
-#define V_ILLWRINT(x) ((x) << S_ILLWRINT)
-#define F_ILLWRINT V_ILLWRINT(1U)
-
-#define S_ILLTRANSINT 1
-#define V_ILLTRANSINT(x) ((x) << S_ILLTRANSINT)
-#define F_ILLTRANSINT V_ILLTRANSINT(1U)
-
-#define S_RSVDSPACEINT 0
-#define V_RSVDSPACEINT(x) ((x) << S_RSVDSPACEINT)
-#define F_RSVDSPACEINT V_RSVDSPACEINT(1U)
-
-#define A_CIM_UP_INT_ENABLE 0x7b38
-
-#define S_MSTPLINTEN 4
-#define V_MSTPLINTEN(x) ((x) << S_MSTPLINTEN)
-#define F_MSTPLINTEN V_MSTPLINTEN(1U)
-
-#define A_CIM_UP_INT_CAUSE 0x7b3c
-
-#define S_MSTPLINT 4
-#define V_MSTPLINT(x) ((x) << S_MSTPLINT)
-#define F_MSTPLINT V_MSTPLINT(1U)
-
-#define A_CIM_UP_ACC_INT_ENABLE 0x7b40
-#define A_CIM_UP_ACC_INT_CAUSE 0x7b44
-#define A_CIM_QUEUE_CONFIG_REF 0x7b48
-
-#define S_OBQSELECT 4
-#define V_OBQSELECT(x) ((x) << S_OBQSELECT)
-#define F_OBQSELECT V_OBQSELECT(1U)
-
-#define S_IBQSELECT 3
-#define V_IBQSELECT(x) ((x) << S_IBQSELECT)
-#define F_IBQSELECT V_IBQSELECT(1U)
-
-#define S_QUENUMSELECT 0
-#define M_QUENUMSELECT 0x7U
-#define V_QUENUMSELECT(x) ((x) << S_QUENUMSELECT)
-#define G_QUENUMSELECT(x) (((x) >> S_QUENUMSELECT) & M_QUENUMSELECT)
-
-#define A_CIM_QUEUE_CONFIG_CTRL 0x7b4c
-
-#define S_CIMQSIZE 24
-#define M_CIMQSIZE 0x3fU
-#define V_CIMQSIZE(x) ((x) << S_CIMQSIZE)
-#define G_CIMQSIZE(x) (((x) >> S_CIMQSIZE) & M_CIMQSIZE)
-
-#define S_CIMQBASE 16
-#define M_CIMQBASE 0x3fU
-#define V_CIMQBASE(x) ((x) << S_CIMQBASE)
-#define G_CIMQBASE(x) (((x) >> S_CIMQBASE) & M_CIMQBASE)
-
-#define S_CIMQDBG8BEN 9
-#define V_CIMQDBG8BEN(x) ((x) << S_CIMQDBG8BEN)
-#define F_CIMQDBG8BEN V_CIMQDBG8BEN(1U)
-
-#define S_QUEFULLTHRSH 0
-#define M_QUEFULLTHRSH 0x1ffU
-#define V_QUEFULLTHRSH(x) ((x) << S_QUEFULLTHRSH)
-#define G_QUEFULLTHRSH(x) (((x) >> S_QUEFULLTHRSH) & M_QUEFULLTHRSH)
-
-#define S_CIMQ1KEN 30
-#define V_CIMQ1KEN(x) ((x) << S_CIMQ1KEN)
-#define F_CIMQ1KEN V_CIMQ1KEN(1U)
-
-#define A_CIM_HOST_ACC_CTRL 0x7b50
-
-#define S_HOSTBUSY 17
-#define V_HOSTBUSY(x) ((x) << S_HOSTBUSY)
-#define F_HOSTBUSY V_HOSTBUSY(1U)
-
-#define S_HOSTWRITE 16
-#define V_HOSTWRITE(x) ((x) << S_HOSTWRITE)
-#define F_HOSTWRITE V_HOSTWRITE(1U)
-
-#define S_HOSTADDR 0
-#define M_HOSTADDR 0xffffU
-#define V_HOSTADDR(x) ((x) << S_HOSTADDR)
-#define G_HOSTADDR(x) (((x) >> S_HOSTADDR) & M_HOSTADDR)
-
-#define A_CIM_HOST_ACC_DATA 0x7b54
-#define A_CIM_CDEBUGDATA 0x7b58
-
-#define S_CDEBUGDATAH 16
-#define M_CDEBUGDATAH 0xffffU
-#define V_CDEBUGDATAH(x) ((x) << S_CDEBUGDATAH)
-#define G_CDEBUGDATAH(x) (((x) >> S_CDEBUGDATAH) & M_CDEBUGDATAH)
-
-#define S_CDEBUGDATAL 0
-#define M_CDEBUGDATAL 0xffffU
-#define V_CDEBUGDATAL(x) ((x) << S_CDEBUGDATAL)
-#define G_CDEBUGDATAL(x) (((x) >> S_CDEBUGDATAL) & M_CDEBUGDATAL)
-
-#define A_CIM_IBQ_DBG_CFG 0x7b60
-
-#define S_IBQDBGADDR 16
-#define M_IBQDBGADDR 0xfffU
-#define V_IBQDBGADDR(x) ((x) << S_IBQDBGADDR)
-#define G_IBQDBGADDR(x) (((x) >> S_IBQDBGADDR) & M_IBQDBGADDR)
-
-#define S_IBQDBGWR 2
-#define V_IBQDBGWR(x) ((x) << S_IBQDBGWR)
-#define F_IBQDBGWR V_IBQDBGWR(1U)
-
-#define S_IBQDBGBUSY 1
-#define V_IBQDBGBUSY(x) ((x) << S_IBQDBGBUSY)
-#define F_IBQDBGBUSY V_IBQDBGBUSY(1U)
-
-#define S_IBQDBGEN 0
-#define V_IBQDBGEN(x) ((x) << S_IBQDBGEN)
-#define F_IBQDBGEN V_IBQDBGEN(1U)
-
-#define A_CIM_OBQ_DBG_CFG 0x7b64
-
-#define S_OBQDBGADDR 16
-#define M_OBQDBGADDR 0xfffU
-#define V_OBQDBGADDR(x) ((x) << S_OBQDBGADDR)
-#define G_OBQDBGADDR(x) (((x) >> S_OBQDBGADDR) & M_OBQDBGADDR)
-
-#define S_OBQDBGWR 2
-#define V_OBQDBGWR(x) ((x) << S_OBQDBGWR)
-#define F_OBQDBGWR V_OBQDBGWR(1U)
-
-#define S_OBQDBGBUSY 1
-#define V_OBQDBGBUSY(x) ((x) << S_OBQDBGBUSY)
-#define F_OBQDBGBUSY V_OBQDBGBUSY(1U)
-
-#define S_OBQDBGEN 0
-#define V_OBQDBGEN(x) ((x) << S_OBQDBGEN)
-#define F_OBQDBGEN V_OBQDBGEN(1U)
-
-#define A_CIM_IBQ_DBG_DATA 0x7b68
-#define A_CIM_OBQ_DBG_DATA 0x7b6c
-#define A_CIM_DEBUGCFG 0x7b70
-
-#define S_POLADBGRDPTR 23
-#define M_POLADBGRDPTR 0x1ffU
-#define V_POLADBGRDPTR(x) ((x) << S_POLADBGRDPTR)
-#define G_POLADBGRDPTR(x) (((x) >> S_POLADBGRDPTR) & M_POLADBGRDPTR)
-
-#define S_PILADBGRDPTR 14
-#define M_PILADBGRDPTR 0x1ffU
-#define V_PILADBGRDPTR(x) ((x) << S_PILADBGRDPTR)
-#define G_PILADBGRDPTR(x) (((x) >> S_PILADBGRDPTR) & M_PILADBGRDPTR)
-
-#define S_LAMASKTRIG 13
-#define V_LAMASKTRIG(x) ((x) << S_LAMASKTRIG)
-#define F_LAMASKTRIG V_LAMASKTRIG(1U)
-
-#define S_LADBGEN 12
-#define V_LADBGEN(x) ((x) << S_LADBGEN)
-#define F_LADBGEN V_LADBGEN(1U)
-
-#define S_LAFILLONCE 11
-#define V_LAFILLONCE(x) ((x) << S_LAFILLONCE)
-#define F_LAFILLONCE V_LAFILLONCE(1U)
-
-#define S_LAMASKSTOP 10
-#define V_LAMASKSTOP(x) ((x) << S_LAMASKSTOP)
-#define F_LAMASKSTOP V_LAMASKSTOP(1U)
-
-#define S_DEBUGSELH 5
-#define M_DEBUGSELH 0x1fU
-#define V_DEBUGSELH(x) ((x) << S_DEBUGSELH)
-#define G_DEBUGSELH(x) (((x) >> S_DEBUGSELH) & M_DEBUGSELH)
-
-#define S_DEBUGSELL 0
-#define M_DEBUGSELL 0x1fU
-#define V_DEBUGSELL(x) ((x) << S_DEBUGSELL)
-#define G_DEBUGSELL(x) (((x) >> S_DEBUGSELL) & M_DEBUGSELL)
-
-#define A_CIM_DEBUGSTS 0x7b74
-
-#define S_LARESET 31
-#define V_LARESET(x) ((x) << S_LARESET)
-#define F_LARESET V_LARESET(1U)
-
-#define S_POLADBGWRPTR 16
-#define M_POLADBGWRPTR 0x1ffU
-#define V_POLADBGWRPTR(x) ((x) << S_POLADBGWRPTR)
-#define G_POLADBGWRPTR(x) (((x) >> S_POLADBGWRPTR) & M_POLADBGWRPTR)
-
-#define S_PILADBGWRPTR 0
-#define M_PILADBGWRPTR 0x1ffU
-#define V_PILADBGWRPTR(x) ((x) << S_PILADBGWRPTR)
-#define G_PILADBGWRPTR(x) (((x) >> S_PILADBGWRPTR) & M_PILADBGWRPTR)
-
-#define A_CIM_PO_LA_DEBUGDATA 0x7b78
-#define A_CIM_PI_LA_DEBUGDATA 0x7b7c
-#define A_CIM_PO_LA_MADEBUGDATA 0x7b80
-#define A_CIM_PI_LA_MADEBUGDATA 0x7b84
-#define A_CIM_PO_LA_PIFSMDEBUGDATA 0x7b8c
-#define A_CIM_MEM_ZONE0_VA 0x7b90
-
-#define S_MEM_ZONE_VA 4
-#define M_MEM_ZONE_VA 0xfffffffU
-#define V_MEM_ZONE_VA(x) ((x) << S_MEM_ZONE_VA)
-#define G_MEM_ZONE_VA(x) (((x) >> S_MEM_ZONE_VA) & M_MEM_ZONE_VA)
-
-#define A_CIM_MEM_ZONE0_BA 0x7b94
-
-#define S_MEM_ZONE_BA 6
-#define M_MEM_ZONE_BA 0x3ffffffU
-#define V_MEM_ZONE_BA(x) ((x) << S_MEM_ZONE_BA)
-#define G_MEM_ZONE_BA(x) (((x) >> S_MEM_ZONE_BA) & M_MEM_ZONE_BA)
-
-#define S_PBT_ENABLE 5
-#define V_PBT_ENABLE(x) ((x) << S_PBT_ENABLE)
-#define F_PBT_ENABLE V_PBT_ENABLE(1U)
-
-#define S_ZONE_DST 0
-#define M_ZONE_DST 0x3U
-#define V_ZONE_DST(x) ((x) << S_ZONE_DST)
-#define G_ZONE_DST(x) (((x) >> S_ZONE_DST) & M_ZONE_DST)
-
-#define A_CIM_MEM_ZONE0_LEN 0x7b98
-
-#define S_MEM_ZONE_LEN 4
-#define M_MEM_ZONE_LEN 0xfffffffU
-#define V_MEM_ZONE_LEN(x) ((x) << S_MEM_ZONE_LEN)
-#define G_MEM_ZONE_LEN(x) (((x) >> S_MEM_ZONE_LEN) & M_MEM_ZONE_LEN)
-
-#define A_CIM_MEM_ZONE1_VA 0x7b9c
-#define A_CIM_MEM_ZONE1_BA 0x7ba0
-#define A_CIM_MEM_ZONE1_LEN 0x7ba4
-#define A_CIM_MEM_ZONE2_VA 0x7ba8
-#define A_CIM_MEM_ZONE2_BA 0x7bac
-#define A_CIM_MEM_ZONE2_LEN 0x7bb0
-#define A_CIM_MEM_ZONE3_VA 0x7bb4
-#define A_CIM_MEM_ZONE3_BA 0x7bb8
-#define A_CIM_MEM_ZONE3_LEN 0x7bbc
-#define A_CIM_MEM_ZONE4_VA 0x7bc0
-#define A_CIM_MEM_ZONE4_BA 0x7bc4
-#define A_CIM_MEM_ZONE4_LEN 0x7bc8
-#define A_CIM_MEM_ZONE5_VA 0x7bcc
-#define A_CIM_MEM_ZONE5_BA 0x7bd0
-#define A_CIM_MEM_ZONE5_LEN 0x7bd4
-#define A_CIM_MEM_ZONE6_VA 0x7bd8
-#define A_CIM_MEM_ZONE6_BA 0x7bdc
-#define A_CIM_MEM_ZONE6_LEN 0x7be0
-#define A_CIM_MEM_ZONE7_VA 0x7be4
-#define A_CIM_MEM_ZONE7_BA 0x7be8
-#define A_CIM_MEM_ZONE7_LEN 0x7bec
-#define A_CIM_BOOT_LEN 0x7bf0
-
-#define S_BOOTLEN 4
-#define M_BOOTLEN 0xfffffffU
-#define V_BOOTLEN(x) ((x) << S_BOOTLEN)
-#define G_BOOTLEN(x) (((x) >> S_BOOTLEN) & M_BOOTLEN)
-
-#define A_CIM_GLB_TIMER_CTL 0x7bf4
-
-#define S_TIMER1EN 4
-#define V_TIMER1EN(x) ((x) << S_TIMER1EN)
-#define F_TIMER1EN V_TIMER1EN(1U)
-
-#define S_TIMER0EN 3
-#define V_TIMER0EN(x) ((x) << S_TIMER0EN)
-#define F_TIMER0EN V_TIMER0EN(1U)
-
-#define S_TIMEREN 1
-#define V_TIMEREN(x) ((x) << S_TIMEREN)
-#define F_TIMEREN V_TIMEREN(1U)
-
-#define A_CIM_GLB_TIMER 0x7bf8
-#define A_CIM_GLB_TIMER_TICK 0x7bfc
-
-#define S_GLBLTTICK 0
-#define M_GLBLTTICK 0xffffU
-#define V_GLBLTTICK(x) ((x) << S_GLBLTTICK)
-#define G_GLBLTTICK(x) (((x) >> S_GLBLTTICK) & M_GLBLTTICK)
-
-#define A_CIM_TIMER0 0x7c00
-#define A_CIM_TIMER1 0x7c04
-#define A_CIM_DEBUG_ADDR_TIMEOUT 0x7c08
-
-#define S_DADDRTIMEOUT 2
-#define M_DADDRTIMEOUT 0x3fffffffU
-#define V_DADDRTIMEOUT(x) ((x) << S_DADDRTIMEOUT)
-#define G_DADDRTIMEOUT(x) (((x) >> S_DADDRTIMEOUT) & M_DADDRTIMEOUT)
-
-#define S_DADDRTIMEOUTTYPE 0
-#define M_DADDRTIMEOUTTYPE 0x3U
-#define V_DADDRTIMEOUTTYPE(x) ((x) << S_DADDRTIMEOUTTYPE)
-#define G_DADDRTIMEOUTTYPE(x) (((x) >> S_DADDRTIMEOUTTYPE) & M_DADDRTIMEOUTTYPE)
-
-#define A_CIM_DEBUG_ADDR_ILLEGAL 0x7c0c
-
-#define S_DADDRILLEGAL 2
-#define M_DADDRILLEGAL 0x3fffffffU
-#define V_DADDRILLEGAL(x) ((x) << S_DADDRILLEGAL)
-#define G_DADDRILLEGAL(x) (((x) >> S_DADDRILLEGAL) & M_DADDRILLEGAL)
-
-#define S_DADDRILLEGALTYPE 0
-#define M_DADDRILLEGALTYPE 0x3U
-#define V_DADDRILLEGALTYPE(x) ((x) << S_DADDRILLEGALTYPE)
-#define G_DADDRILLEGALTYPE(x) (((x) >> S_DADDRILLEGALTYPE) & M_DADDRILLEGALTYPE)
-
-#define A_CIM_DEBUG_PIF_CAUSE_MASK 0x7c10
-
-#define S_DPIFHOSTMASK 0
-#define M_DPIFHOSTMASK 0x1fffffU
-#define V_DPIFHOSTMASK(x) ((x) << S_DPIFHOSTMASK)
-#define G_DPIFHOSTMASK(x) (((x) >> S_DPIFHOSTMASK) & M_DPIFHOSTMASK)
-
-#define S_T5_DPIFHOSTMASK 0
-#define M_T5_DPIFHOSTMASK 0x1fffffffU
-#define V_T5_DPIFHOSTMASK(x) ((x) << S_T5_DPIFHOSTMASK)
-#define G_T5_DPIFHOSTMASK(x) (((x) >> S_T5_DPIFHOSTMASK) & M_T5_DPIFHOSTMASK)
-
-#define S_T6_T5_DPIFHOSTMASK 0
-#define M_T6_T5_DPIFHOSTMASK 0x3fffffffU
-#define V_T6_T5_DPIFHOSTMASK(x) ((x) << S_T6_T5_DPIFHOSTMASK)
-#define G_T6_T5_DPIFHOSTMASK(x) (((x) >> S_T6_T5_DPIFHOSTMASK) & M_T6_T5_DPIFHOSTMASK)
-
-#define A_CIM_DEBUG_PIF_UPACC_CAUSE_MASK 0x7c14
-
-#define S_DPIFHUPAMASK 0
-#define M_DPIFHUPAMASK 0x7fffffffU
-#define V_DPIFHUPAMASK(x) ((x) << S_DPIFHUPAMASK)
-#define G_DPIFHUPAMASK(x) (((x) >> S_DPIFHUPAMASK) & M_DPIFHUPAMASK)
-
-#define A_CIM_DEBUG_UP_CAUSE_MASK 0x7c18
-
-#define S_DUPMASK 0
-#define M_DUPMASK 0x1fffffU
-#define V_DUPMASK(x) ((x) << S_DUPMASK)
-#define G_DUPMASK(x) (((x) >> S_DUPMASK) & M_DUPMASK)
-
-#define S_T5_DUPMASK 0
-#define M_T5_DUPMASK 0x1fffffffU
-#define V_T5_DUPMASK(x) ((x) << S_T5_DUPMASK)
-#define G_T5_DUPMASK(x) (((x) >> S_T5_DUPMASK) & M_T5_DUPMASK)
-
-#define S_T6_T5_DUPMASK 0
-#define M_T6_T5_DUPMASK 0x3fffffffU
-#define V_T6_T5_DUPMASK(x) ((x) << S_T6_T5_DUPMASK)
-#define G_T6_T5_DUPMASK(x) (((x) >> S_T6_T5_DUPMASK) & M_T6_T5_DUPMASK)
-
-#define A_CIM_DEBUG_UP_UPACC_CAUSE_MASK 0x7c1c
-
-#define S_DUPUACCMASK 0
-#define M_DUPUACCMASK 0x7fffffffU
-#define V_DUPUACCMASK(x) ((x) << S_DUPUACCMASK)
-#define G_DUPUACCMASK(x) (((x) >> S_DUPUACCMASK) & M_DUPUACCMASK)
-
-#define A_CIM_PERR_INJECT 0x7c20
-#define A_CIM_PERR_ENABLE 0x7c24
-
-#define S_PERREN 0
-#define M_PERREN 0x1fffffU
-#define V_PERREN(x) ((x) << S_PERREN)
-#define G_PERREN(x) (((x) >> S_PERREN) & M_PERREN)
-
-#define S_T5_PERREN 0
-#define M_T5_PERREN 0x1fffffffU
-#define V_T5_PERREN(x) ((x) << S_T5_PERREN)
-#define G_T5_PERREN(x) (((x) >> S_T5_PERREN) & M_T5_PERREN)
-
-#define S_T6_T5_PERREN 0
-#define M_T6_T5_PERREN 0x3fffffffU
-#define V_T6_T5_PERREN(x) ((x) << S_T6_T5_PERREN)
-#define G_T6_T5_PERREN(x) (((x) >> S_T6_T5_PERREN) & M_T6_T5_PERREN)
-
-#define A_CIM_EEPROM_BUSY_BIT 0x7c28
-
-#define S_EEPROMBUSY 0
-#define V_EEPROMBUSY(x) ((x) << S_EEPROMBUSY)
-#define F_EEPROMBUSY V_EEPROMBUSY(1U)
-
-#define A_CIM_MA_TIMER_EN 0x7c2c
-
-#define S_MA_TIMER_ENABLE 0
-#define V_MA_TIMER_ENABLE(x) ((x) << S_MA_TIMER_ENABLE)
-#define F_MA_TIMER_ENABLE V_MA_TIMER_ENABLE(1U)
-
-#define S_SLOW_TIMER_ENABLE 1
-#define V_SLOW_TIMER_ENABLE(x) ((x) << S_SLOW_TIMER_ENABLE)
-#define F_SLOW_TIMER_ENABLE V_SLOW_TIMER_ENABLE(1U)
-
-#define A_CIM_UP_PO_SINGLE_OUTSTANDING 0x7c30
-
-#define S_UP_PO_SINGLE_OUTSTANDING 0
-#define V_UP_PO_SINGLE_OUTSTANDING(x) ((x) << S_UP_PO_SINGLE_OUTSTANDING)
-#define F_UP_PO_SINGLE_OUTSTANDING V_UP_PO_SINGLE_OUTSTANDING(1U)
-
-#define A_CIM_CIM_DEBUG_SPARE 0x7c34
-#define A_CIM_UP_OPERATION_FREQ 0x7c38
-#define A_CIM_CIM_IBQ_ERR_CODE 0x7c3c
-
-#define S_CIM_ULP_TX_PKT_ERR_CODE 16
-#define M_CIM_ULP_TX_PKT_ERR_CODE 0xffU
-#define V_CIM_ULP_TX_PKT_ERR_CODE(x) ((x) << S_CIM_ULP_TX_PKT_ERR_CODE)
-#define G_CIM_ULP_TX_PKT_ERR_CODE(x) (((x) >> S_CIM_ULP_TX_PKT_ERR_CODE) & M_CIM_ULP_TX_PKT_ERR_CODE)
-
-#define S_CIM_SGE1_PKT_ERR_CODE 8
-#define M_CIM_SGE1_PKT_ERR_CODE 0xffU
-#define V_CIM_SGE1_PKT_ERR_CODE(x) ((x) << S_CIM_SGE1_PKT_ERR_CODE)
-#define G_CIM_SGE1_PKT_ERR_CODE(x) (((x) >> S_CIM_SGE1_PKT_ERR_CODE) & M_CIM_SGE1_PKT_ERR_CODE)
-
-#define S_CIM_SGE0_PKT_ERR_CODE 0
-#define M_CIM_SGE0_PKT_ERR_CODE 0xffU
-#define V_CIM_SGE0_PKT_ERR_CODE(x) ((x) << S_CIM_SGE0_PKT_ERR_CODE)
-#define G_CIM_SGE0_PKT_ERR_CODE(x) (((x) >> S_CIM_SGE0_PKT_ERR_CODE) & M_CIM_SGE0_PKT_ERR_CODE)
-
-#define S_CIM_PCIE_PKT_ERR_CODE 8
-#define M_CIM_PCIE_PKT_ERR_CODE 0xffU
-#define V_CIM_PCIE_PKT_ERR_CODE(x) ((x) << S_CIM_PCIE_PKT_ERR_CODE)
-#define G_CIM_PCIE_PKT_ERR_CODE(x) (((x) >> S_CIM_PCIE_PKT_ERR_CODE) & M_CIM_PCIE_PKT_ERR_CODE)
-
-#define A_CIM_IBQ_DBG_WAIT_COUNTER 0x7c40
-#define A_CIM_PIO_UP_MST_CFG_SEL 0x7c44
-
-#define S_PIO_UP_MST_CFG_SEL 0
-#define V_PIO_UP_MST_CFG_SEL(x) ((x) << S_PIO_UP_MST_CFG_SEL)
-#define F_PIO_UP_MST_CFG_SEL V_PIO_UP_MST_CFG_SEL(1U)
-
-#define A_CIM_CGEN 0x7c48
-
-#define S_TSCH_CGEN 0
-#define V_TSCH_CGEN(x) ((x) << S_TSCH_CGEN)
-#define F_TSCH_CGEN V_TSCH_CGEN(1U)
-
-#define A_CIM_QUEUE_FEATURE_DISABLE 0x7c4c
-
-#define S_OBQ_THROUTTLE_ON_EOP 4
-#define V_OBQ_THROUTTLE_ON_EOP(x) ((x) << S_OBQ_THROUTTLE_ON_EOP)
-#define F_OBQ_THROUTTLE_ON_EOP V_OBQ_THROUTTLE_ON_EOP(1U)
-
-#define S_OBQ_READ_CTL_PERF_MODE_DISABLE 3
-#define V_OBQ_READ_CTL_PERF_MODE_DISABLE(x) ((x) << S_OBQ_READ_CTL_PERF_MODE_DISABLE)
-#define F_OBQ_READ_CTL_PERF_MODE_DISABLE V_OBQ_READ_CTL_PERF_MODE_DISABLE(1U)
-
-#define S_OBQ_WAIT_FOR_EOP_FLUSH_DISABLE 2
-#define V_OBQ_WAIT_FOR_EOP_FLUSH_DISABLE(x) ((x) << S_OBQ_WAIT_FOR_EOP_FLUSH_DISABLE)
-#define F_OBQ_WAIT_FOR_EOP_FLUSH_DISABLE V_OBQ_WAIT_FOR_EOP_FLUSH_DISABLE(1U)
-
-#define S_IBQ_RRA_DSBL 1
-#define V_IBQ_RRA_DSBL(x) ((x) << S_IBQ_RRA_DSBL)
-#define F_IBQ_RRA_DSBL V_IBQ_RRA_DSBL(1U)
-
-#define S_IBQ_SKID_FIFO_EOP_FLSH_DSBL 0
-#define V_IBQ_SKID_FIFO_EOP_FLSH_DSBL(x) ((x) << S_IBQ_SKID_FIFO_EOP_FLSH_DSBL)
-#define F_IBQ_SKID_FIFO_EOP_FLSH_DSBL V_IBQ_SKID_FIFO_EOP_FLSH_DSBL(1U)
-
-#define S_PCIE_OBQ_IF_DISABLE 5
-#define V_PCIE_OBQ_IF_DISABLE(x) ((x) << S_PCIE_OBQ_IF_DISABLE)
-#define F_PCIE_OBQ_IF_DISABLE V_PCIE_OBQ_IF_DISABLE(1U)
-
-#define A_CIM_CGEN_GLOBAL 0x7c50
-
-#define S_CGEN_GLOBAL 0
-#define V_CGEN_GLOBAL(x) ((x) << S_CGEN_GLOBAL)
-#define F_CGEN_GLOBAL V_CGEN_GLOBAL(1U)
-
-#define A_CIM_DPSLP_EN 0x7c54
-
-#define S_PIFDBGLA_DPSLP_EN 0
-#define V_PIFDBGLA_DPSLP_EN(x) ((x) << S_PIFDBGLA_DPSLP_EN)
-#define F_PIFDBGLA_DPSLP_EN V_PIFDBGLA_DPSLP_EN(1U)
-
-/* registers for module TP */
-#define TP_BASE_ADDR 0x7d00
-
-#define A_TP_IN_CONFIG 0x7d00
-
-#define S_TCPOPTPARSERDISCH3 27
-#define V_TCPOPTPARSERDISCH3(x) ((x) << S_TCPOPTPARSERDISCH3)
-#define F_TCPOPTPARSERDISCH3 V_TCPOPTPARSERDISCH3(1U)
-
-#define S_TCPOPTPARSERDISCH2 26
-#define V_TCPOPTPARSERDISCH2(x) ((x) << S_TCPOPTPARSERDISCH2)
-#define F_TCPOPTPARSERDISCH2 V_TCPOPTPARSERDISCH2(1U)
-
-#define S_TCPOPTPARSERDISCH1 25
-#define V_TCPOPTPARSERDISCH1(x) ((x) << S_TCPOPTPARSERDISCH1)
-#define F_TCPOPTPARSERDISCH1 V_TCPOPTPARSERDISCH1(1U)
-
-#define S_TCPOPTPARSERDISCH0 24
-#define V_TCPOPTPARSERDISCH0(x) ((x) << S_TCPOPTPARSERDISCH0)
-#define F_TCPOPTPARSERDISCH0 V_TCPOPTPARSERDISCH0(1U)
-
-#define S_CRCPASSPRT3 23
-#define V_CRCPASSPRT3(x) ((x) << S_CRCPASSPRT3)
-#define F_CRCPASSPRT3 V_CRCPASSPRT3(1U)
-
-#define S_CRCPASSPRT2 22
-#define V_CRCPASSPRT2(x) ((x) << S_CRCPASSPRT2)
-#define F_CRCPASSPRT2 V_CRCPASSPRT2(1U)
-
-#define S_CRCPASSPRT1 21
-#define V_CRCPASSPRT1(x) ((x) << S_CRCPASSPRT1)
-#define F_CRCPASSPRT1 V_CRCPASSPRT1(1U)
-
-#define S_CRCPASSPRT0 20
-#define V_CRCPASSPRT0(x) ((x) << S_CRCPASSPRT0)
-#define F_CRCPASSPRT0 V_CRCPASSPRT0(1U)
-
-#define S_VEPAMODE 19
-#define V_VEPAMODE(x) ((x) << S_VEPAMODE)
-#define F_VEPAMODE V_VEPAMODE(1U)
-
-#define S_FIPUPEN 18
-#define V_FIPUPEN(x) ((x) << S_FIPUPEN)
-#define F_FIPUPEN V_FIPUPEN(1U)
-
-#define S_FCOEUPEN 17
-#define V_FCOEUPEN(x) ((x) << S_FCOEUPEN)
-#define F_FCOEUPEN V_FCOEUPEN(1U)
-
-#define S_FCOEENABLE 16
-#define V_FCOEENABLE(x) ((x) << S_FCOEENABLE)
-#define F_FCOEENABLE V_FCOEENABLE(1U)
-
-#define S_IPV6ENABLE 15
-#define V_IPV6ENABLE(x) ((x) << S_IPV6ENABLE)
-#define F_IPV6ENABLE V_IPV6ENABLE(1U)
-
-#define S_NICMODE 14
-#define V_NICMODE(x) ((x) << S_NICMODE)
-#define F_NICMODE V_NICMODE(1U)
-
-#define S_ECHECKSUMCHECKTCP 13
-#define V_ECHECKSUMCHECKTCP(x) ((x) << S_ECHECKSUMCHECKTCP)
-#define F_ECHECKSUMCHECKTCP V_ECHECKSUMCHECKTCP(1U)
-
-#define S_ECHECKSUMCHECKIP 12
-#define V_ECHECKSUMCHECKIP(x) ((x) << S_ECHECKSUMCHECKIP)
-#define F_ECHECKSUMCHECKIP V_ECHECKSUMCHECKIP(1U)
-
-#define S_EREPORTUDPHDRLEN 11
-#define V_EREPORTUDPHDRLEN(x) ((x) << S_EREPORTUDPHDRLEN)
-#define F_EREPORTUDPHDRLEN V_EREPORTUDPHDRLEN(1U)
-
-#define S_IN_ECPL 10
-#define V_IN_ECPL(x) ((x) << S_IN_ECPL)
-#define F_IN_ECPL V_IN_ECPL(1U)
-
-#define S_VNTAGENABLE 9
-#define V_VNTAGENABLE(x) ((x) << S_VNTAGENABLE)
-#define F_VNTAGENABLE V_VNTAGENABLE(1U)
-
-#define S_IN_EETH 8
-#define V_IN_EETH(x) ((x) << S_IN_EETH)
-#define F_IN_EETH V_IN_EETH(1U)
-
-#define S_CCHECKSUMCHECKTCP 6
-#define V_CCHECKSUMCHECKTCP(x) ((x) << S_CCHECKSUMCHECKTCP)
-#define F_CCHECKSUMCHECKTCP V_CCHECKSUMCHECKTCP(1U)
-
-#define S_CCHECKSUMCHECKIP 5
-#define V_CCHECKSUMCHECKIP(x) ((x) << S_CCHECKSUMCHECKIP)
-#define F_CCHECKSUMCHECKIP V_CCHECKSUMCHECKIP(1U)
-
-#define S_CTAG 4
-#define V_CTAG(x) ((x) << S_CTAG)
-#define F_CTAG V_CTAG(1U)
-
-#define S_IN_CCPL 3
-#define V_IN_CCPL(x) ((x) << S_IN_CCPL)
-#define F_IN_CCPL V_IN_CCPL(1U)
-
-#define S_IN_CETH 1
-#define V_IN_CETH(x) ((x) << S_IN_CETH)
-#define F_IN_CETH V_IN_CETH(1U)
-
-#define S_CTUNNEL 0
-#define V_CTUNNEL(x) ((x) << S_CTUNNEL)
-#define F_CTUNNEL V_CTUNNEL(1U)
-
-#define S_VLANEXTENPORT3 31
-#define V_VLANEXTENPORT3(x) ((x) << S_VLANEXTENPORT3)
-#define F_VLANEXTENPORT3 V_VLANEXTENPORT3(1U)
-
-#define S_VLANEXTENPORT2 30
-#define V_VLANEXTENPORT2(x) ((x) << S_VLANEXTENPORT2)
-#define F_VLANEXTENPORT2 V_VLANEXTENPORT2(1U)
-
-#define S_VLANEXTENPORT1 29
-#define V_VLANEXTENPORT1(x) ((x) << S_VLANEXTENPORT1)
-#define F_VLANEXTENPORT1 V_VLANEXTENPORT1(1U)
-
-#define S_VLANEXTENPORT0 28
-#define V_VLANEXTENPORT0(x) ((x) << S_VLANEXTENPORT0)
-#define F_VLANEXTENPORT0 V_VLANEXTENPORT0(1U)
-
-#define S_VNTAGDEFAULTVAL 13
-#define V_VNTAGDEFAULTVAL(x) ((x) << S_VNTAGDEFAULTVAL)
-#define F_VNTAGDEFAULTVAL V_VNTAGDEFAULTVAL(1U)
-
-#define S_ECHECKUDPLEN 12
-#define V_ECHECKUDPLEN(x) ((x) << S_ECHECKUDPLEN)
-#define F_ECHECKUDPLEN V_ECHECKUDPLEN(1U)
-
-#define S_FCOEFPMA 10
-#define V_FCOEFPMA(x) ((x) << S_FCOEFPMA)
-#define F_FCOEFPMA V_FCOEFPMA(1U)
-
-#define S_VNTAGETHENABLE 8
-#define V_VNTAGETHENABLE(x) ((x) << S_VNTAGETHENABLE)
-#define F_VNTAGETHENABLE V_VNTAGETHENABLE(1U)
-
-#define S_IP_CCSM 7
-#define V_IP_CCSM(x) ((x) << S_IP_CCSM)
-#define F_IP_CCSM V_IP_CCSM(1U)
-
-#define S_CCHECKSUMCHECKUDP 6
-#define V_CCHECKSUMCHECKUDP(x) ((x) << S_CCHECKSUMCHECKUDP)
-#define F_CCHECKSUMCHECKUDP V_CCHECKSUMCHECKUDP(1U)
-
-#define S_TCP_CCSM 5
-#define V_TCP_CCSM(x) ((x) << S_TCP_CCSM)
-#define F_TCP_CCSM V_TCP_CCSM(1U)
-
-#define S_CDEMUX 3
-#define V_CDEMUX(x) ((x) << S_CDEMUX)
-#define F_CDEMUX V_CDEMUX(1U)
-
-#define S_ETHUPEN 2
-#define V_ETHUPEN(x) ((x) << S_ETHUPEN)
-#define F_ETHUPEN V_ETHUPEN(1U)
-
-#define S_CXOFFOVERRIDE 3
-#define V_CXOFFOVERRIDE(x) ((x) << S_CXOFFOVERRIDE)
-#define F_CXOFFOVERRIDE V_CXOFFOVERRIDE(1U)
-
-#define S_EGREDROPEN 1
-#define V_EGREDROPEN(x) ((x) << S_EGREDROPEN)
-#define F_EGREDROPEN V_EGREDROPEN(1U)
-
-#define S_CFASTDEMUXEN 0
-#define V_CFASTDEMUXEN(x) ((x) << S_CFASTDEMUXEN)
-#define F_CFASTDEMUXEN V_CFASTDEMUXEN(1U)
-
-#define A_TP_OUT_CONFIG 0x7d04
-
-#define S_PORTQFCEN 28
-#define M_PORTQFCEN 0xfU
-#define V_PORTQFCEN(x) ((x) << S_PORTQFCEN)
-#define G_PORTQFCEN(x) (((x) >> S_PORTQFCEN) & M_PORTQFCEN)
-
-#define S_EPKTDISTCHN3 23
-#define V_EPKTDISTCHN3(x) ((x) << S_EPKTDISTCHN3)
-#define F_EPKTDISTCHN3 V_EPKTDISTCHN3(1U)
-
-#define S_EPKTDISTCHN2 22
-#define V_EPKTDISTCHN2(x) ((x) << S_EPKTDISTCHN2)
-#define F_EPKTDISTCHN2 V_EPKTDISTCHN2(1U)
-
-#define S_EPKTDISTCHN1 21
-#define V_EPKTDISTCHN1(x) ((x) << S_EPKTDISTCHN1)
-#define F_EPKTDISTCHN1 V_EPKTDISTCHN1(1U)
-
-#define S_EPKTDISTCHN0 20
-#define V_EPKTDISTCHN0(x) ((x) << S_EPKTDISTCHN0)
-#define F_EPKTDISTCHN0 V_EPKTDISTCHN0(1U)
-
-#define S_TTLMODE 19
-#define V_TTLMODE(x) ((x) << S_TTLMODE)
-#define F_TTLMODE V_TTLMODE(1U)
-
-#define S_EQFCDMAC 18
-#define V_EQFCDMAC(x) ((x) << S_EQFCDMAC)
-#define F_EQFCDMAC V_EQFCDMAC(1U)
-
-#define S_ELPBKINCMPSSTAT 17
-#define V_ELPBKINCMPSSTAT(x) ((x) << S_ELPBKINCMPSSTAT)
-#define F_ELPBKINCMPSSTAT V_ELPBKINCMPSSTAT(1U)
-
-#define S_IPIDSPLITMODE 16
-#define V_IPIDSPLITMODE(x) ((x) << S_IPIDSPLITMODE)
-#define F_IPIDSPLITMODE V_IPIDSPLITMODE(1U)
-
-#define S_VLANEXTENABLEPORT3 15
-#define V_VLANEXTENABLEPORT3(x) ((x) << S_VLANEXTENABLEPORT3)
-#define F_VLANEXTENABLEPORT3 V_VLANEXTENABLEPORT3(1U)
-
-#define S_VLANEXTENABLEPORT2 14
-#define V_VLANEXTENABLEPORT2(x) ((x) << S_VLANEXTENABLEPORT2)
-#define F_VLANEXTENABLEPORT2 V_VLANEXTENABLEPORT2(1U)
-
-#define S_VLANEXTENABLEPORT1 13
-#define V_VLANEXTENABLEPORT1(x) ((x) << S_VLANEXTENABLEPORT1)
-#define F_VLANEXTENABLEPORT1 V_VLANEXTENABLEPORT1(1U)
-
-#define S_VLANEXTENABLEPORT0 12
-#define V_VLANEXTENABLEPORT0(x) ((x) << S_VLANEXTENABLEPORT0)
-#define F_VLANEXTENABLEPORT0 V_VLANEXTENABLEPORT0(1U)
-
-#define S_ECHECKSUMINSERTTCP 11
-#define V_ECHECKSUMINSERTTCP(x) ((x) << S_ECHECKSUMINSERTTCP)
-#define F_ECHECKSUMINSERTTCP V_ECHECKSUMINSERTTCP(1U)
-
-#define S_ECHECKSUMINSERTIP 10
-#define V_ECHECKSUMINSERTIP(x) ((x) << S_ECHECKSUMINSERTIP)
-#define F_ECHECKSUMINSERTIP V_ECHECKSUMINSERTIP(1U)
-
-#define S_ECPL 8
-#define V_ECPL(x) ((x) << S_ECPL)
-#define F_ECPL V_ECPL(1U)
-
-#define S_EPRIORITY 7
-#define V_EPRIORITY(x) ((x) << S_EPRIORITY)
-#define F_EPRIORITY V_EPRIORITY(1U)
-
-#define S_EETHERNET 6
-#define V_EETHERNET(x) ((x) << S_EETHERNET)
-#define F_EETHERNET V_EETHERNET(1U)
-
-#define S_CCHECKSUMINSERTTCP 5
-#define V_CCHECKSUMINSERTTCP(x) ((x) << S_CCHECKSUMINSERTTCP)
-#define F_CCHECKSUMINSERTTCP V_CCHECKSUMINSERTTCP(1U)
-
-#define S_CCHECKSUMINSERTIP 4
-#define V_CCHECKSUMINSERTIP(x) ((x) << S_CCHECKSUMINSERTIP)
-#define F_CCHECKSUMINSERTIP V_CCHECKSUMINSERTIP(1U)
-
-#define S_CCPL 2
-#define V_CCPL(x) ((x) << S_CCPL)
-#define F_CCPL V_CCPL(1U)
-
-#define S_CETHERNET 0
-#define V_CETHERNET(x) ((x) << S_CETHERNET)
-#define F_CETHERNET V_CETHERNET(1U)
-
-#define S_EVNTAGEN 9
-#define V_EVNTAGEN(x) ((x) << S_EVNTAGEN)
-#define F_EVNTAGEN V_EVNTAGEN(1U)
-
-#define S_CCPLACKMODE 13
-#define V_CCPLACKMODE(x) ((x) << S_CCPLACKMODE)
-#define F_CCPLACKMODE V_CCPLACKMODE(1U)
-
-#define S_RMWHINTENABLE 12
-#define V_RMWHINTENABLE(x) ((x) << S_RMWHINTENABLE)
-#define F_RMWHINTENABLE V_RMWHINTENABLE(1U)
-
-#define S_EV6FLWEN 8
-#define V_EV6FLWEN(x) ((x) << S_EV6FLWEN)
-#define F_EV6FLWEN V_EV6FLWEN(1U)
-
-#define S_EVLANPRIO 6
-#define V_EVLANPRIO(x) ((x) << S_EVLANPRIO)
-#define F_EVLANPRIO V_EVLANPRIO(1U)
-
-#define S_CRXPKTENC 3
-#define V_CRXPKTENC(x) ((x) << S_CRXPKTENC)
-#define F_CRXPKTENC V_CRXPKTENC(1U)
-
-#define S_CRXPKTXT 1
-#define V_CRXPKTXT(x) ((x) << S_CRXPKTXT)
-#define F_CRXPKTXT V_CRXPKTXT(1U)
-
-#define A_TP_GLOBAL_CONFIG 0x7d08
-
-#define S_SYNCOOKIEPARAMS 26
-#define M_SYNCOOKIEPARAMS 0x3fU
-#define V_SYNCOOKIEPARAMS(x) ((x) << S_SYNCOOKIEPARAMS)
-#define G_SYNCOOKIEPARAMS(x) (((x) >> S_SYNCOOKIEPARAMS) & M_SYNCOOKIEPARAMS)
-
-#define S_RXFLOWCONTROLDISABLE 25
-#define V_RXFLOWCONTROLDISABLE(x) ((x) << S_RXFLOWCONTROLDISABLE)
-#define F_RXFLOWCONTROLDISABLE V_RXFLOWCONTROLDISABLE(1U)
-
-#define S_TXPACINGENABLE 24
-#define V_TXPACINGENABLE(x) ((x) << S_TXPACINGENABLE)
-#define F_TXPACINGENABLE V_TXPACINGENABLE(1U)
-
-#define S_ATTACKFILTERENABLE 23
-#define V_ATTACKFILTERENABLE(x) ((x) << S_ATTACKFILTERENABLE)
-#define F_ATTACKFILTERENABLE V_ATTACKFILTERENABLE(1U)
-
-#define S_SYNCOOKIENOOPTIONS 22
-#define V_SYNCOOKIENOOPTIONS(x) ((x) << S_SYNCOOKIENOOPTIONS)
-#define F_SYNCOOKIENOOPTIONS V_SYNCOOKIENOOPTIONS(1U)
-
-#define S_PROTECTEDMODE 21
-#define V_PROTECTEDMODE(x) ((x) << S_PROTECTEDMODE)
-#define F_PROTECTEDMODE V_PROTECTEDMODE(1U)
-
-#define S_PINGDROP 20
-#define V_PINGDROP(x) ((x) << S_PINGDROP)
-#define F_PINGDROP V_PINGDROP(1U)
-
-#define S_FRAGMENTDROP 19
-#define V_FRAGMENTDROP(x) ((x) << S_FRAGMENTDROP)
-#define F_FRAGMENTDROP V_FRAGMENTDROP(1U)
-
-#define S_FIVETUPLELOOKUP 17
-#define M_FIVETUPLELOOKUP 0x3U
-#define V_FIVETUPLELOOKUP(x) ((x) << S_FIVETUPLELOOKUP)
-#define G_FIVETUPLELOOKUP(x) (((x) >> S_FIVETUPLELOOKUP) & M_FIVETUPLELOOKUP)
-
-#define S_OFDMPSSTATS 16
-#define V_OFDMPSSTATS(x) ((x) << S_OFDMPSSTATS)
-#define F_OFDMPSSTATS V_OFDMPSSTATS(1U)
-
-#define S_DONTFRAGMENT 15
-#define V_DONTFRAGMENT(x) ((x) << S_DONTFRAGMENT)
-#define F_DONTFRAGMENT V_DONTFRAGMENT(1U)
-
-#define S_IPIDENTSPLIT 14
-#define V_IPIDENTSPLIT(x) ((x) << S_IPIDENTSPLIT)
-#define F_IPIDENTSPLIT V_IPIDENTSPLIT(1U)
-
-#define S_IPCHECKSUMOFFLOAD 13
-#define V_IPCHECKSUMOFFLOAD(x) ((x) << S_IPCHECKSUMOFFLOAD)
-#define F_IPCHECKSUMOFFLOAD V_IPCHECKSUMOFFLOAD(1U)
-
-#define S_UDPCHECKSUMOFFLOAD 12
-#define V_UDPCHECKSUMOFFLOAD(x) ((x) << S_UDPCHECKSUMOFFLOAD)
-#define F_UDPCHECKSUMOFFLOAD V_UDPCHECKSUMOFFLOAD(1U)
-
-#define S_TCPCHECKSUMOFFLOAD 11
-#define V_TCPCHECKSUMOFFLOAD(x) ((x) << S_TCPCHECKSUMOFFLOAD)
-#define F_TCPCHECKSUMOFFLOAD V_TCPCHECKSUMOFFLOAD(1U)
-
-#define S_RSSLOOPBACKENABLE 10
-#define V_RSSLOOPBACKENABLE(x) ((x) << S_RSSLOOPBACKENABLE)
-#define F_RSSLOOPBACKENABLE V_RSSLOOPBACKENABLE(1U)
-
-#define S_TCAMSERVERUSE 8
-#define M_TCAMSERVERUSE 0x3U
-#define V_TCAMSERVERUSE(x) ((x) << S_TCAMSERVERUSE)
-#define G_TCAMSERVERUSE(x) (((x) >> S_TCAMSERVERUSE) & M_TCAMSERVERUSE)
-
-#define S_IPTTL 0
-#define M_IPTTL 0xffU
-#define V_IPTTL(x) ((x) << S_IPTTL)
-#define G_IPTTL(x) (((x) >> S_IPTTL) & M_IPTTL)
-
-#define S_RSSSYNSTEERENABLE 12
-#define V_RSSSYNSTEERENABLE(x) ((x) << S_RSSSYNSTEERENABLE)
-#define F_RSSSYNSTEERENABLE V_RSSSYNSTEERENABLE(1U)
-
-#define S_ISSFROMCPLENABLE 11
-#define V_ISSFROMCPLENABLE(x) ((x) << S_ISSFROMCPLENABLE)
-#define F_ISSFROMCPLENABLE V_ISSFROMCPLENABLE(1U)
-
-#define S_ACTIVEFILTERCOUNTS 22
-#define V_ACTIVEFILTERCOUNTS(x) ((x) << S_ACTIVEFILTERCOUNTS)
-#define F_ACTIVEFILTERCOUNTS V_ACTIVEFILTERCOUNTS(1U)
-
-#define A_TP_DB_CONFIG 0x7d0c
-
-#define S_DBMAXOPCNT 24
-#define M_DBMAXOPCNT 0xffU
-#define V_DBMAXOPCNT(x) ((x) << S_DBMAXOPCNT)
-#define G_DBMAXOPCNT(x) (((x) >> S_DBMAXOPCNT) & M_DBMAXOPCNT)
-
-#define S_CXMAXOPCNTDISABLE 23
-#define V_CXMAXOPCNTDISABLE(x) ((x) << S_CXMAXOPCNTDISABLE)
-#define F_CXMAXOPCNTDISABLE V_CXMAXOPCNTDISABLE(1U)
-
-#define S_CXMAXOPCNT 16
-#define M_CXMAXOPCNT 0x7fU
-#define V_CXMAXOPCNT(x) ((x) << S_CXMAXOPCNT)
-#define G_CXMAXOPCNT(x) (((x) >> S_CXMAXOPCNT) & M_CXMAXOPCNT)
-
-#define S_TXMAXOPCNTDISABLE 15
-#define V_TXMAXOPCNTDISABLE(x) ((x) << S_TXMAXOPCNTDISABLE)
-#define F_TXMAXOPCNTDISABLE V_TXMAXOPCNTDISABLE(1U)
-
-#define S_TXMAXOPCNT 8
-#define M_TXMAXOPCNT 0x7fU
-#define V_TXMAXOPCNT(x) ((x) << S_TXMAXOPCNT)
-#define G_TXMAXOPCNT(x) (((x) >> S_TXMAXOPCNT) & M_TXMAXOPCNT)
-
-#define S_RXMAXOPCNTDISABLE 7
-#define V_RXMAXOPCNTDISABLE(x) ((x) << S_RXMAXOPCNTDISABLE)
-#define F_RXMAXOPCNTDISABLE V_RXMAXOPCNTDISABLE(1U)
-
-#define S_RXMAXOPCNT 0
-#define M_RXMAXOPCNT 0x7fU
-#define V_RXMAXOPCNT(x) ((x) << S_RXMAXOPCNT)
-#define G_RXMAXOPCNT(x) (((x) >> S_RXMAXOPCNT) & M_RXMAXOPCNT)
-
-#define A_TP_CMM_TCB_BASE 0x7d10
-#define A_TP_CMM_MM_BASE 0x7d14
-#define A_TP_CMM_TIMER_BASE 0x7d18
-#define A_TP_CMM_MM_FLST_SIZE 0x7d1c
-
-#define S_RXPOOLSIZE 16
-#define M_RXPOOLSIZE 0xffffU
-#define V_RXPOOLSIZE(x) ((x) << S_RXPOOLSIZE)
-#define G_RXPOOLSIZE(x) (((x) >> S_RXPOOLSIZE) & M_RXPOOLSIZE)
-
-#define S_TXPOOLSIZE 0
-#define M_TXPOOLSIZE 0xffffU
-#define V_TXPOOLSIZE(x) ((x) << S_TXPOOLSIZE)
-#define G_TXPOOLSIZE(x) (((x) >> S_TXPOOLSIZE) & M_TXPOOLSIZE)
-
-#define A_TP_PMM_TX_BASE 0x7d20
-#define A_TP_PMM_DEFRAG_BASE 0x7d24
-#define A_TP_PMM_RX_BASE 0x7d28
-#define A_TP_PMM_RX_PAGE_SIZE 0x7d2c
-#define A_TP_PMM_RX_MAX_PAGE 0x7d30
-
-#define S_PMRXNUMCHN 31
-#define V_PMRXNUMCHN(x) ((x) << S_PMRXNUMCHN)
-#define F_PMRXNUMCHN V_PMRXNUMCHN(1U)
-
-#define S_PMRXMAXPAGE 0
-#define M_PMRXMAXPAGE 0x1fffffU
-#define V_PMRXMAXPAGE(x) ((x) << S_PMRXMAXPAGE)
-#define G_PMRXMAXPAGE(x) (((x) >> S_PMRXMAXPAGE) & M_PMRXMAXPAGE)
-
-#define A_TP_PMM_TX_PAGE_SIZE 0x7d34
-#define A_TP_PMM_TX_MAX_PAGE 0x7d38
-
-#define S_PMTXNUMCHN 30
-#define M_PMTXNUMCHN 0x3U
-#define V_PMTXNUMCHN(x) ((x) << S_PMTXNUMCHN)
-#define G_PMTXNUMCHN(x) (((x) >> S_PMTXNUMCHN) & M_PMTXNUMCHN)
-
-#define S_PMTXMAXPAGE 0
-#define M_PMTXMAXPAGE 0x1fffffU
-#define V_PMTXMAXPAGE(x) ((x) << S_PMTXMAXPAGE)
-#define G_PMTXMAXPAGE(x) (((x) >> S_PMTXMAXPAGE) & M_PMTXMAXPAGE)
-
-#define A_TP_TCP_OPTIONS 0x7d40
-
-#define S_MTUDEFAULT 16
-#define M_MTUDEFAULT 0xffffU
-#define V_MTUDEFAULT(x) ((x) << S_MTUDEFAULT)
-#define G_MTUDEFAULT(x) (((x) >> S_MTUDEFAULT) & M_MTUDEFAULT)
-
-#define S_MTUENABLE 10
-#define V_MTUENABLE(x) ((x) << S_MTUENABLE)
-#define F_MTUENABLE V_MTUENABLE(1U)
-
-#define S_SACKTX 9
-#define V_SACKTX(x) ((x) << S_SACKTX)
-#define F_SACKTX V_SACKTX(1U)
-
-#define S_SACKRX 8
-#define V_SACKRX(x) ((x) << S_SACKRX)
-#define F_SACKRX V_SACKRX(1U)
-
-#define S_SACKMODE 4
-#define M_SACKMODE 0x3U
-#define V_SACKMODE(x) ((x) << S_SACKMODE)
-#define G_SACKMODE(x) (((x) >> S_SACKMODE) & M_SACKMODE)
-
-#define S_WINDOWSCALEMODE 2
-#define M_WINDOWSCALEMODE 0x3U
-#define V_WINDOWSCALEMODE(x) ((x) << S_WINDOWSCALEMODE)
-#define G_WINDOWSCALEMODE(x) (((x) >> S_WINDOWSCALEMODE) & M_WINDOWSCALEMODE)
-
-#define S_TIMESTAMPSMODE 0
-#define M_TIMESTAMPSMODE 0x3U
-#define V_TIMESTAMPSMODE(x) ((x) << S_TIMESTAMPSMODE)
-#define G_TIMESTAMPSMODE(x) (((x) >> S_TIMESTAMPSMODE) & M_TIMESTAMPSMODE)
-
-#define A_TP_DACK_CONFIG 0x7d44
-
-#define S_AUTOSTATE3 30
-#define M_AUTOSTATE3 0x3U
-#define V_AUTOSTATE3(x) ((x) << S_AUTOSTATE3)
-#define G_AUTOSTATE3(x) (((x) >> S_AUTOSTATE3) & M_AUTOSTATE3)
-
-#define S_AUTOSTATE2 28
-#define M_AUTOSTATE2 0x3U
-#define V_AUTOSTATE2(x) ((x) << S_AUTOSTATE2)
-#define G_AUTOSTATE2(x) (((x) >> S_AUTOSTATE2) & M_AUTOSTATE2)
-
-#define S_AUTOSTATE1 26
-#define M_AUTOSTATE1 0x3U
-#define V_AUTOSTATE1(x) ((x) << S_AUTOSTATE1)
-#define G_AUTOSTATE1(x) (((x) >> S_AUTOSTATE1) & M_AUTOSTATE1)
-
-#define S_BYTETHRESHOLD 8
-#define M_BYTETHRESHOLD 0x3ffffU
-#define V_BYTETHRESHOLD(x) ((x) << S_BYTETHRESHOLD)
-#define G_BYTETHRESHOLD(x) (((x) >> S_BYTETHRESHOLD) & M_BYTETHRESHOLD)
-
-#define S_MSSTHRESHOLD 4
-#define M_MSSTHRESHOLD 0x7U
-#define V_MSSTHRESHOLD(x) ((x) << S_MSSTHRESHOLD)
-#define G_MSSTHRESHOLD(x) (((x) >> S_MSSTHRESHOLD) & M_MSSTHRESHOLD)
-
-#define S_AUTOCAREFUL 2
-#define V_AUTOCAREFUL(x) ((x) << S_AUTOCAREFUL)
-#define F_AUTOCAREFUL V_AUTOCAREFUL(1U)
-
-#define S_AUTOENABLE 1
-#define V_AUTOENABLE(x) ((x) << S_AUTOENABLE)
-#define F_AUTOENABLE V_AUTOENABLE(1U)
-
-#define S_MODE 0
-#define V_MODE(x) ((x) << S_MODE)
-#define F_MODE V_MODE(1U)
-
-#define A_TP_PC_CONFIG 0x7d48
-
-#define S_CMCACHEDISABLE 31
-#define V_CMCACHEDISABLE(x) ((x) << S_CMCACHEDISABLE)
-#define F_CMCACHEDISABLE V_CMCACHEDISABLE(1U)
-
-#define S_ENABLEOCSPIFULL 30
-#define V_ENABLEOCSPIFULL(x) ((x) << S_ENABLEOCSPIFULL)
-#define F_ENABLEOCSPIFULL V_ENABLEOCSPIFULL(1U)
-
-#define S_ENABLEFLMERRORDDP 29
-#define V_ENABLEFLMERRORDDP(x) ((x) << S_ENABLEFLMERRORDDP)
-#define F_ENABLEFLMERRORDDP V_ENABLEFLMERRORDDP(1U)
-
-#define S_LOCKTID 28
-#define V_LOCKTID(x) ((x) << S_LOCKTID)
-#define F_LOCKTID V_LOCKTID(1U)
-
-#define S_DISABLEINVPEND 27
-#define V_DISABLEINVPEND(x) ((x) << S_DISABLEINVPEND)
-#define F_DISABLEINVPEND V_DISABLEINVPEND(1U)
-
-#define S_ENABLEFILTERCOUNT 26
-#define V_ENABLEFILTERCOUNT(x) ((x) << S_ENABLEFILTERCOUNT)
-#define F_ENABLEFILTERCOUNT V_ENABLEFILTERCOUNT(1U)
-
-#define S_RDDPCONGEN 25
-#define V_RDDPCONGEN(x) ((x) << S_RDDPCONGEN)
-#define F_RDDPCONGEN V_RDDPCONGEN(1U)
-
-#define S_ENABLEONFLYPDU 24
-#define V_ENABLEONFLYPDU(x) ((x) << S_ENABLEONFLYPDU)
-#define F_ENABLEONFLYPDU V_ENABLEONFLYPDU(1U)
-
-#define S_ENABLEMINRCVWND 23
-#define V_ENABLEMINRCVWND(x) ((x) << S_ENABLEMINRCVWND)
-#define F_ENABLEMINRCVWND V_ENABLEMINRCVWND(1U)
-
-#define S_ENABLEMAXRCVWND 22
-#define V_ENABLEMAXRCVWND(x) ((x) << S_ENABLEMAXRCVWND)
-#define F_ENABLEMAXRCVWND V_ENABLEMAXRCVWND(1U)
-
-#define S_TXDATAACKRATEENABLE 21
-#define V_TXDATAACKRATEENABLE(x) ((x) << S_TXDATAACKRATEENABLE)
-#define F_TXDATAACKRATEENABLE V_TXDATAACKRATEENABLE(1U)
-
-#define S_TXDEFERENABLE 20
-#define V_TXDEFERENABLE(x) ((x) << S_TXDEFERENABLE)
-#define F_TXDEFERENABLE V_TXDEFERENABLE(1U)
-
-#define S_RXCONGESTIONMODE 19
-#define V_RXCONGESTIONMODE(x) ((x) << S_RXCONGESTIONMODE)
-#define F_RXCONGESTIONMODE V_RXCONGESTIONMODE(1U)
-
-#define S_HEARBEATONCEDACK 18
-#define V_HEARBEATONCEDACK(x) ((x) << S_HEARBEATONCEDACK)
-#define F_HEARBEATONCEDACK V_HEARBEATONCEDACK(1U)
-
-#define S_HEARBEATONCEHEAP 17
-#define V_HEARBEATONCEHEAP(x) ((x) << S_HEARBEATONCEHEAP)
-#define F_HEARBEATONCEHEAP V_HEARBEATONCEHEAP(1U)
-
-#define S_HEARBEATDACK 16
-#define V_HEARBEATDACK(x) ((x) << S_HEARBEATDACK)
-#define F_HEARBEATDACK V_HEARBEATDACK(1U)
-
-#define S_TXCONGESTIONMODE 15
-#define V_TXCONGESTIONMODE(x) ((x) << S_TXCONGESTIONMODE)
-#define F_TXCONGESTIONMODE V_TXCONGESTIONMODE(1U)
-
-#define S_ACCEPTLATESTRCVADV 14
-#define V_ACCEPTLATESTRCVADV(x) ((x) << S_ACCEPTLATESTRCVADV)
-#define F_ACCEPTLATESTRCVADV V_ACCEPTLATESTRCVADV(1U)
-
-#define S_DISABLESYNDATA 13
-#define V_DISABLESYNDATA(x) ((x) << S_DISABLESYNDATA)
-#define F_DISABLESYNDATA V_DISABLESYNDATA(1U)
-
-#define S_DISABLEWINDOWPSH 12
-#define V_DISABLEWINDOWPSH(x) ((x) << S_DISABLEWINDOWPSH)
-#define F_DISABLEWINDOWPSH V_DISABLEWINDOWPSH(1U)
-
-#define S_DISABLEFINOLDDATA 11
-#define V_DISABLEFINOLDDATA(x) ((x) << S_DISABLEFINOLDDATA)
-#define F_DISABLEFINOLDDATA V_DISABLEFINOLDDATA(1U)
-
-#define S_ENABLEFLMERROR 10
-#define V_ENABLEFLMERROR(x) ((x) << S_ENABLEFLMERROR)
-#define F_ENABLEFLMERROR V_ENABLEFLMERROR(1U)
-
-#define S_ENABLEOPTMTU 9
-#define V_ENABLEOPTMTU(x) ((x) << S_ENABLEOPTMTU)
-#define F_ENABLEOPTMTU V_ENABLEOPTMTU(1U)
-
-#define S_FILTERPEERFIN 8
-#define V_FILTERPEERFIN(x) ((x) << S_FILTERPEERFIN)
-#define F_FILTERPEERFIN V_FILTERPEERFIN(1U)
-
-#define S_ENABLEFEEDBACKSEND 7
-#define V_ENABLEFEEDBACKSEND(x) ((x) << S_ENABLEFEEDBACKSEND)
-#define F_ENABLEFEEDBACKSEND V_ENABLEFEEDBACKSEND(1U)
-
-#define S_ENABLERDMAERROR 6
-#define V_ENABLERDMAERROR(x) ((x) << S_ENABLERDMAERROR)
-#define F_ENABLERDMAERROR V_ENABLERDMAERROR(1U)
-
-#define S_ENABLEDDPFLOWCONTROL 5
-#define V_ENABLEDDPFLOWCONTROL(x) ((x) << S_ENABLEDDPFLOWCONTROL)
-#define F_ENABLEDDPFLOWCONTROL V_ENABLEDDPFLOWCONTROL(1U)
-
-#define S_DISABLEHELDFIN 4
-#define V_DISABLEHELDFIN(x) ((x) << S_DISABLEHELDFIN)
-#define F_DISABLEHELDFIN V_DISABLEHELDFIN(1U)
-
-#define S_ENABLEOFDOVLAN 3
-#define V_ENABLEOFDOVLAN(x) ((x) << S_ENABLEOFDOVLAN)
-#define F_ENABLEOFDOVLAN V_ENABLEOFDOVLAN(1U)
-
-#define S_DISABLETIMEWAIT 2
-#define V_DISABLETIMEWAIT(x) ((x) << S_DISABLETIMEWAIT)
-#define F_DISABLETIMEWAIT V_DISABLETIMEWAIT(1U)
-
-#define S_ENABLEVLANCHECK 1
-#define V_ENABLEVLANCHECK(x) ((x) << S_ENABLEVLANCHECK)
-#define F_ENABLEVLANCHECK V_ENABLEVLANCHECK(1U)
-
-#define S_TXDATAACKPAGEENABLE 0
-#define V_TXDATAACKPAGEENABLE(x) ((x) << S_TXDATAACKPAGEENABLE)
-#define F_TXDATAACKPAGEENABLE V_TXDATAACKPAGEENABLE(1U)
-
-#define S_ENABLEFILTERNAT 5
-#define V_ENABLEFILTERNAT(x) ((x) << S_ENABLEFILTERNAT)
-#define F_ENABLEFILTERNAT V_ENABLEFILTERNAT(1U)
-
-#define S_ENABLEFINCHECK 31
-#define V_ENABLEFINCHECK(x) ((x) << S_ENABLEFINCHECK)
-#define F_ENABLEFINCHECK V_ENABLEFINCHECK(1U)
-
-#define S_ENABLEMIBVFPLD 21
-#define V_ENABLEMIBVFPLD(x) ((x) << S_ENABLEMIBVFPLD)
-#define F_ENABLEMIBVFPLD V_ENABLEMIBVFPLD(1U)
-
-#define S_DISABLESEPPSHFLAG 4
-#define V_DISABLESEPPSHFLAG(x) ((x) << S_DISABLESEPPSHFLAG)
-#define F_DISABLESEPPSHFLAG V_DISABLESEPPSHFLAG(1U)
-
-#define A_TP_PC_CONFIG2 0x7d4c
-
-#define S_ENABLEMTUVFMODE 31
-#define V_ENABLEMTUVFMODE(x) ((x) << S_ENABLEMTUVFMODE)
-#define F_ENABLEMTUVFMODE V_ENABLEMTUVFMODE(1U)
-
-#define S_ENABLEMIBVFMODE 30
-#define V_ENABLEMIBVFMODE(x) ((x) << S_ENABLEMIBVFMODE)
-#define F_ENABLEMIBVFMODE V_ENABLEMIBVFMODE(1U)
-
-#define S_DISABLELBKCHECK 29
-#define V_DISABLELBKCHECK(x) ((x) << S_DISABLELBKCHECK)
-#define F_DISABLELBKCHECK V_DISABLELBKCHECK(1U)
-
-#define S_ENABLEURGDDPOFF 28
-#define V_ENABLEURGDDPOFF(x) ((x) << S_ENABLEURGDDPOFF)
-#define F_ENABLEURGDDPOFF V_ENABLEURGDDPOFF(1U)
-
-#define S_ENABLEFILTERLPBK 27
-#define V_ENABLEFILTERLPBK(x) ((x) << S_ENABLEFILTERLPBK)
-#define F_ENABLEFILTERLPBK V_ENABLEFILTERLPBK(1U)
-
-#define S_DISABLETBLMMGR 26
-#define V_DISABLETBLMMGR(x) ((x) << S_DISABLETBLMMGR)
-#define F_DISABLETBLMMGR V_DISABLETBLMMGR(1U)
-
-#define S_CNGRECSNDNXT 25
-#define V_CNGRECSNDNXT(x) ((x) << S_CNGRECSNDNXT)
-#define F_CNGRECSNDNXT V_CNGRECSNDNXT(1U)
-
-#define S_ENABLELBKCHN 24
-#define V_ENABLELBKCHN(x) ((x) << S_ENABLELBKCHN)
-#define F_ENABLELBKCHN V_ENABLELBKCHN(1U)
-
-#define S_ENABLELROECN 23
-#define V_ENABLELROECN(x) ((x) << S_ENABLELROECN)
-#define F_ENABLELROECN V_ENABLELROECN(1U)
-
-#define S_ENABLEPCMDCHECK 22
-#define V_ENABLEPCMDCHECK(x) ((x) << S_ENABLEPCMDCHECK)
-#define F_ENABLEPCMDCHECK V_ENABLEPCMDCHECK(1U)
-
-#define S_ENABLEELBKAFULL 21
-#define V_ENABLEELBKAFULL(x) ((x) << S_ENABLEELBKAFULL)
-#define F_ENABLEELBKAFULL V_ENABLEELBKAFULL(1U)
-
-#define S_ENABLECLBKAFULL 20
-#define V_ENABLECLBKAFULL(x) ((x) << S_ENABLECLBKAFULL)
-#define F_ENABLECLBKAFULL V_ENABLECLBKAFULL(1U)
-
-#define S_ENABLEOESPIFULL 19
-#define V_ENABLEOESPIFULL(x) ((x) << S_ENABLEOESPIFULL)
-#define F_ENABLEOESPIFULL V_ENABLEOESPIFULL(1U)
-
-#define S_DISABLEHITCHECK 18
-#define V_DISABLEHITCHECK(x) ((x) << S_DISABLEHITCHECK)
-#define F_DISABLEHITCHECK V_DISABLEHITCHECK(1U)
-
-#define S_ENABLERSSERRCHECK 17
-#define V_ENABLERSSERRCHECK(x) ((x) << S_ENABLERSSERRCHECK)
-#define F_ENABLERSSERRCHECK V_ENABLERSSERRCHECK(1U)
-
-#define S_DISABLENEWPSHFLAG 16
-#define V_DISABLENEWPSHFLAG(x) ((x) << S_DISABLENEWPSHFLAG)
-#define F_DISABLENEWPSHFLAG V_DISABLENEWPSHFLAG(1U)
-
-#define S_ENABLERDDPRCVADVCLR 15
-#define V_ENABLERDDPRCVADVCLR(x) ((x) << S_ENABLERDDPRCVADVCLR)
-#define F_ENABLERDDPRCVADVCLR V_ENABLERDDPRCVADVCLR(1U)
-
-#define S_ENABLETXDATAARPMISS 14
-#define V_ENABLETXDATAARPMISS(x) ((x) << S_ENABLETXDATAARPMISS)
-#define F_ENABLETXDATAARPMISS V_ENABLETXDATAARPMISS(1U)
-
-#define S_ENABLEARPMISS 13
-#define V_ENABLEARPMISS(x) ((x) << S_ENABLEARPMISS)
-#define F_ENABLEARPMISS V_ENABLEARPMISS(1U)
-
-#define S_ENABLERSTPAWS 12
-#define V_ENABLERSTPAWS(x) ((x) << S_ENABLERSTPAWS)
-#define F_ENABLERSTPAWS V_ENABLERSTPAWS(1U)
-
-#define S_ENABLEIPV6RSS 11
-#define V_ENABLEIPV6RSS(x) ((x) << S_ENABLEIPV6RSS)
-#define F_ENABLEIPV6RSS V_ENABLEIPV6RSS(1U)
-
-#define S_ENABLENONOFDHYBRSS 10
-#define V_ENABLENONOFDHYBRSS(x) ((x) << S_ENABLENONOFDHYBRSS)
-#define F_ENABLENONOFDHYBRSS V_ENABLENONOFDHYBRSS(1U)
-
-#define S_ENABLEUDP4TUPRSS 9
-#define V_ENABLEUDP4TUPRSS(x) ((x) << S_ENABLEUDP4TUPRSS)
-#define F_ENABLEUDP4TUPRSS V_ENABLEUDP4TUPRSS(1U)
-
-#define S_ENABLERXPKTTMSTPRSS 8
-#define V_ENABLERXPKTTMSTPRSS(x) ((x) << S_ENABLERXPKTTMSTPRSS)
-#define F_ENABLERXPKTTMSTPRSS V_ENABLERXPKTTMSTPRSS(1U)
-
-#define S_ENABLEEPCMDAFULL 7
-#define V_ENABLEEPCMDAFULL(x) ((x) << S_ENABLEEPCMDAFULL)
-#define F_ENABLEEPCMDAFULL V_ENABLEEPCMDAFULL(1U)
-
-#define S_ENABLECPCMDAFULL 6
-#define V_ENABLECPCMDAFULL(x) ((x) << S_ENABLECPCMDAFULL)
-#define F_ENABLECPCMDAFULL V_ENABLECPCMDAFULL(1U)
-
-#define S_ENABLEEHDRAFULL 5
-#define V_ENABLEEHDRAFULL(x) ((x) << S_ENABLEEHDRAFULL)
-#define F_ENABLEEHDRAFULL V_ENABLEEHDRAFULL(1U)
-
-#define S_ENABLECHDRAFULL 4
-#define V_ENABLECHDRAFULL(x) ((x) << S_ENABLECHDRAFULL)
-#define F_ENABLECHDRAFULL V_ENABLECHDRAFULL(1U)
-
-#define S_ENABLEEMACAFULL 3
-#define V_ENABLEEMACAFULL(x) ((x) << S_ENABLEEMACAFULL)
-#define F_ENABLEEMACAFULL V_ENABLEEMACAFULL(1U)
-
-#define S_ENABLENONOFDTIDRSS 2
-#define V_ENABLENONOFDTIDRSS(x) ((x) << S_ENABLENONOFDTIDRSS)
-#define F_ENABLENONOFDTIDRSS V_ENABLENONOFDTIDRSS(1U)
-
-#define S_ENABLENONOFDTCBRSS 1
-#define V_ENABLENONOFDTCBRSS(x) ((x) << S_ENABLENONOFDTCBRSS)
-#define F_ENABLENONOFDTCBRSS V_ENABLENONOFDTCBRSS(1U)
-
-#define S_ENABLETNLOFDCLOSED 0
-#define V_ENABLETNLOFDCLOSED(x) ((x) << S_ENABLETNLOFDCLOSED)
-#define F_ENABLETNLOFDCLOSED V_ENABLETNLOFDCLOSED(1U)
-
-#define S_ENABLEFINDDPOFF 14
-#define V_ENABLEFINDDPOFF(x) ((x) << S_ENABLEFINDDPOFF)
-#define F_ENABLEFINDDPOFF V_ENABLEFINDDPOFF(1U)
-
-#define A_TP_TCP_BACKOFF_REG0 0x7d50
-
-#define S_TIMERBACKOFFINDEX3 24
-#define M_TIMERBACKOFFINDEX3 0xffU
-#define V_TIMERBACKOFFINDEX3(x) ((x) << S_TIMERBACKOFFINDEX3)
-#define G_TIMERBACKOFFINDEX3(x) (((x) >> S_TIMERBACKOFFINDEX3) & M_TIMERBACKOFFINDEX3)
-
-#define S_TIMERBACKOFFINDEX2 16
-#define M_TIMERBACKOFFINDEX2 0xffU
-#define V_TIMERBACKOFFINDEX2(x) ((x) << S_TIMERBACKOFFINDEX2)
-#define G_TIMERBACKOFFINDEX2(x) (((x) >> S_TIMERBACKOFFINDEX2) & M_TIMERBACKOFFINDEX2)
-
-#define S_TIMERBACKOFFINDEX1 8
-#define M_TIMERBACKOFFINDEX1 0xffU
-#define V_TIMERBACKOFFINDEX1(x) ((x) << S_TIMERBACKOFFINDEX1)
-#define G_TIMERBACKOFFINDEX1(x) (((x) >> S_TIMERBACKOFFINDEX1) & M_TIMERBACKOFFINDEX1)
-
-#define S_TIMERBACKOFFINDEX0 0
-#define M_TIMERBACKOFFINDEX0 0xffU
-#define V_TIMERBACKOFFINDEX0(x) ((x) << S_TIMERBACKOFFINDEX0)
-#define G_TIMERBACKOFFINDEX0(x) (((x) >> S_TIMERBACKOFFINDEX0) & M_TIMERBACKOFFINDEX0)
-
-#define A_TP_TCP_BACKOFF_REG1 0x7d54
-
-#define S_TIMERBACKOFFINDEX7 24
-#define M_TIMERBACKOFFINDEX7 0xffU
-#define V_TIMERBACKOFFINDEX7(x) ((x) << S_TIMERBACKOFFINDEX7)
-#define G_TIMERBACKOFFINDEX7(x) (((x) >> S_TIMERBACKOFFINDEX7) & M_TIMERBACKOFFINDEX7)
-
-#define S_TIMERBACKOFFINDEX6 16
-#define M_TIMERBACKOFFINDEX6 0xffU
-#define V_TIMERBACKOFFINDEX6(x) ((x) << S_TIMERBACKOFFINDEX6)
-#define G_TIMERBACKOFFINDEX6(x) (((x) >> S_TIMERBACKOFFINDEX6) & M_TIMERBACKOFFINDEX6)
-
-#define S_TIMERBACKOFFINDEX5 8
-#define M_TIMERBACKOFFINDEX5 0xffU
-#define V_TIMERBACKOFFINDEX5(x) ((x) << S_TIMERBACKOFFINDEX5)
-#define G_TIMERBACKOFFINDEX5(x) (((x) >> S_TIMERBACKOFFINDEX5) & M_TIMERBACKOFFINDEX5)
-
-#define S_TIMERBACKOFFINDEX4 0
-#define M_TIMERBACKOFFINDEX4 0xffU
-#define V_TIMERBACKOFFINDEX4(x) ((x) << S_TIMERBACKOFFINDEX4)
-#define G_TIMERBACKOFFINDEX4(x) (((x) >> S_TIMERBACKOFFINDEX4) & M_TIMERBACKOFFINDEX4)
-
-#define A_TP_TCP_BACKOFF_REG2 0x7d58
-
-#define S_TIMERBACKOFFINDEX11 24
-#define M_TIMERBACKOFFINDEX11 0xffU
-#define V_TIMERBACKOFFINDEX11(x) ((x) << S_TIMERBACKOFFINDEX11)
-#define G_TIMERBACKOFFINDEX11(x) (((x) >> S_TIMERBACKOFFINDEX11) & M_TIMERBACKOFFINDEX11)
-
-#define S_TIMERBACKOFFINDEX10 16
-#define M_TIMERBACKOFFINDEX10 0xffU
-#define V_TIMERBACKOFFINDEX10(x) ((x) << S_TIMERBACKOFFINDEX10)
-#define G_TIMERBACKOFFINDEX10(x) (((x) >> S_TIMERBACKOFFINDEX10) & M_TIMERBACKOFFINDEX10)
-
-#define S_TIMERBACKOFFINDEX9 8
-#define M_TIMERBACKOFFINDEX9 0xffU
-#define V_TIMERBACKOFFINDEX9(x) ((x) << S_TIMERBACKOFFINDEX9)
-#define G_TIMERBACKOFFINDEX9(x) (((x) >> S_TIMERBACKOFFINDEX9) & M_TIMERBACKOFFINDEX9)
-
-#define S_TIMERBACKOFFINDEX8 0
-#define M_TIMERBACKOFFINDEX8 0xffU
-#define V_TIMERBACKOFFINDEX8(x) ((x) << S_TIMERBACKOFFINDEX8)
-#define G_TIMERBACKOFFINDEX8(x) (((x) >> S_TIMERBACKOFFINDEX8) & M_TIMERBACKOFFINDEX8)
-
-#define A_TP_TCP_BACKOFF_REG3 0x7d5c
-
-#define S_TIMERBACKOFFINDEX15 24
-#define M_TIMERBACKOFFINDEX15 0xffU
-#define V_TIMERBACKOFFINDEX15(x) ((x) << S_TIMERBACKOFFINDEX15)
-#define G_TIMERBACKOFFINDEX15(x) (((x) >> S_TIMERBACKOFFINDEX15) & M_TIMERBACKOFFINDEX15)
-
-#define S_TIMERBACKOFFINDEX14 16
-#define M_TIMERBACKOFFINDEX14 0xffU
-#define V_TIMERBACKOFFINDEX14(x) ((x) << S_TIMERBACKOFFINDEX14)
-#define G_TIMERBACKOFFINDEX14(x) (((x) >> S_TIMERBACKOFFINDEX14) & M_TIMERBACKOFFINDEX14)
-
-#define S_TIMERBACKOFFINDEX13 8
-#define M_TIMERBACKOFFINDEX13 0xffU
-#define V_TIMERBACKOFFINDEX13(x) ((x) << S_TIMERBACKOFFINDEX13)
-#define G_TIMERBACKOFFINDEX13(x) (((x) >> S_TIMERBACKOFFINDEX13) & M_TIMERBACKOFFINDEX13)
-
-#define S_TIMERBACKOFFINDEX12 0
-#define M_TIMERBACKOFFINDEX12 0xffU
-#define V_TIMERBACKOFFINDEX12(x) ((x) << S_TIMERBACKOFFINDEX12)
-#define G_TIMERBACKOFFINDEX12(x) (((x) >> S_TIMERBACKOFFINDEX12) & M_TIMERBACKOFFINDEX12)
-
-#define A_TP_PARA_REG0 0x7d60
-
-#define S_INITCWNDIDLE 27
-#define V_INITCWNDIDLE(x) ((x) << S_INITCWNDIDLE)
-#define F_INITCWNDIDLE V_INITCWNDIDLE(1U)
-
-#define S_INITCWND 24
-#define M_INITCWND 0x7U
-#define V_INITCWND(x) ((x) << S_INITCWND)
-#define G_INITCWND(x) (((x) >> S_INITCWND) & M_INITCWND)
-
-#define S_DUPACKTHRESH 20
-#define M_DUPACKTHRESH 0xfU
-#define V_DUPACKTHRESH(x) ((x) << S_DUPACKTHRESH)
-#define G_DUPACKTHRESH(x) (((x) >> S_DUPACKTHRESH) & M_DUPACKTHRESH)
-
-#define S_CPLERRENABLE 12
-#define V_CPLERRENABLE(x) ((x) << S_CPLERRENABLE)
-#define F_CPLERRENABLE V_CPLERRENABLE(1U)
-
-#define S_FASTTNLCNT 11
-#define V_FASTTNLCNT(x) ((x) << S_FASTTNLCNT)
-#define F_FASTTNLCNT V_FASTTNLCNT(1U)
-
-#define S_FASTTBLCNT 10
-#define V_FASTTBLCNT(x) ((x) << S_FASTTBLCNT)
-#define F_FASTTBLCNT V_FASTTBLCNT(1U)
-
-#define S_TPTCAMKEY 9
-#define V_TPTCAMKEY(x) ((x) << S_TPTCAMKEY)
-#define F_TPTCAMKEY V_TPTCAMKEY(1U)
-
-#define S_SWSMODE 8
-#define V_SWSMODE(x) ((x) << S_SWSMODE)
-#define F_SWSMODE V_SWSMODE(1U)
-
-#define S_TSMPMODE 6
-#define M_TSMPMODE 0x3U
-#define V_TSMPMODE(x) ((x) << S_TSMPMODE)
-#define G_TSMPMODE(x) (((x) >> S_TSMPMODE) & M_TSMPMODE)
-
-#define S_BYTECOUNTLIMIT 4
-#define M_BYTECOUNTLIMIT 0x3U
-#define V_BYTECOUNTLIMIT(x) ((x) << S_BYTECOUNTLIMIT)
-#define G_BYTECOUNTLIMIT(x) (((x) >> S_BYTECOUNTLIMIT) & M_BYTECOUNTLIMIT)
-
-#define S_SWSSHOVE 3
-#define V_SWSSHOVE(x) ((x) << S_SWSSHOVE)
-#define F_SWSSHOVE V_SWSSHOVE(1U)
-
-#define S_TBLTIMER 2
-#define V_TBLTIMER(x) ((x) << S_TBLTIMER)
-#define F_TBLTIMER V_TBLTIMER(1U)
-
-#define S_RXTPACE 1
-#define V_RXTPACE(x) ((x) << S_RXTPACE)
-#define F_RXTPACE V_RXTPACE(1U)
-
-#define S_SWSTIMER 0
-#define V_SWSTIMER(x) ((x) << S_SWSTIMER)
-#define F_SWSTIMER V_SWSTIMER(1U)
-
-#define S_LIMTXTHRESH 28
-#define M_LIMTXTHRESH 0xfU
-#define V_LIMTXTHRESH(x) ((x) << S_LIMTXTHRESH)
-#define G_LIMTXTHRESH(x) (((x) >> S_LIMTXTHRESH) & M_LIMTXTHRESH)
-
-#define S_CHNERRENABLE 14
-#define V_CHNERRENABLE(x) ((x) << S_CHNERRENABLE)
-#define F_CHNERRENABLE V_CHNERRENABLE(1U)
-
-#define S_SETTIMEENABLE 13
-#define V_SETTIMEENABLE(x) ((x) << S_SETTIMEENABLE)
-#define F_SETTIMEENABLE V_SETTIMEENABLE(1U)
-
-#define S_ECNCNGFIFO 19
-#define V_ECNCNGFIFO(x) ((x) << S_ECNCNGFIFO)
-#define F_ECNCNGFIFO V_ECNCNGFIFO(1U)
-
-#define S_ECNSYNACK 18
-#define V_ECNSYNACK(x) ((x) << S_ECNSYNACK)
-#define F_ECNSYNACK V_ECNSYNACK(1U)
-
-#define S_ECNTHRESH 16
-#define M_ECNTHRESH 0x3U
-#define V_ECNTHRESH(x) ((x) << S_ECNTHRESH)
-#define G_ECNTHRESH(x) (((x) >> S_ECNTHRESH) & M_ECNTHRESH)
-
-#define S_ECNMODE 15
-#define V_ECNMODE(x) ((x) << S_ECNMODE)
-#define F_ECNMODE V_ECNMODE(1U)
-
-#define S_ECNMODECWR 14
-#define V_ECNMODECWR(x) ((x) << S_ECNMODECWR)
-#define F_ECNMODECWR V_ECNMODECWR(1U)
-
-#define S_FORCESHOVE 10
-#define V_FORCESHOVE(x) ((x) << S_FORCESHOVE)
-#define F_FORCESHOVE V_FORCESHOVE(1U)
-
-#define A_TP_PARA_REG1 0x7d64
-
-#define S_INITRWND 16
-#define M_INITRWND 0xffffU
-#define V_INITRWND(x) ((x) << S_INITRWND)
-#define G_INITRWND(x) (((x) >> S_INITRWND) & M_INITRWND)
-
-#define S_INITIALSSTHRESH 0
-#define M_INITIALSSTHRESH 0xffffU
-#define V_INITIALSSTHRESH(x) ((x) << S_INITIALSSTHRESH)
-#define G_INITIALSSTHRESH(x) (((x) >> S_INITIALSSTHRESH) & M_INITIALSSTHRESH)
-
-#define A_TP_PARA_REG2 0x7d68
-
-#define S_MAXRXDATA 16
-#define M_MAXRXDATA 0xffffU
-#define V_MAXRXDATA(x) ((x) << S_MAXRXDATA)
-#define G_MAXRXDATA(x) (((x) >> S_MAXRXDATA) & M_MAXRXDATA)
-
-#define S_RXCOALESCESIZE 0
-#define M_RXCOALESCESIZE 0xffffU
-#define V_RXCOALESCESIZE(x) ((x) << S_RXCOALESCESIZE)
-#define G_RXCOALESCESIZE(x) (((x) >> S_RXCOALESCESIZE) & M_RXCOALESCESIZE)
-
-#define A_TP_PARA_REG3 0x7d6c
-
-#define S_ENABLETNLCNGLPBK 31
-#define V_ENABLETNLCNGLPBK(x) ((x) << S_ENABLETNLCNGLPBK)
-#define F_ENABLETNLCNGLPBK V_ENABLETNLCNGLPBK(1U)
-
-#define S_ENABLETNLCNGFIFO 30
-#define V_ENABLETNLCNGFIFO(x) ((x) << S_ENABLETNLCNGFIFO)
-#define F_ENABLETNLCNGFIFO V_ENABLETNLCNGFIFO(1U)
-
-#define S_ENABLETNLCNGHDR 29
-#define V_ENABLETNLCNGHDR(x) ((x) << S_ENABLETNLCNGHDR)
-#define F_ENABLETNLCNGHDR V_ENABLETNLCNGHDR(1U)
-
-#define S_ENABLETNLCNGSGE 28
-#define V_ENABLETNLCNGSGE(x) ((x) << S_ENABLETNLCNGSGE)
-#define F_ENABLETNLCNGSGE V_ENABLETNLCNGSGE(1U)
-
-#define S_RXMACCHECK 27
-#define V_RXMACCHECK(x) ((x) << S_RXMACCHECK)
-#define F_RXMACCHECK V_RXMACCHECK(1U)
-
-#define S_RXSYNFILTER 26
-#define V_RXSYNFILTER(x) ((x) << S_RXSYNFILTER)
-#define F_RXSYNFILTER V_RXSYNFILTER(1U)
-
-#define S_CNGCTRLECN 25
-#define V_CNGCTRLECN(x) ((x) << S_CNGCTRLECN)
-#define F_CNGCTRLECN V_CNGCTRLECN(1U)
-
-#define S_RXDDPOFFINIT 24
-#define V_RXDDPOFFINIT(x) ((x) << S_RXDDPOFFINIT)
-#define F_RXDDPOFFINIT V_RXDDPOFFINIT(1U)
-
-#define S_TUNNELCNGDROP3 23
-#define V_TUNNELCNGDROP3(x) ((x) << S_TUNNELCNGDROP3)
-#define F_TUNNELCNGDROP3 V_TUNNELCNGDROP3(1U)
-
-#define S_TUNNELCNGDROP2 22
-#define V_TUNNELCNGDROP2(x) ((x) << S_TUNNELCNGDROP2)
-#define F_TUNNELCNGDROP2 V_TUNNELCNGDROP2(1U)
-
-#define S_TUNNELCNGDROP1 21
-#define V_TUNNELCNGDROP1(x) ((x) << S_TUNNELCNGDROP1)
-#define F_TUNNELCNGDROP1 V_TUNNELCNGDROP1(1U)
-
-#define S_TUNNELCNGDROP0 20
-#define V_TUNNELCNGDROP0(x) ((x) << S_TUNNELCNGDROP0)
-#define F_TUNNELCNGDROP0 V_TUNNELCNGDROP0(1U)
-
-#define S_TXDATAACKIDX 16
-#define M_TXDATAACKIDX 0xfU
-#define V_TXDATAACKIDX(x) ((x) << S_TXDATAACKIDX)
-#define G_TXDATAACKIDX(x) (((x) >> S_TXDATAACKIDX) & M_TXDATAACKIDX)
-
-#define S_RXFRAGENABLE 12
-#define M_RXFRAGENABLE 0x7U
-#define V_RXFRAGENABLE(x) ((x) << S_RXFRAGENABLE)
-#define G_RXFRAGENABLE(x) (((x) >> S_RXFRAGENABLE) & M_RXFRAGENABLE)
-
-#define S_TXPACEFIXEDSTRICT 11
-#define V_TXPACEFIXEDSTRICT(x) ((x) << S_TXPACEFIXEDSTRICT)
-#define F_TXPACEFIXEDSTRICT V_TXPACEFIXEDSTRICT(1U)
-
-#define S_TXPACEAUTOSTRICT 10
-#define V_TXPACEAUTOSTRICT(x) ((x) << S_TXPACEAUTOSTRICT)
-#define F_TXPACEAUTOSTRICT V_TXPACEAUTOSTRICT(1U)
-
-#define S_TXPACEFIXED 9
-#define V_TXPACEFIXED(x) ((x) << S_TXPACEFIXED)
-#define F_TXPACEFIXED V_TXPACEFIXED(1U)
-
-#define S_TXPACEAUTO 8
-#define V_TXPACEAUTO(x) ((x) << S_TXPACEAUTO)
-#define F_TXPACEAUTO V_TXPACEAUTO(1U)
-
-#define S_RXCHNTUNNEL 7
-#define V_RXCHNTUNNEL(x) ((x) << S_RXCHNTUNNEL)
-#define F_RXCHNTUNNEL V_RXCHNTUNNEL(1U)
-
-#define S_RXURGTUNNEL 6
-#define V_RXURGTUNNEL(x) ((x) << S_RXURGTUNNEL)
-#define F_RXURGTUNNEL V_RXURGTUNNEL(1U)
-
-#define S_RXURGMODE 5
-#define V_RXURGMODE(x) ((x) << S_RXURGMODE)
-#define F_RXURGMODE V_RXURGMODE(1U)
-
-#define S_TXURGMODE 4
-#define V_TXURGMODE(x) ((x) << S_TXURGMODE)
-#define F_TXURGMODE V_TXURGMODE(1U)
-
-#define S_CNGCTRLMODE 2
-#define M_CNGCTRLMODE 0x3U
-#define V_CNGCTRLMODE(x) ((x) << S_CNGCTRLMODE)
-#define G_CNGCTRLMODE(x) (((x) >> S_CNGCTRLMODE) & M_CNGCTRLMODE)
-
-#define S_RXCOALESCEENABLE 1
-#define V_RXCOALESCEENABLE(x) ((x) << S_RXCOALESCEENABLE)
-#define F_RXCOALESCEENABLE V_RXCOALESCEENABLE(1U)
-
-#define S_RXCOALESCEPSHEN 0
-#define V_RXCOALESCEPSHEN(x) ((x) << S_RXCOALESCEPSHEN)
-#define F_RXCOALESCEPSHEN V_RXCOALESCEPSHEN(1U)
-
-#define A_TP_PARA_REG4 0x7d70
-
-#define S_HIGHSPEEDCFG 24
-#define M_HIGHSPEEDCFG 0xffU
-#define V_HIGHSPEEDCFG(x) ((x) << S_HIGHSPEEDCFG)
-#define G_HIGHSPEEDCFG(x) (((x) >> S_HIGHSPEEDCFG) & M_HIGHSPEEDCFG)
-
-#define S_NEWRENOCFG 16
-#define M_NEWRENOCFG 0xffU
-#define V_NEWRENOCFG(x) ((x) << S_NEWRENOCFG)
-#define G_NEWRENOCFG(x) (((x) >> S_NEWRENOCFG) & M_NEWRENOCFG)
-
-#define S_TAHOECFG 8
-#define M_TAHOECFG 0xffU
-#define V_TAHOECFG(x) ((x) << S_TAHOECFG)
-#define G_TAHOECFG(x) (((x) >> S_TAHOECFG) & M_TAHOECFG)
-
-#define S_RENOCFG 0
-#define M_RENOCFG 0xffU
-#define V_RENOCFG(x) ((x) << S_RENOCFG)
-#define G_RENOCFG(x) (((x) >> S_RENOCFG) & M_RENOCFG)
-
-#define S_IDLECWNDHIGHSPEED 28
-#define V_IDLECWNDHIGHSPEED(x) ((x) << S_IDLECWNDHIGHSPEED)
-#define F_IDLECWNDHIGHSPEED V_IDLECWNDHIGHSPEED(1U)
-
-#define S_RXMTCWNDHIGHSPEED 27
-#define V_RXMTCWNDHIGHSPEED(x) ((x) << S_RXMTCWNDHIGHSPEED)
-#define F_RXMTCWNDHIGHSPEED V_RXMTCWNDHIGHSPEED(1U)
-
-#define S_OVERDRIVEHIGHSPEED 25
-#define M_OVERDRIVEHIGHSPEED 0x3U
-#define V_OVERDRIVEHIGHSPEED(x) ((x) << S_OVERDRIVEHIGHSPEED)
-#define G_OVERDRIVEHIGHSPEED(x) (((x) >> S_OVERDRIVEHIGHSPEED) & M_OVERDRIVEHIGHSPEED)
-
-#define S_BYTECOUNTHIGHSPEED 24
-#define V_BYTECOUNTHIGHSPEED(x) ((x) << S_BYTECOUNTHIGHSPEED)
-#define F_BYTECOUNTHIGHSPEED V_BYTECOUNTHIGHSPEED(1U)
-
-#define S_IDLECWNDNEWRENO 20
-#define V_IDLECWNDNEWRENO(x) ((x) << S_IDLECWNDNEWRENO)
-#define F_IDLECWNDNEWRENO V_IDLECWNDNEWRENO(1U)
-
-#define S_RXMTCWNDNEWRENO 19
-#define V_RXMTCWNDNEWRENO(x) ((x) << S_RXMTCWNDNEWRENO)
-#define F_RXMTCWNDNEWRENO V_RXMTCWNDNEWRENO(1U)
-
-#define S_OVERDRIVENEWRENO 17
-#define M_OVERDRIVENEWRENO 0x3U
-#define V_OVERDRIVENEWRENO(x) ((x) << S_OVERDRIVENEWRENO)
-#define G_OVERDRIVENEWRENO(x) (((x) >> S_OVERDRIVENEWRENO) & M_OVERDRIVENEWRENO)
-
-#define S_BYTECOUNTNEWRENO 16
-#define V_BYTECOUNTNEWRENO(x) ((x) << S_BYTECOUNTNEWRENO)
-#define F_BYTECOUNTNEWRENO V_BYTECOUNTNEWRENO(1U)
-
-#define S_IDLECWNDTAHOE 12
-#define V_IDLECWNDTAHOE(x) ((x) << S_IDLECWNDTAHOE)
-#define F_IDLECWNDTAHOE V_IDLECWNDTAHOE(1U)
-
-#define S_RXMTCWNDTAHOE 11
-#define V_RXMTCWNDTAHOE(x) ((x) << S_RXMTCWNDTAHOE)
-#define F_RXMTCWNDTAHOE V_RXMTCWNDTAHOE(1U)
-
-#define S_OVERDRIVETAHOE 9
-#define M_OVERDRIVETAHOE 0x3U
-#define V_OVERDRIVETAHOE(x) ((x) << S_OVERDRIVETAHOE)
-#define G_OVERDRIVETAHOE(x) (((x) >> S_OVERDRIVETAHOE) & M_OVERDRIVETAHOE)
-
-#define S_BYTECOUNTTAHOE 8
-#define V_BYTECOUNTTAHOE(x) ((x) << S_BYTECOUNTTAHOE)
-#define F_BYTECOUNTTAHOE V_BYTECOUNTTAHOE(1U)
-
-#define S_IDLECWNDRENO 4
-#define V_IDLECWNDRENO(x) ((x) << S_IDLECWNDRENO)
-#define F_IDLECWNDRENO V_IDLECWNDRENO(1U)
-
-#define S_RXMTCWNDRENO 3
-#define V_RXMTCWNDRENO(x) ((x) << S_RXMTCWNDRENO)
-#define F_RXMTCWNDRENO V_RXMTCWNDRENO(1U)
-
-#define S_OVERDRIVERENO 1
-#define M_OVERDRIVERENO 0x3U
-#define V_OVERDRIVERENO(x) ((x) << S_OVERDRIVERENO)
-#define G_OVERDRIVERENO(x) (((x) >> S_OVERDRIVERENO) & M_OVERDRIVERENO)
-
-#define S_BYTECOUNTRENO 0
-#define V_BYTECOUNTRENO(x) ((x) << S_BYTECOUNTRENO)
-#define F_BYTECOUNTRENO V_BYTECOUNTRENO(1U)
-
-#define A_TP_PARA_REG5 0x7d74
-
-#define S_INDICATESIZE 16
-#define M_INDICATESIZE 0xffffU
-#define V_INDICATESIZE(x) ((x) << S_INDICATESIZE)
-#define G_INDICATESIZE(x) (((x) >> S_INDICATESIZE) & M_INDICATESIZE)
-
-#define S_MAXPROXYSIZE 12
-#define M_MAXPROXYSIZE 0xfU
-#define V_MAXPROXYSIZE(x) ((x) << S_MAXPROXYSIZE)
-#define G_MAXPROXYSIZE(x) (((x) >> S_MAXPROXYSIZE) & M_MAXPROXYSIZE)
-
-#define S_ENABLEREADPDU 11
-#define V_ENABLEREADPDU(x) ((x) << S_ENABLEREADPDU)
-#define F_ENABLEREADPDU V_ENABLEREADPDU(1U)
-
-#define S_RXREADAHEAD 10
-#define V_RXREADAHEAD(x) ((x) << S_RXREADAHEAD)
-#define F_RXREADAHEAD V_RXREADAHEAD(1U)
-
-#define S_EMPTYRQENABLE 9
-#define V_EMPTYRQENABLE(x) ((x) << S_EMPTYRQENABLE)
-#define F_EMPTYRQENABLE V_EMPTYRQENABLE(1U)
-
-#define S_SCHDENABLE 8
-#define V_SCHDENABLE(x) ((x) << S_SCHDENABLE)
-#define F_SCHDENABLE V_SCHDENABLE(1U)
-
-#define S_REARMDDPOFFSET 4
-#define V_REARMDDPOFFSET(x) ((x) << S_REARMDDPOFFSET)
-#define F_REARMDDPOFFSET V_REARMDDPOFFSET(1U)
-
-#define S_RESETDDPOFFSET 3
-#define V_RESETDDPOFFSET(x) ((x) << S_RESETDDPOFFSET)
-#define F_RESETDDPOFFSET V_RESETDDPOFFSET(1U)
-
-#define S_ONFLYDDPENABLE 2
-#define V_ONFLYDDPENABLE(x) ((x) << S_ONFLYDDPENABLE)
-#define F_ONFLYDDPENABLE V_ONFLYDDPENABLE(1U)
-
-#define S_DACKTIMERSPIN 1
-#define V_DACKTIMERSPIN(x) ((x) << S_DACKTIMERSPIN)
-#define F_DACKTIMERSPIN V_DACKTIMERSPIN(1U)
-
-#define S_PUSHTIMERENABLE 0
-#define V_PUSHTIMERENABLE(x) ((x) << S_PUSHTIMERENABLE)
-#define F_PUSHTIMERENABLE V_PUSHTIMERENABLE(1U)
-
-#define S_ENABLEXOFFPDU 7
-#define V_ENABLEXOFFPDU(x) ((x) << S_ENABLEXOFFPDU)
-#define F_ENABLEXOFFPDU V_ENABLEXOFFPDU(1U)
-
-#define S_ENABLENEWFAR 6
-#define V_ENABLENEWFAR(x) ((x) << S_ENABLENEWFAR)
-#define F_ENABLENEWFAR V_ENABLENEWFAR(1U)
-
-#define S_ENABLEFRAGCHECK 5
-#define V_ENABLEFRAGCHECK(x) ((x) << S_ENABLEFRAGCHECK)
-#define F_ENABLEFRAGCHECK V_ENABLEFRAGCHECK(1U)
-
-#define S_ENABLEFCOECHECK 6
-#define V_ENABLEFCOECHECK(x) ((x) << S_ENABLEFCOECHECK)
-#define F_ENABLEFCOECHECK V_ENABLEFCOECHECK(1U)
-
-#define S_ENABLERDMAFIX 1
-#define V_ENABLERDMAFIX(x) ((x) << S_ENABLERDMAFIX)
-#define F_ENABLERDMAFIX V_ENABLERDMAFIX(1U)
-
-#define A_TP_PARA_REG6 0x7d78
-
-#define S_TXPDUSIZEADJ 24
-#define M_TXPDUSIZEADJ 0xffU
-#define V_TXPDUSIZEADJ(x) ((x) << S_TXPDUSIZEADJ)
-#define G_TXPDUSIZEADJ(x) (((x) >> S_TXPDUSIZEADJ) & M_TXPDUSIZEADJ)
-
-#define S_LIMITEDTRANSMIT 20
-#define M_LIMITEDTRANSMIT 0xfU
-#define V_LIMITEDTRANSMIT(x) ((x) << S_LIMITEDTRANSMIT)
-#define G_LIMITEDTRANSMIT(x) (((x) >> S_LIMITEDTRANSMIT) & M_LIMITEDTRANSMIT)
-
-#define S_ENABLECSAV 19
-#define V_ENABLECSAV(x) ((x) << S_ENABLECSAV)
-#define F_ENABLECSAV V_ENABLECSAV(1U)
-
-#define S_ENABLEDEFERPDU 18
-#define V_ENABLEDEFERPDU(x) ((x) << S_ENABLEDEFERPDU)
-#define F_ENABLEDEFERPDU V_ENABLEDEFERPDU(1U)
-
-#define S_ENABLEFLUSH 17
-#define V_ENABLEFLUSH(x) ((x) << S_ENABLEFLUSH)
-#define F_ENABLEFLUSH V_ENABLEFLUSH(1U)
-
-#define S_ENABLEBYTEPERSIST 16
-#define V_ENABLEBYTEPERSIST(x) ((x) << S_ENABLEBYTEPERSIST)
-#define F_ENABLEBYTEPERSIST V_ENABLEBYTEPERSIST(1U)
-
-#define S_DISABLETMOCNG 15
-#define V_DISABLETMOCNG(x) ((x) << S_DISABLETMOCNG)
-#define F_DISABLETMOCNG V_DISABLETMOCNG(1U)
-
-#define S_TXREADAHEAD 14
-#define V_TXREADAHEAD(x) ((x) << S_TXREADAHEAD)
-#define F_TXREADAHEAD V_TXREADAHEAD(1U)
-
-#define S_ALLOWEXEPTION 13
-#define V_ALLOWEXEPTION(x) ((x) << S_ALLOWEXEPTION)
-#define F_ALLOWEXEPTION V_ALLOWEXEPTION(1U)
-
-#define S_ENABLEDEFERACK 12
-#define V_ENABLEDEFERACK(x) ((x) << S_ENABLEDEFERACK)
-#define F_ENABLEDEFERACK V_ENABLEDEFERACK(1U)
-
-#define S_ENABLEESND 11
-#define V_ENABLEESND(x) ((x) << S_ENABLEESND)
-#define F_ENABLEESND V_ENABLEESND(1U)
-
-#define S_ENABLECSND 10
-#define V_ENABLECSND(x) ((x) << S_ENABLECSND)
-#define F_ENABLECSND V_ENABLECSND(1U)
-
-#define S_ENABLEPDUE 9
-#define V_ENABLEPDUE(x) ((x) << S_ENABLEPDUE)
-#define F_ENABLEPDUE V_ENABLEPDUE(1U)
-
-#define S_ENABLEPDUC 8
-#define V_ENABLEPDUC(x) ((x) << S_ENABLEPDUC)
-#define F_ENABLEPDUC V_ENABLEPDUC(1U)
-
-#define S_ENABLEBUFI 7
-#define V_ENABLEBUFI(x) ((x) << S_ENABLEBUFI)
-#define F_ENABLEBUFI V_ENABLEBUFI(1U)
-
-#define S_ENABLEBUFE 6
-#define V_ENABLEBUFE(x) ((x) << S_ENABLEBUFE)
-#define F_ENABLEBUFE V_ENABLEBUFE(1U)
-
-#define S_ENABLEDEFER 5
-#define V_ENABLEDEFER(x) ((x) << S_ENABLEDEFER)
-#define F_ENABLEDEFER V_ENABLEDEFER(1U)
-
-#define S_ENABLECLEARRXMTOOS 4
-#define V_ENABLECLEARRXMTOOS(x) ((x) << S_ENABLECLEARRXMTOOS)
-#define F_ENABLECLEARRXMTOOS V_ENABLECLEARRXMTOOS(1U)
-
-#define S_DISABLEPDUCNG 3
-#define V_DISABLEPDUCNG(x) ((x) << S_DISABLEPDUCNG)
-#define F_DISABLEPDUCNG V_DISABLEPDUCNG(1U)
-
-#define S_DISABLEPDUTIMEOUT 2
-#define V_DISABLEPDUTIMEOUT(x) ((x) << S_DISABLEPDUTIMEOUT)
-#define F_DISABLEPDUTIMEOUT V_DISABLEPDUTIMEOUT(1U)
-
-#define S_DISABLEPDURXMT 1
-#define V_DISABLEPDURXMT(x) ((x) << S_DISABLEPDURXMT)
-#define F_DISABLEPDURXMT V_DISABLEPDURXMT(1U)
-
-#define S_DISABLEPDUXMT 0
-#define V_DISABLEPDUXMT(x) ((x) << S_DISABLEPDUXMT)
-#define F_DISABLEPDUXMT V_DISABLEPDUXMT(1U)
-
-#define S_DISABLEPDUACK 20
-#define V_DISABLEPDUACK(x) ((x) << S_DISABLEPDUACK)
-#define F_DISABLEPDUACK V_DISABLEPDUACK(1U)
-
-#define S_TXTCAMKEY 22
-#define V_TXTCAMKEY(x) ((x) << S_TXTCAMKEY)
-#define F_TXTCAMKEY V_TXTCAMKEY(1U)
-
-#define S_ENABLECBYP 21
-#define V_ENABLECBYP(x) ((x) << S_ENABLECBYP)
-#define F_ENABLECBYP V_ENABLECBYP(1U)
-
-#define A_TP_PARA_REG7 0x7d7c
-
-#define S_PMMAXXFERLEN1 16
-#define M_PMMAXXFERLEN1 0xffffU
-#define V_PMMAXXFERLEN1(x) ((x) << S_PMMAXXFERLEN1)
-#define G_PMMAXXFERLEN1(x) (((x) >> S_PMMAXXFERLEN1) & M_PMMAXXFERLEN1)
-
-#define S_PMMAXXFERLEN0 0
-#define M_PMMAXXFERLEN0 0xffffU
-#define V_PMMAXXFERLEN0(x) ((x) << S_PMMAXXFERLEN0)
-#define G_PMMAXXFERLEN0(x) (((x) >> S_PMMAXXFERLEN0) & M_PMMAXXFERLEN0)
-
-#define A_TP_ENG_CONFIG 0x7d80
-
-#define S_TABLELATENCYDONE 28
-#define M_TABLELATENCYDONE 0xfU
-#define V_TABLELATENCYDONE(x) ((x) << S_TABLELATENCYDONE)
-#define G_TABLELATENCYDONE(x) (((x) >> S_TABLELATENCYDONE) & M_TABLELATENCYDONE)
-
-#define S_TABLELATENCYSTART 24
-#define M_TABLELATENCYSTART 0xfU
-#define V_TABLELATENCYSTART(x) ((x) << S_TABLELATENCYSTART)
-#define G_TABLELATENCYSTART(x) (((x) >> S_TABLELATENCYSTART) & M_TABLELATENCYSTART)
-
-#define S_ENGINELATENCYDELTA 16
-#define M_ENGINELATENCYDELTA 0xfU
-#define V_ENGINELATENCYDELTA(x) ((x) << S_ENGINELATENCYDELTA)
-#define G_ENGINELATENCYDELTA(x) (((x) >> S_ENGINELATENCYDELTA) & M_ENGINELATENCYDELTA)
-
-#define S_ENGINELATENCYMMGR 12
-#define M_ENGINELATENCYMMGR 0xfU
-#define V_ENGINELATENCYMMGR(x) ((x) << S_ENGINELATENCYMMGR)
-#define G_ENGINELATENCYMMGR(x) (((x) >> S_ENGINELATENCYMMGR) & M_ENGINELATENCYMMGR)
-
-#define S_ENGINELATENCYWIREIP6 8
-#define M_ENGINELATENCYWIREIP6 0xfU
-#define V_ENGINELATENCYWIREIP6(x) ((x) << S_ENGINELATENCYWIREIP6)
-#define G_ENGINELATENCYWIREIP6(x) (((x) >> S_ENGINELATENCYWIREIP6) & M_ENGINELATENCYWIREIP6)
-
-#define S_ENGINELATENCYWIRE 4
-#define M_ENGINELATENCYWIRE 0xfU
-#define V_ENGINELATENCYWIRE(x) ((x) << S_ENGINELATENCYWIRE)
-#define G_ENGINELATENCYWIRE(x) (((x) >> S_ENGINELATENCYWIRE) & M_ENGINELATENCYWIRE)
-
-#define S_ENGINELATENCYBASE 0
-#define M_ENGINELATENCYBASE 0xfU
-#define V_ENGINELATENCYBASE(x) ((x) << S_ENGINELATENCYBASE)
-#define G_ENGINELATENCYBASE(x) (((x) >> S_ENGINELATENCYBASE) & M_ENGINELATENCYBASE)
-
-#define A_TP_PARA_REG8 0x7d84
-
-#define S_ECNACKECT 2
-#define V_ECNACKECT(x) ((x) << S_ECNACKECT)
-#define F_ECNACKECT V_ECNACKECT(1U)
-
-#define S_ECNFINECT 1
-#define V_ECNFINECT(x) ((x) << S_ECNFINECT)
-#define F_ECNFINECT V_ECNFINECT(1U)
-
-#define S_ECNSYNECT 0
-#define V_ECNSYNECT(x) ((x) << S_ECNSYNECT)
-#define F_ECNSYNECT V_ECNSYNECT(1U)
-
-#define A_TP_ERR_CONFIG 0x7d8c
-
-#define S_TNLERRORPING 30
-#define V_TNLERRORPING(x) ((x) << S_TNLERRORPING)
-#define F_TNLERRORPING V_TNLERRORPING(1U)
-
-#define S_TNLERRORCSUM 29
-#define V_TNLERRORCSUM(x) ((x) << S_TNLERRORCSUM)
-#define F_TNLERRORCSUM V_TNLERRORCSUM(1U)
-
-#define S_TNLERRORCSUMIP 28
-#define V_TNLERRORCSUMIP(x) ((x) << S_TNLERRORCSUMIP)
-#define F_TNLERRORCSUMIP V_TNLERRORCSUMIP(1U)
-
-#define S_TNLERRORTCPOPT 25
-#define V_TNLERRORTCPOPT(x) ((x) << S_TNLERRORTCPOPT)
-#define F_TNLERRORTCPOPT V_TNLERRORTCPOPT(1U)
-
-#define S_TNLERRORPKTLEN 24
-#define V_TNLERRORPKTLEN(x) ((x) << S_TNLERRORPKTLEN)
-#define F_TNLERRORPKTLEN V_TNLERRORPKTLEN(1U)
-
-#define S_TNLERRORTCPHDRLEN 23
-#define V_TNLERRORTCPHDRLEN(x) ((x) << S_TNLERRORTCPHDRLEN)
-#define F_TNLERRORTCPHDRLEN V_TNLERRORTCPHDRLEN(1U)
-
-#define S_TNLERRORIPHDRLEN 22
-#define V_TNLERRORIPHDRLEN(x) ((x) << S_TNLERRORIPHDRLEN)
-#define F_TNLERRORIPHDRLEN V_TNLERRORIPHDRLEN(1U)
-
-#define S_TNLERRORETHHDRLEN 21
-#define V_TNLERRORETHHDRLEN(x) ((x) << S_TNLERRORETHHDRLEN)
-#define F_TNLERRORETHHDRLEN V_TNLERRORETHHDRLEN(1U)
-
-#define S_TNLERRORATTACK 20
-#define V_TNLERRORATTACK(x) ((x) << S_TNLERRORATTACK)
-#define F_TNLERRORATTACK V_TNLERRORATTACK(1U)
-
-#define S_TNLERRORFRAG 19
-#define V_TNLERRORFRAG(x) ((x) << S_TNLERRORFRAG)
-#define F_TNLERRORFRAG V_TNLERRORFRAG(1U)
-
-#define S_TNLERRORIPVER 18
-#define V_TNLERRORIPVER(x) ((x) << S_TNLERRORIPVER)
-#define F_TNLERRORIPVER V_TNLERRORIPVER(1U)
-
-#define S_TNLERRORMAC 17
-#define V_TNLERRORMAC(x) ((x) << S_TNLERRORMAC)
-#define F_TNLERRORMAC V_TNLERRORMAC(1U)
-
-#define S_TNLERRORANY 16
-#define V_TNLERRORANY(x) ((x) << S_TNLERRORANY)
-#define F_TNLERRORANY V_TNLERRORANY(1U)
-
-#define S_DROPERRORPING 14
-#define V_DROPERRORPING(x) ((x) << S_DROPERRORPING)
-#define F_DROPERRORPING V_DROPERRORPING(1U)
-
-#define S_DROPERRORCSUM 13
-#define V_DROPERRORCSUM(x) ((x) << S_DROPERRORCSUM)
-#define F_DROPERRORCSUM V_DROPERRORCSUM(1U)
-
-#define S_DROPERRORCSUMIP 12
-#define V_DROPERRORCSUMIP(x) ((x) << S_DROPERRORCSUMIP)
-#define F_DROPERRORCSUMIP V_DROPERRORCSUMIP(1U)
-
-#define S_DROPERRORTCPOPT 9
-#define V_DROPERRORTCPOPT(x) ((x) << S_DROPERRORTCPOPT)
-#define F_DROPERRORTCPOPT V_DROPERRORTCPOPT(1U)
-
-#define S_DROPERRORPKTLEN 8
-#define V_DROPERRORPKTLEN(x) ((x) << S_DROPERRORPKTLEN)
-#define F_DROPERRORPKTLEN V_DROPERRORPKTLEN(1U)
-
-#define S_DROPERRORTCPHDRLEN 7
-#define V_DROPERRORTCPHDRLEN(x) ((x) << S_DROPERRORTCPHDRLEN)
-#define F_DROPERRORTCPHDRLEN V_DROPERRORTCPHDRLEN(1U)
-
-#define S_DROPERRORIPHDRLEN 6
-#define V_DROPERRORIPHDRLEN(x) ((x) << S_DROPERRORIPHDRLEN)
-#define F_DROPERRORIPHDRLEN V_DROPERRORIPHDRLEN(1U)
-
-#define S_DROPERRORETHHDRLEN 5
-#define V_DROPERRORETHHDRLEN(x) ((x) << S_DROPERRORETHHDRLEN)
-#define F_DROPERRORETHHDRLEN V_DROPERRORETHHDRLEN(1U)
-
-#define S_DROPERRORATTACK 4
-#define V_DROPERRORATTACK(x) ((x) << S_DROPERRORATTACK)
-#define F_DROPERRORATTACK V_DROPERRORATTACK(1U)
-
-#define S_DROPERRORFRAG 3
-#define V_DROPERRORFRAG(x) ((x) << S_DROPERRORFRAG)
-#define F_DROPERRORFRAG V_DROPERRORFRAG(1U)
-
-#define S_DROPERRORIPVER 2
-#define V_DROPERRORIPVER(x) ((x) << S_DROPERRORIPVER)
-#define F_DROPERRORIPVER V_DROPERRORIPVER(1U)
-
-#define S_DROPERRORMAC 1
-#define V_DROPERRORMAC(x) ((x) << S_DROPERRORMAC)
-#define F_DROPERRORMAC V_DROPERRORMAC(1U)
-
-#define S_DROPERRORANY 0
-#define V_DROPERRORANY(x) ((x) << S_DROPERRORANY)
-#define F_DROPERRORANY V_DROPERRORANY(1U)
-
-#define S_TNLERRORFPMA 31
-#define V_TNLERRORFPMA(x) ((x) << S_TNLERRORFPMA)
-#define F_TNLERRORFPMA V_TNLERRORFPMA(1U)
-
-#define S_DROPERRORFPMA 15
-#define V_DROPERRORFPMA(x) ((x) << S_DROPERRORFPMA)
-#define F_DROPERRORFPMA V_DROPERRORFPMA(1U)
-
-#define S_TNLERROROPAQUE 27
-#define V_TNLERROROPAQUE(x) ((x) << S_TNLERROROPAQUE)
-#define F_TNLERROROPAQUE V_TNLERROROPAQUE(1U)
-
-#define S_TNLERRORIP6OPT 26
-#define V_TNLERRORIP6OPT(x) ((x) << S_TNLERRORIP6OPT)
-#define F_TNLERRORIP6OPT V_TNLERRORIP6OPT(1U)
-
-#define S_DROPERROROPAQUE 11
-#define V_DROPERROROPAQUE(x) ((x) << S_DROPERROROPAQUE)
-#define F_DROPERROROPAQUE V_DROPERROROPAQUE(1U)
-
-#define S_DROPERRORIP6OPT 10
-#define V_DROPERRORIP6OPT(x) ((x) << S_DROPERRORIP6OPT)
-#define F_DROPERRORIP6OPT V_DROPERRORIP6OPT(1U)
-
-#define A_TP_TIMER_RESOLUTION 0x7d90
-
-#define S_TIMERRESOLUTION 16
-#define M_TIMERRESOLUTION 0xffU
-#define V_TIMERRESOLUTION(x) ((x) << S_TIMERRESOLUTION)
-#define G_TIMERRESOLUTION(x) (((x) >> S_TIMERRESOLUTION) & M_TIMERRESOLUTION)
-
-#define S_TIMESTAMPRESOLUTION 8
-#define M_TIMESTAMPRESOLUTION 0xffU
-#define V_TIMESTAMPRESOLUTION(x) ((x) << S_TIMESTAMPRESOLUTION)
-#define G_TIMESTAMPRESOLUTION(x) (((x) >> S_TIMESTAMPRESOLUTION) & M_TIMESTAMPRESOLUTION)
-
-#define S_DELAYEDACKRESOLUTION 0
-#define M_DELAYEDACKRESOLUTION 0xffU
-#define V_DELAYEDACKRESOLUTION(x) ((x) << S_DELAYEDACKRESOLUTION)
-#define G_DELAYEDACKRESOLUTION(x) (((x) >> S_DELAYEDACKRESOLUTION) & M_DELAYEDACKRESOLUTION)
-
-#define A_TP_MSL 0x7d94
-
-#define S_MSL 0
-#define M_MSL 0x3fffffffU
-#define V_MSL(x) ((x) << S_MSL)
-#define G_MSL(x) (((x) >> S_MSL) & M_MSL)
-
-#define A_TP_RXT_MIN 0x7d98
-
-#define S_RXTMIN 0
-#define M_RXTMIN 0x3fffffffU
-#define V_RXTMIN(x) ((x) << S_RXTMIN)
-#define G_RXTMIN(x) (((x) >> S_RXTMIN) & M_RXTMIN)
-
-#define A_TP_RXT_MAX 0x7d9c
-
-#define S_RXTMAX 0
-#define M_RXTMAX 0x3fffffffU
-#define V_RXTMAX(x) ((x) << S_RXTMAX)
-#define G_RXTMAX(x) (((x) >> S_RXTMAX) & M_RXTMAX)
-
-#define A_TP_PERS_MIN 0x7da0
-
-#define S_PERSMIN 0
-#define M_PERSMIN 0x3fffffffU
-#define V_PERSMIN(x) ((x) << S_PERSMIN)
-#define G_PERSMIN(x) (((x) >> S_PERSMIN) & M_PERSMIN)
-
-#define A_TP_PERS_MAX 0x7da4
-
-#define S_PERSMAX 0
-#define M_PERSMAX 0x3fffffffU
-#define V_PERSMAX(x) ((x) << S_PERSMAX)
-#define G_PERSMAX(x) (((x) >> S_PERSMAX) & M_PERSMAX)
-
-#define A_TP_KEEP_IDLE 0x7da8
-
-#define S_KEEPALIVEIDLE 0
-#define M_KEEPALIVEIDLE 0x3fffffffU
-#define V_KEEPALIVEIDLE(x) ((x) << S_KEEPALIVEIDLE)
-#define G_KEEPALIVEIDLE(x) (((x) >> S_KEEPALIVEIDLE) & M_KEEPALIVEIDLE)
-
-#define A_TP_KEEP_INTVL 0x7dac
-
-#define S_KEEPALIVEINTVL 0
-#define M_KEEPALIVEINTVL 0x3fffffffU
-#define V_KEEPALIVEINTVL(x) ((x) << S_KEEPALIVEINTVL)
-#define G_KEEPALIVEINTVL(x) (((x) >> S_KEEPALIVEINTVL) & M_KEEPALIVEINTVL)
-
-#define A_TP_INIT_SRTT 0x7db0
-
-#define S_MAXRTT 16
-#define M_MAXRTT 0xffffU
-#define V_MAXRTT(x) ((x) << S_MAXRTT)
-#define G_MAXRTT(x) (((x) >> S_MAXRTT) & M_MAXRTT)
-
-#define S_INITSRTT 0
-#define M_INITSRTT 0xffffU
-#define V_INITSRTT(x) ((x) << S_INITSRTT)
-#define G_INITSRTT(x) (((x) >> S_INITSRTT) & M_INITSRTT)
-
-#define A_TP_DACK_TIMER 0x7db4
-
-#define S_DACKTIME 0
-#define M_DACKTIME 0xfffU
-#define V_DACKTIME(x) ((x) << S_DACKTIME)
-#define G_DACKTIME(x) (((x) >> S_DACKTIME) & M_DACKTIME)
-
-#define A_TP_FINWAIT2_TIMER 0x7db8
-
-#define S_FINWAIT2TIME 0
-#define M_FINWAIT2TIME 0x3fffffffU
-#define V_FINWAIT2TIME(x) ((x) << S_FINWAIT2TIME)
-#define G_FINWAIT2TIME(x) (((x) >> S_FINWAIT2TIME) & M_FINWAIT2TIME)
-
-#define A_TP_FAST_FINWAIT2_TIMER 0x7dbc
-
-#define S_FASTFINWAIT2TIME 0
-#define M_FASTFINWAIT2TIME 0x3fffffffU
-#define V_FASTFINWAIT2TIME(x) ((x) << S_FASTFINWAIT2TIME)
-#define G_FASTFINWAIT2TIME(x) (((x) >> S_FASTFINWAIT2TIME) & M_FASTFINWAIT2TIME)
-
-#define A_TP_SHIFT_CNT 0x7dc0
-
-#define S_SYNSHIFTMAX 24
-#define M_SYNSHIFTMAX 0xffU
-#define V_SYNSHIFTMAX(x) ((x) << S_SYNSHIFTMAX)
-#define G_SYNSHIFTMAX(x) (((x) >> S_SYNSHIFTMAX) & M_SYNSHIFTMAX)
-
-#define S_RXTSHIFTMAXR1 20
-#define M_RXTSHIFTMAXR1 0xfU
-#define V_RXTSHIFTMAXR1(x) ((x) << S_RXTSHIFTMAXR1)
-#define G_RXTSHIFTMAXR1(x) (((x) >> S_RXTSHIFTMAXR1) & M_RXTSHIFTMAXR1)
-
-#define S_RXTSHIFTMAXR2 16
-#define M_RXTSHIFTMAXR2 0xfU
-#define V_RXTSHIFTMAXR2(x) ((x) << S_RXTSHIFTMAXR2)
-#define G_RXTSHIFTMAXR2(x) (((x) >> S_RXTSHIFTMAXR2) & M_RXTSHIFTMAXR2)
-
-#define S_PERSHIFTBACKOFFMAX 12
-#define M_PERSHIFTBACKOFFMAX 0xfU
-#define V_PERSHIFTBACKOFFMAX(x) ((x) << S_PERSHIFTBACKOFFMAX)
-#define G_PERSHIFTBACKOFFMAX(x) (((x) >> S_PERSHIFTBACKOFFMAX) & M_PERSHIFTBACKOFFMAX)
-
-#define S_PERSHIFTMAX 8
-#define M_PERSHIFTMAX 0xfU
-#define V_PERSHIFTMAX(x) ((x) << S_PERSHIFTMAX)
-#define G_PERSHIFTMAX(x) (((x) >> S_PERSHIFTMAX) & M_PERSHIFTMAX)
-
-#define S_KEEPALIVEMAXR1 4
-#define M_KEEPALIVEMAXR1 0xfU
-#define V_KEEPALIVEMAXR1(x) ((x) << S_KEEPALIVEMAXR1)
-#define G_KEEPALIVEMAXR1(x) (((x) >> S_KEEPALIVEMAXR1) & M_KEEPALIVEMAXR1)
-
-#define S_KEEPALIVEMAXR2 0
-#define M_KEEPALIVEMAXR2 0xfU
-#define V_KEEPALIVEMAXR2(x) ((x) << S_KEEPALIVEMAXR2)
-#define G_KEEPALIVEMAXR2(x) (((x) >> S_KEEPALIVEMAXR2) & M_KEEPALIVEMAXR2)
-
-#define S_T6_SYNSHIFTMAX 24
-#define M_T6_SYNSHIFTMAX 0xfU
-#define V_T6_SYNSHIFTMAX(x) ((x) << S_T6_SYNSHIFTMAX)
-#define G_T6_SYNSHIFTMAX(x) (((x) >> S_T6_SYNSHIFTMAX) & M_T6_SYNSHIFTMAX)
-
-#define A_TP_TM_CONFIG 0x7dc4
-
-#define S_CMTIMERMAXNUM 0
-#define M_CMTIMERMAXNUM 0x7U
-#define V_CMTIMERMAXNUM(x) ((x) << S_CMTIMERMAXNUM)
-#define G_CMTIMERMAXNUM(x) (((x) >> S_CMTIMERMAXNUM) & M_CMTIMERMAXNUM)
-
-#define A_TP_TIME_LO 0x7dc8
-#define A_TP_TIME_HI 0x7dcc
-#define A_TP_PORT_MTU_0 0x7dd0
-
-#define S_PORT1MTUVALUE 16
-#define M_PORT1MTUVALUE 0xffffU
-#define V_PORT1MTUVALUE(x) ((x) << S_PORT1MTUVALUE)
-#define G_PORT1MTUVALUE(x) (((x) >> S_PORT1MTUVALUE) & M_PORT1MTUVALUE)
-
-#define S_PORT0MTUVALUE 0
-#define M_PORT0MTUVALUE 0xffffU
-#define V_PORT0MTUVALUE(x) ((x) << S_PORT0MTUVALUE)
-#define G_PORT0MTUVALUE(x) (((x) >> S_PORT0MTUVALUE) & M_PORT0MTUVALUE)
-
-#define A_TP_PORT_MTU_1 0x7dd4
-
-#define S_PORT3MTUVALUE 16
-#define M_PORT3MTUVALUE 0xffffU
-#define V_PORT3MTUVALUE(x) ((x) << S_PORT3MTUVALUE)
-#define G_PORT3MTUVALUE(x) (((x) >> S_PORT3MTUVALUE) & M_PORT3MTUVALUE)
-
-#define S_PORT2MTUVALUE 0
-#define M_PORT2MTUVALUE 0xffffU
-#define V_PORT2MTUVALUE(x) ((x) << S_PORT2MTUVALUE)
-#define G_PORT2MTUVALUE(x) (((x) >> S_PORT2MTUVALUE) & M_PORT2MTUVALUE)
-
-#define A_TP_PACE_TABLE 0x7dd8
-#define A_TP_CCTRL_TABLE 0x7ddc
-
-#define S_ROWINDEX 16
-#define M_ROWINDEX 0xffffU
-#define V_ROWINDEX(x) ((x) << S_ROWINDEX)
-#define G_ROWINDEX(x) (((x) >> S_ROWINDEX) & M_ROWINDEX)
-
-#define S_ROWVALUE 0
-#define M_ROWVALUE 0xffffU
-#define V_ROWVALUE(x) ((x) << S_ROWVALUE)
-#define G_ROWVALUE(x) (((x) >> S_ROWVALUE) & M_ROWVALUE)
-
-#define A_TP_MTU_TABLE 0x7de4
-
-#define S_MTUINDEX 24
-#define M_MTUINDEX 0xffU
-#define V_MTUINDEX(x) ((x) << S_MTUINDEX)
-#define G_MTUINDEX(x) (((x) >> S_MTUINDEX) & M_MTUINDEX)
-
-#define S_MTUWIDTH 16
-#define M_MTUWIDTH 0xfU
-#define V_MTUWIDTH(x) ((x) << S_MTUWIDTH)
-#define G_MTUWIDTH(x) (((x) >> S_MTUWIDTH) & M_MTUWIDTH)
-
-#define S_MTUVALUE 0
-#define M_MTUVALUE 0x3fffU
-#define V_MTUVALUE(x) ((x) << S_MTUVALUE)
-#define G_MTUVALUE(x) (((x) >> S_MTUVALUE) & M_MTUVALUE)
-
-#define A_TP_ULP_TABLE 0x7de8
-
-#define S_ULPTYPE7FIELD 28
-#define M_ULPTYPE7FIELD 0xfU
-#define V_ULPTYPE7FIELD(x) ((x) << S_ULPTYPE7FIELD)
-#define G_ULPTYPE7FIELD(x) (((x) >> S_ULPTYPE7FIELD) & M_ULPTYPE7FIELD)
-
-#define S_ULPTYPE6FIELD 24
-#define M_ULPTYPE6FIELD 0xfU
-#define V_ULPTYPE6FIELD(x) ((x) << S_ULPTYPE6FIELD)
-#define G_ULPTYPE6FIELD(x) (((x) >> S_ULPTYPE6FIELD) & M_ULPTYPE6FIELD)
-
-#define S_ULPTYPE5FIELD 20
-#define M_ULPTYPE5FIELD 0xfU
-#define V_ULPTYPE5FIELD(x) ((x) << S_ULPTYPE5FIELD)
-#define G_ULPTYPE5FIELD(x) (((x) >> S_ULPTYPE5FIELD) & M_ULPTYPE5FIELD)
-
-#define S_ULPTYPE4FIELD 16
-#define M_ULPTYPE4FIELD 0xfU
-#define V_ULPTYPE4FIELD(x) ((x) << S_ULPTYPE4FIELD)
-#define G_ULPTYPE4FIELD(x) (((x) >> S_ULPTYPE4FIELD) & M_ULPTYPE4FIELD)
-
-#define S_ULPTYPE3FIELD 12
-#define M_ULPTYPE3FIELD 0xfU
-#define V_ULPTYPE3FIELD(x) ((x) << S_ULPTYPE3FIELD)
-#define G_ULPTYPE3FIELD(x) (((x) >> S_ULPTYPE3FIELD) & M_ULPTYPE3FIELD)
-
-#define S_ULPTYPE2FIELD 8
-#define M_ULPTYPE2FIELD 0xfU
-#define V_ULPTYPE2FIELD(x) ((x) << S_ULPTYPE2FIELD)
-#define G_ULPTYPE2FIELD(x) (((x) >> S_ULPTYPE2FIELD) & M_ULPTYPE2FIELD)
-
-#define S_ULPTYPE1FIELD 4
-#define M_ULPTYPE1FIELD 0xfU
-#define V_ULPTYPE1FIELD(x) ((x) << S_ULPTYPE1FIELD)
-#define G_ULPTYPE1FIELD(x) (((x) >> S_ULPTYPE1FIELD) & M_ULPTYPE1FIELD)
-
-#define S_ULPTYPE0FIELD 0
-#define M_ULPTYPE0FIELD 0xfU
-#define V_ULPTYPE0FIELD(x) ((x) << S_ULPTYPE0FIELD)
-#define G_ULPTYPE0FIELD(x) (((x) >> S_ULPTYPE0FIELD) & M_ULPTYPE0FIELD)
-
-#define S_ULPTYPE7LENGTH 31
-#define V_ULPTYPE7LENGTH(x) ((x) << S_ULPTYPE7LENGTH)
-#define F_ULPTYPE7LENGTH V_ULPTYPE7LENGTH(1U)
-
-#define S_ULPTYPE7OFFSET 28
-#define M_ULPTYPE7OFFSET 0x7U
-#define V_ULPTYPE7OFFSET(x) ((x) << S_ULPTYPE7OFFSET)
-#define G_ULPTYPE7OFFSET(x) (((x) >> S_ULPTYPE7OFFSET) & M_ULPTYPE7OFFSET)
-
-#define S_ULPTYPE6LENGTH 27
-#define V_ULPTYPE6LENGTH(x) ((x) << S_ULPTYPE6LENGTH)
-#define F_ULPTYPE6LENGTH V_ULPTYPE6LENGTH(1U)
-
-#define S_ULPTYPE6OFFSET 24
-#define M_ULPTYPE6OFFSET 0x7U
-#define V_ULPTYPE6OFFSET(x) ((x) << S_ULPTYPE6OFFSET)
-#define G_ULPTYPE6OFFSET(x) (((x) >> S_ULPTYPE6OFFSET) & M_ULPTYPE6OFFSET)
-
-#define S_ULPTYPE5LENGTH 23
-#define V_ULPTYPE5LENGTH(x) ((x) << S_ULPTYPE5LENGTH)
-#define F_ULPTYPE5LENGTH V_ULPTYPE5LENGTH(1U)
-
-#define S_ULPTYPE5OFFSET 20
-#define M_ULPTYPE5OFFSET 0x7U
-#define V_ULPTYPE5OFFSET(x) ((x) << S_ULPTYPE5OFFSET)
-#define G_ULPTYPE5OFFSET(x) (((x) >> S_ULPTYPE5OFFSET) & M_ULPTYPE5OFFSET)
-
-#define S_ULPTYPE4LENGTH 19
-#define V_ULPTYPE4LENGTH(x) ((x) << S_ULPTYPE4LENGTH)
-#define F_ULPTYPE4LENGTH V_ULPTYPE4LENGTH(1U)
-
-#define S_ULPTYPE4OFFSET 16
-#define M_ULPTYPE4OFFSET 0x7U
-#define V_ULPTYPE4OFFSET(x) ((x) << S_ULPTYPE4OFFSET)
-#define G_ULPTYPE4OFFSET(x) (((x) >> S_ULPTYPE4OFFSET) & M_ULPTYPE4OFFSET)
-
-#define S_ULPTYPE3LENGTH 15
-#define V_ULPTYPE3LENGTH(x) ((x) << S_ULPTYPE3LENGTH)
-#define F_ULPTYPE3LENGTH V_ULPTYPE3LENGTH(1U)
-
-#define S_ULPTYPE3OFFSET 12
-#define M_ULPTYPE3OFFSET 0x7U
-#define V_ULPTYPE3OFFSET(x) ((x) << S_ULPTYPE3OFFSET)
-#define G_ULPTYPE3OFFSET(x) (((x) >> S_ULPTYPE3OFFSET) & M_ULPTYPE3OFFSET)
-
-#define S_ULPTYPE2LENGTH 11
-#define V_ULPTYPE2LENGTH(x) ((x) << S_ULPTYPE2LENGTH)
-#define F_ULPTYPE2LENGTH V_ULPTYPE2LENGTH(1U)
-
-#define S_ULPTYPE2OFFSET 8
-#define M_ULPTYPE2OFFSET 0x7U
-#define V_ULPTYPE2OFFSET(x) ((x) << S_ULPTYPE2OFFSET)
-#define G_ULPTYPE2OFFSET(x) (((x) >> S_ULPTYPE2OFFSET) & M_ULPTYPE2OFFSET)
-
-#define S_ULPTYPE1LENGTH 7
-#define V_ULPTYPE1LENGTH(x) ((x) << S_ULPTYPE1LENGTH)
-#define F_ULPTYPE1LENGTH V_ULPTYPE1LENGTH(1U)
-
-#define S_ULPTYPE1OFFSET 4
-#define M_ULPTYPE1OFFSET 0x7U
-#define V_ULPTYPE1OFFSET(x) ((x) << S_ULPTYPE1OFFSET)
-#define G_ULPTYPE1OFFSET(x) (((x) >> S_ULPTYPE1OFFSET) & M_ULPTYPE1OFFSET)
-
-#define S_ULPTYPE0LENGTH 3
-#define V_ULPTYPE0LENGTH(x) ((x) << S_ULPTYPE0LENGTH)
-#define F_ULPTYPE0LENGTH V_ULPTYPE0LENGTH(1U)
-
-#define S_ULPTYPE0OFFSET 0
-#define M_ULPTYPE0OFFSET 0x7U
-#define V_ULPTYPE0OFFSET(x) ((x) << S_ULPTYPE0OFFSET)
-#define G_ULPTYPE0OFFSET(x) (((x) >> S_ULPTYPE0OFFSET) & M_ULPTYPE0OFFSET)
-
-#define A_TP_RSS_LKP_TABLE 0x7dec
-
-#define S_LKPTBLROWVLD 31
-#define V_LKPTBLROWVLD(x) ((x) << S_LKPTBLROWVLD)
-#define F_LKPTBLROWVLD V_LKPTBLROWVLD(1U)
-
-#define S_LKPTBLROWIDX 20
-#define M_LKPTBLROWIDX 0x3ffU
-#define V_LKPTBLROWIDX(x) ((x) << S_LKPTBLROWIDX)
-#define G_LKPTBLROWIDX(x) (((x) >> S_LKPTBLROWIDX) & M_LKPTBLROWIDX)
-
-#define S_LKPTBLQUEUE1 10
-#define M_LKPTBLQUEUE1 0x3ffU
-#define V_LKPTBLQUEUE1(x) ((x) << S_LKPTBLQUEUE1)
-#define G_LKPTBLQUEUE1(x) (((x) >> S_LKPTBLQUEUE1) & M_LKPTBLQUEUE1)
-
-#define S_LKPTBLQUEUE0 0
-#define M_LKPTBLQUEUE0 0x3ffU
-#define V_LKPTBLQUEUE0(x) ((x) << S_LKPTBLQUEUE0)
-#define G_LKPTBLQUEUE0(x) (((x) >> S_LKPTBLQUEUE0) & M_LKPTBLQUEUE0)
-
-#define S_T6_LKPTBLROWIDX 20
-#define M_T6_LKPTBLROWIDX 0x7ffU
-#define V_T6_LKPTBLROWIDX(x) ((x) << S_T6_LKPTBLROWIDX)
-#define G_T6_LKPTBLROWIDX(x) (((x) >> S_T6_LKPTBLROWIDX) & M_T6_LKPTBLROWIDX)
-
-#define A_TP_RSS_CONFIG 0x7df0
-
-#define S_TNL4TUPENIPV6 31
-#define V_TNL4TUPENIPV6(x) ((x) << S_TNL4TUPENIPV6)
-#define F_TNL4TUPENIPV6 V_TNL4TUPENIPV6(1U)
-
-#define S_TNL2TUPENIPV6 30
-#define V_TNL2TUPENIPV6(x) ((x) << S_TNL2TUPENIPV6)
-#define F_TNL2TUPENIPV6 V_TNL2TUPENIPV6(1U)
-
-#define S_TNL4TUPENIPV4 29
-#define V_TNL4TUPENIPV4(x) ((x) << S_TNL4TUPENIPV4)
-#define F_TNL4TUPENIPV4 V_TNL4TUPENIPV4(1U)
-
-#define S_TNL2TUPENIPV4 28
-#define V_TNL2TUPENIPV4(x) ((x) << S_TNL2TUPENIPV4)
-#define F_TNL2TUPENIPV4 V_TNL2TUPENIPV4(1U)
-
-#define S_TNLTCPSEL 27
-#define V_TNLTCPSEL(x) ((x) << S_TNLTCPSEL)
-#define F_TNLTCPSEL V_TNLTCPSEL(1U)
-
-#define S_TNLIP6SEL 26
-#define V_TNLIP6SEL(x) ((x) << S_TNLIP6SEL)
-#define F_TNLIP6SEL V_TNLIP6SEL(1U)
-
-#define S_TNLVRTSEL 25
-#define V_TNLVRTSEL(x) ((x) << S_TNLVRTSEL)
-#define F_TNLVRTSEL V_TNLVRTSEL(1U)
-
-#define S_TNLMAPEN 24
-#define V_TNLMAPEN(x) ((x) << S_TNLMAPEN)
-#define F_TNLMAPEN V_TNLMAPEN(1U)
-
-#define S_OFDHASHSAVE 19
-#define V_OFDHASHSAVE(x) ((x) << S_OFDHASHSAVE)
-#define F_OFDHASHSAVE V_OFDHASHSAVE(1U)
-
-#define S_OFDVRTSEL 18
-#define V_OFDVRTSEL(x) ((x) << S_OFDVRTSEL)
-#define F_OFDVRTSEL V_OFDVRTSEL(1U)
-
-#define S_OFDMAPEN 17
-#define V_OFDMAPEN(x) ((x) << S_OFDMAPEN)
-#define F_OFDMAPEN V_OFDMAPEN(1U)
-
-#define S_OFDLKPEN 16
-#define V_OFDLKPEN(x) ((x) << S_OFDLKPEN)
-#define F_OFDLKPEN V_OFDLKPEN(1U)
-
-#define S_SYN4TUPENIPV6 15
-#define V_SYN4TUPENIPV6(x) ((x) << S_SYN4TUPENIPV6)
-#define F_SYN4TUPENIPV6 V_SYN4TUPENIPV6(1U)
-
-#define S_SYN2TUPENIPV6 14
-#define V_SYN2TUPENIPV6(x) ((x) << S_SYN2TUPENIPV6)
-#define F_SYN2TUPENIPV6 V_SYN2TUPENIPV6(1U)
-
-#define S_SYN4TUPENIPV4 13
-#define V_SYN4TUPENIPV4(x) ((x) << S_SYN4TUPENIPV4)
-#define F_SYN4TUPENIPV4 V_SYN4TUPENIPV4(1U)
-
-#define S_SYN2TUPENIPV4 12
-#define V_SYN2TUPENIPV4(x) ((x) << S_SYN2TUPENIPV4)
-#define F_SYN2TUPENIPV4 V_SYN2TUPENIPV4(1U)
-
-#define S_SYNIP6SEL 11
-#define V_SYNIP6SEL(x) ((x) << S_SYNIP6SEL)
-#define F_SYNIP6SEL V_SYNIP6SEL(1U)
-
-#define S_SYNVRTSEL 10
-#define V_SYNVRTSEL(x) ((x) << S_SYNVRTSEL)
-#define F_SYNVRTSEL V_SYNVRTSEL(1U)
-
-#define S_SYNMAPEN 9
-#define V_SYNMAPEN(x) ((x) << S_SYNMAPEN)
-#define F_SYNMAPEN V_SYNMAPEN(1U)
-
-#define S_SYNLKPEN 8
-#define V_SYNLKPEN(x) ((x) << S_SYNLKPEN)
-#define F_SYNLKPEN V_SYNLKPEN(1U)
-
-#define S_CHANNELENABLE 7
-#define V_CHANNELENABLE(x) ((x) << S_CHANNELENABLE)
-#define F_CHANNELENABLE V_CHANNELENABLE(1U)
-
-#define S_PORTENABLE 6
-#define V_PORTENABLE(x) ((x) << S_PORTENABLE)
-#define F_PORTENABLE V_PORTENABLE(1U)
-
-#define S_TNLALLLOOKUP 5
-#define V_TNLALLLOOKUP(x) ((x) << S_TNLALLLOOKUP)
-#define F_TNLALLLOOKUP V_TNLALLLOOKUP(1U)
-
-#define S_VIRTENABLE 4
-#define V_VIRTENABLE(x) ((x) << S_VIRTENABLE)
-#define F_VIRTENABLE V_VIRTENABLE(1U)
-
-#define S_CONGESTIONENABLE 3
-#define V_CONGESTIONENABLE(x) ((x) << S_CONGESTIONENABLE)
-#define F_CONGESTIONENABLE V_CONGESTIONENABLE(1U)
-
-#define S_HASHTOEPLITZ 2
-#define V_HASHTOEPLITZ(x) ((x) << S_HASHTOEPLITZ)
-#define F_HASHTOEPLITZ V_HASHTOEPLITZ(1U)
-
-#define S_UDPENABLE 1
-#define V_UDPENABLE(x) ((x) << S_UDPENABLE)
-#define F_UDPENABLE V_UDPENABLE(1U)
-
-#define S_DISABLE 0
-#define V_DISABLE(x) ((x) << S_DISABLE)
-#define F_DISABLE V_DISABLE(1U)
-
-#define S_TNLFCOEMODE 23
-#define V_TNLFCOEMODE(x) ((x) << S_TNLFCOEMODE)
-#define F_TNLFCOEMODE V_TNLFCOEMODE(1U)
-
-#define S_TNLFCOEEN 21
-#define V_TNLFCOEEN(x) ((x) << S_TNLFCOEEN)
-#define F_TNLFCOEEN V_TNLFCOEEN(1U)
-
-#define S_HASHXOR 20
-#define V_HASHXOR(x) ((x) << S_HASHXOR)
-#define F_HASHXOR V_HASHXOR(1U)
-
-#define S_TNLFCOESID 22
-#define V_TNLFCOESID(x) ((x) << S_TNLFCOESID)
-#define F_TNLFCOESID V_TNLFCOESID(1U)
-
-#define A_TP_RSS_CONFIG_TNL 0x7df4
-
-#define S_MASKSIZE 28
-#define M_MASKSIZE 0xfU
-#define V_MASKSIZE(x) ((x) << S_MASKSIZE)
-#define G_MASKSIZE(x) (((x) >> S_MASKSIZE) & M_MASKSIZE)
-
-#define S_MASKFILTER 16
-#define M_MASKFILTER 0x7ffU
-#define V_MASKFILTER(x) ((x) << S_MASKFILTER)
-#define G_MASKFILTER(x) (((x) >> S_MASKFILTER) & M_MASKFILTER)
-
-#define S_USEWIRECH 0
-#define V_USEWIRECH(x) ((x) << S_USEWIRECH)
-#define F_USEWIRECH V_USEWIRECH(1U)
-
-#define S_HASHALL 2
-#define V_HASHALL(x) ((x) << S_HASHALL)
-#define F_HASHALL V_HASHALL(1U)
-
-#define S_HASHETH 1
-#define V_HASHETH(x) ((x) << S_HASHETH)
-#define F_HASHETH V_HASHETH(1U)
-
-#define A_TP_RSS_CONFIG_OFD 0x7df8
-
-#define S_RRCPLMAPEN 20
-#define V_RRCPLMAPEN(x) ((x) << S_RRCPLMAPEN)
-#define F_RRCPLMAPEN V_RRCPLMAPEN(1U)
-
-#define S_RRCPLQUEWIDTH 16
-#define M_RRCPLQUEWIDTH 0xfU
-#define V_RRCPLQUEWIDTH(x) ((x) << S_RRCPLQUEWIDTH)
-#define G_RRCPLQUEWIDTH(x) (((x) >> S_RRCPLQUEWIDTH) & M_RRCPLQUEWIDTH)
-
-#define S_FRMWRQUEMASK 12
-#define M_FRMWRQUEMASK 0xfU
-#define V_FRMWRQUEMASK(x) ((x) << S_FRMWRQUEMASK)
-#define G_FRMWRQUEMASK(x) (((x) >> S_FRMWRQUEMASK) & M_FRMWRQUEMASK)
-
-#define A_TP_RSS_CONFIG_SYN 0x7dfc
-#define A_TP_RSS_CONFIG_VRT 0x7e00
-
-#define S_VFRDRG 25
-#define V_VFRDRG(x) ((x) << S_VFRDRG)
-#define F_VFRDRG V_VFRDRG(1U)
-
-#define S_VFRDEN 24
-#define V_VFRDEN(x) ((x) << S_VFRDEN)
-#define F_VFRDEN V_VFRDEN(1U)
-
-#define S_VFPERREN 23
-#define V_VFPERREN(x) ((x) << S_VFPERREN)
-#define F_VFPERREN V_VFPERREN(1U)
-
-#define S_KEYPERREN 22
-#define V_KEYPERREN(x) ((x) << S_KEYPERREN)
-#define F_KEYPERREN V_KEYPERREN(1U)
-
-#define S_DISABLEVLAN 21
-#define V_DISABLEVLAN(x) ((x) << S_DISABLEVLAN)
-#define F_DISABLEVLAN V_DISABLEVLAN(1U)
-
-#define S_ENABLEUP0 20
-#define V_ENABLEUP0(x) ((x) << S_ENABLEUP0)
-#define F_ENABLEUP0 V_ENABLEUP0(1U)
-
-#define S_HASHDELAY 16
-#define M_HASHDELAY 0xfU
-#define V_HASHDELAY(x) ((x) << S_HASHDELAY)
-#define G_HASHDELAY(x) (((x) >> S_HASHDELAY) & M_HASHDELAY)
-
-#define S_VFWRADDR 8
-#define M_VFWRADDR 0x7fU
-#define V_VFWRADDR(x) ((x) << S_VFWRADDR)
-#define G_VFWRADDR(x) (((x) >> S_VFWRADDR) & M_VFWRADDR)
-
-#define S_KEYMODE 6
-#define M_KEYMODE 0x3U
-#define V_KEYMODE(x) ((x) << S_KEYMODE)
-#define G_KEYMODE(x) (((x) >> S_KEYMODE) & M_KEYMODE)
-
-#define S_VFWREN 5
-#define V_VFWREN(x) ((x) << S_VFWREN)
-#define F_VFWREN V_VFWREN(1U)
-
-#define S_KEYWREN 4
-#define V_KEYWREN(x) ((x) << S_KEYWREN)
-#define F_KEYWREN V_KEYWREN(1U)
-
-#define S_KEYWRADDR 0
-#define M_KEYWRADDR 0xfU
-#define V_KEYWRADDR(x) ((x) << S_KEYWRADDR)
-#define G_KEYWRADDR(x) (((x) >> S_KEYWRADDR) & M_KEYWRADDR)
-
-#define S_VFVLANEN 21
-#define V_VFVLANEN(x) ((x) << S_VFVLANEN)
-#define F_VFVLANEN V_VFVLANEN(1U)
-
-#define S_VFFWEN 20
-#define V_VFFWEN(x) ((x) << S_VFFWEN)
-#define F_VFFWEN V_VFFWEN(1U)
-
-#define S_KEYWRADDRX 30
-#define M_KEYWRADDRX 0x3U
-#define V_KEYWRADDRX(x) ((x) << S_KEYWRADDRX)
-#define G_KEYWRADDRX(x) (((x) >> S_KEYWRADDRX) & M_KEYWRADDRX)
-
-#define S_KEYEXTEND 26
-#define V_KEYEXTEND(x) ((x) << S_KEYEXTEND)
-#define F_KEYEXTEND V_KEYEXTEND(1U)
-
-#define S_T6_VFWRADDR 8
-#define M_T6_VFWRADDR 0xffU
-#define V_T6_VFWRADDR(x) ((x) << S_T6_VFWRADDR)
-#define G_T6_VFWRADDR(x) (((x) >> S_T6_VFWRADDR) & M_T6_VFWRADDR)
-
-#define A_TP_RSS_CONFIG_CNG 0x7e04
-
-#define S_CHNCOUNT3 31
-#define V_CHNCOUNT3(x) ((x) << S_CHNCOUNT3)
-#define F_CHNCOUNT3 V_CHNCOUNT3(1U)
-
-#define S_CHNCOUNT2 30
-#define V_CHNCOUNT2(x) ((x) << S_CHNCOUNT2)
-#define F_CHNCOUNT2 V_CHNCOUNT2(1U)
-
-#define S_CHNCOUNT1 29
-#define V_CHNCOUNT1(x) ((x) << S_CHNCOUNT1)
-#define F_CHNCOUNT1 V_CHNCOUNT1(1U)
-
-#define S_CHNCOUNT0 28
-#define V_CHNCOUNT0(x) ((x) << S_CHNCOUNT0)
-#define F_CHNCOUNT0 V_CHNCOUNT0(1U)
-
-#define S_CHNUNDFLOW3 27
-#define V_CHNUNDFLOW3(x) ((x) << S_CHNUNDFLOW3)
-#define F_CHNUNDFLOW3 V_CHNUNDFLOW3(1U)
-
-#define S_CHNUNDFLOW2 26
-#define V_CHNUNDFLOW2(x) ((x) << S_CHNUNDFLOW2)
-#define F_CHNUNDFLOW2 V_CHNUNDFLOW2(1U)
-
-#define S_CHNUNDFLOW1 25
-#define V_CHNUNDFLOW1(x) ((x) << S_CHNUNDFLOW1)
-#define F_CHNUNDFLOW1 V_CHNUNDFLOW1(1U)
-
-#define S_CHNUNDFLOW0 24
-#define V_CHNUNDFLOW0(x) ((x) << S_CHNUNDFLOW0)
-#define F_CHNUNDFLOW0 V_CHNUNDFLOW0(1U)
-
-#define S_CHNOVRFLOW3 23
-#define V_CHNOVRFLOW3(x) ((x) << S_CHNOVRFLOW3)
-#define F_CHNOVRFLOW3 V_CHNOVRFLOW3(1U)
-
-#define S_CHNOVRFLOW2 22
-#define V_CHNOVRFLOW2(x) ((x) << S_CHNOVRFLOW2)
-#define F_CHNOVRFLOW2 V_CHNOVRFLOW2(1U)
-
-#define S_CHNOVRFLOW1 21
-#define V_CHNOVRFLOW1(x) ((x) << S_CHNOVRFLOW1)
-#define F_CHNOVRFLOW1 V_CHNOVRFLOW1(1U)
-
-#define S_CHNOVRFLOW0 20
-#define V_CHNOVRFLOW0(x) ((x) << S_CHNOVRFLOW0)
-#define F_CHNOVRFLOW0 V_CHNOVRFLOW0(1U)
-
-#define S_RSTCHN3 19
-#define V_RSTCHN3(x) ((x) << S_RSTCHN3)
-#define F_RSTCHN3 V_RSTCHN3(1U)
-
-#define S_RSTCHN2 18
-#define V_RSTCHN2(x) ((x) << S_RSTCHN2)
-#define F_RSTCHN2 V_RSTCHN2(1U)
-
-#define S_RSTCHN1 17
-#define V_RSTCHN1(x) ((x) << S_RSTCHN1)
-#define F_RSTCHN1 V_RSTCHN1(1U)
-
-#define S_RSTCHN0 16
-#define V_RSTCHN0(x) ((x) << S_RSTCHN0)
-#define F_RSTCHN0 V_RSTCHN0(1U)
-
-#define S_UPDVLD 15
-#define V_UPDVLD(x) ((x) << S_UPDVLD)
-#define F_UPDVLD V_UPDVLD(1U)
-
-#define S_XOFF 14
-#define V_XOFF(x) ((x) << S_XOFF)
-#define F_XOFF V_XOFF(1U)
-
-#define S_UPDCHN3 13
-#define V_UPDCHN3(x) ((x) << S_UPDCHN3)
-#define F_UPDCHN3 V_UPDCHN3(1U)
-
-#define S_UPDCHN2 12
-#define V_UPDCHN2(x) ((x) << S_UPDCHN2)
-#define F_UPDCHN2 V_UPDCHN2(1U)
-
-#define S_UPDCHN1 11
-#define V_UPDCHN1(x) ((x) << S_UPDCHN1)
-#define F_UPDCHN1 V_UPDCHN1(1U)
-
-#define S_UPDCHN0 10
-#define V_UPDCHN0(x) ((x) << S_UPDCHN0)
-#define F_UPDCHN0 V_UPDCHN0(1U)
-
-#define S_QUEUE 0
-#define M_QUEUE 0x3ffU
-#define V_QUEUE(x) ((x) << S_QUEUE)
-#define G_QUEUE(x) (((x) >> S_QUEUE) & M_QUEUE)
-
-#define A_TP_LA_TABLE_0 0x7e10
-
-#define S_VIRTPORT1TABLE 16
-#define M_VIRTPORT1TABLE 0xffffU
-#define V_VIRTPORT1TABLE(x) ((x) << S_VIRTPORT1TABLE)
-#define G_VIRTPORT1TABLE(x) (((x) >> S_VIRTPORT1TABLE) & M_VIRTPORT1TABLE)
-
-#define S_VIRTPORT0TABLE 0
-#define M_VIRTPORT0TABLE 0xffffU
-#define V_VIRTPORT0TABLE(x) ((x) << S_VIRTPORT0TABLE)
-#define G_VIRTPORT0TABLE(x) (((x) >> S_VIRTPORT0TABLE) & M_VIRTPORT0TABLE)
-
-#define A_TP_LA_TABLE_1 0x7e14
-
-#define S_VIRTPORT3TABLE 16
-#define M_VIRTPORT3TABLE 0xffffU
-#define V_VIRTPORT3TABLE(x) ((x) << S_VIRTPORT3TABLE)
-#define G_VIRTPORT3TABLE(x) (((x) >> S_VIRTPORT3TABLE) & M_VIRTPORT3TABLE)
-
-#define S_VIRTPORT2TABLE 0
-#define M_VIRTPORT2TABLE 0xffffU
-#define V_VIRTPORT2TABLE(x) ((x) << S_VIRTPORT2TABLE)
-#define G_VIRTPORT2TABLE(x) (((x) >> S_VIRTPORT2TABLE) & M_VIRTPORT2TABLE)
-
-#define A_TP_TM_PIO_ADDR 0x7e18
-#define A_TP_TM_PIO_DATA 0x7e1c
-#define A_TP_MOD_CONFIG 0x7e24
-
-#define S_RXCHANNELWEIGHT1 24
-#define M_RXCHANNELWEIGHT1 0xffU
-#define V_RXCHANNELWEIGHT1(x) ((x) << S_RXCHANNELWEIGHT1)
-#define G_RXCHANNELWEIGHT1(x) (((x) >> S_RXCHANNELWEIGHT1) & M_RXCHANNELWEIGHT1)
-
-#define S_RXCHANNELWEIGHT0 16
-#define M_RXCHANNELWEIGHT0 0xffU
-#define V_RXCHANNELWEIGHT0(x) ((x) << S_RXCHANNELWEIGHT0)
-#define G_RXCHANNELWEIGHT0(x) (((x) >> S_RXCHANNELWEIGHT0) & M_RXCHANNELWEIGHT0)
-
-#define S_TIMERMODE 8
-#define M_TIMERMODE 0xffU
-#define V_TIMERMODE(x) ((x) << S_TIMERMODE)
-#define G_TIMERMODE(x) (((x) >> S_TIMERMODE) & M_TIMERMODE)
-
-#define S_TXCHANNELXOFFEN 0
-#define M_TXCHANNELXOFFEN 0xfU
-#define V_TXCHANNELXOFFEN(x) ((x) << S_TXCHANNELXOFFEN)
-#define G_TXCHANNELXOFFEN(x) (((x) >> S_TXCHANNELXOFFEN) & M_TXCHANNELXOFFEN)
-
-#define A_TP_TX_MOD_QUEUE_REQ_MAP 0x7e28
-
-#define S_RX_MOD_WEIGHT 24
-#define M_RX_MOD_WEIGHT 0xffU
-#define V_RX_MOD_WEIGHT(x) ((x) << S_RX_MOD_WEIGHT)
-#define G_RX_MOD_WEIGHT(x) (((x) >> S_RX_MOD_WEIGHT) & M_RX_MOD_WEIGHT)
-
-#define S_TX_MOD_WEIGHT 16
-#define M_TX_MOD_WEIGHT 0xffU
-#define V_TX_MOD_WEIGHT(x) ((x) << S_TX_MOD_WEIGHT)
-#define G_TX_MOD_WEIGHT(x) (((x) >> S_TX_MOD_WEIGHT) & M_TX_MOD_WEIGHT)
-
-#define S_TX_MOD_QUEUE_REQ_MAP 0
-#define M_TX_MOD_QUEUE_REQ_MAP 0xffffU
-#define V_TX_MOD_QUEUE_REQ_MAP(x) ((x) << S_TX_MOD_QUEUE_REQ_MAP)
-#define G_TX_MOD_QUEUE_REQ_MAP(x) (((x) >> S_TX_MOD_QUEUE_REQ_MAP) & M_TX_MOD_QUEUE_REQ_MAP)
-
-#define A_TP_TX_MOD_QUEUE_WEIGHT1 0x7e2c
-
-#define S_TX_MODQ_WEIGHT7 24
-#define M_TX_MODQ_WEIGHT7 0xffU
-#define V_TX_MODQ_WEIGHT7(x) ((x) << S_TX_MODQ_WEIGHT7)
-#define G_TX_MODQ_WEIGHT7(x) (((x) >> S_TX_MODQ_WEIGHT7) & M_TX_MODQ_WEIGHT7)
-
-#define S_TX_MODQ_WEIGHT6 16
-#define M_TX_MODQ_WEIGHT6 0xffU
-#define V_TX_MODQ_WEIGHT6(x) ((x) << S_TX_MODQ_WEIGHT6)
-#define G_TX_MODQ_WEIGHT6(x) (((x) >> S_TX_MODQ_WEIGHT6) & M_TX_MODQ_WEIGHT6)
-
-#define S_TX_MODQ_WEIGHT5 8
-#define M_TX_MODQ_WEIGHT5 0xffU
-#define V_TX_MODQ_WEIGHT5(x) ((x) << S_TX_MODQ_WEIGHT5)
-#define G_TX_MODQ_WEIGHT5(x) (((x) >> S_TX_MODQ_WEIGHT5) & M_TX_MODQ_WEIGHT5)
-
-#define S_TX_MODQ_WEIGHT4 0
-#define M_TX_MODQ_WEIGHT4 0xffU
-#define V_TX_MODQ_WEIGHT4(x) ((x) << S_TX_MODQ_WEIGHT4)
-#define G_TX_MODQ_WEIGHT4(x) (((x) >> S_TX_MODQ_WEIGHT4) & M_TX_MODQ_WEIGHT4)
-
-#define A_TP_TX_MOD_QUEUE_WEIGHT0 0x7e30
-
-#define S_TX_MODQ_WEIGHT3 24
-#define M_TX_MODQ_WEIGHT3 0xffU
-#define V_TX_MODQ_WEIGHT3(x) ((x) << S_TX_MODQ_WEIGHT3)
-#define G_TX_MODQ_WEIGHT3(x) (((x) >> S_TX_MODQ_WEIGHT3) & M_TX_MODQ_WEIGHT3)
-
-#define S_TX_MODQ_WEIGHT2 16
-#define M_TX_MODQ_WEIGHT2 0xffU
-#define V_TX_MODQ_WEIGHT2(x) ((x) << S_TX_MODQ_WEIGHT2)
-#define G_TX_MODQ_WEIGHT2(x) (((x) >> S_TX_MODQ_WEIGHT2) & M_TX_MODQ_WEIGHT2)
-
-#define S_TX_MODQ_WEIGHT1 8
-#define M_TX_MODQ_WEIGHT1 0xffU
-#define V_TX_MODQ_WEIGHT1(x) ((x) << S_TX_MODQ_WEIGHT1)
-#define G_TX_MODQ_WEIGHT1(x) (((x) >> S_TX_MODQ_WEIGHT1) & M_TX_MODQ_WEIGHT1)
-
-#define S_TX_MODQ_WEIGHT0 0
-#define M_TX_MODQ_WEIGHT0 0xffU
-#define V_TX_MODQ_WEIGHT0(x) ((x) << S_TX_MODQ_WEIGHT0)
-#define G_TX_MODQ_WEIGHT0(x) (((x) >> S_TX_MODQ_WEIGHT0) & M_TX_MODQ_WEIGHT0)
-
-#define A_TP_TX_MOD_CHANNEL_WEIGHT 0x7e34
-#define A_TP_MOD_RATE_LIMIT 0x7e38
-
-#define S_RX_MOD_RATE_LIMIT_INC 24
-#define M_RX_MOD_RATE_LIMIT_INC 0xffU
-#define V_RX_MOD_RATE_LIMIT_INC(x) ((x) << S_RX_MOD_RATE_LIMIT_INC)
-#define G_RX_MOD_RATE_LIMIT_INC(x) (((x) >> S_RX_MOD_RATE_LIMIT_INC) & M_RX_MOD_RATE_LIMIT_INC)
-
-#define S_RX_MOD_RATE_LIMIT_TICK 16
-#define M_RX_MOD_RATE_LIMIT_TICK 0xffU
-#define V_RX_MOD_RATE_LIMIT_TICK(x) ((x) << S_RX_MOD_RATE_LIMIT_TICK)
-#define G_RX_MOD_RATE_LIMIT_TICK(x) (((x) >> S_RX_MOD_RATE_LIMIT_TICK) & M_RX_MOD_RATE_LIMIT_TICK)
-
-#define S_TX_MOD_RATE_LIMIT_INC 8
-#define M_TX_MOD_RATE_LIMIT_INC 0xffU
-#define V_TX_MOD_RATE_LIMIT_INC(x) ((x) << S_TX_MOD_RATE_LIMIT_INC)
-#define G_TX_MOD_RATE_LIMIT_INC(x) (((x) >> S_TX_MOD_RATE_LIMIT_INC) & M_TX_MOD_RATE_LIMIT_INC)
-
-#define S_TX_MOD_RATE_LIMIT_TICK 0
-#define M_TX_MOD_RATE_LIMIT_TICK 0xffU
-#define V_TX_MOD_RATE_LIMIT_TICK(x) ((x) << S_TX_MOD_RATE_LIMIT_TICK)
-#define G_TX_MOD_RATE_LIMIT_TICK(x) (((x) >> S_TX_MOD_RATE_LIMIT_TICK) & M_TX_MOD_RATE_LIMIT_TICK)
-
-#define A_TP_PIO_ADDR 0x7e40
-#define A_TP_PIO_DATA 0x7e44
-#define A_TP_RESET 0x7e4c
-
-#define S_FLSTINITENABLE 1
-#define V_FLSTINITENABLE(x) ((x) << S_FLSTINITENABLE)
-#define F_FLSTINITENABLE V_FLSTINITENABLE(1U)
-
-#define S_TPRESET 0
-#define V_TPRESET(x) ((x) << S_TPRESET)
-#define F_TPRESET V_TPRESET(1U)
-
-#define A_TP_MIB_INDEX 0x7e50
-#define A_TP_MIB_DATA 0x7e54
-#define A_TP_SYNC_TIME_HI 0x7e58
-#define A_TP_SYNC_TIME_LO 0x7e5c
-#define A_TP_CMM_MM_RX_FLST_BASE 0x7e60
-#define A_TP_CMM_MM_TX_FLST_BASE 0x7e64
-#define A_TP_CMM_MM_PS_FLST_BASE 0x7e68
-#define A_TP_CMM_MM_MAX_PSTRUCT 0x7e6c
-
-#define S_CMMAXPSTRUCT 0
-#define M_CMMAXPSTRUCT 0x1fffffU
-#define V_CMMAXPSTRUCT(x) ((x) << S_CMMAXPSTRUCT)
-#define G_CMMAXPSTRUCT(x) (((x) >> S_CMMAXPSTRUCT) & M_CMMAXPSTRUCT)
-
-#define A_TP_INT_ENABLE 0x7e70
-
-#define S_FLMTXFLSTEMPTY 30
-#define V_FLMTXFLSTEMPTY(x) ((x) << S_FLMTXFLSTEMPTY)
-#define F_FLMTXFLSTEMPTY V_FLMTXFLSTEMPTY(1U)
-
-#define S_RSSLKPPERR 29
-#define V_RSSLKPPERR(x) ((x) << S_RSSLKPPERR)
-#define F_RSSLKPPERR V_RSSLKPPERR(1U)
-
-#define S_FLMPERRSET 28
-#define V_FLMPERRSET(x) ((x) << S_FLMPERRSET)
-#define F_FLMPERRSET V_FLMPERRSET(1U)
-
-#define S_PROTOCOLSRAMPERR 27
-#define V_PROTOCOLSRAMPERR(x) ((x) << S_PROTOCOLSRAMPERR)
-#define F_PROTOCOLSRAMPERR V_PROTOCOLSRAMPERR(1U)
-
-#define S_ARPLUTPERR 26
-#define V_ARPLUTPERR(x) ((x) << S_ARPLUTPERR)
-#define F_ARPLUTPERR V_ARPLUTPERR(1U)
-
-#define S_CMRCFOPPERR 25
-#define V_CMRCFOPPERR(x) ((x) << S_CMRCFOPPERR)
-#define F_CMRCFOPPERR V_CMRCFOPPERR(1U)
-
-#define S_CMCACHEPERR 24
-#define V_CMCACHEPERR(x) ((x) << S_CMCACHEPERR)
-#define F_CMCACHEPERR V_CMCACHEPERR(1U)
-
-#define S_CMRCFDATAPERR 23
-#define V_CMRCFDATAPERR(x) ((x) << S_CMRCFDATAPERR)
-#define F_CMRCFDATAPERR V_CMRCFDATAPERR(1U)
-
-#define S_DBL2TLUTPERR 22
-#define V_DBL2TLUTPERR(x) ((x) << S_DBL2TLUTPERR)
-#define F_DBL2TLUTPERR V_DBL2TLUTPERR(1U)
-
-#define S_DBTXTIDPERR 21
-#define V_DBTXTIDPERR(x) ((x) << S_DBTXTIDPERR)
-#define F_DBTXTIDPERR V_DBTXTIDPERR(1U)
-
-#define S_DBEXTPERR 20
-#define V_DBEXTPERR(x) ((x) << S_DBEXTPERR)
-#define F_DBEXTPERR V_DBEXTPERR(1U)
-
-#define S_DBOPPERR 19
-#define V_DBOPPERR(x) ((x) << S_DBOPPERR)
-#define F_DBOPPERR V_DBOPPERR(1U)
-
-#define S_TMCACHEPERR 18
-#define V_TMCACHEPERR(x) ((x) << S_TMCACHEPERR)
-#define F_TMCACHEPERR V_TMCACHEPERR(1U)
-
-#define S_ETPOUTCPLFIFOPERR 17
-#define V_ETPOUTCPLFIFOPERR(x) ((x) << S_ETPOUTCPLFIFOPERR)
-#define F_ETPOUTCPLFIFOPERR V_ETPOUTCPLFIFOPERR(1U)
-
-#define S_ETPOUTTCPFIFOPERR 16
-#define V_ETPOUTTCPFIFOPERR(x) ((x) << S_ETPOUTTCPFIFOPERR)
-#define F_ETPOUTTCPFIFOPERR V_ETPOUTTCPFIFOPERR(1U)
-
-#define S_ETPOUTIPFIFOPERR 15
-#define V_ETPOUTIPFIFOPERR(x) ((x) << S_ETPOUTIPFIFOPERR)
-#define F_ETPOUTIPFIFOPERR V_ETPOUTIPFIFOPERR(1U)
-
-#define S_ETPOUTETHFIFOPERR 14
-#define V_ETPOUTETHFIFOPERR(x) ((x) << S_ETPOUTETHFIFOPERR)
-#define F_ETPOUTETHFIFOPERR V_ETPOUTETHFIFOPERR(1U)
-
-#define S_ETPINCPLFIFOPERR 13
-#define V_ETPINCPLFIFOPERR(x) ((x) << S_ETPINCPLFIFOPERR)
-#define F_ETPINCPLFIFOPERR V_ETPINCPLFIFOPERR(1U)
-
-#define S_ETPINTCPOPTFIFOPERR 12
-#define V_ETPINTCPOPTFIFOPERR(x) ((x) << S_ETPINTCPOPTFIFOPERR)
-#define F_ETPINTCPOPTFIFOPERR V_ETPINTCPOPTFIFOPERR(1U)
-
-#define S_ETPINTCPFIFOPERR 11
-#define V_ETPINTCPFIFOPERR(x) ((x) << S_ETPINTCPFIFOPERR)
-#define F_ETPINTCPFIFOPERR V_ETPINTCPFIFOPERR(1U)
-
-#define S_ETPINIPFIFOPERR 10
-#define V_ETPINIPFIFOPERR(x) ((x) << S_ETPINIPFIFOPERR)
-#define F_ETPINIPFIFOPERR V_ETPINIPFIFOPERR(1U)
-
-#define S_ETPINETHFIFOPERR 9
-#define V_ETPINETHFIFOPERR(x) ((x) << S_ETPINETHFIFOPERR)
-#define F_ETPINETHFIFOPERR V_ETPINETHFIFOPERR(1U)
-
-#define S_CTPOUTCPLFIFOPERR 8
-#define V_CTPOUTCPLFIFOPERR(x) ((x) << S_CTPOUTCPLFIFOPERR)
-#define F_CTPOUTCPLFIFOPERR V_CTPOUTCPLFIFOPERR(1U)
-
-#define S_CTPOUTTCPFIFOPERR 7
-#define V_CTPOUTTCPFIFOPERR(x) ((x) << S_CTPOUTTCPFIFOPERR)
-#define F_CTPOUTTCPFIFOPERR V_CTPOUTTCPFIFOPERR(1U)
-
-#define S_CTPOUTIPFIFOPERR 6
-#define V_CTPOUTIPFIFOPERR(x) ((x) << S_CTPOUTIPFIFOPERR)
-#define F_CTPOUTIPFIFOPERR V_CTPOUTIPFIFOPERR(1U)
-
-#define S_CTPOUTETHFIFOPERR 5
-#define V_CTPOUTETHFIFOPERR(x) ((x) << S_CTPOUTETHFIFOPERR)
-#define F_CTPOUTETHFIFOPERR V_CTPOUTETHFIFOPERR(1U)
-
-#define S_CTPINCPLFIFOPERR 4
-#define V_CTPINCPLFIFOPERR(x) ((x) << S_CTPINCPLFIFOPERR)
-#define F_CTPINCPLFIFOPERR V_CTPINCPLFIFOPERR(1U)
-
-#define S_CTPINTCPOPFIFOPERR 3
-#define V_CTPINTCPOPFIFOPERR(x) ((x) << S_CTPINTCPOPFIFOPERR)
-#define F_CTPINTCPOPFIFOPERR V_CTPINTCPOPFIFOPERR(1U)
-
-#define S_PDUFBKFIFOPERR 2
-#define V_PDUFBKFIFOPERR(x) ((x) << S_PDUFBKFIFOPERR)
-#define F_PDUFBKFIFOPERR V_PDUFBKFIFOPERR(1U)
-
-#define S_CMOPEXTFIFOPERR 1
-#define V_CMOPEXTFIFOPERR(x) ((x) << S_CMOPEXTFIFOPERR)
-#define F_CMOPEXTFIFOPERR V_CMOPEXTFIFOPERR(1U)
-
-#define S_DELINVFIFOPERR 0
-#define V_DELINVFIFOPERR(x) ((x) << S_DELINVFIFOPERR)
-#define F_DELINVFIFOPERR V_DELINVFIFOPERR(1U)
-
-#define S_CTPOUTPLDFIFOPERR 7
-#define V_CTPOUTPLDFIFOPERR(x) ((x) << S_CTPOUTPLDFIFOPERR)
-#define F_CTPOUTPLDFIFOPERR V_CTPOUTPLDFIFOPERR(1U)
-
-#define S_SRQTABLEPERR 1
-#define V_SRQTABLEPERR(x) ((x) << S_SRQTABLEPERR)
-#define F_SRQTABLEPERR V_SRQTABLEPERR(1U)
-
-#define A_TP_INT_CAUSE 0x7e74
-#define A_TP_PER_ENABLE 0x7e78
-#define A_TP_FLM_FREE_PS_CNT 0x7e80
-
-#define S_FREEPSTRUCTCOUNT 0
-#define M_FREEPSTRUCTCOUNT 0x1fffffU
-#define V_FREEPSTRUCTCOUNT(x) ((x) << S_FREEPSTRUCTCOUNT)
-#define G_FREEPSTRUCTCOUNT(x) (((x) >> S_FREEPSTRUCTCOUNT) & M_FREEPSTRUCTCOUNT)
-
-#define A_TP_FLM_FREE_RX_CNT 0x7e84
-
-#define S_FREERXPAGECHN 28
-#define V_FREERXPAGECHN(x) ((x) << S_FREERXPAGECHN)
-#define F_FREERXPAGECHN V_FREERXPAGECHN(1U)
-
-#define S_FREERXPAGECOUNT 0
-#define M_FREERXPAGECOUNT 0x1fffffU
-#define V_FREERXPAGECOUNT(x) ((x) << S_FREERXPAGECOUNT)
-#define G_FREERXPAGECOUNT(x) (((x) >> S_FREERXPAGECOUNT) & M_FREERXPAGECOUNT)
-
-#define A_TP_FLM_FREE_TX_CNT 0x7e88
-
-#define S_FREETXPAGECHN 28
-#define M_FREETXPAGECHN 0x3U
-#define V_FREETXPAGECHN(x) ((x) << S_FREETXPAGECHN)
-#define G_FREETXPAGECHN(x) (((x) >> S_FREETXPAGECHN) & M_FREETXPAGECHN)
-
-#define S_FREETXPAGECOUNT 0
-#define M_FREETXPAGECOUNT 0x1fffffU
-#define V_FREETXPAGECOUNT(x) ((x) << S_FREETXPAGECOUNT)
-#define G_FREETXPAGECOUNT(x) (((x) >> S_FREETXPAGECOUNT) & M_FREETXPAGECOUNT)
-
-#define A_TP_TM_HEAP_PUSH_CNT 0x7e8c
-#define A_TP_TM_HEAP_POP_CNT 0x7e90
-#define A_TP_TM_DACK_PUSH_CNT 0x7e94
-#define A_TP_TM_DACK_POP_CNT 0x7e98
-#define A_TP_TM_MOD_PUSH_CNT 0x7e9c
-#define A_TP_MOD_POP_CNT 0x7ea0
-#define A_TP_TIMER_SEPARATOR 0x7ea4
-
-#define S_TIMERSEPARATOR 16
-#define M_TIMERSEPARATOR 0xffffU
-#define V_TIMERSEPARATOR(x) ((x) << S_TIMERSEPARATOR)
-#define G_TIMERSEPARATOR(x) (((x) >> S_TIMERSEPARATOR) & M_TIMERSEPARATOR)
-
-#define S_DISABLETIMEFREEZE 0
-#define V_DISABLETIMEFREEZE(x) ((x) << S_DISABLETIMEFREEZE)
-#define F_DISABLETIMEFREEZE V_DISABLETIMEFREEZE(1U)
-
-#define A_TP_STAMP_TIME 0x7ea8
-#define A_TP_DEBUG_FLAGS 0x7eac
-
-#define S_RXTIMERDACKFIRST 26
-#define V_RXTIMERDACKFIRST(x) ((x) << S_RXTIMERDACKFIRST)
-#define F_RXTIMERDACKFIRST V_RXTIMERDACKFIRST(1U)
-
-#define S_RXTIMERDACK 25
-#define V_RXTIMERDACK(x) ((x) << S_RXTIMERDACK)
-#define F_RXTIMERDACK V_RXTIMERDACK(1U)
-
-#define S_RXTIMERHEARTBEAT 24
-#define V_RXTIMERHEARTBEAT(x) ((x) << S_RXTIMERHEARTBEAT)
-#define F_RXTIMERHEARTBEAT V_RXTIMERHEARTBEAT(1U)
-
-#define S_RXPAWSDROP 23
-#define V_RXPAWSDROP(x) ((x) << S_RXPAWSDROP)
-#define F_RXPAWSDROP V_RXPAWSDROP(1U)
-
-#define S_RXURGDATADROP 22
-#define V_RXURGDATADROP(x) ((x) << S_RXURGDATADROP)
-#define F_RXURGDATADROP V_RXURGDATADROP(1U)
-
-#define S_RXFUTUREDATA 21
-#define V_RXFUTUREDATA(x) ((x) << S_RXFUTUREDATA)
-#define F_RXFUTUREDATA V_RXFUTUREDATA(1U)
-
-#define S_RXRCVRXMDATA 20
-#define V_RXRCVRXMDATA(x) ((x) << S_RXRCVRXMDATA)
-#define F_RXRCVRXMDATA V_RXRCVRXMDATA(1U)
-
-#define S_RXRCVOOODATAFIN 19
-#define V_RXRCVOOODATAFIN(x) ((x) << S_RXRCVOOODATAFIN)
-#define F_RXRCVOOODATAFIN V_RXRCVOOODATAFIN(1U)
-
-#define S_RXRCVOOODATA 18
-#define V_RXRCVOOODATA(x) ((x) << S_RXRCVOOODATA)
-#define F_RXRCVOOODATA V_RXRCVOOODATA(1U)
-
-#define S_RXRCVWNDZERO 17
-#define V_RXRCVWNDZERO(x) ((x) << S_RXRCVWNDZERO)
-#define F_RXRCVWNDZERO V_RXRCVWNDZERO(1U)
-
-#define S_RXRCVWNDLTMSS 16
-#define V_RXRCVWNDLTMSS(x) ((x) << S_RXRCVWNDLTMSS)
-#define F_RXRCVWNDLTMSS V_RXRCVWNDLTMSS(1U)
-
-#define S_TXDUPACKINC 11
-#define V_TXDUPACKINC(x) ((x) << S_TXDUPACKINC)
-#define F_TXDUPACKINC V_TXDUPACKINC(1U)
-
-#define S_TXRXMURG 10
-#define V_TXRXMURG(x) ((x) << S_TXRXMURG)
-#define F_TXRXMURG V_TXRXMURG(1U)
-
-#define S_TXRXMFIN 9
-#define V_TXRXMFIN(x) ((x) << S_TXRXMFIN)
-#define F_TXRXMFIN V_TXRXMFIN(1U)
-
-#define S_TXRXMSYN 8
-#define V_TXRXMSYN(x) ((x) << S_TXRXMSYN)
-#define F_TXRXMSYN V_TXRXMSYN(1U)
-
-#define S_TXRXMNEWRENO 7
-#define V_TXRXMNEWRENO(x) ((x) << S_TXRXMNEWRENO)
-#define F_TXRXMNEWRENO V_TXRXMNEWRENO(1U)
-
-#define S_TXRXMFAST 6
-#define V_TXRXMFAST(x) ((x) << S_TXRXMFAST)
-#define F_TXRXMFAST V_TXRXMFAST(1U)
-
-#define S_TXRXMTIMER 5
-#define V_TXRXMTIMER(x) ((x) << S_TXRXMTIMER)
-#define F_TXRXMTIMER V_TXRXMTIMER(1U)
-
-#define S_TXRXMTIMERKEEPALIVE 4
-#define V_TXRXMTIMERKEEPALIVE(x) ((x) << S_TXRXMTIMERKEEPALIVE)
-#define F_TXRXMTIMERKEEPALIVE V_TXRXMTIMERKEEPALIVE(1U)
-
-#define S_TXRXMTIMERPERSIST 3
-#define V_TXRXMTIMERPERSIST(x) ((x) << S_TXRXMTIMERPERSIST)
-#define F_TXRXMTIMERPERSIST V_TXRXMTIMERPERSIST(1U)
-
-#define S_TXRCVADVSHRUNK 2
-#define V_TXRCVADVSHRUNK(x) ((x) << S_TXRCVADVSHRUNK)
-#define F_TXRCVADVSHRUNK V_TXRCVADVSHRUNK(1U)
-
-#define S_TXRCVADVZERO 1
-#define V_TXRCVADVZERO(x) ((x) << S_TXRCVADVZERO)
-#define F_TXRCVADVZERO V_TXRCVADVZERO(1U)
-
-#define S_TXRCVADVLTMSS 0
-#define V_TXRCVADVLTMSS(x) ((x) << S_TXRCVADVLTMSS)
-#define F_TXRCVADVLTMSS V_TXRCVADVLTMSS(1U)
-
-#define S_RXTIMERCOMPBUFFER 27
-#define V_RXTIMERCOMPBUFFER(x) ((x) << S_RXTIMERCOMPBUFFER)
-#define F_RXTIMERCOMPBUFFER V_RXTIMERCOMPBUFFER(1U)
-
-#define S_TXDFRFAST 13
-#define V_TXDFRFAST(x) ((x) << S_TXDFRFAST)
-#define F_TXDFRFAST V_TXDFRFAST(1U)
-
-#define S_TXRXMMISC 12
-#define V_TXRXMMISC(x) ((x) << S_TXRXMMISC)
-#define F_TXRXMMISC V_TXRXMMISC(1U)
-
-#define A_TP_RX_SCHED 0x7eb0
-
-#define S_RXCOMMITRESET1 31
-#define V_RXCOMMITRESET1(x) ((x) << S_RXCOMMITRESET1)
-#define F_RXCOMMITRESET1 V_RXCOMMITRESET1(1U)
-
-#define S_RXCOMMITRESET0 30
-#define V_RXCOMMITRESET0(x) ((x) << S_RXCOMMITRESET0)
-#define F_RXCOMMITRESET0 V_RXCOMMITRESET0(1U)
-
-#define S_RXFORCECONG1 29
-#define V_RXFORCECONG1(x) ((x) << S_RXFORCECONG1)
-#define F_RXFORCECONG1 V_RXFORCECONG1(1U)
-
-#define S_RXFORCECONG0 28
-#define V_RXFORCECONG0(x) ((x) << S_RXFORCECONG0)
-#define F_RXFORCECONG0 V_RXFORCECONG0(1U)
-
-#define S_ENABLELPBKFULL1 26
-#define M_ENABLELPBKFULL1 0x3U
-#define V_ENABLELPBKFULL1(x) ((x) << S_ENABLELPBKFULL1)
-#define G_ENABLELPBKFULL1(x) (((x) >> S_ENABLELPBKFULL1) & M_ENABLELPBKFULL1)
-
-#define S_ENABLELPBKFULL0 24
-#define M_ENABLELPBKFULL0 0x3U
-#define V_ENABLELPBKFULL0(x) ((x) << S_ENABLELPBKFULL0)
-#define G_ENABLELPBKFULL0(x) (((x) >> S_ENABLELPBKFULL0) & M_ENABLELPBKFULL0)
-
-#define S_ENABLEFIFOFULL1 22
-#define M_ENABLEFIFOFULL1 0x3U
-#define V_ENABLEFIFOFULL1(x) ((x) << S_ENABLEFIFOFULL1)
-#define G_ENABLEFIFOFULL1(x) (((x) >> S_ENABLEFIFOFULL1) & M_ENABLEFIFOFULL1)
-
-#define S_ENABLEPCMDFULL1 20
-#define M_ENABLEPCMDFULL1 0x3U
-#define V_ENABLEPCMDFULL1(x) ((x) << S_ENABLEPCMDFULL1)
-#define G_ENABLEPCMDFULL1(x) (((x) >> S_ENABLEPCMDFULL1) & M_ENABLEPCMDFULL1)
-
-#define S_ENABLEHDRFULL1 18
-#define M_ENABLEHDRFULL1 0x3U
-#define V_ENABLEHDRFULL1(x) ((x) << S_ENABLEHDRFULL1)
-#define G_ENABLEHDRFULL1(x) (((x) >> S_ENABLEHDRFULL1) & M_ENABLEHDRFULL1)
-
-#define S_ENABLEFIFOFULL0 16
-#define M_ENABLEFIFOFULL0 0x3U
-#define V_ENABLEFIFOFULL0(x) ((x) << S_ENABLEFIFOFULL0)
-#define G_ENABLEFIFOFULL0(x) (((x) >> S_ENABLEFIFOFULL0) & M_ENABLEFIFOFULL0)
-
-#define S_ENABLEPCMDFULL0 14
-#define M_ENABLEPCMDFULL0 0x3U
-#define V_ENABLEPCMDFULL0(x) ((x) << S_ENABLEPCMDFULL0)
-#define G_ENABLEPCMDFULL0(x) (((x) >> S_ENABLEPCMDFULL0) & M_ENABLEPCMDFULL0)
-
-#define S_ENABLEHDRFULL0 12
-#define M_ENABLEHDRFULL0 0x3U
-#define V_ENABLEHDRFULL0(x) ((x) << S_ENABLEHDRFULL0)
-#define G_ENABLEHDRFULL0(x) (((x) >> S_ENABLEHDRFULL0) & M_ENABLEHDRFULL0)
-
-#define S_COMMITLIMIT1 6
-#define M_COMMITLIMIT1 0x3fU
-#define V_COMMITLIMIT1(x) ((x) << S_COMMITLIMIT1)
-#define G_COMMITLIMIT1(x) (((x) >> S_COMMITLIMIT1) & M_COMMITLIMIT1)
-
-#define S_COMMITLIMIT0 0
-#define M_COMMITLIMIT0 0x3fU
-#define V_COMMITLIMIT0(x) ((x) << S_COMMITLIMIT0)
-#define G_COMMITLIMIT0(x) (((x) >> S_COMMITLIMIT0) & M_COMMITLIMIT0)
-
-#define A_TP_TX_SCHED 0x7eb4
-
-#define S_COMMITRESET3 31
-#define V_COMMITRESET3(x) ((x) << S_COMMITRESET3)
-#define F_COMMITRESET3 V_COMMITRESET3(1U)
-
-#define S_COMMITRESET2 30
-#define V_COMMITRESET2(x) ((x) << S_COMMITRESET2)
-#define F_COMMITRESET2 V_COMMITRESET2(1U)
-
-#define S_COMMITRESET1 29
-#define V_COMMITRESET1(x) ((x) << S_COMMITRESET1)
-#define F_COMMITRESET1 V_COMMITRESET1(1U)
-
-#define S_COMMITRESET0 28
-#define V_COMMITRESET0(x) ((x) << S_COMMITRESET0)
-#define F_COMMITRESET0 V_COMMITRESET0(1U)
-
-#define S_FORCECONG3 27
-#define V_FORCECONG3(x) ((x) << S_FORCECONG3)
-#define F_FORCECONG3 V_FORCECONG3(1U)
-
-#define S_FORCECONG2 26
-#define V_FORCECONG2(x) ((x) << S_FORCECONG2)
-#define F_FORCECONG2 V_FORCECONG2(1U)
-
-#define S_FORCECONG1 25
-#define V_FORCECONG1(x) ((x) << S_FORCECONG1)
-#define F_FORCECONG1 V_FORCECONG1(1U)
-
-#define S_FORCECONG0 24
-#define V_FORCECONG0(x) ((x) << S_FORCECONG0)
-#define F_FORCECONG0 V_FORCECONG0(1U)
-
-#define S_COMMITLIMIT3 18
-#define M_COMMITLIMIT3 0x3fU
-#define V_COMMITLIMIT3(x) ((x) << S_COMMITLIMIT3)
-#define G_COMMITLIMIT3(x) (((x) >> S_COMMITLIMIT3) & M_COMMITLIMIT3)
-
-#define S_COMMITLIMIT2 12
-#define M_COMMITLIMIT2 0x3fU
-#define V_COMMITLIMIT2(x) ((x) << S_COMMITLIMIT2)
-#define G_COMMITLIMIT2(x) (((x) >> S_COMMITLIMIT2) & M_COMMITLIMIT2)
-
-#define A_TP_FX_SCHED 0x7eb8
-
-#define S_TXCHNXOFF3 19
-#define V_TXCHNXOFF3(x) ((x) << S_TXCHNXOFF3)
-#define F_TXCHNXOFF3 V_TXCHNXOFF3(1U)
-
-#define S_TXCHNXOFF2 18
-#define V_TXCHNXOFF2(x) ((x) << S_TXCHNXOFF2)
-#define F_TXCHNXOFF2 V_TXCHNXOFF2(1U)
-
-#define S_TXCHNXOFF1 17
-#define V_TXCHNXOFF1(x) ((x) << S_TXCHNXOFF1)
-#define F_TXCHNXOFF1 V_TXCHNXOFF1(1U)
-
-#define S_TXCHNXOFF0 16
-#define V_TXCHNXOFF0(x) ((x) << S_TXCHNXOFF0)
-#define F_TXCHNXOFF0 V_TXCHNXOFF0(1U)
-
-#define S_TXMODXOFF7 15
-#define V_TXMODXOFF7(x) ((x) << S_TXMODXOFF7)
-#define F_TXMODXOFF7 V_TXMODXOFF7(1U)
-
-#define S_TXMODXOFF6 14
-#define V_TXMODXOFF6(x) ((x) << S_TXMODXOFF6)
-#define F_TXMODXOFF6 V_TXMODXOFF6(1U)
-
-#define S_TXMODXOFF5 13
-#define V_TXMODXOFF5(x) ((x) << S_TXMODXOFF5)
-#define F_TXMODXOFF5 V_TXMODXOFF5(1U)
-
-#define S_TXMODXOFF4 12
-#define V_TXMODXOFF4(x) ((x) << S_TXMODXOFF4)
-#define F_TXMODXOFF4 V_TXMODXOFF4(1U)
-
-#define S_TXMODXOFF3 11
-#define V_TXMODXOFF3(x) ((x) << S_TXMODXOFF3)
-#define F_TXMODXOFF3 V_TXMODXOFF3(1U)
-
-#define S_TXMODXOFF2 10
-#define V_TXMODXOFF2(x) ((x) << S_TXMODXOFF2)
-#define F_TXMODXOFF2 V_TXMODXOFF2(1U)
-
-#define S_TXMODXOFF1 9
-#define V_TXMODXOFF1(x) ((x) << S_TXMODXOFF1)
-#define F_TXMODXOFF1 V_TXMODXOFF1(1U)
-
-#define S_TXMODXOFF0 8
-#define V_TXMODXOFF0(x) ((x) << S_TXMODXOFF0)
-#define F_TXMODXOFF0 V_TXMODXOFF0(1U)
-
-#define S_RXCHNXOFF3 7
-#define V_RXCHNXOFF3(x) ((x) << S_RXCHNXOFF3)
-#define F_RXCHNXOFF3 V_RXCHNXOFF3(1U)
-
-#define S_RXCHNXOFF2 6
-#define V_RXCHNXOFF2(x) ((x) << S_RXCHNXOFF2)
-#define F_RXCHNXOFF2 V_RXCHNXOFF2(1U)
-
-#define S_RXCHNXOFF1 5
-#define V_RXCHNXOFF1(x) ((x) << S_RXCHNXOFF1)
-#define F_RXCHNXOFF1 V_RXCHNXOFF1(1U)
-
-#define S_RXCHNXOFF0 4
-#define V_RXCHNXOFF0(x) ((x) << S_RXCHNXOFF0)
-#define F_RXCHNXOFF0 V_RXCHNXOFF0(1U)
-
-#define S_RXMODXOFF1 1
-#define V_RXMODXOFF1(x) ((x) << S_RXMODXOFF1)
-#define F_RXMODXOFF1 V_RXMODXOFF1(1U)
-
-#define S_RXMODXOFF0 0
-#define V_RXMODXOFF0(x) ((x) << S_RXMODXOFF0)
-#define F_RXMODXOFF0 V_RXMODXOFF0(1U)
-
-#define A_TP_TX_ORATE 0x7ebc
-
-#define S_OFDRATE3 24
-#define M_OFDRATE3 0xffU
-#define V_OFDRATE3(x) ((x) << S_OFDRATE3)
-#define G_OFDRATE3(x) (((x) >> S_OFDRATE3) & M_OFDRATE3)
-
-#define S_OFDRATE2 16
-#define M_OFDRATE2 0xffU
-#define V_OFDRATE2(x) ((x) << S_OFDRATE2)
-#define G_OFDRATE2(x) (((x) >> S_OFDRATE2) & M_OFDRATE2)
-
-#define S_OFDRATE1 8
-#define M_OFDRATE1 0xffU
-#define V_OFDRATE1(x) ((x) << S_OFDRATE1)
-#define G_OFDRATE1(x) (((x) >> S_OFDRATE1) & M_OFDRATE1)
-
-#define S_OFDRATE0 0
-#define M_OFDRATE0 0xffU
-#define V_OFDRATE0(x) ((x) << S_OFDRATE0)
-#define G_OFDRATE0(x) (((x) >> S_OFDRATE0) & M_OFDRATE0)
-
-#define A_TP_IX_SCHED0 0x7ec0
-#define A_TP_IX_SCHED1 0x7ec4
-#define A_TP_IX_SCHED2 0x7ec8
-#define A_TP_IX_SCHED3 0x7ecc
-#define A_TP_TX_TRATE 0x7ed0
-
-#define S_TNLRATE3 24
-#define M_TNLRATE3 0xffU
-#define V_TNLRATE3(x) ((x) << S_TNLRATE3)
-#define G_TNLRATE3(x) (((x) >> S_TNLRATE3) & M_TNLRATE3)
-
-#define S_TNLRATE2 16
-#define M_TNLRATE2 0xffU
-#define V_TNLRATE2(x) ((x) << S_TNLRATE2)
-#define G_TNLRATE2(x) (((x) >> S_TNLRATE2) & M_TNLRATE2)
-
-#define S_TNLRATE1 8
-#define M_TNLRATE1 0xffU
-#define V_TNLRATE1(x) ((x) << S_TNLRATE1)
-#define G_TNLRATE1(x) (((x) >> S_TNLRATE1) & M_TNLRATE1)
-
-#define S_TNLRATE0 0
-#define M_TNLRATE0 0xffU
-#define V_TNLRATE0(x) ((x) << S_TNLRATE0)
-#define G_TNLRATE0(x) (((x) >> S_TNLRATE0) & M_TNLRATE0)
-
-#define A_TP_DBG_LA_CONFIG 0x7ed4
-
-#define S_DBGLAOPCENABLE 24
-#define M_DBGLAOPCENABLE 0xffU
-#define V_DBGLAOPCENABLE(x) ((x) << S_DBGLAOPCENABLE)
-#define G_DBGLAOPCENABLE(x) (((x) >> S_DBGLAOPCENABLE) & M_DBGLAOPCENABLE)
-
-#define S_DBGLAWHLF 23
-#define V_DBGLAWHLF(x) ((x) << S_DBGLAWHLF)
-#define F_DBGLAWHLF V_DBGLAWHLF(1U)
-
-#define S_DBGLAWPTR 16
-#define M_DBGLAWPTR 0x7fU
-#define V_DBGLAWPTR(x) ((x) << S_DBGLAWPTR)
-#define G_DBGLAWPTR(x) (((x) >> S_DBGLAWPTR) & M_DBGLAWPTR)
-
-#define S_DBGLAMODE 14
-#define M_DBGLAMODE 0x3U
-#define V_DBGLAMODE(x) ((x) << S_DBGLAMODE)
-#define G_DBGLAMODE(x) (((x) >> S_DBGLAMODE) & M_DBGLAMODE)
-
-#define S_DBGLAFATALFREEZE 13
-#define V_DBGLAFATALFREEZE(x) ((x) << S_DBGLAFATALFREEZE)
-#define F_DBGLAFATALFREEZE V_DBGLAFATALFREEZE(1U)
-
-#define S_DBGLAENABLE 12
-#define V_DBGLAENABLE(x) ((x) << S_DBGLAENABLE)
-#define F_DBGLAENABLE V_DBGLAENABLE(1U)
-
-#define S_DBGLARPTR 0
-#define M_DBGLARPTR 0x7fU
-#define V_DBGLARPTR(x) ((x) << S_DBGLARPTR)
-#define G_DBGLARPTR(x) (((x) >> S_DBGLARPTR) & M_DBGLARPTR)
-
-#define A_TP_DBG_LA_DATAL 0x7ed8
-#define A_TP_DBG_LA_DATAH 0x7edc
-#define A_TP_PROTOCOL_CNTRL 0x7ee8
-
-#define S_WRITEENABLE 31
-#define V_WRITEENABLE(x) ((x) << S_WRITEENABLE)
-#define F_WRITEENABLE V_WRITEENABLE(1U)
-
-#define S_TCAMENABLE 10
-#define V_TCAMENABLE(x) ((x) << S_TCAMENABLE)
-#define F_TCAMENABLE V_TCAMENABLE(1U)
-
-#define S_BLOCKSELECT 8
-#define M_BLOCKSELECT 0x3U
-#define V_BLOCKSELECT(x) ((x) << S_BLOCKSELECT)
-#define G_BLOCKSELECT(x) (((x) >> S_BLOCKSELECT) & M_BLOCKSELECT)
-
-#define S_LINEADDRESS 1
-#define M_LINEADDRESS 0x7fU
-#define V_LINEADDRESS(x) ((x) << S_LINEADDRESS)
-#define G_LINEADDRESS(x) (((x) >> S_LINEADDRESS) & M_LINEADDRESS)
-
-#define S_REQUESTDONE 0
-#define V_REQUESTDONE(x) ((x) << S_REQUESTDONE)
-#define F_REQUESTDONE V_REQUESTDONE(1U)
-
-#define A_TP_PROTOCOL_DATA0 0x7eec
-#define A_TP_PROTOCOL_DATA1 0x7ef0
-#define A_TP_PROTOCOL_DATA2 0x7ef4
-#define A_TP_PROTOCOL_DATA3 0x7ef8
-#define A_TP_PROTOCOL_DATA4 0x7efc
-
-#define S_PROTOCOLDATAFIELD 0
-#define M_PROTOCOLDATAFIELD 0xfU
-#define V_PROTOCOLDATAFIELD(x) ((x) << S_PROTOCOLDATAFIELD)
-#define G_PROTOCOLDATAFIELD(x) (((x) >> S_PROTOCOLDATAFIELD) & M_PROTOCOLDATAFIELD)
-
-#define A_TP_TX_MOD_Q7_Q6_TIMER_SEPARATOR 0x0
-
-#define S_TXTIMERSEPQ7 16
-#define M_TXTIMERSEPQ7 0xffffU
-#define V_TXTIMERSEPQ7(x) ((x) << S_TXTIMERSEPQ7)
-#define G_TXTIMERSEPQ7(x) (((x) >> S_TXTIMERSEPQ7) & M_TXTIMERSEPQ7)
-
-#define S_TXTIMERSEPQ6 0
-#define M_TXTIMERSEPQ6 0xffffU
-#define V_TXTIMERSEPQ6(x) ((x) << S_TXTIMERSEPQ6)
-#define G_TXTIMERSEPQ6(x) (((x) >> S_TXTIMERSEPQ6) & M_TXTIMERSEPQ6)
-
-#define A_TP_TX_MOD_Q5_Q4_TIMER_SEPARATOR 0x1
-
-#define S_TXTIMERSEPQ5 16
-#define M_TXTIMERSEPQ5 0xffffU
-#define V_TXTIMERSEPQ5(x) ((x) << S_TXTIMERSEPQ5)
-#define G_TXTIMERSEPQ5(x) (((x) >> S_TXTIMERSEPQ5) & M_TXTIMERSEPQ5)
-
-#define S_TXTIMERSEPQ4 0
-#define M_TXTIMERSEPQ4 0xffffU
-#define V_TXTIMERSEPQ4(x) ((x) << S_TXTIMERSEPQ4)
-#define G_TXTIMERSEPQ4(x) (((x) >> S_TXTIMERSEPQ4) & M_TXTIMERSEPQ4)
-
-#define A_TP_TX_MOD_Q3_Q2_TIMER_SEPARATOR 0x2
-
-#define S_TXTIMERSEPQ3 16
-#define M_TXTIMERSEPQ3 0xffffU
-#define V_TXTIMERSEPQ3(x) ((x) << S_TXTIMERSEPQ3)
-#define G_TXTIMERSEPQ3(x) (((x) >> S_TXTIMERSEPQ3) & M_TXTIMERSEPQ3)
-
-#define S_TXTIMERSEPQ2 0
-#define M_TXTIMERSEPQ2 0xffffU
-#define V_TXTIMERSEPQ2(x) ((x) << S_TXTIMERSEPQ2)
-#define G_TXTIMERSEPQ2(x) (((x) >> S_TXTIMERSEPQ2) & M_TXTIMERSEPQ2)
-
-#define A_TP_TX_MOD_Q1_Q0_TIMER_SEPARATOR 0x3
-
-#define S_TXTIMERSEPQ1 16
-#define M_TXTIMERSEPQ1 0xffffU
-#define V_TXTIMERSEPQ1(x) ((x) << S_TXTIMERSEPQ1)
-#define G_TXTIMERSEPQ1(x) (((x) >> S_TXTIMERSEPQ1) & M_TXTIMERSEPQ1)
-
-#define S_TXTIMERSEPQ0 0
-#define M_TXTIMERSEPQ0 0xffffU
-#define V_TXTIMERSEPQ0(x) ((x) << S_TXTIMERSEPQ0)
-#define G_TXTIMERSEPQ0(x) (((x) >> S_TXTIMERSEPQ0) & M_TXTIMERSEPQ0)
-
-#define A_TP_RX_MOD_Q1_Q0_TIMER_SEPARATOR 0x4
-
-#define S_RXTIMERSEPQ1 16
-#define M_RXTIMERSEPQ1 0xffffU
-#define V_RXTIMERSEPQ1(x) ((x) << S_RXTIMERSEPQ1)
-#define G_RXTIMERSEPQ1(x) (((x) >> S_RXTIMERSEPQ1) & M_RXTIMERSEPQ1)
-
-#define S_RXTIMERSEPQ0 0
-#define M_RXTIMERSEPQ0 0xffffU
-#define V_RXTIMERSEPQ0(x) ((x) << S_RXTIMERSEPQ0)
-#define G_RXTIMERSEPQ0(x) (((x) >> S_RXTIMERSEPQ0) & M_RXTIMERSEPQ0)
-
-#define A_TP_TX_MOD_Q7_Q6_RATE_LIMIT 0x5
-
-#define S_TXRATEINCQ7 24
-#define M_TXRATEINCQ7 0xffU
-#define V_TXRATEINCQ7(x) ((x) << S_TXRATEINCQ7)
-#define G_TXRATEINCQ7(x) (((x) >> S_TXRATEINCQ7) & M_TXRATEINCQ7)
-
-#define S_TXRATETCKQ7 16
-#define M_TXRATETCKQ7 0xffU
-#define V_TXRATETCKQ7(x) ((x) << S_TXRATETCKQ7)
-#define G_TXRATETCKQ7(x) (((x) >> S_TXRATETCKQ7) & M_TXRATETCKQ7)
-
-#define S_TXRATEINCQ6 8
-#define M_TXRATEINCQ6 0xffU
-#define V_TXRATEINCQ6(x) ((x) << S_TXRATEINCQ6)
-#define G_TXRATEINCQ6(x) (((x) >> S_TXRATEINCQ6) & M_TXRATEINCQ6)
-
-#define S_TXRATETCKQ6 0
-#define M_TXRATETCKQ6 0xffU
-#define V_TXRATETCKQ6(x) ((x) << S_TXRATETCKQ6)
-#define G_TXRATETCKQ6(x) (((x) >> S_TXRATETCKQ6) & M_TXRATETCKQ6)
-
-#define A_TP_TX_MOD_Q5_Q4_RATE_LIMIT 0x6
-
-#define S_TXRATEINCQ5 24
-#define M_TXRATEINCQ5 0xffU
-#define V_TXRATEINCQ5(x) ((x) << S_TXRATEINCQ5)
-#define G_TXRATEINCQ5(x) (((x) >> S_TXRATEINCQ5) & M_TXRATEINCQ5)
-
-#define S_TXRATETCKQ5 16
-#define M_TXRATETCKQ5 0xffU
-#define V_TXRATETCKQ5(x) ((x) << S_TXRATETCKQ5)
-#define G_TXRATETCKQ5(x) (((x) >> S_TXRATETCKQ5) & M_TXRATETCKQ5)
-
-#define S_TXRATEINCQ4 8
-#define M_TXRATEINCQ4 0xffU
-#define V_TXRATEINCQ4(x) ((x) << S_TXRATEINCQ4)
-#define G_TXRATEINCQ4(x) (((x) >> S_TXRATEINCQ4) & M_TXRATEINCQ4)
-
-#define S_TXRATETCKQ4 0
-#define M_TXRATETCKQ4 0xffU
-#define V_TXRATETCKQ4(x) ((x) << S_TXRATETCKQ4)
-#define G_TXRATETCKQ4(x) (((x) >> S_TXRATETCKQ4) & M_TXRATETCKQ4)
-
-#define A_TP_TX_MOD_Q3_Q2_RATE_LIMIT 0x7
-
-#define S_TXRATEINCQ3 24
-#define M_TXRATEINCQ3 0xffU
-#define V_TXRATEINCQ3(x) ((x) << S_TXRATEINCQ3)
-#define G_TXRATEINCQ3(x) (((x) >> S_TXRATEINCQ3) & M_TXRATEINCQ3)
-
-#define S_TXRATETCKQ3 16
-#define M_TXRATETCKQ3 0xffU
-#define V_TXRATETCKQ3(x) ((x) << S_TXRATETCKQ3)
-#define G_TXRATETCKQ3(x) (((x) >> S_TXRATETCKQ3) & M_TXRATETCKQ3)
-
-#define S_TXRATEINCQ2 8
-#define M_TXRATEINCQ2 0xffU
-#define V_TXRATEINCQ2(x) ((x) << S_TXRATEINCQ2)
-#define G_TXRATEINCQ2(x) (((x) >> S_TXRATEINCQ2) & M_TXRATEINCQ2)
-
-#define S_TXRATETCKQ2 0
-#define M_TXRATETCKQ2 0xffU
-#define V_TXRATETCKQ2(x) ((x) << S_TXRATETCKQ2)
-#define G_TXRATETCKQ2(x) (((x) >> S_TXRATETCKQ2) & M_TXRATETCKQ2)
-
-#define A_TP_TX_MOD_Q1_Q0_RATE_LIMIT 0x8
-
-#define S_TXRATEINCQ1 24
-#define M_TXRATEINCQ1 0xffU
-#define V_TXRATEINCQ1(x) ((x) << S_TXRATEINCQ1)
-#define G_TXRATEINCQ1(x) (((x) >> S_TXRATEINCQ1) & M_TXRATEINCQ1)
-
-#define S_TXRATETCKQ1 16
-#define M_TXRATETCKQ1 0xffU
-#define V_TXRATETCKQ1(x) ((x) << S_TXRATETCKQ1)
-#define G_TXRATETCKQ1(x) (((x) >> S_TXRATETCKQ1) & M_TXRATETCKQ1)
-
-#define S_TXRATEINCQ0 8
-#define M_TXRATEINCQ0 0xffU
-#define V_TXRATEINCQ0(x) ((x) << S_TXRATEINCQ0)
-#define G_TXRATEINCQ0(x) (((x) >> S_TXRATEINCQ0) & M_TXRATEINCQ0)
-
-#define S_TXRATETCKQ0 0
-#define M_TXRATETCKQ0 0xffU
-#define V_TXRATETCKQ0(x) ((x) << S_TXRATETCKQ0)
-#define G_TXRATETCKQ0(x) (((x) >> S_TXRATETCKQ0) & M_TXRATETCKQ0)
-
-#define A_TP_RX_MOD_Q1_Q0_RATE_LIMIT 0x9
-
-#define S_RXRATEINCQ1 24
-#define M_RXRATEINCQ1 0xffU
-#define V_RXRATEINCQ1(x) ((x) << S_RXRATEINCQ1)
-#define G_RXRATEINCQ1(x) (((x) >> S_RXRATEINCQ1) & M_RXRATEINCQ1)
-
-#define S_RXRATETCKQ1 16
-#define M_RXRATETCKQ1 0xffU
-#define V_RXRATETCKQ1(x) ((x) << S_RXRATETCKQ1)
-#define G_RXRATETCKQ1(x) (((x) >> S_RXRATETCKQ1) & M_RXRATETCKQ1)
-
-#define S_RXRATEINCQ0 8
-#define M_RXRATEINCQ0 0xffU
-#define V_RXRATEINCQ0(x) ((x) << S_RXRATEINCQ0)
-#define G_RXRATEINCQ0(x) (((x) >> S_RXRATEINCQ0) & M_RXRATEINCQ0)
-
-#define S_RXRATETCKQ0 0
-#define M_RXRATETCKQ0 0xffU
-#define V_RXRATETCKQ0(x) ((x) << S_RXRATETCKQ0)
-#define G_RXRATETCKQ0(x) (((x) >> S_RXRATETCKQ0) & M_RXRATETCKQ0)
-
-#define A_TP_TX_MOD_C3_C2_RATE_LIMIT 0xa
-#define A_TP_TX_MOD_C1_C0_RATE_LIMIT 0xb
-#define A_TP_RX_SCHED_MAP 0x20
-
-#define S_RXMAPCHANNEL3 24
-#define M_RXMAPCHANNEL3 0xffU
-#define V_RXMAPCHANNEL3(x) ((x) << S_RXMAPCHANNEL3)
-#define G_RXMAPCHANNEL3(x) (((x) >> S_RXMAPCHANNEL3) & M_RXMAPCHANNEL3)
-
-#define S_RXMAPCHANNEL2 16
-#define M_RXMAPCHANNEL2 0xffU
-#define V_RXMAPCHANNEL2(x) ((x) << S_RXMAPCHANNEL2)
-#define G_RXMAPCHANNEL2(x) (((x) >> S_RXMAPCHANNEL2) & M_RXMAPCHANNEL2)
-
-#define S_RXMAPCHANNEL1 8
-#define M_RXMAPCHANNEL1 0xffU
-#define V_RXMAPCHANNEL1(x) ((x) << S_RXMAPCHANNEL1)
-#define G_RXMAPCHANNEL1(x) (((x) >> S_RXMAPCHANNEL1) & M_RXMAPCHANNEL1)
-
-#define S_RXMAPCHANNEL0 0
-#define M_RXMAPCHANNEL0 0xffU
-#define V_RXMAPCHANNEL0(x) ((x) << S_RXMAPCHANNEL0)
-#define G_RXMAPCHANNEL0(x) (((x) >> S_RXMAPCHANNEL0) & M_RXMAPCHANNEL0)
-
-#define A_TP_RX_SCHED_SGE 0x21
-
-#define S_RXSGEMOD1 12
-#define M_RXSGEMOD1 0xfU
-#define V_RXSGEMOD1(x) ((x) << S_RXSGEMOD1)
-#define G_RXSGEMOD1(x) (((x) >> S_RXSGEMOD1) & M_RXSGEMOD1)
-
-#define S_RXSGEMOD0 8
-#define M_RXSGEMOD0 0xfU
-#define V_RXSGEMOD0(x) ((x) << S_RXSGEMOD0)
-#define G_RXSGEMOD0(x) (((x) >> S_RXSGEMOD0) & M_RXSGEMOD0)
-
-#define S_RXSGECHANNEL3 3
-#define V_RXSGECHANNEL3(x) ((x) << S_RXSGECHANNEL3)
-#define F_RXSGECHANNEL3 V_RXSGECHANNEL3(1U)
-
-#define S_RXSGECHANNEL2 2
-#define V_RXSGECHANNEL2(x) ((x) << S_RXSGECHANNEL2)
-#define F_RXSGECHANNEL2 V_RXSGECHANNEL2(1U)
-
-#define S_RXSGECHANNEL1 1
-#define V_RXSGECHANNEL1(x) ((x) << S_RXSGECHANNEL1)
-#define F_RXSGECHANNEL1 V_RXSGECHANNEL1(1U)
-
-#define S_RXSGECHANNEL0 0
-#define V_RXSGECHANNEL0(x) ((x) << S_RXSGECHANNEL0)
-#define F_RXSGECHANNEL0 V_RXSGECHANNEL0(1U)
-
-#define A_TP_TX_SCHED_MAP 0x22
-
-#define S_TXMAPCHANNEL3 12
-#define M_TXMAPCHANNEL3 0xfU
-#define V_TXMAPCHANNEL3(x) ((x) << S_TXMAPCHANNEL3)
-#define G_TXMAPCHANNEL3(x) (((x) >> S_TXMAPCHANNEL3) & M_TXMAPCHANNEL3)
-
-#define S_TXMAPCHANNEL2 8
-#define M_TXMAPCHANNEL2 0xfU
-#define V_TXMAPCHANNEL2(x) ((x) << S_TXMAPCHANNEL2)
-#define G_TXMAPCHANNEL2(x) (((x) >> S_TXMAPCHANNEL2) & M_TXMAPCHANNEL2)
-
-#define S_TXMAPCHANNEL1 4
-#define M_TXMAPCHANNEL1 0xfU
-#define V_TXMAPCHANNEL1(x) ((x) << S_TXMAPCHANNEL1)
-#define G_TXMAPCHANNEL1(x) (((x) >> S_TXMAPCHANNEL1) & M_TXMAPCHANNEL1)
-
-#define S_TXMAPCHANNEL0 0
-#define M_TXMAPCHANNEL0 0xfU
-#define V_TXMAPCHANNEL0(x) ((x) << S_TXMAPCHANNEL0)
-#define G_TXMAPCHANNEL0(x) (((x) >> S_TXMAPCHANNEL0) & M_TXMAPCHANNEL0)
-
-#define S_TXLPKCHANNEL1 17
-#define V_TXLPKCHANNEL1(x) ((x) << S_TXLPKCHANNEL1)
-#define F_TXLPKCHANNEL1 V_TXLPKCHANNEL1(1U)
-
-#define S_TXLPKCHANNEL0 16
-#define V_TXLPKCHANNEL0(x) ((x) << S_TXLPKCHANNEL0)
-#define F_TXLPKCHANNEL0 V_TXLPKCHANNEL0(1U)
-
-#define A_TP_TX_SCHED_HDR 0x23
-
-#define S_TXMAPHDRCHANNEL7 28
-#define M_TXMAPHDRCHANNEL7 0xfU
-#define V_TXMAPHDRCHANNEL7(x) ((x) << S_TXMAPHDRCHANNEL7)
-#define G_TXMAPHDRCHANNEL7(x) (((x) >> S_TXMAPHDRCHANNEL7) & M_TXMAPHDRCHANNEL7)
-
-#define S_TXMAPHDRCHANNEL6 24
-#define M_TXMAPHDRCHANNEL6 0xfU
-#define V_TXMAPHDRCHANNEL6(x) ((x) << S_TXMAPHDRCHANNEL6)
-#define G_TXMAPHDRCHANNEL6(x) (((x) >> S_TXMAPHDRCHANNEL6) & M_TXMAPHDRCHANNEL6)
-
-#define S_TXMAPHDRCHANNEL5 20
-#define M_TXMAPHDRCHANNEL5 0xfU
-#define V_TXMAPHDRCHANNEL5(x) ((x) << S_TXMAPHDRCHANNEL5)
-#define G_TXMAPHDRCHANNEL5(x) (((x) >> S_TXMAPHDRCHANNEL5) & M_TXMAPHDRCHANNEL5)
-
-#define S_TXMAPHDRCHANNEL4 16
-#define M_TXMAPHDRCHANNEL4 0xfU
-#define V_TXMAPHDRCHANNEL4(x) ((x) << S_TXMAPHDRCHANNEL4)
-#define G_TXMAPHDRCHANNEL4(x) (((x) >> S_TXMAPHDRCHANNEL4) & M_TXMAPHDRCHANNEL4)
-
-#define S_TXMAPHDRCHANNEL3 12
-#define M_TXMAPHDRCHANNEL3 0xfU
-#define V_TXMAPHDRCHANNEL3(x) ((x) << S_TXMAPHDRCHANNEL3)
-#define G_TXMAPHDRCHANNEL3(x) (((x) >> S_TXMAPHDRCHANNEL3) & M_TXMAPHDRCHANNEL3)
-
-#define S_TXMAPHDRCHANNEL2 8
-#define M_TXMAPHDRCHANNEL2 0xfU
-#define V_TXMAPHDRCHANNEL2(x) ((x) << S_TXMAPHDRCHANNEL2)
-#define G_TXMAPHDRCHANNEL2(x) (((x) >> S_TXMAPHDRCHANNEL2) & M_TXMAPHDRCHANNEL2)
-
-#define S_TXMAPHDRCHANNEL1 4
-#define M_TXMAPHDRCHANNEL1 0xfU
-#define V_TXMAPHDRCHANNEL1(x) ((x) << S_TXMAPHDRCHANNEL1)
-#define G_TXMAPHDRCHANNEL1(x) (((x) >> S_TXMAPHDRCHANNEL1) & M_TXMAPHDRCHANNEL1)
-
-#define S_TXMAPHDRCHANNEL0 0
-#define M_TXMAPHDRCHANNEL0 0xfU
-#define V_TXMAPHDRCHANNEL0(x) ((x) << S_TXMAPHDRCHANNEL0)
-#define G_TXMAPHDRCHANNEL0(x) (((x) >> S_TXMAPHDRCHANNEL0) & M_TXMAPHDRCHANNEL0)
-
-#define A_TP_TX_SCHED_FIFO 0x24
-
-#define S_TXMAPFIFOCHANNEL7 28
-#define M_TXMAPFIFOCHANNEL7 0xfU
-#define V_TXMAPFIFOCHANNEL7(x) ((x) << S_TXMAPFIFOCHANNEL7)
-#define G_TXMAPFIFOCHANNEL7(x) (((x) >> S_TXMAPFIFOCHANNEL7) & M_TXMAPFIFOCHANNEL7)
-
-#define S_TXMAPFIFOCHANNEL6 24
-#define M_TXMAPFIFOCHANNEL6 0xfU
-#define V_TXMAPFIFOCHANNEL6(x) ((x) << S_TXMAPFIFOCHANNEL6)
-#define G_TXMAPFIFOCHANNEL6(x) (((x) >> S_TXMAPFIFOCHANNEL6) & M_TXMAPFIFOCHANNEL6)
-
-#define S_TXMAPFIFOCHANNEL5 20
-#define M_TXMAPFIFOCHANNEL5 0xfU
-#define V_TXMAPFIFOCHANNEL5(x) ((x) << S_TXMAPFIFOCHANNEL5)
-#define G_TXMAPFIFOCHANNEL5(x) (((x) >> S_TXMAPFIFOCHANNEL5) & M_TXMAPFIFOCHANNEL5)
-
-#define S_TXMAPFIFOCHANNEL4 16
-#define M_TXMAPFIFOCHANNEL4 0xfU
-#define V_TXMAPFIFOCHANNEL4(x) ((x) << S_TXMAPFIFOCHANNEL4)
-#define G_TXMAPFIFOCHANNEL4(x) (((x) >> S_TXMAPFIFOCHANNEL4) & M_TXMAPFIFOCHANNEL4)
-
-#define S_TXMAPFIFOCHANNEL3 12
-#define M_TXMAPFIFOCHANNEL3 0xfU
-#define V_TXMAPFIFOCHANNEL3(x) ((x) << S_TXMAPFIFOCHANNEL3)
-#define G_TXMAPFIFOCHANNEL3(x) (((x) >> S_TXMAPFIFOCHANNEL3) & M_TXMAPFIFOCHANNEL3)
-
-#define S_TXMAPFIFOCHANNEL2 8
-#define M_TXMAPFIFOCHANNEL2 0xfU
-#define V_TXMAPFIFOCHANNEL2(x) ((x) << S_TXMAPFIFOCHANNEL2)
-#define G_TXMAPFIFOCHANNEL2(x) (((x) >> S_TXMAPFIFOCHANNEL2) & M_TXMAPFIFOCHANNEL2)
-
-#define S_TXMAPFIFOCHANNEL1 4
-#define M_TXMAPFIFOCHANNEL1 0xfU
-#define V_TXMAPFIFOCHANNEL1(x) ((x) << S_TXMAPFIFOCHANNEL1)
-#define G_TXMAPFIFOCHANNEL1(x) (((x) >> S_TXMAPFIFOCHANNEL1) & M_TXMAPFIFOCHANNEL1)
-
-#define S_TXMAPFIFOCHANNEL0 0
-#define M_TXMAPFIFOCHANNEL0 0xfU
-#define V_TXMAPFIFOCHANNEL0(x) ((x) << S_TXMAPFIFOCHANNEL0)
-#define G_TXMAPFIFOCHANNEL0(x) (((x) >> S_TXMAPFIFOCHANNEL0) & M_TXMAPFIFOCHANNEL0)
-
-#define A_TP_TX_SCHED_PCMD 0x25
-
-#define S_TXMAPPCMDCHANNEL7 28
-#define M_TXMAPPCMDCHANNEL7 0xfU
-#define V_TXMAPPCMDCHANNEL7(x) ((x) << S_TXMAPPCMDCHANNEL7)
-#define G_TXMAPPCMDCHANNEL7(x) (((x) >> S_TXMAPPCMDCHANNEL7) & M_TXMAPPCMDCHANNEL7)
-
-#define S_TXMAPPCMDCHANNEL6 24
-#define M_TXMAPPCMDCHANNEL6 0xfU
-#define V_TXMAPPCMDCHANNEL6(x) ((x) << S_TXMAPPCMDCHANNEL6)
-#define G_TXMAPPCMDCHANNEL6(x) (((x) >> S_TXMAPPCMDCHANNEL6) & M_TXMAPPCMDCHANNEL6)
-
-#define S_TXMAPPCMDCHANNEL5 20
-#define M_TXMAPPCMDCHANNEL5 0xfU
-#define V_TXMAPPCMDCHANNEL5(x) ((x) << S_TXMAPPCMDCHANNEL5)
-#define G_TXMAPPCMDCHANNEL5(x) (((x) >> S_TXMAPPCMDCHANNEL5) & M_TXMAPPCMDCHANNEL5)
-
-#define S_TXMAPPCMDCHANNEL4 16
-#define M_TXMAPPCMDCHANNEL4 0xfU
-#define V_TXMAPPCMDCHANNEL4(x) ((x) << S_TXMAPPCMDCHANNEL4)
-#define G_TXMAPPCMDCHANNEL4(x) (((x) >> S_TXMAPPCMDCHANNEL4) & M_TXMAPPCMDCHANNEL4)
-
-#define S_TXMAPPCMDCHANNEL3 12
-#define M_TXMAPPCMDCHANNEL3 0xfU
-#define V_TXMAPPCMDCHANNEL3(x) ((x) << S_TXMAPPCMDCHANNEL3)
-#define G_TXMAPPCMDCHANNEL3(x) (((x) >> S_TXMAPPCMDCHANNEL3) & M_TXMAPPCMDCHANNEL3)
-
-#define S_TXMAPPCMDCHANNEL2 8
-#define M_TXMAPPCMDCHANNEL2 0xfU
-#define V_TXMAPPCMDCHANNEL2(x) ((x) << S_TXMAPPCMDCHANNEL2)
-#define G_TXMAPPCMDCHANNEL2(x) (((x) >> S_TXMAPPCMDCHANNEL2) & M_TXMAPPCMDCHANNEL2)
-
-#define S_TXMAPPCMDCHANNEL1 4
-#define M_TXMAPPCMDCHANNEL1 0xfU
-#define V_TXMAPPCMDCHANNEL1(x) ((x) << S_TXMAPPCMDCHANNEL1)
-#define G_TXMAPPCMDCHANNEL1(x) (((x) >> S_TXMAPPCMDCHANNEL1) & M_TXMAPPCMDCHANNEL1)
-
-#define S_TXMAPPCMDCHANNEL0 0
-#define M_TXMAPPCMDCHANNEL0 0xfU
-#define V_TXMAPPCMDCHANNEL0(x) ((x) << S_TXMAPPCMDCHANNEL0)
-#define G_TXMAPPCMDCHANNEL0(x) (((x) >> S_TXMAPPCMDCHANNEL0) & M_TXMAPPCMDCHANNEL0)
-
-#define A_TP_TX_SCHED_LPBK 0x26
-
-#define S_TXMAPLPBKCHANNEL7 28
-#define M_TXMAPLPBKCHANNEL7 0xfU
-#define V_TXMAPLPBKCHANNEL7(x) ((x) << S_TXMAPLPBKCHANNEL7)
-#define G_TXMAPLPBKCHANNEL7(x) (((x) >> S_TXMAPLPBKCHANNEL7) & M_TXMAPLPBKCHANNEL7)
-
-#define S_TXMAPLPBKCHANNEL6 24
-#define M_TXMAPLPBKCHANNEL6 0xfU
-#define V_TXMAPLPBKCHANNEL6(x) ((x) << S_TXMAPLPBKCHANNEL6)
-#define G_TXMAPLPBKCHANNEL6(x) (((x) >> S_TXMAPLPBKCHANNEL6) & M_TXMAPLPBKCHANNEL6)
-
-#define S_TXMAPLPBKCHANNEL5 20
-#define M_TXMAPLPBKCHANNEL5 0xfU
-#define V_TXMAPLPBKCHANNEL5(x) ((x) << S_TXMAPLPBKCHANNEL5)
-#define G_TXMAPLPBKCHANNEL5(x) (((x) >> S_TXMAPLPBKCHANNEL5) & M_TXMAPLPBKCHANNEL5)
-
-#define S_TXMAPLPBKCHANNEL4 16
-#define M_TXMAPLPBKCHANNEL4 0xfU
-#define V_TXMAPLPBKCHANNEL4(x) ((x) << S_TXMAPLPBKCHANNEL4)
-#define G_TXMAPLPBKCHANNEL4(x) (((x) >> S_TXMAPLPBKCHANNEL4) & M_TXMAPLPBKCHANNEL4)
-
-#define S_TXMAPLPBKCHANNEL3 12
-#define M_TXMAPLPBKCHANNEL3 0xfU
-#define V_TXMAPLPBKCHANNEL3(x) ((x) << S_TXMAPLPBKCHANNEL3)
-#define G_TXMAPLPBKCHANNEL3(x) (((x) >> S_TXMAPLPBKCHANNEL3) & M_TXMAPLPBKCHANNEL3)
-
-#define S_TXMAPLPBKCHANNEL2 8
-#define M_TXMAPLPBKCHANNEL2 0xfU
-#define V_TXMAPLPBKCHANNEL2(x) ((x) << S_TXMAPLPBKCHANNEL2)
-#define G_TXMAPLPBKCHANNEL2(x) (((x) >> S_TXMAPLPBKCHANNEL2) & M_TXMAPLPBKCHANNEL2)
-
-#define S_TXMAPLPBKCHANNEL1 4
-#define M_TXMAPLPBKCHANNEL1 0xfU
-#define V_TXMAPLPBKCHANNEL1(x) ((x) << S_TXMAPLPBKCHANNEL1)
-#define G_TXMAPLPBKCHANNEL1(x) (((x) >> S_TXMAPLPBKCHANNEL1) & M_TXMAPLPBKCHANNEL1)
-
-#define S_TXMAPLPBKCHANNEL0 0
-#define M_TXMAPLPBKCHANNEL0 0xfU
-#define V_TXMAPLPBKCHANNEL0(x) ((x) << S_TXMAPLPBKCHANNEL0)
-#define G_TXMAPLPBKCHANNEL0(x) (((x) >> S_TXMAPLPBKCHANNEL0) & M_TXMAPLPBKCHANNEL0)
-
-#define A_TP_CHANNEL_MAP 0x27
-
-#define S_RXMAPCHANNELELN 16
-#define M_RXMAPCHANNELELN 0xfU
-#define V_RXMAPCHANNELELN(x) ((x) << S_RXMAPCHANNELELN)
-#define G_RXMAPCHANNELELN(x) (((x) >> S_RXMAPCHANNELELN) & M_RXMAPCHANNELELN)
-
-#define S_RXMAPE2LCHANNEL3 14
-#define M_RXMAPE2LCHANNEL3 0x3U
-#define V_RXMAPE2LCHANNEL3(x) ((x) << S_RXMAPE2LCHANNEL3)
-#define G_RXMAPE2LCHANNEL3(x) (((x) >> S_RXMAPE2LCHANNEL3) & M_RXMAPE2LCHANNEL3)
-
-#define S_RXMAPE2LCHANNEL2 12
-#define M_RXMAPE2LCHANNEL2 0x3U
-#define V_RXMAPE2LCHANNEL2(x) ((x) << S_RXMAPE2LCHANNEL2)
-#define G_RXMAPE2LCHANNEL2(x) (((x) >> S_RXMAPE2LCHANNEL2) & M_RXMAPE2LCHANNEL2)
-
-#define S_RXMAPE2LCHANNEL1 10
-#define M_RXMAPE2LCHANNEL1 0x3U
-#define V_RXMAPE2LCHANNEL1(x) ((x) << S_RXMAPE2LCHANNEL1)
-#define G_RXMAPE2LCHANNEL1(x) (((x) >> S_RXMAPE2LCHANNEL1) & M_RXMAPE2LCHANNEL1)
-
-#define S_RXMAPE2LCHANNEL0 8
-#define M_RXMAPE2LCHANNEL0 0x3U
-#define V_RXMAPE2LCHANNEL0(x) ((x) << S_RXMAPE2LCHANNEL0)
-#define G_RXMAPE2LCHANNEL0(x) (((x) >> S_RXMAPE2LCHANNEL0) & M_RXMAPE2LCHANNEL0)
-
-#define S_RXMAPC2CCHANNEL3 7
-#define V_RXMAPC2CCHANNEL3(x) ((x) << S_RXMAPC2CCHANNEL3)
-#define F_RXMAPC2CCHANNEL3 V_RXMAPC2CCHANNEL3(1U)
-
-#define S_RXMAPC2CCHANNEL2 6
-#define V_RXMAPC2CCHANNEL2(x) ((x) << S_RXMAPC2CCHANNEL2)
-#define F_RXMAPC2CCHANNEL2 V_RXMAPC2CCHANNEL2(1U)
-
-#define S_RXMAPC2CCHANNEL1 5
-#define V_RXMAPC2CCHANNEL1(x) ((x) << S_RXMAPC2CCHANNEL1)
-#define F_RXMAPC2CCHANNEL1 V_RXMAPC2CCHANNEL1(1U)
-
-#define S_RXMAPC2CCHANNEL0 4
-#define V_RXMAPC2CCHANNEL0(x) ((x) << S_RXMAPC2CCHANNEL0)
-#define F_RXMAPC2CCHANNEL0 V_RXMAPC2CCHANNEL0(1U)
-
-#define S_RXMAPE2CCHANNEL3 3
-#define V_RXMAPE2CCHANNEL3(x) ((x) << S_RXMAPE2CCHANNEL3)
-#define F_RXMAPE2CCHANNEL3 V_RXMAPE2CCHANNEL3(1U)
-
-#define S_RXMAPE2CCHANNEL2 2
-#define V_RXMAPE2CCHANNEL2(x) ((x) << S_RXMAPE2CCHANNEL2)
-#define F_RXMAPE2CCHANNEL2 V_RXMAPE2CCHANNEL2(1U)
-
-#define S_RXMAPE2CCHANNEL1 1
-#define V_RXMAPE2CCHANNEL1(x) ((x) << S_RXMAPE2CCHANNEL1)
-#define F_RXMAPE2CCHANNEL1 V_RXMAPE2CCHANNEL1(1U)
-
-#define S_RXMAPE2CCHANNEL0 0
-#define V_RXMAPE2CCHANNEL0(x) ((x) << S_RXMAPE2CCHANNEL0)
-#define F_RXMAPE2CCHANNEL0 V_RXMAPE2CCHANNEL0(1U)
-
-#define A_TP_RX_LPBK 0x28
-#define A_TP_TX_LPBK 0x29
-#define A_TP_TX_SCHED_PPP 0x2a
-
-#define S_TXPPPENPORT3 24
-#define M_TXPPPENPORT3 0xffU
-#define V_TXPPPENPORT3(x) ((x) << S_TXPPPENPORT3)
-#define G_TXPPPENPORT3(x) (((x) >> S_TXPPPENPORT3) & M_TXPPPENPORT3)
-
-#define S_TXPPPENPORT2 16
-#define M_TXPPPENPORT2 0xffU
-#define V_TXPPPENPORT2(x) ((x) << S_TXPPPENPORT2)
-#define G_TXPPPENPORT2(x) (((x) >> S_TXPPPENPORT2) & M_TXPPPENPORT2)
-
-#define S_TXPPPENPORT1 8
-#define M_TXPPPENPORT1 0xffU
-#define V_TXPPPENPORT1(x) ((x) << S_TXPPPENPORT1)
-#define G_TXPPPENPORT1(x) (((x) >> S_TXPPPENPORT1) & M_TXPPPENPORT1)
-
-#define S_TXPPPENPORT0 0
-#define M_TXPPPENPORT0 0xffU
-#define V_TXPPPENPORT0(x) ((x) << S_TXPPPENPORT0)
-#define G_TXPPPENPORT0(x) (((x) >> S_TXPPPENPORT0) & M_TXPPPENPORT0)
-
-#define A_TP_RX_SCHED_FIFO 0x2b
-
-#define S_COMMITLIMIT1H 24
-#define M_COMMITLIMIT1H 0xffU
-#define V_COMMITLIMIT1H(x) ((x) << S_COMMITLIMIT1H)
-#define G_COMMITLIMIT1H(x) (((x) >> S_COMMITLIMIT1H) & M_COMMITLIMIT1H)
-
-#define S_COMMITLIMIT1L 16
-#define M_COMMITLIMIT1L 0xffU
-#define V_COMMITLIMIT1L(x) ((x) << S_COMMITLIMIT1L)
-#define G_COMMITLIMIT1L(x) (((x) >> S_COMMITLIMIT1L) & M_COMMITLIMIT1L)
-
-#define S_COMMITLIMIT0H 8
-#define M_COMMITLIMIT0H 0xffU
-#define V_COMMITLIMIT0H(x) ((x) << S_COMMITLIMIT0H)
-#define G_COMMITLIMIT0H(x) (((x) >> S_COMMITLIMIT0H) & M_COMMITLIMIT0H)
-
-#define S_COMMITLIMIT0L 0
-#define M_COMMITLIMIT0L 0xffU
-#define V_COMMITLIMIT0L(x) ((x) << S_COMMITLIMIT0L)
-#define G_COMMITLIMIT0L(x) (((x) >> S_COMMITLIMIT0L) & M_COMMITLIMIT0L)
-
-#define A_TP_IPMI_CFG1 0x2e
-
-#define S_VLANENABLE 31
-#define V_VLANENABLE(x) ((x) << S_VLANENABLE)
-#define F_VLANENABLE V_VLANENABLE(1U)
-
-#define S_PRIMARYPORTENABLE 30
-#define V_PRIMARYPORTENABLE(x) ((x) << S_PRIMARYPORTENABLE)
-#define F_PRIMARYPORTENABLE V_PRIMARYPORTENABLE(1U)
-
-#define S_SECUREPORTENABLE 29
-#define V_SECUREPORTENABLE(x) ((x) << S_SECUREPORTENABLE)
-#define F_SECUREPORTENABLE V_SECUREPORTENABLE(1U)
-
-#define S_ARPENABLE 28
-#define V_ARPENABLE(x) ((x) << S_ARPENABLE)
-#define F_ARPENABLE V_ARPENABLE(1U)
-
-#define S_IPMI_VLAN 0
-#define M_IPMI_VLAN 0xffffU
-#define V_IPMI_VLAN(x) ((x) << S_IPMI_VLAN)
-#define G_IPMI_VLAN(x) (((x) >> S_IPMI_VLAN) & M_IPMI_VLAN)
-
-#define A_TP_IPMI_CFG2 0x2f
-
-#define S_SECUREPORT 16
-#define M_SECUREPORT 0xffffU
-#define V_SECUREPORT(x) ((x) << S_SECUREPORT)
-#define G_SECUREPORT(x) (((x) >> S_SECUREPORT) & M_SECUREPORT)
-
-#define S_PRIMARYPORT 0
-#define M_PRIMARYPORT 0xffffU
-#define V_PRIMARYPORT(x) ((x) << S_PRIMARYPORT)
-#define G_PRIMARYPORT(x) (((x) >> S_PRIMARYPORT) & M_PRIMARYPORT)
-
-#define A_TP_RSS_PF0_CONFIG 0x30
-
-#define S_MAPENABLE 31
-#define V_MAPENABLE(x) ((x) << S_MAPENABLE)
-#define F_MAPENABLE V_MAPENABLE(1U)
-
-#define S_CHNENABLE 30
-#define V_CHNENABLE(x) ((x) << S_CHNENABLE)
-#define F_CHNENABLE V_CHNENABLE(1U)
-
-#define S_PRTENABLE 29
-#define V_PRTENABLE(x) ((x) << S_PRTENABLE)
-#define F_PRTENABLE V_PRTENABLE(1U)
-
-#define S_UDPFOURTUPEN 28
-#define V_UDPFOURTUPEN(x) ((x) << S_UDPFOURTUPEN)
-#define F_UDPFOURTUPEN V_UDPFOURTUPEN(1U)
-
-#define S_IP6FOURTUPEN 27
-#define V_IP6FOURTUPEN(x) ((x) << S_IP6FOURTUPEN)
-#define F_IP6FOURTUPEN V_IP6FOURTUPEN(1U)
-
-#define S_IP6TWOTUPEN 26
-#define V_IP6TWOTUPEN(x) ((x) << S_IP6TWOTUPEN)
-#define F_IP6TWOTUPEN V_IP6TWOTUPEN(1U)
-
-#define S_IP4FOURTUPEN 25
-#define V_IP4FOURTUPEN(x) ((x) << S_IP4FOURTUPEN)
-#define F_IP4FOURTUPEN V_IP4FOURTUPEN(1U)
-
-#define S_IP4TWOTUPEN 24
-#define V_IP4TWOTUPEN(x) ((x) << S_IP4TWOTUPEN)
-#define F_IP4TWOTUPEN V_IP4TWOTUPEN(1U)
-
-#define S_IVFWIDTH 20
-#define M_IVFWIDTH 0xfU
-#define V_IVFWIDTH(x) ((x) << S_IVFWIDTH)
-#define G_IVFWIDTH(x) (((x) >> S_IVFWIDTH) & M_IVFWIDTH)
-
-#define S_CH1DEFAULTQUEUE 10
-#define M_CH1DEFAULTQUEUE 0x3ffU
-#define V_CH1DEFAULTQUEUE(x) ((x) << S_CH1DEFAULTQUEUE)
-#define G_CH1DEFAULTQUEUE(x) (((x) >> S_CH1DEFAULTQUEUE) & M_CH1DEFAULTQUEUE)
-
-#define S_CH0DEFAULTQUEUE 0
-#define M_CH0DEFAULTQUEUE 0x3ffU
-#define V_CH0DEFAULTQUEUE(x) ((x) << S_CH0DEFAULTQUEUE)
-#define G_CH0DEFAULTQUEUE(x) (((x) >> S_CH0DEFAULTQUEUE) & M_CH0DEFAULTQUEUE)
-
-#define S_PRIENABLE 30
-#define V_PRIENABLE(x) ((x) << S_PRIENABLE)
-#define F_PRIENABLE V_PRIENABLE(1U)
-
-#define S_T6_CHNENABLE 29
-#define V_T6_CHNENABLE(x) ((x) << S_T6_CHNENABLE)
-#define F_T6_CHNENABLE V_T6_CHNENABLE(1U)
-
-#define A_TP_RSS_PF1_CONFIG 0x31
-
-#define S_T6_CHNENABLE 29
-#define V_T6_CHNENABLE(x) ((x) << S_T6_CHNENABLE)
-#define F_T6_CHNENABLE V_T6_CHNENABLE(1U)
-
-#define A_TP_RSS_PF2_CONFIG 0x32
-
-#define S_T6_CHNENABLE 29
-#define V_T6_CHNENABLE(x) ((x) << S_T6_CHNENABLE)
-#define F_T6_CHNENABLE V_T6_CHNENABLE(1U)
-
-#define A_TP_RSS_PF3_CONFIG 0x33
-
-#define S_T6_CHNENABLE 29
-#define V_T6_CHNENABLE(x) ((x) << S_T6_CHNENABLE)
-#define F_T6_CHNENABLE V_T6_CHNENABLE(1U)
-
-#define A_TP_RSS_PF4_CONFIG 0x34
-
-#define S_T6_CHNENABLE 29
-#define V_T6_CHNENABLE(x) ((x) << S_T6_CHNENABLE)
-#define F_T6_CHNENABLE V_T6_CHNENABLE(1U)
-
-#define A_TP_RSS_PF5_CONFIG 0x35
-
-#define S_T6_CHNENABLE 29
-#define V_T6_CHNENABLE(x) ((x) << S_T6_CHNENABLE)
-#define F_T6_CHNENABLE V_T6_CHNENABLE(1U)
-
-#define A_TP_RSS_PF6_CONFIG 0x36
-
-#define S_T6_CHNENABLE 29
-#define V_T6_CHNENABLE(x) ((x) << S_T6_CHNENABLE)
-#define F_T6_CHNENABLE V_T6_CHNENABLE(1U)
-
-#define A_TP_RSS_PF7_CONFIG 0x37
-
-#define S_T6_CHNENABLE 29
-#define V_T6_CHNENABLE(x) ((x) << S_T6_CHNENABLE)
-#define F_T6_CHNENABLE V_T6_CHNENABLE(1U)
-
-#define A_TP_RSS_PF_MAP 0x38
-
-#define S_LKPIDXSIZE 24
-#define M_LKPIDXSIZE 0x3U
-#define V_LKPIDXSIZE(x) ((x) << S_LKPIDXSIZE)
-#define G_LKPIDXSIZE(x) (((x) >> S_LKPIDXSIZE) & M_LKPIDXSIZE)
-
-#define S_PF7LKPIDX 21
-#define M_PF7LKPIDX 0x7U
-#define V_PF7LKPIDX(x) ((x) << S_PF7LKPIDX)
-#define G_PF7LKPIDX(x) (((x) >> S_PF7LKPIDX) & M_PF7LKPIDX)
-
-#define S_PF6LKPIDX 18
-#define M_PF6LKPIDX 0x7U
-#define V_PF6LKPIDX(x) ((x) << S_PF6LKPIDX)
-#define G_PF6LKPIDX(x) (((x) >> S_PF6LKPIDX) & M_PF6LKPIDX)
-
-#define S_PF5LKPIDX 15
-#define M_PF5LKPIDX 0x7U
-#define V_PF5LKPIDX(x) ((x) << S_PF5LKPIDX)
-#define G_PF5LKPIDX(x) (((x) >> S_PF5LKPIDX) & M_PF5LKPIDX)
-
-#define S_PF4LKPIDX 12
-#define M_PF4LKPIDX 0x7U
-#define V_PF4LKPIDX(x) ((x) << S_PF4LKPIDX)
-#define G_PF4LKPIDX(x) (((x) >> S_PF4LKPIDX) & M_PF4LKPIDX)
-
-#define S_PF3LKPIDX 9
-#define M_PF3LKPIDX 0x7U
-#define V_PF3LKPIDX(x) ((x) << S_PF3LKPIDX)
-#define G_PF3LKPIDX(x) (((x) >> S_PF3LKPIDX) & M_PF3LKPIDX)
-
-#define S_PF2LKPIDX 6
-#define M_PF2LKPIDX 0x7U
-#define V_PF2LKPIDX(x) ((x) << S_PF2LKPIDX)
-#define G_PF2LKPIDX(x) (((x) >> S_PF2LKPIDX) & M_PF2LKPIDX)
-
-#define S_PF1LKPIDX 3
-#define M_PF1LKPIDX 0x7U
-#define V_PF1LKPIDX(x) ((x) << S_PF1LKPIDX)
-#define G_PF1LKPIDX(x) (((x) >> S_PF1LKPIDX) & M_PF1LKPIDX)
-
-#define S_PF0LKPIDX 0
-#define M_PF0LKPIDX 0x7U
-#define V_PF0LKPIDX(x) ((x) << S_PF0LKPIDX)
-#define G_PF0LKPIDX(x) (((x) >> S_PF0LKPIDX) & M_PF0LKPIDX)
-
-#define A_TP_RSS_PF_MSK 0x39
-
-#define S_PF7MSKSIZE 28
-#define M_PF7MSKSIZE 0xfU
-#define V_PF7MSKSIZE(x) ((x) << S_PF7MSKSIZE)
-#define G_PF7MSKSIZE(x) (((x) >> S_PF7MSKSIZE) & M_PF7MSKSIZE)
-
-#define S_PF6MSKSIZE 24
-#define M_PF6MSKSIZE 0xfU
-#define V_PF6MSKSIZE(x) ((x) << S_PF6MSKSIZE)
-#define G_PF6MSKSIZE(x) (((x) >> S_PF6MSKSIZE) & M_PF6MSKSIZE)
-
-#define S_PF5MSKSIZE 20
-#define M_PF5MSKSIZE 0xfU
-#define V_PF5MSKSIZE(x) ((x) << S_PF5MSKSIZE)
-#define G_PF5MSKSIZE(x) (((x) >> S_PF5MSKSIZE) & M_PF5MSKSIZE)
-
-#define S_PF4MSKSIZE 16
-#define M_PF4MSKSIZE 0xfU
-#define V_PF4MSKSIZE(x) ((x) << S_PF4MSKSIZE)
-#define G_PF4MSKSIZE(x) (((x) >> S_PF4MSKSIZE) & M_PF4MSKSIZE)
-
-#define S_PF3MSKSIZE 12
-#define M_PF3MSKSIZE 0xfU
-#define V_PF3MSKSIZE(x) ((x) << S_PF3MSKSIZE)
-#define G_PF3MSKSIZE(x) (((x) >> S_PF3MSKSIZE) & M_PF3MSKSIZE)
-
-#define S_PF2MSKSIZE 8
-#define M_PF2MSKSIZE 0xfU
-#define V_PF2MSKSIZE(x) ((x) << S_PF2MSKSIZE)
-#define G_PF2MSKSIZE(x) (((x) >> S_PF2MSKSIZE) & M_PF2MSKSIZE)
-
-#define S_PF1MSKSIZE 4
-#define M_PF1MSKSIZE 0xfU
-#define V_PF1MSKSIZE(x) ((x) << S_PF1MSKSIZE)
-#define G_PF1MSKSIZE(x) (((x) >> S_PF1MSKSIZE) & M_PF1MSKSIZE)
-
-#define S_PF0MSKSIZE 0
-#define M_PF0MSKSIZE 0xfU
-#define V_PF0MSKSIZE(x) ((x) << S_PF0MSKSIZE)
-#define G_PF0MSKSIZE(x) (((x) >> S_PF0MSKSIZE) & M_PF0MSKSIZE)
-
-#define A_TP_RSS_VFL_CONFIG 0x3a
-#define A_TP_RSS_VFH_CONFIG 0x3b
-
-#define S_ENABLEUDPHASH 31
-#define V_ENABLEUDPHASH(x) ((x) << S_ENABLEUDPHASH)
-#define F_ENABLEUDPHASH V_ENABLEUDPHASH(1U)
-
-#define S_VFUPEN 30
-#define V_VFUPEN(x) ((x) << S_VFUPEN)
-#define F_VFUPEN V_VFUPEN(1U)
-
-#define S_VFVLNEX 28
-#define V_VFVLNEX(x) ((x) << S_VFVLNEX)
-#define F_VFVLNEX V_VFVLNEX(1U)
-
-#define S_VFPRTEN 27
-#define V_VFPRTEN(x) ((x) << S_VFPRTEN)
-#define F_VFPRTEN V_VFPRTEN(1U)
-
-#define S_VFCHNEN 26
-#define V_VFCHNEN(x) ((x) << S_VFCHNEN)
-#define F_VFCHNEN V_VFCHNEN(1U)
-
-#define S_DEFAULTQUEUE 16
-#define M_DEFAULTQUEUE 0x3ffU
-#define V_DEFAULTQUEUE(x) ((x) << S_DEFAULTQUEUE)
-#define G_DEFAULTQUEUE(x) (((x) >> S_DEFAULTQUEUE) & M_DEFAULTQUEUE)
-
-#define S_VFLKPIDX 8
-#define M_VFLKPIDX 0xffU
-#define V_VFLKPIDX(x) ((x) << S_VFLKPIDX)
-#define G_VFLKPIDX(x) (((x) >> S_VFLKPIDX) & M_VFLKPIDX)
-
-#define S_VFIP6FOURTUPEN 7
-#define V_VFIP6FOURTUPEN(x) ((x) << S_VFIP6FOURTUPEN)
-#define F_VFIP6FOURTUPEN V_VFIP6FOURTUPEN(1U)
-
-#define S_VFIP6TWOTUPEN 6
-#define V_VFIP6TWOTUPEN(x) ((x) << S_VFIP6TWOTUPEN)
-#define F_VFIP6TWOTUPEN V_VFIP6TWOTUPEN(1U)
-
-#define S_VFIP4FOURTUPEN 5
-#define V_VFIP4FOURTUPEN(x) ((x) << S_VFIP4FOURTUPEN)
-#define F_VFIP4FOURTUPEN V_VFIP4FOURTUPEN(1U)
-
-#define S_VFIP4TWOTUPEN 4
-#define V_VFIP4TWOTUPEN(x) ((x) << S_VFIP4TWOTUPEN)
-#define F_VFIP4TWOTUPEN V_VFIP4TWOTUPEN(1U)
-
-#define S_KEYINDEX 0
-#define M_KEYINDEX 0xfU
-#define V_KEYINDEX(x) ((x) << S_KEYINDEX)
-#define G_KEYINDEX(x) (((x) >> S_KEYINDEX) & M_KEYINDEX)
-
-#define A_TP_RSS_SECRET_KEY0 0x40
-#define A_TP_RSS_SECRET_KEY1 0x41
-#define A_TP_RSS_SECRET_KEY2 0x42
-#define A_TP_RSS_SECRET_KEY3 0x43
-#define A_TP_RSS_SECRET_KEY4 0x44
-#define A_TP_RSS_SECRET_KEY5 0x45
-#define A_TP_RSS_SECRET_KEY6 0x46
-#define A_TP_RSS_SECRET_KEY7 0x47
-#define A_TP_RSS_SECRET_KEY8 0x48
-#define A_TP_RSS_SECRET_KEY9 0x49
-#define A_TP_ETHER_TYPE_VL 0x50
-
-#define S_CQFCTYPE 16
-#define M_CQFCTYPE 0xffffU
-#define V_CQFCTYPE(x) ((x) << S_CQFCTYPE)
-#define G_CQFCTYPE(x) (((x) >> S_CQFCTYPE) & M_CQFCTYPE)
-
-#define S_VLANTYPE 0
-#define M_VLANTYPE 0xffffU
-#define V_VLANTYPE(x) ((x) << S_VLANTYPE)
-#define G_VLANTYPE(x) (((x) >> S_VLANTYPE) & M_VLANTYPE)
-
-#define A_TP_ETHER_TYPE_IP 0x51
-
-#define S_IPV6TYPE 16
-#define M_IPV6TYPE 0xffffU
-#define V_IPV6TYPE(x) ((x) << S_IPV6TYPE)
-#define G_IPV6TYPE(x) (((x) >> S_IPV6TYPE) & M_IPV6TYPE)
-
-#define S_IPV4TYPE 0
-#define M_IPV4TYPE 0xffffU
-#define V_IPV4TYPE(x) ((x) << S_IPV4TYPE)
-#define G_IPV4TYPE(x) (((x) >> S_IPV4TYPE) & M_IPV4TYPE)
-
-#define A_TP_ETHER_TYPE_FW 0x52
-
-#define S_ETHTYPE1 16
-#define M_ETHTYPE1 0xffffU
-#define V_ETHTYPE1(x) ((x) << S_ETHTYPE1)
-#define G_ETHTYPE1(x) (((x) >> S_ETHTYPE1) & M_ETHTYPE1)
-
-#define S_ETHTYPE0 0
-#define M_ETHTYPE0 0xffffU
-#define V_ETHTYPE0(x) ((x) << S_ETHTYPE0)
-#define G_ETHTYPE0(x) (((x) >> S_ETHTYPE0) & M_ETHTYPE0)
-
-#define A_TP_VXLAN_HEADER 0x53
-
-#define S_VXLANPORT 0
-#define M_VXLANPORT 0xffffU
-#define V_VXLANPORT(x) ((x) << S_VXLANPORT)
-#define G_VXLANPORT(x) (((x) >> S_VXLANPORT) & M_VXLANPORT)
-
-#define A_TP_CORE_POWER 0x54
-
-#define S_SLEEPRDYVNT 12
-#define V_SLEEPRDYVNT(x) ((x) << S_SLEEPRDYVNT)
-#define F_SLEEPRDYVNT V_SLEEPRDYVNT(1U)
-
-#define S_SLEEPRDYTBL 11
-#define V_SLEEPRDYTBL(x) ((x) << S_SLEEPRDYTBL)
-#define F_SLEEPRDYTBL V_SLEEPRDYTBL(1U)
-
-#define S_SLEEPRDYMIB 10
-#define V_SLEEPRDYMIB(x) ((x) << S_SLEEPRDYMIB)
-#define F_SLEEPRDYMIB V_SLEEPRDYMIB(1U)
-
-#define S_SLEEPRDYARP 9
-#define V_SLEEPRDYARP(x) ((x) << S_SLEEPRDYARP)
-#define F_SLEEPRDYARP V_SLEEPRDYARP(1U)
-
-#define S_SLEEPRDYRSS 8
-#define V_SLEEPRDYRSS(x) ((x) << S_SLEEPRDYRSS)
-#define F_SLEEPRDYRSS V_SLEEPRDYRSS(1U)
-
-#define S_SLEEPREQVNT 4
-#define V_SLEEPREQVNT(x) ((x) << S_SLEEPREQVNT)
-#define F_SLEEPREQVNT V_SLEEPREQVNT(1U)
-
-#define S_SLEEPREQTBL 3
-#define V_SLEEPREQTBL(x) ((x) << S_SLEEPREQTBL)
-#define F_SLEEPREQTBL V_SLEEPREQTBL(1U)
-
-#define S_SLEEPREQMIB 2
-#define V_SLEEPREQMIB(x) ((x) << S_SLEEPREQMIB)
-#define F_SLEEPREQMIB V_SLEEPREQMIB(1U)
-
-#define S_SLEEPREQARP 1
-#define V_SLEEPREQARP(x) ((x) << S_SLEEPREQARP)
-#define F_SLEEPREQARP V_SLEEPREQARP(1U)
-
-#define S_SLEEPREQRSS 0
-#define V_SLEEPREQRSS(x) ((x) << S_SLEEPREQRSS)
-#define F_SLEEPREQRSS V_SLEEPREQRSS(1U)
-
-#define A_TP_CORE_RDMA 0x55
-
-#define S_IMMEDIATEOP 20
-#define M_IMMEDIATEOP 0xfU
-#define V_IMMEDIATEOP(x) ((x) << S_IMMEDIATEOP)
-#define G_IMMEDIATEOP(x) (((x) >> S_IMMEDIATEOP) & M_IMMEDIATEOP)
-
-#define S_IMMEDIATESE 16
-#define M_IMMEDIATESE 0xfU
-#define V_IMMEDIATESE(x) ((x) << S_IMMEDIATESE)
-#define G_IMMEDIATESE(x) (((x) >> S_IMMEDIATESE) & M_IMMEDIATESE)
-
-#define S_ATOMICREQOP 12
-#define M_ATOMICREQOP 0xfU
-#define V_ATOMICREQOP(x) ((x) << S_ATOMICREQOP)
-#define G_ATOMICREQOP(x) (((x) >> S_ATOMICREQOP) & M_ATOMICREQOP)
-
-#define S_ATOMICRSPOP 8
-#define M_ATOMICRSPOP 0xfU
-#define V_ATOMICRSPOP(x) ((x) << S_ATOMICRSPOP)
-#define G_ATOMICRSPOP(x) (((x) >> S_ATOMICRSPOP) & M_ATOMICRSPOP)
-
-#define S_IMMEDIASEEN 1
-#define V_IMMEDIASEEN(x) ((x) << S_IMMEDIASEEN)
-#define F_IMMEDIASEEN V_IMMEDIASEEN(1U)
-
-#define S_IMMEDIATEEN 0
-#define V_IMMEDIATEEN(x) ((x) << S_IMMEDIATEEN)
-#define F_IMMEDIATEEN V_IMMEDIATEEN(1U)
-
-#define S_SHAREDRQEN 31
-#define V_SHAREDRQEN(x) ((x) << S_SHAREDRQEN)
-#define F_SHAREDRQEN V_SHAREDRQEN(1U)
-
-#define S_SHAREDXRC 30
-#define V_SHAREDXRC(x) ((x) << S_SHAREDXRC)
-#define F_SHAREDXRC V_SHAREDXRC(1U)
-
-#define A_TP_FRAG_CONFIG 0x56
-
-#define S_TLSMODE 16
-#define M_TLSMODE 0x3U
-#define V_TLSMODE(x) ((x) << S_TLSMODE)
-#define G_TLSMODE(x) (((x) >> S_TLSMODE) & M_TLSMODE)
-
-#define S_USERMODE 14
-#define M_USERMODE 0x3U
-#define V_USERMODE(x) ((x) << S_USERMODE)
-#define G_USERMODE(x) (((x) >> S_USERMODE) & M_USERMODE)
-
-#define S_FCOEMODE 12
-#define M_FCOEMODE 0x3U
-#define V_FCOEMODE(x) ((x) << S_FCOEMODE)
-#define G_FCOEMODE(x) (((x) >> S_FCOEMODE) & M_FCOEMODE)
-
-#define S_IANDPMODE 10
-#define M_IANDPMODE 0x3U
-#define V_IANDPMODE(x) ((x) << S_IANDPMODE)
-#define G_IANDPMODE(x) (((x) >> S_IANDPMODE) & M_IANDPMODE)
-
-#define S_RDDPMODE 8
-#define M_RDDPMODE 0x3U
-#define V_RDDPMODE(x) ((x) << S_RDDPMODE)
-#define G_RDDPMODE(x) (((x) >> S_RDDPMODE) & M_RDDPMODE)
-
-#define S_IWARPMODE 6
-#define M_IWARPMODE 0x3U
-#define V_IWARPMODE(x) ((x) << S_IWARPMODE)
-#define G_IWARPMODE(x) (((x) >> S_IWARPMODE) & M_IWARPMODE)
-
-#define S_ISCSIMODE 4
-#define M_ISCSIMODE 0x3U
-#define V_ISCSIMODE(x) ((x) << S_ISCSIMODE)
-#define G_ISCSIMODE(x) (((x) >> S_ISCSIMODE) & M_ISCSIMODE)
-
-#define S_DDPMODE 2
-#define M_DDPMODE 0x3U
-#define V_DDPMODE(x) ((x) << S_DDPMODE)
-#define G_DDPMODE(x) (((x) >> S_DDPMODE) & M_DDPMODE)
-
-#define S_PASSMODE 0
-#define M_PASSMODE 0x3U
-#define V_PASSMODE(x) ((x) << S_PASSMODE)
-#define G_PASSMODE(x) (((x) >> S_PASSMODE) & M_PASSMODE)
-
-#define A_TP_CMM_CONFIG 0x57
-
-#define S_WRCNTIDLE 16
-#define M_WRCNTIDLE 0xffffU
-#define V_WRCNTIDLE(x) ((x) << S_WRCNTIDLE)
-#define G_WRCNTIDLE(x) (((x) >> S_WRCNTIDLE) & M_WRCNTIDLE)
-
-#define S_RDTHRESHOLD 8
-#define M_RDTHRESHOLD 0x3fU
-#define V_RDTHRESHOLD(x) ((x) << S_RDTHRESHOLD)
-#define G_RDTHRESHOLD(x) (((x) >> S_RDTHRESHOLD) & M_RDTHRESHOLD)
-
-#define S_WRTHRLEVEL2 7
-#define V_WRTHRLEVEL2(x) ((x) << S_WRTHRLEVEL2)
-#define F_WRTHRLEVEL2 V_WRTHRLEVEL2(1U)
-
-#define S_WRTHRLEVEL1 6
-#define V_WRTHRLEVEL1(x) ((x) << S_WRTHRLEVEL1)
-#define F_WRTHRLEVEL1 V_WRTHRLEVEL1(1U)
-
-#define S_WRTHRTHRESHEN 5
-#define V_WRTHRTHRESHEN(x) ((x) << S_WRTHRTHRESHEN)
-#define F_WRTHRTHRESHEN V_WRTHRTHRESHEN(1U)
-
-#define S_WRTHRTHRESH 0
-#define M_WRTHRTHRESH 0x1fU
-#define V_WRTHRTHRESH(x) ((x) << S_WRTHRTHRESH)
-#define G_WRTHRTHRESH(x) (((x) >> S_WRTHRTHRESH) & M_WRTHRTHRESH)
-
-#define A_TP_VXLAN_CONFIG 0x58
-
-#define S_VXLANFLAGS 16
-#define M_VXLANFLAGS 0xffffU
-#define V_VXLANFLAGS(x) ((x) << S_VXLANFLAGS)
-#define G_VXLANFLAGS(x) (((x) >> S_VXLANFLAGS) & M_VXLANFLAGS)
-
-#define S_VXLANTYPE 0
-#define M_VXLANTYPE 0xffffU
-#define V_VXLANTYPE(x) ((x) << S_VXLANTYPE)
-#define G_VXLANTYPE(x) (((x) >> S_VXLANTYPE) & M_VXLANTYPE)
-
-#define A_TP_NVGRE_CONFIG 0x59
-
-#define S_GREFLAGS 16
-#define M_GREFLAGS 0xffffU
-#define V_GREFLAGS(x) ((x) << S_GREFLAGS)
-#define G_GREFLAGS(x) (((x) >> S_GREFLAGS) & M_GREFLAGS)
-
-#define S_GRETYPE 0
-#define M_GRETYPE 0xffffU
-#define V_GRETYPE(x) ((x) << S_GRETYPE)
-#define G_GRETYPE(x) (((x) >> S_GRETYPE) & M_GRETYPE)
-
-#define A_TP_DBG_CLEAR 0x60
-#define A_TP_DBG_CORE_HDR0 0x61
-
-#define S_E_TCP_OP_SRDY 16
-#define V_E_TCP_OP_SRDY(x) ((x) << S_E_TCP_OP_SRDY)
-#define F_E_TCP_OP_SRDY V_E_TCP_OP_SRDY(1U)
-
-#define S_E_PLD_TXZEROP_SRDY 15
-#define V_E_PLD_TXZEROP_SRDY(x) ((x) << S_E_PLD_TXZEROP_SRDY)
-#define F_E_PLD_TXZEROP_SRDY V_E_PLD_TXZEROP_SRDY(1U)
-
-#define S_E_PLD_RX_SRDY 14
-#define V_E_PLD_RX_SRDY(x) ((x) << S_E_PLD_RX_SRDY)
-#define F_E_PLD_RX_SRDY V_E_PLD_RX_SRDY(1U)
-
-#define S_E_RX_ERROR_SRDY 13
-#define V_E_RX_ERROR_SRDY(x) ((x) << S_E_RX_ERROR_SRDY)
-#define F_E_RX_ERROR_SRDY V_E_RX_ERROR_SRDY(1U)
-
-#define S_E_RX_ISS_SRDY 12
-#define V_E_RX_ISS_SRDY(x) ((x) << S_E_RX_ISS_SRDY)
-#define F_E_RX_ISS_SRDY V_E_RX_ISS_SRDY(1U)
-
-#define S_C_TCP_OP_SRDY 11
-#define V_C_TCP_OP_SRDY(x) ((x) << S_C_TCP_OP_SRDY)
-#define F_C_TCP_OP_SRDY V_C_TCP_OP_SRDY(1U)
-
-#define S_C_PLD_TXZEROP_SRDY 10
-#define V_C_PLD_TXZEROP_SRDY(x) ((x) << S_C_PLD_TXZEROP_SRDY)
-#define F_C_PLD_TXZEROP_SRDY V_C_PLD_TXZEROP_SRDY(1U)
-
-#define S_C_PLD_RX_SRDY 9
-#define V_C_PLD_RX_SRDY(x) ((x) << S_C_PLD_RX_SRDY)
-#define F_C_PLD_RX_SRDY V_C_PLD_RX_SRDY(1U)
-
-#define S_C_RX_ERROR_SRDY 8
-#define V_C_RX_ERROR_SRDY(x) ((x) << S_C_RX_ERROR_SRDY)
-#define F_C_RX_ERROR_SRDY V_C_RX_ERROR_SRDY(1U)
-
-#define S_C_RX_ISS_SRDY 7
-#define V_C_RX_ISS_SRDY(x) ((x) << S_C_RX_ISS_SRDY)
-#define F_C_RX_ISS_SRDY V_C_RX_ISS_SRDY(1U)
-
-#define S_E_CPL5_TXVALID 6
-#define V_E_CPL5_TXVALID(x) ((x) << S_E_CPL5_TXVALID)
-#define F_E_CPL5_TXVALID V_E_CPL5_TXVALID(1U)
-
-#define S_E_ETH_TXVALID 5
-#define V_E_ETH_TXVALID(x) ((x) << S_E_ETH_TXVALID)
-#define F_E_ETH_TXVALID V_E_ETH_TXVALID(1U)
-
-#define S_E_IP_TXVALID 4
-#define V_E_IP_TXVALID(x) ((x) << S_E_IP_TXVALID)
-#define F_E_IP_TXVALID V_E_IP_TXVALID(1U)
-
-#define S_E_TCP_TXVALID 3
-#define V_E_TCP_TXVALID(x) ((x) << S_E_TCP_TXVALID)
-#define F_E_TCP_TXVALID V_E_TCP_TXVALID(1U)
-
-#define S_C_CPL5_RXVALID 2
-#define V_C_CPL5_RXVALID(x) ((x) << S_C_CPL5_RXVALID)
-#define F_C_CPL5_RXVALID V_C_CPL5_RXVALID(1U)
-
-#define S_C_CPL5_TXVALID 1
-#define V_C_CPL5_TXVALID(x) ((x) << S_C_CPL5_TXVALID)
-#define F_C_CPL5_TXVALID V_C_CPL5_TXVALID(1U)
-
-#define S_E_TCP_OPT_RXVALID 0
-#define V_E_TCP_OPT_RXVALID(x) ((x) << S_E_TCP_OPT_RXVALID)
-#define F_E_TCP_OPT_RXVALID V_E_TCP_OPT_RXVALID(1U)
-
-#define A_TP_DBG_CORE_HDR1 0x62
-
-#define S_E_CPL5_TXFULL 6
-#define V_E_CPL5_TXFULL(x) ((x) << S_E_CPL5_TXFULL)
-#define F_E_CPL5_TXFULL V_E_CPL5_TXFULL(1U)
-
-#define S_E_ETH_TXFULL 5
-#define V_E_ETH_TXFULL(x) ((x) << S_E_ETH_TXFULL)
-#define F_E_ETH_TXFULL V_E_ETH_TXFULL(1U)
-
-#define S_E_IP_TXFULL 4
-#define V_E_IP_TXFULL(x) ((x) << S_E_IP_TXFULL)
-#define F_E_IP_TXFULL V_E_IP_TXFULL(1U)
-
-#define S_E_TCP_TXFULL 3
-#define V_E_TCP_TXFULL(x) ((x) << S_E_TCP_TXFULL)
-#define F_E_TCP_TXFULL V_E_TCP_TXFULL(1U)
-
-#define S_C_CPL5_RXFULL 2
-#define V_C_CPL5_RXFULL(x) ((x) << S_C_CPL5_RXFULL)
-#define F_C_CPL5_RXFULL V_C_CPL5_RXFULL(1U)
-
-#define S_C_CPL5_TXFULL 1
-#define V_C_CPL5_TXFULL(x) ((x) << S_C_CPL5_TXFULL)
-#define F_C_CPL5_TXFULL V_C_CPL5_TXFULL(1U)
-
-#define S_E_TCP_OPT_RXFULL 0
-#define V_E_TCP_OPT_RXFULL(x) ((x) << S_E_TCP_OPT_RXFULL)
-#define F_E_TCP_OPT_RXFULL V_E_TCP_OPT_RXFULL(1U)
-
-#define A_TP_DBG_CORE_FATAL 0x63
-
-#define S_EMSGFATAL 31
-#define V_EMSGFATAL(x) ((x) << S_EMSGFATAL)
-#define F_EMSGFATAL V_EMSGFATAL(1U)
-
-#define S_CMSGFATAL 30
-#define V_CMSGFATAL(x) ((x) << S_CMSGFATAL)
-#define F_CMSGFATAL V_CMSGFATAL(1U)
-
-#define S_PAWSFATAL 29
-#define V_PAWSFATAL(x) ((x) << S_PAWSFATAL)
-#define F_PAWSFATAL V_PAWSFATAL(1U)
-
-#define S_SRAMFATAL 28
-#define V_SRAMFATAL(x) ((x) << S_SRAMFATAL)
-#define F_SRAMFATAL V_SRAMFATAL(1U)
-
-#define S_CPCMDCONG 24
-#define M_CPCMDCONG 0xfU
-#define V_CPCMDCONG(x) ((x) << S_CPCMDCONG)
-#define G_CPCMDCONG(x) (((x) >> S_CPCMDCONG) & M_CPCMDCONG)
-
-#define S_EPCMDCONG 22
-#define M_EPCMDCONG 0x3U
-#define V_EPCMDCONG(x) ((x) << S_EPCMDCONG)
-#define G_EPCMDCONG(x) (((x) >> S_EPCMDCONG) & M_EPCMDCONG)
-
-#define S_CPCMDLENFATAL 21
-#define V_CPCMDLENFATAL(x) ((x) << S_CPCMDLENFATAL)
-#define F_CPCMDLENFATAL V_CPCMDLENFATAL(1U)
-
-#define S_EPCMDLENFATAL 20
-#define V_EPCMDLENFATAL(x) ((x) << S_EPCMDLENFATAL)
-#define F_EPCMDLENFATAL V_EPCMDLENFATAL(1U)
-
-#define S_CPCMDVALID 16
-#define M_CPCMDVALID 0xfU
-#define V_CPCMDVALID(x) ((x) << S_CPCMDVALID)
-#define G_CPCMDVALID(x) (((x) >> S_CPCMDVALID) & M_CPCMDVALID)
-
-#define S_CPCMDAFULL 12
-#define M_CPCMDAFULL 0xfU
-#define V_CPCMDAFULL(x) ((x) << S_CPCMDAFULL)
-#define G_CPCMDAFULL(x) (((x) >> S_CPCMDAFULL) & M_CPCMDAFULL)
-
-#define S_EPCMDVALID 10
-#define M_EPCMDVALID 0x3U
-#define V_EPCMDVALID(x) ((x) << S_EPCMDVALID)
-#define G_EPCMDVALID(x) (((x) >> S_EPCMDVALID) & M_EPCMDVALID)
-
-#define S_EPCMDAFULL 8
-#define M_EPCMDAFULL 0x3U
-#define V_EPCMDAFULL(x) ((x) << S_EPCMDAFULL)
-#define G_EPCMDAFULL(x) (((x) >> S_EPCMDAFULL) & M_EPCMDAFULL)
-
-#define S_CPCMDEOIFATAL 7
-#define V_CPCMDEOIFATAL(x) ((x) << S_CPCMDEOIFATAL)
-#define F_CPCMDEOIFATAL V_CPCMDEOIFATAL(1U)
-
-#define S_CMDBRQFATAL 4
-#define V_CMDBRQFATAL(x) ((x) << S_CMDBRQFATAL)
-#define F_CMDBRQFATAL V_CMDBRQFATAL(1U)
-
-#define S_CNONZEROPPOPCNT 2
-#define M_CNONZEROPPOPCNT 0x3U
-#define V_CNONZEROPPOPCNT(x) ((x) << S_CNONZEROPPOPCNT)
-#define G_CNONZEROPPOPCNT(x) (((x) >> S_CNONZEROPPOPCNT) & M_CNONZEROPPOPCNT)
-
-#define S_CPCMDEOICNT 0
-#define M_CPCMDEOICNT 0x3U
-#define V_CPCMDEOICNT(x) ((x) << S_CPCMDEOICNT)
-#define G_CPCMDEOICNT(x) (((x) >> S_CPCMDEOICNT) & M_CPCMDEOICNT)
-
-#define S_CPCMDTTLFATAL 6
-#define V_CPCMDTTLFATAL(x) ((x) << S_CPCMDTTLFATAL)
-#define F_CPCMDTTLFATAL V_CPCMDTTLFATAL(1U)
-
-#define S_CDATACHNFATAL 5
-#define V_CDATACHNFATAL(x) ((x) << S_CDATACHNFATAL)
-#define F_CDATACHNFATAL V_CDATACHNFATAL(1U)
-
-#define A_TP_DBG_CORE_OUT 0x64
-
-#define S_CCPLENC 26
-#define V_CCPLENC(x) ((x) << S_CCPLENC)
-#define F_CCPLENC V_CCPLENC(1U)
-
-#define S_CWRCPLPKT 25
-#define V_CWRCPLPKT(x) ((x) << S_CWRCPLPKT)
-#define F_CWRCPLPKT V_CWRCPLPKT(1U)
-
-#define S_CWRETHPKT 24
-#define V_CWRETHPKT(x) ((x) << S_CWRETHPKT)
-#define F_CWRETHPKT V_CWRETHPKT(1U)
-
-#define S_CWRIPPKT 23
-#define V_CWRIPPKT(x) ((x) << S_CWRIPPKT)
-#define F_CWRIPPKT V_CWRIPPKT(1U)
-
-#define S_CWRTCPPKT 22
-#define V_CWRTCPPKT(x) ((x) << S_CWRTCPPKT)
-#define F_CWRTCPPKT V_CWRTCPPKT(1U)
-
-#define S_CWRZEROP 21
-#define V_CWRZEROP(x) ((x) << S_CWRZEROP)
-#define F_CWRZEROP V_CWRZEROP(1U)
-
-#define S_CCPLTXFULL 20
-#define V_CCPLTXFULL(x) ((x) << S_CCPLTXFULL)
-#define F_CCPLTXFULL V_CCPLTXFULL(1U)
-
-#define S_CETHTXFULL 19
-#define V_CETHTXFULL(x) ((x) << S_CETHTXFULL)
-#define F_CETHTXFULL V_CETHTXFULL(1U)
-
-#define S_CIPTXFULL 18
-#define V_CIPTXFULL(x) ((x) << S_CIPTXFULL)
-#define F_CIPTXFULL V_CIPTXFULL(1U)
-
-#define S_CTCPTXFULL 17
-#define V_CTCPTXFULL(x) ((x) << S_CTCPTXFULL)
-#define F_CTCPTXFULL V_CTCPTXFULL(1U)
-
-#define S_CPLDTXZEROPDRDY 16
-#define V_CPLDTXZEROPDRDY(x) ((x) << S_CPLDTXZEROPDRDY)
-#define F_CPLDTXZEROPDRDY V_CPLDTXZEROPDRDY(1U)
-
-#define S_ECPLENC 10
-#define V_ECPLENC(x) ((x) << S_ECPLENC)
-#define F_ECPLENC V_ECPLENC(1U)
-
-#define S_EWRCPLPKT 9
-#define V_EWRCPLPKT(x) ((x) << S_EWRCPLPKT)
-#define F_EWRCPLPKT V_EWRCPLPKT(1U)
-
-#define S_EWRETHPKT 8
-#define V_EWRETHPKT(x) ((x) << S_EWRETHPKT)
-#define F_EWRETHPKT V_EWRETHPKT(1U)
-
-#define S_EWRIPPKT 7
-#define V_EWRIPPKT(x) ((x) << S_EWRIPPKT)
-#define F_EWRIPPKT V_EWRIPPKT(1U)
-
-#define S_EWRTCPPKT 6
-#define V_EWRTCPPKT(x) ((x) << S_EWRTCPPKT)
-#define F_EWRTCPPKT V_EWRTCPPKT(1U)
-
-#define S_EWRZEROP 5
-#define V_EWRZEROP(x) ((x) << S_EWRZEROP)
-#define F_EWRZEROP V_EWRZEROP(1U)
-
-#define S_ECPLTXFULL 4
-#define V_ECPLTXFULL(x) ((x) << S_ECPLTXFULL)
-#define F_ECPLTXFULL V_ECPLTXFULL(1U)
-
-#define S_EETHTXFULL 3
-#define V_EETHTXFULL(x) ((x) << S_EETHTXFULL)
-#define F_EETHTXFULL V_EETHTXFULL(1U)
-
-#define S_EIPTXFULL 2
-#define V_EIPTXFULL(x) ((x) << S_EIPTXFULL)
-#define F_EIPTXFULL V_EIPTXFULL(1U)
-
-#define S_ETCPTXFULL 1
-#define V_ETCPTXFULL(x) ((x) << S_ETCPTXFULL)
-#define F_ETCPTXFULL V_ETCPTXFULL(1U)
-
-#define S_EPLDTXZEROPDRDY 0
-#define V_EPLDTXZEROPDRDY(x) ((x) << S_EPLDTXZEROPDRDY)
-#define F_EPLDTXZEROPDRDY V_EPLDTXZEROPDRDY(1U)
-
-#define S_CRXBUSYOUT 31
-#define V_CRXBUSYOUT(x) ((x) << S_CRXBUSYOUT)
-#define F_CRXBUSYOUT V_CRXBUSYOUT(1U)
-
-#define S_CTXBUSYOUT 30
-#define V_CTXBUSYOUT(x) ((x) << S_CTXBUSYOUT)
-#define F_CTXBUSYOUT V_CTXBUSYOUT(1U)
-
-#define S_CRDCPLPKT 29
-#define V_CRDCPLPKT(x) ((x) << S_CRDCPLPKT)
-#define F_CRDCPLPKT V_CRDCPLPKT(1U)
-
-#define S_CRDTCPPKT 28
-#define V_CRDTCPPKT(x) ((x) << S_CRDTCPPKT)
-#define F_CRDTCPPKT V_CRDTCPPKT(1U)
-
-#define S_CNEWMSG 27
-#define V_CNEWMSG(x) ((x) << S_CNEWMSG)
-#define F_CNEWMSG V_CNEWMSG(1U)
-
-#define S_ERXBUSYOUT 15
-#define V_ERXBUSYOUT(x) ((x) << S_ERXBUSYOUT)
-#define F_ERXBUSYOUT V_ERXBUSYOUT(1U)
-
-#define S_ETXBUSYOUT 14
-#define V_ETXBUSYOUT(x) ((x) << S_ETXBUSYOUT)
-#define F_ETXBUSYOUT V_ETXBUSYOUT(1U)
-
-#define S_ERDCPLPKT 13
-#define V_ERDCPLPKT(x) ((x) << S_ERDCPLPKT)
-#define F_ERDCPLPKT V_ERDCPLPKT(1U)
-
-#define S_ERDTCPPKT 12
-#define V_ERDTCPPKT(x) ((x) << S_ERDTCPPKT)
-#define F_ERDTCPPKT V_ERDTCPPKT(1U)
-
-#define S_ENEWMSG 11
-#define V_ENEWMSG(x) ((x) << S_ENEWMSG)
-#define F_ENEWMSG V_ENEWMSG(1U)
-
-#define A_TP_DBG_CORE_TID 0x65
-
-#define S_LINENUMBER 24
-#define M_LINENUMBER 0x7fU
-#define V_LINENUMBER(x) ((x) << S_LINENUMBER)
-#define G_LINENUMBER(x) (((x) >> S_LINENUMBER) & M_LINENUMBER)
-
-#define S_SPURIOUSMSG 23
-#define V_SPURIOUSMSG(x) ((x) << S_SPURIOUSMSG)
-#define F_SPURIOUSMSG V_SPURIOUSMSG(1U)
-
-#define S_SYNLEARNED 20
-#define V_SYNLEARNED(x) ((x) << S_SYNLEARNED)
-#define F_SYNLEARNED V_SYNLEARNED(1U)
-
-#define S_TIDVALUE 0
-#define M_TIDVALUE 0xfffffU
-#define V_TIDVALUE(x) ((x) << S_TIDVALUE)
-#define G_TIDVALUE(x) (((x) >> S_TIDVALUE) & M_TIDVALUE)
-
-#define S_SRC 21
-#define M_SRC 0x3U
-#define V_SRC(x) ((x) << S_SRC)
-#define G_SRC(x) (((x) >> S_SRC) & M_SRC)
-
-#define A_TP_DBG_ENG_RES0 0x66
-
-#define S_RESOURCESREADY 31
-#define V_RESOURCESREADY(x) ((x) << S_RESOURCESREADY)
-#define F_RESOURCESREADY V_RESOURCESREADY(1U)
-
-#define S_RCFOPCODEOUTSRDY 30
-#define V_RCFOPCODEOUTSRDY(x) ((x) << S_RCFOPCODEOUTSRDY)
-#define F_RCFOPCODEOUTSRDY V_RCFOPCODEOUTSRDY(1U)
-
-#define S_RCFDATAOUTSRDY 29
-#define V_RCFDATAOUTSRDY(x) ((x) << S_RCFDATAOUTSRDY)
-#define F_RCFDATAOUTSRDY V_RCFDATAOUTSRDY(1U)
-
-#define S_FLUSHINPUTMSG 28
-#define V_FLUSHINPUTMSG(x) ((x) << S_FLUSHINPUTMSG)
-#define F_FLUSHINPUTMSG V_FLUSHINPUTMSG(1U)
-
-#define S_RCFOPSRCOUT 26
-#define M_RCFOPSRCOUT 0x3U
-#define V_RCFOPSRCOUT(x) ((x) << S_RCFOPSRCOUT)
-#define G_RCFOPSRCOUT(x) (((x) >> S_RCFOPSRCOUT) & M_RCFOPSRCOUT)
-
-#define S_C_MSG 25
-#define V_C_MSG(x) ((x) << S_C_MSG)
-#define F_C_MSG V_C_MSG(1U)
-
-#define S_E_MSG 24
-#define V_E_MSG(x) ((x) << S_E_MSG)
-#define F_E_MSG V_E_MSG(1U)
-
-#define S_RCFOPCODEOUT 20
-#define M_RCFOPCODEOUT 0xfU
-#define V_RCFOPCODEOUT(x) ((x) << S_RCFOPCODEOUT)
-#define G_RCFOPCODEOUT(x) (((x) >> S_RCFOPCODEOUT) & M_RCFOPCODEOUT)
-
-#define S_EFFRCFOPCODEOUT 16
-#define M_EFFRCFOPCODEOUT 0xfU
-#define V_EFFRCFOPCODEOUT(x) ((x) << S_EFFRCFOPCODEOUT)
-#define G_EFFRCFOPCODEOUT(x) (((x) >> S_EFFRCFOPCODEOUT) & M_EFFRCFOPCODEOUT)
-
-#define S_SEENRESOURCESREADY 15
-#define V_SEENRESOURCESREADY(x) ((x) << S_SEENRESOURCESREADY)
-#define F_SEENRESOURCESREADY V_SEENRESOURCESREADY(1U)
-
-#define S_RESOURCESREADYCOPY 14
-#define V_RESOURCESREADYCOPY(x) ((x) << S_RESOURCESREADYCOPY)
-#define F_RESOURCESREADYCOPY V_RESOURCESREADYCOPY(1U)
-
-#define S_OPCODEWAITSFORDATA 13
-#define V_OPCODEWAITSFORDATA(x) ((x) << S_OPCODEWAITSFORDATA)
-#define F_OPCODEWAITSFORDATA V_OPCODEWAITSFORDATA(1U)
-
-#define S_CPLDRXSRDY 12
-#define V_CPLDRXSRDY(x) ((x) << S_CPLDRXSRDY)
-#define F_CPLDRXSRDY V_CPLDRXSRDY(1U)
-
-#define S_CPLDRXZEROPSRDY 11
-#define V_CPLDRXZEROPSRDY(x) ((x) << S_CPLDRXZEROPSRDY)
-#define F_CPLDRXZEROPSRDY V_CPLDRXZEROPSRDY(1U)
-
-#define S_EPLDRXZEROPSRDY 10
-#define V_EPLDRXZEROPSRDY(x) ((x) << S_EPLDRXZEROPSRDY)
-#define F_EPLDRXZEROPSRDY V_EPLDRXZEROPSRDY(1U)
-
-#define S_ERXERRORSRDY 9
-#define V_ERXERRORSRDY(x) ((x) << S_ERXERRORSRDY)
-#define F_ERXERRORSRDY V_ERXERRORSRDY(1U)
-
-#define S_EPLDRXSRDY 8
-#define V_EPLDRXSRDY(x) ((x) << S_EPLDRXSRDY)
-#define F_EPLDRXSRDY V_EPLDRXSRDY(1U)
-
-#define S_CRXBUSY 7
-#define V_CRXBUSY(x) ((x) << S_CRXBUSY)
-#define F_CRXBUSY V_CRXBUSY(1U)
-
-#define S_ERXBUSY 6
-#define V_ERXBUSY(x) ((x) << S_ERXBUSY)
-#define F_ERXBUSY V_ERXBUSY(1U)
-
-#define S_TIMERINSERTBUSY 5
-#define V_TIMERINSERTBUSY(x) ((x) << S_TIMERINSERTBUSY)
-#define F_TIMERINSERTBUSY V_TIMERINSERTBUSY(1U)
-
-#define S_WCFBUSY 4
-#define V_WCFBUSY(x) ((x) << S_WCFBUSY)
-#define F_WCFBUSY V_WCFBUSY(1U)
-
-#define S_CTXBUSY 3
-#define V_CTXBUSY(x) ((x) << S_CTXBUSY)
-#define F_CTXBUSY V_CTXBUSY(1U)
-
-#define S_CPCMDBUSY 2
-#define V_CPCMDBUSY(x) ((x) << S_CPCMDBUSY)
-#define F_CPCMDBUSY V_CPCMDBUSY(1U)
-
-#define S_EPCMDBUSY 1
-#define V_EPCMDBUSY(x) ((x) << S_EPCMDBUSY)
-#define F_EPCMDBUSY V_EPCMDBUSY(1U)
-
-#define S_ETXBUSY 0
-#define V_ETXBUSY(x) ((x) << S_ETXBUSY)
-#define F_ETXBUSY V_ETXBUSY(1U)
-
-#define S_EFFOPCODEOUT 16
-#define M_EFFOPCODEOUT 0xfU
-#define V_EFFOPCODEOUT(x) ((x) << S_EFFOPCODEOUT)
-#define G_EFFOPCODEOUT(x) (((x) >> S_EFFOPCODEOUT) & M_EFFOPCODEOUT)
-
-#define S_DELDRDY 14
-#define V_DELDRDY(x) ((x) << S_DELDRDY)
-#define F_DELDRDY V_DELDRDY(1U)
-
-#define S_T5_ETXBUSY 1
-#define V_T5_ETXBUSY(x) ((x) << S_T5_ETXBUSY)
-#define F_T5_ETXBUSY V_T5_ETXBUSY(1U)
-
-#define S_T5_EPCMDBUSY 0
-#define V_T5_EPCMDBUSY(x) ((x) << S_T5_EPCMDBUSY)
-#define F_T5_EPCMDBUSY V_T5_EPCMDBUSY(1U)
-
-#define S_T6_ETXBUSY 1
-#define V_T6_ETXBUSY(x) ((x) << S_T6_ETXBUSY)
-#define F_T6_ETXBUSY V_T6_ETXBUSY(1U)
-
-#define S_T6_EPCMDBUSY 0
-#define V_T6_EPCMDBUSY(x) ((x) << S_T6_EPCMDBUSY)
-#define F_T6_EPCMDBUSY V_T6_EPCMDBUSY(1U)
-
-#define A_TP_DBG_ENG_RES1 0x67
-
-#define S_RXCPLSRDY 31
-#define V_RXCPLSRDY(x) ((x) << S_RXCPLSRDY)
-#define F_RXCPLSRDY V_RXCPLSRDY(1U)
-
-#define S_RXOPTSRDY 30
-#define V_RXOPTSRDY(x) ((x) << S_RXOPTSRDY)
-#define F_RXOPTSRDY V_RXOPTSRDY(1U)
-
-#define S_RXPLDLENSRDY 29
-#define V_RXPLDLENSRDY(x) ((x) << S_RXPLDLENSRDY)
-#define F_RXPLDLENSRDY V_RXPLDLENSRDY(1U)
-
-#define S_RXNOTBUSY 28
-#define V_RXNOTBUSY(x) ((x) << S_RXNOTBUSY)
-#define F_RXNOTBUSY V_RXNOTBUSY(1U)
-
-#define S_CPLCMDIN 20
-#define M_CPLCMDIN 0xffU
-#define V_CPLCMDIN(x) ((x) << S_CPLCMDIN)
-#define G_CPLCMDIN(x) (((x) >> S_CPLCMDIN) & M_CPLCMDIN)
-
-#define S_RCFPTIDSRDY 19
-#define V_RCFPTIDSRDY(x) ((x) << S_RCFPTIDSRDY)
-#define F_RCFPTIDSRDY V_RCFPTIDSRDY(1U)
-
-#define S_EPDUHDRSRDY 18
-#define V_EPDUHDRSRDY(x) ((x) << S_EPDUHDRSRDY)
-#define F_EPDUHDRSRDY V_EPDUHDRSRDY(1U)
-
-#define S_TUNNELPKTREG 17
-#define V_TUNNELPKTREG(x) ((x) << S_TUNNELPKTREG)
-#define F_TUNNELPKTREG V_TUNNELPKTREG(1U)
-
-#define S_TXPKTCSUMSRDY 16
-#define V_TXPKTCSUMSRDY(x) ((x) << S_TXPKTCSUMSRDY)
-#define F_TXPKTCSUMSRDY V_TXPKTCSUMSRDY(1U)
-
-#define S_TABLEACCESSLATENCY 12
-#define M_TABLEACCESSLATENCY 0xfU
-#define V_TABLEACCESSLATENCY(x) ((x) << S_TABLEACCESSLATENCY)
-#define G_TABLEACCESSLATENCY(x) (((x) >> S_TABLEACCESSLATENCY) & M_TABLEACCESSLATENCY)
-
-#define S_MMGRDONE 11
-#define V_MMGRDONE(x) ((x) << S_MMGRDONE)
-#define F_MMGRDONE V_MMGRDONE(1U)
-
-#define S_SEENMMGRDONE 10
-#define V_SEENMMGRDONE(x) ((x) << S_SEENMMGRDONE)
-#define F_SEENMMGRDONE V_SEENMMGRDONE(1U)
-
-#define S_RXERRORSRDY 9
-#define V_RXERRORSRDY(x) ((x) << S_RXERRORSRDY)
-#define F_RXERRORSRDY V_RXERRORSRDY(1U)
-
-#define S_RCFOPTIONSTCPSRDY 8
-#define V_RCFOPTIONSTCPSRDY(x) ((x) << S_RCFOPTIONSTCPSRDY)
-#define F_RCFOPTIONSTCPSRDY V_RCFOPTIONSTCPSRDY(1U)
-
-#define S_ENGINESTATE 6
-#define M_ENGINESTATE 0x3U
-#define V_ENGINESTATE(x) ((x) << S_ENGINESTATE)
-#define G_ENGINESTATE(x) (((x) >> S_ENGINESTATE) & M_ENGINESTATE)
-
-#define S_TABLEACCESINCREMENT 5
-#define V_TABLEACCESINCREMENT(x) ((x) << S_TABLEACCESINCREMENT)
-#define F_TABLEACCESINCREMENT V_TABLEACCESINCREMENT(1U)
-
-#define S_TABLEACCESCOMPLETE 4
-#define V_TABLEACCESCOMPLETE(x) ((x) << S_TABLEACCESCOMPLETE)
-#define F_TABLEACCESCOMPLETE V_TABLEACCESCOMPLETE(1U)
-
-#define S_RCFOPCODEOUTUSABLE 3
-#define V_RCFOPCODEOUTUSABLE(x) ((x) << S_RCFOPCODEOUTUSABLE)
-#define F_RCFOPCODEOUTUSABLE V_RCFOPCODEOUTUSABLE(1U)
-
-#define S_RCFDATAOUTUSABLE 2
-#define V_RCFDATAOUTUSABLE(x) ((x) << S_RCFDATAOUTUSABLE)
-#define F_RCFDATAOUTUSABLE V_RCFDATAOUTUSABLE(1U)
-
-#define S_RCFDATAWAITAFTERRD 1
-#define V_RCFDATAWAITAFTERRD(x) ((x) << S_RCFDATAWAITAFTERRD)
-#define F_RCFDATAWAITAFTERRD V_RCFDATAWAITAFTERRD(1U)
-
-#define S_RCFDATACMRDY 0
-#define V_RCFDATACMRDY(x) ((x) << S_RCFDATACMRDY)
-#define F_RCFDATACMRDY V_RCFDATACMRDY(1U)
-
-#define S_RXISSSRDY 28
-#define V_RXISSSRDY(x) ((x) << S_RXISSSRDY)
-#define F_RXISSSRDY V_RXISSSRDY(1U)
-
-#define A_TP_DBG_ENG_RES2 0x68
-
-#define S_CPLCMDRAW 24
-#define M_CPLCMDRAW 0xffU
-#define V_CPLCMDRAW(x) ((x) << S_CPLCMDRAW)
-#define G_CPLCMDRAW(x) (((x) >> S_CPLCMDRAW) & M_CPLCMDRAW)
-
-#define S_RXMACPORT 20
-#define M_RXMACPORT 0xfU
-#define V_RXMACPORT(x) ((x) << S_RXMACPORT)
-#define G_RXMACPORT(x) (((x) >> S_RXMACPORT) & M_RXMACPORT)
-
-#define S_TXECHANNEL 18
-#define M_TXECHANNEL 0x3U
-#define V_TXECHANNEL(x) ((x) << S_TXECHANNEL)
-#define G_TXECHANNEL(x) (((x) >> S_TXECHANNEL) & M_TXECHANNEL)
-
-#define S_RXECHANNEL 16
-#define M_RXECHANNEL 0x3U
-#define V_RXECHANNEL(x) ((x) << S_RXECHANNEL)
-#define G_RXECHANNEL(x) (((x) >> S_RXECHANNEL) & M_RXECHANNEL)
-
-#define S_CDATAOUT 15
-#define V_CDATAOUT(x) ((x) << S_CDATAOUT)
-#define F_CDATAOUT V_CDATAOUT(1U)
-
-#define S_CREADPDU 14
-#define V_CREADPDU(x) ((x) << S_CREADPDU)
-#define F_CREADPDU V_CREADPDU(1U)
-
-#define S_EDATAOUT 13
-#define V_EDATAOUT(x) ((x) << S_EDATAOUT)
-#define F_EDATAOUT V_EDATAOUT(1U)
-
-#define S_EREADPDU 12
-#define V_EREADPDU(x) ((x) << S_EREADPDU)
-#define F_EREADPDU V_EREADPDU(1U)
-
-#define S_ETCPOPSRDY 11
-#define V_ETCPOPSRDY(x) ((x) << S_ETCPOPSRDY)
-#define F_ETCPOPSRDY V_ETCPOPSRDY(1U)
-
-#define S_CTCPOPSRDY 10
-#define V_CTCPOPSRDY(x) ((x) << S_CTCPOPSRDY)
-#define F_CTCPOPSRDY V_CTCPOPSRDY(1U)
-
-#define S_CPKTOUT 9
-#define V_CPKTOUT(x) ((x) << S_CPKTOUT)
-#define F_CPKTOUT V_CPKTOUT(1U)
-
-#define S_CMDBRSPSRDY 8
-#define V_CMDBRSPSRDY(x) ((x) << S_CMDBRSPSRDY)
-#define F_CMDBRSPSRDY V_CMDBRSPSRDY(1U)
-
-#define S_RXPSTRUCTSFULL 6
-#define M_RXPSTRUCTSFULL 0x3U
-#define V_RXPSTRUCTSFULL(x) ((x) << S_RXPSTRUCTSFULL)
-#define G_RXPSTRUCTSFULL(x) (((x) >> S_RXPSTRUCTSFULL) & M_RXPSTRUCTSFULL)
-
-#define S_RXPAGEPOOLFULL 4
-#define M_RXPAGEPOOLFULL 0x3U
-#define V_RXPAGEPOOLFULL(x) ((x) << S_RXPAGEPOOLFULL)
-#define G_RXPAGEPOOLFULL(x) (((x) >> S_RXPAGEPOOLFULL) & M_RXPAGEPOOLFULL)
-
-#define S_RCFREASONOUT 0
-#define M_RCFREASONOUT 0xfU
-#define V_RCFREASONOUT(x) ((x) << S_RCFREASONOUT)
-#define G_RCFREASONOUT(x) (((x) >> S_RCFREASONOUT) & M_RCFREASONOUT)
-
-#define A_TP_DBG_CORE_PCMD 0x69
-
-#define S_CPCMDEOPCNT 30
-#define M_CPCMDEOPCNT 0x3U
-#define V_CPCMDEOPCNT(x) ((x) << S_CPCMDEOPCNT)
-#define G_CPCMDEOPCNT(x) (((x) >> S_CPCMDEOPCNT) & M_CPCMDEOPCNT)
-
-#define S_CPCMDLENSAVE 16
-#define M_CPCMDLENSAVE 0x3fffU
-#define V_CPCMDLENSAVE(x) ((x) << S_CPCMDLENSAVE)
-#define G_CPCMDLENSAVE(x) (((x) >> S_CPCMDLENSAVE) & M_CPCMDLENSAVE)
-
-#define S_EPCMDEOPCNT 14
-#define M_EPCMDEOPCNT 0x3U
-#define V_EPCMDEOPCNT(x) ((x) << S_EPCMDEOPCNT)
-#define G_EPCMDEOPCNT(x) (((x) >> S_EPCMDEOPCNT) & M_EPCMDEOPCNT)
-
-#define S_EPCMDLENSAVE 0
-#define M_EPCMDLENSAVE 0x3fffU
-#define V_EPCMDLENSAVE(x) ((x) << S_EPCMDLENSAVE)
-#define G_EPCMDLENSAVE(x) (((x) >> S_EPCMDLENSAVE) & M_EPCMDLENSAVE)
-
-#define A_TP_DBG_SCHED_TX 0x6a
-
-#define S_TXCHNXOFF 28
-#define M_TXCHNXOFF 0xfU
-#define V_TXCHNXOFF(x) ((x) << S_TXCHNXOFF)
-#define G_TXCHNXOFF(x) (((x) >> S_TXCHNXOFF) & M_TXCHNXOFF)
-
-#define S_TXFIFOCNG 24
-#define M_TXFIFOCNG 0xfU
-#define V_TXFIFOCNG(x) ((x) << S_TXFIFOCNG)
-#define G_TXFIFOCNG(x) (((x) >> S_TXFIFOCNG) & M_TXFIFOCNG)
-
-#define S_TXPCMDCNG 20
-#define M_TXPCMDCNG 0xfU
-#define V_TXPCMDCNG(x) ((x) << S_TXPCMDCNG)
-#define G_TXPCMDCNG(x) (((x) >> S_TXPCMDCNG) & M_TXPCMDCNG)
-
-#define S_TXLPBKCNG 16
-#define M_TXLPBKCNG 0xfU
-#define V_TXLPBKCNG(x) ((x) << S_TXLPBKCNG)
-#define G_TXLPBKCNG(x) (((x) >> S_TXLPBKCNG) & M_TXLPBKCNG)
-
-#define S_TXHDRCNG 8
-#define M_TXHDRCNG 0xffU
-#define V_TXHDRCNG(x) ((x) << S_TXHDRCNG)
-#define G_TXHDRCNG(x) (((x) >> S_TXHDRCNG) & M_TXHDRCNG)
-
-#define S_TXMODXOFF 0
-#define M_TXMODXOFF 0xffU
-#define V_TXMODXOFF(x) ((x) << S_TXMODXOFF)
-#define G_TXMODXOFF(x) (((x) >> S_TXMODXOFF) & M_TXMODXOFF)
-
-#define A_TP_DBG_SCHED_RX 0x6b
-
-#define S_RXCHNXOFF 28
-#define M_RXCHNXOFF 0xfU
-#define V_RXCHNXOFF(x) ((x) << S_RXCHNXOFF)
-#define G_RXCHNXOFF(x) (((x) >> S_RXCHNXOFF) & M_RXCHNXOFF)
-
-#define S_RXSGECNG 24
-#define M_RXSGECNG 0xfU
-#define V_RXSGECNG(x) ((x) << S_RXSGECNG)
-#define G_RXSGECNG(x) (((x) >> S_RXSGECNG) & M_RXSGECNG)
-
-#define S_RXFIFOCNG 22
-#define M_RXFIFOCNG 0x3U
-#define V_RXFIFOCNG(x) ((x) << S_RXFIFOCNG)
-#define G_RXFIFOCNG(x) (((x) >> S_RXFIFOCNG) & M_RXFIFOCNG)
-
-#define S_RXPCMDCNG 20
-#define M_RXPCMDCNG 0x3U
-#define V_RXPCMDCNG(x) ((x) << S_RXPCMDCNG)
-#define G_RXPCMDCNG(x) (((x) >> S_RXPCMDCNG) & M_RXPCMDCNG)
-
-#define S_RXLPBKCNG 16
-#define M_RXLPBKCNG 0xfU
-#define V_RXLPBKCNG(x) ((x) << S_RXLPBKCNG)
-#define G_RXLPBKCNG(x) (((x) >> S_RXLPBKCNG) & M_RXLPBKCNG)
-
-#define S_RXHDRCNG 8
-#define M_RXHDRCNG 0xfU
-#define V_RXHDRCNG(x) ((x) << S_RXHDRCNG)
-#define G_RXHDRCNG(x) (((x) >> S_RXHDRCNG) & M_RXHDRCNG)
-
-#define S_RXMODXOFF 0
-#define M_RXMODXOFF 0x3U
-#define V_RXMODXOFF(x) ((x) << S_RXMODXOFF)
-#define G_RXMODXOFF(x) (((x) >> S_RXMODXOFF) & M_RXMODXOFF)
-
-#define S_T5_RXFIFOCNG 20
-#define M_T5_RXFIFOCNG 0xfU
-#define V_T5_RXFIFOCNG(x) ((x) << S_T5_RXFIFOCNG)
-#define G_T5_RXFIFOCNG(x) (((x) >> S_T5_RXFIFOCNG) & M_T5_RXFIFOCNG)
-
-#define S_T5_RXPCMDCNG 14
-#define M_T5_RXPCMDCNG 0x3U
-#define V_T5_RXPCMDCNG(x) ((x) << S_T5_RXPCMDCNG)
-#define G_T5_RXPCMDCNG(x) (((x) >> S_T5_RXPCMDCNG) & M_T5_RXPCMDCNG)
-
-#define S_T6_RXFIFOCNG 20
-#define M_T6_RXFIFOCNG 0xfU
-#define V_T6_RXFIFOCNG(x) ((x) << S_T6_RXFIFOCNG)
-#define G_T6_RXFIFOCNG(x) (((x) >> S_T6_RXFIFOCNG) & M_T6_RXFIFOCNG)
-
-#define S_T6_RXPCMDCNG 14
-#define M_T6_RXPCMDCNG 0x3U
-#define V_T6_RXPCMDCNG(x) ((x) << S_T6_RXPCMDCNG)
-#define G_T6_RXPCMDCNG(x) (((x) >> S_T6_RXPCMDCNG) & M_T6_RXPCMDCNG)
-
-#define A_TP_DBG_ERROR_CNT 0x6c
-#define A_TP_DBG_CORE_CPL 0x6d
-
-#define S_CPLCMDOUT3 24
-#define M_CPLCMDOUT3 0xffU
-#define V_CPLCMDOUT3(x) ((x) << S_CPLCMDOUT3)
-#define G_CPLCMDOUT3(x) (((x) >> S_CPLCMDOUT3) & M_CPLCMDOUT3)
-
-#define S_CPLCMDOUT2 16
-#define M_CPLCMDOUT2 0xffU
-#define V_CPLCMDOUT2(x) ((x) << S_CPLCMDOUT2)
-#define G_CPLCMDOUT2(x) (((x) >> S_CPLCMDOUT2) & M_CPLCMDOUT2)
-
-#define S_CPLCMDOUT1 8
-#define M_CPLCMDOUT1 0xffU
-#define V_CPLCMDOUT1(x) ((x) << S_CPLCMDOUT1)
-#define G_CPLCMDOUT1(x) (((x) >> S_CPLCMDOUT1) & M_CPLCMDOUT1)
-
-#define S_CPLCMDOUT0 0
-#define M_CPLCMDOUT0 0xffU
-#define V_CPLCMDOUT0(x) ((x) << S_CPLCMDOUT0)
-#define G_CPLCMDOUT0(x) (((x) >> S_CPLCMDOUT0) & M_CPLCMDOUT0)
-
-#define A_TP_MIB_DEBUG 0x6f
-
-#define S_SRC3 31
-#define V_SRC3(x) ((x) << S_SRC3)
-#define F_SRC3 V_SRC3(1U)
-
-#define S_LINENUM3 24
-#define M_LINENUM3 0x7fU
-#define V_LINENUM3(x) ((x) << S_LINENUM3)
-#define G_LINENUM3(x) (((x) >> S_LINENUM3) & M_LINENUM3)
-
-#define S_SRC2 23
-#define V_SRC2(x) ((x) << S_SRC2)
-#define F_SRC2 V_SRC2(1U)
-
-#define S_LINENUM2 16
-#define M_LINENUM2 0x7fU
-#define V_LINENUM2(x) ((x) << S_LINENUM2)
-#define G_LINENUM2(x) (((x) >> S_LINENUM2) & M_LINENUM2)
-
-#define S_SRC1 15
-#define V_SRC1(x) ((x) << S_SRC1)
-#define F_SRC1 V_SRC1(1U)
-
-#define S_LINENUM1 8
-#define M_LINENUM1 0x7fU
-#define V_LINENUM1(x) ((x) << S_LINENUM1)
-#define G_LINENUM1(x) (((x) >> S_LINENUM1) & M_LINENUM1)
-
-#define S_SRC0 7
-#define V_SRC0(x) ((x) << S_SRC0)
-#define F_SRC0 V_SRC0(1U)
-
-#define S_LINENUM0 0
-#define M_LINENUM0 0x7fU
-#define V_LINENUM0(x) ((x) << S_LINENUM0)
-#define G_LINENUM0(x) (((x) >> S_LINENUM0) & M_LINENUM0)
-
-#define A_TP_DBG_CACHE_WR_ALL 0x70
-#define A_TP_DBG_CACHE_WR_HIT 0x71
-#define A_TP_DBG_CACHE_RD_ALL 0x72
-#define A_TP_DBG_CACHE_RD_HIT 0x73
-#define A_TP_DBG_CACHE_MC_REQ 0x74
-#define A_TP_DBG_CACHE_MC_RSP 0x75
-#define A_TP_T5_TX_DROP_CNT_CH0 0x120
-#define A_TP_T5_TX_DROP_CNT_CH1 0x121
-#define A_TP_TX_DROP_CNT_CH2 0x122
-#define A_TP_TX_DROP_CNT_CH3 0x123
-#define A_TP_TX_DROP_CFG_CH0 0x12b
-
-#define S_TIMERENABLED 31
-#define V_TIMERENABLED(x) ((x) << S_TIMERENABLED)
-#define F_TIMERENABLED V_TIMERENABLED(1U)
-
-#define S_TIMERERRORENABLE 30
-#define V_TIMERERRORENABLE(x) ((x) << S_TIMERERRORENABLE)
-#define F_TIMERERRORENABLE V_TIMERERRORENABLE(1U)
-
-#define S_TIMERTHRESHOLD 4
-#define M_TIMERTHRESHOLD 0x3ffffffU
-#define V_TIMERTHRESHOLD(x) ((x) << S_TIMERTHRESHOLD)
-#define G_TIMERTHRESHOLD(x) (((x) >> S_TIMERTHRESHOLD) & M_TIMERTHRESHOLD)
-
-#define S_PACKETDROPS 0
-#define M_PACKETDROPS 0xfU
-#define V_PACKETDROPS(x) ((x) << S_PACKETDROPS)
-#define G_PACKETDROPS(x) (((x) >> S_PACKETDROPS) & M_PACKETDROPS)
-
-#define A_TP_TX_DROP_CFG_CH1 0x12c
-#define A_TP_TX_DROP_CNT_CH0 0x12d
-
-#define S_TXDROPCNTCH0SENT 16
-#define M_TXDROPCNTCH0SENT 0xffffU
-#define V_TXDROPCNTCH0SENT(x) ((x) << S_TXDROPCNTCH0SENT)
-#define G_TXDROPCNTCH0SENT(x) (((x) >> S_TXDROPCNTCH0SENT) & M_TXDROPCNTCH0SENT)
-
-#define S_TXDROPCNTCH0RCVD 0
-#define M_TXDROPCNTCH0RCVD 0xffffU
-#define V_TXDROPCNTCH0RCVD(x) ((x) << S_TXDROPCNTCH0RCVD)
-#define G_TXDROPCNTCH0RCVD(x) (((x) >> S_TXDROPCNTCH0RCVD) & M_TXDROPCNTCH0RCVD)
-
-#define A_TP_TX_DROP_CNT_CH1 0x12e
-
-#define S_TXDROPCNTCH1SENT 16
-#define M_TXDROPCNTCH1SENT 0xffffU
-#define V_TXDROPCNTCH1SENT(x) ((x) << S_TXDROPCNTCH1SENT)
-#define G_TXDROPCNTCH1SENT(x) (((x) >> S_TXDROPCNTCH1SENT) & M_TXDROPCNTCH1SENT)
-
-#define S_TXDROPCNTCH1RCVD 0
-#define M_TXDROPCNTCH1RCVD 0xffffU
-#define V_TXDROPCNTCH1RCVD(x) ((x) << S_TXDROPCNTCH1RCVD)
-#define G_TXDROPCNTCH1RCVD(x) (((x) >> S_TXDROPCNTCH1RCVD) & M_TXDROPCNTCH1RCVD)
-
-#define A_TP_TX_DROP_MODE 0x12f
-
-#define S_TXDROPMODECH3 3
-#define V_TXDROPMODECH3(x) ((x) << S_TXDROPMODECH3)
-#define F_TXDROPMODECH3 V_TXDROPMODECH3(1U)
-
-#define S_TXDROPMODECH2 2
-#define V_TXDROPMODECH2(x) ((x) << S_TXDROPMODECH2)
-#define F_TXDROPMODECH2 V_TXDROPMODECH2(1U)
-
-#define S_TXDROPMODECH1 1
-#define V_TXDROPMODECH1(x) ((x) << S_TXDROPMODECH1)
-#define F_TXDROPMODECH1 V_TXDROPMODECH1(1U)
-
-#define S_TXDROPMODECH0 0
-#define V_TXDROPMODECH0(x) ((x) << S_TXDROPMODECH0)
-#define F_TXDROPMODECH0 V_TXDROPMODECH0(1U)
-
-#define A_TP_DBG_ESIDE_PKT0 0x130
-
-#define S_ETXSOPCNT 28
-#define M_ETXSOPCNT 0xfU
-#define V_ETXSOPCNT(x) ((x) << S_ETXSOPCNT)
-#define G_ETXSOPCNT(x) (((x) >> S_ETXSOPCNT) & M_ETXSOPCNT)
-
-#define S_ETXEOPCNT 24
-#define M_ETXEOPCNT 0xfU
-#define V_ETXEOPCNT(x) ((x) << S_ETXEOPCNT)
-#define G_ETXEOPCNT(x) (((x) >> S_ETXEOPCNT) & M_ETXEOPCNT)
-
-#define S_ETXPLDSOPCNT 20
-#define M_ETXPLDSOPCNT 0xfU
-#define V_ETXPLDSOPCNT(x) ((x) << S_ETXPLDSOPCNT)
-#define G_ETXPLDSOPCNT(x) (((x) >> S_ETXPLDSOPCNT) & M_ETXPLDSOPCNT)
-
-#define S_ETXPLDEOPCNT 16
-#define M_ETXPLDEOPCNT 0xfU
-#define V_ETXPLDEOPCNT(x) ((x) << S_ETXPLDEOPCNT)
-#define G_ETXPLDEOPCNT(x) (((x) >> S_ETXPLDEOPCNT) & M_ETXPLDEOPCNT)
-
-#define S_ERXSOPCNT 12
-#define M_ERXSOPCNT 0xfU
-#define V_ERXSOPCNT(x) ((x) << S_ERXSOPCNT)
-#define G_ERXSOPCNT(x) (((x) >> S_ERXSOPCNT) & M_ERXSOPCNT)
-
-#define S_ERXEOPCNT 8
-#define M_ERXEOPCNT 0xfU
-#define V_ERXEOPCNT(x) ((x) << S_ERXEOPCNT)
-#define G_ERXEOPCNT(x) (((x) >> S_ERXEOPCNT) & M_ERXEOPCNT)
-
-#define S_ERXPLDSOPCNT 4
-#define M_ERXPLDSOPCNT 0xfU
-#define V_ERXPLDSOPCNT(x) ((x) << S_ERXPLDSOPCNT)
-#define G_ERXPLDSOPCNT(x) (((x) >> S_ERXPLDSOPCNT) & M_ERXPLDSOPCNT)
-
-#define S_ERXPLDEOPCNT 0
-#define M_ERXPLDEOPCNT 0xfU
-#define V_ERXPLDEOPCNT(x) ((x) << S_ERXPLDEOPCNT)
-#define G_ERXPLDEOPCNT(x) (((x) >> S_ERXPLDEOPCNT) & M_ERXPLDEOPCNT)
-
-#define A_TP_DBG_ESIDE_PKT1 0x131
-#define A_TP_DBG_ESIDE_PKT2 0x132
-#define A_TP_DBG_ESIDE_PKT3 0x133
-#define A_TP_DBG_ESIDE_FIFO0 0x134
-
-#define S_PLDRXCSUMVALID1 31
-#define V_PLDRXCSUMVALID1(x) ((x) << S_PLDRXCSUMVALID1)
-#define F_PLDRXCSUMVALID1 V_PLDRXCSUMVALID1(1U)
-
-#define S_PLDRXZEROPSRDY1 30
-#define V_PLDRXZEROPSRDY1(x) ((x) << S_PLDRXZEROPSRDY1)
-#define F_PLDRXZEROPSRDY1 V_PLDRXZEROPSRDY1(1U)
-
-#define S_PLDRXVALID1 29
-#define V_PLDRXVALID1(x) ((x) << S_PLDRXVALID1)
-#define F_PLDRXVALID1 V_PLDRXVALID1(1U)
-
-#define S_TCPRXVALID1 28
-#define V_TCPRXVALID1(x) ((x) << S_TCPRXVALID1)
-#define F_TCPRXVALID1 V_TCPRXVALID1(1U)
-
-#define S_IPRXVALID1 27
-#define V_IPRXVALID1(x) ((x) << S_IPRXVALID1)
-#define F_IPRXVALID1 V_IPRXVALID1(1U)
-
-#define S_ETHRXVALID1 26
-#define V_ETHRXVALID1(x) ((x) << S_ETHRXVALID1)
-#define F_ETHRXVALID1 V_ETHRXVALID1(1U)
-
-#define S_CPLRXVALID1 25
-#define V_CPLRXVALID1(x) ((x) << S_CPLRXVALID1)
-#define F_CPLRXVALID1 V_CPLRXVALID1(1U)
-
-#define S_FSTATIC1 24
-#define V_FSTATIC1(x) ((x) << S_FSTATIC1)
-#define F_FSTATIC1 V_FSTATIC1(1U)
-
-#define S_ERRORSRDY1 23
-#define V_ERRORSRDY1(x) ((x) << S_ERRORSRDY1)
-#define F_ERRORSRDY1 V_ERRORSRDY1(1U)
-
-#define S_PLDTXSRDY1 22
-#define V_PLDTXSRDY1(x) ((x) << S_PLDTXSRDY1)
-#define F_PLDTXSRDY1 V_PLDTXSRDY1(1U)
-
-#define S_DBVLD1 21
-#define V_DBVLD1(x) ((x) << S_DBVLD1)
-#define F_DBVLD1 V_DBVLD1(1U)
-
-#define S_PLDTXVALID1 20
-#define V_PLDTXVALID1(x) ((x) << S_PLDTXVALID1)
-#define F_PLDTXVALID1 V_PLDTXVALID1(1U)
-
-#define S_ETXVALID1 19
-#define V_ETXVALID1(x) ((x) << S_ETXVALID1)
-#define F_ETXVALID1 V_ETXVALID1(1U)
-
-#define S_ETXFULL1 18
-#define V_ETXFULL1(x) ((x) << S_ETXFULL1)
-#define F_ETXFULL1 V_ETXFULL1(1U)
-
-#define S_ERXVALID1 17
-#define V_ERXVALID1(x) ((x) << S_ERXVALID1)
-#define F_ERXVALID1 V_ERXVALID1(1U)
-
-#define S_ERXFULL1 16
-#define V_ERXFULL1(x) ((x) << S_ERXFULL1)
-#define F_ERXFULL1 V_ERXFULL1(1U)
-
-#define S_PLDRXCSUMVALID0 15
-#define V_PLDRXCSUMVALID0(x) ((x) << S_PLDRXCSUMVALID0)
-#define F_PLDRXCSUMVALID0 V_PLDRXCSUMVALID0(1U)
-
-#define S_PLDRXZEROPSRDY0 14
-#define V_PLDRXZEROPSRDY0(x) ((x) << S_PLDRXZEROPSRDY0)
-#define F_PLDRXZEROPSRDY0 V_PLDRXZEROPSRDY0(1U)
-
-#define S_PLDRXVALID0 13
-#define V_PLDRXVALID0(x) ((x) << S_PLDRXVALID0)
-#define F_PLDRXVALID0 V_PLDRXVALID0(1U)
-
-#define S_TCPRXVALID0 12
-#define V_TCPRXVALID0(x) ((x) << S_TCPRXVALID0)
-#define F_TCPRXVALID0 V_TCPRXVALID0(1U)
-
-#define S_IPRXVALID0 11
-#define V_IPRXVALID0(x) ((x) << S_IPRXVALID0)
-#define F_IPRXVALID0 V_IPRXVALID0(1U)
-
-#define S_ETHRXVALID0 10
-#define V_ETHRXVALID0(x) ((x) << S_ETHRXVALID0)
-#define F_ETHRXVALID0 V_ETHRXVALID0(1U)
-
-#define S_CPLRXVALID0 9
-#define V_CPLRXVALID0(x) ((x) << S_CPLRXVALID0)
-#define F_CPLRXVALID0 V_CPLRXVALID0(1U)
-
-#define S_FSTATIC0 8
-#define V_FSTATIC0(x) ((x) << S_FSTATIC0)
-#define F_FSTATIC0 V_FSTATIC0(1U)
-
-#define S_ERRORSRDY0 7
-#define V_ERRORSRDY0(x) ((x) << S_ERRORSRDY0)
-#define F_ERRORSRDY0 V_ERRORSRDY0(1U)
-
-#define S_PLDTXSRDY0 6
-#define V_PLDTXSRDY0(x) ((x) << S_PLDTXSRDY0)
-#define F_PLDTXSRDY0 V_PLDTXSRDY0(1U)
-
-#define S_DBVLD0 5
-#define V_DBVLD0(x) ((x) << S_DBVLD0)
-#define F_DBVLD0 V_DBVLD0(1U)
-
-#define S_PLDTXVALID0 4
-#define V_PLDTXVALID0(x) ((x) << S_PLDTXVALID0)
-#define F_PLDTXVALID0 V_PLDTXVALID0(1U)
-
-#define S_ETXVALID0 3
-#define V_ETXVALID0(x) ((x) << S_ETXVALID0)
-#define F_ETXVALID0 V_ETXVALID0(1U)
-
-#define S_ETXFULL0 2
-#define V_ETXFULL0(x) ((x) << S_ETXFULL0)
-#define F_ETXFULL0 V_ETXFULL0(1U)
-
-#define S_ERXVALID0 1
-#define V_ERXVALID0(x) ((x) << S_ERXVALID0)
-#define F_ERXVALID0 V_ERXVALID0(1U)
-
-#define S_ERXFULL0 0
-#define V_ERXFULL0(x) ((x) << S_ERXFULL0)
-#define F_ERXFULL0 V_ERXFULL0(1U)
-
-#define A_TP_DBG_ESIDE_FIFO1 0x135
-
-#define S_PLDRXCSUMVALID3 31
-#define V_PLDRXCSUMVALID3(x) ((x) << S_PLDRXCSUMVALID3)
-#define F_PLDRXCSUMVALID3 V_PLDRXCSUMVALID3(1U)
-
-#define S_PLDRXZEROPSRDY3 30
-#define V_PLDRXZEROPSRDY3(x) ((x) << S_PLDRXZEROPSRDY3)
-#define F_PLDRXZEROPSRDY3 V_PLDRXZEROPSRDY3(1U)
-
-#define S_PLDRXVALID3 29
-#define V_PLDRXVALID3(x) ((x) << S_PLDRXVALID3)
-#define F_PLDRXVALID3 V_PLDRXVALID3(1U)
-
-#define S_TCPRXVALID3 28
-#define V_TCPRXVALID3(x) ((x) << S_TCPRXVALID3)
-#define F_TCPRXVALID3 V_TCPRXVALID3(1U)
-
-#define S_IPRXVALID3 27
-#define V_IPRXVALID3(x) ((x) << S_IPRXVALID3)
-#define F_IPRXVALID3 V_IPRXVALID3(1U)
-
-#define S_ETHRXVALID3 26
-#define V_ETHRXVALID3(x) ((x) << S_ETHRXVALID3)
-#define F_ETHRXVALID3 V_ETHRXVALID3(1U)
-
-#define S_CPLRXVALID3 25
-#define V_CPLRXVALID3(x) ((x) << S_CPLRXVALID3)
-#define F_CPLRXVALID3 V_CPLRXVALID3(1U)
-
-#define S_FSTATIC3 24
-#define V_FSTATIC3(x) ((x) << S_FSTATIC3)
-#define F_FSTATIC3 V_FSTATIC3(1U)
-
-#define S_ERRORSRDY3 23
-#define V_ERRORSRDY3(x) ((x) << S_ERRORSRDY3)
-#define F_ERRORSRDY3 V_ERRORSRDY3(1U)
-
-#define S_PLDTXSRDY3 22
-#define V_PLDTXSRDY3(x) ((x) << S_PLDTXSRDY3)
-#define F_PLDTXSRDY3 V_PLDTXSRDY3(1U)
-
-#define S_DBVLD3 21
-#define V_DBVLD3(x) ((x) << S_DBVLD3)
-#define F_DBVLD3 V_DBVLD3(1U)
-
-#define S_PLDTXVALID3 20
-#define V_PLDTXVALID3(x) ((x) << S_PLDTXVALID3)
-#define F_PLDTXVALID3 V_PLDTXVALID3(1U)
-
-#define S_ETXVALID3 19
-#define V_ETXVALID3(x) ((x) << S_ETXVALID3)
-#define F_ETXVALID3 V_ETXVALID3(1U)
-
-#define S_ETXFULL3 18
-#define V_ETXFULL3(x) ((x) << S_ETXFULL3)
-#define F_ETXFULL3 V_ETXFULL3(1U)
-
-#define S_ERXVALID3 17
-#define V_ERXVALID3(x) ((x) << S_ERXVALID3)
-#define F_ERXVALID3 V_ERXVALID3(1U)
-
-#define S_ERXFULL3 16
-#define V_ERXFULL3(x) ((x) << S_ERXFULL3)
-#define F_ERXFULL3 V_ERXFULL3(1U)
-
-#define S_PLDRXCSUMVALID2 15
-#define V_PLDRXCSUMVALID2(x) ((x) << S_PLDRXCSUMVALID2)
-#define F_PLDRXCSUMVALID2 V_PLDRXCSUMVALID2(1U)
-
-#define S_PLDRXZEROPSRDY2 14
-#define V_PLDRXZEROPSRDY2(x) ((x) << S_PLDRXZEROPSRDY2)
-#define F_PLDRXZEROPSRDY2 V_PLDRXZEROPSRDY2(1U)
-
-#define S_PLDRXVALID2 13
-#define V_PLDRXVALID2(x) ((x) << S_PLDRXVALID2)
-#define F_PLDRXVALID2 V_PLDRXVALID2(1U)
-
-#define S_TCPRXVALID2 12
-#define V_TCPRXVALID2(x) ((x) << S_TCPRXVALID2)
-#define F_TCPRXVALID2 V_TCPRXVALID2(1U)
-
-#define S_IPRXVALID2 11
-#define V_IPRXVALID2(x) ((x) << S_IPRXVALID2)
-#define F_IPRXVALID2 V_IPRXVALID2(1U)
-
-#define S_ETHRXVALID2 10
-#define V_ETHRXVALID2(x) ((x) << S_ETHRXVALID2)
-#define F_ETHRXVALID2 V_ETHRXVALID2(1U)
-
-#define S_CPLRXVALID2 9
-#define V_CPLRXVALID2(x) ((x) << S_CPLRXVALID2)
-#define F_CPLRXVALID2 V_CPLRXVALID2(1U)
-
-#define S_FSTATIC2 8
-#define V_FSTATIC2(x) ((x) << S_FSTATIC2)
-#define F_FSTATIC2 V_FSTATIC2(1U)
-
-#define S_ERRORSRDY2 7
-#define V_ERRORSRDY2(x) ((x) << S_ERRORSRDY2)
-#define F_ERRORSRDY2 V_ERRORSRDY2(1U)
-
-#define S_PLDTXSRDY2 6
-#define V_PLDTXSRDY2(x) ((x) << S_PLDTXSRDY2)
-#define F_PLDTXSRDY2 V_PLDTXSRDY2(1U)
-
-#define S_DBVLD2 5
-#define V_DBVLD2(x) ((x) << S_DBVLD2)
-#define F_DBVLD2 V_DBVLD2(1U)
-
-#define S_PLDTXVALID2 4
-#define V_PLDTXVALID2(x) ((x) << S_PLDTXVALID2)
-#define F_PLDTXVALID2 V_PLDTXVALID2(1U)
-
-#define S_ETXVALID2 3
-#define V_ETXVALID2(x) ((x) << S_ETXVALID2)
-#define F_ETXVALID2 V_ETXVALID2(1U)
-
-#define S_ETXFULL2 2
-#define V_ETXFULL2(x) ((x) << S_ETXFULL2)
-#define F_ETXFULL2 V_ETXFULL2(1U)
-
-#define S_ERXVALID2 1
-#define V_ERXVALID2(x) ((x) << S_ERXVALID2)
-#define F_ERXVALID2 V_ERXVALID2(1U)
-
-#define S_ERXFULL2 0
-#define V_ERXFULL2(x) ((x) << S_ERXFULL2)
-#define F_ERXFULL2 V_ERXFULL2(1U)
-
-#define A_TP_DBG_ESIDE_DISP0 0x136
-
-#define S_RESRDY 31
-#define V_RESRDY(x) ((x) << S_RESRDY)
-#define F_RESRDY V_RESRDY(1U)
-
-#define S_STATE 28
-#define M_STATE 0x7U
-#define V_STATE(x) ((x) << S_STATE)
-#define G_STATE(x) (((x) >> S_STATE) & M_STATE)
-
-#define S_FIFOCPL5RXVALID 27
-#define V_FIFOCPL5RXVALID(x) ((x) << S_FIFOCPL5RXVALID)
-#define F_FIFOCPL5RXVALID V_FIFOCPL5RXVALID(1U)
-
-#define S_FIFOETHRXVALID 26
-#define V_FIFOETHRXVALID(x) ((x) << S_FIFOETHRXVALID)
-#define F_FIFOETHRXVALID V_FIFOETHRXVALID(1U)
-
-#define S_FIFOETHRXSOCP 25
-#define V_FIFOETHRXSOCP(x) ((x) << S_FIFOETHRXSOCP)
-#define F_FIFOETHRXSOCP V_FIFOETHRXSOCP(1U)
-
-#define S_FIFOPLDRXZEROP 24
-#define V_FIFOPLDRXZEROP(x) ((x) << S_FIFOPLDRXZEROP)
-#define F_FIFOPLDRXZEROP V_FIFOPLDRXZEROP(1U)
-
-#define S_PLDRXVALID 23
-#define V_PLDRXVALID(x) ((x) << S_PLDRXVALID)
-#define F_PLDRXVALID V_PLDRXVALID(1U)
-
-#define S_FIFOPLDRXZEROP_SRDY 22
-#define V_FIFOPLDRXZEROP_SRDY(x) ((x) << S_FIFOPLDRXZEROP_SRDY)
-#define F_FIFOPLDRXZEROP_SRDY V_FIFOPLDRXZEROP_SRDY(1U)
-
-#define S_FIFOIPRXVALID 21
-#define V_FIFOIPRXVALID(x) ((x) << S_FIFOIPRXVALID)
-#define F_FIFOIPRXVALID V_FIFOIPRXVALID(1U)
-
-#define S_FIFOTCPRXVALID 20
-#define V_FIFOTCPRXVALID(x) ((x) << S_FIFOTCPRXVALID)
-#define F_FIFOTCPRXVALID V_FIFOTCPRXVALID(1U)
-
-#define S_PLDRXCSUMVALID 19
-#define V_PLDRXCSUMVALID(x) ((x) << S_PLDRXCSUMVALID)
-#define F_PLDRXCSUMVALID V_PLDRXCSUMVALID(1U)
-
-#define S_FIFOIPCSUMSRDY 18
-#define V_FIFOIPCSUMSRDY(x) ((x) << S_FIFOIPCSUMSRDY)
-#define F_FIFOIPCSUMSRDY V_FIFOIPCSUMSRDY(1U)
-
-#define S_FIFOIPPSEUDOCSUMSRDY 17
-#define V_FIFOIPPSEUDOCSUMSRDY(x) ((x) << S_FIFOIPPSEUDOCSUMSRDY)
-#define F_FIFOIPPSEUDOCSUMSRDY V_FIFOIPPSEUDOCSUMSRDY(1U)
-
-#define S_FIFOTCPCSUMSRDY 16
-#define V_FIFOTCPCSUMSRDY(x) ((x) << S_FIFOTCPCSUMSRDY)
-#define F_FIFOTCPCSUMSRDY V_FIFOTCPCSUMSRDY(1U)
-
-#define S_ESTATIC4 12
-#define M_ESTATIC4 0xfU
-#define V_ESTATIC4(x) ((x) << S_ESTATIC4)
-#define G_ESTATIC4(x) (((x) >> S_ESTATIC4) & M_ESTATIC4)
-
-#define S_FIFOCPLSOCPCNT 10
-#define M_FIFOCPLSOCPCNT 0x3U
-#define V_FIFOCPLSOCPCNT(x) ((x) << S_FIFOCPLSOCPCNT)
-#define G_FIFOCPLSOCPCNT(x) (((x) >> S_FIFOCPLSOCPCNT) & M_FIFOCPLSOCPCNT)
-
-#define S_FIFOETHSOCPCNT 8
-#define M_FIFOETHSOCPCNT 0x3U
-#define V_FIFOETHSOCPCNT(x) ((x) << S_FIFOETHSOCPCNT)
-#define G_FIFOETHSOCPCNT(x) (((x) >> S_FIFOETHSOCPCNT) & M_FIFOETHSOCPCNT)
-
-#define S_FIFOIPSOCPCNT 6
-#define M_FIFOIPSOCPCNT 0x3U
-#define V_FIFOIPSOCPCNT(x) ((x) << S_FIFOIPSOCPCNT)
-#define G_FIFOIPSOCPCNT(x) (((x) >> S_FIFOIPSOCPCNT) & M_FIFOIPSOCPCNT)
-
-#define S_FIFOTCPSOCPCNT 4
-#define M_FIFOTCPSOCPCNT 0x3U
-#define V_FIFOTCPSOCPCNT(x) ((x) << S_FIFOTCPSOCPCNT)
-#define G_FIFOTCPSOCPCNT(x) (((x) >> S_FIFOTCPSOCPCNT) & M_FIFOTCPSOCPCNT)
-
-#define S_PLD_RXZEROP_CNT 2
-#define M_PLD_RXZEROP_CNT 0x3U
-#define V_PLD_RXZEROP_CNT(x) ((x) << S_PLD_RXZEROP_CNT)
-#define G_PLD_RXZEROP_CNT(x) (((x) >> S_PLD_RXZEROP_CNT) & M_PLD_RXZEROP_CNT)
-
-#define S_ESTATIC6 1
-#define V_ESTATIC6(x) ((x) << S_ESTATIC6)
-#define F_ESTATIC6 V_ESTATIC6(1U)
-
-#define S_TXFULL 0
-#define V_TXFULL(x) ((x) << S_TXFULL)
-#define F_TXFULL V_TXFULL(1U)
-
-#define S_FIFOGRERXVALID 15
-#define V_FIFOGRERXVALID(x) ((x) << S_FIFOGRERXVALID)
-#define F_FIFOGRERXVALID V_FIFOGRERXVALID(1U)
-
-#define S_FIFOGRERXREADY 14
-#define V_FIFOGRERXREADY(x) ((x) << S_FIFOGRERXREADY)
-#define F_FIFOGRERXREADY V_FIFOGRERXREADY(1U)
-
-#define S_FIFOGRERXSOCP 13
-#define V_FIFOGRERXSOCP(x) ((x) << S_FIFOGRERXSOCP)
-#define F_FIFOGRERXSOCP V_FIFOGRERXSOCP(1U)
-
-#define S_T6_ESTATIC4 12
-#define V_T6_ESTATIC4(x) ((x) << S_T6_ESTATIC4)
-#define F_T6_ESTATIC4 V_T6_ESTATIC4(1U)
-
-#define S_TXFULL_ESIDE0 0
-#define V_TXFULL_ESIDE0(x) ((x) << S_TXFULL_ESIDE0)
-#define F_TXFULL_ESIDE0 V_TXFULL_ESIDE0(1U)
-
-#define A_TP_DBG_ESIDE_DISP1 0x137
-
-#define S_T6_ESTATIC4 12
-#define V_T6_ESTATIC4(x) ((x) << S_T6_ESTATIC4)
-#define F_T6_ESTATIC4 V_T6_ESTATIC4(1U)
-
-#define S_TXFULL_ESIDE1 0
-#define V_TXFULL_ESIDE1(x) ((x) << S_TXFULL_ESIDE1)
-#define F_TXFULL_ESIDE1 V_TXFULL_ESIDE1(1U)
-
-#define A_TP_MAC_MATCH_MAP0 0x138
-
-#define S_MAPVALUEWR 16
-#define M_MAPVALUEWR 0xffU
-#define V_MAPVALUEWR(x) ((x) << S_MAPVALUEWR)
-#define G_MAPVALUEWR(x) (((x) >> S_MAPVALUEWR) & M_MAPVALUEWR)
-
-#define S_MAPINDEX 2
-#define M_MAPINDEX 0x1ffU
-#define V_MAPINDEX(x) ((x) << S_MAPINDEX)
-#define G_MAPINDEX(x) (((x) >> S_MAPINDEX) & M_MAPINDEX)
-
-#define S_MAPREAD 1
-#define V_MAPREAD(x) ((x) << S_MAPREAD)
-#define F_MAPREAD V_MAPREAD(1U)
-
-#define S_MAPWRITE 0
-#define V_MAPWRITE(x) ((x) << S_MAPWRITE)
-#define F_MAPWRITE V_MAPWRITE(1U)
-
-#define A_TP_MAC_MATCH_MAP1 0x139
-
-#define S_MAPVALUERD 0
-#define M_MAPVALUERD 0x1ffU
-#define V_MAPVALUERD(x) ((x) << S_MAPVALUERD)
-#define G_MAPVALUERD(x) (((x) >> S_MAPVALUERD) & M_MAPVALUERD)
-
-#define A_TP_DBG_ESIDE_DISP2 0x13a
-
-#define S_T6_ESTATIC4 12
-#define V_T6_ESTATIC4(x) ((x) << S_T6_ESTATIC4)
-#define F_T6_ESTATIC4 V_T6_ESTATIC4(1U)
-
-#define S_TXFULL_ESIDE2 0
-#define V_TXFULL_ESIDE2(x) ((x) << S_TXFULL_ESIDE2)
-#define F_TXFULL_ESIDE2 V_TXFULL_ESIDE2(1U)
-
-#define A_TP_DBG_ESIDE_DISP3 0x13b
-
-#define S_T6_ESTATIC4 12
-#define V_T6_ESTATIC4(x) ((x) << S_T6_ESTATIC4)
-#define F_T6_ESTATIC4 V_T6_ESTATIC4(1U)
-
-#define S_TXFULL_ESIDE3 0
-#define V_TXFULL_ESIDE3(x) ((x) << S_TXFULL_ESIDE3)
-#define F_TXFULL_ESIDE3 V_TXFULL_ESIDE3(1U)
-
-#define A_TP_DBG_ESIDE_HDR0 0x13c
-
-#define S_TCPSOPCNT 28
-#define M_TCPSOPCNT 0xfU
-#define V_TCPSOPCNT(x) ((x) << S_TCPSOPCNT)
-#define G_TCPSOPCNT(x) (((x) >> S_TCPSOPCNT) & M_TCPSOPCNT)
-
-#define S_TCPEOPCNT 24
-#define M_TCPEOPCNT 0xfU
-#define V_TCPEOPCNT(x) ((x) << S_TCPEOPCNT)
-#define G_TCPEOPCNT(x) (((x) >> S_TCPEOPCNT) & M_TCPEOPCNT)
-
-#define S_IPSOPCNT 20
-#define M_IPSOPCNT 0xfU
-#define V_IPSOPCNT(x) ((x) << S_IPSOPCNT)
-#define G_IPSOPCNT(x) (((x) >> S_IPSOPCNT) & M_IPSOPCNT)
-
-#define S_IPEOPCNT 16
-#define M_IPEOPCNT 0xfU
-#define V_IPEOPCNT(x) ((x) << S_IPEOPCNT)
-#define G_IPEOPCNT(x) (((x) >> S_IPEOPCNT) & M_IPEOPCNT)
-
-#define S_ETHSOPCNT 12
-#define M_ETHSOPCNT 0xfU
-#define V_ETHSOPCNT(x) ((x) << S_ETHSOPCNT)
-#define G_ETHSOPCNT(x) (((x) >> S_ETHSOPCNT) & M_ETHSOPCNT)
-
-#define S_ETHEOPCNT 8
-#define M_ETHEOPCNT 0xfU
-#define V_ETHEOPCNT(x) ((x) << S_ETHEOPCNT)
-#define G_ETHEOPCNT(x) (((x) >> S_ETHEOPCNT) & M_ETHEOPCNT)
-
-#define S_CPLSOPCNT 4
-#define M_CPLSOPCNT 0xfU
-#define V_CPLSOPCNT(x) ((x) << S_CPLSOPCNT)
-#define G_CPLSOPCNT(x) (((x) >> S_CPLSOPCNT) & M_CPLSOPCNT)
-
-#define S_CPLEOPCNT 0
-#define M_CPLEOPCNT 0xfU
-#define V_CPLEOPCNT(x) ((x) << S_CPLEOPCNT)
-#define G_CPLEOPCNT(x) (((x) >> S_CPLEOPCNT) & M_CPLEOPCNT)
-
-#define A_TP_DBG_ESIDE_HDR1 0x13d
-#define A_TP_DBG_ESIDE_HDR2 0x13e
-#define A_TP_DBG_ESIDE_HDR3 0x13f
-#define A_TP_VLAN_PRI_MAP 0x140
-
-#define S_FRAGMENTATION 9
-#define V_FRAGMENTATION(x) ((x) << S_FRAGMENTATION)
-#define F_FRAGMENTATION V_FRAGMENTATION(1U)
-
-#define S_MPSHITTYPE 8
-#define V_MPSHITTYPE(x) ((x) << S_MPSHITTYPE)
-#define F_MPSHITTYPE V_MPSHITTYPE(1U)
-
-#define S_MACMATCH 7
-#define V_MACMATCH(x) ((x) << S_MACMATCH)
-#define F_MACMATCH V_MACMATCH(1U)
-
-#define S_ETHERTYPE 6
-#define V_ETHERTYPE(x) ((x) << S_ETHERTYPE)
-#define F_ETHERTYPE V_ETHERTYPE(1U)
-
-#define S_PROTOCOL 5
-#define V_PROTOCOL(x) ((x) << S_PROTOCOL)
-#define F_PROTOCOL V_PROTOCOL(1U)
-
-#define S_TOS 4
-#define V_TOS(x) ((x) << S_TOS)
-#define F_TOS V_TOS(1U)
-
-#define S_VLAN 3
-#define V_VLAN(x) ((x) << S_VLAN)
-#define F_VLAN V_VLAN(1U)
-
-#define S_VNIC_ID 2
-#define V_VNIC_ID(x) ((x) << S_VNIC_ID)
-#define F_VNIC_ID V_VNIC_ID(1U)
-
-#define S_PORT 1
-#define V_PORT(x) ((x) << S_PORT)
-#define F_PORT V_PORT(1U)
-
-#define S_FCOE 0
-#define V_FCOE(x) ((x) << S_FCOE)
-#define F_FCOE V_FCOE(1U)
-
-#define S_FILTERMODE 15
-#define V_FILTERMODE(x) ((x) << S_FILTERMODE)
-#define F_FILTERMODE V_FILTERMODE(1U)
-
-#define S_FCOEMASK 14
-#define V_FCOEMASK(x) ((x) << S_FCOEMASK)
-#define F_FCOEMASK V_FCOEMASK(1U)
-
-#define S_SRVRSRAM 13
-#define V_SRVRSRAM(x) ((x) << S_SRVRSRAM)
-#define F_SRVRSRAM V_SRVRSRAM(1U)
-
-#define A_TP_INGRESS_CONFIG 0x141
-
-#define S_OPAQUE_TYPE 16
-#define M_OPAQUE_TYPE 0xffffU
-#define V_OPAQUE_TYPE(x) ((x) << S_OPAQUE_TYPE)
-#define G_OPAQUE_TYPE(x) (((x) >> S_OPAQUE_TYPE) & M_OPAQUE_TYPE)
-
-#define S_OPAQUE_RM 15
-#define V_OPAQUE_RM(x) ((x) << S_OPAQUE_RM)
-#define F_OPAQUE_RM V_OPAQUE_RM(1U)
-
-#define S_OPAQUE_HDR_SIZE 14
-#define V_OPAQUE_HDR_SIZE(x) ((x) << S_OPAQUE_HDR_SIZE)
-#define F_OPAQUE_HDR_SIZE V_OPAQUE_HDR_SIZE(1U)
-
-#define S_OPAQUE_RM_MAC_IN_MAC 13
-#define V_OPAQUE_RM_MAC_IN_MAC(x) ((x) << S_OPAQUE_RM_MAC_IN_MAC)
-#define F_OPAQUE_RM_MAC_IN_MAC V_OPAQUE_RM_MAC_IN_MAC(1U)
-
-#define S_FCOE_TARGET 12
-#define V_FCOE_TARGET(x) ((x) << S_FCOE_TARGET)
-#define F_FCOE_TARGET V_FCOE_TARGET(1U)
-
-#define S_VNIC 11
-#define V_VNIC(x) ((x) << S_VNIC)
-#define F_VNIC V_VNIC(1U)
-
-#define S_CSUM_HAS_PSEUDO_HDR 10
-#define V_CSUM_HAS_PSEUDO_HDR(x) ((x) << S_CSUM_HAS_PSEUDO_HDR)
-#define F_CSUM_HAS_PSEUDO_HDR V_CSUM_HAS_PSEUDO_HDR(1U)
-
-#define S_RM_OVLAN 9
-#define V_RM_OVLAN(x) ((x) << S_RM_OVLAN)
-#define F_RM_OVLAN V_RM_OVLAN(1U)
-
-#define S_LOOKUPEVERYPKT 8
-#define V_LOOKUPEVERYPKT(x) ((x) << S_LOOKUPEVERYPKT)
-#define F_LOOKUPEVERYPKT V_LOOKUPEVERYPKT(1U)
-
-#define S_IPV6_EXT_HDR_SKIP 0
-#define M_IPV6_EXT_HDR_SKIP 0xffU
-#define V_IPV6_EXT_HDR_SKIP(x) ((x) << S_IPV6_EXT_HDR_SKIP)
-#define G_IPV6_EXT_HDR_SKIP(x) (((x) >> S_IPV6_EXT_HDR_SKIP) & M_IPV6_EXT_HDR_SKIP)
-
-#define S_FRAG_LEN_MOD8_COMPAT 12
-#define V_FRAG_LEN_MOD8_COMPAT(x) ((x) << S_FRAG_LEN_MOD8_COMPAT)
-#define F_FRAG_LEN_MOD8_COMPAT V_FRAG_LEN_MOD8_COMPAT(1U)
-
-#define S_USE_ENC_IDX 13
-#define V_USE_ENC_IDX(x) ((x) << S_USE_ENC_IDX)
-#define F_USE_ENC_IDX V_USE_ENC_IDX(1U)
-
-#define A_TP_TX_DROP_CFG_CH2 0x142
-#define A_TP_TX_DROP_CFG_CH3 0x143
-#define A_TP_EGRESS_CONFIG 0x145
-
-#define S_REWRITEFORCETOSIZE 0
-#define V_REWRITEFORCETOSIZE(x) ((x) << S_REWRITEFORCETOSIZE)
-#define F_REWRITEFORCETOSIZE V_REWRITEFORCETOSIZE(1U)
-
-#define A_TP_INGRESS_CONFIG2 0x145
-
-#define S_IPV6_UDP_CSUM_COMPAT 31
-#define V_IPV6_UDP_CSUM_COMPAT(x) ((x) << S_IPV6_UDP_CSUM_COMPAT)
-#define F_IPV6_UDP_CSUM_COMPAT V_IPV6_UDP_CSUM_COMPAT(1U)
-
-#define S_VNTAGPLDENABLE 30
-#define V_VNTAGPLDENABLE(x) ((x) << S_VNTAGPLDENABLE)
-#define F_VNTAGPLDENABLE V_VNTAGPLDENABLE(1U)
-
-#define S_TCP_PLD_FILTER_OFFSET 20
-#define M_TCP_PLD_FILTER_OFFSET 0x3ffU
-#define V_TCP_PLD_FILTER_OFFSET(x) ((x) << S_TCP_PLD_FILTER_OFFSET)
-#define G_TCP_PLD_FILTER_OFFSET(x) (((x) >> S_TCP_PLD_FILTER_OFFSET) & M_TCP_PLD_FILTER_OFFSET)
-
-#define S_UDP_PLD_FILTER_OFFSET 10
-#define M_UDP_PLD_FILTER_OFFSET 0x3ffU
-#define V_UDP_PLD_FILTER_OFFSET(x) ((x) << S_UDP_PLD_FILTER_OFFSET)
-#define G_UDP_PLD_FILTER_OFFSET(x) (((x) >> S_UDP_PLD_FILTER_OFFSET) & M_UDP_PLD_FILTER_OFFSET)
-
-#define S_TNL_PLD_FILTER_OFFSET 0
-#define M_TNL_PLD_FILTER_OFFSET 0x3ffU
-#define V_TNL_PLD_FILTER_OFFSET(x) ((x) << S_TNL_PLD_FILTER_OFFSET)
-#define G_TNL_PLD_FILTER_OFFSET(x) (((x) >> S_TNL_PLD_FILTER_OFFSET) & M_TNL_PLD_FILTER_OFFSET)
-
-#define A_TP_EHDR_CONFIG_LO 0x146
-
-#define S_CPLLIMIT 24
-#define M_CPLLIMIT 0xffU
-#define V_CPLLIMIT(x) ((x) << S_CPLLIMIT)
-#define G_CPLLIMIT(x) (((x) >> S_CPLLIMIT) & M_CPLLIMIT)
-
-#define S_ETHLIMIT 16
-#define M_ETHLIMIT 0xffU
-#define V_ETHLIMIT(x) ((x) << S_ETHLIMIT)
-#define G_ETHLIMIT(x) (((x) >> S_ETHLIMIT) & M_ETHLIMIT)
-
-#define S_IPLIMIT 8
-#define M_IPLIMIT 0xffU
-#define V_IPLIMIT(x) ((x) << S_IPLIMIT)
-#define G_IPLIMIT(x) (((x) >> S_IPLIMIT) & M_IPLIMIT)
-
-#define S_TCPLIMIT 0
-#define M_TCPLIMIT 0xffU
-#define V_TCPLIMIT(x) ((x) << S_TCPLIMIT)
-#define G_TCPLIMIT(x) (((x) >> S_TCPLIMIT) & M_TCPLIMIT)
-
-#define A_TP_EHDR_CONFIG_HI 0x147
-#define A_TP_DBG_ESIDE_INT 0x148
-
-#define S_ERXSOP2X 28
-#define M_ERXSOP2X 0xfU
-#define V_ERXSOP2X(x) ((x) << S_ERXSOP2X)
-#define G_ERXSOP2X(x) (((x) >> S_ERXSOP2X) & M_ERXSOP2X)
-
-#define S_ERXEOP2X 24
-#define M_ERXEOP2X 0xfU
-#define V_ERXEOP2X(x) ((x) << S_ERXEOP2X)
-#define G_ERXEOP2X(x) (((x) >> S_ERXEOP2X) & M_ERXEOP2X)
-
-#define S_ERXVALID2X 20
-#define M_ERXVALID2X 0xfU
-#define V_ERXVALID2X(x) ((x) << S_ERXVALID2X)
-#define G_ERXVALID2X(x) (((x) >> S_ERXVALID2X) & M_ERXVALID2X)
-
-#define S_ERXAFULL2X 16
-#define M_ERXAFULL2X 0xfU
-#define V_ERXAFULL2X(x) ((x) << S_ERXAFULL2X)
-#define G_ERXAFULL2X(x) (((x) >> S_ERXAFULL2X) & M_ERXAFULL2X)
-
-#define S_PLD2XTXVALID 12
-#define M_PLD2XTXVALID 0xfU
-#define V_PLD2XTXVALID(x) ((x) << S_PLD2XTXVALID)
-#define G_PLD2XTXVALID(x) (((x) >> S_PLD2XTXVALID) & M_PLD2XTXVALID)
-
-#define S_PLD2XTXAFULL 8
-#define M_PLD2XTXAFULL 0xfU
-#define V_PLD2XTXAFULL(x) ((x) << S_PLD2XTXAFULL)
-#define G_PLD2XTXAFULL(x) (((x) >> S_PLD2XTXAFULL) & M_PLD2XTXAFULL)
-
-#define S_ERRORSRDY 7
-#define V_ERRORSRDY(x) ((x) << S_ERRORSRDY)
-#define F_ERRORSRDY V_ERRORSRDY(1U)
-
-#define S_ERRORDRDY 6
-#define V_ERRORDRDY(x) ((x) << S_ERRORDRDY)
-#define F_ERRORDRDY V_ERRORDRDY(1U)
-
-#define S_TCPOPSRDY 5
-#define V_TCPOPSRDY(x) ((x) << S_TCPOPSRDY)
-#define F_TCPOPSRDY V_TCPOPSRDY(1U)
-
-#define S_TCPOPDRDY 4
-#define V_TCPOPDRDY(x) ((x) << S_TCPOPDRDY)
-#define F_TCPOPDRDY V_TCPOPDRDY(1U)
-
-#define S_PLDTXSRDY 3
-#define V_PLDTXSRDY(x) ((x) << S_PLDTXSRDY)
-#define F_PLDTXSRDY V_PLDTXSRDY(1U)
-
-#define S_PLDTXDRDY 2
-#define V_PLDTXDRDY(x) ((x) << S_PLDTXDRDY)
-#define F_PLDTXDRDY V_PLDTXDRDY(1U)
-
-#define S_TCPOPTTXVALID 1
-#define V_TCPOPTTXVALID(x) ((x) << S_TCPOPTTXVALID)
-#define F_TCPOPTTXVALID V_TCPOPTTXVALID(1U)
-
-#define S_TCPOPTTXFULL 0
-#define V_TCPOPTTXFULL(x) ((x) << S_TCPOPTTXFULL)
-#define F_TCPOPTTXFULL V_TCPOPTTXFULL(1U)
-
-#define S_PKTATTRSRDY 3
-#define V_PKTATTRSRDY(x) ((x) << S_PKTATTRSRDY)
-#define F_PKTATTRSRDY V_PKTATTRSRDY(1U)
-
-#define S_PKTATTRDRDY 2
-#define V_PKTATTRDRDY(x) ((x) << S_PKTATTRDRDY)
-#define F_PKTATTRDRDY V_PKTATTRDRDY(1U)
-
-#define A_TP_DBG_ESIDE_DEMUX 0x149
-
-#define S_EALLDONE 28
-#define M_EALLDONE 0xfU
-#define V_EALLDONE(x) ((x) << S_EALLDONE)
-#define G_EALLDONE(x) (((x) >> S_EALLDONE) & M_EALLDONE)
-
-#define S_EFIFOPLDDONE 24
-#define M_EFIFOPLDDONE 0xfU
-#define V_EFIFOPLDDONE(x) ((x) << S_EFIFOPLDDONE)
-#define G_EFIFOPLDDONE(x) (((x) >> S_EFIFOPLDDONE) & M_EFIFOPLDDONE)
-
-#define S_EDBDONE 20
-#define M_EDBDONE 0xfU
-#define V_EDBDONE(x) ((x) << S_EDBDONE)
-#define G_EDBDONE(x) (((x) >> S_EDBDONE) & M_EDBDONE)
-
-#define S_EISSFIFODONE 16
-#define M_EISSFIFODONE 0xfU
-#define V_EISSFIFODONE(x) ((x) << S_EISSFIFODONE)
-#define G_EISSFIFODONE(x) (((x) >> S_EISSFIFODONE) & M_EISSFIFODONE)
-
-#define S_EACKERRFIFODONE 12
-#define M_EACKERRFIFODONE 0xfU
-#define V_EACKERRFIFODONE(x) ((x) << S_EACKERRFIFODONE)
-#define G_EACKERRFIFODONE(x) (((x) >> S_EACKERRFIFODONE) & M_EACKERRFIFODONE)
-
-#define S_EFIFOERRORDONE 8
-#define M_EFIFOERRORDONE 0xfU
-#define V_EFIFOERRORDONE(x) ((x) << S_EFIFOERRORDONE)
-#define G_EFIFOERRORDONE(x) (((x) >> S_EFIFOERRORDONE) & M_EFIFOERRORDONE)
-
-#define S_ERXPKTATTRFIFOFDONE 4
-#define M_ERXPKTATTRFIFOFDONE 0xfU
-#define V_ERXPKTATTRFIFOFDONE(x) ((x) << S_ERXPKTATTRFIFOFDONE)
-#define G_ERXPKTATTRFIFOFDONE(x) (((x) >> S_ERXPKTATTRFIFOFDONE) & M_ERXPKTATTRFIFOFDONE)
-
-#define S_ETCPOPDONE 0
-#define M_ETCPOPDONE 0xfU
-#define V_ETCPOPDONE(x) ((x) << S_ETCPOPDONE)
-#define G_ETCPOPDONE(x) (((x) >> S_ETCPOPDONE) & M_ETCPOPDONE)
-
-#define A_TP_DBG_ESIDE_IN0 0x14a
-
-#define S_RXVALID 31
-#define V_RXVALID(x) ((x) << S_RXVALID)
-#define F_RXVALID V_RXVALID(1U)
-
-#define S_RXFULL 30
-#define V_RXFULL(x) ((x) << S_RXFULL)
-#define F_RXFULL V_RXFULL(1U)
-
-#define S_RXSOCP 29
-#define V_RXSOCP(x) ((x) << S_RXSOCP)
-#define F_RXSOCP V_RXSOCP(1U)
-
-#define S_RXEOP 28
-#define V_RXEOP(x) ((x) << S_RXEOP)
-#define F_RXEOP V_RXEOP(1U)
-
-#define S_RXVALID_I 27
-#define V_RXVALID_I(x) ((x) << S_RXVALID_I)
-#define F_RXVALID_I V_RXVALID_I(1U)
-
-#define S_RXFULL_I 26
-#define V_RXFULL_I(x) ((x) << S_RXFULL_I)
-#define F_RXFULL_I V_RXFULL_I(1U)
-
-#define S_RXSOCP_I 25
-#define V_RXSOCP_I(x) ((x) << S_RXSOCP_I)
-#define F_RXSOCP_I V_RXSOCP_I(1U)
-
-#define S_RXEOP_I 24
-#define V_RXEOP_I(x) ((x) << S_RXEOP_I)
-#define F_RXEOP_I V_RXEOP_I(1U)
-
-#define S_RXVALID_I2 23
-#define V_RXVALID_I2(x) ((x) << S_RXVALID_I2)
-#define F_RXVALID_I2 V_RXVALID_I2(1U)
-
-#define S_RXFULL_I2 22
-#define V_RXFULL_I2(x) ((x) << S_RXFULL_I2)
-#define F_RXFULL_I2 V_RXFULL_I2(1U)
-
-#define S_RXSOCP_I2 21
-#define V_RXSOCP_I2(x) ((x) << S_RXSOCP_I2)
-#define F_RXSOCP_I2 V_RXSOCP_I2(1U)
-
-#define S_RXEOP_I2 20
-#define V_RXEOP_I2(x) ((x) << S_RXEOP_I2)
-#define F_RXEOP_I2 V_RXEOP_I2(1U)
-
-#define S_CT_MPA_TXVALID_FIFO 19
-#define V_CT_MPA_TXVALID_FIFO(x) ((x) << S_CT_MPA_TXVALID_FIFO)
-#define F_CT_MPA_TXVALID_FIFO V_CT_MPA_TXVALID_FIFO(1U)
-
-#define S_CT_MPA_TXFULL_FIFO 18
-#define V_CT_MPA_TXFULL_FIFO(x) ((x) << S_CT_MPA_TXFULL_FIFO)
-#define F_CT_MPA_TXFULL_FIFO V_CT_MPA_TXFULL_FIFO(1U)
-
-#define S_CT_MPA_TXVALID 17
-#define V_CT_MPA_TXVALID(x) ((x) << S_CT_MPA_TXVALID)
-#define F_CT_MPA_TXVALID V_CT_MPA_TXVALID(1U)
-
-#define S_CT_MPA_TXFULL 16
-#define V_CT_MPA_TXFULL(x) ((x) << S_CT_MPA_TXFULL)
-#define F_CT_MPA_TXFULL V_CT_MPA_TXFULL(1U)
-
-#define S_RXVALID_BUF 15
-#define V_RXVALID_BUF(x) ((x) << S_RXVALID_BUF)
-#define F_RXVALID_BUF V_RXVALID_BUF(1U)
-
-#define S_RXFULL_BUF 14
-#define V_RXFULL_BUF(x) ((x) << S_RXFULL_BUF)
-#define F_RXFULL_BUF V_RXFULL_BUF(1U)
-
-#define S_PLD_TXVALID 13
-#define V_PLD_TXVALID(x) ((x) << S_PLD_TXVALID)
-#define F_PLD_TXVALID V_PLD_TXVALID(1U)
-
-#define S_PLD_TXFULL 12
-#define V_PLD_TXFULL(x) ((x) << S_PLD_TXFULL)
-#define F_PLD_TXFULL V_PLD_TXFULL(1U)
-
-#define S_ISS_FIFO_SRDY 11
-#define V_ISS_FIFO_SRDY(x) ((x) << S_ISS_FIFO_SRDY)
-#define F_ISS_FIFO_SRDY V_ISS_FIFO_SRDY(1U)
-
-#define S_ISS_FIFO_DRDY 10
-#define V_ISS_FIFO_DRDY(x) ((x) << S_ISS_FIFO_DRDY)
-#define F_ISS_FIFO_DRDY V_ISS_FIFO_DRDY(1U)
-
-#define S_CT_TCP_OP_ISS_SRDY 9
-#define V_CT_TCP_OP_ISS_SRDY(x) ((x) << S_CT_TCP_OP_ISS_SRDY)
-#define F_CT_TCP_OP_ISS_SRDY V_CT_TCP_OP_ISS_SRDY(1U)
-
-#define S_CT_TCP_OP_ISS_DRDY 8
-#define V_CT_TCP_OP_ISS_DRDY(x) ((x) << S_CT_TCP_OP_ISS_DRDY)
-#define F_CT_TCP_OP_ISS_DRDY V_CT_TCP_OP_ISS_DRDY(1U)
-
-#define S_P2CSUMERROR_SRDY 7
-#define V_P2CSUMERROR_SRDY(x) ((x) << S_P2CSUMERROR_SRDY)
-#define F_P2CSUMERROR_SRDY V_P2CSUMERROR_SRDY(1U)
-
-#define S_P2CSUMERROR_DRDY 6
-#define V_P2CSUMERROR_DRDY(x) ((x) << S_P2CSUMERROR_DRDY)
-#define F_P2CSUMERROR_DRDY V_P2CSUMERROR_DRDY(1U)
-
-#define S_FIFO_ERROR_SRDY 5
-#define V_FIFO_ERROR_SRDY(x) ((x) << S_FIFO_ERROR_SRDY)
-#define F_FIFO_ERROR_SRDY V_FIFO_ERROR_SRDY(1U)
-
-#define S_FIFO_ERROR_DRDY 4
-#define V_FIFO_ERROR_DRDY(x) ((x) << S_FIFO_ERROR_DRDY)
-#define F_FIFO_ERROR_DRDY V_FIFO_ERROR_DRDY(1U)
-
-#define S_PLD_SRDY 3
-#define V_PLD_SRDY(x) ((x) << S_PLD_SRDY)
-#define F_PLD_SRDY V_PLD_SRDY(1U)
-
-#define S_PLD_DRDY 2
-#define V_PLD_DRDY(x) ((x) << S_PLD_DRDY)
-#define F_PLD_DRDY V_PLD_DRDY(1U)
-
-#define S_RX_PKT_ATTR_SRDY 1
-#define V_RX_PKT_ATTR_SRDY(x) ((x) << S_RX_PKT_ATTR_SRDY)
-#define F_RX_PKT_ATTR_SRDY V_RX_PKT_ATTR_SRDY(1U)
-
-#define S_RX_PKT_ATTR_DRDY 0
-#define V_RX_PKT_ATTR_DRDY(x) ((x) << S_RX_PKT_ATTR_DRDY)
-#define F_RX_PKT_ATTR_DRDY V_RX_PKT_ATTR_DRDY(1U)
-
-#define S_RXRUNT 25
-#define V_RXRUNT(x) ((x) << S_RXRUNT)
-#define F_RXRUNT V_RXRUNT(1U)
-
-#define S_RXRUNTPARSER 24
-#define V_RXRUNTPARSER(x) ((x) << S_RXRUNTPARSER)
-#define F_RXRUNTPARSER V_RXRUNTPARSER(1U)
-
-#define S_ERROR_SRDY 5
-#define V_ERROR_SRDY(x) ((x) << S_ERROR_SRDY)
-#define F_ERROR_SRDY V_ERROR_SRDY(1U)
-
-#define S_ERROR_DRDY 4
-#define V_ERROR_DRDY(x) ((x) << S_ERROR_DRDY)
-#define F_ERROR_DRDY V_ERROR_DRDY(1U)
-
-#define A_TP_DBG_ESIDE_IN1 0x14b
-#define A_TP_DBG_ESIDE_IN2 0x14c
-#define A_TP_DBG_ESIDE_IN3 0x14d
-#define A_TP_DBG_ESIDE_FRM 0x14e
-
-#define S_ERX2XERROR 28
-#define M_ERX2XERROR 0xfU
-#define V_ERX2XERROR(x) ((x) << S_ERX2XERROR)
-#define G_ERX2XERROR(x) (((x) >> S_ERX2XERROR) & M_ERX2XERROR)
-
-#define S_EPLDTX2XERROR 24
-#define M_EPLDTX2XERROR 0xfU
-#define V_EPLDTX2XERROR(x) ((x) << S_EPLDTX2XERROR)
-#define G_EPLDTX2XERROR(x) (((x) >> S_EPLDTX2XERROR) & M_EPLDTX2XERROR)
-
-#define S_ETXERROR 20
-#define M_ETXERROR 0xfU
-#define V_ETXERROR(x) ((x) << S_ETXERROR)
-#define G_ETXERROR(x) (((x) >> S_ETXERROR) & M_ETXERROR)
-
-#define S_EPLDRXERROR 16
-#define M_EPLDRXERROR 0xfU
-#define V_EPLDRXERROR(x) ((x) << S_EPLDRXERROR)
-#define G_EPLDRXERROR(x) (((x) >> S_EPLDRXERROR) & M_EPLDRXERROR)
-
-#define S_ERXSIZEERROR3 12
-#define M_ERXSIZEERROR3 0xfU
-#define V_ERXSIZEERROR3(x) ((x) << S_ERXSIZEERROR3)
-#define G_ERXSIZEERROR3(x) (((x) >> S_ERXSIZEERROR3) & M_ERXSIZEERROR3)
-
-#define S_ERXSIZEERROR2 8
-#define M_ERXSIZEERROR2 0xfU
-#define V_ERXSIZEERROR2(x) ((x) << S_ERXSIZEERROR2)
-#define G_ERXSIZEERROR2(x) (((x) >> S_ERXSIZEERROR2) & M_ERXSIZEERROR2)
-
-#define S_ERXSIZEERROR1 4
-#define M_ERXSIZEERROR1 0xfU
-#define V_ERXSIZEERROR1(x) ((x) << S_ERXSIZEERROR1)
-#define G_ERXSIZEERROR1(x) (((x) >> S_ERXSIZEERROR1) & M_ERXSIZEERROR1)
-
-#define S_ERXSIZEERROR0 0
-#define M_ERXSIZEERROR0 0xfU
-#define V_ERXSIZEERROR0(x) ((x) << S_ERXSIZEERROR0)
-#define G_ERXSIZEERROR0(x) (((x) >> S_ERXSIZEERROR0) & M_ERXSIZEERROR0)
-
-#define A_TP_DBG_ESIDE_DRP 0x14f
-
-#define S_RXDROP3 24
-#define M_RXDROP3 0xffU
-#define V_RXDROP3(x) ((x) << S_RXDROP3)
-#define G_RXDROP3(x) (((x) >> S_RXDROP3) & M_RXDROP3)
-
-#define S_RXDROP2 16
-#define M_RXDROP2 0xffU
-#define V_RXDROP2(x) ((x) << S_RXDROP2)
-#define G_RXDROP2(x) (((x) >> S_RXDROP2) & M_RXDROP2)
-
-#define S_RXDROP1 8
-#define M_RXDROP1 0xffU
-#define V_RXDROP1(x) ((x) << S_RXDROP1)
-#define G_RXDROP1(x) (((x) >> S_RXDROP1) & M_RXDROP1)
-
-#define S_RXDROP0 0
-#define M_RXDROP0 0xffU
-#define V_RXDROP0(x) ((x) << S_RXDROP0)
-#define G_RXDROP0(x) (((x) >> S_RXDROP0) & M_RXDROP0)
-
-#define A_TP_DBG_ESIDE_TX 0x150
-
-#define S_ETXVALID 4
-#define M_ETXVALID 0xfU
-#define V_ETXVALID(x) ((x) << S_ETXVALID)
-#define G_ETXVALID(x) (((x) >> S_ETXVALID) & M_ETXVALID)
-
-#define S_ETXFULL 0
-#define M_ETXFULL 0xfU
-#define V_ETXFULL(x) ((x) << S_ETXFULL)
-#define G_ETXFULL(x) (((x) >> S_ETXFULL) & M_ETXFULL)
-
-#define S_TXERRORCNT 8
-#define M_TXERRORCNT 0xffffffU
-#define V_TXERRORCNT(x) ((x) << S_TXERRORCNT)
-#define G_TXERRORCNT(x) (((x) >> S_TXERRORCNT) & M_TXERRORCNT)
-
-#define A_TP_ESIDE_SVID_MASK 0x151
-#define A_TP_ESIDE_DVID_MASK 0x152
-#define A_TP_ESIDE_ALIGN_MASK 0x153
-
-#define S_USE_LOOP_BIT 24
-#define V_USE_LOOP_BIT(x) ((x) << S_USE_LOOP_BIT)
-#define F_USE_LOOP_BIT V_USE_LOOP_BIT(1U)
-
-#define S_LOOP_OFFSET 16
-#define M_LOOP_OFFSET 0xffU
-#define V_LOOP_OFFSET(x) ((x) << S_LOOP_OFFSET)
-#define G_LOOP_OFFSET(x) (((x) >> S_LOOP_OFFSET) & M_LOOP_OFFSET)
-
-#define S_DVID_ID_OFFSET 8
-#define M_DVID_ID_OFFSET 0xffU
-#define V_DVID_ID_OFFSET(x) ((x) << S_DVID_ID_OFFSET)
-#define G_DVID_ID_OFFSET(x) (((x) >> S_DVID_ID_OFFSET) & M_DVID_ID_OFFSET)
-
-#define S_SVID_ID_OFFSET 0
-#define M_SVID_ID_OFFSET 0xffU
-#define V_SVID_ID_OFFSET(x) ((x) << S_SVID_ID_OFFSET)
-#define G_SVID_ID_OFFSET(x) (((x) >> S_SVID_ID_OFFSET) & M_SVID_ID_OFFSET)
-
-#define A_TP_DBG_ESIDE_OP 0x154
-
-#define S_OPT_PARSER_FATAL_CHANNEL0 29
-#define V_OPT_PARSER_FATAL_CHANNEL0(x) ((x) << S_OPT_PARSER_FATAL_CHANNEL0)
-#define F_OPT_PARSER_FATAL_CHANNEL0 V_OPT_PARSER_FATAL_CHANNEL0(1U)
-
-#define S_OPT_PARSER_BUSY_CHANNEL0 28
-#define V_OPT_PARSER_BUSY_CHANNEL0(x) ((x) << S_OPT_PARSER_BUSY_CHANNEL0)
-#define F_OPT_PARSER_BUSY_CHANNEL0 V_OPT_PARSER_BUSY_CHANNEL0(1U)
-
-#define S_OPT_PARSER_ITCP_STATE_CHANNEL0 26
-#define M_OPT_PARSER_ITCP_STATE_CHANNEL0 0x3U
-#define V_OPT_PARSER_ITCP_STATE_CHANNEL0(x) ((x) << S_OPT_PARSER_ITCP_STATE_CHANNEL0)
-#define G_OPT_PARSER_ITCP_STATE_CHANNEL0(x) (((x) >> S_OPT_PARSER_ITCP_STATE_CHANNEL0) & M_OPT_PARSER_ITCP_STATE_CHANNEL0)
-
-#define S_OPT_PARSER_OTK_STATE_CHANNEL0 24
-#define M_OPT_PARSER_OTK_STATE_CHANNEL0 0x3U
-#define V_OPT_PARSER_OTK_STATE_CHANNEL0(x) ((x) << S_OPT_PARSER_OTK_STATE_CHANNEL0)
-#define G_OPT_PARSER_OTK_STATE_CHANNEL0(x) (((x) >> S_OPT_PARSER_OTK_STATE_CHANNEL0) & M_OPT_PARSER_OTK_STATE_CHANNEL0)
-
-#define S_OPT_PARSER_FATAL_CHANNEL1 21
-#define V_OPT_PARSER_FATAL_CHANNEL1(x) ((x) << S_OPT_PARSER_FATAL_CHANNEL1)
-#define F_OPT_PARSER_FATAL_CHANNEL1 V_OPT_PARSER_FATAL_CHANNEL1(1U)
-
-#define S_OPT_PARSER_BUSY_CHANNEL1 20
-#define V_OPT_PARSER_BUSY_CHANNEL1(x) ((x) << S_OPT_PARSER_BUSY_CHANNEL1)
-#define F_OPT_PARSER_BUSY_CHANNEL1 V_OPT_PARSER_BUSY_CHANNEL1(1U)
-
-#define S_OPT_PARSER_ITCP_STATE_CHANNEL1 18
-#define M_OPT_PARSER_ITCP_STATE_CHANNEL1 0x3U
-#define V_OPT_PARSER_ITCP_STATE_CHANNEL1(x) ((x) << S_OPT_PARSER_ITCP_STATE_CHANNEL1)
-#define G_OPT_PARSER_ITCP_STATE_CHANNEL1(x) (((x) >> S_OPT_PARSER_ITCP_STATE_CHANNEL1) & M_OPT_PARSER_ITCP_STATE_CHANNEL1)
-
-#define S_OPT_PARSER_OTK_STATE_CHANNEL1 16
-#define M_OPT_PARSER_OTK_STATE_CHANNEL1 0x3U
-#define V_OPT_PARSER_OTK_STATE_CHANNEL1(x) ((x) << S_OPT_PARSER_OTK_STATE_CHANNEL1)
-#define G_OPT_PARSER_OTK_STATE_CHANNEL1(x) (((x) >> S_OPT_PARSER_OTK_STATE_CHANNEL1) & M_OPT_PARSER_OTK_STATE_CHANNEL1)
-
-#define S_OPT_PARSER_FATAL_CHANNEL2 13
-#define V_OPT_PARSER_FATAL_CHANNEL2(x) ((x) << S_OPT_PARSER_FATAL_CHANNEL2)
-#define F_OPT_PARSER_FATAL_CHANNEL2 V_OPT_PARSER_FATAL_CHANNEL2(1U)
-
-#define S_OPT_PARSER_BUSY_CHANNEL2 12
-#define V_OPT_PARSER_BUSY_CHANNEL2(x) ((x) << S_OPT_PARSER_BUSY_CHANNEL2)
-#define F_OPT_PARSER_BUSY_CHANNEL2 V_OPT_PARSER_BUSY_CHANNEL2(1U)
-
-#define S_OPT_PARSER_ITCP_STATE_CHANNEL2 10
-#define M_OPT_PARSER_ITCP_STATE_CHANNEL2 0x3U
-#define V_OPT_PARSER_ITCP_STATE_CHANNEL2(x) ((x) << S_OPT_PARSER_ITCP_STATE_CHANNEL2)
-#define G_OPT_PARSER_ITCP_STATE_CHANNEL2(x) (((x) >> S_OPT_PARSER_ITCP_STATE_CHANNEL2) & M_OPT_PARSER_ITCP_STATE_CHANNEL2)
-
-#define S_OPT_PARSER_OTK_STATE_CHANNEL2 8
-#define M_OPT_PARSER_OTK_STATE_CHANNEL2 0x3U
-#define V_OPT_PARSER_OTK_STATE_CHANNEL2(x) ((x) << S_OPT_PARSER_OTK_STATE_CHANNEL2)
-#define G_OPT_PARSER_OTK_STATE_CHANNEL2(x) (((x) >> S_OPT_PARSER_OTK_STATE_CHANNEL2) & M_OPT_PARSER_OTK_STATE_CHANNEL2)
-
-#define S_OPT_PARSER_FATAL_CHANNEL3 5
-#define V_OPT_PARSER_FATAL_CHANNEL3(x) ((x) << S_OPT_PARSER_FATAL_CHANNEL3)
-#define F_OPT_PARSER_FATAL_CHANNEL3 V_OPT_PARSER_FATAL_CHANNEL3(1U)
-
-#define S_OPT_PARSER_BUSY_CHANNEL3 4
-#define V_OPT_PARSER_BUSY_CHANNEL3(x) ((x) << S_OPT_PARSER_BUSY_CHANNEL3)
-#define F_OPT_PARSER_BUSY_CHANNEL3 V_OPT_PARSER_BUSY_CHANNEL3(1U)
-
-#define S_OPT_PARSER_ITCP_STATE_CHANNEL3 2
-#define M_OPT_PARSER_ITCP_STATE_CHANNEL3 0x3U
-#define V_OPT_PARSER_ITCP_STATE_CHANNEL3(x) ((x) << S_OPT_PARSER_ITCP_STATE_CHANNEL3)
-#define G_OPT_PARSER_ITCP_STATE_CHANNEL3(x) (((x) >> S_OPT_PARSER_ITCP_STATE_CHANNEL3) & M_OPT_PARSER_ITCP_STATE_CHANNEL3)
-
-#define S_OPT_PARSER_OTK_STATE_CHANNEL3 0
-#define M_OPT_PARSER_OTK_STATE_CHANNEL3 0x3U
-#define V_OPT_PARSER_OTK_STATE_CHANNEL3(x) ((x) << S_OPT_PARSER_OTK_STATE_CHANNEL3)
-#define G_OPT_PARSER_OTK_STATE_CHANNEL3(x) (((x) >> S_OPT_PARSER_OTK_STATE_CHANNEL3) & M_OPT_PARSER_OTK_STATE_CHANNEL3)
-
-#define A_TP_DBG_ESIDE_OP_ALT 0x155
-
-#define S_OPT_PARSER_PSTATE_FATAL_CHANNEL0 29
-#define V_OPT_PARSER_PSTATE_FATAL_CHANNEL0(x) ((x) << S_OPT_PARSER_PSTATE_FATAL_CHANNEL0)
-#define F_OPT_PARSER_PSTATE_FATAL_CHANNEL0 V_OPT_PARSER_PSTATE_FATAL_CHANNEL0(1U)
-
-#define S_OPT_PARSER_PSTATE_ERRNO_CHANNEL0 24
-#define M_OPT_PARSER_PSTATE_ERRNO_CHANNEL0 0x1fU
-#define V_OPT_PARSER_PSTATE_ERRNO_CHANNEL0(x) ((x) << S_OPT_PARSER_PSTATE_ERRNO_CHANNEL0)
-#define G_OPT_PARSER_PSTATE_ERRNO_CHANNEL0(x) (((x) >> S_OPT_PARSER_PSTATE_ERRNO_CHANNEL0) & M_OPT_PARSER_PSTATE_ERRNO_CHANNEL0)
-
-#define S_OPT_PARSER_PSTATE_FATAL_CHANNEL1 21
-#define V_OPT_PARSER_PSTATE_FATAL_CHANNEL1(x) ((x) << S_OPT_PARSER_PSTATE_FATAL_CHANNEL1)
-#define F_OPT_PARSER_PSTATE_FATAL_CHANNEL1 V_OPT_PARSER_PSTATE_FATAL_CHANNEL1(1U)
-
-#define S_OPT_PARSER_PSTATE_ERRNO_CHANNEL1 16
-#define M_OPT_PARSER_PSTATE_ERRNO_CHANNEL1 0x1fU
-#define V_OPT_PARSER_PSTATE_ERRNO_CHANNEL1(x) ((x) << S_OPT_PARSER_PSTATE_ERRNO_CHANNEL1)
-#define G_OPT_PARSER_PSTATE_ERRNO_CHANNEL1(x) (((x) >> S_OPT_PARSER_PSTATE_ERRNO_CHANNEL1) & M_OPT_PARSER_PSTATE_ERRNO_CHANNEL1)
-
-#define S_OPT_PARSER_PSTATE_FATAL_CHANNEL2 13
-#define V_OPT_PARSER_PSTATE_FATAL_CHANNEL2(x) ((x) << S_OPT_PARSER_PSTATE_FATAL_CHANNEL2)
-#define F_OPT_PARSER_PSTATE_FATAL_CHANNEL2 V_OPT_PARSER_PSTATE_FATAL_CHANNEL2(1U)
-
-#define S_OPT_PARSER_PSTATE_ERRNO_CHANNEL2 8
-#define M_OPT_PARSER_PSTATE_ERRNO_CHANNEL2 0x1fU
-#define V_OPT_PARSER_PSTATE_ERRNO_CHANNEL2(x) ((x) << S_OPT_PARSER_PSTATE_ERRNO_CHANNEL2)
-#define G_OPT_PARSER_PSTATE_ERRNO_CHANNEL2(x) (((x) >> S_OPT_PARSER_PSTATE_ERRNO_CHANNEL2) & M_OPT_PARSER_PSTATE_ERRNO_CHANNEL2)
-
-#define S_OPT_PARSER_PSTATE_FATAL_CHANNEL3 5
-#define V_OPT_PARSER_PSTATE_FATAL_CHANNEL3(x) ((x) << S_OPT_PARSER_PSTATE_FATAL_CHANNEL3)
-#define F_OPT_PARSER_PSTATE_FATAL_CHANNEL3 V_OPT_PARSER_PSTATE_FATAL_CHANNEL3(1U)
-
-#define S_OPT_PARSER_PSTATE_ERRNO_CHANNEL3 0
-#define M_OPT_PARSER_PSTATE_ERRNO_CHANNEL3 0x1fU
-#define V_OPT_PARSER_PSTATE_ERRNO_CHANNEL3(x) ((x) << S_OPT_PARSER_PSTATE_ERRNO_CHANNEL3)
-#define G_OPT_PARSER_PSTATE_ERRNO_CHANNEL3(x) (((x) >> S_OPT_PARSER_PSTATE_ERRNO_CHANNEL3) & M_OPT_PARSER_PSTATE_ERRNO_CHANNEL3)
-
-#define A_TP_DBG_ESIDE_OP_BUSY 0x156
-
-#define S_OPT_PARSER_BUSY_VEC_CHANNEL3 24
-#define M_OPT_PARSER_BUSY_VEC_CHANNEL3 0xffU
-#define V_OPT_PARSER_BUSY_VEC_CHANNEL3(x) ((x) << S_OPT_PARSER_BUSY_VEC_CHANNEL3)
-#define G_OPT_PARSER_BUSY_VEC_CHANNEL3(x) (((x) >> S_OPT_PARSER_BUSY_VEC_CHANNEL3) & M_OPT_PARSER_BUSY_VEC_CHANNEL3)
-
-#define S_OPT_PARSER_BUSY_VEC_CHANNEL2 16
-#define M_OPT_PARSER_BUSY_VEC_CHANNEL2 0xffU
-#define V_OPT_PARSER_BUSY_VEC_CHANNEL2(x) ((x) << S_OPT_PARSER_BUSY_VEC_CHANNEL2)
-#define G_OPT_PARSER_BUSY_VEC_CHANNEL2(x) (((x) >> S_OPT_PARSER_BUSY_VEC_CHANNEL2) & M_OPT_PARSER_BUSY_VEC_CHANNEL2)
-
-#define S_OPT_PARSER_BUSY_VEC_CHANNEL1 8
-#define M_OPT_PARSER_BUSY_VEC_CHANNEL1 0xffU
-#define V_OPT_PARSER_BUSY_VEC_CHANNEL1(x) ((x) << S_OPT_PARSER_BUSY_VEC_CHANNEL1)
-#define G_OPT_PARSER_BUSY_VEC_CHANNEL1(x) (((x) >> S_OPT_PARSER_BUSY_VEC_CHANNEL1) & M_OPT_PARSER_BUSY_VEC_CHANNEL1)
-
-#define S_OPT_PARSER_BUSY_VEC_CHANNEL0 0
-#define M_OPT_PARSER_BUSY_VEC_CHANNEL0 0xffU
-#define V_OPT_PARSER_BUSY_VEC_CHANNEL0(x) ((x) << S_OPT_PARSER_BUSY_VEC_CHANNEL0)
-#define G_OPT_PARSER_BUSY_VEC_CHANNEL0(x) (((x) >> S_OPT_PARSER_BUSY_VEC_CHANNEL0) & M_OPT_PARSER_BUSY_VEC_CHANNEL0)
-
-#define A_TP_DBG_ESIDE_OP_COOKIE 0x157
-
-#define S_OPT_PARSER_COOKIE_CHANNEL3 24
-#define M_OPT_PARSER_COOKIE_CHANNEL3 0xffU
-#define V_OPT_PARSER_COOKIE_CHANNEL3(x) ((x) << S_OPT_PARSER_COOKIE_CHANNEL3)
-#define G_OPT_PARSER_COOKIE_CHANNEL3(x) (((x) >> S_OPT_PARSER_COOKIE_CHANNEL3) & M_OPT_PARSER_COOKIE_CHANNEL3)
-
-#define S_OPT_PARSER_COOKIE_CHANNEL2 16
-#define M_OPT_PARSER_COOKIE_CHANNEL2 0xffU
-#define V_OPT_PARSER_COOKIE_CHANNEL2(x) ((x) << S_OPT_PARSER_COOKIE_CHANNEL2)
-#define G_OPT_PARSER_COOKIE_CHANNEL2(x) (((x) >> S_OPT_PARSER_COOKIE_CHANNEL2) & M_OPT_PARSER_COOKIE_CHANNEL2)
-
-#define S_OPT_PARSER_COOKIE_CHANNEL1 8
-#define M_OPT_PARSER_COOKIE_CHANNEL1 0xffU
-#define V_OPT_PARSER_COOKIE_CHANNEL1(x) ((x) << S_OPT_PARSER_COOKIE_CHANNEL1)
-#define G_OPT_PARSER_COOKIE_CHANNEL1(x) (((x) >> S_OPT_PARSER_COOKIE_CHANNEL1) & M_OPT_PARSER_COOKIE_CHANNEL1)
-
-#define S_OPT_PARSER_COOKIE_CHANNEL0 0
-#define M_OPT_PARSER_COOKIE_CHANNEL0 0xffU
-#define V_OPT_PARSER_COOKIE_CHANNEL0(x) ((x) << S_OPT_PARSER_COOKIE_CHANNEL0)
-#define G_OPT_PARSER_COOKIE_CHANNEL0(x) (((x) >> S_OPT_PARSER_COOKIE_CHANNEL0) & M_OPT_PARSER_COOKIE_CHANNEL0)
-
-#define A_TP_DBG_ESIDE_DEMUX_WAIT0 0x158
-#define A_TP_DBG_ESIDE_DEMUX_WAIT1 0x159
-#define A_TP_DBG_ESIDE_DEMUX_CNT0 0x15a
-#define A_TP_DBG_ESIDE_DEMUX_CNT1 0x15b
-#define A_TP_ESIDE_CONFIG 0x160
-
-#define S_VNI_EN 26
-#define V_VNI_EN(x) ((x) << S_VNI_EN)
-#define F_VNI_EN V_VNI_EN(1U)
-
-#define S_ENC_RX_EN 25
-#define V_ENC_RX_EN(x) ((x) << S_ENC_RX_EN)
-#define F_ENC_RX_EN V_ENC_RX_EN(1U)
-
-#define S_TNL_LKP_INNER_SEL 24
-#define V_TNL_LKP_INNER_SEL(x) ((x) << S_TNL_LKP_INNER_SEL)
-#define F_TNL_LKP_INNER_SEL V_TNL_LKP_INNER_SEL(1U)
-
-#define S_ROCEV2UDPPORT 0
-#define M_ROCEV2UDPPORT 0xffffU
-#define V_ROCEV2UDPPORT(x) ((x) << S_ROCEV2UDPPORT)
-#define G_ROCEV2UDPPORT(x) (((x) >> S_ROCEV2UDPPORT) & M_ROCEV2UDPPORT)
-
-#define A_TP_DBG_CSIDE_RX0 0x230
-
-#define S_CRXSOPCNT 28
-#define M_CRXSOPCNT 0xfU
-#define V_CRXSOPCNT(x) ((x) << S_CRXSOPCNT)
-#define G_CRXSOPCNT(x) (((x) >> S_CRXSOPCNT) & M_CRXSOPCNT)
-
-#define S_CRXEOPCNT 24
-#define M_CRXEOPCNT 0xfU
-#define V_CRXEOPCNT(x) ((x) << S_CRXEOPCNT)
-#define G_CRXEOPCNT(x) (((x) >> S_CRXEOPCNT) & M_CRXEOPCNT)
-
-#define S_CRXPLDSOPCNT 20
-#define M_CRXPLDSOPCNT 0xfU
-#define V_CRXPLDSOPCNT(x) ((x) << S_CRXPLDSOPCNT)
-#define G_CRXPLDSOPCNT(x) (((x) >> S_CRXPLDSOPCNT) & M_CRXPLDSOPCNT)
-
-#define S_CRXPLDEOPCNT 16
-#define M_CRXPLDEOPCNT 0xfU
-#define V_CRXPLDEOPCNT(x) ((x) << S_CRXPLDEOPCNT)
-#define G_CRXPLDEOPCNT(x) (((x) >> S_CRXPLDEOPCNT) & M_CRXPLDEOPCNT)
-
-#define S_CRXARBSOPCNT 12
-#define M_CRXARBSOPCNT 0xfU
-#define V_CRXARBSOPCNT(x) ((x) << S_CRXARBSOPCNT)
-#define G_CRXARBSOPCNT(x) (((x) >> S_CRXARBSOPCNT) & M_CRXARBSOPCNT)
-
-#define S_CRXARBEOPCNT 8
-#define M_CRXARBEOPCNT 0xfU
-#define V_CRXARBEOPCNT(x) ((x) << S_CRXARBEOPCNT)
-#define G_CRXARBEOPCNT(x) (((x) >> S_CRXARBEOPCNT) & M_CRXARBEOPCNT)
-
-#define S_CRXCPLSOPCNT 4
-#define M_CRXCPLSOPCNT 0xfU
-#define V_CRXCPLSOPCNT(x) ((x) << S_CRXCPLSOPCNT)
-#define G_CRXCPLSOPCNT(x) (((x) >> S_CRXCPLSOPCNT) & M_CRXCPLSOPCNT)
-
-#define S_CRXCPLEOPCNT 0
-#define M_CRXCPLEOPCNT 0xfU
-#define V_CRXCPLEOPCNT(x) ((x) << S_CRXCPLEOPCNT)
-#define G_CRXCPLEOPCNT(x) (((x) >> S_CRXCPLEOPCNT) & M_CRXCPLEOPCNT)
-
-#define A_TP_DBG_CSIDE_RX1 0x231
-#define A_TP_DBG_CSIDE_RX2 0x232
-#define A_TP_DBG_CSIDE_RX3 0x233
-#define A_TP_DBG_CSIDE_TX0 0x234
-
-#define S_TXSOPCNT 28
-#define M_TXSOPCNT 0xfU
-#define V_TXSOPCNT(x) ((x) << S_TXSOPCNT)
-#define G_TXSOPCNT(x) (((x) >> S_TXSOPCNT) & M_TXSOPCNT)
-
-#define S_TXEOPCNT 24
-#define M_TXEOPCNT 0xfU
-#define V_TXEOPCNT(x) ((x) << S_TXEOPCNT)
-#define G_TXEOPCNT(x) (((x) >> S_TXEOPCNT) & M_TXEOPCNT)
-
-#define S_TXPLDSOPCNT 20
-#define M_TXPLDSOPCNT 0xfU
-#define V_TXPLDSOPCNT(x) ((x) << S_TXPLDSOPCNT)
-#define G_TXPLDSOPCNT(x) (((x) >> S_TXPLDSOPCNT) & M_TXPLDSOPCNT)
-
-#define S_TXPLDEOPCNT 16
-#define M_TXPLDEOPCNT 0xfU
-#define V_TXPLDEOPCNT(x) ((x) << S_TXPLDEOPCNT)
-#define G_TXPLDEOPCNT(x) (((x) >> S_TXPLDEOPCNT) & M_TXPLDEOPCNT)
-
-#define S_TXARBSOPCNT 12
-#define M_TXARBSOPCNT 0xfU
-#define V_TXARBSOPCNT(x) ((x) << S_TXARBSOPCNT)
-#define G_TXARBSOPCNT(x) (((x) >> S_TXARBSOPCNT) & M_TXARBSOPCNT)
-
-#define S_TXARBEOPCNT 8
-#define M_TXARBEOPCNT 0xfU
-#define V_TXARBEOPCNT(x) ((x) << S_TXARBEOPCNT)
-#define G_TXARBEOPCNT(x) (((x) >> S_TXARBEOPCNT) & M_TXARBEOPCNT)
-
-#define S_TXCPLSOPCNT 4
-#define M_TXCPLSOPCNT 0xfU
-#define V_TXCPLSOPCNT(x) ((x) << S_TXCPLSOPCNT)
-#define G_TXCPLSOPCNT(x) (((x) >> S_TXCPLSOPCNT) & M_TXCPLSOPCNT)
-
-#define S_TXCPLEOPCNT 0
-#define M_TXCPLEOPCNT 0xfU
-#define V_TXCPLEOPCNT(x) ((x) << S_TXCPLEOPCNT)
-#define G_TXCPLEOPCNT(x) (((x) >> S_TXCPLEOPCNT) & M_TXCPLEOPCNT)
-
-#define A_TP_DBG_CSIDE_TX1 0x235
-#define A_TP_DBG_CSIDE_TX2 0x236
-#define A_TP_DBG_CSIDE_TX3 0x237
-#define A_TP_DBG_CSIDE_FIFO0 0x238
-
-#define S_PLD_RXZEROP_SRDY1 31
-#define V_PLD_RXZEROP_SRDY1(x) ((x) << S_PLD_RXZEROP_SRDY1)
-#define F_PLD_RXZEROP_SRDY1 V_PLD_RXZEROP_SRDY1(1U)
-
-#define S_PLD_RXZEROP_DRDY1 30
-#define V_PLD_RXZEROP_DRDY1(x) ((x) << S_PLD_RXZEROP_DRDY1)
-#define F_PLD_RXZEROP_DRDY1 V_PLD_RXZEROP_DRDY1(1U)
-
-#define S_PLD_TXZEROP_SRDY1 29
-#define V_PLD_TXZEROP_SRDY1(x) ((x) << S_PLD_TXZEROP_SRDY1)
-#define F_PLD_TXZEROP_SRDY1 V_PLD_TXZEROP_SRDY1(1U)
-
-#define S_PLD_TXZEROP_DRDY1 28
-#define V_PLD_TXZEROP_DRDY1(x) ((x) << S_PLD_TXZEROP_DRDY1)
-#define F_PLD_TXZEROP_DRDY1 V_PLD_TXZEROP_DRDY1(1U)
-
-#define S_PLD_TX_SRDY1 27
-#define V_PLD_TX_SRDY1(x) ((x) << S_PLD_TX_SRDY1)
-#define F_PLD_TX_SRDY1 V_PLD_TX_SRDY1(1U)
-
-#define S_PLD_TX_DRDY1 26
-#define V_PLD_TX_DRDY1(x) ((x) << S_PLD_TX_DRDY1)
-#define F_PLD_TX_DRDY1 V_PLD_TX_DRDY1(1U)
-
-#define S_ERROR_SRDY1 25
-#define V_ERROR_SRDY1(x) ((x) << S_ERROR_SRDY1)
-#define F_ERROR_SRDY1 V_ERROR_SRDY1(1U)
-
-#define S_ERROR_DRDY1 24
-#define V_ERROR_DRDY1(x) ((x) << S_ERROR_DRDY1)
-#define F_ERROR_DRDY1 V_ERROR_DRDY1(1U)
-
-#define S_DB_VLD1 23
-#define V_DB_VLD1(x) ((x) << S_DB_VLD1)
-#define F_DB_VLD1 V_DB_VLD1(1U)
-
-#define S_DB_GT1 22
-#define V_DB_GT1(x) ((x) << S_DB_GT1)
-#define F_DB_GT1 V_DB_GT1(1U)
-
-#define S_TXVALID1 21
-#define V_TXVALID1(x) ((x) << S_TXVALID1)
-#define F_TXVALID1 V_TXVALID1(1U)
-
-#define S_TXFULL1 20
-#define V_TXFULL1(x) ((x) << S_TXFULL1)
-#define F_TXFULL1 V_TXFULL1(1U)
-
-#define S_PLD_TXVALID1 19
-#define V_PLD_TXVALID1(x) ((x) << S_PLD_TXVALID1)
-#define F_PLD_TXVALID1 V_PLD_TXVALID1(1U)
-
-#define S_PLD_TXFULL1 18
-#define V_PLD_TXFULL1(x) ((x) << S_PLD_TXFULL1)
-#define F_PLD_TXFULL1 V_PLD_TXFULL1(1U)
-
-#define S_CPL5_TXVALID1 17
-#define V_CPL5_TXVALID1(x) ((x) << S_CPL5_TXVALID1)
-#define F_CPL5_TXVALID1 V_CPL5_TXVALID1(1U)
-
-#define S_CPL5_TXFULL1 16
-#define V_CPL5_TXFULL1(x) ((x) << S_CPL5_TXFULL1)
-#define F_CPL5_TXFULL1 V_CPL5_TXFULL1(1U)
-
-#define S_PLD_RXZEROP_SRDY0 15
-#define V_PLD_RXZEROP_SRDY0(x) ((x) << S_PLD_RXZEROP_SRDY0)
-#define F_PLD_RXZEROP_SRDY0 V_PLD_RXZEROP_SRDY0(1U)
-
-#define S_PLD_RXZEROP_DRDY0 14
-#define V_PLD_RXZEROP_DRDY0(x) ((x) << S_PLD_RXZEROP_DRDY0)
-#define F_PLD_RXZEROP_DRDY0 V_PLD_RXZEROP_DRDY0(1U)
-
-#define S_PLD_TXZEROP_SRDY0 13
-#define V_PLD_TXZEROP_SRDY0(x) ((x) << S_PLD_TXZEROP_SRDY0)
-#define F_PLD_TXZEROP_SRDY0 V_PLD_TXZEROP_SRDY0(1U)
-
-#define S_PLD_TXZEROP_DRDY0 12
-#define V_PLD_TXZEROP_DRDY0(x) ((x) << S_PLD_TXZEROP_DRDY0)
-#define F_PLD_TXZEROP_DRDY0 V_PLD_TXZEROP_DRDY0(1U)
-
-#define S_PLD_TX_SRDY0 11
-#define V_PLD_TX_SRDY0(x) ((x) << S_PLD_TX_SRDY0)
-#define F_PLD_TX_SRDY0 V_PLD_TX_SRDY0(1U)
-
-#define S_PLD_TX_DRDY0 10
-#define V_PLD_TX_DRDY0(x) ((x) << S_PLD_TX_DRDY0)
-#define F_PLD_TX_DRDY0 V_PLD_TX_DRDY0(1U)
-
-#define S_ERROR_SRDY0 9
-#define V_ERROR_SRDY0(x) ((x) << S_ERROR_SRDY0)
-#define F_ERROR_SRDY0 V_ERROR_SRDY0(1U)
-
-#define S_ERROR_DRDY0 8
-#define V_ERROR_DRDY0(x) ((x) << S_ERROR_DRDY0)
-#define F_ERROR_DRDY0 V_ERROR_DRDY0(1U)
-
-#define S_DB_VLD0 7
-#define V_DB_VLD0(x) ((x) << S_DB_VLD0)
-#define F_DB_VLD0 V_DB_VLD0(1U)
-
-#define S_DB_GT0 6
-#define V_DB_GT0(x) ((x) << S_DB_GT0)
-#define F_DB_GT0 V_DB_GT0(1U)
-
-#define S_TXVALID0 5
-#define V_TXVALID0(x) ((x) << S_TXVALID0)
-#define F_TXVALID0 V_TXVALID0(1U)
-
-#define S_TXFULL0 4
-#define V_TXFULL0(x) ((x) << S_TXFULL0)
-#define F_TXFULL0 V_TXFULL0(1U)
-
-#define S_PLD_TXVALID0 3
-#define V_PLD_TXVALID0(x) ((x) << S_PLD_TXVALID0)
-#define F_PLD_TXVALID0 V_PLD_TXVALID0(1U)
-
-#define S_PLD_TXFULL0 2
-#define V_PLD_TXFULL0(x) ((x) << S_PLD_TXFULL0)
-#define F_PLD_TXFULL0 V_PLD_TXFULL0(1U)
-
-#define S_CPL5_TXVALID0 1
-#define V_CPL5_TXVALID0(x) ((x) << S_CPL5_TXVALID0)
-#define F_CPL5_TXVALID0 V_CPL5_TXVALID0(1U)
-
-#define S_CPL5_TXFULL0 0
-#define V_CPL5_TXFULL0(x) ((x) << S_CPL5_TXFULL0)
-#define F_CPL5_TXFULL0 V_CPL5_TXFULL0(1U)
-
-#define A_TP_DBG_CSIDE_FIFO1 0x239
-
-#define S_PLD_RXZEROP_SRDY3 31
-#define V_PLD_RXZEROP_SRDY3(x) ((x) << S_PLD_RXZEROP_SRDY3)
-#define F_PLD_RXZEROP_SRDY3 V_PLD_RXZEROP_SRDY3(1U)
-
-#define S_PLD_RXZEROP_DRDY3 30
-#define V_PLD_RXZEROP_DRDY3(x) ((x) << S_PLD_RXZEROP_DRDY3)
-#define F_PLD_RXZEROP_DRDY3 V_PLD_RXZEROP_DRDY3(1U)
-
-#define S_PLD_TXZEROP_SRDY3 29
-#define V_PLD_TXZEROP_SRDY3(x) ((x) << S_PLD_TXZEROP_SRDY3)
-#define F_PLD_TXZEROP_SRDY3 V_PLD_TXZEROP_SRDY3(1U)
-
-#define S_PLD_TXZEROP_DRDY3 28
-#define V_PLD_TXZEROP_DRDY3(x) ((x) << S_PLD_TXZEROP_DRDY3)
-#define F_PLD_TXZEROP_DRDY3 V_PLD_TXZEROP_DRDY3(1U)
-
-#define S_PLD_TX_SRDY3 27
-#define V_PLD_TX_SRDY3(x) ((x) << S_PLD_TX_SRDY3)
-#define F_PLD_TX_SRDY3 V_PLD_TX_SRDY3(1U)
-
-#define S_PLD_TX_DRDY3 26
-#define V_PLD_TX_DRDY3(x) ((x) << S_PLD_TX_DRDY3)
-#define F_PLD_TX_DRDY3 V_PLD_TX_DRDY3(1U)
-
-#define S_ERROR_SRDY3 25
-#define V_ERROR_SRDY3(x) ((x) << S_ERROR_SRDY3)
-#define F_ERROR_SRDY3 V_ERROR_SRDY3(1U)
-
-#define S_ERROR_DRDY3 24
-#define V_ERROR_DRDY3(x) ((x) << S_ERROR_DRDY3)
-#define F_ERROR_DRDY3 V_ERROR_DRDY3(1U)
-
-#define S_DB_VLD3 23
-#define V_DB_VLD3(x) ((x) << S_DB_VLD3)
-#define F_DB_VLD3 V_DB_VLD3(1U)
-
-#define S_DB_GT3 22
-#define V_DB_GT3(x) ((x) << S_DB_GT3)
-#define F_DB_GT3 V_DB_GT3(1U)
-
-#define S_TXVALID3 21
-#define V_TXVALID3(x) ((x) << S_TXVALID3)
-#define F_TXVALID3 V_TXVALID3(1U)
-
-#define S_TXFULL3 20
-#define V_TXFULL3(x) ((x) << S_TXFULL3)
-#define F_TXFULL3 V_TXFULL3(1U)
-
-#define S_PLD_TXVALID3 19
-#define V_PLD_TXVALID3(x) ((x) << S_PLD_TXVALID3)
-#define F_PLD_TXVALID3 V_PLD_TXVALID3(1U)
-
-#define S_PLD_TXFULL3 18
-#define V_PLD_TXFULL3(x) ((x) << S_PLD_TXFULL3)
-#define F_PLD_TXFULL3 V_PLD_TXFULL3(1U)
-
-#define S_CPL5_TXVALID3 17
-#define V_CPL5_TXVALID3(x) ((x) << S_CPL5_TXVALID3)
-#define F_CPL5_TXVALID3 V_CPL5_TXVALID3(1U)
-
-#define S_CPL5_TXFULL3 16
-#define V_CPL5_TXFULL3(x) ((x) << S_CPL5_TXFULL3)
-#define F_CPL5_TXFULL3 V_CPL5_TXFULL3(1U)
-
-#define S_PLD_RXZEROP_SRDY2 15
-#define V_PLD_RXZEROP_SRDY2(x) ((x) << S_PLD_RXZEROP_SRDY2)
-#define F_PLD_RXZEROP_SRDY2 V_PLD_RXZEROP_SRDY2(1U)
-
-#define S_PLD_RXZEROP_DRDY2 14
-#define V_PLD_RXZEROP_DRDY2(x) ((x) << S_PLD_RXZEROP_DRDY2)
-#define F_PLD_RXZEROP_DRDY2 V_PLD_RXZEROP_DRDY2(1U)
-
-#define S_PLD_TXZEROP_SRDY2 13
-#define V_PLD_TXZEROP_SRDY2(x) ((x) << S_PLD_TXZEROP_SRDY2)
-#define F_PLD_TXZEROP_SRDY2 V_PLD_TXZEROP_SRDY2(1U)
-
-#define S_PLD_TXZEROP_DRDY2 12
-#define V_PLD_TXZEROP_DRDY2(x) ((x) << S_PLD_TXZEROP_DRDY2)
-#define F_PLD_TXZEROP_DRDY2 V_PLD_TXZEROP_DRDY2(1U)
-
-#define S_PLD_TX_SRDY2 11
-#define V_PLD_TX_SRDY2(x) ((x) << S_PLD_TX_SRDY2)
-#define F_PLD_TX_SRDY2 V_PLD_TX_SRDY2(1U)
-
-#define S_PLD_TX_DRDY2 10
-#define V_PLD_TX_DRDY2(x) ((x) << S_PLD_TX_DRDY2)
-#define F_PLD_TX_DRDY2 V_PLD_TX_DRDY2(1U)
-
-#define S_ERROR_SRDY2 9
-#define V_ERROR_SRDY2(x) ((x) << S_ERROR_SRDY2)
-#define F_ERROR_SRDY2 V_ERROR_SRDY2(1U)
-
-#define S_ERROR_DRDY2 8
-#define V_ERROR_DRDY2(x) ((x) << S_ERROR_DRDY2)
-#define F_ERROR_DRDY2 V_ERROR_DRDY2(1U)
-
-#define S_DB_VLD2 7
-#define V_DB_VLD2(x) ((x) << S_DB_VLD2)
-#define F_DB_VLD2 V_DB_VLD2(1U)
-
-#define S_DB_GT2 6
-#define V_DB_GT2(x) ((x) << S_DB_GT2)
-#define F_DB_GT2 V_DB_GT2(1U)
-
-#define S_TXVALID2 5
-#define V_TXVALID2(x) ((x) << S_TXVALID2)
-#define F_TXVALID2 V_TXVALID2(1U)
-
-#define S_TXFULL2 4
-#define V_TXFULL2(x) ((x) << S_TXFULL2)
-#define F_TXFULL2 V_TXFULL2(1U)
-
-#define S_PLD_TXVALID2 3
-#define V_PLD_TXVALID2(x) ((x) << S_PLD_TXVALID2)
-#define F_PLD_TXVALID2 V_PLD_TXVALID2(1U)
-
-#define S_PLD_TXFULL2 2
-#define V_PLD_TXFULL2(x) ((x) << S_PLD_TXFULL2)
-#define F_PLD_TXFULL2 V_PLD_TXFULL2(1U)
-
-#define S_CPL5_TXVALID2 1
-#define V_CPL5_TXVALID2(x) ((x) << S_CPL5_TXVALID2)
-#define F_CPL5_TXVALID2 V_CPL5_TXVALID2(1U)
-
-#define S_CPL5_TXFULL2 0
-#define V_CPL5_TXFULL2(x) ((x) << S_CPL5_TXFULL2)
-#define F_CPL5_TXFULL2 V_CPL5_TXFULL2(1U)
-
-#define A_TP_DBG_CSIDE_DISP0 0x23a
-
-#define S_CPL5RXVALID 27
-#define V_CPL5RXVALID(x) ((x) << S_CPL5RXVALID)
-#define F_CPL5RXVALID V_CPL5RXVALID(1U)
-
-#define S_CSTATIC1 26
-#define V_CSTATIC1(x) ((x) << S_CSTATIC1)
-#define F_CSTATIC1 V_CSTATIC1(1U)
-
-#define S_CSTATIC2 25
-#define V_CSTATIC2(x) ((x) << S_CSTATIC2)
-#define F_CSTATIC2 V_CSTATIC2(1U)
-
-#define S_PLD_RXZEROP 24
-#define V_PLD_RXZEROP(x) ((x) << S_PLD_RXZEROP)
-#define F_PLD_RXZEROP V_PLD_RXZEROP(1U)
-
-#define S_DDP_IN_PROGRESS 23
-#define V_DDP_IN_PROGRESS(x) ((x) << S_DDP_IN_PROGRESS)
-#define F_DDP_IN_PROGRESS V_DDP_IN_PROGRESS(1U)
-
-#define S_PLD_RXZEROP_SRDY 22
-#define V_PLD_RXZEROP_SRDY(x) ((x) << S_PLD_RXZEROP_SRDY)
-#define F_PLD_RXZEROP_SRDY V_PLD_RXZEROP_SRDY(1U)
-
-#define S_CSTATIC3 21
-#define V_CSTATIC3(x) ((x) << S_CSTATIC3)
-#define F_CSTATIC3 V_CSTATIC3(1U)
-
-#define S_DDP_DRDY 20
-#define V_DDP_DRDY(x) ((x) << S_DDP_DRDY)
-#define F_DDP_DRDY V_DDP_DRDY(1U)
-
-#define S_DDP_PRE_STATE 17
-#define M_DDP_PRE_STATE 0x7U
-#define V_DDP_PRE_STATE(x) ((x) << S_DDP_PRE_STATE)
-#define G_DDP_PRE_STATE(x) (((x) >> S_DDP_PRE_STATE) & M_DDP_PRE_STATE)
-
-#define S_DDP_SRDY 16
-#define V_DDP_SRDY(x) ((x) << S_DDP_SRDY)
-#define F_DDP_SRDY V_DDP_SRDY(1U)
-
-#define S_DDP_MSG_CODE 12
-#define M_DDP_MSG_CODE 0xfU
-#define V_DDP_MSG_CODE(x) ((x) << S_DDP_MSG_CODE)
-#define G_DDP_MSG_CODE(x) (((x) >> S_DDP_MSG_CODE) & M_DDP_MSG_CODE)
-
-#define S_CPL5_SOCP_CNT 10
-#define M_CPL5_SOCP_CNT 0x3U
-#define V_CPL5_SOCP_CNT(x) ((x) << S_CPL5_SOCP_CNT)
-#define G_CPL5_SOCP_CNT(x) (((x) >> S_CPL5_SOCP_CNT) & M_CPL5_SOCP_CNT)
-
-#define S_CSTATIC4 4
-#define M_CSTATIC4 0x3fU
-#define V_CSTATIC4(x) ((x) << S_CSTATIC4)
-#define G_CSTATIC4(x) (((x) >> S_CSTATIC4) & M_CSTATIC4)
-
-#define S_CMD_SEL 1
-#define V_CMD_SEL(x) ((x) << S_CMD_SEL)
-#define F_CMD_SEL V_CMD_SEL(1U)
-
-#define S_T5_TXFULL 31
-#define V_T5_TXFULL(x) ((x) << S_T5_TXFULL)
-#define F_T5_TXFULL V_T5_TXFULL(1U)
-
-#define S_CPL5RXFULL 26
-#define V_CPL5RXFULL(x) ((x) << S_CPL5RXFULL)
-#define F_CPL5RXFULL V_CPL5RXFULL(1U)
-
-#define S_T5_PLD_RXZEROP_SRDY 25
-#define V_T5_PLD_RXZEROP_SRDY(x) ((x) << S_T5_PLD_RXZEROP_SRDY)
-#define F_T5_PLD_RXZEROP_SRDY V_T5_PLD_RXZEROP_SRDY(1U)
-
-#define S_PLD2XRXVALID 23
-#define V_PLD2XRXVALID(x) ((x) << S_PLD2XRXVALID)
-#define F_PLD2XRXVALID V_PLD2XRXVALID(1U)
-
-#define S_T5_DDP_SRDY 22
-#define V_T5_DDP_SRDY(x) ((x) << S_T5_DDP_SRDY)
-#define F_T5_DDP_SRDY V_T5_DDP_SRDY(1U)
-
-#define S_T5_DDP_DRDY 21
-#define V_T5_DDP_DRDY(x) ((x) << S_T5_DDP_DRDY)
-#define F_T5_DDP_DRDY V_T5_DDP_DRDY(1U)
-
-#define S_DDPSTATE 16
-#define M_DDPSTATE 0x1fU
-#define V_DDPSTATE(x) ((x) << S_DDPSTATE)
-#define G_DDPSTATE(x) (((x) >> S_DDPSTATE) & M_DDPSTATE)
-
-#define S_DDPMSGCODE 12
-#define M_DDPMSGCODE 0xfU
-#define V_DDPMSGCODE(x) ((x) << S_DDPMSGCODE)
-#define G_DDPMSGCODE(x) (((x) >> S_DDPMSGCODE) & M_DDPMSGCODE)
-
-#define S_CPL5SOCPCNT 8
-#define M_CPL5SOCPCNT 0xfU
-#define V_CPL5SOCPCNT(x) ((x) << S_CPL5SOCPCNT)
-#define G_CPL5SOCPCNT(x) (((x) >> S_CPL5SOCPCNT) & M_CPL5SOCPCNT)
-
-#define S_PLDRXZEROPCNT 4
-#define M_PLDRXZEROPCNT 0xfU
-#define V_PLDRXZEROPCNT(x) ((x) << S_PLDRXZEROPCNT)
-#define G_PLDRXZEROPCNT(x) (((x) >> S_PLDRXZEROPCNT) & M_PLDRXZEROPCNT)
-
-#define S_TXFRMERR2 3
-#define V_TXFRMERR2(x) ((x) << S_TXFRMERR2)
-#define F_TXFRMERR2 V_TXFRMERR2(1U)
-
-#define S_TXFRMERR1 2
-#define V_TXFRMERR1(x) ((x) << S_TXFRMERR1)
-#define F_TXFRMERR1 V_TXFRMERR1(1U)
-
-#define S_TXVALID2X 1
-#define V_TXVALID2X(x) ((x) << S_TXVALID2X)
-#define F_TXVALID2X V_TXVALID2X(1U)
-
-#define S_TXFULL2X 0
-#define V_TXFULL2X(x) ((x) << S_TXFULL2X)
-#define F_TXFULL2X V_TXFULL2X(1U)
-
-#define S_T6_TXFULL 31
-#define V_T6_TXFULL(x) ((x) << S_T6_TXFULL)
-#define F_T6_TXFULL V_T6_TXFULL(1U)
-
-#define S_T6_PLD_RXZEROP_SRDY 25
-#define V_T6_PLD_RXZEROP_SRDY(x) ((x) << S_T6_PLD_RXZEROP_SRDY)
-#define F_T6_PLD_RXZEROP_SRDY V_T6_PLD_RXZEROP_SRDY(1U)
-
-#define S_T6_DDP_SRDY 22
-#define V_T6_DDP_SRDY(x) ((x) << S_T6_DDP_SRDY)
-#define F_T6_DDP_SRDY V_T6_DDP_SRDY(1U)
-
-#define S_T6_DDP_DRDY 21
-#define V_T6_DDP_DRDY(x) ((x) << S_T6_DDP_DRDY)
-#define F_T6_DDP_DRDY V_T6_DDP_DRDY(1U)
-
-#define A_TP_DBG_CSIDE_DISP1 0x23b
-
-#define S_T5_TXFULL 31
-#define V_T5_TXFULL(x) ((x) << S_T5_TXFULL)
-#define F_T5_TXFULL V_T5_TXFULL(1U)
-
-#define S_T5_PLD_RXZEROP_SRDY 25
-#define V_T5_PLD_RXZEROP_SRDY(x) ((x) << S_T5_PLD_RXZEROP_SRDY)
-#define F_T5_PLD_RXZEROP_SRDY V_T5_PLD_RXZEROP_SRDY(1U)
-
-#define S_T5_DDP_SRDY 22
-#define V_T5_DDP_SRDY(x) ((x) << S_T5_DDP_SRDY)
-#define F_T5_DDP_SRDY V_T5_DDP_SRDY(1U)
-
-#define S_T5_DDP_DRDY 21
-#define V_T5_DDP_DRDY(x) ((x) << S_T5_DDP_DRDY)
-#define F_T5_DDP_DRDY V_T5_DDP_DRDY(1U)
-
-#define S_T6_TXFULL 31
-#define V_T6_TXFULL(x) ((x) << S_T6_TXFULL)
-#define F_T6_TXFULL V_T6_TXFULL(1U)
-
-#define S_T6_PLD_RXZEROP_SRDY 25
-#define V_T6_PLD_RXZEROP_SRDY(x) ((x) << S_T6_PLD_RXZEROP_SRDY)
-#define F_T6_PLD_RXZEROP_SRDY V_T6_PLD_RXZEROP_SRDY(1U)
-
-#define S_T6_DDP_SRDY 22
-#define V_T6_DDP_SRDY(x) ((x) << S_T6_DDP_SRDY)
-#define F_T6_DDP_SRDY V_T6_DDP_SRDY(1U)
-
-#define S_T6_DDP_DRDY 21
-#define V_T6_DDP_DRDY(x) ((x) << S_T6_DDP_DRDY)
-#define F_T6_DDP_DRDY V_T6_DDP_DRDY(1U)
-
-#define A_TP_DBG_CSIDE_DDP0 0x23c
-
-#define S_DDPMSGLATEST7 28
-#define M_DDPMSGLATEST7 0xfU
-#define V_DDPMSGLATEST7(x) ((x) << S_DDPMSGLATEST7)
-#define G_DDPMSGLATEST7(x) (((x) >> S_DDPMSGLATEST7) & M_DDPMSGLATEST7)
-
-#define S_DDPMSGLATEST6 24
-#define M_DDPMSGLATEST6 0xfU
-#define V_DDPMSGLATEST6(x) ((x) << S_DDPMSGLATEST6)
-#define G_DDPMSGLATEST6(x) (((x) >> S_DDPMSGLATEST6) & M_DDPMSGLATEST6)
-
-#define S_DDPMSGLATEST5 20
-#define M_DDPMSGLATEST5 0xfU
-#define V_DDPMSGLATEST5(x) ((x) << S_DDPMSGLATEST5)
-#define G_DDPMSGLATEST5(x) (((x) >> S_DDPMSGLATEST5) & M_DDPMSGLATEST5)
-
-#define S_DDPMSGLATEST4 16
-#define M_DDPMSGLATEST4 0xfU
-#define V_DDPMSGLATEST4(x) ((x) << S_DDPMSGLATEST4)
-#define G_DDPMSGLATEST4(x) (((x) >> S_DDPMSGLATEST4) & M_DDPMSGLATEST4)
-
-#define S_DDPMSGLATEST3 12
-#define M_DDPMSGLATEST3 0xfU
-#define V_DDPMSGLATEST3(x) ((x) << S_DDPMSGLATEST3)
-#define G_DDPMSGLATEST3(x) (((x) >> S_DDPMSGLATEST3) & M_DDPMSGLATEST3)
-
-#define S_DDPMSGLATEST2 8
-#define M_DDPMSGLATEST2 0xfU
-#define V_DDPMSGLATEST2(x) ((x) << S_DDPMSGLATEST2)
-#define G_DDPMSGLATEST2(x) (((x) >> S_DDPMSGLATEST2) & M_DDPMSGLATEST2)
-
-#define S_DDPMSGLATEST1 4
-#define M_DDPMSGLATEST1 0xfU
-#define V_DDPMSGLATEST1(x) ((x) << S_DDPMSGLATEST1)
-#define G_DDPMSGLATEST1(x) (((x) >> S_DDPMSGLATEST1) & M_DDPMSGLATEST1)
-
-#define S_DDPMSGLATEST0 0
-#define M_DDPMSGLATEST0 0xfU
-#define V_DDPMSGLATEST0(x) ((x) << S_DDPMSGLATEST0)
-#define G_DDPMSGLATEST0(x) (((x) >> S_DDPMSGLATEST0) & M_DDPMSGLATEST0)
-
-#define A_TP_DBG_CSIDE_DDP1 0x23d
-#define A_TP_DBG_CSIDE_FRM 0x23e
-
-#define S_CRX2XERROR 28
-#define M_CRX2XERROR 0xfU
-#define V_CRX2XERROR(x) ((x) << S_CRX2XERROR)
-#define G_CRX2XERROR(x) (((x) >> S_CRX2XERROR) & M_CRX2XERROR)
-
-#define S_CPLDTX2XERROR 24
-#define M_CPLDTX2XERROR 0xfU
-#define V_CPLDTX2XERROR(x) ((x) << S_CPLDTX2XERROR)
-#define G_CPLDTX2XERROR(x) (((x) >> S_CPLDTX2XERROR) & M_CPLDTX2XERROR)
-
-#define S_CTXERROR 22
-#define M_CTXERROR 0x3U
-#define V_CTXERROR(x) ((x) << S_CTXERROR)
-#define G_CTXERROR(x) (((x) >> S_CTXERROR) & M_CTXERROR)
-
-#define S_CPLDRXERROR 20
-#define M_CPLDRXERROR 0x3U
-#define V_CPLDRXERROR(x) ((x) << S_CPLDRXERROR)
-#define G_CPLDRXERROR(x) (((x) >> S_CPLDRXERROR) & M_CPLDRXERROR)
-
-#define S_CPLRXERROR 18
-#define M_CPLRXERROR 0x3U
-#define V_CPLRXERROR(x) ((x) << S_CPLRXERROR)
-#define G_CPLRXERROR(x) (((x) >> S_CPLRXERROR) & M_CPLRXERROR)
-
-#define S_CPLTXERROR 16
-#define M_CPLTXERROR 0x3U
-#define V_CPLTXERROR(x) ((x) << S_CPLTXERROR)
-#define G_CPLTXERROR(x) (((x) >> S_CPLTXERROR) & M_CPLTXERROR)
-
-#define S_CPRSERROR 0
-#define M_CPRSERROR 0xfU
-#define V_CPRSERROR(x) ((x) << S_CPRSERROR)
-#define G_CPRSERROR(x) (((x) >> S_CPRSERROR) & M_CPRSERROR)
-
-#define A_TP_DBG_CSIDE_INT 0x23f
-
-#define S_CRXVALID2X 28
-#define M_CRXVALID2X 0xfU
-#define V_CRXVALID2X(x) ((x) << S_CRXVALID2X)
-#define G_CRXVALID2X(x) (((x) >> S_CRXVALID2X) & M_CRXVALID2X)
-
-#define S_CRXAFULL2X 24
-#define M_CRXAFULL2X 0xfU
-#define V_CRXAFULL2X(x) ((x) << S_CRXAFULL2X)
-#define G_CRXAFULL2X(x) (((x) >> S_CRXAFULL2X) & M_CRXAFULL2X)
-
-#define S_CTXVALID2X 22
-#define M_CTXVALID2X 0x3U
-#define V_CTXVALID2X(x) ((x) << S_CTXVALID2X)
-#define G_CTXVALID2X(x) (((x) >> S_CTXVALID2X) & M_CTXVALID2X)
-
-#define S_CTXAFULL2X 20
-#define M_CTXAFULL2X 0x3U
-#define V_CTXAFULL2X(x) ((x) << S_CTXAFULL2X)
-#define G_CTXAFULL2X(x) (((x) >> S_CTXAFULL2X) & M_CTXAFULL2X)
-
-#define S_PLD2X_RXVALID 18
-#define M_PLD2X_RXVALID 0x3U
-#define V_PLD2X_RXVALID(x) ((x) << S_PLD2X_RXVALID)
-#define G_PLD2X_RXVALID(x) (((x) >> S_PLD2X_RXVALID) & M_PLD2X_RXVALID)
-
-#define S_PLD2X_RXAFULL 16
-#define M_PLD2X_RXAFULL 0x3U
-#define V_PLD2X_RXAFULL(x) ((x) << S_PLD2X_RXAFULL)
-#define G_PLD2X_RXAFULL(x) (((x) >> S_PLD2X_RXAFULL) & M_PLD2X_RXAFULL)
-
-#define S_CSIDE_DDP_VALID 14
-#define M_CSIDE_DDP_VALID 0x3U
-#define V_CSIDE_DDP_VALID(x) ((x) << S_CSIDE_DDP_VALID)
-#define G_CSIDE_DDP_VALID(x) (((x) >> S_CSIDE_DDP_VALID) & M_CSIDE_DDP_VALID)
-
-#define S_DDP_AFULL 12
-#define M_DDP_AFULL 0x3U
-#define V_DDP_AFULL(x) ((x) << S_DDP_AFULL)
-#define G_DDP_AFULL(x) (((x) >> S_DDP_AFULL) & M_DDP_AFULL)
-
-#define S_TRC_RXVALID 11
-#define V_TRC_RXVALID(x) ((x) << S_TRC_RXVALID)
-#define F_TRC_RXVALID V_TRC_RXVALID(1U)
-
-#define S_TRC_RXFULL 10
-#define V_TRC_RXFULL(x) ((x) << S_TRC_RXFULL)
-#define F_TRC_RXFULL V_TRC_RXFULL(1U)
-
-#define S_CPL5_TXVALID 9
-#define V_CPL5_TXVALID(x) ((x) << S_CPL5_TXVALID)
-#define F_CPL5_TXVALID V_CPL5_TXVALID(1U)
-
-#define S_CPL5_TXFULL 8
-#define V_CPL5_TXFULL(x) ((x) << S_CPL5_TXFULL)
-#define F_CPL5_TXFULL V_CPL5_TXFULL(1U)
-
-#define S_PLD2X_TXVALID 4
-#define M_PLD2X_TXVALID 0xfU
-#define V_PLD2X_TXVALID(x) ((x) << S_PLD2X_TXVALID)
-#define G_PLD2X_TXVALID(x) (((x) >> S_PLD2X_TXVALID) & M_PLD2X_TXVALID)
-
-#define S_PLD2X_TXAFULL 0
-#define M_PLD2X_TXAFULL 0xfU
-#define V_PLD2X_TXAFULL(x) ((x) << S_PLD2X_TXAFULL)
-#define G_PLD2X_TXAFULL(x) (((x) >> S_PLD2X_TXAFULL) & M_PLD2X_TXAFULL)
-
-#define A_TP_CHDR_CONFIG 0x240
-
-#define S_CH1HIGH 24
-#define M_CH1HIGH 0xffU
-#define V_CH1HIGH(x) ((x) << S_CH1HIGH)
-#define G_CH1HIGH(x) (((x) >> S_CH1HIGH) & M_CH1HIGH)
-
-#define S_CH1LOW 16
-#define M_CH1LOW 0xffU
-#define V_CH1LOW(x) ((x) << S_CH1LOW)
-#define G_CH1LOW(x) (((x) >> S_CH1LOW) & M_CH1LOW)
-
-#define S_CH0HIGH 8
-#define M_CH0HIGH 0xffU
-#define V_CH0HIGH(x) ((x) << S_CH0HIGH)
-#define G_CH0HIGH(x) (((x) >> S_CH0HIGH) & M_CH0HIGH)
-
-#define S_CH0LOW 0
-#define M_CH0LOW 0xffU
-#define V_CH0LOW(x) ((x) << S_CH0LOW)
-#define G_CH0LOW(x) (((x) >> S_CH0LOW) & M_CH0LOW)
-
-#define A_TP_UTRN_CONFIG 0x241
-
-#define S_CH2FIFOLIMIT 16
-#define M_CH2FIFOLIMIT 0xffU
-#define V_CH2FIFOLIMIT(x) ((x) << S_CH2FIFOLIMIT)
-#define G_CH2FIFOLIMIT(x) (((x) >> S_CH2FIFOLIMIT) & M_CH2FIFOLIMIT)
-
-#define S_CH1FIFOLIMIT 8
-#define M_CH1FIFOLIMIT 0xffU
-#define V_CH1FIFOLIMIT(x) ((x) << S_CH1FIFOLIMIT)
-#define G_CH1FIFOLIMIT(x) (((x) >> S_CH1FIFOLIMIT) & M_CH1FIFOLIMIT)
-
-#define S_CH0FIFOLIMIT 0
-#define M_CH0FIFOLIMIT 0xffU
-#define V_CH0FIFOLIMIT(x) ((x) << S_CH0FIFOLIMIT)
-#define G_CH0FIFOLIMIT(x) (((x) >> S_CH0FIFOLIMIT) & M_CH0FIFOLIMIT)
-
-#define A_TP_CDSP_CONFIG 0x242
-
-#define S_WRITEZEROEN 4
-#define V_WRITEZEROEN(x) ((x) << S_WRITEZEROEN)
-#define F_WRITEZEROEN V_WRITEZEROEN(1U)
-
-#define S_WRITEZEROOP 0
-#define M_WRITEZEROOP 0xfU
-#define V_WRITEZEROOP(x) ((x) << S_WRITEZEROOP)
-#define G_WRITEZEROOP(x) (((x) >> S_WRITEZEROOP) & M_WRITEZEROOP)
-
-#define S_STARTSKIPPLD 7
-#define V_STARTSKIPPLD(x) ((x) << S_STARTSKIPPLD)
-#define F_STARTSKIPPLD V_STARTSKIPPLD(1U)
-
-#define S_ATOMICCMDEN 5
-#define V_ATOMICCMDEN(x) ((x) << S_ATOMICCMDEN)
-#define F_ATOMICCMDEN V_ATOMICCMDEN(1U)
-
-#define S_ISCSICMDMODE 28
-#define V_ISCSICMDMODE(x) ((x) << S_ISCSICMDMODE)
-#define F_ISCSICMDMODE V_ISCSICMDMODE(1U)
-
-#define A_TP_CSPI_POWER 0x243
-
-#define S_GATECHNTX3 11
-#define V_GATECHNTX3(x) ((x) << S_GATECHNTX3)
-#define F_GATECHNTX3 V_GATECHNTX3(1U)
-
-#define S_GATECHNTX2 10
-#define V_GATECHNTX2(x) ((x) << S_GATECHNTX2)
-#define F_GATECHNTX2 V_GATECHNTX2(1U)
-
-#define S_GATECHNTX1 9
-#define V_GATECHNTX1(x) ((x) << S_GATECHNTX1)
-#define F_GATECHNTX1 V_GATECHNTX1(1U)
-
-#define S_GATECHNTX0 8
-#define V_GATECHNTX0(x) ((x) << S_GATECHNTX0)
-#define F_GATECHNTX0 V_GATECHNTX0(1U)
-
-#define S_GATECHNRX1 7
-#define V_GATECHNRX1(x) ((x) << S_GATECHNRX1)
-#define F_GATECHNRX1 V_GATECHNRX1(1U)
-
-#define S_GATECHNRX0 6
-#define V_GATECHNRX0(x) ((x) << S_GATECHNRX0)
-#define F_GATECHNRX0 V_GATECHNRX0(1U)
-
-#define S_SLEEPRDYUTRN 4
-#define V_SLEEPRDYUTRN(x) ((x) << S_SLEEPRDYUTRN)
-#define F_SLEEPRDYUTRN V_SLEEPRDYUTRN(1U)
-
-#define S_SLEEPREQUTRN 0
-#define V_SLEEPREQUTRN(x) ((x) << S_SLEEPREQUTRN)
-#define F_SLEEPREQUTRN V_SLEEPREQUTRN(1U)
-
-#define A_TP_TRC_CONFIG 0x244
-
-#define S_TRCRR 1
-#define V_TRCRR(x) ((x) << S_TRCRR)
-#define F_TRCRR V_TRCRR(1U)
-
-#define S_TRCCH 0
-#define V_TRCCH(x) ((x) << S_TRCCH)
-#define F_TRCCH V_TRCCH(1U)
-
-#define A_TP_TAG_CONFIG 0x245
-
-#define S_ETAGTYPE 16
-#define M_ETAGTYPE 0xffffU
-#define V_ETAGTYPE(x) ((x) << S_ETAGTYPE)
-#define G_ETAGTYPE(x) (((x) >> S_ETAGTYPE) & M_ETAGTYPE)
-
-#define A_TP_DBG_CSIDE_PRS 0x246
-
-#define S_CPRSSTATE3 24
-#define M_CPRSSTATE3 0x7U
-#define V_CPRSSTATE3(x) ((x) << S_CPRSSTATE3)
-#define G_CPRSSTATE3(x) (((x) >> S_CPRSSTATE3) & M_CPRSSTATE3)
-
-#define S_CPRSSTATE2 16
-#define M_CPRSSTATE2 0x7U
-#define V_CPRSSTATE2(x) ((x) << S_CPRSSTATE2)
-#define G_CPRSSTATE2(x) (((x) >> S_CPRSSTATE2) & M_CPRSSTATE2)
-
-#define S_CPRSSTATE1 8
-#define M_CPRSSTATE1 0x7U
-#define V_CPRSSTATE1(x) ((x) << S_CPRSSTATE1)
-#define G_CPRSSTATE1(x) (((x) >> S_CPRSSTATE1) & M_CPRSSTATE1)
-
-#define S_CPRSSTATE0 0
-#define M_CPRSSTATE0 0x7U
-#define V_CPRSSTATE0(x) ((x) << S_CPRSSTATE0)
-#define G_CPRSSTATE0(x) (((x) >> S_CPRSSTATE0) & M_CPRSSTATE0)
-
-#define S_C4TUPBUSY3 31
-#define V_C4TUPBUSY3(x) ((x) << S_C4TUPBUSY3)
-#define F_C4TUPBUSY3 V_C4TUPBUSY3(1U)
-
-#define S_CDBVALID3 30
-#define V_CDBVALID3(x) ((x) << S_CDBVALID3)
-#define F_CDBVALID3 V_CDBVALID3(1U)
-
-#define S_CRXVALID3 29
-#define V_CRXVALID3(x) ((x) << S_CRXVALID3)
-#define F_CRXVALID3 V_CRXVALID3(1U)
-
-#define S_CRXFULL3 28
-#define V_CRXFULL3(x) ((x) << S_CRXFULL3)
-#define F_CRXFULL3 V_CRXFULL3(1U)
-
-#define S_T5_CPRSSTATE3 24
-#define M_T5_CPRSSTATE3 0xfU
-#define V_T5_CPRSSTATE3(x) ((x) << S_T5_CPRSSTATE3)
-#define G_T5_CPRSSTATE3(x) (((x) >> S_T5_CPRSSTATE3) & M_T5_CPRSSTATE3)
-
-#define S_C4TUPBUSY2 23
-#define V_C4TUPBUSY2(x) ((x) << S_C4TUPBUSY2)
-#define F_C4TUPBUSY2 V_C4TUPBUSY2(1U)
-
-#define S_CDBVALID2 22
-#define V_CDBVALID2(x) ((x) << S_CDBVALID2)
-#define F_CDBVALID2 V_CDBVALID2(1U)
-
-#define S_CRXVALID2 21
-#define V_CRXVALID2(x) ((x) << S_CRXVALID2)
-#define F_CRXVALID2 V_CRXVALID2(1U)
-
-#define S_CRXFULL2 20
-#define V_CRXFULL2(x) ((x) << S_CRXFULL2)
-#define F_CRXFULL2 V_CRXFULL2(1U)
-
-#define S_T5_CPRSSTATE2 16
-#define M_T5_CPRSSTATE2 0xfU
-#define V_T5_CPRSSTATE2(x) ((x) << S_T5_CPRSSTATE2)
-#define G_T5_CPRSSTATE2(x) (((x) >> S_T5_CPRSSTATE2) & M_T5_CPRSSTATE2)
-
-#define S_C4TUPBUSY1 15
-#define V_C4TUPBUSY1(x) ((x) << S_C4TUPBUSY1)
-#define F_C4TUPBUSY1 V_C4TUPBUSY1(1U)
-
-#define S_CDBVALID1 14
-#define V_CDBVALID1(x) ((x) << S_CDBVALID1)
-#define F_CDBVALID1 V_CDBVALID1(1U)
-
-#define S_CRXVALID1 13
-#define V_CRXVALID1(x) ((x) << S_CRXVALID1)
-#define F_CRXVALID1 V_CRXVALID1(1U)
-
-#define S_CRXFULL1 12
-#define V_CRXFULL1(x) ((x) << S_CRXFULL1)
-#define F_CRXFULL1 V_CRXFULL1(1U)
-
-#define S_T5_CPRSSTATE1 8
-#define M_T5_CPRSSTATE1 0xfU
-#define V_T5_CPRSSTATE1(x) ((x) << S_T5_CPRSSTATE1)
-#define G_T5_CPRSSTATE1(x) (((x) >> S_T5_CPRSSTATE1) & M_T5_CPRSSTATE1)
-
-#define S_C4TUPBUSY0 7
-#define V_C4TUPBUSY0(x) ((x) << S_C4TUPBUSY0)
-#define F_C4TUPBUSY0 V_C4TUPBUSY0(1U)
-
-#define S_CDBVALID0 6
-#define V_CDBVALID0(x) ((x) << S_CDBVALID0)
-#define F_CDBVALID0 V_CDBVALID0(1U)
-
-#define S_CRXVALID0 5
-#define V_CRXVALID0(x) ((x) << S_CRXVALID0)
-#define F_CRXVALID0 V_CRXVALID0(1U)
-
-#define S_CRXFULL0 4
-#define V_CRXFULL0(x) ((x) << S_CRXFULL0)
-#define F_CRXFULL0 V_CRXFULL0(1U)
-
-#define S_T5_CPRSSTATE0 0
-#define M_T5_CPRSSTATE0 0xfU
-#define V_T5_CPRSSTATE0(x) ((x) << S_T5_CPRSSTATE0)
-#define G_T5_CPRSSTATE0(x) (((x) >> S_T5_CPRSSTATE0) & M_T5_CPRSSTATE0)
-
-#define S_T6_CPRSSTATE3 24
-#define M_T6_CPRSSTATE3 0xfU
-#define V_T6_CPRSSTATE3(x) ((x) << S_T6_CPRSSTATE3)
-#define G_T6_CPRSSTATE3(x) (((x) >> S_T6_CPRSSTATE3) & M_T6_CPRSSTATE3)
-
-#define S_T6_CPRSSTATE2 16
-#define M_T6_CPRSSTATE2 0xfU
-#define V_T6_CPRSSTATE2(x) ((x) << S_T6_CPRSSTATE2)
-#define G_T6_CPRSSTATE2(x) (((x) >> S_T6_CPRSSTATE2) & M_T6_CPRSSTATE2)
-
-#define S_T6_CPRSSTATE1 8
-#define M_T6_CPRSSTATE1 0xfU
-#define V_T6_CPRSSTATE1(x) ((x) << S_T6_CPRSSTATE1)
-#define G_T6_CPRSSTATE1(x) (((x) >> S_T6_CPRSSTATE1) & M_T6_CPRSSTATE1)
-
-#define S_T6_CPRSSTATE0 0
-#define M_T6_CPRSSTATE0 0xfU
-#define V_T6_CPRSSTATE0(x) ((x) << S_T6_CPRSSTATE0)
-#define G_T6_CPRSSTATE0(x) (((x) >> S_T6_CPRSSTATE0) & M_T6_CPRSSTATE0)
-
-#define A_TP_DBG_CSIDE_DEMUX 0x247
-
-#define S_CALLDONE 28
-#define M_CALLDONE 0xfU
-#define V_CALLDONE(x) ((x) << S_CALLDONE)
-#define G_CALLDONE(x) (((x) >> S_CALLDONE) & M_CALLDONE)
-
-#define S_CTCPL5DONE 24
-#define M_CTCPL5DONE 0xfU
-#define V_CTCPL5DONE(x) ((x) << S_CTCPL5DONE)
-#define G_CTCPL5DONE(x) (((x) >> S_CTCPL5DONE) & M_CTCPL5DONE)
-
-#define S_CTXZEROPDONE 20
-#define M_CTXZEROPDONE 0xfU
-#define V_CTXZEROPDONE(x) ((x) << S_CTXZEROPDONE)
-#define G_CTXZEROPDONE(x) (((x) >> S_CTXZEROPDONE) & M_CTXZEROPDONE)
-
-#define S_CPLDDONE 16
-#define M_CPLDDONE 0xfU
-#define V_CPLDDONE(x) ((x) << S_CPLDDONE)
-#define G_CPLDDONE(x) (((x) >> S_CPLDDONE) & M_CPLDDONE)
-
-#define S_CTTCPOPDONE 12
-#define M_CTTCPOPDONE 0xfU
-#define V_CTTCPOPDONE(x) ((x) << S_CTTCPOPDONE)
-#define G_CTTCPOPDONE(x) (((x) >> S_CTTCPOPDONE) & M_CTTCPOPDONE)
-
-#define S_CDBDONE 8
-#define M_CDBDONE 0xfU
-#define V_CDBDONE(x) ((x) << S_CDBDONE)
-#define G_CDBDONE(x) (((x) >> S_CDBDONE) & M_CDBDONE)
-
-#define S_CISSFIFODONE 4
-#define M_CISSFIFODONE 0xfU
-#define V_CISSFIFODONE(x) ((x) << S_CISSFIFODONE)
-#define G_CISSFIFODONE(x) (((x) >> S_CISSFIFODONE) & M_CISSFIFODONE)
-
-#define S_CTXPKTCSUMDONE 0
-#define M_CTXPKTCSUMDONE 0xfU
-#define V_CTXPKTCSUMDONE(x) ((x) << S_CTXPKTCSUMDONE)
-#define G_CTXPKTCSUMDONE(x) (((x) >> S_CTXPKTCSUMDONE) & M_CTXPKTCSUMDONE)
-
-#define S_CARBVALID 28
-#define M_CARBVALID 0xfU
-#define V_CARBVALID(x) ((x) << S_CARBVALID)
-#define G_CARBVALID(x) (((x) >> S_CARBVALID) & M_CARBVALID)
-
-#define S_CCPL5DONE 24
-#define M_CCPL5DONE 0xfU
-#define V_CCPL5DONE(x) ((x) << S_CCPL5DONE)
-#define G_CCPL5DONE(x) (((x) >> S_CCPL5DONE) & M_CCPL5DONE)
-
-#define S_CTCPOPDONE 12
-#define M_CTCPOPDONE 0xfU
-#define V_CTCPOPDONE(x) ((x) << S_CTCPOPDONE)
-#define G_CTCPOPDONE(x) (((x) >> S_CTCPOPDONE) & M_CTCPOPDONE)
-
-#define A_TP_DBG_CSIDE_ARBIT 0x248
-
-#define S_CPLVALID3 31
-#define V_CPLVALID3(x) ((x) << S_CPLVALID3)
-#define F_CPLVALID3 V_CPLVALID3(1U)
-
-#define S_PLDVALID3 30
-#define V_PLDVALID3(x) ((x) << S_PLDVALID3)
-#define F_PLDVALID3 V_PLDVALID3(1U)
-
-#define S_CRCVALID3 29
-#define V_CRCVALID3(x) ((x) << S_CRCVALID3)
-#define F_CRCVALID3 V_CRCVALID3(1U)
-
-#define S_ISSVALID3 28
-#define V_ISSVALID3(x) ((x) << S_ISSVALID3)
-#define F_ISSVALID3 V_ISSVALID3(1U)
-
-#define S_DBVALID3 27
-#define V_DBVALID3(x) ((x) << S_DBVALID3)
-#define F_DBVALID3 V_DBVALID3(1U)
-
-#define S_CHKVALID3 26
-#define V_CHKVALID3(x) ((x) << S_CHKVALID3)
-#define F_CHKVALID3 V_CHKVALID3(1U)
-
-#define S_ZRPVALID3 25
-#define V_ZRPVALID3(x) ((x) << S_ZRPVALID3)
-#define F_ZRPVALID3 V_ZRPVALID3(1U)
-
-#define S_ERRVALID3 24
-#define V_ERRVALID3(x) ((x) << S_ERRVALID3)
-#define F_ERRVALID3 V_ERRVALID3(1U)
-
-#define S_CPLVALID2 23
-#define V_CPLVALID2(x) ((x) << S_CPLVALID2)
-#define F_CPLVALID2 V_CPLVALID2(1U)
-
-#define S_PLDVALID2 22
-#define V_PLDVALID2(x) ((x) << S_PLDVALID2)
-#define F_PLDVALID2 V_PLDVALID2(1U)
-
-#define S_CRCVALID2 21
-#define V_CRCVALID2(x) ((x) << S_CRCVALID2)
-#define F_CRCVALID2 V_CRCVALID2(1U)
-
-#define S_ISSVALID2 20
-#define V_ISSVALID2(x) ((x) << S_ISSVALID2)
-#define F_ISSVALID2 V_ISSVALID2(1U)
-
-#define S_DBVALID2 19
-#define V_DBVALID2(x) ((x) << S_DBVALID2)
-#define F_DBVALID2 V_DBVALID2(1U)
-
-#define S_CHKVALID2 18
-#define V_CHKVALID2(x) ((x) << S_CHKVALID2)
-#define F_CHKVALID2 V_CHKVALID2(1U)
-
-#define S_ZRPVALID2 17
-#define V_ZRPVALID2(x) ((x) << S_ZRPVALID2)
-#define F_ZRPVALID2 V_ZRPVALID2(1U)
-
-#define S_ERRVALID2 16
-#define V_ERRVALID2(x) ((x) << S_ERRVALID2)
-#define F_ERRVALID2 V_ERRVALID2(1U)
-
-#define S_CPLVALID1 15
-#define V_CPLVALID1(x) ((x) << S_CPLVALID1)
-#define F_CPLVALID1 V_CPLVALID1(1U)
-
-#define S_PLDVALID1 14
-#define V_PLDVALID1(x) ((x) << S_PLDVALID1)
-#define F_PLDVALID1 V_PLDVALID1(1U)
-
-#define S_CRCVALID1 13
-#define V_CRCVALID1(x) ((x) << S_CRCVALID1)
-#define F_CRCVALID1 V_CRCVALID1(1U)
-
-#define S_ISSVALID1 12
-#define V_ISSVALID1(x) ((x) << S_ISSVALID1)
-#define F_ISSVALID1 V_ISSVALID1(1U)
-
-#define S_DBVALID1 11
-#define V_DBVALID1(x) ((x) << S_DBVALID1)
-#define F_DBVALID1 V_DBVALID1(1U)
-
-#define S_CHKVALID1 10
-#define V_CHKVALID1(x) ((x) << S_CHKVALID1)
-#define F_CHKVALID1 V_CHKVALID1(1U)
-
-#define S_ZRPVALID1 9
-#define V_ZRPVALID1(x) ((x) << S_ZRPVALID1)
-#define F_ZRPVALID1 V_ZRPVALID1(1U)
-
-#define S_ERRVALID1 8
-#define V_ERRVALID1(x) ((x) << S_ERRVALID1)
-#define F_ERRVALID1 V_ERRVALID1(1U)
-
-#define S_CPLVALID0 7
-#define V_CPLVALID0(x) ((x) << S_CPLVALID0)
-#define F_CPLVALID0 V_CPLVALID0(1U)
-
-#define S_PLDVALID0 6
-#define V_PLDVALID0(x) ((x) << S_PLDVALID0)
-#define F_PLDVALID0 V_PLDVALID0(1U)
-
-#define S_CRCVALID0 5
-#define V_CRCVALID0(x) ((x) << S_CRCVALID0)
-#define F_CRCVALID0 V_CRCVALID0(1U)
-
-#define S_ISSVALID0 4
-#define V_ISSVALID0(x) ((x) << S_ISSVALID0)
-#define F_ISSVALID0 V_ISSVALID0(1U)
-
-#define S_DBVALID0 3
-#define V_DBVALID0(x) ((x) << S_DBVALID0)
-#define F_DBVALID0 V_DBVALID0(1U)
-
-#define S_CHKVALID0 2
-#define V_CHKVALID0(x) ((x) << S_CHKVALID0)
-#define F_CHKVALID0 V_CHKVALID0(1U)
-
-#define S_ZRPVALID0 1
-#define V_ZRPVALID0(x) ((x) << S_ZRPVALID0)
-#define F_ZRPVALID0 V_ZRPVALID0(1U)
-
-#define S_ERRVALID0 0
-#define V_ERRVALID0(x) ((x) << S_ERRVALID0)
-#define F_ERRVALID0 V_ERRVALID0(1U)
-
-#define A_TP_DBG_CSIDE_TRACE_CNT 0x24a
-
-#define S_TRCSOPCNT 24
-#define M_TRCSOPCNT 0xffU
-#define V_TRCSOPCNT(x) ((x) << S_TRCSOPCNT)
-#define G_TRCSOPCNT(x) (((x) >> S_TRCSOPCNT) & M_TRCSOPCNT)
-
-#define S_TRCEOPCNT 16
-#define M_TRCEOPCNT 0xffU
-#define V_TRCEOPCNT(x) ((x) << S_TRCEOPCNT)
-#define G_TRCEOPCNT(x) (((x) >> S_TRCEOPCNT) & M_TRCEOPCNT)
-
-#define S_TRCFLTHIT 12
-#define M_TRCFLTHIT 0xfU
-#define V_TRCFLTHIT(x) ((x) << S_TRCFLTHIT)
-#define G_TRCFLTHIT(x) (((x) >> S_TRCFLTHIT) & M_TRCFLTHIT)
-
-#define S_TRCRNTPKT 8
-#define M_TRCRNTPKT 0xfU
-#define V_TRCRNTPKT(x) ((x) << S_TRCRNTPKT)
-#define G_TRCRNTPKT(x) (((x) >> S_TRCRNTPKT) & M_TRCRNTPKT)
-
-#define S_TRCPKTLEN 0
-#define M_TRCPKTLEN 0xffU
-#define V_TRCPKTLEN(x) ((x) << S_TRCPKTLEN)
-#define G_TRCPKTLEN(x) (((x) >> S_TRCPKTLEN) & M_TRCPKTLEN)
-
-#define A_TP_DBG_CSIDE_TRACE_RSS 0x24b
-#define A_TP_VLN_CONFIG 0x24c
-
-#define S_ETHTYPEQINQ 16
-#define M_ETHTYPEQINQ 0xffffU
-#define V_ETHTYPEQINQ(x) ((x) << S_ETHTYPEQINQ)
-#define G_ETHTYPEQINQ(x) (((x) >> S_ETHTYPEQINQ) & M_ETHTYPEQINQ)
-
-#define S_ETHTYPEVLAN 0
-#define M_ETHTYPEVLAN 0xffffU
-#define V_ETHTYPEVLAN(x) ((x) << S_ETHTYPEVLAN)
-#define G_ETHTYPEVLAN(x) (((x) >> S_ETHTYPEVLAN) & M_ETHTYPEVLAN)
-
-#define A_TP_DBG_CSIDE_ARBIT_WAIT0 0x24d
-#define A_TP_DBG_CSIDE_ARBIT_WAIT1 0x24e
-#define A_TP_DBG_CSIDE_ARBIT_CNT0 0x24f
-#define A_TP_DBG_CSIDE_ARBIT_CNT1 0x250
-#define A_TP_FIFO_CONFIG 0x8c0
-
-#define S_CH1_OUTPUT 27
-#define M_CH1_OUTPUT 0x1fU
-#define V_CH1_OUTPUT(x) ((x) << S_CH1_OUTPUT)
-#define G_CH1_OUTPUT(x) (((x) >> S_CH1_OUTPUT) & M_CH1_OUTPUT)
-
-#define S_CH2_OUTPUT 22
-#define M_CH2_OUTPUT 0x1fU
-#define V_CH2_OUTPUT(x) ((x) << S_CH2_OUTPUT)
-#define G_CH2_OUTPUT(x) (((x) >> S_CH2_OUTPUT) & M_CH2_OUTPUT)
-
-#define S_STROBE1 16
-#define V_STROBE1(x) ((x) << S_STROBE1)
-#define F_STROBE1 V_STROBE1(1U)
-
-#define S_CH1_INPUT 11
-#define M_CH1_INPUT 0x1fU
-#define V_CH1_INPUT(x) ((x) << S_CH1_INPUT)
-#define G_CH1_INPUT(x) (((x) >> S_CH1_INPUT) & M_CH1_INPUT)
-
-#define S_CH2_INPUT 6
-#define M_CH2_INPUT 0x1fU
-#define V_CH2_INPUT(x) ((x) << S_CH2_INPUT)
-#define G_CH2_INPUT(x) (((x) >> S_CH2_INPUT) & M_CH2_INPUT)
-
-#define S_CH3_INPUT 1
-#define M_CH3_INPUT 0x1fU
-#define V_CH3_INPUT(x) ((x) << S_CH3_INPUT)
-#define G_CH3_INPUT(x) (((x) >> S_CH3_INPUT) & M_CH3_INPUT)
-
-#define S_STROBE0 0
-#define V_STROBE0(x) ((x) << S_STROBE0)
-#define F_STROBE0 V_STROBE0(1U)
-
-#define A_TP_MIB_MAC_IN_ERR_0 0x0
-#define A_TP_MIB_MAC_IN_ERR_1 0x1
-#define A_TP_MIB_MAC_IN_ERR_2 0x2
-#define A_TP_MIB_MAC_IN_ERR_3 0x3
-#define A_TP_MIB_HDR_IN_ERR_0 0x4
-#define A_TP_MIB_HDR_IN_ERR_1 0x5
-#define A_TP_MIB_HDR_IN_ERR_2 0x6
-#define A_TP_MIB_HDR_IN_ERR_3 0x7
-#define A_TP_MIB_TCP_IN_ERR_0 0x8
-#define A_TP_MIB_TCP_IN_ERR_1 0x9
-#define A_TP_MIB_TCP_IN_ERR_2 0xa
-#define A_TP_MIB_TCP_IN_ERR_3 0xb
-#define A_TP_MIB_TCP_OUT_RST 0xc
-#define A_TP_MIB_TCP_IN_SEG_HI 0x10
-#define A_TP_MIB_TCP_IN_SEG_LO 0x11
-#define A_TP_MIB_TCP_OUT_SEG_HI 0x12
-#define A_TP_MIB_TCP_OUT_SEG_LO 0x13
-#define A_TP_MIB_TCP_RXT_SEG_HI 0x14
-#define A_TP_MIB_TCP_RXT_SEG_LO 0x15
-#define A_TP_MIB_TNL_CNG_DROP_0 0x18
-#define A_TP_MIB_TNL_CNG_DROP_1 0x19
-#define A_TP_MIB_TNL_CNG_DROP_2 0x1a
-#define A_TP_MIB_TNL_CNG_DROP_3 0x1b
-#define A_TP_MIB_OFD_CHN_DROP_0 0x1c
-#define A_TP_MIB_OFD_CHN_DROP_1 0x1d
-#define A_TP_MIB_OFD_CHN_DROP_2 0x1e
-#define A_TP_MIB_OFD_CHN_DROP_3 0x1f
-#define A_TP_MIB_TNL_OUT_PKT_0 0x20
-#define A_TP_MIB_TNL_OUT_PKT_1 0x21
-#define A_TP_MIB_TNL_OUT_PKT_2 0x22
-#define A_TP_MIB_TNL_OUT_PKT_3 0x23
-#define A_TP_MIB_TNL_IN_PKT_0 0x24
-#define A_TP_MIB_TNL_IN_PKT_1 0x25
-#define A_TP_MIB_TNL_IN_PKT_2 0x26
-#define A_TP_MIB_TNL_IN_PKT_3 0x27
-#define A_TP_MIB_TCP_V6IN_ERR_0 0x28
-#define A_TP_MIB_TCP_V6IN_ERR_1 0x29
-#define A_TP_MIB_TCP_V6IN_ERR_2 0x2a
-#define A_TP_MIB_TCP_V6IN_ERR_3 0x2b
-#define A_TP_MIB_TCP_V6OUT_RST 0x2c
-#define A_TP_MIB_TCP_V6IN_SEG_HI 0x30
-#define A_TP_MIB_TCP_V6IN_SEG_LO 0x31
-#define A_TP_MIB_TCP_V6OUT_SEG_HI 0x32
-#define A_TP_MIB_TCP_V6OUT_SEG_LO 0x33
-#define A_TP_MIB_TCP_V6RXT_SEG_HI 0x34
-#define A_TP_MIB_TCP_V6RXT_SEG_LO 0x35
-#define A_TP_MIB_OFD_ARP_DROP 0x36
-#define A_TP_MIB_OFD_DFR_DROP 0x37
-#define A_TP_MIB_CPL_IN_REQ_0 0x38
-#define A_TP_MIB_CPL_IN_REQ_1 0x39
-#define A_TP_MIB_CPL_IN_REQ_2 0x3a
-#define A_TP_MIB_CPL_IN_REQ_3 0x3b
-#define A_TP_MIB_CPL_OUT_RSP_0 0x3c
-#define A_TP_MIB_CPL_OUT_RSP_1 0x3d
-#define A_TP_MIB_CPL_OUT_RSP_2 0x3e
-#define A_TP_MIB_CPL_OUT_RSP_3 0x3f
-#define A_TP_MIB_TNL_LPBK_0 0x40
-#define A_TP_MIB_TNL_LPBK_1 0x41
-#define A_TP_MIB_TNL_LPBK_2 0x42
-#define A_TP_MIB_TNL_LPBK_3 0x43
-#define A_TP_MIB_TNL_DROP_0 0x44
-#define A_TP_MIB_TNL_DROP_1 0x45
-#define A_TP_MIB_TNL_DROP_2 0x46
-#define A_TP_MIB_TNL_DROP_3 0x47
-#define A_TP_MIB_FCOE_DDP_0 0x48
-#define A_TP_MIB_FCOE_DDP_1 0x49
-#define A_TP_MIB_FCOE_DDP_2 0x4a
-#define A_TP_MIB_FCOE_DDP_3 0x4b
-#define A_TP_MIB_FCOE_DROP_0 0x4c
-#define A_TP_MIB_FCOE_DROP_1 0x4d
-#define A_TP_MIB_FCOE_DROP_2 0x4e
-#define A_TP_MIB_FCOE_DROP_3 0x4f
-#define A_TP_MIB_FCOE_BYTE_0_HI 0x50
-#define A_TP_MIB_FCOE_BYTE_0_LO 0x51
-#define A_TP_MIB_FCOE_BYTE_1_HI 0x52
-#define A_TP_MIB_FCOE_BYTE_1_LO 0x53
-#define A_TP_MIB_FCOE_BYTE_2_HI 0x54
-#define A_TP_MIB_FCOE_BYTE_2_LO 0x55
-#define A_TP_MIB_FCOE_BYTE_3_HI 0x56
-#define A_TP_MIB_FCOE_BYTE_3_LO 0x57
-#define A_TP_MIB_OFD_VLN_DROP_0 0x58
-#define A_TP_MIB_OFD_VLN_DROP_1 0x59
-#define A_TP_MIB_OFD_VLN_DROP_2 0x5a
-#define A_TP_MIB_OFD_VLN_DROP_3 0x5b
-#define A_TP_MIB_USM_PKTS 0x5c
-#define A_TP_MIB_USM_DROP 0x5d
-#define A_TP_MIB_USM_BYTES_HI 0x5e
-#define A_TP_MIB_USM_BYTES_LO 0x5f
-#define A_TP_MIB_TID_DEL 0x60
-#define A_TP_MIB_TID_INV 0x61
-#define A_TP_MIB_TID_ACT 0x62
-#define A_TP_MIB_TID_PAS 0x63
-#define A_TP_MIB_RQE_DFR_PKT 0x64
-#define A_TP_MIB_RQE_DFR_MOD 0x65
-#define A_TP_MIB_CPL_OUT_ERR_0 0x68
-#define A_TP_MIB_CPL_OUT_ERR_1 0x69
-#define A_TP_MIB_CPL_OUT_ERR_2 0x6a
-#define A_TP_MIB_CPL_OUT_ERR_3 0x6b
-#define A_TP_MIB_ENG_LINE_0 0x6c
-#define A_TP_MIB_ENG_LINE_1 0x6d
-#define A_TP_MIB_ENG_LINE_2 0x6e
-#define A_TP_MIB_ENG_LINE_3 0x6f
-#define A_TP_MIB_TNL_ERR_0 0x70
-#define A_TP_MIB_TNL_ERR_1 0x71
-#define A_TP_MIB_TNL_ERR_2 0x72
-#define A_TP_MIB_TNL_ERR_3 0x73
-
-/* registers for module ULP_TX */
-#define ULP_TX_BASE_ADDR 0x8dc0
-
-#define A_ULP_TX_CONFIG 0x8dc0
-
-#define S_STAG_MIX_ENABLE 2
-#define V_STAG_MIX_ENABLE(x) ((x) << S_STAG_MIX_ENABLE)
-#define F_STAG_MIX_ENABLE V_STAG_MIX_ENABLE(1U)
-
-#define S_STAGF_FIX_DISABLE 1
-#define V_STAGF_FIX_DISABLE(x) ((x) << S_STAGF_FIX_DISABLE)
-#define F_STAGF_FIX_DISABLE V_STAGF_FIX_DISABLE(1U)
-
-#define S_EXTRA_TAG_INSERTION_ENABLE 0
-#define V_EXTRA_TAG_INSERTION_ENABLE(x) ((x) << S_EXTRA_TAG_INSERTION_ENABLE)
-#define F_EXTRA_TAG_INSERTION_ENABLE V_EXTRA_TAG_INSERTION_ENABLE(1U)
-
-#define S_PHYS_ADDR_RESP_EN 6
-#define V_PHYS_ADDR_RESP_EN(x) ((x) << S_PHYS_ADDR_RESP_EN)
-#define F_PHYS_ADDR_RESP_EN V_PHYS_ADDR_RESP_EN(1U)
-
-#define S_ENDIANESS_CHANGE 5
-#define V_ENDIANESS_CHANGE(x) ((x) << S_ENDIANESS_CHANGE)
-#define F_ENDIANESS_CHANGE V_ENDIANESS_CHANGE(1U)
-
-#define S_ERR_RTAG_EN 4
-#define V_ERR_RTAG_EN(x) ((x) << S_ERR_RTAG_EN)
-#define F_ERR_RTAG_EN V_ERR_RTAG_EN(1U)
-
-#define S_TSO_ETHLEN_EN 3
-#define V_TSO_ETHLEN_EN(x) ((x) << S_TSO_ETHLEN_EN)
-#define F_TSO_ETHLEN_EN V_TSO_ETHLEN_EN(1U)
-
-#define S_EMSG_MORE_INFO 2
-#define V_EMSG_MORE_INFO(x) ((x) << S_EMSG_MORE_INFO)
-#define F_EMSG_MORE_INFO V_EMSG_MORE_INFO(1U)
-
-#define S_LOSDR 1
-#define V_LOSDR(x) ((x) << S_LOSDR)
-#define F_LOSDR V_LOSDR(1U)
-
-#define S_ULIMIT_EXCLUSIVE_FIX 16
-#define V_ULIMIT_EXCLUSIVE_FIX(x) ((x) << S_ULIMIT_EXCLUSIVE_FIX)
-#define F_ULIMIT_EXCLUSIVE_FIX V_ULIMIT_EXCLUSIVE_FIX(1U)
-
-#define S_ISO_A_FLAG_EN 15
-#define V_ISO_A_FLAG_EN(x) ((x) << S_ISO_A_FLAG_EN)
-#define F_ISO_A_FLAG_EN V_ISO_A_FLAG_EN(1U)
-
-#define S_IWARP_SEQ_FLIT_DIS 14
-#define V_IWARP_SEQ_FLIT_DIS(x) ((x) << S_IWARP_SEQ_FLIT_DIS)
-#define F_IWARP_SEQ_FLIT_DIS V_IWARP_SEQ_FLIT_DIS(1U)
-
-#define S_MR_SIZE_FIX_EN 13
-#define V_MR_SIZE_FIX_EN(x) ((x) << S_MR_SIZE_FIX_EN)
-#define F_MR_SIZE_FIX_EN V_MR_SIZE_FIX_EN(1U)
-
-#define S_T10_ISO_FIX_EN 12
-#define V_T10_ISO_FIX_EN(x) ((x) << S_T10_ISO_FIX_EN)
-#define F_T10_ISO_FIX_EN V_T10_ISO_FIX_EN(1U)
-
-#define S_CPL_FLAGS_UPDATE_EN 11
-#define V_CPL_FLAGS_UPDATE_EN(x) ((x) << S_CPL_FLAGS_UPDATE_EN)
-#define F_CPL_FLAGS_UPDATE_EN V_CPL_FLAGS_UPDATE_EN(1U)
-
-#define S_IWARP_SEQ_UPDATE_EN 10
-#define V_IWARP_SEQ_UPDATE_EN(x) ((x) << S_IWARP_SEQ_UPDATE_EN)
-#define F_IWARP_SEQ_UPDATE_EN V_IWARP_SEQ_UPDATE_EN(1U)
-
-#define S_SEQ_UPDATE_EN 9
-#define V_SEQ_UPDATE_EN(x) ((x) << S_SEQ_UPDATE_EN)
-#define F_SEQ_UPDATE_EN V_SEQ_UPDATE_EN(1U)
-
-#define S_ERR_ITT_EN 8
-#define V_ERR_ITT_EN(x) ((x) << S_ERR_ITT_EN)
-#define F_ERR_ITT_EN V_ERR_ITT_EN(1U)
-
-#define S_ATOMIC_FIX_DIS 7
-#define V_ATOMIC_FIX_DIS(x) ((x) << S_ATOMIC_FIX_DIS)
-#define F_ATOMIC_FIX_DIS V_ATOMIC_FIX_DIS(1U)
-
-#define A_ULP_TX_PERR_INJECT 0x8dc4
-#define A_ULP_TX_INT_ENABLE 0x8dc8
-
-#define S_PBL_BOUND_ERR_CH3 31
-#define V_PBL_BOUND_ERR_CH3(x) ((x) << S_PBL_BOUND_ERR_CH3)
-#define F_PBL_BOUND_ERR_CH3 V_PBL_BOUND_ERR_CH3(1U)
-
-#define S_PBL_BOUND_ERR_CH2 30
-#define V_PBL_BOUND_ERR_CH2(x) ((x) << S_PBL_BOUND_ERR_CH2)
-#define F_PBL_BOUND_ERR_CH2 V_PBL_BOUND_ERR_CH2(1U)
-
-#define S_PBL_BOUND_ERR_CH1 29
-#define V_PBL_BOUND_ERR_CH1(x) ((x) << S_PBL_BOUND_ERR_CH1)
-#define F_PBL_BOUND_ERR_CH1 V_PBL_BOUND_ERR_CH1(1U)
-
-#define S_PBL_BOUND_ERR_CH0 28
-#define V_PBL_BOUND_ERR_CH0(x) ((x) << S_PBL_BOUND_ERR_CH0)
-#define F_PBL_BOUND_ERR_CH0 V_PBL_BOUND_ERR_CH0(1U)
-
-#define S_SGE2ULP_FIFO_PERR_SET3 27
-#define V_SGE2ULP_FIFO_PERR_SET3(x) ((x) << S_SGE2ULP_FIFO_PERR_SET3)
-#define F_SGE2ULP_FIFO_PERR_SET3 V_SGE2ULP_FIFO_PERR_SET3(1U)
-
-#define S_SGE2ULP_FIFO_PERR_SET2 26
-#define V_SGE2ULP_FIFO_PERR_SET2(x) ((x) << S_SGE2ULP_FIFO_PERR_SET2)
-#define F_SGE2ULP_FIFO_PERR_SET2 V_SGE2ULP_FIFO_PERR_SET2(1U)
-
-#define S_SGE2ULP_FIFO_PERR_SET1 25
-#define V_SGE2ULP_FIFO_PERR_SET1(x) ((x) << S_SGE2ULP_FIFO_PERR_SET1)
-#define F_SGE2ULP_FIFO_PERR_SET1 V_SGE2ULP_FIFO_PERR_SET1(1U)
-
-#define S_SGE2ULP_FIFO_PERR_SET0 24
-#define V_SGE2ULP_FIFO_PERR_SET0(x) ((x) << S_SGE2ULP_FIFO_PERR_SET0)
-#define F_SGE2ULP_FIFO_PERR_SET0 V_SGE2ULP_FIFO_PERR_SET0(1U)
-
-#define S_CIM2ULP_FIFO_PERR_SET3 23
-#define V_CIM2ULP_FIFO_PERR_SET3(x) ((x) << S_CIM2ULP_FIFO_PERR_SET3)
-#define F_CIM2ULP_FIFO_PERR_SET3 V_CIM2ULP_FIFO_PERR_SET3(1U)
-
-#define S_CIM2ULP_FIFO_PERR_SET2 22
-#define V_CIM2ULP_FIFO_PERR_SET2(x) ((x) << S_CIM2ULP_FIFO_PERR_SET2)
-#define F_CIM2ULP_FIFO_PERR_SET2 V_CIM2ULP_FIFO_PERR_SET2(1U)
-
-#define S_CIM2ULP_FIFO_PERR_SET1 21
-#define V_CIM2ULP_FIFO_PERR_SET1(x) ((x) << S_CIM2ULP_FIFO_PERR_SET1)
-#define F_CIM2ULP_FIFO_PERR_SET1 V_CIM2ULP_FIFO_PERR_SET1(1U)
-
-#define S_CIM2ULP_FIFO_PERR_SET0 20
-#define V_CIM2ULP_FIFO_PERR_SET0(x) ((x) << S_CIM2ULP_FIFO_PERR_SET0)
-#define F_CIM2ULP_FIFO_PERR_SET0 V_CIM2ULP_FIFO_PERR_SET0(1U)
-
-#define S_CQE_FIFO_PERR_SET3 19
-#define V_CQE_FIFO_PERR_SET3(x) ((x) << S_CQE_FIFO_PERR_SET3)
-#define F_CQE_FIFO_PERR_SET3 V_CQE_FIFO_PERR_SET3(1U)
-
-#define S_CQE_FIFO_PERR_SET2 18
-#define V_CQE_FIFO_PERR_SET2(x) ((x) << S_CQE_FIFO_PERR_SET2)
-#define F_CQE_FIFO_PERR_SET2 V_CQE_FIFO_PERR_SET2(1U)
-
-#define S_CQE_FIFO_PERR_SET1 17
-#define V_CQE_FIFO_PERR_SET1(x) ((x) << S_CQE_FIFO_PERR_SET1)
-#define F_CQE_FIFO_PERR_SET1 V_CQE_FIFO_PERR_SET1(1U)
-
-#define S_CQE_FIFO_PERR_SET0 16
-#define V_CQE_FIFO_PERR_SET0(x) ((x) << S_CQE_FIFO_PERR_SET0)
-#define F_CQE_FIFO_PERR_SET0 V_CQE_FIFO_PERR_SET0(1U)
-
-#define S_PBL_FIFO_PERR_SET3 15
-#define V_PBL_FIFO_PERR_SET3(x) ((x) << S_PBL_FIFO_PERR_SET3)
-#define F_PBL_FIFO_PERR_SET3 V_PBL_FIFO_PERR_SET3(1U)
-
-#define S_PBL_FIFO_PERR_SET2 14
-#define V_PBL_FIFO_PERR_SET2(x) ((x) << S_PBL_FIFO_PERR_SET2)
-#define F_PBL_FIFO_PERR_SET2 V_PBL_FIFO_PERR_SET2(1U)
-
-#define S_PBL_FIFO_PERR_SET1 13
-#define V_PBL_FIFO_PERR_SET1(x) ((x) << S_PBL_FIFO_PERR_SET1)
-#define F_PBL_FIFO_PERR_SET1 V_PBL_FIFO_PERR_SET1(1U)
-
-#define S_PBL_FIFO_PERR_SET0 12
-#define V_PBL_FIFO_PERR_SET0(x) ((x) << S_PBL_FIFO_PERR_SET0)
-#define F_PBL_FIFO_PERR_SET0 V_PBL_FIFO_PERR_SET0(1U)
-
-#define S_CMD_FIFO_PERR_SET3 11
-#define V_CMD_FIFO_PERR_SET3(x) ((x) << S_CMD_FIFO_PERR_SET3)
-#define F_CMD_FIFO_PERR_SET3 V_CMD_FIFO_PERR_SET3(1U)
-
-#define S_CMD_FIFO_PERR_SET2 10
-#define V_CMD_FIFO_PERR_SET2(x) ((x) << S_CMD_FIFO_PERR_SET2)
-#define F_CMD_FIFO_PERR_SET2 V_CMD_FIFO_PERR_SET2(1U)
-
-#define S_CMD_FIFO_PERR_SET1 9
-#define V_CMD_FIFO_PERR_SET1(x) ((x) << S_CMD_FIFO_PERR_SET1)
-#define F_CMD_FIFO_PERR_SET1 V_CMD_FIFO_PERR_SET1(1U)
-
-#define S_CMD_FIFO_PERR_SET0 8
-#define V_CMD_FIFO_PERR_SET0(x) ((x) << S_CMD_FIFO_PERR_SET0)
-#define F_CMD_FIFO_PERR_SET0 V_CMD_FIFO_PERR_SET0(1U)
-
-#define S_LSO_HDR_SRAM_PERR_SET3 7
-#define V_LSO_HDR_SRAM_PERR_SET3(x) ((x) << S_LSO_HDR_SRAM_PERR_SET3)
-#define F_LSO_HDR_SRAM_PERR_SET3 V_LSO_HDR_SRAM_PERR_SET3(1U)
-
-#define S_LSO_HDR_SRAM_PERR_SET2 6
-#define V_LSO_HDR_SRAM_PERR_SET2(x) ((x) << S_LSO_HDR_SRAM_PERR_SET2)
-#define F_LSO_HDR_SRAM_PERR_SET2 V_LSO_HDR_SRAM_PERR_SET2(1U)
-
-#define S_LSO_HDR_SRAM_PERR_SET1 5
-#define V_LSO_HDR_SRAM_PERR_SET1(x) ((x) << S_LSO_HDR_SRAM_PERR_SET1)
-#define F_LSO_HDR_SRAM_PERR_SET1 V_LSO_HDR_SRAM_PERR_SET1(1U)
-
-#define S_LSO_HDR_SRAM_PERR_SET0 4
-#define V_LSO_HDR_SRAM_PERR_SET0(x) ((x) << S_LSO_HDR_SRAM_PERR_SET0)
-#define F_LSO_HDR_SRAM_PERR_SET0 V_LSO_HDR_SRAM_PERR_SET0(1U)
-
-#define S_IMM_DATA_PERR_SET_CH3 3
-#define V_IMM_DATA_PERR_SET_CH3(x) ((x) << S_IMM_DATA_PERR_SET_CH3)
-#define F_IMM_DATA_PERR_SET_CH3 V_IMM_DATA_PERR_SET_CH3(1U)
-
-#define S_IMM_DATA_PERR_SET_CH2 2
-#define V_IMM_DATA_PERR_SET_CH2(x) ((x) << S_IMM_DATA_PERR_SET_CH2)
-#define F_IMM_DATA_PERR_SET_CH2 V_IMM_DATA_PERR_SET_CH2(1U)
-
-#define S_IMM_DATA_PERR_SET_CH1 1
-#define V_IMM_DATA_PERR_SET_CH1(x) ((x) << S_IMM_DATA_PERR_SET_CH1)
-#define F_IMM_DATA_PERR_SET_CH1 V_IMM_DATA_PERR_SET_CH1(1U)
-
-#define S_IMM_DATA_PERR_SET_CH0 0
-#define V_IMM_DATA_PERR_SET_CH0(x) ((x) << S_IMM_DATA_PERR_SET_CH0)
-#define F_IMM_DATA_PERR_SET_CH0 V_IMM_DATA_PERR_SET_CH0(1U)
-
-#define A_ULP_TX_INT_CAUSE 0x8dcc
-#define A_ULP_TX_PERR_ENABLE 0x8dd0
-#define A_ULP_TX_TPT_LLIMIT 0x8dd4
-#define A_ULP_TX_TPT_ULIMIT 0x8dd8
-#define A_ULP_TX_PBL_LLIMIT 0x8ddc
-#define A_ULP_TX_PBL_ULIMIT 0x8de0
-#define A_ULP_TX_CPL_ERR_OFFSET 0x8de4
-#define A_ULP_TX_TLS_CTL 0x8de4
-
-#define S_TLSPERREN 4
-#define V_TLSPERREN(x) ((x) << S_TLSPERREN)
-#define F_TLSPERREN V_TLSPERREN(1U)
-
-#define S_TLSPATHCTL 3
-#define V_TLSPATHCTL(x) ((x) << S_TLSPATHCTL)
-#define F_TLSPATHCTL V_TLSPATHCTL(1U)
-
-#define S_TLSDISABLEIFUSE 2
-#define V_TLSDISABLEIFUSE(x) ((x) << S_TLSDISABLEIFUSE)
-#define F_TLSDISABLEIFUSE V_TLSDISABLEIFUSE(1U)
-
-#define S_TLSDISABLECFUSE 1
-#define V_TLSDISABLECFUSE(x) ((x) << S_TLSDISABLECFUSE)
-#define F_TLSDISABLECFUSE V_TLSDISABLECFUSE(1U)
-
-#define S_TLSDISABLE 0
-#define V_TLSDISABLE(x) ((x) << S_TLSDISABLE)
-#define F_TLSDISABLE V_TLSDISABLE(1U)
-
-#define A_ULP_TX_CPL_ERR_MASK_L 0x8de8
-#define A_ULP_TX_CPL_ERR_MASK_H 0x8dec
-#define A_ULP_TX_CPL_ERR_VALUE_L 0x8df0
-#define A_ULP_TX_CPL_ERR_VALUE_H 0x8df4
-#define A_ULP_TX_CPL_PACK_SIZE1 0x8df8
-
-#define S_CH3SIZE1 24
-#define M_CH3SIZE1 0xffU
-#define V_CH3SIZE1(x) ((x) << S_CH3SIZE1)
-#define G_CH3SIZE1(x) (((x) >> S_CH3SIZE1) & M_CH3SIZE1)
-
-#define S_CH2SIZE1 16
-#define M_CH2SIZE1 0xffU
-#define V_CH2SIZE1(x) ((x) << S_CH2SIZE1)
-#define G_CH2SIZE1(x) (((x) >> S_CH2SIZE1) & M_CH2SIZE1)
-
-#define S_CH1SIZE1 8
-#define M_CH1SIZE1 0xffU
-#define V_CH1SIZE1(x) ((x) << S_CH1SIZE1)
-#define G_CH1SIZE1(x) (((x) >> S_CH1SIZE1) & M_CH1SIZE1)
-
-#define S_CH0SIZE1 0
-#define M_CH0SIZE1 0xffU
-#define V_CH0SIZE1(x) ((x) << S_CH0SIZE1)
-#define G_CH0SIZE1(x) (((x) >> S_CH0SIZE1) & M_CH0SIZE1)
-
-#define A_ULP_TX_CPL_PACK_SIZE2 0x8dfc
-
-#define S_CH3SIZE2 24
-#define M_CH3SIZE2 0xffU
-#define V_CH3SIZE2(x) ((x) << S_CH3SIZE2)
-#define G_CH3SIZE2(x) (((x) >> S_CH3SIZE2) & M_CH3SIZE2)
-
-#define S_CH2SIZE2 16
-#define M_CH2SIZE2 0xffU
-#define V_CH2SIZE2(x) ((x) << S_CH2SIZE2)
-#define G_CH2SIZE2(x) (((x) >> S_CH2SIZE2) & M_CH2SIZE2)
-
-#define S_CH1SIZE2 8
-#define M_CH1SIZE2 0xffU
-#define V_CH1SIZE2(x) ((x) << S_CH1SIZE2)
-#define G_CH1SIZE2(x) (((x) >> S_CH1SIZE2) & M_CH1SIZE2)
-
-#define S_CH0SIZE2 0
-#define M_CH0SIZE2 0xffU
-#define V_CH0SIZE2(x) ((x) << S_CH0SIZE2)
-#define G_CH0SIZE2(x) (((x) >> S_CH0SIZE2) & M_CH0SIZE2)
-
-#define A_ULP_TX_ERR_MSG2CIM 0x8e00
-#define A_ULP_TX_ERR_TABLE_BASE 0x8e04
-#define A_ULP_TX_ERR_CNT_CH0 0x8e10
-
-#define S_ERR_CNT0 0
-#define M_ERR_CNT0 0xfffffU
-#define V_ERR_CNT0(x) ((x) << S_ERR_CNT0)
-#define G_ERR_CNT0(x) (((x) >> S_ERR_CNT0) & M_ERR_CNT0)
-
-#define A_ULP_TX_ERR_CNT_CH1 0x8e14
-
-#define S_ERR_CNT1 0
-#define M_ERR_CNT1 0xfffffU
-#define V_ERR_CNT1(x) ((x) << S_ERR_CNT1)
-#define G_ERR_CNT1(x) (((x) >> S_ERR_CNT1) & M_ERR_CNT1)
-
-#define A_ULP_TX_ERR_CNT_CH2 0x8e18
-
-#define S_ERR_CNT2 0
-#define M_ERR_CNT2 0xfffffU
-#define V_ERR_CNT2(x) ((x) << S_ERR_CNT2)
-#define G_ERR_CNT2(x) (((x) >> S_ERR_CNT2) & M_ERR_CNT2)
-
-#define A_ULP_TX_ERR_CNT_CH3 0x8e1c
-
-#define S_ERR_CNT3 0
-#define M_ERR_CNT3 0xfffffU
-#define V_ERR_CNT3(x) ((x) << S_ERR_CNT3)
-#define G_ERR_CNT3(x) (((x) >> S_ERR_CNT3) & M_ERR_CNT3)
-
-#define A_ULP_TX_FC_SOF 0x8e20
-
-#define S_SOF_FS3 24
-#define M_SOF_FS3 0xffU
-#define V_SOF_FS3(x) ((x) << S_SOF_FS3)
-#define G_SOF_FS3(x) (((x) >> S_SOF_FS3) & M_SOF_FS3)
-
-#define S_SOF_FS2 16
-#define M_SOF_FS2 0xffU
-#define V_SOF_FS2(x) ((x) << S_SOF_FS2)
-#define G_SOF_FS2(x) (((x) >> S_SOF_FS2) & M_SOF_FS2)
-
-#define S_SOF_3 8
-#define M_SOF_3 0xffU
-#define V_SOF_3(x) ((x) << S_SOF_3)
-#define G_SOF_3(x) (((x) >> S_SOF_3) & M_SOF_3)
-
-#define S_SOF_2 0
-#define M_SOF_2 0xffU
-#define V_SOF_2(x) ((x) << S_SOF_2)
-#define G_SOF_2(x) (((x) >> S_SOF_2) & M_SOF_2)
-
-#define A_ULP_TX_FC_EOF 0x8e24
-
-#define S_EOF_LS3 24
-#define M_EOF_LS3 0xffU
-#define V_EOF_LS3(x) ((x) << S_EOF_LS3)
-#define G_EOF_LS3(x) (((x) >> S_EOF_LS3) & M_EOF_LS3)
-
-#define S_EOF_LS2 16
-#define M_EOF_LS2 0xffU
-#define V_EOF_LS2(x) ((x) << S_EOF_LS2)
-#define G_EOF_LS2(x) (((x) >> S_EOF_LS2) & M_EOF_LS2)
-
-#define S_EOF_3 8
-#define M_EOF_3 0xffU
-#define V_EOF_3(x) ((x) << S_EOF_3)
-#define G_EOF_3(x) (((x) >> S_EOF_3) & M_EOF_3)
-
-#define S_EOF_2 0
-#define M_EOF_2 0xffU
-#define V_EOF_2(x) ((x) << S_EOF_2)
-#define G_EOF_2(x) (((x) >> S_EOF_2) & M_EOF_2)
-
-#define A_ULP_TX_CGEN_GLOBAL 0x8e28
-
-#define S_ULP_TX_GLOBAL_CGEN 0
-#define V_ULP_TX_GLOBAL_CGEN(x) ((x) << S_ULP_TX_GLOBAL_CGEN)
-#define F_ULP_TX_GLOBAL_CGEN V_ULP_TX_GLOBAL_CGEN(1U)
-
-#define A_ULP_TX_CGEN 0x8e2c
-
-#define S_ULP_TX_CGEN_STORAGE 8
-#define M_ULP_TX_CGEN_STORAGE 0xfU
-#define V_ULP_TX_CGEN_STORAGE(x) ((x) << S_ULP_TX_CGEN_STORAGE)
-#define G_ULP_TX_CGEN_STORAGE(x) (((x) >> S_ULP_TX_CGEN_STORAGE) & M_ULP_TX_CGEN_STORAGE)
-
-#define S_ULP_TX_CGEN_RDMA 4
-#define M_ULP_TX_CGEN_RDMA 0xfU
-#define V_ULP_TX_CGEN_RDMA(x) ((x) << S_ULP_TX_CGEN_RDMA)
-#define G_ULP_TX_CGEN_RDMA(x) (((x) >> S_ULP_TX_CGEN_RDMA) & M_ULP_TX_CGEN_RDMA)
-
-#define S_ULP_TX_CGEN_CHANNEL 0
-#define M_ULP_TX_CGEN_CHANNEL 0xfU
-#define V_ULP_TX_CGEN_CHANNEL(x) ((x) << S_ULP_TX_CGEN_CHANNEL)
-#define G_ULP_TX_CGEN_CHANNEL(x) (((x) >> S_ULP_TX_CGEN_CHANNEL) & M_ULP_TX_CGEN_CHANNEL)
-
-#define A_ULP_TX_ULP2TP_BIST_CMD 0x8e30
-#define A_ULP_TX_MEM_CFG 0x8e30
-
-#define S_WRREQ_SZ 0
-#define M_WRREQ_SZ 0x7U
-#define V_WRREQ_SZ(x) ((x) << S_WRREQ_SZ)
-#define G_WRREQ_SZ(x) (((x) >> S_WRREQ_SZ) & M_WRREQ_SZ)
-
-#define A_ULP_TX_ULP2TP_BIST_ERROR_CNT 0x8e34
-#define A_ULP_TX_PERR_INJECT_2 0x8e34
-
-#define S_T5_MEMSEL 1
-#define M_T5_MEMSEL 0x7U
-#define V_T5_MEMSEL(x) ((x) << S_T5_MEMSEL)
-#define G_T5_MEMSEL(x) (((x) >> S_T5_MEMSEL) & M_T5_MEMSEL)
-
-#define S_MEMSEL_ULPTX 1
-#define M_MEMSEL_ULPTX 0x1fU
-#define V_MEMSEL_ULPTX(x) ((x) << S_MEMSEL_ULPTX)
-#define G_MEMSEL_ULPTX(x) (((x) >> S_MEMSEL_ULPTX) & M_MEMSEL_ULPTX)
-
-#define A_ULP_TX_FPGA_CMD_CTRL 0x8e38
-#define A_ULP_TX_T5_FPGA_CMD_CTRL 0x8e38
-
-#define S_CHANNEL_SEL 12
-#define M_CHANNEL_SEL 0x3U
-#define V_CHANNEL_SEL(x) ((x) << S_CHANNEL_SEL)
-#define G_CHANNEL_SEL(x) (((x) >> S_CHANNEL_SEL) & M_CHANNEL_SEL)
-
-#define S_INTF_SEL 4
-#define M_INTF_SEL 0xfU
-#define V_INTF_SEL(x) ((x) << S_INTF_SEL)
-#define G_INTF_SEL(x) (((x) >> S_INTF_SEL) & M_INTF_SEL)
-
-#define S_NUM_FLITS 1
-#define M_NUM_FLITS 0x7U
-#define V_NUM_FLITS(x) ((x) << S_NUM_FLITS)
-#define G_NUM_FLITS(x) (((x) >> S_NUM_FLITS) & M_NUM_FLITS)
-
-#define S_CMD_GEN_EN 0
-#define V_CMD_GEN_EN(x) ((x) << S_CMD_GEN_EN)
-#define F_CMD_GEN_EN V_CMD_GEN_EN(1U)
-
-#define A_ULP_TX_FPGA_CMD_0 0x8e3c
-#define A_ULP_TX_T5_FPGA_CMD_0 0x8e3c
-#define A_ULP_TX_FPGA_CMD_1 0x8e40
-#define A_ULP_TX_T5_FPGA_CMD_1 0x8e40
-#define A_ULP_TX_FPGA_CMD_2 0x8e44
-#define A_ULP_TX_T5_FPGA_CMD_2 0x8e44
-#define A_ULP_TX_FPGA_CMD_3 0x8e48
-#define A_ULP_TX_T5_FPGA_CMD_3 0x8e48
-#define A_ULP_TX_FPGA_CMD_4 0x8e4c
-#define A_ULP_TX_T5_FPGA_CMD_4 0x8e4c
-#define A_ULP_TX_FPGA_CMD_5 0x8e50
-#define A_ULP_TX_T5_FPGA_CMD_5 0x8e50
-#define A_ULP_TX_FPGA_CMD_6 0x8e54
-#define A_ULP_TX_T5_FPGA_CMD_6 0x8e54
-#define A_ULP_TX_FPGA_CMD_7 0x8e58
-#define A_ULP_TX_T5_FPGA_CMD_7 0x8e58
-#define A_ULP_TX_FPGA_CMD_8 0x8e5c
-#define A_ULP_TX_T5_FPGA_CMD_8 0x8e5c
-#define A_ULP_TX_FPGA_CMD_9 0x8e60
-#define A_ULP_TX_T5_FPGA_CMD_9 0x8e60
-#define A_ULP_TX_FPGA_CMD_10 0x8e64
-#define A_ULP_TX_T5_FPGA_CMD_10 0x8e64
-#define A_ULP_TX_FPGA_CMD_11 0x8e68
-#define A_ULP_TX_T5_FPGA_CMD_11 0x8e68
-#define A_ULP_TX_FPGA_CMD_12 0x8e6c
-#define A_ULP_TX_T5_FPGA_CMD_12 0x8e6c
-#define A_ULP_TX_FPGA_CMD_13 0x8e70
-#define A_ULP_TX_T5_FPGA_CMD_13 0x8e70
-#define A_ULP_TX_FPGA_CMD_14 0x8e74
-#define A_ULP_TX_T5_FPGA_CMD_14 0x8e74
-#define A_ULP_TX_FPGA_CMD_15 0x8e78
-#define A_ULP_TX_T5_FPGA_CMD_15 0x8e78
-#define A_ULP_TX_INT_ENABLE_2 0x8e7c
-
-#define S_SMARBT2ULP_DATA_PERR_SET 12
-#define V_SMARBT2ULP_DATA_PERR_SET(x) ((x) << S_SMARBT2ULP_DATA_PERR_SET)
-#define F_SMARBT2ULP_DATA_PERR_SET V_SMARBT2ULP_DATA_PERR_SET(1U)
-
-#define S_ULP2TP_DATA_PERR_SET 11
-#define V_ULP2TP_DATA_PERR_SET(x) ((x) << S_ULP2TP_DATA_PERR_SET)
-#define F_ULP2TP_DATA_PERR_SET V_ULP2TP_DATA_PERR_SET(1U)
-
-#define S_MA2ULP_DATA_PERR_SET 10
-#define V_MA2ULP_DATA_PERR_SET(x) ((x) << S_MA2ULP_DATA_PERR_SET)
-#define F_MA2ULP_DATA_PERR_SET V_MA2ULP_DATA_PERR_SET(1U)
-
-#define S_SGE2ULP_DATA_PERR_SET 9
-#define V_SGE2ULP_DATA_PERR_SET(x) ((x) << S_SGE2ULP_DATA_PERR_SET)
-#define F_SGE2ULP_DATA_PERR_SET V_SGE2ULP_DATA_PERR_SET(1U)
-
-#define S_CIM2ULP_DATA_PERR_SET 8
-#define V_CIM2ULP_DATA_PERR_SET(x) ((x) << S_CIM2ULP_DATA_PERR_SET)
-#define F_CIM2ULP_DATA_PERR_SET V_CIM2ULP_DATA_PERR_SET(1U)
-
-#define S_FSO_HDR_SRAM_PERR_SET3 7
-#define V_FSO_HDR_SRAM_PERR_SET3(x) ((x) << S_FSO_HDR_SRAM_PERR_SET3)
-#define F_FSO_HDR_SRAM_PERR_SET3 V_FSO_HDR_SRAM_PERR_SET3(1U)
-
-#define S_FSO_HDR_SRAM_PERR_SET2 6
-#define V_FSO_HDR_SRAM_PERR_SET2(x) ((x) << S_FSO_HDR_SRAM_PERR_SET2)
-#define F_FSO_HDR_SRAM_PERR_SET2 V_FSO_HDR_SRAM_PERR_SET2(1U)
-
-#define S_FSO_HDR_SRAM_PERR_SET1 5
-#define V_FSO_HDR_SRAM_PERR_SET1(x) ((x) << S_FSO_HDR_SRAM_PERR_SET1)
-#define F_FSO_HDR_SRAM_PERR_SET1 V_FSO_HDR_SRAM_PERR_SET1(1U)
-
-#define S_FSO_HDR_SRAM_PERR_SET0 4
-#define V_FSO_HDR_SRAM_PERR_SET0(x) ((x) << S_FSO_HDR_SRAM_PERR_SET0)
-#define F_FSO_HDR_SRAM_PERR_SET0 V_FSO_HDR_SRAM_PERR_SET0(1U)
-
-#define S_T10_PI_SRAM_PERR_SET3 3
-#define V_T10_PI_SRAM_PERR_SET3(x) ((x) << S_T10_PI_SRAM_PERR_SET3)
-#define F_T10_PI_SRAM_PERR_SET3 V_T10_PI_SRAM_PERR_SET3(1U)
-
-#define S_T10_PI_SRAM_PERR_SET2 2
-#define V_T10_PI_SRAM_PERR_SET2(x) ((x) << S_T10_PI_SRAM_PERR_SET2)
-#define F_T10_PI_SRAM_PERR_SET2 V_T10_PI_SRAM_PERR_SET2(1U)
-
-#define S_T10_PI_SRAM_PERR_SET1 1
-#define V_T10_PI_SRAM_PERR_SET1(x) ((x) << S_T10_PI_SRAM_PERR_SET1)
-#define F_T10_PI_SRAM_PERR_SET1 V_T10_PI_SRAM_PERR_SET1(1U)
-
-#define S_T10_PI_SRAM_PERR_SET0 0
-#define V_T10_PI_SRAM_PERR_SET0(x) ((x) << S_T10_PI_SRAM_PERR_SET0)
-#define F_T10_PI_SRAM_PERR_SET0 V_T10_PI_SRAM_PERR_SET0(1U)
-
-#define S_EDMA_IN_FIFO_PERR_SET3 31
-#define V_EDMA_IN_FIFO_PERR_SET3(x) ((x) << S_EDMA_IN_FIFO_PERR_SET3)
-#define F_EDMA_IN_FIFO_PERR_SET3 V_EDMA_IN_FIFO_PERR_SET3(1U)
-
-#define S_EDMA_IN_FIFO_PERR_SET2 30
-#define V_EDMA_IN_FIFO_PERR_SET2(x) ((x) << S_EDMA_IN_FIFO_PERR_SET2)
-#define F_EDMA_IN_FIFO_PERR_SET2 V_EDMA_IN_FIFO_PERR_SET2(1U)
-
-#define S_EDMA_IN_FIFO_PERR_SET1 29
-#define V_EDMA_IN_FIFO_PERR_SET1(x) ((x) << S_EDMA_IN_FIFO_PERR_SET1)
-#define F_EDMA_IN_FIFO_PERR_SET1 V_EDMA_IN_FIFO_PERR_SET1(1U)
-
-#define S_EDMA_IN_FIFO_PERR_SET0 28
-#define V_EDMA_IN_FIFO_PERR_SET0(x) ((x) << S_EDMA_IN_FIFO_PERR_SET0)
-#define F_EDMA_IN_FIFO_PERR_SET0 V_EDMA_IN_FIFO_PERR_SET0(1U)
-
-#define S_ALIGN_CTL_FIFO_PERR_SET3 27
-#define V_ALIGN_CTL_FIFO_PERR_SET3(x) ((x) << S_ALIGN_CTL_FIFO_PERR_SET3)
-#define F_ALIGN_CTL_FIFO_PERR_SET3 V_ALIGN_CTL_FIFO_PERR_SET3(1U)
-
-#define S_ALIGN_CTL_FIFO_PERR_SET2 26
-#define V_ALIGN_CTL_FIFO_PERR_SET2(x) ((x) << S_ALIGN_CTL_FIFO_PERR_SET2)
-#define F_ALIGN_CTL_FIFO_PERR_SET2 V_ALIGN_CTL_FIFO_PERR_SET2(1U)
-
-#define S_ALIGN_CTL_FIFO_PERR_SET1 25
-#define V_ALIGN_CTL_FIFO_PERR_SET1(x) ((x) << S_ALIGN_CTL_FIFO_PERR_SET1)
-#define F_ALIGN_CTL_FIFO_PERR_SET1 V_ALIGN_CTL_FIFO_PERR_SET1(1U)
-
-#define S_ALIGN_CTL_FIFO_PERR_SET0 24
-#define V_ALIGN_CTL_FIFO_PERR_SET0(x) ((x) << S_ALIGN_CTL_FIFO_PERR_SET0)
-#define F_ALIGN_CTL_FIFO_PERR_SET0 V_ALIGN_CTL_FIFO_PERR_SET0(1U)
-
-#define S_SGE_FIFO_PERR_SET3 23
-#define V_SGE_FIFO_PERR_SET3(x) ((x) << S_SGE_FIFO_PERR_SET3)
-#define F_SGE_FIFO_PERR_SET3 V_SGE_FIFO_PERR_SET3(1U)
-
-#define S_SGE_FIFO_PERR_SET2 22
-#define V_SGE_FIFO_PERR_SET2(x) ((x) << S_SGE_FIFO_PERR_SET2)
-#define F_SGE_FIFO_PERR_SET2 V_SGE_FIFO_PERR_SET2(1U)
-
-#define S_SGE_FIFO_PERR_SET1 21
-#define V_SGE_FIFO_PERR_SET1(x) ((x) << S_SGE_FIFO_PERR_SET1)
-#define F_SGE_FIFO_PERR_SET1 V_SGE_FIFO_PERR_SET1(1U)
-
-#define S_SGE_FIFO_PERR_SET0 20
-#define V_SGE_FIFO_PERR_SET0(x) ((x) << S_SGE_FIFO_PERR_SET0)
-#define F_SGE_FIFO_PERR_SET0 V_SGE_FIFO_PERR_SET0(1U)
-
-#define S_STAG_FIFO_PERR_SET3 19
-#define V_STAG_FIFO_PERR_SET3(x) ((x) << S_STAG_FIFO_PERR_SET3)
-#define F_STAG_FIFO_PERR_SET3 V_STAG_FIFO_PERR_SET3(1U)
-
-#define S_STAG_FIFO_PERR_SET2 18
-#define V_STAG_FIFO_PERR_SET2(x) ((x) << S_STAG_FIFO_PERR_SET2)
-#define F_STAG_FIFO_PERR_SET2 V_STAG_FIFO_PERR_SET2(1U)
-
-#define S_STAG_FIFO_PERR_SET1 17
-#define V_STAG_FIFO_PERR_SET1(x) ((x) << S_STAG_FIFO_PERR_SET1)
-#define F_STAG_FIFO_PERR_SET1 V_STAG_FIFO_PERR_SET1(1U)
-
-#define S_STAG_FIFO_PERR_SET0 16
-#define V_STAG_FIFO_PERR_SET0(x) ((x) << S_STAG_FIFO_PERR_SET0)
-#define F_STAG_FIFO_PERR_SET0 V_STAG_FIFO_PERR_SET0(1U)
-
-#define S_MAP_FIFO_PERR_SET3 15
-#define V_MAP_FIFO_PERR_SET3(x) ((x) << S_MAP_FIFO_PERR_SET3)
-#define F_MAP_FIFO_PERR_SET3 V_MAP_FIFO_PERR_SET3(1U)
-
-#define S_MAP_FIFO_PERR_SET2 14
-#define V_MAP_FIFO_PERR_SET2(x) ((x) << S_MAP_FIFO_PERR_SET2)
-#define F_MAP_FIFO_PERR_SET2 V_MAP_FIFO_PERR_SET2(1U)
-
-#define S_MAP_FIFO_PERR_SET1 13
-#define V_MAP_FIFO_PERR_SET1(x) ((x) << S_MAP_FIFO_PERR_SET1)
-#define F_MAP_FIFO_PERR_SET1 V_MAP_FIFO_PERR_SET1(1U)
-
-#define S_MAP_FIFO_PERR_SET0 12
-#define V_MAP_FIFO_PERR_SET0(x) ((x) << S_MAP_FIFO_PERR_SET0)
-#define F_MAP_FIFO_PERR_SET0 V_MAP_FIFO_PERR_SET0(1U)
-
-#define S_DMA_FIFO_PERR_SET3 11
-#define V_DMA_FIFO_PERR_SET3(x) ((x) << S_DMA_FIFO_PERR_SET3)
-#define F_DMA_FIFO_PERR_SET3 V_DMA_FIFO_PERR_SET3(1U)
-
-#define S_DMA_FIFO_PERR_SET2 10
-#define V_DMA_FIFO_PERR_SET2(x) ((x) << S_DMA_FIFO_PERR_SET2)
-#define F_DMA_FIFO_PERR_SET2 V_DMA_FIFO_PERR_SET2(1U)
-
-#define S_DMA_FIFO_PERR_SET1 9
-#define V_DMA_FIFO_PERR_SET1(x) ((x) << S_DMA_FIFO_PERR_SET1)
-#define F_DMA_FIFO_PERR_SET1 V_DMA_FIFO_PERR_SET1(1U)
-
-#define S_DMA_FIFO_PERR_SET0 8
-#define V_DMA_FIFO_PERR_SET0(x) ((x) << S_DMA_FIFO_PERR_SET0)
-#define F_DMA_FIFO_PERR_SET0 V_DMA_FIFO_PERR_SET0(1U)
-
-#define A_ULP_TX_INT_CAUSE_2 0x8e80
-#define A_ULP_TX_PERR_ENABLE_2 0x8e84
-#define A_ULP_TX_SE_CNT_ERR 0x8ea0
-
-#define S_ERR_CH3 12
-#define M_ERR_CH3 0xfU
-#define V_ERR_CH3(x) ((x) << S_ERR_CH3)
-#define G_ERR_CH3(x) (((x) >> S_ERR_CH3) & M_ERR_CH3)
-
-#define S_ERR_CH2 8
-#define M_ERR_CH2 0xfU
-#define V_ERR_CH2(x) ((x) << S_ERR_CH2)
-#define G_ERR_CH2(x) (((x) >> S_ERR_CH2) & M_ERR_CH2)
-
-#define S_ERR_CH1 4
-#define M_ERR_CH1 0xfU
-#define V_ERR_CH1(x) ((x) << S_ERR_CH1)
-#define G_ERR_CH1(x) (((x) >> S_ERR_CH1) & M_ERR_CH1)
-
-#define S_ERR_CH0 0
-#define M_ERR_CH0 0xfU
-#define V_ERR_CH0(x) ((x) << S_ERR_CH0)
-#define G_ERR_CH0(x) (((x) >> S_ERR_CH0) & M_ERR_CH0)
-
-#define A_ULP_TX_T5_SE_CNT_ERR 0x8ea0
-#define A_ULP_TX_SE_CNT_CLR 0x8ea4
-
-#define S_CLR_DROP 16
-#define M_CLR_DROP 0xfU
-#define V_CLR_DROP(x) ((x) << S_CLR_DROP)
-#define G_CLR_DROP(x) (((x) >> S_CLR_DROP) & M_CLR_DROP)
-
-#define S_CLR_CH3 12
-#define M_CLR_CH3 0xfU
-#define V_CLR_CH3(x) ((x) << S_CLR_CH3)
-#define G_CLR_CH3(x) (((x) >> S_CLR_CH3) & M_CLR_CH3)
-
-#define S_CLR_CH2 8
-#define M_CLR_CH2 0xfU
-#define V_CLR_CH2(x) ((x) << S_CLR_CH2)
-#define G_CLR_CH2(x) (((x) >> S_CLR_CH2) & M_CLR_CH2)
-
-#define S_CLR_CH1 4
-#define M_CLR_CH1 0xfU
-#define V_CLR_CH1(x) ((x) << S_CLR_CH1)
-#define G_CLR_CH1(x) (((x) >> S_CLR_CH1) & M_CLR_CH1)
-
-#define S_CLR_CH0 0
-#define M_CLR_CH0 0xfU
-#define V_CLR_CH0(x) ((x) << S_CLR_CH0)
-#define G_CLR_CH0(x) (((x) >> S_CLR_CH0) & M_CLR_CH0)
-
-#define A_ULP_TX_T5_SE_CNT_CLR 0x8ea4
-#define A_ULP_TX_SE_CNT_CH0 0x8ea8
-
-#define S_SOP_CNT_ULP2TP 28
-#define M_SOP_CNT_ULP2TP 0xfU
-#define V_SOP_CNT_ULP2TP(x) ((x) << S_SOP_CNT_ULP2TP)
-#define G_SOP_CNT_ULP2TP(x) (((x) >> S_SOP_CNT_ULP2TP) & M_SOP_CNT_ULP2TP)
-
-#define S_EOP_CNT_ULP2TP 24
-#define M_EOP_CNT_ULP2TP 0xfU
-#define V_EOP_CNT_ULP2TP(x) ((x) << S_EOP_CNT_ULP2TP)
-#define G_EOP_CNT_ULP2TP(x) (((x) >> S_EOP_CNT_ULP2TP) & M_EOP_CNT_ULP2TP)
-
-#define S_SOP_CNT_LSO_IN 20
-#define M_SOP_CNT_LSO_IN 0xfU
-#define V_SOP_CNT_LSO_IN(x) ((x) << S_SOP_CNT_LSO_IN)
-#define G_SOP_CNT_LSO_IN(x) (((x) >> S_SOP_CNT_LSO_IN) & M_SOP_CNT_LSO_IN)
-
-#define S_EOP_CNT_LSO_IN 16
-#define M_EOP_CNT_LSO_IN 0xfU
-#define V_EOP_CNT_LSO_IN(x) ((x) << S_EOP_CNT_LSO_IN)
-#define G_EOP_CNT_LSO_IN(x) (((x) >> S_EOP_CNT_LSO_IN) & M_EOP_CNT_LSO_IN)
-
-#define S_SOP_CNT_ALG_IN 12
-#define M_SOP_CNT_ALG_IN 0xfU
-#define V_SOP_CNT_ALG_IN(x) ((x) << S_SOP_CNT_ALG_IN)
-#define G_SOP_CNT_ALG_IN(x) (((x) >> S_SOP_CNT_ALG_IN) & M_SOP_CNT_ALG_IN)
-
-#define S_EOP_CNT_ALG_IN 8
-#define M_EOP_CNT_ALG_IN 0xfU
-#define V_EOP_CNT_ALG_IN(x) ((x) << S_EOP_CNT_ALG_IN)
-#define G_EOP_CNT_ALG_IN(x) (((x) >> S_EOP_CNT_ALG_IN) & M_EOP_CNT_ALG_IN)
-
-#define S_SOP_CNT_CIM2ULP 4
-#define M_SOP_CNT_CIM2ULP 0xfU
-#define V_SOP_CNT_CIM2ULP(x) ((x) << S_SOP_CNT_CIM2ULP)
-#define G_SOP_CNT_CIM2ULP(x) (((x) >> S_SOP_CNT_CIM2ULP) & M_SOP_CNT_CIM2ULP)
-
-#define S_EOP_CNT_CIM2ULP 0
-#define M_EOP_CNT_CIM2ULP 0xfU
-#define V_EOP_CNT_CIM2ULP(x) ((x) << S_EOP_CNT_CIM2ULP)
-#define G_EOP_CNT_CIM2ULP(x) (((x) >> S_EOP_CNT_CIM2ULP) & M_EOP_CNT_CIM2ULP)
-
-#define A_ULP_TX_T5_SE_CNT_CH0 0x8ea8
-#define A_ULP_TX_SE_CNT_CH1 0x8eac
-#define A_ULP_TX_T5_SE_CNT_CH1 0x8eac
-#define A_ULP_TX_SE_CNT_CH2 0x8eb0
-#define A_ULP_TX_T5_SE_CNT_CH2 0x8eb0
-#define A_ULP_TX_SE_CNT_CH3 0x8eb4
-#define A_ULP_TX_T5_SE_CNT_CH3 0x8eb4
-#define A_ULP_TX_DROP_CNT 0x8eb8
-
-#define S_DROP_CH3 12
-#define M_DROP_CH3 0xfU
-#define V_DROP_CH3(x) ((x) << S_DROP_CH3)
-#define G_DROP_CH3(x) (((x) >> S_DROP_CH3) & M_DROP_CH3)
-
-#define S_DROP_CH2 8
-#define M_DROP_CH2 0xfU
-#define V_DROP_CH2(x) ((x) << S_DROP_CH2)
-#define G_DROP_CH2(x) (((x) >> S_DROP_CH2) & M_DROP_CH2)
-
-#define S_DROP_CH1 4
-#define M_DROP_CH1 0xfU
-#define V_DROP_CH1(x) ((x) << S_DROP_CH1)
-#define G_DROP_CH1(x) (((x) >> S_DROP_CH1) & M_DROP_CH1)
-
-#define S_DROP_CH0 0
-#define M_DROP_CH0 0xfU
-#define V_DROP_CH0(x) ((x) << S_DROP_CH0)
-#define G_DROP_CH0(x) (((x) >> S_DROP_CH0) & M_DROP_CH0)
-
-#define A_ULP_TX_T5_DROP_CNT 0x8eb8
-
-#define S_DROP_INVLD_MC_CH3 28
-#define M_DROP_INVLD_MC_CH3 0xfU
-#define V_DROP_INVLD_MC_CH3(x) ((x) << S_DROP_INVLD_MC_CH3)
-#define G_DROP_INVLD_MC_CH3(x) (((x) >> S_DROP_INVLD_MC_CH3) & M_DROP_INVLD_MC_CH3)
-
-#define S_DROP_INVLD_MC_CH2 24
-#define M_DROP_INVLD_MC_CH2 0xfU
-#define V_DROP_INVLD_MC_CH2(x) ((x) << S_DROP_INVLD_MC_CH2)
-#define G_DROP_INVLD_MC_CH2(x) (((x) >> S_DROP_INVLD_MC_CH2) & M_DROP_INVLD_MC_CH2)
-
-#define S_DROP_INVLD_MC_CH1 20
-#define M_DROP_INVLD_MC_CH1 0xfU
-#define V_DROP_INVLD_MC_CH1(x) ((x) << S_DROP_INVLD_MC_CH1)
-#define G_DROP_INVLD_MC_CH1(x) (((x) >> S_DROP_INVLD_MC_CH1) & M_DROP_INVLD_MC_CH1)
-
-#define S_DROP_INVLD_MC_CH0 16
-#define M_DROP_INVLD_MC_CH0 0xfU
-#define V_DROP_INVLD_MC_CH0(x) ((x) << S_DROP_INVLD_MC_CH0)
-#define G_DROP_INVLD_MC_CH0(x) (((x) >> S_DROP_INVLD_MC_CH0) & M_DROP_INVLD_MC_CH0)
-
-#define A_ULP_TX_CSU_REVISION 0x8ebc
-#define A_ULP_TX_LA_RDPTR_0 0x8ec0
-#define A_ULP_TX_LA_RDDATA_0 0x8ec4
-#define A_ULP_TX_LA_WRPTR_0 0x8ec8
-#define A_ULP_TX_LA_RESERVED_0 0x8ecc
-#define A_ULP_TX_LA_RDPTR_1 0x8ed0
-#define A_ULP_TX_LA_RDDATA_1 0x8ed4
-#define A_ULP_TX_LA_WRPTR_1 0x8ed8
-#define A_ULP_TX_LA_RESERVED_1 0x8edc
-#define A_ULP_TX_LA_RDPTR_2 0x8ee0
-#define A_ULP_TX_LA_RDDATA_2 0x8ee4
-#define A_ULP_TX_LA_WRPTR_2 0x8ee8
-#define A_ULP_TX_LA_RESERVED_2 0x8eec
-#define A_ULP_TX_LA_RDPTR_3 0x8ef0
-#define A_ULP_TX_LA_RDDATA_3 0x8ef4
-#define A_ULP_TX_LA_WRPTR_3 0x8ef8
-#define A_ULP_TX_LA_RESERVED_3 0x8efc
-#define A_ULP_TX_LA_RDPTR_4 0x8f00
-#define A_ULP_TX_LA_RDDATA_4 0x8f04
-#define A_ULP_TX_LA_WRPTR_4 0x8f08
-#define A_ULP_TX_LA_RESERVED_4 0x8f0c
-#define A_ULP_TX_LA_RDPTR_5 0x8f10
-#define A_ULP_TX_LA_RDDATA_5 0x8f14
-#define A_ULP_TX_LA_WRPTR_5 0x8f18
-#define A_ULP_TX_LA_RESERVED_5 0x8f1c
-#define A_ULP_TX_LA_RDPTR_6 0x8f20
-#define A_ULP_TX_LA_RDDATA_6 0x8f24
-#define A_ULP_TX_LA_WRPTR_6 0x8f28
-#define A_ULP_TX_LA_RESERVED_6 0x8f2c
-#define A_ULP_TX_LA_RDPTR_7 0x8f30
-#define A_ULP_TX_LA_RDDATA_7 0x8f34
-#define A_ULP_TX_LA_WRPTR_7 0x8f38
-#define A_ULP_TX_LA_RESERVED_7 0x8f3c
-#define A_ULP_TX_LA_RDPTR_8 0x8f40
-#define A_ULP_TX_LA_RDDATA_8 0x8f44
-#define A_ULP_TX_LA_WRPTR_8 0x8f48
-#define A_ULP_TX_LA_RESERVED_8 0x8f4c
-#define A_ULP_TX_LA_RDPTR_9 0x8f50
-#define A_ULP_TX_LA_RDDATA_9 0x8f54
-#define A_ULP_TX_LA_WRPTR_9 0x8f58
-#define A_ULP_TX_LA_RESERVED_9 0x8f5c
-#define A_ULP_TX_LA_RDPTR_10 0x8f60
-#define A_ULP_TX_LA_RDDATA_10 0x8f64
-#define A_ULP_TX_LA_WRPTR_10 0x8f68
-#define A_ULP_TX_LA_RESERVED_10 0x8f6c
-#define A_ULP_TX_ASIC_DEBUG_CTRL 0x8f70
-
-#define S_LA_WR0 0
-#define V_LA_WR0(x) ((x) << S_LA_WR0)
-#define F_LA_WR0 V_LA_WR0(1U)
-
-#define A_ULP_TX_ASIC_DEBUG_0 0x8f74
-#define A_ULP_TX_ASIC_DEBUG_1 0x8f78
-#define A_ULP_TX_ASIC_DEBUG_2 0x8f7c
-#define A_ULP_TX_ASIC_DEBUG_3 0x8f80
-#define A_ULP_TX_ASIC_DEBUG_4 0x8f84
-#define A_ULP_TX_CPL_TX_DATA_FLAGS_MASK 0x8f88
-
-#define S_BYPASS_FIRST 26
-#define V_BYPASS_FIRST(x) ((x) << S_BYPASS_FIRST)
-#define F_BYPASS_FIRST V_BYPASS_FIRST(1U)
-
-#define S_BYPASS_MIDDLE 25
-#define V_BYPASS_MIDDLE(x) ((x) << S_BYPASS_MIDDLE)
-#define F_BYPASS_MIDDLE V_BYPASS_MIDDLE(1U)
-
-#define S_BYPASS_LAST 24
-#define V_BYPASS_LAST(x) ((x) << S_BYPASS_LAST)
-#define F_BYPASS_LAST V_BYPASS_LAST(1U)
-
-#define S_PUSH_FIRST 22
-#define V_PUSH_FIRST(x) ((x) << S_PUSH_FIRST)
-#define F_PUSH_FIRST V_PUSH_FIRST(1U)
-
-#define S_PUSH_MIDDLE 21
-#define V_PUSH_MIDDLE(x) ((x) << S_PUSH_MIDDLE)
-#define F_PUSH_MIDDLE V_PUSH_MIDDLE(1U)
-
-#define S_PUSH_LAST 20
-#define V_PUSH_LAST(x) ((x) << S_PUSH_LAST)
-#define F_PUSH_LAST V_PUSH_LAST(1U)
-
-#define S_SAVE_FIRST 18
-#define V_SAVE_FIRST(x) ((x) << S_SAVE_FIRST)
-#define F_SAVE_FIRST V_SAVE_FIRST(1U)
-
-#define S_SAVE_MIDDLE 17
-#define V_SAVE_MIDDLE(x) ((x) << S_SAVE_MIDDLE)
-#define F_SAVE_MIDDLE V_SAVE_MIDDLE(1U)
-
-#define S_SAVE_LAST 16
-#define V_SAVE_LAST(x) ((x) << S_SAVE_LAST)
-#define F_SAVE_LAST V_SAVE_LAST(1U)
-
-#define S_FLUSH_FIRST 14
-#define V_FLUSH_FIRST(x) ((x) << S_FLUSH_FIRST)
-#define F_FLUSH_FIRST V_FLUSH_FIRST(1U)
-
-#define S_FLUSH_MIDDLE 13
-#define V_FLUSH_MIDDLE(x) ((x) << S_FLUSH_MIDDLE)
-#define F_FLUSH_MIDDLE V_FLUSH_MIDDLE(1U)
-
-#define S_FLUSH_LAST 12
-#define V_FLUSH_LAST(x) ((x) << S_FLUSH_LAST)
-#define F_FLUSH_LAST V_FLUSH_LAST(1U)
-
-#define S_URGENT_FIRST 10
-#define V_URGENT_FIRST(x) ((x) << S_URGENT_FIRST)
-#define F_URGENT_FIRST V_URGENT_FIRST(1U)
-
-#define S_URGENT_MIDDLE 9
-#define V_URGENT_MIDDLE(x) ((x) << S_URGENT_MIDDLE)
-#define F_URGENT_MIDDLE V_URGENT_MIDDLE(1U)
-
-#define S_URGENT_LAST 8
-#define V_URGENT_LAST(x) ((x) << S_URGENT_LAST)
-#define F_URGENT_LAST V_URGENT_LAST(1U)
-
-#define S_MORE_FIRST 6
-#define V_MORE_FIRST(x) ((x) << S_MORE_FIRST)
-#define F_MORE_FIRST V_MORE_FIRST(1U)
-
-#define S_MORE_MIDDLE 5
-#define V_MORE_MIDDLE(x) ((x) << S_MORE_MIDDLE)
-#define F_MORE_MIDDLE V_MORE_MIDDLE(1U)
-
-#define S_MORE_LAST 4
-#define V_MORE_LAST(x) ((x) << S_MORE_LAST)
-#define F_MORE_LAST V_MORE_LAST(1U)
-
-#define S_SHOVE_FIRST 2
-#define V_SHOVE_FIRST(x) ((x) << S_SHOVE_FIRST)
-#define F_SHOVE_FIRST V_SHOVE_FIRST(1U)
-
-#define S_SHOVE_MIDDLE 1
-#define V_SHOVE_MIDDLE(x) ((x) << S_SHOVE_MIDDLE)
-#define F_SHOVE_MIDDLE V_SHOVE_MIDDLE(1U)
-
-#define S_SHOVE_LAST 0
-#define V_SHOVE_LAST(x) ((x) << S_SHOVE_LAST)
-#define F_SHOVE_LAST V_SHOVE_LAST(1U)
-
-#define A_ULP_TX_TLS_IND_CMD 0x8fb8
-
-#define S_TLS_TX_REG_OFF_ADDR 0
-#define M_TLS_TX_REG_OFF_ADDR 0x3ffU
-#define V_TLS_TX_REG_OFF_ADDR(x) ((x) << S_TLS_TX_REG_OFF_ADDR)
-#define G_TLS_TX_REG_OFF_ADDR(x) (((x) >> S_TLS_TX_REG_OFF_ADDR) & M_TLS_TX_REG_OFF_ADDR)
-
-#define A_ULP_TX_TLS_IND_DATA 0x8fbc
-
-/* registers for module PM_RX */
-#define PM_RX_BASE_ADDR 0x8fc0
-
-#define A_PM_RX_CFG 0x8fc0
-#define A_PM_RX_MODE 0x8fc4
-
-#define S_RX_USE_BUNDLE_LEN 4
-#define V_RX_USE_BUNDLE_LEN(x) ((x) << S_RX_USE_BUNDLE_LEN)
-#define F_RX_USE_BUNDLE_LEN V_RX_USE_BUNDLE_LEN(1U)
-
-#define S_STAT_TO_CH 3
-#define V_STAT_TO_CH(x) ((x) << S_STAT_TO_CH)
-#define F_STAT_TO_CH V_STAT_TO_CH(1U)
-
-#define S_STAT_FROM_CH 1
-#define M_STAT_FROM_CH 0x3U
-#define V_STAT_FROM_CH(x) ((x) << S_STAT_FROM_CH)
-#define G_STAT_FROM_CH(x) (((x) >> S_STAT_FROM_CH) & M_STAT_FROM_CH)
-
-#define S_PREFETCH_ENABLE 0
-#define V_PREFETCH_ENABLE(x) ((x) << S_PREFETCH_ENABLE)
-#define F_PREFETCH_ENABLE V_PREFETCH_ENABLE(1U)
-
-#define A_PM_RX_STAT_CONFIG 0x8fc8
-#define A_PM_RX_STAT_COUNT 0x8fcc
-#define A_PM_RX_STAT_LSB 0x8fd0
-#define A_PM_RX_DBG_CTRL 0x8fd0
-
-#define S_OSPIWRBUSY_T5 21
-#define M_OSPIWRBUSY_T5 0x3U
-#define V_OSPIWRBUSY_T5(x) ((x) << S_OSPIWRBUSY_T5)
-#define G_OSPIWRBUSY_T5(x) (((x) >> S_OSPIWRBUSY_T5) & M_OSPIWRBUSY_T5)
-
-#define S_ISPIWRBUSY 17
-#define M_ISPIWRBUSY 0xfU
-#define V_ISPIWRBUSY(x) ((x) << S_ISPIWRBUSY)
-#define G_ISPIWRBUSY(x) (((x) >> S_ISPIWRBUSY) & M_ISPIWRBUSY)
-
-#define S_PMDBGADDR 0
-#define M_PMDBGADDR 0x1ffffU
-#define V_PMDBGADDR(x) ((x) << S_PMDBGADDR)
-#define G_PMDBGADDR(x) (((x) >> S_PMDBGADDR) & M_PMDBGADDR)
-
-#define A_PM_RX_STAT_MSB 0x8fd4
-#define A_PM_RX_DBG_DATA 0x8fd4
-#define A_PM_RX_INT_ENABLE 0x8fd8
-
-#define S_ZERO_E_CMD_ERROR 22
-#define V_ZERO_E_CMD_ERROR(x) ((x) << S_ZERO_E_CMD_ERROR)
-#define F_ZERO_E_CMD_ERROR V_ZERO_E_CMD_ERROR(1U)
-
-#define S_IESPI0_FIFO2X_RX_FRAMING_ERROR 21
-#define V_IESPI0_FIFO2X_RX_FRAMING_ERROR(x) ((x) << S_IESPI0_FIFO2X_RX_FRAMING_ERROR)
-#define F_IESPI0_FIFO2X_RX_FRAMING_ERROR V_IESPI0_FIFO2X_RX_FRAMING_ERROR(1U)
-
-#define S_IESPI1_FIFO2X_RX_FRAMING_ERROR 20
-#define V_IESPI1_FIFO2X_RX_FRAMING_ERROR(x) ((x) << S_IESPI1_FIFO2X_RX_FRAMING_ERROR)
-#define F_IESPI1_FIFO2X_RX_FRAMING_ERROR V_IESPI1_FIFO2X_RX_FRAMING_ERROR(1U)
-
-#define S_IESPI2_FIFO2X_RX_FRAMING_ERROR 19
-#define V_IESPI2_FIFO2X_RX_FRAMING_ERROR(x) ((x) << S_IESPI2_FIFO2X_RX_FRAMING_ERROR)
-#define F_IESPI2_FIFO2X_RX_FRAMING_ERROR V_IESPI2_FIFO2X_RX_FRAMING_ERROR(1U)
-
-#define S_IESPI3_FIFO2X_RX_FRAMING_ERROR 18
-#define V_IESPI3_FIFO2X_RX_FRAMING_ERROR(x) ((x) << S_IESPI3_FIFO2X_RX_FRAMING_ERROR)
-#define F_IESPI3_FIFO2X_RX_FRAMING_ERROR V_IESPI3_FIFO2X_RX_FRAMING_ERROR(1U)
-
-#define S_IESPI0_RX_FRAMING_ERROR 17
-#define V_IESPI0_RX_FRAMING_ERROR(x) ((x) << S_IESPI0_RX_FRAMING_ERROR)
-#define F_IESPI0_RX_FRAMING_ERROR V_IESPI0_RX_FRAMING_ERROR(1U)
-
-#define S_IESPI1_RX_FRAMING_ERROR 16
-#define V_IESPI1_RX_FRAMING_ERROR(x) ((x) << S_IESPI1_RX_FRAMING_ERROR)
-#define F_IESPI1_RX_FRAMING_ERROR V_IESPI1_RX_FRAMING_ERROR(1U)
-
-#define S_IESPI2_RX_FRAMING_ERROR 15
-#define V_IESPI2_RX_FRAMING_ERROR(x) ((x) << S_IESPI2_RX_FRAMING_ERROR)
-#define F_IESPI2_RX_FRAMING_ERROR V_IESPI2_RX_FRAMING_ERROR(1U)
-
-#define S_IESPI3_RX_FRAMING_ERROR 14
-#define V_IESPI3_RX_FRAMING_ERROR(x) ((x) << S_IESPI3_RX_FRAMING_ERROR)
-#define F_IESPI3_RX_FRAMING_ERROR V_IESPI3_RX_FRAMING_ERROR(1U)
-
-#define S_IESPI0_TX_FRAMING_ERROR 13
-#define V_IESPI0_TX_FRAMING_ERROR(x) ((x) << S_IESPI0_TX_FRAMING_ERROR)
-#define F_IESPI0_TX_FRAMING_ERROR V_IESPI0_TX_FRAMING_ERROR(1U)
-
-#define S_IESPI1_TX_FRAMING_ERROR 12
-#define V_IESPI1_TX_FRAMING_ERROR(x) ((x) << S_IESPI1_TX_FRAMING_ERROR)
-#define F_IESPI1_TX_FRAMING_ERROR V_IESPI1_TX_FRAMING_ERROR(1U)
-
-#define S_IESPI2_TX_FRAMING_ERROR 11
-#define V_IESPI2_TX_FRAMING_ERROR(x) ((x) << S_IESPI2_TX_FRAMING_ERROR)
-#define F_IESPI2_TX_FRAMING_ERROR V_IESPI2_TX_FRAMING_ERROR(1U)
-
-#define S_IESPI3_TX_FRAMING_ERROR 10
-#define V_IESPI3_TX_FRAMING_ERROR(x) ((x) << S_IESPI3_TX_FRAMING_ERROR)
-#define F_IESPI3_TX_FRAMING_ERROR V_IESPI3_TX_FRAMING_ERROR(1U)
-
-#define S_OCSPI0_RX_FRAMING_ERROR 9
-#define V_OCSPI0_RX_FRAMING_ERROR(x) ((x) << S_OCSPI0_RX_FRAMING_ERROR)
-#define F_OCSPI0_RX_FRAMING_ERROR V_OCSPI0_RX_FRAMING_ERROR(1U)
-
-#define S_OCSPI1_RX_FRAMING_ERROR 8
-#define V_OCSPI1_RX_FRAMING_ERROR(x) ((x) << S_OCSPI1_RX_FRAMING_ERROR)
-#define F_OCSPI1_RX_FRAMING_ERROR V_OCSPI1_RX_FRAMING_ERROR(1U)
-
-#define S_OCSPI0_TX_FRAMING_ERROR 7
-#define V_OCSPI0_TX_FRAMING_ERROR(x) ((x) << S_OCSPI0_TX_FRAMING_ERROR)
-#define F_OCSPI0_TX_FRAMING_ERROR V_OCSPI0_TX_FRAMING_ERROR(1U)
-
-#define S_OCSPI1_TX_FRAMING_ERROR 6
-#define V_OCSPI1_TX_FRAMING_ERROR(x) ((x) << S_OCSPI1_TX_FRAMING_ERROR)
-#define F_OCSPI1_TX_FRAMING_ERROR V_OCSPI1_TX_FRAMING_ERROR(1U)
-
-#define S_OCSPI0_OFIFO2X_TX_FRAMING_ERROR 5
-#define V_OCSPI0_OFIFO2X_TX_FRAMING_ERROR(x) ((x) << S_OCSPI0_OFIFO2X_TX_FRAMING_ERROR)
-#define F_OCSPI0_OFIFO2X_TX_FRAMING_ERROR V_OCSPI0_OFIFO2X_TX_FRAMING_ERROR(1U)
-
-#define S_OCSPI1_OFIFO2X_TX_FRAMING_ERROR 4
-#define V_OCSPI1_OFIFO2X_TX_FRAMING_ERROR(x) ((x) << S_OCSPI1_OFIFO2X_TX_FRAMING_ERROR)
-#define F_OCSPI1_OFIFO2X_TX_FRAMING_ERROR V_OCSPI1_OFIFO2X_TX_FRAMING_ERROR(1U)
-
-#define S_OCSPI_PAR_ERROR 3
-#define V_OCSPI_PAR_ERROR(x) ((x) << S_OCSPI_PAR_ERROR)
-#define F_OCSPI_PAR_ERROR V_OCSPI_PAR_ERROR(1U)
-
-#define S_DB_OPTIONS_PAR_ERROR 2
-#define V_DB_OPTIONS_PAR_ERROR(x) ((x) << S_DB_OPTIONS_PAR_ERROR)
-#define F_DB_OPTIONS_PAR_ERROR V_DB_OPTIONS_PAR_ERROR(1U)
-
-#define S_IESPI_PAR_ERROR 1
-#define V_IESPI_PAR_ERROR(x) ((x) << S_IESPI_PAR_ERROR)
-#define F_IESPI_PAR_ERROR V_IESPI_PAR_ERROR(1U)
-
-#define S_E_PCMD_PAR_ERROR 0
-#define V_E_PCMD_PAR_ERROR(x) ((x) << S_E_PCMD_PAR_ERROR)
-#define F_E_PCMD_PAR_ERROR V_E_PCMD_PAR_ERROR(1U)
-
-#define S_OSPI_OVERFLOW1 28
-#define V_OSPI_OVERFLOW1(x) ((x) << S_OSPI_OVERFLOW1)
-#define F_OSPI_OVERFLOW1 V_OSPI_OVERFLOW1(1U)
-
-#define S_OSPI_OVERFLOW0 27
-#define V_OSPI_OVERFLOW0(x) ((x) << S_OSPI_OVERFLOW0)
-#define F_OSPI_OVERFLOW0 V_OSPI_OVERFLOW0(1U)
-
-#define S_MA_INTF_SDC_ERR 26
-#define V_MA_INTF_SDC_ERR(x) ((x) << S_MA_INTF_SDC_ERR)
-#define F_MA_INTF_SDC_ERR V_MA_INTF_SDC_ERR(1U)
-
-#define S_BUNDLE_LEN_PARERR 25
-#define V_BUNDLE_LEN_PARERR(x) ((x) << S_BUNDLE_LEN_PARERR)
-#define F_BUNDLE_LEN_PARERR V_BUNDLE_LEN_PARERR(1U)
-
-#define S_BUNDLE_LEN_OVFL 24
-#define V_BUNDLE_LEN_OVFL(x) ((x) << S_BUNDLE_LEN_OVFL)
-#define F_BUNDLE_LEN_OVFL V_BUNDLE_LEN_OVFL(1U)
-
-#define S_SDC_ERR 23
-#define V_SDC_ERR(x) ((x) << S_SDC_ERR)
-#define F_SDC_ERR V_SDC_ERR(1U)
-
-#define A_PM_RX_INT_CAUSE 0x8fdc
-#define A_PM_RX_ISPI_DBG_4B_DATA0 0x10000
-#define A_PM_RX_ISPI_DBG_4B_DATA1 0x10001
-#define A_PM_RX_ISPI_DBG_4B_DATA2 0x10002
-#define A_PM_RX_ISPI_DBG_4B_DATA3 0x10003
-#define A_PM_RX_ISPI_DBG_4B_DATA4 0x10004
-#define A_PM_RX_ISPI_DBG_4B_DATA5 0x10005
-#define A_PM_RX_ISPI_DBG_4B_DATA6 0x10006
-#define A_PM_RX_ISPI_DBG_4B_DATA7 0x10007
-#define A_PM_RX_ISPI_DBG_4B_DATA8 0x10008
-#define A_PM_RX_OSPI_DBG_4B_DATA0 0x10009
-#define A_PM_RX_OSPI_DBG_4B_DATA1 0x1000a
-#define A_PM_RX_OSPI_DBG_4B_DATA2 0x1000b
-#define A_PM_RX_OSPI_DBG_4B_DATA3 0x1000c
-#define A_PM_RX_OSPI_DBG_4B_DATA4 0x1000d
-#define A_PM_RX_OSPI_DBG_4B_DATA5 0x1000e
-#define A_PM_RX_OSPI_DBG_4B_DATA6 0x1000f
-#define A_PM_RX_OSPI_DBG_4B_DATA7 0x10010
-#define A_PM_RX_OSPI_DBG_4B_DATA8 0x10011
-#define A_PM_RX_OSPI_DBG_4B_DATA9 0x10012
-#define A_PM_RX_DBG_STAT_MSB 0x10013
-#define A_PM_RX_DBG_STAT_LSB 0x10014
-#define A_PM_RX_DBG_RSVD_FLIT_CNT 0x10015
-
-#define S_I_TO_O_PATH_RSVD_FLIT_BACKUP 12
-#define M_I_TO_O_PATH_RSVD_FLIT_BACKUP 0xfU
-#define V_I_TO_O_PATH_RSVD_FLIT_BACKUP(x) ((x) << S_I_TO_O_PATH_RSVD_FLIT_BACKUP)
-#define G_I_TO_O_PATH_RSVD_FLIT_BACKUP(x) (((x) >> S_I_TO_O_PATH_RSVD_FLIT_BACKUP) & M_I_TO_O_PATH_RSVD_FLIT_BACKUP)
-
-#define S_I_TO_O_PATH_RSVD_FLIT 8
-#define M_I_TO_O_PATH_RSVD_FLIT 0xfU
-#define V_I_TO_O_PATH_RSVD_FLIT(x) ((x) << S_I_TO_O_PATH_RSVD_FLIT)
-#define G_I_TO_O_PATH_RSVD_FLIT(x) (((x) >> S_I_TO_O_PATH_RSVD_FLIT) & M_I_TO_O_PATH_RSVD_FLIT)
-
-#define S_PRFCH_RSVD_FLIT 4
-#define M_PRFCH_RSVD_FLIT 0xfU
-#define V_PRFCH_RSVD_FLIT(x) ((x) << S_PRFCH_RSVD_FLIT)
-#define G_PRFCH_RSVD_FLIT(x) (((x) >> S_PRFCH_RSVD_FLIT) & M_PRFCH_RSVD_FLIT)
-
-#define S_OSPI_RSVD_FLIT 0
-#define M_OSPI_RSVD_FLIT 0xfU
-#define V_OSPI_RSVD_FLIT(x) ((x) << S_OSPI_RSVD_FLIT)
-#define G_OSPI_RSVD_FLIT(x) (((x) >> S_OSPI_RSVD_FLIT) & M_OSPI_RSVD_FLIT)
-
-#define A_PM_RX_SDC_EN 0x10016
-
-#define S_SDC_EN 0
-#define V_SDC_EN(x) ((x) << S_SDC_EN)
-#define F_SDC_EN V_SDC_EN(1U)
-
-#define A_PM_RX_INOUT_FIFO_DBG_CHNL_SEL 0x10017
-
-#define S_CHNL_3_SEL 3
-#define V_CHNL_3_SEL(x) ((x) << S_CHNL_3_SEL)
-#define F_CHNL_3_SEL V_CHNL_3_SEL(1U)
-
-#define S_CHNL_2_SEL 2
-#define V_CHNL_2_SEL(x) ((x) << S_CHNL_2_SEL)
-#define F_CHNL_2_SEL V_CHNL_2_SEL(1U)
-
-#define S_CHNL_1_SEL 1
-#define V_CHNL_1_SEL(x) ((x) << S_CHNL_1_SEL)
-#define F_CHNL_1_SEL V_CHNL_1_SEL(1U)
-
-#define S_CHNL_0_SEL 0
-#define V_CHNL_0_SEL(x) ((x) << S_CHNL_0_SEL)
-#define F_CHNL_0_SEL V_CHNL_0_SEL(1U)
-
-#define A_PM_RX_INOUT_FIFO_DBG_WR 0x10018
-
-#define S_O_FIFO_WRITE 3
-#define V_O_FIFO_WRITE(x) ((x) << S_O_FIFO_WRITE)
-#define F_O_FIFO_WRITE V_O_FIFO_WRITE(1U)
-
-#define S_I_FIFO_WRITE 2
-#define V_I_FIFO_WRITE(x) ((x) << S_I_FIFO_WRITE)
-#define F_I_FIFO_WRITE V_I_FIFO_WRITE(1U)
-
-#define S_O_FIFO_READ 1
-#define V_O_FIFO_READ(x) ((x) << S_O_FIFO_READ)
-#define F_O_FIFO_READ V_O_FIFO_READ(1U)
-
-#define S_I_FIFO_READ 0
-#define V_I_FIFO_READ(x) ((x) << S_I_FIFO_READ)
-#define F_I_FIFO_READ V_I_FIFO_READ(1U)
-
-#define A_PM_RX_INPUT_FIFO_STR_FWD_EN 0x10019
-
-#define S_ISPI_STR_FWD_EN 0
-#define V_ISPI_STR_FWD_EN(x) ((x) << S_ISPI_STR_FWD_EN)
-#define F_ISPI_STR_FWD_EN V_ISPI_STR_FWD_EN(1U)
-
-#define A_PM_RX_PRFTCH_ACROSS_BNDLE_EN 0x1001a
-
-#define S_PRFTCH_ACROSS_BNDLE_EN 0
-#define V_PRFTCH_ACROSS_BNDLE_EN(x) ((x) << S_PRFTCH_ACROSS_BNDLE_EN)
-#define F_PRFTCH_ACROSS_BNDLE_EN V_PRFTCH_ACROSS_BNDLE_EN(1U)
-
-#define A_PM_RX_PRFTCH_WRR_ENABLE 0x1001b
-
-#define S_PRFTCH_WRR_ENABLE 0
-#define V_PRFTCH_WRR_ENABLE(x) ((x) << S_PRFTCH_WRR_ENABLE)
-#define F_PRFTCH_WRR_ENABLE V_PRFTCH_WRR_ENABLE(1U)
-
-#define A_PM_RX_PRFTCH_WRR_MAX_DEFICIT_CNT 0x1001c
-
-#define S_CHNL1_MAX_DEFICIT_CNT 16
-#define M_CHNL1_MAX_DEFICIT_CNT 0xffffU
-#define V_CHNL1_MAX_DEFICIT_CNT(x) ((x) << S_CHNL1_MAX_DEFICIT_CNT)
-#define G_CHNL1_MAX_DEFICIT_CNT(x) (((x) >> S_CHNL1_MAX_DEFICIT_CNT) & M_CHNL1_MAX_DEFICIT_CNT)
-
-#define S_CHNL0_MAX_DEFICIT_CNT 0
-#define M_CHNL0_MAX_DEFICIT_CNT 0xffffU
-#define V_CHNL0_MAX_DEFICIT_CNT(x) ((x) << S_CHNL0_MAX_DEFICIT_CNT)
-#define G_CHNL0_MAX_DEFICIT_CNT(x) (((x) >> S_CHNL0_MAX_DEFICIT_CNT) & M_CHNL0_MAX_DEFICIT_CNT)
-
-#define A_PM_RX_FEATURE_EN 0x1001d
-
-#define S_PIO_CH_DEFICIT_CTL_EN_RX 0
-#define V_PIO_CH_DEFICIT_CTL_EN_RX(x) ((x) << S_PIO_CH_DEFICIT_CTL_EN_RX)
-#define F_PIO_CH_DEFICIT_CTL_EN_RX V_PIO_CH_DEFICIT_CTL_EN_RX(1U)
-
-#define A_PM_RX_CH0_OSPI_DEFICIT_THRSHLD 0x1001e
-
-#define S_CH0_OSPI_DEFICIT_THRSHLD 0
-#define M_CH0_OSPI_DEFICIT_THRSHLD 0xfffU
-#define V_CH0_OSPI_DEFICIT_THRSHLD(x) ((x) << S_CH0_OSPI_DEFICIT_THRSHLD)
-#define G_CH0_OSPI_DEFICIT_THRSHLD(x) (((x) >> S_CH0_OSPI_DEFICIT_THRSHLD) & M_CH0_OSPI_DEFICIT_THRSHLD)
-
-#define A_PM_RX_CH1_OSPI_DEFICIT_THRSHLD 0x1001f
-
-#define S_CH1_OSPI_DEFICIT_THRSHLD 0
-#define M_CH1_OSPI_DEFICIT_THRSHLD 0xfffU
-#define V_CH1_OSPI_DEFICIT_THRSHLD(x) ((x) << S_CH1_OSPI_DEFICIT_THRSHLD)
-#define G_CH1_OSPI_DEFICIT_THRSHLD(x) (((x) >> S_CH1_OSPI_DEFICIT_THRSHLD) & M_CH1_OSPI_DEFICIT_THRSHLD)
-
-#define A_PM_RX_INT_CAUSE_MASK_HALT 0x10020
-#define A_PM_RX_DBG_STAT0 0x10021
-
-#define S_RX_RD_I_BUSY 29
-#define V_RX_RD_I_BUSY(x) ((x) << S_RX_RD_I_BUSY)
-#define F_RX_RD_I_BUSY V_RX_RD_I_BUSY(1U)
-
-#define S_RX_WR_TO_O_BUSY 28
-#define V_RX_WR_TO_O_BUSY(x) ((x) << S_RX_WR_TO_O_BUSY)
-#define F_RX_WR_TO_O_BUSY V_RX_WR_TO_O_BUSY(1U)
-
-#define S_RX_M_TO_O_BUSY 27
-#define V_RX_M_TO_O_BUSY(x) ((x) << S_RX_M_TO_O_BUSY)
-#define F_RX_M_TO_O_BUSY V_RX_M_TO_O_BUSY(1U)
-
-#define S_RX_I_TO_M_BUSY 26
-#define V_RX_I_TO_M_BUSY(x) ((x) << S_RX_I_TO_M_BUSY)
-#define F_RX_I_TO_M_BUSY V_RX_I_TO_M_BUSY(1U)
-
-#define S_RX_PCMD_FB_ONLY 25
-#define V_RX_PCMD_FB_ONLY(x) ((x) << S_RX_PCMD_FB_ONLY)
-#define F_RX_PCMD_FB_ONLY V_RX_PCMD_FB_ONLY(1U)
-
-#define S_RX_PCMD_MEM 24
-#define V_RX_PCMD_MEM(x) ((x) << S_RX_PCMD_MEM)
-#define F_RX_PCMD_MEM V_RX_PCMD_MEM(1U)
-
-#define S_RX_PCMD_BYPASS 23
-#define V_RX_PCMD_BYPASS(x) ((x) << S_RX_PCMD_BYPASS)
-#define F_RX_PCMD_BYPASS V_RX_PCMD_BYPASS(1U)
-
-#define S_RX_PCMD_EOP 22
-#define V_RX_PCMD_EOP(x) ((x) << S_RX_PCMD_EOP)
-#define F_RX_PCMD_EOP V_RX_PCMD_EOP(1U)
-
-#define S_RX_DUMPLICATE_PCMD_EOP 21
-#define V_RX_DUMPLICATE_PCMD_EOP(x) ((x) << S_RX_DUMPLICATE_PCMD_EOP)
-#define F_RX_DUMPLICATE_PCMD_EOP V_RX_DUMPLICATE_PCMD_EOP(1U)
-
-#define S_RX_PCMD_EOB 20
-#define V_RX_PCMD_EOB(x) ((x) << S_RX_PCMD_EOB)
-#define F_RX_PCMD_EOB V_RX_PCMD_EOB(1U)
-
-#define S_RX_PCMD_FB 16
-#define M_RX_PCMD_FB 0xfU
-#define V_RX_PCMD_FB(x) ((x) << S_RX_PCMD_FB)
-#define G_RX_PCMD_FB(x) (((x) >> S_RX_PCMD_FB) & M_RX_PCMD_FB)
-
-#define S_RX_PCMD_LEN 0
-#define M_RX_PCMD_LEN 0xffffU
-#define V_RX_PCMD_LEN(x) ((x) << S_RX_PCMD_LEN)
-#define G_RX_PCMD_LEN(x) (((x) >> S_RX_PCMD_LEN) & M_RX_PCMD_LEN)
-
-#define A_PM_RX_DBG_STAT1 0x10022
-
-#define S_RX_PCMD0_MEM 30
-#define V_RX_PCMD0_MEM(x) ((x) << S_RX_PCMD0_MEM)
-#define F_RX_PCMD0_MEM V_RX_PCMD0_MEM(1U)
-
-#define S_RX_FREE_OSPI_CNT0 18
-#define M_RX_FREE_OSPI_CNT0 0xfffU
-#define V_RX_FREE_OSPI_CNT0(x) ((x) << S_RX_FREE_OSPI_CNT0)
-#define G_RX_FREE_OSPI_CNT0(x) (((x) >> S_RX_FREE_OSPI_CNT0) & M_RX_FREE_OSPI_CNT0)
-
-#define S_RX_PCMD0_FLIT_LEN 6
-#define M_RX_PCMD0_FLIT_LEN 0xfffU
-#define V_RX_PCMD0_FLIT_LEN(x) ((x) << S_RX_PCMD0_FLIT_LEN)
-#define G_RX_PCMD0_FLIT_LEN(x) (((x) >> S_RX_PCMD0_FLIT_LEN) & M_RX_PCMD0_FLIT_LEN)
-
-#define S_RX_PCMD0_CMD 2
-#define M_RX_PCMD0_CMD 0xfU
-#define V_RX_PCMD0_CMD(x) ((x) << S_RX_PCMD0_CMD)
-#define G_RX_PCMD0_CMD(x) (((x) >> S_RX_PCMD0_CMD) & M_RX_PCMD0_CMD)
-
-#define S_RX_OFIFO_FULL0 1
-#define V_RX_OFIFO_FULL0(x) ((x) << S_RX_OFIFO_FULL0)
-#define F_RX_OFIFO_FULL0 V_RX_OFIFO_FULL0(1U)
-
-#define S_RX_PCMD0_BYPASS 0
-#define V_RX_PCMD0_BYPASS(x) ((x) << S_RX_PCMD0_BYPASS)
-#define F_RX_PCMD0_BYPASS V_RX_PCMD0_BYPASS(1U)
-
-#define A_PM_RX_DBG_STAT2 0x10023
-
-#define S_RX_PCMD1_MEM 30
-#define V_RX_PCMD1_MEM(x) ((x) << S_RX_PCMD1_MEM)
-#define F_RX_PCMD1_MEM V_RX_PCMD1_MEM(1U)
-
-#define S_RX_FREE_OSPI_CNT1 18
-#define M_RX_FREE_OSPI_CNT1 0xfffU
-#define V_RX_FREE_OSPI_CNT1(x) ((x) << S_RX_FREE_OSPI_CNT1)
-#define G_RX_FREE_OSPI_CNT1(x) (((x) >> S_RX_FREE_OSPI_CNT1) & M_RX_FREE_OSPI_CNT1)
-
-#define S_RX_PCMD1_FLIT_LEN 6
-#define M_RX_PCMD1_FLIT_LEN 0xfffU
-#define V_RX_PCMD1_FLIT_LEN(x) ((x) << S_RX_PCMD1_FLIT_LEN)
-#define G_RX_PCMD1_FLIT_LEN(x) (((x) >> S_RX_PCMD1_FLIT_LEN) & M_RX_PCMD1_FLIT_LEN)
-
-#define S_RX_PCMD1_CMD 2
-#define M_RX_PCMD1_CMD 0xfU
-#define V_RX_PCMD1_CMD(x) ((x) << S_RX_PCMD1_CMD)
-#define G_RX_PCMD1_CMD(x) (((x) >> S_RX_PCMD1_CMD) & M_RX_PCMD1_CMD)
-
-#define S_RX_OFIFO_FULL1 1
-#define V_RX_OFIFO_FULL1(x) ((x) << S_RX_OFIFO_FULL1)
-#define F_RX_OFIFO_FULL1 V_RX_OFIFO_FULL1(1U)
-
-#define S_RX_PCMD1_BYPASS 0
-#define V_RX_PCMD1_BYPASS(x) ((x) << S_RX_PCMD1_BYPASS)
-#define F_RX_PCMD1_BYPASS V_RX_PCMD1_BYPASS(1U)
-
-#define A_PM_RX_DBG_STAT3 0x10024
-
-#define S_RX_SET_PCMD_RES_RDY_RD 10
-#define M_RX_SET_PCMD_RES_RDY_RD 0x3U
-#define V_RX_SET_PCMD_RES_RDY_RD(x) ((x) << S_RX_SET_PCMD_RES_RDY_RD)
-#define G_RX_SET_PCMD_RES_RDY_RD(x) (((x) >> S_RX_SET_PCMD_RES_RDY_RD) & M_RX_SET_PCMD_RES_RDY_RD)
-
-#define S_RX_ISSUED_PREFETCH_RD_E_CLR 8
-#define M_RX_ISSUED_PREFETCH_RD_E_CLR 0x3U
-#define V_RX_ISSUED_PREFETCH_RD_E_CLR(x) ((x) << S_RX_ISSUED_PREFETCH_RD_E_CLR)
-#define G_RX_ISSUED_PREFETCH_RD_E_CLR(x) (((x) >> S_RX_ISSUED_PREFETCH_RD_E_CLR) & M_RX_ISSUED_PREFETCH_RD_E_CLR)
-
-#define S_RX_ISSUED_PREFETCH_RD 6
-#define M_RX_ISSUED_PREFETCH_RD 0x3U
-#define V_RX_ISSUED_PREFETCH_RD(x) ((x) << S_RX_ISSUED_PREFETCH_RD)
-#define G_RX_ISSUED_PREFETCH_RD(x) (((x) >> S_RX_ISSUED_PREFETCH_RD) & M_RX_ISSUED_PREFETCH_RD)
-
-#define S_RX_PCMD_RES_RDY 4
-#define M_RX_PCMD_RES_RDY 0x3U
-#define V_RX_PCMD_RES_RDY(x) ((x) << S_RX_PCMD_RES_RDY)
-#define G_RX_PCMD_RES_RDY(x) (((x) >> S_RX_PCMD_RES_RDY) & M_RX_PCMD_RES_RDY)
-
-#define S_RX_DB_VLD 3
-#define V_RX_DB_VLD(x) ((x) << S_RX_DB_VLD)
-#define F_RX_DB_VLD V_RX_DB_VLD(1U)
-
-#define S_RX_FIRST_BUNDLE 1
-#define M_RX_FIRST_BUNDLE 0x3U
-#define V_RX_FIRST_BUNDLE(x) ((x) << S_RX_FIRST_BUNDLE)
-#define G_RX_FIRST_BUNDLE(x) (((x) >> S_RX_FIRST_BUNDLE) & M_RX_FIRST_BUNDLE)
-
-#define S_RX_SDC_DRDY 0
-#define V_RX_SDC_DRDY(x) ((x) << S_RX_SDC_DRDY)
-#define F_RX_SDC_DRDY V_RX_SDC_DRDY(1U)
-
-#define A_PM_RX_DBG_STAT4 0x10025
-
-#define S_RX_PCMD_VLD 26
-#define V_RX_PCMD_VLD(x) ((x) << S_RX_PCMD_VLD)
-#define F_RX_PCMD_VLD V_RX_PCMD_VLD(1U)
-
-#define S_RX_PCMD_TO_CH 25
-#define V_RX_PCMD_TO_CH(x) ((x) << S_RX_PCMD_TO_CH)
-#define F_RX_PCMD_TO_CH V_RX_PCMD_TO_CH(1U)
-
-#define S_RX_PCMD_FROM_CH 23
-#define M_RX_PCMD_FROM_CH 0x3U
-#define V_RX_PCMD_FROM_CH(x) ((x) << S_RX_PCMD_FROM_CH)
-#define G_RX_PCMD_FROM_CH(x) (((x) >> S_RX_PCMD_FROM_CH) & M_RX_PCMD_FROM_CH)
-
-#define S_RX_LINE 18
-#define M_RX_LINE 0x1fU
-#define V_RX_LINE(x) ((x) << S_RX_LINE)
-#define G_RX_LINE(x) (((x) >> S_RX_LINE) & M_RX_LINE)
-
-#define S_RX_IESPI_TXVALID 14
-#define M_RX_IESPI_TXVALID 0xfU
-#define V_RX_IESPI_TXVALID(x) ((x) << S_RX_IESPI_TXVALID)
-#define G_RX_IESPI_TXVALID(x) (((x) >> S_RX_IESPI_TXVALID) & M_RX_IESPI_TXVALID)
-
-#define S_RX_IESPI_TXFULL 10
-#define M_RX_IESPI_TXFULL 0xfU
-#define V_RX_IESPI_TXFULL(x) ((x) << S_RX_IESPI_TXFULL)
-#define G_RX_IESPI_TXFULL(x) (((x) >> S_RX_IESPI_TXFULL) & M_RX_IESPI_TXFULL)
-
-#define S_RX_PCMD_SRDY 8
-#define M_RX_PCMD_SRDY 0x3U
-#define V_RX_PCMD_SRDY(x) ((x) << S_RX_PCMD_SRDY)
-#define G_RX_PCMD_SRDY(x) (((x) >> S_RX_PCMD_SRDY) & M_RX_PCMD_SRDY)
-
-#define S_RX_PCMD_DRDY 6
-#define M_RX_PCMD_DRDY 0x3U
-#define V_RX_PCMD_DRDY(x) ((x) << S_RX_PCMD_DRDY)
-#define G_RX_PCMD_DRDY(x) (((x) >> S_RX_PCMD_DRDY) & M_RX_PCMD_DRDY)
-
-#define S_RX_PCMD_CMD 2
-#define M_RX_PCMD_CMD 0xfU
-#define V_RX_PCMD_CMD(x) ((x) << S_RX_PCMD_CMD)
-#define G_RX_PCMD_CMD(x) (((x) >> S_RX_PCMD_CMD) & M_RX_PCMD_CMD)
-
-#define S_DUPLICATE 0
-#define M_DUPLICATE 0x3U
-#define V_DUPLICATE(x) ((x) << S_DUPLICATE)
-#define G_DUPLICATE(x) (((x) >> S_DUPLICATE) & M_DUPLICATE)
-
-#define S_RX_PCMD_SRDY_STAT4 8
-#define M_RX_PCMD_SRDY_STAT4 0x3U
-#define V_RX_PCMD_SRDY_STAT4(x) ((x) << S_RX_PCMD_SRDY_STAT4)
-#define G_RX_PCMD_SRDY_STAT4(x) (((x) >> S_RX_PCMD_SRDY_STAT4) & M_RX_PCMD_SRDY_STAT4)
-
-#define S_RX_PCMD_DRDY_STAT4 6
-#define M_RX_PCMD_DRDY_STAT4 0x3U
-#define V_RX_PCMD_DRDY_STAT4(x) ((x) << S_RX_PCMD_DRDY_STAT4)
-#define G_RX_PCMD_DRDY_STAT4(x) (((x) >> S_RX_PCMD_DRDY_STAT4) & M_RX_PCMD_DRDY_STAT4)
-
-#define A_PM_RX_DBG_STAT5 0x10026
-
-#define S_RX_ATLST_1_PCMD_CH1 29
-#define V_RX_ATLST_1_PCMD_CH1(x) ((x) << S_RX_ATLST_1_PCMD_CH1)
-#define F_RX_ATLST_1_PCMD_CH1 V_RX_ATLST_1_PCMD_CH1(1U)
-
-#define S_RX_ATLST_1_PCMD_CH0 28
-#define V_RX_ATLST_1_PCMD_CH0(x) ((x) << S_RX_ATLST_1_PCMD_CH0)
-#define F_RX_ATLST_1_PCMD_CH0 V_RX_ATLST_1_PCMD_CH0(1U)
-
-#define S_T5_RX_PCMD_DRDY 26
-#define M_T5_RX_PCMD_DRDY 0x3U
-#define V_T5_RX_PCMD_DRDY(x) ((x) << S_T5_RX_PCMD_DRDY)
-#define G_T5_RX_PCMD_DRDY(x) (((x) >> S_T5_RX_PCMD_DRDY) & M_T5_RX_PCMD_DRDY)
-
-#define S_T5_RX_PCMD_SRDY 24
-#define M_T5_RX_PCMD_SRDY 0x3U
-#define V_T5_RX_PCMD_SRDY(x) ((x) << S_T5_RX_PCMD_SRDY)
-#define G_T5_RX_PCMD_SRDY(x) (((x) >> S_T5_RX_PCMD_SRDY) & M_T5_RX_PCMD_SRDY)
-
-#define S_RX_ISPI_TXVALID 20
-#define M_RX_ISPI_TXVALID 0xfU
-#define V_RX_ISPI_TXVALID(x) ((x) << S_RX_ISPI_TXVALID)
-#define G_RX_ISPI_TXVALID(x) (((x) >> S_RX_ISPI_TXVALID) & M_RX_ISPI_TXVALID)
-
-#define S_RX_ISPI_FULL 16
-#define M_RX_ISPI_FULL 0xfU
-#define V_RX_ISPI_FULL(x) ((x) << S_RX_ISPI_FULL)
-#define G_RX_ISPI_FULL(x) (((x) >> S_RX_ISPI_FULL) & M_RX_ISPI_FULL)
-
-#define S_RX_OSPI_TXVALID 14
-#define M_RX_OSPI_TXVALID 0x3U
-#define V_RX_OSPI_TXVALID(x) ((x) << S_RX_OSPI_TXVALID)
-#define G_RX_OSPI_TXVALID(x) (((x) >> S_RX_OSPI_TXVALID) & M_RX_OSPI_TXVALID)
-
-#define S_RX_OSPI_FULL 12
-#define M_RX_OSPI_FULL 0x3U
-#define V_RX_OSPI_FULL(x) ((x) << S_RX_OSPI_FULL)
-#define G_RX_OSPI_FULL(x) (((x) >> S_RX_OSPI_FULL) & M_RX_OSPI_FULL)
-
-#define S_RX_E_RXVALID 8
-#define M_RX_E_RXVALID 0xfU
-#define V_RX_E_RXVALID(x) ((x) << S_RX_E_RXVALID)
-#define G_RX_E_RXVALID(x) (((x) >> S_RX_E_RXVALID) & M_RX_E_RXVALID)
-
-#define S_RX_E_RXAFULL 4
-#define M_RX_E_RXAFULL 0xfU
-#define V_RX_E_RXAFULL(x) ((x) << S_RX_E_RXAFULL)
-#define G_RX_E_RXAFULL(x) (((x) >> S_RX_E_RXAFULL) & M_RX_E_RXAFULL)
-
-#define S_RX_C_TXVALID 2
-#define M_RX_C_TXVALID 0x3U
-#define V_RX_C_TXVALID(x) ((x) << S_RX_C_TXVALID)
-#define G_RX_C_TXVALID(x) (((x) >> S_RX_C_TXVALID) & M_RX_C_TXVALID)
-
-#define S_RX_C_TXAFULL 0
-#define M_RX_C_TXAFULL 0x3U
-#define V_RX_C_TXAFULL(x) ((x) << S_RX_C_TXAFULL)
-#define G_RX_C_TXAFULL(x) (((x) >> S_RX_C_TXAFULL) & M_RX_C_TXAFULL)
-
-#define S_T6_RX_PCMD_DRDY 26
-#define M_T6_RX_PCMD_DRDY 0x3U
-#define V_T6_RX_PCMD_DRDY(x) ((x) << S_T6_RX_PCMD_DRDY)
-#define G_T6_RX_PCMD_DRDY(x) (((x) >> S_T6_RX_PCMD_DRDY) & M_T6_RX_PCMD_DRDY)
-
-#define S_T6_RX_PCMD_SRDY 24
-#define M_T6_RX_PCMD_SRDY 0x3U
-#define V_T6_RX_PCMD_SRDY(x) ((x) << S_T6_RX_PCMD_SRDY)
-#define G_T6_RX_PCMD_SRDY(x) (((x) >> S_T6_RX_PCMD_SRDY) & M_T6_RX_PCMD_SRDY)
-
-#define A_PM_RX_DBG_STAT6 0x10027
-
-#define S_RX_M_INTRNL_FIFO_CNT 4
-#define M_RX_M_INTRNL_FIFO_CNT 0x3U
-#define V_RX_M_INTRNL_FIFO_CNT(x) ((x) << S_RX_M_INTRNL_FIFO_CNT)
-#define G_RX_M_INTRNL_FIFO_CNT(x) (((x) >> S_RX_M_INTRNL_FIFO_CNT) & M_RX_M_INTRNL_FIFO_CNT)
-
-#define S_RX_M_REQADDRRDY 3
-#define V_RX_M_REQADDRRDY(x) ((x) << S_RX_M_REQADDRRDY)
-#define F_RX_M_REQADDRRDY V_RX_M_REQADDRRDY(1U)
-
-#define S_RX_M_REQWRITE 2
-#define V_RX_M_REQWRITE(x) ((x) << S_RX_M_REQWRITE)
-#define F_RX_M_REQWRITE V_RX_M_REQWRITE(1U)
-
-#define S_RX_M_REQDATAVLD 1
-#define V_RX_M_REQDATAVLD(x) ((x) << S_RX_M_REQDATAVLD)
-#define F_RX_M_REQDATAVLD V_RX_M_REQDATAVLD(1U)
-
-#define S_RX_M_REQDATARDY 0
-#define V_RX_M_REQDATARDY(x) ((x) << S_RX_M_REQDATARDY)
-#define F_RX_M_REQDATARDY V_RX_M_REQDATARDY(1U)
-
-#define S_T6_RX_M_INTRNL_FIFO_CNT 7
-#define M_T6_RX_M_INTRNL_FIFO_CNT 0x3U
-#define V_T6_RX_M_INTRNL_FIFO_CNT(x) ((x) << S_T6_RX_M_INTRNL_FIFO_CNT)
-#define G_T6_RX_M_INTRNL_FIFO_CNT(x) (((x) >> S_T6_RX_M_INTRNL_FIFO_CNT) & M_T6_RX_M_INTRNL_FIFO_CNT)
-
-#define S_RX_M_RSPVLD 6
-#define V_RX_M_RSPVLD(x) ((x) << S_RX_M_RSPVLD)
-#define F_RX_M_RSPVLD V_RX_M_RSPVLD(1U)
-
-#define S_RX_M_RSPRDY 5
-#define V_RX_M_RSPRDY(x) ((x) << S_RX_M_RSPRDY)
-#define F_RX_M_RSPRDY V_RX_M_RSPRDY(1U)
-
-#define S_RX_M_REQADDRVLD 4
-#define V_RX_M_REQADDRVLD(x) ((x) << S_RX_M_REQADDRVLD)
-#define F_RX_M_REQADDRVLD V_RX_M_REQADDRVLD(1U)
-
-#define A_PM_RX_DBG_STAT7 0x10028
-
-#define S_RX_PCMD1_FREE_CNT 7
-#define M_RX_PCMD1_FREE_CNT 0x7fU
-#define V_RX_PCMD1_FREE_CNT(x) ((x) << S_RX_PCMD1_FREE_CNT)
-#define G_RX_PCMD1_FREE_CNT(x) (((x) >> S_RX_PCMD1_FREE_CNT) & M_RX_PCMD1_FREE_CNT)
-
-#define S_RX_PCMD0_FREE_CNT 0
-#define M_RX_PCMD0_FREE_CNT 0x7fU
-#define V_RX_PCMD0_FREE_CNT(x) ((x) << S_RX_PCMD0_FREE_CNT)
-#define G_RX_PCMD0_FREE_CNT(x) (((x) >> S_RX_PCMD0_FREE_CNT) & M_RX_PCMD0_FREE_CNT)
-
-#define A_PM_RX_DBG_STAT8 0x10029
-
-#define S_RX_IN_EOP_CNT3 28
-#define M_RX_IN_EOP_CNT3 0xfU
-#define V_RX_IN_EOP_CNT3(x) ((x) << S_RX_IN_EOP_CNT3)
-#define G_RX_IN_EOP_CNT3(x) (((x) >> S_RX_IN_EOP_CNT3) & M_RX_IN_EOP_CNT3)
-
-#define S_RX_IN_EOP_CNT2 24
-#define M_RX_IN_EOP_CNT2 0xfU
-#define V_RX_IN_EOP_CNT2(x) ((x) << S_RX_IN_EOP_CNT2)
-#define G_RX_IN_EOP_CNT2(x) (((x) >> S_RX_IN_EOP_CNT2) & M_RX_IN_EOP_CNT2)
-
-#define S_RX_IN_EOP_CNT1 20
-#define M_RX_IN_EOP_CNT1 0xfU
-#define V_RX_IN_EOP_CNT1(x) ((x) << S_RX_IN_EOP_CNT1)
-#define G_RX_IN_EOP_CNT1(x) (((x) >> S_RX_IN_EOP_CNT1) & M_RX_IN_EOP_CNT1)
-
-#define S_RX_IN_EOP_CNT0 16
-#define M_RX_IN_EOP_CNT0 0xfU
-#define V_RX_IN_EOP_CNT0(x) ((x) << S_RX_IN_EOP_CNT0)
-#define G_RX_IN_EOP_CNT0(x) (((x) >> S_RX_IN_EOP_CNT0) & M_RX_IN_EOP_CNT0)
-
-#define S_RX_IN_SOP_CNT3 12
-#define M_RX_IN_SOP_CNT3 0xfU
-#define V_RX_IN_SOP_CNT3(x) ((x) << S_RX_IN_SOP_CNT3)
-#define G_RX_IN_SOP_CNT3(x) (((x) >> S_RX_IN_SOP_CNT3) & M_RX_IN_SOP_CNT3)
-
-#define S_RX_IN_SOP_CNT2 8
-#define M_RX_IN_SOP_CNT2 0xfU
-#define V_RX_IN_SOP_CNT2(x) ((x) << S_RX_IN_SOP_CNT2)
-#define G_RX_IN_SOP_CNT2(x) (((x) >> S_RX_IN_SOP_CNT2) & M_RX_IN_SOP_CNT2)
-
-#define S_RX_IN_SOP_CNT1 4
-#define M_RX_IN_SOP_CNT1 0xfU
-#define V_RX_IN_SOP_CNT1(x) ((x) << S_RX_IN_SOP_CNT1)
-#define G_RX_IN_SOP_CNT1(x) (((x) >> S_RX_IN_SOP_CNT1) & M_RX_IN_SOP_CNT1)
-
-#define S_RX_IN_SOP_CNT0 0
-#define M_RX_IN_SOP_CNT0 0xfU
-#define V_RX_IN_SOP_CNT0(x) ((x) << S_RX_IN_SOP_CNT0)
-#define G_RX_IN_SOP_CNT0(x) (((x) >> S_RX_IN_SOP_CNT0) & M_RX_IN_SOP_CNT0)
-
-#define A_PM_RX_DBG_STAT9 0x1002a
-
-#define S_RX_RSVD0 28
-#define M_RX_RSVD0 0xfU
-#define V_RX_RSVD0(x) ((x) << S_RX_RSVD0)
-#define G_RX_RSVD0(x) (((x) >> S_RX_RSVD0) & M_RX_RSVD0)
-
-#define S_RX_RSVD1 24
-#define M_RX_RSVD1 0xfU
-#define V_RX_RSVD1(x) ((x) << S_RX_RSVD1)
-#define G_RX_RSVD1(x) (((x) >> S_RX_RSVD1) & M_RX_RSVD1)
-
-#define S_RX_OUT_EOP_CNT1 20
-#define M_RX_OUT_EOP_CNT1 0xfU
-#define V_RX_OUT_EOP_CNT1(x) ((x) << S_RX_OUT_EOP_CNT1)
-#define G_RX_OUT_EOP_CNT1(x) (((x) >> S_RX_OUT_EOP_CNT1) & M_RX_OUT_EOP_CNT1)
-
-#define S_RX_OUT_EOP_CNT0 16
-#define M_RX_OUT_EOP_CNT0 0xfU
-#define V_RX_OUT_EOP_CNT0(x) ((x) << S_RX_OUT_EOP_CNT0)
-#define G_RX_OUT_EOP_CNT0(x) (((x) >> S_RX_OUT_EOP_CNT0) & M_RX_OUT_EOP_CNT0)
-
-#define S_RX_RSVD2 12
-#define M_RX_RSVD2 0xfU
-#define V_RX_RSVD2(x) ((x) << S_RX_RSVD2)
-#define G_RX_RSVD2(x) (((x) >> S_RX_RSVD2) & M_RX_RSVD2)
-
-#define S_RX_RSVD3 8
-#define M_RX_RSVD3 0xfU
-#define V_RX_RSVD3(x) ((x) << S_RX_RSVD3)
-#define G_RX_RSVD3(x) (((x) >> S_RX_RSVD3) & M_RX_RSVD3)
-
-#define S_RX_OUT_SOP_CNT1 4
-#define M_RX_OUT_SOP_CNT1 0xfU
-#define V_RX_OUT_SOP_CNT1(x) ((x) << S_RX_OUT_SOP_CNT1)
-#define G_RX_OUT_SOP_CNT1(x) (((x) >> S_RX_OUT_SOP_CNT1) & M_RX_OUT_SOP_CNT1)
-
-#define S_RX_OUT_SOP_CNT0 0
-#define M_RX_OUT_SOP_CNT0 0xfU
-#define V_RX_OUT_SOP_CNT0(x) ((x) << S_RX_OUT_SOP_CNT0)
-#define G_RX_OUT_SOP_CNT0(x) (((x) >> S_RX_OUT_SOP_CNT0) & M_RX_OUT_SOP_CNT0)
-
-#define A_PM_RX_DBG_STAT10 0x1002b
-
-#define S_RX_CH_DEFICIT_BLOWED 24
-#define V_RX_CH_DEFICIT_BLOWED(x) ((x) << S_RX_CH_DEFICIT_BLOWED)
-#define F_RX_CH_DEFICIT_BLOWED V_RX_CH_DEFICIT_BLOWED(1U)
-
-#define S_RX_CH1_DEFICIT 12
-#define M_RX_CH1_DEFICIT 0xfffU
-#define V_RX_CH1_DEFICIT(x) ((x) << S_RX_CH1_DEFICIT)
-#define G_RX_CH1_DEFICIT(x) (((x) >> S_RX_CH1_DEFICIT) & M_RX_CH1_DEFICIT)
-
-#define S_RX_CH0_DEFICIT 0
-#define M_RX_CH0_DEFICIT 0xfffU
-#define V_RX_CH0_DEFICIT(x) ((x) << S_RX_CH0_DEFICIT)
-#define G_RX_CH0_DEFICIT(x) (((x) >> S_RX_CH0_DEFICIT) & M_RX_CH0_DEFICIT)
-
-#define A_PM_RX_DBG_STAT11 0x1002c
-
-#define S_RX_BUNDLE_LEN_SRDY 30
-#define M_RX_BUNDLE_LEN_SRDY 0x3U
-#define V_RX_BUNDLE_LEN_SRDY(x) ((x) << S_RX_BUNDLE_LEN_SRDY)
-#define G_RX_BUNDLE_LEN_SRDY(x) (((x) >> S_RX_BUNDLE_LEN_SRDY) & M_RX_BUNDLE_LEN_SRDY)
-
-#define S_RX_RSVD11_1 28
-#define M_RX_RSVD11_1 0x3U
-#define V_RX_RSVD11_1(x) ((x) << S_RX_RSVD11_1)
-#define G_RX_RSVD11_1(x) (((x) >> S_RX_RSVD11_1) & M_RX_RSVD11_1)
-
-#define S_RX_BUNDLE_LEN1 16
-#define M_RX_BUNDLE_LEN1 0xfffU
-#define V_RX_BUNDLE_LEN1(x) ((x) << S_RX_BUNDLE_LEN1)
-#define G_RX_BUNDLE_LEN1(x) (((x) >> S_RX_BUNDLE_LEN1) & M_RX_BUNDLE_LEN1)
-
-#define S_RX_RSVD11 12
-#define M_RX_RSVD11 0xfU
-#define V_RX_RSVD11(x) ((x) << S_RX_RSVD11)
-#define G_RX_RSVD11(x) (((x) >> S_RX_RSVD11) & M_RX_RSVD11)
-
-#define S_RX_BUNDLE_LEN0 0
-#define M_RX_BUNDLE_LEN0 0xfffU
-#define V_RX_BUNDLE_LEN0(x) ((x) << S_RX_BUNDLE_LEN0)
-#define G_RX_BUNDLE_LEN0(x) (((x) >> S_RX_BUNDLE_LEN0) & M_RX_BUNDLE_LEN0)
-
-/* registers for module PM_TX */
-#define PM_TX_BASE_ADDR 0x8fe0
-
-#define A_PM_TX_CFG 0x8fe0
-
-#define S_CH3_OUTPUT 17
-#define M_CH3_OUTPUT 0x1fU
-#define V_CH3_OUTPUT(x) ((x) << S_CH3_OUTPUT)
-#define G_CH3_OUTPUT(x) (((x) >> S_CH3_OUTPUT) & M_CH3_OUTPUT)
-
-#define A_PM_TX_MODE 0x8fe4
-
-#define S_CONG_THRESH3 25
-#define M_CONG_THRESH3 0x7fU
-#define V_CONG_THRESH3(x) ((x) << S_CONG_THRESH3)
-#define G_CONG_THRESH3(x) (((x) >> S_CONG_THRESH3) & M_CONG_THRESH3)
-
-#define S_CONG_THRESH2 18
-#define M_CONG_THRESH2 0x7fU
-#define V_CONG_THRESH2(x) ((x) << S_CONG_THRESH2)
-#define G_CONG_THRESH2(x) (((x) >> S_CONG_THRESH2) & M_CONG_THRESH2)
-
-#define S_CONG_THRESH1 11
-#define M_CONG_THRESH1 0x7fU
-#define V_CONG_THRESH1(x) ((x) << S_CONG_THRESH1)
-#define G_CONG_THRESH1(x) (((x) >> S_CONG_THRESH1) & M_CONG_THRESH1)
-
-#define S_CONG_THRESH0 4
-#define M_CONG_THRESH0 0x7fU
-#define V_CONG_THRESH0(x) ((x) << S_CONG_THRESH0)
-#define G_CONG_THRESH0(x) (((x) >> S_CONG_THRESH0) & M_CONG_THRESH0)
-
-#define S_TX_USE_BUNDLE_LEN 3
-#define V_TX_USE_BUNDLE_LEN(x) ((x) << S_TX_USE_BUNDLE_LEN)
-#define F_TX_USE_BUNDLE_LEN V_TX_USE_BUNDLE_LEN(1U)
-
-#define S_STAT_CHANNEL 1
-#define M_STAT_CHANNEL 0x3U
-#define V_STAT_CHANNEL(x) ((x) << S_STAT_CHANNEL)
-#define G_STAT_CHANNEL(x) (((x) >> S_STAT_CHANNEL) & M_STAT_CHANNEL)
-
-#define A_PM_TX_STAT_CONFIG 0x8fe8
-#define A_PM_TX_STAT_COUNT 0x8fec
-#define A_PM_TX_STAT_LSB 0x8ff0
-#define A_PM_TX_DBG_CTRL 0x8ff0
-
-#define S_OSPIWRBUSY 21
-#define M_OSPIWRBUSY 0xfU
-#define V_OSPIWRBUSY(x) ((x) << S_OSPIWRBUSY)
-#define G_OSPIWRBUSY(x) (((x) >> S_OSPIWRBUSY) & M_OSPIWRBUSY)
-
-#define A_PM_TX_STAT_MSB 0x8ff4
-#define A_PM_TX_DBG_DATA 0x8ff4
-#define A_PM_TX_INT_ENABLE 0x8ff8
-
-#define S_PCMD_LEN_OVFL0 31
-#define V_PCMD_LEN_OVFL0(x) ((x) << S_PCMD_LEN_OVFL0)
-#define F_PCMD_LEN_OVFL0 V_PCMD_LEN_OVFL0(1U)
-
-#define S_PCMD_LEN_OVFL1 30
-#define V_PCMD_LEN_OVFL1(x) ((x) << S_PCMD_LEN_OVFL1)
-#define F_PCMD_LEN_OVFL1 V_PCMD_LEN_OVFL1(1U)
-
-#define S_PCMD_LEN_OVFL2 29
-#define V_PCMD_LEN_OVFL2(x) ((x) << S_PCMD_LEN_OVFL2)
-#define F_PCMD_LEN_OVFL2 V_PCMD_LEN_OVFL2(1U)
-
-#define S_ZERO_C_CMD_ERRO 28
-#define V_ZERO_C_CMD_ERRO(x) ((x) << S_ZERO_C_CMD_ERRO)
-#define F_ZERO_C_CMD_ERRO V_ZERO_C_CMD_ERRO(1U)
-
-#define S_ICSPI0_FIFO2X_RX_FRAMING_ERROR 27
-#define V_ICSPI0_FIFO2X_RX_FRAMING_ERROR(x) ((x) << S_ICSPI0_FIFO2X_RX_FRAMING_ERROR)
-#define F_ICSPI0_FIFO2X_RX_FRAMING_ERROR V_ICSPI0_FIFO2X_RX_FRAMING_ERROR(1U)
-
-#define S_ICSPI1_FIFO2X_RX_FRAMING_ERROR 26
-#define V_ICSPI1_FIFO2X_RX_FRAMING_ERROR(x) ((x) << S_ICSPI1_FIFO2X_RX_FRAMING_ERROR)
-#define F_ICSPI1_FIFO2X_RX_FRAMING_ERROR V_ICSPI1_FIFO2X_RX_FRAMING_ERROR(1U)
-
-#define S_ICSPI2_FIFO2X_RX_FRAMING_ERROR 25
-#define V_ICSPI2_FIFO2X_RX_FRAMING_ERROR(x) ((x) << S_ICSPI2_FIFO2X_RX_FRAMING_ERROR)
-#define F_ICSPI2_FIFO2X_RX_FRAMING_ERROR V_ICSPI2_FIFO2X_RX_FRAMING_ERROR(1U)
-
-#define S_ICSPI3_FIFO2X_RX_FRAMING_ERROR 24
-#define V_ICSPI3_FIFO2X_RX_FRAMING_ERROR(x) ((x) << S_ICSPI3_FIFO2X_RX_FRAMING_ERROR)
-#define F_ICSPI3_FIFO2X_RX_FRAMING_ERROR V_ICSPI3_FIFO2X_RX_FRAMING_ERROR(1U)
-
-#define S_ICSPI0_RX_FRAMING_ERROR 23
-#define V_ICSPI0_RX_FRAMING_ERROR(x) ((x) << S_ICSPI0_RX_FRAMING_ERROR)
-#define F_ICSPI0_RX_FRAMING_ERROR V_ICSPI0_RX_FRAMING_ERROR(1U)
-
-#define S_ICSPI1_RX_FRAMING_ERROR 22
-#define V_ICSPI1_RX_FRAMING_ERROR(x) ((x) << S_ICSPI1_RX_FRAMING_ERROR)
-#define F_ICSPI1_RX_FRAMING_ERROR V_ICSPI1_RX_FRAMING_ERROR(1U)
-
-#define S_ICSPI2_RX_FRAMING_ERROR 21
-#define V_ICSPI2_RX_FRAMING_ERROR(x) ((x) << S_ICSPI2_RX_FRAMING_ERROR)
-#define F_ICSPI2_RX_FRAMING_ERROR V_ICSPI2_RX_FRAMING_ERROR(1U)
-
-#define S_ICSPI3_RX_FRAMING_ERROR 20
-#define V_ICSPI3_RX_FRAMING_ERROR(x) ((x) << S_ICSPI3_RX_FRAMING_ERROR)
-#define F_ICSPI3_RX_FRAMING_ERROR V_ICSPI3_RX_FRAMING_ERROR(1U)
-
-#define S_ICSPI0_TX_FRAMING_ERROR 19
-#define V_ICSPI0_TX_FRAMING_ERROR(x) ((x) << S_ICSPI0_TX_FRAMING_ERROR)
-#define F_ICSPI0_TX_FRAMING_ERROR V_ICSPI0_TX_FRAMING_ERROR(1U)
-
-#define S_ICSPI1_TX_FRAMING_ERROR 18
-#define V_ICSPI1_TX_FRAMING_ERROR(x) ((x) << S_ICSPI1_TX_FRAMING_ERROR)
-#define F_ICSPI1_TX_FRAMING_ERROR V_ICSPI1_TX_FRAMING_ERROR(1U)
-
-#define S_ICSPI2_TX_FRAMING_ERROR 17
-#define V_ICSPI2_TX_FRAMING_ERROR(x) ((x) << S_ICSPI2_TX_FRAMING_ERROR)
-#define F_ICSPI2_TX_FRAMING_ERROR V_ICSPI2_TX_FRAMING_ERROR(1U)
-
-#define S_ICSPI3_TX_FRAMING_ERROR 16
-#define V_ICSPI3_TX_FRAMING_ERROR(x) ((x) << S_ICSPI3_TX_FRAMING_ERROR)
-#define F_ICSPI3_TX_FRAMING_ERROR V_ICSPI3_TX_FRAMING_ERROR(1U)
-
-#define S_OESPI0_RX_FRAMING_ERROR 15
-#define V_OESPI0_RX_FRAMING_ERROR(x) ((x) << S_OESPI0_RX_FRAMING_ERROR)
-#define F_OESPI0_RX_FRAMING_ERROR V_OESPI0_RX_FRAMING_ERROR(1U)
-
-#define S_OESPI1_RX_FRAMING_ERROR 14
-#define V_OESPI1_RX_FRAMING_ERROR(x) ((x) << S_OESPI1_RX_FRAMING_ERROR)
-#define F_OESPI1_RX_FRAMING_ERROR V_OESPI1_RX_FRAMING_ERROR(1U)
-
-#define S_OESPI2_RX_FRAMING_ERROR 13
-#define V_OESPI2_RX_FRAMING_ERROR(x) ((x) << S_OESPI2_RX_FRAMING_ERROR)
-#define F_OESPI2_RX_FRAMING_ERROR V_OESPI2_RX_FRAMING_ERROR(1U)
-
-#define S_OESPI3_RX_FRAMING_ERROR 12
-#define V_OESPI3_RX_FRAMING_ERROR(x) ((x) << S_OESPI3_RX_FRAMING_ERROR)
-#define F_OESPI3_RX_FRAMING_ERROR V_OESPI3_RX_FRAMING_ERROR(1U)
-
-#define S_OESPI0_TX_FRAMING_ERROR 11
-#define V_OESPI0_TX_FRAMING_ERROR(x) ((x) << S_OESPI0_TX_FRAMING_ERROR)
-#define F_OESPI0_TX_FRAMING_ERROR V_OESPI0_TX_FRAMING_ERROR(1U)
-
-#define S_OESPI1_TX_FRAMING_ERROR 10
-#define V_OESPI1_TX_FRAMING_ERROR(x) ((x) << S_OESPI1_TX_FRAMING_ERROR)
-#define F_OESPI1_TX_FRAMING_ERROR V_OESPI1_TX_FRAMING_ERROR(1U)
-
-#define S_OESPI2_TX_FRAMING_ERROR 9
-#define V_OESPI2_TX_FRAMING_ERROR(x) ((x) << S_OESPI2_TX_FRAMING_ERROR)
-#define F_OESPI2_TX_FRAMING_ERROR V_OESPI2_TX_FRAMING_ERROR(1U)
-
-#define S_OESPI3_TX_FRAMING_ERROR 8
-#define V_OESPI3_TX_FRAMING_ERROR(x) ((x) << S_OESPI3_TX_FRAMING_ERROR)
-#define F_OESPI3_TX_FRAMING_ERROR V_OESPI3_TX_FRAMING_ERROR(1U)
-
-#define S_OESPI0_OFIFO2X_TX_FRAMING_ERROR 7
-#define V_OESPI0_OFIFO2X_TX_FRAMING_ERROR(x) ((x) << S_OESPI0_OFIFO2X_TX_FRAMING_ERROR)
-#define F_OESPI0_OFIFO2X_TX_FRAMING_ERROR V_OESPI0_OFIFO2X_TX_FRAMING_ERROR(1U)
-
-#define S_OESPI1_OFIFO2X_TX_FRAMING_ERROR 6
-#define V_OESPI1_OFIFO2X_TX_FRAMING_ERROR(x) ((x) << S_OESPI1_OFIFO2X_TX_FRAMING_ERROR)
-#define F_OESPI1_OFIFO2X_TX_FRAMING_ERROR V_OESPI1_OFIFO2X_TX_FRAMING_ERROR(1U)
-
-#define S_OESPI2_OFIFO2X_TX_FRAMING_ERROR 5
-#define V_OESPI2_OFIFO2X_TX_FRAMING_ERROR(x) ((x) << S_OESPI2_OFIFO2X_TX_FRAMING_ERROR)
-#define F_OESPI2_OFIFO2X_TX_FRAMING_ERROR V_OESPI2_OFIFO2X_TX_FRAMING_ERROR(1U)
-
-#define S_OESPI3_OFIFO2X_TX_FRAMING_ERROR 4
-#define V_OESPI3_OFIFO2X_TX_FRAMING_ERROR(x) ((x) << S_OESPI3_OFIFO2X_TX_FRAMING_ERROR)
-#define F_OESPI3_OFIFO2X_TX_FRAMING_ERROR V_OESPI3_OFIFO2X_TX_FRAMING_ERROR(1U)
-
-#define S_OESPI_PAR_ERROR 3
-#define V_OESPI_PAR_ERROR(x) ((x) << S_OESPI_PAR_ERROR)
-#define F_OESPI_PAR_ERROR V_OESPI_PAR_ERROR(1U)
-
-#define S_ICSPI_PAR_ERROR 1
-#define V_ICSPI_PAR_ERROR(x) ((x) << S_ICSPI_PAR_ERROR)
-#define F_ICSPI_PAR_ERROR V_ICSPI_PAR_ERROR(1U)
-
-#define S_C_PCMD_PAR_ERROR 0
-#define V_C_PCMD_PAR_ERROR(x) ((x) << S_C_PCMD_PAR_ERROR)
-#define F_C_PCMD_PAR_ERROR V_C_PCMD_PAR_ERROR(1U)
-
-#define A_PM_TX_INT_CAUSE 0x8ffc
-
-#define S_ZERO_C_CMD_ERROR 28
-#define V_ZERO_C_CMD_ERROR(x) ((x) << S_ZERO_C_CMD_ERROR)
-#define F_ZERO_C_CMD_ERROR V_ZERO_C_CMD_ERROR(1U)
-
-#define S_OSPI_OR_BUNDLE_LEN_PAR_ERR 3
-#define V_OSPI_OR_BUNDLE_LEN_PAR_ERR(x) ((x) << S_OSPI_OR_BUNDLE_LEN_PAR_ERR)
-#define F_OSPI_OR_BUNDLE_LEN_PAR_ERR V_OSPI_OR_BUNDLE_LEN_PAR_ERR(1U)
-
-#define A_PM_TX_ISPI_DBG_4B_DATA0 0x10000
-#define A_PM_TX_ISPI_DBG_4B_DATA1 0x10001
-#define A_PM_TX_ISPI_DBG_4B_DATA2 0x10002
-#define A_PM_TX_ISPI_DBG_4B_DATA3 0x10003
-#define A_PM_TX_ISPI_DBG_4B_DATA4 0x10004
-#define A_PM_TX_ISPI_DBG_4B_DATA5 0x10005
-#define A_PM_TX_ISPI_DBG_4B_DATA6 0x10006
-#define A_PM_TX_ISPI_DBG_4B_DATA7 0x10007
-#define A_PM_TX_ISPI_DBG_4B_DATA8 0x10008
-#define A_PM_TX_OSPI_DBG_4B_DATA0 0x10009
-#define A_PM_TX_OSPI_DBG_4B_DATA1 0x1000a
-#define A_PM_TX_OSPI_DBG_4B_DATA2 0x1000b
-#define A_PM_TX_OSPI_DBG_4B_DATA3 0x1000c
-#define A_PM_TX_OSPI_DBG_4B_DATA4 0x1000d
-#define A_PM_TX_OSPI_DBG_4B_DATA5 0x1000e
-#define A_PM_TX_OSPI_DBG_4B_DATA6 0x1000f
-#define A_PM_TX_OSPI_DBG_4B_DATA7 0x10010
-#define A_PM_TX_OSPI_DBG_4B_DATA8 0x10011
-#define A_PM_TX_OSPI_DBG_4B_DATA9 0x10012
-#define A_PM_TX_OSPI_DBG_4B_DATA10 0x10013
-#define A_PM_TX_OSPI_DBG_4B_DATA11 0x10014
-#define A_PM_TX_OSPI_DBG_4B_DATA12 0x10015
-#define A_PM_TX_OSPI_DBG_4B_DATA13 0x10016
-#define A_PM_TX_OSPI_DBG_4B_DATA14 0x10017
-#define A_PM_TX_OSPI_DBG_4B_DATA15 0x10018
-#define A_PM_TX_OSPI_DBG_4B_DATA16 0x10019
-#define A_PM_TX_DBG_STAT_MSB 0x1001a
-#define A_PM_TX_DBG_STAT_LSB 0x1001b
-#define A_PM_TX_DBG_RSVD_FLIT_CNT 0x1001c
-#define A_PM_TX_SDC_EN 0x1001d
-#define A_PM_TX_INOUT_FIFO_DBG_CHNL_SEL 0x1001e
-#define A_PM_TX_INOUT_FIFO_DBG_WR 0x1001f
-#define A_PM_TX_INPUT_FIFO_STR_FWD_EN 0x10020
-#define A_PM_TX_FEATURE_EN 0x10021
-
-#define S_PIO_CH_DEFICIT_CTL_EN 2
-#define V_PIO_CH_DEFICIT_CTL_EN(x) ((x) << S_PIO_CH_DEFICIT_CTL_EN)
-#define F_PIO_CH_DEFICIT_CTL_EN V_PIO_CH_DEFICIT_CTL_EN(1U)
-
-#define S_PIO_WRR_BASED_PRFTCH_EN 1
-#define V_PIO_WRR_BASED_PRFTCH_EN(x) ((x) << S_PIO_WRR_BASED_PRFTCH_EN)
-#define F_PIO_WRR_BASED_PRFTCH_EN V_PIO_WRR_BASED_PRFTCH_EN(1U)
-
-#define A_PM_TX_T5_PM_TX_INT_ENABLE 0x10022
-
-#define S_OSPI_OVERFLOW3 7
-#define V_OSPI_OVERFLOW3(x) ((x) << S_OSPI_OVERFLOW3)
-#define F_OSPI_OVERFLOW3 V_OSPI_OVERFLOW3(1U)
-
-#define S_OSPI_OVERFLOW2 6
-#define V_OSPI_OVERFLOW2(x) ((x) << S_OSPI_OVERFLOW2)
-#define F_OSPI_OVERFLOW2 V_OSPI_OVERFLOW2(1U)
-
-#define S_T5_OSPI_OVERFLOW1 5
-#define V_T5_OSPI_OVERFLOW1(x) ((x) << S_T5_OSPI_OVERFLOW1)
-#define F_T5_OSPI_OVERFLOW1 V_T5_OSPI_OVERFLOW1(1U)
-
-#define S_T5_OSPI_OVERFLOW0 4
-#define V_T5_OSPI_OVERFLOW0(x) ((x) << S_T5_OSPI_OVERFLOW0)
-#define F_T5_OSPI_OVERFLOW0 V_T5_OSPI_OVERFLOW0(1U)
-
-#define S_M_INTFPERREN 3
-#define V_M_INTFPERREN(x) ((x) << S_M_INTFPERREN)
-#define F_M_INTFPERREN V_M_INTFPERREN(1U)
-
-#define S_BUNDLE_LEN_PARERR_EN 2
-#define V_BUNDLE_LEN_PARERR_EN(x) ((x) << S_BUNDLE_LEN_PARERR_EN)
-#define F_BUNDLE_LEN_PARERR_EN V_BUNDLE_LEN_PARERR_EN(1U)
-
-#define S_BUNDLE_LEN_OVFL_EN 1
-#define V_BUNDLE_LEN_OVFL_EN(x) ((x) << S_BUNDLE_LEN_OVFL_EN)
-#define F_BUNDLE_LEN_OVFL_EN V_BUNDLE_LEN_OVFL_EN(1U)
-
-#define S_SDC_ERR_EN 0
-#define V_SDC_ERR_EN(x) ((x) << S_SDC_ERR_EN)
-#define F_SDC_ERR_EN V_SDC_ERR_EN(1U)
-
-#define S_OSPI_OVERFLOW3_T5 7
-#define V_OSPI_OVERFLOW3_T5(x) ((x) << S_OSPI_OVERFLOW3_T5)
-#define F_OSPI_OVERFLOW3_T5 V_OSPI_OVERFLOW3_T5(1U)
-
-#define S_OSPI_OVERFLOW2_T5 6
-#define V_OSPI_OVERFLOW2_T5(x) ((x) << S_OSPI_OVERFLOW2_T5)
-#define F_OSPI_OVERFLOW2_T5 V_OSPI_OVERFLOW2_T5(1U)
-
-#define S_OSPI_OVERFLOW1_T5 5
-#define V_OSPI_OVERFLOW1_T5(x) ((x) << S_OSPI_OVERFLOW1_T5)
-#define F_OSPI_OVERFLOW1_T5 V_OSPI_OVERFLOW1_T5(1U)
-
-#define S_OSPI_OVERFLOW0_T5 4
-#define V_OSPI_OVERFLOW0_T5(x) ((x) << S_OSPI_OVERFLOW0_T5)
-#define F_OSPI_OVERFLOW0_T5 V_OSPI_OVERFLOW0_T5(1U)
-
-#define A_PM_TX_PRFTCH_WRR_WAIT_CNT_THRSHLD0 0x10023
-#define A_PM_TX_PRFTCH_WRR_WAIT_CNT_THRSHLD1 0x10024
-#define A_PM_TX_PRFTCH_WRR_WAIT_CNT_THRSHLD2 0x10025
-#define A_PM_TX_PRFTCH_WRR_WAIT_CNT_THRSHLD3 0x10026
-#define A_PM_TX_CH0_OSPI_DEFICIT_THRSHLD 0x10027
-#define A_PM_TX_CH1_OSPI_DEFICIT_THRSHLD 0x10028
-#define A_PM_TX_CH2_OSPI_DEFICIT_THRSHLD 0x10029
-
-#define S_CH2_OSPI_DEFICIT_THRSHLD 0
-#define M_CH2_OSPI_DEFICIT_THRSHLD 0xfffU
-#define V_CH2_OSPI_DEFICIT_THRSHLD(x) ((x) << S_CH2_OSPI_DEFICIT_THRSHLD)
-#define G_CH2_OSPI_DEFICIT_THRSHLD(x) (((x) >> S_CH2_OSPI_DEFICIT_THRSHLD) & M_CH2_OSPI_DEFICIT_THRSHLD)
-
-#define A_PM_TX_CH3_OSPI_DEFICIT_THRSHLD 0x1002a
-
-#define S_CH3_OSPI_DEFICIT_THRSHLD 0
-#define M_CH3_OSPI_DEFICIT_THRSHLD 0xfffU
-#define V_CH3_OSPI_DEFICIT_THRSHLD(x) ((x) << S_CH3_OSPI_DEFICIT_THRSHLD)
-#define G_CH3_OSPI_DEFICIT_THRSHLD(x) (((x) >> S_CH3_OSPI_DEFICIT_THRSHLD) & M_CH3_OSPI_DEFICIT_THRSHLD)
-
-#define A_PM_TX_INT_CAUSE_MASK_HALT 0x1002b
-#define A_PM_TX_DBG_STAT0 0x1002c
-
-#define S_RD_I_BUSY 29
-#define V_RD_I_BUSY(x) ((x) << S_RD_I_BUSY)
-#define F_RD_I_BUSY V_RD_I_BUSY(1U)
-
-#define S_WR_O_BUSY 28
-#define V_WR_O_BUSY(x) ((x) << S_WR_O_BUSY)
-#define F_WR_O_BUSY V_WR_O_BUSY(1U)
-
-#define S_M_TO_O_BUSY 27
-#define V_M_TO_O_BUSY(x) ((x) << S_M_TO_O_BUSY)
-#define F_M_TO_O_BUSY V_M_TO_O_BUSY(1U)
-
-#define S_I_TO_M_BUSY 26
-#define V_I_TO_M_BUSY(x) ((x) << S_I_TO_M_BUSY)
-#define F_I_TO_M_BUSY V_I_TO_M_BUSY(1U)
-
-#define S_PCMD_FB_ONLY 25
-#define V_PCMD_FB_ONLY(x) ((x) << S_PCMD_FB_ONLY)
-#define F_PCMD_FB_ONLY V_PCMD_FB_ONLY(1U)
-
-#define S_PCMD_MEM 24
-#define V_PCMD_MEM(x) ((x) << S_PCMD_MEM)
-#define F_PCMD_MEM V_PCMD_MEM(1U)
-
-#define S_PCMD_BYPASS 23
-#define V_PCMD_BYPASS(x) ((x) << S_PCMD_BYPASS)
-#define F_PCMD_BYPASS V_PCMD_BYPASS(1U)
-
-#define S_PCMD_EOP2 22
-#define V_PCMD_EOP2(x) ((x) << S_PCMD_EOP2)
-#define F_PCMD_EOP2 V_PCMD_EOP2(1U)
-
-#define S_PCMD_EOP 21
-#define V_PCMD_EOP(x) ((x) << S_PCMD_EOP)
-#define F_PCMD_EOP V_PCMD_EOP(1U)
-
-#define S_PCMD_END_BUNDLE 20
-#define V_PCMD_END_BUNDLE(x) ((x) << S_PCMD_END_BUNDLE)
-#define F_PCMD_END_BUNDLE V_PCMD_END_BUNDLE(1U)
-
-#define S_PCMD_FB_CMD 16
-#define M_PCMD_FB_CMD 0xfU
-#define V_PCMD_FB_CMD(x) ((x) << S_PCMD_FB_CMD)
-#define G_PCMD_FB_CMD(x) (((x) >> S_PCMD_FB_CMD) & M_PCMD_FB_CMD)
-
-#define S_CUR_PCMD_LEN 0
-#define M_CUR_PCMD_LEN 0xffffU
-#define V_CUR_PCMD_LEN(x) ((x) << S_CUR_PCMD_LEN)
-#define G_CUR_PCMD_LEN(x) (((x) >> S_CUR_PCMD_LEN) & M_CUR_PCMD_LEN)
-
-#define S_T6_RD_I_BUSY 28
-#define V_T6_RD_I_BUSY(x) ((x) << S_T6_RD_I_BUSY)
-#define F_T6_RD_I_BUSY V_T6_RD_I_BUSY(1U)
-
-#define S_T6_WR_O_BUSY 27
-#define V_T6_WR_O_BUSY(x) ((x) << S_T6_WR_O_BUSY)
-#define F_T6_WR_O_BUSY V_T6_WR_O_BUSY(1U)
-
-#define S_T6_M_TO_O_BUSY 26
-#define V_T6_M_TO_O_BUSY(x) ((x) << S_T6_M_TO_O_BUSY)
-#define F_T6_M_TO_O_BUSY V_T6_M_TO_O_BUSY(1U)
-
-#define S_T6_I_TO_M_BUSY 25
-#define V_T6_I_TO_M_BUSY(x) ((x) << S_T6_I_TO_M_BUSY)
-#define F_T6_I_TO_M_BUSY V_T6_I_TO_M_BUSY(1U)
-
-#define S_T6_PCMD_FB_ONLY 24
-#define V_T6_PCMD_FB_ONLY(x) ((x) << S_T6_PCMD_FB_ONLY)
-#define F_T6_PCMD_FB_ONLY V_T6_PCMD_FB_ONLY(1U)
-
-#define S_T6_PCMD_MEM 23
-#define V_T6_PCMD_MEM(x) ((x) << S_T6_PCMD_MEM)
-#define F_T6_PCMD_MEM V_T6_PCMD_MEM(1U)
-
-#define S_T6_PCMD_BYPASS 22
-#define V_T6_PCMD_BYPASS(x) ((x) << S_T6_PCMD_BYPASS)
-#define F_T6_PCMD_BYPASS V_T6_PCMD_BYPASS(1U)
-
-#define A_PM_TX_DBG_STAT1 0x1002d
-
-#define S_PCMD_MEM0 31
-#define V_PCMD_MEM0(x) ((x) << S_PCMD_MEM0)
-#define F_PCMD_MEM0 V_PCMD_MEM0(1U)
-
-#define S_FREE_OESPI_CNT0 19
-#define M_FREE_OESPI_CNT0 0xfffU
-#define V_FREE_OESPI_CNT0(x) ((x) << S_FREE_OESPI_CNT0)
-#define G_FREE_OESPI_CNT0(x) (((x) >> S_FREE_OESPI_CNT0) & M_FREE_OESPI_CNT0)
-
-#define S_PCMD_FLIT_LEN0 7
-#define M_PCMD_FLIT_LEN0 0xfffU
-#define V_PCMD_FLIT_LEN0(x) ((x) << S_PCMD_FLIT_LEN0)
-#define G_PCMD_FLIT_LEN0(x) (((x) >> S_PCMD_FLIT_LEN0) & M_PCMD_FLIT_LEN0)
-
-#define S_PCMD_CMD0 3
-#define M_PCMD_CMD0 0xfU
-#define V_PCMD_CMD0(x) ((x) << S_PCMD_CMD0)
-#define G_PCMD_CMD0(x) (((x) >> S_PCMD_CMD0) & M_PCMD_CMD0)
-
-#define S_OFIFO_FULL0 2
-#define V_OFIFO_FULL0(x) ((x) << S_OFIFO_FULL0)
-#define F_OFIFO_FULL0 V_OFIFO_FULL0(1U)
-
-#define S_GCSUM_DRDY0 1
-#define V_GCSUM_DRDY0(x) ((x) << S_GCSUM_DRDY0)
-#define F_GCSUM_DRDY0 V_GCSUM_DRDY0(1U)
-
-#define S_BYPASS0 0
-#define V_BYPASS0(x) ((x) << S_BYPASS0)
-#define F_BYPASS0 V_BYPASS0(1U)
-
-#define A_PM_TX_DBG_STAT2 0x1002e
-
-#define S_PCMD_MEM1 31
-#define V_PCMD_MEM1(x) ((x) << S_PCMD_MEM1)
-#define F_PCMD_MEM1 V_PCMD_MEM1(1U)
-
-#define S_FREE_OESPI_CNT1 19
-#define M_FREE_OESPI_CNT1 0xfffU
-#define V_FREE_OESPI_CNT1(x) ((x) << S_FREE_OESPI_CNT1)
-#define G_FREE_OESPI_CNT1(x) (((x) >> S_FREE_OESPI_CNT1) & M_FREE_OESPI_CNT1)
-
-#define S_PCMD_FLIT_LEN1 7
-#define M_PCMD_FLIT_LEN1 0xfffU
-#define V_PCMD_FLIT_LEN1(x) ((x) << S_PCMD_FLIT_LEN1)
-#define G_PCMD_FLIT_LEN1(x) (((x) >> S_PCMD_FLIT_LEN1) & M_PCMD_FLIT_LEN1)
-
-#define S_PCMD_CMD1 3
-#define M_PCMD_CMD1 0xfU
-#define V_PCMD_CMD1(x) ((x) << S_PCMD_CMD1)
-#define G_PCMD_CMD1(x) (((x) >> S_PCMD_CMD1) & M_PCMD_CMD1)
-
-#define S_OFIFO_FULL1 2
-#define V_OFIFO_FULL1(x) ((x) << S_OFIFO_FULL1)
-#define F_OFIFO_FULL1 V_OFIFO_FULL1(1U)
-
-#define S_GCSUM_DRDY1 1
-#define V_GCSUM_DRDY1(x) ((x) << S_GCSUM_DRDY1)
-#define F_GCSUM_DRDY1 V_GCSUM_DRDY1(1U)
-
-#define S_BYPASS1 0
-#define V_BYPASS1(x) ((x) << S_BYPASS1)
-#define F_BYPASS1 V_BYPASS1(1U)
-
-#define A_PM_TX_DBG_STAT3 0x1002f
-
-#define S_PCMD_MEM2 31
-#define V_PCMD_MEM2(x) ((x) << S_PCMD_MEM2)
-#define F_PCMD_MEM2 V_PCMD_MEM2(1U)
-
-#define S_FREE_OESPI_CNT2 19
-#define M_FREE_OESPI_CNT2 0xfffU
-#define V_FREE_OESPI_CNT2(x) ((x) << S_FREE_OESPI_CNT2)
-#define G_FREE_OESPI_CNT2(x) (((x) >> S_FREE_OESPI_CNT2) & M_FREE_OESPI_CNT2)
-
-#define S_PCMD_FLIT_LEN2 7
-#define M_PCMD_FLIT_LEN2 0xfffU
-#define V_PCMD_FLIT_LEN2(x) ((x) << S_PCMD_FLIT_LEN2)
-#define G_PCMD_FLIT_LEN2(x) (((x) >> S_PCMD_FLIT_LEN2) & M_PCMD_FLIT_LEN2)
-
-#define S_PCMD_CMD2 3
-#define M_PCMD_CMD2 0xfU
-#define V_PCMD_CMD2(x) ((x) << S_PCMD_CMD2)
-#define G_PCMD_CMD2(x) (((x) >> S_PCMD_CMD2) & M_PCMD_CMD2)
-
-#define S_OFIFO_FULL2 2
-#define V_OFIFO_FULL2(x) ((x) << S_OFIFO_FULL2)
-#define F_OFIFO_FULL2 V_OFIFO_FULL2(1U)
-
-#define S_GCSUM_DRDY2 1
-#define V_GCSUM_DRDY2(x) ((x) << S_GCSUM_DRDY2)
-#define F_GCSUM_DRDY2 V_GCSUM_DRDY2(1U)
-
-#define S_BYPASS2 0
-#define V_BYPASS2(x) ((x) << S_BYPASS2)
-#define F_BYPASS2 V_BYPASS2(1U)
-
-#define A_PM_TX_DBG_STAT4 0x10030
-
-#define S_PCMD_MEM3 31
-#define V_PCMD_MEM3(x) ((x) << S_PCMD_MEM3)
-#define F_PCMD_MEM3 V_PCMD_MEM3(1U)
-
-#define S_FREE_OESPI_CNT3 19
-#define M_FREE_OESPI_CNT3 0xfffU
-#define V_FREE_OESPI_CNT3(x) ((x) << S_FREE_OESPI_CNT3)
-#define G_FREE_OESPI_CNT3(x) (((x) >> S_FREE_OESPI_CNT3) & M_FREE_OESPI_CNT3)
-
-#define S_PCMD_FLIT_LEN3 7
-#define M_PCMD_FLIT_LEN3 0xfffU
-#define V_PCMD_FLIT_LEN3(x) ((x) << S_PCMD_FLIT_LEN3)
-#define G_PCMD_FLIT_LEN3(x) (((x) >> S_PCMD_FLIT_LEN3) & M_PCMD_FLIT_LEN3)
-
-#define S_PCMD_CMD3 3
-#define M_PCMD_CMD3 0xfU
-#define V_PCMD_CMD3(x) ((x) << S_PCMD_CMD3)
-#define G_PCMD_CMD3(x) (((x) >> S_PCMD_CMD3) & M_PCMD_CMD3)
-
-#define S_OFIFO_FULL3 2
-#define V_OFIFO_FULL3(x) ((x) << S_OFIFO_FULL3)
-#define F_OFIFO_FULL3 V_OFIFO_FULL3(1U)
-
-#define S_GCSUM_DRDY3 1
-#define V_GCSUM_DRDY3(x) ((x) << S_GCSUM_DRDY3)
-#define F_GCSUM_DRDY3 V_GCSUM_DRDY3(1U)
-
-#define S_BYPASS3 0
-#define V_BYPASS3(x) ((x) << S_BYPASS3)
-#define F_BYPASS3 V_BYPASS3(1U)
-
-#define A_PM_TX_DBG_STAT5 0x10031
-
-#define S_SET_PCMD_RES_RDY_RD 24
-#define M_SET_PCMD_RES_RDY_RD 0xfU
-#define V_SET_PCMD_RES_RDY_RD(x) ((x) << S_SET_PCMD_RES_RDY_RD)
-#define G_SET_PCMD_RES_RDY_RD(x) (((x) >> S_SET_PCMD_RES_RDY_RD) & M_SET_PCMD_RES_RDY_RD)
-
-#define S_ISSUED_PREF_RD_ER_CLR 20
-#define M_ISSUED_PREF_RD_ER_CLR 0xfU
-#define V_ISSUED_PREF_RD_ER_CLR(x) ((x) << S_ISSUED_PREF_RD_ER_CLR)
-#define G_ISSUED_PREF_RD_ER_CLR(x) (((x) >> S_ISSUED_PREF_RD_ER_CLR) & M_ISSUED_PREF_RD_ER_CLR)
-
-#define S_ISSUED_PREF_RD 16
-#define M_ISSUED_PREF_RD 0xfU
-#define V_ISSUED_PREF_RD(x) ((x) << S_ISSUED_PREF_RD)
-#define G_ISSUED_PREF_RD(x) (((x) >> S_ISSUED_PREF_RD) & M_ISSUED_PREF_RD)
-
-#define S_PCMD_RES_RDY 12
-#define M_PCMD_RES_RDY 0xfU
-#define V_PCMD_RES_RDY(x) ((x) << S_PCMD_RES_RDY)
-#define G_PCMD_RES_RDY(x) (((x) >> S_PCMD_RES_RDY) & M_PCMD_RES_RDY)
-
-#define S_DB_VLD 11
-#define V_DB_VLD(x) ((x) << S_DB_VLD)
-#define F_DB_VLD V_DB_VLD(1U)
-
-#define S_INJECT0_DRDY 10
-#define V_INJECT0_DRDY(x) ((x) << S_INJECT0_DRDY)
-#define F_INJECT0_DRDY V_INJECT0_DRDY(1U)
-
-#define S_INJECT1_DRDY 9
-#define V_INJECT1_DRDY(x) ((x) << S_INJECT1_DRDY)
-#define F_INJECT1_DRDY V_INJECT1_DRDY(1U)
-
-#define S_FIRST_BUNDLE 5
-#define M_FIRST_BUNDLE 0xfU
-#define V_FIRST_BUNDLE(x) ((x) << S_FIRST_BUNDLE)
-#define G_FIRST_BUNDLE(x) (((x) >> S_FIRST_BUNDLE) & M_FIRST_BUNDLE)
-
-#define S_GCSUM_MORE_THAN_2_LEFT 1
-#define M_GCSUM_MORE_THAN_2_LEFT 0xfU
-#define V_GCSUM_MORE_THAN_2_LEFT(x) ((x) << S_GCSUM_MORE_THAN_2_LEFT)
-#define G_GCSUM_MORE_THAN_2_LEFT(x) (((x) >> S_GCSUM_MORE_THAN_2_LEFT) & M_GCSUM_MORE_THAN_2_LEFT)
-
-#define S_SDC_DRDY 0
-#define V_SDC_DRDY(x) ((x) << S_SDC_DRDY)
-#define F_SDC_DRDY V_SDC_DRDY(1U)
-
-#define A_PM_TX_DBG_STAT6 0x10032
-
-#define S_PCMD_VLD 31
-#define V_PCMD_VLD(x) ((x) << S_PCMD_VLD)
-#define F_PCMD_VLD V_PCMD_VLD(1U)
-
-#define S_PCMD_CH 29
-#define M_PCMD_CH 0x3U
-#define V_PCMD_CH(x) ((x) << S_PCMD_CH)
-#define G_PCMD_CH(x) (((x) >> S_PCMD_CH) & M_PCMD_CH)
-
-#define S_STATE_MACHINE_LOC 24
-#define M_STATE_MACHINE_LOC 0x1fU
-#define V_STATE_MACHINE_LOC(x) ((x) << S_STATE_MACHINE_LOC)
-#define G_STATE_MACHINE_LOC(x) (((x) >> S_STATE_MACHINE_LOC) & M_STATE_MACHINE_LOC)
-
-#define S_ICSPI_TXVALID 20
-#define M_ICSPI_TXVALID 0xfU
-#define V_ICSPI_TXVALID(x) ((x) << S_ICSPI_TXVALID)
-#define G_ICSPI_TXVALID(x) (((x) >> S_ICSPI_TXVALID) & M_ICSPI_TXVALID)
-
-#define S_ICSPI_TXFULL 16
-#define M_ICSPI_TXFULL 0xfU
-#define V_ICSPI_TXFULL(x) ((x) << S_ICSPI_TXFULL)
-#define G_ICSPI_TXFULL(x) (((x) >> S_ICSPI_TXFULL) & M_ICSPI_TXFULL)
-
-#define S_PCMD_SRDY 12
-#define M_PCMD_SRDY 0xfU
-#define V_PCMD_SRDY(x) ((x) << S_PCMD_SRDY)
-#define G_PCMD_SRDY(x) (((x) >> S_PCMD_SRDY) & M_PCMD_SRDY)
-
-#define S_PCMD_DRDY 8
-#define M_PCMD_DRDY 0xfU
-#define V_PCMD_DRDY(x) ((x) << S_PCMD_DRDY)
-#define G_PCMD_DRDY(x) (((x) >> S_PCMD_DRDY) & M_PCMD_DRDY)
-
-#define S_PCMD_CMD 4
-#define M_PCMD_CMD 0xfU
-#define V_PCMD_CMD(x) ((x) << S_PCMD_CMD)
-#define G_PCMD_CMD(x) (((x) >> S_PCMD_CMD) & M_PCMD_CMD)
-
-#define S_OEFIFO_FULL3 3
-#define V_OEFIFO_FULL3(x) ((x) << S_OEFIFO_FULL3)
-#define F_OEFIFO_FULL3 V_OEFIFO_FULL3(1U)
-
-#define S_OEFIFO_FULL2 2
-#define V_OEFIFO_FULL2(x) ((x) << S_OEFIFO_FULL2)
-#define F_OEFIFO_FULL2 V_OEFIFO_FULL2(1U)
-
-#define S_OEFIFO_FULL1 1
-#define V_OEFIFO_FULL1(x) ((x) << S_OEFIFO_FULL1)
-#define F_OEFIFO_FULL1 V_OEFIFO_FULL1(1U)
-
-#define S_OEFIFO_FULL0 0
-#define V_OEFIFO_FULL0(x) ((x) << S_OEFIFO_FULL0)
-#define F_OEFIFO_FULL0 V_OEFIFO_FULL0(1U)
-
-#define A_PM_TX_DBG_STAT7 0x10033
-
-#define S_ICSPI_RXVALID 28
-#define M_ICSPI_RXVALID 0xfU
-#define V_ICSPI_RXVALID(x) ((x) << S_ICSPI_RXVALID)
-#define G_ICSPI_RXVALID(x) (((x) >> S_ICSPI_RXVALID) & M_ICSPI_RXVALID)
-
-#define S_ICSPI_RXFULL 24
-#define M_ICSPI_RXFULL 0xfU
-#define V_ICSPI_RXFULL(x) ((x) << S_ICSPI_RXFULL)
-#define G_ICSPI_RXFULL(x) (((x) >> S_ICSPI_RXFULL) & M_ICSPI_RXFULL)
-
-#define S_OESPI_VALID 20
-#define M_OESPI_VALID 0xfU
-#define V_OESPI_VALID(x) ((x) << S_OESPI_VALID)
-#define G_OESPI_VALID(x) (((x) >> S_OESPI_VALID) & M_OESPI_VALID)
-
-#define S_OESPI_FULL 16
-#define M_OESPI_FULL 0xfU
-#define V_OESPI_FULL(x) ((x) << S_OESPI_FULL)
-#define G_OESPI_FULL(x) (((x) >> S_OESPI_FULL) & M_OESPI_FULL)
-
-#define S_C_RXVALID 12
-#define M_C_RXVALID 0xfU
-#define V_C_RXVALID(x) ((x) << S_C_RXVALID)
-#define G_C_RXVALID(x) (((x) >> S_C_RXVALID) & M_C_RXVALID)
-
-#define S_C_RXAFULL 8
-#define M_C_RXAFULL 0xfU
-#define V_C_RXAFULL(x) ((x) << S_C_RXAFULL)
-#define G_C_RXAFULL(x) (((x) >> S_C_RXAFULL) & M_C_RXAFULL)
-
-#define S_E_TXVALID3 7
-#define V_E_TXVALID3(x) ((x) << S_E_TXVALID3)
-#define F_E_TXVALID3 V_E_TXVALID3(1U)
-
-#define S_E_TXVALID2 6
-#define V_E_TXVALID2(x) ((x) << S_E_TXVALID2)
-#define F_E_TXVALID2 V_E_TXVALID2(1U)
-
-#define S_E_TXVALID1 5
-#define V_E_TXVALID1(x) ((x) << S_E_TXVALID1)
-#define F_E_TXVALID1 V_E_TXVALID1(1U)
-
-#define S_E_TXVALID0 4
-#define V_E_TXVALID0(x) ((x) << S_E_TXVALID0)
-#define F_E_TXVALID0 V_E_TXVALID0(1U)
-
-#define S_E_TXFULL3 3
-#define V_E_TXFULL3(x) ((x) << S_E_TXFULL3)
-#define F_E_TXFULL3 V_E_TXFULL3(1U)
-
-#define S_E_TXFULL2 2
-#define V_E_TXFULL2(x) ((x) << S_E_TXFULL2)
-#define F_E_TXFULL2 V_E_TXFULL2(1U)
-
-#define S_E_TXFULL1 1
-#define V_E_TXFULL1(x) ((x) << S_E_TXFULL1)
-#define F_E_TXFULL1 V_E_TXFULL1(1U)
-
-#define S_E_TXFULL0 0
-#define V_E_TXFULL0(x) ((x) << S_E_TXFULL0)
-#define F_E_TXFULL0 V_E_TXFULL0(1U)
-
-#define A_PM_TX_DBG_STAT8 0x10034
-
-#define S_MC_RSP_FIFO_CNT 24
-#define M_MC_RSP_FIFO_CNT 0x3U
-#define V_MC_RSP_FIFO_CNT(x) ((x) << S_MC_RSP_FIFO_CNT)
-#define G_MC_RSP_FIFO_CNT(x) (((x) >> S_MC_RSP_FIFO_CNT) & M_MC_RSP_FIFO_CNT)
-
-#define S_PCMD_FREE_CNT0 14
-#define M_PCMD_FREE_CNT0 0x3ffU
-#define V_PCMD_FREE_CNT0(x) ((x) << S_PCMD_FREE_CNT0)
-#define G_PCMD_FREE_CNT0(x) (((x) >> S_PCMD_FREE_CNT0) & M_PCMD_FREE_CNT0)
-
-#define S_PCMD_FREE_CNT1 4
-#define M_PCMD_FREE_CNT1 0x3ffU
-#define V_PCMD_FREE_CNT1(x) ((x) << S_PCMD_FREE_CNT1)
-#define G_PCMD_FREE_CNT1(x) (((x) >> S_PCMD_FREE_CNT1) & M_PCMD_FREE_CNT1)
-
-#define S_M_REQADDRRDY 3
-#define V_M_REQADDRRDY(x) ((x) << S_M_REQADDRRDY)
-#define F_M_REQADDRRDY V_M_REQADDRRDY(1U)
-
-#define S_M_REQWRITE 2
-#define V_M_REQWRITE(x) ((x) << S_M_REQWRITE)
-#define F_M_REQWRITE V_M_REQWRITE(1U)
-
-#define S_M_REQDATAVLD 1
-#define V_M_REQDATAVLD(x) ((x) << S_M_REQDATAVLD)
-#define F_M_REQDATAVLD V_M_REQDATAVLD(1U)
-
-#define S_M_REQDATARDY 0
-#define V_M_REQDATARDY(x) ((x) << S_M_REQDATARDY)
-#define F_M_REQDATARDY V_M_REQDATARDY(1U)
-
-#define S_T6_MC_RSP_FIFO_CNT 27
-#define M_T6_MC_RSP_FIFO_CNT 0x3U
-#define V_T6_MC_RSP_FIFO_CNT(x) ((x) << S_T6_MC_RSP_FIFO_CNT)
-#define G_T6_MC_RSP_FIFO_CNT(x) (((x) >> S_T6_MC_RSP_FIFO_CNT) & M_T6_MC_RSP_FIFO_CNT)
-
-#define S_T6_PCMD_FREE_CNT0 17
-#define M_T6_PCMD_FREE_CNT0 0x3ffU
-#define V_T6_PCMD_FREE_CNT0(x) ((x) << S_T6_PCMD_FREE_CNT0)
-#define G_T6_PCMD_FREE_CNT0(x) (((x) >> S_T6_PCMD_FREE_CNT0) & M_T6_PCMD_FREE_CNT0)
-
-#define S_T6_PCMD_FREE_CNT1 7
-#define M_T6_PCMD_FREE_CNT1 0x3ffU
-#define V_T6_PCMD_FREE_CNT1(x) ((x) << S_T6_PCMD_FREE_CNT1)
-#define G_T6_PCMD_FREE_CNT1(x) (((x) >> S_T6_PCMD_FREE_CNT1) & M_T6_PCMD_FREE_CNT1)
-
-#define S_M_RSPVLD 6
-#define V_M_RSPVLD(x) ((x) << S_M_RSPVLD)
-#define F_M_RSPVLD V_M_RSPVLD(1U)
-
-#define S_M_RSPRDY 5
-#define V_M_RSPRDY(x) ((x) << S_M_RSPRDY)
-#define F_M_RSPRDY V_M_RSPRDY(1U)
-
-#define S_M_REQADDRVLD 4
-#define V_M_REQADDRVLD(x) ((x) << S_M_REQADDRVLD)
-#define F_M_REQADDRVLD V_M_REQADDRVLD(1U)
-
-#define A_PM_TX_DBG_STAT9 0x10035
-
-#define S_PCMD_FREE_CNT2 10
-#define M_PCMD_FREE_CNT2 0x3ffU
-#define V_PCMD_FREE_CNT2(x) ((x) << S_PCMD_FREE_CNT2)
-#define G_PCMD_FREE_CNT2(x) (((x) >> S_PCMD_FREE_CNT2) & M_PCMD_FREE_CNT2)
-
-#define S_PCMD_FREE_CNT3 0
-#define M_PCMD_FREE_CNT3 0x3ffU
-#define V_PCMD_FREE_CNT3(x) ((x) << S_PCMD_FREE_CNT3)
-#define G_PCMD_FREE_CNT3(x) (((x) >> S_PCMD_FREE_CNT3) & M_PCMD_FREE_CNT3)
-
-#define A_PM_TX_DBG_STAT10 0x10036
-
-#define S_IN_EOP_CNT3 28
-#define M_IN_EOP_CNT3 0xfU
-#define V_IN_EOP_CNT3(x) ((x) << S_IN_EOP_CNT3)
-#define G_IN_EOP_CNT3(x) (((x) >> S_IN_EOP_CNT3) & M_IN_EOP_CNT3)
-
-#define S_IN_EOP_CNT2 24
-#define M_IN_EOP_CNT2 0xfU
-#define V_IN_EOP_CNT2(x) ((x) << S_IN_EOP_CNT2)
-#define G_IN_EOP_CNT2(x) (((x) >> S_IN_EOP_CNT2) & M_IN_EOP_CNT2)
-
-#define S_IN_EOP_CNT1 20
-#define M_IN_EOP_CNT1 0xfU
-#define V_IN_EOP_CNT1(x) ((x) << S_IN_EOP_CNT1)
-#define G_IN_EOP_CNT1(x) (((x) >> S_IN_EOP_CNT1) & M_IN_EOP_CNT1)
-
-#define S_IN_EOP_CNT0 16
-#define M_IN_EOP_CNT0 0xfU
-#define V_IN_EOP_CNT0(x) ((x) << S_IN_EOP_CNT0)
-#define G_IN_EOP_CNT0(x) (((x) >> S_IN_EOP_CNT0) & M_IN_EOP_CNT0)
-
-#define S_IN_SOP_CNT3 12
-#define M_IN_SOP_CNT3 0xfU
-#define V_IN_SOP_CNT3(x) ((x) << S_IN_SOP_CNT3)
-#define G_IN_SOP_CNT3(x) (((x) >> S_IN_SOP_CNT3) & M_IN_SOP_CNT3)
-
-#define S_IN_SOP_CNT2 8
-#define M_IN_SOP_CNT2 0xfU
-#define V_IN_SOP_CNT2(x) ((x) << S_IN_SOP_CNT2)
-#define G_IN_SOP_CNT2(x) (((x) >> S_IN_SOP_CNT2) & M_IN_SOP_CNT2)
-
-#define S_IN_SOP_CNT1 4
-#define M_IN_SOP_CNT1 0xfU
-#define V_IN_SOP_CNT1(x) ((x) << S_IN_SOP_CNT1)
-#define G_IN_SOP_CNT1(x) (((x) >> S_IN_SOP_CNT1) & M_IN_SOP_CNT1)
-
-#define S_IN_SOP_CNT0 0
-#define M_IN_SOP_CNT0 0xfU
-#define V_IN_SOP_CNT0(x) ((x) << S_IN_SOP_CNT0)
-#define G_IN_SOP_CNT0(x) (((x) >> S_IN_SOP_CNT0) & M_IN_SOP_CNT0)
-
-#define A_PM_TX_DBG_STAT11 0x10037
-
-#define S_OUT_EOP_CNT3 28
-#define M_OUT_EOP_CNT3 0xfU
-#define V_OUT_EOP_CNT3(x) ((x) << S_OUT_EOP_CNT3)
-#define G_OUT_EOP_CNT3(x) (((x) >> S_OUT_EOP_CNT3) & M_OUT_EOP_CNT3)
-
-#define S_OUT_EOP_CNT2 24
-#define M_OUT_EOP_CNT2 0xfU
-#define V_OUT_EOP_CNT2(x) ((x) << S_OUT_EOP_CNT2)
-#define G_OUT_EOP_CNT2(x) (((x) >> S_OUT_EOP_CNT2) & M_OUT_EOP_CNT2)
-
-#define S_OUT_EOP_CNT1 20
-#define M_OUT_EOP_CNT1 0xfU
-#define V_OUT_EOP_CNT1(x) ((x) << S_OUT_EOP_CNT1)
-#define G_OUT_EOP_CNT1(x) (((x) >> S_OUT_EOP_CNT1) & M_OUT_EOP_CNT1)
-
-#define S_OUT_EOP_CNT0 16
-#define M_OUT_EOP_CNT0 0xfU
-#define V_OUT_EOP_CNT0(x) ((x) << S_OUT_EOP_CNT0)
-#define G_OUT_EOP_CNT0(x) (((x) >> S_OUT_EOP_CNT0) & M_OUT_EOP_CNT0)
-
-#define S_OUT_SOP_CNT3 12
-#define M_OUT_SOP_CNT3 0xfU
-#define V_OUT_SOP_CNT3(x) ((x) << S_OUT_SOP_CNT3)
-#define G_OUT_SOP_CNT3(x) (((x) >> S_OUT_SOP_CNT3) & M_OUT_SOP_CNT3)
-
-#define S_OUT_SOP_CNT2 8
-#define M_OUT_SOP_CNT2 0xfU
-#define V_OUT_SOP_CNT2(x) ((x) << S_OUT_SOP_CNT2)
-#define G_OUT_SOP_CNT2(x) (((x) >> S_OUT_SOP_CNT2) & M_OUT_SOP_CNT2)
-
-#define S_OUT_SOP_CNT1 4
-#define M_OUT_SOP_CNT1 0xfU
-#define V_OUT_SOP_CNT1(x) ((x) << S_OUT_SOP_CNT1)
-#define G_OUT_SOP_CNT1(x) (((x) >> S_OUT_SOP_CNT1) & M_OUT_SOP_CNT1)
-
-#define S_OUT_SOP_CNT0 0
-#define M_OUT_SOP_CNT0 0xfU
-#define V_OUT_SOP_CNT0(x) ((x) << S_OUT_SOP_CNT0)
-#define G_OUT_SOP_CNT0(x) (((x) >> S_OUT_SOP_CNT0) & M_OUT_SOP_CNT0)
-
-#define A_PM_TX_DBG_STAT12 0x10038
-#define A_PM_TX_DBG_STAT13 0x10039
-
-#define S_CH_DEFICIT_BLOWED 31
-#define V_CH_DEFICIT_BLOWED(x) ((x) << S_CH_DEFICIT_BLOWED)
-#define F_CH_DEFICIT_BLOWED V_CH_DEFICIT_BLOWED(1U)
-
-#define S_CH1_DEFICIT 16
-#define M_CH1_DEFICIT 0xfffU
-#define V_CH1_DEFICIT(x) ((x) << S_CH1_DEFICIT)
-#define G_CH1_DEFICIT(x) (((x) >> S_CH1_DEFICIT) & M_CH1_DEFICIT)
-
-#define S_CH0_DEFICIT 0
-#define M_CH0_DEFICIT 0xfffU
-#define V_CH0_DEFICIT(x) ((x) << S_CH0_DEFICIT)
-#define G_CH0_DEFICIT(x) (((x) >> S_CH0_DEFICIT) & M_CH0_DEFICIT)
-
-#define A_PM_TX_DBG_STAT14 0x1003a
-
-#define S_CH3_DEFICIT 16
-#define M_CH3_DEFICIT 0xfffU
-#define V_CH3_DEFICIT(x) ((x) << S_CH3_DEFICIT)
-#define G_CH3_DEFICIT(x) (((x) >> S_CH3_DEFICIT) & M_CH3_DEFICIT)
-
-#define S_CH2_DEFICIT 0
-#define M_CH2_DEFICIT 0xfffU
-#define V_CH2_DEFICIT(x) ((x) << S_CH2_DEFICIT)
-#define G_CH2_DEFICIT(x) (((x) >> S_CH2_DEFICIT) & M_CH2_DEFICIT)
-
-#define A_PM_TX_DBG_STAT15 0x1003b
-
-#define S_BUNDLE_LEN_SRDY 28
-#define M_BUNDLE_LEN_SRDY 0xfU
-#define V_BUNDLE_LEN_SRDY(x) ((x) << S_BUNDLE_LEN_SRDY)
-#define G_BUNDLE_LEN_SRDY(x) (((x) >> S_BUNDLE_LEN_SRDY) & M_BUNDLE_LEN_SRDY)
-
-#define S_BUNDLE_LEN1 16
-#define M_BUNDLE_LEN1 0xfffU
-#define V_BUNDLE_LEN1(x) ((x) << S_BUNDLE_LEN1)
-#define G_BUNDLE_LEN1(x) (((x) >> S_BUNDLE_LEN1) & M_BUNDLE_LEN1)
-
-#define S_BUNDLE_LEN0 0
-#define M_BUNDLE_LEN0 0xfffU
-#define V_BUNDLE_LEN0(x) ((x) << S_BUNDLE_LEN0)
-#define G_BUNDLE_LEN0(x) (((x) >> S_BUNDLE_LEN0) & M_BUNDLE_LEN0)
-
-#define S_T6_BUNDLE_LEN_SRDY 24
-#define M_T6_BUNDLE_LEN_SRDY 0x3U
-#define V_T6_BUNDLE_LEN_SRDY(x) ((x) << S_T6_BUNDLE_LEN_SRDY)
-#define G_T6_BUNDLE_LEN_SRDY(x) (((x) >> S_T6_BUNDLE_LEN_SRDY) & M_T6_BUNDLE_LEN_SRDY)
-
-#define S_T6_BUNDLE_LEN1 12
-#define M_T6_BUNDLE_LEN1 0xfffU
-#define V_T6_BUNDLE_LEN1(x) ((x) << S_T6_BUNDLE_LEN1)
-#define G_T6_BUNDLE_LEN1(x) (((x) >> S_T6_BUNDLE_LEN1) & M_T6_BUNDLE_LEN1)
-
-#define A_PM_TX_DBG_STAT16 0x1003c
-
-#define S_BUNDLE_LEN3 16
-#define M_BUNDLE_LEN3 0xfffU
-#define V_BUNDLE_LEN3(x) ((x) << S_BUNDLE_LEN3)
-#define G_BUNDLE_LEN3(x) (((x) >> S_BUNDLE_LEN3) & M_BUNDLE_LEN3)
-
-#define S_BUNDLE_LEN2 0
-#define M_BUNDLE_LEN2 0xfffU
-#define V_BUNDLE_LEN2(x) ((x) << S_BUNDLE_LEN2)
-#define G_BUNDLE_LEN2(x) (((x) >> S_BUNDLE_LEN2) & M_BUNDLE_LEN2)
-
-/* registers for module MPS */
-#define MPS_BASE_ADDR 0x9000
-
-#define A_MPS_PORT_CTL 0x0
-
-#define S_LPBKEN 31
-#define V_LPBKEN(x) ((x) << S_LPBKEN)
-#define F_LPBKEN V_LPBKEN(1U)
-
-#define S_PORTTXEN 30
-#define V_PORTTXEN(x) ((x) << S_PORTTXEN)
-#define F_PORTTXEN V_PORTTXEN(1U)
-
-#define S_PORTRXEN 29
-#define V_PORTRXEN(x) ((x) << S_PORTRXEN)
-#define F_PORTRXEN V_PORTRXEN(1U)
-
-#define S_PPPEN 28
-#define V_PPPEN(x) ((x) << S_PPPEN)
-#define F_PPPEN V_PPPEN(1U)
-
-#define S_FCSSTRIPEN 27
-#define V_FCSSTRIPEN(x) ((x) << S_FCSSTRIPEN)
-#define F_FCSSTRIPEN V_FCSSTRIPEN(1U)
-
-#define S_PPPANDPAUSE 26
-#define V_PPPANDPAUSE(x) ((x) << S_PPPANDPAUSE)
-#define F_PPPANDPAUSE V_PPPANDPAUSE(1U)
-
-#define S_PRIOPPPENMAP 16
-#define M_PRIOPPPENMAP 0xffU
-#define V_PRIOPPPENMAP(x) ((x) << S_PRIOPPPENMAP)
-#define G_PRIOPPPENMAP(x) (((x) >> S_PRIOPPPENMAP) & M_PRIOPPPENMAP)
-
-#define A_MPS_VF_CTL 0x0
-#define A_MPS_PORT_PAUSE_CTL 0x4
-
-#define S_TIMEUNIT 0
-#define M_TIMEUNIT 0xffffU
-#define V_TIMEUNIT(x) ((x) << S_TIMEUNIT)
-#define G_TIMEUNIT(x) (((x) >> S_TIMEUNIT) & M_TIMEUNIT)
-
-#define A_MPS_PORT_TX_PAUSE_CTL 0x8
-
-#define S_REGSENDOFF 24
-#define M_REGSENDOFF 0xffU
-#define V_REGSENDOFF(x) ((x) << S_REGSENDOFF)
-#define G_REGSENDOFF(x) (((x) >> S_REGSENDOFF) & M_REGSENDOFF)
-
-#define S_REGSENDON 16
-#define M_REGSENDON 0xffU
-#define V_REGSENDON(x) ((x) << S_REGSENDON)
-#define G_REGSENDON(x) (((x) >> S_REGSENDON) & M_REGSENDON)
-
-#define S_SGESENDEN 8
-#define M_SGESENDEN 0xffU
-#define V_SGESENDEN(x) ((x) << S_SGESENDEN)
-#define G_SGESENDEN(x) (((x) >> S_SGESENDEN) & M_SGESENDEN)
-
-#define S_RXSENDEN 0
-#define M_RXSENDEN 0xffU
-#define V_RXSENDEN(x) ((x) << S_RXSENDEN)
-#define G_RXSENDEN(x) (((x) >> S_RXSENDEN) & M_RXSENDEN)
-
-#define A_MPS_PORT_TX_PAUSE_CTL2 0xc
-
-#define S_XOFFDISABLE 0
-#define V_XOFFDISABLE(x) ((x) << S_XOFFDISABLE)
-#define F_XOFFDISABLE V_XOFFDISABLE(1U)
-
-#define A_MPS_PORT_RX_PAUSE_CTL 0x10
-
-#define S_REGHALTON 8
-#define M_REGHALTON 0xffU
-#define V_REGHALTON(x) ((x) << S_REGHALTON)
-#define G_REGHALTON(x) (((x) >> S_REGHALTON) & M_REGHALTON)
-
-#define S_RXHALTEN 0
-#define M_RXHALTEN 0xffU
-#define V_RXHALTEN(x) ((x) << S_RXHALTEN)
-#define G_RXHALTEN(x) (((x) >> S_RXHALTEN) & M_RXHALTEN)
-
-#define A_MPS_PORT_TX_PAUSE_STATUS 0x14
-
-#define S_REGSENDING 16
-#define M_REGSENDING 0xffU
-#define V_REGSENDING(x) ((x) << S_REGSENDING)
-#define G_REGSENDING(x) (((x) >> S_REGSENDING) & M_REGSENDING)
-
-#define S_SGESENDING 8
-#define M_SGESENDING 0xffU
-#define V_SGESENDING(x) ((x) << S_SGESENDING)
-#define G_SGESENDING(x) (((x) >> S_SGESENDING) & M_SGESENDING)
-
-#define S_RXSENDING 0
-#define M_RXSENDING 0xffU
-#define V_RXSENDING(x) ((x) << S_RXSENDING)
-#define G_RXSENDING(x) (((x) >> S_RXSENDING) & M_RXSENDING)
-
-#define A_MPS_PORT_RX_PAUSE_STATUS 0x18
-
-#define S_REGHALTED 8
-#define M_REGHALTED 0xffU
-#define V_REGHALTED(x) ((x) << S_REGHALTED)
-#define G_REGHALTED(x) (((x) >> S_REGHALTED) & M_REGHALTED)
-
-#define S_RXHALTED 0
-#define M_RXHALTED 0xffU
-#define V_RXHALTED(x) ((x) << S_RXHALTED)
-#define G_RXHALTED(x) (((x) >> S_RXHALTED) & M_RXHALTED)
-
-#define A_MPS_PORT_TX_PAUSE_DEST_L 0x1c
-#define A_MPS_PORT_TX_PAUSE_DEST_H 0x20
-
-#define S_ADDR 0
-#define M_ADDR 0xffffU
-#define V_ADDR(x) ((x) << S_ADDR)
-#define G_ADDR(x) (((x) >> S_ADDR) & M_ADDR)
-
-#define A_MPS_PORT_TX_PAUSE_SOURCE_L 0x24
-#define A_MPS_PORT_TX_PAUSE_SOURCE_H 0x28
-#define A_MPS_PORT_PRTY_BUFFER_GROUP_MAP 0x2c
-
-#define S_PRTY7 14
-#define M_PRTY7 0x3U
-#define V_PRTY7(x) ((x) << S_PRTY7)
-#define G_PRTY7(x) (((x) >> S_PRTY7) & M_PRTY7)
-
-#define S_PRTY6 12
-#define M_PRTY6 0x3U
-#define V_PRTY6(x) ((x) << S_PRTY6)
-#define G_PRTY6(x) (((x) >> S_PRTY6) & M_PRTY6)
-
-#define S_PRTY5 10
-#define M_PRTY5 0x3U
-#define V_PRTY5(x) ((x) << S_PRTY5)
-#define G_PRTY5(x) (((x) >> S_PRTY5) & M_PRTY5)
-
-#define S_PRTY4 8
-#define M_PRTY4 0x3U
-#define V_PRTY4(x) ((x) << S_PRTY4)
-#define G_PRTY4(x) (((x) >> S_PRTY4) & M_PRTY4)
-
-#define S_PRTY3 6
-#define M_PRTY3 0x3U
-#define V_PRTY3(x) ((x) << S_PRTY3)
-#define G_PRTY3(x) (((x) >> S_PRTY3) & M_PRTY3)
-
-#define S_PRTY2 4
-#define M_PRTY2 0x3U
-#define V_PRTY2(x) ((x) << S_PRTY2)
-#define G_PRTY2(x) (((x) >> S_PRTY2) & M_PRTY2)
-
-#define S_PRTY1 2
-#define M_PRTY1 0x3U
-#define V_PRTY1(x) ((x) << S_PRTY1)
-#define G_PRTY1(x) (((x) >> S_PRTY1) & M_PRTY1)
-
-#define S_PRTY0 0
-#define M_PRTY0 0x3U
-#define V_PRTY0(x) ((x) << S_PRTY0)
-#define G_PRTY0(x) (((x) >> S_PRTY0) & M_PRTY0)
-
-#define A_MPS_PORT_PRTY_BUFFER_GROUP_TH_MAP 0x30
-
-#define S_TXPRTY7 28
-#define M_TXPRTY7 0xfU
-#define V_TXPRTY7(x) ((x) << S_TXPRTY7)
-#define G_TXPRTY7(x) (((x) >> S_TXPRTY7) & M_TXPRTY7)
-
-#define S_TXPRTY6 24
-#define M_TXPRTY6 0xfU
-#define V_TXPRTY6(x) ((x) << S_TXPRTY6)
-#define G_TXPRTY6(x) (((x) >> S_TXPRTY6) & M_TXPRTY6)
-
-#define S_TXPRTY5 20
-#define M_TXPRTY5 0xfU
-#define V_TXPRTY5(x) ((x) << S_TXPRTY5)
-#define G_TXPRTY5(x) (((x) >> S_TXPRTY5) & M_TXPRTY5)
-
-#define S_TXPRTY4 16
-#define M_TXPRTY4 0xfU
-#define V_TXPRTY4(x) ((x) << S_TXPRTY4)
-#define G_TXPRTY4(x) (((x) >> S_TXPRTY4) & M_TXPRTY4)
-
-#define S_TXPRTY3 12
-#define M_TXPRTY3 0xfU
-#define V_TXPRTY3(x) ((x) << S_TXPRTY3)
-#define G_TXPRTY3(x) (((x) >> S_TXPRTY3) & M_TXPRTY3)
-
-#define S_TXPRTY2 8
-#define M_TXPRTY2 0xfU
-#define V_TXPRTY2(x) ((x) << S_TXPRTY2)
-#define G_TXPRTY2(x) (((x) >> S_TXPRTY2) & M_TXPRTY2)
-
-#define S_TXPRTY1 4
-#define M_TXPRTY1 0xfU
-#define V_TXPRTY1(x) ((x) << S_TXPRTY1)
-#define G_TXPRTY1(x) (((x) >> S_TXPRTY1) & M_TXPRTY1)
-
-#define S_TXPRTY0 0
-#define M_TXPRTY0 0xfU
-#define V_TXPRTY0(x) ((x) << S_TXPRTY0)
-#define G_TXPRTY0(x) (((x) >> S_TXPRTY0) & M_TXPRTY0)
-
-#define A_MPS_VF_STAT_TX_VF_BCAST_BYTES_L 0x80
-#define A_MPS_VF_STAT_TX_VF_BCAST_BYTES_H 0x84
-#define A_MPS_VF_STAT_TX_VF_BCAST_FRAMES_L 0x88
-#define A_MPS_VF_STAT_TX_VF_BCAST_FRAMES_H 0x8c
-#define A_MPS_VF_STAT_TX_VF_MCAST_BYTES_L 0x90
-#define A_MPS_VF_STAT_TX_VF_MCAST_BYTES_H 0x94
-#define A_MPS_VF_STAT_TX_VF_MCAST_FRAMES_L 0x98
-#define A_MPS_VF_STAT_TX_VF_MCAST_FRAMES_H 0x9c
-#define A_MPS_VF_STAT_TX_VF_UCAST_BYTES_L 0xa0
-#define A_MPS_VF_STAT_TX_VF_UCAST_BYTES_H 0xa4
-#define A_MPS_VF_STAT_TX_VF_UCAST_FRAMES_L 0xa8
-#define A_MPS_VF_STAT_TX_VF_UCAST_FRAMES_H 0xac
-#define A_MPS_VF_STAT_TX_VF_DROP_FRAMES_L 0xb0
-#define A_MPS_VF_STAT_TX_VF_DROP_FRAMES_H 0xb4
-#define A_MPS_VF_STAT_TX_VF_OFFLOAD_BYTES_L 0xb8
-#define A_MPS_VF_STAT_TX_VF_OFFLOAD_BYTES_H 0xbc
-#define A_MPS_VF_STAT_TX_VF_OFFLOAD_FRAMES_L 0xc0
-#define A_MPS_VF_STAT_TX_VF_OFFLOAD_FRAMES_H 0xc4
-#define A_MPS_VF_STAT_RX_VF_BCAST_BYTES_L 0xc8
-#define A_MPS_VF_STAT_RX_VF_BCAST_BYTES_H 0xcc
-#define A_MPS_VF_STAT_RX_VF_BCAST_FRAMES_L 0xd0
-#define A_MPS_VF_STAT_RX_VF_BCAST_FRAMES_H 0xd4
-#define A_MPS_VF_STAT_RX_VF_MCAST_BYTES_L 0xd8
-#define A_MPS_VF_STAT_RX_VF_MCAST_BYTES_H 0xdc
-#define A_MPS_VF_STAT_RX_VF_MCAST_FRAMES_L 0xe0
-#define A_MPS_VF_STAT_RX_VF_MCAST_FRAMES_H 0xe4
-#define A_MPS_VF_STAT_RX_VF_UCAST_BYTES_L 0xe8
-#define A_MPS_VF_STAT_RX_VF_UCAST_BYTES_H 0xec
-#define A_MPS_VF_STAT_RX_VF_UCAST_FRAMES_L 0xf0
-#define A_MPS_VF_STAT_RX_VF_UCAST_FRAMES_H 0xf4
-#define A_MPS_VF_STAT_RX_VF_ERR_FRAMES_L 0xf8
-#define A_MPS_VF_STAT_RX_VF_ERR_FRAMES_H 0xfc
-#define A_MPS_PORT_RX_CTL 0x100
-
-#define S_NO_RPLCT_M 20
-#define V_NO_RPLCT_M(x) ((x) << S_NO_RPLCT_M)
-#define F_NO_RPLCT_M V_NO_RPLCT_M(1U)
-
-#define S_RPLCT_SEL_L 18
-#define M_RPLCT_SEL_L 0x3U
-#define V_RPLCT_SEL_L(x) ((x) << S_RPLCT_SEL_L)
-#define G_RPLCT_SEL_L(x) (((x) >> S_RPLCT_SEL_L) & M_RPLCT_SEL_L)
-
-#define S_FLTR_VLAN_SEL 17
-#define V_FLTR_VLAN_SEL(x) ((x) << S_FLTR_VLAN_SEL)
-#define F_FLTR_VLAN_SEL V_FLTR_VLAN_SEL(1U)
-
-#define S_PRIO_VLAN_SEL 16
-#define V_PRIO_VLAN_SEL(x) ((x) << S_PRIO_VLAN_SEL)
-#define F_PRIO_VLAN_SEL V_PRIO_VLAN_SEL(1U)
-
-#define S_CHK_8023_LEN_M 15
-#define V_CHK_8023_LEN_M(x) ((x) << S_CHK_8023_LEN_M)
-#define F_CHK_8023_LEN_M V_CHK_8023_LEN_M(1U)
-
-#define S_CHK_8023_LEN_L 14
-#define V_CHK_8023_LEN_L(x) ((x) << S_CHK_8023_LEN_L)
-#define F_CHK_8023_LEN_L V_CHK_8023_LEN_L(1U)
-
-#define S_NIV_DROP 13
-#define V_NIV_DROP(x) ((x) << S_NIV_DROP)
-#define F_NIV_DROP V_NIV_DROP(1U)
-
-#define S_NOV_DROP 12
-#define V_NOV_DROP(x) ((x) << S_NOV_DROP)
-#define F_NOV_DROP V_NOV_DROP(1U)
-
-#define S_CLS_PRT 11
-#define V_CLS_PRT(x) ((x) << S_CLS_PRT)
-#define F_CLS_PRT V_CLS_PRT(1U)
-
-#define S_RX_QFC_EN 10
-#define V_RX_QFC_EN(x) ((x) << S_RX_QFC_EN)
-#define F_RX_QFC_EN V_RX_QFC_EN(1U)
-
-#define S_QFC_FWD_UP 9
-#define V_QFC_FWD_UP(x) ((x) << S_QFC_FWD_UP)
-#define F_QFC_FWD_UP V_QFC_FWD_UP(1U)
-
-#define S_PPP_FWD_UP 8
-#define V_PPP_FWD_UP(x) ((x) << S_PPP_FWD_UP)
-#define F_PPP_FWD_UP V_PPP_FWD_UP(1U)
-
-#define S_PAUSE_FWD_UP 7
-#define V_PAUSE_FWD_UP(x) ((x) << S_PAUSE_FWD_UP)
-#define F_PAUSE_FWD_UP V_PAUSE_FWD_UP(1U)
-
-#define S_LPBK_BP 6
-#define V_LPBK_BP(x) ((x) << S_LPBK_BP)
-#define F_LPBK_BP V_LPBK_BP(1U)
-
-#define S_PASS_NO_MATCH 5
-#define V_PASS_NO_MATCH(x) ((x) << S_PASS_NO_MATCH)
-#define F_PASS_NO_MATCH V_PASS_NO_MATCH(1U)
-
-#define S_IVLAN_EN 4
-#define V_IVLAN_EN(x) ((x) << S_IVLAN_EN)
-#define F_IVLAN_EN V_IVLAN_EN(1U)
-
-#define S_OVLAN_EN3 3
-#define V_OVLAN_EN3(x) ((x) << S_OVLAN_EN3)
-#define F_OVLAN_EN3 V_OVLAN_EN3(1U)
-
-#define S_OVLAN_EN2 2
-#define V_OVLAN_EN2(x) ((x) << S_OVLAN_EN2)
-#define F_OVLAN_EN2 V_OVLAN_EN2(1U)
-
-#define S_OVLAN_EN1 1
-#define V_OVLAN_EN1(x) ((x) << S_OVLAN_EN1)
-#define F_OVLAN_EN1 V_OVLAN_EN1(1U)
-
-#define S_OVLAN_EN0 0
-#define V_OVLAN_EN0(x) ((x) << S_OVLAN_EN0)
-#define F_OVLAN_EN0 V_OVLAN_EN0(1U)
-
-#define S_PTP_FWD_UP 21
-#define V_PTP_FWD_UP(x) ((x) << S_PTP_FWD_UP)
-#define F_PTP_FWD_UP V_PTP_FWD_UP(1U)
-
-#define S_HASH_PRIO_SEL_LPBK 25
-#define V_HASH_PRIO_SEL_LPBK(x) ((x) << S_HASH_PRIO_SEL_LPBK)
-#define F_HASH_PRIO_SEL_LPBK V_HASH_PRIO_SEL_LPBK(1U)
-
-#define S_HASH_PRIO_SEL_MAC 24
-#define V_HASH_PRIO_SEL_MAC(x) ((x) << S_HASH_PRIO_SEL_MAC)
-#define F_HASH_PRIO_SEL_MAC V_HASH_PRIO_SEL_MAC(1U)
-
-#define S_HASH_EN_LPBK 23
-#define V_HASH_EN_LPBK(x) ((x) << S_HASH_EN_LPBK)
-#define F_HASH_EN_LPBK V_HASH_EN_LPBK(1U)
-
-#define S_HASH_EN_MAC 22
-#define V_HASH_EN_MAC(x) ((x) << S_HASH_EN_MAC)
-#define F_HASH_EN_MAC V_HASH_EN_MAC(1U)
-
-#define A_MPS_PORT_RX_MTU 0x104
-#define A_MPS_PORT_RX_PF_MAP 0x108
-#define A_MPS_PORT_RX_VF_MAP0 0x10c
-#define A_MPS_PORT_RX_VF_MAP1 0x110
-#define A_MPS_PORT_RX_VF_MAP2 0x114
-#define A_MPS_PORT_RX_VF_MAP3 0x118
-#define A_MPS_PORT_RX_IVLAN 0x11c
-
-#define S_IVLAN_ETYPE 0
-#define M_IVLAN_ETYPE 0xffffU
-#define V_IVLAN_ETYPE(x) ((x) << S_IVLAN_ETYPE)
-#define G_IVLAN_ETYPE(x) (((x) >> S_IVLAN_ETYPE) & M_IVLAN_ETYPE)
-
-#define A_MPS_PORT_RX_OVLAN0 0x120
-
-#define S_OVLAN_MASK 16
-#define M_OVLAN_MASK 0xffffU
-#define V_OVLAN_MASK(x) ((x) << S_OVLAN_MASK)
-#define G_OVLAN_MASK(x) (((x) >> S_OVLAN_MASK) & M_OVLAN_MASK)
-
-#define S_OVLAN_ETYPE 0
-#define M_OVLAN_ETYPE 0xffffU
-#define V_OVLAN_ETYPE(x) ((x) << S_OVLAN_ETYPE)
-#define G_OVLAN_ETYPE(x) (((x) >> S_OVLAN_ETYPE) & M_OVLAN_ETYPE)
-
-#define A_MPS_PORT_RX_OVLAN1 0x124
-#define A_MPS_PORT_RX_OVLAN2 0x128
-#define A_MPS_PORT_RX_OVLAN3 0x12c
-#define A_MPS_PORT_RX_RSS_HASH 0x130
-#define A_MPS_PORT_RX_RSS_CONTROL 0x134
-
-#define S_RSS_CTRL 16
-#define M_RSS_CTRL 0xffU
-#define V_RSS_CTRL(x) ((x) << S_RSS_CTRL)
-#define G_RSS_CTRL(x) (((x) >> S_RSS_CTRL) & M_RSS_CTRL)
-
-#define S_QUE_NUM 0
-#define M_QUE_NUM 0xffffU
-#define V_QUE_NUM(x) ((x) << S_QUE_NUM)
-#define G_QUE_NUM(x) (((x) >> S_QUE_NUM) & M_QUE_NUM)
-
-#define A_MPS_PORT_RX_CTL1 0x138
-
-#define S_FIXED_PFVF_MAC 13
-#define V_FIXED_PFVF_MAC(x) ((x) << S_FIXED_PFVF_MAC)
-#define F_FIXED_PFVF_MAC V_FIXED_PFVF_MAC(1U)
-
-#define S_FIXED_PFVF_LPBK 12
-#define V_FIXED_PFVF_LPBK(x) ((x) << S_FIXED_PFVF_LPBK)
-#define F_FIXED_PFVF_LPBK V_FIXED_PFVF_LPBK(1U)
-
-#define S_FIXED_PFVF_LPBK_OV 11
-#define V_FIXED_PFVF_LPBK_OV(x) ((x) << S_FIXED_PFVF_LPBK_OV)
-#define F_FIXED_PFVF_LPBK_OV V_FIXED_PFVF_LPBK_OV(1U)
-
-#define S_FIXED_PF 8
-#define M_FIXED_PF 0x7U
-#define V_FIXED_PF(x) ((x) << S_FIXED_PF)
-#define G_FIXED_PF(x) (((x) >> S_FIXED_PF) & M_FIXED_PF)
-
-#define S_FIXED_VF_VLD 7
-#define V_FIXED_VF_VLD(x) ((x) << S_FIXED_VF_VLD)
-#define F_FIXED_VF_VLD V_FIXED_VF_VLD(1U)
-
-#define S_FIXED_VF 0
-#define M_FIXED_VF 0x7fU
-#define V_FIXED_VF(x) ((x) << S_FIXED_VF)
-#define G_FIXED_VF(x) (((x) >> S_FIXED_VF) & M_FIXED_VF)
-
-#define S_T6_FIXED_PFVF_MAC 14
-#define V_T6_FIXED_PFVF_MAC(x) ((x) << S_T6_FIXED_PFVF_MAC)
-#define F_T6_FIXED_PFVF_MAC V_T6_FIXED_PFVF_MAC(1U)
-
-#define S_T6_FIXED_PFVF_LPBK 13
-#define V_T6_FIXED_PFVF_LPBK(x) ((x) << S_T6_FIXED_PFVF_LPBK)
-#define F_T6_FIXED_PFVF_LPBK V_T6_FIXED_PFVF_LPBK(1U)
-
-#define S_T6_FIXED_PFVF_LPBK_OV 12
-#define V_T6_FIXED_PFVF_LPBK_OV(x) ((x) << S_T6_FIXED_PFVF_LPBK_OV)
-#define F_T6_FIXED_PFVF_LPBK_OV V_T6_FIXED_PFVF_LPBK_OV(1U)
-
-#define S_T6_FIXED_PF 9
-#define M_T6_FIXED_PF 0x7U
-#define V_T6_FIXED_PF(x) ((x) << S_T6_FIXED_PF)
-#define G_T6_FIXED_PF(x) (((x) >> S_T6_FIXED_PF) & M_T6_FIXED_PF)
-
-#define S_T6_FIXED_VF_VLD 8
-#define V_T6_FIXED_VF_VLD(x) ((x) << S_T6_FIXED_VF_VLD)
-#define F_T6_FIXED_VF_VLD V_T6_FIXED_VF_VLD(1U)
-
-#define S_T6_FIXED_VF 0
-#define M_T6_FIXED_VF 0xffU
-#define V_T6_FIXED_VF(x) ((x) << S_T6_FIXED_VF)
-#define G_T6_FIXED_VF(x) (((x) >> S_T6_FIXED_VF) & M_T6_FIXED_VF)
-
-#define A_MPS_PORT_RX_SPARE 0x13c
-#define A_MPS_PORT_RX_PTP_RSS_HASH 0x140
-#define A_MPS_PORT_RX_PTP_RSS_CONTROL 0x144
-#define A_MPS_PORT_RX_TS_VLD 0x148
-
-#define S_TS_VLD 0
-#define M_TS_VLD 0x3U
-#define V_TS_VLD(x) ((x) << S_TS_VLD)
-#define G_TS_VLD(x) (((x) >> S_TS_VLD) & M_TS_VLD)
-
-#define A_MPS_PORT_RX_TNL_LKP_INNER_SEL 0x14c
-
-#define S_LKP_SEL 0
-#define V_LKP_SEL(x) ((x) << S_LKP_SEL)
-#define F_LKP_SEL V_LKP_SEL(1U)
-
-#define A_MPS_PORT_RX_VF_MAP4 0x150
-#define A_MPS_PORT_RX_VF_MAP5 0x154
-#define A_MPS_PORT_RX_VF_MAP6 0x158
-#define A_MPS_PORT_RX_VF_MAP7 0x15c
-#define A_MPS_PORT_RX_PRS_DEBUG_FLAG_MAC 0x160
-
-#define S_OUTER_IPV4_N_INNER_IPV4 31
-#define V_OUTER_IPV4_N_INNER_IPV4(x) ((x) << S_OUTER_IPV4_N_INNER_IPV4)
-#define F_OUTER_IPV4_N_INNER_IPV4 V_OUTER_IPV4_N_INNER_IPV4(1U)
-
-#define S_OUTER_IPV4_N_INNER_IPV6 30
-#define V_OUTER_IPV4_N_INNER_IPV6(x) ((x) << S_OUTER_IPV4_N_INNER_IPV6)
-#define F_OUTER_IPV4_N_INNER_IPV6 V_OUTER_IPV4_N_INNER_IPV6(1U)
-
-#define S_OUTER_IPV6_N_INNER_IPV4 29
-#define V_OUTER_IPV6_N_INNER_IPV4(x) ((x) << S_OUTER_IPV6_N_INNER_IPV4)
-#define F_OUTER_IPV6_N_INNER_IPV4 V_OUTER_IPV6_N_INNER_IPV4(1U)
-
-#define S_OUTER_IPV6_N_INNER_IPV6 28
-#define V_OUTER_IPV6_N_INNER_IPV6(x) ((x) << S_OUTER_IPV6_N_INNER_IPV6)
-#define F_OUTER_IPV6_N_INNER_IPV6 V_OUTER_IPV6_N_INNER_IPV6(1U)
-
-#define S_OUTER_IPV4_N_VLAN_NVGRE 27
-#define V_OUTER_IPV4_N_VLAN_NVGRE(x) ((x) << S_OUTER_IPV4_N_VLAN_NVGRE)
-#define F_OUTER_IPV4_N_VLAN_NVGRE V_OUTER_IPV4_N_VLAN_NVGRE(1U)
-
-#define S_OUTER_IPV6_N_VLAN_NVGRE 26
-#define V_OUTER_IPV6_N_VLAN_NVGRE(x) ((x) << S_OUTER_IPV6_N_VLAN_NVGRE)
-#define F_OUTER_IPV6_N_VLAN_NVGRE V_OUTER_IPV6_N_VLAN_NVGRE(1U)
-
-#define S_OUTER_IPV4_N_DOUBLE_VLAN_NVGRE 25
-#define V_OUTER_IPV4_N_DOUBLE_VLAN_NVGRE(x) ((x) << S_OUTER_IPV4_N_DOUBLE_VLAN_NVGRE)
-#define F_OUTER_IPV4_N_DOUBLE_VLAN_NVGRE V_OUTER_IPV4_N_DOUBLE_VLAN_NVGRE(1U)
-
-#define S_OUTER_IPV6_N_DOUBLE_VLAN_NVGRE 24
-#define V_OUTER_IPV6_N_DOUBLE_VLAN_NVGRE(x) ((x) << S_OUTER_IPV6_N_DOUBLE_VLAN_NVGRE)
-#define F_OUTER_IPV6_N_DOUBLE_VLAN_NVGRE V_OUTER_IPV6_N_DOUBLE_VLAN_NVGRE(1U)
-
-#define S_OUTER_IPV4_N_VLAN_GRE 23
-#define V_OUTER_IPV4_N_VLAN_GRE(x) ((x) << S_OUTER_IPV4_N_VLAN_GRE)
-#define F_OUTER_IPV4_N_VLAN_GRE V_OUTER_IPV4_N_VLAN_GRE(1U)
-
-#define S_OUTER_IPV6_N_VLAN_GRE 22
-#define V_OUTER_IPV6_N_VLAN_GRE(x) ((x) << S_OUTER_IPV6_N_VLAN_GRE)
-#define F_OUTER_IPV6_N_VLAN_GRE V_OUTER_IPV6_N_VLAN_GRE(1U)
-
-#define S_OUTER_IPV4_N_DOUBLE_VLAN_GRE 21
-#define V_OUTER_IPV4_N_DOUBLE_VLAN_GRE(x) ((x) << S_OUTER_IPV4_N_DOUBLE_VLAN_GRE)
-#define F_OUTER_IPV4_N_DOUBLE_VLAN_GRE V_OUTER_IPV4_N_DOUBLE_VLAN_GRE(1U)
-
-#define S_OUTER_IPV6_N_DOUBLE_VLAN_GRE 20
-#define V_OUTER_IPV6_N_DOUBLE_VLAN_GRE(x) ((x) << S_OUTER_IPV6_N_DOUBLE_VLAN_GRE)
-#define F_OUTER_IPV6_N_DOUBLE_VLAN_GRE V_OUTER_IPV6_N_DOUBLE_VLAN_GRE(1U)
-
-#define S_OUTER_IPV4_N_VLAN_VXLAN 19
-#define V_OUTER_IPV4_N_VLAN_VXLAN(x) ((x) << S_OUTER_IPV4_N_VLAN_VXLAN)
-#define F_OUTER_IPV4_N_VLAN_VXLAN V_OUTER_IPV4_N_VLAN_VXLAN(1U)
-
-#define S_OUTER_IPV6_N_VLAN_VXLAN 18
-#define V_OUTER_IPV6_N_VLAN_VXLAN(x) ((x) << S_OUTER_IPV6_N_VLAN_VXLAN)
-#define F_OUTER_IPV6_N_VLAN_VXLAN V_OUTER_IPV6_N_VLAN_VXLAN(1U)
-
-#define S_OUTER_IPV4_N_DOUBLE_VLAN_VXLAN 17
-#define V_OUTER_IPV4_N_DOUBLE_VLAN_VXLAN(x) ((x) << S_OUTER_IPV4_N_DOUBLE_VLAN_VXLAN)
-#define F_OUTER_IPV4_N_DOUBLE_VLAN_VXLAN V_OUTER_IPV4_N_DOUBLE_VLAN_VXLAN(1U)
-
-#define S_OUTER_IPV6_N_DOUBLE_VLAN_VXLAN 16
-#define V_OUTER_IPV6_N_DOUBLE_VLAN_VXLAN(x) ((x) << S_OUTER_IPV6_N_DOUBLE_VLAN_VXLAN)
-#define F_OUTER_IPV6_N_DOUBLE_VLAN_VXLAN V_OUTER_IPV6_N_DOUBLE_VLAN_VXLAN(1U)
-
-#define S_OUTER_IPV4_N_VLAN_GENEVE 15
-#define V_OUTER_IPV4_N_VLAN_GENEVE(x) ((x) << S_OUTER_IPV4_N_VLAN_GENEVE)
-#define F_OUTER_IPV4_N_VLAN_GENEVE V_OUTER_IPV4_N_VLAN_GENEVE(1U)
-
-#define S_OUTER_IPV6_N_VLAN_GENEVE 14
-#define V_OUTER_IPV6_N_VLAN_GENEVE(x) ((x) << S_OUTER_IPV6_N_VLAN_GENEVE)
-#define F_OUTER_IPV6_N_VLAN_GENEVE V_OUTER_IPV6_N_VLAN_GENEVE(1U)
-
-#define S_OUTER_IPV4_N_DOUBLE_VLAN_GENEVE 13
-#define V_OUTER_IPV4_N_DOUBLE_VLAN_GENEVE(x) ((x) << S_OUTER_IPV4_N_DOUBLE_VLAN_GENEVE)
-#define F_OUTER_IPV4_N_DOUBLE_VLAN_GENEVE V_OUTER_IPV4_N_DOUBLE_VLAN_GENEVE(1U)
-
-#define S_OUTER_IPV6_N_DOUBLE_VLAN_GENEVE 12
-#define V_OUTER_IPV6_N_DOUBLE_VLAN_GENEVE(x) ((x) << S_OUTER_IPV6_N_DOUBLE_VLAN_GENEVE)
-#define F_OUTER_IPV6_N_DOUBLE_VLAN_GENEVE V_OUTER_IPV6_N_DOUBLE_VLAN_GENEVE(1U)
-
-#define S_ERR_TNL_HDR_LEN 11
-#define V_ERR_TNL_HDR_LEN(x) ((x) << S_ERR_TNL_HDR_LEN)
-#define F_ERR_TNL_HDR_LEN V_ERR_TNL_HDR_LEN(1U)
-
-#define S_NON_RUNT_FRAME 10
-#define V_NON_RUNT_FRAME(x) ((x) << S_NON_RUNT_FRAME)
-#define F_NON_RUNT_FRAME V_NON_RUNT_FRAME(1U)
-
-#define S_INNER_VLAN_VLD 9
-#define V_INNER_VLAN_VLD(x) ((x) << S_INNER_VLAN_VLD)
-#define F_INNER_VLAN_VLD V_INNER_VLAN_VLD(1U)
-
-#define S_ERR_IP_PAYLOAD_LEN 8
-#define V_ERR_IP_PAYLOAD_LEN(x) ((x) << S_ERR_IP_PAYLOAD_LEN)
-#define F_ERR_IP_PAYLOAD_LEN V_ERR_IP_PAYLOAD_LEN(1U)
-
-#define S_ERR_UDP_PAYLOAD_LEN 7
-#define V_ERR_UDP_PAYLOAD_LEN(x) ((x) << S_ERR_UDP_PAYLOAD_LEN)
-#define F_ERR_UDP_PAYLOAD_LEN V_ERR_UDP_PAYLOAD_LEN(1U)
-
-#define A_MPS_PORT_RX_PRS_DEBUG_FLAG_LPBK 0x164
-
-#define S_T6_INNER_VLAN_VLD 10
-#define V_T6_INNER_VLAN_VLD(x) ((x) << S_T6_INNER_VLAN_VLD)
-#define F_T6_INNER_VLAN_VLD V_T6_INNER_VLAN_VLD(1U)
-
-#define S_T6_ERR_IP_PAYLOAD_LEN 9
-#define V_T6_ERR_IP_PAYLOAD_LEN(x) ((x) << S_T6_ERR_IP_PAYLOAD_LEN)
-#define F_T6_ERR_IP_PAYLOAD_LEN V_T6_ERR_IP_PAYLOAD_LEN(1U)
-
-#define S_T6_ERR_UDP_PAYLOAD_LEN 8
-#define V_T6_ERR_UDP_PAYLOAD_LEN(x) ((x) << S_T6_ERR_UDP_PAYLOAD_LEN)
-#define F_T6_ERR_UDP_PAYLOAD_LEN V_T6_ERR_UDP_PAYLOAD_LEN(1U)
-
-#define A_MPS_PORT_RX_REPL_VECT_SEL 0x168
-
-#define S_DIS_REPL_VECT_SEL 4
-#define V_DIS_REPL_VECT_SEL(x) ((x) << S_DIS_REPL_VECT_SEL)
-#define F_DIS_REPL_VECT_SEL V_DIS_REPL_VECT_SEL(1U)
-
-#define S_REPL_VECT_SEL 0
-#define M_REPL_VECT_SEL 0xfU
-#define V_REPL_VECT_SEL(x) ((x) << S_REPL_VECT_SEL)
-#define G_REPL_VECT_SEL(x) (((x) >> S_REPL_VECT_SEL) & M_REPL_VECT_SEL)
-
-#define A_MPS_PORT_TX_MAC_RELOAD_CH0 0x190
-
-#define S_CREDIT 0
-#define M_CREDIT 0xffffU
-#define V_CREDIT(x) ((x) << S_CREDIT)
-#define G_CREDIT(x) (((x) >> S_CREDIT) & M_CREDIT)
-
-#define A_MPS_PORT_TX_MAC_RELOAD_CH1 0x194
-#define A_MPS_PORT_TX_MAC_RELOAD_CH2 0x198
-#define A_MPS_PORT_TX_MAC_RELOAD_CH3 0x19c
-#define A_MPS_PORT_TX_MAC_RELOAD_CH4 0x1a0
-#define A_MPS_PORT_TX_LPBK_RELOAD_CH0 0x1a8
-#define A_MPS_PORT_TX_LPBK_RELOAD_CH1 0x1ac
-#define A_MPS_PORT_TX_LPBK_RELOAD_CH2 0x1b0
-#define A_MPS_PORT_TX_LPBK_RELOAD_CH3 0x1b4
-#define A_MPS_PORT_TX_LPBK_RELOAD_CH4 0x1b8
-#define A_MPS_PORT_TX_FIFO_CTL 0x1c4
-
-#define S_FIFOTH 5
-#define M_FIFOTH 0x1ffU
-#define V_FIFOTH(x) ((x) << S_FIFOTH)
-#define G_FIFOTH(x) (((x) >> S_FIFOTH) & M_FIFOTH)
-
-#define S_FIFOEN 4
-#define V_FIFOEN(x) ((x) << S_FIFOEN)
-#define F_FIFOEN V_FIFOEN(1U)
-
-#define S_MAXPKTCNT 0
-#define M_MAXPKTCNT 0xfU
-#define V_MAXPKTCNT(x) ((x) << S_MAXPKTCNT)
-#define G_MAXPKTCNT(x) (((x) >> S_MAXPKTCNT) & M_MAXPKTCNT)
-
-#define S_OUT_TH 22
-#define M_OUT_TH 0xffU
-#define V_OUT_TH(x) ((x) << S_OUT_TH)
-#define G_OUT_TH(x) (((x) >> S_OUT_TH) & M_OUT_TH)
-
-#define S_IN_TH 14
-#define M_IN_TH 0xffU
-#define V_IN_TH(x) ((x) << S_IN_TH)
-#define G_IN_TH(x) (((x) >> S_IN_TH) & M_IN_TH)
-
-#define A_MPS_PORT_FPGA_PAUSE_CTL 0x1c8
-
-#define S_FPGAPAUSEEN 0
-#define V_FPGAPAUSEEN(x) ((x) << S_FPGAPAUSEEN)
-#define F_FPGAPAUSEEN V_FPGAPAUSEEN(1U)
-
-#define A_MPS_PORT_TX_PAUSE_PENDING_STATUS 0x1d0
-
-#define S_OFF_PENDING 8
-#define M_OFF_PENDING 0xffU
-#define V_OFF_PENDING(x) ((x) << S_OFF_PENDING)
-#define G_OFF_PENDING(x) (((x) >> S_OFF_PENDING) & M_OFF_PENDING)
-
-#define S_ON_PENDING 0
-#define M_ON_PENDING 0xffU
-#define V_ON_PENDING(x) ((x) << S_ON_PENDING)
-#define G_ON_PENDING(x) (((x) >> S_ON_PENDING) & M_ON_PENDING)
-
-#define A_MPS_PORT_CLS_HASH_SRAM 0x200
-
-#define S_VALID 20
-#define V_VALID(x) ((x) << S_VALID)
-#define F_VALID V_VALID(1U)
-
-#define S_HASHPORTMAP 16
-#define M_HASHPORTMAP 0xfU
-#define V_HASHPORTMAP(x) ((x) << S_HASHPORTMAP)
-#define G_HASHPORTMAP(x) (((x) >> S_HASHPORTMAP) & M_HASHPORTMAP)
-
-#define S_MULTILISTEN 15
-#define V_MULTILISTEN(x) ((x) << S_MULTILISTEN)
-#define F_MULTILISTEN V_MULTILISTEN(1U)
-
-#define S_PRIORITY 12
-#define M_PRIORITY 0x7U
-#define V_PRIORITY(x) ((x) << S_PRIORITY)
-#define G_PRIORITY(x) (((x) >> S_PRIORITY) & M_PRIORITY)
-
-#define S_REPLICATE 11
-#define V_REPLICATE(x) ((x) << S_REPLICATE)
-#define F_REPLICATE V_REPLICATE(1U)
-
-#define S_PF 8
-#define M_PF 0x7U
-#define V_PF(x) ((x) << S_PF)
-#define G_PF(x) (((x) >> S_PF) & M_PF)
-
-#define S_VF_VALID 7
-#define V_VF_VALID(x) ((x) << S_VF_VALID)
-#define F_VF_VALID V_VF_VALID(1U)
-
-#define S_VF 0
-#define M_VF 0x7fU
-#define V_VF(x) ((x) << S_VF)
-#define G_VF(x) (((x) >> S_VF) & M_VF)
-
-#define S_DISENCAPOUTERRPLCT 23
-#define V_DISENCAPOUTERRPLCT(x) ((x) << S_DISENCAPOUTERRPLCT)
-#define F_DISENCAPOUTERRPLCT V_DISENCAPOUTERRPLCT(1U)
-
-#define S_DISENCAP 22
-#define V_DISENCAP(x) ((x) << S_DISENCAP)
-#define F_DISENCAP V_DISENCAP(1U)
-
-#define S_T6_VALID 21
-#define V_T6_VALID(x) ((x) << S_T6_VALID)
-#define F_T6_VALID V_T6_VALID(1U)
-
-#define S_T6_HASHPORTMAP 17
-#define M_T6_HASHPORTMAP 0xfU
-#define V_T6_HASHPORTMAP(x) ((x) << S_T6_HASHPORTMAP)
-#define G_T6_HASHPORTMAP(x) (((x) >> S_T6_HASHPORTMAP) & M_T6_HASHPORTMAP)
-
-#define S_T6_MULTILISTEN 16
-#define V_T6_MULTILISTEN(x) ((x) << S_T6_MULTILISTEN)
-#define F_T6_MULTILISTEN V_T6_MULTILISTEN(1U)
-
-#define S_T6_PRIORITY 13
-#define M_T6_PRIORITY 0x7U
-#define V_T6_PRIORITY(x) ((x) << S_T6_PRIORITY)
-#define G_T6_PRIORITY(x) (((x) >> S_T6_PRIORITY) & M_T6_PRIORITY)
-
-#define S_T6_REPLICATE 12
-#define V_T6_REPLICATE(x) ((x) << S_T6_REPLICATE)
-#define F_T6_REPLICATE V_T6_REPLICATE(1U)
-
-#define S_T6_PF 9
-#define M_T6_PF 0x7U
-#define V_T6_PF(x) ((x) << S_T6_PF)
-#define G_T6_PF(x) (((x) >> S_T6_PF) & M_T6_PF)
-
-#define S_T6_VF_VALID 8
-#define V_T6_VF_VALID(x) ((x) << S_T6_VF_VALID)
-#define F_T6_VF_VALID V_T6_VF_VALID(1U)
-
-#define S_T6_VF 0
-#define M_T6_VF 0xffU
-#define V_T6_VF(x) ((x) << S_T6_VF)
-#define G_T6_VF(x) (((x) >> S_T6_VF) & M_T6_VF)
-
-#define A_MPS_PF_CTL 0x2c0
-
-#define S_TXEN 1
-#define V_TXEN(x) ((x) << S_TXEN)
-#define F_TXEN V_TXEN(1U)
-
-#define S_RXEN 0
-#define V_RXEN(x) ((x) << S_RXEN)
-#define F_RXEN V_RXEN(1U)
-
-#define A_MPS_PF_TX_QINQ_VLAN 0x2e0
-
-#define S_PROTOCOLID 16
-#define M_PROTOCOLID 0xffffU
-#define V_PROTOCOLID(x) ((x) << S_PROTOCOLID)
-#define G_PROTOCOLID(x) (((x) >> S_PROTOCOLID) & M_PROTOCOLID)
-
-#define S_VLAN_PRIO 13
-#define M_VLAN_PRIO 0x7U
-#define V_VLAN_PRIO(x) ((x) << S_VLAN_PRIO)
-#define G_VLAN_PRIO(x) (((x) >> S_VLAN_PRIO) & M_VLAN_PRIO)
-
-#define S_CFI 12
-#define V_CFI(x) ((x) << S_CFI)
-#define F_CFI V_CFI(1U)
-
-#define S_TAG 0
-#define M_TAG 0xfffU
-#define V_TAG(x) ((x) << S_TAG)
-#define G_TAG(x) (((x) >> S_TAG) & M_TAG)
-
-#define A_MPS_PF_STAT_TX_PF_BCAST_BYTES_L 0x300
-#define A_MPS_PF_STAT_TX_PF_BCAST_BYTES_H 0x304
-#define A_MPS_PORT_CLS_HASH_CTL 0x304
-
-#define S_UNICASTENABLE 31
-#define V_UNICASTENABLE(x) ((x) << S_UNICASTENABLE)
-#define F_UNICASTENABLE V_UNICASTENABLE(1U)
-
-#define A_MPS_PF_STAT_TX_PF_BCAST_FRAMES_L 0x308
-#define A_MPS_PORT_CLS_PROMISCUOUS_CTL 0x308
-
-#define S_PROMISCEN 31
-#define V_PROMISCEN(x) ((x) << S_PROMISCEN)
-#define F_PROMISCEN V_PROMISCEN(1U)
-
-#define S_T6_MULTILISTEN 16
-#define V_T6_MULTILISTEN(x) ((x) << S_T6_MULTILISTEN)
-#define F_T6_MULTILISTEN V_T6_MULTILISTEN(1U)
-
-#define S_T6_PRIORITY 13
-#define M_T6_PRIORITY 0x7U
-#define V_T6_PRIORITY(x) ((x) << S_T6_PRIORITY)
-#define G_T6_PRIORITY(x) (((x) >> S_T6_PRIORITY) & M_T6_PRIORITY)
-
-#define S_T6_REPLICATE 12
-#define V_T6_REPLICATE(x) ((x) << S_T6_REPLICATE)
-#define F_T6_REPLICATE V_T6_REPLICATE(1U)
-
-#define S_T6_PF 9
-#define M_T6_PF 0x7U
-#define V_T6_PF(x) ((x) << S_T6_PF)
-#define G_T6_PF(x) (((x) >> S_T6_PF) & M_T6_PF)
-
-#define S_T6_VF_VALID 8
-#define V_T6_VF_VALID(x) ((x) << S_T6_VF_VALID)
-#define F_T6_VF_VALID V_T6_VF_VALID(1U)
-
-#define S_T6_VF 0
-#define M_T6_VF 0xffU
-#define V_T6_VF(x) ((x) << S_T6_VF)
-#define G_T6_VF(x) (((x) >> S_T6_VF) & M_T6_VF)
-
-#define A_MPS_PF_STAT_TX_PF_BCAST_FRAMES_H 0x30c
-#define A_MPS_PORT_CLS_BMC_MAC_ADDR_L 0x30c
-#define A_MPS_PF_STAT_TX_PF_MCAST_BYTES_L 0x310
-#define A_MPS_PORT_CLS_BMC_MAC_ADDR_H 0x310
-
-#define S_MATCHBOTH 17
-#define V_MATCHBOTH(x) ((x) << S_MATCHBOTH)
-#define F_MATCHBOTH V_MATCHBOTH(1U)
-
-#define S_BMC_VLD 16
-#define V_BMC_VLD(x) ((x) << S_BMC_VLD)
-#define F_BMC_VLD V_BMC_VLD(1U)
-
-#define S_MATCHALL 18
-#define V_MATCHALL(x) ((x) << S_MATCHALL)
-#define F_MATCHALL V_MATCHALL(1U)
-
-#define A_MPS_PF_STAT_TX_PF_MCAST_BYTES_H 0x314
-#define A_MPS_PORT_CLS_BMC_VLAN 0x314
-
-#define S_BMC_VLAN_SEL 13
-#define V_BMC_VLAN_SEL(x) ((x) << S_BMC_VLAN_SEL)
-#define F_BMC_VLAN_SEL V_BMC_VLAN_SEL(1U)
-
-#define S_VLAN_VLD 12
-#define V_VLAN_VLD(x) ((x) << S_VLAN_VLD)
-#define F_VLAN_VLD V_VLAN_VLD(1U)
-
-#define A_MPS_PF_STAT_TX_PF_MCAST_FRAMES_L 0x318
-#define A_MPS_PORT_CLS_CTL 0x318
-
-#define S_PF_VLAN_SEL 0
-#define V_PF_VLAN_SEL(x) ((x) << S_PF_VLAN_SEL)
-#define F_PF_VLAN_SEL V_PF_VLAN_SEL(1U)
-
-#define S_LPBK_TCAM1_HIT_PRIORITY 14
-#define V_LPBK_TCAM1_HIT_PRIORITY(x) ((x) << S_LPBK_TCAM1_HIT_PRIORITY)
-#define F_LPBK_TCAM1_HIT_PRIORITY V_LPBK_TCAM1_HIT_PRIORITY(1U)
-
-#define S_LPBK_TCAM0_HIT_PRIORITY 13
-#define V_LPBK_TCAM0_HIT_PRIORITY(x) ((x) << S_LPBK_TCAM0_HIT_PRIORITY)
-#define F_LPBK_TCAM0_HIT_PRIORITY V_LPBK_TCAM0_HIT_PRIORITY(1U)
-
-#define S_LPBK_TCAM_PRIORITY 12
-#define V_LPBK_TCAM_PRIORITY(x) ((x) << S_LPBK_TCAM_PRIORITY)
-#define F_LPBK_TCAM_PRIORITY V_LPBK_TCAM_PRIORITY(1U)
-
-#define S_LPBK_SMAC_TCAM_SEL 10
-#define M_LPBK_SMAC_TCAM_SEL 0x3U
-#define V_LPBK_SMAC_TCAM_SEL(x) ((x) << S_LPBK_SMAC_TCAM_SEL)
-#define G_LPBK_SMAC_TCAM_SEL(x) (((x) >> S_LPBK_SMAC_TCAM_SEL) & M_LPBK_SMAC_TCAM_SEL)
-
-#define S_LPBK_DMAC_TCAM_SEL 8
-#define M_LPBK_DMAC_TCAM_SEL 0x3U
-#define V_LPBK_DMAC_TCAM_SEL(x) ((x) << S_LPBK_DMAC_TCAM_SEL)
-#define G_LPBK_DMAC_TCAM_SEL(x) (((x) >> S_LPBK_DMAC_TCAM_SEL) & M_LPBK_DMAC_TCAM_SEL)
-
-#define S_TCAM1_HIT_PRIORITY 7
-#define V_TCAM1_HIT_PRIORITY(x) ((x) << S_TCAM1_HIT_PRIORITY)
-#define F_TCAM1_HIT_PRIORITY V_TCAM1_HIT_PRIORITY(1U)
-
-#define S_TCAM0_HIT_PRIORITY 6
-#define V_TCAM0_HIT_PRIORITY(x) ((x) << S_TCAM0_HIT_PRIORITY)
-#define F_TCAM0_HIT_PRIORITY V_TCAM0_HIT_PRIORITY(1U)
-
-#define S_TCAM_PRIORITY 5
-#define V_TCAM_PRIORITY(x) ((x) << S_TCAM_PRIORITY)
-#define F_TCAM_PRIORITY V_TCAM_PRIORITY(1U)
-
-#define S_SMAC_TCAM_SEL 3
-#define M_SMAC_TCAM_SEL 0x3U
-#define V_SMAC_TCAM_SEL(x) ((x) << S_SMAC_TCAM_SEL)
-#define G_SMAC_TCAM_SEL(x) (((x) >> S_SMAC_TCAM_SEL) & M_SMAC_TCAM_SEL)
-
-#define S_DMAC_TCAM_SEL 1
-#define M_DMAC_TCAM_SEL 0x3U
-#define V_DMAC_TCAM_SEL(x) ((x) << S_DMAC_TCAM_SEL)
-#define G_DMAC_TCAM_SEL(x) (((x) >> S_DMAC_TCAM_SEL) & M_DMAC_TCAM_SEL)
-
-#define A_MPS_PF_STAT_TX_PF_MCAST_FRAMES_H 0x31c
-#define A_MPS_PORT_CLS_NCSI_ETH_TYPE 0x31c
-
-#define S_ETHTYPE2 0
-#define M_ETHTYPE2 0xffffU
-#define V_ETHTYPE2(x) ((x) << S_ETHTYPE2)
-#define G_ETHTYPE2(x) (((x) >> S_ETHTYPE2) & M_ETHTYPE2)
-
-#define A_MPS_PF_STAT_TX_PF_UCAST_BYTES_L 0x320
-#define A_MPS_PORT_CLS_NCSI_ETH_TYPE_EN 0x320
-
-#define S_EN1 1
-#define V_EN1(x) ((x) << S_EN1)
-#define F_EN1 V_EN1(1U)
-
-#define S_EN2 0
-#define V_EN2(x) ((x) << S_EN2)
-#define F_EN2 V_EN2(1U)
-
-#define A_MPS_PF_STAT_TX_PF_UCAST_BYTES_H 0x324
-#define A_MPS_PF_STAT_TX_PF_UCAST_FRAMES_L 0x328
-#define A_MPS_PF_STAT_TX_PF_UCAST_FRAMES_H 0x32c
-#define A_MPS_PF_STAT_TX_PF_OFFLOAD_BYTES_L 0x330
-#define A_MPS_PF_STAT_TX_PF_OFFLOAD_BYTES_H 0x334
-#define A_MPS_PF_STAT_TX_PF_OFFLOAD_FRAMES_L 0x338
-#define A_MPS_PF_STAT_TX_PF_OFFLOAD_FRAMES_H 0x33c
-#define A_MPS_PF_STAT_RX_PF_BYTES_L 0x340
-#define A_MPS_PF_STAT_RX_PF_BYTES_H 0x344
-#define A_MPS_PF_STAT_RX_PF_FRAMES_L 0x348
-#define A_MPS_PF_STAT_RX_PF_FRAMES_H 0x34c
-#define A_MPS_PF_STAT_RX_PF_BCAST_BYTES_L 0x350
-#define A_MPS_PF_STAT_RX_PF_BCAST_BYTES_H 0x354
-#define A_MPS_PF_STAT_RX_PF_BCAST_FRAMES_L 0x358
-#define A_MPS_PF_STAT_RX_PF_BCAST_FRAMES_H 0x35c
-#define A_MPS_PF_STAT_RX_PF_MCAST_BYTES_L 0x360
-#define A_MPS_PF_STAT_RX_PF_MCAST_BYTES_H 0x364
-#define A_MPS_PF_STAT_RX_PF_MCAST_FRAMES_L 0x368
-#define A_MPS_PF_STAT_RX_PF_MCAST_FRAMES_H 0x36c
-#define A_MPS_PF_STAT_RX_PF_UCAST_BYTES_L 0x370
-#define A_MPS_PF_STAT_RX_PF_UCAST_BYTES_H 0x374
-#define A_MPS_PF_STAT_RX_PF_UCAST_FRAMES_L 0x378
-#define A_MPS_PF_STAT_RX_PF_UCAST_FRAMES_H 0x37c
-#define A_MPS_PF_STAT_RX_PF_ERR_FRAMES_L 0x380
-#define A_MPS_PF_STAT_RX_PF_ERR_FRAMES_H 0x384
-#define A_MPS_PORT_STAT_TX_PORT_BYTES_L 0x400
-#define A_MPS_PORT_STAT_TX_PORT_BYTES_H 0x404
-#define A_MPS_PORT_STAT_TX_PORT_FRAMES_L 0x408
-#define A_MPS_PORT_STAT_TX_PORT_FRAMES_H 0x40c
-#define A_MPS_PORT_STAT_TX_PORT_BCAST_L 0x410
-#define A_MPS_PORT_STAT_TX_PORT_BCAST_H 0x414
-#define A_MPS_PORT_STAT_TX_PORT_MCAST_L 0x418
-#define A_MPS_PORT_STAT_TX_PORT_MCAST_H 0x41c
-#define A_MPS_PORT_STAT_TX_PORT_UCAST_L 0x420
-#define A_MPS_PORT_STAT_TX_PORT_UCAST_H 0x424
-#define A_MPS_PORT_STAT_TX_PORT_ERROR_L 0x428
-#define A_MPS_PORT_STAT_TX_PORT_ERROR_H 0x42c
-#define A_MPS_PORT_STAT_TX_PORT_64B_L 0x430
-#define A_MPS_PORT_STAT_TX_PORT_64B_H 0x434
-#define A_MPS_PORT_STAT_TX_PORT_65B_127B_L 0x438
-#define A_MPS_PORT_STAT_TX_PORT_65B_127B_H 0x43c
-#define A_MPS_PORT_STAT_TX_PORT_128B_255B_L 0x440
-#define A_MPS_PORT_STAT_TX_PORT_128B_255B_H 0x444
-#define A_MPS_PORT_STAT_TX_PORT_256B_511B_L 0x448
-#define A_MPS_PORT_STAT_TX_PORT_256B_511B_H 0x44c
-#define A_MPS_PORT_STAT_TX_PORT_512B_1023B_L 0x450
-#define A_MPS_PORT_STAT_TX_PORT_512B_1023B_H 0x454
-#define A_MPS_PORT_STAT_TX_PORT_1024B_1518B_L 0x458
-#define A_MPS_PORT_STAT_TX_PORT_1024B_1518B_H 0x45c
-#define A_MPS_PORT_STAT_TX_PORT_1519B_MAX_L 0x460
-#define A_MPS_PORT_STAT_TX_PORT_1519B_MAX_H 0x464
-#define A_MPS_PORT_STAT_TX_PORT_DROP_L 0x468
-#define A_MPS_PORT_STAT_TX_PORT_DROP_H 0x46c
-#define A_MPS_PORT_STAT_TX_PORT_PAUSE_L 0x470
-#define A_MPS_PORT_STAT_TX_PORT_PAUSE_H 0x474
-#define A_MPS_PORT_STAT_TX_PORT_PPP0_L 0x478
-#define A_MPS_PORT_STAT_TX_PORT_PPP0_H 0x47c
-#define A_MPS_PORT_STAT_TX_PORT_PPP1_L 0x480
-#define A_MPS_PORT_STAT_TX_PORT_PPP1_H 0x484
-#define A_MPS_PORT_STAT_TX_PORT_PPP2_L 0x488
-#define A_MPS_PORT_STAT_TX_PORT_PPP2_H 0x48c
-#define A_MPS_PORT_STAT_TX_PORT_PPP3_L 0x490
-#define A_MPS_PORT_STAT_TX_PORT_PPP3_H 0x494
-#define A_MPS_PORT_STAT_TX_PORT_PPP4_L 0x498
-#define A_MPS_PORT_STAT_TX_PORT_PPP4_H 0x49c
-#define A_MPS_PORT_STAT_TX_PORT_PPP5_L 0x4a0
-#define A_MPS_PORT_STAT_TX_PORT_PPP5_H 0x4a4
-#define A_MPS_PORT_STAT_TX_PORT_PPP6_L 0x4a8
-#define A_MPS_PORT_STAT_TX_PORT_PPP6_H 0x4ac
-#define A_MPS_PORT_STAT_TX_PORT_PPP7_L 0x4b0
-#define A_MPS_PORT_STAT_TX_PORT_PPP7_H 0x4b4
-#define A_MPS_PORT_STAT_LB_PORT_BYTES_L 0x4c0
-#define A_MPS_PORT_STAT_LB_PORT_BYTES_H 0x4c4
-#define A_MPS_PORT_STAT_LB_PORT_FRAMES_L 0x4c8
-#define A_MPS_PORT_STAT_LB_PORT_FRAMES_H 0x4cc
-#define A_MPS_PORT_STAT_LB_PORT_BCAST_L 0x4d0
-#define A_MPS_PORT_STAT_LB_PORT_BCAST_H 0x4d4
-#define A_MPS_PORT_STAT_LB_PORT_MCAST_L 0x4d8
-#define A_MPS_PORT_STAT_LB_PORT_MCAST_H 0x4dc
-#define A_MPS_PORT_STAT_LB_PORT_UCAST_L 0x4e0
-#define A_MPS_PORT_STAT_LB_PORT_UCAST_H 0x4e4
-#define A_MPS_PORT_STAT_LB_PORT_ERROR_L 0x4e8
-#define A_MPS_PORT_STAT_LB_PORT_ERROR_H 0x4ec
-#define A_MPS_PORT_STAT_LB_PORT_64B_L 0x4f0
-#define A_MPS_PORT_STAT_LB_PORT_64B_H 0x4f4
-#define A_MPS_PORT_STAT_LB_PORT_65B_127B_L 0x4f8
-#define A_MPS_PORT_STAT_LB_PORT_65B_127B_H 0x4fc
-#define A_MPS_PORT_STAT_LB_PORT_128B_255B_L 0x500
-#define A_MPS_PORT_STAT_LB_PORT_128B_255B_H 0x504
-#define A_MPS_PORT_STAT_LB_PORT_256B_511B_L 0x508
-#define A_MPS_PORT_STAT_LB_PORT_256B_511B_H 0x50c
-#define A_MPS_PORT_STAT_LB_PORT_512B_1023B_L 0x510
-#define A_MPS_PORT_STAT_LB_PORT_512B_1023B_H 0x514
-#define A_MPS_PORT_STAT_LB_PORT_1024B_1518B_L 0x518
-#define A_MPS_PORT_STAT_LB_PORT_1024B_1518B_H 0x51c
-#define A_MPS_PORT_STAT_LB_PORT_1519B_MAX_L 0x520
-#define A_MPS_PORT_STAT_LB_PORT_1519B_MAX_H 0x524
-#define A_MPS_PORT_STAT_LB_PORT_DROP_FRAMES 0x528
-#define A_MPS_PORT_STAT_LB_PORT_DROP_FRAMES_L 0x528
-#define A_MPS_PORT_STAT_LB_PORT_DROP_FRAMES_H 0x52c
-#define A_MPS_PORT_STAT_RX_PORT_BYTES_L 0x540
-#define A_MPS_PORT_STAT_RX_PORT_BYTES_H 0x544
-#define A_MPS_PORT_STAT_RX_PORT_FRAMES_L 0x548
-#define A_MPS_PORT_STAT_RX_PORT_FRAMES_H 0x54c
-#define A_MPS_PORT_STAT_RX_PORT_BCAST_L 0x550
-#define A_MPS_PORT_STAT_RX_PORT_BCAST_H 0x554
-#define A_MPS_PORT_STAT_RX_PORT_MCAST_L 0x558
-#define A_MPS_PORT_STAT_RX_PORT_MCAST_H 0x55c
-#define A_MPS_PORT_STAT_RX_PORT_UCAST_L 0x560
-#define A_MPS_PORT_STAT_RX_PORT_UCAST_H 0x564
-#define A_MPS_PORT_STAT_RX_PORT_MTU_ERROR_L 0x568
-#define A_MPS_PORT_STAT_RX_PORT_MTU_ERROR_H 0x56c
-#define A_MPS_PORT_STAT_RX_PORT_MTU_CRC_ERROR_L 0x570
-#define A_MPS_PORT_STAT_RX_PORT_MTU_CRC_ERROR_H 0x574
-#define A_MPS_PORT_STAT_RX_PORT_CRC_ERROR_L 0x578
-#define A_MPS_PORT_STAT_RX_PORT_CRC_ERROR_H 0x57c
-#define A_MPS_PORT_STAT_RX_PORT_LEN_ERROR_L 0x580
-#define A_MPS_PORT_STAT_RX_PORT_LEN_ERROR_H 0x584
-#define A_MPS_PORT_STAT_RX_PORT_SYM_ERROR_L 0x588
-#define A_MPS_PORT_STAT_RX_PORT_SYM_ERROR_H 0x58c
-#define A_MPS_PORT_STAT_RX_PORT_64B_L 0x590
-#define A_MPS_PORT_STAT_RX_PORT_64B_H 0x594
-#define A_MPS_PORT_STAT_RX_PORT_65B_127B_L 0x598
-#define A_MPS_PORT_STAT_RX_PORT_65B_127B_H 0x59c
-#define A_MPS_PORT_STAT_RX_PORT_128B_255B_L 0x5a0
-#define A_MPS_PORT_STAT_RX_PORT_128B_255B_H 0x5a4
-#define A_MPS_PORT_STAT_RX_PORT_256B_511B_L 0x5a8
-#define A_MPS_PORT_STAT_RX_PORT_256B_511B_H 0x5ac
-#define A_MPS_PORT_STAT_RX_PORT_512B_1023B_L 0x5b0
-#define A_MPS_PORT_STAT_RX_PORT_512B_1023B_H 0x5b4
-#define A_MPS_PORT_STAT_RX_PORT_1024B_1518B_L 0x5b8
-#define A_MPS_PORT_STAT_RX_PORT_1024B_1518B_H 0x5bc
-#define A_MPS_PORT_STAT_RX_PORT_1519B_MAX_L 0x5c0
-#define A_MPS_PORT_STAT_RX_PORT_1519B_MAX_H 0x5c4
-#define A_MPS_PORT_STAT_RX_PORT_PAUSE_L 0x5c8
-#define A_MPS_PORT_STAT_RX_PORT_PAUSE_H 0x5cc
-#define A_MPS_PORT_STAT_RX_PORT_PPP0_L 0x5d0
-#define A_MPS_PORT_STAT_RX_PORT_PPP0_H 0x5d4
-#define A_MPS_PORT_STAT_RX_PORT_PPP1_L 0x5d8
-#define A_MPS_PORT_STAT_RX_PORT_PPP1_H 0x5dc
-#define A_MPS_PORT_STAT_RX_PORT_PPP2_L 0x5e0
-#define A_MPS_PORT_STAT_RX_PORT_PPP2_H 0x5e4
-#define A_MPS_PORT_STAT_RX_PORT_PPP3_L 0x5e8
-#define A_MPS_PORT_STAT_RX_PORT_PPP3_H 0x5ec
-#define A_MPS_PORT_STAT_RX_PORT_PPP4_L 0x5f0
-#define A_MPS_PORT_STAT_RX_PORT_PPP4_H 0x5f4
-#define A_MPS_PORT_STAT_RX_PORT_PPP5_L 0x5f8
-#define A_MPS_PORT_STAT_RX_PORT_PPP5_H 0x5fc
-#define A_MPS_PORT_STAT_RX_PORT_PPP6_L 0x600
-#define A_MPS_PORT_STAT_RX_PORT_PPP6_H 0x604
-#define A_MPS_PORT_STAT_RX_PORT_PPP7_L 0x608
-#define A_MPS_PORT_STAT_RX_PORT_PPP7_H 0x60c
-#define A_MPS_PORT_STAT_RX_PORT_LESS_64B_L 0x610
-#define A_MPS_PORT_STAT_RX_PORT_LESS_64B_H 0x614
-#define A_MPS_PORT_STAT_RX_PORT_MAC_ERROR_L 0x618
-#define A_MPS_PORT_STAT_RX_PORT_MAC_ERROR_H 0x61c
-#define A_MPS_CMN_CTL 0x9000
-
-#define S_DETECT8023 3
-#define V_DETECT8023(x) ((x) << S_DETECT8023)
-#define F_DETECT8023 V_DETECT8023(1U)
-
-#define S_VFDIRECTACCESS 2
-#define V_VFDIRECTACCESS(x) ((x) << S_VFDIRECTACCESS)
-#define F_VFDIRECTACCESS V_VFDIRECTACCESS(1U)
-
-#define S_NUMPORTS 0
-#define M_NUMPORTS 0x3U
-#define V_NUMPORTS(x) ((x) << S_NUMPORTS)
-#define G_NUMPORTS(x) (((x) >> S_NUMPORTS) & M_NUMPORTS)
-
-#define S_LPBKCRDTCTRL 4
-#define V_LPBKCRDTCTRL(x) ((x) << S_LPBKCRDTCTRL)
-#define F_LPBKCRDTCTRL V_LPBKCRDTCTRL(1U)
-
-#define S_TX_PORT_STATS_MODE 8
-#define V_TX_PORT_STATS_MODE(x) ((x) << S_TX_PORT_STATS_MODE)
-#define F_TX_PORT_STATS_MODE V_TX_PORT_STATS_MODE(1U)
-
-#define S_T5MODE 7
-#define V_T5MODE(x) ((x) << S_T5MODE)
-#define F_T5MODE V_T5MODE(1U)
-
-#define S_SPEEDMODE 5
-#define M_SPEEDMODE 0x3U
-#define V_SPEEDMODE(x) ((x) << S_SPEEDMODE)
-#define G_SPEEDMODE(x) (((x) >> S_SPEEDMODE) & M_SPEEDMODE)
-
-#define A_MPS_INT_ENABLE 0x9004
-
-#define S_STATINTENB 5
-#define V_STATINTENB(x) ((x) << S_STATINTENB)
-#define F_STATINTENB V_STATINTENB(1U)
-
-#define S_TXINTENB 4
-#define V_TXINTENB(x) ((x) << S_TXINTENB)
-#define F_TXINTENB V_TXINTENB(1U)
-
-#define S_RXINTENB 3
-#define V_RXINTENB(x) ((x) << S_RXINTENB)
-#define F_RXINTENB V_RXINTENB(1U)
-
-#define S_TRCINTENB 2
-#define V_TRCINTENB(x) ((x) << S_TRCINTENB)
-#define F_TRCINTENB V_TRCINTENB(1U)
-
-#define S_CLSINTENB 1
-#define V_CLSINTENB(x) ((x) << S_CLSINTENB)
-#define F_CLSINTENB V_CLSINTENB(1U)
-
-#define S_PLINTENB 0
-#define V_PLINTENB(x) ((x) << S_PLINTENB)
-#define F_PLINTENB V_PLINTENB(1U)
-
-#define A_MPS_INT_CAUSE 0x9008
-
-#define S_STATINT 5
-#define V_STATINT(x) ((x) << S_STATINT)
-#define F_STATINT V_STATINT(1U)
-
-#define S_TXINT 4
-#define V_TXINT(x) ((x) << S_TXINT)
-#define F_TXINT V_TXINT(1U)
-
-#define S_RXINT 3
-#define V_RXINT(x) ((x) << S_RXINT)
-#define F_RXINT V_RXINT(1U)
-
-#define S_TRCINT 2
-#define V_TRCINT(x) ((x) << S_TRCINT)
-#define F_TRCINT V_TRCINT(1U)
-
-#define S_CLSINT 1
-#define V_CLSINT(x) ((x) << S_CLSINT)
-#define F_CLSINT V_CLSINT(1U)
-
-#define S_PLINT 0
-#define V_PLINT(x) ((x) << S_PLINT)
-#define F_PLINT V_PLINT(1U)
-
-#define A_MPS_CGEN_GLOBAL 0x900c
-
-#define S_MPS_GLOBAL_CGEN 0
-#define V_MPS_GLOBAL_CGEN(x) ((x) << S_MPS_GLOBAL_CGEN)
-#define F_MPS_GLOBAL_CGEN V_MPS_GLOBAL_CGEN(1U)
-
-#define A_MPS_VF_TX_CTL_31_0 0x9010
-#define A_MPS_VF_TX_CTL_63_32 0x9014
-#define A_MPS_VF_TX_CTL_95_64 0x9018
-#define A_MPS_VF_TX_CTL_127_96 0x901c
-#define A_MPS_VF_RX_CTL_31_0 0x9020
-#define A_MPS_VF_RX_CTL_63_32 0x9024
-#define A_MPS_VF_RX_CTL_95_64 0x9028
-#define A_MPS_VF_RX_CTL_127_96 0x902c
-#define A_MPS_TX_PAUSE_DURATION_BUF_GRP0 0x9030
-
-#define S_VALUE 0
-#define M_VALUE 0xffffU
-#define V_VALUE(x) ((x) << S_VALUE)
-#define G_VALUE(x) (((x) >> S_VALUE) & M_VALUE)
-
-#define A_MPS_TX_PAUSE_DURATION_BUF_GRP1 0x9034
-#define A_MPS_TX_PAUSE_DURATION_BUF_GRP2 0x9038
-#define A_MPS_TX_PAUSE_DURATION_BUF_GRP3 0x903c
-#define A_MPS_TX_PAUSE_RETRANS_BUF_GRP0 0x9040
-#define A_MPS_TX_PAUSE_RETRANS_BUF_GRP1 0x9044
-#define A_MPS_TX_PAUSE_RETRANS_BUF_GRP2 0x9048
-#define A_MPS_TX_PAUSE_RETRANS_BUF_GRP3 0x904c
-#define A_MPS_TP_CSIDE_MUX_CTL_P0 0x9050
-
-#define S_WEIGHT 0
-#define M_WEIGHT 0xfffU
-#define V_WEIGHT(x) ((x) << S_WEIGHT)
-#define G_WEIGHT(x) (((x) >> S_WEIGHT) & M_WEIGHT)
-
-#define A_MPS_TP_CSIDE_MUX_CTL_P1 0x9054
-#define A_MPS_WOL_CTL_MODE 0x9058
-
-#define S_WOL_MODE 0
-#define V_WOL_MODE(x) ((x) << S_WOL_MODE)
-#define F_WOL_MODE V_WOL_MODE(1U)
-
-#define A_MPS_FPGA_DEBUG 0x9060
-
-#define S_LPBK_EN 8
-#define V_LPBK_EN(x) ((x) << S_LPBK_EN)
-#define F_LPBK_EN V_LPBK_EN(1U)
-
-#define S_CH_MAP3 6
-#define M_CH_MAP3 0x3U
-#define V_CH_MAP3(x) ((x) << S_CH_MAP3)
-#define G_CH_MAP3(x) (((x) >> S_CH_MAP3) & M_CH_MAP3)
-
-#define S_CH_MAP2 4
-#define M_CH_MAP2 0x3U
-#define V_CH_MAP2(x) ((x) << S_CH_MAP2)
-#define G_CH_MAP2(x) (((x) >> S_CH_MAP2) & M_CH_MAP2)
-
-#define S_CH_MAP1 2
-#define M_CH_MAP1 0x3U
-#define V_CH_MAP1(x) ((x) << S_CH_MAP1)
-#define G_CH_MAP1(x) (((x) >> S_CH_MAP1) & M_CH_MAP1)
-
-#define S_CH_MAP0 0
-#define M_CH_MAP0 0x3U
-#define V_CH_MAP0(x) ((x) << S_CH_MAP0)
-#define G_CH_MAP0(x) (((x) >> S_CH_MAP0) & M_CH_MAP0)
-
-#define S_FPGA_PTP_PORT 9
-#define M_FPGA_PTP_PORT 0x3U
-#define V_FPGA_PTP_PORT(x) ((x) << S_FPGA_PTP_PORT)
-#define G_FPGA_PTP_PORT(x) (((x) >> S_FPGA_PTP_PORT) & M_FPGA_PTP_PORT)
-
-#define A_MPS_DEBUG_CTL 0x9068
-
-#define S_DBGMODECTL_H 11
-#define V_DBGMODECTL_H(x) ((x) << S_DBGMODECTL_H)
-#define F_DBGMODECTL_H V_DBGMODECTL_H(1U)
-
-#define S_DBGSEL_H 6
-#define M_DBGSEL_H 0x1fU
-#define V_DBGSEL_H(x) ((x) << S_DBGSEL_H)
-#define G_DBGSEL_H(x) (((x) >> S_DBGSEL_H) & M_DBGSEL_H)
-
-#define S_DBGMODECTL_L 5
-#define V_DBGMODECTL_L(x) ((x) << S_DBGMODECTL_L)
-#define F_DBGMODECTL_L V_DBGMODECTL_L(1U)
-
-#define S_DBGSEL_L 0
-#define M_DBGSEL_L 0x1fU
-#define V_DBGSEL_L(x) ((x) << S_DBGSEL_L)
-#define G_DBGSEL_L(x) (((x) >> S_DBGSEL_L) & M_DBGSEL_L)
-
-#define A_MPS_DEBUG_DATA_REG_L 0x906c
-#define A_MPS_DEBUG_DATA_REG_H 0x9070
-#define A_MPS_TOP_SPARE 0x9074
-
-#define S_TOPSPARE 8
-#define M_TOPSPARE 0xffffffU
-#define V_TOPSPARE(x) ((x) << S_TOPSPARE)
-#define G_TOPSPARE(x) (((x) >> S_TOPSPARE) & M_TOPSPARE)
-
-#define S_OVLANSELLPBK3 7
-#define V_OVLANSELLPBK3(x) ((x) << S_OVLANSELLPBK3)
-#define F_OVLANSELLPBK3 V_OVLANSELLPBK3(1U)
-
-#define S_OVLANSELLPBK2 6
-#define V_OVLANSELLPBK2(x) ((x) << S_OVLANSELLPBK2)
-#define F_OVLANSELLPBK2 V_OVLANSELLPBK2(1U)
-
-#define S_OVLANSELLPBK1 5
-#define V_OVLANSELLPBK1(x) ((x) << S_OVLANSELLPBK1)
-#define F_OVLANSELLPBK1 V_OVLANSELLPBK1(1U)
-
-#define S_OVLANSELLPBK0 4
-#define V_OVLANSELLPBK0(x) ((x) << S_OVLANSELLPBK0)
-#define F_OVLANSELLPBK0 V_OVLANSELLPBK0(1U)
-
-#define S_OVLANSELMAC3 3
-#define V_OVLANSELMAC3(x) ((x) << S_OVLANSELMAC3)
-#define F_OVLANSELMAC3 V_OVLANSELMAC3(1U)
-
-#define S_OVLANSELMAC2 2
-#define V_OVLANSELMAC2(x) ((x) << S_OVLANSELMAC2)
-#define F_OVLANSELMAC2 V_OVLANSELMAC2(1U)
-
-#define S_OVLANSELMAC1 1
-#define V_OVLANSELMAC1(x) ((x) << S_OVLANSELMAC1)
-#define F_OVLANSELMAC1 V_OVLANSELMAC1(1U)
-
-#define S_OVLANSELMAC0 0
-#define V_OVLANSELMAC0(x) ((x) << S_OVLANSELMAC0)
-#define F_OVLANSELMAC0 V_OVLANSELMAC0(1U)
-
-#define S_T5_TOPSPARE 8
-#define M_T5_TOPSPARE 0xffffffU
-#define V_T5_TOPSPARE(x) ((x) << S_T5_TOPSPARE)
-#define G_T5_TOPSPARE(x) (((x) >> S_T5_TOPSPARE) & M_T5_TOPSPARE)
-
-#define A_MPS_T5_BUILD_REVISION 0x9078
-#define A_MPS_TX_PAUSE_DURATION_BUF_GRP_TH0 0x907c
-#define A_MPS_TX_PAUSE_DURATION_BUF_GRP_TH1 0x9080
-#define A_MPS_TX_PAUSE_DURATION_BUF_GRP_TH2 0x9084
-#define A_MPS_TX_PAUSE_DURATION_BUF_GRP_TH3 0x9088
-#define A_MPS_TX_PAUSE_DURATION_BUF_GRP_TH4 0x908c
-#define A_MPS_TX_PAUSE_DURATION_BUF_GRP_TH5 0x9090
-#define A_MPS_TX_PAUSE_DURATION_BUF_GRP_TH6 0x9094
-#define A_MPS_TX_PAUSE_DURATION_BUF_GRP_TH7 0x9098
-#define A_MPS_TX_PAUSE_DURATION_BUF_GRP_TH8 0x909c
-#define A_MPS_TX_PAUSE_DURATION_BUF_GRP_TH9 0x90a0
-#define A_MPS_TX_PAUSE_DURATION_BUF_GRP_TH10 0x90a4
-#define A_MPS_TX_PAUSE_DURATION_BUF_GRP_TH11 0x90a8
-#define A_MPS_TX_PAUSE_DURATION_BUF_GRP_TH12 0x90ac
-#define A_MPS_TX_PAUSE_DURATION_BUF_GRP_TH13 0x90b0
-#define A_MPS_TX_PAUSE_DURATION_BUF_GRP_TH14 0x90b4
-#define A_MPS_TX_PAUSE_DURATION_BUF_GRP_TH15 0x90b8
-#define A_MPS_TX_PAUSE_RETRANS_BUF_GRP_TH0 0x90bc
-#define A_MPS_TX_PAUSE_RETRANS_BUF_GRP_TH1 0x90c0
-#define A_MPS_TX_PAUSE_RETRANS_BUF_GRP_TH2 0x90c4
-#define A_MPS_TX_PAUSE_RETRANS_BUF_GRP_TH3 0x90c8
-#define A_MPS_TX_PAUSE_RETRANS_BUF_GRP_TH4 0x90cc
-#define A_MPS_TX_PAUSE_RETRANS_BUF_GRP_TH5 0x90d0
-#define A_MPS_TX_PAUSE_RETRANS_BUF_GRP_TH6 0x90d4
-#define A_MPS_TX_PAUSE_RETRANS_BUF_GRP_TH7 0x90d8
-#define A_MPS_TX_PAUSE_RETRANS_BUF_GRP_TH8 0x90dc
-#define A_MPS_TX_PAUSE_RETRANS_BUF_GRP_TH9 0x90e0
-#define A_MPS_TX_PAUSE_RETRANS_BUF_GRP_TH10 0x90e4
-#define A_MPS_TX_PAUSE_RETRANS_BUF_GRP_TH11 0x90e8
-#define A_MPS_TX_PAUSE_RETRANS_BUF_GRP_TH12 0x90ec
-#define A_MPS_TX_PAUSE_RETRANS_BUF_GRP_TH13 0x90f0
-#define A_MPS_TX_PAUSE_RETRANS_BUF_GRP_TH14 0x90f4
-#define A_MPS_TX_PAUSE_RETRANS_BUF_GRP_TH15 0x90f8
-#define A_MPS_BUILD_REVISION 0x90fc
-#define A_MPS_VF_TX_CTL_159_128 0x9100
-#define A_MPS_VF_TX_CTL_191_160 0x9104
-#define A_MPS_VF_TX_CTL_223_192 0x9108
-#define A_MPS_VF_TX_CTL_255_224 0x910c
-#define A_MPS_VF_RX_CTL_159_128 0x9110
-#define A_MPS_VF_RX_CTL_191_160 0x9114
-#define A_MPS_VF_RX_CTL_223_192 0x9118
-#define A_MPS_VF_RX_CTL_255_224 0x911c
-#define A_MPS_FPGA_BIST_CFG_P0 0x9120
-
-#define S_ADDRMASK 16
-#define M_ADDRMASK 0xffffU
-#define V_ADDRMASK(x) ((x) << S_ADDRMASK)
-#define G_ADDRMASK(x) (((x) >> S_ADDRMASK) & M_ADDRMASK)
-
-#define S_T6_BASEADDR 0
-#define M_T6_BASEADDR 0xffffU
-#define V_T6_BASEADDR(x) ((x) << S_T6_BASEADDR)
-#define G_T6_BASEADDR(x) (((x) >> S_T6_BASEADDR) & M_T6_BASEADDR)
-
-#define A_MPS_FPGA_BIST_CFG_P1 0x9124
-
-#define S_T6_BASEADDR 0
-#define M_T6_BASEADDR 0xffffU
-#define V_T6_BASEADDR(x) ((x) << S_T6_BASEADDR)
-#define G_T6_BASEADDR(x) (((x) >> S_T6_BASEADDR) & M_T6_BASEADDR)
-
-#define A_MPS_TX_PRTY_SEL 0x9400
-
-#define S_CH4_PRTY 20
-#define M_CH4_PRTY 0x7U
-#define V_CH4_PRTY(x) ((x) << S_CH4_PRTY)
-#define G_CH4_PRTY(x) (((x) >> S_CH4_PRTY) & M_CH4_PRTY)
-
-#define S_CH3_PRTY 16
-#define M_CH3_PRTY 0x7U
-#define V_CH3_PRTY(x) ((x) << S_CH3_PRTY)
-#define G_CH3_PRTY(x) (((x) >> S_CH3_PRTY) & M_CH3_PRTY)
-
-#define S_CH2_PRTY 12
-#define M_CH2_PRTY 0x7U
-#define V_CH2_PRTY(x) ((x) << S_CH2_PRTY)
-#define G_CH2_PRTY(x) (((x) >> S_CH2_PRTY) & M_CH2_PRTY)
-
-#define S_CH1_PRTY 8
-#define M_CH1_PRTY 0x7U
-#define V_CH1_PRTY(x) ((x) << S_CH1_PRTY)
-#define G_CH1_PRTY(x) (((x) >> S_CH1_PRTY) & M_CH1_PRTY)
-
-#define S_CH0_PRTY 4
-#define M_CH0_PRTY 0x7U
-#define V_CH0_PRTY(x) ((x) << S_CH0_PRTY)
-#define G_CH0_PRTY(x) (((x) >> S_CH0_PRTY) & M_CH0_PRTY)
-
-#define S_TP_SOURCE 2
-#define M_TP_SOURCE 0x3U
-#define V_TP_SOURCE(x) ((x) << S_TP_SOURCE)
-#define G_TP_SOURCE(x) (((x) >> S_TP_SOURCE) & M_TP_SOURCE)
-
-#define S_NCSI_SOURCE 0
-#define M_NCSI_SOURCE 0x3U
-#define V_NCSI_SOURCE(x) ((x) << S_NCSI_SOURCE)
-#define G_NCSI_SOURCE(x) (((x) >> S_NCSI_SOURCE) & M_NCSI_SOURCE)
-
-#define A_MPS_TX_INT_ENABLE 0x9404
-
-#define S_PORTERR 16
-#define V_PORTERR(x) ((x) << S_PORTERR)
-#define F_PORTERR V_PORTERR(1U)
-
-#define S_FRMERR 15
-#define V_FRMERR(x) ((x) << S_FRMERR)
-#define F_FRMERR V_FRMERR(1U)
-
-#define S_SECNTERR 14
-#define V_SECNTERR(x) ((x) << S_SECNTERR)
-#define F_SECNTERR V_SECNTERR(1U)
-
-#define S_BUBBLE 13
-#define V_BUBBLE(x) ((x) << S_BUBBLE)
-#define F_BUBBLE V_BUBBLE(1U)
-
-#define S_TXDESCFIFO 9
-#define M_TXDESCFIFO 0xfU
-#define V_TXDESCFIFO(x) ((x) << S_TXDESCFIFO)
-#define G_TXDESCFIFO(x) (((x) >> S_TXDESCFIFO) & M_TXDESCFIFO)
-
-#define S_TXDATAFIFO 5
-#define M_TXDATAFIFO 0xfU
-#define V_TXDATAFIFO(x) ((x) << S_TXDATAFIFO)
-#define G_TXDATAFIFO(x) (((x) >> S_TXDATAFIFO) & M_TXDATAFIFO)
-
-#define S_NCSIFIFO 4
-#define V_NCSIFIFO(x) ((x) << S_NCSIFIFO)
-#define F_NCSIFIFO V_NCSIFIFO(1U)
-
-#define S_TPFIFO 0
-#define M_TPFIFO 0xfU
-#define V_TPFIFO(x) ((x) << S_TPFIFO)
-#define G_TPFIFO(x) (((x) >> S_TPFIFO) & M_TPFIFO)
-
-#define A_MPS_TX_INT_CAUSE 0x9408
-#define A_MPS_TX_NCSI2MPS_CNT 0x940c
-#define A_MPS_TX_PERR_ENABLE 0x9410
-#define A_MPS_TX_PERR_INJECT 0x9414
-
-#define S_MPSTXMEMSEL 1
-#define M_MPSTXMEMSEL 0x1fU
-#define V_MPSTXMEMSEL(x) ((x) << S_MPSTXMEMSEL)
-#define G_MPSTXMEMSEL(x) (((x) >> S_MPSTXMEMSEL) & M_MPSTXMEMSEL)
-
-#define A_MPS_TX_SE_CNT_TP01 0x9418
-#define A_MPS_TX_SE_CNT_TP23 0x941c
-#define A_MPS_TX_SE_CNT_MAC01 0x9420
-#define A_MPS_TX_SE_CNT_MAC23 0x9424
-#define A_MPS_TX_SECNT_SPI_BUBBLE_ERR 0x9428
-
-#define S_BUBBLEERR 16
-#define M_BUBBLEERR 0xffU
-#define V_BUBBLEERR(x) ((x) << S_BUBBLEERR)
-#define G_BUBBLEERR(x) (((x) >> S_BUBBLEERR) & M_BUBBLEERR)
-
-#define S_SPI 8
-#define M_SPI 0xffU
-#define V_SPI(x) ((x) << S_SPI)
-#define G_SPI(x) (((x) >> S_SPI) & M_SPI)
-
-#define S_SECNT 0
-#define M_SECNT 0xffU
-#define V_SECNT(x) ((x) << S_SECNT)
-#define G_SECNT(x) (((x) >> S_SECNT) & M_SECNT)
-
-#define A_MPS_TX_SECNT_BUBBLE_CLR 0x942c
-
-#define S_BUBBLECLR 8
-#define M_BUBBLECLR 0xffU
-#define V_BUBBLECLR(x) ((x) << S_BUBBLECLR)
-#define G_BUBBLECLR(x) (((x) >> S_BUBBLECLR) & M_BUBBLECLR)
-
-#define S_NCSISECNT 20
-#define V_NCSISECNT(x) ((x) << S_NCSISECNT)
-#define F_NCSISECNT V_NCSISECNT(1U)
-
-#define S_LPBKSECNT 16
-#define M_LPBKSECNT 0xfU
-#define V_LPBKSECNT(x) ((x) << S_LPBKSECNT)
-#define G_LPBKSECNT(x) (((x) >> S_LPBKSECNT) & M_LPBKSECNT)
-
-#define A_MPS_TX_PORT_ERR 0x9430
-
-#define S_LPBKPT3 7
-#define V_LPBKPT3(x) ((x) << S_LPBKPT3)
-#define F_LPBKPT3 V_LPBKPT3(1U)
-
-#define S_LPBKPT2 6
-#define V_LPBKPT2(x) ((x) << S_LPBKPT2)
-#define F_LPBKPT2 V_LPBKPT2(1U)
-
-#define S_LPBKPT1 5
-#define V_LPBKPT1(x) ((x) << S_LPBKPT1)
-#define F_LPBKPT1 V_LPBKPT1(1U)
-
-#define S_LPBKPT0 4
-#define V_LPBKPT0(x) ((x) << S_LPBKPT0)
-#define F_LPBKPT0 V_LPBKPT0(1U)
-
-#define S_PT3 3
-#define V_PT3(x) ((x) << S_PT3)
-#define F_PT3 V_PT3(1U)
-
-#define S_PT2 2
-#define V_PT2(x) ((x) << S_PT2)
-#define F_PT2 V_PT2(1U)
-
-#define S_PT1 1
-#define V_PT1(x) ((x) << S_PT1)
-#define F_PT1 V_PT1(1U)
-
-#define S_PT0 0
-#define V_PT0(x) ((x) << S_PT0)
-#define F_PT0 V_PT0(1U)
-
-#define A_MPS_TX_LPBK_DROP_BP_CTL_CH0 0x9434
-
-#define S_BPEN 1
-#define V_BPEN(x) ((x) << S_BPEN)
-#define F_BPEN V_BPEN(1U)
-
-#define S_DROPEN 0
-#define V_DROPEN(x) ((x) << S_DROPEN)
-#define F_DROPEN V_DROPEN(1U)
-
-#define A_MPS_TX_LPBK_DROP_BP_CTL_CH1 0x9438
-#define A_MPS_TX_LPBK_DROP_BP_CTL_CH2 0x943c
-#define A_MPS_TX_LPBK_DROP_BP_CTL_CH3 0x9440
-#define A_MPS_TX_DEBUG_REG_TP2TX_10 0x9444
-
-#define S_SOPCH1 31
-#define V_SOPCH1(x) ((x) << S_SOPCH1)
-#define F_SOPCH1 V_SOPCH1(1U)
-
-#define S_EOPCH1 30
-#define V_EOPCH1(x) ((x) << S_EOPCH1)
-#define F_EOPCH1 V_EOPCH1(1U)
-
-#define S_SIZECH1 27
-#define M_SIZECH1 0x7U
-#define V_SIZECH1(x) ((x) << S_SIZECH1)
-#define G_SIZECH1(x) (((x) >> S_SIZECH1) & M_SIZECH1)
-
-#define S_ERRCH1 26
-#define V_ERRCH1(x) ((x) << S_ERRCH1)
-#define F_ERRCH1 V_ERRCH1(1U)
-
-#define S_FULLCH1 25
-#define V_FULLCH1(x) ((x) << S_FULLCH1)
-#define F_FULLCH1 V_FULLCH1(1U)
-
-#define S_VALIDCH1 24
-#define V_VALIDCH1(x) ((x) << S_VALIDCH1)
-#define F_VALIDCH1 V_VALIDCH1(1U)
-
-#define S_DATACH1 16
-#define M_DATACH1 0xffU
-#define V_DATACH1(x) ((x) << S_DATACH1)
-#define G_DATACH1(x) (((x) >> S_DATACH1) & M_DATACH1)
-
-#define S_SOPCH0 15
-#define V_SOPCH0(x) ((x) << S_SOPCH0)
-#define F_SOPCH0 V_SOPCH0(1U)
-
-#define S_EOPCH0 14
-#define V_EOPCH0(x) ((x) << S_EOPCH0)
-#define F_EOPCH0 V_EOPCH0(1U)
-
-#define S_SIZECH0 11
-#define M_SIZECH0 0x7U
-#define V_SIZECH0(x) ((x) << S_SIZECH0)
-#define G_SIZECH0(x) (((x) >> S_SIZECH0) & M_SIZECH0)
-
-#define S_ERRCH0 10
-#define V_ERRCH0(x) ((x) << S_ERRCH0)
-#define F_ERRCH0 V_ERRCH0(1U)
-
-#define S_FULLCH0 9
-#define V_FULLCH0(x) ((x) << S_FULLCH0)
-#define F_FULLCH0 V_FULLCH0(1U)
-
-#define S_VALIDCH0 8
-#define V_VALIDCH0(x) ((x) << S_VALIDCH0)
-#define F_VALIDCH0 V_VALIDCH0(1U)
-
-#define S_DATACH0 0
-#define M_DATACH0 0xffU
-#define V_DATACH0(x) ((x) << S_DATACH0)
-#define G_DATACH0(x) (((x) >> S_DATACH0) & M_DATACH0)
-
-#define S_T5_SIZECH1 26
-#define M_T5_SIZECH1 0xfU
-#define V_T5_SIZECH1(x) ((x) << S_T5_SIZECH1)
-#define G_T5_SIZECH1(x) (((x) >> S_T5_SIZECH1) & M_T5_SIZECH1)
-
-#define S_T5_ERRCH1 25
-#define V_T5_ERRCH1(x) ((x) << S_T5_ERRCH1)
-#define F_T5_ERRCH1 V_T5_ERRCH1(1U)
-
-#define S_T5_FULLCH1 24
-#define V_T5_FULLCH1(x) ((x) << S_T5_FULLCH1)
-#define F_T5_FULLCH1 V_T5_FULLCH1(1U)
-
-#define S_T5_VALIDCH1 23
-#define V_T5_VALIDCH1(x) ((x) << S_T5_VALIDCH1)
-#define F_T5_VALIDCH1 V_T5_VALIDCH1(1U)
-
-#define S_T5_DATACH1 16
-#define M_T5_DATACH1 0x7fU
-#define V_T5_DATACH1(x) ((x) << S_T5_DATACH1)
-#define G_T5_DATACH1(x) (((x) >> S_T5_DATACH1) & M_T5_DATACH1)
-
-#define S_T5_SIZECH0 10
-#define M_T5_SIZECH0 0xfU
-#define V_T5_SIZECH0(x) ((x) << S_T5_SIZECH0)
-#define G_T5_SIZECH0(x) (((x) >> S_T5_SIZECH0) & M_T5_SIZECH0)
-
-#define S_T5_ERRCH0 9
-#define V_T5_ERRCH0(x) ((x) << S_T5_ERRCH0)
-#define F_T5_ERRCH0 V_T5_ERRCH0(1U)
-
-#define S_T5_FULLCH0 8
-#define V_T5_FULLCH0(x) ((x) << S_T5_FULLCH0)
-#define F_T5_FULLCH0 V_T5_FULLCH0(1U)
-
-#define S_T5_VALIDCH0 7
-#define V_T5_VALIDCH0(x) ((x) << S_T5_VALIDCH0)
-#define F_T5_VALIDCH0 V_T5_VALIDCH0(1U)
-
-#define S_T5_DATACH0 0
-#define M_T5_DATACH0 0x7fU
-#define V_T5_DATACH0(x) ((x) << S_T5_DATACH0)
-#define G_T5_DATACH0(x) (((x) >> S_T5_DATACH0) & M_T5_DATACH0)
-
-#define A_MPS_TX_DEBUG_REG_TP2TX_32 0x9448
-
-#define S_SOPCH3 31
-#define V_SOPCH3(x) ((x) << S_SOPCH3)
-#define F_SOPCH3 V_SOPCH3(1U)
-
-#define S_EOPCH3 30
-#define V_EOPCH3(x) ((x) << S_EOPCH3)
-#define F_EOPCH3 V_EOPCH3(1U)
-
-#define S_SIZECH3 27
-#define M_SIZECH3 0x7U
-#define V_SIZECH3(x) ((x) << S_SIZECH3)
-#define G_SIZECH3(x) (((x) >> S_SIZECH3) & M_SIZECH3)
-
-#define S_ERRCH3 26
-#define V_ERRCH3(x) ((x) << S_ERRCH3)
-#define F_ERRCH3 V_ERRCH3(1U)
-
-#define S_FULLCH3 25
-#define V_FULLCH3(x) ((x) << S_FULLCH3)
-#define F_FULLCH3 V_FULLCH3(1U)
-
-#define S_VALIDCH3 24
-#define V_VALIDCH3(x) ((x) << S_VALIDCH3)
-#define F_VALIDCH3 V_VALIDCH3(1U)
-
-#define S_DATACH3 16
-#define M_DATACH3 0xffU
-#define V_DATACH3(x) ((x) << S_DATACH3)
-#define G_DATACH3(x) (((x) >> S_DATACH3) & M_DATACH3)
-
-#define S_SOPCH2 15
-#define V_SOPCH2(x) ((x) << S_SOPCH2)
-#define F_SOPCH2 V_SOPCH2(1U)
-
-#define S_EOPCH2 14
-#define V_EOPCH2(x) ((x) << S_EOPCH2)
-#define F_EOPCH2 V_EOPCH2(1U)
-
-#define S_SIZECH2 11
-#define M_SIZECH2 0x7U
-#define V_SIZECH2(x) ((x) << S_SIZECH2)
-#define G_SIZECH2(x) (((x) >> S_SIZECH2) & M_SIZECH2)
-
-#define S_ERRCH2 10
-#define V_ERRCH2(x) ((x) << S_ERRCH2)
-#define F_ERRCH2 V_ERRCH2(1U)
-
-#define S_FULLCH2 9
-#define V_FULLCH2(x) ((x) << S_FULLCH2)
-#define F_FULLCH2 V_FULLCH2(1U)
-
-#define S_VALIDCH2 8
-#define V_VALIDCH2(x) ((x) << S_VALIDCH2)
-#define F_VALIDCH2 V_VALIDCH2(1U)
-
-#define S_DATACH2 0
-#define M_DATACH2 0xffU
-#define V_DATACH2(x) ((x) << S_DATACH2)
-#define G_DATACH2(x) (((x) >> S_DATACH2) & M_DATACH2)
-
-#define S_T5_SIZECH3 26
-#define M_T5_SIZECH3 0xfU
-#define V_T5_SIZECH3(x) ((x) << S_T5_SIZECH3)
-#define G_T5_SIZECH3(x) (((x) >> S_T5_SIZECH3) & M_T5_SIZECH3)
-
-#define S_T5_ERRCH3 25
-#define V_T5_ERRCH3(x) ((x) << S_T5_ERRCH3)
-#define F_T5_ERRCH3 V_T5_ERRCH3(1U)
-
-#define S_T5_FULLCH3 24
-#define V_T5_FULLCH3(x) ((x) << S_T5_FULLCH3)
-#define F_T5_FULLCH3 V_T5_FULLCH3(1U)
-
-#define S_T5_VALIDCH3 23
-#define V_T5_VALIDCH3(x) ((x) << S_T5_VALIDCH3)
-#define F_T5_VALIDCH3 V_T5_VALIDCH3(1U)
-
-#define S_T5_DATACH3 16
-#define M_T5_DATACH3 0x7fU
-#define V_T5_DATACH3(x) ((x) << S_T5_DATACH3)
-#define G_T5_DATACH3(x) (((x) >> S_T5_DATACH3) & M_T5_DATACH3)
-
-#define S_T5_SIZECH2 10
-#define M_T5_SIZECH2 0xfU
-#define V_T5_SIZECH2(x) ((x) << S_T5_SIZECH2)
-#define G_T5_SIZECH2(x) (((x) >> S_T5_SIZECH2) & M_T5_SIZECH2)
-
-#define S_T5_ERRCH2 9
-#define V_T5_ERRCH2(x) ((x) << S_T5_ERRCH2)
-#define F_T5_ERRCH2 V_T5_ERRCH2(1U)
-
-#define S_T5_FULLCH2 8
-#define V_T5_FULLCH2(x) ((x) << S_T5_FULLCH2)
-#define F_T5_FULLCH2 V_T5_FULLCH2(1U)
-
-#define S_T5_VALIDCH2 7
-#define V_T5_VALIDCH2(x) ((x) << S_T5_VALIDCH2)
-#define F_T5_VALIDCH2 V_T5_VALIDCH2(1U)
-
-#define S_T5_DATACH2 0
-#define M_T5_DATACH2 0x7fU
-#define V_T5_DATACH2(x) ((x) << S_T5_DATACH2)
-#define G_T5_DATACH2(x) (((x) >> S_T5_DATACH2) & M_T5_DATACH2)
-
-#define A_MPS_TX_DEBUG_REG_TX2MAC_10 0x944c
-
-#define S_SOPPT1 31
-#define V_SOPPT1(x) ((x) << S_SOPPT1)
-#define F_SOPPT1 V_SOPPT1(1U)
-
-#define S_EOPPT1 30
-#define V_EOPPT1(x) ((x) << S_EOPPT1)
-#define F_EOPPT1 V_EOPPT1(1U)
-
-#define S_SIZEPT1 27
-#define M_SIZEPT1 0x7U
-#define V_SIZEPT1(x) ((x) << S_SIZEPT1)
-#define G_SIZEPT1(x) (((x) >> S_SIZEPT1) & M_SIZEPT1)
-
-#define S_ERRPT1 26
-#define V_ERRPT1(x) ((x) << S_ERRPT1)
-#define F_ERRPT1 V_ERRPT1(1U)
-
-#define S_FULLPT1 25
-#define V_FULLPT1(x) ((x) << S_FULLPT1)
-#define F_FULLPT1 V_FULLPT1(1U)
-
-#define S_VALIDPT1 24
-#define V_VALIDPT1(x) ((x) << S_VALIDPT1)
-#define F_VALIDPT1 V_VALIDPT1(1U)
-
-#define S_DATAPT1 16
-#define M_DATAPT1 0xffU
-#define V_DATAPT1(x) ((x) << S_DATAPT1)
-#define G_DATAPT1(x) (((x) >> S_DATAPT1) & M_DATAPT1)
-
-#define S_SOPPT0 15
-#define V_SOPPT0(x) ((x) << S_SOPPT0)
-#define F_SOPPT0 V_SOPPT0(1U)
-
-#define S_EOPPT0 14
-#define V_EOPPT0(x) ((x) << S_EOPPT0)
-#define F_EOPPT0 V_EOPPT0(1U)
-
-#define S_SIZEPT0 11
-#define M_SIZEPT0 0x7U
-#define V_SIZEPT0(x) ((x) << S_SIZEPT0)
-#define G_SIZEPT0(x) (((x) >> S_SIZEPT0) & M_SIZEPT0)
-
-#define S_ERRPT0 10
-#define V_ERRPT0(x) ((x) << S_ERRPT0)
-#define F_ERRPT0 V_ERRPT0(1U)
-
-#define S_FULLPT0 9
-#define V_FULLPT0(x) ((x) << S_FULLPT0)
-#define F_FULLPT0 V_FULLPT0(1U)
-
-#define S_VALIDPT0 8
-#define V_VALIDPT0(x) ((x) << S_VALIDPT0)
-#define F_VALIDPT0 V_VALIDPT0(1U)
-
-#define S_DATAPT0 0
-#define M_DATAPT0 0xffU
-#define V_DATAPT0(x) ((x) << S_DATAPT0)
-#define G_DATAPT0(x) (((x) >> S_DATAPT0) & M_DATAPT0)
-
-#define S_T5_SIZEPT1 26
-#define M_T5_SIZEPT1 0xfU
-#define V_T5_SIZEPT1(x) ((x) << S_T5_SIZEPT1)
-#define G_T5_SIZEPT1(x) (((x) >> S_T5_SIZEPT1) & M_T5_SIZEPT1)
-
-#define S_T5_ERRPT1 25
-#define V_T5_ERRPT1(x) ((x) << S_T5_ERRPT1)
-#define F_T5_ERRPT1 V_T5_ERRPT1(1U)
-
-#define S_T5_FULLPT1 24
-#define V_T5_FULLPT1(x) ((x) << S_T5_FULLPT1)
-#define F_T5_FULLPT1 V_T5_FULLPT1(1U)
-
-#define S_T5_VALIDPT1 23
-#define V_T5_VALIDPT1(x) ((x) << S_T5_VALIDPT1)
-#define F_T5_VALIDPT1 V_T5_VALIDPT1(1U)
-
-#define S_T5_DATAPT1 16
-#define M_T5_DATAPT1 0x7fU
-#define V_T5_DATAPT1(x) ((x) << S_T5_DATAPT1)
-#define G_T5_DATAPT1(x) (((x) >> S_T5_DATAPT1) & M_T5_DATAPT1)
-
-#define S_T5_SIZEPT0 10
-#define M_T5_SIZEPT0 0xfU
-#define V_T5_SIZEPT0(x) ((x) << S_T5_SIZEPT0)
-#define G_T5_SIZEPT0(x) (((x) >> S_T5_SIZEPT0) & M_T5_SIZEPT0)
-
-#define S_T5_ERRPT0 9
-#define V_T5_ERRPT0(x) ((x) << S_T5_ERRPT0)
-#define F_T5_ERRPT0 V_T5_ERRPT0(1U)
-
-#define S_T5_FULLPT0 8
-#define V_T5_FULLPT0(x) ((x) << S_T5_FULLPT0)
-#define F_T5_FULLPT0 V_T5_FULLPT0(1U)
-
-#define S_T5_VALIDPT0 7
-#define V_T5_VALIDPT0(x) ((x) << S_T5_VALIDPT0)
-#define F_T5_VALIDPT0 V_T5_VALIDPT0(1U)
-
-#define S_T5_DATAPT0 0
-#define M_T5_DATAPT0 0x7fU
-#define V_T5_DATAPT0(x) ((x) << S_T5_DATAPT0)
-#define G_T5_DATAPT0(x) (((x) >> S_T5_DATAPT0) & M_T5_DATAPT0)
-
-#define A_MPS_TX_DEBUG_REG_TX2MAC_32 0x9450
-
-#define S_SOPPT3 31
-#define V_SOPPT3(x) ((x) << S_SOPPT3)
-#define F_SOPPT3 V_SOPPT3(1U)
-
-#define S_EOPPT3 30
-#define V_EOPPT3(x) ((x) << S_EOPPT3)
-#define F_EOPPT3 V_EOPPT3(1U)
-
-#define S_SIZEPT3 27
-#define M_SIZEPT3 0x7U
-#define V_SIZEPT3(x) ((x) << S_SIZEPT3)
-#define G_SIZEPT3(x) (((x) >> S_SIZEPT3) & M_SIZEPT3)
-
-#define S_ERRPT3 26
-#define V_ERRPT3(x) ((x) << S_ERRPT3)
-#define F_ERRPT3 V_ERRPT3(1U)
-
-#define S_FULLPT3 25
-#define V_FULLPT3(x) ((x) << S_FULLPT3)
-#define F_FULLPT3 V_FULLPT3(1U)
-
-#define S_VALIDPT3 24
-#define V_VALIDPT3(x) ((x) << S_VALIDPT3)
-#define F_VALIDPT3 V_VALIDPT3(1U)
-
-#define S_DATAPT3 16
-#define M_DATAPT3 0xffU
-#define V_DATAPT3(x) ((x) << S_DATAPT3)
-#define G_DATAPT3(x) (((x) >> S_DATAPT3) & M_DATAPT3)
-
-#define S_SOPPT2 15
-#define V_SOPPT2(x) ((x) << S_SOPPT2)
-#define F_SOPPT2 V_SOPPT2(1U)
-
-#define S_EOPPT2 14
-#define V_EOPPT2(x) ((x) << S_EOPPT2)
-#define F_EOPPT2 V_EOPPT2(1U)
-
-#define S_SIZEPT2 11
-#define M_SIZEPT2 0x7U
-#define V_SIZEPT2(x) ((x) << S_SIZEPT2)
-#define G_SIZEPT2(x) (((x) >> S_SIZEPT2) & M_SIZEPT2)
-
-#define S_ERRPT2 10
-#define V_ERRPT2(x) ((x) << S_ERRPT2)
-#define F_ERRPT2 V_ERRPT2(1U)
-
-#define S_FULLPT2 9
-#define V_FULLPT2(x) ((x) << S_FULLPT2)
-#define F_FULLPT2 V_FULLPT2(1U)
-
-#define S_VALIDPT2 8
-#define V_VALIDPT2(x) ((x) << S_VALIDPT2)
-#define F_VALIDPT2 V_VALIDPT2(1U)
-
-#define S_DATAPT2 0
-#define M_DATAPT2 0xffU
-#define V_DATAPT2(x) ((x) << S_DATAPT2)
-#define G_DATAPT2(x) (((x) >> S_DATAPT2) & M_DATAPT2)
-
-#define S_T5_SIZEPT3 26
-#define M_T5_SIZEPT3 0xfU
-#define V_T5_SIZEPT3(x) ((x) << S_T5_SIZEPT3)
-#define G_T5_SIZEPT3(x) (((x) >> S_T5_SIZEPT3) & M_T5_SIZEPT3)
-
-#define S_T5_ERRPT3 25
-#define V_T5_ERRPT3(x) ((x) << S_T5_ERRPT3)
-#define F_T5_ERRPT3 V_T5_ERRPT3(1U)
-
-#define S_T5_FULLPT3 24
-#define V_T5_FULLPT3(x) ((x) << S_T5_FULLPT3)
-#define F_T5_FULLPT3 V_T5_FULLPT3(1U)
-
-#define S_T5_VALIDPT3 23
-#define V_T5_VALIDPT3(x) ((x) << S_T5_VALIDPT3)
-#define F_T5_VALIDPT3 V_T5_VALIDPT3(1U)
-
-#define S_T5_DATAPT3 16
-#define M_T5_DATAPT3 0x7fU
-#define V_T5_DATAPT3(x) ((x) << S_T5_DATAPT3)
-#define G_T5_DATAPT3(x) (((x) >> S_T5_DATAPT3) & M_T5_DATAPT3)
-
-#define S_T5_SIZEPT2 10
-#define M_T5_SIZEPT2 0xfU
-#define V_T5_SIZEPT2(x) ((x) << S_T5_SIZEPT2)
-#define G_T5_SIZEPT2(x) (((x) >> S_T5_SIZEPT2) & M_T5_SIZEPT2)
-
-#define S_T5_ERRPT2 9
-#define V_T5_ERRPT2(x) ((x) << S_T5_ERRPT2)
-#define F_T5_ERRPT2 V_T5_ERRPT2(1U)
-
-#define S_T5_FULLPT2 8
-#define V_T5_FULLPT2(x) ((x) << S_T5_FULLPT2)
-#define F_T5_FULLPT2 V_T5_FULLPT2(1U)
-
-#define S_T5_VALIDPT2 7
-#define V_T5_VALIDPT2(x) ((x) << S_T5_VALIDPT2)
-#define F_T5_VALIDPT2 V_T5_VALIDPT2(1U)
-
-#define S_T5_DATAPT2 0
-#define M_T5_DATAPT2 0x7fU
-#define V_T5_DATAPT2(x) ((x) << S_T5_DATAPT2)
-#define G_T5_DATAPT2(x) (((x) >> S_T5_DATAPT2) & M_T5_DATAPT2)
-
-#define A_MPS_TX_SGE_CH_PAUSE_IGNR 0x9454
-
-#define S_SGEPAUSEIGNR 0
-#define M_SGEPAUSEIGNR 0xfU
-#define V_SGEPAUSEIGNR(x) ((x) << S_SGEPAUSEIGNR)
-#define G_SGEPAUSEIGNR(x) (((x) >> S_SGEPAUSEIGNR) & M_SGEPAUSEIGNR)
-
-#define A_MPS_T5_TX_SGE_CH_PAUSE_IGNR 0x9454
-
-#define S_T5SGEPAUSEIGNR 0
-#define M_T5SGEPAUSEIGNR 0xffffU
-#define V_T5SGEPAUSEIGNR(x) ((x) << S_T5SGEPAUSEIGNR)
-#define G_T5SGEPAUSEIGNR(x) (((x) >> S_T5SGEPAUSEIGNR) & M_T5SGEPAUSEIGNR)
-
-#define A_MPS_TX_DEBUG_SUBPART_SEL 0x9458
-
-#define S_SUBPRTH 11
-#define M_SUBPRTH 0x1fU
-#define V_SUBPRTH(x) ((x) << S_SUBPRTH)
-#define G_SUBPRTH(x) (((x) >> S_SUBPRTH) & M_SUBPRTH)
-
-#define S_PORTH 8
-#define M_PORTH 0x7U
-#define V_PORTH(x) ((x) << S_PORTH)
-#define G_PORTH(x) (((x) >> S_PORTH) & M_PORTH)
-
-#define S_SUBPRTL 3
-#define M_SUBPRTL 0x1fU
-#define V_SUBPRTL(x) ((x) << S_SUBPRTL)
-#define G_SUBPRTL(x) (((x) >> S_SUBPRTL) & M_SUBPRTL)
-
-#define S_PORTL 0
-#define M_PORTL 0x7U
-#define V_PORTL(x) ((x) << S_PORTL)
-#define G_PORTL(x) (((x) >> S_PORTL) & M_PORTL)
-
-#define A_MPS_TX_PAD_CTL 0x945c
-
-#define S_LPBKPADENPT3 7
-#define V_LPBKPADENPT3(x) ((x) << S_LPBKPADENPT3)
-#define F_LPBKPADENPT3 V_LPBKPADENPT3(1U)
-
-#define S_LPBKPADENPT2 6
-#define V_LPBKPADENPT2(x) ((x) << S_LPBKPADENPT2)
-#define F_LPBKPADENPT2 V_LPBKPADENPT2(1U)
-
-#define S_LPBKPADENPT1 5
-#define V_LPBKPADENPT1(x) ((x) << S_LPBKPADENPT1)
-#define F_LPBKPADENPT1 V_LPBKPADENPT1(1U)
-
-#define S_LPBKPADENPT0 4
-#define V_LPBKPADENPT0(x) ((x) << S_LPBKPADENPT0)
-#define F_LPBKPADENPT0 V_LPBKPADENPT0(1U)
-
-#define S_MACPADENPT3 3
-#define V_MACPADENPT3(x) ((x) << S_MACPADENPT3)
-#define F_MACPADENPT3 V_MACPADENPT3(1U)
-
-#define S_MACPADENPT2 2
-#define V_MACPADENPT2(x) ((x) << S_MACPADENPT2)
-#define F_MACPADENPT2 V_MACPADENPT2(1U)
-
-#define S_MACPADENPT1 1
-#define V_MACPADENPT1(x) ((x) << S_MACPADENPT1)
-#define F_MACPADENPT1 V_MACPADENPT1(1U)
-
-#define S_MACPADENPT0 0
-#define V_MACPADENPT0(x) ((x) << S_MACPADENPT0)
-#define F_MACPADENPT0 V_MACPADENPT0(1U)
-
-#define A_MPS_TX_PFVF_PORT_DROP_TP 0x9460
-
-#define S_TP2MPS_CH3 24
-#define M_TP2MPS_CH3 0xffU
-#define V_TP2MPS_CH3(x) ((x) << S_TP2MPS_CH3)
-#define G_TP2MPS_CH3(x) (((x) >> S_TP2MPS_CH3) & M_TP2MPS_CH3)
-
-#define S_TP2MPS_CH2 16
-#define M_TP2MPS_CH2 0xffU
-#define V_TP2MPS_CH2(x) ((x) << S_TP2MPS_CH2)
-#define G_TP2MPS_CH2(x) (((x) >> S_TP2MPS_CH2) & M_TP2MPS_CH2)
-
-#define S_TP2MPS_CH1 8
-#define M_TP2MPS_CH1 0xffU
-#define V_TP2MPS_CH1(x) ((x) << S_TP2MPS_CH1)
-#define G_TP2MPS_CH1(x) (((x) >> S_TP2MPS_CH1) & M_TP2MPS_CH1)
-
-#define S_TP2MPS_CH0 0
-#define M_TP2MPS_CH0 0xffU
-#define V_TP2MPS_CH0(x) ((x) << S_TP2MPS_CH0)
-#define G_TP2MPS_CH0(x) (((x) >> S_TP2MPS_CH0) & M_TP2MPS_CH0)
-
-#define A_MPS_TX_PFVF_PORT_DROP_NCSI 0x9464
-
-#define S_NCSI_CH4 0
-#define M_NCSI_CH4 0xffU
-#define V_NCSI_CH4(x) ((x) << S_NCSI_CH4)
-#define G_NCSI_CH4(x) (((x) >> S_NCSI_CH4) & M_NCSI_CH4)
-
-#define A_MPS_TX_PFVF_PORT_DROP_CTL 0x9468
-
-#define S_PFNOVFDROP 5
-#define V_PFNOVFDROP(x) ((x) << S_PFNOVFDROP)
-#define F_PFNOVFDROP V_PFNOVFDROP(1U)
-
-#define S_NCSI_CH4_CLR 4
-#define V_NCSI_CH4_CLR(x) ((x) << S_NCSI_CH4_CLR)
-#define F_NCSI_CH4_CLR V_NCSI_CH4_CLR(1U)
-
-#define S_TP2MPS_CH3_CLR 3
-#define V_TP2MPS_CH3_CLR(x) ((x) << S_TP2MPS_CH3_CLR)
-#define F_TP2MPS_CH3_CLR V_TP2MPS_CH3_CLR(1U)
-
-#define S_TP2MPS_CH2_CLR 2
-#define V_TP2MPS_CH2_CLR(x) ((x) << S_TP2MPS_CH2_CLR)
-#define F_TP2MPS_CH2_CLR V_TP2MPS_CH2_CLR(1U)
-
-#define S_TP2MPS_CH1_CLR 1
-#define V_TP2MPS_CH1_CLR(x) ((x) << S_TP2MPS_CH1_CLR)
-#define F_TP2MPS_CH1_CLR V_TP2MPS_CH1_CLR(1U)
-
-#define S_TP2MPS_CH0_CLR 0
-#define V_TP2MPS_CH0_CLR(x) ((x) << S_TP2MPS_CH0_CLR)
-#define F_TP2MPS_CH0_CLR V_TP2MPS_CH0_CLR(1U)
-
-#define A_MPS_TX_CGEN 0x946c
-
-#define S_TXOUTLPBK3_CGEN 31
-#define V_TXOUTLPBK3_CGEN(x) ((x) << S_TXOUTLPBK3_CGEN)
-#define F_TXOUTLPBK3_CGEN V_TXOUTLPBK3_CGEN(1U)
-
-#define S_TXOUTLPBK2_CGEN 30
-#define V_TXOUTLPBK2_CGEN(x) ((x) << S_TXOUTLPBK2_CGEN)
-#define F_TXOUTLPBK2_CGEN V_TXOUTLPBK2_CGEN(1U)
-
-#define S_TXOUTLPBK1_CGEN 29
-#define V_TXOUTLPBK1_CGEN(x) ((x) << S_TXOUTLPBK1_CGEN)
-#define F_TXOUTLPBK1_CGEN V_TXOUTLPBK1_CGEN(1U)
-
-#define S_TXOUTLPBK0_CGEN 28
-#define V_TXOUTLPBK0_CGEN(x) ((x) << S_TXOUTLPBK0_CGEN)
-#define F_TXOUTLPBK0_CGEN V_TXOUTLPBK0_CGEN(1U)
-
-#define S_TXOUTMAC3_CGEN 27
-#define V_TXOUTMAC3_CGEN(x) ((x) << S_TXOUTMAC3_CGEN)
-#define F_TXOUTMAC3_CGEN V_TXOUTMAC3_CGEN(1U)
-
-#define S_TXOUTMAC2_CGEN 26
-#define V_TXOUTMAC2_CGEN(x) ((x) << S_TXOUTMAC2_CGEN)
-#define F_TXOUTMAC2_CGEN V_TXOUTMAC2_CGEN(1U)
-
-#define S_TXOUTMAC1_CGEN 25
-#define V_TXOUTMAC1_CGEN(x) ((x) << S_TXOUTMAC1_CGEN)
-#define F_TXOUTMAC1_CGEN V_TXOUTMAC1_CGEN(1U)
-
-#define S_TXOUTMAC0_CGEN 24
-#define V_TXOUTMAC0_CGEN(x) ((x) << S_TXOUTMAC0_CGEN)
-#define F_TXOUTMAC0_CGEN V_TXOUTMAC0_CGEN(1U)
-
-#define S_TXSCHLPBK3_CGEN 23
-#define V_TXSCHLPBK3_CGEN(x) ((x) << S_TXSCHLPBK3_CGEN)
-#define F_TXSCHLPBK3_CGEN V_TXSCHLPBK3_CGEN(1U)
-
-#define S_TXSCHLPBK2_CGEN 22
-#define V_TXSCHLPBK2_CGEN(x) ((x) << S_TXSCHLPBK2_CGEN)
-#define F_TXSCHLPBK2_CGEN V_TXSCHLPBK2_CGEN(1U)
-
-#define S_TXSCHLPBK1_CGEN 21
-#define V_TXSCHLPBK1_CGEN(x) ((x) << S_TXSCHLPBK1_CGEN)
-#define F_TXSCHLPBK1_CGEN V_TXSCHLPBK1_CGEN(1U)
-
-#define S_TXSCHLPBK0_CGEN 20
-#define V_TXSCHLPBK0_CGEN(x) ((x) << S_TXSCHLPBK0_CGEN)
-#define F_TXSCHLPBK0_CGEN V_TXSCHLPBK0_CGEN(1U)
-
-#define S_TXSCHMAC3_CGEN 19
-#define V_TXSCHMAC3_CGEN(x) ((x) << S_TXSCHMAC3_CGEN)
-#define F_TXSCHMAC3_CGEN V_TXSCHMAC3_CGEN(1U)
-
-#define S_TXSCHMAC2_CGEN 18
-#define V_TXSCHMAC2_CGEN(x) ((x) << S_TXSCHMAC2_CGEN)
-#define F_TXSCHMAC2_CGEN V_TXSCHMAC2_CGEN(1U)
-
-#define S_TXSCHMAC1_CGEN 17
-#define V_TXSCHMAC1_CGEN(x) ((x) << S_TXSCHMAC1_CGEN)
-#define F_TXSCHMAC1_CGEN V_TXSCHMAC1_CGEN(1U)
-
-#define S_TXSCHMAC0_CGEN 16
-#define V_TXSCHMAC0_CGEN(x) ((x) << S_TXSCHMAC0_CGEN)
-#define F_TXSCHMAC0_CGEN V_TXSCHMAC0_CGEN(1U)
-
-#define S_TXINCH4_CGEN 15
-#define V_TXINCH4_CGEN(x) ((x) << S_TXINCH4_CGEN)
-#define F_TXINCH4_CGEN V_TXINCH4_CGEN(1U)
-
-#define S_TXINCH3_CGEN 14
-#define V_TXINCH3_CGEN(x) ((x) << S_TXINCH3_CGEN)
-#define F_TXINCH3_CGEN V_TXINCH3_CGEN(1U)
-
-#define S_TXINCH2_CGEN 13
-#define V_TXINCH2_CGEN(x) ((x) << S_TXINCH2_CGEN)
-#define F_TXINCH2_CGEN V_TXINCH2_CGEN(1U)
-
-#define S_TXINCH1_CGEN 12
-#define V_TXINCH1_CGEN(x) ((x) << S_TXINCH1_CGEN)
-#define F_TXINCH1_CGEN V_TXINCH1_CGEN(1U)
-
-#define S_TXINCH0_CGEN 11
-#define V_TXINCH0_CGEN(x) ((x) << S_TXINCH0_CGEN)
-#define F_TXINCH0_CGEN V_TXINCH0_CGEN(1U)
-
-#define A_MPS_TX_CGEN_DYNAMIC 0x9470
-#define A_MPS_STAT_CTL 0x9600
-
-#define S_COUNTVFINPF 1
-#define V_COUNTVFINPF(x) ((x) << S_COUNTVFINPF)
-#define F_COUNTVFINPF V_COUNTVFINPF(1U)
-
-#define S_LPBKERRSTAT 0
-#define V_LPBKERRSTAT(x) ((x) << S_LPBKERRSTAT)
-#define F_LPBKERRSTAT V_LPBKERRSTAT(1U)
-
-#define S_STATSTOPCTRL 10
-#define V_STATSTOPCTRL(x) ((x) << S_STATSTOPCTRL)
-#define F_STATSTOPCTRL V_STATSTOPCTRL(1U)
-
-#define S_STOPSTAT 9
-#define V_STOPSTAT(x) ((x) << S_STOPSTAT)
-#define F_STOPSTAT V_STOPSTAT(1U)
-
-#define S_STATWRITECTRL 8
-#define V_STATWRITECTRL(x) ((x) << S_STATWRITECTRL)
-#define F_STATWRITECTRL V_STATWRITECTRL(1U)
-
-#define S_COUNTLBPF 7
-#define V_COUNTLBPF(x) ((x) << S_COUNTLBPF)
-#define F_COUNTLBPF V_COUNTLBPF(1U)
-
-#define S_COUNTLBVF 6
-#define V_COUNTLBVF(x) ((x) << S_COUNTLBVF)
-#define F_COUNTLBVF V_COUNTLBVF(1U)
-
-#define S_COUNTPAUSEMCRX 5
-#define V_COUNTPAUSEMCRX(x) ((x) << S_COUNTPAUSEMCRX)
-#define F_COUNTPAUSEMCRX V_COUNTPAUSEMCRX(1U)
-
-#define S_COUNTPAUSESTATRX 4
-#define V_COUNTPAUSESTATRX(x) ((x) << S_COUNTPAUSESTATRX)
-#define F_COUNTPAUSESTATRX V_COUNTPAUSESTATRX(1U)
-
-#define S_COUNTPAUSEMCTX 3
-#define V_COUNTPAUSEMCTX(x) ((x) << S_COUNTPAUSEMCTX)
-#define F_COUNTPAUSEMCTX V_COUNTPAUSEMCTX(1U)
-
-#define S_COUNTPAUSESTATTX 2
-#define V_COUNTPAUSESTATTX(x) ((x) << S_COUNTPAUSESTATTX)
-#define F_COUNTPAUSESTATTX V_COUNTPAUSESTATTX(1U)
-
-#define A_MPS_STAT_INT_ENABLE 0x9608
-
-#define S_PLREADSYNCERR 0
-#define V_PLREADSYNCERR(x) ((x) << S_PLREADSYNCERR)
-#define F_PLREADSYNCERR V_PLREADSYNCERR(1U)
-
-#define A_MPS_STAT_INT_CAUSE 0x960c
-#define A_MPS_STAT_PERR_INT_ENABLE_SRAM 0x9610
-
-#define S_RXBG 20
-#define V_RXBG(x) ((x) << S_RXBG)
-#define F_RXBG V_RXBG(1U)
-
-#define S_RXVF 18
-#define M_RXVF 0x3U
-#define V_RXVF(x) ((x) << S_RXVF)
-#define G_RXVF(x) (((x) >> S_RXVF) & M_RXVF)
-
-#define S_TXVF 16
-#define M_TXVF 0x3U
-#define V_TXVF(x) ((x) << S_TXVF)
-#define G_TXVF(x) (((x) >> S_TXVF) & M_TXVF)
-
-#define S_RXPF 13
-#define M_RXPF 0x7U
-#define V_RXPF(x) ((x) << S_RXPF)
-#define G_RXPF(x) (((x) >> S_RXPF) & M_RXPF)
-
-#define S_TXPF 11
-#define M_TXPF 0x3U
-#define V_TXPF(x) ((x) << S_TXPF)
-#define G_TXPF(x) (((x) >> S_TXPF) & M_TXPF)
-
-#define S_RXPORT 7
-#define M_RXPORT 0xfU
-#define V_RXPORT(x) ((x) << S_RXPORT)
-#define G_RXPORT(x) (((x) >> S_RXPORT) & M_RXPORT)
-
-#define S_LBPORT 4
-#define M_LBPORT 0x7U
-#define V_LBPORT(x) ((x) << S_LBPORT)
-#define G_LBPORT(x) (((x) >> S_LBPORT) & M_LBPORT)
-
-#define S_TXPORT 0
-#define M_TXPORT 0xfU
-#define V_TXPORT(x) ((x) << S_TXPORT)
-#define G_TXPORT(x) (((x) >> S_TXPORT) & M_TXPORT)
-
-#define S_T5_RXBG 27
-#define M_T5_RXBG 0x3U
-#define V_T5_RXBG(x) ((x) << S_T5_RXBG)
-#define G_T5_RXBG(x) (((x) >> S_T5_RXBG) & M_T5_RXBG)
-
-#define S_T5_RXPF 22
-#define M_T5_RXPF 0x1fU
-#define V_T5_RXPF(x) ((x) << S_T5_RXPF)
-#define G_T5_RXPF(x) (((x) >> S_T5_RXPF) & M_T5_RXPF)
-
-#define S_T5_TXPF 18
-#define M_T5_TXPF 0xfU
-#define V_T5_TXPF(x) ((x) << S_T5_TXPF)
-#define G_T5_TXPF(x) (((x) >> S_T5_TXPF) & M_T5_TXPF)
-
-#define S_T5_RXPORT 11
-#define M_T5_RXPORT 0x7fU
-#define V_T5_RXPORT(x) ((x) << S_T5_RXPORT)
-#define G_T5_RXPORT(x) (((x) >> S_T5_RXPORT) & M_T5_RXPORT)
-
-#define S_T5_LBPORT 6
-#define M_T5_LBPORT 0x1fU
-#define V_T5_LBPORT(x) ((x) << S_T5_LBPORT)
-#define G_T5_LBPORT(x) (((x) >> S_T5_LBPORT) & M_T5_LBPORT)
-
-#define S_T5_TXPORT 0
-#define M_T5_TXPORT 0x3fU
-#define V_T5_TXPORT(x) ((x) << S_T5_TXPORT)
-#define G_T5_TXPORT(x) (((x) >> S_T5_TXPORT) & M_T5_TXPORT)
-
-#define A_MPS_STAT_PERR_INT_CAUSE_SRAM 0x9614
-#define A_MPS_STAT_PERR_ENABLE_SRAM 0x9618
-#define A_MPS_STAT_PERR_INT_ENABLE_TX_FIFO 0x961c
-
-#define S_TX 12
-#define M_TX 0xffU
-#define V_TX(x) ((x) << S_TX)
-#define G_TX(x) (((x) >> S_TX) & M_TX)
-
-#define S_TXPAUSEFIFO 8
-#define M_TXPAUSEFIFO 0xfU
-#define V_TXPAUSEFIFO(x) ((x) << S_TXPAUSEFIFO)
-#define G_TXPAUSEFIFO(x) (((x) >> S_TXPAUSEFIFO) & M_TXPAUSEFIFO)
-
-#define S_DROP 0
-#define M_DROP 0xffU
-#define V_DROP(x) ((x) << S_DROP)
-#define G_DROP(x) (((x) >> S_DROP) & M_DROP)
-
-#define S_TXCH 20
-#define M_TXCH 0xfU
-#define V_TXCH(x) ((x) << S_TXCH)
-#define G_TXCH(x) (((x) >> S_TXCH) & M_TXCH)
-
-#define A_MPS_STAT_PERR_INT_CAUSE_TX_FIFO 0x9620
-#define A_MPS_STAT_PERR_ENABLE_TX_FIFO 0x9624
-#define A_MPS_STAT_PERR_INT_ENABLE_RX_FIFO 0x9628
-
-#define S_PAUSEFIFO 20
-#define M_PAUSEFIFO 0xfU
-#define V_PAUSEFIFO(x) ((x) << S_PAUSEFIFO)
-#define G_PAUSEFIFO(x) (((x) >> S_PAUSEFIFO) & M_PAUSEFIFO)
-
-#define S_LPBK 16
-#define M_LPBK 0xfU
-#define V_LPBK(x) ((x) << S_LPBK)
-#define G_LPBK(x) (((x) >> S_LPBK) & M_LPBK)
-
-#define S_NQ 8
-#define M_NQ 0xffU
-#define V_NQ(x) ((x) << S_NQ)
-#define G_NQ(x) (((x) >> S_NQ) & M_NQ)
-
-#define S_PV 4
-#define M_PV 0xfU
-#define V_PV(x) ((x) << S_PV)
-#define G_PV(x) (((x) >> S_PV) & M_PV)
-
-#define S_MAC 0
-#define M_MAC 0xfU
-#define V_MAC(x) ((x) << S_MAC)
-#define G_MAC(x) (((x) >> S_MAC) & M_MAC)
-
-#define A_MPS_STAT_PERR_INT_CAUSE_RX_FIFO 0x962c
-#define A_MPS_STAT_PERR_ENABLE_RX_FIFO 0x9630
-#define A_MPS_STAT_PERR_INJECT 0x9634
-
-#define S_STATMEMSEL 1
-#define M_STATMEMSEL 0x7fU
-#define V_STATMEMSEL(x) ((x) << S_STATMEMSEL)
-#define G_STATMEMSEL(x) (((x) >> S_STATMEMSEL) & M_STATMEMSEL)
-
-#define A_MPS_STAT_DEBUG_SUB_SEL 0x9638
-
-#define S_STATSSUBPRTH 5
-#define M_STATSSUBPRTH 0x1fU
-#define V_STATSSUBPRTH(x) ((x) << S_STATSSUBPRTH)
-#define G_STATSSUBPRTH(x) (((x) >> S_STATSSUBPRTH) & M_STATSSUBPRTH)
-
-#define S_STATSSUBPRTL 0
-#define M_STATSSUBPRTL 0x1fU
-#define V_STATSSUBPRTL(x) ((x) << S_STATSSUBPRTL)
-#define G_STATSSUBPRTL(x) (((x) >> S_STATSSUBPRTL) & M_STATSSUBPRTL)
-
-#define S_STATSUBPRTH 5
-#define M_STATSUBPRTH 0x1fU
-#define V_STATSUBPRTH(x) ((x) << S_STATSUBPRTH)
-#define G_STATSUBPRTH(x) (((x) >> S_STATSUBPRTH) & M_STATSUBPRTH)
-
-#define A_MPS_STAT_RX_BG_0_MAC_DROP_FRAME_L 0x9640
-#define A_MPS_STAT_RX_BG_0_MAC_DROP_FRAME_H 0x9644
-#define A_MPS_STAT_RX_BG_1_MAC_DROP_FRAME_L 0x9648
-#define A_MPS_STAT_RX_BG_1_MAC_DROP_FRAME_H 0x964c
-#define A_MPS_STAT_RX_BG_2_MAC_DROP_FRAME_L 0x9650
-#define A_MPS_STAT_RX_BG_2_MAC_DROP_FRAME_H 0x9654
-#define A_MPS_STAT_RX_BG_3_MAC_DROP_FRAME_L 0x9658
-#define A_MPS_STAT_RX_BG_3_MAC_DROP_FRAME_H 0x965c
-#define A_MPS_STAT_RX_BG_0_LB_DROP_FRAME_L 0x9660
-#define A_MPS_STAT_RX_BG_0_LB_DROP_FRAME_H 0x9664
-#define A_MPS_STAT_RX_BG_1_LB_DROP_FRAME_L 0x9668
-#define A_MPS_STAT_RX_BG_1_LB_DROP_FRAME_H 0x966c
-#define A_MPS_STAT_RX_BG_2_LB_DROP_FRAME_L 0x9670
-#define A_MPS_STAT_RX_BG_2_LB_DROP_FRAME_H 0x9674
-#define A_MPS_STAT_RX_BG_3_LB_DROP_FRAME_L 0x9678
-#define A_MPS_STAT_RX_BG_3_LB_DROP_FRAME_H 0x967c
-#define A_MPS_STAT_RX_BG_0_MAC_TRUNC_FRAME_L 0x9680
-#define A_MPS_STAT_RX_BG_0_MAC_TRUNC_FRAME_H 0x9684
-#define A_MPS_STAT_RX_BG_1_MAC_TRUNC_FRAME_L 0x9688
-#define A_MPS_STAT_RX_BG_1_MAC_TRUNC_FRAME_H 0x968c
-#define A_MPS_STAT_RX_BG_2_MAC_TRUNC_FRAME_L 0x9690
-#define A_MPS_STAT_RX_BG_2_MAC_TRUNC_FRAME_H 0x9694
-#define A_MPS_STAT_RX_BG_3_MAC_TRUNC_FRAME_L 0x9698
-#define A_MPS_STAT_RX_BG_3_MAC_TRUNC_FRAME_H 0x969c
-#define A_MPS_STAT_RX_BG_0_LB_TRUNC_FRAME_L 0x96a0
-#define A_MPS_STAT_RX_BG_0_LB_TRUNC_FRAME_H 0x96a4
-#define A_MPS_STAT_RX_BG_1_LB_TRUNC_FRAME_L 0x96a8
-#define A_MPS_STAT_RX_BG_1_LB_TRUNC_FRAME_H 0x96ac
-#define A_MPS_STAT_RX_BG_2_LB_TRUNC_FRAME_L 0x96b0
-#define A_MPS_STAT_RX_BG_2_LB_TRUNC_FRAME_H 0x96b4
-#define A_MPS_STAT_RX_BG_3_LB_TRUNC_FRAME_L 0x96b8
-#define A_MPS_STAT_RX_BG_3_LB_TRUNC_FRAME_H 0x96bc
-#define A_MPS_STAT_PERR_INT_ENABLE_SRAM1 0x96c0
-
-#define S_T5_RXVF 5
-#define M_T5_RXVF 0x7U
-#define V_T5_RXVF(x) ((x) << S_T5_RXVF)
-#define G_T5_RXVF(x) (((x) >> S_T5_RXVF) & M_T5_RXVF)
-
-#define S_T5_TXVF 0
-#define M_T5_TXVF 0x1fU
-#define V_T5_TXVF(x) ((x) << S_T5_TXVF)
-#define G_T5_TXVF(x) (((x) >> S_T5_TXVF) & M_T5_TXVF)
-
-#define A_MPS_STAT_PERR_INT_CAUSE_SRAM1 0x96c4
-#define A_MPS_STAT_PERR_ENABLE_SRAM1 0x96c8
-#define A_MPS_STAT_STOP_UPD_BG 0x96cc
-
-#define S_BGRX 0
-#define M_BGRX 0xfU
-#define V_BGRX(x) ((x) << S_BGRX)
-#define G_BGRX(x) (((x) >> S_BGRX) & M_BGRX)
-
-#define A_MPS_STAT_STOP_UPD_PORT 0x96d0
-
-#define S_PTLPBK 8
-#define M_PTLPBK 0xfU
-#define V_PTLPBK(x) ((x) << S_PTLPBK)
-#define G_PTLPBK(x) (((x) >> S_PTLPBK) & M_PTLPBK)
-
-#define S_PTTX 4
-#define M_PTTX 0xfU
-#define V_PTTX(x) ((x) << S_PTTX)
-#define G_PTTX(x) (((x) >> S_PTTX) & M_PTTX)
-
-#define S_PTRX 0
-#define M_PTRX 0xfU
-#define V_PTRX(x) ((x) << S_PTRX)
-#define G_PTRX(x) (((x) >> S_PTRX) & M_PTRX)
-
-#define A_MPS_STAT_STOP_UPD_PF 0x96d4
-
-#define S_PFTX 8
-#define M_PFTX 0xffU
-#define V_PFTX(x) ((x) << S_PFTX)
-#define G_PFTX(x) (((x) >> S_PFTX) & M_PFTX)
-
-#define S_PFRX 0
-#define M_PFRX 0xffU
-#define V_PFRX(x) ((x) << S_PFRX)
-#define G_PFRX(x) (((x) >> S_PFRX) & M_PFRX)
-
-#define A_MPS_STAT_STOP_UPD_TX_VF_0_31 0x96d8
-#define A_MPS_STAT_STOP_UPD_TX_VF_32_63 0x96dc
-#define A_MPS_STAT_STOP_UPD_TX_VF_64_95 0x96e0
-#define A_MPS_STAT_STOP_UPD_TX_VF_96_127 0x96e4
-#define A_MPS_STAT_STOP_UPD_RX_VF_0_31 0x96e8
-#define A_MPS_STAT_STOP_UPD_RX_VF_32_63 0x96ec
-#define A_MPS_STAT_STOP_UPD_RX_VF_64_95 0x96f0
-#define A_MPS_STAT_STOP_UPD_RX_VF_96_127 0x96f4
-#define A_MPS_STAT_STOP_UPD_RX_VF_128_159 0x96f8
-#define A_MPS_STAT_STOP_UPD_RX_VF_160_191 0x96fc
-#define A_MPS_STAT_STOP_UPD_RX_VF_192_223 0x9700
-#define A_MPS_STAT_STOP_UPD_RX_VF_224_255 0x9704
-#define A_MPS_STAT_STOP_UPD_TX_VF_128_159 0x9710
-#define A_MPS_STAT_STOP_UPD_TX_VF_160_191 0x9714
-#define A_MPS_STAT_STOP_UPD_TX_VF_192_223 0x9718
-#define A_MPS_STAT_STOP_UPD_TX_VF_224_255 0x971c
-#define A_MPS_TRC_CFG 0x9800
-
-#define S_TRCFIFOEMPTY 4
-#define V_TRCFIFOEMPTY(x) ((x) << S_TRCFIFOEMPTY)
-#define F_TRCFIFOEMPTY V_TRCFIFOEMPTY(1U)
-
-#define S_TRCIGNOREDROPINPUT 3
-#define V_TRCIGNOREDROPINPUT(x) ((x) << S_TRCIGNOREDROPINPUT)
-#define F_TRCIGNOREDROPINPUT V_TRCIGNOREDROPINPUT(1U)
-
-#define S_TRCKEEPDUPLICATES 2
-#define V_TRCKEEPDUPLICATES(x) ((x) << S_TRCKEEPDUPLICATES)
-#define F_TRCKEEPDUPLICATES V_TRCKEEPDUPLICATES(1U)
-
-#define S_TRCEN 1
-#define V_TRCEN(x) ((x) << S_TRCEN)
-#define F_TRCEN V_TRCEN(1U)
-
-#define S_TRCMULTIFILTER 0
-#define V_TRCMULTIFILTER(x) ((x) << S_TRCMULTIFILTER)
-#define F_TRCMULTIFILTER V_TRCMULTIFILTER(1U)
-
-#define S_TRCMULTIRSSFILTER 5
-#define V_TRCMULTIRSSFILTER(x) ((x) << S_TRCMULTIRSSFILTER)
-#define F_TRCMULTIRSSFILTER V_TRCMULTIRSSFILTER(1U)
-
-#define A_MPS_TRC_RSS_HASH 0x9804
-#define A_MPS_TRC_FILTER0_RSS_HASH 0x9804
-#define A_MPS_TRC_RSS_CONTROL 0x9808
-
-#define S_RSSCONTROL 16
-#define M_RSSCONTROL 0xffU
-#define V_RSSCONTROL(x) ((x) << S_RSSCONTROL)
-#define G_RSSCONTROL(x) (((x) >> S_RSSCONTROL) & M_RSSCONTROL)
-
-#define S_QUEUENUMBER 0
-#define M_QUEUENUMBER 0xffffU
-#define V_QUEUENUMBER(x) ((x) << S_QUEUENUMBER)
-#define G_QUEUENUMBER(x) (((x) >> S_QUEUENUMBER) & M_QUEUENUMBER)
-
-#define A_MPS_TRC_FILTER0_RSS_CONTROL 0x9808
-#define A_MPS_TRC_FILTER_MATCH_CTL_A 0x9810
-
-#define S_TFINVERTMATCH 24
-#define V_TFINVERTMATCH(x) ((x) << S_TFINVERTMATCH)
-#define F_TFINVERTMATCH V_TFINVERTMATCH(1U)
-
-#define S_TFPKTTOOLARGE 23
-#define V_TFPKTTOOLARGE(x) ((x) << S_TFPKTTOOLARGE)
-#define F_TFPKTTOOLARGE V_TFPKTTOOLARGE(1U)
-
-#define S_TFEN 22
-#define V_TFEN(x) ((x) << S_TFEN)
-#define F_TFEN V_TFEN(1U)
-
-#define S_TFPORT 18
-#define M_TFPORT 0xfU
-#define V_TFPORT(x) ((x) << S_TFPORT)
-#define G_TFPORT(x) (((x) >> S_TFPORT) & M_TFPORT)
-
-#define S_TFDROP 17
-#define V_TFDROP(x) ((x) << S_TFDROP)
-#define F_TFDROP V_TFDROP(1U)
-
-#define S_TFSOPEOPERR 16
-#define V_TFSOPEOPERR(x) ((x) << S_TFSOPEOPERR)
-#define F_TFSOPEOPERR V_TFSOPEOPERR(1U)
-
-#define S_TFLENGTH 8
-#define M_TFLENGTH 0x1fU
-#define V_TFLENGTH(x) ((x) << S_TFLENGTH)
-#define G_TFLENGTH(x) (((x) >> S_TFLENGTH) & M_TFLENGTH)
-
-#define S_TFOFFSET 0
-#define M_TFOFFSET 0x1fU
-#define V_TFOFFSET(x) ((x) << S_TFOFFSET)
-#define G_TFOFFSET(x) (((x) >> S_TFOFFSET) & M_TFOFFSET)
-
-#define S_TFINSERTACTLEN 27
-#define V_TFINSERTACTLEN(x) ((x) << S_TFINSERTACTLEN)
-#define F_TFINSERTACTLEN V_TFINSERTACTLEN(1U)
-
-#define S_TFINSERTTIMER 26
-#define V_TFINSERTTIMER(x) ((x) << S_TFINSERTTIMER)
-#define F_TFINSERTTIMER V_TFINSERTTIMER(1U)
-
-#define S_T5_TFINVERTMATCH 25
-#define V_T5_TFINVERTMATCH(x) ((x) << S_T5_TFINVERTMATCH)
-#define F_T5_TFINVERTMATCH V_T5_TFINVERTMATCH(1U)
-
-#define S_T5_TFPKTTOOLARGE 24
-#define V_T5_TFPKTTOOLARGE(x) ((x) << S_T5_TFPKTTOOLARGE)
-#define F_T5_TFPKTTOOLARGE V_T5_TFPKTTOOLARGE(1U)
-
-#define S_T5_TFEN 23
-#define V_T5_TFEN(x) ((x) << S_T5_TFEN)
-#define F_T5_TFEN V_T5_TFEN(1U)
-
-#define S_T5_TFPORT 18
-#define M_T5_TFPORT 0x1fU
-#define V_T5_TFPORT(x) ((x) << S_T5_TFPORT)
-#define G_T5_TFPORT(x) (((x) >> S_T5_TFPORT) & M_T5_TFPORT)
-
-#define A_MPS_TRC_FILTER_MATCH_CTL_B 0x9820
-
-#define S_TFMINPKTSIZE 16
-#define M_TFMINPKTSIZE 0x1ffU
-#define V_TFMINPKTSIZE(x) ((x) << S_TFMINPKTSIZE)
-#define G_TFMINPKTSIZE(x) (((x) >> S_TFMINPKTSIZE) & M_TFMINPKTSIZE)
-
-#define S_TFCAPTUREMAX 0
-#define M_TFCAPTUREMAX 0x3fffU
-#define V_TFCAPTUREMAX(x) ((x) << S_TFCAPTUREMAX)
-#define G_TFCAPTUREMAX(x) (((x) >> S_TFCAPTUREMAX) & M_TFCAPTUREMAX)
-
-#define A_MPS_TRC_FILTER_RUNT_CTL 0x9830
-
-#define S_TFRUNTSIZE 0
-#define M_TFRUNTSIZE 0x3fU
-#define V_TFRUNTSIZE(x) ((x) << S_TFRUNTSIZE)
-#define G_TFRUNTSIZE(x) (((x) >> S_TFRUNTSIZE) & M_TFRUNTSIZE)
-
-#define A_MPS_TRC_FILTER_DROP 0x9840
-
-#define S_TFDROPINPCOUNT 16
-#define M_TFDROPINPCOUNT 0xffffU
-#define V_TFDROPINPCOUNT(x) ((x) << S_TFDROPINPCOUNT)
-#define G_TFDROPINPCOUNT(x) (((x) >> S_TFDROPINPCOUNT) & M_TFDROPINPCOUNT)
-
-#define S_TFDROPBUFFERCOUNT 0
-#define M_TFDROPBUFFERCOUNT 0xffffU
-#define V_TFDROPBUFFERCOUNT(x) ((x) << S_TFDROPBUFFERCOUNT)
-#define G_TFDROPBUFFERCOUNT(x) (((x) >> S_TFDROPBUFFERCOUNT) & M_TFDROPBUFFERCOUNT)
-
-#define A_MPS_TRC_PERR_INJECT 0x9850
-
-#define S_TRCMEMSEL 1
-#define M_TRCMEMSEL 0xfU
-#define V_TRCMEMSEL(x) ((x) << S_TRCMEMSEL)
-#define G_TRCMEMSEL(x) (((x) >> S_TRCMEMSEL) & M_TRCMEMSEL)
-
-#define A_MPS_TRC_PERR_ENABLE 0x9854
-
-#define S_MISCPERR 8
-#define V_MISCPERR(x) ((x) << S_MISCPERR)
-#define F_MISCPERR V_MISCPERR(1U)
-
-#define S_PKTFIFO 4
-#define M_PKTFIFO 0xfU
-#define V_PKTFIFO(x) ((x) << S_PKTFIFO)
-#define G_PKTFIFO(x) (((x) >> S_PKTFIFO) & M_PKTFIFO)
-
-#define S_FILTMEM 0
-#define M_FILTMEM 0xfU
-#define V_FILTMEM(x) ((x) << S_FILTMEM)
-#define G_FILTMEM(x) (((x) >> S_FILTMEM) & M_FILTMEM)
-
-#define A_MPS_TRC_INT_ENABLE 0x9858
-
-#define S_TRCPLERRENB 9
-#define V_TRCPLERRENB(x) ((x) << S_TRCPLERRENB)
-#define F_TRCPLERRENB V_TRCPLERRENB(1U)
-
-#define A_MPS_TRC_INT_CAUSE 0x985c
-#define A_MPS_TRC_TIMESTAMP_L 0x9860
-#define A_MPS_TRC_TIMESTAMP_H 0x9864
-#define A_MPS_TRC_FILTER0_MATCH 0x9c00
-#define A_MPS_TRC_FILTER0_DONT_CARE 0x9c80
-#define A_MPS_TRC_FILTER1_MATCH 0x9d00
-#define A_MPS_TRC_FILTER1_DONT_CARE 0x9d80
-#define A_MPS_TRC_FILTER2_MATCH 0x9e00
-#define A_MPS_TRC_FILTER2_DONT_CARE 0x9e80
-#define A_MPS_TRC_FILTER3_MATCH 0x9f00
-#define A_MPS_TRC_FILTER3_DONT_CARE 0x9f80
-#define A_MPS_TRC_FILTER1_RSS_HASH 0x9ff0
-#define A_MPS_TRC_FILTER1_RSS_CONTROL 0x9ff4
-#define A_MPS_TRC_FILTER2_RSS_HASH 0x9ff8
-#define A_MPS_TRC_FILTER2_RSS_CONTROL 0x9ffc
-#define A_MPS_TRC_FILTER3_RSS_HASH 0xa000
-#define A_MPS_TRC_FILTER3_RSS_CONTROL 0xa004
-#define A_MPS_T5_TRC_RSS_HASH 0xa008
-#define A_MPS_T5_TRC_RSS_CONTROL 0xa00c
-#define A_MPS_TRC_VF_OFF_FILTER_0 0xa010
-
-#define S_TRCMPS2TP_MACONLY 20
-#define V_TRCMPS2TP_MACONLY(x) ((x) << S_TRCMPS2TP_MACONLY)
-#define F_TRCMPS2TP_MACONLY V_TRCMPS2TP_MACONLY(1U)
-
-#define S_TRCALLMPS2TP 19
-#define V_TRCALLMPS2TP(x) ((x) << S_TRCALLMPS2TP)
-#define F_TRCALLMPS2TP V_TRCALLMPS2TP(1U)
-
-#define S_TRCALLTP2MPS 18
-#define V_TRCALLTP2MPS(x) ((x) << S_TRCALLTP2MPS)
-#define F_TRCALLTP2MPS V_TRCALLTP2MPS(1U)
-
-#define S_TRCALLVF 17
-#define V_TRCALLVF(x) ((x) << S_TRCALLVF)
-#define F_TRCALLVF V_TRCALLVF(1U)
-
-#define S_TRC_OFLD_EN 16
-#define V_TRC_OFLD_EN(x) ((x) << S_TRC_OFLD_EN)
-#define F_TRC_OFLD_EN V_TRC_OFLD_EN(1U)
-
-#define S_VFFILTEN 15
-#define V_VFFILTEN(x) ((x) << S_VFFILTEN)
-#define F_VFFILTEN V_VFFILTEN(1U)
-
-#define S_VFFILTMASK 8
-#define M_VFFILTMASK 0x7fU
-#define V_VFFILTMASK(x) ((x) << S_VFFILTMASK)
-#define G_VFFILTMASK(x) (((x) >> S_VFFILTMASK) & M_VFFILTMASK)
-
-#define S_VFFILTVALID 7
-#define V_VFFILTVALID(x) ((x) << S_VFFILTVALID)
-#define F_VFFILTVALID V_VFFILTVALID(1U)
-
-#define S_VFFILTDATA 0
-#define M_VFFILTDATA 0x7fU
-#define V_VFFILTDATA(x) ((x) << S_VFFILTDATA)
-#define G_VFFILTDATA(x) (((x) >> S_VFFILTDATA) & M_VFFILTDATA)
-
-#define S_T6_TRCMPS2TP_MACONLY 22
-#define V_T6_TRCMPS2TP_MACONLY(x) ((x) << S_T6_TRCMPS2TP_MACONLY)
-#define F_T6_TRCMPS2TP_MACONLY V_T6_TRCMPS2TP_MACONLY(1U)
-
-#define S_T6_TRCALLMPS2TP 21
-#define V_T6_TRCALLMPS2TP(x) ((x) << S_T6_TRCALLMPS2TP)
-#define F_T6_TRCALLMPS2TP V_T6_TRCALLMPS2TP(1U)
-
-#define S_T6_TRCALLTP2MPS 20
-#define V_T6_TRCALLTP2MPS(x) ((x) << S_T6_TRCALLTP2MPS)
-#define F_T6_TRCALLTP2MPS V_T6_TRCALLTP2MPS(1U)
-
-#define S_T6_TRCALLVF 19
-#define V_T6_TRCALLVF(x) ((x) << S_T6_TRCALLVF)
-#define F_T6_TRCALLVF V_T6_TRCALLVF(1U)
-
-#define S_T6_TRC_OFLD_EN 18
-#define V_T6_TRC_OFLD_EN(x) ((x) << S_T6_TRC_OFLD_EN)
-#define F_T6_TRC_OFLD_EN V_T6_TRC_OFLD_EN(1U)
-
-#define S_T6_VFFILTEN 17
-#define V_T6_VFFILTEN(x) ((x) << S_T6_VFFILTEN)
-#define F_T6_VFFILTEN V_T6_VFFILTEN(1U)
-
-#define S_T6_VFFILTMASK 9
-#define M_T6_VFFILTMASK 0xffU
-#define V_T6_VFFILTMASK(x) ((x) << S_T6_VFFILTMASK)
-#define G_T6_VFFILTMASK(x) (((x) >> S_T6_VFFILTMASK) & M_T6_VFFILTMASK)
-
-#define S_T6_VFFILTVALID 8
-#define V_T6_VFFILTVALID(x) ((x) << S_T6_VFFILTVALID)
-#define F_T6_VFFILTVALID V_T6_VFFILTVALID(1U)
-
-#define S_T6_VFFILTDATA 0
-#define M_T6_VFFILTDATA 0xffU
-#define V_T6_VFFILTDATA(x) ((x) << S_T6_VFFILTDATA)
-#define G_T6_VFFILTDATA(x) (((x) >> S_T6_VFFILTDATA) & M_T6_VFFILTDATA)
-
-#define A_MPS_TRC_VF_OFF_FILTER_1 0xa014
-
-#define S_T6_TRCMPS2TP_MACONLY 22
-#define V_T6_TRCMPS2TP_MACONLY(x) ((x) << S_T6_TRCMPS2TP_MACONLY)
-#define F_T6_TRCMPS2TP_MACONLY V_T6_TRCMPS2TP_MACONLY(1U)
-
-#define S_T6_TRCALLMPS2TP 21
-#define V_T6_TRCALLMPS2TP(x) ((x) << S_T6_TRCALLMPS2TP)
-#define F_T6_TRCALLMPS2TP V_T6_TRCALLMPS2TP(1U)
-
-#define S_T6_TRCALLTP2MPS 20
-#define V_T6_TRCALLTP2MPS(x) ((x) << S_T6_TRCALLTP2MPS)
-#define F_T6_TRCALLTP2MPS V_T6_TRCALLTP2MPS(1U)
-
-#define S_T6_TRCALLVF 19
-#define V_T6_TRCALLVF(x) ((x) << S_T6_TRCALLVF)
-#define F_T6_TRCALLVF V_T6_TRCALLVF(1U)
-
-#define S_T6_TRC_OFLD_EN 18
-#define V_T6_TRC_OFLD_EN(x) ((x) << S_T6_TRC_OFLD_EN)
-#define F_T6_TRC_OFLD_EN V_T6_TRC_OFLD_EN(1U)
-
-#define S_T6_VFFILTEN 17
-#define V_T6_VFFILTEN(x) ((x) << S_T6_VFFILTEN)
-#define F_T6_VFFILTEN V_T6_VFFILTEN(1U)
-
-#define S_T6_VFFILTMASK 9
-#define M_T6_VFFILTMASK 0xffU
-#define V_T6_VFFILTMASK(x) ((x) << S_T6_VFFILTMASK)
-#define G_T6_VFFILTMASK(x) (((x) >> S_T6_VFFILTMASK) & M_T6_VFFILTMASK)
-
-#define S_T6_VFFILTVALID 8
-#define V_T6_VFFILTVALID(x) ((x) << S_T6_VFFILTVALID)
-#define F_T6_VFFILTVALID V_T6_VFFILTVALID(1U)
-
-#define S_T6_VFFILTDATA 0
-#define M_T6_VFFILTDATA 0xffU
-#define V_T6_VFFILTDATA(x) ((x) << S_T6_VFFILTDATA)
-#define G_T6_VFFILTDATA(x) (((x) >> S_T6_VFFILTDATA) & M_T6_VFFILTDATA)
-
-#define A_MPS_TRC_VF_OFF_FILTER_2 0xa018
-
-#define S_T6_TRCMPS2TP_MACONLY 22
-#define V_T6_TRCMPS2TP_MACONLY(x) ((x) << S_T6_TRCMPS2TP_MACONLY)
-#define F_T6_TRCMPS2TP_MACONLY V_T6_TRCMPS2TP_MACONLY(1U)
-
-#define S_T6_TRCALLMPS2TP 21
-#define V_T6_TRCALLMPS2TP(x) ((x) << S_T6_TRCALLMPS2TP)
-#define F_T6_TRCALLMPS2TP V_T6_TRCALLMPS2TP(1U)
-
-#define S_T6_TRCALLTP2MPS 20
-#define V_T6_TRCALLTP2MPS(x) ((x) << S_T6_TRCALLTP2MPS)
-#define F_T6_TRCALLTP2MPS V_T6_TRCALLTP2MPS(1U)
-
-#define S_T6_TRCALLVF 19
-#define V_T6_TRCALLVF(x) ((x) << S_T6_TRCALLVF)
-#define F_T6_TRCALLVF V_T6_TRCALLVF(1U)
-
-#define S_T6_TRC_OFLD_EN 18
-#define V_T6_TRC_OFLD_EN(x) ((x) << S_T6_TRC_OFLD_EN)
-#define F_T6_TRC_OFLD_EN V_T6_TRC_OFLD_EN(1U)
-
-#define S_T6_VFFILTEN 17
-#define V_T6_VFFILTEN(x) ((x) << S_T6_VFFILTEN)
-#define F_T6_VFFILTEN V_T6_VFFILTEN(1U)
-
-#define S_T6_VFFILTMASK 9
-#define M_T6_VFFILTMASK 0xffU
-#define V_T6_VFFILTMASK(x) ((x) << S_T6_VFFILTMASK)
-#define G_T6_VFFILTMASK(x) (((x) >> S_T6_VFFILTMASK) & M_T6_VFFILTMASK)
-
-#define S_T6_VFFILTVALID 8
-#define V_T6_VFFILTVALID(x) ((x) << S_T6_VFFILTVALID)
-#define F_T6_VFFILTVALID V_T6_VFFILTVALID(1U)
-
-#define S_T6_VFFILTDATA 0
-#define M_T6_VFFILTDATA 0xffU
-#define V_T6_VFFILTDATA(x) ((x) << S_T6_VFFILTDATA)
-#define G_T6_VFFILTDATA(x) (((x) >> S_T6_VFFILTDATA) & M_T6_VFFILTDATA)
-
-#define A_MPS_TRC_VF_OFF_FILTER_3 0xa01c
-
-#define S_T6_TRCMPS2TP_MACONLY 22
-#define V_T6_TRCMPS2TP_MACONLY(x) ((x) << S_T6_TRCMPS2TP_MACONLY)
-#define F_T6_TRCMPS2TP_MACONLY V_T6_TRCMPS2TP_MACONLY(1U)
-
-#define S_T6_TRCALLMPS2TP 21
-#define V_T6_TRCALLMPS2TP(x) ((x) << S_T6_TRCALLMPS2TP)
-#define F_T6_TRCALLMPS2TP V_T6_TRCALLMPS2TP(1U)
-
-#define S_T6_TRCALLTP2MPS 20
-#define V_T6_TRCALLTP2MPS(x) ((x) << S_T6_TRCALLTP2MPS)
-#define F_T6_TRCALLTP2MPS V_T6_TRCALLTP2MPS(1U)
-
-#define S_T6_TRCALLVF 19
-#define V_T6_TRCALLVF(x) ((x) << S_T6_TRCALLVF)
-#define F_T6_TRCALLVF V_T6_TRCALLVF(1U)
-
-#define S_T6_TRC_OFLD_EN 18
-#define V_T6_TRC_OFLD_EN(x) ((x) << S_T6_TRC_OFLD_EN)
-#define F_T6_TRC_OFLD_EN V_T6_TRC_OFLD_EN(1U)
-
-#define S_T6_VFFILTEN 17
-#define V_T6_VFFILTEN(x) ((x) << S_T6_VFFILTEN)
-#define F_T6_VFFILTEN V_T6_VFFILTEN(1U)
-
-#define S_T6_VFFILTMASK 9
-#define M_T6_VFFILTMASK 0xffU
-#define V_T6_VFFILTMASK(x) ((x) << S_T6_VFFILTMASK)
-#define G_T6_VFFILTMASK(x) (((x) >> S_T6_VFFILTMASK) & M_T6_VFFILTMASK)
-
-#define S_T6_VFFILTVALID 8
-#define V_T6_VFFILTVALID(x) ((x) << S_T6_VFFILTVALID)
-#define F_T6_VFFILTVALID V_T6_VFFILTVALID(1U)
-
-#define S_T6_VFFILTDATA 0
-#define M_T6_VFFILTDATA 0xffU
-#define V_T6_VFFILTDATA(x) ((x) << S_T6_VFFILTDATA)
-#define G_T6_VFFILTDATA(x) (((x) >> S_T6_VFFILTDATA) & M_T6_VFFILTDATA)
-
-#define A_MPS_TRC_CGEN 0xa020
-
-#define S_MPSTRCCGEN 0
-#define M_MPSTRCCGEN 0xfU
-#define V_MPSTRCCGEN(x) ((x) << S_MPSTRCCGEN)
-#define G_MPSTRCCGEN(x) (((x) >> S_MPSTRCCGEN) & M_MPSTRCCGEN)
-
-#define A_MPS_CLS_CTL 0xd000
-
-#define S_MEMWRITEFAULT 4
-#define V_MEMWRITEFAULT(x) ((x) << S_MEMWRITEFAULT)
-#define F_MEMWRITEFAULT V_MEMWRITEFAULT(1U)
-
-#define S_MEMWRITEWAITING 3
-#define V_MEMWRITEWAITING(x) ((x) << S_MEMWRITEWAITING)
-#define F_MEMWRITEWAITING V_MEMWRITEWAITING(1U)
-
-#define S_CIMNOPROMISCUOUS 2
-#define V_CIMNOPROMISCUOUS(x) ((x) << S_CIMNOPROMISCUOUS)
-#define F_CIMNOPROMISCUOUS V_CIMNOPROMISCUOUS(1U)
-
-#define S_HYPERVISORONLY 1
-#define V_HYPERVISORONLY(x) ((x) << S_HYPERVISORONLY)
-#define F_HYPERVISORONLY V_HYPERVISORONLY(1U)
-
-#define S_VLANCLSEN 0
-#define V_VLANCLSEN(x) ((x) << S_VLANCLSEN)
-#define F_VLANCLSEN V_VLANCLSEN(1U)
-
-#define S_VLANCLSEN_IN 7
-#define V_VLANCLSEN_IN(x) ((x) << S_VLANCLSEN_IN)
-#define F_VLANCLSEN_IN V_VLANCLSEN_IN(1U)
-
-#define S_DISTCAMPARCHK 6
-#define V_DISTCAMPARCHK(x) ((x) << S_DISTCAMPARCHK)
-#define F_DISTCAMPARCHK V_DISTCAMPARCHK(1U)
-
-#define S_VLANLKPEN 5
-#define V_VLANLKPEN(x) ((x) << S_VLANLKPEN)
-#define F_VLANLKPEN V_VLANLKPEN(1U)
-
-#define A_MPS_CLS_ARB_WEIGHT 0xd004
-
-#define S_PLWEIGHT 16
-#define M_PLWEIGHT 0x1fU
-#define V_PLWEIGHT(x) ((x) << S_PLWEIGHT)
-#define G_PLWEIGHT(x) (((x) >> S_PLWEIGHT) & M_PLWEIGHT)
-
-#define S_CIMWEIGHT 8
-#define M_CIMWEIGHT 0x1fU
-#define V_CIMWEIGHT(x) ((x) << S_CIMWEIGHT)
-#define G_CIMWEIGHT(x) (((x) >> S_CIMWEIGHT) & M_CIMWEIGHT)
-
-#define S_LPBKWEIGHT 0
-#define M_LPBKWEIGHT 0x1fU
-#define V_LPBKWEIGHT(x) ((x) << S_LPBKWEIGHT)
-#define G_LPBKWEIGHT(x) (((x) >> S_LPBKWEIGHT) & M_LPBKWEIGHT)
-
-#define A_MPS_CLS_NCSI_ETH_TYPE 0xd008
-#define A_MPS_CLS_NCSI_ETH_TYPE_EN 0xd00c
-#define A_MPS_CLS_BMC_MAC_ADDR_L 0xd010
-#define A_MPS_CLS_BMC_MAC_ADDR_H 0xd014
-#define A_MPS_CLS_BMC_VLAN 0xd018
-#define A_MPS_CLS_PERR_INJECT 0xd01c
-
-#define S_CLS_MEMSEL 1
-#define M_CLS_MEMSEL 0x3U
-#define V_CLS_MEMSEL(x) ((x) << S_CLS_MEMSEL)
-#define G_CLS_MEMSEL(x) (((x) >> S_CLS_MEMSEL) & M_CLS_MEMSEL)
-
-#define A_MPS_CLS_PERR_ENABLE 0xd020
-
-#define S_HASHSRAM 2
-#define V_HASHSRAM(x) ((x) << S_HASHSRAM)
-#define F_HASHSRAM V_HASHSRAM(1U)
-
-#define S_MATCHTCAM 1
-#define V_MATCHTCAM(x) ((x) << S_MATCHTCAM)
-#define F_MATCHTCAM V_MATCHTCAM(1U)
-
-#define S_MATCHSRAM 0
-#define V_MATCHSRAM(x) ((x) << S_MATCHSRAM)
-#define F_MATCHSRAM V_MATCHSRAM(1U)
-
-#define A_MPS_CLS_INT_ENABLE 0xd024
-
-#define S_PLERRENB 3
-#define V_PLERRENB(x) ((x) << S_PLERRENB)
-#define F_PLERRENB V_PLERRENB(1U)
-
-#define A_MPS_CLS_INT_CAUSE 0xd028
-#define A_MPS_CLS_PL_TEST_DATA_L 0xd02c
-#define A_MPS_CLS_PL_TEST_DATA_H 0xd030
-#define A_MPS_CLS_PL_TEST_RES_DATA 0xd034
-
-#define S_CLS_PRIORITY 24
-#define M_CLS_PRIORITY 0x7U
-#define V_CLS_PRIORITY(x) ((x) << S_CLS_PRIORITY)
-#define G_CLS_PRIORITY(x) (((x) >> S_CLS_PRIORITY) & M_CLS_PRIORITY)
-
-#define S_CLS_REPLICATE 23
-#define V_CLS_REPLICATE(x) ((x) << S_CLS_REPLICATE)
-#define F_CLS_REPLICATE V_CLS_REPLICATE(1U)
-
-#define S_CLS_INDEX 14
-#define M_CLS_INDEX 0x1ffU
-#define V_CLS_INDEX(x) ((x) << S_CLS_INDEX)
-#define G_CLS_INDEX(x) (((x) >> S_CLS_INDEX) & M_CLS_INDEX)
-
-#define S_CLS_VF 7
-#define M_CLS_VF 0x7fU
-#define V_CLS_VF(x) ((x) << S_CLS_VF)
-#define G_CLS_VF(x) (((x) >> S_CLS_VF) & M_CLS_VF)
-
-#define S_CLS_VF_VLD 6
-#define V_CLS_VF_VLD(x) ((x) << S_CLS_VF_VLD)
-#define F_CLS_VF_VLD V_CLS_VF_VLD(1U)
-
-#define S_CLS_PF 3
-#define M_CLS_PF 0x7U
-#define V_CLS_PF(x) ((x) << S_CLS_PF)
-#define G_CLS_PF(x) (((x) >> S_CLS_PF) & M_CLS_PF)
-
-#define S_CLS_MATCH 0
-#define M_CLS_MATCH 0x7U
-#define V_CLS_MATCH(x) ((x) << S_CLS_MATCH)
-#define G_CLS_MATCH(x) (((x) >> S_CLS_MATCH) & M_CLS_MATCH)
-
-#define S_CLS_SPARE 28
-#define M_CLS_SPARE 0xfU
-#define V_CLS_SPARE(x) ((x) << S_CLS_SPARE)
-#define G_CLS_SPARE(x) (((x) >> S_CLS_SPARE) & M_CLS_SPARE)
-
-#define S_T6_CLS_PRIORITY 25
-#define M_T6_CLS_PRIORITY 0x7U
-#define V_T6_CLS_PRIORITY(x) ((x) << S_T6_CLS_PRIORITY)
-#define G_T6_CLS_PRIORITY(x) (((x) >> S_T6_CLS_PRIORITY) & M_T6_CLS_PRIORITY)
-
-#define S_T6_CLS_REPLICATE 24
-#define V_T6_CLS_REPLICATE(x) ((x) << S_T6_CLS_REPLICATE)
-#define F_T6_CLS_REPLICATE V_T6_CLS_REPLICATE(1U)
-
-#define S_T6_CLS_INDEX 15
-#define M_T6_CLS_INDEX 0x1ffU
-#define V_T6_CLS_INDEX(x) ((x) << S_T6_CLS_INDEX)
-#define G_T6_CLS_INDEX(x) (((x) >> S_T6_CLS_INDEX) & M_T6_CLS_INDEX)
-
-#define S_T6_CLS_VF 7
-#define M_T6_CLS_VF 0xffU
-#define V_T6_CLS_VF(x) ((x) << S_T6_CLS_VF)
-#define G_T6_CLS_VF(x) (((x) >> S_T6_CLS_VF) & M_T6_CLS_VF)
-
-#define A_MPS_CLS_PL_TEST_CTL 0xd038
-
-#define S_PLTESTCTL 0
-#define V_PLTESTCTL(x) ((x) << S_PLTESTCTL)
-#define F_PLTESTCTL V_PLTESTCTL(1U)
-
-#define A_MPS_CLS_PORT_BMC_CTL 0xd03c
-
-#define S_PRTBMCCTL 0
-#define V_PRTBMCCTL(x) ((x) << S_PRTBMCCTL)
-#define F_PRTBMCCTL V_PRTBMCCTL(1U)
-
-#define A_MPS_CLS_MATCH_CNT_TCAM 0xd100
-#define A_MPS_CLS_MATCH_CNT_HASH 0xd104
-#define A_MPS_CLS_MATCH_CNT_BCAST 0xd108
-#define A_MPS_CLS_MATCH_CNT_BMC 0xd10c
-#define A_MPS_CLS_MATCH_CNT_PROM 0xd110
-#define A_MPS_CLS_MATCH_CNT_HPROM 0xd114
-#define A_MPS_CLS_MISS_CNT 0xd118
-#define A_MPS_CLS_REQUEST_TRACE_MAC_DA_L 0xd200
-#define A_MPS_CLS_REQUEST_TRACE_MAC_DA_H 0xd204
-
-#define S_CLSTRCMACDAHI 0
-#define M_CLSTRCMACDAHI 0xffffU
-#define V_CLSTRCMACDAHI(x) ((x) << S_CLSTRCMACDAHI)
-#define G_CLSTRCMACDAHI(x) (((x) >> S_CLSTRCMACDAHI) & M_CLSTRCMACDAHI)
-
-#define A_MPS_CLS_REQUEST_TRACE_MAC_SA_L 0xd208
-#define A_MPS_CLS_REQUEST_TRACE_MAC_SA_H 0xd20c
-
-#define S_CLSTRCMACSAHI 0
-#define M_CLSTRCMACSAHI 0xffffU
-#define V_CLSTRCMACSAHI(x) ((x) << S_CLSTRCMACSAHI)
-#define G_CLSTRCMACSAHI(x) (((x) >> S_CLSTRCMACSAHI) & M_CLSTRCMACSAHI)
-
-#define A_MPS_CLS_REQUEST_TRACE_PORT_VLAN 0xd210
-
-#define S_CLSTRCVLANVLD 31
-#define V_CLSTRCVLANVLD(x) ((x) << S_CLSTRCVLANVLD)
-#define F_CLSTRCVLANVLD V_CLSTRCVLANVLD(1U)
-
-#define S_CLSTRCVLANID 16
-#define M_CLSTRCVLANID 0xfffU
-#define V_CLSTRCVLANID(x) ((x) << S_CLSTRCVLANID)
-#define G_CLSTRCVLANID(x) (((x) >> S_CLSTRCVLANID) & M_CLSTRCVLANID)
-
-#define S_CLSTRCREQPORT 0
-#define M_CLSTRCREQPORT 0xfU
-#define V_CLSTRCREQPORT(x) ((x) << S_CLSTRCREQPORT)
-#define G_CLSTRCREQPORT(x) (((x) >> S_CLSTRCREQPORT) & M_CLSTRCREQPORT)
-
-#define A_MPS_CLS_REQUEST_TRACE_ENCAP 0xd214
-
-#define S_CLSTRCLKPTYPE 31
-#define V_CLSTRCLKPTYPE(x) ((x) << S_CLSTRCLKPTYPE)
-#define F_CLSTRCLKPTYPE V_CLSTRCLKPTYPE(1U)
-
-#define S_CLSTRCDIPHIT 30
-#define V_CLSTRCDIPHIT(x) ((x) << S_CLSTRCDIPHIT)
-#define F_CLSTRCDIPHIT V_CLSTRCDIPHIT(1U)
-
-#define S_CLSTRCVNI 0
-#define M_CLSTRCVNI 0xffffffU
-#define V_CLSTRCVNI(x) ((x) << S_CLSTRCVNI)
-#define G_CLSTRCVNI(x) (((x) >> S_CLSTRCVNI) & M_CLSTRCVNI)
-
-#define A_MPS_CLS_RESULT_TRACE 0xd300
-
-#define S_CLSTRCPORTNUM 31
-#define V_CLSTRCPORTNUM(x) ((x) << S_CLSTRCPORTNUM)
-#define F_CLSTRCPORTNUM V_CLSTRCPORTNUM(1U)
-
-#define S_CLSTRCPRIORITY 28
-#define M_CLSTRCPRIORITY 0x7U
-#define V_CLSTRCPRIORITY(x) ((x) << S_CLSTRCPRIORITY)
-#define G_CLSTRCPRIORITY(x) (((x) >> S_CLSTRCPRIORITY) & M_CLSTRCPRIORITY)
-
-#define S_CLSTRCMULTILISTEN 27
-#define V_CLSTRCMULTILISTEN(x) ((x) << S_CLSTRCMULTILISTEN)
-#define F_CLSTRCMULTILISTEN V_CLSTRCMULTILISTEN(1U)
-
-#define S_CLSTRCREPLICATE 26
-#define V_CLSTRCREPLICATE(x) ((x) << S_CLSTRCREPLICATE)
-#define F_CLSTRCREPLICATE V_CLSTRCREPLICATE(1U)
-
-#define S_CLSTRCPORTMAP 24
-#define M_CLSTRCPORTMAP 0x3U
-#define V_CLSTRCPORTMAP(x) ((x) << S_CLSTRCPORTMAP)
-#define G_CLSTRCPORTMAP(x) (((x) >> S_CLSTRCPORTMAP) & M_CLSTRCPORTMAP)
-
-#define S_CLSTRCMATCH 21
-#define M_CLSTRCMATCH 0x7U
-#define V_CLSTRCMATCH(x) ((x) << S_CLSTRCMATCH)
-#define G_CLSTRCMATCH(x) (((x) >> S_CLSTRCMATCH) & M_CLSTRCMATCH)
-
-#define S_CLSTRCINDEX 12
-#define M_CLSTRCINDEX 0x1ffU
-#define V_CLSTRCINDEX(x) ((x) << S_CLSTRCINDEX)
-#define G_CLSTRCINDEX(x) (((x) >> S_CLSTRCINDEX) & M_CLSTRCINDEX)
-
-#define S_CLSTRCVF_VLD 11
-#define V_CLSTRCVF_VLD(x) ((x) << S_CLSTRCVF_VLD)
-#define F_CLSTRCVF_VLD V_CLSTRCVF_VLD(1U)
-
-#define S_CLSTRCPF 3
-#define M_CLSTRCPF 0xffU
-#define V_CLSTRCPF(x) ((x) << S_CLSTRCPF)
-#define G_CLSTRCPF(x) (((x) >> S_CLSTRCPF) & M_CLSTRCPF)
-
-#define S_CLSTRCVF 0
-#define M_CLSTRCVF 0x7U
-#define V_CLSTRCVF(x) ((x) << S_CLSTRCVF)
-#define G_CLSTRCVF(x) (((x) >> S_CLSTRCVF) & M_CLSTRCVF)
-
-#define A_MPS_CLS_VLAN_TABLE 0xdfc0
-
-#define S_VLAN_MASK 16
-#define M_VLAN_MASK 0xfffU
-#define V_VLAN_MASK(x) ((x) << S_VLAN_MASK)
-#define G_VLAN_MASK(x) (((x) >> S_VLAN_MASK) & M_VLAN_MASK)
-
-#define S_VLANPF 13
-#define M_VLANPF 0x7U
-#define V_VLANPF(x) ((x) << S_VLANPF)
-#define G_VLANPF(x) (((x) >> S_VLANPF) & M_VLANPF)
-
-#define S_VLAN_VALID 12
-#define V_VLAN_VALID(x) ((x) << S_VLAN_VALID)
-#define F_VLAN_VALID V_VLAN_VALID(1U)
-
-#define A_MPS_CLS_SRAM_L 0xe000
-
-#define S_MULTILISTEN3 28
-#define V_MULTILISTEN3(x) ((x) << S_MULTILISTEN3)
-#define F_MULTILISTEN3 V_MULTILISTEN3(1U)
-
-#define S_MULTILISTEN2 27
-#define V_MULTILISTEN2(x) ((x) << S_MULTILISTEN2)
-#define F_MULTILISTEN2 V_MULTILISTEN2(1U)
-
-#define S_MULTILISTEN1 26
-#define V_MULTILISTEN1(x) ((x) << S_MULTILISTEN1)
-#define F_MULTILISTEN1 V_MULTILISTEN1(1U)
-
-#define S_MULTILISTEN0 25
-#define V_MULTILISTEN0(x) ((x) << S_MULTILISTEN0)
-#define F_MULTILISTEN0 V_MULTILISTEN0(1U)
-
-#define S_SRAM_PRIO3 22
-#define M_SRAM_PRIO3 0x7U
-#define V_SRAM_PRIO3(x) ((x) << S_SRAM_PRIO3)
-#define G_SRAM_PRIO3(x) (((x) >> S_SRAM_PRIO3) & M_SRAM_PRIO3)
-
-#define S_SRAM_PRIO2 19
-#define M_SRAM_PRIO2 0x7U
-#define V_SRAM_PRIO2(x) ((x) << S_SRAM_PRIO2)
-#define G_SRAM_PRIO2(x) (((x) >> S_SRAM_PRIO2) & M_SRAM_PRIO2)
-
-#define S_SRAM_PRIO1 16
-#define M_SRAM_PRIO1 0x7U
-#define V_SRAM_PRIO1(x) ((x) << S_SRAM_PRIO1)
-#define G_SRAM_PRIO1(x) (((x) >> S_SRAM_PRIO1) & M_SRAM_PRIO1)
-
-#define S_SRAM_PRIO0 13
-#define M_SRAM_PRIO0 0x7U
-#define V_SRAM_PRIO0(x) ((x) << S_SRAM_PRIO0)
-#define G_SRAM_PRIO0(x) (((x) >> S_SRAM_PRIO0) & M_SRAM_PRIO0)
-
-#define S_SRAM_VLD 12
-#define V_SRAM_VLD(x) ((x) << S_SRAM_VLD)
-#define F_SRAM_VLD V_SRAM_VLD(1U)
-
-#define A_MPS_T5_CLS_SRAM_L 0xe000
-
-#define S_T6_DISENCAPOUTERRPLCT 31
-#define V_T6_DISENCAPOUTERRPLCT(x) ((x) << S_T6_DISENCAPOUTERRPLCT)
-#define F_T6_DISENCAPOUTERRPLCT V_T6_DISENCAPOUTERRPLCT(1U)
-
-#define S_T6_DISENCAP 30
-#define V_T6_DISENCAP(x) ((x) << S_T6_DISENCAP)
-#define F_T6_DISENCAP V_T6_DISENCAP(1U)
-
-#define S_T6_MULTILISTEN3 29
-#define V_T6_MULTILISTEN3(x) ((x) << S_T6_MULTILISTEN3)
-#define F_T6_MULTILISTEN3 V_T6_MULTILISTEN3(1U)
-
-#define S_T6_MULTILISTEN2 28
-#define V_T6_MULTILISTEN2(x) ((x) << S_T6_MULTILISTEN2)
-#define F_T6_MULTILISTEN2 V_T6_MULTILISTEN2(1U)
-
-#define S_T6_MULTILISTEN1 27
-#define V_T6_MULTILISTEN1(x) ((x) << S_T6_MULTILISTEN1)
-#define F_T6_MULTILISTEN1 V_T6_MULTILISTEN1(1U)
-
-#define S_T6_MULTILISTEN0 26
-#define V_T6_MULTILISTEN0(x) ((x) << S_T6_MULTILISTEN0)
-#define F_T6_MULTILISTEN0 V_T6_MULTILISTEN0(1U)
-
-#define S_T6_SRAM_PRIO3 23
-#define M_T6_SRAM_PRIO3 0x7U
-#define V_T6_SRAM_PRIO3(x) ((x) << S_T6_SRAM_PRIO3)
-#define G_T6_SRAM_PRIO3(x) (((x) >> S_T6_SRAM_PRIO3) & M_T6_SRAM_PRIO3)
-
-#define S_T6_SRAM_PRIO2 20
-#define M_T6_SRAM_PRIO2 0x7U
-#define V_T6_SRAM_PRIO2(x) ((x) << S_T6_SRAM_PRIO2)
-#define G_T6_SRAM_PRIO2(x) (((x) >> S_T6_SRAM_PRIO2) & M_T6_SRAM_PRIO2)
-
-#define S_T6_SRAM_PRIO1 17
-#define M_T6_SRAM_PRIO1 0x7U
-#define V_T6_SRAM_PRIO1(x) ((x) << S_T6_SRAM_PRIO1)
-#define G_T6_SRAM_PRIO1(x) (((x) >> S_T6_SRAM_PRIO1) & M_T6_SRAM_PRIO1)
-
-#define S_T6_SRAM_PRIO0 14
-#define M_T6_SRAM_PRIO0 0x7U
-#define V_T6_SRAM_PRIO0(x) ((x) << S_T6_SRAM_PRIO0)
-#define G_T6_SRAM_PRIO0(x) (((x) >> S_T6_SRAM_PRIO0) & M_T6_SRAM_PRIO0)
-
-#define S_T6_SRAM_VLD 13
-#define V_T6_SRAM_VLD(x) ((x) << S_T6_SRAM_VLD)
-#define F_T6_SRAM_VLD V_T6_SRAM_VLD(1U)
-
-#define S_T6_REPLICATE 12
-#define V_T6_REPLICATE(x) ((x) << S_T6_REPLICATE)
-#define F_T6_REPLICATE V_T6_REPLICATE(1U)
-
-#define S_T6_PF 9
-#define M_T6_PF 0x7U
-#define V_T6_PF(x) ((x) << S_T6_PF)
-#define G_T6_PF(x) (((x) >> S_T6_PF) & M_T6_PF)
-
-#define S_T6_VF_VALID 8
-#define V_T6_VF_VALID(x) ((x) << S_T6_VF_VALID)
-#define F_T6_VF_VALID V_T6_VF_VALID(1U)
-
-#define S_T6_VF 0
-#define M_T6_VF 0xffU
-#define V_T6_VF(x) ((x) << S_T6_VF)
-#define G_T6_VF(x) (((x) >> S_T6_VF) & M_T6_VF)
-
-#define A_MPS_CLS_SRAM_H 0xe004
-
-#define S_MACPARITY1 9
-#define V_MACPARITY1(x) ((x) << S_MACPARITY1)
-#define F_MACPARITY1 V_MACPARITY1(1U)
-
-#define S_MACPARITY0 8
-#define V_MACPARITY0(x) ((x) << S_MACPARITY0)
-#define F_MACPARITY0 V_MACPARITY0(1U)
-
-#define S_MACPARITYMASKSIZE 4
-#define M_MACPARITYMASKSIZE 0xfU
-#define V_MACPARITYMASKSIZE(x) ((x) << S_MACPARITYMASKSIZE)
-#define G_MACPARITYMASKSIZE(x) (((x) >> S_MACPARITYMASKSIZE) & M_MACPARITYMASKSIZE)
-
-#define S_PORTMAP 0
-#define M_PORTMAP 0xfU
-#define V_PORTMAP(x) ((x) << S_PORTMAP)
-#define G_PORTMAP(x) (((x) >> S_PORTMAP) & M_PORTMAP)
-
-#define A_MPS_T5_CLS_SRAM_H 0xe004
-
-#define S_MACPARITY2 10
-#define V_MACPARITY2(x) ((x) << S_MACPARITY2)
-#define F_MACPARITY2 V_MACPARITY2(1U)
-
-#define A_MPS_CLS_TCAM_Y_L 0xf000
-#define A_MPS_CLS_TCAM_DATA0 0xf000
-#define A_MPS_CLS_TCAM_Y_H 0xf004
-
-#define S_TCAMYH 0
-#define M_TCAMYH 0xffffU
-#define V_TCAMYH(x) ((x) << S_TCAMYH)
-#define G_TCAMYH(x) (((x) >> S_TCAMYH) & M_TCAMYH)
-
-#define A_MPS_CLS_TCAM_DATA1 0xf004
-
-#define S_VIDL 16
-#define M_VIDL 0xffffU
-#define V_VIDL(x) ((x) << S_VIDL)
-#define G_VIDL(x) (((x) >> S_VIDL) & M_VIDL)
-
-#define S_DMACH 0
-#define M_DMACH 0xffffU
-#define V_DMACH(x) ((x) << S_DMACH)
-#define G_DMACH(x) (((x) >> S_DMACH) & M_DMACH)
-
-#define A_MPS_CLS_TCAM_X_L 0xf008
-#define A_MPS_CLS_TCAM_DATA2_CTL 0xf008
-
-#define S_CTLCMDTYPE 31
-#define V_CTLCMDTYPE(x) ((x) << S_CTLCMDTYPE)
-#define F_CTLCMDTYPE V_CTLCMDTYPE(1U)
-
-#define S_CTLREQID 30
-#define V_CTLREQID(x) ((x) << S_CTLREQID)
-#define F_CTLREQID V_CTLREQID(1U)
-
-#define S_CTLTCAMSEL 25
-#define V_CTLTCAMSEL(x) ((x) << S_CTLTCAMSEL)
-#define F_CTLTCAMSEL V_CTLTCAMSEL(1U)
-
-#define S_CTLTCAMINDEX 17
-#define M_CTLTCAMINDEX 0xffU
-#define V_CTLTCAMINDEX(x) ((x) << S_CTLTCAMINDEX)
-#define G_CTLTCAMINDEX(x) (((x) >> S_CTLTCAMINDEX) & M_CTLTCAMINDEX)
-
-#define S_CTLXYBITSEL 16
-#define V_CTLXYBITSEL(x) ((x) << S_CTLXYBITSEL)
-#define F_CTLXYBITSEL V_CTLXYBITSEL(1U)
-
-#define S_DATAPORTNUM 12
-#define M_DATAPORTNUM 0xfU
-#define V_DATAPORTNUM(x) ((x) << S_DATAPORTNUM)
-#define G_DATAPORTNUM(x) (((x) >> S_DATAPORTNUM) & M_DATAPORTNUM)
-
-#define S_DATALKPTYPE 10
-#define M_DATALKPTYPE 0x3U
-#define V_DATALKPTYPE(x) ((x) << S_DATALKPTYPE)
-#define G_DATALKPTYPE(x) (((x) >> S_DATALKPTYPE) & M_DATALKPTYPE)
-
-#define S_DATADIPHIT 8
-#define V_DATADIPHIT(x) ((x) << S_DATADIPHIT)
-#define F_DATADIPHIT V_DATADIPHIT(1U)
-
-#define S_DATAVIDH2 7
-#define V_DATAVIDH2(x) ((x) << S_DATAVIDH2)
-#define F_DATAVIDH2 V_DATAVIDH2(1U)
-
-#define S_DATAVIDH1 0
-#define M_DATAVIDH1 0x7fU
-#define V_DATAVIDH1(x) ((x) << S_DATAVIDH1)
-#define G_DATAVIDH1(x) (((x) >> S_DATAVIDH1) & M_DATAVIDH1)
-
-#define A_MPS_CLS_TCAM_X_H 0xf00c
-
-#define S_TCAMXH 0
-#define M_TCAMXH 0xffffU
-#define V_TCAMXH(x) ((x) << S_TCAMXH)
-#define G_TCAMXH(x) (((x) >> S_TCAMXH) & M_TCAMXH)
-
-#define A_MPS_CLS_TCAM_RDATA0_REQ_ID0 0xf010
-#define A_MPS_CLS_TCAM_RDATA1_REQ_ID0 0xf014
-#define A_MPS_CLS_TCAM_RDATA2_REQ_ID0 0xf018
-#define A_MPS_CLS_TCAM_RDATA0_REQ_ID1 0xf020
-#define A_MPS_CLS_TCAM_RDATA1_REQ_ID1 0xf024
-#define A_MPS_CLS_TCAM_RDATA2_REQ_ID1 0xf028
-#define A_MPS_RX_CTL 0x11000
-
-#define S_FILT_VLAN_SEL 17
-#define V_FILT_VLAN_SEL(x) ((x) << S_FILT_VLAN_SEL)
-#define F_FILT_VLAN_SEL V_FILT_VLAN_SEL(1U)
-
-#define S_CBA_EN 16
-#define V_CBA_EN(x) ((x) << S_CBA_EN)
-#define F_CBA_EN V_CBA_EN(1U)
-
-#define S_BLK_SNDR 12
-#define M_BLK_SNDR 0xfU
-#define V_BLK_SNDR(x) ((x) << S_BLK_SNDR)
-#define G_BLK_SNDR(x) (((x) >> S_BLK_SNDR) & M_BLK_SNDR)
-
-#define S_CMPRS 8
-#define M_CMPRS 0xfU
-#define V_CMPRS(x) ((x) << S_CMPRS)
-#define G_CMPRS(x) (((x) >> S_CMPRS) & M_CMPRS)
-
-#define S_SNF 0
-#define M_SNF 0xffU
-#define V_SNF(x) ((x) << S_SNF)
-#define G_SNF(x) (((x) >> S_SNF) & M_SNF)
-
-#define A_MPS_RX_PORT_MUX_CTL 0x11004
-
-#define S_CTL_P3 12
-#define M_CTL_P3 0xfU
-#define V_CTL_P3(x) ((x) << S_CTL_P3)
-#define G_CTL_P3(x) (((x) >> S_CTL_P3) & M_CTL_P3)
-
-#define S_CTL_P2 8
-#define M_CTL_P2 0xfU
-#define V_CTL_P2(x) ((x) << S_CTL_P2)
-#define G_CTL_P2(x) (((x) >> S_CTL_P2) & M_CTL_P2)
-
-#define S_CTL_P1 4
-#define M_CTL_P1 0xfU
-#define V_CTL_P1(x) ((x) << S_CTL_P1)
-#define G_CTL_P1(x) (((x) >> S_CTL_P1) & M_CTL_P1)
-
-#define S_CTL_P0 0
-#define M_CTL_P0 0xfU
-#define V_CTL_P0(x) ((x) << S_CTL_P0)
-#define G_CTL_P0(x) (((x) >> S_CTL_P0) & M_CTL_P0)
-
-#define A_MPS_RX_PG_FL 0x11008
-
-#define S_RST 16
-#define V_RST(x) ((x) << S_RST)
-#define F_RST V_RST(1U)
-
-#define S_CNT 0
-#define M_CNT 0xffffU
-#define V_CNT(x) ((x) << S_CNT)
-#define G_CNT(x) (((x) >> S_CNT) & M_CNT)
-
-#define A_MPS_RX_FIFO_0_CTL 0x11008
-
-#define S_DEST_SELECT 0
-#define M_DEST_SELECT 0xfU
-#define V_DEST_SELECT(x) ((x) << S_DEST_SELECT)
-#define G_DEST_SELECT(x) (((x) >> S_DEST_SELECT) & M_DEST_SELECT)
-
-#define A_MPS_RX_PKT_FL 0x1100c
-#define A_MPS_RX_FIFO_1_CTL 0x1100c
-#define A_MPS_RX_PG_RSV0 0x11010
-
-#define S_CLR_INTR 31
-#define V_CLR_INTR(x) ((x) << S_CLR_INTR)
-#define F_CLR_INTR V_CLR_INTR(1U)
-
-#define S_SET_INTR 30
-#define V_SET_INTR(x) ((x) << S_SET_INTR)
-#define F_SET_INTR V_SET_INTR(1U)
-
-#define S_USED 16
-#define M_USED 0x7ffU
-#define V_USED(x) ((x) << S_USED)
-#define G_USED(x) (((x) >> S_USED) & M_USED)
-
-#define S_ALLOC 0
-#define M_ALLOC 0x7ffU
-#define V_ALLOC(x) ((x) << S_ALLOC)
-#define G_ALLOC(x) (((x) >> S_ALLOC) & M_ALLOC)
-
-#define S_T5_USED 16
-#define M_T5_USED 0xfffU
-#define V_T5_USED(x) ((x) << S_T5_USED)
-#define G_T5_USED(x) (((x) >> S_T5_USED) & M_T5_USED)
-
-#define S_T5_ALLOC 0
-#define M_T5_ALLOC 0xfffU
-#define V_T5_ALLOC(x) ((x) << S_T5_ALLOC)
-#define G_T5_ALLOC(x) (((x) >> S_T5_ALLOC) & M_T5_ALLOC)
-
-#define A_MPS_RX_FIFO_2_CTL 0x11010
-#define A_MPS_RX_PG_RSV1 0x11014
-#define A_MPS_RX_FIFO_3_CTL 0x11014
-#define A_MPS_RX_PG_RSV2 0x11018
-#define A_MPS_RX_PG_RSV3 0x1101c
-#define A_MPS_RX_PG_RSV4 0x11020
-#define A_MPS_RX_PG_RSV5 0x11024
-#define A_MPS_RX_PG_RSV6 0x11028
-#define A_MPS_RX_PG_RSV7 0x1102c
-#define A_MPS_RX_PG_SHR_BG0 0x11030
-
-#define S_EN 31
-#define V_EN(x) ((x) << S_EN)
-#define F_EN V_EN(1U)
-
-#define S_SEL 30
-#define V_SEL(x) ((x) << S_SEL)
-#define F_SEL V_SEL(1U)
-
-#define S_MAX 16
-#define M_MAX 0x7ffU
-#define V_MAX(x) ((x) << S_MAX)
-#define G_MAX(x) (((x) >> S_MAX) & M_MAX)
-
-#define S_BORW 0
-#define M_BORW 0x7ffU
-#define V_BORW(x) ((x) << S_BORW)
-#define G_BORW(x) (((x) >> S_BORW) & M_BORW)
-
-#define S_T5_MAX 16
-#define M_T5_MAX 0xfffU
-#define V_T5_MAX(x) ((x) << S_T5_MAX)
-#define G_T5_MAX(x) (((x) >> S_T5_MAX) & M_T5_MAX)
-
-#define S_T5_BORW 0
-#define M_T5_BORW 0xfffU
-#define V_T5_BORW(x) ((x) << S_T5_BORW)
-#define G_T5_BORW(x) (((x) >> S_T5_BORW) & M_T5_BORW)
-
-#define A_MPS_RX_PG_SHR_BG1 0x11034
-#define A_MPS_RX_PG_SHR_BG2 0x11038
-#define A_MPS_RX_PG_SHR_BG3 0x1103c
-#define A_MPS_RX_PG_SHR0 0x11040
-
-#define S_QUOTA 16
-#define M_QUOTA 0x7ffU
-#define V_QUOTA(x) ((x) << S_QUOTA)
-#define G_QUOTA(x) (((x) >> S_QUOTA) & M_QUOTA)
-
-#define S_SHR_USED 0
-#define M_SHR_USED 0x7ffU
-#define V_SHR_USED(x) ((x) << S_SHR_USED)
-#define G_SHR_USED(x) (((x) >> S_SHR_USED) & M_SHR_USED)
-
-#define S_T5_QUOTA 16
-#define M_T5_QUOTA 0xfffU
-#define V_T5_QUOTA(x) ((x) << S_T5_QUOTA)
-#define G_T5_QUOTA(x) (((x) >> S_T5_QUOTA) & M_T5_QUOTA)
-
-#define S_T5_SHR_USED 0
-#define M_T5_SHR_USED 0xfffU
-#define V_T5_SHR_USED(x) ((x) << S_T5_SHR_USED)
-#define G_T5_SHR_USED(x) (((x) >> S_T5_SHR_USED) & M_T5_SHR_USED)
-
-#define A_MPS_RX_PG_SHR1 0x11044
-#define A_MPS_RX_PG_HYST_BG0 0x11048
-
-#define S_TH 0
-#define M_TH 0x7ffU
-#define V_TH(x) ((x) << S_TH)
-#define G_TH(x) (((x) >> S_TH) & M_TH)
-
-#define S_T5_TH 0
-#define M_T5_TH 0xfffU
-#define V_T5_TH(x) ((x) << S_T5_TH)
-#define G_T5_TH(x) (((x) >> S_T5_TH) & M_T5_TH)
-
-#define S_T6_TH 0
-#define M_T6_TH 0x7ffU
-#define V_T6_TH(x) ((x) << S_T6_TH)
-#define G_T6_TH(x) (((x) >> S_T6_TH) & M_T6_TH)
-
-#define A_MPS_RX_PG_HYST_BG1 0x1104c
-#define A_MPS_RX_PG_HYST_BG2 0x11050
-#define A_MPS_RX_PG_HYST_BG3 0x11054
-#define A_MPS_RX_OCH_CTL 0x11058
-
-#define S_DROP_WT 27
-#define M_DROP_WT 0x1fU
-#define V_DROP_WT(x) ((x) << S_DROP_WT)
-#define G_DROP_WT(x) (((x) >> S_DROP_WT) & M_DROP_WT)
-
-#define S_TRUNC_WT 22
-#define M_TRUNC_WT 0x1fU
-#define V_TRUNC_WT(x) ((x) << S_TRUNC_WT)
-#define G_TRUNC_WT(x) (((x) >> S_TRUNC_WT) & M_TRUNC_WT)
-
-#define S_OCH_DRAIN 13
-#define M_OCH_DRAIN 0x1fU
-#define V_OCH_DRAIN(x) ((x) << S_OCH_DRAIN)
-#define G_OCH_DRAIN(x) (((x) >> S_OCH_DRAIN) & M_OCH_DRAIN)
-
-#define S_OCH_DROP 8
-#define M_OCH_DROP 0x1fU
-#define V_OCH_DROP(x) ((x) << S_OCH_DROP)
-#define G_OCH_DROP(x) (((x) >> S_OCH_DROP) & M_OCH_DROP)
-
-#define S_STOP 0
-#define M_STOP 0x1fU
-#define V_STOP(x) ((x) << S_STOP)
-#define G_STOP(x) (((x) >> S_STOP) & M_STOP)
-
-#define A_MPS_RX_LPBK_BP0 0x1105c
-
-#define S_THRESH 0
-#define M_THRESH 0x7ffU
-#define V_THRESH(x) ((x) << S_THRESH)
-#define G_THRESH(x) (((x) >> S_THRESH) & M_THRESH)
-
-#define A_MPS_RX_LPBK_BP1 0x11060
-#define A_MPS_RX_LPBK_BP2 0x11064
-#define A_MPS_RX_LPBK_BP3 0x11068
-#define A_MPS_RX_PORT_GAP 0x1106c
-
-#define S_GAP 0
-#define M_GAP 0xfffffU
-#define V_GAP(x) ((x) << S_GAP)
-#define G_GAP(x) (((x) >> S_GAP) & M_GAP)
-
-#define A_MPS_RX_CHMN_CNT 0x11070
-#define A_MPS_RX_PERR_INT_CAUSE 0x11074
-
-#define S_FF 23
-#define V_FF(x) ((x) << S_FF)
-#define F_FF V_FF(1U)
-
-#define S_PGMO 22
-#define V_PGMO(x) ((x) << S_PGMO)
-#define F_PGMO V_PGMO(1U)
-
-#define S_PGME 21
-#define V_PGME(x) ((x) << S_PGME)
-#define F_PGME V_PGME(1U)
-
-#define S_CHMN 20
-#define V_CHMN(x) ((x) << S_CHMN)
-#define F_CHMN V_CHMN(1U)
-
-#define S_RPLC 19
-#define V_RPLC(x) ((x) << S_RPLC)
-#define F_RPLC V_RPLC(1U)
-
-#define S_ATRB 18
-#define V_ATRB(x) ((x) << S_ATRB)
-#define F_ATRB V_ATRB(1U)
-
-#define S_PSMX 17
-#define V_PSMX(x) ((x) << S_PSMX)
-#define F_PSMX V_PSMX(1U)
-
-#define S_PGLL 16
-#define V_PGLL(x) ((x) << S_PGLL)
-#define F_PGLL V_PGLL(1U)
-
-#define S_PGFL 15
-#define V_PGFL(x) ((x) << S_PGFL)
-#define F_PGFL V_PGFL(1U)
-
-#define S_PKTQ 14
-#define V_PKTQ(x) ((x) << S_PKTQ)
-#define F_PKTQ V_PKTQ(1U)
-
-#define S_PKFL 13
-#define V_PKFL(x) ((x) << S_PKFL)
-#define F_PKFL V_PKFL(1U)
-
-#define S_PPM3 12
-#define V_PPM3(x) ((x) << S_PPM3)
-#define F_PPM3 V_PPM3(1U)
-
-#define S_PPM2 11
-#define V_PPM2(x) ((x) << S_PPM2)
-#define F_PPM2 V_PPM2(1U)
-
-#define S_PPM1 10
-#define V_PPM1(x) ((x) << S_PPM1)
-#define F_PPM1 V_PPM1(1U)
-
-#define S_PPM0 9
-#define V_PPM0(x) ((x) << S_PPM0)
-#define F_PPM0 V_PPM0(1U)
-
-#define S_SPMX 8
-#define V_SPMX(x) ((x) << S_SPMX)
-#define F_SPMX V_SPMX(1U)
-
-#define S_CDL3 7
-#define V_CDL3(x) ((x) << S_CDL3)
-#define F_CDL3 V_CDL3(1U)
-
-#define S_CDL2 6
-#define V_CDL2(x) ((x) << S_CDL2)
-#define F_CDL2 V_CDL2(1U)
-
-#define S_CDL1 5
-#define V_CDL1(x) ((x) << S_CDL1)
-#define F_CDL1 V_CDL1(1U)
-
-#define S_CDL0 4
-#define V_CDL0(x) ((x) << S_CDL0)
-#define F_CDL0 V_CDL0(1U)
-
-#define S_CDM3 3
-#define V_CDM3(x) ((x) << S_CDM3)
-#define F_CDM3 V_CDM3(1U)
-
-#define S_CDM2 2
-#define V_CDM2(x) ((x) << S_CDM2)
-#define F_CDM2 V_CDM2(1U)
-
-#define S_CDM1 1
-#define V_CDM1(x) ((x) << S_CDM1)
-#define F_CDM1 V_CDM1(1U)
-
-#define S_CDM0 0
-#define V_CDM0(x) ((x) << S_CDM0)
-#define F_CDM0 V_CDM0(1U)
-
-#define S_T6_INT_ERR_INT 24
-#define V_T6_INT_ERR_INT(x) ((x) << S_T6_INT_ERR_INT)
-#define F_T6_INT_ERR_INT V_T6_INT_ERR_INT(1U)
-
-#define A_MPS_RX_PERR_INT_ENABLE 0x11078
-
-#define S_T6_INT_ERR_INT 24
-#define V_T6_INT_ERR_INT(x) ((x) << S_T6_INT_ERR_INT)
-#define F_T6_INT_ERR_INT V_T6_INT_ERR_INT(1U)
-
-#define A_MPS_RX_PERR_ENABLE 0x1107c
-
-#define S_T6_INT_ERR_INT 24
-#define V_T6_INT_ERR_INT(x) ((x) << S_T6_INT_ERR_INT)
-#define F_T6_INT_ERR_INT V_T6_INT_ERR_INT(1U)
-
-#define A_MPS_RX_PERR_INJECT 0x11080
-#define A_MPS_RX_FUNC_INT_CAUSE 0x11084
-
-#define S_INT_ERR_INT 8
-#define M_INT_ERR_INT 0x1fU
-#define V_INT_ERR_INT(x) ((x) << S_INT_ERR_INT)
-#define G_INT_ERR_INT(x) (((x) >> S_INT_ERR_INT) & M_INT_ERR_INT)
-
-#define S_PG_TH_INT7 7
-#define V_PG_TH_INT7(x) ((x) << S_PG_TH_INT7)
-#define F_PG_TH_INT7 V_PG_TH_INT7(1U)
-
-#define S_PG_TH_INT6 6
-#define V_PG_TH_INT6(x) ((x) << S_PG_TH_INT6)
-#define F_PG_TH_INT6 V_PG_TH_INT6(1U)
-
-#define S_PG_TH_INT5 5
-#define V_PG_TH_INT5(x) ((x) << S_PG_TH_INT5)
-#define F_PG_TH_INT5 V_PG_TH_INT5(1U)
-
-#define S_PG_TH_INT4 4
-#define V_PG_TH_INT4(x) ((x) << S_PG_TH_INT4)
-#define F_PG_TH_INT4 V_PG_TH_INT4(1U)
-
-#define S_PG_TH_INT3 3
-#define V_PG_TH_INT3(x) ((x) << S_PG_TH_INT3)
-#define F_PG_TH_INT3 V_PG_TH_INT3(1U)
-
-#define S_PG_TH_INT2 2
-#define V_PG_TH_INT2(x) ((x) << S_PG_TH_INT2)
-#define F_PG_TH_INT2 V_PG_TH_INT2(1U)
-
-#define S_PG_TH_INT1 1
-#define V_PG_TH_INT1(x) ((x) << S_PG_TH_INT1)
-#define F_PG_TH_INT1 V_PG_TH_INT1(1U)
-
-#define S_PG_TH_INT0 0
-#define V_PG_TH_INT0(x) ((x) << S_PG_TH_INT0)
-#define F_PG_TH_INT0 V_PG_TH_INT0(1U)
-
-#define S_MTU_ERR_INT3 19
-#define V_MTU_ERR_INT3(x) ((x) << S_MTU_ERR_INT3)
-#define F_MTU_ERR_INT3 V_MTU_ERR_INT3(1U)
-
-#define S_MTU_ERR_INT2 18
-#define V_MTU_ERR_INT2(x) ((x) << S_MTU_ERR_INT2)
-#define F_MTU_ERR_INT2 V_MTU_ERR_INT2(1U)
-
-#define S_MTU_ERR_INT1 17
-#define V_MTU_ERR_INT1(x) ((x) << S_MTU_ERR_INT1)
-#define F_MTU_ERR_INT1 V_MTU_ERR_INT1(1U)
-
-#define S_MTU_ERR_INT0 16
-#define V_MTU_ERR_INT0(x) ((x) << S_MTU_ERR_INT0)
-#define F_MTU_ERR_INT0 V_MTU_ERR_INT0(1U)
-
-#define S_SE_CNT_ERR_INT 15
-#define V_SE_CNT_ERR_INT(x) ((x) << S_SE_CNT_ERR_INT)
-#define F_SE_CNT_ERR_INT V_SE_CNT_ERR_INT(1U)
-
-#define S_FRM_ERR_INT 14
-#define V_FRM_ERR_INT(x) ((x) << S_FRM_ERR_INT)
-#define F_FRM_ERR_INT V_FRM_ERR_INT(1U)
-
-#define S_LEN_ERR_INT 13
-#define V_LEN_ERR_INT(x) ((x) << S_LEN_ERR_INT)
-#define F_LEN_ERR_INT V_LEN_ERR_INT(1U)
-
-#define A_MPS_RX_FUNC_INT_ENABLE 0x11088
-#define A_MPS_RX_PAUSE_GEN_TH_0 0x1108c
-
-#define S_TH_HIGH 16
-#define M_TH_HIGH 0xffffU
-#define V_TH_HIGH(x) ((x) << S_TH_HIGH)
-#define G_TH_HIGH(x) (((x) >> S_TH_HIGH) & M_TH_HIGH)
-
-#define S_TH_LOW 0
-#define M_TH_LOW 0xffffU
-#define V_TH_LOW(x) ((x) << S_TH_LOW)
-#define G_TH_LOW(x) (((x) >> S_TH_LOW) & M_TH_LOW)
-
-#define A_MPS_RX_PAUSE_GEN_TH_1 0x11090
-#define A_MPS_RX_PAUSE_GEN_TH_2 0x11094
-#define A_MPS_RX_PAUSE_GEN_TH_3 0x11098
-#define A_MPS_RX_REPL_CTL 0x11098
-
-#define S_INDEX_SEL 0
-#define V_INDEX_SEL(x) ((x) << S_INDEX_SEL)
-#define F_INDEX_SEL V_INDEX_SEL(1U)
-
-#define A_MPS_RX_PPP_ATRB 0x1109c
-
-#define S_ETYPE 16
-#define M_ETYPE 0xffffU
-#define V_ETYPE(x) ((x) << S_ETYPE)
-#define G_ETYPE(x) (((x) >> S_ETYPE) & M_ETYPE)
-
-#define S_OPCODE 0
-#define M_OPCODE 0xffffU
-#define V_OPCODE(x) ((x) << S_OPCODE)
-#define G_OPCODE(x) (((x) >> S_OPCODE) & M_OPCODE)
-
-#define A_MPS_RX_QFC0_ATRB 0x110a0
-
-#define S_DA 0
-#define M_DA 0xffffU
-#define V_DA(x) ((x) << S_DA)
-#define G_DA(x) (((x) >> S_DA) & M_DA)
-
-#define A_MPS_RX_QFC1_ATRB 0x110a4
-#define A_MPS_RX_PT_ARB0 0x110a8
-
-#define S_LPBK_WT 16
-#define M_LPBK_WT 0x3fffU
-#define V_LPBK_WT(x) ((x) << S_LPBK_WT)
-#define G_LPBK_WT(x) (((x) >> S_LPBK_WT) & M_LPBK_WT)
-
-#define S_MAC_WT 0
-#define M_MAC_WT 0x3fffU
-#define V_MAC_WT(x) ((x) << S_MAC_WT)
-#define G_MAC_WT(x) (((x) >> S_MAC_WT) & M_MAC_WT)
-
-#define A_MPS_RX_PT_ARB1 0x110ac
-#define A_MPS_RX_PT_ARB2 0x110b0
-#define A_MPS_RX_PT_ARB3 0x110b4
-#define A_T6_MPS_PF_OUT_EN 0x110b4
-#define A_MPS_RX_PT_ARB4 0x110b8
-#define A_T6_MPS_BMC_MTU 0x110b8
-#define A_MPS_PF_OUT_EN 0x110bc
-
-#define S_OUTEN 0
-#define M_OUTEN 0xffU
-#define V_OUTEN(x) ((x) << S_OUTEN)
-#define G_OUTEN(x) (((x) >> S_OUTEN) & M_OUTEN)
-
-#define A_T6_MPS_BMC_PKT_CNT 0x110bc
-#define A_MPS_BMC_MTU 0x110c0
-
-#define S_MTU 0
-#define M_MTU 0x3fffU
-#define V_MTU(x) ((x) << S_MTU)
-#define G_MTU(x) (((x) >> S_MTU) & M_MTU)
-
-#define A_T6_MPS_BMC_BYTE_CNT 0x110c0
-#define A_MPS_BMC_PKT_CNT 0x110c4
-#define A_T6_MPS_PFVF_ATRB_CTL 0x110c4
-
-#define S_T6_PFVF 0
-#define M_T6_PFVF 0x1ffU
-#define V_T6_PFVF(x) ((x) << S_T6_PFVF)
-#define G_T6_PFVF(x) (((x) >> S_T6_PFVF) & M_T6_PFVF)
-
-#define A_MPS_BMC_BYTE_CNT 0x110c8
-#define A_T6_MPS_PFVF_ATRB 0x110c8
-
-#define S_FULL_FRAME_MODE 14
-#define V_FULL_FRAME_MODE(x) ((x) << S_FULL_FRAME_MODE)
-#define F_FULL_FRAME_MODE V_FULL_FRAME_MODE(1U)
-
-#define A_MPS_PFVF_ATRB_CTL 0x110cc
-
-#define S_RD_WRN 31
-#define V_RD_WRN(x) ((x) << S_RD_WRN)
-#define F_RD_WRN V_RD_WRN(1U)
-
-#define S_PFVF 0
-#define M_PFVF 0xffU
-#define V_PFVF(x) ((x) << S_PFVF)
-#define G_PFVF(x) (((x) >> S_PFVF) & M_PFVF)
-
-#define A_T6_MPS_PFVF_ATRB_FLTR0 0x110cc
-#define A_MPS_PFVF_ATRB 0x110d0
-
-#define S_ATTR_PF 28
-#define M_ATTR_PF 0x7U
-#define V_ATTR_PF(x) ((x) << S_ATTR_PF)
-#define G_ATTR_PF(x) (((x) >> S_ATTR_PF) & M_ATTR_PF)
-
-#define S_OFF 18
-#define V_OFF(x) ((x) << S_OFF)
-#define F_OFF V_OFF(1U)
-
-#define S_NV_DROP 17
-#define V_NV_DROP(x) ((x) << S_NV_DROP)
-#define F_NV_DROP V_NV_DROP(1U)
-
-#define S_ATTR_MODE 16
-#define V_ATTR_MODE(x) ((x) << S_ATTR_MODE)
-#define F_ATTR_MODE V_ATTR_MODE(1U)
-
-#define A_T6_MPS_PFVF_ATRB_FLTR1 0x110d0
-#define A_MPS_PFVF_ATRB_FLTR0 0x110d4
-
-#define S_VLAN_EN 16
-#define V_VLAN_EN(x) ((x) << S_VLAN_EN)
-#define F_VLAN_EN V_VLAN_EN(1U)
-
-#define S_VLAN_ID 0
-#define M_VLAN_ID 0xfffU
-#define V_VLAN_ID(x) ((x) << S_VLAN_ID)
-#define G_VLAN_ID(x) (((x) >> S_VLAN_ID) & M_VLAN_ID)
-
-#define A_T6_MPS_PFVF_ATRB_FLTR2 0x110d4
-#define A_MPS_PFVF_ATRB_FLTR1 0x110d8
-#define A_T6_MPS_PFVF_ATRB_FLTR3 0x110d8
-#define A_MPS_PFVF_ATRB_FLTR2 0x110dc
-#define A_T6_MPS_PFVF_ATRB_FLTR4 0x110dc
-#define A_MPS_PFVF_ATRB_FLTR3 0x110e0
-#define A_T6_MPS_PFVF_ATRB_FLTR5 0x110e0
-#define A_MPS_PFVF_ATRB_FLTR4 0x110e4
-#define A_T6_MPS_PFVF_ATRB_FLTR6 0x110e4
-#define A_MPS_PFVF_ATRB_FLTR5 0x110e8
-#define A_T6_MPS_PFVF_ATRB_FLTR7 0x110e8
-#define A_MPS_PFVF_ATRB_FLTR6 0x110ec
-#define A_T6_MPS_PFVF_ATRB_FLTR8 0x110ec
-#define A_MPS_PFVF_ATRB_FLTR7 0x110f0
-#define A_T6_MPS_PFVF_ATRB_FLTR9 0x110f0
-#define A_MPS_PFVF_ATRB_FLTR8 0x110f4
-#define A_T6_MPS_PFVF_ATRB_FLTR10 0x110f4
-#define A_MPS_PFVF_ATRB_FLTR9 0x110f8
-#define A_T6_MPS_PFVF_ATRB_FLTR11 0x110f8
-#define A_MPS_PFVF_ATRB_FLTR10 0x110fc
-#define A_T6_MPS_PFVF_ATRB_FLTR12 0x110fc
-#define A_MPS_PFVF_ATRB_FLTR11 0x11100
-#define A_T6_MPS_PFVF_ATRB_FLTR13 0x11100
-#define A_MPS_PFVF_ATRB_FLTR12 0x11104
-#define A_T6_MPS_PFVF_ATRB_FLTR14 0x11104
-#define A_MPS_PFVF_ATRB_FLTR13 0x11108
-#define A_T6_MPS_PFVF_ATRB_FLTR15 0x11108
-#define A_MPS_PFVF_ATRB_FLTR14 0x1110c
-#define A_T6_MPS_RPLC_MAP_CTL 0x1110c
-#define A_MPS_PFVF_ATRB_FLTR15 0x11110
-#define A_T6_MPS_PF_RPLCT_MAP 0x11110
-#define A_MPS_RPLC_MAP_CTL 0x11114
-
-#define S_RPLC_MAP_ADDR 0
-#define M_RPLC_MAP_ADDR 0x3ffU
-#define V_RPLC_MAP_ADDR(x) ((x) << S_RPLC_MAP_ADDR)
-#define G_RPLC_MAP_ADDR(x) (((x) >> S_RPLC_MAP_ADDR) & M_RPLC_MAP_ADDR)
-
-#define A_T6_MPS_VF_RPLCT_MAP0 0x11114
-#define A_MPS_PF_RPLCT_MAP 0x11118
-
-#define S_PF_EN 0
-#define M_PF_EN 0xffU
-#define V_PF_EN(x) ((x) << S_PF_EN)
-#define G_PF_EN(x) (((x) >> S_PF_EN) & M_PF_EN)
-
-#define A_T6_MPS_VF_RPLCT_MAP1 0x11118
-#define A_MPS_VF_RPLCT_MAP0 0x1111c
-#define A_T6_MPS_VF_RPLCT_MAP2 0x1111c
-#define A_MPS_VF_RPLCT_MAP1 0x11120
-#define A_T6_MPS_VF_RPLCT_MAP3 0x11120
-#define A_MPS_VF_RPLCT_MAP2 0x11124
-#define A_MPS_VF_RPLCT_MAP3 0x11128
-#define A_MPS_MEM_DBG_CTL 0x1112c
-
-#define S_PKD 17
-#define V_PKD(x) ((x) << S_PKD)
-#define F_PKD V_PKD(1U)
-
-#define S_PGD 16
-#define V_PGD(x) ((x) << S_PGD)
-#define F_PGD V_PGD(1U)
-
-#define A_MPS_PKD_MEM_DATA0 0x11130
-#define A_MPS_PKD_MEM_DATA1 0x11134
-#define A_MPS_PKD_MEM_DATA2 0x11138
-#define A_MPS_PGD_MEM_DATA 0x1113c
-#define A_MPS_RX_SE_CNT_ERR 0x11140
-
-#define S_RX_SE_ERRMAP 0
-#define M_RX_SE_ERRMAP 0xfffffU
-#define V_RX_SE_ERRMAP(x) ((x) << S_RX_SE_ERRMAP)
-#define G_RX_SE_ERRMAP(x) (((x) >> S_RX_SE_ERRMAP) & M_RX_SE_ERRMAP)
-
-#define A_MPS_RX_SE_CNT_CLR 0x11144
-#define A_MPS_RX_SE_CNT_IN0 0x11148
-
-#define S_SOP_CNT_PM 24
-#define M_SOP_CNT_PM 0xffU
-#define V_SOP_CNT_PM(x) ((x) << S_SOP_CNT_PM)
-#define G_SOP_CNT_PM(x) (((x) >> S_SOP_CNT_PM) & M_SOP_CNT_PM)
-
-#define S_EOP_CNT_PM 16
-#define M_EOP_CNT_PM 0xffU
-#define V_EOP_CNT_PM(x) ((x) << S_EOP_CNT_PM)
-#define G_EOP_CNT_PM(x) (((x) >> S_EOP_CNT_PM) & M_EOP_CNT_PM)
-
-#define S_SOP_CNT_IN 8
-#define M_SOP_CNT_IN 0xffU
-#define V_SOP_CNT_IN(x) ((x) << S_SOP_CNT_IN)
-#define G_SOP_CNT_IN(x) (((x) >> S_SOP_CNT_IN) & M_SOP_CNT_IN)
-
-#define S_EOP_CNT_IN 0
-#define M_EOP_CNT_IN 0xffU
-#define V_EOP_CNT_IN(x) ((x) << S_EOP_CNT_IN)
-#define G_EOP_CNT_IN(x) (((x) >> S_EOP_CNT_IN) & M_EOP_CNT_IN)
-
-#define A_MPS_RX_SE_CNT_IN1 0x1114c
-#define A_MPS_RX_SE_CNT_IN2 0x11150
-#define A_MPS_RX_SE_CNT_IN3 0x11154
-#define A_MPS_RX_SE_CNT_IN4 0x11158
-#define A_MPS_RX_SE_CNT_IN5 0x1115c
-#define A_MPS_RX_SE_CNT_IN6 0x11160
-#define A_MPS_RX_SE_CNT_IN7 0x11164
-#define A_MPS_RX_SE_CNT_OUT01 0x11168
-
-#define S_SOP_CNT_1 24
-#define M_SOP_CNT_1 0xffU
-#define V_SOP_CNT_1(x) ((x) << S_SOP_CNT_1)
-#define G_SOP_CNT_1(x) (((x) >> S_SOP_CNT_1) & M_SOP_CNT_1)
-
-#define S_EOP_CNT_1 16
-#define M_EOP_CNT_1 0xffU
-#define V_EOP_CNT_1(x) ((x) << S_EOP_CNT_1)
-#define G_EOP_CNT_1(x) (((x) >> S_EOP_CNT_1) & M_EOP_CNT_1)
-
-#define S_SOP_CNT_0 8
-#define M_SOP_CNT_0 0xffU
-#define V_SOP_CNT_0(x) ((x) << S_SOP_CNT_0)
-#define G_SOP_CNT_0(x) (((x) >> S_SOP_CNT_0) & M_SOP_CNT_0)
-
-#define S_EOP_CNT_0 0
-#define M_EOP_CNT_0 0xffU
-#define V_EOP_CNT_0(x) ((x) << S_EOP_CNT_0)
-#define G_EOP_CNT_0(x) (((x) >> S_EOP_CNT_0) & M_EOP_CNT_0)
-
-#define A_MPS_RX_SE_CNT_OUT23 0x1116c
-
-#define S_SOP_CNT_3 24
-#define M_SOP_CNT_3 0xffU
-#define V_SOP_CNT_3(x) ((x) << S_SOP_CNT_3)
-#define G_SOP_CNT_3(x) (((x) >> S_SOP_CNT_3) & M_SOP_CNT_3)
-
-#define S_EOP_CNT_3 16
-#define M_EOP_CNT_3 0xffU
-#define V_EOP_CNT_3(x) ((x) << S_EOP_CNT_3)
-#define G_EOP_CNT_3(x) (((x) >> S_EOP_CNT_3) & M_EOP_CNT_3)
-
-#define S_SOP_CNT_2 8
-#define M_SOP_CNT_2 0xffU
-#define V_SOP_CNT_2(x) ((x) << S_SOP_CNT_2)
-#define G_SOP_CNT_2(x) (((x) >> S_SOP_CNT_2) & M_SOP_CNT_2)
-
-#define S_EOP_CNT_2 0
-#define M_EOP_CNT_2 0xffU
-#define V_EOP_CNT_2(x) ((x) << S_EOP_CNT_2)
-#define G_EOP_CNT_2(x) (((x) >> S_EOP_CNT_2) & M_EOP_CNT_2)
-
-#define A_MPS_RX_SPI_ERR 0x11170
-
-#define S_LENERR 21
-#define M_LENERR 0xfU
-#define V_LENERR(x) ((x) << S_LENERR)
-#define G_LENERR(x) (((x) >> S_LENERR) & M_LENERR)
-
-#define S_SPIERR 0
-#define M_SPIERR 0x1fffffU
-#define V_SPIERR(x) ((x) << S_SPIERR)
-#define G_SPIERR(x) (((x) >> S_SPIERR) & M_SPIERR)
-
-#define A_MPS_RX_IN_BUS_STATE 0x11174
-
-#define S_ST3 24
-#define M_ST3 0xffU
-#define V_ST3(x) ((x) << S_ST3)
-#define G_ST3(x) (((x) >> S_ST3) & M_ST3)
-
-#define S_ST2 16
-#define M_ST2 0xffU
-#define V_ST2(x) ((x) << S_ST2)
-#define G_ST2(x) (((x) >> S_ST2) & M_ST2)
-
-#define S_ST1 8
-#define M_ST1 0xffU
-#define V_ST1(x) ((x) << S_ST1)
-#define G_ST1(x) (((x) >> S_ST1) & M_ST1)
-
-#define S_ST0 0
-#define M_ST0 0xffU
-#define V_ST0(x) ((x) << S_ST0)
-#define G_ST0(x) (((x) >> S_ST0) & M_ST0)
-
-#define A_MPS_RX_OUT_BUS_STATE 0x11178
-
-#define S_ST_NCSI 23
-#define M_ST_NCSI 0x1ffU
-#define V_ST_NCSI(x) ((x) << S_ST_NCSI)
-#define G_ST_NCSI(x) (((x) >> S_ST_NCSI) & M_ST_NCSI)
-
-#define S_ST_TP 0
-#define M_ST_TP 0x7fffffU
-#define V_ST_TP(x) ((x) << S_ST_TP)
-#define G_ST_TP(x) (((x) >> S_ST_TP) & M_ST_TP)
-
-#define A_MPS_RX_DBG_CTL 0x1117c
-
-#define S_OUT_DBG_CHNL 8
-#define M_OUT_DBG_CHNL 0x7U
-#define V_OUT_DBG_CHNL(x) ((x) << S_OUT_DBG_CHNL)
-#define G_OUT_DBG_CHNL(x) (((x) >> S_OUT_DBG_CHNL) & M_OUT_DBG_CHNL)
-
-#define S_DBG_PKD_QSEL 7
-#define V_DBG_PKD_QSEL(x) ((x) << S_DBG_PKD_QSEL)
-#define F_DBG_PKD_QSEL V_DBG_PKD_QSEL(1U)
-
-#define S_DBG_CDS_INV 6
-#define V_DBG_CDS_INV(x) ((x) << S_DBG_CDS_INV)
-#define F_DBG_CDS_INV V_DBG_CDS_INV(1U)
-
-#define S_IN_DBG_PORT 3
-#define M_IN_DBG_PORT 0x7U
-#define V_IN_DBG_PORT(x) ((x) << S_IN_DBG_PORT)
-#define G_IN_DBG_PORT(x) (((x) >> S_IN_DBG_PORT) & M_IN_DBG_PORT)
-
-#define S_IN_DBG_CHNL 0
-#define M_IN_DBG_CHNL 0x7U
-#define V_IN_DBG_CHNL(x) ((x) << S_IN_DBG_CHNL)
-#define G_IN_DBG_CHNL(x) (((x) >> S_IN_DBG_CHNL) & M_IN_DBG_CHNL)
-
-#define A_MPS_RX_CLS_DROP_CNT0 0x11180
-
-#define S_LPBK_CNT0 16
-#define M_LPBK_CNT0 0xffffU
-#define V_LPBK_CNT0(x) ((x) << S_LPBK_CNT0)
-#define G_LPBK_CNT0(x) (((x) >> S_LPBK_CNT0) & M_LPBK_CNT0)
-
-#define S_MAC_CNT0 0
-#define M_MAC_CNT0 0xffffU
-#define V_MAC_CNT0(x) ((x) << S_MAC_CNT0)
-#define G_MAC_CNT0(x) (((x) >> S_MAC_CNT0) & M_MAC_CNT0)
-
-#define A_MPS_RX_CLS_DROP_CNT1 0x11184
-
-#define S_LPBK_CNT1 16
-#define M_LPBK_CNT1 0xffffU
-#define V_LPBK_CNT1(x) ((x) << S_LPBK_CNT1)
-#define G_LPBK_CNT1(x) (((x) >> S_LPBK_CNT1) & M_LPBK_CNT1)
-
-#define S_MAC_CNT1 0
-#define M_MAC_CNT1 0xffffU
-#define V_MAC_CNT1(x) ((x) << S_MAC_CNT1)
-#define G_MAC_CNT1(x) (((x) >> S_MAC_CNT1) & M_MAC_CNT1)
-
-#define A_MPS_RX_CLS_DROP_CNT2 0x11188
-
-#define S_LPBK_CNT2 16
-#define M_LPBK_CNT2 0xffffU
-#define V_LPBK_CNT2(x) ((x) << S_LPBK_CNT2)
-#define G_LPBK_CNT2(x) (((x) >> S_LPBK_CNT2) & M_LPBK_CNT2)
-
-#define S_MAC_CNT2 0
-#define M_MAC_CNT2 0xffffU
-#define V_MAC_CNT2(x) ((x) << S_MAC_CNT2)
-#define G_MAC_CNT2(x) (((x) >> S_MAC_CNT2) & M_MAC_CNT2)
-
-#define A_MPS_RX_CLS_DROP_CNT3 0x1118c
-
-#define S_LPBK_CNT3 16
-#define M_LPBK_CNT3 0xffffU
-#define V_LPBK_CNT3(x) ((x) << S_LPBK_CNT3)
-#define G_LPBK_CNT3(x) (((x) >> S_LPBK_CNT3) & M_LPBK_CNT3)
-
-#define S_MAC_CNT3 0
-#define M_MAC_CNT3 0xffffU
-#define V_MAC_CNT3(x) ((x) << S_MAC_CNT3)
-#define G_MAC_CNT3(x) (((x) >> S_MAC_CNT3) & M_MAC_CNT3)
-
-#define A_MPS_RX_SPARE 0x11190
-#define A_MPS_RX_PTP_ETYPE 0x11194
-
-#define S_PETYPE2 16
-#define M_PETYPE2 0xffffU
-#define V_PETYPE2(x) ((x) << S_PETYPE2)
-#define G_PETYPE2(x) (((x) >> S_PETYPE2) & M_PETYPE2)
-
-#define S_PETYPE1 0
-#define M_PETYPE1 0xffffU
-#define V_PETYPE1(x) ((x) << S_PETYPE1)
-#define G_PETYPE1(x) (((x) >> S_PETYPE1) & M_PETYPE1)
-
-#define A_MPS_RX_PTP_TCP 0x11198
-
-#define S_PTCPORT2 16
-#define M_PTCPORT2 0xffffU
-#define V_PTCPORT2(x) ((x) << S_PTCPORT2)
-#define G_PTCPORT2(x) (((x) >> S_PTCPORT2) & M_PTCPORT2)
-
-#define S_PTCPORT1 0
-#define M_PTCPORT1 0xffffU
-#define V_PTCPORT1(x) ((x) << S_PTCPORT1)
-#define G_PTCPORT1(x) (((x) >> S_PTCPORT1) & M_PTCPORT1)
-
-#define A_MPS_RX_PTP_UDP 0x1119c
-
-#define S_PUDPORT2 16
-#define M_PUDPORT2 0xffffU
-#define V_PUDPORT2(x) ((x) << S_PUDPORT2)
-#define G_PUDPORT2(x) (((x) >> S_PUDPORT2) & M_PUDPORT2)
-
-#define S_PUDPORT1 0
-#define M_PUDPORT1 0xffffU
-#define V_PUDPORT1(x) ((x) << S_PUDPORT1)
-#define G_PUDPORT1(x) (((x) >> S_PUDPORT1) & M_PUDPORT1)
-
-#define A_MPS_RX_PTP_CTL 0x111a0
-
-#define S_MIN_PTP_SPACE 24
-#define M_MIN_PTP_SPACE 0x7fU
-#define V_MIN_PTP_SPACE(x) ((x) << S_MIN_PTP_SPACE)
-#define G_MIN_PTP_SPACE(x) (((x) >> S_MIN_PTP_SPACE) & M_MIN_PTP_SPACE)
-
-#define S_PUDP2EN 20
-#define M_PUDP2EN 0xfU
-#define V_PUDP2EN(x) ((x) << S_PUDP2EN)
-#define G_PUDP2EN(x) (((x) >> S_PUDP2EN) & M_PUDP2EN)
-
-#define S_PUDP1EN 16
-#define M_PUDP1EN 0xfU
-#define V_PUDP1EN(x) ((x) << S_PUDP1EN)
-#define G_PUDP1EN(x) (((x) >> S_PUDP1EN) & M_PUDP1EN)
-
-#define S_PTCP2EN 12
-#define M_PTCP2EN 0xfU
-#define V_PTCP2EN(x) ((x) << S_PTCP2EN)
-#define G_PTCP2EN(x) (((x) >> S_PTCP2EN) & M_PTCP2EN)
-
-#define S_PTCP1EN 8
-#define M_PTCP1EN 0xfU
-#define V_PTCP1EN(x) ((x) << S_PTCP1EN)
-#define G_PTCP1EN(x) (((x) >> S_PTCP1EN) & M_PTCP1EN)
-
-#define S_PETYPE2EN 4
-#define M_PETYPE2EN 0xfU
-#define V_PETYPE2EN(x) ((x) << S_PETYPE2EN)
-#define G_PETYPE2EN(x) (((x) >> S_PETYPE2EN) & M_PETYPE2EN)
-
-#define S_PETYPE1EN 0
-#define M_PETYPE1EN 0xfU
-#define V_PETYPE1EN(x) ((x) << S_PETYPE1EN)
-#define G_PETYPE1EN(x) (((x) >> S_PETYPE1EN) & M_PETYPE1EN)
-
-#define A_MPS_RX_PAUSE_GEN_TH_0_0 0x111a4
-#define A_MPS_RX_PAUSE_GEN_TH_0_1 0x111a8
-#define A_MPS_RX_PAUSE_GEN_TH_0_2 0x111ac
-#define A_MPS_RX_PAUSE_GEN_TH_0_3 0x111b0
-#define A_MPS_RX_PAUSE_GEN_TH_1_0 0x111b4
-#define A_MPS_RX_PAUSE_GEN_TH_1_1 0x111b8
-#define A_MPS_RX_PAUSE_GEN_TH_1_2 0x111bc
-#define A_MPS_RX_PAUSE_GEN_TH_1_3 0x111c0
-#define A_MPS_RX_PAUSE_GEN_TH_2_0 0x111c4
-#define A_MPS_RX_PAUSE_GEN_TH_2_1 0x111c8
-#define A_MPS_RX_PAUSE_GEN_TH_2_2 0x111cc
-#define A_MPS_RX_PAUSE_GEN_TH_2_3 0x111d0
-#define A_MPS_RX_PAUSE_GEN_TH_3_0 0x111d4
-#define A_MPS_RX_PAUSE_GEN_TH_3_1 0x111d8
-#define A_MPS_RX_PAUSE_GEN_TH_3_2 0x111dc
-#define A_MPS_RX_PAUSE_GEN_TH_3_3 0x111e0
-#define A_MPS_RX_MAC_CLS_DROP_CNT0 0x111e4
-#define A_MPS_RX_MAC_CLS_DROP_CNT1 0x111e8
-#define A_MPS_RX_MAC_CLS_DROP_CNT2 0x111ec
-#define A_MPS_RX_MAC_CLS_DROP_CNT3 0x111f0
-#define A_MPS_RX_LPBK_CLS_DROP_CNT0 0x111f4
-#define A_MPS_RX_LPBK_CLS_DROP_CNT1 0x111f8
-#define A_MPS_RX_LPBK_CLS_DROP_CNT2 0x111fc
-#define A_MPS_RX_LPBK_CLS_DROP_CNT3 0x11200
-#define A_MPS_RX_CGEN 0x11204
-
-#define S_MPS_RX_CGEN_NCSI 12
-#define V_MPS_RX_CGEN_NCSI(x) ((x) << S_MPS_RX_CGEN_NCSI)
-#define F_MPS_RX_CGEN_NCSI V_MPS_RX_CGEN_NCSI(1U)
-
-#define S_MPS_RX_CGEN_OUT 8
-#define M_MPS_RX_CGEN_OUT 0xfU
-#define V_MPS_RX_CGEN_OUT(x) ((x) << S_MPS_RX_CGEN_OUT)
-#define G_MPS_RX_CGEN_OUT(x) (((x) >> S_MPS_RX_CGEN_OUT) & M_MPS_RX_CGEN_OUT)
-
-#define S_MPS_RX_CGEN_LPBK_IN 4
-#define M_MPS_RX_CGEN_LPBK_IN 0xfU
-#define V_MPS_RX_CGEN_LPBK_IN(x) ((x) << S_MPS_RX_CGEN_LPBK_IN)
-#define G_MPS_RX_CGEN_LPBK_IN(x) (((x) >> S_MPS_RX_CGEN_LPBK_IN) & M_MPS_RX_CGEN_LPBK_IN)
-
-#define S_MPS_RX_CGEN_MAC_IN 0
-#define M_MPS_RX_CGEN_MAC_IN 0xfU
-#define V_MPS_RX_CGEN_MAC_IN(x) ((x) << S_MPS_RX_CGEN_MAC_IN)
-#define G_MPS_RX_CGEN_MAC_IN(x) (((x) >> S_MPS_RX_CGEN_MAC_IN) & M_MPS_RX_CGEN_MAC_IN)
-
-#define A_MPS_RX_MAC_BG_PG_CNT0 0x11208
-
-#define S_MAC_USED 16
-#define M_MAC_USED 0x7ffU
-#define V_MAC_USED(x) ((x) << S_MAC_USED)
-#define G_MAC_USED(x) (((x) >> S_MAC_USED) & M_MAC_USED)
-
-#define S_MAC_ALLOC 0
-#define M_MAC_ALLOC 0x7ffU
-#define V_MAC_ALLOC(x) ((x) << S_MAC_ALLOC)
-#define G_MAC_ALLOC(x) (((x) >> S_MAC_ALLOC) & M_MAC_ALLOC)
-
-#define A_MPS_RX_MAC_BG_PG_CNT1 0x1120c
-#define A_MPS_RX_MAC_BG_PG_CNT2 0x11210
-#define A_MPS_RX_MAC_BG_PG_CNT3 0x11214
-#define A_MPS_RX_LPBK_BG_PG_CNT0 0x11218
-
-#define S_LPBK_USED 16
-#define M_LPBK_USED 0x7ffU
-#define V_LPBK_USED(x) ((x) << S_LPBK_USED)
-#define G_LPBK_USED(x) (((x) >> S_LPBK_USED) & M_LPBK_USED)
-
-#define S_LPBK_ALLOC 0
-#define M_LPBK_ALLOC 0x7ffU
-#define V_LPBK_ALLOC(x) ((x) << S_LPBK_ALLOC)
-#define G_LPBK_ALLOC(x) (((x) >> S_LPBK_ALLOC) & M_LPBK_ALLOC)
-
-#define A_MPS_RX_LPBK_BG_PG_CNT1 0x1121c
-#define A_MPS_RX_CONGESTION_THRESHOLD_BG0 0x11220
-
-#define S_CONG_EN 31
-#define V_CONG_EN(x) ((x) << S_CONG_EN)
-#define F_CONG_EN V_CONG_EN(1U)
-
-#define S_CONG_TH 0
-#define M_CONG_TH 0xfffffU
-#define V_CONG_TH(x) ((x) << S_CONG_TH)
-#define G_CONG_TH(x) (((x) >> S_CONG_TH) & M_CONG_TH)
-
-#define A_MPS_RX_CONGESTION_THRESHOLD_BG1 0x11224
-#define A_MPS_RX_CONGESTION_THRESHOLD_BG2 0x11228
-#define A_MPS_RX_CONGESTION_THRESHOLD_BG3 0x1122c
-#define A_MPS_RX_GRE_PROT_TYPE 0x11230
-
-#define S_NVGRE_EN 9
-#define V_NVGRE_EN(x) ((x) << S_NVGRE_EN)
-#define F_NVGRE_EN V_NVGRE_EN(1U)
-
-#define S_GRE_EN 8
-#define V_GRE_EN(x) ((x) << S_GRE_EN)
-#define F_GRE_EN V_GRE_EN(1U)
-
-#define S_GRE 0
-#define M_GRE 0xffU
-#define V_GRE(x) ((x) << S_GRE)
-#define G_GRE(x) (((x) >> S_GRE) & M_GRE)
-
-#define A_MPS_RX_VXLAN_TYPE 0x11234
-
-#define S_VXLAN_EN 16
-#define V_VXLAN_EN(x) ((x) << S_VXLAN_EN)
-#define F_VXLAN_EN V_VXLAN_EN(1U)
-
-#define S_VXLAN 0
-#define M_VXLAN 0xffffU
-#define V_VXLAN(x) ((x) << S_VXLAN)
-#define G_VXLAN(x) (((x) >> S_VXLAN) & M_VXLAN)
-
-#define A_MPS_RX_GENEVE_TYPE 0x11238
-
-#define S_GENEVE_EN 16
-#define V_GENEVE_EN(x) ((x) << S_GENEVE_EN)
-#define F_GENEVE_EN V_GENEVE_EN(1U)
-
-#define S_GENEVE 0
-#define M_GENEVE 0xffffU
-#define V_GENEVE(x) ((x) << S_GENEVE)
-#define G_GENEVE(x) (((x) >> S_GENEVE) & M_GENEVE)
-
-#define A_MPS_RX_INNER_HDR_IVLAN 0x1123c
-
-#define S_T6_IVLAN_EN 16
-#define V_T6_IVLAN_EN(x) ((x) << S_T6_IVLAN_EN)
-#define F_T6_IVLAN_EN V_T6_IVLAN_EN(1U)
-
-#define A_MPS_RX_ENCAP_NVGRE 0x11240
-
-#define S_ETYPE_EN 16
-#define V_ETYPE_EN(x) ((x) << S_ETYPE_EN)
-#define F_ETYPE_EN V_ETYPE_EN(1U)
-
-#define S_T6_ETYPE 0
-#define M_T6_ETYPE 0xffffU
-#define V_T6_ETYPE(x) ((x) << S_T6_ETYPE)
-#define G_T6_ETYPE(x) (((x) >> S_T6_ETYPE) & M_T6_ETYPE)
-
-#define A_MPS_RX_ENCAP_GENEVE 0x11244
-
-#define S_T6_ETYPE 0
-#define M_T6_ETYPE 0xffffU
-#define V_T6_ETYPE(x) ((x) << S_T6_ETYPE)
-#define G_T6_ETYPE(x) (((x) >> S_T6_ETYPE) & M_T6_ETYPE)
-
-#define A_MPS_RX_TCP 0x11248
-
-#define S_PROT_TYPE_EN 8
-#define V_PROT_TYPE_EN(x) ((x) << S_PROT_TYPE_EN)
-#define F_PROT_TYPE_EN V_PROT_TYPE_EN(1U)
-
-#define S_PROT_TYPE 0
-#define M_PROT_TYPE 0xffU
-#define V_PROT_TYPE(x) ((x) << S_PROT_TYPE)
-#define G_PROT_TYPE(x) (((x) >> S_PROT_TYPE) & M_PROT_TYPE)
-
-#define A_MPS_RX_UDP 0x1124c
-#define A_MPS_RX_PAUSE 0x11250
-#define A_MPS_RX_LENGTH 0x11254
-
-#define S_SAP_VALUE 16
-#define M_SAP_VALUE 0xffffU
-#define V_SAP_VALUE(x) ((x) << S_SAP_VALUE)
-#define G_SAP_VALUE(x) (((x) >> S_SAP_VALUE) & M_SAP_VALUE)
-
-#define S_LENGTH_ETYPE 0
-#define M_LENGTH_ETYPE 0xffffU
-#define V_LENGTH_ETYPE(x) ((x) << S_LENGTH_ETYPE)
-#define G_LENGTH_ETYPE(x) (((x) >> S_LENGTH_ETYPE) & M_LENGTH_ETYPE)
-
-#define A_MPS_RX_CTL_ORG 0x11258
-
-#define S_CTL_VALUE 24
-#define M_CTL_VALUE 0xffU
-#define V_CTL_VALUE(x) ((x) << S_CTL_VALUE)
-#define G_CTL_VALUE(x) (((x) >> S_CTL_VALUE) & M_CTL_VALUE)
-
-#define S_ORG_VALUE 0
-#define M_ORG_VALUE 0xffffffU
-#define V_ORG_VALUE(x) ((x) << S_ORG_VALUE)
-#define G_ORG_VALUE(x) (((x) >> S_ORG_VALUE) & M_ORG_VALUE)
-
-#define A_MPS_RX_IPV4 0x1125c
-
-#define S_ETYPE_IPV4 0
-#define M_ETYPE_IPV4 0xffffU
-#define V_ETYPE_IPV4(x) ((x) << S_ETYPE_IPV4)
-#define G_ETYPE_IPV4(x) (((x) >> S_ETYPE_IPV4) & M_ETYPE_IPV4)
-
-#define A_MPS_RX_IPV6 0x11260
-
-#define S_ETYPE_IPV6 0
-#define M_ETYPE_IPV6 0xffffU
-#define V_ETYPE_IPV6(x) ((x) << S_ETYPE_IPV6)
-#define G_ETYPE_IPV6(x) (((x) >> S_ETYPE_IPV6) & M_ETYPE_IPV6)
-
-#define A_MPS_RX_TTL 0x11264
-
-#define S_TTL_IPV4 10
-#define M_TTL_IPV4 0xffU
-#define V_TTL_IPV4(x) ((x) << S_TTL_IPV4)
-#define G_TTL_IPV4(x) (((x) >> S_TTL_IPV4) & M_TTL_IPV4)
-
-#define S_TTL_IPV6 2
-#define M_TTL_IPV6 0xffU
-#define V_TTL_IPV6(x) ((x) << S_TTL_IPV6)
-#define G_TTL_IPV6(x) (((x) >> S_TTL_IPV6) & M_TTL_IPV6)
-
-#define S_TTL_CHK_EN_IPV4 1
-#define V_TTL_CHK_EN_IPV4(x) ((x) << S_TTL_CHK_EN_IPV4)
-#define F_TTL_CHK_EN_IPV4 V_TTL_CHK_EN_IPV4(1U)
-
-#define S_TTL_CHK_EN_IPV6 0
-#define V_TTL_CHK_EN_IPV6(x) ((x) << S_TTL_CHK_EN_IPV6)
-#define F_TTL_CHK_EN_IPV6 V_TTL_CHK_EN_IPV6(1U)
-
-#define A_MPS_RX_DEFAULT_VNI 0x11268
-
-#define S_VNI 0
-#define M_VNI 0xffffffU
-#define V_VNI(x) ((x) << S_VNI)
-#define G_VNI(x) (((x) >> S_VNI) & M_VNI)
-
-#define A_MPS_RX_PRS_CTL 0x1126c
-
-#define S_CTL_CHK_EN 28
-#define V_CTL_CHK_EN(x) ((x) << S_CTL_CHK_EN)
-#define F_CTL_CHK_EN V_CTL_CHK_EN(1U)
-
-#define S_ORG_CHK_EN 27
-#define V_ORG_CHK_EN(x) ((x) << S_ORG_CHK_EN)
-#define F_ORG_CHK_EN V_ORG_CHK_EN(1U)
-
-#define S_SAP_CHK_EN 26
-#define V_SAP_CHK_EN(x) ((x) << S_SAP_CHK_EN)
-#define F_SAP_CHK_EN V_SAP_CHK_EN(1U)
-
-#define S_VXLAN_FLAG_CHK_EN 25
-#define V_VXLAN_FLAG_CHK_EN(x) ((x) << S_VXLAN_FLAG_CHK_EN)
-#define F_VXLAN_FLAG_CHK_EN V_VXLAN_FLAG_CHK_EN(1U)
-
-#define S_VXLAN_FLAG_MASK 17
-#define M_VXLAN_FLAG_MASK 0xffU
-#define V_VXLAN_FLAG_MASK(x) ((x) << S_VXLAN_FLAG_MASK)
-#define G_VXLAN_FLAG_MASK(x) (((x) >> S_VXLAN_FLAG_MASK) & M_VXLAN_FLAG_MASK)
-
-#define S_VXLAN_FLAG 9
-#define M_VXLAN_FLAG 0xffU
-#define V_VXLAN_FLAG(x) ((x) << S_VXLAN_FLAG)
-#define G_VXLAN_FLAG(x) (((x) >> S_VXLAN_FLAG) & M_VXLAN_FLAG)
-
-#define S_GRE_VER_CHK_EN 8
-#define V_GRE_VER_CHK_EN(x) ((x) << S_GRE_VER_CHK_EN)
-#define F_GRE_VER_CHK_EN V_GRE_VER_CHK_EN(1U)
-
-#define S_GRE_VER 5
-#define M_GRE_VER 0x7U
-#define V_GRE_VER(x) ((x) << S_GRE_VER)
-#define G_GRE_VER(x) (((x) >> S_GRE_VER) & M_GRE_VER)
-
-#define S_GENEVE_VER_CHK_EN 4
-#define V_GENEVE_VER_CHK_EN(x) ((x) << S_GENEVE_VER_CHK_EN)
-#define F_GENEVE_VER_CHK_EN V_GENEVE_VER_CHK_EN(1U)
-
-#define S_GENEVE_VER 2
-#define M_GENEVE_VER 0x3U
-#define V_GENEVE_VER(x) ((x) << S_GENEVE_VER)
-#define G_GENEVE_VER(x) (((x) >> S_GENEVE_VER) & M_GENEVE_VER)
-
-#define S_DIP_EN 1
-#define V_DIP_EN(x) ((x) << S_DIP_EN)
-#define F_DIP_EN V_DIP_EN(1U)
-
-#define A_MPS_RX_PRS_CTL_2 0x11270
-
-#define S_EN_UDP_CSUM_CHK 4
-#define V_EN_UDP_CSUM_CHK(x) ((x) << S_EN_UDP_CSUM_CHK)
-#define F_EN_UDP_CSUM_CHK V_EN_UDP_CSUM_CHK(1U)
-
-#define S_EN_UDP_LEN_CHK 3
-#define V_EN_UDP_LEN_CHK(x) ((x) << S_EN_UDP_LEN_CHK)
-#define F_EN_UDP_LEN_CHK V_EN_UDP_LEN_CHK(1U)
-
-#define S_EN_IP_CSUM_CHK 2
-#define V_EN_IP_CSUM_CHK(x) ((x) << S_EN_IP_CSUM_CHK)
-#define F_EN_IP_CSUM_CHK V_EN_IP_CSUM_CHK(1U)
-
-#define S_EN_IP_PAYLOAD_LEN_CHK 1
-#define V_EN_IP_PAYLOAD_LEN_CHK(x) ((x) << S_EN_IP_PAYLOAD_LEN_CHK)
-#define F_EN_IP_PAYLOAD_LEN_CHK V_EN_IP_PAYLOAD_LEN_CHK(1U)
-
-#define S_T6_IPV6_UDP_CSUM_COMPAT 0
-#define V_T6_IPV6_UDP_CSUM_COMPAT(x) ((x) << S_T6_IPV6_UDP_CSUM_COMPAT)
-#define F_T6_IPV6_UDP_CSUM_COMPAT V_T6_IPV6_UDP_CSUM_COMPAT(1U)
-
-#define A_MPS_RX_MPS2NCSI_CNT 0x11274
-#define A_MPS_RX_MAX_TNL_HDR_LEN 0x11278
-
-#define S_T6_LEN 0
-#define M_T6_LEN 0x1ffU
-#define V_T6_LEN(x) ((x) << S_T6_LEN)
-#define G_T6_LEN(x) (((x) >> S_T6_LEN) & M_T6_LEN)
-
-#define A_MPS_RX_PAUSE_DA_H 0x1127c
-#define A_MPS_RX_PAUSE_DA_L 0x11280
-#define A_MPS_RX_CNT_NVGRE_PKT_MAC0 0x11284
-#define A_MPS_RX_CNT_VXLAN_PKT_MAC0 0x11288
-#define A_MPS_RX_CNT_GENEVE_PKT_MAC0 0x1128c
-#define A_MPS_RX_CNT_TNL_ERR_PKT_MAC0 0x11290
-#define A_MPS_RX_CNT_NVGRE_PKT_MAC1 0x11294
-#define A_MPS_RX_CNT_VXLAN_PKT_MAC1 0x11298
-#define A_MPS_RX_CNT_GENEVE_PKT_MAC1 0x1129c
-#define A_MPS_RX_CNT_TNL_ERR_PKT_MAC1 0x112a0
-#define A_MPS_RX_CNT_NVGRE_PKT_LPBK0 0x112a4
-#define A_MPS_RX_CNT_VXLAN_PKT_LPBK0 0x112a8
-#define A_MPS_RX_CNT_GENEVE_PKT_LPBK0 0x112ac
-#define A_MPS_RX_CNT_TNL_ERR_PKT_LPBK0 0x112b0
-#define A_MPS_RX_CNT_NVGRE_PKT_LPBK1 0x112b4
-#define A_MPS_RX_CNT_VXLAN_PKT_LPBK1 0x112b8
-#define A_MPS_RX_CNT_GENEVE_PKT_LPBK1 0x112bc
-#define A_MPS_RX_CNT_TNL_ERR_PKT_LPBK1 0x112c0
-#define A_MPS_RX_CNT_NVGRE_PKT_TO_TP0 0x112c4
-#define A_MPS_RX_CNT_VXLAN_PKT_TO_TP0 0x112c8
-#define A_MPS_RX_CNT_GENEVE_PKT_TO_TP0 0x112cc
-#define A_MPS_RX_CNT_TNL_ERR_PKT_TO_TP0 0x112d0
-#define A_MPS_RX_CNT_NVGRE_PKT_TO_TP1 0x112d4
-#define A_MPS_RX_CNT_VXLAN_PKT_TO_TP1 0x112d8
-#define A_MPS_RX_CNT_GENEVE_PKT_TO_TP1 0x112dc
-#define A_MPS_RX_CNT_TNL_ERR_PKT_TO_TP1 0x112e0
-#define A_MPS_VF_RPLCT_MAP4 0x11300
-#define A_MPS_VF_RPLCT_MAP5 0x11304
-#define A_MPS_VF_RPLCT_MAP6 0x11308
-#define A_MPS_VF_RPLCT_MAP7 0x1130c
-#define A_MPS_CLS_DIPIPV4_ID_TABLE 0x12000
-#define A_MPS_CLS_DIPIPV4_MASK_TABLE 0x12004
-#define A_MPS_CLS_DIPIPV6ID_0_TABLE 0x12020
-#define A_MPS_CLS_DIPIPV6ID_1_TABLE 0x12024
-#define A_MPS_CLS_DIPIPV6ID_2_TABLE 0x12028
-#define A_MPS_CLS_DIPIPV6ID_3_TABLE 0x1202c
-#define A_MPS_CLS_DIPIPV6MASK_0_TABLE 0x12030
-#define A_MPS_CLS_DIPIPV6MASK_1_TABLE 0x12034
-#define A_MPS_CLS_DIPIPV6MASK_2_TABLE 0x12038
-#define A_MPS_CLS_DIPIPV6MASK_3_TABLE 0x1203c
-#define A_MPS_RX_HASH_LKP_TABLE 0x12060
-
-/* registers for module CPL_SWITCH */
-#define CPL_SWITCH_BASE_ADDR 0x19040
-
-#define A_CPL_SWITCH_CNTRL 0x19040
-
-#define S_CPL_PKT_TID 8
-#define M_CPL_PKT_TID 0xffffffU
-#define V_CPL_PKT_TID(x) ((x) << S_CPL_PKT_TID)
-#define G_CPL_PKT_TID(x) (((x) >> S_CPL_PKT_TID) & M_CPL_PKT_TID)
-
-#define S_CIM_TRUNCATE_ENABLE 5
-#define V_CIM_TRUNCATE_ENABLE(x) ((x) << S_CIM_TRUNCATE_ENABLE)
-#define F_CIM_TRUNCATE_ENABLE V_CIM_TRUNCATE_ENABLE(1U)
-
-#define S_CIM_TO_UP_FULL_SIZE 4
-#define V_CIM_TO_UP_FULL_SIZE(x) ((x) << S_CIM_TO_UP_FULL_SIZE)
-#define F_CIM_TO_UP_FULL_SIZE V_CIM_TO_UP_FULL_SIZE(1U)
-
-#define S_CPU_NO_ENABLE 3
-#define V_CPU_NO_ENABLE(x) ((x) << S_CPU_NO_ENABLE)
-#define F_CPU_NO_ENABLE V_CPU_NO_ENABLE(1U)
-
-#define S_SWITCH_TABLE_ENABLE 2
-#define V_SWITCH_TABLE_ENABLE(x) ((x) << S_SWITCH_TABLE_ENABLE)
-#define F_SWITCH_TABLE_ENABLE V_SWITCH_TABLE_ENABLE(1U)
-
-#define S_SGE_ENABLE 1
-#define V_SGE_ENABLE(x) ((x) << S_SGE_ENABLE)
-#define F_SGE_ENABLE V_SGE_ENABLE(1U)
-
-#define S_CIM_ENABLE 0
-#define V_CIM_ENABLE(x) ((x) << S_CIM_ENABLE)
-#define F_CIM_ENABLE V_CIM_ENABLE(1U)
-
-#define S_CIM_SPLIT_ENABLE 6
-#define V_CIM_SPLIT_ENABLE(x) ((x) << S_CIM_SPLIT_ENABLE)
-#define F_CIM_SPLIT_ENABLE V_CIM_SPLIT_ENABLE(1U)
-
-#define A_CPL_SWITCH_TBL_IDX 0x19044
-
-#define S_SWITCH_TBL_IDX 0
-#define M_SWITCH_TBL_IDX 0xfU
-#define V_SWITCH_TBL_IDX(x) ((x) << S_SWITCH_TBL_IDX)
-#define G_SWITCH_TBL_IDX(x) (((x) >> S_SWITCH_TBL_IDX) & M_SWITCH_TBL_IDX)
-
-#define A_CPL_SWITCH_TBL_DATA 0x19048
-#define A_CPL_SWITCH_ZERO_ERROR 0x1904c
-
-#define S_ZERO_CMD_CH1 8
-#define M_ZERO_CMD_CH1 0xffU
-#define V_ZERO_CMD_CH1(x) ((x) << S_ZERO_CMD_CH1)
-#define G_ZERO_CMD_CH1(x) (((x) >> S_ZERO_CMD_CH1) & M_ZERO_CMD_CH1)
-
-#define S_ZERO_CMD_CH0 0
-#define M_ZERO_CMD_CH0 0xffU
-#define V_ZERO_CMD_CH0(x) ((x) << S_ZERO_CMD_CH0)
-#define G_ZERO_CMD_CH0(x) (((x) >> S_ZERO_CMD_CH0) & M_ZERO_CMD_CH0)
-
-#define A_CPL_INTR_ENABLE 0x19050
-
-#define S_CIM_OP_MAP_PERR 5
-#define V_CIM_OP_MAP_PERR(x) ((x) << S_CIM_OP_MAP_PERR)
-#define F_CIM_OP_MAP_PERR V_CIM_OP_MAP_PERR(1U)
-
-#define S_CIM_OVFL_ERROR 4
-#define V_CIM_OVFL_ERROR(x) ((x) << S_CIM_OVFL_ERROR)
-#define F_CIM_OVFL_ERROR V_CIM_OVFL_ERROR(1U)
-
-#define S_TP_FRAMING_ERROR 3
-#define V_TP_FRAMING_ERROR(x) ((x) << S_TP_FRAMING_ERROR)
-#define F_TP_FRAMING_ERROR V_TP_FRAMING_ERROR(1U)
-
-#define S_SGE_FRAMING_ERROR 2
-#define V_SGE_FRAMING_ERROR(x) ((x) << S_SGE_FRAMING_ERROR)
-#define F_SGE_FRAMING_ERROR V_SGE_FRAMING_ERROR(1U)
-
-#define S_CIM_FRAMING_ERROR 1
-#define V_CIM_FRAMING_ERROR(x) ((x) << S_CIM_FRAMING_ERROR)
-#define F_CIM_FRAMING_ERROR V_CIM_FRAMING_ERROR(1U)
-
-#define S_ZERO_SWITCH_ERROR 0
-#define V_ZERO_SWITCH_ERROR(x) ((x) << S_ZERO_SWITCH_ERROR)
-#define F_ZERO_SWITCH_ERROR V_ZERO_SWITCH_ERROR(1U)
-
-#define S_PERR_CPL_128TO128_1 7
-#define V_PERR_CPL_128TO128_1(x) ((x) << S_PERR_CPL_128TO128_1)
-#define F_PERR_CPL_128TO128_1 V_PERR_CPL_128TO128_1(1U)
-
-#define S_PERR_CPL_128TO128_0 6
-#define V_PERR_CPL_128TO128_0(x) ((x) << S_PERR_CPL_128TO128_0)
-#define F_PERR_CPL_128TO128_0 V_PERR_CPL_128TO128_0(1U)
-
-#define A_CPL_INTR_CAUSE 0x19054
-#define A_CPL_MAP_TBL_IDX 0x19058
-
-#define S_MAP_TBL_IDX 0
-#define M_MAP_TBL_IDX 0xffU
-#define V_MAP_TBL_IDX(x) ((x) << S_MAP_TBL_IDX)
-#define G_MAP_TBL_IDX(x) (((x) >> S_MAP_TBL_IDX) & M_MAP_TBL_IDX)
-
-#define S_CIM_SPLIT_OPCODE_PROGRAM 8
-#define V_CIM_SPLIT_OPCODE_PROGRAM(x) ((x) << S_CIM_SPLIT_OPCODE_PROGRAM)
-#define F_CIM_SPLIT_OPCODE_PROGRAM V_CIM_SPLIT_OPCODE_PROGRAM(1U)
-
-#define A_CPL_MAP_TBL_DATA 0x1905c
-
-#define S_MAP_TBL_DATA 0
-#define M_MAP_TBL_DATA 0xffU
-#define V_MAP_TBL_DATA(x) ((x) << S_MAP_TBL_DATA)
-#define G_MAP_TBL_DATA(x) (((x) >> S_MAP_TBL_DATA) & M_MAP_TBL_DATA)
-
-/* registers for module SMB */
-#define SMB_BASE_ADDR 0x19060
-
-#define A_SMB_GLOBAL_TIME_CFG 0x19060
-
-#define S_MACROCNTCFG 8
-#define M_MACROCNTCFG 0x1fU
-#define V_MACROCNTCFG(x) ((x) << S_MACROCNTCFG)
-#define G_MACROCNTCFG(x) (((x) >> S_MACROCNTCFG) & M_MACROCNTCFG)
-
-#define S_MICROCNTCFG 0
-#define M_MICROCNTCFG 0xffU
-#define V_MICROCNTCFG(x) ((x) << S_MICROCNTCFG)
-#define G_MICROCNTCFG(x) (((x) >> S_MICROCNTCFG) & M_MICROCNTCFG)
-
-#define A_SMB_MST_TIMEOUT_CFG 0x19064
-
-#define S_MSTTIMEOUTCFG 0
-#define M_MSTTIMEOUTCFG 0xffffffU
-#define V_MSTTIMEOUTCFG(x) ((x) << S_MSTTIMEOUTCFG)
-#define G_MSTTIMEOUTCFG(x) (((x) >> S_MSTTIMEOUTCFG) & M_MSTTIMEOUTCFG)
-
-#define A_SMB_MST_CTL_CFG 0x19068
-
-#define S_MSTFIFODBG 31
-#define V_MSTFIFODBG(x) ((x) << S_MSTFIFODBG)
-#define F_MSTFIFODBG V_MSTFIFODBG(1U)
-
-#define S_MSTFIFODBGCLR 30
-#define V_MSTFIFODBGCLR(x) ((x) << S_MSTFIFODBGCLR)
-#define F_MSTFIFODBGCLR V_MSTFIFODBGCLR(1U)
-
-#define S_MSTRXBYTECFG 12
-#define M_MSTRXBYTECFG 0x3fU
-#define V_MSTRXBYTECFG(x) ((x) << S_MSTRXBYTECFG)
-#define G_MSTRXBYTECFG(x) (((x) >> S_MSTRXBYTECFG) & M_MSTRXBYTECFG)
-
-#define S_MSTTXBYTECFG 6
-#define M_MSTTXBYTECFG 0x3fU
-#define V_MSTTXBYTECFG(x) ((x) << S_MSTTXBYTECFG)
-#define G_MSTTXBYTECFG(x) (((x) >> S_MSTTXBYTECFG) & M_MSTTXBYTECFG)
-
-#define S_MSTRESET 1
-#define V_MSTRESET(x) ((x) << S_MSTRESET)
-#define F_MSTRESET V_MSTRESET(1U)
-
-#define S_MSTCTLEN 0
-#define V_MSTCTLEN(x) ((x) << S_MSTCTLEN)
-#define F_MSTCTLEN V_MSTCTLEN(1U)
-
-#define A_SMB_MST_CTL_STS 0x1906c
-
-#define S_MSTRXBYTECNT 12
-#define M_MSTRXBYTECNT 0x3fU
-#define V_MSTRXBYTECNT(x) ((x) << S_MSTRXBYTECNT)
-#define G_MSTRXBYTECNT(x) (((x) >> S_MSTRXBYTECNT) & M_MSTRXBYTECNT)
-
-#define S_MSTTXBYTECNT 6
-#define M_MSTTXBYTECNT 0x3fU
-#define V_MSTTXBYTECNT(x) ((x) << S_MSTTXBYTECNT)
-#define G_MSTTXBYTECNT(x) (((x) >> S_MSTTXBYTECNT) & M_MSTTXBYTECNT)
-
-#define S_MSTBUSYSTS 0
-#define V_MSTBUSYSTS(x) ((x) << S_MSTBUSYSTS)
-#define F_MSTBUSYSTS V_MSTBUSYSTS(1U)
-
-#define A_SMB_MST_TX_FIFO_RDWR 0x19070
-#define A_SMB_MST_RX_FIFO_RDWR 0x19074
-#define A_SMB_SLV_TIMEOUT_CFG 0x19078
-
-#define S_SLVTIMEOUTCFG 0
-#define M_SLVTIMEOUTCFG 0xffffffU
-#define V_SLVTIMEOUTCFG(x) ((x) << S_SLVTIMEOUTCFG)
-#define G_SLVTIMEOUTCFG(x) (((x) >> S_SLVTIMEOUTCFG) & M_SLVTIMEOUTCFG)
-
-#define A_SMB_SLV_CTL_CFG 0x1907c
-
-#define S_SLVFIFODBG 31
-#define V_SLVFIFODBG(x) ((x) << S_SLVFIFODBG)
-#define F_SLVFIFODBG V_SLVFIFODBG(1U)
-
-#define S_SLVFIFODBGCLR 30
-#define V_SLVFIFODBGCLR(x) ((x) << S_SLVFIFODBGCLR)
-#define F_SLVFIFODBGCLR V_SLVFIFODBGCLR(1U)
-
-#define S_SLVCRCOUTBITINV 21
-#define V_SLVCRCOUTBITINV(x) ((x) << S_SLVCRCOUTBITINV)
-#define F_SLVCRCOUTBITINV V_SLVCRCOUTBITINV(1U)
-
-#define S_SLVCRCOUTBITREV 20
-#define V_SLVCRCOUTBITREV(x) ((x) << S_SLVCRCOUTBITREV)
-#define F_SLVCRCOUTBITREV V_SLVCRCOUTBITREV(1U)
-
-#define S_SLVCRCINBITREV 19
-#define V_SLVCRCINBITREV(x) ((x) << S_SLVCRCINBITREV)
-#define F_SLVCRCINBITREV V_SLVCRCINBITREV(1U)
-
-#define S_SLVCRCPRESET 11
-#define M_SLVCRCPRESET 0xffU
-#define V_SLVCRCPRESET(x) ((x) << S_SLVCRCPRESET)
-#define G_SLVCRCPRESET(x) (((x) >> S_SLVCRCPRESET) & M_SLVCRCPRESET)
-
-#define S_SLVADDRCFG 4
-#define M_SLVADDRCFG 0x7fU
-#define V_SLVADDRCFG(x) ((x) << S_SLVADDRCFG)
-#define G_SLVADDRCFG(x) (((x) >> S_SLVADDRCFG) & M_SLVADDRCFG)
-
-#define S_SLVALRTSET 2
-#define V_SLVALRTSET(x) ((x) << S_SLVALRTSET)
-#define F_SLVALRTSET V_SLVALRTSET(1U)
-
-#define S_SLVRESET 1
-#define V_SLVRESET(x) ((x) << S_SLVRESET)
-#define F_SLVRESET V_SLVRESET(1U)
-
-#define S_SLVCTLEN 0
-#define V_SLVCTLEN(x) ((x) << S_SLVCTLEN)
-#define F_SLVCTLEN V_SLVCTLEN(1U)
-
-#define A_SMB_SLV_CTL_STS 0x19080
-
-#define S_SLVFIFOTXCNT 12
-#define M_SLVFIFOTXCNT 0x3fU
-#define V_SLVFIFOTXCNT(x) ((x) << S_SLVFIFOTXCNT)
-#define G_SLVFIFOTXCNT(x) (((x) >> S_SLVFIFOTXCNT) & M_SLVFIFOTXCNT)
-
-#define S_SLVFIFOCNT 6
-#define M_SLVFIFOCNT 0x3fU
-#define V_SLVFIFOCNT(x) ((x) << S_SLVFIFOCNT)
-#define G_SLVFIFOCNT(x) (((x) >> S_SLVFIFOCNT) & M_SLVFIFOCNT)
-
-#define S_SLVALRTSTS 2
-#define V_SLVALRTSTS(x) ((x) << S_SLVALRTSTS)
-#define F_SLVALRTSTS V_SLVALRTSTS(1U)
-
-#define S_SLVBUSYSTS 0
-#define V_SLVBUSYSTS(x) ((x) << S_SLVBUSYSTS)
-#define F_SLVBUSYSTS V_SLVBUSYSTS(1U)
-
-#define A_SMB_SLV_FIFO_RDWR 0x19084
-#define A_SMB_INT_ENABLE 0x1908c
-
-#define S_MSTTXFIFOPAREN 21
-#define V_MSTTXFIFOPAREN(x) ((x) << S_MSTTXFIFOPAREN)
-#define F_MSTTXFIFOPAREN V_MSTTXFIFOPAREN(1U)
-
-#define S_MSTRXFIFOPAREN 20
-#define V_MSTRXFIFOPAREN(x) ((x) << S_MSTRXFIFOPAREN)
-#define F_MSTRXFIFOPAREN V_MSTRXFIFOPAREN(1U)
-
-#define S_SLVFIFOPAREN 19
-#define V_SLVFIFOPAREN(x) ((x) << S_SLVFIFOPAREN)
-#define F_SLVFIFOPAREN V_SLVFIFOPAREN(1U)
-
-#define S_SLVUNEXPBUSSTOPEN 18
-#define V_SLVUNEXPBUSSTOPEN(x) ((x) << S_SLVUNEXPBUSSTOPEN)
-#define F_SLVUNEXPBUSSTOPEN V_SLVUNEXPBUSSTOPEN(1U)
-
-#define S_SLVUNEXPBUSSTARTEN 17
-#define V_SLVUNEXPBUSSTARTEN(x) ((x) << S_SLVUNEXPBUSSTARTEN)
-#define F_SLVUNEXPBUSSTARTEN V_SLVUNEXPBUSSTARTEN(1U)
-
-#define S_SLVCOMMANDCODEINVEN 16
-#define V_SLVCOMMANDCODEINVEN(x) ((x) << S_SLVCOMMANDCODEINVEN)
-#define F_SLVCOMMANDCODEINVEN V_SLVCOMMANDCODEINVEN(1U)
-
-#define S_SLVBYTECNTERREN 15
-#define V_SLVBYTECNTERREN(x) ((x) << S_SLVBYTECNTERREN)
-#define F_SLVBYTECNTERREN V_SLVBYTECNTERREN(1U)
-
-#define S_SLVUNEXPACKMSTEN 14
-#define V_SLVUNEXPACKMSTEN(x) ((x) << S_SLVUNEXPACKMSTEN)
-#define F_SLVUNEXPACKMSTEN V_SLVUNEXPACKMSTEN(1U)
-
-#define S_SLVUNEXPNACKMSTEN 13
-#define V_SLVUNEXPNACKMSTEN(x) ((x) << S_SLVUNEXPNACKMSTEN)
-#define F_SLVUNEXPNACKMSTEN V_SLVUNEXPNACKMSTEN(1U)
-
-#define S_SLVNOBUSSTOPEN 12
-#define V_SLVNOBUSSTOPEN(x) ((x) << S_SLVNOBUSSTOPEN)
-#define F_SLVNOBUSSTOPEN V_SLVNOBUSSTOPEN(1U)
-
-#define S_SLVNOREPSTARTEN 11
-#define V_SLVNOREPSTARTEN(x) ((x) << S_SLVNOREPSTARTEN)
-#define F_SLVNOREPSTARTEN V_SLVNOREPSTARTEN(1U)
-
-#define S_SLVRXADDRINTEN 10
-#define V_SLVRXADDRINTEN(x) ((x) << S_SLVRXADDRINTEN)
-#define F_SLVRXADDRINTEN V_SLVRXADDRINTEN(1U)
-
-#define S_SLVRXPECERRINTEN 9
-#define V_SLVRXPECERRINTEN(x) ((x) << S_SLVRXPECERRINTEN)
-#define F_SLVRXPECERRINTEN V_SLVRXPECERRINTEN(1U)
-
-#define S_SLVPREPTOARPINTEN 8
-#define V_SLVPREPTOARPINTEN(x) ((x) << S_SLVPREPTOARPINTEN)
-#define F_SLVPREPTOARPINTEN V_SLVPREPTOARPINTEN(1U)
-
-#define S_SLVTIMEOUTINTEN 7
-#define V_SLVTIMEOUTINTEN(x) ((x) << S_SLVTIMEOUTINTEN)
-#define F_SLVTIMEOUTINTEN V_SLVTIMEOUTINTEN(1U)
-
-#define S_SLVERRINTEN 6
-#define V_SLVERRINTEN(x) ((x) << S_SLVERRINTEN)
-#define F_SLVERRINTEN V_SLVERRINTEN(1U)
-
-#define S_SLVDONEINTEN 5
-#define V_SLVDONEINTEN(x) ((x) << S_SLVDONEINTEN)
-#define F_SLVDONEINTEN V_SLVDONEINTEN(1U)
-
-#define S_SLVRXRDYINTEN 4
-#define V_SLVRXRDYINTEN(x) ((x) << S_SLVRXRDYINTEN)
-#define F_SLVRXRDYINTEN V_SLVRXRDYINTEN(1U)
-
-#define S_MSTTIMEOUTINTEN 3
-#define V_MSTTIMEOUTINTEN(x) ((x) << S_MSTTIMEOUTINTEN)
-#define F_MSTTIMEOUTINTEN V_MSTTIMEOUTINTEN(1U)
-
-#define S_MSTNACKINTEN 2
-#define V_MSTNACKINTEN(x) ((x) << S_MSTNACKINTEN)
-#define F_MSTNACKINTEN V_MSTNACKINTEN(1U)
-
-#define S_MSTLOSTARBINTEN 1
-#define V_MSTLOSTARBINTEN(x) ((x) << S_MSTLOSTARBINTEN)
-#define F_MSTLOSTARBINTEN V_MSTLOSTARBINTEN(1U)
-
-#define S_MSTDONEINTEN 0
-#define V_MSTDONEINTEN(x) ((x) << S_MSTDONEINTEN)
-#define F_MSTDONEINTEN V_MSTDONEINTEN(1U)
-
-#define A_SMB_INT_CAUSE 0x19090
-
-#define S_MSTTXFIFOPARINT 21
-#define V_MSTTXFIFOPARINT(x) ((x) << S_MSTTXFIFOPARINT)
-#define F_MSTTXFIFOPARINT V_MSTTXFIFOPARINT(1U)
-
-#define S_MSTRXFIFOPARINT 20
-#define V_MSTRXFIFOPARINT(x) ((x) << S_MSTRXFIFOPARINT)
-#define F_MSTRXFIFOPARINT V_MSTRXFIFOPARINT(1U)
-
-#define S_SLVFIFOPARINT 19
-#define V_SLVFIFOPARINT(x) ((x) << S_SLVFIFOPARINT)
-#define F_SLVFIFOPARINT V_SLVFIFOPARINT(1U)
-
-#define S_SLVUNEXPBUSSTOPINT 18
-#define V_SLVUNEXPBUSSTOPINT(x) ((x) << S_SLVUNEXPBUSSTOPINT)
-#define F_SLVUNEXPBUSSTOPINT V_SLVUNEXPBUSSTOPINT(1U)
-
-#define S_SLVUNEXPBUSSTARTINT 17
-#define V_SLVUNEXPBUSSTARTINT(x) ((x) << S_SLVUNEXPBUSSTARTINT)
-#define F_SLVUNEXPBUSSTARTINT V_SLVUNEXPBUSSTARTINT(1U)
-
-#define S_SLVCOMMANDCODEINVINT 16
-#define V_SLVCOMMANDCODEINVINT(x) ((x) << S_SLVCOMMANDCODEINVINT)
-#define F_SLVCOMMANDCODEINVINT V_SLVCOMMANDCODEINVINT(1U)
-
-#define S_SLVBYTECNTERRINT 15
-#define V_SLVBYTECNTERRINT(x) ((x) << S_SLVBYTECNTERRINT)
-#define F_SLVBYTECNTERRINT V_SLVBYTECNTERRINT(1U)
-
-#define S_SLVUNEXPACKMSTINT 14
-#define V_SLVUNEXPACKMSTINT(x) ((x) << S_SLVUNEXPACKMSTINT)
-#define F_SLVUNEXPACKMSTINT V_SLVUNEXPACKMSTINT(1U)
-
-#define S_SLVUNEXPNACKMSTINT 13
-#define V_SLVUNEXPNACKMSTINT(x) ((x) << S_SLVUNEXPNACKMSTINT)
-#define F_SLVUNEXPNACKMSTINT V_SLVUNEXPNACKMSTINT(1U)
-
-#define S_SLVNOBUSSTOPINT 12
-#define V_SLVNOBUSSTOPINT(x) ((x) << S_SLVNOBUSSTOPINT)
-#define F_SLVNOBUSSTOPINT V_SLVNOBUSSTOPINT(1U)
-
-#define S_SLVNOREPSTARTINT 11
-#define V_SLVNOREPSTARTINT(x) ((x) << S_SLVNOREPSTARTINT)
-#define F_SLVNOREPSTARTINT V_SLVNOREPSTARTINT(1U)
-
-#define S_SLVRXADDRINT 10
-#define V_SLVRXADDRINT(x) ((x) << S_SLVRXADDRINT)
-#define F_SLVRXADDRINT V_SLVRXADDRINT(1U)
-
-#define S_SLVRXPECERRINT 9
-#define V_SLVRXPECERRINT(x) ((x) << S_SLVRXPECERRINT)
-#define F_SLVRXPECERRINT V_SLVRXPECERRINT(1U)
-
-#define S_SLVPREPTOARPINT 8
-#define V_SLVPREPTOARPINT(x) ((x) << S_SLVPREPTOARPINT)
-#define F_SLVPREPTOARPINT V_SLVPREPTOARPINT(1U)
-
-#define S_SLVTIMEOUTINT 7
-#define V_SLVTIMEOUTINT(x) ((x) << S_SLVTIMEOUTINT)
-#define F_SLVTIMEOUTINT V_SLVTIMEOUTINT(1U)
-
-#define S_SLVERRINT 6
-#define V_SLVERRINT(x) ((x) << S_SLVERRINT)
-#define F_SLVERRINT V_SLVERRINT(1U)
-
-#define S_SLVDONEINT 5
-#define V_SLVDONEINT(x) ((x) << S_SLVDONEINT)
-#define F_SLVDONEINT V_SLVDONEINT(1U)
-
-#define S_SLVRXRDYINT 4
-#define V_SLVRXRDYINT(x) ((x) << S_SLVRXRDYINT)
-#define F_SLVRXRDYINT V_SLVRXRDYINT(1U)
-
-#define S_MSTTIMEOUTINT 3
-#define V_MSTTIMEOUTINT(x) ((x) << S_MSTTIMEOUTINT)
-#define F_MSTTIMEOUTINT V_MSTTIMEOUTINT(1U)
-
-#define S_MSTNACKINT 2
-#define V_MSTNACKINT(x) ((x) << S_MSTNACKINT)
-#define F_MSTNACKINT V_MSTNACKINT(1U)
-
-#define S_MSTLOSTARBINT 1
-#define V_MSTLOSTARBINT(x) ((x) << S_MSTLOSTARBINT)
-#define F_MSTLOSTARBINT V_MSTLOSTARBINT(1U)
-
-#define S_MSTDONEINT 0
-#define V_MSTDONEINT(x) ((x) << S_MSTDONEINT)
-#define F_MSTDONEINT V_MSTDONEINT(1U)
-
-#define A_SMB_DEBUG_DATA 0x19094
-
-#define S_DEBUGDATAH 16
-#define M_DEBUGDATAH 0xffffU
-#define V_DEBUGDATAH(x) ((x) << S_DEBUGDATAH)
-#define G_DEBUGDATAH(x) (((x) >> S_DEBUGDATAH) & M_DEBUGDATAH)
-
-#define S_DEBUGDATAL 0
-#define M_DEBUGDATAL 0xffffU
-#define V_DEBUGDATAL(x) ((x) << S_DEBUGDATAL)
-#define G_DEBUGDATAL(x) (((x) >> S_DEBUGDATAL) & M_DEBUGDATAL)
-
-#define A_SMB_PERR_EN 0x19098
-
-#define S_MSTTXFIFOPERREN 2
-#define V_MSTTXFIFOPERREN(x) ((x) << S_MSTTXFIFOPERREN)
-#define F_MSTTXFIFOPERREN V_MSTTXFIFOPERREN(1U)
-
-#define S_MSTRXFIFOPERREN 1
-#define V_MSTRXFIFOPERREN(x) ((x) << S_MSTRXFIFOPERREN)
-#define F_MSTRXFIFOPERREN V_MSTRXFIFOPERREN(1U)
-
-#define S_SLVFIFOPERREN 0
-#define V_SLVFIFOPERREN(x) ((x) << S_SLVFIFOPERREN)
-#define F_SLVFIFOPERREN V_SLVFIFOPERREN(1U)
-
-#define S_MSTTXFIFO 21
-#define V_MSTTXFIFO(x) ((x) << S_MSTTXFIFO)
-#define F_MSTTXFIFO V_MSTTXFIFO(1U)
-
-#define S_MSTRXFIFO 19
-#define V_MSTRXFIFO(x) ((x) << S_MSTRXFIFO)
-#define F_MSTRXFIFO V_MSTRXFIFO(1U)
-
-#define S_SLVFIFO 18
-#define V_SLVFIFO(x) ((x) << S_SLVFIFO)
-#define F_SLVFIFO V_SLVFIFO(1U)
-
-#define A_SMB_PERR_INJ 0x1909c
-
-#define S_MSTTXINJDATAERR 3
-#define V_MSTTXINJDATAERR(x) ((x) << S_MSTTXINJDATAERR)
-#define F_MSTTXINJDATAERR V_MSTTXINJDATAERR(1U)
-
-#define S_MSTRXINJDATAERR 2
-#define V_MSTRXINJDATAERR(x) ((x) << S_MSTRXINJDATAERR)
-#define F_MSTRXINJDATAERR V_MSTRXINJDATAERR(1U)
-
-#define S_SLVINJDATAERR 1
-#define V_SLVINJDATAERR(x) ((x) << S_SLVINJDATAERR)
-#define F_SLVINJDATAERR V_SLVINJDATAERR(1U)
-
-#define S_FIFOINJDATAERREN 0
-#define V_FIFOINJDATAERREN(x) ((x) << S_FIFOINJDATAERREN)
-#define F_FIFOINJDATAERREN V_FIFOINJDATAERREN(1U)
-
-#define A_SMB_SLV_ARP_CTL 0x190a0
-
-#define S_ARPCOMMANDCODE 2
-#define M_ARPCOMMANDCODE 0xffU
-#define V_ARPCOMMANDCODE(x) ((x) << S_ARPCOMMANDCODE)
-#define G_ARPCOMMANDCODE(x) (((x) >> S_ARPCOMMANDCODE) & M_ARPCOMMANDCODE)
-
-#define S_ARPADDRRES 1
-#define V_ARPADDRRES(x) ((x) << S_ARPADDRRES)
-#define F_ARPADDRRES V_ARPADDRRES(1U)
-
-#define S_ARPADDRVAL 0
-#define V_ARPADDRVAL(x) ((x) << S_ARPADDRVAL)
-#define F_ARPADDRVAL V_ARPADDRVAL(1U)
-
-#define A_SMB_ARP_UDID0 0x190a4
-#define A_SMB_ARP_UDID1 0x190a8
-
-#define S_SUBSYSTEMVENDORID 16
-#define M_SUBSYSTEMVENDORID 0xffffU
-#define V_SUBSYSTEMVENDORID(x) ((x) << S_SUBSYSTEMVENDORID)
-#define G_SUBSYSTEMVENDORID(x) (((x) >> S_SUBSYSTEMVENDORID) & M_SUBSYSTEMVENDORID)
-
-#define S_SUBSYSTEMDEVICEID 0
-#define M_SUBSYSTEMDEVICEID 0xffffU
-#define V_SUBSYSTEMDEVICEID(x) ((x) << S_SUBSYSTEMDEVICEID)
-#define G_SUBSYSTEMDEVICEID(x) (((x) >> S_SUBSYSTEMDEVICEID) & M_SUBSYSTEMDEVICEID)
-
-#define A_SMB_ARP_UDID2 0x190ac
-
-#define S_DEVICEID 16
-#define M_DEVICEID 0xffffU
-#define V_DEVICEID(x) ((x) << S_DEVICEID)
-#define G_DEVICEID(x) (((x) >> S_DEVICEID) & M_DEVICEID)
-
-#define S_INTERFACE 0
-#define M_INTERFACE 0xffffU
-#define V_INTERFACE(x) ((x) << S_INTERFACE)
-#define G_INTERFACE(x) (((x) >> S_INTERFACE) & M_INTERFACE)
-
-#define A_SMB_ARP_UDID3 0x190b0
-
-#define S_DEVICECAP 24
-#define M_DEVICECAP 0xffU
-#define V_DEVICECAP(x) ((x) << S_DEVICECAP)
-#define G_DEVICECAP(x) (((x) >> S_DEVICECAP) & M_DEVICECAP)
-
-#define S_VERSIONID 16
-#define M_VERSIONID 0xffU
-#define V_VERSIONID(x) ((x) << S_VERSIONID)
-#define G_VERSIONID(x) (((x) >> S_VERSIONID) & M_VERSIONID)
-
-#define S_VENDORID 0
-#define M_VENDORID 0xffffU
-#define V_VENDORID(x) ((x) << S_VENDORID)
-#define G_VENDORID(x) (((x) >> S_VENDORID) & M_VENDORID)
-
-#define A_SMB_SLV_AUX_ADDR0 0x190b4
-
-#define S_AUXADDR0VAL 6
-#define V_AUXADDR0VAL(x) ((x) << S_AUXADDR0VAL)
-#define F_AUXADDR0VAL V_AUXADDR0VAL(1U)
-
-#define S_AUXADDR0 0
-#define M_AUXADDR0 0x3fU
-#define V_AUXADDR0(x) ((x) << S_AUXADDR0)
-#define G_AUXADDR0(x) (((x) >> S_AUXADDR0) & M_AUXADDR0)
-
-#define A_SMB_SLV_AUX_ADDR1 0x190b8
-
-#define S_AUXADDR1VAL 6
-#define V_AUXADDR1VAL(x) ((x) << S_AUXADDR1VAL)
-#define F_AUXADDR1VAL V_AUXADDR1VAL(1U)
-
-#define S_AUXADDR1 0
-#define M_AUXADDR1 0x3fU
-#define V_AUXADDR1(x) ((x) << S_AUXADDR1)
-#define G_AUXADDR1(x) (((x) >> S_AUXADDR1) & M_AUXADDR1)
-
-#define A_SMB_SLV_AUX_ADDR2 0x190bc
-
-#define S_AUXADDR2VAL 6
-#define V_AUXADDR2VAL(x) ((x) << S_AUXADDR2VAL)
-#define F_AUXADDR2VAL V_AUXADDR2VAL(1U)
-
-#define S_AUXADDR2 0
-#define M_AUXADDR2 0x3fU
-#define V_AUXADDR2(x) ((x) << S_AUXADDR2)
-#define G_AUXADDR2(x) (((x) >> S_AUXADDR2) & M_AUXADDR2)
-
-#define A_SMB_SLV_AUX_ADDR3 0x190c0
-
-#define S_AUXADDR3VAL 6
-#define V_AUXADDR3VAL(x) ((x) << S_AUXADDR3VAL)
-#define F_AUXADDR3VAL V_AUXADDR3VAL(1U)
-
-#define S_AUXADDR3 0
-#define M_AUXADDR3 0x3fU
-#define V_AUXADDR3(x) ((x) << S_AUXADDR3)
-#define G_AUXADDR3(x) (((x) >> S_AUXADDR3) & M_AUXADDR3)
-
-#define A_SMB_COMMAND_CODE0 0x190c4
-
-#define S_SMBUSCOMMANDCODE0 0
-#define M_SMBUSCOMMANDCODE0 0xffU
-#define V_SMBUSCOMMANDCODE0(x) ((x) << S_SMBUSCOMMANDCODE0)
-#define G_SMBUSCOMMANDCODE0(x) (((x) >> S_SMBUSCOMMANDCODE0) & M_SMBUSCOMMANDCODE0)
-
-#define A_SMB_COMMAND_CODE1 0x190c8
-
-#define S_SMBUSCOMMANDCODE1 0
-#define M_SMBUSCOMMANDCODE1 0xffU
-#define V_SMBUSCOMMANDCODE1(x) ((x) << S_SMBUSCOMMANDCODE1)
-#define G_SMBUSCOMMANDCODE1(x) (((x) >> S_SMBUSCOMMANDCODE1) & M_SMBUSCOMMANDCODE1)
-
-#define A_SMB_COMMAND_CODE2 0x190cc
-
-#define S_SMBUSCOMMANDCODE2 0
-#define M_SMBUSCOMMANDCODE2 0xffU
-#define V_SMBUSCOMMANDCODE2(x) ((x) << S_SMBUSCOMMANDCODE2)
-#define G_SMBUSCOMMANDCODE2(x) (((x) >> S_SMBUSCOMMANDCODE2) & M_SMBUSCOMMANDCODE2)
-
-#define A_SMB_COMMAND_CODE3 0x190d0
-
-#define S_SMBUSCOMMANDCODE3 0
-#define M_SMBUSCOMMANDCODE3 0xffU
-#define V_SMBUSCOMMANDCODE3(x) ((x) << S_SMBUSCOMMANDCODE3)
-#define G_SMBUSCOMMANDCODE3(x) (((x) >> S_SMBUSCOMMANDCODE3) & M_SMBUSCOMMANDCODE3)
-
-#define A_SMB_COMMAND_CODE4 0x190d4
-
-#define S_SMBUSCOMMANDCODE4 0
-#define M_SMBUSCOMMANDCODE4 0xffU
-#define V_SMBUSCOMMANDCODE4(x) ((x) << S_SMBUSCOMMANDCODE4)
-#define G_SMBUSCOMMANDCODE4(x) (((x) >> S_SMBUSCOMMANDCODE4) & M_SMBUSCOMMANDCODE4)
-
-#define A_SMB_COMMAND_CODE5 0x190d8
-
-#define S_SMBUSCOMMANDCODE5 0
-#define M_SMBUSCOMMANDCODE5 0xffU
-#define V_SMBUSCOMMANDCODE5(x) ((x) << S_SMBUSCOMMANDCODE5)
-#define G_SMBUSCOMMANDCODE5(x) (((x) >> S_SMBUSCOMMANDCODE5) & M_SMBUSCOMMANDCODE5)
-
-#define A_SMB_COMMAND_CODE6 0x190dc
-
-#define S_SMBUSCOMMANDCODE6 0
-#define M_SMBUSCOMMANDCODE6 0xffU
-#define V_SMBUSCOMMANDCODE6(x) ((x) << S_SMBUSCOMMANDCODE6)
-#define G_SMBUSCOMMANDCODE6(x) (((x) >> S_SMBUSCOMMANDCODE6) & M_SMBUSCOMMANDCODE6)
-
-#define A_SMB_COMMAND_CODE7 0x190e0
-
-#define S_SMBUSCOMMANDCODE7 0
-#define M_SMBUSCOMMANDCODE7 0xffU
-#define V_SMBUSCOMMANDCODE7(x) ((x) << S_SMBUSCOMMANDCODE7)
-#define G_SMBUSCOMMANDCODE7(x) (((x) >> S_SMBUSCOMMANDCODE7) & M_SMBUSCOMMANDCODE7)
-
-#define A_SMB_MICRO_CNT_CLK_CFG 0x190e4
-
-#define S_MACROCNTCLKCFG 8
-#define M_MACROCNTCLKCFG 0x1fU
-#define V_MACROCNTCLKCFG(x) ((x) << S_MACROCNTCLKCFG)
-#define G_MACROCNTCLKCFG(x) (((x) >> S_MACROCNTCLKCFG) & M_MACROCNTCLKCFG)
-
-#define S_MICROCNTCLKCFG 0
-#define M_MICROCNTCLKCFG 0xffU
-#define V_MICROCNTCLKCFG(x) ((x) << S_MICROCNTCLKCFG)
-#define G_MICROCNTCLKCFG(x) (((x) >> S_MICROCNTCLKCFG) & M_MICROCNTCLKCFG)
-
-#define A_SMB_CTL_STATUS 0x190e8
-
-#define S_MSTBUSBUSY 2
-#define V_MSTBUSBUSY(x) ((x) << S_MSTBUSBUSY)
-#define F_MSTBUSBUSY V_MSTBUSBUSY(1U)
-
-#define S_SLVBUSBUSY 1
-#define V_SLVBUSBUSY(x) ((x) << S_SLVBUSBUSY)
-#define F_SLVBUSBUSY V_SLVBUSBUSY(1U)
-
-#define S_BUSBUSY 0
-#define V_BUSBUSY(x) ((x) << S_BUSBUSY)
-#define F_BUSBUSY V_BUSBUSY(1U)
-
-/* registers for module I2CM */
-#define I2CM_BASE_ADDR 0x190f0
-
-#define A_I2CM_CFG 0x190f0
-
-#define S_I2C_CLKDIV 0
-#define M_I2C_CLKDIV 0xfffU
-#define V_I2C_CLKDIV(x) ((x) << S_I2C_CLKDIV)
-#define G_I2C_CLKDIV(x) (((x) >> S_I2C_CLKDIV) & M_I2C_CLKDIV)
-
-#define S_I2C_CLKDIV16B 0
-#define M_I2C_CLKDIV16B 0xffffU
-#define V_I2C_CLKDIV16B(x) ((x) << S_I2C_CLKDIV16B)
-#define G_I2C_CLKDIV16B(x) (((x) >> S_I2C_CLKDIV16B) & M_I2C_CLKDIV16B)
-
-#define A_I2CM_DATA 0x190f4
-
-#define S_I2C_DATA 0
-#define M_I2C_DATA 0xffU
-#define V_I2C_DATA(x) ((x) << S_I2C_DATA)
-#define G_I2C_DATA(x) (((x) >> S_I2C_DATA) & M_I2C_DATA)
-
-#define A_I2CM_OP 0x190f8
-
-#define S_I2C_ACK 30
-#define V_I2C_ACK(x) ((x) << S_I2C_ACK)
-#define F_I2C_ACK V_I2C_ACK(1U)
-
-#define S_I2C_CONT 1
-#define V_I2C_CONT(x) ((x) << S_I2C_CONT)
-#define F_I2C_CONT V_I2C_CONT(1U)
-
-#define S_OP 0
-#define V_OP(x) ((x) << S_OP)
-#define F_OP V_OP(1U)
-
-/* registers for module MI */
-#define MI_BASE_ADDR 0x19100
-
-#define A_MI_CFG 0x19100
-
-#define S_T4_ST 14
-#define V_T4_ST(x) ((x) << S_T4_ST)
-#define F_T4_ST V_T4_ST(1U)
-
-#define S_CLKDIV 5
-#define M_CLKDIV 0xffU
-#define V_CLKDIV(x) ((x) << S_CLKDIV)
-#define G_CLKDIV(x) (((x) >> S_CLKDIV) & M_CLKDIV)
-
-#define S_ST 3
-#define M_ST 0x3U
-#define V_ST(x) ((x) << S_ST)
-#define G_ST(x) (((x) >> S_ST) & M_ST)
-
-#define S_PREEN 2
-#define V_PREEN(x) ((x) << S_PREEN)
-#define F_PREEN V_PREEN(1U)
-
-#define S_MDIINV 1
-#define V_MDIINV(x) ((x) << S_MDIINV)
-#define F_MDIINV V_MDIINV(1U)
-
-#define S_MDIO_1P2V_SEL 0
-#define V_MDIO_1P2V_SEL(x) ((x) << S_MDIO_1P2V_SEL)
-#define F_MDIO_1P2V_SEL V_MDIO_1P2V_SEL(1U)
-
-#define A_MI_ADDR 0x19104
-
-#define S_PHYADDR 5
-#define M_PHYADDR 0x1fU
-#define V_PHYADDR(x) ((x) << S_PHYADDR)
-#define G_PHYADDR(x) (((x) >> S_PHYADDR) & M_PHYADDR)
-
-#define S_REGADDR 0
-#define M_REGADDR 0x1fU
-#define V_REGADDR(x) ((x) << S_REGADDR)
-#define G_REGADDR(x) (((x) >> S_REGADDR) & M_REGADDR)
-
-#define A_MI_DATA 0x19108
-
-#define S_MDIDATA 0
-#define M_MDIDATA 0xffffU
-#define V_MDIDATA(x) ((x) << S_MDIDATA)
-#define G_MDIDATA(x) (((x) >> S_MDIDATA) & M_MDIDATA)
-
-#define A_MI_OP 0x1910c
-
-#define S_INC 2
-#define V_INC(x) ((x) << S_INC)
-#define F_INC V_INC(1U)
-
-#define S_MDIOP 0
-#define M_MDIOP 0x3U
-#define V_MDIOP(x) ((x) << S_MDIOP)
-#define G_MDIOP(x) (((x) >> S_MDIOP) & M_MDIOP)
-
-/* registers for module UART */
-#define UART_BASE_ADDR 0x19110
-
-#define A_UART_CONFIG 0x19110
-
-#define S_STOPBITS 22
-#define M_STOPBITS 0x3U
-#define V_STOPBITS(x) ((x) << S_STOPBITS)
-#define G_STOPBITS(x) (((x) >> S_STOPBITS) & M_STOPBITS)
-
-#define S_PARITY 20
-#define M_PARITY 0x3U
-#define V_PARITY(x) ((x) << S_PARITY)
-#define G_PARITY(x) (((x) >> S_PARITY) & M_PARITY)
-
-#define S_DATABITS 16
-#define M_DATABITS 0xfU
-#define V_DATABITS(x) ((x) << S_DATABITS)
-#define G_DATABITS(x) (((x) >> S_DATABITS) & M_DATABITS)
-
-#define S_UART_CLKDIV 0
-#define M_UART_CLKDIV 0xfffU
-#define V_UART_CLKDIV(x) ((x) << S_UART_CLKDIV)
-#define G_UART_CLKDIV(x) (((x) >> S_UART_CLKDIV) & M_UART_CLKDIV)
-
-/* registers for module PMU */
-#define PMU_BASE_ADDR 0x19120
-
-#define A_PMU_PART_CG_PWRMODE 0x19120
-
-#define S_TPPARTCGEN 14
-#define V_TPPARTCGEN(x) ((x) << S_TPPARTCGEN)
-#define F_TPPARTCGEN V_TPPARTCGEN(1U)
-
-#define S_PDPPARTCGEN 13
-#define V_PDPPARTCGEN(x) ((x) << S_PDPPARTCGEN)
-#define F_PDPPARTCGEN V_PDPPARTCGEN(1U)
-
-#define S_PCIEPARTCGEN 12
-#define V_PCIEPARTCGEN(x) ((x) << S_PCIEPARTCGEN)
-#define F_PCIEPARTCGEN V_PCIEPARTCGEN(1U)
-
-#define S_EDC1PARTCGEN 11
-#define V_EDC1PARTCGEN(x) ((x) << S_EDC1PARTCGEN)
-#define F_EDC1PARTCGEN V_EDC1PARTCGEN(1U)
-
-#define S_MCPARTCGEN 10
-#define V_MCPARTCGEN(x) ((x) << S_MCPARTCGEN)
-#define F_MCPARTCGEN V_MCPARTCGEN(1U)
-
-#define S_EDC0PARTCGEN 9
-#define V_EDC0PARTCGEN(x) ((x) << S_EDC0PARTCGEN)
-#define F_EDC0PARTCGEN V_EDC0PARTCGEN(1U)
-
-#define S_LEPARTCGEN 8
-#define V_LEPARTCGEN(x) ((x) << S_LEPARTCGEN)
-#define F_LEPARTCGEN V_LEPARTCGEN(1U)
-
-#define S_INITPOWERMODE 0
-#define M_INITPOWERMODE 0x3U
-#define V_INITPOWERMODE(x) ((x) << S_INITPOWERMODE)
-#define G_INITPOWERMODE(x) (((x) >> S_INITPOWERMODE) & M_INITPOWERMODE)
-
-#define S_SGE_PART_CGEN 19
-#define V_SGE_PART_CGEN(x) ((x) << S_SGE_PART_CGEN)
-#define F_SGE_PART_CGEN V_SGE_PART_CGEN(1U)
-
-#define S_PDP_PART_CGEN 18
-#define V_PDP_PART_CGEN(x) ((x) << S_PDP_PART_CGEN)
-#define F_PDP_PART_CGEN V_PDP_PART_CGEN(1U)
-
-#define S_TP_PART_CGEN 17
-#define V_TP_PART_CGEN(x) ((x) << S_TP_PART_CGEN)
-#define F_TP_PART_CGEN V_TP_PART_CGEN(1U)
-
-#define S_EDC0_PART_CGEN 16
-#define V_EDC0_PART_CGEN(x) ((x) << S_EDC0_PART_CGEN)
-#define F_EDC0_PART_CGEN V_EDC0_PART_CGEN(1U)
-
-#define S_EDC1_PART_CGEN 15
-#define V_EDC1_PART_CGEN(x) ((x) << S_EDC1_PART_CGEN)
-#define F_EDC1_PART_CGEN V_EDC1_PART_CGEN(1U)
-
-#define S_LE_PART_CGEN 14
-#define V_LE_PART_CGEN(x) ((x) << S_LE_PART_CGEN)
-#define F_LE_PART_CGEN V_LE_PART_CGEN(1U)
-
-#define S_MA_PART_CGEN 13
-#define V_MA_PART_CGEN(x) ((x) << S_MA_PART_CGEN)
-#define F_MA_PART_CGEN V_MA_PART_CGEN(1U)
-
-#define S_MC0_PART_CGEN 12
-#define V_MC0_PART_CGEN(x) ((x) << S_MC0_PART_CGEN)
-#define F_MC0_PART_CGEN V_MC0_PART_CGEN(1U)
-
-#define S_MC1_PART_CGEN 11
-#define V_MC1_PART_CGEN(x) ((x) << S_MC1_PART_CGEN)
-#define F_MC1_PART_CGEN V_MC1_PART_CGEN(1U)
-
-#define S_PCIE_PART_CGEN 10
-#define V_PCIE_PART_CGEN(x) ((x) << S_PCIE_PART_CGEN)
-#define F_PCIE_PART_CGEN V_PCIE_PART_CGEN(1U)
-
-#define S_PL_DIS_PRTY_CHK 20
-#define V_PL_DIS_PRTY_CHK(x) ((x) << S_PL_DIS_PRTY_CHK)
-#define F_PL_DIS_PRTY_CHK V_PL_DIS_PRTY_CHK(1U)
-
-#define A_PMU_SLEEPMODE_WAKEUP 0x19124
-
-#define S_HWWAKEUPEN 5
-#define V_HWWAKEUPEN(x) ((x) << S_HWWAKEUPEN)
-#define F_HWWAKEUPEN V_HWWAKEUPEN(1U)
-
-#define S_PORT3SLEEPMODE 4
-#define V_PORT3SLEEPMODE(x) ((x) << S_PORT3SLEEPMODE)
-#define F_PORT3SLEEPMODE V_PORT3SLEEPMODE(1U)
-
-#define S_PORT2SLEEPMODE 3
-#define V_PORT2SLEEPMODE(x) ((x) << S_PORT2SLEEPMODE)
-#define F_PORT2SLEEPMODE V_PORT2SLEEPMODE(1U)
-
-#define S_PORT1SLEEPMODE 2
-#define V_PORT1SLEEPMODE(x) ((x) << S_PORT1SLEEPMODE)
-#define F_PORT1SLEEPMODE V_PORT1SLEEPMODE(1U)
-
-#define S_PORT0SLEEPMODE 1
-#define V_PORT0SLEEPMODE(x) ((x) << S_PORT0SLEEPMODE)
-#define F_PORT0SLEEPMODE V_PORT0SLEEPMODE(1U)
-
-#define S_WAKEUP 0
-#define V_WAKEUP(x) ((x) << S_WAKEUP)
-#define F_WAKEUP V_WAKEUP(1U)
-
-#define S_GLOBALDEEPSLEEPEN 6
-#define V_GLOBALDEEPSLEEPEN(x) ((x) << S_GLOBALDEEPSLEEPEN)
-#define F_GLOBALDEEPSLEEPEN V_GLOBALDEEPSLEEPEN(1U)
-
-/* registers for module ULP_RX */
-#define ULP_RX_BASE_ADDR 0x19150
-
-#define A_ULP_RX_CTL 0x19150
-
-#define S_PCMD1THRESHOLD 24
-#define M_PCMD1THRESHOLD 0xffU
-#define V_PCMD1THRESHOLD(x) ((x) << S_PCMD1THRESHOLD)
-#define G_PCMD1THRESHOLD(x) (((x) >> S_PCMD1THRESHOLD) & M_PCMD1THRESHOLD)
-
-#define S_PCMD0THRESHOLD 16
-#define M_PCMD0THRESHOLD 0xffU
-#define V_PCMD0THRESHOLD(x) ((x) << S_PCMD0THRESHOLD)
-#define G_PCMD0THRESHOLD(x) (((x) >> S_PCMD0THRESHOLD) & M_PCMD0THRESHOLD)
-
-#define S_DISABLE_0B_STAG_ERR 14
-#define V_DISABLE_0B_STAG_ERR(x) ((x) << S_DISABLE_0B_STAG_ERR)
-#define F_DISABLE_0B_STAG_ERR V_DISABLE_0B_STAG_ERR(1U)
-
-#define S_RDMA_0B_WR_OPCODE 10
-#define M_RDMA_0B_WR_OPCODE 0xfU
-#define V_RDMA_0B_WR_OPCODE(x) ((x) << S_RDMA_0B_WR_OPCODE)
-#define G_RDMA_0B_WR_OPCODE(x) (((x) >> S_RDMA_0B_WR_OPCODE) & M_RDMA_0B_WR_OPCODE)
-
-#define S_RDMA_0B_WR_PASS 9
-#define V_RDMA_0B_WR_PASS(x) ((x) << S_RDMA_0B_WR_PASS)
-#define F_RDMA_0B_WR_PASS V_RDMA_0B_WR_PASS(1U)
-
-#define S_STAG_RQE 8
-#define V_STAG_RQE(x) ((x) << S_STAG_RQE)
-#define F_STAG_RQE V_STAG_RQE(1U)
-
-#define S_RDMA_STATE_EN 7
-#define V_RDMA_STATE_EN(x) ((x) << S_RDMA_STATE_EN)
-#define F_RDMA_STATE_EN V_RDMA_STATE_EN(1U)
-
-#define S_CRC1_EN 6
-#define V_CRC1_EN(x) ((x) << S_CRC1_EN)
-#define F_CRC1_EN V_CRC1_EN(1U)
-
-#define S_RDMA_0B_WR_CQE 5
-#define V_RDMA_0B_WR_CQE(x) ((x) << S_RDMA_0B_WR_CQE)
-#define F_RDMA_0B_WR_CQE V_RDMA_0B_WR_CQE(1U)
-
-#define S_PCIE_ATRB_EN 4
-#define V_PCIE_ATRB_EN(x) ((x) << S_PCIE_ATRB_EN)
-#define F_PCIE_ATRB_EN V_PCIE_ATRB_EN(1U)
-
-#define S_RDMA_PERMISSIVE_MODE 3
-#define V_RDMA_PERMISSIVE_MODE(x) ((x) << S_RDMA_PERMISSIVE_MODE)
-#define F_RDMA_PERMISSIVE_MODE V_RDMA_PERMISSIVE_MODE(1U)
-
-#define S_PAGEPODME 2
-#define V_PAGEPODME(x) ((x) << S_PAGEPODME)
-#define F_PAGEPODME V_PAGEPODME(1U)
-
-#define S_ISCSITAGTCB 1
-#define V_ISCSITAGTCB(x) ((x) << S_ISCSITAGTCB)
-#define F_ISCSITAGTCB V_ISCSITAGTCB(1U)
-
-#define S_TDDPTAGTCB 0
-#define V_TDDPTAGTCB(x) ((x) << S_TDDPTAGTCB)
-#define F_TDDPTAGTCB V_TDDPTAGTCB(1U)
-
-#define A_ULP_RX_INT_ENABLE 0x19154
-
-#define S_ENABLE_CTX_1 24
-#define V_ENABLE_CTX_1(x) ((x) << S_ENABLE_CTX_1)
-#define F_ENABLE_CTX_1 V_ENABLE_CTX_1(1U)
-
-#define S_ENABLE_CTX_0 23
-#define V_ENABLE_CTX_0(x) ((x) << S_ENABLE_CTX_0)
-#define F_ENABLE_CTX_0 V_ENABLE_CTX_0(1U)
-
-#define S_ENABLE_FF 22
-#define V_ENABLE_FF(x) ((x) << S_ENABLE_FF)
-#define F_ENABLE_FF V_ENABLE_FF(1U)
-
-#define S_ENABLE_APF_1 21
-#define V_ENABLE_APF_1(x) ((x) << S_ENABLE_APF_1)
-#define F_ENABLE_APF_1 V_ENABLE_APF_1(1U)
-
-#define S_ENABLE_APF_0 20
-#define V_ENABLE_APF_0(x) ((x) << S_ENABLE_APF_0)
-#define F_ENABLE_APF_0 V_ENABLE_APF_0(1U)
-
-#define S_ENABLE_AF_1 19
-#define V_ENABLE_AF_1(x) ((x) << S_ENABLE_AF_1)
-#define F_ENABLE_AF_1 V_ENABLE_AF_1(1U)
-
-#define S_ENABLE_AF_0 18
-#define V_ENABLE_AF_0(x) ((x) << S_ENABLE_AF_0)
-#define F_ENABLE_AF_0 V_ENABLE_AF_0(1U)
-
-#define S_ENABLE_DDPDF_1 17
-#define V_ENABLE_DDPDF_1(x) ((x) << S_ENABLE_DDPDF_1)
-#define F_ENABLE_DDPDF_1 V_ENABLE_DDPDF_1(1U)
-
-#define S_ENABLE_DDPMF_1 16
-#define V_ENABLE_DDPMF_1(x) ((x) << S_ENABLE_DDPMF_1)
-#define F_ENABLE_DDPMF_1 V_ENABLE_DDPMF_1(1U)
-
-#define S_ENABLE_MEMRF_1 15
-#define V_ENABLE_MEMRF_1(x) ((x) << S_ENABLE_MEMRF_1)
-#define F_ENABLE_MEMRF_1 V_ENABLE_MEMRF_1(1U)
-
-#define S_ENABLE_PRSDF_1 14
-#define V_ENABLE_PRSDF_1(x) ((x) << S_ENABLE_PRSDF_1)
-#define F_ENABLE_PRSDF_1 V_ENABLE_PRSDF_1(1U)
-
-#define S_ENABLE_DDPDF_0 13
-#define V_ENABLE_DDPDF_0(x) ((x) << S_ENABLE_DDPDF_0)
-#define F_ENABLE_DDPDF_0 V_ENABLE_DDPDF_0(1U)
-
-#define S_ENABLE_DDPMF_0 12
-#define V_ENABLE_DDPMF_0(x) ((x) << S_ENABLE_DDPMF_0)
-#define F_ENABLE_DDPMF_0 V_ENABLE_DDPMF_0(1U)
-
-#define S_ENABLE_MEMRF_0 11
-#define V_ENABLE_MEMRF_0(x) ((x) << S_ENABLE_MEMRF_0)
-#define F_ENABLE_MEMRF_0 V_ENABLE_MEMRF_0(1U)
-
-#define S_ENABLE_PRSDF_0 10
-#define V_ENABLE_PRSDF_0(x) ((x) << S_ENABLE_PRSDF_0)
-#define F_ENABLE_PRSDF_0 V_ENABLE_PRSDF_0(1U)
-
-#define S_ENABLE_PCMDF_1 9
-#define V_ENABLE_PCMDF_1(x) ((x) << S_ENABLE_PCMDF_1)
-#define F_ENABLE_PCMDF_1 V_ENABLE_PCMDF_1(1U)
-
-#define S_ENABLE_TPTCF_1 8
-#define V_ENABLE_TPTCF_1(x) ((x) << S_ENABLE_TPTCF_1)
-#define F_ENABLE_TPTCF_1 V_ENABLE_TPTCF_1(1U)
-
-#define S_ENABLE_DDPCF_1 7
-#define V_ENABLE_DDPCF_1(x) ((x) << S_ENABLE_DDPCF_1)
-#define F_ENABLE_DDPCF_1 V_ENABLE_DDPCF_1(1U)
-
-#define S_ENABLE_MPARF_1 6
-#define V_ENABLE_MPARF_1(x) ((x) << S_ENABLE_MPARF_1)
-#define F_ENABLE_MPARF_1 V_ENABLE_MPARF_1(1U)
-
-#define S_ENABLE_MPARC_1 5
-#define V_ENABLE_MPARC_1(x) ((x) << S_ENABLE_MPARC_1)
-#define F_ENABLE_MPARC_1 V_ENABLE_MPARC_1(1U)
-
-#define S_ENABLE_PCMDF_0 4
-#define V_ENABLE_PCMDF_0(x) ((x) << S_ENABLE_PCMDF_0)
-#define F_ENABLE_PCMDF_0 V_ENABLE_PCMDF_0(1U)
-
-#define S_ENABLE_TPTCF_0 3
-#define V_ENABLE_TPTCF_0(x) ((x) << S_ENABLE_TPTCF_0)
-#define F_ENABLE_TPTCF_0 V_ENABLE_TPTCF_0(1U)
-
-#define S_ENABLE_DDPCF_0 2
-#define V_ENABLE_DDPCF_0(x) ((x) << S_ENABLE_DDPCF_0)
-#define F_ENABLE_DDPCF_0 V_ENABLE_DDPCF_0(1U)
-
-#define S_ENABLE_MPARF_0 1
-#define V_ENABLE_MPARF_0(x) ((x) << S_ENABLE_MPARF_0)
-#define F_ENABLE_MPARF_0 V_ENABLE_MPARF_0(1U)
-
-#define S_ENABLE_MPARC_0 0
-#define V_ENABLE_MPARC_0(x) ((x) << S_ENABLE_MPARC_0)
-#define F_ENABLE_MPARC_0 V_ENABLE_MPARC_0(1U)
-
-#define S_SE_CNT_MISMATCH_1 26
-#define V_SE_CNT_MISMATCH_1(x) ((x) << S_SE_CNT_MISMATCH_1)
-#define F_SE_CNT_MISMATCH_1 V_SE_CNT_MISMATCH_1(1U)
-
-#define S_SE_CNT_MISMATCH_0 25
-#define V_SE_CNT_MISMATCH_0(x) ((x) << S_SE_CNT_MISMATCH_0)
-#define F_SE_CNT_MISMATCH_0 V_SE_CNT_MISMATCH_0(1U)
-
-#define A_ULP_RX_INT_CAUSE 0x19158
-
-#define S_CAUSE_CTX_1 24
-#define V_CAUSE_CTX_1(x) ((x) << S_CAUSE_CTX_1)
-#define F_CAUSE_CTX_1 V_CAUSE_CTX_1(1U)
-
-#define S_CAUSE_CTX_0 23
-#define V_CAUSE_CTX_0(x) ((x) << S_CAUSE_CTX_0)
-#define F_CAUSE_CTX_0 V_CAUSE_CTX_0(1U)
-
-#define S_CAUSE_FF 22
-#define V_CAUSE_FF(x) ((x) << S_CAUSE_FF)
-#define F_CAUSE_FF V_CAUSE_FF(1U)
-
-#define S_CAUSE_APF_1 21
-#define V_CAUSE_APF_1(x) ((x) << S_CAUSE_APF_1)
-#define F_CAUSE_APF_1 V_CAUSE_APF_1(1U)
-
-#define S_CAUSE_APF_0 20
-#define V_CAUSE_APF_0(x) ((x) << S_CAUSE_APF_0)
-#define F_CAUSE_APF_0 V_CAUSE_APF_0(1U)
-
-#define S_CAUSE_AF_1 19
-#define V_CAUSE_AF_1(x) ((x) << S_CAUSE_AF_1)
-#define F_CAUSE_AF_1 V_CAUSE_AF_1(1U)
-
-#define S_CAUSE_AF_0 18
-#define V_CAUSE_AF_0(x) ((x) << S_CAUSE_AF_0)
-#define F_CAUSE_AF_0 V_CAUSE_AF_0(1U)
-
-#define S_CAUSE_DDPDF_1 17
-#define V_CAUSE_DDPDF_1(x) ((x) << S_CAUSE_DDPDF_1)
-#define F_CAUSE_DDPDF_1 V_CAUSE_DDPDF_1(1U)
-
-#define S_CAUSE_DDPMF_1 16
-#define V_CAUSE_DDPMF_1(x) ((x) << S_CAUSE_DDPMF_1)
-#define F_CAUSE_DDPMF_1 V_CAUSE_DDPMF_1(1U)
-
-#define S_CAUSE_MEMRF_1 15
-#define V_CAUSE_MEMRF_1(x) ((x) << S_CAUSE_MEMRF_1)
-#define F_CAUSE_MEMRF_1 V_CAUSE_MEMRF_1(1U)
-
-#define S_CAUSE_PRSDF_1 14
-#define V_CAUSE_PRSDF_1(x) ((x) << S_CAUSE_PRSDF_1)
-#define F_CAUSE_PRSDF_1 V_CAUSE_PRSDF_1(1U)
-
-#define S_CAUSE_DDPDF_0 13
-#define V_CAUSE_DDPDF_0(x) ((x) << S_CAUSE_DDPDF_0)
-#define F_CAUSE_DDPDF_0 V_CAUSE_DDPDF_0(1U)
-
-#define S_CAUSE_DDPMF_0 12
-#define V_CAUSE_DDPMF_0(x) ((x) << S_CAUSE_DDPMF_0)
-#define F_CAUSE_DDPMF_0 V_CAUSE_DDPMF_0(1U)
-
-#define S_CAUSE_MEMRF_0 11
-#define V_CAUSE_MEMRF_0(x) ((x) << S_CAUSE_MEMRF_0)
-#define F_CAUSE_MEMRF_0 V_CAUSE_MEMRF_0(1U)
-
-#define S_CAUSE_PRSDF_0 10
-#define V_CAUSE_PRSDF_0(x) ((x) << S_CAUSE_PRSDF_0)
-#define F_CAUSE_PRSDF_0 V_CAUSE_PRSDF_0(1U)
-
-#define S_CAUSE_PCMDF_1 9
-#define V_CAUSE_PCMDF_1(x) ((x) << S_CAUSE_PCMDF_1)
-#define F_CAUSE_PCMDF_1 V_CAUSE_PCMDF_1(1U)
-
-#define S_CAUSE_TPTCF_1 8
-#define V_CAUSE_TPTCF_1(x) ((x) << S_CAUSE_TPTCF_1)
-#define F_CAUSE_TPTCF_1 V_CAUSE_TPTCF_1(1U)
-
-#define S_CAUSE_DDPCF_1 7
-#define V_CAUSE_DDPCF_1(x) ((x) << S_CAUSE_DDPCF_1)
-#define F_CAUSE_DDPCF_1 V_CAUSE_DDPCF_1(1U)
-
-#define S_CAUSE_MPARF_1 6
-#define V_CAUSE_MPARF_1(x) ((x) << S_CAUSE_MPARF_1)
-#define F_CAUSE_MPARF_1 V_CAUSE_MPARF_1(1U)
-
-#define S_CAUSE_MPARC_1 5
-#define V_CAUSE_MPARC_1(x) ((x) << S_CAUSE_MPARC_1)
-#define F_CAUSE_MPARC_1 V_CAUSE_MPARC_1(1U)
-
-#define S_CAUSE_PCMDF_0 4
-#define V_CAUSE_PCMDF_0(x) ((x) << S_CAUSE_PCMDF_0)
-#define F_CAUSE_PCMDF_0 V_CAUSE_PCMDF_0(1U)
-
-#define S_CAUSE_TPTCF_0 3
-#define V_CAUSE_TPTCF_0(x) ((x) << S_CAUSE_TPTCF_0)
-#define F_CAUSE_TPTCF_0 V_CAUSE_TPTCF_0(1U)
-
-#define S_CAUSE_DDPCF_0 2
-#define V_CAUSE_DDPCF_0(x) ((x) << S_CAUSE_DDPCF_0)
-#define F_CAUSE_DDPCF_0 V_CAUSE_DDPCF_0(1U)
-
-#define S_CAUSE_MPARF_0 1
-#define V_CAUSE_MPARF_0(x) ((x) << S_CAUSE_MPARF_0)
-#define F_CAUSE_MPARF_0 V_CAUSE_MPARF_0(1U)
-
-#define S_CAUSE_MPARC_0 0
-#define V_CAUSE_MPARC_0(x) ((x) << S_CAUSE_MPARC_0)
-#define F_CAUSE_MPARC_0 V_CAUSE_MPARC_0(1U)
-
-#define A_ULP_RX_ISCSI_LLIMIT 0x1915c
-
-#define S_ISCSILLIMIT 6
-#define M_ISCSILLIMIT 0x3ffffffU
-#define V_ISCSILLIMIT(x) ((x) << S_ISCSILLIMIT)
-#define G_ISCSILLIMIT(x) (((x) >> S_ISCSILLIMIT) & M_ISCSILLIMIT)
-
-#define A_ULP_RX_ISCSI_ULIMIT 0x19160
-
-#define S_ISCSIULIMIT 6
-#define M_ISCSIULIMIT 0x3ffffffU
-#define V_ISCSIULIMIT(x) ((x) << S_ISCSIULIMIT)
-#define G_ISCSIULIMIT(x) (((x) >> S_ISCSIULIMIT) & M_ISCSIULIMIT)
-
-#define A_ULP_RX_ISCSI_TAGMASK 0x19164
-
-#define S_ISCSITAGMASK 6
-#define M_ISCSITAGMASK 0x3ffffffU
-#define V_ISCSITAGMASK(x) ((x) << S_ISCSITAGMASK)
-#define G_ISCSITAGMASK(x) (((x) >> S_ISCSITAGMASK) & M_ISCSITAGMASK)
-
-#define A_ULP_RX_ISCSI_PSZ 0x19168
-
-#define S_HPZ3 24
-#define M_HPZ3 0xfU
-#define V_HPZ3(x) ((x) << S_HPZ3)
-#define G_HPZ3(x) (((x) >> S_HPZ3) & M_HPZ3)
-
-#define S_HPZ2 16
-#define M_HPZ2 0xfU
-#define V_HPZ2(x) ((x) << S_HPZ2)
-#define G_HPZ2(x) (((x) >> S_HPZ2) & M_HPZ2)
-
-#define S_HPZ1 8
-#define M_HPZ1 0xfU
-#define V_HPZ1(x) ((x) << S_HPZ1)
-#define G_HPZ1(x) (((x) >> S_HPZ1) & M_HPZ1)
-
-#define S_HPZ0 0
-#define M_HPZ0 0xfU
-#define V_HPZ0(x) ((x) << S_HPZ0)
-#define G_HPZ0(x) (((x) >> S_HPZ0) & M_HPZ0)
-
-#define A_ULP_RX_TDDP_LLIMIT 0x1916c
-
-#define S_TDDPLLIMIT 6
-#define M_TDDPLLIMIT 0x3ffffffU
-#define V_TDDPLLIMIT(x) ((x) << S_TDDPLLIMIT)
-#define G_TDDPLLIMIT(x) (((x) >> S_TDDPLLIMIT) & M_TDDPLLIMIT)
-
-#define A_ULP_RX_TDDP_ULIMIT 0x19170
-
-#define S_TDDPULIMIT 6
-#define M_TDDPULIMIT 0x3ffffffU
-#define V_TDDPULIMIT(x) ((x) << S_TDDPULIMIT)
-#define G_TDDPULIMIT(x) (((x) >> S_TDDPULIMIT) & M_TDDPULIMIT)
-
-#define A_ULP_RX_TDDP_TAGMASK 0x19174
-
-#define S_TDDPTAGMASK 6
-#define M_TDDPTAGMASK 0x3ffffffU
-#define V_TDDPTAGMASK(x) ((x) << S_TDDPTAGMASK)
-#define G_TDDPTAGMASK(x) (((x) >> S_TDDPTAGMASK) & M_TDDPTAGMASK)
-
-#define A_ULP_RX_TDDP_PSZ 0x19178
-#define A_ULP_RX_STAG_LLIMIT 0x1917c
-#define A_ULP_RX_STAG_ULIMIT 0x19180
-#define A_ULP_RX_RQ_LLIMIT 0x19184
-#define A_ULP_RX_RQ_ULIMIT 0x19188
-#define A_ULP_RX_PBL_LLIMIT 0x1918c
-#define A_ULP_RX_PBL_ULIMIT 0x19190
-#define A_ULP_RX_CTX_BASE 0x19194
-#define A_ULP_RX_PERR_ENABLE 0x1919c
-
-#define S_PERR_ENABLE_FF 22
-#define V_PERR_ENABLE_FF(x) ((x) << S_PERR_ENABLE_FF)
-#define F_PERR_ENABLE_FF V_PERR_ENABLE_FF(1U)
-
-#define S_PERR_ENABLE_APF_1 21
-#define V_PERR_ENABLE_APF_1(x) ((x) << S_PERR_ENABLE_APF_1)
-#define F_PERR_ENABLE_APF_1 V_PERR_ENABLE_APF_1(1U)
-
-#define S_PERR_ENABLE_APF_0 20
-#define V_PERR_ENABLE_APF_0(x) ((x) << S_PERR_ENABLE_APF_0)
-#define F_PERR_ENABLE_APF_0 V_PERR_ENABLE_APF_0(1U)
-
-#define S_PERR_ENABLE_AF_1 19
-#define V_PERR_ENABLE_AF_1(x) ((x) << S_PERR_ENABLE_AF_1)
-#define F_PERR_ENABLE_AF_1 V_PERR_ENABLE_AF_1(1U)
-
-#define S_PERR_ENABLE_AF_0 18
-#define V_PERR_ENABLE_AF_0(x) ((x) << S_PERR_ENABLE_AF_0)
-#define F_PERR_ENABLE_AF_0 V_PERR_ENABLE_AF_0(1U)
-
-#define S_PERR_ENABLE_DDPDF_1 17
-#define V_PERR_ENABLE_DDPDF_1(x) ((x) << S_PERR_ENABLE_DDPDF_1)
-#define F_PERR_ENABLE_DDPDF_1 V_PERR_ENABLE_DDPDF_1(1U)
-
-#define S_PERR_ENABLE_DDPMF_1 16
-#define V_PERR_ENABLE_DDPMF_1(x) ((x) << S_PERR_ENABLE_DDPMF_1)
-#define F_PERR_ENABLE_DDPMF_1 V_PERR_ENABLE_DDPMF_1(1U)
-
-#define S_PERR_ENABLE_MEMRF_1 15
-#define V_PERR_ENABLE_MEMRF_1(x) ((x) << S_PERR_ENABLE_MEMRF_1)
-#define F_PERR_ENABLE_MEMRF_1 V_PERR_ENABLE_MEMRF_1(1U)
-
-#define S_PERR_ENABLE_PRSDF_1 14
-#define V_PERR_ENABLE_PRSDF_1(x) ((x) << S_PERR_ENABLE_PRSDF_1)
-#define F_PERR_ENABLE_PRSDF_1 V_PERR_ENABLE_PRSDF_1(1U)
-
-#define S_PERR_ENABLE_DDPDF_0 13
-#define V_PERR_ENABLE_DDPDF_0(x) ((x) << S_PERR_ENABLE_DDPDF_0)
-#define F_PERR_ENABLE_DDPDF_0 V_PERR_ENABLE_DDPDF_0(1U)
-
-#define S_PERR_ENABLE_DDPMF_0 12
-#define V_PERR_ENABLE_DDPMF_0(x) ((x) << S_PERR_ENABLE_DDPMF_0)
-#define F_PERR_ENABLE_DDPMF_0 V_PERR_ENABLE_DDPMF_0(1U)
-
-#define S_PERR_ENABLE_MEMRF_0 11
-#define V_PERR_ENABLE_MEMRF_0(x) ((x) << S_PERR_ENABLE_MEMRF_0)
-#define F_PERR_ENABLE_MEMRF_0 V_PERR_ENABLE_MEMRF_0(1U)
-
-#define S_PERR_ENABLE_PRSDF_0 10
-#define V_PERR_ENABLE_PRSDF_0(x) ((x) << S_PERR_ENABLE_PRSDF_0)
-#define F_PERR_ENABLE_PRSDF_0 V_PERR_ENABLE_PRSDF_0(1U)
-
-#define S_PERR_ENABLE_PCMDF_1 9
-#define V_PERR_ENABLE_PCMDF_1(x) ((x) << S_PERR_ENABLE_PCMDF_1)
-#define F_PERR_ENABLE_PCMDF_1 V_PERR_ENABLE_PCMDF_1(1U)
-
-#define S_PERR_ENABLE_TPTCF_1 8
-#define V_PERR_ENABLE_TPTCF_1(x) ((x) << S_PERR_ENABLE_TPTCF_1)
-#define F_PERR_ENABLE_TPTCF_1 V_PERR_ENABLE_TPTCF_1(1U)
-
-#define S_PERR_ENABLE_DDPCF_1 7
-#define V_PERR_ENABLE_DDPCF_1(x) ((x) << S_PERR_ENABLE_DDPCF_1)
-#define F_PERR_ENABLE_DDPCF_1 V_PERR_ENABLE_DDPCF_1(1U)
-
-#define S_PERR_ENABLE_MPARF_1 6
-#define V_PERR_ENABLE_MPARF_1(x) ((x) << S_PERR_ENABLE_MPARF_1)
-#define F_PERR_ENABLE_MPARF_1 V_PERR_ENABLE_MPARF_1(1U)
-
-#define S_PERR_ENABLE_MPARC_1 5
-#define V_PERR_ENABLE_MPARC_1(x) ((x) << S_PERR_ENABLE_MPARC_1)
-#define F_PERR_ENABLE_MPARC_1 V_PERR_ENABLE_MPARC_1(1U)
-
-#define S_PERR_ENABLE_PCMDF_0 4
-#define V_PERR_ENABLE_PCMDF_0(x) ((x) << S_PERR_ENABLE_PCMDF_0)
-#define F_PERR_ENABLE_PCMDF_0 V_PERR_ENABLE_PCMDF_0(1U)
-
-#define S_PERR_ENABLE_TPTCF_0 3
-#define V_PERR_ENABLE_TPTCF_0(x) ((x) << S_PERR_ENABLE_TPTCF_0)
-#define F_PERR_ENABLE_TPTCF_0 V_PERR_ENABLE_TPTCF_0(1U)
-
-#define S_PERR_ENABLE_DDPCF_0 2
-#define V_PERR_ENABLE_DDPCF_0(x) ((x) << S_PERR_ENABLE_DDPCF_0)
-#define F_PERR_ENABLE_DDPCF_0 V_PERR_ENABLE_DDPCF_0(1U)
-
-#define S_PERR_ENABLE_MPARF_0 1
-#define V_PERR_ENABLE_MPARF_0(x) ((x) << S_PERR_ENABLE_MPARF_0)
-#define F_PERR_ENABLE_MPARF_0 V_PERR_ENABLE_MPARF_0(1U)
-
-#define S_PERR_ENABLE_MPARC_0 0
-#define V_PERR_ENABLE_MPARC_0(x) ((x) << S_PERR_ENABLE_MPARC_0)
-#define F_PERR_ENABLE_MPARC_0 V_PERR_ENABLE_MPARC_0(1U)
-
-#define S_PERR_SE_CNT_MISMATCH_1 26
-#define V_PERR_SE_CNT_MISMATCH_1(x) ((x) << S_PERR_SE_CNT_MISMATCH_1)
-#define F_PERR_SE_CNT_MISMATCH_1 V_PERR_SE_CNT_MISMATCH_1(1U)
-
-#define S_PERR_SE_CNT_MISMATCH_0 25
-#define V_PERR_SE_CNT_MISMATCH_0(x) ((x) << S_PERR_SE_CNT_MISMATCH_0)
-#define F_PERR_SE_CNT_MISMATCH_0 V_PERR_SE_CNT_MISMATCH_0(1U)
-
-#define S_PERR_RSVD0 24
-#define V_PERR_RSVD0(x) ((x) << S_PERR_RSVD0)
-#define F_PERR_RSVD0 V_PERR_RSVD0(1U)
-
-#define S_PERR_RSVD1 23
-#define V_PERR_RSVD1(x) ((x) << S_PERR_RSVD1)
-#define F_PERR_RSVD1 V_PERR_RSVD1(1U)
-
-#define S_PERR_ENABLE_CTX_1 24
-#define V_PERR_ENABLE_CTX_1(x) ((x) << S_PERR_ENABLE_CTX_1)
-#define F_PERR_ENABLE_CTX_1 V_PERR_ENABLE_CTX_1(1U)
-
-#define S_PERR_ENABLE_CTX_0 23
-#define V_PERR_ENABLE_CTX_0(x) ((x) << S_PERR_ENABLE_CTX_0)
-#define F_PERR_ENABLE_CTX_0 V_PERR_ENABLE_CTX_0(1U)
-
-#define A_ULP_RX_PERR_INJECT 0x191a0
-#define A_ULP_RX_RQUDP_LLIMIT 0x191a4
-#define A_ULP_RX_RQUDP_ULIMIT 0x191a8
-#define A_ULP_RX_CTX_ACC_CH0 0x191ac
-
-#define S_REQ 21
-#define V_REQ(x) ((x) << S_REQ)
-#define F_REQ V_REQ(1U)
-
-#define S_WB 20
-#define V_WB(x) ((x) << S_WB)
-#define F_WB V_WB(1U)
-
-#define S_ULPRX_TID 0
-#define M_ULPRX_TID 0xfffffU
-#define V_ULPRX_TID(x) ((x) << S_ULPRX_TID)
-#define G_ULPRX_TID(x) (((x) >> S_ULPRX_TID) & M_ULPRX_TID)
-
-#define A_ULP_RX_CTX_ACC_CH1 0x191b0
-#define A_ULP_RX_SE_CNT_ERR 0x191d0
-#define A_ULP_RX_SE_CNT_CLR 0x191d4
-
-#define S_CLRCHAN0 4
-#define M_CLRCHAN0 0xfU
-#define V_CLRCHAN0(x) ((x) << S_CLRCHAN0)
-#define G_CLRCHAN0(x) (((x) >> S_CLRCHAN0) & M_CLRCHAN0)
-
-#define S_CLRCHAN1 0
-#define M_CLRCHAN1 0xfU
-#define V_CLRCHAN1(x) ((x) << S_CLRCHAN1)
-#define G_CLRCHAN1(x) (((x) >> S_CLRCHAN1) & M_CLRCHAN1)
-
-#define A_ULP_RX_SE_CNT_CH0 0x191d8
-
-#define S_SOP_CNT_OUT0 28
-#define M_SOP_CNT_OUT0 0xfU
-#define V_SOP_CNT_OUT0(x) ((x) << S_SOP_CNT_OUT0)
-#define G_SOP_CNT_OUT0(x) (((x) >> S_SOP_CNT_OUT0) & M_SOP_CNT_OUT0)
-
-#define S_EOP_CNT_OUT0 24
-#define M_EOP_CNT_OUT0 0xfU
-#define V_EOP_CNT_OUT0(x) ((x) << S_EOP_CNT_OUT0)
-#define G_EOP_CNT_OUT0(x) (((x) >> S_EOP_CNT_OUT0) & M_EOP_CNT_OUT0)
-
-#define S_SOP_CNT_AL0 20
-#define M_SOP_CNT_AL0 0xfU
-#define V_SOP_CNT_AL0(x) ((x) << S_SOP_CNT_AL0)
-#define G_SOP_CNT_AL0(x) (((x) >> S_SOP_CNT_AL0) & M_SOP_CNT_AL0)
-
-#define S_EOP_CNT_AL0 16
-#define M_EOP_CNT_AL0 0xfU
-#define V_EOP_CNT_AL0(x) ((x) << S_EOP_CNT_AL0)
-#define G_EOP_CNT_AL0(x) (((x) >> S_EOP_CNT_AL0) & M_EOP_CNT_AL0)
-
-#define S_SOP_CNT_MR0 12
-#define M_SOP_CNT_MR0 0xfU
-#define V_SOP_CNT_MR0(x) ((x) << S_SOP_CNT_MR0)
-#define G_SOP_CNT_MR0(x) (((x) >> S_SOP_CNT_MR0) & M_SOP_CNT_MR0)
-
-#define S_EOP_CNT_MR0 8
-#define M_EOP_CNT_MR0 0xfU
-#define V_EOP_CNT_MR0(x) ((x) << S_EOP_CNT_MR0)
-#define G_EOP_CNT_MR0(x) (((x) >> S_EOP_CNT_MR0) & M_EOP_CNT_MR0)
-
-#define S_SOP_CNT_IN0 4
-#define M_SOP_CNT_IN0 0xfU
-#define V_SOP_CNT_IN0(x) ((x) << S_SOP_CNT_IN0)
-#define G_SOP_CNT_IN0(x) (((x) >> S_SOP_CNT_IN0) & M_SOP_CNT_IN0)
-
-#define S_EOP_CNT_IN0 0
-#define M_EOP_CNT_IN0 0xfU
-#define V_EOP_CNT_IN0(x) ((x) << S_EOP_CNT_IN0)
-#define G_EOP_CNT_IN0(x) (((x) >> S_EOP_CNT_IN0) & M_EOP_CNT_IN0)
-
-#define A_ULP_RX_SE_CNT_CH1 0x191dc
-
-#define S_SOP_CNT_OUT1 28
-#define M_SOP_CNT_OUT1 0xfU
-#define V_SOP_CNT_OUT1(x) ((x) << S_SOP_CNT_OUT1)
-#define G_SOP_CNT_OUT1(x) (((x) >> S_SOP_CNT_OUT1) & M_SOP_CNT_OUT1)
-
-#define S_EOP_CNT_OUT1 24
-#define M_EOP_CNT_OUT1 0xfU
-#define V_EOP_CNT_OUT1(x) ((x) << S_EOP_CNT_OUT1)
-#define G_EOP_CNT_OUT1(x) (((x) >> S_EOP_CNT_OUT1) & M_EOP_CNT_OUT1)
-
-#define S_SOP_CNT_AL1 20
-#define M_SOP_CNT_AL1 0xfU
-#define V_SOP_CNT_AL1(x) ((x) << S_SOP_CNT_AL1)
-#define G_SOP_CNT_AL1(x) (((x) >> S_SOP_CNT_AL1) & M_SOP_CNT_AL1)
-
-#define S_EOP_CNT_AL1 16
-#define M_EOP_CNT_AL1 0xfU
-#define V_EOP_CNT_AL1(x) ((x) << S_EOP_CNT_AL1)
-#define G_EOP_CNT_AL1(x) (((x) >> S_EOP_CNT_AL1) & M_EOP_CNT_AL1)
-
-#define S_SOP_CNT_MR1 12
-#define M_SOP_CNT_MR1 0xfU
-#define V_SOP_CNT_MR1(x) ((x) << S_SOP_CNT_MR1)
-#define G_SOP_CNT_MR1(x) (((x) >> S_SOP_CNT_MR1) & M_SOP_CNT_MR1)
-
-#define S_EOP_CNT_MR1 8
-#define M_EOP_CNT_MR1 0xfU
-#define V_EOP_CNT_MR1(x) ((x) << S_EOP_CNT_MR1)
-#define G_EOP_CNT_MR1(x) (((x) >> S_EOP_CNT_MR1) & M_EOP_CNT_MR1)
-
-#define S_SOP_CNT_IN1 4
-#define M_SOP_CNT_IN1 0xfU
-#define V_SOP_CNT_IN1(x) ((x) << S_SOP_CNT_IN1)
-#define G_SOP_CNT_IN1(x) (((x) >> S_SOP_CNT_IN1) & M_SOP_CNT_IN1)
-
-#define S_EOP_CNT_IN1 0
-#define M_EOP_CNT_IN1 0xfU
-#define V_EOP_CNT_IN1(x) ((x) << S_EOP_CNT_IN1)
-#define G_EOP_CNT_IN1(x) (((x) >> S_EOP_CNT_IN1) & M_EOP_CNT_IN1)
-
-#define A_ULP_RX_DBG_CTL 0x191e0
-
-#define S_EN_DBG_H 17
-#define V_EN_DBG_H(x) ((x) << S_EN_DBG_H)
-#define F_EN_DBG_H V_EN_DBG_H(1U)
-
-#define S_EN_DBG_L 16
-#define V_EN_DBG_L(x) ((x) << S_EN_DBG_L)
-#define F_EN_DBG_L V_EN_DBG_L(1U)
-
-#define S_SEL_H 8
-#define M_SEL_H 0xffU
-#define V_SEL_H(x) ((x) << S_SEL_H)
-#define G_SEL_H(x) (((x) >> S_SEL_H) & M_SEL_H)
-
-#define S_SEL_L 0
-#define M_SEL_L 0xffU
-#define V_SEL_L(x) ((x) << S_SEL_L)
-#define G_SEL_L(x) (((x) >> S_SEL_L) & M_SEL_L)
-
-#define A_ULP_RX_DBG_DATAH 0x191e4
-#define A_ULP_RX_DBG_DATAL 0x191e8
-#define A_ULP_RX_LA_CHNL 0x19238
-
-#define S_CHNL_SEL 0
-#define V_CHNL_SEL(x) ((x) << S_CHNL_SEL)
-#define F_CHNL_SEL V_CHNL_SEL(1U)
-
-#define A_ULP_RX_LA_CTL 0x1923c
-
-#define S_TRC_SEL 0
-#define V_TRC_SEL(x) ((x) << S_TRC_SEL)
-#define F_TRC_SEL V_TRC_SEL(1U)
-
-#define A_ULP_RX_LA_RDPTR 0x19240
-
-#define S_RD_PTR 0
-#define M_RD_PTR 0x1ffU
-#define V_RD_PTR(x) ((x) << S_RD_PTR)
-#define G_RD_PTR(x) (((x) >> S_RD_PTR) & M_RD_PTR)
-
-#define A_ULP_RX_LA_RDDATA 0x19244
-#define A_ULP_RX_LA_WRPTR 0x19248
-
-#define S_WR_PTR 0
-#define M_WR_PTR 0x1ffU
-#define V_WR_PTR(x) ((x) << S_WR_PTR)
-#define G_WR_PTR(x) (((x) >> S_WR_PTR) & M_WR_PTR)
-
-#define A_ULP_RX_LA_RESERVED 0x1924c
-#define A_ULP_RX_CQE_GEN_EN 0x19250
-
-#define S_TERMIMATE_MSG 1
-#define V_TERMIMATE_MSG(x) ((x) << S_TERMIMATE_MSG)
-#define F_TERMIMATE_MSG V_TERMIMATE_MSG(1U)
-
-#define S_TERMINATE_WITH_ERR 0
-#define V_TERMINATE_WITH_ERR(x) ((x) << S_TERMINATE_WITH_ERR)
-#define F_TERMINATE_WITH_ERR V_TERMINATE_WITH_ERR(1U)
-
-#define A_ULP_RX_ATOMIC_OPCODES 0x19254
-
-#define S_ATOMIC_REQ_QNO 22
-#define M_ATOMIC_REQ_QNO 0x3U
-#define V_ATOMIC_REQ_QNO(x) ((x) << S_ATOMIC_REQ_QNO)
-#define G_ATOMIC_REQ_QNO(x) (((x) >> S_ATOMIC_REQ_QNO) & M_ATOMIC_REQ_QNO)
-
-#define S_ATOMIC_RSP_QNO 20
-#define M_ATOMIC_RSP_QNO 0x3U
-#define V_ATOMIC_RSP_QNO(x) ((x) << S_ATOMIC_RSP_QNO)
-#define G_ATOMIC_RSP_QNO(x) (((x) >> S_ATOMIC_RSP_QNO) & M_ATOMIC_RSP_QNO)
-
-#define S_IMMEDIATE_QNO 18
-#define M_IMMEDIATE_QNO 0x3U
-#define V_IMMEDIATE_QNO(x) ((x) << S_IMMEDIATE_QNO)
-#define G_IMMEDIATE_QNO(x) (((x) >> S_IMMEDIATE_QNO) & M_IMMEDIATE_QNO)
-
-#define S_IMMEDIATE_WITH_SE_QNO 16
-#define M_IMMEDIATE_WITH_SE_QNO 0x3U
-#define V_IMMEDIATE_WITH_SE_QNO(x) ((x) << S_IMMEDIATE_WITH_SE_QNO)
-#define G_IMMEDIATE_WITH_SE_QNO(x) (((x) >> S_IMMEDIATE_WITH_SE_QNO) & M_IMMEDIATE_WITH_SE_QNO)
-
-#define S_ATOMIC_WR_OPCODE 12
-#define M_ATOMIC_WR_OPCODE 0xfU
-#define V_ATOMIC_WR_OPCODE(x) ((x) << S_ATOMIC_WR_OPCODE)
-#define G_ATOMIC_WR_OPCODE(x) (((x) >> S_ATOMIC_WR_OPCODE) & M_ATOMIC_WR_OPCODE)
-
-#define S_ATOMIC_RD_OPCODE 8
-#define M_ATOMIC_RD_OPCODE 0xfU
-#define V_ATOMIC_RD_OPCODE(x) ((x) << S_ATOMIC_RD_OPCODE)
-#define G_ATOMIC_RD_OPCODE(x) (((x) >> S_ATOMIC_RD_OPCODE) & M_ATOMIC_RD_OPCODE)
-
-#define S_IMMEDIATE_OPCODE 4
-#define M_IMMEDIATE_OPCODE 0xfU
-#define V_IMMEDIATE_OPCODE(x) ((x) << S_IMMEDIATE_OPCODE)
-#define G_IMMEDIATE_OPCODE(x) (((x) >> S_IMMEDIATE_OPCODE) & M_IMMEDIATE_OPCODE)
-
-#define S_IMMEDIATE_WITH_SE_OPCODE 0
-#define M_IMMEDIATE_WITH_SE_OPCODE 0xfU
-#define V_IMMEDIATE_WITH_SE_OPCODE(x) ((x) << S_IMMEDIATE_WITH_SE_OPCODE)
-#define G_IMMEDIATE_WITH_SE_OPCODE(x) (((x) >> S_IMMEDIATE_WITH_SE_OPCODE) & M_IMMEDIATE_WITH_SE_OPCODE)
-
-#define A_ULP_RX_T10_CRC_ENDIAN_SWITCHING 0x19258
-
-#define S_EN_ORIG_DATA 0
-#define V_EN_ORIG_DATA(x) ((x) << S_EN_ORIG_DATA)
-#define F_EN_ORIG_DATA V_EN_ORIG_DATA(1U)
-
-#define A_ULP_RX_MISC_FEATURE_ENABLE 0x1925c
-
-#define S_TERMINATE_STATUS_EN 4
-#define V_TERMINATE_STATUS_EN(x) ((x) << S_TERMINATE_STATUS_EN)
-#define F_TERMINATE_STATUS_EN V_TERMINATE_STATUS_EN(1U)
-
-#define S_MULTIPLE_PREF_ENABLE 3
-#define V_MULTIPLE_PREF_ENABLE(x) ((x) << S_MULTIPLE_PREF_ENABLE)
-#define F_MULTIPLE_PREF_ENABLE V_MULTIPLE_PREF_ENABLE(1U)
-
-#define S_UMUDP_PBL_PREF_ENABLE 2
-#define V_UMUDP_PBL_PREF_ENABLE(x) ((x) << S_UMUDP_PBL_PREF_ENABLE)
-#define F_UMUDP_PBL_PREF_ENABLE V_UMUDP_PBL_PREF_ENABLE(1U)
-
-#define S_RDMA_PBL_PREF_EN 1
-#define V_RDMA_PBL_PREF_EN(x) ((x) << S_RDMA_PBL_PREF_EN)
-#define F_RDMA_PBL_PREF_EN V_RDMA_PBL_PREF_EN(1U)
-
-#define S_SDC_CRC_PROT_EN 0
-#define V_SDC_CRC_PROT_EN(x) ((x) << S_SDC_CRC_PROT_EN)
-#define F_SDC_CRC_PROT_EN V_SDC_CRC_PROT_EN(1U)
-
-#define S_ISCSI_DCRC_ERROR_CMP_EN 25
-#define V_ISCSI_DCRC_ERROR_CMP_EN(x) ((x) << S_ISCSI_DCRC_ERROR_CMP_EN)
-#define F_ISCSI_DCRC_ERROR_CMP_EN V_ISCSI_DCRC_ERROR_CMP_EN(1U)
-
-#define S_ISCSITAGPI 24
-#define V_ISCSITAGPI(x) ((x) << S_ISCSITAGPI)
-#define F_ISCSITAGPI V_ISCSITAGPI(1U)
-
-#define S_DDP_VERSION_1 22
-#define M_DDP_VERSION_1 0x3U
-#define V_DDP_VERSION_1(x) ((x) << S_DDP_VERSION_1)
-#define G_DDP_VERSION_1(x) (((x) >> S_DDP_VERSION_1) & M_DDP_VERSION_1)
-
-#define S_DDP_VERSION_0 20
-#define M_DDP_VERSION_0 0x3U
-#define V_DDP_VERSION_0(x) ((x) << S_DDP_VERSION_0)
-#define G_DDP_VERSION_0(x) (((x) >> S_DDP_VERSION_0) & M_DDP_VERSION_0)
-
-#define S_RDMA_VERSION_1 18
-#define M_RDMA_VERSION_1 0x3U
-#define V_RDMA_VERSION_1(x) ((x) << S_RDMA_VERSION_1)
-#define G_RDMA_VERSION_1(x) (((x) >> S_RDMA_VERSION_1) & M_RDMA_VERSION_1)
-
-#define S_RDMA_VERSION_0 16
-#define M_RDMA_VERSION_0 0x3U
-#define V_RDMA_VERSION_0(x) ((x) << S_RDMA_VERSION_0)
-#define G_RDMA_VERSION_0(x) (((x) >> S_RDMA_VERSION_0) & M_RDMA_VERSION_0)
-
-#define S_PBL_BOUND_CHECK_W_PGLEN 15
-#define V_PBL_BOUND_CHECK_W_PGLEN(x) ((x) << S_PBL_BOUND_CHECK_W_PGLEN)
-#define F_PBL_BOUND_CHECK_W_PGLEN V_PBL_BOUND_CHECK_W_PGLEN(1U)
-
-#define S_ZBYTE_FIX_DISABLE 14
-#define V_ZBYTE_FIX_DISABLE(x) ((x) << S_ZBYTE_FIX_DISABLE)
-#define F_ZBYTE_FIX_DISABLE V_ZBYTE_FIX_DISABLE(1U)
-
-#define S_T10_OFFSET_UPDATE_EN 13
-#define V_T10_OFFSET_UPDATE_EN(x) ((x) << S_T10_OFFSET_UPDATE_EN)
-#define F_T10_OFFSET_UPDATE_EN V_T10_OFFSET_UPDATE_EN(1U)
-
-#define S_ULP_INSERT_PI 12
-#define V_ULP_INSERT_PI(x) ((x) << S_ULP_INSERT_PI)
-#define F_ULP_INSERT_PI V_ULP_INSERT_PI(1U)
-
-#define S_PDU_DPI 11
-#define V_PDU_DPI(x) ((x) << S_PDU_DPI)
-#define F_PDU_DPI V_PDU_DPI(1U)
-
-#define S_ISCSI_EFF_OFFSET_EN 10
-#define V_ISCSI_EFF_OFFSET_EN(x) ((x) << S_ISCSI_EFF_OFFSET_EN)
-#define F_ISCSI_EFF_OFFSET_EN V_ISCSI_EFF_OFFSET_EN(1U)
-
-#define S_ISCSI_ALL_CMP_MODE 9
-#define V_ISCSI_ALL_CMP_MODE(x) ((x) << S_ISCSI_ALL_CMP_MODE)
-#define F_ISCSI_ALL_CMP_MODE V_ISCSI_ALL_CMP_MODE(1U)
-
-#define S_ISCSI_ENABLE_HDR_CMD 8
-#define V_ISCSI_ENABLE_HDR_CMD(x) ((x) << S_ISCSI_ENABLE_HDR_CMD)
-#define F_ISCSI_ENABLE_HDR_CMD V_ISCSI_ENABLE_HDR_CMD(1U)
-
-#define S_ISCSI_FORCE_CMP_MODE 7
-#define V_ISCSI_FORCE_CMP_MODE(x) ((x) << S_ISCSI_FORCE_CMP_MODE)
-#define F_ISCSI_FORCE_CMP_MODE V_ISCSI_FORCE_CMP_MODE(1U)
-
-#define S_ISCSI_ENABLE_CMP_MODE 6
-#define V_ISCSI_ENABLE_CMP_MODE(x) ((x) << S_ISCSI_ENABLE_CMP_MODE)
-#define F_ISCSI_ENABLE_CMP_MODE V_ISCSI_ENABLE_CMP_MODE(1U)
-
-#define S_PIO_RDMA_SEND_RQE 5
-#define V_PIO_RDMA_SEND_RQE(x) ((x) << S_PIO_RDMA_SEND_RQE)
-#define F_PIO_RDMA_SEND_RQE V_PIO_RDMA_SEND_RQE(1U)
-
-#define A_ULP_RX_CH0_CGEN 0x19260
-
-#define S_BYPASS_CGEN 7
-#define V_BYPASS_CGEN(x) ((x) << S_BYPASS_CGEN)
-#define F_BYPASS_CGEN V_BYPASS_CGEN(1U)
-
-#define S_TDDP_CGEN 6
-#define V_TDDP_CGEN(x) ((x) << S_TDDP_CGEN)
-#define F_TDDP_CGEN V_TDDP_CGEN(1U)
-
-#define S_ISCSI_CGEN 5
-#define V_ISCSI_CGEN(x) ((x) << S_ISCSI_CGEN)
-#define F_ISCSI_CGEN V_ISCSI_CGEN(1U)
-
-#define S_RDMA_CGEN 4
-#define V_RDMA_CGEN(x) ((x) << S_RDMA_CGEN)
-#define F_RDMA_CGEN V_RDMA_CGEN(1U)
-
-#define S_CHANNEL_CGEN 3
-#define V_CHANNEL_CGEN(x) ((x) << S_CHANNEL_CGEN)
-#define F_CHANNEL_CGEN V_CHANNEL_CGEN(1U)
-
-#define S_ALL_DATAPATH_CGEN 2
-#define V_ALL_DATAPATH_CGEN(x) ((x) << S_ALL_DATAPATH_CGEN)
-#define F_ALL_DATAPATH_CGEN V_ALL_DATAPATH_CGEN(1U)
-
-#define S_T10DIFF_DATAPATH_CGEN 1
-#define V_T10DIFF_DATAPATH_CGEN(x) ((x) << S_T10DIFF_DATAPATH_CGEN)
-#define F_T10DIFF_DATAPATH_CGEN V_T10DIFF_DATAPATH_CGEN(1U)
-
-#define S_RDMA_DATAPATH_CGEN 0
-#define V_RDMA_DATAPATH_CGEN(x) ((x) << S_RDMA_DATAPATH_CGEN)
-#define F_RDMA_DATAPATH_CGEN V_RDMA_DATAPATH_CGEN(1U)
-
-#define A_ULP_RX_CH1_CGEN 0x19264
-#define A_ULP_RX_RFE_DISABLE 0x19268
-
-#define S_RQE_LIM_CHECK_RFE_DISABLE 0
-#define V_RQE_LIM_CHECK_RFE_DISABLE(x) ((x) << S_RQE_LIM_CHECK_RFE_DISABLE)
-#define F_RQE_LIM_CHECK_RFE_DISABLE V_RQE_LIM_CHECK_RFE_DISABLE(1U)
-
-#define A_ULP_RX_INT_ENABLE_2 0x1926c
-
-#define S_ULPRX2MA_INTFPERR 8
-#define V_ULPRX2MA_INTFPERR(x) ((x) << S_ULPRX2MA_INTFPERR)
-#define F_ULPRX2MA_INTFPERR V_ULPRX2MA_INTFPERR(1U)
-
-#define S_ALN_SDC_ERR_1 7
-#define V_ALN_SDC_ERR_1(x) ((x) << S_ALN_SDC_ERR_1)
-#define F_ALN_SDC_ERR_1 V_ALN_SDC_ERR_1(1U)
-
-#define S_ALN_SDC_ERR_0 6
-#define V_ALN_SDC_ERR_0(x) ((x) << S_ALN_SDC_ERR_0)
-#define F_ALN_SDC_ERR_0 V_ALN_SDC_ERR_0(1U)
-
-#define S_PF_UNTAGGED_TPT_1 5
-#define V_PF_UNTAGGED_TPT_1(x) ((x) << S_PF_UNTAGGED_TPT_1)
-#define F_PF_UNTAGGED_TPT_1 V_PF_UNTAGGED_TPT_1(1U)
-
-#define S_PF_UNTAGGED_TPT_0 4
-#define V_PF_UNTAGGED_TPT_0(x) ((x) << S_PF_UNTAGGED_TPT_0)
-#define F_PF_UNTAGGED_TPT_0 V_PF_UNTAGGED_TPT_0(1U)
-
-#define S_PF_PBL_1 3
-#define V_PF_PBL_1(x) ((x) << S_PF_PBL_1)
-#define F_PF_PBL_1 V_PF_PBL_1(1U)
-
-#define S_PF_PBL_0 2
-#define V_PF_PBL_0(x) ((x) << S_PF_PBL_0)
-#define F_PF_PBL_0 V_PF_PBL_0(1U)
-
-#define S_DDP_HINT_1 1
-#define V_DDP_HINT_1(x) ((x) << S_DDP_HINT_1)
-#define F_DDP_HINT_1 V_DDP_HINT_1(1U)
-
-#define S_DDP_HINT_0 0
-#define V_DDP_HINT_0(x) ((x) << S_DDP_HINT_0)
-#define F_DDP_HINT_0 V_DDP_HINT_0(1U)
-
-#define A_ULP_RX_INT_CAUSE_2 0x19270
-#define A_ULP_RX_PERR_ENABLE_2 0x19274
-
-#define S_ENABLE_ULPRX2MA_INTFPERR 8
-#define V_ENABLE_ULPRX2MA_INTFPERR(x) ((x) << S_ENABLE_ULPRX2MA_INTFPERR)
-#define F_ENABLE_ULPRX2MA_INTFPERR V_ENABLE_ULPRX2MA_INTFPERR(1U)
-
-#define S_ENABLE_ALN_SDC_ERR_1 7
-#define V_ENABLE_ALN_SDC_ERR_1(x) ((x) << S_ENABLE_ALN_SDC_ERR_1)
-#define F_ENABLE_ALN_SDC_ERR_1 V_ENABLE_ALN_SDC_ERR_1(1U)
-
-#define S_ENABLE_ALN_SDC_ERR_0 6
-#define V_ENABLE_ALN_SDC_ERR_0(x) ((x) << S_ENABLE_ALN_SDC_ERR_0)
-#define F_ENABLE_ALN_SDC_ERR_0 V_ENABLE_ALN_SDC_ERR_0(1U)
-
-#define S_ENABLE_PF_UNTAGGED_TPT_1 5
-#define V_ENABLE_PF_UNTAGGED_TPT_1(x) ((x) << S_ENABLE_PF_UNTAGGED_TPT_1)
-#define F_ENABLE_PF_UNTAGGED_TPT_1 V_ENABLE_PF_UNTAGGED_TPT_1(1U)
-
-#define S_ENABLE_PF_UNTAGGED_TPT_0 4
-#define V_ENABLE_PF_UNTAGGED_TPT_0(x) ((x) << S_ENABLE_PF_UNTAGGED_TPT_0)
-#define F_ENABLE_PF_UNTAGGED_TPT_0 V_ENABLE_PF_UNTAGGED_TPT_0(1U)
-
-#define S_ENABLE_PF_PBL_1 3
-#define V_ENABLE_PF_PBL_1(x) ((x) << S_ENABLE_PF_PBL_1)
-#define F_ENABLE_PF_PBL_1 V_ENABLE_PF_PBL_1(1U)
-
-#define S_ENABLE_PF_PBL_0 2
-#define V_ENABLE_PF_PBL_0(x) ((x) << S_ENABLE_PF_PBL_0)
-#define F_ENABLE_PF_PBL_0 V_ENABLE_PF_PBL_0(1U)
-
-#define S_ENABLE_DDP_HINT_1 1
-#define V_ENABLE_DDP_HINT_1(x) ((x) << S_ENABLE_DDP_HINT_1)
-#define F_ENABLE_DDP_HINT_1 V_ENABLE_DDP_HINT_1(1U)
-
-#define S_ENABLE_DDP_HINT_0 0
-#define V_ENABLE_DDP_HINT_0(x) ((x) << S_ENABLE_DDP_HINT_0)
-#define F_ENABLE_DDP_HINT_0 V_ENABLE_DDP_HINT_0(1U)
-
-#define A_ULP_RX_RQE_PBL_MULTIPLE_OUTSTANDING_CNT 0x19278
-
-#define S_PIO_RQE_PBL_MULTIPLE_CNT 0
-#define M_PIO_RQE_PBL_MULTIPLE_CNT 0xfU
-#define V_PIO_RQE_PBL_MULTIPLE_CNT(x) ((x) << S_PIO_RQE_PBL_MULTIPLE_CNT)
-#define G_PIO_RQE_PBL_MULTIPLE_CNT(x) (((x) >> S_PIO_RQE_PBL_MULTIPLE_CNT) & M_PIO_RQE_PBL_MULTIPLE_CNT)
-
-#define A_ULP_RX_ATOMIC_LEN 0x1927c
-
-#define S_ATOMIC_RPL_LEN 16
-#define M_ATOMIC_RPL_LEN 0xffU
-#define V_ATOMIC_RPL_LEN(x) ((x) << S_ATOMIC_RPL_LEN)
-#define G_ATOMIC_RPL_LEN(x) (((x) >> S_ATOMIC_RPL_LEN) & M_ATOMIC_RPL_LEN)
-
-#define S_ATOMIC_REQ_LEN 8
-#define M_ATOMIC_REQ_LEN 0xffU
-#define V_ATOMIC_REQ_LEN(x) ((x) << S_ATOMIC_REQ_LEN)
-#define G_ATOMIC_REQ_LEN(x) (((x) >> S_ATOMIC_REQ_LEN) & M_ATOMIC_REQ_LEN)
-
-#define S_ATOMIC_IMMEDIATE_LEN 0
-#define M_ATOMIC_IMMEDIATE_LEN 0xffU
-#define V_ATOMIC_IMMEDIATE_LEN(x) ((x) << S_ATOMIC_IMMEDIATE_LEN)
-#define G_ATOMIC_IMMEDIATE_LEN(x) (((x) >> S_ATOMIC_IMMEDIATE_LEN) & M_ATOMIC_IMMEDIATE_LEN)
-
-#define A_ULP_RX_CGEN_GLOBAL 0x19280
-#define A_ULP_RX_CTX_SKIP_MA_REQ 0x19284
-
-#define S_CLEAR_CTX_ERR_CNT1 3
-#define V_CLEAR_CTX_ERR_CNT1(x) ((x) << S_CLEAR_CTX_ERR_CNT1)
-#define F_CLEAR_CTX_ERR_CNT1 V_CLEAR_CTX_ERR_CNT1(1U)
-
-#define S_CLEAR_CTX_ERR_CNT0 2
-#define V_CLEAR_CTX_ERR_CNT0(x) ((x) << S_CLEAR_CTX_ERR_CNT0)
-#define F_CLEAR_CTX_ERR_CNT0 V_CLEAR_CTX_ERR_CNT0(1U)
-
-#define S_SKIP_MA_REQ_EN1 1
-#define V_SKIP_MA_REQ_EN1(x) ((x) << S_SKIP_MA_REQ_EN1)
-#define F_SKIP_MA_REQ_EN1 V_SKIP_MA_REQ_EN1(1U)
-
-#define S_SKIP_MA_REQ_EN0 0
-#define V_SKIP_MA_REQ_EN0(x) ((x) << S_SKIP_MA_REQ_EN0)
-#define F_SKIP_MA_REQ_EN0 V_SKIP_MA_REQ_EN0(1U)
-
-#define A_ULP_RX_CHNL0_CTX_ERROR_COUNT_PER_TID 0x19288
-#define A_ULP_RX_CHNL1_CTX_ERROR_COUNT_PER_TID 0x1928c
-#define A_ULP_RX_MSN_CHECK_ENABLE 0x19290
-
-#define S_RD_OR_TERM_MSN_CHECK_ENABLE 2
-#define V_RD_OR_TERM_MSN_CHECK_ENABLE(x) ((x) << S_RD_OR_TERM_MSN_CHECK_ENABLE)
-#define F_RD_OR_TERM_MSN_CHECK_ENABLE V_RD_OR_TERM_MSN_CHECK_ENABLE(1U)
-
-#define S_ATOMIC_OP_MSN_CHECK_ENABLE 1
-#define V_ATOMIC_OP_MSN_CHECK_ENABLE(x) ((x) << S_ATOMIC_OP_MSN_CHECK_ENABLE)
-#define F_ATOMIC_OP_MSN_CHECK_ENABLE V_ATOMIC_OP_MSN_CHECK_ENABLE(1U)
-
-#define S_SEND_MSN_CHECK_ENABLE 0
-#define V_SEND_MSN_CHECK_ENABLE(x) ((x) << S_SEND_MSN_CHECK_ENABLE)
-#define F_SEND_MSN_CHECK_ENABLE V_SEND_MSN_CHECK_ENABLE(1U)
-
-#define A_ULP_RX_TLS_PP_LLIMIT 0x192a4
-
-#define S_TLSPPLLIMIT 6
-#define M_TLSPPLLIMIT 0x3ffffffU
-#define V_TLSPPLLIMIT(x) ((x) << S_TLSPPLLIMIT)
-#define G_TLSPPLLIMIT(x) (((x) >> S_TLSPPLLIMIT) & M_TLSPPLLIMIT)
-
-#define A_ULP_RX_TLS_PP_ULIMIT 0x192a8
-
-#define S_TLSPPULIMIT 6
-#define M_TLSPPULIMIT 0x3ffffffU
-#define V_TLSPPULIMIT(x) ((x) << S_TLSPPULIMIT)
-#define G_TLSPPULIMIT(x) (((x) >> S_TLSPPULIMIT) & M_TLSPPULIMIT)
-
-#define A_ULP_RX_TLS_KEY_LLIMIT 0x192ac
-
-#define S_TLSKEYLLIMIT 8
-#define M_TLSKEYLLIMIT 0xffffffU
-#define V_TLSKEYLLIMIT(x) ((x) << S_TLSKEYLLIMIT)
-#define G_TLSKEYLLIMIT(x) (((x) >> S_TLSKEYLLIMIT) & M_TLSKEYLLIMIT)
-
-#define A_ULP_RX_TLS_KEY_ULIMIT 0x192b0
-
-#define S_TLSKEYULIMIT 8
-#define M_TLSKEYULIMIT 0xffffffU
-#define V_TLSKEYULIMIT(x) ((x) << S_TLSKEYULIMIT)
-#define G_TLSKEYULIMIT(x) (((x) >> S_TLSKEYULIMIT) & M_TLSKEYULIMIT)
-
-#define A_ULP_RX_TLS_CTL 0x192bc
-#define A_ULP_RX_TLS_IND_CMD 0x19348
-
-#define S_TLS_RX_REG_OFF_ADDR 0
-#define M_TLS_RX_REG_OFF_ADDR 0x3ffU
-#define V_TLS_RX_REG_OFF_ADDR(x) ((x) << S_TLS_RX_REG_OFF_ADDR)
-#define G_TLS_RX_REG_OFF_ADDR(x) (((x) >> S_TLS_RX_REG_OFF_ADDR) & M_TLS_RX_REG_OFF_ADDR)
-
-#define A_ULP_RX_TLS_IND_DATA 0x1934c
-
-/* registers for module SF */
-#define SF_BASE_ADDR 0x193f8
-
-#define A_SF_DATA 0x193f8
-#define A_SF_OP 0x193fc
-
-#define S_SF_LOCK 4
-#define V_SF_LOCK(x) ((x) << S_SF_LOCK)
-#define F_SF_LOCK V_SF_LOCK(1U)
-
-#define S_CONT 3
-#define V_CONT(x) ((x) << S_CONT)
-#define F_CONT V_CONT(1U)
-
-#define S_BYTECNT 1
-#define M_BYTECNT 0x3U
-#define V_BYTECNT(x) ((x) << S_BYTECNT)
-#define G_BYTECNT(x) (((x) >> S_BYTECNT) & M_BYTECNT)
-
-/* registers for module PL */
-#define PL_BASE_ADDR 0x19400
-
-#define A_PL_VF_WHOAMI 0x0
-
-#define S_PORTXMAP 24
-#define M_PORTXMAP 0x7U
-#define V_PORTXMAP(x) ((x) << S_PORTXMAP)
-#define G_PORTXMAP(x) (((x) >> S_PORTXMAP) & M_PORTXMAP)
-
-#define S_SOURCEBUS 16
-#define M_SOURCEBUS 0x3U
-#define V_SOURCEBUS(x) ((x) << S_SOURCEBUS)
-#define G_SOURCEBUS(x) (((x) >> S_SOURCEBUS) & M_SOURCEBUS)
-
-#define S_SOURCEPF 8
-#define M_SOURCEPF 0x7U
-#define V_SOURCEPF(x) ((x) << S_SOURCEPF)
-#define G_SOURCEPF(x) (((x) >> S_SOURCEPF) & M_SOURCEPF)
-
-#define S_ISVF 7
-#define V_ISVF(x) ((x) << S_ISVF)
-#define F_ISVF V_ISVF(1U)
-
-#define S_VFID 0
-#define M_VFID 0x7fU
-#define V_VFID(x) ((x) << S_VFID)
-#define G_VFID(x) (((x) >> S_VFID) & M_VFID)
-
-#define S_T6_SOURCEPF 9
-#define M_T6_SOURCEPF 0x7U
-#define V_T6_SOURCEPF(x) ((x) << S_T6_SOURCEPF)
-#define G_T6_SOURCEPF(x) (((x) >> S_T6_SOURCEPF) & M_T6_SOURCEPF)
-
-#define S_T6_ISVF 8
-#define V_T6_ISVF(x) ((x) << S_T6_ISVF)
-#define F_T6_ISVF V_T6_ISVF(1U)
-
-#define S_T6_VFID 0
-#define M_T6_VFID 0xffU
-#define V_T6_VFID(x) ((x) << S_T6_VFID)
-#define G_T6_VFID(x) (((x) >> S_T6_VFID) & M_T6_VFID)
-
-#define A_PL_VF_REV 0x4
-
-#define S_CHIPID 4
-#define M_CHIPID 0xfU
-#define V_CHIPID(x) ((x) << S_CHIPID)
-#define G_CHIPID(x) (((x) >> S_CHIPID) & M_CHIPID)
-
-#define A_PL_VF_REVISION 0x8
-#define A_PL_PF_INT_CAUSE 0x3c0
-
-#define S_PFSW 3
-#define V_PFSW(x) ((x) << S_PFSW)
-#define F_PFSW V_PFSW(1U)
-
-#define S_PFSGE 2
-#define V_PFSGE(x) ((x) << S_PFSGE)
-#define F_PFSGE V_PFSGE(1U)
-
-#define S_PFCIM 1
-#define V_PFCIM(x) ((x) << S_PFCIM)
-#define F_PFCIM V_PFCIM(1U)
-
-#define S_PFMPS 0
-#define V_PFMPS(x) ((x) << S_PFMPS)
-#define F_PFMPS V_PFMPS(1U)
-
-#define A_PL_PF_INT_ENABLE 0x3c4
-#define A_PL_PF_CTL 0x3c8
-
-#define S_SWINT 0
-#define V_SWINT(x) ((x) << S_SWINT)
-#define F_SWINT V_SWINT(1U)
-
-#define A_PL_WHOAMI 0x19400
-
-#define S_T6_SOURCEPF 9
-#define M_T6_SOURCEPF 0x7U
-#define V_T6_SOURCEPF(x) ((x) << S_T6_SOURCEPF)
-#define G_T6_SOURCEPF(x) (((x) >> S_T6_SOURCEPF) & M_T6_SOURCEPF)
-
-#define S_T6_ISVF 8
-#define V_T6_ISVF(x) ((x) << S_T6_ISVF)
-#define F_T6_ISVF V_T6_ISVF(1U)
-
-#define S_T6_VFID 0
-#define M_T6_VFID 0xffU
-#define V_T6_VFID(x) ((x) << S_T6_VFID)
-#define G_T6_VFID(x) (((x) >> S_T6_VFID) & M_T6_VFID)
-
-#define A_PL_PERR_CAUSE 0x19404
-
-#define S_UART 28
-#define V_UART(x) ((x) << S_UART)
-#define F_UART V_UART(1U)
-
-#define S_ULP_TX 27
-#define V_ULP_TX(x) ((x) << S_ULP_TX)
-#define F_ULP_TX V_ULP_TX(1U)
-
-#define S_SGE 26
-#define V_SGE(x) ((x) << S_SGE)
-#define F_SGE V_SGE(1U)
-
-#define S_HMA 25
-#define V_HMA(x) ((x) << S_HMA)
-#define F_HMA V_HMA(1U)
-
-#define S_CPL_SWITCH 24
-#define V_CPL_SWITCH(x) ((x) << S_CPL_SWITCH)
-#define F_CPL_SWITCH V_CPL_SWITCH(1U)
-
-#define S_ULP_RX 23
-#define V_ULP_RX(x) ((x) << S_ULP_RX)
-#define F_ULP_RX V_ULP_RX(1U)
-
-#define S_PM_RX 22
-#define V_PM_RX(x) ((x) << S_PM_RX)
-#define F_PM_RX V_PM_RX(1U)
-
-#define S_PM_TX 21
-#define V_PM_TX(x) ((x) << S_PM_TX)
-#define F_PM_TX V_PM_TX(1U)
-
-#define S_MA 20
-#define V_MA(x) ((x) << S_MA)
-#define F_MA V_MA(1U)
-
-#define S_TP 19
-#define V_TP(x) ((x) << S_TP)
-#define F_TP V_TP(1U)
-
-#define S_LE 18
-#define V_LE(x) ((x) << S_LE)
-#define F_LE V_LE(1U)
-
-#define S_EDC1 17
-#define V_EDC1(x) ((x) << S_EDC1)
-#define F_EDC1 V_EDC1(1U)
-
-#define S_EDC0 16
-#define V_EDC0(x) ((x) << S_EDC0)
-#define F_EDC0 V_EDC0(1U)
-
-#define S_MC 15
-#define V_MC(x) ((x) << S_MC)
-#define F_MC V_MC(1U)
-
-#define S_PCIE 14
-#define V_PCIE(x) ((x) << S_PCIE)
-#define F_PCIE V_PCIE(1U)
-
-#define S_PMU 13
-#define V_PMU(x) ((x) << S_PMU)
-#define F_PMU V_PMU(1U)
-
-#define S_XGMAC_KR1 12
-#define V_XGMAC_KR1(x) ((x) << S_XGMAC_KR1)
-#define F_XGMAC_KR1 V_XGMAC_KR1(1U)
-
-#define S_XGMAC_KR0 11
-#define V_XGMAC_KR0(x) ((x) << S_XGMAC_KR0)
-#define F_XGMAC_KR0 V_XGMAC_KR0(1U)
-
-#define S_XGMAC1 10
-#define V_XGMAC1(x) ((x) << S_XGMAC1)
-#define F_XGMAC1 V_XGMAC1(1U)
-
-#define S_XGMAC0 9
-#define V_XGMAC0(x) ((x) << S_XGMAC0)
-#define F_XGMAC0 V_XGMAC0(1U)
-
-#define S_SMB 8
-#define V_SMB(x) ((x) << S_SMB)
-#define F_SMB V_SMB(1U)
-
-#define S_SF 7
-#define V_SF(x) ((x) << S_SF)
-#define F_SF V_SF(1U)
-
-#define S_PL 6
-#define V_PL(x) ((x) << S_PL)
-#define F_PL V_PL(1U)
-
-#define S_NCSI 5
-#define V_NCSI(x) ((x) << S_NCSI)
-#define F_NCSI V_NCSI(1U)
-
-#define S_MPS 4
-#define V_MPS(x) ((x) << S_MPS)
-#define F_MPS V_MPS(1U)
-
-#define S_MI 3
-#define V_MI(x) ((x) << S_MI)
-#define F_MI V_MI(1U)
-
-#define S_DBG 2
-#define V_DBG(x) ((x) << S_DBG)
-#define F_DBG V_DBG(1U)
-
-#define S_I2CM 1
-#define V_I2CM(x) ((x) << S_I2CM)
-#define F_I2CM V_I2CM(1U)
-
-#define S_CIM 0
-#define V_CIM(x) ((x) << S_CIM)
-#define F_CIM V_CIM(1U)
-
-#define S_MC1 31
-#define V_MC1(x) ((x) << S_MC1)
-#define F_MC1 V_MC1(1U)
-
-#define S_MC0 15
-#define V_MC0(x) ((x) << S_MC0)
-#define F_MC0 V_MC0(1U)
-
-#define S_ANYMAC 9
-#define V_ANYMAC(x) ((x) << S_ANYMAC)
-#define F_ANYMAC V_ANYMAC(1U)
-
-#define A_PL_PERR_ENABLE 0x19408
-#define A_PL_INT_CAUSE 0x1940c
-
-#define S_FLR 30
-#define V_FLR(x) ((x) << S_FLR)
-#define F_FLR V_FLR(1U)
-
-#define S_SW_CIM 29
-#define V_SW_CIM(x) ((x) << S_SW_CIM)
-#define F_SW_CIM V_SW_CIM(1U)
-
-#define S_MAC3 12
-#define V_MAC3(x) ((x) << S_MAC3)
-#define F_MAC3 V_MAC3(1U)
-
-#define S_MAC2 11
-#define V_MAC2(x) ((x) << S_MAC2)
-#define F_MAC2 V_MAC2(1U)
-
-#define S_MAC1 10
-#define V_MAC1(x) ((x) << S_MAC1)
-#define F_MAC1 V_MAC1(1U)
-
-#define S_MAC0 9
-#define V_MAC0(x) ((x) << S_MAC0)
-#define F_MAC0 V_MAC0(1U)
-
-#define A_PL_INT_ENABLE 0x19410
-#define A_PL_INT_MAP0 0x19414
-
-#define S_MAPNCSI 16
-#define M_MAPNCSI 0x1ffU
-#define V_MAPNCSI(x) ((x) << S_MAPNCSI)
-#define G_MAPNCSI(x) (((x) >> S_MAPNCSI) & M_MAPNCSI)
-
-#define S_MAPDEFAULT 0
-#define M_MAPDEFAULT 0x1ffU
-#define V_MAPDEFAULT(x) ((x) << S_MAPDEFAULT)
-#define G_MAPDEFAULT(x) (((x) >> S_MAPDEFAULT) & M_MAPDEFAULT)
-
-#define A_PL_INT_MAP1 0x19418
-
-#define S_MAPXGMAC1 16
-#define M_MAPXGMAC1 0x1ffU
-#define V_MAPXGMAC1(x) ((x) << S_MAPXGMAC1)
-#define G_MAPXGMAC1(x) (((x) >> S_MAPXGMAC1) & M_MAPXGMAC1)
-
-#define S_MAPXGMAC0 0
-#define M_MAPXGMAC0 0x1ffU
-#define V_MAPXGMAC0(x) ((x) << S_MAPXGMAC0)
-#define G_MAPXGMAC0(x) (((x) >> S_MAPXGMAC0) & M_MAPXGMAC0)
-
-#define S_MAPMAC1 16
-#define M_MAPMAC1 0x1ffU
-#define V_MAPMAC1(x) ((x) << S_MAPMAC1)
-#define G_MAPMAC1(x) (((x) >> S_MAPMAC1) & M_MAPMAC1)
-
-#define S_MAPMAC0 0
-#define M_MAPMAC0 0x1ffU
-#define V_MAPMAC0(x) ((x) << S_MAPMAC0)
-#define G_MAPMAC0(x) (((x) >> S_MAPMAC0) & M_MAPMAC0)
-
-#define A_PL_INT_MAP2 0x1941c
-
-#define S_MAPXGMAC_KR1 16
-#define M_MAPXGMAC_KR1 0x1ffU
-#define V_MAPXGMAC_KR1(x) ((x) << S_MAPXGMAC_KR1)
-#define G_MAPXGMAC_KR1(x) (((x) >> S_MAPXGMAC_KR1) & M_MAPXGMAC_KR1)
-
-#define S_MAPXGMAC_KR0 0
-#define M_MAPXGMAC_KR0 0x1ffU
-#define V_MAPXGMAC_KR0(x) ((x) << S_MAPXGMAC_KR0)
-#define G_MAPXGMAC_KR0(x) (((x) >> S_MAPXGMAC_KR0) & M_MAPXGMAC_KR0)
-
-#define S_MAPMAC3 16
-#define M_MAPMAC3 0x1ffU
-#define V_MAPMAC3(x) ((x) << S_MAPMAC3)
-#define G_MAPMAC3(x) (((x) >> S_MAPMAC3) & M_MAPMAC3)
-
-#define S_MAPMAC2 0
-#define M_MAPMAC2 0x1ffU
-#define V_MAPMAC2(x) ((x) << S_MAPMAC2)
-#define G_MAPMAC2(x) (((x) >> S_MAPMAC2) & M_MAPMAC2)
-
-#define A_PL_INT_MAP3 0x19420
-
-#define S_MAPMI 16
-#define M_MAPMI 0x1ffU
-#define V_MAPMI(x) ((x) << S_MAPMI)
-#define G_MAPMI(x) (((x) >> S_MAPMI) & M_MAPMI)
-
-#define S_MAPSMB 0
-#define M_MAPSMB 0x1ffU
-#define V_MAPSMB(x) ((x) << S_MAPSMB)
-#define G_MAPSMB(x) (((x) >> S_MAPSMB) & M_MAPSMB)
-
-#define A_PL_INT_MAP4 0x19424
-
-#define S_MAPDBG 16
-#define M_MAPDBG 0x1ffU
-#define V_MAPDBG(x) ((x) << S_MAPDBG)
-#define G_MAPDBG(x) (((x) >> S_MAPDBG) & M_MAPDBG)
-
-#define S_MAPI2CM 0
-#define M_MAPI2CM 0x1ffU
-#define V_MAPI2CM(x) ((x) << S_MAPI2CM)
-#define G_MAPI2CM(x) (((x) >> S_MAPI2CM) & M_MAPI2CM)
-
-#define A_PL_RST 0x19428
-
-#define S_FATALPERREN 3
-#define V_FATALPERREN(x) ((x) << S_FATALPERREN)
-#define F_FATALPERREN V_FATALPERREN(1U)
-
-#define S_SWINTCIM 2
-#define V_SWINTCIM(x) ((x) << S_SWINTCIM)
-#define F_SWINTCIM V_SWINTCIM(1U)
-
-#define S_PIORST 1
-#define V_PIORST(x) ((x) << S_PIORST)
-#define F_PIORST V_PIORST(1U)
-
-#define S_PIORSTMODE 0
-#define V_PIORSTMODE(x) ((x) << S_PIORSTMODE)
-#define F_PIORSTMODE V_PIORSTMODE(1U)
-
-#define S_AUTOPCIEPAUSE 4
-#define V_AUTOPCIEPAUSE(x) ((x) << S_AUTOPCIEPAUSE)
-#define F_AUTOPCIEPAUSE V_AUTOPCIEPAUSE(1U)
-
-#define A_PL_PL_PERR_INJECT 0x1942c
-
-#define S_PL_MEMSEL 1
-#define V_PL_MEMSEL(x) ((x) << S_PL_MEMSEL)
-#define F_PL_MEMSEL V_PL_MEMSEL(1U)
-
-#define A_PL_PL_INT_CAUSE 0x19430
-
-#define S_PF_ENABLEERR 5
-#define V_PF_ENABLEERR(x) ((x) << S_PF_ENABLEERR)
-#define F_PF_ENABLEERR V_PF_ENABLEERR(1U)
-
-#define S_FATALPERR 4
-#define V_FATALPERR(x) ((x) << S_FATALPERR)
-#define F_FATALPERR V_FATALPERR(1U)
-
-#define S_INVALIDACCESS 3
-#define V_INVALIDACCESS(x) ((x) << S_INVALIDACCESS)
-#define F_INVALIDACCESS V_INVALIDACCESS(1U)
-
-#define S_TIMEOUT 2
-#define V_TIMEOUT(x) ((x) << S_TIMEOUT)
-#define F_TIMEOUT V_TIMEOUT(1U)
-
-#define S_PLERR 1
-#define V_PLERR(x) ((x) << S_PLERR)
-#define F_PLERR V_PLERR(1U)
-
-#define S_PERRVFID 0
-#define V_PERRVFID(x) ((x) << S_PERRVFID)
-#define F_PERRVFID V_PERRVFID(1U)
-
-#define S_PL_BUSPERR 6
-#define V_PL_BUSPERR(x) ((x) << S_PL_BUSPERR)
-#define F_PL_BUSPERR V_PL_BUSPERR(1U)
-
-#define A_PL_PL_INT_ENABLE 0x19434
-#define A_PL_PL_PERR_ENABLE 0x19438
-#define A_PL_REV 0x1943c
-
-#define S_REV 0
-#define M_REV 0xfU
-#define V_REV(x) ((x) << S_REV)
-#define G_REV(x) (((x) >> S_REV) & M_REV)
-
-#define A_PL_PCIE_LINK 0x19440
-
-#define S_LN0_AESTAT 26
-#define M_LN0_AESTAT 0x7U
-#define V_LN0_AESTAT(x) ((x) << S_LN0_AESTAT)
-#define G_LN0_AESTAT(x) (((x) >> S_LN0_AESTAT) & M_LN0_AESTAT)
-
-#define S_LN0_AECMD 23
-#define M_LN0_AECMD 0x7U
-#define V_LN0_AECMD(x) ((x) << S_LN0_AECMD)
-#define G_LN0_AECMD(x) (((x) >> S_LN0_AECMD) & M_LN0_AECMD)
-
-#define S_T5_STATECFGINITF 16
-#define M_T5_STATECFGINITF 0x7fU
-#define V_T5_STATECFGINITF(x) ((x) << S_T5_STATECFGINITF)
-#define G_T5_STATECFGINITF(x) (((x) >> S_T5_STATECFGINITF) & M_T5_STATECFGINITF)
-
-#define S_T5_STATECFGINIT 12
-#define M_T5_STATECFGINIT 0xfU
-#define V_T5_STATECFGINIT(x) ((x) << S_T5_STATECFGINIT)
-#define G_T5_STATECFGINIT(x) (((x) >> S_T5_STATECFGINIT) & M_T5_STATECFGINIT)
-
-#define S_PCIE_SPEED 8
-#define M_PCIE_SPEED 0x3U
-#define V_PCIE_SPEED(x) ((x) << S_PCIE_SPEED)
-#define G_PCIE_SPEED(x) (((x) >> S_PCIE_SPEED) & M_PCIE_SPEED)
-
-#define S_T5_PERSTTIMEOUT 7
-#define V_T5_PERSTTIMEOUT(x) ((x) << S_T5_PERSTTIMEOUT)
-#define F_T5_PERSTTIMEOUT V_T5_PERSTTIMEOUT(1U)
-
-#define S_T5_LTSSMENABLE 6
-#define V_T5_LTSSMENABLE(x) ((x) << S_T5_LTSSMENABLE)
-#define F_T5_LTSSMENABLE V_T5_LTSSMENABLE(1U)
-
-#define S_LTSSM 0
-#define M_LTSSM 0x3fU
-#define V_LTSSM(x) ((x) << S_LTSSM)
-#define G_LTSSM(x) (((x) >> S_LTSSM) & M_LTSSM)
-
-#define S_T6_LN0_AESTAT 27
-#define M_T6_LN0_AESTAT 0x7U
-#define V_T6_LN0_AESTAT(x) ((x) << S_T6_LN0_AESTAT)
-#define G_T6_LN0_AESTAT(x) (((x) >> S_T6_LN0_AESTAT) & M_T6_LN0_AESTAT)
-
-#define S_T6_LN0_AECMD 24
-#define M_T6_LN0_AECMD 0x7U
-#define V_T6_LN0_AECMD(x) ((x) << S_T6_LN0_AECMD)
-#define G_T6_LN0_AECMD(x) (((x) >> S_T6_LN0_AECMD) & M_T6_LN0_AECMD)
-
-#define S_T6_STATECFGINITF 16
-#define M_T6_STATECFGINITF 0xffU
-#define V_T6_STATECFGINITF(x) ((x) << S_T6_STATECFGINITF)
-#define G_T6_STATECFGINITF(x) (((x) >> S_T6_STATECFGINITF) & M_T6_STATECFGINITF)
-
-#define S_T6_STATECFGINIT 12
-#define M_T6_STATECFGINIT 0xfU
-#define V_T6_STATECFGINIT(x) ((x) << S_T6_STATECFGINIT)
-#define G_T6_STATECFGINIT(x) (((x) >> S_T6_STATECFGINIT) & M_T6_STATECFGINIT)
-
-#define S_PHY_STATUS 10
-#define V_PHY_STATUS(x) ((x) << S_PHY_STATUS)
-#define F_PHY_STATUS V_PHY_STATUS(1U)
-
-#define S_SPEED_PL 8
-#define M_SPEED_PL 0x3U
-#define V_SPEED_PL(x) ((x) << S_SPEED_PL)
-#define G_SPEED_PL(x) (((x) >> S_SPEED_PL) & M_SPEED_PL)
-
-#define S_PERSTTIMEOUT_PL 7
-#define V_PERSTTIMEOUT_PL(x) ((x) << S_PERSTTIMEOUT_PL)
-#define F_PERSTTIMEOUT_PL V_PERSTTIMEOUT_PL(1U)
-
-#define S_T6_LTSSMENABLE 6
-#define V_T6_LTSSMENABLE(x) ((x) << S_T6_LTSSMENABLE)
-#define F_T6_LTSSMENABLE V_T6_LTSSMENABLE(1U)
-
-#define A_PL_PCIE_CTL_STAT 0x19444
-
-#define S_PCIE_STATUS 16
-#define M_PCIE_STATUS 0xffffU
-#define V_PCIE_STATUS(x) ((x) << S_PCIE_STATUS)
-#define G_PCIE_STATUS(x) (((x) >> S_PCIE_STATUS) & M_PCIE_STATUS)
-
-#define S_PCIE_CONTROL 0
-#define M_PCIE_CONTROL 0xffffU
-#define V_PCIE_CONTROL(x) ((x) << S_PCIE_CONTROL)
-#define G_PCIE_CONTROL(x) (((x) >> S_PCIE_CONTROL) & M_PCIE_CONTROL)
-
-#define A_PL_SEMAPHORE_CTL 0x1944c
-
-#define S_LOCKSTATUS 16
-#define M_LOCKSTATUS 0xffU
-#define V_LOCKSTATUS(x) ((x) << S_LOCKSTATUS)
-#define G_LOCKSTATUS(x) (((x) >> S_LOCKSTATUS) & M_LOCKSTATUS)
-
-#define S_OWNEROVERRIDE 8
-#define V_OWNEROVERRIDE(x) ((x) << S_OWNEROVERRIDE)
-#define F_OWNEROVERRIDE V_OWNEROVERRIDE(1U)
-
-#define S_ENABLEPF 0
-#define M_ENABLEPF 0xffU
-#define V_ENABLEPF(x) ((x) << S_ENABLEPF)
-#define G_ENABLEPF(x) (((x) >> S_ENABLEPF) & M_ENABLEPF)
-
-#define A_PL_SEMAPHORE_LOCK 0x19450
-
-#define S_SEMLOCK 31
-#define V_SEMLOCK(x) ((x) << S_SEMLOCK)
-#define F_SEMLOCK V_SEMLOCK(1U)
-
-#define S_SEMSRCBUS 3
-#define M_SEMSRCBUS 0x3U
-#define V_SEMSRCBUS(x) ((x) << S_SEMSRCBUS)
-#define G_SEMSRCBUS(x) (((x) >> S_SEMSRCBUS) & M_SEMSRCBUS)
-
-#define S_SEMSRCPF 0
-#define M_SEMSRCPF 0x7U
-#define V_SEMSRCPF(x) ((x) << S_SEMSRCPF)
-#define G_SEMSRCPF(x) (((x) >> S_SEMSRCPF) & M_SEMSRCPF)
-
-#define A_PL_PF_ENABLE 0x19470
-
-#define S_PF_ENABLE 0
-#define M_PF_ENABLE 0xffU
-#define V_PF_ENABLE(x) ((x) << S_PF_ENABLE)
-#define G_PF_ENABLE(x) (((x) >> S_PF_ENABLE) & M_PF_ENABLE)
-
-#define A_PL_PORTX_MAP 0x19474
-
-#define S_MAP7 28
-#define M_MAP7 0x7U
-#define V_MAP7(x) ((x) << S_MAP7)
-#define G_MAP7(x) (((x) >> S_MAP7) & M_MAP7)
-
-#define S_MAP6 24
-#define M_MAP6 0x7U
-#define V_MAP6(x) ((x) << S_MAP6)
-#define G_MAP6(x) (((x) >> S_MAP6) & M_MAP6)
-
-#define S_MAP5 20
-#define M_MAP5 0x7U
-#define V_MAP5(x) ((x) << S_MAP5)
-#define G_MAP5(x) (((x) >> S_MAP5) & M_MAP5)
-
-#define S_MAP4 16
-#define M_MAP4 0x7U
-#define V_MAP4(x) ((x) << S_MAP4)
-#define G_MAP4(x) (((x) >> S_MAP4) & M_MAP4)
-
-#define S_MAP3 12
-#define M_MAP3 0x7U
-#define V_MAP3(x) ((x) << S_MAP3)
-#define G_MAP3(x) (((x) >> S_MAP3) & M_MAP3)
-
-#define S_MAP2 8
-#define M_MAP2 0x7U
-#define V_MAP2(x) ((x) << S_MAP2)
-#define G_MAP2(x) (((x) >> S_MAP2) & M_MAP2)
-
-#define S_MAP1 4
-#define M_MAP1 0x7U
-#define V_MAP1(x) ((x) << S_MAP1)
-#define G_MAP1(x) (((x) >> S_MAP1) & M_MAP1)
-
-#define S_MAP0 0
-#define M_MAP0 0x7U
-#define V_MAP0(x) ((x) << S_MAP0)
-#define G_MAP0(x) (((x) >> S_MAP0) & M_MAP0)
-
-#define A_PL_VF_SLICE_L 0x19490
-
-#define S_LIMITADDR 16
-#define M_LIMITADDR 0x3ffU
-#define V_LIMITADDR(x) ((x) << S_LIMITADDR)
-#define G_LIMITADDR(x) (((x) >> S_LIMITADDR) & M_LIMITADDR)
-
-#define S_SLICEBASEADDR 0
-#define M_SLICEBASEADDR 0x3ffU
-#define V_SLICEBASEADDR(x) ((x) << S_SLICEBASEADDR)
-#define G_SLICEBASEADDR(x) (((x) >> S_SLICEBASEADDR) & M_SLICEBASEADDR)
-
-#define A_PL_VF_SLICE_H 0x19494
-
-#define S_MODINDX 16
-#define M_MODINDX 0x7U
-#define V_MODINDX(x) ((x) << S_MODINDX)
-#define G_MODINDX(x) (((x) >> S_MODINDX) & M_MODINDX)
-
-#define S_MODOFFSET 0
-#define M_MODOFFSET 0x3ffU
-#define V_MODOFFSET(x) ((x) << S_MODOFFSET)
-#define G_MODOFFSET(x) (((x) >> S_MODOFFSET) & M_MODOFFSET)
-
-#define A_PL_FLR_VF_STATUS 0x194d0
-#define A_PL_FLR_PF_STATUS 0x194e0
-
-#define S_FLR_PF 0
-#define M_FLR_PF 0xffU
-#define V_FLR_PF(x) ((x) << S_FLR_PF)
-#define G_FLR_PF(x) (((x) >> S_FLR_PF) & M_FLR_PF)
-
-#define A_PL_TIMEOUT_CTL 0x194f0
-
-#define S_PL_TIMEOUT 0
-#define M_PL_TIMEOUT 0xffffU
-#define V_PL_TIMEOUT(x) ((x) << S_PL_TIMEOUT)
-#define G_PL_TIMEOUT(x) (((x) >> S_PL_TIMEOUT) & M_PL_TIMEOUT)
-
-#define S_PERRCAPTURE 16
-#define V_PERRCAPTURE(x) ((x) << S_PERRCAPTURE)
-#define F_PERRCAPTURE V_PERRCAPTURE(1U)
-
-#define A_PL_TIMEOUT_STATUS0 0x194f4
-
-#define S_PL_TOADDR 2
-#define M_PL_TOADDR 0xfffffffU
-#define V_PL_TOADDR(x) ((x) << S_PL_TOADDR)
-#define G_PL_TOADDR(x) (((x) >> S_PL_TOADDR) & M_PL_TOADDR)
-
-#define A_PL_TIMEOUT_STATUS1 0x194f8
-
-#define S_PL_TOVALID 31
-#define V_PL_TOVALID(x) ((x) << S_PL_TOVALID)
-#define F_PL_TOVALID V_PL_TOVALID(1U)
-
-#define S_WRITE 22
-#define V_WRITE(x) ((x) << S_WRITE)
-#define F_WRITE V_WRITE(1U)
-
-#define S_PL_TOBUS 20
-#define M_PL_TOBUS 0x3U
-#define V_PL_TOBUS(x) ((x) << S_PL_TOBUS)
-#define G_PL_TOBUS(x) (((x) >> S_PL_TOBUS) & M_PL_TOBUS)
-
-#define S_RGN 19
-#define V_RGN(x) ((x) << S_RGN)
-#define F_RGN V_RGN(1U)
-
-#define S_PL_TOPF 16
-#define M_PL_TOPF 0x7U
-#define V_PL_TOPF(x) ((x) << S_PL_TOPF)
-#define G_PL_TOPF(x) (((x) >> S_PL_TOPF) & M_PL_TOPF)
-
-#define S_PL_TORID 0
-#define M_PL_TORID 0xffffU
-#define V_PL_TORID(x) ((x) << S_PL_TORID)
-#define G_PL_TORID(x) (((x) >> S_PL_TORID) & M_PL_TORID)
-
-#define S_VALIDPERR 30
-#define V_VALIDPERR(x) ((x) << S_VALIDPERR)
-#define F_VALIDPERR V_VALIDPERR(1U)
-
-#define S_PL_TOVFID 0
-#define M_PL_TOVFID 0xffU
-#define V_PL_TOVFID(x) ((x) << S_PL_TOVFID)
-#define G_PL_TOVFID(x) (((x) >> S_PL_TOVFID) & M_PL_TOVFID)
-
-#define S_T6_PL_TOVFID 0
-#define M_T6_PL_TOVFID 0x1ffU
-#define V_T6_PL_TOVFID(x) ((x) << S_T6_PL_TOVFID)
-#define G_T6_PL_TOVFID(x) (((x) >> S_T6_PL_TOVFID) & M_T6_PL_TOVFID)
-
-#define A_PL_VFID_MAP 0x19800
-
-#define S_VFID_VLD 7
-#define V_VFID_VLD(x) ((x) << S_VFID_VLD)
-#define F_VFID_VLD V_VFID_VLD(1U)
-
-/* registers for module LE */
-#define LE_BASE_ADDR 0x19c00
-
-#define A_LE_BUF_CONFIG 0x19c00
-#define A_LE_DB_ID 0x19c00
-#define A_LE_DB_CONFIG 0x19c04
-
-#define S_TCAMCMDOVLAPEN 21
-#define V_TCAMCMDOVLAPEN(x) ((x) << S_TCAMCMDOVLAPEN)
-#define F_TCAMCMDOVLAPEN V_TCAMCMDOVLAPEN(1U)
-
-#define S_HASHEN 20
-#define V_HASHEN(x) ((x) << S_HASHEN)
-#define F_HASHEN V_HASHEN(1U)
-
-#define S_ASBOTHSRCHEN 18
-#define V_ASBOTHSRCHEN(x) ((x) << S_ASBOTHSRCHEN)
-#define F_ASBOTHSRCHEN V_ASBOTHSRCHEN(1U)
-
-#define S_ASLIPCOMPEN 17
-#define V_ASLIPCOMPEN(x) ((x) << S_ASLIPCOMPEN)
-#define F_ASLIPCOMPEN V_ASLIPCOMPEN(1U)
-
-#define S_BUILD 16
-#define V_BUILD(x) ((x) << S_BUILD)
-#define F_BUILD V_BUILD(1U)
-
-#define S_FILTEREN 11
-#define V_FILTEREN(x) ((x) << S_FILTEREN)
-#define F_FILTEREN V_FILTEREN(1U)
-
-#define S_SYNMODE 7
-#define M_SYNMODE 0x3U
-#define V_SYNMODE(x) ((x) << S_SYNMODE)
-#define G_SYNMODE(x) (((x) >> S_SYNMODE) & M_SYNMODE)
-
-#define S_LEBUSEN 5
-#define V_LEBUSEN(x) ((x) << S_LEBUSEN)
-#define F_LEBUSEN V_LEBUSEN(1U)
-
-#define S_ELOOKDUMEN 4
-#define V_ELOOKDUMEN(x) ((x) << S_ELOOKDUMEN)
-#define F_ELOOKDUMEN V_ELOOKDUMEN(1U)
-
-#define S_IPV4ONLYEN 3
-#define V_IPV4ONLYEN(x) ((x) << S_IPV4ONLYEN)
-#define F_IPV4ONLYEN V_IPV4ONLYEN(1U)
-
-#define S_MOSTCMDOEN 2
-#define V_MOSTCMDOEN(x) ((x) << S_MOSTCMDOEN)
-#define F_MOSTCMDOEN V_MOSTCMDOEN(1U)
-
-#define S_DELACTSYNOEN 1
-#define V_DELACTSYNOEN(x) ((x) << S_DELACTSYNOEN)
-#define F_DELACTSYNOEN V_DELACTSYNOEN(1U)
-
-#define S_CMDOVERLAPDIS 0
-#define V_CMDOVERLAPDIS(x) ((x) << S_CMDOVERLAPDIS)
-#define F_CMDOVERLAPDIS V_CMDOVERLAPDIS(1U)
-
-#define S_MASKCMDOLAPDIS 26
-#define V_MASKCMDOLAPDIS(x) ((x) << S_MASKCMDOLAPDIS)
-#define F_MASKCMDOLAPDIS V_MASKCMDOLAPDIS(1U)
-
-#define S_IPV4HASHSIZEEN 25
-#define V_IPV4HASHSIZEEN(x) ((x) << S_IPV4HASHSIZEEN)
-#define F_IPV4HASHSIZEEN V_IPV4HASHSIZEEN(1U)
-
-#define S_PROTOCOLMASKEN 24
-#define V_PROTOCOLMASKEN(x) ((x) << S_PROTOCOLMASKEN)
-#define F_PROTOCOLMASKEN V_PROTOCOLMASKEN(1U)
-
-#define S_TUPLESIZEEN 23
-#define V_TUPLESIZEEN(x) ((x) << S_TUPLESIZEEN)
-#define F_TUPLESIZEEN V_TUPLESIZEEN(1U)
-
-#define S_SRVRSRAMEN 22
-#define V_SRVRSRAMEN(x) ((x) << S_SRVRSRAMEN)
-#define F_SRVRSRAMEN V_SRVRSRAMEN(1U)
-
-#define S_ASBOTHSRCHENPR 19
-#define V_ASBOTHSRCHENPR(x) ((x) << S_ASBOTHSRCHENPR)
-#define F_ASBOTHSRCHENPR V_ASBOTHSRCHENPR(1U)
-
-#define S_POCLIPTID0 15
-#define V_POCLIPTID0(x) ((x) << S_POCLIPTID0)
-#define F_POCLIPTID0 V_POCLIPTID0(1U)
-
-#define S_TCAMARBOFF 14
-#define V_TCAMARBOFF(x) ((x) << S_TCAMARBOFF)
-#define F_TCAMARBOFF V_TCAMARBOFF(1U)
-
-#define S_ACCNTFULLEN 13
-#define V_ACCNTFULLEN(x) ((x) << S_ACCNTFULLEN)
-#define F_ACCNTFULLEN V_ACCNTFULLEN(1U)
-
-#define S_FILTERRWNOCLIP 12
-#define V_FILTERRWNOCLIP(x) ((x) << S_FILTERRWNOCLIP)
-#define F_FILTERRWNOCLIP V_FILTERRWNOCLIP(1U)
-
-#define S_CRCHASH 10
-#define V_CRCHASH(x) ((x) << S_CRCHASH)
-#define F_CRCHASH V_CRCHASH(1U)
-
-#define S_COMPTID 9
-#define V_COMPTID(x) ((x) << S_COMPTID)
-#define F_COMPTID V_COMPTID(1U)
-
-#define S_SINGLETHREAD 6
-#define V_SINGLETHREAD(x) ((x) << S_SINGLETHREAD)
-#define F_SINGLETHREAD V_SINGLETHREAD(1U)
-
-#define S_CHK_FUL_TUP_ZERO 27
-#define V_CHK_FUL_TUP_ZERO(x) ((x) << S_CHK_FUL_TUP_ZERO)
-#define F_CHK_FUL_TUP_ZERO V_CHK_FUL_TUP_ZERO(1U)
-
-#define S_PRI_HASH 26
-#define V_PRI_HASH(x) ((x) << S_PRI_HASH)
-#define F_PRI_HASH V_PRI_HASH(1U)
-
-#define S_EXTN_HASH_IPV4 25
-#define V_EXTN_HASH_IPV4(x) ((x) << S_EXTN_HASH_IPV4)
-#define F_EXTN_HASH_IPV4 V_EXTN_HASH_IPV4(1U)
-
-#define S_ASLIPCOMPEN_IPV4 18
-#define V_ASLIPCOMPEN_IPV4(x) ((x) << S_ASLIPCOMPEN_IPV4)
-#define F_ASLIPCOMPEN_IPV4 V_ASLIPCOMPEN_IPV4(1U)
-
-#define S_IGNR_TUP_ZERO 9
-#define V_IGNR_TUP_ZERO(x) ((x) << S_IGNR_TUP_ZERO)
-#define F_IGNR_TUP_ZERO V_IGNR_TUP_ZERO(1U)
-
-#define S_IGNR_LIP_ZERO 8
-#define V_IGNR_LIP_ZERO(x) ((x) << S_IGNR_LIP_ZERO)
-#define F_IGNR_LIP_ZERO V_IGNR_LIP_ZERO(1U)
-
-#define S_CLCAM_INIT_BUSY 7
-#define V_CLCAM_INIT_BUSY(x) ((x) << S_CLCAM_INIT_BUSY)
-#define F_CLCAM_INIT_BUSY V_CLCAM_INIT_BUSY(1U)
-
-#define S_CLCAM_INIT 6
-#define V_CLCAM_INIT(x) ((x) << S_CLCAM_INIT)
-#define F_CLCAM_INIT V_CLCAM_INIT(1U)
-
-#define S_MTCAM_INIT_BUSY 5
-#define V_MTCAM_INIT_BUSY(x) ((x) << S_MTCAM_INIT_BUSY)
-#define F_MTCAM_INIT_BUSY V_MTCAM_INIT_BUSY(1U)
-
-#define S_MTCAM_INIT 4
-#define V_MTCAM_INIT(x) ((x) << S_MTCAM_INIT)
-#define F_MTCAM_INIT V_MTCAM_INIT(1U)
-
-#define S_REGION_EN 0
-#define M_REGION_EN 0xfU
-#define V_REGION_EN(x) ((x) << S_REGION_EN)
-#define G_REGION_EN(x) (((x) >> S_REGION_EN) & M_REGION_EN)
-
-#define A_LE_MISC 0x19c08
-
-#define S_CMPUNVAIL 0
-#define M_CMPUNVAIL 0xfU
-#define V_CMPUNVAIL(x) ((x) << S_CMPUNVAIL)
-#define G_CMPUNVAIL(x) (((x) >> S_CMPUNVAIL) & M_CMPUNVAIL)
-
-#define S_SRAMDEEPSLEEP_STAT 11
-#define V_SRAMDEEPSLEEP_STAT(x) ((x) << S_SRAMDEEPSLEEP_STAT)
-#define F_SRAMDEEPSLEEP_STAT V_SRAMDEEPSLEEP_STAT(1U)
-
-#define S_TCAMDEEPSLEEP1_STAT 10
-#define V_TCAMDEEPSLEEP1_STAT(x) ((x) << S_TCAMDEEPSLEEP1_STAT)
-#define F_TCAMDEEPSLEEP1_STAT V_TCAMDEEPSLEEP1_STAT(1U)
-
-#define S_TCAMDEEPSLEEP0_STAT 9
-#define V_TCAMDEEPSLEEP0_STAT(x) ((x) << S_TCAMDEEPSLEEP0_STAT)
-#define F_TCAMDEEPSLEEP0_STAT V_TCAMDEEPSLEEP0_STAT(1U)
-
-#define S_SRAMDEEPSLEEP 8
-#define V_SRAMDEEPSLEEP(x) ((x) << S_SRAMDEEPSLEEP)
-#define F_SRAMDEEPSLEEP V_SRAMDEEPSLEEP(1U)
-
-#define S_TCAMDEEPSLEEP1 7
-#define V_TCAMDEEPSLEEP1(x) ((x) << S_TCAMDEEPSLEEP1)
-#define F_TCAMDEEPSLEEP1 V_TCAMDEEPSLEEP1(1U)
-
-#define S_TCAMDEEPSLEEP0 6
-#define V_TCAMDEEPSLEEP0(x) ((x) << S_TCAMDEEPSLEEP0)
-#define F_TCAMDEEPSLEEP0 V_TCAMDEEPSLEEP0(1U)
-
-#define S_SRVRAMCLKOFF 5
-#define V_SRVRAMCLKOFF(x) ((x) << S_SRVRAMCLKOFF)
-#define F_SRVRAMCLKOFF V_SRVRAMCLKOFF(1U)
-
-#define S_HASHCLKOFF 4
-#define V_HASHCLKOFF(x) ((x) << S_HASHCLKOFF)
-#define F_HASHCLKOFF V_HASHCLKOFF(1U)
-
-#define A_LE_DB_EXEC_CTRL 0x19c08
-
-#define S_TPDB_IF_PAUSE_ACK 10
-#define V_TPDB_IF_PAUSE_ACK(x) ((x) << S_TPDB_IF_PAUSE_ACK)
-#define F_TPDB_IF_PAUSE_ACK V_TPDB_IF_PAUSE_ACK(1U)
-
-#define S_TPDB_IF_PAUSE_REQ 9
-#define V_TPDB_IF_PAUSE_REQ(x) ((x) << S_TPDB_IF_PAUSE_REQ)
-#define F_TPDB_IF_PAUSE_REQ V_TPDB_IF_PAUSE_REQ(1U)
-
-#define S_ERRSTOP_EN 8
-#define V_ERRSTOP_EN(x) ((x) << S_ERRSTOP_EN)
-#define F_ERRSTOP_EN V_ERRSTOP_EN(1U)
-
-#define S_CMDLIMIT 0
-#define M_CMDLIMIT 0xffU
-#define V_CMDLIMIT(x) ((x) << S_CMDLIMIT)
-#define G_CMDLIMIT(x) (((x) >> S_CMDLIMIT) & M_CMDLIMIT)
-
-#define A_LE_DB_PS_CTRL 0x19c0c
-
-#define S_CLTCAMDEEPSLEEP_STAT 10
-#define V_CLTCAMDEEPSLEEP_STAT(x) ((x) << S_CLTCAMDEEPSLEEP_STAT)
-#define F_CLTCAMDEEPSLEEP_STAT V_CLTCAMDEEPSLEEP_STAT(1U)
-
-#define S_TCAMDEEPSLEEP_STAT 9
-#define V_TCAMDEEPSLEEP_STAT(x) ((x) << S_TCAMDEEPSLEEP_STAT)
-#define F_TCAMDEEPSLEEP_STAT V_TCAMDEEPSLEEP_STAT(1U)
-
-#define S_CLTCAMDEEPSLEEP 7
-#define V_CLTCAMDEEPSLEEP(x) ((x) << S_CLTCAMDEEPSLEEP)
-#define F_CLTCAMDEEPSLEEP V_CLTCAMDEEPSLEEP(1U)
-
-#define S_TCAMDEEPSLEEP 6
-#define V_TCAMDEEPSLEEP(x) ((x) << S_TCAMDEEPSLEEP)
-#define F_TCAMDEEPSLEEP V_TCAMDEEPSLEEP(1U)
-
-#define A_LE_DB_ROUTING_TABLE_INDEX 0x19c10
-
-#define S_RTINDX 7
-#define M_RTINDX 0x3fU
-#define V_RTINDX(x) ((x) << S_RTINDX)
-#define G_RTINDX(x) (((x) >> S_RTINDX) & M_RTINDX)
-
-#define A_LE_DB_ACTIVE_TABLE_START_INDEX 0x19c10
-
-#define S_ATINDX 0
-#define M_ATINDX 0xfffffU
-#define V_ATINDX(x) ((x) << S_ATINDX)
-#define G_ATINDX(x) (((x) >> S_ATINDX) & M_ATINDX)
-
-#define A_LE_DB_FILTER_TABLE_INDEX 0x19c14
-
-#define S_FTINDX 7
-#define M_FTINDX 0x3fU
-#define V_FTINDX(x) ((x) << S_FTINDX)
-#define G_FTINDX(x) (((x) >> S_FTINDX) & M_FTINDX)
-
-#define A_LE_DB_NORM_FILT_TABLE_START_INDEX 0x19c14
-
-#define S_NFTINDX 0
-#define M_NFTINDX 0xfffffU
-#define V_NFTINDX(x) ((x) << S_NFTINDX)
-#define G_NFTINDX(x) (((x) >> S_NFTINDX) & M_NFTINDX)
-
-#define A_LE_DB_SERVER_INDEX 0x19c18
-
-#define S_SRINDX 7
-#define M_SRINDX 0x3fU
-#define V_SRINDX(x) ((x) << S_SRINDX)
-#define G_SRINDX(x) (((x) >> S_SRINDX) & M_SRINDX)
-
-#define A_LE_DB_SRVR_START_INDEX 0x19c18
-
-#define S_T6_SRINDX 0
-#define M_T6_SRINDX 0xfffffU
-#define V_T6_SRINDX(x) ((x) << S_T6_SRINDX)
-#define G_T6_SRINDX(x) (((x) >> S_T6_SRINDX) & M_T6_SRINDX)
-
-#define A_LE_DB_CLIP_TABLE_INDEX 0x19c1c
-
-#define S_CLIPTINDX 7
-#define M_CLIPTINDX 0x3fU
-#define V_CLIPTINDX(x) ((x) << S_CLIPTINDX)
-#define G_CLIPTINDX(x) (((x) >> S_CLIPTINDX) & M_CLIPTINDX)
-
-#define A_LE_DB_HPRI_FILT_TABLE_START_INDEX 0x19c1c
-
-#define S_HFTINDX 0
-#define M_HFTINDX 0xfffffU
-#define V_HFTINDX(x) ((x) << S_HFTINDX)
-#define G_HFTINDX(x) (((x) >> S_HFTINDX) & M_HFTINDX)
-
-#define A_LE_DB_ACT_CNT_IPV4 0x19c20
-
-#define S_ACTCNTIPV4 0
-#define M_ACTCNTIPV4 0xfffffU
-#define V_ACTCNTIPV4(x) ((x) << S_ACTCNTIPV4)
-#define G_ACTCNTIPV4(x) (((x) >> S_ACTCNTIPV4) & M_ACTCNTIPV4)
-
-#define A_LE_DB_ACT_CNT_IPV6 0x19c24
-
-#define S_ACTCNTIPV6 0
-#define M_ACTCNTIPV6 0xfffffU
-#define V_ACTCNTIPV6(x) ((x) << S_ACTCNTIPV6)
-#define G_ACTCNTIPV6(x) (((x) >> S_ACTCNTIPV6) & M_ACTCNTIPV6)
-
-#define A_LE_DB_HASH_CONFIG 0x19c28
-
-#define S_HASHTIDSIZE 16
-#define M_HASHTIDSIZE 0x3fU
-#define V_HASHTIDSIZE(x) ((x) << S_HASHTIDSIZE)
-#define G_HASHTIDSIZE(x) (((x) >> S_HASHTIDSIZE) & M_HASHTIDSIZE)
-
-#define S_HASHSIZE 0
-#define M_HASHSIZE 0x3fU
-#define V_HASHSIZE(x) ((x) << S_HASHSIZE)
-#define G_HASHSIZE(x) (((x) >> S_HASHSIZE) & M_HASHSIZE)
-
-#define S_NUMHASHBKT 20
-#define M_NUMHASHBKT 0x1fU
-#define V_NUMHASHBKT(x) ((x) << S_NUMHASHBKT)
-#define G_NUMHASHBKT(x) (((x) >> S_NUMHASHBKT) & M_NUMHASHBKT)
-
-#define S_HASHTBLSIZE 3
-#define M_HASHTBLSIZE 0x1ffffU
-#define V_HASHTBLSIZE(x) ((x) << S_HASHTBLSIZE)
-#define G_HASHTBLSIZE(x) (((x) >> S_HASHTBLSIZE) & M_HASHTBLSIZE)
-
-#define A_LE_DB_HASH_TABLE_BASE 0x19c2c
-#define A_LE_DB_MIN_NUM_ACTV_TCAM_ENTRIES 0x19c2c
-
-#define S_MIN_ATCAM_ENTS 0
-#define M_MIN_ATCAM_ENTS 0xfffffU
-#define V_MIN_ATCAM_ENTS(x) ((x) << S_MIN_ATCAM_ENTS)
-#define G_MIN_ATCAM_ENTS(x) (((x) >> S_MIN_ATCAM_ENTS) & M_MIN_ATCAM_ENTS)
-
-#define A_LE_DB_HASH_TID_BASE 0x19c30
-#define A_LE_DB_HASH_TBL_BASE_ADDR 0x19c30
-
-#define S_HASHTBLADDR 4
-#define M_HASHTBLADDR 0xfffffffU
-#define V_HASHTBLADDR(x) ((x) << S_HASHTBLADDR)
-#define G_HASHTBLADDR(x) (((x) >> S_HASHTBLADDR) & M_HASHTBLADDR)
-
-#define A_LE_DB_SIZE 0x19c34
-#define A_LE_TCAM_SIZE 0x19c34
-
-#define S_TCAM_SIZE 0
-#define M_TCAM_SIZE 0x3U
-#define V_TCAM_SIZE(x) ((x) << S_TCAM_SIZE)
-#define G_TCAM_SIZE(x) (((x) >> S_TCAM_SIZE) & M_TCAM_SIZE)
-
-#define A_LE_DB_INT_ENABLE 0x19c38
-
-#define S_MSGSEL 27
-#define M_MSGSEL 0x1fU
-#define V_MSGSEL(x) ((x) << S_MSGSEL)
-#define G_MSGSEL(x) (((x) >> S_MSGSEL) & M_MSGSEL)
-
-#define S_REQQPARERR 16
-#define V_REQQPARERR(x) ((x) << S_REQQPARERR)
-#define F_REQQPARERR V_REQQPARERR(1U)
-
-#define S_UNKNOWNCMD 15
-#define V_UNKNOWNCMD(x) ((x) << S_UNKNOWNCMD)
-#define F_UNKNOWNCMD V_UNKNOWNCMD(1U)
-
-#define S_DROPFILTERHIT 13
-#define V_DROPFILTERHIT(x) ((x) << S_DROPFILTERHIT)
-#define F_DROPFILTERHIT V_DROPFILTERHIT(1U)
-
-#define S_FILTERHIT 12
-#define V_FILTERHIT(x) ((x) << S_FILTERHIT)
-#define F_FILTERHIT V_FILTERHIT(1U)
-
-#define S_SYNCOOKIEOFF 11
-#define V_SYNCOOKIEOFF(x) ((x) << S_SYNCOOKIEOFF)
-#define F_SYNCOOKIEOFF V_SYNCOOKIEOFF(1U)
-
-#define S_SYNCOOKIEBAD 10
-#define V_SYNCOOKIEBAD(x) ((x) << S_SYNCOOKIEBAD)
-#define F_SYNCOOKIEBAD V_SYNCOOKIEBAD(1U)
-
-#define S_SYNCOOKIE 9
-#define V_SYNCOOKIE(x) ((x) << S_SYNCOOKIE)
-#define F_SYNCOOKIE V_SYNCOOKIE(1U)
-
-#define S_NFASRCHFAIL 8
-#define V_NFASRCHFAIL(x) ((x) << S_NFASRCHFAIL)
-#define F_NFASRCHFAIL V_NFASRCHFAIL(1U)
-
-#define S_ACTRGNFULL 7
-#define V_ACTRGNFULL(x) ((x) << S_ACTRGNFULL)
-#define F_ACTRGNFULL V_ACTRGNFULL(1U)
-
-#define S_PARITYERR 6
-#define V_PARITYERR(x) ((x) << S_PARITYERR)
-#define F_PARITYERR V_PARITYERR(1U)
-
-#define S_LIPMISS 5
-#define V_LIPMISS(x) ((x) << S_LIPMISS)
-#define F_LIPMISS V_LIPMISS(1U)
-
-#define S_LIP0 4
-#define V_LIP0(x) ((x) << S_LIP0)
-#define F_LIP0 V_LIP0(1U)
-
-#define S_MISS 3
-#define V_MISS(x) ((x) << S_MISS)
-#define F_MISS V_MISS(1U)
-
-#define S_ROUTINGHIT 2
-#define V_ROUTINGHIT(x) ((x) << S_ROUTINGHIT)
-#define F_ROUTINGHIT V_ROUTINGHIT(1U)
-
-#define S_ACTIVEHIT 1
-#define V_ACTIVEHIT(x) ((x) << S_ACTIVEHIT)
-#define F_ACTIVEHIT V_ACTIVEHIT(1U)
-
-#define S_SERVERHIT 0
-#define V_SERVERHIT(x) ((x) << S_SERVERHIT)
-#define F_SERVERHIT V_SERVERHIT(1U)
-
-#define S_ACTCNTIPV6TZERO 21
-#define V_ACTCNTIPV6TZERO(x) ((x) << S_ACTCNTIPV6TZERO)
-#define F_ACTCNTIPV6TZERO V_ACTCNTIPV6TZERO(1U)
-
-#define S_ACTCNTIPV4TZERO 20
-#define V_ACTCNTIPV4TZERO(x) ((x) << S_ACTCNTIPV4TZERO)
-#define F_ACTCNTIPV4TZERO V_ACTCNTIPV4TZERO(1U)
-
-#define S_ACTCNTIPV6ZERO 19
-#define V_ACTCNTIPV6ZERO(x) ((x) << S_ACTCNTIPV6ZERO)
-#define F_ACTCNTIPV6ZERO V_ACTCNTIPV6ZERO(1U)
-
-#define S_ACTCNTIPV4ZERO 18
-#define V_ACTCNTIPV4ZERO(x) ((x) << S_ACTCNTIPV4ZERO)
-#define F_ACTCNTIPV4ZERO V_ACTCNTIPV4ZERO(1U)
-
-#define S_MARSPPARERR 17
-#define V_MARSPPARERR(x) ((x) << S_MARSPPARERR)
-#define F_MARSPPARERR V_MARSPPARERR(1U)
-
-#define S_VFPARERR 14
-#define V_VFPARERR(x) ((x) << S_VFPARERR)
-#define F_VFPARERR V_VFPARERR(1U)
-
-#define S_CLIPSUBERR 29
-#define V_CLIPSUBERR(x) ((x) << S_CLIPSUBERR)
-#define F_CLIPSUBERR V_CLIPSUBERR(1U)
-
-#define S_CLCAMFIFOERR 28
-#define V_CLCAMFIFOERR(x) ((x) << S_CLCAMFIFOERR)
-#define F_CLCAMFIFOERR V_CLCAMFIFOERR(1U)
-
-#define S_HASHTBLMEMCRCERR 27
-#define V_HASHTBLMEMCRCERR(x) ((x) << S_HASHTBLMEMCRCERR)
-#define F_HASHTBLMEMCRCERR V_HASHTBLMEMCRCERR(1U)
-
-#define S_CTCAMINVLDENT 26
-#define V_CTCAMINVLDENT(x) ((x) << S_CTCAMINVLDENT)
-#define F_CTCAMINVLDENT V_CTCAMINVLDENT(1U)
-
-#define S_TCAMINVLDENT 25
-#define V_TCAMINVLDENT(x) ((x) << S_TCAMINVLDENT)
-#define F_TCAMINVLDENT V_TCAMINVLDENT(1U)
-
-#define S_TOTCNTERR 24
-#define V_TOTCNTERR(x) ((x) << S_TOTCNTERR)
-#define F_TOTCNTERR V_TOTCNTERR(1U)
-
-#define S_CMDPRSRINTERR 23
-#define V_CMDPRSRINTERR(x) ((x) << S_CMDPRSRINTERR)
-#define F_CMDPRSRINTERR V_CMDPRSRINTERR(1U)
-
-#define S_CMDTIDERR 22
-#define V_CMDTIDERR(x) ((x) << S_CMDTIDERR)
-#define F_CMDTIDERR V_CMDTIDERR(1U)
-
-#define S_T6_ACTRGNFULL 21
-#define V_T6_ACTRGNFULL(x) ((x) << S_T6_ACTRGNFULL)
-#define F_T6_ACTRGNFULL V_T6_ACTRGNFULL(1U)
-
-#define S_T6_ACTCNTIPV6TZERO 20
-#define V_T6_ACTCNTIPV6TZERO(x) ((x) << S_T6_ACTCNTIPV6TZERO)
-#define F_T6_ACTCNTIPV6TZERO V_T6_ACTCNTIPV6TZERO(1U)
-
-#define S_T6_ACTCNTIPV4TZERO 19
-#define V_T6_ACTCNTIPV4TZERO(x) ((x) << S_T6_ACTCNTIPV4TZERO)
-#define F_T6_ACTCNTIPV4TZERO V_T6_ACTCNTIPV4TZERO(1U)
-
-#define S_T6_ACTCNTIPV6ZERO 18
-#define V_T6_ACTCNTIPV6ZERO(x) ((x) << S_T6_ACTCNTIPV6ZERO)
-#define F_T6_ACTCNTIPV6ZERO V_T6_ACTCNTIPV6ZERO(1U)
-
-#define S_T6_ACTCNTIPV4ZERO 17
-#define V_T6_ACTCNTIPV4ZERO(x) ((x) << S_T6_ACTCNTIPV4ZERO)
-#define F_T6_ACTCNTIPV4ZERO V_T6_ACTCNTIPV4ZERO(1U)
-
-#define S_MAIFWRINTPERR 16
-#define V_MAIFWRINTPERR(x) ((x) << S_MAIFWRINTPERR)
-#define F_MAIFWRINTPERR V_MAIFWRINTPERR(1U)
-
-#define S_HASHTBLMEMACCERR 15
-#define V_HASHTBLMEMACCERR(x) ((x) << S_HASHTBLMEMACCERR)
-#define F_HASHTBLMEMACCERR V_HASHTBLMEMACCERR(1U)
-
-#define S_TCAMCRCERR 14
-#define V_TCAMCRCERR(x) ((x) << S_TCAMCRCERR)
-#define F_TCAMCRCERR V_TCAMCRCERR(1U)
-
-#define S_TCAMINTPERR 13
-#define V_TCAMINTPERR(x) ((x) << S_TCAMINTPERR)
-#define F_TCAMINTPERR V_TCAMINTPERR(1U)
-
-#define S_VFSRAMPERR 12
-#define V_VFSRAMPERR(x) ((x) << S_VFSRAMPERR)
-#define F_VFSRAMPERR V_VFSRAMPERR(1U)
-
-#define S_SRVSRAMPERR 11
-#define V_SRVSRAMPERR(x) ((x) << S_SRVSRAMPERR)
-#define F_SRVSRAMPERR V_SRVSRAMPERR(1U)
-
-#define S_SSRAMINTPERR 10
-#define V_SSRAMINTPERR(x) ((x) << S_SSRAMINTPERR)
-#define F_SSRAMINTPERR V_SSRAMINTPERR(1U)
-
-#define S_CLCAMINTPERR 9
-#define V_CLCAMINTPERR(x) ((x) << S_CLCAMINTPERR)
-#define F_CLCAMINTPERR V_CLCAMINTPERR(1U)
-
-#define S_CLCAMCRCPARERR 8
-#define V_CLCAMCRCPARERR(x) ((x) << S_CLCAMCRCPARERR)
-#define F_CLCAMCRCPARERR V_CLCAMCRCPARERR(1U)
-
-#define S_HASHTBLACCFAIL 7
-#define V_HASHTBLACCFAIL(x) ((x) << S_HASHTBLACCFAIL)
-#define F_HASHTBLACCFAIL V_HASHTBLACCFAIL(1U)
-
-#define S_TCAMACCFAIL 6
-#define V_TCAMACCFAIL(x) ((x) << S_TCAMACCFAIL)
-#define F_TCAMACCFAIL V_TCAMACCFAIL(1U)
-
-#define S_SRVSRAMACCFAIL 5
-#define V_SRVSRAMACCFAIL(x) ((x) << S_SRVSRAMACCFAIL)
-#define F_SRVSRAMACCFAIL V_SRVSRAMACCFAIL(1U)
-
-#define S_CLIPTCAMACCFAIL 4
-#define V_CLIPTCAMACCFAIL(x) ((x) << S_CLIPTCAMACCFAIL)
-#define F_CLIPTCAMACCFAIL V_CLIPTCAMACCFAIL(1U)
-
-#define S_T6_UNKNOWNCMD 3
-#define V_T6_UNKNOWNCMD(x) ((x) << S_T6_UNKNOWNCMD)
-#define F_T6_UNKNOWNCMD V_T6_UNKNOWNCMD(1U)
-
-#define S_T6_LIP0 2
-#define V_T6_LIP0(x) ((x) << S_T6_LIP0)
-#define F_T6_LIP0 V_T6_LIP0(1U)
-
-#define S_T6_LIPMISS 1
-#define V_T6_LIPMISS(x) ((x) << S_T6_LIPMISS)
-#define F_T6_LIPMISS V_T6_LIPMISS(1U)
-
-#define S_PIPELINEERR 0
-#define V_PIPELINEERR(x) ((x) << S_PIPELINEERR)
-#define F_PIPELINEERR V_PIPELINEERR(1U)
-
-#define A_LE_DB_INT_CAUSE 0x19c3c
-
-#define S_T6_ACTRGNFULL 21
-#define V_T6_ACTRGNFULL(x) ((x) << S_T6_ACTRGNFULL)
-#define F_T6_ACTRGNFULL V_T6_ACTRGNFULL(1U)
-
-#define S_T6_ACTCNTIPV6TZERO 20
-#define V_T6_ACTCNTIPV6TZERO(x) ((x) << S_T6_ACTCNTIPV6TZERO)
-#define F_T6_ACTCNTIPV6TZERO V_T6_ACTCNTIPV6TZERO(1U)
-
-#define S_T6_ACTCNTIPV4TZERO 19
-#define V_T6_ACTCNTIPV4TZERO(x) ((x) << S_T6_ACTCNTIPV4TZERO)
-#define F_T6_ACTCNTIPV4TZERO V_T6_ACTCNTIPV4TZERO(1U)
-
-#define S_T6_ACTCNTIPV6ZERO 18
-#define V_T6_ACTCNTIPV6ZERO(x) ((x) << S_T6_ACTCNTIPV6ZERO)
-#define F_T6_ACTCNTIPV6ZERO V_T6_ACTCNTIPV6ZERO(1U)
-
-#define S_T6_ACTCNTIPV4ZERO 17
-#define V_T6_ACTCNTIPV4ZERO(x) ((x) << S_T6_ACTCNTIPV4ZERO)
-#define F_T6_ACTCNTIPV4ZERO V_T6_ACTCNTIPV4ZERO(1U)
-
-#define S_T6_UNKNOWNCMD 3
-#define V_T6_UNKNOWNCMD(x) ((x) << S_T6_UNKNOWNCMD)
-#define F_T6_UNKNOWNCMD V_T6_UNKNOWNCMD(1U)
-
-#define S_T6_LIP0 2
-#define V_T6_LIP0(x) ((x) << S_T6_LIP0)
-#define F_T6_LIP0 V_T6_LIP0(1U)
-
-#define S_T6_LIPMISS 1
-#define V_T6_LIPMISS(x) ((x) << S_T6_LIPMISS)
-#define F_T6_LIPMISS V_T6_LIPMISS(1U)
-
-#define A_LE_DB_INT_TID 0x19c40
-
-#define S_INTTID 0
-#define M_INTTID 0xfffffU
-#define V_INTTID(x) ((x) << S_INTTID)
-#define G_INTTID(x) (((x) >> S_INTTID) & M_INTTID)
-
-#define A_LE_DB_DBG_MATCH_CMD_IDX_MASK 0x19c40
-
-#define S_CMD_CMP_MASK 20
-#define M_CMD_CMP_MASK 0x1fU
-#define V_CMD_CMP_MASK(x) ((x) << S_CMD_CMP_MASK)
-#define G_CMD_CMP_MASK(x) (((x) >> S_CMD_CMP_MASK) & M_CMD_CMP_MASK)
-
-#define S_TID_CMP_MASK 0
-#define M_TID_CMP_MASK 0xfffffU
-#define V_TID_CMP_MASK(x) ((x) << S_TID_CMP_MASK)
-#define G_TID_CMP_MASK(x) (((x) >> S_TID_CMP_MASK) & M_TID_CMP_MASK)
-
-#define A_LE_DB_INT_PTID 0x19c44
-
-#define S_INTPTID 0
-#define M_INTPTID 0xfffffU
-#define V_INTPTID(x) ((x) << S_INTPTID)
-#define G_INTPTID(x) (((x) >> S_INTPTID) & M_INTPTID)
-
-#define A_LE_DB_DBG_MATCH_CMD_IDX_DATA 0x19c44
-
-#define S_CMD_CMP 20
-#define M_CMD_CMP 0x1fU
-#define V_CMD_CMP(x) ((x) << S_CMD_CMP)
-#define G_CMD_CMP(x) (((x) >> S_CMD_CMP) & M_CMD_CMP)
-
-#define S_TID_CMP 0
-#define M_TID_CMP 0xfffffU
-#define V_TID_CMP(x) ((x) << S_TID_CMP)
-#define G_TID_CMP(x) (((x) >> S_TID_CMP) & M_TID_CMP)
-
-#define A_LE_DB_INT_INDEX 0x19c48
-
-#define S_INTINDEX 0
-#define M_INTINDEX 0xfffffU
-#define V_INTINDEX(x) ((x) << S_INTINDEX)
-#define G_INTINDEX(x) (((x) >> S_INTINDEX) & M_INTINDEX)
-
-#define A_LE_DB_ERR_CMD_TID 0x19c48
-
-#define S_ERR_CID 22
-#define M_ERR_CID 0xffU
-#define V_ERR_CID(x) ((x) << S_ERR_CID)
-#define G_ERR_CID(x) (((x) >> S_ERR_CID) & M_ERR_CID)
-
-#define S_ERR_PROT 20
-#define M_ERR_PROT 0x3U
-#define V_ERR_PROT(x) ((x) << S_ERR_PROT)
-#define G_ERR_PROT(x) (((x) >> S_ERR_PROT) & M_ERR_PROT)
-
-#define S_ERR_TID 0
-#define M_ERR_TID 0xfffffU
-#define V_ERR_TID(x) ((x) << S_ERR_TID)
-#define G_ERR_TID(x) (((x) >> S_ERR_TID) & M_ERR_TID)
-
-#define A_LE_DB_INT_CMD 0x19c4c
-
-#define S_INTCMD 0
-#define M_INTCMD 0xfU
-#define V_INTCMD(x) ((x) << S_INTCMD)
-#define G_INTCMD(x) (((x) >> S_INTCMD) & M_INTCMD)
-
-#define A_LE_DB_MASK_IPV4 0x19c50
-#define A_LE_T5_DB_MASK_IPV4 0x19c50
-#define A_LE_DB_DBG_MATCH_DATA_MASK 0x19c50
-#define A_LE_DB_MAX_NUM_HASH_ENTRIES 0x19c70
-
-#define S_MAX_HASH_ENTS 0
-#define M_MAX_HASH_ENTS 0xfffffU
-#define V_MAX_HASH_ENTS(x) ((x) << S_MAX_HASH_ENTS)
-#define G_MAX_HASH_ENTS(x) (((x) >> S_MAX_HASH_ENTS) & M_MAX_HASH_ENTS)
-
-#define A_LE_DB_RSP_CODE_0 0x19c74
-
-#define S_SUCCESS 25
-#define M_SUCCESS 0x1fU
-#define V_SUCCESS(x) ((x) << S_SUCCESS)
-#define G_SUCCESS(x) (((x) >> S_SUCCESS) & M_SUCCESS)
-
-#define S_TCAM_ACTV_SUCC 20
-#define M_TCAM_ACTV_SUCC 0x1fU
-#define V_TCAM_ACTV_SUCC(x) ((x) << S_TCAM_ACTV_SUCC)
-#define G_TCAM_ACTV_SUCC(x) (((x) >> S_TCAM_ACTV_SUCC) & M_TCAM_ACTV_SUCC)
-
-#define S_HASH_ACTV_SUCC 15
-#define M_HASH_ACTV_SUCC 0x1fU
-#define V_HASH_ACTV_SUCC(x) ((x) << S_HASH_ACTV_SUCC)
-#define G_HASH_ACTV_SUCC(x) (((x) >> S_HASH_ACTV_SUCC) & M_HASH_ACTV_SUCC)
-
-#define S_TCAM_SRVR_HIT 10
-#define M_TCAM_SRVR_HIT 0x1fU
-#define V_TCAM_SRVR_HIT(x) ((x) << S_TCAM_SRVR_HIT)
-#define G_TCAM_SRVR_HIT(x) (((x) >> S_TCAM_SRVR_HIT) & M_TCAM_SRVR_HIT)
-
-#define S_SRAM_SRVR_HIT 5
-#define M_SRAM_SRVR_HIT 0x1fU
-#define V_SRAM_SRVR_HIT(x) ((x) << S_SRAM_SRVR_HIT)
-#define G_SRAM_SRVR_HIT(x) (((x) >> S_SRAM_SRVR_HIT) & M_SRAM_SRVR_HIT)
-
-#define S_TCAM_ACTV_HIT 0
-#define M_TCAM_ACTV_HIT 0x1fU
-#define V_TCAM_ACTV_HIT(x) ((x) << S_TCAM_ACTV_HIT)
-#define G_TCAM_ACTV_HIT(x) (((x) >> S_TCAM_ACTV_HIT) & M_TCAM_ACTV_HIT)
-
-#define A_LE_DB_RSP_CODE_1 0x19c78
-
-#define S_HASH_ACTV_HIT 25
-#define M_HASH_ACTV_HIT 0x1fU
-#define V_HASH_ACTV_HIT(x) ((x) << S_HASH_ACTV_HIT)
-#define G_HASH_ACTV_HIT(x) (((x) >> S_HASH_ACTV_HIT) & M_HASH_ACTV_HIT)
-
-#define S_T6_MISS 20
-#define M_T6_MISS 0x1fU
-#define V_T6_MISS(x) ((x) << S_T6_MISS)
-#define G_T6_MISS(x) (((x) >> S_T6_MISS) & M_T6_MISS)
-
-#define S_NORM_FILT_HIT 15
-#define M_NORM_FILT_HIT 0x1fU
-#define V_NORM_FILT_HIT(x) ((x) << S_NORM_FILT_HIT)
-#define G_NORM_FILT_HIT(x) (((x) >> S_NORM_FILT_HIT) & M_NORM_FILT_HIT)
-
-#define S_HPRI_FILT_HIT 10
-#define M_HPRI_FILT_HIT 0x1fU
-#define V_HPRI_FILT_HIT(x) ((x) << S_HPRI_FILT_HIT)
-#define G_HPRI_FILT_HIT(x) (((x) >> S_HPRI_FILT_HIT) & M_HPRI_FILT_HIT)
-
-#define S_ACTV_OPEN_ERR 5
-#define M_ACTV_OPEN_ERR 0x1fU
-#define V_ACTV_OPEN_ERR(x) ((x) << S_ACTV_OPEN_ERR)
-#define G_ACTV_OPEN_ERR(x) (((x) >> S_ACTV_OPEN_ERR) & M_ACTV_OPEN_ERR)
-
-#define S_ACTV_FULL_ERR 0
-#define M_ACTV_FULL_ERR 0x1fU
-#define V_ACTV_FULL_ERR(x) ((x) << S_ACTV_FULL_ERR)
-#define G_ACTV_FULL_ERR(x) (((x) >> S_ACTV_FULL_ERR) & M_ACTV_FULL_ERR)
-
-#define A_LE_DB_RSP_CODE_2 0x19c7c
-
-#define S_SRCH_RGN_HIT 25
-#define M_SRCH_RGN_HIT 0x1fU
-#define V_SRCH_RGN_HIT(x) ((x) << S_SRCH_RGN_HIT)
-#define G_SRCH_RGN_HIT(x) (((x) >> S_SRCH_RGN_HIT) & M_SRCH_RGN_HIT)
-
-#define S_CLIP_FAIL 20
-#define M_CLIP_FAIL 0x1fU
-#define V_CLIP_FAIL(x) ((x) << S_CLIP_FAIL)
-#define G_CLIP_FAIL(x) (((x) >> S_CLIP_FAIL) & M_CLIP_FAIL)
-
-#define S_LIP_ZERO_ERR 15
-#define M_LIP_ZERO_ERR 0x1fU
-#define V_LIP_ZERO_ERR(x) ((x) << S_LIP_ZERO_ERR)
-#define G_LIP_ZERO_ERR(x) (((x) >> S_LIP_ZERO_ERR) & M_LIP_ZERO_ERR)
-
-#define S_UNKNOWN_CMD 10
-#define M_UNKNOWN_CMD 0x1fU
-#define V_UNKNOWN_CMD(x) ((x) << S_UNKNOWN_CMD)
-#define G_UNKNOWN_CMD(x) (((x) >> S_UNKNOWN_CMD) & M_UNKNOWN_CMD)
-
-#define S_CMD_TID_ERR 5
-#define M_CMD_TID_ERR 0x1fU
-#define V_CMD_TID_ERR(x) ((x) << S_CMD_TID_ERR)
-#define G_CMD_TID_ERR(x) (((x) >> S_CMD_TID_ERR) & M_CMD_TID_ERR)
-
-#define S_INTERNAL_ERR 0
-#define M_INTERNAL_ERR 0x1fU
-#define V_INTERNAL_ERR(x) ((x) << S_INTERNAL_ERR)
-#define G_INTERNAL_ERR(x) (((x) >> S_INTERNAL_ERR) & M_INTERNAL_ERR)
-
-#define A_LE_DB_RSP_CODE_3 0x19c80
-
-#define S_SRAM_SRVR_HIT_ACTF 25
-#define M_SRAM_SRVR_HIT_ACTF 0x1fU
-#define V_SRAM_SRVR_HIT_ACTF(x) ((x) << S_SRAM_SRVR_HIT_ACTF)
-#define G_SRAM_SRVR_HIT_ACTF(x) (((x) >> S_SRAM_SRVR_HIT_ACTF) & M_SRAM_SRVR_HIT_ACTF)
-
-#define S_TCAM_SRVR_HIT_ACTF 20
-#define M_TCAM_SRVR_HIT_ACTF 0x1fU
-#define V_TCAM_SRVR_HIT_ACTF(x) ((x) << S_TCAM_SRVR_HIT_ACTF)
-#define G_TCAM_SRVR_HIT_ACTF(x) (((x) >> S_TCAM_SRVR_HIT_ACTF) & M_TCAM_SRVR_HIT_ACTF)
-
-#define S_INVLDRD 15
-#define M_INVLDRD 0x1fU
-#define V_INVLDRD(x) ((x) << S_INVLDRD)
-#define G_INVLDRD(x) (((x) >> S_INVLDRD) & M_INVLDRD)
-
-#define S_TUPLZERO 10
-#define M_TUPLZERO 0x1fU
-#define V_TUPLZERO(x) ((x) << S_TUPLZERO)
-#define G_TUPLZERO(x) (((x) >> S_TUPLZERO) & M_TUPLZERO)
-
-#define A_LE_DB_ACT_CNT_IPV4_TCAM 0x19c94
-#define A_LE_DB_ACT_CNT_IPV6_TCAM 0x19c98
-#define A_LE_ACT_CNT_THRSH 0x19c9c
-
-#define S_ACT_CNT_THRSH 0
-#define M_ACT_CNT_THRSH 0x1fffffU
-#define V_ACT_CNT_THRSH(x) ((x) << S_ACT_CNT_THRSH)
-#define G_ACT_CNT_THRSH(x) (((x) >> S_ACT_CNT_THRSH) & M_ACT_CNT_THRSH)
-
-#define A_LE_DB_MASK_IPV6 0x19ca0
-#define A_LE_DB_DBG_MATCH_DATA 0x19ca0
-#define A_LE_DB_REQ_RSP_CNT 0x19ce4
-
-#define S_T4_RSPCNT 16
-#define M_T4_RSPCNT 0xffffU
-#define V_T4_RSPCNT(x) ((x) << S_T4_RSPCNT)
-#define G_T4_RSPCNT(x) (((x) >> S_T4_RSPCNT) & M_T4_RSPCNT)
-
-#define S_T4_REQCNT 0
-#define M_T4_REQCNT 0xffffU
-#define V_T4_REQCNT(x) ((x) << S_T4_REQCNT)
-#define G_T4_REQCNT(x) (((x) >> S_T4_REQCNT) & M_T4_REQCNT)
-
-#define S_RSPCNTLE 16
-#define M_RSPCNTLE 0xffffU
-#define V_RSPCNTLE(x) ((x) << S_RSPCNTLE)
-#define G_RSPCNTLE(x) (((x) >> S_RSPCNTLE) & M_RSPCNTLE)
-
-#define S_REQCNTLE 0
-#define M_REQCNTLE 0xffffU
-#define V_REQCNTLE(x) ((x) << S_REQCNTLE)
-#define G_REQCNTLE(x) (((x) >> S_REQCNTLE) & M_REQCNTLE)
-
-#define A_LE_DB_DBGI_CONFIG 0x19cf0
-
-#define S_DBGICMDPERR 31
-#define V_DBGICMDPERR(x) ((x) << S_DBGICMDPERR)
-#define F_DBGICMDPERR V_DBGICMDPERR(1U)
-
-#define S_DBGICMDRANGE 22
-#define M_DBGICMDRANGE 0x7U
-#define V_DBGICMDRANGE(x) ((x) << S_DBGICMDRANGE)
-#define G_DBGICMDRANGE(x) (((x) >> S_DBGICMDRANGE) & M_DBGICMDRANGE)
-
-#define S_DBGICMDMSKTYPE 21
-#define V_DBGICMDMSKTYPE(x) ((x) << S_DBGICMDMSKTYPE)
-#define F_DBGICMDMSKTYPE V_DBGICMDMSKTYPE(1U)
-
-#define S_DBGICMDSEARCH 20
-#define V_DBGICMDSEARCH(x) ((x) << S_DBGICMDSEARCH)
-#define F_DBGICMDSEARCH V_DBGICMDSEARCH(1U)
-
-#define S_DBGICMDREAD 19
-#define V_DBGICMDREAD(x) ((x) << S_DBGICMDREAD)
-#define F_DBGICMDREAD V_DBGICMDREAD(1U)
-
-#define S_DBGICMDLEARN 18
-#define V_DBGICMDLEARN(x) ((x) << S_DBGICMDLEARN)
-#define F_DBGICMDLEARN V_DBGICMDLEARN(1U)
-
-#define S_DBGICMDERASE 17
-#define V_DBGICMDERASE(x) ((x) << S_DBGICMDERASE)
-#define F_DBGICMDERASE V_DBGICMDERASE(1U)
-
-#define S_DBGICMDIPV6 16
-#define V_DBGICMDIPV6(x) ((x) << S_DBGICMDIPV6)
-#define F_DBGICMDIPV6 V_DBGICMDIPV6(1U)
-
-#define S_DBGICMDTYPE 13
-#define M_DBGICMDTYPE 0x7U
-#define V_DBGICMDTYPE(x) ((x) << S_DBGICMDTYPE)
-#define G_DBGICMDTYPE(x) (((x) >> S_DBGICMDTYPE) & M_DBGICMDTYPE)
-
-#define S_DBGICMDACKERR 12
-#define V_DBGICMDACKERR(x) ((x) << S_DBGICMDACKERR)
-#define F_DBGICMDACKERR V_DBGICMDACKERR(1U)
-
-#define S_DBGICMDBUSY 3
-#define V_DBGICMDBUSY(x) ((x) << S_DBGICMDBUSY)
-#define F_DBGICMDBUSY V_DBGICMDBUSY(1U)
-
-#define S_DBGICMDSTRT 2
-#define V_DBGICMDSTRT(x) ((x) << S_DBGICMDSTRT)
-#define F_DBGICMDSTRT V_DBGICMDSTRT(1U)
-
-#define S_DBGICMDMODE 0
-#define M_DBGICMDMODE 0x3U
-#define V_DBGICMDMODE(x) ((x) << S_DBGICMDMODE)
-#define G_DBGICMDMODE(x) (((x) >> S_DBGICMDMODE) & M_DBGICMDMODE)
-
-#define S_DBGICMDMSKREAD 21
-#define V_DBGICMDMSKREAD(x) ((x) << S_DBGICMDMSKREAD)
-#define F_DBGICMDMSKREAD V_DBGICMDMSKREAD(1U)
-
-#define S_DBGICMDWRITE 17
-#define V_DBGICMDWRITE(x) ((x) << S_DBGICMDWRITE)
-#define F_DBGICMDWRITE V_DBGICMDWRITE(1U)
-
-#define A_LE_DB_DBGI_REQ_TCAM_CMD 0x19cf4
-
-#define S_DBGICMD 20
-#define M_DBGICMD 0xfU
-#define V_DBGICMD(x) ((x) << S_DBGICMD)
-#define G_DBGICMD(x) (((x) >> S_DBGICMD) & M_DBGICMD)
-
-#define S_DBGITINDEX 0
-#define M_DBGITINDEX 0xfffffU
-#define V_DBGITINDEX(x) ((x) << S_DBGITINDEX)
-#define G_DBGITINDEX(x) (((x) >> S_DBGITINDEX) & M_DBGITINDEX)
-
-#define A_LE_DB_DBGI_REQ_CMD 0x19cf4
-
-#define S_DBGITID 0
-#define M_DBGITID 0xfffffU
-#define V_DBGITID(x) ((x) << S_DBGITID)
-#define G_DBGITID(x) (((x) >> S_DBGITID) & M_DBGITID)
-
-#define A_LE_PERR_ENABLE 0x19cf8
-
-#define S_REQQUEUE 1
-#define V_REQQUEUE(x) ((x) << S_REQQUEUE)
-#define F_REQQUEUE V_REQQUEUE(1U)
-
-#define S_TCAM 0
-#define V_TCAM(x) ((x) << S_TCAM)
-#define F_TCAM V_TCAM(1U)
-
-#define S_MARSPPARERRLE 17
-#define V_MARSPPARERRLE(x) ((x) << S_MARSPPARERRLE)
-#define F_MARSPPARERRLE V_MARSPPARERRLE(1U)
-
-#define S_REQQUEUELE 16
-#define V_REQQUEUELE(x) ((x) << S_REQQUEUELE)
-#define F_REQQUEUELE V_REQQUEUELE(1U)
-
-#define S_VFPARERRLE 14
-#define V_VFPARERRLE(x) ((x) << S_VFPARERRLE)
-#define F_VFPARERRLE V_VFPARERRLE(1U)
-
-#define S_TCAMLE 6
-#define V_TCAMLE(x) ((x) << S_TCAMLE)
-#define F_TCAMLE V_TCAMLE(1U)
-
-#define S_BKCHKPERIOD 22
-#define M_BKCHKPERIOD 0x3ffU
-#define V_BKCHKPERIOD(x) ((x) << S_BKCHKPERIOD)
-#define G_BKCHKPERIOD(x) (((x) >> S_BKCHKPERIOD) & M_BKCHKPERIOD)
-
-#define S_TCAMBKCHKEN 21
-#define V_TCAMBKCHKEN(x) ((x) << S_TCAMBKCHKEN)
-#define F_TCAMBKCHKEN V_TCAMBKCHKEN(1U)
-
-#define S_T6_CLCAMFIFOERR 2
-#define V_T6_CLCAMFIFOERR(x) ((x) << S_T6_CLCAMFIFOERR)
-#define F_T6_CLCAMFIFOERR V_T6_CLCAMFIFOERR(1U)
-
-#define S_T6_HASHTBLMEMCRCERR 1
-#define V_T6_HASHTBLMEMCRCERR(x) ((x) << S_T6_HASHTBLMEMCRCERR)
-#define F_T6_HASHTBLMEMCRCERR V_T6_HASHTBLMEMCRCERR(1U)
-
-#define A_LE_SPARE 0x19cfc
-#define A_LE_DB_DBGI_REQ_DATA 0x19d00
-#define A_LE_DB_DBGI_REQ_MASK 0x19d50
-#define A_LE_DB_DBGI_RSP_STATUS 0x19d94
-
-#define S_DBGIRSPINDEX 12
-#define M_DBGIRSPINDEX 0xfffffU
-#define V_DBGIRSPINDEX(x) ((x) << S_DBGIRSPINDEX)
-#define G_DBGIRSPINDEX(x) (((x) >> S_DBGIRSPINDEX) & M_DBGIRSPINDEX)
-
-#define S_DBGIRSPMSG 8
-#define M_DBGIRSPMSG 0xfU
-#define V_DBGIRSPMSG(x) ((x) << S_DBGIRSPMSG)
-#define G_DBGIRSPMSG(x) (((x) >> S_DBGIRSPMSG) & M_DBGIRSPMSG)
-
-#define S_DBGIRSPMSGVLD 7
-#define V_DBGIRSPMSGVLD(x) ((x) << S_DBGIRSPMSGVLD)
-#define F_DBGIRSPMSGVLD V_DBGIRSPMSGVLD(1U)
-
-#define S_DBGIRSPMHIT 2
-#define V_DBGIRSPMHIT(x) ((x) << S_DBGIRSPMHIT)
-#define F_DBGIRSPMHIT V_DBGIRSPMHIT(1U)
-
-#define S_DBGIRSPHIT 1
-#define V_DBGIRSPHIT(x) ((x) << S_DBGIRSPHIT)
-#define F_DBGIRSPHIT V_DBGIRSPHIT(1U)
-
-#define S_DBGIRSPVALID 0
-#define V_DBGIRSPVALID(x) ((x) << S_DBGIRSPVALID)
-#define F_DBGIRSPVALID V_DBGIRSPVALID(1U)
-
-#define S_DBGIRSPTID 12
-#define M_DBGIRSPTID 0xfffffU
-#define V_DBGIRSPTID(x) ((x) << S_DBGIRSPTID)
-#define G_DBGIRSPTID(x) (((x) >> S_DBGIRSPTID) & M_DBGIRSPTID)
-
-#define S_DBGIRSPLEARN 2
-#define V_DBGIRSPLEARN(x) ((x) << S_DBGIRSPLEARN)
-#define F_DBGIRSPLEARN V_DBGIRSPLEARN(1U)
-
-#define A_LE_DBG_SEL 0x19d98
-#define A_LE_DB_DBGI_RSP_DATA 0x19da0
-#define A_LE_DB_DBGI_RSP_LAST_CMD 0x19de4
-
-#define S_LASTCMDB 16
-#define M_LASTCMDB 0x7ffU
-#define V_LASTCMDB(x) ((x) << S_LASTCMDB)
-#define G_LASTCMDB(x) (((x) >> S_LASTCMDB) & M_LASTCMDB)
-
-#define S_LASTCMDA 0
-#define M_LASTCMDA 0x7ffU
-#define V_LASTCMDA(x) ((x) << S_LASTCMDA)
-#define G_LASTCMDA(x) (((x) >> S_LASTCMDA) & M_LASTCMDA)
-
-#define A_LE_DB_DROP_FILTER_ENTRY 0x19de8
-
-#define S_DROPFILTEREN 31
-#define V_DROPFILTEREN(x) ((x) << S_DROPFILTEREN)
-#define F_DROPFILTEREN V_DROPFILTEREN(1U)
-
-#define S_DROPFILTERCLEAR 17
-#define V_DROPFILTERCLEAR(x) ((x) << S_DROPFILTERCLEAR)
-#define F_DROPFILTERCLEAR V_DROPFILTERCLEAR(1U)
-
-#define S_DROPFILTERSET 16
-#define V_DROPFILTERSET(x) ((x) << S_DROPFILTERSET)
-#define F_DROPFILTERSET V_DROPFILTERSET(1U)
-
-#define S_DROPFILTERFIDX 0
-#define M_DROPFILTERFIDX 0x1fffU
-#define V_DROPFILTERFIDX(x) ((x) << S_DROPFILTERFIDX)
-#define G_DROPFILTERFIDX(x) (((x) >> S_DROPFILTERFIDX) & M_DROPFILTERFIDX)
-
-#define A_LE_DB_PTID_SVRBASE 0x19df0
-
-#define S_SVRBASE_ADDR 2
-#define M_SVRBASE_ADDR 0x3ffffU
-#define V_SVRBASE_ADDR(x) ((x) << S_SVRBASE_ADDR)
-#define G_SVRBASE_ADDR(x) (((x) >> S_SVRBASE_ADDR) & M_SVRBASE_ADDR)
-
-#define A_LE_DB_TCAM_TID_BASE 0x19df0
-
-#define S_TCAM_TID_BASE 0
-#define M_TCAM_TID_BASE 0xfffffU
-#define V_TCAM_TID_BASE(x) ((x) << S_TCAM_TID_BASE)
-#define G_TCAM_TID_BASE(x) (((x) >> S_TCAM_TID_BASE) & M_TCAM_TID_BASE)
-
-#define A_LE_DB_FTID_FLTRBASE 0x19df4
-
-#define S_FLTRBASE_ADDR 2
-#define M_FLTRBASE_ADDR 0x3ffffU
-#define V_FLTRBASE_ADDR(x) ((x) << S_FLTRBASE_ADDR)
-#define G_FLTRBASE_ADDR(x) (((x) >> S_FLTRBASE_ADDR) & M_FLTRBASE_ADDR)
-
-#define A_LE_DB_CLCAM_TID_BASE 0x19df4
-
-#define S_CLCAM_TID_BASE 0
-#define M_CLCAM_TID_BASE 0xfffffU
-#define V_CLCAM_TID_BASE(x) ((x) << S_CLCAM_TID_BASE)
-#define G_CLCAM_TID_BASE(x) (((x) >> S_CLCAM_TID_BASE) & M_CLCAM_TID_BASE)
-
-#define A_LE_DB_TID_HASHBASE 0x19df8
-
-#define S_HASHBASE_ADDR 2
-#define M_HASHBASE_ADDR 0xfffffU
-#define V_HASHBASE_ADDR(x) ((x) << S_HASHBASE_ADDR)
-#define G_HASHBASE_ADDR(x) (((x) >> S_HASHBASE_ADDR) & M_HASHBASE_ADDR)
-
-#define A_T6_LE_DB_HASH_TID_BASE 0x19df8
-
-#define S_HASH_TID_BASE 0
-#define M_HASH_TID_BASE 0xfffffU
-#define V_HASH_TID_BASE(x) ((x) << S_HASH_TID_BASE)
-#define G_HASH_TID_BASE(x) (((x) >> S_HASH_TID_BASE) & M_HASH_TID_BASE)
-
-#define A_LE_PERR_INJECT 0x19dfc
-
-#define S_LEMEMSEL 1
-#define M_LEMEMSEL 0x7U
-#define V_LEMEMSEL(x) ((x) << S_LEMEMSEL)
-#define G_LEMEMSEL(x) (((x) >> S_LEMEMSEL) & M_LEMEMSEL)
-
-#define A_LE_DB_SSRAM_TID_BASE 0x19dfc
-
-#define S_SSRAM_TID_BASE 0
-#define M_SSRAM_TID_BASE 0xfffffU
-#define V_SSRAM_TID_BASE(x) ((x) << S_SSRAM_TID_BASE)
-#define G_SSRAM_TID_BASE(x) (((x) >> S_SSRAM_TID_BASE) & M_SSRAM_TID_BASE)
-
-#define A_LE_DB_ACTIVE_MASK_IPV4 0x19e00
-#define A_LE_T5_DB_ACTIVE_MASK_IPV4 0x19e00
-#define A_LE_DB_ACTIVE_MASK_IPV6 0x19e50
-#define A_LE_HASH_MASK_GEN_IPV4 0x19ea0
-#define A_LE_HASH_MASK_GEN_IPV4T5 0x19ea0
-#define A_LE_HASH_MASK_GEN_IPV6 0x19eb0
-#define A_LE_HASH_MASK_GEN_IPV6T5 0x19eb4
-#define A_T6_LE_HASH_MASK_GEN_IPV6T5 0x19ec4
-#define A_LE_HASH_MASK_CMP_IPV4 0x19ee0
-#define A_LE_HASH_MASK_CMP_IPV4T5 0x19ee4
-#define A_LE_DB_PSV_FILTER_MASK_TUP_IPV4 0x19ee4
-#define A_LE_HASH_MASK_CMP_IPV6 0x19ef0
-#define A_LE_DB_PSV_FILTER_MASK_FLT_IPV4 0x19ef0
-#define A_LE_HASH_MASK_CMP_IPV6T5 0x19ef8
-#define A_LE_DB_PSV_FILTER_MASK_TUP_IPV6 0x19f04
-#define A_LE_DEBUG_LA_CONFIG 0x19f20
-#define A_LE_REQ_DEBUG_LA_DATA 0x19f24
-#define A_LE_REQ_DEBUG_LA_WRPTR 0x19f28
-#define A_LE_DB_PSV_FILTER_MASK_FLT_IPV6 0x19f28
-#define A_LE_RSP_DEBUG_LA_DATA 0x19f2c
-#define A_LE_RSP_DEBUG_LA_WRPTR 0x19f30
-#define A_LE_DEBUG_LA_SELECTOR 0x19f34
-#define A_LE_SRVR_SRAM_INIT 0x19f34
-
-#define S_SRVRSRAMBASE 2
-#define M_SRVRSRAMBASE 0xfffffU
-#define V_SRVRSRAMBASE(x) ((x) << S_SRVRSRAMBASE)
-#define G_SRVRSRAMBASE(x) (((x) >> S_SRVRSRAMBASE) & M_SRVRSRAMBASE)
-
-#define S_SRVRINITBUSY 1
-#define V_SRVRINITBUSY(x) ((x) << S_SRVRINITBUSY)
-#define F_SRVRINITBUSY V_SRVRINITBUSY(1U)
-
-#define S_SRVRINIT 0
-#define V_SRVRINIT(x) ((x) << S_SRVRINIT)
-#define F_SRVRINIT V_SRVRINIT(1U)
-
-#define A_LE_DB_SRVR_SRAM_CONFIG 0x19f34
-
-#define S_PRI_HFILT 4
-#define V_PRI_HFILT(x) ((x) << S_PRI_HFILT)
-#define F_PRI_HFILT V_PRI_HFILT(1U)
-
-#define S_PRI_SRVR 3
-#define V_PRI_SRVR(x) ((x) << S_PRI_SRVR)
-#define F_PRI_SRVR V_PRI_SRVR(1U)
-
-#define S_PRI_FILT 2
-#define V_PRI_FILT(x) ((x) << S_PRI_FILT)
-#define F_PRI_FILT V_PRI_FILT(1U)
-
-#define A_LE_DEBUG_LA_CAPTURED_DATA 0x19f38
-#define A_LE_SRVR_VF_SRCH_TABLE 0x19f38
-
-#define S_RDWR 21
-#define V_RDWR(x) ((x) << S_RDWR)
-#define F_RDWR V_RDWR(1U)
-
-#define S_VFINDEX 14
-#define M_VFINDEX 0x7fU
-#define V_VFINDEX(x) ((x) << S_VFINDEX)
-#define G_VFINDEX(x) (((x) >> S_VFINDEX) & M_VFINDEX)
-
-#define S_SRCHHADDR 7
-#define M_SRCHHADDR 0x7fU
-#define V_SRCHHADDR(x) ((x) << S_SRCHHADDR)
-#define G_SRCHHADDR(x) (((x) >> S_SRCHHADDR) & M_SRCHHADDR)
-
-#define S_SRCHLADDR 0
-#define M_SRCHLADDR 0x7fU
-#define V_SRCHLADDR(x) ((x) << S_SRCHLADDR)
-#define G_SRCHLADDR(x) (((x) >> S_SRCHLADDR) & M_SRCHLADDR)
-
-#define A_LE_DB_SRVR_VF_SRCH_TABLE_CTRL 0x19f38
-
-#define S_VFLUTBUSY 10
-#define V_VFLUTBUSY(x) ((x) << S_VFLUTBUSY)
-#define F_VFLUTBUSY V_VFLUTBUSY(1U)
-
-#define S_VFLUTSTART 9
-#define V_VFLUTSTART(x) ((x) << S_VFLUTSTART)
-#define F_VFLUTSTART V_VFLUTSTART(1U)
-
-#define S_T6_RDWR 8
-#define V_T6_RDWR(x) ((x) << S_T6_RDWR)
-#define F_T6_RDWR V_T6_RDWR(1U)
-
-#define S_T6_VFINDEX 0
-#define M_T6_VFINDEX 0xffU
-#define V_T6_VFINDEX(x) ((x) << S_T6_VFINDEX)
-#define G_T6_VFINDEX(x) (((x) >> S_T6_VFINDEX) & M_T6_VFINDEX)
-
-#define A_LE_MA_DEBUG_LA_DATA 0x19f3c
-#define A_LE_DB_SRVR_VF_SRCH_TABLE_DATA 0x19f3c
-
-#define S_T6_SRCHHADDR 12
-#define M_T6_SRCHHADDR 0xfffU
-#define V_T6_SRCHHADDR(x) ((x) << S_T6_SRCHHADDR)
-#define G_T6_SRCHHADDR(x) (((x) >> S_T6_SRCHHADDR) & M_T6_SRCHHADDR)
-
-#define S_T6_SRCHLADDR 0
-#define M_T6_SRCHLADDR 0xfffU
-#define V_T6_SRCHLADDR(x) ((x) << S_T6_SRCHLADDR)
-#define G_T6_SRCHLADDR(x) (((x) >> S_T6_SRCHLADDR) & M_T6_SRCHLADDR)
-
-#define A_LE_RSP_DEBUG_LA_HASH_WRPTR 0x19f40
-#define A_LE_DB_SECOND_ACTIVE_MASK_IPV4 0x19f40
-#define A_LE_HASH_DEBUG_LA_DATA 0x19f44
-#define A_LE_RSP_DEBUG_LA_TCAM_WRPTR 0x19f48
-#define A_LE_TCAM_DEBUG_LA_DATA 0x19f4c
-#define A_LE_DB_SECOND_GEN_HASH_MASK_IPV4 0x19f90
-#define A_LE_DB_SECOND_CMP_HASH_MASK_IPV4 0x19fa4
-#define A_LE_HASH_COLLISION 0x19fc4
-#define A_LE_GLOBAL_COLLISION 0x19fc8
-#define A_LE_FULL_CNT_COLLISION 0x19fcc
-#define A_LE_DEBUG_LA_CONFIGT5 0x19fd0
-#define A_LE_REQ_DEBUG_LA_DATAT5 0x19fd4
-#define A_LE_REQ_DEBUG_LA_WRPTRT5 0x19fd8
-#define A_LE_RSP_DEBUG_LA_DATAT5 0x19fdc
-#define A_LE_RSP_DEBUG_LA_WRPTRT5 0x19fe0
-#define A_LE_DEBUG_LA_SEL_DATA 0x19fe4
-
-/* registers for module NCSI */
-#define NCSI_BASE_ADDR 0x1a000
-
-#define A_NCSI_PORT_CFGREG 0x1a000
-
-#define S_WIREEN 28
-#define M_WIREEN 0xfU
-#define V_WIREEN(x) ((x) << S_WIREEN)
-#define G_WIREEN(x) (((x) >> S_WIREEN) & M_WIREEN)
-
-#define S_STRP_CRC 24
-#define M_STRP_CRC 0xfU
-#define V_STRP_CRC(x) ((x) << S_STRP_CRC)
-#define G_STRP_CRC(x) (((x) >> S_STRP_CRC) & M_STRP_CRC)
-
-#define S_RX_HALT 22
-#define V_RX_HALT(x) ((x) << S_RX_HALT)
-#define F_RX_HALT V_RX_HALT(1U)
-
-#define S_FLUSH_RX_FIFO 21
-#define V_FLUSH_RX_FIFO(x) ((x) << S_FLUSH_RX_FIFO)
-#define F_FLUSH_RX_FIFO V_FLUSH_RX_FIFO(1U)
-
-#define S_HW_ARB_EN 20
-#define V_HW_ARB_EN(x) ((x) << S_HW_ARB_EN)
-#define F_HW_ARB_EN V_HW_ARB_EN(1U)
-
-#define S_SOFT_PKG_SEL 19
-#define V_SOFT_PKG_SEL(x) ((x) << S_SOFT_PKG_SEL)
-#define F_SOFT_PKG_SEL V_SOFT_PKG_SEL(1U)
-
-#define S_ERR_DISCARD_EN 18
-#define V_ERR_DISCARD_EN(x) ((x) << S_ERR_DISCARD_EN)
-#define F_ERR_DISCARD_EN V_ERR_DISCARD_EN(1U)
-
-#define S_MAX_PKT_SIZE 4
-#define M_MAX_PKT_SIZE 0x3fffU
-#define V_MAX_PKT_SIZE(x) ((x) << S_MAX_PKT_SIZE)
-#define G_MAX_PKT_SIZE(x) (((x) >> S_MAX_PKT_SIZE) & M_MAX_PKT_SIZE)
-
-#define S_RX_BYTE_SWAP 3
-#define V_RX_BYTE_SWAP(x) ((x) << S_RX_BYTE_SWAP)
-#define F_RX_BYTE_SWAP V_RX_BYTE_SWAP(1U)
-
-#define S_TX_BYTE_SWAP 2
-#define V_TX_BYTE_SWAP(x) ((x) << S_TX_BYTE_SWAP)
-#define F_TX_BYTE_SWAP V_TX_BYTE_SWAP(1U)
-
-#define A_NCSI_RST_CTRL 0x1a004
-
-#define S_MAC_REF_RST 2
-#define V_MAC_REF_RST(x) ((x) << S_MAC_REF_RST)
-#define F_MAC_REF_RST V_MAC_REF_RST(1U)
-
-#define S_MAC_RX_RST 1
-#define V_MAC_RX_RST(x) ((x) << S_MAC_RX_RST)
-#define F_MAC_RX_RST V_MAC_RX_RST(1U)
-
-#define S_MAC_TX_RST 0
-#define V_MAC_TX_RST(x) ((x) << S_MAC_TX_RST)
-#define F_MAC_TX_RST V_MAC_TX_RST(1U)
-
-#define A_NCSI_CH0_SADDR_LOW 0x1a010
-#define A_NCSI_CH0_SADDR_HIGH 0x1a014
-
-#define S_CHO_SADDR_EN 31
-#define V_CHO_SADDR_EN(x) ((x) << S_CHO_SADDR_EN)
-#define F_CHO_SADDR_EN V_CHO_SADDR_EN(1U)
-
-#define S_CH0_SADDR_HIGH 0
-#define M_CH0_SADDR_HIGH 0xffffU
-#define V_CH0_SADDR_HIGH(x) ((x) << S_CH0_SADDR_HIGH)
-#define G_CH0_SADDR_HIGH(x) (((x) >> S_CH0_SADDR_HIGH) & M_CH0_SADDR_HIGH)
-
-#define A_NCSI_CH1_SADDR_LOW 0x1a018
-#define A_NCSI_CH1_SADDR_HIGH 0x1a01c
-
-#define S_CH1_SADDR_EN 31
-#define V_CH1_SADDR_EN(x) ((x) << S_CH1_SADDR_EN)
-#define F_CH1_SADDR_EN V_CH1_SADDR_EN(1U)
-
-#define S_CH1_SADDR_HIGH 0
-#define M_CH1_SADDR_HIGH 0xffffU
-#define V_CH1_SADDR_HIGH(x) ((x) << S_CH1_SADDR_HIGH)
-#define G_CH1_SADDR_HIGH(x) (((x) >> S_CH1_SADDR_HIGH) & M_CH1_SADDR_HIGH)
-
-#define A_NCSI_CH2_SADDR_LOW 0x1a020
-#define A_NCSI_CH2_SADDR_HIGH 0x1a024
-
-#define S_CH2_SADDR_EN 31
-#define V_CH2_SADDR_EN(x) ((x) << S_CH2_SADDR_EN)
-#define F_CH2_SADDR_EN V_CH2_SADDR_EN(1U)
-
-#define S_CH2_SADDR_HIGH 0
-#define M_CH2_SADDR_HIGH 0xffffU
-#define V_CH2_SADDR_HIGH(x) ((x) << S_CH2_SADDR_HIGH)
-#define G_CH2_SADDR_HIGH(x) (((x) >> S_CH2_SADDR_HIGH) & M_CH2_SADDR_HIGH)
-
-#define A_NCSI_CH3_SADDR_LOW 0x1a028
-#define A_NCSI_CH3_SADDR_HIGH 0x1a02c
-
-#define S_CH3_SADDR_EN 31
-#define V_CH3_SADDR_EN(x) ((x) << S_CH3_SADDR_EN)
-#define F_CH3_SADDR_EN V_CH3_SADDR_EN(1U)
-
-#define S_CH3_SADDR_HIGH 0
-#define M_CH3_SADDR_HIGH 0xffffU
-#define V_CH3_SADDR_HIGH(x) ((x) << S_CH3_SADDR_HIGH)
-#define G_CH3_SADDR_HIGH(x) (((x) >> S_CH3_SADDR_HIGH) & M_CH3_SADDR_HIGH)
-
-#define A_NCSI_WORK_REQHDR_0 0x1a030
-#define A_NCSI_WORK_REQHDR_1 0x1a034
-#define A_NCSI_WORK_REQHDR_2 0x1a038
-#define A_NCSI_WORK_REQHDR_3 0x1a03c
-#define A_NCSI_MPS_HDR_LO 0x1a040
-#define A_NCSI_MPS_HDR_HI 0x1a044
-#define A_NCSI_CTL 0x1a048
-
-#define S_STRIP_OVLAN 3
-#define V_STRIP_OVLAN(x) ((x) << S_STRIP_OVLAN)
-#define F_STRIP_OVLAN V_STRIP_OVLAN(1U)
-
-#define S_BMC_DROP_NON_BC 2
-#define V_BMC_DROP_NON_BC(x) ((x) << S_BMC_DROP_NON_BC)
-#define F_BMC_DROP_NON_BC V_BMC_DROP_NON_BC(1U)
-
-#define S_BMC_RX_FWD_ALL 1
-#define V_BMC_RX_FWD_ALL(x) ((x) << S_BMC_RX_FWD_ALL)
-#define F_BMC_RX_FWD_ALL V_BMC_RX_FWD_ALL(1U)
-
-#define S_FWD_BMC 0
-#define V_FWD_BMC(x) ((x) << S_FWD_BMC)
-#define F_FWD_BMC V_FWD_BMC(1U)
-
-#define A_NCSI_NCSI_ETYPE 0x1a04c
-
-#define S_NCSI_ETHERTYPE 0
-#define M_NCSI_ETHERTYPE 0xffffU
-#define V_NCSI_ETHERTYPE(x) ((x) << S_NCSI_ETHERTYPE)
-#define G_NCSI_ETHERTYPE(x) (((x) >> S_NCSI_ETHERTYPE) & M_NCSI_ETHERTYPE)
-
-#define A_NCSI_RX_FIFO_CNT 0x1a050
-
-#define S_NCSI_RXFIFO_CNT 0
-#define M_NCSI_RXFIFO_CNT 0x7ffU
-#define V_NCSI_RXFIFO_CNT(x) ((x) << S_NCSI_RXFIFO_CNT)
-#define G_NCSI_RXFIFO_CNT(x) (((x) >> S_NCSI_RXFIFO_CNT) & M_NCSI_RXFIFO_CNT)
-
-#define A_NCSI_RX_ERR_CNT 0x1a054
-#define A_NCSI_RX_OF_CNT 0x1a058
-#define A_NCSI_RX_MS_CNT 0x1a05c
-#define A_NCSI_RX_IE_CNT 0x1a060
-#define A_NCSI_MPS_DEMUX_CNT 0x1a064
-
-#define S_MPS2CIM_CNT 16
-#define M_MPS2CIM_CNT 0x1ffU
-#define V_MPS2CIM_CNT(x) ((x) << S_MPS2CIM_CNT)
-#define G_MPS2CIM_CNT(x) (((x) >> S_MPS2CIM_CNT) & M_MPS2CIM_CNT)
-
-#define S_MPS2BMC_CNT 0
-#define M_MPS2BMC_CNT 0x1ffU
-#define V_MPS2BMC_CNT(x) ((x) << S_MPS2BMC_CNT)
-#define G_MPS2BMC_CNT(x) (((x) >> S_MPS2BMC_CNT) & M_MPS2BMC_CNT)
-
-#define A_NCSI_CIM_DEMUX_CNT 0x1a068
-
-#define S_CIM2MPS_CNT 16
-#define M_CIM2MPS_CNT 0x1ffU
-#define V_CIM2MPS_CNT(x) ((x) << S_CIM2MPS_CNT)
-#define G_CIM2MPS_CNT(x) (((x) >> S_CIM2MPS_CNT) & M_CIM2MPS_CNT)
-
-#define S_CIM2BMC_CNT 0
-#define M_CIM2BMC_CNT 0x1ffU
-#define V_CIM2BMC_CNT(x) ((x) << S_CIM2BMC_CNT)
-#define G_CIM2BMC_CNT(x) (((x) >> S_CIM2BMC_CNT) & M_CIM2BMC_CNT)
-
-#define A_NCSI_TX_FIFO_CNT 0x1a06c
-
-#define S_TX_FIFO_CNT 0
-#define M_TX_FIFO_CNT 0x3ffU
-#define V_TX_FIFO_CNT(x) ((x) << S_TX_FIFO_CNT)
-#define G_TX_FIFO_CNT(x) (((x) >> S_TX_FIFO_CNT) & M_TX_FIFO_CNT)
-
-#define A_NCSI_SE_CNT_CTL 0x1a0b0
-
-#define S_SE_CNT_CLR 0
-#define M_SE_CNT_CLR 0xfU
-#define V_SE_CNT_CLR(x) ((x) << S_SE_CNT_CLR)
-#define G_SE_CNT_CLR(x) (((x) >> S_SE_CNT_CLR) & M_SE_CNT_CLR)
-
-#define A_NCSI_SE_CNT_MPS 0x1a0b4
-
-#define S_NC2MPS_SOP_CNT 24
-#define M_NC2MPS_SOP_CNT 0xffU
-#define V_NC2MPS_SOP_CNT(x) ((x) << S_NC2MPS_SOP_CNT)
-#define G_NC2MPS_SOP_CNT(x) (((x) >> S_NC2MPS_SOP_CNT) & M_NC2MPS_SOP_CNT)
-
-#define S_NC2MPS_EOP_CNT 16
-#define M_NC2MPS_EOP_CNT 0x3fU
-#define V_NC2MPS_EOP_CNT(x) ((x) << S_NC2MPS_EOP_CNT)
-#define G_NC2MPS_EOP_CNT(x) (((x) >> S_NC2MPS_EOP_CNT) & M_NC2MPS_EOP_CNT)
-
-#define S_MPS2NC_SOP_CNT 8
-#define M_MPS2NC_SOP_CNT 0xffU
-#define V_MPS2NC_SOP_CNT(x) ((x) << S_MPS2NC_SOP_CNT)
-#define G_MPS2NC_SOP_CNT(x) (((x) >> S_MPS2NC_SOP_CNT) & M_MPS2NC_SOP_CNT)
-
-#define S_MPS2NC_EOP_CNT 0
-#define M_MPS2NC_EOP_CNT 0xffU
-#define V_MPS2NC_EOP_CNT(x) ((x) << S_MPS2NC_EOP_CNT)
-#define G_MPS2NC_EOP_CNT(x) (((x) >> S_MPS2NC_EOP_CNT) & M_MPS2NC_EOP_CNT)
-
-#define A_NCSI_SE_CNT_CIM 0x1a0b8
-
-#define S_NC2CIM_SOP_CNT 24
-#define M_NC2CIM_SOP_CNT 0xffU
-#define V_NC2CIM_SOP_CNT(x) ((x) << S_NC2CIM_SOP_CNT)
-#define G_NC2CIM_SOP_CNT(x) (((x) >> S_NC2CIM_SOP_CNT) & M_NC2CIM_SOP_CNT)
-
-#define S_NC2CIM_EOP_CNT 16
-#define M_NC2CIM_EOP_CNT 0x3fU
-#define V_NC2CIM_EOP_CNT(x) ((x) << S_NC2CIM_EOP_CNT)
-#define G_NC2CIM_EOP_CNT(x) (((x) >> S_NC2CIM_EOP_CNT) & M_NC2CIM_EOP_CNT)
-
-#define S_CIM2NC_SOP_CNT 8
-#define M_CIM2NC_SOP_CNT 0xffU
-#define V_CIM2NC_SOP_CNT(x) ((x) << S_CIM2NC_SOP_CNT)
-#define G_CIM2NC_SOP_CNT(x) (((x) >> S_CIM2NC_SOP_CNT) & M_CIM2NC_SOP_CNT)
-
-#define S_CIM2NC_EOP_CNT 0
-#define M_CIM2NC_EOP_CNT 0xffU
-#define V_CIM2NC_EOP_CNT(x) ((x) << S_CIM2NC_EOP_CNT)
-#define G_CIM2NC_EOP_CNT(x) (((x) >> S_CIM2NC_EOP_CNT) & M_CIM2NC_EOP_CNT)
-
-#define A_NCSI_BUS_DEBUG 0x1a0bc
-
-#define S_SOP_CNT_ERR 12
-#define M_SOP_CNT_ERR 0xfU
-#define V_SOP_CNT_ERR(x) ((x) << S_SOP_CNT_ERR)
-#define G_SOP_CNT_ERR(x) (((x) >> S_SOP_CNT_ERR) & M_SOP_CNT_ERR)
-
-#define S_BUS_STATE_MPS_OUT 6
-#define M_BUS_STATE_MPS_OUT 0x3U
-#define V_BUS_STATE_MPS_OUT(x) ((x) << S_BUS_STATE_MPS_OUT)
-#define G_BUS_STATE_MPS_OUT(x) (((x) >> S_BUS_STATE_MPS_OUT) & M_BUS_STATE_MPS_OUT)
-
-#define S_BUS_STATE_MPS_IN 4
-#define M_BUS_STATE_MPS_IN 0x3U
-#define V_BUS_STATE_MPS_IN(x) ((x) << S_BUS_STATE_MPS_IN)
-#define G_BUS_STATE_MPS_IN(x) (((x) >> S_BUS_STATE_MPS_IN) & M_BUS_STATE_MPS_IN)
-
-#define S_BUS_STATE_CIM_OUT 2
-#define M_BUS_STATE_CIM_OUT 0x3U
-#define V_BUS_STATE_CIM_OUT(x) ((x) << S_BUS_STATE_CIM_OUT)
-#define G_BUS_STATE_CIM_OUT(x) (((x) >> S_BUS_STATE_CIM_OUT) & M_BUS_STATE_CIM_OUT)
-
-#define S_BUS_STATE_CIM_IN 0
-#define M_BUS_STATE_CIM_IN 0x3U
-#define V_BUS_STATE_CIM_IN(x) ((x) << S_BUS_STATE_CIM_IN)
-#define G_BUS_STATE_CIM_IN(x) (((x) >> S_BUS_STATE_CIM_IN) & M_BUS_STATE_CIM_IN)
-
-#define A_NCSI_LA_RDPTR 0x1a0c0
-#define A_NCSI_LA_RDDATA 0x1a0c4
-#define A_NCSI_LA_WRPTR 0x1a0c8
-#define A_NCSI_LA_RESERVED 0x1a0cc
-#define A_NCSI_LA_CTL 0x1a0d0
-#define A_NCSI_INT_ENABLE 0x1a0d4
-
-#define S_CIM_DM_PRTY_ERR 8
-#define V_CIM_DM_PRTY_ERR(x) ((x) << S_CIM_DM_PRTY_ERR)
-#define F_CIM_DM_PRTY_ERR V_CIM_DM_PRTY_ERR(1U)
-
-#define S_MPS_DM_PRTY_ERR 7
-#define V_MPS_DM_PRTY_ERR(x) ((x) << S_MPS_DM_PRTY_ERR)
-#define F_MPS_DM_PRTY_ERR V_MPS_DM_PRTY_ERR(1U)
-
-#define S_TOKEN 6
-#define V_TOKEN(x) ((x) << S_TOKEN)
-#define F_TOKEN V_TOKEN(1U)
-
-#define S_ARB_DONE 5
-#define V_ARB_DONE(x) ((x) << S_ARB_DONE)
-#define F_ARB_DONE V_ARB_DONE(1U)
-
-#define S_ARB_STARTED 4
-#define V_ARB_STARTED(x) ((x) << S_ARB_STARTED)
-#define F_ARB_STARTED V_ARB_STARTED(1U)
-
-#define S_WOL 3
-#define V_WOL(x) ((x) << S_WOL)
-#define F_WOL V_WOL(1U)
-
-#define S_MACINT 2
-#define V_MACINT(x) ((x) << S_MACINT)
-#define F_MACINT V_MACINT(1U)
-
-#define S_TXFIFO_PRTY_ERR 1
-#define V_TXFIFO_PRTY_ERR(x) ((x) << S_TXFIFO_PRTY_ERR)
-#define F_TXFIFO_PRTY_ERR V_TXFIFO_PRTY_ERR(1U)
-
-#define S_RXFIFO_PRTY_ERR 0
-#define V_RXFIFO_PRTY_ERR(x) ((x) << S_RXFIFO_PRTY_ERR)
-#define F_RXFIFO_PRTY_ERR V_RXFIFO_PRTY_ERR(1U)
-
-#define A_NCSI_INT_CAUSE 0x1a0d8
-#define A_NCSI_STATUS 0x1a0dc
-
-#define S_MASTER 1
-#define V_MASTER(x) ((x) << S_MASTER)
-#define F_MASTER V_MASTER(1U)
-
-#define S_ARB_STATUS 0
-#define V_ARB_STATUS(x) ((x) << S_ARB_STATUS)
-#define F_ARB_STATUS V_ARB_STATUS(1U)
-
-#define A_NCSI_PAUSE_CTRL 0x1a0e0
-
-#define S_FORCEPAUSE 0
-#define V_FORCEPAUSE(x) ((x) << S_FORCEPAUSE)
-#define F_FORCEPAUSE V_FORCEPAUSE(1U)
-
-#define A_NCSI_PAUSE_TIMEOUT 0x1a0e4
-#define A_NCSI_PAUSE_WM 0x1a0ec
-
-#define S_PAUSEHWM 16
-#define M_PAUSEHWM 0x7ffU
-#define V_PAUSEHWM(x) ((x) << S_PAUSEHWM)
-#define G_PAUSEHWM(x) (((x) >> S_PAUSEHWM) & M_PAUSEHWM)
-
-#define S_PAUSELWM 0
-#define M_PAUSELWM 0x7ffU
-#define V_PAUSELWM(x) ((x) << S_PAUSELWM)
-#define G_PAUSELWM(x) (((x) >> S_PAUSELWM) & M_PAUSELWM)
-
-#define A_NCSI_DEBUG 0x1a0f0
-
-#define S_DEBUGSEL 0
-#define M_DEBUGSEL 0x3fU
-#define V_DEBUGSEL(x) ((x) << S_DEBUGSEL)
-#define G_DEBUGSEL(x) (((x) >> S_DEBUGSEL) & M_DEBUGSEL)
-
-#define S_TXFIFO_EMPTY 4
-#define V_TXFIFO_EMPTY(x) ((x) << S_TXFIFO_EMPTY)
-#define F_TXFIFO_EMPTY V_TXFIFO_EMPTY(1U)
-
-#define S_TXFIFO_FULL 3
-#define V_TXFIFO_FULL(x) ((x) << S_TXFIFO_FULL)
-#define F_TXFIFO_FULL V_TXFIFO_FULL(1U)
-
-#define S_PKG_ID 0
-#define M_PKG_ID 0x7U
-#define V_PKG_ID(x) ((x) << S_PKG_ID)
-#define G_PKG_ID(x) (((x) >> S_PKG_ID) & M_PKG_ID)
-
-#define A_NCSI_PERR_INJECT 0x1a0f4
-
-#define S_MCSIMELSEL 1
-#define V_MCSIMELSEL(x) ((x) << S_MCSIMELSEL)
-#define F_MCSIMELSEL V_MCSIMELSEL(1U)
-
-#define A_NCSI_PERR_ENABLE 0x1a0f8
-#define A_NCSI_MACB_NETWORK_CTRL 0x1a100
-
-#define S_TXSNDZEROPAUSE 12
-#define V_TXSNDZEROPAUSE(x) ((x) << S_TXSNDZEROPAUSE)
-#define F_TXSNDZEROPAUSE V_TXSNDZEROPAUSE(1U)
-
-#define S_TXSNDPAUSE 11
-#define V_TXSNDPAUSE(x) ((x) << S_TXSNDPAUSE)
-#define F_TXSNDPAUSE V_TXSNDPAUSE(1U)
-
-#define S_TXSTOP 10
-#define V_TXSTOP(x) ((x) << S_TXSTOP)
-#define F_TXSTOP V_TXSTOP(1U)
-
-#define S_TXSTART 9
-#define V_TXSTART(x) ((x) << S_TXSTART)
-#define F_TXSTART V_TXSTART(1U)
-
-#define S_BACKPRESS 8
-#define V_BACKPRESS(x) ((x) << S_BACKPRESS)
-#define F_BACKPRESS V_BACKPRESS(1U)
-
-#define S_STATWREN 7
-#define V_STATWREN(x) ((x) << S_STATWREN)
-#define F_STATWREN V_STATWREN(1U)
-
-#define S_INCRSTAT 6
-#define V_INCRSTAT(x) ((x) << S_INCRSTAT)
-#define F_INCRSTAT V_INCRSTAT(1U)
-
-#define S_CLEARSTAT 5
-#define V_CLEARSTAT(x) ((x) << S_CLEARSTAT)
-#define F_CLEARSTAT V_CLEARSTAT(1U)
-
-#define S_ENMGMTPORT 4
-#define V_ENMGMTPORT(x) ((x) << S_ENMGMTPORT)
-#define F_ENMGMTPORT V_ENMGMTPORT(1U)
-
-#define S_NCSITXEN 3
-#define V_NCSITXEN(x) ((x) << S_NCSITXEN)
-#define F_NCSITXEN V_NCSITXEN(1U)
-
-#define S_NCSIRXEN 2
-#define V_NCSIRXEN(x) ((x) << S_NCSIRXEN)
-#define F_NCSIRXEN V_NCSIRXEN(1U)
-
-#define S_LOOPLOCAL 1
-#define V_LOOPLOCAL(x) ((x) << S_LOOPLOCAL)
-#define F_LOOPLOCAL V_LOOPLOCAL(1U)
-
-#define S_LOOPPHY 0
-#define V_LOOPPHY(x) ((x) << S_LOOPPHY)
-#define F_LOOPPHY V_LOOPPHY(1U)
-
-#define A_NCSI_MACB_NETWORK_CFG 0x1a104
-
-#define S_PCLKDIV128 22
-#define V_PCLKDIV128(x) ((x) << S_PCLKDIV128)
-#define F_PCLKDIV128 V_PCLKDIV128(1U)
-
-#define S_COPYPAUSE 21
-#define V_COPYPAUSE(x) ((x) << S_COPYPAUSE)
-#define F_COPYPAUSE V_COPYPAUSE(1U)
-
-#define S_NONSTDPREOK 20
-#define V_NONSTDPREOK(x) ((x) << S_NONSTDPREOK)
-#define F_NONSTDPREOK V_NONSTDPREOK(1U)
-
-#define S_NOFCS 19
-#define V_NOFCS(x) ((x) << S_NOFCS)
-#define F_NOFCS V_NOFCS(1U)
-
-#define S_RXENHALFDUP 18
-#define V_RXENHALFDUP(x) ((x) << S_RXENHALFDUP)
-#define F_RXENHALFDUP V_RXENHALFDUP(1U)
-
-#define S_NOCOPYFCS 17
-#define V_NOCOPYFCS(x) ((x) << S_NOCOPYFCS)
-#define F_NOCOPYFCS V_NOCOPYFCS(1U)
-
-#define S_LENCHKEN 16
-#define V_LENCHKEN(x) ((x) << S_LENCHKEN)
-#define F_LENCHKEN V_LENCHKEN(1U)
-
-#define S_RXBUFOFFSET 14
-#define M_RXBUFOFFSET 0x3U
-#define V_RXBUFOFFSET(x) ((x) << S_RXBUFOFFSET)
-#define G_RXBUFOFFSET(x) (((x) >> S_RXBUFOFFSET) & M_RXBUFOFFSET)
-
-#define S_PAUSEEN 13
-#define V_PAUSEEN(x) ((x) << S_PAUSEEN)
-#define F_PAUSEEN V_PAUSEEN(1U)
-
-#define S_RETRYTEST 12
-#define V_RETRYTEST(x) ((x) << S_RETRYTEST)
-#define F_RETRYTEST V_RETRYTEST(1U)
-
-#define S_PCLKDIV 10
-#define M_PCLKDIV 0x3U
-#define V_PCLKDIV(x) ((x) << S_PCLKDIV)
-#define G_PCLKDIV(x) (((x) >> S_PCLKDIV) & M_PCLKDIV)
-
-#define S_EXTCLASS 9
-#define V_EXTCLASS(x) ((x) << S_EXTCLASS)
-#define F_EXTCLASS V_EXTCLASS(1U)
-
-#define S_EN1536FRAME 8
-#define V_EN1536FRAME(x) ((x) << S_EN1536FRAME)
-#define F_EN1536FRAME V_EN1536FRAME(1U)
-
-#define S_UCASTHASHEN 7
-#define V_UCASTHASHEN(x) ((x) << S_UCASTHASHEN)
-#define F_UCASTHASHEN V_UCASTHASHEN(1U)
-
-#define S_MCASTHASHEN 6
-#define V_MCASTHASHEN(x) ((x) << S_MCASTHASHEN)
-#define F_MCASTHASHEN V_MCASTHASHEN(1U)
-
-#define S_RXBCASTDIS 5
-#define V_RXBCASTDIS(x) ((x) << S_RXBCASTDIS)
-#define F_RXBCASTDIS V_RXBCASTDIS(1U)
-
-#define S_NCSICOPYALLFRAMES 4
-#define V_NCSICOPYALLFRAMES(x) ((x) << S_NCSICOPYALLFRAMES)
-#define F_NCSICOPYALLFRAMES V_NCSICOPYALLFRAMES(1U)
-
-#define S_JUMBOEN 3
-#define V_JUMBOEN(x) ((x) << S_JUMBOEN)
-#define F_JUMBOEN V_JUMBOEN(1U)
-
-#define S_SEREN 2
-#define V_SEREN(x) ((x) << S_SEREN)
-#define F_SEREN V_SEREN(1U)
-
-#define S_FULLDUPLEX 1
-#define V_FULLDUPLEX(x) ((x) << S_FULLDUPLEX)
-#define F_FULLDUPLEX V_FULLDUPLEX(1U)
-
-#define S_SPEED 0
-#define V_SPEED(x) ((x) << S_SPEED)
-#define F_SPEED V_SPEED(1U)
-
-#define A_NCSI_MACB_NETWORK_STATUS 0x1a108
-
-#define S_PHYMGMTSTATUS 2
-#define V_PHYMGMTSTATUS(x) ((x) << S_PHYMGMTSTATUS)
-#define F_PHYMGMTSTATUS V_PHYMGMTSTATUS(1U)
-
-#define S_MDISTATUS 1
-#define V_MDISTATUS(x) ((x) << S_MDISTATUS)
-#define F_MDISTATUS V_MDISTATUS(1U)
-
-#define S_LINKSTATUS 0
-#define V_LINKSTATUS(x) ((x) << S_LINKSTATUS)
-#define F_LINKSTATUS V_LINKSTATUS(1U)
-
-#define A_NCSI_MACB_TX_STATUS 0x1a114
-
-#define S_UNDERRUNERR 6
-#define V_UNDERRUNERR(x) ((x) << S_UNDERRUNERR)
-#define F_UNDERRUNERR V_UNDERRUNERR(1U)
-
-#define S_TXCOMPLETE 5
-#define V_TXCOMPLETE(x) ((x) << S_TXCOMPLETE)
-#define F_TXCOMPLETE V_TXCOMPLETE(1U)
-
-#define S_BUFFEREXHAUSTED 4
-#define V_BUFFEREXHAUSTED(x) ((x) << S_BUFFEREXHAUSTED)
-#define F_BUFFEREXHAUSTED V_BUFFEREXHAUSTED(1U)
-
-#define S_TXPROGRESS 3
-#define V_TXPROGRESS(x) ((x) << S_TXPROGRESS)
-#define F_TXPROGRESS V_TXPROGRESS(1U)
-
-#define S_RETRYLIMIT 2
-#define V_RETRYLIMIT(x) ((x) << S_RETRYLIMIT)
-#define F_RETRYLIMIT V_RETRYLIMIT(1U)
-
-#define S_COLEVENT 1
-#define V_COLEVENT(x) ((x) << S_COLEVENT)
-#define F_COLEVENT V_COLEVENT(1U)
-
-#define S_USEDBITREAD 0
-#define V_USEDBITREAD(x) ((x) << S_USEDBITREAD)
-#define F_USEDBITREAD V_USEDBITREAD(1U)
-
-#define A_NCSI_MACB_RX_BUF_QPTR 0x1a118
-
-#define S_RXBUFQPTR 2
-#define M_RXBUFQPTR 0x3fffffffU
-#define V_RXBUFQPTR(x) ((x) << S_RXBUFQPTR)
-#define G_RXBUFQPTR(x) (((x) >> S_RXBUFQPTR) & M_RXBUFQPTR)
-
-#define A_NCSI_MACB_TX_BUF_QPTR 0x1a11c
-
-#define S_TXBUFQPTR 2
-#define M_TXBUFQPTR 0x3fffffffU
-#define V_TXBUFQPTR(x) ((x) << S_TXBUFQPTR)
-#define G_TXBUFQPTR(x) (((x) >> S_TXBUFQPTR) & M_TXBUFQPTR)
-
-#define A_NCSI_MACB_RX_STATUS 0x1a120
-
-#define S_RXOVERRUNERR 2
-#define V_RXOVERRUNERR(x) ((x) << S_RXOVERRUNERR)
-#define F_RXOVERRUNERR V_RXOVERRUNERR(1U)
-
-#define S_MACB_FRAMERCVD 1
-#define V_MACB_FRAMERCVD(x) ((x) << S_MACB_FRAMERCVD)
-#define F_MACB_FRAMERCVD V_MACB_FRAMERCVD(1U)
-
-#define S_NORXBUF 0
-#define V_NORXBUF(x) ((x) << S_NORXBUF)
-#define F_NORXBUF V_NORXBUF(1U)
-
-#define A_NCSI_MACB_INT_STATUS 0x1a124
-
-#define S_PAUSETIMEZERO 13
-#define V_PAUSETIMEZERO(x) ((x) << S_PAUSETIMEZERO)
-#define F_PAUSETIMEZERO V_PAUSETIMEZERO(1U)
-
-#define S_PAUSERCVD 12
-#define V_PAUSERCVD(x) ((x) << S_PAUSERCVD)
-#define F_PAUSERCVD V_PAUSERCVD(1U)
-
-#define S_HRESPNOTOK 11
-#define V_HRESPNOTOK(x) ((x) << S_HRESPNOTOK)
-#define F_HRESPNOTOK V_HRESPNOTOK(1U)
-
-#define S_RXOVERRUN 10
-#define V_RXOVERRUN(x) ((x) << S_RXOVERRUN)
-#define F_RXOVERRUN V_RXOVERRUN(1U)
-
-#define S_LINKCHANGE 9
-#define V_LINKCHANGE(x) ((x) << S_LINKCHANGE)
-#define F_LINKCHANGE V_LINKCHANGE(1U)
-
-#define S_INT_TXCOMPLETE 7
-#define V_INT_TXCOMPLETE(x) ((x) << S_INT_TXCOMPLETE)
-#define F_INT_TXCOMPLETE V_INT_TXCOMPLETE(1U)
-
-#define S_TXBUFERR 6
-#define V_TXBUFERR(x) ((x) << S_TXBUFERR)
-#define F_TXBUFERR V_TXBUFERR(1U)
-
-#define S_RETRYLIMITERR 5
-#define V_RETRYLIMITERR(x) ((x) << S_RETRYLIMITERR)
-#define F_RETRYLIMITERR V_RETRYLIMITERR(1U)
-
-#define S_TXBUFUNDERRUN 4
-#define V_TXBUFUNDERRUN(x) ((x) << S_TXBUFUNDERRUN)
-#define F_TXBUFUNDERRUN V_TXBUFUNDERRUN(1U)
-
-#define S_TXUSEDBITREAD 3
-#define V_TXUSEDBITREAD(x) ((x) << S_TXUSEDBITREAD)
-#define F_TXUSEDBITREAD V_TXUSEDBITREAD(1U)
-
-#define S_RXUSEDBITREAD 2
-#define V_RXUSEDBITREAD(x) ((x) << S_RXUSEDBITREAD)
-#define F_RXUSEDBITREAD V_RXUSEDBITREAD(1U)
-
-#define S_RXCOMPLETE 1
-#define V_RXCOMPLETE(x) ((x) << S_RXCOMPLETE)
-#define F_RXCOMPLETE V_RXCOMPLETE(1U)
-
-#define S_MGMTFRAMESENT 0
-#define V_MGMTFRAMESENT(x) ((x) << S_MGMTFRAMESENT)
-#define F_MGMTFRAMESENT V_MGMTFRAMESENT(1U)
-
-#define A_NCSI_MACB_INT_EN 0x1a128
-#define A_NCSI_MACB_INT_DIS 0x1a12c
-#define A_NCSI_MACB_INT_MASK 0x1a130
-#define A_NCSI_MACB_PAUSE_TIME 0x1a138
-
-#define S_PAUSETIME 0
-#define M_PAUSETIME 0xffffU
-#define V_PAUSETIME(x) ((x) << S_PAUSETIME)
-#define G_PAUSETIME(x) (((x) >> S_PAUSETIME) & M_PAUSETIME)
-
-#define A_NCSI_MACB_PAUSE_FRAMES_RCVD 0x1a13c
-
-#define S_PAUSEFRRCVD 0
-#define M_PAUSEFRRCVD 0xffffU
-#define V_PAUSEFRRCVD(x) ((x) << S_PAUSEFRRCVD)
-#define G_PAUSEFRRCVD(x) (((x) >> S_PAUSEFRRCVD) & M_PAUSEFRRCVD)
-
-#define A_NCSI_MACB_TX_FRAMES_OK 0x1a140
-
-#define S_TXFRAMESOK 0
-#define M_TXFRAMESOK 0xffffffU
-#define V_TXFRAMESOK(x) ((x) << S_TXFRAMESOK)
-#define G_TXFRAMESOK(x) (((x) >> S_TXFRAMESOK) & M_TXFRAMESOK)
-
-#define A_NCSI_MACB_SINGLE_COL_FRAMES 0x1a144
-
-#define S_SINGLECOLTXFRAMES 0
-#define M_SINGLECOLTXFRAMES 0xffffU
-#define V_SINGLECOLTXFRAMES(x) ((x) << S_SINGLECOLTXFRAMES)
-#define G_SINGLECOLTXFRAMES(x) (((x) >> S_SINGLECOLTXFRAMES) & M_SINGLECOLTXFRAMES)
-
-#define A_NCSI_MACB_MUL_COL_FRAMES 0x1a148
-
-#define S_MULCOLTXFRAMES 0
-#define M_MULCOLTXFRAMES 0xffffU
-#define V_MULCOLTXFRAMES(x) ((x) << S_MULCOLTXFRAMES)
-#define G_MULCOLTXFRAMES(x) (((x) >> S_MULCOLTXFRAMES) & M_MULCOLTXFRAMES)
-
-#define A_NCSI_MACB_RX_FRAMES_OK 0x1a14c
-
-#define S_RXFRAMESOK 0
-#define M_RXFRAMESOK 0xffffffU
-#define V_RXFRAMESOK(x) ((x) << S_RXFRAMESOK)
-#define G_RXFRAMESOK(x) (((x) >> S_RXFRAMESOK) & M_RXFRAMESOK)
-
-#define A_NCSI_MACB_FCS_ERR 0x1a150
-
-#define S_RXFCSERR 0
-#define M_RXFCSERR 0xffU
-#define V_RXFCSERR(x) ((x) << S_RXFCSERR)
-#define G_RXFCSERR(x) (((x) >> S_RXFCSERR) & M_RXFCSERR)
-
-#define A_NCSI_MACB_ALIGN_ERR 0x1a154
-
-#define S_RXALIGNERR 0
-#define M_RXALIGNERR 0xffU
-#define V_RXALIGNERR(x) ((x) << S_RXALIGNERR)
-#define G_RXALIGNERR(x) (((x) >> S_RXALIGNERR) & M_RXALIGNERR)
-
-#define A_NCSI_MACB_DEF_TX_FRAMES 0x1a158
-
-#define S_TXDEFERREDFRAMES 0
-#define M_TXDEFERREDFRAMES 0xffffU
-#define V_TXDEFERREDFRAMES(x) ((x) << S_TXDEFERREDFRAMES)
-#define G_TXDEFERREDFRAMES(x) (((x) >> S_TXDEFERREDFRAMES) & M_TXDEFERREDFRAMES)
-
-#define A_NCSI_MACB_LATE_COL 0x1a15c
-
-#define S_LATECOLLISIONS 0
-#define M_LATECOLLISIONS 0xffffU
-#define V_LATECOLLISIONS(x) ((x) << S_LATECOLLISIONS)
-#define G_LATECOLLISIONS(x) (((x) >> S_LATECOLLISIONS) & M_LATECOLLISIONS)
-
-#define A_NCSI_MACB_EXCESSIVE_COL 0x1a160
-
-#define S_EXCESSIVECOLLISIONS 0
-#define M_EXCESSIVECOLLISIONS 0xffU
-#define V_EXCESSIVECOLLISIONS(x) ((x) << S_EXCESSIVECOLLISIONS)
-#define G_EXCESSIVECOLLISIONS(x) (((x) >> S_EXCESSIVECOLLISIONS) & M_EXCESSIVECOLLISIONS)
-
-#define A_NCSI_MACB_TX_UNDERRUN_ERR 0x1a164
-
-#define S_TXUNDERRUNERR 0
-#define M_TXUNDERRUNERR 0xffU
-#define V_TXUNDERRUNERR(x) ((x) << S_TXUNDERRUNERR)
-#define G_TXUNDERRUNERR(x) (((x) >> S_TXUNDERRUNERR) & M_TXUNDERRUNERR)
-
-#define A_NCSI_MACB_CARRIER_SENSE_ERR 0x1a168
-
-#define S_CARRIERSENSEERRS 0
-#define M_CARRIERSENSEERRS 0xffU
-#define V_CARRIERSENSEERRS(x) ((x) << S_CARRIERSENSEERRS)
-#define G_CARRIERSENSEERRS(x) (((x) >> S_CARRIERSENSEERRS) & M_CARRIERSENSEERRS)
-
-#define A_NCSI_MACB_RX_RESOURCE_ERR 0x1a16c
-
-#define S_RXRESOURCEERR 0
-#define M_RXRESOURCEERR 0xffffU
-#define V_RXRESOURCEERR(x) ((x) << S_RXRESOURCEERR)
-#define G_RXRESOURCEERR(x) (((x) >> S_RXRESOURCEERR) & M_RXRESOURCEERR)
-
-#define A_NCSI_MACB_RX_OVERRUN_ERR 0x1a170
-
-#define S_RXOVERRUNERRCNT 0
-#define M_RXOVERRUNERRCNT 0xffU
-#define V_RXOVERRUNERRCNT(x) ((x) << S_RXOVERRUNERRCNT)
-#define G_RXOVERRUNERRCNT(x) (((x) >> S_RXOVERRUNERRCNT) & M_RXOVERRUNERRCNT)
-
-#define A_NCSI_MACB_RX_SYMBOL_ERR 0x1a174
-
-#define S_RXSYMBOLERR 0
-#define M_RXSYMBOLERR 0xffU
-#define V_RXSYMBOLERR(x) ((x) << S_RXSYMBOLERR)
-#define G_RXSYMBOLERR(x) (((x) >> S_RXSYMBOLERR) & M_RXSYMBOLERR)
-
-#define A_NCSI_MACB_RX_OVERSIZE_FRAME 0x1a178
-
-#define S_RXOVERSIZEERR 0
-#define M_RXOVERSIZEERR 0xffU
-#define V_RXOVERSIZEERR(x) ((x) << S_RXOVERSIZEERR)
-#define G_RXOVERSIZEERR(x) (((x) >> S_RXOVERSIZEERR) & M_RXOVERSIZEERR)
-
-#define A_NCSI_MACB_RX_JABBER_ERR 0x1a17c
-
-#define S_RXJABBERERR 0
-#define M_RXJABBERERR 0xffU
-#define V_RXJABBERERR(x) ((x) << S_RXJABBERERR)
-#define G_RXJABBERERR(x) (((x) >> S_RXJABBERERR) & M_RXJABBERERR)
-
-#define A_NCSI_MACB_RX_UNDERSIZE_FRAME 0x1a180
-
-#define S_RXUNDERSIZEFR 0
-#define M_RXUNDERSIZEFR 0xffU
-#define V_RXUNDERSIZEFR(x) ((x) << S_RXUNDERSIZEFR)
-#define G_RXUNDERSIZEFR(x) (((x) >> S_RXUNDERSIZEFR) & M_RXUNDERSIZEFR)
-
-#define A_NCSI_MACB_SQE_TEST_ERR 0x1a184
-
-#define S_SQETESTERR 0
-#define M_SQETESTERR 0xffU
-#define V_SQETESTERR(x) ((x) << S_SQETESTERR)
-#define G_SQETESTERR(x) (((x) >> S_SQETESTERR) & M_SQETESTERR)
-
-#define A_NCSI_MACB_LENGTH_ERR 0x1a188
-
-#define S_LENGTHERR 0
-#define M_LENGTHERR 0xffU
-#define V_LENGTHERR(x) ((x) << S_LENGTHERR)
-#define G_LENGTHERR(x) (((x) >> S_LENGTHERR) & M_LENGTHERR)
-
-#define A_NCSI_MACB_TX_PAUSE_FRAMES 0x1a18c
-
-#define S_TXPAUSEFRAMES 0
-#define M_TXPAUSEFRAMES 0xffffU
-#define V_TXPAUSEFRAMES(x) ((x) << S_TXPAUSEFRAMES)
-#define G_TXPAUSEFRAMES(x) (((x) >> S_TXPAUSEFRAMES) & M_TXPAUSEFRAMES)
-
-#define A_NCSI_MACB_HASH_LOW 0x1a190
-#define A_NCSI_MACB_HASH_HIGH 0x1a194
-#define A_NCSI_MACB_SPECIFIC_1_LOW 0x1a198
-#define A_NCSI_MACB_SPECIFIC_1_HIGH 0x1a19c
-
-#define S_MATCHHIGH 0
-#define M_MATCHHIGH 0xffffU
-#define V_MATCHHIGH(x) ((x) << S_MATCHHIGH)
-#define G_MATCHHIGH(x) (((x) >> S_MATCHHIGH) & M_MATCHHIGH)
-
-#define A_NCSI_MACB_SPECIFIC_2_LOW 0x1a1a0
-#define A_NCSI_MACB_SPECIFIC_2_HIGH 0x1a1a4
-#define A_NCSI_MACB_SPECIFIC_3_LOW 0x1a1a8
-#define A_NCSI_MACB_SPECIFIC_3_HIGH 0x1a1ac
-#define A_NCSI_MACB_SPECIFIC_4_LOW 0x1a1b0
-#define A_NCSI_MACB_SPECIFIC_4_HIGH 0x1a1b4
-#define A_NCSI_MACB_TYPE_ID 0x1a1b8
-
-#define S_TYPEID 0
-#define M_TYPEID 0xffffU
-#define V_TYPEID(x) ((x) << S_TYPEID)
-#define G_TYPEID(x) (((x) >> S_TYPEID) & M_TYPEID)
-
-#define A_NCSI_MACB_TX_PAUSE_QUANTUM 0x1a1bc
-
-#define S_TXPAUSEQUANTUM 0
-#define M_TXPAUSEQUANTUM 0xffffU
-#define V_TXPAUSEQUANTUM(x) ((x) << S_TXPAUSEQUANTUM)
-#define G_TXPAUSEQUANTUM(x) (((x) >> S_TXPAUSEQUANTUM) & M_TXPAUSEQUANTUM)
-
-#define A_NCSI_MACB_USER_IO 0x1a1c0
-
-#define S_USERPROGINPUT 16
-#define M_USERPROGINPUT 0xffffU
-#define V_USERPROGINPUT(x) ((x) << S_USERPROGINPUT)
-#define G_USERPROGINPUT(x) (((x) >> S_USERPROGINPUT) & M_USERPROGINPUT)
-
-#define S_USERPROGOUTPUT 0
-#define M_USERPROGOUTPUT 0xffffU
-#define V_USERPROGOUTPUT(x) ((x) << S_USERPROGOUTPUT)
-#define G_USERPROGOUTPUT(x) (((x) >> S_USERPROGOUTPUT) & M_USERPROGOUTPUT)
-
-#define A_NCSI_MACB_WOL_CFG 0x1a1c4
-
-#define S_MCHASHEN 19
-#define V_MCHASHEN(x) ((x) << S_MCHASHEN)
-#define F_MCHASHEN V_MCHASHEN(1U)
-
-#define S_SPECIFIC1EN 18
-#define V_SPECIFIC1EN(x) ((x) << S_SPECIFIC1EN)
-#define F_SPECIFIC1EN V_SPECIFIC1EN(1U)
-
-#define S_ARPEN 17
-#define V_ARPEN(x) ((x) << S_ARPEN)
-#define F_ARPEN V_ARPEN(1U)
-
-#define S_MAGICPKTEN 16
-#define V_MAGICPKTEN(x) ((x) << S_MAGICPKTEN)
-#define F_MAGICPKTEN V_MAGICPKTEN(1U)
-
-#define S_ARPIPADDR 0
-#define M_ARPIPADDR 0xffffU
-#define V_ARPIPADDR(x) ((x) << S_ARPIPADDR)
-#define G_ARPIPADDR(x) (((x) >> S_ARPIPADDR) & M_ARPIPADDR)
-
-#define A_NCSI_MACB_REV_STATUS 0x1a1fc
-
-#define S_PARTREF 16
-#define M_PARTREF 0xffffU
-#define V_PARTREF(x) ((x) << S_PARTREF)
-#define G_PARTREF(x) (((x) >> S_PARTREF) & M_PARTREF)
-
-#define S_DESREV 0
-#define M_DESREV 0xffffU
-#define V_DESREV(x) ((x) << S_DESREV)
-#define G_DESREV(x) (((x) >> S_DESREV) & M_DESREV)
-
-/* registers for module XGMAC */
-#define XGMAC_BASE_ADDR 0x0
-
-#define A_XGMAC_PORT_CFG 0x1000
-
-#define S_XGMII_CLK_SEL 29
-#define M_XGMII_CLK_SEL 0x7U
-#define V_XGMII_CLK_SEL(x) ((x) << S_XGMII_CLK_SEL)
-#define G_XGMII_CLK_SEL(x) (((x) >> S_XGMII_CLK_SEL) & M_XGMII_CLK_SEL)
-
-#define S_SINKTX 27
-#define V_SINKTX(x) ((x) << S_SINKTX)
-#define F_SINKTX V_SINKTX(1U)
-
-#define S_SINKTXONLINKDOWN 26
-#define V_SINKTXONLINKDOWN(x) ((x) << S_SINKTXONLINKDOWN)
-#define F_SINKTXONLINKDOWN V_SINKTXONLINKDOWN(1U)
-
-#define S_XG2G_SPEED_MODE 25
-#define V_XG2G_SPEED_MODE(x) ((x) << S_XG2G_SPEED_MODE)
-#define F_XG2G_SPEED_MODE V_XG2G_SPEED_MODE(1U)
-
-#define S_LOOPNOFWD 24
-#define V_LOOPNOFWD(x) ((x) << S_LOOPNOFWD)
-#define F_LOOPNOFWD V_LOOPNOFWD(1U)
-
-#define S_XGM_TX_PAUSE_SIZE 23
-#define V_XGM_TX_PAUSE_SIZE(x) ((x) << S_XGM_TX_PAUSE_SIZE)
-#define F_XGM_TX_PAUSE_SIZE V_XGM_TX_PAUSE_SIZE(1U)
-
-#define S_XGM_TX_PAUSE_FRAME 22
-#define V_XGM_TX_PAUSE_FRAME(x) ((x) << S_XGM_TX_PAUSE_FRAME)
-#define F_XGM_TX_PAUSE_FRAME V_XGM_TX_PAUSE_FRAME(1U)
-
-#define S_XGM_TX_DISABLE_PRE 21
-#define V_XGM_TX_DISABLE_PRE(x) ((x) << S_XGM_TX_DISABLE_PRE)
-#define F_XGM_TX_DISABLE_PRE V_XGM_TX_DISABLE_PRE(1U)
-
-#define S_XGM_TX_DISABLE_CRC 20
-#define V_XGM_TX_DISABLE_CRC(x) ((x) << S_XGM_TX_DISABLE_CRC)
-#define F_XGM_TX_DISABLE_CRC V_XGM_TX_DISABLE_CRC(1U)
-
-#define S_SMUX_RX_LOOP 19
-#define V_SMUX_RX_LOOP(x) ((x) << S_SMUX_RX_LOOP)
-#define F_SMUX_RX_LOOP V_SMUX_RX_LOOP(1U)
-
-#define S_RX_LANE_SWAP 18
-#define V_RX_LANE_SWAP(x) ((x) << S_RX_LANE_SWAP)
-#define F_RX_LANE_SWAP V_RX_LANE_SWAP(1U)
-
-#define S_TX_LANE_SWAP 17
-#define V_TX_LANE_SWAP(x) ((x) << S_TX_LANE_SWAP)
-#define F_TX_LANE_SWAP V_TX_LANE_SWAP(1U)
-
-#define S_SIGNAL_DET 14
-#define V_SIGNAL_DET(x) ((x) << S_SIGNAL_DET)
-#define F_SIGNAL_DET V_SIGNAL_DET(1U)
-
-#define S_PMUX_RX_LOOP 13
-#define V_PMUX_RX_LOOP(x) ((x) << S_PMUX_RX_LOOP)
-#define F_PMUX_RX_LOOP V_PMUX_RX_LOOP(1U)
-
-#define S_PMUX_TX_LOOP 12
-#define V_PMUX_TX_LOOP(x) ((x) << S_PMUX_TX_LOOP)
-#define F_PMUX_TX_LOOP V_PMUX_TX_LOOP(1U)
-
-#define S_XGM_RX_SEL 10
-#define M_XGM_RX_SEL 0x3U
-#define V_XGM_RX_SEL(x) ((x) << S_XGM_RX_SEL)
-#define G_XGM_RX_SEL(x) (((x) >> S_XGM_RX_SEL) & M_XGM_RX_SEL)
-
-#define S_PCS_TX_SEL 8
-#define M_PCS_TX_SEL 0x3U
-#define V_PCS_TX_SEL(x) ((x) << S_PCS_TX_SEL)
-#define G_PCS_TX_SEL(x) (((x) >> S_PCS_TX_SEL) & M_PCS_TX_SEL)
-
-#define S_XAUI20_REM_PRE 5
-#define V_XAUI20_REM_PRE(x) ((x) << S_XAUI20_REM_PRE)
-#define F_XAUI20_REM_PRE V_XAUI20_REM_PRE(1U)
-
-#define S_XAUI20_XGMII_SEL 4
-#define V_XAUI20_XGMII_SEL(x) ((x) << S_XAUI20_XGMII_SEL)
-#define F_XAUI20_XGMII_SEL V_XAUI20_XGMII_SEL(1U)
-
-#define S_PORT_SEL 0
-#define V_PORT_SEL(x) ((x) << S_PORT_SEL)
-#define F_PORT_SEL V_PORT_SEL(1U)
-
-#define A_XGMAC_PORT_RESET_CTRL 0x1004
-
-#define S_AUXEXT_RESET 10
-#define V_AUXEXT_RESET(x) ((x) << S_AUXEXT_RESET)
-#define F_AUXEXT_RESET V_AUXEXT_RESET(1U)
-
-#define S_TXFIFO_RESET 9
-#define V_TXFIFO_RESET(x) ((x) << S_TXFIFO_RESET)
-#define F_TXFIFO_RESET V_TXFIFO_RESET(1U)
-
-#define S_RXFIFO_RESET 8
-#define V_RXFIFO_RESET(x) ((x) << S_RXFIFO_RESET)
-#define F_RXFIFO_RESET V_RXFIFO_RESET(1U)
-
-#define S_BEAN_RESET 7
-#define V_BEAN_RESET(x) ((x) << S_BEAN_RESET)
-#define F_BEAN_RESET V_BEAN_RESET(1U)
-
-#define S_XAUI_RESET 6
-#define V_XAUI_RESET(x) ((x) << S_XAUI_RESET)
-#define F_XAUI_RESET V_XAUI_RESET(1U)
-
-#define S_AE_RESET 5
-#define V_AE_RESET(x) ((x) << S_AE_RESET)
-#define F_AE_RESET V_AE_RESET(1U)
-
-#define S_XGM_RESET 4
-#define V_XGM_RESET(x) ((x) << S_XGM_RESET)
-#define F_XGM_RESET V_XGM_RESET(1U)
-
-#define S_XG2G_RESET 3
-#define V_XG2G_RESET(x) ((x) << S_XG2G_RESET)
-#define F_XG2G_RESET V_XG2G_RESET(1U)
-
-#define S_WOL_RESET 2
-#define V_WOL_RESET(x) ((x) << S_WOL_RESET)
-#define F_WOL_RESET V_WOL_RESET(1U)
-
-#define S_XFI_PCS_RESET 1
-#define V_XFI_PCS_RESET(x) ((x) << S_XFI_PCS_RESET)
-#define F_XFI_PCS_RESET V_XFI_PCS_RESET(1U)
-
-#define S_HSS_RESET 0
-#define V_HSS_RESET(x) ((x) << S_HSS_RESET)
-#define F_HSS_RESET V_HSS_RESET(1U)
-
-#define A_XGMAC_PORT_LED_CFG 0x1008
-
-#define S_LED1_CFG 5
-#define M_LED1_CFG 0x7U
-#define V_LED1_CFG(x) ((x) << S_LED1_CFG)
-#define G_LED1_CFG(x) (((x) >> S_LED1_CFG) & M_LED1_CFG)
-
-#define S_LED1_POLARITY_INV 4
-#define V_LED1_POLARITY_INV(x) ((x) << S_LED1_POLARITY_INV)
-#define F_LED1_POLARITY_INV V_LED1_POLARITY_INV(1U)
-
-#define S_LED0_CFG 1
-#define M_LED0_CFG 0x7U
-#define V_LED0_CFG(x) ((x) << S_LED0_CFG)
-#define G_LED0_CFG(x) (((x) >> S_LED0_CFG) & M_LED0_CFG)
-
-#define S_LED0_POLARITY_INV 0
-#define V_LED0_POLARITY_INV(x) ((x) << S_LED0_POLARITY_INV)
-#define F_LED0_POLARITY_INV V_LED0_POLARITY_INV(1U)
-
-#define A_XGMAC_PORT_LED_COUNTHI 0x100c
-
-#define S_LED_COUNT_HI 0
-#define M_LED_COUNT_HI 0x1ffffffU
-#define V_LED_COUNT_HI(x) ((x) << S_LED_COUNT_HI)
-#define G_LED_COUNT_HI(x) (((x) >> S_LED_COUNT_HI) & M_LED_COUNT_HI)
-
-#define A_XGMAC_PORT_LED_COUNTLO 0x1010
-
-#define S_LED_COUNT_LO 0
-#define M_LED_COUNT_LO 0x1ffffffU
-#define V_LED_COUNT_LO(x) ((x) << S_LED_COUNT_LO)
-#define G_LED_COUNT_LO(x) (((x) >> S_LED_COUNT_LO) & M_LED_COUNT_LO)
-
-#define A_XGMAC_PORT_DEBUG_CFG 0x1014
-
-#define S_TESTCLK_SEL 0
-#define M_TESTCLK_SEL 0xfU
-#define V_TESTCLK_SEL(x) ((x) << S_TESTCLK_SEL)
-#define G_TESTCLK_SEL(x) (((x) >> S_TESTCLK_SEL) & M_TESTCLK_SEL)
-
-#define A_XGMAC_PORT_CFG2 0x1018
-
-#define S_RX_POLARITY_INV 28
-#define M_RX_POLARITY_INV 0xfU
-#define V_RX_POLARITY_INV(x) ((x) << S_RX_POLARITY_INV)
-#define G_RX_POLARITY_INV(x) (((x) >> S_RX_POLARITY_INV) & M_RX_POLARITY_INV)
-
-#define S_TX_POLARITY_INV 24
-#define M_TX_POLARITY_INV 0xfU
-#define V_TX_POLARITY_INV(x) ((x) << S_TX_POLARITY_INV)
-#define G_TX_POLARITY_INV(x) (((x) >> S_TX_POLARITY_INV) & M_TX_POLARITY_INV)
-
-#define S_INSTANCENUM 22
-#define M_INSTANCENUM 0x3U
-#define V_INSTANCENUM(x) ((x) << S_INSTANCENUM)
-#define G_INSTANCENUM(x) (((x) >> S_INSTANCENUM) & M_INSTANCENUM)
-
-#define S_STOPONPERR 21
-#define V_STOPONPERR(x) ((x) << S_STOPONPERR)
-#define F_STOPONPERR V_STOPONPERR(1U)
-
-#define S_MACTXEN 20
-#define V_MACTXEN(x) ((x) << S_MACTXEN)
-#define F_MACTXEN V_MACTXEN(1U)
-
-#define S_MACRXEN 19
-#define V_MACRXEN(x) ((x) << S_MACRXEN)
-#define F_MACRXEN V_MACRXEN(1U)
-
-#define S_PATEN 18
-#define V_PATEN(x) ((x) << S_PATEN)
-#define F_PATEN V_PATEN(1U)
-
-#define S_MAGICEN 17
-#define V_MAGICEN(x) ((x) << S_MAGICEN)
-#define F_MAGICEN V_MAGICEN(1U)
-
-#define S_TX_IPG 4
-#define M_TX_IPG 0x1fffU
-#define V_TX_IPG(x) ((x) << S_TX_IPG)
-#define G_TX_IPG(x) (((x) >> S_TX_IPG) & M_TX_IPG)
-
-#define S_AEC_PMA_TX_READY 1
-#define V_AEC_PMA_TX_READY(x) ((x) << S_AEC_PMA_TX_READY)
-#define F_AEC_PMA_TX_READY V_AEC_PMA_TX_READY(1U)
-
-#define S_AEC_PMA_RX_READY 0
-#define V_AEC_PMA_RX_READY(x) ((x) << S_AEC_PMA_RX_READY)
-#define F_AEC_PMA_RX_READY V_AEC_PMA_RX_READY(1U)
-
-#define A_XGMAC_PORT_PKT_COUNT 0x101c
-
-#define S_TX_SOP_COUNT 24
-#define M_TX_SOP_COUNT 0xffU
-#define V_TX_SOP_COUNT(x) ((x) << S_TX_SOP_COUNT)
-#define G_TX_SOP_COUNT(x) (((x) >> S_TX_SOP_COUNT) & M_TX_SOP_COUNT)
-
-#define S_TX_EOP_COUNT 16
-#define M_TX_EOP_COUNT 0xffU
-#define V_TX_EOP_COUNT(x) ((x) << S_TX_EOP_COUNT)
-#define G_TX_EOP_COUNT(x) (((x) >> S_TX_EOP_COUNT) & M_TX_EOP_COUNT)
-
-#define S_RX_SOP_COUNT 8
-#define M_RX_SOP_COUNT 0xffU
-#define V_RX_SOP_COUNT(x) ((x) << S_RX_SOP_COUNT)
-#define G_RX_SOP_COUNT(x) (((x) >> S_RX_SOP_COUNT) & M_RX_SOP_COUNT)
-
-#define S_RX_EOP_COUNT 0
-#define M_RX_EOP_COUNT 0xffU
-#define V_RX_EOP_COUNT(x) ((x) << S_RX_EOP_COUNT)
-#define G_RX_EOP_COUNT(x) (((x) >> S_RX_EOP_COUNT) & M_RX_EOP_COUNT)
-
-#define A_XGMAC_PORT_PERR_INJECT 0x1020
-
-#define S_XGMMEMSEL 1
-#define V_XGMMEMSEL(x) ((x) << S_XGMMEMSEL)
-#define F_XGMMEMSEL V_XGMMEMSEL(1U)
-
-#define A_XGMAC_PORT_MAGIC_MACID_LO 0x1024
-#define A_XGMAC_PORT_MAGIC_MACID_HI 0x1028
-
-#define S_MAC_WOL_DA 0
-#define M_MAC_WOL_DA 0xffffU
-#define V_MAC_WOL_DA(x) ((x) << S_MAC_WOL_DA)
-#define G_MAC_WOL_DA(x) (((x) >> S_MAC_WOL_DA) & M_MAC_WOL_DA)
-
-#define A_XGMAC_PORT_BUILD_REVISION 0x102c
-#define A_XGMAC_PORT_XGMII_SE_COUNT 0x1030
-
-#define S_TXSOP 24
-#define M_TXSOP 0xffU
-#define V_TXSOP(x) ((x) << S_TXSOP)
-#define G_TXSOP(x) (((x) >> S_TXSOP) & M_TXSOP)
-
-#define S_TXEOP 16
-#define M_TXEOP 0xffU
-#define V_TXEOP(x) ((x) << S_TXEOP)
-#define G_TXEOP(x) (((x) >> S_TXEOP) & M_TXEOP)
-
-#define S_RXSOP 8
-#define M_RXSOP 0xffU
-#define V_RXSOP(x) ((x) << S_RXSOP)
-#define G_RXSOP(x) (((x) >> S_RXSOP) & M_RXSOP)
-
-#define S_T4_RXEOP 0
-#define M_T4_RXEOP 0xffU
-#define V_T4_RXEOP(x) ((x) << S_T4_RXEOP)
-#define G_T4_RXEOP(x) (((x) >> S_T4_RXEOP) & M_T4_RXEOP)
-
-#define A_XGMAC_PORT_LINK_STATUS 0x1034
-
-#define S_REMFLT 3
-#define V_REMFLT(x) ((x) << S_REMFLT)
-#define F_REMFLT V_REMFLT(1U)
-
-#define S_LOCFLT 2
-#define V_LOCFLT(x) ((x) << S_LOCFLT)
-#define F_LOCFLT V_LOCFLT(1U)
-
-#define S_LINKUP 1
-#define V_LINKUP(x) ((x) << S_LINKUP)
-#define F_LINKUP V_LINKUP(1U)
-
-#define S_LINKDN 0
-#define V_LINKDN(x) ((x) << S_LINKDN)
-#define F_LINKDN V_LINKDN(1U)
-
-#define A_XGMAC_PORT_CHECKIN 0x1038
-
-#define S_PREAMBLE 1
-#define V_PREAMBLE(x) ((x) << S_PREAMBLE)
-#define F_PREAMBLE V_PREAMBLE(1U)
-
-#define S_CHECKIN 0
-#define V_CHECKIN(x) ((x) << S_CHECKIN)
-#define F_CHECKIN V_CHECKIN(1U)
-
-#define A_XGMAC_PORT_FAULT_TEST 0x103c
-
-#define S_FLTTYPE 1
-#define V_FLTTYPE(x) ((x) << S_FLTTYPE)
-#define F_FLTTYPE V_FLTTYPE(1U)
-
-#define S_FLTCTRL 0
-#define V_FLTCTRL(x) ((x) << S_FLTCTRL)
-#define F_FLTCTRL V_FLTCTRL(1U)
-
-#define A_XGMAC_PORT_SPARE 0x1040
-#define A_XGMAC_PORT_HSS_SIGDET_STATUS 0x1044
-
-#define S_SIGNALDETECT 0
-#define M_SIGNALDETECT 0xfU
-#define V_SIGNALDETECT(x) ((x) << S_SIGNALDETECT)
-#define G_SIGNALDETECT(x) (((x) >> S_SIGNALDETECT) & M_SIGNALDETECT)
-
-#define A_XGMAC_PORT_EXT_LOS_STATUS 0x1048
-#define A_XGMAC_PORT_EXT_LOS_CTRL 0x104c
-
-#define S_CTRL 0
-#define M_CTRL 0xfU
-#define V_CTRL(x) ((x) << S_CTRL)
-#define G_CTRL(x) (((x) >> S_CTRL) & M_CTRL)
-
-#define A_XGMAC_PORT_FPGA_PAUSE_CTL 0x1050
-
-#define S_CTL 31
-#define V_CTL(x) ((x) << S_CTL)
-#define F_CTL V_CTL(1U)
-
-#define S_HWM 13
-#define M_HWM 0x1fffU
-#define V_HWM(x) ((x) << S_HWM)
-#define G_HWM(x) (((x) >> S_HWM) & M_HWM)
-
-#define S_LWM 0
-#define M_LWM 0x1fffU
-#define V_LWM(x) ((x) << S_LWM)
-#define G_LWM(x) (((x) >> S_LWM) & M_LWM)
-
-#define A_XGMAC_PORT_FPGA_ERRPKT_CNT 0x1054
-#define A_XGMAC_PORT_LA_TX_0 0x1058
-#define A_XGMAC_PORT_LA_RX_0 0x105c
-#define A_XGMAC_PORT_FPGA_LA_CTL 0x1060
-
-#define S_RXRST 5
-#define V_RXRST(x) ((x) << S_RXRST)
-#define F_RXRST V_RXRST(1U)
-
-#define S_TXRST 4
-#define V_TXRST(x) ((x) << S_TXRST)
-#define F_TXRST V_TXRST(1U)
-
-#define S_XGMII 3
-#define V_XGMII(x) ((x) << S_XGMII)
-#define F_XGMII V_XGMII(1U)
-
-#define S_LAPAUSE 2
-#define V_LAPAUSE(x) ((x) << S_LAPAUSE)
-#define F_LAPAUSE V_LAPAUSE(1U)
-
-#define S_STOPERR 1
-#define V_STOPERR(x) ((x) << S_STOPERR)
-#define F_STOPERR V_STOPERR(1U)
-
-#define S_LASTOP 0
-#define V_LASTOP(x) ((x) << S_LASTOP)
-#define F_LASTOP V_LASTOP(1U)
-
-#define A_XGMAC_PORT_EPIO_DATA0 0x10c0
-#define A_XGMAC_PORT_EPIO_DATA1 0x10c4
-#define A_XGMAC_PORT_EPIO_DATA2 0x10c8
-#define A_XGMAC_PORT_EPIO_DATA3 0x10cc
-#define A_XGMAC_PORT_EPIO_OP 0x10d0
-
-#define S_EPIOWR 8
-#define V_EPIOWR(x) ((x) << S_EPIOWR)
-#define F_EPIOWR V_EPIOWR(1U)
-
-#define S_ADDRESS 0
-#define M_ADDRESS 0xffU
-#define V_ADDRESS(x) ((x) << S_ADDRESS)
-#define G_ADDRESS(x) (((x) >> S_ADDRESS) & M_ADDRESS)
-
-#define A_XGMAC_PORT_WOL_STATUS 0x10d4
-
-#define S_MAGICDETECTED 31
-#define V_MAGICDETECTED(x) ((x) << S_MAGICDETECTED)
-#define F_MAGICDETECTED V_MAGICDETECTED(1U)
-
-#define S_PATDETECTED 30
-#define V_PATDETECTED(x) ((x) << S_PATDETECTED)
-#define F_PATDETECTED V_PATDETECTED(1U)
-
-#define S_CLEARMAGIC 4
-#define V_CLEARMAGIC(x) ((x) << S_CLEARMAGIC)
-#define F_CLEARMAGIC V_CLEARMAGIC(1U)
-
-#define S_CLEARMATCH 3
-#define V_CLEARMATCH(x) ((x) << S_CLEARMATCH)
-#define F_CLEARMATCH V_CLEARMATCH(1U)
-
-#define S_MATCHEDFILTER 0
-#define M_MATCHEDFILTER 0x7U
-#define V_MATCHEDFILTER(x) ((x) << S_MATCHEDFILTER)
-#define G_MATCHEDFILTER(x) (((x) >> S_MATCHEDFILTER) & M_MATCHEDFILTER)
-
-#define A_XGMAC_PORT_INT_EN 0x10d8
-
-#define S_EXT_LOS 28
-#define V_EXT_LOS(x) ((x) << S_EXT_LOS)
-#define F_EXT_LOS V_EXT_LOS(1U)
-
-#define S_INCMPTBL_LINK 27
-#define V_INCMPTBL_LINK(x) ((x) << S_INCMPTBL_LINK)
-#define F_INCMPTBL_LINK V_INCMPTBL_LINK(1U)
-
-#define S_PATDETWAKE 26
-#define V_PATDETWAKE(x) ((x) << S_PATDETWAKE)
-#define F_PATDETWAKE V_PATDETWAKE(1U)
-
-#define S_MAGICWAKE 25
-#define V_MAGICWAKE(x) ((x) << S_MAGICWAKE)
-#define F_MAGICWAKE V_MAGICWAKE(1U)
-
-#define S_SIGDETCHG 24
-#define V_SIGDETCHG(x) ((x) << S_SIGDETCHG)
-#define F_SIGDETCHG V_SIGDETCHG(1U)
-
-#define S_PCSR_FEC_CORR 23
-#define V_PCSR_FEC_CORR(x) ((x) << S_PCSR_FEC_CORR)
-#define F_PCSR_FEC_CORR V_PCSR_FEC_CORR(1U)
-
-#define S_AE_TRAIN_LOCAL 22
-#define V_AE_TRAIN_LOCAL(x) ((x) << S_AE_TRAIN_LOCAL)
-#define F_AE_TRAIN_LOCAL V_AE_TRAIN_LOCAL(1U)
-
-#define S_HSSPLL_LOCK 21
-#define V_HSSPLL_LOCK(x) ((x) << S_HSSPLL_LOCK)
-#define F_HSSPLL_LOCK V_HSSPLL_LOCK(1U)
-
-#define S_HSSPRT_READY 20
-#define V_HSSPRT_READY(x) ((x) << S_HSSPRT_READY)
-#define F_HSSPRT_READY V_HSSPRT_READY(1U)
-
-#define S_AUTONEG_DONE 19
-#define V_AUTONEG_DONE(x) ((x) << S_AUTONEG_DONE)
-#define F_AUTONEG_DONE V_AUTONEG_DONE(1U)
-
-#define S_PCSR_HI_BER 18
-#define V_PCSR_HI_BER(x) ((x) << S_PCSR_HI_BER)
-#define F_PCSR_HI_BER V_PCSR_HI_BER(1U)
-
-#define S_PCSR_FEC_ERROR 17
-#define V_PCSR_FEC_ERROR(x) ((x) << S_PCSR_FEC_ERROR)
-#define F_PCSR_FEC_ERROR V_PCSR_FEC_ERROR(1U)
-
-#define S_PCSR_LINK_FAIL 16
-#define V_PCSR_LINK_FAIL(x) ((x) << S_PCSR_LINK_FAIL)
-#define F_PCSR_LINK_FAIL V_PCSR_LINK_FAIL(1U)
-
-#define S_XAUI_DEC_ERROR 15
-#define V_XAUI_DEC_ERROR(x) ((x) << S_XAUI_DEC_ERROR)
-#define F_XAUI_DEC_ERROR V_XAUI_DEC_ERROR(1U)
-
-#define S_XAUI_LINK_FAIL 14
-#define V_XAUI_LINK_FAIL(x) ((x) << S_XAUI_LINK_FAIL)
-#define F_XAUI_LINK_FAIL V_XAUI_LINK_FAIL(1U)
-
-#define S_PCS_CTC_ERROR 13
-#define V_PCS_CTC_ERROR(x) ((x) << S_PCS_CTC_ERROR)
-#define F_PCS_CTC_ERROR V_PCS_CTC_ERROR(1U)
-
-#define S_PCS_LINK_GOOD 12
-#define V_PCS_LINK_GOOD(x) ((x) << S_PCS_LINK_GOOD)
-#define F_PCS_LINK_GOOD V_PCS_LINK_GOOD(1U)
-
-#define S_PCS_LINK_FAIL 11
-#define V_PCS_LINK_FAIL(x) ((x) << S_PCS_LINK_FAIL)
-#define F_PCS_LINK_FAIL V_PCS_LINK_FAIL(1U)
-
-#define S_RXFIFOOVERFLOW 10
-#define V_RXFIFOOVERFLOW(x) ((x) << S_RXFIFOOVERFLOW)
-#define F_RXFIFOOVERFLOW V_RXFIFOOVERFLOW(1U)
-
-#define S_HSSPRBSERR 9
-#define V_HSSPRBSERR(x) ((x) << S_HSSPRBSERR)
-#define F_HSSPRBSERR V_HSSPRBSERR(1U)
-
-#define S_HSSEYEQUAL 8
-#define V_HSSEYEQUAL(x) ((x) << S_HSSEYEQUAL)
-#define F_HSSEYEQUAL V_HSSEYEQUAL(1U)
-
-#define S_REMOTEFAULT 7
-#define V_REMOTEFAULT(x) ((x) << S_REMOTEFAULT)
-#define F_REMOTEFAULT V_REMOTEFAULT(1U)
-
-#define S_LOCALFAULT 6
-#define V_LOCALFAULT(x) ((x) << S_LOCALFAULT)
-#define F_LOCALFAULT V_LOCALFAULT(1U)
-
-#define S_MAC_LINK_DOWN 5
-#define V_MAC_LINK_DOWN(x) ((x) << S_MAC_LINK_DOWN)
-#define F_MAC_LINK_DOWN V_MAC_LINK_DOWN(1U)
-
-#define S_MAC_LINK_UP 4
-#define V_MAC_LINK_UP(x) ((x) << S_MAC_LINK_UP)
-#define F_MAC_LINK_UP V_MAC_LINK_UP(1U)
-
-#define S_BEAN_INT 3
-#define V_BEAN_INT(x) ((x) << S_BEAN_INT)
-#define F_BEAN_INT V_BEAN_INT(1U)
-
-#define S_XGM_INT 2
-#define V_XGM_INT(x) ((x) << S_XGM_INT)
-#define F_XGM_INT V_XGM_INT(1U)
-
-#define A_XGMAC_PORT_INT_CAUSE 0x10dc
-#define A_XGMAC_PORT_HSS_CFG0 0x10e0
-
-#define S_TXDTS 31
-#define V_TXDTS(x) ((x) << S_TXDTS)
-#define F_TXDTS V_TXDTS(1U)
-
-#define S_TXCTS 30
-#define V_TXCTS(x) ((x) << S_TXCTS)
-#define F_TXCTS V_TXCTS(1U)
-
-#define S_TXBTS 29
-#define V_TXBTS(x) ((x) << S_TXBTS)
-#define F_TXBTS V_TXBTS(1U)
-
-#define S_TXATS 28
-#define V_TXATS(x) ((x) << S_TXATS)
-#define F_TXATS V_TXATS(1U)
-
-#define S_TXDOBS 27
-#define V_TXDOBS(x) ((x) << S_TXDOBS)
-#define F_TXDOBS V_TXDOBS(1U)
-
-#define S_TXCOBS 26
-#define V_TXCOBS(x) ((x) << S_TXCOBS)
-#define F_TXCOBS V_TXCOBS(1U)
-
-#define S_TXBOBS 25
-#define V_TXBOBS(x) ((x) << S_TXBOBS)
-#define F_TXBOBS V_TXBOBS(1U)
-
-#define S_TXAOBS 24
-#define V_TXAOBS(x) ((x) << S_TXAOBS)
-#define F_TXAOBS V_TXAOBS(1U)
-
-#define S_HSSREFCLKSEL 20
-#define V_HSSREFCLKSEL(x) ((x) << S_HSSREFCLKSEL)
-#define F_HSSREFCLKSEL V_HSSREFCLKSEL(1U)
-
-#define S_HSSAVDHI 17
-#define V_HSSAVDHI(x) ((x) << S_HSSAVDHI)
-#define F_HSSAVDHI V_HSSAVDHI(1U)
-
-#define S_HSSRXTS 16
-#define V_HSSRXTS(x) ((x) << S_HSSRXTS)
-#define F_HSSRXTS V_HSSRXTS(1U)
-
-#define S_HSSTXACMODE 15
-#define V_HSSTXACMODE(x) ((x) << S_HSSTXACMODE)
-#define F_HSSTXACMODE V_HSSTXACMODE(1U)
-
-#define S_HSSRXACMODE 14
-#define V_HSSRXACMODE(x) ((x) << S_HSSRXACMODE)
-#define F_HSSRXACMODE V_HSSRXACMODE(1U)
-
-#define S_HSSRESYNC 13
-#define V_HSSRESYNC(x) ((x) << S_HSSRESYNC)
-#define F_HSSRESYNC V_HSSRESYNC(1U)
-
-#define S_HSSRECCAL 12
-#define V_HSSRECCAL(x) ((x) << S_HSSRECCAL)
-#define F_HSSRECCAL V_HSSRECCAL(1U)
-
-#define S_HSSPDWNPLL 11
-#define V_HSSPDWNPLL(x) ((x) << S_HSSPDWNPLL)
-#define F_HSSPDWNPLL V_HSSPDWNPLL(1U)
-
-#define S_HSSDIVSEL 9
-#define M_HSSDIVSEL 0x3U
-#define V_HSSDIVSEL(x) ((x) << S_HSSDIVSEL)
-#define G_HSSDIVSEL(x) (((x) >> S_HSSDIVSEL) & M_HSSDIVSEL)
-
-#define S_HSSREFDIV 8
-#define V_HSSREFDIV(x) ((x) << S_HSSREFDIV)
-#define F_HSSREFDIV V_HSSREFDIV(1U)
-
-#define S_HSSPLLBYP 7
-#define V_HSSPLLBYP(x) ((x) << S_HSSPLLBYP)
-#define F_HSSPLLBYP V_HSSPLLBYP(1U)
-
-#define S_HSSLOFREQPLL 6
-#define V_HSSLOFREQPLL(x) ((x) << S_HSSLOFREQPLL)
-#define F_HSSLOFREQPLL V_HSSLOFREQPLL(1U)
-
-#define S_HSSLOFREQ2PLL 5
-#define V_HSSLOFREQ2PLL(x) ((x) << S_HSSLOFREQ2PLL)
-#define F_HSSLOFREQ2PLL V_HSSLOFREQ2PLL(1U)
-
-#define S_HSSEXTC16SEL 4
-#define V_HSSEXTC16SEL(x) ((x) << S_HSSEXTC16SEL)
-#define F_HSSEXTC16SEL V_HSSEXTC16SEL(1U)
-
-#define S_HSSRSTCONFIG 1
-#define M_HSSRSTCONFIG 0x7U
-#define V_HSSRSTCONFIG(x) ((x) << S_HSSRSTCONFIG)
-#define G_HSSRSTCONFIG(x) (((x) >> S_HSSRSTCONFIG) & M_HSSRSTCONFIG)
-
-#define S_HSSPRBSEN 0
-#define V_HSSPRBSEN(x) ((x) << S_HSSPRBSEN)
-#define F_HSSPRBSEN V_HSSPRBSEN(1U)
-
-#define A_XGMAC_PORT_HSS_CFG1 0x10e4
-
-#define S_RXDPRBSRST 28
-#define V_RXDPRBSRST(x) ((x) << S_RXDPRBSRST)
-#define F_RXDPRBSRST V_RXDPRBSRST(1U)
-
-#define S_RXDPRBSEN 27
-#define V_RXDPRBSEN(x) ((x) << S_RXDPRBSEN)
-#define F_RXDPRBSEN V_RXDPRBSEN(1U)
-
-#define S_RXDPRBSFRCERR 26
-#define V_RXDPRBSFRCERR(x) ((x) << S_RXDPRBSFRCERR)
-#define F_RXDPRBSFRCERR V_RXDPRBSFRCERR(1U)
-
-#define S_TXDPRBSRST 25
-#define V_TXDPRBSRST(x) ((x) << S_TXDPRBSRST)
-#define F_TXDPRBSRST V_TXDPRBSRST(1U)
-
-#define S_TXDPRBSEN 24
-#define V_TXDPRBSEN(x) ((x) << S_TXDPRBSEN)
-#define F_TXDPRBSEN V_TXDPRBSEN(1U)
-
-#define S_RXCPRBSRST 20
-#define V_RXCPRBSRST(x) ((x) << S_RXCPRBSRST)
-#define F_RXCPRBSRST V_RXCPRBSRST(1U)
-
-#define S_RXCPRBSEN 19
-#define V_RXCPRBSEN(x) ((x) << S_RXCPRBSEN)
-#define F_RXCPRBSEN V_RXCPRBSEN(1U)
-
-#define S_RXCPRBSFRCERR 18
-#define V_RXCPRBSFRCERR(x) ((x) << S_RXCPRBSFRCERR)
-#define F_RXCPRBSFRCERR V_RXCPRBSFRCERR(1U)
-
-#define S_TXCPRBSRST 17
-#define V_TXCPRBSRST(x) ((x) << S_TXCPRBSRST)
-#define F_TXCPRBSRST V_TXCPRBSRST(1U)
-
-#define S_TXCPRBSEN 16
-#define V_TXCPRBSEN(x) ((x) << S_TXCPRBSEN)
-#define F_TXCPRBSEN V_TXCPRBSEN(1U)
-
-#define S_RXBPRBSRST 12
-#define V_RXBPRBSRST(x) ((x) << S_RXBPRBSRST)
-#define F_RXBPRBSRST V_RXBPRBSRST(1U)
-
-#define S_RXBPRBSEN 11
-#define V_RXBPRBSEN(x) ((x) << S_RXBPRBSEN)
-#define F_RXBPRBSEN V_RXBPRBSEN(1U)
-
-#define S_RXBPRBSFRCERR 10
-#define V_RXBPRBSFRCERR(x) ((x) << S_RXBPRBSFRCERR)
-#define F_RXBPRBSFRCERR V_RXBPRBSFRCERR(1U)
-
-#define S_TXBPRBSRST 9
-#define V_TXBPRBSRST(x) ((x) << S_TXBPRBSRST)
-#define F_TXBPRBSRST V_TXBPRBSRST(1U)
-
-#define S_TXBPRBSEN 8
-#define V_TXBPRBSEN(x) ((x) << S_TXBPRBSEN)
-#define F_TXBPRBSEN V_TXBPRBSEN(1U)
-
-#define S_RXAPRBSRST 4
-#define V_RXAPRBSRST(x) ((x) << S_RXAPRBSRST)
-#define F_RXAPRBSRST V_RXAPRBSRST(1U)
-
-#define S_RXAPRBSEN 3
-#define V_RXAPRBSEN(x) ((x) << S_RXAPRBSEN)
-#define F_RXAPRBSEN V_RXAPRBSEN(1U)
-
-#define S_RXAPRBSFRCERR 2
-#define V_RXAPRBSFRCERR(x) ((x) << S_RXAPRBSFRCERR)
-#define F_RXAPRBSFRCERR V_RXAPRBSFRCERR(1U)
-
-#define S_TXAPRBSRST 1
-#define V_TXAPRBSRST(x) ((x) << S_TXAPRBSRST)
-#define F_TXAPRBSRST V_TXAPRBSRST(1U)
-
-#define S_TXAPRBSEN 0
-#define V_TXAPRBSEN(x) ((x) << S_TXAPRBSEN)
-#define F_TXAPRBSEN V_TXAPRBSEN(1U)
-
-#define A_XGMAC_PORT_HSS_CFG2 0x10e8
-
-#define S_RXDDATASYNC 23
-#define V_RXDDATASYNC(x) ((x) << S_RXDDATASYNC)
-#define F_RXDDATASYNC V_RXDDATASYNC(1U)
-
-#define S_RXCDATASYNC 22
-#define V_RXCDATASYNC(x) ((x) << S_RXCDATASYNC)
-#define F_RXCDATASYNC V_RXCDATASYNC(1U)
-
-#define S_RXBDATASYNC 21
-#define V_RXBDATASYNC(x) ((x) << S_RXBDATASYNC)
-#define F_RXBDATASYNC V_RXBDATASYNC(1U)
-
-#define S_RXADATASYNC 20
-#define V_RXADATASYNC(x) ((x) << S_RXADATASYNC)
-#define F_RXADATASYNC V_RXADATASYNC(1U)
-
-#define S_RXDEARLYIN 19
-#define V_RXDEARLYIN(x) ((x) << S_RXDEARLYIN)
-#define F_RXDEARLYIN V_RXDEARLYIN(1U)
-
-#define S_RXDLATEIN 18
-#define V_RXDLATEIN(x) ((x) << S_RXDLATEIN)
-#define F_RXDLATEIN V_RXDLATEIN(1U)
-
-#define S_RXDPHSLOCK 17
-#define V_RXDPHSLOCK(x) ((x) << S_RXDPHSLOCK)
-#define F_RXDPHSLOCK V_RXDPHSLOCK(1U)
-
-#define S_RXDPHSDNIN 16
-#define V_RXDPHSDNIN(x) ((x) << S_RXDPHSDNIN)
-#define F_RXDPHSDNIN V_RXDPHSDNIN(1U)
-
-#define S_RXDPHSUPIN 15
-#define V_RXDPHSUPIN(x) ((x) << S_RXDPHSUPIN)
-#define F_RXDPHSUPIN V_RXDPHSUPIN(1U)
-
-#define S_RXCEARLYIN 14
-#define V_RXCEARLYIN(x) ((x) << S_RXCEARLYIN)
-#define F_RXCEARLYIN V_RXCEARLYIN(1U)
-
-#define S_RXCLATEIN 13
-#define V_RXCLATEIN(x) ((x) << S_RXCLATEIN)
-#define F_RXCLATEIN V_RXCLATEIN(1U)
-
-#define S_RXCPHSLOCK 12
-#define V_RXCPHSLOCK(x) ((x) << S_RXCPHSLOCK)
-#define F_RXCPHSLOCK V_RXCPHSLOCK(1U)
-
-#define S_RXCPHSDNIN 11
-#define V_RXCPHSDNIN(x) ((x) << S_RXCPHSDNIN)
-#define F_RXCPHSDNIN V_RXCPHSDNIN(1U)
-
-#define S_RXCPHSUPIN 10
-#define V_RXCPHSUPIN(x) ((x) << S_RXCPHSUPIN)
-#define F_RXCPHSUPIN V_RXCPHSUPIN(1U)
-
-#define S_RXBEARLYIN 9
-#define V_RXBEARLYIN(x) ((x) << S_RXBEARLYIN)
-#define F_RXBEARLYIN V_RXBEARLYIN(1U)
-
-#define S_RXBLATEIN 8
-#define V_RXBLATEIN(x) ((x) << S_RXBLATEIN)
-#define F_RXBLATEIN V_RXBLATEIN(1U)
-
-#define S_RXBPHSLOCK 7
-#define V_RXBPHSLOCK(x) ((x) << S_RXBPHSLOCK)
-#define F_RXBPHSLOCK V_RXBPHSLOCK(1U)
-
-#define S_RXBPHSDNIN 6
-#define V_RXBPHSDNIN(x) ((x) << S_RXBPHSDNIN)
-#define F_RXBPHSDNIN V_RXBPHSDNIN(1U)
-
-#define S_RXBPHSUPIN 5
-#define V_RXBPHSUPIN(x) ((x) << S_RXBPHSUPIN)
-#define F_RXBPHSUPIN V_RXBPHSUPIN(1U)
-
-#define S_RXAEARLYIN 4
-#define V_RXAEARLYIN(x) ((x) << S_RXAEARLYIN)
-#define F_RXAEARLYIN V_RXAEARLYIN(1U)
-
-#define S_RXALATEIN 3
-#define V_RXALATEIN(x) ((x) << S_RXALATEIN)
-#define F_RXALATEIN V_RXALATEIN(1U)
-
-#define S_RXAPHSLOCK 2
-#define V_RXAPHSLOCK(x) ((x) << S_RXAPHSLOCK)
-#define F_RXAPHSLOCK V_RXAPHSLOCK(1U)
-
-#define S_RXAPHSDNIN 1
-#define V_RXAPHSDNIN(x) ((x) << S_RXAPHSDNIN)
-#define F_RXAPHSDNIN V_RXAPHSDNIN(1U)
-
-#define S_RXAPHSUPIN 0
-#define V_RXAPHSUPIN(x) ((x) << S_RXAPHSUPIN)
-#define F_RXAPHSUPIN V_RXAPHSUPIN(1U)
-
-#define A_XGMAC_PORT_HSS_STATUS 0x10ec
-
-#define S_RXDPRBSSYNC 15
-#define V_RXDPRBSSYNC(x) ((x) << S_RXDPRBSSYNC)
-#define F_RXDPRBSSYNC V_RXDPRBSSYNC(1U)
-
-#define S_RXCPRBSSYNC 14
-#define V_RXCPRBSSYNC(x) ((x) << S_RXCPRBSSYNC)
-#define F_RXCPRBSSYNC V_RXCPRBSSYNC(1U)
-
-#define S_RXBPRBSSYNC 13
-#define V_RXBPRBSSYNC(x) ((x) << S_RXBPRBSSYNC)
-#define F_RXBPRBSSYNC V_RXBPRBSSYNC(1U)
-
-#define S_RXAPRBSSYNC 12
-#define V_RXAPRBSSYNC(x) ((x) << S_RXAPRBSSYNC)
-#define F_RXAPRBSSYNC V_RXAPRBSSYNC(1U)
-
-#define S_RXDPRBSERR 11
-#define V_RXDPRBSERR(x) ((x) << S_RXDPRBSERR)
-#define F_RXDPRBSERR V_RXDPRBSERR(1U)
-
-#define S_RXCPRBSERR 10
-#define V_RXCPRBSERR(x) ((x) << S_RXCPRBSERR)
-#define F_RXCPRBSERR V_RXCPRBSERR(1U)
-
-#define S_RXBPRBSERR 9
-#define V_RXBPRBSERR(x) ((x) << S_RXBPRBSERR)
-#define F_RXBPRBSERR V_RXBPRBSERR(1U)
-
-#define S_RXAPRBSERR 8
-#define V_RXAPRBSERR(x) ((x) << S_RXAPRBSERR)
-#define F_RXAPRBSERR V_RXAPRBSERR(1U)
-
-#define S_RXDSIGDET 7
-#define V_RXDSIGDET(x) ((x) << S_RXDSIGDET)
-#define F_RXDSIGDET V_RXDSIGDET(1U)
-
-#define S_RXCSIGDET 6
-#define V_RXCSIGDET(x) ((x) << S_RXCSIGDET)
-#define F_RXCSIGDET V_RXCSIGDET(1U)
-
-#define S_RXBSIGDET 5
-#define V_RXBSIGDET(x) ((x) << S_RXBSIGDET)
-#define F_RXBSIGDET V_RXBSIGDET(1U)
-
-#define S_RXASIGDET 4
-#define V_RXASIGDET(x) ((x) << S_RXASIGDET)
-#define F_RXASIGDET V_RXASIGDET(1U)
-
-#define S_HSSPLLLOCK 1
-#define V_HSSPLLLOCK(x) ((x) << S_HSSPLLLOCK)
-#define F_HSSPLLLOCK V_HSSPLLLOCK(1U)
-
-#define S_HSSPRTREADY 0
-#define V_HSSPRTREADY(x) ((x) << S_HSSPRTREADY)
-#define F_HSSPRTREADY V_HSSPRTREADY(1U)
-
-#define A_XGMAC_PORT_XGM_TX_CTRL 0x1200
-
-#define S_SENDPAUSE 2
-#define V_SENDPAUSE(x) ((x) << S_SENDPAUSE)
-#define F_SENDPAUSE V_SENDPAUSE(1U)
-
-#define S_SENDZEROPAUSE 1
-#define V_SENDZEROPAUSE(x) ((x) << S_SENDZEROPAUSE)
-#define F_SENDZEROPAUSE V_SENDZEROPAUSE(1U)
-
-#define S_XGM_TXEN 0
-#define V_XGM_TXEN(x) ((x) << S_XGM_TXEN)
-#define F_XGM_TXEN V_XGM_TXEN(1U)
-
-#define A_XGMAC_PORT_XGM_TX_CFG 0x1204
-
-#define S_CRCCAL 8
-#define M_CRCCAL 0x3U
-#define V_CRCCAL(x) ((x) << S_CRCCAL)
-#define G_CRCCAL(x) (((x) >> S_CRCCAL) & M_CRCCAL)
-
-#define S_DISDEFIDLECNT 7
-#define V_DISDEFIDLECNT(x) ((x) << S_DISDEFIDLECNT)
-#define F_DISDEFIDLECNT V_DISDEFIDLECNT(1U)
-
-#define S_DECAVGTXIPG 6
-#define V_DECAVGTXIPG(x) ((x) << S_DECAVGTXIPG)
-#define F_DECAVGTXIPG V_DECAVGTXIPG(1U)
-
-#define S_UNIDIRTXEN 5
-#define V_UNIDIRTXEN(x) ((x) << S_UNIDIRTXEN)
-#define F_UNIDIRTXEN V_UNIDIRTXEN(1U)
-
-#define S_CFGCLKSPEED 2
-#define M_CFGCLKSPEED 0x7U
-#define V_CFGCLKSPEED(x) ((x) << S_CFGCLKSPEED)
-#define G_CFGCLKSPEED(x) (((x) >> S_CFGCLKSPEED) & M_CFGCLKSPEED)
-
-#define S_STRETCHMODE 1
-#define V_STRETCHMODE(x) ((x) << S_STRETCHMODE)
-#define F_STRETCHMODE V_STRETCHMODE(1U)
-
-#define S_TXPAUSEEN 0
-#define V_TXPAUSEEN(x) ((x) << S_TXPAUSEEN)
-#define F_TXPAUSEEN V_TXPAUSEEN(1U)
-
-#define A_XGMAC_PORT_XGM_TX_PAUSE_QUANTA 0x1208
-
-#define S_TXPAUSEQUANTA 0
-#define M_TXPAUSEQUANTA 0xffffU
-#define V_TXPAUSEQUANTA(x) ((x) << S_TXPAUSEQUANTA)
-#define G_TXPAUSEQUANTA(x) (((x) >> S_TXPAUSEQUANTA) & M_TXPAUSEQUANTA)
-
-#define A_XGMAC_PORT_XGM_RX_CTRL 0x120c
-#define A_XGMAC_PORT_XGM_RX_CFG 0x1210
-
-#define S_RXCRCCAL 16
-#define M_RXCRCCAL 0x3U
-#define V_RXCRCCAL(x) ((x) << S_RXCRCCAL)
-#define G_RXCRCCAL(x) (((x) >> S_RXCRCCAL) & M_RXCRCCAL)
-
-#define S_STATLOCALFAULT 15
-#define V_STATLOCALFAULT(x) ((x) << S_STATLOCALFAULT)
-#define F_STATLOCALFAULT V_STATLOCALFAULT(1U)
-
-#define S_STATREMOTEFAULT 14
-#define V_STATREMOTEFAULT(x) ((x) << S_STATREMOTEFAULT)
-#define F_STATREMOTEFAULT V_STATREMOTEFAULT(1U)
-
-#define S_LENERRFRAMEDIS 13
-#define V_LENERRFRAMEDIS(x) ((x) << S_LENERRFRAMEDIS)
-#define F_LENERRFRAMEDIS V_LENERRFRAMEDIS(1U)
-
-#define S_CON802_3PREAMBLE 12
-#define V_CON802_3PREAMBLE(x) ((x) << S_CON802_3PREAMBLE)
-#define F_CON802_3PREAMBLE V_CON802_3PREAMBLE(1U)
-
-#define S_ENNON802_3PREAMBLE 11
-#define V_ENNON802_3PREAMBLE(x) ((x) << S_ENNON802_3PREAMBLE)
-#define F_ENNON802_3PREAMBLE V_ENNON802_3PREAMBLE(1U)
-
-#define S_COPYPREAMBLE 10
-#define V_COPYPREAMBLE(x) ((x) << S_COPYPREAMBLE)
-#define F_COPYPREAMBLE V_COPYPREAMBLE(1U)
-
-#define S_DISPAUSEFRAMES 9
-#define V_DISPAUSEFRAMES(x) ((x) << S_DISPAUSEFRAMES)
-#define F_DISPAUSEFRAMES V_DISPAUSEFRAMES(1U)
-
-#define S_EN1536BFRAMES 8
-#define V_EN1536BFRAMES(x) ((x) << S_EN1536BFRAMES)
-#define F_EN1536BFRAMES V_EN1536BFRAMES(1U)
-
-#define S_ENJUMBO 7
-#define V_ENJUMBO(x) ((x) << S_ENJUMBO)
-#define F_ENJUMBO V_ENJUMBO(1U)
-
-#define S_RMFCS 6
-#define V_RMFCS(x) ((x) << S_RMFCS)
-#define F_RMFCS V_RMFCS(1U)
-
-#define S_DISNONVLAN 5
-#define V_DISNONVLAN(x) ((x) << S_DISNONVLAN)
-#define F_DISNONVLAN V_DISNONVLAN(1U)
-
-#define S_ENEXTMATCH 4
-#define V_ENEXTMATCH(x) ((x) << S_ENEXTMATCH)
-#define F_ENEXTMATCH V_ENEXTMATCH(1U)
-
-#define S_ENHASHUCAST 3
-#define V_ENHASHUCAST(x) ((x) << S_ENHASHUCAST)
-#define F_ENHASHUCAST V_ENHASHUCAST(1U)
-
-#define S_ENHASHMCAST 2
-#define V_ENHASHMCAST(x) ((x) << S_ENHASHMCAST)
-#define F_ENHASHMCAST V_ENHASHMCAST(1U)
-
-#define S_DISBCAST 1
-#define V_DISBCAST(x) ((x) << S_DISBCAST)
-#define F_DISBCAST V_DISBCAST(1U)
-
-#define S_COPYALLFRAMES 0
-#define V_COPYALLFRAMES(x) ((x) << S_COPYALLFRAMES)
-#define F_COPYALLFRAMES V_COPYALLFRAMES(1U)
-
-#define A_XGMAC_PORT_XGM_RX_HASH_LOW 0x1214
-#define A_XGMAC_PORT_XGM_RX_HASH_HIGH 0x1218
-#define A_XGMAC_PORT_XGM_RX_EXACT_MATCH_LOW_1 0x121c
-#define A_XGMAC_PORT_XGM_RX_EXACT_MATCH_HIGH_1 0x1220
-
-#define S_ADDRESS_HIGH 0
-#define M_ADDRESS_HIGH 0xffffU
-#define V_ADDRESS_HIGH(x) ((x) << S_ADDRESS_HIGH)
-#define G_ADDRESS_HIGH(x) (((x) >> S_ADDRESS_HIGH) & M_ADDRESS_HIGH)
-
-#define A_XGMAC_PORT_XGM_RX_EXACT_MATCH_LOW_2 0x1224
-#define A_XGMAC_PORT_XGM_RX_EXACT_MATCH_HIGH_2 0x1228
-#define A_XGMAC_PORT_XGM_RX_EXACT_MATCH_LOW_3 0x122c
-#define A_XGMAC_PORT_XGM_RX_EXACT_MATCH_HIGH_3 0x1230
-#define A_XGMAC_PORT_XGM_RX_EXACT_MATCH_LOW_4 0x1234
-#define A_XGMAC_PORT_XGM_RX_EXACT_MATCH_HIGH_4 0x1238
-#define A_XGMAC_PORT_XGM_RX_EXACT_MATCH_LOW_5 0x123c
-#define A_XGMAC_PORT_XGM_RX_EXACT_MATCH_HIGH_5 0x1240
-#define A_XGMAC_PORT_XGM_RX_EXACT_MATCH_LOW_6 0x1244
-#define A_XGMAC_PORT_XGM_RX_EXACT_MATCH_HIGH_6 0x1248
-#define A_XGMAC_PORT_XGM_RX_EXACT_MATCH_LOW_7 0x124c
-#define A_XGMAC_PORT_XGM_RX_EXACT_MATCH_HIGH_7 0x1250
-#define A_XGMAC_PORT_XGM_RX_EXACT_MATCH_LOW_8 0x1254
-#define A_XGMAC_PORT_XGM_RX_EXACT_MATCH_HIGH_8 0x1258
-#define A_XGMAC_PORT_XGM_RX_TYPE_MATCH_1 0x125c
-
-#define S_ENTYPEMATCH 31
-#define V_ENTYPEMATCH(x) ((x) << S_ENTYPEMATCH)
-#define F_ENTYPEMATCH V_ENTYPEMATCH(1U)
-
-#define S_TYPE 0
-#define M_TYPE 0xffffU
-#define V_TYPE(x) ((x) << S_TYPE)
-#define G_TYPE(x) (((x) >> S_TYPE) & M_TYPE)
-
-#define A_XGMAC_PORT_XGM_RX_TYPE_MATCH_2 0x1260
-#define A_XGMAC_PORT_XGM_RX_TYPE_MATCH_3 0x1264
-#define A_XGMAC_PORT_XGM_RX_TYPE_MATCH_4 0x1268
-#define A_XGMAC_PORT_XGM_INT_STATUS 0x126c
-
-#define S_XGMIIEXTINT 10
-#define V_XGMIIEXTINT(x) ((x) << S_XGMIIEXTINT)
-#define F_XGMIIEXTINT V_XGMIIEXTINT(1U)
-
-#define S_LINKFAULTCHANGE 9
-#define V_LINKFAULTCHANGE(x) ((x) << S_LINKFAULTCHANGE)
-#define F_LINKFAULTCHANGE V_LINKFAULTCHANGE(1U)
-
-#define S_PHYFRAMECOMPLETE 8
-#define V_PHYFRAMECOMPLETE(x) ((x) << S_PHYFRAMECOMPLETE)
-#define F_PHYFRAMECOMPLETE V_PHYFRAMECOMPLETE(1U)
-
-#define S_PAUSEFRAMETXMT 7
-#define V_PAUSEFRAMETXMT(x) ((x) << S_PAUSEFRAMETXMT)
-#define F_PAUSEFRAMETXMT V_PAUSEFRAMETXMT(1U)
-
-#define S_PAUSECNTRTIMEOUT 6
-#define V_PAUSECNTRTIMEOUT(x) ((x) << S_PAUSECNTRTIMEOUT)
-#define F_PAUSECNTRTIMEOUT V_PAUSECNTRTIMEOUT(1U)
-
-#define S_NON0PAUSERCVD 5
-#define V_NON0PAUSERCVD(x) ((x) << S_NON0PAUSERCVD)
-#define F_NON0PAUSERCVD V_NON0PAUSERCVD(1U)
-
-#define S_STATOFLOW 4
-#define V_STATOFLOW(x) ((x) << S_STATOFLOW)
-#define F_STATOFLOW V_STATOFLOW(1U)
-
-#define S_TXERRFIFO 3
-#define V_TXERRFIFO(x) ((x) << S_TXERRFIFO)
-#define F_TXERRFIFO V_TXERRFIFO(1U)
-
-#define S_TXUFLOW 2
-#define V_TXUFLOW(x) ((x) << S_TXUFLOW)
-#define F_TXUFLOW V_TXUFLOW(1U)
-
-#define S_FRAMETXMT 1
-#define V_FRAMETXMT(x) ((x) << S_FRAMETXMT)
-#define F_FRAMETXMT V_FRAMETXMT(1U)
-
-#define S_FRAMERCVD 0
-#define V_FRAMERCVD(x) ((x) << S_FRAMERCVD)
-#define F_FRAMERCVD V_FRAMERCVD(1U)
-
-#define A_XGMAC_PORT_XGM_INT_MASK 0x1270
-#define A_XGMAC_PORT_XGM_INT_EN 0x1274
-#define A_XGMAC_PORT_XGM_INT_DISABLE 0x1278
-#define A_XGMAC_PORT_XGM_TX_PAUSE_TIMER 0x127c
-
-#define S_CURPAUSETIMER 0
-#define M_CURPAUSETIMER 0xffffU
-#define V_CURPAUSETIMER(x) ((x) << S_CURPAUSETIMER)
-#define G_CURPAUSETIMER(x) (((x) >> S_CURPAUSETIMER) & M_CURPAUSETIMER)
-
-#define A_XGMAC_PORT_XGM_STAT_CTRL 0x1280
-
-#define S_READSNPSHOT 4
-#define V_READSNPSHOT(x) ((x) << S_READSNPSHOT)
-#define F_READSNPSHOT V_READSNPSHOT(1U)
-
-#define S_TAKESNPSHOT 3
-#define V_TAKESNPSHOT(x) ((x) << S_TAKESNPSHOT)
-#define F_TAKESNPSHOT V_TAKESNPSHOT(1U)
-
-#define S_CLRSTATS 2
-#define V_CLRSTATS(x) ((x) << S_CLRSTATS)
-#define F_CLRSTATS V_CLRSTATS(1U)
-
-#define S_INCRSTATS 1
-#define V_INCRSTATS(x) ((x) << S_INCRSTATS)
-#define F_INCRSTATS V_INCRSTATS(1U)
-
-#define S_ENTESTMODEWR 0
-#define V_ENTESTMODEWR(x) ((x) << S_ENTESTMODEWR)
-#define F_ENTESTMODEWR V_ENTESTMODEWR(1U)
-
-#define A_XGMAC_PORT_XGM_MDIO_CTRL 0x1284
-
-#define S_FRAMETYPE 30
-#define M_FRAMETYPE 0x3U
-#define V_FRAMETYPE(x) ((x) << S_FRAMETYPE)
-#define G_FRAMETYPE(x) (((x) >> S_FRAMETYPE) & M_FRAMETYPE)
-
-#define S_OPERATION 28
-#define M_OPERATION 0x3U
-#define V_OPERATION(x) ((x) << S_OPERATION)
-#define G_OPERATION(x) (((x) >> S_OPERATION) & M_OPERATION)
-
-#define S_PORTADDR 23
-#define M_PORTADDR 0x1fU
-#define V_PORTADDR(x) ((x) << S_PORTADDR)
-#define G_PORTADDR(x) (((x) >> S_PORTADDR) & M_PORTADDR)
-
-#define S_DEVADDR 18
-#define M_DEVADDR 0x1fU
-#define V_DEVADDR(x) ((x) << S_DEVADDR)
-#define G_DEVADDR(x) (((x) >> S_DEVADDR) & M_DEVADDR)
-
-#define S_RESRV 16
-#define M_RESRV 0x3U
-#define V_RESRV(x) ((x) << S_RESRV)
-#define G_RESRV(x) (((x) >> S_RESRV) & M_RESRV)
-
-#define S_DATA 0
-#define M_DATA 0xffffU
-#define V_DATA(x) ((x) << S_DATA)
-#define G_DATA(x) (((x) >> S_DATA) & M_DATA)
-
-#define A_XGMAC_PORT_XGM_MODULE_ID 0x12fc
-
-#define S_MODULEID 16
-#define M_MODULEID 0xffffU
-#define V_MODULEID(x) ((x) << S_MODULEID)
-#define G_MODULEID(x) (((x) >> S_MODULEID) & M_MODULEID)
-
-#define S_MODULEREV 0
-#define M_MODULEREV 0xffffU
-#define V_MODULEREV(x) ((x) << S_MODULEREV)
-#define G_MODULEREV(x) (((x) >> S_MODULEREV) & M_MODULEREV)
-
-#define A_XGMAC_PORT_XGM_STAT_TX_BYTE_LOW 0x1300
-#define A_XGMAC_PORT_XGM_STAT_TX_BYTE_HIGH 0x1304
-
-#define S_TXBYTES_HIGH 0
-#define M_TXBYTES_HIGH 0x1fffU
-#define V_TXBYTES_HIGH(x) ((x) << S_TXBYTES_HIGH)
-#define G_TXBYTES_HIGH(x) (((x) >> S_TXBYTES_HIGH) & M_TXBYTES_HIGH)
-
-#define A_XGMAC_PORT_XGM_STAT_TX_FRAME_LOW 0x1308
-#define A_XGMAC_PORT_XGM_STAT_TX_FRAME_HIGH 0x130c
-
-#define S_TXFRAMES_HIGH 0
-#define M_TXFRAMES_HIGH 0xfU
-#define V_TXFRAMES_HIGH(x) ((x) << S_TXFRAMES_HIGH)
-#define G_TXFRAMES_HIGH(x) (((x) >> S_TXFRAMES_HIGH) & M_TXFRAMES_HIGH)
-
-#define A_XGMAC_PORT_XGM_STAT_TX_BCAST 0x1310
-#define A_XGMAC_PORT_XGM_STAT_TX_MCAST 0x1314
-#define A_XGMAC_PORT_XGM_STAT_TX_PAUSE 0x1318
-#define A_XGMAC_PORT_XGM_STAT_TX_64B_FRAMES 0x131c
-#define A_XGMAC_PORT_XGM_STAT_TX_65_127B_FRAMES 0x1320
-#define A_XGMAC_PORT_XGM_STAT_TX_128_255B_FRAMES 0x1324
-#define A_XGMAC_PORT_XGM_STAT_TX_256_511B_FRAMES 0x1328
-#define A_XGMAC_PORT_XGM_STAT_TX_512_1023B_FRAMES 0x132c
-#define A_XGMAC_PORT_XGM_STAT_TX_1024_1518B_FRAMES 0x1330
-#define A_XGMAC_PORT_XGM_STAT_TX_1519_MAXB_FRAMES 0x1334
-#define A_XGMAC_PORT_XGM_STAT_TX_ERR_FRAMES 0x1338
-#define A_XGMAC_PORT_XGM_STAT_RX_BYTES_LOW 0x133c
-#define A_XGMAC_PORT_XGM_STAT_RX_BYTES_HIGH 0x1340
-
-#define S_RXBYTES_HIGH 0
-#define M_RXBYTES_HIGH 0x1fffU
-#define V_RXBYTES_HIGH(x) ((x) << S_RXBYTES_HIGH)
-#define G_RXBYTES_HIGH(x) (((x) >> S_RXBYTES_HIGH) & M_RXBYTES_HIGH)
-
-#define A_XGMAC_PORT_XGM_STAT_RX_FRAMES_LOW 0x1344
-#define A_XGMAC_PORT_XGM_STAT_RX_FRAMES_HIGH 0x1348
-
-#define S_RXFRAMES_HIGH 0
-#define M_RXFRAMES_HIGH 0xfU
-#define V_RXFRAMES_HIGH(x) ((x) << S_RXFRAMES_HIGH)
-#define G_RXFRAMES_HIGH(x) (((x) >> S_RXFRAMES_HIGH) & M_RXFRAMES_HIGH)
-
-#define A_XGMAC_PORT_XGM_STAT_RX_BCAST_FRAMES 0x134c
-#define A_XGMAC_PORT_XGM_STAT_RX_MCAST_FRAMES 0x1350
-#define A_XGMAC_PORT_XGM_STAT_RX_PAUSE_FRAMES 0x1354
-
-#define S_RXPAUSEFRAMES 0
-#define M_RXPAUSEFRAMES 0xffffU
-#define V_RXPAUSEFRAMES(x) ((x) << S_RXPAUSEFRAMES)
-#define G_RXPAUSEFRAMES(x) (((x) >> S_RXPAUSEFRAMES) & M_RXPAUSEFRAMES)
-
-#define A_XGMAC_PORT_XGM_STAT_RX_64B_FRAMES 0x1358
-#define A_XGMAC_PORT_XGM_STAT_RX_65_127B_FRAMES 0x135c
-#define A_XGMAC_PORT_XGM_STAT_RX_128_255B_FRAMES 0x1360
-#define A_XGMAC_PORT_XGM_STAT_RX_256_511B_FRAMES 0x1364
-#define A_XGMAC_PORT_XGM_STAT_RX_512_1023B_FRAMES 0x1368
-#define A_XGMAC_PORT_XGM_STAT_RX_1024_1518B_FRAMES 0x136c
-#define A_XGMAC_PORT_XGM_STAT_RX_1519_MAXB_FRAMES 0x1370
-#define A_XGMAC_PORT_XGM_STAT_RX_SHORT_FRAMES 0x1374
-
-#define S_RXSHORTFRAMES 0
-#define M_RXSHORTFRAMES 0xffffU
-#define V_RXSHORTFRAMES(x) ((x) << S_RXSHORTFRAMES)
-#define G_RXSHORTFRAMES(x) (((x) >> S_RXSHORTFRAMES) & M_RXSHORTFRAMES)
-
-#define A_XGMAC_PORT_XGM_STAT_RX_OVERSIZE_FRAMES 0x1378
-
-#define S_RXOVERSIZEFRAMES 0
-#define M_RXOVERSIZEFRAMES 0xffffU
-#define V_RXOVERSIZEFRAMES(x) ((x) << S_RXOVERSIZEFRAMES)
-#define G_RXOVERSIZEFRAMES(x) (((x) >> S_RXOVERSIZEFRAMES) & M_RXOVERSIZEFRAMES)
-
-#define A_XGMAC_PORT_XGM_STAT_RX_JABBER_FRAMES 0x137c
-
-#define S_RXJABBERFRAMES 0
-#define M_RXJABBERFRAMES 0xffffU
-#define V_RXJABBERFRAMES(x) ((x) << S_RXJABBERFRAMES)
-#define G_RXJABBERFRAMES(x) (((x) >> S_RXJABBERFRAMES) & M_RXJABBERFRAMES)
-
-#define A_XGMAC_PORT_XGM_STAT_RX_CRC_ERR_FRAMES 0x1380
-
-#define S_RXCRCERRFRAMES 0
-#define M_RXCRCERRFRAMES 0xffffU
-#define V_RXCRCERRFRAMES(x) ((x) << S_RXCRCERRFRAMES)
-#define G_RXCRCERRFRAMES(x) (((x) >> S_RXCRCERRFRAMES) & M_RXCRCERRFRAMES)
-
-#define A_XGMAC_PORT_XGM_STAT_RX_LENGTH_ERR_FRAMES 0x1384
-
-#define S_RXLENGTHERRFRAMES 0
-#define M_RXLENGTHERRFRAMES 0xffffU
-#define V_RXLENGTHERRFRAMES(x) ((x) << S_RXLENGTHERRFRAMES)
-#define G_RXLENGTHERRFRAMES(x) (((x) >> S_RXLENGTHERRFRAMES) & M_RXLENGTHERRFRAMES)
-
-#define A_XGMAC_PORT_XGM_STAT_RX_SYM_CODE_ERR_FRAMES 0x1388
-
-#define S_RXSYMCODEERRFRAMES 0
-#define M_RXSYMCODEERRFRAMES 0xffffU
-#define V_RXSYMCODEERRFRAMES(x) ((x) << S_RXSYMCODEERRFRAMES)
-#define G_RXSYMCODEERRFRAMES(x) (((x) >> S_RXSYMCODEERRFRAMES) & M_RXSYMCODEERRFRAMES)
-
-#define A_XGMAC_PORT_XAUI_CTRL 0x1400
-
-#define S_POLARITY_INV_RX 8
-#define M_POLARITY_INV_RX 0xfU
-#define V_POLARITY_INV_RX(x) ((x) << S_POLARITY_INV_RX)
-#define G_POLARITY_INV_RX(x) (((x) >> S_POLARITY_INV_RX) & M_POLARITY_INV_RX)
-
-#define S_POLARITY_INV_TX 4
-#define M_POLARITY_INV_TX 0xfU
-#define V_POLARITY_INV_TX(x) ((x) << S_POLARITY_INV_TX)
-#define G_POLARITY_INV_TX(x) (((x) >> S_POLARITY_INV_TX) & M_POLARITY_INV_TX)
-
-#define S_TEST_SEL 2
-#define M_TEST_SEL 0x3U
-#define V_TEST_SEL(x) ((x) << S_TEST_SEL)
-#define G_TEST_SEL(x) (((x) >> S_TEST_SEL) & M_TEST_SEL)
-
-#define S_TEST_EN 0
-#define V_TEST_EN(x) ((x) << S_TEST_EN)
-#define F_TEST_EN V_TEST_EN(1U)
-
-#define A_XGMAC_PORT_XAUI_STATUS 0x1404
-
-#define S_DECODE_ERROR 12
-#define M_DECODE_ERROR 0xffU
-#define V_DECODE_ERROR(x) ((x) << S_DECODE_ERROR)
-#define G_DECODE_ERROR(x) (((x) >> S_DECODE_ERROR) & M_DECODE_ERROR)
-
-#define S_LANE3_CTC_STATUS 11
-#define V_LANE3_CTC_STATUS(x) ((x) << S_LANE3_CTC_STATUS)
-#define F_LANE3_CTC_STATUS V_LANE3_CTC_STATUS(1U)
-
-#define S_LANE2_CTC_STATUS 10
-#define V_LANE2_CTC_STATUS(x) ((x) << S_LANE2_CTC_STATUS)
-#define F_LANE2_CTC_STATUS V_LANE2_CTC_STATUS(1U)
-
-#define S_LANE1_CTC_STATUS 9
-#define V_LANE1_CTC_STATUS(x) ((x) << S_LANE1_CTC_STATUS)
-#define F_LANE1_CTC_STATUS V_LANE1_CTC_STATUS(1U)
-
-#define S_LANE0_CTC_STATUS 8
-#define V_LANE0_CTC_STATUS(x) ((x) << S_LANE0_CTC_STATUS)
-#define F_LANE0_CTC_STATUS V_LANE0_CTC_STATUS(1U)
-
-#define S_ALIGN_STATUS 4
-#define V_ALIGN_STATUS(x) ((x) << S_ALIGN_STATUS)
-#define F_ALIGN_STATUS V_ALIGN_STATUS(1U)
-
-#define S_LANE3_SYNC_STATUS 3
-#define V_LANE3_SYNC_STATUS(x) ((x) << S_LANE3_SYNC_STATUS)
-#define F_LANE3_SYNC_STATUS V_LANE3_SYNC_STATUS(1U)
-
-#define S_LANE2_SYNC_STATUS 2
-#define V_LANE2_SYNC_STATUS(x) ((x) << S_LANE2_SYNC_STATUS)
-#define F_LANE2_SYNC_STATUS V_LANE2_SYNC_STATUS(1U)
-
-#define S_LANE1_SYNC_STATUS 1
-#define V_LANE1_SYNC_STATUS(x) ((x) << S_LANE1_SYNC_STATUS)
-#define F_LANE1_SYNC_STATUS V_LANE1_SYNC_STATUS(1U)
-
-#define S_LANE0_SYNC_STATUS 0
-#define V_LANE0_SYNC_STATUS(x) ((x) << S_LANE0_SYNC_STATUS)
-#define F_LANE0_SYNC_STATUS V_LANE0_SYNC_STATUS(1U)
-
-#define A_XGMAC_PORT_PCSR_CTRL 0x1500
-
-#define S_RX_CLK_SPEED 7
-#define V_RX_CLK_SPEED(x) ((x) << S_RX_CLK_SPEED)
-#define F_RX_CLK_SPEED V_RX_CLK_SPEED(1U)
-
-#define S_SCRBYPASS 6
-#define V_SCRBYPASS(x) ((x) << S_SCRBYPASS)
-#define F_SCRBYPASS V_SCRBYPASS(1U)
-
-#define S_FECERRINDEN 5
-#define V_FECERRINDEN(x) ((x) << S_FECERRINDEN)
-#define F_FECERRINDEN V_FECERRINDEN(1U)
-
-#define S_FECEN 4
-#define V_FECEN(x) ((x) << S_FECEN)
-#define F_FECEN V_FECEN(1U)
-
-#define S_TESTSEL 2
-#define M_TESTSEL 0x3U
-#define V_TESTSEL(x) ((x) << S_TESTSEL)
-#define G_TESTSEL(x) (((x) >> S_TESTSEL) & M_TESTSEL)
-
-#define S_SCRLOOPEN 1
-#define V_SCRLOOPEN(x) ((x) << S_SCRLOOPEN)
-#define F_SCRLOOPEN V_SCRLOOPEN(1U)
-
-#define S_XGMIILOOPEN 0
-#define V_XGMIILOOPEN(x) ((x) << S_XGMIILOOPEN)
-#define F_XGMIILOOPEN V_XGMIILOOPEN(1U)
-
-#define A_XGMAC_PORT_PCSR_TXTEST_CTRL 0x1510
-
-#define S_TX_PRBS9_EN 4
-#define V_TX_PRBS9_EN(x) ((x) << S_TX_PRBS9_EN)
-#define F_TX_PRBS9_EN V_TX_PRBS9_EN(1U)
-
-#define S_TX_PRBS31_EN 3
-#define V_TX_PRBS31_EN(x) ((x) << S_TX_PRBS31_EN)
-#define F_TX_PRBS31_EN V_TX_PRBS31_EN(1U)
-
-#define S_TX_TST_DAT_SEL 2
-#define V_TX_TST_DAT_SEL(x) ((x) << S_TX_TST_DAT_SEL)
-#define F_TX_TST_DAT_SEL V_TX_TST_DAT_SEL(1U)
-
-#define S_TX_TST_SEL 1
-#define V_TX_TST_SEL(x) ((x) << S_TX_TST_SEL)
-#define F_TX_TST_SEL V_TX_TST_SEL(1U)
-
-#define S_TX_TST_EN 0
-#define V_TX_TST_EN(x) ((x) << S_TX_TST_EN)
-#define F_TX_TST_EN V_TX_TST_EN(1U)
-
-#define A_XGMAC_PORT_PCSR_TXTEST_SEEDA_LOWER 0x1514
-#define A_XGMAC_PORT_PCSR_TXTEST_SEEDA_UPPER 0x1518
-
-#define S_SEEDA_UPPER 0
-#define M_SEEDA_UPPER 0x3ffffffU
-#define V_SEEDA_UPPER(x) ((x) << S_SEEDA_UPPER)
-#define G_SEEDA_UPPER(x) (((x) >> S_SEEDA_UPPER) & M_SEEDA_UPPER)
-
-#define A_XGMAC_PORT_PCSR_TXTEST_SEEDB_LOWER 0x152c
-#define A_XGMAC_PORT_PCSR_TXTEST_SEEDB_UPPER 0x1530
-
-#define S_SEEDB_UPPER 0
-#define M_SEEDB_UPPER 0x3ffffffU
-#define V_SEEDB_UPPER(x) ((x) << S_SEEDB_UPPER)
-#define G_SEEDB_UPPER(x) (((x) >> S_SEEDB_UPPER) & M_SEEDB_UPPER)
-
-#define A_XGMAC_PORT_PCSR_RXTEST_CTRL 0x153c
-
-#define S_TPTER_CNT_RST 7
-#define V_TPTER_CNT_RST(x) ((x) << S_TPTER_CNT_RST)
-#define F_TPTER_CNT_RST V_TPTER_CNT_RST(1U)
-
-#define S_TEST_CNT_125US 6
-#define V_TEST_CNT_125US(x) ((x) << S_TEST_CNT_125US)
-#define F_TEST_CNT_125US V_TEST_CNT_125US(1U)
-
-#define S_TEST_CNT_PRE 5
-#define V_TEST_CNT_PRE(x) ((x) << S_TEST_CNT_PRE)
-#define F_TEST_CNT_PRE V_TEST_CNT_PRE(1U)
-
-#define S_BER_CNT_RST 4
-#define V_BER_CNT_RST(x) ((x) << S_BER_CNT_RST)
-#define F_BER_CNT_RST V_BER_CNT_RST(1U)
-
-#define S_ERR_BLK_CNT_RST 3
-#define V_ERR_BLK_CNT_RST(x) ((x) << S_ERR_BLK_CNT_RST)
-#define F_ERR_BLK_CNT_RST V_ERR_BLK_CNT_RST(1U)
-
-#define S_RX_PRBS31_EN 2
-#define V_RX_PRBS31_EN(x) ((x) << S_RX_PRBS31_EN)
-#define F_RX_PRBS31_EN V_RX_PRBS31_EN(1U)
-
-#define S_RX_TST_DAT_SEL 1
-#define V_RX_TST_DAT_SEL(x) ((x) << S_RX_TST_DAT_SEL)
-#define F_RX_TST_DAT_SEL V_RX_TST_DAT_SEL(1U)
-
-#define S_RX_TST_EN 0
-#define V_RX_TST_EN(x) ((x) << S_RX_TST_EN)
-#define F_RX_TST_EN V_RX_TST_EN(1U)
-
-#define A_XGMAC_PORT_PCSR_STATUS 0x1550
-
-#define S_ERR_BLK_CNT 16
-#define M_ERR_BLK_CNT 0xffU
-#define V_ERR_BLK_CNT(x) ((x) << S_ERR_BLK_CNT)
-#define G_ERR_BLK_CNT(x) (((x) >> S_ERR_BLK_CNT) & M_ERR_BLK_CNT)
-
-#define S_BER_COUNT 8
-#define M_BER_COUNT 0x3fU
-#define V_BER_COUNT(x) ((x) << S_BER_COUNT)
-#define G_BER_COUNT(x) (((x) >> S_BER_COUNT) & M_BER_COUNT)
-
-#define S_HI_BER 2
-#define V_HI_BER(x) ((x) << S_HI_BER)
-#define F_HI_BER V_HI_BER(1U)
-
-#define S_RX_FAULT 1
-#define V_RX_FAULT(x) ((x) << S_RX_FAULT)
-#define F_RX_FAULT V_RX_FAULT(1U)
-
-#define S_TX_FAULT 0
-#define V_TX_FAULT(x) ((x) << S_TX_FAULT)
-#define F_TX_FAULT V_TX_FAULT(1U)
-
-#define A_XGMAC_PORT_PCSR_TEST_STATUS 0x1554
-
-#define S_TPT_ERR_CNT 0
-#define M_TPT_ERR_CNT 0xffffU
-#define V_TPT_ERR_CNT(x) ((x) << S_TPT_ERR_CNT)
-#define G_TPT_ERR_CNT(x) (((x) >> S_TPT_ERR_CNT) & M_TPT_ERR_CNT)
-
-#define A_XGMAC_PORT_AN_CONTROL 0x1600
-
-#define S_SOFT_RESET 15
-#define V_SOFT_RESET(x) ((x) << S_SOFT_RESET)
-#define F_SOFT_RESET V_SOFT_RESET(1U)
-
-#define S_AN_ENABLE 12
-#define V_AN_ENABLE(x) ((x) << S_AN_ENABLE)
-#define F_AN_ENABLE V_AN_ENABLE(1U)
-
-#define S_RESTART_AN 9
-#define V_RESTART_AN(x) ((x) << S_RESTART_AN)
-#define F_RESTART_AN V_RESTART_AN(1U)
-
-#define A_XGMAC_PORT_AN_STATUS 0x1604
-
-#define S_NONCER_MATCH 31
-#define V_NONCER_MATCH(x) ((x) << S_NONCER_MATCH)
-#define F_NONCER_MATCH V_NONCER_MATCH(1U)
-
-#define S_PARALLEL_DET_FAULT 9
-#define V_PARALLEL_DET_FAULT(x) ((x) << S_PARALLEL_DET_FAULT)
-#define F_PARALLEL_DET_FAULT V_PARALLEL_DET_FAULT(1U)
-
-#define S_PAGE_RECEIVED 6
-#define V_PAGE_RECEIVED(x) ((x) << S_PAGE_RECEIVED)
-#define F_PAGE_RECEIVED V_PAGE_RECEIVED(1U)
-
-#define S_AN_COMPLETE 5
-#define V_AN_COMPLETE(x) ((x) << S_AN_COMPLETE)
-#define F_AN_COMPLETE V_AN_COMPLETE(1U)
-
-#define S_STAT_REMFAULT 4
-#define V_STAT_REMFAULT(x) ((x) << S_STAT_REMFAULT)
-#define F_STAT_REMFAULT V_STAT_REMFAULT(1U)
-
-#define S_AN_ABILITY 3
-#define V_AN_ABILITY(x) ((x) << S_AN_ABILITY)
-#define F_AN_ABILITY V_AN_ABILITY(1U)
-
-#define S_LINK_STATUS 2
-#define V_LINK_STATUS(x) ((x) << S_LINK_STATUS)
-#define F_LINK_STATUS V_LINK_STATUS(1U)
-
-#define S_PARTNER_AN_ABILITY 0
-#define V_PARTNER_AN_ABILITY(x) ((x) << S_PARTNER_AN_ABILITY)
-#define F_PARTNER_AN_ABILITY V_PARTNER_AN_ABILITY(1U)
-
-#define A_XGMAC_PORT_AN_ADVERTISEMENT 0x1608
-
-#define S_FEC_ENABLE 31
-#define V_FEC_ENABLE(x) ((x) << S_FEC_ENABLE)
-#define F_FEC_ENABLE V_FEC_ENABLE(1U)
-
-#define S_FEC_ABILITY 30
-#define V_FEC_ABILITY(x) ((x) << S_FEC_ABILITY)
-#define F_FEC_ABILITY V_FEC_ABILITY(1U)
-
-#define S_10GBASE_KR_CAPABLE 23
-#define V_10GBASE_KR_CAPABLE(x) ((x) << S_10GBASE_KR_CAPABLE)
-#define F_10GBASE_KR_CAPABLE V_10GBASE_KR_CAPABLE(1U)
-
-#define S_10GBASE_KX4_CAPABLE 22
-#define V_10GBASE_KX4_CAPABLE(x) ((x) << S_10GBASE_KX4_CAPABLE)
-#define F_10GBASE_KX4_CAPABLE V_10GBASE_KX4_CAPABLE(1U)
-
-#define S_1000BASE_KX_CAPABLE 21
-#define V_1000BASE_KX_CAPABLE(x) ((x) << S_1000BASE_KX_CAPABLE)
-#define F_1000BASE_KX_CAPABLE V_1000BASE_KX_CAPABLE(1U)
-
-#define S_TRANSMITTED_NONCE 16
-#define M_TRANSMITTED_NONCE 0x1fU
-#define V_TRANSMITTED_NONCE(x) ((x) << S_TRANSMITTED_NONCE)
-#define G_TRANSMITTED_NONCE(x) (((x) >> S_TRANSMITTED_NONCE) & M_TRANSMITTED_NONCE)
-
-#define S_NP 15
-#define V_NP(x) ((x) << S_NP)
-#define F_NP V_NP(1U)
-
-#define S_ACK 14
-#define V_ACK(x) ((x) << S_ACK)
-#define F_ACK V_ACK(1U)
-
-#define S_REMOTE_FAULT 13
-#define V_REMOTE_FAULT(x) ((x) << S_REMOTE_FAULT)
-#define F_REMOTE_FAULT V_REMOTE_FAULT(1U)
-
-#define S_ASM_DIR 11
-#define V_ASM_DIR(x) ((x) << S_ASM_DIR)
-#define F_ASM_DIR V_ASM_DIR(1U)
-
-#define S_PAUSE 10
-#define V_PAUSE(x) ((x) << S_PAUSE)
-#define F_PAUSE V_PAUSE(1U)
-
-#define S_ECHOED_NONCE 5
-#define M_ECHOED_NONCE 0x1fU
-#define V_ECHOED_NONCE(x) ((x) << S_ECHOED_NONCE)
-#define G_ECHOED_NONCE(x) (((x) >> S_ECHOED_NONCE) & M_ECHOED_NONCE)
-
-#define A_XGMAC_PORT_AN_LINK_PARTNER_ABILITY 0x160c
-
-#define S_SELECTOR_FIELD 0
-#define M_SELECTOR_FIELD 0x1fU
-#define V_SELECTOR_FIELD(x) ((x) << S_SELECTOR_FIELD)
-#define G_SELECTOR_FIELD(x) (((x) >> S_SELECTOR_FIELD) & M_SELECTOR_FIELD)
-
-#define A_XGMAC_PORT_AN_NP_LOWER_TRANSMIT 0x1610
-
-#define S_NP_INFO 16
-#define M_NP_INFO 0xffffU
-#define V_NP_INFO(x) ((x) << S_NP_INFO)
-#define G_NP_INFO(x) (((x) >> S_NP_INFO) & M_NP_INFO)
-
-#define S_NP_INDICATION 15
-#define V_NP_INDICATION(x) ((x) << S_NP_INDICATION)
-#define F_NP_INDICATION V_NP_INDICATION(1U)
-
-#define S_MESSAGE_PAGE 13
-#define V_MESSAGE_PAGE(x) ((x) << S_MESSAGE_PAGE)
-#define F_MESSAGE_PAGE V_MESSAGE_PAGE(1U)
-
-#define S_ACK_2 12
-#define V_ACK_2(x) ((x) << S_ACK_2)
-#define F_ACK_2 V_ACK_2(1U)
-
-#define S_TOGGLE 11
-#define V_TOGGLE(x) ((x) << S_TOGGLE)
-#define F_TOGGLE V_TOGGLE(1U)
-
-#define A_XGMAC_PORT_AN_NP_UPPER_TRANSMIT 0x1614
-
-#define S_NP_INFO_HI 0
-#define M_NP_INFO_HI 0xffffU
-#define V_NP_INFO_HI(x) ((x) << S_NP_INFO_HI)
-#define G_NP_INFO_HI(x) (((x) >> S_NP_INFO_HI) & M_NP_INFO_HI)
-
-#define A_XGMAC_PORT_AN_LP_NP_LOWER 0x1618
-#define A_XGMAC_PORT_AN_LP_NP_UPPER 0x161c
-#define A_XGMAC_PORT_AN_BACKPLANE_ETHERNET_STATUS 0x1624
-
-#define S_TX_PAUSE_OKAY 6
-#define V_TX_PAUSE_OKAY(x) ((x) << S_TX_PAUSE_OKAY)
-#define F_TX_PAUSE_OKAY V_TX_PAUSE_OKAY(1U)
-
-#define S_RX_PAUSE_OKAY 5
-#define V_RX_PAUSE_OKAY(x) ((x) << S_RX_PAUSE_OKAY)
-#define F_RX_PAUSE_OKAY V_RX_PAUSE_OKAY(1U)
-
-#define S_10GBASE_KR_FEC_NEG 4
-#define V_10GBASE_KR_FEC_NEG(x) ((x) << S_10GBASE_KR_FEC_NEG)
-#define F_10GBASE_KR_FEC_NEG V_10GBASE_KR_FEC_NEG(1U)
-
-#define S_10GBASE_KR_NEG 3
-#define V_10GBASE_KR_NEG(x) ((x) << S_10GBASE_KR_NEG)
-#define F_10GBASE_KR_NEG V_10GBASE_KR_NEG(1U)
-
-#define S_10GBASE_KX4_NEG 2
-#define V_10GBASE_KX4_NEG(x) ((x) << S_10GBASE_KX4_NEG)
-#define F_10GBASE_KX4_NEG V_10GBASE_KX4_NEG(1U)
-
-#define S_1000BASE_KX_NEG 1
-#define V_1000BASE_KX_NEG(x) ((x) << S_1000BASE_KX_NEG)
-#define F_1000BASE_KX_NEG V_1000BASE_KX_NEG(1U)
-
-#define S_BP_AN_ABILITY 0
-#define V_BP_AN_ABILITY(x) ((x) << S_BP_AN_ABILITY)
-#define F_BP_AN_ABILITY V_BP_AN_ABILITY(1U)
-
-#define A_XGMAC_PORT_AN_TX_NONCE_CONTROL 0x1628
-
-#define S_BYPASS_LFSR 15
-#define V_BYPASS_LFSR(x) ((x) << S_BYPASS_LFSR)
-#define F_BYPASS_LFSR V_BYPASS_LFSR(1U)
-
-#define S_LFSR_INIT 0
-#define M_LFSR_INIT 0x7fffU
-#define V_LFSR_INIT(x) ((x) << S_LFSR_INIT)
-#define G_LFSR_INIT(x) (((x) >> S_LFSR_INIT) & M_LFSR_INIT)
-
-#define A_XGMAC_PORT_AN_INTERRUPT_STATUS 0x162c
-
-#define S_NP_FROM_LP 3
-#define V_NP_FROM_LP(x) ((x) << S_NP_FROM_LP)
-#define F_NP_FROM_LP V_NP_FROM_LP(1U)
-
-#define S_PARALLELDETFAULTINT 2
-#define V_PARALLELDETFAULTINT(x) ((x) << S_PARALLELDETFAULTINT)
-#define F_PARALLELDETFAULTINT V_PARALLELDETFAULTINT(1U)
-
-#define S_BP_FROM_LP 1
-#define V_BP_FROM_LP(x) ((x) << S_BP_FROM_LP)
-#define F_BP_FROM_LP V_BP_FROM_LP(1U)
-
-#define S_PCS_AN_COMPLETE 0
-#define V_PCS_AN_COMPLETE(x) ((x) << S_PCS_AN_COMPLETE)
-#define F_PCS_AN_COMPLETE V_PCS_AN_COMPLETE(1U)
-
-#define A_XGMAC_PORT_AN_GENERIC_TIMER_TIMEOUT 0x1630
-
-#define S_GENERIC_TIMEOUT 0
-#define M_GENERIC_TIMEOUT 0x7fffffU
-#define V_GENERIC_TIMEOUT(x) ((x) << S_GENERIC_TIMEOUT)
-#define G_GENERIC_TIMEOUT(x) (((x) >> S_GENERIC_TIMEOUT) & M_GENERIC_TIMEOUT)
-
-#define A_XGMAC_PORT_AN_BREAK_LINK_TIMEOUT 0x1634
-
-#define S_BREAK_LINK_TIMEOUT 0
-#define M_BREAK_LINK_TIMEOUT 0xffffffU
-#define V_BREAK_LINK_TIMEOUT(x) ((x) << S_BREAK_LINK_TIMEOUT)
-#define G_BREAK_LINK_TIMEOUT(x) (((x) >> S_BREAK_LINK_TIMEOUT) & M_BREAK_LINK_TIMEOUT)
-
-#define A_XGMAC_PORT_AN_MODULE_ID 0x163c
-
-#define S_MODULE_ID 16
-#define M_MODULE_ID 0xffffU
-#define V_MODULE_ID(x) ((x) << S_MODULE_ID)
-#define G_MODULE_ID(x) (((x) >> S_MODULE_ID) & M_MODULE_ID)
-
-#define S_MODULE_REVISION 0
-#define M_MODULE_REVISION 0xffffU
-#define V_MODULE_REVISION(x) ((x) << S_MODULE_REVISION)
-#define G_MODULE_REVISION(x) (((x) >> S_MODULE_REVISION) & M_MODULE_REVISION)
-
-#define A_XGMAC_PORT_AE_RX_COEF_REQ 0x1700
-
-#define S_RXREQ_CPRE 13
-#define V_RXREQ_CPRE(x) ((x) << S_RXREQ_CPRE)
-#define F_RXREQ_CPRE V_RXREQ_CPRE(1U)
-
-#define S_RXREQ_CINIT 12
-#define V_RXREQ_CINIT(x) ((x) << S_RXREQ_CINIT)
-#define F_RXREQ_CINIT V_RXREQ_CINIT(1U)
-
-#define S_RXREQ_C0 4
-#define M_RXREQ_C0 0x3U
-#define V_RXREQ_C0(x) ((x) << S_RXREQ_C0)
-#define G_RXREQ_C0(x) (((x) >> S_RXREQ_C0) & M_RXREQ_C0)
-
-#define S_RXREQ_C1 2
-#define M_RXREQ_C1 0x3U
-#define V_RXREQ_C1(x) ((x) << S_RXREQ_C1)
-#define G_RXREQ_C1(x) (((x) >> S_RXREQ_C1) & M_RXREQ_C1)
-
-#define S_RXREQ_C2 0
-#define M_RXREQ_C2 0x3U
-#define V_RXREQ_C2(x) ((x) << S_RXREQ_C2)
-#define G_RXREQ_C2(x) (((x) >> S_RXREQ_C2) & M_RXREQ_C2)
-
-#define A_XGMAC_PORT_AE_RX_COEF_STAT 0x1704
-
-#define S_RXSTAT_RDY 15
-#define V_RXSTAT_RDY(x) ((x) << S_RXSTAT_RDY)
-#define F_RXSTAT_RDY V_RXSTAT_RDY(1U)
-
-#define S_RXSTAT_C0 4
-#define M_RXSTAT_C0 0x3U
-#define V_RXSTAT_C0(x) ((x) << S_RXSTAT_C0)
-#define G_RXSTAT_C0(x) (((x) >> S_RXSTAT_C0) & M_RXSTAT_C0)
-
-#define S_RXSTAT_C1 2
-#define M_RXSTAT_C1 0x3U
-#define V_RXSTAT_C1(x) ((x) << S_RXSTAT_C1)
-#define G_RXSTAT_C1(x) (((x) >> S_RXSTAT_C1) & M_RXSTAT_C1)
-
-#define S_RXSTAT_C2 0
-#define M_RXSTAT_C2 0x3U
-#define V_RXSTAT_C2(x) ((x) << S_RXSTAT_C2)
-#define G_RXSTAT_C2(x) (((x) >> S_RXSTAT_C2) & M_RXSTAT_C2)
-
-#define A_XGMAC_PORT_AE_TX_COEF_REQ 0x1708
-
-#define S_TXREQ_CPRE 13
-#define V_TXREQ_CPRE(x) ((x) << S_TXREQ_CPRE)
-#define F_TXREQ_CPRE V_TXREQ_CPRE(1U)
-
-#define S_TXREQ_CINIT 12
-#define V_TXREQ_CINIT(x) ((x) << S_TXREQ_CINIT)
-#define F_TXREQ_CINIT V_TXREQ_CINIT(1U)
-
-#define S_TXREQ_C0 4
-#define M_TXREQ_C0 0x3U
-#define V_TXREQ_C0(x) ((x) << S_TXREQ_C0)
-#define G_TXREQ_C0(x) (((x) >> S_TXREQ_C0) & M_TXREQ_C0)
-
-#define S_TXREQ_C1 2
-#define M_TXREQ_C1 0x3U
-#define V_TXREQ_C1(x) ((x) << S_TXREQ_C1)
-#define G_TXREQ_C1(x) (((x) >> S_TXREQ_C1) & M_TXREQ_C1)
-
-#define S_TXREQ_C2 0
-#define M_TXREQ_C2 0x3U
-#define V_TXREQ_C2(x) ((x) << S_TXREQ_C2)
-#define G_TXREQ_C2(x) (((x) >> S_TXREQ_C2) & M_TXREQ_C2)
-
-#define A_XGMAC_PORT_AE_TX_COEF_STAT 0x170c
-
-#define S_TXSTAT_RDY 15
-#define V_TXSTAT_RDY(x) ((x) << S_TXSTAT_RDY)
-#define F_TXSTAT_RDY V_TXSTAT_RDY(1U)
-
-#define S_TXSTAT_C0 4
-#define M_TXSTAT_C0 0x3U
-#define V_TXSTAT_C0(x) ((x) << S_TXSTAT_C0)
-#define G_TXSTAT_C0(x) (((x) >> S_TXSTAT_C0) & M_TXSTAT_C0)
-
-#define S_TXSTAT_C1 2
-#define M_TXSTAT_C1 0x3U
-#define V_TXSTAT_C1(x) ((x) << S_TXSTAT_C1)
-#define G_TXSTAT_C1(x) (((x) >> S_TXSTAT_C1) & M_TXSTAT_C1)
-
-#define S_TXSTAT_C2 0
-#define M_TXSTAT_C2 0x3U
-#define V_TXSTAT_C2(x) ((x) << S_TXSTAT_C2)
-#define G_TXSTAT_C2(x) (((x) >> S_TXSTAT_C2) & M_TXSTAT_C2)
-
-#define A_XGMAC_PORT_AE_REG_MODE 0x1710
-
-#define S_MAN_DEC 4
-#define M_MAN_DEC 0x3U
-#define V_MAN_DEC(x) ((x) << S_MAN_DEC)
-#define G_MAN_DEC(x) (((x) >> S_MAN_DEC) & M_MAN_DEC)
-
-#define S_MANUAL_RDY 3
-#define V_MANUAL_RDY(x) ((x) << S_MANUAL_RDY)
-#define F_MANUAL_RDY V_MANUAL_RDY(1U)
-
-#define S_MWT_DISABLE 2
-#define V_MWT_DISABLE(x) ((x) << S_MWT_DISABLE)
-#define F_MWT_DISABLE V_MWT_DISABLE(1U)
-
-#define S_MDIO_OVR 1
-#define V_MDIO_OVR(x) ((x) << S_MDIO_OVR)
-#define F_MDIO_OVR V_MDIO_OVR(1U)
-
-#define S_STICKY_MODE 0
-#define V_STICKY_MODE(x) ((x) << S_STICKY_MODE)
-#define F_STICKY_MODE V_STICKY_MODE(1U)
-
-#define A_XGMAC_PORT_AE_PRBS_CTL 0x1714
-
-#define S_PRBS_CHK_ERRCNT 8
-#define M_PRBS_CHK_ERRCNT 0xffU
-#define V_PRBS_CHK_ERRCNT(x) ((x) << S_PRBS_CHK_ERRCNT)
-#define G_PRBS_CHK_ERRCNT(x) (((x) >> S_PRBS_CHK_ERRCNT) & M_PRBS_CHK_ERRCNT)
-
-#define S_PRBS_SYNCCNT 5
-#define M_PRBS_SYNCCNT 0x7U
-#define V_PRBS_SYNCCNT(x) ((x) << S_PRBS_SYNCCNT)
-#define G_PRBS_SYNCCNT(x) (((x) >> S_PRBS_SYNCCNT) & M_PRBS_SYNCCNT)
-
-#define S_PRBS_CHK_SYNC 4
-#define V_PRBS_CHK_SYNC(x) ((x) << S_PRBS_CHK_SYNC)
-#define F_PRBS_CHK_SYNC V_PRBS_CHK_SYNC(1U)
-
-#define S_PRBS_CHK_RST 3
-#define V_PRBS_CHK_RST(x) ((x) << S_PRBS_CHK_RST)
-#define F_PRBS_CHK_RST V_PRBS_CHK_RST(1U)
-
-#define S_PRBS_CHK_OFF 2
-#define V_PRBS_CHK_OFF(x) ((x) << S_PRBS_CHK_OFF)
-#define F_PRBS_CHK_OFF V_PRBS_CHK_OFF(1U)
-
-#define S_PRBS_GEN_FRCERR 1
-#define V_PRBS_GEN_FRCERR(x) ((x) << S_PRBS_GEN_FRCERR)
-#define F_PRBS_GEN_FRCERR V_PRBS_GEN_FRCERR(1U)
-
-#define S_PRBS_GEN_OFF 0
-#define V_PRBS_GEN_OFF(x) ((x) << S_PRBS_GEN_OFF)
-#define F_PRBS_GEN_OFF V_PRBS_GEN_OFF(1U)
-
-#define A_XGMAC_PORT_AE_FSM_CTL 0x1718
-
-#define S_FSM_TR_LCL 14
-#define V_FSM_TR_LCL(x) ((x) << S_FSM_TR_LCL)
-#define F_FSM_TR_LCL V_FSM_TR_LCL(1U)
-
-#define S_FSM_GDMRK 11
-#define M_FSM_GDMRK 0x7U
-#define V_FSM_GDMRK(x) ((x) << S_FSM_GDMRK)
-#define G_FSM_GDMRK(x) (((x) >> S_FSM_GDMRK) & M_FSM_GDMRK)
-
-#define S_FSM_BADMRK 8
-#define M_FSM_BADMRK 0x7U
-#define V_FSM_BADMRK(x) ((x) << S_FSM_BADMRK)
-#define G_FSM_BADMRK(x) (((x) >> S_FSM_BADMRK) & M_FSM_BADMRK)
-
-#define S_FSM_TR_FAIL 7
-#define V_FSM_TR_FAIL(x) ((x) << S_FSM_TR_FAIL)
-#define F_FSM_TR_FAIL V_FSM_TR_FAIL(1U)
-
-#define S_FSM_TR_ACT 6
-#define V_FSM_TR_ACT(x) ((x) << S_FSM_TR_ACT)
-#define F_FSM_TR_ACT V_FSM_TR_ACT(1U)
-
-#define S_FSM_FRM_LCK 5
-#define V_FSM_FRM_LCK(x) ((x) << S_FSM_FRM_LCK)
-#define F_FSM_FRM_LCK V_FSM_FRM_LCK(1U)
-
-#define S_FSM_TR_COMP 4
-#define V_FSM_TR_COMP(x) ((x) << S_FSM_TR_COMP)
-#define F_FSM_TR_COMP V_FSM_TR_COMP(1U)
-
-#define S_MC_RX_RDY 3
-#define V_MC_RX_RDY(x) ((x) << S_MC_RX_RDY)
-#define F_MC_RX_RDY V_MC_RX_RDY(1U)
-
-#define S_FSM_CU_DIS 2
-#define V_FSM_CU_DIS(x) ((x) << S_FSM_CU_DIS)
-#define F_FSM_CU_DIS V_FSM_CU_DIS(1U)
-
-#define S_FSM_TR_RST 1
-#define V_FSM_TR_RST(x) ((x) << S_FSM_TR_RST)
-#define F_FSM_TR_RST V_FSM_TR_RST(1U)
-
-#define S_FSM_TR_EN 0
-#define V_FSM_TR_EN(x) ((x) << S_FSM_TR_EN)
-#define F_FSM_TR_EN V_FSM_TR_EN(1U)
-
-#define A_XGMAC_PORT_AE_FSM_STATE 0x171c
-
-#define S_CC2FSM_STATE 13
-#define M_CC2FSM_STATE 0x7U
-#define V_CC2FSM_STATE(x) ((x) << S_CC2FSM_STATE)
-#define G_CC2FSM_STATE(x) (((x) >> S_CC2FSM_STATE) & M_CC2FSM_STATE)
-
-#define S_CC1FSM_STATE 10
-#define M_CC1FSM_STATE 0x7U
-#define V_CC1FSM_STATE(x) ((x) << S_CC1FSM_STATE)
-#define G_CC1FSM_STATE(x) (((x) >> S_CC1FSM_STATE) & M_CC1FSM_STATE)
-
-#define S_CC0FSM_STATE 7
-#define M_CC0FSM_STATE 0x7U
-#define V_CC0FSM_STATE(x) ((x) << S_CC0FSM_STATE)
-#define G_CC0FSM_STATE(x) (((x) >> S_CC0FSM_STATE) & M_CC0FSM_STATE)
-
-#define S_FLFSM_STATE 4
-#define M_FLFSM_STATE 0x7U
-#define V_FLFSM_STATE(x) ((x) << S_FLFSM_STATE)
-#define G_FLFSM_STATE(x) (((x) >> S_FLFSM_STATE) & M_FLFSM_STATE)
-
-#define S_TFSM_STATE 0
-#define M_TFSM_STATE 0x7U
-#define V_TFSM_STATE(x) ((x) << S_TFSM_STATE)
-#define G_TFSM_STATE(x) (((x) >> S_TFSM_STATE) & M_TFSM_STATE)
-
-#define A_XGMAC_PORT_AE_TX_DIS 0x1780
-
-#define S_PMD_TX_DIS 0
-#define V_PMD_TX_DIS(x) ((x) << S_PMD_TX_DIS)
-#define F_PMD_TX_DIS V_PMD_TX_DIS(1U)
-
-#define A_XGMAC_PORT_AE_KR_CTRL 0x1784
-
-#define S_TRAINING_ENABLE 1
-#define V_TRAINING_ENABLE(x) ((x) << S_TRAINING_ENABLE)
-#define F_TRAINING_ENABLE V_TRAINING_ENABLE(1U)
-
-#define S_RESTART_TRAINING 0
-#define V_RESTART_TRAINING(x) ((x) << S_RESTART_TRAINING)
-#define F_RESTART_TRAINING V_RESTART_TRAINING(1U)
-
-#define A_XGMAC_PORT_AE_RX_SIGDET 0x1788
-
-#define S_PMD_SIGDET 0
-#define V_PMD_SIGDET(x) ((x) << S_PMD_SIGDET)
-#define F_PMD_SIGDET V_PMD_SIGDET(1U)
-
-#define A_XGMAC_PORT_AE_KR_STATUS 0x178c
-
-#define S_TRAINING_FAILURE 3
-#define V_TRAINING_FAILURE(x) ((x) << S_TRAINING_FAILURE)
-#define F_TRAINING_FAILURE V_TRAINING_FAILURE(1U)
-
-#define S_TRAINING 2
-#define V_TRAINING(x) ((x) << S_TRAINING)
-#define F_TRAINING V_TRAINING(1U)
-
-#define S_FRAME_LOCK 1
-#define V_FRAME_LOCK(x) ((x) << S_FRAME_LOCK)
-#define F_FRAME_LOCK V_FRAME_LOCK(1U)
-
-#define S_RX_TRAINED 0
-#define V_RX_TRAINED(x) ((x) << S_RX_TRAINED)
-#define F_RX_TRAINED V_RX_TRAINED(1U)
-
-#define A_XGMAC_PORT_HSS_TXA_MODE_CFG 0x1800
-
-#define S_BWSEL 2
-#define M_BWSEL 0x3U
-#define V_BWSEL(x) ((x) << S_BWSEL)
-#define G_BWSEL(x) (((x) >> S_BWSEL) & M_BWSEL)
-
-#define S_RTSEL 0
-#define M_RTSEL 0x3U
-#define V_RTSEL(x) ((x) << S_RTSEL)
-#define G_RTSEL(x) (((x) >> S_RTSEL) & M_RTSEL)
-
-#define A_XGMAC_PORT_HSS_TXA_TEST_CTRL 0x1804
-
-#define S_TWDP 5
-#define V_TWDP(x) ((x) << S_TWDP)
-#define F_TWDP V_TWDP(1U)
-
-#define S_TPGRST 4
-#define V_TPGRST(x) ((x) << S_TPGRST)
-#define F_TPGRST V_TPGRST(1U)
-
-#define S_TPGEN 3
-#define V_TPGEN(x) ((x) << S_TPGEN)
-#define F_TPGEN V_TPGEN(1U)
-
-#define S_TPSEL 0
-#define M_TPSEL 0x7U
-#define V_TPSEL(x) ((x) << S_TPSEL)
-#define G_TPSEL(x) (((x) >> S_TPSEL) & M_TPSEL)
-
-#define A_XGMAC_PORT_HSS_TXA_COEFF_CTRL 0x1808
-
-#define S_AEINVPOL 6
-#define V_AEINVPOL(x) ((x) << S_AEINVPOL)
-#define F_AEINVPOL V_AEINVPOL(1U)
-
-#define S_AESOURCE 5
-#define V_AESOURCE(x) ((x) << S_AESOURCE)
-#define F_AESOURCE V_AESOURCE(1U)
-
-#define S_EQMODE 4
-#define V_EQMODE(x) ((x) << S_EQMODE)
-#define F_EQMODE V_EQMODE(1U)
-
-#define S_OCOEF 3
-#define V_OCOEF(x) ((x) << S_OCOEF)
-#define F_OCOEF V_OCOEF(1U)
-
-#define S_COEFRST 2
-#define V_COEFRST(x) ((x) << S_COEFRST)
-#define F_COEFRST V_COEFRST(1U)
-
-#define S_SPEN 1
-#define V_SPEN(x) ((x) << S_SPEN)
-#define F_SPEN V_SPEN(1U)
-
-#define S_ALOAD 0
-#define V_ALOAD(x) ((x) << S_ALOAD)
-#define F_ALOAD V_ALOAD(1U)
-
-#define A_XGMAC_PORT_HSS_TXA_DRIVER_MODE 0x180c
-
-#define S_DRVOFFT 5
-#define V_DRVOFFT(x) ((x) << S_DRVOFFT)
-#define F_DRVOFFT V_DRVOFFT(1U)
-
-#define S_SLEW 2
-#define M_SLEW 0x7U
-#define V_SLEW(x) ((x) << S_SLEW)
-#define G_SLEW(x) (((x) >> S_SLEW) & M_SLEW)
-
-#define S_FFE 0
-#define M_FFE 0x3U
-#define V_FFE(x) ((x) << S_FFE)
-#define G_FFE(x) (((x) >> S_FFE) & M_FFE)
-
-#define A_XGMAC_PORT_HSS_TXA_DRIVER_OVR_CTRL 0x1810
-
-#define S_VLINC 7
-#define V_VLINC(x) ((x) << S_VLINC)
-#define F_VLINC V_VLINC(1U)
-
-#define S_VLDEC 6
-#define V_VLDEC(x) ((x) << S_VLDEC)
-#define F_VLDEC V_VLDEC(1U)
-
-#define S_LOPWR 5
-#define V_LOPWR(x) ((x) << S_LOPWR)
-#define F_LOPWR V_LOPWR(1U)
-
-#define S_TDMEN 4
-#define V_TDMEN(x) ((x) << S_TDMEN)
-#define F_TDMEN V_TDMEN(1U)
-
-#define S_DCCEN 3
-#define V_DCCEN(x) ((x) << S_DCCEN)
-#define F_DCCEN V_DCCEN(1U)
-
-#define S_VHSEL 2
-#define V_VHSEL(x) ((x) << S_VHSEL)
-#define F_VHSEL V_VHSEL(1U)
-
-#define S_IDAC 0
-#define M_IDAC 0x3U
-#define V_IDAC(x) ((x) << S_IDAC)
-#define G_IDAC(x) (((x) >> S_IDAC) & M_IDAC)
-
-#define A_XGMAC_PORT_HSS_TXA_TDM_BIASGEN_STANDBY_TIMER 0x1814
-
-#define S_STBY 0
-#define M_STBY 0xffffU
-#define V_STBY(x) ((x) << S_STBY)
-#define G_STBY(x) (((x) >> S_STBY) & M_STBY)
-
-#define A_XGMAC_PORT_HSS_TXA_TDM_BIASGEN_PWRON_TIMER 0x1818
-
-#define S_PON 0
-#define M_PON 0xffffU
-#define V_PON(x) ((x) << S_PON)
-#define G_PON(x) (((x) >> S_PON) & M_PON)
-
-#define A_XGMAC_PORT_HSS_TXA_TAP0_COEFF 0x1820
-
-#define S_NXTT0 0
-#define M_NXTT0 0xfU
-#define V_NXTT0(x) ((x) << S_NXTT0)
-#define G_NXTT0(x) (((x) >> S_NXTT0) & M_NXTT0)
-
-#define A_XGMAC_PORT_HSS_TXA_TAP1_COEFF 0x1824
-
-#define S_NXTT1 0
-#define M_NXTT1 0x3fU
-#define V_NXTT1(x) ((x) << S_NXTT1)
-#define G_NXTT1(x) (((x) >> S_NXTT1) & M_NXTT1)
-
-#define A_XGMAC_PORT_HSS_TXA_TAP2_COEFF 0x1828
-
-#define S_NXTT2 0
-#define M_NXTT2 0x1fU
-#define V_NXTT2(x) ((x) << S_NXTT2)
-#define G_NXTT2(x) (((x) >> S_NXTT2) & M_NXTT2)
-
-#define A_XGMAC_PORT_HSS_TXA_PWR 0x1830
-
-#define S_TXPWR 0
-#define M_TXPWR 0x7fU
-#define V_TXPWR(x) ((x) << S_TXPWR)
-#define G_TXPWR(x) (((x) >> S_TXPWR) & M_TXPWR)
-
-#define A_XGMAC_PORT_HSS_TXA_POLARITY 0x1834
-
-#define S_TXPOL 4
-#define M_TXPOL 0x7U
-#define V_TXPOL(x) ((x) << S_TXPOL)
-#define G_TXPOL(x) (((x) >> S_TXPOL) & M_TXPOL)
-
-#define S_NTXPOL 0
-#define M_NTXPOL 0x7U
-#define V_NTXPOL(x) ((x) << S_NTXPOL)
-#define G_NTXPOL(x) (((x) >> S_NTXPOL) & M_NTXPOL)
-
-#define A_XGMAC_PORT_HSS_TXA_8023AP_AE_CMD 0x1838
-
-#define S_CXPRESET 13
-#define V_CXPRESET(x) ((x) << S_CXPRESET)
-#define F_CXPRESET V_CXPRESET(1U)
-
-#define S_CXINIT 12
-#define V_CXINIT(x) ((x) << S_CXINIT)
-#define F_CXINIT V_CXINIT(1U)
-
-#define S_C2UPDT 4
-#define M_C2UPDT 0x3U
-#define V_C2UPDT(x) ((x) << S_C2UPDT)
-#define G_C2UPDT(x) (((x) >> S_C2UPDT) & M_C2UPDT)
-
-#define S_C1UPDT 2
-#define M_C1UPDT 0x3U
-#define V_C1UPDT(x) ((x) << S_C1UPDT)
-#define G_C1UPDT(x) (((x) >> S_C1UPDT) & M_C1UPDT)
-
-#define S_C0UPDT 0
-#define M_C0UPDT 0x3U
-#define V_C0UPDT(x) ((x) << S_C0UPDT)
-#define G_C0UPDT(x) (((x) >> S_C0UPDT) & M_C0UPDT)
-
-#define A_XGMAC_PORT_HSS_TXA_8023AP_AE_STATUS 0x183c
-
-#define S_C2STAT 4
-#define M_C2STAT 0x3U
-#define V_C2STAT(x) ((x) << S_C2STAT)
-#define G_C2STAT(x) (((x) >> S_C2STAT) & M_C2STAT)
-
-#define S_C1STAT 2
-#define M_C1STAT 0x3U
-#define V_C1STAT(x) ((x) << S_C1STAT)
-#define G_C1STAT(x) (((x) >> S_C1STAT) & M_C1STAT)
-
-#define S_C0STAT 0
-#define M_C0STAT 0x3U
-#define V_C0STAT(x) ((x) << S_C0STAT)
-#define G_C0STAT(x) (((x) >> S_C0STAT) & M_C0STAT)
-
-#define A_XGMAC_PORT_HSS_TXA_TAP0_IDAC_OVR 0x1840
-
-#define S_NIDAC0 0
-#define M_NIDAC0 0x1fU
-#define V_NIDAC0(x) ((x) << S_NIDAC0)
-#define G_NIDAC0(x) (((x) >> S_NIDAC0) & M_NIDAC0)
-
-#define A_XGMAC_PORT_HSS_TXA_TAP1_IDAC_OVR 0x1844
-
-#define S_NIDAC1 0
-#define M_NIDAC1 0x7fU
-#define V_NIDAC1(x) ((x) << S_NIDAC1)
-#define G_NIDAC1(x) (((x) >> S_NIDAC1) & M_NIDAC1)
-
-#define A_XGMAC_PORT_HSS_TXA_TAP2_IDAC_OVR 0x1848
-
-#define S_NIDAC2 0
-#define M_NIDAC2 0x3fU
-#define V_NIDAC2(x) ((x) << S_NIDAC2)
-#define G_NIDAC2(x) (((x) >> S_NIDAC2) & M_NIDAC2)
-
-#define A_XGMAC_PORT_HSS_TXA_PWR_DAC_OVR 0x1850
-
-#define S_OPEN 7
-#define V_OPEN(x) ((x) << S_OPEN)
-#define F_OPEN V_OPEN(1U)
-
-#define S_OPVAL 0
-#define M_OPVAL 0x1fU
-#define V_OPVAL(x) ((x) << S_OPVAL)
-#define G_OPVAL(x) (((x) >> S_OPVAL) & M_OPVAL)
-
-#define A_XGMAC_PORT_HSS_TXA_PWR_DAC 0x1854
-
-#define S_PDAC 0
-#define M_PDAC 0x1fU
-#define V_PDAC(x) ((x) << S_PDAC)
-#define G_PDAC(x) (((x) >> S_PDAC) & M_PDAC)
-
-#define A_XGMAC_PORT_HSS_TXA_TAP0_IDAC_APP 0x1860
-
-#define S_AIDAC0 0
-#define M_AIDAC0 0x1fU
-#define V_AIDAC0(x) ((x) << S_AIDAC0)
-#define G_AIDAC0(x) (((x) >> S_AIDAC0) & M_AIDAC0)
-
-#define A_XGMAC_PORT_HSS_TXA_TAP1_IDAC_APP 0x1864
-
-#define S_AIDAC1 0
-#define M_AIDAC1 0x1fU
-#define V_AIDAC1(x) ((x) << S_AIDAC1)
-#define G_AIDAC1(x) (((x) >> S_AIDAC1) & M_AIDAC1)
-
-#define A_XGMAC_PORT_HSS_TXA_TAP2_IDAC_APP 0x1868
-
-#define S_TXA_AIDAC2 0
-#define M_TXA_AIDAC2 0x1fU
-#define V_TXA_AIDAC2(x) ((x) << S_TXA_AIDAC2)
-#define G_TXA_AIDAC2(x) (((x) >> S_TXA_AIDAC2) & M_TXA_AIDAC2)
-
-#define A_XGMAC_PORT_HSS_TXA_SEG_DIS_APP 0x1870
-
-#define S_CURSD 0
-#define M_CURSD 0x7fU
-#define V_CURSD(x) ((x) << S_CURSD)
-#define G_CURSD(x) (((x) >> S_CURSD) & M_CURSD)
-
-#define A_XGMAC_PORT_HSS_TXA_EXT_ADDR_DATA 0x1878
-
-#define S_XDATA 0
-#define M_XDATA 0xffffU
-#define V_XDATA(x) ((x) << S_XDATA)
-#define G_XDATA(x) (((x) >> S_XDATA) & M_XDATA)
-
-#define A_XGMAC_PORT_HSS_TXA_EXT_ADDR 0x187c
-
-#define S_EXTADDR 1
-#define M_EXTADDR 0x1fU
-#define V_EXTADDR(x) ((x) << S_EXTADDR)
-#define G_EXTADDR(x) (((x) >> S_EXTADDR) & M_EXTADDR)
-
-#define S_XWR 0
-#define V_XWR(x) ((x) << S_XWR)
-#define F_XWR V_XWR(1U)
-
-#define A_XGMAC_PORT_HSS_TXB_MODE_CFG 0x1880
-#define A_XGMAC_PORT_HSS_TXB_TEST_CTRL 0x1884
-#define A_XGMAC_PORT_HSS_TXB_COEFF_CTRL 0x1888
-#define A_XGMAC_PORT_HSS_TXB_DRIVER_MODE 0x188c
-#define A_XGMAC_PORT_HSS_TXB_DRIVER_OVR_CTRL 0x1890
-#define A_XGMAC_PORT_HSS_TXB_TDM_BIASGEN_STANDBY_TIMER 0x1894
-#define A_XGMAC_PORT_HSS_TXB_TDM_BIASGEN_PWRON_TIMER 0x1898
-#define A_XGMAC_PORT_HSS_TXB_TAP0_COEFF 0x18a0
-#define A_XGMAC_PORT_HSS_TXB_TAP1_COEFF 0x18a4
-#define A_XGMAC_PORT_HSS_TXB_TAP2_COEFF 0x18a8
-#define A_XGMAC_PORT_HSS_TXB_PWR 0x18b0
-#define A_XGMAC_PORT_HSS_TXB_POLARITY 0x18b4
-#define A_XGMAC_PORT_HSS_TXB_8023AP_AE_CMD 0x18b8
-#define A_XGMAC_PORT_HSS_TXB_8023AP_AE_STATUS 0x18bc
-#define A_XGMAC_PORT_HSS_TXB_TAP0_IDAC_OVR 0x18c0
-#define A_XGMAC_PORT_HSS_TXB_TAP1_IDAC_OVR 0x18c4
-#define A_XGMAC_PORT_HSS_TXB_TAP2_IDAC_OVR 0x18c8
-#define A_XGMAC_PORT_HSS_TXB_PWR_DAC_OVR 0x18d0
-#define A_XGMAC_PORT_HSS_TXB_PWR_DAC 0x18d4
-#define A_XGMAC_PORT_HSS_TXB_TAP0_IDAC_APP 0x18e0
-#define A_XGMAC_PORT_HSS_TXB_TAP1_IDAC_APP 0x18e4
-#define A_XGMAC_PORT_HSS_TXB_TAP2_IDAC_APP 0x18e8
-
-#define S_AIDAC2 0
-#define M_AIDAC2 0x3fU
-#define V_AIDAC2(x) ((x) << S_AIDAC2)
-#define G_AIDAC2(x) (((x) >> S_AIDAC2) & M_AIDAC2)
-
-#define A_XGMAC_PORT_HSS_TXB_SEG_DIS_APP 0x18f0
-#define A_XGMAC_PORT_HSS_TXB_EXT_ADDR_DATA 0x18f8
-#define A_XGMAC_PORT_HSS_TXB_EXT_ADDR 0x18fc
-
-#define S_XADDR 2
-#define M_XADDR 0xfU
-#define V_XADDR(x) ((x) << S_XADDR)
-#define G_XADDR(x) (((x) >> S_XADDR) & M_XADDR)
-
-#define A_XGMAC_PORT_HSS_RXA_CFG_MODE 0x1900
-
-#define S_BW810 8
-#define V_BW810(x) ((x) << S_BW810)
-#define F_BW810 V_BW810(1U)
-
-#define S_AUXCLK 7
-#define V_AUXCLK(x) ((x) << S_AUXCLK)
-#define F_AUXCLK V_AUXCLK(1U)
-
-#define S_DMSEL 4
-#define M_DMSEL 0x7U
-#define V_DMSEL(x) ((x) << S_DMSEL)
-#define G_DMSEL(x) (((x) >> S_DMSEL) & M_DMSEL)
-
-#define A_XGMAC_PORT_HSS_RXA_TEST_CTRL 0x1904
-
-#define S_RCLKEN 15
-#define V_RCLKEN(x) ((x) << S_RCLKEN)
-#define F_RCLKEN V_RCLKEN(1U)
-
-#define S_RRATE 13
-#define M_RRATE 0x3U
-#define V_RRATE(x) ((x) << S_RRATE)
-#define G_RRATE(x) (((x) >> S_RRATE) & M_RRATE)
-
-#define S_LBFRCERROR 10
-#define V_LBFRCERROR(x) ((x) << S_LBFRCERROR)
-#define F_LBFRCERROR V_LBFRCERROR(1U)
-
-#define S_LBERROR 9
-#define V_LBERROR(x) ((x) << S_LBERROR)
-#define F_LBERROR V_LBERROR(1U)
-
-#define S_LBSYNC 8
-#define V_LBSYNC(x) ((x) << S_LBSYNC)
-#define F_LBSYNC V_LBSYNC(1U)
-
-#define S_FDWRAPCLK 7
-#define V_FDWRAPCLK(x) ((x) << S_FDWRAPCLK)
-#define F_FDWRAPCLK V_FDWRAPCLK(1U)
-
-#define S_FDWRAP 6
-#define V_FDWRAP(x) ((x) << S_FDWRAP)
-#define F_FDWRAP V_FDWRAP(1U)
-
-#define S_PRST 4
-#define V_PRST(x) ((x) << S_PRST)
-#define F_PRST V_PRST(1U)
-
-#define S_PCHKEN 3
-#define V_PCHKEN(x) ((x) << S_PCHKEN)
-#define F_PCHKEN V_PCHKEN(1U)
-
-#define S_PRBSSEL 0
-#define M_PRBSSEL 0x7U
-#define V_PRBSSEL(x) ((x) << S_PRBSSEL)
-#define G_PRBSSEL(x) (((x) >> S_PRBSSEL) & M_PRBSSEL)
-
-#define A_XGMAC_PORT_HSS_RXA_PH_ROTATOR_CTRL 0x1908
-
-#define S_FTHROT 12
-#define M_FTHROT 0xfU
-#define V_FTHROT(x) ((x) << S_FTHROT)
-#define G_FTHROT(x) (((x) >> S_FTHROT) & M_FTHROT)
-
-#define S_RTHROT 11
-#define V_RTHROT(x) ((x) << S_RTHROT)
-#define F_RTHROT V_RTHROT(1U)
-
-#define S_FILTCTL 7
-#define M_FILTCTL 0xfU
-#define V_FILTCTL(x) ((x) << S_FILTCTL)
-#define G_FILTCTL(x) (((x) >> S_FILTCTL) & M_FILTCTL)
-
-#define S_RSRVO 5
-#define M_RSRVO 0x3U
-#define V_RSRVO(x) ((x) << S_RSRVO)
-#define G_RSRVO(x) (((x) >> S_RSRVO) & M_RSRVO)
-
-#define S_EXTEL 4
-#define V_EXTEL(x) ((x) << S_EXTEL)
-#define F_EXTEL V_EXTEL(1U)
-
-#define S_RSTONSTUCK 3
-#define V_RSTONSTUCK(x) ((x) << S_RSTONSTUCK)
-#define F_RSTONSTUCK V_RSTONSTUCK(1U)
-
-#define S_FREEZEFW 2
-#define V_FREEZEFW(x) ((x) << S_FREEZEFW)
-#define F_FREEZEFW V_FREEZEFW(1U)
-
-#define S_RESETFW 1
-#define V_RESETFW(x) ((x) << S_RESETFW)
-#define F_RESETFW V_RESETFW(1U)
-
-#define S_SSCENABLE 0
-#define V_SSCENABLE(x) ((x) << S_SSCENABLE)
-#define F_SSCENABLE V_SSCENABLE(1U)
-
-#define A_XGMAC_PORT_HSS_RXA_PH_ROTATOR_OFFSET_CTRL 0x190c
-
-#define S_RSNP 11
-#define V_RSNP(x) ((x) << S_RSNP)
-#define F_RSNP V_RSNP(1U)
-
-#define S_TSOEN 10
-#define V_TSOEN(x) ((x) << S_TSOEN)
-#define F_TSOEN V_TSOEN(1U)
-
-#define S_OFFEN 9
-#define V_OFFEN(x) ((x) << S_OFFEN)
-#define F_OFFEN V_OFFEN(1U)
-
-#define S_TMSCAL 7
-#define M_TMSCAL 0x3U
-#define V_TMSCAL(x) ((x) << S_TMSCAL)
-#define G_TMSCAL(x) (((x) >> S_TMSCAL) & M_TMSCAL)
-
-#define S_APADJ 6
-#define V_APADJ(x) ((x) << S_APADJ)
-#define F_APADJ V_APADJ(1U)
-
-#define S_RSEL 5
-#define V_RSEL(x) ((x) << S_RSEL)
-#define F_RSEL V_RSEL(1U)
-
-#define S_PHOFFS 0
-#define M_PHOFFS 0x1fU
-#define V_PHOFFS(x) ((x) << S_PHOFFS)
-#define G_PHOFFS(x) (((x) >> S_PHOFFS) & M_PHOFFS)
-
-#define A_XGMAC_PORT_HSS_RXA_PH_ROTATOR_POSITION1 0x1910
-
-#define S_ROT0A 8
-#define M_ROT0A 0x3fU
-#define V_ROT0A(x) ((x) << S_ROT0A)
-#define G_ROT0A(x) (((x) >> S_ROT0A) & M_ROT0A)
-
-#define S_RTSEL_SNAPSHOT 0
-#define M_RTSEL_SNAPSHOT 0x3fU
-#define V_RTSEL_SNAPSHOT(x) ((x) << S_RTSEL_SNAPSHOT)
-#define G_RTSEL_SNAPSHOT(x) (((x) >> S_RTSEL_SNAPSHOT) & M_RTSEL_SNAPSHOT)
-
-#define A_XGMAC_PORT_HSS_RXA_PH_ROTATOR_POSITION2 0x1914
-
-#define S_ROT90 0
-#define M_ROT90 0x3fU
-#define V_ROT90(x) ((x) << S_ROT90)
-#define G_ROT90(x) (((x) >> S_ROT90) & M_ROT90)
-
-#define A_XGMAC_PORT_HSS_RXA_PH_ROTATOR_STATIC_PH_OFFSET 0x1918
-
-#define S_RCALER 15
-#define V_RCALER(x) ((x) << S_RCALER)
-#define F_RCALER V_RCALER(1U)
-
-#define S_RAOOFF 10
-#define M_RAOOFF 0x1fU
-#define V_RAOOFF(x) ((x) << S_RAOOFF)
-#define G_RAOOFF(x) (((x) >> S_RAOOFF) & M_RAOOFF)
-
-#define S_RAEOFF 5
-#define M_RAEOFF 0x1fU
-#define V_RAEOFF(x) ((x) << S_RAEOFF)
-#define G_RAEOFF(x) (((x) >> S_RAEOFF) & M_RAEOFF)
-
-#define S_RDOFF 0
-#define M_RDOFF 0x1fU
-#define V_RDOFF(x) ((x) << S_RDOFF)
-#define G_RDOFF(x) (((x) >> S_RDOFF) & M_RDOFF)
-
-#define A_XGMAC_PORT_HSS_RXA_SIGDET_CTRL 0x191c
-
-#define S_SIGNSD 13
-#define M_SIGNSD 0x3U
-#define V_SIGNSD(x) ((x) << S_SIGNSD)
-#define G_SIGNSD(x) (((x) >> S_SIGNSD) & M_SIGNSD)
-
-#define S_DACSD 8
-#define M_DACSD 0x1fU
-#define V_DACSD(x) ((x) << S_DACSD)
-#define G_DACSD(x) (((x) >> S_DACSD) & M_DACSD)
-
-#define S_SDPDN 6
-#define V_SDPDN(x) ((x) << S_SDPDN)
-#define F_SDPDN V_SDPDN(1U)
-
-#define S_SIGDET 5
-#define V_SIGDET(x) ((x) << S_SIGDET)
-#define F_SIGDET V_SIGDET(1U)
-
-#define S_SDLVL 0
-#define M_SDLVL 0x1fU
-#define V_SDLVL(x) ((x) << S_SDLVL)
-#define G_SDLVL(x) (((x) >> S_SDLVL) & M_SDLVL)
-
-#define A_XGMAC_PORT_HSS_RXA_DFE_CTRL 0x1920
-
-#define S_REQCMP 15
-#define V_REQCMP(x) ((x) << S_REQCMP)
-#define F_REQCMP V_REQCMP(1U)
-
-#define S_DFEREQ 14
-#define V_DFEREQ(x) ((x) << S_DFEREQ)
-#define F_DFEREQ V_DFEREQ(1U)
-
-#define S_SPCEN 13
-#define V_SPCEN(x) ((x) << S_SPCEN)
-#define F_SPCEN V_SPCEN(1U)
-
-#define S_GATEEN 12
-#define V_GATEEN(x) ((x) << S_GATEEN)
-#define F_GATEEN V_GATEEN(1U)
-
-#define S_SPIFMT 9
-#define M_SPIFMT 0x7U
-#define V_SPIFMT(x) ((x) << S_SPIFMT)
-#define G_SPIFMT(x) (((x) >> S_SPIFMT) & M_SPIFMT)
-
-#define S_DFEPWR 6
-#define M_DFEPWR 0x7U
-#define V_DFEPWR(x) ((x) << S_DFEPWR)
-#define G_DFEPWR(x) (((x) >> S_DFEPWR) & M_DFEPWR)
-
-#define S_STNDBY 5
-#define V_STNDBY(x) ((x) << S_STNDBY)
-#define F_STNDBY V_STNDBY(1U)
-
-#define S_FRCH 4
-#define V_FRCH(x) ((x) << S_FRCH)
-#define F_FRCH V_FRCH(1U)
-
-#define S_NONRND 3
-#define V_NONRND(x) ((x) << S_NONRND)
-#define F_NONRND V_NONRND(1U)
-
-#define S_NONRNF 2
-#define V_NONRNF(x) ((x) << S_NONRNF)
-#define F_NONRNF V_NONRNF(1U)
-
-#define S_FSTLCK 1
-#define V_FSTLCK(x) ((x) << S_FSTLCK)
-#define F_FSTLCK V_FSTLCK(1U)
-
-#define S_DFERST 0
-#define V_DFERST(x) ((x) << S_DFERST)
-#define F_DFERST V_DFERST(1U)
-
-#define A_XGMAC_PORT_HSS_RXA_DFE_DATA_EDGE_SAMPLE 0x1924
-
-#define S_ESAMP 8
-#define M_ESAMP 0xffU
-#define V_ESAMP(x) ((x) << S_ESAMP)
-#define G_ESAMP(x) (((x) >> S_ESAMP) & M_ESAMP)
-
-#define S_DSAMP 0
-#define M_DSAMP 0xffU
-#define V_DSAMP(x) ((x) << S_DSAMP)
-#define G_DSAMP(x) (((x) >> S_DSAMP) & M_DSAMP)
-
-#define A_XGMAC_PORT_HSS_RXA_DFE_AMP_SAMPLE 0x1928
-
-#define S_SMODE 8
-#define M_SMODE 0xfU
-#define V_SMODE(x) ((x) << S_SMODE)
-#define G_SMODE(x) (((x) >> S_SMODE) & M_SMODE)
-
-#define S_ADCORR 7
-#define V_ADCORR(x) ((x) << S_ADCORR)
-#define F_ADCORR V_ADCORR(1U)
-
-#define S_TRAINEN 6
-#define V_TRAINEN(x) ((x) << S_TRAINEN)
-#define F_TRAINEN V_TRAINEN(1U)
-
-#define S_ASAMPQ 3
-#define M_ASAMPQ 0x7U
-#define V_ASAMPQ(x) ((x) << S_ASAMPQ)
-#define G_ASAMPQ(x) (((x) >> S_ASAMPQ) & M_ASAMPQ)
-
-#define S_ASAMP 0
-#define M_ASAMP 0x7U
-#define V_ASAMP(x) ((x) << S_ASAMP)
-#define G_ASAMP(x) (((x) >> S_ASAMP) & M_ASAMP)
-
-#define A_XGMAC_PORT_HSS_RXA_VGA_CTRL1 0x192c
-
-#define S_POLE 12
-#define M_POLE 0x3U
-#define V_POLE(x) ((x) << S_POLE)
-#define G_POLE(x) (((x) >> S_POLE) & M_POLE)
-
-#define S_PEAK 8
-#define M_PEAK 0x7U
-#define V_PEAK(x) ((x) << S_PEAK)
-#define G_PEAK(x) (((x) >> S_PEAK) & M_PEAK)
-
-#define S_VOFFSN 6
-#define M_VOFFSN 0x3U
-#define V_VOFFSN(x) ((x) << S_VOFFSN)
-#define G_VOFFSN(x) (((x) >> S_VOFFSN) & M_VOFFSN)
-
-#define S_VOFFA 0
-#define M_VOFFA 0x3fU
-#define V_VOFFA(x) ((x) << S_VOFFA)
-#define G_VOFFA(x) (((x) >> S_VOFFA) & M_VOFFA)
-
-#define A_XGMAC_PORT_HSS_RXA_VGA_CTRL2 0x1930
-
-#define S_SHORTV 10
-#define V_SHORTV(x) ((x) << S_SHORTV)
-#define F_SHORTV V_SHORTV(1U)
-
-#define S_VGAIN 0
-#define M_VGAIN 0xfU
-#define V_VGAIN(x) ((x) << S_VGAIN)
-#define G_VGAIN(x) (((x) >> S_VGAIN) & M_VGAIN)
-
-#define A_XGMAC_PORT_HSS_RXA_VGA_CTRL3 0x1934
-
-#define S_HBND1 10
-#define V_HBND1(x) ((x) << S_HBND1)
-#define F_HBND1 V_HBND1(1U)
-
-#define S_HBND0 9
-#define V_HBND0(x) ((x) << S_HBND0)
-#define F_HBND0 V_HBND0(1U)
-
-#define S_VLCKD 8
-#define V_VLCKD(x) ((x) << S_VLCKD)
-#define F_VLCKD V_VLCKD(1U)
-
-#define S_VLCKDF 7
-#define V_VLCKDF(x) ((x) << S_VLCKDF)
-#define F_VLCKDF V_VLCKDF(1U)
-
-#define S_AMAXT 0
-#define M_AMAXT 0x7fU
-#define V_AMAXT(x) ((x) << S_AMAXT)
-#define G_AMAXT(x) (((x) >> S_AMAXT) & M_AMAXT)
-
-#define A_XGMAC_PORT_HSS_RXA_DFE_D00_D01_OFFSET 0x1938
-
-#define S_D01SN 13
-#define M_D01SN 0x3U
-#define V_D01SN(x) ((x) << S_D01SN)
-#define G_D01SN(x) (((x) >> S_D01SN) & M_D01SN)
-
-#define S_D01AMP 8
-#define M_D01AMP 0x1fU
-#define V_D01AMP(x) ((x) << S_D01AMP)
-#define G_D01AMP(x) (((x) >> S_D01AMP) & M_D01AMP)
-
-#define S_D00SN 5
-#define M_D00SN 0x3U
-#define V_D00SN(x) ((x) << S_D00SN)
-#define G_D00SN(x) (((x) >> S_D00SN) & M_D00SN)
-
-#define S_D00AMP 0
-#define M_D00AMP 0x1fU
-#define V_D00AMP(x) ((x) << S_D00AMP)
-#define G_D00AMP(x) (((x) >> S_D00AMP) & M_D00AMP)
-
-#define A_XGMAC_PORT_HSS_RXA_DFE_D10_D11_OFFSET 0x193c
-
-#define S_D11SN 13
-#define M_D11SN 0x3U
-#define V_D11SN(x) ((x) << S_D11SN)
-#define G_D11SN(x) (((x) >> S_D11SN) & M_D11SN)
-
-#define S_D11AMP 8
-#define M_D11AMP 0x1fU
-#define V_D11AMP(x) ((x) << S_D11AMP)
-#define G_D11AMP(x) (((x) >> S_D11AMP) & M_D11AMP)
-
-#define S_D10SN 5
-#define M_D10SN 0x3U
-#define V_D10SN(x) ((x) << S_D10SN)
-#define G_D10SN(x) (((x) >> S_D10SN) & M_D10SN)
-
-#define S_D10AMP 0
-#define M_D10AMP 0x1fU
-#define V_D10AMP(x) ((x) << S_D10AMP)
-#define G_D10AMP(x) (((x) >> S_D10AMP) & M_D10AMP)
-
-#define A_XGMAC_PORT_HSS_RXA_DFE_E0_E1_OFFSET 0x1940
-
-#define S_E1SN 13
-#define M_E1SN 0x3U
-#define V_E1SN(x) ((x) << S_E1SN)
-#define G_E1SN(x) (((x) >> S_E1SN) & M_E1SN)
-
-#define S_E1AMP 8
-#define M_E1AMP 0x1fU
-#define V_E1AMP(x) ((x) << S_E1AMP)
-#define G_E1AMP(x) (((x) >> S_E1AMP) & M_E1AMP)
-
-#define S_E0SN 5
-#define M_E0SN 0x3U
-#define V_E0SN(x) ((x) << S_E0SN)
-#define G_E0SN(x) (((x) >> S_E0SN) & M_E0SN)
-
-#define S_E0AMP 0
-#define M_E0AMP 0x1fU
-#define V_E0AMP(x) ((x) << S_E0AMP)
-#define G_E0AMP(x) (((x) >> S_E0AMP) & M_E0AMP)
-
-#define A_XGMAC_PORT_HSS_RXA_DACA_OFFSET 0x1944
-
-#define S_AOFFO 8
-#define M_AOFFO 0x3fU
-#define V_AOFFO(x) ((x) << S_AOFFO)
-#define G_AOFFO(x) (((x) >> S_AOFFO) & M_AOFFO)
-
-#define S_AOFFE 0
-#define M_AOFFE 0x3fU
-#define V_AOFFE(x) ((x) << S_AOFFE)
-#define G_AOFFE(x) (((x) >> S_AOFFE) & M_AOFFE)
-
-#define A_XGMAC_PORT_HSS_RXA_DACAP_DAC_AN_OFFSET 0x1948
-
-#define S_DACAN 8
-#define M_DACAN 0xffU
-#define V_DACAN(x) ((x) << S_DACAN)
-#define G_DACAN(x) (((x) >> S_DACAN) & M_DACAN)
-
-#define S_DACAP 0
-#define M_DACAP 0xffU
-#define V_DACAP(x) ((x) << S_DACAP)
-#define G_DACAP(x) (((x) >> S_DACAP) & M_DACAP)
-
-#define A_XGMAC_PORT_HSS_RXA_DACA_MIN 0x194c
-
-#define S_DACAZ 8
-#define M_DACAZ 0xffU
-#define V_DACAZ(x) ((x) << S_DACAZ)
-#define G_DACAZ(x) (((x) >> S_DACAZ) & M_DACAZ)
-
-#define S_DACAM 0
-#define M_DACAM 0xffU
-#define V_DACAM(x) ((x) << S_DACAM)
-#define G_DACAM(x) (((x) >> S_DACAM) & M_DACAM)
-
-#define A_XGMAC_PORT_HSS_RXA_ADAC_CTRL 0x1950
-
-#define S_ADSN 7
-#define M_ADSN 0x3U
-#define V_ADSN(x) ((x) << S_ADSN)
-#define G_ADSN(x) (((x) >> S_ADSN) & M_ADSN)
-
-#define S_ADMAG 0
-#define M_ADMAG 0x7fU
-#define V_ADMAG(x) ((x) << S_ADMAG)
-#define G_ADMAG(x) (((x) >> S_ADMAG) & M_ADMAG)
-
-#define A_XGMAC_PORT_HSS_RXA_DIGITAL_EYE_CTRL 0x1954
-
-#define S_BLKAZ 15
-#define V_BLKAZ(x) ((x) << S_BLKAZ)
-#define F_BLKAZ V_BLKAZ(1U)
-
-#define S_WIDTH 10
-#define M_WIDTH 0x1fU
-#define V_WIDTH(x) ((x) << S_WIDTH)
-#define G_WIDTH(x) (((x) >> S_WIDTH) & M_WIDTH)
-
-#define S_MINWIDTH 5
-#define M_MINWIDTH 0x1fU
-#define V_MINWIDTH(x) ((x) << S_MINWIDTH)
-#define G_MINWIDTH(x) (((x) >> S_MINWIDTH) & M_MINWIDTH)
-
-#define S_MINAMP 0
-#define M_MINAMP 0x1fU
-#define V_MINAMP(x) ((x) << S_MINAMP)
-#define G_MINAMP(x) (((x) >> S_MINAMP) & M_MINAMP)
-
-#define A_XGMAC_PORT_HSS_RXA_DIGITAL_EYE_METRICS 0x1958
-
-#define S_EMBRDY 10
-#define V_EMBRDY(x) ((x) << S_EMBRDY)
-#define F_EMBRDY V_EMBRDY(1U)
-
-#define S_EMBUMP 7
-#define V_EMBUMP(x) ((x) << S_EMBUMP)
-#define F_EMBUMP V_EMBUMP(1U)
-
-#define S_EMMD 5
-#define M_EMMD 0x3U
-#define V_EMMD(x) ((x) << S_EMMD)
-#define G_EMMD(x) (((x) >> S_EMMD) & M_EMMD)
-
-#define S_EMPAT 1
-#define V_EMPAT(x) ((x) << S_EMPAT)
-#define F_EMPAT V_EMPAT(1U)
-
-#define S_EMEN 0
-#define V_EMEN(x) ((x) << S_EMEN)
-#define F_EMEN V_EMEN(1U)
-
-#define A_XGMAC_PORT_HSS_RXA_DFE_H1 0x195c
-
-#define S_H1OSN 14
-#define M_H1OSN 0x3U
-#define V_H1OSN(x) ((x) << S_H1OSN)
-#define G_H1OSN(x) (((x) >> S_H1OSN) & M_H1OSN)
-
-#define S_H1OMAG 8
-#define M_H1OMAG 0x3fU
-#define V_H1OMAG(x) ((x) << S_H1OMAG)
-#define G_H1OMAG(x) (((x) >> S_H1OMAG) & M_H1OMAG)
-
-#define S_H1ESN 6
-#define M_H1ESN 0x3U
-#define V_H1ESN(x) ((x) << S_H1ESN)
-#define G_H1ESN(x) (((x) >> S_H1ESN) & M_H1ESN)
-
-#define S_H1EMAG 0
-#define M_H1EMAG 0x3fU
-#define V_H1EMAG(x) ((x) << S_H1EMAG)
-#define G_H1EMAG(x) (((x) >> S_H1EMAG) & M_H1EMAG)
-
-#define A_XGMAC_PORT_HSS_RXA_DFE_H2 0x1960
-
-#define S_H2OSN 13
-#define M_H2OSN 0x3U
-#define V_H2OSN(x) ((x) << S_H2OSN)
-#define G_H2OSN(x) (((x) >> S_H2OSN) & M_H2OSN)
-
-#define S_H2OMAG 8
-#define M_H2OMAG 0x1fU
-#define V_H2OMAG(x) ((x) << S_H2OMAG)
-#define G_H2OMAG(x) (((x) >> S_H2OMAG) & M_H2OMAG)
-
-#define S_H2ESN 5
-#define M_H2ESN 0x3U
-#define V_H2ESN(x) ((x) << S_H2ESN)
-#define G_H2ESN(x) (((x) >> S_H2ESN) & M_H2ESN)
-
-#define S_H2EMAG 0
-#define M_H2EMAG 0x1fU
-#define V_H2EMAG(x) ((x) << S_H2EMAG)
-#define G_H2EMAG(x) (((x) >> S_H2EMAG) & M_H2EMAG)
-
-#define A_XGMAC_PORT_HSS_RXA_DFE_H3 0x1964
-
-#define S_H3OSN 12
-#define M_H3OSN 0x3U
-#define V_H3OSN(x) ((x) << S_H3OSN)
-#define G_H3OSN(x) (((x) >> S_H3OSN) & M_H3OSN)
-
-#define S_H3OMAG 8
-#define M_H3OMAG 0xfU
-#define V_H3OMAG(x) ((x) << S_H3OMAG)
-#define G_H3OMAG(x) (((x) >> S_H3OMAG) & M_H3OMAG)
-
-#define S_H3ESN 4
-#define M_H3ESN 0x3U
-#define V_H3ESN(x) ((x) << S_H3ESN)
-#define G_H3ESN(x) (((x) >> S_H3ESN) & M_H3ESN)
-
-#define S_H3EMAG 0
-#define M_H3EMAG 0xfU
-#define V_H3EMAG(x) ((x) << S_H3EMAG)
-#define G_H3EMAG(x) (((x) >> S_H3EMAG) & M_H3EMAG)
-
-#define A_XGMAC_PORT_HSS_RXA_DFE_H4 0x1968
-
-#define S_H4OSN 12
-#define M_H4OSN 0x3U
-#define V_H4OSN(x) ((x) << S_H4OSN)
-#define G_H4OSN(x) (((x) >> S_H4OSN) & M_H4OSN)
-
-#define S_H4OMAG 8
-#define M_H4OMAG 0xfU
-#define V_H4OMAG(x) ((x) << S_H4OMAG)
-#define G_H4OMAG(x) (((x) >> S_H4OMAG) & M_H4OMAG)
-
-#define S_H4ESN 4
-#define M_H4ESN 0x3U
-#define V_H4ESN(x) ((x) << S_H4ESN)
-#define G_H4ESN(x) (((x) >> S_H4ESN) & M_H4ESN)
-
-#define S_H4EMAG 0
-#define M_H4EMAG 0xfU
-#define V_H4EMAG(x) ((x) << S_H4EMAG)
-#define G_H4EMAG(x) (((x) >> S_H4EMAG) & M_H4EMAG)
-
-#define A_XGMAC_PORT_HSS_RXA_DFE_H5 0x196c
-
-#define S_H5OSN 12
-#define M_H5OSN 0x3U
-#define V_H5OSN(x) ((x) << S_H5OSN)
-#define G_H5OSN(x) (((x) >> S_H5OSN) & M_H5OSN)
-
-#define S_H5OMAG 8
-#define M_H5OMAG 0xfU
-#define V_H5OMAG(x) ((x) << S_H5OMAG)
-#define G_H5OMAG(x) (((x) >> S_H5OMAG) & M_H5OMAG)
-
-#define S_H5ESN 4
-#define M_H5ESN 0x3U
-#define V_H5ESN(x) ((x) << S_H5ESN)
-#define G_H5ESN(x) (((x) >> S_H5ESN) & M_H5ESN)
-
-#define S_H5EMAG 0
-#define M_H5EMAG 0xfU
-#define V_H5EMAG(x) ((x) << S_H5EMAG)
-#define G_H5EMAG(x) (((x) >> S_H5EMAG) & M_H5EMAG)
-
-#define A_XGMAC_PORT_HSS_RXA_DAC_DPC 0x1970
-
-#define S_DPCCVG 13
-#define V_DPCCVG(x) ((x) << S_DPCCVG)
-#define F_DPCCVG V_DPCCVG(1U)
-
-#define S_DACCVG 12
-#define V_DACCVG(x) ((x) << S_DACCVG)
-#define F_DACCVG V_DACCVG(1U)
-
-#define S_DPCTGT 9
-#define M_DPCTGT 0x7U
-#define V_DPCTGT(x) ((x) << S_DPCTGT)
-#define G_DPCTGT(x) (((x) >> S_DPCTGT) & M_DPCTGT)
-
-#define S_BLKH1T 8
-#define V_BLKH1T(x) ((x) << S_BLKH1T)
-#define F_BLKH1T V_BLKH1T(1U)
-
-#define S_BLKOAE 7
-#define V_BLKOAE(x) ((x) << S_BLKOAE)
-#define F_BLKOAE V_BLKOAE(1U)
-
-#define S_H1TGT 4
-#define M_H1TGT 0x7U
-#define V_H1TGT(x) ((x) << S_H1TGT)
-#define G_H1TGT(x) (((x) >> S_H1TGT) & M_H1TGT)
-
-#define S_OAE 0
-#define M_OAE 0xfU
-#define V_OAE(x) ((x) << S_OAE)
-#define G_OAE(x) (((x) >> S_OAE) & M_OAE)
-
-#define A_XGMAC_PORT_HSS_RXA_DDC 0x1974
-
-#define S_OLS 11
-#define M_OLS 0x1fU
-#define V_OLS(x) ((x) << S_OLS)
-#define G_OLS(x) (((x) >> S_OLS) & M_OLS)
-
-#define S_OES 6
-#define M_OES 0x1fU
-#define V_OES(x) ((x) << S_OES)
-#define G_OES(x) (((x) >> S_OES) & M_OES)
-
-#define S_BLKODEC 5
-#define V_BLKODEC(x) ((x) << S_BLKODEC)
-#define F_BLKODEC V_BLKODEC(1U)
-
-#define S_ODEC 0
-#define M_ODEC 0x1fU
-#define V_ODEC(x) ((x) << S_ODEC)
-#define G_ODEC(x) (((x) >> S_ODEC) & M_ODEC)
-
-#define A_XGMAC_PORT_HSS_RXA_INTERNAL_STATUS 0x1978
-
-#define S_BER6 15
-#define V_BER6(x) ((x) << S_BER6)
-#define F_BER6 V_BER6(1U)
-
-#define S_BER6VAL 14
-#define V_BER6VAL(x) ((x) << S_BER6VAL)
-#define F_BER6VAL V_BER6VAL(1U)
-
-#define S_BER3VAL 13
-#define V_BER3VAL(x) ((x) << S_BER3VAL)
-#define F_BER3VAL V_BER3VAL(1U)
-
-#define S_DPCCMP 9
-#define V_DPCCMP(x) ((x) << S_DPCCMP)
-#define F_DPCCMP V_DPCCMP(1U)
-
-#define S_DACCMP 8
-#define V_DACCMP(x) ((x) << S_DACCMP)
-#define F_DACCMP V_DACCMP(1U)
-
-#define S_DDCCMP 7
-#define V_DDCCMP(x) ((x) << S_DDCCMP)
-#define F_DDCCMP V_DDCCMP(1U)
-
-#define S_AERRFLG 6
-#define V_AERRFLG(x) ((x) << S_AERRFLG)
-#define F_AERRFLG V_AERRFLG(1U)
-
-#define S_WERRFLG 5
-#define V_WERRFLG(x) ((x) << S_WERRFLG)
-#define F_WERRFLG V_WERRFLG(1U)
-
-#define S_TRCMP 4
-#define V_TRCMP(x) ((x) << S_TRCMP)
-#define F_TRCMP V_TRCMP(1U)
-
-#define S_VLCKF 3
-#define V_VLCKF(x) ((x) << S_VLCKF)
-#define F_VLCKF V_VLCKF(1U)
-
-#define S_ROCADJ 2
-#define V_ROCADJ(x) ((x) << S_ROCADJ)
-#define F_ROCADJ V_ROCADJ(1U)
-
-#define S_ROCCMP 1
-#define V_ROCCMP(x) ((x) << S_ROCCMP)
-#define F_ROCCMP V_ROCCMP(1U)
-
-#define S_OCCMP 0
-#define V_OCCMP(x) ((x) << S_OCCMP)
-#define F_OCCMP V_OCCMP(1U)
-
-#define A_XGMAC_PORT_HSS_RXA_DFE_FUNC_CTRL 0x197c
-
-#define S_FDPC 15
-#define V_FDPC(x) ((x) << S_FDPC)
-#define F_FDPC V_FDPC(1U)
-
-#define S_FDAC 14
-#define V_FDAC(x) ((x) << S_FDAC)
-#define F_FDAC V_FDAC(1U)
-
-#define S_FDDC 13
-#define V_FDDC(x) ((x) << S_FDDC)
-#define F_FDDC V_FDDC(1U)
-
-#define S_FNRND 12
-#define V_FNRND(x) ((x) << S_FNRND)
-#define F_FNRND V_FNRND(1U)
-
-#define S_FVGAIN 11
-#define V_FVGAIN(x) ((x) << S_FVGAIN)
-#define F_FVGAIN V_FVGAIN(1U)
-
-#define S_FVOFF 10
-#define V_FVOFF(x) ((x) << S_FVOFF)
-#define F_FVOFF V_FVOFF(1U)
-
-#define S_FSDET 9
-#define V_FSDET(x) ((x) << S_FSDET)
-#define F_FSDET V_FSDET(1U)
-
-#define S_FBER6 8
-#define V_FBER6(x) ((x) << S_FBER6)
-#define F_FBER6 V_FBER6(1U)
-
-#define S_FROTO 7
-#define V_FROTO(x) ((x) << S_FROTO)
-#define F_FROTO V_FROTO(1U)
-
-#define S_FH4H5 6
-#define V_FH4H5(x) ((x) << S_FH4H5)
-#define F_FH4H5 V_FH4H5(1U)
-
-#define S_FH2H3 5
-#define V_FH2H3(x) ((x) << S_FH2H3)
-#define F_FH2H3 V_FH2H3(1U)
-
-#define S_FH1 4
-#define V_FH1(x) ((x) << S_FH1)
-#define F_FH1 V_FH1(1U)
-
-#define S_FH1SN 3
-#define V_FH1SN(x) ((x) << S_FH1SN)
-#define F_FH1SN V_FH1SN(1U)
-
-#define S_FNRDF 2
-#define V_FNRDF(x) ((x) << S_FNRDF)
-#define F_FNRDF V_FNRDF(1U)
-
-#define S_FADAC 0
-#define V_FADAC(x) ((x) << S_FADAC)
-#define F_FADAC V_FADAC(1U)
-
-#define A_XGMAC_PORT_HSS_RXB_CFG_MODE 0x1980
-#define A_XGMAC_PORT_HSS_RXB_TEST_CTRL 0x1984
-#define A_XGMAC_PORT_HSS_RXB_PH_ROTATOR_CTRL 0x1988
-#define A_XGMAC_PORT_HSS_RXB_PH_ROTATOR_OFFSET_CTRL 0x198c
-#define A_XGMAC_PORT_HSS_RXB_PH_ROTATOR_POSITION1 0x1990
-#define A_XGMAC_PORT_HSS_RXB_PH_ROTATOR_POSITION2 0x1994
-#define A_XGMAC_PORT_HSS_RXB_PH_ROTATOR_STATIC_PH_OFFSET 0x1998
-#define A_XGMAC_PORT_HSS_RXB_SIGDET_CTRL 0x199c
-#define A_XGMAC_PORT_HSS_RXB_DFE_CTRL 0x19a0
-#define A_XGMAC_PORT_HSS_RXB_DFE_DATA_EDGE_SAMPLE 0x19a4
-#define A_XGMAC_PORT_HSS_RXB_DFE_AMP_SAMPLE 0x19a8
-#define A_XGMAC_PORT_HSS_RXB_VGA_CTRL1 0x19ac
-#define A_XGMAC_PORT_HSS_RXB_VGA_CTRL2 0x19b0
-#define A_XGMAC_PORT_HSS_RXB_VGA_CTRL3 0x19b4
-#define A_XGMAC_PORT_HSS_RXB_DFE_D00_D01_OFFSET 0x19b8
-#define A_XGMAC_PORT_HSS_RXB_DFE_D10_D11_OFFSET 0x19bc
-#define A_XGMAC_PORT_HSS_RXB_DFE_E0_E1_OFFSET 0x19c0
-#define A_XGMAC_PORT_HSS_RXB_DACA_OFFSET 0x19c4
-#define A_XGMAC_PORT_HSS_RXB_DACAP_DAC_AN_OFFSET 0x19c8
-#define A_XGMAC_PORT_HSS_RXB_DACA_MIN 0x19cc
-#define A_XGMAC_PORT_HSS_RXB_ADAC_CTRL 0x19d0
-#define A_XGMAC_PORT_HSS_RXB_DIGITAL_EYE_CTRL 0x19d4
-#define A_XGMAC_PORT_HSS_RXB_DIGITAL_EYE_METRICS 0x19d8
-#define A_XGMAC_PORT_HSS_RXB_DFE_H1 0x19dc
-#define A_XGMAC_PORT_HSS_RXB_DFE_H2 0x19e0
-#define A_XGMAC_PORT_HSS_RXB_DFE_H3 0x19e4
-#define A_XGMAC_PORT_HSS_RXB_DFE_H4 0x19e8
-#define A_XGMAC_PORT_HSS_RXB_DFE_H5 0x19ec
-#define A_XGMAC_PORT_HSS_RXB_DAC_DPC 0x19f0
-#define A_XGMAC_PORT_HSS_RXB_DDC 0x19f4
-#define A_XGMAC_PORT_HSS_RXB_INTERNAL_STATUS 0x19f8
-#define A_XGMAC_PORT_HSS_RXB_DFE_FUNC_CTRL 0x19fc
-#define A_XGMAC_PORT_HSS_TXC_MODE_CFG 0x1a00
-#define A_XGMAC_PORT_HSS_TXC_TEST_CTRL 0x1a04
-#define A_XGMAC_PORT_HSS_TXC_COEFF_CTRL 0x1a08
-#define A_XGMAC_PORT_HSS_TXC_DRIVER_MODE 0x1a0c
-#define A_XGMAC_PORT_HSS_TXC_DRIVER_OVR_CTRL 0x1a10
-#define A_XGMAC_PORT_HSS_TXC_TDM_BIASGEN_STANDBY_TIMER 0x1a14
-#define A_XGMAC_PORT_HSS_TXC_TDM_BIASGEN_PWRON_TIMER 0x1a18
-#define A_XGMAC_PORT_HSS_TXC_TAP0_COEFF 0x1a20
-#define A_XGMAC_PORT_HSS_TXC_TAP1_COEFF 0x1a24
-#define A_XGMAC_PORT_HSS_TXC_TAP2_COEFF 0x1a28
-#define A_XGMAC_PORT_HSS_TXC_PWR 0x1a30
-#define A_XGMAC_PORT_HSS_TXC_POLARITY 0x1a34
-#define A_XGMAC_PORT_HSS_TXC_8023AP_AE_CMD 0x1a38
-#define A_XGMAC_PORT_HSS_TXC_8023AP_AE_STATUS 0x1a3c
-#define A_XGMAC_PORT_HSS_TXC_TAP0_IDAC_OVR 0x1a40
-#define A_XGMAC_PORT_HSS_TXC_TAP1_IDAC_OVR 0x1a44
-#define A_XGMAC_PORT_HSS_TXC_TAP2_IDAC_OVR 0x1a48
-#define A_XGMAC_PORT_HSS_TXC_PWR_DAC_OVR 0x1a50
-#define A_XGMAC_PORT_HSS_TXC_PWR_DAC 0x1a54
-#define A_XGMAC_PORT_HSS_TXC_TAP0_IDAC_APP 0x1a60
-#define A_XGMAC_PORT_HSS_TXC_TAP1_IDAC_APP 0x1a64
-#define A_XGMAC_PORT_HSS_TXC_TAP2_IDAC_APP 0x1a68
-#define A_XGMAC_PORT_HSS_TXC_SEG_DIS_APP 0x1a70
-#define A_XGMAC_PORT_HSS_TXC_EXT_ADDR_DATA 0x1a78
-#define A_XGMAC_PORT_HSS_TXC_EXT_ADDR 0x1a7c
-#define A_XGMAC_PORT_HSS_TXD_MODE_CFG 0x1a80
-#define A_XGMAC_PORT_HSS_TXD_TEST_CTRL 0x1a84
-#define A_XGMAC_PORT_HSS_TXD_COEFF_CTRL 0x1a88
-#define A_XGMAC_PORT_HSS_TXD_DRIVER_MODE 0x1a8c
-#define A_XGMAC_PORT_HSS_TXD_DRIVER_OVR_CTRL 0x1a90
-#define A_XGMAC_PORT_HSS_TXD_TDM_BIASGEN_STANDBY_TIMER 0x1a94
-#define A_XGMAC_PORT_HSS_TXD_TDM_BIASGEN_PWRON_TIMER 0x1a98
-#define A_XGMAC_PORT_HSS_TXD_TAP0_COEFF 0x1aa0
-#define A_XGMAC_PORT_HSS_TXD_TAP1_COEFF 0x1aa4
-#define A_XGMAC_PORT_HSS_TXD_TAP2_COEFF 0x1aa8
-#define A_XGMAC_PORT_HSS_TXD_PWR 0x1ab0
-#define A_XGMAC_PORT_HSS_TXD_POLARITY 0x1ab4
-#define A_XGMAC_PORT_HSS_TXD_8023AP_AE_CMD 0x1ab8
-#define A_XGMAC_PORT_HSS_TXD_8023AP_AE_STATUS 0x1abc
-#define A_XGMAC_PORT_HSS_TXD_TAP0_IDAC_OVR 0x1ac0
-#define A_XGMAC_PORT_HSS_TXD_TAP1_IDAC_OVR 0x1ac4
-#define A_XGMAC_PORT_HSS_TXD_TAP2_IDAC_OVR 0x1ac8
-#define A_XGMAC_PORT_HSS_TXD_PWR_DAC_OVR 0x1ad0
-#define A_XGMAC_PORT_HSS_TXD_PWR_DAC 0x1ad4
-#define A_XGMAC_PORT_HSS_TXD_TAP0_IDAC_APP 0x1ae0
-#define A_XGMAC_PORT_HSS_TXD_TAP1_IDAC_APP 0x1ae4
-#define A_XGMAC_PORT_HSS_TXD_TAP2_IDAC_APP 0x1ae8
-#define A_XGMAC_PORT_HSS_TXD_SEG_DIS_APP 0x1af0
-#define A_XGMAC_PORT_HSS_TXD_EXT_ADDR_DATA 0x1af8
-#define A_XGMAC_PORT_HSS_TXD_EXT_ADDR 0x1afc
-#define A_XGMAC_PORT_HSS_RXC_CFG_MODE 0x1b00
-#define A_XGMAC_PORT_HSS_RXC_TEST_CTRL 0x1b04
-#define A_XGMAC_PORT_HSS_RXC_PH_ROTATOR_CTRL 0x1b08
-#define A_XGMAC_PORT_HSS_RXC_PH_ROTATOR_OFFSET_CTRL 0x1b0c
-#define A_XGMAC_PORT_HSS_RXC_PH_ROTATOR_POSITION1 0x1b10
-#define A_XGMAC_PORT_HSS_RXC_PH_ROTATOR_POSITION2 0x1b14
-#define A_XGMAC_PORT_HSS_RXC_PH_ROTATOR_STATIC_PH_OFFSET 0x1b18
-#define A_XGMAC_PORT_HSS_RXC_SIGDET_CTRL 0x1b1c
-#define A_XGMAC_PORT_HSS_RXC_DFE_CTRL 0x1b20
-#define A_XGMAC_PORT_HSS_RXC_DFE_DATA_EDGE_SAMPLE 0x1b24
-#define A_XGMAC_PORT_HSS_RXC_DFE_AMP_SAMPLE 0x1b28
-#define A_XGMAC_PORT_HSS_RXC_VGA_CTRL1 0x1b2c
-#define A_XGMAC_PORT_HSS_RXC_VGA_CTRL2 0x1b30
-#define A_XGMAC_PORT_HSS_RXC_VGA_CTRL3 0x1b34
-#define A_XGMAC_PORT_HSS_RXC_DFE_D00_D01_OFFSET 0x1b38
-#define A_XGMAC_PORT_HSS_RXC_DFE_D10_D11_OFFSET 0x1b3c
-#define A_XGMAC_PORT_HSS_RXC_DFE_E0_E1_OFFSET 0x1b40
-#define A_XGMAC_PORT_HSS_RXC_DACA_OFFSET 0x1b44
-#define A_XGMAC_PORT_HSS_RXC_DACAP_DAC_AN_OFFSET 0x1b48
-#define A_XGMAC_PORT_HSS_RXC_DACA_MIN 0x1b4c
-#define A_XGMAC_PORT_HSS_RXC_ADAC_CTRL 0x1b50
-#define A_XGMAC_PORT_HSS_RXC_DIGITAL_EYE_CTRL 0x1b54
-#define A_XGMAC_PORT_HSS_RXC_DIGITAL_EYE_METRICS 0x1b58
-#define A_XGMAC_PORT_HSS_RXC_DFE_H1 0x1b5c
-#define A_XGMAC_PORT_HSS_RXC_DFE_H2 0x1b60
-#define A_XGMAC_PORT_HSS_RXC_DFE_H3 0x1b64
-#define A_XGMAC_PORT_HSS_RXC_DFE_H4 0x1b68
-#define A_XGMAC_PORT_HSS_RXC_DFE_H5 0x1b6c
-#define A_XGMAC_PORT_HSS_RXC_DAC_DPC 0x1b70
-#define A_XGMAC_PORT_HSS_RXC_DDC 0x1b74
-#define A_XGMAC_PORT_HSS_RXC_INTERNAL_STATUS 0x1b78
-#define A_XGMAC_PORT_HSS_RXC_DFE_FUNC_CTRL 0x1b7c
-#define A_XGMAC_PORT_HSS_RXD_CFG_MODE 0x1b80
-#define A_XGMAC_PORT_HSS_RXD_TEST_CTRL 0x1b84
-#define A_XGMAC_PORT_HSS_RXD_PH_ROTATOR_CTRL 0x1b88
-#define A_XGMAC_PORT_HSS_RXD_PH_ROTATOR_OFFSET_CTRL 0x1b8c
-#define A_XGMAC_PORT_HSS_RXD_PH_ROTATOR_POSITION1 0x1b90
-#define A_XGMAC_PORT_HSS_RXD_PH_ROTATOR_POSITION2 0x1b94
-#define A_XGMAC_PORT_HSS_RXD_PH_ROTATOR_STATIC_PH_OFFSET 0x1b98
-#define A_XGMAC_PORT_HSS_RXD_SIGDET_CTRL 0x1b9c
-#define A_XGMAC_PORT_HSS_RXD_DFE_CTRL 0x1ba0
-#define A_XGMAC_PORT_HSS_RXD_DFE_DATA_EDGE_SAMPLE 0x1ba4
-#define A_XGMAC_PORT_HSS_RXD_DFE_AMP_SAMPLE 0x1ba8
-#define A_XGMAC_PORT_HSS_RXD_VGA_CTRL1 0x1bac
-#define A_XGMAC_PORT_HSS_RXD_VGA_CTRL2 0x1bb0
-#define A_XGMAC_PORT_HSS_RXD_VGA_CTRL3 0x1bb4
-#define A_XGMAC_PORT_HSS_RXD_DFE_D00_D01_OFFSET 0x1bb8
-#define A_XGMAC_PORT_HSS_RXD_DFE_D10_D11_OFFSET 0x1bbc
-#define A_XGMAC_PORT_HSS_RXD_DFE_E0_E1_OFFSET 0x1bc0
-#define A_XGMAC_PORT_HSS_RXD_DACA_OFFSET 0x1bc4
-#define A_XGMAC_PORT_HSS_RXD_DACAP_DAC_AN_OFFSET 0x1bc8
-#define A_XGMAC_PORT_HSS_RXD_DACA_MIN 0x1bcc
-#define A_XGMAC_PORT_HSS_RXD_ADAC_CTRL 0x1bd0
-#define A_XGMAC_PORT_HSS_RXD_DIGITAL_EYE_CTRL 0x1bd4
-#define A_XGMAC_PORT_HSS_RXD_DIGITAL_EYE_METRICS 0x1bd8
-#define A_XGMAC_PORT_HSS_RXD_DFE_H1 0x1bdc
-#define A_XGMAC_PORT_HSS_RXD_DFE_H2 0x1be0
-#define A_XGMAC_PORT_HSS_RXD_DFE_H3 0x1be4
-#define A_XGMAC_PORT_HSS_RXD_DFE_H4 0x1be8
-#define A_XGMAC_PORT_HSS_RXD_DFE_H5 0x1bec
-#define A_XGMAC_PORT_HSS_RXD_DAC_DPC 0x1bf0
-#define A_XGMAC_PORT_HSS_RXD_DDC 0x1bf4
-#define A_XGMAC_PORT_HSS_RXD_INTERNAL_STATUS 0x1bf8
-#define A_XGMAC_PORT_HSS_RXD_DFE_FUNC_CTRL 0x1bfc
-#define A_XGMAC_PORT_HSS_VCO_COARSE_CALIBRATION_0 0x1c00
-
-#define S_BSELO 0
-#define M_BSELO 0xfU
-#define V_BSELO(x) ((x) << S_BSELO)
-#define G_BSELO(x) (((x) >> S_BSELO) & M_BSELO)
-
-#define A_XGMAC_PORT_HSS_VCO_COARSE_CALIBRATION_1 0x1c04
-
-#define S_LDET 4
-#define V_LDET(x) ((x) << S_LDET)
-#define F_LDET V_LDET(1U)
-
-#define S_CCERR 3
-#define V_CCERR(x) ((x) << S_CCERR)
-#define F_CCERR V_CCERR(1U)
-
-#define S_CCCMP 2
-#define V_CCCMP(x) ((x) << S_CCCMP)
-#define F_CCCMP V_CCCMP(1U)
-
-#define A_XGMAC_PORT_HSS_VCO_COARSE_CALIBRATION_2 0x1c08
-
-#define S_BSELI 0
-#define M_BSELI 0xfU
-#define V_BSELI(x) ((x) << S_BSELI)
-#define G_BSELI(x) (((x) >> S_BSELI) & M_BSELI)
-
-#define A_XGMAC_PORT_HSS_VCO_COARSE_CALIBRATION_3 0x1c0c
-
-#define S_VISEL 4
-#define V_VISEL(x) ((x) << S_VISEL)
-#define F_VISEL V_VISEL(1U)
-
-#define S_FMIN 3
-#define V_FMIN(x) ((x) << S_FMIN)
-#define F_FMIN V_FMIN(1U)
-
-#define S_FMAX 2
-#define V_FMAX(x) ((x) << S_FMAX)
-#define F_FMAX V_FMAX(1U)
-
-#define S_CVHOLD 1
-#define V_CVHOLD(x) ((x) << S_CVHOLD)
-#define F_CVHOLD V_CVHOLD(1U)
-
-#define S_TCDIS 0
-#define V_TCDIS(x) ((x) << S_TCDIS)
-#define F_TCDIS V_TCDIS(1U)
-
-#define A_XGMAC_PORT_HSS_VCO_COARSE_CALIBRATION_4 0x1c10
-
-#define S_CMETH 2
-#define V_CMETH(x) ((x) << S_CMETH)
-#define F_CMETH V_CMETH(1U)
-
-#define S_RECAL 1
-#define V_RECAL(x) ((x) << S_RECAL)
-#define F_RECAL V_RECAL(1U)
-
-#define S_CCLD 0
-#define V_CCLD(x) ((x) << S_CCLD)
-#define F_CCLD V_CCLD(1U)
-
-#define A_XGMAC_PORT_HSS_ANALOG_TEST_MUX 0x1c14
-
-#define S_ATST 0
-#define M_ATST 0x1fU
-#define V_ATST(x) ((x) << S_ATST)
-#define G_ATST(x) (((x) >> S_ATST) & M_ATST)
-
-#define A_XGMAC_PORT_HSS_PORT_EN_0 0x1c18
-
-#define S_RXDEN 7
-#define V_RXDEN(x) ((x) << S_RXDEN)
-#define F_RXDEN V_RXDEN(1U)
-
-#define S_RXCEN 6
-#define V_RXCEN(x) ((x) << S_RXCEN)
-#define F_RXCEN V_RXCEN(1U)
-
-#define S_TXDEN 5
-#define V_TXDEN(x) ((x) << S_TXDEN)
-#define F_TXDEN V_TXDEN(1U)
-
-#define S_TXCEN 4
-#define V_TXCEN(x) ((x) << S_TXCEN)
-#define F_TXCEN V_TXCEN(1U)
-
-#define S_RXBEN 3
-#define V_RXBEN(x) ((x) << S_RXBEN)
-#define F_RXBEN V_RXBEN(1U)
-
-#define S_RXAEN 2
-#define V_RXAEN(x) ((x) << S_RXAEN)
-#define F_RXAEN V_RXAEN(1U)
-
-#define S_TXBEN 1
-#define V_TXBEN(x) ((x) << S_TXBEN)
-#define F_TXBEN V_TXBEN(1U)
-
-#define S_TXAEN 0
-#define V_TXAEN(x) ((x) << S_TXAEN)
-#define F_TXAEN V_TXAEN(1U)
-
-#define A_XGMAC_PORT_HSS_PORT_RESET_0 0x1c20
-
-#define S_RXDRST 7
-#define V_RXDRST(x) ((x) << S_RXDRST)
-#define F_RXDRST V_RXDRST(1U)
-
-#define S_RXCRST 6
-#define V_RXCRST(x) ((x) << S_RXCRST)
-#define F_RXCRST V_RXCRST(1U)
-
-#define S_TXDRST 5
-#define V_TXDRST(x) ((x) << S_TXDRST)
-#define F_TXDRST V_TXDRST(1U)
-
-#define S_TXCRST 4
-#define V_TXCRST(x) ((x) << S_TXCRST)
-#define F_TXCRST V_TXCRST(1U)
-
-#define S_RXBRST 3
-#define V_RXBRST(x) ((x) << S_RXBRST)
-#define F_RXBRST V_RXBRST(1U)
-
-#define S_RXARST 2
-#define V_RXARST(x) ((x) << S_RXARST)
-#define F_RXARST V_RXARST(1U)
-
-#define S_TXBRST 1
-#define V_TXBRST(x) ((x) << S_TXBRST)
-#define F_TXBRST V_TXBRST(1U)
-
-#define S_TXARST 0
-#define V_TXARST(x) ((x) << S_TXARST)
-#define F_TXARST V_TXARST(1U)
-
-#define A_XGMAC_PORT_HSS_CHARGE_PUMP_CTRL 0x1c28
-
-#define S_ENCPIS 2
-#define V_ENCPIS(x) ((x) << S_ENCPIS)
-#define F_ENCPIS V_ENCPIS(1U)
-
-#define S_CPISEL 0
-#define M_CPISEL 0x3U
-#define V_CPISEL(x) ((x) << S_CPISEL)
-#define G_CPISEL(x) (((x) >> S_CPISEL) & M_CPISEL)
-
-#define A_XGMAC_PORT_HSS_BAND_GAP_CTRL 0x1c2c
-
-#define S_BGCTL 0
-#define M_BGCTL 0x1fU
-#define V_BGCTL(x) ((x) << S_BGCTL)
-#define G_BGCTL(x) (((x) >> S_BGCTL) & M_BGCTL)
-
-#define A_XGMAC_PORT_HSS_LOFREQ_OVR 0x1c30
-
-#define S_LFREQ2 3
-#define V_LFREQ2(x) ((x) << S_LFREQ2)
-#define F_LFREQ2 V_LFREQ2(1U)
-
-#define S_LFREQ1 2
-#define V_LFREQ1(x) ((x) << S_LFREQ1)
-#define F_LFREQ1 V_LFREQ1(1U)
-
-#define S_LFREQO 1
-#define V_LFREQO(x) ((x) << S_LFREQO)
-#define F_LFREQO V_LFREQO(1U)
-
-#define S_LFSEL 0
-#define V_LFSEL(x) ((x) << S_LFSEL)
-#define F_LFSEL V_LFSEL(1U)
-
-#define A_XGMAC_PORT_HSS_VOLTAGE_BOOST_CTRL 0x1c38
-
-#define S_PFVAL 2
-#define V_PFVAL(x) ((x) << S_PFVAL)
-#define F_PFVAL V_PFVAL(1U)
-
-#define S_PFEN 1
-#define V_PFEN(x) ((x) << S_PFEN)
-#define F_PFEN V_PFEN(1U)
-
-#define S_VBADJ 0
-#define V_VBADJ(x) ((x) << S_VBADJ)
-#define F_VBADJ V_VBADJ(1U)
-
-#define A_XGMAC_PORT_HSS_TX_MODE_CFG 0x1c80
-#define A_XGMAC_PORT_HSS_TXTEST_CTRL 0x1c84
-#define A_XGMAC_PORT_HSS_TX_COEFF_CTRL 0x1c88
-#define A_XGMAC_PORT_HSS_TX_DRIVER_MODE 0x1c8c
-#define A_XGMAC_PORT_HSS_TX_DRIVER_OVR_CTRL 0x1c90
-#define A_XGMAC_PORT_HSS_TX_TDM_BIASGEN_STANDBY_TIMER 0x1c94
-#define A_XGMAC_PORT_HSS_TX_TDM_BIASGEN_PWRON_TIMER 0x1c98
-#define A_XGMAC_PORT_HSS_TX_TAP0_COEFF 0x1ca0
-#define A_XGMAC_PORT_HSS_TX_TAP1_COEFF 0x1ca4
-#define A_XGMAC_PORT_HSS_TX_TAP2_COEFF 0x1ca8
-#define A_XGMAC_PORT_HSS_TX_PWR 0x1cb0
-#define A_XGMAC_PORT_HSS_TX_POLARITY 0x1cb4
-#define A_XGMAC_PORT_HSS_TX_8023AP_AE_CMD 0x1cb8
-#define A_XGMAC_PORT_HSS_TX_8023AP_AE_STATUS 0x1cbc
-#define A_XGMAC_PORT_HSS_TX_TAP0_IDAC_OVR 0x1cc0
-#define A_XGMAC_PORT_HSS_TX_TAP1_IDAC_OVR 0x1cc4
-#define A_XGMAC_PORT_HSS_TX_TAP2_IDAC_OVR 0x1cc8
-#define A_XGMAC_PORT_HSS_TX_PWR_DAC_OVR 0x1cd0
-#define A_XGMAC_PORT_HSS_TX_PWR_DAC 0x1cd4
-#define A_XGMAC_PORT_HSS_TX_TAP0_IDAC_APP 0x1ce0
-#define A_XGMAC_PORT_HSS_TX_TAP1_IDAC_APP 0x1ce4
-#define A_XGMAC_PORT_HSS_TX_TAP2_IDAC_APP 0x1ce8
-#define A_XGMAC_PORT_HSS_TX_SEG_DIS_APP 0x1cf0
-#define A_XGMAC_PORT_HSS_TX_EXT_ADDR_DATA 0x1cf8
-#define A_XGMAC_PORT_HSS_TX_EXT_ADDR 0x1cfc
-#define A_XGMAC_PORT_HSS_RX_CFG_MODE 0x1d00
-#define A_XGMAC_PORT_HSS_RXTEST_CTRL 0x1d04
-#define A_XGMAC_PORT_HSS_RX_PH_ROTATOR_CTRL 0x1d08
-#define A_XGMAC_PORT_HSS_RX_PH_ROTATOR_OFFSET_CTRL 0x1d0c
-#define A_XGMAC_PORT_HSS_RX_PH_ROTATOR_POSITION1 0x1d10
-#define A_XGMAC_PORT_HSS_RX_PH_ROTATOR_POSITION2 0x1d14
-#define A_XGMAC_PORT_HSS_RX_PH_ROTATOR_STATIC_PH_OFFSET 0x1d18
-#define A_XGMAC_PORT_HSS_RX_SIGDET_CTRL 0x1d1c
-#define A_XGMAC_PORT_HSS_RX_DFE_CTRL 0x1d20
-#define A_XGMAC_PORT_HSS_RX_DFE_DATA_EDGE_SAMPLE 0x1d24
-#define A_XGMAC_PORT_HSS_RX_DFE_AMP_SAMPLE 0x1d28
-#define A_XGMAC_PORT_HSS_RX_VGA_CTRL1 0x1d2c
-#define A_XGMAC_PORT_HSS_RX_VGA_CTRL2 0x1d30
-#define A_XGMAC_PORT_HSS_RX_VGA_CTRL3 0x1d34
-#define A_XGMAC_PORT_HSS_RX_DFE_D00_D01_OFFSET 0x1d38
-#define A_XGMAC_PORT_HSS_RX_DFE_D10_D11_OFFSET 0x1d3c
-#define A_XGMAC_PORT_HSS_RX_DFE_E0_E1_OFFSET 0x1d40
-#define A_XGMAC_PORT_HSS_RX_DACA_OFFSET 0x1d44
-#define A_XGMAC_PORT_HSS_RX_DACAP_DAC_AN_OFFSET 0x1d48
-#define A_XGMAC_PORT_HSS_RX_DACA_MIN 0x1d4c
-#define A_XGMAC_PORT_HSS_RX_ADAC_CTRL 0x1d50
-#define A_XGMAC_PORT_HSS_RX_DIGITAL_EYE_CTRL 0x1d54
-#define A_XGMAC_PORT_HSS_RX_DIGITAL_EYE_METRICS 0x1d58
-#define A_XGMAC_PORT_HSS_RX_DFE_H1 0x1d5c
-#define A_XGMAC_PORT_HSS_RX_DFE_H2 0x1d60
-#define A_XGMAC_PORT_HSS_RX_DFE_H3 0x1d64
-#define A_XGMAC_PORT_HSS_RX_DFE_H4 0x1d68
-#define A_XGMAC_PORT_HSS_RX_DFE_H5 0x1d6c
-#define A_XGMAC_PORT_HSS_RX_DAC_DPC 0x1d70
-#define A_XGMAC_PORT_HSS_RX_DDC 0x1d74
-#define A_XGMAC_PORT_HSS_RX_INTERNAL_STATUS 0x1d78
-#define A_XGMAC_PORT_HSS_RX_DFE_FUNC_CTRL 0x1d7c
-#define A_XGMAC_PORT_HSS_TXRX_CFG_MODE 0x1e00
-#define A_XGMAC_PORT_HSS_TXRXTEST_CTRL 0x1e04
-
-/* registers for module UP */
-#define UP_BASE_ADDR 0x0
-
-#define A_UP_IBQ_CONFIG 0x0
-
-#define S_IBQGEN2 2
-#define M_IBQGEN2 0x3fffffffU
-#define V_IBQGEN2(x) ((x) << S_IBQGEN2)
-#define G_IBQGEN2(x) (((x) >> S_IBQGEN2) & M_IBQGEN2)
-
-#define S_IBQBUSY 1
-#define V_IBQBUSY(x) ((x) << S_IBQBUSY)
-#define F_IBQBUSY V_IBQBUSY(1U)
-
-#define S_IBQEN 0
-#define V_IBQEN(x) ((x) << S_IBQEN)
-#define F_IBQEN V_IBQEN(1U)
-
-#define A_UP_OBQ_CONFIG 0x4
-
-#define S_OBQGEN2 2
-#define M_OBQGEN2 0x3fffffffU
-#define V_OBQGEN2(x) ((x) << S_OBQGEN2)
-#define G_OBQGEN2(x) (((x) >> S_OBQGEN2) & M_OBQGEN2)
-
-#define S_OBQBUSY 1
-#define V_OBQBUSY(x) ((x) << S_OBQBUSY)
-#define F_OBQBUSY V_OBQBUSY(1U)
-
-#define S_OBQEN 0
-#define V_OBQEN(x) ((x) << S_OBQEN)
-#define F_OBQEN V_OBQEN(1U)
-
-#define A_UP_IBQ_GEN 0x8
-
-#define S_IBQGEN0 22
-#define M_IBQGEN0 0x3ffU
-#define V_IBQGEN0(x) ((x) << S_IBQGEN0)
-#define G_IBQGEN0(x) (((x) >> S_IBQGEN0) & M_IBQGEN0)
-
-#define S_IBQTSCHCHNLRDY 18
-#define M_IBQTSCHCHNLRDY 0xfU
-#define V_IBQTSCHCHNLRDY(x) ((x) << S_IBQTSCHCHNLRDY)
-#define G_IBQTSCHCHNLRDY(x) (((x) >> S_IBQTSCHCHNLRDY) & M_IBQTSCHCHNLRDY)
-
-#define S_IBQMBVFSTATUS 17
-#define V_IBQMBVFSTATUS(x) ((x) << S_IBQMBVFSTATUS)
-#define F_IBQMBVFSTATUS V_IBQMBVFSTATUS(1U)
-
-#define S_IBQMBSTATUS 16
-#define V_IBQMBSTATUS(x) ((x) << S_IBQMBSTATUS)
-#define F_IBQMBSTATUS V_IBQMBSTATUS(1U)
-
-#define S_IBQGEN1 6
-#define M_IBQGEN1 0x3ffU
-#define V_IBQGEN1(x) ((x) << S_IBQGEN1)
-#define G_IBQGEN1(x) (((x) >> S_IBQGEN1) & M_IBQGEN1)
-
-#define S_IBQEMPTY 0
-#define M_IBQEMPTY 0x3fU
-#define V_IBQEMPTY(x) ((x) << S_IBQEMPTY)
-#define G_IBQEMPTY(x) (((x) >> S_IBQEMPTY) & M_IBQEMPTY)
-
-#define A_UP_OBQ_GEN 0xc
-
-#define S_OBQGEN 6
-#define M_OBQGEN 0x3ffffffU
-#define V_OBQGEN(x) ((x) << S_OBQGEN)
-#define G_OBQGEN(x) (((x) >> S_OBQGEN) & M_OBQGEN)
-
-#define S_OBQFULL 0
-#define M_OBQFULL 0x3fU
-#define V_OBQFULL(x) ((x) << S_OBQFULL)
-#define G_OBQFULL(x) (((x) >> S_OBQFULL) & M_OBQFULL)
-
-#define S_T5_OBQGEN 8
-#define M_T5_OBQGEN 0xffffffU
-#define V_T5_OBQGEN(x) ((x) << S_T5_OBQGEN)
-#define G_T5_OBQGEN(x) (((x) >> S_T5_OBQGEN) & M_T5_OBQGEN)
-
-#define S_T5_OBQFULL 0
-#define M_T5_OBQFULL 0xffU
-#define V_T5_OBQFULL(x) ((x) << S_T5_OBQFULL)
-#define G_T5_OBQFULL(x) (((x) >> S_T5_OBQFULL) & M_T5_OBQFULL)
-
-#define A_UP_IBQ_0_RDADDR 0x10
-
-#define S_QUEID 13
-#define M_QUEID 0x7ffffU
-#define V_QUEID(x) ((x) << S_QUEID)
-#define G_QUEID(x) (((x) >> S_QUEID) & M_QUEID)
-
-#define S_IBQRDADDR 0
-#define M_IBQRDADDR 0x1fffU
-#define V_IBQRDADDR(x) ((x) << S_IBQRDADDR)
-#define G_IBQRDADDR(x) (((x) >> S_IBQRDADDR) & M_IBQRDADDR)
-
-#define A_UP_IBQ_0_WRADDR 0x14
-
-#define S_IBQWRADDR 0
-#define M_IBQWRADDR 0x1fffU
-#define V_IBQWRADDR(x) ((x) << S_IBQWRADDR)
-#define G_IBQWRADDR(x) (((x) >> S_IBQWRADDR) & M_IBQWRADDR)
-
-#define A_UP_IBQ_0_STATUS 0x18
-
-#define S_QUEERRFRAME 31
-#define V_QUEERRFRAME(x) ((x) << S_QUEERRFRAME)
-#define F_QUEERRFRAME V_QUEERRFRAME(1U)
-
-#define S_QUEREMFLITS 0
-#define M_QUEREMFLITS 0x7ffU
-#define V_QUEREMFLITS(x) ((x) << S_QUEREMFLITS)
-#define G_QUEREMFLITS(x) (((x) >> S_QUEREMFLITS) & M_QUEREMFLITS)
-
-#define A_UP_IBQ_0_PKTCNT 0x1c
-
-#define S_QUEEOPCNT 16
-#define M_QUEEOPCNT 0xfffU
-#define V_QUEEOPCNT(x) ((x) << S_QUEEOPCNT)
-#define G_QUEEOPCNT(x) (((x) >> S_QUEEOPCNT) & M_QUEEOPCNT)
-
-#define S_QUESOPCNT 0
-#define M_QUESOPCNT 0xfffU
-#define V_QUESOPCNT(x) ((x) << S_QUESOPCNT)
-#define G_QUESOPCNT(x) (((x) >> S_QUESOPCNT) & M_QUESOPCNT)
-
-#define A_UP_IBQ_1_RDADDR 0x20
-#define A_UP_IBQ_1_WRADDR 0x24
-#define A_UP_IBQ_1_STATUS 0x28
-#define A_UP_IBQ_1_PKTCNT 0x2c
-#define A_UP_IBQ_2_RDADDR 0x30
-#define A_UP_IBQ_2_WRADDR 0x34
-#define A_UP_IBQ_2_STATUS 0x38
-#define A_UP_IBQ_2_PKTCNT 0x3c
-#define A_UP_IBQ_3_RDADDR 0x40
-#define A_UP_IBQ_3_WRADDR 0x44
-#define A_UP_IBQ_3_STATUS 0x48
-#define A_UP_IBQ_3_PKTCNT 0x4c
-#define A_UP_IBQ_4_RDADDR 0x50
-#define A_UP_IBQ_4_WRADDR 0x54
-#define A_UP_IBQ_4_STATUS 0x58
-#define A_UP_IBQ_4_PKTCNT 0x5c
-#define A_UP_IBQ_5_RDADDR 0x60
-#define A_UP_IBQ_5_WRADDR 0x64
-#define A_UP_IBQ_5_STATUS 0x68
-#define A_UP_IBQ_5_PKTCNT 0x6c
-#define A_UP_OBQ_0_RDADDR 0x70
-
-#define S_OBQID 15
-#define M_OBQID 0x1ffffU
-#define V_OBQID(x) ((x) << S_OBQID)
-#define G_OBQID(x) (((x) >> S_OBQID) & M_OBQID)
-
-#define S_QUERDADDR 0
-#define M_QUERDADDR 0x7fffU
-#define V_QUERDADDR(x) ((x) << S_QUERDADDR)
-#define G_QUERDADDR(x) (((x) >> S_QUERDADDR) & M_QUERDADDR)
-
-#define A_UP_OBQ_0_WRADDR 0x74
-
-#define S_QUEWRADDR 0
-#define M_QUEWRADDR 0x7fffU
-#define V_QUEWRADDR(x) ((x) << S_QUEWRADDR)
-#define G_QUEWRADDR(x) (((x) >> S_QUEWRADDR) & M_QUEWRADDR)
-
-#define A_UP_OBQ_0_STATUS 0x78
-#define A_UP_OBQ_0_PKTCNT 0x7c
-#define A_UP_OBQ_1_RDADDR 0x80
-#define A_UP_OBQ_1_WRADDR 0x84
-#define A_UP_OBQ_1_STATUS 0x88
-#define A_UP_OBQ_1_PKTCNT 0x8c
-#define A_UP_OBQ_2_RDADDR 0x90
-#define A_UP_OBQ_2_WRADDR 0x94
-#define A_UP_OBQ_2_STATUS 0x98
-#define A_UP_OBQ_2_PKTCNT 0x9c
-#define A_UP_OBQ_3_RDADDR 0xa0
-#define A_UP_OBQ_3_WRADDR 0xa4
-#define A_UP_OBQ_3_STATUS 0xa8
-#define A_UP_OBQ_3_PKTCNT 0xac
-#define A_UP_OBQ_4_RDADDR 0xb0
-#define A_UP_OBQ_4_WRADDR 0xb4
-#define A_UP_OBQ_4_STATUS 0xb8
-#define A_UP_OBQ_4_PKTCNT 0xbc
-#define A_UP_OBQ_5_RDADDR 0xc0
-#define A_UP_OBQ_5_WRADDR 0xc4
-#define A_UP_OBQ_5_STATUS 0xc8
-#define A_UP_OBQ_5_PKTCNT 0xcc
-#define A_UP_IBQ_0_CONFIG 0xd0
-
-#define S_QUESIZE 26
-#define M_QUESIZE 0x3fU
-#define V_QUESIZE(x) ((x) << S_QUESIZE)
-#define G_QUESIZE(x) (((x) >> S_QUESIZE) & M_QUESIZE)
-
-#define S_QUEBASE 8
-#define M_QUEBASE 0x3fU
-#define V_QUEBASE(x) ((x) << S_QUEBASE)
-#define G_QUEBASE(x) (((x) >> S_QUEBASE) & M_QUEBASE)
-
-#define S_QUEDBG8BEN 7
-#define V_QUEDBG8BEN(x) ((x) << S_QUEDBG8BEN)
-#define F_QUEDBG8BEN V_QUEDBG8BEN(1U)
-
-#define S_QUEBAREADDR 0
-#define V_QUEBAREADDR(x) ((x) << S_QUEBAREADDR)
-#define F_QUEBAREADDR V_QUEBAREADDR(1U)
-
-#define S_QUE1KEN 6
-#define V_QUE1KEN(x) ((x) << S_QUE1KEN)
-#define F_QUE1KEN V_QUE1KEN(1U)
-
-#define A_UP_IBQ_0_REALADDR 0xd4
-
-#define S_QUERDADDRWRAP 31
-#define V_QUERDADDRWRAP(x) ((x) << S_QUERDADDRWRAP)
-#define F_QUERDADDRWRAP V_QUERDADDRWRAP(1U)
-
-#define S_QUEWRADDRWRAP 30
-#define V_QUEWRADDRWRAP(x) ((x) << S_QUEWRADDRWRAP)
-#define F_QUEWRADDRWRAP V_QUEWRADDRWRAP(1U)
-
-#define S_QUEMEMADDR 3
-#define M_QUEMEMADDR 0x7ffU
-#define V_QUEMEMADDR(x) ((x) << S_QUEMEMADDR)
-#define G_QUEMEMADDR(x) (((x) >> S_QUEMEMADDR) & M_QUEMEMADDR)
-
-#define A_UP_IBQ_1_CONFIG 0xd8
-#define A_UP_IBQ_1_REALADDR 0xdc
-#define A_UP_IBQ_2_CONFIG 0xe0
-#define A_UP_IBQ_2_REALADDR 0xe4
-#define A_UP_IBQ_3_CONFIG 0xe8
-#define A_UP_IBQ_3_REALADDR 0xec
-#define A_UP_IBQ_4_CONFIG 0xf0
-#define A_UP_IBQ_4_REALADDR 0xf4
-#define A_UP_IBQ_5_CONFIG 0xf8
-#define A_UP_IBQ_5_REALADDR 0xfc
-#define A_UP_OBQ_0_CONFIG 0x100
-#define A_UP_OBQ_0_REALADDR 0x104
-#define A_UP_OBQ_1_CONFIG 0x108
-#define A_UP_OBQ_1_REALADDR 0x10c
-#define A_UP_OBQ_2_CONFIG 0x110
-#define A_UP_OBQ_2_REALADDR 0x114
-#define A_UP_OBQ_3_CONFIG 0x118
-#define A_UP_OBQ_3_REALADDR 0x11c
-#define A_UP_OBQ_4_CONFIG 0x120
-#define A_UP_OBQ_4_REALADDR 0x124
-#define A_UP_OBQ_5_CONFIG 0x128
-#define A_UP_OBQ_5_REALADDR 0x12c
-#define A_UP_MAILBOX_STATUS 0x130
-
-#define S_MBGEN0 20
-#define M_MBGEN0 0xfffU
-#define V_MBGEN0(x) ((x) << S_MBGEN0)
-#define G_MBGEN0(x) (((x) >> S_MBGEN0) & M_MBGEN0)
-
-#define S_GENTIMERTRIGGER 16
-#define M_GENTIMERTRIGGER 0xfU
-#define V_GENTIMERTRIGGER(x) ((x) << S_GENTIMERTRIGGER)
-#define G_GENTIMERTRIGGER(x) (((x) >> S_GENTIMERTRIGGER) & M_GENTIMERTRIGGER)
-
-#define S_MBGEN1 8
-#define M_MBGEN1 0xffU
-#define V_MBGEN1(x) ((x) << S_MBGEN1)
-#define G_MBGEN1(x) (((x) >> S_MBGEN1) & M_MBGEN1)
-
-#define S_MBPFINT 0
-#define M_MBPFINT 0xffU
-#define V_MBPFINT(x) ((x) << S_MBPFINT)
-#define G_MBPFINT(x) (((x) >> S_MBPFINT) & M_MBPFINT)
-
-#define A_UP_UP_DBG_LA_CFG 0x140
-
-#define S_UPDBGLACAPTBUB 31
-#define V_UPDBGLACAPTBUB(x) ((x) << S_UPDBGLACAPTBUB)
-#define F_UPDBGLACAPTBUB V_UPDBGLACAPTBUB(1U)
-
-#define S_UPDBGLACAPTPCONLY 30
-#define V_UPDBGLACAPTPCONLY(x) ((x) << S_UPDBGLACAPTPCONLY)
-#define F_UPDBGLACAPTPCONLY V_UPDBGLACAPTPCONLY(1U)
-
-#define S_UPDBGLAMASKSTOP 29
-#define V_UPDBGLAMASKSTOP(x) ((x) << S_UPDBGLAMASKSTOP)
-#define F_UPDBGLAMASKSTOP V_UPDBGLAMASKSTOP(1U)
-
-#define S_UPDBGLAMASKTRIG 28
-#define V_UPDBGLAMASKTRIG(x) ((x) << S_UPDBGLAMASKTRIG)
-#define F_UPDBGLAMASKTRIG V_UPDBGLAMASKTRIG(1U)
-
-#define S_UPDBGLAWRPTR 16
-#define M_UPDBGLAWRPTR 0xfffU
-#define V_UPDBGLAWRPTR(x) ((x) << S_UPDBGLAWRPTR)
-#define G_UPDBGLAWRPTR(x) (((x) >> S_UPDBGLAWRPTR) & M_UPDBGLAWRPTR)
-
-#define S_UPDBGLARDPTR 2
-#define M_UPDBGLARDPTR 0xfffU
-#define V_UPDBGLARDPTR(x) ((x) << S_UPDBGLARDPTR)
-#define G_UPDBGLARDPTR(x) (((x) >> S_UPDBGLARDPTR) & M_UPDBGLARDPTR)
-
-#define S_UPDBGLARDEN 1
-#define V_UPDBGLARDEN(x) ((x) << S_UPDBGLARDEN)
-#define F_UPDBGLARDEN V_UPDBGLARDEN(1U)
-
-#define S_UPDBGLAEN 0
-#define V_UPDBGLAEN(x) ((x) << S_UPDBGLAEN)
-#define F_UPDBGLAEN V_UPDBGLAEN(1U)
-
-#define S_UPDBGLABUSY 14
-#define V_UPDBGLABUSY(x) ((x) << S_UPDBGLABUSY)
-#define F_UPDBGLABUSY V_UPDBGLABUSY(1U)
-
-#define A_UP_UP_DBG_LA_DATA 0x144
-#define A_UP_PIO_MST_CONFIG 0x148
-
-#define S_FLSRC 24
-#define M_FLSRC 0x7U
-#define V_FLSRC(x) ((x) << S_FLSRC)
-#define G_FLSRC(x) (((x) >> S_FLSRC) & M_FLSRC)
-
-#define S_SEPROT 23
-#define V_SEPROT(x) ((x) << S_SEPROT)
-#define F_SEPROT V_SEPROT(1U)
-
-#define S_SESRC 20
-#define M_SESRC 0x7U
-#define V_SESRC(x) ((x) << S_SESRC)
-#define G_SESRC(x) (((x) >> S_SESRC) & M_SESRC)
-
-#define S_UPRGN 19
-#define V_UPRGN(x) ((x) << S_UPRGN)
-#define F_UPRGN V_UPRGN(1U)
-
-#define S_UPPF 16
-#define M_UPPF 0x7U
-#define V_UPPF(x) ((x) << S_UPPF)
-#define G_UPPF(x) (((x) >> S_UPPF) & M_UPPF)
-
-#define S_UPRID 0
-#define M_UPRID 0xffffU
-#define V_UPRID(x) ((x) << S_UPRID)
-#define G_UPRID(x) (((x) >> S_UPRID) & M_UPRID)
-
-#define S_REQVFVLD 27
-#define V_REQVFVLD(x) ((x) << S_REQVFVLD)
-#define F_REQVFVLD V_REQVFVLD(1U)
-
-#define S_T5_UPRID 0
-#define M_T5_UPRID 0xffU
-#define V_T5_UPRID(x) ((x) << S_T5_UPRID)
-#define G_T5_UPRID(x) (((x) >> S_T5_UPRID) & M_T5_UPRID)
-
-#define S_T6_UPRID 0
-#define M_T6_UPRID 0x1ffU
-#define V_T6_UPRID(x) ((x) << S_T6_UPRID)
-#define G_T6_UPRID(x) (((x) >> S_T6_UPRID) & M_T6_UPRID)
-
-#define A_UP_UP_SELF_CONTROL 0x14c
-
-#define S_UPSELFRESET 0
-#define V_UPSELFRESET(x) ((x) << S_UPSELFRESET)
-#define F_UPSELFRESET V_UPSELFRESET(1U)
-
-#define A_UP_MAILBOX_PF0_CTL 0x180
-#define A_UP_MAILBOX_PF1_CTL 0x190
-#define A_UP_MAILBOX_PF2_CTL 0x1a0
-#define A_UP_MAILBOX_PF3_CTL 0x1b0
-#define A_UP_MAILBOX_PF4_CTL 0x1c0
-#define A_UP_MAILBOX_PF5_CTL 0x1d0
-#define A_UP_MAILBOX_PF6_CTL 0x1e0
-#define A_UP_MAILBOX_PF7_CTL 0x1f0
-#define A_UP_TSCH_CHNLN_CLASS_RDY 0x200
-
-#define S_ECO_15444_SGE_DB_BUSY 31
-#define V_ECO_15444_SGE_DB_BUSY(x) ((x) << S_ECO_15444_SGE_DB_BUSY)
-#define F_ECO_15444_SGE_DB_BUSY V_ECO_15444_SGE_DB_BUSY(1U)
-
-#define S_ECO_15444_PL_INTF_BUSY 30
-#define V_ECO_15444_PL_INTF_BUSY(x) ((x) << S_ECO_15444_PL_INTF_BUSY)
-#define F_ECO_15444_PL_INTF_BUSY V_ECO_15444_PL_INTF_BUSY(1U)
-
-#define S_TSCHCHNLCRDY 0
-#define M_TSCHCHNLCRDY 0x3fffffffU
-#define V_TSCHCHNLCRDY(x) ((x) << S_TSCHCHNLCRDY)
-#define G_TSCHCHNLCRDY(x) (((x) >> S_TSCHCHNLCRDY) & M_TSCHCHNLCRDY)
-
-#define A_UP_TSCH_CHNLN_CLASS_WATCH_RDY 0x204
-
-#define S_TSCHWRRLIMIT 16
-#define M_TSCHWRRLIMIT 0xffffU
-#define V_TSCHWRRLIMIT(x) ((x) << S_TSCHWRRLIMIT)
-#define G_TSCHWRRLIMIT(x) (((x) >> S_TSCHWRRLIMIT) & M_TSCHWRRLIMIT)
-
-#define S_TSCHCHNLCWRDY 0
-#define M_TSCHCHNLCWRDY 0xffffU
-#define V_TSCHCHNLCWRDY(x) ((x) << S_TSCHCHNLCWRDY)
-#define G_TSCHCHNLCWRDY(x) (((x) >> S_TSCHCHNLCWRDY) & M_TSCHCHNLCWRDY)
-
-#define A_UP_TSCH_CHNLN_CLASS_WATCH_LIST 0x208
-
-#define S_TSCHWRRRELOAD 16
-#define M_TSCHWRRRELOAD 0xffffU
-#define V_TSCHWRRRELOAD(x) ((x) << S_TSCHWRRRELOAD)
-#define G_TSCHWRRRELOAD(x) (((x) >> S_TSCHWRRRELOAD) & M_TSCHWRRRELOAD)
-
-#define S_TSCHCHNLCWATCH 0
-#define M_TSCHCHNLCWATCH 0xffffU
-#define V_TSCHCHNLCWATCH(x) ((x) << S_TSCHCHNLCWATCH)
-#define G_TSCHCHNLCWATCH(x) (((x) >> S_TSCHCHNLCWATCH) & M_TSCHCHNLCWATCH)
-
-#define A_UP_TSCH_CHNLN_CLASS_TAKE 0x20c
-
-#define S_TSCHCHNLCNUM 24
-#define M_TSCHCHNLCNUM 0x1fU
-#define V_TSCHCHNLCNUM(x) ((x) << S_TSCHCHNLCNUM)
-#define G_TSCHCHNLCNUM(x) (((x) >> S_TSCHCHNLCNUM) & M_TSCHCHNLCNUM)
-
-#define S_TSCHCHNLCCNT 0
-#define M_TSCHCHNLCCNT 0xffffffU
-#define V_TSCHCHNLCCNT(x) ((x) << S_TSCHCHNLCCNT)
-#define G_TSCHCHNLCCNT(x) (((x) >> S_TSCHCHNLCCNT) & M_TSCHCHNLCCNT)
-
-#define S_TSCHCHNLCHDIS 31
-#define V_TSCHCHNLCHDIS(x) ((x) << S_TSCHCHNLCHDIS)
-#define F_TSCHCHNLCHDIS V_TSCHCHNLCHDIS(1U)
-
-#define S_TSCHCHNLWDIS 30
-#define V_TSCHCHNLWDIS(x) ((x) << S_TSCHCHNLWDIS)
-#define F_TSCHCHNLWDIS V_TSCHCHNLWDIS(1U)
-
-#define S_TSCHCHNLCLDIS 29
-#define V_TSCHCHNLCLDIS(x) ((x) << S_TSCHCHNLCLDIS)
-#define F_TSCHCHNLCLDIS V_TSCHCHNLCLDIS(1U)
-
-#define A_UP_UPLADBGPCCHKDATA_0 0x240
-#define A_UP_UPLADBGPCCHKMASK_0 0x244
-#define A_UP_UPLADBGPCCHKDATA_1 0x250
-#define A_UP_UPLADBGPCCHKMASK_1 0x254
-#define A_UP_UPLADBGPCCHKDATA_2 0x260
-#define A_UP_UPLADBGPCCHKMASK_2 0x264
-#define A_UP_UPLADBGPCCHKDATA_3 0x270
-#define A_UP_UPLADBGPCCHKMASK_3 0x274
-#define A_UP_IBQ_0_SHADOW_RDADDR 0x280
-#define A_UP_IBQ_0_SHADOW_WRADDR 0x284
-#define A_UP_IBQ_0_SHADOW_STATUS 0x288
-#define A_UP_IBQ_0_SHADOW_PKTCNT 0x28c
-#define A_UP_IBQ_1_SHADOW_RDADDR 0x290
-#define A_UP_IBQ_1_SHADOW_WRADDR 0x294
-#define A_UP_IBQ_1_SHADOW_STATUS 0x298
-#define A_UP_IBQ_1_SHADOW_PKTCNT 0x29c
-#define A_UP_IBQ_2_SHADOW_RDADDR 0x2a0
-#define A_UP_IBQ_2_SHADOW_WRADDR 0x2a4
-#define A_UP_IBQ_2_SHADOW_STATUS 0x2a8
-#define A_UP_IBQ_2_SHADOW_PKTCNT 0x2ac
-#define A_UP_IBQ_3_SHADOW_RDADDR 0x2b0
-#define A_UP_IBQ_3_SHADOW_WRADDR 0x2b4
-#define A_UP_IBQ_3_SHADOW_STATUS 0x2b8
-#define A_UP_IBQ_3_SHADOW_PKTCNT 0x2bc
-#define A_UP_IBQ_4_SHADOW_RDADDR 0x2c0
-#define A_UP_IBQ_4_SHADOW_WRADDR 0x2c4
-#define A_UP_IBQ_4_SHADOW_STATUS 0x2c8
-#define A_UP_IBQ_4_SHADOW_PKTCNT 0x2cc
-#define A_UP_IBQ_5_SHADOW_RDADDR 0x2d0
-#define A_UP_IBQ_5_SHADOW_WRADDR 0x2d4
-#define A_UP_IBQ_5_SHADOW_STATUS 0x2d8
-#define A_UP_IBQ_5_SHADOW_PKTCNT 0x2dc
-#define A_UP_OBQ_0_SHADOW_RDADDR 0x2e0
-#define A_UP_OBQ_0_SHADOW_WRADDR 0x2e4
-#define A_UP_OBQ_0_SHADOW_STATUS 0x2e8
-#define A_UP_OBQ_0_SHADOW_PKTCNT 0x2ec
-#define A_UP_OBQ_1_SHADOW_RDADDR 0x2f0
-#define A_UP_OBQ_1_SHADOW_WRADDR 0x2f4
-#define A_UP_OBQ_1_SHADOW_STATUS 0x2f8
-#define A_UP_OBQ_1_SHADOW_PKTCNT 0x2fc
-#define A_UP_OBQ_2_SHADOW_RDADDR 0x300
-#define A_UP_OBQ_2_SHADOW_WRADDR 0x304
-#define A_UP_OBQ_2_SHADOW_STATUS 0x308
-#define A_UP_OBQ_2_SHADOW_PKTCNT 0x30c
-#define A_UP_OBQ_3_SHADOW_RDADDR 0x310
-#define A_UP_OBQ_3_SHADOW_WRADDR 0x314
-#define A_UP_OBQ_3_SHADOW_STATUS 0x318
-#define A_UP_OBQ_3_SHADOW_PKTCNT 0x31c
-#define A_UP_OBQ_4_SHADOW_RDADDR 0x320
-#define A_UP_OBQ_4_SHADOW_WRADDR 0x324
-#define A_UP_OBQ_4_SHADOW_STATUS 0x328
-#define A_UP_OBQ_4_SHADOW_PKTCNT 0x32c
-#define A_UP_OBQ_5_SHADOW_RDADDR 0x330
-#define A_UP_OBQ_5_SHADOW_WRADDR 0x334
-#define A_UP_OBQ_5_SHADOW_STATUS 0x338
-#define A_UP_OBQ_5_SHADOW_PKTCNT 0x33c
-#define A_UP_OBQ_6_SHADOW_RDADDR 0x340
-#define A_UP_OBQ_6_SHADOW_WRADDR 0x344
-#define A_UP_OBQ_6_SHADOW_STATUS 0x348
-#define A_UP_OBQ_6_SHADOW_PKTCNT 0x34c
-#define A_UP_OBQ_7_SHADOW_RDADDR 0x350
-#define A_UP_OBQ_7_SHADOW_WRADDR 0x354
-#define A_UP_OBQ_7_SHADOW_STATUS 0x358
-#define A_UP_OBQ_7_SHADOW_PKTCNT 0x35c
-#define A_UP_IBQ_0_SHADOW_CONFIG 0x360
-#define A_UP_IBQ_0_SHADOW_REALADDR 0x364
-#define A_UP_IBQ_1_SHADOW_CONFIG 0x368
-#define A_UP_IBQ_1_SHADOW_REALADDR 0x36c
-#define A_UP_IBQ_2_SHADOW_CONFIG 0x370
-#define A_UP_IBQ_2_SHADOW_REALADDR 0x374
-#define A_UP_IBQ_3_SHADOW_CONFIG 0x378
-#define A_UP_IBQ_3_SHADOW_REALADDR 0x37c
-#define A_UP_IBQ_4_SHADOW_CONFIG 0x380
-#define A_UP_IBQ_4_SHADOW_REALADDR 0x384
-#define A_UP_IBQ_5_SHADOW_CONFIG 0x388
-#define A_UP_IBQ_5_SHADOW_REALADDR 0x38c
-#define A_UP_OBQ_0_SHADOW_CONFIG 0x390
-#define A_UP_OBQ_0_SHADOW_REALADDR 0x394
-#define A_UP_OBQ_1_SHADOW_CONFIG 0x398
-#define A_UP_OBQ_1_SHADOW_REALADDR 0x39c
-#define A_UP_OBQ_2_SHADOW_CONFIG 0x3a0
-#define A_UP_OBQ_2_SHADOW_REALADDR 0x3a4
-#define A_UP_OBQ_3_SHADOW_CONFIG 0x3a8
-#define A_UP_OBQ_3_SHADOW_REALADDR 0x3ac
-#define A_UP_OBQ_4_SHADOW_CONFIG 0x3b0
-#define A_UP_OBQ_4_SHADOW_REALADDR 0x3b4
-#define A_UP_OBQ_5_SHADOW_CONFIG 0x3b8
-#define A_UP_OBQ_5_SHADOW_REALADDR 0x3bc
-#define A_UP_OBQ_6_SHADOW_CONFIG 0x3c0
-#define A_UP_OBQ_6_SHADOW_REALADDR 0x3c4
-#define A_UP_OBQ_7_SHADOW_CONFIG 0x3c8
-#define A_UP_OBQ_7_SHADOW_REALADDR 0x3cc
-
-/* registers for module CIM_CTL */
-#define CIM_CTL_BASE_ADDR 0x0
-
-#define A_CIM_CTL_CONFIG 0x0
-
-#define S_AUTOPREFLOC 17
-#define M_AUTOPREFLOC 0x1fU
-#define V_AUTOPREFLOC(x) ((x) << S_AUTOPREFLOC)
-#define G_AUTOPREFLOC(x) (((x) >> S_AUTOPREFLOC) & M_AUTOPREFLOC)
-
-#define S_AUTOPREFEN 16
-#define V_AUTOPREFEN(x) ((x) << S_AUTOPREFEN)
-#define F_AUTOPREFEN V_AUTOPREFEN(1U)
-
-#define S_DISMATIMEOUT 15
-#define V_DISMATIMEOUT(x) ((x) << S_DISMATIMEOUT)
-#define F_DISMATIMEOUT V_DISMATIMEOUT(1U)
-
-#define S_PIFMULTICMD 8
-#define V_PIFMULTICMD(x) ((x) << S_PIFMULTICMD)
-#define F_PIFMULTICMD V_PIFMULTICMD(1U)
-
-#define S_UPSELFRESETTOUT 7
-#define V_UPSELFRESETTOUT(x) ((x) << S_UPSELFRESETTOUT)
-#define F_UPSELFRESETTOUT V_UPSELFRESETTOUT(1U)
-
-#define S_PLSWAPDISWR 6
-#define V_PLSWAPDISWR(x) ((x) << S_PLSWAPDISWR)
-#define F_PLSWAPDISWR V_PLSWAPDISWR(1U)
-
-#define S_PLSWAPDISRD 5
-#define V_PLSWAPDISRD(x) ((x) << S_PLSWAPDISRD)
-#define F_PLSWAPDISRD V_PLSWAPDISRD(1U)
-
-#define S_PREFEN 0
-#define V_PREFEN(x) ((x) << S_PREFEN)
-#define F_PREFEN V_PREFEN(1U)
-
-#define S_DISSLOWTIMEOUT 14
-#define V_DISSLOWTIMEOUT(x) ((x) << S_DISSLOWTIMEOUT)
-#define F_DISSLOWTIMEOUT V_DISSLOWTIMEOUT(1U)
-
-#define S_INTLRSPEN 9
-#define V_INTLRSPEN(x) ((x) << S_INTLRSPEN)
-#define F_INTLRSPEN V_INTLRSPEN(1U)
-
-#define A_CIM_CTL_PREFADDR 0x4
-#define A_CIM_CTL_ALLOCADDR 0x8
-#define A_CIM_CTL_INVLDTADDR 0xc
-#define A_CIM_CTL_STATIC_PREFADDR0 0x10
-#define A_CIM_CTL_STATIC_PREFADDR1 0x14
-#define A_CIM_CTL_STATIC_PREFADDR2 0x18
-#define A_CIM_CTL_STATIC_PREFADDR3 0x1c
-#define A_CIM_CTL_STATIC_PREFADDR4 0x20
-#define A_CIM_CTL_STATIC_PREFADDR5 0x24
-#define A_CIM_CTL_STATIC_PREFADDR6 0x28
-#define A_CIM_CTL_STATIC_PREFADDR7 0x2c
-#define A_CIM_CTL_STATIC_PREFADDR8 0x30
-#define A_CIM_CTL_STATIC_PREFADDR9 0x34
-#define A_CIM_CTL_STATIC_PREFADDR10 0x38
-#define A_CIM_CTL_STATIC_PREFADDR11 0x3c
-#define A_CIM_CTL_STATIC_PREFADDR12 0x40
-#define A_CIM_CTL_STATIC_PREFADDR13 0x44
-#define A_CIM_CTL_STATIC_PREFADDR14 0x48
-#define A_CIM_CTL_STATIC_PREFADDR15 0x4c
-#define A_CIM_CTL_STATIC_ALLOCADDR0 0x50
-#define A_CIM_CTL_STATIC_ALLOCADDR1 0x54
-#define A_CIM_CTL_STATIC_ALLOCADDR2 0x58
-#define A_CIM_CTL_STATIC_ALLOCADDR3 0x5c
-#define A_CIM_CTL_STATIC_ALLOCADDR4 0x60
-#define A_CIM_CTL_STATIC_ALLOCADDR5 0x64
-#define A_CIM_CTL_STATIC_ALLOCADDR6 0x68
-#define A_CIM_CTL_STATIC_ALLOCADDR7 0x6c
-#define A_CIM_CTL_STATIC_ALLOCADDR8 0x70
-#define A_CIM_CTL_STATIC_ALLOCADDR9 0x74
-#define A_CIM_CTL_STATIC_ALLOCADDR10 0x78
-#define A_CIM_CTL_STATIC_ALLOCADDR11 0x7c
-#define A_CIM_CTL_STATIC_ALLOCADDR12 0x80
-#define A_CIM_CTL_STATIC_ALLOCADDR13 0x84
-#define A_CIM_CTL_STATIC_ALLOCADDR14 0x88
-#define A_CIM_CTL_STATIC_ALLOCADDR15 0x8c
-#define A_CIM_CTL_FIFO_CNT 0x90
-
-#define S_CTLFIFOCNT 0
-#define M_CTLFIFOCNT 0xfU
-#define V_CTLFIFOCNT(x) ((x) << S_CTLFIFOCNT)
-#define G_CTLFIFOCNT(x) (((x) >> S_CTLFIFOCNT) & M_CTLFIFOCNT)
-
-#define A_CIM_CTL_GLB_TIMER 0x94
-#define A_CIM_CTL_TIMER0 0x98
-#define A_CIM_CTL_TIMER1 0x9c
-#define A_CIM_CTL_GEN0 0xa0
-#define A_CIM_CTL_GEN1 0xa4
-#define A_CIM_CTL_GEN2 0xa8
-#define A_CIM_CTL_GEN3 0xac
-#define A_CIM_CTL_GLB_TIMER_TICK 0xb0
-#define A_CIM_CTL_GEN_TIMER0_CTL 0xb4
-
-#define S_GENTIMERRUN 7
-#define V_GENTIMERRUN(x) ((x) << S_GENTIMERRUN)
-#define F_GENTIMERRUN V_GENTIMERRUN(1U)
-
-#define S_GENTIMERTRIG 6
-#define V_GENTIMERTRIG(x) ((x) << S_GENTIMERTRIG)
-#define F_GENTIMERTRIG V_GENTIMERTRIG(1U)
-
-#define S_GENTIMERACT 4
-#define M_GENTIMERACT 0x3U
-#define V_GENTIMERACT(x) ((x) << S_GENTIMERACT)
-#define G_GENTIMERACT(x) (((x) >> S_GENTIMERACT) & M_GENTIMERACT)
-
-#define S_GENTIMERCFG 2
-#define M_GENTIMERCFG 0x3U
-#define V_GENTIMERCFG(x) ((x) << S_GENTIMERCFG)
-#define G_GENTIMERCFG(x) (((x) >> S_GENTIMERCFG) & M_GENTIMERCFG)
-
-#define S_GENTIMERSTOP 1
-#define V_GENTIMERSTOP(x) ((x) << S_GENTIMERSTOP)
-#define F_GENTIMERSTOP V_GENTIMERSTOP(1U)
-
-#define S_GENTIMERSTRT 0
-#define V_GENTIMERSTRT(x) ((x) << S_GENTIMERSTRT)
-#define F_GENTIMERSTRT V_GENTIMERSTRT(1U)
-
-#define A_CIM_CTL_GEN_TIMER0 0xb8
-#define A_CIM_CTL_GEN_TIMER1_CTL 0xbc
-#define A_CIM_CTL_GEN_TIMER1 0xc0
-#define A_CIM_CTL_GEN_TIMER2_CTL 0xc4
-#define A_CIM_CTL_GEN_TIMER2 0xc8
-#define A_CIM_CTL_GEN_TIMER3_CTL 0xcc
-#define A_CIM_CTL_GEN_TIMER3 0xd0
-#define A_CIM_CTL_MAILBOX_VF_STATUS 0xe0
-#define A_CIM_CTL_MAILBOX_VFN_CTL 0x100
-#define A_CIM_CTL_TSCH_CHNLN_CTL 0x900
-
-#define S_TSCHNLEN 31
-#define V_TSCHNLEN(x) ((x) << S_TSCHNLEN)
-#define F_TSCHNLEN V_TSCHNLEN(1U)
-
-#define S_TSCHNRESET 30
-#define V_TSCHNRESET(x) ((x) << S_TSCHNRESET)
-#define F_TSCHNRESET V_TSCHNRESET(1U)
-
-#define S_T6_MIN_MAX_EN 29
-#define V_T6_MIN_MAX_EN(x) ((x) << S_T6_MIN_MAX_EN)
-#define F_T6_MIN_MAX_EN V_T6_MIN_MAX_EN(1U)
-
-#define A_CIM_CTL_TSCH_CHNLN_TICK 0x904
-
-#define S_TSCHNLTICK 0
-#define M_TSCHNLTICK 0xffffU
-#define V_TSCHNLTICK(x) ((x) << S_TSCHNLTICK)
-#define G_TSCHNLTICK(x) (((x) >> S_TSCHNLTICK) & M_TSCHNLTICK)
-
-#define A_CIM_CTL_TSCH_CHNLN_CLASS_RATECTL 0x904
-
-#define S_TSC15RATECTL 15
-#define V_TSC15RATECTL(x) ((x) << S_TSC15RATECTL)
-#define F_TSC15RATECTL V_TSC15RATECTL(1U)
-
-#define S_TSC14RATECTL 14
-#define V_TSC14RATECTL(x) ((x) << S_TSC14RATECTL)
-#define F_TSC14RATECTL V_TSC14RATECTL(1U)
-
-#define S_TSC13RATECTL 13
-#define V_TSC13RATECTL(x) ((x) << S_TSC13RATECTL)
-#define F_TSC13RATECTL V_TSC13RATECTL(1U)
-
-#define S_TSC12RATECTL 12
-#define V_TSC12RATECTL(x) ((x) << S_TSC12RATECTL)
-#define F_TSC12RATECTL V_TSC12RATECTL(1U)
-
-#define S_TSC11RATECTL 11
-#define V_TSC11RATECTL(x) ((x) << S_TSC11RATECTL)
-#define F_TSC11RATECTL V_TSC11RATECTL(1U)
-
-#define S_TSC10RATECTL 10
-#define V_TSC10RATECTL(x) ((x) << S_TSC10RATECTL)
-#define F_TSC10RATECTL V_TSC10RATECTL(1U)
-
-#define S_TSC9RATECTL 9
-#define V_TSC9RATECTL(x) ((x) << S_TSC9RATECTL)
-#define F_TSC9RATECTL V_TSC9RATECTL(1U)
-
-#define S_TSC8RATECTL 8
-#define V_TSC8RATECTL(x) ((x) << S_TSC8RATECTL)
-#define F_TSC8RATECTL V_TSC8RATECTL(1U)
-
-#define S_TSC7RATECTL 7
-#define V_TSC7RATECTL(x) ((x) << S_TSC7RATECTL)
-#define F_TSC7RATECTL V_TSC7RATECTL(1U)
-
-#define S_TSC6RATECTL 6
-#define V_TSC6RATECTL(x) ((x) << S_TSC6RATECTL)
-#define F_TSC6RATECTL V_TSC6RATECTL(1U)
-
-#define S_TSC5RATECTL 5
-#define V_TSC5RATECTL(x) ((x) << S_TSC5RATECTL)
-#define F_TSC5RATECTL V_TSC5RATECTL(1U)
-
-#define S_TSC4RATECTL 4
-#define V_TSC4RATECTL(x) ((x) << S_TSC4RATECTL)
-#define F_TSC4RATECTL V_TSC4RATECTL(1U)
-
-#define S_TSC3RATECTL 3
-#define V_TSC3RATECTL(x) ((x) << S_TSC3RATECTL)
-#define F_TSC3RATECTL V_TSC3RATECTL(1U)
-
-#define S_TSC2RATECTL 2
-#define V_TSC2RATECTL(x) ((x) << S_TSC2RATECTL)
-#define F_TSC2RATECTL V_TSC2RATECTL(1U)
-
-#define S_TSC1RATECTL 1
-#define V_TSC1RATECTL(x) ((x) << S_TSC1RATECTL)
-#define F_TSC1RATECTL V_TSC1RATECTL(1U)
-
-#define S_TSC0RATECTL 0
-#define V_TSC0RATECTL(x) ((x) << S_TSC0RATECTL)
-#define F_TSC0RATECTL V_TSC0RATECTL(1U)
-
-#define A_CIM_CTL_TSCH_CHNLN_CLASS_ENABLE_A 0x908
-
-#define S_TSC15WRREN 31
-#define V_TSC15WRREN(x) ((x) << S_TSC15WRREN)
-#define F_TSC15WRREN V_TSC15WRREN(1U)
-
-#define S_TSC15RATEEN 30
-#define V_TSC15RATEEN(x) ((x) << S_TSC15RATEEN)
-#define F_TSC15RATEEN V_TSC15RATEEN(1U)
-
-#define S_TSC14WRREN 29
-#define V_TSC14WRREN(x) ((x) << S_TSC14WRREN)
-#define F_TSC14WRREN V_TSC14WRREN(1U)
-
-#define S_TSC14RATEEN 28
-#define V_TSC14RATEEN(x) ((x) << S_TSC14RATEEN)
-#define F_TSC14RATEEN V_TSC14RATEEN(1U)
-
-#define S_TSC13WRREN 27
-#define V_TSC13WRREN(x) ((x) << S_TSC13WRREN)
-#define F_TSC13WRREN V_TSC13WRREN(1U)
-
-#define S_TSC13RATEEN 26
-#define V_TSC13RATEEN(x) ((x) << S_TSC13RATEEN)
-#define F_TSC13RATEEN V_TSC13RATEEN(1U)
-
-#define S_TSC12WRREN 25
-#define V_TSC12WRREN(x) ((x) << S_TSC12WRREN)
-#define F_TSC12WRREN V_TSC12WRREN(1U)
-
-#define S_TSC12RATEEN 24
-#define V_TSC12RATEEN(x) ((x) << S_TSC12RATEEN)
-#define F_TSC12RATEEN V_TSC12RATEEN(1U)
-
-#define S_TSC11WRREN 23
-#define V_TSC11WRREN(x) ((x) << S_TSC11WRREN)
-#define F_TSC11WRREN V_TSC11WRREN(1U)
-
-#define S_TSC11RATEEN 22
-#define V_TSC11RATEEN(x) ((x) << S_TSC11RATEEN)
-#define F_TSC11RATEEN V_TSC11RATEEN(1U)
-
-#define S_TSC10WRREN 21
-#define V_TSC10WRREN(x) ((x) << S_TSC10WRREN)
-#define F_TSC10WRREN V_TSC10WRREN(1U)
-
-#define S_TSC10RATEEN 20
-#define V_TSC10RATEEN(x) ((x) << S_TSC10RATEEN)
-#define F_TSC10RATEEN V_TSC10RATEEN(1U)
-
-#define S_TSC9WRREN 19
-#define V_TSC9WRREN(x) ((x) << S_TSC9WRREN)
-#define F_TSC9WRREN V_TSC9WRREN(1U)
-
-#define S_TSC9RATEEN 18
-#define V_TSC9RATEEN(x) ((x) << S_TSC9RATEEN)
-#define F_TSC9RATEEN V_TSC9RATEEN(1U)
-
-#define S_TSC8WRREN 17
-#define V_TSC8WRREN(x) ((x) << S_TSC8WRREN)
-#define F_TSC8WRREN V_TSC8WRREN(1U)
-
-#define S_TSC8RATEEN 16
-#define V_TSC8RATEEN(x) ((x) << S_TSC8RATEEN)
-#define F_TSC8RATEEN V_TSC8RATEEN(1U)
-
-#define S_TSC7WRREN 15
-#define V_TSC7WRREN(x) ((x) << S_TSC7WRREN)
-#define F_TSC7WRREN V_TSC7WRREN(1U)
-
-#define S_TSC7RATEEN 14
-#define V_TSC7RATEEN(x) ((x) << S_TSC7RATEEN)
-#define F_TSC7RATEEN V_TSC7RATEEN(1U)
-
-#define S_TSC6WRREN 13
-#define V_TSC6WRREN(x) ((x) << S_TSC6WRREN)
-#define F_TSC6WRREN V_TSC6WRREN(1U)
-
-#define S_TSC6RATEEN 12
-#define V_TSC6RATEEN(x) ((x) << S_TSC6RATEEN)
-#define F_TSC6RATEEN V_TSC6RATEEN(1U)
-
-#define S_TSC5WRREN 11
-#define V_TSC5WRREN(x) ((x) << S_TSC5WRREN)
-#define F_TSC5WRREN V_TSC5WRREN(1U)
-
-#define S_TSC5RATEEN 10
-#define V_TSC5RATEEN(x) ((x) << S_TSC5RATEEN)
-#define F_TSC5RATEEN V_TSC5RATEEN(1U)
-
-#define S_TSC4WRREN 9
-#define V_TSC4WRREN(x) ((x) << S_TSC4WRREN)
-#define F_TSC4WRREN V_TSC4WRREN(1U)
-
-#define S_TSC4RATEEN 8
-#define V_TSC4RATEEN(x) ((x) << S_TSC4RATEEN)
-#define F_TSC4RATEEN V_TSC4RATEEN(1U)
-
-#define S_TSC3WRREN 7
-#define V_TSC3WRREN(x) ((x) << S_TSC3WRREN)
-#define F_TSC3WRREN V_TSC3WRREN(1U)
-
-#define S_TSC3RATEEN 6
-#define V_TSC3RATEEN(x) ((x) << S_TSC3RATEEN)
-#define F_TSC3RATEEN V_TSC3RATEEN(1U)
-
-#define S_TSC2WRREN 5
-#define V_TSC2WRREN(x) ((x) << S_TSC2WRREN)
-#define F_TSC2WRREN V_TSC2WRREN(1U)
-
-#define S_TSC2RATEEN 4
-#define V_TSC2RATEEN(x) ((x) << S_TSC2RATEEN)
-#define F_TSC2RATEEN V_TSC2RATEEN(1U)
-
-#define S_TSC1WRREN 3
-#define V_TSC1WRREN(x) ((x) << S_TSC1WRREN)
-#define F_TSC1WRREN V_TSC1WRREN(1U)
-
-#define S_TSC1RATEEN 2
-#define V_TSC1RATEEN(x) ((x) << S_TSC1RATEEN)
-#define F_TSC1RATEEN V_TSC1RATEEN(1U)
-
-#define S_TSC0WRREN 1
-#define V_TSC0WRREN(x) ((x) << S_TSC0WRREN)
-#define F_TSC0WRREN V_TSC0WRREN(1U)
-
-#define S_TSC0RATEEN 0
-#define V_TSC0RATEEN(x) ((x) << S_TSC0RATEEN)
-#define F_TSC0RATEEN V_TSC0RATEEN(1U)
-
-#define A_CIM_CTL_TSCH_MIN_MAX_EN 0x90c
-
-#define S_MIN_MAX_EN 0
-#define V_MIN_MAX_EN(x) ((x) << S_MIN_MAX_EN)
-#define F_MIN_MAX_EN V_MIN_MAX_EN(1U)
-
-#define A_CIM_CTL_TSCH_CHNLN_RATE_LIMITER 0x910
-
-#define S_TSCHNLRATENEG 31
-#define V_TSCHNLRATENEG(x) ((x) << S_TSCHNLRATENEG)
-#define F_TSCHNLRATENEG V_TSCHNLRATENEG(1U)
-
-#define S_TSCHNLRATEL 0
-#define M_TSCHNLRATEL 0x7fffffffU
-#define V_TSCHNLRATEL(x) ((x) << S_TSCHNLRATEL)
-#define G_TSCHNLRATEL(x) (((x) >> S_TSCHNLRATEL) & M_TSCHNLRATEL)
-
-#define S_TSCHNLRATEPROT 30
-#define V_TSCHNLRATEPROT(x) ((x) << S_TSCHNLRATEPROT)
-#define F_TSCHNLRATEPROT V_TSCHNLRATEPROT(1U)
-
-#define S_T6_TSCHNLRATEL 0
-#define M_T6_TSCHNLRATEL 0x3fffffffU
-#define V_T6_TSCHNLRATEL(x) ((x) << S_T6_TSCHNLRATEL)
-#define G_T6_TSCHNLRATEL(x) (((x) >> S_T6_TSCHNLRATEL) & M_T6_TSCHNLRATEL)
-
-#define A_CIM_CTL_TSCH_CHNLN_RATE_PROPERTIES 0x914
-
-#define S_TSCHNLRMAX 16
-#define M_TSCHNLRMAX 0xffffU
-#define V_TSCHNLRMAX(x) ((x) << S_TSCHNLRMAX)
-#define G_TSCHNLRMAX(x) (((x) >> S_TSCHNLRMAX) & M_TSCHNLRMAX)
-
-#define S_TSCHNLRINCR 0
-#define M_TSCHNLRINCR 0xffffU
-#define V_TSCHNLRINCR(x) ((x) << S_TSCHNLRINCR)
-#define G_TSCHNLRINCR(x) (((x) >> S_TSCHNLRINCR) & M_TSCHNLRINCR)
-
-#define S_TSCHNLRTSEL 14
-#define M_TSCHNLRTSEL 0x3U
-#define V_TSCHNLRTSEL(x) ((x) << S_TSCHNLRTSEL)
-#define G_TSCHNLRTSEL(x) (((x) >> S_TSCHNLRTSEL) & M_TSCHNLRTSEL)
-
-#define S_T6_TSCHNLRINCR 0
-#define M_T6_TSCHNLRINCR 0x3fffU
-#define V_T6_TSCHNLRINCR(x) ((x) << S_T6_TSCHNLRINCR)
-#define G_T6_TSCHNLRINCR(x) (((x) >> S_T6_TSCHNLRINCR) & M_T6_TSCHNLRINCR)
-
-#define A_CIM_CTL_TSCH_CHNLN_WRR 0x918
-#define A_CIM_CTL_TSCH_CHNLN_WEIGHT 0x91c
-
-#define S_TSCHNLWEIGHT 0
-#define M_TSCHNLWEIGHT 0x3fffffU
-#define V_TSCHNLWEIGHT(x) ((x) << S_TSCHNLWEIGHT)
-#define G_TSCHNLWEIGHT(x) (((x) >> S_TSCHNLWEIGHT) & M_TSCHNLWEIGHT)
-
-#define A_CIM_CTL_TSCH_CHNLN_CLASSM_RATE_LIMITER 0x920
-
-#define S_TSCCLRATENEG 31
-#define V_TSCCLRATENEG(x) ((x) << S_TSCCLRATENEG)
-#define F_TSCCLRATENEG V_TSCCLRATENEG(1U)
-
-#define S_TSCCLRATEL 0
-#define M_TSCCLRATEL 0xffffffU
-#define V_TSCCLRATEL(x) ((x) << S_TSCCLRATEL)
-#define G_TSCCLRATEL(x) (((x) >> S_TSCCLRATEL) & M_TSCCLRATEL)
-
-#define S_TSCCLRATEPROT 30
-#define V_TSCCLRATEPROT(x) ((x) << S_TSCCLRATEPROT)
-#define F_TSCCLRATEPROT V_TSCCLRATEPROT(1U)
-
-#define A_CIM_CTL_TSCH_CHNLN_CLASSM_RATE_PROPERTIES 0x924
-
-#define S_TSCCLRMAX 16
-#define M_TSCCLRMAX 0xffffU
-#define V_TSCCLRMAX(x) ((x) << S_TSCCLRMAX)
-#define G_TSCCLRMAX(x) (((x) >> S_TSCCLRMAX) & M_TSCCLRMAX)
-
-#define S_TSCCLRINCR 0
-#define M_TSCCLRINCR 0xffffU
-#define V_TSCCLRINCR(x) ((x) << S_TSCCLRINCR)
-#define G_TSCCLRINCR(x) (((x) >> S_TSCCLRINCR) & M_TSCCLRINCR)
-
-#define S_TSCCLRTSEL 14
-#define M_TSCCLRTSEL 0x3U
-#define V_TSCCLRTSEL(x) ((x) << S_TSCCLRTSEL)
-#define G_TSCCLRTSEL(x) (((x) >> S_TSCCLRTSEL) & M_TSCCLRTSEL)
-
-#define S_T6_TSCCLRINCR 0
-#define M_T6_TSCCLRINCR 0x3fffU
-#define V_T6_TSCCLRINCR(x) ((x) << S_T6_TSCCLRINCR)
-#define G_T6_TSCCLRINCR(x) (((x) >> S_T6_TSCCLRINCR) & M_T6_TSCCLRINCR)
-
-#define A_CIM_CTL_TSCH_CHNLN_CLASSM_WRR 0x928
-
-#define S_TSCCLWRRNEG 31
-#define V_TSCCLWRRNEG(x) ((x) << S_TSCCLWRRNEG)
-#define F_TSCCLWRRNEG V_TSCCLWRRNEG(1U)
-
-#define S_TSCCLWRR 0
-#define M_TSCCLWRR 0x3ffffffU
-#define V_TSCCLWRR(x) ((x) << S_TSCCLWRR)
-#define G_TSCCLWRR(x) (((x) >> S_TSCCLWRR) & M_TSCCLWRR)
-
-#define S_TSCCLWRRPROT 30
-#define V_TSCCLWRRPROT(x) ((x) << S_TSCCLWRRPROT)
-#define F_TSCCLWRRPROT V_TSCCLWRRPROT(1U)
-
-#define A_CIM_CTL_TSCH_CHNLN_CLASSM_WEIGHT 0x92c
-
-#define S_TSCCLWEIGHT 0
-#define M_TSCCLWEIGHT 0xffffU
-#define V_TSCCLWEIGHT(x) ((x) << S_TSCCLWEIGHT)
-#define G_TSCCLWEIGHT(x) (((x) >> S_TSCCLWEIGHT) & M_TSCCLWEIGHT)
-
-#define S_PAUSEVECSEL 28
-#define M_PAUSEVECSEL 0x3U
-#define V_PAUSEVECSEL(x) ((x) << S_PAUSEVECSEL)
-#define G_PAUSEVECSEL(x) (((x) >> S_PAUSEVECSEL) & M_PAUSEVECSEL)
-
-#define S_MPSPAUSEMASK 20
-#define M_MPSPAUSEMASK 0xffU
-#define V_MPSPAUSEMASK(x) ((x) << S_MPSPAUSEMASK)
-#define G_MPSPAUSEMASK(x) (((x) >> S_MPSPAUSEMASK) & M_MPSPAUSEMASK)
-
-#define A_CIM_CTL_TSCH_TICK0 0xd80
-#define A_CIM_CTL_MAILBOX_PF0_CTL 0xd84
-#define A_CIM_CTL_TSCH_TICK1 0xd84
-#define A_CIM_CTL_MAILBOX_PF1_CTL 0xd88
-#define A_CIM_CTL_TSCH_TICK2 0xd88
-#define A_CIM_CTL_MAILBOX_PF2_CTL 0xd8c
-#define A_CIM_CTL_TSCH_TICK3 0xd8c
-#define A_CIM_CTL_MAILBOX_PF3_CTL 0xd90
-#define A_T6_CIM_CTL_MAILBOX_PF0_CTL 0xd90
-#define A_CIM_CTL_MAILBOX_PF4_CTL 0xd94
-#define A_T6_CIM_CTL_MAILBOX_PF1_CTL 0xd94
-#define A_CIM_CTL_MAILBOX_PF5_CTL 0xd98
-#define A_T6_CIM_CTL_MAILBOX_PF2_CTL 0xd98
-#define A_CIM_CTL_MAILBOX_PF6_CTL 0xd9c
-#define A_T6_CIM_CTL_MAILBOX_PF3_CTL 0xd9c
-#define A_CIM_CTL_MAILBOX_PF7_CTL 0xda0
-#define A_T6_CIM_CTL_MAILBOX_PF4_CTL 0xda0
-#define A_CIM_CTL_MAILBOX_CTL_OWNER_COPY 0xda4
-
-#define S_PF7_OWNER_PL 15
-#define V_PF7_OWNER_PL(x) ((x) << S_PF7_OWNER_PL)
-#define F_PF7_OWNER_PL V_PF7_OWNER_PL(1U)
-
-#define S_PF6_OWNER_PL 14
-#define V_PF6_OWNER_PL(x) ((x) << S_PF6_OWNER_PL)
-#define F_PF6_OWNER_PL V_PF6_OWNER_PL(1U)
-
-#define S_PF5_OWNER_PL 13
-#define V_PF5_OWNER_PL(x) ((x) << S_PF5_OWNER_PL)
-#define F_PF5_OWNER_PL V_PF5_OWNER_PL(1U)
-
-#define S_PF4_OWNER_PL 12
-#define V_PF4_OWNER_PL(x) ((x) << S_PF4_OWNER_PL)
-#define F_PF4_OWNER_PL V_PF4_OWNER_PL(1U)
-
-#define S_PF3_OWNER_PL 11
-#define V_PF3_OWNER_PL(x) ((x) << S_PF3_OWNER_PL)
-#define F_PF3_OWNER_PL V_PF3_OWNER_PL(1U)
-
-#define S_PF2_OWNER_PL 10
-#define V_PF2_OWNER_PL(x) ((x) << S_PF2_OWNER_PL)
-#define F_PF2_OWNER_PL V_PF2_OWNER_PL(1U)
-
-#define S_PF1_OWNER_PL 9
-#define V_PF1_OWNER_PL(x) ((x) << S_PF1_OWNER_PL)
-#define F_PF1_OWNER_PL V_PF1_OWNER_PL(1U)
-
-#define S_PF0_OWNER_PL 8
-#define V_PF0_OWNER_PL(x) ((x) << S_PF0_OWNER_PL)
-#define F_PF0_OWNER_PL V_PF0_OWNER_PL(1U)
-
-#define S_PF7_OWNER_UP 7
-#define V_PF7_OWNER_UP(x) ((x) << S_PF7_OWNER_UP)
-#define F_PF7_OWNER_UP V_PF7_OWNER_UP(1U)
-
-#define S_PF6_OWNER_UP 6
-#define V_PF6_OWNER_UP(x) ((x) << S_PF6_OWNER_UP)
-#define F_PF6_OWNER_UP V_PF6_OWNER_UP(1U)
-
-#define S_PF5_OWNER_UP 5
-#define V_PF5_OWNER_UP(x) ((x) << S_PF5_OWNER_UP)
-#define F_PF5_OWNER_UP V_PF5_OWNER_UP(1U)
-
-#define S_PF4_OWNER_UP 4
-#define V_PF4_OWNER_UP(x) ((x) << S_PF4_OWNER_UP)
-#define F_PF4_OWNER_UP V_PF4_OWNER_UP(1U)
-
-#define S_PF3_OWNER_UP 3
-#define V_PF3_OWNER_UP(x) ((x) << S_PF3_OWNER_UP)
-#define F_PF3_OWNER_UP V_PF3_OWNER_UP(1U)
-
-#define S_PF2_OWNER_UP 2
-#define V_PF2_OWNER_UP(x) ((x) << S_PF2_OWNER_UP)
-#define F_PF2_OWNER_UP V_PF2_OWNER_UP(1U)
-
-#define S_PF1_OWNER_UP 1
-#define V_PF1_OWNER_UP(x) ((x) << S_PF1_OWNER_UP)
-#define F_PF1_OWNER_UP V_PF1_OWNER_UP(1U)
-
-#define S_PF0_OWNER_UP 0
-#define V_PF0_OWNER_UP(x) ((x) << S_PF0_OWNER_UP)
-#define F_PF0_OWNER_UP V_PF0_OWNER_UP(1U)
-
-#define A_T6_CIM_CTL_MAILBOX_PF5_CTL 0xda4
-#define A_CIM_CTL_PIO_MST_CONFIG 0xda8
-
-#define S_T5_CTLRID 0
-#define M_T5_CTLRID 0xffU
-#define V_T5_CTLRID(x) ((x) << S_T5_CTLRID)
-#define G_T5_CTLRID(x) (((x) >> S_T5_CTLRID) & M_T5_CTLRID)
-
-#define A_T6_CIM_CTL_MAILBOX_PF6_CTL 0xda8
-#define A_T6_CIM_CTL_MAILBOX_PF7_CTL 0xdac
-#define A_T6_CIM_CTL_MAILBOX_CTL_OWNER_COPY 0xdb0
-#define A_T6_CIM_CTL_PIO_MST_CONFIG 0xdb4
-
-#define S_T6_UPRID 0
-#define M_T6_UPRID 0x1ffU
-#define V_T6_UPRID(x) ((x) << S_T6_UPRID)
-#define G_T6_UPRID(x) (((x) >> S_T6_UPRID) & M_T6_UPRID)
-
-#define A_CIM_CTL_ULP_OBQ0_PAUSE_MASK 0xe00
-#define A_CIM_CTL_ULP_OBQ1_PAUSE_MASK 0xe04
-#define A_CIM_CTL_ULP_OBQ2_PAUSE_MASK 0xe08
-#define A_CIM_CTL_ULP_OBQ3_PAUSE_MASK 0xe0c
-#define A_CIM_CTL_ULP_OBQ_CONFIG 0xe10
-
-#define S_CH1_PRIO_EN 1
-#define V_CH1_PRIO_EN(x) ((x) << S_CH1_PRIO_EN)
-#define F_CH1_PRIO_EN V_CH1_PRIO_EN(1U)
-
-#define S_CH0_PRIO_EN 0
-#define V_CH0_PRIO_EN(x) ((x) << S_CH0_PRIO_EN)
-#define F_CH0_PRIO_EN V_CH0_PRIO_EN(1U)
-
-#define A_CIM_CTL_PIF_TIMEOUT 0xe40
-
-#define S_SLOW_TIMEOUT 16
-#define M_SLOW_TIMEOUT 0xffffU
-#define V_SLOW_TIMEOUT(x) ((x) << S_SLOW_TIMEOUT)
-#define G_SLOW_TIMEOUT(x) (((x) >> S_SLOW_TIMEOUT) & M_SLOW_TIMEOUT)
-
-#define S_MA_TIMEOUT 0
-#define M_MA_TIMEOUT 0xffffU
-#define V_MA_TIMEOUT(x) ((x) << S_MA_TIMEOUT)
-#define G_MA_TIMEOUT(x) (((x) >> S_MA_TIMEOUT) & M_MA_TIMEOUT)
-
-/* registers for module MAC */
-#define MAC_BASE_ADDR 0x0
-
-#define A_MAC_PORT_CFG 0x800
-
-#define S_MAC_CLK_SEL 29
-#define M_MAC_CLK_SEL 0x7U
-#define V_MAC_CLK_SEL(x) ((x) << S_MAC_CLK_SEL)
-#define G_MAC_CLK_SEL(x) (((x) >> S_MAC_CLK_SEL) & M_MAC_CLK_SEL)
-
-#define S_SMUXTXSEL 9
-#define V_SMUXTXSEL(x) ((x) << S_SMUXTXSEL)
-#define F_SMUXTXSEL V_SMUXTXSEL(1U)
-
-#define S_SMUXRXSEL 8
-#define V_SMUXRXSEL(x) ((x) << S_SMUXRXSEL)
-#define F_SMUXRXSEL V_SMUXRXSEL(1U)
-
-#define S_PORTSPEED 4
-#define M_PORTSPEED 0x3U
-#define V_PORTSPEED(x) ((x) << S_PORTSPEED)
-#define G_PORTSPEED(x) (((x) >> S_PORTSPEED) & M_PORTSPEED)
-
-#define S_ENA_ERR_RSP 28
-#define V_ENA_ERR_RSP(x) ((x) << S_ENA_ERR_RSP)
-#define F_ENA_ERR_RSP V_ENA_ERR_RSP(1U)
-
-#define S_DEBUG_CLR 25
-#define V_DEBUG_CLR(x) ((x) << S_DEBUG_CLR)
-#define F_DEBUG_CLR V_DEBUG_CLR(1U)
-
-#define S_PLL_SEL 23
-#define V_PLL_SEL(x) ((x) << S_PLL_SEL)
-#define F_PLL_SEL V_PLL_SEL(1U)
-
-#define S_PORT_MAP 20
-#define M_PORT_MAP 0x7U
-#define V_PORT_MAP(x) ((x) << S_PORT_MAP)
-#define G_PORT_MAP(x) (((x) >> S_PORT_MAP) & M_PORT_MAP)
-
-#define S_AEC_PAT_DATA 15
-#define V_AEC_PAT_DATA(x) ((x) << S_AEC_PAT_DATA)
-#define F_AEC_PAT_DATA V_AEC_PAT_DATA(1U)
-
-#define S_MACCLK_SEL 13
-#define V_MACCLK_SEL(x) ((x) << S_MACCLK_SEL)
-#define F_MACCLK_SEL V_MACCLK_SEL(1U)
-
-#define S_XGMII_SEL 12
-#define V_XGMII_SEL(x) ((x) << S_XGMII_SEL)
-#define F_XGMII_SEL V_XGMII_SEL(1U)
-
-#define S_DEBUG_PORT_SEL 10
-#define M_DEBUG_PORT_SEL 0x3U
-#define V_DEBUG_PORT_SEL(x) ((x) << S_DEBUG_PORT_SEL)
-#define G_DEBUG_PORT_SEL(x) (((x) >> S_DEBUG_PORT_SEL) & M_DEBUG_PORT_SEL)
-
-#define S_ENABLE_25G 7
-#define V_ENABLE_25G(x) ((x) << S_ENABLE_25G)
-#define F_ENABLE_25G V_ENABLE_25G(1U)
-
-#define S_ENABLE_50G 6
-#define V_ENABLE_50G(x) ((x) << S_ENABLE_50G)
-#define F_ENABLE_50G V_ENABLE_50G(1U)
-
-#define S_DEBUG_TX_RX_SEL 1
-#define V_DEBUG_TX_RX_SEL(x) ((x) << S_DEBUG_TX_RX_SEL)
-#define F_DEBUG_TX_RX_SEL V_DEBUG_TX_RX_SEL(1U)
-
-#define A_MAC_PORT_RESET_CTRL 0x804
-
-#define S_TWGDSK_HSSC16B 31
-#define V_TWGDSK_HSSC16B(x) ((x) << S_TWGDSK_HSSC16B)
-#define F_TWGDSK_HSSC16B V_TWGDSK_HSSC16B(1U)
-
-#define S_EEE_RESET 30
-#define V_EEE_RESET(x) ((x) << S_EEE_RESET)
-#define F_EEE_RESET V_EEE_RESET(1U)
-
-#define S_PTP_TIMER 29
-#define V_PTP_TIMER(x) ((x) << S_PTP_TIMER)
-#define F_PTP_TIMER V_PTP_TIMER(1U)
-
-#define S_MTIPREFRESET 28
-#define V_MTIPREFRESET(x) ((x) << S_MTIPREFRESET)
-#define F_MTIPREFRESET V_MTIPREFRESET(1U)
-
-#define S_MTIPTXFFRESET 27
-#define V_MTIPTXFFRESET(x) ((x) << S_MTIPTXFFRESET)
-#define F_MTIPTXFFRESET V_MTIPTXFFRESET(1U)
-
-#define S_MTIPRXFFRESET 26
-#define V_MTIPRXFFRESET(x) ((x) << S_MTIPRXFFRESET)
-#define F_MTIPRXFFRESET V_MTIPRXFFRESET(1U)
-
-#define S_MTIPREGRESET 25
-#define V_MTIPREGRESET(x) ((x) << S_MTIPREGRESET)
-#define F_MTIPREGRESET V_MTIPREGRESET(1U)
-
-#define S_AEC3RESET 23
-#define V_AEC3RESET(x) ((x) << S_AEC3RESET)
-#define F_AEC3RESET V_AEC3RESET(1U)
-
-#define S_AEC2RESET 22
-#define V_AEC2RESET(x) ((x) << S_AEC2RESET)
-#define F_AEC2RESET V_AEC2RESET(1U)
-
-#define S_AEC1RESET 21
-#define V_AEC1RESET(x) ((x) << S_AEC1RESET)
-#define F_AEC1RESET V_AEC1RESET(1U)
-
-#define S_AEC0RESET 20
-#define V_AEC0RESET(x) ((x) << S_AEC0RESET)
-#define F_AEC0RESET V_AEC0RESET(1U)
-
-#define S_AET3RESET 19
-#define V_AET3RESET(x) ((x) << S_AET3RESET)
-#define F_AET3RESET V_AET3RESET(1U)
-
-#define S_AET2RESET 18
-#define V_AET2RESET(x) ((x) << S_AET2RESET)
-#define F_AET2RESET V_AET2RESET(1U)
-
-#define S_AET1RESET 17
-#define V_AET1RESET(x) ((x) << S_AET1RESET)
-#define F_AET1RESET V_AET1RESET(1U)
-
-#define S_AET0RESET 16
-#define V_AET0RESET(x) ((x) << S_AET0RESET)
-#define F_AET0RESET V_AET0RESET(1U)
-
-#define S_TXIF_RESET 12
-#define V_TXIF_RESET(x) ((x) << S_TXIF_RESET)
-#define F_TXIF_RESET V_TXIF_RESET(1U)
-
-#define S_RXIF_RESET 11
-#define V_RXIF_RESET(x) ((x) << S_RXIF_RESET)
-#define F_RXIF_RESET V_RXIF_RESET(1U)
-
-#define S_MTIPSD3TXRST 9
-#define V_MTIPSD3TXRST(x) ((x) << S_MTIPSD3TXRST)
-#define F_MTIPSD3TXRST V_MTIPSD3TXRST(1U)
-
-#define S_MTIPSD2TXRST 8
-#define V_MTIPSD2TXRST(x) ((x) << S_MTIPSD2TXRST)
-#define F_MTIPSD2TXRST V_MTIPSD2TXRST(1U)
-
-#define S_MTIPSD1TXRST 7
-#define V_MTIPSD1TXRST(x) ((x) << S_MTIPSD1TXRST)
-#define F_MTIPSD1TXRST V_MTIPSD1TXRST(1U)
-
-#define S_MTIPSD0TXRST 6
-#define V_MTIPSD0TXRST(x) ((x) << S_MTIPSD0TXRST)
-#define F_MTIPSD0TXRST V_MTIPSD0TXRST(1U)
-
-#define S_MTIPSD3RXRST 5
-#define V_MTIPSD3RXRST(x) ((x) << S_MTIPSD3RXRST)
-#define F_MTIPSD3RXRST V_MTIPSD3RXRST(1U)
-
-#define S_MTIPSD2RXRST 4
-#define V_MTIPSD2RXRST(x) ((x) << S_MTIPSD2RXRST)
-#define F_MTIPSD2RXRST V_MTIPSD2RXRST(1U)
-
-#define S_MTIPSD1RXRST 3
-#define V_MTIPSD1RXRST(x) ((x) << S_MTIPSD1RXRST)
-#define F_MTIPSD1RXRST V_MTIPSD1RXRST(1U)
-
-#define S_MTIPSD0RXRST 1
-#define V_MTIPSD0RXRST(x) ((x) << S_MTIPSD0RXRST)
-#define F_MTIPSD0RXRST V_MTIPSD0RXRST(1U)
-
-#define S_MAC100G40G_RESET 27
-#define V_MAC100G40G_RESET(x) ((x) << S_MAC100G40G_RESET)
-#define F_MAC100G40G_RESET V_MAC100G40G_RESET(1U)
-
-#define S_MAC10G1G_RESET 26
-#define V_MAC10G1G_RESET(x) ((x) << S_MAC10G1G_RESET)
-#define F_MAC10G1G_RESET V_MAC10G1G_RESET(1U)
-
-#define S_PCS1G_RESET 24
-#define V_PCS1G_RESET(x) ((x) << S_PCS1G_RESET)
-#define F_PCS1G_RESET V_PCS1G_RESET(1U)
-
-#define S_PCS10G_RESET 15
-#define V_PCS10G_RESET(x) ((x) << S_PCS10G_RESET)
-#define F_PCS10G_RESET V_PCS10G_RESET(1U)
-
-#define S_PCS40G_RESET 14
-#define V_PCS40G_RESET(x) ((x) << S_PCS40G_RESET)
-#define F_PCS40G_RESET V_PCS40G_RESET(1U)
-
-#define S_PCS100G_RESET 13
-#define V_PCS100G_RESET(x) ((x) << S_PCS100G_RESET)
-#define F_PCS100G_RESET V_PCS100G_RESET(1U)
-
-#define A_MAC_PORT_LED_CFG 0x808
-
-#define S_LED1_CFG1 14
-#define M_LED1_CFG1 0x3U
-#define V_LED1_CFG1(x) ((x) << S_LED1_CFG1)
-#define G_LED1_CFG1(x) (((x) >> S_LED1_CFG1) & M_LED1_CFG1)
-
-#define S_LED0_CFG1 12
-#define M_LED0_CFG1 0x3U
-#define V_LED0_CFG1(x) ((x) << S_LED0_CFG1)
-#define G_LED0_CFG1(x) (((x) >> S_LED0_CFG1) & M_LED0_CFG1)
-
-#define S_LED1_TLO 11
-#define V_LED1_TLO(x) ((x) << S_LED1_TLO)
-#define F_LED1_TLO V_LED1_TLO(1U)
-
-#define S_LED1_THI 10
-#define V_LED1_THI(x) ((x) << S_LED1_THI)
-#define F_LED1_THI V_LED1_THI(1U)
-
-#define S_LED0_TLO 9
-#define V_LED0_TLO(x) ((x) << S_LED0_TLO)
-#define F_LED0_TLO V_LED0_TLO(1U)
-
-#define S_LED0_THI 8
-#define V_LED0_THI(x) ((x) << S_LED0_THI)
-#define F_LED0_THI V_LED0_THI(1U)
-
-#define A_MAC_PORT_LED_COUNTHI 0x80c
-#define A_MAC_PORT_LED_COUNTLO 0x810
-#define A_MAC_PORT_CFG3 0x814
-
-#define S_T5_FPGA_PTP_PORT 26
-#define M_T5_FPGA_PTP_PORT 0x3U
-#define V_T5_FPGA_PTP_PORT(x) ((x) << S_T5_FPGA_PTP_PORT)
-#define G_T5_FPGA_PTP_PORT(x) (((x) >> S_T5_FPGA_PTP_PORT) & M_T5_FPGA_PTP_PORT)
-
-#define S_FCSDISCTRL 25
-#define V_FCSDISCTRL(x) ((x) << S_FCSDISCTRL)
-#define F_FCSDISCTRL V_FCSDISCTRL(1U)
-
-#define S_SIGDETCTRL 24
-#define V_SIGDETCTRL(x) ((x) << S_SIGDETCTRL)
-#define F_SIGDETCTRL V_SIGDETCTRL(1U)
-
-#define S_TX_LANE 23
-#define V_TX_LANE(x) ((x) << S_TX_LANE)
-#define F_TX_LANE V_TX_LANE(1U)
-
-#define S_RX_LANE 22
-#define V_RX_LANE(x) ((x) << S_RX_LANE)
-#define F_RX_LANE V_RX_LANE(1U)
-
-#define S_SE_CLR 21
-#define V_SE_CLR(x) ((x) << S_SE_CLR)
-#define F_SE_CLR V_SE_CLR(1U)
-
-#define S_AN_ENA 17
-#define M_AN_ENA 0xfU
-#define V_AN_ENA(x) ((x) << S_AN_ENA)
-#define G_AN_ENA(x) (((x) >> S_AN_ENA) & M_AN_ENA)
-
-#define S_SD_RX_CLK_ENA 13
-#define M_SD_RX_CLK_ENA 0xfU
-#define V_SD_RX_CLK_ENA(x) ((x) << S_SD_RX_CLK_ENA)
-#define G_SD_RX_CLK_ENA(x) (((x) >> S_SD_RX_CLK_ENA) & M_SD_RX_CLK_ENA)
-
-#define S_SD_TX_CLK_ENA 9
-#define M_SD_TX_CLK_ENA 0xfU
-#define V_SD_TX_CLK_ENA(x) ((x) << S_SD_TX_CLK_ENA)
-#define G_SD_TX_CLK_ENA(x) (((x) >> S_SD_TX_CLK_ENA) & M_SD_TX_CLK_ENA)
-
-#define S_SGMIISEL 8
-#define V_SGMIISEL(x) ((x) << S_SGMIISEL)
-#define F_SGMIISEL V_SGMIISEL(1U)
-
-#define S_HSSPLLSEL 4
-#define M_HSSPLLSEL 0xfU
-#define V_HSSPLLSEL(x) ((x) << S_HSSPLLSEL)
-#define G_HSSPLLSEL(x) (((x) >> S_HSSPLLSEL) & M_HSSPLLSEL)
-
-#define S_HSSC16C20SEL 0
-#define M_HSSC16C20SEL 0xfU
-#define V_HSSC16C20SEL(x) ((x) << S_HSSC16C20SEL)
-#define G_HSSC16C20SEL(x) (((x) >> S_HSSC16C20SEL) & M_HSSC16C20SEL)
-
-#define S_REF_CLK_SEL 30
-#define M_REF_CLK_SEL 0x3U
-#define V_REF_CLK_SEL(x) ((x) << S_REF_CLK_SEL)
-#define G_REF_CLK_SEL(x) (((x) >> S_REF_CLK_SEL) & M_REF_CLK_SEL)
-
-#define S_SGMII_SD_SIG_DET 29
-#define V_SGMII_SD_SIG_DET(x) ((x) << S_SGMII_SD_SIG_DET)
-#define F_SGMII_SD_SIG_DET V_SGMII_SD_SIG_DET(1U)
-
-#define S_SGMII_SGPCS_ENA 28
-#define V_SGMII_SGPCS_ENA(x) ((x) << S_SGMII_SGPCS_ENA)
-#define F_SGMII_SGPCS_ENA V_SGMII_SGPCS_ENA(1U)
-
-#define S_MAC_FPGA_PTP_PORT 26
-#define M_MAC_FPGA_PTP_PORT 0x3U
-#define V_MAC_FPGA_PTP_PORT(x) ((x) << S_MAC_FPGA_PTP_PORT)
-#define G_MAC_FPGA_PTP_PORT(x) (((x) >> S_MAC_FPGA_PTP_PORT) & M_MAC_FPGA_PTP_PORT)
-
-#define A_MAC_PORT_CFG2 0x818
-
-#define S_T5_AEC_PMA_TX_READY 4
-#define M_T5_AEC_PMA_TX_READY 0xfU
-#define V_T5_AEC_PMA_TX_READY(x) ((x) << S_T5_AEC_PMA_TX_READY)
-#define G_T5_AEC_PMA_TX_READY(x) (((x) >> S_T5_AEC_PMA_TX_READY) & M_T5_AEC_PMA_TX_READY)
-
-#define S_T5_AEC_PMA_RX_READY 0
-#define M_T5_AEC_PMA_RX_READY 0xfU
-#define V_T5_AEC_PMA_RX_READY(x) ((x) << S_T5_AEC_PMA_RX_READY)
-#define G_T5_AEC_PMA_RX_READY(x) (((x) >> S_T5_AEC_PMA_RX_READY) & M_T5_AEC_PMA_RX_READY)
-
-#define S_AN_DATA_CTL 19
-#define V_AN_DATA_CTL(x) ((x) << S_AN_DATA_CTL)
-#define F_AN_DATA_CTL V_AN_DATA_CTL(1U)
-
-#define A_MAC_PORT_PKT_COUNT 0x81c
-#define A_MAC_PORT_CFG4 0x820
-
-#define S_AEC3_RX_WIDTH 14
-#define M_AEC3_RX_WIDTH 0x3U
-#define V_AEC3_RX_WIDTH(x) ((x) << S_AEC3_RX_WIDTH)
-#define G_AEC3_RX_WIDTH(x) (((x) >> S_AEC3_RX_WIDTH) & M_AEC3_RX_WIDTH)
-
-#define S_AEC2_RX_WIDTH 12
-#define M_AEC2_RX_WIDTH 0x3U
-#define V_AEC2_RX_WIDTH(x) ((x) << S_AEC2_RX_WIDTH)
-#define G_AEC2_RX_WIDTH(x) (((x) >> S_AEC2_RX_WIDTH) & M_AEC2_RX_WIDTH)
-
-#define S_AEC1_RX_WIDTH 10
-#define M_AEC1_RX_WIDTH 0x3U
-#define V_AEC1_RX_WIDTH(x) ((x) << S_AEC1_RX_WIDTH)
-#define G_AEC1_RX_WIDTH(x) (((x) >> S_AEC1_RX_WIDTH) & M_AEC1_RX_WIDTH)
-
-#define S_AEC0_RX_WIDTH 8
-#define M_AEC0_RX_WIDTH 0x3U
-#define V_AEC0_RX_WIDTH(x) ((x) << S_AEC0_RX_WIDTH)
-#define G_AEC0_RX_WIDTH(x) (((x) >> S_AEC0_RX_WIDTH) & M_AEC0_RX_WIDTH)
-
-#define S_AEC3_TX_WIDTH 6
-#define M_AEC3_TX_WIDTH 0x3U
-#define V_AEC3_TX_WIDTH(x) ((x) << S_AEC3_TX_WIDTH)
-#define G_AEC3_TX_WIDTH(x) (((x) >> S_AEC3_TX_WIDTH) & M_AEC3_TX_WIDTH)
-
-#define S_AEC2_TX_WIDTH 4
-#define M_AEC2_TX_WIDTH 0x3U
-#define V_AEC2_TX_WIDTH(x) ((x) << S_AEC2_TX_WIDTH)
-#define G_AEC2_TX_WIDTH(x) (((x) >> S_AEC2_TX_WIDTH) & M_AEC2_TX_WIDTH)
-
-#define S_AEC1_TX_WIDTH 2
-#define M_AEC1_TX_WIDTH 0x3U
-#define V_AEC1_TX_WIDTH(x) ((x) << S_AEC1_TX_WIDTH)
-#define G_AEC1_TX_WIDTH(x) (((x) >> S_AEC1_TX_WIDTH) & M_AEC1_TX_WIDTH)
-
-#define S_AEC0_TX_WIDTH 0
-#define M_AEC0_TX_WIDTH 0x3U
-#define V_AEC0_TX_WIDTH(x) ((x) << S_AEC0_TX_WIDTH)
-#define G_AEC0_TX_WIDTH(x) (((x) >> S_AEC0_TX_WIDTH) & M_AEC0_TX_WIDTH)
-
-#define A_MAC_PORT_MAGIC_MACID_LO 0x824
-#define A_MAC_PORT_MAGIC_MACID_HI 0x828
-#define A_MAC_PORT_MTIP_RESET_CTRL 0x82c
-
-#define S_AN_RESET_SD_TX_CLK 31
-#define V_AN_RESET_SD_TX_CLK(x) ((x) << S_AN_RESET_SD_TX_CLK)
-#define F_AN_RESET_SD_TX_CLK V_AN_RESET_SD_TX_CLK(1U)
-
-#define S_AN_RESET_SD_RX_CLK 30
-#define V_AN_RESET_SD_RX_CLK(x) ((x) << S_AN_RESET_SD_RX_CLK)
-#define F_AN_RESET_SD_RX_CLK V_AN_RESET_SD_RX_CLK(1U)
-
-#define S_SGMII_RESET_TX_CLK 29
-#define V_SGMII_RESET_TX_CLK(x) ((x) << S_SGMII_RESET_TX_CLK)
-#define F_SGMII_RESET_TX_CLK V_SGMII_RESET_TX_CLK(1U)
-
-#define S_SGMII_RESET_RX_CLK 28
-#define V_SGMII_RESET_RX_CLK(x) ((x) << S_SGMII_RESET_RX_CLK)
-#define F_SGMII_RESET_RX_CLK V_SGMII_RESET_RX_CLK(1U)
-
-#define S_SGMII_RESET_REF_CLK 27
-#define V_SGMII_RESET_REF_CLK(x) ((x) << S_SGMII_RESET_REF_CLK)
-#define F_SGMII_RESET_REF_CLK V_SGMII_RESET_REF_CLK(1U)
-
-#define S_PCS10G_RESET_XFI_RXCLK 26
-#define V_PCS10G_RESET_XFI_RXCLK(x) ((x) << S_PCS10G_RESET_XFI_RXCLK)
-#define F_PCS10G_RESET_XFI_RXCLK V_PCS10G_RESET_XFI_RXCLK(1U)
-
-#define S_PCS10G_RESET_XFI_TXCLK 25
-#define V_PCS10G_RESET_XFI_TXCLK(x) ((x) << S_PCS10G_RESET_XFI_TXCLK)
-#define F_PCS10G_RESET_XFI_TXCLK V_PCS10G_RESET_XFI_TXCLK(1U)
-
-#define S_PCS10G_RESET_SD_TX_CLK 24
-#define V_PCS10G_RESET_SD_TX_CLK(x) ((x) << S_PCS10G_RESET_SD_TX_CLK)
-#define F_PCS10G_RESET_SD_TX_CLK V_PCS10G_RESET_SD_TX_CLK(1U)
-
-#define S_PCS10G_RESET_SD_RX_CLK 23
-#define V_PCS10G_RESET_SD_RX_CLK(x) ((x) << S_PCS10G_RESET_SD_RX_CLK)
-#define F_PCS10G_RESET_SD_RX_CLK V_PCS10G_RESET_SD_RX_CLK(1U)
-
-#define S_PCS40G_RESET_RXCLK 22
-#define V_PCS40G_RESET_RXCLK(x) ((x) << S_PCS40G_RESET_RXCLK)
-#define F_PCS40G_RESET_RXCLK V_PCS40G_RESET_RXCLK(1U)
-
-#define S_PCS40G_RESET_SD_TX_CLK 21
-#define V_PCS40G_RESET_SD_TX_CLK(x) ((x) << S_PCS40G_RESET_SD_TX_CLK)
-#define F_PCS40G_RESET_SD_TX_CLK V_PCS40G_RESET_SD_TX_CLK(1U)
-
-#define S_PCS40G_RESET_SD0_RX_CLK 20
-#define V_PCS40G_RESET_SD0_RX_CLK(x) ((x) << S_PCS40G_RESET_SD0_RX_CLK)
-#define F_PCS40G_RESET_SD0_RX_CLK V_PCS40G_RESET_SD0_RX_CLK(1U)
-
-#define S_PCS40G_RESET_SD1_RX_CLK 19
-#define V_PCS40G_RESET_SD1_RX_CLK(x) ((x) << S_PCS40G_RESET_SD1_RX_CLK)
-#define F_PCS40G_RESET_SD1_RX_CLK V_PCS40G_RESET_SD1_RX_CLK(1U)
-
-#define S_PCS40G_RESET_SD2_RX_CLK 18
-#define V_PCS40G_RESET_SD2_RX_CLK(x) ((x) << S_PCS40G_RESET_SD2_RX_CLK)
-#define F_PCS40G_RESET_SD2_RX_CLK V_PCS40G_RESET_SD2_RX_CLK(1U)
-
-#define S_PCS40G_RESET_SD3_RX_CLK 17
-#define V_PCS40G_RESET_SD3_RX_CLK(x) ((x) << S_PCS40G_RESET_SD3_RX_CLK)
-#define F_PCS40G_RESET_SD3_RX_CLK V_PCS40G_RESET_SD3_RX_CLK(1U)
-
-#define S_PCS100G_RESET_CGMII_RXCLK 16
-#define V_PCS100G_RESET_CGMII_RXCLK(x) ((x) << S_PCS100G_RESET_CGMII_RXCLK)
-#define F_PCS100G_RESET_CGMII_RXCLK V_PCS100G_RESET_CGMII_RXCLK(1U)
-
-#define S_PCS100G_RESET_CGMII_TXCLK 15
-#define V_PCS100G_RESET_CGMII_TXCLK(x) ((x) << S_PCS100G_RESET_CGMII_TXCLK)
-#define F_PCS100G_RESET_CGMII_TXCLK V_PCS100G_RESET_CGMII_TXCLK(1U)
-
-#define S_PCS100G_RESET_TX_CLK 14
-#define V_PCS100G_RESET_TX_CLK(x) ((x) << S_PCS100G_RESET_TX_CLK)
-#define F_PCS100G_RESET_TX_CLK V_PCS100G_RESET_TX_CLK(1U)
-
-#define S_PCS100G_RESET_SD0_RX_CLK 13
-#define V_PCS100G_RESET_SD0_RX_CLK(x) ((x) << S_PCS100G_RESET_SD0_RX_CLK)
-#define F_PCS100G_RESET_SD0_RX_CLK V_PCS100G_RESET_SD0_RX_CLK(1U)
-
-#define S_PCS100G_RESET_SD1_RX_CLK 12
-#define V_PCS100G_RESET_SD1_RX_CLK(x) ((x) << S_PCS100G_RESET_SD1_RX_CLK)
-#define F_PCS100G_RESET_SD1_RX_CLK V_PCS100G_RESET_SD1_RX_CLK(1U)
-
-#define S_PCS100G_RESET_SD2_RX_CLK 11
-#define V_PCS100G_RESET_SD2_RX_CLK(x) ((x) << S_PCS100G_RESET_SD2_RX_CLK)
-#define F_PCS100G_RESET_SD2_RX_CLK V_PCS100G_RESET_SD2_RX_CLK(1U)
-
-#define S_PCS100G_RESET_SD3_RX_CLK 10
-#define V_PCS100G_RESET_SD3_RX_CLK(x) ((x) << S_PCS100G_RESET_SD3_RX_CLK)
-#define F_PCS100G_RESET_SD3_RX_CLK V_PCS100G_RESET_SD3_RX_CLK(1U)
-
-#define S_MAC40G100G_RESET_TXCLK 9
-#define V_MAC40G100G_RESET_TXCLK(x) ((x) << S_MAC40G100G_RESET_TXCLK)
-#define F_MAC40G100G_RESET_TXCLK V_MAC40G100G_RESET_TXCLK(1U)
-
-#define S_MAC40G100G_RESET_RXCLK 8
-#define V_MAC40G100G_RESET_RXCLK(x) ((x) << S_MAC40G100G_RESET_RXCLK)
-#define F_MAC40G100G_RESET_RXCLK V_MAC40G100G_RESET_RXCLK(1U)
-
-#define S_MAC40G100G_RESET_FF_TX_CLK 7
-#define V_MAC40G100G_RESET_FF_TX_CLK(x) ((x) << S_MAC40G100G_RESET_FF_TX_CLK)
-#define F_MAC40G100G_RESET_FF_TX_CLK V_MAC40G100G_RESET_FF_TX_CLK(1U)
-
-#define S_MAC40G100G_RESET_FF_RX_CLK 6
-#define V_MAC40G100G_RESET_FF_RX_CLK(x) ((x) << S_MAC40G100G_RESET_FF_RX_CLK)
-#define F_MAC40G100G_RESET_FF_RX_CLK V_MAC40G100G_RESET_FF_RX_CLK(1U)
-
-#define S_MAC40G100G_RESET_TS_CLK 5
-#define V_MAC40G100G_RESET_TS_CLK(x) ((x) << S_MAC40G100G_RESET_TS_CLK)
-#define F_MAC40G100G_RESET_TS_CLK V_MAC40G100G_RESET_TS_CLK(1U)
-
-#define S_MAC1G10G_RESET_RXCLK 4
-#define V_MAC1G10G_RESET_RXCLK(x) ((x) << S_MAC1G10G_RESET_RXCLK)
-#define F_MAC1G10G_RESET_RXCLK V_MAC1G10G_RESET_RXCLK(1U)
-
-#define S_MAC1G10G_RESET_TXCLK 3
-#define V_MAC1G10G_RESET_TXCLK(x) ((x) << S_MAC1G10G_RESET_TXCLK)
-#define F_MAC1G10G_RESET_TXCLK V_MAC1G10G_RESET_TXCLK(1U)
-
-#define S_MAC1G10G_RESET_FF_RX_CLK 2
-#define V_MAC1G10G_RESET_FF_RX_CLK(x) ((x) << S_MAC1G10G_RESET_FF_RX_CLK)
-#define F_MAC1G10G_RESET_FF_RX_CLK V_MAC1G10G_RESET_FF_RX_CLK(1U)
-
-#define S_MAC1G10G_RESET_FF_TX_CLK 1
-#define V_MAC1G10G_RESET_FF_TX_CLK(x) ((x) << S_MAC1G10G_RESET_FF_TX_CLK)
-#define F_MAC1G10G_RESET_FF_TX_CLK V_MAC1G10G_RESET_FF_TX_CLK(1U)
-
-#define S_XGMII_CLK_RESET 0
-#define V_XGMII_CLK_RESET(x) ((x) << S_XGMII_CLK_RESET)
-#define F_XGMII_CLK_RESET V_XGMII_CLK_RESET(1U)
-
-#define A_MAC_PORT_MTIP_GATE_CTRL 0x830
-
-#define S_AN_GATE_SD_TX_CLK 31
-#define V_AN_GATE_SD_TX_CLK(x) ((x) << S_AN_GATE_SD_TX_CLK)
-#define F_AN_GATE_SD_TX_CLK V_AN_GATE_SD_TX_CLK(1U)
-
-#define S_AN_GATE_SD_RX_CLK 30
-#define V_AN_GATE_SD_RX_CLK(x) ((x) << S_AN_GATE_SD_RX_CLK)
-#define F_AN_GATE_SD_RX_CLK V_AN_GATE_SD_RX_CLK(1U)
-
-#define S_SGMII_GATE_TX_CLK 29
-#define V_SGMII_GATE_TX_CLK(x) ((x) << S_SGMII_GATE_TX_CLK)
-#define F_SGMII_GATE_TX_CLK V_SGMII_GATE_TX_CLK(1U)
-
-#define S_SGMII_GATE_RX_CLK 28
-#define V_SGMII_GATE_RX_CLK(x) ((x) << S_SGMII_GATE_RX_CLK)
-#define F_SGMII_GATE_RX_CLK V_SGMII_GATE_RX_CLK(1U)
-
-#define S_SGMII_GATE_REF_CLK 27
-#define V_SGMII_GATE_REF_CLK(x) ((x) << S_SGMII_GATE_REF_CLK)
-#define F_SGMII_GATE_REF_CLK V_SGMII_GATE_REF_CLK(1U)
-
-#define S_PCS10G_GATE_XFI_RXCLK 26
-#define V_PCS10G_GATE_XFI_RXCLK(x) ((x) << S_PCS10G_GATE_XFI_RXCLK)
-#define F_PCS10G_GATE_XFI_RXCLK V_PCS10G_GATE_XFI_RXCLK(1U)
-
-#define S_PCS10G_GATE_XFI_TXCLK 25
-#define V_PCS10G_GATE_XFI_TXCLK(x) ((x) << S_PCS10G_GATE_XFI_TXCLK)
-#define F_PCS10G_GATE_XFI_TXCLK V_PCS10G_GATE_XFI_TXCLK(1U)
-
-#define S_PCS10G_GATE_SD_TX_CLK 24
-#define V_PCS10G_GATE_SD_TX_CLK(x) ((x) << S_PCS10G_GATE_SD_TX_CLK)
-#define F_PCS10G_GATE_SD_TX_CLK V_PCS10G_GATE_SD_TX_CLK(1U)
-
-#define S_PCS10G_GATE_SD_RX_CLK 23
-#define V_PCS10G_GATE_SD_RX_CLK(x) ((x) << S_PCS10G_GATE_SD_RX_CLK)
-#define F_PCS10G_GATE_SD_RX_CLK V_PCS10G_GATE_SD_RX_CLK(1U)
-
-#define S_PCS40G_GATE_RXCLK 22
-#define V_PCS40G_GATE_RXCLK(x) ((x) << S_PCS40G_GATE_RXCLK)
-#define F_PCS40G_GATE_RXCLK V_PCS40G_GATE_RXCLK(1U)
-
-#define S_PCS40G_GATE_SD_TX_CLK 21
-#define V_PCS40G_GATE_SD_TX_CLK(x) ((x) << S_PCS40G_GATE_SD_TX_CLK)
-#define F_PCS40G_GATE_SD_TX_CLK V_PCS40G_GATE_SD_TX_CLK(1U)
-
-#define S_PCS40G_GATE_SD_RX_CLK 20
-#define V_PCS40G_GATE_SD_RX_CLK(x) ((x) << S_PCS40G_GATE_SD_RX_CLK)
-#define F_PCS40G_GATE_SD_RX_CLK V_PCS40G_GATE_SD_RX_CLK(1U)
-
-#define S_PCS100G_GATE_CGMII_RXCLK 19
-#define V_PCS100G_GATE_CGMII_RXCLK(x) ((x) << S_PCS100G_GATE_CGMII_RXCLK)
-#define F_PCS100G_GATE_CGMII_RXCLK V_PCS100G_GATE_CGMII_RXCLK(1U)
-
-#define S_PCS100G_GATE_CGMII_TXCLK 18
-#define V_PCS100G_GATE_CGMII_TXCLK(x) ((x) << S_PCS100G_GATE_CGMII_TXCLK)
-#define F_PCS100G_GATE_CGMII_TXCLK V_PCS100G_GATE_CGMII_TXCLK(1U)
-
-#define S_PCS100G_GATE_TX_CLK 17
-#define V_PCS100G_GATE_TX_CLK(x) ((x) << S_PCS100G_GATE_TX_CLK)
-#define F_PCS100G_GATE_TX_CLK V_PCS100G_GATE_TX_CLK(1U)
-
-#define S_PCS100G_GATE_SD_RX_CLK 16
-#define V_PCS100G_GATE_SD_RX_CLK(x) ((x) << S_PCS100G_GATE_SD_RX_CLK)
-#define F_PCS100G_GATE_SD_RX_CLK V_PCS100G_GATE_SD_RX_CLK(1U)
-
-#define S_MAC40G100G_GATE_TXCLK 15
-#define V_MAC40G100G_GATE_TXCLK(x) ((x) << S_MAC40G100G_GATE_TXCLK)
-#define F_MAC40G100G_GATE_TXCLK V_MAC40G100G_GATE_TXCLK(1U)
-
-#define S_MAC40G100G_GATE_RXCLK 14
-#define V_MAC40G100G_GATE_RXCLK(x) ((x) << S_MAC40G100G_GATE_RXCLK)
-#define F_MAC40G100G_GATE_RXCLK V_MAC40G100G_GATE_RXCLK(1U)
-
-#define S_MAC40G100G_GATE_FF_TX_CLK 13
-#define V_MAC40G100G_GATE_FF_TX_CLK(x) ((x) << S_MAC40G100G_GATE_FF_TX_CLK)
-#define F_MAC40G100G_GATE_FF_TX_CLK V_MAC40G100G_GATE_FF_TX_CLK(1U)
-
-#define S_MAC40G100G_GATE_FF_RX_CLK 12
-#define V_MAC40G100G_GATE_FF_RX_CLK(x) ((x) << S_MAC40G100G_GATE_FF_RX_CLK)
-#define F_MAC40G100G_GATE_FF_RX_CLK V_MAC40G100G_GATE_FF_RX_CLK(1U)
-
-#define S_MAC40G100G_TS_CLK 11
-#define V_MAC40G100G_TS_CLK(x) ((x) << S_MAC40G100G_TS_CLK)
-#define F_MAC40G100G_TS_CLK V_MAC40G100G_TS_CLK(1U)
-
-#define S_MAC1G10G_GATE_RXCLK 10
-#define V_MAC1G10G_GATE_RXCLK(x) ((x) << S_MAC1G10G_GATE_RXCLK)
-#define F_MAC1G10G_GATE_RXCLK V_MAC1G10G_GATE_RXCLK(1U)
-
-#define S_MAC1G10G_GATE_TXCLK 9
-#define V_MAC1G10G_GATE_TXCLK(x) ((x) << S_MAC1G10G_GATE_TXCLK)
-#define F_MAC1G10G_GATE_TXCLK V_MAC1G10G_GATE_TXCLK(1U)
-
-#define S_MAC1G10G_GATE_FF_RX_CLK 8
-#define V_MAC1G10G_GATE_FF_RX_CLK(x) ((x) << S_MAC1G10G_GATE_FF_RX_CLK)
-#define F_MAC1G10G_GATE_FF_RX_CLK V_MAC1G10G_GATE_FF_RX_CLK(1U)
-
-#define S_MAC1G10G_GATE_FF_TX_CLK 7
-#define V_MAC1G10G_GATE_FF_TX_CLK(x) ((x) << S_MAC1G10G_GATE_FF_TX_CLK)
-#define F_MAC1G10G_GATE_FF_TX_CLK V_MAC1G10G_GATE_FF_TX_CLK(1U)
-
-#define S_AEC_RX 6
-#define V_AEC_RX(x) ((x) << S_AEC_RX)
-#define F_AEC_RX V_AEC_RX(1U)
-
-#define S_AEC_TX 5
-#define V_AEC_TX(x) ((x) << S_AEC_TX)
-#define F_AEC_TX V_AEC_TX(1U)
-
-#define S_PCS100G_CLK_ENABLE 4
-#define V_PCS100G_CLK_ENABLE(x) ((x) << S_PCS100G_CLK_ENABLE)
-#define F_PCS100G_CLK_ENABLE V_PCS100G_CLK_ENABLE(1U)
-
-#define S_PCS40G_CLK_ENABLE 3
-#define V_PCS40G_CLK_ENABLE(x) ((x) << S_PCS40G_CLK_ENABLE)
-#define F_PCS40G_CLK_ENABLE V_PCS40G_CLK_ENABLE(1U)
-
-#define S_PCS10G_CLK_ENABLE 2
-#define V_PCS10G_CLK_ENABLE(x) ((x) << S_PCS10G_CLK_ENABLE)
-#define F_PCS10G_CLK_ENABLE V_PCS10G_CLK_ENABLE(1U)
-
-#define S_PCS1G_CLK_ENABLE 1
-#define V_PCS1G_CLK_ENABLE(x) ((x) << S_PCS1G_CLK_ENABLE)
-#define F_PCS1G_CLK_ENABLE V_PCS1G_CLK_ENABLE(1U)
-
-#define S_AN_CLK_ENABLE 0
-#define V_AN_CLK_ENABLE(x) ((x) << S_AN_CLK_ENABLE)
-#define F_AN_CLK_ENABLE V_AN_CLK_ENABLE(1U)
-
-#define A_MAC_PORT_LINK_STATUS 0x834
-
-#define S_AN_DONE 6
-#define V_AN_DONE(x) ((x) << S_AN_DONE)
-#define F_AN_DONE V_AN_DONE(1U)
-
-#define S_ALIGN_DONE 5
-#define V_ALIGN_DONE(x) ((x) << S_ALIGN_DONE)
-#define F_ALIGN_DONE V_ALIGN_DONE(1U)
-
-#define S_BLOCK_LOCK 4
-#define V_BLOCK_LOCK(x) ((x) << S_BLOCK_LOCK)
-#define F_BLOCK_LOCK V_BLOCK_LOCK(1U)
-
-#define S_HI_BER_ST 7
-#define V_HI_BER_ST(x) ((x) << S_HI_BER_ST)
-#define F_HI_BER_ST V_HI_BER_ST(1U)
-
-#define S_AN_DONE_ST 6
-#define V_AN_DONE_ST(x) ((x) << S_AN_DONE_ST)
-#define F_AN_DONE_ST V_AN_DONE_ST(1U)
-
-#define A_MAC_PORT_AEC_ADD_CTL_STAT_0 0x838
-
-#define S_AEC_SYS_LANE_TYPE_3 11
-#define V_AEC_SYS_LANE_TYPE_3(x) ((x) << S_AEC_SYS_LANE_TYPE_3)
-#define F_AEC_SYS_LANE_TYPE_3 V_AEC_SYS_LANE_TYPE_3(1U)
-
-#define S_AEC_SYS_LANE_TYPE_2 10
-#define V_AEC_SYS_LANE_TYPE_2(x) ((x) << S_AEC_SYS_LANE_TYPE_2)
-#define F_AEC_SYS_LANE_TYPE_2 V_AEC_SYS_LANE_TYPE_2(1U)
-
-#define S_AEC_SYS_LANE_TYPE_1 9
-#define V_AEC_SYS_LANE_TYPE_1(x) ((x) << S_AEC_SYS_LANE_TYPE_1)
-#define F_AEC_SYS_LANE_TYPE_1 V_AEC_SYS_LANE_TYPE_1(1U)
-
-#define S_AEC_SYS_LANE_TYPE_0 8
-#define V_AEC_SYS_LANE_TYPE_0(x) ((x) << S_AEC_SYS_LANE_TYPE_0)
-#define F_AEC_SYS_LANE_TYPE_0 V_AEC_SYS_LANE_TYPE_0(1U)
-
-#define S_AEC_SYS_LANE_SELECT_3 6
-#define M_AEC_SYS_LANE_SELECT_3 0x3U
-#define V_AEC_SYS_LANE_SELECT_3(x) ((x) << S_AEC_SYS_LANE_SELECT_3)
-#define G_AEC_SYS_LANE_SELECT_3(x) (((x) >> S_AEC_SYS_LANE_SELECT_3) & M_AEC_SYS_LANE_SELECT_3)
-
-#define S_AEC_SYS_LANE_SELECT_2 4
-#define M_AEC_SYS_LANE_SELECT_2 0x3U
-#define V_AEC_SYS_LANE_SELECT_2(x) ((x) << S_AEC_SYS_LANE_SELECT_2)
-#define G_AEC_SYS_LANE_SELECT_2(x) (((x) >> S_AEC_SYS_LANE_SELECT_2) & M_AEC_SYS_LANE_SELECT_2)
-
-#define S_AEC_SYS_LANE_SELECT_1 2
-#define M_AEC_SYS_LANE_SELECT_1 0x3U
-#define V_AEC_SYS_LANE_SELECT_1(x) ((x) << S_AEC_SYS_LANE_SELECT_1)
-#define G_AEC_SYS_LANE_SELECT_1(x) (((x) >> S_AEC_SYS_LANE_SELECT_1) & M_AEC_SYS_LANE_SELECT_1)
-
-#define S_AEC_SYS_LANE_SELECT_O 0
-#define M_AEC_SYS_LANE_SELECT_O 0x3U
-#define V_AEC_SYS_LANE_SELECT_O(x) ((x) << S_AEC_SYS_LANE_SELECT_O)
-#define G_AEC_SYS_LANE_SELECT_O(x) (((x) >> S_AEC_SYS_LANE_SELECT_O) & M_AEC_SYS_LANE_SELECT_O)
-
-#define A_MAC_PORT_AEC_ADD_CTL_STAT_1 0x83c
-
-#define S_AEC_RX_UNKNOWN_LANE_3 11
-#define V_AEC_RX_UNKNOWN_LANE_3(x) ((x) << S_AEC_RX_UNKNOWN_LANE_3)
-#define F_AEC_RX_UNKNOWN_LANE_3 V_AEC_RX_UNKNOWN_LANE_3(1U)
-
-#define S_AEC_RX_UNKNOWN_LANE_2 10
-#define V_AEC_RX_UNKNOWN_LANE_2(x) ((x) << S_AEC_RX_UNKNOWN_LANE_2)
-#define F_AEC_RX_UNKNOWN_LANE_2 V_AEC_RX_UNKNOWN_LANE_2(1U)
-
-#define S_AEC_RX_UNKNOWN_LANE_1 9
-#define V_AEC_RX_UNKNOWN_LANE_1(x) ((x) << S_AEC_RX_UNKNOWN_LANE_1)
-#define F_AEC_RX_UNKNOWN_LANE_1 V_AEC_RX_UNKNOWN_LANE_1(1U)
-
-#define S_AEC_RX_UNKNOWN_LANE_0 8
-#define V_AEC_RX_UNKNOWN_LANE_0(x) ((x) << S_AEC_RX_UNKNOWN_LANE_0)
-#define F_AEC_RX_UNKNOWN_LANE_0 V_AEC_RX_UNKNOWN_LANE_0(1U)
-
-#define S_AEC_RX_LANE_ID_3 6
-#define M_AEC_RX_LANE_ID_3 0x3U
-#define V_AEC_RX_LANE_ID_3(x) ((x) << S_AEC_RX_LANE_ID_3)
-#define G_AEC_RX_LANE_ID_3(x) (((x) >> S_AEC_RX_LANE_ID_3) & M_AEC_RX_LANE_ID_3)
-
-#define S_AEC_RX_LANE_ID_2 4
-#define M_AEC_RX_LANE_ID_2 0x3U
-#define V_AEC_RX_LANE_ID_2(x) ((x) << S_AEC_RX_LANE_ID_2)
-#define G_AEC_RX_LANE_ID_2(x) (((x) >> S_AEC_RX_LANE_ID_2) & M_AEC_RX_LANE_ID_2)
-
-#define S_AEC_RX_LANE_ID_1 2
-#define M_AEC_RX_LANE_ID_1 0x3U
-#define V_AEC_RX_LANE_ID_1(x) ((x) << S_AEC_RX_LANE_ID_1)
-#define G_AEC_RX_LANE_ID_1(x) (((x) >> S_AEC_RX_LANE_ID_1) & M_AEC_RX_LANE_ID_1)
-
-#define S_AEC_RX_LANE_ID_O 0
-#define M_AEC_RX_LANE_ID_O 0x3U
-#define V_AEC_RX_LANE_ID_O(x) ((x) << S_AEC_RX_LANE_ID_O)
-#define G_AEC_RX_LANE_ID_O(x) (((x) >> S_AEC_RX_LANE_ID_O) & M_AEC_RX_LANE_ID_O)
-
-#define A_MAC_PORT_AEC_XGMII_TIMER_LO_40G 0x840
-
-#define S_XGMII_CLK_IN_1MS_LO_40G 0
-#define M_XGMII_CLK_IN_1MS_LO_40G 0xffffU
-#define V_XGMII_CLK_IN_1MS_LO_40G(x) ((x) << S_XGMII_CLK_IN_1MS_LO_40G)
-#define G_XGMII_CLK_IN_1MS_LO_40G(x) (((x) >> S_XGMII_CLK_IN_1MS_LO_40G) & M_XGMII_CLK_IN_1MS_LO_40G)
-
-#define A_MAC_PORT_AEC_XGMII_TIMER_HI_40G 0x844
-
-#define S_XGMII_CLK_IN_1MS_HI_40G 0
-#define M_XGMII_CLK_IN_1MS_HI_40G 0xfU
-#define V_XGMII_CLK_IN_1MS_HI_40G(x) ((x) << S_XGMII_CLK_IN_1MS_HI_40G)
-#define G_XGMII_CLK_IN_1MS_HI_40G(x) (((x) >> S_XGMII_CLK_IN_1MS_HI_40G) & M_XGMII_CLK_IN_1MS_HI_40G)
-
-#define A_MAC_PORT_AEC_XGMII_TIMER_LO_100G 0x848
-
-#define S_XGMII_CLK_IN_1MS_LO_100G 0
-#define M_XGMII_CLK_IN_1MS_LO_100G 0xffffU
-#define V_XGMII_CLK_IN_1MS_LO_100G(x) ((x) << S_XGMII_CLK_IN_1MS_LO_100G)
-#define G_XGMII_CLK_IN_1MS_LO_100G(x) (((x) >> S_XGMII_CLK_IN_1MS_LO_100G) & M_XGMII_CLK_IN_1MS_LO_100G)
-
-#define A_MAC_PORT_AEC_XGMII_TIMER_HI_100G 0x84c
-
-#define S_XGMII_CLK_IN_1MS_HI_100G 0
-#define M_XGMII_CLK_IN_1MS_HI_100G 0xfU
-#define V_XGMII_CLK_IN_1MS_HI_100G(x) ((x) << S_XGMII_CLK_IN_1MS_HI_100G)
-#define G_XGMII_CLK_IN_1MS_HI_100G(x) (((x) >> S_XGMII_CLK_IN_1MS_HI_100G) & M_XGMII_CLK_IN_1MS_HI_100G)
-
-#define A_MAC_PORT_AEC_DEBUG_LO_0 0x850
-
-#define S_CTL_FSM_CUR_STATE 28
-#define M_CTL_FSM_CUR_STATE 0x7U
-#define V_CTL_FSM_CUR_STATE(x) ((x) << S_CTL_FSM_CUR_STATE)
-#define G_CTL_FSM_CUR_STATE(x) (((x) >> S_CTL_FSM_CUR_STATE) & M_CTL_FSM_CUR_STATE)
-
-#define S_CIN_FSM_CUR_STATE 26
-#define M_CIN_FSM_CUR_STATE 0x3U
-#define V_CIN_FSM_CUR_STATE(x) ((x) << S_CIN_FSM_CUR_STATE)
-#define G_CIN_FSM_CUR_STATE(x) (((x) >> S_CIN_FSM_CUR_STATE) & M_CIN_FSM_CUR_STATE)
-
-#define S_CRI_FSM_CUR_STATE 23
-#define M_CRI_FSM_CUR_STATE 0x7U
-#define V_CRI_FSM_CUR_STATE(x) ((x) << S_CRI_FSM_CUR_STATE)
-#define G_CRI_FSM_CUR_STATE(x) (((x) >> S_CRI_FSM_CUR_STATE) & M_CRI_FSM_CUR_STATE)
-
-#define S_CU_C3_ACK_VALUE 21
-#define M_CU_C3_ACK_VALUE 0x3U
-#define V_CU_C3_ACK_VALUE(x) ((x) << S_CU_C3_ACK_VALUE)
-#define G_CU_C3_ACK_VALUE(x) (((x) >> S_CU_C3_ACK_VALUE) & M_CU_C3_ACK_VALUE)
-
-#define S_CU_C2_ACK_VALUE 19
-#define M_CU_C2_ACK_VALUE 0x3U
-#define V_CU_C2_ACK_VALUE(x) ((x) << S_CU_C2_ACK_VALUE)
-#define G_CU_C2_ACK_VALUE(x) (((x) >> S_CU_C2_ACK_VALUE) & M_CU_C2_ACK_VALUE)
-
-#define S_CU_C1_ACK_VALUE 17
-#define M_CU_C1_ACK_VALUE 0x3U
-#define V_CU_C1_ACK_VALUE(x) ((x) << S_CU_C1_ACK_VALUE)
-#define G_CU_C1_ACK_VALUE(x) (((x) >> S_CU_C1_ACK_VALUE) & M_CU_C1_ACK_VALUE)
-
-#define S_CU_C0_ACK_VALUE 15
-#define M_CU_C0_ACK_VALUE 0x3U
-#define V_CU_C0_ACK_VALUE(x) ((x) << S_CU_C0_ACK_VALUE)
-#define G_CU_C0_ACK_VALUE(x) (((x) >> S_CU_C0_ACK_VALUE) & M_CU_C0_ACK_VALUE)
-
-#define S_CX_INIT 13
-#define V_CX_INIT(x) ((x) << S_CX_INIT)
-#define F_CX_INIT V_CX_INIT(1U)
-
-#define S_CX_PRESET 12
-#define V_CX_PRESET(x) ((x) << S_CX_PRESET)
-#define F_CX_PRESET V_CX_PRESET(1U)
-
-#define S_CUF_C3_UPDATE 9
-#define M_CUF_C3_UPDATE 0x3U
-#define V_CUF_C3_UPDATE(x) ((x) << S_CUF_C3_UPDATE)
-#define G_CUF_C3_UPDATE(x) (((x) >> S_CUF_C3_UPDATE) & M_CUF_C3_UPDATE)
-
-#define S_CUF_C2_UPDATE 7
-#define M_CUF_C2_UPDATE 0x3U
-#define V_CUF_C2_UPDATE(x) ((x) << S_CUF_C2_UPDATE)
-#define G_CUF_C2_UPDATE(x) (((x) >> S_CUF_C2_UPDATE) & M_CUF_C2_UPDATE)
-
-#define S_CUF_C1_UPDATE 5
-#define M_CUF_C1_UPDATE 0x3U
-#define V_CUF_C1_UPDATE(x) ((x) << S_CUF_C1_UPDATE)
-#define G_CUF_C1_UPDATE(x) (((x) >> S_CUF_C1_UPDATE) & M_CUF_C1_UPDATE)
-
-#define S_CUF_C0_UPDATE 3
-#define M_CUF_C0_UPDATE 0x3U
-#define V_CUF_C0_UPDATE(x) ((x) << S_CUF_C0_UPDATE)
-#define G_CUF_C0_UPDATE(x) (((x) >> S_CUF_C0_UPDATE) & M_CUF_C0_UPDATE)
-
-#define S_REG_FPH_ATTR_TXUPDAT_VALID 2
-#define V_REG_FPH_ATTR_TXUPDAT_VALID(x) ((x) << S_REG_FPH_ATTR_TXUPDAT_VALID)
-#define F_REG_FPH_ATTR_TXUPDAT_VALID V_REG_FPH_ATTR_TXUPDAT_VALID(1U)
-
-#define S_REG_FPH_ATTR_TXSTAT_VALID 1
-#define V_REG_FPH_ATTR_TXSTAT_VALID(x) ((x) << S_REG_FPH_ATTR_TXSTAT_VALID)
-#define F_REG_FPH_ATTR_TXSTAT_VALID V_REG_FPH_ATTR_TXSTAT_VALID(1U)
-
-#define S_REG_MAN_DEC_REQ 0
-#define V_REG_MAN_DEC_REQ(x) ((x) << S_REG_MAN_DEC_REQ)
-#define F_REG_MAN_DEC_REQ V_REG_MAN_DEC_REQ(1U)
-
-#define A_MAC_PORT_AEC_DEBUG_HI_0 0x854
-
-#define S_FC_LSNA_ 12
-#define V_FC_LSNA_(x) ((x) << S_FC_LSNA_)
-#define F_FC_LSNA_ V_FC_LSNA_(1U)
-
-#define S_CUF_C0_FSM_DEBUG 9
-#define M_CUF_C0_FSM_DEBUG 0x7U
-#define V_CUF_C0_FSM_DEBUG(x) ((x) << S_CUF_C0_FSM_DEBUG)
-#define G_CUF_C0_FSM_DEBUG(x) (((x) >> S_CUF_C0_FSM_DEBUG) & M_CUF_C0_FSM_DEBUG)
-
-#define S_CUF_C1_FSM_DEBUG 6
-#define M_CUF_C1_FSM_DEBUG 0x7U
-#define V_CUF_C1_FSM_DEBUG(x) ((x) << S_CUF_C1_FSM_DEBUG)
-#define G_CUF_C1_FSM_DEBUG(x) (((x) >> S_CUF_C1_FSM_DEBUG) & M_CUF_C1_FSM_DEBUG)
-
-#define S_CUF_C2_FSM_DEBUG 3
-#define M_CUF_C2_FSM_DEBUG 0x7U
-#define V_CUF_C2_FSM_DEBUG(x) ((x) << S_CUF_C2_FSM_DEBUG)
-#define G_CUF_C2_FSM_DEBUG(x) (((x) >> S_CUF_C2_FSM_DEBUG) & M_CUF_C2_FSM_DEBUG)
-
-#define S_LCK_FSM_CUR_STATE 0
-#define M_LCK_FSM_CUR_STATE 0x7U
-#define V_LCK_FSM_CUR_STATE(x) ((x) << S_LCK_FSM_CUR_STATE)
-#define G_LCK_FSM_CUR_STATE(x) (((x) >> S_LCK_FSM_CUR_STATE) & M_LCK_FSM_CUR_STATE)
-
-#define A_MAC_PORT_AEC_DEBUG_LO_1 0x858
-#define A_MAC_PORT_AEC_DEBUG_HI_1 0x85c
-#define A_MAC_PORT_AEC_DEBUG_LO_2 0x860
-#define A_MAC_PORT_AEC_DEBUG_HI_2 0x864
-#define A_MAC_PORT_AEC_DEBUG_LO_3 0x868
-#define A_MAC_PORT_AEC_DEBUG_HI_3 0x86c
-#define A_MAC_PORT_MAC_DEBUG_RO 0x870
-
-#define S_MAC40G100G_TX_UNDERFLOW 13
-#define V_MAC40G100G_TX_UNDERFLOW(x) ((x) << S_MAC40G100G_TX_UNDERFLOW)
-#define F_MAC40G100G_TX_UNDERFLOW V_MAC40G100G_TX_UNDERFLOW(1U)
-
-#define S_MAC1G10G_MAGIC_IND 12
-#define V_MAC1G10G_MAGIC_IND(x) ((x) << S_MAC1G10G_MAGIC_IND)
-#define F_MAC1G10G_MAGIC_IND V_MAC1G10G_MAGIC_IND(1U)
-
-#define S_MAC1G10G_FF_RX_EMPTY 11
-#define V_MAC1G10G_FF_RX_EMPTY(x) ((x) << S_MAC1G10G_FF_RX_EMPTY)
-#define F_MAC1G10G_FF_RX_EMPTY V_MAC1G10G_FF_RX_EMPTY(1U)
-
-#define S_MAC1G10G_FF_TX_OVR_ERR 10
-#define V_MAC1G10G_FF_TX_OVR_ERR(x) ((x) << S_MAC1G10G_FF_TX_OVR_ERR)
-#define F_MAC1G10G_FF_TX_OVR_ERR V_MAC1G10G_FF_TX_OVR_ERR(1U)
-
-#define S_MAC1G10G_IF_MODE_ENA 8
-#define M_MAC1G10G_IF_MODE_ENA 0x3U
-#define V_MAC1G10G_IF_MODE_ENA(x) ((x) << S_MAC1G10G_IF_MODE_ENA)
-#define G_MAC1G10G_IF_MODE_ENA(x) (((x) >> S_MAC1G10G_IF_MODE_ENA) & M_MAC1G10G_IF_MODE_ENA)
-
-#define S_MAC1G10G_MII_ENA_10 7
-#define V_MAC1G10G_MII_ENA_10(x) ((x) << S_MAC1G10G_MII_ENA_10)
-#define F_MAC1G10G_MII_ENA_10 V_MAC1G10G_MII_ENA_10(1U)
-
-#define S_MAC1G10G_PAUSE_ON 6
-#define V_MAC1G10G_PAUSE_ON(x) ((x) << S_MAC1G10G_PAUSE_ON)
-#define F_MAC1G10G_PAUSE_ON V_MAC1G10G_PAUSE_ON(1U)
-
-#define S_MAC1G10G_PFC_MODE 5
-#define V_MAC1G10G_PFC_MODE(x) ((x) << S_MAC1G10G_PFC_MODE)
-#define F_MAC1G10G_PFC_MODE V_MAC1G10G_PFC_MODE(1U)
-
-#define S_MAC1G10G_RX_SFD_O 4
-#define V_MAC1G10G_RX_SFD_O(x) ((x) << S_MAC1G10G_RX_SFD_O)
-#define F_MAC1G10G_RX_SFD_O V_MAC1G10G_RX_SFD_O(1U)
-
-#define S_MAC1G10G_TX_EMPTY 3
-#define V_MAC1G10G_TX_EMPTY(x) ((x) << S_MAC1G10G_TX_EMPTY)
-#define F_MAC1G10G_TX_EMPTY V_MAC1G10G_TX_EMPTY(1U)
-
-#define S_MAC1G10G_TX_SFD_O 2
-#define V_MAC1G10G_TX_SFD_O(x) ((x) << S_MAC1G10G_TX_SFD_O)
-#define F_MAC1G10G_TX_SFD_O V_MAC1G10G_TX_SFD_O(1U)
-
-#define S_MAC1G10G_TX_TS_FRM_OUT 1
-#define V_MAC1G10G_TX_TS_FRM_OUT(x) ((x) << S_MAC1G10G_TX_TS_FRM_OUT)
-#define F_MAC1G10G_TX_TS_FRM_OUT V_MAC1G10G_TX_TS_FRM_OUT(1U)
-
-#define S_MAC1G10G_TX_UNDERFLOW 0
-#define V_MAC1G10G_TX_UNDERFLOW(x) ((x) << S_MAC1G10G_TX_UNDERFLOW)
-#define F_MAC1G10G_TX_UNDERFLOW V_MAC1G10G_TX_UNDERFLOW(1U)
-
-#define A_MAC_PORT_MAC_CTRL_RW 0x874
-
-#define S_MAC40G100G_FF_TX_PFC_XOFF 17
-#define M_MAC40G100G_FF_TX_PFC_XOFF 0xffU
-#define V_MAC40G100G_FF_TX_PFC_XOFF(x) ((x) << S_MAC40G100G_FF_TX_PFC_XOFF)
-#define G_MAC40G100G_FF_TX_PFC_XOFF(x) (((x) >> S_MAC40G100G_FF_TX_PFC_XOFF) & M_MAC40G100G_FF_TX_PFC_XOFF)
-
-#define S_MAC40G100G_TX_LOC_FAULT 16
-#define V_MAC40G100G_TX_LOC_FAULT(x) ((x) << S_MAC40G100G_TX_LOC_FAULT)
-#define F_MAC40G100G_TX_LOC_FAULT V_MAC40G100G_TX_LOC_FAULT(1U)
-
-#define S_MAC40G100G_TX_REM_FAULT 15
-#define V_MAC40G100G_TX_REM_FAULT(x) ((x) << S_MAC40G100G_TX_REM_FAULT)
-#define F_MAC40G100G_TX_REM_FAULT V_MAC40G100G_TX_REM_FAULT(1U)
-
-#define S_MAC40G_LOOP_BCK 14
-#define V_MAC40G_LOOP_BCK(x) ((x) << S_MAC40G_LOOP_BCK)
-#define F_MAC40G_LOOP_BCK V_MAC40G_LOOP_BCK(1U)
-
-#define S_MAC1G10G_MAGIC_ENA 13
-#define V_MAC1G10G_MAGIC_ENA(x) ((x) << S_MAC1G10G_MAGIC_ENA)
-#define F_MAC1G10G_MAGIC_ENA V_MAC1G10G_MAGIC_ENA(1U)
-
-#define S_MAC1G10G_IF_MODE_SET 11
-#define M_MAC1G10G_IF_MODE_SET 0x3U
-#define V_MAC1G10G_IF_MODE_SET(x) ((x) << S_MAC1G10G_IF_MODE_SET)
-#define G_MAC1G10G_IF_MODE_SET(x) (((x) >> S_MAC1G10G_IF_MODE_SET) & M_MAC1G10G_IF_MODE_SET)
-
-#define S_MAC1G10G_TX_LOC_FAULT 10
-#define V_MAC1G10G_TX_LOC_FAULT(x) ((x) << S_MAC1G10G_TX_LOC_FAULT)
-#define F_MAC1G10G_TX_LOC_FAULT V_MAC1G10G_TX_LOC_FAULT(1U)
-
-#define S_MAC1G10G_TX_REM_FAULT 9
-#define V_MAC1G10G_TX_REM_FAULT(x) ((x) << S_MAC1G10G_TX_REM_FAULT)
-#define F_MAC1G10G_TX_REM_FAULT V_MAC1G10G_TX_REM_FAULT(1U)
-
-#define S_MAC1G10G_XOFF_GEN 1
-#define M_MAC1G10G_XOFF_GEN 0xffU
-#define V_MAC1G10G_XOFF_GEN(x) ((x) << S_MAC1G10G_XOFF_GEN)
-#define G_MAC1G10G_XOFF_GEN(x) (((x) >> S_MAC1G10G_XOFF_GEN) & M_MAC1G10G_XOFF_GEN)
-
-#define S_MAC1G_LOOP_BCK 0
-#define V_MAC1G_LOOP_BCK(x) ((x) << S_MAC1G_LOOP_BCK)
-#define F_MAC1G_LOOP_BCK V_MAC1G_LOOP_BCK(1U)
-
-#define A_MAC_PORT_PCS_DEBUG0_RO 0x878
-
-#define S_FPGA_LOCK 26
-#define M_FPGA_LOCK 0xfU
-#define V_FPGA_LOCK(x) ((x) << S_FPGA_LOCK)
-#define G_FPGA_LOCK(x) (((x) >> S_FPGA_LOCK) & M_FPGA_LOCK)
-
-#define S_T6_AN_DONE 25
-#define V_T6_AN_DONE(x) ((x) << S_T6_AN_DONE)
-#define F_T6_AN_DONE V_T6_AN_DONE(1U)
-
-#define S_AN_INT 24
-#define V_AN_INT(x) ((x) << S_AN_INT)
-#define F_AN_INT V_AN_INT(1U)
-
-#define S_AN_PCS_RX_CLK_ENA 23
-#define V_AN_PCS_RX_CLK_ENA(x) ((x) << S_AN_PCS_RX_CLK_ENA)
-#define F_AN_PCS_RX_CLK_ENA V_AN_PCS_RX_CLK_ENA(1U)
-
-#define S_AN_PCS_TX_CLK_ENA 22
-#define V_AN_PCS_TX_CLK_ENA(x) ((x) << S_AN_PCS_TX_CLK_ENA)
-#define F_AN_PCS_TX_CLK_ENA V_AN_PCS_TX_CLK_ENA(1U)
-
-#define S_AN_SELECT 17
-#define M_AN_SELECT 0x1fU
-#define V_AN_SELECT(x) ((x) << S_AN_SELECT)
-#define G_AN_SELECT(x) (((x) >> S_AN_SELECT) & M_AN_SELECT)
-
-#define S_AN_PROG 16
-#define V_AN_PROG(x) ((x) << S_AN_PROG)
-#define F_AN_PROG V_AN_PROG(1U)
-
-#define S_PCS40G_BLOCK_LOCK 12
-#define M_PCS40G_BLOCK_LOCK 0xfU
-#define V_PCS40G_BLOCK_LOCK(x) ((x) << S_PCS40G_BLOCK_LOCK)
-#define G_PCS40G_BLOCK_LOCK(x) (((x) >> S_PCS40G_BLOCK_LOCK) & M_PCS40G_BLOCK_LOCK)
-
-#define S_PCS40G_BER_TIMER_DONE 11
-#define V_PCS40G_BER_TIMER_DONE(x) ((x) << S_PCS40G_BER_TIMER_DONE)
-#define F_PCS40G_BER_TIMER_DONE V_PCS40G_BER_TIMER_DONE(1U)
-
-#define S_PCS10G_FEC_LOCKED 10
-#define V_PCS10G_FEC_LOCKED(x) ((x) << S_PCS10G_FEC_LOCKED)
-#define F_PCS10G_FEC_LOCKED V_PCS10G_FEC_LOCKED(1U)
-
-#define S_PCS10G_BLOCK_LOCK 9
-#define V_PCS10G_BLOCK_LOCK(x) ((x) << S_PCS10G_BLOCK_LOCK)
-#define F_PCS10G_BLOCK_LOCK V_PCS10G_BLOCK_LOCK(1U)
-
-#define S_SGMII_GMII_COL 8
-#define V_SGMII_GMII_COL(x) ((x) << S_SGMII_GMII_COL)
-#define F_SGMII_GMII_COL V_SGMII_GMII_COL(1U)
-
-#define S_SGMII_GMII_CRS 7
-#define V_SGMII_GMII_CRS(x) ((x) << S_SGMII_GMII_CRS)
-#define F_SGMII_GMII_CRS V_SGMII_GMII_CRS(1U)
-
-#define S_SGMII_SD_LOOPBACK 6
-#define V_SGMII_SD_LOOPBACK(x) ((x) << S_SGMII_SD_LOOPBACK)
-#define F_SGMII_SD_LOOPBACK V_SGMII_SD_LOOPBACK(1U)
-
-#define S_SGMII_SG_AN_DONE 5
-#define V_SGMII_SG_AN_DONE(x) ((x) << S_SGMII_SG_AN_DONE)
-#define F_SGMII_SG_AN_DONE V_SGMII_SG_AN_DONE(1U)
-
-#define S_SGMII_SG_HD 4
-#define V_SGMII_SG_HD(x) ((x) << S_SGMII_SG_HD)
-#define F_SGMII_SG_HD V_SGMII_SG_HD(1U)
-
-#define S_SGMII_SG_PAGE_RX 3
-#define V_SGMII_SG_PAGE_RX(x) ((x) << S_SGMII_SG_PAGE_RX)
-#define F_SGMII_SG_PAGE_RX V_SGMII_SG_PAGE_RX(1U)
-
-#define S_SGMII_SG_RX_SYNC 2
-#define V_SGMII_SG_RX_SYNC(x) ((x) << S_SGMII_SG_RX_SYNC)
-#define F_SGMII_SG_RX_SYNC V_SGMII_SG_RX_SYNC(1U)
-
-#define S_SGMII_SG_SPEED 0
-#define M_SGMII_SG_SPEED 0x3U
-#define V_SGMII_SG_SPEED(x) ((x) << S_SGMII_SG_SPEED)
-#define G_SGMII_SG_SPEED(x) (((x) >> S_SGMII_SG_SPEED) & M_SGMII_SG_SPEED)
-
-#define A_MAC_PORT_PCS_CTRL_RW 0x87c
-
-#define S_TX_LI_FAULT 31
-#define V_TX_LI_FAULT(x) ((x) << S_TX_LI_FAULT)
-#define F_TX_LI_FAULT V_TX_LI_FAULT(1U)
-
-#define S_T6_PAD 30
-#define V_T6_PAD(x) ((x) << S_T6_PAD)
-#define F_T6_PAD V_T6_PAD(1U)
-
-#define S_BLK_STB_VAL 22
-#define M_BLK_STB_VAL 0xffU
-#define V_BLK_STB_VAL(x) ((x) << S_BLK_STB_VAL)
-#define G_BLK_STB_VAL(x) (((x) >> S_BLK_STB_VAL) & M_BLK_STB_VAL)
-
-#define S_DEBUG_SEL 18
-#define M_DEBUG_SEL 0xfU
-#define V_DEBUG_SEL(x) ((x) << S_DEBUG_SEL)
-#define G_DEBUG_SEL(x) (((x) >> S_DEBUG_SEL) & M_DEBUG_SEL)
-
-#define S_SGMII_LOOP 15
-#define M_SGMII_LOOP 0x7U
-#define V_SGMII_LOOP(x) ((x) << S_SGMII_LOOP)
-#define G_SGMII_LOOP(x) (((x) >> S_SGMII_LOOP) & M_SGMII_LOOP)
-
-#define S_AN_DIS_TIMER 14
-#define V_AN_DIS_TIMER(x) ((x) << S_AN_DIS_TIMER)
-#define F_AN_DIS_TIMER V_AN_DIS_TIMER(1U)
-
-#define S_PCS100G_BER_TIMER_SHORT 13
-#define V_PCS100G_BER_TIMER_SHORT(x) ((x) << S_PCS100G_BER_TIMER_SHORT)
-#define F_PCS100G_BER_TIMER_SHORT V_PCS100G_BER_TIMER_SHORT(1U)
-
-#define S_PCS100G_TX_LANE_THRESH 9
-#define M_PCS100G_TX_LANE_THRESH 0xfU
-#define V_PCS100G_TX_LANE_THRESH(x) ((x) << S_PCS100G_TX_LANE_THRESH)
-#define G_PCS100G_TX_LANE_THRESH(x) (((x) >> S_PCS100G_TX_LANE_THRESH) & M_PCS100G_TX_LANE_THRESH)
-
-#define S_PCS100G_VL_INTVL 8
-#define V_PCS100G_VL_INTVL(x) ((x) << S_PCS100G_VL_INTVL)
-#define F_PCS100G_VL_INTVL V_PCS100G_VL_INTVL(1U)
-
-#define S_SGMII_TX_LANE_CKMULT 4
-#define M_SGMII_TX_LANE_CKMULT 0x7U
-#define V_SGMII_TX_LANE_CKMULT(x) ((x) << S_SGMII_TX_LANE_CKMULT)
-#define G_SGMII_TX_LANE_CKMULT(x) (((x) >> S_SGMII_TX_LANE_CKMULT) & M_SGMII_TX_LANE_CKMULT)
-
-#define S_SGMII_TX_LANE_THRESH 0
-#define M_SGMII_TX_LANE_THRESH 0xfU
-#define V_SGMII_TX_LANE_THRESH(x) ((x) << S_SGMII_TX_LANE_THRESH)
-#define G_SGMII_TX_LANE_THRESH(x) (((x) >> S_SGMII_TX_LANE_THRESH) & M_SGMII_TX_LANE_THRESH)
-
-#define A_MAC_PORT_PCS_DEBUG1_RO 0x880
-
-#define S_PCS100G_ALIGN_LOCK 21
-#define V_PCS100G_ALIGN_LOCK(x) ((x) << S_PCS100G_ALIGN_LOCK)
-#define F_PCS100G_ALIGN_LOCK V_PCS100G_ALIGN_LOCK(1U)
-
-#define S_PCS100G_BER_TIMER_DONE 20
-#define V_PCS100G_BER_TIMER_DONE(x) ((x) << S_PCS100G_BER_TIMER_DONE)
-#define F_PCS100G_BER_TIMER_DONE V_PCS100G_BER_TIMER_DONE(1U)
-
-#define S_PCS100G_BLOCK_LOCK 0
-#define M_PCS100G_BLOCK_LOCK 0xfffffU
-#define V_PCS100G_BLOCK_LOCK(x) ((x) << S_PCS100G_BLOCK_LOCK)
-#define G_PCS100G_BLOCK_LOCK(x) (((x) >> S_PCS100G_BLOCK_LOCK) & M_PCS100G_BLOCK_LOCK)
-
-#define A_MAC_PORT_PERR_INT_EN_100G 0x884
-
-#define S_PERR_RX_FEC100G_DLY 29
-#define V_PERR_RX_FEC100G_DLY(x) ((x) << S_PERR_RX_FEC100G_DLY)
-#define F_PERR_RX_FEC100G_DLY V_PERR_RX_FEC100G_DLY(1U)
-
-#define S_PERR_RX_FEC100G 28
-#define V_PERR_RX_FEC100G(x) ((x) << S_PERR_RX_FEC100G)
-#define F_PERR_RX_FEC100G V_PERR_RX_FEC100G(1U)
-
-#define S_PERR_RX3_FEC100G_DK 27
-#define V_PERR_RX3_FEC100G_DK(x) ((x) << S_PERR_RX3_FEC100G_DK)
-#define F_PERR_RX3_FEC100G_DK V_PERR_RX3_FEC100G_DK(1U)
-
-#define S_PERR_RX2_FEC100G_DK 26
-#define V_PERR_RX2_FEC100G_DK(x) ((x) << S_PERR_RX2_FEC100G_DK)
-#define F_PERR_RX2_FEC100G_DK V_PERR_RX2_FEC100G_DK(1U)
-
-#define S_PERR_RX1_FEC100G_DK 25
-#define V_PERR_RX1_FEC100G_DK(x) ((x) << S_PERR_RX1_FEC100G_DK)
-#define F_PERR_RX1_FEC100G_DK V_PERR_RX1_FEC100G_DK(1U)
-
-#define S_PERR_RX0_FEC100G_DK 24
-#define V_PERR_RX0_FEC100G_DK(x) ((x) << S_PERR_RX0_FEC100G_DK)
-#define F_PERR_RX0_FEC100G_DK V_PERR_RX0_FEC100G_DK(1U)
-
-#define S_PERR_TX3_PCS100G 23
-#define V_PERR_TX3_PCS100G(x) ((x) << S_PERR_TX3_PCS100G)
-#define F_PERR_TX3_PCS100G V_PERR_TX3_PCS100G(1U)
-
-#define S_PERR_TX2_PCS100G 22
-#define V_PERR_TX2_PCS100G(x) ((x) << S_PERR_TX2_PCS100G)
-#define F_PERR_TX2_PCS100G V_PERR_TX2_PCS100G(1U)
-
-#define S_PERR_TX1_PCS100G 21
-#define V_PERR_TX1_PCS100G(x) ((x) << S_PERR_TX1_PCS100G)
-#define F_PERR_TX1_PCS100G V_PERR_TX1_PCS100G(1U)
-
-#define S_PERR_TX0_PCS100G 20
-#define V_PERR_TX0_PCS100G(x) ((x) << S_PERR_TX0_PCS100G)
-#define F_PERR_TX0_PCS100G V_PERR_TX0_PCS100G(1U)
-
-#define S_PERR_RX19_PCS100G 19
-#define V_PERR_RX19_PCS100G(x) ((x) << S_PERR_RX19_PCS100G)
-#define F_PERR_RX19_PCS100G V_PERR_RX19_PCS100G(1U)
-
-#define S_PERR_RX18_PCS100G 18
-#define V_PERR_RX18_PCS100G(x) ((x) << S_PERR_RX18_PCS100G)
-#define F_PERR_RX18_PCS100G V_PERR_RX18_PCS100G(1U)
-
-#define S_PERR_RX17_PCS100G 17
-#define V_PERR_RX17_PCS100G(x) ((x) << S_PERR_RX17_PCS100G)
-#define F_PERR_RX17_PCS100G V_PERR_RX17_PCS100G(1U)
-
-#define S_PERR_RX16_PCS100G 16
-#define V_PERR_RX16_PCS100G(x) ((x) << S_PERR_RX16_PCS100G)
-#define F_PERR_RX16_PCS100G V_PERR_RX16_PCS100G(1U)
-
-#define S_PERR_RX15_PCS100G 15
-#define V_PERR_RX15_PCS100G(x) ((x) << S_PERR_RX15_PCS100G)
-#define F_PERR_RX15_PCS100G V_PERR_RX15_PCS100G(1U)
-
-#define S_PERR_RX14_PCS100G 14
-#define V_PERR_RX14_PCS100G(x) ((x) << S_PERR_RX14_PCS100G)
-#define F_PERR_RX14_PCS100G V_PERR_RX14_PCS100G(1U)
-
-#define S_PERR_RX13_PCS100G 13
-#define V_PERR_RX13_PCS100G(x) ((x) << S_PERR_RX13_PCS100G)
-#define F_PERR_RX13_PCS100G V_PERR_RX13_PCS100G(1U)
-
-#define S_PERR_RX12_PCS100G 12
-#define V_PERR_RX12_PCS100G(x) ((x) << S_PERR_RX12_PCS100G)
-#define F_PERR_RX12_PCS100G V_PERR_RX12_PCS100G(1U)
-
-#define S_PERR_RX11_PCS100G 11
-#define V_PERR_RX11_PCS100G(x) ((x) << S_PERR_RX11_PCS100G)
-#define F_PERR_RX11_PCS100G V_PERR_RX11_PCS100G(1U)
-
-#define S_PERR_RX10_PCS100G 10
-#define V_PERR_RX10_PCS100G(x) ((x) << S_PERR_RX10_PCS100G)
-#define F_PERR_RX10_PCS100G V_PERR_RX10_PCS100G(1U)
-
-#define S_PERR_RX9_PCS100G 9
-#define V_PERR_RX9_PCS100G(x) ((x) << S_PERR_RX9_PCS100G)
-#define F_PERR_RX9_PCS100G V_PERR_RX9_PCS100G(1U)
-
-#define S_PERR_RX8_PCS100G 8
-#define V_PERR_RX8_PCS100G(x) ((x) << S_PERR_RX8_PCS100G)
-#define F_PERR_RX8_PCS100G V_PERR_RX8_PCS100G(1U)
-
-#define S_PERR_RX7_PCS100G 7
-#define V_PERR_RX7_PCS100G(x) ((x) << S_PERR_RX7_PCS100G)
-#define F_PERR_RX7_PCS100G V_PERR_RX7_PCS100G(1U)
-
-#define S_PERR_RX6_PCS100G 6
-#define V_PERR_RX6_PCS100G(x) ((x) << S_PERR_RX6_PCS100G)
-#define F_PERR_RX6_PCS100G V_PERR_RX6_PCS100G(1U)
-
-#define S_PERR_RX5_PCS100G 5
-#define V_PERR_RX5_PCS100G(x) ((x) << S_PERR_RX5_PCS100G)
-#define F_PERR_RX5_PCS100G V_PERR_RX5_PCS100G(1U)
-
-#define S_PERR_RX4_PCS100G 4
-#define V_PERR_RX4_PCS100G(x) ((x) << S_PERR_RX4_PCS100G)
-#define F_PERR_RX4_PCS100G V_PERR_RX4_PCS100G(1U)
-
-#define S_PERR_RX3_PCS100G 3
-#define V_PERR_RX3_PCS100G(x) ((x) << S_PERR_RX3_PCS100G)
-#define F_PERR_RX3_PCS100G V_PERR_RX3_PCS100G(1U)
-
-#define S_PERR_RX2_PCS100G 2
-#define V_PERR_RX2_PCS100G(x) ((x) << S_PERR_RX2_PCS100G)
-#define F_PERR_RX2_PCS100G V_PERR_RX2_PCS100G(1U)
-
-#define S_PERR_RX1_PCS100G 1
-#define V_PERR_RX1_PCS100G(x) ((x) << S_PERR_RX1_PCS100G)
-#define F_PERR_RX1_PCS100G V_PERR_RX1_PCS100G(1U)
-
-#define S_PERR_RX0_PCS100G 0
-#define V_PERR_RX0_PCS100G(x) ((x) << S_PERR_RX0_PCS100G)
-#define F_PERR_RX0_PCS100G V_PERR_RX0_PCS100G(1U)
-
-#define A_MAC_PORT_PERR_INT_CAUSE_100G 0x888
-#define A_MAC_PORT_PERR_ENABLE_100G 0x88c
-#define A_MAC_PORT_MAC_STAT_DEBUG 0x890
-#define A_MAC_PORT_MAC_25G_50G_AM0 0x894
-#define A_MAC_PORT_MAC_25G_50G_AM1 0x898
-#define A_MAC_PORT_MAC_25G_50G_AM2 0x89c
-#define A_MAC_PORT_MAC_25G_50G_AM3 0x8a0
-#define A_MAC_PORT_MAC_AN_STATE_STATUS 0x8a4
-#define A_MAC_PORT_EPIO_DATA0 0x8c0
-#define A_MAC_PORT_EPIO_DATA1 0x8c4
-#define A_MAC_PORT_EPIO_DATA2 0x8c8
-#define A_MAC_PORT_EPIO_DATA3 0x8cc
-#define A_MAC_PORT_EPIO_OP 0x8d0
-#define A_MAC_PORT_WOL_STATUS 0x8d4
-#define A_MAC_PORT_INT_EN 0x8d8
-
-#define S_TX_TS_AVAIL 29
-#define V_TX_TS_AVAIL(x) ((x) << S_TX_TS_AVAIL)
-#define F_TX_TS_AVAIL V_TX_TS_AVAIL(1U)
-
-#define S_AN_PAGE_RCVD 2
-#define V_AN_PAGE_RCVD(x) ((x) << S_AN_PAGE_RCVD)
-#define F_AN_PAGE_RCVD V_AN_PAGE_RCVD(1U)
-
-#define S_PPS 30
-#define V_PPS(x) ((x) << S_PPS)
-#define F_PPS V_PPS(1U)
-
-#define S_SINGLE_ALARM 28
-#define V_SINGLE_ALARM(x) ((x) << S_SINGLE_ALARM)
-#define F_SINGLE_ALARM V_SINGLE_ALARM(1U)
-
-#define S_PERIODIC_ALARM 27
-#define V_PERIODIC_ALARM(x) ((x) << S_PERIODIC_ALARM)
-#define F_PERIODIC_ALARM V_PERIODIC_ALARM(1U)
-
-#define A_MAC_PORT_INT_CAUSE 0x8dc
-#define A_MAC_PORT_PERR_INT_EN 0x8e0
-
-#define S_PERR_PKT_RAM 24
-#define V_PERR_PKT_RAM(x) ((x) << S_PERR_PKT_RAM)
-#define F_PERR_PKT_RAM V_PERR_PKT_RAM(1U)
-
-#define S_PERR_MASK_RAM 23
-#define V_PERR_MASK_RAM(x) ((x) << S_PERR_MASK_RAM)
-#define F_PERR_MASK_RAM V_PERR_MASK_RAM(1U)
-
-#define S_PERR_CRC_RAM 22
-#define V_PERR_CRC_RAM(x) ((x) << S_PERR_CRC_RAM)
-#define F_PERR_CRC_RAM V_PERR_CRC_RAM(1U)
-
-#define S_RX_DFF_SEG0 21
-#define V_RX_DFF_SEG0(x) ((x) << S_RX_DFF_SEG0)
-#define F_RX_DFF_SEG0 V_RX_DFF_SEG0(1U)
-
-#define S_RX_SFF_SEG0 20
-#define V_RX_SFF_SEG0(x) ((x) << S_RX_SFF_SEG0)
-#define F_RX_SFF_SEG0 V_RX_SFF_SEG0(1U)
-
-#define S_RX_DFF_MAC10 19
-#define V_RX_DFF_MAC10(x) ((x) << S_RX_DFF_MAC10)
-#define F_RX_DFF_MAC10 V_RX_DFF_MAC10(1U)
-
-#define S_RX_SFF_MAC10 18
-#define V_RX_SFF_MAC10(x) ((x) << S_RX_SFF_MAC10)
-#define F_RX_SFF_MAC10 V_RX_SFF_MAC10(1U)
-
-#define S_TX_DFF_SEG0 17
-#define V_TX_DFF_SEG0(x) ((x) << S_TX_DFF_SEG0)
-#define F_TX_DFF_SEG0 V_TX_DFF_SEG0(1U)
-
-#define S_TX_SFF_SEG0 16
-#define V_TX_SFF_SEG0(x) ((x) << S_TX_SFF_SEG0)
-#define F_TX_SFF_SEG0 V_TX_SFF_SEG0(1U)
-
-#define S_TX_DFF_MAC10 15
-#define V_TX_DFF_MAC10(x) ((x) << S_TX_DFF_MAC10)
-#define F_TX_DFF_MAC10 V_TX_DFF_MAC10(1U)
-
-#define S_TX_SFF_MAC10 14
-#define V_TX_SFF_MAC10(x) ((x) << S_TX_SFF_MAC10)
-#define F_TX_SFF_MAC10 V_TX_SFF_MAC10(1U)
-
-#define S_RX_STATS 13
-#define V_RX_STATS(x) ((x) << S_RX_STATS)
-#define F_RX_STATS V_RX_STATS(1U)
-
-#define S_TX_STATS 12
-#define V_TX_STATS(x) ((x) << S_TX_STATS)
-#define F_TX_STATS V_TX_STATS(1U)
-
-#define S_PERR3_RX_MIX 11
-#define V_PERR3_RX_MIX(x) ((x) << S_PERR3_RX_MIX)
-#define F_PERR3_RX_MIX V_PERR3_RX_MIX(1U)
-
-#define S_PERR3_RX_SD 10
-#define V_PERR3_RX_SD(x) ((x) << S_PERR3_RX_SD)
-#define F_PERR3_RX_SD V_PERR3_RX_SD(1U)
-
-#define S_PERR3_TX 9
-#define V_PERR3_TX(x) ((x) << S_PERR3_TX)
-#define F_PERR3_TX V_PERR3_TX(1U)
-
-#define S_PERR2_RX_MIX 8
-#define V_PERR2_RX_MIX(x) ((x) << S_PERR2_RX_MIX)
-#define F_PERR2_RX_MIX V_PERR2_RX_MIX(1U)
-
-#define S_PERR2_RX_SD 7
-#define V_PERR2_RX_SD(x) ((x) << S_PERR2_RX_SD)
-#define F_PERR2_RX_SD V_PERR2_RX_SD(1U)
-
-#define S_PERR2_TX 6
-#define V_PERR2_TX(x) ((x) << S_PERR2_TX)
-#define F_PERR2_TX V_PERR2_TX(1U)
-
-#define S_PERR1_RX_MIX 5
-#define V_PERR1_RX_MIX(x) ((x) << S_PERR1_RX_MIX)
-#define F_PERR1_RX_MIX V_PERR1_RX_MIX(1U)
-
-#define S_PERR1_RX_SD 4
-#define V_PERR1_RX_SD(x) ((x) << S_PERR1_RX_SD)
-#define F_PERR1_RX_SD V_PERR1_RX_SD(1U)
-
-#define S_PERR1_TX 3
-#define V_PERR1_TX(x) ((x) << S_PERR1_TX)
-#define F_PERR1_TX V_PERR1_TX(1U)
-
-#define S_PERR0_RX_MIX 2
-#define V_PERR0_RX_MIX(x) ((x) << S_PERR0_RX_MIX)
-#define F_PERR0_RX_MIX V_PERR0_RX_MIX(1U)
-
-#define S_PERR0_RX_SD 1
-#define V_PERR0_RX_SD(x) ((x) << S_PERR0_RX_SD)
-#define F_PERR0_RX_SD V_PERR0_RX_SD(1U)
-
-#define S_PERR0_TX 0
-#define V_PERR0_TX(x) ((x) << S_PERR0_TX)
-#define F_PERR0_TX V_PERR0_TX(1U)
-
-#define S_T6_PERR_PKT_RAM 31
-#define V_T6_PERR_PKT_RAM(x) ((x) << S_T6_PERR_PKT_RAM)
-#define F_T6_PERR_PKT_RAM V_T6_PERR_PKT_RAM(1U)
-
-#define S_T6_PERR_MASK_RAM 30
-#define V_T6_PERR_MASK_RAM(x) ((x) << S_T6_PERR_MASK_RAM)
-#define F_T6_PERR_MASK_RAM V_T6_PERR_MASK_RAM(1U)
-
-#define S_T6_PERR_CRC_RAM 29
-#define V_T6_PERR_CRC_RAM(x) ((x) << S_T6_PERR_CRC_RAM)
-#define F_T6_PERR_CRC_RAM V_T6_PERR_CRC_RAM(1U)
-
-#define S_RX_MAC40G 28
-#define V_RX_MAC40G(x) ((x) << S_RX_MAC40G)
-#define F_RX_MAC40G V_RX_MAC40G(1U)
-
-#define S_TX_MAC40G 27
-#define V_TX_MAC40G(x) ((x) << S_TX_MAC40G)
-#define F_TX_MAC40G V_TX_MAC40G(1U)
-
-#define S_RX_ST_MAC40G 26
-#define V_RX_ST_MAC40G(x) ((x) << S_RX_ST_MAC40G)
-#define F_RX_ST_MAC40G V_RX_ST_MAC40G(1U)
-
-#define S_TX_ST_MAC40G 25
-#define V_TX_ST_MAC40G(x) ((x) << S_TX_ST_MAC40G)
-#define F_TX_ST_MAC40G V_TX_ST_MAC40G(1U)
-
-#define S_TX_MAC1G10G 24
-#define V_TX_MAC1G10G(x) ((x) << S_TX_MAC1G10G)
-#define F_TX_MAC1G10G V_TX_MAC1G10G(1U)
-
-#define S_RX_MAC1G10G 23
-#define V_RX_MAC1G10G(x) ((x) << S_RX_MAC1G10G)
-#define F_RX_MAC1G10G V_RX_MAC1G10G(1U)
-
-#define S_RX_STATUS_MAC1G10G 22
-#define V_RX_STATUS_MAC1G10G(x) ((x) << S_RX_STATUS_MAC1G10G)
-#define F_RX_STATUS_MAC1G10G V_RX_STATUS_MAC1G10G(1U)
-
-#define S_RX_ST_MAC1G10G 21
-#define V_RX_ST_MAC1G10G(x) ((x) << S_RX_ST_MAC1G10G)
-#define F_RX_ST_MAC1G10G V_RX_ST_MAC1G10G(1U)
-
-#define S_TX_ST_MAC1G10G 20
-#define V_TX_ST_MAC1G10G(x) ((x) << S_TX_ST_MAC1G10G)
-#define F_TX_ST_MAC1G10G V_TX_ST_MAC1G10G(1U)
-
-#define S_PERR_TX0_PCS40G 19
-#define V_PERR_TX0_PCS40G(x) ((x) << S_PERR_TX0_PCS40G)
-#define F_PERR_TX0_PCS40G V_PERR_TX0_PCS40G(1U)
-
-#define S_PERR_TX1_PCS40G 18
-#define V_PERR_TX1_PCS40G(x) ((x) << S_PERR_TX1_PCS40G)
-#define F_PERR_TX1_PCS40G V_PERR_TX1_PCS40G(1U)
-
-#define S_PERR_TX2_PCS40G 17
-#define V_PERR_TX2_PCS40G(x) ((x) << S_PERR_TX2_PCS40G)
-#define F_PERR_TX2_PCS40G V_PERR_TX2_PCS40G(1U)
-
-#define S_PERR_TX3_PCS40G 16
-#define V_PERR_TX3_PCS40G(x) ((x) << S_PERR_TX3_PCS40G)
-#define F_PERR_TX3_PCS40G V_PERR_TX3_PCS40G(1U)
-
-#define S_PERR_TX0_FEC40G 15
-#define V_PERR_TX0_FEC40G(x) ((x) << S_PERR_TX0_FEC40G)
-#define F_PERR_TX0_FEC40G V_PERR_TX0_FEC40G(1U)
-
-#define S_PERR_TX1_FEC40G 14
-#define V_PERR_TX1_FEC40G(x) ((x) << S_PERR_TX1_FEC40G)
-#define F_PERR_TX1_FEC40G V_PERR_TX1_FEC40G(1U)
-
-#define S_PERR_TX2_FEC40G 13
-#define V_PERR_TX2_FEC40G(x) ((x) << S_PERR_TX2_FEC40G)
-#define F_PERR_TX2_FEC40G V_PERR_TX2_FEC40G(1U)
-
-#define S_PERR_TX3_FEC40G 12
-#define V_PERR_TX3_FEC40G(x) ((x) << S_PERR_TX3_FEC40G)
-#define F_PERR_TX3_FEC40G V_PERR_TX3_FEC40G(1U)
-
-#define S_PERR_RX0_PCS40G 11
-#define V_PERR_RX0_PCS40G(x) ((x) << S_PERR_RX0_PCS40G)
-#define F_PERR_RX0_PCS40G V_PERR_RX0_PCS40G(1U)
-
-#define S_PERR_RX1_PCS40G 10
-#define V_PERR_RX1_PCS40G(x) ((x) << S_PERR_RX1_PCS40G)
-#define F_PERR_RX1_PCS40G V_PERR_RX1_PCS40G(1U)
-
-#define S_PERR_RX2_PCS40G 9
-#define V_PERR_RX2_PCS40G(x) ((x) << S_PERR_RX2_PCS40G)
-#define F_PERR_RX2_PCS40G V_PERR_RX2_PCS40G(1U)
-
-#define S_PERR_RX3_PCS40G 8
-#define V_PERR_RX3_PCS40G(x) ((x) << S_PERR_RX3_PCS40G)
-#define F_PERR_RX3_PCS40G V_PERR_RX3_PCS40G(1U)
-
-#define S_PERR_RX0_FEC40G 7
-#define V_PERR_RX0_FEC40G(x) ((x) << S_PERR_RX0_FEC40G)
-#define F_PERR_RX0_FEC40G V_PERR_RX0_FEC40G(1U)
-
-#define S_PERR_RX1_FEC40G 6
-#define V_PERR_RX1_FEC40G(x) ((x) << S_PERR_RX1_FEC40G)
-#define F_PERR_RX1_FEC40G V_PERR_RX1_FEC40G(1U)
-
-#define S_PERR_RX2_FEC40G 5
-#define V_PERR_RX2_FEC40G(x) ((x) << S_PERR_RX2_FEC40G)
-#define F_PERR_RX2_FEC40G V_PERR_RX2_FEC40G(1U)
-
-#define S_PERR_RX3_FEC40G 4
-#define V_PERR_RX3_FEC40G(x) ((x) << S_PERR_RX3_FEC40G)
-#define F_PERR_RX3_FEC40G V_PERR_RX3_FEC40G(1U)
-
-#define S_PERR_RX_PCS10G_LPBK 3
-#define V_PERR_RX_PCS10G_LPBK(x) ((x) << S_PERR_RX_PCS10G_LPBK)
-#define F_PERR_RX_PCS10G_LPBK V_PERR_RX_PCS10G_LPBK(1U)
-
-#define S_PERR_RX_PCS10G 2
-#define V_PERR_RX_PCS10G(x) ((x) << S_PERR_RX_PCS10G)
-#define F_PERR_RX_PCS10G V_PERR_RX_PCS10G(1U)
-
-#define S_PERR_RX_PCS1G 1
-#define V_PERR_RX_PCS1G(x) ((x) << S_PERR_RX_PCS1G)
-#define F_PERR_RX_PCS1G V_PERR_RX_PCS1G(1U)
-
-#define S_PERR_TX_PCS1G 0
-#define V_PERR_TX_PCS1G(x) ((x) << S_PERR_TX_PCS1G)
-#define F_PERR_TX_PCS1G V_PERR_TX_PCS1G(1U)
-
-#define A_MAC_PORT_PERR_INT_CAUSE 0x8e4
-
-#define S_T6_PERR_PKT_RAM 31
-#define V_T6_PERR_PKT_RAM(x) ((x) << S_T6_PERR_PKT_RAM)
-#define F_T6_PERR_PKT_RAM V_T6_PERR_PKT_RAM(1U)
-
-#define S_T6_PERR_MASK_RAM 30
-#define V_T6_PERR_MASK_RAM(x) ((x) << S_T6_PERR_MASK_RAM)
-#define F_T6_PERR_MASK_RAM V_T6_PERR_MASK_RAM(1U)
-
-#define S_T6_PERR_CRC_RAM 29
-#define V_T6_PERR_CRC_RAM(x) ((x) << S_T6_PERR_CRC_RAM)
-#define F_T6_PERR_CRC_RAM V_T6_PERR_CRC_RAM(1U)
-
-#define A_MAC_PORT_PERR_ENABLE 0x8e8
-
-#define S_T6_PERR_PKT_RAM 31
-#define V_T6_PERR_PKT_RAM(x) ((x) << S_T6_PERR_PKT_RAM)
-#define F_T6_PERR_PKT_RAM V_T6_PERR_PKT_RAM(1U)
-
-#define S_T6_PERR_MASK_RAM 30
-#define V_T6_PERR_MASK_RAM(x) ((x) << S_T6_PERR_MASK_RAM)
-#define F_T6_PERR_MASK_RAM V_T6_PERR_MASK_RAM(1U)
-
-#define S_T6_PERR_CRC_RAM 29
-#define V_T6_PERR_CRC_RAM(x) ((x) << S_T6_PERR_CRC_RAM)
-#define F_T6_PERR_CRC_RAM V_T6_PERR_CRC_RAM(1U)
-
-#define A_MAC_PORT_PERR_INJECT 0x8ec
-
-#define S_MEMSEL_PERR 1
-#define M_MEMSEL_PERR 0x3fU
-#define V_MEMSEL_PERR(x) ((x) << S_MEMSEL_PERR)
-#define G_MEMSEL_PERR(x) (((x) >> S_MEMSEL_PERR) & M_MEMSEL_PERR)
-
-#define A_MAC_PORT_HSS_CFG0 0x8f0
-
-#define S_HSSREFCLKVALIDA 20
-#define V_HSSREFCLKVALIDA(x) ((x) << S_HSSREFCLKVALIDA)
-#define F_HSSREFCLKVALIDA V_HSSREFCLKVALIDA(1U)
-
-#define S_HSSREFCLKVALIDB 19
-#define V_HSSREFCLKVALIDB(x) ((x) << S_HSSREFCLKVALIDB)
-#define F_HSSREFCLKVALIDB V_HSSREFCLKVALIDB(1U)
-
-#define S_HSSRESYNCA 18
-#define V_HSSRESYNCA(x) ((x) << S_HSSRESYNCA)
-#define F_HSSRESYNCA V_HSSRESYNCA(1U)
-
-#define S_HSSRESYNCB 16
-#define V_HSSRESYNCB(x) ((x) << S_HSSRESYNCB)
-#define F_HSSRESYNCB V_HSSRESYNCB(1U)
-
-#define S_HSSRECCALA 15
-#define V_HSSRECCALA(x) ((x) << S_HSSRECCALA)
-#define F_HSSRECCALA V_HSSRECCALA(1U)
-
-#define S_HSSRECCALB 13
-#define V_HSSRECCALB(x) ((x) << S_HSSRECCALB)
-#define F_HSSRECCALB V_HSSRECCALB(1U)
-
-#define S_HSSPLLBYPA 12
-#define V_HSSPLLBYPA(x) ((x) << S_HSSPLLBYPA)
-#define F_HSSPLLBYPA V_HSSPLLBYPA(1U)
-
-#define S_HSSPLLBYPB 11
-#define V_HSSPLLBYPB(x) ((x) << S_HSSPLLBYPB)
-#define F_HSSPLLBYPB V_HSSPLLBYPB(1U)
-
-#define S_HSSPDWNPLLA 10
-#define V_HSSPDWNPLLA(x) ((x) << S_HSSPDWNPLLA)
-#define F_HSSPDWNPLLA V_HSSPDWNPLLA(1U)
-
-#define S_HSSPDWNPLLB 9
-#define V_HSSPDWNPLLB(x) ((x) << S_HSSPDWNPLLB)
-#define F_HSSPDWNPLLB V_HSSPDWNPLLB(1U)
-
-#define S_HSSVCOSELA 8
-#define V_HSSVCOSELA(x) ((x) << S_HSSVCOSELA)
-#define F_HSSVCOSELA V_HSSVCOSELA(1U)
-
-#define S_HSSVCOSELB 7
-#define V_HSSVCOSELB(x) ((x) << S_HSSVCOSELB)
-#define F_HSSVCOSELB V_HSSVCOSELB(1U)
-
-#define S_HSSCALCOMP 6
-#define V_HSSCALCOMP(x) ((x) << S_HSSCALCOMP)
-#define F_HSSCALCOMP V_HSSCALCOMP(1U)
-
-#define S_HSSCALENAB 5
-#define V_HSSCALENAB(x) ((x) << S_HSSCALENAB)
-#define F_HSSCALENAB V_HSSCALENAB(1U)
-
-#define A_MAC_PORT_HSS_CFG1 0x8f4
-
-#define S_RXACONFIGSEL 30
-#define M_RXACONFIGSEL 0x3U
-#define V_RXACONFIGSEL(x) ((x) << S_RXACONFIGSEL)
-#define G_RXACONFIGSEL(x) (((x) >> S_RXACONFIGSEL) & M_RXACONFIGSEL)
-
-#define S_RXAQUIET 29
-#define V_RXAQUIET(x) ((x) << S_RXAQUIET)
-#define F_RXAQUIET V_RXAQUIET(1U)
-
-#define S_RXAREFRESH 28
-#define V_RXAREFRESH(x) ((x) << S_RXAREFRESH)
-#define F_RXAREFRESH V_RXAREFRESH(1U)
-
-#define S_RXBCONFIGSEL 26
-#define M_RXBCONFIGSEL 0x3U
-#define V_RXBCONFIGSEL(x) ((x) << S_RXBCONFIGSEL)
-#define G_RXBCONFIGSEL(x) (((x) >> S_RXBCONFIGSEL) & M_RXBCONFIGSEL)
-
-#define S_RXBQUIET 25
-#define V_RXBQUIET(x) ((x) << S_RXBQUIET)
-#define F_RXBQUIET V_RXBQUIET(1U)
-
-#define S_RXBREFRESH 24
-#define V_RXBREFRESH(x) ((x) << S_RXBREFRESH)
-#define F_RXBREFRESH V_RXBREFRESH(1U)
-
-#define S_RXCCONFIGSEL 22
-#define M_RXCCONFIGSEL 0x3U
-#define V_RXCCONFIGSEL(x) ((x) << S_RXCCONFIGSEL)
-#define G_RXCCONFIGSEL(x) (((x) >> S_RXCCONFIGSEL) & M_RXCCONFIGSEL)
-
-#define S_RXCQUIET 21
-#define V_RXCQUIET(x) ((x) << S_RXCQUIET)
-#define F_RXCQUIET V_RXCQUIET(1U)
-
-#define S_RXCREFRESH 20
-#define V_RXCREFRESH(x) ((x) << S_RXCREFRESH)
-#define F_RXCREFRESH V_RXCREFRESH(1U)
-
-#define S_RXDCONFIGSEL 18
-#define M_RXDCONFIGSEL 0x3U
-#define V_RXDCONFIGSEL(x) ((x) << S_RXDCONFIGSEL)
-#define G_RXDCONFIGSEL(x) (((x) >> S_RXDCONFIGSEL) & M_RXDCONFIGSEL)
-
-#define S_RXDQUIET 17
-#define V_RXDQUIET(x) ((x) << S_RXDQUIET)
-#define F_RXDQUIET V_RXDQUIET(1U)
-
-#define S_RXDREFRESH 16
-#define V_RXDREFRESH(x) ((x) << S_RXDREFRESH)
-#define F_RXDREFRESH V_RXDREFRESH(1U)
-
-#define S_TXACONFIGSEL 14
-#define M_TXACONFIGSEL 0x3U
-#define V_TXACONFIGSEL(x) ((x) << S_TXACONFIGSEL)
-#define G_TXACONFIGSEL(x) (((x) >> S_TXACONFIGSEL) & M_TXACONFIGSEL)
-
-#define S_TXAQUIET 13
-#define V_TXAQUIET(x) ((x) << S_TXAQUIET)
-#define F_TXAQUIET V_TXAQUIET(1U)
-
-#define S_TXAREFRESH 12
-#define V_TXAREFRESH(x) ((x) << S_TXAREFRESH)
-#define F_TXAREFRESH V_TXAREFRESH(1U)
-
-#define S_TXBCONFIGSEL 10
-#define M_TXBCONFIGSEL 0x3U
-#define V_TXBCONFIGSEL(x) ((x) << S_TXBCONFIGSEL)
-#define G_TXBCONFIGSEL(x) (((x) >> S_TXBCONFIGSEL) & M_TXBCONFIGSEL)
-
-#define S_TXBQUIET 9
-#define V_TXBQUIET(x) ((x) << S_TXBQUIET)
-#define F_TXBQUIET V_TXBQUIET(1U)
-
-#define S_TXBREFRESH 8
-#define V_TXBREFRESH(x) ((x) << S_TXBREFRESH)
-#define F_TXBREFRESH V_TXBREFRESH(1U)
-
-#define S_TXCCONFIGSEL 6
-#define M_TXCCONFIGSEL 0x3U
-#define V_TXCCONFIGSEL(x) ((x) << S_TXCCONFIGSEL)
-#define G_TXCCONFIGSEL(x) (((x) >> S_TXCCONFIGSEL) & M_TXCCONFIGSEL)
-
-#define S_TXCQUIET 5
-#define V_TXCQUIET(x) ((x) << S_TXCQUIET)
-#define F_TXCQUIET V_TXCQUIET(1U)
-
-#define S_TXCREFRESH 4
-#define V_TXCREFRESH(x) ((x) << S_TXCREFRESH)
-#define F_TXCREFRESH V_TXCREFRESH(1U)
-
-#define S_TXDCONFIGSEL 2
-#define M_TXDCONFIGSEL 0x3U
-#define V_TXDCONFIGSEL(x) ((x) << S_TXDCONFIGSEL)
-#define G_TXDCONFIGSEL(x) (((x) >> S_TXDCONFIGSEL) & M_TXDCONFIGSEL)
-
-#define S_TXDQUIET 1
-#define V_TXDQUIET(x) ((x) << S_TXDQUIET)
-#define F_TXDQUIET V_TXDQUIET(1U)
-
-#define S_TXDREFRESH 0
-#define V_TXDREFRESH(x) ((x) << S_TXDREFRESH)
-#define F_TXDREFRESH V_TXDREFRESH(1U)
-
-#define A_MAC_PORT_HSS_CFG2 0x8f8
-
-#define S_RXAASSTCLK 31
-#define V_RXAASSTCLK(x) ((x) << S_RXAASSTCLK)
-#define F_RXAASSTCLK V_RXAASSTCLK(1U)
-
-#define S_T5RXAPRBSRST 30
-#define V_T5RXAPRBSRST(x) ((x) << S_T5RXAPRBSRST)
-#define F_T5RXAPRBSRST V_T5RXAPRBSRST(1U)
-
-#define S_RXBASSTCLK 29
-#define V_RXBASSTCLK(x) ((x) << S_RXBASSTCLK)
-#define F_RXBASSTCLK V_RXBASSTCLK(1U)
-
-#define S_T5RXBPRBSRST 28
-#define V_T5RXBPRBSRST(x) ((x) << S_T5RXBPRBSRST)
-#define F_T5RXBPRBSRST V_T5RXBPRBSRST(1U)
-
-#define S_RXCASSTCLK 27
-#define V_RXCASSTCLK(x) ((x) << S_RXCASSTCLK)
-#define F_RXCASSTCLK V_RXCASSTCLK(1U)
-
-#define S_T5RXCPRBSRST 26
-#define V_T5RXCPRBSRST(x) ((x) << S_T5RXCPRBSRST)
-#define F_T5RXCPRBSRST V_T5RXCPRBSRST(1U)
-
-#define S_RXDASSTCLK 25
-#define V_RXDASSTCLK(x) ((x) << S_RXDASSTCLK)
-#define F_RXDASSTCLK V_RXDASSTCLK(1U)
-
-#define S_T5RXDPRBSRST 24
-#define V_T5RXDPRBSRST(x) ((x) << S_T5RXDPRBSRST)
-#define F_T5RXDPRBSRST V_T5RXDPRBSRST(1U)
-
-#define A_MAC_PORT_HSS_CFG3 0x8fc
-
-#define S_HSSCALSSTN 25
-#define M_HSSCALSSTN 0x7U
-#define V_HSSCALSSTN(x) ((x) << S_HSSCALSSTN)
-#define G_HSSCALSSTN(x) (((x) >> S_HSSCALSSTN) & M_HSSCALSSTN)
-
-#define S_HSSCALSSTP 22
-#define M_HSSCALSSTP 0x7U
-#define V_HSSCALSSTP(x) ((x) << S_HSSCALSSTP)
-#define G_HSSCALSSTP(x) (((x) >> S_HSSCALSSTP) & M_HSSCALSSTP)
-
-#define S_HSSVBOOSTDIVB 19
-#define M_HSSVBOOSTDIVB 0x7U
-#define V_HSSVBOOSTDIVB(x) ((x) << S_HSSVBOOSTDIVB)
-#define G_HSSVBOOSTDIVB(x) (((x) >> S_HSSVBOOSTDIVB) & M_HSSVBOOSTDIVB)
-
-#define S_HSSVBOOSTDIVA 16
-#define M_HSSVBOOSTDIVA 0x7U
-#define V_HSSVBOOSTDIVA(x) ((x) << S_HSSVBOOSTDIVA)
-#define G_HSSVBOOSTDIVA(x) (((x) >> S_HSSVBOOSTDIVA) & M_HSSVBOOSTDIVA)
-
-#define S_HSSPLLCONFIGB 8
-#define M_HSSPLLCONFIGB 0xffU
-#define V_HSSPLLCONFIGB(x) ((x) << S_HSSPLLCONFIGB)
-#define G_HSSPLLCONFIGB(x) (((x) >> S_HSSPLLCONFIGB) & M_HSSPLLCONFIGB)
-
-#define S_HSSPLLCONFIGA 0
-#define M_HSSPLLCONFIGA 0xffU
-#define V_HSSPLLCONFIGA(x) ((x) << S_HSSPLLCONFIGA)
-#define G_HSSPLLCONFIGA(x) (((x) >> S_HSSPLLCONFIGA) & M_HSSPLLCONFIGA)
-
-#define S_T6_HSSCALSSTN 22
-#define M_T6_HSSCALSSTN 0x3fU
-#define V_T6_HSSCALSSTN(x) ((x) << S_T6_HSSCALSSTN)
-#define G_T6_HSSCALSSTN(x) (((x) >> S_T6_HSSCALSSTN) & M_T6_HSSCALSSTN)
-
-#define S_T6_HSSCALSSTP 16
-#define M_T6_HSSCALSSTP 0x3fU
-#define V_T6_HSSCALSSTP(x) ((x) << S_T6_HSSCALSSTP)
-#define G_T6_HSSCALSSTP(x) (((x) >> S_T6_HSSCALSSTP) & M_T6_HSSCALSSTP)
-
-#define A_MAC_PORT_HSS_CFG4 0x900
-
-#define S_HSSDIVSELA 9
-#define M_HSSDIVSELA 0x1ffU
-#define V_HSSDIVSELA(x) ((x) << S_HSSDIVSELA)
-#define G_HSSDIVSELA(x) (((x) >> S_HSSDIVSELA) & M_HSSDIVSELA)
-
-#define S_HSSDIVSELB 0
-#define M_HSSDIVSELB 0x1ffU
-#define V_HSSDIVSELB(x) ((x) << S_HSSDIVSELB)
-#define G_HSSDIVSELB(x) (((x) >> S_HSSDIVSELB) & M_HSSDIVSELB)
-
-#define S_HSSREFDIVA 24
-#define M_HSSREFDIVA 0xfU
-#define V_HSSREFDIVA(x) ((x) << S_HSSREFDIVA)
-#define G_HSSREFDIVA(x) (((x) >> S_HSSREFDIVA) & M_HSSREFDIVA)
-
-#define S_HSSREFDIVB 20
-#define M_HSSREFDIVB 0xfU
-#define V_HSSREFDIVB(x) ((x) << S_HSSREFDIVB)
-#define G_HSSREFDIVB(x) (((x) >> S_HSSREFDIVB) & M_HSSREFDIVB)
-
-#define S_HSSPLLDIV2B 19
-#define V_HSSPLLDIV2B(x) ((x) << S_HSSPLLDIV2B)
-#define F_HSSPLLDIV2B V_HSSPLLDIV2B(1U)
-
-#define S_HSSPLLDIV2A 18
-#define V_HSSPLLDIV2A(x) ((x) << S_HSSPLLDIV2A)
-#define F_HSSPLLDIV2A V_HSSPLLDIV2A(1U)
-
-#define A_MAC_PORT_HSS_STATUS 0x904
-
-#define S_HSSPLLLOCKB 3
-#define V_HSSPLLLOCKB(x) ((x) << S_HSSPLLLOCKB)
-#define F_HSSPLLLOCKB V_HSSPLLLOCKB(1U)
-
-#define S_HSSPLLLOCKA 2
-#define V_HSSPLLLOCKA(x) ((x) << S_HSSPLLLOCKA)
-#define F_HSSPLLLOCKA V_HSSPLLLOCKA(1U)
-
-#define S_HSSPRTREADYB 1
-#define V_HSSPRTREADYB(x) ((x) << S_HSSPRTREADYB)
-#define F_HSSPRTREADYB V_HSSPRTREADYB(1U)
-
-#define S_HSSPRTREADYA 0
-#define V_HSSPRTREADYA(x) ((x) << S_HSSPRTREADYA)
-#define F_HSSPRTREADYA V_HSSPRTREADYA(1U)
-
-#define S_RXDERROFLOW 19
-#define V_RXDERROFLOW(x) ((x) << S_RXDERROFLOW)
-#define F_RXDERROFLOW V_RXDERROFLOW(1U)
-
-#define S_RXCERROFLOW 18
-#define V_RXCERROFLOW(x) ((x) << S_RXCERROFLOW)
-#define F_RXCERROFLOW V_RXCERROFLOW(1U)
-
-#define S_RXBERROFLOW 17
-#define V_RXBERROFLOW(x) ((x) << S_RXBERROFLOW)
-#define F_RXBERROFLOW V_RXBERROFLOW(1U)
-
-#define S_RXAERROFLOW 16
-#define V_RXAERROFLOW(x) ((x) << S_RXAERROFLOW)
-#define F_RXAERROFLOW V_RXAERROFLOW(1U)
-
-#define A_MAC_PORT_HSS_EEE_STATUS 0x908
-
-#define S_RXAQUIET_STATUS 15
-#define V_RXAQUIET_STATUS(x) ((x) << S_RXAQUIET_STATUS)
-#define F_RXAQUIET_STATUS V_RXAQUIET_STATUS(1U)
-
-#define S_RXAREFRESH_STATUS 14
-#define V_RXAREFRESH_STATUS(x) ((x) << S_RXAREFRESH_STATUS)
-#define F_RXAREFRESH_STATUS V_RXAREFRESH_STATUS(1U)
-
-#define S_RXBQUIET_STATUS 13
-#define V_RXBQUIET_STATUS(x) ((x) << S_RXBQUIET_STATUS)
-#define F_RXBQUIET_STATUS V_RXBQUIET_STATUS(1U)
-
-#define S_RXBREFRESH_STATUS 12
-#define V_RXBREFRESH_STATUS(x) ((x) << S_RXBREFRESH_STATUS)
-#define F_RXBREFRESH_STATUS V_RXBREFRESH_STATUS(1U)
-
-#define S_RXCQUIET_STATUS 11
-#define V_RXCQUIET_STATUS(x) ((x) << S_RXCQUIET_STATUS)
-#define F_RXCQUIET_STATUS V_RXCQUIET_STATUS(1U)
-
-#define S_RXCREFRESH_STATUS 10
-#define V_RXCREFRESH_STATUS(x) ((x) << S_RXCREFRESH_STATUS)
-#define F_RXCREFRESH_STATUS V_RXCREFRESH_STATUS(1U)
-
-#define S_RXDQUIET_STATUS 9
-#define V_RXDQUIET_STATUS(x) ((x) << S_RXDQUIET_STATUS)
-#define F_RXDQUIET_STATUS V_RXDQUIET_STATUS(1U)
-
-#define S_RXDREFRESH_STATUS 8
-#define V_RXDREFRESH_STATUS(x) ((x) << S_RXDREFRESH_STATUS)
-#define F_RXDREFRESH_STATUS V_RXDREFRESH_STATUS(1U)
-
-#define S_TXAQUIET_STATUS 7
-#define V_TXAQUIET_STATUS(x) ((x) << S_TXAQUIET_STATUS)
-#define F_TXAQUIET_STATUS V_TXAQUIET_STATUS(1U)
-
-#define S_TXAREFRESH_STATUS 6
-#define V_TXAREFRESH_STATUS(x) ((x) << S_TXAREFRESH_STATUS)
-#define F_TXAREFRESH_STATUS V_TXAREFRESH_STATUS(1U)
-
-#define S_TXBQUIET_STATUS 5
-#define V_TXBQUIET_STATUS(x) ((x) << S_TXBQUIET_STATUS)
-#define F_TXBQUIET_STATUS V_TXBQUIET_STATUS(1U)
-
-#define S_TXBREFRESH_STATUS 4
-#define V_TXBREFRESH_STATUS(x) ((x) << S_TXBREFRESH_STATUS)
-#define F_TXBREFRESH_STATUS V_TXBREFRESH_STATUS(1U)
-
-#define S_TXCQUIET_STATUS 3
-#define V_TXCQUIET_STATUS(x) ((x) << S_TXCQUIET_STATUS)
-#define F_TXCQUIET_STATUS V_TXCQUIET_STATUS(1U)
-
-#define S_TXCREFRESH_STATUS 2
-#define V_TXCREFRESH_STATUS(x) ((x) << S_TXCREFRESH_STATUS)
-#define F_TXCREFRESH_STATUS V_TXCREFRESH_STATUS(1U)
-
-#define S_TXDQUIET_STATUS 1
-#define V_TXDQUIET_STATUS(x) ((x) << S_TXDQUIET_STATUS)
-#define F_TXDQUIET_STATUS V_TXDQUIET_STATUS(1U)
-
-#define S_TXDREFRESH_STATUS 0
-#define V_TXDREFRESH_STATUS(x) ((x) << S_TXDREFRESH_STATUS)
-#define F_TXDREFRESH_STATUS V_TXDREFRESH_STATUS(1U)
-
-#define A_MAC_PORT_HSS_SIGDET_STATUS 0x90c
-#define A_MAC_PORT_HSS_PL_CTL 0x910
-
-#define S_TOV 16
-#define M_TOV 0xffU
-#define V_TOV(x) ((x) << S_TOV)
-#define G_TOV(x) (((x) >> S_TOV) & M_TOV)
-
-#define S_TSU 8
-#define M_TSU 0xffU
-#define V_TSU(x) ((x) << S_TSU)
-#define G_TSU(x) (((x) >> S_TSU) & M_TSU)
-
-#define S_IPW 0
-#define M_IPW 0xffU
-#define V_IPW(x) ((x) << S_IPW)
-#define G_IPW(x) (((x) >> S_IPW) & M_IPW)
-
-#define A_MAC_PORT_RUNT_FRAME 0x914
-
-#define S_RUNTCLEAR 16
-#define V_RUNTCLEAR(x) ((x) << S_RUNTCLEAR)
-#define F_RUNTCLEAR V_RUNTCLEAR(1U)
-
-#define S_RUNT 0
-#define M_RUNT 0xffffU
-#define V_RUNT(x) ((x) << S_RUNT)
-#define G_RUNT(x) (((x) >> S_RUNT) & M_RUNT)
-
-#define A_MAC_PORT_EEE_STATUS 0x918
-
-#define S_EEE_TX_10G_STATE 10
-#define M_EEE_TX_10G_STATE 0x3U
-#define V_EEE_TX_10G_STATE(x) ((x) << S_EEE_TX_10G_STATE)
-#define G_EEE_TX_10G_STATE(x) (((x) >> S_EEE_TX_10G_STATE) & M_EEE_TX_10G_STATE)
-
-#define S_EEE_RX_10G_STATE 8
-#define M_EEE_RX_10G_STATE 0x3U
-#define V_EEE_RX_10G_STATE(x) ((x) << S_EEE_RX_10G_STATE)
-#define G_EEE_RX_10G_STATE(x) (((x) >> S_EEE_RX_10G_STATE) & M_EEE_RX_10G_STATE)
-
-#define S_EEE_TX_1G_STATE 6
-#define M_EEE_TX_1G_STATE 0x3U
-#define V_EEE_TX_1G_STATE(x) ((x) << S_EEE_TX_1G_STATE)
-#define G_EEE_TX_1G_STATE(x) (((x) >> S_EEE_TX_1G_STATE) & M_EEE_TX_1G_STATE)
-
-#define S_EEE_RX_1G_STATE 4
-#define M_EEE_RX_1G_STATE 0x3U
-#define V_EEE_RX_1G_STATE(x) ((x) << S_EEE_RX_1G_STATE)
-#define G_EEE_RX_1G_STATE(x) (((x) >> S_EEE_RX_1G_STATE) & M_EEE_RX_1G_STATE)
-
-#define S_PMA_RX_REFRESH 3
-#define V_PMA_RX_REFRESH(x) ((x) << S_PMA_RX_REFRESH)
-#define F_PMA_RX_REFRESH V_PMA_RX_REFRESH(1U)
-
-#define S_PMA_RX_QUIET 2
-#define V_PMA_RX_QUIET(x) ((x) << S_PMA_RX_QUIET)
-#define F_PMA_RX_QUIET V_PMA_RX_QUIET(1U)
-
-#define S_PMA_TX_REFRESH 1
-#define V_PMA_TX_REFRESH(x) ((x) << S_PMA_TX_REFRESH)
-#define F_PMA_TX_REFRESH V_PMA_TX_REFRESH(1U)
-
-#define S_PMA_TX_QUIET 0
-#define V_PMA_TX_QUIET(x) ((x) << S_PMA_TX_QUIET)
-#define F_PMA_TX_QUIET V_PMA_TX_QUIET(1U)
-
-#define A_MAC_PORT_CGEN 0x91c
-
-#define S_CGEN 8
-#define V_CGEN(x) ((x) << S_CGEN)
-#define F_CGEN V_CGEN(1U)
-
-#define S_SD7_CGEN 7
-#define V_SD7_CGEN(x) ((x) << S_SD7_CGEN)
-#define F_SD7_CGEN V_SD7_CGEN(1U)
-
-#define S_SD6_CGEN 6
-#define V_SD6_CGEN(x) ((x) << S_SD6_CGEN)
-#define F_SD6_CGEN V_SD6_CGEN(1U)
-
-#define S_SD5_CGEN 5
-#define V_SD5_CGEN(x) ((x) << S_SD5_CGEN)
-#define F_SD5_CGEN V_SD5_CGEN(1U)
-
-#define S_SD4_CGEN 4
-#define V_SD4_CGEN(x) ((x) << S_SD4_CGEN)
-#define F_SD4_CGEN V_SD4_CGEN(1U)
-
-#define S_SD3_CGEN 3
-#define V_SD3_CGEN(x) ((x) << S_SD3_CGEN)
-#define F_SD3_CGEN V_SD3_CGEN(1U)
-
-#define S_SD2_CGEN 2
-#define V_SD2_CGEN(x) ((x) << S_SD2_CGEN)
-#define F_SD2_CGEN V_SD2_CGEN(1U)
-
-#define S_SD1_CGEN 1
-#define V_SD1_CGEN(x) ((x) << S_SD1_CGEN)
-#define F_SD1_CGEN V_SD1_CGEN(1U)
-
-#define S_SD0_CGEN 0
-#define V_SD0_CGEN(x) ((x) << S_SD0_CGEN)
-#define F_SD0_CGEN V_SD0_CGEN(1U)
-
-#define A_MAC_PORT_CGEN_MTIP 0x920
-
-#define S_MACSEG5_CGEN 11
-#define V_MACSEG5_CGEN(x) ((x) << S_MACSEG5_CGEN)
-#define F_MACSEG5_CGEN V_MACSEG5_CGEN(1U)
-
-#define S_PCSSEG5_CGEN 10
-#define V_PCSSEG5_CGEN(x) ((x) << S_PCSSEG5_CGEN)
-#define F_PCSSEG5_CGEN V_PCSSEG5_CGEN(1U)
-
-#define S_MACSEG4_CGEN 9
-#define V_MACSEG4_CGEN(x) ((x) << S_MACSEG4_CGEN)
-#define F_MACSEG4_CGEN V_MACSEG4_CGEN(1U)
-
-#define S_PCSSEG4_CGEN 8
-#define V_PCSSEG4_CGEN(x) ((x) << S_PCSSEG4_CGEN)
-#define F_PCSSEG4_CGEN V_PCSSEG4_CGEN(1U)
-
-#define S_MACSEG3_CGEN 7
-#define V_MACSEG3_CGEN(x) ((x) << S_MACSEG3_CGEN)
-#define F_MACSEG3_CGEN V_MACSEG3_CGEN(1U)
-
-#define S_PCSSEG3_CGEN 6
-#define V_PCSSEG3_CGEN(x) ((x) << S_PCSSEG3_CGEN)
-#define F_PCSSEG3_CGEN V_PCSSEG3_CGEN(1U)
-
-#define S_MACSEG2_CGEN 5
-#define V_MACSEG2_CGEN(x) ((x) << S_MACSEG2_CGEN)
-#define F_MACSEG2_CGEN V_MACSEG2_CGEN(1U)
-
-#define S_PCSSEG2_CGEN 4
-#define V_PCSSEG2_CGEN(x) ((x) << S_PCSSEG2_CGEN)
-#define F_PCSSEG2_CGEN V_PCSSEG2_CGEN(1U)
-
-#define S_MACSEG1_CGEN 3
-#define V_MACSEG1_CGEN(x) ((x) << S_MACSEG1_CGEN)
-#define F_MACSEG1_CGEN V_MACSEG1_CGEN(1U)
-
-#define S_PCSSEG1_CGEN 2
-#define V_PCSSEG1_CGEN(x) ((x) << S_PCSSEG1_CGEN)
-#define F_PCSSEG1_CGEN V_PCSSEG1_CGEN(1U)
-
-#define S_MACSEG0_CGEN 1
-#define V_MACSEG0_CGEN(x) ((x) << S_MACSEG0_CGEN)
-#define F_MACSEG0_CGEN V_MACSEG0_CGEN(1U)
-
-#define S_PCSSEG0_CGEN 0
-#define V_PCSSEG0_CGEN(x) ((x) << S_PCSSEG0_CGEN)
-#define F_PCSSEG0_CGEN V_PCSSEG0_CGEN(1U)
-
-#define A_MAC_PORT_TX_TS_ID 0x924
-
-#define S_TS_ID 0
-#define M_TS_ID 0x7U
-#define V_TS_ID(x) ((x) << S_TS_ID)
-#define G_TS_ID(x) (((x) >> S_TS_ID) & M_TS_ID)
-
-#define A_MAC_PORT_TX_TS_VAL_LO 0x928
-#define A_MAC_PORT_TX_TS_VAL_HI 0x92c
-#define A_MAC_PORT_EEE_CTL 0x930
-
-#define S_EEE_CTRL 2
-#define M_EEE_CTRL 0x3fffffffU
-#define V_EEE_CTRL(x) ((x) << S_EEE_CTRL)
-#define G_EEE_CTRL(x) (((x) >> S_EEE_CTRL) & M_EEE_CTRL)
-
-#define S_TICK_START 1
-#define V_TICK_START(x) ((x) << S_TICK_START)
-#define F_TICK_START V_TICK_START(1U)
-
-#define S_EEE_ENABLE 0
-#define V_EEE_ENABLE(x) ((x) << S_EEE_ENABLE)
-#define F_EEE_ENABLE V_EEE_ENABLE(1U)
-
-#define A_MAC_PORT_EEE_TX_CTL 0x934
-
-#define S_WAKE_TIMER 16
-#define M_WAKE_TIMER 0xffffU
-#define V_WAKE_TIMER(x) ((x) << S_WAKE_TIMER)
-#define G_WAKE_TIMER(x) (((x) >> S_WAKE_TIMER) & M_WAKE_TIMER)
-
-#define S_HSS_TIMER 5
-#define M_HSS_TIMER 0xfU
-#define V_HSS_TIMER(x) ((x) << S_HSS_TIMER)
-#define G_HSS_TIMER(x) (((x) >> S_HSS_TIMER) & M_HSS_TIMER)
-
-#define S_HSS_CTL 4
-#define V_HSS_CTL(x) ((x) << S_HSS_CTL)
-#define F_HSS_CTL V_HSS_CTL(1U)
-
-#define S_LPI_ACTIVE 3
-#define V_LPI_ACTIVE(x) ((x) << S_LPI_ACTIVE)
-#define F_LPI_ACTIVE V_LPI_ACTIVE(1U)
-
-#define S_LPI_TXHOLD 2
-#define V_LPI_TXHOLD(x) ((x) << S_LPI_TXHOLD)
-#define F_LPI_TXHOLD V_LPI_TXHOLD(1U)
-
-#define S_LPI_REQ 1
-#define V_LPI_REQ(x) ((x) << S_LPI_REQ)
-#define F_LPI_REQ V_LPI_REQ(1U)
-
-#define S_EEE_TX_RESET 0
-#define V_EEE_TX_RESET(x) ((x) << S_EEE_TX_RESET)
-#define F_EEE_TX_RESET V_EEE_TX_RESET(1U)
-
-#define A_MAC_PORT_EEE_RX_CTL 0x938
-
-#define S_LPI_IND 1
-#define V_LPI_IND(x) ((x) << S_LPI_IND)
-#define F_LPI_IND V_LPI_IND(1U)
-
-#define S_EEE_RX_RESET 0
-#define V_EEE_RX_RESET(x) ((x) << S_EEE_RX_RESET)
-#define F_EEE_RX_RESET V_EEE_RX_RESET(1U)
-
-#define A_MAC_PORT_EEE_TX_10G_SLEEP_TIMER 0x93c
-#define A_MAC_PORT_EEE_TX_10G_QUIET_TIMER 0x940
-#define A_MAC_PORT_EEE_TX_10G_WAKE_TIMER 0x944
-#define A_MAC_PORT_EEE_TX_1G_SLEEP_TIMER 0x948
-#define A_MAC_PORT_EEE_TX_1G_QUIET_TIMER 0x94c
-#define A_MAC_PORT_EEE_TX_1G_REFRESH_TIMER 0x950
-#define A_MAC_PORT_EEE_RX_10G_QUIET_TIMER 0x954
-#define A_MAC_PORT_EEE_RX_10G_WAKE_TIMER 0x958
-#define A_MAC_PORT_EEE_RX_10G_WF_TIMER 0x95c
-#define A_MAC_PORT_EEE_RX_1G_QUIET_TIMER 0x960
-#define A_MAC_PORT_EEE_RX_1G_WAKE_TIMER 0x964
-#define A_MAC_PORT_EEE_WF_COUNT 0x968
-
-#define S_WAKE_CNT_CLR 16
-#define V_WAKE_CNT_CLR(x) ((x) << S_WAKE_CNT_CLR)
-#define F_WAKE_CNT_CLR V_WAKE_CNT_CLR(1U)
-
-#define S_WAKE_CNT 0
-#define M_WAKE_CNT 0xffffU
-#define V_WAKE_CNT(x) ((x) << S_WAKE_CNT)
-#define G_WAKE_CNT(x) (((x) >> S_WAKE_CNT) & M_WAKE_CNT)
-
-#define A_MAC_PORT_PTP_TIMER_RD0_LO 0x96c
-#define A_MAC_PORT_PTP_TIMER_RD0_HI 0x970
-#define A_MAC_PORT_PTP_TIMER_RD1_LO 0x974
-#define A_MAC_PORT_PTP_TIMER_RD1_HI 0x978
-#define A_MAC_PORT_PTP_TIMER_WR_LO 0x97c
-#define A_MAC_PORT_PTP_TIMER_WR_HI 0x980
-#define A_MAC_PORT_PTP_TIMER_OFFSET_0 0x984
-#define A_MAC_PORT_PTP_TIMER_OFFSET_1 0x988
-#define A_MAC_PORT_PTP_TIMER_OFFSET_2 0x98c
-
-#define S_PTP_OFFSET 0
-#define M_PTP_OFFSET 0xffU
-#define V_PTP_OFFSET(x) ((x) << S_PTP_OFFSET)
-#define G_PTP_OFFSET(x) (((x) >> S_PTP_OFFSET) & M_PTP_OFFSET)
-
-#define A_MAC_PORT_PTP_SUM_LO 0x990
-#define A_MAC_PORT_PTP_SUM_HI 0x994
-#define A_MAC_PORT_PTP_TIMER_INCR0 0x998
-
-#define S_Y 16
-#define M_Y 0xffffU
-#define V_Y(x) ((x) << S_Y)
-#define G_Y(x) (((x) >> S_Y) & M_Y)
-
-#define S_X 0
-#define M_X 0xffffU
-#define V_X(x) ((x) << S_X)
-#define G_X(x) (((x) >> S_X) & M_X)
-
-#define A_MAC_PORT_PTP_TIMER_INCR1 0x99c
-
-#define S_Y_TICK 16
-#define M_Y_TICK 0xffffU
-#define V_Y_TICK(x) ((x) << S_Y_TICK)
-#define G_Y_TICK(x) (((x) >> S_Y_TICK) & M_Y_TICK)
-
-#define S_X_TICK 0
-#define M_X_TICK 0xffffU
-#define V_X_TICK(x) ((x) << S_X_TICK)
-#define G_X_TICK(x) (((x) >> S_X_TICK) & M_X_TICK)
-
-#define A_MAC_PORT_PTP_DRIFT_ADJUST_COUNT 0x9a0
-#define A_MAC_PORT_PTP_OFFSET_ADJUST_FINE 0x9a4
-
-#define S_B 16
-#define M_B 0xffffU
-#define V_B(x) ((x) << S_B)
-#define G_B(x) (((x) >> S_B) & M_B)
-
-#define S_A 0
-#define M_A 0xffffU
-#define V_A(x) ((x) << S_A)
-#define G_A(x) (((x) >> S_A) & M_A)
-
-#define A_MAC_PORT_PTP_OFFSET_ADJUST_TOTAL 0x9a8
-#define A_MAC_PORT_PTP_CFG 0x9ac
-
-#define S_FRZ 18
-#define V_FRZ(x) ((x) << S_FRZ)
-#define F_FRZ V_FRZ(1U)
-
-#define S_OFFSER_ADJUST_SIGN 17
-#define V_OFFSER_ADJUST_SIGN(x) ((x) << S_OFFSER_ADJUST_SIGN)
-#define F_OFFSER_ADJUST_SIGN V_OFFSER_ADJUST_SIGN(1U)
-
-#define S_ADD_OFFSET 16
-#define V_ADD_OFFSET(x) ((x) << S_ADD_OFFSET)
-#define F_ADD_OFFSET V_ADD_OFFSET(1U)
-
-#define S_CYCLE1 8
-#define M_CYCLE1 0xffU
-#define V_CYCLE1(x) ((x) << S_CYCLE1)
-#define G_CYCLE1(x) (((x) >> S_CYCLE1) & M_CYCLE1)
-
-#define S_Q 0
-#define M_Q 0xffU
-#define V_Q(x) ((x) << S_Q)
-#define G_Q(x) (((x) >> S_Q) & M_Q)
-
-#define S_ALARM_EN 21
-#define V_ALARM_EN(x) ((x) << S_ALARM_EN)
-#define F_ALARM_EN V_ALARM_EN(1U)
-
-#define S_ALARM_START 20
-#define V_ALARM_START(x) ((x) << S_ALARM_START)
-#define F_ALARM_START V_ALARM_START(1U)
-
-#define S_PPS_EN 19
-#define V_PPS_EN(x) ((x) << S_PPS_EN)
-#define F_PPS_EN V_PPS_EN(1U)
-
-#define A_MAC_PORT_PTP_PPS 0x9b0
-#define A_MAC_PORT_PTP_SINGLE_ALARM 0x9b4
-#define A_MAC_PORT_PTP_PERIODIC_ALARM 0x9b8
-#define A_MAC_PORT_PTP_STATUS 0x9bc
-
-#define S_ALARM_DONE 0
-#define V_ALARM_DONE(x) ((x) << S_ALARM_DONE)
-#define F_ALARM_DONE V_ALARM_DONE(1U)
-
-#define A_MAC_PORT_MTIP_REVISION 0xa00
-
-#define S_CUSTREV 16
-#define M_CUSTREV 0xffffU
-#define V_CUSTREV(x) ((x) << S_CUSTREV)
-#define G_CUSTREV(x) (((x) >> S_CUSTREV) & M_CUSTREV)
-
-#define S_VER 8
-#define M_VER 0xffU
-#define V_VER(x) ((x) << S_VER)
-#define G_VER(x) (((x) >> S_VER) & M_VER)
-
-#define S_MTIP_REV 0
-#define M_MTIP_REV 0xffU
-#define V_MTIP_REV(x) ((x) << S_MTIP_REV)
-#define G_MTIP_REV(x) (((x) >> S_MTIP_REV) & M_MTIP_REV)
-
-#define A_MAC_PORT_MTIP_SCRATCH 0xa04
-#define A_MAC_PORT_MTIP_COMMAND_CONFIG 0xa08
-
-#define S_TX_FLUSH_ENABLE 22
-#define V_TX_FLUSH_ENABLE(x) ((x) << S_TX_FLUSH_ENABLE)
-#define F_TX_FLUSH_ENABLE V_TX_FLUSH_ENABLE(1U)
-
-#define S_RX_SFD_ANY 21
-#define V_RX_SFD_ANY(x) ((x) << S_RX_SFD_ANY)
-#define F_RX_SFD_ANY V_RX_SFD_ANY(1U)
-
-#define S_PAUSE_PFC_COMP 20
-#define V_PAUSE_PFC_COMP(x) ((x) << S_PAUSE_PFC_COMP)
-#define F_PAUSE_PFC_COMP V_PAUSE_PFC_COMP(1U)
-
-#define S_PFC_MODE 19
-#define V_PFC_MODE(x) ((x) << S_PFC_MODE)
-#define F_PFC_MODE V_PFC_MODE(1U)
-
-#define S_RS_COL_CNT_EXT 18
-#define V_RS_COL_CNT_EXT(x) ((x) << S_RS_COL_CNT_EXT)
-#define F_RS_COL_CNT_EXT V_RS_COL_CNT_EXT(1U)
-
-#define S_NO_LGTH_CHECK 17
-#define V_NO_LGTH_CHECK(x) ((x) << S_NO_LGTH_CHECK)
-#define F_NO_LGTH_CHECK V_NO_LGTH_CHECK(1U)
-
-#define S_SEND_IDLE 16
-#define V_SEND_IDLE(x) ((x) << S_SEND_IDLE)
-#define F_SEND_IDLE V_SEND_IDLE(1U)
-
-#define S_PHY_TXENA 15
-#define V_PHY_TXENA(x) ((x) << S_PHY_TXENA)
-#define F_PHY_TXENA V_PHY_TXENA(1U)
-
-#define S_RX_ERR_DISC 14
-#define V_RX_ERR_DISC(x) ((x) << S_RX_ERR_DISC)
-#define F_RX_ERR_DISC V_RX_ERR_DISC(1U)
-
-#define S_CMD_FRAME_ENA 13
-#define V_CMD_FRAME_ENA(x) ((x) << S_CMD_FRAME_ENA)
-#define F_CMD_FRAME_ENA V_CMD_FRAME_ENA(1U)
-
-#define S_SW_RESET 12
-#define V_SW_RESET(x) ((x) << S_SW_RESET)
-#define F_SW_RESET V_SW_RESET(1U)
-
-#define S_TX_PAD_EN 11
-#define V_TX_PAD_EN(x) ((x) << S_TX_PAD_EN)
-#define F_TX_PAD_EN V_TX_PAD_EN(1U)
-
-#define S_PHY_LOOPBACK_EN 10
-#define V_PHY_LOOPBACK_EN(x) ((x) << S_PHY_LOOPBACK_EN)
-#define F_PHY_LOOPBACK_EN V_PHY_LOOPBACK_EN(1U)
-
-#define S_TX_ADDR_INS 9
-#define V_TX_ADDR_INS(x) ((x) << S_TX_ADDR_INS)
-#define F_TX_ADDR_INS V_TX_ADDR_INS(1U)
-
-#define S_PAUSE_IGNORE 8
-#define V_PAUSE_IGNORE(x) ((x) << S_PAUSE_IGNORE)
-#define F_PAUSE_IGNORE V_PAUSE_IGNORE(1U)
-
-#define S_PAUSE_FWD 7
-#define V_PAUSE_FWD(x) ((x) << S_PAUSE_FWD)
-#define F_PAUSE_FWD V_PAUSE_FWD(1U)
-
-#define S_CRC_FWD 6
-#define V_CRC_FWD(x) ((x) << S_CRC_FWD)
-#define F_CRC_FWD V_CRC_FWD(1U)
-
-#define S_PAD_EN 5
-#define V_PAD_EN(x) ((x) << S_PAD_EN)
-#define F_PAD_EN V_PAD_EN(1U)
-
-#define S_PROMIS_EN 4
-#define V_PROMIS_EN(x) ((x) << S_PROMIS_EN)
-#define F_PROMIS_EN V_PROMIS_EN(1U)
-
-#define S_WAN_MODE 3
-#define V_WAN_MODE(x) ((x) << S_WAN_MODE)
-#define F_WAN_MODE V_WAN_MODE(1U)
-
-#define S_RX_ENA 1
-#define V_RX_ENA(x) ((x) << S_RX_ENA)
-#define F_RX_ENA V_RX_ENA(1U)
-
-#define S_TX_ENA 0
-#define V_TX_ENA(x) ((x) << S_TX_ENA)
-#define F_TX_ENA V_TX_ENA(1U)
-
-#define A_MAC_PORT_MTIP_MAC_ADDR_0 0xa0c
-#define A_MAC_PORT_MTIP_MAC_ADDR_1 0xa10
-
-#define S_MACADDRHI 0
-#define M_MACADDRHI 0xffffU
-#define V_MACADDRHI(x) ((x) << S_MACADDRHI)
-#define G_MACADDRHI(x) (((x) >> S_MACADDRHI) & M_MACADDRHI)
-
-#define A_MAC_PORT_MTIP_FRM_LENGTH 0xa14
-
-#define S_LEN 0
-#define M_LEN 0xffffU
-#define V_LEN(x) ((x) << S_LEN)
-#define G_LEN(x) (((x) >> S_LEN) & M_LEN)
-
-#define A_MAC_PORT_MTIP_RX_FIFO_SECTIONS 0xa1c
-
-#define S_AVAIL 16
-#define M_AVAIL 0xffffU
-#define V_AVAIL(x) ((x) << S_AVAIL)
-#define G_AVAIL(x) (((x) >> S_AVAIL) & M_AVAIL)
-
-#define S_EMPTY 0
-#define M_EMPTY 0xffffU
-#define V_EMPTY(x) ((x) << S_EMPTY)
-#define G_EMPTY(x) (((x) >> S_EMPTY) & M_EMPTY)
-
-#define A_MAC_PORT_MTIP_TX_FIFO_SECTIONS 0xa20
-#define A_MAC_PORT_MTIP_RX_FIFO_ALMOST_F_E 0xa24
-
-#define S_ALMSTFULL 16
-#define M_ALMSTFULL 0xffffU
-#define V_ALMSTFULL(x) ((x) << S_ALMSTFULL)
-#define G_ALMSTFULL(x) (((x) >> S_ALMSTFULL) & M_ALMSTFULL)
-
-#define S_ALMSTEMPTY 0
-#define M_ALMSTEMPTY 0xffffU
-#define V_ALMSTEMPTY(x) ((x) << S_ALMSTEMPTY)
-#define G_ALMSTEMPTY(x) (((x) >> S_ALMSTEMPTY) & M_ALMSTEMPTY)
-
-#define A_MAC_PORT_MTIP_TX_FIFO_ALMOST_F_E 0xa28
-#define A_MAC_PORT_MTIP_HASHTABLE_LOAD 0xa2c
-
-#define S_ENABLE_MCAST_RX 8
-#define V_ENABLE_MCAST_RX(x) ((x) << S_ENABLE_MCAST_RX)
-#define F_ENABLE_MCAST_RX V_ENABLE_MCAST_RX(1U)
-
-#define S_HASHTABLE_ADDR 0
-#define M_HASHTABLE_ADDR 0x3fU
-#define V_HASHTABLE_ADDR(x) ((x) << S_HASHTABLE_ADDR)
-#define G_HASHTABLE_ADDR(x) (((x) >> S_HASHTABLE_ADDR) & M_HASHTABLE_ADDR)
-
-#define A_MAC_PORT_MTIP_MAC_STATUS 0xa40
-
-#define S_TS_AVAIL 3
-#define V_TS_AVAIL(x) ((x) << S_TS_AVAIL)
-#define F_TS_AVAIL V_TS_AVAIL(1U)
-
-#define S_PHY_LOS 2
-#define V_PHY_LOS(x) ((x) << S_PHY_LOS)
-#define F_PHY_LOS V_PHY_LOS(1U)
-
-#define S_RX_REM_FAULT 1
-#define V_RX_REM_FAULT(x) ((x) << S_RX_REM_FAULT)
-#define F_RX_REM_FAULT V_RX_REM_FAULT(1U)
-
-#define S_RX_LOC_FAULT 0
-#define V_RX_LOC_FAULT(x) ((x) << S_RX_LOC_FAULT)
-#define F_RX_LOC_FAULT V_RX_LOC_FAULT(1U)
-
-#define A_MAC_PORT_MTIP_TX_IPG_LENGTH 0xa44
-
-#define S_IPG 0
-#define M_IPG 0x7fU
-#define V_IPG(x) ((x) << S_IPG)
-#define G_IPG(x) (((x) >> S_IPG) & M_IPG)
-
-#define A_MAC_PORT_MTIP_MAC_CREDIT_TRIGGER 0xa48
-
-#define S_RXFIFORST 0
-#define V_RXFIFORST(x) ((x) << S_RXFIFORST)
-#define F_RXFIFORST V_RXFIFORST(1U)
-
-#define A_MAC_PORT_MTIP_INIT_CREDIT 0xa4c
-
-#define S_MACCRDRST 0
-#define M_MACCRDRST 0xffU
-#define V_MACCRDRST(x) ((x) << S_MACCRDRST)
-#define G_MACCRDRST(x) (((x) >> S_MACCRDRST) & M_MACCRDRST)
-
-#define A_MAC_PORT_MTIP_CURRENT_CREDIT 0xa50
-
-#define S_INITCREDIT 0
-#define M_INITCREDIT 0xffU
-#define V_INITCREDIT(x) ((x) << S_INITCREDIT)
-#define G_INITCREDIT(x) (((x) >> S_INITCREDIT) & M_INITCREDIT)
-
-#define A_MAC_PORT_RX_PAUSE_STATUS 0xa74
-
-#define S_STATUS 0
-#define M_STATUS 0xffU
-#define V_STATUS(x) ((x) << S_STATUS)
-#define G_STATUS(x) (((x) >> S_STATUS) & M_STATUS)
-
-#define A_MAC_PORT_MTIP_TS_TIMESTAMP 0xa7c
-#define A_MAC_PORT_AFRAMESTRANSMITTEDOK 0xa80
-#define A_MAC_PORT_AFRAMESTRANSMITTEDOKHI 0xa84
-#define A_MAC_PORT_AFRAMESRECEIVEDOK 0xa88
-#define A_MAC_PORT_AFRAMESRECEIVEDOKHI 0xa8c
-#define A_MAC_PORT_AFRAMECHECKSEQUENCEERRORS 0xa90
-#define A_MAC_PORT_AFRAMECHECKSEQUENCEERRORSHI 0xa94
-#define A_MAC_PORT_AALIGNMENTERRORS 0xa98
-#define A_MAC_PORT_AALIGNMENTERRORSHI 0xa9c
-#define A_MAC_PORT_APAUSEMACCTRLFRAMESTRANSMITTED 0xaa0
-#define A_MAC_PORT_APAUSEMACCTRLFRAMESTRANSMITTEDHI 0xaa4
-#define A_MAC_PORT_APAUSEMACCTRLFRAMESRECEIVED 0xaa8
-#define A_MAC_PORT_APAUSEMACCTRLFRAMESRECEIVEDHI 0xaac
-#define A_MAC_PORT_AFRAMETOOLONGERRORS 0xab0
-#define A_MAC_PORT_AFRAMETOOLONGERRORSHI 0xab4
-#define A_MAC_PORT_AINRANGELENGTHERRORS 0xab8
-#define A_MAC_PORT_AINRANGELENGTHERRORSHI 0xabc
-#define A_MAC_PORT_VLANTRANSMITTEDOK 0xac0
-#define A_MAC_PORT_VLANTRANSMITTEDOKHI 0xac4
-#define A_MAC_PORT_VLANRECEIVEDOK 0xac8
-#define A_MAC_PORT_VLANRECEIVEDOKHI 0xacc
-#define A_MAC_PORT_AOCTETSTRANSMITTEDOK 0xad0
-#define A_MAC_PORT_AOCTETSTRANSMITTEDOKHI 0xad4
-#define A_MAC_PORT_AOCTETSRECEIVEDOK 0xad8
-#define A_MAC_PORT_AOCTETSRECEIVEDOKHI 0xadc
-#define A_MAC_PORT_IFINUCASTPKTS 0xae0
-#define A_MAC_PORT_IFINUCASTPKTSHI 0xae4
-#define A_MAC_PORT_IFINMULTICASTPKTS 0xae8
-#define A_MAC_PORT_IFINMULTICASTPKTSHI 0xaec
-#define A_MAC_PORT_IFINBROADCASTPKTS 0xaf0
-#define A_MAC_PORT_IFINBROADCASTPKTSHI 0xaf4
-#define A_MAC_PORT_IFOUTERRORS 0xaf8
-#define A_MAC_PORT_IFOUTERRORSHI 0xafc
-#define A_MAC_PORT_IFOUTUCASTPKTS 0xb08
-#define A_MAC_PORT_IFOUTUCASTPKTSHI 0xb0c
-#define A_MAC_PORT_IFOUTMULTICASTPKTS 0xb10
-#define A_MAC_PORT_IFOUTMULTICASTPKTSHI 0xb14
-#define A_MAC_PORT_IFOUTBROADCASTPKTS 0xb18
-#define A_MAC_PORT_IFOUTBROADCASTPKTSHI 0xb1c
-#define A_MAC_PORT_ETHERSTATSDROPEVENTS 0xb20
-#define A_MAC_PORT_ETHERSTATSDROPEVENTSHI 0xb24
-#define A_MAC_PORT_ETHERSTATSOCTETS 0xb28
-#define A_MAC_PORT_ETHERSTATSOCTETSHI 0xb2c
-#define A_MAC_PORT_ETHERSTATSPKTS 0xb30
-#define A_MAC_PORT_ETHERSTATSPKTSHI 0xb34
-#define A_MAC_PORT_ETHERSTATSUNDERSIZEPKTS 0xb38
-#define A_MAC_PORT_ETHERSTATSUNDERSIZEPKTSHI 0xb3c
-#define A_MAC_PORT_ETHERSTATSPKTS64OCTETS 0xb40
-#define A_MAC_PORT_ETHERSTATSPKTS64OCTETSHI 0xb44
-#define A_MAC_PORT_ETHERSTATSPKTS65TO127OCTETS 0xb48
-#define A_MAC_PORT_ETHERSTATSPKTS65TO127OCTETSHI 0xb4c
-#define A_MAC_PORT_ETHERSTATSPKTS128TO255OCTETS 0xb50
-#define A_MAC_PORT_ETHERSTATSPKTS128TO255OCTETSHI 0xb54
-#define A_MAC_PORT_ETHERSTATSPKTS256TO511OCTETS 0xb58
-#define A_MAC_PORT_ETHERSTATSPKTS256TO511OCTETSHI 0xb5c
-#define A_MAC_PORT_ETHERSTATSPKTS512TO1023OCTETS 0xb60
-#define A_MAC_PORT_ETHERSTATSPKTS512TO1023OCTETSHI 0xb64
-#define A_MAC_PORT_ETHERSTATSPKTS1024TO1518OCTETS 0xb68
-#define A_MAC_PORT_ETHERSTATSPKTS1024TO1518OCTETSHI 0xb6c
-#define A_MAC_PORT_ETHERSTATSPKTS1519TOMAXOCTETS 0xb70
-#define A_MAC_PORT_ETHERSTATSPKTS1519TOMAXOCTETSHI 0xb74
-#define A_MAC_PORT_ETHERSTATSOVERSIZEPKTS 0xb78
-#define A_MAC_PORT_ETHERSTATSOVERSIZEPKTSHI 0xb7c
-#define A_MAC_PORT_ETHERSTATSJABBERS 0xb80
-#define A_MAC_PORT_ETHERSTATSJABBERSHI 0xb84
-#define A_MAC_PORT_ETHERSTATSFRAGMENTS 0xb88
-#define A_MAC_PORT_ETHERSTATSFRAGMENTSHI 0xb8c
-#define A_MAC_PORT_IFINERRORS 0xb90
-#define A_MAC_PORT_IFINERRORSHI 0xb94
-#define A_MAC_PORT_ACBFCPAUSEFRAMESTRANSMITTED_0 0xb98
-#define A_MAC_PORT_ACBFCPAUSEFRAMESTRANSMITTED_0HI 0xb9c
-#define A_MAC_PORT_ACBFCPAUSEFRAMESTRANSMITTED_1 0xba0
-#define A_MAC_PORT_ACBFCPAUSEFRAMESTRANSMITTED_1HI 0xba4
-#define A_MAC_PORT_ACBFCPAUSEFRAMESTRANSMITTED_2 0xba8
-#define A_MAC_PORT_ACBFCPAUSEFRAMESTRANSMITTED_2HI 0xbac
-#define A_MAC_PORT_ACBFCPAUSEFRAMESTRANSMITTED_3 0xbb0
-#define A_MAC_PORT_ACBFCPAUSEFRAMESTRANSMITTED_3HI 0xbb4
-#define A_MAC_PORT_ACBFCPAUSEFRAMESTRANSMITTED_4 0xbb8
-#define A_MAC_PORT_ACBFCPAUSEFRAMESTRANSMITTED_4HI 0xbbc
-#define A_MAC_PORT_ACBFCPAUSEFRAMESTRANSMITTED_5 0xbc0
-#define A_MAC_PORT_ACBFCPAUSEFRAMESTRANSMITTED_5HI 0xbc4
-#define A_MAC_PORT_ACBFCPAUSEFRAMESTRANSMITTED_6 0xbc8
-#define A_MAC_PORT_ACBFCPAUSEFRAMESTRANSMITTED_6HI 0xbcc
-#define A_MAC_PORT_ACBFCPAUSEFRAMESTRANSMITTED_7 0xbd0
-#define A_MAC_PORT_ACBFCPAUSEFRAMESTRANSMITTED_7HI 0xbd4
-#define A_MAC_PORT_ACBFCPAUSEFRAMESRECEIVED_0 0xbd8
-#define A_MAC_PORT_ACBFCPAUSEFRAMESRECEIVED_0HI 0xbdc
-#define A_MAC_PORT_ACBFCPAUSEFRAMESRECEIVED_1 0xbe0
-#define A_MAC_PORT_ACBFCPAUSEFRAMESRECEIVED_1HI 0xbe4
-#define A_MAC_PORT_ACBFCPAUSEFRAMESRECEIVED_2 0xbe8
-#define A_MAC_PORT_ACBFCPAUSEFRAMESRECEIVED_2HI 0xbec
-#define A_MAC_PORT_ACBFCPAUSEFRAMESRECEIVED_3 0xbf0
-#define A_MAC_PORT_ACBFCPAUSEFRAMESRECEIVED_3HI 0xbf4
-#define A_MAC_PORT_ACBFCPAUSEFRAMESRECEIVED_4 0xbf8
-#define A_MAC_PORT_ACBFCPAUSEFRAMESRECEIVED_4HI 0xbfc
-#define A_MAC_PORT_ACBFCPAUSEFRAMESRECEIVED_5 0xc00
-#define A_MAC_PORT_ACBFCPAUSEFRAMESRECEIVED_5HI 0xc04
-#define A_MAC_PORT_ACBFCPAUSEFRAMESRECEIVED_6 0xc08
-#define A_MAC_PORT_ACBFCPAUSEFRAMESRECEIVED_6HI 0xc0c
-#define A_MAC_PORT_ACBFCPAUSEFRAMESRECEIVED_7 0xc10
-#define A_MAC_PORT_ACBFCPAUSEFRAMESRECEIVED_7HI 0xc14
-#define A_MAC_PORT_AMACCONTROLFRAMESTRANSMITTED 0xc18
-#define A_MAC_PORT_AMACCONTROLFRAMESTRANSMITTEDHI 0xc1c
-#define A_MAC_PORT_AMACCONTROLFRAMESRECEIVED 0xc20
-#define A_MAC_PORT_AMACCONTROLFRAMESRECEIVEDHI 0xc24
-#define A_MAC_PORT_MTIP_SGMII_CONTROL 0xd00
-
-#define S_RESET 15
-#define V_RESET(x) ((x) << S_RESET)
-#define F_RESET V_RESET(1U)
-
-#define S_LOOPBACK 14
-#define V_LOOPBACK(x) ((x) << S_LOOPBACK)
-#define F_LOOPBACK V_LOOPBACK(1U)
-
-#define S_SPPEDSEL1 13
-#define V_SPPEDSEL1(x) ((x) << S_SPPEDSEL1)
-#define F_SPPEDSEL1 V_SPPEDSEL1(1U)
-
-#define S_AN_EN 12
-#define V_AN_EN(x) ((x) << S_AN_EN)
-#define F_AN_EN V_AN_EN(1U)
-
-#define S_PWRDWN 11
-#define V_PWRDWN(x) ((x) << S_PWRDWN)
-#define F_PWRDWN V_PWRDWN(1U)
-
-#define S_ISOLATE 10
-#define V_ISOLATE(x) ((x) << S_ISOLATE)
-#define F_ISOLATE V_ISOLATE(1U)
-
-#define S_AN_RESTART 9
-#define V_AN_RESTART(x) ((x) << S_AN_RESTART)
-#define F_AN_RESTART V_AN_RESTART(1U)
-
-#define S_DPLX 8
-#define V_DPLX(x) ((x) << S_DPLX)
-#define F_DPLX V_DPLX(1U)
-
-#define S_COLLISIONTEST 7
-#define V_COLLISIONTEST(x) ((x) << S_COLLISIONTEST)
-#define F_COLLISIONTEST V_COLLISIONTEST(1U)
-
-#define S_SPEEDSEL0 6
-#define V_SPEEDSEL0(x) ((x) << S_SPEEDSEL0)
-#define F_SPEEDSEL0 V_SPEEDSEL0(1U)
-
-#define A_MAC_PORT_MTIP_1G10G_REVISION 0xd00
-
-#define S_VER_1G10G 8
-#define M_VER_1G10G 0xffU
-#define V_VER_1G10G(x) ((x) << S_VER_1G10G)
-#define G_VER_1G10G(x) (((x) >> S_VER_1G10G) & M_VER_1G10G)
-
-#define S_REV_1G10G 0
-#define M_REV_1G10G 0xffU
-#define V_REV_1G10G(x) ((x) << S_REV_1G10G)
-#define G_REV_1G10G(x) (((x) >> S_REV_1G10G) & M_REV_1G10G)
-
-#define A_MAC_PORT_MTIP_SGMII_STATUS 0xd04
-
-#define S_100BASET4 15
-#define V_100BASET4(x) ((x) << S_100BASET4)
-#define F_100BASET4 V_100BASET4(1U)
-
-#define S_100BASEXFULLDPLX 14
-#define V_100BASEXFULLDPLX(x) ((x) << S_100BASEXFULLDPLX)
-#define F_100BASEXFULLDPLX V_100BASEXFULLDPLX(1U)
-
-#define S_100BASEXHALFDPLX 13
-#define V_100BASEXHALFDPLX(x) ((x) << S_100BASEXHALFDPLX)
-#define F_100BASEXHALFDPLX V_100BASEXHALFDPLX(1U)
-
-#define S_10MBPSFULLDPLX 12
-#define V_10MBPSFULLDPLX(x) ((x) << S_10MBPSFULLDPLX)
-#define F_10MBPSFULLDPLX V_10MBPSFULLDPLX(1U)
-
-#define S_10MBPSHALFDPLX 11
-#define V_10MBPSHALFDPLX(x) ((x) << S_10MBPSHALFDPLX)
-#define F_10MBPSHALFDPLX V_10MBPSHALFDPLX(1U)
-
-#define S_100BASET2FULLDPLX 10
-#define V_100BASET2FULLDPLX(x) ((x) << S_100BASET2FULLDPLX)
-#define F_100BASET2FULLDPLX V_100BASET2FULLDPLX(1U)
-
-#define S_100BASET2HALFDPLX 9
-#define V_100BASET2HALFDPLX(x) ((x) << S_100BASET2HALFDPLX)
-#define F_100BASET2HALFDPLX V_100BASET2HALFDPLX(1U)
-
-#define S_EXTDSTATUS 8
-#define V_EXTDSTATUS(x) ((x) << S_EXTDSTATUS)
-#define F_EXTDSTATUS V_EXTDSTATUS(1U)
-
-#define S_SGMII_REM_FAULT 4
-#define V_SGMII_REM_FAULT(x) ((x) << S_SGMII_REM_FAULT)
-#define F_SGMII_REM_FAULT V_SGMII_REM_FAULT(1U)
-
-#define S_JABBERDETECT 1
-#define V_JABBERDETECT(x) ((x) << S_JABBERDETECT)
-#define F_JABBERDETECT V_JABBERDETECT(1U)
-
-#define S_EXTDCAPABILITY 0
-#define V_EXTDCAPABILITY(x) ((x) << S_EXTDCAPABILITY)
-#define F_EXTDCAPABILITY V_EXTDCAPABILITY(1U)
-
-#define A_MAC_PORT_MTIP_1G10G_SCRATCH 0xd04
-#define A_MAC_PORT_MTIP_SGMII_PHY_IDENTIFIER_0 0xd08
-#define A_MAC_PORT_MTIP_1G10G_COMMAND_CONFIG 0xd08
-
-#define S_SHORT_DISCARD 25
-#define V_SHORT_DISCARD(x) ((x) << S_SHORT_DISCARD)
-#define F_SHORT_DISCARD V_SHORT_DISCARD(1U)
-
-#define S_REG_LOWP_RXEMPTY 24
-#define V_REG_LOWP_RXEMPTY(x) ((x) << S_REG_LOWP_RXEMPTY)
-#define F_REG_LOWP_RXEMPTY V_REG_LOWP_RXEMPTY(1U)
-
-#define S_TX_LOWP_ENA 23
-#define V_TX_LOWP_ENA(x) ((x) << S_TX_LOWP_ENA)
-#define F_TX_LOWP_ENA V_TX_LOWP_ENA(1U)
-
-#define S_TX_FLUSH_EN 22
-#define V_TX_FLUSH_EN(x) ((x) << S_TX_FLUSH_EN)
-#define F_TX_FLUSH_EN V_TX_FLUSH_EN(1U)
-
-#define S_SFD_ANY 21
-#define V_SFD_ANY(x) ((x) << S_SFD_ANY)
-#define F_SFD_ANY V_SFD_ANY(1U)
-
-#define S_COL_CNT_EXT 18
-#define V_COL_CNT_EXT(x) ((x) << S_COL_CNT_EXT)
-#define F_COL_CNT_EXT V_COL_CNT_EXT(1U)
-
-#define S_FORCE_SEND_IDLE 16
-#define V_FORCE_SEND_IDLE(x) ((x) << S_FORCE_SEND_IDLE)
-#define F_FORCE_SEND_IDLE V_FORCE_SEND_IDLE(1U)
-
-#define S_CNTL_FRM_ENA 13
-#define V_CNTL_FRM_ENA(x) ((x) << S_CNTL_FRM_ENA)
-#define F_CNTL_FRM_ENA V_CNTL_FRM_ENA(1U)
-
-#define S_RX_ENAMAC 1
-#define V_RX_ENAMAC(x) ((x) << S_RX_ENAMAC)
-#define F_RX_ENAMAC V_RX_ENAMAC(1U)
-
-#define S_TX_ENAMAC 0
-#define V_TX_ENAMAC(x) ((x) << S_TX_ENAMAC)
-#define F_TX_ENAMAC V_TX_ENAMAC(1U)
-
-#define A_MAC_PORT_MTIP_SGMII_PHY_IDENTIFIER_1 0xd0c
-#define A_MAC_PORT_MTIP_1G10G_MAC_ADDR_0 0xd0c
-#define A_MAC_PORT_MTIP_SGMII_DEV_ABILITY 0xd10
-
-#define S_RF2 13
-#define V_RF2(x) ((x) << S_RF2)
-#define F_RF2 V_RF2(1U)
-
-#define S_RF1 12
-#define V_RF1(x) ((x) << S_RF1)
-#define F_RF1 V_RF1(1U)
-
-#define S_PS2 8
-#define V_PS2(x) ((x) << S_PS2)
-#define F_PS2 V_PS2(1U)
-
-#define S_PS1 7
-#define V_PS1(x) ((x) << S_PS1)
-#define F_PS1 V_PS1(1U)
-
-#define S_HD 6
-#define V_HD(x) ((x) << S_HD)
-#define F_HD V_HD(1U)
-
-#define S_FD 5
-#define V_FD(x) ((x) << S_FD)
-#define F_FD V_FD(1U)
-
-#define A_MAC_PORT_MTIP_1G10G_MAC_ADDR_1 0xd10
-#define A_MAC_PORT_MTIP_SGMII_PARTNER_ABILITY 0xd14
-
-#define S_CULINKSTATUS 15
-#define V_CULINKSTATUS(x) ((x) << S_CULINKSTATUS)
-#define F_CULINKSTATUS V_CULINKSTATUS(1U)
-
-#define S_CUDPLXSTATUS 12
-#define V_CUDPLXSTATUS(x) ((x) << S_CUDPLXSTATUS)
-#define F_CUDPLXSTATUS V_CUDPLXSTATUS(1U)
-
-#define S_CUSPEED 10
-#define M_CUSPEED 0x3U
-#define V_CUSPEED(x) ((x) << S_CUSPEED)
-#define G_CUSPEED(x) (((x) >> S_CUSPEED) & M_CUSPEED)
-
-#define A_MAC_PORT_MTIP_1G10G_FRM_LENGTH_TX_MTU 0xd14
-
-#define S_SET_LEN 16
-#define M_SET_LEN 0xffffU
-#define V_SET_LEN(x) ((x) << S_SET_LEN)
-#define G_SET_LEN(x) (((x) >> S_SET_LEN) & M_SET_LEN)
-
-#define S_FRM_LEN_SET 0
-#define M_FRM_LEN_SET 0xffffU
-#define V_FRM_LEN_SET(x) ((x) << S_FRM_LEN_SET)
-#define G_FRM_LEN_SET(x) (((x) >> S_FRM_LEN_SET) & M_FRM_LEN_SET)
-
-#define A_MAC_PORT_MTIP_SGMII_AN_EXPANSION 0xd18
-
-#define S_PGRCVD 1
-#define V_PGRCVD(x) ((x) << S_PGRCVD)
-#define F_PGRCVD V_PGRCVD(1U)
-
-#define S_REALTIMEPGRCVD 0
-#define V_REALTIMEPGRCVD(x) ((x) << S_REALTIMEPGRCVD)
-#define F_REALTIMEPGRCVD V_REALTIMEPGRCVD(1U)
-
-#define A_MAC_PORT_MTIP_SGMII_DEVICE_NP 0xd1c
-#define A_MAC_PORT_MTIP_1G10G_RX_FIFO_SECTIONS 0xd1c
-
-#define S_RX1G10G_EMPTY 16
-#define M_RX1G10G_EMPTY 0xffffU
-#define V_RX1G10G_EMPTY(x) ((x) << S_RX1G10G_EMPTY)
-#define G_RX1G10G_EMPTY(x) (((x) >> S_RX1G10G_EMPTY) & M_RX1G10G_EMPTY)
-
-#define S_RX1G10G_AVAIL 0
-#define M_RX1G10G_AVAIL 0xffffU
-#define V_RX1G10G_AVAIL(x) ((x) << S_RX1G10G_AVAIL)
-#define G_RX1G10G_AVAIL(x) (((x) >> S_RX1G10G_AVAIL) & M_RX1G10G_AVAIL)
-
-#define A_MAC_PORT_MTIP_SGMII_PARTNER_NP 0xd20
-#define A_MAC_PORT_MTIP_1G10G_TX_FIFO_SECTIONS 0xd20
-
-#define S_TX1G10G_EMPTY 16
-#define M_TX1G10G_EMPTY 0xffffU
-#define V_TX1G10G_EMPTY(x) ((x) << S_TX1G10G_EMPTY)
-#define G_TX1G10G_EMPTY(x) (((x) >> S_TX1G10G_EMPTY) & M_TX1G10G_EMPTY)
-
-#define S_TX1G10G_AVAIL 0
-#define M_TX1G10G_AVAIL 0xffffU
-#define V_TX1G10G_AVAIL(x) ((x) << S_TX1G10G_AVAIL)
-#define G_TX1G10G_AVAIL(x) (((x) >> S_TX1G10G_AVAIL) & M_TX1G10G_AVAIL)
-
-#define A_MAC_PORT_MTIP_1G10G_RX_FIFO_ALMOST_F_E 0xd24
-
-#define S_ALMOSTFULL 16
-#define M_ALMOSTFULL 0xffffU
-#define V_ALMOSTFULL(x) ((x) << S_ALMOSTFULL)
-#define G_ALMOSTFULL(x) (((x) >> S_ALMOSTFULL) & M_ALMOSTFULL)
-
-#define S_ALMOSTEMPTY 0
-#define M_ALMOSTEMPTY 0xffffU
-#define V_ALMOSTEMPTY(x) ((x) << S_ALMOSTEMPTY)
-#define G_ALMOSTEMPTY(x) (((x) >> S_ALMOSTEMPTY) & M_ALMOSTEMPTY)
-
-#define A_MAC_PORT_MTIP_1G10G_TX_FIFO_ALMOST_F_E 0xd28
-#define A_MAC_PORT_MTIP_1G10G_HASHTABLE_LOAD 0xd2c
-#define A_MAC_PORT_MTIP_1G10G_MDIO_CFG_STATUS 0xd30
-
-#define S_CLK_DIVISOR 7
-#define M_CLK_DIVISOR 0x1ffU
-#define V_CLK_DIVISOR(x) ((x) << S_CLK_DIVISOR)
-#define G_CLK_DIVISOR(x) (((x) >> S_CLK_DIVISOR) & M_CLK_DIVISOR)
-
-#define S_ENA_CLAUSE 6
-#define V_ENA_CLAUSE(x) ((x) << S_ENA_CLAUSE)
-#define F_ENA_CLAUSE V_ENA_CLAUSE(1U)
-
-#define S_PREAMBLE_DISABLE 5
-#define V_PREAMBLE_DISABLE(x) ((x) << S_PREAMBLE_DISABLE)
-#define F_PREAMBLE_DISABLE V_PREAMBLE_DISABLE(1U)
-
-#define S_HOLD_TIME_SETTING 2
-#define M_HOLD_TIME_SETTING 0x7U
-#define V_HOLD_TIME_SETTING(x) ((x) << S_HOLD_TIME_SETTING)
-#define G_HOLD_TIME_SETTING(x) (((x) >> S_HOLD_TIME_SETTING) & M_HOLD_TIME_SETTING)
-
-#define S_MDIO_READ_ERROR 1
-#define V_MDIO_READ_ERROR(x) ((x) << S_MDIO_READ_ERROR)
-#define F_MDIO_READ_ERROR V_MDIO_READ_ERROR(1U)
-
-#define A_MAC_PORT_MTIP_1G10G_MDIO_COMMAND 0xd34
-
-#define S_READ_MODE 15
-#define V_READ_MODE(x) ((x) << S_READ_MODE)
-#define F_READ_MODE V_READ_MODE(1U)
-
-#define S_POST_INCR_READ 14
-#define V_POST_INCR_READ(x) ((x) << S_POST_INCR_READ)
-#define F_POST_INCR_READ V_POST_INCR_READ(1U)
-
-#define S_PORT_PHY_ADDR 5
-#define M_PORT_PHY_ADDR 0x1fU
-#define V_PORT_PHY_ADDR(x) ((x) << S_PORT_PHY_ADDR)
-#define G_PORT_PHY_ADDR(x) (((x) >> S_PORT_PHY_ADDR) & M_PORT_PHY_ADDR)
-
-#define S_DEVICE_REG_ADDR 0
-#define M_DEVICE_REG_ADDR 0x1fU
-#define V_DEVICE_REG_ADDR(x) ((x) << S_DEVICE_REG_ADDR)
-#define G_DEVICE_REG_ADDR(x) (((x) >> S_DEVICE_REG_ADDR) & M_DEVICE_REG_ADDR)
-
-#define A_MAC_PORT_MTIP_1G10G_MDIO_DATA 0xd38
-
-#define S_MDIO_DATA 0
-#define M_MDIO_DATA 0xffffU
-#define V_MDIO_DATA(x) ((x) << S_MDIO_DATA)
-#define G_MDIO_DATA(x) (((x) >> S_MDIO_DATA) & M_MDIO_DATA)
-
-#define A_MAC_PORT_MTIP_SGMII_EXTENDED_STATUS 0xd3c
-#define A_MAC_PORT_MTIP_1G10G_MDIO_REGADDR 0xd3c
-#define A_MAC_PORT_MTIP_1G10G_STATUS 0xd40
-
-#define S_RX_LINT_FAULT 7
-#define V_RX_LINT_FAULT(x) ((x) << S_RX_LINT_FAULT)
-#define F_RX_LINT_FAULT V_RX_LINT_FAULT(1U)
-
-#define S_RX_EMPTY 6
-#define V_RX_EMPTY(x) ((x) << S_RX_EMPTY)
-#define F_RX_EMPTY V_RX_EMPTY(1U)
-
-#define S_TX_EMPTY 5
-#define V_TX_EMPTY(x) ((x) << S_TX_EMPTY)
-#define F_TX_EMPTY V_TX_EMPTY(1U)
-
-#define S_RX_LOWP 4
-#define V_RX_LOWP(x) ((x) << S_RX_LOWP)
-#define F_RX_LOWP V_RX_LOWP(1U)
-
-#define A_MAC_PORT_MTIP_1G10G_TX_IPG_LENGTH 0xd44
-#define A_MAC_PORT_MTIP_SGMII_LINK_TIMER_LO 0xd48
-
-#define S_COUNT_LO 0
-#define M_COUNT_LO 0xffffU
-#define V_COUNT_LO(x) ((x) << S_COUNT_LO)
-#define G_COUNT_LO(x) (((x) >> S_COUNT_LO) & M_COUNT_LO)
-
-#define A_MAC_PORT_MTIP_1G10G_CREDIT_TRIGGER 0xd48
-#define A_MAC_PORT_MTIP_SGMII_LINK_TIMER_HI 0xd4c
-
-#define S_COUNT_HI 0
-#define M_COUNT_HI 0x1fU
-#define V_COUNT_HI(x) ((x) << S_COUNT_HI)
-#define G_COUNT_HI(x) (((x) >> S_COUNT_HI) & M_COUNT_HI)
-
-#define A_MAC_PORT_MTIP_1G10G_INIT_CREDIT 0xd4c
-#define A_MAC_PORT_MTIP_SGMII_IF_MODE 0xd50
-
-#define S_SGMII_PCS_ENABLE 5
-#define V_SGMII_PCS_ENABLE(x) ((x) << S_SGMII_PCS_ENABLE)
-#define F_SGMII_PCS_ENABLE V_SGMII_PCS_ENABLE(1U)
-
-#define S_SGMII_HDUPLEX 4
-#define V_SGMII_HDUPLEX(x) ((x) << S_SGMII_HDUPLEX)
-#define F_SGMII_HDUPLEX V_SGMII_HDUPLEX(1U)
-
-#define S_SGMII_SPEED 2
-#define M_SGMII_SPEED 0x3U
-#define V_SGMII_SPEED(x) ((x) << S_SGMII_SPEED)
-#define G_SGMII_SPEED(x) (((x) >> S_SGMII_SPEED) & M_SGMII_SPEED)
-
-#define S_USE_SGMII_AN 1
-#define V_USE_SGMII_AN(x) ((x) << S_USE_SGMII_AN)
-#define F_USE_SGMII_AN V_USE_SGMII_AN(1U)
-
-#define S_SGMII_ENA 0
-#define V_SGMII_ENA(x) ((x) << S_SGMII_ENA)
-#define F_SGMII_ENA V_SGMII_ENA(1U)
-
-#define A_MAC_PORT_MTIP_1G10G_CL01_PAUSE_QUANTA 0xd54
-
-#define S_CL1_PAUSE_QUANTA 16
-#define M_CL1_PAUSE_QUANTA 0xffffU
-#define V_CL1_PAUSE_QUANTA(x) ((x) << S_CL1_PAUSE_QUANTA)
-#define G_CL1_PAUSE_QUANTA(x) (((x) >> S_CL1_PAUSE_QUANTA) & M_CL1_PAUSE_QUANTA)
-
-#define S_CL0_PAUSE_QUANTA 0
-#define M_CL0_PAUSE_QUANTA 0xffffU
-#define V_CL0_PAUSE_QUANTA(x) ((x) << S_CL0_PAUSE_QUANTA)
-#define G_CL0_PAUSE_QUANTA(x) (((x) >> S_CL0_PAUSE_QUANTA) & M_CL0_PAUSE_QUANTA)
-
-#define A_MAC_PORT_MTIP_1G10G_CL23_PAUSE_QUANTA 0xd58
-
-#define S_CL3_PAUSE_QUANTA 16
-#define M_CL3_PAUSE_QUANTA 0xffffU
-#define V_CL3_PAUSE_QUANTA(x) ((x) << S_CL3_PAUSE_QUANTA)
-#define G_CL3_PAUSE_QUANTA(x) (((x) >> S_CL3_PAUSE_QUANTA) & M_CL3_PAUSE_QUANTA)
-
-#define S_CL2_PAUSE_QUANTA 0
-#define M_CL2_PAUSE_QUANTA 0xffffU
-#define V_CL2_PAUSE_QUANTA(x) ((x) << S_CL2_PAUSE_QUANTA)
-#define G_CL2_PAUSE_QUANTA(x) (((x) >> S_CL2_PAUSE_QUANTA) & M_CL2_PAUSE_QUANTA)
-
-#define A_MAC_PORT_MTIP_1G10G_CL45_PAUSE_QUANTA 0xd5c
-
-#define S_CL5_PAUSE_QUANTA 16
-#define M_CL5_PAUSE_QUANTA 0xffffU
-#define V_CL5_PAUSE_QUANTA(x) ((x) << S_CL5_PAUSE_QUANTA)
-#define G_CL5_PAUSE_QUANTA(x) (((x) >> S_CL5_PAUSE_QUANTA) & M_CL5_PAUSE_QUANTA)
-
-#define S_CL4_PAUSE_QUANTA 0
-#define M_CL4_PAUSE_QUANTA 0xffffU
-#define V_CL4_PAUSE_QUANTA(x) ((x) << S_CL4_PAUSE_QUANTA)
-#define G_CL4_PAUSE_QUANTA(x) (((x) >> S_CL4_PAUSE_QUANTA) & M_CL4_PAUSE_QUANTA)
-
-#define A_MAC_PORT_MTIP_1G10G_CL67_PAUSE_QUANTA 0xd60
-
-#define S_CL7_PAUSE_QUANTA 16
-#define M_CL7_PAUSE_QUANTA 0xffffU
-#define V_CL7_PAUSE_QUANTA(x) ((x) << S_CL7_PAUSE_QUANTA)
-#define G_CL7_PAUSE_QUANTA(x) (((x) >> S_CL7_PAUSE_QUANTA) & M_CL7_PAUSE_QUANTA)
-
-#define S_CL6_PAUSE_QUANTA 0
-#define M_CL6_PAUSE_QUANTA 0xffffU
-#define V_CL6_PAUSE_QUANTA(x) ((x) << S_CL6_PAUSE_QUANTA)
-#define G_CL6_PAUSE_QUANTA(x) (((x) >> S_CL6_PAUSE_QUANTA) & M_CL6_PAUSE_QUANTA)
-
-#define A_MAC_PORT_MTIP_1G10G_CL01_QUANTA_THRESH 0xd64
-
-#define S_CL1_QUANTA_THRESH 16
-#define M_CL1_QUANTA_THRESH 0xffffU
-#define V_CL1_QUANTA_THRESH(x) ((x) << S_CL1_QUANTA_THRESH)
-#define G_CL1_QUANTA_THRESH(x) (((x) >> S_CL1_QUANTA_THRESH) & M_CL1_QUANTA_THRESH)
-
-#define S_CL0_QUANTA_THRESH 0
-#define M_CL0_QUANTA_THRESH 0xffffU
-#define V_CL0_QUANTA_THRESH(x) ((x) << S_CL0_QUANTA_THRESH)
-#define G_CL0_QUANTA_THRESH(x) (((x) >> S_CL0_QUANTA_THRESH) & M_CL0_QUANTA_THRESH)
-
-#define A_MAC_PORT_MTIP_1G10G_CL23_QUANTA_THRESH 0xd68
-
-#define S_CL3_QUANTA_THRESH 16
-#define M_CL3_QUANTA_THRESH 0xffffU
-#define V_CL3_QUANTA_THRESH(x) ((x) << S_CL3_QUANTA_THRESH)
-#define G_CL3_QUANTA_THRESH(x) (((x) >> S_CL3_QUANTA_THRESH) & M_CL3_QUANTA_THRESH)
-
-#define S_CL2_QUANTA_THRESH 0
-#define M_CL2_QUANTA_THRESH 0xffffU
-#define V_CL2_QUANTA_THRESH(x) ((x) << S_CL2_QUANTA_THRESH)
-#define G_CL2_QUANTA_THRESH(x) (((x) >> S_CL2_QUANTA_THRESH) & M_CL2_QUANTA_THRESH)
-
-#define A_MAC_PORT_MTIP_1G10G_CL45_QUANTA_THRESH 0xd6c
-
-#define S_CL5_QUANTA_THRESH 16
-#define M_CL5_QUANTA_THRESH 0xffffU
-#define V_CL5_QUANTA_THRESH(x) ((x) << S_CL5_QUANTA_THRESH)
-#define G_CL5_QUANTA_THRESH(x) (((x) >> S_CL5_QUANTA_THRESH) & M_CL5_QUANTA_THRESH)
-
-#define S_CL4_QUANTA_THRESH 0
-#define M_CL4_QUANTA_THRESH 0xffffU
-#define V_CL4_QUANTA_THRESH(x) ((x) << S_CL4_QUANTA_THRESH)
-#define G_CL4_QUANTA_THRESH(x) (((x) >> S_CL4_QUANTA_THRESH) & M_CL4_QUANTA_THRESH)
-
-#define A_MAC_PORT_MTIP_1G10G_CL67_QUANTA_THRESH 0xd70
-
-#define S_CL7_QUANTA_THRESH 16
-#define M_CL7_QUANTA_THRESH 0xffffU
-#define V_CL7_QUANTA_THRESH(x) ((x) << S_CL7_QUANTA_THRESH)
-#define G_CL7_QUANTA_THRESH(x) (((x) >> S_CL7_QUANTA_THRESH) & M_CL7_QUANTA_THRESH)
-
-#define S_CL6_QUANTA_THRESH 0
-#define M_CL6_QUANTA_THRESH 0xffffU
-#define V_CL6_QUANTA_THRESH(x) ((x) << S_CL6_QUANTA_THRESH)
-#define G_CL6_QUANTA_THRESH(x) (((x) >> S_CL6_QUANTA_THRESH) & M_CL6_QUANTA_THRESH)
-
-#define A_MAC_PORT_MTIP_1G10G_RX_PAUSE_STATUS 0xd74
-
-#define S_STATUS_BIT 0
-#define M_STATUS_BIT 0xffU
-#define V_STATUS_BIT(x) ((x) << S_STATUS_BIT)
-#define G_STATUS_BIT(x) (((x) >> S_STATUS_BIT) & M_STATUS_BIT)
-
-#define A_MAC_PORT_MTIP_1G10G_TS_TIMESTAMP 0xd7c
-#define A_MAC_PORT_MTIP_1G10G_STATN_CONFIG 0xde0
-
-#define S_CLEAR 2
-#define V_CLEAR(x) ((x) << S_CLEAR)
-#define F_CLEAR V_CLEAR(1U)
-
-#define S_CLEAR_ON_READ 1
-#define V_CLEAR_ON_READ(x) ((x) << S_CLEAR_ON_READ)
-#define F_CLEAR_ON_READ V_CLEAR_ON_READ(1U)
-
-#define S_SATURATE 0
-#define V_SATURATE(x) ((x) << S_SATURATE)
-#define F_SATURATE V_SATURATE(1U)
-
-#define A_MAC_PORT_MTIP_1G10G_RX_ETHERSTATSOCTETS 0xe00
-#define A_MAC_PORT_MTIP_1G10G_RX_ETHERSTATSOCTETSHI 0xe04
-#define A_MAC_PORT_MTIP_1G10G_RX_OCTETSOK 0xe08
-#define A_MAC_PORT_MTIP_1G10G_RX_OCTETSOKHI 0xe0c
-#define A_MAC_PORT_MTIP_1G10G_RX_AALIGNMENTERRORS 0xe10
-#define A_MAC_PORT_MTIP_1G10G_RX_AALIGNMENTERRORSHI 0xe14
-#define A_MAC_PORT_MTIP_1G10G_RX_APAUSEMACCTRLFRAMES 0xe18
-#define A_MAC_PORT_MTIP_1G10G_RX_APAUSEMACCTRLFRAMESHI 0xe1c
-#define A_MAC_PORT_MTIP_1G10G_RX_FRAMESOK 0xe20
-#define A_MAC_PORT_MTIP_1G10G_RX_FRAMESOKHI 0xe24
-#define A_MAC_PORT_MTIP_1G10G_RX_CRCERRORS 0xe28
-#define A_MAC_PORT_MTIP_1G10G_RX_CRCERRORSHI 0xe2c
-#define A_MAC_PORT_MTIP_1G10G_RX_VLANOK 0xe30
-#define A_MAC_PORT_MTIP_1G10G_RX_VLANOKHI 0xe34
-#define A_MAC_PORT_MTIP_1G10G_RX_IFINERRORS 0xe38
-#define A_MAC_PORT_MTIP_1G10G_RX_IFINERRORSHI 0xe3c
-#define A_MAC_PORT_MTIP_1G10G_RX_IFINUCASTPKTS 0xe40
-#define A_MAC_PORT_MTIP_1G10G_RX_IFINUCASTPKTSHI 0xe44
-#define A_MAC_PORT_MTIP_1G10G_RX_IFINMULTICASTPKTS 0xe48
-#define A_MAC_PORT_MTIP_1G10G_RX_IFINMULTICASTPKTSHI 0xe4c
-#define A_MAC_PORT_MTIP_1G10G_RX_IFINBROADCASTPKTS 0xe50
-#define A_MAC_PORT_MTIP_1G10G_RX_IFINBROADCASTPKTSHI 0xe54
-#define A_MAC_PORT_MTIP_1G10G_RX_ETHERSTATSDROPEVENTS 0xe58
-#define A_MAC_PORT_MTIP_1G10G_RX_ETHERSTATSDROPEVENTSHI 0xe5c
-#define A_MAC_PORT_MTIP_1G10G_RX_ETHERSTATSPKTS 0xe60
-#define A_MAC_PORT_MTIP_1G10G_RX_ETHERSTATSPKTSHI 0xe64
-#define A_MAC_PORT_MTIP_1G10G_RX_ETHERSTATSUNDERSIZEPKTS 0xe68
-#define A_MAC_PORT_MTIP_1G10G_RX_ETHERSTATSUNDERSIZEPKTSHI 0xe6c
-#define A_MAC_PORT_MTIP_1G10G_RX_ETHERSTATSPKTS64OCTETS 0xe70
-#define A_MAC_PORT_MTIP_1G10G_RX_ETHERSTATSPKTS64OCTETSHI 0xe74
-#define A_MAC_PORT_MTIP_1G10G_RX_ETHERSTATSPKTS65TO127OCTETS 0xe78
-#define A_MAC_PORT_MTIP_1G10G_RX_ETHERSTATSPKTS65TO127OCTETSHI 0xe7c
-#define A_MAC_PORT_MTIP_1G10G_RX_ETHERSTATSPKTS128TO255OCTETS 0xe80
-#define A_MAC_PORT_MTIP_1G10G_RX_ETHERSTATSPKTS128TO255OCTETSHI 0xe84
-#define A_MAC_PORT_MTIP_1G10G_RX_ETHERSTATSPKTS256TO511OCTETS 0xe88
-#define A_MAC_PORT_MTIP_1G10G_RX_ETHERSTATSPKTS256TO511OCTETSHI 0xe8c
-#define A_MAC_PORT_MTIP_1G10G_RX_ETHERSTATSPKTS512TO1023OCTETS 0xe90
-#define A_MAC_PORT_MTIP_1G10G_RX_ETHERSTATSPKTS512TO1023OCTETSHI 0xe94
-#define A_MAC_PORT_MTIP_1G10G_RX_ETHERSTATSPKTS1024TO1518OCTETS 0xe98
-#define A_MAC_PORT_MTIP_1G10G_RX_ETHERSTATSPKTS1024TO1518OCTETSHI 0xe9c
-#define A_MAC_PORT_MTIP_1G10G_RX_ETHERSTATSPKTS1519TOMAX 0xea0
-#define A_MAC_PORT_MTIP_1G10G_RX_ETHERSTATSPKTS1519TOMAXHI 0xea4
-#define A_MAC_PORT_MTIP_1G10G_RX_ETHERSTATSOVERSIZEPKTS 0xea8
-#define A_MAC_PORT_MTIP_1G10G_RX_ETHERSTATSOVERSIZEPKTSHI 0xeac
-#define A_MAC_PORT_MTIP_1G10G_RX_ETHERSTATSJABBERS 0xeb0
-#define A_MAC_PORT_MTIP_1G10G_RX_ETHERSTATSJABBERSHI 0xeb4
-#define A_MAC_PORT_MTIP_1G10G_RX_ETHERSTATSFRAGMENTS 0xeb8
-#define A_MAC_PORT_MTIP_1G10G_RX_ETHERSTATSFRAGMENTSHI 0xebc
-#define A_MAC_PORT_MTIP_1G10G_AMACCONTROLFRAMESRECEIVED 0xec0
-#define A_MAC_PORT_MTIP_1G10G_AMACCONTROLFRAMESRECEIVEDHI 0xec4
-#define A_MAC_PORT_MTIP_1G10G_RX_AFRAMETOOLONG 0xec8
-#define A_MAC_PORT_MTIP_1G10G_RX_AFRAMETOOLONGHI 0xecc
-#define A_MAC_PORT_MTIP_1G10G_RX_AINRANGELENGTHERRORS 0xed0
-#define A_MAC_PORT_MTIP_1G10G_RX_AINRANGELENGTHERRORSHI 0xed4
-#define A_MAC_PORT_MTIP_1G10G_TX_ETHERSTATSOCTETS 0xf00
-#define A_MAC_PORT_MTIP_1G10G_TX_ETHERSTATSOCTETSHI 0xf04
-#define A_MAC_PORT_MTIP_1G10G_TX_OCTETSOK 0xf08
-#define A_MAC_PORT_MTIP_1G10G_TX_OCTETSOKHI 0xf0c
-#define A_MAC_PORT_MTIP_1G10G_TX_AALIGNMENTERRORS 0xf10
-#define A_MAC_PORT_MTIP_1G10G_TX_AALIGNMENTERRORSHI 0xf14
-#define A_MAC_PORT_MTIP_1G10G_TX_APAUSEMACCTRLFRAMES 0xf18
-#define A_MAC_PORT_MTIP_1G10G_TX_APAUSEMACCTRLFRAMESHI 0xf1c
-#define A_MAC_PORT_MTIP_1G10G_TX_FRAMESOK 0xf20
-#define A_MAC_PORT_MTIP_1G10G_TX_FRAMESOKHI 0xf24
-#define A_MAC_PORT_MTIP_1G10G_TX_CRCERRORS 0xf28
-#define A_MAC_PORT_MTIP_1G10G_TX_CRCERRORSHI 0xf2c
-#define A_MAC_PORT_MTIP_1G10G_TX_VLANOK 0xf30
-#define A_MAC_PORT_MTIP_1G10G_TX_VLANOKHI 0xf34
-#define A_MAC_PORT_MTIP_1G10G_TX_IFOUTERRORS 0xf38
-#define A_MAC_PORT_MTIP_1G10G_TX_IFOUTERRORSHI 0xf3c
-#define A_MAC_PORT_MTIP_1G10G_TX_IFUCASTPKTS 0xf40
-#define A_MAC_PORT_MTIP_1G10G_TX_IFUCASTPKTSHI 0xf44
-#define A_MAC_PORT_MTIP_1G10G_TX_IFMULTICASTPKTS 0xf48
-#define A_MAC_PORT_MTIP_1G10G_TX_IFMULTICASTPKTSHI 0xf4c
-#define A_MAC_PORT_MTIP_1G10G_TX_IFBROADCASTPKTS 0xf50
-#define A_MAC_PORT_MTIP_1G10G_TX_IFBROADCASTPKTSHI 0xf54
-#define A_MAC_PORT_MTIP_1G10G_TX_ETHERSTATSDROPEVENTS 0xf58
-#define A_MAC_PORT_MTIP_1G10G_TX_ETHERSTATSDROPEVENTSHI 0xf5c
-#define A_MAC_PORT_MTIP_1G10G_TX_ETHERSTATSPKTS 0xf60
-#define A_MAC_PORT_MTIP_1G10G_TX_ETHERSTATSPKTSHI 0xf64
-#define A_MAC_PORT_MTIP_1G10G_TX_ETHERSTATSUNDERSIZEPKTS 0xf68
-#define A_MAC_PORT_MTIP_1G10G_TX_ETHERSTATSUNDERSIZEPKTSHI 0xf6c
-#define A_MAC_PORT_MTIP_1G10G_TX_ETHERSTATSPKTS64OCTETS 0xf70
-#define A_MAC_PORT_MTIP_1G10G_TX_ETHERSTATSPKTS64OCTETSHI 0xf74
-#define A_MAC_PORT_MTIP_1G10G_TX_ETHERSTATSPKTS65TO127OCTETS 0xf78
-#define A_MAC_PORT_MTIP_1G10G_TX_ETHERSTATSPKTS65TO127OCTETSHI 0xf7c
-#define A_MAC_PORT_MTIP_1G10G_TX_ETHERSTATSPKTS128TO255OCTETS 0xf80
-#define A_MAC_PORT_MTIP_1G10G_TX_ETHERSTATSPKTS128TO255OCTETSHI 0xf84
-#define A_MAC_PORT_MTIP_1G10G_TX_ETHERSTATSPKTS256TO511OCTETS 0xf88
-#define A_MAC_PORT_MTIP_1G10G_TX_ETHERSTATSPKTS256TO511OCTETSHI 0xf8c
-#define A_MAC_PORT_MTIP_1G10G_TX_ETHERSTATSPKTS512TO1023OCTETS 0xf90
-#define A_MAC_PORT_MTIP_1G10G_TX_ETHERSTATSPKTS512TO1023OCTETSHI 0xf94
-#define A_MAC_PORT_MTIP_1G10G_TX_ETHERSTATSPKTS1024TO1518OCTETS 0xf98
-#define A_MAC_PORT_MTIP_1G10G_TX_ETHERSTATSPKTS1024TO1518OCTETSHI 0xf9c
-#define A_MAC_PORT_MTIP_1G10G_ETHERSTATSPKTS1519TOTX_MTU 0xfa0
-#define A_MAC_PORT_MTIP_1G10G_ETHERSTATSPKTS1519TOTX_MTUHI 0xfa4
-#define A_MAC_PORT_MTIP_1G10G_TX_AMACCONTROLFRAMES 0xfc0
-#define A_MAC_PORT_MTIP_1G10G_TX_AMACCONTROLFRAMESHI 0xfc4
-#define A_MAC_PORT_MTIP_1G10G_IF_MODE 0x1000
-
-#define S_MII_ENA_10 4
-#define V_MII_ENA_10(x) ((x) << S_MII_ENA_10)
-#define F_MII_ENA_10 V_MII_ENA_10(1U)
-
-#define S_IF_MODE 0
-#define M_IF_MODE 0x3U
-#define V_IF_MODE(x) ((x) << S_IF_MODE)
-#define G_IF_MODE(x) (((x) >> S_IF_MODE) & M_IF_MODE)
-
-#define A_MAC_PORT_MTIP_1G10G_IF_STATUS 0x1004
-
-#define S_IF_STATUS_MODE 0
-#define M_IF_STATUS_MODE 0x3U
-#define V_IF_STATUS_MODE(x) ((x) << S_IF_STATUS_MODE)
-#define G_IF_STATUS_MODE(x) (((x) >> S_IF_STATUS_MODE) & M_IF_STATUS_MODE)
-
-#define A_MAC_PORT_MTIP_1G10G_PFCFRAMESRECEIVED_0 0x1080
-#define A_MAC_PORT_MTIP_1G10G_PFCFRAMESRECEIVED_0HI 0x1084
-#define A_MAC_PORT_MTIP_1G10G_PFCFRAMESRECEIVED_1 0x1088
-#define A_MAC_PORT_MTIP_1G10G_PFCFRAMESRECEIVED_1HI 0x108c
-#define A_MAC_PORT_MTIP_1G10G_PFCFRAMESRECEIVED_2 0x1090
-#define A_MAC_PORT_MTIP_1G10G_PFCFRAMESRECEIVED_2HI 0x1094
-#define A_MAC_PORT_MTIP_1G10G_PFCFRAMESRECEIVED_3 0x1098
-#define A_MAC_PORT_MTIP_1G10G_PFCFRAMESRECEIVED_3HI 0x109c
-#define A_MAC_PORT_MTIP_1G10G_PFCFRAMESRECEIVED_4 0x10a0
-#define A_MAC_PORT_MTIP_1G10G_PFCFRAMESRECEIVED_4HI 0x10a4
-#define A_MAC_PORT_MTIP_1G10G_PFCFRAMESRECEIVED_5 0x10a8
-#define A_MAC_PORT_MTIP_1G10G_PFCFRAMESRECEIVED_5HI 0x10ac
-#define A_MAC_PORT_MTIP_1G10G_PFCFRAMESRECEIVED_6 0x10b0
-#define A_MAC_PORT_MTIP_1G10G_PFCFRAMESRECEIVED_6HI 0x10b4
-#define A_MAC_PORT_MTIP_1G10G_PFCFRAMESRECEIVED_7 0x10b8
-#define A_MAC_PORT_MTIP_1G10G_PFCFRAMESRECEIVED_7HI 0x10bc
-#define A_MAC_PORT_MTIP_1G10G_PFCFRAMESTRANSMITTED_0 0x10c0
-#define A_MAC_PORT_MTIP_1G10G_PFCFRAMESTRANSMITTED_0HI 0x10c4
-#define A_MAC_PORT_MTIP_1G10G_PFCFRAMESTRANSMITTED_1 0x10c8
-#define A_MAC_PORT_MTIP_1G10G_PFCFRAMESTRANSMITTED_1HI 0x10cc
-#define A_MAC_PORT_MTIP_1G10G_PFCFRAMESTRANSMITTED_2 0x10d0
-#define A_MAC_PORT_MTIP_1G10G_PFCFRAMESTRANSMITTED_2HI 0x10d4
-#define A_MAC_PORT_MTIP_1G10G_PFCFRAMESTRANSMITTED_3 0x10d8
-#define A_MAC_PORT_MTIP_1G10G_PFCFRAMESTRANSMITTED_3HI 0x10dc
-#define A_MAC_PORT_MTIP_1G10G_PFCFRAMESTRANSMITTED_4 0x10e0
-#define A_MAC_PORT_MTIP_1G10G_PFCFRAMESTRANSMITTED_4HI 0x10e4
-#define A_MAC_PORT_MTIP_1G10G_PFCFRAMESTRANSMITTED_5 0x10e8
-#define A_MAC_PORT_MTIP_1G10G_PFCFRAMESTRANSMITTED_5HI 0x10ec
-#define A_MAC_PORT_MTIP_1G10G_PFCFRAMESTRANSMITTED_6 0x10f0
-#define A_MAC_PORT_MTIP_1G10G_PFCFRAMESTRANSMITTED_6HI 0x10f4
-#define A_MAC_PORT_MTIP_1G10G_PFCFRAMESTRANSMITTED_7 0x10f8
-#define A_MAC_PORT_MTIP_1G10G_PFCFRAMESTRANSMITTED_7HI 0x10fc
-#define A_MAC_PORT_MTIP_ACT_CTL_SEG 0x1200
-
-#define S_ACTIVE 0
-#define M_ACTIVE 0x3fU
-#define V_ACTIVE(x) ((x) << S_ACTIVE)
-#define G_ACTIVE(x) (((x) >> S_ACTIVE) & M_ACTIVE)
-
-#define A_T6_MAC_PORT_MTIP_SGMII_CONTROL 0x1200
-
-#define S_SPEED_SEL 13
-#define V_SPEED_SEL(x) ((x) << S_SPEED_SEL)
-#define F_SPEED_SEL V_SPEED_SEL(1U)
-
-#define S_PWR_DWN 11
-#define V_PWR_DWN(x) ((x) << S_PWR_DWN)
-#define F_PWR_DWN V_PWR_DWN(1U)
-
-#define S_DUPLEX_MODE 8
-#define V_DUPLEX_MODE(x) ((x) << S_DUPLEX_MODE)
-#define F_DUPLEX_MODE V_DUPLEX_MODE(1U)
-
-#define S_COLLISION_TEST 7
-#define V_COLLISION_TEST(x) ((x) << S_COLLISION_TEST)
-#define F_COLLISION_TEST V_COLLISION_TEST(1U)
-
-#define S_T6_SPEED_SEL1 6
-#define V_T6_SPEED_SEL1(x) ((x) << S_T6_SPEED_SEL1)
-#define F_T6_SPEED_SEL1 V_T6_SPEED_SEL1(1U)
-
-#define A_MAC_PORT_MTIP_MODE_CTL_SEG 0x1204
-
-#define S_MODE_CTL 0
-#define M_MODE_CTL 0x3U
-#define V_MODE_CTL(x) ((x) << S_MODE_CTL)
-#define G_MODE_CTL(x) (((x) >> S_MODE_CTL) & M_MODE_CTL)
-
-#define A_T6_MAC_PORT_MTIP_SGMII_STATUS 0x1204
-
-#define S_T6_REM_FAULT 4
-#define V_T6_REM_FAULT(x) ((x) << S_T6_REM_FAULT)
-#define F_T6_REM_FAULT V_T6_REM_FAULT(1U)
-
-#define A_MAC_PORT_MTIP_TXCLK_CTL_SEG 0x1208
-
-#define S_TXCLK_CTL 0
-#define M_TXCLK_CTL 0xffffU
-#define V_TXCLK_CTL(x) ((x) << S_TXCLK_CTL)
-#define G_TXCLK_CTL(x) (((x) >> S_TXCLK_CTL) & M_TXCLK_CTL)
-
-#define A_T6_MAC_PORT_MTIP_SGMII_PHY_IDENTIFIER_0 0x1208
-#define A_MAC_PORT_MTIP_TX_PRMBL_CTL_SEG 0x120c
-#define A_T6_MAC_PORT_MTIP_SGMII_PHY_IDENTIFIER_1 0x120c
-#define A_T6_MAC_PORT_MTIP_SGMII_DEV_ABILITY 0x1210
-#define A_T6_MAC_PORT_MTIP_SGMII_PARTNER_ABILITY 0x1214
-#define A_T6_MAC_PORT_MTIP_SGMII_AN_EXPANSION 0x1218
-
-#define S_NEXT_PAGE_ABLE 2
-#define V_NEXT_PAGE_ABLE(x) ((x) << S_NEXT_PAGE_ABLE)
-#define F_NEXT_PAGE_ABLE V_NEXT_PAGE_ABLE(1U)
-
-#define S_PAGE_RECEIVE 1
-#define V_PAGE_RECEIVE(x) ((x) << S_PAGE_RECEIVE)
-#define F_PAGE_RECEIVE V_PAGE_RECEIVE(1U)
-
-#define A_MAC_PORT_MTIP_SGMII_NP_TX 0x121c
-
-#define S_NP_TX 0
-#define M_NP_TX 0xffffU
-#define V_NP_TX(x) ((x) << S_NP_TX)
-#define G_NP_TX(x) (((x) >> S_NP_TX) & M_NP_TX)
-
-#define A_MAC_PORT_MTIP_WAN_RS_COL_CNT 0x1220
-
-#define S_COL_CNT 0
-#define M_COL_CNT 0xffffU
-#define V_COL_CNT(x) ((x) << S_COL_CNT)
-#define G_COL_CNT(x) (((x) >> S_COL_CNT) & M_COL_CNT)
-
-#define A_MAC_PORT_MTIP_SGMII_LP_NP_RX 0x1220
-
-#define S_LP_NP_RX 0
-#define M_LP_NP_RX 0xffffU
-#define V_LP_NP_RX(x) ((x) << S_LP_NP_RX)
-#define G_LP_NP_RX(x) (((x) >> S_LP_NP_RX) & M_LP_NP_RX)
-
-#define A_T6_MAC_PORT_MTIP_SGMII_EXTENDED_STATUS 0x123c
-
-#define S_EXTENDED_STATUS 0
-#define M_EXTENDED_STATUS 0xffffU
-#define V_EXTENDED_STATUS(x) ((x) << S_EXTENDED_STATUS)
-#define G_EXTENDED_STATUS(x) (((x) >> S_EXTENDED_STATUS) & M_EXTENDED_STATUS)
-
-#define A_MAC_PORT_MTIP_VL_INTVL 0x1240
-
-#define S_VL_INTVL 1
-#define V_VL_INTVL(x) ((x) << S_VL_INTVL)
-#define F_VL_INTVL V_VL_INTVL(1U)
-
-#define A_MAC_PORT_MTIP_SGMII_SCRATCH 0x1240
-
-#define S_SCRATCH 0
-#define M_SCRATCH 0xffffU
-#define V_SCRATCH(x) ((x) << S_SCRATCH)
-#define G_SCRATCH(x) (((x) >> S_SCRATCH) & M_SCRATCH)
-
-#define A_MAC_PORT_MTIP_SGMII_REV 0x1244
-
-#define S_SGMII_VER 8
-#define M_SGMII_VER 0xffU
-#define V_SGMII_VER(x) ((x) << S_SGMII_VER)
-#define G_SGMII_VER(x) (((x) >> S_SGMII_VER) & M_SGMII_VER)
-
-#define S_SGMII_REV 0
-#define M_SGMII_REV 0xffU
-#define V_SGMII_REV(x) ((x) << S_SGMII_REV)
-#define G_SGMII_REV(x) (((x) >> S_SGMII_REV) & M_SGMII_REV)
-
-#define A_T6_MAC_PORT_MTIP_SGMII_LINK_TIMER_LO 0x1248
-
-#define S_LINK_TIMER_LO 0
-#define M_LINK_TIMER_LO 0xffffU
-#define V_LINK_TIMER_LO(x) ((x) << S_LINK_TIMER_LO)
-#define G_LINK_TIMER_LO(x) (((x) >> S_LINK_TIMER_LO) & M_LINK_TIMER_LO)
-
-#define A_T6_MAC_PORT_MTIP_SGMII_LINK_TIMER_HI 0x124c
-
-#define S_LINK_TIMER_HI 0
-#define M_LINK_TIMER_HI 0xffffU
-#define V_LINK_TIMER_HI(x) ((x) << S_LINK_TIMER_HI)
-#define G_LINK_TIMER_HI(x) (((x) >> S_LINK_TIMER_HI) & M_LINK_TIMER_HI)
-
-#define A_T6_MAC_PORT_MTIP_SGMII_IF_MODE 0x1250
-
-#define S_SGMII_DUPLEX 4
-#define V_SGMII_DUPLEX(x) ((x) << S_SGMII_DUPLEX)
-#define F_SGMII_DUPLEX V_SGMII_DUPLEX(1U)
-
-#define A_MAC_PORT_MTIP_SGMII_DECODE_ERROR 0x1254
-
-#define S_T6_DECODE_ERROR 0
-#define M_T6_DECODE_ERROR 0xffffU
-#define V_T6_DECODE_ERROR(x) ((x) << S_T6_DECODE_ERROR)
-#define G_T6_DECODE_ERROR(x) (((x) >> S_T6_DECODE_ERROR) & M_T6_DECODE_ERROR)
-
-#define A_MAC_PORT_MTIP_KR_PCS_CONTROL_1 0x1300
-
-#define S_LOW_POWER 11
-#define V_LOW_POWER(x) ((x) << S_LOW_POWER)
-#define F_LOW_POWER V_LOW_POWER(1U)
-
-#define S_T6_SPEED_SEL1 6
-#define V_T6_SPEED_SEL1(x) ((x) << S_T6_SPEED_SEL1)
-#define F_T6_SPEED_SEL1 V_T6_SPEED_SEL1(1U)
-
-#define S_SPEED_SEL2 2
-#define M_SPEED_SEL2 0xfU
-#define V_SPEED_SEL2(x) ((x) << S_SPEED_SEL2)
-#define G_SPEED_SEL2(x) (((x) >> S_SPEED_SEL2) & M_SPEED_SEL2)
-
-#define A_MAC_PORT_MTIP_KR_PCS_STATUS_1 0x1304
-
-#define S_TX_LPI 11
-#define V_TX_LPI(x) ((x) << S_TX_LPI)
-#define F_TX_LPI V_TX_LPI(1U)
-
-#define S_RX_LPI 10
-#define V_RX_LPI(x) ((x) << S_RX_LPI)
-#define F_RX_LPI V_RX_LPI(1U)
-
-#define S_TX_LPI_ACTIVE 9
-#define V_TX_LPI_ACTIVE(x) ((x) << S_TX_LPI_ACTIVE)
-#define F_TX_LPI_ACTIVE V_TX_LPI_ACTIVE(1U)
-
-#define S_RX_LPI_ACTIVE 8
-#define V_RX_LPI_ACTIVE(x) ((x) << S_RX_LPI_ACTIVE)
-#define F_RX_LPI_ACTIVE V_RX_LPI_ACTIVE(1U)
-
-#define S_FAULT 7
-#define V_FAULT(x) ((x) << S_FAULT)
-#define F_FAULT V_FAULT(1U)
-
-#define S_PCS_RX_LINK_STAT 2
-#define V_PCS_RX_LINK_STAT(x) ((x) << S_PCS_RX_LINK_STAT)
-#define F_PCS_RX_LINK_STAT V_PCS_RX_LINK_STAT(1U)
-
-#define S_LOW_POWER_ABILITY 1
-#define V_LOW_POWER_ABILITY(x) ((x) << S_LOW_POWER_ABILITY)
-#define F_LOW_POWER_ABILITY V_LOW_POWER_ABILITY(1U)
-
-#define A_MAC_PORT_MTIP_KR_PCS_DEVICE_IDENTIFIER_1 0x1308
-#define A_MAC_PORT_MTIP_KR_PCS_DEVICE_IDENTIFIER_2 0x130c
-#define A_MAC_PORT_MTIP_KR_PCS_SPEED_ABILITY 0x1310
-
-#define S_10G_CAPABLE 0
-#define V_10G_CAPABLE(x) ((x) << S_10G_CAPABLE)
-#define F_10G_CAPABLE V_10G_CAPABLE(1U)
-
-#define A_MAC_PORT_MTIP_KR_PCS_DEVICES_IN_PACKAGELO 0x1314
-
-#define S_AUTO_NEGOTIATION_PRESENT 7
-#define V_AUTO_NEGOTIATION_PRESENT(x) ((x) << S_AUTO_NEGOTIATION_PRESENT)
-#define F_AUTO_NEGOTIATION_PRESENT V_AUTO_NEGOTIATION_PRESENT(1U)
-
-#define S_DTE_XS_PRESENT 5
-#define V_DTE_XS_PRESENT(x) ((x) << S_DTE_XS_PRESENT)
-#define F_DTE_XS_PRESENT V_DTE_XS_PRESENT(1U)
-
-#define S_PHY_XS_PRESENT 4
-#define V_PHY_XS_PRESENT(x) ((x) << S_PHY_XS_PRESENT)
-#define F_PHY_XS_PRESENT V_PHY_XS_PRESENT(1U)
-
-#define S_PCS_PRESENT 3
-#define V_PCS_PRESENT(x) ((x) << S_PCS_PRESENT)
-#define F_PCS_PRESENT V_PCS_PRESENT(1U)
-
-#define S_WIS_PRESENT 2
-#define V_WIS_PRESENT(x) ((x) << S_WIS_PRESENT)
-#define F_WIS_PRESENT V_WIS_PRESENT(1U)
-
-#define S_PMD_PMA_PRESENT 1
-#define V_PMD_PMA_PRESENT(x) ((x) << S_PMD_PMA_PRESENT)
-#define F_PMD_PMA_PRESENT V_PMD_PMA_PRESENT(1U)
-
-#define S_CLAUSE_22_REG_PRESENT 0
-#define V_CLAUSE_22_REG_PRESENT(x) ((x) << S_CLAUSE_22_REG_PRESENT)
-#define F_CLAUSE_22_REG_PRESENT V_CLAUSE_22_REG_PRESENT(1U)
-
-#define A_MAC_PORT_MTIP_KR_PCS_DEVICES_IN_PACKAGEHI 0x1318
-#define A_MAC_PORT_MTIP_KR_PCS_CONTROL_2 0x131c
-
-#define S_PCS_TYPE_SELECTION 0
-#define M_PCS_TYPE_SELECTION 0x3U
-#define V_PCS_TYPE_SELECTION(x) ((x) << S_PCS_TYPE_SELECTION)
-#define G_PCS_TYPE_SELECTION(x) (((x) >> S_PCS_TYPE_SELECTION) & M_PCS_TYPE_SELECTION)
-
-#define A_MAC_PORT_MTIP_KR_PCS_STATUS_2 0x1320
-
-#define S_DEVICE_PRESENT 14
-#define M_DEVICE_PRESENT 0x3U
-#define V_DEVICE_PRESENT(x) ((x) << S_DEVICE_PRESENT)
-#define G_DEVICE_PRESENT(x) (((x) >> S_DEVICE_PRESENT) & M_DEVICE_PRESENT)
-
-#define S_TRANSMIT_FAULT 11
-#define V_TRANSMIT_FAULT(x) ((x) << S_TRANSMIT_FAULT)
-#define F_TRANSMIT_FAULT V_TRANSMIT_FAULT(1U)
-
-#define S_RECEIVE_FAULT 10
-#define V_RECEIVE_FAULT(x) ((x) << S_RECEIVE_FAULT)
-#define F_RECEIVE_FAULT V_RECEIVE_FAULT(1U)
-
-#define S_10GBASE_W_CAPABLE 2
-#define V_10GBASE_W_CAPABLE(x) ((x) << S_10GBASE_W_CAPABLE)
-#define F_10GBASE_W_CAPABLE V_10GBASE_W_CAPABLE(1U)
-
-#define S_10GBASE_X_CAPABLE 1
-#define V_10GBASE_X_CAPABLE(x) ((x) << S_10GBASE_X_CAPABLE)
-#define F_10GBASE_X_CAPABLE V_10GBASE_X_CAPABLE(1U)
-
-#define S_10GBASE_R_CAPABLE 0
-#define V_10GBASE_R_CAPABLE(x) ((x) << S_10GBASE_R_CAPABLE)
-#define F_10GBASE_R_CAPABLE V_10GBASE_R_CAPABLE(1U)
-
-#define A_MAC_PORT_MTIP_KR_10GBASE_R_PCS_PACKAGE_IDENTIFIER_LO 0x1338
-
-#define S_PCS_PACKAGE_IDENTIFIER_LO 0
-#define M_PCS_PACKAGE_IDENTIFIER_LO 0xffffU
-#define V_PCS_PACKAGE_IDENTIFIER_LO(x) ((x) << S_PCS_PACKAGE_IDENTIFIER_LO)
-#define G_PCS_PACKAGE_IDENTIFIER_LO(x) (((x) >> S_PCS_PACKAGE_IDENTIFIER_LO) & M_PCS_PACKAGE_IDENTIFIER_LO)
-
-#define A_MAC_PORT_MTIP_KR_10GBASE_R_PCS_PACKAGE_IDENTIFIER_HI 0x133c
-
-#define S_PCS_PACKAGE_IDENTIFIER_HI 0
-#define M_PCS_PACKAGE_IDENTIFIER_HI 0xffffU
-#define V_PCS_PACKAGE_IDENTIFIER_HI(x) ((x) << S_PCS_PACKAGE_IDENTIFIER_HI)
-#define G_PCS_PACKAGE_IDENTIFIER_HI(x) (((x) >> S_PCS_PACKAGE_IDENTIFIER_HI) & M_PCS_PACKAGE_IDENTIFIER_HI)
-
-#define A_MAC_PORT_MTIP_KR_10GBASE_R_PCS_STATUS_1 0x1380
-
-#define S_10GBASE_R_RX_LINK_STATUS 12
-#define V_10GBASE_R_RX_LINK_STATUS(x) ((x) << S_10GBASE_R_RX_LINK_STATUS)
-#define F_10GBASE_R_RX_LINK_STATUS V_10GBASE_R_RX_LINK_STATUS(1U)
-
-#define S_PRBS9_PTTRN_TSTNG_ABILITY 3
-#define V_PRBS9_PTTRN_TSTNG_ABILITY(x) ((x) << S_PRBS9_PTTRN_TSTNG_ABILITY)
-#define F_PRBS9_PTTRN_TSTNG_ABILITY V_PRBS9_PTTRN_TSTNG_ABILITY(1U)
-
-#define S_PRBS31_PTTRN_TSTNG_ABILITY 2
-#define V_PRBS31_PTTRN_TSTNG_ABILITY(x) ((x) << S_PRBS31_PTTRN_TSTNG_ABILITY)
-#define F_PRBS31_PTTRN_TSTNG_ABILITY V_PRBS31_PTTRN_TSTNG_ABILITY(1U)
-
-#define S_10GBASE_R_PCS_HIGH_BER 1
-#define V_10GBASE_R_PCS_HIGH_BER(x) ((x) << S_10GBASE_R_PCS_HIGH_BER)
-#define F_10GBASE_R_PCS_HIGH_BER V_10GBASE_R_PCS_HIGH_BER(1U)
-
-#define S_10GBASE_R_PCS_BLOCK_LOCK 0
-#define V_10GBASE_R_PCS_BLOCK_LOCK(x) ((x) << S_10GBASE_R_PCS_BLOCK_LOCK)
-#define F_10GBASE_R_PCS_BLOCK_LOCK V_10GBASE_R_PCS_BLOCK_LOCK(1U)
-
-#define A_MAC_PORT_MTIP_KR_10GBASE_R_PCS_STATUS_2 0x1384
-
-#define S_LATCHED_BLOCK_LOCK 15
-#define V_LATCHED_BLOCK_LOCK(x) ((x) << S_LATCHED_BLOCK_LOCK)
-#define F_LATCHED_BLOCK_LOCK V_LATCHED_BLOCK_LOCK(1U)
-
-#define S_LATCHED_HIGH_BER 14
-#define V_LATCHED_HIGH_BER(x) ((x) << S_LATCHED_HIGH_BER)
-#define F_LATCHED_HIGH_BER V_LATCHED_HIGH_BER(1U)
-
-#define S_BERBER_COUNTER 8
-#define M_BERBER_COUNTER 0x3fU
-#define V_BERBER_COUNTER(x) ((x) << S_BERBER_COUNTER)
-#define G_BERBER_COUNTER(x) (((x) >> S_BERBER_COUNTER) & M_BERBER_COUNTER)
-
-#define A_MAC_PORT_MTIP_KR_10GBASE_R_PCS_TEST_PATTERN_SEED_A_0 0x1388
-
-#define S_TEST_PATTERN_SEED_A0 0
-#define M_TEST_PATTERN_SEED_A0 0xffffU
-#define V_TEST_PATTERN_SEED_A0(x) ((x) << S_TEST_PATTERN_SEED_A0)
-#define G_TEST_PATTERN_SEED_A0(x) (((x) >> S_TEST_PATTERN_SEED_A0) & M_TEST_PATTERN_SEED_A0)
-
-#define A_MAC_PORT_MTIP_KR_10GBASE_R_PCS_TEST_PATTERN_SEED_A_1 0x138c
-
-#define S_TEST_PATTERN_SEED_A1 0
-#define M_TEST_PATTERN_SEED_A1 0xffffU
-#define V_TEST_PATTERN_SEED_A1(x) ((x) << S_TEST_PATTERN_SEED_A1)
-#define G_TEST_PATTERN_SEED_A1(x) (((x) >> S_TEST_PATTERN_SEED_A1) & M_TEST_PATTERN_SEED_A1)
-
-#define A_MAC_PORT_MTIP_KR_10GBASE_R_PCS_TEST_PATTERN_SEED_A_2 0x1390
-
-#define S_TEST_PATTERN_SEED_A2 0
-#define M_TEST_PATTERN_SEED_A2 0xffffU
-#define V_TEST_PATTERN_SEED_A2(x) ((x) << S_TEST_PATTERN_SEED_A2)
-#define G_TEST_PATTERN_SEED_A2(x) (((x) >> S_TEST_PATTERN_SEED_A2) & M_TEST_PATTERN_SEED_A2)
-
-#define A_MAC_PORT_MTIP_KR_10GBASE_R_PCS_TEST_PATTERN_SEED_A_3 0x1394
-
-#define S_TEST_PATTERN_SEED_A3 0
-#define M_TEST_PATTERN_SEED_A3 0x3ffU
-#define V_TEST_PATTERN_SEED_A3(x) ((x) << S_TEST_PATTERN_SEED_A3)
-#define G_TEST_PATTERN_SEED_A3(x) (((x) >> S_TEST_PATTERN_SEED_A3) & M_TEST_PATTERN_SEED_A3)
-
-#define A_MAC_PORT_MTIP_KR_10GBASE_R_PCS_TEST_PATTERN_SEED_B_0 0x1398
-
-#define S_TEST_PATTERN_SEED_B0 0
-#define M_TEST_PATTERN_SEED_B0 0xffffU
-#define V_TEST_PATTERN_SEED_B0(x) ((x) << S_TEST_PATTERN_SEED_B0)
-#define G_TEST_PATTERN_SEED_B0(x) (((x) >> S_TEST_PATTERN_SEED_B0) & M_TEST_PATTERN_SEED_B0)
-
-#define A_MAC_PORT_MTIP_KR_10GBASE_R_PCS_TEST_PATTERN_SEED_B_1 0x139c
-
-#define S_TEST_PATTERN_SEED_B1 0
-#define M_TEST_PATTERN_SEED_B1 0xffffU
-#define V_TEST_PATTERN_SEED_B1(x) ((x) << S_TEST_PATTERN_SEED_B1)
-#define G_TEST_PATTERN_SEED_B1(x) (((x) >> S_TEST_PATTERN_SEED_B1) & M_TEST_PATTERN_SEED_B1)
-
-#define A_MAC_PORT_MTIP_KR_10GBASE_R_PCS_TEST_PATTERN_SEED_B_2 0x13a0
-
-#define S_TEST_PATTERN_SEED_B2 0
-#define M_TEST_PATTERN_SEED_B2 0xffffU
-#define V_TEST_PATTERN_SEED_B2(x) ((x) << S_TEST_PATTERN_SEED_B2)
-#define G_TEST_PATTERN_SEED_B2(x) (((x) >> S_TEST_PATTERN_SEED_B2) & M_TEST_PATTERN_SEED_B2)
-
-#define A_MAC_PORT_MTIP_KR_10GBASE_R_PCS_TEST_PATTERN_SEED_B_3 0x13a4
-
-#define S_TEST_PATTERN_SEED_B3 0
-#define M_TEST_PATTERN_SEED_B3 0x3ffU
-#define V_TEST_PATTERN_SEED_B3(x) ((x) << S_TEST_PATTERN_SEED_B3)
-#define G_TEST_PATTERN_SEED_B3(x) (((x) >> S_TEST_PATTERN_SEED_B3) & M_TEST_PATTERN_SEED_B3)
-
-#define A_MAC_PORT_MTIP_KR_10GBASE_R_PCS_TEST_PATTERN_CONTROL 0x13a8
-
-#define S_PRBS9_TX_TST_PTTRN_EN 6
-#define V_PRBS9_TX_TST_PTTRN_EN(x) ((x) << S_PRBS9_TX_TST_PTTRN_EN)
-#define F_PRBS9_TX_TST_PTTRN_EN V_PRBS9_TX_TST_PTTRN_EN(1U)
-
-#define S_PRBS31_RX_TST_PTTRN_EN 5
-#define V_PRBS31_RX_TST_PTTRN_EN(x) ((x) << S_PRBS31_RX_TST_PTTRN_EN)
-#define F_PRBS31_RX_TST_PTTRN_EN V_PRBS31_RX_TST_PTTRN_EN(1U)
-
-#define S_PRBS31_TX_TST_PTTRN_EN 4
-#define V_PRBS31_TX_TST_PTTRN_EN(x) ((x) << S_PRBS31_TX_TST_PTTRN_EN)
-#define F_PRBS31_TX_TST_PTTRN_EN V_PRBS31_TX_TST_PTTRN_EN(1U)
-
-#define S_TX_TEST_PATTERN_EN 3
-#define V_TX_TEST_PATTERN_EN(x) ((x) << S_TX_TEST_PATTERN_EN)
-#define F_TX_TEST_PATTERN_EN V_TX_TEST_PATTERN_EN(1U)
-
-#define S_RX_TEST_PATTERN_EN 2
-#define V_RX_TEST_PATTERN_EN(x) ((x) << S_RX_TEST_PATTERN_EN)
-#define F_RX_TEST_PATTERN_EN V_RX_TEST_PATTERN_EN(1U)
-
-#define S_TEST_PATTERN_SELECT 1
-#define V_TEST_PATTERN_SELECT(x) ((x) << S_TEST_PATTERN_SELECT)
-#define F_TEST_PATTERN_SELECT V_TEST_PATTERN_SELECT(1U)
-
-#define S_DATA_PATTERN_SELECT 0
-#define V_DATA_PATTERN_SELECT(x) ((x) << S_DATA_PATTERN_SELECT)
-#define F_DATA_PATTERN_SELECT V_DATA_PATTERN_SELECT(1U)
-
-#define A_MAC_PORT_MTIP_KR_10GBASE_R_PCS_TEST_PATTERN_ERROR_COUNTER 0x13ac
-
-#define S_TEST_PATTERN_ERR_CNTR 0
-#define M_TEST_PATTERN_ERR_CNTR 0xffffU
-#define V_TEST_PATTERN_ERR_CNTR(x) ((x) << S_TEST_PATTERN_ERR_CNTR)
-#define G_TEST_PATTERN_ERR_CNTR(x) (((x) >> S_TEST_PATTERN_ERR_CNTR) & M_TEST_PATTERN_ERR_CNTR)
-
-#define A_MAC_PORT_MTIP_KR_VENDOR_SPECIFIC_PCS_STATUS 0x13b4
-
-#define S_TRANSMIT_FIFO_FAULT 1
-#define V_TRANSMIT_FIFO_FAULT(x) ((x) << S_TRANSMIT_FIFO_FAULT)
-#define F_TRANSMIT_FIFO_FAULT V_TRANSMIT_FIFO_FAULT(1U)
-
-#define S_RECEIVE_FIFO_FAULT 0
-#define V_RECEIVE_FIFO_FAULT(x) ((x) << S_RECEIVE_FIFO_FAULT)
-#define F_RECEIVE_FIFO_FAULT V_RECEIVE_FIFO_FAULT(1U)
-
-#define A_MAC_PORT_MTIP_KR4_CONTROL_1 0x1400
-
-#define S_SPEED_SELECTION 13
-#define V_SPEED_SELECTION(x) ((x) << S_SPEED_SELECTION)
-#define F_SPEED_SELECTION V_SPEED_SELECTION(1U)
-
-#define S_SPEED_SELECTION1 6
-#define V_SPEED_SELECTION1(x) ((x) << S_SPEED_SELECTION1)
-#define F_SPEED_SELECTION1 V_SPEED_SELECTION1(1U)
-
-#define S_SPEED_SELECTION2 2
-#define M_SPEED_SELECTION2 0xfU
-#define V_SPEED_SELECTION2(x) ((x) << S_SPEED_SELECTION2)
-#define G_SPEED_SELECTION2(x) (((x) >> S_SPEED_SELECTION2) & M_SPEED_SELECTION2)
-
-#define A_MAC_PORT_MTIP_KR4_STATUS_1 0x1404
-
-#define S_RECEIVE_LINK_STAT 2
-#define V_RECEIVE_LINK_STAT(x) ((x) << S_RECEIVE_LINK_STAT)
-#define F_RECEIVE_LINK_STAT V_RECEIVE_LINK_STAT(1U)
-
-#define A_MAC_PORT_MTIP_KR4_DEVICE_ID0 0x1408
-#define A_MAC_PORT_MTIP_KR4_DEVICE_ID1 0x140c
-
-#define S_T6_DEVICE_ID1 16
-#define M_T6_DEVICE_ID1 0xffffU
-#define V_T6_DEVICE_ID1(x) ((x) << S_T6_DEVICE_ID1)
-#define G_T6_DEVICE_ID1(x) (((x) >> S_T6_DEVICE_ID1) & M_T6_DEVICE_ID1)
-
-#define A_MAC_PORT_MTIP_KR4_SPEED_ABILITY 0x1410
-
-#define S_100G_CAPABLE 3
-#define V_100G_CAPABLE(x) ((x) << S_100G_CAPABLE)
-#define F_100G_CAPABLE V_100G_CAPABLE(1U)
-
-#define S_40G_CAPABLE 2
-#define V_40G_CAPABLE(x) ((x) << S_40G_CAPABLE)
-#define F_40G_CAPABLE V_40G_CAPABLE(1U)
-
-#define S_10PASS_TS_2BASE_TL_CAPABLE 1
-#define V_10PASS_TS_2BASE_TL_CAPABLE(x) ((x) << S_10PASS_TS_2BASE_TL_CAPABLE)
-#define F_10PASS_TS_2BASE_TL_CAPABLE V_10PASS_TS_2BASE_TL_CAPABLE(1U)
-
-#define A_MAC_PORT_MTIP_KR4_DEVICES_IN_PKG1 0x1414
-
-#define S_CLAUSE_22_REG 0
-#define V_CLAUSE_22_REG(x) ((x) << S_CLAUSE_22_REG)
-#define F_CLAUSE_22_REG V_CLAUSE_22_REG(1U)
-
-#define A_MAC_PORT_MTIP_KR4_DEVICES_IN_PKG2 0x1418
-
-#define S_VENDOR_SPECIFIC_DEVICE 15
-#define V_VENDOR_SPECIFIC_DEVICE(x) ((x) << S_VENDOR_SPECIFIC_DEVICE)
-#define F_VENDOR_SPECIFIC_DEVICE V_VENDOR_SPECIFIC_DEVICE(1U)
-
-#define S_VENDOR_SPECIFIC_DEVICE1 14
-#define V_VENDOR_SPECIFIC_DEVICE1(x) ((x) << S_VENDOR_SPECIFIC_DEVICE1)
-#define F_VENDOR_SPECIFIC_DEVICE1 V_VENDOR_SPECIFIC_DEVICE1(1U)
-
-#define S_CLAUSE_22_EXT 13
-#define V_CLAUSE_22_EXT(x) ((x) << S_CLAUSE_22_EXT)
-#define F_CLAUSE_22_EXT V_CLAUSE_22_EXT(1U)
-
-#define A_MAC_PORT_MTIP_KR4_CONTROL_2 0x141c
-
-#define S_PCS_TYPE_SEL 0
-#define M_PCS_TYPE_SEL 0x7U
-#define V_PCS_TYPE_SEL(x) ((x) << S_PCS_TYPE_SEL)
-#define G_PCS_TYPE_SEL(x) (((x) >> S_PCS_TYPE_SEL) & M_PCS_TYPE_SEL)
-
-#define A_MAC_PORT_MTIP_KR4_STATUS_2 0x1420
-
-#define S_100GBASE_R_CAPABLE 5
-#define V_100GBASE_R_CAPABLE(x) ((x) << S_100GBASE_R_CAPABLE)
-#define F_100GBASE_R_CAPABLE V_100GBASE_R_CAPABLE(1U)
-
-#define S_40GBASE_R_CAPABLE 4
-#define V_40GBASE_R_CAPABLE(x) ((x) << S_40GBASE_R_CAPABLE)
-#define F_40GBASE_R_CAPABLE V_40GBASE_R_CAPABLE(1U)
-
-#define S_10GBASE_T_CAPABLE 3
-#define V_10GBASE_T_CAPABLE(x) ((x) << S_10GBASE_T_CAPABLE)
-#define F_10GBASE_T_CAPABLE V_10GBASE_T_CAPABLE(1U)
-
-#define A_MAC_PORT_MTIP_KR4_PKG_ID0 0x1438
-#define A_MAC_PORT_MTIP_KR4_PKG_ID1 0x143c
-#define A_MAC_PORT_MTIP_KR4_BASE_R_STATUS_1 0x1480
-
-#define S_T6_RX_LINK_STATUS 12
-#define V_T6_RX_LINK_STATUS(x) ((x) << S_T6_RX_LINK_STATUS)
-#define F_T6_RX_LINK_STATUS V_T6_RX_LINK_STATUS(1U)
-
-#define S_HIGH_BER 1
-#define V_HIGH_BER(x) ((x) << S_HIGH_BER)
-#define F_HIGH_BER V_HIGH_BER(1U)
-
-#define S_KR4_BLOCK_LOCK 0
-#define V_KR4_BLOCK_LOCK(x) ((x) << S_KR4_BLOCK_LOCK)
-#define F_KR4_BLOCK_LOCK V_KR4_BLOCK_LOCK(1U)
-
-#define A_MAC_PORT_MTIP_KR4_BASE_R_STATUS_2 0x1484
-
-#define S_LATCHED_BL_LK 15
-#define V_LATCHED_BL_LK(x) ((x) << S_LATCHED_BL_LK)
-#define F_LATCHED_BL_LK V_LATCHED_BL_LK(1U)
-
-#define S_LATCHED_HG_BR 14
-#define V_LATCHED_HG_BR(x) ((x) << S_LATCHED_HG_BR)
-#define F_LATCHED_HG_BR V_LATCHED_HG_BR(1U)
-
-#define S_BER_CNT 8
-#define M_BER_CNT 0x3fU
-#define V_BER_CNT(x) ((x) << S_BER_CNT)
-#define G_BER_CNT(x) (((x) >> S_BER_CNT) & M_BER_CNT)
-
-#define S_ERR_BL_CNT 0
-#define M_ERR_BL_CNT 0xffU
-#define V_ERR_BL_CNT(x) ((x) << S_ERR_BL_CNT)
-#define G_ERR_BL_CNT(x) (((x) >> S_ERR_BL_CNT) & M_ERR_BL_CNT)
-
-#define A_MAC_PORT_MTIP_KR4_BASE_R_TEST_CONTROL 0x14a8
-
-#define S_TX_TP_EN 3
-#define V_TX_TP_EN(x) ((x) << S_TX_TP_EN)
-#define F_TX_TP_EN V_TX_TP_EN(1U)
-
-#define S_RX_TP_EN 2
-#define V_RX_TP_EN(x) ((x) << S_RX_TP_EN)
-#define F_RX_TP_EN V_RX_TP_EN(1U)
-
-#define A_MAC_PORT_MTIP_KR4_BASE_R_TEST_ERR_CNT 0x14ac
-
-#define S_TP_ERR_CNTR 0
-#define M_TP_ERR_CNTR 0xffffU
-#define V_TP_ERR_CNTR(x) ((x) << S_TP_ERR_CNTR)
-#define G_TP_ERR_CNTR(x) (((x) >> S_TP_ERR_CNTR) & M_TP_ERR_CNTR)
-
-#define A_MAC_PORT_MTIP_KR4_BER_HIGH_ORDER_CNT 0x14b0
-
-#define S_BER_HI_ORDER_CNT 0
-#define M_BER_HI_ORDER_CNT 0xffffU
-#define V_BER_HI_ORDER_CNT(x) ((x) << S_BER_HI_ORDER_CNT)
-#define G_BER_HI_ORDER_CNT(x) (((x) >> S_BER_HI_ORDER_CNT) & M_BER_HI_ORDER_CNT)
-
-#define A_MAC_PORT_MTIP_KR4_ERR_BLK_HIGH_ORDER_CNT 0x14b4
-
-#define S_HI_ORDER_CNT_EN 15
-#define V_HI_ORDER_CNT_EN(x) ((x) << S_HI_ORDER_CNT_EN)
-#define F_HI_ORDER_CNT_EN V_HI_ORDER_CNT_EN(1U)
-
-#define S_ERR_BLK_CNTR 0
-#define M_ERR_BLK_CNTR 0x3fffU
-#define V_ERR_BLK_CNTR(x) ((x) << S_ERR_BLK_CNTR)
-#define G_ERR_BLK_CNTR(x) (((x) >> S_ERR_BLK_CNTR) & M_ERR_BLK_CNTR)
-
-#define A_MAC_PORT_MTIP_KR4_MULTI_LANE_ALIGN_STATUS_1 0x14c8
-
-#define S_LANE_ALIGN_STATUS 12
-#define V_LANE_ALIGN_STATUS(x) ((x) << S_LANE_ALIGN_STATUS)
-#define F_LANE_ALIGN_STATUS V_LANE_ALIGN_STATUS(1U)
-
-#define S_LANE_3_BLK_LCK 3
-#define V_LANE_3_BLK_LCK(x) ((x) << S_LANE_3_BLK_LCK)
-#define F_LANE_3_BLK_LCK V_LANE_3_BLK_LCK(1U)
-
-#define S_LANE_2_BLK_LC32_6431K 2
-#define V_LANE_2_BLK_LC32_6431K(x) ((x) << S_LANE_2_BLK_LC32_6431K)
-#define F_LANE_2_BLK_LC32_6431K V_LANE_2_BLK_LC32_6431K(1U)
-
-#define S_LANE_1_BLK_LCK 1
-#define V_LANE_1_BLK_LCK(x) ((x) << S_LANE_1_BLK_LCK)
-#define F_LANE_1_BLK_LCK V_LANE_1_BLK_LCK(1U)
-
-#define S_LANE_0_BLK_LCK 0
-#define V_LANE_0_BLK_LCK(x) ((x) << S_LANE_0_BLK_LCK)
-#define F_LANE_0_BLK_LCK V_LANE_0_BLK_LCK(1U)
-
-#define A_MAC_PORT_MTIP_KR4_MULTI_LANE_ALIGN_STATUS_2 0x14cc
-#define A_MAC_PORT_MTIP_KR4_MULTI_LANE_ALIGN_STATUS_3 0x14d0
-
-#define S_LANE_3_ALIGN_MRKR_LCK 3
-#define V_LANE_3_ALIGN_MRKR_LCK(x) ((x) << S_LANE_3_ALIGN_MRKR_LCK)
-#define F_LANE_3_ALIGN_MRKR_LCK V_LANE_3_ALIGN_MRKR_LCK(1U)
-
-#define S_LANE_2_ALIGN_MRKR_LCK 2
-#define V_LANE_2_ALIGN_MRKR_LCK(x) ((x) << S_LANE_2_ALIGN_MRKR_LCK)
-#define F_LANE_2_ALIGN_MRKR_LCK V_LANE_2_ALIGN_MRKR_LCK(1U)
-
-#define S_LANE_1_ALIGN_MRKR_LCK 1
-#define V_LANE_1_ALIGN_MRKR_LCK(x) ((x) << S_LANE_1_ALIGN_MRKR_LCK)
-#define F_LANE_1_ALIGN_MRKR_LCK V_LANE_1_ALIGN_MRKR_LCK(1U)
-
-#define S_LANE_0_ALIGN_MRKR_LCK 0
-#define V_LANE_0_ALIGN_MRKR_LCK(x) ((x) << S_LANE_0_ALIGN_MRKR_LCK)
-#define F_LANE_0_ALIGN_MRKR_LCK V_LANE_0_ALIGN_MRKR_LCK(1U)
-
-#define A_MAC_PORT_MTIP_KR4_MULTI_LANE_ALIGN_STATUS_4 0x14d4
-#define A_MAC_PORT_MTIP_MDIO_CFG_STATUS 0x1600
-
-#define S_CLK_DIV 7
-#define M_CLK_DIV 0x1ffU
-#define V_CLK_DIV(x) ((x) << S_CLK_DIV)
-#define G_CLK_DIV(x) (((x) >> S_CLK_DIV) & M_CLK_DIV)
-
-#define S_CL45_EN 6
-#define V_CL45_EN(x) ((x) << S_CL45_EN)
-#define F_CL45_EN V_CL45_EN(1U)
-
-#define S_DISABLE_PREAMBLE 5
-#define V_DISABLE_PREAMBLE(x) ((x) << S_DISABLE_PREAMBLE)
-#define F_DISABLE_PREAMBLE V_DISABLE_PREAMBLE(1U)
-
-#define S_MDIO_HOLD_TIME 2
-#define M_MDIO_HOLD_TIME 0x7U
-#define V_MDIO_HOLD_TIME(x) ((x) << S_MDIO_HOLD_TIME)
-#define G_MDIO_HOLD_TIME(x) (((x) >> S_MDIO_HOLD_TIME) & M_MDIO_HOLD_TIME)
-
-#define S_MDIO_READ_ERR 1
-#define V_MDIO_READ_ERR(x) ((x) << S_MDIO_READ_ERR)
-#define F_MDIO_READ_ERR V_MDIO_READ_ERR(1U)
-
-#define S_MDIO_BUSY 0
-#define V_MDIO_BUSY(x) ((x) << S_MDIO_BUSY)
-#define F_MDIO_BUSY V_MDIO_BUSY(1U)
-
-#define A_MAC_PORT_MTIP_MDIO_COMMAND 0x1604
-
-#define S_MDIO_CMD_READ 15
-#define V_MDIO_CMD_READ(x) ((x) << S_MDIO_CMD_READ)
-#define F_MDIO_CMD_READ V_MDIO_CMD_READ(1U)
-
-#define S_READ_INCR 14
-#define V_READ_INCR(x) ((x) << S_READ_INCR)
-#define F_READ_INCR V_READ_INCR(1U)
-
-#define S_PORT_ADDR 5
-#define M_PORT_ADDR 0x1fU
-#define V_PORT_ADDR(x) ((x) << S_PORT_ADDR)
-#define G_PORT_ADDR(x) (((x) >> S_PORT_ADDR) & M_PORT_ADDR)
-
-#define S_DEV_ADDR 0
-#define M_DEV_ADDR 0x1fU
-#define V_DEV_ADDR(x) ((x) << S_DEV_ADDR)
-#define G_DEV_ADDR(x) (((x) >> S_DEV_ADDR) & M_DEV_ADDR)
-
-#define A_MAC_PORT_MTIP_MDIO_DATA 0x1608
-
-#define S_READBUSY 31
-#define V_READBUSY(x) ((x) << S_READBUSY)
-#define F_READBUSY V_READBUSY(1U)
-
-#define S_DATA_WORD 0
-#define M_DATA_WORD 0xffffU
-#define V_DATA_WORD(x) ((x) << S_DATA_WORD)
-#define G_DATA_WORD(x) (((x) >> S_DATA_WORD) & M_DATA_WORD)
-
-#define A_MAC_PORT_MTIP_MDIO_REGADDR 0x160c
-
-#define S_MDIO_ADDR 0
-#define M_MDIO_ADDR 0xffffU
-#define V_MDIO_ADDR(x) ((x) << S_MDIO_ADDR)
-#define G_MDIO_ADDR(x) (((x) >> S_MDIO_ADDR) & M_MDIO_ADDR)
-
-#define A_MAC_PORT_MTIP_KR4_BIP_ERR_CNT_LANE_0 0x1720
-
-#define S_BIP_ERR_CNT_LANE_0 0
-#define M_BIP_ERR_CNT_LANE_0 0xffffU
-#define V_BIP_ERR_CNT_LANE_0(x) ((x) << S_BIP_ERR_CNT_LANE_0)
-#define G_BIP_ERR_CNT_LANE_0(x) (((x) >> S_BIP_ERR_CNT_LANE_0) & M_BIP_ERR_CNT_LANE_0)
-
-#define A_MAC_PORT_MTIP_KR4_BIP_ERR_CNT_LANE_1 0x1724
-
-#define S_BIP_ERR_CNT_LANE_1 0
-#define M_BIP_ERR_CNT_LANE_1 0xffffU
-#define V_BIP_ERR_CNT_LANE_1(x) ((x) << S_BIP_ERR_CNT_LANE_1)
-#define G_BIP_ERR_CNT_LANE_1(x) (((x) >> S_BIP_ERR_CNT_LANE_1) & M_BIP_ERR_CNT_LANE_1)
-
-#define A_MAC_PORT_MTIP_KR4_BIP_ERR_CNT_LANE_2 0x1728
-
-#define S_BIP_ERR_CNT_LANE_2 0
-#define M_BIP_ERR_CNT_LANE_2 0xffffU
-#define V_BIP_ERR_CNT_LANE_2(x) ((x) << S_BIP_ERR_CNT_LANE_2)
-#define G_BIP_ERR_CNT_LANE_2(x) (((x) >> S_BIP_ERR_CNT_LANE_2) & M_BIP_ERR_CNT_LANE_2)
-
-#define A_MAC_PORT_MTIP_KR4_BIP_ERR_CNT_LANE_3 0x172c
-
-#define S_BIP_ERR_CNT_LANE_3 0
-#define M_BIP_ERR_CNT_LANE_3 0xffffU
-#define V_BIP_ERR_CNT_LANE_3(x) ((x) << S_BIP_ERR_CNT_LANE_3)
-#define G_BIP_ERR_CNT_LANE_3(x) (((x) >> S_BIP_ERR_CNT_LANE_3) & M_BIP_ERR_CNT_LANE_3)
-
-#define A_MAC_PORT_MTIP_VLAN_TPID_0 0x1a00
-
-#define S_VLANTAG 0
-#define M_VLANTAG 0xffffU
-#define V_VLANTAG(x) ((x) << S_VLANTAG)
-#define G_VLANTAG(x) (((x) >> S_VLANTAG) & M_VLANTAG)
-
-#define A_MAC_PORT_MTIP_VLAN_TPID_1 0x1a04
-#define A_MAC_PORT_MTIP_VLAN_TPID_2 0x1a08
-#define A_MAC_PORT_MTIP_VLAN_TPID_3 0x1a0c
-#define A_MAC_PORT_MTIP_VLAN_TPID_4 0x1a10
-#define A_MAC_PORT_MTIP_VLAN_TPID_5 0x1a14
-#define A_MAC_PORT_MTIP_VLAN_TPID_6 0x1a18
-#define A_MAC_PORT_MTIP_VLAN_TPID_7 0x1a1c
-#define A_MAC_PORT_MTIP_KR4_LANE_0_MAPPING 0x1a40
-
-#define S_KR4_LANE_0_MAPPING 0
-#define M_KR4_LANE_0_MAPPING 0x3U
-#define V_KR4_LANE_0_MAPPING(x) ((x) << S_KR4_LANE_0_MAPPING)
-#define G_KR4_LANE_0_MAPPING(x) (((x) >> S_KR4_LANE_0_MAPPING) & M_KR4_LANE_0_MAPPING)
-
-#define A_MAC_PORT_MTIP_KR4_LANE_1_MAPPING 0x1a44
-
-#define S_KR4_LANE_1_MAPPING 0
-#define M_KR4_LANE_1_MAPPING 0x3U
-#define V_KR4_LANE_1_MAPPING(x) ((x) << S_KR4_LANE_1_MAPPING)
-#define G_KR4_LANE_1_MAPPING(x) (((x) >> S_KR4_LANE_1_MAPPING) & M_KR4_LANE_1_MAPPING)
-
-#define A_MAC_PORT_MTIP_KR4_LANE_2_MAPPING 0x1a48
-
-#define S_KR4_LANE_2_MAPPING 0
-#define M_KR4_LANE_2_MAPPING 0x3U
-#define V_KR4_LANE_2_MAPPING(x) ((x) << S_KR4_LANE_2_MAPPING)
-#define G_KR4_LANE_2_MAPPING(x) (((x) >> S_KR4_LANE_2_MAPPING) & M_KR4_LANE_2_MAPPING)
-
-#define A_MAC_PORT_MTIP_KR4_LANE_3_MAPPING 0x1a4c
-
-#define S_KR4_LANE_3_MAPPING 0
-#define M_KR4_LANE_3_MAPPING 0x3U
-#define V_KR4_LANE_3_MAPPING(x) ((x) << S_KR4_LANE_3_MAPPING)
-#define G_KR4_LANE_3_MAPPING(x) (((x) >> S_KR4_LANE_3_MAPPING) & M_KR4_LANE_3_MAPPING)
-
-#define A_MAC_PORT_MTIP_KR4_SCRATCH 0x1af0
-#define A_MAC_PORT_MTIP_KR4_CORE_REVISION 0x1af4
-#define A_MAC_PORT_MTIP_KR4_VL_INTVL 0x1af8
-
-#define S_SHRT_MRKR_CNFG 0
-#define V_SHRT_MRKR_CNFG(x) ((x) << S_SHRT_MRKR_CNFG)
-#define F_SHRT_MRKR_CNFG V_SHRT_MRKR_CNFG(1U)
-
-#define A_MAC_PORT_MTIP_KR4_TX_LANE_THRESH 0x1afc
-#define A_MAC_PORT_MTIP_CR4_CONTROL_1 0x1b00
-#define A_MAC_PORT_MTIP_CR4_STATUS_1 0x1b04
-
-#define S_CR4_RX_LINK_STATUS 2
-#define V_CR4_RX_LINK_STATUS(x) ((x) << S_CR4_RX_LINK_STATUS)
-#define F_CR4_RX_LINK_STATUS V_CR4_RX_LINK_STATUS(1U)
-
-#define A_MAC_PORT_MTIP_CR4_DEVICE_ID0 0x1b08
-
-#define S_CR4_DEVICE_ID0 0
-#define M_CR4_DEVICE_ID0 0xffffU
-#define V_CR4_DEVICE_ID0(x) ((x) << S_CR4_DEVICE_ID0)
-#define G_CR4_DEVICE_ID0(x) (((x) >> S_CR4_DEVICE_ID0) & M_CR4_DEVICE_ID0)
-
-#define A_MAC_PORT_MTIP_CR4_DEVICE_ID1 0x1b0c
-
-#define S_CR4_DEVICE_ID1 0
-#define M_CR4_DEVICE_ID1 0xffffU
-#define V_CR4_DEVICE_ID1(x) ((x) << S_CR4_DEVICE_ID1)
-#define G_CR4_DEVICE_ID1(x) (((x) >> S_CR4_DEVICE_ID1) & M_CR4_DEVICE_ID1)
-
-#define A_MAC_PORT_MTIP_CR4_SPEED_ABILITY 0x1b10
-
-#define S_CR4_100G_CAPABLE 8
-#define V_CR4_100G_CAPABLE(x) ((x) << S_CR4_100G_CAPABLE)
-#define F_CR4_100G_CAPABLE V_CR4_100G_CAPABLE(1U)
-
-#define S_CR4_40G_CAPABLE 7
-#define V_CR4_40G_CAPABLE(x) ((x) << S_CR4_40G_CAPABLE)
-#define F_CR4_40G_CAPABLE V_CR4_40G_CAPABLE(1U)
-
-#define A_MAC_PORT_MTIP_CR4_DEVICES_IN_PKG1 0x1b14
-
-#define S_CLAUSE22REG_PRESENT 0
-#define V_CLAUSE22REG_PRESENT(x) ((x) << S_CLAUSE22REG_PRESENT)
-#define F_CLAUSE22REG_PRESENT V_CLAUSE22REG_PRESENT(1U)
-
-#define A_MAC_PORT_MTIP_CR4_DEVICES_IN_PKG2 0x1b18
-
-#define S_VSD_2_PRESENT 15
-#define V_VSD_2_PRESENT(x) ((x) << S_VSD_2_PRESENT)
-#define F_VSD_2_PRESENT V_VSD_2_PRESENT(1U)
-
-#define S_VSD_1_PRESENT 14
-#define V_VSD_1_PRESENT(x) ((x) << S_VSD_1_PRESENT)
-#define F_VSD_1_PRESENT V_VSD_1_PRESENT(1U)
-
-#define S_CLAUSE22_EXT_PRESENT 13
-#define V_CLAUSE22_EXT_PRESENT(x) ((x) << S_CLAUSE22_EXT_PRESENT)
-#define F_CLAUSE22_EXT_PRESENT V_CLAUSE22_EXT_PRESENT(1U)
-
-#define A_MAC_PORT_MTIP_CR4_CONTROL_2 0x1b1c
-
-#define S_CR4_PCS_TYPE_SELECTION 0
-#define M_CR4_PCS_TYPE_SELECTION 0x7U
-#define V_CR4_PCS_TYPE_SELECTION(x) ((x) << S_CR4_PCS_TYPE_SELECTION)
-#define G_CR4_PCS_TYPE_SELECTION(x) (((x) >> S_CR4_PCS_TYPE_SELECTION) & M_CR4_PCS_TYPE_SELECTION)
-
-#define A_MAC_PORT_MTIP_CR4_STATUS_2 0x1b20
-#define A_MAC_PORT_MTIP_CR4_PKG_ID0 0x1b38
-#define A_MAC_PORT_MTIP_CR4_PKG_ID1 0x1b3c
-#define A_MAC_PORT_MTIP_CR4_BASE_R_STATUS_1 0x1b80
-
-#define S_RX_LINK_STAT 12
-#define V_RX_LINK_STAT(x) ((x) << S_RX_LINK_STAT)
-#define F_RX_LINK_STAT V_RX_LINK_STAT(1U)
-
-#define S_BR_BLOCK_LOCK 0
-#define V_BR_BLOCK_LOCK(x) ((x) << S_BR_BLOCK_LOCK)
-#define F_BR_BLOCK_LOCK V_BR_BLOCK_LOCK(1U)
-
-#define A_MAC_PORT_MTIP_CR4_BASE_R_STATUS_2 0x1b84
-
-#define S_BER_COUNTER 8
-#define M_BER_COUNTER 0x3fU
-#define V_BER_COUNTER(x) ((x) << S_BER_COUNTER)
-#define G_BER_COUNTER(x) (((x) >> S_BER_COUNTER) & M_BER_COUNTER)
-
-#define S_ERRORED_BLOCKS_CNTR 0
-#define M_ERRORED_BLOCKS_CNTR 0xffU
-#define V_ERRORED_BLOCKS_CNTR(x) ((x) << S_ERRORED_BLOCKS_CNTR)
-#define G_ERRORED_BLOCKS_CNTR(x) (((x) >> S_ERRORED_BLOCKS_CNTR) & M_ERRORED_BLOCKS_CNTR)
-
-#define A_MAC_PORT_MTIP_CR4_BASE_R_TEST_CONTROL 0x1ba8
-
-#define S_SCRAMBLED_ID_TP_EN 7
-#define V_SCRAMBLED_ID_TP_EN(x) ((x) << S_SCRAMBLED_ID_TP_EN)
-#define F_SCRAMBLED_ID_TP_EN V_SCRAMBLED_ID_TP_EN(1U)
-
-#define A_MAC_PORT_MTIP_CR4_BASE_R_TEST_ERR_CNT 0x1bac
-
-#define S_BASE_R_TEST_ERR_CNT 0
-#define M_BASE_R_TEST_ERR_CNT 0xffffU
-#define V_BASE_R_TEST_ERR_CNT(x) ((x) << S_BASE_R_TEST_ERR_CNT)
-#define G_BASE_R_TEST_ERR_CNT(x) (((x) >> S_BASE_R_TEST_ERR_CNT) & M_BASE_R_TEST_ERR_CNT)
-
-#define A_MAC_PORT_MTIP_CR4_BER_HIGH_ORDER_CNT 0x1bb0
-
-#define S_BER_HIGH_ORDER_CNT 0
-#define M_BER_HIGH_ORDER_CNT 0xffffU
-#define V_BER_HIGH_ORDER_CNT(x) ((x) << S_BER_HIGH_ORDER_CNT)
-#define G_BER_HIGH_ORDER_CNT(x) (((x) >> S_BER_HIGH_ORDER_CNT) & M_BER_HIGH_ORDER_CNT)
-
-#define A_MAC_PORT_MTIP_CR4_ERR_BLK_HIGH_ORDER_CNT 0x1bb4
-
-#define S_HI_ORDER_CNT_PRESENT 15
-#define V_HI_ORDER_CNT_PRESENT(x) ((x) << S_HI_ORDER_CNT_PRESENT)
-#define F_HI_ORDER_CNT_PRESENT V_HI_ORDER_CNT_PRESENT(1U)
-
-#define S_ERR_BLKS_CNTR 0
-#define M_ERR_BLKS_CNTR 0x3fffU
-#define V_ERR_BLKS_CNTR(x) ((x) << S_ERR_BLKS_CNTR)
-#define G_ERR_BLKS_CNTR(x) (((x) >> S_ERR_BLKS_CNTR) & M_ERR_BLKS_CNTR)
-
-#define A_MAC_PORT_MTIP_CR4_MULTI_LANE_ALIGN_STATUS_1 0x1bc8
-
-#define S_LANE_ALIGN_STAT 12
-#define V_LANE_ALIGN_STAT(x) ((x) << S_LANE_ALIGN_STAT)
-#define F_LANE_ALIGN_STAT V_LANE_ALIGN_STAT(1U)
-
-#define S_LANE_7_BLCK_LCK 7
-#define V_LANE_7_BLCK_LCK(x) ((x) << S_LANE_7_BLCK_LCK)
-#define F_LANE_7_BLCK_LCK V_LANE_7_BLCK_LCK(1U)
-
-#define S_LANE_6_BLCK_LCK 6
-#define V_LANE_6_BLCK_LCK(x) ((x) << S_LANE_6_BLCK_LCK)
-#define F_LANE_6_BLCK_LCK V_LANE_6_BLCK_LCK(1U)
-
-#define S_LANE_5_BLCK_LCK 5
-#define V_LANE_5_BLCK_LCK(x) ((x) << S_LANE_5_BLCK_LCK)
-#define F_LANE_5_BLCK_LCK V_LANE_5_BLCK_LCK(1U)
-
-#define S_LANE_4_BLCK_LCK 4
-#define V_LANE_4_BLCK_LCK(x) ((x) << S_LANE_4_BLCK_LCK)
-#define F_LANE_4_BLCK_LCK V_LANE_4_BLCK_LCK(1U)
-
-#define S_LANE_3_BLCK_LCK 3
-#define V_LANE_3_BLCK_LCK(x) ((x) << S_LANE_3_BLCK_LCK)
-#define F_LANE_3_BLCK_LCK V_LANE_3_BLCK_LCK(1U)
-
-#define S_LANE_2_BLCK_LCK 2
-#define V_LANE_2_BLCK_LCK(x) ((x) << S_LANE_2_BLCK_LCK)
-#define F_LANE_2_BLCK_LCK V_LANE_2_BLCK_LCK(1U)
-
-#define S_LANE_1_BLCK_LCK 1
-#define V_LANE_1_BLCK_LCK(x) ((x) << S_LANE_1_BLCK_LCK)
-#define F_LANE_1_BLCK_LCK V_LANE_1_BLCK_LCK(1U)
-
-#define S_LANE_0_BLCK_LCK 0
-#define V_LANE_0_BLCK_LCK(x) ((x) << S_LANE_0_BLCK_LCK)
-#define F_LANE_0_BLCK_LCK V_LANE_0_BLCK_LCK(1U)
-
-#define A_MAC_PORT_MTIP_CR4_MULTI_LANE_ALIGN_STATUS_2 0x1bcc
-
-#define S_LANE_19_BLCK_LCK 11
-#define V_LANE_19_BLCK_LCK(x) ((x) << S_LANE_19_BLCK_LCK)
-#define F_LANE_19_BLCK_LCK V_LANE_19_BLCK_LCK(1U)
-
-#define S_LANE_18_BLCK_LCK 10
-#define V_LANE_18_BLCK_LCK(x) ((x) << S_LANE_18_BLCK_LCK)
-#define F_LANE_18_BLCK_LCK V_LANE_18_BLCK_LCK(1U)
-
-#define S_LANE_17_BLCK_LCK 9
-#define V_LANE_17_BLCK_LCK(x) ((x) << S_LANE_17_BLCK_LCK)
-#define F_LANE_17_BLCK_LCK V_LANE_17_BLCK_LCK(1U)
-
-#define S_LANE_16_BLCK_LCK 8
-#define V_LANE_16_BLCK_LCK(x) ((x) << S_LANE_16_BLCK_LCK)
-#define F_LANE_16_BLCK_LCK V_LANE_16_BLCK_LCK(1U)
-
-#define S_LANE_15_BLCK_LCK 7
-#define V_LANE_15_BLCK_LCK(x) ((x) << S_LANE_15_BLCK_LCK)
-#define F_LANE_15_BLCK_LCK V_LANE_15_BLCK_LCK(1U)
-
-#define S_LANE_14_BLCK_LCK 6
-#define V_LANE_14_BLCK_LCK(x) ((x) << S_LANE_14_BLCK_LCK)
-#define F_LANE_14_BLCK_LCK V_LANE_14_BLCK_LCK(1U)
-
-#define S_LANE_13_BLCK_LCK 5
-#define V_LANE_13_BLCK_LCK(x) ((x) << S_LANE_13_BLCK_LCK)
-#define F_LANE_13_BLCK_LCK V_LANE_13_BLCK_LCK(1U)
-
-#define S_LANE_12_BLCK_LCK 4
-#define V_LANE_12_BLCK_LCK(x) ((x) << S_LANE_12_BLCK_LCK)
-#define F_LANE_12_BLCK_LCK V_LANE_12_BLCK_LCK(1U)
-
-#define S_LANE_11_BLCK_LCK 3
-#define V_LANE_11_BLCK_LCK(x) ((x) << S_LANE_11_BLCK_LCK)
-#define F_LANE_11_BLCK_LCK V_LANE_11_BLCK_LCK(1U)
-
-#define S_LANE_10_BLCK_LCK 2
-#define V_LANE_10_BLCK_LCK(x) ((x) << S_LANE_10_BLCK_LCK)
-#define F_LANE_10_BLCK_LCK V_LANE_10_BLCK_LCK(1U)
-
-#define S_LANE_9_BLCK_LCK 1
-#define V_LANE_9_BLCK_LCK(x) ((x) << S_LANE_9_BLCK_LCK)
-#define F_LANE_9_BLCK_LCK V_LANE_9_BLCK_LCK(1U)
-
-#define S_LANE_8_BLCK_LCK 0
-#define V_LANE_8_BLCK_LCK(x) ((x) << S_LANE_8_BLCK_LCK)
-#define F_LANE_8_BLCK_LCK V_LANE_8_BLCK_LCK(1U)
-
-#define A_MAC_PORT_MTIP_CR4_MULTI_LANE_ALIGN_STATUS_3 0x1bd0
-
-#define S_LANE7_ALGN_MRKR_LCK 7
-#define V_LANE7_ALGN_MRKR_LCK(x) ((x) << S_LANE7_ALGN_MRKR_LCK)
-#define F_LANE7_ALGN_MRKR_LCK V_LANE7_ALGN_MRKR_LCK(1U)
-
-#define S_LANE6_ALGN_MRKR_LCK 6
-#define V_LANE6_ALGN_MRKR_LCK(x) ((x) << S_LANE6_ALGN_MRKR_LCK)
-#define F_LANE6_ALGN_MRKR_LCK V_LANE6_ALGN_MRKR_LCK(1U)
-
-#define S_LANE5_ALGN_MRKR_LCK 5
-#define V_LANE5_ALGN_MRKR_LCK(x) ((x) << S_LANE5_ALGN_MRKR_LCK)
-#define F_LANE5_ALGN_MRKR_LCK V_LANE5_ALGN_MRKR_LCK(1U)
-
-#define S_LANE4_ALGN_MRKR_LCK 4
-#define V_LANE4_ALGN_MRKR_LCK(x) ((x) << S_LANE4_ALGN_MRKR_LCK)
-#define F_LANE4_ALGN_MRKR_LCK V_LANE4_ALGN_MRKR_LCK(1U)
-
-#define S_LANE3_ALGN_MRKR_LCK 3
-#define V_LANE3_ALGN_MRKR_LCK(x) ((x) << S_LANE3_ALGN_MRKR_LCK)
-#define F_LANE3_ALGN_MRKR_LCK V_LANE3_ALGN_MRKR_LCK(1U)
-
-#define S_LANE2_ALGN_MRKR_LCK 2
-#define V_LANE2_ALGN_MRKR_LCK(x) ((x) << S_LANE2_ALGN_MRKR_LCK)
-#define F_LANE2_ALGN_MRKR_LCK V_LANE2_ALGN_MRKR_LCK(1U)
-
-#define S_LANE1_ALGN_MRKR_LCK 1
-#define V_LANE1_ALGN_MRKR_LCK(x) ((x) << S_LANE1_ALGN_MRKR_LCK)
-#define F_LANE1_ALGN_MRKR_LCK V_LANE1_ALGN_MRKR_LCK(1U)
-
-#define S_LANE0_ALGN_MRKR_LCK 0
-#define V_LANE0_ALGN_MRKR_LCK(x) ((x) << S_LANE0_ALGN_MRKR_LCK)
-#define F_LANE0_ALGN_MRKR_LCK V_LANE0_ALGN_MRKR_LCK(1U)
-
-#define A_MAC_PORT_MTIP_CR4_MULTI_LANE_ALIGN_STATUS_4 0x1bd4
-
-#define S_LANE19_ALGN_MRKR_LCK 11
-#define V_LANE19_ALGN_MRKR_LCK(x) ((x) << S_LANE19_ALGN_MRKR_LCK)
-#define F_LANE19_ALGN_MRKR_LCK V_LANE19_ALGN_MRKR_LCK(1U)
-
-#define S_LANE18_ALGN_MRKR_LCK 10
-#define V_LANE18_ALGN_MRKR_LCK(x) ((x) << S_LANE18_ALGN_MRKR_LCK)
-#define F_LANE18_ALGN_MRKR_LCK V_LANE18_ALGN_MRKR_LCK(1U)
-
-#define S_LANE17_ALGN_MRKR_LCK 9
-#define V_LANE17_ALGN_MRKR_LCK(x) ((x) << S_LANE17_ALGN_MRKR_LCK)
-#define F_LANE17_ALGN_MRKR_LCK V_LANE17_ALGN_MRKR_LCK(1U)
-
-#define S_LANE16_ALGN_MRKR_LCK 8
-#define V_LANE16_ALGN_MRKR_LCK(x) ((x) << S_LANE16_ALGN_MRKR_LCK)
-#define F_LANE16_ALGN_MRKR_LCK V_LANE16_ALGN_MRKR_LCK(1U)
-
-#define S_LANE15_ALGN_MRKR_LCK 7
-#define V_LANE15_ALGN_MRKR_LCK(x) ((x) << S_LANE15_ALGN_MRKR_LCK)
-#define F_LANE15_ALGN_MRKR_LCK V_LANE15_ALGN_MRKR_LCK(1U)
-
-#define S_LANE14_ALGN_MRKR_LCK 6
-#define V_LANE14_ALGN_MRKR_LCK(x) ((x) << S_LANE14_ALGN_MRKR_LCK)
-#define F_LANE14_ALGN_MRKR_LCK V_LANE14_ALGN_MRKR_LCK(1U)
-
-#define S_LANE13_ALGN_MRKR_LCK 5
-#define V_LANE13_ALGN_MRKR_LCK(x) ((x) << S_LANE13_ALGN_MRKR_LCK)
-#define F_LANE13_ALGN_MRKR_LCK V_LANE13_ALGN_MRKR_LCK(1U)
-
-#define S_LANE12_ALGN_MRKR_LCK 4
-#define V_LANE12_ALGN_MRKR_LCK(x) ((x) << S_LANE12_ALGN_MRKR_LCK)
-#define F_LANE12_ALGN_MRKR_LCK V_LANE12_ALGN_MRKR_LCK(1U)
-
-#define S_LANE11_ALGN_MRKR_LCK 3
-#define V_LANE11_ALGN_MRKR_LCK(x) ((x) << S_LANE11_ALGN_MRKR_LCK)
-#define F_LANE11_ALGN_MRKR_LCK V_LANE11_ALGN_MRKR_LCK(1U)
-
-#define S_LANE10_ALGN_MRKR_LCK 2
-#define V_LANE10_ALGN_MRKR_LCK(x) ((x) << S_LANE10_ALGN_MRKR_LCK)
-#define F_LANE10_ALGN_MRKR_LCK V_LANE10_ALGN_MRKR_LCK(1U)
-
-#define S_LANE9_ALGN_MRKR_LCK 1
-#define V_LANE9_ALGN_MRKR_LCK(x) ((x) << S_LANE9_ALGN_MRKR_LCK)
-#define F_LANE9_ALGN_MRKR_LCK V_LANE9_ALGN_MRKR_LCK(1U)
-
-#define S_LANE8_ALGN_MRKR_LCK 0
-#define V_LANE8_ALGN_MRKR_LCK(x) ((x) << S_LANE8_ALGN_MRKR_LCK)
-#define F_LANE8_ALGN_MRKR_LCK V_LANE8_ALGN_MRKR_LCK(1U)
-
-#define A_MAC_PORT_MTIP_PCS_CTL 0x1e00
-
-#define S_PCS_LPBK 14
-#define V_PCS_LPBK(x) ((x) << S_PCS_LPBK)
-#define F_PCS_LPBK V_PCS_LPBK(1U)
-
-#define S_SPEED_SEL1 13
-#define V_SPEED_SEL1(x) ((x) << S_SPEED_SEL1)
-#define F_SPEED_SEL1 V_SPEED_SEL1(1U)
-
-#define S_LP_MODE 11
-#define V_LP_MODE(x) ((x) << S_LP_MODE)
-#define F_LP_MODE V_LP_MODE(1U)
-
-#define S_SPEED_SEL0 6
-#define V_SPEED_SEL0(x) ((x) << S_SPEED_SEL0)
-#define F_SPEED_SEL0 V_SPEED_SEL0(1U)
-
-#define S_PCS_SPEED 2
-#define M_PCS_SPEED 0xfU
-#define V_PCS_SPEED(x) ((x) << S_PCS_SPEED)
-#define G_PCS_SPEED(x) (((x) >> S_PCS_SPEED) & M_PCS_SPEED)
-
-#define A_MAC_PORT_MTIP_PCS_STATUS1 0x1e04
-
-#define S_FAULTDET 7
-#define V_FAULTDET(x) ((x) << S_FAULTDET)
-#define F_FAULTDET V_FAULTDET(1U)
-
-#define S_RX_LINK_STATUS 2
-#define V_RX_LINK_STATUS(x) ((x) << S_RX_LINK_STATUS)
-#define F_RX_LINK_STATUS V_RX_LINK_STATUS(1U)
-
-#define S_LOPWRABL 1
-#define V_LOPWRABL(x) ((x) << S_LOPWRABL)
-#define F_LOPWRABL V_LOPWRABL(1U)
-
-#define A_MAC_PORT_MTIP_PCS_DEVICE_ID0 0x1e08
-
-#define S_DEVICE_ID0 0
-#define M_DEVICE_ID0 0xffffU
-#define V_DEVICE_ID0(x) ((x) << S_DEVICE_ID0)
-#define G_DEVICE_ID0(x) (((x) >> S_DEVICE_ID0) & M_DEVICE_ID0)
-
-#define A_MAC_PORT_MTIP_PCS_DEVICE_ID1 0x1e0c
-
-#define S_DEVICE_ID1 0
-#define M_DEVICE_ID1 0xffffU
-#define V_DEVICE_ID1(x) ((x) << S_DEVICE_ID1)
-#define G_DEVICE_ID1(x) (((x) >> S_DEVICE_ID1) & M_DEVICE_ID1)
-
-#define A_MAC_PORT_MTIP_PCS_SPEED_ABILITY 0x1e10
-
-#define S_100G 8
-#define V_100G(x) ((x) << S_100G)
-#define F_100G V_100G(1U)
-
-#define S_40G 7
-#define V_40G(x) ((x) << S_40G)
-#define F_40G V_40G(1U)
-
-#define S_10BASE_TL 1
-#define V_10BASE_TL(x) ((x) << S_10BASE_TL)
-#define F_10BASE_TL V_10BASE_TL(1U)
-
-#define S_10G 0
-#define V_10G(x) ((x) << S_10G)
-#define F_10G V_10G(1U)
-
-#define A_MAC_PORT_MTIP_PCS_DEVICE_PKG1 0x1e14
-
-#define S_TC_PRESENT 6
-#define V_TC_PRESENT(x) ((x) << S_TC_PRESENT)
-#define F_TC_PRESENT V_TC_PRESENT(1U)
-
-#define S_DTEXS 5
-#define V_DTEXS(x) ((x) << S_DTEXS)
-#define F_DTEXS V_DTEXS(1U)
-
-#define S_PHYXS 4
-#define V_PHYXS(x) ((x) << S_PHYXS)
-#define F_PHYXS V_PHYXS(1U)
-
-#define S_PCS 3
-#define V_PCS(x) ((x) << S_PCS)
-#define F_PCS V_PCS(1U)
-
-#define S_WIS 2
-#define V_WIS(x) ((x) << S_WIS)
-#define F_WIS V_WIS(1U)
-
-#define S_PMD_PMA 1
-#define V_PMD_PMA(x) ((x) << S_PMD_PMA)
-#define F_PMD_PMA V_PMD_PMA(1U)
-
-#define S_CL22 0
-#define V_CL22(x) ((x) << S_CL22)
-#define F_CL22 V_CL22(1U)
-
-#define A_MAC_PORT_MTIP_PCS_DEVICE_PKG2 0x1e18
-
-#define S_VENDDEV2 15
-#define V_VENDDEV2(x) ((x) << S_VENDDEV2)
-#define F_VENDDEV2 V_VENDDEV2(1U)
-
-#define S_VENDDEV1 14
-#define V_VENDDEV1(x) ((x) << S_VENDDEV1)
-#define F_VENDDEV1 V_VENDDEV1(1U)
-
-#define S_CL22EXT 13
-#define V_CL22EXT(x) ((x) << S_CL22EXT)
-#define F_CL22EXT V_CL22EXT(1U)
-
-#define A_MAC_PORT_MTIP_PCS_CTL2 0x1e1c
-
-#define S_PCSTYPE 0
-#define M_PCSTYPE 0x7U
-#define V_PCSTYPE(x) ((x) << S_PCSTYPE)
-#define G_PCSTYPE(x) (((x) >> S_PCSTYPE) & M_PCSTYPE)
-
-#define A_MAC_PORT_MTIP_PCS_STATUS2 0x1e20
-
-#define S_PCS_STAT2_DEVICE 15
-#define V_PCS_STAT2_DEVICE(x) ((x) << S_PCS_STAT2_DEVICE)
-#define F_PCS_STAT2_DEVICE V_PCS_STAT2_DEVICE(1U)
-
-#define S_TXFAULT 7
-#define V_TXFAULT(x) ((x) << S_TXFAULT)
-#define F_TXFAULT V_TXFAULT(1U)
-
-#define S_RXFAULT 6
-#define V_RXFAULT(x) ((x) << S_RXFAULT)
-#define F_RXFAULT V_RXFAULT(1U)
-
-#define S_100BASE_R 5
-#define V_100BASE_R(x) ((x) << S_100BASE_R)
-#define F_100BASE_R V_100BASE_R(1U)
-
-#define S_40GBASE_R 4
-#define V_40GBASE_R(x) ((x) << S_40GBASE_R)
-#define F_40GBASE_R V_40GBASE_R(1U)
-
-#define S_10GBASE_T 3
-#define V_10GBASE_T(x) ((x) << S_10GBASE_T)
-#define F_10GBASE_T V_10GBASE_T(1U)
-
-#define S_10GBASE_W 2
-#define V_10GBASE_W(x) ((x) << S_10GBASE_W)
-#define F_10GBASE_W V_10GBASE_W(1U)
-
-#define S_10GBASE_X 1
-#define V_10GBASE_X(x) ((x) << S_10GBASE_X)
-#define F_10GBASE_X V_10GBASE_X(1U)
-
-#define S_10GBASE_R 0
-#define V_10GBASE_R(x) ((x) << S_10GBASE_R)
-#define F_10GBASE_R V_10GBASE_R(1U)
-
-#define A_MAC_PORT_MTIP_CR4_BIP_ERR_CNTLANE_0 0x1e20
-
-#define S_BIP_ERR_CNTLANE_0 0
-#define M_BIP_ERR_CNTLANE_0 0xffffU
-#define V_BIP_ERR_CNTLANE_0(x) ((x) << S_BIP_ERR_CNTLANE_0)
-#define G_BIP_ERR_CNTLANE_0(x) (((x) >> S_BIP_ERR_CNTLANE_0) & M_BIP_ERR_CNTLANE_0)
-
-#define A_MAC_PORT_MTIP_CR4_BIP_ERR_CNTLANE_1 0x1e24
-
-#define S_BIP_ERR_CNTLANE_1 0
-#define M_BIP_ERR_CNTLANE_1 0xffffU
-#define V_BIP_ERR_CNTLANE_1(x) ((x) << S_BIP_ERR_CNTLANE_1)
-#define G_BIP_ERR_CNTLANE_1(x) (((x) >> S_BIP_ERR_CNTLANE_1) & M_BIP_ERR_CNTLANE_1)
-
-#define A_MAC_PORT_MTIP_CR4_BIP_ERR_CNTLANE_2 0x1e28
-
-#define S_BIP_ERR_CNTLANE_2 0
-#define M_BIP_ERR_CNTLANE_2 0xffffU
-#define V_BIP_ERR_CNTLANE_2(x) ((x) << S_BIP_ERR_CNTLANE_2)
-#define G_BIP_ERR_CNTLANE_2(x) (((x) >> S_BIP_ERR_CNTLANE_2) & M_BIP_ERR_CNTLANE_2)
-
-#define A_MAC_PORT_MTIP_CR4_BIP_ERR_CNTLANE_3 0x1e2c
-
-#define S_BIP_ERR_CNTLANE_3 0
-#define M_BIP_ERR_CNTLANE_3 0xffffU
-#define V_BIP_ERR_CNTLANE_3(x) ((x) << S_BIP_ERR_CNTLANE_3)
-#define G_BIP_ERR_CNTLANE_3(x) (((x) >> S_BIP_ERR_CNTLANE_3) & M_BIP_ERR_CNTLANE_3)
-
-#define A_MAC_PORT_MTIP_CR4_BIP_ERR_CNTLANE_4 0x1e30
-
-#define S_BIP_ERR_CNTLANE_4 0
-#define M_BIP_ERR_CNTLANE_4 0xffffU
-#define V_BIP_ERR_CNTLANE_4(x) ((x) << S_BIP_ERR_CNTLANE_4)
-#define G_BIP_ERR_CNTLANE_4(x) (((x) >> S_BIP_ERR_CNTLANE_4) & M_BIP_ERR_CNTLANE_4)
-
-#define A_MAC_PORT_MTIP_CR4_BIP_ERR_CNTLANE_5 0x1e34
-
-#define S_BIP_ERR_CNTLANE_5 0
-#define M_BIP_ERR_CNTLANE_5 0xffffU
-#define V_BIP_ERR_CNTLANE_5(x) ((x) << S_BIP_ERR_CNTLANE_5)
-#define G_BIP_ERR_CNTLANE_5(x) (((x) >> S_BIP_ERR_CNTLANE_5) & M_BIP_ERR_CNTLANE_5)
-
-#define A_MAC_PORT_MTIP_PCS_PKG_ID0 0x1e38
-
-#define S_PKG_ID0 0
-#define M_PKG_ID0 0xffffU
-#define V_PKG_ID0(x) ((x) << S_PKG_ID0)
-#define G_PKG_ID0(x) (((x) >> S_PKG_ID0) & M_PKG_ID0)
-
-#define A_MAC_PORT_MTIP_CR4_BIP_ERR_CNTLANE_6 0x1e38
-
-#define S_BIP_ERR_CNTLANE_6 0
-#define M_BIP_ERR_CNTLANE_6 0xffffU
-#define V_BIP_ERR_CNTLANE_6(x) ((x) << S_BIP_ERR_CNTLANE_6)
-#define G_BIP_ERR_CNTLANE_6(x) (((x) >> S_BIP_ERR_CNTLANE_6) & M_BIP_ERR_CNTLANE_6)
-
-#define A_MAC_PORT_MTIP_PCS_PKG_ID1 0x1e3c
-
-#define S_PKG_ID1 0
-#define M_PKG_ID1 0xffffU
-#define V_PKG_ID1(x) ((x) << S_PKG_ID1)
-#define G_PKG_ID1(x) (((x) >> S_PKG_ID1) & M_PKG_ID1)
-
-#define A_MAC_PORT_MTIP_CR4_BIP_ERR_CNTLANE_7 0x1e3c
-
-#define S_BIP_ERR_CNTLANE_7 0
-#define M_BIP_ERR_CNTLANE_7 0xffffU
-#define V_BIP_ERR_CNTLANE_7(x) ((x) << S_BIP_ERR_CNTLANE_7)
-#define G_BIP_ERR_CNTLANE_7(x) (((x) >> S_BIP_ERR_CNTLANE_7) & M_BIP_ERR_CNTLANE_7)
-
-#define A_MAC_PORT_MTIP_CR4_BIP_ERR_CNTLANE_8 0x1e40
-
-#define S_BIP_ERR_CNTLANE_8 0
-#define M_BIP_ERR_CNTLANE_8 0xffffU
-#define V_BIP_ERR_CNTLANE_8(x) ((x) << S_BIP_ERR_CNTLANE_8)
-#define G_BIP_ERR_CNTLANE_8(x) (((x) >> S_BIP_ERR_CNTLANE_8) & M_BIP_ERR_CNTLANE_8)
-
-#define A_MAC_PORT_MTIP_CR4_BIP_ERR_CNTLANE_9 0x1e44
-
-#define S_BIP_ERR_CNTLANE_9 0
-#define M_BIP_ERR_CNTLANE_9 0xffffU
-#define V_BIP_ERR_CNTLANE_9(x) ((x) << S_BIP_ERR_CNTLANE_9)
-#define G_BIP_ERR_CNTLANE_9(x) (((x) >> S_BIP_ERR_CNTLANE_9) & M_BIP_ERR_CNTLANE_9)
-
-#define A_MAC_PORT_MTIP_CR4_BIP_ERR_CNTLANE_10 0x1e48
-
-#define S_BIP_ERR_CNTLANE_10 0
-#define M_BIP_ERR_CNTLANE_10 0xffffU
-#define V_BIP_ERR_CNTLANE_10(x) ((x) << S_BIP_ERR_CNTLANE_10)
-#define G_BIP_ERR_CNTLANE_10(x) (((x) >> S_BIP_ERR_CNTLANE_10) & M_BIP_ERR_CNTLANE_10)
-
-#define A_MAC_PORT_MTIP_CR4_BIP_ERR_CNTLANE_11 0x1e4c
-
-#define S_BIP_ERR_CNTLANE_11 0
-#define M_BIP_ERR_CNTLANE_11 0xffffU
-#define V_BIP_ERR_CNTLANE_11(x) ((x) << S_BIP_ERR_CNTLANE_11)
-#define G_BIP_ERR_CNTLANE_11(x) (((x) >> S_BIP_ERR_CNTLANE_11) & M_BIP_ERR_CNTLANE_11)
-
-#define A_MAC_PORT_MTIP_CR4_BIP_ERR_CNTLANE_12 0x1e50
-
-#define S_BIP_ERR_CNTLANE_12 0
-#define M_BIP_ERR_CNTLANE_12 0xffffU
-#define V_BIP_ERR_CNTLANE_12(x) ((x) << S_BIP_ERR_CNTLANE_12)
-#define G_BIP_ERR_CNTLANE_12(x) (((x) >> S_BIP_ERR_CNTLANE_12) & M_BIP_ERR_CNTLANE_12)
-
-#define A_MAC_PORT_MTIP_CR4_BIP_ERR_CNTLANE_13 0x1e54
-
-#define S_BIP_ERR_CNTLANE_13 0
-#define M_BIP_ERR_CNTLANE_13 0xffffU
-#define V_BIP_ERR_CNTLANE_13(x) ((x) << S_BIP_ERR_CNTLANE_13)
-#define G_BIP_ERR_CNTLANE_13(x) (((x) >> S_BIP_ERR_CNTLANE_13) & M_BIP_ERR_CNTLANE_13)
-
-#define A_MAC_PORT_MTIP_CR4_BIP_ERR_CNTLANE_14 0x1e58
-
-#define S_BIP_ERR_CNTLANE_14 0
-#define M_BIP_ERR_CNTLANE_14 0xffffU
-#define V_BIP_ERR_CNTLANE_14(x) ((x) << S_BIP_ERR_CNTLANE_14)
-#define G_BIP_ERR_CNTLANE_14(x) (((x) >> S_BIP_ERR_CNTLANE_14) & M_BIP_ERR_CNTLANE_14)
-
-#define A_MAC_PORT_MTIP_CR4_BIP_ERR_CNTLANE_15 0x1e5c
-
-#define S_BIP_ERR_CNTLANE_15 0
-#define M_BIP_ERR_CNTLANE_15 0xffffU
-#define V_BIP_ERR_CNTLANE_15(x) ((x) << S_BIP_ERR_CNTLANE_15)
-#define G_BIP_ERR_CNTLANE_15(x) (((x) >> S_BIP_ERR_CNTLANE_15) & M_BIP_ERR_CNTLANE_15)
-
-#define A_MAC_PORT_MTIP_CR4_BIP_ERR_CNTLANE_16 0x1e60
-
-#define S_BIP_ERR_CNTLANE_16 0
-#define M_BIP_ERR_CNTLANE_16 0xffffU
-#define V_BIP_ERR_CNTLANE_16(x) ((x) << S_BIP_ERR_CNTLANE_16)
-#define G_BIP_ERR_CNTLANE_16(x) (((x) >> S_BIP_ERR_CNTLANE_16) & M_BIP_ERR_CNTLANE_16)
-
-#define A_MAC_PORT_MTIP_CR4_BIP_ERR_CNTLANE_17 0x1e64
-
-#define S_BIP_ERR_CNTLANE_17 0
-#define M_BIP_ERR_CNTLANE_17 0xffffU
-#define V_BIP_ERR_CNTLANE_17(x) ((x) << S_BIP_ERR_CNTLANE_17)
-#define G_BIP_ERR_CNTLANE_17(x) (((x) >> S_BIP_ERR_CNTLANE_17) & M_BIP_ERR_CNTLANE_17)
-
-#define A_MAC_PORT_MTIP_CR4_BIP_ERR_CNTLANE_18 0x1e68
-
-#define S_BIP_ERR_CNTLANE_18 0
-#define M_BIP_ERR_CNTLANE_18 0xffffU
-#define V_BIP_ERR_CNTLANE_18(x) ((x) << S_BIP_ERR_CNTLANE_18)
-#define G_BIP_ERR_CNTLANE_18(x) (((x) >> S_BIP_ERR_CNTLANE_18) & M_BIP_ERR_CNTLANE_18)
-
-#define A_MAC_PORT_MTIP_CR4_BIP_ERR_CNTLANE_19 0x1e6c
-
-#define S_BIP_ERR_CNTLANE_19 0
-#define M_BIP_ERR_CNTLANE_19 0xffffU
-#define V_BIP_ERR_CNTLANE_19(x) ((x) << S_BIP_ERR_CNTLANE_19)
-#define G_BIP_ERR_CNTLANE_19(x) (((x) >> S_BIP_ERR_CNTLANE_19) & M_BIP_ERR_CNTLANE_19)
-
-#define A_MAC_PORT_MTIP_PCS_BASER_STATUS1 0x1e80
-
-#define S_RXLINKSTATUS 12
-#define V_RXLINKSTATUS(x) ((x) << S_RXLINKSTATUS)
-#define F_RXLINKSTATUS V_RXLINKSTATUS(1U)
-
-#define S_RESEREVED 4
-#define M_RESEREVED 0xffU
-#define V_RESEREVED(x) ((x) << S_RESEREVED)
-#define G_RESEREVED(x) (((x) >> S_RESEREVED) & M_RESEREVED)
-
-#define S_10GPRBS9 3
-#define V_10GPRBS9(x) ((x) << S_10GPRBS9)
-#define F_10GPRBS9 V_10GPRBS9(1U)
-
-#define S_10GPRBS31 2
-#define V_10GPRBS31(x) ((x) << S_10GPRBS31)
-#define F_10GPRBS31 V_10GPRBS31(1U)
-
-#define S_HIBER 1
-#define V_HIBER(x) ((x) << S_HIBER)
-#define F_HIBER V_HIBER(1U)
-
-#define S_BLOCKLOCK 0
-#define V_BLOCKLOCK(x) ((x) << S_BLOCKLOCK)
-#define F_BLOCKLOCK V_BLOCKLOCK(1U)
-
-#define A_MAC_PORT_MTIP_PCS_BASER_STATUS2 0x1e84
-
-#define S_BLOCKLOCKLL 15
-#define V_BLOCKLOCKLL(x) ((x) << S_BLOCKLOCKLL)
-#define F_BLOCKLOCKLL V_BLOCKLOCKLL(1U)
-
-#define S_HIBERLH 14
-#define V_HIBERLH(x) ((x) << S_HIBERLH)
-#define F_HIBERLH V_HIBERLH(1U)
-
-#define S_HIBERCOUNT 8
-#define M_HIBERCOUNT 0x3fU
-#define V_HIBERCOUNT(x) ((x) << S_HIBERCOUNT)
-#define G_HIBERCOUNT(x) (((x) >> S_HIBERCOUNT) & M_HIBERCOUNT)
-
-#define S_ERRBLKCNT 0
-#define M_ERRBLKCNT 0xffU
-#define V_ERRBLKCNT(x) ((x) << S_ERRBLKCNT)
-#define G_ERRBLKCNT(x) (((x) >> S_ERRBLKCNT) & M_ERRBLKCNT)
-
-#define A_MAC_PORT_MTIP_10GBASER_SEED_A 0x1e88
-
-#define S_SEEDA 0
-#define M_SEEDA 0xffffU
-#define V_SEEDA(x) ((x) << S_SEEDA)
-#define G_SEEDA(x) (((x) >> S_SEEDA) & M_SEEDA)
-
-#define A_MAC_PORT_MTIP_10GBASER_SEED_A1 0x1e8c
-
-#define S_SEEDA1 0
-#define M_SEEDA1 0xffffU
-#define V_SEEDA1(x) ((x) << S_SEEDA1)
-#define G_SEEDA1(x) (((x) >> S_SEEDA1) & M_SEEDA1)
-
-#define A_MAC_PORT_MTIP_10GBASER_SEED_A2 0x1e90
-
-#define S_SEEDA2 0
-#define M_SEEDA2 0xffffU
-#define V_SEEDA2(x) ((x) << S_SEEDA2)
-#define G_SEEDA2(x) (((x) >> S_SEEDA2) & M_SEEDA2)
-
-#define A_MAC_PORT_MTIP_10GBASER_SEED_A3 0x1e94
-
-#define S_SEEDA3 0
-#define M_SEEDA3 0x3ffU
-#define V_SEEDA3(x) ((x) << S_SEEDA3)
-#define G_SEEDA3(x) (((x) >> S_SEEDA3) & M_SEEDA3)
-
-#define A_MAC_PORT_MTIP_10GBASER_SEED_B 0x1e98
-
-#define S_SEEDB 0
-#define M_SEEDB 0xffffU
-#define V_SEEDB(x) ((x) << S_SEEDB)
-#define G_SEEDB(x) (((x) >> S_SEEDB) & M_SEEDB)
-
-#define A_MAC_PORT_MTIP_10GBASER_SEED_B1 0x1e9c
-
-#define S_SEEDB1 0
-#define M_SEEDB1 0xffffU
-#define V_SEEDB1(x) ((x) << S_SEEDB1)
-#define G_SEEDB1(x) (((x) >> S_SEEDB1) & M_SEEDB1)
-
-#define A_MAC_PORT_MTIP_10GBASER_SEED_B2 0x1ea0
-
-#define S_SEEDB2 0
-#define M_SEEDB2 0xffffU
-#define V_SEEDB2(x) ((x) << S_SEEDB2)
-#define G_SEEDB2(x) (((x) >> S_SEEDB2) & M_SEEDB2)
-
-#define A_MAC_PORT_MTIP_10GBASER_SEED_B3 0x1ea4
-
-#define S_SEEDB3 0
-#define M_SEEDB3 0x3ffU
-#define V_SEEDB3(x) ((x) << S_SEEDB3)
-#define G_SEEDB3(x) (((x) >> S_SEEDB3) & M_SEEDB3)
-
-#define A_MAC_PORT_MTIP_BASER_TEST_CTRL 0x1ea8
-
-#define S_TXPRBS9 6
-#define V_TXPRBS9(x) ((x) << S_TXPRBS9)
-#define F_TXPRBS9 V_TXPRBS9(1U)
-
-#define S_RXPRBS31 5
-#define V_RXPRBS31(x) ((x) << S_RXPRBS31)
-#define F_RXPRBS31 V_RXPRBS31(1U)
-
-#define S_TXPRBS31 4
-#define V_TXPRBS31(x) ((x) << S_TXPRBS31)
-#define F_TXPRBS31 V_TXPRBS31(1U)
-
-#define S_TXTESTPATEN 3
-#define V_TXTESTPATEN(x) ((x) << S_TXTESTPATEN)
-#define F_TXTESTPATEN V_TXTESTPATEN(1U)
-
-#define S_RXTESTPATEN 2
-#define V_RXTESTPATEN(x) ((x) << S_RXTESTPATEN)
-#define F_RXTESTPATEN V_RXTESTPATEN(1U)
-
-#define S_TESTPATSEL 1
-#define V_TESTPATSEL(x) ((x) << S_TESTPATSEL)
-#define F_TESTPATSEL V_TESTPATSEL(1U)
-
-#define S_DATAPATSEL 0
-#define V_DATAPATSEL(x) ((x) << S_DATAPATSEL)
-#define F_DATAPATSEL V_DATAPATSEL(1U)
-
-#define A_MAC_PORT_MTIP_BASER_TEST_ERR_CNT 0x1eac
-
-#define S_TEST_ERR_CNT 0
-#define M_TEST_ERR_CNT 0xffffU
-#define V_TEST_ERR_CNT(x) ((x) << S_TEST_ERR_CNT)
-#define G_TEST_ERR_CNT(x) (((x) >> S_TEST_ERR_CNT) & M_TEST_ERR_CNT)
-
-#define A_MAC_PORT_MTIP_BER_HIGH_ORDER_CNT 0x1eb0
-
-#define S_BER_CNT_HI 0
-#define M_BER_CNT_HI 0xffffU
-#define V_BER_CNT_HI(x) ((x) << S_BER_CNT_HI)
-#define G_BER_CNT_HI(x) (((x) >> S_BER_CNT_HI) & M_BER_CNT_HI)
-
-#define A_MAC_PORT_MTIP_BLK_HIGH_ORDER_CNT 0x1eb4
-
-#define S_HICOUNTPRSNT 15
-#define V_HICOUNTPRSNT(x) ((x) << S_HICOUNTPRSNT)
-#define F_HICOUNTPRSNT V_HICOUNTPRSNT(1U)
-
-#define S_BLOCK_CNT_HI 0
-#define M_BLOCK_CNT_HI 0x3fffU
-#define V_BLOCK_CNT_HI(x) ((x) << S_BLOCK_CNT_HI)
-#define G_BLOCK_CNT_HI(x) (((x) >> S_BLOCK_CNT_HI) & M_BLOCK_CNT_HI)
-
-#define A_MAC_PORT_MTIP_PCS_MULTI_LANE_ALIGN_STATUS1 0x1ec8
-
-#define S_ALIGNSTATUS 12
-#define V_ALIGNSTATUS(x) ((x) << S_ALIGNSTATUS)
-#define F_ALIGNSTATUS V_ALIGNSTATUS(1U)
-
-#define S_LANE7 7
-#define V_LANE7(x) ((x) << S_LANE7)
-#define F_LANE7 V_LANE7(1U)
-
-#define S_LANE6 6
-#define V_LANE6(x) ((x) << S_LANE6)
-#define F_LANE6 V_LANE6(1U)
-
-#define S_LANE5 5
-#define V_LANE5(x) ((x) << S_LANE5)
-#define F_LANE5 V_LANE5(1U)
-
-#define S_LANE4 4
-#define V_LANE4(x) ((x) << S_LANE4)
-#define F_LANE4 V_LANE4(1U)
-
-#define S_LANE3 3
-#define V_LANE3(x) ((x) << S_LANE3)
-#define F_LANE3 V_LANE3(1U)
-
-#define S_LANE2 2
-#define V_LANE2(x) ((x) << S_LANE2)
-#define F_LANE2 V_LANE2(1U)
-
-#define S_LANE1 1
-#define V_LANE1(x) ((x) << S_LANE1)
-#define F_LANE1 V_LANE1(1U)
-
-#define S_LANE0 0
-#define V_LANE0(x) ((x) << S_LANE0)
-#define F_LANE0 V_LANE0(1U)
-
-#define A_MAC_PORT_MTIP_PCS_MULTI_LANE_ALIGN_STATUS2 0x1ecc
-
-#define S_LANE19 11
-#define V_LANE19(x) ((x) << S_LANE19)
-#define F_LANE19 V_LANE19(1U)
-
-#define S_LANE18 10
-#define V_LANE18(x) ((x) << S_LANE18)
-#define F_LANE18 V_LANE18(1U)
-
-#define S_LANE17 9
-#define V_LANE17(x) ((x) << S_LANE17)
-#define F_LANE17 V_LANE17(1U)
-
-#define S_LANE16 8
-#define V_LANE16(x) ((x) << S_LANE16)
-#define F_LANE16 V_LANE16(1U)
-
-#define S_LANE15 7
-#define V_LANE15(x) ((x) << S_LANE15)
-#define F_LANE15 V_LANE15(1U)
-
-#define S_LANE14 6
-#define V_LANE14(x) ((x) << S_LANE14)
-#define F_LANE14 V_LANE14(1U)
-
-#define S_LANE13 5
-#define V_LANE13(x) ((x) << S_LANE13)
-#define F_LANE13 V_LANE13(1U)
-
-#define S_LANE12 4
-#define V_LANE12(x) ((x) << S_LANE12)
-#define F_LANE12 V_LANE12(1U)
-
-#define S_LANE11 3
-#define V_LANE11(x) ((x) << S_LANE11)
-#define F_LANE11 V_LANE11(1U)
-
-#define S_LANE10 2
-#define V_LANE10(x) ((x) << S_LANE10)
-#define F_LANE10 V_LANE10(1U)
-
-#define S_LANE9 1
-#define V_LANE9(x) ((x) << S_LANE9)
-#define F_LANE9 V_LANE9(1U)
-
-#define S_LANE8 0
-#define V_LANE8(x) ((x) << S_LANE8)
-#define F_LANE8 V_LANE8(1U)
-
-#define A_MAC_PORT_MTIP_PCS_MULTI_LANE_ALIGN_STATUS3 0x1ed0
-
-#define S_AMLOCK7 7
-#define V_AMLOCK7(x) ((x) << S_AMLOCK7)
-#define F_AMLOCK7 V_AMLOCK7(1U)
-
-#define S_AMLOCK6 6
-#define V_AMLOCK6(x) ((x) << S_AMLOCK6)
-#define F_AMLOCK6 V_AMLOCK6(1U)
-
-#define S_AMLOCK5 5
-#define V_AMLOCK5(x) ((x) << S_AMLOCK5)
-#define F_AMLOCK5 V_AMLOCK5(1U)
-
-#define S_AMLOCK4 4
-#define V_AMLOCK4(x) ((x) << S_AMLOCK4)
-#define F_AMLOCK4 V_AMLOCK4(1U)
-
-#define S_AMLOCK3 3
-#define V_AMLOCK3(x) ((x) << S_AMLOCK3)
-#define F_AMLOCK3 V_AMLOCK3(1U)
-
-#define S_AMLOCK2 2
-#define V_AMLOCK2(x) ((x) << S_AMLOCK2)
-#define F_AMLOCK2 V_AMLOCK2(1U)
-
-#define S_AMLOCK1 1
-#define V_AMLOCK1(x) ((x) << S_AMLOCK1)
-#define F_AMLOCK1 V_AMLOCK1(1U)
-
-#define S_AMLOCK0 0
-#define V_AMLOCK0(x) ((x) << S_AMLOCK0)
-#define F_AMLOCK0 V_AMLOCK0(1U)
-
-#define A_MAC_PORT_MTIP_PCS_MULTI_LANE_ALIGN_STATUS4 0x1ed4
-
-#define S_AMLOCK19 11
-#define V_AMLOCK19(x) ((x) << S_AMLOCK19)
-#define F_AMLOCK19 V_AMLOCK19(1U)
-
-#define S_AMLOCK18 10
-#define V_AMLOCK18(x) ((x) << S_AMLOCK18)
-#define F_AMLOCK18 V_AMLOCK18(1U)
-
-#define S_AMLOCK17 9
-#define V_AMLOCK17(x) ((x) << S_AMLOCK17)
-#define F_AMLOCK17 V_AMLOCK17(1U)
-
-#define S_AMLOCK16 8
-#define V_AMLOCK16(x) ((x) << S_AMLOCK16)
-#define F_AMLOCK16 V_AMLOCK16(1U)
-
-#define S_AMLOCK15 7
-#define V_AMLOCK15(x) ((x) << S_AMLOCK15)
-#define F_AMLOCK15 V_AMLOCK15(1U)
-
-#define S_AMLOCK14 6
-#define V_AMLOCK14(x) ((x) << S_AMLOCK14)
-#define F_AMLOCK14 V_AMLOCK14(1U)
-
-#define S_AMLOCK13 5
-#define V_AMLOCK13(x) ((x) << S_AMLOCK13)
-#define F_AMLOCK13 V_AMLOCK13(1U)
-
-#define S_AMLOCK12 4
-#define V_AMLOCK12(x) ((x) << S_AMLOCK12)
-#define F_AMLOCK12 V_AMLOCK12(1U)
-
-#define S_AMLOCK11 3
-#define V_AMLOCK11(x) ((x) << S_AMLOCK11)
-#define F_AMLOCK11 V_AMLOCK11(1U)
-
-#define S_AMLOCK10 2
-#define V_AMLOCK10(x) ((x) << S_AMLOCK10)
-#define F_AMLOCK10 V_AMLOCK10(1U)
-
-#define S_AMLOCK9 1
-#define V_AMLOCK9(x) ((x) << S_AMLOCK9)
-#define F_AMLOCK9 V_AMLOCK9(1U)
-
-#define S_AMLOCK8 0
-#define V_AMLOCK8(x) ((x) << S_AMLOCK8)
-#define F_AMLOCK8 V_AMLOCK8(1U)
-
-#define A_MAC_PORT_MTIP_PCS_BIP_ERR_CNT_0 0x1f68
-
-#define S_BIPERR_CNT 0
-#define M_BIPERR_CNT 0xffffU
-#define V_BIPERR_CNT(x) ((x) << S_BIPERR_CNT)
-#define G_BIPERR_CNT(x) (((x) >> S_BIPERR_CNT) & M_BIPERR_CNT)
-
-#define A_MAC_PORT_MTIP_PCS_BIP_ERR_CNT_1 0x1f6c
-#define A_MAC_PORT_MTIP_PCS_BIP_ERR_CNT_2 0x1f70
-#define A_MAC_PORT_MTIP_PCS_BIP_ERR_CNT_3 0x1f74
-#define A_MAC_PORT_MTIP_PCS_BIP_ERR_CNT_4 0x1f78
-#define A_MAC_PORT_MTIP_PCS_BIP_ERR_CNT_5 0x1f7c
-#define A_MAC_PORT_MTIP_PCS_BIP_ERR_CNT_6 0x1f80
-#define A_MAC_PORT_MTIP_PCS_BIP_ERR_CNT_7 0x1f84
-#define A_MAC_PORT_MTIP_PCS_BIP_ERR_CNT_8 0x1f88
-#define A_MAC_PORT_MTIP_PCS_BIP_ERR_CNT_9 0x1f8c
-#define A_MAC_PORT_MTIP_PCS_BIP_ERR_CNT_10 0x1f90
-#define A_MAC_PORT_MTIP_PCS_BIP_ERR_CNT_11 0x1f94
-#define A_MAC_PORT_MTIP_PCS_BIP_ERR_CNT_12 0x1f98
-#define A_MAC_PORT_MTIP_PCS_BIP_ERR_CNT_13 0x1f9c
-#define A_MAC_PORT_MTIP_PCS_BIP_ERR_CNT_14 0x1fa0
-#define A_MAC_PORT_MTIP_PCS_BIP_ERR_CNT_15 0x1fa4
-#define A_MAC_PORT_MTIP_PCS_BIP_ERR_CNT_16 0x1fa8
-#define A_MAC_PORT_MTIP_PCS_BIP_ERR_CNT_17 0x1fac
-#define A_MAC_PORT_MTIP_PCS_BIP_ERR_CNT_18 0x1fb0
-#define A_MAC_PORT_MTIP_PCS_BIP_ERR_CNT_19 0x1fb4
-#define A_MAC_PORT_MTIP_PCS_LANE_MAP_0 0x1fb8
-
-#define S_MAP 0
-#define M_MAP 0x1fU
-#define V_MAP(x) ((x) << S_MAP)
-#define G_MAP(x) (((x) >> S_MAP) & M_MAP)
-
-#define A_MAC_PORT_MTIP_PCS_LANE_MAP_1 0x1fbc
-#define A_MAC_PORT_MTIP_PCS_LANE_MAP_2 0x1fc0
-#define A_MAC_PORT_MTIP_PCS_LANE_MAP_3 0x1fc4
-#define A_MAC_PORT_MTIP_PCS_LANE_MAP_4 0x1fc8
-#define A_MAC_PORT_MTIP_PCS_LANE_MAP_5 0x1fcc
-#define A_MAC_PORT_MTIP_PCS_LANE_MAP_6 0x1fd0
-#define A_MAC_PORT_MTIP_PCS_LANE_MAP_7 0x1fd4
-#define A_MAC_PORT_MTIP_PCS_LANE_MAP_8 0x1fd8
-#define A_MAC_PORT_MTIP_PCS_LANE_MAP_9 0x1fdc
-#define A_MAC_PORT_MTIP_PCS_LANE_MAP_10 0x1fe0
-#define A_MAC_PORT_MTIP_PCS_LANE_MAP_11 0x1fe4
-#define A_MAC_PORT_MTIP_PCS_LANE_MAP_12 0x1fe8
-#define A_MAC_PORT_MTIP_PCS_LANE_MAP_13 0x1fec
-#define A_MAC_PORT_MTIP_PCS_LANE_MAP_14 0x1ff0
-#define A_MAC_PORT_MTIP_PCS_LANE_MAP_15 0x1ff4
-#define A_MAC_PORT_MTIP_PCS_LANE_MAP_16 0x1ff8
-#define A_MAC_PORT_MTIP_PCS_LANE_MAP_17 0x1ffc
-#define A_MAC_PORT_MTIP_PCS_LANE_MAP_18 0x2000
-#define A_MAC_PORT_MTIP_PCS_LANE_MAP_19 0x2004
-#define A_MAC_PORT_MTIP_CR4_LANE_0_MAPPING 0x2140
-
-#define S_LANE_0_MAPPING 0
-#define M_LANE_0_MAPPING 0x3fU
-#define V_LANE_0_MAPPING(x) ((x) << S_LANE_0_MAPPING)
-#define G_LANE_0_MAPPING(x) (((x) >> S_LANE_0_MAPPING) & M_LANE_0_MAPPING)
-
-#define A_MAC_PORT_MTIP_CR4_LANE_1_MAPPING 0x2144
-
-#define S_LANE_1_MAPPING 0
-#define M_LANE_1_MAPPING 0x3fU
-#define V_LANE_1_MAPPING(x) ((x) << S_LANE_1_MAPPING)
-#define G_LANE_1_MAPPING(x) (((x) >> S_LANE_1_MAPPING) & M_LANE_1_MAPPING)
-
-#define A_MAC_PORT_MTIP_CR4_LANE_2_MAPPING 0x2148
-
-#define S_LANE_2_MAPPING 0
-#define M_LANE_2_MAPPING 0x3fU
-#define V_LANE_2_MAPPING(x) ((x) << S_LANE_2_MAPPING)
-#define G_LANE_2_MAPPING(x) (((x) >> S_LANE_2_MAPPING) & M_LANE_2_MAPPING)
-
-#define A_MAC_PORT_MTIP_CR4_LANE_3_MAPPING 0x214c
-
-#define S_LANE_3_MAPPING 0
-#define M_LANE_3_MAPPING 0x3fU
-#define V_LANE_3_MAPPING(x) ((x) << S_LANE_3_MAPPING)
-#define G_LANE_3_MAPPING(x) (((x) >> S_LANE_3_MAPPING) & M_LANE_3_MAPPING)
-
-#define A_MAC_PORT_MTIP_CR4_LANE_4_MAPPING 0x2150
-
-#define S_LANE_4_MAPPING 0
-#define M_LANE_4_MAPPING 0x3fU
-#define V_LANE_4_MAPPING(x) ((x) << S_LANE_4_MAPPING)
-#define G_LANE_4_MAPPING(x) (((x) >> S_LANE_4_MAPPING) & M_LANE_4_MAPPING)
-
-#define A_MAC_PORT_MTIP_CR4_LANE_5_MAPPING 0x2154
-
-#define S_LANE_5_MAPPING 0
-#define M_LANE_5_MAPPING 0x3fU
-#define V_LANE_5_MAPPING(x) ((x) << S_LANE_5_MAPPING)
-#define G_LANE_5_MAPPING(x) (((x) >> S_LANE_5_MAPPING) & M_LANE_5_MAPPING)
-
-#define A_MAC_PORT_MTIP_CR4_LANE_6_MAPPING 0x2158
-
-#define S_LANE_6_MAPPING 0
-#define M_LANE_6_MAPPING 0x3fU
-#define V_LANE_6_MAPPING(x) ((x) << S_LANE_6_MAPPING)
-#define G_LANE_6_MAPPING(x) (((x) >> S_LANE_6_MAPPING) & M_LANE_6_MAPPING)
-
-#define A_MAC_PORT_MTIP_CR4_LANE_7_MAPPING 0x215c
-
-#define S_LANE_7_MAPPING 0
-#define M_LANE_7_MAPPING 0x3fU
-#define V_LANE_7_MAPPING(x) ((x) << S_LANE_7_MAPPING)
-#define G_LANE_7_MAPPING(x) (((x) >> S_LANE_7_MAPPING) & M_LANE_7_MAPPING)
-
-#define A_MAC_PORT_MTIP_CR4_LANE_8_MAPPING 0x2160
-
-#define S_LANE_8_MAPPING 0
-#define M_LANE_8_MAPPING 0x3fU
-#define V_LANE_8_MAPPING(x) ((x) << S_LANE_8_MAPPING)
-#define G_LANE_8_MAPPING(x) (((x) >> S_LANE_8_MAPPING) & M_LANE_8_MAPPING)
-
-#define A_MAC_PORT_MTIP_CR4_LANE_9_MAPPING 0x2164
-
-#define S_LANE_9_MAPPING 0
-#define M_LANE_9_MAPPING 0x3fU
-#define V_LANE_9_MAPPING(x) ((x) << S_LANE_9_MAPPING)
-#define G_LANE_9_MAPPING(x) (((x) >> S_LANE_9_MAPPING) & M_LANE_9_MAPPING)
-
-#define A_MAC_PORT_MTIP_CR4_LANE_10_MAPPING 0x2168
-
-#define S_LANE_10_MAPPING 0
-#define M_LANE_10_MAPPING 0x3fU
-#define V_LANE_10_MAPPING(x) ((x) << S_LANE_10_MAPPING)
-#define G_LANE_10_MAPPING(x) (((x) >> S_LANE_10_MAPPING) & M_LANE_10_MAPPING)
-
-#define A_MAC_PORT_MTIP_CR4_LANE_11_MAPPING 0x216c
-
-#define S_LANE_11_MAPPING 0
-#define M_LANE_11_MAPPING 0x3fU
-#define V_LANE_11_MAPPING(x) ((x) << S_LANE_11_MAPPING)
-#define G_LANE_11_MAPPING(x) (((x) >> S_LANE_11_MAPPING) & M_LANE_11_MAPPING)
-
-#define A_MAC_PORT_MTIP_CR4_LANE_12_MAPPING 0x2170
-
-#define S_LANE_12_MAPPING 0
-#define M_LANE_12_MAPPING 0x3fU
-#define V_LANE_12_MAPPING(x) ((x) << S_LANE_12_MAPPING)
-#define G_LANE_12_MAPPING(x) (((x) >> S_LANE_12_MAPPING) & M_LANE_12_MAPPING)
-
-#define A_MAC_PORT_MTIP_CR4_LANE_13_MAPPING 0x2174
-
-#define S_LANE_13_MAPPING 0
-#define M_LANE_13_MAPPING 0x3fU
-#define V_LANE_13_MAPPING(x) ((x) << S_LANE_13_MAPPING)
-#define G_LANE_13_MAPPING(x) (((x) >> S_LANE_13_MAPPING) & M_LANE_13_MAPPING)
-
-#define A_MAC_PORT_MTIP_CR4_LANE_14_MAPPING 0x2178
-
-#define S_LANE_14_MAPPING 0
-#define M_LANE_14_MAPPING 0x3fU
-#define V_LANE_14_MAPPING(x) ((x) << S_LANE_14_MAPPING)
-#define G_LANE_14_MAPPING(x) (((x) >> S_LANE_14_MAPPING) & M_LANE_14_MAPPING)
-
-#define A_MAC_PORT_MTIP_CR4_LANE_15_MAPPING 0x217c
-
-#define S_LANE_15_MAPPING 0
-#define M_LANE_15_MAPPING 0x3fU
-#define V_LANE_15_MAPPING(x) ((x) << S_LANE_15_MAPPING)
-#define G_LANE_15_MAPPING(x) (((x) >> S_LANE_15_MAPPING) & M_LANE_15_MAPPING)
-
-#define A_MAC_PORT_MTIP_CR4_LANE_16_MAPPING 0x2180
-
-#define S_LANE_16_MAPPING 0
-#define M_LANE_16_MAPPING 0x3fU
-#define V_LANE_16_MAPPING(x) ((x) << S_LANE_16_MAPPING)
-#define G_LANE_16_MAPPING(x) (((x) >> S_LANE_16_MAPPING) & M_LANE_16_MAPPING)
-
-#define A_MAC_PORT_MTIP_CR4_LANE_17_MAPPING 0x2184
-
-#define S_LANE_17_MAPPING 0
-#define M_LANE_17_MAPPING 0x3fU
-#define V_LANE_17_MAPPING(x) ((x) << S_LANE_17_MAPPING)
-#define G_LANE_17_MAPPING(x) (((x) >> S_LANE_17_MAPPING) & M_LANE_17_MAPPING)
-
-#define A_MAC_PORT_MTIP_CR4_LANE_18_MAPPING 0x2188
-
-#define S_LANE_18_MAPPING 0
-#define M_LANE_18_MAPPING 0x3fU
-#define V_LANE_18_MAPPING(x) ((x) << S_LANE_18_MAPPING)
-#define G_LANE_18_MAPPING(x) (((x) >> S_LANE_18_MAPPING) & M_LANE_18_MAPPING)
-
-#define A_MAC_PORT_MTIP_CR4_LANE_19_MAPPING 0x218c
-
-#define S_LANE_19_MAPPING 0
-#define M_LANE_19_MAPPING 0x3fU
-#define V_LANE_19_MAPPING(x) ((x) << S_LANE_19_MAPPING)
-#define G_LANE_19_MAPPING(x) (((x) >> S_LANE_19_MAPPING) & M_LANE_19_MAPPING)
-
-#define A_MAC_PORT_MTIP_CR4_SCRATCH 0x21f0
-#define A_MAC_PORT_MTIP_CR4_CORE_REVISION 0x21f4
-
-#define S_CORE_REVISION 0
-#define M_CORE_REVISION 0xffffU
-#define V_CORE_REVISION(x) ((x) << S_CORE_REVISION)
-#define G_CORE_REVISION(x) (((x) >> S_CORE_REVISION) & M_CORE_REVISION)
-
-#define A_MAC_PORT_BEAN_CTL 0x2200
-
-#define S_AN_RESET 15
-#define V_AN_RESET(x) ((x) << S_AN_RESET)
-#define F_AN_RESET V_AN_RESET(1U)
-
-#define S_EXT_NXP_CTRL 13
-#define V_EXT_NXP_CTRL(x) ((x) << S_EXT_NXP_CTRL)
-#define F_EXT_NXP_CTRL V_EXT_NXP_CTRL(1U)
-
-#define S_BEAN_EN 12
-#define V_BEAN_EN(x) ((x) << S_BEAN_EN)
-#define F_BEAN_EN V_BEAN_EN(1U)
-
-#define S_RESTART_BEAN 9
-#define V_RESTART_BEAN(x) ((x) << S_RESTART_BEAN)
-#define F_RESTART_BEAN V_RESTART_BEAN(1U)
-
-#define A_MAC_PORT_MTIP_RS_FEC_CONTROL 0x2200
-
-#define S_RS_FEC_BYPASS_ERROR_INDICATION 1
-#define V_RS_FEC_BYPASS_ERROR_INDICATION(x) ((x) << S_RS_FEC_BYPASS_ERROR_INDICATION)
-#define F_RS_FEC_BYPASS_ERROR_INDICATION V_RS_FEC_BYPASS_ERROR_INDICATION(1U)
-
-#define S_RS_FEC_BYPASS_CORRECTION 0
-#define V_RS_FEC_BYPASS_CORRECTION(x) ((x) << S_RS_FEC_BYPASS_CORRECTION)
-#define F_RS_FEC_BYPASS_CORRECTION V_RS_FEC_BYPASS_CORRECTION(1U)
-
-#define A_MAC_PORT_BEAN_STATUS 0x2204
-
-#define S_PDF 9
-#define V_PDF(x) ((x) << S_PDF)
-#define F_PDF V_PDF(1U)
-
-#define S_EXT_NXP_STATUS 7
-#define V_EXT_NXP_STATUS(x) ((x) << S_EXT_NXP_STATUS)
-#define F_EXT_NXP_STATUS V_EXT_NXP_STATUS(1U)
-
-#define S_PAGE_RCVD 6
-#define V_PAGE_RCVD(x) ((x) << S_PAGE_RCVD)
-#define F_PAGE_RCVD V_PAGE_RCVD(1U)
-
-#define S_BEAN_COMPLETE 5
-#define V_BEAN_COMPLETE(x) ((x) << S_BEAN_COMPLETE)
-#define F_BEAN_COMPLETE V_BEAN_COMPLETE(1U)
-
-#define S_REM_FAULT_STATUS 4
-#define V_REM_FAULT_STATUS(x) ((x) << S_REM_FAULT_STATUS)
-#define F_REM_FAULT_STATUS V_REM_FAULT_STATUS(1U)
-
-#define S_BEAN_ABILITY 3
-#define V_BEAN_ABILITY(x) ((x) << S_BEAN_ABILITY)
-#define F_BEAN_ABILITY V_BEAN_ABILITY(1U)
-
-#define S_LP_BEAN_ABILITY 0
-#define V_LP_BEAN_ABILITY(x) ((x) << S_LP_BEAN_ABILITY)
-#define F_LP_BEAN_ABILITY V_LP_BEAN_ABILITY(1U)
-
-#define A_MAC_PORT_MTIP_RS_FEC_STATUS 0x2204
-
-#define S_RS_FEC_PCS_ALIGN_STATUS 15
-#define V_RS_FEC_PCS_ALIGN_STATUS(x) ((x) << S_RS_FEC_PCS_ALIGN_STATUS)
-#define F_RS_FEC_PCS_ALIGN_STATUS V_RS_FEC_PCS_ALIGN_STATUS(1U)
-
-#define S_FEC_ALIGN_STATUS 14
-#define V_FEC_ALIGN_STATUS(x) ((x) << S_FEC_ALIGN_STATUS)
-#define F_FEC_ALIGN_STATUS V_FEC_ALIGN_STATUS(1U)
-
-#define S_RS_FEC_HIGH_SER 2
-#define V_RS_FEC_HIGH_SER(x) ((x) << S_RS_FEC_HIGH_SER)
-#define F_RS_FEC_HIGH_SER V_RS_FEC_HIGH_SER(1U)
-
-#define S_RS_FEC_BYPASS_ERROR_INDICATION_ABILITY 1
-#define V_RS_FEC_BYPASS_ERROR_INDICATION_ABILITY(x) ((x) << S_RS_FEC_BYPASS_ERROR_INDICATION_ABILITY)
-#define F_RS_FEC_BYPASS_ERROR_INDICATION_ABILITY V_RS_FEC_BYPASS_ERROR_INDICATION_ABILITY(1U)
-
-#define S_RS_FEC_BYPASS_CORRECTION_ABILITY 0
-#define V_RS_FEC_BYPASS_CORRECTION_ABILITY(x) ((x) << S_RS_FEC_BYPASS_CORRECTION_ABILITY)
-#define F_RS_FEC_BYPASS_CORRECTION_ABILITY V_RS_FEC_BYPASS_CORRECTION_ABILITY(1U)
-
-#define A_MAC_PORT_BEAN_ABILITY_0 0x2208
-
-#define S_NXP 15
-#define V_NXP(x) ((x) << S_NXP)
-#define F_NXP V_NXP(1U)
-
-#define S_REM_FAULT 13
-#define V_REM_FAULT(x) ((x) << S_REM_FAULT)
-#define F_REM_FAULT V_REM_FAULT(1U)
-
-#define S_PAUSE_ABILITY 10
-#define M_PAUSE_ABILITY 0x7U
-#define V_PAUSE_ABILITY(x) ((x) << S_PAUSE_ABILITY)
-#define G_PAUSE_ABILITY(x) (((x) >> S_PAUSE_ABILITY) & M_PAUSE_ABILITY)
-
-#define S_ECHO_NONCE 5
-#define M_ECHO_NONCE 0x1fU
-#define V_ECHO_NONCE(x) ((x) << S_ECHO_NONCE)
-#define G_ECHO_NONCE(x) (((x) >> S_ECHO_NONCE) & M_ECHO_NONCE)
-
-#define S_SELECTOR 0
-#define M_SELECTOR 0x1fU
-#define V_SELECTOR(x) ((x) << S_SELECTOR)
-#define G_SELECTOR(x) (((x) >> S_SELECTOR) & M_SELECTOR)
-
-#define A_MAC_PORT_MTIP_RS_FEC_CCW_LO 0x2208
-
-#define S_RS_RS_FEC_CCW_LO 0
-#define M_RS_RS_FEC_CCW_LO 0xffffU
-#define V_RS_RS_FEC_CCW_LO(x) ((x) << S_RS_RS_FEC_CCW_LO)
-#define G_RS_RS_FEC_CCW_LO(x) (((x) >> S_RS_RS_FEC_CCW_LO) & M_RS_RS_FEC_CCW_LO)
-
-#define A_MAC_PORT_BEAN_ABILITY_1 0x220c
-
-#define S_TECH_ABILITY_1 5
-#define M_TECH_ABILITY_1 0x7ffU
-#define V_TECH_ABILITY_1(x) ((x) << S_TECH_ABILITY_1)
-#define G_TECH_ABILITY_1(x) (((x) >> S_TECH_ABILITY_1) & M_TECH_ABILITY_1)
-
-#define S_TX_NONCE 0
-#define M_TX_NONCE 0x1fU
-#define V_TX_NONCE(x) ((x) << S_TX_NONCE)
-#define G_TX_NONCE(x) (((x) >> S_TX_NONCE) & M_TX_NONCE)
-
-#define A_MAC_PORT_MTIP_RS_FEC_CCW_HI 0x220c
-
-#define S_RS_RS_FEC_CCW_HI 0
-#define M_RS_RS_FEC_CCW_HI 0xffffU
-#define V_RS_RS_FEC_CCW_HI(x) ((x) << S_RS_RS_FEC_CCW_HI)
-#define G_RS_RS_FEC_CCW_HI(x) (((x) >> S_RS_RS_FEC_CCW_HI) & M_RS_RS_FEC_CCW_HI)
-
-#define A_MAC_PORT_BEAN_ABILITY_2 0x2210
-
-#define S_T5_FEC_ABILITY 14
-#define M_T5_FEC_ABILITY 0x3U
-#define V_T5_FEC_ABILITY(x) ((x) << S_T5_FEC_ABILITY)
-#define G_T5_FEC_ABILITY(x) (((x) >> S_T5_FEC_ABILITY) & M_T5_FEC_ABILITY)
-
-#define S_TECH_ABILITY_2 0
-#define M_TECH_ABILITY_2 0x3fffU
-#define V_TECH_ABILITY_2(x) ((x) << S_TECH_ABILITY_2)
-#define G_TECH_ABILITY_2(x) (((x) >> S_TECH_ABILITY_2) & M_TECH_ABILITY_2)
-
-#define A_MAC_PORT_MTIP_RS_FEC_NCCW_LO 0x2210
-
-#define S_RS_RS_FEC_NCCW_LO 0
-#define M_RS_RS_FEC_NCCW_LO 0xffffU
-#define V_RS_RS_FEC_NCCW_LO(x) ((x) << S_RS_RS_FEC_NCCW_LO)
-#define G_RS_RS_FEC_NCCW_LO(x) (((x) >> S_RS_RS_FEC_NCCW_LO) & M_RS_RS_FEC_NCCW_LO)
-
-#define A_MAC_PORT_BEAN_REM_ABILITY_0 0x2214
-#define A_MAC_PORT_MTIP_RS_FEC_NCCW_HI 0x2214
-
-#define S_RS_RS_FEC_NCCW_HI 0
-#define M_RS_RS_FEC_NCCW_HI 0xffffU
-#define V_RS_RS_FEC_NCCW_HI(x) ((x) << S_RS_RS_FEC_NCCW_HI)
-#define G_RS_RS_FEC_NCCW_HI(x) (((x) >> S_RS_RS_FEC_NCCW_HI) & M_RS_RS_FEC_NCCW_HI)
-
-#define A_MAC_PORT_BEAN_REM_ABILITY_1 0x2218
-#define A_MAC_PORT_MTIP_RS_FEC_LANEMAPRS_FEC_NCCW_HI 0x2218
-
-#define S_PMA_MAPPING 0
-#define M_PMA_MAPPING 0xffU
-#define V_PMA_MAPPING(x) ((x) << S_PMA_MAPPING)
-#define G_PMA_MAPPING(x) (((x) >> S_PMA_MAPPING) & M_PMA_MAPPING)
-
-#define A_MAC_PORT_BEAN_REM_ABILITY_2 0x221c
-#define A_MAC_PORT_BEAN_MS_COUNT 0x2220
-
-#define S_MS_COUNT 0
-#define M_MS_COUNT 0xffffU
-#define V_MS_COUNT(x) ((x) << S_MS_COUNT)
-#define G_MS_COUNT(x) (((x) >> S_MS_COUNT) & M_MS_COUNT)
-
-#define A_MAC_PORT_BEAN_XNP_0 0x2224
-
-#define S_XNP 15
-#define V_XNP(x) ((x) << S_XNP)
-#define F_XNP V_XNP(1U)
-
-#define S_ACKNOWLEDGE 14
-#define V_ACKNOWLEDGE(x) ((x) << S_ACKNOWLEDGE)
-#define F_ACKNOWLEDGE V_ACKNOWLEDGE(1U)
-
-#define S_MP 13
-#define V_MP(x) ((x) << S_MP)
-#define F_MP V_MP(1U)
-
-#define S_ACK2 12
-#define V_ACK2(x) ((x) << S_ACK2)
-#define F_ACK2 V_ACK2(1U)
-
-#define S_MU 0
-#define M_MU 0x7ffU
-#define V_MU(x) ((x) << S_MU)
-#define G_MU(x) (((x) >> S_MU) & M_MU)
-
-#define A_MAC_PORT_BEAN_XNP_1 0x2228
-
-#define S_UNFORMATED 0
-#define M_UNFORMATED 0xffffU
-#define V_UNFORMATED(x) ((x) << S_UNFORMATED)
-#define G_UNFORMATED(x) (((x) >> S_UNFORMATED) & M_UNFORMATED)
-
-#define A_MAC_PORT_MTIP_RS_FEC_SYMBLERR0_LO 0x2228
-
-#define S_RS_FEC_SYMBLERR0_LO 0
-#define V_RS_FEC_SYMBLERR0_LO(x) ((x) << S_RS_FEC_SYMBLERR0_LO)
-#define F_RS_FEC_SYMBLERR0_LO V_RS_FEC_SYMBLERR0_LO(1U)
-
-#define A_MAC_PORT_BEAN_XNP_2 0x222c
-#define A_MAC_PORT_MTIP_RS_FEC_SYMBLERR0_HI 0x222c
-
-#define S_RS_FEC_SYMBLERR0_HI 0
-#define V_RS_FEC_SYMBLERR0_HI(x) ((x) << S_RS_FEC_SYMBLERR0_HI)
-#define F_RS_FEC_SYMBLERR0_HI V_RS_FEC_SYMBLERR0_HI(1U)
-
-#define A_MAC_PORT_LP_BEAN_XNP_0 0x2230
-#define A_MAC_PORT_MTIP_RS_FEC_SYMBLERR1_LO 0x2230
-
-#define S_RS_FEC_SYMBLERR1_LO 0
-#define V_RS_FEC_SYMBLERR1_LO(x) ((x) << S_RS_FEC_SYMBLERR1_LO)
-#define F_RS_FEC_SYMBLERR1_LO V_RS_FEC_SYMBLERR1_LO(1U)
-
-#define A_MAC_PORT_LP_BEAN_XNP_1 0x2234
-#define A_MAC_PORT_MTIP_RS_FEC_SYMBLERR1_HI 0x2234
-
-#define S_RS_FEC_SYMBLERR1_HI 0
-#define V_RS_FEC_SYMBLERR1_HI(x) ((x) << S_RS_FEC_SYMBLERR1_HI)
-#define F_RS_FEC_SYMBLERR1_HI V_RS_FEC_SYMBLERR1_HI(1U)
-
-#define A_MAC_PORT_LP_BEAN_XNP_2 0x2238
-#define A_MAC_PORT_MTIP_RS_FEC_SYMBLERR2_LO 0x2238
-
-#define S_RS_FEC_SYMBLERR2_LO 0
-#define V_RS_FEC_SYMBLERR2_LO(x) ((x) << S_RS_FEC_SYMBLERR2_LO)
-#define F_RS_FEC_SYMBLERR2_LO V_RS_FEC_SYMBLERR2_LO(1U)
-
-#define A_MAC_PORT_BEAN_ETH_STATUS 0x223c
-
-#define S_100GCR10 8
-#define V_100GCR10(x) ((x) << S_100GCR10)
-#define F_100GCR10 V_100GCR10(1U)
-
-#define S_40GCR4 6
-#define V_40GCR4(x) ((x) << S_40GCR4)
-#define F_40GCR4 V_40GCR4(1U)
-
-#define S_40GKR4 5
-#define V_40GKR4(x) ((x) << S_40GKR4)
-#define F_40GKR4 V_40GKR4(1U)
-
-#define S_FEC 4
-#define V_FEC(x) ((x) << S_FEC)
-#define F_FEC V_FEC(1U)
-
-#define S_10GKR 3
-#define V_10GKR(x) ((x) << S_10GKR)
-#define F_10GKR V_10GKR(1U)
-
-#define S_10GKX4 2
-#define V_10GKX4(x) ((x) << S_10GKX4)
-#define F_10GKX4 V_10GKX4(1U)
-
-#define S_1GKX 1
-#define V_1GKX(x) ((x) << S_1GKX)
-#define F_1GKX V_1GKX(1U)
-
-#define A_MAC_PORT_MTIP_RS_FEC_SYMBLERR2_HI 0x223c
-
-#define S_RS_FEC_SYMBLERR2_HI 0
-#define V_RS_FEC_SYMBLERR2_HI(x) ((x) << S_RS_FEC_SYMBLERR2_HI)
-#define F_RS_FEC_SYMBLERR2_HI V_RS_FEC_SYMBLERR2_HI(1U)
-
-#define A_MAC_PORT_BEAN_CTL_LANE1 0x2240
-#define A_MAC_PORT_MTIP_RS_FEC_SYMBLERR3_LO 0x2240
-
-#define S_RS_FEC_SYMBLERR3_LO 0
-#define V_RS_FEC_SYMBLERR3_LO(x) ((x) << S_RS_FEC_SYMBLERR3_LO)
-#define F_RS_FEC_SYMBLERR3_LO V_RS_FEC_SYMBLERR3_LO(1U)
-
-#define A_MAC_PORT_BEAN_STATUS_LANE1 0x2244
-#define A_MAC_PORT_MTIP_RS_FEC_SYMBLERR3_HI 0x2244
-
-#define S_RS_FEC_SYMBLERR3_HI 0
-#define V_RS_FEC_SYMBLERR3_HI(x) ((x) << S_RS_FEC_SYMBLERR3_HI)
-#define F_RS_FEC_SYMBLERR3_HI V_RS_FEC_SYMBLERR3_HI(1U)
-
-#define A_MAC_PORT_BEAN_ABILITY_0_LANE1 0x2248
-#define A_MAC_PORT_BEAN_ABILITY_1_LANE1 0x224c
-#define A_MAC_PORT_BEAN_ABILITY_2_LANE1 0x2250
-#define A_MAC_PORT_BEAN_REM_ABILITY_0_LANE1 0x2254
-#define A_MAC_PORT_BEAN_REM_ABILITY_1_LANE1 0x2258
-#define A_MAC_PORT_BEAN_REM_ABILITY_2_LANE1 0x225c
-#define A_MAC_PORT_BEAN_MS_COUNT_LANE1 0x2260
-#define A_MAC_PORT_BEAN_XNP_0_LANE1 0x2264
-#define A_MAC_PORT_BEAN_XNP_1_LANE1 0x2268
-#define A_MAC_PORT_BEAN_XNP_2_LANE1 0x226c
-#define A_MAC_PORT_LP_BEAN_XNP_0_LANE1 0x2270
-#define A_MAC_PORT_LP_BEAN_XNP_1_LANE1 0x2274
-#define A_MAC_PORT_LP_BEAN_XNP_2_LANE1 0x2278
-#define A_MAC_PORT_BEAN_ETH_STATUS_LANE1 0x227c
-#define A_MAC_PORT_BEAN_CTL_LANE2 0x2280
-#define A_MAC_PORT_BEAN_STATUS_LANE2 0x2284
-#define A_MAC_PORT_BEAN_ABILITY_0_LANE2 0x2288
-#define A_MAC_PORT_BEAN_ABILITY_1_LANE2 0x228c
-#define A_MAC_PORT_BEAN_ABILITY_2_LANE2 0x2290
-#define A_MAC_PORT_BEAN_REM_ABILITY_0_LANE2 0x2294
-#define A_MAC_PORT_BEAN_REM_ABILITY_1_LANE2 0x2298
-#define A_MAC_PORT_BEAN_REM_ABILITY_2_LANE2 0x229c
-#define A_MAC_PORT_BEAN_MS_COUNT_LANE2 0x22a0
-#define A_MAC_PORT_BEAN_XNP_0_LANE2 0x22a4
-#define A_MAC_PORT_BEAN_XNP_1_LANE2 0x22a8
-#define A_MAC_PORT_BEAN_XNP_2_LANE2 0x22ac
-#define A_MAC_PORT_LP_BEAN_XNP_0_LANE2 0x22b0
-#define A_MAC_PORT_LP_BEAN_XNP_1_LANE2 0x22b4
-#define A_MAC_PORT_LP_BEAN_XNP_2_LANE2 0x22b8
-#define A_MAC_PORT_BEAN_ETH_STATUS_LANE2 0x22bc
-#define A_MAC_PORT_BEAN_CTL_LANE3 0x22c0
-#define A_MAC_PORT_BEAN_STATUS_LANE3 0x22c4
-#define A_MAC_PORT_BEAN_ABILITY_0_LANE3 0x22c8
-#define A_MAC_PORT_BEAN_ABILITY_1_LANE3 0x22cc
-#define A_MAC_PORT_BEAN_ABILITY_2_LANE3 0x22d0
-#define A_MAC_PORT_BEAN_REM_ABILITY_0_LANE3 0x22d4
-#define A_MAC_PORT_BEAN_REM_ABILITY_1_LANE3 0x22d8
-#define A_MAC_PORT_BEAN_REM_ABILITY_2_LANE3 0x22dc
-#define A_MAC_PORT_BEAN_MS_COUNT_LANE3 0x22e0
-#define A_MAC_PORT_BEAN_XNP_0_LANE3 0x22e4
-#define A_MAC_PORT_BEAN_XNP_1_LANE3 0x22e8
-#define A_MAC_PORT_BEAN_XNP_2_LANE3 0x22ec
-#define A_MAC_PORT_LP_BEAN_XNP_0_LANE3 0x22f0
-#define A_MAC_PORT_LP_BEAN_XNP_1_LANE3 0x22f4
-#define A_MAC_PORT_LP_BEAN_XNP_2_LANE3 0x22f8
-#define A_MAC_PORT_BEAN_ETH_STATUS_LANE3 0x22fc
-#define A_MAC_PORT_MTIP_RS_FEC_VENDOR_CONTROL 0x2400
-
-#define S_RS_FEC_ENABLED_STATUS 15
-#define V_RS_FEC_ENABLED_STATUS(x) ((x) << S_RS_FEC_ENABLED_STATUS)
-#define F_RS_FEC_ENABLED_STATUS V_RS_FEC_ENABLED_STATUS(1U)
-
-#define S_RS_FEC_ENABLE 2
-#define V_RS_FEC_ENABLE(x) ((x) << S_RS_FEC_ENABLE)
-#define F_RS_FEC_ENABLE V_RS_FEC_ENABLE(1U)
-
-#define A_MAC_PORT_MTIP_RS_FEC_VENDOR_INFO_1 0x2404
-
-#define S_DESKEW_EMPTY 12
-#define M_DESKEW_EMPTY 0xfU
-#define V_DESKEW_EMPTY(x) ((x) << S_DESKEW_EMPTY)
-#define G_DESKEW_EMPTY(x) (((x) >> S_DESKEW_EMPTY) & M_DESKEW_EMPTY)
-
-#define S_FEC_ALIGN_STATUS_LH 10
-#define V_FEC_ALIGN_STATUS_LH(x) ((x) << S_FEC_ALIGN_STATUS_LH)
-#define F_FEC_ALIGN_STATUS_LH V_FEC_ALIGN_STATUS_LH(1U)
-
-#define S_TX_DP_OVERFLOW 9
-#define V_TX_DP_OVERFLOW(x) ((x) << S_TX_DP_OVERFLOW)
-#define F_TX_DP_OVERFLOW V_TX_DP_OVERFLOW(1U)
-
-#define S_RX_DP_OVERFLOW 8
-#define V_RX_DP_OVERFLOW(x) ((x) << S_RX_DP_OVERFLOW)
-#define F_RX_DP_OVERFLOW V_RX_DP_OVERFLOW(1U)
-
-#define S_TX_DATAPATH_RESTART 7
-#define V_TX_DATAPATH_RESTART(x) ((x) << S_TX_DATAPATH_RESTART)
-#define F_TX_DATAPATH_RESTART V_TX_DATAPATH_RESTART(1U)
-
-#define S_RX_DATAPATH_RESTART 6
-#define V_RX_DATAPATH_RESTART(x) ((x) << S_RX_DATAPATH_RESTART)
-#define F_RX_DATAPATH_RESTART V_RX_DATAPATH_RESTART(1U)
-
-#define S_MARKER_CHECK_RESTART 5
-#define V_MARKER_CHECK_RESTART(x) ((x) << S_MARKER_CHECK_RESTART)
-#define F_MARKER_CHECK_RESTART V_MARKER_CHECK_RESTART(1U)
-
-#define S_FEC_ALIGN_STATUS_LL 4
-#define V_FEC_ALIGN_STATUS_LL(x) ((x) << S_FEC_ALIGN_STATUS_LL)
-#define F_FEC_ALIGN_STATUS_LL V_FEC_ALIGN_STATUS_LL(1U)
-
-#define S_AMPS_LOCK 0
-#define M_AMPS_LOCK 0xfU
-#define V_AMPS_LOCK(x) ((x) << S_AMPS_LOCK)
-#define G_AMPS_LOCK(x) (((x) >> S_AMPS_LOCK) & M_AMPS_LOCK)
-
-#define A_MAC_PORT_MTIP_RS_FEC_VENDOR_INFO_2 0x2408
-#define A_MAC_PORT_MTIP_RS_FEC_VENDOR_REVISION 0x240c
-
-#define S_RS_FEC_VENDOR_REVISION 0
-#define M_RS_FEC_VENDOR_REVISION 0xffffU
-#define V_RS_FEC_VENDOR_REVISION(x) ((x) << S_RS_FEC_VENDOR_REVISION)
-#define G_RS_FEC_VENDOR_REVISION(x) (((x) >> S_RS_FEC_VENDOR_REVISION) & M_RS_FEC_VENDOR_REVISION)
-
-#define A_MAC_PORT_MTIP_RS_FEC_VENDOR_TX_TEST_KEY 0x2410
-
-#define S_RS_FEC_VENDOR_TX_TEST_KEY 0
-#define M_RS_FEC_VENDOR_TX_TEST_KEY 0xffffU
-#define V_RS_FEC_VENDOR_TX_TEST_KEY(x) ((x) << S_RS_FEC_VENDOR_TX_TEST_KEY)
-#define G_RS_FEC_VENDOR_TX_TEST_KEY(x) (((x) >> S_RS_FEC_VENDOR_TX_TEST_KEY) & M_RS_FEC_VENDOR_TX_TEST_KEY)
-
-#define A_MAC_PORT_MTIP_RS_FEC_VENDOR_TX_TEST_SYMBOLS 0x2414
-
-#define S_RS_FEC_VENDOR_TX_TEST_SYMBOLS 0
-#define M_RS_FEC_VENDOR_TX_TEST_SYMBOLS 0xffffU
-#define V_RS_FEC_VENDOR_TX_TEST_SYMBOLS(x) ((x) << S_RS_FEC_VENDOR_TX_TEST_SYMBOLS)
-#define G_RS_FEC_VENDOR_TX_TEST_SYMBOLS(x) (((x) >> S_RS_FEC_VENDOR_TX_TEST_SYMBOLS) & M_RS_FEC_VENDOR_TX_TEST_SYMBOLS)
-
-#define A_MAC_PORT_MTIP_RS_FEC_VENDOR_TX_TEST_PATTERN 0x2418
-
-#define S_RS_FEC_VENDOR_TX_TEST_PATTERN 0
-#define M_RS_FEC_VENDOR_TX_TEST_PATTERN 0xffffU
-#define V_RS_FEC_VENDOR_TX_TEST_PATTERN(x) ((x) << S_RS_FEC_VENDOR_TX_TEST_PATTERN)
-#define G_RS_FEC_VENDOR_TX_TEST_PATTERN(x) (((x) >> S_RS_FEC_VENDOR_TX_TEST_PATTERN) & M_RS_FEC_VENDOR_TX_TEST_PATTERN)
-
-#define A_MAC_PORT_MTIP_RS_FEC_VENDOR_TX_TEST_TRIGGER 0x241c
-
-#define S_RS_FEC_VENDOR_TX_TEST_TRIGGER 0
-#define M_RS_FEC_VENDOR_TX_TEST_TRIGGER 0xffffU
-#define V_RS_FEC_VENDOR_TX_TEST_TRIGGER(x) ((x) << S_RS_FEC_VENDOR_TX_TEST_TRIGGER)
-#define G_RS_FEC_VENDOR_TX_TEST_TRIGGER(x) (((x) >> S_RS_FEC_VENDOR_TX_TEST_TRIGGER) & M_RS_FEC_VENDOR_TX_TEST_TRIGGER)
-
-#define A_MAC_PORT_FEC_KR_CONTROL 0x2600
-
-#define S_ENABLE_TR 1
-#define V_ENABLE_TR(x) ((x) << S_ENABLE_TR)
-#define F_ENABLE_TR V_ENABLE_TR(1U)
-
-#define S_RESTART_TR 0
-#define V_RESTART_TR(x) ((x) << S_RESTART_TR)
-#define F_RESTART_TR V_RESTART_TR(1U)
-
-#define A_MAC_PORT_FEC_KR_STATUS 0x2604
-
-#define S_FECKRSIGDET 15
-#define V_FECKRSIGDET(x) ((x) << S_FECKRSIGDET)
-#define F_FECKRSIGDET V_FECKRSIGDET(1U)
-
-#define S_TRAIN_FAIL 3
-#define V_TRAIN_FAIL(x) ((x) << S_TRAIN_FAIL)
-#define F_TRAIN_FAIL V_TRAIN_FAIL(1U)
-
-#define S_STARTUP_STATUS 2
-#define V_STARTUP_STATUS(x) ((x) << S_STARTUP_STATUS)
-#define F_STARTUP_STATUS V_STARTUP_STATUS(1U)
-
-#define S_RX_STATUS 0
-#define V_RX_STATUS(x) ((x) << S_RX_STATUS)
-#define F_RX_STATUS V_RX_STATUS(1U)
-
-#define A_MAC_PORT_FEC_KR_LP_COEFF 0x2608
-
-#define S_PRESET 13
-#define V_PRESET(x) ((x) << S_PRESET)
-#define F_PRESET V_PRESET(1U)
-
-#define S_INITIALIZE 12
-#define V_INITIALIZE(x) ((x) << S_INITIALIZE)
-#define F_INITIALIZE V_INITIALIZE(1U)
-
-#define S_CP1_UPD 4
-#define M_CP1_UPD 0x3U
-#define V_CP1_UPD(x) ((x) << S_CP1_UPD)
-#define G_CP1_UPD(x) (((x) >> S_CP1_UPD) & M_CP1_UPD)
-
-#define S_C0_UPD 2
-#define M_C0_UPD 0x3U
-#define V_C0_UPD(x) ((x) << S_C0_UPD)
-#define G_C0_UPD(x) (((x) >> S_C0_UPD) & M_C0_UPD)
-
-#define S_CN1_UPD 0
-#define M_CN1_UPD 0x3U
-#define V_CN1_UPD(x) ((x) << S_CN1_UPD)
-#define G_CN1_UPD(x) (((x) >> S_CN1_UPD) & M_CN1_UPD)
-
-#define A_MAC_PORT_FEC_KR_LP_STAT 0x260c
-
-#define S_RX_READY 15
-#define V_RX_READY(x) ((x) << S_RX_READY)
-#define F_RX_READY V_RX_READY(1U)
-
-#define S_CP1_STAT 4
-#define M_CP1_STAT 0x3U
-#define V_CP1_STAT(x) ((x) << S_CP1_STAT)
-#define G_CP1_STAT(x) (((x) >> S_CP1_STAT) & M_CP1_STAT)
-
-#define S_C0_STAT 2
-#define M_C0_STAT 0x3U
-#define V_C0_STAT(x) ((x) << S_C0_STAT)
-#define G_C0_STAT(x) (((x) >> S_C0_STAT) & M_C0_STAT)
-
-#define S_CN1_STAT 0
-#define M_CN1_STAT 0x3U
-#define V_CN1_STAT(x) ((x) << S_CN1_STAT)
-#define G_CN1_STAT(x) (((x) >> S_CN1_STAT) & M_CN1_STAT)
-
-#define A_MAC_PORT_FEC_KR_LD_COEFF 0x2610
-#define A_MAC_PORT_FEC_KR_LD_STAT 0x2614
-#define A_MAC_PORT_FEC_ABILITY 0x2618
-
-#define S_FEC_IND_ABILITY 1
-#define V_FEC_IND_ABILITY(x) ((x) << S_FEC_IND_ABILITY)
-#define F_FEC_IND_ABILITY V_FEC_IND_ABILITY(1U)
-
-#define S_ABILITY 0
-#define V_ABILITY(x) ((x) << S_ABILITY)
-#define F_ABILITY V_ABILITY(1U)
-
-#define A_MAC_PORT_MTIP_FEC_ABILITY 0x2618
-
-#define S_BASE_R_FEC_ERROR_INDICATION_ABILITY 1
-#define V_BASE_R_FEC_ERROR_INDICATION_ABILITY(x) ((x) << S_BASE_R_FEC_ERROR_INDICATION_ABILITY)
-#define F_BASE_R_FEC_ERROR_INDICATION_ABILITY V_BASE_R_FEC_ERROR_INDICATION_ABILITY(1U)
-
-#define S_BASE_R_FEC_ABILITY 0
-#define V_BASE_R_FEC_ABILITY(x) ((x) << S_BASE_R_FEC_ABILITY)
-#define F_BASE_R_FEC_ABILITY V_BASE_R_FEC_ABILITY(1U)
-
-#define A_MAC_PORT_FEC_CONTROL 0x261c
-
-#define S_FEC_EN_ERR_IND 1
-#define V_FEC_EN_ERR_IND(x) ((x) << S_FEC_EN_ERR_IND)
-#define F_FEC_EN_ERR_IND V_FEC_EN_ERR_IND(1U)
-
-#define S_FEC_EN 0
-#define V_FEC_EN(x) ((x) << S_FEC_EN)
-#define F_FEC_EN V_FEC_EN(1U)
-
-#define A_MAC_PORT_FEC_STATUS 0x2620
-
-#define S_FEC_LOCKED_100 1
-#define V_FEC_LOCKED_100(x) ((x) << S_FEC_LOCKED_100)
-#define F_FEC_LOCKED_100 V_FEC_LOCKED_100(1U)
-
-#define S_FEC_LOCKED 0
-#define V_FEC_LOCKED(x) ((x) << S_FEC_LOCKED)
-#define F_FEC_LOCKED V_FEC_LOCKED(1U)
-
-#define S_FEC_LOCKED0 1
-#define M_FEC_LOCKED0 0xfU
-#define V_FEC_LOCKED0(x) ((x) << S_FEC_LOCKED0)
-#define G_FEC_LOCKED0(x) (((x) >> S_FEC_LOCKED0) & M_FEC_LOCKED0)
-
-#define A_MAC_PORT_FEC_CERR_CNT_0 0x2624
-
-#define S_FEC_CERR_CNT_0 0
-#define M_FEC_CERR_CNT_0 0xffffU
-#define V_FEC_CERR_CNT_0(x) ((x) << S_FEC_CERR_CNT_0)
-#define G_FEC_CERR_CNT_0(x) (((x) >> S_FEC_CERR_CNT_0) & M_FEC_CERR_CNT_0)
-
-#define A_MAC_PORT_MTIP_FEC0_CERR_CNT_0 0x2624
-#define A_MAC_PORT_FEC_CERR_CNT_1 0x2628
-
-#define S_FEC_CERR_CNT_1 0
-#define M_FEC_CERR_CNT_1 0xffffU
-#define V_FEC_CERR_CNT_1(x) ((x) << S_FEC_CERR_CNT_1)
-#define G_FEC_CERR_CNT_1(x) (((x) >> S_FEC_CERR_CNT_1) & M_FEC_CERR_CNT_1)
-
-#define A_MAC_PORT_MTIP_FEC0_CERR_CNT_1 0x2628
-#define A_MAC_PORT_FEC_NCERR_CNT_0 0x262c
-
-#define S_FEC_NCERR_CNT_0 0
-#define M_FEC_NCERR_CNT_0 0xffffU
-#define V_FEC_NCERR_CNT_0(x) ((x) << S_FEC_NCERR_CNT_0)
-#define G_FEC_NCERR_CNT_0(x) (((x) >> S_FEC_NCERR_CNT_0) & M_FEC_NCERR_CNT_0)
-
-#define A_MAC_PORT_MTIP_FEC0_NCERR_CNT_0 0x262c
-
-#define S_FEC0_NCERR_CNT_0 0
-#define M_FEC0_NCERR_CNT_0 0xffffU
-#define V_FEC0_NCERR_CNT_0(x) ((x) << S_FEC0_NCERR_CNT_0)
-#define G_FEC0_NCERR_CNT_0(x) (((x) >> S_FEC0_NCERR_CNT_0) & M_FEC0_NCERR_CNT_0)
-
-#define A_MAC_PORT_FEC_NCERR_CNT_1 0x2630
-
-#define S_FEC_NCERR_CNT_1 0
-#define M_FEC_NCERR_CNT_1 0xffffU
-#define V_FEC_NCERR_CNT_1(x) ((x) << S_FEC_NCERR_CNT_1)
-#define G_FEC_NCERR_CNT_1(x) (((x) >> S_FEC_NCERR_CNT_1) & M_FEC_NCERR_CNT_1)
-
-#define A_MAC_PORT_MTIP_FEC0_NCERR_CNT_1 0x2630
-
-#define S_FEC0_NCERR_CNT_1 0
-#define M_FEC0_NCERR_CNT_1 0xffffU
-#define V_FEC0_NCERR_CNT_1(x) ((x) << S_FEC0_NCERR_CNT_1)
-#define G_FEC0_NCERR_CNT_1(x) (((x) >> S_FEC0_NCERR_CNT_1) & M_FEC0_NCERR_CNT_1)
-
-#define A_MAC_PORT_MTIP_FEC_STATUS1 0x2664
-#define A_MAC_PORT_MTIP_FEC1_CERR_CNT_0 0x2668
-#define A_MAC_PORT_MTIP_FEC1_CERR_CNT_1 0x266c
-#define A_MAC_PORT_MTIP_FEC1_NCERR_CNT_0 0x2670
-#define A_MAC_PORT_MTIP_FEC1_NCERR_CNT_1 0x2674
-#define A_MAC_PORT_MTIP_FEC_STATUS2 0x26a8
-#define A_MAC_PORT_MTIP_FEC2_CERR_CNT_0 0x26ac
-#define A_MAC_PORT_MTIP_FEC2_CERR_CNT_1 0x26b0
-#define A_MAC_PORT_MTIP_FEC2_NCERR_CNT_0 0x26b4
-#define A_MAC_PORT_MTIP_FEC2_NCERR_CNT_1 0x26b8
-#define A_MAC_PORT_MTIP_FEC_STATUS3 0x26ec
-#define A_MAC_PORT_MTIP_FEC3_CERR_CNT_0 0x26f0
-#define A_MAC_PORT_MTIP_FEC3_CERR_CNT_1 0x26f4
-#define A_MAC_PORT_MTIP_FEC3_NCERR_CNT_0 0x26f8
-#define A_MAC_PORT_MTIP_FEC3_NCERR_CNT_1 0x26fc
-#define A_MAC_PORT_AE_RX_COEF_REQ 0x2a00
-
-#define S_T5_RXREQ_C2 4
-#define M_T5_RXREQ_C2 0x3U
-#define V_T5_RXREQ_C2(x) ((x) << S_T5_RXREQ_C2)
-#define G_T5_RXREQ_C2(x) (((x) >> S_T5_RXREQ_C2) & M_T5_RXREQ_C2)
-
-#define S_T5_RXREQ_C1 2
-#define M_T5_RXREQ_C1 0x3U
-#define V_T5_RXREQ_C1(x) ((x) << S_T5_RXREQ_C1)
-#define G_T5_RXREQ_C1(x) (((x) >> S_T5_RXREQ_C1) & M_T5_RXREQ_C1)
-
-#define S_T5_RXREQ_C0 0
-#define M_T5_RXREQ_C0 0x3U
-#define V_T5_RXREQ_C0(x) ((x) << S_T5_RXREQ_C0)
-#define G_T5_RXREQ_C0(x) (((x) >> S_T5_RXREQ_C0) & M_T5_RXREQ_C0)
-
-#define S_T5_RXREQ_C3 6
-#define M_T5_RXREQ_C3 0x3U
-#define V_T5_RXREQ_C3(x) ((x) << S_T5_RXREQ_C3)
-#define G_T5_RXREQ_C3(x) (((x) >> S_T5_RXREQ_C3) & M_T5_RXREQ_C3)
-
-#define A_MAC_PORT_AE_RX_COEF_STAT 0x2a04
-
-#define S_T5_AE0_RXSTAT_RDY 15
-#define V_T5_AE0_RXSTAT_RDY(x) ((x) << S_T5_AE0_RXSTAT_RDY)
-#define F_T5_AE0_RXSTAT_RDY V_T5_AE0_RXSTAT_RDY(1U)
-
-#define S_T5_AE0_RXSTAT_C2 4
-#define M_T5_AE0_RXSTAT_C2 0x3U
-#define V_T5_AE0_RXSTAT_C2(x) ((x) << S_T5_AE0_RXSTAT_C2)
-#define G_T5_AE0_RXSTAT_C2(x) (((x) >> S_T5_AE0_RXSTAT_C2) & M_T5_AE0_RXSTAT_C2)
-
-#define S_T5_AE0_RXSTAT_C1 2
-#define M_T5_AE0_RXSTAT_C1 0x3U
-#define V_T5_AE0_RXSTAT_C1(x) ((x) << S_T5_AE0_RXSTAT_C1)
-#define G_T5_AE0_RXSTAT_C1(x) (((x) >> S_T5_AE0_RXSTAT_C1) & M_T5_AE0_RXSTAT_C1)
-
-#define S_T5_AE0_RXSTAT_C0 0
-#define M_T5_AE0_RXSTAT_C0 0x3U
-#define V_T5_AE0_RXSTAT_C0(x) ((x) << S_T5_AE0_RXSTAT_C0)
-#define G_T5_AE0_RXSTAT_C0(x) (((x) >> S_T5_AE0_RXSTAT_C0) & M_T5_AE0_RXSTAT_C0)
-
-#define S_T5_AE0_RXSTAT_LSNA 14
-#define V_T5_AE0_RXSTAT_LSNA(x) ((x) << S_T5_AE0_RXSTAT_LSNA)
-#define F_T5_AE0_RXSTAT_LSNA V_T5_AE0_RXSTAT_LSNA(1U)
-
-#define S_T5_AE0_RXSTAT_FEC 13
-#define V_T5_AE0_RXSTAT_FEC(x) ((x) << S_T5_AE0_RXSTAT_FEC)
-#define F_T5_AE0_RXSTAT_FEC V_T5_AE0_RXSTAT_FEC(1U)
-
-#define S_T5_AE0_RXSTAT_TF 12
-#define V_T5_AE0_RXSTAT_TF(x) ((x) << S_T5_AE0_RXSTAT_TF)
-#define F_T5_AE0_RXSTAT_TF V_T5_AE0_RXSTAT_TF(1U)
-
-#define S_T5_AE0_RXSTAT_C3 6
-#define M_T5_AE0_RXSTAT_C3 0x3U
-#define V_T5_AE0_RXSTAT_C3(x) ((x) << S_T5_AE0_RXSTAT_C3)
-#define G_T5_AE0_RXSTAT_C3(x) (((x) >> S_T5_AE0_RXSTAT_C3) & M_T5_AE0_RXSTAT_C3)
-
-#define A_MAC_PORT_AE_TX_COEF_REQ 0x2a08
-
-#define S_T5_TXREQ_C2 4
-#define M_T5_TXREQ_C2 0x3U
-#define V_T5_TXREQ_C2(x) ((x) << S_T5_TXREQ_C2)
-#define G_T5_TXREQ_C2(x) (((x) >> S_T5_TXREQ_C2) & M_T5_TXREQ_C2)
-
-#define S_T5_TXREQ_C1 2
-#define M_T5_TXREQ_C1 0x3U
-#define V_T5_TXREQ_C1(x) ((x) << S_T5_TXREQ_C1)
-#define G_T5_TXREQ_C1(x) (((x) >> S_T5_TXREQ_C1) & M_T5_TXREQ_C1)
-
-#define S_T5_TXREQ_C0 0
-#define M_T5_TXREQ_C0 0x3U
-#define V_T5_TXREQ_C0(x) ((x) << S_T5_TXREQ_C0)
-#define G_T5_TXREQ_C0(x) (((x) >> S_T5_TXREQ_C0) & M_T5_TXREQ_C0)
-
-#define S_TXREQ_FEC 11
-#define V_TXREQ_FEC(x) ((x) << S_TXREQ_FEC)
-#define F_TXREQ_FEC V_TXREQ_FEC(1U)
-
-#define S_T5_TXREQ_C3 6
-#define M_T5_TXREQ_C3 0x3U
-#define V_T5_TXREQ_C3(x) ((x) << S_T5_TXREQ_C3)
-#define G_T5_TXREQ_C3(x) (((x) >> S_T5_TXREQ_C3) & M_T5_TXREQ_C3)
-
-#define A_MAC_PORT_AE_TX_COEF_STAT 0x2a0c
-
-#define S_T5_TXSTAT_C2 4
-#define M_T5_TXSTAT_C2 0x3U
-#define V_T5_TXSTAT_C2(x) ((x) << S_T5_TXSTAT_C2)
-#define G_T5_TXSTAT_C2(x) (((x) >> S_T5_TXSTAT_C2) & M_T5_TXSTAT_C2)
-
-#define S_T5_TXSTAT_C1 2
-#define M_T5_TXSTAT_C1 0x3U
-#define V_T5_TXSTAT_C1(x) ((x) << S_T5_TXSTAT_C1)
-#define G_T5_TXSTAT_C1(x) (((x) >> S_T5_TXSTAT_C1) & M_T5_TXSTAT_C1)
-
-#define S_T5_TXSTAT_C0 0
-#define M_T5_TXSTAT_C0 0x3U
-#define V_T5_TXSTAT_C0(x) ((x) << S_T5_TXSTAT_C0)
-#define G_T5_TXSTAT_C0(x) (((x) >> S_T5_TXSTAT_C0) & M_T5_TXSTAT_C0)
-
-#define S_T5_TXSTAT_C3 6
-#define M_T5_TXSTAT_C3 0x3U
-#define V_T5_TXSTAT_C3(x) ((x) << S_T5_TXSTAT_C3)
-#define G_T5_TXSTAT_C3(x) (((x) >> S_T5_TXSTAT_C3) & M_T5_TXSTAT_C3)
-
-#define A_MAC_PORT_AE_REG_MODE 0x2a10
-
-#define S_AET_RSVD 7
-#define V_AET_RSVD(x) ((x) << S_AET_RSVD)
-#define F_AET_RSVD V_AET_RSVD(1U)
-
-#define S_AET_ENABLE 6
-#define V_AET_ENABLE(x) ((x) << S_AET_ENABLE)
-#define F_AET_ENABLE V_AET_ENABLE(1U)
-
-#define S_SET_WAIT_TIMER 13
-#define M_SET_WAIT_TIMER 0x3U
-#define V_SET_WAIT_TIMER(x) ((x) << S_SET_WAIT_TIMER)
-#define G_SET_WAIT_TIMER(x) (((x) >> S_SET_WAIT_TIMER) & M_SET_WAIT_TIMER)
-
-#define S_C2_C3_STATE_SEL 12
-#define V_C2_C3_STATE_SEL(x) ((x) << S_C2_C3_STATE_SEL)
-#define F_C2_C3_STATE_SEL V_C2_C3_STATE_SEL(1U)
-
-#define S_FFE4_EN 11
-#define V_FFE4_EN(x) ((x) << S_FFE4_EN)
-#define F_FFE4_EN V_FFE4_EN(1U)
-
-#define S_FEC_REQUEST 10
-#define V_FEC_REQUEST(x) ((x) << S_FEC_REQUEST)
-#define F_FEC_REQUEST V_FEC_REQUEST(1U)
-
-#define S_FEC_SUPPORTED 9
-#define V_FEC_SUPPORTED(x) ((x) << S_FEC_SUPPORTED)
-#define F_FEC_SUPPORTED V_FEC_SUPPORTED(1U)
-
-#define S_TX_FIXED 8
-#define V_TX_FIXED(x) ((x) << S_TX_FIXED)
-#define F_TX_FIXED V_TX_FIXED(1U)
-
-#define A_MAC_PORT_AE_PRBS_CTL 0x2a14
-#define A_MAC_PORT_AE_FSM_CTL 0x2a18
-
-#define S_CIN_ENABLE 15
-#define V_CIN_ENABLE(x) ((x) << S_CIN_ENABLE)
-#define F_CIN_ENABLE V_CIN_ENABLE(1U)
-
-#define A_MAC_PORT_AE_FSM_STATE 0x2a1c
-#define A_MAC_PORT_AE_RX_COEF_REQ_1 0x2a20
-#define A_MAC_PORT_AE_RX_COEF_STAT_1 0x2a24
-
-#define S_T5_AE1_RXSTAT_RDY 15
-#define V_T5_AE1_RXSTAT_RDY(x) ((x) << S_T5_AE1_RXSTAT_RDY)
-#define F_T5_AE1_RXSTAT_RDY V_T5_AE1_RXSTAT_RDY(1U)
-
-#define S_T5_AE1_RXSTAT_C2 4
-#define M_T5_AE1_RXSTAT_C2 0x3U
-#define V_T5_AE1_RXSTAT_C2(x) ((x) << S_T5_AE1_RXSTAT_C2)
-#define G_T5_AE1_RXSTAT_C2(x) (((x) >> S_T5_AE1_RXSTAT_C2) & M_T5_AE1_RXSTAT_C2)
-
-#define S_T5_AE1_RXSTAT_C1 2
-#define M_T5_AE1_RXSTAT_C1 0x3U
-#define V_T5_AE1_RXSTAT_C1(x) ((x) << S_T5_AE1_RXSTAT_C1)
-#define G_T5_AE1_RXSTAT_C1(x) (((x) >> S_T5_AE1_RXSTAT_C1) & M_T5_AE1_RXSTAT_C1)
-
-#define S_T5_AE1_RXSTAT_C0 0
-#define M_T5_AE1_RXSTAT_C0 0x3U
-#define V_T5_AE1_RXSTAT_C0(x) ((x) << S_T5_AE1_RXSTAT_C0)
-#define G_T5_AE1_RXSTAT_C0(x) (((x) >> S_T5_AE1_RXSTAT_C0) & M_T5_AE1_RXSTAT_C0)
-
-#define S_T5_AE1_RXSTAT_LSNA 14
-#define V_T5_AE1_RXSTAT_LSNA(x) ((x) << S_T5_AE1_RXSTAT_LSNA)
-#define F_T5_AE1_RXSTAT_LSNA V_T5_AE1_RXSTAT_LSNA(1U)
-
-#define S_T5_AE1_RXSTAT_FEC 13
-#define V_T5_AE1_RXSTAT_FEC(x) ((x) << S_T5_AE1_RXSTAT_FEC)
-#define F_T5_AE1_RXSTAT_FEC V_T5_AE1_RXSTAT_FEC(1U)
-
-#define S_T5_AE1_RXSTAT_TF 12
-#define V_T5_AE1_RXSTAT_TF(x) ((x) << S_T5_AE1_RXSTAT_TF)
-#define F_T5_AE1_RXSTAT_TF V_T5_AE1_RXSTAT_TF(1U)
-
-#define S_T5_AE1_RXSTAT_C3 6
-#define M_T5_AE1_RXSTAT_C3 0x3U
-#define V_T5_AE1_RXSTAT_C3(x) ((x) << S_T5_AE1_RXSTAT_C3)
-#define G_T5_AE1_RXSTAT_C3(x) (((x) >> S_T5_AE1_RXSTAT_C3) & M_T5_AE1_RXSTAT_C3)
-
-#define A_MAC_PORT_AE_TX_COEF_REQ_1 0x2a28
-#define A_MAC_PORT_AE_TX_COEF_STAT_1 0x2a2c
-#define A_MAC_PORT_AE_REG_MODE_1 0x2a30
-#define A_MAC_PORT_AE_PRBS_CTL_1 0x2a34
-#define A_MAC_PORT_AE_FSM_CTL_1 0x2a38
-#define A_MAC_PORT_AE_FSM_STATE_1 0x2a3c
-#define A_MAC_PORT_AE_RX_COEF_REQ_2 0x2a40
-#define A_MAC_PORT_AE_RX_COEF_STAT_2 0x2a44
-
-#define S_T5_AE2_RXSTAT_RDY 15
-#define V_T5_AE2_RXSTAT_RDY(x) ((x) << S_T5_AE2_RXSTAT_RDY)
-#define F_T5_AE2_RXSTAT_RDY V_T5_AE2_RXSTAT_RDY(1U)
-
-#define S_T5_AE2_RXSTAT_C2 4
-#define M_T5_AE2_RXSTAT_C2 0x3U
-#define V_T5_AE2_RXSTAT_C2(x) ((x) << S_T5_AE2_RXSTAT_C2)
-#define G_T5_AE2_RXSTAT_C2(x) (((x) >> S_T5_AE2_RXSTAT_C2) & M_T5_AE2_RXSTAT_C2)
-
-#define S_T5_AE2_RXSTAT_C1 2
-#define M_T5_AE2_RXSTAT_C1 0x3U
-#define V_T5_AE2_RXSTAT_C1(x) ((x) << S_T5_AE2_RXSTAT_C1)
-#define G_T5_AE2_RXSTAT_C1(x) (((x) >> S_T5_AE2_RXSTAT_C1) & M_T5_AE2_RXSTAT_C1)
-
-#define S_T5_AE2_RXSTAT_C0 0
-#define M_T5_AE2_RXSTAT_C0 0x3U
-#define V_T5_AE2_RXSTAT_C0(x) ((x) << S_T5_AE2_RXSTAT_C0)
-#define G_T5_AE2_RXSTAT_C0(x) (((x) >> S_T5_AE2_RXSTAT_C0) & M_T5_AE2_RXSTAT_C0)
-
-#define S_T5_AE2_RXSTAT_LSNA 14
-#define V_T5_AE2_RXSTAT_LSNA(x) ((x) << S_T5_AE2_RXSTAT_LSNA)
-#define F_T5_AE2_RXSTAT_LSNA V_T5_AE2_RXSTAT_LSNA(1U)
-
-#define S_T5_AE2_RXSTAT_FEC 13
-#define V_T5_AE2_RXSTAT_FEC(x) ((x) << S_T5_AE2_RXSTAT_FEC)
-#define F_T5_AE2_RXSTAT_FEC V_T5_AE2_RXSTAT_FEC(1U)
-
-#define S_T5_AE2_RXSTAT_TF 12
-#define V_T5_AE2_RXSTAT_TF(x) ((x) << S_T5_AE2_RXSTAT_TF)
-#define F_T5_AE2_RXSTAT_TF V_T5_AE2_RXSTAT_TF(1U)
-
-#define S_T5_AE2_RXSTAT_C3 6
-#define M_T5_AE2_RXSTAT_C3 0x3U
-#define V_T5_AE2_RXSTAT_C3(x) ((x) << S_T5_AE2_RXSTAT_C3)
-#define G_T5_AE2_RXSTAT_C3(x) (((x) >> S_T5_AE2_RXSTAT_C3) & M_T5_AE2_RXSTAT_C3)
-
-#define A_MAC_PORT_AE_TX_COEF_REQ_2 0x2a48
-#define A_MAC_PORT_AE_TX_COEF_STAT_2 0x2a4c
-#define A_MAC_PORT_AE_REG_MODE_2 0x2a50
-#define A_MAC_PORT_AE_PRBS_CTL_2 0x2a54
-#define A_MAC_PORT_AE_FSM_CTL_2 0x2a58
-#define A_MAC_PORT_AE_FSM_STATE_2 0x2a5c
-#define A_MAC_PORT_AE_RX_COEF_REQ_3 0x2a60
-#define A_MAC_PORT_AE_RX_COEF_STAT_3 0x2a64
-
-#define S_T5_AE3_RXSTAT_RDY 15
-#define V_T5_AE3_RXSTAT_RDY(x) ((x) << S_T5_AE3_RXSTAT_RDY)
-#define F_T5_AE3_RXSTAT_RDY V_T5_AE3_RXSTAT_RDY(1U)
-
-#define S_T5_AE3_RXSTAT_C2 4
-#define M_T5_AE3_RXSTAT_C2 0x3U
-#define V_T5_AE3_RXSTAT_C2(x) ((x) << S_T5_AE3_RXSTAT_C2)
-#define G_T5_AE3_RXSTAT_C2(x) (((x) >> S_T5_AE3_RXSTAT_C2) & M_T5_AE3_RXSTAT_C2)
-
-#define S_T5_AE3_RXSTAT_C1 2
-#define M_T5_AE3_RXSTAT_C1 0x3U
-#define V_T5_AE3_RXSTAT_C1(x) ((x) << S_T5_AE3_RXSTAT_C1)
-#define G_T5_AE3_RXSTAT_C1(x) (((x) >> S_T5_AE3_RXSTAT_C1) & M_T5_AE3_RXSTAT_C1)
-
-#define S_T5_AE3_RXSTAT_C0 0
-#define M_T5_AE3_RXSTAT_C0 0x3U
-#define V_T5_AE3_RXSTAT_C0(x) ((x) << S_T5_AE3_RXSTAT_C0)
-#define G_T5_AE3_RXSTAT_C0(x) (((x) >> S_T5_AE3_RXSTAT_C0) & M_T5_AE3_RXSTAT_C0)
-
-#define S_T5_AE3_RXSTAT_LSNA 14
-#define V_T5_AE3_RXSTAT_LSNA(x) ((x) << S_T5_AE3_RXSTAT_LSNA)
-#define F_T5_AE3_RXSTAT_LSNA V_T5_AE3_RXSTAT_LSNA(1U)
-
-#define S_T5_AE3_RXSTAT_FEC 13
-#define V_T5_AE3_RXSTAT_FEC(x) ((x) << S_T5_AE3_RXSTAT_FEC)
-#define F_T5_AE3_RXSTAT_FEC V_T5_AE3_RXSTAT_FEC(1U)
-
-#define S_T5_AE3_RXSTAT_TF 12
-#define V_T5_AE3_RXSTAT_TF(x) ((x) << S_T5_AE3_RXSTAT_TF)
-#define F_T5_AE3_RXSTAT_TF V_T5_AE3_RXSTAT_TF(1U)
-
-#define S_T5_AE3_RXSTAT_C3 6
-#define M_T5_AE3_RXSTAT_C3 0x3U
-#define V_T5_AE3_RXSTAT_C3(x) ((x) << S_T5_AE3_RXSTAT_C3)
-#define G_T5_AE3_RXSTAT_C3(x) (((x) >> S_T5_AE3_RXSTAT_C3) & M_T5_AE3_RXSTAT_C3)
-
-#define A_MAC_PORT_AE_TX_COEF_REQ_3 0x2a68
-#define A_MAC_PORT_AE_TX_COEF_STAT_3 0x2a6c
-#define A_MAC_PORT_AE_REG_MODE_3 0x2a70
-#define A_MAC_PORT_AE_PRBS_CTL_3 0x2a74
-#define A_MAC_PORT_AE_FSM_CTL_3 0x2a78
-#define A_MAC_PORT_AE_FSM_STATE_3 0x2a7c
-#define A_MAC_PORT_AE_TX_DIS 0x2a80
-#define A_MAC_PORT_AE_KR_CTRL 0x2a84
-#define A_MAC_PORT_AE_RX_SIGDET 0x2a88
-#define A_MAC_PORT_AE_KR_STATUS 0x2a8c
-#define A_MAC_PORT_AE_TX_DIS_1 0x2a90
-#define A_MAC_PORT_AE_KR_CTRL_1 0x2a94
-#define A_MAC_PORT_AE_RX_SIGDET_1 0x2a98
-#define A_MAC_PORT_AE_KR_STATUS_1 0x2a9c
-#define A_MAC_PORT_AE_TX_DIS_2 0x2aa0
-#define A_MAC_PORT_AE_KR_CTRL_2 0x2aa4
-#define A_MAC_PORT_AE_RX_SIGDET_2 0x2aa8
-#define A_MAC_PORT_AE_KR_STATUS_2 0x2aac
-#define A_MAC_PORT_AE_TX_DIS_3 0x2ab0
-#define A_MAC_PORT_AE_KR_CTRL_3 0x2ab4
-#define A_MAC_PORT_AE_RX_SIGDET_3 0x2ab8
-#define A_MAC_PORT_AE_KR_STATUS_3 0x2abc
-#define A_MAC_PORT_AET_STAGE_CONFIGURATION_0 0x2b00
-
-#define S_EN_HOLD_FAIL 14
-#define V_EN_HOLD_FAIL(x) ((x) << S_EN_HOLD_FAIL)
-#define F_EN_HOLD_FAIL V_EN_HOLD_FAIL(1U)
-
-#define S_INIT_METH 12
-#define M_INIT_METH 0x3U
-#define V_INIT_METH(x) ((x) << S_INIT_METH)
-#define G_INIT_METH(x) (((x) >> S_INIT_METH) & M_INIT_METH)
-
-#define S_CE_DECS 8
-#define M_CE_DECS 0xfU
-#define V_CE_DECS(x) ((x) << S_CE_DECS)
-#define G_CE_DECS(x) (((x) >> S_CE_DECS) & M_CE_DECS)
-
-#define S_EN_ZFE 7
-#define V_EN_ZFE(x) ((x) << S_EN_ZFE)
-#define F_EN_ZFE V_EN_ZFE(1U)
-
-#define S_EN_GAIN_TOG 6
-#define V_EN_GAIN_TOG(x) ((x) << S_EN_GAIN_TOG)
-#define F_EN_GAIN_TOG V_EN_GAIN_TOG(1U)
-
-#define S_EN_AI_C1 5
-#define V_EN_AI_C1(x) ((x) << S_EN_AI_C1)
-#define F_EN_AI_C1 V_EN_AI_C1(1U)
-
-#define S_EN_MAX_ST 4
-#define V_EN_MAX_ST(x) ((x) << S_EN_MAX_ST)
-#define F_EN_MAX_ST V_EN_MAX_ST(1U)
-
-#define S_EN_H1T_EQ 3
-#define V_EN_H1T_EQ(x) ((x) << S_EN_H1T_EQ)
-#define F_EN_H1T_EQ V_EN_H1T_EQ(1U)
-
-#define S_H1TEQ_GOAL 0
-#define M_H1TEQ_GOAL 0x7U
-#define V_H1TEQ_GOAL(x) ((x) << S_H1TEQ_GOAL)
-#define G_H1TEQ_GOAL(x) (((x) >> S_H1TEQ_GOAL) & M_H1TEQ_GOAL)
-
-#define S_T6_INIT_METH 12
-#define M_T6_INIT_METH 0xfU
-#define V_T6_INIT_METH(x) ((x) << S_T6_INIT_METH)
-#define G_T6_INIT_METH(x) (((x) >> S_T6_INIT_METH) & M_T6_INIT_METH)
-
-#define S_INIT_CNT 8
-#define M_INIT_CNT 0xfU
-#define V_INIT_CNT(x) ((x) << S_INIT_CNT)
-#define G_INIT_CNT(x) (((x) >> S_INIT_CNT) & M_INIT_CNT)
-
-#define S_EN_AI_N0 5
-#define V_EN_AI_N0(x) ((x) << S_EN_AI_N0)
-#define F_EN_AI_N0 V_EN_AI_N0(1U)
-
-#define A_MAC_PORT_AET_SIGNAL_LOSS_DETECTION_0 0x2b04
-
-#define S_GAIN_TH 6
-#define M_GAIN_TH 0x1fU
-#define V_GAIN_TH(x) ((x) << S_GAIN_TH)
-#define G_GAIN_TH(x) (((x) >> S_GAIN_TH) & M_GAIN_TH)
-
-#define S_EN_SD_TH 5
-#define V_EN_SD_TH(x) ((x) << S_EN_SD_TH)
-#define F_EN_SD_TH V_EN_SD_TH(1U)
-
-#define S_EN_AMIN_TH 4
-#define V_EN_AMIN_TH(x) ((x) << S_EN_AMIN_TH)
-#define F_EN_AMIN_TH V_EN_AMIN_TH(1U)
-
-#define S_AMIN_TH 0
-#define M_AMIN_TH 0xfU
-#define V_AMIN_TH(x) ((x) << S_AMIN_TH)
-#define G_AMIN_TH(x) (((x) >> S_AMIN_TH) & M_AMIN_TH)
-
-#define S_FEC_CNV 15
-#define V_FEC_CNV(x) ((x) << S_FEC_CNV)
-#define F_FEC_CNV V_FEC_CNV(1U)
-
-#define S_EN_RETRY 14
-#define V_EN_RETRY(x) ((x) << S_EN_RETRY)
-#define F_EN_RETRY V_EN_RETRY(1U)
-
-#define S_DPC_METH 12
-#define M_DPC_METH 0x3U
-#define V_DPC_METH(x) ((x) << S_DPC_METH)
-#define G_DPC_METH(x) (((x) >> S_DPC_METH) & M_DPC_METH)
-
-#define S_EN_P2 11
-#define V_EN_P2(x) ((x) << S_EN_P2)
-#define F_EN_P2 V_EN_P2(1U)
-
-#define A_MAC_PORT_AET_ZFE_LIMITS_0 0x2b08
-
-#define S_ACC_LIM 8
-#define M_ACC_LIM 0xfU
-#define V_ACC_LIM(x) ((x) << S_ACC_LIM)
-#define G_ACC_LIM(x) (((x) >> S_ACC_LIM) & M_ACC_LIM)
-
-#define S_CNV_LIM 4
-#define M_CNV_LIM 0xfU
-#define V_CNV_LIM(x) ((x) << S_CNV_LIM)
-#define G_CNV_LIM(x) (((x) >> S_CNV_LIM) & M_CNV_LIM)
-
-#define S_TOG_LIM 0
-#define M_TOG_LIM 0xfU
-#define V_TOG_LIM(x) ((x) << S_TOG_LIM)
-#define G_TOG_LIM(x) (((x) >> S_TOG_LIM) & M_TOG_LIM)
-
-#define A_MAC_PORT_AET_BOOTSTRAP_LOOKUP_TABLE_0 0x2b0c
-
-#define S_BOOT_LUT7 12
-#define M_BOOT_LUT7 0xfU
-#define V_BOOT_LUT7(x) ((x) << S_BOOT_LUT7)
-#define G_BOOT_LUT7(x) (((x) >> S_BOOT_LUT7) & M_BOOT_LUT7)
-
-#define S_BOOT_LUT6 8
-#define M_BOOT_LUT6 0xfU
-#define V_BOOT_LUT6(x) ((x) << S_BOOT_LUT6)
-#define G_BOOT_LUT6(x) (((x) >> S_BOOT_LUT6) & M_BOOT_LUT6)
-
-#define S_BOOT_LUT45 4
-#define M_BOOT_LUT45 0xfU
-#define V_BOOT_LUT45(x) ((x) << S_BOOT_LUT45)
-#define G_BOOT_LUT45(x) (((x) >> S_BOOT_LUT45) & M_BOOT_LUT45)
-
-#define S_BOOT_LUT0123 2
-#define M_BOOT_LUT0123 0x3U
-#define V_BOOT_LUT0123(x) ((x) << S_BOOT_LUT0123)
-#define G_BOOT_LUT0123(x) (((x) >> S_BOOT_LUT0123) & M_BOOT_LUT0123)
-
-#define S_BOOT_DEC_C0 1
-#define V_BOOT_DEC_C0(x) ((x) << S_BOOT_DEC_C0)
-#define F_BOOT_DEC_C0 V_BOOT_DEC_C0(1U)
-
-#define S_BOOT_LUT5 8
-#define M_BOOT_LUT5 0xfU
-#define V_BOOT_LUT5(x) ((x) << S_BOOT_LUT5)
-#define G_BOOT_LUT5(x) (((x) >> S_BOOT_LUT5) & M_BOOT_LUT5)
-
-#define A_MAC_PORT_AET_STATUS_0 0x2b10
-
-#define S_AET_STAT 9
-#define M_AET_STAT 0xfU
-#define V_AET_STAT(x) ((x) << S_AET_STAT)
-#define G_AET_STAT(x) (((x) >> S_AET_STAT) & M_AET_STAT)
-
-#define S_NEU_STATE 5
-#define M_NEU_STATE 0xfU
-#define V_NEU_STATE(x) ((x) << S_NEU_STATE)
-#define G_NEU_STATE(x) (((x) >> S_NEU_STATE) & M_NEU_STATE)
-
-#define S_CTRL_STATE 0
-#define M_CTRL_STATE 0x1fU
-#define V_CTRL_STATE(x) ((x) << S_CTRL_STATE)
-#define G_CTRL_STATE(x) (((x) >> S_CTRL_STATE) & M_CTRL_STATE)
-
-#define S_CTRL_STAT 8
-#define M_CTRL_STAT 0x1fU
-#define V_CTRL_STAT(x) ((x) << S_CTRL_STAT)
-#define G_CTRL_STAT(x) (((x) >> S_CTRL_STAT) & M_CTRL_STAT)
-
-#define S_T6_NEU_STATE 4
-#define M_T6_NEU_STATE 0xfU
-#define V_T6_NEU_STATE(x) ((x) << S_T6_NEU_STATE)
-#define G_T6_NEU_STATE(x) (((x) >> S_T6_NEU_STATE) & M_T6_NEU_STATE)
-
-#define S_T6_CTRL_STATE 0
-#define M_T6_CTRL_STATE 0xfU
-#define V_T6_CTRL_STATE(x) ((x) << S_T6_CTRL_STATE)
-#define G_T6_CTRL_STATE(x) (((x) >> S_T6_CTRL_STATE) & M_T6_CTRL_STATE)
-
-#define A_MAC_PORT_AET_STATUS_20 0x2b14
-
-#define S_FRAME_LOCK_CNT 0
-#define M_FRAME_LOCK_CNT 0x7U
-#define V_FRAME_LOCK_CNT(x) ((x) << S_FRAME_LOCK_CNT)
-#define G_FRAME_LOCK_CNT(x) (((x) >> S_FRAME_LOCK_CNT) & M_FRAME_LOCK_CNT)
-
-#define A_MAC_PORT_AET_LIMITS0 0x2b18
-
-#define S_DPC_TIME_LIM 0
-#define M_DPC_TIME_LIM 0x3U
-#define V_DPC_TIME_LIM(x) ((x) << S_DPC_TIME_LIM)
-#define G_DPC_TIME_LIM(x) (((x) >> S_DPC_TIME_LIM) & M_DPC_TIME_LIM)
-
-#define A_MAC_PORT_AET_STAGE_CONFIGURATION_1 0x2b20
-
-#define S_T6_INIT_METH 12
-#define M_T6_INIT_METH 0xfU
-#define V_T6_INIT_METH(x) ((x) << S_T6_INIT_METH)
-#define G_T6_INIT_METH(x) (((x) >> S_T6_INIT_METH) & M_T6_INIT_METH)
-
-#define A_MAC_PORT_AET_SIGNAL_LOSS_DETECTION_1 0x2b24
-#define A_MAC_PORT_AET_ZFE_LIMITS_1 0x2b28
-#define A_MAC_PORT_AET_BOOTSTRAP_LOOKUP_TABLE_1 0x2b2c
-#define A_MAC_PORT_AET_STATUS_1 0x2b30
-
-#define S_T6_NEU_STATE 4
-#define M_T6_NEU_STATE 0xfU
-#define V_T6_NEU_STATE(x) ((x) << S_T6_NEU_STATE)
-#define G_T6_NEU_STATE(x) (((x) >> S_T6_NEU_STATE) & M_T6_NEU_STATE)
-
-#define S_T6_CTRL_STATE 0
-#define M_T6_CTRL_STATE 0xfU
-#define V_T6_CTRL_STATE(x) ((x) << S_T6_CTRL_STATE)
-#define G_T6_CTRL_STATE(x) (((x) >> S_T6_CTRL_STATE) & M_T6_CTRL_STATE)
-
-#define A_MAC_PORT_AET_STATUS_21 0x2b34
-#define A_MAC_PORT_AET_LIMITS1 0x2b38
-#define A_MAC_PORT_AET_STAGE_CONFIGURATION_2 0x2b40
-
-#define S_T6_INIT_METH 12
-#define M_T6_INIT_METH 0xfU
-#define V_T6_INIT_METH(x) ((x) << S_T6_INIT_METH)
-#define G_T6_INIT_METH(x) (((x) >> S_T6_INIT_METH) & M_T6_INIT_METH)
-
-#define A_MAC_PORT_AET_SIGNAL_LOSS_DETECTION_2 0x2b44
-#define A_MAC_PORT_AET_ZFE_LIMITS_2 0x2b48
-#define A_MAC_PORT_AET_BOOTSTRAP_LOOKUP_TABLE_2 0x2b4c
-#define A_MAC_PORT_AET_STATUS_2 0x2b50
-
-#define S_T6_NEU_STATE 4
-#define M_T6_NEU_STATE 0xfU
-#define V_T6_NEU_STATE(x) ((x) << S_T6_NEU_STATE)
-#define G_T6_NEU_STATE(x) (((x) >> S_T6_NEU_STATE) & M_T6_NEU_STATE)
-
-#define S_T6_CTRL_STATE 0
-#define M_T6_CTRL_STATE 0xfU
-#define V_T6_CTRL_STATE(x) ((x) << S_T6_CTRL_STATE)
-#define G_T6_CTRL_STATE(x) (((x) >> S_T6_CTRL_STATE) & M_T6_CTRL_STATE)
-
-#define A_MAC_PORT_AET_STATUS_22 0x2b54
-#define A_MAC_PORT_AET_LIMITS2 0x2b58
-#define A_MAC_PORT_AET_STAGE_CONFIGURATION_3 0x2b60
-
-#define S_T6_INIT_METH 12
-#define M_T6_INIT_METH 0xfU
-#define V_T6_INIT_METH(x) ((x) << S_T6_INIT_METH)
-#define G_T6_INIT_METH(x) (((x) >> S_T6_INIT_METH) & M_T6_INIT_METH)
-
-#define A_MAC_PORT_AET_SIGNAL_LOSS_DETECTION_3 0x2b64
-#define A_MAC_PORT_AET_ZFE_LIMITS_3 0x2b68
-#define A_MAC_PORT_AET_BOOTSTRAP_LOOKUP_TABLE_3 0x2b6c
-#define A_MAC_PORT_AET_STATUS_3 0x2b70
-
-#define S_T6_NEU_STATE 4
-#define M_T6_NEU_STATE 0xfU
-#define V_T6_NEU_STATE(x) ((x) << S_T6_NEU_STATE)
-#define G_T6_NEU_STATE(x) (((x) >> S_T6_NEU_STATE) & M_T6_NEU_STATE)
-
-#define S_T6_CTRL_STATE 0
-#define M_T6_CTRL_STATE 0xfU
-#define V_T6_CTRL_STATE(x) ((x) << S_T6_CTRL_STATE)
-#define G_T6_CTRL_STATE(x) (((x) >> S_T6_CTRL_STATE) & M_T6_CTRL_STATE)
-
-#define A_MAC_PORT_AET_STATUS_23 0x2b74
-#define A_MAC_PORT_AET_LIMITS3 0x2b78
-#define A_T6_MAC_PORT_BEAN_CTL 0x2c00
-#define A_T6_MAC_PORT_BEAN_STATUS 0x2c04
-#define A_T6_MAC_PORT_BEAN_ABILITY_0 0x2c08
-
-#define S_BEAN_REM_FAULT 13
-#define V_BEAN_REM_FAULT(x) ((x) << S_BEAN_REM_FAULT)
-#define F_BEAN_REM_FAULT V_BEAN_REM_FAULT(1U)
-
-#define A_T6_MAC_PORT_BEAN_ABILITY_1 0x2c0c
-#define A_T6_MAC_PORT_BEAN_ABILITY_2 0x2c10
-#define A_T6_MAC_PORT_BEAN_REM_ABILITY_0 0x2c14
-
-#define S_BEAN_ABL_REM_FAULT 13
-#define V_BEAN_ABL_REM_FAULT(x) ((x) << S_BEAN_ABL_REM_FAULT)
-#define F_BEAN_ABL_REM_FAULT V_BEAN_ABL_REM_FAULT(1U)
-
-#define A_T6_MAC_PORT_BEAN_REM_ABILITY_1 0x2c18
-#define A_T6_MAC_PORT_BEAN_REM_ABILITY_2 0x2c1c
-#define A_T6_MAC_PORT_BEAN_MS_COUNT 0x2c20
-#define A_T6_MAC_PORT_BEAN_XNP_0 0x2c24
-#define A_T6_MAC_PORT_BEAN_XNP_1 0x2c28
-#define A_T6_MAC_PORT_BEAN_XNP_2 0x2c2c
-#define A_T6_MAC_PORT_LP_BEAN_XNP_0 0x2c30
-#define A_T6_MAC_PORT_LP_BEAN_XNP_1 0x2c34
-#define A_T6_MAC_PORT_LP_BEAN_XNP_2 0x2c38
-#define A_T6_MAC_PORT_BEAN_ETH_STATUS 0x2c3c
-
-#define S_100GCR4 11
-#define V_100GCR4(x) ((x) << S_100GCR4)
-#define F_100GCR4 V_100GCR4(1U)
-
-#define S_100GKR4 10
-#define V_100GKR4(x) ((x) << S_100GKR4)
-#define F_100GKR4 V_100GKR4(1U)
-
-#define S_100GKP4 9
-#define V_100GKP4(x) ((x) << S_100GKP4)
-#define F_100GKP4 V_100GKP4(1U)
-
-#define A_MAC_PORT_TX_LINKA_TRANSMIT_CONFIGURATION_MODE 0x3000
-
-#define S_T5_TX_LINKEN 15
-#define V_T5_TX_LINKEN(x) ((x) << S_T5_TX_LINKEN)
-#define F_T5_TX_LINKEN V_T5_TX_LINKEN(1U)
-
-#define S_T5_TX_LINKRST 14
-#define V_T5_TX_LINKRST(x) ((x) << S_T5_TX_LINKRST)
-#define F_T5_TX_LINKRST V_T5_TX_LINKRST(1U)
-
-#define S_T5_TX_CFGWRT 13
-#define V_T5_TX_CFGWRT(x) ((x) << S_T5_TX_CFGWRT)
-#define F_T5_TX_CFGWRT V_T5_TX_CFGWRT(1U)
-
-#define S_T5_TX_CFGPTR 11
-#define M_T5_TX_CFGPTR 0x3U
-#define V_T5_TX_CFGPTR(x) ((x) << S_T5_TX_CFGPTR)
-#define G_T5_TX_CFGPTR(x) (((x) >> S_T5_TX_CFGPTR) & M_T5_TX_CFGPTR)
-
-#define S_T5_TX_CFGEXT 10
-#define V_T5_TX_CFGEXT(x) ((x) << S_T5_TX_CFGEXT)
-#define F_T5_TX_CFGEXT V_T5_TX_CFGEXT(1U)
-
-#define S_T5_TX_CFGACT 9
-#define V_T5_TX_CFGACT(x) ((x) << S_T5_TX_CFGACT)
-#define F_T5_TX_CFGACT V_T5_TX_CFGACT(1U)
-
-#define S_T5_TX_RSYNCC 8
-#define V_T5_TX_RSYNCC(x) ((x) << S_T5_TX_RSYNCC)
-#define F_T5_TX_RSYNCC V_T5_TX_RSYNCC(1U)
-
-#define S_T5_TX_PLLSEL 6
-#define M_T5_TX_PLLSEL 0x3U
-#define V_T5_TX_PLLSEL(x) ((x) << S_T5_TX_PLLSEL)
-#define G_T5_TX_PLLSEL(x) (((x) >> S_T5_TX_PLLSEL) & M_T5_TX_PLLSEL)
-
-#define S_T5_TX_EXTC16 5
-#define V_T5_TX_EXTC16(x) ((x) << S_T5_TX_EXTC16)
-#define F_T5_TX_EXTC16 V_T5_TX_EXTC16(1U)
-
-#define S_T5_TX_DCKSEL 4
-#define V_T5_TX_DCKSEL(x) ((x) << S_T5_TX_DCKSEL)
-#define F_T5_TX_DCKSEL V_T5_TX_DCKSEL(1U)
-
-#define S_T5_TX_RXLOOP 3
-#define V_T5_TX_RXLOOP(x) ((x) << S_T5_TX_RXLOOP)
-#define F_T5_TX_RXLOOP V_T5_TX_RXLOOP(1U)
-
-#define S_T5_TX_BWSEL 2
-#define V_T5_TX_BWSEL(x) ((x) << S_T5_TX_BWSEL)
-#define F_T5_TX_BWSEL V_T5_TX_BWSEL(1U)
-
-#define S_T5_TX_RTSEL 0
-#define M_T5_TX_RTSEL 0x3U
-#define V_T5_TX_RTSEL(x) ((x) << S_T5_TX_RTSEL)
-#define G_T5_TX_RTSEL(x) (((x) >> S_T5_TX_RTSEL) & M_T5_TX_RTSEL)
-
-#define S_T6_T5_TX_RXLOOP 5
-#define V_T6_T5_TX_RXLOOP(x) ((x) << S_T6_T5_TX_RXLOOP)
-#define F_T6_T5_TX_RXLOOP V_T6_T5_TX_RXLOOP(1U)
-
-#define S_T5_TX_ENFFE4 4
-#define V_T5_TX_ENFFE4(x) ((x) << S_T5_TX_ENFFE4)
-#define F_T5_TX_ENFFE4 V_T5_TX_ENFFE4(1U)
-
-#define S_T6_T5_TX_BWSEL 2
-#define M_T6_T5_TX_BWSEL 0x3U
-#define V_T6_T5_TX_BWSEL(x) ((x) << S_T6_T5_TX_BWSEL)
-#define G_T6_T5_TX_BWSEL(x) (((x) >> S_T6_T5_TX_BWSEL) & M_T6_T5_TX_BWSEL)
-
-#define A_MAC_PORT_TX_LINKA_TRANSMIT_TEST_CONTROL 0x3004
-
-#define S_SPSEL 11
-#define M_SPSEL 0x7U
-#define V_SPSEL(x) ((x) << S_SPSEL)
-#define G_SPSEL(x) (((x) >> S_SPSEL) & M_SPSEL)
-
-#define S_AFDWEN 7
-#define V_AFDWEN(x) ((x) << S_AFDWEN)
-#define F_AFDWEN V_AFDWEN(1U)
-
-#define S_TPGMD 3
-#define V_TPGMD(x) ((x) << S_TPGMD)
-#define F_TPGMD V_TPGMD(1U)
-
-#define S_TC_FRCERR 10
-#define V_TC_FRCERR(x) ((x) << S_TC_FRCERR)
-#define F_TC_FRCERR V_TC_FRCERR(1U)
-
-#define S_T6_ERROR 9
-#define V_T6_ERROR(x) ((x) << S_T6_ERROR)
-#define F_T6_ERROR V_T6_ERROR(1U)
-
-#define S_SYNC 8
-#define V_SYNC(x) ((x) << S_SYNC)
-#define F_SYNC V_SYNC(1U)
-
-#define S_P7CHK 5
-#define V_P7CHK(x) ((x) << S_P7CHK)
-#define F_P7CHK V_P7CHK(1U)
-
-#define A_MAC_PORT_TX_LINKA_TRANSMIT_COEFFICIENT_CONTROL 0x3008
-
-#define S_ZCALOVRD 8
-#define V_ZCALOVRD(x) ((x) << S_ZCALOVRD)
-#define F_ZCALOVRD V_ZCALOVRD(1U)
-
-#define S_AMMODE 7
-#define V_AMMODE(x) ((x) << S_AMMODE)
-#define F_AMMODE V_AMMODE(1U)
-
-#define S_AEPOL 6
-#define V_AEPOL(x) ((x) << S_AEPOL)
-#define F_AEPOL V_AEPOL(1U)
-
-#define S_AESRC 5
-#define V_AESRC(x) ((x) << S_AESRC)
-#define F_AESRC V_AESRC(1U)
-
-#define S_SASMODE 7
-#define V_SASMODE(x) ((x) << S_SASMODE)
-#define F_SASMODE V_SASMODE(1U)
-
-#define A_MAC_PORT_TX_LINKA_TRANSMIT_DRIVER_MODE_CONTROL 0x300c
-
-#define S_T5DRVHIZ 5
-#define V_T5DRVHIZ(x) ((x) << S_T5DRVHIZ)
-#define F_T5DRVHIZ V_T5DRVHIZ(1U)
-
-#define S_T5SASIMP 4
-#define V_T5SASIMP(x) ((x) << S_T5SASIMP)
-#define F_T5SASIMP V_T5SASIMP(1U)
-
-#define S_T5SLEW 2
-#define M_T5SLEW 0x3U
-#define V_T5SLEW(x) ((x) << S_T5SLEW)
-#define G_T5SLEW(x) (((x) >> S_T5SLEW) & M_T5SLEW)
-
-#define A_MAC_PORT_TX_LINKA_TRANSMIT_DRIVER_OVERRIDE_CONTROL 0x3010
-
-#define S_T5C2BUFDCEN 5
-#define V_T5C2BUFDCEN(x) ((x) << S_T5C2BUFDCEN)
-#define F_T5C2BUFDCEN V_T5C2BUFDCEN(1U)
-
-#define S_T5DCCEN 4
-#define V_T5DCCEN(x) ((x) << S_T5DCCEN)
-#define F_T5DCCEN V_T5DCCEN(1U)
-
-#define S_T5REGBYP 3
-#define V_T5REGBYP(x) ((x) << S_T5REGBYP)
-#define F_T5REGBYP V_T5REGBYP(1U)
-
-#define S_T5REGAEN 2
-#define V_T5REGAEN(x) ((x) << S_T5REGAEN)
-#define F_T5REGAEN V_T5REGAEN(1U)
-
-#define S_T5REGAMP 0
-#define M_T5REGAMP 0x3U
-#define V_T5REGAMP(x) ((x) << S_T5REGAMP)
-#define G_T5REGAMP(x) (((x) >> S_T5REGAMP) & M_T5REGAMP)
-
-#define A_MAC_PORT_TX_LINKA_TRANSMIT_DCLK_ROTATOR_OVERRIDE 0x3014
-
-#define S_RSTEP 15
-#define V_RSTEP(x) ((x) << S_RSTEP)
-#define F_RSTEP V_RSTEP(1U)
-
-#define S_RLOCK 14
-#define V_RLOCK(x) ((x) << S_RLOCK)
-#define F_RLOCK V_RLOCK(1U)
-
-#define S_RPOS 8
-#define M_RPOS 0x3fU
-#define V_RPOS(x) ((x) << S_RPOS)
-#define G_RPOS(x) (((x) >> S_RPOS) & M_RPOS)
-
-#define S_DCLKSAM 7
-#define V_DCLKSAM(x) ((x) << S_DCLKSAM)
-#define F_DCLKSAM V_DCLKSAM(1U)
-
-#define A_MAC_PORT_TX_LINKA_TRANSMIT_IMPEDANCE_CALIBRATION_OVERRIDE 0x3018
-
-#define S_CALSSTN 3
-#define M_CALSSTN 0x7U
-#define V_CALSSTN(x) ((x) << S_CALSSTN)
-#define G_CALSSTN(x) (((x) >> S_CALSSTN) & M_CALSSTN)
-
-#define S_CALSSTP 0
-#define M_CALSSTP 0x7U
-#define V_CALSSTP(x) ((x) << S_CALSSTP)
-#define G_CALSSTP(x) (((x) >> S_CALSSTP) & M_CALSSTP)
-
-#define S_T6_CALSSTN 8
-#define M_T6_CALSSTN 0x3fU
-#define V_T6_CALSSTN(x) ((x) << S_T6_CALSSTN)
-#define G_T6_CALSSTN(x) (((x) >> S_T6_CALSSTN) & M_T6_CALSSTN)
-
-#define S_T6_CALSSTP 0
-#define M_T6_CALSSTP 0x3fU
-#define V_T6_CALSSTP(x) ((x) << S_T6_CALSSTP)
-#define G_T6_CALSSTP(x) (((x) >> S_T6_CALSSTP) & M_T6_CALSSTP)
-
-#define A_MAC_PORT_TX_LINKA_TRANSMIT_DCLK_DRIFT_TOLERANCE 0x301c
-
-#define S_DRTOL 0
-#define M_DRTOL 0x1fU
-#define V_DRTOL(x) ((x) << S_DRTOL)
-#define G_DRTOL(x) (((x) >> S_DRTOL) & M_DRTOL)
-
-#define S_T6_DRTOL 2
-#define M_T6_DRTOL 0x7U
-#define V_T6_DRTOL(x) ((x) << S_T6_DRTOL)
-#define G_T6_DRTOL(x) (((x) >> S_T6_DRTOL) & M_T6_DRTOL)
-
-#define A_MAC_PORT_TX_LINKA_TRANSMIT_TAP_0_COEFFICIENT 0x3020
-
-#define S_T5NXTT0 0
-#define M_T5NXTT0 0x1fU
-#define V_T5NXTT0(x) ((x) << S_T5NXTT0)
-#define G_T5NXTT0(x) (((x) >> S_T5NXTT0) & M_T5NXTT0)
-
-#define S_T6_NXTT0 0
-#define M_T6_NXTT0 0x3fU
-#define V_T6_NXTT0(x) ((x) << S_T6_NXTT0)
-#define G_T6_NXTT0(x) (((x) >> S_T6_NXTT0) & M_T6_NXTT0)
-
-#define A_MAC_PORT_TX_LINKA_TRANSMIT_TAP_1_COEFFICIENT 0x3024
-
-#define S_T5NXTT1 0
-#define M_T5NXTT1 0x3fU
-#define V_T5NXTT1(x) ((x) << S_T5NXTT1)
-#define G_T5NXTT1(x) (((x) >> S_T5NXTT1) & M_T5NXTT1)
-
-#define A_MAC_PORT_TX_LINKA_TRANSMIT_TAP_2_COEFFICIENT 0x3028
-
-#define S_T5NXTT2 0
-#define M_T5NXTT2 0x3fU
-#define V_T5NXTT2(x) ((x) << S_T5NXTT2)
-#define G_T5NXTT2(x) (((x) >> S_T5NXTT2) & M_T5NXTT2)
-
-#define S_T6_NXTT2 0
-#define M_T6_NXTT2 0x3fU
-#define V_T6_NXTT2(x) ((x) << S_T6_NXTT2)
-#define G_T6_NXTT2(x) (((x) >> S_T6_NXTT2) & M_T6_NXTT2)
-
-#define A_MAC_PORT_TX_LINKA_TRANSMIT_TAP_3_COEFFICIENT 0x302c
-
-#define S_NXTT3 0
-#define M_NXTT3 0x3fU
-#define V_NXTT3(x) ((x) << S_NXTT3)
-#define G_NXTT3(x) (((x) >> S_NXTT3) & M_NXTT3)
-
-#define A_MAC_PORT_TX_LINKA_TRANSMIT_AMPLITUDE 0x3030
-
-#define S_T5TXPWR 0
-#define M_T5TXPWR 0x3fU
-#define V_T5TXPWR(x) ((x) << S_T5TXPWR)
-#define G_T5TXPWR(x) (((x) >> S_T5TXPWR) & M_T5TXPWR)
-
-#define A_MAC_PORT_TX_LINKA_TRANSMIT_POLARITY 0x3034
-
-#define S_NXTPOL 0
-#define M_NXTPOL 0x7U
-#define V_NXTPOL(x) ((x) << S_NXTPOL)
-#define G_NXTPOL(x) (((x) >> S_NXTPOL) & M_NXTPOL)
-
-#define S_T6_NXTPOL 0
-#define M_T6_NXTPOL 0xfU
-#define V_T6_NXTPOL(x) ((x) << S_T6_NXTPOL)
-#define G_T6_NXTPOL(x) (((x) >> S_T6_NXTPOL) & M_T6_NXTPOL)
-
-#define A_MAC_PORT_TX_LINKA_TRANSMIT_802_3AP_ADAPTIVE_EQUALIZATION_COMMAND 0x3038
-
-#define S_CPREST 13
-#define V_CPREST(x) ((x) << S_CPREST)
-#define F_CPREST V_CPREST(1U)
-
-#define S_CINIT 12
-#define V_CINIT(x) ((x) << S_CINIT)
-#define F_CINIT V_CINIT(1U)
-
-#define S_SASCMD 10
-#define M_SASCMD 0x3U
-#define V_SASCMD(x) ((x) << S_SASCMD)
-#define G_SASCMD(x) (((x) >> S_SASCMD) & M_SASCMD)
-
-#define S_T6_C0UPDT 6
-#define M_T6_C0UPDT 0x3U
-#define V_T6_C0UPDT(x) ((x) << S_T6_C0UPDT)
-#define G_T6_C0UPDT(x) (((x) >> S_T6_C0UPDT) & M_T6_C0UPDT)
-
-#define S_C3UPDT 4
-#define M_C3UPDT 0x3U
-#define V_C3UPDT(x) ((x) << S_C3UPDT)
-#define G_C3UPDT(x) (((x) >> S_C3UPDT) & M_C3UPDT)
-
-#define S_T6_C2UPDT 2
-#define M_T6_C2UPDT 0x3U
-#define V_T6_C2UPDT(x) ((x) << S_T6_C2UPDT)
-#define G_T6_C2UPDT(x) (((x) >> S_T6_C2UPDT) & M_T6_C2UPDT)
-
-#define S_T6_C1UPDT 0
-#define M_T6_C1UPDT 0x3U
-#define V_T6_C1UPDT(x) ((x) << S_T6_C1UPDT)
-#define G_T6_C1UPDT(x) (((x) >> S_T6_C1UPDT) & M_T6_C1UPDT)
-
-#define A_MAC_PORT_TX_LINKA_TRANSMIT_802_3AP_ADAPTIVE_EQUALIZATION_STATUS 0x303c
-
-#define S_T6_C0STAT 6
-#define M_T6_C0STAT 0x3U
-#define V_T6_C0STAT(x) ((x) << S_T6_C0STAT)
-#define G_T6_C0STAT(x) (((x) >> S_T6_C0STAT) & M_T6_C0STAT)
-
-#define S_C3STAT 4
-#define M_C3STAT 0x3U
-#define V_C3STAT(x) ((x) << S_C3STAT)
-#define G_C3STAT(x) (((x) >> S_C3STAT) & M_C3STAT)
-
-#define S_T6_C2STAT 2
-#define M_T6_C2STAT 0x3U
-#define V_T6_C2STAT(x) ((x) << S_T6_C2STAT)
-#define G_T6_C2STAT(x) (((x) >> S_T6_C2STAT) & M_T6_C2STAT)
-
-#define S_T6_C1STAT 0
-#define M_T6_C1STAT 0x3U
-#define V_T6_C1STAT(x) ((x) << S_T6_C1STAT)
-#define G_T6_C1STAT(x) (((x) >> S_T6_C1STAT) & M_T6_C1STAT)
-
-#define A_MAC_PORT_TX_LINKA_TRANSMIT_TAP_0_COEFFICIENT_OVERRIDE 0x3040
-#define A_MAC_PORT_TX_LINKA_TRANSMIT_AE_TAP_0_COEFFICIENT_OVERRIDE 0x3040
-
-#define S_AETAP0 0
-#define M_AETAP0 0x7fU
-#define V_AETAP0(x) ((x) << S_AETAP0)
-#define G_AETAP0(x) (((x) >> S_AETAP0) & M_AETAP0)
-
-#define A_MAC_PORT_TX_LINKA_TRANSMIT_TAP_1_COEFFICIENT_OVERRIDE 0x3044
-
-#define S_T5NIDAC1 0
-#define M_T5NIDAC1 0x3fU
-#define V_T5NIDAC1(x) ((x) << S_T5NIDAC1)
-#define G_T5NIDAC1(x) (((x) >> S_T5NIDAC1) & M_T5NIDAC1)
-
-#define A_MAC_PORT_TX_LINKA_TRANSMIT_AE_TAP_1_COEFFICIENT_OVERRIDE 0x3044
-
-#define S_AETAP1 0
-#define M_AETAP1 0x7fU
-#define V_AETAP1(x) ((x) << S_AETAP1)
-#define G_AETAP1(x) (((x) >> S_AETAP1) & M_AETAP1)
-
-#define A_MAC_PORT_TX_LINKA_TRANSMIT_TAP_2_COEFFICIENT_OVERRIDE 0x3048
-
-#define S_T5NIDAC2 0
-#define M_T5NIDAC2 0x3fU
-#define V_T5NIDAC2(x) ((x) << S_T5NIDAC2)
-#define G_T5NIDAC2(x) (((x) >> S_T5NIDAC2) & M_T5NIDAC2)
-
-#define A_MAC_PORT_TX_LINKA_TRANSMIT_AE_TAP_2_COEFFICIENT_OVERRIDE 0x3048
-
-#define S_AETAP2 0
-#define M_AETAP2 0x7fU
-#define V_AETAP2(x) ((x) << S_AETAP2)
-#define G_AETAP2(x) (((x) >> S_AETAP2) & M_AETAP2)
-
-#define A_MAC_PORT_TX_LINKA_TRANSMIT_AE_TAP_3_COEFFICIENT_OVERRIDE 0x304c
-
-#define S_AETAP3 0
-#define M_AETAP3 0x7fU
-#define V_AETAP3(x) ((x) << S_AETAP3)
-#define G_AETAP3(x) (((x) >> S_AETAP3) & M_AETAP3)
-
-#define A_MAC_PORT_TX_LINKA_TRANSMIT_APPLIED_TUNE_REGISTER 0x3050
-
-#define S_ATUNEN 8
-#define M_ATUNEN 0xffU
-#define V_ATUNEN(x) ((x) << S_ATUNEN)
-#define G_ATUNEN(x) (((x) >> S_ATUNEN) & M_ATUNEN)
-
-#define S_ATUNEP 0
-#define M_ATUNEP 0xffU
-#define V_ATUNEP(x) ((x) << S_ATUNEP)
-#define G_ATUNEP(x) (((x) >> S_ATUNEP) & M_ATUNEP)
-
-#define A_MAC_PORT_TX_LINKA_TRANSMIT_ANALOG_DIAGNOSTICS_REGISTER 0x3058
-
-#define S_DCCCOMPINV 8
-#define V_DCCCOMPINV(x) ((x) << S_DCCCOMPINV)
-#define F_DCCCOMPINV V_DCCCOMPINV(1U)
-
-#define A_MAC_PORT_TX_LINKA_TRANSMIT_TAP_0_COEFFICIENT_APPLIED 0x3060
-#define A_MAC_PORT_TX_LINKA_TRANSMIT_4X_SEGMENT_APPLIED 0x3060
-
-#define S_AS4X7 14
-#define M_AS4X7 0x3U
-#define V_AS4X7(x) ((x) << S_AS4X7)
-#define G_AS4X7(x) (((x) >> S_AS4X7) & M_AS4X7)
-
-#define S_AS4X6 12
-#define M_AS4X6 0x3U
-#define V_AS4X6(x) ((x) << S_AS4X6)
-#define G_AS4X6(x) (((x) >> S_AS4X6) & M_AS4X6)
-
-#define S_AS4X5 10
-#define M_AS4X5 0x3U
-#define V_AS4X5(x) ((x) << S_AS4X5)
-#define G_AS4X5(x) (((x) >> S_AS4X5) & M_AS4X5)
-
-#define S_AS4X4 8
-#define M_AS4X4 0x3U
-#define V_AS4X4(x) ((x) << S_AS4X4)
-#define G_AS4X4(x) (((x) >> S_AS4X4) & M_AS4X4)
-
-#define S_AS4X3 6
-#define M_AS4X3 0x3U
-#define V_AS4X3(x) ((x) << S_AS4X3)
-#define G_AS4X3(x) (((x) >> S_AS4X3) & M_AS4X3)
-
-#define S_AS4X2 4
-#define M_AS4X2 0x3U
-#define V_AS4X2(x) ((x) << S_AS4X2)
-#define G_AS4X2(x) (((x) >> S_AS4X2) & M_AS4X2)
-
-#define S_AS4X1 2
-#define M_AS4X1 0x3U
-#define V_AS4X1(x) ((x) << S_AS4X1)
-#define G_AS4X1(x) (((x) >> S_AS4X1) & M_AS4X1)
-
-#define S_AS4X0 0
-#define M_AS4X0 0x3U
-#define V_AS4X0(x) ((x) << S_AS4X0)
-#define G_AS4X0(x) (((x) >> S_AS4X0) & M_AS4X0)
-
-#define A_MAC_PORT_TX_LINKA_TRANSMIT_TAP_1_COEFFICIENT_APPLIED 0x3064
-
-#define S_T5AIDAC1 0
-#define M_T5AIDAC1 0x3fU
-#define V_T5AIDAC1(x) ((x) << S_T5AIDAC1)
-#define G_T5AIDAC1(x) (((x) >> S_T5AIDAC1) & M_T5AIDAC1)
-
-#define A_MAC_PORT_TX_LINKA_TRANSMIT_2X_SEGMENT_APPLIED 0x3064
-
-#define S_AS2X3 6
-#define M_AS2X3 0x3U
-#define V_AS2X3(x) ((x) << S_AS2X3)
-#define G_AS2X3(x) (((x) >> S_AS2X3) & M_AS2X3)
-
-#define S_AS2X2 4
-#define M_AS2X2 0x3U
-#define V_AS2X2(x) ((x) << S_AS2X2)
-#define G_AS2X2(x) (((x) >> S_AS2X2) & M_AS2X2)
-
-#define S_AS2X1 2
-#define M_AS2X1 0x3U
-#define V_AS2X1(x) ((x) << S_AS2X1)
-#define G_AS2X1(x) (((x) >> S_AS2X1) & M_AS2X1)
-
-#define S_AS2X0 0
-#define M_AS2X0 0x3U
-#define V_AS2X0(x) ((x) << S_AS2X0)
-#define G_AS2X0(x) (((x) >> S_AS2X0) & M_AS2X0)
-
-#define A_MAC_PORT_TX_LINKA_TRANSMIT_TAP_2_COEFFICIENT_APPLIED 0x3068
-#define A_MAC_PORT_TX_LINKA_TRANSMIT_1X_SEGMENT_APPLIED 0x3068
-
-#define S_AS1X7 14
-#define M_AS1X7 0x3U
-#define V_AS1X7(x) ((x) << S_AS1X7)
-#define G_AS1X7(x) (((x) >> S_AS1X7) & M_AS1X7)
-
-#define S_AS1X6 12
-#define M_AS1X6 0x3U
-#define V_AS1X6(x) ((x) << S_AS1X6)
-#define G_AS1X6(x) (((x) >> S_AS1X6) & M_AS1X6)
-
-#define S_AS1X5 10
-#define M_AS1X5 0x3U
-#define V_AS1X5(x) ((x) << S_AS1X5)
-#define G_AS1X5(x) (((x) >> S_AS1X5) & M_AS1X5)
-
-#define S_AS1X4 8
-#define M_AS1X4 0x3U
-#define V_AS1X4(x) ((x) << S_AS1X4)
-#define G_AS1X4(x) (((x) >> S_AS1X4) & M_AS1X4)
-
-#define S_AS1X3 6
-#define M_AS1X3 0x3U
-#define V_AS1X3(x) ((x) << S_AS1X3)
-#define G_AS1X3(x) (((x) >> S_AS1X3) & M_AS1X3)
-
-#define S_AS1X2 4
-#define M_AS1X2 0x3U
-#define V_AS1X2(x) ((x) << S_AS1X2)
-#define G_AS1X2(x) (((x) >> S_AS1X2) & M_AS1X2)
-
-#define S_AS1X1 2
-#define M_AS1X1 0x3U
-#define V_AS1X1(x) ((x) << S_AS1X1)
-#define G_AS1X1(x) (((x) >> S_AS1X1) & M_AS1X1)
-
-#define S_AS1X0 0
-#define M_AS1X0 0x3U
-#define V_AS1X0(x) ((x) << S_AS1X0)
-#define G_AS1X0(x) (((x) >> S_AS1X0) & M_AS1X0)
-
-#define A_MAC_PORT_TX_LINKA_TRANSMIT_SEGMENT_4X_TERMINATION_APPLIED 0x306c
-
-#define S_AT4X 0
-#define M_AT4X 0xffU
-#define V_AT4X(x) ((x) << S_AT4X)
-#define G_AT4X(x) (((x) >> S_AT4X) & M_AT4X)
-
-#define A_MAC_PORT_TX_LINKA_TRANSMIT_SEGMENT_DISABLE_APPLIED_1 0x3070
-
-#define S_MAINSC 6
-#define M_MAINSC 0x3fU
-#define V_MAINSC(x) ((x) << S_MAINSC)
-#define G_MAINSC(x) (((x) >> S_MAINSC) & M_MAINSC)
-
-#define S_POSTSC 0
-#define M_POSTSC 0x3fU
-#define V_POSTSC(x) ((x) << S_POSTSC)
-#define G_POSTSC(x) (((x) >> S_POSTSC) & M_POSTSC)
-
-#define A_MAC_PORT_TX_LINKA_TRANSMIT_SEGMENT_2X1X_TERMINATION_APPLIED 0x3070
-
-#define S_AT2X 8
-#define M_AT2X 0xfU
-#define V_AT2X(x) ((x) << S_AT2X)
-#define G_AT2X(x) (((x) >> S_AT2X) & M_AT2X)
-
-#define A_MAC_PORT_TX_LINKA_TRANSMIT_SEGMENT_DISABLE_APPLIED_2 0x3074
-
-#define S_PRESC 0
-#define M_PRESC 0x1fU
-#define V_PRESC(x) ((x) << S_PRESC)
-#define G_PRESC(x) (((x) >> S_PRESC) & M_PRESC)
-
-#define A_MAC_PORT_TX_LINKA_TRANSMIT_TAP_SIGN_APPLIED_REGISTER 0x3074
-
-#define S_ATSIGN 0
-#define M_ATSIGN 0xfU
-#define V_ATSIGN(x) ((x) << S_ATSIGN)
-#define G_ATSIGN(x) (((x) >> S_ATSIGN) & M_ATSIGN)
-
-#define A_MAC_PORT_TX_LINKA_TRANSMIT_EXTENDED_ADDRESS_DATA 0x3078
-#define A_MAC_PORT_TX_LINKA_TRANSMIT_EXTENDED_ADDRESS_ADDR 0x307c
-
-#define S_T5XADDR 1
-#define M_T5XADDR 0x1fU
-#define V_T5XADDR(x) ((x) << S_T5XADDR)
-#define G_T5XADDR(x) (((x) >> S_T5XADDR) & M_T5XADDR)
-
-#define S_T5XWR 0
-#define V_T5XWR(x) ((x) << S_T5XWR)
-#define F_T5XWR V_T5XWR(1U)
-
-#define S_T6_XADDR 1
-#define M_T6_XADDR 0x1fU
-#define V_T6_XADDR(x) ((x) << S_T6_XADDR)
-#define G_T6_XADDR(x) (((x) >> S_T6_XADDR) & M_T6_XADDR)
-
-#define A_MAC_PORT_TX_LINKA_TRANSMIT_PATTERN_BUFFER_BYTES_1_0 0x3080
-
-#define S_XDAT10 0
-#define M_XDAT10 0xffffU
-#define V_XDAT10(x) ((x) << S_XDAT10)
-#define G_XDAT10(x) (((x) >> S_XDAT10) & M_XDAT10)
-
-#define A_MAC_PORT_TX_LINKA_TRANSMIT_PATTERN_BUFFER_BYTES_3_2 0x3084
-
-#define S_XDAT32 0
-#define M_XDAT32 0xffffU
-#define V_XDAT32(x) ((x) << S_XDAT32)
-#define G_XDAT32(x) (((x) >> S_XDAT32) & M_XDAT32)
-
-#define A_MAC_PORT_TX_LINKA_TRANSMIT_PATTERN_BUFFER_BYTE_4 0x3088
-
-#define S_XDAT4 0
-#define M_XDAT4 0xffU
-#define V_XDAT4(x) ((x) << S_XDAT4)
-#define G_XDAT4(x) (((x) >> S_XDAT4) & M_XDAT4)
-
-#define A_MAC_PORT_TX_LINKA_TRANSMIT_PATTERN_BUFFER_BYTES_5_4 0x3088
-
-#define S_XDAT54 0
-#define M_XDAT54 0xffffU
-#define V_XDAT54(x) ((x) << S_XDAT54)
-#define G_XDAT54(x) (((x) >> S_XDAT54) & M_XDAT54)
-
-#define A_MAC_PORT_TX_LINKA_TRANSMIT_DCC_CONTROL 0x308c
-
-#define S_DCCTIMEDOUT 15
-#define V_DCCTIMEDOUT(x) ((x) << S_DCCTIMEDOUT)
-#define F_DCCTIMEDOUT V_DCCTIMEDOUT(1U)
-
-#define S_DCCTIMEEN 14
-#define V_DCCTIMEEN(x) ((x) << S_DCCTIMEEN)
-#define F_DCCTIMEEN V_DCCTIMEEN(1U)
-
-#define S_DCCLOCK 13
-#define V_DCCLOCK(x) ((x) << S_DCCLOCK)
-#define F_DCCLOCK V_DCCLOCK(1U)
-
-#define S_DCCOFFSET 8
-#define M_DCCOFFSET 0x1fU
-#define V_DCCOFFSET(x) ((x) << S_DCCOFFSET)
-#define G_DCCOFFSET(x) (((x) >> S_DCCOFFSET) & M_DCCOFFSET)
-
-#define S_DCCSTEP 6
-#define M_DCCSTEP 0x3U
-#define V_DCCSTEP(x) ((x) << S_DCCSTEP)
-#define G_DCCSTEP(x) (((x) >> S_DCCSTEP) & M_DCCSTEP)
-
-#define S_DCCASTEP 1
-#define M_DCCASTEP 0x1fU
-#define V_DCCASTEP(x) ((x) << S_DCCASTEP)
-#define G_DCCASTEP(x) (((x) >> S_DCCASTEP) & M_DCCASTEP)
-
-#define S_DCCAEN 0
-#define V_DCCAEN(x) ((x) << S_DCCAEN)
-#define F_DCCAEN V_DCCAEN(1U)
-
-#define A_MAC_PORT_TX_LINKA_TRANSMIT_PATTERN_BUFFER_BYTES_7_6 0x308c
-
-#define S_XDAT76 0
-#define M_XDAT76 0xffffU
-#define V_XDAT76(x) ((x) << S_XDAT76)
-#define G_XDAT76(x) (((x) >> S_XDAT76) & M_XDAT76)
-
-#define A_MAC_PORT_TX_LINKA_TRANSMIT_DCC_OVERRIDE 0x3090
-
-#define S_DCCOUT 12
-#define V_DCCOUT(x) ((x) << S_DCCOUT)
-#define F_DCCOUT V_DCCOUT(1U)
-
-#define S_DCCCLK 11
-#define V_DCCCLK(x) ((x) << S_DCCCLK)
-#define F_DCCCLK V_DCCCLK(1U)
-
-#define S_DCCHOLD 10
-#define V_DCCHOLD(x) ((x) << S_DCCHOLD)
-#define F_DCCHOLD V_DCCHOLD(1U)
-
-#define S_DCCSIGN 8
-#define M_DCCSIGN 0x3U
-#define V_DCCSIGN(x) ((x) << S_DCCSIGN)
-#define G_DCCSIGN(x) (((x) >> S_DCCSIGN) & M_DCCSIGN)
-
-#define S_DCCAMP 1
-#define M_DCCAMP 0x7fU
-#define V_DCCAMP(x) ((x) << S_DCCAMP)
-#define G_DCCAMP(x) (((x) >> S_DCCAMP) & M_DCCAMP)
-
-#define S_DCCOEN 0
-#define V_DCCOEN(x) ((x) << S_DCCOEN)
-#define F_DCCOEN V_DCCOEN(1U)
-
-#define A_MAC_PORT_TX_LINKA_TRANSMIT_DCC_APPLIED 0x3094
-
-#define S_DCCASIGN 7
-#define M_DCCASIGN 0x3U
-#define V_DCCASIGN(x) ((x) << S_DCCASIGN)
-#define G_DCCASIGN(x) (((x) >> S_DCCASIGN) & M_DCCASIGN)
-
-#define S_DCCAAMP 0
-#define M_DCCAAMP 0x7fU
-#define V_DCCAAMP(x) ((x) << S_DCCAAMP)
-#define G_DCCAAMP(x) (((x) >> S_DCCAAMP) & M_DCCAAMP)
-
-#define A_MAC_PORT_TX_LINKA_TRANSMIT_DCC_TIME_OUT 0x3098
-
-#define S_DCCTIMEOUTVAL 0
-#define M_DCCTIMEOUTVAL 0xffffU
-#define V_DCCTIMEOUTVAL(x) ((x) << S_DCCTIMEOUTVAL)
-#define G_DCCTIMEOUTVAL(x) (((x) >> S_DCCTIMEOUTVAL) & M_DCCTIMEOUTVAL)
-
-#define A_MAC_PORT_TX_LINKA_TRANSMIT_802_3AZ_CONTROL 0x309c
-
-#define S_LPIDCLK 4
-#define V_LPIDCLK(x) ((x) << S_LPIDCLK)
-#define F_LPIDCLK V_LPIDCLK(1U)
-
-#define S_LPITERM 2
-#define M_LPITERM 0x3U
-#define V_LPITERM(x) ((x) << S_LPITERM)
-#define G_LPITERM(x) (((x) >> S_LPITERM) & M_LPITERM)
-
-#define S_LPIPRCD 0
-#define M_LPIPRCD 0x3U
-#define V_LPIPRCD(x) ((x) << S_LPIPRCD)
-#define G_LPIPRCD(x) (((x) >> S_LPIPRCD) & M_LPIPRCD)
-
-#define A_T6_MAC_PORT_TX_LINKA_TRANSMIT_DCC_CONTROL 0x30a0
-
-#define S_T6_DCCTIMEEN 13
-#define M_T6_DCCTIMEEN 0x3U
-#define V_T6_DCCTIMEEN(x) ((x) << S_T6_DCCTIMEEN)
-#define G_T6_DCCTIMEEN(x) (((x) >> S_T6_DCCTIMEEN) & M_T6_DCCTIMEEN)
-
-#define S_T6_DCCLOCK 11
-#define M_T6_DCCLOCK 0x3U
-#define V_T6_DCCLOCK(x) ((x) << S_T6_DCCLOCK)
-#define G_T6_DCCLOCK(x) (((x) >> S_T6_DCCLOCK) & M_T6_DCCLOCK)
-
-#define S_T6_DCCOFFSET 8
-#define M_T6_DCCOFFSET 0x7U
-#define V_T6_DCCOFFSET(x) ((x) << S_T6_DCCOFFSET)
-#define G_T6_DCCOFFSET(x) (((x) >> S_T6_DCCOFFSET) & M_T6_DCCOFFSET)
-
-#define S_TX_LINKA_DCCSTEP_CTL 6
-#define M_TX_LINKA_DCCSTEP_CTL 0x3U
-#define V_TX_LINKA_DCCSTEP_CTL(x) ((x) << S_TX_LINKA_DCCSTEP_CTL)
-#define G_TX_LINKA_DCCSTEP_CTL(x) (((x) >> S_TX_LINKA_DCCSTEP_CTL) & M_TX_LINKA_DCCSTEP_CTL)
-
-#define A_T6_MAC_PORT_TX_LINKA_TRANSMIT_DCC_OVERRIDE 0x30a4
-#define A_T6_MAC_PORT_TX_LINKA_TRANSMIT_DCC_APPLIED 0x30a8
-#define A_T6_MAC_PORT_TX_LINKA_TRANSMIT_DCC_TIME_OUT 0x30ac
-#define A_MAC_PORT_TX_LINKA_TRANSMIT_TAP_SIGN_OVERRIDE 0x30c0
-
-#define S_OSIGN 0
-#define M_OSIGN 0xfU
-#define V_OSIGN(x) ((x) << S_OSIGN)
-#define G_OSIGN(x) (((x) >> S_OSIGN) & M_OSIGN)
-
-#define A_MAC_PORT_TX_LINKA_TRANSMIT_SEGMENT_4X_OVERRIDE 0x30c8
-
-#define S_OS4X7 14
-#define M_OS4X7 0x3U
-#define V_OS4X7(x) ((x) << S_OS4X7)
-#define G_OS4X7(x) (((x) >> S_OS4X7) & M_OS4X7)
-
-#define S_OS4X6 12
-#define M_OS4X6 0x3U
-#define V_OS4X6(x) ((x) << S_OS4X6)
-#define G_OS4X6(x) (((x) >> S_OS4X6) & M_OS4X6)
-
-#define S_OS4X5 10
-#define M_OS4X5 0x3U
-#define V_OS4X5(x) ((x) << S_OS4X5)
-#define G_OS4X5(x) (((x) >> S_OS4X5) & M_OS4X5)
-
-#define S_OS4X4 8
-#define M_OS4X4 0x3U
-#define V_OS4X4(x) ((x) << S_OS4X4)
-#define G_OS4X4(x) (((x) >> S_OS4X4) & M_OS4X4)
-
-#define S_OS4X3 6
-#define M_OS4X3 0x3U
-#define V_OS4X3(x) ((x) << S_OS4X3)
-#define G_OS4X3(x) (((x) >> S_OS4X3) & M_OS4X3)
-
-#define S_OS4X2 4
-#define M_OS4X2 0x3U
-#define V_OS4X2(x) ((x) << S_OS4X2)
-#define G_OS4X2(x) (((x) >> S_OS4X2) & M_OS4X2)
-
-#define S_OS4X1 2
-#define M_OS4X1 0x3U
-#define V_OS4X1(x) ((x) << S_OS4X1)
-#define G_OS4X1(x) (((x) >> S_OS4X1) & M_OS4X1)
-
-#define S_OS4X0 0
-#define M_OS4X0 0x3U
-#define V_OS4X0(x) ((x) << S_OS4X0)
-#define G_OS4X0(x) (((x) >> S_OS4X0) & M_OS4X0)
-
-#define A_MAC_PORT_TX_LINKA_TRANSMIT_SEGMENT_2X_OVERRIDE 0x30cc
-
-#define S_OS2X3 6
-#define M_OS2X3 0x3U
-#define V_OS2X3(x) ((x) << S_OS2X3)
-#define G_OS2X3(x) (((x) >> S_OS2X3) & M_OS2X3)
-
-#define S_OS2X2 4
-#define M_OS2X2 0x3U
-#define V_OS2X2(x) ((x) << S_OS2X2)
-#define G_OS2X2(x) (((x) >> S_OS2X2) & M_OS2X2)
-
-#define S_OS2X1 2
-#define M_OS2X1 0x3U
-#define V_OS2X1(x) ((x) << S_OS2X1)
-#define G_OS2X1(x) (((x) >> S_OS2X1) & M_OS2X1)
-
-#define S_OS2X0 0
-#define M_OS2X0 0x3U
-#define V_OS2X0(x) ((x) << S_OS2X0)
-#define G_OS2X0(x) (((x) >> S_OS2X0) & M_OS2X0)
-
-#define A_MAC_PORT_TX_LINKA_TRANSMIT_SEGMENT_1X_OVERRIDE 0x30d0
-
-#define S_OS1X7 14
-#define M_OS1X7 0x3U
-#define V_OS1X7(x) ((x) << S_OS1X7)
-#define G_OS1X7(x) (((x) >> S_OS1X7) & M_OS1X7)
-
-#define S_OS1X6 12
-#define M_OS1X6 0x3U
-#define V_OS1X6(x) ((x) << S_OS1X6)
-#define G_OS1X6(x) (((x) >> S_OS1X6) & M_OS1X6)
-
-#define S_OS1X5 10
-#define M_OS1X5 0x3U
-#define V_OS1X5(x) ((x) << S_OS1X5)
-#define G_OS1X5(x) (((x) >> S_OS1X5) & M_OS1X5)
-
-#define S_OS1X4 8
-#define M_OS1X4 0x3U
-#define V_OS1X4(x) ((x) << S_OS1X4)
-#define G_OS1X4(x) (((x) >> S_OS1X4) & M_OS1X4)
-
-#define S_OS1X3 6
-#define M_OS1X3 0x3U
-#define V_OS1X3(x) ((x) << S_OS1X3)
-#define G_OS1X3(x) (((x) >> S_OS1X3) & M_OS1X3)
-
-#define S_OS1X2 4
-#define M_OS1X2 0x3U
-#define V_OS1X2(x) ((x) << S_OS1X2)
-#define G_OS1X2(x) (((x) >> S_OS1X2) & M_OS1X2)
-
-#define S_OS1X1 2
-#define M_OS1X1 0x3U
-#define V_OS1X1(x) ((x) << S_OS1X1)
-#define G_OS1X1(x) (((x) >> S_OS1X1) & M_OS1X1)
-
-#define S_OS1X0 0
-#define M_OS1X0 0x3U
-#define V_OS1X0(x) ((x) << S_OS1X0)
-#define G_OS1X0(x) (((x) >> S_OS1X0) & M_OS1X0)
-
-#define A_MAC_PORT_TX_LINKA_TRANSMIT_TAP_SEGMENT_4X_TERMINATION_OVERRIDE 0x30d8
-
-#define S_OT4X 0
-#define M_OT4X 0xffU
-#define V_OT4X(x) ((x) << S_OT4X)
-#define G_OT4X(x) (((x) >> S_OT4X) & M_OT4X)
-
-#define A_MAC_PORT_TX_LINKA_TRANSMIT_TAP_SEGMENT_2X_TERMINATION_OVERRIDE 0x30dc
-
-#define S_OT2X 0
-#define M_OT2X 0xfU
-#define V_OT2X(x) ((x) << S_OT2X)
-#define G_OT2X(x) (((x) >> S_OT2X) & M_OT2X)
-
-#define A_MAC_PORT_TX_LINKA_TRANSMIT_TAP_SEGMENT_1X_TERMINATION_OVERRIDE 0x30e0
-
-#define S_OT1X 0
-#define M_OT1X 0xffU
-#define V_OT1X(x) ((x) << S_OT1X)
-#define G_OT1X(x) (((x) >> S_OT1X) & M_OT1X)
-
-#define A_MAC_PORT_TX_LINKA_TRANSMIT_MACRO_TEST_CONTROL_5 0x30ec
-
-#define S_ERRORP 15
-#define V_ERRORP(x) ((x) << S_ERRORP)
-#define F_ERRORP V_ERRORP(1U)
-
-#define S_ERRORN 14
-#define V_ERRORN(x) ((x) << S_ERRORN)
-#define F_ERRORN V_ERRORN(1U)
-
-#define S_TESTENA 13
-#define V_TESTENA(x) ((x) << S_TESTENA)
-#define F_TESTENA V_TESTENA(1U)
-
-#define S_TUNEBIT 10
-#define M_TUNEBIT 0x7U
-#define V_TUNEBIT(x) ((x) << S_TUNEBIT)
-#define G_TUNEBIT(x) (((x) >> S_TUNEBIT) & M_TUNEBIT)
-
-#define S_DATAPOS 8
-#define M_DATAPOS 0x3U
-#define V_DATAPOS(x) ((x) << S_DATAPOS)
-#define G_DATAPOS(x) (((x) >> S_DATAPOS) & M_DATAPOS)
-
-#define S_SEGSEL 3
-#define M_SEGSEL 0x1fU
-#define V_SEGSEL(x) ((x) << S_SEGSEL)
-#define G_SEGSEL(x) (((x) >> S_SEGSEL) & M_SEGSEL)
-
-#define S_TAPSEL 1
-#define M_TAPSEL 0x3U
-#define V_TAPSEL(x) ((x) << S_TAPSEL)
-#define G_TAPSEL(x) (((x) >> S_TAPSEL) & M_TAPSEL)
-
-#define S_DATASIGN 0
-#define V_DATASIGN(x) ((x) << S_DATASIGN)
-#define F_DATASIGN V_DATASIGN(1U)
-
-#define A_MAC_PORT_TX_LINKA_TRANSMIT_MACRO_TEST_CONTROL_4 0x30f0
-
-#define S_SDOVRDEN 8
-#define V_SDOVRDEN(x) ((x) << S_SDOVRDEN)
-#define F_SDOVRDEN V_SDOVRDEN(1U)
-
-#define S_SDOVRD 0
-#define M_SDOVRD 0xffU
-#define V_SDOVRD(x) ((x) << S_SDOVRD)
-#define G_SDOVRD(x) (((x) >> S_SDOVRD) & M_SDOVRD)
-
-#define S_T6_SDOVRD 0
-#define M_T6_SDOVRD 0xffffU
-#define V_T6_SDOVRD(x) ((x) << S_T6_SDOVRD)
-#define G_T6_SDOVRD(x) (((x) >> S_T6_SDOVRD) & M_T6_SDOVRD)
-
-#define A_MAC_PORT_TX_LINKA_TRANSMIT_MACRO_TEST_CONTROL_3 0x30f4
-
-#define S_SLEWCODE 1
-#define M_SLEWCODE 0x3U
-#define V_SLEWCODE(x) ((x) << S_SLEWCODE)
-#define G_SLEWCODE(x) (((x) >> S_SLEWCODE) & M_SLEWCODE)
-
-#define S_ASEGEN 0
-#define V_ASEGEN(x) ((x) << S_ASEGEN)
-#define F_ASEGEN V_ASEGEN(1U)
-
-#define S_WCNT 0
-#define M_WCNT 0x3ffU
-#define V_WCNT(x) ((x) << S_WCNT)
-#define G_WCNT(x) (((x) >> S_WCNT) & M_WCNT)
-
-#define A_MAC_PORT_TX_LINKA_TRANSMIT_MACRO_TEST_CONTROL_2 0x30f8
-
-#define S_AECMDVAL 14
-#define V_AECMDVAL(x) ((x) << S_AECMDVAL)
-#define F_AECMDVAL V_AECMDVAL(1U)
-
-#define S_AECMD1312 12
-#define M_AECMD1312 0x3U
-#define V_AECMD1312(x) ((x) << S_AECMD1312)
-#define G_AECMD1312(x) (((x) >> S_AECMD1312) & M_AECMD1312)
-
-#define S_AECMD70 0
-#define M_AECMD70 0xffU
-#define V_AECMD70(x) ((x) << S_AECMD70)
-#define G_AECMD70(x) (((x) >> S_AECMD70) & M_AECMD70)
-
-#define A_MAC_PORT_TX_LINKA_TRANSMIT_MACRO_TEST_CONTROL_1 0x30fc
-
-#define S_C48DIVCTL 12
-#define M_C48DIVCTL 0x7U
-#define V_C48DIVCTL(x) ((x) << S_C48DIVCTL)
-#define G_C48DIVCTL(x) (((x) >> S_C48DIVCTL) & M_C48DIVCTL)
-
-#define S_RATEDIVCTL 9
-#define M_RATEDIVCTL 0x7U
-#define V_RATEDIVCTL(x) ((x) << S_RATEDIVCTL)
-#define G_RATEDIVCTL(x) (((x) >> S_RATEDIVCTL) & M_RATEDIVCTL)
-
-#define S_ANLGFLSH 8
-#define V_ANLGFLSH(x) ((x) << S_ANLGFLSH)
-#define F_ANLGFLSH V_ANLGFLSH(1U)
-
-#define S_DCCTSTOUT 7
-#define V_DCCTSTOUT(x) ((x) << S_DCCTSTOUT)
-#define F_DCCTSTOUT V_DCCTSTOUT(1U)
-
-#define S_BSOUT 6
-#define V_BSOUT(x) ((x) << S_BSOUT)
-#define F_BSOUT V_BSOUT(1U)
-
-#define S_BSIN 5
-#define V_BSIN(x) ((x) << S_BSIN)
-#define F_BSIN V_BSIN(1U)
-
-#define S_JTAGAMPL 3
-#define M_JTAGAMPL 0x3U
-#define V_JTAGAMPL(x) ((x) << S_JTAGAMPL)
-#define G_JTAGAMPL(x) (((x) >> S_JTAGAMPL) & M_JTAGAMPL)
-
-#define S_JTAGTS 2
-#define V_JTAGTS(x) ((x) << S_JTAGTS)
-#define F_JTAGTS V_JTAGTS(1U)
-
-#define S_TS 1
-#define V_TS(x) ((x) << S_TS)
-#define F_TS V_TS(1U)
-
-#define S_OBS 0
-#define V_OBS(x) ((x) << S_OBS)
-#define F_OBS V_OBS(1U)
-
-#define S_T6_SDOVRDEN 15
-#define V_T6_SDOVRDEN(x) ((x) << S_T6_SDOVRDEN)
-#define F_T6_SDOVRDEN V_T6_SDOVRDEN(1U)
-
-#define S_BSOUTN 7
-#define V_BSOUTN(x) ((x) << S_BSOUTN)
-#define F_BSOUTN V_BSOUTN(1U)
-
-#define S_BSOUTP 6
-#define V_BSOUTP(x) ((x) << S_BSOUTP)
-#define F_BSOUTP V_BSOUTP(1U)
-
-#define A_MAC_PORT_TX_LINKB_TRANSMIT_CONFIGURATION_MODE 0x3100
-
-#define S_T6_T5_TX_RXLOOP 5
-#define V_T6_T5_TX_RXLOOP(x) ((x) << S_T6_T5_TX_RXLOOP)
-#define F_T6_T5_TX_RXLOOP V_T6_T5_TX_RXLOOP(1U)
-
-#define S_T6_T5_TX_BWSEL 2
-#define M_T6_T5_TX_BWSEL 0x3U
-#define V_T6_T5_TX_BWSEL(x) ((x) << S_T6_T5_TX_BWSEL)
-#define G_T6_T5_TX_BWSEL(x) (((x) >> S_T6_T5_TX_BWSEL) & M_T6_T5_TX_BWSEL)
-
-#define A_MAC_PORT_TX_LINKB_TRANSMIT_TEST_CONTROL 0x3104
-
-#define S_T6_ERROR 9
-#define V_T6_ERROR(x) ((x) << S_T6_ERROR)
-#define F_T6_ERROR V_T6_ERROR(1U)
-
-#define A_MAC_PORT_TX_LINKB_TRANSMIT_COEFFICIENT_CONTROL 0x3108
-#define A_MAC_PORT_TX_LINKB_TRANSMIT_DRIVER_MODE_CONTROL 0x310c
-#define A_MAC_PORT_TX_LINKB_TRANSMIT_DRIVER_OVERRIDE_CONTROL 0x3110
-#define A_MAC_PORT_TX_LINKB_TRANSMIT_DCLK_ROTATOR_OVERRIDE 0x3114
-#define A_MAC_PORT_TX_LINKB_TRANSMIT_IMPEDANCE_CALIBRATION_OVERRIDE 0x3118
-
-#define S_T6_CALSSTN 8
-#define M_T6_CALSSTN 0x3fU
-#define V_T6_CALSSTN(x) ((x) << S_T6_CALSSTN)
-#define G_T6_CALSSTN(x) (((x) >> S_T6_CALSSTN) & M_T6_CALSSTN)
-
-#define S_T6_CALSSTP 0
-#define M_T6_CALSSTP 0x3fU
-#define V_T6_CALSSTP(x) ((x) << S_T6_CALSSTP)
-#define G_T6_CALSSTP(x) (((x) >> S_T6_CALSSTP) & M_T6_CALSSTP)
-
-#define A_MAC_PORT_TX_LINKB_TRANSMIT_DCLK_DRIFT_TOLERANCE 0x311c
-
-#define S_T6_DRTOL 2
-#define M_T6_DRTOL 0x7U
-#define V_T6_DRTOL(x) ((x) << S_T6_DRTOL)
-#define G_T6_DRTOL(x) (((x) >> S_T6_DRTOL) & M_T6_DRTOL)
-
-#define A_MAC_PORT_TX_LINKB_TRANSMIT_TAP_0_COEFFICIENT 0x3120
-
-#define S_T6_NXTT0 0
-#define M_T6_NXTT0 0x3fU
-#define V_T6_NXTT0(x) ((x) << S_T6_NXTT0)
-#define G_T6_NXTT0(x) (((x) >> S_T6_NXTT0) & M_T6_NXTT0)
-
-#define A_MAC_PORT_TX_LINKB_TRANSMIT_TAP_1_COEFFICIENT 0x3124
-#define A_MAC_PORT_TX_LINKB_TRANSMIT_TAP_2_COEFFICIENT 0x3128
-
-#define S_T6_NXTT2 0
-#define M_T6_NXTT2 0x3fU
-#define V_T6_NXTT2(x) ((x) << S_T6_NXTT2)
-#define G_T6_NXTT2(x) (((x) >> S_T6_NXTT2) & M_T6_NXTT2)
-
-#define A_MAC_PORT_TX_LINKB_TRANSMIT_TAP_3_COEFFICIENT 0x312c
-#define A_MAC_PORT_TX_LINKB_TRANSMIT_AMPLITUDE 0x3130
-#define A_MAC_PORT_TX_LINKB_TRANSMIT_POLARITY 0x3134
-
-#define S_T6_NXTPOL 0
-#define M_T6_NXTPOL 0xfU
-#define V_T6_NXTPOL(x) ((x) << S_T6_NXTPOL)
-#define G_T6_NXTPOL(x) (((x) >> S_T6_NXTPOL) & M_T6_NXTPOL)
-
-#define A_MAC_PORT_TX_LINKB_TRANSMIT_802_3AP_ADAPTIVE_EQUALIZATION_COMMAND 0x3138
-
-#define S_T6_C0UPDT 6
-#define M_T6_C0UPDT 0x3U
-#define V_T6_C0UPDT(x) ((x) << S_T6_C0UPDT)
-#define G_T6_C0UPDT(x) (((x) >> S_T6_C0UPDT) & M_T6_C0UPDT)
-
-#define S_T6_C2UPDT 2
-#define M_T6_C2UPDT 0x3U
-#define V_T6_C2UPDT(x) ((x) << S_T6_C2UPDT)
-#define G_T6_C2UPDT(x) (((x) >> S_T6_C2UPDT) & M_T6_C2UPDT)
-
-#define S_T6_C1UPDT 0
-#define M_T6_C1UPDT 0x3U
-#define V_T6_C1UPDT(x) ((x) << S_T6_C1UPDT)
-#define G_T6_C1UPDT(x) (((x) >> S_T6_C1UPDT) & M_T6_C1UPDT)
-
-#define A_MAC_PORT_TX_LINKB_TRANSMIT_802_3AP_ADAPTIVE_EQUALIZATION_STATUS 0x313c
-
-#define S_T6_C0STAT 6
-#define M_T6_C0STAT 0x3U
-#define V_T6_C0STAT(x) ((x) << S_T6_C0STAT)
-#define G_T6_C0STAT(x) (((x) >> S_T6_C0STAT) & M_T6_C0STAT)
-
-#define S_T6_C2STAT 2
-#define M_T6_C2STAT 0x3U
-#define V_T6_C2STAT(x) ((x) << S_T6_C2STAT)
-#define G_T6_C2STAT(x) (((x) >> S_T6_C2STAT) & M_T6_C2STAT)
-
-#define S_T6_C1STAT 0
-#define M_T6_C1STAT 0x3U
-#define V_T6_C1STAT(x) ((x) << S_T6_C1STAT)
-#define G_T6_C1STAT(x) (((x) >> S_T6_C1STAT) & M_T6_C1STAT)
-
-#define A_MAC_PORT_TX_LINKB_TRANSMIT_TAP_0_COEFFICIENT_OVERRIDE 0x3140
-#define A_MAC_PORT_TX_LINKB_TRANSMIT_AE_TAP_0_COEFFICIENT_OVERRIDE 0x3140
-#define A_MAC_PORT_TX_LINKB_TRANSMIT_TAP_1_COEFFICIENT_OVERRIDE 0x3144
-#define A_MAC_PORT_TX_LINKB_TRANSMIT_AE_TAP_1_COEFFICIENT_OVERRIDE 0x3144
-#define A_MAC_PORT_TX_LINKB_TRANSMIT_TAP_2_COEFFICIENT_OVERRIDE 0x3148
-#define A_MAC_PORT_TX_LINKB_TRANSMIT_AE_TAP_2_COEFFICIENT_OVERRIDE 0x3148
-#define A_MAC_PORT_TX_LINKB_TRANSMIT_AE_TAP_3_COEFFICIENT_OVERRIDE 0x314c
-#define A_MAC_PORT_TX_LINKB_TRANSMIT_APPLIED_TUNE_REGISTER 0x3150
-#define A_MAC_PORT_TX_LINKB_TRANSMIT_ANALOG_DIAGNOSTICS_REGISTER 0x3158
-#define A_MAC_PORT_TX_LINKB_TRANSMIT_TAP_0_COEFFICIENT_APPLIED 0x3160
-#define A_MAC_PORT_TX_LINKB_TRANSMIT_4X_SEGMENT_APPLIED 0x3160
-#define A_MAC_PORT_TX_LINKB_TRANSMIT_TAP_1_COEFFICIENT_APPLIED 0x3164
-#define A_MAC_PORT_TX_LINKB_TRANSMIT_2X_SEGMENT_APPLIED 0x3164
-#define A_MAC_PORT_TX_LINKB_TRANSMIT_TAP_2_COEFFICIENT_APPLIED 0x3168
-#define A_MAC_PORT_TX_LINKB_TRANSMIT_1X_SEGMENT_APPLIED 0x3168
-#define A_MAC_PORT_TX_LINKB_TRANSMIT_SEGMENT_4X_TERMINATION_APPLIED 0x316c
-#define A_MAC_PORT_TX_LINKB_TRANSMIT_SEGMENT_DISABLE_APPLIED_1 0x3170
-#define A_MAC_PORT_TX_LINKB_TRANSMIT_SEGMENT_2X1X_TERMINATION_APPLIED 0x3170
-#define A_MAC_PORT_TX_LINKB_TRANSMIT_SEGMENT_DISABLE_APPLIED_2 0x3174
-#define A_MAC_PORT_TX_LINKB_TRANSMIT_TAP_SIGN_APPLIED_REGISTER 0x3174
-#define A_MAC_PORT_TX_LINKB_TRANSMIT_EXTENDED_ADDRESS_DATA 0x3178
-#define A_MAC_PORT_TX_LINKB_TRANSMIT_EXTENDED_ADDRESS_ADDR 0x317c
-
-#define S_T6_XADDR 1
-#define M_T6_XADDR 0x1fU
-#define V_T6_XADDR(x) ((x) << S_T6_XADDR)
-#define G_T6_XADDR(x) (((x) >> S_T6_XADDR) & M_T6_XADDR)
-
-#define A_MAC_PORT_TX_LINKB_TRANSMIT_PATTERN_BUFFER_BYTES_1_0 0x3180
-#define A_MAC_PORT_TX_LINKB_TRANSMIT_PATTERN_BUFFER_BYTES_3_2 0x3184
-#define A_MAC_PORT_TX_LINKB_TRANSMIT_PATTERN_BUFFER_BYTE_4 0x3188
-#define A_MAC_PORT_TX_LINKB_TRANSMIT_PATTERN_BUFFER_BYTES_5_4 0x3188
-#define A_MAC_PORT_TX_LINKB_TRANSMIT_DCC_CONTROL 0x318c
-#define A_MAC_PORT_TX_LINKB_TRANSMIT_PATTERN_BUFFER_BYTES_7_6 0x318c
-#define A_MAC_PORT_TX_LINKB_TRANSMIT_DCC_OVERRIDE 0x3190
-#define A_MAC_PORT_TX_LINKB_TRANSMIT_DCC_APPLIED 0x3194
-#define A_MAC_PORT_TX_LINKB_TRANSMIT_DCC_TIME_OUT 0x3198
-#define A_MAC_PORT_TX_LINKB_TRANSMIT_802_3AZ_CONTROL 0x319c
-#define A_T6_MAC_PORT_TX_LINKB_TRANSMIT_DCC_CONTROL 0x31a0
-
-#define S_T6_DCCTIMEEN 13
-#define M_T6_DCCTIMEEN 0x3U
-#define V_T6_DCCTIMEEN(x) ((x) << S_T6_DCCTIMEEN)
-#define G_T6_DCCTIMEEN(x) (((x) >> S_T6_DCCTIMEEN) & M_T6_DCCTIMEEN)
-
-#define S_T6_DCCLOCK 11
-#define M_T6_DCCLOCK 0x3U
-#define V_T6_DCCLOCK(x) ((x) << S_T6_DCCLOCK)
-#define G_T6_DCCLOCK(x) (((x) >> S_T6_DCCLOCK) & M_T6_DCCLOCK)
-
-#define S_T6_DCCOFFSET 8
-#define M_T6_DCCOFFSET 0x7U
-#define V_T6_DCCOFFSET(x) ((x) << S_T6_DCCOFFSET)
-#define G_T6_DCCOFFSET(x) (((x) >> S_T6_DCCOFFSET) & M_T6_DCCOFFSET)
-
-#define S_TX_LINKB_DCCSTEP_CTL 6
-#define M_TX_LINKB_DCCSTEP_CTL 0x3U
-#define V_TX_LINKB_DCCSTEP_CTL(x) ((x) << S_TX_LINKB_DCCSTEP_CTL)
-#define G_TX_LINKB_DCCSTEP_CTL(x) (((x) >> S_TX_LINKB_DCCSTEP_CTL) & M_TX_LINKB_DCCSTEP_CTL)
-
-#define A_T6_MAC_PORT_TX_LINKB_TRANSMIT_DCC_OVERRIDE 0x31a4
-#define A_T6_MAC_PORT_TX_LINKB_TRANSMIT_DCC_APPLIED 0x31a8
-#define A_T6_MAC_PORT_TX_LINKB_TRANSMIT_DCC_TIME_OUT 0x31ac
-#define A_MAC_PORT_TX_LINKB_TRANSMIT_TAP_SIGN_OVERRIDE 0x31c0
-#define A_MAC_PORT_TX_LINKB_TRANSMIT_SEGMENT_4X_OVERRIDE 0x31c8
-#define A_MAC_PORT_TX_LINKB_TRANSMIT_SEGMENT_2X_OVERRIDE 0x31cc
-#define A_MAC_PORT_TX_LINKB_TRANSMIT_SEGMENT_1X_OVERRIDE 0x31d0
-#define A_MAC_PORT_TX_LINKB_TRANSMIT_TAP_SEGMENT_4X_TERMINATION_OVERRIDE 0x31d8
-#define A_MAC_PORT_TX_LINKB_TRANSMIT_TAP_SEGMENT_2X_TERMINATION_OVERRIDE 0x31dc
-#define A_MAC_PORT_TX_LINKB_TRANSMIT_TAP_SEGMENT_1X_TERMINATION_OVERRIDE 0x31e0
-#define A_MAC_PORT_TX_LINKB_TRANSMIT_MACRO_TEST_CONTROL_5 0x31ec
-#define A_MAC_PORT_TX_LINKB_TRANSMIT_MACRO_TEST_CONTROL_4 0x31f0
-
-#define S_T6_SDOVRD 0
-#define M_T6_SDOVRD 0xffffU
-#define V_T6_SDOVRD(x) ((x) << S_T6_SDOVRD)
-#define G_T6_SDOVRD(x) (((x) >> S_T6_SDOVRD) & M_T6_SDOVRD)
-
-#define A_MAC_PORT_TX_LINKB_TRANSMIT_MACRO_TEST_CONTROL_3 0x31f4
-#define A_MAC_PORT_TX_LINKB_TRANSMIT_MACRO_TEST_CONTROL_2 0x31f8
-#define A_MAC_PORT_TX_LINKB_TRANSMIT_MACRO_TEST_CONTROL_1 0x31fc
-
-#define S_T6_SDOVRDEN 15
-#define V_T6_SDOVRDEN(x) ((x) << S_T6_SDOVRDEN)
-#define F_T6_SDOVRDEN V_T6_SDOVRDEN(1U)
-
-#define A_MAC_PORT_RX_LINKA_RECEIVER_CONFIGURATION_MODE 0x3200
-
-#define S_T5_RX_LINKEN 15
-#define V_T5_RX_LINKEN(x) ((x) << S_T5_RX_LINKEN)
-#define F_T5_RX_LINKEN V_T5_RX_LINKEN(1U)
-
-#define S_T5_RX_LINKRST 14
-#define V_T5_RX_LINKRST(x) ((x) << S_T5_RX_LINKRST)
-#define F_T5_RX_LINKRST V_T5_RX_LINKRST(1U)
-
-#define S_T5_RX_CFGWRT 13
-#define V_T5_RX_CFGWRT(x) ((x) << S_T5_RX_CFGWRT)
-#define F_T5_RX_CFGWRT V_T5_RX_CFGWRT(1U)
-
-#define S_T5_RX_CFGPTR 11
-#define M_T5_RX_CFGPTR 0x3U
-#define V_T5_RX_CFGPTR(x) ((x) << S_T5_RX_CFGPTR)
-#define G_T5_RX_CFGPTR(x) (((x) >> S_T5_RX_CFGPTR) & M_T5_RX_CFGPTR)
-
-#define S_T5_RX_CFGEXT 10
-#define V_T5_RX_CFGEXT(x) ((x) << S_T5_RX_CFGEXT)
-#define F_T5_RX_CFGEXT V_T5_RX_CFGEXT(1U)
-
-#define S_T5_RX_CFGACT 9
-#define V_T5_RX_CFGACT(x) ((x) << S_T5_RX_CFGACT)
-#define F_T5_RX_CFGACT V_T5_RX_CFGACT(1U)
-
-#define S_T5_RX_AUXCLK 8
-#define V_T5_RX_AUXCLK(x) ((x) << S_T5_RX_AUXCLK)
-#define F_T5_RX_AUXCLK V_T5_RX_AUXCLK(1U)
-
-#define S_T5_RX_PLLSEL 6
-#define M_T5_RX_PLLSEL 0x3U
-#define V_T5_RX_PLLSEL(x) ((x) << S_T5_RX_PLLSEL)
-#define G_T5_RX_PLLSEL(x) (((x) >> S_T5_RX_PLLSEL) & M_T5_RX_PLLSEL)
-
-#define S_T5_RX_DMSEL 4
-#define M_T5_RX_DMSEL 0x3U
-#define V_T5_RX_DMSEL(x) ((x) << S_T5_RX_DMSEL)
-#define G_T5_RX_DMSEL(x) (((x) >> S_T5_RX_DMSEL) & M_T5_RX_DMSEL)
-
-#define S_T5_RX_BWSEL 2
-#define M_T5_RX_BWSEL 0x3U
-#define V_T5_RX_BWSEL(x) ((x) << S_T5_RX_BWSEL)
-#define G_T5_RX_BWSEL(x) (((x) >> S_T5_RX_BWSEL) & M_T5_RX_BWSEL)
-
-#define S_T5_RX_RTSEL 0
-#define M_T5_RX_RTSEL 0x3U
-#define V_T5_RX_RTSEL(x) ((x) << S_T5_RX_RTSEL)
-#define G_T5_RX_RTSEL(x) (((x) >> S_T5_RX_RTSEL) & M_T5_RX_RTSEL)
-
-#define S_T5_RX_MODE8023AZ 8
-#define V_T5_RX_MODE8023AZ(x) ((x) << S_T5_RX_MODE8023AZ)
-#define F_T5_RX_MODE8023AZ V_T5_RX_MODE8023AZ(1U)
-
-#define A_MAC_PORT_RX_LINKA_RECEIVER_TEST_CONTROL 0x3204
-
-#define S_FERRST 10
-#define V_FERRST(x) ((x) << S_FERRST)
-#define F_FERRST V_FERRST(1U)
-
-#define S_ERRST 9
-#define V_ERRST(x) ((x) << S_ERRST)
-#define F_ERRST V_ERRST(1U)
-
-#define S_SYNCST 8
-#define V_SYNCST(x) ((x) << S_SYNCST)
-#define F_SYNCST V_SYNCST(1U)
-
-#define S_WRPSM 7
-#define V_WRPSM(x) ((x) << S_WRPSM)
-#define F_WRPSM V_WRPSM(1U)
-
-#define S_WPLPEN 6
-#define V_WPLPEN(x) ((x) << S_WPLPEN)
-#define F_WPLPEN V_WPLPEN(1U)
-
-#define S_WRPMD 5
-#define V_WRPMD(x) ((x) << S_WRPMD)
-#define F_WRPMD V_WRPMD(1U)
-
-#define S_PATSEL 0
-#define M_PATSEL 0x7U
-#define V_PATSEL(x) ((x) << S_PATSEL)
-#define G_PATSEL(x) (((x) >> S_PATSEL) & M_PATSEL)
-
-#define S_APLYDCD 15
-#define V_APLYDCD(x) ((x) << S_APLYDCD)
-#define F_APLYDCD V_APLYDCD(1U)
-
-#define S_PPOL 13
-#define M_PPOL 0x3U
-#define V_PPOL(x) ((x) << S_PPOL)
-#define G_PPOL(x) (((x) >> S_PPOL) & M_PPOL)
-
-#define S_PCLKSEL 11
-#define M_PCLKSEL 0x3U
-#define V_PCLKSEL(x) ((x) << S_PCLKSEL)
-#define G_PCLKSEL(x) (((x) >> S_PCLKSEL) & M_PCLKSEL)
-
-#define A_MAC_PORT_RX_LINKA_PHASE_ROTATOR_CONTROL 0x3208
-
-#define S_RSTUCK 3
-#define V_RSTUCK(x) ((x) << S_RSTUCK)
-#define F_RSTUCK V_RSTUCK(1U)
-
-#define S_FRZFW 2
-#define V_FRZFW(x) ((x) << S_FRZFW)
-#define F_FRZFW V_FRZFW(1U)
-
-#define S_RSTFW 1
-#define V_RSTFW(x) ((x) << S_RSTFW)
-#define F_RSTFW V_RSTFW(1U)
-
-#define S_SSCEN 0
-#define V_SSCEN(x) ((x) << S_SSCEN)
-#define F_SSCEN V_SSCEN(1U)
-
-#define A_MAC_PORT_RX_LINKA_PHASE_ROTATOR_OFFSET_CONTROL 0x320c
-
-#define S_H1ANOFST 12
-#define M_H1ANOFST 0xfU
-#define V_H1ANOFST(x) ((x) << S_H1ANOFST)
-#define G_H1ANOFST(x) (((x) >> S_H1ANOFST) & M_H1ANOFST)
-
-#define S_T6_TMSCAL 8
-#define M_T6_TMSCAL 0x3U
-#define V_T6_TMSCAL(x) ((x) << S_T6_TMSCAL)
-#define G_T6_TMSCAL(x) (((x) >> S_T6_TMSCAL) & M_T6_TMSCAL)
-
-#define S_T6_APADJ 7
-#define V_T6_APADJ(x) ((x) << S_T6_APADJ)
-#define F_T6_APADJ V_T6_APADJ(1U)
-
-#define S_T6_RSEL 6
-#define V_T6_RSEL(x) ((x) << S_T6_RSEL)
-#define F_T6_RSEL V_T6_RSEL(1U)
-
-#define S_T6_PHOFFS 0
-#define M_T6_PHOFFS 0x3fU
-#define V_T6_PHOFFS(x) ((x) << S_T6_PHOFFS)
-#define G_T6_PHOFFS(x) (((x) >> S_T6_PHOFFS) & M_T6_PHOFFS)
-
-#define A_MAC_PORT_RX_LINKA_PHASE_ROTATOR_POSITION_1 0x3210
-
-#define S_ROT00 0
-#define M_ROT00 0x3fU
-#define V_ROT00(x) ((x) << S_ROT00)
-#define G_ROT00(x) (((x) >> S_ROT00) & M_ROT00)
-
-#define S_ROTA 8
-#define M_ROTA 0x3fU
-#define V_ROTA(x) ((x) << S_ROTA)
-#define G_ROTA(x) (((x) >> S_ROTA) & M_ROTA)
-
-#define S_ROTD 0
-#define M_ROTD 0x3fU
-#define V_ROTD(x) ((x) << S_ROTD)
-#define G_ROTD(x) (((x) >> S_ROTD) & M_ROTD)
-
-#define A_MAC_PORT_RX_LINKA_PHASE_ROTATOR_POSITION_2 0x3214
-
-#define S_FREQFW 8
-#define M_FREQFW 0xffU
-#define V_FREQFW(x) ((x) << S_FREQFW)
-#define G_FREQFW(x) (((x) >> S_FREQFW) & M_FREQFW)
-
-#define S_FWSNAP 7
-#define V_FWSNAP(x) ((x) << S_FWSNAP)
-#define F_FWSNAP V_FWSNAP(1U)
-
-#define S_ROTE 0
-#define M_ROTE 0x3fU
-#define V_ROTE(x) ((x) << S_ROTE)
-#define G_ROTE(x) (((x) >> S_ROTE) & M_ROTE)
-
-#define A_MAC_PORT_RX_LINKA_PHASE_ROTATOR_STATIC_PHASE_OFFSET_1 0x3218
-
-#define S_RAOFFF 8
-#define M_RAOFFF 0xfU
-#define V_RAOFFF(x) ((x) << S_RAOFFF)
-#define G_RAOFFF(x) (((x) >> S_RAOFFF) & M_RAOFFF)
-
-#define S_RAOFF 0
-#define M_RAOFF 0x1fU
-#define V_RAOFF(x) ((x) << S_RAOFF)
-#define G_RAOFF(x) (((x) >> S_RAOFF) & M_RAOFF)
-
-#define A_MAC_PORT_RX_LINKA_PHASE_ROTATOR_STATIC_PHASE_OFFSET_2 0x321c
-
-#define S_RBOOFF 10
-#define M_RBOOFF 0x1fU
-#define V_RBOOFF(x) ((x) << S_RBOOFF)
-#define G_RBOOFF(x) (((x) >> S_RBOOFF) & M_RBOOFF)
-
-#define S_RBEOFF 5
-#define M_RBEOFF 0x1fU
-#define V_RBEOFF(x) ((x) << S_RBEOFF)
-#define G_RBEOFF(x) (((x) >> S_RBEOFF) & M_RBEOFF)
-
-#define A_MAC_PORT_RX_LINKA_DFE_CONTROL 0x3220
-
-#define S_T6_SPIFMT 8
-#define M_T6_SPIFMT 0xfU
-#define V_T6_SPIFMT(x) ((x) << S_T6_SPIFMT)
-#define G_T6_SPIFMT(x) (((x) >> S_T6_SPIFMT) & M_T6_SPIFMT)
-
-#define A_MAC_PORT_RX_LINKA_DFE_SAMPLE_SNAPSHOT_1 0x3224
-
-#define S_T5BYTE1 8
-#define M_T5BYTE1 0xffU
-#define V_T5BYTE1(x) ((x) << S_T5BYTE1)
-#define G_T5BYTE1(x) (((x) >> S_T5BYTE1) & M_T5BYTE1)
-
-#define S_T5BYTE0 0
-#define M_T5BYTE0 0xffU
-#define V_T5BYTE0(x) ((x) << S_T5BYTE0)
-#define G_T5BYTE0(x) (((x) >> S_T5BYTE0) & M_T5BYTE0)
-
-#define A_MAC_PORT_RX_LINKA_DFE_SAMPLE_SNAPSHOT_2 0x3228
-
-#define S_T5_RX_SMODE 8
-#define M_T5_RX_SMODE 0x7U
-#define V_T5_RX_SMODE(x) ((x) << S_T5_RX_SMODE)
-#define G_T5_RX_SMODE(x) (((x) >> S_T5_RX_SMODE) & M_T5_RX_SMODE)
-
-#define S_T5_RX_ADCORR 7
-#define V_T5_RX_ADCORR(x) ((x) << S_T5_RX_ADCORR)
-#define F_T5_RX_ADCORR V_T5_RX_ADCORR(1U)
-
-#define S_T5_RX_TRAINEN 6
-#define V_T5_RX_TRAINEN(x) ((x) << S_T5_RX_TRAINEN)
-#define F_T5_RX_TRAINEN V_T5_RX_TRAINEN(1U)
-
-#define S_T5_RX_ASAMPQ 3
-#define M_T5_RX_ASAMPQ 0x7U
-#define V_T5_RX_ASAMPQ(x) ((x) << S_T5_RX_ASAMPQ)
-#define G_T5_RX_ASAMPQ(x) (((x) >> S_T5_RX_ASAMPQ) & M_T5_RX_ASAMPQ)
-
-#define S_T5_RX_ASAMP 0
-#define M_T5_RX_ASAMP 0x7U
-#define V_T5_RX_ASAMP(x) ((x) << S_T5_RX_ASAMP)
-#define G_T5_RX_ASAMP(x) (((x) >> S_T5_RX_ASAMP) & M_T5_RX_ASAMP)
-
-#define S_REQWOV 15
-#define V_REQWOV(x) ((x) << S_REQWOV)
-#define F_REQWOV V_REQWOV(1U)
-
-#define S_RASEL 11
-#define M_RASEL 0x7U
-#define V_RASEL(x) ((x) << S_RASEL)
-#define G_RASEL(x) (((x) >> S_RASEL) & M_RASEL)
-
-#define A_MAC_PORT_RX_LINKA_RECEIVER_VGA_CONTROL_1 0x322c
-
-#define S_T6_WRAPSEL 15
-#define V_T6_WRAPSEL(x) ((x) << S_T6_WRAPSEL)
-#define F_T6_WRAPSEL V_T6_WRAPSEL(1U)
-
-#define S_ACTL 14
-#define V_ACTL(x) ((x) << S_ACTL)
-#define F_ACTL V_ACTL(1U)
-
-#define S_T6_PEAK 9
-#define M_T6_PEAK 0x1fU
-#define V_T6_PEAK(x) ((x) << S_T6_PEAK)
-#define G_T6_PEAK(x) (((x) >> S_T6_PEAK) & M_T6_PEAK)
-
-#define A_MAC_PORT_RX_LINKA_RECEIVER_VGA_CONTROL_2 0x3230
-
-#define S_T5SHORTV 10
-#define V_T5SHORTV(x) ((x) << S_T5SHORTV)
-#define F_T5SHORTV V_T5SHORTV(1U)
-
-#define S_T5VGAIN 0
-#define M_T5VGAIN 0x1fU
-#define V_T5VGAIN(x) ((x) << S_T5VGAIN)
-#define G_T5VGAIN(x) (((x) >> S_T5VGAIN) & M_T5VGAIN)
-
-#define S_FVOFFSKP 15
-#define V_FVOFFSKP(x) ((x) << S_FVOFFSKP)
-#define F_FVOFFSKP V_FVOFFSKP(1U)
-
-#define S_FGAINCHK 14
-#define V_FGAINCHK(x) ((x) << S_FGAINCHK)
-#define F_FGAINCHK V_FGAINCHK(1U)
-
-#define S_FH1ACAL 13
-#define V_FH1ACAL(x) ((x) << S_FH1ACAL)
-#define F_FH1ACAL V_FH1ACAL(1U)
-
-#define S_FH1AFLTR 11
-#define M_FH1AFLTR 0x3U
-#define V_FH1AFLTR(x) ((x) << S_FH1AFLTR)
-#define G_FH1AFLTR(x) (((x) >> S_FH1AFLTR) & M_FH1AFLTR)
-
-#define S_WGAIN 8
-#define M_WGAIN 0x3U
-#define V_WGAIN(x) ((x) << S_WGAIN)
-#define G_WGAIN(x) (((x) >> S_WGAIN) & M_WGAIN)
-
-#define S_GAIN_STAT 7
-#define V_GAIN_STAT(x) ((x) << S_GAIN_STAT)
-#define F_GAIN_STAT V_GAIN_STAT(1U)
-
-#define S_T6_T5VGAIN 0
-#define M_T6_T5VGAIN 0x7fU
-#define V_T6_T5VGAIN(x) ((x) << S_T6_T5VGAIN)
-#define G_T6_T5VGAIN(x) (((x) >> S_T6_T5VGAIN) & M_T6_T5VGAIN)
-
-#define A_MAC_PORT_RX_LINKA_RECEIVER_VGA_CONTROL_3 0x3234
-#define A_MAC_PORT_RX_LINKA_RECEIVER_DQCC_CONTROL_1 0x3238
-
-#define S_IQSEP 10
-#define M_IQSEP 0x1fU
-#define V_IQSEP(x) ((x) << S_IQSEP)
-#define G_IQSEP(x) (((x) >> S_IQSEP) & M_IQSEP)
-
-#define S_DUTYQ 5
-#define M_DUTYQ 0x1fU
-#define V_DUTYQ(x) ((x) << S_DUTYQ)
-#define G_DUTYQ(x) (((x) >> S_DUTYQ) & M_DUTYQ)
-
-#define S_DUTYI 0
-#define M_DUTYI 0x1fU
-#define V_DUTYI(x) ((x) << S_DUTYI)
-#define G_DUTYI(x) (((x) >> S_DUTYI) & M_DUTYI)
-
-#define A_MAC_PORT_RX_LINKA_RECEIVER_POWER_MANAGEMENT_CONTROL 0x3238
-
-#define S_PMCFG 6
-#define M_PMCFG 0x3U
-#define V_PMCFG(x) ((x) << S_PMCFG)
-#define G_PMCFG(x) (((x) >> S_PMCFG) & M_PMCFG)
-
-#define S_PMOFFTIME 0
-#define M_PMOFFTIME 0x3fU
-#define V_PMOFFTIME(x) ((x) << S_PMOFFTIME)
-#define G_PMOFFTIME(x) (((x) >> S_PMOFFTIME) & M_PMOFFTIME)
-
-#define A_MAC_PORT_RX_LINKA_RECEIVER_IQAMP_CONTROL_1 0x323c
-
-#define S_SELI 9
-#define V_SELI(x) ((x) << S_SELI)
-#define F_SELI V_SELI(1U)
-
-#define S_SERVREF 5
-#define M_SERVREF 0x7U
-#define V_SERVREF(x) ((x) << S_SERVREF)
-#define G_SERVREF(x) (((x) >> S_SERVREF) & M_SERVREF)
-
-#define S_IQAMP 0
-#define M_IQAMP 0x1fU
-#define V_IQAMP(x) ((x) << S_IQAMP)
-#define G_IQAMP(x) (((x) >> S_IQAMP) & M_IQAMP)
-
-#define A_MAC_PORT_RX_LINKA_RECEIVER_DQCC_CONTROL_3 0x3240
-
-#define S_DTHR 8
-#define M_DTHR 0x3fU
-#define V_DTHR(x) ((x) << S_DTHR)
-#define G_DTHR(x) (((x) >> S_DTHR) & M_DTHR)
-
-#define S_SNUL 0
-#define M_SNUL 0x1fU
-#define V_SNUL(x) ((x) << S_SNUL)
-#define G_SNUL(x) (((x) >> S_SNUL) & M_SNUL)
-
-#define A_MAC_PORT_RX_LINKA_RECEIVER_IQAMP_CONTROL_2 0x3240
-#define A_MAC_PORT_RX_LINKA_RECEIVER_DACAP_AND_DACAN_SELECTION 0x3244
-
-#define S_SAVEADAC 8
-#define V_SAVEADAC(x) ((x) << S_SAVEADAC)
-#define F_SAVEADAC V_SAVEADAC(1U)
-
-#define S_LOAD2 7
-#define V_LOAD2(x) ((x) << S_LOAD2)
-#define F_LOAD2 V_LOAD2(1U)
-
-#define S_LOAD1 6
-#define V_LOAD1(x) ((x) << S_LOAD1)
-#define F_LOAD1 V_LOAD1(1U)
-
-#define S_WRTACC2 5
-#define V_WRTACC2(x) ((x) << S_WRTACC2)
-#define F_WRTACC2 V_WRTACC2(1U)
-
-#define S_WRTACC1 4
-#define V_WRTACC1(x) ((x) << S_WRTACC1)
-#define F_WRTACC1 V_WRTACC1(1U)
-
-#define S_SELAPAN 3
-#define V_SELAPAN(x) ((x) << S_SELAPAN)
-#define F_SELAPAN V_SELAPAN(1U)
-
-#define S_DASEL 0
-#define M_DASEL 0x7U
-#define V_DASEL(x) ((x) << S_DASEL)
-#define G_DASEL(x) (((x) >> S_DASEL) & M_DASEL)
-
-#define A_MAC_PORT_RX_LINKA_RECEIVER_DACAP_AND_DACAN 0x3248
-#define A_MAC_PORT_RX_LINKA_RECEIVER_DACA_MIN_AND_DACAZ 0x324c
-#define A_MAC_PORT_RX_LINKA_RECEIVER_DACA_MIN 0x324c
-#define A_MAC_PORT_RX_LINKA_RECEIVER_ADAC_CONTROL 0x3250
-
-#define S_ADSN_READWRITE 8
-#define V_ADSN_READWRITE(x) ((x) << S_ADSN_READWRITE)
-#define F_ADSN_READWRITE V_ADSN_READWRITE(1U)
-
-#define S_ADSN_READONLY 7
-#define V_ADSN_READONLY(x) ((x) << S_ADSN_READONLY)
-#define F_ADSN_READONLY V_ADSN_READONLY(1U)
-
-#define S_ADAC2 8
-#define M_ADAC2 0xffU
-#define V_ADAC2(x) ((x) << S_ADAC2)
-#define G_ADAC2(x) (((x) >> S_ADAC2) & M_ADAC2)
-
-#define S_ADAC1 0
-#define M_ADAC1 0xffU
-#define V_ADAC1(x) ((x) << S_ADAC1)
-#define G_ADAC1(x) (((x) >> S_ADAC1) & M_ADAC1)
-
-#define A_MAC_PORT_RX_LINKA_RECEIVER_AC_COUPLING_CONTROL 0x3254
-
-#define S_FACCPLDYN 13
-#define V_FACCPLDYN(x) ((x) << S_FACCPLDYN)
-#define F_FACCPLDYN V_FACCPLDYN(1U)
-
-#define S_ACCPLGAIN 10
-#define M_ACCPLGAIN 0x7U
-#define V_ACCPLGAIN(x) ((x) << S_ACCPLGAIN)
-#define G_ACCPLGAIN(x) (((x) >> S_ACCPLGAIN) & M_ACCPLGAIN)
-
-#define S_ACCPLREF 8
-#define M_ACCPLREF 0x3U
-#define V_ACCPLREF(x) ((x) << S_ACCPLREF)
-#define G_ACCPLREF(x) (((x) >> S_ACCPLREF) & M_ACCPLREF)
-
-#define S_ACCPLSTEP 6
-#define M_ACCPLSTEP 0x3U
-#define V_ACCPLSTEP(x) ((x) << S_ACCPLSTEP)
-#define G_ACCPLSTEP(x) (((x) >> S_ACCPLSTEP) & M_ACCPLSTEP)
-
-#define S_ACCPLASTEP 1
-#define M_ACCPLASTEP 0x1fU
-#define V_ACCPLASTEP(x) ((x) << S_ACCPLASTEP)
-#define G_ACCPLASTEP(x) (((x) >> S_ACCPLASTEP) & M_ACCPLASTEP)
-
-#define S_FACCPL 0
-#define V_FACCPL(x) ((x) << S_FACCPL)
-#define F_FACCPL V_FACCPL(1U)
-
-#define A_MAC_PORT_RX_LINKA_RECEIVER_AC_COUPLING_VALUE 0x3258
-
-#define S_ACCPLMEANS 15
-#define V_ACCPLMEANS(x) ((x) << S_ACCPLMEANS)
-#define F_ACCPLMEANS V_ACCPLMEANS(1U)
-
-#define S_CDROVREN 8
-#define V_CDROVREN(x) ((x) << S_CDROVREN)
-#define F_CDROVREN V_CDROVREN(1U)
-
-#define S_ACCPLBIAS 0
-#define M_ACCPLBIAS 0xffU
-#define V_ACCPLBIAS(x) ((x) << S_ACCPLBIAS)
-#define G_ACCPLBIAS(x) (((x) >> S_ACCPLBIAS) & M_ACCPLBIAS)
-
-#define A_MAC_PORT_RX_LINKA_DFE_H1_LOCAL_OFFSET_ODD2_EVN2 0x325c
-
-#define S_H1O2 8
-#define M_H1O2 0x3fU
-#define V_H1O2(x) ((x) << S_H1O2)
-#define G_H1O2(x) (((x) >> S_H1O2) & M_H1O2)
-
-#define S_H1E2 0
-#define M_H1E2 0x3fU
-#define V_H1E2(x) ((x) << S_H1E2)
-#define G_H1E2(x) (((x) >> S_H1E2) & M_H1E2)
-
-#define A_MAC_PORT_RX_LINKA_DFE_H1H2H3_LOCAL_OFFSET 0x325c
-
-#define S_H123CH 0
-#define M_H123CH 0x3fU
-#define V_H123CH(x) ((x) << S_H123CH)
-#define G_H123CH(x) (((x) >> S_H123CH) & M_H123CH)
-
-#define A_MAC_PORT_RX_LINKA_DFE_H1_LOCAL_OFFSET_ODD3_EVN3 0x3260
-
-#define S_H1O3 8
-#define M_H1O3 0x3fU
-#define V_H1O3(x) ((x) << S_H1O3)
-#define G_H1O3(x) (((x) >> S_H1O3) & M_H1O3)
-
-#define S_H1E3 0
-#define M_H1E3 0x3fU
-#define V_H1E3(x) ((x) << S_H1E3)
-#define G_H1E3(x) (((x) >> S_H1E3) & M_H1E3)
-
-#define A_MAC_PORT_RX_LINKA_DFE_H1H2H3_LOCAL_OFFSET_VALUE 0x3260
-
-#define S_H1OX 8
-#define M_H1OX 0x3fU
-#define V_H1OX(x) ((x) << S_H1OX)
-#define G_H1OX(x) (((x) >> S_H1OX) & M_H1OX)
-
-#define S_H1EX 0
-#define M_H1EX 0x3fU
-#define V_H1EX(x) ((x) << S_H1EX)
-#define G_H1EX(x) (((x) >> S_H1EX) & M_H1EX)
-
-#define A_MAC_PORT_RX_LINKA_DFE_H1_LOCAL_OFFSET_ODD4_EVN4 0x3264
-
-#define S_H1O4 8
-#define M_H1O4 0x3fU
-#define V_H1O4(x) ((x) << S_H1O4)
-#define G_H1O4(x) (((x) >> S_H1O4) & M_H1O4)
-
-#define S_H1E4 0
-#define M_H1E4 0x3fU
-#define V_H1E4(x) ((x) << S_H1E4)
-#define G_H1E4(x) (((x) >> S_H1E4) & M_H1E4)
-
-#define A_MAC_PORT_RX_LINKA_PEAKED_INTEGRATOR 0x3264
-
-#define S_PILOCK 10
-#define V_PILOCK(x) ((x) << S_PILOCK)
-#define F_PILOCK V_PILOCK(1U)
-
-#define S_UNPKPKA 2
-#define M_UNPKPKA 0x3fU
-#define V_UNPKPKA(x) ((x) << S_UNPKPKA)
-#define G_UNPKPKA(x) (((x) >> S_UNPKPKA) & M_UNPKPKA)
-
-#define S_UNPKVGA 0
-#define M_UNPKVGA 0x3U
-#define V_UNPKVGA(x) ((x) << S_UNPKVGA)
-#define G_UNPKVGA(x) (((x) >> S_UNPKVGA) & M_UNPKVGA)
-
-#define A_MAC_PORT_RX_LINKA_CDR_ANALOG_SWITCH 0x3268
-
-#define S_OVRAC 15
-#define V_OVRAC(x) ((x) << S_OVRAC)
-#define F_OVRAC V_OVRAC(1U)
-
-#define S_OVRPK 14
-#define V_OVRPK(x) ((x) << S_OVRPK)
-#define F_OVRPK V_OVRPK(1U)
-
-#define S_OVRTAILS 12
-#define M_OVRTAILS 0x3U
-#define V_OVRTAILS(x) ((x) << S_OVRTAILS)
-#define G_OVRTAILS(x) (((x) >> S_OVRTAILS) & M_OVRTAILS)
-
-#define S_OVRTAILV 9
-#define M_OVRTAILV 0x7U
-#define V_OVRTAILV(x) ((x) << S_OVRTAILV)
-#define G_OVRTAILV(x) (((x) >> S_OVRTAILV) & M_OVRTAILV)
-
-#define S_OVRCAP 8
-#define V_OVRCAP(x) ((x) << S_OVRCAP)
-#define F_OVRCAP V_OVRCAP(1U)
-
-#define S_OVRDCDPRE 7
-#define V_OVRDCDPRE(x) ((x) << S_OVRDCDPRE)
-#define F_OVRDCDPRE V_OVRDCDPRE(1U)
-
-#define S_OVRDCDPST 6
-#define V_OVRDCDPST(x) ((x) << S_OVRDCDPST)
-#define F_OVRDCDPST V_OVRDCDPST(1U)
-
-#define S_DCVSCTMODE 2
-#define V_DCVSCTMODE(x) ((x) << S_DCVSCTMODE)
-#define F_DCVSCTMODE V_DCVSCTMODE(1U)
-
-#define S_CDRANLGSW 0
-#define M_CDRANLGSW 0x3U
-#define V_CDRANLGSW(x) ((x) << S_CDRANLGSW)
-#define G_CDRANLGSW(x) (((x) >> S_CDRANLGSW) & M_CDRANLGSW)
-
-#define A_MAC_PORT_RX_LINKA_PEAKING_AMPLIFIER_INTIALIZATION_CONTROL 0x326c
-
-#define S_PFLAG 5
-#define M_PFLAG 0x3U
-#define V_PFLAG(x) ((x) << S_PFLAG)
-#define G_PFLAG(x) (((x) >> S_PFLAG) & M_PFLAG)
-
-#define A_MAC_PORT_RX_LINKA_DYNAMIC_AMPLITUDE_CENTERING_DAC_AND_DYNAMIC_PEAKING_CONTROL_DPC 0x3270
-
-#define S_DPCMD 14
-#define V_DPCMD(x) ((x) << S_DPCMD)
-#define F_DPCMD V_DPCMD(1U)
-
-#define S_DACCLIP 15
-#define V_DACCLIP(x) ((x) << S_DACCLIP)
-#define F_DACCLIP V_DACCLIP(1U)
-
-#define S_DPCFRZ 14
-#define V_DPCFRZ(x) ((x) << S_DPCFRZ)
-#define F_DPCFRZ V_DPCFRZ(1U)
-
-#define S_DPCLKNQ 11
-#define V_DPCLKNQ(x) ((x) << S_DPCLKNQ)
-#define F_DPCLKNQ V_DPCLKNQ(1U)
-
-#define S_DPCWDFE 10
-#define V_DPCWDFE(x) ((x) << S_DPCWDFE)
-#define F_DPCWDFE V_DPCWDFE(1U)
-
-#define S_DPCWPK 9
-#define V_DPCWPK(x) ((x) << S_DPCWPK)
-#define F_DPCWPK V_DPCWPK(1U)
-
-#define A_MAC_PORT_RX_LINKA_DYNAMIC_DATA_CENTERING_DDC 0x3274
-
-#define S_VIEWSCAN 4
-#define V_VIEWSCAN(x) ((x) << S_VIEWSCAN)
-#define F_VIEWSCAN V_VIEWSCAN(1U)
-
-#define S_T6_ODEC 0
-#define M_T6_ODEC 0xfU
-#define V_T6_ODEC(x) ((x) << S_T6_ODEC)
-#define G_T6_ODEC(x) (((x) >> S_T6_ODEC) & M_T6_ODEC)
-
-#define A_MAC_PORT_RX_LINKA_RECEIVER_INTERNAL_STATUS 0x3278
-
-#define S_T5BER6VAL 15
-#define V_T5BER6VAL(x) ((x) << S_T5BER6VAL)
-#define F_T5BER6VAL V_T5BER6VAL(1U)
-
-#define S_T5BER6 14
-#define V_T5BER6(x) ((x) << S_T5BER6)
-#define F_T5BER6 V_T5BER6(1U)
-
-#define S_T5BER3VAL 13
-#define V_T5BER3VAL(x) ((x) << S_T5BER3VAL)
-#define F_T5BER3VAL V_T5BER3VAL(1U)
-
-#define S_T5TOOFAST 12
-#define V_T5TOOFAST(x) ((x) << S_T5TOOFAST)
-#define F_T5TOOFAST V_T5TOOFAST(1U)
-
-#define S_T5DPCCMP 9
-#define V_T5DPCCMP(x) ((x) << S_T5DPCCMP)
-#define F_T5DPCCMP V_T5DPCCMP(1U)
-
-#define S_T5DACCMP 8
-#define V_T5DACCMP(x) ((x) << S_T5DACCMP)
-#define F_T5DACCMP V_T5DACCMP(1U)
-
-#define S_T5DDCCMP 7
-#define V_T5DDCCMP(x) ((x) << S_T5DDCCMP)
-#define F_T5DDCCMP V_T5DDCCMP(1U)
-
-#define S_T5AERRFLG 6
-#define V_T5AERRFLG(x) ((x) << S_T5AERRFLG)
-#define F_T5AERRFLG V_T5AERRFLG(1U)
-
-#define S_T5WERRFLG 5
-#define V_T5WERRFLG(x) ((x) << S_T5WERRFLG)
-#define F_T5WERRFLG V_T5WERRFLG(1U)
-
-#define S_T5TRCMP 4
-#define V_T5TRCMP(x) ((x) << S_T5TRCMP)
-#define F_T5TRCMP V_T5TRCMP(1U)
-
-#define S_T5VLCKF 3
-#define V_T5VLCKF(x) ((x) << S_T5VLCKF)
-#define F_T5VLCKF V_T5VLCKF(1U)
-
-#define S_T5ROCCMP 2
-#define V_T5ROCCMP(x) ((x) << S_T5ROCCMP)
-#define F_T5ROCCMP V_T5ROCCMP(1U)
-
-#define S_T5DQCCCMP 1
-#define V_T5DQCCCMP(x) ((x) << S_T5DQCCCMP)
-#define F_T5DQCCCMP V_T5DQCCCMP(1U)
-
-#define S_T5OCCMP 0
-#define V_T5OCCMP(x) ((x) << S_T5OCCMP)
-#define F_T5OCCMP V_T5OCCMP(1U)
-
-#define S_RX_LINKA_ACCCMP_RIS 11
-#define V_RX_LINKA_ACCCMP_RIS(x) ((x) << S_RX_LINKA_ACCCMP_RIS)
-#define F_RX_LINKA_ACCCMP_RIS V_RX_LINKA_ACCCMP_RIS(1U)
-
-#define S_DCCCMP 10
-#define V_DCCCMP(x) ((x) << S_DCCCMP)
-#define F_DCCCMP V_DCCCMP(1U)
-
-#define S_T5IQCMP 1
-#define V_T5IQCMP(x) ((x) << S_T5IQCMP)
-#define F_T5IQCMP V_T5IQCMP(1U)
-
-#define A_MAC_PORT_RX_LINKA_DFE_FUNCTION_CONTROL_1 0x327c
-
-#define S_FLOFF 1
-#define V_FLOFF(x) ((x) << S_FLOFF)
-#define F_FLOFF V_FLOFF(1U)
-
-#define A_MAC_PORT_RX_LINKA_DFE_FUNCTION_CONTROL_2 0x3280
-
-#define S_H25SPC 15
-#define V_H25SPC(x) ((x) << S_H25SPC)
-#define F_H25SPC V_H25SPC(1U)
-
-#define S_FTOOFAST 8
-#define V_FTOOFAST(x) ((x) << S_FTOOFAST)
-#define F_FTOOFAST V_FTOOFAST(1U)
-
-#define S_FINTTRIM 7
-#define V_FINTTRIM(x) ((x) << S_FINTTRIM)
-#define F_FINTTRIM V_FINTTRIM(1U)
-
-#define S_FDINV 6
-#define V_FDINV(x) ((x) << S_FDINV)
-#define F_FDINV V_FDINV(1U)
-
-#define S_FHGS 5
-#define V_FHGS(x) ((x) << S_FHGS)
-#define F_FHGS V_FHGS(1U)
-
-#define S_FH6H12 4
-#define V_FH6H12(x) ((x) << S_FH6H12)
-#define F_FH6H12 V_FH6H12(1U)
-
-#define S_FH1CAL 3
-#define V_FH1CAL(x) ((x) << S_FH1CAL)
-#define F_FH1CAL V_FH1CAL(1U)
-
-#define S_FINTCAL 2
-#define V_FINTCAL(x) ((x) << S_FINTCAL)
-#define F_FINTCAL V_FINTCAL(1U)
-
-#define S_FDCA 1
-#define V_FDCA(x) ((x) << S_FDCA)
-#define F_FDCA V_FDCA(1U)
-
-#define S_FDQCC 0
-#define V_FDQCC(x) ((x) << S_FDQCC)
-#define F_FDQCC V_FDQCC(1U)
-
-#define S_FDCCAL 14
-#define V_FDCCAL(x) ((x) << S_FDCCAL)
-#define F_FDCCAL V_FDCCAL(1U)
-
-#define S_FROTCAL 13
-#define V_FROTCAL(x) ((x) << S_FROTCAL)
-#define F_FROTCAL V_FROTCAL(1U)
-
-#define S_FIQAMP 12
-#define V_FIQAMP(x) ((x) << S_FIQAMP)
-#define F_FIQAMP V_FIQAMP(1U)
-
-#define S_FRPTCALF 11
-#define V_FRPTCALF(x) ((x) << S_FRPTCALF)
-#define F_FRPTCALF V_FRPTCALF(1U)
-
-#define S_FINTCALGS 10
-#define V_FINTCALGS(x) ((x) << S_FINTCALGS)
-#define F_FINTCALGS V_FINTCALGS(1U)
-
-#define S_FDCC 9
-#define V_FDCC(x) ((x) << S_FDCC)
-#define F_FDCC V_FDCC(1U)
-
-#define S_FDCD 7
-#define V_FDCD(x) ((x) << S_FDCD)
-#define F_FDCD V_FDCD(1U)
-
-#define S_FINTRCALDYN 1
-#define V_FINTRCALDYN(x) ((x) << S_FINTRCALDYN)
-#define F_FINTRCALDYN V_FINTRCALDYN(1U)
-
-#define S_FQCC 0
-#define V_FQCC(x) ((x) << S_FQCC)
-#define F_FQCC V_FQCC(1U)
-
-#define A_MAC_PORT_RX_LINKA_DFE_OFFSET_EVN1_EVN2 0x3284
-
-#define S_LOFE2S_READWRITE 16
-#define V_LOFE2S_READWRITE(x) ((x) << S_LOFE2S_READWRITE)
-#define F_LOFE2S_READWRITE V_LOFE2S_READWRITE(1U)
-
-#define S_LOFE2S_READONLY 14
-#define M_LOFE2S_READONLY 0x3U
-#define V_LOFE2S_READONLY(x) ((x) << S_LOFE2S_READONLY)
-#define G_LOFE2S_READONLY(x) (((x) >> S_LOFE2S_READONLY) & M_LOFE2S_READONLY)
-
-#define S_LOFE2 8
-#define M_LOFE2 0x3fU
-#define V_LOFE2(x) ((x) << S_LOFE2)
-#define G_LOFE2(x) (((x) >> S_LOFE2) & M_LOFE2)
-
-#define S_LOFE1S_READWRITE 7
-#define V_LOFE1S_READWRITE(x) ((x) << S_LOFE1S_READWRITE)
-#define F_LOFE1S_READWRITE V_LOFE1S_READWRITE(1U)
-
-#define S_LOFE1S_READONLY 6
-#define V_LOFE1S_READONLY(x) ((x) << S_LOFE1S_READONLY)
-#define F_LOFE1S_READONLY V_LOFE1S_READONLY(1U)
-
-#define S_LOFE1 0
-#define M_LOFE1 0x3fU
-#define V_LOFE1(x) ((x) << S_LOFE1)
-#define G_LOFE1(x) (((x) >> S_LOFE1) & M_LOFE1)
-
-#define A_MAC_PORT_RX_LINKA_DFE_OFFSET_CHANNEL 0x3284
-
-#define S_QCCIND 13
-#define V_QCCIND(x) ((x) << S_QCCIND)
-#define F_QCCIND V_QCCIND(1U)
-
-#define S_DCDIND 10
-#define M_DCDIND 0x7U
-#define V_DCDIND(x) ((x) << S_DCDIND)
-#define G_DCDIND(x) (((x) >> S_DCDIND) & M_DCDIND)
-
-#define S_DCCIND 8
-#define M_DCCIND 0x3U
-#define V_DCCIND(x) ((x) << S_DCCIND)
-#define G_DCCIND(x) (((x) >> S_DCCIND) & M_DCCIND)
-
-#define S_CFSEL 5
-#define V_CFSEL(x) ((x) << S_CFSEL)
-#define F_CFSEL V_CFSEL(1U)
-
-#define S_LOFCH 0
-#define M_LOFCH 0x1fU
-#define V_LOFCH(x) ((x) << S_LOFCH)
-#define G_LOFCH(x) (((x) >> S_LOFCH) & M_LOFCH)
-
-#define A_MAC_PORT_RX_LINKA_DFE_OFFSET_ODD1_ODD2 0x3288
-
-#define S_LOFO2S_READWRITE 15
-#define V_LOFO2S_READWRITE(x) ((x) << S_LOFO2S_READWRITE)
-#define F_LOFO2S_READWRITE V_LOFO2S_READWRITE(1U)
-
-#define S_LOFO2S_READONLY 14
-#define V_LOFO2S_READONLY(x) ((x) << S_LOFO2S_READONLY)
-#define F_LOFO2S_READONLY V_LOFO2S_READONLY(1U)
-
-#define S_LOFO2 8
-#define M_LOFO2 0x3fU
-#define V_LOFO2(x) ((x) << S_LOFO2)
-#define G_LOFO2(x) (((x) >> S_LOFO2) & M_LOFO2)
-
-#define S_LOFO1S_READWRITE 7
-#define V_LOFO1S_READWRITE(x) ((x) << S_LOFO1S_READWRITE)
-#define F_LOFO1S_READWRITE V_LOFO1S_READWRITE(1U)
-
-#define S_LOFO1S_READONLY 6
-#define V_LOFO1S_READONLY(x) ((x) << S_LOFO1S_READONLY)
-#define F_LOFO1S_READONLY V_LOFO1S_READONLY(1U)
-
-#define S_LOFO1 0
-#define M_LOFO1 0x3fU
-#define V_LOFO1(x) ((x) << S_LOFO1)
-#define G_LOFO1(x) (((x) >> S_LOFO1) & M_LOFO1)
-
-#define A_MAC_PORT_RX_LINKA_DFE_OFFSET_VALUE 0x3288
-
-#define S_LOFU 8
-#define M_LOFU 0x7fU
-#define V_LOFU(x) ((x) << S_LOFU)
-#define G_LOFU(x) (((x) >> S_LOFU) & M_LOFU)
-
-#define S_LOFL 0
-#define M_LOFL 0x7fU
-#define V_LOFL(x) ((x) << S_LOFL)
-#define G_LOFL(x) (((x) >> S_LOFL) & M_LOFL)
-
-#define A_MAC_PORT_RX_LINKA_DFE_OFFSET_EVN3_EVN4 0x328c
-
-#define S_LOFE4S_READWRITE 15
-#define V_LOFE4S_READWRITE(x) ((x) << S_LOFE4S_READWRITE)
-#define F_LOFE4S_READWRITE V_LOFE4S_READWRITE(1U)
-
-#define S_LOFE4S_READONLY 14
-#define V_LOFE4S_READONLY(x) ((x) << S_LOFE4S_READONLY)
-#define F_LOFE4S_READONLY V_LOFE4S_READONLY(1U)
-
-#define S_LOFE 8
-#define M_LOFE 0x3fU
-#define V_LOFE(x) ((x) << S_LOFE)
-#define G_LOFE(x) (((x) >> S_LOFE) & M_LOFE)
-
-#define S_LOFE3S_READWRITE 7
-#define V_LOFE3S_READWRITE(x) ((x) << S_LOFE3S_READWRITE)
-#define F_LOFE3S_READWRITE V_LOFE3S_READWRITE(1U)
-
-#define S_LOFE3S_READONLY 6
-#define V_LOFE3S_READONLY(x) ((x) << S_LOFE3S_READONLY)
-#define F_LOFE3S_READONLY V_LOFE3S_READONLY(1U)
-
-#define S_LOFE3 0
-#define M_LOFE3 0x3fU
-#define V_LOFE3(x) ((x) << S_LOFE3)
-#define G_LOFE3(x) (((x) >> S_LOFE3) & M_LOFE3)
-
-#define A_MAC_PORT_RX_LINKA_H_COEFFICIENBT_BIST 0x328c
-
-#define S_HBISTMAN 12
-#define V_HBISTMAN(x) ((x) << S_HBISTMAN)
-#define F_HBISTMAN V_HBISTMAN(1U)
-
-#define S_HBISTRES 11
-#define V_HBISTRES(x) ((x) << S_HBISTRES)
-#define F_HBISTRES V_HBISTRES(1U)
-
-#define S_HBISTSP 8
-#define M_HBISTSP 0x7U
-#define V_HBISTSP(x) ((x) << S_HBISTSP)
-#define G_HBISTSP(x) (((x) >> S_HBISTSP) & M_HBISTSP)
-
-#define S_HBISTEN 7
-#define V_HBISTEN(x) ((x) << S_HBISTEN)
-#define F_HBISTEN V_HBISTEN(1U)
-
-#define S_HBISTRST 6
-#define V_HBISTRST(x) ((x) << S_HBISTRST)
-#define F_HBISTRST V_HBISTRST(1U)
-
-#define S_HCOMP 5
-#define V_HCOMP(x) ((x) << S_HCOMP)
-#define F_HCOMP V_HCOMP(1U)
-
-#define S_HPASS 4
-#define V_HPASS(x) ((x) << S_HPASS)
-#define F_HPASS V_HPASS(1U)
-
-#define S_HSEL 0
-#define M_HSEL 0xfU
-#define V_HSEL(x) ((x) << S_HSEL)
-#define G_HSEL(x) (((x) >> S_HSEL) & M_HSEL)
-
-#define A_MAC_PORT_RX_LINKA_DFE_OFFSET_ODD3_ODD4 0x3290
-
-#define S_LOFO4S_READWRITE 15
-#define V_LOFO4S_READWRITE(x) ((x) << S_LOFO4S_READWRITE)
-#define F_LOFO4S_READWRITE V_LOFO4S_READWRITE(1U)
-
-#define S_LOFO4S_READONLY 14
-#define V_LOFO4S_READONLY(x) ((x) << S_LOFO4S_READONLY)
-#define F_LOFO4S_READONLY V_LOFO4S_READONLY(1U)
-
-#define S_LOFO4 8
-#define M_LOFO4 0x3fU
-#define V_LOFO4(x) ((x) << S_LOFO4)
-#define G_LOFO4(x) (((x) >> S_LOFO4) & M_LOFO4)
-
-#define S_LOFO3S_READWRITE 7
-#define V_LOFO3S_READWRITE(x) ((x) << S_LOFO3S_READWRITE)
-#define F_LOFO3S_READWRITE V_LOFO3S_READWRITE(1U)
-
-#define S_LOFO3S_READONLY 6
-#define V_LOFO3S_READONLY(x) ((x) << S_LOFO3S_READONLY)
-#define F_LOFO3S_READONLY V_LOFO3S_READONLY(1U)
-
-#define S_LOFO3 0
-#define M_LOFO3 0x3fU
-#define V_LOFO3(x) ((x) << S_LOFO3)
-#define G_LOFO3(x) (((x) >> S_LOFO3) & M_LOFO3)
-
-#define A_MAC_PORT_RX_LINKA_AC_CAPACITOR_BIST 0x3290
-
-#define S_RX_LINKA_ACCCMP_BIST 13
-#define V_RX_LINKA_ACCCMP_BIST(x) ((x) << S_RX_LINKA_ACCCMP_BIST)
-#define F_RX_LINKA_ACCCMP_BIST V_RX_LINKA_ACCCMP_BIST(1U)
-
-#define S_ACCEN 12
-#define V_ACCEN(x) ((x) << S_ACCEN)
-#define F_ACCEN V_ACCEN(1U)
-
-#define S_ACCRST 11
-#define V_ACCRST(x) ((x) << S_ACCRST)
-#define F_ACCRST V_ACCRST(1U)
-
-#define S_ACCIND 8
-#define M_ACCIND 0x7U
-#define V_ACCIND(x) ((x) << S_ACCIND)
-#define G_ACCIND(x) (((x) >> S_ACCIND) & M_ACCIND)
-
-#define S_ACCRD 0
-#define M_ACCRD 0xffU
-#define V_ACCRD(x) ((x) << S_ACCRD)
-#define G_ACCRD(x) (((x) >> S_ACCRD) & M_ACCRD)
-
-#define A_MAC_PORT_RX_LINKA_DFE_E0_AND_E1_OFFSET 0x3294
-
-#define S_T5E1SN_READWRITE 15
-#define V_T5E1SN_READWRITE(x) ((x) << S_T5E1SN_READWRITE)
-#define F_T5E1SN_READWRITE V_T5E1SN_READWRITE(1U)
-
-#define S_T5E1SN_READONLY 14
-#define V_T5E1SN_READONLY(x) ((x) << S_T5E1SN_READONLY)
-#define F_T5E1SN_READONLY V_T5E1SN_READONLY(1U)
-
-#define S_T5E1AMP 8
-#define M_T5E1AMP 0x3fU
-#define V_T5E1AMP(x) ((x) << S_T5E1AMP)
-#define G_T5E1AMP(x) (((x) >> S_T5E1AMP) & M_T5E1AMP)
-
-#define S_T5E0SN_READWRITE 7
-#define V_T5E0SN_READWRITE(x) ((x) << S_T5E0SN_READWRITE)
-#define F_T5E0SN_READWRITE V_T5E0SN_READWRITE(1U)
-
-#define S_T5E0SN_READONLY 6
-#define V_T5E0SN_READONLY(x) ((x) << S_T5E0SN_READONLY)
-#define F_T5E0SN_READONLY V_T5E0SN_READONLY(1U)
-
-#define S_T5E0AMP 0
-#define M_T5E0AMP 0x3fU
-#define V_T5E0AMP(x) ((x) << S_T5E0AMP)
-#define G_T5E0AMP(x) (((x) >> S_T5E0AMP) & M_T5E0AMP)
-
-#define A_MAC_PORT_RX_LINKA_RECEIVER_LOFF_CONTROL 0x3298
-
-#define S_T5LFREG 12
-#define V_T5LFREG(x) ((x) << S_T5LFREG)
-#define F_T5LFREG V_T5LFREG(1U)
-
-#define S_T5LFRC 11
-#define V_T5LFRC(x) ((x) << S_T5LFRC)
-#define F_T5LFRC V_T5LFRC(1U)
-
-#define S_T5LFSEL 8
-#define M_T5LFSEL 0x7U
-#define V_T5LFSEL(x) ((x) << S_T5LFSEL)
-#define G_T5LFSEL(x) (((x) >> S_T5LFSEL) & M_T5LFSEL)
-
-#define A_MAC_PORT_RX_LINKA_RECEIVER_LOFF_CONTROL_REGISTER 0x3298
-
-#define S_LFREG 15
-#define V_LFREG(x) ((x) << S_LFREG)
-#define F_LFREG V_LFREG(1U)
-
-#define S_LFRC 14
-#define V_LFRC(x) ((x) << S_LFRC)
-#define F_LFRC V_LFRC(1U)
-
-#define S_LGIDLE 13
-#define V_LGIDLE(x) ((x) << S_LGIDLE)
-#define F_LGIDLE V_LGIDLE(1U)
-
-#define S_LFTGT 8
-#define M_LFTGT 0x1fU
-#define V_LFTGT(x) ((x) << S_LFTGT)
-#define G_LFTGT(x) (((x) >> S_LFTGT) & M_LFTGT)
-
-#define S_LGTGT 7
-#define V_LGTGT(x) ((x) << S_LGTGT)
-#define F_LGTGT V_LGTGT(1U)
-
-#define S_LRDY 6
-#define V_LRDY(x) ((x) << S_LRDY)
-#define F_LRDY V_LRDY(1U)
-
-#define S_LIDLE 5
-#define V_LIDLE(x) ((x) << S_LIDLE)
-#define F_LIDLE V_LIDLE(1U)
-
-#define S_LCURR 0
-#define M_LCURR 0x1fU
-#define V_LCURR(x) ((x) << S_LCURR)
-#define G_LCURR(x) (((x) >> S_LCURR) & M_LCURR)
-
-#define A_MAC_PORT_RX_LINKA_RECEIVER_SIGDET_CONTROL 0x329c
-
-#define S_OFFSN_READWRITE 14
-#define V_OFFSN_READWRITE(x) ((x) << S_OFFSN_READWRITE)
-#define F_OFFSN_READWRITE V_OFFSN_READWRITE(1U)
-
-#define S_OFFSN_READONLY 13
-#define V_OFFSN_READONLY(x) ((x) << S_OFFSN_READONLY)
-#define F_OFFSN_READONLY V_OFFSN_READONLY(1U)
-
-#define S_OFFAMP 8
-#define M_OFFAMP 0x1fU
-#define V_OFFAMP(x) ((x) << S_OFFAMP)
-#define G_OFFAMP(x) (((x) >> S_OFFAMP) & M_OFFAMP)
-
-#define S_SDACDC 7
-#define V_SDACDC(x) ((x) << S_SDACDC)
-#define F_SDACDC V_SDACDC(1U)
-
-#define S_OFFSN 13
-#define M_OFFSN 0x3U
-#define V_OFFSN(x) ((x) << S_OFFSN)
-#define G_OFFSN(x) (((x) >> S_OFFSN) & M_OFFSN)
-
-#define A_MAC_PORT_RX_LINKA_RECEIVER_ANALOG_CONTROL_SWITCH 0x32a0
-
-#define S_T5_RX_SETHDIS 7
-#define V_T5_RX_SETHDIS(x) ((x) << S_T5_RX_SETHDIS)
-#define F_T5_RX_SETHDIS V_T5_RX_SETHDIS(1U)
-
-#define S_T5_RX_PDTERM 6
-#define V_T5_RX_PDTERM(x) ((x) << S_T5_RX_PDTERM)
-#define F_T5_RX_PDTERM V_T5_RX_PDTERM(1U)
-
-#define S_T5_RX_BYPASS 5
-#define V_T5_RX_BYPASS(x) ((x) << S_T5_RX_BYPASS)
-#define F_T5_RX_BYPASS V_T5_RX_BYPASS(1U)
-
-#define S_T5_RX_LPFEN 4
-#define V_T5_RX_LPFEN(x) ((x) << S_T5_RX_LPFEN)
-#define F_T5_RX_LPFEN V_T5_RX_LPFEN(1U)
-
-#define S_T5_RX_VGABOD 3
-#define V_T5_RX_VGABOD(x) ((x) << S_T5_RX_VGABOD)
-#define F_T5_RX_VGABOD V_T5_RX_VGABOD(1U)
-
-#define S_T5_RX_VTBYP 2
-#define V_T5_RX_VTBYP(x) ((x) << S_T5_RX_VTBYP)
-#define F_T5_RX_VTBYP V_T5_RX_VTBYP(1U)
-
-#define S_T5_RX_VTERM 0
-#define M_T5_RX_VTERM 0x3U
-#define V_T5_RX_VTERM(x) ((x) << S_T5_RX_VTERM)
-#define G_T5_RX_VTERM(x) (((x) >> S_T5_RX_VTERM) & M_T5_RX_VTERM)
-
-#define S_RX_OVRSUMPD 15
-#define V_RX_OVRSUMPD(x) ((x) << S_RX_OVRSUMPD)
-#define F_RX_OVRSUMPD V_RX_OVRSUMPD(1U)
-
-#define S_RX_OVRKBPD 14
-#define V_RX_OVRKBPD(x) ((x) << S_RX_OVRKBPD)
-#define F_RX_OVRKBPD V_RX_OVRKBPD(1U)
-
-#define S_RX_OVRDIVPD 13
-#define V_RX_OVRDIVPD(x) ((x) << S_RX_OVRDIVPD)
-#define F_RX_OVRDIVPD V_RX_OVRDIVPD(1U)
-
-#define S_RX_OFFVGADIS 12
-#define V_RX_OFFVGADIS(x) ((x) << S_RX_OFFVGADIS)
-#define F_RX_OFFVGADIS V_RX_OFFVGADIS(1U)
-
-#define S_RX_OFFACDIS 11
-#define V_RX_OFFACDIS(x) ((x) << S_RX_OFFACDIS)
-#define F_RX_OFFACDIS V_RX_OFFACDIS(1U)
-
-#define S_RX_VTERM 10
-#define V_RX_VTERM(x) ((x) << S_RX_VTERM)
-#define F_RX_VTERM V_RX_VTERM(1U)
-
-#define S_RX_DISSPY2D 8
-#define V_RX_DISSPY2D(x) ((x) << S_RX_DISSPY2D)
-#define F_RX_DISSPY2D V_RX_DISSPY2D(1U)
-
-#define S_RX_OBSOVEN 7
-#define V_RX_OBSOVEN(x) ((x) << S_RX_OBSOVEN)
-#define F_RX_OBSOVEN V_RX_OBSOVEN(1U)
-
-#define S_RX_LINKANLGSW 0
-#define M_RX_LINKANLGSW 0x7fU
-#define V_RX_LINKANLGSW(x) ((x) << S_RX_LINKANLGSW)
-#define G_RX_LINKANLGSW(x) (((x) >> S_RX_LINKANLGSW) & M_RX_LINKANLGSW)
-
-#define A_MAC_PORT_RX_LINKA_INTEGRATOR_DAC_OFFSET 0x32a4
-
-#define S_ISTRIMS 14
-#define M_ISTRIMS 0x3U
-#define V_ISTRIMS(x) ((x) << S_ISTRIMS)
-#define G_ISTRIMS(x) (((x) >> S_ISTRIMS) & M_ISTRIMS)
-
-#define S_ISTRIM 8
-#define M_ISTRIM 0x3fU
-#define V_ISTRIM(x) ((x) << S_ISTRIM)
-#define G_ISTRIM(x) (((x) >> S_ISTRIM) & M_ISTRIM)
-
-#define S_HALF1 7
-#define V_HALF1(x) ((x) << S_HALF1)
-#define F_HALF1 V_HALF1(1U)
-
-#define S_HALF2 6
-#define V_HALF2(x) ((x) << S_HALF2)
-#define F_HALF2 V_HALF2(1U)
-
-#define S_INTDAC 0
-#define M_INTDAC 0x3fU
-#define V_INTDAC(x) ((x) << S_INTDAC)
-#define G_INTDAC(x) (((x) >> S_INTDAC) & M_INTDAC)
-
-#define S_INTDACEGS 13
-#define M_INTDACEGS 0x7U
-#define V_INTDACEGS(x) ((x) << S_INTDACEGS)
-#define G_INTDACEGS(x) (((x) >> S_INTDACEGS) & M_INTDACEGS)
-
-#define S_INTDACE 8
-#define M_INTDACE 0x1fU
-#define V_INTDACE(x) ((x) << S_INTDACE)
-#define G_INTDACE(x) (((x) >> S_INTDACE) & M_INTDACE)
-
-#define S_INTDACGS 6
-#define M_INTDACGS 0x3U
-#define V_INTDACGS(x) ((x) << S_INTDACGS)
-#define G_INTDACGS(x) (((x) >> S_INTDACGS) & M_INTDACGS)
-
-#define A_MAC_PORT_RX_LINKA_DIGITAL_EYE_CONTROL 0x32a8
-
-#define S_MINWDTH 5
-#define M_MINWDTH 0x1fU
-#define V_MINWDTH(x) ((x) << S_MINWDTH)
-#define G_MINWDTH(x) (((x) >> S_MINWDTH) & M_MINWDTH)
-
-#define A_MAC_PORT_RX_LINKA_DIGITAL_EYE_METRICS 0x32ac
-
-#define S_T5SMQM 13
-#define M_T5SMQM 0x7U
-#define V_T5SMQM(x) ((x) << S_T5SMQM)
-#define G_T5SMQM(x) (((x) >> S_T5SMQM) & M_T5SMQM)
-
-#define S_T5SMQ 5
-#define M_T5SMQ 0xffU
-#define V_T5SMQ(x) ((x) << S_T5SMQ)
-#define G_T5SMQ(x) (((x) >> S_T5SMQ) & M_T5SMQ)
-
-#define S_T5EMMD 3
-#define M_T5EMMD 0x3U
-#define V_T5EMMD(x) ((x) << S_T5EMMD)
-#define G_T5EMMD(x) (((x) >> S_T5EMMD) & M_T5EMMD)
-
-#define S_T5EMBRDY 2
-#define V_T5EMBRDY(x) ((x) << S_T5EMBRDY)
-#define F_T5EMBRDY V_T5EMBRDY(1U)
-
-#define S_T5EMBUMP 1
-#define V_T5EMBUMP(x) ((x) << S_T5EMBUMP)
-#define F_T5EMBUMP V_T5EMBUMP(1U)
-
-#define S_T5EMEN 0
-#define V_T5EMEN(x) ((x) << S_T5EMEN)
-#define F_T5EMEN V_T5EMEN(1U)
-
-#define S_SMQM 13
-#define M_SMQM 0x7U
-#define V_SMQM(x) ((x) << S_SMQM)
-#define G_SMQM(x) (((x) >> S_SMQM) & M_SMQM)
-
-#define S_SMQ 5
-#define M_SMQ 0xffU
-#define V_SMQ(x) ((x) << S_SMQ)
-#define G_SMQ(x) (((x) >> S_SMQ) & M_SMQ)
-
-#define S_T6_EMMD 3
-#define M_T6_EMMD 0x3U
-#define V_T6_EMMD(x) ((x) << S_T6_EMMD)
-#define G_T6_EMMD(x) (((x) >> S_T6_EMMD) & M_T6_EMMD)
-
-#define S_T6_EMBRDY 2
-#define V_T6_EMBRDY(x) ((x) << S_T6_EMBRDY)
-#define F_T6_EMBRDY V_T6_EMBRDY(1U)
-
-#define S_T6_EMBUMP 1
-#define V_T6_EMBUMP(x) ((x) << S_T6_EMBUMP)
-#define F_T6_EMBUMP V_T6_EMBUMP(1U)
-
-#define A_MAC_PORT_RX_LINKA_DIGITAL_EYE_METRICS_ERROR_COUNT 0x32b0
-
-#define S_EMF8 15
-#define V_EMF8(x) ((x) << S_EMF8)
-#define F_EMF8 V_EMF8(1U)
-
-#define S_EMCNT 4
-#define M_EMCNT 0xffU
-#define V_EMCNT(x) ((x) << S_EMCNT)
-#define G_EMCNT(x) (((x) >> S_EMCNT) & M_EMCNT)
-
-#define S_EMOFLO 2
-#define V_EMOFLO(x) ((x) << S_EMOFLO)
-#define F_EMOFLO V_EMOFLO(1U)
-
-#define S_EMCRST 1
-#define V_EMCRST(x) ((x) << S_EMCRST)
-#define F_EMCRST V_EMCRST(1U)
-
-#define S_EMCEN 0
-#define V_EMCEN(x) ((x) << S_EMCEN)
-#define F_EMCEN V_EMCEN(1U)
-
-#define S_EMSF 13
-#define V_EMSF(x) ((x) << S_EMSF)
-#define F_EMSF V_EMSF(1U)
-
-#define S_EMDATA59 12
-#define V_EMDATA59(x) ((x) << S_EMDATA59)
-#define F_EMDATA59 V_EMDATA59(1U)
-
-#define A_MAC_PORT_RX_LINKA_DIGITAL_EYE_METRICS_PDF_EYE_COUNT 0x32b4
-
-#define S_SM2RDY 15
-#define V_SM2RDY(x) ((x) << S_SM2RDY)
-#define F_SM2RDY V_SM2RDY(1U)
-
-#define S_SM2RST 14
-#define V_SM2RST(x) ((x) << S_SM2RST)
-#define F_SM2RST V_SM2RST(1U)
-
-#define S_APDF 0
-#define M_APDF 0xfffU
-#define V_APDF(x) ((x) << S_APDF)
-#define G_APDF(x) (((x) >> S_APDF) & M_APDF)
-
-#define A_MAC_PORT_RX_LINKA_DIGITAL_EYE_METRICS_PATTERN_LENGTH 0x32b8
-
-#define S_SM0LEN 0
-#define M_SM0LEN 0x7fffU
-#define V_SM0LEN(x) ((x) << S_SM0LEN)
-#define G_SM0LEN(x) (((x) >> S_SM0LEN) & M_SM0LEN)
-
-#define A_MAC_PORT_RX_LINKA_DFE_FUNCTION_CONTROL_3 0x32bc
-
-#define S_FTIMEOUT 15
-#define V_FTIMEOUT(x) ((x) << S_FTIMEOUT)
-#define F_FTIMEOUT V_FTIMEOUT(1U)
-
-#define S_FROTCAL4 14
-#define V_FROTCAL4(x) ((x) << S_FROTCAL4)
-#define F_FROTCAL4 V_FROTCAL4(1U)
-
-#define S_FDCD2 13
-#define V_FDCD2(x) ((x) << S_FDCD2)
-#define F_FDCD2 V_FDCD2(1U)
-
-#define S_FPRBSPOLTOG 12
-#define V_FPRBSPOLTOG(x) ((x) << S_FPRBSPOLTOG)
-#define F_FPRBSPOLTOG V_FPRBSPOLTOG(1U)
-
-#define S_FPRBSOFF2 11
-#define V_FPRBSOFF2(x) ((x) << S_FPRBSOFF2)
-#define F_FPRBSOFF2 V_FPRBSOFF2(1U)
-
-#define S_FDDCAL2 10
-#define V_FDDCAL2(x) ((x) << S_FDDCAL2)
-#define F_FDDCAL2 V_FDDCAL2(1U)
-
-#define S_FDDCFLTR 9
-#define V_FDDCFLTR(x) ((x) << S_FDDCFLTR)
-#define F_FDDCFLTR V_FDDCFLTR(1U)
-
-#define S_FDAC6 8
-#define V_FDAC6(x) ((x) << S_FDAC6)
-#define F_FDAC6 V_FDAC6(1U)
-
-#define S_FDDC5 7
-#define V_FDDC5(x) ((x) << S_FDDC5)
-#define F_FDDC5 V_FDDC5(1U)
-
-#define S_FDDC3456 6
-#define V_FDDC3456(x) ((x) << S_FDDC3456)
-#define F_FDDC3456 V_FDDC3456(1U)
-
-#define S_FSPY2DATA 5
-#define V_FSPY2DATA(x) ((x) << S_FSPY2DATA)
-#define F_FSPY2DATA V_FSPY2DATA(1U)
-
-#define S_FPHSLOCK 4
-#define V_FPHSLOCK(x) ((x) << S_FPHSLOCK)
-#define F_FPHSLOCK V_FPHSLOCK(1U)
-
-#define S_FCLKALGN 3
-#define V_FCLKALGN(x) ((x) << S_FCLKALGN)
-#define F_FCLKALGN V_FCLKALGN(1U)
-
-#define S_FCLKALDYN 2
-#define V_FCLKALDYN(x) ((x) << S_FCLKALDYN)
-#define F_FCLKALDYN V_FCLKALDYN(1U)
-
-#define S_FDFE 1
-#define V_FDFE(x) ((x) << S_FDFE)
-#define F_FDFE V_FDFE(1U)
-
-#define S_FPRBSOFF 0
-#define V_FPRBSOFF(x) ((x) << S_FPRBSOFF)
-#define F_FPRBSOFF V_FPRBSOFF(1U)
-
-#define A_MAC_PORT_RX_LINKA_DFE_TAP_ENABLE 0x32c0
-
-#define S_H_EN 1
-#define M_H_EN 0xfffU
-#define V_H_EN(x) ((x) << S_H_EN)
-#define G_H_EN(x) (((x) >> S_H_EN) & M_H_EN)
-
-#define A_MAC_PORT_RX_LINKA_DFE_TAP_CONTROL 0x32c0
-
-#define S_RX_LINKA_INDEX_DFE_TC 0
-#define M_RX_LINKA_INDEX_DFE_TC 0xfU
-#define V_RX_LINKA_INDEX_DFE_TC(x) ((x) << S_RX_LINKA_INDEX_DFE_TC)
-#define G_RX_LINKA_INDEX_DFE_TC(x) (((x) >> S_RX_LINKA_INDEX_DFE_TC) & M_RX_LINKA_INDEX_DFE_TC)
-
-#define A_MAC_PORT_RX_LINKA_DFE_H1 0x32c4
-#define A_MAC_PORT_RX_LINKA_DFE_TAP 0x32c4
-
-#define S_RX_LINKA_INDEX_DFE_TAP 0
-#define M_RX_LINKA_INDEX_DFE_TAP 0xfU
-#define V_RX_LINKA_INDEX_DFE_TAP(x) ((x) << S_RX_LINKA_INDEX_DFE_TAP)
-#define G_RX_LINKA_INDEX_DFE_TAP(x) (((x) >> S_RX_LINKA_INDEX_DFE_TAP) & M_RX_LINKA_INDEX_DFE_TAP)
-
-#define A_MAC_PORT_RX_LINKA_DFE_H2 0x32c8
-
-#define S_H2OSN_READWRITE 14
-#define V_H2OSN_READWRITE(x) ((x) << S_H2OSN_READWRITE)
-#define F_H2OSN_READWRITE V_H2OSN_READWRITE(1U)
-
-#define S_H2OSN_READONLY 13
-#define V_H2OSN_READONLY(x) ((x) << S_H2OSN_READONLY)
-#define F_H2OSN_READONLY V_H2OSN_READONLY(1U)
-
-#define S_H2ESN_READWRITE 6
-#define V_H2ESN_READWRITE(x) ((x) << S_H2ESN_READWRITE)
-#define F_H2ESN_READWRITE V_H2ESN_READWRITE(1U)
-
-#define S_H2ESN_READONLY 5
-#define V_H2ESN_READONLY(x) ((x) << S_H2ESN_READONLY)
-#define F_H2ESN_READONLY V_H2ESN_READONLY(1U)
-
-#define A_MAC_PORT_RX_LINKA_DFE_H3 0x32cc
-
-#define S_H3OSN_READWRITE 13
-#define V_H3OSN_READWRITE(x) ((x) << S_H3OSN_READWRITE)
-#define F_H3OSN_READWRITE V_H3OSN_READWRITE(1U)
-
-#define S_H3OSN_READONLY 12
-#define V_H3OSN_READONLY(x) ((x) << S_H3OSN_READONLY)
-#define F_H3OSN_READONLY V_H3OSN_READONLY(1U)
-
-#define S_H3ESN_READWRITE 5
-#define V_H3ESN_READWRITE(x) ((x) << S_H3ESN_READWRITE)
-#define F_H3ESN_READWRITE V_H3ESN_READWRITE(1U)
-
-#define S_H3ESN_READONLY 4
-#define V_H3ESN_READONLY(x) ((x) << S_H3ESN_READONLY)
-#define F_H3ESN_READONLY V_H3ESN_READONLY(1U)
-
-#define A_MAC_PORT_RX_LINKA_DFE_H4 0x32d0
-
-#define S_H4OGS 14
-#define M_H4OGS 0x3U
-#define V_H4OGS(x) ((x) << S_H4OGS)
-#define G_H4OGS(x) (((x) >> S_H4OGS) & M_H4OGS)
-
-#define S_H4OSN_READWRITE 13
-#define V_H4OSN_READWRITE(x) ((x) << S_H4OSN_READWRITE)
-#define F_H4OSN_READWRITE V_H4OSN_READWRITE(1U)
-
-#define S_H4OSN_READONLY 12
-#define V_H4OSN_READONLY(x) ((x) << S_H4OSN_READONLY)
-#define F_H4OSN_READONLY V_H4OSN_READONLY(1U)
-
-#define S_H4EGS 6
-#define M_H4EGS 0x3U
-#define V_H4EGS(x) ((x) << S_H4EGS)
-#define G_H4EGS(x) (((x) >> S_H4EGS) & M_H4EGS)
-
-#define S_H4ESN_READWRITE 5
-#define V_H4ESN_READWRITE(x) ((x) << S_H4ESN_READWRITE)
-#define F_H4ESN_READWRITE V_H4ESN_READWRITE(1U)
-
-#define S_H4ESN_READONLY 4
-#define V_H4ESN_READONLY(x) ((x) << S_H4ESN_READONLY)
-#define F_H4ESN_READONLY V_H4ESN_READONLY(1U)
-
-#define A_MAC_PORT_RX_LINKA_DFE_H5 0x32d4
-
-#define S_H5OGS 14
-#define M_H5OGS 0x3U
-#define V_H5OGS(x) ((x) << S_H5OGS)
-#define G_H5OGS(x) (((x) >> S_H5OGS) & M_H5OGS)
-
-#define S_H5OSN_READWRITE 13
-#define V_H5OSN_READWRITE(x) ((x) << S_H5OSN_READWRITE)
-#define F_H5OSN_READWRITE V_H5OSN_READWRITE(1U)
-
-#define S_H5OSN_READONLY 12
-#define V_H5OSN_READONLY(x) ((x) << S_H5OSN_READONLY)
-#define F_H5OSN_READONLY V_H5OSN_READONLY(1U)
-
-#define S_H5EGS 6
-#define M_H5EGS 0x3U
-#define V_H5EGS(x) ((x) << S_H5EGS)
-#define G_H5EGS(x) (((x) >> S_H5EGS) & M_H5EGS)
-
-#define S_H5ESN_READWRITE 5
-#define V_H5ESN_READWRITE(x) ((x) << S_H5ESN_READWRITE)
-#define F_H5ESN_READWRITE V_H5ESN_READWRITE(1U)
-
-#define S_H5ESN_READONLY 4
-#define V_H5ESN_READONLY(x) ((x) << S_H5ESN_READONLY)
-#define F_H5ESN_READONLY V_H5ESN_READONLY(1U)
-
-#define A_MAC_PORT_RX_LINKA_DFE_H6_AND_H7 0x32d8
-
-#define S_H7GS 14
-#define M_H7GS 0x3U
-#define V_H7GS(x) ((x) << S_H7GS)
-#define G_H7GS(x) (((x) >> S_H7GS) & M_H7GS)
-
-#define S_H7SN_READWRITE 13
-#define V_H7SN_READWRITE(x) ((x) << S_H7SN_READWRITE)
-#define F_H7SN_READWRITE V_H7SN_READWRITE(1U)
-
-#define S_H7SN_READONLY 12
-#define V_H7SN_READONLY(x) ((x) << S_H7SN_READONLY)
-#define F_H7SN_READONLY V_H7SN_READONLY(1U)
-
-#define S_H7MAG 8
-#define M_H7MAG 0xfU
-#define V_H7MAG(x) ((x) << S_H7MAG)
-#define G_H7MAG(x) (((x) >> S_H7MAG) & M_H7MAG)
-
-#define S_H6GS 6
-#define M_H6GS 0x3U
-#define V_H6GS(x) ((x) << S_H6GS)
-#define G_H6GS(x) (((x) >> S_H6GS) & M_H6GS)
-
-#define S_H6SN_READWRITE 5
-#define V_H6SN_READWRITE(x) ((x) << S_H6SN_READWRITE)
-#define F_H6SN_READWRITE V_H6SN_READWRITE(1U)
-
-#define S_H6SN_READONLY 4
-#define V_H6SN_READONLY(x) ((x) << S_H6SN_READONLY)
-#define F_H6SN_READONLY V_H6SN_READONLY(1U)
-
-#define S_H6MAG 0
-#define M_H6MAG 0xfU
-#define V_H6MAG(x) ((x) << S_H6MAG)
-#define G_H6MAG(x) (((x) >> S_H6MAG) & M_H6MAG)
-
-#define A_MAC_PORT_RX_LINKA_DFE_H8_AND_H9 0x32dc
-
-#define S_H9GS 14
-#define M_H9GS 0x3U
-#define V_H9GS(x) ((x) << S_H9GS)
-#define G_H9GS(x) (((x) >> S_H9GS) & M_H9GS)
-
-#define S_H9SN_READWRITE 13
-#define V_H9SN_READWRITE(x) ((x) << S_H9SN_READWRITE)
-#define F_H9SN_READWRITE V_H9SN_READWRITE(1U)
-
-#define S_H9SN_READONLY 12
-#define V_H9SN_READONLY(x) ((x) << S_H9SN_READONLY)
-#define F_H9SN_READONLY V_H9SN_READONLY(1U)
-
-#define S_H9MAG 8
-#define M_H9MAG 0xfU
-#define V_H9MAG(x) ((x) << S_H9MAG)
-#define G_H9MAG(x) (((x) >> S_H9MAG) & M_H9MAG)
-
-#define S_H8GS 6
-#define M_H8GS 0x3U
-#define V_H8GS(x) ((x) << S_H8GS)
-#define G_H8GS(x) (((x) >> S_H8GS) & M_H8GS)
-
-#define S_H8SN_READWRITE 5
-#define V_H8SN_READWRITE(x) ((x) << S_H8SN_READWRITE)
-#define F_H8SN_READWRITE V_H8SN_READWRITE(1U)
-
-#define S_H8SN_READONLY 4
-#define V_H8SN_READONLY(x) ((x) << S_H8SN_READONLY)
-#define F_H8SN_READONLY V_H8SN_READONLY(1U)
-
-#define S_H8MAG 0
-#define M_H8MAG 0xfU
-#define V_H8MAG(x) ((x) << S_H8MAG)
-#define G_H8MAG(x) (((x) >> S_H8MAG) & M_H8MAG)
-
-#define A_MAC_PORT_RX_LINKA_DFE_H10_AND_H11 0x32e0
-
-#define S_H11GS 14
-#define M_H11GS 0x3U
-#define V_H11GS(x) ((x) << S_H11GS)
-#define G_H11GS(x) (((x) >> S_H11GS) & M_H11GS)
-
-#define S_H11SN_READWRITE 13
-#define V_H11SN_READWRITE(x) ((x) << S_H11SN_READWRITE)
-#define F_H11SN_READWRITE V_H11SN_READWRITE(1U)
-
-#define S_H11SN_READONLY 12
-#define V_H11SN_READONLY(x) ((x) << S_H11SN_READONLY)
-#define F_H11SN_READONLY V_H11SN_READONLY(1U)
-
-#define S_H11MAG 8
-#define M_H11MAG 0xfU
-#define V_H11MAG(x) ((x) << S_H11MAG)
-#define G_H11MAG(x) (((x) >> S_H11MAG) & M_H11MAG)
-
-#define S_H10GS 6
-#define M_H10GS 0x3U
-#define V_H10GS(x) ((x) << S_H10GS)
-#define G_H10GS(x) (((x) >> S_H10GS) & M_H10GS)
-
-#define S_H10SN_READWRITE 5
-#define V_H10SN_READWRITE(x) ((x) << S_H10SN_READWRITE)
-#define F_H10SN_READWRITE V_H10SN_READWRITE(1U)
-
-#define S_H10SN_READONLY 4
-#define V_H10SN_READONLY(x) ((x) << S_H10SN_READONLY)
-#define F_H10SN_READONLY V_H10SN_READONLY(1U)
-
-#define S_H10MAG 0
-#define M_H10MAG 0xfU
-#define V_H10MAG(x) ((x) << S_H10MAG)
-#define G_H10MAG(x) (((x) >> S_H10MAG) & M_H10MAG)
-
-#define A_MAC_PORT_RX_LINKA_DFE_H12 0x32e4
-
-#define S_H12GS 6
-#define M_H12GS 0x3U
-#define V_H12GS(x) ((x) << S_H12GS)
-#define G_H12GS(x) (((x) >> S_H12GS) & M_H12GS)
-
-#define S_H12SN_READWRITE 5
-#define V_H12SN_READWRITE(x) ((x) << S_H12SN_READWRITE)
-#define F_H12SN_READWRITE V_H12SN_READWRITE(1U)
-
-#define S_H12SN_READONLY 4
-#define V_H12SN_READONLY(x) ((x) << S_H12SN_READONLY)
-#define F_H12SN_READONLY V_H12SN_READONLY(1U)
-
-#define S_H12MAG 0
-#define M_H12MAG 0xfU
-#define V_H12MAG(x) ((x) << S_H12MAG)
-#define G_H12MAG(x) (((x) >> S_H12MAG) & M_H12MAG)
-
-#define A_MAC_PORT_RX_LINKA_RECEIVER_INTERNAL_STATUS_2 0x32e4
-
-#define S_STNDBYSTAT 15
-#define V_STNDBYSTAT(x) ((x) << S_STNDBYSTAT)
-#define F_STNDBYSTAT V_STNDBYSTAT(1U)
-
-#define S_CALSDONE 14
-#define V_CALSDONE(x) ((x) << S_CALSDONE)
-#define F_CALSDONE V_CALSDONE(1U)
-
-#define S_ACISRCCMP 5
-#define V_ACISRCCMP(x) ((x) << S_ACISRCCMP)
-#define F_ACISRCCMP V_ACISRCCMP(1U)
-
-#define S_PRBSOFFCMP 4
-#define V_PRBSOFFCMP(x) ((x) << S_PRBSOFFCMP)
-#define F_PRBSOFFCMP V_PRBSOFFCMP(1U)
-
-#define S_CLKALGNCMP 3
-#define V_CLKALGNCMP(x) ((x) << S_CLKALGNCMP)
-#define F_CLKALGNCMP V_CLKALGNCMP(1U)
-
-#define S_ROTFCMP 2
-#define V_ROTFCMP(x) ((x) << S_ROTFCMP)
-#define F_ROTFCMP V_ROTFCMP(1U)
-
-#define S_DCDCMP 1
-#define V_DCDCMP(x) ((x) << S_DCDCMP)
-#define F_DCDCMP V_DCDCMP(1U)
-
-#define S_QCCCMP 0
-#define V_QCCCMP(x) ((x) << S_QCCCMP)
-#define F_QCCCMP V_QCCCMP(1U)
-
-#define A_MAC_PORT_RX_LINKA_AC_COUPLING_CURRENT_SOURCE_ADJUST 0x32e8
-
-#define S_FCSADJ 6
-#define V_FCSADJ(x) ((x) << S_FCSADJ)
-#define F_FCSADJ V_FCSADJ(1U)
-
-#define S_CSIND 3
-#define M_CSIND 0x3U
-#define V_CSIND(x) ((x) << S_CSIND)
-#define G_CSIND(x) (((x) >> S_CSIND) & M_CSIND)
-
-#define S_CSVAL 0
-#define M_CSVAL 0x7U
-#define V_CSVAL(x) ((x) << S_CSVAL)
-#define G_CSVAL(x) (((x) >> S_CSVAL) & M_CSVAL)
-
-#define A_MAC_PORT_RX_LINKA_RECEIVER_DCD_CONTROL 0x32ec
-
-#define S_DCDTMDOUT 15
-#define V_DCDTMDOUT(x) ((x) << S_DCDTMDOUT)
-#define F_DCDTMDOUT V_DCDTMDOUT(1U)
-
-#define S_DCDTOEN 14
-#define V_DCDTOEN(x) ((x) << S_DCDTOEN)
-#define F_DCDTOEN V_DCDTOEN(1U)
-
-#define S_DCDLOCK 13
-#define V_DCDLOCK(x) ((x) << S_DCDLOCK)
-#define F_DCDLOCK V_DCDLOCK(1U)
-
-#define S_DCDSTEP 11
-#define M_DCDSTEP 0x3U
-#define V_DCDSTEP(x) ((x) << S_DCDSTEP)
-#define G_DCDSTEP(x) (((x) >> S_DCDSTEP) & M_DCDSTEP)
-
-#define S_DCDALTWPDIS 10
-#define V_DCDALTWPDIS(x) ((x) << S_DCDALTWPDIS)
-#define F_DCDALTWPDIS V_DCDALTWPDIS(1U)
-
-#define S_DCDOVRDEN 9
-#define V_DCDOVRDEN(x) ((x) << S_DCDOVRDEN)
-#define F_DCDOVRDEN V_DCDOVRDEN(1U)
-
-#define S_DCCAOVRDEN 8
-#define V_DCCAOVRDEN(x) ((x) << S_DCCAOVRDEN)
-#define F_DCCAOVRDEN V_DCCAOVRDEN(1U)
-
-#define S_DCDSIGN 6
-#define M_DCDSIGN 0x3U
-#define V_DCDSIGN(x) ((x) << S_DCDSIGN)
-#define G_DCDSIGN(x) (((x) >> S_DCDSIGN) & M_DCDSIGN)
-
-#define S_DCDAMP 0
-#define M_DCDAMP 0x3fU
-#define V_DCDAMP(x) ((x) << S_DCDAMP)
-#define G_DCDAMP(x) (((x) >> S_DCDAMP) & M_DCDAMP)
-
-#define A_MAC_PORT_RX_LINKA_RECEIVER_DCC_CONTROL 0x32f0
-
-#define S_PRBSMODE 14
-#define M_PRBSMODE 0x3U
-#define V_PRBSMODE(x) ((x) << S_PRBSMODE)
-#define G_PRBSMODE(x) (((x) >> S_PRBSMODE) & M_PRBSMODE)
-
-#define S_RX_LINKA_DCCSTEP_RXCTL 10
-#define M_RX_LINKA_DCCSTEP_RXCTL 0x3U
-#define V_RX_LINKA_DCCSTEP_RXCTL(x) ((x) << S_RX_LINKA_DCCSTEP_RXCTL)
-#define G_RX_LINKA_DCCSTEP_RXCTL(x) (((x) >> S_RX_LINKA_DCCSTEP_RXCTL) & M_RX_LINKA_DCCSTEP_RXCTL)
-
-#define S_DCCOVRDEN 9
-#define V_DCCOVRDEN(x) ((x) << S_DCCOVRDEN)
-#define F_DCCOVRDEN V_DCCOVRDEN(1U)
-
-#define S_RX_LINKA_DCCLOCK_RXCTL 8
-#define V_RX_LINKA_DCCLOCK_RXCTL(x) ((x) << S_RX_LINKA_DCCLOCK_RXCTL)
-#define F_RX_LINKA_DCCLOCK_RXCTL V_RX_LINKA_DCCLOCK_RXCTL(1U)
-
-#define A_MAC_PORT_RX_LINKA_RECEIVER_QCC_CONTROL 0x32f4
-
-#define S_DCCQCCMODE 15
-#define V_DCCQCCMODE(x) ((x) << S_DCCQCCMODE)
-#define F_DCCQCCMODE V_DCCQCCMODE(1U)
-
-#define S_DCCQCCDYN 14
-#define V_DCCQCCDYN(x) ((x) << S_DCCQCCDYN)
-#define F_DCCQCCDYN V_DCCQCCDYN(1U)
-
-#define S_DCCQCCHOLD 13
-#define V_DCCQCCHOLD(x) ((x) << S_DCCQCCHOLD)
-#define F_DCCQCCHOLD V_DCCQCCHOLD(1U)
-
-#define S_QCCSTEP 10
-#define M_QCCSTEP 0x3U
-#define V_QCCSTEP(x) ((x) << S_QCCSTEP)
-#define G_QCCSTEP(x) (((x) >> S_QCCSTEP) & M_QCCSTEP)
-
-#define S_QCCOVRDEN 9
-#define V_QCCOVRDEN(x) ((x) << S_QCCOVRDEN)
-#define F_QCCOVRDEN V_QCCOVRDEN(1U)
-
-#define S_QCCLOCK 8
-#define V_QCCLOCK(x) ((x) << S_QCCLOCK)
-#define F_QCCLOCK V_QCCLOCK(1U)
-
-#define S_QCCSIGN 6
-#define M_QCCSIGN 0x3U
-#define V_QCCSIGN(x) ((x) << S_QCCSIGN)
-#define G_QCCSIGN(x) (((x) >> S_QCCSIGN) & M_QCCSIGN)
-
-#define S_QCDAMP 0
-#define M_QCDAMP 0x3fU
-#define V_QCDAMP(x) ((x) << S_QCDAMP)
-#define G_QCDAMP(x) (((x) >> S_QCDAMP) & M_QCDAMP)
-
-#define A_MAC_PORT_RX_LINKA_RECEIVER_MACRO_TEST_CONTROL_2 0x32f8
-
-#define S_DFEDACLSSD 6
-#define V_DFEDACLSSD(x) ((x) << S_DFEDACLSSD)
-#define F_DFEDACLSSD V_DFEDACLSSD(1U)
-
-#define S_SDLSSD 5
-#define V_SDLSSD(x) ((x) << S_SDLSSD)
-#define F_SDLSSD V_SDLSSD(1U)
-
-#define S_DFEOBSBIAS 4
-#define V_DFEOBSBIAS(x) ((x) << S_DFEOBSBIAS)
-#define F_DFEOBSBIAS V_DFEOBSBIAS(1U)
-
-#define S_GBOFSTLSSD 3
-#define V_GBOFSTLSSD(x) ((x) << S_GBOFSTLSSD)
-#define F_GBOFSTLSSD V_GBOFSTLSSD(1U)
-
-#define S_RXDOBS 2
-#define V_RXDOBS(x) ((x) << S_RXDOBS)
-#define F_RXDOBS V_RXDOBS(1U)
-
-#define S_ACJZPT 1
-#define V_ACJZPT(x) ((x) << S_ACJZPT)
-#define F_ACJZPT V_ACJZPT(1U)
-
-#define S_ACJZNT 0
-#define V_ACJZNT(x) ((x) << S_ACJZNT)
-#define F_ACJZNT V_ACJZNT(1U)
-
-#define A_MAC_PORT_RX_LINKA_RECEIVER_MACRO_TEST_CONTROL_REGISTER_2 0x32f8
-
-#define S_TSTCMP 15
-#define V_TSTCMP(x) ((x) << S_TSTCMP)
-#define F_TSTCMP V_TSTCMP(1U)
-
-#define A_MAC_PORT_RX_LINKA_RECEIVER_MACRO_TEST_CONTROL_1 0x32fc
-
-#define S_PHSLOCK 10
-#define V_PHSLOCK(x) ((x) << S_PHSLOCK)
-#define F_PHSLOCK V_PHSLOCK(1U)
-
-#define S_TESTMODE 9
-#define V_TESTMODE(x) ((x) << S_TESTMODE)
-#define F_TESTMODE V_TESTMODE(1U)
-
-#define S_CALMODE 8
-#define V_CALMODE(x) ((x) << S_CALMODE)
-#define F_CALMODE V_CALMODE(1U)
-
-#define S_AMPSEL 7
-#define V_AMPSEL(x) ((x) << S_AMPSEL)
-#define F_AMPSEL V_AMPSEL(1U)
-
-#define S_WHICHNRZ 6
-#define V_WHICHNRZ(x) ((x) << S_WHICHNRZ)
-#define F_WHICHNRZ V_WHICHNRZ(1U)
-
-#define S_BANKA 5
-#define V_BANKA(x) ((x) << S_BANKA)
-#define F_BANKA V_BANKA(1U)
-
-#define S_BANKB 4
-#define V_BANKB(x) ((x) << S_BANKB)
-#define F_BANKB V_BANKB(1U)
-
-#define S_ACJPDP 3
-#define V_ACJPDP(x) ((x) << S_ACJPDP)
-#define F_ACJPDP V_ACJPDP(1U)
-
-#define S_ACJPDN 2
-#define V_ACJPDN(x) ((x) << S_ACJPDN)
-#define F_ACJPDN V_ACJPDN(1U)
-
-#define S_LSSDT 1
-#define V_LSSDT(x) ((x) << S_LSSDT)
-#define F_LSSDT V_LSSDT(1U)
-
-#define S_MTHOLD 0
-#define V_MTHOLD(x) ((x) << S_MTHOLD)
-#define F_MTHOLD V_MTHOLD(1U)
-
-#define S_CALMODEEDGE 14
-#define V_CALMODEEDGE(x) ((x) << S_CALMODEEDGE)
-#define F_CALMODEEDGE V_CALMODEEDGE(1U)
-
-#define S_TESTCAP 13
-#define V_TESTCAP(x) ((x) << S_TESTCAP)
-#define F_TESTCAP V_TESTCAP(1U)
-
-#define S_SNAPEN 12
-#define V_SNAPEN(x) ((x) << S_SNAPEN)
-#define F_SNAPEN V_SNAPEN(1U)
-
-#define S_ASYNCDIR 11
-#define V_ASYNCDIR(x) ((x) << S_ASYNCDIR)
-#define F_ASYNCDIR V_ASYNCDIR(1U)
-
-#define A_MAC_PORT_RX_LINKB_RECEIVER_CONFIGURATION_MODE 0x3300
-#define A_MAC_PORT_RX_LINKB_RECEIVER_TEST_CONTROL 0x3304
-#define A_MAC_PORT_RX_LINKB_PHASE_ROTATOR_CONTROL 0x3308
-#define A_MAC_PORT_RX_LINKB_PHASE_ROTATOR_OFFSET_CONTROL 0x330c
-
-#define S_T6_TMSCAL 8
-#define M_T6_TMSCAL 0x3U
-#define V_T6_TMSCAL(x) ((x) << S_T6_TMSCAL)
-#define G_T6_TMSCAL(x) (((x) >> S_T6_TMSCAL) & M_T6_TMSCAL)
-
-#define S_T6_APADJ 7
-#define V_T6_APADJ(x) ((x) << S_T6_APADJ)
-#define F_T6_APADJ V_T6_APADJ(1U)
-
-#define S_T6_RSEL 6
-#define V_T6_RSEL(x) ((x) << S_T6_RSEL)
-#define F_T6_RSEL V_T6_RSEL(1U)
-
-#define S_T6_PHOFFS 0
-#define M_T6_PHOFFS 0x3fU
-#define V_T6_PHOFFS(x) ((x) << S_T6_PHOFFS)
-#define G_T6_PHOFFS(x) (((x) >> S_T6_PHOFFS) & M_T6_PHOFFS)
-
-#define A_MAC_PORT_RX_LINKB_PHASE_ROTATOR_POSITION_1 0x3310
-#define A_MAC_PORT_RX_LINKB_PHASE_ROTATOR_POSITION_2 0x3314
-#define A_MAC_PORT_RX_LINKB_PHASE_ROTATOR_STATIC_PHASE_OFFSET_1 0x3318
-#define A_MAC_PORT_RX_LINKB_PHASE_ROTATOR_STATIC_PHASE_OFFSET_2 0x331c
-#define A_MAC_PORT_RX_LINKB_DFE_CONTROL 0x3320
-
-#define S_T6_SPIFMT 8
-#define M_T6_SPIFMT 0xfU
-#define V_T6_SPIFMT(x) ((x) << S_T6_SPIFMT)
-#define G_T6_SPIFMT(x) (((x) >> S_T6_SPIFMT) & M_T6_SPIFMT)
-
-#define A_MAC_PORT_RX_LINKB_DFE_SAMPLE_SNAPSHOT_1 0x3324
-#define A_MAC_PORT_RX_LINKB_DFE_SAMPLE_SNAPSHOT_2 0x3328
-#define A_MAC_PORT_RX_LINKB_RECEIVER_VGA_CONTROL_1 0x332c
-
-#define S_T6_WRAPSEL 15
-#define V_T6_WRAPSEL(x) ((x) << S_T6_WRAPSEL)
-#define F_T6_WRAPSEL V_T6_WRAPSEL(1U)
-
-#define S_T6_PEAK 9
-#define M_T6_PEAK 0x1fU
-#define V_T6_PEAK(x) ((x) << S_T6_PEAK)
-#define G_T6_PEAK(x) (((x) >> S_T6_PEAK) & M_T6_PEAK)
-
-#define A_MAC_PORT_RX_LINKB_RECEIVER_VGA_CONTROL_2 0x3330
-
-#define S_T6_T5VGAIN 0
-#define M_T6_T5VGAIN 0x7fU
-#define V_T6_T5VGAIN(x) ((x) << S_T6_T5VGAIN)
-#define G_T6_T5VGAIN(x) (((x) >> S_T6_T5VGAIN) & M_T6_T5VGAIN)
-
-#define A_MAC_PORT_RX_LINKB_RECEIVER_VGA_CONTROL_3 0x3334
-#define A_MAC_PORT_RX_LINKB_RECEIVER_DQCC_CONTROL_1 0x3338
-#define A_MAC_PORT_RX_LINKB_RECEIVER_POWER_MANAGEMENT_CONTROL 0x3338
-#define A_MAC_PORT_RX_LINKB_RECEIVER_IQAMP_CONTROL_1 0x333c
-#define A_MAC_PORT_RX_LINKB_RECEIVER_DQCC_CONTROL_3 0x3340
-#define A_MAC_PORT_RX_LINKB_RECEIVER_IQAMP_CONTROL_2 0x3340
-#define A_MAC_PORT_RX_LINKB_RECEIVER_DACAP_AND_DACAN_SELECTION 0x3344
-#define A_MAC_PORT_RX_LINKB_RECEIVER_DACAP_AND_DACAN 0x3348
-#define A_MAC_PORT_RX_LINKB_RECEIVER_DACA_MIN_AND_DACAZ 0x334c
-#define A_MAC_PORT_RX_LINKB_RECEIVER_DACA_MIN 0x334c
-#define A_MAC_PORT_RX_LINKB_RECEIVER_ADAC_CONTROL 0x3350
-#define A_MAC_PORT_RX_LINKB_RECEIVER_AC_COUPLING_CONTROL 0x3354
-#define A_MAC_PORT_RX_LINKB_RECEIVER_AC_COUPLING_VALUE 0x3358
-#define A_MAC_PORT_RX_LINKB_DFE_H1_LOCAL_OFFSET_ODD2_EVN2 0x335c
-#define A_MAC_PORT_RX_LINKB_DFE_H1H2H3_LOCAL_OFFSET 0x335c
-#define A_MAC_PORT_RX_LINKB_DFE_H1_LOCAL_OFFSET_ODD3_EVN3 0x3360
-#define A_MAC_PORT_RX_LINKB_DFE_H1H2H3_LOCAL_OFFSET_VALUE 0x3360
-#define A_MAC_PORT_RX_LINKB_DFE_H1_LOCAL_OFFSET_ODD4_EVN4 0x3364
-#define A_MAC_PORT_RX_LINKB_PEAKED_INTEGRATOR 0x3364
-#define A_MAC_PORT_RX_LINKB_CDR_ANALOG_SWITCH 0x3368
-#define A_MAC_PORT_RX_LINKB_PEAKING_AMPLIFIER_INTIALIZATION_CONTROL 0x336c
-#define A_MAC_PORT_RX_LINKB_DYNAMIC_AMPLITUDE_CENTERING_DAC_AND_DYNAMIC_PEAKING_CONTROL_DPC 0x3370
-#define A_MAC_PORT_RX_LINKB_DYNAMIC_DATA_CENTERING_DDC 0x3374
-
-#define S_T6_ODEC 0
-#define M_T6_ODEC 0xfU
-#define V_T6_ODEC(x) ((x) << S_T6_ODEC)
-#define G_T6_ODEC(x) (((x) >> S_T6_ODEC) & M_T6_ODEC)
-
-#define A_MAC_PORT_RX_LINKB_RECEIVER_INTERNAL_STATUS 0x3378
-
-#define S_RX_LINKB_ACCCMP_RIS 11
-#define V_RX_LINKB_ACCCMP_RIS(x) ((x) << S_RX_LINKB_ACCCMP_RIS)
-#define F_RX_LINKB_ACCCMP_RIS V_RX_LINKB_ACCCMP_RIS(1U)
-
-#define A_MAC_PORT_RX_LINKB_DFE_FUNCTION_CONTROL_1 0x337c
-#define A_MAC_PORT_RX_LINKB_DFE_FUNCTION_CONTROL_2 0x3380
-#define A_MAC_PORT_RX_LINKB_DFE_OFFSET_EVN1_EVN2 0x3384
-#define A_MAC_PORT_RX_LINKB_DFE_OFFSET_CHANNEL 0x3384
-#define A_MAC_PORT_RX_LINKB_DFE_OFFSET_ODD1_ODD2 0x3388
-#define A_MAC_PORT_RX_LINKB_DFE_OFFSET_VALUE 0x3388
-#define A_MAC_PORT_RX_LINKB_DFE_OFFSET_EVN3_EVN4 0x338c
-#define A_MAC_PORT_RX_LINKB_H_COEFFICIENBT_BIST 0x338c
-#define A_MAC_PORT_RX_LINKB_DFE_OFFSET_ODD3_ODD4 0x3390
-#define A_MAC_PORT_RX_LINKB_AC_CAPACITOR_BIST 0x3390
-
-#define S_RX_LINKB_ACCCMP_BIST 13
-#define V_RX_LINKB_ACCCMP_BIST(x) ((x) << S_RX_LINKB_ACCCMP_BIST)
-#define F_RX_LINKB_ACCCMP_BIST V_RX_LINKB_ACCCMP_BIST(1U)
-
-#define A_MAC_PORT_RX_LINKB_DFE_E0_AND_E1_OFFSET 0x3394
-#define A_MAC_PORT_RX_LINKB_RECEIVER_LOFF_CONTROL 0x3398
-#define A_MAC_PORT_RX_LINKB_RECEIVER_LOFF_CONTROL_REGISTER 0x3398
-#define A_MAC_PORT_RX_LINKB_RECEIVER_SIGDET_CONTROL 0x339c
-#define A_MAC_PORT_RX_LINKB_RECEIVER_ANALOG_CONTROL_SWITCH 0x33a0
-#define A_MAC_PORT_RX_LINKB_INTEGRATOR_DAC_OFFSET 0x33a4
-#define A_MAC_PORT_RX_LINKB_DIGITAL_EYE_CONTROL 0x33a8
-#define A_MAC_PORT_RX_LINKB_DIGITAL_EYE_METRICS 0x33ac
-
-#define S_T6_EMMD 3
-#define M_T6_EMMD 0x3U
-#define V_T6_EMMD(x) ((x) << S_T6_EMMD)
-#define G_T6_EMMD(x) (((x) >> S_T6_EMMD) & M_T6_EMMD)
-
-#define S_T6_EMBRDY 2
-#define V_T6_EMBRDY(x) ((x) << S_T6_EMBRDY)
-#define F_T6_EMBRDY V_T6_EMBRDY(1U)
-
-#define S_T6_EMBUMP 1
-#define V_T6_EMBUMP(x) ((x) << S_T6_EMBUMP)
-#define F_T6_EMBUMP V_T6_EMBUMP(1U)
-
-#define A_MAC_PORT_RX_LINKB_DIGITAL_EYE_METRICS_ERROR_COUNT 0x33b0
-#define A_MAC_PORT_RX_LINKB_DIGITAL_EYE_METRICS_PDF_EYE_COUNT 0x33b4
-#define A_MAC_PORT_RX_LINKB_DIGITAL_EYE_METRICS_PATTERN_LENGTH 0x33b8
-#define A_MAC_PORT_RX_LINKB_DFE_FUNCTION_CONTROL_3 0x33bc
-#define A_MAC_PORT_RX_LINKB_DFE_TAP_ENABLE 0x33c0
-#define A_MAC_PORT_RX_LINKB_DFE_TAP_CONTROL 0x33c0
-
-#define S_RX_LINKB_INDEX_DFE_TC 0
-#define M_RX_LINKB_INDEX_DFE_TC 0xfU
-#define V_RX_LINKB_INDEX_DFE_TC(x) ((x) << S_RX_LINKB_INDEX_DFE_TC)
-#define G_RX_LINKB_INDEX_DFE_TC(x) (((x) >> S_RX_LINKB_INDEX_DFE_TC) & M_RX_LINKB_INDEX_DFE_TC)
-
-#define A_MAC_PORT_RX_LINKB_DFE_H1 0x33c4
-#define A_MAC_PORT_RX_LINKB_DFE_TAP 0x33c4
-
-#define S_RX_LINKB_INDEX_DFE_TAP 0
-#define M_RX_LINKB_INDEX_DFE_TAP 0xfU
-#define V_RX_LINKB_INDEX_DFE_TAP(x) ((x) << S_RX_LINKB_INDEX_DFE_TAP)
-#define G_RX_LINKB_INDEX_DFE_TAP(x) (((x) >> S_RX_LINKB_INDEX_DFE_TAP) & M_RX_LINKB_INDEX_DFE_TAP)
-
-#define A_MAC_PORT_RX_LINKB_DFE_H2 0x33c8
-#define A_MAC_PORT_RX_LINKB_DFE_H3 0x33cc
-#define A_MAC_PORT_RX_LINKB_DFE_H4 0x33d0
-#define A_MAC_PORT_RX_LINKB_DFE_H5 0x33d4
-#define A_MAC_PORT_RX_LINKB_DFE_H6_AND_H7 0x33d8
-#define A_MAC_PORT_RX_LINKB_DFE_H8_AND_H9 0x33dc
-#define A_MAC_PORT_RX_LINKB_DFE_H10_AND_H11 0x33e0
-#define A_MAC_PORT_RX_LINKB_DFE_H12 0x33e4
-#define A_MAC_PORT_RX_LINKB_RECEIVER_INTERNAL_STATUS_2 0x33e4
-#define A_MAC_PORT_RX_LINKB_AC_COUPLING_CURRENT_SOURCE_ADJUST 0x33e8
-#define A_MAC_PORT_RX_LINKB_RECEIVER_DCD_CONTROL 0x33ec
-#define A_MAC_PORT_RX_LINKB_RECEIVER_DCC_CONTROL 0x33f0
-
-#define S_RX_LINKB_DCCSTEP_RXCTL 10
-#define M_RX_LINKB_DCCSTEP_RXCTL 0x3U
-#define V_RX_LINKB_DCCSTEP_RXCTL(x) ((x) << S_RX_LINKB_DCCSTEP_RXCTL)
-#define G_RX_LINKB_DCCSTEP_RXCTL(x) (((x) >> S_RX_LINKB_DCCSTEP_RXCTL) & M_RX_LINKB_DCCSTEP_RXCTL)
-
-#define S_RX_LINKB_DCCLOCK_RXCTL 8
-#define V_RX_LINKB_DCCLOCK_RXCTL(x) ((x) << S_RX_LINKB_DCCLOCK_RXCTL)
-#define F_RX_LINKB_DCCLOCK_RXCTL V_RX_LINKB_DCCLOCK_RXCTL(1U)
-
-#define A_MAC_PORT_RX_LINKB_RECEIVER_QCC_CONTROL 0x33f4
-#define A_MAC_PORT_RX_LINKB_RECEIVER_MACRO_TEST_CONTROL_2 0x33f8
-#define A_MAC_PORT_RX_LINKB_RECEIVER_MACRO_TEST_CONTROL_REGISTER_2 0x33f8
-#define A_MAC_PORT_RX_LINKB_RECEIVER_MACRO_TEST_CONTROL_1 0x33fc
-#define A_MAC_PORT_TX_LINKC_TRANSMIT_CONFIGURATION_MODE 0x3400
-
-#define S_T6_T5_TX_RXLOOP 5
-#define V_T6_T5_TX_RXLOOP(x) ((x) << S_T6_T5_TX_RXLOOP)
-#define F_T6_T5_TX_RXLOOP V_T6_T5_TX_RXLOOP(1U)
-
-#define S_T6_T5_TX_BWSEL 2
-#define M_T6_T5_TX_BWSEL 0x3U
-#define V_T6_T5_TX_BWSEL(x) ((x) << S_T6_T5_TX_BWSEL)
-#define G_T6_T5_TX_BWSEL(x) (((x) >> S_T6_T5_TX_BWSEL) & M_T6_T5_TX_BWSEL)
-
-#define A_MAC_PORT_TX_LINKC_TRANSMIT_TEST_CONTROL 0x3404
-
-#define S_T6_ERROR 9
-#define V_T6_ERROR(x) ((x) << S_T6_ERROR)
-#define F_T6_ERROR V_T6_ERROR(1U)
-
-#define A_MAC_PORT_TX_LINKC_TRANSMIT_COEFFICIENT_CONTROL 0x3408
-#define A_MAC_PORT_TX_LINKC_TRANSMIT_DRIVER_MODE_CONTROL 0x340c
-#define A_MAC_PORT_TX_LINKC_TRANSMIT_DRIVER_OVERRIDE_CONTROL 0x3410
-#define A_MAC_PORT_TX_LINKC_TRANSMIT_DCLK_ROTATOR_OVERRIDE 0x3414
-#define A_MAC_PORT_TX_LINKC_TRANSMIT_IMPEDANCE_CALIBRATION_OVERRIDE 0x3418
-
-#define S_T6_CALSSTN 8
-#define M_T6_CALSSTN 0x3fU
-#define V_T6_CALSSTN(x) ((x) << S_T6_CALSSTN)
-#define G_T6_CALSSTN(x) (((x) >> S_T6_CALSSTN) & M_T6_CALSSTN)
-
-#define S_T6_CALSSTP 0
-#define M_T6_CALSSTP 0x3fU
-#define V_T6_CALSSTP(x) ((x) << S_T6_CALSSTP)
-#define G_T6_CALSSTP(x) (((x) >> S_T6_CALSSTP) & M_T6_CALSSTP)
-
-#define A_MAC_PORT_TX_LINKC_TRANSMIT_DCLK_DRIFT_TOLERANCE 0x341c
-
-#define S_T6_DRTOL 2
-#define M_T6_DRTOL 0x7U
-#define V_T6_DRTOL(x) ((x) << S_T6_DRTOL)
-#define G_T6_DRTOL(x) (((x) >> S_T6_DRTOL) & M_T6_DRTOL)
-
-#define A_MAC_PORT_TX_LINKC_TRANSMIT_TAP_0_COEFFICIENT 0x3420
-
-#define S_T6_NXTT0 0
-#define M_T6_NXTT0 0x3fU
-#define V_T6_NXTT0(x) ((x) << S_T6_NXTT0)
-#define G_T6_NXTT0(x) (((x) >> S_T6_NXTT0) & M_T6_NXTT0)
-
-#define A_MAC_PORT_TX_LINKC_TRANSMIT_TAP_1_COEFFICIENT 0x3424
-#define A_MAC_PORT_TX_LINKC_TRANSMIT_TAP_2_COEFFICIENT 0x3428
-
-#define S_T6_NXTT2 0
-#define M_T6_NXTT2 0x3fU
-#define V_T6_NXTT2(x) ((x) << S_T6_NXTT2)
-#define G_T6_NXTT2(x) (((x) >> S_T6_NXTT2) & M_T6_NXTT2)
-
-#define A_MAC_PORT_TX_LINKC_TRANSMIT_TAP_3_COEFFICIENT 0x342c
-#define A_MAC_PORT_TX_LINKC_TRANSMIT_AMPLITUDE 0x3430
-#define A_MAC_PORT_TX_LINKC_TRANSMIT_POLARITY 0x3434
-
-#define S_T6_NXTPOL 0
-#define M_T6_NXTPOL 0xfU
-#define V_T6_NXTPOL(x) ((x) << S_T6_NXTPOL)
-#define G_T6_NXTPOL(x) (((x) >> S_T6_NXTPOL) & M_T6_NXTPOL)
-
-#define A_MAC_PORT_TX_LINKC_TRANSMIT_802_3AP_ADAPTIVE_EQUALIZATION_COMMAND 0x3438
-
-#define S_T6_C0UPDT 6
-#define M_T6_C0UPDT 0x3U
-#define V_T6_C0UPDT(x) ((x) << S_T6_C0UPDT)
-#define G_T6_C0UPDT(x) (((x) >> S_T6_C0UPDT) & M_T6_C0UPDT)
-
-#define S_T6_C2UPDT 2
-#define M_T6_C2UPDT 0x3U
-#define V_T6_C2UPDT(x) ((x) << S_T6_C2UPDT)
-#define G_T6_C2UPDT(x) (((x) >> S_T6_C2UPDT) & M_T6_C2UPDT)
-
-#define S_T6_C1UPDT 0
-#define M_T6_C1UPDT 0x3U
-#define V_T6_C1UPDT(x) ((x) << S_T6_C1UPDT)
-#define G_T6_C1UPDT(x) (((x) >> S_T6_C1UPDT) & M_T6_C1UPDT)
-
-#define A_MAC_PORT_TX_LINKC_TRANSMIT_802_3AP_ADAPTIVE_EQUALIZATION_STATUS 0x343c
-
-#define S_T6_C0STAT 6
-#define M_T6_C0STAT 0x3U
-#define V_T6_C0STAT(x) ((x) << S_T6_C0STAT)
-#define G_T6_C0STAT(x) (((x) >> S_T6_C0STAT) & M_T6_C0STAT)
-
-#define S_T6_C2STAT 2
-#define M_T6_C2STAT 0x3U
-#define V_T6_C2STAT(x) ((x) << S_T6_C2STAT)
-#define G_T6_C2STAT(x) (((x) >> S_T6_C2STAT) & M_T6_C2STAT)
-
-#define S_T6_C1STAT 0
-#define M_T6_C1STAT 0x3U
-#define V_T6_C1STAT(x) ((x) << S_T6_C1STAT)
-#define G_T6_C1STAT(x) (((x) >> S_T6_C1STAT) & M_T6_C1STAT)
-
-#define A_MAC_PORT_TX_LINKC_TRANSMIT_TAP_0_COEFFICIENT_OVERRIDE 0x3440
-#define A_MAC_PORT_TX_LINKC_TRANSMIT_AE_TAP_0_COEFFICIENT_OVERRIDE 0x3440
-#define A_MAC_PORT_TX_LINKC_TRANSMIT_TAP_1_COEFFICIENT_OVERRIDE 0x3444
-#define A_MAC_PORT_TX_LINKC_TRANSMIT_AE_TAP_1_COEFFICIENT_OVERRIDE 0x3444
-#define A_MAC_PORT_TX_LINKC_TRANSMIT_TAP_2_COEFFICIENT_OVERRIDE 0x3448
-#define A_MAC_PORT_TX_LINKC_TRANSMIT_AE_TAP_2_COEFFICIENT_OVERRIDE 0x3448
-#define A_MAC_PORT_TX_LINKC_TRANSMIT_AE_TAP_3_COEFFICIENT_OVERRIDE 0x344c
-#define A_MAC_PORT_TX_LINKC_TRANSMIT_APPLIED_TUNE_REGISTER 0x3450
-#define A_MAC_PORT_TX_LINKC_TRANSMIT_ANALOG_DIAGNOSTICS_REGISTER 0x3458
-#define A_MAC_PORT_TX_LINKC_TRANSMIT_TAP_0_COEFFICIENT_APPLIED 0x3460
-#define A_MAC_PORT_TX_LINKC_TRANSMIT_4X_SEGMENT_APPLIED 0x3460
-#define A_MAC_PORT_TX_LINKC_TRANSMIT_TAP_1_COEFFICIENT_APPLIED 0x3464
-#define A_MAC_PORT_TX_LINKC_TRANSMIT_2X_SEGMENT_APPLIED 0x3464
-#define A_MAC_PORT_TX_LINKC_TRANSMIT_TAP_2_COEFFICIENT_APPLIED 0x3468
-#define A_MAC_PORT_TX_LINKC_TRANSMIT_1X_SEGMENT_APPLIED 0x3468
-#define A_MAC_PORT_TX_LINKC_TRANSMIT_SEGMENT_4X_TERMINATION_APPLIED 0x346c
-#define A_MAC_PORT_TX_LINKC_TRANSMIT_SEGMENT_DISABLE_APPLIED_1 0x3470
-#define A_MAC_PORT_TX_LINKC_TRANSMIT_SEGMENT_2X1X_TERMINATION_APPLIED 0x3470
-#define A_MAC_PORT_TX_LINKC_TRANSMIT_SEGMENT_DISABLE_APPLIED_2 0x3474
-#define A_MAC_PORT_TX_LINKC_TRANSMIT_TAP_SIGN_APPLIED_REGISTER 0x3474
-#define A_MAC_PORT_TX_LINKC_TRANSMIT_EXTENDED_ADDRESS_DATA 0x3478
-#define A_MAC_PORT_TX_LINKC_TRANSMIT_EXTENDED_ADDRESS_ADDR 0x347c
-
-#define S_T6_XADDR 1
-#define M_T6_XADDR 0x1fU
-#define V_T6_XADDR(x) ((x) << S_T6_XADDR)
-#define G_T6_XADDR(x) (((x) >> S_T6_XADDR) & M_T6_XADDR)
-
-#define A_MAC_PORT_TX_LINKC_TRANSMIT_PATTERN_BUFFER_BYTES_1_0 0x3480
-#define A_MAC_PORT_TX_LINKC_TRANSMIT_PATTERN_BUFFER_BYTES_3_2 0x3484
-#define A_MAC_PORT_TX_LINKC_TRANSMIT_PATTERN_BUFFER_BYTE_4 0x3488
-#define A_MAC_PORT_TX_LINKC_TRANSMIT_PATTERN_BUFFER_BYTES_5_4 0x3488
-#define A_MAC_PORT_TX_LINKC_TRANSMIT_DCC_CONTROL 0x348c
-#define A_MAC_PORT_TX_LINKC_TRANSMIT_PATTERN_BUFFER_BYTES_7_6 0x348c
-#define A_MAC_PORT_TX_LINKC_TRANSMIT_DCC_OVERRIDE 0x3490
-#define A_MAC_PORT_TX_LINKC_TRANSMIT_DCC_APPLIED 0x3494
-#define A_MAC_PORT_TX_LINKC_TRANSMIT_DCC_TIME_OUT 0x3498
-#define A_MAC_PORT_TX_LINKC_TRANSMIT_802_3AZ_CONTROL 0x349c
-#define A_T6_MAC_PORT_TX_LINKC_TRANSMIT_DCC_CONTROL 0x34a0
-
-#define S_T6_DCCTIMEEN 13
-#define M_T6_DCCTIMEEN 0x3U
-#define V_T6_DCCTIMEEN(x) ((x) << S_T6_DCCTIMEEN)
-#define G_T6_DCCTIMEEN(x) (((x) >> S_T6_DCCTIMEEN) & M_T6_DCCTIMEEN)
-
-#define S_T6_DCCLOCK 11
-#define M_T6_DCCLOCK 0x3U
-#define V_T6_DCCLOCK(x) ((x) << S_T6_DCCLOCK)
-#define G_T6_DCCLOCK(x) (((x) >> S_T6_DCCLOCK) & M_T6_DCCLOCK)
-
-#define S_T6_DCCOFFSET 8
-#define M_T6_DCCOFFSET 0x7U
-#define V_T6_DCCOFFSET(x) ((x) << S_T6_DCCOFFSET)
-#define G_T6_DCCOFFSET(x) (((x) >> S_T6_DCCOFFSET) & M_T6_DCCOFFSET)
-
-#define S_TX_LINKC_DCCSTEP_CTL 6
-#define M_TX_LINKC_DCCSTEP_CTL 0x3U
-#define V_TX_LINKC_DCCSTEP_CTL(x) ((x) << S_TX_LINKC_DCCSTEP_CTL)
-#define G_TX_LINKC_DCCSTEP_CTL(x) (((x) >> S_TX_LINKC_DCCSTEP_CTL) & M_TX_LINKC_DCCSTEP_CTL)
-
-#define A_T6_MAC_PORT_TX_LINKC_TRANSMIT_DCC_OVERRIDE 0x34a4
-#define A_T6_MAC_PORT_TX_LINKC_TRANSMIT_DCC_APPLIED 0x34a8
-#define A_T6_MAC_PORT_TX_LINKC_TRANSMIT_DCC_TIME_OUT 0x34ac
-#define A_MAC_PORT_TX_LINKC_TRANSMIT_TAP_SIGN_OVERRIDE 0x34c0
-#define A_MAC_PORT_TX_LINKC_TRANSMIT_SEGMENT_4X_OVERRIDE 0x34c8
-#define A_MAC_PORT_TX_LINKC_TRANSMIT_SEGMENT_2X_OVERRIDE 0x34cc
-#define A_MAC_PORT_TX_LINKC_TRANSMIT_SEGMENT_1X_OVERRIDE 0x34d0
-#define A_MAC_PORT_TX_LINKC_TRANSMIT_TAP_SEGMENT_4X_TERMINATION_OVERRIDE 0x34d8
-#define A_MAC_PORT_TX_LINKC_TRANSMIT_TAP_SEGMENT_2X_TERMINATION_OVERRIDE 0x34dc
-#define A_MAC_PORT_TX_LINKC_TRANSMIT_TAP_SEGMENT_1X_TERMINATION_OVERRIDE 0x34e0
-#define A_MAC_PORT_TX_LINKC_TRANSMIT_MACRO_TEST_CONTROL_5 0x34ec
-#define A_MAC_PORT_TX_LINKC_TRANSMIT_MACRO_TEST_CONTROL_4 0x34f0
-
-#define S_T6_SDOVRD 0
-#define M_T6_SDOVRD 0xffffU
-#define V_T6_SDOVRD(x) ((x) << S_T6_SDOVRD)
-#define G_T6_SDOVRD(x) (((x) >> S_T6_SDOVRD) & M_T6_SDOVRD)
-
-#define A_MAC_PORT_TX_LINKC_TRANSMIT_MACRO_TEST_CONTROL_3 0x34f4
-#define A_MAC_PORT_TX_LINKC_TRANSMIT_MACRO_TEST_CONTROL_2 0x34f8
-#define A_MAC_PORT_TX_LINKC_TRANSMIT_MACRO_TEST_CONTROL_1 0x34fc
-
-#define S_T6_SDOVRDEN 15
-#define V_T6_SDOVRDEN(x) ((x) << S_T6_SDOVRDEN)
-#define F_T6_SDOVRDEN V_T6_SDOVRDEN(1U)
-
-#define A_MAC_PORT_TX_LINKD_TRANSMIT_CONFIGURATION_MODE 0x3500
-
-#define S_T6_T5_TX_RXLOOP 5
-#define V_T6_T5_TX_RXLOOP(x) ((x) << S_T6_T5_TX_RXLOOP)
-#define F_T6_T5_TX_RXLOOP V_T6_T5_TX_RXLOOP(1U)
-
-#define S_T6_T5_TX_BWSEL 2
-#define M_T6_T5_TX_BWSEL 0x3U
-#define V_T6_T5_TX_BWSEL(x) ((x) << S_T6_T5_TX_BWSEL)
-#define G_T6_T5_TX_BWSEL(x) (((x) >> S_T6_T5_TX_BWSEL) & M_T6_T5_TX_BWSEL)
-
-#define A_MAC_PORT_TX_LINKD_TRANSMIT_TEST_CONTROL 0x3504
-
-#define S_T6_ERROR 9
-#define V_T6_ERROR(x) ((x) << S_T6_ERROR)
-#define F_T6_ERROR V_T6_ERROR(1U)
-
-#define A_MAC_PORT_TX_LINKD_TRANSMIT_COEFFICIENT_CONTROL 0x3508
-#define A_MAC_PORT_TX_LINKD_TRANSMIT_DRIVER_MODE_CONTROL 0x350c
-#define A_MAC_PORT_TX_LINKD_TRANSMIT_DRIVER_OVERRIDE_CONTROL 0x3510
-#define A_MAC_PORT_TX_LINKD_TRANSMIT_DCLK_ROTATOR_OVERRIDE 0x3514
-#define A_MAC_PORT_TX_LINKD_TRANSMIT_IMPEDANCE_CALIBRATION_OVERRIDE 0x3518
-
-#define S_T6_CALSSTN 8
-#define M_T6_CALSSTN 0x3fU
-#define V_T6_CALSSTN(x) ((x) << S_T6_CALSSTN)
-#define G_T6_CALSSTN(x) (((x) >> S_T6_CALSSTN) & M_T6_CALSSTN)
-
-#define S_T6_CALSSTP 0
-#define M_T6_CALSSTP 0x3fU
-#define V_T6_CALSSTP(x) ((x) << S_T6_CALSSTP)
-#define G_T6_CALSSTP(x) (((x) >> S_T6_CALSSTP) & M_T6_CALSSTP)
-
-#define A_MAC_PORT_TX_LINKD_TRANSMIT_DCLK_DRIFT_TOLERANCE 0x351c
-
-#define S_T6_DRTOL 2
-#define M_T6_DRTOL 0x7U
-#define V_T6_DRTOL(x) ((x) << S_T6_DRTOL)
-#define G_T6_DRTOL(x) (((x) >> S_T6_DRTOL) & M_T6_DRTOL)
-
-#define A_MAC_PORT_TX_LINKD_TRANSMIT_TAP_0_COEFFICIENT 0x3520
-
-#define S_T6_NXTT0 0
-#define M_T6_NXTT0 0x3fU
-#define V_T6_NXTT0(x) ((x) << S_T6_NXTT0)
-#define G_T6_NXTT0(x) (((x) >> S_T6_NXTT0) & M_T6_NXTT0)
-
-#define A_MAC_PORT_TX_LINKD_TRANSMIT_TAP_1_COEFFICIENT 0x3524
-#define A_MAC_PORT_TX_LINKD_TRANSMIT_TAP_2_COEFFICIENT 0x3528
-
-#define S_T6_NXTT2 0
-#define M_T6_NXTT2 0x3fU
-#define V_T6_NXTT2(x) ((x) << S_T6_NXTT2)
-#define G_T6_NXTT2(x) (((x) >> S_T6_NXTT2) & M_T6_NXTT2)
-
-#define A_MAC_PORT_TX_LINKD_TRANSMIT_TAP_3_COEFFICIENT 0x352c
-#define A_MAC_PORT_TX_LINKD_TRANSMIT_AMPLITUDE 0x3530
-#define A_MAC_PORT_TX_LINKD_TRANSMIT_POLARITY 0x3534
-
-#define S_T6_NXTPOL 0
-#define M_T6_NXTPOL 0xfU
-#define V_T6_NXTPOL(x) ((x) << S_T6_NXTPOL)
-#define G_T6_NXTPOL(x) (((x) >> S_T6_NXTPOL) & M_T6_NXTPOL)
-
-#define A_MAC_PORT_TX_LINKD_TRANSMIT_802_3AP_ADAPTIVE_EQUALIZATION_COMMAND 0x3538
-
-#define S_T6_C0UPDT 6
-#define M_T6_C0UPDT 0x3U
-#define V_T6_C0UPDT(x) ((x) << S_T6_C0UPDT)
-#define G_T6_C0UPDT(x) (((x) >> S_T6_C0UPDT) & M_T6_C0UPDT)
-
-#define S_T6_C2UPDT 2
-#define M_T6_C2UPDT 0x3U
-#define V_T6_C2UPDT(x) ((x) << S_T6_C2UPDT)
-#define G_T6_C2UPDT(x) (((x) >> S_T6_C2UPDT) & M_T6_C2UPDT)
-
-#define S_T6_C1UPDT 0
-#define M_T6_C1UPDT 0x3U
-#define V_T6_C1UPDT(x) ((x) << S_T6_C1UPDT)
-#define G_T6_C1UPDT(x) (((x) >> S_T6_C1UPDT) & M_T6_C1UPDT)
-
-#define A_MAC_PORT_TX_LINKD_TRANSMIT_802_3AP_ADAPTIVE_EQUALIZATION_STATUS 0x353c
-
-#define S_T6_C0STAT 6
-#define M_T6_C0STAT 0x3U
-#define V_T6_C0STAT(x) ((x) << S_T6_C0STAT)
-#define G_T6_C0STAT(x) (((x) >> S_T6_C0STAT) & M_T6_C0STAT)
-
-#define S_T6_C2STAT 2
-#define M_T6_C2STAT 0x3U
-#define V_T6_C2STAT(x) ((x) << S_T6_C2STAT)
-#define G_T6_C2STAT(x) (((x) >> S_T6_C2STAT) & M_T6_C2STAT)
-
-#define S_T6_C1STAT 0
-#define M_T6_C1STAT 0x3U
-#define V_T6_C1STAT(x) ((x) << S_T6_C1STAT)
-#define G_T6_C1STAT(x) (((x) >> S_T6_C1STAT) & M_T6_C1STAT)
-
-#define A_MAC_PORT_TX_LINKD_TRANSMIT_TAP_0_COEFFICIENT_OVERRIDE 0x3540
-#define A_MAC_PORT_TX_LINKD_TRANSMIT_AE_TAP_0_COEFFICIENT_OVERRIDE 0x3540
-#define A_MAC_PORT_TX_LINKD_TRANSMIT_TAP_1_COEFFICIENT_OVERRIDE 0x3544
-#define A_MAC_PORT_TX_LINKD_TRANSMIT_AE_TAP_1_COEFFICIENT_OVERRIDE 0x3544
-#define A_MAC_PORT_TX_LINKD_TRANSMIT_TAP_2_COEFFICIENT_OVERRIDE 0x3548
-#define A_MAC_PORT_TX_LINKD_TRANSMIT_AE_TAP_2_COEFFICIENT_OVERRIDE 0x3548
-#define A_MAC_PORT_TX_LINKD_TRANSMIT_AE_TAP_3_COEFFICIENT_OVERRIDE 0x354c
-#define A_MAC_PORT_TX_LINKD_TRANSMIT_APPLIED_TUNE_REGISTER 0x3550
-#define A_MAC_PORT_TX_LINKD_TRANSMIT_ANALOG_DIAGNOSTICS_REGISTER 0x3558
-#define A_MAC_PORT_TX_LINKD_TRANSMIT_TAP_0_COEFFICIENT_APPLIED 0x3560
-#define A_MAC_PORT_TX_LINKD_TRANSMIT_4X_SEGMENT_APPLIED 0x3560
-#define A_MAC_PORT_TX_LINKD_TRANSMIT_TAP_1_COEFFICIENT_APPLIED 0x3564
-#define A_MAC_PORT_TX_LINKD_TRANSMIT_2X_SEGMENT_APPLIED 0x3564
-#define A_MAC_PORT_TX_LINKD_TRANSMIT_TAP_2_COEFFICIENT_APPLIED 0x3568
-#define A_MAC_PORT_TX_LINKD_TRANSMIT_1X_SEGMENT_APPLIED 0x3568
-#define A_MAC_PORT_TX_LINKD_TRANSMIT_SEGMENT_4X_TERMINATION_APPLIED 0x356c
-#define A_MAC_PORT_TX_LINKD_TRANSMIT_SEGMENT_DISABLE_APPLIED_1 0x3570
-#define A_MAC_PORT_TX_LINKD_TRANSMIT_SEGMENT_2X1X_TERMINATION_APPLIED 0x3570
-#define A_MAC_PORT_TX_LINKD_TRANSMIT_SEGMENT_DISABLE_APPLIED_2 0x3574
-#define A_MAC_PORT_TX_LINKD_TRANSMIT_TAP_SIGN_APPLIED_REGISTER 0x3574
-#define A_MAC_PORT_TX_LINKD_TRANSMIT_EXTENDED_ADDRESS_DATA 0x3578
-#define A_MAC_PORT_TX_LINKD_TRANSMIT_EXTENDED_ADDRESS_ADDR 0x357c
-
-#define S_T6_XADDR 1
-#define M_T6_XADDR 0x1fU
-#define V_T6_XADDR(x) ((x) << S_T6_XADDR)
-#define G_T6_XADDR(x) (((x) >> S_T6_XADDR) & M_T6_XADDR)
-
-#define A_MAC_PORT_TX_LINKD_TRANSMIT_PATTERN_BUFFER_BYTES_1_0 0x3580
-#define A_MAC_PORT_TX_LINKD_TRANSMIT_PATTERN_BUFFER_BYTES_3_2 0x3584
-#define A_MAC_PORT_TX_LINKD_TRANSMIT_PATTERN_BUFFER_BYTE_4 0x3588
-#define A_MAC_PORT_TX_LINKD_TRANSMIT_PATTERN_BUFFER_BYTES_5_4 0x3588
-#define A_MAC_PORT_TX_LINKD_TRANSMIT_DCC_CONTROL 0x358c
-#define A_MAC_PORT_TX_LINKD_TRANSMIT_PATTERN_BUFFER_BYTES_7_6 0x358c
-#define A_MAC_PORT_TX_LINKD_TRANSMIT_DCC_OVERRIDE 0x3590
-#define A_MAC_PORT_TX_LINKD_TRANSMIT_DCC_APPLIED 0x3594
-#define A_MAC_PORT_TX_LINKD_TRANSMIT_DCC_TIME_OUT 0x3598
-#define A_MAC_PORT_TX_LINKD_TRANSMIT_802_3AZ_CONTROL 0x359c
-#define A_T6_MAC_PORT_TX_LINKD_TRANSMIT_DCC_CONTROL 0x35a0
-
-#define S_T6_DCCTIMEEN 13
-#define M_T6_DCCTIMEEN 0x3U
-#define V_T6_DCCTIMEEN(x) ((x) << S_T6_DCCTIMEEN)
-#define G_T6_DCCTIMEEN(x) (((x) >> S_T6_DCCTIMEEN) & M_T6_DCCTIMEEN)
-
-#define S_T6_DCCLOCK 11
-#define M_T6_DCCLOCK 0x3U
-#define V_T6_DCCLOCK(x) ((x) << S_T6_DCCLOCK)
-#define G_T6_DCCLOCK(x) (((x) >> S_T6_DCCLOCK) & M_T6_DCCLOCK)
-
-#define S_T6_DCCOFFSET 8
-#define M_T6_DCCOFFSET 0x7U
-#define V_T6_DCCOFFSET(x) ((x) << S_T6_DCCOFFSET)
-#define G_T6_DCCOFFSET(x) (((x) >> S_T6_DCCOFFSET) & M_T6_DCCOFFSET)
-
-#define S_TX_LINKD_DCCSTEP_CTL 6
-#define M_TX_LINKD_DCCSTEP_CTL 0x3U
-#define V_TX_LINKD_DCCSTEP_CTL(x) ((x) << S_TX_LINKD_DCCSTEP_CTL)
-#define G_TX_LINKD_DCCSTEP_CTL(x) (((x) >> S_TX_LINKD_DCCSTEP_CTL) & M_TX_LINKD_DCCSTEP_CTL)
-
-#define A_T6_MAC_PORT_TX_LINKD_TRANSMIT_DCC_OVERRIDE 0x35a4
-#define A_T6_MAC_PORT_TX_LINKD_TRANSMIT_DCC_APPLIED 0x35a8
-#define A_T6_MAC_PORT_TX_LINKD_TRANSMIT_DCC_TIME_OUT 0x35ac
-#define A_MAC_PORT_TX_LINKD_TRANSMIT_TAP_SIGN_OVERRIDE 0x35c0
-#define A_MAC_PORT_TX_LINKD_TRANSMIT_SEGMENT_4X_OVERRIDE 0x35c8
-#define A_MAC_PORT_TX_LINKD_TRANSMIT_SEGMENT_2X_OVERRIDE 0x35cc
-#define A_MAC_PORT_TX_LINKD_TRANSMIT_SEGMENT_1X_OVERRIDE 0x35d0
-#define A_MAC_PORT_TX_LINKD_TRANSMIT_TAP_SEGMENT_4X_TERMINATION_OVERRIDE 0x35d8
-#define A_MAC_PORT_TX_LINKD_TRANSMIT_TAP_SEGMENT_2X_TERMINATION_OVERRIDE 0x35dc
-#define A_MAC_PORT_TX_LINKD_TRANSMIT_TAP_SEGMENT_1X_TERMINATION_OVERRIDE 0x35e0
-#define A_MAC_PORT_TX_LINKD_TRANSMIT_MACRO_TEST_CONTROL_5 0x35ec
-#define A_MAC_PORT_TX_LINKD_TRANSMIT_MACRO_TEST_CONTROL_4 0x35f0
-
-#define S_T6_SDOVRD 0
-#define M_T6_SDOVRD 0xffffU
-#define V_T6_SDOVRD(x) ((x) << S_T6_SDOVRD)
-#define G_T6_SDOVRD(x) (((x) >> S_T6_SDOVRD) & M_T6_SDOVRD)
-
-#define A_MAC_PORT_TX_LINKD_TRANSMIT_MACRO_TEST_CONTROL_3 0x35f4
-#define A_MAC_PORT_TX_LINKD_TRANSMIT_MACRO_TEST_CONTROL_2 0x35f8
-#define A_MAC_PORT_TX_LINKD_TRANSMIT_MACRO_TEST_CONTROL_1 0x35fc
-
-#define S_T6_SDOVRDEN 15
-#define V_T6_SDOVRDEN(x) ((x) << S_T6_SDOVRDEN)
-#define F_T6_SDOVRDEN V_T6_SDOVRDEN(1U)
-
-#define A_MAC_PORT_RX_LINKC_RECEIVER_CONFIGURATION_MODE 0x3600
-#define A_MAC_PORT_RX_LINKC_RECEIVER_TEST_CONTROL 0x3604
-#define A_MAC_PORT_RX_LINKC_PHASE_ROTATOR_CONTROL 0x3608
-#define A_MAC_PORT_RX_LINKC_PHASE_ROTATOR_OFFSET_CONTROL 0x360c
-
-#define S_T6_TMSCAL 8
-#define M_T6_TMSCAL 0x3U
-#define V_T6_TMSCAL(x) ((x) << S_T6_TMSCAL)
-#define G_T6_TMSCAL(x) (((x) >> S_T6_TMSCAL) & M_T6_TMSCAL)
-
-#define S_T6_APADJ 7
-#define V_T6_APADJ(x) ((x) << S_T6_APADJ)
-#define F_T6_APADJ V_T6_APADJ(1U)
-
-#define S_T6_RSEL 6
-#define V_T6_RSEL(x) ((x) << S_T6_RSEL)
-#define F_T6_RSEL V_T6_RSEL(1U)
-
-#define S_T6_PHOFFS 0
-#define M_T6_PHOFFS 0x3fU
-#define V_T6_PHOFFS(x) ((x) << S_T6_PHOFFS)
-#define G_T6_PHOFFS(x) (((x) >> S_T6_PHOFFS) & M_T6_PHOFFS)
-
-#define A_MAC_PORT_RX_LINKC_PHASE_ROTATOR_POSITION_1 0x3610
-#define A_MAC_PORT_RX_LINKC_PHASE_ROTATOR_POSITION_2 0x3614
-#define A_MAC_PORT_RX_LINKC_PHASE_ROTATOR_STATIC_PHASE_OFFSET_1 0x3618
-#define A_MAC_PORT_RX_LINKC_PHASE_ROTATOR_STATIC_PHASE_OFFSET_2 0x361c
-#define A_MAC_PORT_RX_LINKC_DFE_CONTROL 0x3620
-
-#define S_T6_SPIFMT 8
-#define M_T6_SPIFMT 0xfU
-#define V_T6_SPIFMT(x) ((x) << S_T6_SPIFMT)
-#define G_T6_SPIFMT(x) (((x) >> S_T6_SPIFMT) & M_T6_SPIFMT)
-
-#define A_MAC_PORT_RX_LINKC_DFE_SAMPLE_SNAPSHOT_1 0x3624
-#define A_MAC_PORT_RX_LINKC_DFE_SAMPLE_SNAPSHOT_2 0x3628
-#define A_MAC_PORT_RX_LINKC_RECEIVER_VGA_CONTROL_1 0x362c
-
-#define S_T6_WRAPSEL 15
-#define V_T6_WRAPSEL(x) ((x) << S_T6_WRAPSEL)
-#define F_T6_WRAPSEL V_T6_WRAPSEL(1U)
-
-#define S_T6_PEAK 9
-#define M_T6_PEAK 0x1fU
-#define V_T6_PEAK(x) ((x) << S_T6_PEAK)
-#define G_T6_PEAK(x) (((x) >> S_T6_PEAK) & M_T6_PEAK)
-
-#define A_MAC_PORT_RX_LINKC_RECEIVER_VGA_CONTROL_2 0x3630
-
-#define S_T6_T5VGAIN 0
-#define M_T6_T5VGAIN 0x7fU
-#define V_T6_T5VGAIN(x) ((x) << S_T6_T5VGAIN)
-#define G_T6_T5VGAIN(x) (((x) >> S_T6_T5VGAIN) & M_T6_T5VGAIN)
-
-#define A_MAC_PORT_RX_LINKC_RECEIVER_VGA_CONTROL_3 0x3634
-#define A_MAC_PORT_RX_LINKC_RECEIVER_DQCC_CONTROL_1 0x3638
-#define A_MAC_PORT_RX_LINKC_RECEIVER_POWER_MANAGEMENT_CONTROL 0x3638
-#define A_MAC_PORT_RX_LINKC_RECEIVER_IQAMP_CONTROL_1 0x363c
-#define A_MAC_PORT_RX_LINKC_RECEIVER_DQCC_CONTROL_3 0x3640
-#define A_MAC_PORT_RX_LINKC_RECEIVER_IQAMP_CONTROL_2 0x3640
-#define A_MAC_PORT_RX_LINKC_RECEIVER_DACAP_AND_DACAN_SELECTION 0x3644
-#define A_MAC_PORT_RX_LINKC_RECEIVER_DACAP_AND_DACAN 0x3648
-#define A_MAC_PORT_RX_LINKC_RECEIVER_DACA_MIN_AND_DACAZ 0x364c
-#define A_MAC_PORT_RX_LINKC_RECEIVER_DACA_MIN 0x364c
-#define A_MAC_PORT_RX_LINKC_RECEIVER_ADAC_CONTROL 0x3650
-#define A_MAC_PORT_RX_LINKC_RECEIVER_AC_COUPLING_CONTROL 0x3654
-#define A_MAC_PORT_RX_LINKC_RECEIVER_AC_COUPLING_VALUE 0x3658
-#define A_MAC_PORT_RX_LINKC_DFE_H1_LOCAL_OFFSET_ODD2_EVN2 0x365c
-#define A_MAC_PORT_RX_LINKC_DFE_H1H2H3_LOCAL_OFFSET 0x365c
-#define A_MAC_PORT_RX_LINKC_DFE_H1_LOCAL_OFFSET_ODD3_EVN3 0x3660
-#define A_MAC_PORT_RX_LINKC_DFE_H1H2H3_LOCAL_OFFSET_VALUE 0x3660
-#define A_MAC_PORT_RX_LINKC_DFE_H1_LOCAL_OFFSET_ODD4_EVN4 0x3664
-#define A_MAC_PORT_RX_LINKC_PEAKED_INTEGRATOR 0x3664
-#define A_MAC_PORT_RX_LINKC_CDR_ANALOG_SWITCH 0x3668
-#define A_MAC_PORT_RX_LINKC_PEAKING_AMPLIFIER_INTIALIZATION_CONTROL 0x366c
-#define A_MAC_PORT_RX_LINKC_DYNAMIC_AMPLITUDE_CENTERING_DAC_AND_DYNAMIC_PEAKING_CONTROL_DPC 0x3670
-#define A_MAC_PORT_RX_LINKC_DYNAMIC_DATA_CENTERING_DDC 0x3674
-
-#define S_T6_ODEC 0
-#define M_T6_ODEC 0xfU
-#define V_T6_ODEC(x) ((x) << S_T6_ODEC)
-#define G_T6_ODEC(x) (((x) >> S_T6_ODEC) & M_T6_ODEC)
-
-#define A_MAC_PORT_RX_LINKC_RECEIVER_INTERNAL_STATUS 0x3678
-
-#define S_RX_LINKC_ACCCMP_RIS 11
-#define V_RX_LINKC_ACCCMP_RIS(x) ((x) << S_RX_LINKC_ACCCMP_RIS)
-#define F_RX_LINKC_ACCCMP_RIS V_RX_LINKC_ACCCMP_RIS(1U)
-
-#define A_MAC_PORT_RX_LINKC_DFE_FUNCTION_CONTROL_1 0x367c
-#define A_MAC_PORT_RX_LINKC_DFE_FUNCTION_CONTROL_2 0x3680
-#define A_MAC_PORT_RX_LINKC_DFE_OFFSET_EVN1_EVN2 0x3684
-#define A_MAC_PORT_RX_LINKC_DFE_OFFSET_CHANNEL 0x3684
-#define A_MAC_PORT_RX_LINKC_DFE_OFFSET_ODD1_ODD2 0x3688
-#define A_MAC_PORT_RX_LINKC_DFE_OFFSET_VALUE 0x3688
-#define A_MAC_PORT_RX_LINKC_DFE_OFFSET_EVN3_EVN4 0x368c
-#define A_MAC_PORT_RX_LINKC_H_COEFFICIENBT_BIST 0x368c
-#define A_MAC_PORT_RX_LINKC_DFE_OFFSET_ODD3_ODD4 0x3690
-#define A_MAC_PORT_RX_LINKC_AC_CAPACITOR_BIST 0x3690
-
-#define S_RX_LINKC_ACCCMP_BIST 13
-#define V_RX_LINKC_ACCCMP_BIST(x) ((x) << S_RX_LINKC_ACCCMP_BIST)
-#define F_RX_LINKC_ACCCMP_BIST V_RX_LINKC_ACCCMP_BIST(1U)
-
-#define A_MAC_PORT_RX_LINKC_DFE_E0_AND_E1_OFFSET 0x3694
-#define A_MAC_PORT_RX_LINKC_RECEIVER_LOFF_CONTROL 0x3698
-#define A_MAC_PORT_RX_LINKC_RECEIVER_LOFF_CONTROL_REGISTER 0x3698
-#define A_MAC_PORT_RX_LINKC_RECEIVER_SIGDET_CONTROL 0x369c
-#define A_MAC_PORT_RX_LINKC_RECEIVER_ANALOG_CONTROL_SWITCH 0x36a0
-#define A_MAC_PORT_RX_LINKC_INTEGRATOR_DAC_OFFSET 0x36a4
-#define A_MAC_PORT_RX_LINKC_DIGITAL_EYE_CONTROL 0x36a8
-#define A_MAC_PORT_RX_LINKC_DIGITAL_EYE_METRICS 0x36ac
-
-#define S_T6_EMMD 3
-#define M_T6_EMMD 0x3U
-#define V_T6_EMMD(x) ((x) << S_T6_EMMD)
-#define G_T6_EMMD(x) (((x) >> S_T6_EMMD) & M_T6_EMMD)
-
-#define S_T6_EMBRDY 2
-#define V_T6_EMBRDY(x) ((x) << S_T6_EMBRDY)
-#define F_T6_EMBRDY V_T6_EMBRDY(1U)
-
-#define S_T6_EMBUMP 1
-#define V_T6_EMBUMP(x) ((x) << S_T6_EMBUMP)
-#define F_T6_EMBUMP V_T6_EMBUMP(1U)
-
-#define A_MAC_PORT_RX_LINKC_DIGITAL_EYE_METRICS_ERROR_COUNT 0x36b0
-#define A_MAC_PORT_RX_LINKC_DIGITAL_EYE_METRICS_PDF_EYE_COUNT 0x36b4
-#define A_MAC_PORT_RX_LINKC_DIGITAL_EYE_METRICS_PATTERN_LENGTH 0x36b8
-#define A_MAC_PORT_RX_LINKC_DFE_FUNCTION_CONTROL_3 0x36bc
-#define A_MAC_PORT_RX_LINKC_DFE_TAP_ENABLE 0x36c0
-#define A_MAC_PORT_RX_LINKC_DFE_TAP_CONTROL 0x36c0
-
-#define S_RX_LINKC_INDEX_DFE_TC 0
-#define M_RX_LINKC_INDEX_DFE_TC 0xfU
-#define V_RX_LINKC_INDEX_DFE_TC(x) ((x) << S_RX_LINKC_INDEX_DFE_TC)
-#define G_RX_LINKC_INDEX_DFE_TC(x) (((x) >> S_RX_LINKC_INDEX_DFE_TC) & M_RX_LINKC_INDEX_DFE_TC)
-
-#define A_MAC_PORT_RX_LINKC_DFE_H1 0x36c4
-#define A_MAC_PORT_RX_LINKC_DFE_TAP 0x36c4
-
-#define S_RX_LINKC_INDEX_DFE_TAP 0
-#define M_RX_LINKC_INDEX_DFE_TAP 0xfU
-#define V_RX_LINKC_INDEX_DFE_TAP(x) ((x) << S_RX_LINKC_INDEX_DFE_TAP)
-#define G_RX_LINKC_INDEX_DFE_TAP(x) (((x) >> S_RX_LINKC_INDEX_DFE_TAP) & M_RX_LINKC_INDEX_DFE_TAP)
-
-#define A_MAC_PORT_RX_LINKC_DFE_H2 0x36c8
-#define A_MAC_PORT_RX_LINKC_DFE_H3 0x36cc
-#define A_MAC_PORT_RX_LINKC_DFE_H4 0x36d0
-#define A_MAC_PORT_RX_LINKC_DFE_H5 0x36d4
-#define A_MAC_PORT_RX_LINKC_DFE_H6_AND_H7 0x36d8
-#define A_MAC_PORT_RX_LINKC_DFE_H8_AND_H9 0x36dc
-#define A_MAC_PORT_RX_LINKC_DFE_H10_AND_H11 0x36e0
-#define A_MAC_PORT_RX_LINKC_DFE_H12 0x36e4
-#define A_MAC_PORT_RX_LINKC_RECEIVER_INTERNAL_STATUS_2 0x36e4
-#define A_MAC_PORT_RX_LINKC_AC_COUPLING_CURRENT_SOURCE_ADJUST 0x36e8
-#define A_MAC_PORT_RX_LINKC_RECEIVER_DCD_CONTROL 0x36ec
-#define A_MAC_PORT_RX_LINKC_RECEIVER_DCC_CONTROL 0x36f0
-
-#define S_RX_LINKC_DCCSTEP_RXCTL 10
-#define M_RX_LINKC_DCCSTEP_RXCTL 0x3U
-#define V_RX_LINKC_DCCSTEP_RXCTL(x) ((x) << S_RX_LINKC_DCCSTEP_RXCTL)
-#define G_RX_LINKC_DCCSTEP_RXCTL(x) (((x) >> S_RX_LINKC_DCCSTEP_RXCTL) & M_RX_LINKC_DCCSTEP_RXCTL)
-
-#define S_RX_LINKC_DCCLOCK_RXCTL 8
-#define V_RX_LINKC_DCCLOCK_RXCTL(x) ((x) << S_RX_LINKC_DCCLOCK_RXCTL)
-#define F_RX_LINKC_DCCLOCK_RXCTL V_RX_LINKC_DCCLOCK_RXCTL(1U)
-
-#define A_MAC_PORT_RX_LINKC_RECEIVER_QCC_CONTROL 0x36f4
-#define A_MAC_PORT_RX_LINKC_RECEIVER_MACRO_TEST_CONTROL_2 0x36f8
-#define A_MAC_PORT_RX_LINKC_RECEIVER_MACRO_TEST_CONTROL_REGISTER_2 0x36f8
-#define A_MAC_PORT_RX_LINKC_RECEIVER_MACRO_TEST_CONTROL_1 0x36fc
-#define A_MAC_PORT_RX_LINKD_RECEIVER_CONFIGURATION_MODE 0x3700
-#define A_MAC_PORT_RX_LINKD_RECEIVER_TEST_CONTROL 0x3704
-#define A_MAC_PORT_RX_LINKD_PHASE_ROTATOR_CONTROL 0x3708
-#define A_MAC_PORT_RX_LINKD_PHASE_ROTATOR_OFFSET_CONTROL 0x370c
-
-#define S_T6_TMSCAL 8
-#define M_T6_TMSCAL 0x3U
-#define V_T6_TMSCAL(x) ((x) << S_T6_TMSCAL)
-#define G_T6_TMSCAL(x) (((x) >> S_T6_TMSCAL) & M_T6_TMSCAL)
-
-#define S_T6_APADJ 7
-#define V_T6_APADJ(x) ((x) << S_T6_APADJ)
-#define F_T6_APADJ V_T6_APADJ(1U)
-
-#define S_T6_RSEL 6
-#define V_T6_RSEL(x) ((x) << S_T6_RSEL)
-#define F_T6_RSEL V_T6_RSEL(1U)
-
-#define S_T6_PHOFFS 0
-#define M_T6_PHOFFS 0x3fU
-#define V_T6_PHOFFS(x) ((x) << S_T6_PHOFFS)
-#define G_T6_PHOFFS(x) (((x) >> S_T6_PHOFFS) & M_T6_PHOFFS)
-
-#define A_MAC_PORT_RX_LINKD_PHASE_ROTATOR_POSITION_1 0x3710
-#define A_MAC_PORT_RX_LINKD_PHASE_ROTATOR_POSITION_2 0x3714
-#define A_MAC_PORT_RX_LINKD_PHASE_ROTATOR_STATIC_PHASE_OFFSET_1 0x3718
-#define A_MAC_PORT_RX_LINKD_PHASE_ROTATOR_STATIC_PHASE_OFFSET_2 0x371c
-#define A_MAC_PORT_RX_LINKD_DFE_CONTROL 0x3720
-
-#define S_T6_SPIFMT 8
-#define M_T6_SPIFMT 0xfU
-#define V_T6_SPIFMT(x) ((x) << S_T6_SPIFMT)
-#define G_T6_SPIFMT(x) (((x) >> S_T6_SPIFMT) & M_T6_SPIFMT)
-
-#define A_MAC_PORT_RX_LINKD_DFE_SAMPLE_SNAPSHOT_1 0x3724
-#define A_MAC_PORT_RX_LINKD_DFE_SAMPLE_SNAPSHOT_2 0x3728
-#define A_MAC_PORT_RX_LINKD_RECEIVER_VGA_CONTROL_1 0x372c
-
-#define S_T6_WRAPSEL 15
-#define V_T6_WRAPSEL(x) ((x) << S_T6_WRAPSEL)
-#define F_T6_WRAPSEL V_T6_WRAPSEL(1U)
-
-#define S_T6_PEAK 9
-#define M_T6_PEAK 0x1fU
-#define V_T6_PEAK(x) ((x) << S_T6_PEAK)
-#define G_T6_PEAK(x) (((x) >> S_T6_PEAK) & M_T6_PEAK)
-
-#define A_MAC_PORT_RX_LINKD_RECEIVER_VGA_CONTROL_2 0x3730
-
-#define S_T6_T5VGAIN 0
-#define M_T6_T5VGAIN 0x7fU
-#define V_T6_T5VGAIN(x) ((x) << S_T6_T5VGAIN)
-#define G_T6_T5VGAIN(x) (((x) >> S_T6_T5VGAIN) & M_T6_T5VGAIN)
-
-#define A_MAC_PORT_RX_LINKD_RECEIVER_VGA_CONTROL_3 0x3734
-#define A_MAC_PORT_RX_LINKD_RECEIVER_DQCC_CONTROL_1 0x3738
-#define A_MAC_PORT_RX_LINKD_RECEIVER_POWER_MANAGEMENT_CONTROL 0x3738
-#define A_MAC_PORT_RX_LINKD_RECEIVER_IQAMP_CONTROL_1 0x373c
-#define A_MAC_PORT_RX_LINKD_RECEIVER_DQCC_CONTROL_3 0x3740
-#define A_MAC_PORT_RX_LINKD_RECEIVER_IQAMP_CONTROL_2 0x3740
-#define A_MAC_PORT_RX_LINKD_RECEIVER_DACAP_AND_DACAN_SELECTION 0x3744
-#define A_MAC_PORT_RX_LINKD_RECEIVER_DACAP_AND_DACAN 0x3748
-#define A_MAC_PORT_RX_LINKD_RECEIVER_DACA_MIN_AND_DACAZ 0x374c
-#define A_MAC_PORT_RX_LINKD_RECEIVER_DACA_MIN 0x374c
-#define A_MAC_PORT_RX_LINKD_RECEIVER_ADAC_CONTROL 0x3750
-#define A_MAC_PORT_RX_LINKD_RECEIVER_AC_COUPLING_CONTROL 0x3754
-#define A_MAC_PORT_RX_LINKD_RECEIVER_AC_COUPLING_VALUE 0x3758
-#define A_MAC_PORT_RX_LINKD_DFE_H1_LOCAL_OFFSET_ODD2_EVN2 0x375c
-#define A_MAC_PORT_RX_LINKD_DFE_H1H2H3_LOCAL_OFFSET 0x375c
-#define A_MAC_PORT_RX_LINKD_DFE_H1_LOCAL_OFFSET_ODD3_EVN3 0x3760
-#define A_MAC_PORT_RX_LINKD_DFE_H1H2H3_LOCAL_OFFSET_VALUE 0x3760
-#define A_MAC_PORT_RX_LINKD_DFE_H1_LOCAL_OFFSET_ODD4_EVN4 0x3764
-#define A_MAC_PORT_RX_LINKD_PEAKED_INTEGRATOR 0x3764
-#define A_MAC_PORT_RX_LINKD_CDR_ANALOG_SWITCH 0x3768
-#define A_MAC_PORT_RX_LINKD_PEAKING_AMPLIFIER_INTIALIZATION_CONTROL 0x376c
-#define A_MAC_PORT_RX_LINKD_DYNAMIC_AMPLITUDE_CENTERING_DAC_AND_DYNAMIC_PEAKING_CONTROL_DPC 0x3770
-#define A_MAC_PORT_RX_LINKD_DYNAMIC_DATA_CENTERING_DDC 0x3774
-
-#define S_T6_ODEC 0
-#define M_T6_ODEC 0xfU
-#define V_T6_ODEC(x) ((x) << S_T6_ODEC)
-#define G_T6_ODEC(x) (((x) >> S_T6_ODEC) & M_T6_ODEC)
-
-#define A_MAC_PORT_RX_LINKD_RECEIVER_INTERNAL_STATUS 0x3778
-
-#define S_RX_LINKD_ACCCMP_RIS 11
-#define V_RX_LINKD_ACCCMP_RIS(x) ((x) << S_RX_LINKD_ACCCMP_RIS)
-#define F_RX_LINKD_ACCCMP_RIS V_RX_LINKD_ACCCMP_RIS(1U)
-
-#define A_MAC_PORT_RX_LINKD_DFE_FUNCTION_CONTROL_1 0x377c
-#define A_MAC_PORT_RX_LINKD_DFE_FUNCTION_CONTROL_2 0x3780
-#define A_MAC_PORT_RX_LINKD_DFE_OFFSET_EVN1_EVN2 0x3784
-#define A_MAC_PORT_RX_LINKD_DFE_OFFSET_CHANNEL 0x3784
-#define A_MAC_PORT_RX_LINKD_DFE_OFFSET_ODD1_ODD2 0x3788
-#define A_MAC_PORT_RX_LINKD_DFE_OFFSET_VALUE 0x3788
-#define A_MAC_PORT_RX_LINKD_DFE_OFFSET_EVN3_EVN4 0x378c
-#define A_MAC_PORT_RX_LINKD_H_COEFFICIENBT_BIST 0x378c
-#define A_MAC_PORT_RX_LINKD_DFE_OFFSET_ODD3_ODD4 0x3790
-#define A_MAC_PORT_RX_LINKD_AC_CAPACITOR_BIST 0x3790
-
-#define S_RX_LINKD_ACCCMP_BIST 13
-#define V_RX_LINKD_ACCCMP_BIST(x) ((x) << S_RX_LINKD_ACCCMP_BIST)
-#define F_RX_LINKD_ACCCMP_BIST V_RX_LINKD_ACCCMP_BIST(1U)
-
-#define A_MAC_PORT_RX_LINKD_DFE_E0_AND_E1_OFFSET 0x3794
-#define A_MAC_PORT_RX_LINKD_RECEIVER_LOFF_CONTROL 0x3798
-#define A_MAC_PORT_RX_LINKD_RECEIVER_LOFF_CONTROL_REGISTER 0x3798
-#define A_MAC_PORT_RX_LINKD_RECEIVER_SIGDET_CONTROL 0x379c
-#define A_MAC_PORT_RX_LINKD_RECEIVER_ANALOG_CONTROL_SWITCH 0x37a0
-#define A_MAC_PORT_RX_LINKD_INTEGRATOR_DAC_OFFSET 0x37a4
-#define A_MAC_PORT_RX_LINKD_DIGITAL_EYE_CONTROL 0x37a8
-#define A_MAC_PORT_RX_LINKD_DIGITAL_EYE_METRICS 0x37ac
-
-#define S_T6_EMMD 3
-#define M_T6_EMMD 0x3U
-#define V_T6_EMMD(x) ((x) << S_T6_EMMD)
-#define G_T6_EMMD(x) (((x) >> S_T6_EMMD) & M_T6_EMMD)
-
-#define S_T6_EMBRDY 2
-#define V_T6_EMBRDY(x) ((x) << S_T6_EMBRDY)
-#define F_T6_EMBRDY V_T6_EMBRDY(1U)
-
-#define S_T6_EMBUMP 1
-#define V_T6_EMBUMP(x) ((x) << S_T6_EMBUMP)
-#define F_T6_EMBUMP V_T6_EMBUMP(1U)
-
-#define A_MAC_PORT_RX_LINKD_DIGITAL_EYE_METRICS_ERROR_COUNT 0x37b0
-#define A_MAC_PORT_RX_LINKD_DIGITAL_EYE_METRICS_PDF_EYE_COUNT 0x37b4
-#define A_MAC_PORT_RX_LINKD_DIGITAL_EYE_METRICS_PATTERN_LENGTH 0x37b8
-#define A_MAC_PORT_RX_LINKD_DFE_FUNCTION_CONTROL_3 0x37bc
-#define A_MAC_PORT_RX_LINKD_DFE_TAP_ENABLE 0x37c0
-#define A_MAC_PORT_RX_LINKD_DFE_TAP_CONTROL 0x37c0
-
-#define S_RX_LINKD_INDEX_DFE_TC 0
-#define M_RX_LINKD_INDEX_DFE_TC 0xfU
-#define V_RX_LINKD_INDEX_DFE_TC(x) ((x) << S_RX_LINKD_INDEX_DFE_TC)
-#define G_RX_LINKD_INDEX_DFE_TC(x) (((x) >> S_RX_LINKD_INDEX_DFE_TC) & M_RX_LINKD_INDEX_DFE_TC)
-
-#define A_MAC_PORT_RX_LINKD_DFE_H1 0x37c4
-#define A_MAC_PORT_RX_LINKD_DFE_TAP 0x37c4
-
-#define S_RX_LINKD_INDEX_DFE_TAP 0
-#define M_RX_LINKD_INDEX_DFE_TAP 0xfU
-#define V_RX_LINKD_INDEX_DFE_TAP(x) ((x) << S_RX_LINKD_INDEX_DFE_TAP)
-#define G_RX_LINKD_INDEX_DFE_TAP(x) (((x) >> S_RX_LINKD_INDEX_DFE_TAP) & M_RX_LINKD_INDEX_DFE_TAP)
-
-#define A_MAC_PORT_RX_LINKD_DFE_H2 0x37c8
-#define A_MAC_PORT_RX_LINKD_DFE_H3 0x37cc
-#define A_MAC_PORT_RX_LINKD_DFE_H4 0x37d0
-#define A_MAC_PORT_RX_LINKD_DFE_H5 0x37d4
-#define A_MAC_PORT_RX_LINKD_DFE_H6_AND_H7 0x37d8
-#define A_MAC_PORT_RX_LINKD_DFE_H8_AND_H9 0x37dc
-#define A_MAC_PORT_RX_LINKD_DFE_H10_AND_H11 0x37e0
-#define A_MAC_PORT_RX_LINKD_DFE_H12 0x37e4
-#define A_MAC_PORT_RX_LINKD_RECEIVER_INTERNAL_STATUS_2 0x37e4
-#define A_MAC_PORT_RX_LINKD_AC_COUPLING_CURRENT_SOURCE_ADJUST 0x37e8
-#define A_MAC_PORT_RX_LINKD_RECEIVER_DCD_CONTROL 0x37ec
-#define A_MAC_PORT_RX_LINKD_RECEIVER_DCC_CONTROL 0x37f0
-
-#define S_RX_LINKD_DCCSTEP_RXCTL 10
-#define M_RX_LINKD_DCCSTEP_RXCTL 0x3U
-#define V_RX_LINKD_DCCSTEP_RXCTL(x) ((x) << S_RX_LINKD_DCCSTEP_RXCTL)
-#define G_RX_LINKD_DCCSTEP_RXCTL(x) (((x) >> S_RX_LINKD_DCCSTEP_RXCTL) & M_RX_LINKD_DCCSTEP_RXCTL)
-
-#define S_RX_LINKD_DCCLOCK_RXCTL 8
-#define V_RX_LINKD_DCCLOCK_RXCTL(x) ((x) << S_RX_LINKD_DCCLOCK_RXCTL)
-#define F_RX_LINKD_DCCLOCK_RXCTL V_RX_LINKD_DCCLOCK_RXCTL(1U)
-
-#define A_MAC_PORT_RX_LINKD_RECEIVER_QCC_CONTROL 0x37f4
-#define A_MAC_PORT_RX_LINKD_RECEIVER_MACRO_TEST_CONTROL_2 0x37f8
-#define A_MAC_PORT_RX_LINKD_RECEIVER_MACRO_TEST_CONTROL_REGISTER_2 0x37f8
-#define A_MAC_PORT_RX_LINKD_RECEIVER_MACRO_TEST_CONTROL_1 0x37fc
-#define A_MAC_PORT_ANALOG_TEST_MUX 0x3814
-#define A_MAC_PORT_BANDGAP_CONTROL 0x382c
-
-#define S_T5BGCTL 0
-#define M_T5BGCTL 0xfU
-#define V_T5BGCTL(x) ((x) << S_T5BGCTL)
-#define G_T5BGCTL(x) (((x) >> S_T5BGCTL) & M_T5BGCTL)
-
-#define A_MAC_PORT_PLLREFSEL_CONTROL 0x3854
-
-#define S_REFSEL 0
-#define M_REFSEL 0x7U
-#define V_REFSEL(x) ((x) << S_REFSEL)
-#define G_REFSEL(x) (((x) >> S_REFSEL) & M_REFSEL)
-
-#define A_MAC_PORT_REFISINK_CONTROL 0x3858
-
-#define S_REFISINK 0
-#define M_REFISINK 0x3fU
-#define V_REFISINK(x) ((x) << S_REFISINK)
-#define G_REFISINK(x) (((x) >> S_REFISINK) & M_REFISINK)
-
-#define A_MAC_PORT_REFISRC_CONTROL 0x385c
-
-#define S_REFISRC 0
-#define M_REFISRC 0x3fU
-#define V_REFISRC(x) ((x) << S_REFISRC)
-#define G_REFISRC(x) (((x) >> S_REFISRC) & M_REFISRC)
-
-#define A_MAC_PORT_REFVREG_CONTROL 0x3860
-
-#define S_REFVREG 0
-#define M_REFVREG 0x3fU
-#define V_REFVREG(x) ((x) << S_REFVREG)
-#define G_REFVREG(x) (((x) >> S_REFVREG) & M_REFVREG)
-
-#define A_MAC_PORT_VBGENDOC_CONTROL 0x3864
-
-#define S_BGCLKSEL 2
-#define V_BGCLKSEL(x) ((x) << S_BGCLKSEL)
-#define F_BGCLKSEL V_BGCLKSEL(1U)
-
-#define S_VBGENDOC 0
-#define M_VBGENDOC 0x3U
-#define V_VBGENDOC(x) ((x) << S_VBGENDOC)
-#define G_VBGENDOC(x) (((x) >> S_VBGENDOC) & M_VBGENDOC)
-
-#define A_MAC_PORT_VREFTUNE_CONTROL 0x3868
-
-#define S_VREFTUNE 0
-#define M_VREFTUNE 0xfU
-#define V_VREFTUNE(x) ((x) << S_VREFTUNE)
-#define G_VREFTUNE(x) (((x) >> S_VREFTUNE) & M_VREFTUNE)
-
-#define A_MAC_PORT_RESISTOR_CALIBRATION_CONTROL 0x3880
-
-#define S_RCCTL1 5
-#define V_RCCTL1(x) ((x) << S_RCCTL1)
-#define F_RCCTL1 V_RCCTL1(1U)
-
-#define S_RCCTL0 4
-#define V_RCCTL0(x) ((x) << S_RCCTL0)
-#define F_RCCTL0 V_RCCTL0(1U)
-
-#define S_RCAMP1 3
-#define V_RCAMP1(x) ((x) << S_RCAMP1)
-#define F_RCAMP1 V_RCAMP1(1U)
-
-#define S_RCAMP0 2
-#define V_RCAMP0(x) ((x) << S_RCAMP0)
-#define F_RCAMP0 V_RCAMP0(1U)
-
-#define S_RCAMPEN 1
-#define V_RCAMPEN(x) ((x) << S_RCAMPEN)
-#define F_RCAMPEN V_RCAMPEN(1U)
-
-#define S_RCRST 0
-#define V_RCRST(x) ((x) << S_RCRST)
-#define F_RCRST V_RCRST(1U)
-
-#define A_MAC_PORT_IMPEDENCE_CALIBRATION_CONTROL 0x3880
-
-#define S_FRCCAL_COMP 6
-#define V_FRCCAL_COMP(x) ((x) << S_FRCCAL_COMP)
-#define F_FRCCAL_COMP V_FRCCAL_COMP(1U)
-
-#define S_IC_FRCERR 5
-#define V_IC_FRCERR(x) ((x) << S_IC_FRCERR)
-#define F_IC_FRCERR V_IC_FRCERR(1U)
-
-#define S_CAL_BISTENAB 4
-#define V_CAL_BISTENAB(x) ((x) << S_CAL_BISTENAB)
-#define F_CAL_BISTENAB V_CAL_BISTENAB(1U)
-
-#define S_RCAL_RESET 0
-#define V_RCAL_RESET(x) ((x) << S_RCAL_RESET)
-#define F_RCAL_RESET V_RCAL_RESET(1U)
-
-#define A_MAC_PORT_RESISTOR_CALIBRATION_STATUS_1 0x3884
-
-#define S_RCERR 1
-#define V_RCERR(x) ((x) << S_RCERR)
-#define F_RCERR V_RCERR(1U)
-
-#define S_RCCOMP 0
-#define V_RCCOMP(x) ((x) << S_RCCOMP)
-#define F_RCCOMP V_RCCOMP(1U)
-
-#define A_MAC_PORT_IMPEDENCE_CALIBRATION_STATUS_1 0x3884
-
-#define S_RCALBENAB 3
-#define V_RCALBENAB(x) ((x) << S_RCALBENAB)
-#define F_RCALBENAB V_RCALBENAB(1U)
-
-#define S_RCALBUSY 2
-#define V_RCALBUSY(x) ((x) << S_RCALBUSY)
-#define F_RCALBUSY V_RCALBUSY(1U)
-
-#define S_RCALERR 1
-#define V_RCALERR(x) ((x) << S_RCALERR)
-#define F_RCALERR V_RCALERR(1U)
-
-#define S_RCALCOMP 0
-#define V_RCALCOMP(x) ((x) << S_RCALCOMP)
-#define F_RCALCOMP V_RCALCOMP(1U)
-
-#define A_MAC_PORT_RESISTOR_CALIBRATION_STATUS_2 0x3888
-
-#define S_RESREG2 0
-#define M_RESREG2 0xffU
-#define V_RESREG2(x) ((x) << S_RESREG2)
-#define G_RESREG2(x) (((x) >> S_RESREG2) & M_RESREG2)
-
-#define A_MAC_PORT_IMPEDENCE_CALIBRATION_STATUS_2 0x3888
-
-#define S_T6_RESREG2 0
-#define M_T6_RESREG2 0x3fU
-#define V_T6_RESREG2(x) ((x) << S_T6_RESREG2)
-#define G_T6_RESREG2(x) (((x) >> S_T6_RESREG2) & M_T6_RESREG2)
-
-#define A_MAC_PORT_RESISTOR_CALIBRATION_STATUS_3 0x388c
-
-#define S_RESREG3 0
-#define M_RESREG3 0xffU
-#define V_RESREG3(x) ((x) << S_RESREG3)
-#define G_RESREG3(x) (((x) >> S_RESREG3) & M_RESREG3)
-
-#define A_MAC_PORT_IMPEDENCE_CALIBRATION_STATUS_3 0x388c
-
-#define S_T6_RESREG3 0
-#define M_T6_RESREG3 0x3fU
-#define V_T6_RESREG3(x) ((x) << S_T6_RESREG3)
-#define G_T6_RESREG3(x) (((x) >> S_T6_RESREG3) & M_T6_RESREG3)
-
-#define A_MAC_PORT_INEQUALITY_CONTROL_AND_RESULT 0x38c0
-
-#define S_ISGT 7
-#define V_ISGT(x) ((x) << S_ISGT)
-#define F_ISGT V_ISGT(1U)
-
-#define S_ISLT 6
-#define V_ISLT(x) ((x) << S_ISLT)
-#define F_ISLT V_ISLT(1U)
-
-#define S_ISEQ 5
-#define V_ISEQ(x) ((x) << S_ISEQ)
-#define F_ISEQ V_ISEQ(1U)
-
-#define S_ISVAL 3
-#define M_ISVAL 0x3U
-#define V_ISVAL(x) ((x) << S_ISVAL)
-#define G_ISVAL(x) (((x) >> S_ISVAL) & M_ISVAL)
-
-#define S_GTORLT 1
-#define M_GTORLT 0x3U
-#define V_GTORLT(x) ((x) << S_GTORLT)
-#define G_GTORLT(x) (((x) >> S_GTORLT) & M_GTORLT)
-
-#define S_INEQ 0
-#define V_INEQ(x) ((x) << S_INEQ)
-#define F_INEQ V_INEQ(1U)
-
-#define A_MAC_PORT_INEQUALITY_LOW_LIMIT 0x38c4
-
-#define S_LLIM 0
-#define M_LLIM 0xffffU
-#define V_LLIM(x) ((x) << S_LLIM)
-#define G_LLIM(x) (((x) >> S_LLIM) & M_LLIM)
-
-#define A_MAC_PORT_INEQUALITY_LOW_LIMIT_MASK 0x38c8
-
-#define S_LMSK 0
-#define M_LMSK 0xffffU
-#define V_LMSK(x) ((x) << S_LMSK)
-#define G_LMSK(x) (((x) >> S_LMSK) & M_LMSK)
-
-#define A_MAC_PORT_INEQUALITY_HIGH_LIMIT 0x38cc
-
-#define S_HLIM 0
-#define M_HLIM 0xffffU
-#define V_HLIM(x) ((x) << S_HLIM)
-#define G_HLIM(x) (((x) >> S_HLIM) & M_HLIM)
-
-#define A_MAC_PORT_INEQUALITY_HIGH_LIMIT_MASK 0x38d0
-
-#define S_HMSK 0
-#define M_HMSK 0xffffU
-#define V_HMSK(x) ((x) << S_HMSK)
-#define G_HMSK(x) (((x) >> S_HMSK) & M_HMSK)
-
-#define A_MAC_PORT_MACRO_TEST_CONTROL_6 0x38e8
-
-#define S_LBIST 7
-#define V_LBIST(x) ((x) << S_LBIST)
-#define F_LBIST V_LBIST(1U)
-
-#define S_LOGICTEST 6
-#define V_LOGICTEST(x) ((x) << S_LOGICTEST)
-#define F_LOGICTEST V_LOGICTEST(1U)
-
-#define S_MAVDHI 5
-#define V_MAVDHI(x) ((x) << S_MAVDHI)
-#define F_MAVDHI V_MAVDHI(1U)
-
-#define S_AUXEN 4
-#define V_AUXEN(x) ((x) << S_AUXEN)
-#define F_AUXEN V_AUXEN(1U)
-
-#define S_JTAGMD 3
-#define V_JTAGMD(x) ((x) << S_JTAGMD)
-#define F_JTAGMD V_JTAGMD(1U)
-
-#define S_RXACMODE 2
-#define V_RXACMODE(x) ((x) << S_RXACMODE)
-#define F_RXACMODE V_RXACMODE(1U)
-
-#define S_HSSACJPC 1
-#define V_HSSACJPC(x) ((x) << S_HSSACJPC)
-#define F_HSSACJPC V_HSSACJPC(1U)
-
-#define S_HSSACJAC 0
-#define V_HSSACJAC(x) ((x) << S_HSSACJAC)
-#define F_HSSACJAC V_HSSACJAC(1U)
-
-#define A_MAC_PORT_MACRO_TEST_CONTROL_5 0x38ec
-
-#define S_REFVALIDD 6
-#define V_REFVALIDD(x) ((x) << S_REFVALIDD)
-#define F_REFVALIDD V_REFVALIDD(1U)
-
-#define S_REFVALIDC 5
-#define V_REFVALIDC(x) ((x) << S_REFVALIDC)
-#define F_REFVALIDC V_REFVALIDC(1U)
-
-#define S_REFVALIDB 4
-#define V_REFVALIDB(x) ((x) << S_REFVALIDB)
-#define F_REFVALIDB V_REFVALIDB(1U)
-
-#define S_REFVALIDA 3
-#define V_REFVALIDA(x) ((x) << S_REFVALIDA)
-#define F_REFVALIDA V_REFVALIDA(1U)
-
-#define S_REFSELRESET 2
-#define V_REFSELRESET(x) ((x) << S_REFSELRESET)
-#define F_REFSELRESET V_REFSELRESET(1U)
-
-#define S_SOFTRESET 1
-#define V_SOFTRESET(x) ((x) << S_SOFTRESET)
-#define F_SOFTRESET V_SOFTRESET(1U)
-
-#define S_MACROTEST 0
-#define V_MACROTEST(x) ((x) << S_MACROTEST)
-#define F_MACROTEST V_MACROTEST(1U)
-
-#define A_MAC_PORT_TX_LINK_BCST_TRANSMIT_CONFIGURATION_MODE 0x3900
-
-#define S_T6_T5_TX_RXLOOP 5
-#define V_T6_T5_TX_RXLOOP(x) ((x) << S_T6_T5_TX_RXLOOP)
-#define F_T6_T5_TX_RXLOOP V_T6_T5_TX_RXLOOP(1U)
-
-#define S_T6_T5_TX_BWSEL 2
-#define M_T6_T5_TX_BWSEL 0x3U
-#define V_T6_T5_TX_BWSEL(x) ((x) << S_T6_T5_TX_BWSEL)
-#define G_T6_T5_TX_BWSEL(x) (((x) >> S_T6_T5_TX_BWSEL) & M_T6_T5_TX_BWSEL)
-
-#define A_MAC_PORT_TX_LINK_BCST_TRANSMIT_TEST_CONTROL 0x3904
-
-#define S_T6_ERROR 9
-#define V_T6_ERROR(x) ((x) << S_T6_ERROR)
-#define F_T6_ERROR V_T6_ERROR(1U)
-
-#define A_MAC_PORT_TX_LINK_BCST_TRANSMIT_COEFFICIENT_CONTROL 0x3908
-#define A_MAC_PORT_TX_LINK_BCST_TRANSMIT_DRIVER_MODE_CONTROL 0x390c
-#define A_MAC_PORT_TX_LINK_BCST_TRANSMIT_DRIVER_OVERRIDE_CONTROL 0x3910
-#define A_MAC_PORT_TX_LINK_BCST_TRANSMIT_DCLK_ROTATOR_OVERRIDE 0x3914
-#define A_MAC_PORT_TX_LINK_BCST_TRANSMIT_IMPEDANCE_CALIBRATION_OVERRIDE 0x3918
-
-#define S_T6_CALSSTN 8
-#define M_T6_CALSSTN 0x3fU
-#define V_T6_CALSSTN(x) ((x) << S_T6_CALSSTN)
-#define G_T6_CALSSTN(x) (((x) >> S_T6_CALSSTN) & M_T6_CALSSTN)
-
-#define S_T6_CALSSTP 0
-#define M_T6_CALSSTP 0x3fU
-#define V_T6_CALSSTP(x) ((x) << S_T6_CALSSTP)
-#define G_T6_CALSSTP(x) (((x) >> S_T6_CALSSTP) & M_T6_CALSSTP)
-
-#define A_MAC_PORT_TX_LINK_BCST_TRANSMIT_DCLK_DRIFT_TOLERANCE 0x391c
-
-#define S_T6_DRTOL 2
-#define M_T6_DRTOL 0x7U
-#define V_T6_DRTOL(x) ((x) << S_T6_DRTOL)
-#define G_T6_DRTOL(x) (((x) >> S_T6_DRTOL) & M_T6_DRTOL)
-
-#define A_MAC_PORT_TX_LINK_BCST_TRANSMIT_TAP_0_COEFFICIENT 0x3920
-
-#define S_T6_NXTT0 0
-#define M_T6_NXTT0 0x3fU
-#define V_T6_NXTT0(x) ((x) << S_T6_NXTT0)
-#define G_T6_NXTT0(x) (((x) >> S_T6_NXTT0) & M_T6_NXTT0)
-
-#define A_MAC_PORT_TX_LINK_BCST_TRANSMIT_TAP_1_COEFFICIENT 0x3924
-#define A_MAC_PORT_TX_LINK_BCST_TRANSMIT_TAP_2_COEFFICIENT 0x3928
-
-#define S_T6_NXTT2 0
-#define M_T6_NXTT2 0x3fU
-#define V_T6_NXTT2(x) ((x) << S_T6_NXTT2)
-#define G_T6_NXTT2(x) (((x) >> S_T6_NXTT2) & M_T6_NXTT2)
-
-#define A_MAC_PORT_TX_LINK_BCST_TRANSMIT_TAP_3_COEFFICIENT 0x392c
-#define A_MAC_PORT_TX_LINK_BCST_TRANSMIT_AMPLITUDE 0x3930
-#define A_MAC_PORT_TX_LINK_BCST_TRANSMIT_POLARITY 0x3934
-
-#define S_T6_NXTPOL 0
-#define M_T6_NXTPOL 0xfU
-#define V_T6_NXTPOL(x) ((x) << S_T6_NXTPOL)
-#define G_T6_NXTPOL(x) (((x) >> S_T6_NXTPOL) & M_T6_NXTPOL)
-
-#define A_MAC_PORT_TX_LINK_BCST_TRANSMIT_802_3AP_ADAPTIVE_EQUALIZATION_COMMAND 0x3938
-
-#define S_T6_C0UPDT 6
-#define M_T6_C0UPDT 0x3U
-#define V_T6_C0UPDT(x) ((x) << S_T6_C0UPDT)
-#define G_T6_C0UPDT(x) (((x) >> S_T6_C0UPDT) & M_T6_C0UPDT)
-
-#define S_T6_C2UPDT 2
-#define M_T6_C2UPDT 0x3U
-#define V_T6_C2UPDT(x) ((x) << S_T6_C2UPDT)
-#define G_T6_C2UPDT(x) (((x) >> S_T6_C2UPDT) & M_T6_C2UPDT)
-
-#define S_T6_C1UPDT 0
-#define M_T6_C1UPDT 0x3U
-#define V_T6_C1UPDT(x) ((x) << S_T6_C1UPDT)
-#define G_T6_C1UPDT(x) (((x) >> S_T6_C1UPDT) & M_T6_C1UPDT)
-
-#define A_MAC_PORT_TX_LINK_BCST_TRANSMIT_802_3AP_ADAPTIVE_EQUALIZATION_STATUS 0x393c
-
-#define S_T6_C0STAT 6
-#define M_T6_C0STAT 0x3U
-#define V_T6_C0STAT(x) ((x) << S_T6_C0STAT)
-#define G_T6_C0STAT(x) (((x) >> S_T6_C0STAT) & M_T6_C0STAT)
-
-#define S_T6_C2STAT 2
-#define M_T6_C2STAT 0x3U
-#define V_T6_C2STAT(x) ((x) << S_T6_C2STAT)
-#define G_T6_C2STAT(x) (((x) >> S_T6_C2STAT) & M_T6_C2STAT)
-
-#define S_T6_C1STAT 0
-#define M_T6_C1STAT 0x3U
-#define V_T6_C1STAT(x) ((x) << S_T6_C1STAT)
-#define G_T6_C1STAT(x) (((x) >> S_T6_C1STAT) & M_T6_C1STAT)
-
-#define A_MAC_PORT_TX_LINK_BCST_TRANSMIT_TAP_0_COEFFICIENT_OVERRIDE 0x3940
-#define A_MAC_PORT_TX_LINK_BCST_TRANSMIT_AE_TAP_0_COEFFICIENT_OVERRIDE 0x3940
-#define A_MAC_PORT_TX_LINK_BCST_TRANSMIT_TAP_1_COEFFICIENT_OVERRIDE 0x3944
-#define A_MAC_PORT_TX_LINK_BCST_TRANSMIT_AE_TAP_1_COEFFICIENT_OVERRIDE 0x3944
-#define A_MAC_PORT_TX_LINK_BCST_TRANSMIT_TAP_2_COEFFICIENT_OVERRIDE 0x3948
-#define A_MAC_PORT_TX_LINK_BCST_TRANSMIT_AE_TAP_2_COEFFICIENT_OVERRIDE 0x3948
-#define A_MAC_PORT_TX_LINK_BCST_TRANSMIT_AE_TAP_3_COEFFICIENT_OVERRIDE 0x394c
-#define A_MAC_PORT_TX_LINK_BCST_TRANSMIT_APPLIED_TUNE_REGISTER 0x3950
-#define A_MAC_PORT_TX_LINK_BCST_TRANSMIT_ANALOG_DIAGNOSTICS_REGISTER 0x3958
-#define A_MAC_PORT_TX_LINK_BCST_TRANSMIT_TAP_0_COEFFICIENT_APPLIED 0x3960
-#define A_MAC_PORT_TX_LINK_BCST_TRANSMIT_4X_SEGMENT_APPLIED 0x3960
-#define A_MAC_PORT_TX_LINK_BCST_TRANSMIT_TAP_1_COEFFICIENT_APPLIED 0x3964
-#define A_MAC_PORT_TX_LINK_BCST_TRANSMIT_2X_SEGMENT_APPLIED 0x3964
-#define A_MAC_PORT_TX_LINK_BCST_TRANSMIT_TAP_2_COEFFICIENT_APPLIED 0x3968
-#define A_MAC_PORT_TX_LINK_BCST_TRANSMIT_1X_SEGMENT_APPLIED 0x3968
-#define A_MAC_PORT_TX_LINK_BCST_TRANSMIT_SEGMENT_4X_TERMINATION_APPLIED 0x396c
-#define A_MAC_PORT_TX_LINK_BCST_TRANSMIT_SEGMENT_DISABLE_APPLIED_1 0x3970
-#define A_MAC_PORT_TX_LINK_BCST_TRANSMIT_SEGMENT_2X1X_TERMINATION_APPLIED 0x3970
-#define A_MAC_PORT_TX_LINK_BCST_TRANSMIT_SEGMENT_DISABLE_APPLIED_2 0x3974
-#define A_MAC_PORT_TX_LINK_BCST_TRANSMIT_TAP_SIGN_APPLIED_REGISTER 0x3974
-#define A_MAC_PORT_TX_LINK_BCST_TRANSMIT_EXTENDED_ADDRESS_DATA 0x3978
-#define A_MAC_PORT_TX_LINK_BCST_TRANSMIT_EXTENDED_ADDRESS_ADDR 0x397c
-
-#define S_T6_XADDR 1
-#define M_T6_XADDR 0x1fU
-#define V_T6_XADDR(x) ((x) << S_T6_XADDR)
-#define G_T6_XADDR(x) (((x) >> S_T6_XADDR) & M_T6_XADDR)
-
-#define A_MAC_PORT_TX_LINK_BCST_TRANSMIT_PATTERN_BUFFER_BYTES_1_0 0x3980
-#define A_MAC_PORT_TX_LINK_BCST_TRANSMIT_PATTERN_BUFFER_BYTES_3_2 0x3984
-#define A_MAC_PORT_TX_LINK_BCST_TRANSMIT_PATTERN_BUFFER_BYTE_4 0x3988
-#define A_MAC_PORT_TX_LINK_BCST_TRANSMIT_PATTERN_BUFFER_BYTES_5_4 0x3988
-#define A_MAC_PORT_TX_LINK_BCST_TRANSMIT_DCC_CONTROL 0x398c
-#define A_MAC_PORT_TX_LINK_BCST_TRANSMIT_PATTERN_BUFFER_BYTES_7_6 0x398c
-#define A_MAC_PORT_TX_LINK_BCST_TRANSMIT_DCC_OVERRIDE 0x3990
-#define A_MAC_PORT_TX_LINK_BCST_TRANSMIT_DCC_APPLIED 0x3994
-#define A_MAC_PORT_TX_LINK_BCST_TRANSMIT_DCC_TIME_OUT 0x3998
-#define A_MAC_PORT_TX_LINK_BCST_TRANSMIT_802_3AZ_CONTROL 0x399c
-#define A_T6_MAC_PORT_TX_LINK_BCST_TRANSMIT_DCC_CONTROL 0x39a0
-
-#define S_T6_DCCTIMEEN 13
-#define M_T6_DCCTIMEEN 0x3U
-#define V_T6_DCCTIMEEN(x) ((x) << S_T6_DCCTIMEEN)
-#define G_T6_DCCTIMEEN(x) (((x) >> S_T6_DCCTIMEEN) & M_T6_DCCTIMEEN)
-
-#define S_T6_DCCLOCK 11
-#define M_T6_DCCLOCK 0x3U
-#define V_T6_DCCLOCK(x) ((x) << S_T6_DCCLOCK)
-#define G_T6_DCCLOCK(x) (((x) >> S_T6_DCCLOCK) & M_T6_DCCLOCK)
-
-#define S_T6_DCCOFFSET 8
-#define M_T6_DCCOFFSET 0x7U
-#define V_T6_DCCOFFSET(x) ((x) << S_T6_DCCOFFSET)
-#define G_T6_DCCOFFSET(x) (((x) >> S_T6_DCCOFFSET) & M_T6_DCCOFFSET)
-
-#define S_TX_LINK_BCST_DCCSTEP_CTL 6
-#define M_TX_LINK_BCST_DCCSTEP_CTL 0x3U
-#define V_TX_LINK_BCST_DCCSTEP_CTL(x) ((x) << S_TX_LINK_BCST_DCCSTEP_CTL)
-#define G_TX_LINK_BCST_DCCSTEP_CTL(x) (((x) >> S_TX_LINK_BCST_DCCSTEP_CTL) & M_TX_LINK_BCST_DCCSTEP_CTL)
-
-#define A_T6_MAC_PORT_TX_LINK_BCST_TRANSMIT_DCC_OVERRIDE 0x39a4
-#define A_T6_MAC_PORT_TX_LINK_BCST_TRANSMIT_DCC_APPLIED 0x39a8
-#define A_T6_MAC_PORT_TX_LINK_BCST_TRANSMIT_DCC_TIME_OUT 0x39ac
-#define A_MAC_PORT_TX_LINK_BCST_TRANSMIT_TAP_SIGN_OVERRIDE 0x39c0
-#define A_MAC_PORT_TX_LINK_BCST_TRANSMIT_SEGMENT_4X_OVERRIDE 0x39c8
-#define A_MAC_PORT_TX_LINK_BCST_TRANSMIT_SEGMENT_2X_OVERRIDE 0x39cc
-#define A_MAC_PORT_TX_LINK_BCST_TRANSMIT_SEGMENT_1X_OVERRIDE 0x39d0
-#define A_MAC_PORT_TX_LINK_BCST_TRANSMIT_TAP_SEGMENT_4X_TERMINATION_OVERRIDE 0x39d8
-#define A_MAC_PORT_TX_LINK_BCST_TRANSMIT_TAP_SEGMENT_2X_TERMINATION_OVERRIDE 0x39dc
-#define A_MAC_PORT_TX_LINK_BCST_TRANSMIT_TAP_SEGMENT_1X_TERMINATION_OVERRIDE 0x39e0
-#define A_MAC_PORT_TX_LINK_BCST_TRANSMIT_MACRO_TEST_CONTROL_5 0x39ec
-#define A_MAC_PORT_TX_LINK_BCST_TRANSMIT_MACRO_TEST_CONTROL_4 0x39f0
-
-#define S_T6_SDOVRD 0
-#define M_T6_SDOVRD 0xffffU
-#define V_T6_SDOVRD(x) ((x) << S_T6_SDOVRD)
-#define G_T6_SDOVRD(x) (((x) >> S_T6_SDOVRD) & M_T6_SDOVRD)
-
-#define A_MAC_PORT_TX_LINK_BCST_TRANSMIT_MACRO_TEST_CONTROL_3 0x39f4
-#define A_MAC_PORT_TX_LINK_BCST_TRANSMIT_MACRO_TEST_CONTROL_2 0x39f8
-#define A_MAC_PORT_TX_LINK_BCST_TRANSMIT_MACRO_TEST_CONTROL_1 0x39fc
-
-#define S_T6_SDOVRDEN 15
-#define V_T6_SDOVRDEN(x) ((x) << S_T6_SDOVRDEN)
-#define F_T6_SDOVRDEN V_T6_SDOVRDEN(1U)
-
-#define A_MAC_PORT_RX_LINK_BCST_RECEIVER_CONFIGURATION_MODE 0x3a00
-#define A_MAC_PORT_RX_LINK_BCST_RECEIVER_TEST_CONTROL 0x3a04
-#define A_MAC_PORT_RX_LINK_BCST_PHASE_ROTATOR_CONTROL 0x3a08
-#define A_MAC_PORT_RX_LINK_BCST_PHASE_ROTATOR_OFFSET_CONTROL 0x3a0c
-
-#define S_T6_TMSCAL 8
-#define M_T6_TMSCAL 0x3U
-#define V_T6_TMSCAL(x) ((x) << S_T6_TMSCAL)
-#define G_T6_TMSCAL(x) (((x) >> S_T6_TMSCAL) & M_T6_TMSCAL)
-
-#define S_T6_APADJ 7
-#define V_T6_APADJ(x) ((x) << S_T6_APADJ)
-#define F_T6_APADJ V_T6_APADJ(1U)
-
-#define S_T6_RSEL 6
-#define V_T6_RSEL(x) ((x) << S_T6_RSEL)
-#define F_T6_RSEL V_T6_RSEL(1U)
-
-#define S_T6_PHOFFS 0
-#define M_T6_PHOFFS 0x3fU
-#define V_T6_PHOFFS(x) ((x) << S_T6_PHOFFS)
-#define G_T6_PHOFFS(x) (((x) >> S_T6_PHOFFS) & M_T6_PHOFFS)
-
-#define A_MAC_PORT_RX_LINK_BCST_PHASE_ROTATOR_POSITION_1 0x3a10
-#define A_MAC_PORT_RX_LINK_BCST_PHASE_ROTATOR_POSITION_2 0x3a14
-#define A_MAC_PORT_RX_LINK_BCST_PHASE_ROTATOR_STATIC_PHASE_OFFSET_1 0x3a18
-#define A_MAC_PORT_RX_LINK_BCST_PHASE_ROTATOR_STATIC_PHASE_OFFSET_2 0x3a1c
-#define A_MAC_PORT_RX_LINK_BCST_DFE_CONTROL 0x3a20
-
-#define S_T6_SPIFMT 8
-#define M_T6_SPIFMT 0xfU
-#define V_T6_SPIFMT(x) ((x) << S_T6_SPIFMT)
-#define G_T6_SPIFMT(x) (((x) >> S_T6_SPIFMT) & M_T6_SPIFMT)
-
-#define A_MAC_PORT_RX_LINK_BCST_DFE_SAMPLE_SNAPSHOT_1 0x3a24
-#define A_MAC_PORT_RX_LINK_BCST_DFE_SAMPLE_SNAPSHOT_2 0x3a28
-#define A_MAC_PORT_RX_LINK_BCST_RECEIVER_VGA_CONTROL_1 0x3a2c
-
-#define S_T6_WRAPSEL 15
-#define V_T6_WRAPSEL(x) ((x) << S_T6_WRAPSEL)
-#define F_T6_WRAPSEL V_T6_WRAPSEL(1U)
-
-#define S_T6_PEAK 9
-#define M_T6_PEAK 0x1fU
-#define V_T6_PEAK(x) ((x) << S_T6_PEAK)
-#define G_T6_PEAK(x) (((x) >> S_T6_PEAK) & M_T6_PEAK)
-
-#define A_MAC_PORT_RX_LINK_BCST_RECEIVER_VGA_CONTROL_2 0x3a30
-
-#define S_T6_T5VGAIN 0
-#define M_T6_T5VGAIN 0x7fU
-#define V_T6_T5VGAIN(x) ((x) << S_T6_T5VGAIN)
-#define G_T6_T5VGAIN(x) (((x) >> S_T6_T5VGAIN) & M_T6_T5VGAIN)
-
-#define A_MAC_PORT_RX_LINK_BCST_RECEIVER_VGA_CONTROL_3 0x3a34
-#define A_MAC_PORT_RX_LINK_BCST_RECEIVER_DQCC_CONTROL_1 0x3a38
-#define A_MAC_PORT_RX_LINK_BCST_RECEIVER_POWER_MANAGEMENT_CONTROL 0x3a38
-#define A_MAC_PORT_RX_LINK_BCST_RECEIVER_IQAMP_CONTROL_1 0x3a3c
-#define A_MAC_PORT_RX_LINK_BCST_RECEIVER_DQCC_CONTROL_3 0x3a40
-#define A_MAC_PORT_RX_LINK_BCST_RECEIVER_IQAMP_CONTROL_2 0x3a40
-#define A_MAC_PORT_RX_LINK_BCST_RECEIVER_DACAP_AND_DACAN_SELECTION 0x3a44
-#define A_MAC_PORT_RX_LINK_BCST_RECEIVER_DACAP_AND_DACAN 0x3a48
-#define A_MAC_PORT_RX_LINK_BCST_RECEIVER_DACA_MIN_AND_DACAZ 0x3a4c
-#define A_MAC_PORT_RX_LINK_BCST_RECEIVER_DACA_MIN 0x3a4c
-#define A_MAC_PORT_RX_LINK_BCST_RECEIVER_ADAC_CONTROL 0x3a50
-#define A_MAC_PORT_RX_LINK_BCST_RECEIVER_AC_COUPLING_CONTROL 0x3a54
-#define A_MAC_PORT_RX_LINK_BCST_RECEIVER_AC_COUPLING_VALUE 0x3a58
-#define A_MAC_PORT_RX_LINK_BCST_DFE_H1_LOCAL_OFFSET_ODD2_EVN2 0x3a5c
-#define A_MAC_PORT_RX_LINK_BCST_DFE_H1H2H3_LOCAL_OFFSET 0x3a5c
-#define A_MAC_PORT_RX_LINK_BCST_DFE_H1_LOCAL_OFFSET_ODD3_EVN3 0x3a60
-#define A_MAC_PORT_RX_LINK_BCST_DFE_H1H2H3_LOCAL_OFFSET_VALUE 0x3a60
-#define A_MAC_PORT_RX_LINK_BCST_DFE_H1_LOCAL_OFFSET_ODD4_EVN4 0x3a64
-#define A_MAC_PORT_RX_LINK_BCST_PEAKED_INTEGRATOR 0x3a64
-#define A_MAC_PORT_RX_LINK_BCST_CDR_ANALOG_SWITCH 0x3a68
-#define A_MAC_PORT_RX_LINK_BCST_PEAKING_AMPLIFIER_INTIALIZATION_CONTROL 0x3a6c
-#define A_MAC_PORT_RX_LINK_BCST_DYNAMIC_AMPLITUDE_CENTERING_DAC_AND_DYNAMIC_PEAKING_CONTROL_DPC 0x3a70
-#define A_MAC_PORT_RX_LINK_BCST_DYNAMIC_DATA_CENTERING_DDC 0x3a74
-
-#define S_T6_ODEC 0
-#define M_T6_ODEC 0xfU
-#define V_T6_ODEC(x) ((x) << S_T6_ODEC)
-#define G_T6_ODEC(x) (((x) >> S_T6_ODEC) & M_T6_ODEC)
-
-#define A_MAC_PORT_RX_LINK_BCST_RECEIVER_INTERNAL_STATUS 0x3a78
-
-#define S_RX_LINK_BCST_ACCCMP_RIS 11
-#define V_RX_LINK_BCST_ACCCMP_RIS(x) ((x) << S_RX_LINK_BCST_ACCCMP_RIS)
-#define F_RX_LINK_BCST_ACCCMP_RIS V_RX_LINK_BCST_ACCCMP_RIS(1U)
-
-#define A_MAC_PORT_RX_LINK_BCST_DFE_FUNCTION_CONTROL_1 0x3a7c
-#define A_MAC_PORT_RX_LINK_BCST_DFE_FUNCTION_CONTROL_2 0x3a80
-#define A_MAC_PORT_RX_LINK_BCST_DFE_OFFSET_EVN1_EVN2 0x3a84
-#define A_MAC_PORT_RX_LINK_BCST_DFE_OFFSET_CHANNEL 0x3a84
-#define A_MAC_PORT_RX_LINK_BCST_DFE_OFFSET_ODD1_ODD2 0x3a88
-#define A_MAC_PORT_RX_LINK_BCST_DFE_OFFSET_VALUE 0x3a88
-#define A_MAC_PORT_RX_LINK_BCST_DFE_OFFSET_EVN3_EVN4 0x3a8c
-#define A_MAC_PORT_RX_LINK_BCST_H_COEFFICIENBT_BIST 0x3a8c
-#define A_MAC_PORT_RX_LINK_BCST_DFE_OFFSET_ODD3_ODD4 0x3a90
-#define A_MAC_PORT_RX_LINK_BCST_AC_CAPACITOR_BIST 0x3a90
-
-#define S_RX_LINK_BCST_ACCCMP_BIST 13
-#define V_RX_LINK_BCST_ACCCMP_BIST(x) ((x) << S_RX_LINK_BCST_ACCCMP_BIST)
-#define F_RX_LINK_BCST_ACCCMP_BIST V_RX_LINK_BCST_ACCCMP_BIST(1U)
-
-#define A_MAC_PORT_RX_LINK_BCST_DFE_E0_AND_E1_OFFSET 0x3a94
-#define A_MAC_PORT_RX_LINK_BCST_RECEIVER_LOFF_CONTROL 0x3a98
-#define A_MAC_PORT_RX_LINK_BCST_RECEIVER_LOFF_CONTROL_REGISTER 0x3a98
-#define A_MAC_PORT_RX_LINK_BCST_RECEIVER_SIGDET_CONTROL 0x3a9c
-#define A_MAC_PORT_RX_LINK_BCST_RECEIVER_ANALOG_CONTROL_SWITCH 0x3aa0
-#define A_MAC_PORT_RX_LINK_BCST_INTEGRATOR_DAC_OFFSET 0x3aa4
-#define A_MAC_PORT_RX_LINK_BCST_DIGITAL_EYE_CONTROL 0x3aa8
-#define A_MAC_PORT_RX_LINK_BCST_DIGITAL_EYE_METRICS 0x3aac
-
-#define S_T6_EMMD 3
-#define M_T6_EMMD 0x3U
-#define V_T6_EMMD(x) ((x) << S_T6_EMMD)
-#define G_T6_EMMD(x) (((x) >> S_T6_EMMD) & M_T6_EMMD)
-
-#define S_T6_EMBRDY 2
-#define V_T6_EMBRDY(x) ((x) << S_T6_EMBRDY)
-#define F_T6_EMBRDY V_T6_EMBRDY(1U)
-
-#define S_T6_EMBUMP 1
-#define V_T6_EMBUMP(x) ((x) << S_T6_EMBUMP)
-#define F_T6_EMBUMP V_T6_EMBUMP(1U)
-
-#define A_MAC_PORT_RX_LINK_BCST_DIGITAL_EYE_METRICS_ERROR_COUNT 0x3ab0
-#define A_MAC_PORT_RX_LINK_BCST_DIGITAL_EYE_METRICS_PDF_EYE_COUNT 0x3ab4
-#define A_MAC_PORT_RX_LINK_BCST_DIGITAL_EYE_METRICS_PATTERN_LENGTH 0x3ab8
-#define A_MAC_PORT_RX_LINK_BCST_DFE_FUNCTION_CONTROL_3 0x3abc
-#define A_MAC_PORT_RX_LINK_BCST_DFE_TAP_ENABLE 0x3ac0
-#define A_MAC_PORT_RX_LINK_BCST_DFE_TAP_CONTROL 0x3ac0
-
-#define S_RX_LINK_BCST_INDEX_DFE_TC 0
-#define M_RX_LINK_BCST_INDEX_DFE_TC 0xfU
-#define V_RX_LINK_BCST_INDEX_DFE_TC(x) ((x) << S_RX_LINK_BCST_INDEX_DFE_TC)
-#define G_RX_LINK_BCST_INDEX_DFE_TC(x) (((x) >> S_RX_LINK_BCST_INDEX_DFE_TC) & M_RX_LINK_BCST_INDEX_DFE_TC)
-
-#define A_MAC_PORT_RX_LINK_BCST_DFE_H1 0x3ac4
-#define A_MAC_PORT_RX_LINK_BCST_DFE_TAP 0x3ac4
-
-#define S_RX_LINK_BCST_INDEX_DFE_TAP 0
-#define M_RX_LINK_BCST_INDEX_DFE_TAP 0xfU
-#define V_RX_LINK_BCST_INDEX_DFE_TAP(x) ((x) << S_RX_LINK_BCST_INDEX_DFE_TAP)
-#define G_RX_LINK_BCST_INDEX_DFE_TAP(x) (((x) >> S_RX_LINK_BCST_INDEX_DFE_TAP) & M_RX_LINK_BCST_INDEX_DFE_TAP)
-
-#define A_MAC_PORT_RX_LINK_BCST_DFE_H2 0x3ac8
-#define A_MAC_PORT_RX_LINK_BCST_DFE_H3 0x3acc
-#define A_MAC_PORT_RX_LINK_BCST_DFE_H4 0x3ad0
-#define A_MAC_PORT_RX_LINK_BCST_DFE_H5 0x3ad4
-#define A_MAC_PORT_RX_LINK_BCST_DFE_H6_AND_H7 0x3ad8
-#define A_MAC_PORT_RX_LINK_BCST_DFE_H8_AND_H9 0x3adc
-#define A_MAC_PORT_RX_LINK_BCST_DFE_H10_AND_H11 0x3ae0
-#define A_MAC_PORT_RX_LINK_BCST_DFE_H12 0x3ae4
-#define A_MAC_PORT_RX_LINK_BCST_RECEIVER_INTERNAL_STATUS_2 0x3ae4
-#define A_MAC_PORT_RX_LINK_BCST_AC_COUPLING_CURRENT_SOURCE_ADJUST 0x3ae8
-#define A_MAC_PORT_RX_LINK_BCST_RECEIVER_DCD_CONTROL 0x3aec
-#define A_MAC_PORT_RX_LINK_BCST_RECEIVER_DCC_CONTROL 0x3af0
-
-#define S_RX_LINK_BCST_DCCSTEP_RXCTL 10
-#define M_RX_LINK_BCST_DCCSTEP_RXCTL 0x3U
-#define V_RX_LINK_BCST_DCCSTEP_RXCTL(x) ((x) << S_RX_LINK_BCST_DCCSTEP_RXCTL)
-#define G_RX_LINK_BCST_DCCSTEP_RXCTL(x) (((x) >> S_RX_LINK_BCST_DCCSTEP_RXCTL) & M_RX_LINK_BCST_DCCSTEP_RXCTL)
-
-#define S_RX_LINK_BCST_DCCLOCK_RXCTL 8
-#define V_RX_LINK_BCST_DCCLOCK_RXCTL(x) ((x) << S_RX_LINK_BCST_DCCLOCK_RXCTL)
-#define F_RX_LINK_BCST_DCCLOCK_RXCTL V_RX_LINK_BCST_DCCLOCK_RXCTL(1U)
-
-#define A_MAC_PORT_RX_LINK_BCST_RECEIVER_QCC_CONTROL 0x3af4
-#define A_MAC_PORT_RX_LINK_BCST_RECEIVER_MACRO_TEST_CONTROL_2 0x3af8
-#define A_MAC_PORT_RX_LINK_BCST_RECEIVER_MACRO_TEST_CONTROL_REGISTER_2 0x3af8
-#define A_MAC_PORT_RX_LINK_BCST_RECEIVER_MACRO_TEST_CONTROL_1 0x3afc
-#define A_MAC_PORT_PLLA_VCO_COARSE_CALIBRATION_0 0x3b00
-#define A_MAC_PORT_PLLA_VCO_COARSE_CALIBRATION_1 0x3b04
-#define A_MAC_PORT_PLLA_VCO_COARSE_CALIBRATION_2 0x3b08
-#define A_MAC_PORT_PLLA_VCO_COARSE_CALIBRATION_3 0x3b0c
-#define A_MAC_PORT_PLLA_VCO_COARSE_CALIBRATION_4 0x3b10
-#define A_MAC_PORT_PLLA_POWER_CONTROL 0x3b24
-
-#define S_SPWRENA 1
-#define V_SPWRENA(x) ((x) << S_SPWRENA)
-#define F_SPWRENA V_SPWRENA(1U)
-
-#define S_NPWRENA 0
-#define V_NPWRENA(x) ((x) << S_NPWRENA)
-#define F_NPWRENA V_NPWRENA(1U)
-
-#define A_MAC_PORT_PLLA_CHARGE_PUMP_CONTROL 0x3b28
-
-#define S_T5CPISEL 0
-#define M_T5CPISEL 0x7U
-#define V_T5CPISEL(x) ((x) << S_T5CPISEL)
-#define G_T5CPISEL(x) (((x) >> S_T5CPISEL) & M_T5CPISEL)
-
-#define A_MAC_PORT_PLLA_PLL_MICELLANEOUS_CONTROL 0x3b38
-#define A_MAC_PORT_PLLA_PCLK_CONTROL 0x3b3c
-
-#define S_SPEDIV 3
-#define M_SPEDIV 0x1fU
-#define V_SPEDIV(x) ((x) << S_SPEDIV)
-#define G_SPEDIV(x) (((x) >> S_SPEDIV) & M_SPEDIV)
-
-#define S_PCKSEL 0
-#define M_PCKSEL 0x7U
-#define V_PCKSEL(x) ((x) << S_PCKSEL)
-#define G_PCKSEL(x) (((x) >> S_PCKSEL) & M_PCKSEL)
-
-#define A_MAC_PORT_PLLA_EYE_METRICS_INTERVAL_CONTROL 0x3b40
-
-#define S_EMIL 2
-#define V_EMIL(x) ((x) << S_EMIL)
-#define F_EMIL V_EMIL(1U)
-
-#define S_EMID 1
-#define V_EMID(x) ((x) << S_EMID)
-#define F_EMID V_EMID(1U)
-
-#define S_EMIS 0
-#define V_EMIS(x) ((x) << S_EMIS)
-#define F_EMIS V_EMIS(1U)
-
-#define A_MAC_PORT_PLLA_EYE_METRICS_INTERVAL_LIMIT_1 0x3b44
-
-#define S_EMIL1 0
-#define M_EMIL1 0xffU
-#define V_EMIL1(x) ((x) << S_EMIL1)
-#define G_EMIL1(x) (((x) >> S_EMIL1) & M_EMIL1)
-
-#define A_MAC_PORT_PLLA_EYE_METRICS_INTERVAL_LIMIT_2 0x3b48
-
-#define S_EMIL2 0
-#define M_EMIL2 0xffU
-#define V_EMIL2(x) ((x) << S_EMIL2)
-#define G_EMIL2(x) (((x) >> S_EMIL2) & M_EMIL2)
-
-#define A_MAC_PORT_PLLA_EYE_METRICS_INTERVAL_LIMIT_3 0x3b4c
-
-#define S_EMIL3 0
-#define M_EMIL3 0xffU
-#define V_EMIL3(x) ((x) << S_EMIL3)
-#define G_EMIL3(x) (((x) >> S_EMIL3) & M_EMIL3)
-
-#define A_MAC_PORT_PLLA_EYE_METRICS_INTERVAL_LIMIT_4 0x3b50
-
-#define S_EMIL4 0
-#define M_EMIL4 0xffU
-#define V_EMIL4(x) ((x) << S_EMIL4)
-#define G_EMIL4(x) (((x) >> S_EMIL4) & M_EMIL4)
-
-#define A_MAC_PORT_PLLA_MACRO_TEST_CONTROL_4 0x3bf0
-
-#define S_VBST 1
-#define M_VBST 0x7U
-#define V_VBST(x) ((x) << S_VBST)
-#define G_VBST(x) (((x) >> S_VBST) & M_VBST)
-
-#define S_PLLDIVA 4
-#define V_PLLDIVA(x) ((x) << S_PLLDIVA)
-#define F_PLLDIVA V_PLLDIVA(1U)
-
-#define S_REFDIV 0
-#define M_REFDIV 0xfU
-#define V_REFDIV(x) ((x) << S_REFDIV)
-#define G_REFDIV(x) (((x) >> S_REFDIV) & M_REFDIV)
-
-#define A_MAC_PORT_PLLA_MACRO_TEST_CONTROL_3 0x3bf4
-
-#define S_RESYNC 6
-#define V_RESYNC(x) ((x) << S_RESYNC)
-#define F_RESYNC V_RESYNC(1U)
-
-#define S_RXCLKSEL 5
-#define V_RXCLKSEL(x) ((x) << S_RXCLKSEL)
-#define F_RXCLKSEL V_RXCLKSEL(1U)
-
-#define S_FRCBAND 4
-#define V_FRCBAND(x) ((x) << S_FRCBAND)
-#define F_FRCBAND V_FRCBAND(1U)
-
-#define S_PLLBYP 3
-#define V_PLLBYP(x) ((x) << S_PLLBYP)
-#define F_PLLBYP V_PLLBYP(1U)
-
-#define S_PDWNP 2
-#define V_PDWNP(x) ((x) << S_PDWNP)
-#define F_PDWNP V_PDWNP(1U)
-
-#define S_VCOSEL 1
-#define V_VCOSEL(x) ((x) << S_VCOSEL)
-#define F_VCOSEL V_VCOSEL(1U)
-
-#define S_DIVSEL8 0
-#define V_DIVSEL8(x) ((x) << S_DIVSEL8)
-#define F_DIVSEL8 V_DIVSEL8(1U)
-
-#define A_MAC_PORT_PLLA_MACRO_TEST_CONTROL_2 0x3bf8
-
-#define S_DIVSEL 0
-#define M_DIVSEL 0xffU
-#define V_DIVSEL(x) ((x) << S_DIVSEL)
-#define G_DIVSEL(x) (((x) >> S_DIVSEL) & M_DIVSEL)
-
-#define A_MAC_PORT_PLLA_MACRO_TEST_CONTROL_1 0x3bfc
-
-#define S_CONFIG 0
-#define M_CONFIG 0xffU
-#define V_CONFIG(x) ((x) << S_CONFIG)
-#define G_CONFIG(x) (((x) >> S_CONFIG) & M_CONFIG)
-
-#define A_MAC_PORT_PLLB_VCO_COARSE_CALIBRATION_0 0x3c00
-#define A_MAC_PORT_PLLB_VCO_COARSE_CALIBRATION_1 0x3c04
-#define A_MAC_PORT_PLLB_VCO_COARSE_CALIBRATION_2 0x3c08
-#define A_MAC_PORT_PLLB_VCO_COARSE_CALIBRATION_3 0x3c0c
-#define A_MAC_PORT_PLLB_VCO_COARSE_CALIBRATION_4 0x3c10
-#define A_MAC_PORT_PLLB_POWER_CONTROL 0x3c24
-#define A_MAC_PORT_PLLB_CHARGE_PUMP_CONTROL 0x3c28
-#define A_MAC_PORT_PLLB_PLL_MICELLANEOUS_CONTROL 0x3c38
-#define A_MAC_PORT_PLLB_PCLK_CONTROL 0x3c3c
-#define A_MAC_PORT_PLLB_EYE_METRICS_INTERVAL_CONTROL 0x3c40
-#define A_MAC_PORT_PLLB_EYE_METRICS_INTERVAL_LIMIT_1 0x3c44
-#define A_MAC_PORT_PLLB_EYE_METRICS_INTERVAL_LIMIT_2 0x3c48
-#define A_MAC_PORT_PLLB_EYE_METRICS_INTERVAL_LIMIT_3 0x3c4c
-#define A_MAC_PORT_PLLB_EYE_METRICS_INTERVAL_LIMIT_4 0x3c50
-#define A_MAC_PORT_PLLB_MACRO_TEST_CONTROL_4 0x3cf0
-#define A_MAC_PORT_PLLB_MACRO_TEST_CONTROL_3 0x3cf4
-#define A_MAC_PORT_PLLB_MACRO_TEST_CONTROL_2 0x3cf8
-#define A_MAC_PORT_PLLB_MACRO_TEST_CONTROL_1 0x3cfc
-#define A_MAC_PORT_TX_LINKA_TRANSMIT_802_3AP_STEP_SIZE_EXTENDED 0x0
-
-#define S_STEP 0
-#define M_STEP 0x7U
-#define V_STEP(x) ((x) << S_STEP)
-#define G_STEP(x) (((x) >> S_STEP) & M_STEP)
-
-#define A_MAC_PORT_TX_LINKA_TRANSMIT_AE_STEP_SIZE_EXTENDED 0x0
-#define A_MAC_PORT_TX_LINKA_TRANSMIT_802_3AP_C0_INIT_EXTENDED 0x8
-
-#define S_C0INIT 0
-#define M_C0INIT 0x1fU
-#define V_C0INIT(x) ((x) << S_C0INIT)
-#define G_C0INIT(x) (((x) >> S_C0INIT) & M_C0INIT)
-
-#define S_C0PRESET 8
-#define M_C0PRESET 0x7fU
-#define V_C0PRESET(x) ((x) << S_C0PRESET)
-#define G_C0PRESET(x) (((x) >> S_C0PRESET) & M_C0PRESET)
-
-#define S_C0INIT1 0
-#define M_C0INIT1 0x7fU
-#define V_C0INIT1(x) ((x) << S_C0INIT1)
-#define G_C0INIT1(x) (((x) >> S_C0INIT1) & M_C0INIT1)
-
-#define A_MAC_PORT_TX_LINKA_TRANSMIT_802_3AP_C0_LIMIT_EXTENDED 0x10
-
-#define S_C0MAX 8
-#define M_C0MAX 0x1fU
-#define V_C0MAX(x) ((x) << S_C0MAX)
-#define G_C0MAX(x) (((x) >> S_C0MAX) & M_C0MAX)
-
-#define S_C0MIN 0
-#define M_C0MIN 0x1fU
-#define V_C0MIN(x) ((x) << S_C0MIN)
-#define G_C0MIN(x) (((x) >> S_C0MIN) & M_C0MIN)
-
-#define A_MAC_PORT_TX_LINKA_TRANSMIT_AE_C0_LIMIT_EXTENDED 0x10
-
-#define S_T6_C0MAX 8
-#define M_T6_C0MAX 0x7fU
-#define V_T6_C0MAX(x) ((x) << S_T6_C0MAX)
-#define G_T6_C0MAX(x) (((x) >> S_T6_C0MAX) & M_T6_C0MAX)
-
-#define S_T6_C0MIN 0
-#define M_T6_C0MIN 0x7fU
-#define V_T6_C0MIN(x) ((x) << S_T6_C0MIN)
-#define G_T6_C0MIN(x) (((x) >> S_T6_C0MIN) & M_T6_C0MIN)
-
-#define A_MAC_PORT_TX_LINKA_TRANSMIT_802_3AP_C1_INIT_EXTENDED 0x18
-
-#define S_C1INIT 0
-#define M_C1INIT 0x7fU
-#define V_C1INIT(x) ((x) << S_C1INIT)
-#define G_C1INIT(x) (((x) >> S_C1INIT) & M_C1INIT)
-
-#define A_MAC_PORT_TX_LINKA_TRANSMIT_AE_C1_INIT_EXTENDED 0x18
-
-#define S_C1PRESET 8
-#define M_C1PRESET 0x7fU
-#define V_C1PRESET(x) ((x) << S_C1PRESET)
-#define G_C1PRESET(x) (((x) >> S_C1PRESET) & M_C1PRESET)
-
-#define S_C1INIT1 0
-#define M_C1INIT1 0x7fU
-#define V_C1INIT1(x) ((x) << S_C1INIT1)
-#define G_C1INIT1(x) (((x) >> S_C1INIT1) & M_C1INIT1)
-
-#define A_MAC_PORT_TX_LINKA_TRANSMIT_802_3AP_C1_LIMIT_EXTENDED 0x20
-
-#define S_C1MAX 8
-#define M_C1MAX 0x7fU
-#define V_C1MAX(x) ((x) << S_C1MAX)
-#define G_C1MAX(x) (((x) >> S_C1MAX) & M_C1MAX)
-
-#define S_C1MIN 0
-#define M_C1MIN 0x7fU
-#define V_C1MIN(x) ((x) << S_C1MIN)
-#define G_C1MIN(x) (((x) >> S_C1MIN) & M_C1MIN)
-
-#define A_MAC_PORT_TX_LINKA_TRANSMIT_AE_C1_LIMIT_EXTENDED 0x20
-#define A_MAC_PORT_TX_LINKA_TRANSMIT_802_3AP_C2_INIT_EXTENDED 0x28
-
-#define S_C2INIT 0
-#define M_C2INIT 0x3fU
-#define V_C2INIT(x) ((x) << S_C2INIT)
-#define G_C2INIT(x) (((x) >> S_C2INIT) & M_C2INIT)
-
-#define A_MAC_PORT_TX_LINKA_TRANSMIT_AE_C2_INIT_EXTENDED 0x28
-
-#define S_C2PRESET 8
-#define M_C2PRESET 0x7fU
-#define V_C2PRESET(x) ((x) << S_C2PRESET)
-#define G_C2PRESET(x) (((x) >> S_C2PRESET) & M_C2PRESET)
-
-#define S_C2INIT1 0
-#define M_C2INIT1 0x7fU
-#define V_C2INIT1(x) ((x) << S_C2INIT1)
-#define G_C2INIT1(x) (((x) >> S_C2INIT1) & M_C2INIT1)
-
-#define A_MAC_PORT_TX_LINKA_TRANSMIT_802_3AP_C2_LIMIT_EXTENDED 0x30
-
-#define S_C2MAX 8
-#define M_C2MAX 0x3fU
-#define V_C2MAX(x) ((x) << S_C2MAX)
-#define G_C2MAX(x) (((x) >> S_C2MAX) & M_C2MAX)
-
-#define S_C2MIN 0
-#define M_C2MIN 0x3fU
-#define V_C2MIN(x) ((x) << S_C2MIN)
-#define G_C2MIN(x) (((x) >> S_C2MIN) & M_C2MIN)
-
-#define A_MAC_PORT_TX_LINKA_TRANSMIT_AE_C2_LIMIT_EXTENDED 0x30
-
-#define S_T6_C2MAX 8
-#define M_T6_C2MAX 0x7fU
-#define V_T6_C2MAX(x) ((x) << S_T6_C2MAX)
-#define G_T6_C2MAX(x) (((x) >> S_T6_C2MAX) & M_T6_C2MAX)
-
-#define S_T6_C2MIN 0
-#define M_T6_C2MIN 0x7fU
-#define V_T6_C2MIN(x) ((x) << S_T6_C2MIN)
-#define G_T6_C2MIN(x) (((x) >> S_T6_C2MIN) & M_T6_C2MIN)
-
-#define A_MAC_PORT_TX_LINKA_TRANSMIT_802_3AP_VM_LIMIT_EXTENDED 0x38
-
-#define S_VMMAX 0
-#define M_VMMAX 0x7fU
-#define V_VMMAX(x) ((x) << S_VMMAX)
-#define G_VMMAX(x) (((x) >> S_VMMAX) & M_VMMAX)
-
-#define A_MAC_PORT_TX_LINKA_TRANSMIT_AE_VM_LIMIT_EXTENDED 0x38
-#define A_MAC_PORT_TX_LINKA_TRANSMIT_802_3AP_V2_LIMIT_EXTENDED 0x40
-
-#define S_V2MIN 0
-#define M_V2MIN 0x7fU
-#define V_V2MIN(x) ((x) << S_V2MIN)
-#define G_V2MIN(x) (((x) >> S_V2MIN) & M_V2MIN)
-
-#define A_MAC_PORT_TX_LINKA_TRANSMIT_AE_V2_LIMIT_EXTENDED 0x40
-#define A_MAC_PORT_TX_LINKA_TRANSMIT_AE_C3_INIT_EXTENDED 0x48
-
-#define S_C3PRESET 8
-#define M_C3PRESET 0x7fU
-#define V_C3PRESET(x) ((x) << S_C3PRESET)
-#define G_C3PRESET(x) (((x) >> S_C3PRESET) & M_C3PRESET)
-
-#define S_C3INIT1 0
-#define M_C3INIT1 0x7fU
-#define V_C3INIT1(x) ((x) << S_C3INIT1)
-#define G_C3INIT1(x) (((x) >> S_C3INIT1) & M_C3INIT1)
-
-#define A_MAC_PORT_TX_LINKA_TRANSMIT_AE_C3_LIMIT_EXTENDED 0x50
-
-#define S_C3MAX 8
-#define M_C3MAX 0x7fU
-#define V_C3MAX(x) ((x) << S_C3MAX)
-#define G_C3MAX(x) (((x) >> S_C3MAX) & M_C3MAX)
-
-#define S_C3MIN 0
-#define M_C3MIN 0x7fU
-#define V_C3MIN(x) ((x) << S_C3MIN)
-#define G_C3MIN(x) (((x) >> S_C3MIN) & M_C3MIN)
-
-#define A_MAC_PORT_TX_LINKA_TRANSMIT_AE_C0_INIT2_EXTENDED 0x5c
-
-#define S_C0INIT2 0
-#define M_C0INIT2 0x7fU
-#define V_C0INIT2(x) ((x) << S_C0INIT2)
-#define G_C0INIT2(x) (((x) >> S_C0INIT2) & M_C0INIT2)
-
-#define A_MAC_PORT_TX_LINKA_TRANSMIT_AE_C1_INIT2_EXTENDED 0x60
-
-#define S_C1INIT2 0
-#define M_C1INIT2 0x7fU
-#define V_C1INIT2(x) ((x) << S_C1INIT2)
-#define G_C1INIT2(x) (((x) >> S_C1INIT2) & M_C1INIT2)
-
-#define A_MAC_PORT_TX_LINKA_TRANSMIT_AE_C2_INIT2_EXTENDED 0x68
-
-#define S_C2INIT2 0
-#define M_C2INIT2 0x7fU
-#define V_C2INIT2(x) ((x) << S_C2INIT2)
-#define G_C2INIT2(x) (((x) >> S_C2INIT2) & M_C2INIT2)
-
-#define A_MAC_PORT_TX_LINKA_TRANSMIT_AE_C3_INIT2_EXTENDED 0x70
-
-#define S_C3INIT2 0
-#define M_C3INIT2 0x7fU
-#define V_C3INIT2(x) ((x) << S_C3INIT2)
-#define G_C3INIT2(x) (((x) >> S_C3INIT2) & M_C3INIT2)
-
-#define A_MAC_PORT_TX_LINKB_TRANSMIT_802_3AP_STEP_SIZE_EXTENDED 0x0
-#define A_MAC_PORT_TX_LINKB_TRANSMIT_AE_STEP_SIZE_EXTENDED 0x0
-#define A_MAC_PORT_TX_LINKB_TRANSMIT_802_3AP_C0_INIT_EXTENDED 0x8
-#define A_MAC_PORT_TX_LINKB_TRANSMIT_802_3AP_C0_LIMIT_EXTENDED 0x10
-#define A_MAC_PORT_TX_LINKB_TRANSMIT_AE_C0_LIMIT_EXTENDED 0x10
-
-#define S_T6_C0MAX 8
-#define M_T6_C0MAX 0x7fU
-#define V_T6_C0MAX(x) ((x) << S_T6_C0MAX)
-#define G_T6_C0MAX(x) (((x) >> S_T6_C0MAX) & M_T6_C0MAX)
-
-#define S_T6_C0MIN 0
-#define M_T6_C0MIN 0x7fU
-#define V_T6_C0MIN(x) ((x) << S_T6_C0MIN)
-#define G_T6_C0MIN(x) (((x) >> S_T6_C0MIN) & M_T6_C0MIN)
-
-#define A_MAC_PORT_TX_LINKB_TRANSMIT_802_3AP_C1_INIT_EXTENDED 0x18
-#define A_MAC_PORT_TX_LINKB_TRANSMIT_AE_C1_INIT_EXTENDED 0x18
-#define A_MAC_PORT_TX_LINKB_TRANSMIT_802_3AP_C1_LIMIT_EXTENDED 0x20
-#define A_MAC_PORT_TX_LINKB_TRANSMIT_AE_C1_LIMIT_EXTENDED 0x20
-#define A_MAC_PORT_TX_LINKB_TRANSMIT_802_3AP_C2_INIT_EXTENDED 0x28
-#define A_MAC_PORT_TX_LINKB_TRANSMIT_AE_C2_INIT_EXTENDED 0x28
-#define A_MAC_PORT_TX_LINKB_TRANSMIT_802_3AP_C2_LIMIT_EXTENDED 0x30
-#define A_MAC_PORT_TX_LINKB_TRANSMIT_AE_C2_LIMIT_EXTENDED 0x30
-
-#define S_T6_C2MAX 8
-#define M_T6_C2MAX 0x7fU
-#define V_T6_C2MAX(x) ((x) << S_T6_C2MAX)
-#define G_T6_C2MAX(x) (((x) >> S_T6_C2MAX) & M_T6_C2MAX)
-
-#define S_T6_C2MIN 0
-#define M_T6_C2MIN 0x7fU
-#define V_T6_C2MIN(x) ((x) << S_T6_C2MIN)
-#define G_T6_C2MIN(x) (((x) >> S_T6_C2MIN) & M_T6_C2MIN)
-
-#define A_MAC_PORT_TX_LINKB_TRANSMIT_802_3AP_VM_LIMIT_EXTENDED 0x38
-#define A_MAC_PORT_TX_LINKB_TRANSMIT_AE_VM_LIMIT_EXTENDED 0x38
-#define A_MAC_PORT_TX_LINKB_TRANSMIT_802_3AP_V2_LIMIT_EXTENDED 0x40
-#define A_MAC_PORT_TX_LINKB_TRANSMIT_AE_V2_LIMIT_EXTENDED 0x40
-#define A_MAC_PORT_TX_LINKB_TRANSMIT_AE_C3_INIT_EXTENDED 0x48
-#define A_MAC_PORT_TX_LINKB_TRANSMIT_AE_C3_LIMIT_EXTENDED 0x50
-#define A_MAC_PORT_TX_LINKB_TRANSMIT_AE_C0_INIT2_EXTENDED 0x5c
-#define A_MAC_PORT_TX_LINKB_TRANSMIT_AE_C1_INIT2_EXTENDED 0x60
-#define A_MAC_PORT_TX_LINKB_TRANSMIT_AE_C2_INIT2_EXTENDED 0x68
-#define A_MAC_PORT_TX_LINKB_TRANSMIT_AE_C3_INIT2_EXTENDED 0x70
-#define A_MAC_PORT_TX_LINKC_TRANSMIT_802_3AP_STEP_SIZE_EXTENDED 0x0
-#define A_MAC_PORT_TX_LINKC_TRANSMIT_AE_STEP_SIZE_EXTENDED 0x0
-#define A_MAC_PORT_TX_LINKC_TRANSMIT_802_3AP_C0_INIT_EXTENDED 0x8
-#define A_MAC_PORT_TX_LINKC_TRANSMIT_802_3AP_C0_LIMIT_EXTENDED 0x10
-#define A_MAC_PORT_TX_LINKC_TRANSMIT_AE_C0_LIMIT_EXTENDED 0x10
-
-#define S_T6_C0MAX 8
-#define M_T6_C0MAX 0x7fU
-#define V_T6_C0MAX(x) ((x) << S_T6_C0MAX)
-#define G_T6_C0MAX(x) (((x) >> S_T6_C0MAX) & M_T6_C0MAX)
-
-#define S_T6_C0MIN 0
-#define M_T6_C0MIN 0x7fU
-#define V_T6_C0MIN(x) ((x) << S_T6_C0MIN)
-#define G_T6_C0MIN(x) (((x) >> S_T6_C0MIN) & M_T6_C0MIN)
-
-#define A_MAC_PORT_TX_LINKC_TRANSMIT_802_3AP_C1_INIT_EXTENDED 0x18
-#define A_MAC_PORT_TX_LINKC_TRANSMIT_AE_C1_INIT_EXTENDED 0x18
-#define A_MAC_PORT_TX_LINKC_TRANSMIT_802_3AP_C1_LIMIT_EXTENDED 0x20
-#define A_MAC_PORT_TX_LINKC_TRANSMIT_AE_C1_LIMIT_EXTENDED 0x20
-#define A_MAC_PORT_TX_LINKC_TRANSMIT_802_3AP_C2_INIT_EXTENDED 0x28
-#define A_MAC_PORT_TX_LINKC_TRANSMIT_AE_C2_INIT_EXTENDED 0x28
-#define A_MAC_PORT_TX_LINKC_TRANSMIT_802_3AP_C2_LIMIT_EXTENDED 0x30
-#define A_MAC_PORT_TX_LINKC_TRANSMIT_AE_C2_LIMIT_EXTENDED 0x30
-
-#define S_T6_C2MAX 8
-#define M_T6_C2MAX 0x7fU
-#define V_T6_C2MAX(x) ((x) << S_T6_C2MAX)
-#define G_T6_C2MAX(x) (((x) >> S_T6_C2MAX) & M_T6_C2MAX)
-
-#define S_T6_C2MIN 0
-#define M_T6_C2MIN 0x7fU
-#define V_T6_C2MIN(x) ((x) << S_T6_C2MIN)
-#define G_T6_C2MIN(x) (((x) >> S_T6_C2MIN) & M_T6_C2MIN)
-
-#define A_MAC_PORT_TX_LINKC_TRANSMIT_802_3AP_VM_LIMIT_EXTENDED 0x38
-#define A_MAC_PORT_TX_LINKC_TRANSMIT_AE_VM_LIMIT_EXTENDED 0x38
-#define A_MAC_PORT_TX_LINKC_TRANSMIT_802_3AP_V2_LIMIT_EXTENDED 0x40
-#define A_MAC_PORT_TX_LINKC_TRANSMIT_AE_V2_LIMIT_EXTENDED 0x40
-#define A_MAC_PORT_TX_LINKC_TRANSMIT_AE_C3_INIT_EXTENDED 0x48
-#define A_MAC_PORT_TX_LINKC_TRANSMIT_AE_C3_LIMIT_EXTENDED 0x50
-#define A_MAC_PORT_TX_LINKC_TRANSMIT_AE_C0_INIT2_EXTENDED 0x5c
-#define A_MAC_PORT_TX_LINKC_TRANSMIT_AE_C1_INIT2_EXTENDED 0x60
-#define A_MAC_PORT_TX_LINKC_TRANSMIT_AE_C2_INIT2_EXTENDED 0x68
-#define A_MAC_PORT_TX_LINKC_TRANSMIT_AE_C3_INIT2_EXTENDED 0x70
-#define A_MAC_PORT_TX_LINKD_TRANSMIT_802_3AP_STEP_SIZE_EXTENDED 0x0
-#define A_MAC_PORT_TX_LINKD_TRANSMIT_AE_STEP_SIZE_EXTENDED 0x0
-#define A_MAC_PORT_TX_LINKD_TRANSMIT_802_3AP_C0_INIT_EXTENDED 0x8
-#define A_MAC_PORT_TX_LINKD_TRANSMIT_802_3AP_C0_LIMIT_EXTENDED 0x10
-#define A_MAC_PORT_TX_LINKD_TRANSMIT_AE_C0_LIMIT_EXTENDED 0x10
-
-#define S_T6_C0MAX 8
-#define M_T6_C0MAX 0x7fU
-#define V_T6_C0MAX(x) ((x) << S_T6_C0MAX)
-#define G_T6_C0MAX(x) (((x) >> S_T6_C0MAX) & M_T6_C0MAX)
-
-#define S_T6_C0MIN 0
-#define M_T6_C0MIN 0x7fU
-#define V_T6_C0MIN(x) ((x) << S_T6_C0MIN)
-#define G_T6_C0MIN(x) (((x) >> S_T6_C0MIN) & M_T6_C0MIN)
-
-#define A_MAC_PORT_TX_LINKD_TRANSMIT_802_3AP_C1_INIT_EXTENDED 0x18
-#define A_MAC_PORT_TX_LINKD_TRANSMIT_AE_C1_INIT_EXTENDED 0x18
-#define A_MAC_PORT_TX_LINKD_TRANSMIT_802_3AP_C1_LIMIT_EXTENDED 0x20
-#define A_MAC_PORT_TX_LINKD_TRANSMIT_AE_C1_LIMIT_EXTENDED 0x20
-#define A_MAC_PORT_TX_LINKD_TRANSMIT_802_3AP_C2_INIT_EXTENDED 0x28
-#define A_MAC_PORT_TX_LINKD_TRANSMIT_AE_C2_INIT_EXTENDED 0x28
-#define A_MAC_PORT_TX_LINKD_TRANSMIT_802_3AP_C2_LIMIT_EXTENDED 0x30
-#define A_MAC_PORT_TX_LINKD_TRANSMIT_AE_C2_LIMIT_EXTENDED 0x30
-
-#define S_T6_C2MAX 8
-#define M_T6_C2MAX 0x7fU
-#define V_T6_C2MAX(x) ((x) << S_T6_C2MAX)
-#define G_T6_C2MAX(x) (((x) >> S_T6_C2MAX) & M_T6_C2MAX)
-
-#define S_T6_C2MIN 0
-#define M_T6_C2MIN 0x7fU
-#define V_T6_C2MIN(x) ((x) << S_T6_C2MIN)
-#define G_T6_C2MIN(x) (((x) >> S_T6_C2MIN) & M_T6_C2MIN)
-
-#define A_MAC_PORT_TX_LINKD_TRANSMIT_802_3AP_VM_LIMIT_EXTENDED 0x38
-#define A_MAC_PORT_TX_LINKD_TRANSMIT_AE_VM_LIMIT_EXTENDED 0x38
-#define A_MAC_PORT_TX_LINKD_TRANSMIT_802_3AP_V2_LIMIT_EXTENDED 0x40
-#define A_MAC_PORT_TX_LINKD_TRANSMIT_AE_V2_LIMIT_EXTENDED 0x40
-#define A_MAC_PORT_TX_LINKD_TRANSMIT_AE_C3_INIT_EXTENDED 0x48
-#define A_MAC_PORT_TX_LINKD_TRANSMIT_AE_C3_LIMIT_EXTENDED 0x50
-#define A_MAC_PORT_TX_LINKD_TRANSMIT_AE_C0_INIT2_EXTENDED 0x5c
-#define A_MAC_PORT_TX_LINKD_TRANSMIT_AE_C1_INIT2_EXTENDED 0x60
-#define A_MAC_PORT_TX_LINKD_TRANSMIT_AE_C2_INIT2_EXTENDED 0x68
-#define A_MAC_PORT_TX_LINKD_TRANSMIT_AE_C3_INIT2_EXTENDED 0x70
-#define A_MAC_PORT_TX_LINK_BCST_TRANSMIT_802_3AP_STEP_SIZE_EXTENDED 0x0
-#define A_MAC_PORT_TX_LINK_BCST_TRANSMIT_AE_STEP_SIZE_EXTENDED 0x0
-#define A_MAC_PORT_TX_LINK_BCST_TRANSMIT_802_3AP_C0_INIT_EXTENDED 0x8
-#define A_MAC_PORT_TX_LINK_BCST_TRANSMIT_802_3AP_C0_LIMIT_EXTENDED 0x10
-#define A_MAC_PORT_TX_LINK_BCST_TRANSMIT_AE_C0_LIMIT_EXTENDED 0x10
-
-#define S_T6_C0MAX 8
-#define M_T6_C0MAX 0x7fU
-#define V_T6_C0MAX(x) ((x) << S_T6_C0MAX)
-#define G_T6_C0MAX(x) (((x) >> S_T6_C0MAX) & M_T6_C0MAX)
-
-#define S_T6_C0MIN 0
-#define M_T6_C0MIN 0x7fU
-#define V_T6_C0MIN(x) ((x) << S_T6_C0MIN)
-#define G_T6_C0MIN(x) (((x) >> S_T6_C0MIN) & M_T6_C0MIN)
-
-#define A_MAC_PORT_TX_LINK_BCST_TRANSMIT_802_3AP_C1_INIT_EXTENDED 0x18
-#define A_MAC_PORT_TX_LINK_BCST_TRANSMIT_AE_C1_INIT_EXTENDED 0x18
-#define A_MAC_PORT_TX_LINK_BCST_TRANSMIT_802_3AP_C1_LIMIT_EXTENDED 0x20
-#define A_MAC_PORT_TX_LINK_BCST_TRANSMIT_AE_C1_LIMIT_EXTENDED 0x20
-#define A_MAC_PORT_TX_LINK_BCST_TRANSMIT_802_3AP_C2_INIT_EXTENDED 0x28
-#define A_MAC_PORT_TX_LINK_BCST_TRANSMIT_AE_C2_INIT_EXTENDED 0x28
-#define A_MAC_PORT_TX_LINK_BCST_TRANSMIT_802_3AP_C2_LIMIT_EXTENDED 0x30
-#define A_MAC_PORT_TX_LINK_BCST_TRANSMIT_AE_C2_LIMIT_EXTENDED 0x30
-
-#define S_T6_C2MAX 8
-#define M_T6_C2MAX 0x7fU
-#define V_T6_C2MAX(x) ((x) << S_T6_C2MAX)
-#define G_T6_C2MAX(x) (((x) >> S_T6_C2MAX) & M_T6_C2MAX)
-
-#define S_T6_C2MIN 0
-#define M_T6_C2MIN 0x7fU
-#define V_T6_C2MIN(x) ((x) << S_T6_C2MIN)
-#define G_T6_C2MIN(x) (((x) >> S_T6_C2MIN) & M_T6_C2MIN)
-
-#define A_MAC_PORT_TX_LINK_BCST_TRANSMIT_802_3AP_VM_LIMIT_EXTENDED 0x38
-#define A_MAC_PORT_TX_LINK_BCST_TRANSMIT_AE_VM_LIMIT_EXTENDED 0x38
-#define A_MAC_PORT_TX_LINK_BCST_TRANSMIT_802_3AP_V2_LIMIT_EXTENDED 0x40
-#define A_MAC_PORT_TX_LINK_BCST_TRANSMIT_AE_V2_LIMIT_EXTENDED 0x40
-#define A_MAC_PORT_TX_LINK_BCST_TRANSMIT_AE_C3_INIT_EXTENDED 0x48
-#define A_MAC_PORT_TX_LINK_BCST_TRANSMIT_AE_C3_LIMIT_EXTENDED 0x50
-#define A_MAC_PORT_TX_LINK_BCST_TRANSMIT_AE_C0_INIT2_EXTENDED 0x5c
-#define A_MAC_PORT_TX_LINK_BCST_TRANSMIT_AE_C1_INIT2_EXTENDED 0x60
-#define A_MAC_PORT_TX_LINK_BCST_TRANSMIT_AE_C2_INIT2_EXTENDED 0x68
-#define A_MAC_PORT_TX_LINK_BCST_TRANSMIT_AE_C3_INIT2_EXTENDED 0x70
-#define A_T6_MAC_PORT_RX_LINKA_DFE_TAP_ENABLE 0x2a00
-
-#define S_RX_LINKA_INDEX_DFE_EN 1
-#define M_RX_LINKA_INDEX_DFE_EN 0x7fffU
-#define V_RX_LINKA_INDEX_DFE_EN(x) ((x) << S_RX_LINKA_INDEX_DFE_EN)
-#define G_RX_LINKA_INDEX_DFE_EN(x) (((x) >> S_RX_LINKA_INDEX_DFE_EN) & M_RX_LINKA_INDEX_DFE_EN)
-
-#define A_T6_MAC_PORT_RX_LINKA_DFE_H1 0x2a04
-
-#define S_T6_H1OSN 13
-#define M_T6_H1OSN 0x7U
-#define V_T6_H1OSN(x) ((x) << S_T6_H1OSN)
-#define G_T6_H1OSN(x) (((x) >> S_T6_H1OSN) & M_T6_H1OSN)
-
-#define S_T6_H1OMAG 8
-#define M_T6_H1OMAG 0x1fU
-#define V_T6_H1OMAG(x) ((x) << S_T6_H1OMAG)
-#define G_T6_H1OMAG(x) (((x) >> S_T6_H1OMAG) & M_T6_H1OMAG)
-
-#define A_T6_MAC_PORT_RX_LINKA_DFE_H2 0x2a08
-#define A_T6_MAC_PORT_RX_LINKA_DFE_H3 0x2a0c
-#define A_T6_MAC_PORT_RX_LINKA_DFE_H4 0x2a10
-
-#define S_H4SN 4
-#define M_H4SN 0x3U
-#define V_H4SN(x) ((x) << S_H4SN)
-#define G_H4SN(x) (((x) >> S_H4SN) & M_H4SN)
-
-#define S_H4MAG 0
-#define M_H4MAG 0xfU
-#define V_H4MAG(x) ((x) << S_H4MAG)
-#define G_H4MAG(x) (((x) >> S_H4MAG) & M_H4MAG)
-
-#define A_T6_MAC_PORT_RX_LINKA_DFE_H5 0x2a14
-
-#define S_H5GS 6
-#define M_H5GS 0x3U
-#define V_H5GS(x) ((x) << S_H5GS)
-#define G_H5GS(x) (((x) >> S_H5GS) & M_H5GS)
-
-#define S_H5SN 4
-#define M_H5SN 0x3U
-#define V_H5SN(x) ((x) << S_H5SN)
-#define G_H5SN(x) (((x) >> S_H5SN) & M_H5SN)
-
-#define S_H5MAG 0
-#define M_H5MAG 0xfU
-#define V_H5MAG(x) ((x) << S_H5MAG)
-#define G_H5MAG(x) (((x) >> S_H5MAG) & M_H5MAG)
-
-#define A_T6_MAC_PORT_RX_LINKA_DFE_H6_AND_H7 0x2a18
-
-#define S_H7SN 12
-#define M_H7SN 0x3U
-#define V_H7SN(x) ((x) << S_H7SN)
-#define G_H7SN(x) (((x) >> S_H7SN) & M_H7SN)
-
-#define S_H6SN 4
-#define M_H6SN 0x3U
-#define V_H6SN(x) ((x) << S_H6SN)
-#define G_H6SN(x) (((x) >> S_H6SN) & M_H6SN)
-
-#define A_T6_MAC_PORT_RX_LINKA_DFE_H8_AND_H9 0x2a1c
-
-#define S_H9SN 12
-#define M_H9SN 0x3U
-#define V_H9SN(x) ((x) << S_H9SN)
-#define G_H9SN(x) (((x) >> S_H9SN) & M_H9SN)
-
-#define S_H8SN 4
-#define M_H8SN 0x3U
-#define V_H8SN(x) ((x) << S_H8SN)
-#define G_H8SN(x) (((x) >> S_H8SN) & M_H8SN)
-
-#define A_T6_MAC_PORT_RX_LINKA_DFE_H10_AND_H11 0x2a20
-
-#define S_H11SN 12
-#define M_H11SN 0x3U
-#define V_H11SN(x) ((x) << S_H11SN)
-#define G_H11SN(x) (((x) >> S_H11SN) & M_H11SN)
-
-#define S_H10SN 4
-#define M_H10SN 0x3U
-#define V_H10SN(x) ((x) << S_H10SN)
-#define G_H10SN(x) (((x) >> S_H10SN) & M_H10SN)
-
-#define A_MAC_PORT_RX_LINKA_DFE_H12_13 0x2a24
-
-#define S_H13GS 13
-#define M_H13GS 0x7U
-#define V_H13GS(x) ((x) << S_H13GS)
-#define G_H13GS(x) (((x) >> S_H13GS) & M_H13GS)
-
-#define S_H13SN 10
-#define M_H13SN 0x7U
-#define V_H13SN(x) ((x) << S_H13SN)
-#define G_H13SN(x) (((x) >> S_H13SN) & M_H13SN)
-
-#define S_H13MAG 8
-#define M_H13MAG 0x3U
-#define V_H13MAG(x) ((x) << S_H13MAG)
-#define G_H13MAG(x) (((x) >> S_H13MAG) & M_H13MAG)
-
-#define S_H12SN 4
-#define M_H12SN 0x3U
-#define V_H12SN(x) ((x) << S_H12SN)
-#define G_H12SN(x) (((x) >> S_H12SN) & M_H12SN)
-
-#define A_MAC_PORT_RX_LINKA_DFE_H14_15 0x2a28
-
-#define S_H15GS 13
-#define M_H15GS 0x7U
-#define V_H15GS(x) ((x) << S_H15GS)
-#define G_H15GS(x) (((x) >> S_H15GS) & M_H15GS)
-
-#define S_H15SN 10
-#define M_H15SN 0x7U
-#define V_H15SN(x) ((x) << S_H15SN)
-#define G_H15SN(x) (((x) >> S_H15SN) & M_H15SN)
-
-#define S_H15MAG 8
-#define M_H15MAG 0x3U
-#define V_H15MAG(x) ((x) << S_H15MAG)
-#define G_H15MAG(x) (((x) >> S_H15MAG) & M_H15MAG)
-
-#define S_H14GS 6
-#define M_H14GS 0x3U
-#define V_H14GS(x) ((x) << S_H14GS)
-#define G_H14GS(x) (((x) >> S_H14GS) & M_H14GS)
-
-#define S_H14SN 4
-#define M_H14SN 0x3U
-#define V_H14SN(x) ((x) << S_H14SN)
-#define G_H14SN(x) (((x) >> S_H14SN) & M_H14SN)
-
-#define S_H14MAG 0
-#define M_H14MAG 0xfU
-#define V_H14MAG(x) ((x) << S_H14MAG)
-#define G_H14MAG(x) (((x) >> S_H14MAG) & M_H14MAG)
-
-#define A_MAC_PORT_RX_LINKA_DFE_H1ODD_DELTA_AND_H1EVEN_DELTA 0x2a2c
-
-#define S_H1ODELTA 8
-#define M_H1ODELTA 0x1fU
-#define V_H1ODELTA(x) ((x) << S_H1ODELTA)
-#define G_H1ODELTA(x) (((x) >> S_H1ODELTA) & M_H1ODELTA)
-
-#define S_H1EDELTA 0
-#define M_H1EDELTA 0x3fU
-#define V_H1EDELTA(x) ((x) << S_H1EDELTA)
-#define G_H1EDELTA(x) (((x) >> S_H1EDELTA) & M_H1EDELTA)
-
-#define A_T6_MAC_PORT_RX_LINKB_DFE_TAP_ENABLE 0x2b00
-
-#define S_RX_LINKB_INDEX_DFE_EN 1
-#define M_RX_LINKB_INDEX_DFE_EN 0x7fffU
-#define V_RX_LINKB_INDEX_DFE_EN(x) ((x) << S_RX_LINKB_INDEX_DFE_EN)
-#define G_RX_LINKB_INDEX_DFE_EN(x) (((x) >> S_RX_LINKB_INDEX_DFE_EN) & M_RX_LINKB_INDEX_DFE_EN)
-
-#define A_T6_MAC_PORT_RX_LINKB_DFE_H1 0x2b04
-
-#define S_T6_H1OSN 13
-#define M_T6_H1OSN 0x7U
-#define V_T6_H1OSN(x) ((x) << S_T6_H1OSN)
-#define G_T6_H1OSN(x) (((x) >> S_T6_H1OSN) & M_T6_H1OSN)
-
-#define S_T6_H1OMAG 8
-#define M_T6_H1OMAG 0x1fU
-#define V_T6_H1OMAG(x) ((x) << S_T6_H1OMAG)
-#define G_T6_H1OMAG(x) (((x) >> S_T6_H1OMAG) & M_T6_H1OMAG)
-
-#define A_T6_MAC_PORT_RX_LINKB_DFE_H2 0x2b08
-#define A_T6_MAC_PORT_RX_LINKB_DFE_H3 0x2b0c
-#define A_T6_MAC_PORT_RX_LINKB_DFE_H4 0x2b10
-#define A_T6_MAC_PORT_RX_LINKB_DFE_H5 0x2b14
-#define A_T6_MAC_PORT_RX_LINKB_DFE_H6_AND_H7 0x2b18
-#define A_T6_MAC_PORT_RX_LINKB_DFE_H8_AND_H9 0x2b1c
-#define A_T6_MAC_PORT_RX_LINKB_DFE_H10_AND_H11 0x2b20
-#define A_MAC_PORT_RX_LINKB_DFE_H12_13 0x2b24
-#define A_MAC_PORT_RX_LINKB_DFE_H14_15 0x2b28
-#define A_MAC_PORT_RX_LINKB_DFE_H1ODD_DELTA_AND_H1EVEN_DELTA 0x2b2c
-#define A_T6_MAC_PORT_RX_LINKC_DFE_TAP_ENABLE 0x2e00
-
-#define S_RX_LINKC_INDEX_DFE_EN 1
-#define M_RX_LINKC_INDEX_DFE_EN 0x7fffU
-#define V_RX_LINKC_INDEX_DFE_EN(x) ((x) << S_RX_LINKC_INDEX_DFE_EN)
-#define G_RX_LINKC_INDEX_DFE_EN(x) (((x) >> S_RX_LINKC_INDEX_DFE_EN) & M_RX_LINKC_INDEX_DFE_EN)
-
-#define A_T6_MAC_PORT_RX_LINKC_DFE_H1 0x2e04
-
-#define S_T6_H1OSN 13
-#define M_T6_H1OSN 0x7U
-#define V_T6_H1OSN(x) ((x) << S_T6_H1OSN)
-#define G_T6_H1OSN(x) (((x) >> S_T6_H1OSN) & M_T6_H1OSN)
-
-#define S_T6_H1OMAG 8
-#define M_T6_H1OMAG 0x1fU
-#define V_T6_H1OMAG(x) ((x) << S_T6_H1OMAG)
-#define G_T6_H1OMAG(x) (((x) >> S_T6_H1OMAG) & M_T6_H1OMAG)
-
-#define A_T6_MAC_PORT_RX_LINKC_DFE_H2 0x2e08
-#define A_T6_MAC_PORT_RX_LINKC_DFE_H3 0x2e0c
-#define A_T6_MAC_PORT_RX_LINKC_DFE_H4 0x2e10
-#define A_T6_MAC_PORT_RX_LINKC_DFE_H5 0x2e14
-#define A_T6_MAC_PORT_RX_LINKC_DFE_H6_AND_H7 0x2e18
-#define A_T6_MAC_PORT_RX_LINKC_DFE_H8_AND_H9 0x2e1c
-#define A_T6_MAC_PORT_RX_LINKC_DFE_H10_AND_H11 0x2e20
-#define A_MAC_PORT_RX_LINKC_DFE_H12_13 0x2e24
-#define A_MAC_PORT_RX_LINKC_DFE_H14_15 0x2e28
-#define A_MAC_PORT_RX_LINKC_DFE_H1ODD_DELTA_AND_H1EVEN_DELTA 0x2e2c
-#define A_T6_MAC_PORT_RX_LINKD_DFE_TAP_ENABLE 0x2f00
-
-#define S_RX_LINKD_INDEX_DFE_EN 1
-#define M_RX_LINKD_INDEX_DFE_EN 0x7fffU
-#define V_RX_LINKD_INDEX_DFE_EN(x) ((x) << S_RX_LINKD_INDEX_DFE_EN)
-#define G_RX_LINKD_INDEX_DFE_EN(x) (((x) >> S_RX_LINKD_INDEX_DFE_EN) & M_RX_LINKD_INDEX_DFE_EN)
-
-#define A_T6_MAC_PORT_RX_LINKD_DFE_H1 0x2f04
-
-#define S_T6_H1OSN 13
-#define M_T6_H1OSN 0x7U
-#define V_T6_H1OSN(x) ((x) << S_T6_H1OSN)
-#define G_T6_H1OSN(x) (((x) >> S_T6_H1OSN) & M_T6_H1OSN)
-
-#define S_T6_H1OMAG 8
-#define M_T6_H1OMAG 0x1fU
-#define V_T6_H1OMAG(x) ((x) << S_T6_H1OMAG)
-#define G_T6_H1OMAG(x) (((x) >> S_T6_H1OMAG) & M_T6_H1OMAG)
-
-#define A_T6_MAC_PORT_RX_LINKD_DFE_H2 0x2f08
-#define A_T6_MAC_PORT_RX_LINKD_DFE_H3 0x2f0c
-#define A_T6_MAC_PORT_RX_LINKD_DFE_H4 0x2f10
-#define A_T6_MAC_PORT_RX_LINKD_DFE_H5 0x2f14
-#define A_T6_MAC_PORT_RX_LINKD_DFE_H6_AND_H7 0x2f18
-#define A_T6_MAC_PORT_RX_LINKD_DFE_H8_AND_H9 0x2f1c
-#define A_T6_MAC_PORT_RX_LINKD_DFE_H10_AND_H11 0x2f20
-#define A_MAC_PORT_RX_LINKD_DFE_H12_13 0x2f24
-#define A_MAC_PORT_RX_LINKD_DFE_H14_15 0x2f28
-#define A_MAC_PORT_RX_LINKD_DFE_H1ODD_DELTA_AND_H1EVEN_DELTA 0x2f2c
-#define A_T6_MAC_PORT_RX_LINK_BCST_DFE_TAP_ENABLE 0x3200
-
-#define S_RX_LINK_BCST_INDEX_DFE_EN 1
-#define M_RX_LINK_BCST_INDEX_DFE_EN 0x7fffU
-#define V_RX_LINK_BCST_INDEX_DFE_EN(x) ((x) << S_RX_LINK_BCST_INDEX_DFE_EN)
-#define G_RX_LINK_BCST_INDEX_DFE_EN(x) (((x) >> S_RX_LINK_BCST_INDEX_DFE_EN) & M_RX_LINK_BCST_INDEX_DFE_EN)
-
-#define A_T6_MAC_PORT_RX_LINK_BCST_DFE_H1 0x3204
-
-#define S_T6_H1OSN 13
-#define M_T6_H1OSN 0x7U
-#define V_T6_H1OSN(x) ((x) << S_T6_H1OSN)
-#define G_T6_H1OSN(x) (((x) >> S_T6_H1OSN) & M_T6_H1OSN)
-
-#define S_T6_H1OMAG 8
-#define M_T6_H1OMAG 0x1fU
-#define V_T6_H1OMAG(x) ((x) << S_T6_H1OMAG)
-#define G_T6_H1OMAG(x) (((x) >> S_T6_H1OMAG) & M_T6_H1OMAG)
-
-#define A_T6_MAC_PORT_RX_LINK_BCST_DFE_H2 0x3208
-#define A_T6_MAC_PORT_RX_LINK_BCST_DFE_H3 0x320c
-#define A_T6_MAC_PORT_RX_LINK_BCST_DFE_H4 0x3210
-#define A_T6_MAC_PORT_RX_LINK_BCST_DFE_H5 0x3214
-#define A_T6_MAC_PORT_RX_LINK_BCST_DFE_H6_AND_H7 0x3218
-#define A_T6_MAC_PORT_RX_LINK_BCST_DFE_H8_AND_H9 0x321c
-#define A_T6_MAC_PORT_RX_LINK_BCST_DFE_H10_AND_H11 0x3220
-#define A_MAC_PORT_RX_LINK_BCST_DFE_H12_13 0x3224
-#define A_MAC_PORT_RX_LINK_BCST_DFE_H14_15 0x3228
-#define A_MAC_PORT_RX_LINK_BCST_DFE_H1ODD_DELTA_AND_H1EVEN_DELTA 0x322c
-
-/* registers for module MC_0 */
-#define MC_0_BASE_ADDR 0x40000
-
-#define A_MC_UPCTL_SCFG 0x40000
-
-#define S_BBFLAGS_TIMING 8
-#define M_BBFLAGS_TIMING 0xfU
-#define V_BBFLAGS_TIMING(x) ((x) << S_BBFLAGS_TIMING)
-#define G_BBFLAGS_TIMING(x) (((x) >> S_BBFLAGS_TIMING) & M_BBFLAGS_TIMING)
-
-#define S_NFIFO_NIF1_DIS 6
-#define V_NFIFO_NIF1_DIS(x) ((x) << S_NFIFO_NIF1_DIS)
-#define F_NFIFO_NIF1_DIS V_NFIFO_NIF1_DIS(1U)
-
-#define A_MC_UPCTL_SCTL 0x40004
-#define A_MC_UPCTL_STAT 0x40008
-
-#define S_LP_TRIG 4
-#define M_LP_TRIG 0x7U
-#define V_LP_TRIG(x) ((x) << S_LP_TRIG)
-#define G_LP_TRIG(x) (((x) >> S_LP_TRIG) & M_LP_TRIG)
-
-#define A_MC_UPCTL_INTRSTAT 0x4000c
-
-#define S_PARITY_INTR 1
-#define V_PARITY_INTR(x) ((x) << S_PARITY_INTR)
-#define F_PARITY_INTR V_PARITY_INTR(1U)
-
-#define S_ECC_INTR 0
-#define V_ECC_INTR(x) ((x) << S_ECC_INTR)
-#define F_ECC_INTR V_ECC_INTR(1U)
-
-#define A_MC_UPCTL_MCMD 0x40040
-
-#define S_CMD_OPCODE0 0
-#define M_CMD_OPCODE0 0xfU
-#define V_CMD_OPCODE0(x) ((x) << S_CMD_OPCODE0)
-#define G_CMD_OPCODE0(x) (((x) >> S_CMD_OPCODE0) & M_CMD_OPCODE0)
-
-#define A_MC_LMC_MCSTAT 0x40040
-
-#define S_INIT_COMPLETE 31
-#define V_INIT_COMPLETE(x) ((x) << S_INIT_COMPLETE)
-#define F_INIT_COMPLETE V_INIT_COMPLETE(1U)
-
-#define S_SELF_REF_MODE 30
-#define V_SELF_REF_MODE(x) ((x) << S_SELF_REF_MODE)
-#define F_SELF_REF_MODE V_SELF_REF_MODE(1U)
-
-#define S_IDLE 29
-#define V_IDLE(x) ((x) << S_IDLE)
-#define F_IDLE V_IDLE(1U)
-
-#define S_T6_DFI_INIT_COMPLETE 28
-#define V_T6_DFI_INIT_COMPLETE(x) ((x) << S_T6_DFI_INIT_COMPLETE)
-#define F_T6_DFI_INIT_COMPLETE V_T6_DFI_INIT_COMPLETE(1U)
-
-#define S_PREFILL_COMPLETE 27
-#define V_PREFILL_COMPLETE(x) ((x) << S_PREFILL_COMPLETE)
-#define F_PREFILL_COMPLETE V_PREFILL_COMPLETE(1U)
-
-#define A_MC_UPCTL_POWCTL 0x40044
-#define A_MC_UPCTL_POWSTAT 0x40048
-#define A_MC_UPCTL_CMDTSTAT 0x4004c
-
-#define S_CMD_TSTAT 0
-#define V_CMD_TSTAT(x) ((x) << S_CMD_TSTAT)
-#define F_CMD_TSTAT V_CMD_TSTAT(1U)
-
-#define A_MC_UPCTL_CMDTSTATEN 0x40050
-
-#define S_CMD_TSTAT_EN 0
-#define V_CMD_TSTAT_EN(x) ((x) << S_CMD_TSTAT_EN)
-#define F_CMD_TSTAT_EN V_CMD_TSTAT_EN(1U)
-
-#define A_MC_UPCTL_MRRCFG0 0x40060
-
-#define S_MRR_BYTE_SEL 0
-#define M_MRR_BYTE_SEL 0xfU
-#define V_MRR_BYTE_SEL(x) ((x) << S_MRR_BYTE_SEL)
-#define G_MRR_BYTE_SEL(x) (((x) >> S_MRR_BYTE_SEL) & M_MRR_BYTE_SEL)
-
-#define A_MC_UPCTL_MRRSTAT0 0x40064
-
-#define S_MRRSTAT_BEAT3 24
-#define M_MRRSTAT_BEAT3 0xffU
-#define V_MRRSTAT_BEAT3(x) ((x) << S_MRRSTAT_BEAT3)
-#define G_MRRSTAT_BEAT3(x) (((x) >> S_MRRSTAT_BEAT3) & M_MRRSTAT_BEAT3)
-
-#define S_MRRSTAT_BEAT2 16
-#define M_MRRSTAT_BEAT2 0xffU
-#define V_MRRSTAT_BEAT2(x) ((x) << S_MRRSTAT_BEAT2)
-#define G_MRRSTAT_BEAT2(x) (((x) >> S_MRRSTAT_BEAT2) & M_MRRSTAT_BEAT2)
-
-#define S_MRRSTAT_BEAT1 8
-#define M_MRRSTAT_BEAT1 0xffU
-#define V_MRRSTAT_BEAT1(x) ((x) << S_MRRSTAT_BEAT1)
-#define G_MRRSTAT_BEAT1(x) (((x) >> S_MRRSTAT_BEAT1) & M_MRRSTAT_BEAT1)
-
-#define S_MRRSTAT_BEAT0 0
-#define M_MRRSTAT_BEAT0 0xffU
-#define V_MRRSTAT_BEAT0(x) ((x) << S_MRRSTAT_BEAT0)
-#define G_MRRSTAT_BEAT0(x) (((x) >> S_MRRSTAT_BEAT0) & M_MRRSTAT_BEAT0)
-
-#define A_MC_UPCTL_MRRSTAT1 0x40068
-
-#define S_MRRSTAT_BEAT7 24
-#define M_MRRSTAT_BEAT7 0xffU
-#define V_MRRSTAT_BEAT7(x) ((x) << S_MRRSTAT_BEAT7)
-#define G_MRRSTAT_BEAT7(x) (((x) >> S_MRRSTAT_BEAT7) & M_MRRSTAT_BEAT7)
-
-#define S_MRRSTAT_BEAT6 16
-#define M_MRRSTAT_BEAT6 0xffU
-#define V_MRRSTAT_BEAT6(x) ((x) << S_MRRSTAT_BEAT6)
-#define G_MRRSTAT_BEAT6(x) (((x) >> S_MRRSTAT_BEAT6) & M_MRRSTAT_BEAT6)
-
-#define S_MRRSTAT_BEAT5 8
-#define M_MRRSTAT_BEAT5 0xffU
-#define V_MRRSTAT_BEAT5(x) ((x) << S_MRRSTAT_BEAT5)
-#define G_MRRSTAT_BEAT5(x) (((x) >> S_MRRSTAT_BEAT5) & M_MRRSTAT_BEAT5)
-
-#define S_MRRSTAT_BEAT4 0
-#define M_MRRSTAT_BEAT4 0xffU
-#define V_MRRSTAT_BEAT4(x) ((x) << S_MRRSTAT_BEAT4)
-#define G_MRRSTAT_BEAT4(x) (((x) >> S_MRRSTAT_BEAT4) & M_MRRSTAT_BEAT4)
-
-#define A_MC_UPCTL_MCFG1 0x4007c
-
-#define S_HW_EXIT_IDLE_EN 31
-#define V_HW_EXIT_IDLE_EN(x) ((x) << S_HW_EXIT_IDLE_EN)
-#define F_HW_EXIT_IDLE_EN V_HW_EXIT_IDLE_EN(1U)
-
-#define S_HW_IDLE 16
-#define M_HW_IDLE 0xffU
-#define V_HW_IDLE(x) ((x) << S_HW_IDLE)
-#define G_HW_IDLE(x) (((x) >> S_HW_IDLE) & M_HW_IDLE)
-
-#define S_SR_IDLE 0
-#define M_SR_IDLE 0xffU
-#define V_SR_IDLE(x) ((x) << S_SR_IDLE)
-#define G_SR_IDLE(x) (((x) >> S_SR_IDLE) & M_SR_IDLE)
-
-#define A_MC_UPCTL_MCFG 0x40080
-
-#define S_MDDR_LPDDR2_CLK_STOP_IDLE 24
-#define M_MDDR_LPDDR2_CLK_STOP_IDLE 0xffU
-#define V_MDDR_LPDDR2_CLK_STOP_IDLE(x) ((x) << S_MDDR_LPDDR2_CLK_STOP_IDLE)
-#define G_MDDR_LPDDR2_CLK_STOP_IDLE(x) (((x) >> S_MDDR_LPDDR2_CLK_STOP_IDLE) & M_MDDR_LPDDR2_CLK_STOP_IDLE)
-
-#define S_MDDR_LPDDR2_EN 22
-#define M_MDDR_LPDDR2_EN 0x3U
-#define V_MDDR_LPDDR2_EN(x) ((x) << S_MDDR_LPDDR2_EN)
-#define G_MDDR_LPDDR2_EN(x) (((x) >> S_MDDR_LPDDR2_EN) & M_MDDR_LPDDR2_EN)
-
-#define S_MDDR_LPDDR2_BL 20
-#define M_MDDR_LPDDR2_BL 0x3U
-#define V_MDDR_LPDDR2_BL(x) ((x) << S_MDDR_LPDDR2_BL)
-#define G_MDDR_LPDDR2_BL(x) (((x) >> S_MDDR_LPDDR2_BL) & M_MDDR_LPDDR2_BL)
-
-#define S_LPDDR2_S4 6
-#define V_LPDDR2_S4(x) ((x) << S_LPDDR2_S4)
-#define F_LPDDR2_S4 V_LPDDR2_S4(1U)
-
-#define S_STAGGER_CS 4
-#define V_STAGGER_CS(x) ((x) << S_STAGGER_CS)
-#define F_STAGGER_CS V_STAGGER_CS(1U)
-
-#define S_CKE_OR_EN 1
-#define V_CKE_OR_EN(x) ((x) << S_CKE_OR_EN)
-#define F_CKE_OR_EN V_CKE_OR_EN(1U)
-
-#define A_MC_LMC_MCOPT1 0x40080
-
-#define S_MC_PROTOCOL 31
-#define V_MC_PROTOCOL(x) ((x) << S_MC_PROTOCOL)
-#define F_MC_PROTOCOL V_MC_PROTOCOL(1U)
-
-#define S_DM_ENABLE 30
-#define V_DM_ENABLE(x) ((x) << S_DM_ENABLE)
-#define F_DM_ENABLE V_DM_ENABLE(1U)
-
-#define S_T6_ECC_EN 29
-#define V_T6_ECC_EN(x) ((x) << S_T6_ECC_EN)
-#define F_T6_ECC_EN V_T6_ECC_EN(1U)
-
-#define S_ECC_COR 28
-#define V_ECC_COR(x) ((x) << S_ECC_COR)
-#define F_ECC_COR V_ECC_COR(1U)
-
-#define S_RDIMM 27
-#define V_RDIMM(x) ((x) << S_RDIMM)
-#define F_RDIMM V_RDIMM(1U)
-
-#define S_PMUM 25
-#define M_PMUM 0x3U
-#define V_PMUM(x) ((x) << S_PMUM)
-#define G_PMUM(x) (((x) >> S_PMUM) & M_PMUM)
-
-#define S_WIDTH0 24
-#define V_WIDTH0(x) ((x) << S_WIDTH0)
-#define F_WIDTH0 V_WIDTH0(1U)
-
-#define S_PORT_ID_CHK_EN 23
-#define V_PORT_ID_CHK_EN(x) ((x) << S_PORT_ID_CHK_EN)
-#define F_PORT_ID_CHK_EN V_PORT_ID_CHK_EN(1U)
-
-#define S_UIOS 22
-#define V_UIOS(x) ((x) << S_UIOS)
-#define F_UIOS V_UIOS(1U)
-
-#define S_QUADCS_RDIMM 21
-#define V_QUADCS_RDIMM(x) ((x) << S_QUADCS_RDIMM)
-#define F_QUADCS_RDIMM V_QUADCS_RDIMM(1U)
-
-#define S_ZQCL_EN 20
-#define V_ZQCL_EN(x) ((x) << S_ZQCL_EN)
-#define F_ZQCL_EN V_ZQCL_EN(1U)
-
-#define S_WIDTH1 19
-#define V_WIDTH1(x) ((x) << S_WIDTH1)
-#define F_WIDTH1 V_WIDTH1(1U)
-
-#define S_WD_DLY 18
-#define V_WD_DLY(x) ((x) << S_WD_DLY)
-#define F_WD_DLY V_WD_DLY(1U)
-
-#define S_QDEPTH 16
-#define M_QDEPTH 0x3U
-#define V_QDEPTH(x) ((x) << S_QDEPTH)
-#define G_QDEPTH(x) (((x) >> S_QDEPTH) & M_QDEPTH)
-
-#define S_RWOO 15
-#define V_RWOO(x) ((x) << S_RWOO)
-#define F_RWOO V_RWOO(1U)
-
-#define S_WOOO 14
-#define V_WOOO(x) ((x) << S_WOOO)
-#define F_WOOO V_WOOO(1U)
-
-#define S_DCOO 13
-#define V_DCOO(x) ((x) << S_DCOO)
-#define F_DCOO V_DCOO(1U)
-
-#define S_DEF_REF 12
-#define V_DEF_REF(x) ((x) << S_DEF_REF)
-#define F_DEF_REF V_DEF_REF(1U)
-
-#define S_DEV_TYPE 11
-#define V_DEV_TYPE(x) ((x) << S_DEV_TYPE)
-#define F_DEV_TYPE V_DEV_TYPE(1U)
-
-#define S_CA_PTY_DLY 10
-#define V_CA_PTY_DLY(x) ((x) << S_CA_PTY_DLY)
-#define F_CA_PTY_DLY V_CA_PTY_DLY(1U)
-
-#define S_ECC_MUX 8
-#define M_ECC_MUX 0x3U
-#define V_ECC_MUX(x) ((x) << S_ECC_MUX)
-#define G_ECC_MUX(x) (((x) >> S_ECC_MUX) & M_ECC_MUX)
-
-#define S_CE_THRESHOLD 0
-#define M_CE_THRESHOLD 0xffU
-#define V_CE_THRESHOLD(x) ((x) << S_CE_THRESHOLD)
-#define G_CE_THRESHOLD(x) (((x) >> S_CE_THRESHOLD) & M_CE_THRESHOLD)
-
-#define A_MC_UPCTL_PPCFG 0x40084
-#define A_MC_LMC_MCOPT2 0x40084
-
-#define S_SELF_REF_EN 31
-#define V_SELF_REF_EN(x) ((x) << S_SELF_REF_EN)
-#define F_SELF_REF_EN V_SELF_REF_EN(1U)
-
-#define S_XSR_PREVENT 30
-#define V_XSR_PREVENT(x) ((x) << S_XSR_PREVENT)
-#define F_XSR_PREVENT V_XSR_PREVENT(1U)
-
-#define S_INIT_START 29
-#define V_INIT_START(x) ((x) << S_INIT_START)
-#define F_INIT_START V_INIT_START(1U)
-
-#define S_MC_ENABLE 28
-#define V_MC_ENABLE(x) ((x) << S_MC_ENABLE)
-#define F_MC_ENABLE V_MC_ENABLE(1U)
-
-#define S_CLK_DISABLE 24
-#define M_CLK_DISABLE 0xfU
-#define V_CLK_DISABLE(x) ((x) << S_CLK_DISABLE)
-#define G_CLK_DISABLE(x) (((x) >> S_CLK_DISABLE) & M_CLK_DISABLE)
-
-#define S_RESET_RANK 20
-#define M_RESET_RANK 0xfU
-#define V_RESET_RANK(x) ((x) << S_RESET_RANK)
-#define G_RESET_RANK(x) (((x) >> S_RESET_RANK) & M_RESET_RANK)
-
-#define S_MCIF_COMP_PTY_EN 19
-#define V_MCIF_COMP_PTY_EN(x) ((x) << S_MCIF_COMP_PTY_EN)
-#define F_MCIF_COMP_PTY_EN V_MCIF_COMP_PTY_EN(1U)
-
-#define S_CKE_OE 17
-#define V_CKE_OE(x) ((x) << S_CKE_OE)
-#define F_CKE_OE V_CKE_OE(1U)
-
-#define S_RESET_OE 16
-#define V_RESET_OE(x) ((x) << S_RESET_OE)
-#define F_RESET_OE V_RESET_OE(1U)
-
-#define S_DFI_PHYUD_CNTL 14
-#define V_DFI_PHYUD_CNTL(x) ((x) << S_DFI_PHYUD_CNTL)
-#define F_DFI_PHYUD_CNTL V_DFI_PHYUD_CNTL(1U)
-
-#define S_DFI_PHYUD_ACK 13
-#define V_DFI_PHYUD_ACK(x) ((x) << S_DFI_PHYUD_ACK)
-#define F_DFI_PHYUD_ACK V_DFI_PHYUD_ACK(1U)
-
-#define S_T6_DFI_INIT_START 12
-#define V_T6_DFI_INIT_START(x) ((x) << S_T6_DFI_INIT_START)
-#define F_T6_DFI_INIT_START V_T6_DFI_INIT_START(1U)
-
-#define S_PM_ENABLE 8
-#define M_PM_ENABLE 0xfU
-#define V_PM_ENABLE(x) ((x) << S_PM_ENABLE)
-#define G_PM_ENABLE(x) (((x) >> S_PM_ENABLE) & M_PM_ENABLE)
-
-#define S_RD_DEFREF_CNT 4
-#define M_RD_DEFREF_CNT 0xfU
-#define V_RD_DEFREF_CNT(x) ((x) << S_RD_DEFREF_CNT)
-#define G_RD_DEFREF_CNT(x) (((x) >> S_RD_DEFREF_CNT) & M_RD_DEFREF_CNT)
-
-#define A_MC_UPCTL_MSTAT 0x40088
-
-#define S_SELF_REFRESH 2
-#define V_SELF_REFRESH(x) ((x) << S_SELF_REFRESH)
-#define F_SELF_REFRESH V_SELF_REFRESH(1U)
-
-#define S_CLOCK_STOP 1
-#define V_CLOCK_STOP(x) ((x) << S_CLOCK_STOP)
-#define F_CLOCK_STOP V_CLOCK_STOP(1U)
-
-#define A_MC_UPCTL_LPDDR2ZQCFG 0x4008c
-
-#define S_ZQCL_OP 24
-#define M_ZQCL_OP 0xffU
-#define V_ZQCL_OP(x) ((x) << S_ZQCL_OP)
-#define G_ZQCL_OP(x) (((x) >> S_ZQCL_OP) & M_ZQCL_OP)
-
-#define S_ZQCL_MA 16
-#define M_ZQCL_MA 0xffU
-#define V_ZQCL_MA(x) ((x) << S_ZQCL_MA)
-#define G_ZQCL_MA(x) (((x) >> S_ZQCL_MA) & M_ZQCL_MA)
-
-#define S_ZQCS_OP 8
-#define M_ZQCS_OP 0xffU
-#define V_ZQCS_OP(x) ((x) << S_ZQCS_OP)
-#define G_ZQCS_OP(x) (((x) >> S_ZQCS_OP) & M_ZQCS_OP)
-
-#define S_ZQCS_MA 0
-#define M_ZQCS_MA 0xffU
-#define V_ZQCS_MA(x) ((x) << S_ZQCS_MA)
-#define G_ZQCS_MA(x) (((x) >> S_ZQCS_MA) & M_ZQCS_MA)
-
-#define A_MC_UPCTL_DTUPDES 0x40094
-
-#define S_DTU_ERR_B7 7
-#define V_DTU_ERR_B7(x) ((x) << S_DTU_ERR_B7)
-#define F_DTU_ERR_B7 V_DTU_ERR_B7(1U)
-
-#define A_MC_UPCTL_DTUNA 0x40098
-#define A_MC_UPCTL_DTUNE 0x4009c
-#define A_MC_UPCTL_DTUPRD0 0x400a0
-#define A_MC_UPCTL_DTUPRD1 0x400a4
-#define A_MC_UPCTL_DTUPRD2 0x400a8
-#define A_MC_UPCTL_DTUPRD3 0x400ac
-#define A_MC_UPCTL_DTUAWDT 0x400b0
-#define A_MC_UPCTL_TOGCNT1U 0x400c0
-#define A_MC_UPCTL_TINIT 0x400c4
-#define A_MC_UPCTL_TRSTH 0x400c8
-#define A_MC_UPCTL_TOGCNT100N 0x400cc
-#define A_MC_UPCTL_TREFI 0x400d0
-#define A_MC_UPCTL_TMRD 0x400d4
-#define A_MC_UPCTL_TRFC 0x400d8
-
-#define S_T_RFC0 0
-#define M_T_RFC0 0x1ffU
-#define V_T_RFC0(x) ((x) << S_T_RFC0)
-#define G_T_RFC0(x) (((x) >> S_T_RFC0) & M_T_RFC0)
-
-#define A_MC_UPCTL_TRP 0x400dc
-
-#define S_PREA_EXTRA 16
-#define M_PREA_EXTRA 0x3U
-#define V_PREA_EXTRA(x) ((x) << S_PREA_EXTRA)
-#define G_PREA_EXTRA(x) (((x) >> S_PREA_EXTRA) & M_PREA_EXTRA)
-
-#define A_MC_UPCTL_TRTW 0x400e0
-
-#define S_T_RTW0 0
-#define M_T_RTW0 0xfU
-#define V_T_RTW0(x) ((x) << S_T_RTW0)
-#define G_T_RTW0(x) (((x) >> S_T_RTW0) & M_T_RTW0)
-
-#define A_MC_UPCTL_TAL 0x400e4
-#define A_MC_UPCTL_TCL 0x400e8
-#define A_MC_UPCTL_TCWL 0x400ec
-#define A_MC_UPCTL_TRAS 0x400f0
-#define A_MC_UPCTL_TRC 0x400f4
-#define A_MC_UPCTL_TRCD 0x400f8
-#define A_MC_UPCTL_TRRD 0x400fc
-#define A_MC_UPCTL_TRTP 0x40100
-
-#define S_T_RTP0 0
-#define M_T_RTP0 0xfU
-#define V_T_RTP0(x) ((x) << S_T_RTP0)
-#define G_T_RTP0(x) (((x) >> S_T_RTP0) & M_T_RTP0)
-
-#define A_MC_LMC_CFGR0 0x40100
-
-#define S_ROW_WIDTH 12
-#define M_ROW_WIDTH 0x7U
-#define V_ROW_WIDTH(x) ((x) << S_ROW_WIDTH)
-#define G_ROW_WIDTH(x) (((x) >> S_ROW_WIDTH) & M_ROW_WIDTH)
-
-#define S_ADDR_MODE 8
-#define M_ADDR_MODE 0xfU
-#define V_ADDR_MODE(x) ((x) << S_ADDR_MODE)
-#define G_ADDR_MODE(x) (((x) >> S_ADDR_MODE) & M_ADDR_MODE)
-
-#define S_MIRROR 4
-#define V_MIRROR(x) ((x) << S_MIRROR)
-#define F_MIRROR V_MIRROR(1U)
-
-#define S_RANK_ENABLE 0
-#define V_RANK_ENABLE(x) ((x) << S_RANK_ENABLE)
-#define F_RANK_ENABLE V_RANK_ENABLE(1U)
-
-#define A_MC_UPCTL_TWR 0x40104
-
-#define S_U_T_WR 0
-#define M_U_T_WR 0x1fU
-#define V_U_T_WR(x) ((x) << S_U_T_WR)
-#define G_U_T_WR(x) (((x) >> S_U_T_WR) & M_U_T_WR)
-
-#define A_MC_UPCTL_TWTR 0x40108
-
-#define S_T_WTR0 0
-#define M_T_WTR0 0xfU
-#define V_T_WTR0(x) ((x) << S_T_WTR0)
-#define G_T_WTR0(x) (((x) >> S_T_WTR0) & M_T_WTR0)
-
-#define A_MC_UPCTL_TEXSR 0x4010c
-#define A_MC_UPCTL_TXP 0x40110
-#define A_MC_UPCTL_TXPDLL 0x40114
-#define A_MC_UPCTL_TZQCS 0x40118
-#define A_MC_UPCTL_TZQCSI 0x4011c
-#define A_MC_UPCTL_TDQS 0x40120
-#define A_MC_UPCTL_TCKSRE 0x40124
-
-#define S_T_CKSRE0 0
-#define M_T_CKSRE0 0x1fU
-#define V_T_CKSRE0(x) ((x) << S_T_CKSRE0)
-#define G_T_CKSRE0(x) (((x) >> S_T_CKSRE0) & M_T_CKSRE0)
-
-#define A_MC_UPCTL_TCKSRX 0x40128
-
-#define S_T_CKSRX0 0
-#define M_T_CKSRX0 0x1fU
-#define V_T_CKSRX0(x) ((x) << S_T_CKSRX0)
-#define G_T_CKSRX0(x) (((x) >> S_T_CKSRX0) & M_T_CKSRX0)
-
-#define A_MC_UPCTL_TCKE 0x4012c
-#define A_MC_UPCTL_TMOD 0x40130
-
-#define S_T_MOD0 0
-#define M_T_MOD0 0x1fU
-#define V_T_MOD0(x) ((x) << S_T_MOD0)
-#define G_T_MOD0(x) (((x) >> S_T_MOD0) & M_T_MOD0)
-
-#define A_MC_UPCTL_TRSTL 0x40134
-
-#define S_T_RSTL 0
-#define M_T_RSTL 0x7fU
-#define V_T_RSTL(x) ((x) << S_T_RSTL)
-#define G_T_RSTL(x) (((x) >> S_T_RSTL) & M_T_RSTL)
-
-#define A_MC_UPCTL_TZQCL 0x40138
-#define A_MC_UPCTL_TMRR 0x4013c
-
-#define S_T_MRR 0
-#define M_T_MRR 0xffU
-#define V_T_MRR(x) ((x) << S_T_MRR)
-#define G_T_MRR(x) (((x) >> S_T_MRR) & M_T_MRR)
-
-#define A_MC_UPCTL_TCKESR 0x40140
-
-#define S_T_CKESR 0
-#define M_T_CKESR 0xfU
-#define V_T_CKESR(x) ((x) << S_T_CKESR)
-#define G_T_CKESR(x) (((x) >> S_T_CKESR) & M_T_CKESR)
-
-#define A_MC_LMC_INITSEQ0 0x40140
-
-#define S_INIT_ENABLE 31
-#define V_INIT_ENABLE(x) ((x) << S_INIT_ENABLE)
-#define F_INIT_ENABLE V_INIT_ENABLE(1U)
-
-#define S_WAIT 16
-#define M_WAIT 0xfffU
-#define V_WAIT(x) ((x) << S_WAIT)
-#define G_WAIT(x) (((x) >> S_WAIT) & M_WAIT)
-
-#define S_EN_MULTI_RANK_SEL 4
-#define V_EN_MULTI_RANK_SEL(x) ((x) << S_EN_MULTI_RANK_SEL)
-#define F_EN_MULTI_RANK_SEL V_EN_MULTI_RANK_SEL(1U)
-
-#define S_T6_RANK 0
-#define M_T6_RANK 0xfU
-#define V_T6_RANK(x) ((x) << S_T6_RANK)
-#define G_T6_RANK(x) (((x) >> S_T6_RANK) & M_T6_RANK)
-
-#define A_MC_UPCTL_TDPD 0x40144
-
-#define S_T_DPD 0
-#define M_T_DPD 0x3ffU
-#define V_T_DPD(x) ((x) << S_T_DPD)
-#define G_T_DPD(x) (((x) >> S_T_DPD) & M_T_DPD)
-
-#define A_MC_LMC_CMD0 0x40144
-
-#define S_CMD 29
-#define M_CMD 0x7U
-#define V_CMD(x) ((x) << S_CMD)
-#define G_CMD(x) (((x) >> S_CMD) & M_CMD)
-
-#define S_CMD_ACTN 28
-#define V_CMD_ACTN(x) ((x) << S_CMD_ACTN)
-#define F_CMD_ACTN V_CMD_ACTN(1U)
-
-#define S_BG1 23
-#define V_BG1(x) ((x) << S_BG1)
-#define F_BG1 V_BG1(1U)
-
-#define S_BANK 20
-#define M_BANK 0x7U
-#define V_BANK(x) ((x) << S_BANK)
-#define G_BANK(x) (((x) >> S_BANK) & M_BANK)
-
-#define A_MC_LMC_INITSEQ1 0x40148
-
-#define S_T6_RANK 0
-#define M_T6_RANK 0xfU
-#define V_T6_RANK(x) ((x) << S_T6_RANK)
-#define G_T6_RANK(x) (((x) >> S_T6_RANK) & M_T6_RANK)
-
-#define A_MC_LMC_CMD1 0x4014c
-#define A_MC_LMC_INITSEQ2 0x40150
-
-#define S_T6_RANK 0
-#define M_T6_RANK 0xfU
-#define V_T6_RANK(x) ((x) << S_T6_RANK)
-#define G_T6_RANK(x) (((x) >> S_T6_RANK) & M_T6_RANK)
-
-#define A_MC_LMC_CMD2 0x40154
-#define A_MC_LMC_INITSEQ3 0x40158
-
-#define S_T6_RANK 0
-#define M_T6_RANK 0xfU
-#define V_T6_RANK(x) ((x) << S_T6_RANK)
-#define G_T6_RANK(x) (((x) >> S_T6_RANK) & M_T6_RANK)
-
-#define A_MC_LMC_CMD3 0x4015c
-#define A_MC_LMC_INITSEQ4 0x40160
-
-#define S_T6_RANK 0
-#define M_T6_RANK 0xfU
-#define V_T6_RANK(x) ((x) << S_T6_RANK)
-#define G_T6_RANK(x) (((x) >> S_T6_RANK) & M_T6_RANK)
-
-#define A_MC_LMC_CMD4 0x40164
-#define A_MC_LMC_INITSEQ5 0x40168
-
-#define S_T6_RANK 0
-#define M_T6_RANK 0xfU
-#define V_T6_RANK(x) ((x) << S_T6_RANK)
-#define G_T6_RANK(x) (((x) >> S_T6_RANK) & M_T6_RANK)
-
-#define A_MC_LMC_CMD5 0x4016c
-#define A_MC_LMC_INITSEQ6 0x40170
-
-#define S_T6_RANK 0
-#define M_T6_RANK 0xfU
-#define V_T6_RANK(x) ((x) << S_T6_RANK)
-#define G_T6_RANK(x) (((x) >> S_T6_RANK) & M_T6_RANK)
-
-#define A_MC_LMC_CMD6 0x40174
-#define A_MC_LMC_INITSEQ7 0x40178
-
-#define S_T6_RANK 0
-#define M_T6_RANK 0xfU
-#define V_T6_RANK(x) ((x) << S_T6_RANK)
-#define G_T6_RANK(x) (((x) >> S_T6_RANK) & M_T6_RANK)
-
-#define A_MC_LMC_CMD7 0x4017c
-#define A_MC_UPCTL_ECCCFG 0x40180
-#define A_MC_LMC_INITSEQ8 0x40180
-
-#define S_T6_RANK 0
-#define M_T6_RANK 0xfU
-#define V_T6_RANK(x) ((x) << S_T6_RANK)
-#define G_T6_RANK(x) (((x) >> S_T6_RANK) & M_T6_RANK)
-
-#define A_MC_UPCTL_ECCTST 0x40184
-
-#define S_ECC_TEST_MASK0 0
-#define M_ECC_TEST_MASK0 0x7fU
-#define V_ECC_TEST_MASK0(x) ((x) << S_ECC_TEST_MASK0)
-#define G_ECC_TEST_MASK0(x) (((x) >> S_ECC_TEST_MASK0) & M_ECC_TEST_MASK0)
-
-#define A_MC_LMC_CMD8 0x40184
-#define A_MC_UPCTL_ECCCLR 0x40188
-#define A_MC_LMC_INITSEQ9 0x40188
-
-#define S_T6_RANK 0
-#define M_T6_RANK 0xfU
-#define V_T6_RANK(x) ((x) << S_T6_RANK)
-#define G_T6_RANK(x) (((x) >> S_T6_RANK) & M_T6_RANK)
-
-#define A_MC_UPCTL_ECCLOG 0x4018c
-#define A_MC_LMC_CMD9 0x4018c
-#define A_MC_LMC_INITSEQ10 0x40190
-
-#define S_T6_RANK 0
-#define M_T6_RANK 0xfU
-#define V_T6_RANK(x) ((x) << S_T6_RANK)
-#define G_T6_RANK(x) (((x) >> S_T6_RANK) & M_T6_RANK)
-
-#define A_MC_LMC_CMD10 0x40194
-#define A_MC_LMC_INITSEQ11 0x40198
-
-#define S_T6_RANK 0
-#define M_T6_RANK 0xfU
-#define V_T6_RANK(x) ((x) << S_T6_RANK)
-#define G_T6_RANK(x) (((x) >> S_T6_RANK) & M_T6_RANK)
-
-#define A_MC_LMC_CMD11 0x4019c
-#define A_MC_LMC_INITSEQ12 0x401a0
-
-#define S_T6_RANK 0
-#define M_T6_RANK 0xfU
-#define V_T6_RANK(x) ((x) << S_T6_RANK)
-#define G_T6_RANK(x) (((x) >> S_T6_RANK) & M_T6_RANK)
-
-#define A_MC_LMC_CMD12 0x401a4
-#define A_MC_LMC_INITSEQ13 0x401a8
-
-#define S_T6_RANK 0
-#define M_T6_RANK 0xfU
-#define V_T6_RANK(x) ((x) << S_T6_RANK)
-#define G_T6_RANK(x) (((x) >> S_T6_RANK) & M_T6_RANK)
-
-#define A_MC_LMC_CMD13 0x401ac
-#define A_MC_LMC_INITSEQ14 0x401b0
-
-#define S_T6_RANK 0
-#define M_T6_RANK 0xfU
-#define V_T6_RANK(x) ((x) << S_T6_RANK)
-#define G_T6_RANK(x) (((x) >> S_T6_RANK) & M_T6_RANK)
-
-#define A_MC_LMC_CMD14 0x401b4
-#define A_MC_LMC_INITSEQ15 0x401b8
-
-#define S_T6_RANK 0
-#define M_T6_RANK 0xfU
-#define V_T6_RANK(x) ((x) << S_T6_RANK)
-#define G_T6_RANK(x) (((x) >> S_T6_RANK) & M_T6_RANK)
-
-#define A_MC_LMC_CMD15 0x401bc
-#define A_MC_UPCTL_DTUWACTL 0x40200
-
-#define S_DTU_WR_ROW0 13
-#define M_DTU_WR_ROW0 0xffffU
-#define V_DTU_WR_ROW0(x) ((x) << S_DTU_WR_ROW0)
-#define G_DTU_WR_ROW0(x) (((x) >> S_DTU_WR_ROW0) & M_DTU_WR_ROW0)
-
-#define A_MC_LMC_SDTR0 0x40200
-
-#define S_REFI 16
-#define M_REFI 0xffffU
-#define V_REFI(x) ((x) << S_REFI)
-#define G_REFI(x) (((x) >> S_REFI) & M_REFI)
-
-#define S_T_RFC_XPR 0
-#define M_T_RFC_XPR 0xfffU
-#define V_T_RFC_XPR(x) ((x) << S_T_RFC_XPR)
-#define G_T_RFC_XPR(x) (((x) >> S_T_RFC_XPR) & M_T_RFC_XPR)
-
-#define A_MC_UPCTL_DTURACTL 0x40204
-
-#define S_DTU_RD_ROW0 13
-#define M_DTU_RD_ROW0 0xffffU
-#define V_DTU_RD_ROW0(x) ((x) << S_DTU_RD_ROW0)
-#define G_DTU_RD_ROW0(x) (((x) >> S_DTU_RD_ROW0) & M_DTU_RD_ROW0)
-
-#define A_MC_LMC_SDTR1 0x40204
-
-#define S_T_LEADOFF 31
-#define V_T_LEADOFF(x) ((x) << S_T_LEADOFF)
-#define F_T_LEADOFF V_T_LEADOFF(1U)
-
-#define S_ODT_DELAY 30
-#define V_ODT_DELAY(x) ((x) << S_ODT_DELAY)
-#define F_ODT_DELAY V_ODT_DELAY(1U)
-
-#define S_ODT_WIDTH 29
-#define V_ODT_WIDTH(x) ((x) << S_ODT_WIDTH)
-#define F_ODT_WIDTH V_ODT_WIDTH(1U)
-
-#define S_T_WTRO 24
-#define M_T_WTRO 0xfU
-#define V_T_WTRO(x) ((x) << S_T_WTRO)
-#define G_T_WTRO(x) (((x) >> S_T_WTRO) & M_T_WTRO)
-
-#define S_T_RTWO 16
-#define M_T_RTWO 0xfU
-#define V_T_RTWO(x) ((x) << S_T_RTWO)
-#define G_T_RTWO(x) (((x) >> S_T_RTWO) & M_T_RTWO)
-
-#define S_T_RTW_ADJ 12
-#define M_T_RTW_ADJ 0xfU
-#define V_T_RTW_ADJ(x) ((x) << S_T_RTW_ADJ)
-#define G_T_RTW_ADJ(x) (((x) >> S_T_RTW_ADJ) & M_T_RTW_ADJ)
-
-#define S_T_WTWO 8
-#define M_T_WTWO 0xfU
-#define V_T_WTWO(x) ((x) << S_T_WTWO)
-#define G_T_WTWO(x) (((x) >> S_T_WTWO) & M_T_WTWO)
-
-#define S_T_RTRO 0
-#define M_T_RTRO 0xfU
-#define V_T_RTRO(x) ((x) << S_T_RTRO)
-#define G_T_RTRO(x) (((x) >> S_T_RTRO) & M_T_RTRO)
-
-#define A_MC_UPCTL_DTUCFG 0x40208
-#define A_MC_LMC_SDTR2 0x40208
-
-#define S_T6_T_CWL 28
-#define M_T6_T_CWL 0xfU
-#define V_T6_T_CWL(x) ((x) << S_T6_T_CWL)
-#define G_T6_T_CWL(x) (((x) >> S_T6_T_CWL) & M_T6_T_CWL)
-
-#define S_T_RCD0 24
-#define M_T_RCD0 0xfU
-#define V_T_RCD0(x) ((x) << S_T_RCD0)
-#define G_T_RCD0(x) (((x) >> S_T_RCD0) & M_T_RCD0)
-
-#define S_T_PL 20
-#define M_T_PL 0xfU
-#define V_T_PL(x) ((x) << S_T_PL)
-#define G_T_PL(x) (((x) >> S_T_PL) & M_T_PL)
-
-#define S_T_RP0 16
-#define M_T_RP0 0xfU
-#define V_T_RP0(x) ((x) << S_T_RP0)
-#define G_T_RP0(x) (((x) >> S_T_RP0) & M_T_RP0)
-
-#define S_T_RP1 15
-#define V_T_RP1(x) ((x) << S_T_RP1)
-#define F_T_RP1 V_T_RP1(1U)
-
-#define S_T_RCD1 14
-#define V_T_RCD1(x) ((x) << S_T_RCD1)
-#define F_T_RCD1 V_T_RCD1(1U)
-
-#define S_T6_T_RC 8
-#define M_T6_T_RC 0x3fU
-#define V_T6_T_RC(x) ((x) << S_T6_T_RC)
-#define G_T6_T_RC(x) (((x) >> S_T6_T_RC) & M_T6_T_RC)
-
-#define A_MC_UPCTL_DTUECTL 0x4020c
-#define A_MC_LMC_SDTR3 0x4020c
-
-#define S_T_WTR_S 28
-#define M_T_WTR_S 0xfU
-#define V_T_WTR_S(x) ((x) << S_T_WTR_S)
-#define G_T_WTR_S(x) (((x) >> S_T_WTR_S) & M_T_WTR_S)
-
-#define S_T6_T_WTR 24
-#define M_T6_T_WTR 0xfU
-#define V_T6_T_WTR(x) ((x) << S_T6_T_WTR)
-#define G_T6_T_WTR(x) (((x) >> S_T6_T_WTR) & M_T6_T_WTR)
-
-#define S_FAW_ADJ 20
-#define M_FAW_ADJ 0x3U
-#define V_FAW_ADJ(x) ((x) << S_FAW_ADJ)
-#define G_FAW_ADJ(x) (((x) >> S_FAW_ADJ) & M_FAW_ADJ)
-
-#define S_T6_T_RTP 16
-#define M_T6_T_RTP 0xfU
-#define V_T6_T_RTP(x) ((x) << S_T6_T_RTP)
-#define G_T6_T_RTP(x) (((x) >> S_T6_T_RTP) & M_T6_T_RTP)
-
-#define S_T_RRD_L 12
-#define M_T_RRD_L 0xfU
-#define V_T_RRD_L(x) ((x) << S_T_RRD_L)
-#define G_T_RRD_L(x) (((x) >> S_T_RRD_L) & M_T_RRD_L)
-
-#define S_T6_T_RRD 8
-#define M_T6_T_RRD 0xfU
-#define V_T6_T_RRD(x) ((x) << S_T6_T_RRD)
-#define G_T6_T_RRD(x) (((x) >> S_T6_T_RRD) & M_T6_T_RRD)
-
-#define S_T_XSDLL 0
-#define M_T_XSDLL 0xffU
-#define V_T_XSDLL(x) ((x) << S_T_XSDLL)
-#define G_T_XSDLL(x) (((x) >> S_T_XSDLL) & M_T_XSDLL)
-
-#define A_MC_UPCTL_DTUWD0 0x40210
-#define A_MC_LMC_SDTR4 0x40210
-
-#define S_T_RDDATA_EN 24
-#define M_T_RDDATA_EN 0x7fU
-#define V_T_RDDATA_EN(x) ((x) << S_T_RDDATA_EN)
-#define G_T_RDDATA_EN(x) (((x) >> S_T_RDDATA_EN) & M_T_RDDATA_EN)
-
-#define S_T_SYS_RDLAT 16
-#define M_T_SYS_RDLAT 0x3fU
-#define V_T_SYS_RDLAT(x) ((x) << S_T_SYS_RDLAT)
-#define G_T_SYS_RDLAT(x) (((x) >> S_T_SYS_RDLAT) & M_T_SYS_RDLAT)
-
-#define S_T_CCD_L 12
-#define M_T_CCD_L 0xfU
-#define V_T_CCD_L(x) ((x) << S_T_CCD_L)
-#define G_T_CCD_L(x) (((x) >> S_T_CCD_L) & M_T_CCD_L)
-
-#define S_T_CCD 8
-#define M_T_CCD 0x7U
-#define V_T_CCD(x) ((x) << S_T_CCD)
-#define G_T_CCD(x) (((x) >> S_T_CCD) & M_T_CCD)
-
-#define S_T_CPDED 5
-#define M_T_CPDED 0x7U
-#define V_T_CPDED(x) ((x) << S_T_CPDED)
-#define G_T_CPDED(x) (((x) >> S_T_CPDED) & M_T_CPDED)
-
-#define S_T6_T_MOD 0
-#define M_T6_T_MOD 0x1fU
-#define V_T6_T_MOD(x) ((x) << S_T6_T_MOD)
-#define G_T6_T_MOD(x) (((x) >> S_T6_T_MOD) & M_T6_T_MOD)
-
-#define A_MC_UPCTL_DTUWD1 0x40214
-#define A_MC_LMC_SDTR5 0x40214
-
-#define S_T_PHY_WRDATA 24
-#define M_T_PHY_WRDATA 0x7U
-#define V_T_PHY_WRDATA(x) ((x) << S_T_PHY_WRDATA)
-#define G_T_PHY_WRDATA(x) (((x) >> S_T_PHY_WRDATA) & M_T_PHY_WRDATA)
-
-#define S_T_PHY_WRLAT 16
-#define M_T_PHY_WRLAT 0x1fU
-#define V_T_PHY_WRLAT(x) ((x) << S_T_PHY_WRLAT)
-#define G_T_PHY_WRLAT(x) (((x) >> S_T_PHY_WRLAT) & M_T_PHY_WRLAT)
-
-#define A_MC_UPCTL_DTUWD2 0x40218
-#define A_MC_UPCTL_DTUWD3 0x4021c
-#define A_MC_UPCTL_DTUWDM 0x40220
-#define A_MC_UPCTL_DTURD0 0x40224
-#define A_MC_UPCTL_DTURD1 0x40228
-#define A_MC_LMC_DBG0 0x40228
-
-#define S_T_SYS_RDLAT_DBG 16
-#define M_T_SYS_RDLAT_DBG 0x1fU
-#define V_T_SYS_RDLAT_DBG(x) ((x) << S_T_SYS_RDLAT_DBG)
-#define G_T_SYS_RDLAT_DBG(x) (((x) >> S_T_SYS_RDLAT_DBG) & M_T_SYS_RDLAT_DBG)
-
-#define A_MC_UPCTL_DTURD2 0x4022c
-#define A_MC_UPCTL_DTURD3 0x40230
-#define A_MC_UPCTL_DTULFSRWD 0x40234
-#define A_MC_UPCTL_DTULFSRRD 0x40238
-#define A_MC_UPCTL_DTUEAF 0x4023c
-
-#define S_EA_ROW0 13
-#define M_EA_ROW0 0xffffU
-#define V_EA_ROW0(x) ((x) << S_EA_ROW0)
-#define G_EA_ROW0(x) (((x) >> S_EA_ROW0) & M_EA_ROW0)
-
-#define A_MC_UPCTL_DFITCTRLDELAY 0x40240
-
-#define S_TCTRL_DELAY 0
-#define M_TCTRL_DELAY 0xfU
-#define V_TCTRL_DELAY(x) ((x) << S_TCTRL_DELAY)
-#define G_TCTRL_DELAY(x) (((x) >> S_TCTRL_DELAY) & M_TCTRL_DELAY)
-
-#define A_MC_LMC_SMR0 0x40240
-
-#define S_SMR0_RFU0 13
-#define M_SMR0_RFU0 0x7U
-#define V_SMR0_RFU0(x) ((x) << S_SMR0_RFU0)
-#define G_SMR0_RFU0(x) (((x) >> S_SMR0_RFU0) & M_SMR0_RFU0)
-
-#define S_PPD 12
-#define V_PPD(x) ((x) << S_PPD)
-#define F_PPD V_PPD(1U)
-
-#define S_WR_RTP 9
-#define M_WR_RTP 0x7U
-#define V_WR_RTP(x) ((x) << S_WR_RTP)
-#define G_WR_RTP(x) (((x) >> S_WR_RTP) & M_WR_RTP)
-
-#define S_SMR0_DLL 8
-#define V_SMR0_DLL(x) ((x) << S_SMR0_DLL)
-#define F_SMR0_DLL V_SMR0_DLL(1U)
-
-#define S_TM 7
-#define V_TM(x) ((x) << S_TM)
-#define F_TM V_TM(1U)
-
-#define S_CL31 4
-#define M_CL31 0x7U
-#define V_CL31(x) ((x) << S_CL31)
-#define G_CL31(x) (((x) >> S_CL31) & M_CL31)
-
-#define S_RBT 3
-#define V_RBT(x) ((x) << S_RBT)
-#define F_RBT V_RBT(1U)
-
-#define S_CL0 2
-#define V_CL0(x) ((x) << S_CL0)
-#define F_CL0 V_CL0(1U)
-
-#define S_BL 0
-#define M_BL 0x3U
-#define V_BL(x) ((x) << S_BL)
-#define G_BL(x) (((x) >> S_BL) & M_BL)
-
-#define A_MC_UPCTL_DFIODTCFG 0x40244
-
-#define S_RANK3_ODT_WRITE_NSEL 26
-#define V_RANK3_ODT_WRITE_NSEL(x) ((x) << S_RANK3_ODT_WRITE_NSEL)
-#define F_RANK3_ODT_WRITE_NSEL V_RANK3_ODT_WRITE_NSEL(1U)
-
-#define A_MC_LMC_SMR1 0x40244
-
-#define S_QOFF 12
-#define V_QOFF(x) ((x) << S_QOFF)
-#define F_QOFF V_QOFF(1U)
-
-#define S_TDQS 11
-#define V_TDQS(x) ((x) << S_TDQS)
-#define F_TDQS V_TDQS(1U)
-
-#define S_SMR1_RFU0 10
-#define V_SMR1_RFU0(x) ((x) << S_SMR1_RFU0)
-#define F_SMR1_RFU0 V_SMR1_RFU0(1U)
-
-#define S_RTT_NOM0 9
-#define V_RTT_NOM0(x) ((x) << S_RTT_NOM0)
-#define F_RTT_NOM0 V_RTT_NOM0(1U)
-
-#define S_SMR1_RFU1 8
-#define V_SMR1_RFU1(x) ((x) << S_SMR1_RFU1)
-#define F_SMR1_RFU1 V_SMR1_RFU1(1U)
-
-#define S_WR_LEVEL 7
-#define V_WR_LEVEL(x) ((x) << S_WR_LEVEL)
-#define F_WR_LEVEL V_WR_LEVEL(1U)
-
-#define S_RTT_NOM1 6
-#define V_RTT_NOM1(x) ((x) << S_RTT_NOM1)
-#define F_RTT_NOM1 V_RTT_NOM1(1U)
-
-#define S_DIC0 5
-#define V_DIC0(x) ((x) << S_DIC0)
-#define F_DIC0 V_DIC0(1U)
-
-#define S_AL 3
-#define M_AL 0x3U
-#define V_AL(x) ((x) << S_AL)
-#define G_AL(x) (((x) >> S_AL) & M_AL)
-
-#define S_RTT_NOM2 2
-#define V_RTT_NOM2(x) ((x) << S_RTT_NOM2)
-#define F_RTT_NOM2 V_RTT_NOM2(1U)
-
-#define S_DIC1 1
-#define V_DIC1(x) ((x) << S_DIC1)
-#define F_DIC1 V_DIC1(1U)
-
-#define S_SMR1_DLL 0
-#define V_SMR1_DLL(x) ((x) << S_SMR1_DLL)
-#define F_SMR1_DLL V_SMR1_DLL(1U)
-
-#define A_MC_UPCTL_DFIODTCFG1 0x40248
-
-#define S_ODT_LEN_B8_R 24
-#define M_ODT_LEN_B8_R 0x7U
-#define V_ODT_LEN_B8_R(x) ((x) << S_ODT_LEN_B8_R)
-#define G_ODT_LEN_B8_R(x) (((x) >> S_ODT_LEN_B8_R) & M_ODT_LEN_B8_R)
-
-#define S_ODT_LEN_BL8_W 16
-#define M_ODT_LEN_BL8_W 0x7U
-#define V_ODT_LEN_BL8_W(x) ((x) << S_ODT_LEN_BL8_W)
-#define G_ODT_LEN_BL8_W(x) (((x) >> S_ODT_LEN_BL8_W) & M_ODT_LEN_BL8_W)
-
-#define S_ODT_LAT_R 8
-#define M_ODT_LAT_R 0x1fU
-#define V_ODT_LAT_R(x) ((x) << S_ODT_LAT_R)
-#define G_ODT_LAT_R(x) (((x) >> S_ODT_LAT_R) & M_ODT_LAT_R)
-
-#define S_ODT_LAT_W 0
-#define M_ODT_LAT_W 0x1fU
-#define V_ODT_LAT_W(x) ((x) << S_ODT_LAT_W)
-#define G_ODT_LAT_W(x) (((x) >> S_ODT_LAT_W) & M_ODT_LAT_W)
-
-#define A_MC_LMC_SMR2 0x40248
-
-#define S_WR_CRC 12
-#define V_WR_CRC(x) ((x) << S_WR_CRC)
-#define F_WR_CRC V_WR_CRC(1U)
-
-#define S_RD_CRC 11
-#define V_RD_CRC(x) ((x) << S_RD_CRC)
-#define F_RD_CRC V_RD_CRC(1U)
-
-#define S_RTT_WR 9
-#define M_RTT_WR 0x3U
-#define V_RTT_WR(x) ((x) << S_RTT_WR)
-#define G_RTT_WR(x) (((x) >> S_RTT_WR) & M_RTT_WR)
-
-#define S_SMR2_RFU0 8
-#define V_SMR2_RFU0(x) ((x) << S_SMR2_RFU0)
-#define F_SMR2_RFU0 V_SMR2_RFU0(1U)
-
-#define S_SRT_ASR1 7
-#define V_SRT_ASR1(x) ((x) << S_SRT_ASR1)
-#define F_SRT_ASR1 V_SRT_ASR1(1U)
-
-#define S_ASR0 6
-#define V_ASR0(x) ((x) << S_ASR0)
-#define F_ASR0 V_ASR0(1U)
-
-#define S_CWL 3
-#define M_CWL 0x7U
-#define V_CWL(x) ((x) << S_CWL)
-#define G_CWL(x) (((x) >> S_CWL) & M_CWL)
-
-#define S_PASR 0
-#define M_PASR 0x7U
-#define V_PASR(x) ((x) << S_PASR)
-#define G_PASR(x) (((x) >> S_PASR) & M_PASR)
-
-#define A_MC_UPCTL_DFIODTRANKMAP 0x4024c
-
-#define S_ODT_RANK_MAP3 12
-#define M_ODT_RANK_MAP3 0xfU
-#define V_ODT_RANK_MAP3(x) ((x) << S_ODT_RANK_MAP3)
-#define G_ODT_RANK_MAP3(x) (((x) >> S_ODT_RANK_MAP3) & M_ODT_RANK_MAP3)
-
-#define S_ODT_RANK_MAP2 8
-#define M_ODT_RANK_MAP2 0xfU
-#define V_ODT_RANK_MAP2(x) ((x) << S_ODT_RANK_MAP2)
-#define G_ODT_RANK_MAP2(x) (((x) >> S_ODT_RANK_MAP2) & M_ODT_RANK_MAP2)
-
-#define S_ODT_RANK_MAP1 4
-#define M_ODT_RANK_MAP1 0xfU
-#define V_ODT_RANK_MAP1(x) ((x) << S_ODT_RANK_MAP1)
-#define G_ODT_RANK_MAP1(x) (((x) >> S_ODT_RANK_MAP1) & M_ODT_RANK_MAP1)
-
-#define S_ODT_RANK_MAP0 0
-#define M_ODT_RANK_MAP0 0xfU
-#define V_ODT_RANK_MAP0(x) ((x) << S_ODT_RANK_MAP0)
-#define G_ODT_RANK_MAP0(x) (((x) >> S_ODT_RANK_MAP0) & M_ODT_RANK_MAP0)
-
-#define A_MC_LMC_SMR3 0x4024c
-
-#define S_MPR_RD_FMT 11
-#define M_MPR_RD_FMT 0x3U
-#define V_MPR_RD_FMT(x) ((x) << S_MPR_RD_FMT)
-#define G_MPR_RD_FMT(x) (((x) >> S_MPR_RD_FMT) & M_MPR_RD_FMT)
-
-#define S_SMR3_RFU0 9
-#define M_SMR3_RFU0 0x3U
-#define V_SMR3_RFU0(x) ((x) << S_SMR3_RFU0)
-#define G_SMR3_RFU0(x) (((x) >> S_SMR3_RFU0) & M_SMR3_RFU0)
-
-#define S_FGR_MODE 6
-#define M_FGR_MODE 0x7U
-#define V_FGR_MODE(x) ((x) << S_FGR_MODE)
-#define G_FGR_MODE(x) (((x) >> S_FGR_MODE) & M_FGR_MODE)
-
-#define S_MRS_RDO 5
-#define V_MRS_RDO(x) ((x) << S_MRS_RDO)
-#define F_MRS_RDO V_MRS_RDO(1U)
-
-#define S_DRAM_ADR 4
-#define V_DRAM_ADR(x) ((x) << S_DRAM_ADR)
-#define F_DRAM_ADR V_DRAM_ADR(1U)
-
-#define S_GD_MODE 3
-#define V_GD_MODE(x) ((x) << S_GD_MODE)
-#define F_GD_MODE V_GD_MODE(1U)
-
-#define S_MPR 2
-#define V_MPR(x) ((x) << S_MPR)
-#define F_MPR V_MPR(1U)
-
-#define S_MPR_SEL 0
-#define M_MPR_SEL 0x3U
-#define V_MPR_SEL(x) ((x) << S_MPR_SEL)
-#define G_MPR_SEL(x) (((x) >> S_MPR_SEL) & M_MPR_SEL)
-
-#define A_MC_UPCTL_DFITPHYWRDATA 0x40250
-
-#define S_TPHY_WRDATA 0
-#define M_TPHY_WRDATA 0x1fU
-#define V_TPHY_WRDATA(x) ((x) << S_TPHY_WRDATA)
-#define G_TPHY_WRDATA(x) (((x) >> S_TPHY_WRDATA) & M_TPHY_WRDATA)
-
-#define A_MC_LMC_SMR4 0x40250
-
-#define S_WR_PRE 12
-#define V_WR_PRE(x) ((x) << S_WR_PRE)
-#define F_WR_PRE V_WR_PRE(1U)
-
-#define S_RD_PRE 11
-#define V_RD_PRE(x) ((x) << S_RD_PRE)
-#define F_RD_PRE V_RD_PRE(1U)
-
-#define S_RPT_MODE 10
-#define V_RPT_MODE(x) ((x) << S_RPT_MODE)
-#define F_RPT_MODE V_RPT_MODE(1U)
-
-#define S_FESR_MODE 9
-#define V_FESR_MODE(x) ((x) << S_FESR_MODE)
-#define F_FESR_MODE V_FESR_MODE(1U)
-
-#define S_CS_LAT_MODE 6
-#define M_CS_LAT_MODE 0x7U
-#define V_CS_LAT_MODE(x) ((x) << S_CS_LAT_MODE)
-#define G_CS_LAT_MODE(x) (((x) >> S_CS_LAT_MODE) & M_CS_LAT_MODE)
-
-#define S_ALERT_STAT 5
-#define V_ALERT_STAT(x) ((x) << S_ALERT_STAT)
-#define F_ALERT_STAT V_ALERT_STAT(1U)
-
-#define S_IVM_MODE 4
-#define V_IVM_MODE(x) ((x) << S_IVM_MODE)
-#define F_IVM_MODE V_IVM_MODE(1U)
-
-#define S_TCR_MODE 3
-#define V_TCR_MODE(x) ((x) << S_TCR_MODE)
-#define F_TCR_MODE V_TCR_MODE(1U)
-
-#define S_TCR_RANGE 2
-#define V_TCR_RANGE(x) ((x) << S_TCR_RANGE)
-#define F_TCR_RANGE V_TCR_RANGE(1U)
-
-#define S_MPD_MODE 1
-#define V_MPD_MODE(x) ((x) << S_MPD_MODE)
-#define F_MPD_MODE V_MPD_MODE(1U)
-
-#define S_SMR4_RFU 0
-#define V_SMR4_RFU(x) ((x) << S_SMR4_RFU)
-#define F_SMR4_RFU V_SMR4_RFU(1U)
-
-#define A_MC_UPCTL_DFITPHYWRLAT 0x40254
-
-#define S_TPHY_WRLAT 0
-#define M_TPHY_WRLAT 0x1fU
-#define V_TPHY_WRLAT(x) ((x) << S_TPHY_WRLAT)
-#define G_TPHY_WRLAT(x) (((x) >> S_TPHY_WRLAT) & M_TPHY_WRLAT)
-
-#define A_MC_LMC_SMR5 0x40254
-
-#define S_RD_DBI 11
-#define V_RD_DBI(x) ((x) << S_RD_DBI)
-#define F_RD_DBI V_RD_DBI(1U)
-
-#define S_WR_DBI 10
-#define V_WR_DBI(x) ((x) << S_WR_DBI)
-#define F_WR_DBI V_WR_DBI(1U)
-
-#define S_DM_MODE 9
-#define V_DM_MODE(x) ((x) << S_DM_MODE)
-#define F_DM_MODE V_DM_MODE(1U)
-
-#define S_RTT_PARK 6
-#define M_RTT_PARK 0x7U
-#define V_RTT_PARK(x) ((x) << S_RTT_PARK)
-#define G_RTT_PARK(x) (((x) >> S_RTT_PARK) & M_RTT_PARK)
-
-#define S_SMR5_RFU 5
-#define V_SMR5_RFU(x) ((x) << S_SMR5_RFU)
-#define F_SMR5_RFU V_SMR5_RFU(1U)
-
-#define S_PAR_ERR_STAT 4
-#define V_PAR_ERR_STAT(x) ((x) << S_PAR_ERR_STAT)
-#define F_PAR_ERR_STAT V_PAR_ERR_STAT(1U)
-
-#define S_CRC_CLEAR 3
-#define V_CRC_CLEAR(x) ((x) << S_CRC_CLEAR)
-#define F_CRC_CLEAR V_CRC_CLEAR(1U)
-
-#define S_PAR_LAT_MODE 0
-#define M_PAR_LAT_MODE 0x7U
-#define V_PAR_LAT_MODE(x) ((x) << S_PAR_LAT_MODE)
-#define G_PAR_LAT_MODE(x) (((x) >> S_PAR_LAT_MODE) & M_PAR_LAT_MODE)
-
-#define A_MC_LMC_SMR6 0x40258
-
-#define S_TCCD_L 10
-#define M_TCCD_L 0x7U
-#define V_TCCD_L(x) ((x) << S_TCCD_L)
-#define G_TCCD_L(x) (((x) >> S_TCCD_L) & M_TCCD_L)
-
-#define S_SRM6_RFU 7
-#define M_SRM6_RFU 0x7U
-#define V_SRM6_RFU(x) ((x) << S_SRM6_RFU)
-#define G_SRM6_RFU(x) (((x) >> S_SRM6_RFU) & M_SRM6_RFU)
-
-#define S_VREF_DQ_RANGE 6
-#define V_VREF_DQ_RANGE(x) ((x) << S_VREF_DQ_RANGE)
-#define F_VREF_DQ_RANGE V_VREF_DQ_RANGE(1U)
-
-#define S_VREF_DQ_VALUE 0
-#define M_VREF_DQ_VALUE 0x3fU
-#define V_VREF_DQ_VALUE(x) ((x) << S_VREF_DQ_VALUE)
-#define G_VREF_DQ_VALUE(x) (((x) >> S_VREF_DQ_VALUE) & M_VREF_DQ_VALUE)
-
-#define A_MC_UPCTL_DFITRDDATAEN 0x40260
-
-#define S_TRDDATA_EN 0
-#define M_TRDDATA_EN 0x1fU
-#define V_TRDDATA_EN(x) ((x) << S_TRDDATA_EN)
-#define G_TRDDATA_EN(x) (((x) >> S_TRDDATA_EN) & M_TRDDATA_EN)
-
-#define A_MC_UPCTL_DFITPHYRDLAT 0x40264
-
-#define S_TPHY_RDLAT 0
-#define M_TPHY_RDLAT 0x3fU
-#define V_TPHY_RDLAT(x) ((x) << S_TPHY_RDLAT)
-#define G_TPHY_RDLAT(x) (((x) >> S_TPHY_RDLAT) & M_TPHY_RDLAT)
-
-#define A_MC_UPCTL_DFITPHYUPDTYPE0 0x40270
-
-#define S_TPHYUPD_TYPE0 0
-#define M_TPHYUPD_TYPE0 0xfffU
-#define V_TPHYUPD_TYPE0(x) ((x) << S_TPHYUPD_TYPE0)
-#define G_TPHYUPD_TYPE0(x) (((x) >> S_TPHYUPD_TYPE0) & M_TPHYUPD_TYPE0)
-
-#define A_MC_UPCTL_DFITPHYUPDTYPE1 0x40274
-
-#define S_TPHYUPD_TYPE1 0
-#define M_TPHYUPD_TYPE1 0xfffU
-#define V_TPHYUPD_TYPE1(x) ((x) << S_TPHYUPD_TYPE1)
-#define G_TPHYUPD_TYPE1(x) (((x) >> S_TPHYUPD_TYPE1) & M_TPHYUPD_TYPE1)
-
-#define A_MC_UPCTL_DFITPHYUPDTYPE2 0x40278
-
-#define S_TPHYUPD_TYPE2 0
-#define M_TPHYUPD_TYPE2 0xfffU
-#define V_TPHYUPD_TYPE2(x) ((x) << S_TPHYUPD_TYPE2)
-#define G_TPHYUPD_TYPE2(x) (((x) >> S_TPHYUPD_TYPE2) & M_TPHYUPD_TYPE2)
-
-#define A_MC_UPCTL_DFITPHYUPDTYPE3 0x4027c
-
-#define S_TPHYUPD_TYPE3 0
-#define M_TPHYUPD_TYPE3 0xfffU
-#define V_TPHYUPD_TYPE3(x) ((x) << S_TPHYUPD_TYPE3)
-#define G_TPHYUPD_TYPE3(x) (((x) >> S_TPHYUPD_TYPE3) & M_TPHYUPD_TYPE3)
-
-#define A_MC_UPCTL_DFITCTRLUPDMIN 0x40280
-
-#define S_TCTRLUPD_MIN 0
-#define M_TCTRLUPD_MIN 0xffffU
-#define V_TCTRLUPD_MIN(x) ((x) << S_TCTRLUPD_MIN)
-#define G_TCTRLUPD_MIN(x) (((x) >> S_TCTRLUPD_MIN) & M_TCTRLUPD_MIN)
-
-#define A_MC_LMC_ODTR0 0x40280
-
-#define S_RK0W 25
-#define V_RK0W(x) ((x) << S_RK0W)
-#define F_RK0W V_RK0W(1U)
-
-#define S_RK0R 24
-#define V_RK0R(x) ((x) << S_RK0R)
-#define F_RK0R V_RK0R(1U)
-
-#define A_MC_UPCTL_DFITCTRLUPDMAX 0x40284
-
-#define S_TCTRLUPD_MAX 0
-#define M_TCTRLUPD_MAX 0xffffU
-#define V_TCTRLUPD_MAX(x) ((x) << S_TCTRLUPD_MAX)
-#define G_TCTRLUPD_MAX(x) (((x) >> S_TCTRLUPD_MAX) & M_TCTRLUPD_MAX)
-
-#define A_MC_UPCTL_DFITCTRLUPDDLY 0x40288
-
-#define S_TCTRLUPD_DLY 0
-#define M_TCTRLUPD_DLY 0xfU
-#define V_TCTRLUPD_DLY(x) ((x) << S_TCTRLUPD_DLY)
-#define G_TCTRLUPD_DLY(x) (((x) >> S_TCTRLUPD_DLY) & M_TCTRLUPD_DLY)
-
-#define A_MC_UPCTL_DFIUPDCFG 0x40290
-
-#define S_DFI_PHYUPD_EN 1
-#define V_DFI_PHYUPD_EN(x) ((x) << S_DFI_PHYUPD_EN)
-#define F_DFI_PHYUPD_EN V_DFI_PHYUPD_EN(1U)
-
-#define S_DFI_CTRLUPD_EN 0
-#define V_DFI_CTRLUPD_EN(x) ((x) << S_DFI_CTRLUPD_EN)
-#define F_DFI_CTRLUPD_EN V_DFI_CTRLUPD_EN(1U)
-
-#define A_MC_UPCTL_DFITREFMSKI 0x40294
-
-#define S_TREFMSKI 0
-#define M_TREFMSKI 0xffU
-#define V_TREFMSKI(x) ((x) << S_TREFMSKI)
-#define G_TREFMSKI(x) (((x) >> S_TREFMSKI) & M_TREFMSKI)
-
-#define A_MC_UPCTL_DFITCTRLUPDI 0x40298
-#define A_MC_UPCTL_DFITRCFG0 0x402ac
-
-#define S_DFI_WRLVL_RANK_SEL 16
-#define M_DFI_WRLVL_RANK_SEL 0xfU
-#define V_DFI_WRLVL_RANK_SEL(x) ((x) << S_DFI_WRLVL_RANK_SEL)
-#define G_DFI_WRLVL_RANK_SEL(x) (((x) >> S_DFI_WRLVL_RANK_SEL) & M_DFI_WRLVL_RANK_SEL)
-
-#define S_DFI_RDLVL_EDGE 4
-#define M_DFI_RDLVL_EDGE 0x1ffU
-#define V_DFI_RDLVL_EDGE(x) ((x) << S_DFI_RDLVL_EDGE)
-#define G_DFI_RDLVL_EDGE(x) (((x) >> S_DFI_RDLVL_EDGE) & M_DFI_RDLVL_EDGE)
-
-#define S_DFI_RDLVL_RANK_SEL 0
-#define M_DFI_RDLVL_RANK_SEL 0xfU
-#define V_DFI_RDLVL_RANK_SEL(x) ((x) << S_DFI_RDLVL_RANK_SEL)
-#define G_DFI_RDLVL_RANK_SEL(x) (((x) >> S_DFI_RDLVL_RANK_SEL) & M_DFI_RDLVL_RANK_SEL)
-
-#define A_MC_UPCTL_DFITRSTAT0 0x402b0
-
-#define S_DFI_WRLVL_MODE 16
-#define M_DFI_WRLVL_MODE 0x3U
-#define V_DFI_WRLVL_MODE(x) ((x) << S_DFI_WRLVL_MODE)
-#define G_DFI_WRLVL_MODE(x) (((x) >> S_DFI_WRLVL_MODE) & M_DFI_WRLVL_MODE)
-
-#define S_DFI_RDLVL_GATE_MODE 8
-#define M_DFI_RDLVL_GATE_MODE 0x3U
-#define V_DFI_RDLVL_GATE_MODE(x) ((x) << S_DFI_RDLVL_GATE_MODE)
-#define G_DFI_RDLVL_GATE_MODE(x) (((x) >> S_DFI_RDLVL_GATE_MODE) & M_DFI_RDLVL_GATE_MODE)
-
-#define S_DFI_RDLVL_MODE 0
-#define M_DFI_RDLVL_MODE 0x3U
-#define V_DFI_RDLVL_MODE(x) ((x) << S_DFI_RDLVL_MODE)
-#define G_DFI_RDLVL_MODE(x) (((x) >> S_DFI_RDLVL_MODE) & M_DFI_RDLVL_MODE)
-
-#define A_MC_UPCTL_DFITRWRLVLEN 0x402b4
-
-#define S_DFI_WRLVL_EN 0
-#define M_DFI_WRLVL_EN 0x1ffU
-#define V_DFI_WRLVL_EN(x) ((x) << S_DFI_WRLVL_EN)
-#define G_DFI_WRLVL_EN(x) (((x) >> S_DFI_WRLVL_EN) & M_DFI_WRLVL_EN)
-
-#define A_MC_UPCTL_DFITRRDLVLEN 0x402b8
-
-#define S_DFI_RDLVL_EN 0
-#define M_DFI_RDLVL_EN 0x1ffU
-#define V_DFI_RDLVL_EN(x) ((x) << S_DFI_RDLVL_EN)
-#define G_DFI_RDLVL_EN(x) (((x) >> S_DFI_RDLVL_EN) & M_DFI_RDLVL_EN)
-
-#define A_MC_UPCTL_DFITRRDLVLGATEEN 0x402bc
-
-#define S_DFI_RDLVL_GATE_EN 0
-#define M_DFI_RDLVL_GATE_EN 0x1ffU
-#define V_DFI_RDLVL_GATE_EN(x) ((x) << S_DFI_RDLVL_GATE_EN)
-#define G_DFI_RDLVL_GATE_EN(x) (((x) >> S_DFI_RDLVL_GATE_EN) & M_DFI_RDLVL_GATE_EN)
-
-#define A_MC_UPCTL_DFISTSTAT0 0x402c0
-
-#define S_DFI_DATA_BYTE_DISABLE 16
-#define M_DFI_DATA_BYTE_DISABLE 0x1ffU
-#define V_DFI_DATA_BYTE_DISABLE(x) ((x) << S_DFI_DATA_BYTE_DISABLE)
-#define G_DFI_DATA_BYTE_DISABLE(x) (((x) >> S_DFI_DATA_BYTE_DISABLE) & M_DFI_DATA_BYTE_DISABLE)
-
-#define S_DFI_FREQ_RATIO 4
-#define M_DFI_FREQ_RATIO 0x3U
-#define V_DFI_FREQ_RATIO(x) ((x) << S_DFI_FREQ_RATIO)
-#define G_DFI_FREQ_RATIO(x) (((x) >> S_DFI_FREQ_RATIO) & M_DFI_FREQ_RATIO)
-
-#define S_DFI_INIT_START0 1
-#define V_DFI_INIT_START0(x) ((x) << S_DFI_INIT_START0)
-#define F_DFI_INIT_START0 V_DFI_INIT_START0(1U)
-
-#define S_DFI_INIT_COMPLETE 0
-#define V_DFI_INIT_COMPLETE(x) ((x) << S_DFI_INIT_COMPLETE)
-#define F_DFI_INIT_COMPLETE V_DFI_INIT_COMPLETE(1U)
-
-#define A_MC_UPCTL_DFISTCFG0 0x402c4
-
-#define S_DFI_DATA_BYTE_DISABLE_EN 2
-#define V_DFI_DATA_BYTE_DISABLE_EN(x) ((x) << S_DFI_DATA_BYTE_DISABLE_EN)
-#define F_DFI_DATA_BYTE_DISABLE_EN V_DFI_DATA_BYTE_DISABLE_EN(1U)
-
-#define S_DFI_FREQ_RATIO_EN 1
-#define V_DFI_FREQ_RATIO_EN(x) ((x) << S_DFI_FREQ_RATIO_EN)
-#define F_DFI_FREQ_RATIO_EN V_DFI_FREQ_RATIO_EN(1U)
-
-#define S_DFI_INIT_START 0
-#define V_DFI_INIT_START(x) ((x) << S_DFI_INIT_START)
-#define F_DFI_INIT_START V_DFI_INIT_START(1U)
-
-#define A_MC_UPCTL_DFISTCFG1 0x402c8
-
-#define S_DFI_DRAM_CLK_DISABLE_EN_DPD 1
-#define V_DFI_DRAM_CLK_DISABLE_EN_DPD(x) ((x) << S_DFI_DRAM_CLK_DISABLE_EN_DPD)
-#define F_DFI_DRAM_CLK_DISABLE_EN_DPD V_DFI_DRAM_CLK_DISABLE_EN_DPD(1U)
-
-#define S_DFI_DRAM_CLK_DISABLE_EN 0
-#define V_DFI_DRAM_CLK_DISABLE_EN(x) ((x) << S_DFI_DRAM_CLK_DISABLE_EN)
-#define F_DFI_DRAM_CLK_DISABLE_EN V_DFI_DRAM_CLK_DISABLE_EN(1U)
-
-#define A_MC_UPCTL_DFITDRAMCLKEN 0x402d0
-
-#define S_TDRAM_CLK_ENABLE 0
-#define M_TDRAM_CLK_ENABLE 0xfU
-#define V_TDRAM_CLK_ENABLE(x) ((x) << S_TDRAM_CLK_ENABLE)
-#define G_TDRAM_CLK_ENABLE(x) (((x) >> S_TDRAM_CLK_ENABLE) & M_TDRAM_CLK_ENABLE)
-
-#define A_MC_UPCTL_DFITDRAMCLKDIS 0x402d4
-
-#define S_TDRAM_CLK_DISABLE 0
-#define M_TDRAM_CLK_DISABLE 0xfU
-#define V_TDRAM_CLK_DISABLE(x) ((x) << S_TDRAM_CLK_DISABLE)
-#define G_TDRAM_CLK_DISABLE(x) (((x) >> S_TDRAM_CLK_DISABLE) & M_TDRAM_CLK_DISABLE)
-
-#define A_MC_UPCTL_DFISTCFG2 0x402d8
-
-#define S_PARITY_EN 1
-#define V_PARITY_EN(x) ((x) << S_PARITY_EN)
-#define F_PARITY_EN V_PARITY_EN(1U)
-
-#define S_PARITY_INTR_EN 0
-#define V_PARITY_INTR_EN(x) ((x) << S_PARITY_INTR_EN)
-#define F_PARITY_INTR_EN V_PARITY_INTR_EN(1U)
-
-#define A_MC_UPCTL_DFISTPARCLR 0x402dc
-
-#define S_PARITY_LOG_CLR 1
-#define V_PARITY_LOG_CLR(x) ((x) << S_PARITY_LOG_CLR)
-#define F_PARITY_LOG_CLR V_PARITY_LOG_CLR(1U)
-
-#define S_PARITY_INTR_CLR 0
-#define V_PARITY_INTR_CLR(x) ((x) << S_PARITY_INTR_CLR)
-#define F_PARITY_INTR_CLR V_PARITY_INTR_CLR(1U)
-
-#define A_MC_UPCTL_DFISTPARLOG 0x402e0
-#define A_MC_UPCTL_DFILPCFG0 0x402f0
-
-#define S_DFI_LP_WAKEUP_DPD 28
-#define M_DFI_LP_WAKEUP_DPD 0xfU
-#define V_DFI_LP_WAKEUP_DPD(x) ((x) << S_DFI_LP_WAKEUP_DPD)
-#define G_DFI_LP_WAKEUP_DPD(x) (((x) >> S_DFI_LP_WAKEUP_DPD) & M_DFI_LP_WAKEUP_DPD)
-
-#define S_DFI_LP_EN_DPD 24
-#define V_DFI_LP_EN_DPD(x) ((x) << S_DFI_LP_EN_DPD)
-#define F_DFI_LP_EN_DPD V_DFI_LP_EN_DPD(1U)
-
-#define S_DFI_TLP_RESP 16
-#define M_DFI_TLP_RESP 0xfU
-#define V_DFI_TLP_RESP(x) ((x) << S_DFI_TLP_RESP)
-#define G_DFI_TLP_RESP(x) (((x) >> S_DFI_TLP_RESP) & M_DFI_TLP_RESP)
-
-#define S_DFI_LP_EN_SR 8
-#define V_DFI_LP_EN_SR(x) ((x) << S_DFI_LP_EN_SR)
-#define F_DFI_LP_EN_SR V_DFI_LP_EN_SR(1U)
-
-#define S_DFI_LP_WAKEUP_PD 4
-#define M_DFI_LP_WAKEUP_PD 0xfU
-#define V_DFI_LP_WAKEUP_PD(x) ((x) << S_DFI_LP_WAKEUP_PD)
-#define G_DFI_LP_WAKEUP_PD(x) (((x) >> S_DFI_LP_WAKEUP_PD) & M_DFI_LP_WAKEUP_PD)
-
-#define S_DFI_LP_EN_PD 0
-#define V_DFI_LP_EN_PD(x) ((x) << S_DFI_LP_EN_PD)
-#define F_DFI_LP_EN_PD V_DFI_LP_EN_PD(1U)
-
-#define A_MC_UPCTL_DFITRWRLVLRESP0 0x40300
-#define A_MC_UPCTL_DFITRWRLVLRESP1 0x40304
-#define A_MC_LMC_CALSTAT 0x40304
-
-#define S_PHYUPD_ERR 28
-#define M_PHYUPD_ERR 0xfU
-#define V_PHYUPD_ERR(x) ((x) << S_PHYUPD_ERR)
-#define G_PHYUPD_ERR(x) (((x) >> S_PHYUPD_ERR) & M_PHYUPD_ERR)
-
-#define S_PHYUPD_BUSY 27
-#define V_PHYUPD_BUSY(x) ((x) << S_PHYUPD_BUSY)
-#define F_PHYUPD_BUSY V_PHYUPD_BUSY(1U)
-
-#define A_MC_UPCTL_DFITRWRLVLRESP2 0x40308
-
-#define S_DFI_WRLVL_RESP2 0
-#define M_DFI_WRLVL_RESP2 0xffU
-#define V_DFI_WRLVL_RESP2(x) ((x) << S_DFI_WRLVL_RESP2)
-#define G_DFI_WRLVL_RESP2(x) (((x) >> S_DFI_WRLVL_RESP2) & M_DFI_WRLVL_RESP2)
-
-#define A_MC_UPCTL_DFITRRDLVLRESP0 0x4030c
-#define A_MC_UPCTL_DFITRRDLVLRESP1 0x40310
-#define A_MC_UPCTL_DFITRRDLVLRESP2 0x40314
-
-#define S_DFI_RDLVL_RESP2 0
-#define M_DFI_RDLVL_RESP2 0xffU
-#define V_DFI_RDLVL_RESP2(x) ((x) << S_DFI_RDLVL_RESP2)
-#define G_DFI_RDLVL_RESP2(x) (((x) >> S_DFI_RDLVL_RESP2) & M_DFI_RDLVL_RESP2)
-
-#define A_MC_UPCTL_DFITRWRLVLDELAY0 0x40318
-#define A_MC_UPCTL_DFITRWRLVLDELAY1 0x4031c
-#define A_MC_UPCTL_DFITRWRLVLDELAY2 0x40320
-
-#define S_DFI_WRLVL_DELAY2 0
-#define M_DFI_WRLVL_DELAY2 0xffU
-#define V_DFI_WRLVL_DELAY2(x) ((x) << S_DFI_WRLVL_DELAY2)
-#define G_DFI_WRLVL_DELAY2(x) (((x) >> S_DFI_WRLVL_DELAY2) & M_DFI_WRLVL_DELAY2)
-
-#define A_MC_UPCTL_DFITRRDLVLDELAY0 0x40324
-#define A_MC_UPCTL_DFITRRDLVLDELAY1 0x40328
-#define A_MC_UPCTL_DFITRRDLVLDELAY2 0x4032c
-
-#define S_DFI_RDLVL_DELAY2 0
-#define M_DFI_RDLVL_DELAY2 0xffU
-#define V_DFI_RDLVL_DELAY2(x) ((x) << S_DFI_RDLVL_DELAY2)
-#define G_DFI_RDLVL_DELAY2(x) (((x) >> S_DFI_RDLVL_DELAY2) & M_DFI_RDLVL_DELAY2)
-
-#define A_MC_UPCTL_DFITRRDLVLGATEDELAY0 0x40330
-#define A_MC_LMC_T_PHYUPD0 0x40330
-#define A_MC_UPCTL_DFITRRDLVLGATEDELAY1 0x40334
-#define A_MC_LMC_T_PHYUPD1 0x40334
-#define A_MC_UPCTL_DFITRRDLVLGATEDELAY2 0x40338
-
-#define S_DFI_RDLVL_GATE_DELAY2 0
-#define M_DFI_RDLVL_GATE_DELAY2 0xffU
-#define V_DFI_RDLVL_GATE_DELAY2(x) ((x) << S_DFI_RDLVL_GATE_DELAY2)
-#define G_DFI_RDLVL_GATE_DELAY2(x) (((x) >> S_DFI_RDLVL_GATE_DELAY2) & M_DFI_RDLVL_GATE_DELAY2)
-
-#define A_MC_LMC_T_PHYUPD2 0x40338
-#define A_MC_UPCTL_DFITRCMD 0x4033c
-
-#define S_DFITRCMD_START 31
-#define V_DFITRCMD_START(x) ((x) << S_DFITRCMD_START)
-#define F_DFITRCMD_START V_DFITRCMD_START(1U)
-
-#define S_DFITRCMD_EN 4
-#define M_DFITRCMD_EN 0x1ffU
-#define V_DFITRCMD_EN(x) ((x) << S_DFITRCMD_EN)
-#define G_DFITRCMD_EN(x) (((x) >> S_DFITRCMD_EN) & M_DFITRCMD_EN)
-
-#define S_DFITRCMD_OPCODE 0
-#define M_DFITRCMD_OPCODE 0x3U
-#define V_DFITRCMD_OPCODE(x) ((x) << S_DFITRCMD_OPCODE)
-#define G_DFITRCMD_OPCODE(x) (((x) >> S_DFITRCMD_OPCODE) & M_DFITRCMD_OPCODE)
-
-#define A_MC_LMC_T_PHYUPD3 0x4033c
-#define A_MC_UPCTL_IPVR 0x403f8
-#define A_MC_UPCTL_IPTR 0x403fc
-#define A_MC_P_DDRPHY_RST_CTRL 0x41300
-
-#define S_PHY_DRAM_WL 17
-#define M_PHY_DRAM_WL 0x1fU
-#define V_PHY_DRAM_WL(x) ((x) << S_PHY_DRAM_WL)
-#define G_PHY_DRAM_WL(x) (((x) >> S_PHY_DRAM_WL) & M_PHY_DRAM_WL)
-
-#define S_PHY_CALIB_DONE 5
-#define V_PHY_CALIB_DONE(x) ((x) << S_PHY_CALIB_DONE)
-#define F_PHY_CALIB_DONE V_PHY_CALIB_DONE(1U)
-
-#define S_CTL_CAL_REQ 4
-#define V_CTL_CAL_REQ(x) ((x) << S_CTL_CAL_REQ)
-#define F_CTL_CAL_REQ V_CTL_CAL_REQ(1U)
-
-#define S_CTL_CKE 3
-#define V_CTL_CKE(x) ((x) << S_CTL_CKE)
-#define F_CTL_CKE V_CTL_CKE(1U)
-
-#define S_CTL_RST_N 2
-#define V_CTL_RST_N(x) ((x) << S_CTL_RST_N)
-#define F_CTL_RST_N V_CTL_RST_N(1U)
-
-#define S_PHY_CAL_REQ 21
-#define V_PHY_CAL_REQ(x) ((x) << S_PHY_CAL_REQ)
-#define F_PHY_CAL_REQ V_PHY_CAL_REQ(1U)
-
-#define S_T6_PHY_DRAM_WL 17
-#define M_T6_PHY_DRAM_WL 0xfU
-#define V_T6_PHY_DRAM_WL(x) ((x) << S_T6_PHY_DRAM_WL)
-#define G_T6_PHY_DRAM_WL(x) (((x) >> S_T6_PHY_DRAM_WL) & M_T6_PHY_DRAM_WL)
-
-#define A_MC_P_PERFORMANCE_CTRL 0x41304
-
-#define S_BUF_USE_TH 12
-#define M_BUF_USE_TH 0x7U
-#define V_BUF_USE_TH(x) ((x) << S_BUF_USE_TH)
-#define G_BUF_USE_TH(x) (((x) >> S_BUF_USE_TH) & M_BUF_USE_TH)
-
-#define S_MC_IDLE_TH 8
-#define M_MC_IDLE_TH 0xfU
-#define V_MC_IDLE_TH(x) ((x) << S_MC_IDLE_TH)
-#define G_MC_IDLE_TH(x) (((x) >> S_MC_IDLE_TH) & M_MC_IDLE_TH)
-
-#define S_RMW_DEFER_EN 7
-#define V_RMW_DEFER_EN(x) ((x) << S_RMW_DEFER_EN)
-#define F_RMW_DEFER_EN V_RMW_DEFER_EN(1U)
-
-#define S_DDR3_BRBC_MODE 6
-#define V_DDR3_BRBC_MODE(x) ((x) << S_DDR3_BRBC_MODE)
-#define F_DDR3_BRBC_MODE V_DDR3_BRBC_MODE(1U)
-
-#define S_RMW_DWRITE_EN 5
-#define V_RMW_DWRITE_EN(x) ((x) << S_RMW_DWRITE_EN)
-#define F_RMW_DWRITE_EN V_RMW_DWRITE_EN(1U)
-
-#define S_RMW_MERGE_EN 4
-#define V_RMW_MERGE_EN(x) ((x) << S_RMW_MERGE_EN)
-#define F_RMW_MERGE_EN V_RMW_MERGE_EN(1U)
-
-#define S_SYNC_PAB_EN 3
-#define V_SYNC_PAB_EN(x) ((x) << S_SYNC_PAB_EN)
-#define F_SYNC_PAB_EN V_SYNC_PAB_EN(1U)
-
-#define A_MC_P_ECC_CTRL 0x41308
-#define A_MC_P_PAR_ENABLE 0x4130c
-#define A_MC_P_PAR_CAUSE 0x41310
-#define A_MC_P_INT_ENABLE 0x41314
-#define A_MC_P_INT_CAUSE 0x41318
-#define A_MC_P_ECC_STATUS 0x4131c
-#define A_MC_P_PHY_CTRL 0x41320
-#define A_MC_P_STATIC_CFG_STATUS 0x41324
-
-#define S_STATIC_AWEN 23
-#define V_STATIC_AWEN(x) ((x) << S_STATIC_AWEN)
-#define F_STATIC_AWEN V_STATIC_AWEN(1U)
-
-#define S_STATIC_SWLAT 18
-#define M_STATIC_SWLAT 0x1fU
-#define V_STATIC_SWLAT(x) ((x) << S_STATIC_SWLAT)
-#define G_STATIC_SWLAT(x) (((x) >> S_STATIC_SWLAT) & M_STATIC_SWLAT)
-
-#define S_STATIC_WLAT 17
-#define V_STATIC_WLAT(x) ((x) << S_STATIC_WLAT)
-#define F_STATIC_WLAT V_STATIC_WLAT(1U)
-
-#define S_STATIC_ALIGN 16
-#define V_STATIC_ALIGN(x) ((x) << S_STATIC_ALIGN)
-#define F_STATIC_ALIGN V_STATIC_ALIGN(1U)
-
-#define S_STATIC_SLAT 11
-#define M_STATIC_SLAT 0x1fU
-#define V_STATIC_SLAT(x) ((x) << S_STATIC_SLAT)
-#define G_STATIC_SLAT(x) (((x) >> S_STATIC_SLAT) & M_STATIC_SLAT)
-
-#define S_STATIC_LAT 10
-#define V_STATIC_LAT(x) ((x) << S_STATIC_LAT)
-#define F_STATIC_LAT V_STATIC_LAT(1U)
-
-#define S_STATIC_PP64 26
-#define V_STATIC_PP64(x) ((x) << S_STATIC_PP64)
-#define F_STATIC_PP64 V_STATIC_PP64(1U)
-
-#define S_STATIC_PPEN 25
-#define V_STATIC_PPEN(x) ((x) << S_STATIC_PPEN)
-#define F_STATIC_PPEN V_STATIC_PPEN(1U)
-
-#define S_STATIC_OOOEN 24
-#define V_STATIC_OOOEN(x) ((x) << S_STATIC_OOOEN)
-#define F_STATIC_OOOEN V_STATIC_OOOEN(1U)
-
-#define A_MC_P_CORE_PCTL_STAT 0x41328
-#define A_MC_P_DEBUG_CNT 0x4132c
-#define A_MC_CE_ERR_DATA_RDATA 0x41330
-#define A_MC_CE_COR_DATA_RDATA 0x41350
-#define A_MC_UE_ERR_DATA_RDATA 0x41370
-#define A_MC_UE_COR_DATA_RDATA 0x41390
-#define A_MC_CE_ADDR 0x413b0
-#define A_MC_UE_ADDR 0x413b4
-#define A_MC_P_DEEP_SLEEP 0x413b8
-
-#define S_SLEEPSTATUS 1
-#define V_SLEEPSTATUS(x) ((x) << S_SLEEPSTATUS)
-#define F_SLEEPSTATUS V_SLEEPSTATUS(1U)
-
-#define S_SLEEPREQ 0
-#define V_SLEEPREQ(x) ((x) << S_SLEEPREQ)
-#define F_SLEEPREQ V_SLEEPREQ(1U)
-
-#define A_MC_P_FPGA_BONUS 0x413bc
-#define A_MC_P_DEBUG_CFG 0x413c0
-#define A_MC_P_DEBUG_RPT 0x413c4
-#define A_MC_P_PHY_ADR_CK_EN 0x413c8
-
-#define S_ADR_CK_EN 0
-#define V_ADR_CK_EN(x) ((x) << S_ADR_CK_EN)
-#define F_ADR_CK_EN V_ADR_CK_EN(1U)
-
-#define A_MC_CE_ERR_ECC_DATA0 0x413d0
-#define A_MC_CE_ERR_ECC_DATA1 0x413d4
-#define A_MC_UE_ERR_ECC_DATA0 0x413d8
-#define A_MC_UE_ERR_ECC_DATA1 0x413dc
-#define A_MC_P_RMW_PRIO 0x413f0
-
-#define S_WR_HI_TH 24
-#define M_WR_HI_TH 0xffU
-#define V_WR_HI_TH(x) ((x) << S_WR_HI_TH)
-#define G_WR_HI_TH(x) (((x) >> S_WR_HI_TH) & M_WR_HI_TH)
-
-#define S_WR_MID_TH 16
-#define M_WR_MID_TH 0xffU
-#define V_WR_MID_TH(x) ((x) << S_WR_MID_TH)
-#define G_WR_MID_TH(x) (((x) >> S_WR_MID_TH) & M_WR_MID_TH)
-
-#define S_RD_HI_TH 8
-#define M_RD_HI_TH 0xffU
-#define V_RD_HI_TH(x) ((x) << S_RD_HI_TH)
-#define G_RD_HI_TH(x) (((x) >> S_RD_HI_TH) & M_RD_HI_TH)
-
-#define S_RD_MID_TH 0
-#define M_RD_MID_TH 0xffU
-#define V_RD_MID_TH(x) ((x) << S_RD_MID_TH)
-#define G_RD_MID_TH(x) (((x) >> S_RD_MID_TH) & M_RD_MID_TH)
-
-#define A_MC_P_BIST_CMD 0x41400
-
-#define S_BURST_LEN 16
-#define M_BURST_LEN 0x3U
-#define V_BURST_LEN(x) ((x) << S_BURST_LEN)
-#define G_BURST_LEN(x) (((x) >> S_BURST_LEN) & M_BURST_LEN)
-
-#define A_MC_P_BIST_CMD_ADDR 0x41404
-#define A_MC_P_BIST_CMD_LEN 0x41408
-#define A_MC_P_BIST_DATA_PATTERN 0x4140c
-#define A_MC_P_BIST_USER_WDATA0 0x41414
-#define A_MC_P_BIST_USER_WMASK0 0x41414
-#define A_MC_P_BIST_USER_WDATA1 0x41418
-#define A_MC_P_BIST_USER_WMASK1 0x41418
-#define A_MC_P_BIST_USER_WDATA2 0x4141c
-
-#define S_USER_DATA_MASK 8
-#define M_USER_DATA_MASK 0x1ffU
-#define V_USER_DATA_MASK(x) ((x) << S_USER_DATA_MASK)
-#define G_USER_DATA_MASK(x) (((x) >> S_USER_DATA_MASK) & M_USER_DATA_MASK)
-
-#define A_MC_P_BIST_USER_WMASK2 0x4141c
-
-#define S_MASK_128_1 9
-#define V_MASK_128_1(x) ((x) << S_MASK_128_1)
-#define F_MASK_128_1 V_MASK_128_1(1U)
-
-#define S_MASK_128_0 8
-#define V_MASK_128_0(x) ((x) << S_MASK_128_0)
-#define F_MASK_128_0 V_MASK_128_0(1U)
-
-#define S_USER_MASK_ECC 0
-#define M_USER_MASK_ECC 0xffU
-#define V_USER_MASK_ECC(x) ((x) << S_USER_MASK_ECC)
-#define G_USER_MASK_ECC(x) (((x) >> S_USER_MASK_ECC) & M_USER_MASK_ECC)
-
-#define A_MC_P_BIST_NUM_ERR 0x41480
-#define A_MC_P_BIST_ERR_FIRST_ADDR 0x41484
-#define A_MC_P_BIST_STATUS_RDATA 0x41488
-#define A_MC_P_BIST_CRC_SEED 0x414d0
-#define A_MC_DDRPHY_DP18_DATA_BIT_ENABLE0 0x44000
-
-#define S_DATA_BIT_ENABLE_0_15 0
-#define M_DATA_BIT_ENABLE_0_15 0xffffU
-#define V_DATA_BIT_ENABLE_0_15(x) ((x) << S_DATA_BIT_ENABLE_0_15)
-#define G_DATA_BIT_ENABLE_0_15(x) (((x) >> S_DATA_BIT_ENABLE_0_15) & M_DATA_BIT_ENABLE_0_15)
-
-#define A_MC_DDRPHY_DP18_DATA_BIT_ENABLE1 0x44004
-
-#define S_DATA_BIT_ENABLE_16_23 8
-#define M_DATA_BIT_ENABLE_16_23 0xffU
-#define V_DATA_BIT_ENABLE_16_23(x) ((x) << S_DATA_BIT_ENABLE_16_23)
-#define G_DATA_BIT_ENABLE_16_23(x) (((x) >> S_DATA_BIT_ENABLE_16_23) & M_DATA_BIT_ENABLE_16_23)
-
-#define S_DFT_FORCE_OUTPUTS 7
-#define V_DFT_FORCE_OUTPUTS(x) ((x) << S_DFT_FORCE_OUTPUTS)
-#define F_DFT_FORCE_OUTPUTS V_DFT_FORCE_OUTPUTS(1U)
-
-#define S_DFT_PRBS7_GEN_EN 6
-#define V_DFT_PRBS7_GEN_EN(x) ((x) << S_DFT_PRBS7_GEN_EN)
-#define F_DFT_PRBS7_GEN_EN V_DFT_PRBS7_GEN_EN(1U)
-
-#define S_WRAPSEL 5
-#define V_WRAPSEL(x) ((x) << S_WRAPSEL)
-#define F_WRAPSEL V_WRAPSEL(1U)
-
-#define S_MRS_CMD_DATA_N0 3
-#define V_MRS_CMD_DATA_N0(x) ((x) << S_MRS_CMD_DATA_N0)
-#define F_MRS_CMD_DATA_N0 V_MRS_CMD_DATA_N0(1U)
-
-#define S_MRS_CMD_DATA_N1 2
-#define V_MRS_CMD_DATA_N1(x) ((x) << S_MRS_CMD_DATA_N1)
-#define F_MRS_CMD_DATA_N1 V_MRS_CMD_DATA_N1(1U)
-
-#define S_MRS_CMD_DATA_N2 1
-#define V_MRS_CMD_DATA_N2(x) ((x) << S_MRS_CMD_DATA_N2)
-#define F_MRS_CMD_DATA_N2 V_MRS_CMD_DATA_N2(1U)
-
-#define S_MRS_CMD_DATA_N3 0
-#define V_MRS_CMD_DATA_N3(x) ((x) << S_MRS_CMD_DATA_N3)
-#define F_MRS_CMD_DATA_N3 V_MRS_CMD_DATA_N3(1U)
-
-#define S_DP18_WRAPSEL 5
-#define V_DP18_WRAPSEL(x) ((x) << S_DP18_WRAPSEL)
-#define F_DP18_WRAPSEL V_DP18_WRAPSEL(1U)
-
-#define S_HW_VALUE 4
-#define V_HW_VALUE(x) ((x) << S_HW_VALUE)
-#define F_HW_VALUE V_HW_VALUE(1U)
-
-#define A_MC_DDRPHY_DP18_DATA_BIT_DIR0 0x44008
-
-#define S_DATA_BIT_DIR_0_15 0
-#define M_DATA_BIT_DIR_0_15 0xffffU
-#define V_DATA_BIT_DIR_0_15(x) ((x) << S_DATA_BIT_DIR_0_15)
-#define G_DATA_BIT_DIR_0_15(x) (((x) >> S_DATA_BIT_DIR_0_15) & M_DATA_BIT_DIR_0_15)
-
-#define A_MC_DDRPHY_DP18_DATA_BIT_DIR1 0x4400c
-
-#define S_DATA_BIT_DIR_16_23 8
-#define M_DATA_BIT_DIR_16_23 0xffU
-#define V_DATA_BIT_DIR_16_23(x) ((x) << S_DATA_BIT_DIR_16_23)
-#define G_DATA_BIT_DIR_16_23(x) (((x) >> S_DATA_BIT_DIR_16_23) & M_DATA_BIT_DIR_16_23)
-
-#define S_WL_ADVANCE_DISABLE 7
-#define V_WL_ADVANCE_DISABLE(x) ((x) << S_WL_ADVANCE_DISABLE)
-#define F_WL_ADVANCE_DISABLE V_WL_ADVANCE_DISABLE(1U)
-
-#define S_DISABLE_PING_PONG 6
-#define V_DISABLE_PING_PONG(x) ((x) << S_DISABLE_PING_PONG)
-#define F_DISABLE_PING_PONG V_DISABLE_PING_PONG(1U)
-
-#define S_DELAY_PING_PONG_HALF 5
-#define V_DELAY_PING_PONG_HALF(x) ((x) << S_DELAY_PING_PONG_HALF)
-#define F_DELAY_PING_PONG_HALF V_DELAY_PING_PONG_HALF(1U)
-
-#define S_ADVANCE_PING_PONG 4
-#define V_ADVANCE_PING_PONG(x) ((x) << S_ADVANCE_PING_PONG)
-#define F_ADVANCE_PING_PONG V_ADVANCE_PING_PONG(1U)
-
-#define S_ATEST_MUX_CTL0 3
-#define V_ATEST_MUX_CTL0(x) ((x) << S_ATEST_MUX_CTL0)
-#define F_ATEST_MUX_CTL0 V_ATEST_MUX_CTL0(1U)
-
-#define S_ATEST_MUX_CTL1 2
-#define V_ATEST_MUX_CTL1(x) ((x) << S_ATEST_MUX_CTL1)
-#define F_ATEST_MUX_CTL1 V_ATEST_MUX_CTL1(1U)
-
-#define S_ATEST_MUX_CTL2 1
-#define V_ATEST_MUX_CTL2(x) ((x) << S_ATEST_MUX_CTL2)
-#define F_ATEST_MUX_CTL2 V_ATEST_MUX_CTL2(1U)
-
-#define S_ATEST_MUX_CTL3 0
-#define V_ATEST_MUX_CTL3(x) ((x) << S_ATEST_MUX_CTL3)
-#define F_ATEST_MUX_CTL3 V_ATEST_MUX_CTL3(1U)
-
-#define A_MC_DDRPHY_DP18_READ_CLOCK_RANK_PAIR 0x44010
-
-#define S_QUAD0_CLK16_BIT0 15
-#define V_QUAD0_CLK16_BIT0(x) ((x) << S_QUAD0_CLK16_BIT0)
-#define F_QUAD0_CLK16_BIT0 V_QUAD0_CLK16_BIT0(1U)
-
-#define S_QUAD1_CLK16_BIT1 14
-#define V_QUAD1_CLK16_BIT1(x) ((x) << S_QUAD1_CLK16_BIT1)
-#define F_QUAD1_CLK16_BIT1 V_QUAD1_CLK16_BIT1(1U)
-
-#define S_QUAD2_CLK16_BIT2 13
-#define V_QUAD2_CLK16_BIT2(x) ((x) << S_QUAD2_CLK16_BIT2)
-#define F_QUAD2_CLK16_BIT2 V_QUAD2_CLK16_BIT2(1U)
-
-#define S_QUAD3_CLK16_BIT3 12
-#define V_QUAD3_CLK16_BIT3(x) ((x) << S_QUAD3_CLK16_BIT3)
-#define F_QUAD3_CLK16_BIT3 V_QUAD3_CLK16_BIT3(1U)
-
-#define S_QUAD0_CLK18_BIT4 11
-#define V_QUAD0_CLK18_BIT4(x) ((x) << S_QUAD0_CLK18_BIT4)
-#define F_QUAD0_CLK18_BIT4 V_QUAD0_CLK18_BIT4(1U)
-
-#define S_QUAD1_CLK18_BIT5 10
-#define V_QUAD1_CLK18_BIT5(x) ((x) << S_QUAD1_CLK18_BIT5)
-#define F_QUAD1_CLK18_BIT5 V_QUAD1_CLK18_BIT5(1U)
-
-#define S_QUAD2_CLK20_BIT6 9
-#define V_QUAD2_CLK20_BIT6(x) ((x) << S_QUAD2_CLK20_BIT6)
-#define F_QUAD2_CLK20_BIT6 V_QUAD2_CLK20_BIT6(1U)
-
-#define S_QUAD3_CLK20_BIT7 8
-#define V_QUAD3_CLK20_BIT7(x) ((x) << S_QUAD3_CLK20_BIT7)
-#define F_QUAD3_CLK20_BIT7 V_QUAD3_CLK20_BIT7(1U)
-
-#define S_QUAD2_CLK22_BIT8 7
-#define V_QUAD2_CLK22_BIT8(x) ((x) << S_QUAD2_CLK22_BIT8)
-#define F_QUAD2_CLK22_BIT8 V_QUAD2_CLK22_BIT8(1U)
-
-#define S_QUAD3_CLK22_BIT9 6
-#define V_QUAD3_CLK22_BIT9(x) ((x) << S_QUAD3_CLK22_BIT9)
-#define F_QUAD3_CLK22_BIT9 V_QUAD3_CLK22_BIT9(1U)
-
-#define S_CLK16_SINGLE_ENDED_BIT10 5
-#define V_CLK16_SINGLE_ENDED_BIT10(x) ((x) << S_CLK16_SINGLE_ENDED_BIT10)
-#define F_CLK16_SINGLE_ENDED_BIT10 V_CLK16_SINGLE_ENDED_BIT10(1U)
-
-#define S_CLK18_SINGLE_ENDED_BIT11 4
-#define V_CLK18_SINGLE_ENDED_BIT11(x) ((x) << S_CLK18_SINGLE_ENDED_BIT11)
-#define F_CLK18_SINGLE_ENDED_BIT11 V_CLK18_SINGLE_ENDED_BIT11(1U)
-
-#define S_CLK20_SINGLE_ENDED_BIT12 3
-#define V_CLK20_SINGLE_ENDED_BIT12(x) ((x) << S_CLK20_SINGLE_ENDED_BIT12)
-#define F_CLK20_SINGLE_ENDED_BIT12 V_CLK20_SINGLE_ENDED_BIT12(1U)
-
-#define S_CLK22_SINGLE_ENDED_BIT13 2
-#define V_CLK22_SINGLE_ENDED_BIT13(x) ((x) << S_CLK22_SINGLE_ENDED_BIT13)
-#define F_CLK22_SINGLE_ENDED_BIT13 V_CLK22_SINGLE_ENDED_BIT13(1U)
-
-#define A_MC_DDRPHY_DP18_WRCLK_EN_RP 0x44014
-
-#define S_QUAD2_CLK18_BIT14 1
-#define V_QUAD2_CLK18_BIT14(x) ((x) << S_QUAD2_CLK18_BIT14)
-#define F_QUAD2_CLK18_BIT14 V_QUAD2_CLK18_BIT14(1U)
-
-#define S_QUAD3_CLK18_BIT15 0
-#define V_QUAD3_CLK18_BIT15(x) ((x) << S_QUAD3_CLK18_BIT15)
-#define F_QUAD3_CLK18_BIT15 V_QUAD3_CLK18_BIT15(1U)
-
-#define A_MC_DDRPHY_DP18_RX_PEAK_AMP 0x44018
-
-#define S_PEAK_AMP_CTL_SIDE0 13
-#define M_PEAK_AMP_CTL_SIDE0 0x7U
-#define V_PEAK_AMP_CTL_SIDE0(x) ((x) << S_PEAK_AMP_CTL_SIDE0)
-#define G_PEAK_AMP_CTL_SIDE0(x) (((x) >> S_PEAK_AMP_CTL_SIDE0) & M_PEAK_AMP_CTL_SIDE0)
-
-#define S_PEAK_AMP_CTL_SIDE1 9
-#define M_PEAK_AMP_CTL_SIDE1 0x7U
-#define V_PEAK_AMP_CTL_SIDE1(x) ((x) << S_PEAK_AMP_CTL_SIDE1)
-#define G_PEAK_AMP_CTL_SIDE1(x) (((x) >> S_PEAK_AMP_CTL_SIDE1) & M_PEAK_AMP_CTL_SIDE1)
-
-#define S_SXMCVREF_0_3 4
-#define M_SXMCVREF_0_3 0xfU
-#define V_SXMCVREF_0_3(x) ((x) << S_SXMCVREF_0_3)
-#define G_SXMCVREF_0_3(x) (((x) >> S_SXMCVREF_0_3) & M_SXMCVREF_0_3)
-
-#define S_SXPODVREF 3
-#define V_SXPODVREF(x) ((x) << S_SXPODVREF)
-#define F_SXPODVREF V_SXPODVREF(1U)
-
-#define S_DISABLE_TERMINATION 2
-#define V_DISABLE_TERMINATION(x) ((x) << S_DISABLE_TERMINATION)
-#define F_DISABLE_TERMINATION V_DISABLE_TERMINATION(1U)
-
-#define S_READ_CENTERING_MODE 0
-#define M_READ_CENTERING_MODE 0x3U
-#define V_READ_CENTERING_MODE(x) ((x) << S_READ_CENTERING_MODE)
-#define G_READ_CENTERING_MODE(x) (((x) >> S_READ_CENTERING_MODE) & M_READ_CENTERING_MODE)
-
-#define A_MC_DDRPHY_DP18_SYSCLK_PR 0x4401c
-
-#define S_SYSCLK_PHASE_ALIGN_RESET 6
-#define V_SYSCLK_PHASE_ALIGN_RESET(x) ((x) << S_SYSCLK_PHASE_ALIGN_RESET)
-#define F_SYSCLK_PHASE_ALIGN_RESET V_SYSCLK_PHASE_ALIGN_RESET(1U)
-
-#define A_MC_DDRPHY_DP18_DFT_DIG_EYE 0x44020
-
-#define S_DIGITAL_EYE_EN 15
-#define V_DIGITAL_EYE_EN(x) ((x) << S_DIGITAL_EYE_EN)
-#define F_DIGITAL_EYE_EN V_DIGITAL_EYE_EN(1U)
-
-#define S_BUMP 14
-#define V_BUMP(x) ((x) << S_BUMP)
-#define F_BUMP V_BUMP(1U)
-
-#define S_TRIG_PERIOD 13
-#define V_TRIG_PERIOD(x) ((x) << S_TRIG_PERIOD)
-#define F_TRIG_PERIOD V_TRIG_PERIOD(1U)
-
-#define S_CNTL_POL 12
-#define V_CNTL_POL(x) ((x) << S_CNTL_POL)
-#define F_CNTL_POL V_CNTL_POL(1U)
-
-#define S_CNTL_SRC 8
-#define V_CNTL_SRC(x) ((x) << S_CNTL_SRC)
-#define F_CNTL_SRC V_CNTL_SRC(1U)
-
-#define S_DIGITAL_EYE_VALUE 0
-#define M_DIGITAL_EYE_VALUE 0xffU
-#define V_DIGITAL_EYE_VALUE(x) ((x) << S_DIGITAL_EYE_VALUE)
-#define G_DIGITAL_EYE_VALUE(x) (((x) >> S_DIGITAL_EYE_VALUE) & M_DIGITAL_EYE_VALUE)
-
-#define A_MC_DDRPHY_DP18_DQS_RD_PHASE_SELECT_RANK_PAIR 0x44024
-
-#define S_DQSCLK_SELECT0 14
-#define M_DQSCLK_SELECT0 0x3U
-#define V_DQSCLK_SELECT0(x) ((x) << S_DQSCLK_SELECT0)
-#define G_DQSCLK_SELECT0(x) (((x) >> S_DQSCLK_SELECT0) & M_DQSCLK_SELECT0)
-
-#define S_RDCLK_SELECT0 12
-#define M_RDCLK_SELECT0 0x3U
-#define V_RDCLK_SELECT0(x) ((x) << S_RDCLK_SELECT0)
-#define G_RDCLK_SELECT0(x) (((x) >> S_RDCLK_SELECT0) & M_RDCLK_SELECT0)
-
-#define S_DQSCLK_SELECT1 10
-#define M_DQSCLK_SELECT1 0x3U
-#define V_DQSCLK_SELECT1(x) ((x) << S_DQSCLK_SELECT1)
-#define G_DQSCLK_SELECT1(x) (((x) >> S_DQSCLK_SELECT1) & M_DQSCLK_SELECT1)
-
-#define S_RDCLK_SELECT1 8
-#define M_RDCLK_SELECT1 0x3U
-#define V_RDCLK_SELECT1(x) ((x) << S_RDCLK_SELECT1)
-#define G_RDCLK_SELECT1(x) (((x) >> S_RDCLK_SELECT1) & M_RDCLK_SELECT1)
-
-#define S_DQSCLK_SELECT2 6
-#define M_DQSCLK_SELECT2 0x3U
-#define V_DQSCLK_SELECT2(x) ((x) << S_DQSCLK_SELECT2)
-#define G_DQSCLK_SELECT2(x) (((x) >> S_DQSCLK_SELECT2) & M_DQSCLK_SELECT2)
-
-#define S_RDCLK_SELECT2 4
-#define M_RDCLK_SELECT2 0x3U
-#define V_RDCLK_SELECT2(x) ((x) << S_RDCLK_SELECT2)
-#define G_RDCLK_SELECT2(x) (((x) >> S_RDCLK_SELECT2) & M_RDCLK_SELECT2)
-
-#define S_DQSCLK_SELECT3 2
-#define M_DQSCLK_SELECT3 0x3U
-#define V_DQSCLK_SELECT3(x) ((x) << S_DQSCLK_SELECT3)
-#define G_DQSCLK_SELECT3(x) (((x) >> S_DQSCLK_SELECT3) & M_DQSCLK_SELECT3)
-
-#define S_RDCLK_SELECT3 0
-#define M_RDCLK_SELECT3 0x3U
-#define V_RDCLK_SELECT3(x) ((x) << S_RDCLK_SELECT3)
-#define G_RDCLK_SELECT3(x) (((x) >> S_RDCLK_SELECT3) & M_RDCLK_SELECT3)
-
-#define A_MC_DDRPHY_DP18_DRIFT_LIMITS 0x44028
-
-#define S_MIN_RD_EYE_SIZE 8
-#define M_MIN_RD_EYE_SIZE 0x3fU
-#define V_MIN_RD_EYE_SIZE(x) ((x) << S_MIN_RD_EYE_SIZE)
-#define G_MIN_RD_EYE_SIZE(x) (((x) >> S_MIN_RD_EYE_SIZE) & M_MIN_RD_EYE_SIZE)
-
-#define S_MAX_DQS_DRIFT 0
-#define M_MAX_DQS_DRIFT 0x3fU
-#define V_MAX_DQS_DRIFT(x) ((x) << S_MAX_DQS_DRIFT)
-#define G_MAX_DQS_DRIFT(x) (((x) >> S_MAX_DQS_DRIFT) & M_MAX_DQS_DRIFT)
-
-#define A_MC_DDRPHY_DP18_DEBUG_SEL 0x4402c
-
-#define S_HS_PROBE_A_SEL 11
-#define M_HS_PROBE_A_SEL 0x1fU
-#define V_HS_PROBE_A_SEL(x) ((x) << S_HS_PROBE_A_SEL)
-#define G_HS_PROBE_A_SEL(x) (((x) >> S_HS_PROBE_A_SEL) & M_HS_PROBE_A_SEL)
-
-#define S_HS_PROBE_B_SEL 6
-#define M_HS_PROBE_B_SEL 0x1fU
-#define V_HS_PROBE_B_SEL(x) ((x) << S_HS_PROBE_B_SEL)
-#define G_HS_PROBE_B_SEL(x) (((x) >> S_HS_PROBE_B_SEL) & M_HS_PROBE_B_SEL)
-
-#define S_RD_DEBUG_SEL 3
-#define M_RD_DEBUG_SEL 0x7U
-#define V_RD_DEBUG_SEL(x) ((x) << S_RD_DEBUG_SEL)
-#define G_RD_DEBUG_SEL(x) (((x) >> S_RD_DEBUG_SEL) & M_RD_DEBUG_SEL)
-
-#define S_WR_DEBUG_SEL 0
-#define M_WR_DEBUG_SEL 0x7U
-#define V_WR_DEBUG_SEL(x) ((x) << S_WR_DEBUG_SEL)
-#define G_WR_DEBUG_SEL(x) (((x) >> S_WR_DEBUG_SEL) & M_WR_DEBUG_SEL)
-
-#define S_DP18_HS_PROBE_A_SEL 11
-#define M_DP18_HS_PROBE_A_SEL 0x1fU
-#define V_DP18_HS_PROBE_A_SEL(x) ((x) << S_DP18_HS_PROBE_A_SEL)
-#define G_DP18_HS_PROBE_A_SEL(x) (((x) >> S_DP18_HS_PROBE_A_SEL) & M_DP18_HS_PROBE_A_SEL)
-
-#define S_DP18_HS_PROBE_B_SEL 6
-#define M_DP18_HS_PROBE_B_SEL 0x1fU
-#define V_DP18_HS_PROBE_B_SEL(x) ((x) << S_DP18_HS_PROBE_B_SEL)
-#define G_DP18_HS_PROBE_B_SEL(x) (((x) >> S_DP18_HS_PROBE_B_SEL) & M_DP18_HS_PROBE_B_SEL)
-
-#define A_MC_DDRPHY_DP18_READ_DELAY_OFFSET0_RANK_PAIR 0x44030
-
-#define S_OFFSET_BITS1_7 8
-#define M_OFFSET_BITS1_7 0x7fU
-#define V_OFFSET_BITS1_7(x) ((x) << S_OFFSET_BITS1_7)
-#define G_OFFSET_BITS1_7(x) (((x) >> S_OFFSET_BITS1_7) & M_OFFSET_BITS1_7)
-
-#define S_OFFSET_BITS9_15 0
-#define M_OFFSET_BITS9_15 0x7fU
-#define V_OFFSET_BITS9_15(x) ((x) << S_OFFSET_BITS9_15)
-#define G_OFFSET_BITS9_15(x) (((x) >> S_OFFSET_BITS9_15) & M_OFFSET_BITS9_15)
-
-#define A_MC_DDRPHY_DP18_READ_DELAY_OFFSET1_RANK_PAIR 0x44034
-#define A_MC_DDRPHY_DP18_RD_LVL_STATUS0 0x44038
-
-#define S_LEADING_EDGE_NOT_FOUND_0 0
-#define M_LEADING_EDGE_NOT_FOUND_0 0xffffU
-#define V_LEADING_EDGE_NOT_FOUND_0(x) ((x) << S_LEADING_EDGE_NOT_FOUND_0)
-#define G_LEADING_EDGE_NOT_FOUND_0(x) (((x) >> S_LEADING_EDGE_NOT_FOUND_0) & M_LEADING_EDGE_NOT_FOUND_0)
-
-#define A_MC_DDRPHY_DP18_RD_LVL_STATUS1 0x4403c
-
-#define S_LEADING_EDGE_NOT_FOUND_1 8
-#define M_LEADING_EDGE_NOT_FOUND_1 0xffU
-#define V_LEADING_EDGE_NOT_FOUND_1(x) ((x) << S_LEADING_EDGE_NOT_FOUND_1)
-#define G_LEADING_EDGE_NOT_FOUND_1(x) (((x) >> S_LEADING_EDGE_NOT_FOUND_1) & M_LEADING_EDGE_NOT_FOUND_1)
-
-#define A_MC_DDRPHY_DP18_RD_LVL_STATUS2 0x44040
-
-#define S_TRAILING_EDGE_NOT_FOUND 0
-#define M_TRAILING_EDGE_NOT_FOUND 0xffffU
-#define V_TRAILING_EDGE_NOT_FOUND(x) ((x) << S_TRAILING_EDGE_NOT_FOUND)
-#define G_TRAILING_EDGE_NOT_FOUND(x) (((x) >> S_TRAILING_EDGE_NOT_FOUND) & M_TRAILING_EDGE_NOT_FOUND)
-
-#define A_MC_DDRPHY_DP18_RD_LVL_STATUS3 0x44044
-
-#define S_TRAILING_EDGE_NOT_FOUND_16_23 8
-#define M_TRAILING_EDGE_NOT_FOUND_16_23 0xffU
-#define V_TRAILING_EDGE_NOT_FOUND_16_23(x) ((x) << S_TRAILING_EDGE_NOT_FOUND_16_23)
-#define G_TRAILING_EDGE_NOT_FOUND_16_23(x) (((x) >> S_TRAILING_EDGE_NOT_FOUND_16_23) & M_TRAILING_EDGE_NOT_FOUND_16_23)
-
-#define A_MC_DDRPHY_DP18_RD_DIA_CONFIG5 0x44048
-
-#define S_DYN_POWER_CNTL_EN 15
-#define V_DYN_POWER_CNTL_EN(x) ((x) << S_DYN_POWER_CNTL_EN)
-#define F_DYN_POWER_CNTL_EN V_DYN_POWER_CNTL_EN(1U)
-
-#define S_DYN_MCTERM_CNTL_EN 14
-#define V_DYN_MCTERM_CNTL_EN(x) ((x) << S_DYN_MCTERM_CNTL_EN)
-#define F_DYN_MCTERM_CNTL_EN V_DYN_MCTERM_CNTL_EN(1U)
-
-#define S_DYN_RX_GATE_CNTL_EN 13
-#define V_DYN_RX_GATE_CNTL_EN(x) ((x) << S_DYN_RX_GATE_CNTL_EN)
-#define F_DYN_RX_GATE_CNTL_EN V_DYN_RX_GATE_CNTL_EN(1U)
-
-#define S_CALGATE_ON 12
-#define V_CALGATE_ON(x) ((x) << S_CALGATE_ON)
-#define F_CALGATE_ON V_CALGATE_ON(1U)
-
-#define S_PER_RDCLK_UPDATE_DIS 11
-#define V_PER_RDCLK_UPDATE_DIS(x) ((x) << S_PER_RDCLK_UPDATE_DIS)
-#define F_PER_RDCLK_UPDATE_DIS V_PER_RDCLK_UPDATE_DIS(1U)
-
-#define S_DQS_ALIGN_BY_QUAD 4
-#define V_DQS_ALIGN_BY_QUAD(x) ((x) << S_DQS_ALIGN_BY_QUAD)
-#define F_DQS_ALIGN_BY_QUAD V_DQS_ALIGN_BY_QUAD(1U)
-
-#define A_MC_DDRPHY_DP18_DQS_GATE_DELAY_RP 0x4404c
-
-#define S_DQS_GATE_DELAY_N0 12
-#define M_DQS_GATE_DELAY_N0 0x7U
-#define V_DQS_GATE_DELAY_N0(x) ((x) << S_DQS_GATE_DELAY_N0)
-#define G_DQS_GATE_DELAY_N0(x) (((x) >> S_DQS_GATE_DELAY_N0) & M_DQS_GATE_DELAY_N0)
-
-#define S_DQS_GATE_DELAY_N1 8
-#define M_DQS_GATE_DELAY_N1 0x7U
-#define V_DQS_GATE_DELAY_N1(x) ((x) << S_DQS_GATE_DELAY_N1)
-#define G_DQS_GATE_DELAY_N1(x) (((x) >> S_DQS_GATE_DELAY_N1) & M_DQS_GATE_DELAY_N1)
-
-#define S_DQS_GATE_DELAY_N2 4
-#define M_DQS_GATE_DELAY_N2 0x7U
-#define V_DQS_GATE_DELAY_N2(x) ((x) << S_DQS_GATE_DELAY_N2)
-#define G_DQS_GATE_DELAY_N2(x) (((x) >> S_DQS_GATE_DELAY_N2) & M_DQS_GATE_DELAY_N2)
-
-#define S_DQS_GATE_DELAY_N3 0
-#define M_DQS_GATE_DELAY_N3 0x7U
-#define V_DQS_GATE_DELAY_N3(x) ((x) << S_DQS_GATE_DELAY_N3)
-#define G_DQS_GATE_DELAY_N3(x) (((x) >> S_DQS_GATE_DELAY_N3) & M_DQS_GATE_DELAY_N3)
-
-#define A_MC_DDRPHY_DP18_RD_STATUS0 0x44050
-
-#define S_NO_EYE_DETECTED 15
-#define V_NO_EYE_DETECTED(x) ((x) << S_NO_EYE_DETECTED)
-#define F_NO_EYE_DETECTED V_NO_EYE_DETECTED(1U)
-
-#define S_LEADING_EDGE_FOUND 14
-#define V_LEADING_EDGE_FOUND(x) ((x) << S_LEADING_EDGE_FOUND)
-#define F_LEADING_EDGE_FOUND V_LEADING_EDGE_FOUND(1U)
-
-#define S_TRAILING_EDGE_FOUND 13
-#define V_TRAILING_EDGE_FOUND(x) ((x) << S_TRAILING_EDGE_FOUND)
-#define F_TRAILING_EDGE_FOUND V_TRAILING_EDGE_FOUND(1U)
-
-#define S_INCOMPLETE_RD_CAL_N0 12
-#define V_INCOMPLETE_RD_CAL_N0(x) ((x) << S_INCOMPLETE_RD_CAL_N0)
-#define F_INCOMPLETE_RD_CAL_N0 V_INCOMPLETE_RD_CAL_N0(1U)
-
-#define S_INCOMPLETE_RD_CAL_N1 11
-#define V_INCOMPLETE_RD_CAL_N1(x) ((x) << S_INCOMPLETE_RD_CAL_N1)
-#define F_INCOMPLETE_RD_CAL_N1 V_INCOMPLETE_RD_CAL_N1(1U)
-
-#define S_INCOMPLETE_RD_CAL_N2 10
-#define V_INCOMPLETE_RD_CAL_N2(x) ((x) << S_INCOMPLETE_RD_CAL_N2)
-#define F_INCOMPLETE_RD_CAL_N2 V_INCOMPLETE_RD_CAL_N2(1U)
-
-#define S_INCOMPLETE_RD_CAL_N3 9
-#define V_INCOMPLETE_RD_CAL_N3(x) ((x) << S_INCOMPLETE_RD_CAL_N3)
-#define F_INCOMPLETE_RD_CAL_N3 V_INCOMPLETE_RD_CAL_N3(1U)
-
-#define S_COARSE_PATTERN_ERR_N0 8
-#define V_COARSE_PATTERN_ERR_N0(x) ((x) << S_COARSE_PATTERN_ERR_N0)
-#define F_COARSE_PATTERN_ERR_N0 V_COARSE_PATTERN_ERR_N0(1U)
-
-#define S_COARSE_PATTERN_ERR_N1 7
-#define V_COARSE_PATTERN_ERR_N1(x) ((x) << S_COARSE_PATTERN_ERR_N1)
-#define F_COARSE_PATTERN_ERR_N1 V_COARSE_PATTERN_ERR_N1(1U)
-
-#define S_COARSE_PATTERN_ERR_N2 6
-#define V_COARSE_PATTERN_ERR_N2(x) ((x) << S_COARSE_PATTERN_ERR_N2)
-#define F_COARSE_PATTERN_ERR_N2 V_COARSE_PATTERN_ERR_N2(1U)
-
-#define S_COARSE_PATTERN_ERR_N3 5
-#define V_COARSE_PATTERN_ERR_N3(x) ((x) << S_COARSE_PATTERN_ERR_N3)
-#define F_COARSE_PATTERN_ERR_N3 V_COARSE_PATTERN_ERR_N3(1U)
-
-#define S_EYE_CLIPPING 4
-#define V_EYE_CLIPPING(x) ((x) << S_EYE_CLIPPING)
-#define F_EYE_CLIPPING V_EYE_CLIPPING(1U)
-
-#define S_NO_DQS 3
-#define V_NO_DQS(x) ((x) << S_NO_DQS)
-#define F_NO_DQS V_NO_DQS(1U)
-
-#define S_NO_LOCK 2
-#define V_NO_LOCK(x) ((x) << S_NO_LOCK)
-#define F_NO_LOCK V_NO_LOCK(1U)
-
-#define S_DRIFT_ERROR 1
-#define V_DRIFT_ERROR(x) ((x) << S_DRIFT_ERROR)
-#define F_DRIFT_ERROR V_DRIFT_ERROR(1U)
-
-#define S_MIN_EYE 0
-#define V_MIN_EYE(x) ((x) << S_MIN_EYE)
-#define F_MIN_EYE V_MIN_EYE(1U)
-
-#define A_MC_DDRPHY_DP18_RD_ERROR_MASK0 0x44054
-
-#define S_NO_EYE_DETECTED_MASK 15
-#define V_NO_EYE_DETECTED_MASK(x) ((x) << S_NO_EYE_DETECTED_MASK)
-#define F_NO_EYE_DETECTED_MASK V_NO_EYE_DETECTED_MASK(1U)
-
-#define S_LEADING_EDGE_FOUND_MASK 14
-#define V_LEADING_EDGE_FOUND_MASK(x) ((x) << S_LEADING_EDGE_FOUND_MASK)
-#define F_LEADING_EDGE_FOUND_MASK V_LEADING_EDGE_FOUND_MASK(1U)
-
-#define S_TRAILING_EDGE_FOUND_MASK 13
-#define V_TRAILING_EDGE_FOUND_MASK(x) ((x) << S_TRAILING_EDGE_FOUND_MASK)
-#define F_TRAILING_EDGE_FOUND_MASK V_TRAILING_EDGE_FOUND_MASK(1U)
-
-#define S_INCOMPLETE_RD_CAL_N0_MASK 12
-#define V_INCOMPLETE_RD_CAL_N0_MASK(x) ((x) << S_INCOMPLETE_RD_CAL_N0_MASK)
-#define F_INCOMPLETE_RD_CAL_N0_MASK V_INCOMPLETE_RD_CAL_N0_MASK(1U)
-
-#define S_INCOMPLETE_RD_CAL_N1_MASK 11
-#define V_INCOMPLETE_RD_CAL_N1_MASK(x) ((x) << S_INCOMPLETE_RD_CAL_N1_MASK)
-#define F_INCOMPLETE_RD_CAL_N1_MASK V_INCOMPLETE_RD_CAL_N1_MASK(1U)
-
-#define S_INCOMPLETE_RD_CAL_N2_MASK 10
-#define V_INCOMPLETE_RD_CAL_N2_MASK(x) ((x) << S_INCOMPLETE_RD_CAL_N2_MASK)
-#define F_INCOMPLETE_RD_CAL_N2_MASK V_INCOMPLETE_RD_CAL_N2_MASK(1U)
-
-#define S_INCOMPLETE_RD_CAL_N3_MASK 9
-#define V_INCOMPLETE_RD_CAL_N3_MASK(x) ((x) << S_INCOMPLETE_RD_CAL_N3_MASK)
-#define F_INCOMPLETE_RD_CAL_N3_MASK V_INCOMPLETE_RD_CAL_N3_MASK(1U)
-
-#define S_COARSE_PATTERN_ERR_N0_MASK 8
-#define V_COARSE_PATTERN_ERR_N0_MASK(x) ((x) << S_COARSE_PATTERN_ERR_N0_MASK)
-#define F_COARSE_PATTERN_ERR_N0_MASK V_COARSE_PATTERN_ERR_N0_MASK(1U)
-
-#define S_COARSE_PATTERN_ERR_N1_MASK 7
-#define V_COARSE_PATTERN_ERR_N1_MASK(x) ((x) << S_COARSE_PATTERN_ERR_N1_MASK)
-#define F_COARSE_PATTERN_ERR_N1_MASK V_COARSE_PATTERN_ERR_N1_MASK(1U)
-
-#define S_COARSE_PATTERN_ERR_N2_MASK 6
-#define V_COARSE_PATTERN_ERR_N2_MASK(x) ((x) << S_COARSE_PATTERN_ERR_N2_MASK)
-#define F_COARSE_PATTERN_ERR_N2_MASK V_COARSE_PATTERN_ERR_N2_MASK(1U)
-
-#define S_COARSE_PATTERN_ERR_N3_MASK 5
-#define V_COARSE_PATTERN_ERR_N3_MASK(x) ((x) << S_COARSE_PATTERN_ERR_N3_MASK)
-#define F_COARSE_PATTERN_ERR_N3_MASK V_COARSE_PATTERN_ERR_N3_MASK(1U)
-
-#define S_EYE_CLIPPING_MASK 4
-#define V_EYE_CLIPPING_MASK(x) ((x) << S_EYE_CLIPPING_MASK)
-#define F_EYE_CLIPPING_MASK V_EYE_CLIPPING_MASK(1U)
-
-#define S_NO_DQS_MASK 3
-#define V_NO_DQS_MASK(x) ((x) << S_NO_DQS_MASK)
-#define F_NO_DQS_MASK V_NO_DQS_MASK(1U)
-
-#define S_NO_LOCK_MASK 2
-#define V_NO_LOCK_MASK(x) ((x) << S_NO_LOCK_MASK)
-#define F_NO_LOCK_MASK V_NO_LOCK_MASK(1U)
-
-#define S_DRIFT_ERROR_MASK 1
-#define V_DRIFT_ERROR_MASK(x) ((x) << S_DRIFT_ERROR_MASK)
-#define F_DRIFT_ERROR_MASK V_DRIFT_ERROR_MASK(1U)
-
-#define S_MIN_EYE_MASK 0
-#define V_MIN_EYE_MASK(x) ((x) << S_MIN_EYE_MASK)
-#define F_MIN_EYE_MASK V_MIN_EYE_MASK(1U)
-
-#define A_MC_DDRPHY_DP18_WRCLK_CNTL 0x44058
-
-#define S_PRBS_WAIT 14
-#define M_PRBS_WAIT 0x3U
-#define V_PRBS_WAIT(x) ((x) << S_PRBS_WAIT)
-#define G_PRBS_WAIT(x) (((x) >> S_PRBS_WAIT) & M_PRBS_WAIT)
-
-#define S_PRBS_SYNC_EARLY 13
-#define V_PRBS_SYNC_EARLY(x) ((x) << S_PRBS_SYNC_EARLY)
-#define F_PRBS_SYNC_EARLY V_PRBS_SYNC_EARLY(1U)
-
-#define S_RD_DELAY_EARLY 12
-#define V_RD_DELAY_EARLY(x) ((x) << S_RD_DELAY_EARLY)
-#define F_RD_DELAY_EARLY V_RD_DELAY_EARLY(1U)
-
-#define S_SS_QUAD_CAL 10
-#define V_SS_QUAD_CAL(x) ((x) << S_SS_QUAD_CAL)
-#define F_SS_QUAD_CAL V_SS_QUAD_CAL(1U)
-
-#define S_SS_QUAD 8
-#define M_SS_QUAD 0x3U
-#define V_SS_QUAD(x) ((x) << S_SS_QUAD)
-#define G_SS_QUAD(x) (((x) >> S_SS_QUAD) & M_SS_QUAD)
-
-#define S_SS_RD_DELAY 7
-#define V_SS_RD_DELAY(x) ((x) << S_SS_RD_DELAY)
-#define F_SS_RD_DELAY V_SS_RD_DELAY(1U)
-
-#define S_FORCE_HI_Z 6
-#define V_FORCE_HI_Z(x) ((x) << S_FORCE_HI_Z)
-#define F_FORCE_HI_Z V_FORCE_HI_Z(1U)
-
-#define A_MC_DDRPHY_DP18_WR_LVL_STATUS0 0x4405c
-
-#define S_CLK_LEVEL 14
-#define M_CLK_LEVEL 0x3U
-#define V_CLK_LEVEL(x) ((x) << S_CLK_LEVEL)
-#define G_CLK_LEVEL(x) (((x) >> S_CLK_LEVEL) & M_CLK_LEVEL)
-
-#define S_FINE_STEPPING 13
-#define V_FINE_STEPPING(x) ((x) << S_FINE_STEPPING)
-#define F_FINE_STEPPING V_FINE_STEPPING(1U)
-
-#define S_DONE 12
-#define V_DONE(x) ((x) << S_DONE)
-#define F_DONE V_DONE(1U)
-
-#define S_WL_ERR_CLK16_ST 11
-#define V_WL_ERR_CLK16_ST(x) ((x) << S_WL_ERR_CLK16_ST)
-#define F_WL_ERR_CLK16_ST V_WL_ERR_CLK16_ST(1U)
-
-#define S_WL_ERR_CLK18_ST 10
-#define V_WL_ERR_CLK18_ST(x) ((x) << S_WL_ERR_CLK18_ST)
-#define F_WL_ERR_CLK18_ST V_WL_ERR_CLK18_ST(1U)
-
-#define S_WL_ERR_CLK20_ST 9
-#define V_WL_ERR_CLK20_ST(x) ((x) << S_WL_ERR_CLK20_ST)
-#define F_WL_ERR_CLK20_ST V_WL_ERR_CLK20_ST(1U)
-
-#define S_WL_ERR_CLK22_ST 8
-#define V_WL_ERR_CLK22_ST(x) ((x) << S_WL_ERR_CLK22_ST)
-#define F_WL_ERR_CLK22_ST V_WL_ERR_CLK22_ST(1U)
-
-#define S_ZERO_DETECTED 7
-#define V_ZERO_DETECTED(x) ((x) << S_ZERO_DETECTED)
-#define F_ZERO_DETECTED V_ZERO_DETECTED(1U)
-
-#define S_WR_LVL_DONE 12
-#define V_WR_LVL_DONE(x) ((x) << S_WR_LVL_DONE)
-#define F_WR_LVL_DONE V_WR_LVL_DONE(1U)
-
-#define A_MC_DDRPHY_DP18_WR_CNTR_STATUS0 0x44060
-
-#define S_BIT_CENTERED 11
-#define M_BIT_CENTERED 0x1fU
-#define V_BIT_CENTERED(x) ((x) << S_BIT_CENTERED)
-#define G_BIT_CENTERED(x) (((x) >> S_BIT_CENTERED) & M_BIT_CENTERED)
-
-#define S_SMALL_STEP_LEFT 10
-#define V_SMALL_STEP_LEFT(x) ((x) << S_SMALL_STEP_LEFT)
-#define F_SMALL_STEP_LEFT V_SMALL_STEP_LEFT(1U)
-
-#define S_BIG_STEP_RIGHT 9
-#define V_BIG_STEP_RIGHT(x) ((x) << S_BIG_STEP_RIGHT)
-#define F_BIG_STEP_RIGHT V_BIG_STEP_RIGHT(1U)
-
-#define S_MATCH_STEP_RIGHT 8
-#define V_MATCH_STEP_RIGHT(x) ((x) << S_MATCH_STEP_RIGHT)
-#define F_MATCH_STEP_RIGHT V_MATCH_STEP_RIGHT(1U)
-
-#define S_JUMP_BACK_RIGHT 7
-#define V_JUMP_BACK_RIGHT(x) ((x) << S_JUMP_BACK_RIGHT)
-#define F_JUMP_BACK_RIGHT V_JUMP_BACK_RIGHT(1U)
-
-#define S_SMALL_STEP_RIGHT 6
-#define V_SMALL_STEP_RIGHT(x) ((x) << S_SMALL_STEP_RIGHT)
-#define F_SMALL_STEP_RIGHT V_SMALL_STEP_RIGHT(1U)
-
-#define S_DDONE 5
-#define V_DDONE(x) ((x) << S_DDONE)
-#define F_DDONE V_DDONE(1U)
-
-#define S_WR_CNTR_DONE 5
-#define V_WR_CNTR_DONE(x) ((x) << S_WR_CNTR_DONE)
-#define F_WR_CNTR_DONE V_WR_CNTR_DONE(1U)
-
-#define A_MC_DDRPHY_DP18_WR_CNTR_STATUS1 0x44064
-
-#define S_FW_LEFT_SIDE 5
-#define M_FW_LEFT_SIDE 0x7ffU
-#define V_FW_LEFT_SIDE(x) ((x) << S_FW_LEFT_SIDE)
-#define G_FW_LEFT_SIDE(x) (((x) >> S_FW_LEFT_SIDE) & M_FW_LEFT_SIDE)
-
-#define A_MC_DDRPHY_DP18_WR_CNTR_STATUS2 0x44068
-
-#define S_FW_RIGHT_SIDE 5
-#define M_FW_RIGHT_SIDE 0x7ffU
-#define V_FW_RIGHT_SIDE(x) ((x) << S_FW_RIGHT_SIDE)
-#define G_FW_RIGHT_SIDE(x) (((x) >> S_FW_RIGHT_SIDE) & M_FW_RIGHT_SIDE)
-
-#define A_MC_DDRPHY_DP18_WR_ERROR0 0x4406c
-
-#define S_WL_ERR_CLK16 15
-#define V_WL_ERR_CLK16(x) ((x) << S_WL_ERR_CLK16)
-#define F_WL_ERR_CLK16 V_WL_ERR_CLK16(1U)
-
-#define S_WL_ERR_CLK18 14
-#define V_WL_ERR_CLK18(x) ((x) << S_WL_ERR_CLK18)
-#define F_WL_ERR_CLK18 V_WL_ERR_CLK18(1U)
-
-#define S_WL_ERR_CLK20 13
-#define V_WL_ERR_CLK20(x) ((x) << S_WL_ERR_CLK20)
-#define F_WL_ERR_CLK20 V_WL_ERR_CLK20(1U)
-
-#define S_WL_ERR_CLK22 12
-#define V_WL_ERR_CLK22(x) ((x) << S_WL_ERR_CLK22)
-#define F_WL_ERR_CLK22 V_WL_ERR_CLK22(1U)
-
-#define S_VALID_NS_BIG_L 7
-#define V_VALID_NS_BIG_L(x) ((x) << S_VALID_NS_BIG_L)
-#define F_VALID_NS_BIG_L V_VALID_NS_BIG_L(1U)
-
-#define S_INVALID_NS_SMALL_L 6
-#define V_INVALID_NS_SMALL_L(x) ((x) << S_INVALID_NS_SMALL_L)
-#define F_INVALID_NS_SMALL_L V_INVALID_NS_SMALL_L(1U)
-
-#define S_VALID_NS_BIG_R 5
-#define V_VALID_NS_BIG_R(x) ((x) << S_VALID_NS_BIG_R)
-#define F_VALID_NS_BIG_R V_VALID_NS_BIG_R(1U)
-
-#define S_INVALID_NS_BIG_R 4
-#define V_INVALID_NS_BIG_R(x) ((x) << S_INVALID_NS_BIG_R)
-#define F_INVALID_NS_BIG_R V_INVALID_NS_BIG_R(1U)
-
-#define S_VALID_NS_JUMP_BACK 3
-#define V_VALID_NS_JUMP_BACK(x) ((x) << S_VALID_NS_JUMP_BACK)
-#define F_VALID_NS_JUMP_BACK V_VALID_NS_JUMP_BACK(1U)
-
-#define S_INVALID_NS_SMALL_R 2
-#define V_INVALID_NS_SMALL_R(x) ((x) << S_INVALID_NS_SMALL_R)
-#define F_INVALID_NS_SMALL_R V_INVALID_NS_SMALL_R(1U)
-
-#define S_OFFSET_ERR 1
-#define V_OFFSET_ERR(x) ((x) << S_OFFSET_ERR)
-#define F_OFFSET_ERR V_OFFSET_ERR(1U)
-
-#define A_MC_DDRPHY_DP18_WR_ERROR_MASK0 0x44070
-
-#define S_WL_ERR_CLK16_MASK 15
-#define V_WL_ERR_CLK16_MASK(x) ((x) << S_WL_ERR_CLK16_MASK)
-#define F_WL_ERR_CLK16_MASK V_WL_ERR_CLK16_MASK(1U)
-
-#define S_WL_ERR_CLK18_MASK 14
-#define V_WL_ERR_CLK18_MASK(x) ((x) << S_WL_ERR_CLK18_MASK)
-#define F_WL_ERR_CLK18_MASK V_WL_ERR_CLK18_MASK(1U)
-
-#define S_WL_ERR_CLK20_MASK 13
-#define V_WL_ERR_CLK20_MASK(x) ((x) << S_WL_ERR_CLK20_MASK)
-#define F_WL_ERR_CLK20_MASK V_WL_ERR_CLK20_MASK(1U)
-
-#define S_WR_ERR_CLK22_MASK 12
-#define V_WR_ERR_CLK22_MASK(x) ((x) << S_WR_ERR_CLK22_MASK)
-#define F_WR_ERR_CLK22_MASK V_WR_ERR_CLK22_MASK(1U)
-
-#define S_VALID_NS_BIG_L_MASK 7
-#define V_VALID_NS_BIG_L_MASK(x) ((x) << S_VALID_NS_BIG_L_MASK)
-#define F_VALID_NS_BIG_L_MASK V_VALID_NS_BIG_L_MASK(1U)
-
-#define S_INVALID_NS_SMALL_L_MASK 6
-#define V_INVALID_NS_SMALL_L_MASK(x) ((x) << S_INVALID_NS_SMALL_L_MASK)
-#define F_INVALID_NS_SMALL_L_MASK V_INVALID_NS_SMALL_L_MASK(1U)
-
-#define S_VALID_NS_BIG_R_MASK 5
-#define V_VALID_NS_BIG_R_MASK(x) ((x) << S_VALID_NS_BIG_R_MASK)
-#define F_VALID_NS_BIG_R_MASK V_VALID_NS_BIG_R_MASK(1U)
-
-#define S_INVALID_NS_BIG_R_MASK 4
-#define V_INVALID_NS_BIG_R_MASK(x) ((x) << S_INVALID_NS_BIG_R_MASK)
-#define F_INVALID_NS_BIG_R_MASK V_INVALID_NS_BIG_R_MASK(1U)
-
-#define S_VALID_NS_JUMP_BACK_MASK 3
-#define V_VALID_NS_JUMP_BACK_MASK(x) ((x) << S_VALID_NS_JUMP_BACK_MASK)
-#define F_VALID_NS_JUMP_BACK_MASK V_VALID_NS_JUMP_BACK_MASK(1U)
-
-#define S_INVALID_NS_SMALL_R_MASK 2
-#define V_INVALID_NS_SMALL_R_MASK(x) ((x) << S_INVALID_NS_SMALL_R_MASK)
-#define F_INVALID_NS_SMALL_R_MASK V_INVALID_NS_SMALL_R_MASK(1U)
-
-#define S_OFFSET_ERR_MASK 1
-#define V_OFFSET_ERR_MASK(x) ((x) << S_OFFSET_ERR_MASK)
-#define F_OFFSET_ERR_MASK V_OFFSET_ERR_MASK(1U)
-
-#define S_DQS_REC_LOW_POWER 11
-#define V_DQS_REC_LOW_POWER(x) ((x) << S_DQS_REC_LOW_POWER)
-#define F_DQS_REC_LOW_POWER V_DQS_REC_LOW_POWER(1U)
-
-#define S_DQ_REC_LOW_POWER 10
-#define V_DQ_REC_LOW_POWER(x) ((x) << S_DQ_REC_LOW_POWER)
-#define F_DQ_REC_LOW_POWER V_DQ_REC_LOW_POWER(1U)
-
-#define S_ADVANCE_PR_VALUE 0
-#define V_ADVANCE_PR_VALUE(x) ((x) << S_ADVANCE_PR_VALUE)
-#define F_ADVANCE_PR_VALUE V_ADVANCE_PR_VALUE(1U)
-
-#define A_MC_DDRPHY_DP18_DFT_WRAP_STATUS 0x44074
-
-#define S_CHECKER_RESET 14
-#define V_CHECKER_RESET(x) ((x) << S_CHECKER_RESET)
-#define F_CHECKER_RESET V_CHECKER_RESET(1U)
-
-#define S_DP18_DFT_SYNC 6
-#define M_DP18_DFT_SYNC 0x3fU
-#define V_DP18_DFT_SYNC(x) ((x) << S_DP18_DFT_SYNC)
-#define G_DP18_DFT_SYNC(x) (((x) >> S_DP18_DFT_SYNC) & M_DP18_DFT_SYNC)
-
-#define S_ERROR 0
-#define M_ERROR 0x3fU
-#define V_ERROR(x) ((x) << S_ERROR)
-#define G_ERROR(x) (((x) >> S_ERROR) & M_ERROR)
-
-#define S_CHECKER_ENABLE 15
-#define V_CHECKER_ENABLE(x) ((x) << S_CHECKER_ENABLE)
-#define F_CHECKER_ENABLE V_CHECKER_ENABLE(1U)
-
-#define S_DP18_DFT_ERROR 0
-#define M_DP18_DFT_ERROR 0x3fU
-#define V_DP18_DFT_ERROR(x) ((x) << S_DP18_DFT_ERROR)
-#define G_DP18_DFT_ERROR(x) (((x) >> S_DP18_DFT_ERROR) & M_DP18_DFT_ERROR)
-
-#define A_MC_DDRPHY_DP18_RD_DIA_CONFIG0 0x44078
-
-#define S_SYSCLK_RDCLK_OFFSET 8
-#define M_SYSCLK_RDCLK_OFFSET 0x7fU
-#define V_SYSCLK_RDCLK_OFFSET(x) ((x) << S_SYSCLK_RDCLK_OFFSET)
-#define G_SYSCLK_RDCLK_OFFSET(x) (((x) >> S_SYSCLK_RDCLK_OFFSET) & M_SYSCLK_RDCLK_OFFSET)
-
-#define S_SYSCLK_DQSCLK_OFFSET 0
-#define M_SYSCLK_DQSCLK_OFFSET 0x7fU
-#define V_SYSCLK_DQSCLK_OFFSET(x) ((x) << S_SYSCLK_DQSCLK_OFFSET)
-#define G_SYSCLK_DQSCLK_OFFSET(x) (((x) >> S_SYSCLK_DQSCLK_OFFSET) & M_SYSCLK_DQSCLK_OFFSET)
-
-#define S_T6_SYSCLK_DQSCLK_OFFSET 8
-#define M_T6_SYSCLK_DQSCLK_OFFSET 0x7fU
-#define V_T6_SYSCLK_DQSCLK_OFFSET(x) ((x) << S_T6_SYSCLK_DQSCLK_OFFSET)
-#define G_T6_SYSCLK_DQSCLK_OFFSET(x) (((x) >> S_T6_SYSCLK_DQSCLK_OFFSET) & M_T6_SYSCLK_DQSCLK_OFFSET)
-
-#define S_T6_SYSCLK_RDCLK_OFFSET 0
-#define M_T6_SYSCLK_RDCLK_OFFSET 0x7fU
-#define V_T6_SYSCLK_RDCLK_OFFSET(x) ((x) << S_T6_SYSCLK_RDCLK_OFFSET)
-#define G_T6_SYSCLK_RDCLK_OFFSET(x) (((x) >> S_T6_SYSCLK_RDCLK_OFFSET) & M_T6_SYSCLK_RDCLK_OFFSET)
-
-#define A_MC_DDRPHY_DP18_WRCLK_AUX_CNTL 0x4407c
-#define A_MC_DDRPHY_DP18_DQSCLK_PR0_RANK_PAIR 0x440c0
-
-#define S_DQSCLK_ROT_CLK_N0_N2 8
-#define M_DQSCLK_ROT_CLK_N0_N2 0x7fU
-#define V_DQSCLK_ROT_CLK_N0_N2(x) ((x) << S_DQSCLK_ROT_CLK_N0_N2)
-#define G_DQSCLK_ROT_CLK_N0_N2(x) (((x) >> S_DQSCLK_ROT_CLK_N0_N2) & M_DQSCLK_ROT_CLK_N0_N2)
-
-#define S_DQSCLK_ROT_CLK_N1_N3 0
-#define M_DQSCLK_ROT_CLK_N1_N3 0x7fU
-#define V_DQSCLK_ROT_CLK_N1_N3(x) ((x) << S_DQSCLK_ROT_CLK_N1_N3)
-#define G_DQSCLK_ROT_CLK_N1_N3(x) (((x) >> S_DQSCLK_ROT_CLK_N1_N3) & M_DQSCLK_ROT_CLK_N1_N3)
-
-#define A_MC_DDRPHY_DP18_DQSCLK_PR1_RANK_PAIR 0x440c4
-#define A_MC_DDRPHY_DP18_PATTERN_POS_0 0x440c8
-
-#define S_MEMINTD00_POS 14
-#define M_MEMINTD00_POS 0x3U
-#define V_MEMINTD00_POS(x) ((x) << S_MEMINTD00_POS)
-#define G_MEMINTD00_POS(x) (((x) >> S_MEMINTD00_POS) & M_MEMINTD00_POS)
-
-#define S_MEMINTD01_PO 12
-#define M_MEMINTD01_PO 0x3U
-#define V_MEMINTD01_PO(x) ((x) << S_MEMINTD01_PO)
-#define G_MEMINTD01_PO(x) (((x) >> S_MEMINTD01_PO) & M_MEMINTD01_PO)
-
-#define S_MEMINTD02_POS 10
-#define M_MEMINTD02_POS 0x3U
-#define V_MEMINTD02_POS(x) ((x) << S_MEMINTD02_POS)
-#define G_MEMINTD02_POS(x) (((x) >> S_MEMINTD02_POS) & M_MEMINTD02_POS)
-
-#define S_MEMINTD03_POS 8
-#define M_MEMINTD03_POS 0x3U
-#define V_MEMINTD03_POS(x) ((x) << S_MEMINTD03_POS)
-#define G_MEMINTD03_POS(x) (((x) >> S_MEMINTD03_POS) & M_MEMINTD03_POS)
-
-#define S_MEMINTD04_POS 6
-#define M_MEMINTD04_POS 0x3U
-#define V_MEMINTD04_POS(x) ((x) << S_MEMINTD04_POS)
-#define G_MEMINTD04_POS(x) (((x) >> S_MEMINTD04_POS) & M_MEMINTD04_POS)
-
-#define S_MEMINTD05_POS 4
-#define M_MEMINTD05_POS 0x3U
-#define V_MEMINTD05_POS(x) ((x) << S_MEMINTD05_POS)
-#define G_MEMINTD05_POS(x) (((x) >> S_MEMINTD05_POS) & M_MEMINTD05_POS)
-
-#define S_MEMINTD06_POS 2
-#define M_MEMINTD06_POS 0x3U
-#define V_MEMINTD06_POS(x) ((x) << S_MEMINTD06_POS)
-#define G_MEMINTD06_POS(x) (((x) >> S_MEMINTD06_POS) & M_MEMINTD06_POS)
-
-#define S_MEMINTD07_POS 0
-#define M_MEMINTD07_POS 0x3U
-#define V_MEMINTD07_POS(x) ((x) << S_MEMINTD07_POS)
-#define G_MEMINTD07_POS(x) (((x) >> S_MEMINTD07_POS) & M_MEMINTD07_POS)
-
-#define A_MC_DDRPHY_DP18_PATTERN_POS_1 0x440cc
-
-#define S_MEMINTD08_POS 14
-#define M_MEMINTD08_POS 0x3U
-#define V_MEMINTD08_POS(x) ((x) << S_MEMINTD08_POS)
-#define G_MEMINTD08_POS(x) (((x) >> S_MEMINTD08_POS) & M_MEMINTD08_POS)
-
-#define S_MEMINTD09_POS 12
-#define M_MEMINTD09_POS 0x3U
-#define V_MEMINTD09_POS(x) ((x) << S_MEMINTD09_POS)
-#define G_MEMINTD09_POS(x) (((x) >> S_MEMINTD09_POS) & M_MEMINTD09_POS)
-
-#define S_MEMINTD10_POS 10
-#define M_MEMINTD10_POS 0x3U
-#define V_MEMINTD10_POS(x) ((x) << S_MEMINTD10_POS)
-#define G_MEMINTD10_POS(x) (((x) >> S_MEMINTD10_POS) & M_MEMINTD10_POS)
-
-#define S_MEMINTD11_POS 8
-#define M_MEMINTD11_POS 0x3U
-#define V_MEMINTD11_POS(x) ((x) << S_MEMINTD11_POS)
-#define G_MEMINTD11_POS(x) (((x) >> S_MEMINTD11_POS) & M_MEMINTD11_POS)
-
-#define S_MEMINTD12_POS 6
-#define M_MEMINTD12_POS 0x3U
-#define V_MEMINTD12_POS(x) ((x) << S_MEMINTD12_POS)
-#define G_MEMINTD12_POS(x) (((x) >> S_MEMINTD12_POS) & M_MEMINTD12_POS)
-
-#define S_MEMINTD13_POS 4
-#define M_MEMINTD13_POS 0x3U
-#define V_MEMINTD13_POS(x) ((x) << S_MEMINTD13_POS)
-#define G_MEMINTD13_POS(x) (((x) >> S_MEMINTD13_POS) & M_MEMINTD13_POS)
-
-#define S_MEMINTD14_POS 2
-#define M_MEMINTD14_POS 0x3U
-#define V_MEMINTD14_POS(x) ((x) << S_MEMINTD14_POS)
-#define G_MEMINTD14_POS(x) (((x) >> S_MEMINTD14_POS) & M_MEMINTD14_POS)
-
-#define S_MEMINTD15_POS 0
-#define M_MEMINTD15_POS 0x3U
-#define V_MEMINTD15_POS(x) ((x) << S_MEMINTD15_POS)
-#define G_MEMINTD15_POS(x) (((x) >> S_MEMINTD15_POS) & M_MEMINTD15_POS)
-
-#define A_MC_DDRPHY_DP18_PATTERN_POS_2 0x440d0
-
-#define S_MEMINTD16_POS 14
-#define M_MEMINTD16_POS 0x3U
-#define V_MEMINTD16_POS(x) ((x) << S_MEMINTD16_POS)
-#define G_MEMINTD16_POS(x) (((x) >> S_MEMINTD16_POS) & M_MEMINTD16_POS)
-
-#define S_MEMINTD17_POS 12
-#define M_MEMINTD17_POS 0x3U
-#define V_MEMINTD17_POS(x) ((x) << S_MEMINTD17_POS)
-#define G_MEMINTD17_POS(x) (((x) >> S_MEMINTD17_POS) & M_MEMINTD17_POS)
-
-#define S_MEMINTD18_POS 10
-#define M_MEMINTD18_POS 0x3U
-#define V_MEMINTD18_POS(x) ((x) << S_MEMINTD18_POS)
-#define G_MEMINTD18_POS(x) (((x) >> S_MEMINTD18_POS) & M_MEMINTD18_POS)
-
-#define S_MEMINTD19_POS 8
-#define M_MEMINTD19_POS 0x3U
-#define V_MEMINTD19_POS(x) ((x) << S_MEMINTD19_POS)
-#define G_MEMINTD19_POS(x) (((x) >> S_MEMINTD19_POS) & M_MEMINTD19_POS)
-
-#define S_MEMINTD20_POS 6
-#define M_MEMINTD20_POS 0x3U
-#define V_MEMINTD20_POS(x) ((x) << S_MEMINTD20_POS)
-#define G_MEMINTD20_POS(x) (((x) >> S_MEMINTD20_POS) & M_MEMINTD20_POS)
-
-#define S_MEMINTD21_POS 4
-#define M_MEMINTD21_POS 0x3U
-#define V_MEMINTD21_POS(x) ((x) << S_MEMINTD21_POS)
-#define G_MEMINTD21_POS(x) (((x) >> S_MEMINTD21_POS) & M_MEMINTD21_POS)
-
-#define S_MEMINTD22_POS 2
-#define M_MEMINTD22_POS 0x3U
-#define V_MEMINTD22_POS(x) ((x) << S_MEMINTD22_POS)
-#define G_MEMINTD22_POS(x) (((x) >> S_MEMINTD22_POS) & M_MEMINTD22_POS)
-
-#define S_MEMINTD23_POS 0
-#define M_MEMINTD23_POS 0x3U
-#define V_MEMINTD23_POS(x) ((x) << S_MEMINTD23_POS)
-#define G_MEMINTD23_POS(x) (((x) >> S_MEMINTD23_POS) & M_MEMINTD23_POS)
-
-#define A_MC_DDRPHY_DP18_RD_DIA_CONFIG1 0x440d4
-
-#define S_DQS_ALIGN_SM 11
-#define M_DQS_ALIGN_SM 0x1fU
-#define V_DQS_ALIGN_SM(x) ((x) << S_DQS_ALIGN_SM)
-#define G_DQS_ALIGN_SM(x) (((x) >> S_DQS_ALIGN_SM) & M_DQS_ALIGN_SM)
-
-#define S_DQS_ALIGN_CNTR 7
-#define M_DQS_ALIGN_CNTR 0xfU
-#define V_DQS_ALIGN_CNTR(x) ((x) << S_DQS_ALIGN_CNTR)
-#define G_DQS_ALIGN_CNTR(x) (((x) >> S_DQS_ALIGN_CNTR) & M_DQS_ALIGN_CNTR)
-
-#define S_ITERATION_CNTR 6
-#define V_ITERATION_CNTR(x) ((x) << S_ITERATION_CNTR)
-#define F_ITERATION_CNTR V_ITERATION_CNTR(1U)
-
-#define S_DQS_ALIGN_ITER_CNTR 0
-#define M_DQS_ALIGN_ITER_CNTR 0x3fU
-#define V_DQS_ALIGN_ITER_CNTR(x) ((x) << S_DQS_ALIGN_ITER_CNTR)
-#define G_DQS_ALIGN_ITER_CNTR(x) (((x) >> S_DQS_ALIGN_ITER_CNTR) & M_DQS_ALIGN_ITER_CNTR)
-
-#define A_MC_DDRPHY_DP18_RD_DIA_CONFIG2 0x440d8
-
-#define S_CALIBRATE_BIT 13
-#define M_CALIBRATE_BIT 0x7U
-#define V_CALIBRATE_BIT(x) ((x) << S_CALIBRATE_BIT)
-#define G_CALIBRATE_BIT(x) (((x) >> S_CALIBRATE_BIT) & M_CALIBRATE_BIT)
-
-#define S_DQS_ALIGN_QUAD 11
-#define M_DQS_ALIGN_QUAD 0x3U
-#define V_DQS_ALIGN_QUAD(x) ((x) << S_DQS_ALIGN_QUAD)
-#define G_DQS_ALIGN_QUAD(x) (((x) >> S_DQS_ALIGN_QUAD) & M_DQS_ALIGN_QUAD)
-
-#define S_DQS_QUAD_CONFIG 8
-#define M_DQS_QUAD_CONFIG 0x7U
-#define V_DQS_QUAD_CONFIG(x) ((x) << S_DQS_QUAD_CONFIG)
-#define G_DQS_QUAD_CONFIG(x) (((x) >> S_DQS_QUAD_CONFIG) & M_DQS_QUAD_CONFIG)
-
-#define S_OPERATE_MODE 4
-#define M_OPERATE_MODE 0xfU
-#define V_OPERATE_MODE(x) ((x) << S_OPERATE_MODE)
-#define G_OPERATE_MODE(x) (((x) >> S_OPERATE_MODE) & M_OPERATE_MODE)
-
-#define S_EN_DQS_OFFSET 3
-#define V_EN_DQS_OFFSET(x) ((x) << S_EN_DQS_OFFSET)
-#define F_EN_DQS_OFFSET V_EN_DQS_OFFSET(1U)
-
-#define S_DQS_ALIGN_JITTER 2
-#define V_DQS_ALIGN_JITTER(x) ((x) << S_DQS_ALIGN_JITTER)
-#define F_DQS_ALIGN_JITTER V_DQS_ALIGN_JITTER(1U)
-
-#define S_DIS_CLK_GATE 1
-#define V_DIS_CLK_GATE(x) ((x) << S_DIS_CLK_GATE)
-#define F_DIS_CLK_GATE V_DIS_CLK_GATE(1U)
-
-#define S_MAX_DQS_ITER 0
-#define V_MAX_DQS_ITER(x) ((x) << S_MAX_DQS_ITER)
-#define F_MAX_DQS_ITER V_MAX_DQS_ITER(1U)
-
-#define A_MC_DDRPHY_DP18_DQSCLK_OFFSET 0x440dc
-
-#define S_DQS_OFFSET 8
-#define M_DQS_OFFSET 0x7fU
-#define V_DQS_OFFSET(x) ((x) << S_DQS_OFFSET)
-#define G_DQS_OFFSET(x) (((x) >> S_DQS_OFFSET) & M_DQS_OFFSET)
-
-#define A_MC_DDRPHY_DP18_WR_DELAY_VALUE_0_RP 0x440e0
-
-#define S_WR_DELAY 6
-#define M_WR_DELAY 0x3ffU
-#define V_WR_DELAY(x) ((x) << S_WR_DELAY)
-#define G_WR_DELAY(x) (((x) >> S_WR_DELAY) & M_WR_DELAY)
-
-#define A_MC_DDRPHY_DP18_WR_DELAY_VALUE_1_RP 0x440e4
-#define A_MC_DDRPHY_DP18_WR_DELAY_VALUE_2_RP 0x440e8
-#define A_MC_DDRPHY_DP18_WR_DELAY_VALUE_3_RP 0x440ec
-#define A_MC_DDRPHY_DP18_WR_DELAY_VALUE_4_RP 0x440f0
-#define A_MC_DDRPHY_DP18_WR_DELAY_VALUE_5_RP 0x440f4
-#define A_MC_DDRPHY_DP18_WR_DELAY_VALUE_6_RP 0x440f8
-#define A_MC_DDRPHY_DP18_WR_DELAY_VALUE_7_RP 0x440fc
-#define A_MC_DDRPHY_DP18_WR_DELAY_VALUE_8_RP 0x44100
-#define A_MC_DDRPHY_DP18_WR_DELAY_VALUE_9_RP 0x44104
-#define A_MC_DDRPHY_DP18_WR_DELAY_VALUE_10_RP 0x44108
-#define A_MC_DDRPHY_DP18_WR_DELAY_VALUE_11_RP 0x4410c
-#define A_MC_DDRPHY_DP18_WR_DELAY_VALUE_12_RP 0x44110
-#define A_MC_DDRPHY_DP18_WR_DELAY_VALUE_13_RP 0x44114
-#define A_MC_DDRPHY_DP18_WR_DELAY_VALUE_14_RP 0x44118
-#define A_MC_DDRPHY_DP18_WR_DELAY_VALUE_15_RP 0x4411c
-#define A_MC_DDRPHY_DP18_WR_DELAY_VALUE_16_RP 0x44120
-#define A_MC_DDRPHY_DP18_WR_DELAY_VALUE_17_RP 0x44124
-#define A_MC_DDRPHY_DP18_WR_DELAY_VALUE_18_RP 0x44128
-#define A_MC_DDRPHY_DP18_WR_DELAY_VALUE_19_RP 0x4412c
-#define A_MC_DDRPHY_DP18_WR_DELAY_VALUE_20_RP 0x44130
-#define A_MC_DDRPHY_DP18_WR_DELAY_VALUE_21_RP 0x44134
-#define A_MC_DDRPHY_DP18_WR_DELAY_VALUE_22_RP 0x44138
-#define A_MC_DDRPHY_DP18_WR_DELAY_VALUE_23_RP 0x4413c
-#define A_MC_DDRPHY_DP18_READ_DELAY0_RANK_PAIR 0x44140
-
-#define S_RD_DELAY_BITS0_6 9
-#define M_RD_DELAY_BITS0_6 0x7fU
-#define V_RD_DELAY_BITS0_6(x) ((x) << S_RD_DELAY_BITS0_6)
-#define G_RD_DELAY_BITS0_6(x) (((x) >> S_RD_DELAY_BITS0_6) & M_RD_DELAY_BITS0_6)
-
-#define S_RD_DELAY_BITS8_14 1
-#define M_RD_DELAY_BITS8_14 0x7fU
-#define V_RD_DELAY_BITS8_14(x) ((x) << S_RD_DELAY_BITS8_14)
-#define G_RD_DELAY_BITS8_14(x) (((x) >> S_RD_DELAY_BITS8_14) & M_RD_DELAY_BITS8_14)
-
-#define A_MC_DDRPHY_DP18_READ_DELAY1_RANK_PAIR 0x44144
-#define A_MC_DDRPHY_DP18_READ_DELAY2_RANK_PAIR 0x44148
-#define A_MC_DDRPHY_DP18_READ_DELAY3_RANK_PAIR 0x4414c
-#define A_MC_DDRPHY_DP18_READ_DELAY4_RANK_PAIR 0x44150
-#define A_MC_DDRPHY_DP18_READ_DELAY5_RANK_PAIR 0x44154
-#define A_MC_DDRPHY_DP18_READ_DELAY6_RANK_PAIR 0x44158
-#define A_MC_DDRPHY_DP18_READ_DELAY7_RANK_PAIR 0x4415c
-#define A_MC_DDRPHY_DP18_READ_DELAY8_RANK_PAIR 0x44160
-#define A_MC_DDRPHY_DP18_READ_DELAY9_RANK_PAIR 0x44164
-#define A_MC_DDRPHY_DP18_READ_DELAY10_RANK_PAIR 0x44168
-#define A_MC_DDRPHY_DP18_READ_DELAY11_RANK_PAIR 0x4416c
-#define A_MC_DDRPHY_DP18_INITIAL_DQS_ALIGN0_RANK_PAIR 0x44170
-
-#define S_INITIAL_DQS_ROT_N0_N2 8
-#define M_INITIAL_DQS_ROT_N0_N2 0x7fU
-#define V_INITIAL_DQS_ROT_N0_N2(x) ((x) << S_INITIAL_DQS_ROT_N0_N2)
-#define G_INITIAL_DQS_ROT_N0_N2(x) (((x) >> S_INITIAL_DQS_ROT_N0_N2) & M_INITIAL_DQS_ROT_N0_N2)
-
-#define S_INITIAL_DQS_ROT_N1_N3 0
-#define M_INITIAL_DQS_ROT_N1_N3 0x7fU
-#define V_INITIAL_DQS_ROT_N1_N3(x) ((x) << S_INITIAL_DQS_ROT_N1_N3)
-#define G_INITIAL_DQS_ROT_N1_N3(x) (((x) >> S_INITIAL_DQS_ROT_N1_N3) & M_INITIAL_DQS_ROT_N1_N3)
-
-#define A_MC_DDRPHY_DP18_INITIAL_DQS_ALIGN1_RANK_PAIR 0x44174
-#define A_MC_DDRPHY_DP18_WRCLK_STATUS 0x44178
-
-#define S_WRCLK_CALIB_DONE 15
-#define V_WRCLK_CALIB_DONE(x) ((x) << S_WRCLK_CALIB_DONE)
-#define F_WRCLK_CALIB_DONE V_WRCLK_CALIB_DONE(1U)
-
-#define S_VALUE_UPDATED 14
-#define V_VALUE_UPDATED(x) ((x) << S_VALUE_UPDATED)
-#define F_VALUE_UPDATED V_VALUE_UPDATED(1U)
-
-#define S_FAIL_PASS_V 13
-#define V_FAIL_PASS_V(x) ((x) << S_FAIL_PASS_V)
-#define F_FAIL_PASS_V V_FAIL_PASS_V(1U)
-
-#define S_PASS_FAIL_V 12
-#define V_PASS_FAIL_V(x) ((x) << S_PASS_FAIL_V)
-#define F_PASS_FAIL_V V_PASS_FAIL_V(1U)
-
-#define S_FP_PF_EDGE_NF 11
-#define V_FP_PF_EDGE_NF(x) ((x) << S_FP_PF_EDGE_NF)
-#define F_FP_PF_EDGE_NF V_FP_PF_EDGE_NF(1U)
-
-#define S_NON_SYMETRIC 10
-#define V_NON_SYMETRIC(x) ((x) << S_NON_SYMETRIC)
-#define F_NON_SYMETRIC V_NON_SYMETRIC(1U)
-
-#define S_FULL_RANGE 8
-#define V_FULL_RANGE(x) ((x) << S_FULL_RANGE)
-#define F_FULL_RANGE V_FULL_RANGE(1U)
-
-#define S_QUAD3_EDGES 7
-#define V_QUAD3_EDGES(x) ((x) << S_QUAD3_EDGES)
-#define F_QUAD3_EDGES V_QUAD3_EDGES(1U)
-
-#define S_QUAD2_EDGES 6
-#define V_QUAD2_EDGES(x) ((x) << S_QUAD2_EDGES)
-#define F_QUAD2_EDGES V_QUAD2_EDGES(1U)
-
-#define S_QUAD1_EDGES 5
-#define V_QUAD1_EDGES(x) ((x) << S_QUAD1_EDGES)
-#define F_QUAD1_EDGES V_QUAD1_EDGES(1U)
-
-#define S_QUAD0_EDGES 4
-#define V_QUAD0_EDGES(x) ((x) << S_QUAD0_EDGES)
-#define F_QUAD0_EDGES V_QUAD0_EDGES(1U)
-
-#define S_QUAD3_CAVEAT 3
-#define V_QUAD3_CAVEAT(x) ((x) << S_QUAD3_CAVEAT)
-#define F_QUAD3_CAVEAT V_QUAD3_CAVEAT(1U)
-
-#define S_QUAD2_CAVEAT 2
-#define V_QUAD2_CAVEAT(x) ((x) << S_QUAD2_CAVEAT)
-#define F_QUAD2_CAVEAT V_QUAD2_CAVEAT(1U)
-
-#define S_QUAD1_CAVEAT 1
-#define V_QUAD1_CAVEAT(x) ((x) << S_QUAD1_CAVEAT)
-#define F_QUAD1_CAVEAT V_QUAD1_CAVEAT(1U)
-
-#define S_QUAD0_CAVEAT 0
-#define V_QUAD0_CAVEAT(x) ((x) << S_QUAD0_CAVEAT)
-#define F_QUAD0_CAVEAT V_QUAD0_CAVEAT(1U)
-
-#define A_MC_DDRPHY_DP18_WRCLK_EDGE 0x4417c
-
-#define S_FAIL_PASS_VALUE 8
-#define M_FAIL_PASS_VALUE 0x7fU
-#define V_FAIL_PASS_VALUE(x) ((x) << S_FAIL_PASS_VALUE)
-#define G_FAIL_PASS_VALUE(x) (((x) >> S_FAIL_PASS_VALUE) & M_FAIL_PASS_VALUE)
-
-#define S_PASS_FAIL_VALUE 0
-#define M_PASS_FAIL_VALUE 0xffU
-#define V_PASS_FAIL_VALUE(x) ((x) << S_PASS_FAIL_VALUE)
-#define G_PASS_FAIL_VALUE(x) (((x) >> S_PASS_FAIL_VALUE) & M_PASS_FAIL_VALUE)
-
-#define A_MC_DDRPHY_DP18_READ_EYE_SIZE0_RANK_PAIR 0x44180
-
-#define S_RD_EYE_SIZE_BITS2_7 8
-#define M_RD_EYE_SIZE_BITS2_7 0x3fU
-#define V_RD_EYE_SIZE_BITS2_7(x) ((x) << S_RD_EYE_SIZE_BITS2_7)
-#define G_RD_EYE_SIZE_BITS2_7(x) (((x) >> S_RD_EYE_SIZE_BITS2_7) & M_RD_EYE_SIZE_BITS2_7)
-
-#define S_RD_EYE_SIZE_BITS10_15 0
-#define M_RD_EYE_SIZE_BITS10_15 0x3fU
-#define V_RD_EYE_SIZE_BITS10_15(x) ((x) << S_RD_EYE_SIZE_BITS10_15)
-#define G_RD_EYE_SIZE_BITS10_15(x) (((x) >> S_RD_EYE_SIZE_BITS10_15) & M_RD_EYE_SIZE_BITS10_15)
-
-#define A_MC_DDRPHY_DP18_READ_EYE_SIZE1_RANK_PAIR 0x44184
-#define A_MC_DDRPHY_DP18_READ_EYE_SIZE2_RANK_PAIR 0x44188
-#define A_MC_DDRPHY_DP18_READ_EYE_SIZE3_RANK_PAIR 0x4418c
-#define A_MC_DDRPHY_DP18_READ_EYE_SIZE4_RANK_PAIR 0x44190
-#define A_MC_DDRPHY_DP18_READ_EYE_SIZE5_RANK_PAIR 0x44194
-#define A_MC_DDRPHY_DP18_READ_EYE_SIZE6_RANK_PAIR 0x44198
-#define A_MC_DDRPHY_DP18_READ_EYE_SIZE7_RANK_PAIR 0x4419c
-#define A_MC_DDRPHY_DP18_READ_EYE_SIZE8_RANK_PAIR 0x441a0
-#define A_MC_DDRPHY_DP18_READ_EYE_SIZE9_RANK_PAIR 0x441a4
-#define A_MC_DDRPHY_DP18_READ_EYE_SIZE10_RANK_PAIR 0x441a8
-#define A_MC_DDRPHY_DP18_READ_EYE_SIZE11_RANK_PAIR 0x441ac
-#define A_MC_DDRPHY_DP18_RD_DIA_CONFIG3 0x441b4
-
-#define S_DESIRED_EDGE_CNTR_TARGET_HIGH 8
-#define M_DESIRED_EDGE_CNTR_TARGET_HIGH 0xffU
-#define V_DESIRED_EDGE_CNTR_TARGET_HIGH(x) ((x) << S_DESIRED_EDGE_CNTR_TARGET_HIGH)
-#define G_DESIRED_EDGE_CNTR_TARGET_HIGH(x) (((x) >> S_DESIRED_EDGE_CNTR_TARGET_HIGH) & M_DESIRED_EDGE_CNTR_TARGET_HIGH)
-
-#define S_DESIRED_EDGE_CNTR_TARGET_LOW 0
-#define M_DESIRED_EDGE_CNTR_TARGET_LOW 0xffU
-#define V_DESIRED_EDGE_CNTR_TARGET_LOW(x) ((x) << S_DESIRED_EDGE_CNTR_TARGET_LOW)
-#define G_DESIRED_EDGE_CNTR_TARGET_LOW(x) (((x) >> S_DESIRED_EDGE_CNTR_TARGET_LOW) & M_DESIRED_EDGE_CNTR_TARGET_LOW)
-
-#define A_MC_DDRPHY_DP18_RD_DIA_CONFIG4 0x441b8
-
-#define S_APPROACH_ALIGNMENT 15
-#define V_APPROACH_ALIGNMENT(x) ((x) << S_APPROACH_ALIGNMENT)
-#define F_APPROACH_ALIGNMENT V_APPROACH_ALIGNMENT(1U)
-
-#define A_MC_DDRPHY_DP18_DELAY_LINE_PWR_CTL 0x441bc
-
-#define S_QUAD0_PWR_CTL 12
-#define M_QUAD0_PWR_CTL 0xfU
-#define V_QUAD0_PWR_CTL(x) ((x) << S_QUAD0_PWR_CTL)
-#define G_QUAD0_PWR_CTL(x) (((x) >> S_QUAD0_PWR_CTL) & M_QUAD0_PWR_CTL)
-
-#define S_QUAD1_PWR_CTL 8
-#define M_QUAD1_PWR_CTL 0xfU
-#define V_QUAD1_PWR_CTL(x) ((x) << S_QUAD1_PWR_CTL)
-#define G_QUAD1_PWR_CTL(x) (((x) >> S_QUAD1_PWR_CTL) & M_QUAD1_PWR_CTL)
-
-#define S_QUAD2_PWR_CTL 4
-#define M_QUAD2_PWR_CTL 0xfU
-#define V_QUAD2_PWR_CTL(x) ((x) << S_QUAD2_PWR_CTL)
-#define G_QUAD2_PWR_CTL(x) (((x) >> S_QUAD2_PWR_CTL) & M_QUAD2_PWR_CTL)
-
-#define S_QUAD3_PWR_CTL 0
-#define M_QUAD3_PWR_CTL 0xfU
-#define V_QUAD3_PWR_CTL(x) ((x) << S_QUAD3_PWR_CTL)
-#define G_QUAD3_PWR_CTL(x) (((x) >> S_QUAD3_PWR_CTL) & M_QUAD3_PWR_CTL)
-
-#define A_MC_DDRPHY_DP18_READ_TIMING_REFERENCE0 0x441c0
-
-#define S_REFERENCE_BITS1_7 8
-#define M_REFERENCE_BITS1_7 0x7fU
-#define V_REFERENCE_BITS1_7(x) ((x) << S_REFERENCE_BITS1_7)
-#define G_REFERENCE_BITS1_7(x) (((x) >> S_REFERENCE_BITS1_7) & M_REFERENCE_BITS1_7)
-
-#define S_REFERENCE_BITS9_15 0
-#define M_REFERENCE_BITS9_15 0x7fU
-#define V_REFERENCE_BITS9_15(x) ((x) << S_REFERENCE_BITS9_15)
-#define G_REFERENCE_BITS9_15(x) (((x) >> S_REFERENCE_BITS9_15) & M_REFERENCE_BITS9_15)
-
-#define A_MC_DDRPHY_DP18_READ_TIMING_REFERENCE1 0x441c4
-#define A_MC_DDRPHY_DP18_READ_DQS_TIMING_REFERENCE 0x441c8
-
-#define S_REFERENCE 8
-#define M_REFERENCE 0x7fU
-#define V_REFERENCE(x) ((x) << S_REFERENCE)
-#define G_REFERENCE(x) (((x) >> S_REFERENCE) & M_REFERENCE)
-
-#define A_MC_DDRPHY_DP18_SYSCLK_PR_VALUE 0x441cc
-#define A_MC_DDRPHY_DP18_WRCLK_PR 0x441d0
-#define A_MC_DDRPHY_DP18_IO_TX_CONFIG0 0x441d4
-
-#define S_INTERP_SIG_SLEW 12
-#define M_INTERP_SIG_SLEW 0xfU
-#define V_INTERP_SIG_SLEW(x) ((x) << S_INTERP_SIG_SLEW)
-#define G_INTERP_SIG_SLEW(x) (((x) >> S_INTERP_SIG_SLEW) & M_INTERP_SIG_SLEW)
-
-#define S_POST_CURSOR 8
-#define M_POST_CURSOR 0xfU
-#define V_POST_CURSOR(x) ((x) << S_POST_CURSOR)
-#define G_POST_CURSOR(x) (((x) >> S_POST_CURSOR) & M_POST_CURSOR)
-
-#define S_SLEW_CTL 4
-#define M_SLEW_CTL 0xfU
-#define V_SLEW_CTL(x) ((x) << S_SLEW_CTL)
-#define G_SLEW_CTL(x) (((x) >> S_SLEW_CTL) & M_SLEW_CTL)
-
-#define A_MC_DDRPHY_DP18_PLL_CONFIG0 0x441d8
-#define A_MC_DDRPHY_DP18_PLL_CONFIG1 0x441dc
-
-#define S_CE0DLTVCCA 7
-#define V_CE0DLTVCCA(x) ((x) << S_CE0DLTVCCA)
-#define F_CE0DLTVCCA V_CE0DLTVCCA(1U)
-
-#define S_CE0DLTVCCD1 4
-#define V_CE0DLTVCCD1(x) ((x) << S_CE0DLTVCCD1)
-#define F_CE0DLTVCCD1 V_CE0DLTVCCD1(1U)
-
-#define S_CE0DLTVCCD2 3
-#define V_CE0DLTVCCD2(x) ((x) << S_CE0DLTVCCD2)
-#define F_CE0DLTVCCD2 V_CE0DLTVCCD2(1U)
-
-#define S_S0INSDLYTAP 2
-#define V_S0INSDLYTAP(x) ((x) << S_S0INSDLYTAP)
-#define F_S0INSDLYTAP V_S0INSDLYTAP(1U)
-
-#define S_S1INSDLYTAP 1
-#define V_S1INSDLYTAP(x) ((x) << S_S1INSDLYTAP)
-#define F_S1INSDLYTAP V_S1INSDLYTAP(1U)
-
-#define A_MC_DDRPHY_DP18_IO_TX_NFET_SLICE 0x441e0
-
-#define S_EN_SLICE_N_WR 8
-#define M_EN_SLICE_N_WR 0xffU
-#define V_EN_SLICE_N_WR(x) ((x) << S_EN_SLICE_N_WR)
-#define G_EN_SLICE_N_WR(x) (((x) >> S_EN_SLICE_N_WR) & M_EN_SLICE_N_WR)
-
-#define A_MC_DDRPHY_DP18_IO_TX_PFET_SLICE 0x441e4
-#define A_MC_DDRPHY_DP18_IO_TX_NFET_TERM 0x441e8
-
-#define S_EN_TERM_N_WR 8
-#define M_EN_TERM_N_WR 0xffU
-#define V_EN_TERM_N_WR(x) ((x) << S_EN_TERM_N_WR)
-#define G_EN_TERM_N_WR(x) (((x) >> S_EN_TERM_N_WR) & M_EN_TERM_N_WR)
-
-#define S_EN_TERM_N_WR_FFE 4
-#define M_EN_TERM_N_WR_FFE 0xfU
-#define V_EN_TERM_N_WR_FFE(x) ((x) << S_EN_TERM_N_WR_FFE)
-#define G_EN_TERM_N_WR_FFE(x) (((x) >> S_EN_TERM_N_WR_FFE) & M_EN_TERM_N_WR_FFE)
-
-#define A_MC_DDRPHY_DP18_IO_TX_PFET_TERM 0x441ec
-
-#define S_EN_TERM_P_WR 8
-#define M_EN_TERM_P_WR 0xffU
-#define V_EN_TERM_P_WR(x) ((x) << S_EN_TERM_P_WR)
-#define G_EN_TERM_P_WR(x) (((x) >> S_EN_TERM_P_WR) & M_EN_TERM_P_WR)
-
-#define S_EN_TERM_P_WR_FFE 4
-#define M_EN_TERM_P_WR_FFE 0xfU
-#define V_EN_TERM_P_WR_FFE(x) ((x) << S_EN_TERM_P_WR_FFE)
-#define G_EN_TERM_P_WR_FFE(x) (((x) >> S_EN_TERM_P_WR_FFE) & M_EN_TERM_P_WR_FFE)
-
-#define A_MC_DDRPHY_DP18_DATA_BIT_DISABLE0_RP 0x441f0
-
-#define S_DATA_BIT_DISABLE_0_15 0
-#define M_DATA_BIT_DISABLE_0_15 0xffffU
-#define V_DATA_BIT_DISABLE_0_15(x) ((x) << S_DATA_BIT_DISABLE_0_15)
-#define G_DATA_BIT_DISABLE_0_15(x) (((x) >> S_DATA_BIT_DISABLE_0_15) & M_DATA_BIT_DISABLE_0_15)
-
-#define A_MC_DDRPHY_DP18_DATA_BIT_DISABLE1_RP 0x441f4
-
-#define S_DATA_BIT_DISABLE_16_23 8
-#define M_DATA_BIT_DISABLE_16_23 0xffU
-#define V_DATA_BIT_DISABLE_16_23(x) ((x) << S_DATA_BIT_DISABLE_16_23)
-#define G_DATA_BIT_DISABLE_16_23(x) (((x) >> S_DATA_BIT_DISABLE_16_23) & M_DATA_BIT_DISABLE_16_23)
-
-#define A_MC_DDRPHY_DP18_DQ_WR_OFFSET_RP 0x441f8
-
-#define S_DQ_WR_OFFSET_N0 12
-#define M_DQ_WR_OFFSET_N0 0xfU
-#define V_DQ_WR_OFFSET_N0(x) ((x) << S_DQ_WR_OFFSET_N0)
-#define G_DQ_WR_OFFSET_N0(x) (((x) >> S_DQ_WR_OFFSET_N0) & M_DQ_WR_OFFSET_N0)
-
-#define S_DQ_WR_OFFSET_N1 8
-#define M_DQ_WR_OFFSET_N1 0xfU
-#define V_DQ_WR_OFFSET_N1(x) ((x) << S_DQ_WR_OFFSET_N1)
-#define G_DQ_WR_OFFSET_N1(x) (((x) >> S_DQ_WR_OFFSET_N1) & M_DQ_WR_OFFSET_N1)
-
-#define S_DQ_WR_OFFSET_N2 4
-#define M_DQ_WR_OFFSET_N2 0xfU
-#define V_DQ_WR_OFFSET_N2(x) ((x) << S_DQ_WR_OFFSET_N2)
-#define G_DQ_WR_OFFSET_N2(x) (((x) >> S_DQ_WR_OFFSET_N2) & M_DQ_WR_OFFSET_N2)
-
-#define S_DQ_WR_OFFSET_N3 0
-#define M_DQ_WR_OFFSET_N3 0xfU
-#define V_DQ_WR_OFFSET_N3(x) ((x) << S_DQ_WR_OFFSET_N3)
-#define G_DQ_WR_OFFSET_N3(x) (((x) >> S_DQ_WR_OFFSET_N3) & M_DQ_WR_OFFSET_N3)
-
-#define A_MC_DDRPHY_DP18_POWERDOWN_1 0x441fc
-
-#define S_EYEDAC_PD 13
-#define V_EYEDAC_PD(x) ((x) << S_EYEDAC_PD)
-#define F_EYEDAC_PD V_EYEDAC_PD(1U)
-
-#define S_ANALOG_OUTPUT_STAB 9
-#define V_ANALOG_OUTPUT_STAB(x) ((x) << S_ANALOG_OUTPUT_STAB)
-#define F_ANALOG_OUTPUT_STAB V_ANALOG_OUTPUT_STAB(1U)
-
-#define S_DP18_RX_PD 2
-#define M_DP18_RX_PD 0x3U
-#define V_DP18_RX_PD(x) ((x) << S_DP18_RX_PD)
-#define G_DP18_RX_PD(x) (((x) >> S_DP18_RX_PD) & M_DP18_RX_PD)
-
-#define S_DELAY_LINE_CTL_OVERRIDE 4
-#define V_DELAY_LINE_CTL_OVERRIDE(x) ((x) << S_DELAY_LINE_CTL_OVERRIDE)
-#define F_DELAY_LINE_CTL_OVERRIDE V_DELAY_LINE_CTL_OVERRIDE(1U)
-
-#define S_VCC_REG_PD 0
-#define V_VCC_REG_PD(x) ((x) << S_VCC_REG_PD)
-#define F_VCC_REG_PD V_VCC_REG_PD(1U)
-
-#define A_MC_ADR_DDRPHY_ADR_BIT_ENABLE 0x45000
-
-#define S_BIT_ENABLE_0_11 4
-#define M_BIT_ENABLE_0_11 0xfffU
-#define V_BIT_ENABLE_0_11(x) ((x) << S_BIT_ENABLE_0_11)
-#define G_BIT_ENABLE_0_11(x) (((x) >> S_BIT_ENABLE_0_11) & M_BIT_ENABLE_0_11)
-
-#define S_BIT_ENABLE_12_15 0
-#define M_BIT_ENABLE_12_15 0xfU
-#define V_BIT_ENABLE_12_15(x) ((x) << S_BIT_ENABLE_12_15)
-#define G_BIT_ENABLE_12_15(x) (((x) >> S_BIT_ENABLE_12_15) & M_BIT_ENABLE_12_15)
-
-#define A_MC_ADR_DDRPHY_ADR_DIFFPAIR_ENABLE 0x45004
-
-#define S_DI_ADR0_ADR1 15
-#define V_DI_ADR0_ADR1(x) ((x) << S_DI_ADR0_ADR1)
-#define F_DI_ADR0_ADR1 V_DI_ADR0_ADR1(1U)
-
-#define S_DI_ADR2_ADR3 14
-#define V_DI_ADR2_ADR3(x) ((x) << S_DI_ADR2_ADR3)
-#define F_DI_ADR2_ADR3 V_DI_ADR2_ADR3(1U)
-
-#define S_DI_ADR4_ADR5 13
-#define V_DI_ADR4_ADR5(x) ((x) << S_DI_ADR4_ADR5)
-#define F_DI_ADR4_ADR5 V_DI_ADR4_ADR5(1U)
-
-#define S_DI_ADR6_ADR7 12
-#define V_DI_ADR6_ADR7(x) ((x) << S_DI_ADR6_ADR7)
-#define F_DI_ADR6_ADR7 V_DI_ADR6_ADR7(1U)
-
-#define S_DI_ADR8_ADR9 11
-#define V_DI_ADR8_ADR9(x) ((x) << S_DI_ADR8_ADR9)
-#define F_DI_ADR8_ADR9 V_DI_ADR8_ADR9(1U)
-
-#define S_DI_ADR10_ADR11 10
-#define V_DI_ADR10_ADR11(x) ((x) << S_DI_ADR10_ADR11)
-#define F_DI_ADR10_ADR11 V_DI_ADR10_ADR11(1U)
-
-#define S_DI_ADR12_ADR13 9
-#define V_DI_ADR12_ADR13(x) ((x) << S_DI_ADR12_ADR13)
-#define F_DI_ADR12_ADR13 V_DI_ADR12_ADR13(1U)
-
-#define S_DI_ADR14_ADR15 8
-#define V_DI_ADR14_ADR15(x) ((x) << S_DI_ADR14_ADR15)
-#define F_DI_ADR14_ADR15 V_DI_ADR14_ADR15(1U)
-
-#define A_MC_ADR_DDRPHY_ADR_DELAY0 0x45010
-
-#define S_ADR_DELAY_BITS1_7 8
-#define M_ADR_DELAY_BITS1_7 0x7fU
-#define V_ADR_DELAY_BITS1_7(x) ((x) << S_ADR_DELAY_BITS1_7)
-#define G_ADR_DELAY_BITS1_7(x) (((x) >> S_ADR_DELAY_BITS1_7) & M_ADR_DELAY_BITS1_7)
-
-#define S_ADR_DELAY_BITS9_15 0
-#define M_ADR_DELAY_BITS9_15 0x7fU
-#define V_ADR_DELAY_BITS9_15(x) ((x) << S_ADR_DELAY_BITS9_15)
-#define G_ADR_DELAY_BITS9_15(x) (((x) >> S_ADR_DELAY_BITS9_15) & M_ADR_DELAY_BITS9_15)
-
-#define A_MC_ADR_DDRPHY_ADR_DELAY1 0x45014
-#define A_MC_ADR_DDRPHY_ADR_DELAY2 0x45018
-#define A_MC_ADR_DDRPHY_ADR_DELAY3 0x4501c
-#define A_MC_ADR_DDRPHY_ADR_DELAY4 0x45020
-#define A_MC_ADR_DDRPHY_ADR_DELAY5 0x45024
-#define A_MC_ADR_DDRPHY_ADR_DELAY6 0x45028
-#define A_MC_ADR_DDRPHY_ADR_DELAY7 0x4502c
-#define A_MC_ADR_DDRPHY_ADR_DFT_WRAP_STATUS_CONTROL 0x45030
-
-#define S_ADR_TEST_LANE_PAIR_FAIL 8
-#define M_ADR_TEST_LANE_PAIR_FAIL 0xffU
-#define V_ADR_TEST_LANE_PAIR_FAIL(x) ((x) << S_ADR_TEST_LANE_PAIR_FAIL)
-#define G_ADR_TEST_LANE_PAIR_FAIL(x) (((x) >> S_ADR_TEST_LANE_PAIR_FAIL) & M_ADR_TEST_LANE_PAIR_FAIL)
-
-#define S_ADR_TEST_DATA_EN 7
-#define V_ADR_TEST_DATA_EN(x) ((x) << S_ADR_TEST_DATA_EN)
-#define F_ADR_TEST_DATA_EN V_ADR_TEST_DATA_EN(1U)
-
-#define S_DADR_TEST_MODE 5
-#define M_DADR_TEST_MODE 0x3U
-#define V_DADR_TEST_MODE(x) ((x) << S_DADR_TEST_MODE)
-#define G_DADR_TEST_MODE(x) (((x) >> S_DADR_TEST_MODE) & M_DADR_TEST_MODE)
-
-#define S_ADR_TEST_4TO1_MODE 4
-#define V_ADR_TEST_4TO1_MODE(x) ((x) << S_ADR_TEST_4TO1_MODE)
-#define F_ADR_TEST_4TO1_MODE V_ADR_TEST_4TO1_MODE(1U)
-
-#define S_ADR_TEST_RESET 3
-#define V_ADR_TEST_RESET(x) ((x) << S_ADR_TEST_RESET)
-#define F_ADR_TEST_RESET V_ADR_TEST_RESET(1U)
-
-#define S_ADR_TEST_GEN_EN 2
-#define V_ADR_TEST_GEN_EN(x) ((x) << S_ADR_TEST_GEN_EN)
-#define F_ADR_TEST_GEN_EN V_ADR_TEST_GEN_EN(1U)
-
-#define S_ADR_TEST_CLEAR_ERROR 1
-#define V_ADR_TEST_CLEAR_ERROR(x) ((x) << S_ADR_TEST_CLEAR_ERROR)
-#define F_ADR_TEST_CLEAR_ERROR V_ADR_TEST_CLEAR_ERROR(1U)
-
-#define S_ADR_TEST_CHECK_EN 0
-#define V_ADR_TEST_CHECK_EN(x) ((x) << S_ADR_TEST_CHECK_EN)
-#define F_ADR_TEST_CHECK_EN V_ADR_TEST_CHECK_EN(1U)
-
-#define A_MC_ADR_DDRPHY_ADR_IO_NFET_SLICE_EN0 0x45040
-
-#define S_EN_SLICE_N_WR_0 8
-#define M_EN_SLICE_N_WR_0 0xffU
-#define V_EN_SLICE_N_WR_0(x) ((x) << S_EN_SLICE_N_WR_0)
-#define G_EN_SLICE_N_WR_0(x) (((x) >> S_EN_SLICE_N_WR_0) & M_EN_SLICE_N_WR_0)
-
-#define S_EN_SLICE_N_WR_FFE 4
-#define M_EN_SLICE_N_WR_FFE 0xfU
-#define V_EN_SLICE_N_WR_FFE(x) ((x) << S_EN_SLICE_N_WR_FFE)
-#define G_EN_SLICE_N_WR_FFE(x) (((x) >> S_EN_SLICE_N_WR_FFE) & M_EN_SLICE_N_WR_FFE)
-
-#define A_MC_ADR_DDRPHY_ADR_IO_NFET_SLICE_EN1 0x45044
-
-#define S_EN_SLICE_N_WR_1 8
-#define M_EN_SLICE_N_WR_1 0xffU
-#define V_EN_SLICE_N_WR_1(x) ((x) << S_EN_SLICE_N_WR_1)
-#define G_EN_SLICE_N_WR_1(x) (((x) >> S_EN_SLICE_N_WR_1) & M_EN_SLICE_N_WR_1)
-
-#define A_MC_ADR_DDRPHY_ADR_IO_NFET_SLICE_EN2 0x45048
-
-#define S_EN_SLICE_N_WR_2 8
-#define M_EN_SLICE_N_WR_2 0xffU
-#define V_EN_SLICE_N_WR_2(x) ((x) << S_EN_SLICE_N_WR_2)
-#define G_EN_SLICE_N_WR_2(x) (((x) >> S_EN_SLICE_N_WR_2) & M_EN_SLICE_N_WR_2)
-
-#define A_MC_ADR_DDRPHY_ADR_IO_NFET_SLICE_EN3 0x4504c
-
-#define S_EN_SLICE_N_WR_3 8
-#define M_EN_SLICE_N_WR_3 0xffU
-#define V_EN_SLICE_N_WR_3(x) ((x) << S_EN_SLICE_N_WR_3)
-#define G_EN_SLICE_N_WR_3(x) (((x) >> S_EN_SLICE_N_WR_3) & M_EN_SLICE_N_WR_3)
-
-#define A_MC_ADR_DDRPHY_ADR_IO_PFET_SLICE_EN0 0x45050
-
-#define S_EN_SLICE_P_WR 8
-#define M_EN_SLICE_P_WR 0xffU
-#define V_EN_SLICE_P_WR(x) ((x) << S_EN_SLICE_P_WR)
-#define G_EN_SLICE_P_WR(x) (((x) >> S_EN_SLICE_P_WR) & M_EN_SLICE_P_WR)
-
-#define S_EN_SLICE_P_WR_FFE 4
-#define M_EN_SLICE_P_WR_FFE 0xfU
-#define V_EN_SLICE_P_WR_FFE(x) ((x) << S_EN_SLICE_P_WR_FFE)
-#define G_EN_SLICE_P_WR_FFE(x) (((x) >> S_EN_SLICE_P_WR_FFE) & M_EN_SLICE_P_WR_FFE)
-
-#define A_MC_ADR_DDRPHY_ADR_IO_PFET_SLICE_EN1 0x45054
-#define A_MC_ADR_DDRPHY_ADR_IO_PFET_SLICE_EN2 0x45058
-#define A_MC_ADR_DDRPHY_ADR_IO_PFET_SLICE_EN3 0x4505c
-#define A_MC_ADR_DDRPHY_ADR_IO_POST_CURSOR_VALUE 0x45060
-
-#define S_POST_CURSOR0 12
-#define M_POST_CURSOR0 0xfU
-#define V_POST_CURSOR0(x) ((x) << S_POST_CURSOR0)
-#define G_POST_CURSOR0(x) (((x) >> S_POST_CURSOR0) & M_POST_CURSOR0)
-
-#define S_POST_CURSOR1 8
-#define M_POST_CURSOR1 0xfU
-#define V_POST_CURSOR1(x) ((x) << S_POST_CURSOR1)
-#define G_POST_CURSOR1(x) (((x) >> S_POST_CURSOR1) & M_POST_CURSOR1)
-
-#define S_POST_CURSOR2 4
-#define M_POST_CURSOR2 0xfU
-#define V_POST_CURSOR2(x) ((x) << S_POST_CURSOR2)
-#define G_POST_CURSOR2(x) (((x) >> S_POST_CURSOR2) & M_POST_CURSOR2)
-
-#define S_POST_CURSOR3 0
-#define M_POST_CURSOR3 0xfU
-#define V_POST_CURSOR3(x) ((x) << S_POST_CURSOR3)
-#define G_POST_CURSOR3(x) (((x) >> S_POST_CURSOR3) & M_POST_CURSOR3)
-
-#define A_MC_ADR_DDRPHY_ADR_IO_SLEW_CTL_VALUE 0x45068
-
-#define S_SLEW_CTL0 12
-#define M_SLEW_CTL0 0xfU
-#define V_SLEW_CTL0(x) ((x) << S_SLEW_CTL0)
-#define G_SLEW_CTL0(x) (((x) >> S_SLEW_CTL0) & M_SLEW_CTL0)
-
-#define S_SLEW_CTL1 8
-#define M_SLEW_CTL1 0xfU
-#define V_SLEW_CTL1(x) ((x) << S_SLEW_CTL1)
-#define G_SLEW_CTL1(x) (((x) >> S_SLEW_CTL1) & M_SLEW_CTL1)
-
-#define S_SLEW_CTL2 4
-#define M_SLEW_CTL2 0xfU
-#define V_SLEW_CTL2(x) ((x) << S_SLEW_CTL2)
-#define G_SLEW_CTL2(x) (((x) >> S_SLEW_CTL2) & M_SLEW_CTL2)
-
-#define S_SLEW_CTL3 0
-#define M_SLEW_CTL3 0xfU
-#define V_SLEW_CTL3(x) ((x) << S_SLEW_CTL3)
-#define G_SLEW_CTL3(x) (((x) >> S_SLEW_CTL3) & M_SLEW_CTL3)
-
-#define A_MC_ADR_DDRPHY_ADR_IO_FET_SLICE_EN_MAP0 0x45080
-
-#define S_SLICE_SEL_REG_BITS0_1 14
-#define M_SLICE_SEL_REG_BITS0_1 0x3U
-#define V_SLICE_SEL_REG_BITS0_1(x) ((x) << S_SLICE_SEL_REG_BITS0_1)
-#define G_SLICE_SEL_REG_BITS0_1(x) (((x) >> S_SLICE_SEL_REG_BITS0_1) & M_SLICE_SEL_REG_BITS0_1)
-
-#define S_SLICE_SEL_REG_BITS2_3 12
-#define M_SLICE_SEL_REG_BITS2_3 0x3U
-#define V_SLICE_SEL_REG_BITS2_3(x) ((x) << S_SLICE_SEL_REG_BITS2_3)
-#define G_SLICE_SEL_REG_BITS2_3(x) (((x) >> S_SLICE_SEL_REG_BITS2_3) & M_SLICE_SEL_REG_BITS2_3)
-
-#define S_SLICE_SEL_REG_BITS4_5 10
-#define M_SLICE_SEL_REG_BITS4_5 0x3U
-#define V_SLICE_SEL_REG_BITS4_5(x) ((x) << S_SLICE_SEL_REG_BITS4_5)
-#define G_SLICE_SEL_REG_BITS4_5(x) (((x) >> S_SLICE_SEL_REG_BITS4_5) & M_SLICE_SEL_REG_BITS4_5)
-
-#define S_SLICE_SEL_REG_BITS6_7 8
-#define M_SLICE_SEL_REG_BITS6_7 0x3U
-#define V_SLICE_SEL_REG_BITS6_7(x) ((x) << S_SLICE_SEL_REG_BITS6_7)
-#define G_SLICE_SEL_REG_BITS6_7(x) (((x) >> S_SLICE_SEL_REG_BITS6_7) & M_SLICE_SEL_REG_BITS6_7)
-
-#define S_SLICE_SEL_REG_BITS8_9 6
-#define M_SLICE_SEL_REG_BITS8_9 0x3U
-#define V_SLICE_SEL_REG_BITS8_9(x) ((x) << S_SLICE_SEL_REG_BITS8_9)
-#define G_SLICE_SEL_REG_BITS8_9(x) (((x) >> S_SLICE_SEL_REG_BITS8_9) & M_SLICE_SEL_REG_BITS8_9)
-
-#define S_SLICE_SEL_REG_BITS10_11 4
-#define M_SLICE_SEL_REG_BITS10_11 0x3U
-#define V_SLICE_SEL_REG_BITS10_11(x) ((x) << S_SLICE_SEL_REG_BITS10_11)
-#define G_SLICE_SEL_REG_BITS10_11(x) (((x) >> S_SLICE_SEL_REG_BITS10_11) & M_SLICE_SEL_REG_BITS10_11)
-
-#define S_SLICE_SEL_REG_BITS12_13 2
-#define M_SLICE_SEL_REG_BITS12_13 0x3U
-#define V_SLICE_SEL_REG_BITS12_13(x) ((x) << S_SLICE_SEL_REG_BITS12_13)
-#define G_SLICE_SEL_REG_BITS12_13(x) (((x) >> S_SLICE_SEL_REG_BITS12_13) & M_SLICE_SEL_REG_BITS12_13)
-
-#define S_SLICE_SEL_REG_BITS14_15 0
-#define M_SLICE_SEL_REG_BITS14_15 0x3U
-#define V_SLICE_SEL_REG_BITS14_15(x) ((x) << S_SLICE_SEL_REG_BITS14_15)
-#define G_SLICE_SEL_REG_BITS14_15(x) (((x) >> S_SLICE_SEL_REG_BITS14_15) & M_SLICE_SEL_REG_BITS14_15)
-
-#define A_MC_ADR_DDRPHY_ADR_IO_FET_SLICE_EN_MAP1 0x45084
-#define A_MC_ADR_DDRPHY_ADR_IO_POST_CURSOR_VALUE_MAP0 0x450a0
-
-#define S_POST_CUR_SEL_BITS0_1 14
-#define M_POST_CUR_SEL_BITS0_1 0x3U
-#define V_POST_CUR_SEL_BITS0_1(x) ((x) << S_POST_CUR_SEL_BITS0_1)
-#define G_POST_CUR_SEL_BITS0_1(x) (((x) >> S_POST_CUR_SEL_BITS0_1) & M_POST_CUR_SEL_BITS0_1)
-
-#define S_POST_CUR_SEL_BITS2_3 12
-#define M_POST_CUR_SEL_BITS2_3 0x3U
-#define V_POST_CUR_SEL_BITS2_3(x) ((x) << S_POST_CUR_SEL_BITS2_3)
-#define G_POST_CUR_SEL_BITS2_3(x) (((x) >> S_POST_CUR_SEL_BITS2_3) & M_POST_CUR_SEL_BITS2_3)
-
-#define S_POST_CUR_SEL_BITS4_5 10
-#define M_POST_CUR_SEL_BITS4_5 0x3U
-#define V_POST_CUR_SEL_BITS4_5(x) ((x) << S_POST_CUR_SEL_BITS4_5)
-#define G_POST_CUR_SEL_BITS4_5(x) (((x) >> S_POST_CUR_SEL_BITS4_5) & M_POST_CUR_SEL_BITS4_5)
-
-#define S_POST_CUR_SEL_BITS6_7 8
-#define M_POST_CUR_SEL_BITS6_7 0x3U
-#define V_POST_CUR_SEL_BITS6_7(x) ((x) << S_POST_CUR_SEL_BITS6_7)
-#define G_POST_CUR_SEL_BITS6_7(x) (((x) >> S_POST_CUR_SEL_BITS6_7) & M_POST_CUR_SEL_BITS6_7)
-
-#define S_POST_CUR_SEL_BITS8_9 6
-#define M_POST_CUR_SEL_BITS8_9 0x3U
-#define V_POST_CUR_SEL_BITS8_9(x) ((x) << S_POST_CUR_SEL_BITS8_9)
-#define G_POST_CUR_SEL_BITS8_9(x) (((x) >> S_POST_CUR_SEL_BITS8_9) & M_POST_CUR_SEL_BITS8_9)
-
-#define S_POST_CUR_SEL_BITS10_11 4
-#define M_POST_CUR_SEL_BITS10_11 0x3U
-#define V_POST_CUR_SEL_BITS10_11(x) ((x) << S_POST_CUR_SEL_BITS10_11)
-#define G_POST_CUR_SEL_BITS10_11(x) (((x) >> S_POST_CUR_SEL_BITS10_11) & M_POST_CUR_SEL_BITS10_11)
-
-#define S_POST_CUR_SEL_BITS12_13 2
-#define M_POST_CUR_SEL_BITS12_13 0x3U
-#define V_POST_CUR_SEL_BITS12_13(x) ((x) << S_POST_CUR_SEL_BITS12_13)
-#define G_POST_CUR_SEL_BITS12_13(x) (((x) >> S_POST_CUR_SEL_BITS12_13) & M_POST_CUR_SEL_BITS12_13)
-
-#define S_POST_CUR_SEL_BITS14_15 0
-#define M_POST_CUR_SEL_BITS14_15 0x3U
-#define V_POST_CUR_SEL_BITS14_15(x) ((x) << S_POST_CUR_SEL_BITS14_15)
-#define G_POST_CUR_SEL_BITS14_15(x) (((x) >> S_POST_CUR_SEL_BITS14_15) & M_POST_CUR_SEL_BITS14_15)
-
-#define A_MC_ADR_DDRPHY_ADR_IO_POST_CURSOR_VALUE_MAP1 0x450a4
-#define A_MC_ADR_DDRPHY_ADR_IO_SLEW_CTL_VALUE_MAP0 0x450a8
-
-#define S_SLEW_CTL_SEL_BITS0_1 14
-#define M_SLEW_CTL_SEL_BITS0_1 0x3U
-#define V_SLEW_CTL_SEL_BITS0_1(x) ((x) << S_SLEW_CTL_SEL_BITS0_1)
-#define G_SLEW_CTL_SEL_BITS0_1(x) (((x) >> S_SLEW_CTL_SEL_BITS0_1) & M_SLEW_CTL_SEL_BITS0_1)
-
-#define S_SLEW_CTL_SEL_BITS2_3 12
-#define M_SLEW_CTL_SEL_BITS2_3 0x3U
-#define V_SLEW_CTL_SEL_BITS2_3(x) ((x) << S_SLEW_CTL_SEL_BITS2_3)
-#define G_SLEW_CTL_SEL_BITS2_3(x) (((x) >> S_SLEW_CTL_SEL_BITS2_3) & M_SLEW_CTL_SEL_BITS2_3)
-
-#define S_SLEW_CTL_SEL_BITS4_5 10
-#define M_SLEW_CTL_SEL_BITS4_5 0x3U
-#define V_SLEW_CTL_SEL_BITS4_5(x) ((x) << S_SLEW_CTL_SEL_BITS4_5)
-#define G_SLEW_CTL_SEL_BITS4_5(x) (((x) >> S_SLEW_CTL_SEL_BITS4_5) & M_SLEW_CTL_SEL_BITS4_5)
-
-#define S_SLEW_CTL_SEL_BITS6_7 8
-#define M_SLEW_CTL_SEL_BITS6_7 0x3U
-#define V_SLEW_CTL_SEL_BITS6_7(x) ((x) << S_SLEW_CTL_SEL_BITS6_7)
-#define G_SLEW_CTL_SEL_BITS6_7(x) (((x) >> S_SLEW_CTL_SEL_BITS6_7) & M_SLEW_CTL_SEL_BITS6_7)
-
-#define S_SLEW_CTL_SEL_BITS8_9 6
-#define M_SLEW_CTL_SEL_BITS8_9 0x3U
-#define V_SLEW_CTL_SEL_BITS8_9(x) ((x) << S_SLEW_CTL_SEL_BITS8_9)
-#define G_SLEW_CTL_SEL_BITS8_9(x) (((x) >> S_SLEW_CTL_SEL_BITS8_9) & M_SLEW_CTL_SEL_BITS8_9)
-
-#define S_SLEW_CTL_SEL_BITS10_11 4
-#define M_SLEW_CTL_SEL_BITS10_11 0x3U
-#define V_SLEW_CTL_SEL_BITS10_11(x) ((x) << S_SLEW_CTL_SEL_BITS10_11)
-#define G_SLEW_CTL_SEL_BITS10_11(x) (((x) >> S_SLEW_CTL_SEL_BITS10_11) & M_SLEW_CTL_SEL_BITS10_11)
-
-#define S_SLEW_CTL_SEL_BITS12_13 2
-#define M_SLEW_CTL_SEL_BITS12_13 0x3U
-#define V_SLEW_CTL_SEL_BITS12_13(x) ((x) << S_SLEW_CTL_SEL_BITS12_13)
-#define G_SLEW_CTL_SEL_BITS12_13(x) (((x) >> S_SLEW_CTL_SEL_BITS12_13) & M_SLEW_CTL_SEL_BITS12_13)
-
-#define S_SLEW_CTL_SEL_BITS14_15 0
-#define M_SLEW_CTL_SEL_BITS14_15 0x3U
-#define V_SLEW_CTL_SEL_BITS14_15(x) ((x) << S_SLEW_CTL_SEL_BITS14_15)
-#define G_SLEW_CTL_SEL_BITS14_15(x) (((x) >> S_SLEW_CTL_SEL_BITS14_15) & M_SLEW_CTL_SEL_BITS14_15)
-
-#define A_MC_ADR_DDRPHY_ADR_IO_SLEW_CTL_VALUE_MAP1 0x450ac
-#define A_MC_ADR_DDRPHY_ADR_POWERDOWN_2 0x450b0
-
-#define S_ADR_LANE_0_11_PD 4
-#define M_ADR_LANE_0_11_PD 0xfffU
-#define V_ADR_LANE_0_11_PD(x) ((x) << S_ADR_LANE_0_11_PD)
-#define G_ADR_LANE_0_11_PD(x) (((x) >> S_ADR_LANE_0_11_PD) & M_ADR_LANE_0_11_PD)
-
-#define S_ADR_LANE_12_15_PD 0
-#define M_ADR_LANE_12_15_PD 0xfU
-#define V_ADR_LANE_12_15_PD(x) ((x) << S_ADR_LANE_12_15_PD)
-#define G_ADR_LANE_12_15_PD(x) (((x) >> S_ADR_LANE_12_15_PD) & M_ADR_LANE_12_15_PD)
-
-#define A_T6_MC_ADR_DDRPHY_ADR_BIT_ENABLE 0x45800
-#define A_T6_MC_ADR_DDRPHY_ADR_DIFFPAIR_ENABLE 0x45804
-#define A_T6_MC_ADR_DDRPHY_ADR_DELAY0 0x45810
-#define A_T6_MC_ADR_DDRPHY_ADR_DELAY1 0x45814
-#define A_T6_MC_ADR_DDRPHY_ADR_DELAY2 0x45818
-#define A_T6_MC_ADR_DDRPHY_ADR_DELAY3 0x4581c
-#define A_T6_MC_ADR_DDRPHY_ADR_DELAY4 0x45820
-#define A_T6_MC_ADR_DDRPHY_ADR_DELAY5 0x45824
-#define A_T6_MC_ADR_DDRPHY_ADR_DELAY6 0x45828
-#define A_T6_MC_ADR_DDRPHY_ADR_DELAY7 0x4582c
-#define A_T6_MC_ADR_DDRPHY_ADR_DFT_WRAP_STATUS_CONTROL 0x45830
-
-#define S_ADR_TEST_MODE 5
-#define M_ADR_TEST_MODE 0x3U
-#define V_ADR_TEST_MODE(x) ((x) << S_ADR_TEST_MODE)
-#define G_ADR_TEST_MODE(x) (((x) >> S_ADR_TEST_MODE) & M_ADR_TEST_MODE)
-
-#define A_T6_MC_ADR_DDRPHY_ADR_IO_NFET_SLICE_EN0 0x45840
-#define A_T6_MC_ADR_DDRPHY_ADR_IO_NFET_SLICE_EN1 0x45844
-#define A_T6_MC_ADR_DDRPHY_ADR_IO_NFET_SLICE_EN2 0x45848
-#define A_T6_MC_ADR_DDRPHY_ADR_IO_NFET_SLICE_EN3 0x4584c
-#define A_T6_MC_ADR_DDRPHY_ADR_IO_PFET_SLICE_EN0 0x45850
-#define A_T6_MC_ADR_DDRPHY_ADR_IO_PFET_SLICE_EN1 0x45854
-#define A_T6_MC_ADR_DDRPHY_ADR_IO_PFET_SLICE_EN2 0x45858
-#define A_T6_MC_ADR_DDRPHY_ADR_IO_PFET_SLICE_EN3 0x4585c
-#define A_T6_MC_ADR_DDRPHY_ADR_IO_POST_CURSOR_VALUE 0x45860
-#define A_T6_MC_ADR_DDRPHY_ADR_IO_SLEW_CTL_VALUE 0x45868
-#define A_T6_MC_ADR_DDRPHY_ADR_IO_FET_SLICE_EN_MAP0 0x45880
-#define A_T6_MC_ADR_DDRPHY_ADR_IO_FET_SLICE_EN_MAP1 0x45884
-#define A_T6_MC_ADR_DDRPHY_ADR_IO_POST_CURSOR_VALUE_MAP0 0x458a0
-#define A_T6_MC_ADR_DDRPHY_ADR_IO_POST_CURSOR_VALUE_MAP1 0x458a4
-#define A_T6_MC_ADR_DDRPHY_ADR_IO_SLEW_CTL_VALUE_MAP0 0x458a8
-#define A_T6_MC_ADR_DDRPHY_ADR_IO_SLEW_CTL_VALUE_MAP1 0x458ac
-#define A_T6_MC_ADR_DDRPHY_ADR_POWERDOWN_2 0x458b0
-#define A_MC_DDRPHY_ADR_PLL_VREG_CONFIG_0 0x460c0
-
-#define S_PLL_TUNE_0_2 13
-#define M_PLL_TUNE_0_2 0x7U
-#define V_PLL_TUNE_0_2(x) ((x) << S_PLL_TUNE_0_2)
-#define G_PLL_TUNE_0_2(x) (((x) >> S_PLL_TUNE_0_2) & M_PLL_TUNE_0_2)
-
-#define S_PLL_TUNECP_0_2 10
-#define M_PLL_TUNECP_0_2 0x7U
-#define V_PLL_TUNECP_0_2(x) ((x) << S_PLL_TUNECP_0_2)
-#define G_PLL_TUNECP_0_2(x) (((x) >> S_PLL_TUNECP_0_2) & M_PLL_TUNECP_0_2)
-
-#define S_PLL_TUNEF_0_5 4
-#define M_PLL_TUNEF_0_5 0x3fU
-#define V_PLL_TUNEF_0_5(x) ((x) << S_PLL_TUNEF_0_5)
-#define G_PLL_TUNEF_0_5(x) (((x) >> S_PLL_TUNEF_0_5) & M_PLL_TUNEF_0_5)
-
-#define S_PLL_TUNEVCO_0_1 2
-#define M_PLL_TUNEVCO_0_1 0x3U
-#define V_PLL_TUNEVCO_0_1(x) ((x) << S_PLL_TUNEVCO_0_1)
-#define G_PLL_TUNEVCO_0_1(x) (((x) >> S_PLL_TUNEVCO_0_1) & M_PLL_TUNEVCO_0_1)
-
-#define S_PLL_PLLXTR_0_1 0
-#define M_PLL_PLLXTR_0_1 0x3U
-#define V_PLL_PLLXTR_0_1(x) ((x) << S_PLL_PLLXTR_0_1)
-#define G_PLL_PLLXTR_0_1(x) (((x) >> S_PLL_PLLXTR_0_1) & M_PLL_PLLXTR_0_1)
-
-#define A_MC_DDRPHY_AD32S_PLL_VREG_CONFIG_0 0x460c0
-#define A_MC_DDRPHY_ADR_PLL_VREG_CONFIG_1 0x460c4
-
-#define S_PLL_TUNETDIV_0_2 13
-#define M_PLL_TUNETDIV_0_2 0x7U
-#define V_PLL_TUNETDIV_0_2(x) ((x) << S_PLL_TUNETDIV_0_2)
-#define G_PLL_TUNETDIV_0_2(x) (((x) >> S_PLL_TUNETDIV_0_2) & M_PLL_TUNETDIV_0_2)
-
-#define S_PLL_TUNEMDIV_0_1 11
-#define M_PLL_TUNEMDIV_0_1 0x3U
-#define V_PLL_TUNEMDIV_0_1(x) ((x) << S_PLL_TUNEMDIV_0_1)
-#define G_PLL_TUNEMDIV_0_1(x) (((x) >> S_PLL_TUNEMDIV_0_1) & M_PLL_TUNEMDIV_0_1)
-
-#define S_PLL_TUNEATST 10
-#define V_PLL_TUNEATST(x) ((x) << S_PLL_TUNEATST)
-#define F_PLL_TUNEATST V_PLL_TUNEATST(1U)
-
-#define S_VREG_RANGE_0_1 8
-#define M_VREG_RANGE_0_1 0x3U
-#define V_VREG_RANGE_0_1(x) ((x) << S_VREG_RANGE_0_1)
-#define G_VREG_RANGE_0_1(x) (((x) >> S_VREG_RANGE_0_1) & M_VREG_RANGE_0_1)
-
-#define S_VREG_VREGSPARE 7
-#define V_VREG_VREGSPARE(x) ((x) << S_VREG_VREGSPARE)
-#define F_VREG_VREGSPARE V_VREG_VREGSPARE(1U)
-
-#define S_VREG_VCCTUNE_0_1 5
-#define M_VREG_VCCTUNE_0_1 0x3U
-#define V_VREG_VCCTUNE_0_1(x) ((x) << S_VREG_VCCTUNE_0_1)
-#define G_VREG_VCCTUNE_0_1(x) (((x) >> S_VREG_VCCTUNE_0_1) & M_VREG_VCCTUNE_0_1)
-
-#define S_INTERP_SIG_SLEW_0_3 1
-#define M_INTERP_SIG_SLEW_0_3 0xfU
-#define V_INTERP_SIG_SLEW_0_3(x) ((x) << S_INTERP_SIG_SLEW_0_3)
-#define G_INTERP_SIG_SLEW_0_3(x) (((x) >> S_INTERP_SIG_SLEW_0_3) & M_INTERP_SIG_SLEW_0_3)
-
-#define S_ANALOG_WRAPON 0
-#define V_ANALOG_WRAPON(x) ((x) << S_ANALOG_WRAPON)
-#define F_ANALOG_WRAPON V_ANALOG_WRAPON(1U)
-
-#define A_MC_DDRPHY_AD32S_PLL_VREG_CONFIG_1 0x460c4
-#define A_MC_DDRPHY_ADR_SYSCLK_CNTL_PR 0x460c8
-
-#define S_SYSCLK_ENABLE 15
-#define V_SYSCLK_ENABLE(x) ((x) << S_SYSCLK_ENABLE)
-#define F_SYSCLK_ENABLE V_SYSCLK_ENABLE(1U)
-
-#define S_SYSCLK_ROT_OVERRIDE 8
-#define M_SYSCLK_ROT_OVERRIDE 0x7fU
-#define V_SYSCLK_ROT_OVERRIDE(x) ((x) << S_SYSCLK_ROT_OVERRIDE)
-#define G_SYSCLK_ROT_OVERRIDE(x) (((x) >> S_SYSCLK_ROT_OVERRIDE) & M_SYSCLK_ROT_OVERRIDE)
-
-#define S_SYSCLK_ROT_OVERRIDE_EN 7
-#define V_SYSCLK_ROT_OVERRIDE_EN(x) ((x) << S_SYSCLK_ROT_OVERRIDE_EN)
-#define F_SYSCLK_ROT_OVERRIDE_EN V_SYSCLK_ROT_OVERRIDE_EN(1U)
-
-#define S_SYSCLK_PHASE_ALIGN_RESE 6
-#define V_SYSCLK_PHASE_ALIGN_RESE(x) ((x) << S_SYSCLK_PHASE_ALIGN_RESE)
-#define F_SYSCLK_PHASE_ALIGN_RESE V_SYSCLK_PHASE_ALIGN_RESE(1U)
-
-#define S_SYSCLK_PHASE_CNTL_EN 5
-#define V_SYSCLK_PHASE_CNTL_EN(x) ((x) << S_SYSCLK_PHASE_CNTL_EN)
-#define F_SYSCLK_PHASE_CNTL_EN V_SYSCLK_PHASE_CNTL_EN(1U)
-
-#define S_SYSCLK_PHASE_DEFAULT_EN 4
-#define V_SYSCLK_PHASE_DEFAULT_EN(x) ((x) << S_SYSCLK_PHASE_DEFAULT_EN)
-#define F_SYSCLK_PHASE_DEFAULT_EN V_SYSCLK_PHASE_DEFAULT_EN(1U)
-
-#define S_SYSCLK_POS_EDGE_ALIGN 3
-#define V_SYSCLK_POS_EDGE_ALIGN(x) ((x) << S_SYSCLK_POS_EDGE_ALIGN)
-#define F_SYSCLK_POS_EDGE_ALIGN V_SYSCLK_POS_EDGE_ALIGN(1U)
-
-#define S_CONTINUOUS_UPDATE 2
-#define V_CONTINUOUS_UPDATE(x) ((x) << S_CONTINUOUS_UPDATE)
-#define F_CONTINUOUS_UPDATE V_CONTINUOUS_UPDATE(1U)
-
-#define S_CE0DLTVCC 0
-#define M_CE0DLTVCC 0x3U
-#define V_CE0DLTVCC(x) ((x) << S_CE0DLTVCC)
-#define G_CE0DLTVCC(x) (((x) >> S_CE0DLTVCC) & M_CE0DLTVCC)
-
-#define A_MC_DDRPHY_AD32S_SYSCLK_CNTL_PR 0x460c8
-#define A_MC_DDRPHY_ADR_MCCLK_WRCLK_PR_STATIC_OFFSET 0x460cc
-
-#define S_TSYS_WRCLK 8
-#define M_TSYS_WRCLK 0x7fU
-#define V_TSYS_WRCLK(x) ((x) << S_TSYS_WRCLK)
-#define G_TSYS_WRCLK(x) (((x) >> S_TSYS_WRCLK) & M_TSYS_WRCLK)
-
-#define A_MC_DDRPHY_AD32S_MCCLK_WRCLK_PR_STATIC_OFFSET 0x460cc
-#define A_MC_DDRPHY_ADR_SYSCLK_PR_VALUE_RO 0x460d0
-
-#define S_SLEW_LATE_SAMPLE 15
-#define V_SLEW_LATE_SAMPLE(x) ((x) << S_SLEW_LATE_SAMPLE)
-#define F_SLEW_LATE_SAMPLE V_SLEW_LATE_SAMPLE(1U)
-
-#define S_SYSCLK_ROT 8
-#define M_SYSCLK_ROT 0x7fU
-#define V_SYSCLK_ROT(x) ((x) << S_SYSCLK_ROT)
-#define G_SYSCLK_ROT(x) (((x) >> S_SYSCLK_ROT) & M_SYSCLK_ROT)
-
-#define S_BB_LOCK 7
-#define V_BB_LOCK(x) ((x) << S_BB_LOCK)
-#define F_BB_LOCK V_BB_LOCK(1U)
-
-#define S_SLEW_EARLY_SAMPLE 6
-#define V_SLEW_EARLY_SAMPLE(x) ((x) << S_SLEW_EARLY_SAMPLE)
-#define F_SLEW_EARLY_SAMPLE V_SLEW_EARLY_SAMPLE(1U)
-
-#define S_SLEW_DONE_STATUS 4
-#define M_SLEW_DONE_STATUS 0x3U
-#define V_SLEW_DONE_STATUS(x) ((x) << S_SLEW_DONE_STATUS)
-#define G_SLEW_DONE_STATUS(x) (((x) >> S_SLEW_DONE_STATUS) & M_SLEW_DONE_STATUS)
-
-#define S_SLEW_CNTL 0
-#define M_SLEW_CNTL 0xfU
-#define V_SLEW_CNTL(x) ((x) << S_SLEW_CNTL)
-#define G_SLEW_CNTL(x) (((x) >> S_SLEW_CNTL) & M_SLEW_CNTL)
-
-#define A_MC_DDRPHY_AD32S_SYSCLK_PR_VALUE_RO 0x460d0
-#define A_MC_DDRPHY_ADR_GMTEST_ATEST_CNTL 0x460d4
-
-#define S_FLUSH 15
-#define V_FLUSH(x) ((x) << S_FLUSH)
-#define F_FLUSH V_FLUSH(1U)
-
-#define S_GIANT_MUX_TEST_EN 14
-#define V_GIANT_MUX_TEST_EN(x) ((x) << S_GIANT_MUX_TEST_EN)
-#define F_GIANT_MUX_TEST_EN V_GIANT_MUX_TEST_EN(1U)
-
-#define S_GIANT_MUX_TEST_VAL 13
-#define V_GIANT_MUX_TEST_VAL(x) ((x) << S_GIANT_MUX_TEST_VAL)
-#define F_GIANT_MUX_TEST_VAL V_GIANT_MUX_TEST_VAL(1U)
-
-#define S_HS_PROBE_A_SEL_ 8
-#define M_HS_PROBE_A_SEL_ 0xfU
-#define V_HS_PROBE_A_SEL_(x) ((x) << S_HS_PROBE_A_SEL_)
-#define G_HS_PROBE_A_SEL_(x) (((x) >> S_HS_PROBE_A_SEL_) & M_HS_PROBE_A_SEL_)
-
-#define S_HS_PROBE_B_SEL_ 4
-#define M_HS_PROBE_B_SEL_ 0xfU
-#define V_HS_PROBE_B_SEL_(x) ((x) << S_HS_PROBE_B_SEL_)
-#define G_HS_PROBE_B_SEL_(x) (((x) >> S_HS_PROBE_B_SEL_) & M_HS_PROBE_B_SEL_)
-
-#define S_ATEST1CTL0 3
-#define V_ATEST1CTL0(x) ((x) << S_ATEST1CTL0)
-#define F_ATEST1CTL0 V_ATEST1CTL0(1U)
-
-#define S_ATEST1CTL1 2
-#define V_ATEST1CTL1(x) ((x) << S_ATEST1CTL1)
-#define F_ATEST1CTL1 V_ATEST1CTL1(1U)
-
-#define S_ATEST1CTL2 1
-#define V_ATEST1CTL2(x) ((x) << S_ATEST1CTL2)
-#define F_ATEST1CTL2 V_ATEST1CTL2(1U)
-
-#define S_ATEST1CTL3 0
-#define V_ATEST1CTL3(x) ((x) << S_ATEST1CTL3)
-#define F_ATEST1CTL3 V_ATEST1CTL3(1U)
-
-#define A_MC_DDRPHY_AD32S_OUTPUT_FORCE_ATEST_CNTL 0x460d4
-
-#define S_FORCE_EN 14
-#define V_FORCE_EN(x) ((x) << S_FORCE_EN)
-#define F_FORCE_EN V_FORCE_EN(1U)
-
-#define S_AD32S_HS_PROBE_A_SEL 8
-#define M_AD32S_HS_PROBE_A_SEL 0xfU
-#define V_AD32S_HS_PROBE_A_SEL(x) ((x) << S_AD32S_HS_PROBE_A_SEL)
-#define G_AD32S_HS_PROBE_A_SEL(x) (((x) >> S_AD32S_HS_PROBE_A_SEL) & M_AD32S_HS_PROBE_A_SEL)
-
-#define S_AD32S_HS_PROBE_B_SEL 4
-#define M_AD32S_HS_PROBE_B_SEL 0xfU
-#define V_AD32S_HS_PROBE_B_SEL(x) ((x) << S_AD32S_HS_PROBE_B_SEL)
-#define G_AD32S_HS_PROBE_B_SEL(x) (((x) >> S_AD32S_HS_PROBE_B_SEL) & M_AD32S_HS_PROBE_B_SEL)
-
-#define A_MC_DDRPHY_ADR_GIANT_MUX_RESULTS_A0 0x460d8
-
-#define S_GIANT_MUX_TEST_RESULTS 0
-#define M_GIANT_MUX_TEST_RESULTS 0xffffU
-#define V_GIANT_MUX_TEST_RESULTS(x) ((x) << S_GIANT_MUX_TEST_RESULTS)
-#define G_GIANT_MUX_TEST_RESULTS(x) (((x) >> S_GIANT_MUX_TEST_RESULTS) & M_GIANT_MUX_TEST_RESULTS)
-
-#define A_MC_DDRPHY_AD32S_OUTPUT_DRIVER_FORCE_VALUE0 0x460d8
-
-#define S_OUTPUT_DRIVER_FORCE_VALUE 0
-#define M_OUTPUT_DRIVER_FORCE_VALUE 0xffffU
-#define V_OUTPUT_DRIVER_FORCE_VALUE(x) ((x) << S_OUTPUT_DRIVER_FORCE_VALUE)
-#define G_OUTPUT_DRIVER_FORCE_VALUE(x) (((x) >> S_OUTPUT_DRIVER_FORCE_VALUE) & M_OUTPUT_DRIVER_FORCE_VALUE)
-
-#define A_MC_DDRPHY_ADR_GIANT_MUX_RESULTS_A1 0x460dc
-#define A_MC_DDRPHY_AD32S_OUTPUT_DRIVER_FORCE_VALUE1 0x460dc
-#define A_MC_DDRPHY_ADR_POWERDOWN_1 0x460e0
-
-#define S_MASTER_PD_CNTL 15
-#define V_MASTER_PD_CNTL(x) ((x) << S_MASTER_PD_CNTL)
-#define F_MASTER_PD_CNTL V_MASTER_PD_CNTL(1U)
-
-#define S_ANALOG_INPUT_STAB2 14
-#define V_ANALOG_INPUT_STAB2(x) ((x) << S_ANALOG_INPUT_STAB2)
-#define F_ANALOG_INPUT_STAB2 V_ANALOG_INPUT_STAB2(1U)
-
-#define S_ANALOG_INPUT_STAB1 8
-#define V_ANALOG_INPUT_STAB1(x) ((x) << S_ANALOG_INPUT_STAB1)
-#define F_ANALOG_INPUT_STAB1 V_ANALOG_INPUT_STAB1(1U)
-
-#define S_SYSCLK_CLK_GATE 6
-#define M_SYSCLK_CLK_GATE 0x3U
-#define V_SYSCLK_CLK_GATE(x) ((x) << S_SYSCLK_CLK_GATE)
-#define G_SYSCLK_CLK_GATE(x) (((x) >> S_SYSCLK_CLK_GATE) & M_SYSCLK_CLK_GATE)
-
-#define S_WR_FIFO_STAB 5
-#define V_WR_FIFO_STAB(x) ((x) << S_WR_FIFO_STAB)
-#define F_WR_FIFO_STAB V_WR_FIFO_STAB(1U)
-
-#define S_ADR_RX_PD 4
-#define V_ADR_RX_PD(x) ((x) << S_ADR_RX_PD)
-#define F_ADR_RX_PD V_ADR_RX_PD(1U)
-
-#define S_TX_TRISTATE_CNTL 1
-#define V_TX_TRISTATE_CNTL(x) ((x) << S_TX_TRISTATE_CNTL)
-#define F_TX_TRISTATE_CNTL V_TX_TRISTATE_CNTL(1U)
-
-#define S_DVCC_REG_PD 0
-#define V_DVCC_REG_PD(x) ((x) << S_DVCC_REG_PD)
-#define F_DVCC_REG_PD V_DVCC_REG_PD(1U)
-
-#define A_MC_DDRPHY_AD32S_POWERDOWN_1 0x460e0
-#define A_MC_DDRPHY_ADR_SLEW_CAL_CNTL 0x460e4
-
-#define S_SLEW_CAL_ENABLE 15
-#define V_SLEW_CAL_ENABLE(x) ((x) << S_SLEW_CAL_ENABLE)
-#define F_SLEW_CAL_ENABLE V_SLEW_CAL_ENABLE(1U)
-
-#define S_SLEW_CAL_START 14
-#define V_SLEW_CAL_START(x) ((x) << S_SLEW_CAL_START)
-#define F_SLEW_CAL_START V_SLEW_CAL_START(1U)
-
-#define S_SLEW_CAL_OVERRIDE_EN 12
-#define V_SLEW_CAL_OVERRIDE_EN(x) ((x) << S_SLEW_CAL_OVERRIDE_EN)
-#define F_SLEW_CAL_OVERRIDE_EN V_SLEW_CAL_OVERRIDE_EN(1U)
-
-#define S_SLEW_CAL_OVERRIDE 8
-#define M_SLEW_CAL_OVERRIDE 0xfU
-#define V_SLEW_CAL_OVERRIDE(x) ((x) << S_SLEW_CAL_OVERRIDE)
-#define G_SLEW_CAL_OVERRIDE(x) (((x) >> S_SLEW_CAL_OVERRIDE) & M_SLEW_CAL_OVERRIDE)
-
-#define S_SLEW_TARGET_PR_OFFSET 0
-#define M_SLEW_TARGET_PR_OFFSET 0x1fU
-#define V_SLEW_TARGET_PR_OFFSET(x) ((x) << S_SLEW_TARGET_PR_OFFSET)
-#define G_SLEW_TARGET_PR_OFFSET(x) (((x) >> S_SLEW_TARGET_PR_OFFSET) & M_SLEW_TARGET_PR_OFFSET)
-
-#define A_MC_DDRPHY_AD32S_SLEW_CAL_CNTL 0x460e4
-#define A_MC_DDRPHY_PC_DP18_PLL_LOCK_STATUS 0x47000
-
-#define S_DP18_PLL_LOCK 1
-#define M_DP18_PLL_LOCK 0x7fffU
-#define V_DP18_PLL_LOCK(x) ((x) << S_DP18_PLL_LOCK)
-#define G_DP18_PLL_LOCK(x) (((x) >> S_DP18_PLL_LOCK) & M_DP18_PLL_LOCK)
-
-#define A_MC_DDRPHY_PC_AD32S_PLL_LOCK_STATUS 0x47004
-
-#define S_AD32S_PLL_LOCK 14
-#define M_AD32S_PLL_LOCK 0x3U
-#define V_AD32S_PLL_LOCK(x) ((x) << S_AD32S_PLL_LOCK)
-#define G_AD32S_PLL_LOCK(x) (((x) >> S_AD32S_PLL_LOCK) & M_AD32S_PLL_LOCK)
-
-#define A_MC_DDRPHY_PC_RANK_PAIR0 0x47008
-
-#define S_RANK_PAIR0_PRI 13
-#define M_RANK_PAIR0_PRI 0x7U
-#define V_RANK_PAIR0_PRI(x) ((x) << S_RANK_PAIR0_PRI)
-#define G_RANK_PAIR0_PRI(x) (((x) >> S_RANK_PAIR0_PRI) & M_RANK_PAIR0_PRI)
-
-#define S_RANK_PAIR0_PRI_V 12
-#define V_RANK_PAIR0_PRI_V(x) ((x) << S_RANK_PAIR0_PRI_V)
-#define F_RANK_PAIR0_PRI_V V_RANK_PAIR0_PRI_V(1U)
-
-#define S_RANK_PAIR0_SEC 9
-#define M_RANK_PAIR0_SEC 0x7U
-#define V_RANK_PAIR0_SEC(x) ((x) << S_RANK_PAIR0_SEC)
-#define G_RANK_PAIR0_SEC(x) (((x) >> S_RANK_PAIR0_SEC) & M_RANK_PAIR0_SEC)
-
-#define S_RANK_PAIR0_SEC_V 8
-#define V_RANK_PAIR0_SEC_V(x) ((x) << S_RANK_PAIR0_SEC_V)
-#define F_RANK_PAIR0_SEC_V V_RANK_PAIR0_SEC_V(1U)
-
-#define S_RANK_PAIR1_PRI 5
-#define M_RANK_PAIR1_PRI 0x7U
-#define V_RANK_PAIR1_PRI(x) ((x) << S_RANK_PAIR1_PRI)
-#define G_RANK_PAIR1_PRI(x) (((x) >> S_RANK_PAIR1_PRI) & M_RANK_PAIR1_PRI)
-
-#define S_RANK_PAIR1_PRI_V 4
-#define V_RANK_PAIR1_PRI_V(x) ((x) << S_RANK_PAIR1_PRI_V)
-#define F_RANK_PAIR1_PRI_V V_RANK_PAIR1_PRI_V(1U)
-
-#define S_RANK_PAIR1_SEC 1
-#define M_RANK_PAIR1_SEC 0x7U
-#define V_RANK_PAIR1_SEC(x) ((x) << S_RANK_PAIR1_SEC)
-#define G_RANK_PAIR1_SEC(x) (((x) >> S_RANK_PAIR1_SEC) & M_RANK_PAIR1_SEC)
-
-#define S_RANK_PAIR1_SEC_V 0
-#define V_RANK_PAIR1_SEC_V(x) ((x) << S_RANK_PAIR1_SEC_V)
-#define F_RANK_PAIR1_SEC_V V_RANK_PAIR1_SEC_V(1U)
-
-#define A_MC_DDRPHY_PC_RANK_PAIR1 0x4700c
-
-#define S_RANK_PAIR2_PRI 13
-#define M_RANK_PAIR2_PRI 0x7U
-#define V_RANK_PAIR2_PRI(x) ((x) << S_RANK_PAIR2_PRI)
-#define G_RANK_PAIR2_PRI(x) (((x) >> S_RANK_PAIR2_PRI) & M_RANK_PAIR2_PRI)
-
-#define S_RANK_PAIR2_PRI_V 12
-#define V_RANK_PAIR2_PRI_V(x) ((x) << S_RANK_PAIR2_PRI_V)
-#define F_RANK_PAIR2_PRI_V V_RANK_PAIR2_PRI_V(1U)
-
-#define S_RANK_PAIR2_SEC 9
-#define M_RANK_PAIR2_SEC 0x7U
-#define V_RANK_PAIR2_SEC(x) ((x) << S_RANK_PAIR2_SEC)
-#define G_RANK_PAIR2_SEC(x) (((x) >> S_RANK_PAIR2_SEC) & M_RANK_PAIR2_SEC)
-
-#define S_RANK_PAIR2_SEC_V 8
-#define V_RANK_PAIR2_SEC_V(x) ((x) << S_RANK_PAIR2_SEC_V)
-#define F_RANK_PAIR2_SEC_V V_RANK_PAIR2_SEC_V(1U)
-
-#define S_RANK_PAIR3_PRI 5
-#define M_RANK_PAIR3_PRI 0x7U
-#define V_RANK_PAIR3_PRI(x) ((x) << S_RANK_PAIR3_PRI)
-#define G_RANK_PAIR3_PRI(x) (((x) >> S_RANK_PAIR3_PRI) & M_RANK_PAIR3_PRI)
-
-#define S_RANK_PAIR3_PRI_V 4
-#define V_RANK_PAIR3_PRI_V(x) ((x) << S_RANK_PAIR3_PRI_V)
-#define F_RANK_PAIR3_PRI_V V_RANK_PAIR3_PRI_V(1U)
-
-#define S_RANK_PAIR3_SEC 1
-#define M_RANK_PAIR3_SEC 0x7U
-#define V_RANK_PAIR3_SEC(x) ((x) << S_RANK_PAIR3_SEC)
-#define G_RANK_PAIR3_SEC(x) (((x) >> S_RANK_PAIR3_SEC) & M_RANK_PAIR3_SEC)
-
-#define S_RANK_PAIR3_SEC_V 0
-#define V_RANK_PAIR3_SEC_V(x) ((x) << S_RANK_PAIR3_SEC_V)
-#define F_RANK_PAIR3_SEC_V V_RANK_PAIR3_SEC_V(1U)
-
-#define A_MC_DDRPHY_PC_BASE_CNTR0 0x47010
-
-#define S_PERIODIC_BASE_CNTR0 0
-#define M_PERIODIC_BASE_CNTR0 0xffffU
-#define V_PERIODIC_BASE_CNTR0(x) ((x) << S_PERIODIC_BASE_CNTR0)
-#define G_PERIODIC_BASE_CNTR0(x) (((x) >> S_PERIODIC_BASE_CNTR0) & M_PERIODIC_BASE_CNTR0)
-
-#define A_MC_DDRPHY_PC_RELOAD_VALUE0 0x47014
-
-#define S_PERIODIC_CAL_REQ_EN 15
-#define V_PERIODIC_CAL_REQ_EN(x) ((x) << S_PERIODIC_CAL_REQ_EN)
-#define F_PERIODIC_CAL_REQ_EN V_PERIODIC_CAL_REQ_EN(1U)
-
-#define S_PERIODIC_RELOAD_VALUE0 0
-#define M_PERIODIC_RELOAD_VALUE0 0x7fffU
-#define V_PERIODIC_RELOAD_VALUE0(x) ((x) << S_PERIODIC_RELOAD_VALUE0)
-#define G_PERIODIC_RELOAD_VALUE0(x) (((x) >> S_PERIODIC_RELOAD_VALUE0) & M_PERIODIC_RELOAD_VALUE0)
-
-#define A_MC_DDRPHY_PC_BASE_CNTR1 0x47018
-
-#define S_PERIODIC_BASE_CNTR1 0
-#define M_PERIODIC_BASE_CNTR1 0xffffU
-#define V_PERIODIC_BASE_CNTR1(x) ((x) << S_PERIODIC_BASE_CNTR1)
-#define G_PERIODIC_BASE_CNTR1(x) (((x) >> S_PERIODIC_BASE_CNTR1) & M_PERIODIC_BASE_CNTR1)
-
-#define A_MC_DDRPHY_PC_CAL_TIMER 0x4701c
-
-#define S_PERIODIC_CAL_TIMER 0
-#define M_PERIODIC_CAL_TIMER 0xffffU
-#define V_PERIODIC_CAL_TIMER(x) ((x) << S_PERIODIC_CAL_TIMER)
-#define G_PERIODIC_CAL_TIMER(x) (((x) >> S_PERIODIC_CAL_TIMER) & M_PERIODIC_CAL_TIMER)
-
-#define A_MC_DDRPHY_PC_CAL_TIMER_RELOAD_VALUE 0x47020
-
-#define S_PERIODIC_TIMER_RELOAD_VALUE 0
-#define M_PERIODIC_TIMER_RELOAD_VALUE 0xffffU
-#define V_PERIODIC_TIMER_RELOAD_VALUE(x) ((x) << S_PERIODIC_TIMER_RELOAD_VALUE)
-#define G_PERIODIC_TIMER_RELOAD_VALUE(x) (((x) >> S_PERIODIC_TIMER_RELOAD_VALUE) & M_PERIODIC_TIMER_RELOAD_VALUE)
-
-#define A_MC_DDRPHY_PC_ZCAL_TIMER 0x47024
-
-#define S_PERIODIC_ZCAL_TIMER 0
-#define M_PERIODIC_ZCAL_TIMER 0xffffU
-#define V_PERIODIC_ZCAL_TIMER(x) ((x) << S_PERIODIC_ZCAL_TIMER)
-#define G_PERIODIC_ZCAL_TIMER(x) (((x) >> S_PERIODIC_ZCAL_TIMER) & M_PERIODIC_ZCAL_TIMER)
-
-#define A_MC_DDRPHY_PC_ZCAL_TIMER_RELOAD_VALUE 0x47028
-#define A_MC_DDRPHY_PC_PER_CAL_CONFIG 0x4702c
-
-#define S_PER_ENA_RANK_PAIR 12
-#define M_PER_ENA_RANK_PAIR 0xfU
-#define V_PER_ENA_RANK_PAIR(x) ((x) << S_PER_ENA_RANK_PAIR)
-#define G_PER_ENA_RANK_PAIR(x) (((x) >> S_PER_ENA_RANK_PAIR) & M_PER_ENA_RANK_PAIR)
-
-#define S_PER_ENA_ZCAL 11
-#define V_PER_ENA_ZCAL(x) ((x) << S_PER_ENA_ZCAL)
-#define F_PER_ENA_ZCAL V_PER_ENA_ZCAL(1U)
-
-#define S_PER_ENA_SYSCLK_ALIGN 10
-#define V_PER_ENA_SYSCLK_ALIGN(x) ((x) << S_PER_ENA_SYSCLK_ALIGN)
-#define F_PER_ENA_SYSCLK_ALIGN V_PER_ENA_SYSCLK_ALIGN(1U)
-
-#define S_ENA_PER_READ_CTR 9
-#define V_ENA_PER_READ_CTR(x) ((x) << S_ENA_PER_READ_CTR)
-#define F_ENA_PER_READ_CTR V_ENA_PER_READ_CTR(1U)
-
-#define S_ENA_PER_RDCLK_ALIGN 8
-#define V_ENA_PER_RDCLK_ALIGN(x) ((x) << S_ENA_PER_RDCLK_ALIGN)
-#define F_ENA_PER_RDCLK_ALIGN V_ENA_PER_RDCLK_ALIGN(1U)
-
-#define S_ENA_PER_DQS_ALIGN 7
-#define V_ENA_PER_DQS_ALIGN(x) ((x) << S_ENA_PER_DQS_ALIGN)
-#define F_ENA_PER_DQS_ALIGN V_ENA_PER_DQS_ALIGN(1U)
-
-#define S_PER_NEXT_RANK_PAIR 5
-#define M_PER_NEXT_RANK_PAIR 0x3U
-#define V_PER_NEXT_RANK_PAIR(x) ((x) << S_PER_NEXT_RANK_PAIR)
-#define G_PER_NEXT_RANK_PAIR(x) (((x) >> S_PER_NEXT_RANK_PAIR) & M_PER_NEXT_RANK_PAIR)
-
-#define S_FAST_SIM_PER_CNTR 4
-#define V_FAST_SIM_PER_CNTR(x) ((x) << S_FAST_SIM_PER_CNTR)
-#define F_FAST_SIM_PER_CNTR V_FAST_SIM_PER_CNTR(1U)
-
-#define S_START_INIT_CAL 3
-#define V_START_INIT_CAL(x) ((x) << S_START_INIT_CAL)
-#define F_START_INIT_CAL V_START_INIT_CAL(1U)
-
-#define S_START_PER_CAL 2
-#define V_START_PER_CAL(x) ((x) << S_START_PER_CAL)
-#define F_START_PER_CAL V_START_PER_CAL(1U)
-
-#define S_ABORT_ON_ERR_EN 1
-#define V_ABORT_ON_ERR_EN(x) ((x) << S_ABORT_ON_ERR_EN)
-#define F_ABORT_ON_ERR_EN V_ABORT_ON_ERR_EN(1U)
-
-#define S_ENA_PER_RD_CTR 9
-#define V_ENA_PER_RD_CTR(x) ((x) << S_ENA_PER_RD_CTR)
-#define F_ENA_PER_RD_CTR V_ENA_PER_RD_CTR(1U)
-
-#define A_MC_DDRPHY_PC_CONFIG0 0x47030
-
-#define S_PROTOCOL_DDR 12
-#define M_PROTOCOL_DDR 0xfU
-#define V_PROTOCOL_DDR(x) ((x) << S_PROTOCOL_DDR)
-#define G_PROTOCOL_DDR(x) (((x) >> S_PROTOCOL_DDR) & M_PROTOCOL_DDR)
-
-#define S_DATA_MUX4_1MODE 11
-#define V_DATA_MUX4_1MODE(x) ((x) << S_DATA_MUX4_1MODE)
-#define F_DATA_MUX4_1MODE V_DATA_MUX4_1MODE(1U)
-
-#define S_DDR4_CMD_SIG_REDUCTION 9
-#define V_DDR4_CMD_SIG_REDUCTION(x) ((x) << S_DDR4_CMD_SIG_REDUCTION)
-#define F_DDR4_CMD_SIG_REDUCTION V_DDR4_CMD_SIG_REDUCTION(1U)
-
-#define S_SYSCLK_2X_MEMINTCLKO 8
-#define V_SYSCLK_2X_MEMINTCLKO(x) ((x) << S_SYSCLK_2X_MEMINTCLKO)
-#define F_SYSCLK_2X_MEMINTCLKO V_SYSCLK_2X_MEMINTCLKO(1U)
-
-#define S_RANK_OVERRIDE 7
-#define V_RANK_OVERRIDE(x) ((x) << S_RANK_OVERRIDE)
-#define F_RANK_OVERRIDE V_RANK_OVERRIDE(1U)
-
-#define S_RANK_OVERRIDE_VALUE 4
-#define M_RANK_OVERRIDE_VALUE 0x7U
-#define V_RANK_OVERRIDE_VALUE(x) ((x) << S_RANK_OVERRIDE_VALUE)
-#define G_RANK_OVERRIDE_VALUE(x) (((x) >> S_RANK_OVERRIDE_VALUE) & M_RANK_OVERRIDE_VALUE)
-
-#define S_LOW_LATENCY 3
-#define V_LOW_LATENCY(x) ((x) << S_LOW_LATENCY)
-#define F_LOW_LATENCY V_LOW_LATENCY(1U)
-
-#define S_DDR4_BANK_REFRESH 2
-#define V_DDR4_BANK_REFRESH(x) ((x) << S_DDR4_BANK_REFRESH)
-#define F_DDR4_BANK_REFRESH V_DDR4_BANK_REFRESH(1U)
-
-#define S_DDR4_VLEVEL_BANK_GROUP 1
-#define V_DDR4_VLEVEL_BANK_GROUP(x) ((x) << S_DDR4_VLEVEL_BANK_GROUP)
-#define F_DDR4_VLEVEL_BANK_GROUP V_DDR4_VLEVEL_BANK_GROUP(1U)
-
-#define S_DDRPHY_PROTOCOL 12
-#define M_DDRPHY_PROTOCOL 0xfU
-#define V_DDRPHY_PROTOCOL(x) ((x) << S_DDRPHY_PROTOCOL)
-#define G_DDRPHY_PROTOCOL(x) (((x) >> S_DDRPHY_PROTOCOL) & M_DDRPHY_PROTOCOL)
-
-#define S_SPAM_EN 10
-#define V_SPAM_EN(x) ((x) << S_SPAM_EN)
-#define F_SPAM_EN V_SPAM_EN(1U)
-
-#define S_DDR4_IPW_LOOP_DIS 2
-#define V_DDR4_IPW_LOOP_DIS(x) ((x) << S_DDR4_IPW_LOOP_DIS)
-#define F_DDR4_IPW_LOOP_DIS V_DDR4_IPW_LOOP_DIS(1U)
-
-#define A_MC_DDRPHY_PC_CONFIG1 0x47034
-
-#define S_WRITE_LATENCY_OFFSET 12
-#define M_WRITE_LATENCY_OFFSET 0xfU
-#define V_WRITE_LATENCY_OFFSET(x) ((x) << S_WRITE_LATENCY_OFFSET)
-#define G_WRITE_LATENCY_OFFSET(x) (((x) >> S_WRITE_LATENCY_OFFSET) & M_WRITE_LATENCY_OFFSET)
-
-#define S_READ_LATENCY_OFFSET 8
-#define M_READ_LATENCY_OFFSET 0xfU
-#define V_READ_LATENCY_OFFSET(x) ((x) << S_READ_LATENCY_OFFSET)
-#define G_READ_LATENCY_OFFSET(x) (((x) >> S_READ_LATENCY_OFFSET) & M_READ_LATENCY_OFFSET)
-
-#define S_MEMCTL_CIC_FAST 7
-#define V_MEMCTL_CIC_FAST(x) ((x) << S_MEMCTL_CIC_FAST)
-#define F_MEMCTL_CIC_FAST V_MEMCTL_CIC_FAST(1U)
-
-#define S_MEMCTL_CTRN_IGNORE 6
-#define V_MEMCTL_CTRN_IGNORE(x) ((x) << S_MEMCTL_CTRN_IGNORE)
-#define F_MEMCTL_CTRN_IGNORE V_MEMCTL_CTRN_IGNORE(1U)
-
-#define S_DISABLE_MEMCTL_CAL 5
-#define V_DISABLE_MEMCTL_CAL(x) ((x) << S_DISABLE_MEMCTL_CAL)
-#define F_DISABLE_MEMCTL_CAL V_DISABLE_MEMCTL_CAL(1U)
-
-#define S_MEMCTL_CIS_IGNORE 6
-#define V_MEMCTL_CIS_IGNORE(x) ((x) << S_MEMCTL_CIS_IGNORE)
-#define F_MEMCTL_CIS_IGNORE V_MEMCTL_CIS_IGNORE(1U)
-
-#define S_MEMORY_TYPE 2
-#define M_MEMORY_TYPE 0x7U
-#define V_MEMORY_TYPE(x) ((x) << S_MEMORY_TYPE)
-#define G_MEMORY_TYPE(x) (((x) >> S_MEMORY_TYPE) & M_MEMORY_TYPE)
-
-#define S_DDR4_PDA_MODE 1
-#define V_DDR4_PDA_MODE(x) ((x) << S_DDR4_PDA_MODE)
-#define F_DDR4_PDA_MODE V_DDR4_PDA_MODE(1U)
-
-#define A_MC_DDRPHY_PC_RESETS 0x47038
-
-#define S_PLL_RESET 15
-#define V_PLL_RESET(x) ((x) << S_PLL_RESET)
-#define F_PLL_RESET V_PLL_RESET(1U)
-
-#define S_SYSCLK_RESET 14
-#define V_SYSCLK_RESET(x) ((x) << S_SYSCLK_RESET)
-#define F_SYSCLK_RESET V_SYSCLK_RESET(1U)
-
-#define A_MC_DDRPHY_PC_PER_ZCAL_CONFIG 0x4703c
-
-#define S_PER_ZCAL_ENA_RANK 8
-#define M_PER_ZCAL_ENA_RANK 0xffU
-#define V_PER_ZCAL_ENA_RANK(x) ((x) << S_PER_ZCAL_ENA_RANK)
-#define G_PER_ZCAL_ENA_RANK(x) (((x) >> S_PER_ZCAL_ENA_RANK) & M_PER_ZCAL_ENA_RANK)
-
-#define S_PER_ZCAL_NEXT_RANK 5
-#define M_PER_ZCAL_NEXT_RANK 0x7U
-#define V_PER_ZCAL_NEXT_RANK(x) ((x) << S_PER_ZCAL_NEXT_RANK)
-#define G_PER_ZCAL_NEXT_RANK(x) (((x) >> S_PER_ZCAL_NEXT_RANK) & M_PER_ZCAL_NEXT_RANK)
-
-#define S_START_PER_ZCAL 4
-#define V_START_PER_ZCAL(x) ((x) << S_START_PER_ZCAL)
-#define F_START_PER_ZCAL V_START_PER_ZCAL(1U)
-
-#define A_MC_DDRPHY_PC_RANK_GROUP 0x47044
-
-#define S_ADDR_MIRROR_RP0_PRI 15
-#define V_ADDR_MIRROR_RP0_PRI(x) ((x) << S_ADDR_MIRROR_RP0_PRI)
-#define F_ADDR_MIRROR_RP0_PRI V_ADDR_MIRROR_RP0_PRI(1U)
-
-#define S_ADDR_MIRROR_RP0_SEC 14
-#define V_ADDR_MIRROR_RP0_SEC(x) ((x) << S_ADDR_MIRROR_RP0_SEC)
-#define F_ADDR_MIRROR_RP0_SEC V_ADDR_MIRROR_RP0_SEC(1U)
-
-#define S_ADDR_MIRROR_RP1_PRI 13
-#define V_ADDR_MIRROR_RP1_PRI(x) ((x) << S_ADDR_MIRROR_RP1_PRI)
-#define F_ADDR_MIRROR_RP1_PRI V_ADDR_MIRROR_RP1_PRI(1U)
-
-#define S_ADDR_MIRROR_RP1_SEC 12
-#define V_ADDR_MIRROR_RP1_SEC(x) ((x) << S_ADDR_MIRROR_RP1_SEC)
-#define F_ADDR_MIRROR_RP1_SEC V_ADDR_MIRROR_RP1_SEC(1U)
-
-#define S_ADDR_MIRROR_RP2_PRI 11
-#define V_ADDR_MIRROR_RP2_PRI(x) ((x) << S_ADDR_MIRROR_RP2_PRI)
-#define F_ADDR_MIRROR_RP2_PRI V_ADDR_MIRROR_RP2_PRI(1U)
-
-#define S_ADDR_MIRROR_RP2_SEC 10
-#define V_ADDR_MIRROR_RP2_SEC(x) ((x) << S_ADDR_MIRROR_RP2_SEC)
-#define F_ADDR_MIRROR_RP2_SEC V_ADDR_MIRROR_RP2_SEC(1U)
-
-#define S_ADDR_MIRROR_RP3_PRI 9
-#define V_ADDR_MIRROR_RP3_PRI(x) ((x) << S_ADDR_MIRROR_RP3_PRI)
-#define F_ADDR_MIRROR_RP3_PRI V_ADDR_MIRROR_RP3_PRI(1U)
-
-#define S_ADDR_MIRROR_RP3_SEC 8
-#define V_ADDR_MIRROR_RP3_SEC(x) ((x) << S_ADDR_MIRROR_RP3_SEC)
-#define F_ADDR_MIRROR_RP3_SEC V_ADDR_MIRROR_RP3_SEC(1U)
-
-#define S_RANK_GROUPING 6
-#define M_RANK_GROUPING 0x3U
-#define V_RANK_GROUPING(x) ((x) << S_RANK_GROUPING)
-#define G_RANK_GROUPING(x) (((x) >> S_RANK_GROUPING) & M_RANK_GROUPING)
-
-#define S_ADDR_MIRROR_A3_A4 5
-#define V_ADDR_MIRROR_A3_A4(x) ((x) << S_ADDR_MIRROR_A3_A4)
-#define F_ADDR_MIRROR_A3_A4 V_ADDR_MIRROR_A3_A4(1U)
-
-#define S_ADDR_MIRROR_A5_A6 4
-#define V_ADDR_MIRROR_A5_A6(x) ((x) << S_ADDR_MIRROR_A5_A6)
-#define F_ADDR_MIRROR_A5_A6 V_ADDR_MIRROR_A5_A6(1U)
-
-#define S_ADDR_MIRROR_A7_A8 3
-#define V_ADDR_MIRROR_A7_A8(x) ((x) << S_ADDR_MIRROR_A7_A8)
-#define F_ADDR_MIRROR_A7_A8 V_ADDR_MIRROR_A7_A8(1U)
-
-#define S_ADDR_MIRROR_A11_A13 2
-#define V_ADDR_MIRROR_A11_A13(x) ((x) << S_ADDR_MIRROR_A11_A13)
-#define F_ADDR_MIRROR_A11_A13 V_ADDR_MIRROR_A11_A13(1U)
-
-#define S_ADDR_MIRROR_BA0_BA1 1
-#define V_ADDR_MIRROR_BA0_BA1(x) ((x) << S_ADDR_MIRROR_BA0_BA1)
-#define F_ADDR_MIRROR_BA0_BA1 V_ADDR_MIRROR_BA0_BA1(1U)
-
-#define S_ADDR_MIRROR_BG0_BG1 0
-#define V_ADDR_MIRROR_BG0_BG1(x) ((x) << S_ADDR_MIRROR_BG0_BG1)
-#define F_ADDR_MIRROR_BG0_BG1 V_ADDR_MIRROR_BG0_BG1(1U)
-
-#define A_MC_DDRPHY_PC_ERROR_STATUS0 0x47048
-
-#define S_RC_ERROR 15
-#define V_RC_ERROR(x) ((x) << S_RC_ERROR)
-#define F_RC_ERROR V_RC_ERROR(1U)
-
-#define S_WC_ERROR 14
-#define V_WC_ERROR(x) ((x) << S_WC_ERROR)
-#define F_WC_ERROR V_WC_ERROR(1U)
-
-#define S_SEQ_ERROR 13
-#define V_SEQ_ERROR(x) ((x) << S_SEQ_ERROR)
-#define F_SEQ_ERROR V_SEQ_ERROR(1U)
-
-#define S_CC_ERROR 12
-#define V_CC_ERROR(x) ((x) << S_CC_ERROR)
-#define F_CC_ERROR V_CC_ERROR(1U)
-
-#define S_APB_ERROR 11
-#define V_APB_ERROR(x) ((x) << S_APB_ERROR)
-#define F_APB_ERROR V_APB_ERROR(1U)
-
-#define S_PC_ERROR 10
-#define V_PC_ERROR(x) ((x) << S_PC_ERROR)
-#define F_PC_ERROR V_PC_ERROR(1U)
-
-#define A_MC_DDRPHY_PC_ERROR_MASK0 0x4704c
-
-#define S_RC_ERROR_MASK 15
-#define V_RC_ERROR_MASK(x) ((x) << S_RC_ERROR_MASK)
-#define F_RC_ERROR_MASK V_RC_ERROR_MASK(1U)
-
-#define S_WC_ERROR_MASK 14
-#define V_WC_ERROR_MASK(x) ((x) << S_WC_ERROR_MASK)
-#define F_WC_ERROR_MASK V_WC_ERROR_MASK(1U)
-
-#define S_SEQ_ERROR_MASK 13
-#define V_SEQ_ERROR_MASK(x) ((x) << S_SEQ_ERROR_MASK)
-#define F_SEQ_ERROR_MASK V_SEQ_ERROR_MASK(1U)
-
-#define S_CC_ERROR_MASK 12
-#define V_CC_ERROR_MASK(x) ((x) << S_CC_ERROR_MASK)
-#define F_CC_ERROR_MASK V_CC_ERROR_MASK(1U)
-
-#define S_APB_ERROR_MASK 11
-#define V_APB_ERROR_MASK(x) ((x) << S_APB_ERROR_MASK)
-#define F_APB_ERROR_MASK V_APB_ERROR_MASK(1U)
-
-#define S_PC_ERROR_MASK 10
-#define V_PC_ERROR_MASK(x) ((x) << S_PC_ERROR_MASK)
-#define F_PC_ERROR_MASK V_PC_ERROR_MASK(1U)
-
-#define A_MC_DDRPHY_PC_IO_PVT_FET_CONTROL 0x47050
-
-#define S_PVTP 11
-#define M_PVTP 0x1fU
-#define V_PVTP(x) ((x) << S_PVTP)
-#define G_PVTP(x) (((x) >> S_PVTP) & M_PVTP)
-
-#define S_PVTN 6
-#define M_PVTN 0x1fU
-#define V_PVTN(x) ((x) << S_PVTN)
-#define G_PVTN(x) (((x) >> S_PVTN) & M_PVTN)
-
-#define S_PVT_OVERRIDE 5
-#define V_PVT_OVERRIDE(x) ((x) << S_PVT_OVERRIDE)
-#define F_PVT_OVERRIDE V_PVT_OVERRIDE(1U)
-
-#define S_ENABLE_ZCAL 4
-#define V_ENABLE_ZCAL(x) ((x) << S_ENABLE_ZCAL)
-#define F_ENABLE_ZCAL V_ENABLE_ZCAL(1U)
-
-#define A_MC_DDRPHY_PC_VREF_DRV_CONTROL 0x47054
-
-#define S_VREFDQ0DSGN 15
-#define V_VREFDQ0DSGN(x) ((x) << S_VREFDQ0DSGN)
-#define F_VREFDQ0DSGN V_VREFDQ0DSGN(1U)
-
-#define S_VREFDQ0D 11
-#define M_VREFDQ0D 0xfU
-#define V_VREFDQ0D(x) ((x) << S_VREFDQ0D)
-#define G_VREFDQ0D(x) (((x) >> S_VREFDQ0D) & M_VREFDQ0D)
-
-#define S_VREFDQ1DSGN 10
-#define V_VREFDQ1DSGN(x) ((x) << S_VREFDQ1DSGN)
-#define F_VREFDQ1DSGN V_VREFDQ1DSGN(1U)
-
-#define S_VREFDQ1D 6
-#define M_VREFDQ1D 0xfU
-#define V_VREFDQ1D(x) ((x) << S_VREFDQ1D)
-#define G_VREFDQ1D(x) (((x) >> S_VREFDQ1D) & M_VREFDQ1D)
-
-#define S_EN_ANALOG_PD 3
-#define V_EN_ANALOG_PD(x) ((x) << S_EN_ANALOG_PD)
-#define F_EN_ANALOG_PD V_EN_ANALOG_PD(1U)
-
-#define S_ANALOG_PD_DLY 2
-#define V_ANALOG_PD_DLY(x) ((x) << S_ANALOG_PD_DLY)
-#define F_ANALOG_PD_DLY V_ANALOG_PD_DLY(1U)
-
-#define S_ANALOG_PD_DIV 0
-#define M_ANALOG_PD_DIV 0x3U
-#define V_ANALOG_PD_DIV(x) ((x) << S_ANALOG_PD_DIV)
-#define G_ANALOG_PD_DIV(x) (((x) >> S_ANALOG_PD_DIV) & M_ANALOG_PD_DIV)
-
-#define A_MC_DDRPHY_PC_INIT_CAL_CONFIG0 0x47058
-
-#define S_ENA_WR_LEVEL 15
-#define V_ENA_WR_LEVEL(x) ((x) << S_ENA_WR_LEVEL)
-#define F_ENA_WR_LEVEL V_ENA_WR_LEVEL(1U)
-
-#define S_ENA_INITIAL_PAT_WR 14
-#define V_ENA_INITIAL_PAT_WR(x) ((x) << S_ENA_INITIAL_PAT_WR)
-#define F_ENA_INITIAL_PAT_WR V_ENA_INITIAL_PAT_WR(1U)
-
-#define S_ENA_DQS_ALIGN 13
-#define V_ENA_DQS_ALIGN(x) ((x) << S_ENA_DQS_ALIGN)
-#define F_ENA_DQS_ALIGN V_ENA_DQS_ALIGN(1U)
-
-#define S_ENA_RDCLK_ALIGN 12
-#define V_ENA_RDCLK_ALIGN(x) ((x) << S_ENA_RDCLK_ALIGN)
-#define F_ENA_RDCLK_ALIGN V_ENA_RDCLK_ALIGN(1U)
-
-#define S_ENA_READ_CTR 11
-#define V_ENA_READ_CTR(x) ((x) << S_ENA_READ_CTR)
-#define F_ENA_READ_CTR V_ENA_READ_CTR(1U)
-
-#define S_ENA_WRITE_CTR 10
-#define V_ENA_WRITE_CTR(x) ((x) << S_ENA_WRITE_CTR)
-#define F_ENA_WRITE_CTR V_ENA_WRITE_CTR(1U)
-
-#define S_ENA_INITIAL_COARSE_WR 9
-#define V_ENA_INITIAL_COARSE_WR(x) ((x) << S_ENA_INITIAL_COARSE_WR)
-#define F_ENA_INITIAL_COARSE_WR V_ENA_INITIAL_COARSE_WR(1U)
-
-#define S_ENA_COARSE_RD 8
-#define V_ENA_COARSE_RD(x) ((x) << S_ENA_COARSE_RD)
-#define F_ENA_COARSE_RD V_ENA_COARSE_RD(1U)
-
-#define S_ENA_CUSTOM_RD 7
-#define V_ENA_CUSTOM_RD(x) ((x) << S_ENA_CUSTOM_RD)
-#define F_ENA_CUSTOM_RD V_ENA_CUSTOM_RD(1U)
-
-#define S_ENA_CUSTOM_WR 6
-#define V_ENA_CUSTOM_WR(x) ((x) << S_ENA_CUSTOM_WR)
-#define F_ENA_CUSTOM_WR V_ENA_CUSTOM_WR(1U)
-
-#define S_ABORT_ON_CAL_ERROR 5
-#define V_ABORT_ON_CAL_ERROR(x) ((x) << S_ABORT_ON_CAL_ERROR)
-#define F_ABORT_ON_CAL_ERROR V_ABORT_ON_CAL_ERROR(1U)
-
-#define S_ENA_DIGITAL_EYE 4
-#define V_ENA_DIGITAL_EYE(x) ((x) << S_ENA_DIGITAL_EYE)
-#define F_ENA_DIGITAL_EYE V_ENA_DIGITAL_EYE(1U)
-
-#define S_ENA_RANK_PAIR 0
-#define M_ENA_RANK_PAIR 0xfU
-#define V_ENA_RANK_PAIR(x) ((x) << S_ENA_RANK_PAIR)
-#define G_ENA_RANK_PAIR(x) (((x) >> S_ENA_RANK_PAIR) & M_ENA_RANK_PAIR)
-
-#define A_MC_DDRPHY_PC_INIT_CAL_CONFIG1 0x4705c
-
-#define S_REFRESH_COUNT 12
-#define M_REFRESH_COUNT 0xfU
-#define V_REFRESH_COUNT(x) ((x) << S_REFRESH_COUNT)
-#define G_REFRESH_COUNT(x) (((x) >> S_REFRESH_COUNT) & M_REFRESH_COUNT)
-
-#define S_REFRESH_CONTROL 10
-#define M_REFRESH_CONTROL 0x3U
-#define V_REFRESH_CONTROL(x) ((x) << S_REFRESH_CONTROL)
-#define G_REFRESH_CONTROL(x) (((x) >> S_REFRESH_CONTROL) & M_REFRESH_CONTROL)
-
-#define S_REFRESH_ALL_RANKS 9
-#define V_REFRESH_ALL_RANKS(x) ((x) << S_REFRESH_ALL_RANKS)
-#define F_REFRESH_ALL_RANKS V_REFRESH_ALL_RANKS(1U)
-
-#define S_REFRESH_INTERVAL 0
-#define M_REFRESH_INTERVAL 0x7fU
-#define V_REFRESH_INTERVAL(x) ((x) << S_REFRESH_INTERVAL)
-#define G_REFRESH_INTERVAL(x) (((x) >> S_REFRESH_INTERVAL) & M_REFRESH_INTERVAL)
-
-#define A_MC_DDRPHY_PC_INIT_CAL_ERROR 0x47060
-
-#define S_ERROR_WR_LEVEL 15
-#define V_ERROR_WR_LEVEL(x) ((x) << S_ERROR_WR_LEVEL)
-#define F_ERROR_WR_LEVEL V_ERROR_WR_LEVEL(1U)
-
-#define S_ERROR_INITIAL_PAT_WRITE 14
-#define V_ERROR_INITIAL_PAT_WRITE(x) ((x) << S_ERROR_INITIAL_PAT_WRITE)
-#define F_ERROR_INITIAL_PAT_WRITE V_ERROR_INITIAL_PAT_WRITE(1U)
-
-#define S_ERROR_DQS_ALIGN 13
-#define V_ERROR_DQS_ALIGN(x) ((x) << S_ERROR_DQS_ALIGN)
-#define F_ERROR_DQS_ALIGN V_ERROR_DQS_ALIGN(1U)
-
-#define S_ERROR_RDCLK_ALIGN 12
-#define V_ERROR_RDCLK_ALIGN(x) ((x) << S_ERROR_RDCLK_ALIGN)
-#define F_ERROR_RDCLK_ALIGN V_ERROR_RDCLK_ALIGN(1U)
-
-#define S_ERROR_READ_CTR 11
-#define V_ERROR_READ_CTR(x) ((x) << S_ERROR_READ_CTR)
-#define F_ERROR_READ_CTR V_ERROR_READ_CTR(1U)
-
-#define S_ERROR_WRITE_CTR 10
-#define V_ERROR_WRITE_CTR(x) ((x) << S_ERROR_WRITE_CTR)
-#define F_ERROR_WRITE_CTR V_ERROR_WRITE_CTR(1U)
-
-#define S_ERROR_INITIAL_COARSE_WR 9
-#define V_ERROR_INITIAL_COARSE_WR(x) ((x) << S_ERROR_INITIAL_COARSE_WR)
-#define F_ERROR_INITIAL_COARSE_WR V_ERROR_INITIAL_COARSE_WR(1U)
-
-#define S_ERROR_COARSE_RD 8
-#define V_ERROR_COARSE_RD(x) ((x) << S_ERROR_COARSE_RD)
-#define F_ERROR_COARSE_RD V_ERROR_COARSE_RD(1U)
-
-#define S_ERROR_CUSTOM_RD 7
-#define V_ERROR_CUSTOM_RD(x) ((x) << S_ERROR_CUSTOM_RD)
-#define F_ERROR_CUSTOM_RD V_ERROR_CUSTOM_RD(1U)
-
-#define S_ERROR_CUSTOM_WR 6
-#define V_ERROR_CUSTOM_WR(x) ((x) << S_ERROR_CUSTOM_WR)
-#define F_ERROR_CUSTOM_WR V_ERROR_CUSTOM_WR(1U)
-
-#define S_ERROR_DIGITAL_EYE 5
-#define V_ERROR_DIGITAL_EYE(x) ((x) << S_ERROR_DIGITAL_EYE)
-#define F_ERROR_DIGITAL_EYE V_ERROR_DIGITAL_EYE(1U)
-
-#define S_ERROR_RANK_PAIR 0
-#define M_ERROR_RANK_PAIR 0xfU
-#define V_ERROR_RANK_PAIR(x) ((x) << S_ERROR_RANK_PAIR)
-#define G_ERROR_RANK_PAIR(x) (((x) >> S_ERROR_RANK_PAIR) & M_ERROR_RANK_PAIR)
-
-#define A_MC_DDRPHY_PC_INIT_CAL_STATUS 0x47064
-
-#define S_INIT_CAL_COMPLETE 12
-#define M_INIT_CAL_COMPLETE 0xfU
-#define V_INIT_CAL_COMPLETE(x) ((x) << S_INIT_CAL_COMPLETE)
-#define G_INIT_CAL_COMPLETE(x) (((x) >> S_INIT_CAL_COMPLETE) & M_INIT_CAL_COMPLETE)
-
-#define S_PER_CAL_ABORT 6
-#define V_PER_CAL_ABORT(x) ((x) << S_PER_CAL_ABORT)
-#define F_PER_CAL_ABORT V_PER_CAL_ABORT(1U)
-
-#define A_MC_DDRPHY_PC_INIT_CAL_MASK 0x47068
-
-#define S_ERROR_WR_LEVEL_MASK 15
-#define V_ERROR_WR_LEVEL_MASK(x) ((x) << S_ERROR_WR_LEVEL_MASK)
-#define F_ERROR_WR_LEVEL_MASK V_ERROR_WR_LEVEL_MASK(1U)
-
-#define S_ERROR_INITIAL_PAT_WRITE_MASK 14
-#define V_ERROR_INITIAL_PAT_WRITE_MASK(x) ((x) << S_ERROR_INITIAL_PAT_WRITE_MASK)
-#define F_ERROR_INITIAL_PAT_WRITE_MASK V_ERROR_INITIAL_PAT_WRITE_MASK(1U)
-
-#define S_ERROR_DQS_ALIGN_MASK 13
-#define V_ERROR_DQS_ALIGN_MASK(x) ((x) << S_ERROR_DQS_ALIGN_MASK)
-#define F_ERROR_DQS_ALIGN_MASK V_ERROR_DQS_ALIGN_MASK(1U)
-
-#define S_ERROR_RDCLK_ALIGN_MASK 12
-#define V_ERROR_RDCLK_ALIGN_MASK(x) ((x) << S_ERROR_RDCLK_ALIGN_MASK)
-#define F_ERROR_RDCLK_ALIGN_MASK V_ERROR_RDCLK_ALIGN_MASK(1U)
-
-#define S_ERROR_READ_CTR_MASK 11
-#define V_ERROR_READ_CTR_MASK(x) ((x) << S_ERROR_READ_CTR_MASK)
-#define F_ERROR_READ_CTR_MASK V_ERROR_READ_CTR_MASK(1U)
-
-#define S_ERROR_WRITE_CTR_MASK 10
-#define V_ERROR_WRITE_CTR_MASK(x) ((x) << S_ERROR_WRITE_CTR_MASK)
-#define F_ERROR_WRITE_CTR_MASK V_ERROR_WRITE_CTR_MASK(1U)
-
-#define S_ERROR_INITIAL_COARSE_WR_MASK 9
-#define V_ERROR_INITIAL_COARSE_WR_MASK(x) ((x) << S_ERROR_INITIAL_COARSE_WR_MASK)
-#define F_ERROR_INITIAL_COARSE_WR_MASK V_ERROR_INITIAL_COARSE_WR_MASK(1U)
-
-#define S_ERROR_COARSE_RD_MASK 8
-#define V_ERROR_COARSE_RD_MASK(x) ((x) << S_ERROR_COARSE_RD_MASK)
-#define F_ERROR_COARSE_RD_MASK V_ERROR_COARSE_RD_MASK(1U)
-
-#define S_ERROR_CUSTOM_RD_MASK 7
-#define V_ERROR_CUSTOM_RD_MASK(x) ((x) << S_ERROR_CUSTOM_RD_MASK)
-#define F_ERROR_CUSTOM_RD_MASK V_ERROR_CUSTOM_RD_MASK(1U)
-
-#define S_ERROR_CUSTOM_WR_MASK 6
-#define V_ERROR_CUSTOM_WR_MASK(x) ((x) << S_ERROR_CUSTOM_WR_MASK)
-#define F_ERROR_CUSTOM_WR_MASK V_ERROR_CUSTOM_WR_MASK(1U)
-
-#define S_ERROR_DIGITAL_EYE_MASK 5
-#define V_ERROR_DIGITAL_EYE_MASK(x) ((x) << S_ERROR_DIGITAL_EYE_MASK)
-#define F_ERROR_DIGITAL_EYE_MASK V_ERROR_DIGITAL_EYE_MASK(1U)
-
-#define A_MC_DDRPHY_PC_IO_PVT_FET_STATUS 0x4706c
-#define A_MC_DDRPHY_PC_MR0_PRI_RP 0x47070
-
-#define S_MODEREGISTER0VALUE 0
-#define M_MODEREGISTER0VALUE 0xffffU
-#define V_MODEREGISTER0VALUE(x) ((x) << S_MODEREGISTER0VALUE)
-#define G_MODEREGISTER0VALUE(x) (((x) >> S_MODEREGISTER0VALUE) & M_MODEREGISTER0VALUE)
-
-#define A_MC_DDRPHY_PC_MR1_PRI_RP 0x47074
-
-#define S_MODEREGISTER1VALUE 0
-#define M_MODEREGISTER1VALUE 0xffffU
-#define V_MODEREGISTER1VALUE(x) ((x) << S_MODEREGISTER1VALUE)
-#define G_MODEREGISTER1VALUE(x) (((x) >> S_MODEREGISTER1VALUE) & M_MODEREGISTER1VALUE)
-
-#define A_MC_DDRPHY_PC_MR2_PRI_RP 0x47078
-
-#define S_MODEREGISTER2VALUE 0
-#define M_MODEREGISTER2VALUE 0xffffU
-#define V_MODEREGISTER2VALUE(x) ((x) << S_MODEREGISTER2VALUE)
-#define G_MODEREGISTER2VALUE(x) (((x) >> S_MODEREGISTER2VALUE) & M_MODEREGISTER2VALUE)
-
-#define A_MC_DDRPHY_PC_MR3_PRI_RP 0x4707c
-
-#define S_MODEREGISTER3VALUE 0
-#define M_MODEREGISTER3VALUE 0xffffU
-#define V_MODEREGISTER3VALUE(x) ((x) << S_MODEREGISTER3VALUE)
-#define G_MODEREGISTER3VALUE(x) (((x) >> S_MODEREGISTER3VALUE) & M_MODEREGISTER3VALUE)
-
-#define A_MC_DDRPHY_PC_MR0_SEC_RP 0x47080
-#define A_MC_DDRPHY_PC_MR1_SEC_RP 0x47084
-#define A_MC_DDRPHY_PC_MR2_SEC_RP 0x47088
-#define A_MC_DDRPHY_PC_MR3_SEC_RP 0x4708c
-
-#define S_MODE_REGISTER_3_VALUE 0
-#define M_MODE_REGISTER_3_VALUE 0xffffU
-#define V_MODE_REGISTER_3_VALUE(x) ((x) << S_MODE_REGISTER_3_VALUE)
-#define G_MODE_REGISTER_3_VALUE(x) (((x) >> S_MODE_REGISTER_3_VALUE) & M_MODE_REGISTER_3_VALUE)
-
-#define A_MC_DDRPHY_SEQ_RD_WR_DATA0 0x47200
-
-#define S_DRD_WR_DATA_REG 0
-#define M_DRD_WR_DATA_REG 0xffffU
-#define V_DRD_WR_DATA_REG(x) ((x) << S_DRD_WR_DATA_REG)
-#define G_DRD_WR_DATA_REG(x) (((x) >> S_DRD_WR_DATA_REG) & M_DRD_WR_DATA_REG)
-
-#define A_MC_DDRPHY_SEQ_RD_WR_DATA1 0x47204
-#define A_MC_DDRPHY_SEQ_CONFIG0 0x47208
-
-#define S_MPR_PATTERN_BIT 15
-#define V_MPR_PATTERN_BIT(x) ((x) << S_MPR_PATTERN_BIT)
-#define F_MPR_PATTERN_BIT V_MPR_PATTERN_BIT(1U)
-
-#define S_TWO_CYCLE_ADDR_EN 14
-#define V_TWO_CYCLE_ADDR_EN(x) ((x) << S_TWO_CYCLE_ADDR_EN)
-#define F_TWO_CYCLE_ADDR_EN V_TWO_CYCLE_ADDR_EN(1U)
-
-#define S_MR_MASK_EN 10
-#define M_MR_MASK_EN 0xfU
-#define V_MR_MASK_EN(x) ((x) << S_MR_MASK_EN)
-#define G_MR_MASK_EN(x) (((x) >> S_MR_MASK_EN) & M_MR_MASK_EN)
-
-#define S_PARITY_DLY 9
-#define V_PARITY_DLY(x) ((x) << S_PARITY_DLY)
-#define F_PARITY_DLY V_PARITY_DLY(1U)
-
-#define S_FORCE_RESERVED 7
-#define V_FORCE_RESERVED(x) ((x) << S_FORCE_RESERVED)
-#define F_FORCE_RESERVED V_FORCE_RESERVED(1U)
-
-#define S_HALT_ROTATION 6
-#define V_HALT_ROTATION(x) ((x) << S_HALT_ROTATION)
-#define F_HALT_ROTATION V_HALT_ROTATION(1U)
-
-#define S_FORCE_MPR 5
-#define V_FORCE_MPR(x) ((x) << S_FORCE_MPR)
-#define F_FORCE_MPR V_FORCE_MPR(1U)
-
-#define S_IPW_SIDEAB_SEL 2
-#define V_IPW_SIDEAB_SEL(x) ((x) << S_IPW_SIDEAB_SEL)
-#define F_IPW_SIDEAB_SEL V_IPW_SIDEAB_SEL(1U)
-
-#define S_PARITY_A17_MASK 1
-#define V_PARITY_A17_MASK(x) ((x) << S_PARITY_A17_MASK)
-#define F_PARITY_A17_MASK V_PARITY_A17_MASK(1U)
-
-#define S_X16_DEVICE 0
-#define V_X16_DEVICE(x) ((x) << S_X16_DEVICE)
-#define F_X16_DEVICE V_X16_DEVICE(1U)
-
-#define A_MC_DDRPHY_SEQ_RESERVED_ADDR0 0x4720c
-#define A_MC_DDRPHY_SEQ_RESERVED_ADDR1 0x47210
-#define A_MC_DDRPHY_SEQ_RESERVED_ADDR2 0x47214
-#define A_MC_DDRPHY_SEQ_RESERVED_ADDR3 0x47218
-#define A_MC_DDRPHY_SEQ_RESERVED_ADDR4 0x4721c
-#define A_MC_DDRPHY_SEQ_ERROR_STATUS0 0x47220
-
-#define S_MULTIPLE_REQ_ERROR 15
-#define V_MULTIPLE_REQ_ERROR(x) ((x) << S_MULTIPLE_REQ_ERROR)
-#define F_MULTIPLE_REQ_ERROR V_MULTIPLE_REQ_ERROR(1U)
-
-#define S_INVALID_REQTYPE_ERRO 14
-#define V_INVALID_REQTYPE_ERRO(x) ((x) << S_INVALID_REQTYPE_ERRO)
-#define F_INVALID_REQTYPE_ERRO V_INVALID_REQTYPE_ERRO(1U)
-
-#define S_EARLY_REQ_ERROR 13
-#define V_EARLY_REQ_ERROR(x) ((x) << S_EARLY_REQ_ERROR)
-#define F_EARLY_REQ_ERROR V_EARLY_REQ_ERROR(1U)
-
-#define S_MULTIPLE_REQ_SOURCE 10
-#define M_MULTIPLE_REQ_SOURCE 0x7U
-#define V_MULTIPLE_REQ_SOURCE(x) ((x) << S_MULTIPLE_REQ_SOURCE)
-#define G_MULTIPLE_REQ_SOURCE(x) (((x) >> S_MULTIPLE_REQ_SOURCE) & M_MULTIPLE_REQ_SOURCE)
-
-#define S_INVALID_REQTYPE 6
-#define M_INVALID_REQTYPE 0xfU
-#define V_INVALID_REQTYPE(x) ((x) << S_INVALID_REQTYPE)
-#define G_INVALID_REQTYPE(x) (((x) >> S_INVALID_REQTYPE) & M_INVALID_REQTYPE)
-
-#define S_INVALID_REQ_SOURCE 3
-#define M_INVALID_REQ_SOURCE 0x7U
-#define V_INVALID_REQ_SOURCE(x) ((x) << S_INVALID_REQ_SOURCE)
-#define G_INVALID_REQ_SOURCE(x) (((x) >> S_INVALID_REQ_SOURCE) & M_INVALID_REQ_SOURCE)
-
-#define S_EARLY_REQ_SOURCE 0
-#define M_EARLY_REQ_SOURCE 0x7U
-#define V_EARLY_REQ_SOURCE(x) ((x) << S_EARLY_REQ_SOURCE)
-#define G_EARLY_REQ_SOURCE(x) (((x) >> S_EARLY_REQ_SOURCE) & M_EARLY_REQ_SOURCE)
-
-#define A_MC_DDRPHY_SEQ_ERROR_MASK0 0x47224
-
-#define S_MULT_REQ_ERR_MASK 15
-#define V_MULT_REQ_ERR_MASK(x) ((x) << S_MULT_REQ_ERR_MASK)
-#define F_MULT_REQ_ERR_MASK V_MULT_REQ_ERR_MASK(1U)
-
-#define S_INVALID_REQTYPE_ERR_MASK 14
-#define V_INVALID_REQTYPE_ERR_MASK(x) ((x) << S_INVALID_REQTYPE_ERR_MASK)
-#define F_INVALID_REQTYPE_ERR_MASK V_INVALID_REQTYPE_ERR_MASK(1U)
-
-#define S_EARLY_REQ_ERR_MASK 13
-#define V_EARLY_REQ_ERR_MASK(x) ((x) << S_EARLY_REQ_ERR_MASK)
-#define F_EARLY_REQ_ERR_MASK V_EARLY_REQ_ERR_MASK(1U)
-
-#define A_MC_DDRPHY_SEQ_ODT_WR_CONFIG0 0x47228
-
-#define S_ODT_WR_VALUES_BITS0_7 8
-#define M_ODT_WR_VALUES_BITS0_7 0xffU
-#define V_ODT_WR_VALUES_BITS0_7(x) ((x) << S_ODT_WR_VALUES_BITS0_7)
-#define G_ODT_WR_VALUES_BITS0_7(x) (((x) >> S_ODT_WR_VALUES_BITS0_7) & M_ODT_WR_VALUES_BITS0_7)
-
-#define S_ODT_WR_VALUES_BITS8_15 0
-#define M_ODT_WR_VALUES_BITS8_15 0xffU
-#define V_ODT_WR_VALUES_BITS8_15(x) ((x) << S_ODT_WR_VALUES_BITS8_15)
-#define G_ODT_WR_VALUES_BITS8_15(x) (((x) >> S_ODT_WR_VALUES_BITS8_15) & M_ODT_WR_VALUES_BITS8_15)
-
-#define A_MC_DDRPHY_SEQ_ODT_WR_CONFIG1 0x4722c
-#define A_MC_DDRPHY_SEQ_ODT_WR_CONFIG2 0x47230
-#define A_MC_DDRPHY_SEQ_ODT_WR_CONFIG3 0x47234
-#define A_MC_DDRPHY_SEQ_ODT_RD_CONFIG0 0x47238
-
-#define S_ODT_RD_VALUES_X2 8
-#define M_ODT_RD_VALUES_X2 0xffU
-#define V_ODT_RD_VALUES_X2(x) ((x) << S_ODT_RD_VALUES_X2)
-#define G_ODT_RD_VALUES_X2(x) (((x) >> S_ODT_RD_VALUES_X2) & M_ODT_RD_VALUES_X2)
-
-#define S_ODT_RD_VALUES_X2PLUS1 0
-#define M_ODT_RD_VALUES_X2PLUS1 0xffU
-#define V_ODT_RD_VALUES_X2PLUS1(x) ((x) << S_ODT_RD_VALUES_X2PLUS1)
-#define G_ODT_RD_VALUES_X2PLUS1(x) (((x) >> S_ODT_RD_VALUES_X2PLUS1) & M_ODT_RD_VALUES_X2PLUS1)
-
-#define A_MC_DDRPHY_SEQ_ODT_RD_CONFIG1 0x4723c
-#define A_MC_DDRPHY_SEQ_ODT_RD_CONFIG2 0x47240
-#define A_MC_DDRPHY_SEQ_ODT_RD_CONFIG3 0x47244
-#define A_MC_DDRPHY_SEQ_MEM_TIMING_PARAM0 0x47248
-
-#define S_TMOD_CYCLES 12
-#define M_TMOD_CYCLES 0xfU
-#define V_TMOD_CYCLES(x) ((x) << S_TMOD_CYCLES)
-#define G_TMOD_CYCLES(x) (((x) >> S_TMOD_CYCLES) & M_TMOD_CYCLES)
-
-#define S_TRCD_CYCLES 8
-#define M_TRCD_CYCLES 0xfU
-#define V_TRCD_CYCLES(x) ((x) << S_TRCD_CYCLES)
-#define G_TRCD_CYCLES(x) (((x) >> S_TRCD_CYCLES) & M_TRCD_CYCLES)
-
-#define S_TRP_CYCLES 4
-#define M_TRP_CYCLES 0xfU
-#define V_TRP_CYCLES(x) ((x) << S_TRP_CYCLES)
-#define G_TRP_CYCLES(x) (((x) >> S_TRP_CYCLES) & M_TRP_CYCLES)
-
-#define S_TRFC_CYCLES 0
-#define M_TRFC_CYCLES 0xfU
-#define V_TRFC_CYCLES(x) ((x) << S_TRFC_CYCLES)
-#define G_TRFC_CYCLES(x) (((x) >> S_TRFC_CYCLES) & M_TRFC_CYCLES)
-
-#define A_MC_DDRPHY_SEQ_MEM_TIMING_PARAM1 0x4724c
-
-#define S_TZQINIT_CYCLES 12
-#define M_TZQINIT_CYCLES 0xfU
-#define V_TZQINIT_CYCLES(x) ((x) << S_TZQINIT_CYCLES)
-#define G_TZQINIT_CYCLES(x) (((x) >> S_TZQINIT_CYCLES) & M_TZQINIT_CYCLES)
-
-#define S_TZQCS_CYCLES 8
-#define M_TZQCS_CYCLES 0xfU
-#define V_TZQCS_CYCLES(x) ((x) << S_TZQCS_CYCLES)
-#define G_TZQCS_CYCLES(x) (((x) >> S_TZQCS_CYCLES) & M_TZQCS_CYCLES)
-
-#define S_TWLDQSEN_CYCLES 4
-#define M_TWLDQSEN_CYCLES 0xfU
-#define V_TWLDQSEN_CYCLES(x) ((x) << S_TWLDQSEN_CYCLES)
-#define G_TWLDQSEN_CYCLES(x) (((x) >> S_TWLDQSEN_CYCLES) & M_TWLDQSEN_CYCLES)
-
-#define S_TWRMRD_CYCLES 0
-#define M_TWRMRD_CYCLES 0xfU
-#define V_TWRMRD_CYCLES(x) ((x) << S_TWRMRD_CYCLES)
-#define G_TWRMRD_CYCLES(x) (((x) >> S_TWRMRD_CYCLES) & M_TWRMRD_CYCLES)
-
-#define A_MC_DDRPHY_SEQ_MEM_TIMING_PARAM2 0x47250
-
-#define S_TODTLON_OFF_CYCLES 12
-#define M_TODTLON_OFF_CYCLES 0xfU
-#define V_TODTLON_OFF_CYCLES(x) ((x) << S_TODTLON_OFF_CYCLES)
-#define G_TODTLON_OFF_CYCLES(x) (((x) >> S_TODTLON_OFF_CYCLES) & M_TODTLON_OFF_CYCLES)
-
-#define S_TRC_CYCLES 8
-#define M_TRC_CYCLES 0xfU
-#define V_TRC_CYCLES(x) ((x) << S_TRC_CYCLES)
-#define G_TRC_CYCLES(x) (((x) >> S_TRC_CYCLES) & M_TRC_CYCLES)
-
-#define S_TMRSC_CYCLES 4
-#define M_TMRSC_CYCLES 0xfU
-#define V_TMRSC_CYCLES(x) ((x) << S_TMRSC_CYCLES)
-#define G_TMRSC_CYCLES(x) (((x) >> S_TMRSC_CYCLES) & M_TMRSC_CYCLES)
-
-#define S_MRS_CMD_SPACE 0
-#define M_MRS_CMD_SPACE 0xfU
-#define V_MRS_CMD_SPACE(x) ((x) << S_MRS_CMD_SPACE)
-#define G_MRS_CMD_SPACE(x) (((x) >> S_MRS_CMD_SPACE) & M_MRS_CMD_SPACE)
-
-#define A_MC_DDRPHY_RC_CONFIG0 0x47400
-
-#define S_GLOBAL_PHY_OFFSET 12
-#define M_GLOBAL_PHY_OFFSET 0xfU
-#define V_GLOBAL_PHY_OFFSET(x) ((x) << S_GLOBAL_PHY_OFFSET)
-#define G_GLOBAL_PHY_OFFSET(x) (((x) >> S_GLOBAL_PHY_OFFSET) & M_GLOBAL_PHY_OFFSET)
-
-#define S_ADVANCE_RD_VALID 11
-#define V_ADVANCE_RD_VALID(x) ((x) << S_ADVANCE_RD_VALID)
-#define F_ADVANCE_RD_VALID V_ADVANCE_RD_VALID(1U)
-
-#define S_SINGLE_BIT_MPR_RP0 6
-#define V_SINGLE_BIT_MPR_RP0(x) ((x) << S_SINGLE_BIT_MPR_RP0)
-#define F_SINGLE_BIT_MPR_RP0 V_SINGLE_BIT_MPR_RP0(1U)
-
-#define S_SINGLE_BIT_MPR_RP1 5
-#define V_SINGLE_BIT_MPR_RP1(x) ((x) << S_SINGLE_BIT_MPR_RP1)
-#define F_SINGLE_BIT_MPR_RP1 V_SINGLE_BIT_MPR_RP1(1U)
-
-#define S_SINGLE_BIT_MPR_RP2 4
-#define V_SINGLE_BIT_MPR_RP2(x) ((x) << S_SINGLE_BIT_MPR_RP2)
-#define F_SINGLE_BIT_MPR_RP2 V_SINGLE_BIT_MPR_RP2(1U)
-
-#define S_SINGLE_BIT_MPR_RP3 3
-#define V_SINGLE_BIT_MPR_RP3(x) ((x) << S_SINGLE_BIT_MPR_RP3)
-#define F_SINGLE_BIT_MPR_RP3 V_SINGLE_BIT_MPR_RP3(1U)
-
-#define S_ALIGN_ON_EVEN_CYCLES 2
-#define V_ALIGN_ON_EVEN_CYCLES(x) ((x) << S_ALIGN_ON_EVEN_CYCLES)
-#define F_ALIGN_ON_EVEN_CYCLES V_ALIGN_ON_EVEN_CYCLES(1U)
-
-#define S_PERFORM_RDCLK_ALIGN 1
-#define V_PERFORM_RDCLK_ALIGN(x) ((x) << S_PERFORM_RDCLK_ALIGN)
-#define F_PERFORM_RDCLK_ALIGN V_PERFORM_RDCLK_ALIGN(1U)
-
-#define S_STAGGERED_PATTERN 0
-#define V_STAGGERED_PATTERN(x) ((x) << S_STAGGERED_PATTERN)
-#define F_STAGGERED_PATTERN V_STAGGERED_PATTERN(1U)
-
-#define S_ERS_MODE 10
-#define V_ERS_MODE(x) ((x) << S_ERS_MODE)
-#define F_ERS_MODE V_ERS_MODE(1U)
-
-#define A_MC_DDRPHY_RC_CONFIG1 0x47404
-
-#define S_OUTER_LOOP_CNT 2
-#define M_OUTER_LOOP_CNT 0x3fffU
-#define V_OUTER_LOOP_CNT(x) ((x) << S_OUTER_LOOP_CNT)
-#define G_OUTER_LOOP_CNT(x) (((x) >> S_OUTER_LOOP_CNT) & M_OUTER_LOOP_CNT)
-
-#define A_MC_DDRPHY_RC_CONFIG2 0x47408
-
-#define S_CONSEQ_PASS 11
-#define M_CONSEQ_PASS 0x1fU
-#define V_CONSEQ_PASS(x) ((x) << S_CONSEQ_PASS)
-#define G_CONSEQ_PASS(x) (((x) >> S_CONSEQ_PASS) & M_CONSEQ_PASS)
-
-#define S_BURST_WINDOW 5
-#define M_BURST_WINDOW 0x3U
-#define V_BURST_WINDOW(x) ((x) << S_BURST_WINDOW)
-#define G_BURST_WINDOW(x) (((x) >> S_BURST_WINDOW) & M_BURST_WINDOW)
-
-#define S_ALLOW_RD_FIFO_AUTO_R_ESET 4
-#define V_ALLOW_RD_FIFO_AUTO_R_ESET(x) ((x) << S_ALLOW_RD_FIFO_AUTO_R_ESET)
-#define F_ALLOW_RD_FIFO_AUTO_R_ESET V_ALLOW_RD_FIFO_AUTO_R_ESET(1U)
-
-#define S_DIS_LOW_PWR_PER_CAL 3
-#define V_DIS_LOW_PWR_PER_CAL(x) ((x) << S_DIS_LOW_PWR_PER_CAL)
-#define F_DIS_LOW_PWR_PER_CAL V_DIS_LOW_PWR_PER_CAL(1U)
-
-#define A_MC_DDRPHY_RC_ERROR_STATUS0 0x47414
-
-#define S_RD_CNTL_ERROR 15
-#define V_RD_CNTL_ERROR(x) ((x) << S_RD_CNTL_ERROR)
-#define F_RD_CNTL_ERROR V_RD_CNTL_ERROR(1U)
-
-#define A_MC_DDRPHY_RC_ERROR_MASK0 0x47418
-
-#define S_RD_CNTL_ERROR_MASK 15
-#define V_RD_CNTL_ERROR_MASK(x) ((x) << S_RD_CNTL_ERROR_MASK)
-#define F_RD_CNTL_ERROR_MASK V_RD_CNTL_ERROR_MASK(1U)
-
-#define A_MC_DDRPHY_RC_CONFIG3 0x4741c
-
-#define S_FINE_CAL_STEP_SIZE 13
-#define M_FINE_CAL_STEP_SIZE 0x7U
-#define V_FINE_CAL_STEP_SIZE(x) ((x) << S_FINE_CAL_STEP_SIZE)
-#define G_FINE_CAL_STEP_SIZE(x) (((x) >> S_FINE_CAL_STEP_SIZE) & M_FINE_CAL_STEP_SIZE)
-
-#define S_COARSE_CAL_STEP_SIZE 9
-#define M_COARSE_CAL_STEP_SIZE 0xfU
-#define V_COARSE_CAL_STEP_SIZE(x) ((x) << S_COARSE_CAL_STEP_SIZE)
-#define G_COARSE_CAL_STEP_SIZE(x) (((x) >> S_COARSE_CAL_STEP_SIZE) & M_COARSE_CAL_STEP_SIZE)
-
-#define S_DQ_SEL_QUAD 7
-#define M_DQ_SEL_QUAD 0x3U
-#define V_DQ_SEL_QUAD(x) ((x) << S_DQ_SEL_QUAD)
-#define G_DQ_SEL_QUAD(x) (((x) >> S_DQ_SEL_QUAD) & M_DQ_SEL_QUAD)
-
-#define S_DQ_SEL_LANE 4
-#define M_DQ_SEL_LANE 0x7U
-#define V_DQ_SEL_LANE(x) ((x) << S_DQ_SEL_LANE)
-#define G_DQ_SEL_LANE(x) (((x) >> S_DQ_SEL_LANE) & M_DQ_SEL_LANE)
-
-#define A_MC_DDRPHY_RC_PERIODIC 0x47420
-#define A_MC_DDRPHY_WC_CONFIG0 0x47600
-
-#define S_TWLO_TWLOE 8
-#define M_TWLO_TWLOE 0xffU
-#define V_TWLO_TWLOE(x) ((x) << S_TWLO_TWLOE)
-#define G_TWLO_TWLOE(x) (((x) >> S_TWLO_TWLOE) & M_TWLO_TWLOE)
-
-#define S_WL_ONE_DQS_PULSE 7
-#define V_WL_ONE_DQS_PULSE(x) ((x) << S_WL_ONE_DQS_PULSE)
-#define F_WL_ONE_DQS_PULSE V_WL_ONE_DQS_PULSE(1U)
-
-#define S_FW_WR_RD 1
-#define M_FW_WR_RD 0x3fU
-#define V_FW_WR_RD(x) ((x) << S_FW_WR_RD)
-#define G_FW_WR_RD(x) (((x) >> S_FW_WR_RD) & M_FW_WR_RD)
-
-#define S_CUSTOM_INIT_WRITE 0
-#define V_CUSTOM_INIT_WRITE(x) ((x) << S_CUSTOM_INIT_WRITE)
-#define F_CUSTOM_INIT_WRITE V_CUSTOM_INIT_WRITE(1U)
-
-#define A_MC_DDRPHY_WC_CONFIG1 0x47604
-
-#define S_BIG_STEP 12
-#define M_BIG_STEP 0xfU
-#define V_BIG_STEP(x) ((x) << S_BIG_STEP)
-#define G_BIG_STEP(x) (((x) >> S_BIG_STEP) & M_BIG_STEP)
-
-#define S_SMALL_STEP 9
-#define M_SMALL_STEP 0x7U
-#define V_SMALL_STEP(x) ((x) << S_SMALL_STEP)
-#define G_SMALL_STEP(x) (((x) >> S_SMALL_STEP) & M_SMALL_STEP)
-
-#define S_WR_PRE_DLY 3
-#define M_WR_PRE_DLY 0x3fU
-#define V_WR_PRE_DLY(x) ((x) << S_WR_PRE_DLY)
-#define G_WR_PRE_DLY(x) (((x) >> S_WR_PRE_DLY) & M_WR_PRE_DLY)
-
-#define A_MC_DDRPHY_WC_CONFIG2 0x47608
-
-#define S_NUM_VALID_SAMPLES 12
-#define M_NUM_VALID_SAMPLES 0xfU
-#define V_NUM_VALID_SAMPLES(x) ((x) << S_NUM_VALID_SAMPLES)
-#define G_NUM_VALID_SAMPLES(x) (((x) >> S_NUM_VALID_SAMPLES) & M_NUM_VALID_SAMPLES)
-
-#define S_FW_RD_WR 6
-#define M_FW_RD_WR 0x3fU
-#define V_FW_RD_WR(x) ((x) << S_FW_RD_WR)
-#define G_FW_RD_WR(x) (((x) >> S_FW_RD_WR) & M_FW_RD_WR)
-
-#define S_EN_RESET_WR_DELAY_WL 0
-#define V_EN_RESET_WR_DELAY_WL(x) ((x) << S_EN_RESET_WR_DELAY_WL)
-#define F_EN_RESET_WR_DELAY_WL V_EN_RESET_WR_DELAY_WL(1U)
-
-#define S_TWR_MPR 2
-#define M_TWR_MPR 0xfU
-#define V_TWR_MPR(x) ((x) << S_TWR_MPR)
-#define G_TWR_MPR(x) (((x) >> S_TWR_MPR) & M_TWR_MPR)
-
-#define A_MC_DDRPHY_WC_ERROR_STATUS0 0x4760c
-
-#define S_WR_CNTL_ERROR 15
-#define V_WR_CNTL_ERROR(x) ((x) << S_WR_CNTL_ERROR)
-#define F_WR_CNTL_ERROR V_WR_CNTL_ERROR(1U)
-
-#define A_MC_DDRPHY_WC_ERROR_MASK0 0x47610
-
-#define S_WR_CNTL_ERROR_MASK 15
-#define V_WR_CNTL_ERROR_MASK(x) ((x) << S_WR_CNTL_ERROR_MASK)
-#define F_WR_CNTL_ERROR_MASK V_WR_CNTL_ERROR_MASK(1U)
-
-#define A_MC_DDRPHY_WC_CONFIG3 0x47614
-
-#define S_DDR4_MRS_CMD_DQ_EN 15
-#define V_DDR4_MRS_CMD_DQ_EN(x) ((x) << S_DDR4_MRS_CMD_DQ_EN)
-#define F_DDR4_MRS_CMD_DQ_EN V_DDR4_MRS_CMD_DQ_EN(1U)
-
-#define S_MRS_CMD_DQ_ON 9
-#define M_MRS_CMD_DQ_ON 0x3fU
-#define V_MRS_CMD_DQ_ON(x) ((x) << S_MRS_CMD_DQ_ON)
-#define G_MRS_CMD_DQ_ON(x) (((x) >> S_MRS_CMD_DQ_ON) & M_MRS_CMD_DQ_ON)
-
-#define S_MRS_CMD_DQ_OFF 3
-#define M_MRS_CMD_DQ_OFF 0x3fU
-#define V_MRS_CMD_DQ_OFF(x) ((x) << S_MRS_CMD_DQ_OFF)
-#define G_MRS_CMD_DQ_OFF(x) (((x) >> S_MRS_CMD_DQ_OFF) & M_MRS_CMD_DQ_OFF)
-
-#define A_MC_DDRPHY_WC_WRCLK_CNTL 0x47618
-
-#define S_WRCLK_CAL_START 15
-#define V_WRCLK_CAL_START(x) ((x) << S_WRCLK_CAL_START)
-#define F_WRCLK_CAL_START V_WRCLK_CAL_START(1U)
-
-#define S_WRCLK_CAL_DONE 14
-#define V_WRCLK_CAL_DONE(x) ((x) << S_WRCLK_CAL_DONE)
-#define F_WRCLK_CAL_DONE V_WRCLK_CAL_DONE(1U)
-
-#define A_MC_DDRPHY_APB_CONFIG0 0x47800
-
-#define S_DISABLE_PARITY_CHECKER 15
-#define V_DISABLE_PARITY_CHECKER(x) ((x) << S_DISABLE_PARITY_CHECKER)
-#define F_DISABLE_PARITY_CHECKER V_DISABLE_PARITY_CHECKER(1U)
-
-#define S_GENERATE_EVEN_PARITY 14
-#define V_GENERATE_EVEN_PARITY(x) ((x) << S_GENERATE_EVEN_PARITY)
-#define F_GENERATE_EVEN_PARITY V_GENERATE_EVEN_PARITY(1U)
-
-#define S_FORCE_ON_CLK_GATE 13
-#define V_FORCE_ON_CLK_GATE(x) ((x) << S_FORCE_ON_CLK_GATE)
-#define F_FORCE_ON_CLK_GATE V_FORCE_ON_CLK_GATE(1U)
-
-#define S_DEBUG_BUS_SEL_LO 12
-#define V_DEBUG_BUS_SEL_LO(x) ((x) << S_DEBUG_BUS_SEL_LO)
-#define F_DEBUG_BUS_SEL_LO V_DEBUG_BUS_SEL_LO(1U)
-
-#define S_DEBUG_BUS_SEL_HI 8
-#define M_DEBUG_BUS_SEL_HI 0xfU
-#define V_DEBUG_BUS_SEL_HI(x) ((x) << S_DEBUG_BUS_SEL_HI)
-#define G_DEBUG_BUS_SEL_HI(x) (((x) >> S_DEBUG_BUS_SEL_HI) & M_DEBUG_BUS_SEL_HI)
-
-#define A_MC_DDRPHY_APB_ERROR_STATUS0 0x47804
-
-#define S_INVALID_ADDRESS 15
-#define V_INVALID_ADDRESS(x) ((x) << S_INVALID_ADDRESS)
-#define F_INVALID_ADDRESS V_INVALID_ADDRESS(1U)
-
-#define S_WR_PAR_ERR 14
-#define V_WR_PAR_ERR(x) ((x) << S_WR_PAR_ERR)
-#define F_WR_PAR_ERR V_WR_PAR_ERR(1U)
-
-#define A_MC_DDRPHY_APB_ERROR_MASK0 0x47808
-
-#define S_INVALID_ADDRESS_MASK 15
-#define V_INVALID_ADDRESS_MASK(x) ((x) << S_INVALID_ADDRESS_MASK)
-#define F_INVALID_ADDRESS_MASK V_INVALID_ADDRESS_MASK(1U)
-
-#define S_WR_PAR_ERR_MASK 14
-#define V_WR_PAR_ERR_MASK(x) ((x) << S_WR_PAR_ERR_MASK)
-#define F_WR_PAR_ERR_MASK V_WR_PAR_ERR_MASK(1U)
-
-#define A_MC_DDRPHY_APB_DP18_POPULATION 0x4780c
-
-#define S_DP18_0_POPULATED 15
-#define V_DP18_0_POPULATED(x) ((x) << S_DP18_0_POPULATED)
-#define F_DP18_0_POPULATED V_DP18_0_POPULATED(1U)
-
-#define S_DP18_1_POPULATED 14
-#define V_DP18_1_POPULATED(x) ((x) << S_DP18_1_POPULATED)
-#define F_DP18_1_POPULATED V_DP18_1_POPULATED(1U)
-
-#define S_DP18_2_POPULATED 13
-#define V_DP18_2_POPULATED(x) ((x) << S_DP18_2_POPULATED)
-#define F_DP18_2_POPULATED V_DP18_2_POPULATED(1U)
-
-#define S_DP18_3_POPULATED 12
-#define V_DP18_3_POPULATED(x) ((x) << S_DP18_3_POPULATED)
-#define F_DP18_3_POPULATED V_DP18_3_POPULATED(1U)
-
-#define S_DP18_4_POPULATED 11
-#define V_DP18_4_POPULATED(x) ((x) << S_DP18_4_POPULATED)
-#define F_DP18_4_POPULATED V_DP18_4_POPULATED(1U)
-
-#define S_DP18_5_POPULATED 10
-#define V_DP18_5_POPULATED(x) ((x) << S_DP18_5_POPULATED)
-#define F_DP18_5_POPULATED V_DP18_5_POPULATED(1U)
-
-#define S_DP18_6_POPULATED 9
-#define V_DP18_6_POPULATED(x) ((x) << S_DP18_6_POPULATED)
-#define F_DP18_6_POPULATED V_DP18_6_POPULATED(1U)
-
-#define S_DP18_7_POPULATED 8
-#define V_DP18_7_POPULATED(x) ((x) << S_DP18_7_POPULATED)
-#define F_DP18_7_POPULATED V_DP18_7_POPULATED(1U)
-
-#define S_DP18_8_POPULATED 7
-#define V_DP18_8_POPULATED(x) ((x) << S_DP18_8_POPULATED)
-#define F_DP18_8_POPULATED V_DP18_8_POPULATED(1U)
-
-#define S_DP18_9_POPULATED 6
-#define V_DP18_9_POPULATED(x) ((x) << S_DP18_9_POPULATED)
-#define F_DP18_9_POPULATED V_DP18_9_POPULATED(1U)
-
-#define S_DP18_10_POPULATED 5
-#define V_DP18_10_POPULATED(x) ((x) << S_DP18_10_POPULATED)
-#define F_DP18_10_POPULATED V_DP18_10_POPULATED(1U)
-
-#define S_DP18_11_POPULATED 4
-#define V_DP18_11_POPULATED(x) ((x) << S_DP18_11_POPULATED)
-#define F_DP18_11_POPULATED V_DP18_11_POPULATED(1U)
-
-#define S_DP18_12_POPULATED 3
-#define V_DP18_12_POPULATED(x) ((x) << S_DP18_12_POPULATED)
-#define F_DP18_12_POPULATED V_DP18_12_POPULATED(1U)
-
-#define S_DP18_13_POPULATED 2
-#define V_DP18_13_POPULATED(x) ((x) << S_DP18_13_POPULATED)
-#define F_DP18_13_POPULATED V_DP18_13_POPULATED(1U)
-
-#define S_DP18_14_POPULATED 1
-#define V_DP18_14_POPULATED(x) ((x) << S_DP18_14_POPULATED)
-#define F_DP18_14_POPULATED V_DP18_14_POPULATED(1U)
-
-#define A_MC_DDRPHY_APB_ADR_POPULATION 0x47810
-
-#define S_ADR16_0_POPULATED 15
-#define V_ADR16_0_POPULATED(x) ((x) << S_ADR16_0_POPULATED)
-#define F_ADR16_0_POPULATED V_ADR16_0_POPULATED(1U)
-
-#define S_ADR16_1_POPULATED 14
-#define V_ADR16_1_POPULATED(x) ((x) << S_ADR16_1_POPULATED)
-#define F_ADR16_1_POPULATED V_ADR16_1_POPULATED(1U)
-
-#define S_ADR16_2_POPULATED 13
-#define V_ADR16_2_POPULATED(x) ((x) << S_ADR16_2_POPULATED)
-#define F_ADR16_2_POPULATED V_ADR16_2_POPULATED(1U)
-
-#define S_ADR16_3_POPULATED 12
-#define V_ADR16_3_POPULATED(x) ((x) << S_ADR16_3_POPULATED)
-#define F_ADR16_3_POPULATED V_ADR16_3_POPULATED(1U)
-
-#define S_ADR12_0_POPULATED 7
-#define V_ADR12_0_POPULATED(x) ((x) << S_ADR12_0_POPULATED)
-#define F_ADR12_0_POPULATED V_ADR12_0_POPULATED(1U)
-
-#define S_ADR12_1_POPULATED 6
-#define V_ADR12_1_POPULATED(x) ((x) << S_ADR12_1_POPULATED)
-#define F_ADR12_1_POPULATED V_ADR12_1_POPULATED(1U)
-
-#define S_ADR12_2_POPULATED 5
-#define V_ADR12_2_POPULATED(x) ((x) << S_ADR12_2_POPULATED)
-#define F_ADR12_2_POPULATED V_ADR12_2_POPULATED(1U)
-
-#define S_ADR12_3_POPULATED 4
-#define V_ADR12_3_POPULATED(x) ((x) << S_ADR12_3_POPULATED)
-#define F_ADR12_3_POPULATED V_ADR12_3_POPULATED(1U)
-
-#define A_MC_DDRPHY_APB_ATEST_MUX_SEL 0x47814
-
-#define S_ATEST_CNTL 10
-#define M_ATEST_CNTL 0x3fU
-#define V_ATEST_CNTL(x) ((x) << S_ATEST_CNTL)
-#define G_ATEST_CNTL(x) (((x) >> S_ATEST_CNTL) & M_ATEST_CNTL)
-
-#define A_MC_DDRPHY_APB_MTCTL_REG0 0x47820
-
-#define S_MT_DATA_MUX4_1MODE 15
-#define V_MT_DATA_MUX4_1MODE(x) ((x) << S_MT_DATA_MUX4_1MODE)
-#define F_MT_DATA_MUX4_1MODE V_MT_DATA_MUX4_1MODE(1U)
-
-#define S_MT_PLL_RESET 14
-#define V_MT_PLL_RESET(x) ((x) << S_MT_PLL_RESET)
-#define F_MT_PLL_RESET V_MT_PLL_RESET(1U)
-
-#define S_MT_SYSCLK_RESET 13
-#define V_MT_SYSCLK_RESET(x) ((x) << S_MT_SYSCLK_RESET)
-#define F_MT_SYSCLK_RESET V_MT_SYSCLK_RESET(1U)
-
-#define S_MT_GLOBAL_PHY_OFFSET 9
-#define M_MT_GLOBAL_PHY_OFFSET 0xfU
-#define V_MT_GLOBAL_PHY_OFFSET(x) ((x) << S_MT_GLOBAL_PHY_OFFSET)
-#define G_MT_GLOBAL_PHY_OFFSET(x) (((x) >> S_MT_GLOBAL_PHY_OFFSET) & M_MT_GLOBAL_PHY_OFFSET)
-
-#define S_MT_DQ_SEL_QUAD 7
-#define M_MT_DQ_SEL_QUAD 0x3U
-#define V_MT_DQ_SEL_QUAD(x) ((x) << S_MT_DQ_SEL_QUAD)
-#define G_MT_DQ_SEL_QUAD(x) (((x) >> S_MT_DQ_SEL_QUAD) & M_MT_DQ_SEL_QUAD)
-
-#define S_MT_PERFORM_RDCLK_ALIGN 6
-#define V_MT_PERFORM_RDCLK_ALIGN(x) ((x) << S_MT_PERFORM_RDCLK_ALIGN)
-#define F_MT_PERFORM_RDCLK_ALIGN V_MT_PERFORM_RDCLK_ALIGN(1U)
-
-#define S_MT_ALIGN_ON_EVEN_CYCLES 5
-#define V_MT_ALIGN_ON_EVEN_CYCLES(x) ((x) << S_MT_ALIGN_ON_EVEN_CYCLES)
-#define F_MT_ALIGN_ON_EVEN_CYCLES V_MT_ALIGN_ON_EVEN_CYCLES(1U)
-
-#define S_MT_WRCLK_CAL_START 4
-#define V_MT_WRCLK_CAL_START(x) ((x) << S_MT_WRCLK_CAL_START)
-#define F_MT_WRCLK_CAL_START V_MT_WRCLK_CAL_START(1U)
-
-#define A_MC_DDRPHY_APB_MTCTL_REG1 0x47824
-
-#define S_MT_WPRD_ENABLE 15
-#define V_MT_WPRD_ENABLE(x) ((x) << S_MT_WPRD_ENABLE)
-#define F_MT_WPRD_ENABLE V_MT_WPRD_ENABLE(1U)
-
-#define S_MT_PVTP 10
-#define M_MT_PVTP 0x1fU
-#define V_MT_PVTP(x) ((x) << S_MT_PVTP)
-#define G_MT_PVTP(x) (((x) >> S_MT_PVTP) & M_MT_PVTP)
-
-#define S_MT_PVTN 5
-#define M_MT_PVTN 0x1fU
-#define V_MT_PVTN(x) ((x) << S_MT_PVTN)
-#define G_MT_PVTN(x) (((x) >> S_MT_PVTN) & M_MT_PVTN)
-
-#define A_MC_DDRPHY_APB_MTSTAT_REG0 0x47828
-#define A_MC_DDRPHY_APB_MTSTAT_REG1 0x4782c
-
-#define S_MT_ADR32_PLL_LOCK_SUM 1
-#define V_MT_ADR32_PLL_LOCK_SUM(x) ((x) << S_MT_ADR32_PLL_LOCK_SUM)
-#define F_MT_ADR32_PLL_LOCK_SUM V_MT_ADR32_PLL_LOCK_SUM(1U)
-
-#define S_MT_DP18_PLL_LOCK_SUM 0
-#define V_MT_DP18_PLL_LOCK_SUM(x) ((x) << S_MT_DP18_PLL_LOCK_SUM)
-#define F_MT_DP18_PLL_LOCK_SUM V_MT_DP18_PLL_LOCK_SUM(1U)
-
-/* registers for module MC_1 */
-#define MC_1_BASE_ADDR 0x48000
-
-/* registers for module EDC_T50 */
-#define EDC_T50_BASE_ADDR 0x50000
-
-#define A_EDC_H_REF 0x50000
-
-#define S_EDC_SLEEPSTATUS 31
-#define V_EDC_SLEEPSTATUS(x) ((x) << S_EDC_SLEEPSTATUS)
-#define F_EDC_SLEEPSTATUS V_EDC_SLEEPSTATUS(1U)
-
-#define S_EDC_SLEEPREQ 30
-#define V_EDC_SLEEPREQ(x) ((x) << S_EDC_SLEEPREQ)
-#define F_EDC_SLEEPREQ V_EDC_SLEEPREQ(1U)
-
-#define S_PING_PONG 29
-#define V_PING_PONG(x) ((x) << S_PING_PONG)
-#define F_PING_PONG V_PING_PONG(1U)
-
-#define A_EDC_H_BIST_CMD 0x50004
-#define A_EDC_H_BIST_CMD_ADDR 0x50008
-#define A_EDC_H_BIST_CMD_LEN 0x5000c
-#define A_EDC_H_BIST_DATA_PATTERN 0x50010
-#define A_EDC_H_BIST_USER_WDATA0 0x50014
-#define A_EDC_H_BIST_USER_WDATA1 0x50018
-#define A_EDC_H_BIST_USER_WDATA2 0x5001c
-#define A_EDC_H_BIST_NUM_ERR 0x50020
-#define A_EDC_H_BIST_ERR_FIRST_ADDR 0x50024
-#define A_EDC_H_BIST_STATUS_RDATA 0x50028
-#define A_EDC_H_PAR_ENABLE 0x50070
-
-#define S_PERR_PAR_ENABLE 0
-#define V_PERR_PAR_ENABLE(x) ((x) << S_PERR_PAR_ENABLE)
-#define F_PERR_PAR_ENABLE V_PERR_PAR_ENABLE(1U)
-
-#define A_EDC_H_INT_ENABLE 0x50074
-#define A_EDC_H_INT_CAUSE 0x50078
-
-#define S_ECC_UE_INT0_CAUSE 5
-#define V_ECC_UE_INT0_CAUSE(x) ((x) << S_ECC_UE_INT0_CAUSE)
-#define F_ECC_UE_INT0_CAUSE V_ECC_UE_INT0_CAUSE(1U)
-
-#define S_ECC_CE_INT0_CAUSE 4
-#define V_ECC_CE_INT0_CAUSE(x) ((x) << S_ECC_CE_INT0_CAUSE)
-#define F_ECC_CE_INT0_CAUSE V_ECC_CE_INT0_CAUSE(1U)
-
-#define S_PERR_INT0_CAUSE 3
-#define V_PERR_INT0_CAUSE(x) ((x) << S_PERR_INT0_CAUSE)
-#define F_PERR_INT0_CAUSE V_PERR_INT0_CAUSE(1U)
-
-#define A_EDC_H_ECC_STATUS 0x5007c
-#define A_EDC_H_ECC_ERR_SEL 0x50080
-
-#define S_CFG 0
-#define M_CFG 0x3U
-#define V_CFG(x) ((x) << S_CFG)
-#define G_CFG(x) (((x) >> S_CFG) & M_CFG)
-
-#define A_EDC_H_ECC_ERR_ADDR 0x50084
-
-#define S_ECC_ADDR 0
-#define M_ECC_ADDR 0x7fffffU
-#define V_ECC_ADDR(x) ((x) << S_ECC_ADDR)
-#define G_ECC_ADDR(x) (((x) >> S_ECC_ADDR) & M_ECC_ADDR)
-
-#define A_EDC_H_ECC_ERR_DATA_RDATA 0x50090
-#define A_EDC_H_BIST_CRC_SEED 0x50400
-
-/* registers for module EDC_T51 */
-#define EDC_T51_BASE_ADDR 0x50800
-
-/* registers for module HMA_T5 */
-#define HMA_T5_BASE_ADDR 0x51000
-
-#define A_HMA_TABLE_ACCESS 0x51000
-
-#define S_TRIG 31
-#define V_TRIG(x) ((x) << S_TRIG)
-#define F_TRIG V_TRIG(1U)
-
-#define S_RW 30
-#define V_RW(x) ((x) << S_RW)
-#define F_RW V_RW(1U)
-
-#define S_L_SEL 0
-#define M_L_SEL 0xfU
-#define V_L_SEL(x) ((x) << S_L_SEL)
-#define G_L_SEL(x) (((x) >> S_L_SEL) & M_L_SEL)
-
-#define A_HMA_TABLE_LINE0 0x51004
-
-#define S_CLIENT_EN 0
-#define M_CLIENT_EN 0x1fffU
-#define V_CLIENT_EN(x) ((x) << S_CLIENT_EN)
-#define G_CLIENT_EN(x) (((x) >> S_CLIENT_EN) & M_CLIENT_EN)
-
-#define A_HMA_TABLE_LINE1 0x51008
-#define A_HMA_TABLE_LINE2 0x5100c
-#define A_HMA_TABLE_LINE3 0x51010
-#define A_HMA_TABLE_LINE4 0x51014
-#define A_HMA_TABLE_LINE5 0x51018
-
-#define S_FID 16
-#define M_FID 0x7ffU
-#define V_FID(x) ((x) << S_FID)
-#define G_FID(x) (((x) >> S_FID) & M_FID)
-
-#define S_NOS 15
-#define V_NOS(x) ((x) << S_NOS)
-#define F_NOS V_NOS(1U)
-
-#define S_RO 14
-#define V_RO(x) ((x) << S_RO)
-#define F_RO V_RO(1U)
-
-#define A_HMA_COOKIE 0x5101c
-
-#define S_C_REQ 31
-#define V_C_REQ(x) ((x) << S_C_REQ)
-#define F_C_REQ V_C_REQ(1U)
-
-#define S_C_FID 18
-#define M_C_FID 0x7ffU
-#define V_C_FID(x) ((x) << S_C_FID)
-#define G_C_FID(x) (((x) >> S_C_FID) & M_C_FID)
-
-#define S_C_VAL 8
-#define M_C_VAL 0x3ffU
-#define V_C_VAL(x) ((x) << S_C_VAL)
-#define G_C_VAL(x) (((x) >> S_C_VAL) & M_C_VAL)
-
-#define S_C_SEL 0
-#define M_C_SEL 0xfU
-#define V_C_SEL(x) ((x) << S_C_SEL)
-#define G_C_SEL(x) (((x) >> S_C_SEL) & M_C_SEL)
-
-#define A_HMA_PAR_ENABLE 0x51300
-#define A_HMA_INT_ENABLE 0x51304
-#define A_HMA_INT_CAUSE 0x51308
-
-/* registers for module EDC_T60 */
-#define EDC_T60_BASE_ADDR 0x50000
-
-#define S_QDR_CLKPHASE 24
-#define M_QDR_CLKPHASE 0x7U
-#define V_QDR_CLKPHASE(x) ((x) << S_QDR_CLKPHASE)
-#define G_QDR_CLKPHASE(x) (((x) >> S_QDR_CLKPHASE) & M_QDR_CLKPHASE)
-
-#define S_MAXOPSPERTRC 21
-#define M_MAXOPSPERTRC 0x7U
-#define V_MAXOPSPERTRC(x) ((x) << S_MAXOPSPERTRC)
-#define G_MAXOPSPERTRC(x) (((x) >> S_MAXOPSPERTRC) & M_MAXOPSPERTRC)
-
-#define S_NUMPIPESTAGES 19
-#define M_NUMPIPESTAGES 0x3U
-#define V_NUMPIPESTAGES(x) ((x) << S_NUMPIPESTAGES)
-#define G_NUMPIPESTAGES(x) (((x) >> S_NUMPIPESTAGES) & M_NUMPIPESTAGES)
-
-#define A_EDC_H_DBG_MA_CMD_INTF 0x50300
-
-#define S_MCMDADDR 12
-#define M_MCMDADDR 0xfffffU
-#define V_MCMDADDR(x) ((x) << S_MCMDADDR)
-#define G_MCMDADDR(x) (((x) >> S_MCMDADDR) & M_MCMDADDR)
-
-#define S_MCMDLEN 5
-#define M_MCMDLEN 0x7fU
-#define V_MCMDLEN(x) ((x) << S_MCMDLEN)
-#define G_MCMDLEN(x) (((x) >> S_MCMDLEN) & M_MCMDLEN)
-
-#define S_MCMDNRE 4
-#define V_MCMDNRE(x) ((x) << S_MCMDNRE)
-#define F_MCMDNRE V_MCMDNRE(1U)
-
-#define S_MCMDNRB 3
-#define V_MCMDNRB(x) ((x) << S_MCMDNRB)
-#define F_MCMDNRB V_MCMDNRB(1U)
-
-#define S_MCMDWR 2
-#define V_MCMDWR(x) ((x) << S_MCMDWR)
-#define F_MCMDWR V_MCMDWR(1U)
-
-#define S_MCMDRDY 1
-#define V_MCMDRDY(x) ((x) << S_MCMDRDY)
-#define F_MCMDRDY V_MCMDRDY(1U)
-
-#define S_MCMDVLD 0
-#define V_MCMDVLD(x) ((x) << S_MCMDVLD)
-#define F_MCMDVLD V_MCMDVLD(1U)
-
-#define A_EDC_H_DBG_MA_WDATA_INTF 0x50304
-
-#define S_MWDATAVLD 31
-#define V_MWDATAVLD(x) ((x) << S_MWDATAVLD)
-#define F_MWDATAVLD V_MWDATAVLD(1U)
-
-#define S_MWDATARDY 30
-#define V_MWDATARDY(x) ((x) << S_MWDATARDY)
-#define F_MWDATARDY V_MWDATARDY(1U)
-
-#define S_MWDATA 0
-#define M_MWDATA 0x3fffffffU
-#define V_MWDATA(x) ((x) << S_MWDATA)
-#define G_MWDATA(x) (((x) >> S_MWDATA) & M_MWDATA)
-
-#define A_EDC_H_DBG_MA_RDATA_INTF 0x50308
-
-#define S_MRSPVLD 31
-#define V_MRSPVLD(x) ((x) << S_MRSPVLD)
-#define F_MRSPVLD V_MRSPVLD(1U)
-
-#define S_MRSPRDY 30
-#define V_MRSPRDY(x) ((x) << S_MRSPRDY)
-#define F_MRSPRDY V_MRSPRDY(1U)
-
-#define S_MRSPDATA 0
-#define M_MRSPDATA 0x3fffffffU
-#define V_MRSPDATA(x) ((x) << S_MRSPDATA)
-#define G_MRSPDATA(x) (((x) >> S_MRSPDATA) & M_MRSPDATA)
-
-#define A_EDC_H_DBG_BIST_CMD_INTF 0x5030c
-
-#define S_BCMDADDR 9
-#define M_BCMDADDR 0x7fffffU
-#define V_BCMDADDR(x) ((x) << S_BCMDADDR)
-#define G_BCMDADDR(x) (((x) >> S_BCMDADDR) & M_BCMDADDR)
-
-#define S_BCMDLEN 3
-#define M_BCMDLEN 0x3fU
-#define V_BCMDLEN(x) ((x) << S_BCMDLEN)
-#define G_BCMDLEN(x) (((x) >> S_BCMDLEN) & M_BCMDLEN)
-
-#define S_BCMDWR 2
-#define V_BCMDWR(x) ((x) << S_BCMDWR)
-#define F_BCMDWR V_BCMDWR(1U)
-
-#define S_BCMDRDY 1
-#define V_BCMDRDY(x) ((x) << S_BCMDRDY)
-#define F_BCMDRDY V_BCMDRDY(1U)
-
-#define S_BCMDVLD 0
-#define V_BCMDVLD(x) ((x) << S_BCMDVLD)
-#define F_BCMDVLD V_BCMDVLD(1U)
-
-#define A_EDC_H_DBG_BIST_WDATA_INTF 0x50310
-
-#define S_BWDATAVLD 31
-#define V_BWDATAVLD(x) ((x) << S_BWDATAVLD)
-#define F_BWDATAVLD V_BWDATAVLD(1U)
-
-#define S_BWDATARDY 30
-#define V_BWDATARDY(x) ((x) << S_BWDATARDY)
-#define F_BWDATARDY V_BWDATARDY(1U)
-
-#define S_BWDATA 0
-#define M_BWDATA 0x3fffffffU
-#define V_BWDATA(x) ((x) << S_BWDATA)
-#define G_BWDATA(x) (((x) >> S_BWDATA) & M_BWDATA)
-
-#define A_EDC_H_DBG_BIST_RDATA_INTF 0x50314
-
-#define S_BRSPVLD 31
-#define V_BRSPVLD(x) ((x) << S_BRSPVLD)
-#define F_BRSPVLD V_BRSPVLD(1U)
-
-#define S_BRSPRDY 30
-#define V_BRSPRDY(x) ((x) << S_BRSPRDY)
-#define F_BRSPRDY V_BRSPRDY(1U)
-
-#define S_BRSPDATA 0
-#define M_BRSPDATA 0x3fffffffU
-#define V_BRSPDATA(x) ((x) << S_BRSPDATA)
-#define G_BRSPDATA(x) (((x) >> S_BRSPDATA) & M_BRSPDATA)
-
-#define A_EDC_H_DBG_EDRAM_CMD_INTF 0x50318
-
-#define S_EDRAMADDR 16
-#define M_EDRAMADDR 0xffffU
-#define V_EDRAMADDR(x) ((x) << S_EDRAMADDR)
-#define G_EDRAMADDR(x) (((x) >> S_EDRAMADDR) & M_EDRAMADDR)
-
-#define S_EDRAMDWSN 8
-#define M_EDRAMDWSN 0xffU
-#define V_EDRAMDWSN(x) ((x) << S_EDRAMDWSN)
-#define G_EDRAMDWSN(x) (((x) >> S_EDRAMDWSN) & M_EDRAMDWSN)
-
-#define S_EDRAMCRA 5
-#define M_EDRAMCRA 0x7U
-#define V_EDRAMCRA(x) ((x) << S_EDRAMCRA)
-#define G_EDRAMCRA(x) (((x) >> S_EDRAMCRA) & M_EDRAMCRA)
-
-#define S_EDRAMREFENLO 4
-#define V_EDRAMREFENLO(x) ((x) << S_EDRAMREFENLO)
-#define F_EDRAMREFENLO V_EDRAMREFENLO(1U)
-
-#define S_EDRAM1WRENLO 3
-#define V_EDRAM1WRENLO(x) ((x) << S_EDRAM1WRENLO)
-#define F_EDRAM1WRENLO V_EDRAM1WRENLO(1U)
-
-#define S_EDRAM1RDENLO 2
-#define V_EDRAM1RDENLO(x) ((x) << S_EDRAM1RDENLO)
-#define F_EDRAM1RDENLO V_EDRAM1RDENLO(1U)
-
-#define S_EDRAM0WRENLO 1
-#define V_EDRAM0WRENLO(x) ((x) << S_EDRAM0WRENLO)
-#define F_EDRAM0WRENLO V_EDRAM0WRENLO(1U)
-
-#define S_EDRAM0RDENLO 0
-#define V_EDRAM0RDENLO(x) ((x) << S_EDRAM0RDENLO)
-#define F_EDRAM0RDENLO V_EDRAM0RDENLO(1U)
-
-#define A_EDC_H_DBG_EDRAM_WDATA_INTF 0x5031c
-
-#define S_EDRAMWDATA 9
-#define M_EDRAMWDATA 0x7fffffU
-#define V_EDRAMWDATA(x) ((x) << S_EDRAMWDATA)
-#define G_EDRAMWDATA(x) (((x) >> S_EDRAMWDATA) & M_EDRAMWDATA)
-
-#define S_EDRAMWBYTEEN 0
-#define M_EDRAMWBYTEEN 0x1ffU
-#define V_EDRAMWBYTEEN(x) ((x) << S_EDRAMWBYTEEN)
-#define G_EDRAMWBYTEEN(x) (((x) >> S_EDRAMWBYTEEN) & M_EDRAMWBYTEEN)
-
-#define A_EDC_H_DBG_EDRAM0_RDATA_INTF 0x50320
-#define A_EDC_H_DBG_EDRAM1_RDATA_INTF 0x50324
-#define A_EDC_H_DBG_MA_WR_REQ_CNT 0x50328
-#define A_EDC_H_DBG_MA_WR_EXP_DAT_CYC_CNT 0x5032c
-#define A_EDC_H_DBG_MA_WR_DAT_CYC_CNT 0x50330
-#define A_EDC_H_DBG_MA_RD_REQ_CNT 0x50334
-#define A_EDC_H_DBG_MA_RD_EXP_DAT_CYC_CNT 0x50338
-#define A_EDC_H_DBG_MA_RD_DAT_CYC_CNT 0x5033c
-#define A_EDC_H_DBG_BIST_WR_REQ_CNT 0x50340
-#define A_EDC_H_DBG_BIST_WR_EXP_DAT_CYC_CNT 0x50344
-#define A_EDC_H_DBG_BIST_WR_DAT_CYC_CNT 0x50348
-#define A_EDC_H_DBG_BIST_RD_REQ_CNT 0x5034c
-#define A_EDC_H_DBG_BIST_RD_EXP_DAT_CYC_CNT 0x50350
-#define A_EDC_H_DBG_BIST_RD_DAT_CYC_CNT 0x50354
-#define A_EDC_H_DBG_EDRAM0_WR_REQ_CNT 0x50358
-#define A_EDC_H_DBG_EDRAM0_RD_REQ_CNT 0x5035c
-#define A_EDC_H_DBG_EDRAM0_RMW_CNT 0x50360
-#define A_EDC_H_DBG_EDRAM1_WR_REQ_CNT 0x50364
-#define A_EDC_H_DBG_EDRAM1_RD_REQ_CNT 0x50368
-#define A_EDC_H_DBG_EDRAM1_RMW_CNT 0x5036c
-#define A_EDC_H_DBG_EDRAM_REF_BURST_CNT 0x50370
-#define A_EDC_H_DBG_FIFO_STATUS 0x50374
-
-#define S_RDTAG_NOTFULL 17
-#define V_RDTAG_NOTFULL(x) ((x) << S_RDTAG_NOTFULL)
-#define F_RDTAG_NOTFULL V_RDTAG_NOTFULL(1U)
-
-#define S_RDTAG_NOTEMPTY 16
-#define V_RDTAG_NOTEMPTY(x) ((x) << S_RDTAG_NOTEMPTY)
-#define F_RDTAG_NOTEMPTY V_RDTAG_NOTEMPTY(1U)
-
-#define S_INP_CMDQ_NOTFULL_ARB 15
-#define V_INP_CMDQ_NOTFULL_ARB(x) ((x) << S_INP_CMDQ_NOTFULL_ARB)
-#define F_INP_CMDQ_NOTFULL_ARB V_INP_CMDQ_NOTFULL_ARB(1U)
-
-#define S_INP_CMDQ_NOTEMPTY 14
-#define V_INP_CMDQ_NOTEMPTY(x) ((x) << S_INP_CMDQ_NOTEMPTY)
-#define F_INP_CMDQ_NOTEMPTY V_INP_CMDQ_NOTEMPTY(1U)
-
-#define S_INP_WRDQ_WRRDY 13
-#define V_INP_WRDQ_WRRDY(x) ((x) << S_INP_WRDQ_WRRDY)
-#define F_INP_WRDQ_WRRDY V_INP_WRDQ_WRRDY(1U)
-
-#define S_INP_WRDQ_NOTEMPTY 12
-#define V_INP_WRDQ_NOTEMPTY(x) ((x) << S_INP_WRDQ_NOTEMPTY)
-#define F_INP_WRDQ_NOTEMPTY V_INP_WRDQ_NOTEMPTY(1U)
-
-#define S_INP_BEQ_WRRDY_OPEN 11
-#define V_INP_BEQ_WRRDY_OPEN(x) ((x) << S_INP_BEQ_WRRDY_OPEN)
-#define F_INP_BEQ_WRRDY_OPEN V_INP_BEQ_WRRDY_OPEN(1U)
-
-#define S_INP_BEQ_NOTEMPTY 10
-#define V_INP_BEQ_NOTEMPTY(x) ((x) << S_INP_BEQ_NOTEMPTY)
-#define F_INP_BEQ_NOTEMPTY V_INP_BEQ_NOTEMPTY(1U)
-
-#define S_RDDQ_NOTFULL_OPEN 9
-#define V_RDDQ_NOTFULL_OPEN(x) ((x) << S_RDDQ_NOTFULL_OPEN)
-#define F_RDDQ_NOTFULL_OPEN V_RDDQ_NOTFULL_OPEN(1U)
-
-#define S_RDDQ_RDCNT 4
-#define M_RDDQ_RDCNT 0x1fU
-#define V_RDDQ_RDCNT(x) ((x) << S_RDDQ_RDCNT)
-#define G_RDDQ_RDCNT(x) (((x) >> S_RDDQ_RDCNT) & M_RDDQ_RDCNT)
-
-#define S_RDSIDEQ_NOTFULL 3
-#define V_RDSIDEQ_NOTFULL(x) ((x) << S_RDSIDEQ_NOTFULL)
-#define F_RDSIDEQ_NOTFULL V_RDSIDEQ_NOTFULL(1U)
-
-#define S_RDSIDEQ_NOTEMPTY 2
-#define V_RDSIDEQ_NOTEMPTY(x) ((x) << S_RDSIDEQ_NOTEMPTY)
-#define F_RDSIDEQ_NOTEMPTY V_RDSIDEQ_NOTEMPTY(1U)
-
-#define S_STG_CMDQ_NOTEMPTY 1
-#define V_STG_CMDQ_NOTEMPTY(x) ((x) << S_STG_CMDQ_NOTEMPTY)
-#define F_STG_CMDQ_NOTEMPTY V_STG_CMDQ_NOTEMPTY(1U)
-
-#define S_STG_WRDQ_NOTEMPTY 0
-#define V_STG_WRDQ_NOTEMPTY(x) ((x) << S_STG_WRDQ_NOTEMPTY)
-#define F_STG_WRDQ_NOTEMPTY V_STG_WRDQ_NOTEMPTY(1U)
-
-#define A_EDC_H_DBG_FSM_STATE 0x50378
-
-#define S_CMDSPLITFSM 3
-#define V_CMDSPLITFSM(x) ((x) << S_CMDSPLITFSM)
-#define F_CMDSPLITFSM V_CMDSPLITFSM(1U)
-
-#define S_CMDFSM 0
-#define M_CMDFSM 0x7U
-#define V_CMDFSM(x) ((x) << S_CMDFSM)
-#define G_CMDFSM(x) (((x) >> S_CMDFSM) & M_CMDFSM)
-
-#define A_EDC_H_DBG_STALL_CYCLES 0x5037c
-
-#define S_STALL_RMW 19
-#define V_STALL_RMW(x) ((x) << S_STALL_RMW)
-#define F_STALL_RMW V_STALL_RMW(1U)
-
-#define S_STALL_EDC_CMD 18
-#define V_STALL_EDC_CMD(x) ((x) << S_STALL_EDC_CMD)
-#define F_STALL_EDC_CMD V_STALL_EDC_CMD(1U)
-
-#define S_DEAD_CYCLE0 17
-#define V_DEAD_CYCLE0(x) ((x) << S_DEAD_CYCLE0)
-#define F_DEAD_CYCLE0 V_DEAD_CYCLE0(1U)
-
-#define S_DEAD_CYCLE1 16
-#define V_DEAD_CYCLE1(x) ((x) << S_DEAD_CYCLE1)
-#define F_DEAD_CYCLE1 V_DEAD_CYCLE1(1U)
-
-#define S_DEAD_CYCLE0_BBI 15
-#define V_DEAD_CYCLE0_BBI(x) ((x) << S_DEAD_CYCLE0_BBI)
-#define F_DEAD_CYCLE0_BBI V_DEAD_CYCLE0_BBI(1U)
-
-#define S_DEAD_CYCLE1_BBI 14
-#define V_DEAD_CYCLE1_BBI(x) ((x) << S_DEAD_CYCLE1_BBI)
-#define F_DEAD_CYCLE1_BBI V_DEAD_CYCLE1_BBI(1U)
-
-#define S_DEAD_CYCLE0_MAX_OP 13
-#define V_DEAD_CYCLE0_MAX_OP(x) ((x) << S_DEAD_CYCLE0_MAX_OP)
-#define F_DEAD_CYCLE0_MAX_OP V_DEAD_CYCLE0_MAX_OP(1U)
-
-#define S_DEAD_CYCLE1_MAX_OP 12
-#define V_DEAD_CYCLE1_MAX_OP(x) ((x) << S_DEAD_CYCLE1_MAX_OP)
-#define F_DEAD_CYCLE1_MAX_OP V_DEAD_CYCLE1_MAX_OP(1U)
-
-#define S_DEAD_CYCLE0_PRE_REF 11
-#define V_DEAD_CYCLE0_PRE_REF(x) ((x) << S_DEAD_CYCLE0_PRE_REF)
-#define F_DEAD_CYCLE0_PRE_REF V_DEAD_CYCLE0_PRE_REF(1U)
-
-#define S_DEAD_CYCLE1_PRE_REF 10
-#define V_DEAD_CYCLE1_PRE_REF(x) ((x) << S_DEAD_CYCLE1_PRE_REF)
-#define F_DEAD_CYCLE1_PRE_REF V_DEAD_CYCLE1_PRE_REF(1U)
-
-#define S_DEAD_CYCLE0_POST_REF 9
-#define V_DEAD_CYCLE0_POST_REF(x) ((x) << S_DEAD_CYCLE0_POST_REF)
-#define F_DEAD_CYCLE0_POST_REF V_DEAD_CYCLE0_POST_REF(1U)
-
-#define S_DEAD_CYCLE1_POST_REF 8
-#define V_DEAD_CYCLE1_POST_REF(x) ((x) << S_DEAD_CYCLE1_POST_REF)
-#define F_DEAD_CYCLE1_POST_REF V_DEAD_CYCLE1_POST_REF(1U)
-
-#define S_DEAD_CYCLE0_RMW 7
-#define V_DEAD_CYCLE0_RMW(x) ((x) << S_DEAD_CYCLE0_RMW)
-#define F_DEAD_CYCLE0_RMW V_DEAD_CYCLE0_RMW(1U)
-
-#define S_DEAD_CYCLE1_RMW 6
-#define V_DEAD_CYCLE1_RMW(x) ((x) << S_DEAD_CYCLE1_RMW)
-#define F_DEAD_CYCLE1_RMW V_DEAD_CYCLE1_RMW(1U)
-
-#define S_DEAD_CYCLE0_BBI_RMW 5
-#define V_DEAD_CYCLE0_BBI_RMW(x) ((x) << S_DEAD_CYCLE0_BBI_RMW)
-#define F_DEAD_CYCLE0_BBI_RMW V_DEAD_CYCLE0_BBI_RMW(1U)
-
-#define S_DEAD_CYCLE1_BBI_RMW 4
-#define V_DEAD_CYCLE1_BBI_RMW(x) ((x) << S_DEAD_CYCLE1_BBI_RMW)
-#define F_DEAD_CYCLE1_BBI_RMW V_DEAD_CYCLE1_BBI_RMW(1U)
-
-#define S_DEAD_CYCLE0_PRE_REF_RMW 3
-#define V_DEAD_CYCLE0_PRE_REF_RMW(x) ((x) << S_DEAD_CYCLE0_PRE_REF_RMW)
-#define F_DEAD_CYCLE0_PRE_REF_RMW V_DEAD_CYCLE0_PRE_REF_RMW(1U)
-
-#define S_DEAD_CYCLE1_PRE_REF_RMW 2
-#define V_DEAD_CYCLE1_PRE_REF_RMW(x) ((x) << S_DEAD_CYCLE1_PRE_REF_RMW)
-#define F_DEAD_CYCLE1_PRE_REF_RMW V_DEAD_CYCLE1_PRE_REF_RMW(1U)
-
-#define S_DEAD_CYCLE0_POST_REF_RMW 1
-#define V_DEAD_CYCLE0_POST_REF_RMW(x) ((x) << S_DEAD_CYCLE0_POST_REF_RMW)
-#define F_DEAD_CYCLE0_POST_REF_RMW V_DEAD_CYCLE0_POST_REF_RMW(1U)
-
-#define S_DEAD_CYCLE1_POST_REF_RMW 0
-#define V_DEAD_CYCLE1_POST_REF_RMW(x) ((x) << S_DEAD_CYCLE1_POST_REF_RMW)
-#define F_DEAD_CYCLE1_POST_REF_RMW V_DEAD_CYCLE1_POST_REF_RMW(1U)
-
-#define A_EDC_H_DBG_CMD_QUEUE 0x50380
-
-#define S_ECMDNRE 31
-#define V_ECMDNRE(x) ((x) << S_ECMDNRE)
-#define F_ECMDNRE V_ECMDNRE(1U)
-
-#define S_ECMDNRB 30
-#define V_ECMDNRB(x) ((x) << S_ECMDNRB)
-#define F_ECMDNRB V_ECMDNRB(1U)
-
-#define S_ECMDWR 29
-#define V_ECMDWR(x) ((x) << S_ECMDWR)
-#define F_ECMDWR V_ECMDWR(1U)
-
-#define S_ECMDLEN 22
-#define M_ECMDLEN 0x7fU
-#define V_ECMDLEN(x) ((x) << S_ECMDLEN)
-#define G_ECMDLEN(x) (((x) >> S_ECMDLEN) & M_ECMDLEN)
-
-#define S_ECMDADDR 0
-#define M_ECMDADDR 0x3fffffU
-#define V_ECMDADDR(x) ((x) << S_ECMDADDR)
-#define G_ECMDADDR(x) (((x) >> S_ECMDADDR) & M_ECMDADDR)
-
-#define A_EDC_H_DBG_REFRESH 0x50384
-
-#define S_REFDONE 12
-#define V_REFDONE(x) ((x) << S_REFDONE)
-#define F_REFDONE V_REFDONE(1U)
-
-#define S_REFCNTEXPR 11
-#define V_REFCNTEXPR(x) ((x) << S_REFCNTEXPR)
-#define F_REFCNTEXPR V_REFCNTEXPR(1U)
-
-#define S_REFPTR 8
-#define M_REFPTR 0x7U
-#define V_REFPTR(x) ((x) << S_REFPTR)
-#define G_REFPTR(x) (((x) >> S_REFPTR) & M_REFPTR)
-
-#define S_REFCNT 0
-#define M_REFCNT 0xffU
-#define V_REFCNT(x) ((x) << S_REFCNT)
-#define G_REFCNT(x) (((x) >> S_REFCNT) & M_REFCNT)
-
-/* registers for module EDC_T61 */
-#define EDC_T61_BASE_ADDR 0x50800
-
-/* registers for module HMA_T6 */
-#define HMA_T6_BASE_ADDR 0x51000
-
-#define S_TPH 12
-#define M_TPH 0x3U
-#define V_TPH(x) ((x) << S_TPH)
-#define G_TPH(x) (((x) >> S_TPH) & M_TPH)
-
-#define S_TPH_V 11
-#define V_TPH_V(x) ((x) << S_TPH_V)
-#define F_TPH_V V_TPH_V(1U)
-
-#define S_DCA 0
-#define M_DCA 0x7ffU
-#define V_DCA(x) ((x) << S_DCA)
-#define G_DCA(x) (((x) >> S_DCA) & M_DCA)
-
-#define A_HMA_CFG 0x51020
-
-#define S_OP_MODE 31
-#define V_OP_MODE(x) ((x) << S_OP_MODE)
-#define F_OP_MODE V_OP_MODE(1U)
-
-#define A_HMA_TLB_ACCESS 0x51028
-
-#define S_INV_ALL 29
-#define V_INV_ALL(x) ((x) << S_INV_ALL)
-#define F_INV_ALL V_INV_ALL(1U)
-
-#define S_LOCK_ENTRY 28
-#define V_LOCK_ENTRY(x) ((x) << S_LOCK_ENTRY)
-#define F_LOCK_ENTRY V_LOCK_ENTRY(1U)
-
-#define S_E_SEL 0
-#define M_E_SEL 0x1fU
-#define V_E_SEL(x) ((x) << S_E_SEL)
-#define G_E_SEL(x) (((x) >> S_E_SEL) & M_E_SEL)
-
-#define A_HMA_TLB_BITS 0x5102c
-
-#define S_VA 12
-#define M_VA 0xfffffU
-#define V_VA(x) ((x) << S_VA)
-#define G_VA(x) (((x) >> S_VA) & M_VA)
-
-#define S_VALID_E 4
-#define V_VALID_E(x) ((x) << S_VALID_E)
-#define F_VALID_E V_VALID_E(1U)
-
-#define S_LOCK_HMA 3
-#define V_LOCK_HMA(x) ((x) << S_LOCK_HMA)
-#define F_LOCK_HMA V_LOCK_HMA(1U)
-
-#define S_T6_USED 2
-#define V_T6_USED(x) ((x) << S_T6_USED)
-#define F_T6_USED V_T6_USED(1U)
-
-#define S_REGION 0
-#define M_REGION 0x3U
-#define V_REGION(x) ((x) << S_REGION)
-#define G_REGION(x) (((x) >> S_REGION) & M_REGION)
-
-#define A_HMA_TLB_DESC_0_H 0x51030
-#define A_HMA_TLB_DESC_0_L 0x51034
-#define A_HMA_TLB_DESC_1_H 0x51038
-#define A_HMA_TLB_DESC_1_L 0x5103c
-#define A_HMA_TLB_DESC_2_H 0x51040
-#define A_HMA_TLB_DESC_2_L 0x51044
-#define A_HMA_TLB_DESC_3_H 0x51048
-#define A_HMA_TLB_DESC_3_L 0x5104c
-#define A_HMA_TLB_DESC_4_H 0x51050
-#define A_HMA_TLB_DESC_4_L 0x51054
-#define A_HMA_TLB_DESC_5_H 0x51058
-#define A_HMA_TLB_DESC_5_L 0x5105c
-#define A_HMA_TLB_DESC_6_H 0x51060
-#define A_HMA_TLB_DESC_6_L 0x51064
-#define A_HMA_TLB_DESC_7_H 0x51068
-#define A_HMA_TLB_DESC_7_L 0x5106c
-#define A_HMA_REG0_MIN 0x51070
-
-#define S_ADDR0_MIN 12
-#define M_ADDR0_MIN 0xfffffU
-#define V_ADDR0_MIN(x) ((x) << S_ADDR0_MIN)
-#define G_ADDR0_MIN(x) (((x) >> S_ADDR0_MIN) & M_ADDR0_MIN)
-
-#define A_HMA_REG0_MAX 0x51074
-
-#define S_ADDR0_MAX 12
-#define M_ADDR0_MAX 0xfffffU
-#define V_ADDR0_MAX(x) ((x) << S_ADDR0_MAX)
-#define G_ADDR0_MAX(x) (((x) >> S_ADDR0_MAX) & M_ADDR0_MAX)
-
-#define A_HMA_REG0_MASK 0x51078
-
-#define S_PAGE_SIZE0 12
-#define M_PAGE_SIZE0 0xfffffU
-#define V_PAGE_SIZE0(x) ((x) << S_PAGE_SIZE0)
-#define G_PAGE_SIZE0(x) (((x) >> S_PAGE_SIZE0) & M_PAGE_SIZE0)
-
-#define A_HMA_REG0_BASE 0x5107c
-#define A_HMA_REG1_MIN 0x51080
-
-#define S_ADDR1_MIN 12
-#define M_ADDR1_MIN 0xfffffU
-#define V_ADDR1_MIN(x) ((x) << S_ADDR1_MIN)
-#define G_ADDR1_MIN(x) (((x) >> S_ADDR1_MIN) & M_ADDR1_MIN)
-
-#define A_HMA_REG1_MAX 0x51084
-
-#define S_ADDR1_MAX 12
-#define M_ADDR1_MAX 0xfffffU
-#define V_ADDR1_MAX(x) ((x) << S_ADDR1_MAX)
-#define G_ADDR1_MAX(x) (((x) >> S_ADDR1_MAX) & M_ADDR1_MAX)
-
-#define A_HMA_REG1_MASK 0x51088
-
-#define S_PAGE_SIZE1 12
-#define M_PAGE_SIZE1 0xfffffU
-#define V_PAGE_SIZE1(x) ((x) << S_PAGE_SIZE1)
-#define G_PAGE_SIZE1(x) (((x) >> S_PAGE_SIZE1) & M_PAGE_SIZE1)
-
-#define A_HMA_REG1_BASE 0x5108c
-#define A_HMA_REG2_MIN 0x51090
-
-#define S_ADDR2_MIN 12
-#define M_ADDR2_MIN 0xfffffU
-#define V_ADDR2_MIN(x) ((x) << S_ADDR2_MIN)
-#define G_ADDR2_MIN(x) (((x) >> S_ADDR2_MIN) & M_ADDR2_MIN)
-
-#define A_HMA_REG2_MAX 0x51094
-
-#define S_ADDR2_MAX 12
-#define M_ADDR2_MAX 0xfffffU
-#define V_ADDR2_MAX(x) ((x) << S_ADDR2_MAX)
-#define G_ADDR2_MAX(x) (((x) >> S_ADDR2_MAX) & M_ADDR2_MAX)
-
-#define A_HMA_REG2_MASK 0x51098
-
-#define S_PAGE_SIZE2 12
-#define M_PAGE_SIZE2 0xfffffU
-#define V_PAGE_SIZE2(x) ((x) << S_PAGE_SIZE2)
-#define G_PAGE_SIZE2(x) (((x) >> S_PAGE_SIZE2) & M_PAGE_SIZE2)
-
-#define A_HMA_REG2_BASE 0x5109c
-#define A_HMA_REG3_MIN 0x510a0
-
-#define S_ADDR3_MIN 12
-#define M_ADDR3_MIN 0xfffffU
-#define V_ADDR3_MIN(x) ((x) << S_ADDR3_MIN)
-#define G_ADDR3_MIN(x) (((x) >> S_ADDR3_MIN) & M_ADDR3_MIN)
-
-#define A_HMA_REG3_MAX 0x510a4
-
-#define S_ADDR3_MAX 12
-#define M_ADDR3_MAX 0xfffffU
-#define V_ADDR3_MAX(x) ((x) << S_ADDR3_MAX)
-#define G_ADDR3_MAX(x) (((x) >> S_ADDR3_MAX) & M_ADDR3_MAX)
-
-#define A_HMA_REG3_MASK 0x510a8
-
-#define S_PAGE_SIZE3 12
-#define M_PAGE_SIZE3 0xfffffU
-#define V_PAGE_SIZE3(x) ((x) << S_PAGE_SIZE3)
-#define G_PAGE_SIZE3(x) (((x) >> S_PAGE_SIZE3) & M_PAGE_SIZE3)
-
-#define A_HMA_REG3_BASE 0x510ac
-#define A_HMA_SW_SYNC 0x510b0
-
-#define S_ENTER_SYNC 31
-#define V_ENTER_SYNC(x) ((x) << S_ENTER_SYNC)
-#define F_ENTER_SYNC V_ENTER_SYNC(1U)
-
-#define S_EXIT_SYNC 30
-#define V_EXIT_SYNC(x) ((x) << S_EXIT_SYNC)
-#define F_EXIT_SYNC V_EXIT_SYNC(1U)
-
-#define S_IDTF_INT_ENABLE 5
-#define V_IDTF_INT_ENABLE(x) ((x) << S_IDTF_INT_ENABLE)
-#define F_IDTF_INT_ENABLE V_IDTF_INT_ENABLE(1U)
-
-#define S_OTF_INT_ENABLE 4
-#define V_OTF_INT_ENABLE(x) ((x) << S_OTF_INT_ENABLE)
-#define F_OTF_INT_ENABLE V_OTF_INT_ENABLE(1U)
-
-#define S_RTF_INT_ENABLE 3
-#define V_RTF_INT_ENABLE(x) ((x) << S_RTF_INT_ENABLE)
-#define F_RTF_INT_ENABLE V_RTF_INT_ENABLE(1U)
-
-#define S_PCIEMST_INT_ENABLE 2
-#define V_PCIEMST_INT_ENABLE(x) ((x) << S_PCIEMST_INT_ENABLE)
-#define F_PCIEMST_INT_ENABLE V_PCIEMST_INT_ENABLE(1U)
-
-#define S_MAMST_INT_ENABLE 1
-#define V_MAMST_INT_ENABLE(x) ((x) << S_MAMST_INT_ENABLE)
-#define F_MAMST_INT_ENABLE V_MAMST_INT_ENABLE(1U)
-
-#define S_IDTF_INT_CAUSE 5
-#define V_IDTF_INT_CAUSE(x) ((x) << S_IDTF_INT_CAUSE)
-#define F_IDTF_INT_CAUSE V_IDTF_INT_CAUSE(1U)
-
-#define S_OTF_INT_CAUSE 4
-#define V_OTF_INT_CAUSE(x) ((x) << S_OTF_INT_CAUSE)
-#define F_OTF_INT_CAUSE V_OTF_INT_CAUSE(1U)
-
-#define S_RTF_INT_CAUSE 3
-#define V_RTF_INT_CAUSE(x) ((x) << S_RTF_INT_CAUSE)
-#define F_RTF_INT_CAUSE V_RTF_INT_CAUSE(1U)
-
-#define S_PCIEMST_INT_CAUSE 2
-#define V_PCIEMST_INT_CAUSE(x) ((x) << S_PCIEMST_INT_CAUSE)
-#define F_PCIEMST_INT_CAUSE V_PCIEMST_INT_CAUSE(1U)
-
-#define S_MAMST_INT_CAUSE 1
-#define V_MAMST_INT_CAUSE(x) ((x) << S_MAMST_INT_CAUSE)
-#define F_MAMST_INT_CAUSE V_MAMST_INT_CAUSE(1U)
-
-#define A_HMA_MA_MST_ERR 0x5130c
-#define A_HMA_RTF_ERR 0x51310
-#define A_HMA_OTF_ERR 0x51314
-#define A_HMA_IDTF_ERR 0x51318
-#define A_HMA_EXIT_TF 0x5131c
-
-#define S_RTF 30
-#define V_RTF(x) ((x) << S_RTF)
-#define F_RTF V_RTF(1U)
-
-#define S_OTF 29
-#define V_OTF(x) ((x) << S_OTF)
-#define F_OTF V_OTF(1U)
-
-#define S_IDTF 28
-#define V_IDTF(x) ((x) << S_IDTF)
-#define F_IDTF V_IDTF(1U)
-
-#define A_HMA_LOCAL_DEBUG_CFG 0x51320
-#define A_HMA_LOCAL_DEBUG_RPT 0x51324
-#define A_HMA_DEBUG_FSM_0 0xa000
-
-#define S_EDC_FSM 18
-#define M_EDC_FSM 0x1fU
-#define V_EDC_FSM(x) ((x) << S_EDC_FSM)
-#define G_EDC_FSM(x) (((x) >> S_EDC_FSM) & M_EDC_FSM)
-
-#define S_RAS_FSM_SLV 15
-#define M_RAS_FSM_SLV 0x7U
-#define V_RAS_FSM_SLV(x) ((x) << S_RAS_FSM_SLV)
-#define G_RAS_FSM_SLV(x) (((x) >> S_RAS_FSM_SLV) & M_RAS_FSM_SLV)
-
-#define S_FC_FSM 10
-#define M_FC_FSM 0x1fU
-#define V_FC_FSM(x) ((x) << S_FC_FSM)
-#define G_FC_FSM(x) (((x) >> S_FC_FSM) & M_FC_FSM)
-
-#define S_COOKIE_ARB_FSM 8
-#define M_COOKIE_ARB_FSM 0x3U
-#define V_COOKIE_ARB_FSM(x) ((x) << S_COOKIE_ARB_FSM)
-#define G_COOKIE_ARB_FSM(x) (((x) >> S_COOKIE_ARB_FSM) & M_COOKIE_ARB_FSM)
-
-#define S_PCIE_CHUNK_FSM 6
-#define M_PCIE_CHUNK_FSM 0x3U
-#define V_PCIE_CHUNK_FSM(x) ((x) << S_PCIE_CHUNK_FSM)
-#define G_PCIE_CHUNK_FSM(x) (((x) >> S_PCIE_CHUNK_FSM) & M_PCIE_CHUNK_FSM)
-
-#define S_WTRANSFER_FSM 4
-#define M_WTRANSFER_FSM 0x3U
-#define V_WTRANSFER_FSM(x) ((x) << S_WTRANSFER_FSM)
-#define G_WTRANSFER_FSM(x) (((x) >> S_WTRANSFER_FSM) & M_WTRANSFER_FSM)
-
-#define S_WD_FSM 2
-#define M_WD_FSM 0x3U
-#define V_WD_FSM(x) ((x) << S_WD_FSM)
-#define G_WD_FSM(x) (((x) >> S_WD_FSM) & M_WD_FSM)
-
-#define S_RD_FSM 0
-#define M_RD_FSM 0x3U
-#define V_RD_FSM(x) ((x) << S_RD_FSM)
-#define G_RD_FSM(x) (((x) >> S_RD_FSM) & M_RD_FSM)
-
-#define A_HMA_DEBUG_FSM_1 0xa001
-
-#define S_SYNC_FSM 11
-#define M_SYNC_FSM 0x3ffU
-#define V_SYNC_FSM(x) ((x) << S_SYNC_FSM)
-#define G_SYNC_FSM(x) (((x) >> S_SYNC_FSM) & M_SYNC_FSM)
-
-#define S_OCHK_FSM 9
-#define M_OCHK_FSM 0x3U
-#define V_OCHK_FSM(x) ((x) << S_OCHK_FSM)
-#define G_OCHK_FSM(x) (((x) >> S_OCHK_FSM) & M_OCHK_FSM)
-
-#define S_TLB_FSM 5
-#define M_TLB_FSM 0xfU
-#define V_TLB_FSM(x) ((x) << S_TLB_FSM)
-#define G_TLB_FSM(x) (((x) >> S_TLB_FSM) & M_TLB_FSM)
-
-#define S_PIO_FSM 0
-#define M_PIO_FSM 0x1fU
-#define V_PIO_FSM(x) ((x) << S_PIO_FSM)
-#define G_PIO_FSM(x) (((x) >> S_PIO_FSM) & M_PIO_FSM)
-
-#define A_HMA_DEBUG_PCIE_INTF 0xa002
-
-#define S_T6_H_REQVLD 28
-#define V_T6_H_REQVLD(x) ((x) << S_T6_H_REQVLD)
-#define F_T6_H_REQVLD V_T6_H_REQVLD(1U)
-
-#define S_H_REQFULL 27
-#define V_H_REQFULL(x) ((x) << S_H_REQFULL)
-#define F_H_REQFULL V_H_REQFULL(1U)
-
-#define S_H_REQSOP 26
-#define V_H_REQSOP(x) ((x) << S_H_REQSOP)
-#define F_H_REQSOP V_H_REQSOP(1U)
-
-#define S_H_REQEOP 25
-#define V_H_REQEOP(x) ((x) << S_H_REQEOP)
-#define F_H_REQEOP V_H_REQEOP(1U)
-
-#define S_T6_H_RSPVLD 24
-#define V_T6_H_RSPVLD(x) ((x) << S_T6_H_RSPVLD)
-#define F_T6_H_RSPVLD V_T6_H_RSPVLD(1U)
-
-#define S_H_RSPFULL 23
-#define V_H_RSPFULL(x) ((x) << S_H_RSPFULL)
-#define F_H_RSPFULL V_H_RSPFULL(1U)
-
-#define S_H_RSPSOP 22
-#define V_H_RSPSOP(x) ((x) << S_H_RSPSOP)
-#define F_H_RSPSOP V_H_RSPSOP(1U)
-
-#define S_H_RSPEOP 21
-#define V_H_RSPEOP(x) ((x) << S_H_RSPEOP)
-#define F_H_RSPEOP V_H_RSPEOP(1U)
-
-#define S_H_RSPERR 20
-#define V_H_RSPERR(x) ((x) << S_H_RSPERR)
-#define F_H_RSPERR V_H_RSPERR(1U)
-
-#define S_PCIE_CMD_AVAIL 19
-#define V_PCIE_CMD_AVAIL(x) ((x) << S_PCIE_CMD_AVAIL)
-#define F_PCIE_CMD_AVAIL V_PCIE_CMD_AVAIL(1U)
-
-#define S_PCIE_CMD_RDY 18
-#define V_PCIE_CMD_RDY(x) ((x) << S_PCIE_CMD_RDY)
-#define F_PCIE_CMD_RDY V_PCIE_CMD_RDY(1U)
-
-#define S_PCIE_WNR 17
-#define V_PCIE_WNR(x) ((x) << S_PCIE_WNR)
-#define F_PCIE_WNR V_PCIE_WNR(1U)
-
-#define S_PCIE_LEN 9
-#define M_PCIE_LEN 0xffU
-#define V_PCIE_LEN(x) ((x) << S_PCIE_LEN)
-#define G_PCIE_LEN(x) (((x) >> S_PCIE_LEN) & M_PCIE_LEN)
-
-#define S_PCIE_TRWDAT_RDY 8
-#define V_PCIE_TRWDAT_RDY(x) ((x) << S_PCIE_TRWDAT_RDY)
-#define F_PCIE_TRWDAT_RDY V_PCIE_TRWDAT_RDY(1U)
-
-#define S_PCIE_TRWDAT_AVAIL 7
-#define V_PCIE_TRWDAT_AVAIL(x) ((x) << S_PCIE_TRWDAT_AVAIL)
-#define F_PCIE_TRWDAT_AVAIL V_PCIE_TRWDAT_AVAIL(1U)
-
-#define S_PCIE_TRWSOP 6
-#define V_PCIE_TRWSOP(x) ((x) << S_PCIE_TRWSOP)
-#define F_PCIE_TRWSOP V_PCIE_TRWSOP(1U)
-
-#define S_PCIE_TRWEOP 5
-#define V_PCIE_TRWEOP(x) ((x) << S_PCIE_TRWEOP)
-#define F_PCIE_TRWEOP V_PCIE_TRWEOP(1U)
-
-#define S_PCIE_TRRDAT_RDY 4
-#define V_PCIE_TRRDAT_RDY(x) ((x) << S_PCIE_TRRDAT_RDY)
-#define F_PCIE_TRRDAT_RDY V_PCIE_TRRDAT_RDY(1U)
-
-#define S_PCIE_TRRDAT_AVAIL 3
-#define V_PCIE_TRRDAT_AVAIL(x) ((x) << S_PCIE_TRRDAT_AVAIL)
-#define F_PCIE_TRRDAT_AVAIL V_PCIE_TRRDAT_AVAIL(1U)
-
-#define S_PCIE_TRRSOP 2
-#define V_PCIE_TRRSOP(x) ((x) << S_PCIE_TRRSOP)
-#define F_PCIE_TRRSOP V_PCIE_TRRSOP(1U)
-
-#define S_PCIE_TRREOP 1
-#define V_PCIE_TRREOP(x) ((x) << S_PCIE_TRREOP)
-#define F_PCIE_TRREOP V_PCIE_TRREOP(1U)
-
-#define S_PCIE_TRRERR 0
-#define V_PCIE_TRRERR(x) ((x) << S_PCIE_TRRERR)
-#define F_PCIE_TRRERR V_PCIE_TRRERR(1U)
-
-#define A_HMA_DEBUG_PCIE_ADDR_INTERNAL_LO 0xa003
-#define A_HMA_DEBUG_PCIE_ADDR_INTERNAL_HI 0xa004
-#define A_HMA_DEBUG_PCIE_REQ_DATA_EXTERNAL 0xa005
-
-#define S_REQDATA2 24
-#define M_REQDATA2 0xffU
-#define V_REQDATA2(x) ((x) << S_REQDATA2)
-#define G_REQDATA2(x) (((x) >> S_REQDATA2) & M_REQDATA2)
-
-#define S_REQDATA1 21
-#define M_REQDATA1 0x7U
-#define V_REQDATA1(x) ((x) << S_REQDATA1)
-#define G_REQDATA1(x) (((x) >> S_REQDATA1) & M_REQDATA1)
-
-#define S_REQDATA0 0
-#define M_REQDATA0 0x1fffffU
-#define V_REQDATA0(x) ((x) << S_REQDATA0)
-#define G_REQDATA0(x) (((x) >> S_REQDATA0) & M_REQDATA0)
-
-#define A_HMA_DEBUG_PCIE_RSP_DATA_EXTERNAL 0xa006
-
-#define S_RSPDATA3 24
-#define M_RSPDATA3 0xffU
-#define V_RSPDATA3(x) ((x) << S_RSPDATA3)
-#define G_RSPDATA3(x) (((x) >> S_RSPDATA3) & M_RSPDATA3)
-
-#define S_RSPDATA2 16
-#define M_RSPDATA2 0xffU
-#define V_RSPDATA2(x) ((x) << S_RSPDATA2)
-#define G_RSPDATA2(x) (((x) >> S_RSPDATA2) & M_RSPDATA2)
-
-#define S_RSPDATA1 8
-#define M_RSPDATA1 0xffU
-#define V_RSPDATA1(x) ((x) << S_RSPDATA1)
-#define G_RSPDATA1(x) (((x) >> S_RSPDATA1) & M_RSPDATA1)
-
-#define S_RSPDATA0 0
-#define M_RSPDATA0 0xffU
-#define V_RSPDATA0(x) ((x) << S_RSPDATA0)
-#define G_RSPDATA0(x) (((x) >> S_RSPDATA0) & M_RSPDATA0)
-
-#define A_HMA_DEBUG_MA_SLV_CTL 0xa007
-
-#define S_MA_CMD_AVAIL 19
-#define V_MA_CMD_AVAIL(x) ((x) << S_MA_CMD_AVAIL)
-#define F_MA_CMD_AVAIL V_MA_CMD_AVAIL(1U)
-
-#define S_MA_CLNT 15
-#define M_MA_CLNT 0xfU
-#define V_MA_CLNT(x) ((x) << S_MA_CLNT)
-#define G_MA_CLNT(x) (((x) >> S_MA_CLNT) & M_MA_CLNT)
-
-#define S_MA_WNR 14
-#define V_MA_WNR(x) ((x) << S_MA_WNR)
-#define F_MA_WNR V_MA_WNR(1U)
-
-#define S_MA_LEN 6
-#define M_MA_LEN 0xffU
-#define V_MA_LEN(x) ((x) << S_MA_LEN)
-#define G_MA_LEN(x) (((x) >> S_MA_LEN) & M_MA_LEN)
-
-#define S_MA_MST_RD 5
-#define V_MA_MST_RD(x) ((x) << S_MA_MST_RD)
-#define F_MA_MST_RD V_MA_MST_RD(1U)
-
-#define S_MA_MST_VLD 4
-#define V_MA_MST_VLD(x) ((x) << S_MA_MST_VLD)
-#define F_MA_MST_VLD V_MA_MST_VLD(1U)
-
-#define S_MA_MST_ERR 3
-#define V_MA_MST_ERR(x) ((x) << S_MA_MST_ERR)
-#define F_MA_MST_ERR V_MA_MST_ERR(1U)
-
-#define S_MAS_TLB_REQ 2
-#define V_MAS_TLB_REQ(x) ((x) << S_MAS_TLB_REQ)
-#define F_MAS_TLB_REQ V_MAS_TLB_REQ(1U)
-
-#define S_MAS_TLB_ACK 1
-#define V_MAS_TLB_ACK(x) ((x) << S_MAS_TLB_ACK)
-#define F_MAS_TLB_ACK V_MAS_TLB_ACK(1U)
-
-#define S_MAS_TLB_ERR 0
-#define V_MAS_TLB_ERR(x) ((x) << S_MAS_TLB_ERR)
-#define F_MAS_TLB_ERR V_MAS_TLB_ERR(1U)
-
-#define A_HMA_DEBUG_MA_SLV_ADDR_INTERNAL 0xa008
-#define A_HMA_DEBUG_TLB_HIT_ENTRY 0xa009
-#define A_HMA_DEBUG_TLB_HIT_CNT 0xa00a
-#define A_HMA_DEBUG_TLB_MISS_CNT 0xa00b
-#define A_HMA_DEBUG_PAGE_TBL_LKP_CTL 0xa00c
-
-#define S_LKP_REQ_VLD 4
-#define V_LKP_REQ_VLD(x) ((x) << S_LKP_REQ_VLD)
-#define F_LKP_REQ_VLD V_LKP_REQ_VLD(1U)
-
-#define S_LKP_DESC_SEL 1
-#define M_LKP_DESC_SEL 0x7U
-#define V_LKP_DESC_SEL(x) ((x) << S_LKP_DESC_SEL)
-#define G_LKP_DESC_SEL(x) (((x) >> S_LKP_DESC_SEL) & M_LKP_DESC_SEL)
-
-#define S_LKP_RSP_VLD 0
-#define V_LKP_RSP_VLD(x) ((x) << S_LKP_RSP_VLD)
-#define F_LKP_RSP_VLD V_LKP_RSP_VLD(1U)
-
-#define A_HMA_DEBUG_PAGE_TBL_LKP_REQ_ADDR 0xa00d
-#define A_HMA_DEBUG_PAGE_TBL_LKP_RSP_0 0xa00e
-#define A_HMA_DEBUG_PAGE_TBL_LKP_RSP_1 0xa00f
-#define A_HMA_DEBUG_PAGE_TBL_LKP_RSP_2 0xa010
-#define A_HMA_DEBUG_PAGE_TBL_LKP_RSP_3 0xa011
-#define A_HMA_DEBUG_PAGE_TBL_LKP_RSP_4 0xa012
-#define A_HMA_DEBUG_PAGE_TBL_LKP_RSP_5 0xa013
-#define A_HMA_DEBUG_PAGE_TBL_LKP_RSP_6 0xa014
-#define A_HMA_DEBUG_PAGE_TBL_LKP_RSP_7 0xa015
-#define A_HMA_DEBUG_PHYS_DESC_INTERNAL_LO 0xa016
-#define A_HMA_DEBUG_PCIE_RD_REQ_CNT_LO 0xa017
-#define A_HMA_DEBUG_PCIE_RD_REQ_CNT_HI 0xa018
-#define A_HMA_DEBUG_PCIE_WR_REQ_CNT_LO 0xa019
-#define A_HMA_DEBUG_PCIE_WR_REQ_CNT_HI 0xa01a
-#define A_HMA_DEBUG_PCIE_RD_DATA_CYC_CNT_LO 0xa01b
-#define A_HMA_DEBUG_PCIE_RD_DATA_CYC_CNT_HI 0xa01c
-#define A_HMA_DEBUG_PCIE_WR_DATA_CYC_CNT_LO 0xa01d
-#define A_HMA_DEBUG_PCIE_WR_DATA_CYC_CNT_HI 0xa01e
-#define A_HMA_DEBUG_PCIE_SOP_EOP_CNT 0xa01f
-
-#define S_WR_EOP_CNT 16
-#define M_WR_EOP_CNT 0xffU
-#define V_WR_EOP_CNT(x) ((x) << S_WR_EOP_CNT)
-#define G_WR_EOP_CNT(x) (((x) >> S_WR_EOP_CNT) & M_WR_EOP_CNT)
-
-#define S_RD_SOP_CNT 8
-#define M_RD_SOP_CNT 0xffU
-#define V_RD_SOP_CNT(x) ((x) << S_RD_SOP_CNT)
-#define G_RD_SOP_CNT(x) (((x) >> S_RD_SOP_CNT) & M_RD_SOP_CNT)
-
-#define S_RD_EOP_CNT 0
-#define M_RD_EOP_CNT 0xffU
-#define V_RD_EOP_CNT(x) ((x) << S_RD_EOP_CNT)
-#define G_RD_EOP_CNT(x) (((x) >> S_RD_EOP_CNT) & M_RD_EOP_CNT)
diff --git a/contrib/ofed/libcxgb4/src/t4fw_interface.h b/contrib/ofed/libcxgb4/src/t4fw_interface.h
deleted file mode 100644
index 988b513..0000000
--- a/contrib/ofed/libcxgb4/src/t4fw_interface.h
+++ /dev/null
@@ -1,7811 +0,0 @@
-/*
- * Chelsio Terminator 4 (T4) Firmware interface header file.
- *
- * Copyright (C) 2009-2014 Chelsio Communications. All rights reserved.
- *
- * Written by felix marti (felix@chelsio.com)
- *
- * This program 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 LICENSE file included in this
- * release for licensing terms and conditions.
- */
-
-#ifndef _T4FW_INTERFACE_H_
-#define _T4FW_INTERFACE_H_
-
-/******************************************************************************
- * R E T U R N V A L U E S
- ********************************/
-
-enum fw_retval {
- FW_SUCCESS = 0, /* completed sucessfully */
- FW_EPERM = 1, /* operation not permitted */
- FW_ENOENT = 2, /* no such file or directory */
- FW_EIO = 5, /* input/output error; hw bad */
- FW_ENOEXEC = 8, /* exec format error; inv microcode */
- FW_EAGAIN = 11, /* try again */
- FW_ENOMEM = 12, /* out of memory */
- FW_EFAULT = 14, /* bad address; fw bad */
- FW_EBUSY = 16, /* resource busy */
- FW_EEXIST = 17, /* file exists */
- FW_ENODEV = 19, /* no such device */
- FW_EINVAL = 22, /* invalid argument */
- FW_ENOSPC = 28, /* no space left on device */
- FW_ENOSYS = 38, /* functionality not implemented */
- FW_ENODATA = 61, /* no data available */
- FW_EPROTO = 71, /* protocol error */
- FW_EADDRINUSE = 98, /* address already in use */
- FW_EADDRNOTAVAIL = 99, /* cannot assigned requested address */
- FW_ENETDOWN = 100, /* network is down */
- FW_ENETUNREACH = 101, /* network is unreachable */
- FW_ENOBUFS = 105, /* no buffer space available */
- FW_ETIMEDOUT = 110, /* timeout */
- FW_EINPROGRESS = 115, /* fw internal */
- FW_SCSI_ABORT_REQUESTED = 128, /* */
- FW_SCSI_ABORT_TIMEDOUT = 129, /* */
- FW_SCSI_ABORTED = 130, /* */
- FW_SCSI_CLOSE_REQUESTED = 131, /* */
- FW_ERR_LINK_DOWN = 132, /* */
- FW_RDEV_NOT_READY = 133, /* */
- FW_ERR_RDEV_LOST = 134, /* */
- FW_ERR_RDEV_LOGO = 135, /* */
- FW_FCOE_NO_XCHG = 136, /* */
- FW_SCSI_RSP_ERR = 137, /* */
- FW_ERR_RDEV_IMPL_LOGO = 138, /* */
- FW_SCSI_UNDER_FLOW_ERR = 139, /* */
- FW_SCSI_OVER_FLOW_ERR = 140, /* */
- FW_SCSI_DDP_ERR = 141, /* DDP error*/
- FW_SCSI_TASK_ERR = 142, /* No SCSI tasks available */
-};
-
-/******************************************************************************
- * M E M O R Y T Y P E s
- ******************************/
-
-enum fw_memtype {
- FW_MEMTYPE_EDC0 = 0x0,
- FW_MEMTYPE_EDC1 = 0x1,
- FW_MEMTYPE_EXTMEM = 0x2,
- FW_MEMTYPE_FLASH = 0x4,
- FW_MEMTYPE_INTERNAL = 0x5,
- FW_MEMTYPE_EXTMEM1 = 0x6,
-};
-
-/******************************************************************************
- * W O R K R E Q U E S T s
- ********************************/
-
-enum fw_wr_opcodes {
- FW_FRAG_WR = 0x1d,
- FW_FILTER_WR = 0x02,
- FW_ULPTX_WR = 0x04,
- FW_TP_WR = 0x05,
- FW_ETH_TX_PKT_WR = 0x08,
- FW_ETH_TX_PKT2_WR = 0x44,
- FW_ETH_TX_PKTS_WR = 0x09,
- FW_ETH_TX_UO_WR = 0x1c,
- FW_EQ_FLUSH_WR = 0x1b,
- FW_OFLD_CONNECTION_WR = 0x2f,
- FW_FLOWC_WR = 0x0a,
- FW_OFLD_TX_DATA_WR = 0x0b,
- FW_CMD_WR = 0x10,
- FW_ETH_TX_PKT_VM_WR = 0x11,
- FW_RI_RES_WR = 0x0c,
- FW_RI_RDMA_WRITE_WR = 0x14,
- FW_RI_SEND_WR = 0x15,
- FW_RI_RDMA_READ_WR = 0x16,
- FW_RI_RECV_WR = 0x17,
- FW_RI_BIND_MW_WR = 0x18,
- FW_RI_FR_NSMR_WR = 0x19,
- FW_RI_INV_LSTAG_WR = 0x1a,
- FW_RI_SEND_IMMEDIATE_WR = 0x15,
- FW_RI_ATOMIC_WR = 0x16,
- FW_RI_WR = 0x0d,
- FW_CHNET_IFCONF_WR = 0x6b,
- FW_RDEV_WR = 0x38,
- FW_FOISCSI_NODE_WR = 0x60,
- FW_FOISCSI_CTRL_WR = 0x6a,
- FW_FOISCSI_CHAP_WR = 0x6c,
- FW_FCOE_ELS_CT_WR = 0x30,
- FW_SCSI_WRITE_WR = 0x31,
- FW_SCSI_READ_WR = 0x32,
- FW_SCSI_CMD_WR = 0x33,
- FW_SCSI_ABRT_CLS_WR = 0x34,
- FW_SCSI_TGT_ACC_WR = 0x35,
- FW_SCSI_TGT_XMIT_WR = 0x36,
- FW_SCSI_TGT_RSP_WR = 0x37,
- FW_POFCOE_TCB_WR = 0x42,
- FW_POFCOE_ULPTX_WR = 0x43,
- FW_LASTC2E_WR = 0x70
-};
-
-/*
- * Generic work request header flit0
- */
-struct fw_wr_hdr {
- __be32 hi;
- __be32 lo;
-};
-
-/* work request opcode (hi)
- */
-#define S_FW_WR_OP 24
-#define M_FW_WR_OP 0xff
-#define V_FW_WR_OP(x) ((x) << S_FW_WR_OP)
-#define G_FW_WR_OP(x) (((x) >> S_FW_WR_OP) & M_FW_WR_OP)
-
-/* atomic flag (hi) - firmware encapsulates CPLs in CPL_BARRIER
- */
-#define S_FW_WR_ATOMIC 23
-#define M_FW_WR_ATOMIC 0x1
-#define V_FW_WR_ATOMIC(x) ((x) << S_FW_WR_ATOMIC)
-#define G_FW_WR_ATOMIC(x) \
- (((x) >> S_FW_WR_ATOMIC) & M_FW_WR_ATOMIC)
-#define F_FW_WR_ATOMIC V_FW_WR_ATOMIC(1U)
-
-/* flush flag (hi) - firmware flushes flushable work request buffered
- * in the flow context.
- */
-#define S_FW_WR_FLUSH 22
-#define M_FW_WR_FLUSH 0x1
-#define V_FW_WR_FLUSH(x) ((x) << S_FW_WR_FLUSH)
-#define G_FW_WR_FLUSH(x) \
- (((x) >> S_FW_WR_FLUSH) & M_FW_WR_FLUSH)
-#define F_FW_WR_FLUSH V_FW_WR_FLUSH(1U)
-
-/* completion flag (hi) - firmware generates a cpl_fw6_ack
- */
-#define S_FW_WR_COMPL 21
-#define M_FW_WR_COMPL 0x1
-#define V_FW_WR_COMPL(x) ((x) << S_FW_WR_COMPL)
-#define G_FW_WR_COMPL(x) \
- (((x) >> S_FW_WR_COMPL) & M_FW_WR_COMPL)
-#define F_FW_WR_COMPL V_FW_WR_COMPL(1U)
-
-
-/* work request immediate data lengh (hi)
- */
-#define S_FW_WR_IMMDLEN 0
-#define M_FW_WR_IMMDLEN 0xff
-#define V_FW_WR_IMMDLEN(x) ((x) << S_FW_WR_IMMDLEN)
-#define G_FW_WR_IMMDLEN(x) \
- (((x) >> S_FW_WR_IMMDLEN) & M_FW_WR_IMMDLEN)
-
-/* egress queue status update to associated ingress queue entry (lo)
- */
-#define S_FW_WR_EQUIQ 31
-#define M_FW_WR_EQUIQ 0x1
-#define V_FW_WR_EQUIQ(x) ((x) << S_FW_WR_EQUIQ)
-#define G_FW_WR_EQUIQ(x) (((x) >> S_FW_WR_EQUIQ) & M_FW_WR_EQUIQ)
-#define F_FW_WR_EQUIQ V_FW_WR_EQUIQ(1U)
-
-/* egress queue status update to egress queue status entry (lo)
- */
-#define S_FW_WR_EQUEQ 30
-#define M_FW_WR_EQUEQ 0x1
-#define V_FW_WR_EQUEQ(x) ((x) << S_FW_WR_EQUEQ)
-#define G_FW_WR_EQUEQ(x) (((x) >> S_FW_WR_EQUEQ) & M_FW_WR_EQUEQ)
-#define F_FW_WR_EQUEQ V_FW_WR_EQUEQ(1U)
-
-/* flow context identifier (lo)
- */
-#define S_FW_WR_FLOWID 8
-#define M_FW_WR_FLOWID 0xfffff
-#define V_FW_WR_FLOWID(x) ((x) << S_FW_WR_FLOWID)
-#define G_FW_WR_FLOWID(x) (((x) >> S_FW_WR_FLOWID) & M_FW_WR_FLOWID)
-
-/* length in units of 16-bytes (lo)
- */
-#define S_FW_WR_LEN16 0
-#define M_FW_WR_LEN16 0xff
-#define V_FW_WR_LEN16(x) ((x) << S_FW_WR_LEN16)
-#define G_FW_WR_LEN16(x) (((x) >> S_FW_WR_LEN16) & M_FW_WR_LEN16)
-
-struct fw_frag_wr {
- __be32 op_to_fragoff16;
- __be32 flowid_len16;
- __be64 r4;
-};
-
-#define S_FW_FRAG_WR_EOF 15
-#define M_FW_FRAG_WR_EOF 0x1
-#define V_FW_FRAG_WR_EOF(x) ((x) << S_FW_FRAG_WR_EOF)
-#define G_FW_FRAG_WR_EOF(x) (((x) >> S_FW_FRAG_WR_EOF) & M_FW_FRAG_WR_EOF)
-#define F_FW_FRAG_WR_EOF V_FW_FRAG_WR_EOF(1U)
-
-#define S_FW_FRAG_WR_FRAGOFF16 8
-#define M_FW_FRAG_WR_FRAGOFF16 0x7f
-#define V_FW_FRAG_WR_FRAGOFF16(x) ((x) << S_FW_FRAG_WR_FRAGOFF16)
-#define G_FW_FRAG_WR_FRAGOFF16(x) \
- (((x) >> S_FW_FRAG_WR_FRAGOFF16) & M_FW_FRAG_WR_FRAGOFF16)
-
-/* valid filter configurations for compressed tuple
- * Encodings: TPL - Compressed TUPLE for filter in addition to 4-tuple
- * FR - FRAGMENT, FC - FCoE, MT - MPS MATCH TYPE, M - MPS MATCH,
- * E - Ethertype, P - Port, PR - Protocol, T - TOS, IV - Inner VLAN,
- * OV - Outer VLAN/VNIC_ID,
-*/
-#define HW_TPL_FR_MT_M_E_P_FC 0x3C3
-#define HW_TPL_FR_MT_M_PR_T_FC 0x3B3
-#define HW_TPL_FR_MT_M_IV_P_FC 0x38B
-#define HW_TPL_FR_MT_M_OV_P_FC 0x387
-#define HW_TPL_FR_MT_E_PR_T 0x370
-#define HW_TPL_FR_MT_E_PR_P_FC 0X363
-#define HW_TPL_FR_MT_E_T_P_FC 0X353
-#define HW_TPL_FR_MT_PR_IV_P_FC 0X32B
-#define HW_TPL_FR_MT_PR_OV_P_FC 0X327
-#define HW_TPL_FR_MT_T_IV_P_FC 0X31B
-#define HW_TPL_FR_MT_T_OV_P_FC 0X317
-#define HW_TPL_FR_M_E_PR_FC 0X2E1
-#define HW_TPL_FR_M_E_T_FC 0X2D1
-#define HW_TPL_FR_M_PR_IV_FC 0X2A9
-#define HW_TPL_FR_M_PR_OV_FC 0X2A5
-#define HW_TPL_FR_M_T_IV_FC 0X299
-#define HW_TPL_FR_M_T_OV_FC 0X295
-#define HW_TPL_FR_E_PR_T_P 0X272
-#define HW_TPL_FR_E_PR_T_FC 0X271
-#define HW_TPL_FR_E_IV_FC 0X249
-#define HW_TPL_FR_E_OV_FC 0X245
-#define HW_TPL_FR_PR_T_IV_FC 0X239
-#define HW_TPL_FR_PR_T_OV_FC 0X235
-#define HW_TPL_FR_IV_OV_FC 0X20D
-#define HW_TPL_MT_M_E_PR 0X1E0
-#define HW_TPL_MT_M_E_T 0X1D0
-#define HW_TPL_MT_E_PR_T_FC 0X171
-#define HW_TPL_MT_E_IV 0X148
-#define HW_TPL_MT_E_OV 0X144
-#define HW_TPL_MT_PR_T_IV 0X138
-#define HW_TPL_MT_PR_T_OV 0X134
-#define HW_TPL_M_E_PR_P 0X0E2
-#define HW_TPL_M_E_T_P 0X0D2
-#define HW_TPL_E_PR_T_P_FC 0X073
-#define HW_TPL_E_IV_P 0X04A
-#define HW_TPL_E_OV_P 0X046
-#define HW_TPL_PR_T_IV_P 0X03A
-#define HW_TPL_PR_T_OV_P 0X036
-
-/* filter wr reply code in cookie in CPL_SET_TCB_RPL */
-enum fw_filter_wr_cookie {
- FW_FILTER_WR_SUCCESS,
- FW_FILTER_WR_FLT_ADDED,
- FW_FILTER_WR_FLT_DELETED,
- FW_FILTER_WR_SMT_TBL_FULL,
- FW_FILTER_WR_EINVAL,
-};
-
-struct fw_filter_wr {
- __be32 op_pkd;
- __be32 len16_pkd;
- __be64 r3;
- __be32 tid_to_iq;
- __be32 del_filter_to_l2tix;
- __be16 ethtype;
- __be16 ethtypem;
- __u8 frag_to_ovlan_vldm;
- __u8 smac_sel;
- __be16 rx_chan_rx_rpl_iq;
- __be32 maci_to_matchtypem;
- __u8 ptcl;
- __u8 ptclm;
- __u8 ttyp;
- __u8 ttypm;
- __be16 ivlan;
- __be16 ivlanm;
- __be16 ovlan;
- __be16 ovlanm;
- __u8 lip[16];
- __u8 lipm[16];
- __u8 fip[16];
- __u8 fipm[16];
- __be16 lp;
- __be16 lpm;
- __be16 fp;
- __be16 fpm;
- __be16 r7;
- __u8 sma[6];
-};
-
-#define S_FW_FILTER_WR_TID 12
-#define M_FW_FILTER_WR_TID 0xfffff
-#define V_FW_FILTER_WR_TID(x) ((x) << S_FW_FILTER_WR_TID)
-#define G_FW_FILTER_WR_TID(x) \
- (((x) >> S_FW_FILTER_WR_TID) & M_FW_FILTER_WR_TID)
-
-#define S_FW_FILTER_WR_RQTYPE 11
-#define M_FW_FILTER_WR_RQTYPE 0x1
-#define V_FW_FILTER_WR_RQTYPE(x) ((x) << S_FW_FILTER_WR_RQTYPE)
-#define G_FW_FILTER_WR_RQTYPE(x) \
- (((x) >> S_FW_FILTER_WR_RQTYPE) & M_FW_FILTER_WR_RQTYPE)
-#define F_FW_FILTER_WR_RQTYPE V_FW_FILTER_WR_RQTYPE(1U)
-
-#define S_FW_FILTER_WR_NOREPLY 10
-#define M_FW_FILTER_WR_NOREPLY 0x1
-#define V_FW_FILTER_WR_NOREPLY(x) ((x) << S_FW_FILTER_WR_NOREPLY)
-#define G_FW_FILTER_WR_NOREPLY(x) \
- (((x) >> S_FW_FILTER_WR_NOREPLY) & M_FW_FILTER_WR_NOREPLY)
-#define F_FW_FILTER_WR_NOREPLY V_FW_FILTER_WR_NOREPLY(1U)
-
-#define S_FW_FILTER_WR_IQ 0
-#define M_FW_FILTER_WR_IQ 0x3ff
-#define V_FW_FILTER_WR_IQ(x) ((x) << S_FW_FILTER_WR_IQ)
-#define G_FW_FILTER_WR_IQ(x) \
- (((x) >> S_FW_FILTER_WR_IQ) & M_FW_FILTER_WR_IQ)
-
-#define S_FW_FILTER_WR_DEL_FILTER 31
-#define M_FW_FILTER_WR_DEL_FILTER 0x1
-#define V_FW_FILTER_WR_DEL_FILTER(x) ((x) << S_FW_FILTER_WR_DEL_FILTER)
-#define G_FW_FILTER_WR_DEL_FILTER(x) \
- (((x) >> S_FW_FILTER_WR_DEL_FILTER) & M_FW_FILTER_WR_DEL_FILTER)
-#define F_FW_FILTER_WR_DEL_FILTER V_FW_FILTER_WR_DEL_FILTER(1U)
-
-#define S_FW_FILTER_WR_RPTTID 25
-#define M_FW_FILTER_WR_RPTTID 0x1
-#define V_FW_FILTER_WR_RPTTID(x) ((x) << S_FW_FILTER_WR_RPTTID)
-#define G_FW_FILTER_WR_RPTTID(x) \
- (((x) >> S_FW_FILTER_WR_RPTTID) & M_FW_FILTER_WR_RPTTID)
-#define F_FW_FILTER_WR_RPTTID V_FW_FILTER_WR_RPTTID(1U)
-
-#define S_FW_FILTER_WR_DROP 24
-#define M_FW_FILTER_WR_DROP 0x1
-#define V_FW_FILTER_WR_DROP(x) ((x) << S_FW_FILTER_WR_DROP)
-#define G_FW_FILTER_WR_DROP(x) \
- (((x) >> S_FW_FILTER_WR_DROP) & M_FW_FILTER_WR_DROP)
-#define F_FW_FILTER_WR_DROP V_FW_FILTER_WR_DROP(1U)
-
-#define S_FW_FILTER_WR_DIRSTEER 23
-#define M_FW_FILTER_WR_DIRSTEER 0x1
-#define V_FW_FILTER_WR_DIRSTEER(x) ((x) << S_FW_FILTER_WR_DIRSTEER)
-#define G_FW_FILTER_WR_DIRSTEER(x) \
- (((x) >> S_FW_FILTER_WR_DIRSTEER) & M_FW_FILTER_WR_DIRSTEER)
-#define F_FW_FILTER_WR_DIRSTEER V_FW_FILTER_WR_DIRSTEER(1U)
-
-#define S_FW_FILTER_WR_MASKHASH 22
-#define M_FW_FILTER_WR_MASKHASH 0x1
-#define V_FW_FILTER_WR_MASKHASH(x) ((x) << S_FW_FILTER_WR_MASKHASH)
-#define G_FW_FILTER_WR_MASKHASH(x) \
- (((x) >> S_FW_FILTER_WR_MASKHASH) & M_FW_FILTER_WR_MASKHASH)
-#define F_FW_FILTER_WR_MASKHASH V_FW_FILTER_WR_MASKHASH(1U)
-
-#define S_FW_FILTER_WR_DIRSTEERHASH 21
-#define M_FW_FILTER_WR_DIRSTEERHASH 0x1
-#define V_FW_FILTER_WR_DIRSTEERHASH(x) ((x) << S_FW_FILTER_WR_DIRSTEERHASH)
-#define G_FW_FILTER_WR_DIRSTEERHASH(x) \
- (((x) >> S_FW_FILTER_WR_DIRSTEERHASH) & M_FW_FILTER_WR_DIRSTEERHASH)
-#define F_FW_FILTER_WR_DIRSTEERHASH V_FW_FILTER_WR_DIRSTEERHASH(1U)
-
-#define S_FW_FILTER_WR_LPBK 20
-#define M_FW_FILTER_WR_LPBK 0x1
-#define V_FW_FILTER_WR_LPBK(x) ((x) << S_FW_FILTER_WR_LPBK)
-#define G_FW_FILTER_WR_LPBK(x) \
- (((x) >> S_FW_FILTER_WR_LPBK) & M_FW_FILTER_WR_LPBK)
-#define F_FW_FILTER_WR_LPBK V_FW_FILTER_WR_LPBK(1U)
-
-#define S_FW_FILTER_WR_DMAC 19
-#define M_FW_FILTER_WR_DMAC 0x1
-#define V_FW_FILTER_WR_DMAC(x) ((x) << S_FW_FILTER_WR_DMAC)
-#define G_FW_FILTER_WR_DMAC(x) \
- (((x) >> S_FW_FILTER_WR_DMAC) & M_FW_FILTER_WR_DMAC)
-#define F_FW_FILTER_WR_DMAC V_FW_FILTER_WR_DMAC(1U)
-
-#define S_FW_FILTER_WR_SMAC 18
-#define M_FW_FILTER_WR_SMAC 0x1
-#define V_FW_FILTER_WR_SMAC(x) ((x) << S_FW_FILTER_WR_SMAC)
-#define G_FW_FILTER_WR_SMAC(x) \
- (((x) >> S_FW_FILTER_WR_SMAC) & M_FW_FILTER_WR_SMAC)
-#define F_FW_FILTER_WR_SMAC V_FW_FILTER_WR_SMAC(1U)
-
-#define S_FW_FILTER_WR_INSVLAN 17
-#define M_FW_FILTER_WR_INSVLAN 0x1
-#define V_FW_FILTER_WR_INSVLAN(x) ((x) << S_FW_FILTER_WR_INSVLAN)
-#define G_FW_FILTER_WR_INSVLAN(x) \
- (((x) >> S_FW_FILTER_WR_INSVLAN) & M_FW_FILTER_WR_INSVLAN)
-#define F_FW_FILTER_WR_INSVLAN V_FW_FILTER_WR_INSVLAN(1U)
-
-#define S_FW_FILTER_WR_RMVLAN 16
-#define M_FW_FILTER_WR_RMVLAN 0x1
-#define V_FW_FILTER_WR_RMVLAN(x) ((x) << S_FW_FILTER_WR_RMVLAN)
-#define G_FW_FILTER_WR_RMVLAN(x) \
- (((x) >> S_FW_FILTER_WR_RMVLAN) & M_FW_FILTER_WR_RMVLAN)
-#define F_FW_FILTER_WR_RMVLAN V_FW_FILTER_WR_RMVLAN(1U)
-
-#define S_FW_FILTER_WR_HITCNTS 15
-#define M_FW_FILTER_WR_HITCNTS 0x1
-#define V_FW_FILTER_WR_HITCNTS(x) ((x) << S_FW_FILTER_WR_HITCNTS)
-#define G_FW_FILTER_WR_HITCNTS(x) \
- (((x) >> S_FW_FILTER_WR_HITCNTS) & M_FW_FILTER_WR_HITCNTS)
-#define F_FW_FILTER_WR_HITCNTS V_FW_FILTER_WR_HITCNTS(1U)
-
-#define S_FW_FILTER_WR_TXCHAN 13
-#define M_FW_FILTER_WR_TXCHAN 0x3
-#define V_FW_FILTER_WR_TXCHAN(x) ((x) << S_FW_FILTER_WR_TXCHAN)
-#define G_FW_FILTER_WR_TXCHAN(x) \
- (((x) >> S_FW_FILTER_WR_TXCHAN) & M_FW_FILTER_WR_TXCHAN)
-
-#define S_FW_FILTER_WR_PRIO 12
-#define M_FW_FILTER_WR_PRIO 0x1
-#define V_FW_FILTER_WR_PRIO(x) ((x) << S_FW_FILTER_WR_PRIO)
-#define G_FW_FILTER_WR_PRIO(x) \
- (((x) >> S_FW_FILTER_WR_PRIO) & M_FW_FILTER_WR_PRIO)
-#define F_FW_FILTER_WR_PRIO V_FW_FILTER_WR_PRIO(1U)
-
-#define S_FW_FILTER_WR_L2TIX 0
-#define M_FW_FILTER_WR_L2TIX 0xfff
-#define V_FW_FILTER_WR_L2TIX(x) ((x) << S_FW_FILTER_WR_L2TIX)
-#define G_FW_FILTER_WR_L2TIX(x) \
- (((x) >> S_FW_FILTER_WR_L2TIX) & M_FW_FILTER_WR_L2TIX)
-
-#define S_FW_FILTER_WR_FRAG 7
-#define M_FW_FILTER_WR_FRAG 0x1
-#define V_FW_FILTER_WR_FRAG(x) ((x) << S_FW_FILTER_WR_FRAG)
-#define G_FW_FILTER_WR_FRAG(x) \
- (((x) >> S_FW_FILTER_WR_FRAG) & M_FW_FILTER_WR_FRAG)
-#define F_FW_FILTER_WR_FRAG V_FW_FILTER_WR_FRAG(1U)
-
-#define S_FW_FILTER_WR_FRAGM 6
-#define M_FW_FILTER_WR_FRAGM 0x1
-#define V_FW_FILTER_WR_FRAGM(x) ((x) << S_FW_FILTER_WR_FRAGM)
-#define G_FW_FILTER_WR_FRAGM(x) \
- (((x) >> S_FW_FILTER_WR_FRAGM) & M_FW_FILTER_WR_FRAGM)
-#define F_FW_FILTER_WR_FRAGM V_FW_FILTER_WR_FRAGM(1U)
-
-#define S_FW_FILTER_WR_IVLAN_VLD 5
-#define M_FW_FILTER_WR_IVLAN_VLD 0x1
-#define V_FW_FILTER_WR_IVLAN_VLD(x) ((x) << S_FW_FILTER_WR_IVLAN_VLD)
-#define G_FW_FILTER_WR_IVLAN_VLD(x) \
- (((x) >> S_FW_FILTER_WR_IVLAN_VLD) & M_FW_FILTER_WR_IVLAN_VLD)
-#define F_FW_FILTER_WR_IVLAN_VLD V_FW_FILTER_WR_IVLAN_VLD(1U)
-
-#define S_FW_FILTER_WR_OVLAN_VLD 4
-#define M_FW_FILTER_WR_OVLAN_VLD 0x1
-#define V_FW_FILTER_WR_OVLAN_VLD(x) ((x) << S_FW_FILTER_WR_OVLAN_VLD)
-#define G_FW_FILTER_WR_OVLAN_VLD(x) \
- (((x) >> S_FW_FILTER_WR_OVLAN_VLD) & M_FW_FILTER_WR_OVLAN_VLD)
-#define F_FW_FILTER_WR_OVLAN_VLD V_FW_FILTER_WR_OVLAN_VLD(1U)
-
-#define S_FW_FILTER_WR_IVLAN_VLDM 3
-#define M_FW_FILTER_WR_IVLAN_VLDM 0x1
-#define V_FW_FILTER_WR_IVLAN_VLDM(x) ((x) << S_FW_FILTER_WR_IVLAN_VLDM)
-#define G_FW_FILTER_WR_IVLAN_VLDM(x) \
- (((x) >> S_FW_FILTER_WR_IVLAN_VLDM) & M_FW_FILTER_WR_IVLAN_VLDM)
-#define F_FW_FILTER_WR_IVLAN_VLDM V_FW_FILTER_WR_IVLAN_VLDM(1U)
-
-#define S_FW_FILTER_WR_OVLAN_VLDM 2
-#define M_FW_FILTER_WR_OVLAN_VLDM 0x1
-#define V_FW_FILTER_WR_OVLAN_VLDM(x) ((x) << S_FW_FILTER_WR_OVLAN_VLDM)
-#define G_FW_FILTER_WR_OVLAN_VLDM(x) \
- (((x) >> S_FW_FILTER_WR_OVLAN_VLDM) & M_FW_FILTER_WR_OVLAN_VLDM)
-#define F_FW_FILTER_WR_OVLAN_VLDM V_FW_FILTER_WR_OVLAN_VLDM(1U)
-
-#define S_FW_FILTER_WR_RX_CHAN 15
-#define M_FW_FILTER_WR_RX_CHAN 0x1
-#define V_FW_FILTER_WR_RX_CHAN(x) ((x) << S_FW_FILTER_WR_RX_CHAN)
-#define G_FW_FILTER_WR_RX_CHAN(x) \
- (((x) >> S_FW_FILTER_WR_RX_CHAN) & M_FW_FILTER_WR_RX_CHAN)
-#define F_FW_FILTER_WR_RX_CHAN V_FW_FILTER_WR_RX_CHAN(1U)
-
-#define S_FW_FILTER_WR_RX_RPL_IQ 0
-#define M_FW_FILTER_WR_RX_RPL_IQ 0x3ff
-#define V_FW_FILTER_WR_RX_RPL_IQ(x) ((x) << S_FW_FILTER_WR_RX_RPL_IQ)
-#define G_FW_FILTER_WR_RX_RPL_IQ(x) \
- (((x) >> S_FW_FILTER_WR_RX_RPL_IQ) & M_FW_FILTER_WR_RX_RPL_IQ)
-
-#define S_FW_FILTER_WR_MACI 23
-#define M_FW_FILTER_WR_MACI 0x1ff
-#define V_FW_FILTER_WR_MACI(x) ((x) << S_FW_FILTER_WR_MACI)
-#define G_FW_FILTER_WR_MACI(x) \
- (((x) >> S_FW_FILTER_WR_MACI) & M_FW_FILTER_WR_MACI)
-
-#define S_FW_FILTER_WR_MACIM 14
-#define M_FW_FILTER_WR_MACIM 0x1ff
-#define V_FW_FILTER_WR_MACIM(x) ((x) << S_FW_FILTER_WR_MACIM)
-#define G_FW_FILTER_WR_MACIM(x) \
- (((x) >> S_FW_FILTER_WR_MACIM) & M_FW_FILTER_WR_MACIM)
-
-#define S_FW_FILTER_WR_FCOE 13
-#define M_FW_FILTER_WR_FCOE 0x1
-#define V_FW_FILTER_WR_FCOE(x) ((x) << S_FW_FILTER_WR_FCOE)
-#define G_FW_FILTER_WR_FCOE(x) \
- (((x) >> S_FW_FILTER_WR_FCOE) & M_FW_FILTER_WR_FCOE)
-#define F_FW_FILTER_WR_FCOE V_FW_FILTER_WR_FCOE(1U)
-
-#define S_FW_FILTER_WR_FCOEM 12
-#define M_FW_FILTER_WR_FCOEM 0x1
-#define V_FW_FILTER_WR_FCOEM(x) ((x) << S_FW_FILTER_WR_FCOEM)
-#define G_FW_FILTER_WR_FCOEM(x) \
- (((x) >> S_FW_FILTER_WR_FCOEM) & M_FW_FILTER_WR_FCOEM)
-#define F_FW_FILTER_WR_FCOEM V_FW_FILTER_WR_FCOEM(1U)
-
-#define S_FW_FILTER_WR_PORT 9
-#define M_FW_FILTER_WR_PORT 0x7
-#define V_FW_FILTER_WR_PORT(x) ((x) << S_FW_FILTER_WR_PORT)
-#define G_FW_FILTER_WR_PORT(x) \
- (((x) >> S_FW_FILTER_WR_PORT) & M_FW_FILTER_WR_PORT)
-
-#define S_FW_FILTER_WR_PORTM 6
-#define M_FW_FILTER_WR_PORTM 0x7
-#define V_FW_FILTER_WR_PORTM(x) ((x) << S_FW_FILTER_WR_PORTM)
-#define G_FW_FILTER_WR_PORTM(x) \
- (((x) >> S_FW_FILTER_WR_PORTM) & M_FW_FILTER_WR_PORTM)
-
-#define S_FW_FILTER_WR_MATCHTYPE 3
-#define M_FW_FILTER_WR_MATCHTYPE 0x7
-#define V_FW_FILTER_WR_MATCHTYPE(x) ((x) << S_FW_FILTER_WR_MATCHTYPE)
-#define G_FW_FILTER_WR_MATCHTYPE(x) \
- (((x) >> S_FW_FILTER_WR_MATCHTYPE) & M_FW_FILTER_WR_MATCHTYPE)
-
-#define S_FW_FILTER_WR_MATCHTYPEM 0
-#define M_FW_FILTER_WR_MATCHTYPEM 0x7
-#define V_FW_FILTER_WR_MATCHTYPEM(x) ((x) << S_FW_FILTER_WR_MATCHTYPEM)
-#define G_FW_FILTER_WR_MATCHTYPEM(x) \
- (((x) >> S_FW_FILTER_WR_MATCHTYPEM) & M_FW_FILTER_WR_MATCHTYPEM)
-
-struct fw_ulptx_wr {
- __be32 op_to_compl;
- __be32 flowid_len16;
- __u64 cookie;
-};
-
-struct fw_tp_wr {
- __be32 op_to_immdlen;
- __be32 flowid_len16;
- __u64 cookie;
-};
-
-struct fw_eth_tx_pkt_wr {
- __be32 op_immdlen;
- __be32 equiq_to_len16;
- __be64 r3;
-};
-
-#define S_FW_ETH_TX_PKT_WR_IMMDLEN 0
-#define M_FW_ETH_TX_PKT_WR_IMMDLEN 0x1ff
-#define V_FW_ETH_TX_PKT_WR_IMMDLEN(x) ((x) << S_FW_ETH_TX_PKT_WR_IMMDLEN)
-#define G_FW_ETH_TX_PKT_WR_IMMDLEN(x) \
- (((x) >> S_FW_ETH_TX_PKT_WR_IMMDLEN) & M_FW_ETH_TX_PKT_WR_IMMDLEN)
-
-struct fw_eth_tx_pkt2_wr {
- __be32 op_immdlen;
- __be32 equiq_to_len16;
- __be32 r3;
- __be32 L4ChkDisable_to_IpHdrLen;
-};
-
-#define S_FW_ETH_TX_PKT2_WR_IMMDLEN 0
-#define M_FW_ETH_TX_PKT2_WR_IMMDLEN 0x1ff
-#define V_FW_ETH_TX_PKT2_WR_IMMDLEN(x) ((x) << S_FW_ETH_TX_PKT2_WR_IMMDLEN)
-#define G_FW_ETH_TX_PKT2_WR_IMMDLEN(x) \
- (((x) >> S_FW_ETH_TX_PKT2_WR_IMMDLEN) & M_FW_ETH_TX_PKT2_WR_IMMDLEN)
-
-#define S_FW_ETH_TX_PKT2_WR_L4CHKDISABLE 31
-#define M_FW_ETH_TX_PKT2_WR_L4CHKDISABLE 0x1
-#define V_FW_ETH_TX_PKT2_WR_L4CHKDISABLE(x) \
- ((x) << S_FW_ETH_TX_PKT2_WR_L4CHKDISABLE)
-#define G_FW_ETH_TX_PKT2_WR_L4CHKDISABLE(x) \
- (((x) >> S_FW_ETH_TX_PKT2_WR_L4CHKDISABLE) & \
- M_FW_ETH_TX_PKT2_WR_L4CHKDISABLE)
-#define F_FW_ETH_TX_PKT2_WR_L4CHKDISABLE \
- V_FW_ETH_TX_PKT2_WR_L4CHKDISABLE(1U)
-
-#define S_FW_ETH_TX_PKT2_WR_L3CHKDISABLE 30
-#define M_FW_ETH_TX_PKT2_WR_L3CHKDISABLE 0x1
-#define V_FW_ETH_TX_PKT2_WR_L3CHKDISABLE(x) \
- ((x) << S_FW_ETH_TX_PKT2_WR_L3CHKDISABLE)
-#define G_FW_ETH_TX_PKT2_WR_L3CHKDISABLE(x) \
- (((x) >> S_FW_ETH_TX_PKT2_WR_L3CHKDISABLE) & \
- M_FW_ETH_TX_PKT2_WR_L3CHKDISABLE)
-#define F_FW_ETH_TX_PKT2_WR_L3CHKDISABLE \
- V_FW_ETH_TX_PKT2_WR_L3CHKDISABLE(1U)
-
-#define S_FW_ETH_TX_PKT2_WR_IVLAN 28
-#define M_FW_ETH_TX_PKT2_WR_IVLAN 0x1
-#define V_FW_ETH_TX_PKT2_WR_IVLAN(x) ((x) << S_FW_ETH_TX_PKT2_WR_IVLAN)
-#define G_FW_ETH_TX_PKT2_WR_IVLAN(x) \
- (((x) >> S_FW_ETH_TX_PKT2_WR_IVLAN) & M_FW_ETH_TX_PKT2_WR_IVLAN)
-#define F_FW_ETH_TX_PKT2_WR_IVLAN V_FW_ETH_TX_PKT2_WR_IVLAN(1U)
-
-#define S_FW_ETH_TX_PKT2_WR_IVLANTAG 12
-#define M_FW_ETH_TX_PKT2_WR_IVLANTAG 0xffff
-#define V_FW_ETH_TX_PKT2_WR_IVLANTAG(x) ((x) << S_FW_ETH_TX_PKT2_WR_IVLANTAG)
-#define G_FW_ETH_TX_PKT2_WR_IVLANTAG(x) \
- (((x) >> S_FW_ETH_TX_PKT2_WR_IVLANTAG) & M_FW_ETH_TX_PKT2_WR_IVLANTAG)
-
-#define S_FW_ETH_TX_PKT2_WR_CHKTYPE 8
-#define M_FW_ETH_TX_PKT2_WR_CHKTYPE 0xf
-#define V_FW_ETH_TX_PKT2_WR_CHKTYPE(x) ((x) << S_FW_ETH_TX_PKT2_WR_CHKTYPE)
-#define G_FW_ETH_TX_PKT2_WR_CHKTYPE(x) \
- (((x) >> S_FW_ETH_TX_PKT2_WR_CHKTYPE) & M_FW_ETH_TX_PKT2_WR_CHKTYPE)
-
-#define S_FW_ETH_TX_PKT2_WR_IPHDRLEN 0
-#define M_FW_ETH_TX_PKT2_WR_IPHDRLEN 0xff
-#define V_FW_ETH_TX_PKT2_WR_IPHDRLEN(x) ((x) << S_FW_ETH_TX_PKT2_WR_IPHDRLEN)
-#define G_FW_ETH_TX_PKT2_WR_IPHDRLEN(x) \
- (((x) >> S_FW_ETH_TX_PKT2_WR_IPHDRLEN) & M_FW_ETH_TX_PKT2_WR_IPHDRLEN)
-
-struct fw_eth_tx_pkts_wr {
- __be32 op_pkd;
- __be32 equiq_to_len16;
- __be32 r3;
- __be16 plen;
- __u8 npkt;
- __u8 type;
-};
-
-struct fw_eth_tx_uo_wr {
- __be32 op_immdlen;
- __be32 equiq_to_len16;
- __be64 r3;
- __u8 r4;
- __u8 ethlen;
- __be16 iplen;
- __u8 udplen;
- __u8 rtplen;
- __be16 r5;
- __be16 mss;
- __be16 schedpktsize;
- __be32 length;
-};
-
-struct fw_eq_flush_wr {
- __u8 opcode;
- __u8 r1[3];
- __be32 equiq_to_len16;
- __be64 r3;
-};
-
-struct fw_ofld_connection_wr {
- __be32 op_compl;
- __be32 len16_pkd;
- __u64 cookie;
- __be64 r2;
- __be64 r3;
- struct fw_ofld_connection_le {
- __be32 version_cpl;
- __be32 filter;
- __be32 r1;
- __be16 lport;
- __be16 pport;
- union fw_ofld_connection_leip {
- struct fw_ofld_connection_le_ipv4 {
- __be32 pip;
- __be32 lip;
- __be64 r0;
- __be64 r1;
- __be64 r2;
- } ipv4;
- struct fw_ofld_connection_le_ipv6 {
- __be64 pip_hi;
- __be64 pip_lo;
- __be64 lip_hi;
- __be64 lip_lo;
- } ipv6;
- } u;
- } le;
- struct fw_ofld_connection_tcb {
- __be32 t_state_to_astid;
- __be16 cplrxdataack_cplpassacceptrpl;
- __be16 rcv_adv;
- __be32 rcv_nxt;
- __be32 tx_max;
- __be64 opt0;
- __be32 opt2;
- __be32 r1;
- __be64 r2;
- __be64 r3;
- } tcb;
-};
-
-#define S_FW_OFLD_CONNECTION_WR_VERSION 31
-#define M_FW_OFLD_CONNECTION_WR_VERSION 0x1
-#define V_FW_OFLD_CONNECTION_WR_VERSION(x) \
- ((x) << S_FW_OFLD_CONNECTION_WR_VERSION)
-#define G_FW_OFLD_CONNECTION_WR_VERSION(x) \
- (((x) >> S_FW_OFLD_CONNECTION_WR_VERSION) & \
- M_FW_OFLD_CONNECTION_WR_VERSION)
-#define F_FW_OFLD_CONNECTION_WR_VERSION V_FW_OFLD_CONNECTION_WR_VERSION(1U)
-
-#define S_FW_OFLD_CONNECTION_WR_CPL 30
-#define M_FW_OFLD_CONNECTION_WR_CPL 0x1
-#define V_FW_OFLD_CONNECTION_WR_CPL(x) ((x) << S_FW_OFLD_CONNECTION_WR_CPL)
-#define G_FW_OFLD_CONNECTION_WR_CPL(x) \
- (((x) >> S_FW_OFLD_CONNECTION_WR_CPL) & M_FW_OFLD_CONNECTION_WR_CPL)
-#define F_FW_OFLD_CONNECTION_WR_CPL V_FW_OFLD_CONNECTION_WR_CPL(1U)
-
-#define S_FW_OFLD_CONNECTION_WR_T_STATE 28
-#define M_FW_OFLD_CONNECTION_WR_T_STATE 0xf
-#define V_FW_OFLD_CONNECTION_WR_T_STATE(x) \
- ((x) << S_FW_OFLD_CONNECTION_WR_T_STATE)
-#define G_FW_OFLD_CONNECTION_WR_T_STATE(x) \
- (((x) >> S_FW_OFLD_CONNECTION_WR_T_STATE) & \
- M_FW_OFLD_CONNECTION_WR_T_STATE)
-
-#define S_FW_OFLD_CONNECTION_WR_RCV_SCALE 24
-#define M_FW_OFLD_CONNECTION_WR_RCV_SCALE 0xf
-#define V_FW_OFLD_CONNECTION_WR_RCV_SCALE(x) \
- ((x) << S_FW_OFLD_CONNECTION_WR_RCV_SCALE)
-#define G_FW_OFLD_CONNECTION_WR_RCV_SCALE(x) \
- (((x) >> S_FW_OFLD_CONNECTION_WR_RCV_SCALE) & \
- M_FW_OFLD_CONNECTION_WR_RCV_SCALE)
-
-#define S_FW_OFLD_CONNECTION_WR_ASTID 0
-#define M_FW_OFLD_CONNECTION_WR_ASTID 0xffffff
-#define V_FW_OFLD_CONNECTION_WR_ASTID(x) \
- ((x) << S_FW_OFLD_CONNECTION_WR_ASTID)
-#define G_FW_OFLD_CONNECTION_WR_ASTID(x) \
- (((x) >> S_FW_OFLD_CONNECTION_WR_ASTID) & M_FW_OFLD_CONNECTION_WR_ASTID)
-
-#define S_FW_OFLD_CONNECTION_WR_CPLRXDATAACK 15
-#define M_FW_OFLD_CONNECTION_WR_CPLRXDATAACK 0x1
-#define V_FW_OFLD_CONNECTION_WR_CPLRXDATAACK(x) \
- ((x) << S_FW_OFLD_CONNECTION_WR_CPLRXDATAACK)
-#define G_FW_OFLD_CONNECTION_WR_CPLRXDATAACK(x) \
- (((x) >> S_FW_OFLD_CONNECTION_WR_CPLRXDATAACK) & \
- M_FW_OFLD_CONNECTION_WR_CPLRXDATAACK)
-#define F_FW_OFLD_CONNECTION_WR_CPLRXDATAACK \
- V_FW_OFLD_CONNECTION_WR_CPLRXDATAACK(1U)
-
-#define S_FW_OFLD_CONNECTION_WR_CPLPASSACCEPTRPL 14
-#define M_FW_OFLD_CONNECTION_WR_CPLPASSACCEPTRPL 0x1
-#define V_FW_OFLD_CONNECTION_WR_CPLPASSACCEPTRPL(x) \
- ((x) << S_FW_OFLD_CONNECTION_WR_CPLPASSACCEPTRPL)
-#define G_FW_OFLD_CONNECTION_WR_CPLPASSACCEPTRPL(x) \
- (((x) >> S_FW_OFLD_CONNECTION_WR_CPLPASSACCEPTRPL) & \
- M_FW_OFLD_CONNECTION_WR_CPLPASSACCEPTRPL)
-#define F_FW_OFLD_CONNECTION_WR_CPLPASSACCEPTRPL \
- V_FW_OFLD_CONNECTION_WR_CPLPASSACCEPTRPL(1U)
-
-enum fw_flowc_mnem_tcpstate {
- FW_FLOWC_MNEM_TCPSTATE_CLOSED = 0, /* illegal */
- FW_FLOWC_MNEM_TCPSTATE_LISTEN = 1, /* illegal */
- FW_FLOWC_MNEM_TCPSTATE_SYNSENT = 2, /* illegal */
- FW_FLOWC_MNEM_TCPSTATE_SYNRECEIVED = 3, /* illegal */
- FW_FLOWC_MNEM_TCPSTATE_ESTABLISHED = 4, /* default */
- FW_FLOWC_MNEM_TCPSTATE_CLOSEWAIT = 5, /* got peer close already */
- FW_FLOWC_MNEM_TCPSTATE_FINWAIT1 = 6, /* haven't gotten ACK for FIN and
- * will resend FIN - equiv ESTAB
- */
- FW_FLOWC_MNEM_TCPSTATE_CLOSING = 7, /* haven't gotten ACK for FIN and
- * will resend FIN but have
- * received FIN
- */
- FW_FLOWC_MNEM_TCPSTATE_LASTACK = 8, /* haven't gotten ACK for FIN and
- * will resend FIN but have
- * received FIN
- */
- FW_FLOWC_MNEM_TCPSTATE_FINWAIT2 = 9, /* sent FIN and got FIN + ACK,
- * waiting for FIN
- */
- FW_FLOWC_MNEM_TCPSTATE_TIMEWAIT = 10, /* not expected */
-};
-
-enum fw_flowc_mnem_uostate {
- FW_FLOWC_MNEM_UOSTATE_CLOSED = 0, /* illegal */
- FW_FLOWC_MNEM_UOSTATE_ESTABLISHED = 1, /* default */
- FW_FLOWC_MNEM_UOSTATE_CLOSING = 2, /* graceful close, after sending
- * outstanding payload
- */
- FW_FLOWC_MNEM_UOSTATE_ABORTING = 3, /* immediate close, after
- * discarding outstanding payload
- */
-};
-
-enum fw_flowc_mnem {
- FW_FLOWC_MNEM_PFNVFN = 0, /* PFN [15:8] VFN [7:0] */
- FW_FLOWC_MNEM_CH = 1,
- FW_FLOWC_MNEM_PORT = 2,
- FW_FLOWC_MNEM_IQID = 3,
- FW_FLOWC_MNEM_SNDNXT = 4,
- FW_FLOWC_MNEM_RCVNXT = 5,
- FW_FLOWC_MNEM_SNDBUF = 6,
- FW_FLOWC_MNEM_MSS = 7,
- FW_FLOWC_MNEM_TXDATAPLEN_MAX = 8,
- FW_FLOWC_MNEM_TCPSTATE = 9,
- FW_FLOWC_MNEM_UOSTATE = 10,
- FW_FLOWC_MNEM_SCHEDCLASS = 11,
- FW_FLOWC_MNEM_DCBPRIO = 12,
-};
-
-struct fw_flowc_mnemval {
- __u8 mnemonic;
- __u8 r4[3];
- __be32 val;
-};
-
-struct fw_flowc_wr {
- __be32 op_to_nparams;
- __be32 flowid_len16;
-#ifndef C99_NOT_SUPPORTED
- struct fw_flowc_mnemval mnemval[0];
-#endif
-};
-
-#define S_FW_FLOWC_WR_NPARAMS 0
-#define M_FW_FLOWC_WR_NPARAMS 0xff
-#define V_FW_FLOWC_WR_NPARAMS(x) ((x) << S_FW_FLOWC_WR_NPARAMS)
-#define G_FW_FLOWC_WR_NPARAMS(x) \
- (((x) >> S_FW_FLOWC_WR_NPARAMS) & M_FW_FLOWC_WR_NPARAMS)
-
-struct fw_ofld_tx_data_wr {
- __be32 op_to_immdlen;
- __be32 flowid_len16;
- __be32 plen;
- __be32 lsodisable_to_proxy;
-};
-
-#define S_FW_OFLD_TX_DATA_WR_LSODISABLE 31
-#define M_FW_OFLD_TX_DATA_WR_LSODISABLE 0x1
-#define V_FW_OFLD_TX_DATA_WR_LSODISABLE(x) \
- ((x) << S_FW_OFLD_TX_DATA_WR_LSODISABLE)
-#define G_FW_OFLD_TX_DATA_WR_LSODISABLE(x) \
- (((x) >> S_FW_OFLD_TX_DATA_WR_LSODISABLE) & \
- M_FW_OFLD_TX_DATA_WR_LSODISABLE)
-#define F_FW_OFLD_TX_DATA_WR_LSODISABLE V_FW_OFLD_TX_DATA_WR_LSODISABLE(1U)
-
-#define S_FW_OFLD_TX_DATA_WR_ALIGNPLD 30
-#define M_FW_OFLD_TX_DATA_WR_ALIGNPLD 0x1
-#define V_FW_OFLD_TX_DATA_WR_ALIGNPLD(x) \
- ((x) << S_FW_OFLD_TX_DATA_WR_ALIGNPLD)
-#define G_FW_OFLD_TX_DATA_WR_ALIGNPLD(x) \
- (((x) >> S_FW_OFLD_TX_DATA_WR_ALIGNPLD) & M_FW_OFLD_TX_DATA_WR_ALIGNPLD)
-#define F_FW_OFLD_TX_DATA_WR_ALIGNPLD V_FW_OFLD_TX_DATA_WR_ALIGNPLD(1U)
-
-#define S_FW_OFLD_TX_DATA_WR_ALIGNPLDSHOVE 29
-#define M_FW_OFLD_TX_DATA_WR_ALIGNPLDSHOVE 0x1
-#define V_FW_OFLD_TX_DATA_WR_ALIGNPLDSHOVE(x) \
- ((x) << S_FW_OFLD_TX_DATA_WR_ALIGNPLDSHOVE)
-#define G_FW_OFLD_TX_DATA_WR_ALIGNPLDSHOVE(x) \
- (((x) >> S_FW_OFLD_TX_DATA_WR_ALIGNPLDSHOVE) & \
- M_FW_OFLD_TX_DATA_WR_ALIGNPLDSHOVE)
-#define F_FW_OFLD_TX_DATA_WR_ALIGNPLDSHOVE \
- V_FW_OFLD_TX_DATA_WR_ALIGNPLDSHOVE(1U)
-
-#define S_FW_OFLD_TX_DATA_WR_TUNNEL 19
-#define M_FW_OFLD_TX_DATA_WR_TUNNEL 0x1
-#define V_FW_OFLD_TX_DATA_WR_TUNNEL(x) ((x) << S_FW_OFLD_TX_DATA_WR_TUNNEL)
-#define G_FW_OFLD_TX_DATA_WR_TUNNEL(x) \
- (((x) >> S_FW_OFLD_TX_DATA_WR_TUNNEL) & M_FW_OFLD_TX_DATA_WR_TUNNEL)
-#define F_FW_OFLD_TX_DATA_WR_TUNNEL V_FW_OFLD_TX_DATA_WR_TUNNEL(1U)
-
-#define S_FW_OFLD_TX_DATA_WR_SAVE 18
-#define M_FW_OFLD_TX_DATA_WR_SAVE 0x1
-#define V_FW_OFLD_TX_DATA_WR_SAVE(x) ((x) << S_FW_OFLD_TX_DATA_WR_SAVE)
-#define G_FW_OFLD_TX_DATA_WR_SAVE(x) \
- (((x) >> S_FW_OFLD_TX_DATA_WR_SAVE) & M_FW_OFLD_TX_DATA_WR_SAVE)
-#define F_FW_OFLD_TX_DATA_WR_SAVE V_FW_OFLD_TX_DATA_WR_SAVE(1U)
-
-#define S_FW_OFLD_TX_DATA_WR_FLUSH 17
-#define M_FW_OFLD_TX_DATA_WR_FLUSH 0x1
-#define V_FW_OFLD_TX_DATA_WR_FLUSH(x) ((x) << S_FW_OFLD_TX_DATA_WR_FLUSH)
-#define G_FW_OFLD_TX_DATA_WR_FLUSH(x) \
- (((x) >> S_FW_OFLD_TX_DATA_WR_FLUSH) & M_FW_OFLD_TX_DATA_WR_FLUSH)
-#define F_FW_OFLD_TX_DATA_WR_FLUSH V_FW_OFLD_TX_DATA_WR_FLUSH(1U)
-
-#define S_FW_OFLD_TX_DATA_WR_URGENT 16
-#define M_FW_OFLD_TX_DATA_WR_URGENT 0x1
-#define V_FW_OFLD_TX_DATA_WR_URGENT(x) ((x) << S_FW_OFLD_TX_DATA_WR_URGENT)
-#define G_FW_OFLD_TX_DATA_WR_URGENT(x) \
- (((x) >> S_FW_OFLD_TX_DATA_WR_URGENT) & M_FW_OFLD_TX_DATA_WR_URGENT)
-#define F_FW_OFLD_TX_DATA_WR_URGENT V_FW_OFLD_TX_DATA_WR_URGENT(1U)
-
-#define S_FW_OFLD_TX_DATA_WR_MORE 15
-#define M_FW_OFLD_TX_DATA_WR_MORE 0x1
-#define V_FW_OFLD_TX_DATA_WR_MORE(x) ((x) << S_FW_OFLD_TX_DATA_WR_MORE)
-#define G_FW_OFLD_TX_DATA_WR_MORE(x) \
- (((x) >> S_FW_OFLD_TX_DATA_WR_MORE) & M_FW_OFLD_TX_DATA_WR_MORE)
-#define F_FW_OFLD_TX_DATA_WR_MORE V_FW_OFLD_TX_DATA_WR_MORE(1U)
-
-#define S_FW_OFLD_TX_DATA_WR_SHOVE 14
-#define M_FW_OFLD_TX_DATA_WR_SHOVE 0x1
-#define V_FW_OFLD_TX_DATA_WR_SHOVE(x) ((x) << S_FW_OFLD_TX_DATA_WR_SHOVE)
-#define G_FW_OFLD_TX_DATA_WR_SHOVE(x) \
- (((x) >> S_FW_OFLD_TX_DATA_WR_SHOVE) & M_FW_OFLD_TX_DATA_WR_SHOVE)
-#define F_FW_OFLD_TX_DATA_WR_SHOVE V_FW_OFLD_TX_DATA_WR_SHOVE(1U)
-
-#define S_FW_OFLD_TX_DATA_WR_ULPMODE 10
-#define M_FW_OFLD_TX_DATA_WR_ULPMODE 0xf
-#define V_FW_OFLD_TX_DATA_WR_ULPMODE(x) ((x) << S_FW_OFLD_TX_DATA_WR_ULPMODE)
-#define G_FW_OFLD_TX_DATA_WR_ULPMODE(x) \
- (((x) >> S_FW_OFLD_TX_DATA_WR_ULPMODE) & M_FW_OFLD_TX_DATA_WR_ULPMODE)
-
-#define S_FW_OFLD_TX_DATA_WR_ULPSUBMODE 6
-#define M_FW_OFLD_TX_DATA_WR_ULPSUBMODE 0xf
-#define V_FW_OFLD_TX_DATA_WR_ULPSUBMODE(x) \
- ((x) << S_FW_OFLD_TX_DATA_WR_ULPSUBMODE)
-#define G_FW_OFLD_TX_DATA_WR_ULPSUBMODE(x) \
- (((x) >> S_FW_OFLD_TX_DATA_WR_ULPSUBMODE) & \
- M_FW_OFLD_TX_DATA_WR_ULPSUBMODE)
-
-#define S_FW_OFLD_TX_DATA_WR_PROXY 5
-#define M_FW_OFLD_TX_DATA_WR_PROXY 0x1
-#define V_FW_OFLD_TX_DATA_WR_PROXY(x) ((x) << S_FW_OFLD_TX_DATA_WR_PROXY)
-#define G_FW_OFLD_TX_DATA_WR_PROXY(x) \
- (((x) >> S_FW_OFLD_TX_DATA_WR_PROXY) & M_FW_OFLD_TX_DATA_WR_PROXY)
-#define F_FW_OFLD_TX_DATA_WR_PROXY V_FW_OFLD_TX_DATA_WR_PROXY(1U)
-
-struct fw_cmd_wr {
- __be32 op_dma;
- __be32 len16_pkd;
- __be64 cookie_daddr;
-};
-
-#define S_FW_CMD_WR_DMA 17
-#define M_FW_CMD_WR_DMA 0x1
-#define V_FW_CMD_WR_DMA(x) ((x) << S_FW_CMD_WR_DMA)
-#define G_FW_CMD_WR_DMA(x) (((x) >> S_FW_CMD_WR_DMA) & M_FW_CMD_WR_DMA)
-#define F_FW_CMD_WR_DMA V_FW_CMD_WR_DMA(1U)
-
-struct fw_eth_tx_pkt_vm_wr {
- __be32 op_immdlen;
- __be32 equiq_to_len16;
- __be32 r3[2];
- __u8 ethmacdst[6];
- __u8 ethmacsrc[6];
- __be16 ethtype;
- __be16 vlantci;
-};
-
-/******************************************************************************
- * R I W O R K R E Q U E S T s
- **************************************/
-
-enum fw_ri_wr_opcode {
- FW_RI_RDMA_WRITE = 0x0, /* IETF RDMAP v1.0 ... */
- FW_RI_READ_REQ = 0x1,
- FW_RI_READ_RESP = 0x2,
- FW_RI_SEND = 0x3,
- FW_RI_SEND_WITH_INV = 0x4,
- FW_RI_SEND_WITH_SE = 0x5,
- FW_RI_SEND_WITH_SE_INV = 0x6,
- FW_RI_TERMINATE = 0x7,
- FW_RI_RDMA_INIT = 0x8, /* CHELSIO RI specific ... */
- FW_RI_BIND_MW = 0x9,
- FW_RI_FAST_REGISTER = 0xa,
- FW_RI_LOCAL_INV = 0xb,
- FW_RI_QP_MODIFY = 0xc,
- FW_RI_BYPASS = 0xd,
- FW_RI_RECEIVE = 0xe,
-#if 0
- FW_RI_SEND_IMMEDIATE = 0x8,
- FW_RI_SEND_IMMEDIATE_WITH_SE = 0x9,
- FW_RI_ATOMIC_REQUEST = 0xa,
- FW_RI_ATOMIC_RESPONSE = 0xb,
-
- FW_RI_BIND_MW = 0xc, /* CHELSIO RI specific ... */
- FW_RI_FAST_REGISTER = 0xd,
- FW_RI_LOCAL_INV = 0xe,
-#endif
- FW_RI_SGE_EC_CR_RETURN = 0xf
-};
-
-enum fw_ri_wr_flags {
- FW_RI_COMPLETION_FLAG = 0x01,
- FW_RI_NOTIFICATION_FLAG = 0x02,
- FW_RI_SOLICITED_EVENT_FLAG = 0x04,
- FW_RI_READ_FENCE_FLAG = 0x08,
- FW_RI_LOCAL_FENCE_FLAG = 0x10,
- FW_RI_RDMA_READ_INVALIDATE = 0x20
-};
-
-enum fw_ri_mpa_attrs {
- FW_RI_MPA_RX_MARKER_ENABLE = 0x01,
- FW_RI_MPA_TX_MARKER_ENABLE = 0x02,
- FW_RI_MPA_CRC_ENABLE = 0x04,
- FW_RI_MPA_IETF_ENABLE = 0x08
-};
-
-enum fw_ri_qp_caps {
- FW_RI_QP_RDMA_READ_ENABLE = 0x01,
- FW_RI_QP_RDMA_WRITE_ENABLE = 0x02,
- FW_RI_QP_BIND_ENABLE = 0x04,
- FW_RI_QP_FAST_REGISTER_ENABLE = 0x08,
- FW_RI_QP_STAG0_ENABLE = 0x10,
- FW_RI_QP_RDMA_READ_REQ_0B_ENABLE= 0x80,
-};
-
-enum fw_ri_addr_type {
- FW_RI_ZERO_BASED_TO = 0x00,
- FW_RI_VA_BASED_TO = 0x01
-};
-
-enum fw_ri_mem_perms {
- FW_RI_MEM_ACCESS_REM_WRITE = 0x01,
- FW_RI_MEM_ACCESS_REM_READ = 0x02,
- FW_RI_MEM_ACCESS_REM = 0x03,
- FW_RI_MEM_ACCESS_LOCAL_WRITE = 0x04,
- FW_RI_MEM_ACCESS_LOCAL_READ = 0x08,
- FW_RI_MEM_ACCESS_LOCAL = 0x0C
-};
-
-enum fw_ri_stag_type {
- FW_RI_STAG_NSMR = 0x00,
- FW_RI_STAG_SMR = 0x01,
- FW_RI_STAG_MW = 0x02,
- FW_RI_STAG_MW_RELAXED = 0x03
-};
-
-enum fw_ri_data_op {
- FW_RI_DATA_IMMD = 0x81,
- FW_RI_DATA_DSGL = 0x82,
- FW_RI_DATA_ISGL = 0x83
-};
-
-enum fw_ri_sgl_depth {
- FW_RI_SGL_DEPTH_MAX_SQ = 16,
- FW_RI_SGL_DEPTH_MAX_RQ = 4
-};
-
-enum fw_ri_cqe_err {
- FW_RI_CQE_ERR_SUCCESS = 0x00, /* success, no error detected */
- FW_RI_CQE_ERR_STAG = 0x01, /* STAG invalid */
- FW_RI_CQE_ERR_PDID = 0x02, /* PDID mismatch */
- FW_RI_CQE_ERR_QPID = 0x03, /* QPID mismatch */
- FW_RI_CQE_ERR_ACCESS = 0x04, /* Invalid access right */
- FW_RI_CQE_ERR_WRAP = 0x05, /* Wrap error */
- FW_RI_CQE_ERR_BOUND = 0x06, /* base and bounds violation */
- FW_RI_CQE_ERR_INVALIDATE_SHARED_MR = 0x07, /* attempt to invalidate a SMR */
- FW_RI_CQE_ERR_INVALIDATE_MR_WITH_MW_BOUND = 0x08, /* attempt to invalidate a MR w MW */
- FW_RI_CQE_ERR_ECC = 0x09, /* ECC error detected */
- FW_RI_CQE_ERR_ECC_PSTAG = 0x0A, /* ECC error detected when reading the PSTAG for a MW Invalidate */
- FW_RI_CQE_ERR_PBL_ADDR_BOUND = 0x0B, /* pbl address out of bound : software error */
- FW_RI_CQE_ERR_CRC = 0x10, /* CRC error */
- FW_RI_CQE_ERR_MARKER = 0x11, /* Marker error */
- FW_RI_CQE_ERR_PDU_LEN_ERR = 0x12, /* invalid PDU length */
- FW_RI_CQE_ERR_OUT_OF_RQE = 0x13, /* out of RQE */
- FW_RI_CQE_ERR_DDP_VERSION = 0x14, /* wrong DDP version */
- FW_RI_CQE_ERR_RDMA_VERSION = 0x15, /* wrong RDMA version */
- FW_RI_CQE_ERR_OPCODE = 0x16, /* invalid rdma opcode */
- FW_RI_CQE_ERR_DDP_QUEUE_NUM = 0x17, /* invalid ddp queue number */
- FW_RI_CQE_ERR_MSN = 0x18, /* MSN error */
- FW_RI_CQE_ERR_TBIT = 0x19, /* tag bit not set correctly */
- FW_RI_CQE_ERR_MO = 0x1A, /* MO not zero for TERMINATE or READ_REQ */
- FW_RI_CQE_ERR_MSN_GAP = 0x1B, /* */
- FW_RI_CQE_ERR_MSN_RANGE = 0x1C, /* */
- FW_RI_CQE_ERR_IRD_OVERFLOW = 0x1D, /* */
- FW_RI_CQE_ERR_RQE_ADDR_BOUND = 0x1E, /* RQE address out of bound : software error */
- FW_RI_CQE_ERR_INTERNAL_ERR = 0x1F /* internel error (opcode mismatch) */
-
-};
-
-struct fw_ri_dsge_pair {
- __be32 len[2];
- __be64 addr[2];
-};
-
-struct fw_ri_dsgl {
- __u8 op;
- __u8 r1;
- __be16 nsge;
- __be32 len0;
- __be64 addr0;
-#ifndef C99_NOT_SUPPORTED
- struct fw_ri_dsge_pair sge[0];
-#endif
-};
-
-struct fw_ri_sge {
- __be32 stag;
- __be32 len;
- __be64 to;
-};
-
-struct fw_ri_isgl {
- __u8 op;
- __u8 r1;
- __be16 nsge;
- __be32 r2;
-#ifndef C99_NOT_SUPPORTED
- struct fw_ri_sge sge[0];
-#endif
-};
-
-struct fw_ri_immd {
- __u8 op;
- __u8 r1;
- __be16 r2;
- __be32 immdlen;
-#ifndef C99_NOT_SUPPORTED
- __u8 data[0];
-#endif
-};
-
-struct fw_ri_tpte {
- __be32 valid_to_pdid;
- __be32 locread_to_qpid;
- __be32 nosnoop_pbladdr;
- __be32 len_lo;
- __be32 va_hi;
- __be32 va_lo_fbo;
- __be32 dca_mwbcnt_pstag;
- __be32 len_hi;
-};
-
-#define S_FW_RI_TPTE_VALID 31
-#define M_FW_RI_TPTE_VALID 0x1
-#define V_FW_RI_TPTE_VALID(x) ((x) << S_FW_RI_TPTE_VALID)
-#define G_FW_RI_TPTE_VALID(x) \
- (((x) >> S_FW_RI_TPTE_VALID) & M_FW_RI_TPTE_VALID)
-#define F_FW_RI_TPTE_VALID V_FW_RI_TPTE_VALID(1U)
-
-#define S_FW_RI_TPTE_STAGKEY 23
-#define M_FW_RI_TPTE_STAGKEY 0xff
-#define V_FW_RI_TPTE_STAGKEY(x) ((x) << S_FW_RI_TPTE_STAGKEY)
-#define G_FW_RI_TPTE_STAGKEY(x) \
- (((x) >> S_FW_RI_TPTE_STAGKEY) & M_FW_RI_TPTE_STAGKEY)
-
-#define S_FW_RI_TPTE_STAGSTATE 22
-#define M_FW_RI_TPTE_STAGSTATE 0x1
-#define V_FW_RI_TPTE_STAGSTATE(x) ((x) << S_FW_RI_TPTE_STAGSTATE)
-#define G_FW_RI_TPTE_STAGSTATE(x) \
- (((x) >> S_FW_RI_TPTE_STAGSTATE) & M_FW_RI_TPTE_STAGSTATE)
-#define F_FW_RI_TPTE_STAGSTATE V_FW_RI_TPTE_STAGSTATE(1U)
-
-#define S_FW_RI_TPTE_STAGTYPE 20
-#define M_FW_RI_TPTE_STAGTYPE 0x3
-#define V_FW_RI_TPTE_STAGTYPE(x) ((x) << S_FW_RI_TPTE_STAGTYPE)
-#define G_FW_RI_TPTE_STAGTYPE(x) \
- (((x) >> S_FW_RI_TPTE_STAGTYPE) & M_FW_RI_TPTE_STAGTYPE)
-
-#define S_FW_RI_TPTE_PDID 0
-#define M_FW_RI_TPTE_PDID 0xfffff
-#define V_FW_RI_TPTE_PDID(x) ((x) << S_FW_RI_TPTE_PDID)
-#define G_FW_RI_TPTE_PDID(x) \
- (((x) >> S_FW_RI_TPTE_PDID) & M_FW_RI_TPTE_PDID)
-
-#define S_FW_RI_TPTE_PERM 28
-#define M_FW_RI_TPTE_PERM 0xf
-#define V_FW_RI_TPTE_PERM(x) ((x) << S_FW_RI_TPTE_PERM)
-#define G_FW_RI_TPTE_PERM(x) \
- (((x) >> S_FW_RI_TPTE_PERM) & M_FW_RI_TPTE_PERM)
-
-#define S_FW_RI_TPTE_REMINVDIS 27
-#define M_FW_RI_TPTE_REMINVDIS 0x1
-#define V_FW_RI_TPTE_REMINVDIS(x) ((x) << S_FW_RI_TPTE_REMINVDIS)
-#define G_FW_RI_TPTE_REMINVDIS(x) \
- (((x) >> S_FW_RI_TPTE_REMINVDIS) & M_FW_RI_TPTE_REMINVDIS)
-#define F_FW_RI_TPTE_REMINVDIS V_FW_RI_TPTE_REMINVDIS(1U)
-
-#define S_FW_RI_TPTE_ADDRTYPE 26
-#define M_FW_RI_TPTE_ADDRTYPE 1
-#define V_FW_RI_TPTE_ADDRTYPE(x) ((x) << S_FW_RI_TPTE_ADDRTYPE)
-#define G_FW_RI_TPTE_ADDRTYPE(x) \
- (((x) >> S_FW_RI_TPTE_ADDRTYPE) & M_FW_RI_TPTE_ADDRTYPE)
-#define F_FW_RI_TPTE_ADDRTYPE V_FW_RI_TPTE_ADDRTYPE(1U)
-
-#define S_FW_RI_TPTE_MWBINDEN 25
-#define M_FW_RI_TPTE_MWBINDEN 0x1
-#define V_FW_RI_TPTE_MWBINDEN(x) ((x) << S_FW_RI_TPTE_MWBINDEN)
-#define G_FW_RI_TPTE_MWBINDEN(x) \
- (((x) >> S_FW_RI_TPTE_MWBINDEN) & M_FW_RI_TPTE_MWBINDEN)
-#define F_FW_RI_TPTE_MWBINDEN V_FW_RI_TPTE_MWBINDEN(1U)
-
-#define S_FW_RI_TPTE_PS 20
-#define M_FW_RI_TPTE_PS 0x1f
-#define V_FW_RI_TPTE_PS(x) ((x) << S_FW_RI_TPTE_PS)
-#define G_FW_RI_TPTE_PS(x) \
- (((x) >> S_FW_RI_TPTE_PS) & M_FW_RI_TPTE_PS)
-
-#define S_FW_RI_TPTE_QPID 0
-#define M_FW_RI_TPTE_QPID 0xfffff
-#define V_FW_RI_TPTE_QPID(x) ((x) << S_FW_RI_TPTE_QPID)
-#define G_FW_RI_TPTE_QPID(x) \
- (((x) >> S_FW_RI_TPTE_QPID) & M_FW_RI_TPTE_QPID)
-
-#define S_FW_RI_TPTE_NOSNOOP 31
-#define M_FW_RI_TPTE_NOSNOOP 0x1
-#define V_FW_RI_TPTE_NOSNOOP(x) ((x) << S_FW_RI_TPTE_NOSNOOP)
-#define G_FW_RI_TPTE_NOSNOOP(x) \
- (((x) >> S_FW_RI_TPTE_NOSNOOP) & M_FW_RI_TPTE_NOSNOOP)
-#define F_FW_RI_TPTE_NOSNOOP V_FW_RI_TPTE_NOSNOOP(1U)
-
-#define S_FW_RI_TPTE_PBLADDR 0
-#define M_FW_RI_TPTE_PBLADDR 0x1fffffff
-#define V_FW_RI_TPTE_PBLADDR(x) ((x) << S_FW_RI_TPTE_PBLADDR)
-#define G_FW_RI_TPTE_PBLADDR(x) \
- (((x) >> S_FW_RI_TPTE_PBLADDR) & M_FW_RI_TPTE_PBLADDR)
-
-#define S_FW_RI_TPTE_DCA 24
-#define M_FW_RI_TPTE_DCA 0x1f
-#define V_FW_RI_TPTE_DCA(x) ((x) << S_FW_RI_TPTE_DCA)
-#define G_FW_RI_TPTE_DCA(x) \
- (((x) >> S_FW_RI_TPTE_DCA) & M_FW_RI_TPTE_DCA)
-
-#define S_FW_RI_TPTE_MWBCNT_PSTAG 0
-#define M_FW_RI_TPTE_MWBCNT_PSTAG 0xffffff
-#define V_FW_RI_TPTE_MWBCNT_PSTAT(x) \
- ((x) << S_FW_RI_TPTE_MWBCNT_PSTAG)
-#define G_FW_RI_TPTE_MWBCNT_PSTAG(x) \
- (((x) >> S_FW_RI_TPTE_MWBCNT_PSTAG) & M_FW_RI_TPTE_MWBCNT_PSTAG)
-
-enum fw_ri_cqe_rxtx {
- FW_RI_CQE_RXTX_RX = 0x0,
- FW_RI_CQE_RXTX_TX = 0x1,
-};
-
-struct fw_ri_cqe {
- union fw_ri_rxtx {
- struct fw_ri_scqe {
- __be32 qpid_n_stat_rxtx_type;
- __be32 plen;
- __be32 reserved;
- __be32 wrid;
- } scqe;
- struct fw_ri_rcqe {
- __be32 qpid_n_stat_rxtx_type;
- __be32 plen;
- __be32 stag;
- __be32 msn;
- } rcqe;
- } u;
-};
-
-#define S_FW_RI_CQE_QPID 12
-#define M_FW_RI_CQE_QPID 0xfffff
-#define V_FW_RI_CQE_QPID(x) ((x) << S_FW_RI_CQE_QPID)
-#define G_FW_RI_CQE_QPID(x) \
- (((x) >> S_FW_RI_CQE_QPID) & M_FW_RI_CQE_QPID)
-
-#define S_FW_RI_CQE_NOTIFY 10
-#define M_FW_RI_CQE_NOTIFY 0x1
-#define V_FW_RI_CQE_NOTIFY(x) ((x) << S_FW_RI_CQE_NOTIFY)
-#define G_FW_RI_CQE_NOTIFY(x) \
- (((x) >> S_FW_RI_CQE_NOTIFY) & M_FW_RI_CQE_NOTIFY)
-
-#define S_FW_RI_CQE_STATUS 5
-#define M_FW_RI_CQE_STATUS 0x1f
-#define V_FW_RI_CQE_STATUS(x) ((x) << S_FW_RI_CQE_STATUS)
-#define G_FW_RI_CQE_STATUS(x) \
- (((x) >> S_FW_RI_CQE_STATUS) & M_FW_RI_CQE_STATUS)
-
-
-#define S_FW_RI_CQE_RXTX 4
-#define M_FW_RI_CQE_RXTX 0x1
-#define V_FW_RI_CQE_RXTX(x) ((x) << S_FW_RI_CQE_RXTX)
-#define G_FW_RI_CQE_RXTX(x) \
- (((x) >> S_FW_RI_CQE_RXTX) & M_FW_RI_CQE_RXTX)
-
-#define S_FW_RI_CQE_TYPE 0
-#define M_FW_RI_CQE_TYPE 0xf
-#define V_FW_RI_CQE_TYPE(x) ((x) << S_FW_RI_CQE_TYPE)
-#define G_FW_RI_CQE_TYPE(x) \
- (((x) >> S_FW_RI_CQE_TYPE) & M_FW_RI_CQE_TYPE)
-
-enum fw_ri_res_type {
- FW_RI_RES_TYPE_SQ,
- FW_RI_RES_TYPE_RQ,
- FW_RI_RES_TYPE_CQ,
-};
-
-enum fw_ri_res_op {
- FW_RI_RES_OP_WRITE,
- FW_RI_RES_OP_RESET,
-};
-
-struct fw_ri_res {
- union fw_ri_restype {
- struct fw_ri_res_sqrq {
- __u8 restype;
- __u8 op;
- __be16 r3;
- __be32 eqid;
- __be32 r4[2];
- __be32 fetchszm_to_iqid;
- __be32 dcaen_to_eqsize;
- __be64 eqaddr;
- } sqrq;
- struct fw_ri_res_cq {
- __u8 restype;
- __u8 op;
- __be16 r3;
- __be32 iqid;
- __be32 r4[2];
- __be32 iqandst_to_iqandstindex;
- __be16 iqdroprss_to_iqesize;
- __be16 iqsize;
- __be64 iqaddr;
- __be32 iqns_iqro;
- __be32 r6_lo;
- __be64 r7;
- } cq;
- } u;
-};
-
-struct fw_ri_res_wr {
- __be32 op_nres;
- __be32 len16_pkd;
- __u64 cookie;
-#ifndef C99_NOT_SUPPORTED
- struct fw_ri_res res[0];
-#endif
-};
-
-#define S_FW_RI_RES_WR_NRES 0
-#define M_FW_RI_RES_WR_NRES 0xff
-#define V_FW_RI_RES_WR_NRES(x) ((x) << S_FW_RI_RES_WR_NRES)
-#define G_FW_RI_RES_WR_NRES(x) \
- (((x) >> S_FW_RI_RES_WR_NRES) & M_FW_RI_RES_WR_NRES)
-
-#define S_FW_RI_RES_WR_FETCHSZM 26
-#define M_FW_RI_RES_WR_FETCHSZM 0x1
-#define V_FW_RI_RES_WR_FETCHSZM(x) ((x) << S_FW_RI_RES_WR_FETCHSZM)
-#define G_FW_RI_RES_WR_FETCHSZM(x) \
- (((x) >> S_FW_RI_RES_WR_FETCHSZM) & M_FW_RI_RES_WR_FETCHSZM)
-#define F_FW_RI_RES_WR_FETCHSZM V_FW_RI_RES_WR_FETCHSZM(1U)
-
-#define S_FW_RI_RES_WR_STATUSPGNS 25
-#define M_FW_RI_RES_WR_STATUSPGNS 0x1
-#define V_FW_RI_RES_WR_STATUSPGNS(x) ((x) << S_FW_RI_RES_WR_STATUSPGNS)
-#define G_FW_RI_RES_WR_STATUSPGNS(x) \
- (((x) >> S_FW_RI_RES_WR_STATUSPGNS) & M_FW_RI_RES_WR_STATUSPGNS)
-#define F_FW_RI_RES_WR_STATUSPGNS V_FW_RI_RES_WR_STATUSPGNS(1U)
-
-#define S_FW_RI_RES_WR_STATUSPGRO 24
-#define M_FW_RI_RES_WR_STATUSPGRO 0x1
-#define V_FW_RI_RES_WR_STATUSPGRO(x) ((x) << S_FW_RI_RES_WR_STATUSPGRO)
-#define G_FW_RI_RES_WR_STATUSPGRO(x) \
- (((x) >> S_FW_RI_RES_WR_STATUSPGRO) & M_FW_RI_RES_WR_STATUSPGRO)
-#define F_FW_RI_RES_WR_STATUSPGRO V_FW_RI_RES_WR_STATUSPGRO(1U)
-
-#define S_FW_RI_RES_WR_FETCHNS 23
-#define M_FW_RI_RES_WR_FETCHNS 0x1
-#define V_FW_RI_RES_WR_FETCHNS(x) ((x) << S_FW_RI_RES_WR_FETCHNS)
-#define G_FW_RI_RES_WR_FETCHNS(x) \
- (((x) >> S_FW_RI_RES_WR_FETCHNS) & M_FW_RI_RES_WR_FETCHNS)
-#define F_FW_RI_RES_WR_FETCHNS V_FW_RI_RES_WR_FETCHNS(1U)
-
-#define S_FW_RI_RES_WR_FETCHRO 22
-#define M_FW_RI_RES_WR_FETCHRO 0x1
-#define V_FW_RI_RES_WR_FETCHRO(x) ((x) << S_FW_RI_RES_WR_FETCHRO)
-#define G_FW_RI_RES_WR_FETCHRO(x) \
- (((x) >> S_FW_RI_RES_WR_FETCHRO) & M_FW_RI_RES_WR_FETCHRO)
-#define F_FW_RI_RES_WR_FETCHRO V_FW_RI_RES_WR_FETCHRO(1U)
-
-#define S_FW_RI_RES_WR_HOSTFCMODE 20
-#define M_FW_RI_RES_WR_HOSTFCMODE 0x3
-#define V_FW_RI_RES_WR_HOSTFCMODE(x) ((x) << S_FW_RI_RES_WR_HOSTFCMODE)
-#define G_FW_RI_RES_WR_HOSTFCMODE(x) \
- (((x) >> S_FW_RI_RES_WR_HOSTFCMODE) & M_FW_RI_RES_WR_HOSTFCMODE)
-
-#define S_FW_RI_RES_WR_CPRIO 19
-#define M_FW_RI_RES_WR_CPRIO 0x1
-#define V_FW_RI_RES_WR_CPRIO(x) ((x) << S_FW_RI_RES_WR_CPRIO)
-#define G_FW_RI_RES_WR_CPRIO(x) \
- (((x) >> S_FW_RI_RES_WR_CPRIO) & M_FW_RI_RES_WR_CPRIO)
-#define F_FW_RI_RES_WR_CPRIO V_FW_RI_RES_WR_CPRIO(1U)
-
-#define S_FW_RI_RES_WR_ONCHIP 18
-#define M_FW_RI_RES_WR_ONCHIP 0x1
-#define V_FW_RI_RES_WR_ONCHIP(x) ((x) << S_FW_RI_RES_WR_ONCHIP)
-#define G_FW_RI_RES_WR_ONCHIP(x) \
- (((x) >> S_FW_RI_RES_WR_ONCHIP) & M_FW_RI_RES_WR_ONCHIP)
-#define F_FW_RI_RES_WR_ONCHIP V_FW_RI_RES_WR_ONCHIP(1U)
-
-#define S_FW_RI_RES_WR_PCIECHN 16
-#define M_FW_RI_RES_WR_PCIECHN 0x3
-#define V_FW_RI_RES_WR_PCIECHN(x) ((x) << S_FW_RI_RES_WR_PCIECHN)
-#define G_FW_RI_RES_WR_PCIECHN(x) \
- (((x) >> S_FW_RI_RES_WR_PCIECHN) & M_FW_RI_RES_WR_PCIECHN)
-
-#define S_FW_RI_RES_WR_IQID 0
-#define M_FW_RI_RES_WR_IQID 0xffff
-#define V_FW_RI_RES_WR_IQID(x) ((x) << S_FW_RI_RES_WR_IQID)
-#define G_FW_RI_RES_WR_IQID(x) \
- (((x) >> S_FW_RI_RES_WR_IQID) & M_FW_RI_RES_WR_IQID)
-
-#define S_FW_RI_RES_WR_DCAEN 31
-#define M_FW_RI_RES_WR_DCAEN 0x1
-#define V_FW_RI_RES_WR_DCAEN(x) ((x) << S_FW_RI_RES_WR_DCAEN)
-#define G_FW_RI_RES_WR_DCAEN(x) \
- (((x) >> S_FW_RI_RES_WR_DCAEN) & M_FW_RI_RES_WR_DCAEN)
-#define F_FW_RI_RES_WR_DCAEN V_FW_RI_RES_WR_DCAEN(1U)
-
-#define S_FW_RI_RES_WR_DCACPU 26
-#define M_FW_RI_RES_WR_DCACPU 0x1f
-#define V_FW_RI_RES_WR_DCACPU(x) ((x) << S_FW_RI_RES_WR_DCACPU)
-#define G_FW_RI_RES_WR_DCACPU(x) \
- (((x) >> S_FW_RI_RES_WR_DCACPU) & M_FW_RI_RES_WR_DCACPU)
-
-#define S_FW_RI_RES_WR_FBMIN 23
-#define M_FW_RI_RES_WR_FBMIN 0x7
-#define V_FW_RI_RES_WR_FBMIN(x) ((x) << S_FW_RI_RES_WR_FBMIN)
-#define G_FW_RI_RES_WR_FBMIN(x) \
- (((x) >> S_FW_RI_RES_WR_FBMIN) & M_FW_RI_RES_WR_FBMIN)
-
-#define S_FW_RI_RES_WR_FBMAX 20
-#define M_FW_RI_RES_WR_FBMAX 0x7
-#define V_FW_RI_RES_WR_FBMAX(x) ((x) << S_FW_RI_RES_WR_FBMAX)
-#define G_FW_RI_RES_WR_FBMAX(x) \
- (((x) >> S_FW_RI_RES_WR_FBMAX) & M_FW_RI_RES_WR_FBMAX)
-
-#define S_FW_RI_RES_WR_CIDXFTHRESHO 19
-#define M_FW_RI_RES_WR_CIDXFTHRESHO 0x1
-#define V_FW_RI_RES_WR_CIDXFTHRESHO(x) ((x) << S_FW_RI_RES_WR_CIDXFTHRESHO)
-#define G_FW_RI_RES_WR_CIDXFTHRESHO(x) \
- (((x) >> S_FW_RI_RES_WR_CIDXFTHRESHO) & M_FW_RI_RES_WR_CIDXFTHRESHO)
-#define F_FW_RI_RES_WR_CIDXFTHRESHO V_FW_RI_RES_WR_CIDXFTHRESHO(1U)
-
-#define S_FW_RI_RES_WR_CIDXFTHRESH 16
-#define M_FW_RI_RES_WR_CIDXFTHRESH 0x7
-#define V_FW_RI_RES_WR_CIDXFTHRESH(x) ((x) << S_FW_RI_RES_WR_CIDXFTHRESH)
-#define G_FW_RI_RES_WR_CIDXFTHRESH(x) \
- (((x) >> S_FW_RI_RES_WR_CIDXFTHRESH) & M_FW_RI_RES_WR_CIDXFTHRESH)
-
-#define S_FW_RI_RES_WR_EQSIZE 0
-#define M_FW_RI_RES_WR_EQSIZE 0xffff
-#define V_FW_RI_RES_WR_EQSIZE(x) ((x) << S_FW_RI_RES_WR_EQSIZE)
-#define G_FW_RI_RES_WR_EQSIZE(x) \
- (((x) >> S_FW_RI_RES_WR_EQSIZE) & M_FW_RI_RES_WR_EQSIZE)
-
-#define S_FW_RI_RES_WR_IQANDST 15
-#define M_FW_RI_RES_WR_IQANDST 0x1
-#define V_FW_RI_RES_WR_IQANDST(x) ((x) << S_FW_RI_RES_WR_IQANDST)
-#define G_FW_RI_RES_WR_IQANDST(x) \
- (((x) >> S_FW_RI_RES_WR_IQANDST) & M_FW_RI_RES_WR_IQANDST)
-#define F_FW_RI_RES_WR_IQANDST V_FW_RI_RES_WR_IQANDST(1U)
-
-#define S_FW_RI_RES_WR_IQANUS 14
-#define M_FW_RI_RES_WR_IQANUS 0x1
-#define V_FW_RI_RES_WR_IQANUS(x) ((x) << S_FW_RI_RES_WR_IQANUS)
-#define G_FW_RI_RES_WR_IQANUS(x) \
- (((x) >> S_FW_RI_RES_WR_IQANUS) & M_FW_RI_RES_WR_IQANUS)
-#define F_FW_RI_RES_WR_IQANUS V_FW_RI_RES_WR_IQANUS(1U)
-
-#define S_FW_RI_RES_WR_IQANUD 12
-#define M_FW_RI_RES_WR_IQANUD 0x3
-#define V_FW_RI_RES_WR_IQANUD(x) ((x) << S_FW_RI_RES_WR_IQANUD)
-#define G_FW_RI_RES_WR_IQANUD(x) \
- (((x) >> S_FW_RI_RES_WR_IQANUD) & M_FW_RI_RES_WR_IQANUD)
-
-#define S_FW_RI_RES_WR_IQANDSTINDEX 0
-#define M_FW_RI_RES_WR_IQANDSTINDEX 0xfff
-#define V_FW_RI_RES_WR_IQANDSTINDEX(x) ((x) << S_FW_RI_RES_WR_IQANDSTINDEX)
-#define G_FW_RI_RES_WR_IQANDSTINDEX(x) \
- (((x) >> S_FW_RI_RES_WR_IQANDSTINDEX) & M_FW_RI_RES_WR_IQANDSTINDEX)
-
-#define S_FW_RI_RES_WR_IQDROPRSS 15
-#define M_FW_RI_RES_WR_IQDROPRSS 0x1
-#define V_FW_RI_RES_WR_IQDROPRSS(x) ((x) << S_FW_RI_RES_WR_IQDROPRSS)
-#define G_FW_RI_RES_WR_IQDROPRSS(x) \
- (((x) >> S_FW_RI_RES_WR_IQDROPRSS) & M_FW_RI_RES_WR_IQDROPRSS)
-#define F_FW_RI_RES_WR_IQDROPRSS V_FW_RI_RES_WR_IQDROPRSS(1U)
-
-#define S_FW_RI_RES_WR_IQGTSMODE 14
-#define M_FW_RI_RES_WR_IQGTSMODE 0x1
-#define V_FW_RI_RES_WR_IQGTSMODE(x) ((x) << S_FW_RI_RES_WR_IQGTSMODE)
-#define G_FW_RI_RES_WR_IQGTSMODE(x) \
- (((x) >> S_FW_RI_RES_WR_IQGTSMODE) & M_FW_RI_RES_WR_IQGTSMODE)
-#define F_FW_RI_RES_WR_IQGTSMODE V_FW_RI_RES_WR_IQGTSMODE(1U)
-
-#define S_FW_RI_RES_WR_IQPCIECH 12
-#define M_FW_RI_RES_WR_IQPCIECH 0x3
-#define V_FW_RI_RES_WR_IQPCIECH(x) ((x) << S_FW_RI_RES_WR_IQPCIECH)
-#define G_FW_RI_RES_WR_IQPCIECH(x) \
- (((x) >> S_FW_RI_RES_WR_IQPCIECH) & M_FW_RI_RES_WR_IQPCIECH)
-
-#define S_FW_RI_RES_WR_IQDCAEN 11
-#define M_FW_RI_RES_WR_IQDCAEN 0x1
-#define V_FW_RI_RES_WR_IQDCAEN(x) ((x) << S_FW_RI_RES_WR_IQDCAEN)
-#define G_FW_RI_RES_WR_IQDCAEN(x) \
- (((x) >> S_FW_RI_RES_WR_IQDCAEN) & M_FW_RI_RES_WR_IQDCAEN)
-#define F_FW_RI_RES_WR_IQDCAEN V_FW_RI_RES_WR_IQDCAEN(1U)
-
-#define S_FW_RI_RES_WR_IQDCACPU 6
-#define M_FW_RI_RES_WR_IQDCACPU 0x1f
-#define V_FW_RI_RES_WR_IQDCACPU(x) ((x) << S_FW_RI_RES_WR_IQDCACPU)
-#define G_FW_RI_RES_WR_IQDCACPU(x) \
- (((x) >> S_FW_RI_RES_WR_IQDCACPU) & M_FW_RI_RES_WR_IQDCACPU)
-
-#define S_FW_RI_RES_WR_IQINTCNTTHRESH 4
-#define M_FW_RI_RES_WR_IQINTCNTTHRESH 0x3
-#define V_FW_RI_RES_WR_IQINTCNTTHRESH(x) \
- ((x) << S_FW_RI_RES_WR_IQINTCNTTHRESH)
-#define G_FW_RI_RES_WR_IQINTCNTTHRESH(x) \
- (((x) >> S_FW_RI_RES_WR_IQINTCNTTHRESH) & M_FW_RI_RES_WR_IQINTCNTTHRESH)
-
-#define S_FW_RI_RES_WR_IQO 3
-#define M_FW_RI_RES_WR_IQO 0x1
-#define V_FW_RI_RES_WR_IQO(x) ((x) << S_FW_RI_RES_WR_IQO)
-#define G_FW_RI_RES_WR_IQO(x) \
- (((x) >> S_FW_RI_RES_WR_IQO) & M_FW_RI_RES_WR_IQO)
-#define F_FW_RI_RES_WR_IQO V_FW_RI_RES_WR_IQO(1U)
-
-#define S_FW_RI_RES_WR_IQCPRIO 2
-#define M_FW_RI_RES_WR_IQCPRIO 0x1
-#define V_FW_RI_RES_WR_IQCPRIO(x) ((x) << S_FW_RI_RES_WR_IQCPRIO)
-#define G_FW_RI_RES_WR_IQCPRIO(x) \
- (((x) >> S_FW_RI_RES_WR_IQCPRIO) & M_FW_RI_RES_WR_IQCPRIO)
-#define F_FW_RI_RES_WR_IQCPRIO V_FW_RI_RES_WR_IQCPRIO(1U)
-
-#define S_FW_RI_RES_WR_IQESIZE 0
-#define M_FW_RI_RES_WR_IQESIZE 0x3
-#define V_FW_RI_RES_WR_IQESIZE(x) ((x) << S_FW_RI_RES_WR_IQESIZE)
-#define G_FW_RI_RES_WR_IQESIZE(x) \
- (((x) >> S_FW_RI_RES_WR_IQESIZE) & M_FW_RI_RES_WR_IQESIZE)
-
-#define S_FW_RI_RES_WR_IQNS 31
-#define M_FW_RI_RES_WR_IQNS 0x1
-#define V_FW_RI_RES_WR_IQNS(x) ((x) << S_FW_RI_RES_WR_IQNS)
-#define G_FW_RI_RES_WR_IQNS(x) \
- (((x) >> S_FW_RI_RES_WR_IQNS) & M_FW_RI_RES_WR_IQNS)
-#define F_FW_RI_RES_WR_IQNS V_FW_RI_RES_WR_IQNS(1U)
-
-#define S_FW_RI_RES_WR_IQRO 30
-#define M_FW_RI_RES_WR_IQRO 0x1
-#define V_FW_RI_RES_WR_IQRO(x) ((x) << S_FW_RI_RES_WR_IQRO)
-#define G_FW_RI_RES_WR_IQRO(x) \
- (((x) >> S_FW_RI_RES_WR_IQRO) & M_FW_RI_RES_WR_IQRO)
-#define F_FW_RI_RES_WR_IQRO V_FW_RI_RES_WR_IQRO(1U)
-
-struct fw_ri_rdma_write_wr {
- __u8 opcode;
- __u8 flags;
- __u16 wrid;
- __u8 r1[3];
- __u8 len16;
- __be64 r2;
- __be32 plen;
- __be32 stag_sink;
- __be64 to_sink;
-#ifndef C99_NOT_SUPPORTED
- union {
- struct fw_ri_immd immd_src[0];
- struct fw_ri_isgl isgl_src[0];
- } u;
-#endif
-};
-
-struct fw_ri_send_wr {
- __u8 opcode;
- __u8 flags;
- __u16 wrid;
- __u8 r1[3];
- __u8 len16;
- __be32 sendop_pkd;
- __be32 stag_inv;
- __be32 plen;
- __be32 r3;
- __be64 r4;
-#ifndef C99_NOT_SUPPORTED
- union {
- struct fw_ri_immd immd_src[0];
- struct fw_ri_isgl isgl_src[0];
- } u;
-#endif
-};
-
-#define S_FW_RI_SEND_WR_SENDOP 0
-#define M_FW_RI_SEND_WR_SENDOP 0xf
-#define V_FW_RI_SEND_WR_SENDOP(x) ((x) << S_FW_RI_SEND_WR_SENDOP)
-#define G_FW_RI_SEND_WR_SENDOP(x) \
- (((x) >> S_FW_RI_SEND_WR_SENDOP) & M_FW_RI_SEND_WR_SENDOP)
-
-struct fw_ri_rdma_read_wr {
- __u8 opcode;
- __u8 flags;
- __u16 wrid;
- __u8 r1[3];
- __u8 len16;
- __be64 r2;
- __be32 stag_sink;
- __be32 to_sink_hi;
- __be32 to_sink_lo;
- __be32 plen;
- __be32 stag_src;
- __be32 to_src_hi;
- __be32 to_src_lo;
- __be32 r5;
-};
-
-struct fw_ri_recv_wr {
- __u8 opcode;
- __u8 r1;
- __u16 wrid;
- __u8 r2[3];
- __u8 len16;
- struct fw_ri_isgl isgl;
-};
-
-struct fw_ri_bind_mw_wr {
- __u8 opcode;
- __u8 flags;
- __u16 wrid;
- __u8 r1[3];
- __u8 len16;
- __u8 qpbinde_to_dcacpu;
- __u8 pgsz_shift;
- __u8 addr_type;
- __u8 mem_perms;
- __be32 stag_mr;
- __be32 stag_mw;
- __be32 r3;
- __be64 len_mw;
- __be64 va_fbo;
- __be64 r4;
-};
-
-#define S_FW_RI_BIND_MW_WR_QPBINDE 6
-#define M_FW_RI_BIND_MW_WR_QPBINDE 0x1
-#define V_FW_RI_BIND_MW_WR_QPBINDE(x) ((x) << S_FW_RI_BIND_MW_WR_QPBINDE)
-#define G_FW_RI_BIND_MW_WR_QPBINDE(x) \
- (((x) >> S_FW_RI_BIND_MW_WR_QPBINDE) & M_FW_RI_BIND_MW_WR_QPBINDE)
-#define F_FW_RI_BIND_MW_WR_QPBINDE V_FW_RI_BIND_MW_WR_QPBINDE(1U)
-
-#define S_FW_RI_BIND_MW_WR_NS 5
-#define M_FW_RI_BIND_MW_WR_NS 0x1
-#define V_FW_RI_BIND_MW_WR_NS(x) ((x) << S_FW_RI_BIND_MW_WR_NS)
-#define G_FW_RI_BIND_MW_WR_NS(x) \
- (((x) >> S_FW_RI_BIND_MW_WR_NS) & M_FW_RI_BIND_MW_WR_NS)
-#define F_FW_RI_BIND_MW_WR_NS V_FW_RI_BIND_MW_WR_NS(1U)
-
-#define S_FW_RI_BIND_MW_WR_DCACPU 0
-#define M_FW_RI_BIND_MW_WR_DCACPU 0x1f
-#define V_FW_RI_BIND_MW_WR_DCACPU(x) ((x) << S_FW_RI_BIND_MW_WR_DCACPU)
-#define G_FW_RI_BIND_MW_WR_DCACPU(x) \
- (((x) >> S_FW_RI_BIND_MW_WR_DCACPU) & M_FW_RI_BIND_MW_WR_DCACPU)
-
-struct fw_ri_fr_nsmr_wr {
- __u8 opcode;
- __u8 flags;
- __u16 wrid;
- __u8 r1[3];
- __u8 len16;
- __u8 qpbinde_to_dcacpu;
- __u8 pgsz_shift;
- __u8 addr_type;
- __u8 mem_perms;
- __be32 stag;
- __be32 len_hi;
- __be32 len_lo;
- __be32 va_hi;
- __be32 va_lo_fbo;
-};
-
-#define S_FW_RI_FR_NSMR_WR_QPBINDE 6
-#define M_FW_RI_FR_NSMR_WR_QPBINDE 0x1
-#define V_FW_RI_FR_NSMR_WR_QPBINDE(x) ((x) << S_FW_RI_FR_NSMR_WR_QPBINDE)
-#define G_FW_RI_FR_NSMR_WR_QPBINDE(x) \
- (((x) >> S_FW_RI_FR_NSMR_WR_QPBINDE) & M_FW_RI_FR_NSMR_WR_QPBINDE)
-#define F_FW_RI_FR_NSMR_WR_QPBINDE V_FW_RI_FR_NSMR_WR_QPBINDE(1U)
-
-#define S_FW_RI_FR_NSMR_WR_NS 5
-#define M_FW_RI_FR_NSMR_WR_NS 0x1
-#define V_FW_RI_FR_NSMR_WR_NS(x) ((x) << S_FW_RI_FR_NSMR_WR_NS)
-#define G_FW_RI_FR_NSMR_WR_NS(x) \
- (((x) >> S_FW_RI_FR_NSMR_WR_NS) & M_FW_RI_FR_NSMR_WR_NS)
-#define F_FW_RI_FR_NSMR_WR_NS V_FW_RI_FR_NSMR_WR_NS(1U)
-
-#define S_FW_RI_FR_NSMR_WR_DCACPU 0
-#define M_FW_RI_FR_NSMR_WR_DCACPU 0x1f
-#define V_FW_RI_FR_NSMR_WR_DCACPU(x) ((x) << S_FW_RI_FR_NSMR_WR_DCACPU)
-#define G_FW_RI_FR_NSMR_WR_DCACPU(x) \
- (((x) >> S_FW_RI_FR_NSMR_WR_DCACPU) & M_FW_RI_FR_NSMR_WR_DCACPU)
-
-struct fw_ri_inv_lstag_wr {
- __u8 opcode;
- __u8 flags;
- __u16 wrid;
- __u8 r1[3];
- __u8 len16;
- __be32 r2;
- __be32 stag_inv;
-};
-
-struct fw_ri_send_immediate_wr {
- __u8 opcode;
- __u8 flags;
- __u16 wrid;
- __u8 r1[3];
- __u8 len16;
- __be32 sendimmop_pkd;
- __be32 r3;
- __be32 plen;
- __be32 r4;
- __be64 r5;
-#ifndef C99_NOT_SUPPORTED
- struct fw_ri_immd immd_src[0];
-#endif
-};
-
-#define S_FW_RI_SEND_IMMEDIATE_WR_SENDIMMOP 0
-#define M_FW_RI_SEND_IMMEDIATE_WR_SENDIMMOP 0xf
-#define V_FW_RI_SEND_IMMEDIATE_WR_SENDIMMOP(x) \
- ((x) << S_FW_RI_SEND_IMMEDIATE_WR_SENDIMMOP)
-#define G_FW_RI_SEND_IMMEDIATE_WR_SENDIMMOP(x) \
- (((x) >> S_FW_RI_SEND_IMMEDIATE_WR_SENDIMMOP) & \
- M_FW_RI_SEND_IMMEDIATE_WR_SENDIMMOP)
-
-enum fw_ri_atomic_op {
- FW_RI_ATOMIC_OP_FETCHADD,
- FW_RI_ATOMIC_OP_SWAP,
- FW_RI_ATOMIC_OP_CMDSWAP,
-};
-
-struct fw_ri_atomic_wr {
- __u8 opcode;
- __u8 flags;
- __u16 wrid;
- __u8 r1[3];
- __u8 len16;
- __be32 atomicop_pkd;
- __be64 r3;
- __be32 aopcode_pkd;
- __be32 reqid;
- __be32 stag;
- __be32 to_hi;
- __be32 to_lo;
- __be32 addswap_data_hi;
- __be32 addswap_data_lo;
- __be32 addswap_mask_hi;
- __be32 addswap_mask_lo;
- __be32 compare_data_hi;
- __be32 compare_data_lo;
- __be32 compare_mask_hi;
- __be32 compare_mask_lo;
- __be32 r5;
-};
-
-#define S_FW_RI_ATOMIC_WR_ATOMICOP 0
-#define M_FW_RI_ATOMIC_WR_ATOMICOP 0xf
-#define V_FW_RI_ATOMIC_WR_ATOMICOP(x) ((x) << S_FW_RI_ATOMIC_WR_ATOMICOP)
-#define G_FW_RI_ATOMIC_WR_ATOMICOP(x) \
- (((x) >> S_FW_RI_ATOMIC_WR_ATOMICOP) & M_FW_RI_ATOMIC_WR_ATOMICOP)
-
-#define S_FW_RI_ATOMIC_WR_AOPCODE 0
-#define M_FW_RI_ATOMIC_WR_AOPCODE 0xf
-#define V_FW_RI_ATOMIC_WR_AOPCODE(x) ((x) << S_FW_RI_ATOMIC_WR_AOPCODE)
-#define G_FW_RI_ATOMIC_WR_AOPCODE(x) \
- (((x) >> S_FW_RI_ATOMIC_WR_AOPCODE) & M_FW_RI_ATOMIC_WR_AOPCODE)
-
-enum fw_ri_type {
- FW_RI_TYPE_INIT,
- FW_RI_TYPE_FINI,
- FW_RI_TYPE_TERMINATE
-};
-
-enum fw_ri_init_p2ptype {
- FW_RI_INIT_P2PTYPE_RDMA_WRITE = FW_RI_RDMA_WRITE,
- FW_RI_INIT_P2PTYPE_READ_REQ = FW_RI_READ_REQ,
- FW_RI_INIT_P2PTYPE_SEND = FW_RI_SEND,
- FW_RI_INIT_P2PTYPE_SEND_WITH_INV = FW_RI_SEND_WITH_INV,
- FW_RI_INIT_P2PTYPE_SEND_WITH_SE = FW_RI_SEND_WITH_SE,
- FW_RI_INIT_P2PTYPE_SEND_WITH_SE_INV = FW_RI_SEND_WITH_SE_INV,
- FW_RI_INIT_P2PTYPE_DISABLED = 0xf,
-};
-
-struct fw_ri_wr {
- __be32 op_compl;
- __be32 flowid_len16;
- __u64 cookie;
- union fw_ri {
- struct fw_ri_init {
- __u8 type;
- __u8 mpareqbit_p2ptype;
- __u8 r4[2];
- __u8 mpa_attrs;
- __u8 qp_caps;
- __be16 nrqe;
- __be32 pdid;
- __be32 qpid;
- __be32 sq_eqid;
- __be32 rq_eqid;
- __be32 scqid;
- __be32 rcqid;
- __be32 ord_max;
- __be32 ird_max;
- __be32 iss;
- __be32 irs;
- __be32 hwrqsize;
- __be32 hwrqaddr;
- __be64 r5;
- union fw_ri_init_p2p {
- struct fw_ri_rdma_write_wr write;
- struct fw_ri_rdma_read_wr read;
- struct fw_ri_send_wr send;
- } u;
- } init;
- struct fw_ri_fini {
- __u8 type;
- __u8 r3[7];
- __be64 r4;
- } fini;
- struct fw_ri_terminate {
- __u8 type;
- __u8 r3[3];
- __be32 immdlen;
- __u8 termmsg[40];
- } terminate;
- } u;
-};
-
-#define S_FW_RI_WR_MPAREQBIT 7
-#define M_FW_RI_WR_MPAREQBIT 0x1
-#define V_FW_RI_WR_MPAREQBIT(x) ((x) << S_FW_RI_WR_MPAREQBIT)
-#define G_FW_RI_WR_MPAREQBIT(x) \
- (((x) >> S_FW_RI_WR_MPAREQBIT) & M_FW_RI_WR_MPAREQBIT)
-#define F_FW_RI_WR_MPAREQBIT V_FW_RI_WR_MPAREQBIT(1U)
-
-#define S_FW_RI_WR_0BRRBIT 6
-#define M_FW_RI_WR_0BRRBIT 0x1
-#define V_FW_RI_WR_0BRRBIT(x) ((x) << S_FW_RI_WR_0BRRBIT)
-#define G_FW_RI_WR_0BRRBIT(x) \
- (((x) >> S_FW_RI_WR_0BRRBIT) & M_FW_RI_WR_0BRRBIT)
-#define F_FW_RI_WR_0BRRBIT V_FW_RI_WR_0BRRBIT(1U)
-
-#define S_FW_RI_WR_P2PTYPE 0
-#define M_FW_RI_WR_P2PTYPE 0xf
-#define V_FW_RI_WR_P2PTYPE(x) ((x) << S_FW_RI_WR_P2PTYPE)
-#define G_FW_RI_WR_P2PTYPE(x) \
- (((x) >> S_FW_RI_WR_P2PTYPE) & M_FW_RI_WR_P2PTYPE)
-
-/******************************************************************************
- * F O i S C S I W O R K R E Q U E S T s
- *********************************************/
-
-#define FW_FOISCSI_NAME_MAX_LEN 224
-#define FW_FOISCSI_ALIAS_MAX_LEN 224
-#define FW_FOISCSI_CHAP_SEC_MAX_LEN 128
-#define FW_FOISCSI_INIT_NODE_MAX 8
-
-enum fw_chnet_ifconf_wr_subop {
- FW_CHNET_IFCONF_WR_SUBOP_NONE = 0,
-
- FW_CHNET_IFCONF_WR_SUBOP_IPV4_SET,
- FW_CHNET_IFCONF_WR_SUBOP_IPV4_GET,
-
- FW_CHNET_IFCONF_WR_SUBOP_VLAN_IPV4_SET,
- FW_CHNET_IFCONF_WR_SUBOP_VLAN_IPV4_GET,
-
- FW_CHNET_IFCONF_WR_SUBOP_IPV6_SET,
- FW_CHNET_IFCONF_WR_SUBOP_IPV6_GET,
-
- FW_CHNET_IFCONF_WR_SUBOP_VLAN_SET,
- FW_CHNET_IFCONF_WR_SUBOP_VLAN_GET,
-
- FW_CHNET_IFCONF_WR_SUBOP_MTU_SET,
- FW_CHNET_IFCONF_WR_SUBOP_MTU_GET,
-
- FW_CHNET_IFCONF_WR_SUBOP_DHCP_SET,
- FW_CHNET_IFCONF_WR_SUBOP_DHCP_GET,
-
- FW_CHNET_IFCONF_WR_SUBOP_MAX,
-};
-
-struct fw_chnet_ifconf_wr {
- __be32 op_compl;
- __be32 flowid_len16;
- __be64 cookie;
- __be32 if_flowid;
- __u8 idx;
- __u8 subop;
- __u8 retval;
- __u8 r2;
- __be64 r3;
- struct fw_chnet_ifconf_params {
- __be32 r0;
- __be16 vlanid;
- __be16 mtu;
- union fw_chnet_ifconf_addr_type {
- struct fw_chnet_ifconf_ipv4 {
- __be32 addr;
- __be32 mask;
- __be32 router;
- __be32 r0;
- __be64 r1;
- } ipv4;
- struct fw_chnet_ifconf_ipv6 {
- __be64 linklocal_lo;
- __be64 linklocal_hi;
- __be64 router_hi;
- __be64 router_lo;
- __be64 aconf_hi;
- __be64 aconf_lo;
- __be64 linklocal_aconf_hi;
- __be64 linklocal_aconf_lo;
- __be64 router_aconf_hi;
- __be64 router_aconf_lo;
- __be64 r0;
- } ipv6;
- } in_attr;
- } param;
-};
-
-enum fw_foiscsi_node_type {
- FW_FOISCSI_NODE_TYPE_INITIATOR = 0,
- FW_FOISCSI_NODE_TYPE_TARGET,
-};
-
-enum fw_foiscsi_session_type {
- FW_FOISCSI_SESSION_TYPE_DISCOVERY = 0,
- FW_FOISCSI_SESSION_TYPE_NORMAL,
-};
-
-enum fw_foiscsi_auth_policy {
- FW_FOISCSI_AUTH_POLICY_ONEWAY = 0,
- FW_FOISCSI_AUTH_POLICY_MUTUAL,
-};
-
-enum fw_foiscsi_auth_method {
- FW_FOISCSI_AUTH_METHOD_NONE = 0,
- FW_FOISCSI_AUTH_METHOD_CHAP,
- FW_FOISCSI_AUTH_METHOD_CHAP_FST,
- FW_FOISCSI_AUTH_METHOD_CHAP_SEC,
-};
-
-enum fw_foiscsi_digest_type {
- FW_FOISCSI_DIGEST_TYPE_NONE = 0,
- FW_FOISCSI_DIGEST_TYPE_CRC32,
- FW_FOISCSI_DIGEST_TYPE_CRC32_FST,
- FW_FOISCSI_DIGEST_TYPE_CRC32_SEC,
-};
-
-enum fw_foiscsi_wr_subop {
- FW_FOISCSI_WR_SUBOP_ADD = 1,
- FW_FOISCSI_WR_SUBOP_DEL = 2,
- FW_FOISCSI_WR_SUBOP_MOD = 4,
-};
-
-enum fw_foiscsi_ctrl_state {
- FW_FOISCSI_CTRL_STATE_FREE = 0,
- FW_FOISCSI_CTRL_STATE_ONLINE = 1,
- FW_FOISCSI_CTRL_STATE_FAILED,
- FW_FOISCSI_CTRL_STATE_IN_RECOVERY,
- FW_FOISCSI_CTRL_STATE_REDIRECT,
-};
-
-struct fw_rdev_wr {
- __be32 op_to_immdlen;
- __be32 alloc_to_len16;
- __be64 cookie;
- __u8 protocol;
- __u8 event_cause;
- __u8 cur_state;
- __u8 prev_state;
- __be32 flags_to_assoc_flowid;
- union rdev_entry {
- struct fcoe_rdev_entry {
- __be32 flowid;
- __u8 protocol;
- __u8 event_cause;
- __u8 flags;
- __u8 rjt_reason;
- __u8 cur_login_st;
- __u8 prev_login_st;
- __be16 rcv_fr_sz;
- __u8 rd_xfer_rdy_to_rport_type;
- __u8 vft_to_qos;
- __u8 org_proc_assoc_to_acc_rsp_code;
- __u8 enh_disc_to_tgt;
- __u8 wwnn[8];
- __u8 wwpn[8];
- __be16 iqid;
- __u8 fc_oui[3];
- __u8 r_id[3];
- } fcoe_rdev;
- struct iscsi_rdev_entry {
- __be32 flowid;
- __u8 protocol;
- __u8 event_cause;
- __u8 flags;
- __u8 r3;
- __be16 iscsi_opts;
- __be16 tcp_opts;
- __be16 ip_opts;
- __be16 max_rcv_len;
- __be16 max_snd_len;
- __be16 first_brst_len;
- __be16 max_brst_len;
- __be16 r4;
- __be16 def_time2wait;
- __be16 def_time2ret;
- __be16 nop_out_intrvl;
- __be16 non_scsi_to;
- __be16 isid;
- __be16 tsid;
- __be16 port;
- __be16 tpgt;
- __u8 r5[6];
- __be16 iqid;
- } iscsi_rdev;
- } u;
-};
-
-#define S_FW_RDEV_WR_IMMDLEN 0
-#define M_FW_RDEV_WR_IMMDLEN 0xff
-#define V_FW_RDEV_WR_IMMDLEN(x) ((x) << S_FW_RDEV_WR_IMMDLEN)
-#define G_FW_RDEV_WR_IMMDLEN(x) \
- (((x) >> S_FW_RDEV_WR_IMMDLEN) & M_FW_RDEV_WR_IMMDLEN)
-
-#define S_FW_RDEV_WR_ALLOC 31
-#define M_FW_RDEV_WR_ALLOC 0x1
-#define V_FW_RDEV_WR_ALLOC(x) ((x) << S_FW_RDEV_WR_ALLOC)
-#define G_FW_RDEV_WR_ALLOC(x) \
- (((x) >> S_FW_RDEV_WR_ALLOC) & M_FW_RDEV_WR_ALLOC)
-#define F_FW_RDEV_WR_ALLOC V_FW_RDEV_WR_ALLOC(1U)
-
-#define S_FW_RDEV_WR_FREE 30
-#define M_FW_RDEV_WR_FREE 0x1
-#define V_FW_RDEV_WR_FREE(x) ((x) << S_FW_RDEV_WR_FREE)
-#define G_FW_RDEV_WR_FREE(x) \
- (((x) >> S_FW_RDEV_WR_FREE) & M_FW_RDEV_WR_FREE)
-#define F_FW_RDEV_WR_FREE V_FW_RDEV_WR_FREE(1U)
-
-#define S_FW_RDEV_WR_MODIFY 29
-#define M_FW_RDEV_WR_MODIFY 0x1
-#define V_FW_RDEV_WR_MODIFY(x) ((x) << S_FW_RDEV_WR_MODIFY)
-#define G_FW_RDEV_WR_MODIFY(x) \
- (((x) >> S_FW_RDEV_WR_MODIFY) & M_FW_RDEV_WR_MODIFY)
-#define F_FW_RDEV_WR_MODIFY V_FW_RDEV_WR_MODIFY(1U)
-
-#define S_FW_RDEV_WR_FLOWID 8
-#define M_FW_RDEV_WR_FLOWID 0xfffff
-#define V_FW_RDEV_WR_FLOWID(x) ((x) << S_FW_RDEV_WR_FLOWID)
-#define G_FW_RDEV_WR_FLOWID(x) \
- (((x) >> S_FW_RDEV_WR_FLOWID) & M_FW_RDEV_WR_FLOWID)
-
-#define S_FW_RDEV_WR_LEN16 0
-#define M_FW_RDEV_WR_LEN16 0xff
-#define V_FW_RDEV_WR_LEN16(x) ((x) << S_FW_RDEV_WR_LEN16)
-#define G_FW_RDEV_WR_LEN16(x) \
- (((x) >> S_FW_RDEV_WR_LEN16) & M_FW_RDEV_WR_LEN16)
-
-#define S_FW_RDEV_WR_FLAGS 24
-#define M_FW_RDEV_WR_FLAGS 0xff
-#define V_FW_RDEV_WR_FLAGS(x) ((x) << S_FW_RDEV_WR_FLAGS)
-#define G_FW_RDEV_WR_FLAGS(x) \
- (((x) >> S_FW_RDEV_WR_FLAGS) & M_FW_RDEV_WR_FLAGS)
-
-#define S_FW_RDEV_WR_GET_NEXT 20
-#define M_FW_RDEV_WR_GET_NEXT 0xf
-#define V_FW_RDEV_WR_GET_NEXT(x) ((x) << S_FW_RDEV_WR_GET_NEXT)
-#define G_FW_RDEV_WR_GET_NEXT(x) \
- (((x) >> S_FW_RDEV_WR_GET_NEXT) & M_FW_RDEV_WR_GET_NEXT)
-
-#define S_FW_RDEV_WR_ASSOC_FLOWID 0
-#define M_FW_RDEV_WR_ASSOC_FLOWID 0xfffff
-#define V_FW_RDEV_WR_ASSOC_FLOWID(x) ((x) << S_FW_RDEV_WR_ASSOC_FLOWID)
-#define G_FW_RDEV_WR_ASSOC_FLOWID(x) \
- (((x) >> S_FW_RDEV_WR_ASSOC_FLOWID) & M_FW_RDEV_WR_ASSOC_FLOWID)
-
-#define S_FW_RDEV_WR_RJT 7
-#define M_FW_RDEV_WR_RJT 0x1
-#define V_FW_RDEV_WR_RJT(x) ((x) << S_FW_RDEV_WR_RJT)
-#define G_FW_RDEV_WR_RJT(x) (((x) >> S_FW_RDEV_WR_RJT) & M_FW_RDEV_WR_RJT)
-#define F_FW_RDEV_WR_RJT V_FW_RDEV_WR_RJT(1U)
-
-#define S_FW_RDEV_WR_REASON 0
-#define M_FW_RDEV_WR_REASON 0x7f
-#define V_FW_RDEV_WR_REASON(x) ((x) << S_FW_RDEV_WR_REASON)
-#define G_FW_RDEV_WR_REASON(x) \
- (((x) >> S_FW_RDEV_WR_REASON) & M_FW_RDEV_WR_REASON)
-
-#define S_FW_RDEV_WR_RD_XFER_RDY 7
-#define M_FW_RDEV_WR_RD_XFER_RDY 0x1
-#define V_FW_RDEV_WR_RD_XFER_RDY(x) ((x) << S_FW_RDEV_WR_RD_XFER_RDY)
-#define G_FW_RDEV_WR_RD_XFER_RDY(x) \
- (((x) >> S_FW_RDEV_WR_RD_XFER_RDY) & M_FW_RDEV_WR_RD_XFER_RDY)
-#define F_FW_RDEV_WR_RD_XFER_RDY V_FW_RDEV_WR_RD_XFER_RDY(1U)
-
-#define S_FW_RDEV_WR_WR_XFER_RDY 6
-#define M_FW_RDEV_WR_WR_XFER_RDY 0x1
-#define V_FW_RDEV_WR_WR_XFER_RDY(x) ((x) << S_FW_RDEV_WR_WR_XFER_RDY)
-#define G_FW_RDEV_WR_WR_XFER_RDY(x) \
- (((x) >> S_FW_RDEV_WR_WR_XFER_RDY) & M_FW_RDEV_WR_WR_XFER_RDY)
-#define F_FW_RDEV_WR_WR_XFER_RDY V_FW_RDEV_WR_WR_XFER_RDY(1U)
-
-#define S_FW_RDEV_WR_FC_SP 5
-#define M_FW_RDEV_WR_FC_SP 0x1
-#define V_FW_RDEV_WR_FC_SP(x) ((x) << S_FW_RDEV_WR_FC_SP)
-#define G_FW_RDEV_WR_FC_SP(x) \
- (((x) >> S_FW_RDEV_WR_FC_SP) & M_FW_RDEV_WR_FC_SP)
-#define F_FW_RDEV_WR_FC_SP V_FW_RDEV_WR_FC_SP(1U)
-
-#define S_FW_RDEV_WR_RPORT_TYPE 0
-#define M_FW_RDEV_WR_RPORT_TYPE 0x1f
-#define V_FW_RDEV_WR_RPORT_TYPE(x) ((x) << S_FW_RDEV_WR_RPORT_TYPE)
-#define G_FW_RDEV_WR_RPORT_TYPE(x) \
- (((x) >> S_FW_RDEV_WR_RPORT_TYPE) & M_FW_RDEV_WR_RPORT_TYPE)
-
-#define S_FW_RDEV_WR_VFT 7
-#define M_FW_RDEV_WR_VFT 0x1
-#define V_FW_RDEV_WR_VFT(x) ((x) << S_FW_RDEV_WR_VFT)
-#define G_FW_RDEV_WR_VFT(x) (((x) >> S_FW_RDEV_WR_VFT) & M_FW_RDEV_WR_VFT)
-#define F_FW_RDEV_WR_VFT V_FW_RDEV_WR_VFT(1U)
-
-#define S_FW_RDEV_WR_NPIV 6
-#define M_FW_RDEV_WR_NPIV 0x1
-#define V_FW_RDEV_WR_NPIV(x) ((x) << S_FW_RDEV_WR_NPIV)
-#define G_FW_RDEV_WR_NPIV(x) \
- (((x) >> S_FW_RDEV_WR_NPIV) & M_FW_RDEV_WR_NPIV)
-#define F_FW_RDEV_WR_NPIV V_FW_RDEV_WR_NPIV(1U)
-
-#define S_FW_RDEV_WR_CLASS 4
-#define M_FW_RDEV_WR_CLASS 0x3
-#define V_FW_RDEV_WR_CLASS(x) ((x) << S_FW_RDEV_WR_CLASS)
-#define G_FW_RDEV_WR_CLASS(x) \
- (((x) >> S_FW_RDEV_WR_CLASS) & M_FW_RDEV_WR_CLASS)
-
-#define S_FW_RDEV_WR_SEQ_DEL 3
-#define M_FW_RDEV_WR_SEQ_DEL 0x1
-#define V_FW_RDEV_WR_SEQ_DEL(x) ((x) << S_FW_RDEV_WR_SEQ_DEL)
-#define G_FW_RDEV_WR_SEQ_DEL(x) \
- (((x) >> S_FW_RDEV_WR_SEQ_DEL) & M_FW_RDEV_WR_SEQ_DEL)
-#define F_FW_RDEV_WR_SEQ_DEL V_FW_RDEV_WR_SEQ_DEL(1U)
-
-#define S_FW_RDEV_WR_PRIO_PREEMP 2
-#define M_FW_RDEV_WR_PRIO_PREEMP 0x1
-#define V_FW_RDEV_WR_PRIO_PREEMP(x) ((x) << S_FW_RDEV_WR_PRIO_PREEMP)
-#define G_FW_RDEV_WR_PRIO_PREEMP(x) \
- (((x) >> S_FW_RDEV_WR_PRIO_PREEMP) & M_FW_RDEV_WR_PRIO_PREEMP)
-#define F_FW_RDEV_WR_PRIO_PREEMP V_FW_RDEV_WR_PRIO_PREEMP(1U)
-
-#define S_FW_RDEV_WR_PREF 1
-#define M_FW_RDEV_WR_PREF 0x1
-#define V_FW_RDEV_WR_PREF(x) ((x) << S_FW_RDEV_WR_PREF)
-#define G_FW_RDEV_WR_PREF(x) \
- (((x) >> S_FW_RDEV_WR_PREF) & M_FW_RDEV_WR_PREF)
-#define F_FW_RDEV_WR_PREF V_FW_RDEV_WR_PREF(1U)
-
-#define S_FW_RDEV_WR_QOS 0
-#define M_FW_RDEV_WR_QOS 0x1
-#define V_FW_RDEV_WR_QOS(x) ((x) << S_FW_RDEV_WR_QOS)
-#define G_FW_RDEV_WR_QOS(x) (((x) >> S_FW_RDEV_WR_QOS) & M_FW_RDEV_WR_QOS)
-#define F_FW_RDEV_WR_QOS V_FW_RDEV_WR_QOS(1U)
-
-#define S_FW_RDEV_WR_ORG_PROC_ASSOC 7
-#define M_FW_RDEV_WR_ORG_PROC_ASSOC 0x1
-#define V_FW_RDEV_WR_ORG_PROC_ASSOC(x) ((x) << S_FW_RDEV_WR_ORG_PROC_ASSOC)
-#define G_FW_RDEV_WR_ORG_PROC_ASSOC(x) \
- (((x) >> S_FW_RDEV_WR_ORG_PROC_ASSOC) & M_FW_RDEV_WR_ORG_PROC_ASSOC)
-#define F_FW_RDEV_WR_ORG_PROC_ASSOC V_FW_RDEV_WR_ORG_PROC_ASSOC(1U)
-
-#define S_FW_RDEV_WR_RSP_PROC_ASSOC 6
-#define M_FW_RDEV_WR_RSP_PROC_ASSOC 0x1
-#define V_FW_RDEV_WR_RSP_PROC_ASSOC(x) ((x) << S_FW_RDEV_WR_RSP_PROC_ASSOC)
-#define G_FW_RDEV_WR_RSP_PROC_ASSOC(x) \
- (((x) >> S_FW_RDEV_WR_RSP_PROC_ASSOC) & M_FW_RDEV_WR_RSP_PROC_ASSOC)
-#define F_FW_RDEV_WR_RSP_PROC_ASSOC V_FW_RDEV_WR_RSP_PROC_ASSOC(1U)
-
-#define S_FW_RDEV_WR_IMAGE_PAIR 5
-#define M_FW_RDEV_WR_IMAGE_PAIR 0x1
-#define V_FW_RDEV_WR_IMAGE_PAIR(x) ((x) << S_FW_RDEV_WR_IMAGE_PAIR)
-#define G_FW_RDEV_WR_IMAGE_PAIR(x) \
- (((x) >> S_FW_RDEV_WR_IMAGE_PAIR) & M_FW_RDEV_WR_IMAGE_PAIR)
-#define F_FW_RDEV_WR_IMAGE_PAIR V_FW_RDEV_WR_IMAGE_PAIR(1U)
-
-#define S_FW_RDEV_WR_ACC_RSP_CODE 0
-#define M_FW_RDEV_WR_ACC_RSP_CODE 0x1f
-#define V_FW_RDEV_WR_ACC_RSP_CODE(x) ((x) << S_FW_RDEV_WR_ACC_RSP_CODE)
-#define G_FW_RDEV_WR_ACC_RSP_CODE(x) \
- (((x) >> S_FW_RDEV_WR_ACC_RSP_CODE) & M_FW_RDEV_WR_ACC_RSP_CODE)
-
-#define S_FW_RDEV_WR_ENH_DISC 7
-#define M_FW_RDEV_WR_ENH_DISC 0x1
-#define V_FW_RDEV_WR_ENH_DISC(x) ((x) << S_FW_RDEV_WR_ENH_DISC)
-#define G_FW_RDEV_WR_ENH_DISC(x) \
- (((x) >> S_FW_RDEV_WR_ENH_DISC) & M_FW_RDEV_WR_ENH_DISC)
-#define F_FW_RDEV_WR_ENH_DISC V_FW_RDEV_WR_ENH_DISC(1U)
-
-#define S_FW_RDEV_WR_REC 6
-#define M_FW_RDEV_WR_REC 0x1
-#define V_FW_RDEV_WR_REC(x) ((x) << S_FW_RDEV_WR_REC)
-#define G_FW_RDEV_WR_REC(x) (((x) >> S_FW_RDEV_WR_REC) & M_FW_RDEV_WR_REC)
-#define F_FW_RDEV_WR_REC V_FW_RDEV_WR_REC(1U)
-
-#define S_FW_RDEV_WR_TASK_RETRY_ID 5
-#define M_FW_RDEV_WR_TASK_RETRY_ID 0x1
-#define V_FW_RDEV_WR_TASK_RETRY_ID(x) ((x) << S_FW_RDEV_WR_TASK_RETRY_ID)
-#define G_FW_RDEV_WR_TASK_RETRY_ID(x) \
- (((x) >> S_FW_RDEV_WR_TASK_RETRY_ID) & M_FW_RDEV_WR_TASK_RETRY_ID)
-#define F_FW_RDEV_WR_TASK_RETRY_ID V_FW_RDEV_WR_TASK_RETRY_ID(1U)
-
-#define S_FW_RDEV_WR_RETRY 4
-#define M_FW_RDEV_WR_RETRY 0x1
-#define V_FW_RDEV_WR_RETRY(x) ((x) << S_FW_RDEV_WR_RETRY)
-#define G_FW_RDEV_WR_RETRY(x) \
- (((x) >> S_FW_RDEV_WR_RETRY) & M_FW_RDEV_WR_RETRY)
-#define F_FW_RDEV_WR_RETRY V_FW_RDEV_WR_RETRY(1U)
-
-#define S_FW_RDEV_WR_CONF_CMPL 3
-#define M_FW_RDEV_WR_CONF_CMPL 0x1
-#define V_FW_RDEV_WR_CONF_CMPL(x) ((x) << S_FW_RDEV_WR_CONF_CMPL)
-#define G_FW_RDEV_WR_CONF_CMPL(x) \
- (((x) >> S_FW_RDEV_WR_CONF_CMPL) & M_FW_RDEV_WR_CONF_CMPL)
-#define F_FW_RDEV_WR_CONF_CMPL V_FW_RDEV_WR_CONF_CMPL(1U)
-
-#define S_FW_RDEV_WR_DATA_OVLY 2
-#define M_FW_RDEV_WR_DATA_OVLY 0x1
-#define V_FW_RDEV_WR_DATA_OVLY(x) ((x) << S_FW_RDEV_WR_DATA_OVLY)
-#define G_FW_RDEV_WR_DATA_OVLY(x) \
- (((x) >> S_FW_RDEV_WR_DATA_OVLY) & M_FW_RDEV_WR_DATA_OVLY)
-#define F_FW_RDEV_WR_DATA_OVLY V_FW_RDEV_WR_DATA_OVLY(1U)
-
-#define S_FW_RDEV_WR_INI 1
-#define M_FW_RDEV_WR_INI 0x1
-#define V_FW_RDEV_WR_INI(x) ((x) << S_FW_RDEV_WR_INI)
-#define G_FW_RDEV_WR_INI(x) (((x) >> S_FW_RDEV_WR_INI) & M_FW_RDEV_WR_INI)
-#define F_FW_RDEV_WR_INI V_FW_RDEV_WR_INI(1U)
-
-#define S_FW_RDEV_WR_TGT 0
-#define M_FW_RDEV_WR_TGT 0x1
-#define V_FW_RDEV_WR_TGT(x) ((x) << S_FW_RDEV_WR_TGT)
-#define G_FW_RDEV_WR_TGT(x) (((x) >> S_FW_RDEV_WR_TGT) & M_FW_RDEV_WR_TGT)
-#define F_FW_RDEV_WR_TGT V_FW_RDEV_WR_TGT(1U)
-
-struct fw_foiscsi_node_wr {
- __be32 op_to_immdlen;
- __be32 flowid_len16;
- __u64 cookie;
- __u8 subop;
- __u8 status;
- __u8 alias_len;
- __u8 iqn_len;
- __be32 node_flowid;
- __be16 nodeid;
- __be16 login_retry;
- __be16 retry_timeout;
- __be16 r3;
- __u8 iqn[224];
- __u8 alias[224];
-};
-
-#define S_FW_FOISCSI_NODE_WR_IMMDLEN 0
-#define M_FW_FOISCSI_NODE_WR_IMMDLEN 0xffff
-#define V_FW_FOISCSI_NODE_WR_IMMDLEN(x) ((x) << S_FW_FOISCSI_NODE_WR_IMMDLEN)
-#define G_FW_FOISCSI_NODE_WR_IMMDLEN(x) \
- (((x) >> S_FW_FOISCSI_NODE_WR_IMMDLEN) & M_FW_FOISCSI_NODE_WR_IMMDLEN)
-
-struct fw_foiscsi_ctrl_wr {
- __be32 op_compl;
- __be32 flowid_len16;
- __u64 cookie;
- __u8 subop;
- __u8 status;
- __u8 ctrl_state;
- __u8 io_state;
- __be32 node_id;
- __be32 ctrl_id;
- __be32 io_id;
- struct fw_foiscsi_sess_attr {
- __be32 sess_type_to_erl;
- __be16 max_conn;
- __be16 max_r2t;
- __be16 time2wait;
- __be16 time2retain;
- __be32 max_burst;
- __be32 first_burst;
- __be32 r1;
- } sess_attr;
- struct fw_foiscsi_conn_attr {
- __be32 hdigest_to_ddp_pgsz;
- __be32 max_rcv_dsl;
- __be32 ping_tmo;
- __be16 dst_port;
- __be16 src_port;
- union fw_foiscsi_conn_attr_addr {
- struct fw_foiscsi_conn_attr_ipv6 {
- __be64 dst_addr[2];
- __be64 src_addr[2];
- } ipv6_addr;
- struct fw_foiscsi_conn_attr_ipv4 {
- __be32 dst_addr;
- __be32 src_addr;
- } ipv4_addr;
- } u;
- } conn_attr;
- __u8 tgt_name_len;
- __u8 r3[7];
- __u8 tgt_name[FW_FOISCSI_NAME_MAX_LEN];
-};
-
-#define S_FW_FOISCSI_CTRL_WR_SESS_TYPE 30
-#define M_FW_FOISCSI_CTRL_WR_SESS_TYPE 0x3
-#define V_FW_FOISCSI_CTRL_WR_SESS_TYPE(x) \
- ((x) << S_FW_FOISCSI_CTRL_WR_SESS_TYPE)
-#define G_FW_FOISCSI_CTRL_WR_SESS_TYPE(x) \
- (((x) >> S_FW_FOISCSI_CTRL_WR_SESS_TYPE) & M_FW_FOISCSI_CTRL_WR_SESS_TYPE)
-
-#define S_FW_FOISCSI_CTRL_WR_SEQ_INORDER 29
-#define M_FW_FOISCSI_CTRL_WR_SEQ_INORDER 0x1
-#define V_FW_FOISCSI_CTRL_WR_SEQ_INORDER(x) \
- ((x) << S_FW_FOISCSI_CTRL_WR_SEQ_INORDER)
-#define G_FW_FOISCSI_CTRL_WR_SEQ_INORDER(x) \
- (((x) >> S_FW_FOISCSI_CTRL_WR_SEQ_INORDER) & \
- M_FW_FOISCSI_CTRL_WR_SEQ_INORDER)
-#define F_FW_FOISCSI_CTRL_WR_SEQ_INORDER \
- V_FW_FOISCSI_CTRL_WR_SEQ_INORDER(1U)
-
-#define S_FW_FOISCSI_CTRL_WR_PDU_INORDER 28
-#define M_FW_FOISCSI_CTRL_WR_PDU_INORDER 0x1
-#define V_FW_FOISCSI_CTRL_WR_PDU_INORDER(x) \
- ((x) << S_FW_FOISCSI_CTRL_WR_PDU_INORDER)
-#define G_FW_FOISCSI_CTRL_WR_PDU_INORDER(x) \
- (((x) >> S_FW_FOISCSI_CTRL_WR_PDU_INORDER) & \
- M_FW_FOISCSI_CTRL_WR_PDU_INORDER)
-#define F_FW_FOISCSI_CTRL_WR_PDU_INORDER \
- V_FW_FOISCSI_CTRL_WR_PDU_INORDER(1U)
-
-#define S_FW_FOISCSI_CTRL_WR_IMMD_DATA_EN 27
-#define M_FW_FOISCSI_CTRL_WR_IMMD_DATA_EN 0x1
-#define V_FW_FOISCSI_CTRL_WR_IMMD_DATA_EN(x) \
- ((x) << S_FW_FOISCSI_CTRL_WR_IMMD_DATA_EN)
-#define G_FW_FOISCSI_CTRL_WR_IMMD_DATA_EN(x) \
- (((x) >> S_FW_FOISCSI_CTRL_WR_IMMD_DATA_EN) & \
- M_FW_FOISCSI_CTRL_WR_IMMD_DATA_EN)
-#define F_FW_FOISCSI_CTRL_WR_IMMD_DATA_EN \
- V_FW_FOISCSI_CTRL_WR_IMMD_DATA_EN(1U)
-
-#define S_FW_FOISCSI_CTRL_WR_INIT_R2T_EN 26
-#define M_FW_FOISCSI_CTRL_WR_INIT_R2T_EN 0x1
-#define V_FW_FOISCSI_CTRL_WR_INIT_R2T_EN(x) \
- ((x) << S_FW_FOISCSI_CTRL_WR_INIT_R2T_EN)
-#define G_FW_FOISCSI_CTRL_WR_INIT_R2T_EN(x) \
- (((x) >> S_FW_FOISCSI_CTRL_WR_INIT_R2T_EN) & \
- M_FW_FOISCSI_CTRL_WR_INIT_R2T_EN)
-#define F_FW_FOISCSI_CTRL_WR_INIT_R2T_EN \
- V_FW_FOISCSI_CTRL_WR_INIT_R2T_EN(1U)
-
-#define S_FW_FOISCSI_CTRL_WR_ERL 24
-#define M_FW_FOISCSI_CTRL_WR_ERL 0x3
-#define V_FW_FOISCSI_CTRL_WR_ERL(x) ((x) << S_FW_FOISCSI_CTRL_WR_ERL)
-#define G_FW_FOISCSI_CTRL_WR_ERL(x) \
- (((x) >> S_FW_FOISCSI_CTRL_WR_ERL) & M_FW_FOISCSI_CTRL_WR_ERL)
-
-#define S_FW_FOISCSI_CTRL_WR_HDIGEST 30
-#define M_FW_FOISCSI_CTRL_WR_HDIGEST 0x3
-#define V_FW_FOISCSI_CTRL_WR_HDIGEST(x) ((x) << S_FW_FOISCSI_CTRL_WR_HDIGEST)
-#define G_FW_FOISCSI_CTRL_WR_HDIGEST(x) \
- (((x) >> S_FW_FOISCSI_CTRL_WR_HDIGEST) & M_FW_FOISCSI_CTRL_WR_HDIGEST)
-
-#define S_FW_FOISCSI_CTRL_WR_DDIGEST 28
-#define M_FW_FOISCSI_CTRL_WR_DDIGEST 0x3
-#define V_FW_FOISCSI_CTRL_WR_DDIGEST(x) ((x) << S_FW_FOISCSI_CTRL_WR_DDIGEST)
-#define G_FW_FOISCSI_CTRL_WR_DDIGEST(x) \
- (((x) >> S_FW_FOISCSI_CTRL_WR_DDIGEST) & M_FW_FOISCSI_CTRL_WR_DDIGEST)
-
-#define S_FW_FOISCSI_CTRL_WR_AUTH_METHOD 25
-#define M_FW_FOISCSI_CTRL_WR_AUTH_METHOD 0x7
-#define V_FW_FOISCSI_CTRL_WR_AUTH_METHOD(x) \
- ((x) << S_FW_FOISCSI_CTRL_WR_AUTH_METHOD)
-#define G_FW_FOISCSI_CTRL_WR_AUTH_METHOD(x) \
- (((x) >> S_FW_FOISCSI_CTRL_WR_AUTH_METHOD) & \
- M_FW_FOISCSI_CTRL_WR_AUTH_METHOD)
-
-#define S_FW_FOISCSI_CTRL_WR_AUTH_POLICY 23
-#define M_FW_FOISCSI_CTRL_WR_AUTH_POLICY 0x3
-#define V_FW_FOISCSI_CTRL_WR_AUTH_POLICY(x) \
- ((x) << S_FW_FOISCSI_CTRL_WR_AUTH_POLICY)
-#define G_FW_FOISCSI_CTRL_WR_AUTH_POLICY(x) \
- (((x) >> S_FW_FOISCSI_CTRL_WR_AUTH_POLICY) & \
- M_FW_FOISCSI_CTRL_WR_AUTH_POLICY)
-
-#define S_FW_FOISCSI_CTRL_WR_DDP_PGSZ 21
-#define M_FW_FOISCSI_CTRL_WR_DDP_PGSZ 0x3
-#define V_FW_FOISCSI_CTRL_WR_DDP_PGSZ(x) \
- ((x) << S_FW_FOISCSI_CTRL_WR_DDP_PGSZ)
-#define G_FW_FOISCSI_CTRL_WR_DDP_PGSZ(x) \
- (((x) >> S_FW_FOISCSI_CTRL_WR_DDP_PGSZ) & M_FW_FOISCSI_CTRL_WR_DDP_PGSZ)
-
-struct fw_foiscsi_chap_wr {
- __be32 op_compl;
- __be32 flowid_len16;
- __u64 cookie;
- __u8 status;
- __u8 id_len;
- __u8 sec_len;
- __u8 node_type;
- __be16 node_id;
- __u8 r3[2];
- __u8 chap_id[FW_FOISCSI_NAME_MAX_LEN];
- __u8 chap_sec[FW_FOISCSI_CHAP_SEC_MAX_LEN];
-};
-
-/******************************************************************************
- * F O F C O E W O R K R E Q U E S T s
- *******************************************/
-
-struct fw_fcoe_els_ct_wr {
- __be32 op_immdlen;
- __be32 flowid_len16;
- __be64 cookie;
- __be16 iqid;
- __u8 tmo_val;
- __u8 els_ct_type;
- __u8 ctl_pri;
- __u8 cp_en_class;
- __be16 xfer_cnt;
- __u8 fl_to_sp;
- __u8 l_id[3];
- __u8 r5;
- __u8 r_id[3];
- __be64 rsp_dmaaddr;
- __be32 rsp_dmalen;
- __be32 r6;
-};
-
-#define S_FW_FCOE_ELS_CT_WR_OPCODE 24
-#define M_FW_FCOE_ELS_CT_WR_OPCODE 0xff
-#define V_FW_FCOE_ELS_CT_WR_OPCODE(x) ((x) << S_FW_FCOE_ELS_CT_WR_OPCODE)
-#define G_FW_FCOE_ELS_CT_WR_OPCODE(x) \
- (((x) >> S_FW_FCOE_ELS_CT_WR_OPCODE) & M_FW_FCOE_ELS_CT_WR_OPCODE)
-
-#define S_FW_FCOE_ELS_CT_WR_IMMDLEN 0
-#define M_FW_FCOE_ELS_CT_WR_IMMDLEN 0xff
-#define V_FW_FCOE_ELS_CT_WR_IMMDLEN(x) ((x) << S_FW_FCOE_ELS_CT_WR_IMMDLEN)
-#define G_FW_FCOE_ELS_CT_WR_IMMDLEN(x) \
- (((x) >> S_FW_FCOE_ELS_CT_WR_IMMDLEN) & M_FW_FCOE_ELS_CT_WR_IMMDLEN)
-
-#define S_FW_FCOE_ELS_CT_WR_FLOWID 8
-#define M_FW_FCOE_ELS_CT_WR_FLOWID 0xfffff
-#define V_FW_FCOE_ELS_CT_WR_FLOWID(x) ((x) << S_FW_FCOE_ELS_CT_WR_FLOWID)
-#define G_FW_FCOE_ELS_CT_WR_FLOWID(x) \
- (((x) >> S_FW_FCOE_ELS_CT_WR_FLOWID) & M_FW_FCOE_ELS_CT_WR_FLOWID)
-
-#define S_FW_FCOE_ELS_CT_WR_LEN16 0
-#define M_FW_FCOE_ELS_CT_WR_LEN16 0xff
-#define V_FW_FCOE_ELS_CT_WR_LEN16(x) ((x) << S_FW_FCOE_ELS_CT_WR_LEN16)
-#define G_FW_FCOE_ELS_CT_WR_LEN16(x) \
- (((x) >> S_FW_FCOE_ELS_CT_WR_LEN16) & M_FW_FCOE_ELS_CT_WR_LEN16)
-
-#define S_FW_FCOE_ELS_CT_WR_CP_EN 6
-#define M_FW_FCOE_ELS_CT_WR_CP_EN 0x3
-#define V_FW_FCOE_ELS_CT_WR_CP_EN(x) ((x) << S_FW_FCOE_ELS_CT_WR_CP_EN)
-#define G_FW_FCOE_ELS_CT_WR_CP_EN(x) \
- (((x) >> S_FW_FCOE_ELS_CT_WR_CP_EN) & M_FW_FCOE_ELS_CT_WR_CP_EN)
-
-#define S_FW_FCOE_ELS_CT_WR_CLASS 4
-#define M_FW_FCOE_ELS_CT_WR_CLASS 0x3
-#define V_FW_FCOE_ELS_CT_WR_CLASS(x) ((x) << S_FW_FCOE_ELS_CT_WR_CLASS)
-#define G_FW_FCOE_ELS_CT_WR_CLASS(x) \
- (((x) >> S_FW_FCOE_ELS_CT_WR_CLASS) & M_FW_FCOE_ELS_CT_WR_CLASS)
-
-#define S_FW_FCOE_ELS_CT_WR_FL 2
-#define M_FW_FCOE_ELS_CT_WR_FL 0x1
-#define V_FW_FCOE_ELS_CT_WR_FL(x) ((x) << S_FW_FCOE_ELS_CT_WR_FL)
-#define G_FW_FCOE_ELS_CT_WR_FL(x) \
- (((x) >> S_FW_FCOE_ELS_CT_WR_FL) & M_FW_FCOE_ELS_CT_WR_FL)
-#define F_FW_FCOE_ELS_CT_WR_FL V_FW_FCOE_ELS_CT_WR_FL(1U)
-
-#define S_FW_FCOE_ELS_CT_WR_NPIV 1
-#define M_FW_FCOE_ELS_CT_WR_NPIV 0x1
-#define V_FW_FCOE_ELS_CT_WR_NPIV(x) ((x) << S_FW_FCOE_ELS_CT_WR_NPIV)
-#define G_FW_FCOE_ELS_CT_WR_NPIV(x) \
- (((x) >> S_FW_FCOE_ELS_CT_WR_NPIV) & M_FW_FCOE_ELS_CT_WR_NPIV)
-#define F_FW_FCOE_ELS_CT_WR_NPIV V_FW_FCOE_ELS_CT_WR_NPIV(1U)
-
-#define S_FW_FCOE_ELS_CT_WR_SP 0
-#define M_FW_FCOE_ELS_CT_WR_SP 0x1
-#define V_FW_FCOE_ELS_CT_WR_SP(x) ((x) << S_FW_FCOE_ELS_CT_WR_SP)
-#define G_FW_FCOE_ELS_CT_WR_SP(x) \
- (((x) >> S_FW_FCOE_ELS_CT_WR_SP) & M_FW_FCOE_ELS_CT_WR_SP)
-#define F_FW_FCOE_ELS_CT_WR_SP V_FW_FCOE_ELS_CT_WR_SP(1U)
-
-/******************************************************************************
- * S C S I W O R K R E Q U E S T s (FOiSCSI and FCOE unified data path)
- *****************************************************************************/
-
-struct fw_scsi_write_wr {
- __be32 op_immdlen;
- __be32 flowid_len16;
- __be64 cookie;
- __be16 iqid;
- __u8 tmo_val;
- __u8 use_xfer_cnt;
- union fw_scsi_write_priv {
- struct fcoe_write_priv {
- __u8 ctl_pri;
- __u8 cp_en_class;
- __u8 r3_lo[2];
- } fcoe;
- struct iscsi_write_priv {
- __u8 r3[4];
- } iscsi;
- } u;
- __be32 xfer_cnt;
- __be32 ini_xfer_cnt;
- __be64 rsp_dmaaddr;
- __be32 rsp_dmalen;
- __be32 r4;
-};
-
-#define S_FW_SCSI_WRITE_WR_OPCODE 24
-#define M_FW_SCSI_WRITE_WR_OPCODE 0xff
-#define V_FW_SCSI_WRITE_WR_OPCODE(x) ((x) << S_FW_SCSI_WRITE_WR_OPCODE)
-#define G_FW_SCSI_WRITE_WR_OPCODE(x) \
- (((x) >> S_FW_SCSI_WRITE_WR_OPCODE) & M_FW_SCSI_WRITE_WR_OPCODE)
-
-#define S_FW_SCSI_WRITE_WR_IMMDLEN 0
-#define M_FW_SCSI_WRITE_WR_IMMDLEN 0xff
-#define V_FW_SCSI_WRITE_WR_IMMDLEN(x) ((x) << S_FW_SCSI_WRITE_WR_IMMDLEN)
-#define G_FW_SCSI_WRITE_WR_IMMDLEN(x) \
- (((x) >> S_FW_SCSI_WRITE_WR_IMMDLEN) & M_FW_SCSI_WRITE_WR_IMMDLEN)
-
-#define S_FW_SCSI_WRITE_WR_FLOWID 8
-#define M_FW_SCSI_WRITE_WR_FLOWID 0xfffff
-#define V_FW_SCSI_WRITE_WR_FLOWID(x) ((x) << S_FW_SCSI_WRITE_WR_FLOWID)
-#define G_FW_SCSI_WRITE_WR_FLOWID(x) \
- (((x) >> S_FW_SCSI_WRITE_WR_FLOWID) & M_FW_SCSI_WRITE_WR_FLOWID)
-
-#define S_FW_SCSI_WRITE_WR_LEN16 0
-#define M_FW_SCSI_WRITE_WR_LEN16 0xff
-#define V_FW_SCSI_WRITE_WR_LEN16(x) ((x) << S_FW_SCSI_WRITE_WR_LEN16)
-#define G_FW_SCSI_WRITE_WR_LEN16(x) \
- (((x) >> S_FW_SCSI_WRITE_WR_LEN16) & M_FW_SCSI_WRITE_WR_LEN16)
-
-#define S_FW_SCSI_WRITE_WR_CP_EN 6
-#define M_FW_SCSI_WRITE_WR_CP_EN 0x3
-#define V_FW_SCSI_WRITE_WR_CP_EN(x) ((x) << S_FW_SCSI_WRITE_WR_CP_EN)
-#define G_FW_SCSI_WRITE_WR_CP_EN(x) \
- (((x) >> S_FW_SCSI_WRITE_WR_CP_EN) & M_FW_SCSI_WRITE_WR_CP_EN)
-
-#define S_FW_SCSI_WRITE_WR_CLASS 4
-#define M_FW_SCSI_WRITE_WR_CLASS 0x3
-#define V_FW_SCSI_WRITE_WR_CLASS(x) ((x) << S_FW_SCSI_WRITE_WR_CLASS)
-#define G_FW_SCSI_WRITE_WR_CLASS(x) \
- (((x) >> S_FW_SCSI_WRITE_WR_CLASS) & M_FW_SCSI_WRITE_WR_CLASS)
-
-struct fw_scsi_read_wr {
- __be32 op_immdlen;
- __be32 flowid_len16;
- __be64 cookie;
- __be16 iqid;
- __u8 tmo_val;
- __u8 use_xfer_cnt;
- union fw_scsi_read_priv {
- struct fcoe_read_priv {
- __u8 ctl_pri;
- __u8 cp_en_class;
- __u8 r3_lo[2];
- } fcoe;
- struct iscsi_read_priv {
- __u8 r3[4];
- } iscsi;
- } u;
- __be32 xfer_cnt;
- __be32 ini_xfer_cnt;
- __be64 rsp_dmaaddr;
- __be32 rsp_dmalen;
- __be32 r4;
-};
-
-#define S_FW_SCSI_READ_WR_OPCODE 24
-#define M_FW_SCSI_READ_WR_OPCODE 0xff
-#define V_FW_SCSI_READ_WR_OPCODE(x) ((x) << S_FW_SCSI_READ_WR_OPCODE)
-#define G_FW_SCSI_READ_WR_OPCODE(x) \
- (((x) >> S_FW_SCSI_READ_WR_OPCODE) & M_FW_SCSI_READ_WR_OPCODE)
-
-#define S_FW_SCSI_READ_WR_IMMDLEN 0
-#define M_FW_SCSI_READ_WR_IMMDLEN 0xff
-#define V_FW_SCSI_READ_WR_IMMDLEN(x) ((x) << S_FW_SCSI_READ_WR_IMMDLEN)
-#define G_FW_SCSI_READ_WR_IMMDLEN(x) \
- (((x) >> S_FW_SCSI_READ_WR_IMMDLEN) & M_FW_SCSI_READ_WR_IMMDLEN)
-
-#define S_FW_SCSI_READ_WR_FLOWID 8
-#define M_FW_SCSI_READ_WR_FLOWID 0xfffff
-#define V_FW_SCSI_READ_WR_FLOWID(x) ((x) << S_FW_SCSI_READ_WR_FLOWID)
-#define G_FW_SCSI_READ_WR_FLOWID(x) \
- (((x) >> S_FW_SCSI_READ_WR_FLOWID) & M_FW_SCSI_READ_WR_FLOWID)
-
-#define S_FW_SCSI_READ_WR_LEN16 0
-#define M_FW_SCSI_READ_WR_LEN16 0xff
-#define V_FW_SCSI_READ_WR_LEN16(x) ((x) << S_FW_SCSI_READ_WR_LEN16)
-#define G_FW_SCSI_READ_WR_LEN16(x) \
- (((x) >> S_FW_SCSI_READ_WR_LEN16) & M_FW_SCSI_READ_WR_LEN16)
-
-#define S_FW_SCSI_READ_WR_CP_EN 6
-#define M_FW_SCSI_READ_WR_CP_EN 0x3
-#define V_FW_SCSI_READ_WR_CP_EN(x) ((x) << S_FW_SCSI_READ_WR_CP_EN)
-#define G_FW_SCSI_READ_WR_CP_EN(x) \
- (((x) >> S_FW_SCSI_READ_WR_CP_EN) & M_FW_SCSI_READ_WR_CP_EN)
-
-#define S_FW_SCSI_READ_WR_CLASS 4
-#define M_FW_SCSI_READ_WR_CLASS 0x3
-#define V_FW_SCSI_READ_WR_CLASS(x) ((x) << S_FW_SCSI_READ_WR_CLASS)
-#define G_FW_SCSI_READ_WR_CLASS(x) \
- (((x) >> S_FW_SCSI_READ_WR_CLASS) & M_FW_SCSI_READ_WR_CLASS)
-
-struct fw_scsi_cmd_wr {
- __be32 op_immdlen;
- __be32 flowid_len16;
- __be64 cookie;
- __be16 iqid;
- __u8 tmo_val;
- __u8 r3;
- union fw_scsi_cmd_priv {
- struct fcoe_cmd_priv {
- __u8 ctl_pri;
- __u8 cp_en_class;
- __u8 r4_lo[2];
- } fcoe;
- struct iscsi_cmd_priv {
- __u8 r4[4];
- } iscsi;
- } u;
- __u8 r5[8];
- __be64 rsp_dmaaddr;
- __be32 rsp_dmalen;
- __be32 r6;
-};
-
-#define S_FW_SCSI_CMD_WR_OPCODE 24
-#define M_FW_SCSI_CMD_WR_OPCODE 0xff
-#define V_FW_SCSI_CMD_WR_OPCODE(x) ((x) << S_FW_SCSI_CMD_WR_OPCODE)
-#define G_FW_SCSI_CMD_WR_OPCODE(x) \
- (((x) >> S_FW_SCSI_CMD_WR_OPCODE) & M_FW_SCSI_CMD_WR_OPCODE)
-
-#define S_FW_SCSI_CMD_WR_IMMDLEN 0
-#define M_FW_SCSI_CMD_WR_IMMDLEN 0xff
-#define V_FW_SCSI_CMD_WR_IMMDLEN(x) ((x) << S_FW_SCSI_CMD_WR_IMMDLEN)
-#define G_FW_SCSI_CMD_WR_IMMDLEN(x) \
- (((x) >> S_FW_SCSI_CMD_WR_IMMDLEN) & M_FW_SCSI_CMD_WR_IMMDLEN)
-
-#define S_FW_SCSI_CMD_WR_FLOWID 8
-#define M_FW_SCSI_CMD_WR_FLOWID 0xfffff
-#define V_FW_SCSI_CMD_WR_FLOWID(x) ((x) << S_FW_SCSI_CMD_WR_FLOWID)
-#define G_FW_SCSI_CMD_WR_FLOWID(x) \
- (((x) >> S_FW_SCSI_CMD_WR_FLOWID) & M_FW_SCSI_CMD_WR_FLOWID)
-
-#define S_FW_SCSI_CMD_WR_LEN16 0
-#define M_FW_SCSI_CMD_WR_LEN16 0xff
-#define V_FW_SCSI_CMD_WR_LEN16(x) ((x) << S_FW_SCSI_CMD_WR_LEN16)
-#define G_FW_SCSI_CMD_WR_LEN16(x) \
- (((x) >> S_FW_SCSI_CMD_WR_LEN16) & M_FW_SCSI_CMD_WR_LEN16)
-
-#define S_FW_SCSI_CMD_WR_CP_EN 6
-#define M_FW_SCSI_CMD_WR_CP_EN 0x3
-#define V_FW_SCSI_CMD_WR_CP_EN(x) ((x) << S_FW_SCSI_CMD_WR_CP_EN)
-#define G_FW_SCSI_CMD_WR_CP_EN(x) \
- (((x) >> S_FW_SCSI_CMD_WR_CP_EN) & M_FW_SCSI_CMD_WR_CP_EN)
-
-#define S_FW_SCSI_CMD_WR_CLASS 4
-#define M_FW_SCSI_CMD_WR_CLASS 0x3
-#define V_FW_SCSI_CMD_WR_CLASS(x) ((x) << S_FW_SCSI_CMD_WR_CLASS)
-#define G_FW_SCSI_CMD_WR_CLASS(x) \
- (((x) >> S_FW_SCSI_CMD_WR_CLASS) & M_FW_SCSI_CMD_WR_CLASS)
-
-struct fw_scsi_abrt_cls_wr {
- __be32 op_immdlen;
- __be32 flowid_len16;
- __be64 cookie;
- __be16 iqid;
- __u8 tmo_val;
- __u8 sub_opcode_to_chk_all_io;
- __u8 r3[4];
- __be64 t_cookie;
-};
-
-#define S_FW_SCSI_ABRT_CLS_WR_OPCODE 24
-#define M_FW_SCSI_ABRT_CLS_WR_OPCODE 0xff
-#define V_FW_SCSI_ABRT_CLS_WR_OPCODE(x) ((x) << S_FW_SCSI_ABRT_CLS_WR_OPCODE)
-#define G_FW_SCSI_ABRT_CLS_WR_OPCODE(x) \
- (((x) >> S_FW_SCSI_ABRT_CLS_WR_OPCODE) & M_FW_SCSI_ABRT_CLS_WR_OPCODE)
-
-#define S_FW_SCSI_ABRT_CLS_WR_IMMDLEN 0
-#define M_FW_SCSI_ABRT_CLS_WR_IMMDLEN 0xff
-#define V_FW_SCSI_ABRT_CLS_WR_IMMDLEN(x) \
- ((x) << S_FW_SCSI_ABRT_CLS_WR_IMMDLEN)
-#define G_FW_SCSI_ABRT_CLS_WR_IMMDLEN(x) \
- (((x) >> S_FW_SCSI_ABRT_CLS_WR_IMMDLEN) & M_FW_SCSI_ABRT_CLS_WR_IMMDLEN)
-
-#define S_FW_SCSI_ABRT_CLS_WR_FLOWID 8
-#define M_FW_SCSI_ABRT_CLS_WR_FLOWID 0xfffff
-#define V_FW_SCSI_ABRT_CLS_WR_FLOWID(x) ((x) << S_FW_SCSI_ABRT_CLS_WR_FLOWID)
-#define G_FW_SCSI_ABRT_CLS_WR_FLOWID(x) \
- (((x) >> S_FW_SCSI_ABRT_CLS_WR_FLOWID) & M_FW_SCSI_ABRT_CLS_WR_FLOWID)
-
-#define S_FW_SCSI_ABRT_CLS_WR_LEN16 0
-#define M_FW_SCSI_ABRT_CLS_WR_LEN16 0xff
-#define V_FW_SCSI_ABRT_CLS_WR_LEN16(x) ((x) << S_FW_SCSI_ABRT_CLS_WR_LEN16)
-#define G_FW_SCSI_ABRT_CLS_WR_LEN16(x) \
- (((x) >> S_FW_SCSI_ABRT_CLS_WR_LEN16) & M_FW_SCSI_ABRT_CLS_WR_LEN16)
-
-#define S_FW_SCSI_ABRT_CLS_WR_SUB_OPCODE 2
-#define M_FW_SCSI_ABRT_CLS_WR_SUB_OPCODE 0x3f
-#define V_FW_SCSI_ABRT_CLS_WR_SUB_OPCODE(x) \
- ((x) << S_FW_SCSI_ABRT_CLS_WR_SUB_OPCODE)
-#define G_FW_SCSI_ABRT_CLS_WR_SUB_OPCODE(x) \
- (((x) >> S_FW_SCSI_ABRT_CLS_WR_SUB_OPCODE) & \
- M_FW_SCSI_ABRT_CLS_WR_SUB_OPCODE)
-
-#define S_FW_SCSI_ABRT_CLS_WR_UNSOL 1
-#define M_FW_SCSI_ABRT_CLS_WR_UNSOL 0x1
-#define V_FW_SCSI_ABRT_CLS_WR_UNSOL(x) ((x) << S_FW_SCSI_ABRT_CLS_WR_UNSOL)
-#define G_FW_SCSI_ABRT_CLS_WR_UNSOL(x) \
- (((x) >> S_FW_SCSI_ABRT_CLS_WR_UNSOL) & M_FW_SCSI_ABRT_CLS_WR_UNSOL)
-#define F_FW_SCSI_ABRT_CLS_WR_UNSOL V_FW_SCSI_ABRT_CLS_WR_UNSOL(1U)
-
-#define S_FW_SCSI_ABRT_CLS_WR_CHK_ALL_IO 0
-#define M_FW_SCSI_ABRT_CLS_WR_CHK_ALL_IO 0x1
-#define V_FW_SCSI_ABRT_CLS_WR_CHK_ALL_IO(x) \
- ((x) << S_FW_SCSI_ABRT_CLS_WR_CHK_ALL_IO)
-#define G_FW_SCSI_ABRT_CLS_WR_CHK_ALL_IO(x) \
- (((x) >> S_FW_SCSI_ABRT_CLS_WR_CHK_ALL_IO) & \
- M_FW_SCSI_ABRT_CLS_WR_CHK_ALL_IO)
-#define F_FW_SCSI_ABRT_CLS_WR_CHK_ALL_IO \
- V_FW_SCSI_ABRT_CLS_WR_CHK_ALL_IO(1U)
-
-struct fw_scsi_tgt_acc_wr {
- __be32 op_immdlen;
- __be32 flowid_len16;
- __be64 cookie;
- __be16 iqid;
- __u8 r3;
- __u8 use_burst_len;
- union fw_scsi_tgt_acc_priv {
- struct fcoe_tgt_acc_priv {
- __u8 ctl_pri;
- __u8 cp_en_class;
- __u8 r4_lo[2];
- } fcoe;
- struct iscsi_tgt_acc_priv {
- __u8 r4[4];
- } iscsi;
- } u;
- __be32 burst_len;
- __be32 rel_off;
- __be64 r5;
- __be32 r6;
- __be32 tot_xfer_len;
-};
-
-#define S_FW_SCSI_TGT_ACC_WR_OPCODE 24
-#define M_FW_SCSI_TGT_ACC_WR_OPCODE 0xff
-#define V_FW_SCSI_TGT_ACC_WR_OPCODE(x) ((x) << S_FW_SCSI_TGT_ACC_WR_OPCODE)
-#define G_FW_SCSI_TGT_ACC_WR_OPCODE(x) \
- (((x) >> S_FW_SCSI_TGT_ACC_WR_OPCODE) & M_FW_SCSI_TGT_ACC_WR_OPCODE)
-
-#define S_FW_SCSI_TGT_ACC_WR_IMMDLEN 0
-#define M_FW_SCSI_TGT_ACC_WR_IMMDLEN 0xff
-#define V_FW_SCSI_TGT_ACC_WR_IMMDLEN(x) ((x) << S_FW_SCSI_TGT_ACC_WR_IMMDLEN)
-#define G_FW_SCSI_TGT_ACC_WR_IMMDLEN(x) \
- (((x) >> S_FW_SCSI_TGT_ACC_WR_IMMDLEN) & M_FW_SCSI_TGT_ACC_WR_IMMDLEN)
-
-#define S_FW_SCSI_TGT_ACC_WR_FLOWID 8
-#define M_FW_SCSI_TGT_ACC_WR_FLOWID 0xfffff
-#define V_FW_SCSI_TGT_ACC_WR_FLOWID(x) ((x) << S_FW_SCSI_TGT_ACC_WR_FLOWID)
-#define G_FW_SCSI_TGT_ACC_WR_FLOWID(x) \
- (((x) >> S_FW_SCSI_TGT_ACC_WR_FLOWID) & M_FW_SCSI_TGT_ACC_WR_FLOWID)
-
-#define S_FW_SCSI_TGT_ACC_WR_LEN16 0
-#define M_FW_SCSI_TGT_ACC_WR_LEN16 0xff
-#define V_FW_SCSI_TGT_ACC_WR_LEN16(x) ((x) << S_FW_SCSI_TGT_ACC_WR_LEN16)
-#define G_FW_SCSI_TGT_ACC_WR_LEN16(x) \
- (((x) >> S_FW_SCSI_TGT_ACC_WR_LEN16) & M_FW_SCSI_TGT_ACC_WR_LEN16)
-
-#define S_FW_SCSI_TGT_ACC_WR_CP_EN 6
-#define M_FW_SCSI_TGT_ACC_WR_CP_EN 0x3
-#define V_FW_SCSI_TGT_ACC_WR_CP_EN(x) ((x) << S_FW_SCSI_TGT_ACC_WR_CP_EN)
-#define G_FW_SCSI_TGT_ACC_WR_CP_EN(x) \
- (((x) >> S_FW_SCSI_TGT_ACC_WR_CP_EN) & M_FW_SCSI_TGT_ACC_WR_CP_EN)
-
-#define S_FW_SCSI_TGT_ACC_WR_CLASS 4
-#define M_FW_SCSI_TGT_ACC_WR_CLASS 0x3
-#define V_FW_SCSI_TGT_ACC_WR_CLASS(x) ((x) << S_FW_SCSI_TGT_ACC_WR_CLASS)
-#define G_FW_SCSI_TGT_ACC_WR_CLASS(x) \
- (((x) >> S_FW_SCSI_TGT_ACC_WR_CLASS) & M_FW_SCSI_TGT_ACC_WR_CLASS)
-
-struct fw_scsi_tgt_xmit_wr {
- __be32 op_immdlen;
- __be32 flowid_len16;
- __be64 cookie;
- __be16 iqid;
- __u8 auto_rsp;
- __u8 use_xfer_cnt;
- union fw_scsi_tgt_xmit_priv {
- struct fcoe_tgt_xmit_priv {
- __u8 ctl_pri;
- __u8 cp_en_class;
- __u8 r3_lo[2];
- } fcoe;
- struct iscsi_tgt_xmit_priv {
- __u8 r3[4];
- } iscsi;
- } u;
- __be32 xfer_cnt;
- __be32 r4;
- __be64 r5;
- __be32 r6;
- __be32 tot_xfer_len;
-};
-
-#define S_FW_SCSI_TGT_XMIT_WR_OPCODE 24
-#define M_FW_SCSI_TGT_XMIT_WR_OPCODE 0xff
-#define V_FW_SCSI_TGT_XMIT_WR_OPCODE(x) ((x) << S_FW_SCSI_TGT_XMIT_WR_OPCODE)
-#define G_FW_SCSI_TGT_XMIT_WR_OPCODE(x) \
- (((x) >> S_FW_SCSI_TGT_XMIT_WR_OPCODE) & M_FW_SCSI_TGT_XMIT_WR_OPCODE)
-
-#define S_FW_SCSI_TGT_XMIT_WR_IMMDLEN 0
-#define M_FW_SCSI_TGT_XMIT_WR_IMMDLEN 0xff
-#define V_FW_SCSI_TGT_XMIT_WR_IMMDLEN(x) \
- ((x) << S_FW_SCSI_TGT_XMIT_WR_IMMDLEN)
-#define G_FW_SCSI_TGT_XMIT_WR_IMMDLEN(x) \
- (((x) >> S_FW_SCSI_TGT_XMIT_WR_IMMDLEN) & M_FW_SCSI_TGT_XMIT_WR_IMMDLEN)
-
-#define S_FW_SCSI_TGT_XMIT_WR_FLOWID 8
-#define M_FW_SCSI_TGT_XMIT_WR_FLOWID 0xfffff
-#define V_FW_SCSI_TGT_XMIT_WR_FLOWID(x) ((x) << S_FW_SCSI_TGT_XMIT_WR_FLOWID)
-#define G_FW_SCSI_TGT_XMIT_WR_FLOWID(x) \
- (((x) >> S_FW_SCSI_TGT_XMIT_WR_FLOWID) & M_FW_SCSI_TGT_XMIT_WR_FLOWID)
-
-#define S_FW_SCSI_TGT_XMIT_WR_LEN16 0
-#define M_FW_SCSI_TGT_XMIT_WR_LEN16 0xff
-#define V_FW_SCSI_TGT_XMIT_WR_LEN16(x) ((x) << S_FW_SCSI_TGT_XMIT_WR_LEN16)
-#define G_FW_SCSI_TGT_XMIT_WR_LEN16(x) \
- (((x) >> S_FW_SCSI_TGT_XMIT_WR_LEN16) & M_FW_SCSI_TGT_XMIT_WR_LEN16)
-
-#define S_FW_SCSI_TGT_XMIT_WR_CP_EN 6
-#define M_FW_SCSI_TGT_XMIT_WR_CP_EN 0x3
-#define V_FW_SCSI_TGT_XMIT_WR_CP_EN(x) ((x) << S_FW_SCSI_TGT_XMIT_WR_CP_EN)
-#define G_FW_SCSI_TGT_XMIT_WR_CP_EN(x) \
- (((x) >> S_FW_SCSI_TGT_XMIT_WR_CP_EN) & M_FW_SCSI_TGT_XMIT_WR_CP_EN)
-
-#define S_FW_SCSI_TGT_XMIT_WR_CLASS 4
-#define M_FW_SCSI_TGT_XMIT_WR_CLASS 0x3
-#define V_FW_SCSI_TGT_XMIT_WR_CLASS(x) ((x) << S_FW_SCSI_TGT_XMIT_WR_CLASS)
-#define G_FW_SCSI_TGT_XMIT_WR_CLASS(x) \
- (((x) >> S_FW_SCSI_TGT_XMIT_WR_CLASS) & M_FW_SCSI_TGT_XMIT_WR_CLASS)
-
-struct fw_scsi_tgt_rsp_wr {
- __be32 op_immdlen;
- __be32 flowid_len16;
- __be64 cookie;
- __be16 iqid;
- __u8 r3[2];
- union fw_scsi_tgt_rsp_priv {
- struct fcoe_tgt_rsp_priv {
- __u8 ctl_pri;
- __u8 cp_en_class;
- __u8 r4_lo[2];
- } fcoe;
- struct iscsi_tgt_rsp_priv {
- __u8 r4[4];
- } iscsi;
- } u;
- __u8 r5[8];
-};
-
-#define S_FW_SCSI_TGT_RSP_WR_OPCODE 24
-#define M_FW_SCSI_TGT_RSP_WR_OPCODE 0xff
-#define V_FW_SCSI_TGT_RSP_WR_OPCODE(x) ((x) << S_FW_SCSI_TGT_RSP_WR_OPCODE)
-#define G_FW_SCSI_TGT_RSP_WR_OPCODE(x) \
- (((x) >> S_FW_SCSI_TGT_RSP_WR_OPCODE) & M_FW_SCSI_TGT_RSP_WR_OPCODE)
-
-#define S_FW_SCSI_TGT_RSP_WR_IMMDLEN 0
-#define M_FW_SCSI_TGT_RSP_WR_IMMDLEN 0xff
-#define V_FW_SCSI_TGT_RSP_WR_IMMDLEN(x) ((x) << S_FW_SCSI_TGT_RSP_WR_IMMDLEN)
-#define G_FW_SCSI_TGT_RSP_WR_IMMDLEN(x) \
- (((x) >> S_FW_SCSI_TGT_RSP_WR_IMMDLEN) & M_FW_SCSI_TGT_RSP_WR_IMMDLEN)
-
-#define S_FW_SCSI_TGT_RSP_WR_FLOWID 8
-#define M_FW_SCSI_TGT_RSP_WR_FLOWID 0xfffff
-#define V_FW_SCSI_TGT_RSP_WR_FLOWID(x) ((x) << S_FW_SCSI_TGT_RSP_WR_FLOWID)
-#define G_FW_SCSI_TGT_RSP_WR_FLOWID(x) \
- (((x) >> S_FW_SCSI_TGT_RSP_WR_FLOWID) & M_FW_SCSI_TGT_RSP_WR_FLOWID)
-
-#define S_FW_SCSI_TGT_RSP_WR_LEN16 0
-#define M_FW_SCSI_TGT_RSP_WR_LEN16 0xff
-#define V_FW_SCSI_TGT_RSP_WR_LEN16(x) ((x) << S_FW_SCSI_TGT_RSP_WR_LEN16)
-#define G_FW_SCSI_TGT_RSP_WR_LEN16(x) \
- (((x) >> S_FW_SCSI_TGT_RSP_WR_LEN16) & M_FW_SCSI_TGT_RSP_WR_LEN16)
-
-#define S_FW_SCSI_TGT_RSP_WR_CP_EN 6
-#define M_FW_SCSI_TGT_RSP_WR_CP_EN 0x3
-#define V_FW_SCSI_TGT_RSP_WR_CP_EN(x) ((x) << S_FW_SCSI_TGT_RSP_WR_CP_EN)
-#define G_FW_SCSI_TGT_RSP_WR_CP_EN(x) \
- (((x) >> S_FW_SCSI_TGT_RSP_WR_CP_EN) & M_FW_SCSI_TGT_RSP_WR_CP_EN)
-
-#define S_FW_SCSI_TGT_RSP_WR_CLASS 4
-#define M_FW_SCSI_TGT_RSP_WR_CLASS 0x3
-#define V_FW_SCSI_TGT_RSP_WR_CLASS(x) ((x) << S_FW_SCSI_TGT_RSP_WR_CLASS)
-#define G_FW_SCSI_TGT_RSP_WR_CLASS(x) \
- (((x) >> S_FW_SCSI_TGT_RSP_WR_CLASS) & M_FW_SCSI_TGT_RSP_WR_CLASS)
-
-struct fw_pofcoe_tcb_wr {
- __be32 op_compl;
- __be32 equiq_to_len16;
- __be64 cookie;
- __be32 tid_to_port;
- __be16 x_id;
- __be16 vlan_id;
- __be32 s_id;
- __be32 d_id;
- __be32 tag;
- __be32 xfer_len;
- __be32 r4;
- __be16 r5;
- __be16 iqid;
-};
-
-#define S_FW_POFCOE_TCB_WR_TID 12
-#define M_FW_POFCOE_TCB_WR_TID 0xfffff
-#define V_FW_POFCOE_TCB_WR_TID(x) ((x) << S_FW_POFCOE_TCB_WR_TID)
-#define G_FW_POFCOE_TCB_WR_TID(x) \
- (((x) >> S_FW_POFCOE_TCB_WR_TID) & M_FW_POFCOE_TCB_WR_TID)
-
-#define S_FW_POFCOE_TCB_WR_ALLOC 4
-#define M_FW_POFCOE_TCB_WR_ALLOC 0x1
-#define V_FW_POFCOE_TCB_WR_ALLOC(x) ((x) << S_FW_POFCOE_TCB_WR_ALLOC)
-#define G_FW_POFCOE_TCB_WR_ALLOC(x) \
- (((x) >> S_FW_POFCOE_TCB_WR_ALLOC) & M_FW_POFCOE_TCB_WR_ALLOC)
-#define F_FW_POFCOE_TCB_WR_ALLOC V_FW_POFCOE_TCB_WR_ALLOC(1U)
-
-#define S_FW_POFCOE_TCB_WR_FREE 3
-#define M_FW_POFCOE_TCB_WR_FREE 0x1
-#define V_FW_POFCOE_TCB_WR_FREE(x) ((x) << S_FW_POFCOE_TCB_WR_FREE)
-#define G_FW_POFCOE_TCB_WR_FREE(x) \
- (((x) >> S_FW_POFCOE_TCB_WR_FREE) & M_FW_POFCOE_TCB_WR_FREE)
-#define F_FW_POFCOE_TCB_WR_FREE V_FW_POFCOE_TCB_WR_FREE(1U)
-
-#define S_FW_POFCOE_TCB_WR_PORT 0
-#define M_FW_POFCOE_TCB_WR_PORT 0x7
-#define V_FW_POFCOE_TCB_WR_PORT(x) ((x) << S_FW_POFCOE_TCB_WR_PORT)
-#define G_FW_POFCOE_TCB_WR_PORT(x) \
- (((x) >> S_FW_POFCOE_TCB_WR_PORT) & M_FW_POFCOE_TCB_WR_PORT)
-
-struct fw_pofcoe_ulptx_wr {
- __be32 op_pkd;
- __be32 equiq_to_len16;
- __u64 cookie;
-};
-
-
-/******************************************************************************
- * C O M M A N D s
- *********************/
-
-/*
- * The maximum length of time, in miliseconds, that we expect any firmware
- * command to take to execute and return a reply to the host. The RESET
- * and INITIALIZE commands can take a fair amount of time to execute but
- * most execute in far less time than this maximum. This constant is used
- * by host software to determine how long to wait for a firmware command
- * reply before declaring the firmware as dead/unreachable ...
- */
-#define FW_CMD_MAX_TIMEOUT 10000
-
-/*
- * If a host driver does a HELLO and discovers that there's already a MASTER
- * selected, we may have to wait for that MASTER to finish issuing RESET,
- * configuration and INITIALIZE commands. Also, there's a possibility that
- * our own HELLO may get lost if it happens right as the MASTER is issuign a
- * RESET command, so we need to be willing to make a few retries of our HELLO.
- */
-#define FW_CMD_HELLO_TIMEOUT (3 * FW_CMD_MAX_TIMEOUT)
-#define FW_CMD_HELLO_RETRIES 3
-
-enum fw_cmd_opcodes {
- FW_LDST_CMD = 0x01,
- FW_RESET_CMD = 0x03,
- FW_HELLO_CMD = 0x04,
- FW_BYE_CMD = 0x05,
- FW_INITIALIZE_CMD = 0x06,
- FW_CAPS_CONFIG_CMD = 0x07,
- FW_PARAMS_CMD = 0x08,
- FW_PFVF_CMD = 0x09,
- FW_IQ_CMD = 0x10,
- FW_EQ_MNGT_CMD = 0x11,
- FW_EQ_ETH_CMD = 0x12,
- FW_EQ_CTRL_CMD = 0x13,
- FW_EQ_OFLD_CMD = 0x21,
- FW_VI_CMD = 0x14,
- FW_VI_MAC_CMD = 0x15,
- FW_VI_RXMODE_CMD = 0x16,
- FW_VI_ENABLE_CMD = 0x17,
- FW_VI_STATS_CMD = 0x1a,
- FW_ACL_MAC_CMD = 0x18,
- FW_ACL_VLAN_CMD = 0x19,
- FW_PORT_CMD = 0x1b,
- FW_PORT_STATS_CMD = 0x1c,
- FW_PORT_LB_STATS_CMD = 0x1d,
- FW_PORT_TRACE_CMD = 0x1e,
- FW_PORT_TRACE_MMAP_CMD = 0x1f,
- FW_RSS_IND_TBL_CMD = 0x20,
- FW_RSS_GLB_CONFIG_CMD = 0x22,
- FW_RSS_VI_CONFIG_CMD = 0x23,
- FW_SCHED_CMD = 0x24,
- FW_DEVLOG_CMD = 0x25,
- FW_WATCHDOG_CMD = 0x27,
- FW_CLIP_CMD = 0x28,
- FW_CHNET_IFACE_CMD = 0x26,
- FW_FCOE_RES_INFO_CMD = 0x31,
- FW_FCOE_LINK_CMD = 0x32,
- FW_FCOE_VNP_CMD = 0x33,
- FW_FCOE_SPARAMS_CMD = 0x35,
- FW_FCOE_STATS_CMD = 0x37,
- FW_FCOE_FCF_CMD = 0x38,
- FW_LASTC2E_CMD = 0x40,
- FW_ERROR_CMD = 0x80,
- FW_DEBUG_CMD = 0x81,
-};
-
-enum fw_cmd_cap {
- FW_CMD_CAP_PF = 0x01,
- FW_CMD_CAP_DMAQ = 0x02,
- FW_CMD_CAP_PORT = 0x04,
- FW_CMD_CAP_PORTPROMISC = 0x08,
- FW_CMD_CAP_PORTSTATS = 0x10,
- FW_CMD_CAP_VF = 0x80,
-};
-
-/*
- * Generic command header flit0
- */
-struct fw_cmd_hdr {
- __be32 hi;
- __be32 lo;
-};
-
-#define S_FW_CMD_OP 24
-#define M_FW_CMD_OP 0xff
-#define V_FW_CMD_OP(x) ((x) << S_FW_CMD_OP)
-#define G_FW_CMD_OP(x) (((x) >> S_FW_CMD_OP) & M_FW_CMD_OP)
-
-#define S_FW_CMD_REQUEST 23
-#define M_FW_CMD_REQUEST 0x1
-#define V_FW_CMD_REQUEST(x) ((x) << S_FW_CMD_REQUEST)
-#define G_FW_CMD_REQUEST(x) (((x) >> S_FW_CMD_REQUEST) & M_FW_CMD_REQUEST)
-#define F_FW_CMD_REQUEST V_FW_CMD_REQUEST(1U)
-
-#define S_FW_CMD_READ 22
-#define M_FW_CMD_READ 0x1
-#define V_FW_CMD_READ(x) ((x) << S_FW_CMD_READ)
-#define G_FW_CMD_READ(x) (((x) >> S_FW_CMD_READ) & M_FW_CMD_READ)
-#define F_FW_CMD_READ V_FW_CMD_READ(1U)
-
-#define S_FW_CMD_WRITE 21
-#define M_FW_CMD_WRITE 0x1
-#define V_FW_CMD_WRITE(x) ((x) << S_FW_CMD_WRITE)
-#define G_FW_CMD_WRITE(x) (((x) >> S_FW_CMD_WRITE) & M_FW_CMD_WRITE)
-#define F_FW_CMD_WRITE V_FW_CMD_WRITE(1U)
-
-#define S_FW_CMD_EXEC 20
-#define M_FW_CMD_EXEC 0x1
-#define V_FW_CMD_EXEC(x) ((x) << S_FW_CMD_EXEC)
-#define G_FW_CMD_EXEC(x) (((x) >> S_FW_CMD_EXEC) & M_FW_CMD_EXEC)
-#define F_FW_CMD_EXEC V_FW_CMD_EXEC(1U)
-
-#define S_FW_CMD_RAMASK 20
-#define M_FW_CMD_RAMASK 0xf
-#define V_FW_CMD_RAMASK(x) ((x) << S_FW_CMD_RAMASK)
-#define G_FW_CMD_RAMASK(x) (((x) >> S_FW_CMD_RAMASK) & M_FW_CMD_RAMASK)
-
-#define S_FW_CMD_RETVAL 8
-#define M_FW_CMD_RETVAL 0xff
-#define V_FW_CMD_RETVAL(x) ((x) << S_FW_CMD_RETVAL)
-#define G_FW_CMD_RETVAL(x) (((x) >> S_FW_CMD_RETVAL) & M_FW_CMD_RETVAL)
-
-#define S_FW_CMD_LEN16 0
-#define M_FW_CMD_LEN16 0xff
-#define V_FW_CMD_LEN16(x) ((x) << S_FW_CMD_LEN16)
-#define G_FW_CMD_LEN16(x) (((x) >> S_FW_CMD_LEN16) & M_FW_CMD_LEN16)
-
-#define FW_LEN16(fw_struct) V_FW_CMD_LEN16(sizeof(fw_struct) / 16)
-
-/*
- * address spaces
- */
-enum fw_ldst_addrspc {
- FW_LDST_ADDRSPC_FIRMWARE = 0x0001,
- FW_LDST_ADDRSPC_SGE_EGRC = 0x0008,
- FW_LDST_ADDRSPC_SGE_INGC = 0x0009,
- FW_LDST_ADDRSPC_SGE_FLMC = 0x000a,
- FW_LDST_ADDRSPC_SGE_CONMC = 0x000b,
- FW_LDST_ADDRSPC_TP_PIO = 0x0010,
- FW_LDST_ADDRSPC_TP_TM_PIO = 0x0011,
- FW_LDST_ADDRSPC_TP_MIB = 0x0012,
- FW_LDST_ADDRSPC_MDIO = 0x0018,
- FW_LDST_ADDRSPC_MPS = 0x0020,
- FW_LDST_ADDRSPC_FUNC = 0x0028,
- FW_LDST_ADDRSPC_FUNC_PCIE = 0x0029,
- FW_LDST_ADDRSPC_FUNC_I2C = 0x002A, /* legacy */
- FW_LDST_ADDRSPC_LE = 0x0030,
- FW_LDST_ADDRSPC_I2C = 0x0038,
- FW_LDST_ADDRSPC_PCIE_CFGS = 0x0040,
- FW_LDST_ADDRSPC_PCIE_DBG = 0x0041,
- FW_LDST_ADDRSPC_PCIE_PHY = 0x0042,
-};
-
-/*
- * MDIO VSC8634 register access control field
- */
-enum fw_ldst_mdio_vsc8634_aid {
- FW_LDST_MDIO_VS_STANDARD,
- FW_LDST_MDIO_VS_EXTENDED,
- FW_LDST_MDIO_VS_GPIO
-};
-
-enum fw_ldst_mps_fid {
- FW_LDST_MPS_ATRB,
- FW_LDST_MPS_RPLC
-};
-
-enum fw_ldst_func_access_ctl {
- FW_LDST_FUNC_ACC_CTL_VIID,
- FW_LDST_FUNC_ACC_CTL_FID
-};
-
-enum fw_ldst_func_mod_index {
- FW_LDST_FUNC_MPS
-};
-
-struct fw_ldst_cmd {
- __be32 op_to_addrspace;
- __be32 cycles_to_len16;
- union fw_ldst {
- struct fw_ldst_addrval {
- __be32 addr;
- __be32 val;
- } addrval;
- struct fw_ldst_idctxt {
- __be32 physid;
- __be32 msg_ctxtflush;
- __be32 ctxt_data7;
- __be32 ctxt_data6;
- __be32 ctxt_data5;
- __be32 ctxt_data4;
- __be32 ctxt_data3;
- __be32 ctxt_data2;
- __be32 ctxt_data1;
- __be32 ctxt_data0;
- } idctxt;
- struct fw_ldst_mdio {
- __be16 paddr_mmd;
- __be16 raddr;
- __be16 vctl;
- __be16 rval;
- } mdio;
- struct fw_ldst_mps {
- __be16 fid_ctl;
- __be16 rplcpf_pkd;
- __be32 rplc127_96;
- __be32 rplc95_64;
- __be32 rplc63_32;
- __be32 rplc31_0;
- __be32 atrb;
- __be16 vlan[16];
- } mps;
- struct fw_ldst_func {
- __u8 access_ctl;
- __u8 mod_index;
- __be16 ctl_id;
- __be32 offset;
- __be64 data0;
- __be64 data1;
- } func;
- struct fw_ldst_pcie {
- __u8 ctrl_to_fn;
- __u8 bnum;
- __u8 r;
- __u8 ext_r;
- __u8 select_naccess;
- __u8 pcie_fn;
- __be16 nset_pkd;
- __be32 data[12];
- } pcie;
- struct fw_ldst_i2c_deprecated {
- __u8 pid_pkd;
- __u8 base;
- __u8 boffset;
- __u8 data;
- __be32 r9;
- } i2c_deprecated;
- struct fw_ldst_i2c {
- __u8 pid;
- __u8 did;
- __u8 boffset;
- __u8 blen;
- __be32 r9;
- __u8 data[48];
- } i2c;
- struct fw_ldst_le {
- __be32 index;
- __be32 r9;
- __u8 val[33];
- __u8 r11[7];
- } le;
- } u;
-};
-
-#define S_FW_LDST_CMD_ADDRSPACE 0
-#define M_FW_LDST_CMD_ADDRSPACE 0xff
-#define V_FW_LDST_CMD_ADDRSPACE(x) ((x) << S_FW_LDST_CMD_ADDRSPACE)
-#define G_FW_LDST_CMD_ADDRSPACE(x) \
- (((x) >> S_FW_LDST_CMD_ADDRSPACE) & M_FW_LDST_CMD_ADDRSPACE)
-
-#define S_FW_LDST_CMD_CYCLES 16
-#define M_FW_LDST_CMD_CYCLES 0xffff
-#define V_FW_LDST_CMD_CYCLES(x) ((x) << S_FW_LDST_CMD_CYCLES)
-#define G_FW_LDST_CMD_CYCLES(x) \
- (((x) >> S_FW_LDST_CMD_CYCLES) & M_FW_LDST_CMD_CYCLES)
-
-#define S_FW_LDST_CMD_MSG 31
-#define M_FW_LDST_CMD_MSG 0x1
-#define V_FW_LDST_CMD_MSG(x) ((x) << S_FW_LDST_CMD_MSG)
-#define G_FW_LDST_CMD_MSG(x) \
- (((x) >> S_FW_LDST_CMD_MSG) & M_FW_LDST_CMD_MSG)
-#define F_FW_LDST_CMD_MSG V_FW_LDST_CMD_MSG(1U)
-
-#define S_FW_LDST_CMD_CTXTFLUSH 30
-#define M_FW_LDST_CMD_CTXTFLUSH 0x1
-#define V_FW_LDST_CMD_CTXTFLUSH(x) ((x) << S_FW_LDST_CMD_CTXTFLUSH)
-#define G_FW_LDST_CMD_CTXTFLUSH(x) \
- (((x) >> S_FW_LDST_CMD_CTXTFLUSH) & M_FW_LDST_CMD_CTXTFLUSH)
-#define F_FW_LDST_CMD_CTXTFLUSH V_FW_LDST_CMD_CTXTFLUSH(1U)
-
-#define S_FW_LDST_CMD_PADDR 8
-#define M_FW_LDST_CMD_PADDR 0x1f
-#define V_FW_LDST_CMD_PADDR(x) ((x) << S_FW_LDST_CMD_PADDR)
-#define G_FW_LDST_CMD_PADDR(x) \
- (((x) >> S_FW_LDST_CMD_PADDR) & M_FW_LDST_CMD_PADDR)
-
-#define S_FW_LDST_CMD_MMD 0
-#define M_FW_LDST_CMD_MMD 0x1f
-#define V_FW_LDST_CMD_MMD(x) ((x) << S_FW_LDST_CMD_MMD)
-#define G_FW_LDST_CMD_MMD(x) \
- (((x) >> S_FW_LDST_CMD_MMD) & M_FW_LDST_CMD_MMD)
-
-#define S_FW_LDST_CMD_FID 15
-#define M_FW_LDST_CMD_FID 0x1
-#define V_FW_LDST_CMD_FID(x) ((x) << S_FW_LDST_CMD_FID)
-#define G_FW_LDST_CMD_FID(x) \
- (((x) >> S_FW_LDST_CMD_FID) & M_FW_LDST_CMD_FID)
-#define F_FW_LDST_CMD_FID V_FW_LDST_CMD_FID(1U)
-
-#define S_FW_LDST_CMD_CTL 0
-#define M_FW_LDST_CMD_CTL 0x7fff
-#define V_FW_LDST_CMD_CTL(x) ((x) << S_FW_LDST_CMD_CTL)
-#define G_FW_LDST_CMD_CTL(x) \
- (((x) >> S_FW_LDST_CMD_CTL) & M_FW_LDST_CMD_CTL)
-
-#define S_FW_LDST_CMD_RPLCPF 0
-#define M_FW_LDST_CMD_RPLCPF 0xff
-#define V_FW_LDST_CMD_RPLCPF(x) ((x) << S_FW_LDST_CMD_RPLCPF)
-#define G_FW_LDST_CMD_RPLCPF(x) \
- (((x) >> S_FW_LDST_CMD_RPLCPF) & M_FW_LDST_CMD_RPLCPF)
-
-#define S_FW_LDST_CMD_CTRL 7
-#define M_FW_LDST_CMD_CTRL 0x1
-#define V_FW_LDST_CMD_CTRL(x) ((x) << S_FW_LDST_CMD_CTRL)
-#define G_FW_LDST_CMD_CTRL(x) \
- (((x) >> S_FW_LDST_CMD_CTRL) & M_FW_LDST_CMD_CTRL)
-#define F_FW_LDST_CMD_CTRL V_FW_LDST_CMD_CTRL(1U)
-
-#define S_FW_LDST_CMD_LC 4
-#define M_FW_LDST_CMD_LC 0x1
-#define V_FW_LDST_CMD_LC(x) ((x) << S_FW_LDST_CMD_LC)
-#define G_FW_LDST_CMD_LC(x) (((x) >> S_FW_LDST_CMD_LC) & M_FW_LDST_CMD_LC)
-#define F_FW_LDST_CMD_LC V_FW_LDST_CMD_LC(1U)
-
-#define S_FW_LDST_CMD_AI 3
-#define M_FW_LDST_CMD_AI 0x1
-#define V_FW_LDST_CMD_AI(x) ((x) << S_FW_LDST_CMD_AI)
-#define G_FW_LDST_CMD_AI(x) (((x) >> S_FW_LDST_CMD_AI) & M_FW_LDST_CMD_AI)
-#define F_FW_LDST_CMD_AI V_FW_LDST_CMD_AI(1U)
-
-#define S_FW_LDST_CMD_FN 0
-#define M_FW_LDST_CMD_FN 0x7
-#define V_FW_LDST_CMD_FN(x) ((x) << S_FW_LDST_CMD_FN)
-#define G_FW_LDST_CMD_FN(x) (((x) >> S_FW_LDST_CMD_FN) & M_FW_LDST_CMD_FN)
-
-#define S_FW_LDST_CMD_SELECT 4
-#define M_FW_LDST_CMD_SELECT 0xf
-#define V_FW_LDST_CMD_SELECT(x) ((x) << S_FW_LDST_CMD_SELECT)
-#define G_FW_LDST_CMD_SELECT(x) \
- (((x) >> S_FW_LDST_CMD_SELECT) & M_FW_LDST_CMD_SELECT)
-
-#define S_FW_LDST_CMD_NACCESS 0
-#define M_FW_LDST_CMD_NACCESS 0xf
-#define V_FW_LDST_CMD_NACCESS(x) ((x) << S_FW_LDST_CMD_NACCESS)
-#define G_FW_LDST_CMD_NACCESS(x) \
- (((x) >> S_FW_LDST_CMD_NACCESS) & M_FW_LDST_CMD_NACCESS)
-
-#define S_FW_LDST_CMD_NSET 14
-#define M_FW_LDST_CMD_NSET 0x3
-#define V_FW_LDST_CMD_NSET(x) ((x) << S_FW_LDST_CMD_NSET)
-#define G_FW_LDST_CMD_NSET(x) \
- (((x) >> S_FW_LDST_CMD_NSET) & M_FW_LDST_CMD_NSET)
-
-#define S_FW_LDST_CMD_PID 6
-#define M_FW_LDST_CMD_PID 0x3
-#define V_FW_LDST_CMD_PID(x) ((x) << S_FW_LDST_CMD_PID)
-#define G_FW_LDST_CMD_PID(x) \
- (((x) >> S_FW_LDST_CMD_PID) & M_FW_LDST_CMD_PID)
-
-struct fw_reset_cmd {
- __be32 op_to_write;
- __be32 retval_len16;
- __be32 val;
- __be32 halt_pkd;
-};
-
-#define S_FW_RESET_CMD_HALT 31
-#define M_FW_RESET_CMD_HALT 0x1
-#define V_FW_RESET_CMD_HALT(x) ((x) << S_FW_RESET_CMD_HALT)
-#define G_FW_RESET_CMD_HALT(x) \
- (((x) >> S_FW_RESET_CMD_HALT) & M_FW_RESET_CMD_HALT)
-#define F_FW_RESET_CMD_HALT V_FW_RESET_CMD_HALT(1U)
-
-enum {
- FW_HELLO_CMD_STAGE_OS = 0,
- FW_HELLO_CMD_STAGE_PREOS0 = 1,
- FW_HELLO_CMD_STAGE_PREOS1 = 2,
- FW_HELLO_CMD_STAGE_POSTOS = 3,
-};
-
-struct fw_hello_cmd {
- __be32 op_to_write;
- __be32 retval_len16;
- __be32 err_to_clearinit;
- __be32 fwrev;
-};
-
-#define S_FW_HELLO_CMD_ERR 31
-#define M_FW_HELLO_CMD_ERR 0x1
-#define V_FW_HELLO_CMD_ERR(x) ((x) << S_FW_HELLO_CMD_ERR)
-#define G_FW_HELLO_CMD_ERR(x) \
- (((x) >> S_FW_HELLO_CMD_ERR) & M_FW_HELLO_CMD_ERR)
-#define F_FW_HELLO_CMD_ERR V_FW_HELLO_CMD_ERR(1U)
-
-#define S_FW_HELLO_CMD_INIT 30
-#define M_FW_HELLO_CMD_INIT 0x1
-#define V_FW_HELLO_CMD_INIT(x) ((x) << S_FW_HELLO_CMD_INIT)
-#define G_FW_HELLO_CMD_INIT(x) \
- (((x) >> S_FW_HELLO_CMD_INIT) & M_FW_HELLO_CMD_INIT)
-#define F_FW_HELLO_CMD_INIT V_FW_HELLO_CMD_INIT(1U)
-
-#define S_FW_HELLO_CMD_MASTERDIS 29
-#define M_FW_HELLO_CMD_MASTERDIS 0x1
-#define V_FW_HELLO_CMD_MASTERDIS(x) ((x) << S_FW_HELLO_CMD_MASTERDIS)
-#define G_FW_HELLO_CMD_MASTERDIS(x) \
- (((x) >> S_FW_HELLO_CMD_MASTERDIS) & M_FW_HELLO_CMD_MASTERDIS)
-#define F_FW_HELLO_CMD_MASTERDIS V_FW_HELLO_CMD_MASTERDIS(1U)
-
-#define S_FW_HELLO_CMD_MASTERFORCE 28
-#define M_FW_HELLO_CMD_MASTERFORCE 0x1
-#define V_FW_HELLO_CMD_MASTERFORCE(x) ((x) << S_FW_HELLO_CMD_MASTERFORCE)
-#define G_FW_HELLO_CMD_MASTERFORCE(x) \
- (((x) >> S_FW_HELLO_CMD_MASTERFORCE) & M_FW_HELLO_CMD_MASTERFORCE)
-#define F_FW_HELLO_CMD_MASTERFORCE V_FW_HELLO_CMD_MASTERFORCE(1U)
-
-#define S_FW_HELLO_CMD_MBMASTER 24
-#define M_FW_HELLO_CMD_MBMASTER 0xf
-#define V_FW_HELLO_CMD_MBMASTER(x) ((x) << S_FW_HELLO_CMD_MBMASTER)
-#define G_FW_HELLO_CMD_MBMASTER(x) \
- (((x) >> S_FW_HELLO_CMD_MBMASTER) & M_FW_HELLO_CMD_MBMASTER)
-
-#define S_FW_HELLO_CMD_MBASYNCNOTINT 23
-#define M_FW_HELLO_CMD_MBASYNCNOTINT 0x1
-#define V_FW_HELLO_CMD_MBASYNCNOTINT(x) ((x) << S_FW_HELLO_CMD_MBASYNCNOTINT)
-#define G_FW_HELLO_CMD_MBASYNCNOTINT(x) \
- (((x) >> S_FW_HELLO_CMD_MBASYNCNOTINT) & M_FW_HELLO_CMD_MBASYNCNOTINT)
-#define F_FW_HELLO_CMD_MBASYNCNOTINT V_FW_HELLO_CMD_MBASYNCNOTINT(1U)
-
-#define S_FW_HELLO_CMD_MBASYNCNOT 20
-#define M_FW_HELLO_CMD_MBASYNCNOT 0x7
-#define V_FW_HELLO_CMD_MBASYNCNOT(x) ((x) << S_FW_HELLO_CMD_MBASYNCNOT)
-#define G_FW_HELLO_CMD_MBASYNCNOT(x) \
- (((x) >> S_FW_HELLO_CMD_MBASYNCNOT) & M_FW_HELLO_CMD_MBASYNCNOT)
-
-#define S_FW_HELLO_CMD_STAGE 17
-#define M_FW_HELLO_CMD_STAGE 0x7
-#define V_FW_HELLO_CMD_STAGE(x) ((x) << S_FW_HELLO_CMD_STAGE)
-#define G_FW_HELLO_CMD_STAGE(x) \
- (((x) >> S_FW_HELLO_CMD_STAGE) & M_FW_HELLO_CMD_STAGE)
-
-#define S_FW_HELLO_CMD_CLEARINIT 16
-#define M_FW_HELLO_CMD_CLEARINIT 0x1
-#define V_FW_HELLO_CMD_CLEARINIT(x) ((x) << S_FW_HELLO_CMD_CLEARINIT)
-#define G_FW_HELLO_CMD_CLEARINIT(x) \
- (((x) >> S_FW_HELLO_CMD_CLEARINIT) & M_FW_HELLO_CMD_CLEARINIT)
-#define F_FW_HELLO_CMD_CLEARINIT V_FW_HELLO_CMD_CLEARINIT(1U)
-
-struct fw_bye_cmd {
- __be32 op_to_write;
- __be32 retval_len16;
- __be64 r3;
-};
-
-struct fw_initialize_cmd {
- __be32 op_to_write;
- __be32 retval_len16;
- __be64 r3;
-};
-
-enum fw_caps_config_hm {
- FW_CAPS_CONFIG_HM_PCIE = 0x00000001,
- FW_CAPS_CONFIG_HM_PL = 0x00000002,
- FW_CAPS_CONFIG_HM_SGE = 0x00000004,
- FW_CAPS_CONFIG_HM_CIM = 0x00000008,
- FW_CAPS_CONFIG_HM_ULPTX = 0x00000010,
- FW_CAPS_CONFIG_HM_TP = 0x00000020,
- FW_CAPS_CONFIG_HM_ULPRX = 0x00000040,
- FW_CAPS_CONFIG_HM_PMRX = 0x00000080,
- FW_CAPS_CONFIG_HM_PMTX = 0x00000100,
- FW_CAPS_CONFIG_HM_MC = 0x00000200,
- FW_CAPS_CONFIG_HM_LE = 0x00000400,
- FW_CAPS_CONFIG_HM_MPS = 0x00000800,
- FW_CAPS_CONFIG_HM_XGMAC = 0x00001000,
- FW_CAPS_CONFIG_HM_CPLSWITCH = 0x00002000,
- FW_CAPS_CONFIG_HM_T4DBG = 0x00004000,
- FW_CAPS_CONFIG_HM_MI = 0x00008000,
- FW_CAPS_CONFIG_HM_I2CM = 0x00010000,
- FW_CAPS_CONFIG_HM_NCSI = 0x00020000,
- FW_CAPS_CONFIG_HM_SMB = 0x00040000,
- FW_CAPS_CONFIG_HM_MA = 0x00080000,
- FW_CAPS_CONFIG_HM_EDRAM = 0x00100000,
- FW_CAPS_CONFIG_HM_PMU = 0x00200000,
- FW_CAPS_CONFIG_HM_UART = 0x00400000,
- FW_CAPS_CONFIG_HM_SF = 0x00800000,
-};
-
-/*
- * The VF Register Map.
- *
- * The Scatter Gather Engine (SGE), Multiport Support module (MPS), PIO Local
- * bus module (PL) and CPU Interface Module (CIM) components are mapped via
- * the Slice to Module Map Table (see below) in the Physical Function Register
- * Map. The Mail Box Data (MBDATA) range is mapped via the PCI-E Mailbox Base
- * and Offset registers in the PF Register Map. The MBDATA base address is
- * quite constrained as it determines the Mailbox Data addresses for both PFs
- * and VFs, and therefore must fit in both the VF and PF Register Maps without
- * overlapping other registers.
- */
-#define FW_T4VF_SGE_BASE_ADDR 0x0000
-#define FW_T4VF_MPS_BASE_ADDR 0x0100
-#define FW_T4VF_PL_BASE_ADDR 0x0200
-#define FW_T4VF_MBDATA_BASE_ADDR 0x0240
-#define FW_T4VF_CIM_BASE_ADDR 0x0300
-
-#define FW_T4VF_REGMAP_START 0x0000
-#define FW_T4VF_REGMAP_SIZE 0x0400
-
-enum fw_caps_config_nbm {
- FW_CAPS_CONFIG_NBM_IPMI = 0x00000001,
- FW_CAPS_CONFIG_NBM_NCSI = 0x00000002,
-};
-
-enum fw_caps_config_link {
- FW_CAPS_CONFIG_LINK_PPP = 0x00000001,
- FW_CAPS_CONFIG_LINK_QFC = 0x00000002,
- FW_CAPS_CONFIG_LINK_DCBX = 0x00000004,
-};
-
-enum fw_caps_config_switch {
- FW_CAPS_CONFIG_SWITCH_INGRESS = 0x00000001,
- FW_CAPS_CONFIG_SWITCH_EGRESS = 0x00000002,
-};
-
-enum fw_caps_config_nic {
- FW_CAPS_CONFIG_NIC = 0x00000001,
- FW_CAPS_CONFIG_NIC_VM = 0x00000002,
- FW_CAPS_CONFIG_NIC_IDS = 0x00000004,
- FW_CAPS_CONFIG_NIC_UM = 0x00000008,
- FW_CAPS_CONFIG_NIC_UM_ISGL = 0x00000010,
- FW_CAPS_CONFIG_NIC_HASHFILTER = 0x00000020,
- FW_CAPS_CONFIG_NIC_ETHOFLD = 0x00000040,
-};
-
-enum fw_caps_config_toe {
- FW_CAPS_CONFIG_TOE = 0x00000001,
-};
-
-enum fw_caps_config_rdma {
- FW_CAPS_CONFIG_RDMA_RDDP = 0x00000001,
- FW_CAPS_CONFIG_RDMA_RDMAC = 0x00000002,
-};
-
-enum fw_caps_config_iscsi {
- FW_CAPS_CONFIG_ISCSI_INITIATOR_PDU = 0x00000001,
- FW_CAPS_CONFIG_ISCSI_TARGET_PDU = 0x00000002,
- FW_CAPS_CONFIG_ISCSI_INITIATOR_CNXOFLD = 0x00000004,
- FW_CAPS_CONFIG_ISCSI_TARGET_CNXOFLD = 0x00000008,
- FW_CAPS_CONFIG_ISCSI_INITIATOR_SSNOFLD = 0x00000010,
- FW_CAPS_CONFIG_ISCSI_TARGET_SSNOFLD = 0x00000020,
-};
-
-enum fw_caps_config_fcoe {
- FW_CAPS_CONFIG_FCOE_INITIATOR = 0x00000001,
- FW_CAPS_CONFIG_FCOE_TARGET = 0x00000002,
- FW_CAPS_CONFIG_FCOE_CTRL_OFLD = 0x00000004,
- FW_CAPS_CONFIG_POFCOE_INITIATOR = 0x00000008,
- FW_CAPS_CONFIG_POFCOE_TARGET = 0x00000010,
-};
-
-enum fw_memtype_cf {
- FW_MEMTYPE_CF_EDC0 = FW_MEMTYPE_EDC0,
- FW_MEMTYPE_CF_EDC1 = FW_MEMTYPE_EDC1,
- FW_MEMTYPE_CF_EXTMEM = FW_MEMTYPE_EXTMEM,
- FW_MEMTYPE_CF_FLASH = FW_MEMTYPE_FLASH,
- FW_MEMTYPE_CF_INTERNAL = FW_MEMTYPE_INTERNAL,
- FW_MEMTYPE_CF_EXTMEM1 = FW_MEMTYPE_EXTMEM1,
-};
-
-struct fw_caps_config_cmd {
- __be32 op_to_write;
- __be32 cfvalid_to_len16;
- __be32 r2;
- __be32 hwmbitmap;
- __be16 nbmcaps;
- __be16 linkcaps;
- __be16 switchcaps;
- __be16 r3;
- __be16 niccaps;
- __be16 toecaps;
- __be16 rdmacaps;
- __be16 r4;
- __be16 iscsicaps;
- __be16 fcoecaps;
- __be32 cfcsum;
- __be32 finiver;
- __be32 finicsum;
-};
-
-#define S_FW_CAPS_CONFIG_CMD_CFVALID 27
-#define M_FW_CAPS_CONFIG_CMD_CFVALID 0x1
-#define V_FW_CAPS_CONFIG_CMD_CFVALID(x) ((x) << S_FW_CAPS_CONFIG_CMD_CFVALID)
-#define G_FW_CAPS_CONFIG_CMD_CFVALID(x) \
- (((x) >> S_FW_CAPS_CONFIG_CMD_CFVALID) & M_FW_CAPS_CONFIG_CMD_CFVALID)
-#define F_FW_CAPS_CONFIG_CMD_CFVALID V_FW_CAPS_CONFIG_CMD_CFVALID(1U)
-
-#define S_FW_CAPS_CONFIG_CMD_MEMTYPE_CF 24
-#define M_FW_CAPS_CONFIG_CMD_MEMTYPE_CF 0x7
-#define V_FW_CAPS_CONFIG_CMD_MEMTYPE_CF(x) \
- ((x) << S_FW_CAPS_CONFIG_CMD_MEMTYPE_CF)
-#define G_FW_CAPS_CONFIG_CMD_MEMTYPE_CF(x) \
- (((x) >> S_FW_CAPS_CONFIG_CMD_MEMTYPE_CF) & \
- M_FW_CAPS_CONFIG_CMD_MEMTYPE_CF)
-
-#define S_FW_CAPS_CONFIG_CMD_MEMADDR64K_CF 16
-#define M_FW_CAPS_CONFIG_CMD_MEMADDR64K_CF 0xff
-#define V_FW_CAPS_CONFIG_CMD_MEMADDR64K_CF(x) \
- ((x) << S_FW_CAPS_CONFIG_CMD_MEMADDR64K_CF)
-#define G_FW_CAPS_CONFIG_CMD_MEMADDR64K_CF(x) \
- (((x) >> S_FW_CAPS_CONFIG_CMD_MEMADDR64K_CF) & \
- M_FW_CAPS_CONFIG_CMD_MEMADDR64K_CF)
-
-/*
- * params command mnemonics
- */
-enum fw_params_mnem {
- FW_PARAMS_MNEM_DEV = 1, /* device params */
- FW_PARAMS_MNEM_PFVF = 2, /* function params */
- FW_PARAMS_MNEM_REG = 3, /* limited register access */
- FW_PARAMS_MNEM_DMAQ = 4, /* dma queue params */
- FW_PARAMS_MNEM_LAST
-};
-
-/*
- * device parameters
- */
-enum fw_params_param_dev {
- FW_PARAMS_PARAM_DEV_CCLK = 0x00, /* chip core clock in khz */
- FW_PARAMS_PARAM_DEV_PORTVEC = 0x01, /* the port vector */
- FW_PARAMS_PARAM_DEV_NTID = 0x02, /* reads the number of TIDs
- * allocated by the device's
- * Lookup Engine
- */
- FW_PARAMS_PARAM_DEV_FLOWC_BUFFIFO_SZ = 0x03,
- FW_PARAMS_PARAM_DEV_INTFVER_NIC = 0x04,
- FW_PARAMS_PARAM_DEV_INTFVER_VNIC = 0x05,
- FW_PARAMS_PARAM_DEV_INTFVER_OFLD = 0x06,
- FW_PARAMS_PARAM_DEV_INTFVER_RI = 0x07,
- FW_PARAMS_PARAM_DEV_INTFVER_ISCSIPDU = 0x08,
- FW_PARAMS_PARAM_DEV_INTFVER_ISCSI = 0x09,
- FW_PARAMS_PARAM_DEV_INTFVER_FCOE = 0x0A,
- FW_PARAMS_PARAM_DEV_FWREV = 0x0B,
- FW_PARAMS_PARAM_DEV_TPREV = 0x0C,
- FW_PARAMS_PARAM_DEV_CF = 0x0D,
- FW_PARAMS_PARAM_DEV_BYPASS = 0x0E,
- FW_PARAMS_PARAM_DEV_PHYFW = 0x0F,
- FW_PARAMS_PARAM_DEV_LOAD = 0x10,
- FW_PARAMS_PARAM_DEV_DIAG = 0x11,
- FW_PARAMS_PARAM_DEV_UCLK = 0x12, /* uP clock in khz */
- FW_PARAMS_PARAM_DEV_MAXORDIRD_QP = 0x13, /* max supported QP IRD/ORD
- */
- FW_PARAMS_PARAM_DEV_MAXIRD_ADAPTER= 0x14,/* max supported ADAPTER IRD
- */
- FW_PARAMS_PARAM_DEV_INTFVER_FCOEPDU = 0x15,
- FW_PARAMS_PARAM_DEV_MCINIT = 0x16,
- FW_PARAMS_PARAM_DEV_ULPTX_MEMWRITE_DSGL = 0x17,
-};
-
-/*
- * physical and virtual function parameters
- */
-enum fw_params_param_pfvf {
- FW_PARAMS_PARAM_PFVF_RWXCAPS = 0x00,
- FW_PARAMS_PARAM_PFVF_ROUTE_START = 0x01,
- FW_PARAMS_PARAM_PFVF_ROUTE_END = 0x02,
- FW_PARAMS_PARAM_PFVF_CLIP_START = 0x03,
- FW_PARAMS_PARAM_PFVF_CLIP_END = 0x04,
- FW_PARAMS_PARAM_PFVF_FILTER_START = 0x05,
- FW_PARAMS_PARAM_PFVF_FILTER_END = 0x06,
- FW_PARAMS_PARAM_PFVF_SERVER_START = 0x07,
- FW_PARAMS_PARAM_PFVF_SERVER_END = 0x08,
- FW_PARAMS_PARAM_PFVF_TDDP_START = 0x09,
- FW_PARAMS_PARAM_PFVF_TDDP_END = 0x0A,
- FW_PARAMS_PARAM_PFVF_ISCSI_START = 0x0B,
- FW_PARAMS_PARAM_PFVF_ISCSI_END = 0x0C,
- FW_PARAMS_PARAM_PFVF_STAG_START = 0x0D,
- FW_PARAMS_PARAM_PFVF_STAG_END = 0x0E,
- FW_PARAMS_PARAM_PFVF_RQ_START = 0x1F,
- FW_PARAMS_PARAM_PFVF_RQ_END = 0x10,
- FW_PARAMS_PARAM_PFVF_PBL_START = 0x11,
- FW_PARAMS_PARAM_PFVF_PBL_END = 0x12,
- FW_PARAMS_PARAM_PFVF_L2T_START = 0x13,
- FW_PARAMS_PARAM_PFVF_L2T_END = 0x14,
- FW_PARAMS_PARAM_PFVF_SQRQ_START = 0x15,
- FW_PARAMS_PARAM_PFVF_SQRQ_END = 0x16,
- FW_PARAMS_PARAM_PFVF_CQ_START = 0x17,
- FW_PARAMS_PARAM_PFVF_CQ_END = 0x18,
- FW_PARAMS_PARAM_PFVF_SCHEDCLASS_ETH = 0x20,
- FW_PARAMS_PARAM_PFVF_VIID = 0x24,
- FW_PARAMS_PARAM_PFVF_CPMASK = 0x25,
- FW_PARAMS_PARAM_PFVF_OCQ_START = 0x26,
- FW_PARAMS_PARAM_PFVF_OCQ_END = 0x27,
- FW_PARAMS_PARAM_PFVF_CONM_MAP = 0x28,
- FW_PARAMS_PARAM_PFVF_IQFLINT_START = 0x29,
- FW_PARAMS_PARAM_PFVF_IQFLINT_END = 0x2A,
- FW_PARAMS_PARAM_PFVF_EQ_START = 0x2B,
- FW_PARAMS_PARAM_PFVF_EQ_END = 0x2C,
- FW_PARAMS_PARAM_PFVF_ACTIVE_FILTER_START = 0x2D,
- FW_PARAMS_PARAM_PFVF_ACTIVE_FILTER_END = 0x2E,
- FW_PARAMS_PARAM_PFVF_ETHOFLD_START = 0x2F,
- FW_PARAMS_PARAM_PFVF_ETHOFLD_END = 0x30,
- FW_PARAMS_PARAM_PFVF_CPLFW4MSG_ENCAP = 0x31
-};
-
-/*
- * dma queue parameters
- */
-enum fw_params_param_dmaq {
- FW_PARAMS_PARAM_DMAQ_IQ_DCAEN_DCACPU = 0x00,
- FW_PARAMS_PARAM_DMAQ_IQ_INTCNTTHRESH = 0x01,
- FW_PARAMS_PARAM_DMAQ_IQ_INTIDX = 0x02,
- FW_PARAMS_PARAM_DMAQ_EQ_CMPLIQID_MNGT = 0x10,
- FW_PARAMS_PARAM_DMAQ_EQ_CMPLIQID_CTRL = 0x11,
- FW_PARAMS_PARAM_DMAQ_EQ_SCHEDCLASS_ETH = 0x12,
- FW_PARAMS_PARAM_DMAQ_EQ_DCBPRIO_ETH = 0x13,
- FW_PARAMS_PARAM_DMAQ_CONM_CTXT = 0x20,
-};
-
-/*
- * dev bypass parameters; actions and modes
- */
-enum fw_params_param_dev_bypass {
-
- /* actions
- */
- FW_PARAMS_PARAM_DEV_BYPASS_PFAIL = 0x00,
- FW_PARAMS_PARAM_DEV_BYPASS_CURRENT = 0x01,
-
- /* modes
- */
- FW_PARAMS_PARAM_DEV_BYPASS_NORMAL = 0x00,
- FW_PARAMS_PARAM_DEV_BYPASS_DROP = 0x1,
- FW_PARAMS_PARAM_DEV_BYPASS_BYPASS = 0x2,
-};
-
-enum fw_params_phyfw_actions {
- FW_PARAMS_PARAM_PHYFW_DOWNLOAD = 0x00,
- FW_PARAMS_PARAM_PHYFW_VERSION = 0x01,
-};
-
-enum fw_params_param_dev_diag {
- FW_PARAM_DEV_DIAG_TMP = 0x00,
- FW_PARAM_DEV_DIAG_VDD = 0x01,
-};
-
-#define S_FW_PARAMS_MNEM 24
-#define M_FW_PARAMS_MNEM 0xff
-#define V_FW_PARAMS_MNEM(x) ((x) << S_FW_PARAMS_MNEM)
-#define G_FW_PARAMS_MNEM(x) \
- (((x) >> S_FW_PARAMS_MNEM) & M_FW_PARAMS_MNEM)
-
-#define S_FW_PARAMS_PARAM_X 16
-#define M_FW_PARAMS_PARAM_X 0xff
-#define V_FW_PARAMS_PARAM_X(x) ((x) << S_FW_PARAMS_PARAM_X)
-#define G_FW_PARAMS_PARAM_X(x) \
- (((x) >> S_FW_PARAMS_PARAM_X) & M_FW_PARAMS_PARAM_X)
-
-#define S_FW_PARAMS_PARAM_Y 8
-#define M_FW_PARAMS_PARAM_Y 0xff
-#define V_FW_PARAMS_PARAM_Y(x) ((x) << S_FW_PARAMS_PARAM_Y)
-#define G_FW_PARAMS_PARAM_Y(x) \
- (((x) >> S_FW_PARAMS_PARAM_Y) & M_FW_PARAMS_PARAM_Y)
-
-#define S_FW_PARAMS_PARAM_Z 0
-#define M_FW_PARAMS_PARAM_Z 0xff
-#define V_FW_PARAMS_PARAM_Z(x) ((x) << S_FW_PARAMS_PARAM_Z)
-#define G_FW_PARAMS_PARAM_Z(x) \
- (((x) >> S_FW_PARAMS_PARAM_Z) & M_FW_PARAMS_PARAM_Z)
-
-#define S_FW_PARAMS_PARAM_XYZ 0
-#define M_FW_PARAMS_PARAM_XYZ 0xffffff
-#define V_FW_PARAMS_PARAM_XYZ(x) ((x) << S_FW_PARAMS_PARAM_XYZ)
-#define G_FW_PARAMS_PARAM_XYZ(x) \
- (((x) >> S_FW_PARAMS_PARAM_XYZ) & M_FW_PARAMS_PARAM_XYZ)
-
-#define S_FW_PARAMS_PARAM_YZ 0
-#define M_FW_PARAMS_PARAM_YZ 0xffff
-#define V_FW_PARAMS_PARAM_YZ(x) ((x) << S_FW_PARAMS_PARAM_YZ)
-#define G_FW_PARAMS_PARAM_YZ(x) \
- (((x) >> S_FW_PARAMS_PARAM_YZ) & M_FW_PARAMS_PARAM_YZ)
-
-struct fw_params_cmd {
- __be32 op_to_vfn;
- __be32 retval_len16;
- struct fw_params_param {
- __be32 mnem;
- __be32 val;
- } param[7];
-};
-
-#define S_FW_PARAMS_CMD_PFN 8
-#define M_FW_PARAMS_CMD_PFN 0x7
-#define V_FW_PARAMS_CMD_PFN(x) ((x) << S_FW_PARAMS_CMD_PFN)
-#define G_FW_PARAMS_CMD_PFN(x) \
- (((x) >> S_FW_PARAMS_CMD_PFN) & M_FW_PARAMS_CMD_PFN)
-
-#define S_FW_PARAMS_CMD_VFN 0
-#define M_FW_PARAMS_CMD_VFN 0xff
-#define V_FW_PARAMS_CMD_VFN(x) ((x) << S_FW_PARAMS_CMD_VFN)
-#define G_FW_PARAMS_CMD_VFN(x) \
- (((x) >> S_FW_PARAMS_CMD_VFN) & M_FW_PARAMS_CMD_VFN)
-
-struct fw_pfvf_cmd {
- __be32 op_to_vfn;
- __be32 retval_len16;
- __be32 niqflint_niq;
- __be32 type_to_neq;
- __be32 tc_to_nexactf;
- __be32 r_caps_to_nethctrl;
- __be16 nricq;
- __be16 nriqp;
- __be32 r4;
-};
-
-#define S_FW_PFVF_CMD_PFN 8
-#define M_FW_PFVF_CMD_PFN 0x7
-#define V_FW_PFVF_CMD_PFN(x) ((x) << S_FW_PFVF_CMD_PFN)
-#define G_FW_PFVF_CMD_PFN(x) \
- (((x) >> S_FW_PFVF_CMD_PFN) & M_FW_PFVF_CMD_PFN)
-
-#define S_FW_PFVF_CMD_VFN 0
-#define M_FW_PFVF_CMD_VFN 0xff
-#define V_FW_PFVF_CMD_VFN(x) ((x) << S_FW_PFVF_CMD_VFN)
-#define G_FW_PFVF_CMD_VFN(x) \
- (((x) >> S_FW_PFVF_CMD_VFN) & M_FW_PFVF_CMD_VFN)
-
-#define S_FW_PFVF_CMD_NIQFLINT 20
-#define M_FW_PFVF_CMD_NIQFLINT 0xfff
-#define V_FW_PFVF_CMD_NIQFLINT(x) ((x) << S_FW_PFVF_CMD_NIQFLINT)
-#define G_FW_PFVF_CMD_NIQFLINT(x) \
- (((x) >> S_FW_PFVF_CMD_NIQFLINT) & M_FW_PFVF_CMD_NIQFLINT)
-
-#define S_FW_PFVF_CMD_NIQ 0
-#define M_FW_PFVF_CMD_NIQ 0xfffff
-#define V_FW_PFVF_CMD_NIQ(x) ((x) << S_FW_PFVF_CMD_NIQ)
-#define G_FW_PFVF_CMD_NIQ(x) \
- (((x) >> S_FW_PFVF_CMD_NIQ) & M_FW_PFVF_CMD_NIQ)
-
-#define S_FW_PFVF_CMD_TYPE 31
-#define M_FW_PFVF_CMD_TYPE 0x1
-#define V_FW_PFVF_CMD_TYPE(x) ((x) << S_FW_PFVF_CMD_TYPE)
-#define G_FW_PFVF_CMD_TYPE(x) \
- (((x) >> S_FW_PFVF_CMD_TYPE) & M_FW_PFVF_CMD_TYPE)
-#define F_FW_PFVF_CMD_TYPE V_FW_PFVF_CMD_TYPE(1U)
-
-#define S_FW_PFVF_CMD_CMASK 24
-#define M_FW_PFVF_CMD_CMASK 0xf
-#define V_FW_PFVF_CMD_CMASK(x) ((x) << S_FW_PFVF_CMD_CMASK)
-#define G_FW_PFVF_CMD_CMASK(x) \
- (((x) >> S_FW_PFVF_CMD_CMASK) & M_FW_PFVF_CMD_CMASK)
-
-#define S_FW_PFVF_CMD_PMASK 20
-#define M_FW_PFVF_CMD_PMASK 0xf
-#define V_FW_PFVF_CMD_PMASK(x) ((x) << S_FW_PFVF_CMD_PMASK)
-#define G_FW_PFVF_CMD_PMASK(x) \
- (((x) >> S_FW_PFVF_CMD_PMASK) & M_FW_PFVF_CMD_PMASK)
-
-#define S_FW_PFVF_CMD_NEQ 0
-#define M_FW_PFVF_CMD_NEQ 0xfffff
-#define V_FW_PFVF_CMD_NEQ(x) ((x) << S_FW_PFVF_CMD_NEQ)
-#define G_FW_PFVF_CMD_NEQ(x) \
- (((x) >> S_FW_PFVF_CMD_NEQ) & M_FW_PFVF_CMD_NEQ)
-
-#define S_FW_PFVF_CMD_TC 24
-#define M_FW_PFVF_CMD_TC 0xff
-#define V_FW_PFVF_CMD_TC(x) ((x) << S_FW_PFVF_CMD_TC)
-#define G_FW_PFVF_CMD_TC(x) (((x) >> S_FW_PFVF_CMD_TC) & M_FW_PFVF_CMD_TC)
-
-#define S_FW_PFVF_CMD_NVI 16
-#define M_FW_PFVF_CMD_NVI 0xff
-#define V_FW_PFVF_CMD_NVI(x) ((x) << S_FW_PFVF_CMD_NVI)
-#define G_FW_PFVF_CMD_NVI(x) \
- (((x) >> S_FW_PFVF_CMD_NVI) & M_FW_PFVF_CMD_NVI)
-
-#define S_FW_PFVF_CMD_NEXACTF 0
-#define M_FW_PFVF_CMD_NEXACTF 0xffff
-#define V_FW_PFVF_CMD_NEXACTF(x) ((x) << S_FW_PFVF_CMD_NEXACTF)
-#define G_FW_PFVF_CMD_NEXACTF(x) \
- (((x) >> S_FW_PFVF_CMD_NEXACTF) & M_FW_PFVF_CMD_NEXACTF)
-
-#define S_FW_PFVF_CMD_R_CAPS 24
-#define M_FW_PFVF_CMD_R_CAPS 0xff
-#define V_FW_PFVF_CMD_R_CAPS(x) ((x) << S_FW_PFVF_CMD_R_CAPS)
-#define G_FW_PFVF_CMD_R_CAPS(x) \
- (((x) >> S_FW_PFVF_CMD_R_CAPS) & M_FW_PFVF_CMD_R_CAPS)
-
-#define S_FW_PFVF_CMD_WX_CAPS 16
-#define M_FW_PFVF_CMD_WX_CAPS 0xff
-#define V_FW_PFVF_CMD_WX_CAPS(x) ((x) << S_FW_PFVF_CMD_WX_CAPS)
-#define G_FW_PFVF_CMD_WX_CAPS(x) \
- (((x) >> S_FW_PFVF_CMD_WX_CAPS) & M_FW_PFVF_CMD_WX_CAPS)
-
-#define S_FW_PFVF_CMD_NETHCTRL 0
-#define M_FW_PFVF_CMD_NETHCTRL 0xffff
-#define V_FW_PFVF_CMD_NETHCTRL(x) ((x) << S_FW_PFVF_CMD_NETHCTRL)
-#define G_FW_PFVF_CMD_NETHCTRL(x) \
- (((x) >> S_FW_PFVF_CMD_NETHCTRL) & M_FW_PFVF_CMD_NETHCTRL)
-
-/*
- * ingress queue type; the first 1K ingress queues can have associated 0,
- * 1 or 2 free lists and an interrupt, all other ingress queues lack these
- * capabilities
- */
-enum fw_iq_type {
- FW_IQ_TYPE_FL_INT_CAP,
- FW_IQ_TYPE_NO_FL_INT_CAP
-};
-
-struct fw_iq_cmd {
- __be32 op_to_vfn;
- __be32 alloc_to_len16;
- __be16 physiqid;
- __be16 iqid;
- __be16 fl0id;
- __be16 fl1id;
- __be32 type_to_iqandstindex;
- __be16 iqdroprss_to_iqesize;
- __be16 iqsize;
- __be64 iqaddr;
- __be32 iqns_to_fl0congen;
- __be16 fl0dcaen_to_fl0cidxfthresh;
- __be16 fl0size;
- __be64 fl0addr;
- __be32 fl1cngchmap_to_fl1congen;
- __be16 fl1dcaen_to_fl1cidxfthresh;
- __be16 fl1size;
- __be64 fl1addr;
-};
-
-#define S_FW_IQ_CMD_PFN 8
-#define M_FW_IQ_CMD_PFN 0x7
-#define V_FW_IQ_CMD_PFN(x) ((x) << S_FW_IQ_CMD_PFN)
-#define G_FW_IQ_CMD_PFN(x) (((x) >> S_FW_IQ_CMD_PFN) & M_FW_IQ_CMD_PFN)
-
-#define S_FW_IQ_CMD_VFN 0
-#define M_FW_IQ_CMD_VFN 0xff
-#define V_FW_IQ_CMD_VFN(x) ((x) << S_FW_IQ_CMD_VFN)
-#define G_FW_IQ_CMD_VFN(x) (((x) >> S_FW_IQ_CMD_VFN) & M_FW_IQ_CMD_VFN)
-
-#define S_FW_IQ_CMD_ALLOC 31
-#define M_FW_IQ_CMD_ALLOC 0x1
-#define V_FW_IQ_CMD_ALLOC(x) ((x) << S_FW_IQ_CMD_ALLOC)
-#define G_FW_IQ_CMD_ALLOC(x) \
- (((x) >> S_FW_IQ_CMD_ALLOC) & M_FW_IQ_CMD_ALLOC)
-#define F_FW_IQ_CMD_ALLOC V_FW_IQ_CMD_ALLOC(1U)
-
-#define S_FW_IQ_CMD_FREE 30
-#define M_FW_IQ_CMD_FREE 0x1
-#define V_FW_IQ_CMD_FREE(x) ((x) << S_FW_IQ_CMD_FREE)
-#define G_FW_IQ_CMD_FREE(x) (((x) >> S_FW_IQ_CMD_FREE) & M_FW_IQ_CMD_FREE)
-#define F_FW_IQ_CMD_FREE V_FW_IQ_CMD_FREE(1U)
-
-#define S_FW_IQ_CMD_MODIFY 29
-#define M_FW_IQ_CMD_MODIFY 0x1
-#define V_FW_IQ_CMD_MODIFY(x) ((x) << S_FW_IQ_CMD_MODIFY)
-#define G_FW_IQ_CMD_MODIFY(x) \
- (((x) >> S_FW_IQ_CMD_MODIFY) & M_FW_IQ_CMD_MODIFY)
-#define F_FW_IQ_CMD_MODIFY V_FW_IQ_CMD_MODIFY(1U)
-
-#define S_FW_IQ_CMD_IQSTART 28
-#define M_FW_IQ_CMD_IQSTART 0x1
-#define V_FW_IQ_CMD_IQSTART(x) ((x) << S_FW_IQ_CMD_IQSTART)
-#define G_FW_IQ_CMD_IQSTART(x) \
- (((x) >> S_FW_IQ_CMD_IQSTART) & M_FW_IQ_CMD_IQSTART)
-#define F_FW_IQ_CMD_IQSTART V_FW_IQ_CMD_IQSTART(1U)
-
-#define S_FW_IQ_CMD_IQSTOP 27
-#define M_FW_IQ_CMD_IQSTOP 0x1
-#define V_FW_IQ_CMD_IQSTOP(x) ((x) << S_FW_IQ_CMD_IQSTOP)
-#define G_FW_IQ_CMD_IQSTOP(x) \
- (((x) >> S_FW_IQ_CMD_IQSTOP) & M_FW_IQ_CMD_IQSTOP)
-#define F_FW_IQ_CMD_IQSTOP V_FW_IQ_CMD_IQSTOP(1U)
-
-#define S_FW_IQ_CMD_TYPE 29
-#define M_FW_IQ_CMD_TYPE 0x7
-#define V_FW_IQ_CMD_TYPE(x) ((x) << S_FW_IQ_CMD_TYPE)
-#define G_FW_IQ_CMD_TYPE(x) (((x) >> S_FW_IQ_CMD_TYPE) & M_FW_IQ_CMD_TYPE)
-
-#define S_FW_IQ_CMD_IQASYNCH 28
-#define M_FW_IQ_CMD_IQASYNCH 0x1
-#define V_FW_IQ_CMD_IQASYNCH(x) ((x) << S_FW_IQ_CMD_IQASYNCH)
-#define G_FW_IQ_CMD_IQASYNCH(x) \
- (((x) >> S_FW_IQ_CMD_IQASYNCH) & M_FW_IQ_CMD_IQASYNCH)
-#define F_FW_IQ_CMD_IQASYNCH V_FW_IQ_CMD_IQASYNCH(1U)
-
-#define S_FW_IQ_CMD_VIID 16
-#define M_FW_IQ_CMD_VIID 0xfff
-#define V_FW_IQ_CMD_VIID(x) ((x) << S_FW_IQ_CMD_VIID)
-#define G_FW_IQ_CMD_VIID(x) (((x) >> S_FW_IQ_CMD_VIID) & M_FW_IQ_CMD_VIID)
-
-#define S_FW_IQ_CMD_IQANDST 15
-#define M_FW_IQ_CMD_IQANDST 0x1
-#define V_FW_IQ_CMD_IQANDST(x) ((x) << S_FW_IQ_CMD_IQANDST)
-#define G_FW_IQ_CMD_IQANDST(x) \
- (((x) >> S_FW_IQ_CMD_IQANDST) & M_FW_IQ_CMD_IQANDST)
-#define F_FW_IQ_CMD_IQANDST V_FW_IQ_CMD_IQANDST(1U)
-
-#define S_FW_IQ_CMD_IQANUS 14
-#define M_FW_IQ_CMD_IQANUS 0x1
-#define V_FW_IQ_CMD_IQANUS(x) ((x) << S_FW_IQ_CMD_IQANUS)
-#define G_FW_IQ_CMD_IQANUS(x) \
- (((x) >> S_FW_IQ_CMD_IQANUS) & M_FW_IQ_CMD_IQANUS)
-#define F_FW_IQ_CMD_IQANUS V_FW_IQ_CMD_IQANUS(1U)
-
-#define S_FW_IQ_CMD_IQANUD 12
-#define M_FW_IQ_CMD_IQANUD 0x3
-#define V_FW_IQ_CMD_IQANUD(x) ((x) << S_FW_IQ_CMD_IQANUD)
-#define G_FW_IQ_CMD_IQANUD(x) \
- (((x) >> S_FW_IQ_CMD_IQANUD) & M_FW_IQ_CMD_IQANUD)
-
-#define S_FW_IQ_CMD_IQANDSTINDEX 0
-#define M_FW_IQ_CMD_IQANDSTINDEX 0xfff
-#define V_FW_IQ_CMD_IQANDSTINDEX(x) ((x) << S_FW_IQ_CMD_IQANDSTINDEX)
-#define G_FW_IQ_CMD_IQANDSTINDEX(x) \
- (((x) >> S_FW_IQ_CMD_IQANDSTINDEX) & M_FW_IQ_CMD_IQANDSTINDEX)
-
-#define S_FW_IQ_CMD_IQDROPRSS 15
-#define M_FW_IQ_CMD_IQDROPRSS 0x1
-#define V_FW_IQ_CMD_IQDROPRSS(x) ((x) << S_FW_IQ_CMD_IQDROPRSS)
-#define G_FW_IQ_CMD_IQDROPRSS(x) \
- (((x) >> S_FW_IQ_CMD_IQDROPRSS) & M_FW_IQ_CMD_IQDROPRSS)
-#define F_FW_IQ_CMD_IQDROPRSS V_FW_IQ_CMD_IQDROPRSS(1U)
-
-#define S_FW_IQ_CMD_IQGTSMODE 14
-#define M_FW_IQ_CMD_IQGTSMODE 0x1
-#define V_FW_IQ_CMD_IQGTSMODE(x) ((x) << S_FW_IQ_CMD_IQGTSMODE)
-#define G_FW_IQ_CMD_IQGTSMODE(x) \
- (((x) >> S_FW_IQ_CMD_IQGTSMODE) & M_FW_IQ_CMD_IQGTSMODE)
-#define F_FW_IQ_CMD_IQGTSMODE V_FW_IQ_CMD_IQGTSMODE(1U)
-
-#define S_FW_IQ_CMD_IQPCIECH 12
-#define M_FW_IQ_CMD_IQPCIECH 0x3
-#define V_FW_IQ_CMD_IQPCIECH(x) ((x) << S_FW_IQ_CMD_IQPCIECH)
-#define G_FW_IQ_CMD_IQPCIECH(x) \
- (((x) >> S_FW_IQ_CMD_IQPCIECH) & M_FW_IQ_CMD_IQPCIECH)
-
-#define S_FW_IQ_CMD_IQDCAEN 11
-#define M_FW_IQ_CMD_IQDCAEN 0x1
-#define V_FW_IQ_CMD_IQDCAEN(x) ((x) << S_FW_IQ_CMD_IQDCAEN)
-#define G_FW_IQ_CMD_IQDCAEN(x) \
- (((x) >> S_FW_IQ_CMD_IQDCAEN) & M_FW_IQ_CMD_IQDCAEN)
-#define F_FW_IQ_CMD_IQDCAEN V_FW_IQ_CMD_IQDCAEN(1U)
-
-#define S_FW_IQ_CMD_IQDCACPU 6
-#define M_FW_IQ_CMD_IQDCACPU 0x1f
-#define V_FW_IQ_CMD_IQDCACPU(x) ((x) << S_FW_IQ_CMD_IQDCACPU)
-#define G_FW_IQ_CMD_IQDCACPU(x) \
- (((x) >> S_FW_IQ_CMD_IQDCACPU) & M_FW_IQ_CMD_IQDCACPU)
-
-#define S_FW_IQ_CMD_IQINTCNTTHRESH 4
-#define M_FW_IQ_CMD_IQINTCNTTHRESH 0x3
-#define V_FW_IQ_CMD_IQINTCNTTHRESH(x) ((x) << S_FW_IQ_CMD_IQINTCNTTHRESH)
-#define G_FW_IQ_CMD_IQINTCNTTHRESH(x) \
- (((x) >> S_FW_IQ_CMD_IQINTCNTTHRESH) & M_FW_IQ_CMD_IQINTCNTTHRESH)
-
-#define S_FW_IQ_CMD_IQO 3
-#define M_FW_IQ_CMD_IQO 0x1
-#define V_FW_IQ_CMD_IQO(x) ((x) << S_FW_IQ_CMD_IQO)
-#define G_FW_IQ_CMD_IQO(x) (((x) >> S_FW_IQ_CMD_IQO) & M_FW_IQ_CMD_IQO)
-#define F_FW_IQ_CMD_IQO V_FW_IQ_CMD_IQO(1U)
-
-#define S_FW_IQ_CMD_IQCPRIO 2
-#define M_FW_IQ_CMD_IQCPRIO 0x1
-#define V_FW_IQ_CMD_IQCPRIO(x) ((x) << S_FW_IQ_CMD_IQCPRIO)
-#define G_FW_IQ_CMD_IQCPRIO(x) \
- (((x) >> S_FW_IQ_CMD_IQCPRIO) & M_FW_IQ_CMD_IQCPRIO)
-#define F_FW_IQ_CMD_IQCPRIO V_FW_IQ_CMD_IQCPRIO(1U)
-
-#define S_FW_IQ_CMD_IQESIZE 0
-#define M_FW_IQ_CMD_IQESIZE 0x3
-#define V_FW_IQ_CMD_IQESIZE(x) ((x) << S_FW_IQ_CMD_IQESIZE)
-#define G_FW_IQ_CMD_IQESIZE(x) \
- (((x) >> S_FW_IQ_CMD_IQESIZE) & M_FW_IQ_CMD_IQESIZE)
-
-#define S_FW_IQ_CMD_IQNS 31
-#define M_FW_IQ_CMD_IQNS 0x1
-#define V_FW_IQ_CMD_IQNS(x) ((x) << S_FW_IQ_CMD_IQNS)
-#define G_FW_IQ_CMD_IQNS(x) (((x) >> S_FW_IQ_CMD_IQNS) & M_FW_IQ_CMD_IQNS)
-#define F_FW_IQ_CMD_IQNS V_FW_IQ_CMD_IQNS(1U)
-
-#define S_FW_IQ_CMD_IQRO 30
-#define M_FW_IQ_CMD_IQRO 0x1
-#define V_FW_IQ_CMD_IQRO(x) ((x) << S_FW_IQ_CMD_IQRO)
-#define G_FW_IQ_CMD_IQRO(x) (((x) >> S_FW_IQ_CMD_IQRO) & M_FW_IQ_CMD_IQRO)
-#define F_FW_IQ_CMD_IQRO V_FW_IQ_CMD_IQRO(1U)
-
-#define S_FW_IQ_CMD_IQFLINTIQHSEN 28
-#define M_FW_IQ_CMD_IQFLINTIQHSEN 0x3
-#define V_FW_IQ_CMD_IQFLINTIQHSEN(x) ((x) << S_FW_IQ_CMD_IQFLINTIQHSEN)
-#define G_FW_IQ_CMD_IQFLINTIQHSEN(x) \
- (((x) >> S_FW_IQ_CMD_IQFLINTIQHSEN) & M_FW_IQ_CMD_IQFLINTIQHSEN)
-
-#define S_FW_IQ_CMD_IQFLINTCONGEN 27
-#define M_FW_IQ_CMD_IQFLINTCONGEN 0x1
-#define V_FW_IQ_CMD_IQFLINTCONGEN(x) ((x) << S_FW_IQ_CMD_IQFLINTCONGEN)
-#define G_FW_IQ_CMD_IQFLINTCONGEN(x) \
- (((x) >> S_FW_IQ_CMD_IQFLINTCONGEN) & M_FW_IQ_CMD_IQFLINTCONGEN)
-#define F_FW_IQ_CMD_IQFLINTCONGEN V_FW_IQ_CMD_IQFLINTCONGEN(1U)
-
-#define S_FW_IQ_CMD_IQFLINTISCSIC 26
-#define M_FW_IQ_CMD_IQFLINTISCSIC 0x1
-#define V_FW_IQ_CMD_IQFLINTISCSIC(x) ((x) << S_FW_IQ_CMD_IQFLINTISCSIC)
-#define G_FW_IQ_CMD_IQFLINTISCSIC(x) \
- (((x) >> S_FW_IQ_CMD_IQFLINTISCSIC) & M_FW_IQ_CMD_IQFLINTISCSIC)
-#define F_FW_IQ_CMD_IQFLINTISCSIC V_FW_IQ_CMD_IQFLINTISCSIC(1U)
-
-#define S_FW_IQ_CMD_FL0CNGCHMAP 20
-#define M_FW_IQ_CMD_FL0CNGCHMAP 0xf
-#define V_FW_IQ_CMD_FL0CNGCHMAP(x) ((x) << S_FW_IQ_CMD_FL0CNGCHMAP)
-#define G_FW_IQ_CMD_FL0CNGCHMAP(x) \
- (((x) >> S_FW_IQ_CMD_FL0CNGCHMAP) & M_FW_IQ_CMD_FL0CNGCHMAP)
-
-#define S_FW_IQ_CMD_FL0CACHELOCK 15
-#define M_FW_IQ_CMD_FL0CACHELOCK 0x1
-#define V_FW_IQ_CMD_FL0CACHELOCK(x) ((x) << S_FW_IQ_CMD_FL0CACHELOCK)
-#define G_FW_IQ_CMD_FL0CACHELOCK(x) \
- (((x) >> S_FW_IQ_CMD_FL0CACHELOCK) & M_FW_IQ_CMD_FL0CACHELOCK)
-#define F_FW_IQ_CMD_FL0CACHELOCK V_FW_IQ_CMD_FL0CACHELOCK(1U)
-
-#define S_FW_IQ_CMD_FL0DBP 14
-#define M_FW_IQ_CMD_FL0DBP 0x1
-#define V_FW_IQ_CMD_FL0DBP(x) ((x) << S_FW_IQ_CMD_FL0DBP)
-#define G_FW_IQ_CMD_FL0DBP(x) \
- (((x) >> S_FW_IQ_CMD_FL0DBP) & M_FW_IQ_CMD_FL0DBP)
-#define F_FW_IQ_CMD_FL0DBP V_FW_IQ_CMD_FL0DBP(1U)
-
-#define S_FW_IQ_CMD_FL0DATANS 13
-#define M_FW_IQ_CMD_FL0DATANS 0x1
-#define V_FW_IQ_CMD_FL0DATANS(x) ((x) << S_FW_IQ_CMD_FL0DATANS)
-#define G_FW_IQ_CMD_FL0DATANS(x) \
- (((x) >> S_FW_IQ_CMD_FL0DATANS) & M_FW_IQ_CMD_FL0DATANS)
-#define F_FW_IQ_CMD_FL0DATANS V_FW_IQ_CMD_FL0DATANS(1U)
-
-#define S_FW_IQ_CMD_FL0DATARO 12
-#define M_FW_IQ_CMD_FL0DATARO 0x1
-#define V_FW_IQ_CMD_FL0DATARO(x) ((x) << S_FW_IQ_CMD_FL0DATARO)
-#define G_FW_IQ_CMD_FL0DATARO(x) \
- (((x) >> S_FW_IQ_CMD_FL0DATARO) & M_FW_IQ_CMD_FL0DATARO)
-#define F_FW_IQ_CMD_FL0DATARO V_FW_IQ_CMD_FL0DATARO(1U)
-
-#define S_FW_IQ_CMD_FL0CONGCIF 11
-#define M_FW_IQ_CMD_FL0CONGCIF 0x1
-#define V_FW_IQ_CMD_FL0CONGCIF(x) ((x) << S_FW_IQ_CMD_FL0CONGCIF)
-#define G_FW_IQ_CMD_FL0CONGCIF(x) \
- (((x) >> S_FW_IQ_CMD_FL0CONGCIF) & M_FW_IQ_CMD_FL0CONGCIF)
-#define F_FW_IQ_CMD_FL0CONGCIF V_FW_IQ_CMD_FL0CONGCIF(1U)
-
-#define S_FW_IQ_CMD_FL0ONCHIP 10
-#define M_FW_IQ_CMD_FL0ONCHIP 0x1
-#define V_FW_IQ_CMD_FL0ONCHIP(x) ((x) << S_FW_IQ_CMD_FL0ONCHIP)
-#define G_FW_IQ_CMD_FL0ONCHIP(x) \
- (((x) >> S_FW_IQ_CMD_FL0ONCHIP) & M_FW_IQ_CMD_FL0ONCHIP)
-#define F_FW_IQ_CMD_FL0ONCHIP V_FW_IQ_CMD_FL0ONCHIP(1U)
-
-#define S_FW_IQ_CMD_FL0STATUSPGNS 9
-#define M_FW_IQ_CMD_FL0STATUSPGNS 0x1
-#define V_FW_IQ_CMD_FL0STATUSPGNS(x) ((x) << S_FW_IQ_CMD_FL0STATUSPGNS)
-#define G_FW_IQ_CMD_FL0STATUSPGNS(x) \
- (((x) >> S_FW_IQ_CMD_FL0STATUSPGNS) & M_FW_IQ_CMD_FL0STATUSPGNS)
-#define F_FW_IQ_CMD_FL0STATUSPGNS V_FW_IQ_CMD_FL0STATUSPGNS(1U)
-
-#define S_FW_IQ_CMD_FL0STATUSPGRO 8
-#define M_FW_IQ_CMD_FL0STATUSPGRO 0x1
-#define V_FW_IQ_CMD_FL0STATUSPGRO(x) ((x) << S_FW_IQ_CMD_FL0STATUSPGRO)
-#define G_FW_IQ_CMD_FL0STATUSPGRO(x) \
- (((x) >> S_FW_IQ_CMD_FL0STATUSPGRO) & M_FW_IQ_CMD_FL0STATUSPGRO)
-#define F_FW_IQ_CMD_FL0STATUSPGRO V_FW_IQ_CMD_FL0STATUSPGRO(1U)
-
-#define S_FW_IQ_CMD_FL0FETCHNS 7
-#define M_FW_IQ_CMD_FL0FETCHNS 0x1
-#define V_FW_IQ_CMD_FL0FETCHNS(x) ((x) << S_FW_IQ_CMD_FL0FETCHNS)
-#define G_FW_IQ_CMD_FL0FETCHNS(x) \
- (((x) >> S_FW_IQ_CMD_FL0FETCHNS) & M_FW_IQ_CMD_FL0FETCHNS)
-#define F_FW_IQ_CMD_FL0FETCHNS V_FW_IQ_CMD_FL0FETCHNS(1U)
-
-#define S_FW_IQ_CMD_FL0FETCHRO 6
-#define M_FW_IQ_CMD_FL0FETCHRO 0x1
-#define V_FW_IQ_CMD_FL0FETCHRO(x) ((x) << S_FW_IQ_CMD_FL0FETCHRO)
-#define G_FW_IQ_CMD_FL0FETCHRO(x) \
- (((x) >> S_FW_IQ_CMD_FL0FETCHRO) & M_FW_IQ_CMD_FL0FETCHRO)
-#define F_FW_IQ_CMD_FL0FETCHRO V_FW_IQ_CMD_FL0FETCHRO(1U)
-
-#define S_FW_IQ_CMD_FL0HOSTFCMODE 4
-#define M_FW_IQ_CMD_FL0HOSTFCMODE 0x3
-#define V_FW_IQ_CMD_FL0HOSTFCMODE(x) ((x) << S_FW_IQ_CMD_FL0HOSTFCMODE)
-#define G_FW_IQ_CMD_FL0HOSTFCMODE(x) \
- (((x) >> S_FW_IQ_CMD_FL0HOSTFCMODE) & M_FW_IQ_CMD_FL0HOSTFCMODE)
-
-#define S_FW_IQ_CMD_FL0CPRIO 3
-#define M_FW_IQ_CMD_FL0CPRIO 0x1
-#define V_FW_IQ_CMD_FL0CPRIO(x) ((x) << S_FW_IQ_CMD_FL0CPRIO)
-#define G_FW_IQ_CMD_FL0CPRIO(x) \
- (((x) >> S_FW_IQ_CMD_FL0CPRIO) & M_FW_IQ_CMD_FL0CPRIO)
-#define F_FW_IQ_CMD_FL0CPRIO V_FW_IQ_CMD_FL0CPRIO(1U)
-
-#define S_FW_IQ_CMD_FL0PADEN 2
-#define M_FW_IQ_CMD_FL0PADEN 0x1
-#define V_FW_IQ_CMD_FL0PADEN(x) ((x) << S_FW_IQ_CMD_FL0PADEN)
-#define G_FW_IQ_CMD_FL0PADEN(x) \
- (((x) >> S_FW_IQ_CMD_FL0PADEN) & M_FW_IQ_CMD_FL0PADEN)
-#define F_FW_IQ_CMD_FL0PADEN V_FW_IQ_CMD_FL0PADEN(1U)
-
-#define S_FW_IQ_CMD_FL0PACKEN 1
-#define M_FW_IQ_CMD_FL0PACKEN 0x1
-#define V_FW_IQ_CMD_FL0PACKEN(x) ((x) << S_FW_IQ_CMD_FL0PACKEN)
-#define G_FW_IQ_CMD_FL0PACKEN(x) \
- (((x) >> S_FW_IQ_CMD_FL0PACKEN) & M_FW_IQ_CMD_FL0PACKEN)
-#define F_FW_IQ_CMD_FL0PACKEN V_FW_IQ_CMD_FL0PACKEN(1U)
-
-#define S_FW_IQ_CMD_FL0CONGEN 0
-#define M_FW_IQ_CMD_FL0CONGEN 0x1
-#define V_FW_IQ_CMD_FL0CONGEN(x) ((x) << S_FW_IQ_CMD_FL0CONGEN)
-#define G_FW_IQ_CMD_FL0CONGEN(x) \
- (((x) >> S_FW_IQ_CMD_FL0CONGEN) & M_FW_IQ_CMD_FL0CONGEN)
-#define F_FW_IQ_CMD_FL0CONGEN V_FW_IQ_CMD_FL0CONGEN(1U)
-
-#define S_FW_IQ_CMD_FL0DCAEN 15
-#define M_FW_IQ_CMD_FL0DCAEN 0x1
-#define V_FW_IQ_CMD_FL0DCAEN(x) ((x) << S_FW_IQ_CMD_FL0DCAEN)
-#define G_FW_IQ_CMD_FL0DCAEN(x) \
- (((x) >> S_FW_IQ_CMD_FL0DCAEN) & M_FW_IQ_CMD_FL0DCAEN)
-#define F_FW_IQ_CMD_FL0DCAEN V_FW_IQ_CMD_FL0DCAEN(1U)
-
-#define S_FW_IQ_CMD_FL0DCACPU 10
-#define M_FW_IQ_CMD_FL0DCACPU 0x1f
-#define V_FW_IQ_CMD_FL0DCACPU(x) ((x) << S_FW_IQ_CMD_FL0DCACPU)
-#define G_FW_IQ_CMD_FL0DCACPU(x) \
- (((x) >> S_FW_IQ_CMD_FL0DCACPU) & M_FW_IQ_CMD_FL0DCACPU)
-
-#define S_FW_IQ_CMD_FL0FBMIN 7
-#define M_FW_IQ_CMD_FL0FBMIN 0x7
-#define V_FW_IQ_CMD_FL0FBMIN(x) ((x) << S_FW_IQ_CMD_FL0FBMIN)
-#define G_FW_IQ_CMD_FL0FBMIN(x) \
- (((x) >> S_FW_IQ_CMD_FL0FBMIN) & M_FW_IQ_CMD_FL0FBMIN)
-
-#define S_FW_IQ_CMD_FL0FBMAX 4
-#define M_FW_IQ_CMD_FL0FBMAX 0x7
-#define V_FW_IQ_CMD_FL0FBMAX(x) ((x) << S_FW_IQ_CMD_FL0FBMAX)
-#define G_FW_IQ_CMD_FL0FBMAX(x) \
- (((x) >> S_FW_IQ_CMD_FL0FBMAX) & M_FW_IQ_CMD_FL0FBMAX)
-
-#define S_FW_IQ_CMD_FL0CIDXFTHRESHO 3
-#define M_FW_IQ_CMD_FL0CIDXFTHRESHO 0x1
-#define V_FW_IQ_CMD_FL0CIDXFTHRESHO(x) ((x) << S_FW_IQ_CMD_FL0CIDXFTHRESHO)
-#define G_FW_IQ_CMD_FL0CIDXFTHRESHO(x) \
- (((x) >> S_FW_IQ_CMD_FL0CIDXFTHRESHO) & M_FW_IQ_CMD_FL0CIDXFTHRESHO)
-#define F_FW_IQ_CMD_FL0CIDXFTHRESHO V_FW_IQ_CMD_FL0CIDXFTHRESHO(1U)
-
-#define S_FW_IQ_CMD_FL0CIDXFTHRESH 0
-#define M_FW_IQ_CMD_FL0CIDXFTHRESH 0x7
-#define V_FW_IQ_CMD_FL0CIDXFTHRESH(x) ((x) << S_FW_IQ_CMD_FL0CIDXFTHRESH)
-#define G_FW_IQ_CMD_FL0CIDXFTHRESH(x) \
- (((x) >> S_FW_IQ_CMD_FL0CIDXFTHRESH) & M_FW_IQ_CMD_FL0CIDXFTHRESH)
-
-#define S_FW_IQ_CMD_FL1CNGCHMAP 20
-#define M_FW_IQ_CMD_FL1CNGCHMAP 0xf
-#define V_FW_IQ_CMD_FL1CNGCHMAP(x) ((x) << S_FW_IQ_CMD_FL1CNGCHMAP)
-#define G_FW_IQ_CMD_FL1CNGCHMAP(x) \
- (((x) >> S_FW_IQ_CMD_FL1CNGCHMAP) & M_FW_IQ_CMD_FL1CNGCHMAP)
-
-#define S_FW_IQ_CMD_FL1CACHELOCK 15
-#define M_FW_IQ_CMD_FL1CACHELOCK 0x1
-#define V_FW_IQ_CMD_FL1CACHELOCK(x) ((x) << S_FW_IQ_CMD_FL1CACHELOCK)
-#define G_FW_IQ_CMD_FL1CACHELOCK(x) \
- (((x) >> S_FW_IQ_CMD_FL1CACHELOCK) & M_FW_IQ_CMD_FL1CACHELOCK)
-#define F_FW_IQ_CMD_FL1CACHELOCK V_FW_IQ_CMD_FL1CACHELOCK(1U)
-
-#define S_FW_IQ_CMD_FL1DBP 14
-#define M_FW_IQ_CMD_FL1DBP 0x1
-#define V_FW_IQ_CMD_FL1DBP(x) ((x) << S_FW_IQ_CMD_FL1DBP)
-#define G_FW_IQ_CMD_FL1DBP(x) \
- (((x) >> S_FW_IQ_CMD_FL1DBP) & M_FW_IQ_CMD_FL1DBP)
-#define F_FW_IQ_CMD_FL1DBP V_FW_IQ_CMD_FL1DBP(1U)
-
-#define S_FW_IQ_CMD_FL1DATANS 13
-#define M_FW_IQ_CMD_FL1DATANS 0x1
-#define V_FW_IQ_CMD_FL1DATANS(x) ((x) << S_FW_IQ_CMD_FL1DATANS)
-#define G_FW_IQ_CMD_FL1DATANS(x) \
- (((x) >> S_FW_IQ_CMD_FL1DATANS) & M_FW_IQ_CMD_FL1DATANS)
-#define F_FW_IQ_CMD_FL1DATANS V_FW_IQ_CMD_FL1DATANS(1U)
-
-#define S_FW_IQ_CMD_FL1DATARO 12
-#define M_FW_IQ_CMD_FL1DATARO 0x1
-#define V_FW_IQ_CMD_FL1DATARO(x) ((x) << S_FW_IQ_CMD_FL1DATARO)
-#define G_FW_IQ_CMD_FL1DATARO(x) \
- (((x) >> S_FW_IQ_CMD_FL1DATARO) & M_FW_IQ_CMD_FL1DATARO)
-#define F_FW_IQ_CMD_FL1DATARO V_FW_IQ_CMD_FL1DATARO(1U)
-
-#define S_FW_IQ_CMD_FL1CONGCIF 11
-#define M_FW_IQ_CMD_FL1CONGCIF 0x1
-#define V_FW_IQ_CMD_FL1CONGCIF(x) ((x) << S_FW_IQ_CMD_FL1CONGCIF)
-#define G_FW_IQ_CMD_FL1CONGCIF(x) \
- (((x) >> S_FW_IQ_CMD_FL1CONGCIF) & M_FW_IQ_CMD_FL1CONGCIF)
-#define F_FW_IQ_CMD_FL1CONGCIF V_FW_IQ_CMD_FL1CONGCIF(1U)
-
-#define S_FW_IQ_CMD_FL1ONCHIP 10
-#define M_FW_IQ_CMD_FL1ONCHIP 0x1
-#define V_FW_IQ_CMD_FL1ONCHIP(x) ((x) << S_FW_IQ_CMD_FL1ONCHIP)
-#define G_FW_IQ_CMD_FL1ONCHIP(x) \
- (((x) >> S_FW_IQ_CMD_FL1ONCHIP) & M_FW_IQ_CMD_FL1ONCHIP)
-#define F_FW_IQ_CMD_FL1ONCHIP V_FW_IQ_CMD_FL1ONCHIP(1U)
-
-#define S_FW_IQ_CMD_FL1STATUSPGNS 9
-#define M_FW_IQ_CMD_FL1STATUSPGNS 0x1
-#define V_FW_IQ_CMD_FL1STATUSPGNS(x) ((x) << S_FW_IQ_CMD_FL1STATUSPGNS)
-#define G_FW_IQ_CMD_FL1STATUSPGNS(x) \
- (((x) >> S_FW_IQ_CMD_FL1STATUSPGNS) & M_FW_IQ_CMD_FL1STATUSPGNS)
-#define F_FW_IQ_CMD_FL1STATUSPGNS V_FW_IQ_CMD_FL1STATUSPGNS(1U)
-
-#define S_FW_IQ_CMD_FL1STATUSPGRO 8
-#define M_FW_IQ_CMD_FL1STATUSPGRO 0x1
-#define V_FW_IQ_CMD_FL1STATUSPGRO(x) ((x) << S_FW_IQ_CMD_FL1STATUSPGRO)
-#define G_FW_IQ_CMD_FL1STATUSPGRO(x) \
- (((x) >> S_FW_IQ_CMD_FL1STATUSPGRO) & M_FW_IQ_CMD_FL1STATUSPGRO)
-#define F_FW_IQ_CMD_FL1STATUSPGRO V_FW_IQ_CMD_FL1STATUSPGRO(1U)
-
-#define S_FW_IQ_CMD_FL1FETCHNS 7
-#define M_FW_IQ_CMD_FL1FETCHNS 0x1
-#define V_FW_IQ_CMD_FL1FETCHNS(x) ((x) << S_FW_IQ_CMD_FL1FETCHNS)
-#define G_FW_IQ_CMD_FL1FETCHNS(x) \
- (((x) >> S_FW_IQ_CMD_FL1FETCHNS) & M_FW_IQ_CMD_FL1FETCHNS)
-#define F_FW_IQ_CMD_FL1FETCHNS V_FW_IQ_CMD_FL1FETCHNS(1U)
-
-#define S_FW_IQ_CMD_FL1FETCHRO 6
-#define M_FW_IQ_CMD_FL1FETCHRO 0x1
-#define V_FW_IQ_CMD_FL1FETCHRO(x) ((x) << S_FW_IQ_CMD_FL1FETCHRO)
-#define G_FW_IQ_CMD_FL1FETCHRO(x) \
- (((x) >> S_FW_IQ_CMD_FL1FETCHRO) & M_FW_IQ_CMD_FL1FETCHRO)
-#define F_FW_IQ_CMD_FL1FETCHRO V_FW_IQ_CMD_FL1FETCHRO(1U)
-
-#define S_FW_IQ_CMD_FL1HOSTFCMODE 4
-#define M_FW_IQ_CMD_FL1HOSTFCMODE 0x3
-#define V_FW_IQ_CMD_FL1HOSTFCMODE(x) ((x) << S_FW_IQ_CMD_FL1HOSTFCMODE)
-#define G_FW_IQ_CMD_FL1HOSTFCMODE(x) \
- (((x) >> S_FW_IQ_CMD_FL1HOSTFCMODE) & M_FW_IQ_CMD_FL1HOSTFCMODE)
-
-#define S_FW_IQ_CMD_FL1CPRIO 3
-#define M_FW_IQ_CMD_FL1CPRIO 0x1
-#define V_FW_IQ_CMD_FL1CPRIO(x) ((x) << S_FW_IQ_CMD_FL1CPRIO)
-#define G_FW_IQ_CMD_FL1CPRIO(x) \
- (((x) >> S_FW_IQ_CMD_FL1CPRIO) & M_FW_IQ_CMD_FL1CPRIO)
-#define F_FW_IQ_CMD_FL1CPRIO V_FW_IQ_CMD_FL1CPRIO(1U)
-
-#define S_FW_IQ_CMD_FL1PADEN 2
-#define M_FW_IQ_CMD_FL1PADEN 0x1
-#define V_FW_IQ_CMD_FL1PADEN(x) ((x) << S_FW_IQ_CMD_FL1PADEN)
-#define G_FW_IQ_CMD_FL1PADEN(x) \
- (((x) >> S_FW_IQ_CMD_FL1PADEN) & M_FW_IQ_CMD_FL1PADEN)
-#define F_FW_IQ_CMD_FL1PADEN V_FW_IQ_CMD_FL1PADEN(1U)
-
-#define S_FW_IQ_CMD_FL1PACKEN 1
-#define M_FW_IQ_CMD_FL1PACKEN 0x1
-#define V_FW_IQ_CMD_FL1PACKEN(x) ((x) << S_FW_IQ_CMD_FL1PACKEN)
-#define G_FW_IQ_CMD_FL1PACKEN(x) \
- (((x) >> S_FW_IQ_CMD_FL1PACKEN) & M_FW_IQ_CMD_FL1PACKEN)
-#define F_FW_IQ_CMD_FL1PACKEN V_FW_IQ_CMD_FL1PACKEN(1U)
-
-#define S_FW_IQ_CMD_FL1CONGEN 0
-#define M_FW_IQ_CMD_FL1CONGEN 0x1
-#define V_FW_IQ_CMD_FL1CONGEN(x) ((x) << S_FW_IQ_CMD_FL1CONGEN)
-#define G_FW_IQ_CMD_FL1CONGEN(x) \
- (((x) >> S_FW_IQ_CMD_FL1CONGEN) & M_FW_IQ_CMD_FL1CONGEN)
-#define F_FW_IQ_CMD_FL1CONGEN V_FW_IQ_CMD_FL1CONGEN(1U)
-
-#define S_FW_IQ_CMD_FL1DCAEN 15
-#define M_FW_IQ_CMD_FL1DCAEN 0x1
-#define V_FW_IQ_CMD_FL1DCAEN(x) ((x) << S_FW_IQ_CMD_FL1DCAEN)
-#define G_FW_IQ_CMD_FL1DCAEN(x) \
- (((x) >> S_FW_IQ_CMD_FL1DCAEN) & M_FW_IQ_CMD_FL1DCAEN)
-#define F_FW_IQ_CMD_FL1DCAEN V_FW_IQ_CMD_FL1DCAEN(1U)
-
-#define S_FW_IQ_CMD_FL1DCACPU 10
-#define M_FW_IQ_CMD_FL1DCACPU 0x1f
-#define V_FW_IQ_CMD_FL1DCACPU(x) ((x) << S_FW_IQ_CMD_FL1DCACPU)
-#define G_FW_IQ_CMD_FL1DCACPU(x) \
- (((x) >> S_FW_IQ_CMD_FL1DCACPU) & M_FW_IQ_CMD_FL1DCACPU)
-
-#define S_FW_IQ_CMD_FL1FBMIN 7
-#define M_FW_IQ_CMD_FL1FBMIN 0x7
-#define V_FW_IQ_CMD_FL1FBMIN(x) ((x) << S_FW_IQ_CMD_FL1FBMIN)
-#define G_FW_IQ_CMD_FL1FBMIN(x) \
- (((x) >> S_FW_IQ_CMD_FL1FBMIN) & M_FW_IQ_CMD_FL1FBMIN)
-
-#define S_FW_IQ_CMD_FL1FBMAX 4
-#define M_FW_IQ_CMD_FL1FBMAX 0x7
-#define V_FW_IQ_CMD_FL1FBMAX(x) ((x) << S_FW_IQ_CMD_FL1FBMAX)
-#define G_FW_IQ_CMD_FL1FBMAX(x) \
- (((x) >> S_FW_IQ_CMD_FL1FBMAX) & M_FW_IQ_CMD_FL1FBMAX)
-
-#define S_FW_IQ_CMD_FL1CIDXFTHRESHO 3
-#define M_FW_IQ_CMD_FL1CIDXFTHRESHO 0x1
-#define V_FW_IQ_CMD_FL1CIDXFTHRESHO(x) ((x) << S_FW_IQ_CMD_FL1CIDXFTHRESHO)
-#define G_FW_IQ_CMD_FL1CIDXFTHRESHO(x) \
- (((x) >> S_FW_IQ_CMD_FL1CIDXFTHRESHO) & M_FW_IQ_CMD_FL1CIDXFTHRESHO)
-#define F_FW_IQ_CMD_FL1CIDXFTHRESHO V_FW_IQ_CMD_FL1CIDXFTHRESHO(1U)
-
-#define S_FW_IQ_CMD_FL1CIDXFTHRESH 0
-#define M_FW_IQ_CMD_FL1CIDXFTHRESH 0x7
-#define V_FW_IQ_CMD_FL1CIDXFTHRESH(x) ((x) << S_FW_IQ_CMD_FL1CIDXFTHRESH)
-#define G_FW_IQ_CMD_FL1CIDXFTHRESH(x) \
- (((x) >> S_FW_IQ_CMD_FL1CIDXFTHRESH) & M_FW_IQ_CMD_FL1CIDXFTHRESH)
-
-struct fw_eq_mngt_cmd {
- __be32 op_to_vfn;
- __be32 alloc_to_len16;
- __be32 cmpliqid_eqid;
- __be32 physeqid_pkd;
- __be32 fetchszm_to_iqid;
- __be32 dcaen_to_eqsize;
- __be64 eqaddr;
-};
-
-#define S_FW_EQ_MNGT_CMD_PFN 8
-#define M_FW_EQ_MNGT_CMD_PFN 0x7
-#define V_FW_EQ_MNGT_CMD_PFN(x) ((x) << S_FW_EQ_MNGT_CMD_PFN)
-#define G_FW_EQ_MNGT_CMD_PFN(x) \
- (((x) >> S_FW_EQ_MNGT_CMD_PFN) & M_FW_EQ_MNGT_CMD_PFN)
-
-#define S_FW_EQ_MNGT_CMD_VFN 0
-#define M_FW_EQ_MNGT_CMD_VFN 0xff
-#define V_FW_EQ_MNGT_CMD_VFN(x) ((x) << S_FW_EQ_MNGT_CMD_VFN)
-#define G_FW_EQ_MNGT_CMD_VFN(x) \
- (((x) >> S_FW_EQ_MNGT_CMD_VFN) & M_FW_EQ_MNGT_CMD_VFN)
-
-#define S_FW_EQ_MNGT_CMD_ALLOC 31
-#define M_FW_EQ_MNGT_CMD_ALLOC 0x1
-#define V_FW_EQ_MNGT_CMD_ALLOC(x) ((x) << S_FW_EQ_MNGT_CMD_ALLOC)
-#define G_FW_EQ_MNGT_CMD_ALLOC(x) \
- (((x) >> S_FW_EQ_MNGT_CMD_ALLOC) & M_FW_EQ_MNGT_CMD_ALLOC)
-#define F_FW_EQ_MNGT_CMD_ALLOC V_FW_EQ_MNGT_CMD_ALLOC(1U)
-
-#define S_FW_EQ_MNGT_CMD_FREE 30
-#define M_FW_EQ_MNGT_CMD_FREE 0x1
-#define V_FW_EQ_MNGT_CMD_FREE(x) ((x) << S_FW_EQ_MNGT_CMD_FREE)
-#define G_FW_EQ_MNGT_CMD_FREE(x) \
- (((x) >> S_FW_EQ_MNGT_CMD_FREE) & M_FW_EQ_MNGT_CMD_FREE)
-#define F_FW_EQ_MNGT_CMD_FREE V_FW_EQ_MNGT_CMD_FREE(1U)
-
-#define S_FW_EQ_MNGT_CMD_MODIFY 29
-#define M_FW_EQ_MNGT_CMD_MODIFY 0x1
-#define V_FW_EQ_MNGT_CMD_MODIFY(x) ((x) << S_FW_EQ_MNGT_CMD_MODIFY)
-#define G_FW_EQ_MNGT_CMD_MODIFY(x) \
- (((x) >> S_FW_EQ_MNGT_CMD_MODIFY) & M_FW_EQ_MNGT_CMD_MODIFY)
-#define F_FW_EQ_MNGT_CMD_MODIFY V_FW_EQ_MNGT_CMD_MODIFY(1U)
-
-#define S_FW_EQ_MNGT_CMD_EQSTART 28
-#define M_FW_EQ_MNGT_CMD_EQSTART 0x1
-#define V_FW_EQ_MNGT_CMD_EQSTART(x) ((x) << S_FW_EQ_MNGT_CMD_EQSTART)
-#define G_FW_EQ_MNGT_CMD_EQSTART(x) \
- (((x) >> S_FW_EQ_MNGT_CMD_EQSTART) & M_FW_EQ_MNGT_CMD_EQSTART)
-#define F_FW_EQ_MNGT_CMD_EQSTART V_FW_EQ_MNGT_CMD_EQSTART(1U)
-
-#define S_FW_EQ_MNGT_CMD_EQSTOP 27
-#define M_FW_EQ_MNGT_CMD_EQSTOP 0x1
-#define V_FW_EQ_MNGT_CMD_EQSTOP(x) ((x) << S_FW_EQ_MNGT_CMD_EQSTOP)
-#define G_FW_EQ_MNGT_CMD_EQSTOP(x) \
- (((x) >> S_FW_EQ_MNGT_CMD_EQSTOP) & M_FW_EQ_MNGT_CMD_EQSTOP)
-#define F_FW_EQ_MNGT_CMD_EQSTOP V_FW_EQ_MNGT_CMD_EQSTOP(1U)
-
-#define S_FW_EQ_MNGT_CMD_CMPLIQID 20
-#define M_FW_EQ_MNGT_CMD_CMPLIQID 0xfff
-#define V_FW_EQ_MNGT_CMD_CMPLIQID(x) ((x) << S_FW_EQ_MNGT_CMD_CMPLIQID)
-#define G_FW_EQ_MNGT_CMD_CMPLIQID(x) \
- (((x) >> S_FW_EQ_MNGT_CMD_CMPLIQID) & M_FW_EQ_MNGT_CMD_CMPLIQID)
-
-#define S_FW_EQ_MNGT_CMD_EQID 0
-#define M_FW_EQ_MNGT_CMD_EQID 0xfffff
-#define V_FW_EQ_MNGT_CMD_EQID(x) ((x) << S_FW_EQ_MNGT_CMD_EQID)
-#define G_FW_EQ_MNGT_CMD_EQID(x) \
- (((x) >> S_FW_EQ_MNGT_CMD_EQID) & M_FW_EQ_MNGT_CMD_EQID)
-
-#define S_FW_EQ_MNGT_CMD_PHYSEQID 0
-#define M_FW_EQ_MNGT_CMD_PHYSEQID 0xfffff
-#define V_FW_EQ_MNGT_CMD_PHYSEQID(x) ((x) << S_FW_EQ_MNGT_CMD_PHYSEQID)
-#define G_FW_EQ_MNGT_CMD_PHYSEQID(x) \
- (((x) >> S_FW_EQ_MNGT_CMD_PHYSEQID) & M_FW_EQ_MNGT_CMD_PHYSEQID)
-
-#define S_FW_EQ_MNGT_CMD_FETCHSZM 26
-#define M_FW_EQ_MNGT_CMD_FETCHSZM 0x1
-#define V_FW_EQ_MNGT_CMD_FETCHSZM(x) ((x) << S_FW_EQ_MNGT_CMD_FETCHSZM)
-#define G_FW_EQ_MNGT_CMD_FETCHSZM(x) \
- (((x) >> S_FW_EQ_MNGT_CMD_FETCHSZM) & M_FW_EQ_MNGT_CMD_FETCHSZM)
-#define F_FW_EQ_MNGT_CMD_FETCHSZM V_FW_EQ_MNGT_CMD_FETCHSZM(1U)
-
-#define S_FW_EQ_MNGT_CMD_STATUSPGNS 25
-#define M_FW_EQ_MNGT_CMD_STATUSPGNS 0x1
-#define V_FW_EQ_MNGT_CMD_STATUSPGNS(x) ((x) << S_FW_EQ_MNGT_CMD_STATUSPGNS)
-#define G_FW_EQ_MNGT_CMD_STATUSPGNS(x) \
- (((x) >> S_FW_EQ_MNGT_CMD_STATUSPGNS) & M_FW_EQ_MNGT_CMD_STATUSPGNS)
-#define F_FW_EQ_MNGT_CMD_STATUSPGNS V_FW_EQ_MNGT_CMD_STATUSPGNS(1U)
-
-#define S_FW_EQ_MNGT_CMD_STATUSPGRO 24
-#define M_FW_EQ_MNGT_CMD_STATUSPGRO 0x1
-#define V_FW_EQ_MNGT_CMD_STATUSPGRO(x) ((x) << S_FW_EQ_MNGT_CMD_STATUSPGRO)
-#define G_FW_EQ_MNGT_CMD_STATUSPGRO(x) \
- (((x) >> S_FW_EQ_MNGT_CMD_STATUSPGRO) & M_FW_EQ_MNGT_CMD_STATUSPGRO)
-#define F_FW_EQ_MNGT_CMD_STATUSPGRO V_FW_EQ_MNGT_CMD_STATUSPGRO(1U)
-
-#define S_FW_EQ_MNGT_CMD_FETCHNS 23
-#define M_FW_EQ_MNGT_CMD_FETCHNS 0x1
-#define V_FW_EQ_MNGT_CMD_FETCHNS(x) ((x) << S_FW_EQ_MNGT_CMD_FETCHNS)
-#define G_FW_EQ_MNGT_CMD_FETCHNS(x) \
- (((x) >> S_FW_EQ_MNGT_CMD_FETCHNS) & M_FW_EQ_MNGT_CMD_FETCHNS)
-#define F_FW_EQ_MNGT_CMD_FETCHNS V_FW_EQ_MNGT_CMD_FETCHNS(1U)
-
-#define S_FW_EQ_MNGT_CMD_FETCHRO 22
-#define M_FW_EQ_MNGT_CMD_FETCHRO 0x1
-#define V_FW_EQ_MNGT_CMD_FETCHRO(x) ((x) << S_FW_EQ_MNGT_CMD_FETCHRO)
-#define G_FW_EQ_MNGT_CMD_FETCHRO(x) \
- (((x) >> S_FW_EQ_MNGT_CMD_FETCHRO) & M_FW_EQ_MNGT_CMD_FETCHRO)
-#define F_FW_EQ_MNGT_CMD_FETCHRO V_FW_EQ_MNGT_CMD_FETCHRO(1U)
-
-#define S_FW_EQ_MNGT_CMD_HOSTFCMODE 20
-#define M_FW_EQ_MNGT_CMD_HOSTFCMODE 0x3
-#define V_FW_EQ_MNGT_CMD_HOSTFCMODE(x) ((x) << S_FW_EQ_MNGT_CMD_HOSTFCMODE)
-#define G_FW_EQ_MNGT_CMD_HOSTFCMODE(x) \
- (((x) >> S_FW_EQ_MNGT_CMD_HOSTFCMODE) & M_FW_EQ_MNGT_CMD_HOSTFCMODE)
-
-#define S_FW_EQ_MNGT_CMD_CPRIO 19
-#define M_FW_EQ_MNGT_CMD_CPRIO 0x1
-#define V_FW_EQ_MNGT_CMD_CPRIO(x) ((x) << S_FW_EQ_MNGT_CMD_CPRIO)
-#define G_FW_EQ_MNGT_CMD_CPRIO(x) \
- (((x) >> S_FW_EQ_MNGT_CMD_CPRIO) & M_FW_EQ_MNGT_CMD_CPRIO)
-#define F_FW_EQ_MNGT_CMD_CPRIO V_FW_EQ_MNGT_CMD_CPRIO(1U)
-
-#define S_FW_EQ_MNGT_CMD_ONCHIP 18
-#define M_FW_EQ_MNGT_CMD_ONCHIP 0x1
-#define V_FW_EQ_MNGT_CMD_ONCHIP(x) ((x) << S_FW_EQ_MNGT_CMD_ONCHIP)
-#define G_FW_EQ_MNGT_CMD_ONCHIP(x) \
- (((x) >> S_FW_EQ_MNGT_CMD_ONCHIP) & M_FW_EQ_MNGT_CMD_ONCHIP)
-#define F_FW_EQ_MNGT_CMD_ONCHIP V_FW_EQ_MNGT_CMD_ONCHIP(1U)
-
-#define S_FW_EQ_MNGT_CMD_PCIECHN 16
-#define M_FW_EQ_MNGT_CMD_PCIECHN 0x3
-#define V_FW_EQ_MNGT_CMD_PCIECHN(x) ((x) << S_FW_EQ_MNGT_CMD_PCIECHN)
-#define G_FW_EQ_MNGT_CMD_PCIECHN(x) \
- (((x) >> S_FW_EQ_MNGT_CMD_PCIECHN) & M_FW_EQ_MNGT_CMD_PCIECHN)
-
-#define S_FW_EQ_MNGT_CMD_IQID 0
-#define M_FW_EQ_MNGT_CMD_IQID 0xffff
-#define V_FW_EQ_MNGT_CMD_IQID(x) ((x) << S_FW_EQ_MNGT_CMD_IQID)
-#define G_FW_EQ_MNGT_CMD_IQID(x) \
- (((x) >> S_FW_EQ_MNGT_CMD_IQID) & M_FW_EQ_MNGT_CMD_IQID)
-
-#define S_FW_EQ_MNGT_CMD_DCAEN 31
-#define M_FW_EQ_MNGT_CMD_DCAEN 0x1
-#define V_FW_EQ_MNGT_CMD_DCAEN(x) ((x) << S_FW_EQ_MNGT_CMD_DCAEN)
-#define G_FW_EQ_MNGT_CMD_DCAEN(x) \
- (((x) >> S_FW_EQ_MNGT_CMD_DCAEN) & M_FW_EQ_MNGT_CMD_DCAEN)
-#define F_FW_EQ_MNGT_CMD_DCAEN V_FW_EQ_MNGT_CMD_DCAEN(1U)
-
-#define S_FW_EQ_MNGT_CMD_DCACPU 26
-#define M_FW_EQ_MNGT_CMD_DCACPU 0x1f
-#define V_FW_EQ_MNGT_CMD_DCACPU(x) ((x) << S_FW_EQ_MNGT_CMD_DCACPU)
-#define G_FW_EQ_MNGT_CMD_DCACPU(x) \
- (((x) >> S_FW_EQ_MNGT_CMD_DCACPU) & M_FW_EQ_MNGT_CMD_DCACPU)
-
-#define S_FW_EQ_MNGT_CMD_FBMIN 23
-#define M_FW_EQ_MNGT_CMD_FBMIN 0x7
-#define V_FW_EQ_MNGT_CMD_FBMIN(x) ((x) << S_FW_EQ_MNGT_CMD_FBMIN)
-#define G_FW_EQ_MNGT_CMD_FBMIN(x) \
- (((x) >> S_FW_EQ_MNGT_CMD_FBMIN) & M_FW_EQ_MNGT_CMD_FBMIN)
-
-#define S_FW_EQ_MNGT_CMD_FBMAX 20
-#define M_FW_EQ_MNGT_CMD_FBMAX 0x7
-#define V_FW_EQ_MNGT_CMD_FBMAX(x) ((x) << S_FW_EQ_MNGT_CMD_FBMAX)
-#define G_FW_EQ_MNGT_CMD_FBMAX(x) \
- (((x) >> S_FW_EQ_MNGT_CMD_FBMAX) & M_FW_EQ_MNGT_CMD_FBMAX)
-
-#define S_FW_EQ_MNGT_CMD_CIDXFTHRESHO 19
-#define M_FW_EQ_MNGT_CMD_CIDXFTHRESHO 0x1
-#define V_FW_EQ_MNGT_CMD_CIDXFTHRESHO(x) \
- ((x) << S_FW_EQ_MNGT_CMD_CIDXFTHRESHO)
-#define G_FW_EQ_MNGT_CMD_CIDXFTHRESHO(x) \
- (((x) >> S_FW_EQ_MNGT_CMD_CIDXFTHRESHO) & M_FW_EQ_MNGT_CMD_CIDXFTHRESHO)
-#define F_FW_EQ_MNGT_CMD_CIDXFTHRESHO V_FW_EQ_MNGT_CMD_CIDXFTHRESHO(1U)
-
-#define S_FW_EQ_MNGT_CMD_CIDXFTHRESH 16
-#define M_FW_EQ_MNGT_CMD_CIDXFTHRESH 0x7
-#define V_FW_EQ_MNGT_CMD_CIDXFTHRESH(x) ((x) << S_FW_EQ_MNGT_CMD_CIDXFTHRESH)
-#define G_FW_EQ_MNGT_CMD_CIDXFTHRESH(x) \
- (((x) >> S_FW_EQ_MNGT_CMD_CIDXFTHRESH) & M_FW_EQ_MNGT_CMD_CIDXFTHRESH)
-
-#define S_FW_EQ_MNGT_CMD_EQSIZE 0
-#define M_FW_EQ_MNGT_CMD_EQSIZE 0xffff
-#define V_FW_EQ_MNGT_CMD_EQSIZE(x) ((x) << S_FW_EQ_MNGT_CMD_EQSIZE)
-#define G_FW_EQ_MNGT_CMD_EQSIZE(x) \
- (((x) >> S_FW_EQ_MNGT_CMD_EQSIZE) & M_FW_EQ_MNGT_CMD_EQSIZE)
-
-struct fw_eq_eth_cmd {
- __be32 op_to_vfn;
- __be32 alloc_to_len16;
- __be32 eqid_pkd;
- __be32 physeqid_pkd;
- __be32 fetchszm_to_iqid;
- __be32 dcaen_to_eqsize;
- __be64 eqaddr;
- __be32 viid_pkd;
- __be32 r8_lo;
- __be64 r9;
-};
-
-#define S_FW_EQ_ETH_CMD_PFN 8
-#define M_FW_EQ_ETH_CMD_PFN 0x7
-#define V_FW_EQ_ETH_CMD_PFN(x) ((x) << S_FW_EQ_ETH_CMD_PFN)
-#define G_FW_EQ_ETH_CMD_PFN(x) \
- (((x) >> S_FW_EQ_ETH_CMD_PFN) & M_FW_EQ_ETH_CMD_PFN)
-
-#define S_FW_EQ_ETH_CMD_VFN 0
-#define M_FW_EQ_ETH_CMD_VFN 0xff
-#define V_FW_EQ_ETH_CMD_VFN(x) ((x) << S_FW_EQ_ETH_CMD_VFN)
-#define G_FW_EQ_ETH_CMD_VFN(x) \
- (((x) >> S_FW_EQ_ETH_CMD_VFN) & M_FW_EQ_ETH_CMD_VFN)
-
-#define S_FW_EQ_ETH_CMD_ALLOC 31
-#define M_FW_EQ_ETH_CMD_ALLOC 0x1
-#define V_FW_EQ_ETH_CMD_ALLOC(x) ((x) << S_FW_EQ_ETH_CMD_ALLOC)
-#define G_FW_EQ_ETH_CMD_ALLOC(x) \
- (((x) >> S_FW_EQ_ETH_CMD_ALLOC) & M_FW_EQ_ETH_CMD_ALLOC)
-#define F_FW_EQ_ETH_CMD_ALLOC V_FW_EQ_ETH_CMD_ALLOC(1U)
-
-#define S_FW_EQ_ETH_CMD_FREE 30
-#define M_FW_EQ_ETH_CMD_FREE 0x1
-#define V_FW_EQ_ETH_CMD_FREE(x) ((x) << S_FW_EQ_ETH_CMD_FREE)
-#define G_FW_EQ_ETH_CMD_FREE(x) \
- (((x) >> S_FW_EQ_ETH_CMD_FREE) & M_FW_EQ_ETH_CMD_FREE)
-#define F_FW_EQ_ETH_CMD_FREE V_FW_EQ_ETH_CMD_FREE(1U)
-
-#define S_FW_EQ_ETH_CMD_MODIFY 29
-#define M_FW_EQ_ETH_CMD_MODIFY 0x1
-#define V_FW_EQ_ETH_CMD_MODIFY(x) ((x) << S_FW_EQ_ETH_CMD_MODIFY)
-#define G_FW_EQ_ETH_CMD_MODIFY(x) \
- (((x) >> S_FW_EQ_ETH_CMD_MODIFY) & M_FW_EQ_ETH_CMD_MODIFY)
-#define F_FW_EQ_ETH_CMD_MODIFY V_FW_EQ_ETH_CMD_MODIFY(1U)
-
-#define S_FW_EQ_ETH_CMD_EQSTART 28
-#define M_FW_EQ_ETH_CMD_EQSTART 0x1
-#define V_FW_EQ_ETH_CMD_EQSTART(x) ((x) << S_FW_EQ_ETH_CMD_EQSTART)
-#define G_FW_EQ_ETH_CMD_EQSTART(x) \
- (((x) >> S_FW_EQ_ETH_CMD_EQSTART) & M_FW_EQ_ETH_CMD_EQSTART)
-#define F_FW_EQ_ETH_CMD_EQSTART V_FW_EQ_ETH_CMD_EQSTART(1U)
-
-#define S_FW_EQ_ETH_CMD_EQSTOP 27
-#define M_FW_EQ_ETH_CMD_EQSTOP 0x1
-#define V_FW_EQ_ETH_CMD_EQSTOP(x) ((x) << S_FW_EQ_ETH_CMD_EQSTOP)
-#define G_FW_EQ_ETH_CMD_EQSTOP(x) \
- (((x) >> S_FW_EQ_ETH_CMD_EQSTOP) & M_FW_EQ_ETH_CMD_EQSTOP)
-#define F_FW_EQ_ETH_CMD_EQSTOP V_FW_EQ_ETH_CMD_EQSTOP(1U)
-
-#define S_FW_EQ_ETH_CMD_EQID 0
-#define M_FW_EQ_ETH_CMD_EQID 0xfffff
-#define V_FW_EQ_ETH_CMD_EQID(x) ((x) << S_FW_EQ_ETH_CMD_EQID)
-#define G_FW_EQ_ETH_CMD_EQID(x) \
- (((x) >> S_FW_EQ_ETH_CMD_EQID) & M_FW_EQ_ETH_CMD_EQID)
-
-#define S_FW_EQ_ETH_CMD_PHYSEQID 0
-#define M_FW_EQ_ETH_CMD_PHYSEQID 0xfffff
-#define V_FW_EQ_ETH_CMD_PHYSEQID(x) ((x) << S_FW_EQ_ETH_CMD_PHYSEQID)
-#define G_FW_EQ_ETH_CMD_PHYSEQID(x) \
- (((x) >> S_FW_EQ_ETH_CMD_PHYSEQID) & M_FW_EQ_ETH_CMD_PHYSEQID)
-
-#define S_FW_EQ_ETH_CMD_FETCHSZM 26
-#define M_FW_EQ_ETH_CMD_FETCHSZM 0x1
-#define V_FW_EQ_ETH_CMD_FETCHSZM(x) ((x) << S_FW_EQ_ETH_CMD_FETCHSZM)
-#define G_FW_EQ_ETH_CMD_FETCHSZM(x) \
- (((x) >> S_FW_EQ_ETH_CMD_FETCHSZM) & M_FW_EQ_ETH_CMD_FETCHSZM)
-#define F_FW_EQ_ETH_CMD_FETCHSZM V_FW_EQ_ETH_CMD_FETCHSZM(1U)
-
-#define S_FW_EQ_ETH_CMD_STATUSPGNS 25
-#define M_FW_EQ_ETH_CMD_STATUSPGNS 0x1
-#define V_FW_EQ_ETH_CMD_STATUSPGNS(x) ((x) << S_FW_EQ_ETH_CMD_STATUSPGNS)
-#define G_FW_EQ_ETH_CMD_STATUSPGNS(x) \
- (((x) >> S_FW_EQ_ETH_CMD_STATUSPGNS) & M_FW_EQ_ETH_CMD_STATUSPGNS)
-#define F_FW_EQ_ETH_CMD_STATUSPGNS V_FW_EQ_ETH_CMD_STATUSPGNS(1U)
-
-#define S_FW_EQ_ETH_CMD_STATUSPGRO 24
-#define M_FW_EQ_ETH_CMD_STATUSPGRO 0x1
-#define V_FW_EQ_ETH_CMD_STATUSPGRO(x) ((x) << S_FW_EQ_ETH_CMD_STATUSPGRO)
-#define G_FW_EQ_ETH_CMD_STATUSPGRO(x) \
- (((x) >> S_FW_EQ_ETH_CMD_STATUSPGRO) & M_FW_EQ_ETH_CMD_STATUSPGRO)
-#define F_FW_EQ_ETH_CMD_STATUSPGRO V_FW_EQ_ETH_CMD_STATUSPGRO(1U)
-
-#define S_FW_EQ_ETH_CMD_FETCHNS 23
-#define M_FW_EQ_ETH_CMD_FETCHNS 0x1
-#define V_FW_EQ_ETH_CMD_FETCHNS(x) ((x) << S_FW_EQ_ETH_CMD_FETCHNS)
-#define G_FW_EQ_ETH_CMD_FETCHNS(x) \
- (((x) >> S_FW_EQ_ETH_CMD_FETCHNS) & M_FW_EQ_ETH_CMD_FETCHNS)
-#define F_FW_EQ_ETH_CMD_FETCHNS V_FW_EQ_ETH_CMD_FETCHNS(1U)
-
-#define S_FW_EQ_ETH_CMD_FETCHRO 22
-#define M_FW_EQ_ETH_CMD_FETCHRO 0x1
-#define V_FW_EQ_ETH_CMD_FETCHRO(x) ((x) << S_FW_EQ_ETH_CMD_FETCHRO)
-#define G_FW_EQ_ETH_CMD_FETCHRO(x) \
- (((x) >> S_FW_EQ_ETH_CMD_FETCHRO) & M_FW_EQ_ETH_CMD_FETCHRO)
-#define F_FW_EQ_ETH_CMD_FETCHRO V_FW_EQ_ETH_CMD_FETCHRO(1U)
-
-#define S_FW_EQ_ETH_CMD_HOSTFCMODE 20
-#define M_FW_EQ_ETH_CMD_HOSTFCMODE 0x3
-#define V_FW_EQ_ETH_CMD_HOSTFCMODE(x) ((x) << S_FW_EQ_ETH_CMD_HOSTFCMODE)
-#define G_FW_EQ_ETH_CMD_HOSTFCMODE(x) \
- (((x) >> S_FW_EQ_ETH_CMD_HOSTFCMODE) & M_FW_EQ_ETH_CMD_HOSTFCMODE)
-
-#define S_FW_EQ_ETH_CMD_CPRIO 19
-#define M_FW_EQ_ETH_CMD_CPRIO 0x1
-#define V_FW_EQ_ETH_CMD_CPRIO(x) ((x) << S_FW_EQ_ETH_CMD_CPRIO)
-#define G_FW_EQ_ETH_CMD_CPRIO(x) \
- (((x) >> S_FW_EQ_ETH_CMD_CPRIO) & M_FW_EQ_ETH_CMD_CPRIO)
-#define F_FW_EQ_ETH_CMD_CPRIO V_FW_EQ_ETH_CMD_CPRIO(1U)
-
-#define S_FW_EQ_ETH_CMD_ONCHIP 18
-#define M_FW_EQ_ETH_CMD_ONCHIP 0x1
-#define V_FW_EQ_ETH_CMD_ONCHIP(x) ((x) << S_FW_EQ_ETH_CMD_ONCHIP)
-#define G_FW_EQ_ETH_CMD_ONCHIP(x) \
- (((x) >> S_FW_EQ_ETH_CMD_ONCHIP) & M_FW_EQ_ETH_CMD_ONCHIP)
-#define F_FW_EQ_ETH_CMD_ONCHIP V_FW_EQ_ETH_CMD_ONCHIP(1U)
-
-#define S_FW_EQ_ETH_CMD_PCIECHN 16
-#define M_FW_EQ_ETH_CMD_PCIECHN 0x3
-#define V_FW_EQ_ETH_CMD_PCIECHN(x) ((x) << S_FW_EQ_ETH_CMD_PCIECHN)
-#define G_FW_EQ_ETH_CMD_PCIECHN(x) \
- (((x) >> S_FW_EQ_ETH_CMD_PCIECHN) & M_FW_EQ_ETH_CMD_PCIECHN)
-
-#define S_FW_EQ_ETH_CMD_IQID 0
-#define M_FW_EQ_ETH_CMD_IQID 0xffff
-#define V_FW_EQ_ETH_CMD_IQID(x) ((x) << S_FW_EQ_ETH_CMD_IQID)
-#define G_FW_EQ_ETH_CMD_IQID(x) \
- (((x) >> S_FW_EQ_ETH_CMD_IQID) & M_FW_EQ_ETH_CMD_IQID)
-
-#define S_FW_EQ_ETH_CMD_DCAEN 31
-#define M_FW_EQ_ETH_CMD_DCAEN 0x1
-#define V_FW_EQ_ETH_CMD_DCAEN(x) ((x) << S_FW_EQ_ETH_CMD_DCAEN)
-#define G_FW_EQ_ETH_CMD_DCAEN(x) \
- (((x) >> S_FW_EQ_ETH_CMD_DCAEN) & M_FW_EQ_ETH_CMD_DCAEN)
-#define F_FW_EQ_ETH_CMD_DCAEN V_FW_EQ_ETH_CMD_DCAEN(1U)
-
-#define S_FW_EQ_ETH_CMD_DCACPU 26
-#define M_FW_EQ_ETH_CMD_DCACPU 0x1f
-#define V_FW_EQ_ETH_CMD_DCACPU(x) ((x) << S_FW_EQ_ETH_CMD_DCACPU)
-#define G_FW_EQ_ETH_CMD_DCACPU(x) \
- (((x) >> S_FW_EQ_ETH_CMD_DCACPU) & M_FW_EQ_ETH_CMD_DCACPU)
-
-#define S_FW_EQ_ETH_CMD_FBMIN 23
-#define M_FW_EQ_ETH_CMD_FBMIN 0x7
-#define V_FW_EQ_ETH_CMD_FBMIN(x) ((x) << S_FW_EQ_ETH_CMD_FBMIN)
-#define G_FW_EQ_ETH_CMD_FBMIN(x) \
- (((x) >> S_FW_EQ_ETH_CMD_FBMIN) & M_FW_EQ_ETH_CMD_FBMIN)
-
-#define S_FW_EQ_ETH_CMD_FBMAX 20
-#define M_FW_EQ_ETH_CMD_FBMAX 0x7
-#define V_FW_EQ_ETH_CMD_FBMAX(x) ((x) << S_FW_EQ_ETH_CMD_FBMAX)
-#define G_FW_EQ_ETH_CMD_FBMAX(x) \
- (((x) >> S_FW_EQ_ETH_CMD_FBMAX) & M_FW_EQ_ETH_CMD_FBMAX)
-
-#define S_FW_EQ_ETH_CMD_CIDXFTHRESHO 19
-#define M_FW_EQ_ETH_CMD_CIDXFTHRESHO 0x1
-#define V_FW_EQ_ETH_CMD_CIDXFTHRESHO(x) ((x) << S_FW_EQ_ETH_CMD_CIDXFTHRESHO)
-#define G_FW_EQ_ETH_CMD_CIDXFTHRESHO(x) \
- (((x) >> S_FW_EQ_ETH_CMD_CIDXFTHRESHO) & M_FW_EQ_ETH_CMD_CIDXFTHRESHO)
-#define F_FW_EQ_ETH_CMD_CIDXFTHRESHO V_FW_EQ_ETH_CMD_CIDXFTHRESHO(1U)
-
-#define S_FW_EQ_ETH_CMD_CIDXFTHRESH 16
-#define M_FW_EQ_ETH_CMD_CIDXFTHRESH 0x7
-#define V_FW_EQ_ETH_CMD_CIDXFTHRESH(x) ((x) << S_FW_EQ_ETH_CMD_CIDXFTHRESH)
-#define G_FW_EQ_ETH_CMD_CIDXFTHRESH(x) \
- (((x) >> S_FW_EQ_ETH_CMD_CIDXFTHRESH) & M_FW_EQ_ETH_CMD_CIDXFTHRESH)
-
-#define S_FW_EQ_ETH_CMD_EQSIZE 0
-#define M_FW_EQ_ETH_CMD_EQSIZE 0xffff
-#define V_FW_EQ_ETH_CMD_EQSIZE(x) ((x) << S_FW_EQ_ETH_CMD_EQSIZE)
-#define G_FW_EQ_ETH_CMD_EQSIZE(x) \
- (((x) >> S_FW_EQ_ETH_CMD_EQSIZE) & M_FW_EQ_ETH_CMD_EQSIZE)
-
-#define S_FW_EQ_ETH_CMD_VIID 16
-#define M_FW_EQ_ETH_CMD_VIID 0xfff
-#define V_FW_EQ_ETH_CMD_VIID(x) ((x) << S_FW_EQ_ETH_CMD_VIID)
-#define G_FW_EQ_ETH_CMD_VIID(x) \
- (((x) >> S_FW_EQ_ETH_CMD_VIID) & M_FW_EQ_ETH_CMD_VIID)
-
-struct fw_eq_ctrl_cmd {
- __be32 op_to_vfn;
- __be32 alloc_to_len16;
- __be32 cmpliqid_eqid;
- __be32 physeqid_pkd;
- __be32 fetchszm_to_iqid;
- __be32 dcaen_to_eqsize;
- __be64 eqaddr;
-};
-
-#define S_FW_EQ_CTRL_CMD_PFN 8
-#define M_FW_EQ_CTRL_CMD_PFN 0x7
-#define V_FW_EQ_CTRL_CMD_PFN(x) ((x) << S_FW_EQ_CTRL_CMD_PFN)
-#define G_FW_EQ_CTRL_CMD_PFN(x) \
- (((x) >> S_FW_EQ_CTRL_CMD_PFN) & M_FW_EQ_CTRL_CMD_PFN)
-
-#define S_FW_EQ_CTRL_CMD_VFN 0
-#define M_FW_EQ_CTRL_CMD_VFN 0xff
-#define V_FW_EQ_CTRL_CMD_VFN(x) ((x) << S_FW_EQ_CTRL_CMD_VFN)
-#define G_FW_EQ_CTRL_CMD_VFN(x) \
- (((x) >> S_FW_EQ_CTRL_CMD_VFN) & M_FW_EQ_CTRL_CMD_VFN)
-
-#define S_FW_EQ_CTRL_CMD_ALLOC 31
-#define M_FW_EQ_CTRL_CMD_ALLOC 0x1
-#define V_FW_EQ_CTRL_CMD_ALLOC(x) ((x) << S_FW_EQ_CTRL_CMD_ALLOC)
-#define G_FW_EQ_CTRL_CMD_ALLOC(x) \
- (((x) >> S_FW_EQ_CTRL_CMD_ALLOC) & M_FW_EQ_CTRL_CMD_ALLOC)
-#define F_FW_EQ_CTRL_CMD_ALLOC V_FW_EQ_CTRL_CMD_ALLOC(1U)
-
-#define S_FW_EQ_CTRL_CMD_FREE 30
-#define M_FW_EQ_CTRL_CMD_FREE 0x1
-#define V_FW_EQ_CTRL_CMD_FREE(x) ((x) << S_FW_EQ_CTRL_CMD_FREE)
-#define G_FW_EQ_CTRL_CMD_FREE(x) \
- (((x) >> S_FW_EQ_CTRL_CMD_FREE) & M_FW_EQ_CTRL_CMD_FREE)
-#define F_FW_EQ_CTRL_CMD_FREE V_FW_EQ_CTRL_CMD_FREE(1U)
-
-#define S_FW_EQ_CTRL_CMD_MODIFY 29
-#define M_FW_EQ_CTRL_CMD_MODIFY 0x1
-#define V_FW_EQ_CTRL_CMD_MODIFY(x) ((x) << S_FW_EQ_CTRL_CMD_MODIFY)
-#define G_FW_EQ_CTRL_CMD_MODIFY(x) \
- (((x) >> S_FW_EQ_CTRL_CMD_MODIFY) & M_FW_EQ_CTRL_CMD_MODIFY)
-#define F_FW_EQ_CTRL_CMD_MODIFY V_FW_EQ_CTRL_CMD_MODIFY(1U)
-
-#define S_FW_EQ_CTRL_CMD_EQSTART 28
-#define M_FW_EQ_CTRL_CMD_EQSTART 0x1
-#define V_FW_EQ_CTRL_CMD_EQSTART(x) ((x) << S_FW_EQ_CTRL_CMD_EQSTART)
-#define G_FW_EQ_CTRL_CMD_EQSTART(x) \
- (((x) >> S_FW_EQ_CTRL_CMD_EQSTART) & M_FW_EQ_CTRL_CMD_EQSTART)
-#define F_FW_EQ_CTRL_CMD_EQSTART V_FW_EQ_CTRL_CMD_EQSTART(1U)
-
-#define S_FW_EQ_CTRL_CMD_EQSTOP 27
-#define M_FW_EQ_CTRL_CMD_EQSTOP 0x1
-#define V_FW_EQ_CTRL_CMD_EQSTOP(x) ((x) << S_FW_EQ_CTRL_CMD_EQSTOP)
-#define G_FW_EQ_CTRL_CMD_EQSTOP(x) \
- (((x) >> S_FW_EQ_CTRL_CMD_EQSTOP) & M_FW_EQ_CTRL_CMD_EQSTOP)
-#define F_FW_EQ_CTRL_CMD_EQSTOP V_FW_EQ_CTRL_CMD_EQSTOP(1U)
-
-#define S_FW_EQ_CTRL_CMD_CMPLIQID 20
-#define M_FW_EQ_CTRL_CMD_CMPLIQID 0xfff
-#define V_FW_EQ_CTRL_CMD_CMPLIQID(x) ((x) << S_FW_EQ_CTRL_CMD_CMPLIQID)
-#define G_FW_EQ_CTRL_CMD_CMPLIQID(x) \
- (((x) >> S_FW_EQ_CTRL_CMD_CMPLIQID) & M_FW_EQ_CTRL_CMD_CMPLIQID)
-
-#define S_FW_EQ_CTRL_CMD_EQID 0
-#define M_FW_EQ_CTRL_CMD_EQID 0xfffff
-#define V_FW_EQ_CTRL_CMD_EQID(x) ((x) << S_FW_EQ_CTRL_CMD_EQID)
-#define G_FW_EQ_CTRL_CMD_EQID(x) \
- (((x) >> S_FW_EQ_CTRL_CMD_EQID) & M_FW_EQ_CTRL_CMD_EQID)
-
-#define S_FW_EQ_CTRL_CMD_PHYSEQID 0
-#define M_FW_EQ_CTRL_CMD_PHYSEQID 0xfffff
-#define V_FW_EQ_CTRL_CMD_PHYSEQID(x) ((x) << S_FW_EQ_CTRL_CMD_PHYSEQID)
-#define G_FW_EQ_CTRL_CMD_PHYSEQID(x) \
- (((x) >> S_FW_EQ_CTRL_CMD_PHYSEQID) & M_FW_EQ_CTRL_CMD_PHYSEQID)
-
-#define S_FW_EQ_CTRL_CMD_FETCHSZM 26
-#define M_FW_EQ_CTRL_CMD_FETCHSZM 0x1
-#define V_FW_EQ_CTRL_CMD_FETCHSZM(x) ((x) << S_FW_EQ_CTRL_CMD_FETCHSZM)
-#define G_FW_EQ_CTRL_CMD_FETCHSZM(x) \
- (((x) >> S_FW_EQ_CTRL_CMD_FETCHSZM) & M_FW_EQ_CTRL_CMD_FETCHSZM)
-#define F_FW_EQ_CTRL_CMD_FETCHSZM V_FW_EQ_CTRL_CMD_FETCHSZM(1U)
-
-#define S_FW_EQ_CTRL_CMD_STATUSPGNS 25
-#define M_FW_EQ_CTRL_CMD_STATUSPGNS 0x1
-#define V_FW_EQ_CTRL_CMD_STATUSPGNS(x) ((x) << S_FW_EQ_CTRL_CMD_STATUSPGNS)
-#define G_FW_EQ_CTRL_CMD_STATUSPGNS(x) \
- (((x) >> S_FW_EQ_CTRL_CMD_STATUSPGNS) & M_FW_EQ_CTRL_CMD_STATUSPGNS)
-#define F_FW_EQ_CTRL_CMD_STATUSPGNS V_FW_EQ_CTRL_CMD_STATUSPGNS(1U)
-
-#define S_FW_EQ_CTRL_CMD_STATUSPGRO 24
-#define M_FW_EQ_CTRL_CMD_STATUSPGRO 0x1
-#define V_FW_EQ_CTRL_CMD_STATUSPGRO(x) ((x) << S_FW_EQ_CTRL_CMD_STATUSPGRO)
-#define G_FW_EQ_CTRL_CMD_STATUSPGRO(x) \
- (((x) >> S_FW_EQ_CTRL_CMD_STATUSPGRO) & M_FW_EQ_CTRL_CMD_STATUSPGRO)
-#define F_FW_EQ_CTRL_CMD_STATUSPGRO V_FW_EQ_CTRL_CMD_STATUSPGRO(1U)
-
-#define S_FW_EQ_CTRL_CMD_FETCHNS 23
-#define M_FW_EQ_CTRL_CMD_FETCHNS 0x1
-#define V_FW_EQ_CTRL_CMD_FETCHNS(x) ((x) << S_FW_EQ_CTRL_CMD_FETCHNS)
-#define G_FW_EQ_CTRL_CMD_FETCHNS(x) \
- (((x) >> S_FW_EQ_CTRL_CMD_FETCHNS) & M_FW_EQ_CTRL_CMD_FETCHNS)
-#define F_FW_EQ_CTRL_CMD_FETCHNS V_FW_EQ_CTRL_CMD_FETCHNS(1U)
-
-#define S_FW_EQ_CTRL_CMD_FETCHRO 22
-#define M_FW_EQ_CTRL_CMD_FETCHRO 0x1
-#define V_FW_EQ_CTRL_CMD_FETCHRO(x) ((x) << S_FW_EQ_CTRL_CMD_FETCHRO)
-#define G_FW_EQ_CTRL_CMD_FETCHRO(x) \
- (((x) >> S_FW_EQ_CTRL_CMD_FETCHRO) & M_FW_EQ_CTRL_CMD_FETCHRO)
-#define F_FW_EQ_CTRL_CMD_FETCHRO V_FW_EQ_CTRL_CMD_FETCHRO(1U)
-
-#define S_FW_EQ_CTRL_CMD_HOSTFCMODE 20
-#define M_FW_EQ_CTRL_CMD_HOSTFCMODE 0x3
-#define V_FW_EQ_CTRL_CMD_HOSTFCMODE(x) ((x) << S_FW_EQ_CTRL_CMD_HOSTFCMODE)
-#define G_FW_EQ_CTRL_CMD_HOSTFCMODE(x) \
- (((x) >> S_FW_EQ_CTRL_CMD_HOSTFCMODE) & M_FW_EQ_CTRL_CMD_HOSTFCMODE)
-
-#define S_FW_EQ_CTRL_CMD_CPRIO 19
-#define M_FW_EQ_CTRL_CMD_CPRIO 0x1
-#define V_FW_EQ_CTRL_CMD_CPRIO(x) ((x) << S_FW_EQ_CTRL_CMD_CPRIO)
-#define G_FW_EQ_CTRL_CMD_CPRIO(x) \
- (((x) >> S_FW_EQ_CTRL_CMD_CPRIO) & M_FW_EQ_CTRL_CMD_CPRIO)
-#define F_FW_EQ_CTRL_CMD_CPRIO V_FW_EQ_CTRL_CMD_CPRIO(1U)
-
-#define S_FW_EQ_CTRL_CMD_ONCHIP 18
-#define M_FW_EQ_CTRL_CMD_ONCHIP 0x1
-#define V_FW_EQ_CTRL_CMD_ONCHIP(x) ((x) << S_FW_EQ_CTRL_CMD_ONCHIP)
-#define G_FW_EQ_CTRL_CMD_ONCHIP(x) \
- (((x) >> S_FW_EQ_CTRL_CMD_ONCHIP) & M_FW_EQ_CTRL_CMD_ONCHIP)
-#define F_FW_EQ_CTRL_CMD_ONCHIP V_FW_EQ_CTRL_CMD_ONCHIP(1U)
-
-#define S_FW_EQ_CTRL_CMD_PCIECHN 16
-#define M_FW_EQ_CTRL_CMD_PCIECHN 0x3
-#define V_FW_EQ_CTRL_CMD_PCIECHN(x) ((x) << S_FW_EQ_CTRL_CMD_PCIECHN)
-#define G_FW_EQ_CTRL_CMD_PCIECHN(x) \
- (((x) >> S_FW_EQ_CTRL_CMD_PCIECHN) & M_FW_EQ_CTRL_CMD_PCIECHN)
-
-#define S_FW_EQ_CTRL_CMD_IQID 0
-#define M_FW_EQ_CTRL_CMD_IQID 0xffff
-#define V_FW_EQ_CTRL_CMD_IQID(x) ((x) << S_FW_EQ_CTRL_CMD_IQID)
-#define G_FW_EQ_CTRL_CMD_IQID(x) \
- (((x) >> S_FW_EQ_CTRL_CMD_IQID) & M_FW_EQ_CTRL_CMD_IQID)
-
-#define S_FW_EQ_CTRL_CMD_DCAEN 31
-#define M_FW_EQ_CTRL_CMD_DCAEN 0x1
-#define V_FW_EQ_CTRL_CMD_DCAEN(x) ((x) << S_FW_EQ_CTRL_CMD_DCAEN)
-#define G_FW_EQ_CTRL_CMD_DCAEN(x) \
- (((x) >> S_FW_EQ_CTRL_CMD_DCAEN) & M_FW_EQ_CTRL_CMD_DCAEN)
-#define F_FW_EQ_CTRL_CMD_DCAEN V_FW_EQ_CTRL_CMD_DCAEN(1U)
-
-#define S_FW_EQ_CTRL_CMD_DCACPU 26
-#define M_FW_EQ_CTRL_CMD_DCACPU 0x1f
-#define V_FW_EQ_CTRL_CMD_DCACPU(x) ((x) << S_FW_EQ_CTRL_CMD_DCACPU)
-#define G_FW_EQ_CTRL_CMD_DCACPU(x) \
- (((x) >> S_FW_EQ_CTRL_CMD_DCACPU) & M_FW_EQ_CTRL_CMD_DCACPU)
-
-#define S_FW_EQ_CTRL_CMD_FBMIN 23
-#define M_FW_EQ_CTRL_CMD_FBMIN 0x7
-#define V_FW_EQ_CTRL_CMD_FBMIN(x) ((x) << S_FW_EQ_CTRL_CMD_FBMIN)
-#define G_FW_EQ_CTRL_CMD_FBMIN(x) \
- (((x) >> S_FW_EQ_CTRL_CMD_FBMIN) & M_FW_EQ_CTRL_CMD_FBMIN)
-
-#define S_FW_EQ_CTRL_CMD_FBMAX 20
-#define M_FW_EQ_CTRL_CMD_FBMAX 0x7
-#define V_FW_EQ_CTRL_CMD_FBMAX(x) ((x) << S_FW_EQ_CTRL_CMD_FBMAX)
-#define G_FW_EQ_CTRL_CMD_FBMAX(x) \
- (((x) >> S_FW_EQ_CTRL_CMD_FBMAX) & M_FW_EQ_CTRL_CMD_FBMAX)
-
-#define S_FW_EQ_CTRL_CMD_CIDXFTHRESHO 19
-#define M_FW_EQ_CTRL_CMD_CIDXFTHRESHO 0x1
-#define V_FW_EQ_CTRL_CMD_CIDXFTHRESHO(x) \
- ((x) << S_FW_EQ_CTRL_CMD_CIDXFTHRESHO)
-#define G_FW_EQ_CTRL_CMD_CIDXFTHRESHO(x) \
- (((x) >> S_FW_EQ_CTRL_CMD_CIDXFTHRESHO) & M_FW_EQ_CTRL_CMD_CIDXFTHRESHO)
-#define F_FW_EQ_CTRL_CMD_CIDXFTHRESHO V_FW_EQ_CTRL_CMD_CIDXFTHRESHO(1U)
-
-#define S_FW_EQ_CTRL_CMD_CIDXFTHRESH 16
-#define M_FW_EQ_CTRL_CMD_CIDXFTHRESH 0x7
-#define V_FW_EQ_CTRL_CMD_CIDXFTHRESH(x) ((x) << S_FW_EQ_CTRL_CMD_CIDXFTHRESH)
-#define G_FW_EQ_CTRL_CMD_CIDXFTHRESH(x) \
- (((x) >> S_FW_EQ_CTRL_CMD_CIDXFTHRESH) & M_FW_EQ_CTRL_CMD_CIDXFTHRESH)
-
-#define S_FW_EQ_CTRL_CMD_EQSIZE 0
-#define M_FW_EQ_CTRL_CMD_EQSIZE 0xffff
-#define V_FW_EQ_CTRL_CMD_EQSIZE(x) ((x) << S_FW_EQ_CTRL_CMD_EQSIZE)
-#define G_FW_EQ_CTRL_CMD_EQSIZE(x) \
- (((x) >> S_FW_EQ_CTRL_CMD_EQSIZE) & M_FW_EQ_CTRL_CMD_EQSIZE)
-
-struct fw_eq_ofld_cmd {
- __be32 op_to_vfn;
- __be32 alloc_to_len16;
- __be32 eqid_pkd;
- __be32 physeqid_pkd;
- __be32 fetchszm_to_iqid;
- __be32 dcaen_to_eqsize;
- __be64 eqaddr;
-};
-
-#define S_FW_EQ_OFLD_CMD_PFN 8
-#define M_FW_EQ_OFLD_CMD_PFN 0x7
-#define V_FW_EQ_OFLD_CMD_PFN(x) ((x) << S_FW_EQ_OFLD_CMD_PFN)
-#define G_FW_EQ_OFLD_CMD_PFN(x) \
- (((x) >> S_FW_EQ_OFLD_CMD_PFN) & M_FW_EQ_OFLD_CMD_PFN)
-
-#define S_FW_EQ_OFLD_CMD_VFN 0
-#define M_FW_EQ_OFLD_CMD_VFN 0xff
-#define V_FW_EQ_OFLD_CMD_VFN(x) ((x) << S_FW_EQ_OFLD_CMD_VFN)
-#define G_FW_EQ_OFLD_CMD_VFN(x) \
- (((x) >> S_FW_EQ_OFLD_CMD_VFN) & M_FW_EQ_OFLD_CMD_VFN)
-
-#define S_FW_EQ_OFLD_CMD_ALLOC 31
-#define M_FW_EQ_OFLD_CMD_ALLOC 0x1
-#define V_FW_EQ_OFLD_CMD_ALLOC(x) ((x) << S_FW_EQ_OFLD_CMD_ALLOC)
-#define G_FW_EQ_OFLD_CMD_ALLOC(x) \
- (((x) >> S_FW_EQ_OFLD_CMD_ALLOC) & M_FW_EQ_OFLD_CMD_ALLOC)
-#define F_FW_EQ_OFLD_CMD_ALLOC V_FW_EQ_OFLD_CMD_ALLOC(1U)
-
-#define S_FW_EQ_OFLD_CMD_FREE 30
-#define M_FW_EQ_OFLD_CMD_FREE 0x1
-#define V_FW_EQ_OFLD_CMD_FREE(x) ((x) << S_FW_EQ_OFLD_CMD_FREE)
-#define G_FW_EQ_OFLD_CMD_FREE(x) \
- (((x) >> S_FW_EQ_OFLD_CMD_FREE) & M_FW_EQ_OFLD_CMD_FREE)
-#define F_FW_EQ_OFLD_CMD_FREE V_FW_EQ_OFLD_CMD_FREE(1U)
-
-#define S_FW_EQ_OFLD_CMD_MODIFY 29
-#define M_FW_EQ_OFLD_CMD_MODIFY 0x1
-#define V_FW_EQ_OFLD_CMD_MODIFY(x) ((x) << S_FW_EQ_OFLD_CMD_MODIFY)
-#define G_FW_EQ_OFLD_CMD_MODIFY(x) \
- (((x) >> S_FW_EQ_OFLD_CMD_MODIFY) & M_FW_EQ_OFLD_CMD_MODIFY)
-#define F_FW_EQ_OFLD_CMD_MODIFY V_FW_EQ_OFLD_CMD_MODIFY(1U)
-
-#define S_FW_EQ_OFLD_CMD_EQSTART 28
-#define M_FW_EQ_OFLD_CMD_EQSTART 0x1
-#define V_FW_EQ_OFLD_CMD_EQSTART(x) ((x) << S_FW_EQ_OFLD_CMD_EQSTART)
-#define G_FW_EQ_OFLD_CMD_EQSTART(x) \
- (((x) >> S_FW_EQ_OFLD_CMD_EQSTART) & M_FW_EQ_OFLD_CMD_EQSTART)
-#define F_FW_EQ_OFLD_CMD_EQSTART V_FW_EQ_OFLD_CMD_EQSTART(1U)
-
-#define S_FW_EQ_OFLD_CMD_EQSTOP 27
-#define M_FW_EQ_OFLD_CMD_EQSTOP 0x1
-#define V_FW_EQ_OFLD_CMD_EQSTOP(x) ((x) << S_FW_EQ_OFLD_CMD_EQSTOP)
-#define G_FW_EQ_OFLD_CMD_EQSTOP(x) \
- (((x) >> S_FW_EQ_OFLD_CMD_EQSTOP) & M_FW_EQ_OFLD_CMD_EQSTOP)
-#define F_FW_EQ_OFLD_CMD_EQSTOP V_FW_EQ_OFLD_CMD_EQSTOP(1U)
-
-#define S_FW_EQ_OFLD_CMD_EQID 0
-#define M_FW_EQ_OFLD_CMD_EQID 0xfffff
-#define V_FW_EQ_OFLD_CMD_EQID(x) ((x) << S_FW_EQ_OFLD_CMD_EQID)
-#define G_FW_EQ_OFLD_CMD_EQID(x) \
- (((x) >> S_FW_EQ_OFLD_CMD_EQID) & M_FW_EQ_OFLD_CMD_EQID)
-
-#define S_FW_EQ_OFLD_CMD_PHYSEQID 0
-#define M_FW_EQ_OFLD_CMD_PHYSEQID 0xfffff
-#define V_FW_EQ_OFLD_CMD_PHYSEQID(x) ((x) << S_FW_EQ_OFLD_CMD_PHYSEQID)
-#define G_FW_EQ_OFLD_CMD_PHYSEQID(x) \
- (((x) >> S_FW_EQ_OFLD_CMD_PHYSEQID) & M_FW_EQ_OFLD_CMD_PHYSEQID)
-
-#define S_FW_EQ_OFLD_CMD_FETCHSZM 26
-#define M_FW_EQ_OFLD_CMD_FETCHSZM 0x1
-#define V_FW_EQ_OFLD_CMD_FETCHSZM(x) ((x) << S_FW_EQ_OFLD_CMD_FETCHSZM)
-#define G_FW_EQ_OFLD_CMD_FETCHSZM(x) \
- (((x) >> S_FW_EQ_OFLD_CMD_FETCHSZM) & M_FW_EQ_OFLD_CMD_FETCHSZM)
-#define F_FW_EQ_OFLD_CMD_FETCHSZM V_FW_EQ_OFLD_CMD_FETCHSZM(1U)
-
-#define S_FW_EQ_OFLD_CMD_STATUSPGNS 25
-#define M_FW_EQ_OFLD_CMD_STATUSPGNS 0x1
-#define V_FW_EQ_OFLD_CMD_STATUSPGNS(x) ((x) << S_FW_EQ_OFLD_CMD_STATUSPGNS)
-#define G_FW_EQ_OFLD_CMD_STATUSPGNS(x) \
- (((x) >> S_FW_EQ_OFLD_CMD_STATUSPGNS) & M_FW_EQ_OFLD_CMD_STATUSPGNS)
-#define F_FW_EQ_OFLD_CMD_STATUSPGNS V_FW_EQ_OFLD_CMD_STATUSPGNS(1U)
-
-#define S_FW_EQ_OFLD_CMD_STATUSPGRO 24
-#define M_FW_EQ_OFLD_CMD_STATUSPGRO 0x1
-#define V_FW_EQ_OFLD_CMD_STATUSPGRO(x) ((x) << S_FW_EQ_OFLD_CMD_STATUSPGRO)
-#define G_FW_EQ_OFLD_CMD_STATUSPGRO(x) \
- (((x) >> S_FW_EQ_OFLD_CMD_STATUSPGRO) & M_FW_EQ_OFLD_CMD_STATUSPGRO)
-#define F_FW_EQ_OFLD_CMD_STATUSPGRO V_FW_EQ_OFLD_CMD_STATUSPGRO(1U)
-
-#define S_FW_EQ_OFLD_CMD_FETCHNS 23
-#define M_FW_EQ_OFLD_CMD_FETCHNS 0x1
-#define V_FW_EQ_OFLD_CMD_FETCHNS(x) ((x) << S_FW_EQ_OFLD_CMD_FETCHNS)
-#define G_FW_EQ_OFLD_CMD_FETCHNS(x) \
- (((x) >> S_FW_EQ_OFLD_CMD_FETCHNS) & M_FW_EQ_OFLD_CMD_FETCHNS)
-#define F_FW_EQ_OFLD_CMD_FETCHNS V_FW_EQ_OFLD_CMD_FETCHNS(1U)
-
-#define S_FW_EQ_OFLD_CMD_FETCHRO 22
-#define M_FW_EQ_OFLD_CMD_FETCHRO 0x1
-#define V_FW_EQ_OFLD_CMD_FETCHRO(x) ((x) << S_FW_EQ_OFLD_CMD_FETCHRO)
-#define G_FW_EQ_OFLD_CMD_FETCHRO(x) \
- (((x) >> S_FW_EQ_OFLD_CMD_FETCHRO) & M_FW_EQ_OFLD_CMD_FETCHRO)
-#define F_FW_EQ_OFLD_CMD_FETCHRO V_FW_EQ_OFLD_CMD_FETCHRO(1U)
-
-#define S_FW_EQ_OFLD_CMD_HOSTFCMODE 20
-#define M_FW_EQ_OFLD_CMD_HOSTFCMODE 0x3
-#define V_FW_EQ_OFLD_CMD_HOSTFCMODE(x) ((x) << S_FW_EQ_OFLD_CMD_HOSTFCMODE)
-#define G_FW_EQ_OFLD_CMD_HOSTFCMODE(x) \
- (((x) >> S_FW_EQ_OFLD_CMD_HOSTFCMODE) & M_FW_EQ_OFLD_CMD_HOSTFCMODE)
-
-#define S_FW_EQ_OFLD_CMD_CPRIO 19
-#define M_FW_EQ_OFLD_CMD_CPRIO 0x1
-#define V_FW_EQ_OFLD_CMD_CPRIO(x) ((x) << S_FW_EQ_OFLD_CMD_CPRIO)
-#define G_FW_EQ_OFLD_CMD_CPRIO(x) \
- (((x) >> S_FW_EQ_OFLD_CMD_CPRIO) & M_FW_EQ_OFLD_CMD_CPRIO)
-#define F_FW_EQ_OFLD_CMD_CPRIO V_FW_EQ_OFLD_CMD_CPRIO(1U)
-
-#define S_FW_EQ_OFLD_CMD_ONCHIP 18
-#define M_FW_EQ_OFLD_CMD_ONCHIP 0x1
-#define V_FW_EQ_OFLD_CMD_ONCHIP(x) ((x) << S_FW_EQ_OFLD_CMD_ONCHIP)
-#define G_FW_EQ_OFLD_CMD_ONCHIP(x) \
- (((x) >> S_FW_EQ_OFLD_CMD_ONCHIP) & M_FW_EQ_OFLD_CMD_ONCHIP)
-#define F_FW_EQ_OFLD_CMD_ONCHIP V_FW_EQ_OFLD_CMD_ONCHIP(1U)
-
-#define S_FW_EQ_OFLD_CMD_PCIECHN 16
-#define M_FW_EQ_OFLD_CMD_PCIECHN 0x3
-#define V_FW_EQ_OFLD_CMD_PCIECHN(x) ((x) << S_FW_EQ_OFLD_CMD_PCIECHN)
-#define G_FW_EQ_OFLD_CMD_PCIECHN(x) \
- (((x) >> S_FW_EQ_OFLD_CMD_PCIECHN) & M_FW_EQ_OFLD_CMD_PCIECHN)
-
-#define S_FW_EQ_OFLD_CMD_IQID 0
-#define M_FW_EQ_OFLD_CMD_IQID 0xffff
-#define V_FW_EQ_OFLD_CMD_IQID(x) ((x) << S_FW_EQ_OFLD_CMD_IQID)
-#define G_FW_EQ_OFLD_CMD_IQID(x) \
- (((x) >> S_FW_EQ_OFLD_CMD_IQID) & M_FW_EQ_OFLD_CMD_IQID)
-
-#define S_FW_EQ_OFLD_CMD_DCAEN 31
-#define M_FW_EQ_OFLD_CMD_DCAEN 0x1
-#define V_FW_EQ_OFLD_CMD_DCAEN(x) ((x) << S_FW_EQ_OFLD_CMD_DCAEN)
-#define G_FW_EQ_OFLD_CMD_DCAEN(x) \
- (((x) >> S_FW_EQ_OFLD_CMD_DCAEN) & M_FW_EQ_OFLD_CMD_DCAEN)
-#define F_FW_EQ_OFLD_CMD_DCAEN V_FW_EQ_OFLD_CMD_DCAEN(1U)
-
-#define S_FW_EQ_OFLD_CMD_DCACPU 26
-#define M_FW_EQ_OFLD_CMD_DCACPU 0x1f
-#define V_FW_EQ_OFLD_CMD_DCACPU(x) ((x) << S_FW_EQ_OFLD_CMD_DCACPU)
-#define G_FW_EQ_OFLD_CMD_DCACPU(x) \
- (((x) >> S_FW_EQ_OFLD_CMD_DCACPU) & M_FW_EQ_OFLD_CMD_DCACPU)
-
-#define S_FW_EQ_OFLD_CMD_FBMIN 23
-#define M_FW_EQ_OFLD_CMD_FBMIN 0x7
-#define V_FW_EQ_OFLD_CMD_FBMIN(x) ((x) << S_FW_EQ_OFLD_CMD_FBMIN)
-#define G_FW_EQ_OFLD_CMD_FBMIN(x) \
- (((x) >> S_FW_EQ_OFLD_CMD_FBMIN) & M_FW_EQ_OFLD_CMD_FBMIN)
-
-#define S_FW_EQ_OFLD_CMD_FBMAX 20
-#define M_FW_EQ_OFLD_CMD_FBMAX 0x7
-#define V_FW_EQ_OFLD_CMD_FBMAX(x) ((x) << S_FW_EQ_OFLD_CMD_FBMAX)
-#define G_FW_EQ_OFLD_CMD_FBMAX(x) \
- (((x) >> S_FW_EQ_OFLD_CMD_FBMAX) & M_FW_EQ_OFLD_CMD_FBMAX)
-
-#define S_FW_EQ_OFLD_CMD_CIDXFTHRESHO 19
-#define M_FW_EQ_OFLD_CMD_CIDXFTHRESHO 0x1
-#define V_FW_EQ_OFLD_CMD_CIDXFTHRESHO(x) \
- ((x) << S_FW_EQ_OFLD_CMD_CIDXFTHRESHO)
-#define G_FW_EQ_OFLD_CMD_CIDXFTHRESHO(x) \
- (((x) >> S_FW_EQ_OFLD_CMD_CIDXFTHRESHO) & M_FW_EQ_OFLD_CMD_CIDXFTHRESHO)
-#define F_FW_EQ_OFLD_CMD_CIDXFTHRESHO V_FW_EQ_OFLD_CMD_CIDXFTHRESHO(1U)
-
-#define S_FW_EQ_OFLD_CMD_CIDXFTHRESH 16
-#define M_FW_EQ_OFLD_CMD_CIDXFTHRESH 0x7
-#define V_FW_EQ_OFLD_CMD_CIDXFTHRESH(x) ((x) << S_FW_EQ_OFLD_CMD_CIDXFTHRESH)
-#define G_FW_EQ_OFLD_CMD_CIDXFTHRESH(x) \
- (((x) >> S_FW_EQ_OFLD_CMD_CIDXFTHRESH) & M_FW_EQ_OFLD_CMD_CIDXFTHRESH)
-
-#define S_FW_EQ_OFLD_CMD_EQSIZE 0
-#define M_FW_EQ_OFLD_CMD_EQSIZE 0xffff
-#define V_FW_EQ_OFLD_CMD_EQSIZE(x) ((x) << S_FW_EQ_OFLD_CMD_EQSIZE)
-#define G_FW_EQ_OFLD_CMD_EQSIZE(x) \
- (((x) >> S_FW_EQ_OFLD_CMD_EQSIZE) & M_FW_EQ_OFLD_CMD_EQSIZE)
-
-/* Macros for VIID parsing:
- VIID - [10:8] PFN, [7] VI Valid, [6:0] VI number */
-#define S_FW_VIID_PFN 8
-#define M_FW_VIID_PFN 0x7
-#define V_FW_VIID_PFN(x) ((x) << S_FW_VIID_PFN)
-#define G_FW_VIID_PFN(x) (((x) >> S_FW_VIID_PFN) & M_FW_VIID_PFN)
-
-#define S_FW_VIID_VIVLD 7
-#define M_FW_VIID_VIVLD 0x1
-#define V_FW_VIID_VIVLD(x) ((x) << S_FW_VIID_VIVLD)
-#define G_FW_VIID_VIVLD(x) (((x) >> S_FW_VIID_VIVLD) & M_FW_VIID_VIVLD)
-
-#define S_FW_VIID_VIN 0
-#define M_FW_VIID_VIN 0x7F
-#define V_FW_VIID_VIN(x) ((x) << S_FW_VIID_VIN)
-#define G_FW_VIID_VIN(x) (((x) >> S_FW_VIID_VIN) & M_FW_VIID_VIN)
-
-enum fw_vi_func {
- FW_VI_FUNC_ETH,
- FW_VI_FUNC_OFLD,
- FW_VI_FUNC_IWARP,
- FW_VI_FUNC_OPENISCSI,
- FW_VI_FUNC_OPENFCOE,
- FW_VI_FUNC_FOISCSI,
- FW_VI_FUNC_FOFCOE,
- FW_VI_FUNC_FW,
-};
-
-struct fw_vi_cmd {
- __be32 op_to_vfn;
- __be32 alloc_to_len16;
- __be16 type_to_viid;
- __u8 mac[6];
- __u8 portid_pkd;
- __u8 nmac;
- __u8 nmac0[6];
- __be16 norss_rsssize;
- __u8 nmac1[6];
- __be16 idsiiq_pkd;
- __u8 nmac2[6];
- __be16 idseiq_pkd;
- __u8 nmac3[6];
- __be64 r9;
- __be64 r10;
-};
-
-#define S_FW_VI_CMD_PFN 8
-#define M_FW_VI_CMD_PFN 0x7
-#define V_FW_VI_CMD_PFN(x) ((x) << S_FW_VI_CMD_PFN)
-#define G_FW_VI_CMD_PFN(x) (((x) >> S_FW_VI_CMD_PFN) & M_FW_VI_CMD_PFN)
-
-#define S_FW_VI_CMD_VFN 0
-#define M_FW_VI_CMD_VFN 0xff
-#define V_FW_VI_CMD_VFN(x) ((x) << S_FW_VI_CMD_VFN)
-#define G_FW_VI_CMD_VFN(x) (((x) >> S_FW_VI_CMD_VFN) & M_FW_VI_CMD_VFN)
-
-#define S_FW_VI_CMD_ALLOC 31
-#define M_FW_VI_CMD_ALLOC 0x1
-#define V_FW_VI_CMD_ALLOC(x) ((x) << S_FW_VI_CMD_ALLOC)
-#define G_FW_VI_CMD_ALLOC(x) \
- (((x) >> S_FW_VI_CMD_ALLOC) & M_FW_VI_CMD_ALLOC)
-#define F_FW_VI_CMD_ALLOC V_FW_VI_CMD_ALLOC(1U)
-
-#define S_FW_VI_CMD_FREE 30
-#define M_FW_VI_CMD_FREE 0x1
-#define V_FW_VI_CMD_FREE(x) ((x) << S_FW_VI_CMD_FREE)
-#define G_FW_VI_CMD_FREE(x) (((x) >> S_FW_VI_CMD_FREE) & M_FW_VI_CMD_FREE)
-#define F_FW_VI_CMD_FREE V_FW_VI_CMD_FREE(1U)
-
-#define S_FW_VI_CMD_TYPE 15
-#define M_FW_VI_CMD_TYPE 0x1
-#define V_FW_VI_CMD_TYPE(x) ((x) << S_FW_VI_CMD_TYPE)
-#define G_FW_VI_CMD_TYPE(x) (((x) >> S_FW_VI_CMD_TYPE) & M_FW_VI_CMD_TYPE)
-#define F_FW_VI_CMD_TYPE V_FW_VI_CMD_TYPE(1U)
-
-#define S_FW_VI_CMD_FUNC 12
-#define M_FW_VI_CMD_FUNC 0x7
-#define V_FW_VI_CMD_FUNC(x) ((x) << S_FW_VI_CMD_FUNC)
-#define G_FW_VI_CMD_FUNC(x) (((x) >> S_FW_VI_CMD_FUNC) & M_FW_VI_CMD_FUNC)
-
-#define S_FW_VI_CMD_VIID 0
-#define M_FW_VI_CMD_VIID 0xfff
-#define V_FW_VI_CMD_VIID(x) ((x) << S_FW_VI_CMD_VIID)
-#define G_FW_VI_CMD_VIID(x) (((x) >> S_FW_VI_CMD_VIID) & M_FW_VI_CMD_VIID)
-
-#define S_FW_VI_CMD_PORTID 4
-#define M_FW_VI_CMD_PORTID 0xf
-#define V_FW_VI_CMD_PORTID(x) ((x) << S_FW_VI_CMD_PORTID)
-#define G_FW_VI_CMD_PORTID(x) \
- (((x) >> S_FW_VI_CMD_PORTID) & M_FW_VI_CMD_PORTID)
-
-#define S_FW_VI_CMD_NORSS 11
-#define M_FW_VI_CMD_NORSS 0x1
-#define V_FW_VI_CMD_NORSS(x) ((x) << S_FW_VI_CMD_NORSS)
-#define G_FW_VI_CMD_NORSS(x) \
- (((x) >> S_FW_VI_CMD_NORSS) & M_FW_VI_CMD_NORSS)
-#define F_FW_VI_CMD_NORSS V_FW_VI_CMD_NORSS(1U)
-
-#define S_FW_VI_CMD_RSSSIZE 0
-#define M_FW_VI_CMD_RSSSIZE 0x7ff
-#define V_FW_VI_CMD_RSSSIZE(x) ((x) << S_FW_VI_CMD_RSSSIZE)
-#define G_FW_VI_CMD_RSSSIZE(x) \
- (((x) >> S_FW_VI_CMD_RSSSIZE) & M_FW_VI_CMD_RSSSIZE)
-
-#define S_FW_VI_CMD_IDSIIQ 0
-#define M_FW_VI_CMD_IDSIIQ 0x3ff
-#define V_FW_VI_CMD_IDSIIQ(x) ((x) << S_FW_VI_CMD_IDSIIQ)
-#define G_FW_VI_CMD_IDSIIQ(x) \
- (((x) >> S_FW_VI_CMD_IDSIIQ) & M_FW_VI_CMD_IDSIIQ)
-
-#define S_FW_VI_CMD_IDSEIQ 0
-#define M_FW_VI_CMD_IDSEIQ 0x3ff
-#define V_FW_VI_CMD_IDSEIQ(x) ((x) << S_FW_VI_CMD_IDSEIQ)
-#define G_FW_VI_CMD_IDSEIQ(x) \
- (((x) >> S_FW_VI_CMD_IDSEIQ) & M_FW_VI_CMD_IDSEIQ)
-
-/* Special VI_MAC command index ids */
-#define FW_VI_MAC_ADD_MAC 0x3FF
-#define FW_VI_MAC_ADD_PERSIST_MAC 0x3FE
-#define FW_VI_MAC_MAC_BASED_FREE 0x3FD
-
-enum fw_vi_mac_smac {
- FW_VI_MAC_MPS_TCAM_ENTRY,
- FW_VI_MAC_MPS_TCAM_ONLY,
- FW_VI_MAC_SMT_ONLY,
- FW_VI_MAC_SMT_AND_MPSTCAM
-};
-
-enum fw_vi_mac_result {
- FW_VI_MAC_R_SUCCESS,
- FW_VI_MAC_R_F_NONEXISTENT_NOMEM,
- FW_VI_MAC_R_SMAC_FAIL,
- FW_VI_MAC_R_F_ACL_CHECK
-};
-
-struct fw_vi_mac_cmd {
- __be32 op_to_viid;
- __be32 freemacs_to_len16;
- union fw_vi_mac {
- struct fw_vi_mac_exact {
- __be16 valid_to_idx;
- __u8 macaddr[6];
- } exact[7];
- struct fw_vi_mac_hash {
- __be64 hashvec;
- } hash;
- } u;
-};
-
-#define S_FW_VI_MAC_CMD_VIID 0
-#define M_FW_VI_MAC_CMD_VIID 0xfff
-#define V_FW_VI_MAC_CMD_VIID(x) ((x) << S_FW_VI_MAC_CMD_VIID)
-#define G_FW_VI_MAC_CMD_VIID(x) \
- (((x) >> S_FW_VI_MAC_CMD_VIID) & M_FW_VI_MAC_CMD_VIID)
-
-#define S_FW_VI_MAC_CMD_FREEMACS 31
-#define M_FW_VI_MAC_CMD_FREEMACS 0x1
-#define V_FW_VI_MAC_CMD_FREEMACS(x) ((x) << S_FW_VI_MAC_CMD_FREEMACS)
-#define G_FW_VI_MAC_CMD_FREEMACS(x) \
- (((x) >> S_FW_VI_MAC_CMD_FREEMACS) & M_FW_VI_MAC_CMD_FREEMACS)
-#define F_FW_VI_MAC_CMD_FREEMACS V_FW_VI_MAC_CMD_FREEMACS(1U)
-
-#define S_FW_VI_MAC_CMD_HASHVECEN 23
-#define M_FW_VI_MAC_CMD_HASHVECEN 0x1
-#define V_FW_VI_MAC_CMD_HASHVECEN(x) ((x) << S_FW_VI_MAC_CMD_HASHVECEN)
-#define G_FW_VI_MAC_CMD_HASHVECEN(x) \
- (((x) >> S_FW_VI_MAC_CMD_HASHVECEN) & M_FW_VI_MAC_CMD_HASHVECEN)
-#define F_FW_VI_MAC_CMD_HASHVECEN V_FW_VI_MAC_CMD_HASHVECEN(1U)
-
-#define S_FW_VI_MAC_CMD_HASHUNIEN 22
-#define M_FW_VI_MAC_CMD_HASHUNIEN 0x1
-#define V_FW_VI_MAC_CMD_HASHUNIEN(x) ((x) << S_FW_VI_MAC_CMD_HASHUNIEN)
-#define G_FW_VI_MAC_CMD_HASHUNIEN(x) \
- (((x) >> S_FW_VI_MAC_CMD_HASHUNIEN) & M_FW_VI_MAC_CMD_HASHUNIEN)
-#define F_FW_VI_MAC_CMD_HASHUNIEN V_FW_VI_MAC_CMD_HASHUNIEN(1U)
-
-#define S_FW_VI_MAC_CMD_VALID 15
-#define M_FW_VI_MAC_CMD_VALID 0x1
-#define V_FW_VI_MAC_CMD_VALID(x) ((x) << S_FW_VI_MAC_CMD_VALID)
-#define G_FW_VI_MAC_CMD_VALID(x) \
- (((x) >> S_FW_VI_MAC_CMD_VALID) & M_FW_VI_MAC_CMD_VALID)
-#define F_FW_VI_MAC_CMD_VALID V_FW_VI_MAC_CMD_VALID(1U)
-
-#define S_FW_VI_MAC_CMD_PRIO 12
-#define M_FW_VI_MAC_CMD_PRIO 0x7
-#define V_FW_VI_MAC_CMD_PRIO(x) ((x) << S_FW_VI_MAC_CMD_PRIO)
-#define G_FW_VI_MAC_CMD_PRIO(x) \
- (((x) >> S_FW_VI_MAC_CMD_PRIO) & M_FW_VI_MAC_CMD_PRIO)
-
-#define S_FW_VI_MAC_CMD_SMAC_RESULT 10
-#define M_FW_VI_MAC_CMD_SMAC_RESULT 0x3
-#define V_FW_VI_MAC_CMD_SMAC_RESULT(x) ((x) << S_FW_VI_MAC_CMD_SMAC_RESULT)
-#define G_FW_VI_MAC_CMD_SMAC_RESULT(x) \
- (((x) >> S_FW_VI_MAC_CMD_SMAC_RESULT) & M_FW_VI_MAC_CMD_SMAC_RESULT)
-
-#define S_FW_VI_MAC_CMD_IDX 0
-#define M_FW_VI_MAC_CMD_IDX 0x3ff
-#define V_FW_VI_MAC_CMD_IDX(x) ((x) << S_FW_VI_MAC_CMD_IDX)
-#define G_FW_VI_MAC_CMD_IDX(x) \
- (((x) >> S_FW_VI_MAC_CMD_IDX) & M_FW_VI_MAC_CMD_IDX)
-
-/* T4 max MTU supported */
-#define T4_MAX_MTU_SUPPORTED 9600
-#define FW_RXMODE_MTU_NO_CHG 65535
-
-struct fw_vi_rxmode_cmd {
- __be32 op_to_viid;
- __be32 retval_len16;
- __be32 mtu_to_vlanexen;
- __be32 r4_lo;
-};
-
-#define S_FW_VI_RXMODE_CMD_VIID 0
-#define M_FW_VI_RXMODE_CMD_VIID 0xfff
-#define V_FW_VI_RXMODE_CMD_VIID(x) ((x) << S_FW_VI_RXMODE_CMD_VIID)
-#define G_FW_VI_RXMODE_CMD_VIID(x) \
- (((x) >> S_FW_VI_RXMODE_CMD_VIID) & M_FW_VI_RXMODE_CMD_VIID)
-
-#define S_FW_VI_RXMODE_CMD_MTU 16
-#define M_FW_VI_RXMODE_CMD_MTU 0xffff
-#define V_FW_VI_RXMODE_CMD_MTU(x) ((x) << S_FW_VI_RXMODE_CMD_MTU)
-#define G_FW_VI_RXMODE_CMD_MTU(x) \
- (((x) >> S_FW_VI_RXMODE_CMD_MTU) & M_FW_VI_RXMODE_CMD_MTU)
-
-#define S_FW_VI_RXMODE_CMD_PROMISCEN 14
-#define M_FW_VI_RXMODE_CMD_PROMISCEN 0x3
-#define V_FW_VI_RXMODE_CMD_PROMISCEN(x) ((x) << S_FW_VI_RXMODE_CMD_PROMISCEN)
-#define G_FW_VI_RXMODE_CMD_PROMISCEN(x) \
- (((x) >> S_FW_VI_RXMODE_CMD_PROMISCEN) & M_FW_VI_RXMODE_CMD_PROMISCEN)
-
-#define S_FW_VI_RXMODE_CMD_ALLMULTIEN 12
-#define M_FW_VI_RXMODE_CMD_ALLMULTIEN 0x3
-#define V_FW_VI_RXMODE_CMD_ALLMULTIEN(x) \
- ((x) << S_FW_VI_RXMODE_CMD_ALLMULTIEN)
-#define G_FW_VI_RXMODE_CMD_ALLMULTIEN(x) \
- (((x) >> S_FW_VI_RXMODE_CMD_ALLMULTIEN) & M_FW_VI_RXMODE_CMD_ALLMULTIEN)
-
-#define S_FW_VI_RXMODE_CMD_BROADCASTEN 10
-#define M_FW_VI_RXMODE_CMD_BROADCASTEN 0x3
-#define V_FW_VI_RXMODE_CMD_BROADCASTEN(x) \
- ((x) << S_FW_VI_RXMODE_CMD_BROADCASTEN)
-#define G_FW_VI_RXMODE_CMD_BROADCASTEN(x) \
- (((x) >> S_FW_VI_RXMODE_CMD_BROADCASTEN) & M_FW_VI_RXMODE_CMD_BROADCASTEN)
-
-#define S_FW_VI_RXMODE_CMD_VLANEXEN 8
-#define M_FW_VI_RXMODE_CMD_VLANEXEN 0x3
-#define V_FW_VI_RXMODE_CMD_VLANEXEN(x) ((x) << S_FW_VI_RXMODE_CMD_VLANEXEN)
-#define G_FW_VI_RXMODE_CMD_VLANEXEN(x) \
- (((x) >> S_FW_VI_RXMODE_CMD_VLANEXEN) & M_FW_VI_RXMODE_CMD_VLANEXEN)
-
-struct fw_vi_enable_cmd {
- __be32 op_to_viid;
- __be32 ien_to_len16;
- __be16 blinkdur;
- __be16 r3;
- __be32 r4;
-};
-
-#define S_FW_VI_ENABLE_CMD_VIID 0
-#define M_FW_VI_ENABLE_CMD_VIID 0xfff
-#define V_FW_VI_ENABLE_CMD_VIID(x) ((x) << S_FW_VI_ENABLE_CMD_VIID)
-#define G_FW_VI_ENABLE_CMD_VIID(x) \
- (((x) >> S_FW_VI_ENABLE_CMD_VIID) & M_FW_VI_ENABLE_CMD_VIID)
-
-#define S_FW_VI_ENABLE_CMD_IEN 31
-#define M_FW_VI_ENABLE_CMD_IEN 0x1
-#define V_FW_VI_ENABLE_CMD_IEN(x) ((x) << S_FW_VI_ENABLE_CMD_IEN)
-#define G_FW_VI_ENABLE_CMD_IEN(x) \
- (((x) >> S_FW_VI_ENABLE_CMD_IEN) & M_FW_VI_ENABLE_CMD_IEN)
-#define F_FW_VI_ENABLE_CMD_IEN V_FW_VI_ENABLE_CMD_IEN(1U)
-
-#define S_FW_VI_ENABLE_CMD_EEN 30
-#define M_FW_VI_ENABLE_CMD_EEN 0x1
-#define V_FW_VI_ENABLE_CMD_EEN(x) ((x) << S_FW_VI_ENABLE_CMD_EEN)
-#define G_FW_VI_ENABLE_CMD_EEN(x) \
- (((x) >> S_FW_VI_ENABLE_CMD_EEN) & M_FW_VI_ENABLE_CMD_EEN)
-#define F_FW_VI_ENABLE_CMD_EEN V_FW_VI_ENABLE_CMD_EEN(1U)
-
-#define S_FW_VI_ENABLE_CMD_LED 29
-#define M_FW_VI_ENABLE_CMD_LED 0x1
-#define V_FW_VI_ENABLE_CMD_LED(x) ((x) << S_FW_VI_ENABLE_CMD_LED)
-#define G_FW_VI_ENABLE_CMD_LED(x) \
- (((x) >> S_FW_VI_ENABLE_CMD_LED) & M_FW_VI_ENABLE_CMD_LED)
-#define F_FW_VI_ENABLE_CMD_LED V_FW_VI_ENABLE_CMD_LED(1U)
-
-#define S_FW_VI_ENABLE_CMD_DCB_INFO 28
-#define M_FW_VI_ENABLE_CMD_DCB_INFO 0x1
-#define V_FW_VI_ENABLE_CMD_DCB_INFO(x) ((x) << S_FW_VI_ENABLE_CMD_DCB_INFO)
-#define G_FW_VI_ENABLE_CMD_DCB_INFO(x) \
- (((x) >> S_FW_VI_ENABLE_CMD_DCB_INFO) & M_FW_VI_ENABLE_CMD_DCB_INFO)
-#define F_FW_VI_ENABLE_CMD_DCB_INFO V_FW_VI_ENABLE_CMD_DCB_INFO(1U)
-
-/* VI VF stats offset definitions */
-#define VI_VF_NUM_STATS 16
-enum fw_vi_stats_vf_index {
- FW_VI_VF_STAT_TX_BCAST_BYTES_IX,
- FW_VI_VF_STAT_TX_BCAST_FRAMES_IX,
- FW_VI_VF_STAT_TX_MCAST_BYTES_IX,
- FW_VI_VF_STAT_TX_MCAST_FRAMES_IX,
- FW_VI_VF_STAT_TX_UCAST_BYTES_IX,
- FW_VI_VF_STAT_TX_UCAST_FRAMES_IX,
- FW_VI_VF_STAT_TX_DROP_FRAMES_IX,
- FW_VI_VF_STAT_TX_OFLD_BYTES_IX,
- FW_VI_VF_STAT_TX_OFLD_FRAMES_IX,
- FW_VI_VF_STAT_RX_BCAST_BYTES_IX,
- FW_VI_VF_STAT_RX_BCAST_FRAMES_IX,
- FW_VI_VF_STAT_RX_MCAST_BYTES_IX,
- FW_VI_VF_STAT_RX_MCAST_FRAMES_IX,
- FW_VI_VF_STAT_RX_UCAST_BYTES_IX,
- FW_VI_VF_STAT_RX_UCAST_FRAMES_IX,
- FW_VI_VF_STAT_RX_ERR_FRAMES_IX
-};
-
-/* VI PF stats offset definitions */
-#define VI_PF_NUM_STATS 17
-enum fw_vi_stats_pf_index {
- FW_VI_PF_STAT_TX_BCAST_BYTES_IX,
- FW_VI_PF_STAT_TX_BCAST_FRAMES_IX,
- FW_VI_PF_STAT_TX_MCAST_BYTES_IX,
- FW_VI_PF_STAT_TX_MCAST_FRAMES_IX,
- FW_VI_PF_STAT_TX_UCAST_BYTES_IX,
- FW_VI_PF_STAT_TX_UCAST_FRAMES_IX,
- FW_VI_PF_STAT_TX_OFLD_BYTES_IX,
- FW_VI_PF_STAT_TX_OFLD_FRAMES_IX,
- FW_VI_PF_STAT_RX_BYTES_IX,
- FW_VI_PF_STAT_RX_FRAMES_IX,
- FW_VI_PF_STAT_RX_BCAST_BYTES_IX,
- FW_VI_PF_STAT_RX_BCAST_FRAMES_IX,
- FW_VI_PF_STAT_RX_MCAST_BYTES_IX,
- FW_VI_PF_STAT_RX_MCAST_FRAMES_IX,
- FW_VI_PF_STAT_RX_UCAST_BYTES_IX,
- FW_VI_PF_STAT_RX_UCAST_FRAMES_IX,
- FW_VI_PF_STAT_RX_ERR_FRAMES_IX
-};
-
-struct fw_vi_stats_cmd {
- __be32 op_to_viid;
- __be32 retval_len16;
- union fw_vi_stats {
- struct fw_vi_stats_ctl {
- __be16 nstats_ix;
- __be16 r6;
- __be32 r7;
- __be64 stat0;
- __be64 stat1;
- __be64 stat2;
- __be64 stat3;
- __be64 stat4;
- __be64 stat5;
- } ctl;
- struct fw_vi_stats_pf {
- __be64 tx_bcast_bytes;
- __be64 tx_bcast_frames;
- __be64 tx_mcast_bytes;
- __be64 tx_mcast_frames;
- __be64 tx_ucast_bytes;
- __be64 tx_ucast_frames;
- __be64 tx_offload_bytes;
- __be64 tx_offload_frames;
- __be64 rx_pf_bytes;
- __be64 rx_pf_frames;
- __be64 rx_bcast_bytes;
- __be64 rx_bcast_frames;
- __be64 rx_mcast_bytes;
- __be64 rx_mcast_frames;
- __be64 rx_ucast_bytes;
- __be64 rx_ucast_frames;
- __be64 rx_err_frames;
- } pf;
- struct fw_vi_stats_vf {
- __be64 tx_bcast_bytes;
- __be64 tx_bcast_frames;
- __be64 tx_mcast_bytes;
- __be64 tx_mcast_frames;
- __be64 tx_ucast_bytes;
- __be64 tx_ucast_frames;
- __be64 tx_drop_frames;
- __be64 tx_offload_bytes;
- __be64 tx_offload_frames;
- __be64 rx_bcast_bytes;
- __be64 rx_bcast_frames;
- __be64 rx_mcast_bytes;
- __be64 rx_mcast_frames;
- __be64 rx_ucast_bytes;
- __be64 rx_ucast_frames;
- __be64 rx_err_frames;
- } vf;
- } u;
-};
-
-#define S_FW_VI_STATS_CMD_VIID 0
-#define M_FW_VI_STATS_CMD_VIID 0xfff
-#define V_FW_VI_STATS_CMD_VIID(x) ((x) << S_FW_VI_STATS_CMD_VIID)
-#define G_FW_VI_STATS_CMD_VIID(x) \
- (((x) >> S_FW_VI_STATS_CMD_VIID) & M_FW_VI_STATS_CMD_VIID)
-
-#define S_FW_VI_STATS_CMD_NSTATS 12
-#define M_FW_VI_STATS_CMD_NSTATS 0x7
-#define V_FW_VI_STATS_CMD_NSTATS(x) ((x) << S_FW_VI_STATS_CMD_NSTATS)
-#define G_FW_VI_STATS_CMD_NSTATS(x) \
- (((x) >> S_FW_VI_STATS_CMD_NSTATS) & M_FW_VI_STATS_CMD_NSTATS)
-
-#define S_FW_VI_STATS_CMD_IX 0
-#define M_FW_VI_STATS_CMD_IX 0x1f
-#define V_FW_VI_STATS_CMD_IX(x) ((x) << S_FW_VI_STATS_CMD_IX)
-#define G_FW_VI_STATS_CMD_IX(x) \
- (((x) >> S_FW_VI_STATS_CMD_IX) & M_FW_VI_STATS_CMD_IX)
-
-struct fw_acl_mac_cmd {
- __be32 op_to_vfn;
- __be32 en_to_len16;
- __u8 nmac;
- __u8 r3[7];
- __be16 r4;
- __u8 macaddr0[6];
- __be16 r5;
- __u8 macaddr1[6];
- __be16 r6;
- __u8 macaddr2[6];
- __be16 r7;
- __u8 macaddr3[6];
-};
-
-#define S_FW_ACL_MAC_CMD_PFN 8
-#define M_FW_ACL_MAC_CMD_PFN 0x7
-#define V_FW_ACL_MAC_CMD_PFN(x) ((x) << S_FW_ACL_MAC_CMD_PFN)
-#define G_FW_ACL_MAC_CMD_PFN(x) \
- (((x) >> S_FW_ACL_MAC_CMD_PFN) & M_FW_ACL_MAC_CMD_PFN)
-
-#define S_FW_ACL_MAC_CMD_VFN 0
-#define M_FW_ACL_MAC_CMD_VFN 0xff
-#define V_FW_ACL_MAC_CMD_VFN(x) ((x) << S_FW_ACL_MAC_CMD_VFN)
-#define G_FW_ACL_MAC_CMD_VFN(x) \
- (((x) >> S_FW_ACL_MAC_CMD_VFN) & M_FW_ACL_MAC_CMD_VFN)
-
-#define S_FW_ACL_MAC_CMD_EN 31
-#define M_FW_ACL_MAC_CMD_EN 0x1
-#define V_FW_ACL_MAC_CMD_EN(x) ((x) << S_FW_ACL_MAC_CMD_EN)
-#define G_FW_ACL_MAC_CMD_EN(x) \
- (((x) >> S_FW_ACL_MAC_CMD_EN) & M_FW_ACL_MAC_CMD_EN)
-#define F_FW_ACL_MAC_CMD_EN V_FW_ACL_MAC_CMD_EN(1U)
-
-struct fw_acl_vlan_cmd {
- __be32 op_to_vfn;
- __be32 en_to_len16;
- __u8 nvlan;
- __u8 dropnovlan_fm;
- __u8 r3_lo[6];
- __be16 vlanid[16];
-};
-
-#define S_FW_ACL_VLAN_CMD_PFN 8
-#define M_FW_ACL_VLAN_CMD_PFN 0x7
-#define V_FW_ACL_VLAN_CMD_PFN(x) ((x) << S_FW_ACL_VLAN_CMD_PFN)
-#define G_FW_ACL_VLAN_CMD_PFN(x) \
- (((x) >> S_FW_ACL_VLAN_CMD_PFN) & M_FW_ACL_VLAN_CMD_PFN)
-
-#define S_FW_ACL_VLAN_CMD_VFN 0
-#define M_FW_ACL_VLAN_CMD_VFN 0xff
-#define V_FW_ACL_VLAN_CMD_VFN(x) ((x) << S_FW_ACL_VLAN_CMD_VFN)
-#define G_FW_ACL_VLAN_CMD_VFN(x) \
- (((x) >> S_FW_ACL_VLAN_CMD_VFN) & M_FW_ACL_VLAN_CMD_VFN)
-
-#define S_FW_ACL_VLAN_CMD_EN 31
-#define M_FW_ACL_VLAN_CMD_EN 0x1
-#define V_FW_ACL_VLAN_CMD_EN(x) ((x) << S_FW_ACL_VLAN_CMD_EN)
-#define G_FW_ACL_VLAN_CMD_EN(x) \
- (((x) >> S_FW_ACL_VLAN_CMD_EN) & M_FW_ACL_VLAN_CMD_EN)
-#define F_FW_ACL_VLAN_CMD_EN V_FW_ACL_VLAN_CMD_EN(1U)
-
-#define S_FW_ACL_VLAN_CMD_DROPNOVLAN 7
-#define M_FW_ACL_VLAN_CMD_DROPNOVLAN 0x1
-#define V_FW_ACL_VLAN_CMD_DROPNOVLAN(x) ((x) << S_FW_ACL_VLAN_CMD_DROPNOVLAN)
-#define G_FW_ACL_VLAN_CMD_DROPNOVLAN(x) \
- (((x) >> S_FW_ACL_VLAN_CMD_DROPNOVLAN) & M_FW_ACL_VLAN_CMD_DROPNOVLAN)
-#define F_FW_ACL_VLAN_CMD_DROPNOVLAN V_FW_ACL_VLAN_CMD_DROPNOVLAN(1U)
-
-#define S_FW_ACL_VLAN_CMD_FM 6
-#define M_FW_ACL_VLAN_CMD_FM 0x1
-#define V_FW_ACL_VLAN_CMD_FM(x) ((x) << S_FW_ACL_VLAN_CMD_FM)
-#define G_FW_ACL_VLAN_CMD_FM(x) \
- (((x) >> S_FW_ACL_VLAN_CMD_FM) & M_FW_ACL_VLAN_CMD_FM)
-#define F_FW_ACL_VLAN_CMD_FM V_FW_ACL_VLAN_CMD_FM(1U)
-
-/* port capabilities bitmap */
-enum fw_port_cap {
- FW_PORT_CAP_SPEED_100M = 0x0001,
- FW_PORT_CAP_SPEED_1G = 0x0002,
- FW_PORT_CAP_SPEED_2_5G = 0x0004,
- FW_PORT_CAP_SPEED_10G = 0x0008,
- FW_PORT_CAP_SPEED_40G = 0x0010,
- FW_PORT_CAP_SPEED_100G = 0x0020,
- FW_PORT_CAP_FC_RX = 0x0040,
- FW_PORT_CAP_FC_TX = 0x0080,
- FW_PORT_CAP_ANEG = 0x0100,
- FW_PORT_CAP_MDIX = 0x0200,
- FW_PORT_CAP_MDIAUTO = 0x0400,
- FW_PORT_CAP_FEC = 0x0800,
- FW_PORT_CAP_TECHKR = 0x1000,
- FW_PORT_CAP_TECHKX4 = 0x2000,
-};
-
-#define S_FW_PORT_AUXLINFO_MDI 3
-#define M_FW_PORT_AUXLINFO_MDI 0x3
-#define V_FW_PORT_AUXLINFO_MDI(x) ((x) << S_FW_PORT_AUXLINFO_MDI)
-#define G_FW_PORT_AUXLINFO_MDI(x) \
- (((x) >> S_FW_PORT_AUXLINFO_MDI) & M_FW_PORT_AUXLINFO_MDI)
-
-#define S_FW_PORT_AUXLINFO_KX4 2
-#define M_FW_PORT_AUXLINFO_KX4 0x1
-#define V_FW_PORT_AUXLINFO_KX4(x) ((x) << S_FW_PORT_AUXLINFO_KX4)
-#define G_FW_PORT_AUXLINFO_KX4(x) \
- (((x) >> S_FW_PORT_AUXLINFO_KX4) & M_FW_PORT_AUXLINFO_KX4)
-#define F_FW_PORT_AUXLINFO_KX4 V_FW_PORT_AUXLINFO_KX4(1U)
-
-#define S_FW_PORT_AUXLINFO_KR 1
-#define M_FW_PORT_AUXLINFO_KR 0x1
-#define V_FW_PORT_AUXLINFO_KR(x) ((x) << S_FW_PORT_AUXLINFO_KR)
-#define G_FW_PORT_AUXLINFO_KR(x) \
- (((x) >> S_FW_PORT_AUXLINFO_KR) & M_FW_PORT_AUXLINFO_KR)
-#define F_FW_PORT_AUXLINFO_KR V_FW_PORT_AUXLINFO_KR(1U)
-
-#define S_FW_PORT_AUXLINFO_FEC 0
-#define M_FW_PORT_AUXLINFO_FEC 0x1
-#define V_FW_PORT_AUXLINFO_FEC(x) ((x) << S_FW_PORT_AUXLINFO_FEC)
-#define G_FW_PORT_AUXLINFO_FEC(x) \
- (((x) >> S_FW_PORT_AUXLINFO_FEC) & M_FW_PORT_AUXLINFO_FEC)
-#define F_FW_PORT_AUXLINFO_FEC V_FW_PORT_AUXLINFO_FEC(1U)
-
-#define S_FW_PORT_RCAP_AUX 11
-#define M_FW_PORT_RCAP_AUX 0x7
-#define V_FW_PORT_RCAP_AUX(x) ((x) << S_FW_PORT_RCAP_AUX)
-#define G_FW_PORT_RCAP_AUX(x) \
- (((x) >> S_FW_PORT_RCAP_AUX) & M_FW_PORT_RCAP_AUX)
-
-#define S_FW_PORT_CAP_SPEED 0
-#define M_FW_PORT_CAP_SPEED 0x3f
-#define V_FW_PORT_CAP_SPEED(x) ((x) << S_FW_PORT_CAP_SPEED)
-#define G_FW_PORT_CAP_SPEED(x) \
- (((x) >> S_FW_PORT_CAP_SPEED) & M_FW_PORT_CAP_SPEED)
-
-#define S_FW_PORT_CAP_FC 6
-#define M_FW_PORT_CAP_FC 0x3
-#define V_FW_PORT_CAP_FC(x) ((x) << S_FW_PORT_CAP_FC)
-#define G_FW_PORT_CAP_FC(x) \
- (((x) >> S_FW_PORT_CAP_FC) & M_FW_PORT_CAP_FC)
-
-#define S_FW_PORT_CAP_ANEG 8
-#define M_FW_PORT_CAP_ANEG 0x1
-#define V_FW_PORT_CAP_ANEG(x) ((x) << S_FW_PORT_CAP_ANEG)
-#define G_FW_PORT_CAP_ANEG(x) \
- (((x) >> S_FW_PORT_CAP_ANEG) & M_FW_PORT_CAP_ANEG)
-
-enum fw_port_mdi {
- FW_PORT_CAP_MDI_UNCHANGED,
- FW_PORT_CAP_MDI_AUTO,
- FW_PORT_CAP_MDI_F_STRAIGHT,
- FW_PORT_CAP_MDI_F_CROSSOVER
-};
-
-#define S_FW_PORT_CAP_MDI 9
-#define M_FW_PORT_CAP_MDI 3
-#define V_FW_PORT_CAP_MDI(x) ((x) << S_FW_PORT_CAP_MDI)
-#define G_FW_PORT_CAP_MDI(x) (((x) >> S_FW_PORT_CAP_MDI) & M_FW_PORT_CAP_MDI)
-
-enum fw_port_action {
- FW_PORT_ACTION_L1_CFG = 0x0001,
- FW_PORT_ACTION_L2_CFG = 0x0002,
- FW_PORT_ACTION_GET_PORT_INFO = 0x0003,
- FW_PORT_ACTION_L2_PPP_CFG = 0x0004,
- FW_PORT_ACTION_L2_DCB_CFG = 0x0005,
- FW_PORT_ACTION_DCB_READ_TRANS = 0x0006,
- FW_PORT_ACTION_DCB_READ_RECV = 0x0007,
- FW_PORT_ACTION_DCB_READ_DET = 0x0008,
- FW_PORT_ACTION_LOW_PWR_TO_NORMAL = 0x0010,
- FW_PORT_ACTION_L1_LOW_PWR_EN = 0x0011,
- FW_PORT_ACTION_L2_WOL_MODE_EN = 0x0012,
- FW_PORT_ACTION_LPBK_TO_NORMAL = 0x0020,
- FW_PORT_ACTION_LPBK_SS_ASIC = 0x0022,
- FW_PORT_ACTION_LPBK_WS_ASIC = 0x0023,
- FW_PORT_ACTION_LPBK_WS_EXT_PHY = 0x0025,
- FW_PORT_ACTION_LPBK_SS_EXT = 0x0026,
- FW_PORT_ACTION_DIAGNOSTICS = 0x0027,
- FW_PORT_ACTION_LPBK_SS_EXT_PHY = 0x0028,
- FW_PORT_ACTION_PHY_RESET = 0x0040,
- FW_PORT_ACTION_PMA_RESET = 0x0041,
- FW_PORT_ACTION_PCS_RESET = 0x0042,
- FW_PORT_ACTION_PHYXS_RESET = 0x0043,
- FW_PORT_ACTION_DTEXS_REEST = 0x0044,
- FW_PORT_ACTION_AN_RESET = 0x0045,
-
-};
-
-enum fw_port_l2cfg_ctlbf {
- FW_PORT_L2_CTLBF_OVLAN0 = 0x01,
- FW_PORT_L2_CTLBF_OVLAN1 = 0x02,
- FW_PORT_L2_CTLBF_OVLAN2 = 0x04,
- FW_PORT_L2_CTLBF_OVLAN3 = 0x08,
- FW_PORT_L2_CTLBF_IVLAN = 0x10,
- FW_PORT_L2_CTLBF_TXIPG = 0x20,
- FW_PORT_L2_CTLBF_MTU = 0x40
-};
-
-enum fw_dcb_app_tlv_sf {
- FW_DCB_APP_SF_ETHERTYPE,
- FW_DCB_APP_SF_SOCKET_TCP,
- FW_DCB_APP_SF_SOCKET_UDP,
- FW_DCB_APP_SF_SOCKET_ALL,
-};
-
-enum fw_port_dcb_versions {
- FW_PORT_DCB_VER_CEE1D0,
- FW_PORT_DCB_VER_CEE1D01,
- FW_PORT_DCB_VER_IEEE,
- FW_PORT_DCB_VER_UNKNOWN=7
-};
-
-enum fw_port_dcb_cfg {
- FW_PORT_DCB_CFG_PG = 0x01,
- FW_PORT_DCB_CFG_PFC = 0x02,
- FW_PORT_DCB_CFG_APPL = 0x04
-};
-
-enum fw_port_dcb_cfg_rc {
- FW_PORT_DCB_CFG_SUCCESS = 0x0,
- FW_PORT_DCB_CFG_ERROR = 0x1
-};
-
-enum fw_port_dcb_type {
- FW_PORT_DCB_TYPE_PGID = 0x00,
- FW_PORT_DCB_TYPE_PGRATE = 0x01,
- FW_PORT_DCB_TYPE_PRIORATE = 0x02,
- FW_PORT_DCB_TYPE_PFC = 0x03,
- FW_PORT_DCB_TYPE_APP_ID = 0x04,
- FW_PORT_DCB_TYPE_CONTROL = 0x05,
-};
-
-enum fw_port_dcb_feature_state {
- FW_PORT_DCB_FEATURE_STATE_PENDING = 0x0,
- FW_PORT_DCB_FEATURE_STATE_SUCCESS = 0x1,
- FW_PORT_DCB_FEATURE_STATE_ERROR = 0x2,
- FW_PORT_DCB_FEATURE_STATE_TIMEOUT = 0x3,
-};
-
-enum fw_port_diag_ops {
- FW_PORT_DIAGS_TEMP = 0x00,
- FW_PORT_DIAGS_TX_POWER = 0x01,
- FW_PORT_DIAGS_RX_POWER = 0x02,
-};
-
-struct fw_port_cmd {
- __be32 op_to_portid;
- __be32 action_to_len16;
- union fw_port {
- struct fw_port_l1cfg {
- __be32 rcap;
- __be32 r;
- } l1cfg;
- struct fw_port_l2cfg {
- __u8 ctlbf;
- __u8 ovlan3_to_ivlan0;
- __be16 ivlantype;
- __be16 txipg_force_pinfo;
- __be16 mtu;
- __be16 ovlan0mask;
- __be16 ovlan0type;
- __be16 ovlan1mask;
- __be16 ovlan1type;
- __be16 ovlan2mask;
- __be16 ovlan2type;
- __be16 ovlan3mask;
- __be16 ovlan3type;
- } l2cfg;
- struct fw_port_info {
- __be32 lstatus_to_modtype;
- __be16 pcap;
- __be16 acap;
- __be16 mtu;
- __u8 cbllen;
- __u8 auxlinfo;
- __u8 dcbxdis_pkd;
- __u8 r8_lo[3];
- __be64 r9;
- } info;
- struct fw_port_diags {
- __u8 diagop;
- __u8 r[3];
- __be32 diagval;
- } diags;
- union fw_port_dcb {
- struct fw_port_dcb_pgid {
- __u8 type;
- __u8 apply_pkd;
- __u8 r10_lo[2];
- __be32 pgid;
- __be64 r11;
- } pgid;
- struct fw_port_dcb_pgrate {
- __u8 type;
- __u8 apply_pkd;
- __u8 r10_lo[5];
- __u8 num_tcs_supported;
- __u8 pgrate[8];
- } pgrate;
- struct fw_port_dcb_priorate {
- __u8 type;
- __u8 apply_pkd;
- __u8 r10_lo[6];
- __u8 strict_priorate[8];
- } priorate;
- struct fw_port_dcb_pfc {
- __u8 type;
- __u8 pfcen;
- __be16 r10[3];
- __be64 r11;
- } pfc;
- struct fw_port_app_priority {
- __u8 type;
- __u8 r10[2];
- __u8 idx;
- __u8 user_prio_map;
- __u8 sel_field;
- __be16 protocolid;
- __be64 r12;
- } app_priority;
- struct fw_port_dcb_control {
- __u8 type;
- __u8 all_syncd_pkd;
- __be16 pfc_state_to_app_state;
- __be32 r11;
- __be64 r12;
- } control;
- } dcb;
- } u;
-};
-
-#define S_FW_PORT_CMD_READ 22
-#define M_FW_PORT_CMD_READ 0x1
-#define V_FW_PORT_CMD_READ(x) ((x) << S_FW_PORT_CMD_READ)
-#define G_FW_PORT_CMD_READ(x) \
- (((x) >> S_FW_PORT_CMD_READ) & M_FW_PORT_CMD_READ)
-#define F_FW_PORT_CMD_READ V_FW_PORT_CMD_READ(1U)
-
-#define S_FW_PORT_CMD_PORTID 0
-#define M_FW_PORT_CMD_PORTID 0xf
-#define V_FW_PORT_CMD_PORTID(x) ((x) << S_FW_PORT_CMD_PORTID)
-#define G_FW_PORT_CMD_PORTID(x) \
- (((x) >> S_FW_PORT_CMD_PORTID) & M_FW_PORT_CMD_PORTID)
-
-#define S_FW_PORT_CMD_ACTION 16
-#define M_FW_PORT_CMD_ACTION 0xffff
-#define V_FW_PORT_CMD_ACTION(x) ((x) << S_FW_PORT_CMD_ACTION)
-#define G_FW_PORT_CMD_ACTION(x) \
- (((x) >> S_FW_PORT_CMD_ACTION) & M_FW_PORT_CMD_ACTION)
-
-#define S_FW_PORT_CMD_OVLAN3 7
-#define M_FW_PORT_CMD_OVLAN3 0x1
-#define V_FW_PORT_CMD_OVLAN3(x) ((x) << S_FW_PORT_CMD_OVLAN3)
-#define G_FW_PORT_CMD_OVLAN3(x) \
- (((x) >> S_FW_PORT_CMD_OVLAN3) & M_FW_PORT_CMD_OVLAN3)
-#define F_FW_PORT_CMD_OVLAN3 V_FW_PORT_CMD_OVLAN3(1U)
-
-#define S_FW_PORT_CMD_OVLAN2 6
-#define M_FW_PORT_CMD_OVLAN2 0x1
-#define V_FW_PORT_CMD_OVLAN2(x) ((x) << S_FW_PORT_CMD_OVLAN2)
-#define G_FW_PORT_CMD_OVLAN2(x) \
- (((x) >> S_FW_PORT_CMD_OVLAN2) & M_FW_PORT_CMD_OVLAN2)
-#define F_FW_PORT_CMD_OVLAN2 V_FW_PORT_CMD_OVLAN2(1U)
-
-#define S_FW_PORT_CMD_OVLAN1 5
-#define M_FW_PORT_CMD_OVLAN1 0x1
-#define V_FW_PORT_CMD_OVLAN1(x) ((x) << S_FW_PORT_CMD_OVLAN1)
-#define G_FW_PORT_CMD_OVLAN1(x) \
- (((x) >> S_FW_PORT_CMD_OVLAN1) & M_FW_PORT_CMD_OVLAN1)
-#define F_FW_PORT_CMD_OVLAN1 V_FW_PORT_CMD_OVLAN1(1U)
-
-#define S_FW_PORT_CMD_OVLAN0 4
-#define M_FW_PORT_CMD_OVLAN0 0x1
-#define V_FW_PORT_CMD_OVLAN0(x) ((x) << S_FW_PORT_CMD_OVLAN0)
-#define G_FW_PORT_CMD_OVLAN0(x) \
- (((x) >> S_FW_PORT_CMD_OVLAN0) & M_FW_PORT_CMD_OVLAN0)
-#define F_FW_PORT_CMD_OVLAN0 V_FW_PORT_CMD_OVLAN0(1U)
-
-#define S_FW_PORT_CMD_IVLAN0 3
-#define M_FW_PORT_CMD_IVLAN0 0x1
-#define V_FW_PORT_CMD_IVLAN0(x) ((x) << S_FW_PORT_CMD_IVLAN0)
-#define G_FW_PORT_CMD_IVLAN0(x) \
- (((x) >> S_FW_PORT_CMD_IVLAN0) & M_FW_PORT_CMD_IVLAN0)
-#define F_FW_PORT_CMD_IVLAN0 V_FW_PORT_CMD_IVLAN0(1U)
-
-#define S_FW_PORT_CMD_TXIPG 3
-#define M_FW_PORT_CMD_TXIPG 0x1fff
-#define V_FW_PORT_CMD_TXIPG(x) ((x) << S_FW_PORT_CMD_TXIPG)
-#define G_FW_PORT_CMD_TXIPG(x) \
- (((x) >> S_FW_PORT_CMD_TXIPG) & M_FW_PORT_CMD_TXIPG)
-
-#define S_FW_PORT_CMD_FORCE_PINFO 0
-#define M_FW_PORT_CMD_FORCE_PINFO 0x1
-#define V_FW_PORT_CMD_FORCE_PINFO(x) ((x) << S_FW_PORT_CMD_FORCE_PINFO)
-#define G_FW_PORT_CMD_FORCE_PINFO(x) \
- (((x) >> S_FW_PORT_CMD_FORCE_PINFO) & M_FW_PORT_CMD_FORCE_PINFO)
-#define F_FW_PORT_CMD_FORCE_PINFO V_FW_PORT_CMD_FORCE_PINFO(1U)
-
-#define S_FW_PORT_CMD_LSTATUS 31
-#define M_FW_PORT_CMD_LSTATUS 0x1
-#define V_FW_PORT_CMD_LSTATUS(x) ((x) << S_FW_PORT_CMD_LSTATUS)
-#define G_FW_PORT_CMD_LSTATUS(x) \
- (((x) >> S_FW_PORT_CMD_LSTATUS) & M_FW_PORT_CMD_LSTATUS)
-#define F_FW_PORT_CMD_LSTATUS V_FW_PORT_CMD_LSTATUS(1U)
-
-#define S_FW_PORT_CMD_LSPEED 24
-#define M_FW_PORT_CMD_LSPEED 0x3f
-#define V_FW_PORT_CMD_LSPEED(x) ((x) << S_FW_PORT_CMD_LSPEED)
-#define G_FW_PORT_CMD_LSPEED(x) \
- (((x) >> S_FW_PORT_CMD_LSPEED) & M_FW_PORT_CMD_LSPEED)
-
-#define S_FW_PORT_CMD_TXPAUSE 23
-#define M_FW_PORT_CMD_TXPAUSE 0x1
-#define V_FW_PORT_CMD_TXPAUSE(x) ((x) << S_FW_PORT_CMD_TXPAUSE)
-#define G_FW_PORT_CMD_TXPAUSE(x) \
- (((x) >> S_FW_PORT_CMD_TXPAUSE) & M_FW_PORT_CMD_TXPAUSE)
-#define F_FW_PORT_CMD_TXPAUSE V_FW_PORT_CMD_TXPAUSE(1U)
-
-#define S_FW_PORT_CMD_RXPAUSE 22
-#define M_FW_PORT_CMD_RXPAUSE 0x1
-#define V_FW_PORT_CMD_RXPAUSE(x) ((x) << S_FW_PORT_CMD_RXPAUSE)
-#define G_FW_PORT_CMD_RXPAUSE(x) \
- (((x) >> S_FW_PORT_CMD_RXPAUSE) & M_FW_PORT_CMD_RXPAUSE)
-#define F_FW_PORT_CMD_RXPAUSE V_FW_PORT_CMD_RXPAUSE(1U)
-
-#define S_FW_PORT_CMD_MDIOCAP 21
-#define M_FW_PORT_CMD_MDIOCAP 0x1
-#define V_FW_PORT_CMD_MDIOCAP(x) ((x) << S_FW_PORT_CMD_MDIOCAP)
-#define G_FW_PORT_CMD_MDIOCAP(x) \
- (((x) >> S_FW_PORT_CMD_MDIOCAP) & M_FW_PORT_CMD_MDIOCAP)
-#define F_FW_PORT_CMD_MDIOCAP V_FW_PORT_CMD_MDIOCAP(1U)
-
-#define S_FW_PORT_CMD_MDIOADDR 16
-#define M_FW_PORT_CMD_MDIOADDR 0x1f
-#define V_FW_PORT_CMD_MDIOADDR(x) ((x) << S_FW_PORT_CMD_MDIOADDR)
-#define G_FW_PORT_CMD_MDIOADDR(x) \
- (((x) >> S_FW_PORT_CMD_MDIOADDR) & M_FW_PORT_CMD_MDIOADDR)
-
-#define S_FW_PORT_CMD_LPTXPAUSE 15
-#define M_FW_PORT_CMD_LPTXPAUSE 0x1
-#define V_FW_PORT_CMD_LPTXPAUSE(x) ((x) << S_FW_PORT_CMD_LPTXPAUSE)
-#define G_FW_PORT_CMD_LPTXPAUSE(x) \
- (((x) >> S_FW_PORT_CMD_LPTXPAUSE) & M_FW_PORT_CMD_LPTXPAUSE)
-#define F_FW_PORT_CMD_LPTXPAUSE V_FW_PORT_CMD_LPTXPAUSE(1U)
-
-#define S_FW_PORT_CMD_LPRXPAUSE 14
-#define M_FW_PORT_CMD_LPRXPAUSE 0x1
-#define V_FW_PORT_CMD_LPRXPAUSE(x) ((x) << S_FW_PORT_CMD_LPRXPAUSE)
-#define G_FW_PORT_CMD_LPRXPAUSE(x) \
- (((x) >> S_FW_PORT_CMD_LPRXPAUSE) & M_FW_PORT_CMD_LPRXPAUSE)
-#define F_FW_PORT_CMD_LPRXPAUSE V_FW_PORT_CMD_LPRXPAUSE(1U)
-
-#define S_FW_PORT_CMD_PTYPE 8
-#define M_FW_PORT_CMD_PTYPE 0x1f
-#define V_FW_PORT_CMD_PTYPE(x) ((x) << S_FW_PORT_CMD_PTYPE)
-#define G_FW_PORT_CMD_PTYPE(x) \
- (((x) >> S_FW_PORT_CMD_PTYPE) & M_FW_PORT_CMD_PTYPE)
-
-#define S_FW_PORT_CMD_LINKDNRC 5
-#define M_FW_PORT_CMD_LINKDNRC 0x7
-#define V_FW_PORT_CMD_LINKDNRC(x) ((x) << S_FW_PORT_CMD_LINKDNRC)
-#define G_FW_PORT_CMD_LINKDNRC(x) \
- (((x) >> S_FW_PORT_CMD_LINKDNRC) & M_FW_PORT_CMD_LINKDNRC)
-
-#define S_FW_PORT_CMD_MODTYPE 0
-#define M_FW_PORT_CMD_MODTYPE 0x1f
-#define V_FW_PORT_CMD_MODTYPE(x) ((x) << S_FW_PORT_CMD_MODTYPE)
-#define G_FW_PORT_CMD_MODTYPE(x) \
- (((x) >> S_FW_PORT_CMD_MODTYPE) & M_FW_PORT_CMD_MODTYPE)
-
-#define S_FW_PORT_CMD_DCBXDIS 7
-#define M_FW_PORT_CMD_DCBXDIS 0x1
-#define V_FW_PORT_CMD_DCBXDIS(x) ((x) << S_FW_PORT_CMD_DCBXDIS)
-#define G_FW_PORT_CMD_DCBXDIS(x) \
- (((x) >> S_FW_PORT_CMD_DCBXDIS) & M_FW_PORT_CMD_DCBXDIS)
-#define F_FW_PORT_CMD_DCBXDIS V_FW_PORT_CMD_DCBXDIS(1U)
-
-#define S_FW_PORT_CMD_APPLY 7
-#define M_FW_PORT_CMD_APPLY 0x1
-#define V_FW_PORT_CMD_APPLY(x) ((x) << S_FW_PORT_CMD_APPLY)
-#define G_FW_PORT_CMD_APPLY(x) \
- (((x) >> S_FW_PORT_CMD_APPLY) & M_FW_PORT_CMD_APPLY)
-#define F_FW_PORT_CMD_APPLY V_FW_PORT_CMD_APPLY(1U)
-
-#define S_FW_PORT_CMD_ALL_SYNCD 7
-#define M_FW_PORT_CMD_ALL_SYNCD 0x1
-#define V_FW_PORT_CMD_ALL_SYNCD(x) ((x) << S_FW_PORT_CMD_ALL_SYNCD)
-#define G_FW_PORT_CMD_ALL_SYNCD(x) \
- (((x) >> S_FW_PORT_CMD_ALL_SYNCD) & M_FW_PORT_CMD_ALL_SYNCD)
-#define F_FW_PORT_CMD_ALL_SYNCD V_FW_PORT_CMD_ALL_SYNCD(1U)
-
-#define S_FW_PORT_CMD_PFC_STATE 8
-#define M_FW_PORT_CMD_PFC_STATE 0xf
-#define V_FW_PORT_CMD_PFC_STATE(x) ((x) << S_FW_PORT_CMD_PFC_STATE)
-#define G_FW_PORT_CMD_PFC_STATE(x) \
- (((x) >> S_FW_PORT_CMD_PFC_STATE) & M_FW_PORT_CMD_PFC_STATE)
-
-#define S_FW_PORT_CMD_ETS_STATE 4
-#define M_FW_PORT_CMD_ETS_STATE 0xf
-#define V_FW_PORT_CMD_ETS_STATE(x) ((x) << S_FW_PORT_CMD_ETS_STATE)
-#define G_FW_PORT_CMD_ETS_STATE(x) \
- (((x) >> S_FW_PORT_CMD_ETS_STATE) & M_FW_PORT_CMD_ETS_STATE)
-
-#define S_FW_PORT_CMD_APP_STATE 0
-#define M_FW_PORT_CMD_APP_STATE 0xf
-#define V_FW_PORT_CMD_APP_STATE(x) ((x) << S_FW_PORT_CMD_APP_STATE)
-#define G_FW_PORT_CMD_APP_STATE(x) \
- (((x) >> S_FW_PORT_CMD_APP_STATE) & M_FW_PORT_CMD_APP_STATE)
-
-/*
- * These are configured into the VPD and hence tools that generate
- * VPD may use this enumeration.
- * extPHY #lanes T4_I2C extI2C BP_Eq BP_ANEG Speed
- *
- * REMEMBER:
- * Update the Common Code t4_hw.c:t4_get_port_type_description()
- * with any new Firmware Port Technology Types!
- */
-enum fw_port_type {
- FW_PORT_TYPE_FIBER_XFI = 0, /* Y, 1, N, Y, N, N, 10G */
- FW_PORT_TYPE_FIBER_XAUI = 1, /* Y, 4, N, Y, N, N, 10G */
- FW_PORT_TYPE_BT_SGMII = 2, /* Y, 1, No, No, No, No, 1G/100M */
- FW_PORT_TYPE_BT_XFI = 3, /* Y, 1, No, No, No, No, 10G */
- FW_PORT_TYPE_BT_XAUI = 4, /* Y, 4, No, No, No, No, 10G/1G/100M? */
- FW_PORT_TYPE_KX4 = 5, /* No, 4, No, No, Yes, Yes, 10G */
- FW_PORT_TYPE_CX4 = 6, /* No, 4, No, No, No, No, 10G */
- FW_PORT_TYPE_KX = 7, /* No, 1, No, No, Yes, No, 1G */
- FW_PORT_TYPE_KR = 8, /* No, 1, No, No, Yes, Yes, 10G */
- FW_PORT_TYPE_SFP = 9, /* No, 1, Yes, No, No, No, 10G */
- FW_PORT_TYPE_BP_AP = 10, /* No, 1, No, No, Yes, Yes, 10G, BP ANGE */
- FW_PORT_TYPE_BP4_AP = 11, /* No, 4, No, No, Yes, Yes, 10G, BP ANGE */
- FW_PORT_TYPE_QSFP_10G = 12, /* No, 1, Yes, No, No, No, 10G */
- FW_PORT_TYPE_QSFP = 14, /* No, 4, Yes, No, No, No, 40G */
- FW_PORT_TYPE_BP40_BA = 15, /* No, 4, No, No, Yes, Yes, 40G/10G/1G, BP ANGE */
-
- FW_PORT_TYPE_NONE = M_FW_PORT_CMD_PTYPE
-};
-
-/* These are read from module's EEPROM and determined once the
- module is inserted. */
-enum fw_port_module_type {
- FW_PORT_MOD_TYPE_NA = 0x0,
- FW_PORT_MOD_TYPE_LR = 0x1,
- FW_PORT_MOD_TYPE_SR = 0x2,
- FW_PORT_MOD_TYPE_ER = 0x3,
- FW_PORT_MOD_TYPE_TWINAX_PASSIVE = 0x4,
- FW_PORT_MOD_TYPE_TWINAX_ACTIVE = 0x5,
- FW_PORT_MOD_TYPE_LRM = 0x6,
- FW_PORT_MOD_TYPE_ERROR = M_FW_PORT_CMD_MODTYPE - 3,
- FW_PORT_MOD_TYPE_UNKNOWN = M_FW_PORT_CMD_MODTYPE - 2,
- FW_PORT_MOD_TYPE_NOTSUPPORTED = M_FW_PORT_CMD_MODTYPE - 1,
- FW_PORT_MOD_TYPE_NONE = M_FW_PORT_CMD_MODTYPE
-};
-
-/* used by FW and tools may use this to generate VPD */
-enum fw_port_mod_sub_type {
- FW_PORT_MOD_SUB_TYPE_NA,
- FW_PORT_MOD_SUB_TYPE_MV88E114X=0x1,
- FW_PORT_MOD_SUB_TYPE_TN8022=0x2,
- FW_PORT_MOD_SUB_TYPE_AQ1202=0x3,
- FW_PORT_MOD_SUB_TYPE_88x3120=0x4,
- FW_PORT_MOD_SUB_TYPE_BCM84834=0x5,
- FW_PORT_MOD_SUB_TYPE_BCM5482=0x6,
- FW_PORT_MOD_SUB_TYPE_BT_VSC8634=0x8,
-
- /*
- * The following will never been in the VPD. They are TWINAX cable
- * lengths decoded from SFP+ module i2c PROMs. These should almost
- * certainly go somewhere else ...
- */
- FW_PORT_MOD_SUB_TYPE_TWINAX_1=0x9,
- FW_PORT_MOD_SUB_TYPE_TWINAX_3=0xA,
- FW_PORT_MOD_SUB_TYPE_TWINAX_5=0xB,
- FW_PORT_MOD_SUB_TYPE_TWINAX_7=0xC,
-};
-
-/* link down reason codes (3b) */
-enum fw_port_link_dn_rc {
- FW_PORT_LINK_DN_RC_NONE,
- FW_PORT_LINK_DN_RC_REMFLT, /* Remote fault detected */
- FW_PORT_LINK_DN_ANEG_F, /* Auto-negotiation fault */
- FW_PORT_LINK_DN_RESERVED3,
- FW_PORT_LINK_DN_OVERHEAT, /* Port overheated */
- FW_PORT_LINK_DN_UNKNOWN, /* Unable to determine reason */
- FW_PORT_LINK_DN_RX_LOS, /* No RX signal detected */
- FW_PORT_LINK_DN_RESERVED7
-};
-
-/* port stats */
-#define FW_NUM_PORT_STATS 50
-#define FW_NUM_PORT_TX_STATS 23
-#define FW_NUM_PORT_RX_STATS 27
-
-enum fw_port_stats_tx_index {
- FW_STAT_TX_PORT_BYTES_IX,
- FW_STAT_TX_PORT_FRAMES_IX,
- FW_STAT_TX_PORT_BCAST_IX,
- FW_STAT_TX_PORT_MCAST_IX,
- FW_STAT_TX_PORT_UCAST_IX,
- FW_STAT_TX_PORT_ERROR_IX,
- FW_STAT_TX_PORT_64B_IX,
- FW_STAT_TX_PORT_65B_127B_IX,
- FW_STAT_TX_PORT_128B_255B_IX,
- FW_STAT_TX_PORT_256B_511B_IX,
- FW_STAT_TX_PORT_512B_1023B_IX,
- FW_STAT_TX_PORT_1024B_1518B_IX,
- FW_STAT_TX_PORT_1519B_MAX_IX,
- FW_STAT_TX_PORT_DROP_IX,
- FW_STAT_TX_PORT_PAUSE_IX,
- FW_STAT_TX_PORT_PPP0_IX,
- FW_STAT_TX_PORT_PPP1_IX,
- FW_STAT_TX_PORT_PPP2_IX,
- FW_STAT_TX_PORT_PPP3_IX,
- FW_STAT_TX_PORT_PPP4_IX,
- FW_STAT_TX_PORT_PPP5_IX,
- FW_STAT_TX_PORT_PPP6_IX,
- FW_STAT_TX_PORT_PPP7_IX
-};
-
-enum fw_port_stat_rx_index {
- FW_STAT_RX_PORT_BYTES_IX,
- FW_STAT_RX_PORT_FRAMES_IX,
- FW_STAT_RX_PORT_BCAST_IX,
- FW_STAT_RX_PORT_MCAST_IX,
- FW_STAT_RX_PORT_UCAST_IX,
- FW_STAT_RX_PORT_MTU_ERROR_IX,
- FW_STAT_RX_PORT_MTU_CRC_ERROR_IX,
- FW_STAT_RX_PORT_CRC_ERROR_IX,
- FW_STAT_RX_PORT_LEN_ERROR_IX,
- FW_STAT_RX_PORT_SYM_ERROR_IX,
- FW_STAT_RX_PORT_64B_IX,
- FW_STAT_RX_PORT_65B_127B_IX,
- FW_STAT_RX_PORT_128B_255B_IX,
- FW_STAT_RX_PORT_256B_511B_IX,
- FW_STAT_RX_PORT_512B_1023B_IX,
- FW_STAT_RX_PORT_1024B_1518B_IX,
- FW_STAT_RX_PORT_1519B_MAX_IX,
- FW_STAT_RX_PORT_PAUSE_IX,
- FW_STAT_RX_PORT_PPP0_IX,
- FW_STAT_RX_PORT_PPP1_IX,
- FW_STAT_RX_PORT_PPP2_IX,
- FW_STAT_RX_PORT_PPP3_IX,
- FW_STAT_RX_PORT_PPP4_IX,
- FW_STAT_RX_PORT_PPP5_IX,
- FW_STAT_RX_PORT_PPP6_IX,
- FW_STAT_RX_PORT_PPP7_IX,
- FW_STAT_RX_PORT_LESS_64B_IX
-};
-
-struct fw_port_stats_cmd {
- __be32 op_to_portid;
- __be32 retval_len16;
- union fw_port_stats {
- struct fw_port_stats_ctl {
- __u8 nstats_bg_bm;
- __u8 tx_ix;
- __be16 r6;
- __be32 r7;
- __be64 stat0;
- __be64 stat1;
- __be64 stat2;
- __be64 stat3;
- __be64 stat4;
- __be64 stat5;
- } ctl;
- struct fw_port_stats_all {
- __be64 tx_bytes;
- __be64 tx_frames;
- __be64 tx_bcast;
- __be64 tx_mcast;
- __be64 tx_ucast;
- __be64 tx_error;
- __be64 tx_64b;
- __be64 tx_65b_127b;
- __be64 tx_128b_255b;
- __be64 tx_256b_511b;
- __be64 tx_512b_1023b;
- __be64 tx_1024b_1518b;
- __be64 tx_1519b_max;
- __be64 tx_drop;
- __be64 tx_pause;
- __be64 tx_ppp0;
- __be64 tx_ppp1;
- __be64 tx_ppp2;
- __be64 tx_ppp3;
- __be64 tx_ppp4;
- __be64 tx_ppp5;
- __be64 tx_ppp6;
- __be64 tx_ppp7;
- __be64 rx_bytes;
- __be64 rx_frames;
- __be64 rx_bcast;
- __be64 rx_mcast;
- __be64 rx_ucast;
- __be64 rx_mtu_error;
- __be64 rx_mtu_crc_error;
- __be64 rx_crc_error;
- __be64 rx_len_error;
- __be64 rx_sym_error;
- __be64 rx_64b;
- __be64 rx_65b_127b;
- __be64 rx_128b_255b;
- __be64 rx_256b_511b;
- __be64 rx_512b_1023b;
- __be64 rx_1024b_1518b;
- __be64 rx_1519b_max;
- __be64 rx_pause;
- __be64 rx_ppp0;
- __be64 rx_ppp1;
- __be64 rx_ppp2;
- __be64 rx_ppp3;
- __be64 rx_ppp4;
- __be64 rx_ppp5;
- __be64 rx_ppp6;
- __be64 rx_ppp7;
- __be64 rx_less_64b;
- __be64 rx_bg_drop;
- __be64 rx_bg_trunc;
- } all;
- } u;
-};
-
-#define S_FW_PORT_STATS_CMD_NSTATS 4
-#define M_FW_PORT_STATS_CMD_NSTATS 0x7
-#define V_FW_PORT_STATS_CMD_NSTATS(x) ((x) << S_FW_PORT_STATS_CMD_NSTATS)
-#define G_FW_PORT_STATS_CMD_NSTATS(x) \
- (((x) >> S_FW_PORT_STATS_CMD_NSTATS) & M_FW_PORT_STATS_CMD_NSTATS)
-
-#define S_FW_PORT_STATS_CMD_BG_BM 0
-#define M_FW_PORT_STATS_CMD_BG_BM 0x3
-#define V_FW_PORT_STATS_CMD_BG_BM(x) ((x) << S_FW_PORT_STATS_CMD_BG_BM)
-#define G_FW_PORT_STATS_CMD_BG_BM(x) \
- (((x) >> S_FW_PORT_STATS_CMD_BG_BM) & M_FW_PORT_STATS_CMD_BG_BM)
-
-#define S_FW_PORT_STATS_CMD_TX 7
-#define M_FW_PORT_STATS_CMD_TX 0x1
-#define V_FW_PORT_STATS_CMD_TX(x) ((x) << S_FW_PORT_STATS_CMD_TX)
-#define G_FW_PORT_STATS_CMD_TX(x) \
- (((x) >> S_FW_PORT_STATS_CMD_TX) & M_FW_PORT_STATS_CMD_TX)
-#define F_FW_PORT_STATS_CMD_TX V_FW_PORT_STATS_CMD_TX(1U)
-
-#define S_FW_PORT_STATS_CMD_IX 0
-#define M_FW_PORT_STATS_CMD_IX 0x3f
-#define V_FW_PORT_STATS_CMD_IX(x) ((x) << S_FW_PORT_STATS_CMD_IX)
-#define G_FW_PORT_STATS_CMD_IX(x) \
- (((x) >> S_FW_PORT_STATS_CMD_IX) & M_FW_PORT_STATS_CMD_IX)
-
-/* port loopback stats */
-#define FW_NUM_LB_STATS 14
-enum fw_port_lb_stats_index {
- FW_STAT_LB_PORT_BYTES_IX,
- FW_STAT_LB_PORT_FRAMES_IX,
- FW_STAT_LB_PORT_BCAST_IX,
- FW_STAT_LB_PORT_MCAST_IX,
- FW_STAT_LB_PORT_UCAST_IX,
- FW_STAT_LB_PORT_ERROR_IX,
- FW_STAT_LB_PORT_64B_IX,
- FW_STAT_LB_PORT_65B_127B_IX,
- FW_STAT_LB_PORT_128B_255B_IX,
- FW_STAT_LB_PORT_256B_511B_IX,
- FW_STAT_LB_PORT_512B_1023B_IX,
- FW_STAT_LB_PORT_1024B_1518B_IX,
- FW_STAT_LB_PORT_1519B_MAX_IX,
- FW_STAT_LB_PORT_DROP_FRAMES_IX
-};
-
-struct fw_port_lb_stats_cmd {
- __be32 op_to_lbport;
- __be32 retval_len16;
- union fw_port_lb_stats {
- struct fw_port_lb_stats_ctl {
- __u8 nstats_bg_bm;
- __u8 ix_pkd;
- __be16 r6;
- __be32 r7;
- __be64 stat0;
- __be64 stat1;
- __be64 stat2;
- __be64 stat3;
- __be64 stat4;
- __be64 stat5;
- } ctl;
- struct fw_port_lb_stats_all {
- __be64 tx_bytes;
- __be64 tx_frames;
- __be64 tx_bcast;
- __be64 tx_mcast;
- __be64 tx_ucast;
- __be64 tx_error;
- __be64 tx_64b;
- __be64 tx_65b_127b;
- __be64 tx_128b_255b;
- __be64 tx_256b_511b;
- __be64 tx_512b_1023b;
- __be64 tx_1024b_1518b;
- __be64 tx_1519b_max;
- __be64 rx_lb_drop;
- __be64 rx_lb_trunc;
- } all;
- } u;
-};
-
-#define S_FW_PORT_LB_STATS_CMD_LBPORT 0
-#define M_FW_PORT_LB_STATS_CMD_LBPORT 0xf
-#define V_FW_PORT_LB_STATS_CMD_LBPORT(x) \
- ((x) << S_FW_PORT_LB_STATS_CMD_LBPORT)
-#define G_FW_PORT_LB_STATS_CMD_LBPORT(x) \
- (((x) >> S_FW_PORT_LB_STATS_CMD_LBPORT) & M_FW_PORT_LB_STATS_CMD_LBPORT)
-
-#define S_FW_PORT_LB_STATS_CMD_NSTATS 4
-#define M_FW_PORT_LB_STATS_CMD_NSTATS 0x7
-#define V_FW_PORT_LB_STATS_CMD_NSTATS(x) \
- ((x) << S_FW_PORT_LB_STATS_CMD_NSTATS)
-#define G_FW_PORT_LB_STATS_CMD_NSTATS(x) \
- (((x) >> S_FW_PORT_LB_STATS_CMD_NSTATS) & M_FW_PORT_LB_STATS_CMD_NSTATS)
-
-#define S_FW_PORT_LB_STATS_CMD_BG_BM 0
-#define M_FW_PORT_LB_STATS_CMD_BG_BM 0x3
-#define V_FW_PORT_LB_STATS_CMD_BG_BM(x) ((x) << S_FW_PORT_LB_STATS_CMD_BG_BM)
-#define G_FW_PORT_LB_STATS_CMD_BG_BM(x) \
- (((x) >> S_FW_PORT_LB_STATS_CMD_BG_BM) & M_FW_PORT_LB_STATS_CMD_BG_BM)
-
-#define S_FW_PORT_LB_STATS_CMD_IX 0
-#define M_FW_PORT_LB_STATS_CMD_IX 0xf
-#define V_FW_PORT_LB_STATS_CMD_IX(x) ((x) << S_FW_PORT_LB_STATS_CMD_IX)
-#define G_FW_PORT_LB_STATS_CMD_IX(x) \
- (((x) >> S_FW_PORT_LB_STATS_CMD_IX) & M_FW_PORT_LB_STATS_CMD_IX)
-
-/* Trace related defines */
-#define FW_TRACE_CAPTURE_MAX_SINGLE_FLT_MODE 10240
-#define FW_TRACE_CAPTURE_MAX_MULTI_FLT_MODE 2560
-
-struct fw_port_trace_cmd {
- __be32 op_to_portid;
- __be32 retval_len16;
- __be16 traceen_to_pciech;
- __be16 qnum;
- __be32 r5;
-};
-
-#define S_FW_PORT_TRACE_CMD_PORTID 0
-#define M_FW_PORT_TRACE_CMD_PORTID 0xf
-#define V_FW_PORT_TRACE_CMD_PORTID(x) ((x) << S_FW_PORT_TRACE_CMD_PORTID)
-#define G_FW_PORT_TRACE_CMD_PORTID(x) \
- (((x) >> S_FW_PORT_TRACE_CMD_PORTID) & M_FW_PORT_TRACE_CMD_PORTID)
-
-#define S_FW_PORT_TRACE_CMD_TRACEEN 15
-#define M_FW_PORT_TRACE_CMD_TRACEEN 0x1
-#define V_FW_PORT_TRACE_CMD_TRACEEN(x) ((x) << S_FW_PORT_TRACE_CMD_TRACEEN)
-#define G_FW_PORT_TRACE_CMD_TRACEEN(x) \
- (((x) >> S_FW_PORT_TRACE_CMD_TRACEEN) & M_FW_PORT_TRACE_CMD_TRACEEN)
-#define F_FW_PORT_TRACE_CMD_TRACEEN V_FW_PORT_TRACE_CMD_TRACEEN(1U)
-
-#define S_FW_PORT_TRACE_CMD_FLTMODE 14
-#define M_FW_PORT_TRACE_CMD_FLTMODE 0x1
-#define V_FW_PORT_TRACE_CMD_FLTMODE(x) ((x) << S_FW_PORT_TRACE_CMD_FLTMODE)
-#define G_FW_PORT_TRACE_CMD_FLTMODE(x) \
- (((x) >> S_FW_PORT_TRACE_CMD_FLTMODE) & M_FW_PORT_TRACE_CMD_FLTMODE)
-#define F_FW_PORT_TRACE_CMD_FLTMODE V_FW_PORT_TRACE_CMD_FLTMODE(1U)
-
-#define S_FW_PORT_TRACE_CMD_DUPLEN 13
-#define M_FW_PORT_TRACE_CMD_DUPLEN 0x1
-#define V_FW_PORT_TRACE_CMD_DUPLEN(x) ((x) << S_FW_PORT_TRACE_CMD_DUPLEN)
-#define G_FW_PORT_TRACE_CMD_DUPLEN(x) \
- (((x) >> S_FW_PORT_TRACE_CMD_DUPLEN) & M_FW_PORT_TRACE_CMD_DUPLEN)
-#define F_FW_PORT_TRACE_CMD_DUPLEN V_FW_PORT_TRACE_CMD_DUPLEN(1U)
-
-#define S_FW_PORT_TRACE_CMD_RUNTFLTSIZE 8
-#define M_FW_PORT_TRACE_CMD_RUNTFLTSIZE 0x1f
-#define V_FW_PORT_TRACE_CMD_RUNTFLTSIZE(x) \
- ((x) << S_FW_PORT_TRACE_CMD_RUNTFLTSIZE)
-#define G_FW_PORT_TRACE_CMD_RUNTFLTSIZE(x) \
- (((x) >> S_FW_PORT_TRACE_CMD_RUNTFLTSIZE) & \
- M_FW_PORT_TRACE_CMD_RUNTFLTSIZE)
-
-#define S_FW_PORT_TRACE_CMD_PCIECH 6
-#define M_FW_PORT_TRACE_CMD_PCIECH 0x3
-#define V_FW_PORT_TRACE_CMD_PCIECH(x) ((x) << S_FW_PORT_TRACE_CMD_PCIECH)
-#define G_FW_PORT_TRACE_CMD_PCIECH(x) \
- (((x) >> S_FW_PORT_TRACE_CMD_PCIECH) & M_FW_PORT_TRACE_CMD_PCIECH)
-
-struct fw_port_trace_mmap_cmd {
- __be32 op_to_portid;
- __be32 retval_len16;
- __be32 fid_to_skipoffset;
- __be32 minpktsize_capturemax;
- __u8 map[224];
-};
-
-#define S_FW_PORT_TRACE_MMAP_CMD_PORTID 0
-#define M_FW_PORT_TRACE_MMAP_CMD_PORTID 0xf
-#define V_FW_PORT_TRACE_MMAP_CMD_PORTID(x) \
- ((x) << S_FW_PORT_TRACE_MMAP_CMD_PORTID)
-#define G_FW_PORT_TRACE_MMAP_CMD_PORTID(x) \
- (((x) >> S_FW_PORT_TRACE_MMAP_CMD_PORTID) & \
- M_FW_PORT_TRACE_MMAP_CMD_PORTID)
-
-#define S_FW_PORT_TRACE_MMAP_CMD_FID 30
-#define M_FW_PORT_TRACE_MMAP_CMD_FID 0x3
-#define V_FW_PORT_TRACE_MMAP_CMD_FID(x) ((x) << S_FW_PORT_TRACE_MMAP_CMD_FID)
-#define G_FW_PORT_TRACE_MMAP_CMD_FID(x) \
- (((x) >> S_FW_PORT_TRACE_MMAP_CMD_FID) & M_FW_PORT_TRACE_MMAP_CMD_FID)
-
-#define S_FW_PORT_TRACE_MMAP_CMD_MMAPEN 29
-#define M_FW_PORT_TRACE_MMAP_CMD_MMAPEN 0x1
-#define V_FW_PORT_TRACE_MMAP_CMD_MMAPEN(x) \
- ((x) << S_FW_PORT_TRACE_MMAP_CMD_MMAPEN)
-#define G_FW_PORT_TRACE_MMAP_CMD_MMAPEN(x) \
- (((x) >> S_FW_PORT_TRACE_MMAP_CMD_MMAPEN) & \
- M_FW_PORT_TRACE_MMAP_CMD_MMAPEN)
-#define F_FW_PORT_TRACE_MMAP_CMD_MMAPEN V_FW_PORT_TRACE_MMAP_CMD_MMAPEN(1U)
-
-#define S_FW_PORT_TRACE_MMAP_CMD_DCMAPEN 28
-#define M_FW_PORT_TRACE_MMAP_CMD_DCMAPEN 0x1
-#define V_FW_PORT_TRACE_MMAP_CMD_DCMAPEN(x) \
- ((x) << S_FW_PORT_TRACE_MMAP_CMD_DCMAPEN)
-#define G_FW_PORT_TRACE_MMAP_CMD_DCMAPEN(x) \
- (((x) >> S_FW_PORT_TRACE_MMAP_CMD_DCMAPEN) & \
- M_FW_PORT_TRACE_MMAP_CMD_DCMAPEN)
-#define F_FW_PORT_TRACE_MMAP_CMD_DCMAPEN \
- V_FW_PORT_TRACE_MMAP_CMD_DCMAPEN(1U)
-
-#define S_FW_PORT_TRACE_MMAP_CMD_SKIPLENGTH 8
-#define M_FW_PORT_TRACE_MMAP_CMD_SKIPLENGTH 0x1f
-#define V_FW_PORT_TRACE_MMAP_CMD_SKIPLENGTH(x) \
- ((x) << S_FW_PORT_TRACE_MMAP_CMD_SKIPLENGTH)
-#define G_FW_PORT_TRACE_MMAP_CMD_SKIPLENGTH(x) \
- (((x) >> S_FW_PORT_TRACE_MMAP_CMD_SKIPLENGTH) & \
- M_FW_PORT_TRACE_MMAP_CMD_SKIPLENGTH)
-
-#define S_FW_PORT_TRACE_MMAP_CMD_SKIPOFFSET 0
-#define M_FW_PORT_TRACE_MMAP_CMD_SKIPOFFSET 0x1f
-#define V_FW_PORT_TRACE_MMAP_CMD_SKIPOFFSET(x) \
- ((x) << S_FW_PORT_TRACE_MMAP_CMD_SKIPOFFSET)
-#define G_FW_PORT_TRACE_MMAP_CMD_SKIPOFFSET(x) \
- (((x) >> S_FW_PORT_TRACE_MMAP_CMD_SKIPOFFSET) & \
- M_FW_PORT_TRACE_MMAP_CMD_SKIPOFFSET)
-
-#define S_FW_PORT_TRACE_MMAP_CMD_MINPKTSIZE 18
-#define M_FW_PORT_TRACE_MMAP_CMD_MINPKTSIZE 0x3fff
-#define V_FW_PORT_TRACE_MMAP_CMD_MINPKTSIZE(x) \
- ((x) << S_FW_PORT_TRACE_MMAP_CMD_MINPKTSIZE)
-#define G_FW_PORT_TRACE_MMAP_CMD_MINPKTSIZE(x) \
- (((x) >> S_FW_PORT_TRACE_MMAP_CMD_MINPKTSIZE) & \
- M_FW_PORT_TRACE_MMAP_CMD_MINPKTSIZE)
-
-#define S_FW_PORT_TRACE_MMAP_CMD_CAPTUREMAX 0
-#define M_FW_PORT_TRACE_MMAP_CMD_CAPTUREMAX 0x3fff
-#define V_FW_PORT_TRACE_MMAP_CMD_CAPTUREMAX(x) \
- ((x) << S_FW_PORT_TRACE_MMAP_CMD_CAPTUREMAX)
-#define G_FW_PORT_TRACE_MMAP_CMD_CAPTUREMAX(x) \
- (((x) >> S_FW_PORT_TRACE_MMAP_CMD_CAPTUREMAX) & \
- M_FW_PORT_TRACE_MMAP_CMD_CAPTUREMAX)
-
-struct fw_rss_ind_tbl_cmd {
- __be32 op_to_viid;
- __be32 retval_len16;
- __be16 niqid;
- __be16 startidx;
- __be32 r3;
- __be32 iq0_to_iq2;
- __be32 iq3_to_iq5;
- __be32 iq6_to_iq8;
- __be32 iq9_to_iq11;
- __be32 iq12_to_iq14;
- __be32 iq15_to_iq17;
- __be32 iq18_to_iq20;
- __be32 iq21_to_iq23;
- __be32 iq24_to_iq26;
- __be32 iq27_to_iq29;
- __be32 iq30_iq31;
- __be32 r15_lo;
-};
-
-#define S_FW_RSS_IND_TBL_CMD_VIID 0
-#define M_FW_RSS_IND_TBL_CMD_VIID 0xfff
-#define V_FW_RSS_IND_TBL_CMD_VIID(x) ((x) << S_FW_RSS_IND_TBL_CMD_VIID)
-#define G_FW_RSS_IND_TBL_CMD_VIID(x) \
- (((x) >> S_FW_RSS_IND_TBL_CMD_VIID) & M_FW_RSS_IND_TBL_CMD_VIID)
-
-#define S_FW_RSS_IND_TBL_CMD_IQ0 20
-#define M_FW_RSS_IND_TBL_CMD_IQ0 0x3ff
-#define V_FW_RSS_IND_TBL_CMD_IQ0(x) ((x) << S_FW_RSS_IND_TBL_CMD_IQ0)
-#define G_FW_RSS_IND_TBL_CMD_IQ0(x) \
- (((x) >> S_FW_RSS_IND_TBL_CMD_IQ0) & M_FW_RSS_IND_TBL_CMD_IQ0)
-
-#define S_FW_RSS_IND_TBL_CMD_IQ1 10
-#define M_FW_RSS_IND_TBL_CMD_IQ1 0x3ff
-#define V_FW_RSS_IND_TBL_CMD_IQ1(x) ((x) << S_FW_RSS_IND_TBL_CMD_IQ1)
-#define G_FW_RSS_IND_TBL_CMD_IQ1(x) \
- (((x) >> S_FW_RSS_IND_TBL_CMD_IQ1) & M_FW_RSS_IND_TBL_CMD_IQ1)
-
-#define S_FW_RSS_IND_TBL_CMD_IQ2 0
-#define M_FW_RSS_IND_TBL_CMD_IQ2 0x3ff
-#define V_FW_RSS_IND_TBL_CMD_IQ2(x) ((x) << S_FW_RSS_IND_TBL_CMD_IQ2)
-#define G_FW_RSS_IND_TBL_CMD_IQ2(x) \
- (((x) >> S_FW_RSS_IND_TBL_CMD_IQ2) & M_FW_RSS_IND_TBL_CMD_IQ2)
-
-#define S_FW_RSS_IND_TBL_CMD_IQ3 20
-#define M_FW_RSS_IND_TBL_CMD_IQ3 0x3ff
-#define V_FW_RSS_IND_TBL_CMD_IQ3(x) ((x) << S_FW_RSS_IND_TBL_CMD_IQ3)
-#define G_FW_RSS_IND_TBL_CMD_IQ3(x) \
- (((x) >> S_FW_RSS_IND_TBL_CMD_IQ3) & M_FW_RSS_IND_TBL_CMD_IQ3)
-
-#define S_FW_RSS_IND_TBL_CMD_IQ4 10
-#define M_FW_RSS_IND_TBL_CMD_IQ4 0x3ff
-#define V_FW_RSS_IND_TBL_CMD_IQ4(x) ((x) << S_FW_RSS_IND_TBL_CMD_IQ4)
-#define G_FW_RSS_IND_TBL_CMD_IQ4(x) \
- (((x) >> S_FW_RSS_IND_TBL_CMD_IQ4) & M_FW_RSS_IND_TBL_CMD_IQ4)
-
-#define S_FW_RSS_IND_TBL_CMD_IQ5 0
-#define M_FW_RSS_IND_TBL_CMD_IQ5 0x3ff
-#define V_FW_RSS_IND_TBL_CMD_IQ5(x) ((x) << S_FW_RSS_IND_TBL_CMD_IQ5)
-#define G_FW_RSS_IND_TBL_CMD_IQ5(x) \
- (((x) >> S_FW_RSS_IND_TBL_CMD_IQ5) & M_FW_RSS_IND_TBL_CMD_IQ5)
-
-#define S_FW_RSS_IND_TBL_CMD_IQ6 20
-#define M_FW_RSS_IND_TBL_CMD_IQ6 0x3ff
-#define V_FW_RSS_IND_TBL_CMD_IQ6(x) ((x) << S_FW_RSS_IND_TBL_CMD_IQ6)
-#define G_FW_RSS_IND_TBL_CMD_IQ6(x) \
- (((x) >> S_FW_RSS_IND_TBL_CMD_IQ6) & M_FW_RSS_IND_TBL_CMD_IQ6)
-
-#define S_FW_RSS_IND_TBL_CMD_IQ7 10
-#define M_FW_RSS_IND_TBL_CMD_IQ7 0x3ff
-#define V_FW_RSS_IND_TBL_CMD_IQ7(x) ((x) << S_FW_RSS_IND_TBL_CMD_IQ7)
-#define G_FW_RSS_IND_TBL_CMD_IQ7(x) \
- (((x) >> S_FW_RSS_IND_TBL_CMD_IQ7) & M_FW_RSS_IND_TBL_CMD_IQ7)
-
-#define S_FW_RSS_IND_TBL_CMD_IQ8 0
-#define M_FW_RSS_IND_TBL_CMD_IQ8 0x3ff
-#define V_FW_RSS_IND_TBL_CMD_IQ8(x) ((x) << S_FW_RSS_IND_TBL_CMD_IQ8)
-#define G_FW_RSS_IND_TBL_CMD_IQ8(x) \
- (((x) >> S_FW_RSS_IND_TBL_CMD_IQ8) & M_FW_RSS_IND_TBL_CMD_IQ8)
-
-#define S_FW_RSS_IND_TBL_CMD_IQ9 20
-#define M_FW_RSS_IND_TBL_CMD_IQ9 0x3ff
-#define V_FW_RSS_IND_TBL_CMD_IQ9(x) ((x) << S_FW_RSS_IND_TBL_CMD_IQ9)
-#define G_FW_RSS_IND_TBL_CMD_IQ9(x) \
- (((x) >> S_FW_RSS_IND_TBL_CMD_IQ9) & M_FW_RSS_IND_TBL_CMD_IQ9)
-
-#define S_FW_RSS_IND_TBL_CMD_IQ10 10
-#define M_FW_RSS_IND_TBL_CMD_IQ10 0x3ff
-#define V_FW_RSS_IND_TBL_CMD_IQ10(x) ((x) << S_FW_RSS_IND_TBL_CMD_IQ10)
-#define G_FW_RSS_IND_TBL_CMD_IQ10(x) \
- (((x) >> S_FW_RSS_IND_TBL_CMD_IQ10) & M_FW_RSS_IND_TBL_CMD_IQ10)
-
-#define S_FW_RSS_IND_TBL_CMD_IQ11 0
-#define M_FW_RSS_IND_TBL_CMD_IQ11 0x3ff
-#define V_FW_RSS_IND_TBL_CMD_IQ11(x) ((x) << S_FW_RSS_IND_TBL_CMD_IQ11)
-#define G_FW_RSS_IND_TBL_CMD_IQ11(x) \
- (((x) >> S_FW_RSS_IND_TBL_CMD_IQ11) & M_FW_RSS_IND_TBL_CMD_IQ11)
-
-#define S_FW_RSS_IND_TBL_CMD_IQ12 20
-#define M_FW_RSS_IND_TBL_CMD_IQ12 0x3ff
-#define V_FW_RSS_IND_TBL_CMD_IQ12(x) ((x) << S_FW_RSS_IND_TBL_CMD_IQ12)
-#define G_FW_RSS_IND_TBL_CMD_IQ12(x) \
- (((x) >> S_FW_RSS_IND_TBL_CMD_IQ12) & M_FW_RSS_IND_TBL_CMD_IQ12)
-
-#define S_FW_RSS_IND_TBL_CMD_IQ13 10
-#define M_FW_RSS_IND_TBL_CMD_IQ13 0x3ff
-#define V_FW_RSS_IND_TBL_CMD_IQ13(x) ((x) << S_FW_RSS_IND_TBL_CMD_IQ13)
-#define G_FW_RSS_IND_TBL_CMD_IQ13(x) \
- (((x) >> S_FW_RSS_IND_TBL_CMD_IQ13) & M_FW_RSS_IND_TBL_CMD_IQ13)
-
-#define S_FW_RSS_IND_TBL_CMD_IQ14 0
-#define M_FW_RSS_IND_TBL_CMD_IQ14 0x3ff
-#define V_FW_RSS_IND_TBL_CMD_IQ14(x) ((x) << S_FW_RSS_IND_TBL_CMD_IQ14)
-#define G_FW_RSS_IND_TBL_CMD_IQ14(x) \
- (((x) >> S_FW_RSS_IND_TBL_CMD_IQ14) & M_FW_RSS_IND_TBL_CMD_IQ14)
-
-#define S_FW_RSS_IND_TBL_CMD_IQ15 20
-#define M_FW_RSS_IND_TBL_CMD_IQ15 0x3ff
-#define V_FW_RSS_IND_TBL_CMD_IQ15(x) ((x) << S_FW_RSS_IND_TBL_CMD_IQ15)
-#define G_FW_RSS_IND_TBL_CMD_IQ15(x) \
- (((x) >> S_FW_RSS_IND_TBL_CMD_IQ15) & M_FW_RSS_IND_TBL_CMD_IQ15)
-
-#define S_FW_RSS_IND_TBL_CMD_IQ16 10
-#define M_FW_RSS_IND_TBL_CMD_IQ16 0x3ff
-#define V_FW_RSS_IND_TBL_CMD_IQ16(x) ((x) << S_FW_RSS_IND_TBL_CMD_IQ16)
-#define G_FW_RSS_IND_TBL_CMD_IQ16(x) \
- (((x) >> S_FW_RSS_IND_TBL_CMD_IQ16) & M_FW_RSS_IND_TBL_CMD_IQ16)
-
-#define S_FW_RSS_IND_TBL_CMD_IQ17 0
-#define M_FW_RSS_IND_TBL_CMD_IQ17 0x3ff
-#define V_FW_RSS_IND_TBL_CMD_IQ17(x) ((x) << S_FW_RSS_IND_TBL_CMD_IQ17)
-#define G_FW_RSS_IND_TBL_CMD_IQ17(x) \
- (((x) >> S_FW_RSS_IND_TBL_CMD_IQ17) & M_FW_RSS_IND_TBL_CMD_IQ17)
-
-#define S_FW_RSS_IND_TBL_CMD_IQ18 20
-#define M_FW_RSS_IND_TBL_CMD_IQ18 0x3ff
-#define V_FW_RSS_IND_TBL_CMD_IQ18(x) ((x) << S_FW_RSS_IND_TBL_CMD_IQ18)
-#define G_FW_RSS_IND_TBL_CMD_IQ18(x) \
- (((x) >> S_FW_RSS_IND_TBL_CMD_IQ18) & M_FW_RSS_IND_TBL_CMD_IQ18)
-
-#define S_FW_RSS_IND_TBL_CMD_IQ19 10
-#define M_FW_RSS_IND_TBL_CMD_IQ19 0x3ff
-#define V_FW_RSS_IND_TBL_CMD_IQ19(x) ((x) << S_FW_RSS_IND_TBL_CMD_IQ19)
-#define G_FW_RSS_IND_TBL_CMD_IQ19(x) \
- (((x) >> S_FW_RSS_IND_TBL_CMD_IQ19) & M_FW_RSS_IND_TBL_CMD_IQ19)
-
-#define S_FW_RSS_IND_TBL_CMD_IQ20 0
-#define M_FW_RSS_IND_TBL_CMD_IQ20 0x3ff
-#define V_FW_RSS_IND_TBL_CMD_IQ20(x) ((x) << S_FW_RSS_IND_TBL_CMD_IQ20)
-#define G_FW_RSS_IND_TBL_CMD_IQ20(x) \
- (((x) >> S_FW_RSS_IND_TBL_CMD_IQ20) & M_FW_RSS_IND_TBL_CMD_IQ20)
-
-#define S_FW_RSS_IND_TBL_CMD_IQ21 20
-#define M_FW_RSS_IND_TBL_CMD_IQ21 0x3ff
-#define V_FW_RSS_IND_TBL_CMD_IQ21(x) ((x) << S_FW_RSS_IND_TBL_CMD_IQ21)
-#define G_FW_RSS_IND_TBL_CMD_IQ21(x) \
- (((x) >> S_FW_RSS_IND_TBL_CMD_IQ21) & M_FW_RSS_IND_TBL_CMD_IQ21)
-
-#define S_FW_RSS_IND_TBL_CMD_IQ22 10
-#define M_FW_RSS_IND_TBL_CMD_IQ22 0x3ff
-#define V_FW_RSS_IND_TBL_CMD_IQ22(x) ((x) << S_FW_RSS_IND_TBL_CMD_IQ22)
-#define G_FW_RSS_IND_TBL_CMD_IQ22(x) \
- (((x) >> S_FW_RSS_IND_TBL_CMD_IQ22) & M_FW_RSS_IND_TBL_CMD_IQ22)
-
-#define S_FW_RSS_IND_TBL_CMD_IQ23 0
-#define M_FW_RSS_IND_TBL_CMD_IQ23 0x3ff
-#define V_FW_RSS_IND_TBL_CMD_IQ23(x) ((x) << S_FW_RSS_IND_TBL_CMD_IQ23)
-#define G_FW_RSS_IND_TBL_CMD_IQ23(x) \
- (((x) >> S_FW_RSS_IND_TBL_CMD_IQ23) & M_FW_RSS_IND_TBL_CMD_IQ23)
-
-#define S_FW_RSS_IND_TBL_CMD_IQ24 20
-#define M_FW_RSS_IND_TBL_CMD_IQ24 0x3ff
-#define V_FW_RSS_IND_TBL_CMD_IQ24(x) ((x) << S_FW_RSS_IND_TBL_CMD_IQ24)
-#define G_FW_RSS_IND_TBL_CMD_IQ24(x) \
- (((x) >> S_FW_RSS_IND_TBL_CMD_IQ24) & M_FW_RSS_IND_TBL_CMD_IQ24)
-
-#define S_FW_RSS_IND_TBL_CMD_IQ25 10
-#define M_FW_RSS_IND_TBL_CMD_IQ25 0x3ff
-#define V_FW_RSS_IND_TBL_CMD_IQ25(x) ((x) << S_FW_RSS_IND_TBL_CMD_IQ25)
-#define G_FW_RSS_IND_TBL_CMD_IQ25(x) \
- (((x) >> S_FW_RSS_IND_TBL_CMD_IQ25) & M_FW_RSS_IND_TBL_CMD_IQ25)
-
-#define S_FW_RSS_IND_TBL_CMD_IQ26 0
-#define M_FW_RSS_IND_TBL_CMD_IQ26 0x3ff
-#define V_FW_RSS_IND_TBL_CMD_IQ26(x) ((x) << S_FW_RSS_IND_TBL_CMD_IQ26)
-#define G_FW_RSS_IND_TBL_CMD_IQ26(x) \
- (((x) >> S_FW_RSS_IND_TBL_CMD_IQ26) & M_FW_RSS_IND_TBL_CMD_IQ26)
-
-#define S_FW_RSS_IND_TBL_CMD_IQ27 20
-#define M_FW_RSS_IND_TBL_CMD_IQ27 0x3ff
-#define V_FW_RSS_IND_TBL_CMD_IQ27(x) ((x) << S_FW_RSS_IND_TBL_CMD_IQ27)
-#define G_FW_RSS_IND_TBL_CMD_IQ27(x) \
- (((x) >> S_FW_RSS_IND_TBL_CMD_IQ27) & M_FW_RSS_IND_TBL_CMD_IQ27)
-
-#define S_FW_RSS_IND_TBL_CMD_IQ28 10
-#define M_FW_RSS_IND_TBL_CMD_IQ28 0x3ff
-#define V_FW_RSS_IND_TBL_CMD_IQ28(x) ((x) << S_FW_RSS_IND_TBL_CMD_IQ28)
-#define G_FW_RSS_IND_TBL_CMD_IQ28(x) \
- (((x) >> S_FW_RSS_IND_TBL_CMD_IQ28) & M_FW_RSS_IND_TBL_CMD_IQ28)
-
-#define S_FW_RSS_IND_TBL_CMD_IQ29 0
-#define M_FW_RSS_IND_TBL_CMD_IQ29 0x3ff
-#define V_FW_RSS_IND_TBL_CMD_IQ29(x) ((x) << S_FW_RSS_IND_TBL_CMD_IQ29)
-#define G_FW_RSS_IND_TBL_CMD_IQ29(x) \
- (((x) >> S_FW_RSS_IND_TBL_CMD_IQ29) & M_FW_RSS_IND_TBL_CMD_IQ29)
-
-#define S_FW_RSS_IND_TBL_CMD_IQ30 20
-#define M_FW_RSS_IND_TBL_CMD_IQ30 0x3ff
-#define V_FW_RSS_IND_TBL_CMD_IQ30(x) ((x) << S_FW_RSS_IND_TBL_CMD_IQ30)
-#define G_FW_RSS_IND_TBL_CMD_IQ30(x) \
- (((x) >> S_FW_RSS_IND_TBL_CMD_IQ30) & M_FW_RSS_IND_TBL_CMD_IQ30)
-
-#define S_FW_RSS_IND_TBL_CMD_IQ31 10
-#define M_FW_RSS_IND_TBL_CMD_IQ31 0x3ff
-#define V_FW_RSS_IND_TBL_CMD_IQ31(x) ((x) << S_FW_RSS_IND_TBL_CMD_IQ31)
-#define G_FW_RSS_IND_TBL_CMD_IQ31(x) \
- (((x) >> S_FW_RSS_IND_TBL_CMD_IQ31) & M_FW_RSS_IND_TBL_CMD_IQ31)
-
-struct fw_rss_glb_config_cmd {
- __be32 op_to_write;
- __be32 retval_len16;
- union fw_rss_glb_config {
- struct fw_rss_glb_config_manual {
- __be32 mode_pkd;
- __be32 r3;
- __be64 r4;
- __be64 r5;
- } manual;
- struct fw_rss_glb_config_basicvirtual {
- __be32 mode_pkd;
- __be32 synmapen_to_hashtoeplitz;
- __be64 r8;
- __be64 r9;
- } basicvirtual;
- } u;
-};
-
-#define S_FW_RSS_GLB_CONFIG_CMD_MODE 28
-#define M_FW_RSS_GLB_CONFIG_CMD_MODE 0xf
-#define V_FW_RSS_GLB_CONFIG_CMD_MODE(x) ((x) << S_FW_RSS_GLB_CONFIG_CMD_MODE)
-#define G_FW_RSS_GLB_CONFIG_CMD_MODE(x) \
- (((x) >> S_FW_RSS_GLB_CONFIG_CMD_MODE) & M_FW_RSS_GLB_CONFIG_CMD_MODE)
-
-#define FW_RSS_GLB_CONFIG_CMD_MODE_MANUAL 0
-#define FW_RSS_GLB_CONFIG_CMD_MODE_BASICVIRTUAL 1
-#define FW_RSS_GLB_CONFIG_CMD_MODE_MAX 1
-
-#define S_FW_RSS_GLB_CONFIG_CMD_SYNMAPEN 8
-#define M_FW_RSS_GLB_CONFIG_CMD_SYNMAPEN 0x1
-#define V_FW_RSS_GLB_CONFIG_CMD_SYNMAPEN(x) \
- ((x) << S_FW_RSS_GLB_CONFIG_CMD_SYNMAPEN)
-#define G_FW_RSS_GLB_CONFIG_CMD_SYNMAPEN(x) \
- (((x) >> S_FW_RSS_GLB_CONFIG_CMD_SYNMAPEN) & \
- M_FW_RSS_GLB_CONFIG_CMD_SYNMAPEN)
-#define F_FW_RSS_GLB_CONFIG_CMD_SYNMAPEN \
- V_FW_RSS_GLB_CONFIG_CMD_SYNMAPEN(1U)
-
-#define S_FW_RSS_GLB_CONFIG_CMD_SYN4TUPENIPV6 7
-#define M_FW_RSS_GLB_CONFIG_CMD_SYN4TUPENIPV6 0x1
-#define V_FW_RSS_GLB_CONFIG_CMD_SYN4TUPENIPV6(x) \
- ((x) << S_FW_RSS_GLB_CONFIG_CMD_SYN4TUPENIPV6)
-#define G_FW_RSS_GLB_CONFIG_CMD_SYN4TUPENIPV6(x) \
- (((x) >> S_FW_RSS_GLB_CONFIG_CMD_SYN4TUPENIPV6) & \
- M_FW_RSS_GLB_CONFIG_CMD_SYN4TUPENIPV6)
-#define F_FW_RSS_GLB_CONFIG_CMD_SYN4TUPENIPV6 \
- V_FW_RSS_GLB_CONFIG_CMD_SYN4TUPENIPV6(1U)
-
-#define S_FW_RSS_GLB_CONFIG_CMD_SYN2TUPENIPV6 6
-#define M_FW_RSS_GLB_CONFIG_CMD_SYN2TUPENIPV6 0x1
-#define V_FW_RSS_GLB_CONFIG_CMD_SYN2TUPENIPV6(x) \
- ((x) << S_FW_RSS_GLB_CONFIG_CMD_SYN2TUPENIPV6)
-#define G_FW_RSS_GLB_CONFIG_CMD_SYN2TUPENIPV6(x) \
- (((x) >> S_FW_RSS_GLB_CONFIG_CMD_SYN2TUPENIPV6) & \
- M_FW_RSS_GLB_CONFIG_CMD_SYN2TUPENIPV6)
-#define F_FW_RSS_GLB_CONFIG_CMD_SYN2TUPENIPV6 \
- V_FW_RSS_GLB_CONFIG_CMD_SYN2TUPENIPV6(1U)
-
-#define S_FW_RSS_GLB_CONFIG_CMD_SYN4TUPENIPV4 5
-#define M_FW_RSS_GLB_CONFIG_CMD_SYN4TUPENIPV4 0x1
-#define V_FW_RSS_GLB_CONFIG_CMD_SYN4TUPENIPV4(x) \
- ((x) << S_FW_RSS_GLB_CONFIG_CMD_SYN4TUPENIPV4)
-#define G_FW_RSS_GLB_CONFIG_CMD_SYN4TUPENIPV4(x) \
- (((x) >> S_FW_RSS_GLB_CONFIG_CMD_SYN4TUPENIPV4) & \
- M_FW_RSS_GLB_CONFIG_CMD_SYN4TUPENIPV4)
-#define F_FW_RSS_GLB_CONFIG_CMD_SYN4TUPENIPV4 \
- V_FW_RSS_GLB_CONFIG_CMD_SYN4TUPENIPV4(1U)
-
-#define S_FW_RSS_GLB_CONFIG_CMD_SYN2TUPENIPV4 4
-#define M_FW_RSS_GLB_CONFIG_CMD_SYN2TUPENIPV4 0x1
-#define V_FW_RSS_GLB_CONFIG_CMD_SYN2TUPENIPV4(x) \
- ((x) << S_FW_RSS_GLB_CONFIG_CMD_SYN2TUPENIPV4)
-#define G_FW_RSS_GLB_CONFIG_CMD_SYN2TUPENIPV4(x) \
- (((x) >> S_FW_RSS_GLB_CONFIG_CMD_SYN2TUPENIPV4) & \
- M_FW_RSS_GLB_CONFIG_CMD_SYN2TUPENIPV4)
-#define F_FW_RSS_GLB_CONFIG_CMD_SYN2TUPENIPV4 \
- V_FW_RSS_GLB_CONFIG_CMD_SYN2TUPENIPV4(1U)
-
-#define S_FW_RSS_GLB_CONFIG_CMD_OFDMAPEN 3
-#define M_FW_RSS_GLB_CONFIG_CMD_OFDMAPEN 0x1
-#define V_FW_RSS_GLB_CONFIG_CMD_OFDMAPEN(x) \
- ((x) << S_FW_RSS_GLB_CONFIG_CMD_OFDMAPEN)
-#define G_FW_RSS_GLB_CONFIG_CMD_OFDMAPEN(x) \
- (((x) >> S_FW_RSS_GLB_CONFIG_CMD_OFDMAPEN) & \
- M_FW_RSS_GLB_CONFIG_CMD_OFDMAPEN)
-#define F_FW_RSS_GLB_CONFIG_CMD_OFDMAPEN \
- V_FW_RSS_GLB_CONFIG_CMD_OFDMAPEN(1U)
-
-#define S_FW_RSS_GLB_CONFIG_CMD_TNLMAPEN 2
-#define M_FW_RSS_GLB_CONFIG_CMD_TNLMAPEN 0x1
-#define V_FW_RSS_GLB_CONFIG_CMD_TNLMAPEN(x) \
- ((x) << S_FW_RSS_GLB_CONFIG_CMD_TNLMAPEN)
-#define G_FW_RSS_GLB_CONFIG_CMD_TNLMAPEN(x) \
- (((x) >> S_FW_RSS_GLB_CONFIG_CMD_TNLMAPEN) & \
- M_FW_RSS_GLB_CONFIG_CMD_TNLMAPEN)
-#define F_FW_RSS_GLB_CONFIG_CMD_TNLMAPEN \
- V_FW_RSS_GLB_CONFIG_CMD_TNLMAPEN(1U)
-
-#define S_FW_RSS_GLB_CONFIG_CMD_TNLALLLKP 1
-#define M_FW_RSS_GLB_CONFIG_CMD_TNLALLLKP 0x1
-#define V_FW_RSS_GLB_CONFIG_CMD_TNLALLLKP(x) \
- ((x) << S_FW_RSS_GLB_CONFIG_CMD_TNLALLLKP)
-#define G_FW_RSS_GLB_CONFIG_CMD_TNLALLLKP(x) \
- (((x) >> S_FW_RSS_GLB_CONFIG_CMD_TNLALLLKP) & \
- M_FW_RSS_GLB_CONFIG_CMD_TNLALLLKP)
-#define F_FW_RSS_GLB_CONFIG_CMD_TNLALLLKP \
- V_FW_RSS_GLB_CONFIG_CMD_TNLALLLKP(1U)
-
-#define S_FW_RSS_GLB_CONFIG_CMD_HASHTOEPLITZ 0
-#define M_FW_RSS_GLB_CONFIG_CMD_HASHTOEPLITZ 0x1
-#define V_FW_RSS_GLB_CONFIG_CMD_HASHTOEPLITZ(x) \
- ((x) << S_FW_RSS_GLB_CONFIG_CMD_HASHTOEPLITZ)
-#define G_FW_RSS_GLB_CONFIG_CMD_HASHTOEPLITZ(x) \
- (((x) >> S_FW_RSS_GLB_CONFIG_CMD_HASHTOEPLITZ) & \
- M_FW_RSS_GLB_CONFIG_CMD_HASHTOEPLITZ)
-#define F_FW_RSS_GLB_CONFIG_CMD_HASHTOEPLITZ \
- V_FW_RSS_GLB_CONFIG_CMD_HASHTOEPLITZ(1U)
-
-struct fw_rss_vi_config_cmd {
- __be32 op_to_viid;
- __be32 retval_len16;
- union fw_rss_vi_config {
- struct fw_rss_vi_config_manual {
- __be64 r3;
- __be64 r4;
- __be64 r5;
- } manual;
- struct fw_rss_vi_config_basicvirtual {
- __be32 r6;
- __be32 defaultq_to_udpen;
- __be64 r9;
- __be64 r10;
- } basicvirtual;
- } u;
-};
-
-#define S_FW_RSS_VI_CONFIG_CMD_VIID 0
-#define M_FW_RSS_VI_CONFIG_CMD_VIID 0xfff
-#define V_FW_RSS_VI_CONFIG_CMD_VIID(x) ((x) << S_FW_RSS_VI_CONFIG_CMD_VIID)
-#define G_FW_RSS_VI_CONFIG_CMD_VIID(x) \
- (((x) >> S_FW_RSS_VI_CONFIG_CMD_VIID) & M_FW_RSS_VI_CONFIG_CMD_VIID)
-
-#define S_FW_RSS_VI_CONFIG_CMD_DEFAULTQ 16
-#define M_FW_RSS_VI_CONFIG_CMD_DEFAULTQ 0x3ff
-#define V_FW_RSS_VI_CONFIG_CMD_DEFAULTQ(x) \
- ((x) << S_FW_RSS_VI_CONFIG_CMD_DEFAULTQ)
-#define G_FW_RSS_VI_CONFIG_CMD_DEFAULTQ(x) \
- (((x) >> S_FW_RSS_VI_CONFIG_CMD_DEFAULTQ) & \
- M_FW_RSS_VI_CONFIG_CMD_DEFAULTQ)
-
-#define S_FW_RSS_VI_CONFIG_CMD_IP6FOURTUPEN 4
-#define M_FW_RSS_VI_CONFIG_CMD_IP6FOURTUPEN 0x1
-#define V_FW_RSS_VI_CONFIG_CMD_IP6FOURTUPEN(x) \
- ((x) << S_FW_RSS_VI_CONFIG_CMD_IP6FOURTUPEN)
-#define G_FW_RSS_VI_CONFIG_CMD_IP6FOURTUPEN(x) \
- (((x) >> S_FW_RSS_VI_CONFIG_CMD_IP6FOURTUPEN) & \
- M_FW_RSS_VI_CONFIG_CMD_IP6FOURTUPEN)
-#define F_FW_RSS_VI_CONFIG_CMD_IP6FOURTUPEN \
- V_FW_RSS_VI_CONFIG_CMD_IP6FOURTUPEN(1U)
-
-#define S_FW_RSS_VI_CONFIG_CMD_IP6TWOTUPEN 3
-#define M_FW_RSS_VI_CONFIG_CMD_IP6TWOTUPEN 0x1
-#define V_FW_RSS_VI_CONFIG_CMD_IP6TWOTUPEN(x) \
- ((x) << S_FW_RSS_VI_CONFIG_CMD_IP6TWOTUPEN)
-#define G_FW_RSS_VI_CONFIG_CMD_IP6TWOTUPEN(x) \
- (((x) >> S_FW_RSS_VI_CONFIG_CMD_IP6TWOTUPEN) & \
- M_FW_RSS_VI_CONFIG_CMD_IP6TWOTUPEN)
-#define F_FW_RSS_VI_CONFIG_CMD_IP6TWOTUPEN \
- V_FW_RSS_VI_CONFIG_CMD_IP6TWOTUPEN(1U)
-
-#define S_FW_RSS_VI_CONFIG_CMD_IP4FOURTUPEN 2
-#define M_FW_RSS_VI_CONFIG_CMD_IP4FOURTUPEN 0x1
-#define V_FW_RSS_VI_CONFIG_CMD_IP4FOURTUPEN(x) \
- ((x) << S_FW_RSS_VI_CONFIG_CMD_IP4FOURTUPEN)
-#define G_FW_RSS_VI_CONFIG_CMD_IP4FOURTUPEN(x) \
- (((x) >> S_FW_RSS_VI_CONFIG_CMD_IP4FOURTUPEN) & \
- M_FW_RSS_VI_CONFIG_CMD_IP4FOURTUPEN)
-#define F_FW_RSS_VI_CONFIG_CMD_IP4FOURTUPEN \
- V_FW_RSS_VI_CONFIG_CMD_IP4FOURTUPEN(1U)
-
-#define S_FW_RSS_VI_CONFIG_CMD_IP4TWOTUPEN 1
-#define M_FW_RSS_VI_CONFIG_CMD_IP4TWOTUPEN 0x1
-#define V_FW_RSS_VI_CONFIG_CMD_IP4TWOTUPEN(x) \
- ((x) << S_FW_RSS_VI_CONFIG_CMD_IP4TWOTUPEN)
-#define G_FW_RSS_VI_CONFIG_CMD_IP4TWOTUPEN(x) \
- (((x) >> S_FW_RSS_VI_CONFIG_CMD_IP4TWOTUPEN) & \
- M_FW_RSS_VI_CONFIG_CMD_IP4TWOTUPEN)
-#define F_FW_RSS_VI_CONFIG_CMD_IP4TWOTUPEN \
- V_FW_RSS_VI_CONFIG_CMD_IP4TWOTUPEN(1U)
-
-#define S_FW_RSS_VI_CONFIG_CMD_UDPEN 0
-#define M_FW_RSS_VI_CONFIG_CMD_UDPEN 0x1
-#define V_FW_RSS_VI_CONFIG_CMD_UDPEN(x) ((x) << S_FW_RSS_VI_CONFIG_CMD_UDPEN)
-#define G_FW_RSS_VI_CONFIG_CMD_UDPEN(x) \
- (((x) >> S_FW_RSS_VI_CONFIG_CMD_UDPEN) & M_FW_RSS_VI_CONFIG_CMD_UDPEN)
-#define F_FW_RSS_VI_CONFIG_CMD_UDPEN V_FW_RSS_VI_CONFIG_CMD_UDPEN(1U)
-
-enum fw_sched_sc {
- FW_SCHED_SC_CONFIG = 0,
- FW_SCHED_SC_PARAMS = 1,
-};
-
-enum fw_sched_type {
- FW_SCHED_TYPE_PKTSCHED = 0,
- FW_SCHED_TYPE_STREAMSCHED = 1,
-};
-
-enum fw_sched_params_level {
- FW_SCHED_PARAMS_LEVEL_CL_RL = 0,
- FW_SCHED_PARAMS_LEVEL_CL_WRR = 1,
- FW_SCHED_PARAMS_LEVEL_CH_RL = 2,
-};
-
-enum fw_sched_params_mode {
- FW_SCHED_PARAMS_MODE_CLASS = 0,
- FW_SCHED_PARAMS_MODE_FLOW = 1,
-};
-
-enum fw_sched_params_unit {
- FW_SCHED_PARAMS_UNIT_BITRATE = 0,
- FW_SCHED_PARAMS_UNIT_PKTRATE = 1,
-};
-
-enum fw_sched_params_rate {
- FW_SCHED_PARAMS_RATE_REL = 0,
- FW_SCHED_PARAMS_RATE_ABS = 1,
-};
-
-struct fw_sched_cmd {
- __be32 op_to_write;
- __be32 retval_len16;
- union fw_sched {
- struct fw_sched_config {
- __u8 sc;
- __u8 type;
- __u8 minmaxen;
- __u8 r3[5];
- __u8 nclasses[4];
- __be32 r4;
- } config;
- struct fw_sched_params {
- __u8 sc;
- __u8 type;
- __u8 level;
- __u8 mode;
- __u8 unit;
- __u8 rate;
- __u8 ch;
- __u8 cl;
- __be32 min;
- __be32 max;
- __be16 weight;
- __be16 pktsize;
- __be16 burstsize;
- __be16 r4;
- } params;
- } u;
-};
-
-/*
- * length of the formatting string
- */
-#define FW_DEVLOG_FMT_LEN 192
-
-/*
- * maximum number of the formatting string parameters
- */
-#define FW_DEVLOG_FMT_PARAMS_NUM 8
-
-/*
- * priority levels
- */
-enum fw_devlog_level {
- FW_DEVLOG_LEVEL_EMERG = 0x0,
- FW_DEVLOG_LEVEL_CRIT = 0x1,
- FW_DEVLOG_LEVEL_ERR = 0x2,
- FW_DEVLOG_LEVEL_NOTICE = 0x3,
- FW_DEVLOG_LEVEL_INFO = 0x4,
- FW_DEVLOG_LEVEL_DEBUG = 0x5,
- FW_DEVLOG_LEVEL_MAX = 0x5,
-};
-
-/*
- * facilities that may send a log message
- */
-enum fw_devlog_facility {
- FW_DEVLOG_FACILITY_CORE = 0x00,
- FW_DEVLOG_FACILITY_CF = 0x01,
- FW_DEVLOG_FACILITY_SCHED = 0x02,
- FW_DEVLOG_FACILITY_TIMER = 0x04,
- FW_DEVLOG_FACILITY_RES = 0x06,
- FW_DEVLOG_FACILITY_HW = 0x08,
- FW_DEVLOG_FACILITY_FLR = 0x10,
- FW_DEVLOG_FACILITY_DMAQ = 0x12,
- FW_DEVLOG_FACILITY_PHY = 0x14,
- FW_DEVLOG_FACILITY_MAC = 0x16,
- FW_DEVLOG_FACILITY_PORT = 0x18,
- FW_DEVLOG_FACILITY_VI = 0x1A,
- FW_DEVLOG_FACILITY_FILTER = 0x1C,
- FW_DEVLOG_FACILITY_ACL = 0x1E,
- FW_DEVLOG_FACILITY_TM = 0x20,
- FW_DEVLOG_FACILITY_QFC = 0x22,
- FW_DEVLOG_FACILITY_DCB = 0x24,
- FW_DEVLOG_FACILITY_ETH = 0x26,
- FW_DEVLOG_FACILITY_OFLD = 0x28,
- FW_DEVLOG_FACILITY_RI = 0x2A,
- FW_DEVLOG_FACILITY_ISCSI = 0x2C,
- FW_DEVLOG_FACILITY_FCOE = 0x2E,
- FW_DEVLOG_FACILITY_FOISCSI = 0x30,
- FW_DEVLOG_FACILITY_FOFCOE = 0x32,
- FW_DEVLOG_FACILITY_MAX = 0x32,
-};
-
-/*
- * log message format
- */
-struct fw_devlog_e {
- __be64 timestamp;
- __be32 seqno;
- __be16 reserved1;
- __u8 level;
- __u8 facility;
- __u8 fmt[FW_DEVLOG_FMT_LEN];
- __be32 params[FW_DEVLOG_FMT_PARAMS_NUM];
- __be32 reserved3[4];
-};
-
-struct fw_devlog_cmd {
- __be32 op_to_write;
- __be32 retval_len16;
- __u8 level;
- __u8 r2[7];
- __be32 memtype_devlog_memaddr16_devlog;
- __be32 memsize_devlog;
- __be32 r3[2];
-};
-
-#define S_FW_DEVLOG_CMD_MEMTYPE_DEVLOG 28
-#define M_FW_DEVLOG_CMD_MEMTYPE_DEVLOG 0xf
-#define V_FW_DEVLOG_CMD_MEMTYPE_DEVLOG(x) \
- ((x) << S_FW_DEVLOG_CMD_MEMTYPE_DEVLOG)
-#define G_FW_DEVLOG_CMD_MEMTYPE_DEVLOG(x) \
- (((x) >> S_FW_DEVLOG_CMD_MEMTYPE_DEVLOG) & M_FW_DEVLOG_CMD_MEMTYPE_DEVLOG)
-
-#define S_FW_DEVLOG_CMD_MEMADDR16_DEVLOG 0
-#define M_FW_DEVLOG_CMD_MEMADDR16_DEVLOG 0xfffffff
-#define V_FW_DEVLOG_CMD_MEMADDR16_DEVLOG(x) \
- ((x) << S_FW_DEVLOG_CMD_MEMADDR16_DEVLOG)
-#define G_FW_DEVLOG_CMD_MEMADDR16_DEVLOG(x) \
- (((x) >> S_FW_DEVLOG_CMD_MEMADDR16_DEVLOG) & \
- M_FW_DEVLOG_CMD_MEMADDR16_DEVLOG)
-
-enum fw_watchdog_actions {
- FW_WATCHDOG_ACTION_SHUTDOWN = 0,
- FW_WATCHDOG_ACTION_FLR = 1,
- FW_WATCHDOG_ACTION_BYPASS = 2,
- FW_WATCHDOG_ACTION_TMPCHK = 3,
-
- FW_WATCHDOG_ACTION_MAX = 4,
-};
-
-#define FW_WATCHDOG_MAX_TIMEOUT_SECS 60
-
-struct fw_watchdog_cmd {
- __be32 op_to_vfn;
- __be32 retval_len16;
- __be32 timeout;
- __be32 action;
-};
-
-#define S_FW_WATCHDOG_CMD_PFN 8
-#define M_FW_WATCHDOG_CMD_PFN 0x7
-#define V_FW_WATCHDOG_CMD_PFN(x) ((x) << S_FW_WATCHDOG_CMD_PFN)
-#define G_FW_WATCHDOG_CMD_PFN(x) \
- (((x) >> S_FW_WATCHDOG_CMD_PFN) & M_FW_WATCHDOG_CMD_PFN)
-
-#define S_FW_WATCHDOG_CMD_VFN 0
-#define M_FW_WATCHDOG_CMD_VFN 0xff
-#define V_FW_WATCHDOG_CMD_VFN(x) ((x) << S_FW_WATCHDOG_CMD_VFN)
-#define G_FW_WATCHDOG_CMD_VFN(x) \
- (((x) >> S_FW_WATCHDOG_CMD_VFN) & M_FW_WATCHDOG_CMD_VFN)
-
-struct fw_clip_cmd {
- __be32 op_to_write;
- __be32 alloc_to_len16;
- __be64 ip_hi;
- __be64 ip_lo;
- __be32 r4[2];
-};
-
-#define S_FW_CLIP_CMD_ALLOC 31
-#define M_FW_CLIP_CMD_ALLOC 0x1
-#define V_FW_CLIP_CMD_ALLOC(x) ((x) << S_FW_CLIP_CMD_ALLOC)
-#define G_FW_CLIP_CMD_ALLOC(x) \
- (((x) >> S_FW_CLIP_CMD_ALLOC) & M_FW_CLIP_CMD_ALLOC)
-#define F_FW_CLIP_CMD_ALLOC V_FW_CLIP_CMD_ALLOC(1U)
-
-#define S_FW_CLIP_CMD_FREE 30
-#define M_FW_CLIP_CMD_FREE 0x1
-#define V_FW_CLIP_CMD_FREE(x) ((x) << S_FW_CLIP_CMD_FREE)
-#define G_FW_CLIP_CMD_FREE(x) \
- (((x) >> S_FW_CLIP_CMD_FREE) & M_FW_CLIP_CMD_FREE)
-#define F_FW_CLIP_CMD_FREE V_FW_CLIP_CMD_FREE(1U)
-
-/******************************************************************************
- * F O i S C S I C O M M A N D s
- **************************************/
-
-#define FW_CHNET_IFACE_ADDR_MAX 3
-
-enum fw_chnet_iface_cmd_subop {
- FW_CHNET_IFACE_CMD_SUBOP_NOOP = 0,
-
- FW_CHNET_IFACE_CMD_SUBOP_LINK_UP,
- FW_CHNET_IFACE_CMD_SUBOP_LINK_DOWN,
-
- FW_CHNET_IFACE_CMD_SUBOP_MTU_SET,
- FW_CHNET_IFACE_CMD_SUBOP_MTU_GET,
-
- FW_CHNET_IFACE_CMD_SUBOP_MAX,
-};
-
-struct fw_chnet_iface_cmd {
- __be32 op_to_portid;
- __be32 retval_len16;
- __u8 subop;
- __u8 r2[3];
- __be32 ifid_ifstate;
- __be16 mtu;
- __be16 vlanid;
- __be32 r3;
- __be16 r4;
- __u8 mac[6];
-};
-
-#define S_FW_CHNET_IFACE_CMD_PORTID 0
-#define M_FW_CHNET_IFACE_CMD_PORTID 0xf
-#define V_FW_CHNET_IFACE_CMD_PORTID(x) ((x) << S_FW_CHNET_IFACE_CMD_PORTID)
-#define G_FW_CHNET_IFACE_CMD_PORTID(x) \
- (((x) >> S_FW_CHNET_IFACE_CMD_PORTID) & M_FW_CHNET_IFACE_CMD_PORTID)
-
-#define S_FW_CHNET_IFACE_CMD_IFID 8
-#define M_FW_CHNET_IFACE_CMD_IFID 0xffffff
-#define V_FW_CHNET_IFACE_CMD_IFID(x) ((x) << S_FW_CHNET_IFACE_CMD_IFID)
-#define G_FW_CHNET_IFACE_CMD_IFID(x) \
- (((x) >> S_FW_CHNET_IFACE_CMD_IFID) & M_FW_CHNET_IFACE_CMD_IFID)
-
-#define S_FW_CHNET_IFACE_CMD_IFSTATE 0
-#define M_FW_CHNET_IFACE_CMD_IFSTATE 0xff
-#define V_FW_CHNET_IFACE_CMD_IFSTATE(x) ((x) << S_FW_CHNET_IFACE_CMD_IFSTATE)
-#define G_FW_CHNET_IFACE_CMD_IFSTATE(x) \
- (((x) >> S_FW_CHNET_IFACE_CMD_IFSTATE) & M_FW_CHNET_IFACE_CMD_IFSTATE)
-
-/******************************************************************************
- * F O F C O E C O M M A N D s
- ************************************/
-
-struct fw_fcoe_res_info_cmd {
- __be32 op_to_read;
- __be32 retval_len16;
- __be16 e_d_tov;
- __be16 r_a_tov_seq;
- __be16 r_a_tov_els;
- __be16 r_r_tov;
- __be32 max_xchgs;
- __be32 max_ssns;
- __be32 used_xchgs;
- __be32 used_ssns;
- __be32 max_fcfs;
- __be32 max_vnps;
- __be32 used_fcfs;
- __be32 used_vnps;
-};
-
-struct fw_fcoe_link_cmd {
- __be32 op_to_portid;
- __be32 retval_len16;
- __be32 sub_opcode_fcfi;
- __u8 r3;
- __u8 lstatus;
- __be16 flags;
- __u8 r4;
- __u8 set_vlan;
- __be16 vlan_id;
- __be32 vnpi_pkd;
- __be16 r6;
- __u8 phy_mac[6];
- __u8 vnport_wwnn[8];
- __u8 vnport_wwpn[8];
-};
-
-#define S_FW_FCOE_LINK_CMD_PORTID 0
-#define M_FW_FCOE_LINK_CMD_PORTID 0xf
-#define V_FW_FCOE_LINK_CMD_PORTID(x) ((x) << S_FW_FCOE_LINK_CMD_PORTID)
-#define G_FW_FCOE_LINK_CMD_PORTID(x) \
- (((x) >> S_FW_FCOE_LINK_CMD_PORTID) & M_FW_FCOE_LINK_CMD_PORTID)
-
-#define S_FW_FCOE_LINK_CMD_SUB_OPCODE 24
-#define M_FW_FCOE_LINK_CMD_SUB_OPCODE 0xff
-#define V_FW_FCOE_LINK_CMD_SUB_OPCODE(x) \
- ((x) << S_FW_FCOE_LINK_CMD_SUB_OPCODE)
-#define G_FW_FCOE_LINK_CMD_SUB_OPCODE(x) \
- (((x) >> S_FW_FCOE_LINK_CMD_SUB_OPCODE) & M_FW_FCOE_LINK_CMD_SUB_OPCODE)
-
-#define S_FW_FCOE_LINK_CMD_FCFI 0
-#define M_FW_FCOE_LINK_CMD_FCFI 0xffffff
-#define V_FW_FCOE_LINK_CMD_FCFI(x) ((x) << S_FW_FCOE_LINK_CMD_FCFI)
-#define G_FW_FCOE_LINK_CMD_FCFI(x) \
- (((x) >> S_FW_FCOE_LINK_CMD_FCFI) & M_FW_FCOE_LINK_CMD_FCFI)
-
-#define S_FW_FCOE_LINK_CMD_VNPI 0
-#define M_FW_FCOE_LINK_CMD_VNPI 0xfffff
-#define V_FW_FCOE_LINK_CMD_VNPI(x) ((x) << S_FW_FCOE_LINK_CMD_VNPI)
-#define G_FW_FCOE_LINK_CMD_VNPI(x) \
- (((x) >> S_FW_FCOE_LINK_CMD_VNPI) & M_FW_FCOE_LINK_CMD_VNPI)
-
-struct fw_fcoe_vnp_cmd {
- __be32 op_to_fcfi;
- __be32 alloc_to_len16;
- __be32 gen_wwn_to_vnpi;
- __be32 vf_id;
- __be16 iqid;
- __u8 vnport_mac[6];
- __u8 vnport_wwnn[8];
- __u8 vnport_wwpn[8];
- __u8 cmn_srv_parms[16];
- __u8 clsp_word_0_1[8];
-};
-
-#define S_FW_FCOE_VNP_CMD_FCFI 0
-#define M_FW_FCOE_VNP_CMD_FCFI 0xfffff
-#define V_FW_FCOE_VNP_CMD_FCFI(x) ((x) << S_FW_FCOE_VNP_CMD_FCFI)
-#define G_FW_FCOE_VNP_CMD_FCFI(x) \
- (((x) >> S_FW_FCOE_VNP_CMD_FCFI) & M_FW_FCOE_VNP_CMD_FCFI)
-
-#define S_FW_FCOE_VNP_CMD_ALLOC 31
-#define M_FW_FCOE_VNP_CMD_ALLOC 0x1
-#define V_FW_FCOE_VNP_CMD_ALLOC(x) ((x) << S_FW_FCOE_VNP_CMD_ALLOC)
-#define G_FW_FCOE_VNP_CMD_ALLOC(x) \
- (((x) >> S_FW_FCOE_VNP_CMD_ALLOC) & M_FW_FCOE_VNP_CMD_ALLOC)
-#define F_FW_FCOE_VNP_CMD_ALLOC V_FW_FCOE_VNP_CMD_ALLOC(1U)
-
-#define S_FW_FCOE_VNP_CMD_FREE 30
-#define M_FW_FCOE_VNP_CMD_FREE 0x1
-#define V_FW_FCOE_VNP_CMD_FREE(x) ((x) << S_FW_FCOE_VNP_CMD_FREE)
-#define G_FW_FCOE_VNP_CMD_FREE(x) \
- (((x) >> S_FW_FCOE_VNP_CMD_FREE) & M_FW_FCOE_VNP_CMD_FREE)
-#define F_FW_FCOE_VNP_CMD_FREE V_FW_FCOE_VNP_CMD_FREE(1U)
-
-#define S_FW_FCOE_VNP_CMD_MODIFY 29
-#define M_FW_FCOE_VNP_CMD_MODIFY 0x1
-#define V_FW_FCOE_VNP_CMD_MODIFY(x) ((x) << S_FW_FCOE_VNP_CMD_MODIFY)
-#define G_FW_FCOE_VNP_CMD_MODIFY(x) \
- (((x) >> S_FW_FCOE_VNP_CMD_MODIFY) & M_FW_FCOE_VNP_CMD_MODIFY)
-#define F_FW_FCOE_VNP_CMD_MODIFY V_FW_FCOE_VNP_CMD_MODIFY(1U)
-
-#define S_FW_FCOE_VNP_CMD_GEN_WWN 22
-#define M_FW_FCOE_VNP_CMD_GEN_WWN 0x1
-#define V_FW_FCOE_VNP_CMD_GEN_WWN(x) ((x) << S_FW_FCOE_VNP_CMD_GEN_WWN)
-#define G_FW_FCOE_VNP_CMD_GEN_WWN(x) \
- (((x) >> S_FW_FCOE_VNP_CMD_GEN_WWN) & M_FW_FCOE_VNP_CMD_GEN_WWN)
-#define F_FW_FCOE_VNP_CMD_GEN_WWN V_FW_FCOE_VNP_CMD_GEN_WWN(1U)
-
-#define S_FW_FCOE_VNP_CMD_PERSIST 21
-#define M_FW_FCOE_VNP_CMD_PERSIST 0x1
-#define V_FW_FCOE_VNP_CMD_PERSIST(x) ((x) << S_FW_FCOE_VNP_CMD_PERSIST)
-#define G_FW_FCOE_VNP_CMD_PERSIST(x) \
- (((x) >> S_FW_FCOE_VNP_CMD_PERSIST) & M_FW_FCOE_VNP_CMD_PERSIST)
-#define F_FW_FCOE_VNP_CMD_PERSIST V_FW_FCOE_VNP_CMD_PERSIST(1U)
-
-#define S_FW_FCOE_VNP_CMD_VFID_EN 20
-#define M_FW_FCOE_VNP_CMD_VFID_EN 0x1
-#define V_FW_FCOE_VNP_CMD_VFID_EN(x) ((x) << S_FW_FCOE_VNP_CMD_VFID_EN)
-#define G_FW_FCOE_VNP_CMD_VFID_EN(x) \
- (((x) >> S_FW_FCOE_VNP_CMD_VFID_EN) & M_FW_FCOE_VNP_CMD_VFID_EN)
-#define F_FW_FCOE_VNP_CMD_VFID_EN V_FW_FCOE_VNP_CMD_VFID_EN(1U)
-
-#define S_FW_FCOE_VNP_CMD_VNPI 0
-#define M_FW_FCOE_VNP_CMD_VNPI 0xfffff
-#define V_FW_FCOE_VNP_CMD_VNPI(x) ((x) << S_FW_FCOE_VNP_CMD_VNPI)
-#define G_FW_FCOE_VNP_CMD_VNPI(x) \
- (((x) >> S_FW_FCOE_VNP_CMD_VNPI) & M_FW_FCOE_VNP_CMD_VNPI)
-
-struct fw_fcoe_sparams_cmd {
- __be32 op_to_portid;
- __be32 retval_len16;
- __u8 r3[7];
- __u8 cos;
- __u8 lport_wwnn[8];
- __u8 lport_wwpn[8];
- __u8 cmn_srv_parms[16];
- __u8 cls_srv_parms[16];
-};
-
-#define S_FW_FCOE_SPARAMS_CMD_PORTID 0
-#define M_FW_FCOE_SPARAMS_CMD_PORTID 0xf
-#define V_FW_FCOE_SPARAMS_CMD_PORTID(x) ((x) << S_FW_FCOE_SPARAMS_CMD_PORTID)
-#define G_FW_FCOE_SPARAMS_CMD_PORTID(x) \
- (((x) >> S_FW_FCOE_SPARAMS_CMD_PORTID) & M_FW_FCOE_SPARAMS_CMD_PORTID)
-
-struct fw_fcoe_stats_cmd {
- __be32 op_to_flowid;
- __be32 free_to_len16;
- union fw_fcoe_stats {
- struct fw_fcoe_stats_ctl {
- __u8 nstats_port;
- __u8 port_valid_ix;
- __be16 r6;
- __be32 r7;
- __be64 stat0;
- __be64 stat1;
- __be64 stat2;
- __be64 stat3;
- __be64 stat4;
- __be64 stat5;
- } ctl;
- struct fw_fcoe_port_stats {
- __be64 tx_bcast_bytes;
- __be64 tx_bcast_frames;
- __be64 tx_mcast_bytes;
- __be64 tx_mcast_frames;
- __be64 tx_ucast_bytes;
- __be64 tx_ucast_frames;
- __be64 tx_drop_frames;
- __be64 tx_offload_bytes;
- __be64 tx_offload_frames;
- __be64 rx_bcast_bytes;
- __be64 rx_bcast_frames;
- __be64 rx_mcast_bytes;
- __be64 rx_mcast_frames;
- __be64 rx_ucast_bytes;
- __be64 rx_ucast_frames;
- __be64 rx_err_frames;
- } port_stats;
- struct fw_fcoe_fcf_stats {
- __be32 fip_tx_bytes;
- __be32 fip_tx_fr;
- __be64 fcf_ka;
- __be64 mcast_adv_rcvd;
- __be16 ucast_adv_rcvd;
- __be16 sol_sent;
- __be16 vlan_req;
- __be16 vlan_rpl;
- __be16 clr_vlink;
- __be16 link_down;
- __be16 link_up;
- __be16 logo;
- __be16 flogi_req;
- __be16 flogi_rpl;
- __be16 fdisc_req;
- __be16 fdisc_rpl;
- __be16 fka_prd_chg;
- __be16 fc_map_chg;
- __be16 vfid_chg;
- __u8 no_fka_req;
- __u8 no_vnp;
- } fcf_stats;
- struct fw_fcoe_pcb_stats {
- __be64 tx_bytes;
- __be64 tx_frames;
- __be64 rx_bytes;
- __be64 rx_frames;
- __be32 vnp_ka;
- __be32 unsol_els_rcvd;
- __be64 unsol_cmd_rcvd;
- __be16 implicit_logo;
- __be16 flogi_inv_sparm;
- __be16 fdisc_inv_sparm;
- __be16 flogi_rjt;
- __be16 fdisc_rjt;
- __be16 no_ssn;
- __be16 mac_flt_fail;
- __be16 inv_fr_rcvd;
- } pcb_stats;
- struct fw_fcoe_scb_stats {
- __be64 tx_bytes;
- __be64 tx_frames;
- __be64 rx_bytes;
- __be64 rx_frames;
- __be32 host_abrt_req;
- __be32 adap_auto_abrt;
- __be32 adap_abrt_rsp;
- __be32 host_ios_req;
- __be16 ssn_offl_ios;
- __be16 ssn_not_rdy_ios;
- __u8 rx_data_ddp_err;
- __u8 ddp_flt_set_err;
- __be16 rx_data_fr_err;
- __u8 bad_st_abrt_req;
- __u8 no_io_abrt_req;
- __u8 abort_tmo;
- __u8 abort_tmo_2;
- __be32 abort_req;
- __u8 no_ppod_res_tmo;
- __u8 bp_tmo;
- __u8 adap_auto_cls;
- __u8 no_io_cls_req;
- __be32 host_cls_req;
- __be64 unsol_cmd_rcvd;
- __be32 plogi_req_rcvd;
- __be32 prli_req_rcvd;
- __be16 logo_req_rcvd;
- __be16 prlo_req_rcvd;
- __be16 plogi_rjt_rcvd;
- __be16 prli_rjt_rcvd;
- __be32 adisc_req_rcvd;
- __be32 rscn_rcvd;
- __be32 rrq_req_rcvd;
- __be32 unsol_els_rcvd;
- __u8 adisc_rjt_rcvd;
- __u8 scr_rjt;
- __u8 ct_rjt;
- __u8 inval_bls_rcvd;
- __be32 ba_rjt_rcvd;
- } scb_stats;
- } u;
-};
-
-#define S_FW_FCOE_STATS_CMD_FLOWID 0
-#define M_FW_FCOE_STATS_CMD_FLOWID 0xfffff
-#define V_FW_FCOE_STATS_CMD_FLOWID(x) ((x) << S_FW_FCOE_STATS_CMD_FLOWID)
-#define G_FW_FCOE_STATS_CMD_FLOWID(x) \
- (((x) >> S_FW_FCOE_STATS_CMD_FLOWID) & M_FW_FCOE_STATS_CMD_FLOWID)
-
-#define S_FW_FCOE_STATS_CMD_FREE 30
-#define M_FW_FCOE_STATS_CMD_FREE 0x1
-#define V_FW_FCOE_STATS_CMD_FREE(x) ((x) << S_FW_FCOE_STATS_CMD_FREE)
-#define G_FW_FCOE_STATS_CMD_FREE(x) \
- (((x) >> S_FW_FCOE_STATS_CMD_FREE) & M_FW_FCOE_STATS_CMD_FREE)
-#define F_FW_FCOE_STATS_CMD_FREE V_FW_FCOE_STATS_CMD_FREE(1U)
-
-#define S_FW_FCOE_STATS_CMD_NSTATS 4
-#define M_FW_FCOE_STATS_CMD_NSTATS 0x7
-#define V_FW_FCOE_STATS_CMD_NSTATS(x) ((x) << S_FW_FCOE_STATS_CMD_NSTATS)
-#define G_FW_FCOE_STATS_CMD_NSTATS(x) \
- (((x) >> S_FW_FCOE_STATS_CMD_NSTATS) & M_FW_FCOE_STATS_CMD_NSTATS)
-
-#define S_FW_FCOE_STATS_CMD_PORT 0
-#define M_FW_FCOE_STATS_CMD_PORT 0x3
-#define V_FW_FCOE_STATS_CMD_PORT(x) ((x) << S_FW_FCOE_STATS_CMD_PORT)
-#define G_FW_FCOE_STATS_CMD_PORT(x) \
- (((x) >> S_FW_FCOE_STATS_CMD_PORT) & M_FW_FCOE_STATS_CMD_PORT)
-
-#define S_FW_FCOE_STATS_CMD_PORT_VALID 7
-#define M_FW_FCOE_STATS_CMD_PORT_VALID 0x1
-#define V_FW_FCOE_STATS_CMD_PORT_VALID(x) \
- ((x) << S_FW_FCOE_STATS_CMD_PORT_VALID)
-#define G_FW_FCOE_STATS_CMD_PORT_VALID(x) \
- (((x) >> S_FW_FCOE_STATS_CMD_PORT_VALID) & M_FW_FCOE_STATS_CMD_PORT_VALID)
-#define F_FW_FCOE_STATS_CMD_PORT_VALID V_FW_FCOE_STATS_CMD_PORT_VALID(1U)
-
-#define S_FW_FCOE_STATS_CMD_IX 0
-#define M_FW_FCOE_STATS_CMD_IX 0x3f
-#define V_FW_FCOE_STATS_CMD_IX(x) ((x) << S_FW_FCOE_STATS_CMD_IX)
-#define G_FW_FCOE_STATS_CMD_IX(x) \
- (((x) >> S_FW_FCOE_STATS_CMD_IX) & M_FW_FCOE_STATS_CMD_IX)
-
-struct fw_fcoe_fcf_cmd {
- __be32 op_to_fcfi;
- __be32 retval_len16;
- __be16 priority_pkd;
- __u8 mac[6];
- __u8 name_id[8];
- __u8 fabric[8];
- __be16 vf_id;
- __be16 max_fcoe_size;
- __u8 vlan_id;
- __u8 fc_map[3];
- __be32 fka_adv;
- __be32 r6;
- __u8 r7_hi;
- __u8 fpma_to_portid;
- __u8 spma_mac[6];
- __be64 r8;
-};
-
-#define S_FW_FCOE_FCF_CMD_FCFI 0
-#define M_FW_FCOE_FCF_CMD_FCFI 0xfffff
-#define V_FW_FCOE_FCF_CMD_FCFI(x) ((x) << S_FW_FCOE_FCF_CMD_FCFI)
-#define G_FW_FCOE_FCF_CMD_FCFI(x) \
- (((x) >> S_FW_FCOE_FCF_CMD_FCFI) & M_FW_FCOE_FCF_CMD_FCFI)
-
-#define S_FW_FCOE_FCF_CMD_PRIORITY 0
-#define M_FW_FCOE_FCF_CMD_PRIORITY 0xff
-#define V_FW_FCOE_FCF_CMD_PRIORITY(x) ((x) << S_FW_FCOE_FCF_CMD_PRIORITY)
-#define G_FW_FCOE_FCF_CMD_PRIORITY(x) \
- (((x) >> S_FW_FCOE_FCF_CMD_PRIORITY) & M_FW_FCOE_FCF_CMD_PRIORITY)
-
-#define S_FW_FCOE_FCF_CMD_FPMA 6
-#define M_FW_FCOE_FCF_CMD_FPMA 0x1
-#define V_FW_FCOE_FCF_CMD_FPMA(x) ((x) << S_FW_FCOE_FCF_CMD_FPMA)
-#define G_FW_FCOE_FCF_CMD_FPMA(x) \
- (((x) >> S_FW_FCOE_FCF_CMD_FPMA) & M_FW_FCOE_FCF_CMD_FPMA)
-#define F_FW_FCOE_FCF_CMD_FPMA V_FW_FCOE_FCF_CMD_FPMA(1U)
-
-#define S_FW_FCOE_FCF_CMD_SPMA 5
-#define M_FW_FCOE_FCF_CMD_SPMA 0x1
-#define V_FW_FCOE_FCF_CMD_SPMA(x) ((x) << S_FW_FCOE_FCF_CMD_SPMA)
-#define G_FW_FCOE_FCF_CMD_SPMA(x) \
- (((x) >> S_FW_FCOE_FCF_CMD_SPMA) & M_FW_FCOE_FCF_CMD_SPMA)
-#define F_FW_FCOE_FCF_CMD_SPMA V_FW_FCOE_FCF_CMD_SPMA(1U)
-
-#define S_FW_FCOE_FCF_CMD_LOGIN 4
-#define M_FW_FCOE_FCF_CMD_LOGIN 0x1
-#define V_FW_FCOE_FCF_CMD_LOGIN(x) ((x) << S_FW_FCOE_FCF_CMD_LOGIN)
-#define G_FW_FCOE_FCF_CMD_LOGIN(x) \
- (((x) >> S_FW_FCOE_FCF_CMD_LOGIN) & M_FW_FCOE_FCF_CMD_LOGIN)
-#define F_FW_FCOE_FCF_CMD_LOGIN V_FW_FCOE_FCF_CMD_LOGIN(1U)
-
-#define S_FW_FCOE_FCF_CMD_PORTID 0
-#define M_FW_FCOE_FCF_CMD_PORTID 0xf
-#define V_FW_FCOE_FCF_CMD_PORTID(x) ((x) << S_FW_FCOE_FCF_CMD_PORTID)
-#define G_FW_FCOE_FCF_CMD_PORTID(x) \
- (((x) >> S_FW_FCOE_FCF_CMD_PORTID) & M_FW_FCOE_FCF_CMD_PORTID)
-
-/******************************************************************************
- * E R R O R a n d D E B U G C O M M A N D s
- ******************************************************/
-
-enum fw_error_type {
- FW_ERROR_TYPE_EXCEPTION = 0x0,
- FW_ERROR_TYPE_HWMODULE = 0x1,
- FW_ERROR_TYPE_WR = 0x2,
- FW_ERROR_TYPE_ACL = 0x3,
-};
-
-struct fw_error_cmd {
- __be32 op_to_type;
- __be32 len16_pkd;
- union fw_error {
- struct fw_error_exception {
- __be32 info[6];
- } exception;
- struct fw_error_hwmodule {
- __be32 regaddr;
- __be32 regval;
- } hwmodule;
- struct fw_error_wr {
- __be16 cidx;
- __be16 pfn_vfn;
- __be32 eqid;
- __u8 wrhdr[16];
- } wr;
- struct fw_error_acl {
- __be16 cidx;
- __be16 pfn_vfn;
- __be32 eqid;
- __be16 mv_pkd;
- __u8 val[6];
- __be64 r4;
- } acl;
- } u;
-};
-
-#define S_FW_ERROR_CMD_FATAL 4
-#define M_FW_ERROR_CMD_FATAL 0x1
-#define V_FW_ERROR_CMD_FATAL(x) ((x) << S_FW_ERROR_CMD_FATAL)
-#define G_FW_ERROR_CMD_FATAL(x) \
- (((x) >> S_FW_ERROR_CMD_FATAL) & M_FW_ERROR_CMD_FATAL)
-#define F_FW_ERROR_CMD_FATAL V_FW_ERROR_CMD_FATAL(1U)
-
-#define S_FW_ERROR_CMD_TYPE 0
-#define M_FW_ERROR_CMD_TYPE 0xf
-#define V_FW_ERROR_CMD_TYPE(x) ((x) << S_FW_ERROR_CMD_TYPE)
-#define G_FW_ERROR_CMD_TYPE(x) \
- (((x) >> S_FW_ERROR_CMD_TYPE) & M_FW_ERROR_CMD_TYPE)
-
-#define S_FW_ERROR_CMD_PFN 8
-#define M_FW_ERROR_CMD_PFN 0x7
-#define V_FW_ERROR_CMD_PFN(x) ((x) << S_FW_ERROR_CMD_PFN)
-#define G_FW_ERROR_CMD_PFN(x) \
- (((x) >> S_FW_ERROR_CMD_PFN) & M_FW_ERROR_CMD_PFN)
-
-#define S_FW_ERROR_CMD_VFN 0
-#define M_FW_ERROR_CMD_VFN 0xff
-#define V_FW_ERROR_CMD_VFN(x) ((x) << S_FW_ERROR_CMD_VFN)
-#define G_FW_ERROR_CMD_VFN(x) \
- (((x) >> S_FW_ERROR_CMD_VFN) & M_FW_ERROR_CMD_VFN)
-
-#define S_FW_ERROR_CMD_PFN 8
-#define M_FW_ERROR_CMD_PFN 0x7
-#define V_FW_ERROR_CMD_PFN(x) ((x) << S_FW_ERROR_CMD_PFN)
-#define G_FW_ERROR_CMD_PFN(x) \
- (((x) >> S_FW_ERROR_CMD_PFN) & M_FW_ERROR_CMD_PFN)
-
-#define S_FW_ERROR_CMD_VFN 0
-#define M_FW_ERROR_CMD_VFN 0xff
-#define V_FW_ERROR_CMD_VFN(x) ((x) << S_FW_ERROR_CMD_VFN)
-#define G_FW_ERROR_CMD_VFN(x) \
- (((x) >> S_FW_ERROR_CMD_VFN) & M_FW_ERROR_CMD_VFN)
-
-#define S_FW_ERROR_CMD_MV 15
-#define M_FW_ERROR_CMD_MV 0x1
-#define V_FW_ERROR_CMD_MV(x) ((x) << S_FW_ERROR_CMD_MV)
-#define G_FW_ERROR_CMD_MV(x) \
- (((x) >> S_FW_ERROR_CMD_MV) & M_FW_ERROR_CMD_MV)
-#define F_FW_ERROR_CMD_MV V_FW_ERROR_CMD_MV(1U)
-
-struct fw_debug_cmd {
- __be32 op_type;
- __be32 len16_pkd;
- union fw_debug {
- struct fw_debug_assert {
- __be32 fcid;
- __be32 line;
- __be32 x;
- __be32 y;
- __u8 filename_0_7[8];
- __u8 filename_8_15[8];
- __be64 r3;
- } assert;
- struct fw_debug_prt {
- __be16 dprtstridx;
- __be16 r3[3];
- __be32 dprtstrparam0;
- __be32 dprtstrparam1;
- __be32 dprtstrparam2;
- __be32 dprtstrparam3;
- } prt;
- } u;
-};
-
-#define S_FW_DEBUG_CMD_TYPE 0
-#define M_FW_DEBUG_CMD_TYPE 0xff
-#define V_FW_DEBUG_CMD_TYPE(x) ((x) << S_FW_DEBUG_CMD_TYPE)
-#define G_FW_DEBUG_CMD_TYPE(x) \
- (((x) >> S_FW_DEBUG_CMD_TYPE) & M_FW_DEBUG_CMD_TYPE)
-
-/******************************************************************************
- * P C I E F W R E G I S T E R
- **************************************/
-
-enum pcie_fw_eval {
- PCIE_FW_EVAL_CRASH = 0,
- PCIE_FW_EVAL_PREP = 1,
- PCIE_FW_EVAL_CONF = 2,
- PCIE_FW_EVAL_INIT = 3,
- PCIE_FW_EVAL_UNEXPECTEDEVENT = 4,
- PCIE_FW_EVAL_OVERHEAT = 5,
- PCIE_FW_EVAL_DEVICESHUTDOWN = 6,
-};
-
-/**
- * Register definitions for the PCIE_FW register which the firmware uses
- * to retain status across RESETs. This register should be considered
- * as a READ-ONLY register for Host Software and only to be used to
- * track firmware initialization/error state, etc.
- */
-#define S_PCIE_FW_ERR 31
-#define M_PCIE_FW_ERR 0x1
-#define V_PCIE_FW_ERR(x) ((x) << S_PCIE_FW_ERR)
-#define G_PCIE_FW_ERR(x) (((x) >> S_PCIE_FW_ERR) & M_PCIE_FW_ERR)
-#define F_PCIE_FW_ERR V_PCIE_FW_ERR(1U)
-
-#define S_PCIE_FW_INIT 30
-#define M_PCIE_FW_INIT 0x1
-#define V_PCIE_FW_INIT(x) ((x) << S_PCIE_FW_INIT)
-#define G_PCIE_FW_INIT(x) (((x) >> S_PCIE_FW_INIT) & M_PCIE_FW_INIT)
-#define F_PCIE_FW_INIT V_PCIE_FW_INIT(1U)
-
-#define S_PCIE_FW_HALT 29
-#define M_PCIE_FW_HALT 0x1
-#define V_PCIE_FW_HALT(x) ((x) << S_PCIE_FW_HALT)
-#define G_PCIE_FW_HALT(x) (((x) >> S_PCIE_FW_HALT) & M_PCIE_FW_HALT)
-#define F_PCIE_FW_HALT V_PCIE_FW_HALT(1U)
-
-#define S_PCIE_FW_EVAL 24
-#define M_PCIE_FW_EVAL 0x7
-#define V_PCIE_FW_EVAL(x) ((x) << S_PCIE_FW_EVAL)
-#define G_PCIE_FW_EVAL(x) (((x) >> S_PCIE_FW_EVAL) & M_PCIE_FW_EVAL)
-
-#define S_PCIE_FW_STAGE 21
-#define M_PCIE_FW_STAGE 0x7
-#define V_PCIE_FW_STAGE(x) ((x) << S_PCIE_FW_STAGE)
-#define G_PCIE_FW_STAGE(x) (((x) >> S_PCIE_FW_STAGE) & M_PCIE_FW_STAGE)
-
-#define S_PCIE_FW_ASYNCNOT_VLD 20
-#define M_PCIE_FW_ASYNCNOT_VLD 0x1
-#define V_PCIE_FW_ASYNCNOT_VLD(x) \
- ((x) << S_PCIE_FW_ASYNCNOT_VLD)
-#define G_PCIE_FW_ASYNCNOT_VLD(x) \
- (((x) >> S_PCIE_FW_ASYNCNOT_VLD) & M_PCIE_FW_ASYNCNOT_VLD)
-#define F_PCIE_FW_ASYNCNOT_VLD V_PCIE_FW_ASYNCNOT_VLD(1U)
-
-#define S_PCIE_FW_ASYNCNOTINT 19
-#define M_PCIE_FW_ASYNCNOTINT 0x1
-#define V_PCIE_FW_ASYNCNOTINT(x) \
- ((x) << S_PCIE_FW_ASYNCNOTINT)
-#define G_PCIE_FW_ASYNCNOTINT(x) \
- (((x) >> S_PCIE_FW_ASYNCNOTINT) & M_PCIE_FW_ASYNCNOTINT)
-#define F_PCIE_FW_ASYNCNOTINT V_PCIE_FW_ASYNCNOTINT(1U)
-
-#define S_PCIE_FW_ASYNCNOT 16
-#define M_PCIE_FW_ASYNCNOT 0x7
-#define V_PCIE_FW_ASYNCNOT(x) ((x) << S_PCIE_FW_ASYNCNOT)
-#define G_PCIE_FW_ASYNCNOT(x) \
- (((x) >> S_PCIE_FW_ASYNCNOT) & M_PCIE_FW_ASYNCNOT)
-
-#define S_PCIE_FW_MASTER_VLD 15
-#define M_PCIE_FW_MASTER_VLD 0x1
-#define V_PCIE_FW_MASTER_VLD(x) ((x) << S_PCIE_FW_MASTER_VLD)
-#define G_PCIE_FW_MASTER_VLD(x) \
- (((x) >> S_PCIE_FW_MASTER_VLD) & M_PCIE_FW_MASTER_VLD)
-#define F_PCIE_FW_MASTER_VLD V_PCIE_FW_MASTER_VLD(1U)
-
-#define S_PCIE_FW_MASTER 12
-#define M_PCIE_FW_MASTER 0x7
-#define V_PCIE_FW_MASTER(x) ((x) << S_PCIE_FW_MASTER)
-#define G_PCIE_FW_MASTER(x) (((x) >> S_PCIE_FW_MASTER) & M_PCIE_FW_MASTER)
-
-#define S_PCIE_FW_RESET_VLD 11
-#define M_PCIE_FW_RESET_VLD 0x1
-#define V_PCIE_FW_RESET_VLD(x) ((x) << S_PCIE_FW_RESET_VLD)
-#define G_PCIE_FW_RESET_VLD(x) \
- (((x) >> S_PCIE_FW_RESET_VLD) & M_PCIE_FW_RESET_VLD)
-#define F_PCIE_FW_RESET_VLD V_PCIE_FW_RESET_VLD(1U)
-
-#define S_PCIE_FW_RESET 8
-#define M_PCIE_FW_RESET 0x7
-#define V_PCIE_FW_RESET(x) ((x) << S_PCIE_FW_RESET)
-#define G_PCIE_FW_RESET(x) \
- (((x) >> S_PCIE_FW_RESET) & M_PCIE_FW_RESET)
-
-#define S_PCIE_FW_REGISTERED 0
-#define M_PCIE_FW_REGISTERED 0xff
-#define V_PCIE_FW_REGISTERED(x) ((x) << S_PCIE_FW_REGISTERED)
-#define G_PCIE_FW_REGISTERED(x) \
- (((x) >> S_PCIE_FW_REGISTERED) & M_PCIE_FW_REGISTERED)
-
-
-/******************************************************************************
- * P C I E F W P F 0 R E G I S T E R
- **********************************************/
-
-/*
- * this register is available as 32-bit of persistent storage (accross
- * PL_RST based chip-reset) for boot drivers (i.e. firmware and driver
- * will not write it)
- */
-
-
-/******************************************************************************
- * B I N A R Y H E A D E R F O R M A T
- **********************************************/
-
-/*
- * firmware binary header format
- */
-struct fw_hdr {
- __u8 ver;
- __u8 chip; /* terminator chip family */
- __be16 len512; /* bin length in units of 512-bytes */
- __be32 fw_ver; /* firmware version */
- __be32 tp_microcode_ver; /* tcp processor microcode version */
- __u8 intfver_nic;
- __u8 intfver_vnic;
- __u8 intfver_ofld;
- __u8 intfver_ri;
- __u8 intfver_iscsipdu;
- __u8 intfver_iscsi;
- __u8 intfver_fcoepdu;
- __u8 intfver_fcoe;
- __u32 reserved2;
- __u32 reserved3;
- __u32 magic; /* runtime or bootstrap fw */
- __be32 flags;
- __be32 reserved6[23];
-};
-
-enum fw_hdr_chip {
- FW_HDR_CHIP_T4,
- FW_HDR_CHIP_T5
-};
-
-#define S_FW_HDR_FW_VER_MAJOR 24
-#define M_FW_HDR_FW_VER_MAJOR 0xff
-#define V_FW_HDR_FW_VER_MAJOR(x) \
- ((x) << S_FW_HDR_FW_VER_MAJOR)
-#define G_FW_HDR_FW_VER_MAJOR(x) \
- (((x) >> S_FW_HDR_FW_VER_MAJOR) & M_FW_HDR_FW_VER_MAJOR)
-
-#define S_FW_HDR_FW_VER_MINOR 16
-#define M_FW_HDR_FW_VER_MINOR 0xff
-#define V_FW_HDR_FW_VER_MINOR(x) \
- ((x) << S_FW_HDR_FW_VER_MINOR)
-#define G_FW_HDR_FW_VER_MINOR(x) \
- (((x) >> S_FW_HDR_FW_VER_MINOR) & M_FW_HDR_FW_VER_MINOR)
-
-#define S_FW_HDR_FW_VER_MICRO 8
-#define M_FW_HDR_FW_VER_MICRO 0xff
-#define V_FW_HDR_FW_VER_MICRO(x) \
- ((x) << S_FW_HDR_FW_VER_MICRO)
-#define G_FW_HDR_FW_VER_MICRO(x) \
- (((x) >> S_FW_HDR_FW_VER_MICRO) & M_FW_HDR_FW_VER_MICRO)
-
-#define S_FW_HDR_FW_VER_BUILD 0
-#define M_FW_HDR_FW_VER_BUILD 0xff
-#define V_FW_HDR_FW_VER_BUILD(x) \
- ((x) << S_FW_HDR_FW_VER_BUILD)
-#define G_FW_HDR_FW_VER_BUILD(x) \
- (((x) >> S_FW_HDR_FW_VER_BUILD) & M_FW_HDR_FW_VER_BUILD)
-
-enum {
- /* T4
- */
- FW_HDR_INTFVER_NIC = 0x00,
- FW_HDR_INTFVER_VNIC = 0x00,
- FW_HDR_INTFVER_OFLD = 0x00,
- FW_HDR_INTFVER_RI = 0x00,
- FW_HDR_INTFVER_ISCSIPDU = 0x00,
- FW_HDR_INTFVER_ISCSI = 0x00,
- FW_HDR_INTFVER_FCOEPDU = 0x00,
- FW_HDR_INTFVER_FCOE = 0x00,
-
- /* T5
- */
- T5FW_HDR_INTFVER_NIC = 0x00,
- T5FW_HDR_INTFVER_VNIC = 0x00,
- T5FW_HDR_INTFVER_OFLD = 0x00,
- T5FW_HDR_INTFVER_RI = 0x00,
- T5FW_HDR_INTFVER_ISCSIPDU= 0x00,
- T5FW_HDR_INTFVER_ISCSI = 0x00,
- T5FW_HDR_INTFVER_FCOEPDU= 0x00,
- T5FW_HDR_INTFVER_FCOE = 0x00,
-};
-
-enum {
- FW_HDR_MAGIC_RUNTIME = 0x00000000,
- FW_HDR_MAGIC_BOOTSTRAP = 0x626f6f74,
-};
-
-enum fw_hdr_flags {
- FW_HDR_FLAGS_RESET_HALT = 0x00000001,
-};
-
-#endif /* _T4FW_INTERFACE_H_ */
diff --git a/contrib/ofed/libcxgb4/src/verbs.c b/contrib/ofed/libcxgb4/src/verbs.c
deleted file mode 100644
index 6b99c75..0000000
--- a/contrib/ofed/libcxgb4/src/verbs.c
+++ /dev/null
@@ -1,714 +0,0 @@
-/*
- * Copyright (c) 2006-2014 Chelsio, Inc. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-#if HAVE_CONFIG_H
-# include <config.h>
-#endif /* HAVE_CONFIG_H */
-
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-#include <errno.h>
-#include <pthread.h>
-#include <sys/mman.h>
-#include <netinet/in.h>
-#include <inttypes.h>
-#include <assert.h>
-
-#include "libcxgb4.h"
-#include "cxgb4-abi.h"
-
-#define MASKED(x) (void *)((unsigned long)(x) & c4iw_page_mask)
-
-int c4iw_query_device(struct ibv_context *context, struct ibv_device_attr *attr)
-{
- struct ibv_query_device cmd;
- uint64_t raw_fw_ver;
- unsigned major, minor, sub_minor;
- int ret;
-
- ret = ibv_cmd_query_device(context, attr, &raw_fw_ver, &cmd,
- sizeof cmd);
- if (ret)
- return ret;
-
- major = (raw_fw_ver >> 32) & 0xffff;
- minor = (raw_fw_ver >> 16) & 0xffff;
- sub_minor = raw_fw_ver & 0xffff;
-
- snprintf(attr->fw_ver, sizeof attr->fw_ver,
- "%d.%d.%d", major, minor, sub_minor);
-
- return 0;
-}
-
-int c4iw_query_port(struct ibv_context *context, uint8_t port,
- struct ibv_port_attr *attr)
-{
- struct ibv_query_port cmd;
-
- return ibv_cmd_query_port(context, port, attr, &cmd, sizeof cmd);
-}
-
-struct ibv_pd *c4iw_alloc_pd(struct ibv_context *context)
-{
- struct ibv_alloc_pd cmd;
- struct c4iw_alloc_pd_resp resp;
- struct c4iw_pd *pd;
-
- pd = malloc(sizeof *pd);
- if (!pd)
- return NULL;
-
- if (ibv_cmd_alloc_pd(context, &pd->ibv_pd, &cmd, sizeof cmd,
- &resp.ibv_resp, sizeof resp)) {
- free(pd);
- return NULL;
- }
-
- return &pd->ibv_pd;
-}
-
-int c4iw_free_pd(struct ibv_pd *pd)
-{
- int ret;
-
- ret = ibv_cmd_dealloc_pd(pd);
- if (ret)
- return ret;
-
- free(pd);
- return 0;
-}
-
-static struct ibv_mr *__c4iw_reg_mr(struct ibv_pd *pd, void *addr,
- size_t length, uint64_t hca_va,
- int access)
-{
- struct c4iw_mr *mhp;
- struct ibv_reg_mr cmd;
- struct ibv_reg_mr_resp resp;
- struct c4iw_dev *dev = to_c4iw_dev(pd->context->device);
-
- mhp = malloc(sizeof *mhp);
- if (!mhp)
- return NULL;
-
- if (ibv_cmd_reg_mr(pd, addr, length, hca_va,
- access, &mhp->ibv_mr, &cmd, sizeof cmd,
- &resp, sizeof resp)) {
- free(mhp);
- return NULL;
- }
-
- mhp->va_fbo = hca_va;
- mhp->len = length;
-
- PDBG("%s stag 0x%x va_fbo 0x%" PRIx64 " len %d\n",
- __func__, mhp->ibv_mr.rkey, mhp->va_fbo, mhp->len);
-
- pthread_spin_lock(&dev->lock);
- dev->mmid2ptr[c4iw_mmid(mhp->ibv_mr.lkey)] = mhp;
- pthread_spin_unlock(&dev->lock);
- INC_STAT(mr);
- return &mhp->ibv_mr;
-}
-
-struct ibv_mr *c4iw_reg_mr(struct ibv_pd *pd, void *addr,
- size_t length, int access)
-{
- PDBG("%s addr %p length %ld\n", __func__, addr, length);
- return __c4iw_reg_mr(pd, addr, length, (uintptr_t) addr, access);
-}
-
-int c4iw_dereg_mr(struct ibv_mr *mr)
-{
- int ret;
- struct c4iw_dev *dev = to_c4iw_dev(mr->pd->context->device);
-
- ret = ibv_cmd_dereg_mr(mr);
- if (ret)
- return ret;
-
- pthread_spin_lock(&dev->lock);
- dev->mmid2ptr[c4iw_mmid(mr->lkey)] = NULL;
- pthread_spin_unlock(&dev->lock);
-
- free(to_c4iw_mr(mr));
-
- return 0;
-}
-
-struct ibv_cq *c4iw_create_cq(struct ibv_context *context, int cqe,
- struct ibv_comp_channel *channel, int comp_vector)
-{
- struct ibv_create_cq cmd;
- struct c4iw_create_cq_resp resp;
- struct c4iw_cq *chp;
- struct c4iw_dev *dev = to_c4iw_dev(context->device);
- int ret;
-
- chp = calloc(1, sizeof *chp);
- if (!chp) {
- return NULL;
- }
-
- resp.reserved = 0;
- ret = ibv_cmd_create_cq(context, cqe, channel, comp_vector,
- &chp->ibv_cq, &cmd, sizeof cmd,
- &resp.ibv_resp, sizeof resp);
- if (ret)
- goto err1;
-
- if (resp.reserved)
- PDBG("%s c4iw_create_cq_resp reserved field modified by kernel\n",
- __FUNCTION__);
-
- pthread_spin_init(&chp->lock, PTHREAD_PROCESS_PRIVATE);
-#ifdef STALL_DETECTION
- gettimeofday(&chp->time, NULL);
-#endif
- chp->rhp = dev;
- chp->cq.qid_mask = resp.qid_mask;
- chp->cq.cqid = resp.cqid;
- chp->cq.size = resp.size;
- chp->cq.memsize = resp.memsize;
- chp->cq.gen = 1;
- chp->cq.queue = mmap(NULL, chp->cq.memsize, PROT_READ|PROT_WRITE,
- MAP_SHARED, context->cmd_fd, resp.key);
- if (chp->cq.queue == MAP_FAILED)
- goto err2;
-
- chp->cq.ugts = mmap(NULL, c4iw_page_size, PROT_WRITE, MAP_SHARED,
- context->cmd_fd, resp.gts_key);
- if (chp->cq.ugts == MAP_FAILED)
- goto err3;
-
- if (dev_is_t4(chp->rhp))
- chp->cq.ugts += 1;
- else
- chp->cq.ugts += 5;
- chp->cq.sw_queue = calloc(chp->cq.size, sizeof *chp->cq.queue);
- if (!chp->cq.sw_queue)
- goto err4;
-
- PDBG("%s cqid 0x%x key %" PRIx64 " va %p memsize %lu gts_key %"
- PRIx64 " va %p qid_mask 0x%x\n",
- __func__, chp->cq.cqid, resp.key, chp->cq.queue,
- chp->cq.memsize, resp.gts_key, chp->cq.ugts, chp->cq.qid_mask);
-
- pthread_spin_lock(&dev->lock);
- dev->cqid2ptr[chp->cq.cqid] = chp;
- pthread_spin_unlock(&dev->lock);
- INC_STAT(cq);
- return &chp->ibv_cq;
-err4:
- munmap(MASKED(chp->cq.ugts), c4iw_page_size);
-err3:
- munmap(chp->cq.queue, chp->cq.memsize);
-err2:
- (void)ibv_cmd_destroy_cq(&chp->ibv_cq);
-err1:
- free(chp);
- return NULL;
-}
-
-int c4iw_resize_cq(struct ibv_cq *ibcq, int cqe)
-{
-#if 0
- int ret;
-
- struct ibv_resize_cq cmd;
- struct ibv_resize_cq_resp resp;
- ret = ibv_cmd_resize_cq(ibcq, cqe, &cmd, sizeof cmd, &resp, sizeof resp);
- PDBG("%s ret %d\n", __func__, ret);
- return ret;
-#else
- return -ENOSYS;
-#endif
-}
-
-int c4iw_destroy_cq(struct ibv_cq *ibcq)
-{
- int ret;
- struct c4iw_cq *chp = to_c4iw_cq(ibcq);
- struct c4iw_dev *dev = to_c4iw_dev(ibcq->context->device);
-
- chp->cq.error = 1;
- ret = ibv_cmd_destroy_cq(ibcq);
- if (ret) {
- return ret;
- }
- munmap(MASKED(chp->cq.ugts), c4iw_page_size);
- munmap(chp->cq.queue, chp->cq.memsize);
-
- pthread_spin_lock(&dev->lock);
- dev->cqid2ptr[chp->cq.cqid] = NULL;
- pthread_spin_unlock(&dev->lock);
-
- free(chp->cq.sw_queue);
- free(chp);
- return 0;
-}
-
-struct ibv_srq *c4iw_create_srq(struct ibv_pd *pd,
- struct ibv_srq_init_attr *attr)
-{
- return NULL;
-}
-
-int c4iw_modify_srq(struct ibv_srq *srq, struct ibv_srq_attr *attr,
- int attr_mask)
-{
- return ENOSYS;
-}
-
-int c4iw_destroy_srq(struct ibv_srq *srq)
-{
- return ENOSYS;
-}
-
-int c4iw_post_srq_recv(struct ibv_srq *ibsrq, struct ibv_recv_wr *wr,
- struct ibv_recv_wr **bad_wr)
-{
- return ENOSYS;
-}
-
-static struct ibv_qp *create_qp_v0(struct ibv_pd *pd,
- struct ibv_qp_init_attr *attr)
-{
- struct ibv_create_qp cmd;
- struct c4iw_create_qp_resp_v0 resp;
- struct c4iw_qp *qhp;
- struct c4iw_dev *dev = to_c4iw_dev(pd->context->device);
- int ret;
- void *dbva;
-
- PDBG("%s enter qp\n", __func__);
- qhp = calloc(1, sizeof *qhp);
- if (!qhp)
- goto err1;
-
- ret = ibv_cmd_create_qp(pd, &qhp->ibv_qp, attr, &cmd,
- sizeof cmd, &resp.ibv_resp, sizeof resp);
- if (ret)
- goto err2;
-
- PDBG("%s sqid 0x%x sq key %" PRIx64 " sq db/gts key %" PRIx64
- " rqid 0x%x rq key %" PRIx64 " rq db/gts key %" PRIx64
- " qid_mask 0x%x\n",
- __func__,
- resp.sqid, resp.sq_key, resp.sq_db_gts_key,
- resp.rqid, resp.rq_key, resp.rq_db_gts_key, resp.qid_mask);
-
- qhp->wq.qid_mask = resp.qid_mask;
- qhp->rhp = dev;
- qhp->wq.sq.qid = resp.sqid;
- qhp->wq.sq.size = resp.sq_size;
- qhp->wq.sq.memsize = resp.sq_memsize;
- qhp->wq.sq.flags = 0;
- qhp->wq.rq.msn = 1;
- qhp->wq.rq.qid = resp.rqid;
- qhp->wq.rq.size = resp.rq_size;
- qhp->wq.rq.memsize = resp.rq_memsize;
- pthread_spin_init(&qhp->lock, PTHREAD_PROCESS_PRIVATE);
-
- dbva = mmap(NULL, c4iw_page_size, PROT_WRITE, MAP_SHARED,
- pd->context->cmd_fd, resp.sq_db_gts_key);
- if (dbva == MAP_FAILED)
- goto err3;
-
- qhp->wq.sq.udb = dbva;
- qhp->wq.sq.queue = mmap(NULL, qhp->wq.sq.memsize,
- PROT_WRITE, MAP_SHARED,
- pd->context->cmd_fd, resp.sq_key);
- if (qhp->wq.sq.queue == MAP_FAILED)
- goto err4;
-
- dbva = mmap(NULL, c4iw_page_size, PROT_WRITE, MAP_SHARED,
- pd->context->cmd_fd, resp.rq_db_gts_key);
- if (dbva == MAP_FAILED)
- goto err5;
- qhp->wq.rq.udb = dbva;
- qhp->wq.rq.queue = mmap(NULL, qhp->wq.rq.memsize,
- PROT_WRITE, MAP_SHARED,
- pd->context->cmd_fd, resp.rq_key);
- if (qhp->wq.rq.queue == MAP_FAILED)
- goto err6;
-
- qhp->wq.sq.sw_sq = calloc(qhp->wq.sq.size, sizeof (struct t4_swsqe));
- if (!qhp->wq.sq.sw_sq)
- goto err7;
-
- qhp->wq.rq.sw_rq = calloc(qhp->wq.rq.size, sizeof (uint64_t));
- if (!qhp->wq.rq.sw_rq)
- goto err8;
-
- PDBG("%s sq dbva %p sq qva %p sq depth %u sq memsize %lu "
- " rq dbva %p rq qva %p rq depth %u rq memsize %lu\n",
- __func__,
- qhp->wq.sq.udb, qhp->wq.sq.queue,
- qhp->wq.sq.size, qhp->wq.sq.memsize,
- qhp->wq.rq.udb, qhp->wq.rq.queue,
- qhp->wq.rq.size, qhp->wq.rq.memsize);
-
- qhp->sq_sig_all = attr->sq_sig_all;
-
- pthread_spin_lock(&dev->lock);
- dev->qpid2ptr[qhp->wq.sq.qid] = qhp;
- pthread_spin_unlock(&dev->lock);
- INC_STAT(qp);
- return &qhp->ibv_qp;
-err8:
- free(qhp->wq.sq.sw_sq);
-err7:
- munmap((void *)qhp->wq.rq.queue, qhp->wq.rq.memsize);
-err6:
- munmap(MASKED(qhp->wq.rq.udb), c4iw_page_size);
-err5:
- munmap((void *)qhp->wq.sq.queue, qhp->wq.sq.memsize);
-err4:
- munmap(MASKED(qhp->wq.sq.udb), c4iw_page_size);
-err3:
- (void)ibv_cmd_destroy_qp(&qhp->ibv_qp);
-err2:
- free(qhp);
-err1:
- return NULL;
-}
-
-static struct ibv_qp *create_qp(struct ibv_pd *pd,
- struct ibv_qp_init_attr *attr)
-{
- struct ibv_create_qp cmd;
- struct c4iw_create_qp_resp resp;
- struct c4iw_qp *qhp;
- struct c4iw_dev *dev = to_c4iw_dev(pd->context->device);
- struct c4iw_context *ctx = to_c4iw_context(pd->context);
- int ret;
- void *dbva;
-
- PDBG("%s enter qp\n", __func__);
- qhp = calloc(1, sizeof *qhp);
- if (!qhp)
- goto err1;
-
- ret = ibv_cmd_create_qp(pd, &qhp->ibv_qp, attr, &cmd,
- sizeof cmd, &resp.ibv_resp, sizeof resp);
- if (ret)
- goto err2;
-
- PDBG("%s sqid 0x%x sq key %" PRIx64 " sq db/gts key %" PRIx64
- " rqid 0x%x rq key %" PRIx64 " rq db/gts key %" PRIx64
- " qid_mask 0x%x\n",
- __func__,
- resp.sqid, resp.sq_key, resp.sq_db_gts_key,
- resp.rqid, resp.rq_key, resp.rq_db_gts_key, resp.qid_mask);
-
- qhp->wq.qid_mask = resp.qid_mask;
- qhp->rhp = dev;
- qhp->wq.sq.qid = resp.sqid;
- qhp->wq.sq.size = resp.sq_size;
- qhp->wq.sq.memsize = resp.sq_memsize;
- qhp->wq.sq.flags = resp.flags & C4IW_QPF_ONCHIP ? T4_SQ_ONCHIP : 0;
- qhp->wq.sq.flush_cidx = -1;
- qhp->wq.rq.msn = 1;
- qhp->wq.rq.qid = resp.rqid;
- qhp->wq.rq.size = resp.rq_size;
- qhp->wq.rq.memsize = resp.rq_memsize;
- if (ma_wr && resp.sq_memsize < (resp.sq_size + 1) *
- sizeof *qhp->wq.sq.queue + 16*sizeof(__be64) ) {
- ma_wr = 0;
- fprintf(stderr, "libcxgb4 warning - downlevel iw_cxgb4 driver. "
- "MA workaround disabled.\n");
- }
- pthread_spin_init(&qhp->lock, PTHREAD_PROCESS_PRIVATE);
-
- dbva = mmap(NULL, c4iw_page_size, PROT_WRITE, MAP_SHARED,
- pd->context->cmd_fd, resp.sq_db_gts_key);
- if (dbva == MAP_FAILED) {
- PDBG(" %s mmap for sq db failed\n", __func__);
- abort();
- goto err3;
- }
- qhp->wq.sq.udb = dbva;
- if (!dev_is_t4(qhp->rhp)) {
- unsigned long segment_offset = 128 * (qhp->wq.sq.qid & qhp->wq.qid_mask);
-
- if (segment_offset < c4iw_page_size) {
- qhp->wq.sq.udb += segment_offset / 4;
- qhp->wq.sq.wc_reg_available = 1;
- } else
- qhp->wq.sq.bar2_qid = qhp->wq.sq.qid & qhp->wq.qid_mask;
- qhp->wq.sq.udb += 2;
- }
-
- qhp->wq.sq.queue = mmap(NULL, qhp->wq.sq.memsize,
- PROT_READ | PROT_WRITE, MAP_SHARED,
- pd->context->cmd_fd, resp.sq_key);
- if (qhp->wq.sq.queue == MAP_FAILED) {
- PDBG(" %s mmap for sq q failed size is qhp->wq.sq.memsize %zu \n", __func__, qhp->wq.sq.memsize);
- abort();
- goto err4;
- }
-
- dbva = mmap(NULL, c4iw_page_size, PROT_WRITE, MAP_SHARED,
- pd->context->cmd_fd, resp.rq_db_gts_key);
- if (dbva == MAP_FAILED)
- goto err5;
- qhp->wq.rq.udb = dbva;
- if (!dev_is_t4(qhp->rhp)) {
- unsigned long segment_offset = 128 * (qhp->wq.rq.qid & qhp->wq.qid_mask);
-
- if (segment_offset < c4iw_page_size) {
- qhp->wq.rq.udb += segment_offset / 4;
- qhp->wq.rq.wc_reg_available = 1;
- } else
- qhp->wq.rq.bar2_qid = qhp->wq.rq.qid & qhp->wq.qid_mask;
- qhp->wq.rq.udb += 2;
- }
- qhp->wq.rq.queue = mmap(NULL, qhp->wq.rq.memsize,
- PROT_READ | PROT_WRITE, MAP_SHARED,
- pd->context->cmd_fd, resp.rq_key);
- if (qhp->wq.rq.queue == MAP_FAILED)
- goto err6;
-
- qhp->wq.sq.sw_sq = calloc(qhp->wq.sq.size, sizeof (struct t4_swsqe));
- if (!qhp->wq.sq.sw_sq)
- goto err7;
-
- qhp->wq.rq.sw_rq = calloc(qhp->wq.rq.size, sizeof (uint64_t));
- if (!qhp->wq.rq.sw_rq)
- goto err8;
-
- if (t4_sq_onchip(&qhp->wq)) {
- qhp->wq.sq.ma_sync = mmap(NULL, c4iw_page_size, PROT_WRITE,
- MAP_SHARED, pd->context->cmd_fd,
- resp.ma_sync_key);
- if (qhp->wq.sq.ma_sync == MAP_FAILED)
- goto err9;
- qhp->wq.sq.ma_sync += (A_PCIE_MA_SYNC & (c4iw_page_size - 1));
- }
-
- if (ctx->status_page_size) {
- qhp->wq.db_offp = &ctx->status_page->db_off;
- } else {
- qhp->wq.db_offp =
- &qhp->wq.rq.queue[qhp->wq.rq.size].status.db_off;
- }
-
- PDBG("%s sq dbva %p sq qva %p sq depth %u sq memsize %lu "
- " rq dbva %p rq qva %p rq depth %u rq memsize %lu\n",
- __func__,
- qhp->wq.sq.udb, qhp->wq.sq.queue,
- qhp->wq.sq.size, qhp->wq.sq.memsize,
- qhp->wq.rq.udb, qhp->wq.rq.queue,
- qhp->wq.rq.size, qhp->wq.rq.memsize);
-
- qhp->sq_sig_all = attr->sq_sig_all;
-
- pthread_spin_lock(&dev->lock);
- dev->qpid2ptr[qhp->wq.sq.qid] = qhp;
- pthread_spin_unlock(&dev->lock);
- INC_STAT(qp);
- return &qhp->ibv_qp;
-err9:
- free(qhp->wq.rq.sw_rq);
-err8:
- free(qhp->wq.sq.sw_sq);
-err7:
- munmap((void *)qhp->wq.rq.queue, qhp->wq.rq.memsize);
-err6:
- munmap(MASKED(qhp->wq.rq.udb), c4iw_page_size);
-err5:
- munmap((void *)qhp->wq.sq.queue, qhp->wq.sq.memsize);
-err4:
- munmap(MASKED(qhp->wq.sq.udb), c4iw_page_size);
-err3:
- (void)ibv_cmd_destroy_qp(&qhp->ibv_qp);
-err2:
- free(qhp);
-err1:
- return NULL;
-}
-
-struct ibv_qp *c4iw_create_qp(struct ibv_pd *pd,
- struct ibv_qp_init_attr *attr)
-{
- struct c4iw_dev *dev = to_c4iw_dev(pd->context->device);
-
- if (dev->abi_version == 0)
- return create_qp_v0(pd, attr);
- return create_qp(pd, attr);
-}
-
-static void reset_qp(struct c4iw_qp *qhp)
-{
- PDBG("%s enter qp %p\n", __func__, qhp);
- qhp->wq.sq.cidx = 0;
- qhp->wq.sq.wq_pidx = qhp->wq.sq.pidx = qhp->wq.sq.in_use = 0;
- qhp->wq.rq.cidx = qhp->wq.rq.pidx = qhp->wq.rq.in_use = 0;
- qhp->wq.sq.oldest_read = NULL;
- memset(qhp->wq.sq.queue, 0, qhp->wq.sq.memsize);
- memset(qhp->wq.rq.queue, 0, qhp->wq.rq.memsize);
-}
-
-int c4iw_modify_qp(struct ibv_qp *ibqp, struct ibv_qp_attr *attr,
- int attr_mask)
-{
- struct ibv_modify_qp cmd;
- struct c4iw_qp *qhp = to_c4iw_qp(ibqp);
- int ret;
-
- PDBG("%s enter qp %p new state %d\n", __func__, ibqp, attr_mask & IBV_QP_STATE ? attr->qp_state : -1);
- pthread_spin_lock(&qhp->lock);
- if (t4_wq_in_error(&qhp->wq))
- c4iw_flush_qp(qhp);
- ret = ibv_cmd_modify_qp(ibqp, attr, attr_mask, &cmd, sizeof cmd);
- if (!ret && (attr_mask & IBV_QP_STATE) && attr->qp_state == IBV_QPS_RESET)
- reset_qp(qhp);
- pthread_spin_unlock(&qhp->lock);
- return ret;
-}
-
-int c4iw_destroy_qp(struct ibv_qp *ibqp)
-{
- int ret;
- struct c4iw_qp *qhp = to_c4iw_qp(ibqp);
- struct c4iw_dev *dev = to_c4iw_dev(ibqp->context->device);
-
- PDBG("%s enter qp %p\n", __func__, ibqp);
- pthread_spin_lock(&qhp->lock);
- c4iw_flush_qp(qhp);
- pthread_spin_unlock(&qhp->lock);
-
- ret = ibv_cmd_destroy_qp(ibqp);
- if (ret) {
- return ret;
- }
- if (t4_sq_onchip(&qhp->wq)) {
- qhp->wq.sq.ma_sync -= (A_PCIE_MA_SYNC & (c4iw_page_size - 1));
- munmap((void *)qhp->wq.sq.ma_sync, c4iw_page_size);
- }
- munmap(MASKED(qhp->wq.sq.udb), c4iw_page_size);
- munmap(MASKED(qhp->wq.rq.udb), c4iw_page_size);
- munmap(qhp->wq.sq.queue, qhp->wq.sq.memsize);
- munmap(qhp->wq.rq.queue, qhp->wq.rq.memsize);
-
- pthread_spin_lock(&dev->lock);
- dev->qpid2ptr[qhp->wq.sq.qid] = NULL;
- pthread_spin_unlock(&dev->lock);
-
- free(qhp->wq.rq.sw_rq);
- free(qhp->wq.sq.sw_sq);
- free(qhp);
- return 0;
-}
-
-int c4iw_query_qp(struct ibv_qp *ibqp, struct ibv_qp_attr *attr,
- int attr_mask, struct ibv_qp_init_attr *init_attr)
-{
- struct ibv_query_qp cmd;
- struct c4iw_qp *qhp = to_c4iw_qp(ibqp);
- int ret;
-
- pthread_spin_lock(&qhp->lock);
- if (t4_wq_in_error(&qhp->wq))
- c4iw_flush_qp(qhp);
- ret = ibv_cmd_query_qp(ibqp, attr, attr_mask, init_attr, &cmd, sizeof cmd);
- pthread_spin_unlock(&qhp->lock);
- return ret;
-}
-
-struct ibv_ah *c4iw_create_ah(struct ibv_pd *pd, struct ibv_ah_attr *attr)
-{
- return NULL;
-}
-
-int c4iw_destroy_ah(struct ibv_ah *ah)
-{
- return ENOSYS;
-}
-
-int c4iw_attach_mcast(struct ibv_qp *ibqp, const union ibv_gid *gid,
- uint16_t lid)
-{
- struct c4iw_qp *qhp = to_c4iw_qp(ibqp);
- int ret;
-
- pthread_spin_lock(&qhp->lock);
- if (t4_wq_in_error(&qhp->wq))
- c4iw_flush_qp(qhp);
- ret = ibv_cmd_attach_mcast(ibqp, gid, lid);
- pthread_spin_unlock(&qhp->lock);
- return ret;
-}
-
-int c4iw_detach_mcast(struct ibv_qp *ibqp, const union ibv_gid *gid,
- uint16_t lid)
-{
- struct c4iw_qp *qhp = to_c4iw_qp(ibqp);
- int ret;
-
- pthread_spin_lock(&qhp->lock);
- if (t4_wq_in_error(&qhp->wq))
- c4iw_flush_qp(qhp);
- ret = ibv_cmd_detach_mcast(ibqp, gid, lid);
- pthread_spin_unlock(&qhp->lock);
- return ret;
-}
-
-void c4iw_async_event(struct ibv_async_event *event)
-{
- PDBG("%s type %d obj %p\n", __func__, event->event_type,
- event->element.cq);
-
- switch (event->event_type) {
- case IBV_EVENT_CQ_ERR:
- break;
- case IBV_EVENT_QP_FATAL:
- case IBV_EVENT_QP_REQ_ERR:
- case IBV_EVENT_QP_ACCESS_ERR:
- case IBV_EVENT_PATH_MIG_ERR: {
- struct c4iw_qp *qhp = to_c4iw_qp(event->element.qp);
- pthread_spin_lock(&qhp->lock);
- c4iw_flush_qp(qhp);
- pthread_spin_unlock(&qhp->lock);
- break;
- }
- case IBV_EVENT_SQ_DRAINED:
- case IBV_EVENT_PATH_MIG:
- case IBV_EVENT_COMM_EST:
- case IBV_EVENT_QP_LAST_WQE_REACHED:
- default:
- break;
- }
-}
diff --git a/contrib/ofed/libcxgb4/t4.h b/contrib/ofed/libcxgb4/t4.h
new file mode 100644
index 0000000..05984e8
--- /dev/null
+++ b/contrib/ofed/libcxgb4/t4.h
@@ -0,0 +1,735 @@
+/*
+ * Copyright (c) 2006-2016 Chelsio, Inc. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+#ifndef __T4_H__
+#define __T4_H__
+
+#include <assert.h>
+#include <errno.h>
+#include <stddef.h>
+#include <stdint.h>
+#include <syslog.h>
+#include <infiniband/types.h>
+#include <infiniband/udma_barrier.h>
+#include <infiniband/endian.h>
+
+/*
+ * Try and minimize the changes from the kernel code that is pull in
+ * here for kernel bypass ops.
+ */
+#define u8 uint8_t
+#define u16 uint16_t
+#define u32 uint32_t
+#define u64 uint64_t
+#define DECLARE_PCI_UNMAP_ADDR(a)
+#define __iomem
+#define BUG_ON(c) assert(!(c))
+#define ROUND_UP(x, n) (((x) + (n) - 1u) & ~((n) - 1u))
+#define DIV_ROUND_UP(n,d) (((n) + (d) - 1) / (d))
+
+/* FIXME: Move me to a generic PCI mmio accessor */
+#define cpu_to_pci32(val) htole32(val)
+
+#define writel(v, a) do { *((volatile u32 *)(a)) = cpu_to_pci32(v); } while (0)
+
+#include "t4_regs.h"
+#include "t4_chip_type.h"
+#include "t4fw_api.h"
+#include "t4fw_ri_api.h"
+
+#ifdef DEBUG
+#define DBGLOG(s)
+#define PDBG(fmt, args...) do {syslog(LOG_DEBUG, fmt, ##args); } while (0)
+#else
+#define DBGLOG(s)
+#define PDBG(fmt, args...) do {} while (0)
+#endif
+
+#define A_PCIE_MA_SYNC 0x30b4
+
+#define T4_MAX_READ_DEPTH 16
+#define T4_QID_BASE 1024
+#define T4_MAX_QIDS 256
+#define T4_MAX_NUM_PD 65536
+#define T4_EQ_STATUS_ENTRIES (L1_CACHE_BYTES > 64 ? 2 : 1)
+#define T4_MAX_EQ_SIZE (65520 - T4_EQ_STATUS_ENTRIES)
+#define T4_MAX_IQ_SIZE (65520 - 1)
+#define T4_MAX_RQ_SIZE (8192 - T4_EQ_STATUS_ENTRIES)
+#define T4_MAX_SQ_SIZE (T4_MAX_EQ_SIZE - 1)
+#define T4_MAX_QP_DEPTH (T4_MAX_RQ_SIZE - 1)
+#define T4_MAX_CQ_DEPTH (T4_MAX_IQ_SIZE - 1)
+#define T4_MAX_NUM_STAG (1<<15)
+#define T4_MAX_MR_SIZE (~0ULL - 1)
+#define T4_PAGESIZE_MASK 0xffffffff000 /* 4KB-8TB */
+#define T4_STAG_UNSET 0xffffffff
+#define T4_FW_MAJ 0
+
+struct t4_status_page {
+ __be32 rsvd1; /* flit 0 - hw owns */
+ __be16 rsvd2;
+ __be16 qid;
+ __be16 cidx;
+ __be16 pidx;
+ u8 qp_err; /* flit 1 - sw owns */
+ u8 db_off;
+ u8 pad;
+ u16 host_wq_pidx;
+ u16 host_cidx;
+ u16 host_pidx;
+};
+
+#define T4_EQ_ENTRY_SIZE 64
+
+#define T4_SQ_NUM_SLOTS 5
+#define T4_SQ_NUM_BYTES (T4_EQ_ENTRY_SIZE * T4_SQ_NUM_SLOTS)
+#define T4_MAX_SEND_SGE ((T4_SQ_NUM_BYTES - sizeof(struct fw_ri_send_wr) - sizeof(struct fw_ri_isgl)) / sizeof (struct fw_ri_sge))
+#define T4_MAX_SEND_INLINE ((T4_SQ_NUM_BYTES - sizeof(struct fw_ri_send_wr) - sizeof(struct fw_ri_immd)))
+#define T4_MAX_WRITE_INLINE ((T4_SQ_NUM_BYTES - sizeof(struct fw_ri_rdma_write_wr) - sizeof(struct fw_ri_immd)))
+#define T4_MAX_WRITE_SGE ((T4_SQ_NUM_BYTES - sizeof(struct fw_ri_rdma_write_wr) - sizeof(struct fw_ri_isgl)) / sizeof (struct fw_ri_sge))
+#define T4_MAX_FR_IMMD ((T4_SQ_NUM_BYTES - sizeof(struct fw_ri_fr_nsmr_wr) - sizeof(struct fw_ri_immd)))
+#define T4_MAX_FR_DEPTH 255
+
+#define T4_RQ_NUM_SLOTS 2
+#define T4_RQ_NUM_BYTES (T4_EQ_ENTRY_SIZE * T4_RQ_NUM_SLOTS)
+#define T4_MAX_RECV_SGE 4
+
+union t4_wr {
+ struct fw_ri_res_wr res;
+ struct fw_ri_wr init;
+ struct fw_ri_rdma_write_wr write;
+ struct fw_ri_send_wr send;
+ struct fw_ri_rdma_read_wr read;
+ struct fw_ri_bind_mw_wr bind;
+ struct fw_ri_fr_nsmr_wr fr;
+ struct fw_ri_inv_lstag_wr inv;
+ struct t4_status_page status;
+ __be64 flits[T4_EQ_ENTRY_SIZE / sizeof(__be64) * T4_SQ_NUM_SLOTS];
+};
+
+union t4_recv_wr {
+ struct fw_ri_recv_wr recv;
+ struct t4_status_page status;
+ __be64 flits[T4_EQ_ENTRY_SIZE / sizeof(__be64) * T4_RQ_NUM_SLOTS];
+};
+
+static inline void init_wr_hdr(union t4_wr *wqe, u16 wrid,
+ enum fw_wr_opcodes opcode, u8 flags, u8 len16)
+{
+ wqe->send.opcode = (u8)opcode;
+ wqe->send.flags = flags;
+ wqe->send.wrid = wrid;
+ wqe->send.r1[0] = 0;
+ wqe->send.r1[1] = 0;
+ wqe->send.r1[2] = 0;
+ wqe->send.len16 = len16;
+}
+
+/* CQE/AE status codes */
+#define T4_ERR_SUCCESS 0x0
+#define T4_ERR_STAG 0x1 /* STAG invalid: either the */
+ /* STAG is offlimt, being 0, */
+ /* or STAG_key mismatch */
+#define T4_ERR_PDID 0x2 /* PDID mismatch */
+#define T4_ERR_QPID 0x3 /* QPID mismatch */
+#define T4_ERR_ACCESS 0x4 /* Invalid access right */
+#define T4_ERR_WRAP 0x5 /* Wrap error */
+#define T4_ERR_BOUND 0x6 /* base and bounds voilation */
+#define T4_ERR_INVALIDATE_SHARED_MR 0x7 /* attempt to invalidate a */
+ /* shared memory region */
+#define T4_ERR_INVALIDATE_MR_WITH_MW_BOUND 0x8 /* attempt to invalidate a */
+ /* shared memory region */
+#define T4_ERR_ECC 0x9 /* ECC error detected */
+#define T4_ERR_ECC_PSTAG 0xA /* ECC error detected when */
+ /* reading PSTAG for a MW */
+ /* Invalidate */
+#define T4_ERR_PBL_ADDR_BOUND 0xB /* pbl addr out of bounds: */
+ /* software error */
+#define T4_ERR_SWFLUSH 0xC /* SW FLUSHED */
+#define T4_ERR_CRC 0x10 /* CRC error */
+#define T4_ERR_MARKER 0x11 /* Marker error */
+#define T4_ERR_PDU_LEN_ERR 0x12 /* invalid PDU length */
+#define T4_ERR_OUT_OF_RQE 0x13 /* out of RQE */
+#define T4_ERR_DDP_VERSION 0x14 /* wrong DDP version */
+#define T4_ERR_RDMA_VERSION 0x15 /* wrong RDMA version */
+#define T4_ERR_OPCODE 0x16 /* invalid rdma opcode */
+#define T4_ERR_DDP_QUEUE_NUM 0x17 /* invalid ddp queue number */
+#define T4_ERR_MSN 0x18 /* MSN error */
+#define T4_ERR_TBIT 0x19 /* tag bit not set correctly */
+#define T4_ERR_MO 0x1A /* MO not 0 for TERMINATE */
+ /* or READ_REQ */
+#define T4_ERR_MSN_GAP 0x1B
+#define T4_ERR_MSN_RANGE 0x1C
+#define T4_ERR_IRD_OVERFLOW 0x1D
+#define T4_ERR_RQE_ADDR_BOUND 0x1E /* RQE addr out of bounds: */
+ /* software error */
+#define T4_ERR_INTERNAL_ERR 0x1F /* internal error (opcode */
+ /* mismatch) */
+/*
+ * CQE defs
+ */
+struct t4_cqe {
+ __be32 header;
+ __be32 len;
+ union {
+ struct {
+ __be32 stag;
+ __be32 msn;
+ } rcqe;
+ struct {
+ u32 nada1;
+ u16 nada2;
+ u16 cidx;
+ } scqe;
+ struct {
+ __be32 wrid_hi;
+ __be32 wrid_low;
+ } gen;
+ } u;
+ __be64 reserved;
+ __be64 bits_type_ts;
+};
+
+/* macros for flit 0 of the cqe */
+
+#define S_CQE_QPID 12
+#define M_CQE_QPID 0xFFFFF
+#define G_CQE_QPID(x) ((((x) >> S_CQE_QPID)) & M_CQE_QPID)
+#define V_CQE_QPID(x) ((x)<<S_CQE_QPID)
+
+#define S_CQE_SWCQE 11
+#define M_CQE_SWCQE 0x1
+#define G_CQE_SWCQE(x) ((((x) >> S_CQE_SWCQE)) & M_CQE_SWCQE)
+#define V_CQE_SWCQE(x) ((x)<<S_CQE_SWCQE)
+
+#define S_CQE_STATUS 5
+#define M_CQE_STATUS 0x1F
+#define G_CQE_STATUS(x) ((((x) >> S_CQE_STATUS)) & M_CQE_STATUS)
+#define V_CQE_STATUS(x) ((x)<<S_CQE_STATUS)
+
+#define S_CQE_TYPE 4
+#define M_CQE_TYPE 0x1
+#define G_CQE_TYPE(x) ((((x) >> S_CQE_TYPE)) & M_CQE_TYPE)
+#define V_CQE_TYPE(x) ((x)<<S_CQE_TYPE)
+
+#define S_CQE_OPCODE 0
+#define M_CQE_OPCODE 0xF
+#define G_CQE_OPCODE(x) ((((x) >> S_CQE_OPCODE)) & M_CQE_OPCODE)
+#define V_CQE_OPCODE(x) ((x)<<S_CQE_OPCODE)
+
+#define SW_CQE(x) (G_CQE_SWCQE(be32toh((x)->header)))
+#define CQE_QPID(x) (G_CQE_QPID(be32toh((x)->header)))
+#define CQE_TYPE(x) (G_CQE_TYPE(be32toh((x)->header)))
+#define SQ_TYPE(x) (CQE_TYPE((x)))
+#define RQ_TYPE(x) (!CQE_TYPE((x)))
+#define CQE_STATUS(x) (G_CQE_STATUS(be32toh((x)->header)))
+#define CQE_OPCODE(x) (G_CQE_OPCODE(be32toh((x)->header)))
+
+#define CQE_SEND_OPCODE(x)( \
+ (G_CQE_OPCODE(be32toh((x)->header)) == FW_RI_SEND) || \
+ (G_CQE_OPCODE(be32toh((x)->header)) == FW_RI_SEND_WITH_SE) || \
+ (G_CQE_OPCODE(be32toh((x)->header)) == FW_RI_SEND_WITH_INV) || \
+ (G_CQE_OPCODE(be32toh((x)->header)) == FW_RI_SEND_WITH_SE_INV))
+
+#define CQE_LEN(x) (be32toh((x)->len))
+
+/* used for RQ completion processing */
+#define CQE_WRID_STAG(x) (be32toh((x)->u.rcqe.stag))
+#define CQE_WRID_MSN(x) (be32toh((x)->u.rcqe.msn))
+
+/* used for SQ completion processing */
+#define CQE_WRID_SQ_IDX(x) (x)->u.scqe.cidx
+
+/* generic accessor macros */
+#define CQE_WRID_HI(x) ((x)->u.gen.wrid_hi)
+#define CQE_WRID_LOW(x) ((x)->u.gen.wrid_low)
+
+/* macros for flit 3 of the cqe */
+#define S_CQE_GENBIT 63
+#define M_CQE_GENBIT 0x1
+#define G_CQE_GENBIT(x) (((x) >> S_CQE_GENBIT) & M_CQE_GENBIT)
+#define V_CQE_GENBIT(x) ((x)<<S_CQE_GENBIT)
+
+#define S_CQE_OVFBIT 62
+#define M_CQE_OVFBIT 0x1
+#define G_CQE_OVFBIT(x) ((((x) >> S_CQE_OVFBIT)) & M_CQE_OVFBIT)
+
+#define S_CQE_IQTYPE 60
+#define M_CQE_IQTYPE 0x3
+#define G_CQE_IQTYPE(x) ((((x) >> S_CQE_IQTYPE)) & M_CQE_IQTYPE)
+
+#define M_CQE_TS 0x0fffffffffffffffULL
+#define G_CQE_TS(x) ((x) & M_CQE_TS)
+
+#define CQE_OVFBIT(x) ((unsigned)G_CQE_OVFBIT(be64toh((x)->bits_type_ts)))
+#define CQE_GENBIT(x) ((unsigned)G_CQE_GENBIT(be64toh((x)->bits_type_ts)))
+#define CQE_TS(x) (G_CQE_TS(be64toh((x)->bits_type_ts)))
+
+struct t4_swsqe {
+ u64 wr_id;
+ struct t4_cqe cqe;
+ __be32 read_len;
+ int opcode;
+ int complete;
+ int signaled;
+ u16 idx;
+ int flushed;
+};
+
+enum {
+ T4_SQ_ONCHIP = (1<<0),
+};
+
+struct t4_sq {
+ /* queue is either host memory or WC MMIO memory if
+ * t4_sq_onchip(). */
+ union t4_wr *queue;
+ struct t4_swsqe *sw_sq;
+ struct t4_swsqe *oldest_read;
+ /* udb is either UC or WC MMIO memory depending on device version. */
+ volatile u32 *udb;
+ size_t memsize;
+ u32 qid;
+ u32 bar2_qid;
+ void *ma_sync;
+ u16 in_use;
+ u16 size;
+ u16 cidx;
+ u16 pidx;
+ u16 wq_pidx;
+ u16 flags;
+ short flush_cidx;
+ int wc_reg_available;
+};
+
+struct t4_swrqe {
+ u64 wr_id;
+};
+
+struct t4_rq {
+ union t4_recv_wr *queue;
+ struct t4_swrqe *sw_rq;
+ volatile u32 *udb;
+ size_t memsize;
+ u32 qid;
+ u32 bar2_qid;
+ u32 msn;
+ u32 rqt_hwaddr;
+ u16 rqt_size;
+ u16 in_use;
+ u16 size;
+ u16 cidx;
+ u16 pidx;
+ u16 wq_pidx;
+ int wc_reg_available;
+};
+
+struct t4_wq {
+ struct t4_sq sq;
+ struct t4_rq rq;
+ struct c4iw_rdev *rdev;
+ u32 qid_mask;
+ int error;
+ int flushed;
+ u8 *db_offp;
+};
+
+static inline int t4_rqes_posted(struct t4_wq *wq)
+{
+ return wq->rq.in_use;
+}
+
+static inline int t4_rq_empty(struct t4_wq *wq)
+{
+ return wq->rq.in_use == 0;
+}
+
+static inline int t4_rq_full(struct t4_wq *wq)
+{
+ return wq->rq.in_use == (wq->rq.size - 1);
+}
+
+static inline u32 t4_rq_avail(struct t4_wq *wq)
+{
+ return wq->rq.size - 1 - wq->rq.in_use;
+}
+
+static inline void t4_rq_produce(struct t4_wq *wq, u8 len16)
+{
+ wq->rq.in_use++;
+ if (++wq->rq.pidx == wq->rq.size)
+ wq->rq.pidx = 0;
+ wq->rq.wq_pidx += DIV_ROUND_UP(len16*16, T4_EQ_ENTRY_SIZE);
+ if (wq->rq.wq_pidx >= wq->rq.size * T4_RQ_NUM_SLOTS)
+ wq->rq.wq_pidx %= wq->rq.size * T4_RQ_NUM_SLOTS;
+ if (!wq->error)
+ wq->rq.queue[wq->rq.size].status.host_pidx = wq->rq.pidx;
+}
+
+static inline void t4_rq_consume(struct t4_wq *wq)
+{
+ wq->rq.in_use--;
+ wq->rq.msn++;
+ if (++wq->rq.cidx == wq->rq.size)
+ wq->rq.cidx = 0;
+ assert((wq->rq.cidx != wq->rq.pidx) || wq->rq.in_use == 0);
+ if (!wq->error)
+ wq->rq.queue[wq->rq.size].status.host_cidx = wq->rq.cidx;
+}
+
+static inline int t4_sq_empty(struct t4_wq *wq)
+{
+ return wq->sq.in_use == 0;
+}
+
+static inline int t4_sq_full(struct t4_wq *wq)
+{
+ return wq->sq.in_use == (wq->sq.size - 1);
+}
+
+static inline u32 t4_sq_avail(struct t4_wq *wq)
+{
+ return wq->sq.size - 1 - wq->sq.in_use;
+}
+
+static inline int t4_sq_onchip(struct t4_wq *wq)
+{
+ return wq->sq.flags & T4_SQ_ONCHIP;
+}
+
+static inline void t4_sq_produce(struct t4_wq *wq, u8 len16)
+{
+ wq->sq.in_use++;
+ if (++wq->sq.pidx == wq->sq.size)
+ wq->sq.pidx = 0;
+ wq->sq.wq_pidx += DIV_ROUND_UP(len16*16, T4_EQ_ENTRY_SIZE);
+ if (wq->sq.wq_pidx >= wq->sq.size * T4_SQ_NUM_SLOTS)
+ wq->sq.wq_pidx %= wq->sq.size * T4_SQ_NUM_SLOTS;
+ if (!wq->error) {
+ /* This write is only for debugging, the value does not matter
+ * for DMA */
+ wq->sq.queue[wq->sq.size].status.host_pidx = (wq->sq.pidx);
+ }
+}
+
+static inline void t4_sq_consume(struct t4_wq *wq)
+{
+ assert(wq->sq.in_use >= 1);
+ if (wq->sq.cidx == wq->sq.flush_cidx)
+ wq->sq.flush_cidx = -1;
+ wq->sq.in_use--;
+ if (++wq->sq.cidx == wq->sq.size)
+ wq->sq.cidx = 0;
+ assert((wq->sq.cidx != wq->sq.pidx) || wq->sq.in_use == 0);
+ if (!wq->error){
+ /* This write is only for debugging, the value does not matter
+ * for DMA */
+ wq->sq.queue[wq->sq.size].status.host_cidx = wq->sq.cidx;
+ }
+}
+
+/* Copies to WC MMIO memory */
+static void copy_wqe_to_udb(volatile u32 *udb_offset, void *wqe)
+{
+ u64 *src, *dst;
+ int len16 = 4;
+
+ src = (u64 *)wqe;
+ dst = (u64 *)udb_offset;
+
+ while (len16) {
+ *dst++ = *src++;
+ *dst++ = *src++;
+ len16--;
+ }
+}
+
+extern int ma_wr;
+extern int t5_en_wc;
+
+static inline void t4_ring_sq_db(struct t4_wq *wq, u16 inc, u8 t4, u8 len16,
+ union t4_wr *wqe)
+{
+ if (!t4) {
+ mmio_wc_start();
+ if (t5_en_wc && inc == 1 && wq->sq.wc_reg_available) {
+ PDBG("%s: WC wq->sq.pidx = %d; len16=%d\n",
+ __func__, wq->sq.pidx, len16);
+ copy_wqe_to_udb(wq->sq.udb + 14, wqe);
+ } else {
+ PDBG("%s: DB wq->sq.pidx = %d; len16=%d\n",
+ __func__, wq->sq.pidx, len16);
+ writel(QID_V(wq->sq.bar2_qid) | PIDX_T5_V(inc),
+ wq->sq.udb);
+ }
+ /* udb is WC for > t4 devices */
+ mmio_flush_writes();
+ return;
+ }
+
+ udma_to_device_barrier();
+ if (ma_wr) {
+ if (t4_sq_onchip(wq)) {
+ int i;
+
+ mmio_wc_start();
+ for (i = 0; i < 16; i++)
+ *(volatile u32 *)&wq->sq.queue[wq->sq.size].flits[2+i] = i;
+ mmio_flush_writes();
+ }
+ } else {
+ if (t4_sq_onchip(wq)) {
+ int i;
+
+ mmio_wc_start();
+ for (i = 0; i < 16; i++)
+ /* FIXME: What is this supposed to be doing?
+ * Writing to the same address multiple times
+ * with WC memory is not guarenteed to
+ * generate any more than one TLP. Why isn't
+ * writing to WC memory marked volatile? */
+ *(u32 *)&wq->sq.queue[wq->sq.size].flits[2] = i;
+ mmio_flush_writes();
+ }
+ }
+ /* udb is UC for t4 devices */
+ writel(QID_V(wq->sq.qid & wq->qid_mask) | PIDX_V(inc), wq->sq.udb);
+}
+
+static inline void t4_ring_rq_db(struct t4_wq *wq, u16 inc, u8 t4, u8 len16,
+ union t4_recv_wr *wqe)
+{
+ if (!t4) {
+ mmio_wc_start();
+ if (t5_en_wc && inc == 1 && wq->sq.wc_reg_available) {
+ PDBG("%s: WC wq->rq.pidx = %d; len16=%d\n",
+ __func__, wq->rq.pidx, len16);
+ copy_wqe_to_udb(wq->rq.udb + 14, wqe);
+ } else {
+ PDBG("%s: DB wq->rq.pidx = %d; len16=%d\n",
+ __func__, wq->rq.pidx, len16);
+ writel(QID_V(wq->rq.bar2_qid) | PIDX_T5_V(inc),
+ wq->rq.udb);
+ }
+ /* udb is WC for > t4 devices */
+ mmio_flush_writes();
+ return;
+ }
+ /* udb is UC for t4 devices */
+ udma_to_device_barrier();
+ writel(QID_V(wq->rq.qid & wq->qid_mask) | PIDX_V(inc), wq->rq.udb);
+}
+
+static inline int t4_wq_in_error(struct t4_wq *wq)
+{
+ return wq->error || wq->rq.queue[wq->rq.size].status.qp_err;
+}
+
+static inline void t4_set_wq_in_error(struct t4_wq *wq)
+{
+ wq->rq.queue[wq->rq.size].status.qp_err = 1;
+}
+
+extern int c4iw_abi_version;
+
+static inline int t4_wq_db_enabled(struct t4_wq *wq)
+{
+ /*
+ * If iw_cxgb4 driver supports door bell drop recovery then its
+ * c4iw_abi_version would be greater than or equal to 2. In such
+ * case return the status of db_off flag to ring the kernel mode
+ * DB from user mode library.
+ */
+ if ( c4iw_abi_version >= 2 )
+ return ! *wq->db_offp;
+ else
+ return 1;
+}
+
+struct t4_cq {
+ struct t4_cqe *queue;
+ struct t4_cqe *sw_queue;
+ struct c4iw_rdev *rdev;
+ volatile u32 *ugts;
+ size_t memsize;
+ u64 bits_type_ts;
+ u32 cqid;
+ u32 qid_mask;
+ u16 size; /* including status page */
+ u16 cidx;
+ u16 sw_pidx;
+ u16 sw_cidx;
+ u16 sw_in_use;
+ u16 cidx_inc;
+ u8 gen;
+ u8 error;
+};
+
+static inline int t4_arm_cq(struct t4_cq *cq, int se)
+{
+ u32 val;
+
+ while (cq->cidx_inc > CIDXINC_M) {
+ val = SEINTARM_V(0) | CIDXINC_V(CIDXINC_M) | TIMERREG_V(7) |
+ INGRESSQID_V(cq->cqid & cq->qid_mask);
+ writel(val, cq->ugts);
+ cq->cidx_inc -= CIDXINC_M;
+ }
+ val = SEINTARM_V(se) | CIDXINC_V(cq->cidx_inc) | TIMERREG_V(6) |
+ INGRESSQID_V(cq->cqid & cq->qid_mask);
+ writel(val, cq->ugts);
+ cq->cidx_inc = 0;
+ return 0;
+}
+
+static inline void t4_swcq_produce(struct t4_cq *cq)
+{
+ cq->sw_in_use++;
+ if (cq->sw_in_use == cq->size) {
+ syslog(LOG_NOTICE, "cxgb4 sw cq overflow cqid %u\n", cq->cqid);
+ cq->error = 1;
+ assert(0);
+ }
+ if (++cq->sw_pidx == cq->size)
+ cq->sw_pidx = 0;
+}
+
+static inline void t4_swcq_consume(struct t4_cq *cq)
+{
+ assert(cq->sw_in_use >= 1);
+ cq->sw_in_use--;
+ if (++cq->sw_cidx == cq->size)
+ cq->sw_cidx = 0;
+}
+
+static inline void t4_hwcq_consume(struct t4_cq *cq)
+{
+ cq->bits_type_ts = cq->queue[cq->cidx].bits_type_ts;
+ if (++cq->cidx_inc == (cq->size >> 4) || cq->cidx_inc == CIDXINC_M) {
+ uint32_t val;
+
+ val = SEINTARM_V(0) | CIDXINC_V(cq->cidx_inc) | TIMERREG_V(7) |
+ INGRESSQID_V(cq->cqid & cq->qid_mask);
+ writel(val, cq->ugts);
+ cq->cidx_inc = 0;
+ }
+ if (++cq->cidx == cq->size) {
+ cq->cidx = 0;
+ cq->gen ^= 1;
+ }
+ ((struct t4_status_page *)&cq->queue[cq->size])->host_cidx = cq->cidx;
+}
+
+static inline int t4_valid_cqe(struct t4_cq *cq, struct t4_cqe *cqe)
+{
+ return (CQE_GENBIT(cqe) == cq->gen);
+}
+
+static inline int t4_next_hw_cqe(struct t4_cq *cq, struct t4_cqe **cqe)
+{
+ int ret;
+ u16 prev_cidx;
+
+ if (cq->cidx == 0)
+ prev_cidx = cq->size - 1;
+ else
+ prev_cidx = cq->cidx - 1;
+
+ if (cq->queue[prev_cidx].bits_type_ts != cq->bits_type_ts) {
+ ret = -EOVERFLOW;
+ syslog(LOG_NOTICE, "cxgb4 cq overflow cqid %u\n", cq->cqid);
+ cq->error = 1;
+ assert(0);
+ } else if (t4_valid_cqe(cq, &cq->queue[cq->cidx])) {
+ udma_from_device_barrier();
+ *cqe = &cq->queue[cq->cidx];
+ ret = 0;
+ } else
+ ret = -ENODATA;
+ return ret;
+}
+
+static inline struct t4_cqe *t4_next_sw_cqe(struct t4_cq *cq)
+{
+ if (cq->sw_in_use == cq->size) {
+ syslog(LOG_NOTICE, "cxgb4 sw cq overflow cqid %u\n", cq->cqid);
+ cq->error = 1;
+ assert(0);
+ return NULL;
+ }
+ if (cq->sw_in_use)
+ return &cq->sw_queue[cq->sw_cidx];
+ return NULL;
+}
+
+static inline int t4_cq_notempty(struct t4_cq *cq)
+{
+ return cq->sw_in_use || t4_valid_cqe(cq, &cq->queue[cq->cidx]);
+}
+
+static inline int t4_next_cqe(struct t4_cq *cq, struct t4_cqe **cqe)
+{
+ int ret = 0;
+
+ if (cq->error)
+ ret = -ENODATA;
+ else if (cq->sw_in_use)
+ *cqe = &cq->sw_queue[cq->sw_cidx];
+ else ret = t4_next_hw_cqe(cq, cqe);
+ return ret;
+}
+
+static inline int t4_cq_in_error(struct t4_cq *cq)
+{
+ return ((struct t4_status_page *)&cq->queue[cq->size])->qp_err;
+}
+
+static inline void t4_set_cq_in_error(struct t4_cq *cq)
+{
+ ((struct t4_status_page *)&cq->queue[cq->size])->qp_err = 1;
+}
+
+static inline void t4_reset_cq_in_error(struct t4_cq *cq)
+{
+ ((struct t4_status_page *)&cq->queue[cq->size])->qp_err = 0;
+}
+
+struct t4_dev_status_page
+{
+ u8 db_off;
+ u8 wc_supported;
+ u16 pad2;
+ u32 pad3;
+ u64 qp_start;
+ u64 qp_size;
+ u64 cq_start;
+ u64 cq_size;
+};
+
+#endif
diff --git a/contrib/ofed/libcxgb4/t4_chip_type.h b/contrib/ofed/libcxgb4/t4_chip_type.h
new file mode 100644
index 0000000..54b7181
--- /dev/null
+++ b/contrib/ofed/libcxgb4/t4_chip_type.h
@@ -0,0 +1,85 @@
+/*
+ * This file is part of the Chelsio T4 Ethernet driver for Linux.
+ *
+ * Copyright (c) 2003-2015 Chelsio Communications, Inc. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+#ifndef __T4_CHIP_TYPE_H__
+#define __T4_CHIP_TYPE_H__
+
+#define CHELSIO_T4 0x4
+#define CHELSIO_T5 0x5
+#define CHELSIO_T6 0x6
+
+/* We code the Chelsio T4 Family "Chip Code" as a tuple:
+ *
+ * (Chip Version, Chip Revision)
+ *
+ * where:
+ *
+ * Chip Version: is T4, T5, etc.
+ * Chip Revision: is the FAB "spin" of the Chip Version.
+ */
+#define CHELSIO_CHIP_CODE(version, revision) (((version) << 4) | (revision))
+#define CHELSIO_CHIP_VERSION(code) (((code) >> 4) & 0xf)
+#define CHELSIO_CHIP_RELEASE(code) ((code) & 0xf)
+
+enum chip_type {
+ T4_A1 = CHELSIO_CHIP_CODE(CHELSIO_T4, 1),
+ T4_A2 = CHELSIO_CHIP_CODE(CHELSIO_T4, 2),
+ T4_FIRST_REV = T4_A1,
+ T4_LAST_REV = T4_A2,
+
+ T5_A0 = CHELSIO_CHIP_CODE(CHELSIO_T5, 0),
+ T5_A1 = CHELSIO_CHIP_CODE(CHELSIO_T5, 1),
+ T5_FIRST_REV = T5_A0,
+ T5_LAST_REV = T5_A1,
+
+ T6_A0 = CHELSIO_CHIP_CODE(CHELSIO_T6, 0),
+ T6_FIRST_REV = T6_A0,
+ T6_LAST_REV = T6_A0,
+};
+
+static inline int is_t4(enum chip_type chip)
+{
+ return (CHELSIO_CHIP_VERSION(chip) == CHELSIO_T4);
+}
+
+static inline int is_t5(enum chip_type chip)
+{
+ return (CHELSIO_CHIP_VERSION(chip) == CHELSIO_T5);
+}
+
+static inline int is_t6(enum chip_type chip)
+{
+ return (CHELSIO_CHIP_VERSION(chip) == CHELSIO_T6);
+}
+
+#endif /* __T4_CHIP_TYPE_H__ */
diff --git a/contrib/ofed/libcxgb4/t4_pci_id_tbl.h b/contrib/ofed/libcxgb4/t4_pci_id_tbl.h
new file mode 100644
index 0000000..50812a1
--- /dev/null
+++ b/contrib/ofed/libcxgb4/t4_pci_id_tbl.h
@@ -0,0 +1,189 @@
+/*
+ * This file is part of the Chelsio T4/T5 Ethernet driver for Linux.
+ *
+ * Copyright (c) 2003-2014 Chelsio Communications, Inc. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+#ifndef __T4_PCI_ID_TBL_H__
+#define __T4_PCI_ID_TBL_H__
+
+/* The code can defined cpp macros for creating a PCI Device ID Table. This is
+ * useful because it allows the PCI ID Table to be maintained in a single place.
+ *
+ * The macros are:
+ *
+ * CH_PCI_DEVICE_ID_TABLE_DEFINE_BEGIN
+ * -- Used to start the definition of the PCI ID Table.
+ *
+ * CH_PCI_DEVICE_ID_FUNCTION
+ * -- The PCI Function Number to use in the PCI Device ID Table. "0"
+ * -- for drivers attaching to PF0-3, "4" for drivers attaching to PF4,
+ * -- "8" for drivers attaching to SR-IOV Virtual Functions, etc.
+ *
+ * CH_PCI_DEVICE_ID_FUNCTION2 [optional]
+ * -- If defined, create a PCI Device ID Table with both
+ * -- CH_PCI_DEVICE_ID_FUNCTION and CH_PCI_DEVICE_ID_FUNCTION2 populated.
+ *
+ * CH_PCI_ID_TABLE_ENTRY(DeviceID)
+ * -- Used for the individual PCI Device ID entries. Note that we will
+ * -- be adding a trailing comma (",") after all of the entries (and
+ * -- between the pairs of entries if CH_PCI_DEVICE_ID_FUNCTION2 is defined).
+ *
+ * CH_PCI_DEVICE_ID_TABLE_DEFINE_END
+ * -- Used to finish the definition of the PCI ID Table. Note that we
+ * -- will be adding a trailing semi-colon (";") here.
+ */
+#ifndef CH_PCI_DEVICE_ID_FUNCTION
+#error CH_PCI_DEVICE_ID_FUNCTION not defined!
+#endif
+#ifndef CH_PCI_ID_TABLE_ENTRY
+#error CH_PCI_ID_TABLE_ENTRY not defined!
+#endif
+#ifndef CH_PCI_DEVICE_ID_TABLE_DEFINE_END
+#error CH_PCI_DEVICE_ID_TABLE_DEFINE_END not defined!
+#endif
+
+/* T4 and later ASICs use a PCI Device ID scheme of 0xVFPP where:
+ *
+ * V = "4" for T4; "5" for T5, etc.
+ * F = "0" for PF 0..3; "4".."7" for PF4..7; and "8" for VFs
+ * PP = adapter product designation
+ *
+ * We use this consistency in order to create the proper PCI Device IDs
+ * for the specified CH_PCI_DEVICE_ID_FUNCTION.
+ */
+#ifndef CH_PCI_DEVICE_ID_FUNCTION2
+#define CH_PCI_ID_TABLE_FENTRY(devid) \
+ CH_PCI_ID_TABLE_ENTRY((devid) | \
+ ((CH_PCI_DEVICE_ID_FUNCTION) << 8))
+#else
+#define CH_PCI_ID_TABLE_FENTRY(devid) \
+ CH_PCI_ID_TABLE_ENTRY((devid) | \
+ ((CH_PCI_DEVICE_ID_FUNCTION) << 8)), \
+ CH_PCI_ID_TABLE_ENTRY((devid) | \
+ ((CH_PCI_DEVICE_ID_FUNCTION2) << 8))
+#endif
+
+CH_PCI_DEVICE_ID_TABLE_DEFINE_BEGIN
+ /* T4 adapters:
+ */
+ CH_PCI_ID_TABLE_FENTRY(0x4000), /* T440-dbg */
+ CH_PCI_ID_TABLE_FENTRY(0x4001), /* T420-cr */
+ CH_PCI_ID_TABLE_FENTRY(0x4002), /* T422-cr */
+ CH_PCI_ID_TABLE_FENTRY(0x4003), /* T440-cr */
+ CH_PCI_ID_TABLE_FENTRY(0x4004), /* T420-bch */
+ CH_PCI_ID_TABLE_FENTRY(0x4005), /* T440-bch */
+ CH_PCI_ID_TABLE_FENTRY(0x4006), /* T440-ch */
+ CH_PCI_ID_TABLE_FENTRY(0x4007), /* T420-so */
+ CH_PCI_ID_TABLE_FENTRY(0x4008), /* T420-cx */
+ CH_PCI_ID_TABLE_FENTRY(0x4009), /* T420-bt */
+ CH_PCI_ID_TABLE_FENTRY(0x400a), /* T404-bt */
+ CH_PCI_ID_TABLE_FENTRY(0x400b), /* B420-sr */
+ CH_PCI_ID_TABLE_FENTRY(0x400c), /* B404-bt */
+ CH_PCI_ID_TABLE_FENTRY(0x400d), /* T480-cr */
+ CH_PCI_ID_TABLE_FENTRY(0x400e), /* T440-LP-cr */
+ CH_PCI_ID_TABLE_FENTRY(0x4080), /* Custom T480-cr */
+ CH_PCI_ID_TABLE_FENTRY(0x4081), /* Custom T440-cr */
+ CH_PCI_ID_TABLE_FENTRY(0x4082), /* Custom T420-cr */
+ CH_PCI_ID_TABLE_FENTRY(0x4083), /* Custom T420-xaui */
+ CH_PCI_ID_TABLE_FENTRY(0x4084), /* Custom T440-cr */
+ CH_PCI_ID_TABLE_FENTRY(0x4085), /* Custom T420-cr */
+ CH_PCI_ID_TABLE_FENTRY(0x4086), /* Custom T440-bt */
+ CH_PCI_ID_TABLE_FENTRY(0x4087), /* Custom T440-cr */
+ CH_PCI_ID_TABLE_FENTRY(0x4088), /* Custom T440 2-xaui, 2-xfi */
+
+ /* T5 adapters:
+ */
+ CH_PCI_ID_TABLE_FENTRY(0x5000), /* T580-dbg */
+ CH_PCI_ID_TABLE_FENTRY(0x5001), /* T520-cr */
+ CH_PCI_ID_TABLE_FENTRY(0x5002), /* T522-cr */
+ CH_PCI_ID_TABLE_FENTRY(0x5003), /* T540-cr */
+ CH_PCI_ID_TABLE_FENTRY(0x5004), /* T520-bch */
+ CH_PCI_ID_TABLE_FENTRY(0x5005), /* T540-bch */
+ CH_PCI_ID_TABLE_FENTRY(0x5006), /* T540-ch */
+ CH_PCI_ID_TABLE_FENTRY(0x5007), /* T520-so */
+ CH_PCI_ID_TABLE_FENTRY(0x5008), /* T520-cx */
+ CH_PCI_ID_TABLE_FENTRY(0x5009), /* T520-bt */
+ CH_PCI_ID_TABLE_FENTRY(0x500a), /* T504-bt */
+ CH_PCI_ID_TABLE_FENTRY(0x500b), /* B520-sr */
+ CH_PCI_ID_TABLE_FENTRY(0x500c), /* B504-bt */
+ CH_PCI_ID_TABLE_FENTRY(0x500d), /* T580-cr */
+ CH_PCI_ID_TABLE_FENTRY(0x500e), /* T540-LP-cr */
+ CH_PCI_ID_TABLE_FENTRY(0x5010), /* T580-LP-cr */
+ CH_PCI_ID_TABLE_FENTRY(0x5011), /* T520-LL-cr */
+ CH_PCI_ID_TABLE_FENTRY(0x5012), /* T560-cr */
+ CH_PCI_ID_TABLE_FENTRY(0x5013), /* T580-chr */
+ CH_PCI_ID_TABLE_FENTRY(0x5014), /* T580-so */
+ CH_PCI_ID_TABLE_FENTRY(0x5015), /* T502-bt */
+ CH_PCI_ID_TABLE_FENTRY(0x5016), /* T580-OCP-SO */
+ CH_PCI_ID_TABLE_FENTRY(0x5017), /* T520-OCP-SO */
+ CH_PCI_ID_TABLE_FENTRY(0x5018), /* T540-BT */
+ CH_PCI_ID_TABLE_FENTRY(0x5080), /* Custom T540-cr */
+ CH_PCI_ID_TABLE_FENTRY(0x5081), /* Custom T540-LL-cr */
+ CH_PCI_ID_TABLE_FENTRY(0x5082), /* Custom T504-cr */
+ CH_PCI_ID_TABLE_FENTRY(0x5083), /* Custom T540-LP-CR */
+ CH_PCI_ID_TABLE_FENTRY(0x5084), /* Custom T580-cr */
+ CH_PCI_ID_TABLE_FENTRY(0x5085), /* Custom 3x T580-CR */
+ CH_PCI_ID_TABLE_FENTRY(0x5086), /* Custom 2x T580-CR */
+ CH_PCI_ID_TABLE_FENTRY(0x5087), /* Custom T580-CR */
+ CH_PCI_ID_TABLE_FENTRY(0x5088), /* Custom T570-CR */
+ CH_PCI_ID_TABLE_FENTRY(0x5089), /* Custom T520-CR */
+ CH_PCI_ID_TABLE_FENTRY(0x5090), /* Custom T540-CR */
+ CH_PCI_ID_TABLE_FENTRY(0x5091), /* Custom T522-CR */
+ CH_PCI_ID_TABLE_FENTRY(0x5092), /* Custom T520-CR */
+ CH_PCI_ID_TABLE_FENTRY(0x5093), /* Custom T580-LP-CR */
+ CH_PCI_ID_TABLE_FENTRY(0x5094), /* Custom T540-CR */
+ CH_PCI_ID_TABLE_FENTRY(0x5095), /* Custom T540-CR-SO */
+ CH_PCI_ID_TABLE_FENTRY(0x5096), /* Custom T580-CR */
+ CH_PCI_ID_TABLE_FENTRY(0x5097), /* Custom T520-KR */
+ CH_PCI_ID_TABLE_FENTRY(0x5098), /* Custom 2x40G QSFP */
+ CH_PCI_ID_TABLE_FENTRY(0x5099), /* Custom 2x40G QSFP */
+ CH_PCI_ID_TABLE_FENTRY(0x509a), /* Custom T520-CR */
+ CH_PCI_ID_TABLE_FENTRY(0x509b), /* Custom T540-CR LOM */
+ CH_PCI_ID_TABLE_FENTRY(0x509c), /* Custom T520-CR*/
+
+ /* T6 adapters:
+ */
+ CH_PCI_ID_TABLE_FENTRY(0x6001),
+ CH_PCI_ID_TABLE_FENTRY(0x6002),
+ CH_PCI_ID_TABLE_FENTRY(0x6003),
+ CH_PCI_ID_TABLE_FENTRY(0x6004),
+ CH_PCI_ID_TABLE_FENTRY(0x6005),
+ CH_PCI_ID_TABLE_FENTRY(0x6006),
+ CH_PCI_ID_TABLE_FENTRY(0x6007),
+ CH_PCI_ID_TABLE_FENTRY(0x6009),
+ CH_PCI_ID_TABLE_FENTRY(0x600d),
+ CH_PCI_ID_TABLE_FENTRY(0x6010),
+ CH_PCI_ID_TABLE_FENTRY(0x6011),
+ CH_PCI_ID_TABLE_FENTRY(0x6014),
+ CH_PCI_ID_TABLE_FENTRY(0x6015),
+CH_PCI_DEVICE_ID_TABLE_DEFINE_END;
+
+#endif /* __T4_PCI_ID_TBL_H__ */
diff --git a/contrib/ofed/libcxgb4/t4_regs.h b/contrib/ofed/libcxgb4/t4_regs.h
new file mode 100644
index 0000000..9fea255
--- /dev/null
+++ b/contrib/ofed/libcxgb4/t4_regs.h
@@ -0,0 +1,3125 @@
+/*
+ * This file is part of the Chelsio T4 Ethernet driver for Linux.
+ *
+ * Copyright (c) 2003-2014 Chelsio Communications, Inc. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#ifndef __T4_REGS_H
+#define __T4_REGS_H
+
+#define MYPF_BASE 0x1b000
+#define MYPF_REG(reg_addr) (MYPF_BASE + (reg_addr))
+
+#define PF0_BASE 0x1e000
+#define PF0_REG(reg_addr) (PF0_BASE + (reg_addr))
+
+#define PF_STRIDE 0x400
+#define PF_BASE(idx) (PF0_BASE + (idx) * PF_STRIDE)
+#define PF_REG(idx, reg) (PF_BASE(idx) + (reg))
+
+#define MYPORT_BASE 0x1c000
+#define MYPORT_REG(reg_addr) (MYPORT_BASE + (reg_addr))
+
+#define PORT0_BASE 0x20000
+#define PORT0_REG(reg_addr) (PORT0_BASE + (reg_addr))
+
+#define PORT_STRIDE 0x2000
+#define PORT_BASE(idx) (PORT0_BASE + (idx) * PORT_STRIDE)
+#define PORT_REG(idx, reg) (PORT_BASE(idx) + (reg))
+
+#define EDC_STRIDE (EDC_1_BASE_ADDR - EDC_0_BASE_ADDR)
+#define EDC_REG(reg, idx) (reg + EDC_STRIDE * idx)
+
+#define PCIE_MEM_ACCESS_REG(reg_addr, idx) ((reg_addr) + (idx) * 8)
+#define PCIE_MAILBOX_REG(reg_addr, idx) ((reg_addr) + (idx) * 8)
+#define MC_BIST_STATUS_REG(reg_addr, idx) ((reg_addr) + (idx) * 4)
+#define EDC_BIST_STATUS_REG(reg_addr, idx) ((reg_addr) + (idx) * 4)
+
+#define PCIE_FW_REG(reg_addr, idx) ((reg_addr) + (idx) * 4)
+
+#define SGE_PF_KDOORBELL_A 0x0
+
+#define QID_S 15
+#define QID_V(x) ((x) << QID_S)
+
+#define DBPRIO_S 14
+#define DBPRIO_V(x) ((x) << DBPRIO_S)
+#define DBPRIO_F DBPRIO_V(1U)
+
+#define PIDX_S 0
+#define PIDX_V(x) ((x) << PIDX_S)
+
+#define SGE_VF_KDOORBELL_A 0x0
+
+#define DBTYPE_S 13
+#define DBTYPE_V(x) ((x) << DBTYPE_S)
+#define DBTYPE_F DBTYPE_V(1U)
+
+#define PIDX_T5_S 0
+#define PIDX_T5_M 0x1fffU
+#define PIDX_T5_V(x) ((x) << PIDX_T5_S)
+#define PIDX_T5_G(x) (((x) >> PIDX_T5_S) & PIDX_T5_M)
+
+#define SGE_PF_GTS_A 0x4
+
+#define INGRESSQID_S 16
+#define INGRESSQID_V(x) ((x) << INGRESSQID_S)
+
+#define TIMERREG_S 13
+#define TIMERREG_V(x) ((x) << TIMERREG_S)
+
+#define SEINTARM_S 12
+#define SEINTARM_V(x) ((x) << SEINTARM_S)
+
+#define CIDXINC_S 0
+#define CIDXINC_M 0xfffU
+#define CIDXINC_V(x) ((x) << CIDXINC_S)
+
+#define SGE_CONTROL_A 0x1008
+#define SGE_CONTROL2_A 0x1124
+
+#define RXPKTCPLMODE_S 18
+#define RXPKTCPLMODE_V(x) ((x) << RXPKTCPLMODE_S)
+#define RXPKTCPLMODE_F RXPKTCPLMODE_V(1U)
+
+#define EGRSTATUSPAGESIZE_S 17
+#define EGRSTATUSPAGESIZE_V(x) ((x) << EGRSTATUSPAGESIZE_S)
+#define EGRSTATUSPAGESIZE_F EGRSTATUSPAGESIZE_V(1U)
+
+#define PKTSHIFT_S 10
+#define PKTSHIFT_M 0x7U
+#define PKTSHIFT_V(x) ((x) << PKTSHIFT_S)
+#define PKTSHIFT_G(x) (((x) >> PKTSHIFT_S) & PKTSHIFT_M)
+
+#define INGPCIEBOUNDARY_S 7
+#define INGPCIEBOUNDARY_V(x) ((x) << INGPCIEBOUNDARY_S)
+
+#define INGPADBOUNDARY_S 4
+#define INGPADBOUNDARY_M 0x7U
+#define INGPADBOUNDARY_V(x) ((x) << INGPADBOUNDARY_S)
+#define INGPADBOUNDARY_G(x) (((x) >> INGPADBOUNDARY_S) & INGPADBOUNDARY_M)
+
+#define EGRPCIEBOUNDARY_S 1
+#define EGRPCIEBOUNDARY_V(x) ((x) << EGRPCIEBOUNDARY_S)
+
+#define INGPACKBOUNDARY_S 16
+#define INGPACKBOUNDARY_M 0x7U
+#define INGPACKBOUNDARY_V(x) ((x) << INGPACKBOUNDARY_S)
+#define INGPACKBOUNDARY_G(x) (((x) >> INGPACKBOUNDARY_S) \
+ & INGPACKBOUNDARY_M)
+
+#define VFIFO_ENABLE_S 10
+#define VFIFO_ENABLE_V(x) ((x) << VFIFO_ENABLE_S)
+#define VFIFO_ENABLE_F VFIFO_ENABLE_V(1U)
+
+#define SGE_DBVFIFO_BADDR_A 0x1138
+
+#define DBVFIFO_SIZE_S 6
+#define DBVFIFO_SIZE_M 0xfffU
+#define DBVFIFO_SIZE_G(x) (((x) >> DBVFIFO_SIZE_S) & DBVFIFO_SIZE_M)
+
+#define T6_DBVFIFO_SIZE_S 0
+#define T6_DBVFIFO_SIZE_M 0x1fffU
+#define T6_DBVFIFO_SIZE_G(x) (((x) >> T6_DBVFIFO_SIZE_S) & T6_DBVFIFO_SIZE_M)
+
+#define GLOBALENABLE_S 0
+#define GLOBALENABLE_V(x) ((x) << GLOBALENABLE_S)
+#define GLOBALENABLE_F GLOBALENABLE_V(1U)
+
+#define SGE_HOST_PAGE_SIZE_A 0x100c
+
+#define HOSTPAGESIZEPF7_S 28
+#define HOSTPAGESIZEPF7_M 0xfU
+#define HOSTPAGESIZEPF7_V(x) ((x) << HOSTPAGESIZEPF7_S)
+#define HOSTPAGESIZEPF7_G(x) (((x) >> HOSTPAGESIZEPF7_S) & HOSTPAGESIZEPF7_M)
+
+#define HOSTPAGESIZEPF6_S 24
+#define HOSTPAGESIZEPF6_M 0xfU
+#define HOSTPAGESIZEPF6_V(x) ((x) << HOSTPAGESIZEPF6_S)
+#define HOSTPAGESIZEPF6_G(x) (((x) >> HOSTPAGESIZEPF6_S) & HOSTPAGESIZEPF6_M)
+
+#define HOSTPAGESIZEPF5_S 20
+#define HOSTPAGESIZEPF5_M 0xfU
+#define HOSTPAGESIZEPF5_V(x) ((x) << HOSTPAGESIZEPF5_S)
+#define HOSTPAGESIZEPF5_G(x) (((x) >> HOSTPAGESIZEPF5_S) & HOSTPAGESIZEPF5_M)
+
+#define HOSTPAGESIZEPF4_S 16
+#define HOSTPAGESIZEPF4_M 0xfU
+#define HOSTPAGESIZEPF4_V(x) ((x) << HOSTPAGESIZEPF4_S)
+#define HOSTPAGESIZEPF4_G(x) (((x) >> HOSTPAGESIZEPF4_S) & HOSTPAGESIZEPF4_M)
+
+#define HOSTPAGESIZEPF3_S 12
+#define HOSTPAGESIZEPF3_M 0xfU
+#define HOSTPAGESIZEPF3_V(x) ((x) << HOSTPAGESIZEPF3_S)
+#define HOSTPAGESIZEPF3_G(x) (((x) >> HOSTPAGESIZEPF3_S) & HOSTPAGESIZEPF3_M)
+
+#define HOSTPAGESIZEPF2_S 8
+#define HOSTPAGESIZEPF2_M 0xfU
+#define HOSTPAGESIZEPF2_V(x) ((x) << HOSTPAGESIZEPF2_S)
+#define HOSTPAGESIZEPF2_G(x) (((x) >> HOSTPAGESIZEPF2_S) & HOSTPAGESIZEPF2_M)
+
+#define HOSTPAGESIZEPF1_S 4
+#define HOSTPAGESIZEPF1_M 0xfU
+#define HOSTPAGESIZEPF1_V(x) ((x) << HOSTPAGESIZEPF1_S)
+#define HOSTPAGESIZEPF1_G(x) (((x) >> HOSTPAGESIZEPF1_S) & HOSTPAGESIZEPF1_M)
+
+#define HOSTPAGESIZEPF0_S 0
+#define HOSTPAGESIZEPF0_M 0xfU
+#define HOSTPAGESIZEPF0_V(x) ((x) << HOSTPAGESIZEPF0_S)
+#define HOSTPAGESIZEPF0_G(x) (((x) >> HOSTPAGESIZEPF0_S) & HOSTPAGESIZEPF0_M)
+
+#define SGE_EGRESS_QUEUES_PER_PAGE_PF_A 0x1010
+#define SGE_EGRESS_QUEUES_PER_PAGE_VF_A 0x1014
+
+#define QUEUESPERPAGEPF1_S 4
+
+#define QUEUESPERPAGEPF0_S 0
+#define QUEUESPERPAGEPF0_M 0xfU
+#define QUEUESPERPAGEPF0_V(x) ((x) << QUEUESPERPAGEPF0_S)
+#define QUEUESPERPAGEPF0_G(x) (((x) >> QUEUESPERPAGEPF0_S) & QUEUESPERPAGEPF0_M)
+
+#define SGE_INT_CAUSE1_A 0x1024
+#define SGE_INT_CAUSE2_A 0x1030
+#define SGE_INT_CAUSE3_A 0x103c
+
+#define ERR_FLM_DBP_S 31
+#define ERR_FLM_DBP_V(x) ((x) << ERR_FLM_DBP_S)
+#define ERR_FLM_DBP_F ERR_FLM_DBP_V(1U)
+
+#define ERR_FLM_IDMA1_S 30
+#define ERR_FLM_IDMA1_V(x) ((x) << ERR_FLM_IDMA1_S)
+#define ERR_FLM_IDMA1_F ERR_FLM_IDMA1_V(1U)
+
+#define ERR_FLM_IDMA0_S 29
+#define ERR_FLM_IDMA0_V(x) ((x) << ERR_FLM_IDMA0_S)
+#define ERR_FLM_IDMA0_F ERR_FLM_IDMA0_V(1U)
+
+#define ERR_FLM_HINT_S 28
+#define ERR_FLM_HINT_V(x) ((x) << ERR_FLM_HINT_S)
+#define ERR_FLM_HINT_F ERR_FLM_HINT_V(1U)
+
+#define ERR_PCIE_ERROR3_S 27
+#define ERR_PCIE_ERROR3_V(x) ((x) << ERR_PCIE_ERROR3_S)
+#define ERR_PCIE_ERROR3_F ERR_PCIE_ERROR3_V(1U)
+
+#define ERR_PCIE_ERROR2_S 26
+#define ERR_PCIE_ERROR2_V(x) ((x) << ERR_PCIE_ERROR2_S)
+#define ERR_PCIE_ERROR2_F ERR_PCIE_ERROR2_V(1U)
+
+#define ERR_PCIE_ERROR1_S 25
+#define ERR_PCIE_ERROR1_V(x) ((x) << ERR_PCIE_ERROR1_S)
+#define ERR_PCIE_ERROR1_F ERR_PCIE_ERROR1_V(1U)
+
+#define ERR_PCIE_ERROR0_S 24
+#define ERR_PCIE_ERROR0_V(x) ((x) << ERR_PCIE_ERROR0_S)
+#define ERR_PCIE_ERROR0_F ERR_PCIE_ERROR0_V(1U)
+
+#define ERR_CPL_EXCEED_IQE_SIZE_S 22
+#define ERR_CPL_EXCEED_IQE_SIZE_V(x) ((x) << ERR_CPL_EXCEED_IQE_SIZE_S)
+#define ERR_CPL_EXCEED_IQE_SIZE_F ERR_CPL_EXCEED_IQE_SIZE_V(1U)
+
+#define ERR_INVALID_CIDX_INC_S 21
+#define ERR_INVALID_CIDX_INC_V(x) ((x) << ERR_INVALID_CIDX_INC_S)
+#define ERR_INVALID_CIDX_INC_F ERR_INVALID_CIDX_INC_V(1U)
+
+#define ERR_CPL_OPCODE_0_S 19
+#define ERR_CPL_OPCODE_0_V(x) ((x) << ERR_CPL_OPCODE_0_S)
+#define ERR_CPL_OPCODE_0_F ERR_CPL_OPCODE_0_V(1U)
+
+#define ERR_DROPPED_DB_S 18
+#define ERR_DROPPED_DB_V(x) ((x) << ERR_DROPPED_DB_S)
+#define ERR_DROPPED_DB_F ERR_DROPPED_DB_V(1U)
+
+#define ERR_DATA_CPL_ON_HIGH_QID1_S 17
+#define ERR_DATA_CPL_ON_HIGH_QID1_V(x) ((x) << ERR_DATA_CPL_ON_HIGH_QID1_S)
+#define ERR_DATA_CPL_ON_HIGH_QID1_F ERR_DATA_CPL_ON_HIGH_QID1_V(1U)
+
+#define ERR_DATA_CPL_ON_HIGH_QID0_S 16
+#define ERR_DATA_CPL_ON_HIGH_QID0_V(x) ((x) << ERR_DATA_CPL_ON_HIGH_QID0_S)
+#define ERR_DATA_CPL_ON_HIGH_QID0_F ERR_DATA_CPL_ON_HIGH_QID0_V(1U)
+
+#define ERR_BAD_DB_PIDX3_S 15
+#define ERR_BAD_DB_PIDX3_V(x) ((x) << ERR_BAD_DB_PIDX3_S)
+#define ERR_BAD_DB_PIDX3_F ERR_BAD_DB_PIDX3_V(1U)
+
+#define ERR_BAD_DB_PIDX2_S 14
+#define ERR_BAD_DB_PIDX2_V(x) ((x) << ERR_BAD_DB_PIDX2_S)
+#define ERR_BAD_DB_PIDX2_F ERR_BAD_DB_PIDX2_V(1U)
+
+#define ERR_BAD_DB_PIDX1_S 13
+#define ERR_BAD_DB_PIDX1_V(x) ((x) << ERR_BAD_DB_PIDX1_S)
+#define ERR_BAD_DB_PIDX1_F ERR_BAD_DB_PIDX1_V(1U)
+
+#define ERR_BAD_DB_PIDX0_S 12
+#define ERR_BAD_DB_PIDX0_V(x) ((x) << ERR_BAD_DB_PIDX0_S)
+#define ERR_BAD_DB_PIDX0_F ERR_BAD_DB_PIDX0_V(1U)
+
+#define ERR_ING_CTXT_PRIO_S 10
+#define ERR_ING_CTXT_PRIO_V(x) ((x) << ERR_ING_CTXT_PRIO_S)
+#define ERR_ING_CTXT_PRIO_F ERR_ING_CTXT_PRIO_V(1U)
+
+#define ERR_EGR_CTXT_PRIO_S 9
+#define ERR_EGR_CTXT_PRIO_V(x) ((x) << ERR_EGR_CTXT_PRIO_S)
+#define ERR_EGR_CTXT_PRIO_F ERR_EGR_CTXT_PRIO_V(1U)
+
+#define DBFIFO_HP_INT_S 8
+#define DBFIFO_HP_INT_V(x) ((x) << DBFIFO_HP_INT_S)
+#define DBFIFO_HP_INT_F DBFIFO_HP_INT_V(1U)
+
+#define DBFIFO_LP_INT_S 7
+#define DBFIFO_LP_INT_V(x) ((x) << DBFIFO_LP_INT_S)
+#define DBFIFO_LP_INT_F DBFIFO_LP_INT_V(1U)
+
+#define INGRESS_SIZE_ERR_S 5
+#define INGRESS_SIZE_ERR_V(x) ((x) << INGRESS_SIZE_ERR_S)
+#define INGRESS_SIZE_ERR_F INGRESS_SIZE_ERR_V(1U)
+
+#define EGRESS_SIZE_ERR_S 4
+#define EGRESS_SIZE_ERR_V(x) ((x) << EGRESS_SIZE_ERR_S)
+#define EGRESS_SIZE_ERR_F EGRESS_SIZE_ERR_V(1U)
+
+#define SGE_INT_ENABLE3_A 0x1040
+#define SGE_FL_BUFFER_SIZE0_A 0x1044
+#define SGE_FL_BUFFER_SIZE1_A 0x1048
+#define SGE_FL_BUFFER_SIZE2_A 0x104c
+#define SGE_FL_BUFFER_SIZE3_A 0x1050
+#define SGE_FL_BUFFER_SIZE4_A 0x1054
+#define SGE_FL_BUFFER_SIZE5_A 0x1058
+#define SGE_FL_BUFFER_SIZE6_A 0x105c
+#define SGE_FL_BUFFER_SIZE7_A 0x1060
+#define SGE_FL_BUFFER_SIZE8_A 0x1064
+
+#define SGE_IMSG_CTXT_BADDR_A 0x1088
+#define SGE_FLM_CACHE_BADDR_A 0x108c
+#define SGE_INGRESS_RX_THRESHOLD_A 0x10a0
+
+#define THRESHOLD_0_S 24
+#define THRESHOLD_0_M 0x3fU
+#define THRESHOLD_0_V(x) ((x) << THRESHOLD_0_S)
+#define THRESHOLD_0_G(x) (((x) >> THRESHOLD_0_S) & THRESHOLD_0_M)
+
+#define THRESHOLD_1_S 16
+#define THRESHOLD_1_M 0x3fU
+#define THRESHOLD_1_V(x) ((x) << THRESHOLD_1_S)
+#define THRESHOLD_1_G(x) (((x) >> THRESHOLD_1_S) & THRESHOLD_1_M)
+
+#define THRESHOLD_2_S 8
+#define THRESHOLD_2_M 0x3fU
+#define THRESHOLD_2_V(x) ((x) << THRESHOLD_2_S)
+#define THRESHOLD_2_G(x) (((x) >> THRESHOLD_2_S) & THRESHOLD_2_M)
+
+#define THRESHOLD_3_S 0
+#define THRESHOLD_3_M 0x3fU
+#define THRESHOLD_3_V(x) ((x) << THRESHOLD_3_S)
+#define THRESHOLD_3_G(x) (((x) >> THRESHOLD_3_S) & THRESHOLD_3_M)
+
+#define SGE_CONM_CTRL_A 0x1094
+
+#define EGRTHRESHOLD_S 8
+#define EGRTHRESHOLD_M 0x3fU
+#define EGRTHRESHOLD_V(x) ((x) << EGRTHRESHOLD_S)
+#define EGRTHRESHOLD_G(x) (((x) >> EGRTHRESHOLD_S) & EGRTHRESHOLD_M)
+
+#define EGRTHRESHOLDPACKING_S 14
+#define EGRTHRESHOLDPACKING_M 0x3fU
+#define EGRTHRESHOLDPACKING_V(x) ((x) << EGRTHRESHOLDPACKING_S)
+#define EGRTHRESHOLDPACKING_G(x) \
+ (((x) >> EGRTHRESHOLDPACKING_S) & EGRTHRESHOLDPACKING_M)
+
+#define T6_EGRTHRESHOLDPACKING_S 16
+#define T6_EGRTHRESHOLDPACKING_M 0xffU
+#define T6_EGRTHRESHOLDPACKING_G(x) \
+ (((x) >> T6_EGRTHRESHOLDPACKING_S) & T6_EGRTHRESHOLDPACKING_M)
+
+#define SGE_TIMESTAMP_LO_A 0x1098
+#define SGE_TIMESTAMP_HI_A 0x109c
+
+#define TSOP_S 28
+#define TSOP_M 0x3U
+#define TSOP_V(x) ((x) << TSOP_S)
+#define TSOP_G(x) (((x) >> TSOP_S) & TSOP_M)
+
+#define TSVAL_S 0
+#define TSVAL_M 0xfffffffU
+#define TSVAL_V(x) ((x) << TSVAL_S)
+#define TSVAL_G(x) (((x) >> TSVAL_S) & TSVAL_M)
+
+#define SGE_DBFIFO_STATUS_A 0x10a4
+#define SGE_DBVFIFO_SIZE_A 0x113c
+
+#define HP_INT_THRESH_S 28
+#define HP_INT_THRESH_M 0xfU
+#define HP_INT_THRESH_V(x) ((x) << HP_INT_THRESH_S)
+
+#define LP_INT_THRESH_S 12
+#define LP_INT_THRESH_M 0xfU
+#define LP_INT_THRESH_V(x) ((x) << LP_INT_THRESH_S)
+
+#define SGE_DOORBELL_CONTROL_A 0x10a8
+
+#define NOCOALESCE_S 26
+#define NOCOALESCE_V(x) ((x) << NOCOALESCE_S)
+#define NOCOALESCE_F NOCOALESCE_V(1U)
+
+#define ENABLE_DROP_S 13
+#define ENABLE_DROP_V(x) ((x) << ENABLE_DROP_S)
+#define ENABLE_DROP_F ENABLE_DROP_V(1U)
+
+#define SGE_TIMER_VALUE_0_AND_1_A 0x10b8
+
+#define TIMERVALUE0_S 16
+#define TIMERVALUE0_M 0xffffU
+#define TIMERVALUE0_V(x) ((x) << TIMERVALUE0_S)
+#define TIMERVALUE0_G(x) (((x) >> TIMERVALUE0_S) & TIMERVALUE0_M)
+
+#define TIMERVALUE1_S 0
+#define TIMERVALUE1_M 0xffffU
+#define TIMERVALUE1_V(x) ((x) << TIMERVALUE1_S)
+#define TIMERVALUE1_G(x) (((x) >> TIMERVALUE1_S) & TIMERVALUE1_M)
+
+#define SGE_TIMER_VALUE_2_AND_3_A 0x10bc
+
+#define TIMERVALUE2_S 16
+#define TIMERVALUE2_M 0xffffU
+#define TIMERVALUE2_V(x) ((x) << TIMERVALUE2_S)
+#define TIMERVALUE2_G(x) (((x) >> TIMERVALUE2_S) & TIMERVALUE2_M)
+
+#define TIMERVALUE3_S 0
+#define TIMERVALUE3_M 0xffffU
+#define TIMERVALUE3_V(x) ((x) << TIMERVALUE3_S)
+#define TIMERVALUE3_G(x) (((x) >> TIMERVALUE3_S) & TIMERVALUE3_M)
+
+#define SGE_TIMER_VALUE_4_AND_5_A 0x10c0
+
+#define TIMERVALUE4_S 16
+#define TIMERVALUE4_M 0xffffU
+#define TIMERVALUE4_V(x) ((x) << TIMERVALUE4_S)
+#define TIMERVALUE4_G(x) (((x) >> TIMERVALUE4_S) & TIMERVALUE4_M)
+
+#define TIMERVALUE5_S 0
+#define TIMERVALUE5_M 0xffffU
+#define TIMERVALUE5_V(x) ((x) << TIMERVALUE5_S)
+#define TIMERVALUE5_G(x) (((x) >> TIMERVALUE5_S) & TIMERVALUE5_M)
+
+#define SGE_DEBUG_INDEX_A 0x10cc
+#define SGE_DEBUG_DATA_HIGH_A 0x10d0
+#define SGE_DEBUG_DATA_LOW_A 0x10d4
+
+#define SGE_DEBUG_DATA_LOW_INDEX_2_A 0x12c8
+#define SGE_DEBUG_DATA_LOW_INDEX_3_A 0x12cc
+#define SGE_DEBUG_DATA_HIGH_INDEX_10_A 0x12a8
+
+#define SGE_INGRESS_QUEUES_PER_PAGE_PF_A 0x10f4
+#define SGE_INGRESS_QUEUES_PER_PAGE_VF_A 0x10f8
+
+#define SGE_ERROR_STATS_A 0x1100
+
+#define UNCAPTURED_ERROR_S 18
+#define UNCAPTURED_ERROR_V(x) ((x) << UNCAPTURED_ERROR_S)
+#define UNCAPTURED_ERROR_F UNCAPTURED_ERROR_V(1U)
+
+#define ERROR_QID_VALID_S 17
+#define ERROR_QID_VALID_V(x) ((x) << ERROR_QID_VALID_S)
+#define ERROR_QID_VALID_F ERROR_QID_VALID_V(1U)
+
+#define ERROR_QID_S 0
+#define ERROR_QID_M 0x1ffffU
+#define ERROR_QID_G(x) (((x) >> ERROR_QID_S) & ERROR_QID_M)
+
+#define HP_INT_THRESH_S 28
+#define HP_INT_THRESH_M 0xfU
+#define HP_INT_THRESH_V(x) ((x) << HP_INT_THRESH_S)
+
+#define HP_COUNT_S 16
+#define HP_COUNT_M 0x7ffU
+#define HP_COUNT_G(x) (((x) >> HP_COUNT_S) & HP_COUNT_M)
+
+#define LP_INT_THRESH_S 12
+#define LP_INT_THRESH_M 0xfU
+#define LP_INT_THRESH_V(x) ((x) << LP_INT_THRESH_S)
+
+#define LP_COUNT_S 0
+#define LP_COUNT_M 0x7ffU
+#define LP_COUNT_G(x) (((x) >> LP_COUNT_S) & LP_COUNT_M)
+
+#define LP_INT_THRESH_T5_S 18
+#define LP_INT_THRESH_T5_M 0xfffU
+#define LP_INT_THRESH_T5_V(x) ((x) << LP_INT_THRESH_T5_S)
+
+#define LP_COUNT_T5_S 0
+#define LP_COUNT_T5_M 0x3ffffU
+#define LP_COUNT_T5_G(x) (((x) >> LP_COUNT_T5_S) & LP_COUNT_T5_M)
+
+#define SGE_DOORBELL_CONTROL_A 0x10a8
+
+#define SGE_STAT_TOTAL_A 0x10e4
+#define SGE_STAT_MATCH_A 0x10e8
+#define SGE_STAT_CFG_A 0x10ec
+
+#define STATMODE_S 2
+#define STATMODE_V(x) ((x) << STATMODE_S)
+
+#define STATSOURCE_T5_S 9
+#define STATSOURCE_T5_M 0xfU
+#define STATSOURCE_T5_V(x) ((x) << STATSOURCE_T5_S)
+#define STATSOURCE_T5_G(x) (((x) >> STATSOURCE_T5_S) & STATSOURCE_T5_M)
+
+#define T6_STATMODE_S 0
+#define T6_STATMODE_V(x) ((x) << T6_STATMODE_S)
+
+#define SGE_DBFIFO_STATUS2_A 0x1118
+
+#define HP_INT_THRESH_T5_S 10
+#define HP_INT_THRESH_T5_M 0xfU
+#define HP_INT_THRESH_T5_V(x) ((x) << HP_INT_THRESH_T5_S)
+
+#define HP_COUNT_T5_S 0
+#define HP_COUNT_T5_M 0x3ffU
+#define HP_COUNT_T5_G(x) (((x) >> HP_COUNT_T5_S) & HP_COUNT_T5_M)
+
+#define ENABLE_DROP_S 13
+#define ENABLE_DROP_V(x) ((x) << ENABLE_DROP_S)
+#define ENABLE_DROP_F ENABLE_DROP_V(1U)
+
+#define DROPPED_DB_S 0
+#define DROPPED_DB_V(x) ((x) << DROPPED_DB_S)
+#define DROPPED_DB_F DROPPED_DB_V(1U)
+
+#define SGE_CTXT_CMD_A 0x11fc
+#define SGE_DBQ_CTXT_BADDR_A 0x1084
+
+/* registers for module PCIE */
+#define PCIE_PF_CFG_A 0x40
+
+#define AIVEC_S 4
+#define AIVEC_M 0x3ffU
+#define AIVEC_V(x) ((x) << AIVEC_S)
+
+#define PCIE_PF_CLI_A 0x44
+#define PCIE_INT_CAUSE_A 0x3004
+
+#define UNXSPLCPLERR_S 29
+#define UNXSPLCPLERR_V(x) ((x) << UNXSPLCPLERR_S)
+#define UNXSPLCPLERR_F UNXSPLCPLERR_V(1U)
+
+#define PCIEPINT_S 28
+#define PCIEPINT_V(x) ((x) << PCIEPINT_S)
+#define PCIEPINT_F PCIEPINT_V(1U)
+
+#define PCIESINT_S 27
+#define PCIESINT_V(x) ((x) << PCIESINT_S)
+#define PCIESINT_F PCIESINT_V(1U)
+
+#define RPLPERR_S 26
+#define RPLPERR_V(x) ((x) << RPLPERR_S)
+#define RPLPERR_F RPLPERR_V(1U)
+
+#define RXWRPERR_S 25
+#define RXWRPERR_V(x) ((x) << RXWRPERR_S)
+#define RXWRPERR_F RXWRPERR_V(1U)
+
+#define RXCPLPERR_S 24
+#define RXCPLPERR_V(x) ((x) << RXCPLPERR_S)
+#define RXCPLPERR_F RXCPLPERR_V(1U)
+
+#define PIOTAGPERR_S 23
+#define PIOTAGPERR_V(x) ((x) << PIOTAGPERR_S)
+#define PIOTAGPERR_F PIOTAGPERR_V(1U)
+
+#define MATAGPERR_S 22
+#define MATAGPERR_V(x) ((x) << MATAGPERR_S)
+#define MATAGPERR_F MATAGPERR_V(1U)
+
+#define INTXCLRPERR_S 21
+#define INTXCLRPERR_V(x) ((x) << INTXCLRPERR_S)
+#define INTXCLRPERR_F INTXCLRPERR_V(1U)
+
+#define FIDPERR_S 20
+#define FIDPERR_V(x) ((x) << FIDPERR_S)
+#define FIDPERR_F FIDPERR_V(1U)
+
+#define CFGSNPPERR_S 19
+#define CFGSNPPERR_V(x) ((x) << CFGSNPPERR_S)
+#define CFGSNPPERR_F CFGSNPPERR_V(1U)
+
+#define HRSPPERR_S 18
+#define HRSPPERR_V(x) ((x) << HRSPPERR_S)
+#define HRSPPERR_F HRSPPERR_V(1U)
+
+#define HREQPERR_S 17
+#define HREQPERR_V(x) ((x) << HREQPERR_S)
+#define HREQPERR_F HREQPERR_V(1U)
+
+#define HCNTPERR_S 16
+#define HCNTPERR_V(x) ((x) << HCNTPERR_S)
+#define HCNTPERR_F HCNTPERR_V(1U)
+
+#define DRSPPERR_S 15
+#define DRSPPERR_V(x) ((x) << DRSPPERR_S)
+#define DRSPPERR_F DRSPPERR_V(1U)
+
+#define DREQPERR_S 14
+#define DREQPERR_V(x) ((x) << DREQPERR_S)
+#define DREQPERR_F DREQPERR_V(1U)
+
+#define DCNTPERR_S 13
+#define DCNTPERR_V(x) ((x) << DCNTPERR_S)
+#define DCNTPERR_F DCNTPERR_V(1U)
+
+#define CRSPPERR_S 12
+#define CRSPPERR_V(x) ((x) << CRSPPERR_S)
+#define CRSPPERR_F CRSPPERR_V(1U)
+
+#define CREQPERR_S 11
+#define CREQPERR_V(x) ((x) << CREQPERR_S)
+#define CREQPERR_F CREQPERR_V(1U)
+
+#define CCNTPERR_S 10
+#define CCNTPERR_V(x) ((x) << CCNTPERR_S)
+#define CCNTPERR_F CCNTPERR_V(1U)
+
+#define TARTAGPERR_S 9
+#define TARTAGPERR_V(x) ((x) << TARTAGPERR_S)
+#define TARTAGPERR_F TARTAGPERR_V(1U)
+
+#define PIOREQPERR_S 8
+#define PIOREQPERR_V(x) ((x) << PIOREQPERR_S)
+#define PIOREQPERR_F PIOREQPERR_V(1U)
+
+#define PIOCPLPERR_S 7
+#define PIOCPLPERR_V(x) ((x) << PIOCPLPERR_S)
+#define PIOCPLPERR_F PIOCPLPERR_V(1U)
+
+#define MSIXDIPERR_S 6
+#define MSIXDIPERR_V(x) ((x) << MSIXDIPERR_S)
+#define MSIXDIPERR_F MSIXDIPERR_V(1U)
+
+#define MSIXDATAPERR_S 5
+#define MSIXDATAPERR_V(x) ((x) << MSIXDATAPERR_S)
+#define MSIXDATAPERR_F MSIXDATAPERR_V(1U)
+
+#define MSIXADDRHPERR_S 4
+#define MSIXADDRHPERR_V(x) ((x) << MSIXADDRHPERR_S)
+#define MSIXADDRHPERR_F MSIXADDRHPERR_V(1U)
+
+#define MSIXADDRLPERR_S 3
+#define MSIXADDRLPERR_V(x) ((x) << MSIXADDRLPERR_S)
+#define MSIXADDRLPERR_F MSIXADDRLPERR_V(1U)
+
+#define MSIDATAPERR_S 2
+#define MSIDATAPERR_V(x) ((x) << MSIDATAPERR_S)
+#define MSIDATAPERR_F MSIDATAPERR_V(1U)
+
+#define MSIADDRHPERR_S 1
+#define MSIADDRHPERR_V(x) ((x) << MSIADDRHPERR_S)
+#define MSIADDRHPERR_F MSIADDRHPERR_V(1U)
+
+#define MSIADDRLPERR_S 0
+#define MSIADDRLPERR_V(x) ((x) << MSIADDRLPERR_S)
+#define MSIADDRLPERR_F MSIADDRLPERR_V(1U)
+
+#define READRSPERR_S 29
+#define READRSPERR_V(x) ((x) << READRSPERR_S)
+#define READRSPERR_F READRSPERR_V(1U)
+
+#define TRGT1GRPPERR_S 28
+#define TRGT1GRPPERR_V(x) ((x) << TRGT1GRPPERR_S)
+#define TRGT1GRPPERR_F TRGT1GRPPERR_V(1U)
+
+#define IPSOTPERR_S 27
+#define IPSOTPERR_V(x) ((x) << IPSOTPERR_S)
+#define IPSOTPERR_F IPSOTPERR_V(1U)
+
+#define IPRETRYPERR_S 26
+#define IPRETRYPERR_V(x) ((x) << IPRETRYPERR_S)
+#define IPRETRYPERR_F IPRETRYPERR_V(1U)
+
+#define IPRXDATAGRPPERR_S 25
+#define IPRXDATAGRPPERR_V(x) ((x) << IPRXDATAGRPPERR_S)
+#define IPRXDATAGRPPERR_F IPRXDATAGRPPERR_V(1U)
+
+#define IPRXHDRGRPPERR_S 24
+#define IPRXHDRGRPPERR_V(x) ((x) << IPRXHDRGRPPERR_S)
+#define IPRXHDRGRPPERR_F IPRXHDRGRPPERR_V(1U)
+
+#define MAGRPPERR_S 22
+#define MAGRPPERR_V(x) ((x) << MAGRPPERR_S)
+#define MAGRPPERR_F MAGRPPERR_V(1U)
+
+#define VFIDPERR_S 21
+#define VFIDPERR_V(x) ((x) << VFIDPERR_S)
+#define VFIDPERR_F VFIDPERR_V(1U)
+
+#define HREQWRPERR_S 16
+#define HREQWRPERR_V(x) ((x) << HREQWRPERR_S)
+#define HREQWRPERR_F HREQWRPERR_V(1U)
+
+#define DREQWRPERR_S 13
+#define DREQWRPERR_V(x) ((x) << DREQWRPERR_S)
+#define DREQWRPERR_F DREQWRPERR_V(1U)
+
+#define CREQRDPERR_S 11
+#define CREQRDPERR_V(x) ((x) << CREQRDPERR_S)
+#define CREQRDPERR_F CREQRDPERR_V(1U)
+
+#define MSTTAGQPERR_S 10
+#define MSTTAGQPERR_V(x) ((x) << MSTTAGQPERR_S)
+#define MSTTAGQPERR_F MSTTAGQPERR_V(1U)
+
+#define PIOREQGRPPERR_S 8
+#define PIOREQGRPPERR_V(x) ((x) << PIOREQGRPPERR_S)
+#define PIOREQGRPPERR_F PIOREQGRPPERR_V(1U)
+
+#define PIOCPLGRPPERR_S 7
+#define PIOCPLGRPPERR_V(x) ((x) << PIOCPLGRPPERR_S)
+#define PIOCPLGRPPERR_F PIOCPLGRPPERR_V(1U)
+
+#define MSIXSTIPERR_S 2
+#define MSIXSTIPERR_V(x) ((x) << MSIXSTIPERR_S)
+#define MSIXSTIPERR_F MSIXSTIPERR_V(1U)
+
+#define MSTTIMEOUTPERR_S 1
+#define MSTTIMEOUTPERR_V(x) ((x) << MSTTIMEOUTPERR_S)
+#define MSTTIMEOUTPERR_F MSTTIMEOUTPERR_V(1U)
+
+#define MSTGRPPERR_S 0
+#define MSTGRPPERR_V(x) ((x) << MSTGRPPERR_S)
+#define MSTGRPPERR_F MSTGRPPERR_V(1U)
+
+#define PCIE_NONFAT_ERR_A 0x3010
+#define PCIE_CFG_SPACE_REQ_A 0x3060
+#define PCIE_CFG_SPACE_DATA_A 0x3064
+#define PCIE_MEM_ACCESS_BASE_WIN_A 0x3068
+
+#define PCIEOFST_S 10
+#define PCIEOFST_M 0x3fffffU
+#define PCIEOFST_G(x) (((x) >> PCIEOFST_S) & PCIEOFST_M)
+
+#define BIR_S 8
+#define BIR_M 0x3U
+#define BIR_V(x) ((x) << BIR_S)
+#define BIR_G(x) (((x) >> BIR_S) & BIR_M)
+
+#define WINDOW_S 0
+#define WINDOW_M 0xffU
+#define WINDOW_V(x) ((x) << WINDOW_S)
+#define WINDOW_G(x) (((x) >> WINDOW_S) & WINDOW_M)
+
+#define PCIE_MEM_ACCESS_OFFSET_A 0x306c
+
+#define ENABLE_S 30
+#define ENABLE_V(x) ((x) << ENABLE_S)
+#define ENABLE_F ENABLE_V(1U)
+
+#define LOCALCFG_S 28
+#define LOCALCFG_V(x) ((x) << LOCALCFG_S)
+#define LOCALCFG_F LOCALCFG_V(1U)
+
+#define FUNCTION_S 12
+#define FUNCTION_V(x) ((x) << FUNCTION_S)
+
+#define REGISTER_S 0
+#define REGISTER_V(x) ((x) << REGISTER_S)
+
+#define T6_ENABLE_S 31
+#define T6_ENABLE_V(x) ((x) << T6_ENABLE_S)
+#define T6_ENABLE_F T6_ENABLE_V(1U)
+
+#define PFNUM_S 0
+#define PFNUM_V(x) ((x) << PFNUM_S)
+
+#define PCIE_FW_A 0x30b8
+#define PCIE_FW_PF_A 0x30bc
+
+#define PCIE_CORE_UTL_SYSTEM_BUS_AGENT_STATUS_A 0x5908
+
+#define RNPP_S 31
+#define RNPP_V(x) ((x) << RNPP_S)
+#define RNPP_F RNPP_V(1U)
+
+#define RPCP_S 29
+#define RPCP_V(x) ((x) << RPCP_S)
+#define RPCP_F RPCP_V(1U)
+
+#define RCIP_S 27
+#define RCIP_V(x) ((x) << RCIP_S)
+#define RCIP_F RCIP_V(1U)
+
+#define RCCP_S 26
+#define RCCP_V(x) ((x) << RCCP_S)
+#define RCCP_F RCCP_V(1U)
+
+#define RFTP_S 23
+#define RFTP_V(x) ((x) << RFTP_S)
+#define RFTP_F RFTP_V(1U)
+
+#define PTRP_S 20
+#define PTRP_V(x) ((x) << PTRP_S)
+#define PTRP_F PTRP_V(1U)
+
+#define PCIE_CORE_UTL_PCI_EXPRESS_PORT_STATUS_A 0x59a4
+
+#define TPCP_S 30
+#define TPCP_V(x) ((x) << TPCP_S)
+#define TPCP_F TPCP_V(1U)
+
+#define TNPP_S 29
+#define TNPP_V(x) ((x) << TNPP_S)
+#define TNPP_F TNPP_V(1U)
+
+#define TFTP_S 28
+#define TFTP_V(x) ((x) << TFTP_S)
+#define TFTP_F TFTP_V(1U)
+
+#define TCAP_S 27
+#define TCAP_V(x) ((x) << TCAP_S)
+#define TCAP_F TCAP_V(1U)
+
+#define TCIP_S 26
+#define TCIP_V(x) ((x) << TCIP_S)
+#define TCIP_F TCIP_V(1U)
+
+#define RCAP_S 25
+#define RCAP_V(x) ((x) << RCAP_S)
+#define RCAP_F RCAP_V(1U)
+
+#define PLUP_S 23
+#define PLUP_V(x) ((x) << PLUP_S)
+#define PLUP_F PLUP_V(1U)
+
+#define PLDN_S 22
+#define PLDN_V(x) ((x) << PLDN_S)
+#define PLDN_F PLDN_V(1U)
+
+#define OTDD_S 21
+#define OTDD_V(x) ((x) << OTDD_S)
+#define OTDD_F OTDD_V(1U)
+
+#define GTRP_S 20
+#define GTRP_V(x) ((x) << GTRP_S)
+#define GTRP_F GTRP_V(1U)
+
+#define RDPE_S 18
+#define RDPE_V(x) ((x) << RDPE_S)
+#define RDPE_F RDPE_V(1U)
+
+#define TDCE_S 17
+#define TDCE_V(x) ((x) << TDCE_S)
+#define TDCE_F TDCE_V(1U)
+
+#define TDUE_S 16
+#define TDUE_V(x) ((x) << TDUE_S)
+#define TDUE_F TDUE_V(1U)
+
+/* registers for module MC */
+#define MC_INT_CAUSE_A 0x7518
+#define MC_P_INT_CAUSE_A 0x41318
+
+#define ECC_UE_INT_CAUSE_S 2
+#define ECC_UE_INT_CAUSE_V(x) ((x) << ECC_UE_INT_CAUSE_S)
+#define ECC_UE_INT_CAUSE_F ECC_UE_INT_CAUSE_V(1U)
+
+#define ECC_CE_INT_CAUSE_S 1
+#define ECC_CE_INT_CAUSE_V(x) ((x) << ECC_CE_INT_CAUSE_S)
+#define ECC_CE_INT_CAUSE_F ECC_CE_INT_CAUSE_V(1U)
+
+#define PERR_INT_CAUSE_S 0
+#define PERR_INT_CAUSE_V(x) ((x) << PERR_INT_CAUSE_S)
+#define PERR_INT_CAUSE_F PERR_INT_CAUSE_V(1U)
+
+#define MC_ECC_STATUS_A 0x751c
+#define MC_P_ECC_STATUS_A 0x4131c
+
+#define ECC_CECNT_S 16
+#define ECC_CECNT_M 0xffffU
+#define ECC_CECNT_V(x) ((x) << ECC_CECNT_S)
+#define ECC_CECNT_G(x) (((x) >> ECC_CECNT_S) & ECC_CECNT_M)
+
+#define ECC_UECNT_S 0
+#define ECC_UECNT_M 0xffffU
+#define ECC_UECNT_V(x) ((x) << ECC_UECNT_S)
+#define ECC_UECNT_G(x) (((x) >> ECC_UECNT_S) & ECC_UECNT_M)
+
+#define MC_BIST_CMD_A 0x7600
+
+#define START_BIST_S 31
+#define START_BIST_V(x) ((x) << START_BIST_S)
+#define START_BIST_F START_BIST_V(1U)
+
+#define BIST_CMD_GAP_S 8
+#define BIST_CMD_GAP_V(x) ((x) << BIST_CMD_GAP_S)
+
+#define BIST_OPCODE_S 0
+#define BIST_OPCODE_V(x) ((x) << BIST_OPCODE_S)
+
+#define MC_BIST_CMD_ADDR_A 0x7604
+#define MC_BIST_CMD_LEN_A 0x7608
+#define MC_BIST_DATA_PATTERN_A 0x760c
+
+#define MC_BIST_STATUS_RDATA_A 0x7688
+
+/* registers for module MA */
+#define MA_EDRAM0_BAR_A 0x77c0
+
+#define EDRAM0_BASE_S 16
+#define EDRAM0_BASE_M 0xfffU
+#define EDRAM0_BASE_G(x) (((x) >> EDRAM0_BASE_S) & EDRAM0_BASE_M)
+
+#define EDRAM0_SIZE_S 0
+#define EDRAM0_SIZE_M 0xfffU
+#define EDRAM0_SIZE_V(x) ((x) << EDRAM0_SIZE_S)
+#define EDRAM0_SIZE_G(x) (((x) >> EDRAM0_SIZE_S) & EDRAM0_SIZE_M)
+
+#define MA_EDRAM1_BAR_A 0x77c4
+
+#define EDRAM1_BASE_S 16
+#define EDRAM1_BASE_M 0xfffU
+#define EDRAM1_BASE_G(x) (((x) >> EDRAM1_BASE_S) & EDRAM1_BASE_M)
+
+#define EDRAM1_SIZE_S 0
+#define EDRAM1_SIZE_M 0xfffU
+#define EDRAM1_SIZE_V(x) ((x) << EDRAM1_SIZE_S)
+#define EDRAM1_SIZE_G(x) (((x) >> EDRAM1_SIZE_S) & EDRAM1_SIZE_M)
+
+#define MA_EXT_MEMORY_BAR_A 0x77c8
+
+#define EXT_MEM_BASE_S 16
+#define EXT_MEM_BASE_M 0xfffU
+#define EXT_MEM_BASE_V(x) ((x) << EXT_MEM_BASE_S)
+#define EXT_MEM_BASE_G(x) (((x) >> EXT_MEM_BASE_S) & EXT_MEM_BASE_M)
+
+#define EXT_MEM_SIZE_S 0
+#define EXT_MEM_SIZE_M 0xfffU
+#define EXT_MEM_SIZE_V(x) ((x) << EXT_MEM_SIZE_S)
+#define EXT_MEM_SIZE_G(x) (((x) >> EXT_MEM_SIZE_S) & EXT_MEM_SIZE_M)
+
+#define MA_EXT_MEMORY1_BAR_A 0x7808
+
+#define EXT_MEM1_BASE_S 16
+#define EXT_MEM1_BASE_M 0xfffU
+#define EXT_MEM1_BASE_G(x) (((x) >> EXT_MEM1_BASE_S) & EXT_MEM1_BASE_M)
+
+#define EXT_MEM1_SIZE_S 0
+#define EXT_MEM1_SIZE_M 0xfffU
+#define EXT_MEM1_SIZE_V(x) ((x) << EXT_MEM1_SIZE_S)
+#define EXT_MEM1_SIZE_G(x) (((x) >> EXT_MEM1_SIZE_S) & EXT_MEM1_SIZE_M)
+
+#define MA_EXT_MEMORY0_BAR_A 0x77c8
+
+#define EXT_MEM0_BASE_S 16
+#define EXT_MEM0_BASE_M 0xfffU
+#define EXT_MEM0_BASE_G(x) (((x) >> EXT_MEM0_BASE_S) & EXT_MEM0_BASE_M)
+
+#define EXT_MEM0_SIZE_S 0
+#define EXT_MEM0_SIZE_M 0xfffU
+#define EXT_MEM0_SIZE_V(x) ((x) << EXT_MEM0_SIZE_S)
+#define EXT_MEM0_SIZE_G(x) (((x) >> EXT_MEM0_SIZE_S) & EXT_MEM0_SIZE_M)
+
+#define MA_TARGET_MEM_ENABLE_A 0x77d8
+
+#define EXT_MEM_ENABLE_S 2
+#define EXT_MEM_ENABLE_V(x) ((x) << EXT_MEM_ENABLE_S)
+#define EXT_MEM_ENABLE_F EXT_MEM_ENABLE_V(1U)
+
+#define EDRAM1_ENABLE_S 1
+#define EDRAM1_ENABLE_V(x) ((x) << EDRAM1_ENABLE_S)
+#define EDRAM1_ENABLE_F EDRAM1_ENABLE_V(1U)
+
+#define EDRAM0_ENABLE_S 0
+#define EDRAM0_ENABLE_V(x) ((x) << EDRAM0_ENABLE_S)
+#define EDRAM0_ENABLE_F EDRAM0_ENABLE_V(1U)
+
+#define EXT_MEM1_ENABLE_S 4
+#define EXT_MEM1_ENABLE_V(x) ((x) << EXT_MEM1_ENABLE_S)
+#define EXT_MEM1_ENABLE_F EXT_MEM1_ENABLE_V(1U)
+
+#define EXT_MEM0_ENABLE_S 2
+#define EXT_MEM0_ENABLE_V(x) ((x) << EXT_MEM0_ENABLE_S)
+#define EXT_MEM0_ENABLE_F EXT_MEM0_ENABLE_V(1U)
+
+#define MA_INT_CAUSE_A 0x77e0
+
+#define MEM_PERR_INT_CAUSE_S 1
+#define MEM_PERR_INT_CAUSE_V(x) ((x) << MEM_PERR_INT_CAUSE_S)
+#define MEM_PERR_INT_CAUSE_F MEM_PERR_INT_CAUSE_V(1U)
+
+#define MEM_WRAP_INT_CAUSE_S 0
+#define MEM_WRAP_INT_CAUSE_V(x) ((x) << MEM_WRAP_INT_CAUSE_S)
+#define MEM_WRAP_INT_CAUSE_F MEM_WRAP_INT_CAUSE_V(1U)
+
+#define MA_INT_WRAP_STATUS_A 0x77e4
+
+#define MEM_WRAP_ADDRESS_S 4
+#define MEM_WRAP_ADDRESS_M 0xfffffffU
+#define MEM_WRAP_ADDRESS_G(x) (((x) >> MEM_WRAP_ADDRESS_S) & MEM_WRAP_ADDRESS_M)
+
+#define MEM_WRAP_CLIENT_NUM_S 0
+#define MEM_WRAP_CLIENT_NUM_M 0xfU
+#define MEM_WRAP_CLIENT_NUM_G(x) \
+ (((x) >> MEM_WRAP_CLIENT_NUM_S) & MEM_WRAP_CLIENT_NUM_M)
+
+#define MA_PARITY_ERROR_STATUS_A 0x77f4
+#define MA_PARITY_ERROR_STATUS1_A 0x77f4
+#define MA_PARITY_ERROR_STATUS2_A 0x7804
+
+/* registers for module EDC_0 */
+#define EDC_0_BASE_ADDR 0x7900
+
+#define EDC_BIST_CMD_A 0x7904
+#define EDC_BIST_CMD_ADDR_A 0x7908
+#define EDC_BIST_CMD_LEN_A 0x790c
+#define EDC_BIST_DATA_PATTERN_A 0x7910
+#define EDC_BIST_STATUS_RDATA_A 0x7928
+#define EDC_INT_CAUSE_A 0x7978
+
+#define ECC_UE_PAR_S 5
+#define ECC_UE_PAR_V(x) ((x) << ECC_UE_PAR_S)
+#define ECC_UE_PAR_F ECC_UE_PAR_V(1U)
+
+#define ECC_CE_PAR_S 4
+#define ECC_CE_PAR_V(x) ((x) << ECC_CE_PAR_S)
+#define ECC_CE_PAR_F ECC_CE_PAR_V(1U)
+
+#define PERR_PAR_CAUSE_S 3
+#define PERR_PAR_CAUSE_V(x) ((x) << PERR_PAR_CAUSE_S)
+#define PERR_PAR_CAUSE_F PERR_PAR_CAUSE_V(1U)
+
+#define EDC_ECC_STATUS_A 0x797c
+
+/* registers for module EDC_1 */
+#define EDC_1_BASE_ADDR 0x7980
+
+/* registers for module CIM */
+#define CIM_BOOT_CFG_A 0x7b00
+#define CIM_SDRAM_BASE_ADDR_A 0x7b14
+#define CIM_SDRAM_ADDR_SIZE_A 0x7b18
+#define CIM_EXTMEM2_BASE_ADDR_A 0x7b1c
+#define CIM_EXTMEM2_ADDR_SIZE_A 0x7b20
+#define CIM_PF_MAILBOX_CTRL_SHADOW_COPY_A 0x290
+
+#define BOOTADDR_M 0xffffff00U
+
+#define UPCRST_S 0
+#define UPCRST_V(x) ((x) << UPCRST_S)
+#define UPCRST_F UPCRST_V(1U)
+
+#define CIM_PF_MAILBOX_DATA_A 0x240
+#define CIM_PF_MAILBOX_CTRL_A 0x280
+
+#define MBMSGVALID_S 3
+#define MBMSGVALID_V(x) ((x) << MBMSGVALID_S)
+#define MBMSGVALID_F MBMSGVALID_V(1U)
+
+#define MBINTREQ_S 2
+#define MBINTREQ_V(x) ((x) << MBINTREQ_S)
+#define MBINTREQ_F MBINTREQ_V(1U)
+
+#define MBOWNER_S 0
+#define MBOWNER_M 0x3U
+#define MBOWNER_V(x) ((x) << MBOWNER_S)
+#define MBOWNER_G(x) (((x) >> MBOWNER_S) & MBOWNER_M)
+
+#define CIM_PF_HOST_INT_ENABLE_A 0x288
+
+#define MBMSGRDYINTEN_S 19
+#define MBMSGRDYINTEN_V(x) ((x) << MBMSGRDYINTEN_S)
+#define MBMSGRDYINTEN_F MBMSGRDYINTEN_V(1U)
+
+#define CIM_PF_HOST_INT_CAUSE_A 0x28c
+
+#define MBMSGRDYINT_S 19
+#define MBMSGRDYINT_V(x) ((x) << MBMSGRDYINT_S)
+#define MBMSGRDYINT_F MBMSGRDYINT_V(1U)
+
+#define CIM_HOST_INT_CAUSE_A 0x7b2c
+
+#define TIEQOUTPARERRINT_S 20
+#define TIEQOUTPARERRINT_V(x) ((x) << TIEQOUTPARERRINT_S)
+#define TIEQOUTPARERRINT_F TIEQOUTPARERRINT_V(1U)
+
+#define TIEQINPARERRINT_S 19
+#define TIEQINPARERRINT_V(x) ((x) << TIEQINPARERRINT_S)
+#define TIEQINPARERRINT_F TIEQINPARERRINT_V(1U)
+
+#define PREFDROPINT_S 1
+#define PREFDROPINT_V(x) ((x) << PREFDROPINT_S)
+#define PREFDROPINT_F PREFDROPINT_V(1U)
+
+#define UPACCNONZERO_S 0
+#define UPACCNONZERO_V(x) ((x) << UPACCNONZERO_S)
+#define UPACCNONZERO_F UPACCNONZERO_V(1U)
+
+#define MBHOSTPARERR_S 18
+#define MBHOSTPARERR_V(x) ((x) << MBHOSTPARERR_S)
+#define MBHOSTPARERR_F MBHOSTPARERR_V(1U)
+
+#define MBUPPARERR_S 17
+#define MBUPPARERR_V(x) ((x) << MBUPPARERR_S)
+#define MBUPPARERR_F MBUPPARERR_V(1U)
+
+#define IBQTP0PARERR_S 16
+#define IBQTP0PARERR_V(x) ((x) << IBQTP0PARERR_S)
+#define IBQTP0PARERR_F IBQTP0PARERR_V(1U)
+
+#define IBQTP1PARERR_S 15
+#define IBQTP1PARERR_V(x) ((x) << IBQTP1PARERR_S)
+#define IBQTP1PARERR_F IBQTP1PARERR_V(1U)
+
+#define IBQULPPARERR_S 14
+#define IBQULPPARERR_V(x) ((x) << IBQULPPARERR_S)
+#define IBQULPPARERR_F IBQULPPARERR_V(1U)
+
+#define IBQSGELOPARERR_S 13
+#define IBQSGELOPARERR_V(x) ((x) << IBQSGELOPARERR_S)
+#define IBQSGELOPARERR_F IBQSGELOPARERR_V(1U)
+
+#define IBQSGEHIPARERR_S 12
+#define IBQSGEHIPARERR_V(x) ((x) << IBQSGEHIPARERR_S)
+#define IBQSGEHIPARERR_F IBQSGEHIPARERR_V(1U)
+
+#define IBQNCSIPARERR_S 11
+#define IBQNCSIPARERR_V(x) ((x) << IBQNCSIPARERR_S)
+#define IBQNCSIPARERR_F IBQNCSIPARERR_V(1U)
+
+#define OBQULP0PARERR_S 10
+#define OBQULP0PARERR_V(x) ((x) << OBQULP0PARERR_S)
+#define OBQULP0PARERR_F OBQULP0PARERR_V(1U)
+
+#define OBQULP1PARERR_S 9
+#define OBQULP1PARERR_V(x) ((x) << OBQULP1PARERR_S)
+#define OBQULP1PARERR_F OBQULP1PARERR_V(1U)
+
+#define OBQULP2PARERR_S 8
+#define OBQULP2PARERR_V(x) ((x) << OBQULP2PARERR_S)
+#define OBQULP2PARERR_F OBQULP2PARERR_V(1U)
+
+#define OBQULP3PARERR_S 7
+#define OBQULP3PARERR_V(x) ((x) << OBQULP3PARERR_S)
+#define OBQULP3PARERR_F OBQULP3PARERR_V(1U)
+
+#define OBQSGEPARERR_S 6
+#define OBQSGEPARERR_V(x) ((x) << OBQSGEPARERR_S)
+#define OBQSGEPARERR_F OBQSGEPARERR_V(1U)
+
+#define OBQNCSIPARERR_S 5
+#define OBQNCSIPARERR_V(x) ((x) << OBQNCSIPARERR_S)
+#define OBQNCSIPARERR_F OBQNCSIPARERR_V(1U)
+
+#define CIM_HOST_UPACC_INT_CAUSE_A 0x7b34
+
+#define EEPROMWRINT_S 30
+#define EEPROMWRINT_V(x) ((x) << EEPROMWRINT_S)
+#define EEPROMWRINT_F EEPROMWRINT_V(1U)
+
+#define TIMEOUTMAINT_S 29
+#define TIMEOUTMAINT_V(x) ((x) << TIMEOUTMAINT_S)
+#define TIMEOUTMAINT_F TIMEOUTMAINT_V(1U)
+
+#define TIMEOUTINT_S 28
+#define TIMEOUTINT_V(x) ((x) << TIMEOUTINT_S)
+#define TIMEOUTINT_F TIMEOUTINT_V(1U)
+
+#define RSPOVRLOOKUPINT_S 27
+#define RSPOVRLOOKUPINT_V(x) ((x) << RSPOVRLOOKUPINT_S)
+#define RSPOVRLOOKUPINT_F RSPOVRLOOKUPINT_V(1U)
+
+#define REQOVRLOOKUPINT_S 26
+#define REQOVRLOOKUPINT_V(x) ((x) << REQOVRLOOKUPINT_S)
+#define REQOVRLOOKUPINT_F REQOVRLOOKUPINT_V(1U)
+
+#define BLKWRPLINT_S 25
+#define BLKWRPLINT_V(x) ((x) << BLKWRPLINT_S)
+#define BLKWRPLINT_F BLKWRPLINT_V(1U)
+
+#define BLKRDPLINT_S 24
+#define BLKRDPLINT_V(x) ((x) << BLKRDPLINT_S)
+#define BLKRDPLINT_F BLKRDPLINT_V(1U)
+
+#define SGLWRPLINT_S 23
+#define SGLWRPLINT_V(x) ((x) << SGLWRPLINT_S)
+#define SGLWRPLINT_F SGLWRPLINT_V(1U)
+
+#define SGLRDPLINT_S 22
+#define SGLRDPLINT_V(x) ((x) << SGLRDPLINT_S)
+#define SGLRDPLINT_F SGLRDPLINT_V(1U)
+
+#define BLKWRCTLINT_S 21
+#define BLKWRCTLINT_V(x) ((x) << BLKWRCTLINT_S)
+#define BLKWRCTLINT_F BLKWRCTLINT_V(1U)
+
+#define BLKRDCTLINT_S 20
+#define BLKRDCTLINT_V(x) ((x) << BLKRDCTLINT_S)
+#define BLKRDCTLINT_F BLKRDCTLINT_V(1U)
+
+#define SGLWRCTLINT_S 19
+#define SGLWRCTLINT_V(x) ((x) << SGLWRCTLINT_S)
+#define SGLWRCTLINT_F SGLWRCTLINT_V(1U)
+
+#define SGLRDCTLINT_S 18
+#define SGLRDCTLINT_V(x) ((x) << SGLRDCTLINT_S)
+#define SGLRDCTLINT_F SGLRDCTLINT_V(1U)
+
+#define BLKWREEPROMINT_S 17
+#define BLKWREEPROMINT_V(x) ((x) << BLKWREEPROMINT_S)
+#define BLKWREEPROMINT_F BLKWREEPROMINT_V(1U)
+
+#define BLKRDEEPROMINT_S 16
+#define BLKRDEEPROMINT_V(x) ((x) << BLKRDEEPROMINT_S)
+#define BLKRDEEPROMINT_F BLKRDEEPROMINT_V(1U)
+
+#define SGLWREEPROMINT_S 15
+#define SGLWREEPROMINT_V(x) ((x) << SGLWREEPROMINT_S)
+#define SGLWREEPROMINT_F SGLWREEPROMINT_V(1U)
+
+#define SGLRDEEPROMINT_S 14
+#define SGLRDEEPROMINT_V(x) ((x) << SGLRDEEPROMINT_S)
+#define SGLRDEEPROMINT_F SGLRDEEPROMINT_V(1U)
+
+#define BLKWRFLASHINT_S 13
+#define BLKWRFLASHINT_V(x) ((x) << BLKWRFLASHINT_S)
+#define BLKWRFLASHINT_F BLKWRFLASHINT_V(1U)
+
+#define BLKRDFLASHINT_S 12
+#define BLKRDFLASHINT_V(x) ((x) << BLKRDFLASHINT_S)
+#define BLKRDFLASHINT_F BLKRDFLASHINT_V(1U)
+
+#define SGLWRFLASHINT_S 11
+#define SGLWRFLASHINT_V(x) ((x) << SGLWRFLASHINT_S)
+#define SGLWRFLASHINT_F SGLWRFLASHINT_V(1U)
+
+#define SGLRDFLASHINT_S 10
+#define SGLRDFLASHINT_V(x) ((x) << SGLRDFLASHINT_S)
+#define SGLRDFLASHINT_F SGLRDFLASHINT_V(1U)
+
+#define BLKWRBOOTINT_S 9
+#define BLKWRBOOTINT_V(x) ((x) << BLKWRBOOTINT_S)
+#define BLKWRBOOTINT_F BLKWRBOOTINT_V(1U)
+
+#define BLKRDBOOTINT_S 8
+#define BLKRDBOOTINT_V(x) ((x) << BLKRDBOOTINT_S)
+#define BLKRDBOOTINT_F BLKRDBOOTINT_V(1U)
+
+#define SGLWRBOOTINT_S 7
+#define SGLWRBOOTINT_V(x) ((x) << SGLWRBOOTINT_S)
+#define SGLWRBOOTINT_F SGLWRBOOTINT_V(1U)
+
+#define SGLRDBOOTINT_S 6
+#define SGLRDBOOTINT_V(x) ((x) << SGLRDBOOTINT_S)
+#define SGLRDBOOTINT_F SGLRDBOOTINT_V(1U)
+
+#define ILLWRBEINT_S 5
+#define ILLWRBEINT_V(x) ((x) << ILLWRBEINT_S)
+#define ILLWRBEINT_F ILLWRBEINT_V(1U)
+
+#define ILLRDBEINT_S 4
+#define ILLRDBEINT_V(x) ((x) << ILLRDBEINT_S)
+#define ILLRDBEINT_F ILLRDBEINT_V(1U)
+
+#define ILLRDINT_S 3
+#define ILLRDINT_V(x) ((x) << ILLRDINT_S)
+#define ILLRDINT_F ILLRDINT_V(1U)
+
+#define ILLWRINT_S 2
+#define ILLWRINT_V(x) ((x) << ILLWRINT_S)
+#define ILLWRINT_F ILLWRINT_V(1U)
+
+#define ILLTRANSINT_S 1
+#define ILLTRANSINT_V(x) ((x) << ILLTRANSINT_S)
+#define ILLTRANSINT_F ILLTRANSINT_V(1U)
+
+#define RSVDSPACEINT_S 0
+#define RSVDSPACEINT_V(x) ((x) << RSVDSPACEINT_S)
+#define RSVDSPACEINT_F RSVDSPACEINT_V(1U)
+
+/* registers for module TP */
+#define DBGLAWHLF_S 23
+#define DBGLAWHLF_V(x) ((x) << DBGLAWHLF_S)
+#define DBGLAWHLF_F DBGLAWHLF_V(1U)
+
+#define DBGLAWPTR_S 16
+#define DBGLAWPTR_M 0x7fU
+#define DBGLAWPTR_G(x) (((x) >> DBGLAWPTR_S) & DBGLAWPTR_M)
+
+#define DBGLAENABLE_S 12
+#define DBGLAENABLE_V(x) ((x) << DBGLAENABLE_S)
+#define DBGLAENABLE_F DBGLAENABLE_V(1U)
+
+#define DBGLARPTR_S 0
+#define DBGLARPTR_M 0x7fU
+#define DBGLARPTR_V(x) ((x) << DBGLARPTR_S)
+
+#define TP_DBG_LA_DATAL_A 0x7ed8
+#define TP_DBG_LA_CONFIG_A 0x7ed4
+#define TP_OUT_CONFIG_A 0x7d04
+#define TP_GLOBAL_CONFIG_A 0x7d08
+
+#define TP_CMM_TCB_BASE_A 0x7d10
+#define TP_CMM_MM_BASE_A 0x7d14
+#define TP_CMM_TIMER_BASE_A 0x7d18
+#define TP_PMM_TX_BASE_A 0x7d20
+#define TP_PMM_RX_BASE_A 0x7d28
+#define TP_PMM_RX_PAGE_SIZE_A 0x7d2c
+#define TP_PMM_RX_MAX_PAGE_A 0x7d30
+#define TP_PMM_TX_PAGE_SIZE_A 0x7d34
+#define TP_PMM_TX_MAX_PAGE_A 0x7d38
+#define TP_CMM_MM_MAX_PSTRUCT_A 0x7e6c
+
+#define PMRXNUMCHN_S 31
+#define PMRXNUMCHN_V(x) ((x) << PMRXNUMCHN_S)
+#define PMRXNUMCHN_F PMRXNUMCHN_V(1U)
+
+#define PMTXNUMCHN_S 30
+#define PMTXNUMCHN_M 0x3U
+#define PMTXNUMCHN_G(x) (((x) >> PMTXNUMCHN_S) & PMTXNUMCHN_M)
+
+#define PMTXMAXPAGE_S 0
+#define PMTXMAXPAGE_M 0x1fffffU
+#define PMTXMAXPAGE_G(x) (((x) >> PMTXMAXPAGE_S) & PMTXMAXPAGE_M)
+
+#define PMRXMAXPAGE_S 0
+#define PMRXMAXPAGE_M 0x1fffffU
+#define PMRXMAXPAGE_G(x) (((x) >> PMRXMAXPAGE_S) & PMRXMAXPAGE_M)
+
+#define DBGLAMODE_S 14
+#define DBGLAMODE_M 0x3U
+#define DBGLAMODE_G(x) (((x) >> DBGLAMODE_S) & DBGLAMODE_M)
+
+#define FIVETUPLELOOKUP_S 17
+#define FIVETUPLELOOKUP_M 0x3U
+#define FIVETUPLELOOKUP_V(x) ((x) << FIVETUPLELOOKUP_S)
+#define FIVETUPLELOOKUP_G(x) (((x) >> FIVETUPLELOOKUP_S) & FIVETUPLELOOKUP_M)
+
+#define TP_PARA_REG2_A 0x7d68
+
+#define MAXRXDATA_S 16
+#define MAXRXDATA_M 0xffffU
+#define MAXRXDATA_G(x) (((x) >> MAXRXDATA_S) & MAXRXDATA_M)
+
+#define TP_TIMER_RESOLUTION_A 0x7d90
+
+#define TIMERRESOLUTION_S 16
+#define TIMERRESOLUTION_M 0xffU
+#define TIMERRESOLUTION_G(x) (((x) >> TIMERRESOLUTION_S) & TIMERRESOLUTION_M)
+
+#define TIMESTAMPRESOLUTION_S 8
+#define TIMESTAMPRESOLUTION_M 0xffU
+#define TIMESTAMPRESOLUTION_G(x) \
+ (((x) >> TIMESTAMPRESOLUTION_S) & TIMESTAMPRESOLUTION_M)
+
+#define DELAYEDACKRESOLUTION_S 0
+#define DELAYEDACKRESOLUTION_M 0xffU
+#define DELAYEDACKRESOLUTION_G(x) \
+ (((x) >> DELAYEDACKRESOLUTION_S) & DELAYEDACKRESOLUTION_M)
+
+#define TP_SHIFT_CNT_A 0x7dc0
+#define TP_RXT_MIN_A 0x7d98
+#define TP_RXT_MAX_A 0x7d9c
+#define TP_PERS_MIN_A 0x7da0
+#define TP_PERS_MAX_A 0x7da4
+#define TP_KEEP_IDLE_A 0x7da8
+#define TP_KEEP_INTVL_A 0x7dac
+#define TP_INIT_SRTT_A 0x7db0
+#define TP_DACK_TIMER_A 0x7db4
+#define TP_FINWAIT2_TIMER_A 0x7db8
+
+#define INITSRTT_S 0
+#define INITSRTT_M 0xffffU
+#define INITSRTT_G(x) (((x) >> INITSRTT_S) & INITSRTT_M)
+
+#define PERSMAX_S 0
+#define PERSMAX_M 0x3fffffffU
+#define PERSMAX_V(x) ((x) << PERSMAX_S)
+#define PERSMAX_G(x) (((x) >> PERSMAX_S) & PERSMAX_M)
+
+#define SYNSHIFTMAX_S 24
+#define SYNSHIFTMAX_M 0xffU
+#define SYNSHIFTMAX_V(x) ((x) << SYNSHIFTMAX_S)
+#define SYNSHIFTMAX_G(x) (((x) >> SYNSHIFTMAX_S) & SYNSHIFTMAX_M)
+
+#define RXTSHIFTMAXR1_S 20
+#define RXTSHIFTMAXR1_M 0xfU
+#define RXTSHIFTMAXR1_V(x) ((x) << RXTSHIFTMAXR1_S)
+#define RXTSHIFTMAXR1_G(x) (((x) >> RXTSHIFTMAXR1_S) & RXTSHIFTMAXR1_M)
+
+#define RXTSHIFTMAXR2_S 16
+#define RXTSHIFTMAXR2_M 0xfU
+#define RXTSHIFTMAXR2_V(x) ((x) << RXTSHIFTMAXR2_S)
+#define RXTSHIFTMAXR2_G(x) (((x) >> RXTSHIFTMAXR2_S) & RXTSHIFTMAXR2_M)
+
+#define PERSHIFTBACKOFFMAX_S 12
+#define PERSHIFTBACKOFFMAX_M 0xfU
+#define PERSHIFTBACKOFFMAX_V(x) ((x) << PERSHIFTBACKOFFMAX_S)
+#define PERSHIFTBACKOFFMAX_G(x) \
+ (((x) >> PERSHIFTBACKOFFMAX_S) & PERSHIFTBACKOFFMAX_M)
+
+#define PERSHIFTMAX_S 8
+#define PERSHIFTMAX_M 0xfU
+#define PERSHIFTMAX_V(x) ((x) << PERSHIFTMAX_S)
+#define PERSHIFTMAX_G(x) (((x) >> PERSHIFTMAX_S) & PERSHIFTMAX_M)
+
+#define KEEPALIVEMAXR1_S 4
+#define KEEPALIVEMAXR1_M 0xfU
+#define KEEPALIVEMAXR1_V(x) ((x) << KEEPALIVEMAXR1_S)
+#define KEEPALIVEMAXR1_G(x) (((x) >> KEEPALIVEMAXR1_S) & KEEPALIVEMAXR1_M)
+
+#define KEEPALIVEMAXR2_S 0
+#define KEEPALIVEMAXR2_M 0xfU
+#define KEEPALIVEMAXR2_V(x) ((x) << KEEPALIVEMAXR2_S)
+#define KEEPALIVEMAXR2_G(x) (((x) >> KEEPALIVEMAXR2_S) & KEEPALIVEMAXR2_M)
+
+#define ROWINDEX_S 16
+#define ROWINDEX_V(x) ((x) << ROWINDEX_S)
+
+#define TP_CCTRL_TABLE_A 0x7ddc
+#define TP_MTU_TABLE_A 0x7de4
+
+#define MTUINDEX_S 24
+#define MTUINDEX_V(x) ((x) << MTUINDEX_S)
+
+#define MTUWIDTH_S 16
+#define MTUWIDTH_M 0xfU
+#define MTUWIDTH_V(x) ((x) << MTUWIDTH_S)
+#define MTUWIDTH_G(x) (((x) >> MTUWIDTH_S) & MTUWIDTH_M)
+
+#define MTUVALUE_S 0
+#define MTUVALUE_M 0x3fffU
+#define MTUVALUE_V(x) ((x) << MTUVALUE_S)
+#define MTUVALUE_G(x) (((x) >> MTUVALUE_S) & MTUVALUE_M)
+
+#define TP_RSS_LKP_TABLE_A 0x7dec
+#define TP_CMM_MM_RX_FLST_BASE_A 0x7e60
+#define TP_CMM_MM_TX_FLST_BASE_A 0x7e64
+#define TP_CMM_MM_PS_FLST_BASE_A 0x7e68
+
+#define LKPTBLROWVLD_S 31
+#define LKPTBLROWVLD_V(x) ((x) << LKPTBLROWVLD_S)
+#define LKPTBLROWVLD_F LKPTBLROWVLD_V(1U)
+
+#define LKPTBLQUEUE1_S 10
+#define LKPTBLQUEUE1_M 0x3ffU
+#define LKPTBLQUEUE1_G(x) (((x) >> LKPTBLQUEUE1_S) & LKPTBLQUEUE1_M)
+
+#define LKPTBLQUEUE0_S 0
+#define LKPTBLQUEUE0_M 0x3ffU
+#define LKPTBLQUEUE0_G(x) (((x) >> LKPTBLQUEUE0_S) & LKPTBLQUEUE0_M)
+
+#define TP_PIO_ADDR_A 0x7e40
+#define TP_PIO_DATA_A 0x7e44
+#define TP_MIB_INDEX_A 0x7e50
+#define TP_MIB_DATA_A 0x7e54
+#define TP_INT_CAUSE_A 0x7e74
+
+#define FLMTXFLSTEMPTY_S 30
+#define FLMTXFLSTEMPTY_V(x) ((x) << FLMTXFLSTEMPTY_S)
+#define FLMTXFLSTEMPTY_F FLMTXFLSTEMPTY_V(1U)
+
+#define TP_TX_ORATE_A 0x7ebc
+
+#define OFDRATE3_S 24
+#define OFDRATE3_M 0xffU
+#define OFDRATE3_G(x) (((x) >> OFDRATE3_S) & OFDRATE3_M)
+
+#define OFDRATE2_S 16
+#define OFDRATE2_M 0xffU
+#define OFDRATE2_G(x) (((x) >> OFDRATE2_S) & OFDRATE2_M)
+
+#define OFDRATE1_S 8
+#define OFDRATE1_M 0xffU
+#define OFDRATE1_G(x) (((x) >> OFDRATE1_S) & OFDRATE1_M)
+
+#define OFDRATE0_S 0
+#define OFDRATE0_M 0xffU
+#define OFDRATE0_G(x) (((x) >> OFDRATE0_S) & OFDRATE0_M)
+
+#define TP_TX_TRATE_A 0x7ed0
+
+#define TNLRATE3_S 24
+#define TNLRATE3_M 0xffU
+#define TNLRATE3_G(x) (((x) >> TNLRATE3_S) & TNLRATE3_M)
+
+#define TNLRATE2_S 16
+#define TNLRATE2_M 0xffU
+#define TNLRATE2_G(x) (((x) >> TNLRATE2_S) & TNLRATE2_M)
+
+#define TNLRATE1_S 8
+#define TNLRATE1_M 0xffU
+#define TNLRATE1_G(x) (((x) >> TNLRATE1_S) & TNLRATE1_M)
+
+#define TNLRATE0_S 0
+#define TNLRATE0_M 0xffU
+#define TNLRATE0_G(x) (((x) >> TNLRATE0_S) & TNLRATE0_M)
+
+#define TP_VLAN_PRI_MAP_A 0x140
+
+#define FRAGMENTATION_S 9
+#define FRAGMENTATION_V(x) ((x) << FRAGMENTATION_S)
+#define FRAGMENTATION_F FRAGMENTATION_V(1U)
+
+#define MPSHITTYPE_S 8
+#define MPSHITTYPE_V(x) ((x) << MPSHITTYPE_S)
+#define MPSHITTYPE_F MPSHITTYPE_V(1U)
+
+#define MACMATCH_S 7
+#define MACMATCH_V(x) ((x) << MACMATCH_S)
+#define MACMATCH_F MACMATCH_V(1U)
+
+#define ETHERTYPE_S 6
+#define ETHERTYPE_V(x) ((x) << ETHERTYPE_S)
+#define ETHERTYPE_F ETHERTYPE_V(1U)
+
+#define PROTOCOL_S 5
+#define PROTOCOL_V(x) ((x) << PROTOCOL_S)
+#define PROTOCOL_F PROTOCOL_V(1U)
+
+#define TOS_S 4
+#define TOS_V(x) ((x) << TOS_S)
+#define TOS_F TOS_V(1U)
+
+#define VLAN_S 3
+#define VLAN_V(x) ((x) << VLAN_S)
+#define VLAN_F VLAN_V(1U)
+
+#define VNIC_ID_S 2
+#define VNIC_ID_V(x) ((x) << VNIC_ID_S)
+#define VNIC_ID_F VNIC_ID_V(1U)
+
+#define PORT_S 1
+#define PORT_V(x) ((x) << PORT_S)
+#define PORT_F PORT_V(1U)
+
+#define FCOE_S 0
+#define FCOE_V(x) ((x) << FCOE_S)
+#define FCOE_F FCOE_V(1U)
+
+#define FILTERMODE_S 15
+#define FILTERMODE_V(x) ((x) << FILTERMODE_S)
+#define FILTERMODE_F FILTERMODE_V(1U)
+
+#define FCOEMASK_S 14
+#define FCOEMASK_V(x) ((x) << FCOEMASK_S)
+#define FCOEMASK_F FCOEMASK_V(1U)
+
+#define TP_INGRESS_CONFIG_A 0x141
+
+#define VNIC_S 11
+#define VNIC_V(x) ((x) << VNIC_S)
+#define VNIC_F VNIC_V(1U)
+
+#define CSUM_HAS_PSEUDO_HDR_S 10
+#define CSUM_HAS_PSEUDO_HDR_V(x) ((x) << CSUM_HAS_PSEUDO_HDR_S)
+#define CSUM_HAS_PSEUDO_HDR_F CSUM_HAS_PSEUDO_HDR_V(1U)
+
+#define TP_MIB_MAC_IN_ERR_0_A 0x0
+#define TP_MIB_HDR_IN_ERR_0_A 0x4
+#define TP_MIB_TCP_IN_ERR_0_A 0x8
+#define TP_MIB_TCP_OUT_RST_A 0xc
+#define TP_MIB_TCP_IN_SEG_HI_A 0x10
+#define TP_MIB_TCP_IN_SEG_LO_A 0x11
+#define TP_MIB_TCP_OUT_SEG_HI_A 0x12
+#define TP_MIB_TCP_OUT_SEG_LO_A 0x13
+#define TP_MIB_TCP_RXT_SEG_HI_A 0x14
+#define TP_MIB_TCP_RXT_SEG_LO_A 0x15
+#define TP_MIB_TNL_CNG_DROP_0_A 0x18
+#define TP_MIB_OFD_CHN_DROP_0_A 0x1c
+#define TP_MIB_TCP_V6IN_ERR_0_A 0x28
+#define TP_MIB_TCP_V6OUT_RST_A 0x2c
+#define TP_MIB_OFD_ARP_DROP_A 0x36
+#define TP_MIB_CPL_IN_REQ_0_A 0x38
+#define TP_MIB_CPL_OUT_RSP_0_A 0x3c
+#define TP_MIB_TNL_DROP_0_A 0x44
+#define TP_MIB_FCOE_DDP_0_A 0x48
+#define TP_MIB_FCOE_DROP_0_A 0x4c
+#define TP_MIB_FCOE_BYTE_0_HI_A 0x50
+#define TP_MIB_OFD_VLN_DROP_0_A 0x58
+#define TP_MIB_USM_PKTS_A 0x5c
+#define TP_MIB_RQE_DFR_PKT_A 0x64
+
+#define ULP_TX_INT_CAUSE_A 0x8dcc
+#define ULP_TX_TPT_LLIMIT_A 0x8dd4
+#define ULP_TX_TPT_ULIMIT_A 0x8dd8
+#define ULP_TX_PBL_LLIMIT_A 0x8ddc
+#define ULP_TX_PBL_ULIMIT_A 0x8de0
+#define ULP_TX_ERR_TABLE_BASE_A 0x8e04
+
+#define PBL_BOUND_ERR_CH3_S 31
+#define PBL_BOUND_ERR_CH3_V(x) ((x) << PBL_BOUND_ERR_CH3_S)
+#define PBL_BOUND_ERR_CH3_F PBL_BOUND_ERR_CH3_V(1U)
+
+#define PBL_BOUND_ERR_CH2_S 30
+#define PBL_BOUND_ERR_CH2_V(x) ((x) << PBL_BOUND_ERR_CH2_S)
+#define PBL_BOUND_ERR_CH2_F PBL_BOUND_ERR_CH2_V(1U)
+
+#define PBL_BOUND_ERR_CH1_S 29
+#define PBL_BOUND_ERR_CH1_V(x) ((x) << PBL_BOUND_ERR_CH1_S)
+#define PBL_BOUND_ERR_CH1_F PBL_BOUND_ERR_CH1_V(1U)
+
+#define PBL_BOUND_ERR_CH0_S 28
+#define PBL_BOUND_ERR_CH0_V(x) ((x) << PBL_BOUND_ERR_CH0_S)
+#define PBL_BOUND_ERR_CH0_F PBL_BOUND_ERR_CH0_V(1U)
+
+#define PM_RX_INT_CAUSE_A 0x8fdc
+#define PM_RX_STAT_CONFIG_A 0x8fc8
+#define PM_RX_STAT_COUNT_A 0x8fcc
+#define PM_RX_STAT_LSB_A 0x8fd0
+#define PM_RX_DBG_CTRL_A 0x8fd0
+#define PM_RX_DBG_DATA_A 0x8fd4
+#define PM_RX_DBG_STAT_MSB_A 0x10013
+
+#define PMRX_FRAMING_ERROR_F 0x003ffff0U
+
+#define ZERO_E_CMD_ERROR_S 22
+#define ZERO_E_CMD_ERROR_V(x) ((x) << ZERO_E_CMD_ERROR_S)
+#define ZERO_E_CMD_ERROR_F ZERO_E_CMD_ERROR_V(1U)
+
+#define OCSPI_PAR_ERROR_S 3
+#define OCSPI_PAR_ERROR_V(x) ((x) << OCSPI_PAR_ERROR_S)
+#define OCSPI_PAR_ERROR_F OCSPI_PAR_ERROR_V(1U)
+
+#define DB_OPTIONS_PAR_ERROR_S 2
+#define DB_OPTIONS_PAR_ERROR_V(x) ((x) << DB_OPTIONS_PAR_ERROR_S)
+#define DB_OPTIONS_PAR_ERROR_F DB_OPTIONS_PAR_ERROR_V(1U)
+
+#define IESPI_PAR_ERROR_S 1
+#define IESPI_PAR_ERROR_V(x) ((x) << IESPI_PAR_ERROR_S)
+#define IESPI_PAR_ERROR_F IESPI_PAR_ERROR_V(1U)
+
+#define PMRX_E_PCMD_PAR_ERROR_S 0
+#define PMRX_E_PCMD_PAR_ERROR_V(x) ((x) << PMRX_E_PCMD_PAR_ERROR_S)
+#define PMRX_E_PCMD_PAR_ERROR_F PMRX_E_PCMD_PAR_ERROR_V(1U)
+
+#define PM_TX_INT_CAUSE_A 0x8ffc
+#define PM_TX_STAT_CONFIG_A 0x8fe8
+#define PM_TX_STAT_COUNT_A 0x8fec
+#define PM_TX_STAT_LSB_A 0x8ff0
+#define PM_TX_DBG_CTRL_A 0x8ff0
+#define PM_TX_DBG_DATA_A 0x8ff4
+#define PM_TX_DBG_STAT_MSB_A 0x1001a
+
+#define PCMD_LEN_OVFL0_S 31
+#define PCMD_LEN_OVFL0_V(x) ((x) << PCMD_LEN_OVFL0_S)
+#define PCMD_LEN_OVFL0_F PCMD_LEN_OVFL0_V(1U)
+
+#define PCMD_LEN_OVFL1_S 30
+#define PCMD_LEN_OVFL1_V(x) ((x) << PCMD_LEN_OVFL1_S)
+#define PCMD_LEN_OVFL1_F PCMD_LEN_OVFL1_V(1U)
+
+#define PCMD_LEN_OVFL2_S 29
+#define PCMD_LEN_OVFL2_V(x) ((x) << PCMD_LEN_OVFL2_S)
+#define PCMD_LEN_OVFL2_F PCMD_LEN_OVFL2_V(1U)
+
+#define ZERO_C_CMD_ERROR_S 28
+#define ZERO_C_CMD_ERROR_V(x) ((x) << ZERO_C_CMD_ERROR_S)
+#define ZERO_C_CMD_ERROR_F ZERO_C_CMD_ERROR_V(1U)
+
+#define PMTX_FRAMING_ERROR_F 0x0ffffff0U
+
+#define OESPI_PAR_ERROR_S 3
+#define OESPI_PAR_ERROR_V(x) ((x) << OESPI_PAR_ERROR_S)
+#define OESPI_PAR_ERROR_F OESPI_PAR_ERROR_V(1U)
+
+#define ICSPI_PAR_ERROR_S 1
+#define ICSPI_PAR_ERROR_V(x) ((x) << ICSPI_PAR_ERROR_S)
+#define ICSPI_PAR_ERROR_F ICSPI_PAR_ERROR_V(1U)
+
+#define PMTX_C_PCMD_PAR_ERROR_S 0
+#define PMTX_C_PCMD_PAR_ERROR_V(x) ((x) << PMTX_C_PCMD_PAR_ERROR_S)
+#define PMTX_C_PCMD_PAR_ERROR_F PMTX_C_PCMD_PAR_ERROR_V(1U)
+
+#define MPS_PORT_STAT_TX_PORT_BYTES_L 0x400
+#define MPS_PORT_STAT_TX_PORT_BYTES_H 0x404
+#define MPS_PORT_STAT_TX_PORT_FRAMES_L 0x408
+#define MPS_PORT_STAT_TX_PORT_FRAMES_H 0x40c
+#define MPS_PORT_STAT_TX_PORT_BCAST_L 0x410
+#define MPS_PORT_STAT_TX_PORT_BCAST_H 0x414
+#define MPS_PORT_STAT_TX_PORT_MCAST_L 0x418
+#define MPS_PORT_STAT_TX_PORT_MCAST_H 0x41c
+#define MPS_PORT_STAT_TX_PORT_UCAST_L 0x420
+#define MPS_PORT_STAT_TX_PORT_UCAST_H 0x424
+#define MPS_PORT_STAT_TX_PORT_ERROR_L 0x428
+#define MPS_PORT_STAT_TX_PORT_ERROR_H 0x42c
+#define MPS_PORT_STAT_TX_PORT_64B_L 0x430
+#define MPS_PORT_STAT_TX_PORT_64B_H 0x434
+#define MPS_PORT_STAT_TX_PORT_65B_127B_L 0x438
+#define MPS_PORT_STAT_TX_PORT_65B_127B_H 0x43c
+#define MPS_PORT_STAT_TX_PORT_128B_255B_L 0x440
+#define MPS_PORT_STAT_TX_PORT_128B_255B_H 0x444
+#define MPS_PORT_STAT_TX_PORT_256B_511B_L 0x448
+#define MPS_PORT_STAT_TX_PORT_256B_511B_H 0x44c
+#define MPS_PORT_STAT_TX_PORT_512B_1023B_L 0x450
+#define MPS_PORT_STAT_TX_PORT_512B_1023B_H 0x454
+#define MPS_PORT_STAT_TX_PORT_1024B_1518B_L 0x458
+#define MPS_PORT_STAT_TX_PORT_1024B_1518B_H 0x45c
+#define MPS_PORT_STAT_TX_PORT_1519B_MAX_L 0x460
+#define MPS_PORT_STAT_TX_PORT_1519B_MAX_H 0x464
+#define MPS_PORT_STAT_TX_PORT_DROP_L 0x468
+#define MPS_PORT_STAT_TX_PORT_DROP_H 0x46c
+#define MPS_PORT_STAT_TX_PORT_PAUSE_L 0x470
+#define MPS_PORT_STAT_TX_PORT_PAUSE_H 0x474
+#define MPS_PORT_STAT_TX_PORT_PPP0_L 0x478
+#define MPS_PORT_STAT_TX_PORT_PPP0_H 0x47c
+#define MPS_PORT_STAT_TX_PORT_PPP1_L 0x480
+#define MPS_PORT_STAT_TX_PORT_PPP1_H 0x484
+#define MPS_PORT_STAT_TX_PORT_PPP2_L 0x488
+#define MPS_PORT_STAT_TX_PORT_PPP2_H 0x48c
+#define MPS_PORT_STAT_TX_PORT_PPP3_L 0x490
+#define MPS_PORT_STAT_TX_PORT_PPP3_H 0x494
+#define MPS_PORT_STAT_TX_PORT_PPP4_L 0x498
+#define MPS_PORT_STAT_TX_PORT_PPP4_H 0x49c
+#define MPS_PORT_STAT_TX_PORT_PPP5_L 0x4a0
+#define MPS_PORT_STAT_TX_PORT_PPP5_H 0x4a4
+#define MPS_PORT_STAT_TX_PORT_PPP6_L 0x4a8
+#define MPS_PORT_STAT_TX_PORT_PPP6_H 0x4ac
+#define MPS_PORT_STAT_TX_PORT_PPP7_L 0x4b0
+#define MPS_PORT_STAT_TX_PORT_PPP7_H 0x4b4
+#define MPS_PORT_STAT_LB_PORT_BYTES_L 0x4c0
+#define MPS_PORT_STAT_LB_PORT_BYTES_H 0x4c4
+#define MPS_PORT_STAT_LB_PORT_FRAMES_L 0x4c8
+#define MPS_PORT_STAT_LB_PORT_FRAMES_H 0x4cc
+#define MPS_PORT_STAT_LB_PORT_BCAST_L 0x4d0
+#define MPS_PORT_STAT_LB_PORT_BCAST_H 0x4d4
+#define MPS_PORT_STAT_LB_PORT_MCAST_L 0x4d8
+#define MPS_PORT_STAT_LB_PORT_MCAST_H 0x4dc
+#define MPS_PORT_STAT_LB_PORT_UCAST_L 0x4e0
+#define MPS_PORT_STAT_LB_PORT_UCAST_H 0x4e4
+#define MPS_PORT_STAT_LB_PORT_ERROR_L 0x4e8
+#define MPS_PORT_STAT_LB_PORT_ERROR_H 0x4ec
+#define MPS_PORT_STAT_LB_PORT_64B_L 0x4f0
+#define MPS_PORT_STAT_LB_PORT_64B_H 0x4f4
+#define MPS_PORT_STAT_LB_PORT_65B_127B_L 0x4f8
+#define MPS_PORT_STAT_LB_PORT_65B_127B_H 0x4fc
+#define MPS_PORT_STAT_LB_PORT_128B_255B_L 0x500
+#define MPS_PORT_STAT_LB_PORT_128B_255B_H 0x504
+#define MPS_PORT_STAT_LB_PORT_256B_511B_L 0x508
+#define MPS_PORT_STAT_LB_PORT_256B_511B_H 0x50c
+#define MPS_PORT_STAT_LB_PORT_512B_1023B_L 0x510
+#define MPS_PORT_STAT_LB_PORT_512B_1023B_H 0x514
+#define MPS_PORT_STAT_LB_PORT_1024B_1518B_L 0x518
+#define MPS_PORT_STAT_LB_PORT_1024B_1518B_H 0x51c
+#define MPS_PORT_STAT_LB_PORT_1519B_MAX_L 0x520
+#define MPS_PORT_STAT_LB_PORT_1519B_MAX_H 0x524
+#define MPS_PORT_STAT_LB_PORT_DROP_FRAMES 0x528
+#define MPS_PORT_STAT_LB_PORT_DROP_FRAMES_L 0x528
+#define MPS_PORT_STAT_RX_PORT_BYTES_L 0x540
+#define MPS_PORT_STAT_RX_PORT_BYTES_H 0x544
+#define MPS_PORT_STAT_RX_PORT_FRAMES_L 0x548
+#define MPS_PORT_STAT_RX_PORT_FRAMES_H 0x54c
+#define MPS_PORT_STAT_RX_PORT_BCAST_L 0x550
+#define MPS_PORT_STAT_RX_PORT_BCAST_H 0x554
+#define MPS_PORT_STAT_RX_PORT_MCAST_L 0x558
+#define MPS_PORT_STAT_RX_PORT_MCAST_H 0x55c
+#define MPS_PORT_STAT_RX_PORT_UCAST_L 0x560
+#define MPS_PORT_STAT_RX_PORT_UCAST_H 0x564
+#define MPS_PORT_STAT_RX_PORT_MTU_ERROR_L 0x568
+#define MPS_PORT_STAT_RX_PORT_MTU_ERROR_H 0x56c
+#define MPS_PORT_STAT_RX_PORT_MTU_CRC_ERROR_L 0x570
+#define MPS_PORT_STAT_RX_PORT_MTU_CRC_ERROR_H 0x574
+#define MPS_PORT_STAT_RX_PORT_CRC_ERROR_L 0x578
+#define MPS_PORT_STAT_RX_PORT_CRC_ERROR_H 0x57c
+#define MPS_PORT_STAT_RX_PORT_LEN_ERROR_L 0x580
+#define MPS_PORT_STAT_RX_PORT_LEN_ERROR_H 0x584
+#define MPS_PORT_STAT_RX_PORT_SYM_ERROR_L 0x588
+#define MPS_PORT_STAT_RX_PORT_SYM_ERROR_H 0x58c
+#define MPS_PORT_STAT_RX_PORT_64B_L 0x590
+#define MPS_PORT_STAT_RX_PORT_64B_H 0x594
+#define MPS_PORT_STAT_RX_PORT_65B_127B_L 0x598
+#define MPS_PORT_STAT_RX_PORT_65B_127B_H 0x59c
+#define MPS_PORT_STAT_RX_PORT_128B_255B_L 0x5a0
+#define MPS_PORT_STAT_RX_PORT_128B_255B_H 0x5a4
+#define MPS_PORT_STAT_RX_PORT_256B_511B_L 0x5a8
+#define MPS_PORT_STAT_RX_PORT_256B_511B_H 0x5ac
+#define MPS_PORT_STAT_RX_PORT_512B_1023B_L 0x5b0
+#define MPS_PORT_STAT_RX_PORT_512B_1023B_H 0x5b4
+#define MPS_PORT_STAT_RX_PORT_1024B_1518B_L 0x5b8
+#define MPS_PORT_STAT_RX_PORT_1024B_1518B_H 0x5bc
+#define MPS_PORT_STAT_RX_PORT_1519B_MAX_L 0x5c0
+#define MPS_PORT_STAT_RX_PORT_1519B_MAX_H 0x5c4
+#define MPS_PORT_STAT_RX_PORT_PAUSE_L 0x5c8
+#define MPS_PORT_STAT_RX_PORT_PAUSE_H 0x5cc
+#define MPS_PORT_STAT_RX_PORT_PPP0_L 0x5d0
+#define MPS_PORT_STAT_RX_PORT_PPP0_H 0x5d4
+#define MPS_PORT_STAT_RX_PORT_PPP1_L 0x5d8
+#define MPS_PORT_STAT_RX_PORT_PPP1_H 0x5dc
+#define MPS_PORT_STAT_RX_PORT_PPP2_L 0x5e0
+#define MPS_PORT_STAT_RX_PORT_PPP2_H 0x5e4
+#define MPS_PORT_STAT_RX_PORT_PPP3_L 0x5e8
+#define MPS_PORT_STAT_RX_PORT_PPP3_H 0x5ec
+#define MPS_PORT_STAT_RX_PORT_PPP4_L 0x5f0
+#define MPS_PORT_STAT_RX_PORT_PPP4_H 0x5f4
+#define MPS_PORT_STAT_RX_PORT_PPP5_L 0x5f8
+#define MPS_PORT_STAT_RX_PORT_PPP5_H 0x5fc
+#define MPS_PORT_STAT_RX_PORT_PPP6_L 0x600
+#define MPS_PORT_STAT_RX_PORT_PPP6_H 0x604
+#define MPS_PORT_STAT_RX_PORT_PPP7_L 0x608
+#define MPS_PORT_STAT_RX_PORT_PPP7_H 0x60c
+#define MPS_PORT_STAT_RX_PORT_LESS_64B_L 0x610
+#define MPS_PORT_STAT_RX_PORT_LESS_64B_H 0x614
+#define MAC_PORT_MAGIC_MACID_LO 0x824
+#define MAC_PORT_MAGIC_MACID_HI 0x828
+
+#define MAC_PORT_EPIO_DATA0_A 0x8c0
+#define MAC_PORT_EPIO_DATA1_A 0x8c4
+#define MAC_PORT_EPIO_DATA2_A 0x8c8
+#define MAC_PORT_EPIO_DATA3_A 0x8cc
+#define MAC_PORT_EPIO_OP_A 0x8d0
+
+#define MAC_PORT_CFG2_A 0x818
+
+#define MPS_CMN_CTL_A 0x9000
+
+#define NUMPORTS_S 0
+#define NUMPORTS_M 0x3U
+#define NUMPORTS_G(x) (((x) >> NUMPORTS_S) & NUMPORTS_M)
+
+#define MPS_INT_CAUSE_A 0x9008
+#define MPS_TX_INT_CAUSE_A 0x9408
+
+#define FRMERR_S 15
+#define FRMERR_V(x) ((x) << FRMERR_S)
+#define FRMERR_F FRMERR_V(1U)
+
+#define SECNTERR_S 14
+#define SECNTERR_V(x) ((x) << SECNTERR_S)
+#define SECNTERR_F SECNTERR_V(1U)
+
+#define BUBBLE_S 13
+#define BUBBLE_V(x) ((x) << BUBBLE_S)
+#define BUBBLE_F BUBBLE_V(1U)
+
+#define TXDESCFIFO_S 9
+#define TXDESCFIFO_M 0xfU
+#define TXDESCFIFO_V(x) ((x) << TXDESCFIFO_S)
+
+#define TXDATAFIFO_S 5
+#define TXDATAFIFO_M 0xfU
+#define TXDATAFIFO_V(x) ((x) << TXDATAFIFO_S)
+
+#define NCSIFIFO_S 4
+#define NCSIFIFO_V(x) ((x) << NCSIFIFO_S)
+#define NCSIFIFO_F NCSIFIFO_V(1U)
+
+#define TPFIFO_S 0
+#define TPFIFO_M 0xfU
+#define TPFIFO_V(x) ((x) << TPFIFO_S)
+
+#define MPS_STAT_PERR_INT_CAUSE_SRAM_A 0x9614
+#define MPS_STAT_PERR_INT_CAUSE_TX_FIFO_A 0x9620
+#define MPS_STAT_PERR_INT_CAUSE_RX_FIFO_A 0x962c
+
+#define MPS_STAT_RX_BG_0_MAC_DROP_FRAME_L 0x9640
+#define MPS_STAT_RX_BG_0_MAC_DROP_FRAME_H 0x9644
+#define MPS_STAT_RX_BG_1_MAC_DROP_FRAME_L 0x9648
+#define MPS_STAT_RX_BG_1_MAC_DROP_FRAME_H 0x964c
+#define MPS_STAT_RX_BG_2_MAC_DROP_FRAME_L 0x9650
+#define MPS_STAT_RX_BG_2_MAC_DROP_FRAME_H 0x9654
+#define MPS_STAT_RX_BG_3_MAC_DROP_FRAME_L 0x9658
+#define MPS_STAT_RX_BG_3_MAC_DROP_FRAME_H 0x965c
+#define MPS_STAT_RX_BG_0_LB_DROP_FRAME_L 0x9660
+#define MPS_STAT_RX_BG_0_LB_DROP_FRAME_H 0x9664
+#define MPS_STAT_RX_BG_1_LB_DROP_FRAME_L 0x9668
+#define MPS_STAT_RX_BG_1_LB_DROP_FRAME_H 0x966c
+#define MPS_STAT_RX_BG_2_LB_DROP_FRAME_L 0x9670
+#define MPS_STAT_RX_BG_2_LB_DROP_FRAME_H 0x9674
+#define MPS_STAT_RX_BG_3_LB_DROP_FRAME_L 0x9678
+#define MPS_STAT_RX_BG_3_LB_DROP_FRAME_H 0x967c
+#define MPS_STAT_RX_BG_0_MAC_TRUNC_FRAME_L 0x9680
+#define MPS_STAT_RX_BG_0_MAC_TRUNC_FRAME_H 0x9684
+#define MPS_STAT_RX_BG_1_MAC_TRUNC_FRAME_L 0x9688
+#define MPS_STAT_RX_BG_1_MAC_TRUNC_FRAME_H 0x968c
+#define MPS_STAT_RX_BG_2_MAC_TRUNC_FRAME_L 0x9690
+#define MPS_STAT_RX_BG_2_MAC_TRUNC_FRAME_H 0x9694
+#define MPS_STAT_RX_BG_3_MAC_TRUNC_FRAME_L 0x9698
+#define MPS_STAT_RX_BG_3_MAC_TRUNC_FRAME_H 0x969c
+#define MPS_STAT_RX_BG_0_LB_TRUNC_FRAME_L 0x96a0
+#define MPS_STAT_RX_BG_0_LB_TRUNC_FRAME_H 0x96a4
+#define MPS_STAT_RX_BG_1_LB_TRUNC_FRAME_L 0x96a8
+#define MPS_STAT_RX_BG_1_LB_TRUNC_FRAME_H 0x96ac
+#define MPS_STAT_RX_BG_2_LB_TRUNC_FRAME_L 0x96b0
+#define MPS_STAT_RX_BG_2_LB_TRUNC_FRAME_H 0x96b4
+#define MPS_STAT_RX_BG_3_LB_TRUNC_FRAME_L 0x96b8
+#define MPS_STAT_RX_BG_3_LB_TRUNC_FRAME_H 0x96bc
+
+#define MPS_TRC_CFG_A 0x9800
+
+#define TRCFIFOEMPTY_S 4
+#define TRCFIFOEMPTY_V(x) ((x) << TRCFIFOEMPTY_S)
+#define TRCFIFOEMPTY_F TRCFIFOEMPTY_V(1U)
+
+#define TRCIGNOREDROPINPUT_S 3
+#define TRCIGNOREDROPINPUT_V(x) ((x) << TRCIGNOREDROPINPUT_S)
+#define TRCIGNOREDROPINPUT_F TRCIGNOREDROPINPUT_V(1U)
+
+#define TRCKEEPDUPLICATES_S 2
+#define TRCKEEPDUPLICATES_V(x) ((x) << TRCKEEPDUPLICATES_S)
+#define TRCKEEPDUPLICATES_F TRCKEEPDUPLICATES_V(1U)
+
+#define TRCEN_S 1
+#define TRCEN_V(x) ((x) << TRCEN_S)
+#define TRCEN_F TRCEN_V(1U)
+
+#define TRCMULTIFILTER_S 0
+#define TRCMULTIFILTER_V(x) ((x) << TRCMULTIFILTER_S)
+#define TRCMULTIFILTER_F TRCMULTIFILTER_V(1U)
+
+#define MPS_TRC_RSS_CONTROL_A 0x9808
+#define MPS_TRC_FILTER1_RSS_CONTROL_A 0x9ff4
+#define MPS_TRC_FILTER2_RSS_CONTROL_A 0x9ffc
+#define MPS_TRC_FILTER3_RSS_CONTROL_A 0xa004
+#define MPS_T5_TRC_RSS_CONTROL_A 0xa00c
+
+#define RSSCONTROL_S 16
+#define RSSCONTROL_V(x) ((x) << RSSCONTROL_S)
+
+#define QUEUENUMBER_S 0
+#define QUEUENUMBER_V(x) ((x) << QUEUENUMBER_S)
+
+#define TFINVERTMATCH_S 24
+#define TFINVERTMATCH_V(x) ((x) << TFINVERTMATCH_S)
+#define TFINVERTMATCH_F TFINVERTMATCH_V(1U)
+
+#define TFEN_S 22
+#define TFEN_V(x) ((x) << TFEN_S)
+#define TFEN_F TFEN_V(1U)
+
+#define TFPORT_S 18
+#define TFPORT_M 0xfU
+#define TFPORT_V(x) ((x) << TFPORT_S)
+#define TFPORT_G(x) (((x) >> TFPORT_S) & TFPORT_M)
+
+#define TFLENGTH_S 8
+#define TFLENGTH_M 0x1fU
+#define TFLENGTH_V(x) ((x) << TFLENGTH_S)
+#define TFLENGTH_G(x) (((x) >> TFLENGTH_S) & TFLENGTH_M)
+
+#define TFOFFSET_S 0
+#define TFOFFSET_M 0x1fU
+#define TFOFFSET_V(x) ((x) << TFOFFSET_S)
+#define TFOFFSET_G(x) (((x) >> TFOFFSET_S) & TFOFFSET_M)
+
+#define T5_TFINVERTMATCH_S 25
+#define T5_TFINVERTMATCH_V(x) ((x) << T5_TFINVERTMATCH_S)
+#define T5_TFINVERTMATCH_F T5_TFINVERTMATCH_V(1U)
+
+#define T5_TFEN_S 23
+#define T5_TFEN_V(x) ((x) << T5_TFEN_S)
+#define T5_TFEN_F T5_TFEN_V(1U)
+
+#define T5_TFPORT_S 18
+#define T5_TFPORT_M 0x1fU
+#define T5_TFPORT_V(x) ((x) << T5_TFPORT_S)
+#define T5_TFPORT_G(x) (((x) >> T5_TFPORT_S) & T5_TFPORT_M)
+
+#define MPS_TRC_FILTER_MATCH_CTL_A_A 0x9810
+#define MPS_TRC_FILTER_MATCH_CTL_B_A 0x9820
+
+#define TFMINPKTSIZE_S 16
+#define TFMINPKTSIZE_M 0x1ffU
+#define TFMINPKTSIZE_V(x) ((x) << TFMINPKTSIZE_S)
+#define TFMINPKTSIZE_G(x) (((x) >> TFMINPKTSIZE_S) & TFMINPKTSIZE_M)
+
+#define TFCAPTUREMAX_S 0
+#define TFCAPTUREMAX_M 0x3fffU
+#define TFCAPTUREMAX_V(x) ((x) << TFCAPTUREMAX_S)
+#define TFCAPTUREMAX_G(x) (((x) >> TFCAPTUREMAX_S) & TFCAPTUREMAX_M)
+
+#define MPS_TRC_FILTER0_MATCH_A 0x9c00
+#define MPS_TRC_FILTER0_DONT_CARE_A 0x9c80
+#define MPS_TRC_FILTER1_MATCH_A 0x9d00
+
+#define TP_RSS_CONFIG_A 0x7df0
+
+#define TNL4TUPENIPV6_S 31
+#define TNL4TUPENIPV6_V(x) ((x) << TNL4TUPENIPV6_S)
+#define TNL4TUPENIPV6_F TNL4TUPENIPV6_V(1U)
+
+#define TNL2TUPENIPV6_S 30
+#define TNL2TUPENIPV6_V(x) ((x) << TNL2TUPENIPV6_S)
+#define TNL2TUPENIPV6_F TNL2TUPENIPV6_V(1U)
+
+#define TNL4TUPENIPV4_S 29
+#define TNL4TUPENIPV4_V(x) ((x) << TNL4TUPENIPV4_S)
+#define TNL4TUPENIPV4_F TNL4TUPENIPV4_V(1U)
+
+#define TNL2TUPENIPV4_S 28
+#define TNL2TUPENIPV4_V(x) ((x) << TNL2TUPENIPV4_S)
+#define TNL2TUPENIPV4_F TNL2TUPENIPV4_V(1U)
+
+#define TNLTCPSEL_S 27
+#define TNLTCPSEL_V(x) ((x) << TNLTCPSEL_S)
+#define TNLTCPSEL_F TNLTCPSEL_V(1U)
+
+#define TNLIP6SEL_S 26
+#define TNLIP6SEL_V(x) ((x) << TNLIP6SEL_S)
+#define TNLIP6SEL_F TNLIP6SEL_V(1U)
+
+#define TNLVRTSEL_S 25
+#define TNLVRTSEL_V(x) ((x) << TNLVRTSEL_S)
+#define TNLVRTSEL_F TNLVRTSEL_V(1U)
+
+#define TNLMAPEN_S 24
+#define TNLMAPEN_V(x) ((x) << TNLMAPEN_S)
+#define TNLMAPEN_F TNLMAPEN_V(1U)
+
+#define OFDHASHSAVE_S 19
+#define OFDHASHSAVE_V(x) ((x) << OFDHASHSAVE_S)
+#define OFDHASHSAVE_F OFDHASHSAVE_V(1U)
+
+#define OFDVRTSEL_S 18
+#define OFDVRTSEL_V(x) ((x) << OFDVRTSEL_S)
+#define OFDVRTSEL_F OFDVRTSEL_V(1U)
+
+#define OFDMAPEN_S 17
+#define OFDMAPEN_V(x) ((x) << OFDMAPEN_S)
+#define OFDMAPEN_F OFDMAPEN_V(1U)
+
+#define OFDLKPEN_S 16
+#define OFDLKPEN_V(x) ((x) << OFDLKPEN_S)
+#define OFDLKPEN_F OFDLKPEN_V(1U)
+
+#define SYN4TUPENIPV6_S 15
+#define SYN4TUPENIPV6_V(x) ((x) << SYN4TUPENIPV6_S)
+#define SYN4TUPENIPV6_F SYN4TUPENIPV6_V(1U)
+
+#define SYN2TUPENIPV6_S 14
+#define SYN2TUPENIPV6_V(x) ((x) << SYN2TUPENIPV6_S)
+#define SYN2TUPENIPV6_F SYN2TUPENIPV6_V(1U)
+
+#define SYN4TUPENIPV4_S 13
+#define SYN4TUPENIPV4_V(x) ((x) << SYN4TUPENIPV4_S)
+#define SYN4TUPENIPV4_F SYN4TUPENIPV4_V(1U)
+
+#define SYN2TUPENIPV4_S 12
+#define SYN2TUPENIPV4_V(x) ((x) << SYN2TUPENIPV4_S)
+#define SYN2TUPENIPV4_F SYN2TUPENIPV4_V(1U)
+
+#define SYNIP6SEL_S 11
+#define SYNIP6SEL_V(x) ((x) << SYNIP6SEL_S)
+#define SYNIP6SEL_F SYNIP6SEL_V(1U)
+
+#define SYNVRTSEL_S 10
+#define SYNVRTSEL_V(x) ((x) << SYNVRTSEL_S)
+#define SYNVRTSEL_F SYNVRTSEL_V(1U)
+
+#define SYNMAPEN_S 9
+#define SYNMAPEN_V(x) ((x) << SYNMAPEN_S)
+#define SYNMAPEN_F SYNMAPEN_V(1U)
+
+#define SYNLKPEN_S 8
+#define SYNLKPEN_V(x) ((x) << SYNLKPEN_S)
+#define SYNLKPEN_F SYNLKPEN_V(1U)
+
+#define CHANNELENABLE_S 7
+#define CHANNELENABLE_V(x) ((x) << CHANNELENABLE_S)
+#define CHANNELENABLE_F CHANNELENABLE_V(1U)
+
+#define PORTENABLE_S 6
+#define PORTENABLE_V(x) ((x) << PORTENABLE_S)
+#define PORTENABLE_F PORTENABLE_V(1U)
+
+#define TNLALLLOOKUP_S 5
+#define TNLALLLOOKUP_V(x) ((x) << TNLALLLOOKUP_S)
+#define TNLALLLOOKUP_F TNLALLLOOKUP_V(1U)
+
+#define VIRTENABLE_S 4
+#define VIRTENABLE_V(x) ((x) << VIRTENABLE_S)
+#define VIRTENABLE_F VIRTENABLE_V(1U)
+
+#define CONGESTIONENABLE_S 3
+#define CONGESTIONENABLE_V(x) ((x) << CONGESTIONENABLE_S)
+#define CONGESTIONENABLE_F CONGESTIONENABLE_V(1U)
+
+#define HASHTOEPLITZ_S 2
+#define HASHTOEPLITZ_V(x) ((x) << HASHTOEPLITZ_S)
+#define HASHTOEPLITZ_F HASHTOEPLITZ_V(1U)
+
+#define UDPENABLE_S 1
+#define UDPENABLE_V(x) ((x) << UDPENABLE_S)
+#define UDPENABLE_F UDPENABLE_V(1U)
+
+#define DISABLE_S 0
+#define DISABLE_V(x) ((x) << DISABLE_S)
+#define DISABLE_F DISABLE_V(1U)
+
+#define TP_RSS_CONFIG_TNL_A 0x7df4
+
+#define MASKSIZE_S 28
+#define MASKSIZE_M 0xfU
+#define MASKSIZE_V(x) ((x) << MASKSIZE_S)
+#define MASKSIZE_G(x) (((x) >> MASKSIZE_S) & MASKSIZE_M)
+
+#define MASKFILTER_S 16
+#define MASKFILTER_M 0x7ffU
+#define MASKFILTER_V(x) ((x) << MASKFILTER_S)
+#define MASKFILTER_G(x) (((x) >> MASKFILTER_S) & MASKFILTER_M)
+
+#define USEWIRECH_S 0
+#define USEWIRECH_V(x) ((x) << USEWIRECH_S)
+#define USEWIRECH_F USEWIRECH_V(1U)
+
+#define HASHALL_S 2
+#define HASHALL_V(x) ((x) << HASHALL_S)
+#define HASHALL_F HASHALL_V(1U)
+
+#define HASHETH_S 1
+#define HASHETH_V(x) ((x) << HASHETH_S)
+#define HASHETH_F HASHETH_V(1U)
+
+#define TP_RSS_CONFIG_OFD_A 0x7df8
+
+#define RRCPLMAPEN_S 20
+#define RRCPLMAPEN_V(x) ((x) << RRCPLMAPEN_S)
+#define RRCPLMAPEN_F RRCPLMAPEN_V(1U)
+
+#define RRCPLQUEWIDTH_S 16
+#define RRCPLQUEWIDTH_M 0xfU
+#define RRCPLQUEWIDTH_V(x) ((x) << RRCPLQUEWIDTH_S)
+#define RRCPLQUEWIDTH_G(x) (((x) >> RRCPLQUEWIDTH_S) & RRCPLQUEWIDTH_M)
+
+#define TP_RSS_CONFIG_SYN_A 0x7dfc
+#define TP_RSS_CONFIG_VRT_A 0x7e00
+
+#define VFRDRG_S 25
+#define VFRDRG_V(x) ((x) << VFRDRG_S)
+#define VFRDRG_F VFRDRG_V(1U)
+
+#define VFRDEN_S 24
+#define VFRDEN_V(x) ((x) << VFRDEN_S)
+#define VFRDEN_F VFRDEN_V(1U)
+
+#define VFPERREN_S 23
+#define VFPERREN_V(x) ((x) << VFPERREN_S)
+#define VFPERREN_F VFPERREN_V(1U)
+
+#define KEYPERREN_S 22
+#define KEYPERREN_V(x) ((x) << KEYPERREN_S)
+#define KEYPERREN_F KEYPERREN_V(1U)
+
+#define DISABLEVLAN_S 21
+#define DISABLEVLAN_V(x) ((x) << DISABLEVLAN_S)
+#define DISABLEVLAN_F DISABLEVLAN_V(1U)
+
+#define ENABLEUP0_S 20
+#define ENABLEUP0_V(x) ((x) << ENABLEUP0_S)
+#define ENABLEUP0_F ENABLEUP0_V(1U)
+
+#define HASHDELAY_S 16
+#define HASHDELAY_M 0xfU
+#define HASHDELAY_V(x) ((x) << HASHDELAY_S)
+#define HASHDELAY_G(x) (((x) >> HASHDELAY_S) & HASHDELAY_M)
+
+#define VFWRADDR_S 8
+#define VFWRADDR_M 0x7fU
+#define VFWRADDR_V(x) ((x) << VFWRADDR_S)
+#define VFWRADDR_G(x) (((x) >> VFWRADDR_S) & VFWRADDR_M)
+
+#define KEYMODE_S 6
+#define KEYMODE_M 0x3U
+#define KEYMODE_V(x) ((x) << KEYMODE_S)
+#define KEYMODE_G(x) (((x) >> KEYMODE_S) & KEYMODE_M)
+
+#define VFWREN_S 5
+#define VFWREN_V(x) ((x) << VFWREN_S)
+#define VFWREN_F VFWREN_V(1U)
+
+#define KEYWREN_S 4
+#define KEYWREN_V(x) ((x) << KEYWREN_S)
+#define KEYWREN_F KEYWREN_V(1U)
+
+#define KEYWRADDR_S 0
+#define KEYWRADDR_M 0xfU
+#define KEYWRADDR_V(x) ((x) << KEYWRADDR_S)
+#define KEYWRADDR_G(x) (((x) >> KEYWRADDR_S) & KEYWRADDR_M)
+
+#define KEYWRADDRX_S 30
+#define KEYWRADDRX_M 0x3U
+#define KEYWRADDRX_V(x) ((x) << KEYWRADDRX_S)
+#define KEYWRADDRX_G(x) (((x) >> KEYWRADDRX_S) & KEYWRADDRX_M)
+
+#define KEYEXTEND_S 26
+#define KEYEXTEND_V(x) ((x) << KEYEXTEND_S)
+#define KEYEXTEND_F KEYEXTEND_V(1U)
+
+#define LKPIDXSIZE_S 24
+#define LKPIDXSIZE_M 0x3U
+#define LKPIDXSIZE_V(x) ((x) << LKPIDXSIZE_S)
+#define LKPIDXSIZE_G(x) (((x) >> LKPIDXSIZE_S) & LKPIDXSIZE_M)
+
+#define TP_RSS_VFL_CONFIG_A 0x3a
+#define TP_RSS_VFH_CONFIG_A 0x3b
+
+#define ENABLEUDPHASH_S 31
+#define ENABLEUDPHASH_V(x) ((x) << ENABLEUDPHASH_S)
+#define ENABLEUDPHASH_F ENABLEUDPHASH_V(1U)
+
+#define VFUPEN_S 30
+#define VFUPEN_V(x) ((x) << VFUPEN_S)
+#define VFUPEN_F VFUPEN_V(1U)
+
+#define VFVLNEX_S 28
+#define VFVLNEX_V(x) ((x) << VFVLNEX_S)
+#define VFVLNEX_F VFVLNEX_V(1U)
+
+#define VFPRTEN_S 27
+#define VFPRTEN_V(x) ((x) << VFPRTEN_S)
+#define VFPRTEN_F VFPRTEN_V(1U)
+
+#define VFCHNEN_S 26
+#define VFCHNEN_V(x) ((x) << VFCHNEN_S)
+#define VFCHNEN_F VFCHNEN_V(1U)
+
+#define DEFAULTQUEUE_S 16
+#define DEFAULTQUEUE_M 0x3ffU
+#define DEFAULTQUEUE_G(x) (((x) >> DEFAULTQUEUE_S) & DEFAULTQUEUE_M)
+
+#define VFIP6TWOTUPEN_S 6
+#define VFIP6TWOTUPEN_V(x) ((x) << VFIP6TWOTUPEN_S)
+#define VFIP6TWOTUPEN_F VFIP6TWOTUPEN_V(1U)
+
+#define VFIP4FOURTUPEN_S 5
+#define VFIP4FOURTUPEN_V(x) ((x) << VFIP4FOURTUPEN_S)
+#define VFIP4FOURTUPEN_F VFIP4FOURTUPEN_V(1U)
+
+#define VFIP4TWOTUPEN_S 4
+#define VFIP4TWOTUPEN_V(x) ((x) << VFIP4TWOTUPEN_S)
+#define VFIP4TWOTUPEN_F VFIP4TWOTUPEN_V(1U)
+
+#define KEYINDEX_S 0
+#define KEYINDEX_M 0xfU
+#define KEYINDEX_G(x) (((x) >> KEYINDEX_S) & KEYINDEX_M)
+
+#define MAPENABLE_S 31
+#define MAPENABLE_V(x) ((x) << MAPENABLE_S)
+#define MAPENABLE_F MAPENABLE_V(1U)
+
+#define CHNENABLE_S 30
+#define CHNENABLE_V(x) ((x) << CHNENABLE_S)
+#define CHNENABLE_F CHNENABLE_V(1U)
+
+#define PRTENABLE_S 29
+#define PRTENABLE_V(x) ((x) << PRTENABLE_S)
+#define PRTENABLE_F PRTENABLE_V(1U)
+
+#define UDPFOURTUPEN_S 28
+#define UDPFOURTUPEN_V(x) ((x) << UDPFOURTUPEN_S)
+#define UDPFOURTUPEN_F UDPFOURTUPEN_V(1U)
+
+#define IP6FOURTUPEN_S 27
+#define IP6FOURTUPEN_V(x) ((x) << IP6FOURTUPEN_S)
+#define IP6FOURTUPEN_F IP6FOURTUPEN_V(1U)
+
+#define IP6TWOTUPEN_S 26
+#define IP6TWOTUPEN_V(x) ((x) << IP6TWOTUPEN_S)
+#define IP6TWOTUPEN_F IP6TWOTUPEN_V(1U)
+
+#define IP4FOURTUPEN_S 25
+#define IP4FOURTUPEN_V(x) ((x) << IP4FOURTUPEN_S)
+#define IP4FOURTUPEN_F IP4FOURTUPEN_V(1U)
+
+#define IP4TWOTUPEN_S 24
+#define IP4TWOTUPEN_V(x) ((x) << IP4TWOTUPEN_S)
+#define IP4TWOTUPEN_F IP4TWOTUPEN_V(1U)
+
+#define IVFWIDTH_S 20
+#define IVFWIDTH_M 0xfU
+#define IVFWIDTH_V(x) ((x) << IVFWIDTH_S)
+#define IVFWIDTH_G(x) (((x) >> IVFWIDTH_S) & IVFWIDTH_M)
+
+#define CH1DEFAULTQUEUE_S 10
+#define CH1DEFAULTQUEUE_M 0x3ffU
+#define CH1DEFAULTQUEUE_V(x) ((x) << CH1DEFAULTQUEUE_S)
+#define CH1DEFAULTQUEUE_G(x) (((x) >> CH1DEFAULTQUEUE_S) & CH1DEFAULTQUEUE_M)
+
+#define CH0DEFAULTQUEUE_S 0
+#define CH0DEFAULTQUEUE_M 0x3ffU
+#define CH0DEFAULTQUEUE_V(x) ((x) << CH0DEFAULTQUEUE_S)
+#define CH0DEFAULTQUEUE_G(x) (((x) >> CH0DEFAULTQUEUE_S) & CH0DEFAULTQUEUE_M)
+
+#define VFLKPIDX_S 8
+#define VFLKPIDX_M 0xffU
+#define VFLKPIDX_G(x) (((x) >> VFLKPIDX_S) & VFLKPIDX_M)
+
+#define T6_VFWRADDR_S 8
+#define T6_VFWRADDR_M 0xffU
+#define T6_VFWRADDR_V(x) ((x) << T6_VFWRADDR_S)
+#define T6_VFWRADDR_G(x) (((x) >> T6_VFWRADDR_S) & T6_VFWRADDR_M)
+
+#define TP_RSS_CONFIG_CNG_A 0x7e04
+#define TP_RSS_SECRET_KEY0_A 0x40
+#define TP_RSS_PF0_CONFIG_A 0x30
+#define TP_RSS_PF_MAP_A 0x38
+#define TP_RSS_PF_MSK_A 0x39
+
+#define PF1LKPIDX_S 3
+
+#define PF0LKPIDX_M 0x7U
+
+#define PF1MSKSIZE_S 4
+#define PF1MSKSIZE_M 0xfU
+
+#define CHNCOUNT3_S 31
+#define CHNCOUNT3_V(x) ((x) << CHNCOUNT3_S)
+#define CHNCOUNT3_F CHNCOUNT3_V(1U)
+
+#define CHNCOUNT2_S 30
+#define CHNCOUNT2_V(x) ((x) << CHNCOUNT2_S)
+#define CHNCOUNT2_F CHNCOUNT2_V(1U)
+
+#define CHNCOUNT1_S 29
+#define CHNCOUNT1_V(x) ((x) << CHNCOUNT1_S)
+#define CHNCOUNT1_F CHNCOUNT1_V(1U)
+
+#define CHNCOUNT0_S 28
+#define CHNCOUNT0_V(x) ((x) << CHNCOUNT0_S)
+#define CHNCOUNT0_F CHNCOUNT0_V(1U)
+
+#define CHNUNDFLOW3_S 27
+#define CHNUNDFLOW3_V(x) ((x) << CHNUNDFLOW3_S)
+#define CHNUNDFLOW3_F CHNUNDFLOW3_V(1U)
+
+#define CHNUNDFLOW2_S 26
+#define CHNUNDFLOW2_V(x) ((x) << CHNUNDFLOW2_S)
+#define CHNUNDFLOW2_F CHNUNDFLOW2_V(1U)
+
+#define CHNUNDFLOW1_S 25
+#define CHNUNDFLOW1_V(x) ((x) << CHNUNDFLOW1_S)
+#define CHNUNDFLOW1_F CHNUNDFLOW1_V(1U)
+
+#define CHNUNDFLOW0_S 24
+#define CHNUNDFLOW0_V(x) ((x) << CHNUNDFLOW0_S)
+#define CHNUNDFLOW0_F CHNUNDFLOW0_V(1U)
+
+#define RSTCHN3_S 19
+#define RSTCHN3_V(x) ((x) << RSTCHN3_S)
+#define RSTCHN3_F RSTCHN3_V(1U)
+
+#define RSTCHN2_S 18
+#define RSTCHN2_V(x) ((x) << RSTCHN2_S)
+#define RSTCHN2_F RSTCHN2_V(1U)
+
+#define RSTCHN1_S 17
+#define RSTCHN1_V(x) ((x) << RSTCHN1_S)
+#define RSTCHN1_F RSTCHN1_V(1U)
+
+#define RSTCHN0_S 16
+#define RSTCHN0_V(x) ((x) << RSTCHN0_S)
+#define RSTCHN0_F RSTCHN0_V(1U)
+
+#define UPDVLD_S 15
+#define UPDVLD_V(x) ((x) << UPDVLD_S)
+#define UPDVLD_F UPDVLD_V(1U)
+
+#define XOFF_S 14
+#define XOFF_V(x) ((x) << XOFF_S)
+#define XOFF_F XOFF_V(1U)
+
+#define UPDCHN3_S 13
+#define UPDCHN3_V(x) ((x) << UPDCHN3_S)
+#define UPDCHN3_F UPDCHN3_V(1U)
+
+#define UPDCHN2_S 12
+#define UPDCHN2_V(x) ((x) << UPDCHN2_S)
+#define UPDCHN2_F UPDCHN2_V(1U)
+
+#define UPDCHN1_S 11
+#define UPDCHN1_V(x) ((x) << UPDCHN1_S)
+#define UPDCHN1_F UPDCHN1_V(1U)
+
+#define UPDCHN0_S 10
+#define UPDCHN0_V(x) ((x) << UPDCHN0_S)
+#define UPDCHN0_F UPDCHN0_V(1U)
+
+#define QUEUE_S 0
+#define QUEUE_M 0x3ffU
+#define QUEUE_V(x) ((x) << QUEUE_S)
+#define QUEUE_G(x) (((x) >> QUEUE_S) & QUEUE_M)
+
+#define MPS_TRC_INT_CAUSE_A 0x985c
+
+#define MISCPERR_S 8
+#define MISCPERR_V(x) ((x) << MISCPERR_S)
+#define MISCPERR_F MISCPERR_V(1U)
+
+#define PKTFIFO_S 4
+#define PKTFIFO_M 0xfU
+#define PKTFIFO_V(x) ((x) << PKTFIFO_S)
+
+#define FILTMEM_S 0
+#define FILTMEM_M 0xfU
+#define FILTMEM_V(x) ((x) << FILTMEM_S)
+
+#define MPS_CLS_INT_CAUSE_A 0xd028
+
+#define HASHSRAM_S 2
+#define HASHSRAM_V(x) ((x) << HASHSRAM_S)
+#define HASHSRAM_F HASHSRAM_V(1U)
+
+#define MATCHTCAM_S 1
+#define MATCHTCAM_V(x) ((x) << MATCHTCAM_S)
+#define MATCHTCAM_F MATCHTCAM_V(1U)
+
+#define MATCHSRAM_S 0
+#define MATCHSRAM_V(x) ((x) << MATCHSRAM_S)
+#define MATCHSRAM_F MATCHSRAM_V(1U)
+
+#define MPS_RX_PG_RSV0_A 0x11010
+#define MPS_RX_PG_RSV4_A 0x11020
+#define MPS_RX_PERR_INT_CAUSE_A 0x11074
+#define MPS_RX_MAC_BG_PG_CNT0_A 0x11208
+#define MPS_RX_LPBK_BG_PG_CNT0_A 0x11218
+
+#define MPS_CLS_TCAM_Y_L_A 0xf000
+#define MPS_CLS_TCAM_DATA0_A 0xf000
+#define MPS_CLS_TCAM_DATA1_A 0xf004
+
+#define VIDL_S 16
+#define VIDL_M 0xffffU
+#define VIDL_G(x) (((x) >> VIDL_S) & VIDL_M)
+
+#define DATALKPTYPE_S 10
+#define DATALKPTYPE_M 0x3U
+#define DATALKPTYPE_G(x) (((x) >> DATALKPTYPE_S) & DATALKPTYPE_M)
+
+#define DATAPORTNUM_S 12
+#define DATAPORTNUM_M 0xfU
+#define DATAPORTNUM_G(x) (((x) >> DATAPORTNUM_S) & DATAPORTNUM_M)
+
+#define DATADIPHIT_S 8
+#define DATADIPHIT_V(x) ((x) << DATADIPHIT_S)
+#define DATADIPHIT_F DATADIPHIT_V(1U)
+
+#define DATAVIDH2_S 7
+#define DATAVIDH2_V(x) ((x) << DATAVIDH2_S)
+#define DATAVIDH2_F DATAVIDH2_V(1U)
+
+#define DATAVIDH1_S 0
+#define DATAVIDH1_M 0x7fU
+#define DATAVIDH1_G(x) (((x) >> DATAVIDH1_S) & DATAVIDH1_M)
+
+#define USED_S 16
+#define USED_M 0x7ffU
+#define USED_G(x) (((x) >> USED_S) & USED_M)
+
+#define ALLOC_S 0
+#define ALLOC_M 0x7ffU
+#define ALLOC_G(x) (((x) >> ALLOC_S) & ALLOC_M)
+
+#define T5_USED_S 16
+#define T5_USED_M 0xfffU
+#define T5_USED_G(x) (((x) >> T5_USED_S) & T5_USED_M)
+
+#define T5_ALLOC_S 0
+#define T5_ALLOC_M 0xfffU
+#define T5_ALLOC_G(x) (((x) >> T5_ALLOC_S) & T5_ALLOC_M)
+
+#define DMACH_S 0
+#define DMACH_M 0xffffU
+#define DMACH_G(x) (((x) >> DMACH_S) & DMACH_M)
+
+#define MPS_CLS_TCAM_X_L_A 0xf008
+#define MPS_CLS_TCAM_DATA2_CTL_A 0xf008
+
+#define CTLCMDTYPE_S 31
+#define CTLCMDTYPE_V(x) ((x) << CTLCMDTYPE_S)
+#define CTLCMDTYPE_F CTLCMDTYPE_V(1U)
+
+#define CTLTCAMSEL_S 25
+#define CTLTCAMSEL_V(x) ((x) << CTLTCAMSEL_S)
+
+#define CTLTCAMINDEX_S 17
+#define CTLTCAMINDEX_V(x) ((x) << CTLTCAMINDEX_S)
+
+#define CTLXYBITSEL_S 16
+#define CTLXYBITSEL_V(x) ((x) << CTLXYBITSEL_S)
+
+#define MPS_CLS_TCAM_Y_L(idx) (MPS_CLS_TCAM_Y_L_A + (idx) * 16)
+#define NUM_MPS_CLS_TCAM_Y_L_INSTANCES 512
+
+#define MPS_CLS_TCAM_X_L(idx) (MPS_CLS_TCAM_X_L_A + (idx) * 16)
+#define NUM_MPS_CLS_TCAM_X_L_INSTANCES 512
+
+#define MPS_CLS_SRAM_L_A 0xe000
+
+#define T6_MULTILISTEN0_S 26
+
+#define T6_SRAM_PRIO3_S 23
+#define T6_SRAM_PRIO3_M 0x7U
+#define T6_SRAM_PRIO3_G(x) (((x) >> T6_SRAM_PRIO3_S) & T6_SRAM_PRIO3_M)
+
+#define T6_SRAM_PRIO2_S 20
+#define T6_SRAM_PRIO2_M 0x7U
+#define T6_SRAM_PRIO2_G(x) (((x) >> T6_SRAM_PRIO2_S) & T6_SRAM_PRIO2_M)
+
+#define T6_SRAM_PRIO1_S 17
+#define T6_SRAM_PRIO1_M 0x7U
+#define T6_SRAM_PRIO1_G(x) (((x) >> T6_SRAM_PRIO1_S) & T6_SRAM_PRIO1_M)
+
+#define T6_SRAM_PRIO0_S 14
+#define T6_SRAM_PRIO0_M 0x7U
+#define T6_SRAM_PRIO0_G(x) (((x) >> T6_SRAM_PRIO0_S) & T6_SRAM_PRIO0_M)
+
+#define T6_SRAM_VLD_S 13
+#define T6_SRAM_VLD_V(x) ((x) << T6_SRAM_VLD_S)
+#define T6_SRAM_VLD_F T6_SRAM_VLD_V(1U)
+
+#define T6_REPLICATE_S 12
+#define T6_REPLICATE_V(x) ((x) << T6_REPLICATE_S)
+#define T6_REPLICATE_F T6_REPLICATE_V(1U)
+
+#define T6_PF_S 9
+#define T6_PF_M 0x7U
+#define T6_PF_G(x) (((x) >> T6_PF_S) & T6_PF_M)
+
+#define T6_VF_VALID_S 8
+#define T6_VF_VALID_V(x) ((x) << T6_VF_VALID_S)
+#define T6_VF_VALID_F T6_VF_VALID_V(1U)
+
+#define T6_VF_S 0
+#define T6_VF_M 0xffU
+#define T6_VF_G(x) (((x) >> T6_VF_S) & T6_VF_M)
+
+#define MPS_CLS_SRAM_H_A 0xe004
+
+#define MPS_CLS_SRAM_L(idx) (MPS_CLS_SRAM_L_A + (idx) * 8)
+#define NUM_MPS_CLS_SRAM_L_INSTANCES 336
+
+#define MPS_CLS_SRAM_H(idx) (MPS_CLS_SRAM_H_A + (idx) * 8)
+#define NUM_MPS_CLS_SRAM_H_INSTANCES 336
+
+#define MULTILISTEN0_S 25
+
+#define REPLICATE_S 11
+#define REPLICATE_V(x) ((x) << REPLICATE_S)
+#define REPLICATE_F REPLICATE_V(1U)
+
+#define PF_S 8
+#define PF_M 0x7U
+#define PF_G(x) (((x) >> PF_S) & PF_M)
+
+#define VF_VALID_S 7
+#define VF_VALID_V(x) ((x) << VF_VALID_S)
+#define VF_VALID_F VF_VALID_V(1U)
+
+#define VF_S 0
+#define VF_M 0x7fU
+#define VF_G(x) (((x) >> VF_S) & VF_M)
+
+#define SRAM_PRIO3_S 22
+#define SRAM_PRIO3_M 0x7U
+#define SRAM_PRIO3_G(x) (((x) >> SRAM_PRIO3_S) & SRAM_PRIO3_M)
+
+#define SRAM_PRIO2_S 19
+#define SRAM_PRIO2_M 0x7U
+#define SRAM_PRIO2_G(x) (((x) >> SRAM_PRIO2_S) & SRAM_PRIO2_M)
+
+#define SRAM_PRIO1_S 16
+#define SRAM_PRIO1_M 0x7U
+#define SRAM_PRIO1_G(x) (((x) >> SRAM_PRIO1_S) & SRAM_PRIO1_M)
+
+#define SRAM_PRIO0_S 13
+#define SRAM_PRIO0_M 0x7U
+#define SRAM_PRIO0_G(x) (((x) >> SRAM_PRIO0_S) & SRAM_PRIO0_M)
+
+#define SRAM_VLD_S 12
+#define SRAM_VLD_V(x) ((x) << SRAM_VLD_S)
+#define SRAM_VLD_F SRAM_VLD_V(1U)
+
+#define PORTMAP_S 0
+#define PORTMAP_M 0xfU
+#define PORTMAP_G(x) (((x) >> PORTMAP_S) & PORTMAP_M)
+
+#define CPL_INTR_CAUSE_A 0x19054
+
+#define CIM_OP_MAP_PERR_S 5
+#define CIM_OP_MAP_PERR_V(x) ((x) << CIM_OP_MAP_PERR_S)
+#define CIM_OP_MAP_PERR_F CIM_OP_MAP_PERR_V(1U)
+
+#define CIM_OVFL_ERROR_S 4
+#define CIM_OVFL_ERROR_V(x) ((x) << CIM_OVFL_ERROR_S)
+#define CIM_OVFL_ERROR_F CIM_OVFL_ERROR_V(1U)
+
+#define TP_FRAMING_ERROR_S 3
+#define TP_FRAMING_ERROR_V(x) ((x) << TP_FRAMING_ERROR_S)
+#define TP_FRAMING_ERROR_F TP_FRAMING_ERROR_V(1U)
+
+#define SGE_FRAMING_ERROR_S 2
+#define SGE_FRAMING_ERROR_V(x) ((x) << SGE_FRAMING_ERROR_S)
+#define SGE_FRAMING_ERROR_F SGE_FRAMING_ERROR_V(1U)
+
+#define CIM_FRAMING_ERROR_S 1
+#define CIM_FRAMING_ERROR_V(x) ((x) << CIM_FRAMING_ERROR_S)
+#define CIM_FRAMING_ERROR_F CIM_FRAMING_ERROR_V(1U)
+
+#define ZERO_SWITCH_ERROR_S 0
+#define ZERO_SWITCH_ERROR_V(x) ((x) << ZERO_SWITCH_ERROR_S)
+#define ZERO_SWITCH_ERROR_F ZERO_SWITCH_ERROR_V(1U)
+
+#define SMB_INT_CAUSE_A 0x19090
+
+#define MSTTXFIFOPARINT_S 21
+#define MSTTXFIFOPARINT_V(x) ((x) << MSTTXFIFOPARINT_S)
+#define MSTTXFIFOPARINT_F MSTTXFIFOPARINT_V(1U)
+
+#define MSTRXFIFOPARINT_S 20
+#define MSTRXFIFOPARINT_V(x) ((x) << MSTRXFIFOPARINT_S)
+#define MSTRXFIFOPARINT_F MSTRXFIFOPARINT_V(1U)
+
+#define SLVFIFOPARINT_S 19
+#define SLVFIFOPARINT_V(x) ((x) << SLVFIFOPARINT_S)
+#define SLVFIFOPARINT_F SLVFIFOPARINT_V(1U)
+
+#define ULP_RX_INT_CAUSE_A 0x19158
+#define ULP_RX_ISCSI_LLIMIT_A 0x1915c
+#define ULP_RX_ISCSI_ULIMIT_A 0x19160
+#define ULP_RX_ISCSI_TAGMASK_A 0x19164
+#define ULP_RX_ISCSI_PSZ_A 0x19168
+#define ULP_RX_TDDP_LLIMIT_A 0x1916c
+#define ULP_RX_TDDP_ULIMIT_A 0x19170
+#define ULP_RX_STAG_LLIMIT_A 0x1917c
+#define ULP_RX_STAG_ULIMIT_A 0x19180
+#define ULP_RX_RQ_LLIMIT_A 0x19184
+#define ULP_RX_RQ_ULIMIT_A 0x19188
+#define ULP_RX_PBL_LLIMIT_A 0x1918c
+#define ULP_RX_PBL_ULIMIT_A 0x19190
+#define ULP_RX_CTX_BASE_A 0x19194
+#define ULP_RX_RQUDP_LLIMIT_A 0x191a4
+#define ULP_RX_RQUDP_ULIMIT_A 0x191a8
+#define ULP_RX_LA_CTL_A 0x1923c
+#define ULP_RX_LA_RDPTR_A 0x19240
+#define ULP_RX_LA_RDDATA_A 0x19244
+#define ULP_RX_LA_WRPTR_A 0x19248
+
+#define HPZ3_S 24
+#define HPZ3_V(x) ((x) << HPZ3_S)
+
+#define HPZ2_S 16
+#define HPZ2_V(x) ((x) << HPZ2_S)
+
+#define HPZ1_S 8
+#define HPZ1_V(x) ((x) << HPZ1_S)
+
+#define HPZ0_S 0
+#define HPZ0_V(x) ((x) << HPZ0_S)
+
+#define ULP_RX_TDDP_PSZ_A 0x19178
+
+/* registers for module SF */
+#define SF_DATA_A 0x193f8
+#define SF_OP_A 0x193fc
+
+#define SF_BUSY_S 31
+#define SF_BUSY_V(x) ((x) << SF_BUSY_S)
+#define SF_BUSY_F SF_BUSY_V(1U)
+
+#define SF_LOCK_S 4
+#define SF_LOCK_V(x) ((x) << SF_LOCK_S)
+#define SF_LOCK_F SF_LOCK_V(1U)
+
+#define SF_CONT_S 3
+#define SF_CONT_V(x) ((x) << SF_CONT_S)
+#define SF_CONT_F SF_CONT_V(1U)
+
+#define BYTECNT_S 1
+#define BYTECNT_V(x) ((x) << BYTECNT_S)
+
+#define OP_S 0
+#define OP_V(x) ((x) << OP_S)
+#define OP_F OP_V(1U)
+
+#define PL_PF_INT_CAUSE_A 0x3c0
+
+#define PFSW_S 3
+#define PFSW_V(x) ((x) << PFSW_S)
+#define PFSW_F PFSW_V(1U)
+
+#define PFCIM_S 1
+#define PFCIM_V(x) ((x) << PFCIM_S)
+#define PFCIM_F PFCIM_V(1U)
+
+#define PL_PF_INT_ENABLE_A 0x3c4
+#define PL_PF_CTL_A 0x3c8
+
+#define PL_WHOAMI_A 0x19400
+
+#define SOURCEPF_S 8
+#define SOURCEPF_M 0x7U
+#define SOURCEPF_G(x) (((x) >> SOURCEPF_S) & SOURCEPF_M)
+
+#define T6_SOURCEPF_S 9
+#define T6_SOURCEPF_M 0x7U
+#define T6_SOURCEPF_G(x) (((x) >> T6_SOURCEPF_S) & T6_SOURCEPF_M)
+
+#define PL_INT_CAUSE_A 0x1940c
+
+#define ULP_TX_S 27
+#define ULP_TX_V(x) ((x) << ULP_TX_S)
+#define ULP_TX_F ULP_TX_V(1U)
+
+#define SGE_S 26
+#define SGE_V(x) ((x) << SGE_S)
+#define SGE_F SGE_V(1U)
+
+#define CPL_SWITCH_S 24
+#define CPL_SWITCH_V(x) ((x) << CPL_SWITCH_S)
+#define CPL_SWITCH_F CPL_SWITCH_V(1U)
+
+#define ULP_RX_S 23
+#define ULP_RX_V(x) ((x) << ULP_RX_S)
+#define ULP_RX_F ULP_RX_V(1U)
+
+#define PM_RX_S 22
+#define PM_RX_V(x) ((x) << PM_RX_S)
+#define PM_RX_F PM_RX_V(1U)
+
+#define PM_TX_S 21
+#define PM_TX_V(x) ((x) << PM_TX_S)
+#define PM_TX_F PM_TX_V(1U)
+
+#define MA_S 20
+#define MA_V(x) ((x) << MA_S)
+#define MA_F MA_V(1U)
+
+#define TP_S 19
+#define TP_V(x) ((x) << TP_S)
+#define TP_F TP_V(1U)
+
+#define LE_S 18
+#define LE_V(x) ((x) << LE_S)
+#define LE_F LE_V(1U)
+
+#define EDC1_S 17
+#define EDC1_V(x) ((x) << EDC1_S)
+#define EDC1_F EDC1_V(1U)
+
+#define EDC0_S 16
+#define EDC0_V(x) ((x) << EDC0_S)
+#define EDC0_F EDC0_V(1U)
+
+#define MC_S 15
+#define MC_V(x) ((x) << MC_S)
+#define MC_F MC_V(1U)
+
+#define PCIE_S 14
+#define PCIE_V(x) ((x) << PCIE_S)
+#define PCIE_F PCIE_V(1U)
+
+#define XGMAC_KR1_S 12
+#define XGMAC_KR1_V(x) ((x) << XGMAC_KR1_S)
+#define XGMAC_KR1_F XGMAC_KR1_V(1U)
+
+#define XGMAC_KR0_S 11
+#define XGMAC_KR0_V(x) ((x) << XGMAC_KR0_S)
+#define XGMAC_KR0_F XGMAC_KR0_V(1U)
+
+#define XGMAC1_S 10
+#define XGMAC1_V(x) ((x) << XGMAC1_S)
+#define XGMAC1_F XGMAC1_V(1U)
+
+#define XGMAC0_S 9
+#define XGMAC0_V(x) ((x) << XGMAC0_S)
+#define XGMAC0_F XGMAC0_V(1U)
+
+#define SMB_S 8
+#define SMB_V(x) ((x) << SMB_S)
+#define SMB_F SMB_V(1U)
+
+#define SF_S 7
+#define SF_V(x) ((x) << SF_S)
+#define SF_F SF_V(1U)
+
+#define PL_S 6
+#define PL_V(x) ((x) << PL_S)
+#define PL_F PL_V(1U)
+
+#define NCSI_S 5
+#define NCSI_V(x) ((x) << NCSI_S)
+#define NCSI_F NCSI_V(1U)
+
+#define MPS_S 4
+#define MPS_V(x) ((x) << MPS_S)
+#define MPS_F MPS_V(1U)
+
+#define CIM_S 0
+#define CIM_V(x) ((x) << CIM_S)
+#define CIM_F CIM_V(1U)
+
+#define MC1_S 31
+#define MC1_V(x) ((x) << MC1_S)
+#define MC1_F MC1_V(1U)
+
+#define PL_INT_ENABLE_A 0x19410
+#define PL_INT_MAP0_A 0x19414
+#define PL_RST_A 0x19428
+
+#define PIORST_S 1
+#define PIORST_V(x) ((x) << PIORST_S)
+#define PIORST_F PIORST_V(1U)
+
+#define PIORSTMODE_S 0
+#define PIORSTMODE_V(x) ((x) << PIORSTMODE_S)
+#define PIORSTMODE_F PIORSTMODE_V(1U)
+
+#define PL_PL_INT_CAUSE_A 0x19430
+
+#define FATALPERR_S 4
+#define FATALPERR_V(x) ((x) << FATALPERR_S)
+#define FATALPERR_F FATALPERR_V(1U)
+
+#define PERRVFID_S 0
+#define PERRVFID_V(x) ((x) << PERRVFID_S)
+#define PERRVFID_F PERRVFID_V(1U)
+
+#define PL_REV_A 0x1943c
+
+#define REV_S 0
+#define REV_M 0xfU
+#define REV_V(x) ((x) << REV_S)
+#define REV_G(x) (((x) >> REV_S) & REV_M)
+
+#define T6_UNKNOWNCMD_S 3
+#define T6_UNKNOWNCMD_V(x) ((x) << T6_UNKNOWNCMD_S)
+#define T6_UNKNOWNCMD_F T6_UNKNOWNCMD_V(1U)
+
+#define T6_LIP0_S 2
+#define T6_LIP0_V(x) ((x) << T6_LIP0_S)
+#define T6_LIP0_F T6_LIP0_V(1U)
+
+#define T6_LIPMISS_S 1
+#define T6_LIPMISS_V(x) ((x) << T6_LIPMISS_S)
+#define T6_LIPMISS_F T6_LIPMISS_V(1U)
+
+#define LE_DB_CONFIG_A 0x19c04
+#define LE_DB_SERVER_INDEX_A 0x19c18
+#define LE_DB_SRVR_START_INDEX_A 0x19c18
+#define LE_DB_ACT_CNT_IPV4_A 0x19c20
+#define LE_DB_ACT_CNT_IPV6_A 0x19c24
+#define LE_DB_HASH_TID_BASE_A 0x19c30
+#define LE_DB_HASH_TBL_BASE_ADDR_A 0x19c30
+#define LE_DB_INT_CAUSE_A 0x19c3c
+#define LE_DB_TID_HASHBASE_A 0x19df8
+#define T6_LE_DB_HASH_TID_BASE_A 0x19df8
+
+#define HASHEN_S 20
+#define HASHEN_V(x) ((x) << HASHEN_S)
+#define HASHEN_F HASHEN_V(1U)
+
+#define ASLIPCOMPEN_S 17
+#define ASLIPCOMPEN_V(x) ((x) << ASLIPCOMPEN_S)
+#define ASLIPCOMPEN_F ASLIPCOMPEN_V(1U)
+
+#define REQQPARERR_S 16
+#define REQQPARERR_V(x) ((x) << REQQPARERR_S)
+#define REQQPARERR_F REQQPARERR_V(1U)
+
+#define UNKNOWNCMD_S 15
+#define UNKNOWNCMD_V(x) ((x) << UNKNOWNCMD_S)
+#define UNKNOWNCMD_F UNKNOWNCMD_V(1U)
+
+#define PARITYERR_S 6
+#define PARITYERR_V(x) ((x) << PARITYERR_S)
+#define PARITYERR_F PARITYERR_V(1U)
+
+#define LIPMISS_S 5
+#define LIPMISS_V(x) ((x) << LIPMISS_S)
+#define LIPMISS_F LIPMISS_V(1U)
+
+#define LIP0_S 4
+#define LIP0_V(x) ((x) << LIP0_S)
+#define LIP0_F LIP0_V(1U)
+
+#define BASEADDR_S 3
+#define BASEADDR_M 0x1fffffffU
+#define BASEADDR_G(x) (((x) >> BASEADDR_S) & BASEADDR_M)
+
+#define TCAMINTPERR_S 13
+#define TCAMINTPERR_V(x) ((x) << TCAMINTPERR_S)
+#define TCAMINTPERR_F TCAMINTPERR_V(1U)
+
+#define SSRAMINTPERR_S 10
+#define SSRAMINTPERR_V(x) ((x) << SSRAMINTPERR_S)
+#define SSRAMINTPERR_F SSRAMINTPERR_V(1U)
+
+#define NCSI_INT_CAUSE_A 0x1a0d8
+
+#define CIM_DM_PRTY_ERR_S 8
+#define CIM_DM_PRTY_ERR_V(x) ((x) << CIM_DM_PRTY_ERR_S)
+#define CIM_DM_PRTY_ERR_F CIM_DM_PRTY_ERR_V(1U)
+
+#define MPS_DM_PRTY_ERR_S 7
+#define MPS_DM_PRTY_ERR_V(x) ((x) << MPS_DM_PRTY_ERR_S)
+#define MPS_DM_PRTY_ERR_F MPS_DM_PRTY_ERR_V(1U)
+
+#define TXFIFO_PRTY_ERR_S 1
+#define TXFIFO_PRTY_ERR_V(x) ((x) << TXFIFO_PRTY_ERR_S)
+#define TXFIFO_PRTY_ERR_F TXFIFO_PRTY_ERR_V(1U)
+
+#define RXFIFO_PRTY_ERR_S 0
+#define RXFIFO_PRTY_ERR_V(x) ((x) << RXFIFO_PRTY_ERR_S)
+#define RXFIFO_PRTY_ERR_F RXFIFO_PRTY_ERR_V(1U)
+
+#define XGMAC_PORT_CFG2_A 0x1018
+
+#define PATEN_S 18
+#define PATEN_V(x) ((x) << PATEN_S)
+#define PATEN_F PATEN_V(1U)
+
+#define MAGICEN_S 17
+#define MAGICEN_V(x) ((x) << MAGICEN_S)
+#define MAGICEN_F MAGICEN_V(1U)
+
+#define XGMAC_PORT_MAGIC_MACID_LO 0x1024
+#define XGMAC_PORT_MAGIC_MACID_HI 0x1028
+
+#define XGMAC_PORT_EPIO_DATA0_A 0x10c0
+#define XGMAC_PORT_EPIO_DATA1_A 0x10c4
+#define XGMAC_PORT_EPIO_DATA2_A 0x10c8
+#define XGMAC_PORT_EPIO_DATA3_A 0x10cc
+#define XGMAC_PORT_EPIO_OP_A 0x10d0
+
+#define EPIOWR_S 8
+#define EPIOWR_V(x) ((x) << EPIOWR_S)
+#define EPIOWR_F EPIOWR_V(1U)
+
+#define ADDRESS_S 0
+#define ADDRESS_V(x) ((x) << ADDRESS_S)
+
+#define MAC_PORT_INT_CAUSE_A 0x8dc
+#define XGMAC_PORT_INT_CAUSE_A 0x10dc
+
+#define TP_TX_MOD_QUEUE_REQ_MAP_A 0x7e28
+
+#define TP_TX_MOD_QUEUE_WEIGHT0_A 0x7e30
+#define TP_TX_MOD_CHANNEL_WEIGHT_A 0x7e34
+
+#define TX_MOD_QUEUE_REQ_MAP_S 0
+#define TX_MOD_QUEUE_REQ_MAP_V(x) ((x) << TX_MOD_QUEUE_REQ_MAP_S)
+
+#define TX_MODQ_WEIGHT3_S 24
+#define TX_MODQ_WEIGHT3_V(x) ((x) << TX_MODQ_WEIGHT3_S)
+
+#define TX_MODQ_WEIGHT2_S 16
+#define TX_MODQ_WEIGHT2_V(x) ((x) << TX_MODQ_WEIGHT2_S)
+
+#define TX_MODQ_WEIGHT1_S 8
+#define TX_MODQ_WEIGHT1_V(x) ((x) << TX_MODQ_WEIGHT1_S)
+
+#define TX_MODQ_WEIGHT0_S 0
+#define TX_MODQ_WEIGHT0_V(x) ((x) << TX_MODQ_WEIGHT0_S)
+
+#define TP_TX_SCHED_HDR_A 0x23
+#define TP_TX_SCHED_FIFO_A 0x24
+#define TP_TX_SCHED_PCMD_A 0x25
+
+#define NUM_MPS_CLS_SRAM_L_INSTANCES 336
+#define NUM_MPS_T5_CLS_SRAM_L_INSTANCES 512
+
+#define T5_PORT0_BASE 0x30000
+#define T5_PORT_STRIDE 0x4000
+#define T5_PORT_BASE(idx) (T5_PORT0_BASE + (idx) * T5_PORT_STRIDE)
+#define T5_PORT_REG(idx, reg) (T5_PORT_BASE(idx) + (reg))
+
+#define MC_0_BASE_ADDR 0x40000
+#define MC_1_BASE_ADDR 0x48000
+#define MC_STRIDE (MC_1_BASE_ADDR - MC_0_BASE_ADDR)
+#define MC_REG(reg, idx) (reg + MC_STRIDE * idx)
+
+#define MC_P_BIST_CMD_A 0x41400
+#define MC_P_BIST_CMD_ADDR_A 0x41404
+#define MC_P_BIST_CMD_LEN_A 0x41408
+#define MC_P_BIST_DATA_PATTERN_A 0x4140c
+#define MC_P_BIST_STATUS_RDATA_A 0x41488
+
+#define EDC_T50_BASE_ADDR 0x50000
+
+#define EDC_H_BIST_CMD_A 0x50004
+#define EDC_H_BIST_CMD_ADDR_A 0x50008
+#define EDC_H_BIST_CMD_LEN_A 0x5000c
+#define EDC_H_BIST_DATA_PATTERN_A 0x50010
+#define EDC_H_BIST_STATUS_RDATA_A 0x50028
+
+#define EDC_H_ECC_ERR_ADDR_A 0x50084
+#define EDC_T51_BASE_ADDR 0x50800
+
+#define EDC_T5_STRIDE (EDC_T51_BASE_ADDR - EDC_T50_BASE_ADDR)
+#define EDC_T5_REG(reg, idx) (reg + EDC_T5_STRIDE * idx)
+
+#define PL_VF_REV_A 0x4
+#define PL_VF_WHOAMI_A 0x0
+#define PL_VF_REVISION_A 0x8
+
+/* registers for module CIM */
+#define CIM_HOST_ACC_CTRL_A 0x7b50
+#define CIM_HOST_ACC_DATA_A 0x7b54
+#define UP_UP_DBG_LA_CFG_A 0x140
+#define UP_UP_DBG_LA_DATA_A 0x144
+
+#define HOSTBUSY_S 17
+#define HOSTBUSY_V(x) ((x) << HOSTBUSY_S)
+#define HOSTBUSY_F HOSTBUSY_V(1U)
+
+#define HOSTWRITE_S 16
+#define HOSTWRITE_V(x) ((x) << HOSTWRITE_S)
+#define HOSTWRITE_F HOSTWRITE_V(1U)
+
+#define CIM_IBQ_DBG_CFG_A 0x7b60
+
+#define IBQDBGADDR_S 16
+#define IBQDBGADDR_M 0xfffU
+#define IBQDBGADDR_V(x) ((x) << IBQDBGADDR_S)
+#define IBQDBGADDR_G(x) (((x) >> IBQDBGADDR_S) & IBQDBGADDR_M)
+
+#define IBQDBGBUSY_S 1
+#define IBQDBGBUSY_V(x) ((x) << IBQDBGBUSY_S)
+#define IBQDBGBUSY_F IBQDBGBUSY_V(1U)
+
+#define IBQDBGEN_S 0
+#define IBQDBGEN_V(x) ((x) << IBQDBGEN_S)
+#define IBQDBGEN_F IBQDBGEN_V(1U)
+
+#define CIM_OBQ_DBG_CFG_A 0x7b64
+
+#define OBQDBGADDR_S 16
+#define OBQDBGADDR_M 0xfffU
+#define OBQDBGADDR_V(x) ((x) << OBQDBGADDR_S)
+#define OBQDBGADDR_G(x) (((x) >> OBQDBGADDR_S) & OBQDBGADDR_M)
+
+#define OBQDBGBUSY_S 1
+#define OBQDBGBUSY_V(x) ((x) << OBQDBGBUSY_S)
+#define OBQDBGBUSY_F OBQDBGBUSY_V(1U)
+
+#define OBQDBGEN_S 0
+#define OBQDBGEN_V(x) ((x) << OBQDBGEN_S)
+#define OBQDBGEN_F OBQDBGEN_V(1U)
+
+#define CIM_IBQ_DBG_DATA_A 0x7b68
+#define CIM_OBQ_DBG_DATA_A 0x7b6c
+#define CIM_DEBUGCFG_A 0x7b70
+#define CIM_DEBUGSTS_A 0x7b74
+
+#define POLADBGRDPTR_S 23
+#define POLADBGRDPTR_M 0x1ffU
+#define POLADBGRDPTR_V(x) ((x) << POLADBGRDPTR_S)
+
+#define POLADBGWRPTR_S 16
+#define POLADBGWRPTR_M 0x1ffU
+#define POLADBGWRPTR_G(x) (((x) >> POLADBGWRPTR_S) & POLADBGWRPTR_M)
+
+#define PILADBGRDPTR_S 14
+#define PILADBGRDPTR_M 0x1ffU
+#define PILADBGRDPTR_V(x) ((x) << PILADBGRDPTR_S)
+
+#define PILADBGWRPTR_S 0
+#define PILADBGWRPTR_M 0x1ffU
+#define PILADBGWRPTR_G(x) (((x) >> PILADBGWRPTR_S) & PILADBGWRPTR_M)
+
+#define LADBGEN_S 12
+#define LADBGEN_V(x) ((x) << LADBGEN_S)
+#define LADBGEN_F LADBGEN_V(1U)
+
+#define CIM_PO_LA_DEBUGDATA_A 0x7b78
+#define CIM_PI_LA_DEBUGDATA_A 0x7b7c
+#define CIM_PO_LA_MADEBUGDATA_A 0x7b80
+#define CIM_PI_LA_MADEBUGDATA_A 0x7b84
+
+#define UPDBGLARDEN_S 1
+#define UPDBGLARDEN_V(x) ((x) << UPDBGLARDEN_S)
+#define UPDBGLARDEN_F UPDBGLARDEN_V(1U)
+
+#define UPDBGLAEN_S 0
+#define UPDBGLAEN_V(x) ((x) << UPDBGLAEN_S)
+#define UPDBGLAEN_F UPDBGLAEN_V(1U)
+
+#define UPDBGLARDPTR_S 2
+#define UPDBGLARDPTR_M 0xfffU
+#define UPDBGLARDPTR_V(x) ((x) << UPDBGLARDPTR_S)
+
+#define UPDBGLAWRPTR_S 16
+#define UPDBGLAWRPTR_M 0xfffU
+#define UPDBGLAWRPTR_G(x) (((x) >> UPDBGLAWRPTR_S) & UPDBGLAWRPTR_M)
+
+#define UPDBGLACAPTPCONLY_S 30
+#define UPDBGLACAPTPCONLY_V(x) ((x) << UPDBGLACAPTPCONLY_S)
+#define UPDBGLACAPTPCONLY_F UPDBGLACAPTPCONLY_V(1U)
+
+#define CIM_QUEUE_CONFIG_REF_A 0x7b48
+#define CIM_QUEUE_CONFIG_CTRL_A 0x7b4c
+
+#define CIMQSIZE_S 24
+#define CIMQSIZE_M 0x3fU
+#define CIMQSIZE_G(x) (((x) >> CIMQSIZE_S) & CIMQSIZE_M)
+
+#define CIMQBASE_S 16
+#define CIMQBASE_M 0x3fU
+#define CIMQBASE_G(x) (((x) >> CIMQBASE_S) & CIMQBASE_M)
+
+#define QUEFULLTHRSH_S 0
+#define QUEFULLTHRSH_M 0x1ffU
+#define QUEFULLTHRSH_G(x) (((x) >> QUEFULLTHRSH_S) & QUEFULLTHRSH_M)
+
+#define UP_IBQ_0_RDADDR_A 0x10
+#define UP_IBQ_0_SHADOW_RDADDR_A 0x280
+#define UP_OBQ_0_REALADDR_A 0x104
+#define UP_OBQ_0_SHADOW_REALADDR_A 0x394
+
+#define IBQRDADDR_S 0
+#define IBQRDADDR_M 0x1fffU
+#define IBQRDADDR_G(x) (((x) >> IBQRDADDR_S) & IBQRDADDR_M)
+
+#define IBQWRADDR_S 0
+#define IBQWRADDR_M 0x1fffU
+#define IBQWRADDR_G(x) (((x) >> IBQWRADDR_S) & IBQWRADDR_M)
+
+#define QUERDADDR_S 0
+#define QUERDADDR_M 0x7fffU
+#define QUERDADDR_G(x) (((x) >> QUERDADDR_S) & QUERDADDR_M)
+
+#define QUEREMFLITS_S 0
+#define QUEREMFLITS_M 0x7ffU
+#define QUEREMFLITS_G(x) (((x) >> QUEREMFLITS_S) & QUEREMFLITS_M)
+
+#define QUEEOPCNT_S 16
+#define QUEEOPCNT_M 0xfffU
+#define QUEEOPCNT_G(x) (((x) >> QUEEOPCNT_S) & QUEEOPCNT_M)
+
+#define QUESOPCNT_S 0
+#define QUESOPCNT_M 0xfffU
+#define QUESOPCNT_G(x) (((x) >> QUESOPCNT_S) & QUESOPCNT_M)
+
+#define OBQSELECT_S 4
+#define OBQSELECT_V(x) ((x) << OBQSELECT_S)
+#define OBQSELECT_F OBQSELECT_V(1U)
+
+#define IBQSELECT_S 3
+#define IBQSELECT_V(x) ((x) << IBQSELECT_S)
+#define IBQSELECT_F IBQSELECT_V(1U)
+
+#define QUENUMSELECT_S 0
+#define QUENUMSELECT_V(x) ((x) << QUENUMSELECT_S)
+
+#endif /* __T4_REGS_H */
diff --git a/contrib/ofed/libcxgb4/t4fw_api.h b/contrib/ofed/libcxgb4/t4fw_api.h
new file mode 100644
index 0000000..07698bb
--- /dev/null
+++ b/contrib/ofed/libcxgb4/t4fw_api.h
@@ -0,0 +1,3260 @@
+/*
+ * This file is part of the Chelsio T4 Ethernet driver for Linux.
+ *
+ * Copyright (c) 2009-2014 Chelsio Communications, Inc. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#ifndef _T4FW_INTERFACE_H_
+#define _T4FW_INTERFACE_H_
+
+#include <infiniband/types.h>
+
+enum fw_retval {
+ FW_SUCCESS = 0, /* completed successfully */
+ FW_EPERM = 1, /* operation not permitted */
+ FW_ENOENT = 2, /* no such file or directory */
+ FW_EIO = 5, /* input/output error; hw bad */
+ FW_ENOEXEC = 8, /* exec format error; inv microcode */
+ FW_EAGAIN = 11, /* try again */
+ FW_ENOMEM = 12, /* out of memory */
+ FW_EFAULT = 14, /* bad address; fw bad */
+ FW_EBUSY = 16, /* resource busy */
+ FW_EEXIST = 17, /* file exists */
+ FW_ENODEV = 19, /* no such device */
+ FW_EINVAL = 22, /* invalid argument */
+ FW_ENOSPC = 28, /* no space left on device */
+ FW_ENOSYS = 38, /* functionality not implemented */
+ FW_ENODATA = 61, /* no data available */
+ FW_EPROTO = 71, /* protocol error */
+ FW_EADDRINUSE = 98, /* address already in use */
+ FW_EADDRNOTAVAIL = 99, /* cannot assigned requested address */
+ FW_ENETDOWN = 100, /* network is down */
+ FW_ENETUNREACH = 101, /* network is unreachable */
+ FW_ENOBUFS = 105, /* no buffer space available */
+ FW_ETIMEDOUT = 110, /* timeout */
+ FW_EINPROGRESS = 115, /* fw internal */
+ FW_SCSI_ABORT_REQUESTED = 128, /* */
+ FW_SCSI_ABORT_TIMEDOUT = 129, /* */
+ FW_SCSI_ABORTED = 130, /* */
+ FW_SCSI_CLOSE_REQUESTED = 131, /* */
+ FW_ERR_LINK_DOWN = 132, /* */
+ FW_RDEV_NOT_READY = 133, /* */
+ FW_ERR_RDEV_LOST = 134, /* */
+ FW_ERR_RDEV_LOGO = 135, /* */
+ FW_FCOE_NO_XCHG = 136, /* */
+ FW_SCSI_RSP_ERR = 137, /* */
+ FW_ERR_RDEV_IMPL_LOGO = 138, /* */
+ FW_SCSI_UNDER_FLOW_ERR = 139, /* */
+ FW_SCSI_OVER_FLOW_ERR = 140, /* */
+ FW_SCSI_DDP_ERR = 141, /* DDP error*/
+ FW_SCSI_TASK_ERR = 142, /* No SCSI tasks available */
+};
+
+#define FW_T4VF_SGE_BASE_ADDR 0x0000
+#define FW_T4VF_MPS_BASE_ADDR 0x0100
+#define FW_T4VF_PL_BASE_ADDR 0x0200
+#define FW_T4VF_MBDATA_BASE_ADDR 0x0240
+#define FW_T4VF_CIM_BASE_ADDR 0x0300
+
+enum fw_wr_opcodes {
+ FW_FILTER_WR = 0x02,
+ FW_ULPTX_WR = 0x04,
+ FW_TP_WR = 0x05,
+ FW_ETH_TX_PKT_WR = 0x08,
+ FW_OFLD_CONNECTION_WR = 0x2f,
+ FW_FLOWC_WR = 0x0a,
+ FW_OFLD_TX_DATA_WR = 0x0b,
+ FW_CMD_WR = 0x10,
+ FW_ETH_TX_PKT_VM_WR = 0x11,
+ FW_RI_RES_WR = 0x0c,
+ FW_RI_INIT_WR = 0x0d,
+ FW_RI_RDMA_WRITE_WR = 0x14,
+ FW_RI_SEND_WR = 0x15,
+ FW_RI_RDMA_READ_WR = 0x16,
+ FW_RI_RECV_WR = 0x17,
+ FW_RI_BIND_MW_WR = 0x18,
+ FW_RI_FR_NSMR_WR = 0x19,
+ FW_RI_INV_LSTAG_WR = 0x1a,
+ FW_ISCSI_TX_DATA_WR = 0x45,
+ FW_LASTC2E_WR = 0x70
+};
+
+struct fw_wr_hdr {
+ __be32 hi;
+ __be32 lo;
+};
+
+/* work request opcode (hi) */
+#define FW_WR_OP_S 24
+#define FW_WR_OP_M 0xff
+#define FW_WR_OP_V(x) ((x) << FW_WR_OP_S)
+#define FW_WR_OP_G(x) (((x) >> FW_WR_OP_S) & FW_WR_OP_M)
+
+/* atomic flag (hi) - firmware encapsulates CPLs in CPL_BARRIER */
+#define FW_WR_ATOMIC_S 23
+#define FW_WR_ATOMIC_V(x) ((x) << FW_WR_ATOMIC_S)
+
+/* flush flag (hi) - firmware flushes flushable work request buffered
+ * in the flow context.
+ */
+#define FW_WR_FLUSH_S 22
+#define FW_WR_FLUSH_V(x) ((x) << FW_WR_FLUSH_S)
+
+/* completion flag (hi) - firmware generates a cpl_fw6_ack */
+#define FW_WR_COMPL_S 21
+#define FW_WR_COMPL_V(x) ((x) << FW_WR_COMPL_S)
+#define FW_WR_COMPL_F FW_WR_COMPL_V(1U)
+
+/* work request immediate data length (hi) */
+#define FW_WR_IMMDLEN_S 0
+#define FW_WR_IMMDLEN_M 0xff
+#define FW_WR_IMMDLEN_V(x) ((x) << FW_WR_IMMDLEN_S)
+
+/* egress queue status update to associated ingress queue entry (lo) */
+#define FW_WR_EQUIQ_S 31
+#define FW_WR_EQUIQ_V(x) ((x) << FW_WR_EQUIQ_S)
+#define FW_WR_EQUIQ_F FW_WR_EQUIQ_V(1U)
+
+/* egress queue status update to egress queue status entry (lo) */
+#define FW_WR_EQUEQ_S 30
+#define FW_WR_EQUEQ_V(x) ((x) << FW_WR_EQUEQ_S)
+#define FW_WR_EQUEQ_F FW_WR_EQUEQ_V(1U)
+
+/* flow context identifier (lo) */
+#define FW_WR_FLOWID_S 8
+#define FW_WR_FLOWID_V(x) ((x) << FW_WR_FLOWID_S)
+
+/* length in units of 16-bytes (lo) */
+#define FW_WR_LEN16_S 0
+#define FW_WR_LEN16_V(x) ((x) << FW_WR_LEN16_S)
+
+#define HW_TPL_FR_MT_PR_IV_P_FC 0X32B
+#define HW_TPL_FR_MT_PR_OV_P_FC 0X327
+
+/* filter wr reply code in cookie in CPL_SET_TCB_RPL */
+enum fw_filter_wr_cookie {
+ FW_FILTER_WR_SUCCESS,
+ FW_FILTER_WR_FLT_ADDED,
+ FW_FILTER_WR_FLT_DELETED,
+ FW_FILTER_WR_SMT_TBL_FULL,
+ FW_FILTER_WR_EINVAL,
+};
+
+struct fw_filter_wr {
+ __be32 op_pkd;
+ __be32 len16_pkd;
+ __be64 r3;
+ __be32 tid_to_iq;
+ __be32 del_filter_to_l2tix;
+ __be16 ethtype;
+ __be16 ethtypem;
+ __u8 frag_to_ovlan_vldm;
+ __u8 smac_sel;
+ __be16 rx_chan_rx_rpl_iq;
+ __be32 maci_to_matchtypem;
+ __u8 ptcl;
+ __u8 ptclm;
+ __u8 ttyp;
+ __u8 ttypm;
+ __be16 ivlan;
+ __be16 ivlanm;
+ __be16 ovlan;
+ __be16 ovlanm;
+ __u8 lip[16];
+ __u8 lipm[16];
+ __u8 fip[16];
+ __u8 fipm[16];
+ __be16 lp;
+ __be16 lpm;
+ __be16 fp;
+ __be16 fpm;
+ __be16 r7;
+ __u8 sma[6];
+};
+
+#define FW_FILTER_WR_TID_S 12
+#define FW_FILTER_WR_TID_M 0xfffff
+#define FW_FILTER_WR_TID_V(x) ((x) << FW_FILTER_WR_TID_S)
+#define FW_FILTER_WR_TID_G(x) \
+ (((x) >> FW_FILTER_WR_TID_S) & FW_FILTER_WR_TID_M)
+
+#define FW_FILTER_WR_RQTYPE_S 11
+#define FW_FILTER_WR_RQTYPE_M 0x1
+#define FW_FILTER_WR_RQTYPE_V(x) ((x) << FW_FILTER_WR_RQTYPE_S)
+#define FW_FILTER_WR_RQTYPE_G(x) \
+ (((x) >> FW_FILTER_WR_RQTYPE_S) & FW_FILTER_WR_RQTYPE_M)
+#define FW_FILTER_WR_RQTYPE_F FW_FILTER_WR_RQTYPE_V(1U)
+
+#define FW_FILTER_WR_NOREPLY_S 10
+#define FW_FILTER_WR_NOREPLY_M 0x1
+#define FW_FILTER_WR_NOREPLY_V(x) ((x) << FW_FILTER_WR_NOREPLY_S)
+#define FW_FILTER_WR_NOREPLY_G(x) \
+ (((x) >> FW_FILTER_WR_NOREPLY_S) & FW_FILTER_WR_NOREPLY_M)
+#define FW_FILTER_WR_NOREPLY_F FW_FILTER_WR_NOREPLY_V(1U)
+
+#define FW_FILTER_WR_IQ_S 0
+#define FW_FILTER_WR_IQ_M 0x3ff
+#define FW_FILTER_WR_IQ_V(x) ((x) << FW_FILTER_WR_IQ_S)
+#define FW_FILTER_WR_IQ_G(x) \
+ (((x) >> FW_FILTER_WR_IQ_S) & FW_FILTER_WR_IQ_M)
+
+#define FW_FILTER_WR_DEL_FILTER_S 31
+#define FW_FILTER_WR_DEL_FILTER_M 0x1
+#define FW_FILTER_WR_DEL_FILTER_V(x) ((x) << FW_FILTER_WR_DEL_FILTER_S)
+#define FW_FILTER_WR_DEL_FILTER_G(x) \
+ (((x) >> FW_FILTER_WR_DEL_FILTER_S) & FW_FILTER_WR_DEL_FILTER_M)
+#define FW_FILTER_WR_DEL_FILTER_F FW_FILTER_WR_DEL_FILTER_V(1U)
+
+#define FW_FILTER_WR_RPTTID_S 25
+#define FW_FILTER_WR_RPTTID_M 0x1
+#define FW_FILTER_WR_RPTTID_V(x) ((x) << FW_FILTER_WR_RPTTID_S)
+#define FW_FILTER_WR_RPTTID_G(x) \
+ (((x) >> FW_FILTER_WR_RPTTID_S) & FW_FILTER_WR_RPTTID_M)
+#define FW_FILTER_WR_RPTTID_F FW_FILTER_WR_RPTTID_V(1U)
+
+#define FW_FILTER_WR_DROP_S 24
+#define FW_FILTER_WR_DROP_M 0x1
+#define FW_FILTER_WR_DROP_V(x) ((x) << FW_FILTER_WR_DROP_S)
+#define FW_FILTER_WR_DROP_G(x) \
+ (((x) >> FW_FILTER_WR_DROP_S) & FW_FILTER_WR_DROP_M)
+#define FW_FILTER_WR_DROP_F FW_FILTER_WR_DROP_V(1U)
+
+#define FW_FILTER_WR_DIRSTEER_S 23
+#define FW_FILTER_WR_DIRSTEER_M 0x1
+#define FW_FILTER_WR_DIRSTEER_V(x) ((x) << FW_FILTER_WR_DIRSTEER_S)
+#define FW_FILTER_WR_DIRSTEER_G(x) \
+ (((x) >> FW_FILTER_WR_DIRSTEER_S) & FW_FILTER_WR_DIRSTEER_M)
+#define FW_FILTER_WR_DIRSTEER_F FW_FILTER_WR_DIRSTEER_V(1U)
+
+#define FW_FILTER_WR_MASKHASH_S 22
+#define FW_FILTER_WR_MASKHASH_M 0x1
+#define FW_FILTER_WR_MASKHASH_V(x) ((x) << FW_FILTER_WR_MASKHASH_S)
+#define FW_FILTER_WR_MASKHASH_G(x) \
+ (((x) >> FW_FILTER_WR_MASKHASH_S) & FW_FILTER_WR_MASKHASH_M)
+#define FW_FILTER_WR_MASKHASH_F FW_FILTER_WR_MASKHASH_V(1U)
+
+#define FW_FILTER_WR_DIRSTEERHASH_S 21
+#define FW_FILTER_WR_DIRSTEERHASH_M 0x1
+#define FW_FILTER_WR_DIRSTEERHASH_V(x) ((x) << FW_FILTER_WR_DIRSTEERHASH_S)
+#define FW_FILTER_WR_DIRSTEERHASH_G(x) \
+ (((x) >> FW_FILTER_WR_DIRSTEERHASH_S) & FW_FILTER_WR_DIRSTEERHASH_M)
+#define FW_FILTER_WR_DIRSTEERHASH_F FW_FILTER_WR_DIRSTEERHASH_V(1U)
+
+#define FW_FILTER_WR_LPBK_S 20
+#define FW_FILTER_WR_LPBK_M 0x1
+#define FW_FILTER_WR_LPBK_V(x) ((x) << FW_FILTER_WR_LPBK_S)
+#define FW_FILTER_WR_LPBK_G(x) \
+ (((x) >> FW_FILTER_WR_LPBK_S) & FW_FILTER_WR_LPBK_M)
+#define FW_FILTER_WR_LPBK_F FW_FILTER_WR_LPBK_V(1U)
+
+#define FW_FILTER_WR_DMAC_S 19
+#define FW_FILTER_WR_DMAC_M 0x1
+#define FW_FILTER_WR_DMAC_V(x) ((x) << FW_FILTER_WR_DMAC_S)
+#define FW_FILTER_WR_DMAC_G(x) \
+ (((x) >> FW_FILTER_WR_DMAC_S) & FW_FILTER_WR_DMAC_M)
+#define FW_FILTER_WR_DMAC_F FW_FILTER_WR_DMAC_V(1U)
+
+#define FW_FILTER_WR_SMAC_S 18
+#define FW_FILTER_WR_SMAC_M 0x1
+#define FW_FILTER_WR_SMAC_V(x) ((x) << FW_FILTER_WR_SMAC_S)
+#define FW_FILTER_WR_SMAC_G(x) \
+ (((x) >> FW_FILTER_WR_SMAC_S) & FW_FILTER_WR_SMAC_M)
+#define FW_FILTER_WR_SMAC_F FW_FILTER_WR_SMAC_V(1U)
+
+#define FW_FILTER_WR_INSVLAN_S 17
+#define FW_FILTER_WR_INSVLAN_M 0x1
+#define FW_FILTER_WR_INSVLAN_V(x) ((x) << FW_FILTER_WR_INSVLAN_S)
+#define FW_FILTER_WR_INSVLAN_G(x) \
+ (((x) >> FW_FILTER_WR_INSVLAN_S) & FW_FILTER_WR_INSVLAN_M)
+#define FW_FILTER_WR_INSVLAN_F FW_FILTER_WR_INSVLAN_V(1U)
+
+#define FW_FILTER_WR_RMVLAN_S 16
+#define FW_FILTER_WR_RMVLAN_M 0x1
+#define FW_FILTER_WR_RMVLAN_V(x) ((x) << FW_FILTER_WR_RMVLAN_S)
+#define FW_FILTER_WR_RMVLAN_G(x) \
+ (((x) >> FW_FILTER_WR_RMVLAN_S) & FW_FILTER_WR_RMVLAN_M)
+#define FW_FILTER_WR_RMVLAN_F FW_FILTER_WR_RMVLAN_V(1U)
+
+#define FW_FILTER_WR_HITCNTS_S 15
+#define FW_FILTER_WR_HITCNTS_M 0x1
+#define FW_FILTER_WR_HITCNTS_V(x) ((x) << FW_FILTER_WR_HITCNTS_S)
+#define FW_FILTER_WR_HITCNTS_G(x) \
+ (((x) >> FW_FILTER_WR_HITCNTS_S) & FW_FILTER_WR_HITCNTS_M)
+#define FW_FILTER_WR_HITCNTS_F FW_FILTER_WR_HITCNTS_V(1U)
+
+#define FW_FILTER_WR_TXCHAN_S 13
+#define FW_FILTER_WR_TXCHAN_M 0x3
+#define FW_FILTER_WR_TXCHAN_V(x) ((x) << FW_FILTER_WR_TXCHAN_S)
+#define FW_FILTER_WR_TXCHAN_G(x) \
+ (((x) >> FW_FILTER_WR_TXCHAN_S) & FW_FILTER_WR_TXCHAN_M)
+
+#define FW_FILTER_WR_PRIO_S 12
+#define FW_FILTER_WR_PRIO_M 0x1
+#define FW_FILTER_WR_PRIO_V(x) ((x) << FW_FILTER_WR_PRIO_S)
+#define FW_FILTER_WR_PRIO_G(x) \
+ (((x) >> FW_FILTER_WR_PRIO_S) & FW_FILTER_WR_PRIO_M)
+#define FW_FILTER_WR_PRIO_F FW_FILTER_WR_PRIO_V(1U)
+
+#define FW_FILTER_WR_L2TIX_S 0
+#define FW_FILTER_WR_L2TIX_M 0xfff
+#define FW_FILTER_WR_L2TIX_V(x) ((x) << FW_FILTER_WR_L2TIX_S)
+#define FW_FILTER_WR_L2TIX_G(x) \
+ (((x) >> FW_FILTER_WR_L2TIX_S) & FW_FILTER_WR_L2TIX_M)
+
+#define FW_FILTER_WR_FRAG_S 7
+#define FW_FILTER_WR_FRAG_M 0x1
+#define FW_FILTER_WR_FRAG_V(x) ((x) << FW_FILTER_WR_FRAG_S)
+#define FW_FILTER_WR_FRAG_G(x) \
+ (((x) >> FW_FILTER_WR_FRAG_S) & FW_FILTER_WR_FRAG_M)
+#define FW_FILTER_WR_FRAG_F FW_FILTER_WR_FRAG_V(1U)
+
+#define FW_FILTER_WR_FRAGM_S 6
+#define FW_FILTER_WR_FRAGM_M 0x1
+#define FW_FILTER_WR_FRAGM_V(x) ((x) << FW_FILTER_WR_FRAGM_S)
+#define FW_FILTER_WR_FRAGM_G(x) \
+ (((x) >> FW_FILTER_WR_FRAGM_S) & FW_FILTER_WR_FRAGM_M)
+#define FW_FILTER_WR_FRAGM_F FW_FILTER_WR_FRAGM_V(1U)
+
+#define FW_FILTER_WR_IVLAN_VLD_S 5
+#define FW_FILTER_WR_IVLAN_VLD_M 0x1
+#define FW_FILTER_WR_IVLAN_VLD_V(x) ((x) << FW_FILTER_WR_IVLAN_VLD_S)
+#define FW_FILTER_WR_IVLAN_VLD_G(x) \
+ (((x) >> FW_FILTER_WR_IVLAN_VLD_S) & FW_FILTER_WR_IVLAN_VLD_M)
+#define FW_FILTER_WR_IVLAN_VLD_F FW_FILTER_WR_IVLAN_VLD_V(1U)
+
+#define FW_FILTER_WR_OVLAN_VLD_S 4
+#define FW_FILTER_WR_OVLAN_VLD_M 0x1
+#define FW_FILTER_WR_OVLAN_VLD_V(x) ((x) << FW_FILTER_WR_OVLAN_VLD_S)
+#define FW_FILTER_WR_OVLAN_VLD_G(x) \
+ (((x) >> FW_FILTER_WR_OVLAN_VLD_S) & FW_FILTER_WR_OVLAN_VLD_M)
+#define FW_FILTER_WR_OVLAN_VLD_F FW_FILTER_WR_OVLAN_VLD_V(1U)
+
+#define FW_FILTER_WR_IVLAN_VLDM_S 3
+#define FW_FILTER_WR_IVLAN_VLDM_M 0x1
+#define FW_FILTER_WR_IVLAN_VLDM_V(x) ((x) << FW_FILTER_WR_IVLAN_VLDM_S)
+#define FW_FILTER_WR_IVLAN_VLDM_G(x) \
+ (((x) >> FW_FILTER_WR_IVLAN_VLDM_S) & FW_FILTER_WR_IVLAN_VLDM_M)
+#define FW_FILTER_WR_IVLAN_VLDM_F FW_FILTER_WR_IVLAN_VLDM_V(1U)
+
+#define FW_FILTER_WR_OVLAN_VLDM_S 2
+#define FW_FILTER_WR_OVLAN_VLDM_M 0x1
+#define FW_FILTER_WR_OVLAN_VLDM_V(x) ((x) << FW_FILTER_WR_OVLAN_VLDM_S)
+#define FW_FILTER_WR_OVLAN_VLDM_G(x) \
+ (((x) >> FW_FILTER_WR_OVLAN_VLDM_S) & FW_FILTER_WR_OVLAN_VLDM_M)
+#define FW_FILTER_WR_OVLAN_VLDM_F FW_FILTER_WR_OVLAN_VLDM_V(1U)
+
+#define FW_FILTER_WR_RX_CHAN_S 15
+#define FW_FILTER_WR_RX_CHAN_M 0x1
+#define FW_FILTER_WR_RX_CHAN_V(x) ((x) << FW_FILTER_WR_RX_CHAN_S)
+#define FW_FILTER_WR_RX_CHAN_G(x) \
+ (((x) >> FW_FILTER_WR_RX_CHAN_S) & FW_FILTER_WR_RX_CHAN_M)
+#define FW_FILTER_WR_RX_CHAN_F FW_FILTER_WR_RX_CHAN_V(1U)
+
+#define FW_FILTER_WR_RX_RPL_IQ_S 0
+#define FW_FILTER_WR_RX_RPL_IQ_M 0x3ff
+#define FW_FILTER_WR_RX_RPL_IQ_V(x) ((x) << FW_FILTER_WR_RX_RPL_IQ_S)
+#define FW_FILTER_WR_RX_RPL_IQ_G(x) \
+ (((x) >> FW_FILTER_WR_RX_RPL_IQ_S) & FW_FILTER_WR_RX_RPL_IQ_M)
+
+#define FW_FILTER_WR_MACI_S 23
+#define FW_FILTER_WR_MACI_M 0x1ff
+#define FW_FILTER_WR_MACI_V(x) ((x) << FW_FILTER_WR_MACI_S)
+#define FW_FILTER_WR_MACI_G(x) \
+ (((x) >> FW_FILTER_WR_MACI_S) & FW_FILTER_WR_MACI_M)
+
+#define FW_FILTER_WR_MACIM_S 14
+#define FW_FILTER_WR_MACIM_M 0x1ff
+#define FW_FILTER_WR_MACIM_V(x) ((x) << FW_FILTER_WR_MACIM_S)
+#define FW_FILTER_WR_MACIM_G(x) \
+ (((x) >> FW_FILTER_WR_MACIM_S) & FW_FILTER_WR_MACIM_M)
+
+#define FW_FILTER_WR_FCOE_S 13
+#define FW_FILTER_WR_FCOE_M 0x1
+#define FW_FILTER_WR_FCOE_V(x) ((x) << FW_FILTER_WR_FCOE_S)
+#define FW_FILTER_WR_FCOE_G(x) \
+ (((x) >> FW_FILTER_WR_FCOE_S) & FW_FILTER_WR_FCOE_M)
+#define FW_FILTER_WR_FCOE_F FW_FILTER_WR_FCOE_V(1U)
+
+#define FW_FILTER_WR_FCOEM_S 12
+#define FW_FILTER_WR_FCOEM_M 0x1
+#define FW_FILTER_WR_FCOEM_V(x) ((x) << FW_FILTER_WR_FCOEM_S)
+#define FW_FILTER_WR_FCOEM_G(x) \
+ (((x) >> FW_FILTER_WR_FCOEM_S) & FW_FILTER_WR_FCOEM_M)
+#define FW_FILTER_WR_FCOEM_F FW_FILTER_WR_FCOEM_V(1U)
+
+#define FW_FILTER_WR_PORT_S 9
+#define FW_FILTER_WR_PORT_M 0x7
+#define FW_FILTER_WR_PORT_V(x) ((x) << FW_FILTER_WR_PORT_S)
+#define FW_FILTER_WR_PORT_G(x) \
+ (((x) >> FW_FILTER_WR_PORT_S) & FW_FILTER_WR_PORT_M)
+
+#define FW_FILTER_WR_PORTM_S 6
+#define FW_FILTER_WR_PORTM_M 0x7
+#define FW_FILTER_WR_PORTM_V(x) ((x) << FW_FILTER_WR_PORTM_S)
+#define FW_FILTER_WR_PORTM_G(x) \
+ (((x) >> FW_FILTER_WR_PORTM_S) & FW_FILTER_WR_PORTM_M)
+
+#define FW_FILTER_WR_MATCHTYPE_S 3
+#define FW_FILTER_WR_MATCHTYPE_M 0x7
+#define FW_FILTER_WR_MATCHTYPE_V(x) ((x) << FW_FILTER_WR_MATCHTYPE_S)
+#define FW_FILTER_WR_MATCHTYPE_G(x) \
+ (((x) >> FW_FILTER_WR_MATCHTYPE_S) & FW_FILTER_WR_MATCHTYPE_M)
+
+#define FW_FILTER_WR_MATCHTYPEM_S 0
+#define FW_FILTER_WR_MATCHTYPEM_M 0x7
+#define FW_FILTER_WR_MATCHTYPEM_V(x) ((x) << FW_FILTER_WR_MATCHTYPEM_S)
+#define FW_FILTER_WR_MATCHTYPEM_G(x) \
+ (((x) >> FW_FILTER_WR_MATCHTYPEM_S) & FW_FILTER_WR_MATCHTYPEM_M)
+
+struct fw_ulptx_wr {
+ __be32 op_to_compl;
+ __be32 flowid_len16;
+ u64 cookie;
+};
+
+struct fw_tp_wr {
+ __be32 op_to_immdlen;
+ __be32 flowid_len16;
+ u64 cookie;
+};
+
+struct fw_eth_tx_pkt_wr {
+ __be32 op_immdlen;
+ __be32 equiq_to_len16;
+ __be64 r3;
+};
+
+struct fw_ofld_connection_wr {
+ __be32 op_compl;
+ __be32 len16_pkd;
+ __u64 cookie;
+ __be64 r2;
+ __be64 r3;
+ struct fw_ofld_connection_le {
+ __be32 version_cpl;
+ __be32 filter;
+ __be32 r1;
+ __be16 lport;
+ __be16 pport;
+ union fw_ofld_connection_leip {
+ struct fw_ofld_connection_le_ipv4 {
+ __be32 pip;
+ __be32 lip;
+ __be64 r0;
+ __be64 r1;
+ __be64 r2;
+ } ipv4;
+ struct fw_ofld_connection_le_ipv6 {
+ __be64 pip_hi;
+ __be64 pip_lo;
+ __be64 lip_hi;
+ __be64 lip_lo;
+ } ipv6;
+ } u;
+ } le;
+ struct fw_ofld_connection_tcb {
+ __be32 t_state_to_astid;
+ __be16 cplrxdataack_cplpassacceptrpl;
+ __be16 rcv_adv;
+ __be32 rcv_nxt;
+ __be32 tx_max;
+ __be64 opt0;
+ __be32 opt2;
+ __be32 r1;
+ __be64 r2;
+ __be64 r3;
+ } tcb;
+};
+
+#define FW_OFLD_CONNECTION_WR_VERSION_S 31
+#define FW_OFLD_CONNECTION_WR_VERSION_M 0x1
+#define FW_OFLD_CONNECTION_WR_VERSION_V(x) \
+ ((x) << FW_OFLD_CONNECTION_WR_VERSION_S)
+#define FW_OFLD_CONNECTION_WR_VERSION_G(x) \
+ (((x) >> FW_OFLD_CONNECTION_WR_VERSION_S) & \
+ FW_OFLD_CONNECTION_WR_VERSION_M)
+#define FW_OFLD_CONNECTION_WR_VERSION_F \
+ FW_OFLD_CONNECTION_WR_VERSION_V(1U)
+
+#define FW_OFLD_CONNECTION_WR_CPL_S 30
+#define FW_OFLD_CONNECTION_WR_CPL_M 0x1
+#define FW_OFLD_CONNECTION_WR_CPL_V(x) ((x) << FW_OFLD_CONNECTION_WR_CPL_S)
+#define FW_OFLD_CONNECTION_WR_CPL_G(x) \
+ (((x) >> FW_OFLD_CONNECTION_WR_CPL_S) & FW_OFLD_CONNECTION_WR_CPL_M)
+#define FW_OFLD_CONNECTION_WR_CPL_F FW_OFLD_CONNECTION_WR_CPL_V(1U)
+
+#define FW_OFLD_CONNECTION_WR_T_STATE_S 28
+#define FW_OFLD_CONNECTION_WR_T_STATE_M 0xf
+#define FW_OFLD_CONNECTION_WR_T_STATE_V(x) \
+ ((x) << FW_OFLD_CONNECTION_WR_T_STATE_S)
+#define FW_OFLD_CONNECTION_WR_T_STATE_G(x) \
+ (((x) >> FW_OFLD_CONNECTION_WR_T_STATE_S) & \
+ FW_OFLD_CONNECTION_WR_T_STATE_M)
+
+#define FW_OFLD_CONNECTION_WR_RCV_SCALE_S 24
+#define FW_OFLD_CONNECTION_WR_RCV_SCALE_M 0xf
+#define FW_OFLD_CONNECTION_WR_RCV_SCALE_V(x) \
+ ((x) << FW_OFLD_CONNECTION_WR_RCV_SCALE_S)
+#define FW_OFLD_CONNECTION_WR_RCV_SCALE_G(x) \
+ (((x) >> FW_OFLD_CONNECTION_WR_RCV_SCALE_S) & \
+ FW_OFLD_CONNECTION_WR_RCV_SCALE_M)
+
+#define FW_OFLD_CONNECTION_WR_ASTID_S 0
+#define FW_OFLD_CONNECTION_WR_ASTID_M 0xffffff
+#define FW_OFLD_CONNECTION_WR_ASTID_V(x) \
+ ((x) << FW_OFLD_CONNECTION_WR_ASTID_S)
+#define FW_OFLD_CONNECTION_WR_ASTID_G(x) \
+ (((x) >> FW_OFLD_CONNECTION_WR_ASTID_S) & FW_OFLD_CONNECTION_WR_ASTID_M)
+
+#define FW_OFLD_CONNECTION_WR_CPLRXDATAACK_S 15
+#define FW_OFLD_CONNECTION_WR_CPLRXDATAACK_M 0x1
+#define FW_OFLD_CONNECTION_WR_CPLRXDATAACK_V(x) \
+ ((x) << FW_OFLD_CONNECTION_WR_CPLRXDATAACK_S)
+#define FW_OFLD_CONNECTION_WR_CPLRXDATAACK_G(x) \
+ (((x) >> FW_OFLD_CONNECTION_WR_CPLRXDATAACK_S) & \
+ FW_OFLD_CONNECTION_WR_CPLRXDATAACK_M)
+#define FW_OFLD_CONNECTION_WR_CPLRXDATAACK_F \
+ FW_OFLD_CONNECTION_WR_CPLRXDATAACK_V(1U)
+
+#define FW_OFLD_CONNECTION_WR_CPLPASSACCEPTRPL_S 14
+#define FW_OFLD_CONNECTION_WR_CPLPASSACCEPTRPL_M 0x1
+#define FW_OFLD_CONNECTION_WR_CPLPASSACCEPTRPL_V(x) \
+ ((x) << FW_OFLD_CONNECTION_WR_CPLPASSACCEPTRPL_S)
+#define FW_OFLD_CONNECTION_WR_CPLPASSACCEPTRPL_G(x) \
+ (((x) >> FW_OFLD_CONNECTION_WR_CPLPASSACCEPTRPL_S) & \
+ FW_OFLD_CONNECTION_WR_CPLPASSACCEPTRPL_M)
+#define FW_OFLD_CONNECTION_WR_CPLPASSACCEPTRPL_F \
+ FW_OFLD_CONNECTION_WR_CPLPASSACCEPTRPL_V(1U)
+
+enum fw_flowc_mnem {
+ FW_FLOWC_MNEM_PFNVFN, /* PFN [15:8] VFN [7:0] */
+ FW_FLOWC_MNEM_CH,
+ FW_FLOWC_MNEM_PORT,
+ FW_FLOWC_MNEM_IQID,
+ FW_FLOWC_MNEM_SNDNXT,
+ FW_FLOWC_MNEM_RCVNXT,
+ FW_FLOWC_MNEM_SNDBUF,
+ FW_FLOWC_MNEM_MSS,
+ FW_FLOWC_MNEM_TXDATAPLEN_MAX,
+ FW_FLOWC_MNEM_TCPSTATE,
+ FW_FLOWC_MNEM_EOSTATE,
+ FW_FLOWC_MNEM_SCHEDCLASS,
+ FW_FLOWC_MNEM_DCBPRIO,
+ FW_FLOWC_MNEM_SND_SCALE,
+ FW_FLOWC_MNEM_RCV_SCALE,
+};
+
+struct fw_flowc_mnemval {
+ u8 mnemonic;
+ u8 r4[3];
+ __be32 val;
+};
+
+struct fw_flowc_wr {
+ __be32 op_to_nparams;
+ __be32 flowid_len16;
+ struct fw_flowc_mnemval mnemval[0];
+};
+
+#define FW_FLOWC_WR_NPARAMS_S 0
+#define FW_FLOWC_WR_NPARAMS_V(x) ((x) << FW_FLOWC_WR_NPARAMS_S)
+
+struct fw_ofld_tx_data_wr {
+ __be32 op_to_immdlen;
+ __be32 flowid_len16;
+ __be32 plen;
+ __be32 tunnel_to_proxy;
+};
+
+#define FW_OFLD_TX_DATA_WR_TUNNEL_S 19
+#define FW_OFLD_TX_DATA_WR_TUNNEL_V(x) ((x) << FW_OFLD_TX_DATA_WR_TUNNEL_S)
+
+#define FW_OFLD_TX_DATA_WR_SAVE_S 18
+#define FW_OFLD_TX_DATA_WR_SAVE_V(x) ((x) << FW_OFLD_TX_DATA_WR_SAVE_S)
+
+#define FW_OFLD_TX_DATA_WR_FLUSH_S 17
+#define FW_OFLD_TX_DATA_WR_FLUSH_V(x) ((x) << FW_OFLD_TX_DATA_WR_FLUSH_S)
+#define FW_OFLD_TX_DATA_WR_FLUSH_F FW_OFLD_TX_DATA_WR_FLUSH_V(1U)
+
+#define FW_OFLD_TX_DATA_WR_URGENT_S 16
+#define FW_OFLD_TX_DATA_WR_URGENT_V(x) ((x) << FW_OFLD_TX_DATA_WR_URGENT_S)
+
+#define FW_OFLD_TX_DATA_WR_MORE_S 15
+#define FW_OFLD_TX_DATA_WR_MORE_V(x) ((x) << FW_OFLD_TX_DATA_WR_MORE_S)
+
+#define FW_OFLD_TX_DATA_WR_SHOVE_S 14
+#define FW_OFLD_TX_DATA_WR_SHOVE_V(x) ((x) << FW_OFLD_TX_DATA_WR_SHOVE_S)
+#define FW_OFLD_TX_DATA_WR_SHOVE_F FW_OFLD_TX_DATA_WR_SHOVE_V(1U)
+
+#define FW_OFLD_TX_DATA_WR_ULPMODE_S 10
+#define FW_OFLD_TX_DATA_WR_ULPMODE_V(x) ((x) << FW_OFLD_TX_DATA_WR_ULPMODE_S)
+
+#define FW_OFLD_TX_DATA_WR_ULPSUBMODE_S 6
+#define FW_OFLD_TX_DATA_WR_ULPSUBMODE_V(x) \
+ ((x) << FW_OFLD_TX_DATA_WR_ULPSUBMODE_S)
+
+struct fw_cmd_wr {
+ __be32 op_dma;
+ __be32 len16_pkd;
+ __be64 cookie_daddr;
+};
+
+#define FW_CMD_WR_DMA_S 17
+#define FW_CMD_WR_DMA_V(x) ((x) << FW_CMD_WR_DMA_S)
+
+struct fw_eth_tx_pkt_vm_wr {
+ __be32 op_immdlen;
+ __be32 equiq_to_len16;
+ __be32 r3[2];
+ u8 ethmacdst[6];
+ u8 ethmacsrc[6];
+ __be16 ethtype;
+ __be16 vlantci;
+};
+
+#define FW_CMD_MAX_TIMEOUT 10000
+
+/*
+ * If a host driver does a HELLO and discovers that there's already a MASTER
+ * selected, we may have to wait for that MASTER to finish issuing RESET,
+ * configuration and INITIALIZE commands. Also, there's a possibility that
+ * our own HELLO may get lost if it happens right as the MASTER is issuign a
+ * RESET command, so we need to be willing to make a few retries of our HELLO.
+ */
+#define FW_CMD_HELLO_TIMEOUT (3 * FW_CMD_MAX_TIMEOUT)
+#define FW_CMD_HELLO_RETRIES 3
+
+
+enum fw_cmd_opcodes {
+ FW_LDST_CMD = 0x01,
+ FW_RESET_CMD = 0x03,
+ FW_HELLO_CMD = 0x04,
+ FW_BYE_CMD = 0x05,
+ FW_INITIALIZE_CMD = 0x06,
+ FW_CAPS_CONFIG_CMD = 0x07,
+ FW_PARAMS_CMD = 0x08,
+ FW_PFVF_CMD = 0x09,
+ FW_IQ_CMD = 0x10,
+ FW_EQ_MNGT_CMD = 0x11,
+ FW_EQ_ETH_CMD = 0x12,
+ FW_EQ_CTRL_CMD = 0x13,
+ FW_EQ_OFLD_CMD = 0x21,
+ FW_VI_CMD = 0x14,
+ FW_VI_MAC_CMD = 0x15,
+ FW_VI_RXMODE_CMD = 0x16,
+ FW_VI_ENABLE_CMD = 0x17,
+ FW_ACL_MAC_CMD = 0x18,
+ FW_ACL_VLAN_CMD = 0x19,
+ FW_VI_STATS_CMD = 0x1a,
+ FW_PORT_CMD = 0x1b,
+ FW_PORT_STATS_CMD = 0x1c,
+ FW_PORT_LB_STATS_CMD = 0x1d,
+ FW_PORT_TRACE_CMD = 0x1e,
+ FW_PORT_TRACE_MMAP_CMD = 0x1f,
+ FW_RSS_IND_TBL_CMD = 0x20,
+ FW_RSS_GLB_CONFIG_CMD = 0x22,
+ FW_RSS_VI_CONFIG_CMD = 0x23,
+ FW_DEVLOG_CMD = 0x25,
+ FW_CLIP_CMD = 0x28,
+ FW_LASTC2E_CMD = 0x40,
+ FW_ERROR_CMD = 0x80,
+ FW_DEBUG_CMD = 0x81,
+};
+
+enum fw_cmd_cap {
+ FW_CMD_CAP_PF = 0x01,
+ FW_CMD_CAP_DMAQ = 0x02,
+ FW_CMD_CAP_PORT = 0x04,
+ FW_CMD_CAP_PORTPROMISC = 0x08,
+ FW_CMD_CAP_PORTSTATS = 0x10,
+ FW_CMD_CAP_VF = 0x80,
+};
+
+/*
+ * Generic command header flit0
+ */
+struct fw_cmd_hdr {
+ __be32 hi;
+ __be32 lo;
+};
+
+#define FW_CMD_OP_S 24
+#define FW_CMD_OP_M 0xff
+#define FW_CMD_OP_V(x) ((x) << FW_CMD_OP_S)
+#define FW_CMD_OP_G(x) (((x) >> FW_CMD_OP_S) & FW_CMD_OP_M)
+
+#define FW_CMD_REQUEST_S 23
+#define FW_CMD_REQUEST_V(x) ((x) << FW_CMD_REQUEST_S)
+#define FW_CMD_REQUEST_F FW_CMD_REQUEST_V(1U)
+
+#define FW_CMD_READ_S 22
+#define FW_CMD_READ_V(x) ((x) << FW_CMD_READ_S)
+#define FW_CMD_READ_F FW_CMD_READ_V(1U)
+
+#define FW_CMD_WRITE_S 21
+#define FW_CMD_WRITE_V(x) ((x) << FW_CMD_WRITE_S)
+#define FW_CMD_WRITE_F FW_CMD_WRITE_V(1U)
+
+#define FW_CMD_EXEC_S 20
+#define FW_CMD_EXEC_V(x) ((x) << FW_CMD_EXEC_S)
+#define FW_CMD_EXEC_F FW_CMD_EXEC_V(1U)
+
+#define FW_CMD_RAMASK_S 20
+#define FW_CMD_RAMASK_V(x) ((x) << FW_CMD_RAMASK_S)
+
+#define FW_CMD_RETVAL_S 8
+#define FW_CMD_RETVAL_M 0xff
+#define FW_CMD_RETVAL_V(x) ((x) << FW_CMD_RETVAL_S)
+#define FW_CMD_RETVAL_G(x) (((x) >> FW_CMD_RETVAL_S) & FW_CMD_RETVAL_M)
+
+#define FW_CMD_LEN16_S 0
+#define FW_CMD_LEN16_V(x) ((x) << FW_CMD_LEN16_S)
+
+#define FW_LEN16(fw_struct) FW_CMD_LEN16_V(sizeof(fw_struct) / 16)
+
+enum fw_ldst_addrspc {
+ FW_LDST_ADDRSPC_FIRMWARE = 0x0001,
+ FW_LDST_ADDRSPC_SGE_EGRC = 0x0008,
+ FW_LDST_ADDRSPC_SGE_INGC = 0x0009,
+ FW_LDST_ADDRSPC_SGE_FLMC = 0x000a,
+ FW_LDST_ADDRSPC_SGE_CONMC = 0x000b,
+ FW_LDST_ADDRSPC_TP_PIO = 0x0010,
+ FW_LDST_ADDRSPC_TP_TM_PIO = 0x0011,
+ FW_LDST_ADDRSPC_TP_MIB = 0x0012,
+ FW_LDST_ADDRSPC_MDIO = 0x0018,
+ FW_LDST_ADDRSPC_MPS = 0x0020,
+ FW_LDST_ADDRSPC_FUNC = 0x0028,
+ FW_LDST_ADDRSPC_FUNC_PCIE = 0x0029,
+};
+
+enum fw_ldst_mps_fid {
+ FW_LDST_MPS_ATRB,
+ FW_LDST_MPS_RPLC
+};
+
+enum fw_ldst_func_access_ctl {
+ FW_LDST_FUNC_ACC_CTL_VIID,
+ FW_LDST_FUNC_ACC_CTL_FID
+};
+
+enum fw_ldst_func_mod_index {
+ FW_LDST_FUNC_MPS
+};
+
+struct fw_ldst_cmd {
+ __be32 op_to_addrspace;
+ __be32 cycles_to_len16;
+ union fw_ldst {
+ struct fw_ldst_addrval {
+ __be32 addr;
+ __be32 val;
+ } addrval;
+ struct fw_ldst_idctxt {
+ __be32 physid;
+ __be32 msg_ctxtflush;
+ __be32 ctxt_data7;
+ __be32 ctxt_data6;
+ __be32 ctxt_data5;
+ __be32 ctxt_data4;
+ __be32 ctxt_data3;
+ __be32 ctxt_data2;
+ __be32 ctxt_data1;
+ __be32 ctxt_data0;
+ } idctxt;
+ struct fw_ldst_mdio {
+ __be16 paddr_mmd;
+ __be16 raddr;
+ __be16 vctl;
+ __be16 rval;
+ } mdio;
+ struct fw_ldst_cim_rq {
+ u8 req_first64[8];
+ u8 req_second64[8];
+ u8 resp_first64[8];
+ u8 resp_second64[8];
+ __be32 r3[2];
+ } cim_rq;
+ union fw_ldst_mps {
+ struct fw_ldst_mps_rplc {
+ __be16 fid_idx;
+ __be16 rplcpf_pkd;
+ __be32 rplc255_224;
+ __be32 rplc223_192;
+ __be32 rplc191_160;
+ __be32 rplc159_128;
+ __be32 rplc127_96;
+ __be32 rplc95_64;
+ __be32 rplc63_32;
+ __be32 rplc31_0;
+ } rplc;
+ struct fw_ldst_mps_atrb {
+ __be16 fid_mpsid;
+ __be16 r2[3];
+ __be32 r3[2];
+ __be32 r4;
+ __be32 atrb;
+ __be16 vlan[16];
+ } atrb;
+ } mps;
+ struct fw_ldst_func {
+ u8 access_ctl;
+ u8 mod_index;
+ __be16 ctl_id;
+ __be32 offset;
+ __be64 data0;
+ __be64 data1;
+ } func;
+ struct fw_ldst_pcie {
+ u8 ctrl_to_fn;
+ u8 bnum;
+ u8 r;
+ u8 ext_r;
+ u8 select_naccess;
+ u8 pcie_fn;
+ __be16 nset_pkd;
+ __be32 data[12];
+ } pcie;
+ struct fw_ldst_i2c_deprecated {
+ u8 pid_pkd;
+ u8 base;
+ u8 boffset;
+ u8 data;
+ __be32 r9;
+ } i2c_deprecated;
+ struct fw_ldst_i2c {
+ u8 pid;
+ u8 did;
+ u8 boffset;
+ u8 blen;
+ __be32 r9;
+ __u8 data[48];
+ } i2c;
+ struct fw_ldst_le {
+ __be32 index;
+ __be32 r9;
+ u8 val[33];
+ u8 r11[7];
+ } le;
+ } u;
+};
+
+#define FW_LDST_CMD_ADDRSPACE_S 0
+#define FW_LDST_CMD_ADDRSPACE_V(x) ((x) << FW_LDST_CMD_ADDRSPACE_S)
+
+#define FW_LDST_CMD_MSG_S 31
+#define FW_LDST_CMD_MSG_V(x) ((x) << FW_LDST_CMD_MSG_S)
+
+#define FW_LDST_CMD_CTXTFLUSH_S 30
+#define FW_LDST_CMD_CTXTFLUSH_V(x) ((x) << FW_LDST_CMD_CTXTFLUSH_S)
+#define FW_LDST_CMD_CTXTFLUSH_F FW_LDST_CMD_CTXTFLUSH_V(1U)
+
+#define FW_LDST_CMD_PADDR_S 8
+#define FW_LDST_CMD_PADDR_V(x) ((x) << FW_LDST_CMD_PADDR_S)
+
+#define FW_LDST_CMD_MMD_S 0
+#define FW_LDST_CMD_MMD_V(x) ((x) << FW_LDST_CMD_MMD_S)
+
+#define FW_LDST_CMD_FID_S 15
+#define FW_LDST_CMD_FID_V(x) ((x) << FW_LDST_CMD_FID_S)
+
+#define FW_LDST_CMD_IDX_S 0
+#define FW_LDST_CMD_IDX_V(x) ((x) << FW_LDST_CMD_IDX_S)
+
+#define FW_LDST_CMD_RPLCPF_S 0
+#define FW_LDST_CMD_RPLCPF_V(x) ((x) << FW_LDST_CMD_RPLCPF_S)
+
+#define FW_LDST_CMD_LC_S 4
+#define FW_LDST_CMD_LC_V(x) ((x) << FW_LDST_CMD_LC_S)
+#define FW_LDST_CMD_LC_F FW_LDST_CMD_LC_V(1U)
+
+#define FW_LDST_CMD_FN_S 0
+#define FW_LDST_CMD_FN_V(x) ((x) << FW_LDST_CMD_FN_S)
+
+#define FW_LDST_CMD_NACCESS_S 0
+#define FW_LDST_CMD_NACCESS_V(x) ((x) << FW_LDST_CMD_NACCESS_S)
+
+struct fw_reset_cmd {
+ __be32 op_to_write;
+ __be32 retval_len16;
+ __be32 val;
+ __be32 halt_pkd;
+};
+
+#define FW_RESET_CMD_HALT_S 31
+#define FW_RESET_CMD_HALT_M 0x1
+#define FW_RESET_CMD_HALT_V(x) ((x) << FW_RESET_CMD_HALT_S)
+#define FW_RESET_CMD_HALT_G(x) \
+ (((x) >> FW_RESET_CMD_HALT_S) & FW_RESET_CMD_HALT_M)
+#define FW_RESET_CMD_HALT_F FW_RESET_CMD_HALT_V(1U)
+
+enum fw_hellow_cmd {
+ fw_hello_cmd_stage_os = 0x0
+};
+
+struct fw_hello_cmd {
+ __be32 op_to_write;
+ __be32 retval_len16;
+ __be32 err_to_clearinit;
+ __be32 fwrev;
+};
+
+#define FW_HELLO_CMD_ERR_S 31
+#define FW_HELLO_CMD_ERR_V(x) ((x) << FW_HELLO_CMD_ERR_S)
+#define FW_HELLO_CMD_ERR_F FW_HELLO_CMD_ERR_V(1U)
+
+#define FW_HELLO_CMD_INIT_S 30
+#define FW_HELLO_CMD_INIT_V(x) ((x) << FW_HELLO_CMD_INIT_S)
+#define FW_HELLO_CMD_INIT_F FW_HELLO_CMD_INIT_V(1U)
+
+#define FW_HELLO_CMD_MASTERDIS_S 29
+#define FW_HELLO_CMD_MASTERDIS_V(x) ((x) << FW_HELLO_CMD_MASTERDIS_S)
+
+#define FW_HELLO_CMD_MASTERFORCE_S 28
+#define FW_HELLO_CMD_MASTERFORCE_V(x) ((x) << FW_HELLO_CMD_MASTERFORCE_S)
+
+#define FW_HELLO_CMD_MBMASTER_S 24
+#define FW_HELLO_CMD_MBMASTER_M 0xfU
+#define FW_HELLO_CMD_MBMASTER_V(x) ((x) << FW_HELLO_CMD_MBMASTER_S)
+#define FW_HELLO_CMD_MBMASTER_G(x) \
+ (((x) >> FW_HELLO_CMD_MBMASTER_S) & FW_HELLO_CMD_MBMASTER_M)
+
+#define FW_HELLO_CMD_MBASYNCNOTINT_S 23
+#define FW_HELLO_CMD_MBASYNCNOTINT_V(x) ((x) << FW_HELLO_CMD_MBASYNCNOTINT_S)
+
+#define FW_HELLO_CMD_MBASYNCNOT_S 20
+#define FW_HELLO_CMD_MBASYNCNOT_V(x) ((x) << FW_HELLO_CMD_MBASYNCNOT_S)
+
+#define FW_HELLO_CMD_STAGE_S 17
+#define FW_HELLO_CMD_STAGE_V(x) ((x) << FW_HELLO_CMD_STAGE_S)
+
+#define FW_HELLO_CMD_CLEARINIT_S 16
+#define FW_HELLO_CMD_CLEARINIT_V(x) ((x) << FW_HELLO_CMD_CLEARINIT_S)
+#define FW_HELLO_CMD_CLEARINIT_F FW_HELLO_CMD_CLEARINIT_V(1U)
+
+struct fw_bye_cmd {
+ __be32 op_to_write;
+ __be32 retval_len16;
+ __be64 r3;
+};
+
+struct fw_initialize_cmd {
+ __be32 op_to_write;
+ __be32 retval_len16;
+ __be64 r3;
+};
+
+enum fw_caps_config_hm {
+ FW_CAPS_CONFIG_HM_PCIE = 0x00000001,
+ FW_CAPS_CONFIG_HM_PL = 0x00000002,
+ FW_CAPS_CONFIG_HM_SGE = 0x00000004,
+ FW_CAPS_CONFIG_HM_CIM = 0x00000008,
+ FW_CAPS_CONFIG_HM_ULPTX = 0x00000010,
+ FW_CAPS_CONFIG_HM_TP = 0x00000020,
+ FW_CAPS_CONFIG_HM_ULPRX = 0x00000040,
+ FW_CAPS_CONFIG_HM_PMRX = 0x00000080,
+ FW_CAPS_CONFIG_HM_PMTX = 0x00000100,
+ FW_CAPS_CONFIG_HM_MC = 0x00000200,
+ FW_CAPS_CONFIG_HM_LE = 0x00000400,
+ FW_CAPS_CONFIG_HM_MPS = 0x00000800,
+ FW_CAPS_CONFIG_HM_XGMAC = 0x00001000,
+ FW_CAPS_CONFIG_HM_CPLSWITCH = 0x00002000,
+ FW_CAPS_CONFIG_HM_T4DBG = 0x00004000,
+ FW_CAPS_CONFIG_HM_MI = 0x00008000,
+ FW_CAPS_CONFIG_HM_I2CM = 0x00010000,
+ FW_CAPS_CONFIG_HM_NCSI = 0x00020000,
+ FW_CAPS_CONFIG_HM_SMB = 0x00040000,
+ FW_CAPS_CONFIG_HM_MA = 0x00080000,
+ FW_CAPS_CONFIG_HM_EDRAM = 0x00100000,
+ FW_CAPS_CONFIG_HM_PMU = 0x00200000,
+ FW_CAPS_CONFIG_HM_UART = 0x00400000,
+ FW_CAPS_CONFIG_HM_SF = 0x00800000,
+};
+
+enum fw_caps_config_nbm {
+ FW_CAPS_CONFIG_NBM_IPMI = 0x00000001,
+ FW_CAPS_CONFIG_NBM_NCSI = 0x00000002,
+};
+
+enum fw_caps_config_link {
+ FW_CAPS_CONFIG_LINK_PPP = 0x00000001,
+ FW_CAPS_CONFIG_LINK_QFC = 0x00000002,
+ FW_CAPS_CONFIG_LINK_DCBX = 0x00000004,
+};
+
+enum fw_caps_config_switch {
+ FW_CAPS_CONFIG_SWITCH_INGRESS = 0x00000001,
+ FW_CAPS_CONFIG_SWITCH_EGRESS = 0x00000002,
+};
+
+enum fw_caps_config_nic {
+ FW_CAPS_CONFIG_NIC = 0x00000001,
+ FW_CAPS_CONFIG_NIC_VM = 0x00000002,
+};
+
+enum fw_caps_config_ofld {
+ FW_CAPS_CONFIG_OFLD = 0x00000001,
+};
+
+enum fw_caps_config_rdma {
+ FW_CAPS_CONFIG_RDMA_RDDP = 0x00000001,
+ FW_CAPS_CONFIG_RDMA_RDMAC = 0x00000002,
+};
+
+enum fw_caps_config_iscsi {
+ FW_CAPS_CONFIG_ISCSI_INITIATOR_PDU = 0x00000001,
+ FW_CAPS_CONFIG_ISCSI_TARGET_PDU = 0x00000002,
+ FW_CAPS_CONFIG_ISCSI_INITIATOR_CNXOFLD = 0x00000004,
+ FW_CAPS_CONFIG_ISCSI_TARGET_CNXOFLD = 0x00000008,
+};
+
+enum fw_caps_config_fcoe {
+ FW_CAPS_CONFIG_FCOE_INITIATOR = 0x00000001,
+ FW_CAPS_CONFIG_FCOE_TARGET = 0x00000002,
+ FW_CAPS_CONFIG_FCOE_CTRL_OFLD = 0x00000004,
+};
+
+enum fw_memtype_cf {
+ FW_MEMTYPE_CF_EDC0 = 0x0,
+ FW_MEMTYPE_CF_EDC1 = 0x1,
+ FW_MEMTYPE_CF_EXTMEM = 0x2,
+ FW_MEMTYPE_CF_FLASH = 0x4,
+ FW_MEMTYPE_CF_INTERNAL = 0x5,
+ FW_MEMTYPE_CF_EXTMEM1 = 0x6,
+};
+
+struct fw_caps_config_cmd {
+ __be32 op_to_write;
+ __be32 cfvalid_to_len16;
+ __be32 r2;
+ __be32 hwmbitmap;
+ __be16 nbmcaps;
+ __be16 linkcaps;
+ __be16 switchcaps;
+ __be16 r3;
+ __be16 niccaps;
+ __be16 ofldcaps;
+ __be16 rdmacaps;
+ __be16 r4;
+ __be16 iscsicaps;
+ __be16 fcoecaps;
+ __be32 cfcsum;
+ __be32 finiver;
+ __be32 finicsum;
+};
+
+#define FW_CAPS_CONFIG_CMD_CFVALID_S 27
+#define FW_CAPS_CONFIG_CMD_CFVALID_V(x) ((x) << FW_CAPS_CONFIG_CMD_CFVALID_S)
+#define FW_CAPS_CONFIG_CMD_CFVALID_F FW_CAPS_CONFIG_CMD_CFVALID_V(1U)
+
+#define FW_CAPS_CONFIG_CMD_MEMTYPE_CF_S 24
+#define FW_CAPS_CONFIG_CMD_MEMTYPE_CF_V(x) \
+ ((x) << FW_CAPS_CONFIG_CMD_MEMTYPE_CF_S)
+
+#define FW_CAPS_CONFIG_CMD_MEMADDR64K_CF_S 16
+#define FW_CAPS_CONFIG_CMD_MEMADDR64K_CF_V(x) \
+ ((x) << FW_CAPS_CONFIG_CMD_MEMADDR64K_CF_S)
+
+/*
+ * params command mnemonics
+ */
+enum fw_params_mnem {
+ FW_PARAMS_MNEM_DEV = 1, /* device params */
+ FW_PARAMS_MNEM_PFVF = 2, /* function params */
+ FW_PARAMS_MNEM_REG = 3, /* limited register access */
+ FW_PARAMS_MNEM_DMAQ = 4, /* dma queue params */
+ FW_PARAMS_MNEM_CHNET = 5, /* chnet params */
+ FW_PARAMS_MNEM_LAST
+};
+
+/*
+ * device parameters
+ */
+enum fw_params_param_dev {
+ FW_PARAMS_PARAM_DEV_CCLK = 0x00, /* chip core clock in khz */
+ FW_PARAMS_PARAM_DEV_PORTVEC = 0x01, /* the port vector */
+ FW_PARAMS_PARAM_DEV_NTID = 0x02, /* reads the number of TIDs
+ * allocated by the device's
+ * Lookup Engine
+ */
+ FW_PARAMS_PARAM_DEV_FLOWC_BUFFIFO_SZ = 0x03,
+ FW_PARAMS_PARAM_DEV_INTVER_NIC = 0x04,
+ FW_PARAMS_PARAM_DEV_INTVER_VNIC = 0x05,
+ FW_PARAMS_PARAM_DEV_INTVER_OFLD = 0x06,
+ FW_PARAMS_PARAM_DEV_INTVER_RI = 0x07,
+ FW_PARAMS_PARAM_DEV_INTVER_ISCSIPDU = 0x08,
+ FW_PARAMS_PARAM_DEV_INTVER_ISCSI = 0x09,
+ FW_PARAMS_PARAM_DEV_INTVER_FCOE = 0x0A,
+ FW_PARAMS_PARAM_DEV_FWREV = 0x0B,
+ FW_PARAMS_PARAM_DEV_TPREV = 0x0C,
+ FW_PARAMS_PARAM_DEV_CF = 0x0D,
+ FW_PARAMS_PARAM_DEV_PHYFW = 0x0F,
+ FW_PARAMS_PARAM_DEV_DIAG = 0x11,
+ FW_PARAMS_PARAM_DEV_MAXORDIRD_QP = 0x13, /* max supported QP IRD/ORD */
+ FW_PARAMS_PARAM_DEV_MAXIRD_ADAPTER = 0x14, /* max supported adap IRD */
+ FW_PARAMS_PARAM_DEV_ULPTX_MEMWRITE_DSGL = 0x17,
+ FW_PARAMS_PARAM_DEV_FWCACHE = 0x18,
+};
+
+/*
+ * physical and virtual function parameters
+ */
+enum fw_params_param_pfvf {
+ FW_PARAMS_PARAM_PFVF_RWXCAPS = 0x00,
+ FW_PARAMS_PARAM_PFVF_ROUTE_START = 0x01,
+ FW_PARAMS_PARAM_PFVF_ROUTE_END = 0x02,
+ FW_PARAMS_PARAM_PFVF_CLIP_START = 0x03,
+ FW_PARAMS_PARAM_PFVF_CLIP_END = 0x04,
+ FW_PARAMS_PARAM_PFVF_FILTER_START = 0x05,
+ FW_PARAMS_PARAM_PFVF_FILTER_END = 0x06,
+ FW_PARAMS_PARAM_PFVF_SERVER_START = 0x07,
+ FW_PARAMS_PARAM_PFVF_SERVER_END = 0x08,
+ FW_PARAMS_PARAM_PFVF_TDDP_START = 0x09,
+ FW_PARAMS_PARAM_PFVF_TDDP_END = 0x0A,
+ FW_PARAMS_PARAM_PFVF_ISCSI_START = 0x0B,
+ FW_PARAMS_PARAM_PFVF_ISCSI_END = 0x0C,
+ FW_PARAMS_PARAM_PFVF_STAG_START = 0x0D,
+ FW_PARAMS_PARAM_PFVF_STAG_END = 0x0E,
+ FW_PARAMS_PARAM_PFVF_RQ_START = 0x1F,
+ FW_PARAMS_PARAM_PFVF_RQ_END = 0x10,
+ FW_PARAMS_PARAM_PFVF_PBL_START = 0x11,
+ FW_PARAMS_PARAM_PFVF_PBL_END = 0x12,
+ FW_PARAMS_PARAM_PFVF_L2T_START = 0x13,
+ FW_PARAMS_PARAM_PFVF_L2T_END = 0x14,
+ FW_PARAMS_PARAM_PFVF_SQRQ_START = 0x15,
+ FW_PARAMS_PARAM_PFVF_SQRQ_END = 0x16,
+ FW_PARAMS_PARAM_PFVF_CQ_START = 0x17,
+ FW_PARAMS_PARAM_PFVF_CQ_END = 0x18,
+ FW_PARAMS_PARAM_PFVF_SCHEDCLASS_ETH = 0x20,
+ FW_PARAMS_PARAM_PFVF_VIID = 0x24,
+ FW_PARAMS_PARAM_PFVF_CPMASK = 0x25,
+ FW_PARAMS_PARAM_PFVF_OCQ_START = 0x26,
+ FW_PARAMS_PARAM_PFVF_OCQ_END = 0x27,
+ FW_PARAMS_PARAM_PFVF_CONM_MAP = 0x28,
+ FW_PARAMS_PARAM_PFVF_IQFLINT_START = 0x29,
+ FW_PARAMS_PARAM_PFVF_IQFLINT_END = 0x2A,
+ FW_PARAMS_PARAM_PFVF_EQ_START = 0x2B,
+ FW_PARAMS_PARAM_PFVF_EQ_END = 0x2C,
+ FW_PARAMS_PARAM_PFVF_ACTIVE_FILTER_START = 0x2D,
+ FW_PARAMS_PARAM_PFVF_ACTIVE_FILTER_END = 0x2E,
+ FW_PARAMS_PARAM_PFVF_ETHOFLD_END = 0x30,
+ FW_PARAMS_PARAM_PFVF_CPLFW4MSG_ENCAP = 0x31
+};
+
+/*
+ * dma queue parameters
+ */
+enum fw_params_param_dmaq {
+ FW_PARAMS_PARAM_DMAQ_IQ_DCAEN_DCACPU = 0x00,
+ FW_PARAMS_PARAM_DMAQ_IQ_INTCNTTHRESH = 0x01,
+ FW_PARAMS_PARAM_DMAQ_EQ_CMPLIQID_MNGT = 0x10,
+ FW_PARAMS_PARAM_DMAQ_EQ_CMPLIQID_CTRL = 0x11,
+ FW_PARAMS_PARAM_DMAQ_EQ_SCHEDCLASS_ETH = 0x12,
+ FW_PARAMS_PARAM_DMAQ_EQ_DCBPRIO_ETH = 0x13,
+ FW_PARAMS_PARAM_DMAQ_CONM_CTXT = 0x20,
+};
+
+enum fw_params_param_dev_phyfw {
+ FW_PARAMS_PARAM_DEV_PHYFW_DOWNLOAD = 0x00,
+ FW_PARAMS_PARAM_DEV_PHYFW_VERSION = 0x01,
+};
+
+enum fw_params_param_dev_diag {
+ FW_PARAM_DEV_DIAG_TMP = 0x00,
+ FW_PARAM_DEV_DIAG_VDD = 0x01,
+};
+
+enum fw_params_param_dev_fwcache {
+ FW_PARAM_DEV_FWCACHE_FLUSH = 0x00,
+ FW_PARAM_DEV_FWCACHE_FLUSHINV = 0x01,
+};
+
+#define FW_PARAMS_MNEM_S 24
+#define FW_PARAMS_MNEM_V(x) ((x) << FW_PARAMS_MNEM_S)
+
+#define FW_PARAMS_PARAM_X_S 16
+#define FW_PARAMS_PARAM_X_V(x) ((x) << FW_PARAMS_PARAM_X_S)
+
+#define FW_PARAMS_PARAM_Y_S 8
+#define FW_PARAMS_PARAM_Y_M 0xffU
+#define FW_PARAMS_PARAM_Y_V(x) ((x) << FW_PARAMS_PARAM_Y_S)
+#define FW_PARAMS_PARAM_Y_G(x) (((x) >> FW_PARAMS_PARAM_Y_S) &\
+ FW_PARAMS_PARAM_Y_M)
+
+#define FW_PARAMS_PARAM_Z_S 0
+#define FW_PARAMS_PARAM_Z_M 0xffu
+#define FW_PARAMS_PARAM_Z_V(x) ((x) << FW_PARAMS_PARAM_Z_S)
+#define FW_PARAMS_PARAM_Z_G(x) (((x) >> FW_PARAMS_PARAM_Z_S) &\
+ FW_PARAMS_PARAM_Z_M)
+
+#define FW_PARAMS_PARAM_XYZ_S 0
+#define FW_PARAMS_PARAM_XYZ_V(x) ((x) << FW_PARAMS_PARAM_XYZ_S)
+
+#define FW_PARAMS_PARAM_YZ_S 0
+#define FW_PARAMS_PARAM_YZ_V(x) ((x) << FW_PARAMS_PARAM_YZ_S)
+
+struct fw_params_cmd {
+ __be32 op_to_vfn;
+ __be32 retval_len16;
+ struct fw_params_param {
+ __be32 mnem;
+ __be32 val;
+ } param[7];
+};
+
+#define FW_PARAMS_CMD_PFN_S 8
+#define FW_PARAMS_CMD_PFN_V(x) ((x) << FW_PARAMS_CMD_PFN_S)
+
+#define FW_PARAMS_CMD_VFN_S 0
+#define FW_PARAMS_CMD_VFN_V(x) ((x) << FW_PARAMS_CMD_VFN_S)
+
+struct fw_pfvf_cmd {
+ __be32 op_to_vfn;
+ __be32 retval_len16;
+ __be32 niqflint_niq;
+ __be32 type_to_neq;
+ __be32 tc_to_nexactf;
+ __be32 r_caps_to_nethctrl;
+ __be16 nricq;
+ __be16 nriqp;
+ __be32 r4;
+};
+
+#define FW_PFVF_CMD_PFN_S 8
+#define FW_PFVF_CMD_PFN_V(x) ((x) << FW_PFVF_CMD_PFN_S)
+
+#define FW_PFVF_CMD_VFN_S 0
+#define FW_PFVF_CMD_VFN_V(x) ((x) << FW_PFVF_CMD_VFN_S)
+
+#define FW_PFVF_CMD_NIQFLINT_S 20
+#define FW_PFVF_CMD_NIQFLINT_M 0xfff
+#define FW_PFVF_CMD_NIQFLINT_V(x) ((x) << FW_PFVF_CMD_NIQFLINT_S)
+#define FW_PFVF_CMD_NIQFLINT_G(x) \
+ (((x) >> FW_PFVF_CMD_NIQFLINT_S) & FW_PFVF_CMD_NIQFLINT_M)
+
+#define FW_PFVF_CMD_NIQ_S 0
+#define FW_PFVF_CMD_NIQ_M 0xfffff
+#define FW_PFVF_CMD_NIQ_V(x) ((x) << FW_PFVF_CMD_NIQ_S)
+#define FW_PFVF_CMD_NIQ_G(x) \
+ (((x) >> FW_PFVF_CMD_NIQ_S) & FW_PFVF_CMD_NIQ_M)
+
+#define FW_PFVF_CMD_TYPE_S 31
+#define FW_PFVF_CMD_TYPE_M 0x1
+#define FW_PFVF_CMD_TYPE_V(x) ((x) << FW_PFVF_CMD_TYPE_S)
+#define FW_PFVF_CMD_TYPE_G(x) \
+ (((x) >> FW_PFVF_CMD_TYPE_S) & FW_PFVF_CMD_TYPE_M)
+#define FW_PFVF_CMD_TYPE_F FW_PFVF_CMD_TYPE_V(1U)
+
+#define FW_PFVF_CMD_CMASK_S 24
+#define FW_PFVF_CMD_CMASK_M 0xf
+#define FW_PFVF_CMD_CMASK_V(x) ((x) << FW_PFVF_CMD_CMASK_S)
+#define FW_PFVF_CMD_CMASK_G(x) \
+ (((x) >> FW_PFVF_CMD_CMASK_S) & FW_PFVF_CMD_CMASK_M)
+
+#define FW_PFVF_CMD_PMASK_S 20
+#define FW_PFVF_CMD_PMASK_M 0xf
+#define FW_PFVF_CMD_PMASK_V(x) ((x) << FW_PFVF_CMD_PMASK_S)
+#define FW_PFVF_CMD_PMASK_G(x) \
+ (((x) >> FW_PFVF_CMD_PMASK_S) & FW_PFVF_CMD_PMASK_M)
+
+#define FW_PFVF_CMD_NEQ_S 0
+#define FW_PFVF_CMD_NEQ_M 0xfffff
+#define FW_PFVF_CMD_NEQ_V(x) ((x) << FW_PFVF_CMD_NEQ_S)
+#define FW_PFVF_CMD_NEQ_G(x) \
+ (((x) >> FW_PFVF_CMD_NEQ_S) & FW_PFVF_CMD_NEQ_M)
+
+#define FW_PFVF_CMD_TC_S 24
+#define FW_PFVF_CMD_TC_M 0xff
+#define FW_PFVF_CMD_TC_V(x) ((x) << FW_PFVF_CMD_TC_S)
+#define FW_PFVF_CMD_TC_G(x) (((x) >> FW_PFVF_CMD_TC_S) & FW_PFVF_CMD_TC_M)
+
+#define FW_PFVF_CMD_NVI_S 16
+#define FW_PFVF_CMD_NVI_M 0xff
+#define FW_PFVF_CMD_NVI_V(x) ((x) << FW_PFVF_CMD_NVI_S)
+#define FW_PFVF_CMD_NVI_G(x) (((x) >> FW_PFVF_CMD_NVI_S) & FW_PFVF_CMD_NVI_M)
+
+#define FW_PFVF_CMD_NEXACTF_S 0
+#define FW_PFVF_CMD_NEXACTF_M 0xffff
+#define FW_PFVF_CMD_NEXACTF_V(x) ((x) << FW_PFVF_CMD_NEXACTF_S)
+#define FW_PFVF_CMD_NEXACTF_G(x) \
+ (((x) >> FW_PFVF_CMD_NEXACTF_S) & FW_PFVF_CMD_NEXACTF_M)
+
+#define FW_PFVF_CMD_R_CAPS_S 24
+#define FW_PFVF_CMD_R_CAPS_M 0xff
+#define FW_PFVF_CMD_R_CAPS_V(x) ((x) << FW_PFVF_CMD_R_CAPS_S)
+#define FW_PFVF_CMD_R_CAPS_G(x) \
+ (((x) >> FW_PFVF_CMD_R_CAPS_S) & FW_PFVF_CMD_R_CAPS_M)
+
+#define FW_PFVF_CMD_WX_CAPS_S 16
+#define FW_PFVF_CMD_WX_CAPS_M 0xff
+#define FW_PFVF_CMD_WX_CAPS_V(x) ((x) << FW_PFVF_CMD_WX_CAPS_S)
+#define FW_PFVF_CMD_WX_CAPS_G(x) \
+ (((x) >> FW_PFVF_CMD_WX_CAPS_S) & FW_PFVF_CMD_WX_CAPS_M)
+
+#define FW_PFVF_CMD_NETHCTRL_S 0
+#define FW_PFVF_CMD_NETHCTRL_M 0xffff
+#define FW_PFVF_CMD_NETHCTRL_V(x) ((x) << FW_PFVF_CMD_NETHCTRL_S)
+#define FW_PFVF_CMD_NETHCTRL_G(x) \
+ (((x) >> FW_PFVF_CMD_NETHCTRL_S) & FW_PFVF_CMD_NETHCTRL_M)
+
+enum fw_iq_type {
+ FW_IQ_TYPE_FL_INT_CAP,
+ FW_IQ_TYPE_NO_FL_INT_CAP
+};
+
+struct fw_iq_cmd {
+ __be32 op_to_vfn;
+ __be32 alloc_to_len16;
+ __be16 physiqid;
+ __be16 iqid;
+ __be16 fl0id;
+ __be16 fl1id;
+ __be32 type_to_iqandstindex;
+ __be16 iqdroprss_to_iqesize;
+ __be16 iqsize;
+ __be64 iqaddr;
+ __be32 iqns_to_fl0congen;
+ __be16 fl0dcaen_to_fl0cidxfthresh;
+ __be16 fl0size;
+ __be64 fl0addr;
+ __be32 fl1cngchmap_to_fl1congen;
+ __be16 fl1dcaen_to_fl1cidxfthresh;
+ __be16 fl1size;
+ __be64 fl1addr;
+};
+
+#define FW_IQ_CMD_PFN_S 8
+#define FW_IQ_CMD_PFN_V(x) ((x) << FW_IQ_CMD_PFN_S)
+
+#define FW_IQ_CMD_VFN_S 0
+#define FW_IQ_CMD_VFN_V(x) ((x) << FW_IQ_CMD_VFN_S)
+
+#define FW_IQ_CMD_ALLOC_S 31
+#define FW_IQ_CMD_ALLOC_V(x) ((x) << FW_IQ_CMD_ALLOC_S)
+#define FW_IQ_CMD_ALLOC_F FW_IQ_CMD_ALLOC_V(1U)
+
+#define FW_IQ_CMD_FREE_S 30
+#define FW_IQ_CMD_FREE_V(x) ((x) << FW_IQ_CMD_FREE_S)
+#define FW_IQ_CMD_FREE_F FW_IQ_CMD_FREE_V(1U)
+
+#define FW_IQ_CMD_MODIFY_S 29
+#define FW_IQ_CMD_MODIFY_V(x) ((x) << FW_IQ_CMD_MODIFY_S)
+#define FW_IQ_CMD_MODIFY_F FW_IQ_CMD_MODIFY_V(1U)
+
+#define FW_IQ_CMD_IQSTART_S 28
+#define FW_IQ_CMD_IQSTART_V(x) ((x) << FW_IQ_CMD_IQSTART_S)
+#define FW_IQ_CMD_IQSTART_F FW_IQ_CMD_IQSTART_V(1U)
+
+#define FW_IQ_CMD_IQSTOP_S 27
+#define FW_IQ_CMD_IQSTOP_V(x) ((x) << FW_IQ_CMD_IQSTOP_S)
+#define FW_IQ_CMD_IQSTOP_F FW_IQ_CMD_IQSTOP_V(1U)
+
+#define FW_IQ_CMD_TYPE_S 29
+#define FW_IQ_CMD_TYPE_V(x) ((x) << FW_IQ_CMD_TYPE_S)
+
+#define FW_IQ_CMD_IQASYNCH_S 28
+#define FW_IQ_CMD_IQASYNCH_V(x) ((x) << FW_IQ_CMD_IQASYNCH_S)
+
+#define FW_IQ_CMD_VIID_S 16
+#define FW_IQ_CMD_VIID_V(x) ((x) << FW_IQ_CMD_VIID_S)
+
+#define FW_IQ_CMD_IQANDST_S 15
+#define FW_IQ_CMD_IQANDST_V(x) ((x) << FW_IQ_CMD_IQANDST_S)
+
+#define FW_IQ_CMD_IQANUS_S 14
+#define FW_IQ_CMD_IQANUS_V(x) ((x) << FW_IQ_CMD_IQANUS_S)
+
+#define FW_IQ_CMD_IQANUD_S 12
+#define FW_IQ_CMD_IQANUD_V(x) ((x) << FW_IQ_CMD_IQANUD_S)
+
+#define FW_IQ_CMD_IQANDSTINDEX_S 0
+#define FW_IQ_CMD_IQANDSTINDEX_V(x) ((x) << FW_IQ_CMD_IQANDSTINDEX_S)
+
+#define FW_IQ_CMD_IQDROPRSS_S 15
+#define FW_IQ_CMD_IQDROPRSS_V(x) ((x) << FW_IQ_CMD_IQDROPRSS_S)
+#define FW_IQ_CMD_IQDROPRSS_F FW_IQ_CMD_IQDROPRSS_V(1U)
+
+#define FW_IQ_CMD_IQGTSMODE_S 14
+#define FW_IQ_CMD_IQGTSMODE_V(x) ((x) << FW_IQ_CMD_IQGTSMODE_S)
+#define FW_IQ_CMD_IQGTSMODE_F FW_IQ_CMD_IQGTSMODE_V(1U)
+
+#define FW_IQ_CMD_IQPCIECH_S 12
+#define FW_IQ_CMD_IQPCIECH_V(x) ((x) << FW_IQ_CMD_IQPCIECH_S)
+
+#define FW_IQ_CMD_IQDCAEN_S 11
+#define FW_IQ_CMD_IQDCAEN_V(x) ((x) << FW_IQ_CMD_IQDCAEN_S)
+
+#define FW_IQ_CMD_IQDCACPU_S 6
+#define FW_IQ_CMD_IQDCACPU_V(x) ((x) << FW_IQ_CMD_IQDCACPU_S)
+
+#define FW_IQ_CMD_IQINTCNTTHRESH_S 4
+#define FW_IQ_CMD_IQINTCNTTHRESH_V(x) ((x) << FW_IQ_CMD_IQINTCNTTHRESH_S)
+
+#define FW_IQ_CMD_IQO_S 3
+#define FW_IQ_CMD_IQO_V(x) ((x) << FW_IQ_CMD_IQO_S)
+#define FW_IQ_CMD_IQO_F FW_IQ_CMD_IQO_V(1U)
+
+#define FW_IQ_CMD_IQCPRIO_S 2
+#define FW_IQ_CMD_IQCPRIO_V(x) ((x) << FW_IQ_CMD_IQCPRIO_S)
+
+#define FW_IQ_CMD_IQESIZE_S 0
+#define FW_IQ_CMD_IQESIZE_V(x) ((x) << FW_IQ_CMD_IQESIZE_S)
+
+#define FW_IQ_CMD_IQNS_S 31
+#define FW_IQ_CMD_IQNS_V(x) ((x) << FW_IQ_CMD_IQNS_S)
+
+#define FW_IQ_CMD_IQRO_S 30
+#define FW_IQ_CMD_IQRO_V(x) ((x) << FW_IQ_CMD_IQRO_S)
+
+#define FW_IQ_CMD_IQFLINTIQHSEN_S 28
+#define FW_IQ_CMD_IQFLINTIQHSEN_V(x) ((x) << FW_IQ_CMD_IQFLINTIQHSEN_S)
+
+#define FW_IQ_CMD_IQFLINTCONGEN_S 27
+#define FW_IQ_CMD_IQFLINTCONGEN_V(x) ((x) << FW_IQ_CMD_IQFLINTCONGEN_S)
+#define FW_IQ_CMD_IQFLINTCONGEN_F FW_IQ_CMD_IQFLINTCONGEN_V(1U)
+
+#define FW_IQ_CMD_IQFLINTISCSIC_S 26
+#define FW_IQ_CMD_IQFLINTISCSIC_V(x) ((x) << FW_IQ_CMD_IQFLINTISCSIC_S)
+
+#define FW_IQ_CMD_FL0CNGCHMAP_S 20
+#define FW_IQ_CMD_FL0CNGCHMAP_V(x) ((x) << FW_IQ_CMD_FL0CNGCHMAP_S)
+
+#define FW_IQ_CMD_FL0CACHELOCK_S 15
+#define FW_IQ_CMD_FL0CACHELOCK_V(x) ((x) << FW_IQ_CMD_FL0CACHELOCK_S)
+
+#define FW_IQ_CMD_FL0DBP_S 14
+#define FW_IQ_CMD_FL0DBP_V(x) ((x) << FW_IQ_CMD_FL0DBP_S)
+
+#define FW_IQ_CMD_FL0DATANS_S 13
+#define FW_IQ_CMD_FL0DATANS_V(x) ((x) << FW_IQ_CMD_FL0DATANS_S)
+
+#define FW_IQ_CMD_FL0DATARO_S 12
+#define FW_IQ_CMD_FL0DATARO_V(x) ((x) << FW_IQ_CMD_FL0DATARO_S)
+#define FW_IQ_CMD_FL0DATARO_F FW_IQ_CMD_FL0DATARO_V(1U)
+
+#define FW_IQ_CMD_FL0CONGCIF_S 11
+#define FW_IQ_CMD_FL0CONGCIF_V(x) ((x) << FW_IQ_CMD_FL0CONGCIF_S)
+#define FW_IQ_CMD_FL0CONGCIF_F FW_IQ_CMD_FL0CONGCIF_V(1U)
+
+#define FW_IQ_CMD_FL0ONCHIP_S 10
+#define FW_IQ_CMD_FL0ONCHIP_V(x) ((x) << FW_IQ_CMD_FL0ONCHIP_S)
+
+#define FW_IQ_CMD_FL0STATUSPGNS_S 9
+#define FW_IQ_CMD_FL0STATUSPGNS_V(x) ((x) << FW_IQ_CMD_FL0STATUSPGNS_S)
+
+#define FW_IQ_CMD_FL0STATUSPGRO_S 8
+#define FW_IQ_CMD_FL0STATUSPGRO_V(x) ((x) << FW_IQ_CMD_FL0STATUSPGRO_S)
+
+#define FW_IQ_CMD_FL0FETCHNS_S 7
+#define FW_IQ_CMD_FL0FETCHNS_V(x) ((x) << FW_IQ_CMD_FL0FETCHNS_S)
+
+#define FW_IQ_CMD_FL0FETCHRO_S 6
+#define FW_IQ_CMD_FL0FETCHRO_V(x) ((x) << FW_IQ_CMD_FL0FETCHRO_S)
+#define FW_IQ_CMD_FL0FETCHRO_F FW_IQ_CMD_FL0FETCHRO_V(1U)
+
+#define FW_IQ_CMD_FL0HOSTFCMODE_S 4
+#define FW_IQ_CMD_FL0HOSTFCMODE_V(x) ((x) << FW_IQ_CMD_FL0HOSTFCMODE_S)
+
+#define FW_IQ_CMD_FL0CPRIO_S 3
+#define FW_IQ_CMD_FL0CPRIO_V(x) ((x) << FW_IQ_CMD_FL0CPRIO_S)
+
+#define FW_IQ_CMD_FL0PADEN_S 2
+#define FW_IQ_CMD_FL0PADEN_V(x) ((x) << FW_IQ_CMD_FL0PADEN_S)
+#define FW_IQ_CMD_FL0PADEN_F FW_IQ_CMD_FL0PADEN_V(1U)
+
+#define FW_IQ_CMD_FL0PACKEN_S 1
+#define FW_IQ_CMD_FL0PACKEN_V(x) ((x) << FW_IQ_CMD_FL0PACKEN_S)
+#define FW_IQ_CMD_FL0PACKEN_F FW_IQ_CMD_FL0PACKEN_V(1U)
+
+#define FW_IQ_CMD_FL0CONGEN_S 0
+#define FW_IQ_CMD_FL0CONGEN_V(x) ((x) << FW_IQ_CMD_FL0CONGEN_S)
+#define FW_IQ_CMD_FL0CONGEN_F FW_IQ_CMD_FL0CONGEN_V(1U)
+
+#define FW_IQ_CMD_FL0DCAEN_S 15
+#define FW_IQ_CMD_FL0DCAEN_V(x) ((x) << FW_IQ_CMD_FL0DCAEN_S)
+
+#define FW_IQ_CMD_FL0DCACPU_S 10
+#define FW_IQ_CMD_FL0DCACPU_V(x) ((x) << FW_IQ_CMD_FL0DCACPU_S)
+
+#define FW_IQ_CMD_FL0FBMIN_S 7
+#define FW_IQ_CMD_FL0FBMIN_V(x) ((x) << FW_IQ_CMD_FL0FBMIN_S)
+
+#define FW_IQ_CMD_FL0FBMAX_S 4
+#define FW_IQ_CMD_FL0FBMAX_V(x) ((x) << FW_IQ_CMD_FL0FBMAX_S)
+
+#define FW_IQ_CMD_FL0CIDXFTHRESHO_S 3
+#define FW_IQ_CMD_FL0CIDXFTHRESHO_V(x) ((x) << FW_IQ_CMD_FL0CIDXFTHRESHO_S)
+#define FW_IQ_CMD_FL0CIDXFTHRESHO_F FW_IQ_CMD_FL0CIDXFTHRESHO_V(1U)
+
+#define FW_IQ_CMD_FL0CIDXFTHRESH_S 0
+#define FW_IQ_CMD_FL0CIDXFTHRESH_V(x) ((x) << FW_IQ_CMD_FL0CIDXFTHRESH_S)
+
+#define FW_IQ_CMD_FL1CNGCHMAP_S 20
+#define FW_IQ_CMD_FL1CNGCHMAP_V(x) ((x) << FW_IQ_CMD_FL1CNGCHMAP_S)
+
+#define FW_IQ_CMD_FL1CACHELOCK_S 15
+#define FW_IQ_CMD_FL1CACHELOCK_V(x) ((x) << FW_IQ_CMD_FL1CACHELOCK_S)
+
+#define FW_IQ_CMD_FL1DBP_S 14
+#define FW_IQ_CMD_FL1DBP_V(x) ((x) << FW_IQ_CMD_FL1DBP_S)
+
+#define FW_IQ_CMD_FL1DATANS_S 13
+#define FW_IQ_CMD_FL1DATANS_V(x) ((x) << FW_IQ_CMD_FL1DATANS_S)
+
+#define FW_IQ_CMD_FL1DATARO_S 12
+#define FW_IQ_CMD_FL1DATARO_V(x) ((x) << FW_IQ_CMD_FL1DATARO_S)
+
+#define FW_IQ_CMD_FL1CONGCIF_S 11
+#define FW_IQ_CMD_FL1CONGCIF_V(x) ((x) << FW_IQ_CMD_FL1CONGCIF_S)
+
+#define FW_IQ_CMD_FL1ONCHIP_S 10
+#define FW_IQ_CMD_FL1ONCHIP_V(x) ((x) << FW_IQ_CMD_FL1ONCHIP_S)
+
+#define FW_IQ_CMD_FL1STATUSPGNS_S 9
+#define FW_IQ_CMD_FL1STATUSPGNS_V(x) ((x) << FW_IQ_CMD_FL1STATUSPGNS_S)
+
+#define FW_IQ_CMD_FL1STATUSPGRO_S 8
+#define FW_IQ_CMD_FL1STATUSPGRO_V(x) ((x) << FW_IQ_CMD_FL1STATUSPGRO_S)
+
+#define FW_IQ_CMD_FL1FETCHNS_S 7
+#define FW_IQ_CMD_FL1FETCHNS_V(x) ((x) << FW_IQ_CMD_FL1FETCHNS_S)
+
+#define FW_IQ_CMD_FL1FETCHRO_S 6
+#define FW_IQ_CMD_FL1FETCHRO_V(x) ((x) << FW_IQ_CMD_FL1FETCHRO_S)
+
+#define FW_IQ_CMD_FL1HOSTFCMODE_S 4
+#define FW_IQ_CMD_FL1HOSTFCMODE_V(x) ((x) << FW_IQ_CMD_FL1HOSTFCMODE_S)
+
+#define FW_IQ_CMD_FL1CPRIO_S 3
+#define FW_IQ_CMD_FL1CPRIO_V(x) ((x) << FW_IQ_CMD_FL1CPRIO_S)
+
+#define FW_IQ_CMD_FL1PADEN_S 2
+#define FW_IQ_CMD_FL1PADEN_V(x) ((x) << FW_IQ_CMD_FL1PADEN_S)
+#define FW_IQ_CMD_FL1PADEN_F FW_IQ_CMD_FL1PADEN_V(1U)
+
+#define FW_IQ_CMD_FL1PACKEN_S 1
+#define FW_IQ_CMD_FL1PACKEN_V(x) ((x) << FW_IQ_CMD_FL1PACKEN_S)
+#define FW_IQ_CMD_FL1PACKEN_F FW_IQ_CMD_FL1PACKEN_V(1U)
+
+#define FW_IQ_CMD_FL1CONGEN_S 0
+#define FW_IQ_CMD_FL1CONGEN_V(x) ((x) << FW_IQ_CMD_FL1CONGEN_S)
+#define FW_IQ_CMD_FL1CONGEN_F FW_IQ_CMD_FL1CONGEN_V(1U)
+
+#define FW_IQ_CMD_FL1DCAEN_S 15
+#define FW_IQ_CMD_FL1DCAEN_V(x) ((x) << FW_IQ_CMD_FL1DCAEN_S)
+
+#define FW_IQ_CMD_FL1DCACPU_S 10
+#define FW_IQ_CMD_FL1DCACPU_V(x) ((x) << FW_IQ_CMD_FL1DCACPU_S)
+
+#define FW_IQ_CMD_FL1FBMIN_S 7
+#define FW_IQ_CMD_FL1FBMIN_V(x) ((x) << FW_IQ_CMD_FL1FBMIN_S)
+
+#define FW_IQ_CMD_FL1FBMAX_S 4
+#define FW_IQ_CMD_FL1FBMAX_V(x) ((x) << FW_IQ_CMD_FL1FBMAX_S)
+
+#define FW_IQ_CMD_FL1CIDXFTHRESHO_S 3
+#define FW_IQ_CMD_FL1CIDXFTHRESHO_V(x) ((x) << FW_IQ_CMD_FL1CIDXFTHRESHO_S)
+#define FW_IQ_CMD_FL1CIDXFTHRESHO_F FW_IQ_CMD_FL1CIDXFTHRESHO_V(1U)
+
+#define FW_IQ_CMD_FL1CIDXFTHRESH_S 0
+#define FW_IQ_CMD_FL1CIDXFTHRESH_V(x) ((x) << FW_IQ_CMD_FL1CIDXFTHRESH_S)
+
+struct fw_eq_eth_cmd {
+ __be32 op_to_vfn;
+ __be32 alloc_to_len16;
+ __be32 eqid_pkd;
+ __be32 physeqid_pkd;
+ __be32 fetchszm_to_iqid;
+ __be32 dcaen_to_eqsize;
+ __be64 eqaddr;
+ __be32 viid_pkd;
+ __be32 r8_lo;
+ __be64 r9;
+};
+
+#define FW_EQ_ETH_CMD_PFN_S 8
+#define FW_EQ_ETH_CMD_PFN_V(x) ((x) << FW_EQ_ETH_CMD_PFN_S)
+
+#define FW_EQ_ETH_CMD_VFN_S 0
+#define FW_EQ_ETH_CMD_VFN_V(x) ((x) << FW_EQ_ETH_CMD_VFN_S)
+
+#define FW_EQ_ETH_CMD_ALLOC_S 31
+#define FW_EQ_ETH_CMD_ALLOC_V(x) ((x) << FW_EQ_ETH_CMD_ALLOC_S)
+#define FW_EQ_ETH_CMD_ALLOC_F FW_EQ_ETH_CMD_ALLOC_V(1U)
+
+#define FW_EQ_ETH_CMD_FREE_S 30
+#define FW_EQ_ETH_CMD_FREE_V(x) ((x) << FW_EQ_ETH_CMD_FREE_S)
+#define FW_EQ_ETH_CMD_FREE_F FW_EQ_ETH_CMD_FREE_V(1U)
+
+#define FW_EQ_ETH_CMD_MODIFY_S 29
+#define FW_EQ_ETH_CMD_MODIFY_V(x) ((x) << FW_EQ_ETH_CMD_MODIFY_S)
+#define FW_EQ_ETH_CMD_MODIFY_F FW_EQ_ETH_CMD_MODIFY_V(1U)
+
+#define FW_EQ_ETH_CMD_EQSTART_S 28
+#define FW_EQ_ETH_CMD_EQSTART_V(x) ((x) << FW_EQ_ETH_CMD_EQSTART_S)
+#define FW_EQ_ETH_CMD_EQSTART_F FW_EQ_ETH_CMD_EQSTART_V(1U)
+
+#define FW_EQ_ETH_CMD_EQSTOP_S 27
+#define FW_EQ_ETH_CMD_EQSTOP_V(x) ((x) << FW_EQ_ETH_CMD_EQSTOP_S)
+#define FW_EQ_ETH_CMD_EQSTOP_F FW_EQ_ETH_CMD_EQSTOP_V(1U)
+
+#define FW_EQ_ETH_CMD_EQID_S 0
+#define FW_EQ_ETH_CMD_EQID_M 0xfffff
+#define FW_EQ_ETH_CMD_EQID_V(x) ((x) << FW_EQ_ETH_CMD_EQID_S)
+#define FW_EQ_ETH_CMD_EQID_G(x) \
+ (((x) >> FW_EQ_ETH_CMD_EQID_S) & FW_EQ_ETH_CMD_EQID_M)
+
+#define FW_EQ_ETH_CMD_PHYSEQID_S 0
+#define FW_EQ_ETH_CMD_PHYSEQID_M 0xfffff
+#define FW_EQ_ETH_CMD_PHYSEQID_V(x) ((x) << FW_EQ_ETH_CMD_PHYSEQID_S)
+#define FW_EQ_ETH_CMD_PHYSEQID_G(x) \
+ (((x) >> FW_EQ_ETH_CMD_PHYSEQID_S) & FW_EQ_ETH_CMD_PHYSEQID_M)
+
+#define FW_EQ_ETH_CMD_FETCHSZM_S 26
+#define FW_EQ_ETH_CMD_FETCHSZM_V(x) ((x) << FW_EQ_ETH_CMD_FETCHSZM_S)
+#define FW_EQ_ETH_CMD_FETCHSZM_F FW_EQ_ETH_CMD_FETCHSZM_V(1U)
+
+#define FW_EQ_ETH_CMD_STATUSPGNS_S 25
+#define FW_EQ_ETH_CMD_STATUSPGNS_V(x) ((x) << FW_EQ_ETH_CMD_STATUSPGNS_S)
+
+#define FW_EQ_ETH_CMD_STATUSPGRO_S 24
+#define FW_EQ_ETH_CMD_STATUSPGRO_V(x) ((x) << FW_EQ_ETH_CMD_STATUSPGRO_S)
+
+#define FW_EQ_ETH_CMD_FETCHNS_S 23
+#define FW_EQ_ETH_CMD_FETCHNS_V(x) ((x) << FW_EQ_ETH_CMD_FETCHNS_S)
+
+#define FW_EQ_ETH_CMD_FETCHRO_S 22
+#define FW_EQ_ETH_CMD_FETCHRO_V(x) ((x) << FW_EQ_ETH_CMD_FETCHRO_S)
+#define FW_EQ_ETH_CMD_FETCHRO_F FW_EQ_ETH_CMD_FETCHRO_V(1U)
+
+#define FW_EQ_ETH_CMD_HOSTFCMODE_S 20
+#define FW_EQ_ETH_CMD_HOSTFCMODE_V(x) ((x) << FW_EQ_ETH_CMD_HOSTFCMODE_S)
+
+#define FW_EQ_ETH_CMD_CPRIO_S 19
+#define FW_EQ_ETH_CMD_CPRIO_V(x) ((x) << FW_EQ_ETH_CMD_CPRIO_S)
+
+#define FW_EQ_ETH_CMD_ONCHIP_S 18
+#define FW_EQ_ETH_CMD_ONCHIP_V(x) ((x) << FW_EQ_ETH_CMD_ONCHIP_S)
+
+#define FW_EQ_ETH_CMD_PCIECHN_S 16
+#define FW_EQ_ETH_CMD_PCIECHN_V(x) ((x) << FW_EQ_ETH_CMD_PCIECHN_S)
+
+#define FW_EQ_ETH_CMD_IQID_S 0
+#define FW_EQ_ETH_CMD_IQID_V(x) ((x) << FW_EQ_ETH_CMD_IQID_S)
+
+#define FW_EQ_ETH_CMD_DCAEN_S 31
+#define FW_EQ_ETH_CMD_DCAEN_V(x) ((x) << FW_EQ_ETH_CMD_DCAEN_S)
+
+#define FW_EQ_ETH_CMD_DCACPU_S 26
+#define FW_EQ_ETH_CMD_DCACPU_V(x) ((x) << FW_EQ_ETH_CMD_DCACPU_S)
+
+#define FW_EQ_ETH_CMD_FBMIN_S 23
+#define FW_EQ_ETH_CMD_FBMIN_V(x) ((x) << FW_EQ_ETH_CMD_FBMIN_S)
+
+#define FW_EQ_ETH_CMD_FBMAX_S 20
+#define FW_EQ_ETH_CMD_FBMAX_V(x) ((x) << FW_EQ_ETH_CMD_FBMAX_S)
+
+#define FW_EQ_ETH_CMD_CIDXFTHRESHO_S 19
+#define FW_EQ_ETH_CMD_CIDXFTHRESHO_V(x) ((x) << FW_EQ_ETH_CMD_CIDXFTHRESHO_S)
+
+#define FW_EQ_ETH_CMD_CIDXFTHRESH_S 16
+#define FW_EQ_ETH_CMD_CIDXFTHRESH_V(x) ((x) << FW_EQ_ETH_CMD_CIDXFTHRESH_S)
+
+#define FW_EQ_ETH_CMD_EQSIZE_S 0
+#define FW_EQ_ETH_CMD_EQSIZE_V(x) ((x) << FW_EQ_ETH_CMD_EQSIZE_S)
+
+#define FW_EQ_ETH_CMD_AUTOEQUEQE_S 30
+#define FW_EQ_ETH_CMD_AUTOEQUEQE_V(x) ((x) << FW_EQ_ETH_CMD_AUTOEQUEQE_S)
+#define FW_EQ_ETH_CMD_AUTOEQUEQE_F FW_EQ_ETH_CMD_AUTOEQUEQE_V(1U)
+
+#define FW_EQ_ETH_CMD_VIID_S 16
+#define FW_EQ_ETH_CMD_VIID_V(x) ((x) << FW_EQ_ETH_CMD_VIID_S)
+
+struct fw_eq_ctrl_cmd {
+ __be32 op_to_vfn;
+ __be32 alloc_to_len16;
+ __be32 cmpliqid_eqid;
+ __be32 physeqid_pkd;
+ __be32 fetchszm_to_iqid;
+ __be32 dcaen_to_eqsize;
+ __be64 eqaddr;
+};
+
+#define FW_EQ_CTRL_CMD_PFN_S 8
+#define FW_EQ_CTRL_CMD_PFN_V(x) ((x) << FW_EQ_CTRL_CMD_PFN_S)
+
+#define FW_EQ_CTRL_CMD_VFN_S 0
+#define FW_EQ_CTRL_CMD_VFN_V(x) ((x) << FW_EQ_CTRL_CMD_VFN_S)
+
+#define FW_EQ_CTRL_CMD_ALLOC_S 31
+#define FW_EQ_CTRL_CMD_ALLOC_V(x) ((x) << FW_EQ_CTRL_CMD_ALLOC_S)
+#define FW_EQ_CTRL_CMD_ALLOC_F FW_EQ_CTRL_CMD_ALLOC_V(1U)
+
+#define FW_EQ_CTRL_CMD_FREE_S 30
+#define FW_EQ_CTRL_CMD_FREE_V(x) ((x) << FW_EQ_CTRL_CMD_FREE_S)
+#define FW_EQ_CTRL_CMD_FREE_F FW_EQ_CTRL_CMD_FREE_V(1U)
+
+#define FW_EQ_CTRL_CMD_MODIFY_S 29
+#define FW_EQ_CTRL_CMD_MODIFY_V(x) ((x) << FW_EQ_CTRL_CMD_MODIFY_S)
+#define FW_EQ_CTRL_CMD_MODIFY_F FW_EQ_CTRL_CMD_MODIFY_V(1U)
+
+#define FW_EQ_CTRL_CMD_EQSTART_S 28
+#define FW_EQ_CTRL_CMD_EQSTART_V(x) ((x) << FW_EQ_CTRL_CMD_EQSTART_S)
+#define FW_EQ_CTRL_CMD_EQSTART_F FW_EQ_CTRL_CMD_EQSTART_V(1U)
+
+#define FW_EQ_CTRL_CMD_EQSTOP_S 27
+#define FW_EQ_CTRL_CMD_EQSTOP_V(x) ((x) << FW_EQ_CTRL_CMD_EQSTOP_S)
+#define FW_EQ_CTRL_CMD_EQSTOP_F FW_EQ_CTRL_CMD_EQSTOP_V(1U)
+
+#define FW_EQ_CTRL_CMD_CMPLIQID_S 20
+#define FW_EQ_CTRL_CMD_CMPLIQID_V(x) ((x) << FW_EQ_CTRL_CMD_CMPLIQID_S)
+
+#define FW_EQ_CTRL_CMD_EQID_S 0
+#define FW_EQ_CTRL_CMD_EQID_M 0xfffff
+#define FW_EQ_CTRL_CMD_EQID_V(x) ((x) << FW_EQ_CTRL_CMD_EQID_S)
+#define FW_EQ_CTRL_CMD_EQID_G(x) \
+ (((x) >> FW_EQ_CTRL_CMD_EQID_S) & FW_EQ_CTRL_CMD_EQID_M)
+
+#define FW_EQ_CTRL_CMD_PHYSEQID_S 0
+#define FW_EQ_CTRL_CMD_PHYSEQID_M 0xfffff
+#define FW_EQ_CTRL_CMD_PHYSEQID_G(x) \
+ (((x) >> FW_EQ_CTRL_CMD_PHYSEQID_S) & FW_EQ_CTRL_CMD_PHYSEQID_M)
+
+#define FW_EQ_CTRL_CMD_FETCHSZM_S 26
+#define FW_EQ_CTRL_CMD_FETCHSZM_V(x) ((x) << FW_EQ_CTRL_CMD_FETCHSZM_S)
+#define FW_EQ_CTRL_CMD_FETCHSZM_F FW_EQ_CTRL_CMD_FETCHSZM_V(1U)
+
+#define FW_EQ_CTRL_CMD_STATUSPGNS_S 25
+#define FW_EQ_CTRL_CMD_STATUSPGNS_V(x) ((x) << FW_EQ_CTRL_CMD_STATUSPGNS_S)
+#define FW_EQ_CTRL_CMD_STATUSPGNS_F FW_EQ_CTRL_CMD_STATUSPGNS_V(1U)
+
+#define FW_EQ_CTRL_CMD_STATUSPGRO_S 24
+#define FW_EQ_CTRL_CMD_STATUSPGRO_V(x) ((x) << FW_EQ_CTRL_CMD_STATUSPGRO_S)
+#define FW_EQ_CTRL_CMD_STATUSPGRO_F FW_EQ_CTRL_CMD_STATUSPGRO_V(1U)
+
+#define FW_EQ_CTRL_CMD_FETCHNS_S 23
+#define FW_EQ_CTRL_CMD_FETCHNS_V(x) ((x) << FW_EQ_CTRL_CMD_FETCHNS_S)
+#define FW_EQ_CTRL_CMD_FETCHNS_F FW_EQ_CTRL_CMD_FETCHNS_V(1U)
+
+#define FW_EQ_CTRL_CMD_FETCHRO_S 22
+#define FW_EQ_CTRL_CMD_FETCHRO_V(x) ((x) << FW_EQ_CTRL_CMD_FETCHRO_S)
+#define FW_EQ_CTRL_CMD_FETCHRO_F FW_EQ_CTRL_CMD_FETCHRO_V(1U)
+
+#define FW_EQ_CTRL_CMD_HOSTFCMODE_S 20
+#define FW_EQ_CTRL_CMD_HOSTFCMODE_V(x) ((x) << FW_EQ_CTRL_CMD_HOSTFCMODE_S)
+
+#define FW_EQ_CTRL_CMD_CPRIO_S 19
+#define FW_EQ_CTRL_CMD_CPRIO_V(x) ((x) << FW_EQ_CTRL_CMD_CPRIO_S)
+
+#define FW_EQ_CTRL_CMD_ONCHIP_S 18
+#define FW_EQ_CTRL_CMD_ONCHIP_V(x) ((x) << FW_EQ_CTRL_CMD_ONCHIP_S)
+
+#define FW_EQ_CTRL_CMD_PCIECHN_S 16
+#define FW_EQ_CTRL_CMD_PCIECHN_V(x) ((x) << FW_EQ_CTRL_CMD_PCIECHN_S)
+
+#define FW_EQ_CTRL_CMD_IQID_S 0
+#define FW_EQ_CTRL_CMD_IQID_V(x) ((x) << FW_EQ_CTRL_CMD_IQID_S)
+
+#define FW_EQ_CTRL_CMD_DCAEN_S 31
+#define FW_EQ_CTRL_CMD_DCAEN_V(x) ((x) << FW_EQ_CTRL_CMD_DCAEN_S)
+
+#define FW_EQ_CTRL_CMD_DCACPU_S 26
+#define FW_EQ_CTRL_CMD_DCACPU_V(x) ((x) << FW_EQ_CTRL_CMD_DCACPU_S)
+
+#define FW_EQ_CTRL_CMD_FBMIN_S 23
+#define FW_EQ_CTRL_CMD_FBMIN_V(x) ((x) << FW_EQ_CTRL_CMD_FBMIN_S)
+
+#define FW_EQ_CTRL_CMD_FBMAX_S 20
+#define FW_EQ_CTRL_CMD_FBMAX_V(x) ((x) << FW_EQ_CTRL_CMD_FBMAX_S)
+
+#define FW_EQ_CTRL_CMD_CIDXFTHRESHO_S 19
+#define FW_EQ_CTRL_CMD_CIDXFTHRESHO_V(x) \
+ ((x) << FW_EQ_CTRL_CMD_CIDXFTHRESHO_S)
+
+#define FW_EQ_CTRL_CMD_CIDXFTHRESH_S 16
+#define FW_EQ_CTRL_CMD_CIDXFTHRESH_V(x) ((x) << FW_EQ_CTRL_CMD_CIDXFTHRESH_S)
+
+#define FW_EQ_CTRL_CMD_EQSIZE_S 0
+#define FW_EQ_CTRL_CMD_EQSIZE_V(x) ((x) << FW_EQ_CTRL_CMD_EQSIZE_S)
+
+struct fw_eq_ofld_cmd {
+ __be32 op_to_vfn;
+ __be32 alloc_to_len16;
+ __be32 eqid_pkd;
+ __be32 physeqid_pkd;
+ __be32 fetchszm_to_iqid;
+ __be32 dcaen_to_eqsize;
+ __be64 eqaddr;
+};
+
+#define FW_EQ_OFLD_CMD_PFN_S 8
+#define FW_EQ_OFLD_CMD_PFN_V(x) ((x) << FW_EQ_OFLD_CMD_PFN_S)
+
+#define FW_EQ_OFLD_CMD_VFN_S 0
+#define FW_EQ_OFLD_CMD_VFN_V(x) ((x) << FW_EQ_OFLD_CMD_VFN_S)
+
+#define FW_EQ_OFLD_CMD_ALLOC_S 31
+#define FW_EQ_OFLD_CMD_ALLOC_V(x) ((x) << FW_EQ_OFLD_CMD_ALLOC_S)
+#define FW_EQ_OFLD_CMD_ALLOC_F FW_EQ_OFLD_CMD_ALLOC_V(1U)
+
+#define FW_EQ_OFLD_CMD_FREE_S 30
+#define FW_EQ_OFLD_CMD_FREE_V(x) ((x) << FW_EQ_OFLD_CMD_FREE_S)
+#define FW_EQ_OFLD_CMD_FREE_F FW_EQ_OFLD_CMD_FREE_V(1U)
+
+#define FW_EQ_OFLD_CMD_MODIFY_S 29
+#define FW_EQ_OFLD_CMD_MODIFY_V(x) ((x) << FW_EQ_OFLD_CMD_MODIFY_S)
+#define FW_EQ_OFLD_CMD_MODIFY_F FW_EQ_OFLD_CMD_MODIFY_V(1U)
+
+#define FW_EQ_OFLD_CMD_EQSTART_S 28
+#define FW_EQ_OFLD_CMD_EQSTART_V(x) ((x) << FW_EQ_OFLD_CMD_EQSTART_S)
+#define FW_EQ_OFLD_CMD_EQSTART_F FW_EQ_OFLD_CMD_EQSTART_V(1U)
+
+#define FW_EQ_OFLD_CMD_EQSTOP_S 27
+#define FW_EQ_OFLD_CMD_EQSTOP_V(x) ((x) << FW_EQ_OFLD_CMD_EQSTOP_S)
+#define FW_EQ_OFLD_CMD_EQSTOP_F FW_EQ_OFLD_CMD_EQSTOP_V(1U)
+
+#define FW_EQ_OFLD_CMD_EQID_S 0
+#define FW_EQ_OFLD_CMD_EQID_M 0xfffff
+#define FW_EQ_OFLD_CMD_EQID_V(x) ((x) << FW_EQ_OFLD_CMD_EQID_S)
+#define FW_EQ_OFLD_CMD_EQID_G(x) \
+ (((x) >> FW_EQ_OFLD_CMD_EQID_S) & FW_EQ_OFLD_CMD_EQID_M)
+
+#define FW_EQ_OFLD_CMD_PHYSEQID_S 0
+#define FW_EQ_OFLD_CMD_PHYSEQID_M 0xfffff
+#define FW_EQ_OFLD_CMD_PHYSEQID_G(x) \
+ (((x) >> FW_EQ_OFLD_CMD_PHYSEQID_S) & FW_EQ_OFLD_CMD_PHYSEQID_M)
+
+#define FW_EQ_OFLD_CMD_FETCHSZM_S 26
+#define FW_EQ_OFLD_CMD_FETCHSZM_V(x) ((x) << FW_EQ_OFLD_CMD_FETCHSZM_S)
+
+#define FW_EQ_OFLD_CMD_STATUSPGNS_S 25
+#define FW_EQ_OFLD_CMD_STATUSPGNS_V(x) ((x) << FW_EQ_OFLD_CMD_STATUSPGNS_S)
+
+#define FW_EQ_OFLD_CMD_STATUSPGRO_S 24
+#define FW_EQ_OFLD_CMD_STATUSPGRO_V(x) ((x) << FW_EQ_OFLD_CMD_STATUSPGRO_S)
+
+#define FW_EQ_OFLD_CMD_FETCHNS_S 23
+#define FW_EQ_OFLD_CMD_FETCHNS_V(x) ((x) << FW_EQ_OFLD_CMD_FETCHNS_S)
+
+#define FW_EQ_OFLD_CMD_FETCHRO_S 22
+#define FW_EQ_OFLD_CMD_FETCHRO_V(x) ((x) << FW_EQ_OFLD_CMD_FETCHRO_S)
+#define FW_EQ_OFLD_CMD_FETCHRO_F FW_EQ_OFLD_CMD_FETCHRO_V(1U)
+
+#define FW_EQ_OFLD_CMD_HOSTFCMODE_S 20
+#define FW_EQ_OFLD_CMD_HOSTFCMODE_V(x) ((x) << FW_EQ_OFLD_CMD_HOSTFCMODE_S)
+
+#define FW_EQ_OFLD_CMD_CPRIO_S 19
+#define FW_EQ_OFLD_CMD_CPRIO_V(x) ((x) << FW_EQ_OFLD_CMD_CPRIO_S)
+
+#define FW_EQ_OFLD_CMD_ONCHIP_S 18
+#define FW_EQ_OFLD_CMD_ONCHIP_V(x) ((x) << FW_EQ_OFLD_CMD_ONCHIP_S)
+
+#define FW_EQ_OFLD_CMD_PCIECHN_S 16
+#define FW_EQ_OFLD_CMD_PCIECHN_V(x) ((x) << FW_EQ_OFLD_CMD_PCIECHN_S)
+
+#define FW_EQ_OFLD_CMD_IQID_S 0
+#define FW_EQ_OFLD_CMD_IQID_V(x) ((x) << FW_EQ_OFLD_CMD_IQID_S)
+
+#define FW_EQ_OFLD_CMD_DCAEN_S 31
+#define FW_EQ_OFLD_CMD_DCAEN_V(x) ((x) << FW_EQ_OFLD_CMD_DCAEN_S)
+
+#define FW_EQ_OFLD_CMD_DCACPU_S 26
+#define FW_EQ_OFLD_CMD_DCACPU_V(x) ((x) << FW_EQ_OFLD_CMD_DCACPU_S)
+
+#define FW_EQ_OFLD_CMD_FBMIN_S 23
+#define FW_EQ_OFLD_CMD_FBMIN_V(x) ((x) << FW_EQ_OFLD_CMD_FBMIN_S)
+
+#define FW_EQ_OFLD_CMD_FBMAX_S 20
+#define FW_EQ_OFLD_CMD_FBMAX_V(x) ((x) << FW_EQ_OFLD_CMD_FBMAX_S)
+
+#define FW_EQ_OFLD_CMD_CIDXFTHRESHO_S 19
+#define FW_EQ_OFLD_CMD_CIDXFTHRESHO_V(x) \
+ ((x) << FW_EQ_OFLD_CMD_CIDXFTHRESHO_S)
+
+#define FW_EQ_OFLD_CMD_CIDXFTHRESH_S 16
+#define FW_EQ_OFLD_CMD_CIDXFTHRESH_V(x) ((x) << FW_EQ_OFLD_CMD_CIDXFTHRESH_S)
+
+#define FW_EQ_OFLD_CMD_EQSIZE_S 0
+#define FW_EQ_OFLD_CMD_EQSIZE_V(x) ((x) << FW_EQ_OFLD_CMD_EQSIZE_S)
+
+/*
+ * Macros for VIID parsing:
+ * VIID - [10:8] PFN, [7] VI Valid, [6:0] VI number
+ */
+
+#define FW_VIID_PFN_S 8
+#define FW_VIID_PFN_M 0x7
+#define FW_VIID_PFN_G(x) (((x) >> FW_VIID_PFN_S) & FW_VIID_PFN_M)
+
+#define FW_VIID_VIVLD_S 7
+#define FW_VIID_VIVLD_M 0x1
+#define FW_VIID_VIVLD_G(x) (((x) >> FW_VIID_VIVLD_S) & FW_VIID_VIVLD_M)
+
+#define FW_VIID_VIN_S 0
+#define FW_VIID_VIN_M 0x7F
+#define FW_VIID_VIN_G(x) (((x) >> FW_VIID_VIN_S) & FW_VIID_VIN_M)
+
+struct fw_vi_cmd {
+ __be32 op_to_vfn;
+ __be32 alloc_to_len16;
+ __be16 type_viid;
+ u8 mac[6];
+ u8 portid_pkd;
+ u8 nmac;
+ u8 nmac0[6];
+ __be16 rsssize_pkd;
+ u8 nmac1[6];
+ __be16 idsiiq_pkd;
+ u8 nmac2[6];
+ __be16 idseiq_pkd;
+ u8 nmac3[6];
+ __be64 r9;
+ __be64 r10;
+};
+
+#define FW_VI_CMD_PFN_S 8
+#define FW_VI_CMD_PFN_V(x) ((x) << FW_VI_CMD_PFN_S)
+
+#define FW_VI_CMD_VFN_S 0
+#define FW_VI_CMD_VFN_V(x) ((x) << FW_VI_CMD_VFN_S)
+
+#define FW_VI_CMD_ALLOC_S 31
+#define FW_VI_CMD_ALLOC_V(x) ((x) << FW_VI_CMD_ALLOC_S)
+#define FW_VI_CMD_ALLOC_F FW_VI_CMD_ALLOC_V(1U)
+
+#define FW_VI_CMD_FREE_S 30
+#define FW_VI_CMD_FREE_V(x) ((x) << FW_VI_CMD_FREE_S)
+#define FW_VI_CMD_FREE_F FW_VI_CMD_FREE_V(1U)
+
+#define FW_VI_CMD_VIID_S 0
+#define FW_VI_CMD_VIID_M 0xfff
+#define FW_VI_CMD_VIID_V(x) ((x) << FW_VI_CMD_VIID_S)
+#define FW_VI_CMD_VIID_G(x) (((x) >> FW_VI_CMD_VIID_S) & FW_VI_CMD_VIID_M)
+
+#define FW_VI_CMD_PORTID_S 4
+#define FW_VI_CMD_PORTID_M 0xf
+#define FW_VI_CMD_PORTID_V(x) ((x) << FW_VI_CMD_PORTID_S)
+#define FW_VI_CMD_PORTID_G(x) \
+ (((x) >> FW_VI_CMD_PORTID_S) & FW_VI_CMD_PORTID_M)
+
+#define FW_VI_CMD_RSSSIZE_S 0
+#define FW_VI_CMD_RSSSIZE_M 0x7ff
+#define FW_VI_CMD_RSSSIZE_G(x) \
+ (((x) >> FW_VI_CMD_RSSSIZE_S) & FW_VI_CMD_RSSSIZE_M)
+
+/* Special VI_MAC command index ids */
+#define FW_VI_MAC_ADD_MAC 0x3FF
+#define FW_VI_MAC_ADD_PERSIST_MAC 0x3FE
+#define FW_VI_MAC_MAC_BASED_FREE 0x3FD
+#define FW_CLS_TCAM_NUM_ENTRIES 336
+
+enum fw_vi_mac_smac {
+ FW_VI_MAC_MPS_TCAM_ENTRY,
+ FW_VI_MAC_MPS_TCAM_ONLY,
+ FW_VI_MAC_SMT_ONLY,
+ FW_VI_MAC_SMT_AND_MPSTCAM
+};
+
+enum fw_vi_mac_result {
+ FW_VI_MAC_R_SUCCESS,
+ FW_VI_MAC_R_F_NONEXISTENT_NOMEM,
+ FW_VI_MAC_R_SMAC_FAIL,
+ FW_VI_MAC_R_F_ACL_CHECK
+};
+
+struct fw_vi_mac_cmd {
+ __be32 op_to_viid;
+ __be32 freemacs_to_len16;
+ union fw_vi_mac {
+ struct fw_vi_mac_exact {
+ __be16 valid_to_idx;
+ u8 macaddr[6];
+ } exact[7];
+ struct fw_vi_mac_hash {
+ __be64 hashvec;
+ } hash;
+ } u;
+};
+
+#define FW_VI_MAC_CMD_VIID_S 0
+#define FW_VI_MAC_CMD_VIID_V(x) ((x) << FW_VI_MAC_CMD_VIID_S)
+
+#define FW_VI_MAC_CMD_FREEMACS_S 31
+#define FW_VI_MAC_CMD_FREEMACS_V(x) ((x) << FW_VI_MAC_CMD_FREEMACS_S)
+
+#define FW_VI_MAC_CMD_HASHVECEN_S 23
+#define FW_VI_MAC_CMD_HASHVECEN_V(x) ((x) << FW_VI_MAC_CMD_HASHVECEN_S)
+#define FW_VI_MAC_CMD_HASHVECEN_F FW_VI_MAC_CMD_HASHVECEN_V(1U)
+
+#define FW_VI_MAC_CMD_HASHUNIEN_S 22
+#define FW_VI_MAC_CMD_HASHUNIEN_V(x) ((x) << FW_VI_MAC_CMD_HASHUNIEN_S)
+
+#define FW_VI_MAC_CMD_VALID_S 15
+#define FW_VI_MAC_CMD_VALID_V(x) ((x) << FW_VI_MAC_CMD_VALID_S)
+#define FW_VI_MAC_CMD_VALID_F FW_VI_MAC_CMD_VALID_V(1U)
+
+#define FW_VI_MAC_CMD_PRIO_S 12
+#define FW_VI_MAC_CMD_PRIO_V(x) ((x) << FW_VI_MAC_CMD_PRIO_S)
+
+#define FW_VI_MAC_CMD_SMAC_RESULT_S 10
+#define FW_VI_MAC_CMD_SMAC_RESULT_M 0x3
+#define FW_VI_MAC_CMD_SMAC_RESULT_V(x) ((x) << FW_VI_MAC_CMD_SMAC_RESULT_S)
+#define FW_VI_MAC_CMD_SMAC_RESULT_G(x) \
+ (((x) >> FW_VI_MAC_CMD_SMAC_RESULT_S) & FW_VI_MAC_CMD_SMAC_RESULT_M)
+
+#define FW_VI_MAC_CMD_IDX_S 0
+#define FW_VI_MAC_CMD_IDX_M 0x3ff
+#define FW_VI_MAC_CMD_IDX_V(x) ((x) << FW_VI_MAC_CMD_IDX_S)
+#define FW_VI_MAC_CMD_IDX_G(x) \
+ (((x) >> FW_VI_MAC_CMD_IDX_S) & FW_VI_MAC_CMD_IDX_M)
+
+#define FW_RXMODE_MTU_NO_CHG 65535
+
+struct fw_vi_rxmode_cmd {
+ __be32 op_to_viid;
+ __be32 retval_len16;
+ __be32 mtu_to_vlanexen;
+ __be32 r4_lo;
+};
+
+#define FW_VI_RXMODE_CMD_VIID_S 0
+#define FW_VI_RXMODE_CMD_VIID_V(x) ((x) << FW_VI_RXMODE_CMD_VIID_S)
+
+#define FW_VI_RXMODE_CMD_MTU_S 16
+#define FW_VI_RXMODE_CMD_MTU_M 0xffff
+#define FW_VI_RXMODE_CMD_MTU_V(x) ((x) << FW_VI_RXMODE_CMD_MTU_S)
+
+#define FW_VI_RXMODE_CMD_PROMISCEN_S 14
+#define FW_VI_RXMODE_CMD_PROMISCEN_M 0x3
+#define FW_VI_RXMODE_CMD_PROMISCEN_V(x) ((x) << FW_VI_RXMODE_CMD_PROMISCEN_S)
+
+#define FW_VI_RXMODE_CMD_ALLMULTIEN_S 12
+#define FW_VI_RXMODE_CMD_ALLMULTIEN_M 0x3
+#define FW_VI_RXMODE_CMD_ALLMULTIEN_V(x) \
+ ((x) << FW_VI_RXMODE_CMD_ALLMULTIEN_S)
+
+#define FW_VI_RXMODE_CMD_BROADCASTEN_S 10
+#define FW_VI_RXMODE_CMD_BROADCASTEN_M 0x3
+#define FW_VI_RXMODE_CMD_BROADCASTEN_V(x) \
+ ((x) << FW_VI_RXMODE_CMD_BROADCASTEN_S)
+
+#define FW_VI_RXMODE_CMD_VLANEXEN_S 8
+#define FW_VI_RXMODE_CMD_VLANEXEN_M 0x3
+#define FW_VI_RXMODE_CMD_VLANEXEN_V(x) ((x) << FW_VI_RXMODE_CMD_VLANEXEN_S)
+
+struct fw_vi_enable_cmd {
+ __be32 op_to_viid;
+ __be32 ien_to_len16;
+ __be16 blinkdur;
+ __be16 r3;
+ __be32 r4;
+};
+
+#define FW_VI_ENABLE_CMD_VIID_S 0
+#define FW_VI_ENABLE_CMD_VIID_V(x) ((x) << FW_VI_ENABLE_CMD_VIID_S)
+
+#define FW_VI_ENABLE_CMD_IEN_S 31
+#define FW_VI_ENABLE_CMD_IEN_V(x) ((x) << FW_VI_ENABLE_CMD_IEN_S)
+
+#define FW_VI_ENABLE_CMD_EEN_S 30
+#define FW_VI_ENABLE_CMD_EEN_V(x) ((x) << FW_VI_ENABLE_CMD_EEN_S)
+
+#define FW_VI_ENABLE_CMD_LED_S 29
+#define FW_VI_ENABLE_CMD_LED_V(x) ((x) << FW_VI_ENABLE_CMD_LED_S)
+#define FW_VI_ENABLE_CMD_LED_F FW_VI_ENABLE_CMD_LED_V(1U)
+
+#define FW_VI_ENABLE_CMD_DCB_INFO_S 28
+#define FW_VI_ENABLE_CMD_DCB_INFO_V(x) ((x) << FW_VI_ENABLE_CMD_DCB_INFO_S)
+
+/* VI VF stats offset definitions */
+#define VI_VF_NUM_STATS 16
+enum fw_vi_stats_vf_index {
+ FW_VI_VF_STAT_TX_BCAST_BYTES_IX,
+ FW_VI_VF_STAT_TX_BCAST_FRAMES_IX,
+ FW_VI_VF_STAT_TX_MCAST_BYTES_IX,
+ FW_VI_VF_STAT_TX_MCAST_FRAMES_IX,
+ FW_VI_VF_STAT_TX_UCAST_BYTES_IX,
+ FW_VI_VF_STAT_TX_UCAST_FRAMES_IX,
+ FW_VI_VF_STAT_TX_DROP_FRAMES_IX,
+ FW_VI_VF_STAT_TX_OFLD_BYTES_IX,
+ FW_VI_VF_STAT_TX_OFLD_FRAMES_IX,
+ FW_VI_VF_STAT_RX_BCAST_BYTES_IX,
+ FW_VI_VF_STAT_RX_BCAST_FRAMES_IX,
+ FW_VI_VF_STAT_RX_MCAST_BYTES_IX,
+ FW_VI_VF_STAT_RX_MCAST_FRAMES_IX,
+ FW_VI_VF_STAT_RX_UCAST_BYTES_IX,
+ FW_VI_VF_STAT_RX_UCAST_FRAMES_IX,
+ FW_VI_VF_STAT_RX_ERR_FRAMES_IX
+};
+
+/* VI PF stats offset definitions */
+#define VI_PF_NUM_STATS 17
+enum fw_vi_stats_pf_index {
+ FW_VI_PF_STAT_TX_BCAST_BYTES_IX,
+ FW_VI_PF_STAT_TX_BCAST_FRAMES_IX,
+ FW_VI_PF_STAT_TX_MCAST_BYTES_IX,
+ FW_VI_PF_STAT_TX_MCAST_FRAMES_IX,
+ FW_VI_PF_STAT_TX_UCAST_BYTES_IX,
+ FW_VI_PF_STAT_TX_UCAST_FRAMES_IX,
+ FW_VI_PF_STAT_TX_OFLD_BYTES_IX,
+ FW_VI_PF_STAT_TX_OFLD_FRAMES_IX,
+ FW_VI_PF_STAT_RX_BYTES_IX,
+ FW_VI_PF_STAT_RX_FRAMES_IX,
+ FW_VI_PF_STAT_RX_BCAST_BYTES_IX,
+ FW_VI_PF_STAT_RX_BCAST_FRAMES_IX,
+ FW_VI_PF_STAT_RX_MCAST_BYTES_IX,
+ FW_VI_PF_STAT_RX_MCAST_FRAMES_IX,
+ FW_VI_PF_STAT_RX_UCAST_BYTES_IX,
+ FW_VI_PF_STAT_RX_UCAST_FRAMES_IX,
+ FW_VI_PF_STAT_RX_ERR_FRAMES_IX
+};
+
+struct fw_vi_stats_cmd {
+ __be32 op_to_viid;
+ __be32 retval_len16;
+ union fw_vi_stats {
+ struct fw_vi_stats_ctl {
+ __be16 nstats_ix;
+ __be16 r6;
+ __be32 r7;
+ __be64 stat0;
+ __be64 stat1;
+ __be64 stat2;
+ __be64 stat3;
+ __be64 stat4;
+ __be64 stat5;
+ } ctl;
+ struct fw_vi_stats_pf {
+ __be64 tx_bcast_bytes;
+ __be64 tx_bcast_frames;
+ __be64 tx_mcast_bytes;
+ __be64 tx_mcast_frames;
+ __be64 tx_ucast_bytes;
+ __be64 tx_ucast_frames;
+ __be64 tx_offload_bytes;
+ __be64 tx_offload_frames;
+ __be64 rx_pf_bytes;
+ __be64 rx_pf_frames;
+ __be64 rx_bcast_bytes;
+ __be64 rx_bcast_frames;
+ __be64 rx_mcast_bytes;
+ __be64 rx_mcast_frames;
+ __be64 rx_ucast_bytes;
+ __be64 rx_ucast_frames;
+ __be64 rx_err_frames;
+ } pf;
+ struct fw_vi_stats_vf {
+ __be64 tx_bcast_bytes;
+ __be64 tx_bcast_frames;
+ __be64 tx_mcast_bytes;
+ __be64 tx_mcast_frames;
+ __be64 tx_ucast_bytes;
+ __be64 tx_ucast_frames;
+ __be64 tx_drop_frames;
+ __be64 tx_offload_bytes;
+ __be64 tx_offload_frames;
+ __be64 rx_bcast_bytes;
+ __be64 rx_bcast_frames;
+ __be64 rx_mcast_bytes;
+ __be64 rx_mcast_frames;
+ __be64 rx_ucast_bytes;
+ __be64 rx_ucast_frames;
+ __be64 rx_err_frames;
+ } vf;
+ } u;
+};
+
+#define FW_VI_STATS_CMD_VIID_S 0
+#define FW_VI_STATS_CMD_VIID_V(x) ((x) << FW_VI_STATS_CMD_VIID_S)
+
+#define FW_VI_STATS_CMD_NSTATS_S 12
+#define FW_VI_STATS_CMD_NSTATS_V(x) ((x) << FW_VI_STATS_CMD_NSTATS_S)
+
+#define FW_VI_STATS_CMD_IX_S 0
+#define FW_VI_STATS_CMD_IX_V(x) ((x) << FW_VI_STATS_CMD_IX_S)
+
+struct fw_acl_mac_cmd {
+ __be32 op_to_vfn;
+ __be32 en_to_len16;
+ u8 nmac;
+ u8 r3[7];
+ __be16 r4;
+ u8 macaddr0[6];
+ __be16 r5;
+ u8 macaddr1[6];
+ __be16 r6;
+ u8 macaddr2[6];
+ __be16 r7;
+ u8 macaddr3[6];
+};
+
+#define FW_ACL_MAC_CMD_PFN_S 8
+#define FW_ACL_MAC_CMD_PFN_V(x) ((x) << FW_ACL_MAC_CMD_PFN_S)
+
+#define FW_ACL_MAC_CMD_VFN_S 0
+#define FW_ACL_MAC_CMD_VFN_V(x) ((x) << FW_ACL_MAC_CMD_VFN_S)
+
+#define FW_ACL_MAC_CMD_EN_S 31
+#define FW_ACL_MAC_CMD_EN_V(x) ((x) << FW_ACL_MAC_CMD_EN_S)
+
+struct fw_acl_vlan_cmd {
+ __be32 op_to_vfn;
+ __be32 en_to_len16;
+ u8 nvlan;
+ u8 dropnovlan_fm;
+ u8 r3_lo[6];
+ __be16 vlanid[16];
+};
+
+#define FW_ACL_VLAN_CMD_PFN_S 8
+#define FW_ACL_VLAN_CMD_PFN_V(x) ((x) << FW_ACL_VLAN_CMD_PFN_S)
+
+#define FW_ACL_VLAN_CMD_VFN_S 0
+#define FW_ACL_VLAN_CMD_VFN_V(x) ((x) << FW_ACL_VLAN_CMD_VFN_S)
+
+#define FW_ACL_VLAN_CMD_EN_S 31
+#define FW_ACL_VLAN_CMD_EN_V(x) ((x) << FW_ACL_VLAN_CMD_EN_S)
+
+#define FW_ACL_VLAN_CMD_DROPNOVLAN_S 7
+#define FW_ACL_VLAN_CMD_DROPNOVLAN_V(x) ((x) << FW_ACL_VLAN_CMD_DROPNOVLAN_S)
+
+#define FW_ACL_VLAN_CMD_FM_S 6
+#define FW_ACL_VLAN_CMD_FM_V(x) ((x) << FW_ACL_VLAN_CMD_FM_S)
+
+enum fw_port_cap {
+ FW_PORT_CAP_SPEED_100M = 0x0001,
+ FW_PORT_CAP_SPEED_1G = 0x0002,
+ FW_PORT_CAP_SPEED_25G = 0x0004,
+ FW_PORT_CAP_SPEED_10G = 0x0008,
+ FW_PORT_CAP_SPEED_40G = 0x0010,
+ FW_PORT_CAP_SPEED_100G = 0x0020,
+ FW_PORT_CAP_FC_RX = 0x0040,
+ FW_PORT_CAP_FC_TX = 0x0080,
+ FW_PORT_CAP_ANEG = 0x0100,
+ FW_PORT_CAP_MDIX = 0x0200,
+ FW_PORT_CAP_MDIAUTO = 0x0400,
+ FW_PORT_CAP_FEC = 0x0800,
+ FW_PORT_CAP_TECHKR = 0x1000,
+ FW_PORT_CAP_TECHKX4 = 0x2000,
+ FW_PORT_CAP_802_3_PAUSE = 0x4000,
+ FW_PORT_CAP_802_3_ASM_DIR = 0x8000,
+};
+
+#define FW_PORT_CAP_SPEED_S 0
+#define FW_PORT_CAP_SPEED_M 0x3f
+#define FW_PORT_CAP_SPEED_V(x) ((x) << FW_PORT_CAP_SPEED_S)
+#define FW_PORT_CAP_SPEED_G(x) \
+ (((x) >> FW_PORT_CAP_SPEED_S) & FW_PORT_CAP_SPEED_M)
+
+enum fw_port_mdi {
+ FW_PORT_CAP_MDI_UNCHANGED,
+ FW_PORT_CAP_MDI_AUTO,
+ FW_PORT_CAP_MDI_F_STRAIGHT,
+ FW_PORT_CAP_MDI_F_CROSSOVER
+};
+
+#define FW_PORT_CAP_MDI_S 9
+#define FW_PORT_CAP_MDI_V(x) ((x) << FW_PORT_CAP_MDI_S)
+
+enum fw_port_action {
+ FW_PORT_ACTION_L1_CFG = 0x0001,
+ FW_PORT_ACTION_L2_CFG = 0x0002,
+ FW_PORT_ACTION_GET_PORT_INFO = 0x0003,
+ FW_PORT_ACTION_L2_PPP_CFG = 0x0004,
+ FW_PORT_ACTION_L2_DCB_CFG = 0x0005,
+ FW_PORT_ACTION_DCB_READ_TRANS = 0x0006,
+ FW_PORT_ACTION_DCB_READ_RECV = 0x0007,
+ FW_PORT_ACTION_DCB_READ_DET = 0x0008,
+ FW_PORT_ACTION_LOW_PWR_TO_NORMAL = 0x0010,
+ FW_PORT_ACTION_L1_LOW_PWR_EN = 0x0011,
+ FW_PORT_ACTION_L2_WOL_MODE_EN = 0x0012,
+ FW_PORT_ACTION_LPBK_TO_NORMAL = 0x0020,
+ FW_PORT_ACTION_L1_LPBK = 0x0021,
+ FW_PORT_ACTION_L1_PMA_LPBK = 0x0022,
+ FW_PORT_ACTION_L1_PCS_LPBK = 0x0023,
+ FW_PORT_ACTION_L1_PHYXS_CSIDE_LPBK = 0x0024,
+ FW_PORT_ACTION_L1_PHYXS_ESIDE_LPBK = 0x0025,
+ FW_PORT_ACTION_PHY_RESET = 0x0040,
+ FW_PORT_ACTION_PMA_RESET = 0x0041,
+ FW_PORT_ACTION_PCS_RESET = 0x0042,
+ FW_PORT_ACTION_PHYXS_RESET = 0x0043,
+ FW_PORT_ACTION_DTEXS_REEST = 0x0044,
+ FW_PORT_ACTION_AN_RESET = 0x0045
+};
+
+enum fw_port_l2cfg_ctlbf {
+ FW_PORT_L2_CTLBF_OVLAN0 = 0x01,
+ FW_PORT_L2_CTLBF_OVLAN1 = 0x02,
+ FW_PORT_L2_CTLBF_OVLAN2 = 0x04,
+ FW_PORT_L2_CTLBF_OVLAN3 = 0x08,
+ FW_PORT_L2_CTLBF_IVLAN = 0x10,
+ FW_PORT_L2_CTLBF_TXIPG = 0x20
+};
+
+enum fw_port_dcb_versions {
+ FW_PORT_DCB_VER_UNKNOWN,
+ FW_PORT_DCB_VER_CEE1D0,
+ FW_PORT_DCB_VER_CEE1D01,
+ FW_PORT_DCB_VER_IEEE,
+ FW_PORT_DCB_VER_AUTO = 7
+};
+
+enum fw_port_dcb_cfg {
+ FW_PORT_DCB_CFG_PG = 0x01,
+ FW_PORT_DCB_CFG_PFC = 0x02,
+ FW_PORT_DCB_CFG_APPL = 0x04
+};
+
+enum fw_port_dcb_cfg_rc {
+ FW_PORT_DCB_CFG_SUCCESS = 0x0,
+ FW_PORT_DCB_CFG_ERROR = 0x1
+};
+
+enum fw_port_dcb_type {
+ FW_PORT_DCB_TYPE_PGID = 0x00,
+ FW_PORT_DCB_TYPE_PGRATE = 0x01,
+ FW_PORT_DCB_TYPE_PRIORATE = 0x02,
+ FW_PORT_DCB_TYPE_PFC = 0x03,
+ FW_PORT_DCB_TYPE_APP_ID = 0x04,
+ FW_PORT_DCB_TYPE_CONTROL = 0x05,
+};
+
+enum fw_port_dcb_feature_state {
+ FW_PORT_DCB_FEATURE_STATE_PENDING = 0x0,
+ FW_PORT_DCB_FEATURE_STATE_SUCCESS = 0x1,
+ FW_PORT_DCB_FEATURE_STATE_ERROR = 0x2,
+ FW_PORT_DCB_FEATURE_STATE_TIMEOUT = 0x3,
+};
+
+struct fw_port_cmd {
+ __be32 op_to_portid;
+ __be32 action_to_len16;
+ union fw_port {
+ struct fw_port_l1cfg {
+ __be32 rcap;
+ __be32 r;
+ } l1cfg;
+ struct fw_port_l2cfg {
+ __u8 ctlbf;
+ __u8 ovlan3_to_ivlan0;
+ __be16 ivlantype;
+ __be16 txipg_force_pinfo;
+ __be16 mtu;
+ __be16 ovlan0mask;
+ __be16 ovlan0type;
+ __be16 ovlan1mask;
+ __be16 ovlan1type;
+ __be16 ovlan2mask;
+ __be16 ovlan2type;
+ __be16 ovlan3mask;
+ __be16 ovlan3type;
+ } l2cfg;
+ struct fw_port_info {
+ __be32 lstatus_to_modtype;
+ __be16 pcap;
+ __be16 acap;
+ __be16 mtu;
+ __u8 cbllen;
+ __u8 auxlinfo;
+ __u8 dcbxdis_pkd;
+ __u8 r8_lo;
+ __be16 lpacap;
+ __be64 r9;
+ } info;
+ struct fw_port_diags {
+ __u8 diagop;
+ __u8 r[3];
+ __be32 diagval;
+ } diags;
+ union fw_port_dcb {
+ struct fw_port_dcb_pgid {
+ __u8 type;
+ __u8 apply_pkd;
+ __u8 r10_lo[2];
+ __be32 pgid;
+ __be64 r11;
+ } pgid;
+ struct fw_port_dcb_pgrate {
+ __u8 type;
+ __u8 apply_pkd;
+ __u8 r10_lo[5];
+ __u8 num_tcs_supported;
+ __u8 pgrate[8];
+ __u8 tsa[8];
+ } pgrate;
+ struct fw_port_dcb_priorate {
+ __u8 type;
+ __u8 apply_pkd;
+ __u8 r10_lo[6];
+ __u8 strict_priorate[8];
+ } priorate;
+ struct fw_port_dcb_pfc {
+ __u8 type;
+ __u8 pfcen;
+ __u8 r10[5];
+ __u8 max_pfc_tcs;
+ __be64 r11;
+ } pfc;
+ struct fw_port_app_priority {
+ __u8 type;
+ __u8 r10[2];
+ __u8 idx;
+ __u8 user_prio_map;
+ __u8 sel_field;
+ __be16 protocolid;
+ __be64 r12;
+ } app_priority;
+ struct fw_port_dcb_control {
+ __u8 type;
+ __u8 all_syncd_pkd;
+ __be16 dcb_version_to_app_state;
+ __be32 r11;
+ __be64 r12;
+ } control;
+ } dcb;
+ } u;
+};
+
+#define FW_PORT_CMD_READ_S 22
+#define FW_PORT_CMD_READ_V(x) ((x) << FW_PORT_CMD_READ_S)
+#define FW_PORT_CMD_READ_F FW_PORT_CMD_READ_V(1U)
+
+#define FW_PORT_CMD_PORTID_S 0
+#define FW_PORT_CMD_PORTID_M 0xf
+#define FW_PORT_CMD_PORTID_V(x) ((x) << FW_PORT_CMD_PORTID_S)
+#define FW_PORT_CMD_PORTID_G(x) \
+ (((x) >> FW_PORT_CMD_PORTID_S) & FW_PORT_CMD_PORTID_M)
+
+#define FW_PORT_CMD_ACTION_S 16
+#define FW_PORT_CMD_ACTION_M 0xffff
+#define FW_PORT_CMD_ACTION_V(x) ((x) << FW_PORT_CMD_ACTION_S)
+#define FW_PORT_CMD_ACTION_G(x) \
+ (((x) >> FW_PORT_CMD_ACTION_S) & FW_PORT_CMD_ACTION_M)
+
+#define FW_PORT_CMD_OVLAN3_S 7
+#define FW_PORT_CMD_OVLAN3_V(x) ((x) << FW_PORT_CMD_OVLAN3_S)
+
+#define FW_PORT_CMD_OVLAN2_S 6
+#define FW_PORT_CMD_OVLAN2_V(x) ((x) << FW_PORT_CMD_OVLAN2_S)
+
+#define FW_PORT_CMD_OVLAN1_S 5
+#define FW_PORT_CMD_OVLAN1_V(x) ((x) << FW_PORT_CMD_OVLAN1_S)
+
+#define FW_PORT_CMD_OVLAN0_S 4
+#define FW_PORT_CMD_OVLAN0_V(x) ((x) << FW_PORT_CMD_OVLAN0_S)
+
+#define FW_PORT_CMD_IVLAN0_S 3
+#define FW_PORT_CMD_IVLAN0_V(x) ((x) << FW_PORT_CMD_IVLAN0_S)
+
+#define FW_PORT_CMD_TXIPG_S 3
+#define FW_PORT_CMD_TXIPG_V(x) ((x) << FW_PORT_CMD_TXIPG_S)
+
+#define FW_PORT_CMD_LSTATUS_S 31
+#define FW_PORT_CMD_LSTATUS_M 0x1
+#define FW_PORT_CMD_LSTATUS_V(x) ((x) << FW_PORT_CMD_LSTATUS_S)
+#define FW_PORT_CMD_LSTATUS_G(x) \
+ (((x) >> FW_PORT_CMD_LSTATUS_S) & FW_PORT_CMD_LSTATUS_M)
+#define FW_PORT_CMD_LSTATUS_F FW_PORT_CMD_LSTATUS_V(1U)
+
+#define FW_PORT_CMD_LSPEED_S 24
+#define FW_PORT_CMD_LSPEED_M 0x3f
+#define FW_PORT_CMD_LSPEED_V(x) ((x) << FW_PORT_CMD_LSPEED_S)
+#define FW_PORT_CMD_LSPEED_G(x) \
+ (((x) >> FW_PORT_CMD_LSPEED_S) & FW_PORT_CMD_LSPEED_M)
+
+#define FW_PORT_CMD_TXPAUSE_S 23
+#define FW_PORT_CMD_TXPAUSE_V(x) ((x) << FW_PORT_CMD_TXPAUSE_S)
+#define FW_PORT_CMD_TXPAUSE_F FW_PORT_CMD_TXPAUSE_V(1U)
+
+#define FW_PORT_CMD_RXPAUSE_S 22
+#define FW_PORT_CMD_RXPAUSE_V(x) ((x) << FW_PORT_CMD_RXPAUSE_S)
+#define FW_PORT_CMD_RXPAUSE_F FW_PORT_CMD_RXPAUSE_V(1U)
+
+#define FW_PORT_CMD_MDIOCAP_S 21
+#define FW_PORT_CMD_MDIOCAP_V(x) ((x) << FW_PORT_CMD_MDIOCAP_S)
+#define FW_PORT_CMD_MDIOCAP_F FW_PORT_CMD_MDIOCAP_V(1U)
+
+#define FW_PORT_CMD_MDIOADDR_S 16
+#define FW_PORT_CMD_MDIOADDR_M 0x1f
+#define FW_PORT_CMD_MDIOADDR_G(x) \
+ (((x) >> FW_PORT_CMD_MDIOADDR_S) & FW_PORT_CMD_MDIOADDR_M)
+
+#define FW_PORT_CMD_LPTXPAUSE_S 15
+#define FW_PORT_CMD_LPTXPAUSE_V(x) ((x) << FW_PORT_CMD_LPTXPAUSE_S)
+#define FW_PORT_CMD_LPTXPAUSE_F FW_PORT_CMD_LPTXPAUSE_V(1U)
+
+#define FW_PORT_CMD_LPRXPAUSE_S 14
+#define FW_PORT_CMD_LPRXPAUSE_V(x) ((x) << FW_PORT_CMD_LPRXPAUSE_S)
+#define FW_PORT_CMD_LPRXPAUSE_F FW_PORT_CMD_LPRXPAUSE_V(1U)
+
+#define FW_PORT_CMD_PTYPE_S 8
+#define FW_PORT_CMD_PTYPE_M 0x1f
+#define FW_PORT_CMD_PTYPE_G(x) \
+ (((x) >> FW_PORT_CMD_PTYPE_S) & FW_PORT_CMD_PTYPE_M)
+
+#define FW_PORT_CMD_LINKDNRC_S 5
+#define FW_PORT_CMD_LINKDNRC_M 0x7
+#define FW_PORT_CMD_LINKDNRC_G(x) \
+ (((x) >> FW_PORT_CMD_LINKDNRC_S) & FW_PORT_CMD_LINKDNRC_M)
+
+#define FW_PORT_CMD_MODTYPE_S 0
+#define FW_PORT_CMD_MODTYPE_M 0x1f
+#define FW_PORT_CMD_MODTYPE_V(x) ((x) << FW_PORT_CMD_MODTYPE_S)
+#define FW_PORT_CMD_MODTYPE_G(x) \
+ (((x) >> FW_PORT_CMD_MODTYPE_S) & FW_PORT_CMD_MODTYPE_M)
+
+#define FW_PORT_CMD_DCBXDIS_S 7
+#define FW_PORT_CMD_DCBXDIS_V(x) ((x) << FW_PORT_CMD_DCBXDIS_S)
+#define FW_PORT_CMD_DCBXDIS_F FW_PORT_CMD_DCBXDIS_V(1U)
+
+#define FW_PORT_CMD_APPLY_S 7
+#define FW_PORT_CMD_APPLY_V(x) ((x) << FW_PORT_CMD_APPLY_S)
+#define FW_PORT_CMD_APPLY_F FW_PORT_CMD_APPLY_V(1U)
+
+#define FW_PORT_CMD_ALL_SYNCD_S 7
+#define FW_PORT_CMD_ALL_SYNCD_V(x) ((x) << FW_PORT_CMD_ALL_SYNCD_S)
+#define FW_PORT_CMD_ALL_SYNCD_F FW_PORT_CMD_ALL_SYNCD_V(1U)
+
+#define FW_PORT_CMD_DCB_VERSION_S 12
+#define FW_PORT_CMD_DCB_VERSION_M 0x7
+#define FW_PORT_CMD_DCB_VERSION_G(x) \
+ (((x) >> FW_PORT_CMD_DCB_VERSION_S) & FW_PORT_CMD_DCB_VERSION_M)
+
+enum fw_port_type {
+ FW_PORT_TYPE_FIBER_XFI,
+ FW_PORT_TYPE_FIBER_XAUI,
+ FW_PORT_TYPE_BT_SGMII,
+ FW_PORT_TYPE_BT_XFI,
+ FW_PORT_TYPE_BT_XAUI,
+ FW_PORT_TYPE_KX4,
+ FW_PORT_TYPE_CX4,
+ FW_PORT_TYPE_KX,
+ FW_PORT_TYPE_KR,
+ FW_PORT_TYPE_SFP,
+ FW_PORT_TYPE_BP_AP,
+ FW_PORT_TYPE_BP4_AP,
+ FW_PORT_TYPE_QSFP_10G,
+ FW_PORT_TYPE_QSA,
+ FW_PORT_TYPE_QSFP,
+ FW_PORT_TYPE_BP40_BA,
+ FW_PORT_TYPE_KR4_100G,
+ FW_PORT_TYPE_CR4_QSFP,
+ FW_PORT_TYPE_CR_QSFP,
+ FW_PORT_TYPE_CR2_QSFP,
+ FW_PORT_TYPE_SFP28,
+
+ FW_PORT_TYPE_NONE = FW_PORT_CMD_PTYPE_M
+};
+
+enum fw_port_module_type {
+ FW_PORT_MOD_TYPE_NA,
+ FW_PORT_MOD_TYPE_LR,
+ FW_PORT_MOD_TYPE_SR,
+ FW_PORT_MOD_TYPE_ER,
+ FW_PORT_MOD_TYPE_TWINAX_PASSIVE,
+ FW_PORT_MOD_TYPE_TWINAX_ACTIVE,
+ FW_PORT_MOD_TYPE_LRM,
+ FW_PORT_MOD_TYPE_ERROR = FW_PORT_CMD_MODTYPE_M - 3,
+ FW_PORT_MOD_TYPE_UNKNOWN = FW_PORT_CMD_MODTYPE_M - 2,
+ FW_PORT_MOD_TYPE_NOTSUPPORTED = FW_PORT_CMD_MODTYPE_M - 1,
+
+ FW_PORT_MOD_TYPE_NONE = FW_PORT_CMD_MODTYPE_M
+};
+
+enum fw_port_mod_sub_type {
+ FW_PORT_MOD_SUB_TYPE_NA,
+ FW_PORT_MOD_SUB_TYPE_MV88E114X = 0x1,
+ FW_PORT_MOD_SUB_TYPE_TN8022 = 0x2,
+ FW_PORT_MOD_SUB_TYPE_AQ1202 = 0x3,
+ FW_PORT_MOD_SUB_TYPE_88x3120 = 0x4,
+ FW_PORT_MOD_SUB_TYPE_BCM84834 = 0x5,
+ FW_PORT_MOD_SUB_TYPE_BT_VSC8634 = 0x8,
+
+ /* The following will never been in the VPD. They are TWINAX cable
+ * lengths decoded from SFP+ module i2c PROMs. These should
+ * almost certainly go somewhere else ...
+ */
+ FW_PORT_MOD_SUB_TYPE_TWINAX_1 = 0x9,
+ FW_PORT_MOD_SUB_TYPE_TWINAX_3 = 0xA,
+ FW_PORT_MOD_SUB_TYPE_TWINAX_5 = 0xB,
+ FW_PORT_MOD_SUB_TYPE_TWINAX_7 = 0xC,
+};
+
+enum fw_port_stats_tx_index {
+ FW_STAT_TX_PORT_BYTES_IX = 0,
+ FW_STAT_TX_PORT_FRAMES_IX,
+ FW_STAT_TX_PORT_BCAST_IX,
+ FW_STAT_TX_PORT_MCAST_IX,
+ FW_STAT_TX_PORT_UCAST_IX,
+ FW_STAT_TX_PORT_ERROR_IX,
+ FW_STAT_TX_PORT_64B_IX,
+ FW_STAT_TX_PORT_65B_127B_IX,
+ FW_STAT_TX_PORT_128B_255B_IX,
+ FW_STAT_TX_PORT_256B_511B_IX,
+ FW_STAT_TX_PORT_512B_1023B_IX,
+ FW_STAT_TX_PORT_1024B_1518B_IX,
+ FW_STAT_TX_PORT_1519B_MAX_IX,
+ FW_STAT_TX_PORT_DROP_IX,
+ FW_STAT_TX_PORT_PAUSE_IX,
+ FW_STAT_TX_PORT_PPP0_IX,
+ FW_STAT_TX_PORT_PPP1_IX,
+ FW_STAT_TX_PORT_PPP2_IX,
+ FW_STAT_TX_PORT_PPP3_IX,
+ FW_STAT_TX_PORT_PPP4_IX,
+ FW_STAT_TX_PORT_PPP5_IX,
+ FW_STAT_TX_PORT_PPP6_IX,
+ FW_STAT_TX_PORT_PPP7_IX,
+ FW_NUM_PORT_TX_STATS
+};
+
+enum fw_port_stat_rx_index {
+ FW_STAT_RX_PORT_BYTES_IX = 0,
+ FW_STAT_RX_PORT_FRAMES_IX,
+ FW_STAT_RX_PORT_BCAST_IX,
+ FW_STAT_RX_PORT_MCAST_IX,
+ FW_STAT_RX_PORT_UCAST_IX,
+ FW_STAT_RX_PORT_MTU_ERROR_IX,
+ FW_STAT_RX_PORT_MTU_CRC_ERROR_IX,
+ FW_STAT_RX_PORT_CRC_ERROR_IX,
+ FW_STAT_RX_PORT_LEN_ERROR_IX,
+ FW_STAT_RX_PORT_SYM_ERROR_IX,
+ FW_STAT_RX_PORT_64B_IX,
+ FW_STAT_RX_PORT_65B_127B_IX,
+ FW_STAT_RX_PORT_128B_255B_IX,
+ FW_STAT_RX_PORT_256B_511B_IX,
+ FW_STAT_RX_PORT_512B_1023B_IX,
+ FW_STAT_RX_PORT_1024B_1518B_IX,
+ FW_STAT_RX_PORT_1519B_MAX_IX,
+ FW_STAT_RX_PORT_PAUSE_IX,
+ FW_STAT_RX_PORT_PPP0_IX,
+ FW_STAT_RX_PORT_PPP1_IX,
+ FW_STAT_RX_PORT_PPP2_IX,
+ FW_STAT_RX_PORT_PPP3_IX,
+ FW_STAT_RX_PORT_PPP4_IX,
+ FW_STAT_RX_PORT_PPP5_IX,
+ FW_STAT_RX_PORT_PPP6_IX,
+ FW_STAT_RX_PORT_PPP7_IX,
+ FW_STAT_RX_PORT_LESS_64B_IX,
+ FW_STAT_RX_PORT_MAC_ERROR_IX,
+ FW_NUM_PORT_RX_STATS
+};
+
+/* port stats */
+#define FW_NUM_PORT_STATS (FW_NUM_PORT_TX_STATS + FW_NUM_PORT_RX_STATS)
+
+struct fw_port_stats_cmd {
+ __be32 op_to_portid;
+ __be32 retval_len16;
+ union fw_port_stats {
+ struct fw_port_stats_ctl {
+ u8 nstats_bg_bm;
+ u8 tx_ix;
+ __be16 r6;
+ __be32 r7;
+ __be64 stat0;
+ __be64 stat1;
+ __be64 stat2;
+ __be64 stat3;
+ __be64 stat4;
+ __be64 stat5;
+ } ctl;
+ struct fw_port_stats_all {
+ __be64 tx_bytes;
+ __be64 tx_frames;
+ __be64 tx_bcast;
+ __be64 tx_mcast;
+ __be64 tx_ucast;
+ __be64 tx_error;
+ __be64 tx_64b;
+ __be64 tx_65b_127b;
+ __be64 tx_128b_255b;
+ __be64 tx_256b_511b;
+ __be64 tx_512b_1023b;
+ __be64 tx_1024b_1518b;
+ __be64 tx_1519b_max;
+ __be64 tx_drop;
+ __be64 tx_pause;
+ __be64 tx_ppp0;
+ __be64 tx_ppp1;
+ __be64 tx_ppp2;
+ __be64 tx_ppp3;
+ __be64 tx_ppp4;
+ __be64 tx_ppp5;
+ __be64 tx_ppp6;
+ __be64 tx_ppp7;
+ __be64 rx_bytes;
+ __be64 rx_frames;
+ __be64 rx_bcast;
+ __be64 rx_mcast;
+ __be64 rx_ucast;
+ __be64 rx_mtu_error;
+ __be64 rx_mtu_crc_error;
+ __be64 rx_crc_error;
+ __be64 rx_len_error;
+ __be64 rx_sym_error;
+ __be64 rx_64b;
+ __be64 rx_65b_127b;
+ __be64 rx_128b_255b;
+ __be64 rx_256b_511b;
+ __be64 rx_512b_1023b;
+ __be64 rx_1024b_1518b;
+ __be64 rx_1519b_max;
+ __be64 rx_pause;
+ __be64 rx_ppp0;
+ __be64 rx_ppp1;
+ __be64 rx_ppp2;
+ __be64 rx_ppp3;
+ __be64 rx_ppp4;
+ __be64 rx_ppp5;
+ __be64 rx_ppp6;
+ __be64 rx_ppp7;
+ __be64 rx_less_64b;
+ __be64 rx_bg_drop;
+ __be64 rx_bg_trunc;
+ } all;
+ } u;
+};
+
+/* port loopback stats */
+#define FW_NUM_LB_STATS 16
+enum fw_port_lb_stats_index {
+ FW_STAT_LB_PORT_BYTES_IX,
+ FW_STAT_LB_PORT_FRAMES_IX,
+ FW_STAT_LB_PORT_BCAST_IX,
+ FW_STAT_LB_PORT_MCAST_IX,
+ FW_STAT_LB_PORT_UCAST_IX,
+ FW_STAT_LB_PORT_ERROR_IX,
+ FW_STAT_LB_PORT_64B_IX,
+ FW_STAT_LB_PORT_65B_127B_IX,
+ FW_STAT_LB_PORT_128B_255B_IX,
+ FW_STAT_LB_PORT_256B_511B_IX,
+ FW_STAT_LB_PORT_512B_1023B_IX,
+ FW_STAT_LB_PORT_1024B_1518B_IX,
+ FW_STAT_LB_PORT_1519B_MAX_IX,
+ FW_STAT_LB_PORT_DROP_FRAMES_IX
+};
+
+struct fw_port_lb_stats_cmd {
+ __be32 op_to_lbport;
+ __be32 retval_len16;
+ union fw_port_lb_stats {
+ struct fw_port_lb_stats_ctl {
+ u8 nstats_bg_bm;
+ u8 ix_pkd;
+ __be16 r6;
+ __be32 r7;
+ __be64 stat0;
+ __be64 stat1;
+ __be64 stat2;
+ __be64 stat3;
+ __be64 stat4;
+ __be64 stat5;
+ } ctl;
+ struct fw_port_lb_stats_all {
+ __be64 tx_bytes;
+ __be64 tx_frames;
+ __be64 tx_bcast;
+ __be64 tx_mcast;
+ __be64 tx_ucast;
+ __be64 tx_error;
+ __be64 tx_64b;
+ __be64 tx_65b_127b;
+ __be64 tx_128b_255b;
+ __be64 tx_256b_511b;
+ __be64 tx_512b_1023b;
+ __be64 tx_1024b_1518b;
+ __be64 tx_1519b_max;
+ __be64 rx_lb_drop;
+ __be64 rx_lb_trunc;
+ } all;
+ } u;
+};
+
+struct fw_rss_ind_tbl_cmd {
+ __be32 op_to_viid;
+ __be32 retval_len16;
+ __be16 niqid;
+ __be16 startidx;
+ __be32 r3;
+ __be32 iq0_to_iq2;
+ __be32 iq3_to_iq5;
+ __be32 iq6_to_iq8;
+ __be32 iq9_to_iq11;
+ __be32 iq12_to_iq14;
+ __be32 iq15_to_iq17;
+ __be32 iq18_to_iq20;
+ __be32 iq21_to_iq23;
+ __be32 iq24_to_iq26;
+ __be32 iq27_to_iq29;
+ __be32 iq30_iq31;
+ __be32 r15_lo;
+};
+
+#define FW_RSS_IND_TBL_CMD_VIID_S 0
+#define FW_RSS_IND_TBL_CMD_VIID_V(x) ((x) << FW_RSS_IND_TBL_CMD_VIID_S)
+
+#define FW_RSS_IND_TBL_CMD_IQ0_S 20
+#define FW_RSS_IND_TBL_CMD_IQ0_V(x) ((x) << FW_RSS_IND_TBL_CMD_IQ0_S)
+
+#define FW_RSS_IND_TBL_CMD_IQ1_S 10
+#define FW_RSS_IND_TBL_CMD_IQ1_V(x) ((x) << FW_RSS_IND_TBL_CMD_IQ1_S)
+
+#define FW_RSS_IND_TBL_CMD_IQ2_S 0
+#define FW_RSS_IND_TBL_CMD_IQ2_V(x) ((x) << FW_RSS_IND_TBL_CMD_IQ2_S)
+
+struct fw_rss_glb_config_cmd {
+ __be32 op_to_write;
+ __be32 retval_len16;
+ union fw_rss_glb_config {
+ struct fw_rss_glb_config_manual {
+ __be32 mode_pkd;
+ __be32 r3;
+ __be64 r4;
+ __be64 r5;
+ } manual;
+ struct fw_rss_glb_config_basicvirtual {
+ __be32 mode_pkd;
+ __be32 synmapen_to_hashtoeplitz;
+ __be64 r8;
+ __be64 r9;
+ } basicvirtual;
+ } u;
+};
+
+#define FW_RSS_GLB_CONFIG_CMD_MODE_S 28
+#define FW_RSS_GLB_CONFIG_CMD_MODE_M 0xf
+#define FW_RSS_GLB_CONFIG_CMD_MODE_V(x) ((x) << FW_RSS_GLB_CONFIG_CMD_MODE_S)
+#define FW_RSS_GLB_CONFIG_CMD_MODE_G(x) \
+ (((x) >> FW_RSS_GLB_CONFIG_CMD_MODE_S) & FW_RSS_GLB_CONFIG_CMD_MODE_M)
+
+#define FW_RSS_GLB_CONFIG_CMD_MODE_MANUAL 0
+#define FW_RSS_GLB_CONFIG_CMD_MODE_BASICVIRTUAL 1
+
+#define FW_RSS_GLB_CONFIG_CMD_SYNMAPEN_S 8
+#define FW_RSS_GLB_CONFIG_CMD_SYNMAPEN_V(x) \
+ ((x) << FW_RSS_GLB_CONFIG_CMD_SYNMAPEN_S)
+#define FW_RSS_GLB_CONFIG_CMD_SYNMAPEN_F \
+ FW_RSS_GLB_CONFIG_CMD_SYNMAPEN_V(1U)
+
+#define FW_RSS_GLB_CONFIG_CMD_SYN4TUPENIPV6_S 7
+#define FW_RSS_GLB_CONFIG_CMD_SYN4TUPENIPV6_V(x) \
+ ((x) << FW_RSS_GLB_CONFIG_CMD_SYN4TUPENIPV6_S)
+#define FW_RSS_GLB_CONFIG_CMD_SYN4TUPENIPV6_F \
+ FW_RSS_GLB_CONFIG_CMD_SYN4TUPENIPV6_V(1U)
+
+#define FW_RSS_GLB_CONFIG_CMD_SYN2TUPENIPV6_S 6
+#define FW_RSS_GLB_CONFIG_CMD_SYN2TUPENIPV6_V(x) \
+ ((x) << FW_RSS_GLB_CONFIG_CMD_SYN2TUPENIPV6_S)
+#define FW_RSS_GLB_CONFIG_CMD_SYN2TUPENIPV6_F \
+ FW_RSS_GLB_CONFIG_CMD_SYN2TUPENIPV6_V(1U)
+
+#define FW_RSS_GLB_CONFIG_CMD_SYN4TUPENIPV4_S 5
+#define FW_RSS_GLB_CONFIG_CMD_SYN4TUPENIPV4_V(x) \
+ ((x) << FW_RSS_GLB_CONFIG_CMD_SYN4TUPENIPV4_S)
+#define FW_RSS_GLB_CONFIG_CMD_SYN4TUPENIPV4_F \
+ FW_RSS_GLB_CONFIG_CMD_SYN4TUPENIPV4_V(1U)
+
+#define FW_RSS_GLB_CONFIG_CMD_SYN2TUPENIPV4_S 4
+#define FW_RSS_GLB_CONFIG_CMD_SYN2TUPENIPV4_V(x) \
+ ((x) << FW_RSS_GLB_CONFIG_CMD_SYN2TUPENIPV4_S)
+#define FW_RSS_GLB_CONFIG_CMD_SYN2TUPENIPV4_F \
+ FW_RSS_GLB_CONFIG_CMD_SYN2TUPENIPV4_V(1U)
+
+#define FW_RSS_GLB_CONFIG_CMD_OFDMAPEN_S 3
+#define FW_RSS_GLB_CONFIG_CMD_OFDMAPEN_V(x) \
+ ((x) << FW_RSS_GLB_CONFIG_CMD_OFDMAPEN_S)
+#define FW_RSS_GLB_CONFIG_CMD_OFDMAPEN_F \
+ FW_RSS_GLB_CONFIG_CMD_OFDMAPEN_V(1U)
+
+#define FW_RSS_GLB_CONFIG_CMD_TNLMAPEN_S 2
+#define FW_RSS_GLB_CONFIG_CMD_TNLMAPEN_V(x) \
+ ((x) << FW_RSS_GLB_CONFIG_CMD_TNLMAPEN_S)
+#define FW_RSS_GLB_CONFIG_CMD_TNLMAPEN_F \
+ FW_RSS_GLB_CONFIG_CMD_TNLMAPEN_V(1U)
+
+#define FW_RSS_GLB_CONFIG_CMD_TNLALLLKP_S 1
+#define FW_RSS_GLB_CONFIG_CMD_TNLALLLKP_V(x) \
+ ((x) << FW_RSS_GLB_CONFIG_CMD_TNLALLLKP_S)
+#define FW_RSS_GLB_CONFIG_CMD_TNLALLLKP_F \
+ FW_RSS_GLB_CONFIG_CMD_TNLALLLKP_V(1U)
+
+#define FW_RSS_GLB_CONFIG_CMD_HASHTOEPLITZ_S 0
+#define FW_RSS_GLB_CONFIG_CMD_HASHTOEPLITZ_V(x) \
+ ((x) << FW_RSS_GLB_CONFIG_CMD_HASHTOEPLITZ_S)
+#define FW_RSS_GLB_CONFIG_CMD_HASHTOEPLITZ_F \
+ FW_RSS_GLB_CONFIG_CMD_HASHTOEPLITZ_V(1U)
+
+struct fw_rss_vi_config_cmd {
+ __be32 op_to_viid;
+#define FW_RSS_VI_CONFIG_CMD_VIID(x) ((x) << 0)
+ __be32 retval_len16;
+ union fw_rss_vi_config {
+ struct fw_rss_vi_config_manual {
+ __be64 r3;
+ __be64 r4;
+ __be64 r5;
+ } manual;
+ struct fw_rss_vi_config_basicvirtual {
+ __be32 r6;
+ __be32 defaultq_to_udpen;
+ __be64 r9;
+ __be64 r10;
+ } basicvirtual;
+ } u;
+};
+
+#define FW_RSS_VI_CONFIG_CMD_VIID_S 0
+#define FW_RSS_VI_CONFIG_CMD_VIID_V(x) ((x) << FW_RSS_VI_CONFIG_CMD_VIID_S)
+
+#define FW_RSS_VI_CONFIG_CMD_DEFAULTQ_S 16
+#define FW_RSS_VI_CONFIG_CMD_DEFAULTQ_M 0x3ff
+#define FW_RSS_VI_CONFIG_CMD_DEFAULTQ_V(x) \
+ ((x) << FW_RSS_VI_CONFIG_CMD_DEFAULTQ_S)
+#define FW_RSS_VI_CONFIG_CMD_DEFAULTQ_G(x) \
+ (((x) >> FW_RSS_VI_CONFIG_CMD_DEFAULTQ_S) & \
+ FW_RSS_VI_CONFIG_CMD_DEFAULTQ_M)
+
+#define FW_RSS_VI_CONFIG_CMD_IP6FOURTUPEN_S 4
+#define FW_RSS_VI_CONFIG_CMD_IP6FOURTUPEN_V(x) \
+ ((x) << FW_RSS_VI_CONFIG_CMD_IP6FOURTUPEN_S)
+#define FW_RSS_VI_CONFIG_CMD_IP6FOURTUPEN_F \
+ FW_RSS_VI_CONFIG_CMD_IP6FOURTUPEN_V(1U)
+
+#define FW_RSS_VI_CONFIG_CMD_IP6TWOTUPEN_S 3
+#define FW_RSS_VI_CONFIG_CMD_IP6TWOTUPEN_V(x) \
+ ((x) << FW_RSS_VI_CONFIG_CMD_IP6TWOTUPEN_S)
+#define FW_RSS_VI_CONFIG_CMD_IP6TWOTUPEN_F \
+ FW_RSS_VI_CONFIG_CMD_IP6TWOTUPEN_V(1U)
+
+#define FW_RSS_VI_CONFIG_CMD_IP4FOURTUPEN_S 2
+#define FW_RSS_VI_CONFIG_CMD_IP4FOURTUPEN_V(x) \
+ ((x) << FW_RSS_VI_CONFIG_CMD_IP4FOURTUPEN_S)
+#define FW_RSS_VI_CONFIG_CMD_IP4FOURTUPEN_F \
+ FW_RSS_VI_CONFIG_CMD_IP4FOURTUPEN_V(1U)
+
+#define FW_RSS_VI_CONFIG_CMD_IP4TWOTUPEN_S 1
+#define FW_RSS_VI_CONFIG_CMD_IP4TWOTUPEN_V(x) \
+ ((x) << FW_RSS_VI_CONFIG_CMD_IP4TWOTUPEN_S)
+#define FW_RSS_VI_CONFIG_CMD_IP4TWOTUPEN_F \
+ FW_RSS_VI_CONFIG_CMD_IP4TWOTUPEN_V(1U)
+
+#define FW_RSS_VI_CONFIG_CMD_UDPEN_S 0
+#define FW_RSS_VI_CONFIG_CMD_UDPEN_V(x) ((x) << FW_RSS_VI_CONFIG_CMD_UDPEN_S)
+#define FW_RSS_VI_CONFIG_CMD_UDPEN_F FW_RSS_VI_CONFIG_CMD_UDPEN_V(1U)
+
+struct fw_clip_cmd {
+ __be32 op_to_write;
+ __be32 alloc_to_len16;
+ __be64 ip_hi;
+ __be64 ip_lo;
+ __be32 r4[2];
+};
+
+#define FW_CLIP_CMD_ALLOC_S 31
+#define FW_CLIP_CMD_ALLOC_V(x) ((x) << FW_CLIP_CMD_ALLOC_S)
+#define FW_CLIP_CMD_ALLOC_F FW_CLIP_CMD_ALLOC_V(1U)
+
+#define FW_CLIP_CMD_FREE_S 30
+#define FW_CLIP_CMD_FREE_V(x) ((x) << FW_CLIP_CMD_FREE_S)
+#define FW_CLIP_CMD_FREE_F FW_CLIP_CMD_FREE_V(1U)
+
+enum fw_error_type {
+ FW_ERROR_TYPE_EXCEPTION = 0x0,
+ FW_ERROR_TYPE_HWMODULE = 0x1,
+ FW_ERROR_TYPE_WR = 0x2,
+ FW_ERROR_TYPE_ACL = 0x3,
+};
+
+struct fw_error_cmd {
+ __be32 op_to_type;
+ __be32 len16_pkd;
+ union fw_error {
+ struct fw_error_exception {
+ __be32 info[6];
+ } exception;
+ struct fw_error_hwmodule {
+ __be32 regaddr;
+ __be32 regval;
+ } hwmodule;
+ struct fw_error_wr {
+ __be16 cidx;
+ __be16 pfn_vfn;
+ __be32 eqid;
+ u8 wrhdr[16];
+ } wr;
+ struct fw_error_acl {
+ __be16 cidx;
+ __be16 pfn_vfn;
+ __be32 eqid;
+ __be16 mv_pkd;
+ u8 val[6];
+ __be64 r4;
+ } acl;
+ } u;
+};
+
+struct fw_debug_cmd {
+ __be32 op_type;
+ __be32 len16_pkd;
+ union fw_debug {
+ struct fw_debug_assert {
+ __be32 fcid;
+ __be32 line;
+ __be32 x;
+ __be32 y;
+ u8 filename_0_7[8];
+ u8 filename_8_15[8];
+ __be64 r3;
+ } assert;
+ struct fw_debug_prt {
+ __be16 dprtstridx;
+ __be16 r3[3];
+ __be32 dprtstrparam0;
+ __be32 dprtstrparam1;
+ __be32 dprtstrparam2;
+ __be32 dprtstrparam3;
+ } prt;
+ } u;
+};
+
+#define FW_DEBUG_CMD_TYPE_S 0
+#define FW_DEBUG_CMD_TYPE_M 0xff
+#define FW_DEBUG_CMD_TYPE_G(x) \
+ (((x) >> FW_DEBUG_CMD_TYPE_S) & FW_DEBUG_CMD_TYPE_M)
+
+#define PCIE_FW_ERR_S 31
+#define PCIE_FW_ERR_V(x) ((x) << PCIE_FW_ERR_S)
+#define PCIE_FW_ERR_F PCIE_FW_ERR_V(1U)
+
+#define PCIE_FW_INIT_S 30
+#define PCIE_FW_INIT_V(x) ((x) << PCIE_FW_INIT_S)
+#define PCIE_FW_INIT_F PCIE_FW_INIT_V(1U)
+
+#define PCIE_FW_HALT_S 29
+#define PCIE_FW_HALT_V(x) ((x) << PCIE_FW_HALT_S)
+#define PCIE_FW_HALT_F PCIE_FW_HALT_V(1U)
+
+#define PCIE_FW_EVAL_S 24
+#define PCIE_FW_EVAL_M 0x7
+#define PCIE_FW_EVAL_G(x) (((x) >> PCIE_FW_EVAL_S) & PCIE_FW_EVAL_M)
+
+#define PCIE_FW_MASTER_VLD_S 15
+#define PCIE_FW_MASTER_VLD_V(x) ((x) << PCIE_FW_MASTER_VLD_S)
+#define PCIE_FW_MASTER_VLD_F PCIE_FW_MASTER_VLD_V(1U)
+
+#define PCIE_FW_MASTER_S 12
+#define PCIE_FW_MASTER_M 0x7
+#define PCIE_FW_MASTER_V(x) ((x) << PCIE_FW_MASTER_S)
+#define PCIE_FW_MASTER_G(x) (((x) >> PCIE_FW_MASTER_S) & PCIE_FW_MASTER_M)
+
+struct fw_hdr {
+ u8 ver;
+ u8 chip; /* terminator chip type */
+ __be16 len512; /* bin length in units of 512-bytes */
+ __be32 fw_ver; /* firmware version */
+ __be32 tp_microcode_ver;
+ u8 intfver_nic;
+ u8 intfver_vnic;
+ u8 intfver_ofld;
+ u8 intfver_ri;
+ u8 intfver_iscsipdu;
+ u8 intfver_iscsi;
+ u8 intfver_fcoepdu;
+ u8 intfver_fcoe;
+ __u32 reserved2;
+ __u32 reserved3;
+ __u32 reserved4;
+ __be32 flags;
+ __be32 reserved6[23];
+};
+
+enum fw_hdr_chip {
+ FW_HDR_CHIP_T4,
+ FW_HDR_CHIP_T5,
+ FW_HDR_CHIP_T6
+};
+
+#define FW_HDR_FW_VER_MAJOR_S 24
+#define FW_HDR_FW_VER_MAJOR_M 0xff
+#define FW_HDR_FW_VER_MAJOR_V(x) \
+ ((x) << FW_HDR_FW_VER_MAJOR_S)
+#define FW_HDR_FW_VER_MAJOR_G(x) \
+ (((x) >> FW_HDR_FW_VER_MAJOR_S) & FW_HDR_FW_VER_MAJOR_M)
+
+#define FW_HDR_FW_VER_MINOR_S 16
+#define FW_HDR_FW_VER_MINOR_M 0xff
+#define FW_HDR_FW_VER_MINOR_V(x) \
+ ((x) << FW_HDR_FW_VER_MINOR_S)
+#define FW_HDR_FW_VER_MINOR_G(x) \
+ (((x) >> FW_HDR_FW_VER_MINOR_S) & FW_HDR_FW_VER_MINOR_M)
+
+#define FW_HDR_FW_VER_MICRO_S 8
+#define FW_HDR_FW_VER_MICRO_M 0xff
+#define FW_HDR_FW_VER_MICRO_V(x) \
+ ((x) << FW_HDR_FW_VER_MICRO_S)
+#define FW_HDR_FW_VER_MICRO_G(x) \
+ (((x) >> FW_HDR_FW_VER_MICRO_S) & FW_HDR_FW_VER_MICRO_M)
+
+#define FW_HDR_FW_VER_BUILD_S 0
+#define FW_HDR_FW_VER_BUILD_M 0xff
+#define FW_HDR_FW_VER_BUILD_V(x) \
+ ((x) << FW_HDR_FW_VER_BUILD_S)
+#define FW_HDR_FW_VER_BUILD_G(x) \
+ (((x) >> FW_HDR_FW_VER_BUILD_S) & FW_HDR_FW_VER_BUILD_M)
+
+enum fw_hdr_intfver {
+ FW_HDR_INTFVER_NIC = 0x00,
+ FW_HDR_INTFVER_VNIC = 0x00,
+ FW_HDR_INTFVER_OFLD = 0x00,
+ FW_HDR_INTFVER_RI = 0x00,
+ FW_HDR_INTFVER_ISCSIPDU = 0x00,
+ FW_HDR_INTFVER_ISCSI = 0x00,
+ FW_HDR_INTFVER_FCOEPDU = 0x00,
+ FW_HDR_INTFVER_FCOE = 0x00,
+};
+
+enum fw_hdr_flags {
+ FW_HDR_FLAGS_RESET_HALT = 0x00000001,
+};
+
+/* length of the formatting string */
+#define FW_DEVLOG_FMT_LEN 192
+
+/* maximum number of the formatting string parameters */
+#define FW_DEVLOG_FMT_PARAMS_NUM 8
+
+/* priority levels */
+enum fw_devlog_level {
+ FW_DEVLOG_LEVEL_EMERG = 0x0,
+ FW_DEVLOG_LEVEL_CRIT = 0x1,
+ FW_DEVLOG_LEVEL_ERR = 0x2,
+ FW_DEVLOG_LEVEL_NOTICE = 0x3,
+ FW_DEVLOG_LEVEL_INFO = 0x4,
+ FW_DEVLOG_LEVEL_DEBUG = 0x5,
+ FW_DEVLOG_LEVEL_MAX = 0x5,
+};
+
+/* facilities that may send a log message */
+enum fw_devlog_facility {
+ FW_DEVLOG_FACILITY_CORE = 0x00,
+ FW_DEVLOG_FACILITY_CF = 0x01,
+ FW_DEVLOG_FACILITY_SCHED = 0x02,
+ FW_DEVLOG_FACILITY_TIMER = 0x04,
+ FW_DEVLOG_FACILITY_RES = 0x06,
+ FW_DEVLOG_FACILITY_HW = 0x08,
+ FW_DEVLOG_FACILITY_FLR = 0x10,
+ FW_DEVLOG_FACILITY_DMAQ = 0x12,
+ FW_DEVLOG_FACILITY_PHY = 0x14,
+ FW_DEVLOG_FACILITY_MAC = 0x16,
+ FW_DEVLOG_FACILITY_PORT = 0x18,
+ FW_DEVLOG_FACILITY_VI = 0x1A,
+ FW_DEVLOG_FACILITY_FILTER = 0x1C,
+ FW_DEVLOG_FACILITY_ACL = 0x1E,
+ FW_DEVLOG_FACILITY_TM = 0x20,
+ FW_DEVLOG_FACILITY_QFC = 0x22,
+ FW_DEVLOG_FACILITY_DCB = 0x24,
+ FW_DEVLOG_FACILITY_ETH = 0x26,
+ FW_DEVLOG_FACILITY_OFLD = 0x28,
+ FW_DEVLOG_FACILITY_RI = 0x2A,
+ FW_DEVLOG_FACILITY_ISCSI = 0x2C,
+ FW_DEVLOG_FACILITY_FCOE = 0x2E,
+ FW_DEVLOG_FACILITY_FOISCSI = 0x30,
+ FW_DEVLOG_FACILITY_FOFCOE = 0x32,
+ FW_DEVLOG_FACILITY_CHNET = 0x34,
+ FW_DEVLOG_FACILITY_MAX = 0x34,
+};
+
+/* log message format */
+struct fw_devlog_e {
+ __be64 timestamp;
+ __be32 seqno;
+ __be16 reserved1;
+ __u8 level;
+ __u8 facility;
+ __u8 fmt[FW_DEVLOG_FMT_LEN];
+ __be32 params[FW_DEVLOG_FMT_PARAMS_NUM];
+ __be32 reserved3[4];
+};
+
+struct fw_devlog_cmd {
+ __be32 op_to_write;
+ __be32 retval_len16;
+ __u8 level;
+ __u8 r2[7];
+ __be32 memtype_devlog_memaddr16_devlog;
+ __be32 memsize_devlog;
+ __be32 r3[2];
+};
+
+#define FW_DEVLOG_CMD_MEMTYPE_DEVLOG_S 28
+#define FW_DEVLOG_CMD_MEMTYPE_DEVLOG_M 0xf
+#define FW_DEVLOG_CMD_MEMTYPE_DEVLOG_G(x) \
+ (((x) >> FW_DEVLOG_CMD_MEMTYPE_DEVLOG_S) & \
+ FW_DEVLOG_CMD_MEMTYPE_DEVLOG_M)
+
+#define FW_DEVLOG_CMD_MEMADDR16_DEVLOG_S 0
+#define FW_DEVLOG_CMD_MEMADDR16_DEVLOG_M 0xfffffff
+#define FW_DEVLOG_CMD_MEMADDR16_DEVLOG_G(x) \
+ (((x) >> FW_DEVLOG_CMD_MEMADDR16_DEVLOG_S) & \
+ FW_DEVLOG_CMD_MEMADDR16_DEVLOG_M)
+
+/* P C I E F W P F 7 R E G I S T E R */
+
+/* PF7 stores the Firmware Device Log parameters which allows Host Drivers to
+ * access the "devlog" which needing to contact firmware. The encoding is
+ * mostly the same as that returned by the DEVLOG command except for the size
+ * which is encoded as the number of entries in multiples-1 of 128 here rather
+ * than the memory size as is done in the DEVLOG command. Thus, 0 means 128
+ * and 15 means 2048. This of course in turn constrains the allowed values
+ * for the devlog size ...
+ */
+#define PCIE_FW_PF_DEVLOG 7
+
+#define PCIE_FW_PF_DEVLOG_NENTRIES128_S 28
+#define PCIE_FW_PF_DEVLOG_NENTRIES128_M 0xf
+#define PCIE_FW_PF_DEVLOG_NENTRIES128_V(x) \
+ ((x) << PCIE_FW_PF_DEVLOG_NENTRIES128_S)
+#define PCIE_FW_PF_DEVLOG_NENTRIES128_G(x) \
+ (((x) >> PCIE_FW_PF_DEVLOG_NENTRIES128_S) & \
+ PCIE_FW_PF_DEVLOG_NENTRIES128_M)
+
+#define PCIE_FW_PF_DEVLOG_ADDR16_S 4
+#define PCIE_FW_PF_DEVLOG_ADDR16_M 0xffffff
+#define PCIE_FW_PF_DEVLOG_ADDR16_V(x) ((x) << PCIE_FW_PF_DEVLOG_ADDR16_S)
+#define PCIE_FW_PF_DEVLOG_ADDR16_G(x) \
+ (((x) >> PCIE_FW_PF_DEVLOG_ADDR16_S) & PCIE_FW_PF_DEVLOG_ADDR16_M)
+
+#define PCIE_FW_PF_DEVLOG_MEMTYPE_S 0
+#define PCIE_FW_PF_DEVLOG_MEMTYPE_M 0xf
+#define PCIE_FW_PF_DEVLOG_MEMTYPE_V(x) ((x) << PCIE_FW_PF_DEVLOG_MEMTYPE_S)
+#define PCIE_FW_PF_DEVLOG_MEMTYPE_G(x) \
+ (((x) >> PCIE_FW_PF_DEVLOG_MEMTYPE_S) & PCIE_FW_PF_DEVLOG_MEMTYPE_M)
+
+#endif /* _T4FW_INTERFACE_H_ */
diff --git a/contrib/ofed/libcxgb4/t4fw_ri_api.h b/contrib/ofed/libcxgb4/t4fw_ri_api.h
new file mode 100644
index 0000000..1e26669
--- /dev/null
+++ b/contrib/ofed/libcxgb4/t4fw_ri_api.h
@@ -0,0 +1,756 @@
+/*
+ * Copyright (c) 2009-2010 Chelsio, Inc. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+#ifndef _T4FW_RI_API_H_
+#define _T4FW_RI_API_H_
+
+#include "t4fw_api.h"
+
+enum fw_ri_wr_opcode {
+ FW_RI_RDMA_WRITE = 0x0, /* IETF RDMAP v1.0 ... */
+ FW_RI_READ_REQ = 0x1,
+ FW_RI_READ_RESP = 0x2,
+ FW_RI_SEND = 0x3,
+ FW_RI_SEND_WITH_INV = 0x4,
+ FW_RI_SEND_WITH_SE = 0x5,
+ FW_RI_SEND_WITH_SE_INV = 0x6,
+ FW_RI_TERMINATE = 0x7,
+ FW_RI_RDMA_INIT = 0x8, /* CHELSIO RI specific ... */
+ FW_RI_BIND_MW = 0x9,
+ FW_RI_FAST_REGISTER = 0xa,
+ FW_RI_LOCAL_INV = 0xb,
+ FW_RI_QP_MODIFY = 0xc,
+ FW_RI_BYPASS = 0xd,
+ FW_RI_RECEIVE = 0xe,
+
+ FW_RI_SGE_EC_CR_RETURN = 0xf
+};
+
+enum fw_ri_wr_flags {
+ FW_RI_COMPLETION_FLAG = 0x01,
+ FW_RI_NOTIFICATION_FLAG = 0x02,
+ FW_RI_SOLICITED_EVENT_FLAG = 0x04,
+ FW_RI_READ_FENCE_FLAG = 0x08,
+ FW_RI_LOCAL_FENCE_FLAG = 0x10,
+ FW_RI_RDMA_READ_INVALIDATE = 0x20
+};
+
+enum fw_ri_mpa_attrs {
+ FW_RI_MPA_RX_MARKER_ENABLE = 0x01,
+ FW_RI_MPA_TX_MARKER_ENABLE = 0x02,
+ FW_RI_MPA_CRC_ENABLE = 0x04,
+ FW_RI_MPA_IETF_ENABLE = 0x08
+};
+
+enum fw_ri_qp_caps {
+ FW_RI_QP_RDMA_READ_ENABLE = 0x01,
+ FW_RI_QP_RDMA_WRITE_ENABLE = 0x02,
+ FW_RI_QP_BIND_ENABLE = 0x04,
+ FW_RI_QP_FAST_REGISTER_ENABLE = 0x08,
+ FW_RI_QP_STAG0_ENABLE = 0x10
+};
+
+enum fw_ri_addr_type {
+ FW_RI_ZERO_BASED_TO = 0x00,
+ FW_RI_VA_BASED_TO = 0x01
+};
+
+enum fw_ri_mem_perms {
+ FW_RI_MEM_ACCESS_REM_WRITE = 0x01,
+ FW_RI_MEM_ACCESS_REM_READ = 0x02,
+ FW_RI_MEM_ACCESS_REM = 0x03,
+ FW_RI_MEM_ACCESS_LOCAL_WRITE = 0x04,
+ FW_RI_MEM_ACCESS_LOCAL_READ = 0x08,
+ FW_RI_MEM_ACCESS_LOCAL = 0x0C
+};
+
+enum fw_ri_stag_type {
+ FW_RI_STAG_NSMR = 0x00,
+ FW_RI_STAG_SMR = 0x01,
+ FW_RI_STAG_MW = 0x02,
+ FW_RI_STAG_MW_RELAXED = 0x03
+};
+
+enum fw_ri_data_op {
+ FW_RI_DATA_IMMD = 0x81,
+ FW_RI_DATA_DSGL = 0x82,
+ FW_RI_DATA_ISGL = 0x83
+};
+
+enum fw_ri_sgl_depth {
+ FW_RI_SGL_DEPTH_MAX_SQ = 16,
+ FW_RI_SGL_DEPTH_MAX_RQ = 4
+};
+
+struct fw_ri_dsge_pair {
+ __be32 len[2];
+ __be64 addr[2];
+};
+
+struct fw_ri_dsgl {
+ __u8 op;
+ __u8 r1;
+ __be16 nsge;
+ __be32 len0;
+ __be64 addr0;
+#ifndef C99_NOT_SUPPORTED
+ struct fw_ri_dsge_pair sge[0];
+#endif
+};
+
+struct fw_ri_sge {
+ __be32 stag;
+ __be32 len;
+ __be64 to;
+};
+
+struct fw_ri_isgl {
+ __u8 op;
+ __u8 r1;
+ __be16 nsge;
+ __be32 r2;
+#ifndef C99_NOT_SUPPORTED
+ struct fw_ri_sge sge[0];
+#endif
+};
+
+struct fw_ri_immd {
+ __u8 op;
+ __u8 r1;
+ __be16 r2;
+ __be32 immdlen;
+#ifndef C99_NOT_SUPPORTED
+ __u8 data[0];
+#endif
+};
+
+struct fw_ri_tpte {
+ __be32 valid_to_pdid;
+ __be32 locread_to_qpid;
+ __be32 nosnoop_pbladdr;
+ __be32 len_lo;
+ __be32 va_hi;
+ __be32 va_lo_fbo;
+ __be32 dca_mwbcnt_pstag;
+ __be32 len_hi;
+};
+
+#define FW_RI_TPTE_VALID_S 31
+#define FW_RI_TPTE_VALID_M 0x1
+#define FW_RI_TPTE_VALID_V(x) ((x) << FW_RI_TPTE_VALID_S)
+#define FW_RI_TPTE_VALID_G(x) \
+ (((x) >> FW_RI_TPTE_VALID_S) & FW_RI_TPTE_VALID_M)
+#define FW_RI_TPTE_VALID_F FW_RI_TPTE_VALID_V(1U)
+
+#define FW_RI_TPTE_STAGKEY_S 23
+#define FW_RI_TPTE_STAGKEY_M 0xff
+#define FW_RI_TPTE_STAGKEY_V(x) ((x) << FW_RI_TPTE_STAGKEY_S)
+#define FW_RI_TPTE_STAGKEY_G(x) \
+ (((x) >> FW_RI_TPTE_STAGKEY_S) & FW_RI_TPTE_STAGKEY_M)
+
+#define FW_RI_TPTE_STAGSTATE_S 22
+#define FW_RI_TPTE_STAGSTATE_M 0x1
+#define FW_RI_TPTE_STAGSTATE_V(x) ((x) << FW_RI_TPTE_STAGSTATE_S)
+#define FW_RI_TPTE_STAGSTATE_G(x) \
+ (((x) >> FW_RI_TPTE_STAGSTATE_S) & FW_RI_TPTE_STAGSTATE_M)
+#define FW_RI_TPTE_STAGSTATE_F FW_RI_TPTE_STAGSTATE_V(1U)
+
+#define FW_RI_TPTE_STAGTYPE_S 20
+#define FW_RI_TPTE_STAGTYPE_M 0x3
+#define FW_RI_TPTE_STAGTYPE_V(x) ((x) << FW_RI_TPTE_STAGTYPE_S)
+#define FW_RI_TPTE_STAGTYPE_G(x) \
+ (((x) >> FW_RI_TPTE_STAGTYPE_S) & FW_RI_TPTE_STAGTYPE_M)
+
+#define FW_RI_TPTE_PDID_S 0
+#define FW_RI_TPTE_PDID_M 0xfffff
+#define FW_RI_TPTE_PDID_V(x) ((x) << FW_RI_TPTE_PDID_S)
+#define FW_RI_TPTE_PDID_G(x) \
+ (((x) >> FW_RI_TPTE_PDID_S) & FW_RI_TPTE_PDID_M)
+
+#define FW_RI_TPTE_PERM_S 28
+#define FW_RI_TPTE_PERM_M 0xf
+#define FW_RI_TPTE_PERM_V(x) ((x) << FW_RI_TPTE_PERM_S)
+#define FW_RI_TPTE_PERM_G(x) \
+ (((x) >> FW_RI_TPTE_PERM_S) & FW_RI_TPTE_PERM_M)
+
+#define FW_RI_TPTE_REMINVDIS_S 27
+#define FW_RI_TPTE_REMINVDIS_M 0x1
+#define FW_RI_TPTE_REMINVDIS_V(x) ((x) << FW_RI_TPTE_REMINVDIS_S)
+#define FW_RI_TPTE_REMINVDIS_G(x) \
+ (((x) >> FW_RI_TPTE_REMINVDIS_S) & FW_RI_TPTE_REMINVDIS_M)
+#define FW_RI_TPTE_REMINVDIS_F FW_RI_TPTE_REMINVDIS_V(1U)
+
+#define FW_RI_TPTE_ADDRTYPE_S 26
+#define FW_RI_TPTE_ADDRTYPE_M 1
+#define FW_RI_TPTE_ADDRTYPE_V(x) ((x) << FW_RI_TPTE_ADDRTYPE_S)
+#define FW_RI_TPTE_ADDRTYPE_G(x) \
+ (((x) >> FW_RI_TPTE_ADDRTYPE_S) & FW_RI_TPTE_ADDRTYPE_M)
+#define FW_RI_TPTE_ADDRTYPE_F FW_RI_TPTE_ADDRTYPE_V(1U)
+
+#define FW_RI_TPTE_MWBINDEN_S 25
+#define FW_RI_TPTE_MWBINDEN_M 0x1
+#define FW_RI_TPTE_MWBINDEN_V(x) ((x) << FW_RI_TPTE_MWBINDEN_S)
+#define FW_RI_TPTE_MWBINDEN_G(x) \
+ (((x) >> FW_RI_TPTE_MWBINDEN_S) & FW_RI_TPTE_MWBINDEN_M)
+#define FW_RI_TPTE_MWBINDEN_F FW_RI_TPTE_MWBINDEN_V(1U)
+
+#define FW_RI_TPTE_PS_S 20
+#define FW_RI_TPTE_PS_M 0x1f
+#define FW_RI_TPTE_PS_V(x) ((x) << FW_RI_TPTE_PS_S)
+#define FW_RI_TPTE_PS_G(x) \
+ (((x) >> FW_RI_TPTE_PS_S) & FW_RI_TPTE_PS_M)
+
+#define FW_RI_TPTE_QPID_S 0
+#define FW_RI_TPTE_QPID_M 0xfffff
+#define FW_RI_TPTE_QPID_V(x) ((x) << FW_RI_TPTE_QPID_S)
+#define FW_RI_TPTE_QPID_G(x) \
+ (((x) >> FW_RI_TPTE_QPID_S) & FW_RI_TPTE_QPID_M)
+
+#define FW_RI_TPTE_NOSNOOP_S 30
+#define FW_RI_TPTE_NOSNOOP_M 0x1
+#define FW_RI_TPTE_NOSNOOP_V(x) ((x) << FW_RI_TPTE_NOSNOOP_S)
+#define FW_RI_TPTE_NOSNOOP_G(x) \
+ (((x) >> FW_RI_TPTE_NOSNOOP_S) & FW_RI_TPTE_NOSNOOP_M)
+#define FW_RI_TPTE_NOSNOOP_F FW_RI_TPTE_NOSNOOP_V(1U)
+
+#define FW_RI_TPTE_PBLADDR_S 0
+#define FW_RI_TPTE_PBLADDR_M 0x1fffffff
+#define FW_RI_TPTE_PBLADDR_V(x) ((x) << FW_RI_TPTE_PBLADDR_S)
+#define FW_RI_TPTE_PBLADDR_G(x) \
+ (((x) >> FW_RI_TPTE_PBLADDR_S) & FW_RI_TPTE_PBLADDR_M)
+
+#define FW_RI_TPTE_DCA_S 24
+#define FW_RI_TPTE_DCA_M 0x1f
+#define FW_RI_TPTE_DCA_V(x) ((x) << FW_RI_TPTE_DCA_S)
+#define FW_RI_TPTE_DCA_G(x) \
+ (((x) >> FW_RI_TPTE_DCA_S) & FW_RI_TPTE_DCA_M)
+
+#define FW_RI_TPTE_MWBCNT_PSTAG_S 0
+#define FW_RI_TPTE_MWBCNT_PSTAG_M 0xffffff
+#define FW_RI_TPTE_MWBCNT_PSTAT_V(x) \
+ ((x) << FW_RI_TPTE_MWBCNT_PSTAG_S)
+#define FW_RI_TPTE_MWBCNT_PSTAG_G(x) \
+ (((x) >> FW_RI_TPTE_MWBCNT_PSTAG_S) & FW_RI_TPTE_MWBCNT_PSTAG_M)
+
+enum fw_ri_res_type {
+ FW_RI_RES_TYPE_SQ,
+ FW_RI_RES_TYPE_RQ,
+ FW_RI_RES_TYPE_CQ,
+};
+
+enum fw_ri_res_op {
+ FW_RI_RES_OP_WRITE,
+ FW_RI_RES_OP_RESET,
+};
+
+struct fw_ri_res {
+ union fw_ri_restype {
+ struct fw_ri_res_sqrq {
+ __u8 restype;
+ __u8 op;
+ __be16 r3;
+ __be32 eqid;
+ __be32 r4[2];
+ __be32 fetchszm_to_iqid;
+ __be32 dcaen_to_eqsize;
+ __be64 eqaddr;
+ } sqrq;
+ struct fw_ri_res_cq {
+ __u8 restype;
+ __u8 op;
+ __be16 r3;
+ __be32 iqid;
+ __be32 r4[2];
+ __be32 iqandst_to_iqandstindex;
+ __be16 iqdroprss_to_iqesize;
+ __be16 iqsize;
+ __be64 iqaddr;
+ __be32 iqns_iqro;
+ __be32 r6_lo;
+ __be64 r7;
+ } cq;
+ } u;
+};
+
+struct fw_ri_res_wr {
+ __be32 op_nres;
+ __be32 len16_pkd;
+ __u64 cookie;
+#ifndef C99_NOT_SUPPORTED
+ struct fw_ri_res res[0];
+#endif
+};
+
+#define FW_RI_RES_WR_NRES_S 0
+#define FW_RI_RES_WR_NRES_M 0xff
+#define FW_RI_RES_WR_NRES_V(x) ((x) << FW_RI_RES_WR_NRES_S)
+#define FW_RI_RES_WR_NRES_G(x) \
+ (((x) >> FW_RI_RES_WR_NRES_S) & FW_RI_RES_WR_NRES_M)
+
+#define FW_RI_RES_WR_FETCHSZM_S 26
+#define FW_RI_RES_WR_FETCHSZM_M 0x1
+#define FW_RI_RES_WR_FETCHSZM_V(x) ((x) << FW_RI_RES_WR_FETCHSZM_S)
+#define FW_RI_RES_WR_FETCHSZM_G(x) \
+ (((x) >> FW_RI_RES_WR_FETCHSZM_S) & FW_RI_RES_WR_FETCHSZM_M)
+#define FW_RI_RES_WR_FETCHSZM_F FW_RI_RES_WR_FETCHSZM_V(1U)
+
+#define FW_RI_RES_WR_STATUSPGNS_S 25
+#define FW_RI_RES_WR_STATUSPGNS_M 0x1
+#define FW_RI_RES_WR_STATUSPGNS_V(x) ((x) << FW_RI_RES_WR_STATUSPGNS_S)
+#define FW_RI_RES_WR_STATUSPGNS_G(x) \
+ (((x) >> FW_RI_RES_WR_STATUSPGNS_S) & FW_RI_RES_WR_STATUSPGNS_M)
+#define FW_RI_RES_WR_STATUSPGNS_F FW_RI_RES_WR_STATUSPGNS_V(1U)
+
+#define FW_RI_RES_WR_STATUSPGRO_S 24
+#define FW_RI_RES_WR_STATUSPGRO_M 0x1
+#define FW_RI_RES_WR_STATUSPGRO_V(x) ((x) << FW_RI_RES_WR_STATUSPGRO_S)
+#define FW_RI_RES_WR_STATUSPGRO_G(x) \
+ (((x) >> FW_RI_RES_WR_STATUSPGRO_S) & FW_RI_RES_WR_STATUSPGRO_M)
+#define FW_RI_RES_WR_STATUSPGRO_F FW_RI_RES_WR_STATUSPGRO_V(1U)
+
+#define FW_RI_RES_WR_FETCHNS_S 23
+#define FW_RI_RES_WR_FETCHNS_M 0x1
+#define FW_RI_RES_WR_FETCHNS_V(x) ((x) << FW_RI_RES_WR_FETCHNS_S)
+#define FW_RI_RES_WR_FETCHNS_G(x) \
+ (((x) >> FW_RI_RES_WR_FETCHNS_S) & FW_RI_RES_WR_FETCHNS_M)
+#define FW_RI_RES_WR_FETCHNS_F FW_RI_RES_WR_FETCHNS_V(1U)
+
+#define FW_RI_RES_WR_FETCHRO_S 22
+#define FW_RI_RES_WR_FETCHRO_M 0x1
+#define FW_RI_RES_WR_FETCHRO_V(x) ((x) << FW_RI_RES_WR_FETCHRO_S)
+#define FW_RI_RES_WR_FETCHRO_G(x) \
+ (((x) >> FW_RI_RES_WR_FETCHRO_S) & FW_RI_RES_WR_FETCHRO_M)
+#define FW_RI_RES_WR_FETCHRO_F FW_RI_RES_WR_FETCHRO_V(1U)
+
+#define FW_RI_RES_WR_HOSTFCMODE_S 20
+#define FW_RI_RES_WR_HOSTFCMODE_M 0x3
+#define FW_RI_RES_WR_HOSTFCMODE_V(x) ((x) << FW_RI_RES_WR_HOSTFCMODE_S)
+#define FW_RI_RES_WR_HOSTFCMODE_G(x) \
+ (((x) >> FW_RI_RES_WR_HOSTFCMODE_S) & FW_RI_RES_WR_HOSTFCMODE_M)
+
+#define FW_RI_RES_WR_CPRIO_S 19
+#define FW_RI_RES_WR_CPRIO_M 0x1
+#define FW_RI_RES_WR_CPRIO_V(x) ((x) << FW_RI_RES_WR_CPRIO_S)
+#define FW_RI_RES_WR_CPRIO_G(x) \
+ (((x) >> FW_RI_RES_WR_CPRIO_S) & FW_RI_RES_WR_CPRIO_M)
+#define FW_RI_RES_WR_CPRIO_F FW_RI_RES_WR_CPRIO_V(1U)
+
+#define FW_RI_RES_WR_ONCHIP_S 18
+#define FW_RI_RES_WR_ONCHIP_M 0x1
+#define FW_RI_RES_WR_ONCHIP_V(x) ((x) << FW_RI_RES_WR_ONCHIP_S)
+#define FW_RI_RES_WR_ONCHIP_G(x) \
+ (((x) >> FW_RI_RES_WR_ONCHIP_S) & FW_RI_RES_WR_ONCHIP_M)
+#define FW_RI_RES_WR_ONCHIP_F FW_RI_RES_WR_ONCHIP_V(1U)
+
+#define FW_RI_RES_WR_PCIECHN_S 16
+#define FW_RI_RES_WR_PCIECHN_M 0x3
+#define FW_RI_RES_WR_PCIECHN_V(x) ((x) << FW_RI_RES_WR_PCIECHN_S)
+#define FW_RI_RES_WR_PCIECHN_G(x) \
+ (((x) >> FW_RI_RES_WR_PCIECHN_S) & FW_RI_RES_WR_PCIECHN_M)
+
+#define FW_RI_RES_WR_IQID_S 0
+#define FW_RI_RES_WR_IQID_M 0xffff
+#define FW_RI_RES_WR_IQID_V(x) ((x) << FW_RI_RES_WR_IQID_S)
+#define FW_RI_RES_WR_IQID_G(x) \
+ (((x) >> FW_RI_RES_WR_IQID_S) & FW_RI_RES_WR_IQID_M)
+
+#define FW_RI_RES_WR_DCAEN_S 31
+#define FW_RI_RES_WR_DCAEN_M 0x1
+#define FW_RI_RES_WR_DCAEN_V(x) ((x) << FW_RI_RES_WR_DCAEN_S)
+#define FW_RI_RES_WR_DCAEN_G(x) \
+ (((x) >> FW_RI_RES_WR_DCAEN_S) & FW_RI_RES_WR_DCAEN_M)
+#define FW_RI_RES_WR_DCAEN_F FW_RI_RES_WR_DCAEN_V(1U)
+
+#define FW_RI_RES_WR_DCACPU_S 26
+#define FW_RI_RES_WR_DCACPU_M 0x1f
+#define FW_RI_RES_WR_DCACPU_V(x) ((x) << FW_RI_RES_WR_DCACPU_S)
+#define FW_RI_RES_WR_DCACPU_G(x) \
+ (((x) >> FW_RI_RES_WR_DCACPU_S) & FW_RI_RES_WR_DCACPU_M)
+
+#define FW_RI_RES_WR_FBMIN_S 23
+#define FW_RI_RES_WR_FBMIN_M 0x7
+#define FW_RI_RES_WR_FBMIN_V(x) ((x) << FW_RI_RES_WR_FBMIN_S)
+#define FW_RI_RES_WR_FBMIN_G(x) \
+ (((x) >> FW_RI_RES_WR_FBMIN_S) & FW_RI_RES_WR_FBMIN_M)
+
+#define FW_RI_RES_WR_FBMAX_S 20
+#define FW_RI_RES_WR_FBMAX_M 0x7
+#define FW_RI_RES_WR_FBMAX_V(x) ((x) << FW_RI_RES_WR_FBMAX_S)
+#define FW_RI_RES_WR_FBMAX_G(x) \
+ (((x) >> FW_RI_RES_WR_FBMAX_S) & FW_RI_RES_WR_FBMAX_M)
+
+#define FW_RI_RES_WR_CIDXFTHRESHO_S 19
+#define FW_RI_RES_WR_CIDXFTHRESHO_M 0x1
+#define FW_RI_RES_WR_CIDXFTHRESHO_V(x) ((x) << FW_RI_RES_WR_CIDXFTHRESHO_S)
+#define FW_RI_RES_WR_CIDXFTHRESHO_G(x) \
+ (((x) >> FW_RI_RES_WR_CIDXFTHRESHO_S) & FW_RI_RES_WR_CIDXFTHRESHO_M)
+#define FW_RI_RES_WR_CIDXFTHRESHO_F FW_RI_RES_WR_CIDXFTHRESHO_V(1U)
+
+#define FW_RI_RES_WR_CIDXFTHRESH_S 16
+#define FW_RI_RES_WR_CIDXFTHRESH_M 0x7
+#define FW_RI_RES_WR_CIDXFTHRESH_V(x) ((x) << FW_RI_RES_WR_CIDXFTHRESH_S)
+#define FW_RI_RES_WR_CIDXFTHRESH_G(x) \
+ (((x) >> FW_RI_RES_WR_CIDXFTHRESH_S) & FW_RI_RES_WR_CIDXFTHRESH_M)
+
+#define FW_RI_RES_WR_EQSIZE_S 0
+#define FW_RI_RES_WR_EQSIZE_M 0xffff
+#define FW_RI_RES_WR_EQSIZE_V(x) ((x) << FW_RI_RES_WR_EQSIZE_S)
+#define FW_RI_RES_WR_EQSIZE_G(x) \
+ (((x) >> FW_RI_RES_WR_EQSIZE_S) & FW_RI_RES_WR_EQSIZE_M)
+
+#define FW_RI_RES_WR_IQANDST_S 15
+#define FW_RI_RES_WR_IQANDST_M 0x1
+#define FW_RI_RES_WR_IQANDST_V(x) ((x) << FW_RI_RES_WR_IQANDST_S)
+#define FW_RI_RES_WR_IQANDST_G(x) \
+ (((x) >> FW_RI_RES_WR_IQANDST_S) & FW_RI_RES_WR_IQANDST_M)
+#define FW_RI_RES_WR_IQANDST_F FW_RI_RES_WR_IQANDST_V(1U)
+
+#define FW_RI_RES_WR_IQANUS_S 14
+#define FW_RI_RES_WR_IQANUS_M 0x1
+#define FW_RI_RES_WR_IQANUS_V(x) ((x) << FW_RI_RES_WR_IQANUS_S)
+#define FW_RI_RES_WR_IQANUS_G(x) \
+ (((x) >> FW_RI_RES_WR_IQANUS_S) & FW_RI_RES_WR_IQANUS_M)
+#define FW_RI_RES_WR_IQANUS_F FW_RI_RES_WR_IQANUS_V(1U)
+
+#define FW_RI_RES_WR_IQANUD_S 12
+#define FW_RI_RES_WR_IQANUD_M 0x3
+#define FW_RI_RES_WR_IQANUD_V(x) ((x) << FW_RI_RES_WR_IQANUD_S)
+#define FW_RI_RES_WR_IQANUD_G(x) \
+ (((x) >> FW_RI_RES_WR_IQANUD_S) & FW_RI_RES_WR_IQANUD_M)
+
+#define FW_RI_RES_WR_IQANDSTINDEX_S 0
+#define FW_RI_RES_WR_IQANDSTINDEX_M 0xfff
+#define FW_RI_RES_WR_IQANDSTINDEX_V(x) ((x) << FW_RI_RES_WR_IQANDSTINDEX_S)
+#define FW_RI_RES_WR_IQANDSTINDEX_G(x) \
+ (((x) >> FW_RI_RES_WR_IQANDSTINDEX_S) & FW_RI_RES_WR_IQANDSTINDEX_M)
+
+#define FW_RI_RES_WR_IQDROPRSS_S 15
+#define FW_RI_RES_WR_IQDROPRSS_M 0x1
+#define FW_RI_RES_WR_IQDROPRSS_V(x) ((x) << FW_RI_RES_WR_IQDROPRSS_S)
+#define FW_RI_RES_WR_IQDROPRSS_G(x) \
+ (((x) >> FW_RI_RES_WR_IQDROPRSS_S) & FW_RI_RES_WR_IQDROPRSS_M)
+#define FW_RI_RES_WR_IQDROPRSS_F FW_RI_RES_WR_IQDROPRSS_V(1U)
+
+#define FW_RI_RES_WR_IQGTSMODE_S 14
+#define FW_RI_RES_WR_IQGTSMODE_M 0x1
+#define FW_RI_RES_WR_IQGTSMODE_V(x) ((x) << FW_RI_RES_WR_IQGTSMODE_S)
+#define FW_RI_RES_WR_IQGTSMODE_G(x) \
+ (((x) >> FW_RI_RES_WR_IQGTSMODE_S) & FW_RI_RES_WR_IQGTSMODE_M)
+#define FW_RI_RES_WR_IQGTSMODE_F FW_RI_RES_WR_IQGTSMODE_V(1U)
+
+#define FW_RI_RES_WR_IQPCIECH_S 12
+#define FW_RI_RES_WR_IQPCIECH_M 0x3
+#define FW_RI_RES_WR_IQPCIECH_V(x) ((x) << FW_RI_RES_WR_IQPCIECH_S)
+#define FW_RI_RES_WR_IQPCIECH_G(x) \
+ (((x) >> FW_RI_RES_WR_IQPCIECH_S) & FW_RI_RES_WR_IQPCIECH_M)
+
+#define FW_RI_RES_WR_IQDCAEN_S 11
+#define FW_RI_RES_WR_IQDCAEN_M 0x1
+#define FW_RI_RES_WR_IQDCAEN_V(x) ((x) << FW_RI_RES_WR_IQDCAEN_S)
+#define FW_RI_RES_WR_IQDCAEN_G(x) \
+ (((x) >> FW_RI_RES_WR_IQDCAEN_S) & FW_RI_RES_WR_IQDCAEN_M)
+#define FW_RI_RES_WR_IQDCAEN_F FW_RI_RES_WR_IQDCAEN_V(1U)
+
+#define FW_RI_RES_WR_IQDCACPU_S 6
+#define FW_RI_RES_WR_IQDCACPU_M 0x1f
+#define FW_RI_RES_WR_IQDCACPU_V(x) ((x) << FW_RI_RES_WR_IQDCACPU_S)
+#define FW_RI_RES_WR_IQDCACPU_G(x) \
+ (((x) >> FW_RI_RES_WR_IQDCACPU_S) & FW_RI_RES_WR_IQDCACPU_M)
+
+#define FW_RI_RES_WR_IQINTCNTTHRESH_S 4
+#define FW_RI_RES_WR_IQINTCNTTHRESH_M 0x3
+#define FW_RI_RES_WR_IQINTCNTTHRESH_V(x) \
+ ((x) << FW_RI_RES_WR_IQINTCNTTHRESH_S)
+#define FW_RI_RES_WR_IQINTCNTTHRESH_G(x) \
+ (((x) >> FW_RI_RES_WR_IQINTCNTTHRESH_S) & FW_RI_RES_WR_IQINTCNTTHRESH_M)
+
+#define FW_RI_RES_WR_IQO_S 3
+#define FW_RI_RES_WR_IQO_M 0x1
+#define FW_RI_RES_WR_IQO_V(x) ((x) << FW_RI_RES_WR_IQO_S)
+#define FW_RI_RES_WR_IQO_G(x) \
+ (((x) >> FW_RI_RES_WR_IQO_S) & FW_RI_RES_WR_IQO_M)
+#define FW_RI_RES_WR_IQO_F FW_RI_RES_WR_IQO_V(1U)
+
+#define FW_RI_RES_WR_IQCPRIO_S 2
+#define FW_RI_RES_WR_IQCPRIO_M 0x1
+#define FW_RI_RES_WR_IQCPRIO_V(x) ((x) << FW_RI_RES_WR_IQCPRIO_S)
+#define FW_RI_RES_WR_IQCPRIO_G(x) \
+ (((x) >> FW_RI_RES_WR_IQCPRIO_S) & FW_RI_RES_WR_IQCPRIO_M)
+#define FW_RI_RES_WR_IQCPRIO_F FW_RI_RES_WR_IQCPRIO_V(1U)
+
+#define FW_RI_RES_WR_IQESIZE_S 0
+#define FW_RI_RES_WR_IQESIZE_M 0x3
+#define FW_RI_RES_WR_IQESIZE_V(x) ((x) << FW_RI_RES_WR_IQESIZE_S)
+#define FW_RI_RES_WR_IQESIZE_G(x) \
+ (((x) >> FW_RI_RES_WR_IQESIZE_S) & FW_RI_RES_WR_IQESIZE_M)
+
+#define FW_RI_RES_WR_IQNS_S 31
+#define FW_RI_RES_WR_IQNS_M 0x1
+#define FW_RI_RES_WR_IQNS_V(x) ((x) << FW_RI_RES_WR_IQNS_S)
+#define FW_RI_RES_WR_IQNS_G(x) \
+ (((x) >> FW_RI_RES_WR_IQNS_S) & FW_RI_RES_WR_IQNS_M)
+#define FW_RI_RES_WR_IQNS_F FW_RI_RES_WR_IQNS_V(1U)
+
+#define FW_RI_RES_WR_IQRO_S 30
+#define FW_RI_RES_WR_IQRO_M 0x1
+#define FW_RI_RES_WR_IQRO_V(x) ((x) << FW_RI_RES_WR_IQRO_S)
+#define FW_RI_RES_WR_IQRO_G(x) \
+ (((x) >> FW_RI_RES_WR_IQRO_S) & FW_RI_RES_WR_IQRO_M)
+#define FW_RI_RES_WR_IQRO_F FW_RI_RES_WR_IQRO_V(1U)
+
+struct fw_ri_rdma_write_wr {
+ __u8 opcode;
+ __u8 flags;
+ __u16 wrid;
+ __u8 r1[3];
+ __u8 len16;
+ __be64 r2;
+ __be32 plen;
+ __be32 stag_sink;
+ __be64 to_sink;
+#ifndef C99_NOT_SUPPORTED
+ union {
+ struct fw_ri_immd immd_src[0];
+ struct fw_ri_isgl isgl_src[0];
+ } u;
+#endif
+};
+
+struct fw_ri_send_wr {
+ __u8 opcode;
+ __u8 flags;
+ __u16 wrid;
+ __u8 r1[3];
+ __u8 len16;
+ __be32 sendop_pkd;
+ __be32 stag_inv;
+ __be32 plen;
+ __be32 r3;
+ __be64 r4;
+#ifndef C99_NOT_SUPPORTED
+ union {
+ struct fw_ri_immd immd_src[0];
+ struct fw_ri_isgl isgl_src[0];
+ } u;
+#endif
+};
+
+#define FW_RI_SEND_WR_SENDOP_S 0
+#define FW_RI_SEND_WR_SENDOP_M 0xf
+#define FW_RI_SEND_WR_SENDOP_V(x) ((x) << FW_RI_SEND_WR_SENDOP_S)
+#define FW_RI_SEND_WR_SENDOP_G(x) \
+ (((x) >> FW_RI_SEND_WR_SENDOP_S) & FW_RI_SEND_WR_SENDOP_M)
+
+struct fw_ri_rdma_read_wr {
+ __u8 opcode;
+ __u8 flags;
+ __u16 wrid;
+ __u8 r1[3];
+ __u8 len16;
+ __be64 r2;
+ __be32 stag_sink;
+ __be32 to_sink_hi;
+ __be32 to_sink_lo;
+ __be32 plen;
+ __be32 stag_src;
+ __be32 to_src_hi;
+ __be32 to_src_lo;
+ __be32 r5;
+};
+
+struct fw_ri_recv_wr {
+ __u8 opcode;
+ __u8 r1;
+ __u16 wrid;
+ __u8 r2[3];
+ __u8 len16;
+ struct fw_ri_isgl isgl;
+};
+
+struct fw_ri_bind_mw_wr {
+ __u8 opcode;
+ __u8 flags;
+ __u16 wrid;
+ __u8 r1[3];
+ __u8 len16;
+ __u8 qpbinde_to_dcacpu;
+ __u8 pgsz_shift;
+ __u8 addr_type;
+ __u8 mem_perms;
+ __be32 stag_mr;
+ __be32 stag_mw;
+ __be32 r3;
+ __be64 len_mw;
+ __be64 va_fbo;
+ __be64 r4;
+};
+
+#define FW_RI_BIND_MW_WR_QPBINDE_S 6
+#define FW_RI_BIND_MW_WR_QPBINDE_M 0x1
+#define FW_RI_BIND_MW_WR_QPBINDE_V(x) ((x) << FW_RI_BIND_MW_WR_QPBINDE_S)
+#define FW_RI_BIND_MW_WR_QPBINDE_G(x) \
+ (((x) >> FW_RI_BIND_MW_WR_QPBINDE_S) & FW_RI_BIND_MW_WR_QPBINDE_M)
+#define FW_RI_BIND_MW_WR_QPBINDE_F FW_RI_BIND_MW_WR_QPBINDE_V(1U)
+
+#define FW_RI_BIND_MW_WR_NS_S 5
+#define FW_RI_BIND_MW_WR_NS_M 0x1
+#define FW_RI_BIND_MW_WR_NS_V(x) ((x) << FW_RI_BIND_MW_WR_NS_S)
+#define FW_RI_BIND_MW_WR_NS_G(x) \
+ (((x) >> FW_RI_BIND_MW_WR_NS_S) & FW_RI_BIND_MW_WR_NS_M)
+#define FW_RI_BIND_MW_WR_NS_F FW_RI_BIND_MW_WR_NS_V(1U)
+
+#define FW_RI_BIND_MW_WR_DCACPU_S 0
+#define FW_RI_BIND_MW_WR_DCACPU_M 0x1f
+#define FW_RI_BIND_MW_WR_DCACPU_V(x) ((x) << FW_RI_BIND_MW_WR_DCACPU_S)
+#define FW_RI_BIND_MW_WR_DCACPU_G(x) \
+ (((x) >> FW_RI_BIND_MW_WR_DCACPU_S) & FW_RI_BIND_MW_WR_DCACPU_M)
+
+struct fw_ri_fr_nsmr_wr {
+ __u8 opcode;
+ __u8 flags;
+ __u16 wrid;
+ __u8 r1[3];
+ __u8 len16;
+ __u8 qpbinde_to_dcacpu;
+ __u8 pgsz_shift;
+ __u8 addr_type;
+ __u8 mem_perms;
+ __be32 stag;
+ __be32 len_hi;
+ __be32 len_lo;
+ __be32 va_hi;
+ __be32 va_lo_fbo;
+};
+
+#define FW_RI_FR_NSMR_WR_QPBINDE_S 6
+#define FW_RI_FR_NSMR_WR_QPBINDE_M 0x1
+#define FW_RI_FR_NSMR_WR_QPBINDE_V(x) ((x) << FW_RI_FR_NSMR_WR_QPBINDE_S)
+#define FW_RI_FR_NSMR_WR_QPBINDE_G(x) \
+ (((x) >> FW_RI_FR_NSMR_WR_QPBINDE_S) & FW_RI_FR_NSMR_WR_QPBINDE_M)
+#define FW_RI_FR_NSMR_WR_QPBINDE_F FW_RI_FR_NSMR_WR_QPBINDE_V(1U)
+
+#define FW_RI_FR_NSMR_WR_NS_S 5
+#define FW_RI_FR_NSMR_WR_NS_M 0x1
+#define FW_RI_FR_NSMR_WR_NS_V(x) ((x) << FW_RI_FR_NSMR_WR_NS_S)
+#define FW_RI_FR_NSMR_WR_NS_G(x) \
+ (((x) >> FW_RI_FR_NSMR_WR_NS_S) & FW_RI_FR_NSMR_WR_NS_M)
+#define FW_RI_FR_NSMR_WR_NS_F FW_RI_FR_NSMR_WR_NS_V(1U)
+
+#define FW_RI_FR_NSMR_WR_DCACPU_S 0
+#define FW_RI_FR_NSMR_WR_DCACPU_M 0x1f
+#define FW_RI_FR_NSMR_WR_DCACPU_V(x) ((x) << FW_RI_FR_NSMR_WR_DCACPU_S)
+#define FW_RI_FR_NSMR_WR_DCACPU_G(x) \
+ (((x) >> FW_RI_FR_NSMR_WR_DCACPU_S) & FW_RI_FR_NSMR_WR_DCACPU_M)
+
+struct fw_ri_inv_lstag_wr {
+ __u8 opcode;
+ __u8 flags;
+ __u16 wrid;
+ __u8 r1[3];
+ __u8 len16;
+ __be32 r2;
+ __be32 stag_inv;
+};
+
+enum fw_ri_type {
+ FW_RI_TYPE_INIT,
+ FW_RI_TYPE_FINI,
+ FW_RI_TYPE_TERMINATE
+};
+
+enum fw_ri_init_p2ptype {
+ FW_RI_INIT_P2PTYPE_RDMA_WRITE = FW_RI_RDMA_WRITE,
+ FW_RI_INIT_P2PTYPE_READ_REQ = FW_RI_READ_REQ,
+ FW_RI_INIT_P2PTYPE_SEND = FW_RI_SEND,
+ FW_RI_INIT_P2PTYPE_SEND_WITH_INV = FW_RI_SEND_WITH_INV,
+ FW_RI_INIT_P2PTYPE_SEND_WITH_SE = FW_RI_SEND_WITH_SE,
+ FW_RI_INIT_P2PTYPE_SEND_WITH_SE_INV = FW_RI_SEND_WITH_SE_INV,
+ FW_RI_INIT_P2PTYPE_DISABLED = 0xf,
+};
+
+struct fw_ri_wr {
+ __be32 op_compl;
+ __be32 flowid_len16;
+ __u64 cookie;
+ union fw_ri {
+ struct fw_ri_init {
+ __u8 type;
+ __u8 mpareqbit_p2ptype;
+ __u8 r4[2];
+ __u8 mpa_attrs;
+ __u8 qp_caps;
+ __be16 nrqe;
+ __be32 pdid;
+ __be32 qpid;
+ __be32 sq_eqid;
+ __be32 rq_eqid;
+ __be32 scqid;
+ __be32 rcqid;
+ __be32 ord_max;
+ __be32 ird_max;
+ __be32 iss;
+ __be32 irs;
+ __be32 hwrqsize;
+ __be32 hwrqaddr;
+ __be64 r5;
+ union fw_ri_init_p2p {
+ struct fw_ri_rdma_write_wr write;
+ struct fw_ri_rdma_read_wr read;
+ struct fw_ri_send_wr send;
+ } u;
+ } init;
+ struct fw_ri_fini {
+ __u8 type;
+ __u8 r3[7];
+ __be64 r4;
+ } fini;
+ struct fw_ri_terminate {
+ __u8 type;
+ __u8 r3[3];
+ __be32 immdlen;
+ __u8 termmsg[40];
+ } terminate;
+ } u;
+};
+
+#define FW_RI_WR_MPAREQBIT_S 7
+#define FW_RI_WR_MPAREQBIT_M 0x1
+#define FW_RI_WR_MPAREQBIT_V(x) ((x) << FW_RI_WR_MPAREQBIT_S)
+#define FW_RI_WR_MPAREQBIT_G(x) \
+ (((x) >> FW_RI_WR_MPAREQBIT_S) & FW_RI_WR_MPAREQBIT_M)
+#define FW_RI_WR_MPAREQBIT_F FW_RI_WR_MPAREQBIT_V(1U)
+
+#define FW_RI_WR_P2PTYPE_S 0
+#define FW_RI_WR_P2PTYPE_M 0xf
+#define FW_RI_WR_P2PTYPE_V(x) ((x) << FW_RI_WR_P2PTYPE_S)
+#define FW_RI_WR_P2PTYPE_G(x) \
+ (((x) >> FW_RI_WR_P2PTYPE_S) & FW_RI_WR_P2PTYPE_M)
+
+#endif /* _T4FW_RI_API_H_ */
diff --git a/contrib/ofed/libcxgb4/verbs.c b/contrib/ofed/libcxgb4/verbs.c
new file mode 100644
index 0000000..04d765d
--- /dev/null
+++ b/contrib/ofed/libcxgb4/verbs.c
@@ -0,0 +1,710 @@
+/*
+ * Copyright (c) 2006-2016 Chelsio, Inc. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+#include <config.h>
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <errno.h>
+#include <pthread.h>
+#include <sys/mman.h>
+#include <inttypes.h>
+#include <assert.h>
+
+#include "libcxgb4.h"
+#include "cxgb4-abi.h"
+
+#define MASKED(x) (void *)((unsigned long)(x) & c4iw_page_mask)
+
+int c4iw_query_device(struct ibv_context *context, struct ibv_device_attr *attr)
+{
+ struct ibv_query_device cmd;
+ uint64_t raw_fw_ver;
+ u8 major, minor, sub_minor, build;
+ int ret;
+
+ ret = ibv_cmd_query_device(context, attr, &raw_fw_ver, &cmd,
+ sizeof cmd);
+ if (ret)
+ return ret;
+
+ major = (raw_fw_ver >> 24) & 0xff;
+ minor = (raw_fw_ver >> 16) & 0xff;
+ sub_minor = (raw_fw_ver >> 8) & 0xff;
+ build = raw_fw_ver & 0xff;
+
+ snprintf(attr->fw_ver, sizeof attr->fw_ver,
+ "%d.%d.%d.%d", major, minor, sub_minor, build);
+
+ return 0;
+}
+
+int c4iw_query_port(struct ibv_context *context, uint8_t port,
+ struct ibv_port_attr *attr)
+{
+ struct ibv_query_port cmd;
+
+ return ibv_cmd_query_port(context, port, attr, &cmd, sizeof cmd);
+}
+
+struct ibv_pd *c4iw_alloc_pd(struct ibv_context *context)
+{
+ struct ibv_alloc_pd cmd;
+ struct c4iw_alloc_pd_resp resp;
+ struct c4iw_pd *pd;
+
+ pd = malloc(sizeof *pd);
+ if (!pd)
+ return NULL;
+
+ if (ibv_cmd_alloc_pd(context, &pd->ibv_pd, &cmd, sizeof cmd,
+ &resp.ibv_resp, sizeof resp)) {
+ free(pd);
+ return NULL;
+ }
+
+ return &pd->ibv_pd;
+}
+
+int c4iw_free_pd(struct ibv_pd *pd)
+{
+ int ret;
+
+ ret = ibv_cmd_dealloc_pd(pd);
+ if (ret)
+ return ret;
+
+ free(pd);
+ return 0;
+}
+
+static struct ibv_mr *__c4iw_reg_mr(struct ibv_pd *pd, void *addr,
+ size_t length, uint64_t hca_va,
+ int access)
+{
+ struct c4iw_mr *mhp;
+ struct ibv_reg_mr cmd;
+ struct ibv_reg_mr_resp resp;
+ struct c4iw_dev *dev = to_c4iw_dev(pd->context->device);
+
+ mhp = malloc(sizeof *mhp);
+ if (!mhp)
+ return NULL;
+
+ if (ibv_cmd_reg_mr(pd, addr, length, hca_va,
+ access, &mhp->ibv_mr, &cmd, sizeof cmd,
+ &resp, sizeof resp)) {
+ free(mhp);
+ return NULL;
+ }
+
+ mhp->va_fbo = hca_va;
+ mhp->len = length;
+
+ PDBG("%s stag 0x%x va_fbo 0x%" PRIx64 " len %d\n",
+ __func__, mhp->ibv_mr.rkey, mhp->va_fbo, mhp->len);
+
+ pthread_spin_lock(&dev->lock);
+ dev->mmid2ptr[c4iw_mmid(mhp->ibv_mr.lkey)] = mhp;
+ pthread_spin_unlock(&dev->lock);
+ INC_STAT(mr);
+ return &mhp->ibv_mr;
+}
+
+struct ibv_mr *c4iw_reg_mr(struct ibv_pd *pd, void *addr,
+ size_t length, int access)
+{
+ PDBG("%s addr %p length %ld\n", __func__, addr, length);
+ return __c4iw_reg_mr(pd, addr, length, (uintptr_t) addr, access);
+}
+
+int c4iw_dereg_mr(struct ibv_mr *mr)
+{
+ int ret;
+ struct c4iw_dev *dev = to_c4iw_dev(mr->pd->context->device);
+
+ ret = ibv_cmd_dereg_mr(mr);
+ if (ret)
+ return ret;
+
+ pthread_spin_lock(&dev->lock);
+ dev->mmid2ptr[c4iw_mmid(mr->lkey)] = NULL;
+ pthread_spin_unlock(&dev->lock);
+
+ free(to_c4iw_mr(mr));
+
+ return 0;
+}
+
+struct ibv_cq *c4iw_create_cq(struct ibv_context *context, int cqe,
+ struct ibv_comp_channel *channel, int comp_vector)
+{
+ struct ibv_create_cq cmd;
+ struct c4iw_create_cq_resp resp;
+ struct c4iw_cq *chp;
+ struct c4iw_dev *dev = to_c4iw_dev(context->device);
+ int ret;
+
+ chp = calloc(1, sizeof *chp);
+ if (!chp) {
+ return NULL;
+ }
+
+ resp.reserved = 0;
+ ret = ibv_cmd_create_cq(context, cqe, channel, comp_vector,
+ &chp->ibv_cq, &cmd, sizeof cmd,
+ &resp.ibv_resp, sizeof resp);
+ if (ret)
+ goto err1;
+
+ if (resp.reserved)
+ PDBG("%s c4iw_create_cq_resp reserved field modified by kernel\n",
+ __FUNCTION__);
+
+ pthread_spin_init(&chp->lock, PTHREAD_PROCESS_PRIVATE);
+#ifdef STALL_DETECTION
+ gettimeofday(&chp->time, NULL);
+#endif
+ chp->rhp = dev;
+ chp->cq.qid_mask = resp.qid_mask;
+ chp->cq.cqid = resp.cqid;
+ chp->cq.size = resp.size;
+ chp->cq.memsize = resp.memsize;
+ chp->cq.gen = 1;
+ chp->cq.queue = mmap(NULL, chp->cq.memsize, PROT_READ|PROT_WRITE,
+ MAP_SHARED, context->cmd_fd, resp.key);
+ if (chp->cq.queue == MAP_FAILED)
+ goto err2;
+
+ chp->cq.ugts = mmap(NULL, c4iw_page_size, PROT_WRITE, MAP_SHARED,
+ context->cmd_fd, resp.gts_key);
+ if (chp->cq.ugts == MAP_FAILED)
+ goto err3;
+
+ if (dev_is_t4(chp->rhp))
+ chp->cq.ugts += 1;
+ else
+ chp->cq.ugts += 5;
+ chp->cq.sw_queue = calloc(chp->cq.size, sizeof *chp->cq.queue);
+ if (!chp->cq.sw_queue)
+ goto err4;
+
+ PDBG("%s cqid 0x%x key %" PRIx64 " va %p memsize %lu gts_key %"
+ PRIx64 " va %p qid_mask 0x%x\n",
+ __func__, chp->cq.cqid, resp.key, chp->cq.queue,
+ chp->cq.memsize, resp.gts_key, chp->cq.ugts, chp->cq.qid_mask);
+
+ pthread_spin_lock(&dev->lock);
+ dev->cqid2ptr[chp->cq.cqid] = chp;
+ pthread_spin_unlock(&dev->lock);
+ INC_STAT(cq);
+ return &chp->ibv_cq;
+err4:
+ munmap(MASKED(chp->cq.ugts), c4iw_page_size);
+err3:
+ munmap(chp->cq.queue, chp->cq.memsize);
+err2:
+ (void)ibv_cmd_destroy_cq(&chp->ibv_cq);
+err1:
+ free(chp);
+ return NULL;
+}
+
+int c4iw_resize_cq(struct ibv_cq *ibcq, int cqe)
+{
+#if 0
+ int ret;
+
+ struct ibv_resize_cq cmd;
+ struct ibv_resize_cq_resp resp;
+ ret = ibv_cmd_resize_cq(ibcq, cqe, &cmd, sizeof cmd, &resp, sizeof resp);
+ PDBG("%s ret %d\n", __func__, ret);
+ return ret;
+#else
+ return -ENOSYS;
+#endif
+}
+
+int c4iw_destroy_cq(struct ibv_cq *ibcq)
+{
+ int ret;
+ struct c4iw_cq *chp = to_c4iw_cq(ibcq);
+ struct c4iw_dev *dev = to_c4iw_dev(ibcq->context->device);
+
+ chp->cq.error = 1;
+ ret = ibv_cmd_destroy_cq(ibcq);
+ if (ret) {
+ return ret;
+ }
+ munmap(MASKED(chp->cq.ugts), c4iw_page_size);
+ munmap(chp->cq.queue, chp->cq.memsize);
+
+ pthread_spin_lock(&dev->lock);
+ dev->cqid2ptr[chp->cq.cqid] = NULL;
+ pthread_spin_unlock(&dev->lock);
+
+ free(chp->cq.sw_queue);
+ free(chp);
+ return 0;
+}
+
+struct ibv_srq *c4iw_create_srq(struct ibv_pd *pd,
+ struct ibv_srq_init_attr *attr)
+{
+ return NULL;
+}
+
+int c4iw_modify_srq(struct ibv_srq *srq, struct ibv_srq_attr *attr,
+ int attr_mask)
+{
+ return ENOSYS;
+}
+
+int c4iw_destroy_srq(struct ibv_srq *srq)
+{
+ return ENOSYS;
+}
+
+int c4iw_post_srq_recv(struct ibv_srq *ibsrq, struct ibv_recv_wr *wr,
+ struct ibv_recv_wr **bad_wr)
+{
+ return ENOSYS;
+}
+
+static struct ibv_qp *create_qp_v0(struct ibv_pd *pd,
+ struct ibv_qp_init_attr *attr)
+{
+ struct ibv_create_qp cmd;
+ struct c4iw_create_qp_resp_v0 resp;
+ struct c4iw_qp *qhp;
+ struct c4iw_dev *dev = to_c4iw_dev(pd->context->device);
+ int ret;
+ void *dbva;
+
+ PDBG("%s enter qp\n", __func__);
+ qhp = calloc(1, sizeof *qhp);
+ if (!qhp)
+ goto err1;
+
+ ret = ibv_cmd_create_qp(pd, &qhp->ibv_qp, attr, &cmd,
+ sizeof cmd, &resp.ibv_resp, sizeof resp);
+ if (ret)
+ goto err2;
+
+ PDBG("%s sqid 0x%x sq key %" PRIx64 " sq db/gts key %" PRIx64
+ " rqid 0x%x rq key %" PRIx64 " rq db/gts key %" PRIx64
+ " qid_mask 0x%x\n",
+ __func__,
+ resp.sqid, resp.sq_key, resp.sq_db_gts_key,
+ resp.rqid, resp.rq_key, resp.rq_db_gts_key, resp.qid_mask);
+
+ qhp->wq.qid_mask = resp.qid_mask;
+ qhp->rhp = dev;
+ qhp->wq.sq.qid = resp.sqid;
+ qhp->wq.sq.size = resp.sq_size;
+ qhp->wq.sq.memsize = resp.sq_memsize;
+ qhp->wq.sq.flags = 0;
+ qhp->wq.rq.msn = 1;
+ qhp->wq.rq.qid = resp.rqid;
+ qhp->wq.rq.size = resp.rq_size;
+ qhp->wq.rq.memsize = resp.rq_memsize;
+ pthread_spin_init(&qhp->lock, PTHREAD_PROCESS_PRIVATE);
+
+ dbva = mmap(NULL, c4iw_page_size, PROT_WRITE, MAP_SHARED,
+ pd->context->cmd_fd, resp.sq_db_gts_key);
+ if (dbva == MAP_FAILED)
+ goto err3;
+
+ qhp->wq.sq.udb = dbva;
+ qhp->wq.sq.queue = mmap(NULL, qhp->wq.sq.memsize,
+ PROT_WRITE, MAP_SHARED,
+ pd->context->cmd_fd, resp.sq_key);
+ if (qhp->wq.sq.queue == MAP_FAILED)
+ goto err4;
+
+ dbva = mmap(NULL, c4iw_page_size, PROT_WRITE, MAP_SHARED,
+ pd->context->cmd_fd, resp.rq_db_gts_key);
+ if (dbva == MAP_FAILED)
+ goto err5;
+ qhp->wq.rq.udb = dbva;
+ qhp->wq.rq.queue = mmap(NULL, qhp->wq.rq.memsize,
+ PROT_WRITE, MAP_SHARED,
+ pd->context->cmd_fd, resp.rq_key);
+ if (qhp->wq.rq.queue == MAP_FAILED)
+ goto err6;
+
+ qhp->wq.sq.sw_sq = calloc(qhp->wq.sq.size, sizeof (struct t4_swsqe));
+ if (!qhp->wq.sq.sw_sq)
+ goto err7;
+
+ qhp->wq.rq.sw_rq = calloc(qhp->wq.rq.size, sizeof (uint64_t));
+ if (!qhp->wq.rq.sw_rq)
+ goto err8;
+
+ PDBG("%s sq dbva %p sq qva %p sq depth %u sq memsize %lu "
+ " rq dbva %p rq qva %p rq depth %u rq memsize %lu\n",
+ __func__,
+ qhp->wq.sq.udb, qhp->wq.sq.queue,
+ qhp->wq.sq.size, qhp->wq.sq.memsize,
+ qhp->wq.rq.udb, qhp->wq.rq.queue,
+ qhp->wq.rq.size, qhp->wq.rq.memsize);
+
+ qhp->sq_sig_all = attr->sq_sig_all;
+
+ pthread_spin_lock(&dev->lock);
+ dev->qpid2ptr[qhp->wq.sq.qid] = qhp;
+ pthread_spin_unlock(&dev->lock);
+ INC_STAT(qp);
+ return &qhp->ibv_qp;
+err8:
+ free(qhp->wq.sq.sw_sq);
+err7:
+ munmap((void *)qhp->wq.rq.queue, qhp->wq.rq.memsize);
+err6:
+ munmap(MASKED(qhp->wq.rq.udb), c4iw_page_size);
+err5:
+ munmap((void *)qhp->wq.sq.queue, qhp->wq.sq.memsize);
+err4:
+ munmap(MASKED(qhp->wq.sq.udb), c4iw_page_size);
+err3:
+ (void)ibv_cmd_destroy_qp(&qhp->ibv_qp);
+err2:
+ free(qhp);
+err1:
+ return NULL;
+}
+
+static struct ibv_qp *create_qp(struct ibv_pd *pd,
+ struct ibv_qp_init_attr *attr)
+{
+ struct ibv_create_qp cmd;
+ struct c4iw_create_qp_resp resp;
+ struct c4iw_qp *qhp;
+ struct c4iw_dev *dev = to_c4iw_dev(pd->context->device);
+ struct c4iw_context *ctx = to_c4iw_context(pd->context);
+ int ret;
+ void *dbva;
+
+ PDBG("%s enter qp\n", __func__);
+ qhp = calloc(1, sizeof *qhp);
+ if (!qhp)
+ goto err1;
+
+ ret = ibv_cmd_create_qp(pd, &qhp->ibv_qp, attr, &cmd,
+ sizeof cmd, &resp.ibv_resp, sizeof resp);
+ if (ret)
+ goto err2;
+
+ PDBG("%s sqid 0x%x sq key %" PRIx64 " sq db/gts key %" PRIx64
+ " rqid 0x%x rq key %" PRIx64 " rq db/gts key %" PRIx64
+ " qid_mask 0x%x\n",
+ __func__,
+ resp.sqid, resp.sq_key, resp.sq_db_gts_key,
+ resp.rqid, resp.rq_key, resp.rq_db_gts_key, resp.qid_mask);
+
+ qhp->wq.qid_mask = resp.qid_mask;
+ qhp->rhp = dev;
+ qhp->wq.sq.qid = resp.sqid;
+ qhp->wq.sq.size = resp.sq_size;
+ qhp->wq.sq.memsize = resp.sq_memsize;
+ qhp->wq.sq.flags = resp.flags & C4IW_QPF_ONCHIP ? T4_SQ_ONCHIP : 0;
+ qhp->wq.sq.flush_cidx = -1;
+ qhp->wq.rq.msn = 1;
+ qhp->wq.rq.qid = resp.rqid;
+ qhp->wq.rq.size = resp.rq_size;
+ qhp->wq.rq.memsize = resp.rq_memsize;
+ if (ma_wr && resp.sq_memsize < (resp.sq_size + 1) *
+ sizeof *qhp->wq.sq.queue + 16*sizeof(__be64) ) {
+ ma_wr = 0;
+ fprintf(stderr, "libcxgb4 warning - downlevel iw_cxgb4 driver. "
+ "MA workaround disabled.\n");
+ }
+ pthread_spin_init(&qhp->lock, PTHREAD_PROCESS_PRIVATE);
+
+ dbva = mmap(NULL, c4iw_page_size, PROT_WRITE, MAP_SHARED,
+ pd->context->cmd_fd, resp.sq_db_gts_key);
+ if (dbva == MAP_FAILED)
+ goto err3;
+ qhp->wq.sq.udb = dbva;
+ if (!dev_is_t4(qhp->rhp)) {
+ unsigned long segment_offset = 128 * (qhp->wq.sq.qid &
+ qhp->wq.qid_mask);
+
+ if (segment_offset < c4iw_page_size) {
+ qhp->wq.sq.udb += segment_offset / 4;
+ qhp->wq.sq.wc_reg_available = 1;
+ } else
+ qhp->wq.sq.bar2_qid = qhp->wq.sq.qid & qhp->wq.qid_mask;
+ qhp->wq.sq.udb += 2;
+ }
+
+ qhp->wq.sq.queue = mmap(NULL, qhp->wq.sq.memsize,
+ PROT_READ|PROT_WRITE, MAP_SHARED,
+ pd->context->cmd_fd, resp.sq_key);
+ if (qhp->wq.sq.queue == MAP_FAILED)
+ goto err4;
+
+ dbva = mmap(NULL, c4iw_page_size, PROT_WRITE, MAP_SHARED,
+ pd->context->cmd_fd, resp.rq_db_gts_key);
+ if (dbva == MAP_FAILED)
+ goto err5;
+ qhp->wq.rq.udb = dbva;
+ if (!dev_is_t4(qhp->rhp)) {
+ unsigned long segment_offset = 128 * (qhp->wq.rq.qid &
+ qhp->wq.qid_mask);
+
+ if (segment_offset < c4iw_page_size) {
+ qhp->wq.rq.udb += segment_offset / 4;
+ qhp->wq.rq.wc_reg_available = 1;
+ } else
+ qhp->wq.rq.bar2_qid = qhp->wq.rq.qid & qhp->wq.qid_mask;
+ qhp->wq.rq.udb += 2;
+ }
+ qhp->wq.rq.queue = mmap(NULL, qhp->wq.rq.memsize,
+ PROT_READ|PROT_WRITE, MAP_SHARED,
+ pd->context->cmd_fd, resp.rq_key);
+ if (qhp->wq.rq.queue == MAP_FAILED)
+ goto err6;
+
+ qhp->wq.sq.sw_sq = calloc(qhp->wq.sq.size, sizeof (struct t4_swsqe));
+ if (!qhp->wq.sq.sw_sq)
+ goto err7;
+
+ qhp->wq.rq.sw_rq = calloc(qhp->wq.rq.size, sizeof (uint64_t));
+ if (!qhp->wq.rq.sw_rq)
+ goto err8;
+
+ if (t4_sq_onchip(&qhp->wq)) {
+ qhp->wq.sq.ma_sync = mmap(NULL, c4iw_page_size, PROT_WRITE,
+ MAP_SHARED, pd->context->cmd_fd,
+ resp.ma_sync_key);
+ if (qhp->wq.sq.ma_sync == MAP_FAILED)
+ goto err9;
+ qhp->wq.sq.ma_sync += (A_PCIE_MA_SYNC & (c4iw_page_size - 1));
+ }
+
+ if (ctx->status_page_size) {
+ qhp->wq.db_offp = &ctx->status_page->db_off;
+ } else {
+ qhp->wq.db_offp =
+ &qhp->wq.rq.queue[qhp->wq.rq.size].status.db_off;
+ }
+
+ PDBG("%s sq dbva %p sq qva %p sq depth %u sq memsize %lu "
+ " rq dbva %p rq qva %p rq depth %u rq memsize %lu\n",
+ __func__,
+ qhp->wq.sq.udb, qhp->wq.sq.queue,
+ qhp->wq.sq.size, qhp->wq.sq.memsize,
+ qhp->wq.rq.udb, qhp->wq.rq.queue,
+ qhp->wq.rq.size, qhp->wq.rq.memsize);
+
+ qhp->sq_sig_all = attr->sq_sig_all;
+
+ pthread_spin_lock(&dev->lock);
+ dev->qpid2ptr[qhp->wq.sq.qid] = qhp;
+ pthread_spin_unlock(&dev->lock);
+ INC_STAT(qp);
+ return &qhp->ibv_qp;
+err9:
+ free(qhp->wq.rq.sw_rq);
+err8:
+ free(qhp->wq.sq.sw_sq);
+err7:
+ munmap((void *)qhp->wq.rq.queue, qhp->wq.rq.memsize);
+err6:
+ munmap(MASKED(qhp->wq.rq.udb), c4iw_page_size);
+err5:
+ munmap((void *)qhp->wq.sq.queue, qhp->wq.sq.memsize);
+err4:
+ munmap(MASKED(qhp->wq.sq.udb), c4iw_page_size);
+err3:
+ (void)ibv_cmd_destroy_qp(&qhp->ibv_qp);
+err2:
+ free(qhp);
+err1:
+ return NULL;
+}
+
+struct ibv_qp *c4iw_create_qp(struct ibv_pd *pd,
+ struct ibv_qp_init_attr *attr)
+{
+ struct c4iw_dev *dev = to_c4iw_dev(pd->context->device);
+
+ if (dev->abi_version == 0)
+ return create_qp_v0(pd, attr);
+ return create_qp(pd, attr);
+}
+
+static void reset_qp(struct c4iw_qp *qhp)
+{
+ PDBG("%s enter qp %p\n", __func__, qhp);
+ qhp->wq.sq.cidx = 0;
+ qhp->wq.sq.wq_pidx = qhp->wq.sq.pidx = qhp->wq.sq.in_use = 0;
+ qhp->wq.rq.cidx = qhp->wq.rq.pidx = qhp->wq.rq.in_use = 0;
+ qhp->wq.sq.oldest_read = NULL;
+ memset(qhp->wq.sq.queue, 0, qhp->wq.sq.memsize);
+ if (t4_sq_onchip(&qhp->wq))
+ mmio_flush_writes();
+ memset(qhp->wq.rq.queue, 0, qhp->wq.rq.memsize);
+}
+
+int c4iw_modify_qp(struct ibv_qp *ibqp, struct ibv_qp_attr *attr,
+ int attr_mask)
+{
+ struct ibv_modify_qp cmd = {};
+ struct c4iw_qp *qhp = to_c4iw_qp(ibqp);
+ int ret;
+
+ PDBG("%s enter qp %p new state %d\n", __func__, ibqp, attr_mask & IBV_QP_STATE ? attr->qp_state : -1);
+ pthread_spin_lock(&qhp->lock);
+ if (t4_wq_in_error(&qhp->wq))
+ c4iw_flush_qp(qhp);
+ ret = ibv_cmd_modify_qp(ibqp, attr, attr_mask, &cmd, sizeof cmd);
+ if (!ret && (attr_mask & IBV_QP_STATE) && attr->qp_state == IBV_QPS_RESET)
+ reset_qp(qhp);
+ pthread_spin_unlock(&qhp->lock);
+ return ret;
+}
+
+int c4iw_destroy_qp(struct ibv_qp *ibqp)
+{
+ int ret;
+ struct c4iw_qp *qhp = to_c4iw_qp(ibqp);
+ struct c4iw_dev *dev = to_c4iw_dev(ibqp->context->device);
+
+ PDBG("%s enter qp %p\n", __func__, ibqp);
+ pthread_spin_lock(&qhp->lock);
+ c4iw_flush_qp(qhp);
+ pthread_spin_unlock(&qhp->lock);
+
+ ret = ibv_cmd_destroy_qp(ibqp);
+ if (ret) {
+ return ret;
+ }
+ if (t4_sq_onchip(&qhp->wq)) {
+ qhp->wq.sq.ma_sync -= (A_PCIE_MA_SYNC & (c4iw_page_size - 1));
+ munmap((void *)qhp->wq.sq.ma_sync, c4iw_page_size);
+ }
+ munmap(MASKED(qhp->wq.sq.udb), c4iw_page_size);
+ munmap(MASKED(qhp->wq.rq.udb), c4iw_page_size);
+ munmap(qhp->wq.sq.queue, qhp->wq.sq.memsize);
+ munmap(qhp->wq.rq.queue, qhp->wq.rq.memsize);
+
+ pthread_spin_lock(&dev->lock);
+ dev->qpid2ptr[qhp->wq.sq.qid] = NULL;
+ pthread_spin_unlock(&dev->lock);
+
+ free(qhp->wq.rq.sw_rq);
+ free(qhp->wq.sq.sw_sq);
+ free(qhp);
+ return 0;
+}
+
+int c4iw_query_qp(struct ibv_qp *ibqp, struct ibv_qp_attr *attr,
+ int attr_mask, struct ibv_qp_init_attr *init_attr)
+{
+ struct ibv_query_qp cmd;
+ struct c4iw_qp *qhp = to_c4iw_qp(ibqp);
+ int ret;
+
+ pthread_spin_lock(&qhp->lock);
+ if (t4_wq_in_error(&qhp->wq))
+ c4iw_flush_qp(qhp);
+ ret = ibv_cmd_query_qp(ibqp, attr, attr_mask, init_attr, &cmd, sizeof cmd);
+ pthread_spin_unlock(&qhp->lock);
+ return ret;
+}
+
+struct ibv_ah *c4iw_create_ah(struct ibv_pd *pd, struct ibv_ah_attr *attr)
+{
+ return NULL;
+}
+
+int c4iw_destroy_ah(struct ibv_ah *ah)
+{
+ return ENOSYS;
+}
+
+int c4iw_attach_mcast(struct ibv_qp *ibqp, const union ibv_gid *gid,
+ uint16_t lid)
+{
+ struct c4iw_qp *qhp = to_c4iw_qp(ibqp);
+ int ret;
+
+ pthread_spin_lock(&qhp->lock);
+ if (t4_wq_in_error(&qhp->wq))
+ c4iw_flush_qp(qhp);
+ ret = ibv_cmd_attach_mcast(ibqp, gid, lid);
+ pthread_spin_unlock(&qhp->lock);
+ return ret;
+}
+
+int c4iw_detach_mcast(struct ibv_qp *ibqp, const union ibv_gid *gid,
+ uint16_t lid)
+{
+ struct c4iw_qp *qhp = to_c4iw_qp(ibqp);
+ int ret;
+
+ pthread_spin_lock(&qhp->lock);
+ if (t4_wq_in_error(&qhp->wq))
+ c4iw_flush_qp(qhp);
+ ret = ibv_cmd_detach_mcast(ibqp, gid, lid);
+ pthread_spin_unlock(&qhp->lock);
+ return ret;
+}
+
+void c4iw_async_event(struct ibv_async_event *event)
+{
+ PDBG("%s type %d obj %p\n", __func__, event->event_type,
+ event->element.cq);
+
+ switch (event->event_type) {
+ case IBV_EVENT_CQ_ERR:
+ break;
+ case IBV_EVENT_QP_FATAL:
+ case IBV_EVENT_QP_REQ_ERR:
+ case IBV_EVENT_QP_ACCESS_ERR:
+ case IBV_EVENT_PATH_MIG_ERR: {
+ struct c4iw_qp *qhp = to_c4iw_qp(event->element.qp);
+ pthread_spin_lock(&qhp->lock);
+ c4iw_flush_qp(qhp);
+ pthread_spin_unlock(&qhp->lock);
+ break;
+ }
+ case IBV_EVENT_SQ_DRAINED:
+ case IBV_EVENT_PATH_MIG:
+ case IBV_EVENT_COMM_EST:
+ case IBV_EVENT_QP_LAST_WQE_REACHED:
+ default:
+ break;
+ }
+}
diff --git a/contrib/ofed/libibcm/AUTHORS b/contrib/ofed/libibcm/AUTHORS
deleted file mode 100644
index a694ab7..0000000
--- a/contrib/ofed/libibcm/AUTHORS
+++ /dev/null
@@ -1,2 +0,0 @@
-Sean Hefty <sean.hefty@intel.com>
-Libor Michalek <libor@topspin.com>
diff --git a/contrib/ofed/libibcm/COPYING b/contrib/ofed/libibcm/COPYING
deleted file mode 100644
index ee1a79ff..0000000
--- a/contrib/ofed/libibcm/COPYING
+++ /dev/null
@@ -1,378 +0,0 @@
-This software is available to you under a choice of one of two
-licenses. You may choose to be licensed under the terms of the the
-OpenIB.org BSD license or the GNU General Public License (GPL) Version
-2, both included below.
-
-Copyright (c) 2004 Topspin Communications. All rights reserved.
-
-==================================================================
-
- OpenIB.org BSD license
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions
-are met:
-
- * Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
-
- * Redistributions in binary form must reproduce the above
- copyright notice, this list of conditions and the following
- disclaimer in the documentation and/or other materials provided
- with the distribution.
-
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
-FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
-COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
-INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
-BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
-LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
-CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
-ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-POSSIBILITY OF SUCH DAMAGE.
-
-==================================================================
-
- GNU GENERAL PUBLIC LICENSE
- Version 2, June 1991
-
- Copyright (C) 1989, 1991 Free Software Foundation, Inc.
- 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- Everyone is permitted to copy and distribute verbatim copies
- of this license document, but changing it is not allowed.
-
- Preamble
-
- The licenses for most software are designed to take away your
-freedom to share and change it. By contrast, the GNU General Public
-License is intended to guarantee your freedom to share and change free
-software--to make sure the software is free for all its users. This
-General Public License applies to most of the Free Software
-Foundation's software and to any other program whose authors commit to
-using it. (Some other Free Software Foundation software is covered by
-the GNU Library General Public License instead.) You can apply it to
-your programs, too.
-
- When we speak of free software, we are referring to freedom, not
-price. Our General Public Licenses are designed to make sure that you
-have the freedom to distribute copies of free software (and charge for
-this service if you wish), that you receive source code or can get it
-if you want it, that you can change the software or use pieces of it
-in new free programs; and that you know you can do these things.
-
- To protect your rights, we need to make restrictions that forbid
-anyone to deny you these rights or to ask you to surrender the rights.
-These restrictions translate to certain responsibilities for you if you
-distribute copies of the software, or if you modify it.
-
- For example, if you distribute copies of such a program, whether
-gratis or for a fee, you must give the recipients all the rights that
-you have. You must make sure that they, too, receive or can get the
-source code. And you must show them these terms so they know their
-rights.
-
- We protect your rights with two steps: (1) copyright the software, and
-(2) offer you this license which gives you legal permission to copy,
-distribute and/or modify the software.
-
- Also, for each author's protection and ours, we want to make certain
-that everyone understands that there is no warranty for this free
-software. If the software is modified by someone else and passed on, we
-want its recipients to know that what they have is not the original, so
-that any problems introduced by others will not reflect on the original
-authors' reputations.
-
- Finally, any free program is threatened constantly by software
-patents. We wish to avoid the danger that redistributors of a free
-program will individually obtain patent licenses, in effect making the
-program proprietary. To prevent this, we have made it clear that any
-patent must be licensed for everyone's free use or not licensed at all.
-
- The precise terms and conditions for copying, distribution and
-modification follow.
-
- GNU GENERAL PUBLIC LICENSE
- TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
-
- 0. This License applies to any program or other work which contains
-a notice placed by the copyright holder saying it may be distributed
-under the terms of this General Public License. The "Program", below,
-refers to any such program or work, and a "work based on the Program"
-means either the Program or any derivative work under copyright law:
-that is to say, a work containing the Program or a portion of it,
-either verbatim or with modifications and/or translated into another
-language. (Hereinafter, translation is included without limitation in
-the term "modification".) Each licensee is addressed as "you".
-
-Activities other than copying, distribution and modification are not
-covered by this License; they are outside its scope. The act of
-running the Program is not restricted, and the output from the Program
-is covered only if its contents constitute a work based on the
-Program (independent of having been made by running the Program).
-Whether that is true depends on what the Program does.
-
- 1. You may copy and distribute verbatim copies of the Program's
-source code as you receive it, in any medium, provided that you
-conspicuously and appropriately publish on each copy an appropriate
-copyright notice and disclaimer of warranty; keep intact all the
-notices that refer to this License and to the absence of any warranty;
-and give any other recipients of the Program a copy of this License
-along with the Program.
-
-You may charge a fee for the physical act of transferring a copy, and
-you may at your option offer warranty protection in exchange for a fee.
-
- 2. You may modify your copy or copies of the Program or any portion
-of it, thus forming a work based on the Program, and copy and
-distribute such modifications or work under the terms of Section 1
-above, provided that you also meet all of these conditions:
-
- a) You must cause the modified files to carry prominent notices
- stating that you changed the files and the date of any change.
-
- b) You must cause any work that you distribute or publish, that in
- whole or in part contains or is derived from the Program or any
- part thereof, to be licensed as a whole at no charge to all third
- parties under the terms of this License.
-
- c) If the modified program normally reads commands interactively
- when run, you must cause it, when started running for such
- interactive use in the most ordinary way, to print or display an
- announcement including an appropriate copyright notice and a
- notice that there is no warranty (or else, saying that you provide
- a warranty) and that users may redistribute the program under
- these conditions, and telling the user how to view a copy of this
- License. (Exception: if the Program itself is interactive but
- does not normally print such an announcement, your work based on
- the Program is not required to print an announcement.)
-
-These requirements apply to the modified work as a whole. If
-identifiable sections of that work are not derived from the Program,
-and can be reasonably considered independent and separate works in
-themselves, then this License, and its terms, do not apply to those
-sections when you distribute them as separate works. But when you
-distribute the same sections as part of a whole which is a work based
-on the Program, the distribution of the whole must be on the terms of
-this License, whose permissions for other licensees extend to the
-entire whole, and thus to each and every part regardless of who wrote it.
-
-Thus, it is not the intent of this section to claim rights or contest
-your rights to work written entirely by you; rather, the intent is to
-exercise the right to control the distribution of derivative or
-collective works based on the Program.
-
-In addition, mere aggregation of another work not based on the Program
-with the Program (or with a work based on the Program) on a volume of
-a storage or distribution medium does not bring the other work under
-the scope of this License.
-
- 3. You may copy and distribute the Program (or a work based on it,
-under Section 2) in object code or executable form under the terms of
-Sections 1 and 2 above provided that you also do one of the following:
-
- a) Accompany it with the complete corresponding machine-readable
- source code, which must be distributed under the terms of Sections
- 1 and 2 above on a medium customarily used for software interchange; or,
-
- b) Accompany it with a written offer, valid for at least three
- years, to give any third party, for a charge no more than your
- cost of physically performing source distribution, a complete
- machine-readable copy of the corresponding source code, to be
- distributed under the terms of Sections 1 and 2 above on a medium
- customarily used for software interchange; or,
-
- c) Accompany it with the information you received as to the offer
- to distribute corresponding source code. (This alternative is
- allowed only for noncommercial distribution and only if you
- received the program in object code or executable form with such
- an offer, in accord with Subsection b above.)
-
-The source code for a work means the preferred form of the work for
-making modifications to it. For an executable work, complete source
-code means all the source code for all modules it contains, plus any
-associated interface definition files, plus the scripts used to
-control compilation and installation of the executable. However, as a
-special exception, the source code distributed need not include
-anything that is normally distributed (in either source or binary
-form) with the major components (compiler, kernel, and so on) of the
-operating system on which the executable runs, unless that component
-itself accompanies the executable.
-
-If distribution of executable or object code is made by offering
-access to copy from a designated place, then offering equivalent
-access to copy the source code from the same place counts as
-distribution of the source code, even though third parties are not
-compelled to copy the source along with the object code.
-
- 4. You may not copy, modify, sublicense, or distribute the Program
-except as expressly provided under this License. Any attempt
-otherwise to copy, modify, sublicense or distribute the Program is
-void, and will automatically terminate your rights under this License.
-However, parties who have received copies, or rights, from you under
-this License will not have their licenses terminated so long as such
-parties remain in full compliance.
-
- 5. You are not required to accept this License, since you have not
-signed it. However, nothing else grants you permission to modify or
-distribute the Program or its derivative works. These actions are
-prohibited by law if you do not accept this License. Therefore, by
-modifying or distributing the Program (or any work based on the
-Program), you indicate your acceptance of this License to do so, and
-all its terms and conditions for copying, distributing or modifying
-the Program or works based on it.
-
- 6. Each time you redistribute the Program (or any work based on the
-Program), the recipient automatically receives a license from the
-original licensor to copy, distribute or modify the Program subject to
-these terms and conditions. You may not impose any further
-restrictions on the recipients' exercise of the rights granted herein.
-You are not responsible for enforcing compliance by third parties to
-this License.
-
- 7. If, as a consequence of a court judgment or allegation of patent
-infringement or for any other reason (not limited to patent issues),
-conditions are imposed on you (whether by court order, agreement or
-otherwise) that contradict the conditions of this License, they do not
-excuse you from the conditions of this License. If you cannot
-distribute so as to satisfy simultaneously your obligations under this
-License and any other pertinent obligations, then as a consequence you
-may not distribute the Program at all. For example, if a patent
-license would not permit royalty-free redistribution of the Program by
-all those who receive copies directly or indirectly through you, then
-the only way you could satisfy both it and this License would be to
-refrain entirely from distribution of the Program.
-
-If any portion of this section is held invalid or unenforceable under
-any particular circumstance, the balance of the section is intended to
-apply and the section as a whole is intended to apply in other
-circumstances.
-
-It is not the purpose of this section to induce you to infringe any
-patents or other property right claims or to contest validity of any
-such claims; this section has the sole purpose of protecting the
-integrity of the free software distribution system, which is
-implemented by public license practices. Many people have made
-generous contributions to the wide range of software distributed
-through that system in reliance on consistent application of that
-system; it is up to the author/donor to decide if he or she is willing
-to distribute software through any other system and a licensee cannot
-impose that choice.
-
-This section is intended to make thoroughly clear what is believed to
-be a consequence of the rest of this License.
-
- 8. If the distribution and/or use of the Program is restricted in
-certain countries either by patents or by copyrighted interfaces, the
-original copyright holder who places the Program under this License
-may add an explicit geographical distribution limitation excluding
-those countries, so that distribution is permitted only in or among
-countries not thus excluded. In such case, this License incorporates
-the limitation as if written in the body of this License.
-
- 9. The Free Software Foundation may publish revised and/or new versions
-of the General Public License from time to time. Such new versions will
-be similar in spirit to the present version, but may differ in detail to
-address new problems or concerns.
-
-Each version is given a distinguishing version number. If the Program
-specifies a version number of this License which applies to it and "any
-later version", you have the option of following the terms and conditions
-either of that version or of any later version published by the Free
-Software Foundation. If the Program does not specify a version number of
-this License, you may choose any version ever published by the Free Software
-Foundation.
-
- 10. If you wish to incorporate parts of the Program into other free
-programs whose distribution conditions are different, write to the author
-to ask for permission. For software which is copyrighted by the Free
-Software Foundation, write to the Free Software Foundation; we sometimes
-make exceptions for this. Our decision will be guided by the two goals
-of preserving the free status of all derivatives of our free software and
-of promoting the sharing and reuse of software generally.
-
- NO WARRANTY
-
- 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
-FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
-OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
-PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
-OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
-MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
-TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
-PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
-REPAIR OR CORRECTION.
-
- 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
-WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
-REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
-INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
-OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
-TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
-YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
-PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
-POSSIBILITY OF SUCH DAMAGES.
-
- END OF TERMS AND CONDITIONS
-
- How to Apply These Terms to Your New Programs
-
- If you develop a new program, and you want it to be of the greatest
-possible use to the public, the best way to achieve this is to make it
-free software which everyone can redistribute and change under these terms.
-
- To do so, attach the following notices to the program. It is safest
-to attach them to the start of each source file to most effectively
-convey the exclusion of warranty; and each file should have at least
-the "copyright" line and a pointer to where the full notice is found.
-
- <one line to give the program's name and a brief idea of what it does.>
- Copyright (C) <year> <name of author>
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program 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 this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-
-Also add information on how to contact you by electronic and paper mail.
-
-If the program is interactive, make it output a short notice like this
-when it starts in an interactive mode:
-
- Gnomovision version 69, Copyright (C) year name of author
- Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
- This is free software, and you are welcome to redistribute it
- under certain conditions; type `show c' for details.
-
-The hypothetical commands `show w' and `show c' should show the appropriate
-parts of the General Public License. Of course, the commands you use may
-be called something other than `show w' and `show c'; they could even be
-mouse-clicks or menu items--whatever suits your program.
-
-You should also get your employer (if you work as a programmer) or your
-school, if any, to sign a "copyright disclaimer" for the program, if
-necessary. Here is a sample; alter the names:
-
- Yoyodyne, Inc., hereby disclaims all copyright interest in the program
- `Gnomovision' (which makes passes at compilers) written by James Hacker.
-
- <signature of Ty Coon>, 1 April 1989
- Ty Coon, President of Vice
-
-This General Public License does not permit incorporating your program into
-proprietary programs. If your program is a subroutine library, you may
-consider it more useful to permit linking proprietary applications with the
-library. If this is what you want to do, use the GNU Library General
-Public License instead of this License.
diff --git a/contrib/ofed/libibcm/ChangeLog b/contrib/ofed/libibcm/ChangeLog
deleted file mode 100644
index e69de29..0000000
--- a/contrib/ofed/libibcm/ChangeLog
+++ /dev/null
diff --git a/contrib/ofed/libibcm/INSTALL b/contrib/ofed/libibcm/INSTALL
deleted file mode 100644
index e69de29..0000000
--- a/contrib/ofed/libibcm/INSTALL
+++ /dev/null
diff --git a/contrib/ofed/libibcm/Makefile b/contrib/ofed/libibcm/Makefile
new file mode 100644
index 0000000..c40e820
--- /dev/null
+++ b/contrib/ofed/libibcm/Makefile
@@ -0,0 +1,15 @@
+# $FreeBSD$
+
+.PATH: ${.CURDIR}
+
+SHLIBDIR?= /usr/lib
+LIB= ibcm
+SHLIB_MAJOR= 1
+MK_PROFILE= no
+SRCS= cm.c
+LIBADD= ibverbs
+CFLAGS+= -I${.CURDIR}
+MAN=
+VERSION_MAP= ${.CURDIR}/libibcm.map
+
+.include <bsd.lib.mk>
diff --git a/contrib/ofed/libibcm/Makefile.am b/contrib/ofed/libibcm/Makefile.am
deleted file mode 100644
index 4b2ad74..0000000
--- a/contrib/ofed/libibcm/Makefile.am
+++ /dev/null
@@ -1,34 +0,0 @@
-INCLUDES = -I$(srcdir)/include
-
-lib_LTLIBRARIES = src/libibcm.la
-
-AM_CFLAGS = -g -Wall -D_GNU_SOURCE
-
-src_libibcm_la_CFLAGS = $(AM_CFLAGS)
-
-if HAVE_LD_VERSION_SCRIPT
- ibcm_version_script = -Wl,--version-script=$(srcdir)/src/libibcm.map
-else
- ibcm_version_script =
-endif
-
-src_libibcm_la_SOURCES = src/cm.c
-src_libibcm_la_LDFLAGS = -version-info 1 -export-dynamic \
- $(libibcm_version_script)
-src_libibcm_la_DEPENDENCIES = $(srcdir)/src/libibcm.map
-
-# Sample program requires use if librdmacm.
-#bin_PROGRAMS = examples/ucmpost
-#examples_ucmpost_SOURCES = examples/cmpost.c
-#examples_ucmpost_LDADD = $(top_builddir)/src/libibcm.la
-
-libibcmincludedir = $(includedir)/infiniband
-
-libibcminclude_HEADERS = include/infiniband/cm_abi.h \
- include/infiniband/cm.h
-
-EXTRA_DIST = include/infiniband/cm_abi.h include/infiniband/cm.h \
- src/libibcm.map libibcm.spec.in
-
-dist-hook: libibcm.spec
- cp libibcm.spec $(distdir)
diff --git a/contrib/ofed/libibcm/Makefile.in b/contrib/ofed/libibcm/Makefile.in
deleted file mode 100644
index 23e15d1..0000000
--- a/contrib/ofed/libibcm/Makefile.in
+++ /dev/null
@@ -1,660 +0,0 @@
-# Makefile.in generated by automake 1.9.6 from Makefile.am.
-# @configure_input@
-
-# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
-# 2003, 2004, 2005 Free Software Foundation, Inc.
-# This Makefile.in is free software; the Free Software Foundation
-# gives unlimited permission to copy and/or distribute it,
-# with or without modifications, as long as this notice is preserved.
-
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
-# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
-# PARTICULAR PURPOSE.
-
-@SET_MAKE@
-
-
-srcdir = @srcdir@
-top_srcdir = @top_srcdir@
-VPATH = @srcdir@
-pkgdatadir = $(datadir)/@PACKAGE@
-pkglibdir = $(libdir)/@PACKAGE@
-pkgincludedir = $(includedir)/@PACKAGE@
-top_builddir = .
-am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
-INSTALL = @INSTALL@
-install_sh_DATA = $(install_sh) -c -m 644
-install_sh_PROGRAM = $(install_sh) -c
-install_sh_SCRIPT = $(install_sh) -c
-INSTALL_HEADER = $(INSTALL_DATA)
-transform = $(program_transform_name)
-NORMAL_INSTALL = :
-PRE_INSTALL = :
-POST_INSTALL = :
-NORMAL_UNINSTALL = :
-PRE_UNINSTALL = :
-POST_UNINSTALL = :
-build_triplet = @build@
-host_triplet = @host@
-DIST_COMMON = README $(am__configure_deps) $(libibcminclude_HEADERS) \
- $(srcdir)/Makefile.am $(srcdir)/Makefile.in \
- $(srcdir)/config.h.in $(srcdir)/libibcm.spec.in \
- $(top_srcdir)/configure AUTHORS COPYING ChangeLog INSTALL NEWS \
- config/compile config/config.guess config/config.sub \
- config/depcomp config/install-sh config/ltmain.sh \
- config/missing
-subdir = .
-ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
-am__aclocal_m4_deps = $(top_srcdir)/configure.in
-am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
- $(ACLOCAL_M4)
-am__CONFIG_DISTCLEAN_FILES = config.status config.cache config.log \
- configure.lineno configure.status.lineno
-mkinstalldirs = $(install_sh) -d
-CONFIG_HEADER = config.h
-CONFIG_CLEAN_FILES = libibcm.spec
-am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
-am__vpath_adj = case $$p in \
- $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \
- *) f=$$p;; \
- esac;
-am__strip_dir = `echo $$p | sed -e 's|^.*/||'`;
-am__installdirs = "$(DESTDIR)$(libdir)" \
- "$(DESTDIR)$(libibcmincludedir)"
-libLTLIBRARIES_INSTALL = $(INSTALL)
-LTLIBRARIES = $(lib_LTLIBRARIES)
-src_libibcm_la_LIBADD =
-am_src_libibcm_la_OBJECTS = src_libibcm_la-cm.lo
-src_libibcm_la_OBJECTS = $(am_src_libibcm_la_OBJECTS)
-am__dirstamp = $(am__leading_dot)dirstamp
-DEFAULT_INCLUDES = -I. -I$(srcdir) -I.
-depcomp = $(SHELL) $(top_srcdir)/config/depcomp
-am__depfiles_maybe = depfiles
-COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
- $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
-LTCOMPILE = $(LIBTOOL) --tag=CC --mode=compile $(CC) $(DEFS) \
- $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
- $(AM_CFLAGS) $(CFLAGS)
-CCLD = $(CC)
-LINK = $(LIBTOOL) --tag=CC --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
- $(AM_LDFLAGS) $(LDFLAGS) -o $@
-SOURCES = $(src_libibcm_la_SOURCES)
-DIST_SOURCES = $(src_libibcm_la_SOURCES)
-libibcmincludeHEADERS_INSTALL = $(INSTALL_HEADER)
-HEADERS = $(libibcminclude_HEADERS)
-ETAGS = etags
-CTAGS = ctags
-DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
-distdir = $(PACKAGE)-$(VERSION)
-top_distdir = $(distdir)
-am__remove_distdir = \
- { test ! -d $(distdir) \
- || { find $(distdir) -type d ! -perm -200 -exec chmod u+w {} ';' \
- && rm -fr $(distdir); }; }
-DIST_ARCHIVES = $(distdir).tar.gz
-GZIP_ENV = --best
-distuninstallcheck_listfiles = find . -type f -print
-distcleancheck_listfiles = find . -type f -print
-ACLOCAL = @ACLOCAL@
-AMDEP_FALSE = @AMDEP_FALSE@
-AMDEP_TRUE = @AMDEP_TRUE@
-AMTAR = @AMTAR@
-AR = @AR@
-AUTOCONF = @AUTOCONF@
-AUTOHEADER = @AUTOHEADER@
-AUTOMAKE = @AUTOMAKE@
-AWK = @AWK@
-CC = @CC@
-CCDEPMODE = @CCDEPMODE@
-CFLAGS = @CFLAGS@
-CPP = @CPP@
-CPPFLAGS = @CPPFLAGS@
-CXX = @CXX@
-CXXCPP = @CXXCPP@
-CXXDEPMODE = @CXXDEPMODE@
-CXXFLAGS = @CXXFLAGS@
-CYGPATH_W = @CYGPATH_W@
-DEFS = @DEFS@
-DEPDIR = @DEPDIR@
-ECHO = @ECHO@
-ECHO_C = @ECHO_C@
-ECHO_N = @ECHO_N@
-ECHO_T = @ECHO_T@
-EGREP = @EGREP@
-EXEEXT = @EXEEXT@
-F77 = @F77@
-FFLAGS = @FFLAGS@
-HAVE_LD_VERSION_SCRIPT_FALSE = @HAVE_LD_VERSION_SCRIPT_FALSE@
-HAVE_LD_VERSION_SCRIPT_TRUE = @HAVE_LD_VERSION_SCRIPT_TRUE@
-INSTALL_DATA = @INSTALL_DATA@
-INSTALL_PROGRAM = @INSTALL_PROGRAM@
-INSTALL_SCRIPT = @INSTALL_SCRIPT@
-INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
-LDFLAGS = @LDFLAGS@
-LIBOBJS = @LIBOBJS@
-LIBS = @LIBS@
-LIBTOOL = @LIBTOOL@
-LN_S = @LN_S@
-LTLIBOBJS = @LTLIBOBJS@
-MAKEINFO = @MAKEINFO@
-OBJEXT = @OBJEXT@
-PACKAGE = @PACKAGE@
-PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
-PACKAGE_NAME = @PACKAGE_NAME@
-PACKAGE_STRING = @PACKAGE_STRING@
-PACKAGE_TARNAME = @PACKAGE_TARNAME@
-PACKAGE_VERSION = @PACKAGE_VERSION@
-PATH_SEPARATOR = @PATH_SEPARATOR@
-RANLIB = @RANLIB@
-SET_MAKE = @SET_MAKE@
-SHELL = @SHELL@
-STRIP = @STRIP@
-VERSION = @VERSION@
-ac_ct_AR = @ac_ct_AR@
-ac_ct_CC = @ac_ct_CC@
-ac_ct_CXX = @ac_ct_CXX@
-ac_ct_F77 = @ac_ct_F77@
-ac_ct_RANLIB = @ac_ct_RANLIB@
-ac_ct_STRIP = @ac_ct_STRIP@
-am__fastdepCC_FALSE = @am__fastdepCC_FALSE@
-am__fastdepCC_TRUE = @am__fastdepCC_TRUE@
-am__fastdepCXX_FALSE = @am__fastdepCXX_FALSE@
-am__fastdepCXX_TRUE = @am__fastdepCXX_TRUE@
-am__include = @am__include@
-am__leading_dot = @am__leading_dot@
-am__quote = @am__quote@
-am__tar = @am__tar@
-am__untar = @am__untar@
-bindir = @bindir@
-build = @build@
-build_alias = @build_alias@
-build_cpu = @build_cpu@
-build_os = @build_os@
-build_vendor = @build_vendor@
-datadir = @datadir@
-exec_prefix = @exec_prefix@
-host = @host@
-host_alias = @host_alias@
-host_cpu = @host_cpu@
-host_os = @host_os@
-host_vendor = @host_vendor@
-includedir = @includedir@
-infodir = @infodir@
-install_sh = @install_sh@
-libdir = @libdir@
-libexecdir = @libexecdir@
-localstatedir = @localstatedir@
-mandir = @mandir@
-mkdir_p = @mkdir_p@
-oldincludedir = @oldincludedir@
-prefix = @prefix@
-program_transform_name = @program_transform_name@
-sbindir = @sbindir@
-sharedstatedir = @sharedstatedir@
-sysconfdir = @sysconfdir@
-target_alias = @target_alias@
-INCLUDES = -I$(srcdir)/include
-lib_LTLIBRARIES = src/libibcm.la
-AM_CFLAGS = -g -Wall -D_GNU_SOURCE
-src_libibcm_la_CFLAGS = $(AM_CFLAGS)
-@HAVE_LD_VERSION_SCRIPT_FALSE@ibcm_version_script =
-@HAVE_LD_VERSION_SCRIPT_TRUE@ibcm_version_script = -Wl,--version-script=$(srcdir)/src/libibcm.map
-src_libibcm_la_SOURCES = src/cm.c
-src_libibcm_la_LDFLAGS = -version-info 1 -export-dynamic \
- $(libibcm_version_script)
-
-src_libibcm_la_DEPENDENCIES = $(srcdir)/src/libibcm.map
-
-# Sample program requires use if librdmacm.
-#bin_PROGRAMS = examples/ucmpost
-#examples_ucmpost_SOURCES = examples/cmpost.c
-#examples_ucmpost_LDADD = $(top_builddir)/src/libibcm.la
-libibcmincludedir = $(includedir)/infiniband
-libibcminclude_HEADERS = include/infiniband/cm_abi.h \
- include/infiniband/cm.h
-
-EXTRA_DIST = include/infiniband/cm_abi.h include/infiniband/cm.h \
- src/libibcm.map libibcm.spec.in
-
-all: config.h
- $(MAKE) $(AM_MAKEFLAGS) all-am
-
-.SUFFIXES:
-.SUFFIXES: .c .lo .o .obj
-am--refresh:
- @:
-$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps)
- @for dep in $?; do \
- case '$(am__configure_deps)' in \
- *$$dep*) \
- echo ' cd $(srcdir) && $(AUTOMAKE) --foreign '; \
- cd $(srcdir) && $(AUTOMAKE) --foreign \
- && exit 0; \
- exit 1;; \
- esac; \
- done; \
- echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign Makefile'; \
- cd $(top_srcdir) && \
- $(AUTOMAKE) --foreign Makefile
-.PRECIOUS: Makefile
-Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
- @case '$?' in \
- *config.status*) \
- echo ' $(SHELL) ./config.status'; \
- $(SHELL) ./config.status;; \
- *) \
- echo ' cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe)'; \
- cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe);; \
- esac;
-
-$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
- $(SHELL) ./config.status --recheck
-
-$(top_srcdir)/configure: $(am__configure_deps)
- cd $(srcdir) && $(AUTOCONF)
-$(ACLOCAL_M4): $(am__aclocal_m4_deps)
- cd $(srcdir) && $(ACLOCAL) $(ACLOCAL_AMFLAGS)
-
-config.h: stamp-h1
- @if test ! -f $@; then \
- rm -f stamp-h1; \
- $(MAKE) stamp-h1; \
- else :; fi
-
-stamp-h1: $(srcdir)/config.h.in $(top_builddir)/config.status
- @rm -f stamp-h1
- cd $(top_builddir) && $(SHELL) ./config.status config.h
-$(srcdir)/config.h.in: $(am__configure_deps)
- cd $(top_srcdir) && $(AUTOHEADER)
- rm -f stamp-h1
- touch $@
-
-distclean-hdr:
- -rm -f config.h stamp-h1
-libibcm.spec: $(top_builddir)/config.status $(srcdir)/libibcm.spec.in
- cd $(top_builddir) && $(SHELL) ./config.status $@
-install-libLTLIBRARIES: $(lib_LTLIBRARIES)
- @$(NORMAL_INSTALL)
- test -z "$(libdir)" || $(mkdir_p) "$(DESTDIR)$(libdir)"
- @list='$(lib_LTLIBRARIES)'; for p in $$list; do \
- if test -f $$p; then \
- f=$(am__strip_dir) \
- echo " $(LIBTOOL) --mode=install $(libLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) '$$p' '$(DESTDIR)$(libdir)/$$f'"; \
- $(LIBTOOL) --mode=install $(libLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) "$$p" "$(DESTDIR)$(libdir)/$$f"; \
- else :; fi; \
- done
-
-uninstall-libLTLIBRARIES:
- @$(NORMAL_UNINSTALL)
- @set -x; list='$(lib_LTLIBRARIES)'; for p in $$list; do \
- p=$(am__strip_dir) \
- echo " $(LIBTOOL) --mode=uninstall rm -f '$(DESTDIR)$(libdir)/$$p'"; \
- $(LIBTOOL) --mode=uninstall rm -f "$(DESTDIR)$(libdir)/$$p"; \
- done
-
-clean-libLTLIBRARIES:
- -test -z "$(lib_LTLIBRARIES)" || rm -f $(lib_LTLIBRARIES)
- @list='$(lib_LTLIBRARIES)'; for p in $$list; do \
- dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \
- test "$$dir" != "$$p" || dir=.; \
- echo "rm -f \"$${dir}/so_locations\""; \
- rm -f "$${dir}/so_locations"; \
- done
-src/$(am__dirstamp):
- @$(mkdir_p) src
- @: > src/$(am__dirstamp)
-src/libibcm.la: $(src_libibcm_la_OBJECTS) $(src_libibcm_la_DEPENDENCIES) src/$(am__dirstamp)
- $(LINK) -rpath $(libdir) $(src_libibcm_la_LDFLAGS) $(src_libibcm_la_OBJECTS) $(src_libibcm_la_LIBADD) $(LIBS)
-
-mostlyclean-compile:
- -rm -f *.$(OBJEXT)
-
-distclean-compile:
- -rm -f *.tab.c
-
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/src_libibcm_la-cm.Plo@am__quote@
-
-.c.o:
-@am__fastdepCC_TRUE@ if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ $<; \
-@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi
-@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
-@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@ $(COMPILE) -c $<
-
-.c.obj:
-@am__fastdepCC_TRUE@ if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ `$(CYGPATH_W) '$<'`; \
-@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi
-@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
-@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'`
-
-.c.lo:
-@am__fastdepCC_TRUE@ if $(LTCOMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ $<; \
-@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Plo"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi
-@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
-@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $<
-
-src_libibcm_la-cm.lo: src/cm.c
-@am__fastdepCC_TRUE@ if $(LIBTOOL) --tag=CC --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(src_libibcm_la_CFLAGS) $(CFLAGS) -MT src_libibcm_la-cm.lo -MD -MP -MF "$(DEPDIR)/src_libibcm_la-cm.Tpo" -c -o src_libibcm_la-cm.lo `test -f 'src/cm.c' || echo '$(srcdir)/'`src/cm.c; \
-@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/src_libibcm_la-cm.Tpo" "$(DEPDIR)/src_libibcm_la-cm.Plo"; else rm -f "$(DEPDIR)/src_libibcm_la-cm.Tpo"; exit 1; fi
-@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='src/cm.c' object='src_libibcm_la-cm.lo' libtool=yes @AMDEPBACKSLASH@
-@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(src_libibcm_la_CFLAGS) $(CFLAGS) -c -o src_libibcm_la-cm.lo `test -f 'src/cm.c' || echo '$(srcdir)/'`src/cm.c
-
-mostlyclean-libtool:
- -rm -f *.lo
-
-clean-libtool:
- -rm -rf .libs _libs
- -rm -rf src/.libs src/_libs
-
-distclean-libtool:
- -rm -f libtool
-uninstall-info-am:
-install-libibcmincludeHEADERS: $(libibcminclude_HEADERS)
- @$(NORMAL_INSTALL)
- test -z "$(libibcmincludedir)" || $(mkdir_p) "$(DESTDIR)$(libibcmincludedir)"
- @list='$(libibcminclude_HEADERS)'; for p in $$list; do \
- if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
- f=$(am__strip_dir) \
- echo " $(libibcmincludeHEADERS_INSTALL) '$$d$$p' '$(DESTDIR)$(libibcmincludedir)/$$f'"; \
- $(libibcmincludeHEADERS_INSTALL) "$$d$$p" "$(DESTDIR)$(libibcmincludedir)/$$f"; \
- done
-
-uninstall-libibcmincludeHEADERS:
- @$(NORMAL_UNINSTALL)
- @list='$(libibcminclude_HEADERS)'; for p in $$list; do \
- f=$(am__strip_dir) \
- echo " rm -f '$(DESTDIR)$(libibcmincludedir)/$$f'"; \
- rm -f "$(DESTDIR)$(libibcmincludedir)/$$f"; \
- done
-
-ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
- list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
- unique=`for i in $$list; do \
- if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
- done | \
- $(AWK) ' { files[$$0] = 1; } \
- END { for (i in files) print i; }'`; \
- mkid -fID $$unique
-tags: TAGS
-
-TAGS: $(HEADERS) $(SOURCES) config.h.in $(TAGS_DEPENDENCIES) \
- $(TAGS_FILES) $(LISP)
- tags=; \
- here=`pwd`; \
- list='$(SOURCES) $(HEADERS) config.h.in $(LISP) $(TAGS_FILES)'; \
- unique=`for i in $$list; do \
- if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
- done | \
- $(AWK) ' { files[$$0] = 1; } \
- END { for (i in files) print i; }'`; \
- if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
- test -n "$$unique" || unique=$$empty_fix; \
- $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
- $$tags $$unique; \
- fi
-ctags: CTAGS
-CTAGS: $(HEADERS) $(SOURCES) config.h.in $(TAGS_DEPENDENCIES) \
- $(TAGS_FILES) $(LISP)
- tags=; \
- here=`pwd`; \
- list='$(SOURCES) $(HEADERS) config.h.in $(LISP) $(TAGS_FILES)'; \
- unique=`for i in $$list; do \
- if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
- done | \
- $(AWK) ' { files[$$0] = 1; } \
- END { for (i in files) print i; }'`; \
- test -z "$(CTAGS_ARGS)$$tags$$unique" \
- || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
- $$tags $$unique
-
-GTAGS:
- here=`$(am__cd) $(top_builddir) && pwd` \
- && cd $(top_srcdir) \
- && gtags -i $(GTAGS_ARGS) $$here
-
-distclean-tags:
- -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
-
-distdir: $(DISTFILES)
- $(am__remove_distdir)
- mkdir $(distdir)
- $(mkdir_p) $(distdir)/. $(distdir)/config $(distdir)/include/infiniband $(distdir)/src
- @srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \
- topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \
- list='$(DISTFILES)'; for file in $$list; do \
- case $$file in \
- $(srcdir)/*) file=`echo "$$file" | sed "s|^$$srcdirstrip/||"`;; \
- $(top_srcdir)/*) file=`echo "$$file" | sed "s|^$$topsrcdirstrip/|$(top_builddir)/|"`;; \
- esac; \
- if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
- dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \
- if test "$$dir" != "$$file" && test "$$dir" != "."; then \
- dir="/$$dir"; \
- $(mkdir_p) "$(distdir)$$dir"; \
- else \
- dir=''; \
- fi; \
- if test -d $$d/$$file; then \
- if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
- cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
- fi; \
- cp -pR $$d/$$file $(distdir)$$dir || exit 1; \
- else \
- test -f $(distdir)/$$file \
- || cp -p $$d/$$file $(distdir)/$$file \
- || exit 1; \
- fi; \
- done
- $(MAKE) $(AM_MAKEFLAGS) \
- top_distdir="$(top_distdir)" distdir="$(distdir)" \
- dist-hook
- -find $(distdir) -type d ! -perm -777 -exec chmod a+rwx {} \; -o \
- ! -type d ! -perm -444 -links 1 -exec chmod a+r {} \; -o \
- ! -type d ! -perm -400 -exec chmod a+r {} \; -o \
- ! -type d ! -perm -444 -exec $(SHELL) $(install_sh) -c -m a+r {} {} \; \
- || chmod -R a+r $(distdir)
-dist-gzip: distdir
- tardir=$(distdir) && $(am__tar) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz
- $(am__remove_distdir)
-
-dist-bzip2: distdir
- tardir=$(distdir) && $(am__tar) | bzip2 -9 -c >$(distdir).tar.bz2
- $(am__remove_distdir)
-
-dist-tarZ: distdir
- tardir=$(distdir) && $(am__tar) | compress -c >$(distdir).tar.Z
- $(am__remove_distdir)
-
-dist-shar: distdir
- shar $(distdir) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).shar.gz
- $(am__remove_distdir)
-
-dist-zip: distdir
- -rm -f $(distdir).zip
- zip -rq $(distdir).zip $(distdir)
- $(am__remove_distdir)
-
-dist dist-all: distdir
- tardir=$(distdir) && $(am__tar) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz
- $(am__remove_distdir)
-
-# This target untars the dist file and tries a VPATH configuration. Then
-# it guarantees that the distribution is self-contained by making another
-# tarfile.
-distcheck: dist
- case '$(DIST_ARCHIVES)' in \
- *.tar.gz*) \
- GZIP=$(GZIP_ENV) gunzip -c $(distdir).tar.gz | $(am__untar) ;;\
- *.tar.bz2*) \
- bunzip2 -c $(distdir).tar.bz2 | $(am__untar) ;;\
- *.tar.Z*) \
- uncompress -c $(distdir).tar.Z | $(am__untar) ;;\
- *.shar.gz*) \
- GZIP=$(GZIP_ENV) gunzip -c $(distdir).shar.gz | unshar ;;\
- *.zip*) \
- unzip $(distdir).zip ;;\
- esac
- chmod -R a-w $(distdir); chmod a+w $(distdir)
- mkdir $(distdir)/_build
- mkdir $(distdir)/_inst
- chmod a-w $(distdir)
- dc_install_base=`$(am__cd) $(distdir)/_inst && pwd | sed -e 's,^[^:\\/]:[\\/],/,'` \
- && dc_destdir="$${TMPDIR-/tmp}/am-dc-$$$$/" \
- && cd $(distdir)/_build \
- && ../configure --srcdir=.. --prefix="$$dc_install_base" \
- $(DISTCHECK_CONFIGURE_FLAGS) \
- && $(MAKE) $(AM_MAKEFLAGS) \
- && $(MAKE) $(AM_MAKEFLAGS) dvi \
- && $(MAKE) $(AM_MAKEFLAGS) check \
- && $(MAKE) $(AM_MAKEFLAGS) install \
- && $(MAKE) $(AM_MAKEFLAGS) installcheck \
- && $(MAKE) $(AM_MAKEFLAGS) uninstall \
- && $(MAKE) $(AM_MAKEFLAGS) distuninstallcheck_dir="$$dc_install_base" \
- distuninstallcheck \
- && chmod -R a-w "$$dc_install_base" \
- && ({ \
- (cd ../.. && umask 077 && mkdir "$$dc_destdir") \
- && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" install \
- && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" uninstall \
- && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" \
- distuninstallcheck_dir="$$dc_destdir" distuninstallcheck; \
- } || { rm -rf "$$dc_destdir"; exit 1; }) \
- && rm -rf "$$dc_destdir" \
- && $(MAKE) $(AM_MAKEFLAGS) dist \
- && rm -rf $(DIST_ARCHIVES) \
- && $(MAKE) $(AM_MAKEFLAGS) distcleancheck
- $(am__remove_distdir)
- @(echo "$(distdir) archives ready for distribution: "; \
- list='$(DIST_ARCHIVES)'; for i in $$list; do echo $$i; done) | \
- sed -e '1{h;s/./=/g;p;x;}' -e '$${p;x;}'
-distuninstallcheck:
- @cd $(distuninstallcheck_dir) \
- && test `$(distuninstallcheck_listfiles) | wc -l` -le 1 \
- || { echo "ERROR: files left after uninstall:" ; \
- if test -n "$(DESTDIR)"; then \
- echo " (check DESTDIR support)"; \
- fi ; \
- $(distuninstallcheck_listfiles) ; \
- exit 1; } >&2
-distcleancheck: distclean
- @if test '$(srcdir)' = . ; then \
- echo "ERROR: distcleancheck can only run from a VPATH build" ; \
- exit 1 ; \
- fi
- @test `$(distcleancheck_listfiles) | wc -l` -eq 0 \
- || { echo "ERROR: files left in build directory after distclean:" ; \
- $(distcleancheck_listfiles) ; \
- exit 1; } >&2
-check-am: all-am
-check: check-am
-all-am: Makefile $(LTLIBRARIES) $(HEADERS) config.h
-installdirs:
- for dir in "$(DESTDIR)$(libdir)" "$(DESTDIR)$(libibcmincludedir)"; do \
- test -z "$$dir" || $(mkdir_p) "$$dir"; \
- done
-install: install-am
-install-exec: install-exec-am
-install-data: install-data-am
-uninstall: uninstall-am
-
-install-am: all-am
- @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
-
-installcheck: installcheck-am
-install-strip:
- $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
- install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
- `test -z '$(STRIP)' || \
- echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
-mostlyclean-generic:
-
-clean-generic:
-
-distclean-generic:
- -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
- -rm -f src/$(am__dirstamp)
-
-maintainer-clean-generic:
- @echo "This command is intended for maintainers to use"
- @echo "it deletes files that may require special tools to rebuild."
-clean: clean-am
-
-clean-am: clean-generic clean-libLTLIBRARIES clean-libtool \
- mostlyclean-am
-
-distclean: distclean-am
- -rm -f $(am__CONFIG_DISTCLEAN_FILES)
- -rm -rf ./$(DEPDIR)
- -rm -f Makefile
-distclean-am: clean-am distclean-compile distclean-generic \
- distclean-hdr distclean-libtool distclean-tags
-
-dvi: dvi-am
-
-dvi-am:
-
-html: html-am
-
-info: info-am
-
-info-am:
-
-install-data-am: install-libibcmincludeHEADERS
-
-install-exec-am: install-libLTLIBRARIES
-
-install-info: install-info-am
-
-install-man:
-
-installcheck-am:
-
-maintainer-clean: maintainer-clean-am
- -rm -f $(am__CONFIG_DISTCLEAN_FILES)
- -rm -rf $(top_srcdir)/autom4te.cache
- -rm -rf ./$(DEPDIR)
- -rm -f Makefile
-maintainer-clean-am: distclean-am maintainer-clean-generic
-
-mostlyclean: mostlyclean-am
-
-mostlyclean-am: mostlyclean-compile mostlyclean-generic \
- mostlyclean-libtool
-
-pdf: pdf-am
-
-pdf-am:
-
-ps: ps-am
-
-ps-am:
-
-uninstall-am: uninstall-info-am uninstall-libLTLIBRARIES \
- uninstall-libibcmincludeHEADERS
-
-.PHONY: CTAGS GTAGS all all-am am--refresh check check-am clean \
- clean-generic clean-libLTLIBRARIES clean-libtool ctags dist \
- dist-all dist-bzip2 dist-gzip dist-hook dist-shar dist-tarZ \
- dist-zip distcheck distclean distclean-compile \
- distclean-generic distclean-hdr distclean-libtool \
- distclean-tags distcleancheck distdir distuninstallcheck dvi \
- dvi-am html html-am info info-am install install-am \
- install-data install-data-am install-exec install-exec-am \
- install-info install-info-am install-libLTLIBRARIES \
- install-libibcmincludeHEADERS install-man install-strip \
- installcheck installcheck-am installdirs maintainer-clean \
- maintainer-clean-generic mostlyclean mostlyclean-compile \
- mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
- tags uninstall uninstall-am uninstall-info-am \
- uninstall-libLTLIBRARIES uninstall-libibcmincludeHEADERS
-
-
-dist-hook: libibcm.spec
- cp libibcm.spec $(distdir)
-# Tell versions [3.59,3.63) of GNU make to not export all variables.
-# Otherwise a system limit (for SysV at least) may be exceeded.
-.NOEXPORT:
diff --git a/contrib/ofed/libibcm/NEWS b/contrib/ofed/libibcm/NEWS
deleted file mode 100644
index e69de29..0000000
--- a/contrib/ofed/libibcm/NEWS
+++ /dev/null
diff --git a/contrib/ofed/libibcm/README b/contrib/ofed/libibcm/README
deleted file mode 100644
index 4dda13c..0000000
--- a/contrib/ofed/libibcm/README
+++ /dev/null
@@ -1,28 +0,0 @@
-This README is for userspace cm library.
-
-Building
-
-To make this directory, run:
-./autogen.sh && ./configure && make && make install
-
-Typically the autogen and configure steps only need be done the first
-time unless configure.in or Makefile.am changes.
-
-Libraries are installed by default at /usr/local/lib.
-
-Device files
-
-The userspace CM uses a device file per adapter present.
-
-To create the appropriate character device file automatically with
-udev, a rule like
-
- KERNEL="ucm*", NAME="infiniband/%k", MODE="0666"
-
-can be used. This will create the device node named
-
- /dev/infiniband/ucm0
-
-for the first HCA in the system, or you can create it manually
-
- mknod /dev/infiniband/ucm0 c 231 224
diff --git a/contrib/ofed/libibcm/aclocal.m4 b/contrib/ofed/libibcm/aclocal.m4
deleted file mode 100644
index 5baa59e..0000000
--- a/contrib/ofed/libibcm/aclocal.m4
+++ /dev/null
@@ -1,7267 +0,0 @@
-# generated automatically by aclocal 1.9.6 -*- Autoconf -*-
-
-# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
-# 2005 Free Software Foundation, Inc.
-# This file is free software; the Free Software Foundation
-# gives unlimited permission to copy and/or distribute it,
-# with or without modifications, as long as this notice is preserved.
-
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
-# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
-# PARTICULAR PURPOSE.
-
-# libtool.m4 - Configure libtool for the host system. -*-Autoconf-*-
-
-# serial 48 Debian 1.5.22-2 AC_PROG_LIBTOOL
-
-
-# AC_PROVIDE_IFELSE(MACRO-NAME, IF-PROVIDED, IF-NOT-PROVIDED)
-# -----------------------------------------------------------
-# If this macro is not defined by Autoconf, define it here.
-m4_ifdef([AC_PROVIDE_IFELSE],
- [],
- [m4_define([AC_PROVIDE_IFELSE],
- [m4_ifdef([AC_PROVIDE_$1],
- [$2], [$3])])])
-
-
-# AC_PROG_LIBTOOL
-# ---------------
-AC_DEFUN([AC_PROG_LIBTOOL],
-[AC_REQUIRE([_AC_PROG_LIBTOOL])dnl
-dnl If AC_PROG_CXX has already been expanded, run AC_LIBTOOL_CXX
-dnl immediately, otherwise, hook it in at the end of AC_PROG_CXX.
- AC_PROVIDE_IFELSE([AC_PROG_CXX],
- [AC_LIBTOOL_CXX],
- [define([AC_PROG_CXX], defn([AC_PROG_CXX])[AC_LIBTOOL_CXX
- ])])
-dnl And a similar setup for Fortran 77 support
- AC_PROVIDE_IFELSE([AC_PROG_F77],
- [AC_LIBTOOL_F77],
- [define([AC_PROG_F77], defn([AC_PROG_F77])[AC_LIBTOOL_F77
-])])
-
-dnl Quote A][M_PROG_GCJ so that aclocal doesn't bring it in needlessly.
-dnl If either AC_PROG_GCJ or A][M_PROG_GCJ have already been expanded, run
-dnl AC_LIBTOOL_GCJ immediately, otherwise, hook it in at the end of both.
- AC_PROVIDE_IFELSE([AC_PROG_GCJ],
- [AC_LIBTOOL_GCJ],
- [AC_PROVIDE_IFELSE([A][M_PROG_GCJ],
- [AC_LIBTOOL_GCJ],
- [AC_PROVIDE_IFELSE([LT_AC_PROG_GCJ],
- [AC_LIBTOOL_GCJ],
- [ifdef([AC_PROG_GCJ],
- [define([AC_PROG_GCJ], defn([AC_PROG_GCJ])[AC_LIBTOOL_GCJ])])
- ifdef([A][M_PROG_GCJ],
- [define([A][M_PROG_GCJ], defn([A][M_PROG_GCJ])[AC_LIBTOOL_GCJ])])
- ifdef([LT_AC_PROG_GCJ],
- [define([LT_AC_PROG_GCJ],
- defn([LT_AC_PROG_GCJ])[AC_LIBTOOL_GCJ])])])])
-])])# AC_PROG_LIBTOOL
-
-
-# _AC_PROG_LIBTOOL
-# ----------------
-AC_DEFUN([_AC_PROG_LIBTOOL],
-[AC_REQUIRE([AC_LIBTOOL_SETUP])dnl
-AC_BEFORE([$0],[AC_LIBTOOL_CXX])dnl
-AC_BEFORE([$0],[AC_LIBTOOL_F77])dnl
-AC_BEFORE([$0],[AC_LIBTOOL_GCJ])dnl
-
-# This can be used to rebuild libtool when needed
-LIBTOOL_DEPS="$ac_aux_dir/ltmain.sh"
-
-# Always use our own libtool.
-LIBTOOL='$(SHELL) $(top_builddir)/libtool'
-AC_SUBST(LIBTOOL)dnl
-
-# Prevent multiple expansion
-define([AC_PROG_LIBTOOL], [])
-])# _AC_PROG_LIBTOOL
-
-
-# AC_LIBTOOL_SETUP
-# ----------------
-AC_DEFUN([AC_LIBTOOL_SETUP],
-[AC_PREREQ(2.50)dnl
-AC_REQUIRE([AC_ENABLE_SHARED])dnl
-AC_REQUIRE([AC_ENABLE_STATIC])dnl
-AC_REQUIRE([AC_ENABLE_FAST_INSTALL])dnl
-AC_REQUIRE([AC_CANONICAL_HOST])dnl
-AC_REQUIRE([AC_CANONICAL_BUILD])dnl
-AC_REQUIRE([AC_PROG_CC])dnl
-AC_REQUIRE([AC_PROG_LD])dnl
-AC_REQUIRE([AC_PROG_LD_RELOAD_FLAG])dnl
-AC_REQUIRE([AC_PROG_NM])dnl
-
-AC_REQUIRE([AC_PROG_LN_S])dnl
-AC_REQUIRE([AC_DEPLIBS_CHECK_METHOD])dnl
-# Autoconf 2.13's AC_OBJEXT and AC_EXEEXT macros only works for C compilers!
-AC_REQUIRE([AC_OBJEXT])dnl
-AC_REQUIRE([AC_EXEEXT])dnl
-dnl
-
-AC_LIBTOOL_SYS_MAX_CMD_LEN
-AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE
-AC_LIBTOOL_OBJDIR
-
-AC_REQUIRE([_LT_AC_SYS_COMPILER])dnl
-_LT_AC_PROG_ECHO_BACKSLASH
-
-case $host_os in
-aix3*)
- # AIX sometimes has problems with the GCC collect2 program. For some
- # reason, if we set the COLLECT_NAMES environment variable, the problems
- # vanish in a puff of smoke.
- if test "X${COLLECT_NAMES+set}" != Xset; then
- COLLECT_NAMES=
- export COLLECT_NAMES
- fi
- ;;
-esac
-
-# Sed substitution that helps us do robust quoting. It backslashifies
-# metacharacters that are still active within double-quoted strings.
-Xsed='sed -e 1s/^X//'
-[sed_quote_subst='s/\([\\"\\`$\\\\]\)/\\\1/g']
-
-# Same as above, but do not quote variable references.
-[double_quote_subst='s/\([\\"\\`\\\\]\)/\\\1/g']
-
-# Sed substitution to delay expansion of an escaped shell variable in a
-# double_quote_subst'ed string.
-delay_variable_subst='s/\\\\\\\\\\\$/\\\\\\$/g'
-
-# Sed substitution to avoid accidental globbing in evaled expressions
-no_glob_subst='s/\*/\\\*/g'
-
-# Constants:
-rm="rm -f"
-
-# Global variables:
-default_ofile=libtool
-can_build_shared=yes
-
-# All known linkers require a `.a' archive for static linking (except MSVC,
-# which needs '.lib').
-libext=a
-ltmain="$ac_aux_dir/ltmain.sh"
-ofile="$default_ofile"
-with_gnu_ld="$lt_cv_prog_gnu_ld"
-
-AC_CHECK_TOOL(AR, ar, false)
-AC_CHECK_TOOL(RANLIB, ranlib, :)
-AC_CHECK_TOOL(STRIP, strip, :)
-
-old_CC="$CC"
-old_CFLAGS="$CFLAGS"
-
-# Set sane defaults for various variables
-test -z "$AR" && AR=ar
-test -z "$AR_FLAGS" && AR_FLAGS=cru
-test -z "$AS" && AS=as
-test -z "$CC" && CC=cc
-test -z "$LTCC" && LTCC=$CC
-test -z "$LTCFLAGS" && LTCFLAGS=$CFLAGS
-test -z "$DLLTOOL" && DLLTOOL=dlltool
-test -z "$LD" && LD=ld
-test -z "$LN_S" && LN_S="ln -s"
-test -z "$MAGIC_CMD" && MAGIC_CMD=file
-test -z "$NM" && NM=nm
-test -z "$SED" && SED=sed
-test -z "$OBJDUMP" && OBJDUMP=objdump
-test -z "$RANLIB" && RANLIB=:
-test -z "$STRIP" && STRIP=:
-test -z "$ac_objext" && ac_objext=o
-
-# Determine commands to create old-style static archives.
-old_archive_cmds='$AR $AR_FLAGS $oldlib$oldobjs$old_deplibs'
-old_postinstall_cmds='chmod 644 $oldlib'
-old_postuninstall_cmds=
-
-if test -n "$RANLIB"; then
- case $host_os in
- openbsd*)
- old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB -t \$oldlib"
- ;;
- *)
- old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB \$oldlib"
- ;;
- esac
- old_archive_cmds="$old_archive_cmds~\$RANLIB \$oldlib"
-fi
-
-_LT_CC_BASENAME([$compiler])
-
-# Only perform the check for file, if the check method requires it
-case $deplibs_check_method in
-file_magic*)
- if test "$file_magic_cmd" = '$MAGIC_CMD'; then
- AC_PATH_MAGIC
- fi
- ;;
-esac
-
-AC_PROVIDE_IFELSE([AC_LIBTOOL_DLOPEN], enable_dlopen=yes, enable_dlopen=no)
-AC_PROVIDE_IFELSE([AC_LIBTOOL_WIN32_DLL],
-enable_win32_dll=yes, enable_win32_dll=no)
-
-AC_ARG_ENABLE([libtool-lock],
- [AC_HELP_STRING([--disable-libtool-lock],
- [avoid locking (might break parallel builds)])])
-test "x$enable_libtool_lock" != xno && enable_libtool_lock=yes
-
-AC_ARG_WITH([pic],
- [AC_HELP_STRING([--with-pic],
- [try to use only PIC/non-PIC objects @<:@default=use both@:>@])],
- [pic_mode="$withval"],
- [pic_mode=default])
-test -z "$pic_mode" && pic_mode=default
-
-# Use C for the default configuration in the libtool script
-tagname=
-AC_LIBTOOL_LANG_C_CONFIG
-_LT_AC_TAGCONFIG
-])# AC_LIBTOOL_SETUP
-
-
-# _LT_AC_SYS_COMPILER
-# -------------------
-AC_DEFUN([_LT_AC_SYS_COMPILER],
-[AC_REQUIRE([AC_PROG_CC])dnl
-
-# If no C compiler was specified, use CC.
-LTCC=${LTCC-"$CC"}
-
-# If no C compiler flags were specified, use CFLAGS.
-LTCFLAGS=${LTCFLAGS-"$CFLAGS"}
-
-# Allow CC to be a program name with arguments.
-compiler=$CC
-])# _LT_AC_SYS_COMPILER
-
-
-# _LT_CC_BASENAME(CC)
-# -------------------
-# Calculate cc_basename. Skip known compiler wrappers and cross-prefix.
-AC_DEFUN([_LT_CC_BASENAME],
-[for cc_temp in $1""; do
- case $cc_temp in
- compile | *[[\\/]]compile | ccache | *[[\\/]]ccache ) ;;
- distcc | *[[\\/]]distcc | purify | *[[\\/]]purify ) ;;
- \-*) ;;
- *) break;;
- esac
-done
-cc_basename=`$echo "X$cc_temp" | $Xsed -e 's%.*/%%' -e "s%^$host_alias-%%"`
-])
-
-
-# _LT_COMPILER_BOILERPLATE
-# ------------------------
-# Check for compiler boilerplate output or warnings with
-# the simple compiler test code.
-AC_DEFUN([_LT_COMPILER_BOILERPLATE],
-[ac_outfile=conftest.$ac_objext
-printf "$lt_simple_compile_test_code" >conftest.$ac_ext
-eval "$ac_compile" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err
-_lt_compiler_boilerplate=`cat conftest.err`
-$rm conftest*
-])# _LT_COMPILER_BOILERPLATE
-
-
-# _LT_LINKER_BOILERPLATE
-# ----------------------
-# Check for linker boilerplate output or warnings with
-# the simple link test code.
-AC_DEFUN([_LT_LINKER_BOILERPLATE],
-[ac_outfile=conftest.$ac_objext
-printf "$lt_simple_link_test_code" >conftest.$ac_ext
-eval "$ac_link" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err
-_lt_linker_boilerplate=`cat conftest.err`
-$rm conftest*
-])# _LT_LINKER_BOILERPLATE
-
-
-# _LT_AC_SYS_LIBPATH_AIX
-# ----------------------
-# Links a minimal program and checks the executable
-# for the system default hardcoded library path. In most cases,
-# this is /usr/lib:/lib, but when the MPI compilers are used
-# the location of the communication and MPI libs are included too.
-# If we don't find anything, use the default library path according
-# to the aix ld manual.
-AC_DEFUN([_LT_AC_SYS_LIBPATH_AIX],
-[AC_LINK_IFELSE(AC_LANG_PROGRAM,[
-aix_libpath=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; }
-}'`
-# Check for a 64-bit object if we didn't find anything.
-if test -z "$aix_libpath"; then aix_libpath=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; }
-}'`; fi],[])
-if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
-])# _LT_AC_SYS_LIBPATH_AIX
-
-
-# _LT_AC_SHELL_INIT(ARG)
-# ----------------------
-AC_DEFUN([_LT_AC_SHELL_INIT],
-[ifdef([AC_DIVERSION_NOTICE],
- [AC_DIVERT_PUSH(AC_DIVERSION_NOTICE)],
- [AC_DIVERT_PUSH(NOTICE)])
-$1
-AC_DIVERT_POP
-])# _LT_AC_SHELL_INIT
-
-
-# _LT_AC_PROG_ECHO_BACKSLASH
-# --------------------------
-# Add some code to the start of the generated configure script which
-# will find an echo command which doesn't interpret backslashes.
-AC_DEFUN([_LT_AC_PROG_ECHO_BACKSLASH],
-[_LT_AC_SHELL_INIT([
-# Check that we are running under the correct shell.
-SHELL=${CONFIG_SHELL-/bin/sh}
-
-case X$ECHO in
-X*--fallback-echo)
- # Remove one level of quotation (which was required for Make).
- ECHO=`echo "$ECHO" | sed 's,\\\\\[$]\\[$]0,'[$]0','`
- ;;
-esac
-
-echo=${ECHO-echo}
-if test "X[$]1" = X--no-reexec; then
- # Discard the --no-reexec flag, and continue.
- shift
-elif test "X[$]1" = X--fallback-echo; then
- # Avoid inline document here, it may be left over
- :
-elif test "X`($echo '\t') 2>/dev/null`" = 'X\t' ; then
- # Yippee, $echo works!
- :
-else
- # Restart under the correct shell.
- exec $SHELL "[$]0" --no-reexec ${1+"[$]@"}
-fi
-
-if test "X[$]1" = X--fallback-echo; then
- # used as fallback echo
- shift
- cat <<EOF
-[$]*
-EOF
- exit 0
-fi
-
-# The HP-UX ksh and POSIX shell print the target directory to stdout
-# if CDPATH is set.
-(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
-
-if test -z "$ECHO"; then
-if test "X${echo_test_string+set}" != Xset; then
-# find a string as large as possible, as long as the shell can cope with it
- for cmd in 'sed 50q "[$]0"' 'sed 20q "[$]0"' 'sed 10q "[$]0"' 'sed 2q "[$]0"' 'echo test'; do
- # expected sizes: less than 2Kb, 1Kb, 512 bytes, 16 bytes, ...
- if (echo_test_string=`eval $cmd`) 2>/dev/null &&
- echo_test_string=`eval $cmd` &&
- (test "X$echo_test_string" = "X$echo_test_string") 2>/dev/null
- then
- break
- fi
- done
-fi
-
-if test "X`($echo '\t') 2>/dev/null`" = 'X\t' &&
- echo_testing_string=`($echo "$echo_test_string") 2>/dev/null` &&
- test "X$echo_testing_string" = "X$echo_test_string"; then
- :
-else
- # The Solaris, AIX, and Digital Unix default echo programs unquote
- # backslashes. This makes it impossible to quote backslashes using
- # echo "$something" | sed 's/\\/\\\\/g'
- #
- # So, first we look for a working echo in the user's PATH.
-
- lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
- for dir in $PATH /usr/ucb; do
- IFS="$lt_save_ifs"
- if (test -f $dir/echo || test -f $dir/echo$ac_exeext) &&
- test "X`($dir/echo '\t') 2>/dev/null`" = 'X\t' &&
- echo_testing_string=`($dir/echo "$echo_test_string") 2>/dev/null` &&
- test "X$echo_testing_string" = "X$echo_test_string"; then
- echo="$dir/echo"
- break
- fi
- done
- IFS="$lt_save_ifs"
-
- if test "X$echo" = Xecho; then
- # We didn't find a better echo, so look for alternatives.
- if test "X`(print -r '\t') 2>/dev/null`" = 'X\t' &&
- echo_testing_string=`(print -r "$echo_test_string") 2>/dev/null` &&
- test "X$echo_testing_string" = "X$echo_test_string"; then
- # This shell has a builtin print -r that does the trick.
- echo='print -r'
- elif (test -f /bin/ksh || test -f /bin/ksh$ac_exeext) &&
- test "X$CONFIG_SHELL" != X/bin/ksh; then
- # If we have ksh, try running configure again with it.
- ORIGINAL_CONFIG_SHELL=${CONFIG_SHELL-/bin/sh}
- export ORIGINAL_CONFIG_SHELL
- CONFIG_SHELL=/bin/ksh
- export CONFIG_SHELL
- exec $CONFIG_SHELL "[$]0" --no-reexec ${1+"[$]@"}
- else
- # Try using printf.
- echo='printf %s\n'
- if test "X`($echo '\t') 2>/dev/null`" = 'X\t' &&
- echo_testing_string=`($echo "$echo_test_string") 2>/dev/null` &&
- test "X$echo_testing_string" = "X$echo_test_string"; then
- # Cool, printf works
- :
- elif echo_testing_string=`($ORIGINAL_CONFIG_SHELL "[$]0" --fallback-echo '\t') 2>/dev/null` &&
- test "X$echo_testing_string" = 'X\t' &&
- echo_testing_string=`($ORIGINAL_CONFIG_SHELL "[$]0" --fallback-echo "$echo_test_string") 2>/dev/null` &&
- test "X$echo_testing_string" = "X$echo_test_string"; then
- CONFIG_SHELL=$ORIGINAL_CONFIG_SHELL
- export CONFIG_SHELL
- SHELL="$CONFIG_SHELL"
- export SHELL
- echo="$CONFIG_SHELL [$]0 --fallback-echo"
- elif echo_testing_string=`($CONFIG_SHELL "[$]0" --fallback-echo '\t') 2>/dev/null` &&
- test "X$echo_testing_string" = 'X\t' &&
- echo_testing_string=`($CONFIG_SHELL "[$]0" --fallback-echo "$echo_test_string") 2>/dev/null` &&
- test "X$echo_testing_string" = "X$echo_test_string"; then
- echo="$CONFIG_SHELL [$]0 --fallback-echo"
- else
- # maybe with a smaller string...
- prev=:
-
- for cmd in 'echo test' 'sed 2q "[$]0"' 'sed 10q "[$]0"' 'sed 20q "[$]0"' 'sed 50q "[$]0"'; do
- if (test "X$echo_test_string" = "X`eval $cmd`") 2>/dev/null
- then
- break
- fi
- prev="$cmd"
- done
-
- if test "$prev" != 'sed 50q "[$]0"'; then
- echo_test_string=`eval $prev`
- export echo_test_string
- exec ${ORIGINAL_CONFIG_SHELL-${CONFIG_SHELL-/bin/sh}} "[$]0" ${1+"[$]@"}
- else
- # Oops. We lost completely, so just stick with echo.
- echo=echo
- fi
- fi
- fi
- fi
-fi
-fi
-
-# Copy echo and quote the copy suitably for passing to libtool from
-# the Makefile, instead of quoting the original, which is used later.
-ECHO=$echo
-if test "X$ECHO" = "X$CONFIG_SHELL [$]0 --fallback-echo"; then
- ECHO="$CONFIG_SHELL \\\$\[$]0 --fallback-echo"
-fi
-
-AC_SUBST(ECHO)
-])])# _LT_AC_PROG_ECHO_BACKSLASH
-
-
-# _LT_AC_LOCK
-# -----------
-AC_DEFUN([_LT_AC_LOCK],
-[AC_ARG_ENABLE([libtool-lock],
- [AC_HELP_STRING([--disable-libtool-lock],
- [avoid locking (might break parallel builds)])])
-test "x$enable_libtool_lock" != xno && enable_libtool_lock=yes
-
-# Some flags need to be propagated to the compiler or linker for good
-# libtool support.
-case $host in
-ia64-*-hpux*)
- # Find out which ABI we are using.
- echo 'int i;' > conftest.$ac_ext
- if AC_TRY_EVAL(ac_compile); then
- case `/usr/bin/file conftest.$ac_objext` in
- *ELF-32*)
- HPUX_IA64_MODE="32"
- ;;
- *ELF-64*)
- HPUX_IA64_MODE="64"
- ;;
- esac
- fi
- rm -rf conftest*
- ;;
-*-*-irix6*)
- # Find out which ABI we are using.
- echo '[#]line __oline__ "configure"' > conftest.$ac_ext
- if AC_TRY_EVAL(ac_compile); then
- if test "$lt_cv_prog_gnu_ld" = yes; then
- case `/usr/bin/file conftest.$ac_objext` in
- *32-bit*)
- LD="${LD-ld} -melf32bsmip"
- ;;
- *N32*)
- LD="${LD-ld} -melf32bmipn32"
- ;;
- *64-bit*)
- LD="${LD-ld} -melf64bmip"
- ;;
- esac
- else
- case `/usr/bin/file conftest.$ac_objext` in
- *32-bit*)
- LD="${LD-ld} -32"
- ;;
- *N32*)
- LD="${LD-ld} -n32"
- ;;
- *64-bit*)
- LD="${LD-ld} -64"
- ;;
- esac
- fi
- fi
- rm -rf conftest*
- ;;
-
-x86_64-*linux*|ppc*-*linux*|powerpc*-*linux*|s390*-*linux*|sparc*-*linux*)
- # Find out which ABI we are using.
- echo 'int i;' > conftest.$ac_ext
- if AC_TRY_EVAL(ac_compile); then
- case `/usr/bin/file conftest.o` in
- *32-bit*)
- case $host in
- x86_64-*linux*)
- LD="${LD-ld} -m elf_i386"
- ;;
- ppc64-*linux*|powerpc64-*linux*)
- LD="${LD-ld} -m elf32ppclinux"
- ;;
- s390x-*linux*)
- LD="${LD-ld} -m elf_s390"
- ;;
- sparc64-*linux*)
- LD="${LD-ld} -m elf32_sparc"
- ;;
- esac
- ;;
- *64-bit*)
- case $host in
- x86_64-*linux*)
- LD="${LD-ld} -m elf_x86_64"
- ;;
- ppc*-*linux*|powerpc*-*linux*)
- LD="${LD-ld} -m elf64ppc"
- ;;
- s390*-*linux*)
- LD="${LD-ld} -m elf64_s390"
- ;;
- sparc*-*linux*)
- LD="${LD-ld} -m elf64_sparc"
- ;;
- esac
- ;;
- esac
- fi
- rm -rf conftest*
- ;;
-
-*-*-sco3.2v5*)
- # On SCO OpenServer 5, we need -belf to get full-featured binaries.
- SAVE_CFLAGS="$CFLAGS"
- CFLAGS="$CFLAGS -belf"
- AC_CACHE_CHECK([whether the C compiler needs -belf], lt_cv_cc_needs_belf,
- [AC_LANG_PUSH(C)
- AC_TRY_LINK([],[],[lt_cv_cc_needs_belf=yes],[lt_cv_cc_needs_belf=no])
- AC_LANG_POP])
- if test x"$lt_cv_cc_needs_belf" != x"yes"; then
- # this is probably gcc 2.8.0, egcs 1.0 or newer; no need for -belf
- CFLAGS="$SAVE_CFLAGS"
- fi
- ;;
-sparc*-*solaris*)
- # Find out which ABI we are using.
- echo 'int i;' > conftest.$ac_ext
- if AC_TRY_EVAL(ac_compile); then
- case `/usr/bin/file conftest.o` in
- *64-bit*)
- case $lt_cv_prog_gnu_ld in
- yes*) LD="${LD-ld} -m elf64_sparc" ;;
- *) LD="${LD-ld} -64" ;;
- esac
- ;;
- esac
- fi
- rm -rf conftest*
- ;;
-
-AC_PROVIDE_IFELSE([AC_LIBTOOL_WIN32_DLL],
-[*-*-cygwin* | *-*-mingw* | *-*-pw32*)
- AC_CHECK_TOOL(DLLTOOL, dlltool, false)
- AC_CHECK_TOOL(AS, as, false)
- AC_CHECK_TOOL(OBJDUMP, objdump, false)
- ;;
- ])
-esac
-
-need_locks="$enable_libtool_lock"
-
-])# _LT_AC_LOCK
-
-
-# AC_LIBTOOL_COMPILER_OPTION(MESSAGE, VARIABLE-NAME, FLAGS,
-# [OUTPUT-FILE], [ACTION-SUCCESS], [ACTION-FAILURE])
-# ----------------------------------------------------------------
-# Check whether the given compiler option works
-AC_DEFUN([AC_LIBTOOL_COMPILER_OPTION],
-[AC_REQUIRE([LT_AC_PROG_SED])
-AC_CACHE_CHECK([$1], [$2],
- [$2=no
- ifelse([$4], , [ac_outfile=conftest.$ac_objext], [ac_outfile=$4])
- printf "$lt_simple_compile_test_code" > conftest.$ac_ext
- lt_compiler_flag="$3"
- # Insert the option either (1) after the last *FLAGS variable, or
- # (2) before a word containing "conftest.", or (3) at the end.
- # Note that $ac_compile itself does not contain backslashes and begins
- # with a dollar sign (not a hyphen), so the echo should work correctly.
- # The option is referenced via a variable to avoid confusing sed.
- lt_compile=`echo "$ac_compile" | $SED \
- -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
- -e 's: [[^ ]]*conftest\.: $lt_compiler_flag&:; t' \
- -e 's:$: $lt_compiler_flag:'`
- (eval echo "\"\$as_me:__oline__: $lt_compile\"" >&AS_MESSAGE_LOG_FD)
- (eval "$lt_compile" 2>conftest.err)
- ac_status=$?
- cat conftest.err >&AS_MESSAGE_LOG_FD
- echo "$as_me:__oline__: \$? = $ac_status" >&AS_MESSAGE_LOG_FD
- if (exit $ac_status) && test -s "$ac_outfile"; then
- # The compiler can only warn and ignore the option if not recognized
- # So say no if there are warnings other than the usual output.
- $echo "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' >conftest.exp
- $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2
- if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then
- $2=yes
- fi
- fi
- $rm conftest*
-])
-
-if test x"[$]$2" = xyes; then
- ifelse([$5], , :, [$5])
-else
- ifelse([$6], , :, [$6])
-fi
-])# AC_LIBTOOL_COMPILER_OPTION
-
-
-# AC_LIBTOOL_LINKER_OPTION(MESSAGE, VARIABLE-NAME, FLAGS,
-# [ACTION-SUCCESS], [ACTION-FAILURE])
-# ------------------------------------------------------------
-# Check whether the given compiler option works
-AC_DEFUN([AC_LIBTOOL_LINKER_OPTION],
-[AC_CACHE_CHECK([$1], [$2],
- [$2=no
- save_LDFLAGS="$LDFLAGS"
- LDFLAGS="$LDFLAGS $3"
- printf "$lt_simple_link_test_code" > conftest.$ac_ext
- if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then
- # The linker can only warn and ignore the option if not recognized
- # So say no if there are warnings
- if test -s conftest.err; then
- # Append any errors to the config.log.
- cat conftest.err 1>&AS_MESSAGE_LOG_FD
- $echo "X$_lt_linker_boilerplate" | $Xsed -e '/^$/d' > conftest.exp
- $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2
- if diff conftest.exp conftest.er2 >/dev/null; then
- $2=yes
- fi
- else
- $2=yes
- fi
- fi
- $rm conftest*
- LDFLAGS="$save_LDFLAGS"
-])
-
-if test x"[$]$2" = xyes; then
- ifelse([$4], , :, [$4])
-else
- ifelse([$5], , :, [$5])
-fi
-])# AC_LIBTOOL_LINKER_OPTION
-
-
-# AC_LIBTOOL_SYS_MAX_CMD_LEN
-# --------------------------
-AC_DEFUN([AC_LIBTOOL_SYS_MAX_CMD_LEN],
-[# find the maximum length of command line arguments
-AC_MSG_CHECKING([the maximum length of command line arguments])
-AC_CACHE_VAL([lt_cv_sys_max_cmd_len], [dnl
- i=0
- teststring="ABCD"
-
- case $build_os in
- msdosdjgpp*)
- # On DJGPP, this test can blow up pretty badly due to problems in libc
- # (any single argument exceeding 2000 bytes causes a buffer overrun
- # during glob expansion). Even if it were fixed, the result of this
- # check would be larger than it should be.
- lt_cv_sys_max_cmd_len=12288; # 12K is about right
- ;;
-
- gnu*)
- # Under GNU Hurd, this test is not required because there is
- # no limit to the length of command line arguments.
- # Libtool will interpret -1 as no limit whatsoever
- lt_cv_sys_max_cmd_len=-1;
- ;;
-
- cygwin* | mingw*)
- # On Win9x/ME, this test blows up -- it succeeds, but takes
- # about 5 minutes as the teststring grows exponentially.
- # Worse, since 9x/ME are not pre-emptively multitasking,
- # you end up with a "frozen" computer, even though with patience
- # the test eventually succeeds (with a max line length of 256k).
- # Instead, let's just punt: use the minimum linelength reported by
- # all of the supported platforms: 8192 (on NT/2K/XP).
- lt_cv_sys_max_cmd_len=8192;
- ;;
-
- amigaos*)
- # On AmigaOS with pdksh, this test takes hours, literally.
- # So we just punt and use a minimum line length of 8192.
- lt_cv_sys_max_cmd_len=8192;
- ;;
-
- netbsd* | freebsd* | openbsd* | darwin* | dragonfly*)
- # This has been around since 386BSD, at least. Likely further.
- if test -x /sbin/sysctl; then
- lt_cv_sys_max_cmd_len=`/sbin/sysctl -n kern.argmax`
- elif test -x /usr/sbin/sysctl; then
- lt_cv_sys_max_cmd_len=`/usr/sbin/sysctl -n kern.argmax`
- else
- lt_cv_sys_max_cmd_len=65536 # usable default for all BSDs
- fi
- # And add a safety zone
- lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4`
- lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3`
- ;;
-
- interix*)
- # We know the value 262144 and hardcode it with a safety zone (like BSD)
- lt_cv_sys_max_cmd_len=196608
- ;;
-
- osf*)
- # Dr. Hans Ekkehard Plesser reports seeing a kernel panic running configure
- # due to this test when exec_disable_arg_limit is 1 on Tru64. It is not
- # nice to cause kernel panics so lets avoid the loop below.
- # First set a reasonable default.
- lt_cv_sys_max_cmd_len=16384
- #
- if test -x /sbin/sysconfig; then
- case `/sbin/sysconfig -q proc exec_disable_arg_limit` in
- *1*) lt_cv_sys_max_cmd_len=-1 ;;
- esac
- fi
- ;;
- sco3.2v5*)
- lt_cv_sys_max_cmd_len=102400
- ;;
- sysv5* | sco5v6* | sysv4.2uw2*)
- kargmax=`grep ARG_MAX /etc/conf/cf.d/stune 2>/dev/null`
- if test -n "$kargmax"; then
- lt_cv_sys_max_cmd_len=`echo $kargmax | sed 's/.*[[ ]]//'`
- else
- lt_cv_sys_max_cmd_len=32768
- fi
- ;;
- *)
- # If test is not a shell built-in, we'll probably end up computing a
- # maximum length that is only half of the actual maximum length, but
- # we can't tell.
- SHELL=${SHELL-${CONFIG_SHELL-/bin/sh}}
- while (test "X"`$SHELL [$]0 --fallback-echo "X$teststring" 2>/dev/null` \
- = "XX$teststring") >/dev/null 2>&1 &&
- new_result=`expr "X$teststring" : ".*" 2>&1` &&
- lt_cv_sys_max_cmd_len=$new_result &&
- test $i != 17 # 1/2 MB should be enough
- do
- i=`expr $i + 1`
- teststring=$teststring$teststring
- done
- teststring=
- # Add a significant safety factor because C++ compilers can tack on massive
- # amounts of additional arguments before passing them to the linker.
- # It appears as though 1/2 is a usable value.
- lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 2`
- ;;
- esac
-])
-if test -n $lt_cv_sys_max_cmd_len ; then
- AC_MSG_RESULT($lt_cv_sys_max_cmd_len)
-else
- AC_MSG_RESULT(none)
-fi
-])# AC_LIBTOOL_SYS_MAX_CMD_LEN
-
-
-# _LT_AC_CHECK_DLFCN
-# ------------------
-AC_DEFUN([_LT_AC_CHECK_DLFCN],
-[AC_CHECK_HEADERS(dlfcn.h)dnl
-])# _LT_AC_CHECK_DLFCN
-
-
-# _LT_AC_TRY_DLOPEN_SELF (ACTION-IF-TRUE, ACTION-IF-TRUE-W-USCORE,
-# ACTION-IF-FALSE, ACTION-IF-CROSS-COMPILING)
-# ---------------------------------------------------------------------
-AC_DEFUN([_LT_AC_TRY_DLOPEN_SELF],
-[AC_REQUIRE([_LT_AC_CHECK_DLFCN])dnl
-if test "$cross_compiling" = yes; then :
- [$4]
-else
- lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
- lt_status=$lt_dlunknown
- cat > conftest.$ac_ext <<EOF
-[#line __oline__ "configure"
-#include "confdefs.h"
-
-#if HAVE_DLFCN_H
-#include <dlfcn.h>
-#endif
-
-#include <stdio.h>
-
-#ifdef RTLD_GLOBAL
-# define LT_DLGLOBAL RTLD_GLOBAL
-#else
-# ifdef DL_GLOBAL
-# define LT_DLGLOBAL DL_GLOBAL
-# else
-# define LT_DLGLOBAL 0
-# endif
-#endif
-
-/* We may have to define LT_DLLAZY_OR_NOW in the command line if we
- find out it does not work in some platform. */
-#ifndef LT_DLLAZY_OR_NOW
-# ifdef RTLD_LAZY
-# define LT_DLLAZY_OR_NOW RTLD_LAZY
-# else
-# ifdef DL_LAZY
-# define LT_DLLAZY_OR_NOW DL_LAZY
-# else
-# ifdef RTLD_NOW
-# define LT_DLLAZY_OR_NOW RTLD_NOW
-# else
-# ifdef DL_NOW
-# define LT_DLLAZY_OR_NOW DL_NOW
-# else
-# define LT_DLLAZY_OR_NOW 0
-# endif
-# endif
-# endif
-# endif
-#endif
-
-#ifdef __cplusplus
-extern "C" void exit (int);
-#endif
-
-void fnord() { int i=42;}
-int main ()
-{
- void *self = dlopen (0, LT_DLGLOBAL|LT_DLLAZY_OR_NOW);
- int status = $lt_dlunknown;
-
- if (self)
- {
- if (dlsym (self,"fnord")) status = $lt_dlno_uscore;
- else if (dlsym( self,"_fnord")) status = $lt_dlneed_uscore;
- /* dlclose (self); */
- }
- else
- puts (dlerror ());
-
- exit (status);
-}]
-EOF
- if AC_TRY_EVAL(ac_link) && test -s conftest${ac_exeext} 2>/dev/null; then
- (./conftest; exit; ) >&AS_MESSAGE_LOG_FD 2>/dev/null
- lt_status=$?
- case x$lt_status in
- x$lt_dlno_uscore) $1 ;;
- x$lt_dlneed_uscore) $2 ;;
- x$lt_dlunknown|x*) $3 ;;
- esac
- else :
- # compilation failed
- $3
- fi
-fi
-rm -fr conftest*
-])# _LT_AC_TRY_DLOPEN_SELF
-
-
-# AC_LIBTOOL_DLOPEN_SELF
-# ----------------------
-AC_DEFUN([AC_LIBTOOL_DLOPEN_SELF],
-[AC_REQUIRE([_LT_AC_CHECK_DLFCN])dnl
-if test "x$enable_dlopen" != xyes; then
- enable_dlopen=unknown
- enable_dlopen_self=unknown
- enable_dlopen_self_static=unknown
-else
- lt_cv_dlopen=no
- lt_cv_dlopen_libs=
-
- case $host_os in
- beos*)
- lt_cv_dlopen="load_add_on"
- lt_cv_dlopen_libs=
- lt_cv_dlopen_self=yes
- ;;
-
- mingw* | pw32*)
- lt_cv_dlopen="LoadLibrary"
- lt_cv_dlopen_libs=
- ;;
-
- cygwin*)
- lt_cv_dlopen="dlopen"
- lt_cv_dlopen_libs=
- ;;
-
- darwin*)
- # if libdl is installed we need to link against it
- AC_CHECK_LIB([dl], [dlopen],
- [lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl"],[
- lt_cv_dlopen="dyld"
- lt_cv_dlopen_libs=
- lt_cv_dlopen_self=yes
- ])
- ;;
-
- *)
- AC_CHECK_FUNC([shl_load],
- [lt_cv_dlopen="shl_load"],
- [AC_CHECK_LIB([dld], [shl_load],
- [lt_cv_dlopen="shl_load" lt_cv_dlopen_libs="-dld"],
- [AC_CHECK_FUNC([dlopen],
- [lt_cv_dlopen="dlopen"],
- [AC_CHECK_LIB([dl], [dlopen],
- [lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl"],
- [AC_CHECK_LIB([svld], [dlopen],
- [lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-lsvld"],
- [AC_CHECK_LIB([dld], [dld_link],
- [lt_cv_dlopen="dld_link" lt_cv_dlopen_libs="-dld"])
- ])
- ])
- ])
- ])
- ])
- ;;
- esac
-
- if test "x$lt_cv_dlopen" != xno; then
- enable_dlopen=yes
- else
- enable_dlopen=no
- fi
-
- case $lt_cv_dlopen in
- dlopen)
- save_CPPFLAGS="$CPPFLAGS"
- test "x$ac_cv_header_dlfcn_h" = xyes && CPPFLAGS="$CPPFLAGS -DHAVE_DLFCN_H"
-
- save_LDFLAGS="$LDFLAGS"
- wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $export_dynamic_flag_spec\"
-
- save_LIBS="$LIBS"
- LIBS="$lt_cv_dlopen_libs $LIBS"
-
- AC_CACHE_CHECK([whether a program can dlopen itself],
- lt_cv_dlopen_self, [dnl
- _LT_AC_TRY_DLOPEN_SELF(
- lt_cv_dlopen_self=yes, lt_cv_dlopen_self=yes,
- lt_cv_dlopen_self=no, lt_cv_dlopen_self=cross)
- ])
-
- if test "x$lt_cv_dlopen_self" = xyes; then
- wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $lt_prog_compiler_static\"
- AC_CACHE_CHECK([whether a statically linked program can dlopen itself],
- lt_cv_dlopen_self_static, [dnl
- _LT_AC_TRY_DLOPEN_SELF(
- lt_cv_dlopen_self_static=yes, lt_cv_dlopen_self_static=yes,
- lt_cv_dlopen_self_static=no, lt_cv_dlopen_self_static=cross)
- ])
- fi
-
- CPPFLAGS="$save_CPPFLAGS"
- LDFLAGS="$save_LDFLAGS"
- LIBS="$save_LIBS"
- ;;
- esac
-
- case $lt_cv_dlopen_self in
- yes|no) enable_dlopen_self=$lt_cv_dlopen_self ;;
- *) enable_dlopen_self=unknown ;;
- esac
-
- case $lt_cv_dlopen_self_static in
- yes|no) enable_dlopen_self_static=$lt_cv_dlopen_self_static ;;
- *) enable_dlopen_self_static=unknown ;;
- esac
-fi
-])# AC_LIBTOOL_DLOPEN_SELF
-
-
-# AC_LIBTOOL_PROG_CC_C_O([TAGNAME])
-# ---------------------------------
-# Check to see if options -c and -o are simultaneously supported by compiler
-AC_DEFUN([AC_LIBTOOL_PROG_CC_C_O],
-[AC_REQUIRE([_LT_AC_SYS_COMPILER])dnl
-AC_CACHE_CHECK([if $compiler supports -c -o file.$ac_objext],
- [_LT_AC_TAGVAR(lt_cv_prog_compiler_c_o, $1)],
- [_LT_AC_TAGVAR(lt_cv_prog_compiler_c_o, $1)=no
- $rm -r conftest 2>/dev/null
- mkdir conftest
- cd conftest
- mkdir out
- printf "$lt_simple_compile_test_code" > conftest.$ac_ext
-
- lt_compiler_flag="-o out/conftest2.$ac_objext"
- # Insert the option either (1) after the last *FLAGS variable, or
- # (2) before a word containing "conftest.", or (3) at the end.
- # Note that $ac_compile itself does not contain backslashes and begins
- # with a dollar sign (not a hyphen), so the echo should work correctly.
- lt_compile=`echo "$ac_compile" | $SED \
- -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
- -e 's: [[^ ]]*conftest\.: $lt_compiler_flag&:; t' \
- -e 's:$: $lt_compiler_flag:'`
- (eval echo "\"\$as_me:__oline__: $lt_compile\"" >&AS_MESSAGE_LOG_FD)
- (eval "$lt_compile" 2>out/conftest.err)
- ac_status=$?
- cat out/conftest.err >&AS_MESSAGE_LOG_FD
- echo "$as_me:__oline__: \$? = $ac_status" >&AS_MESSAGE_LOG_FD
- if (exit $ac_status) && test -s out/conftest2.$ac_objext
- then
- # The compiler can only warn and ignore the option if not recognized
- # So say no if there are warnings
- $echo "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' > out/conftest.exp
- $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2
- if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then
- _LT_AC_TAGVAR(lt_cv_prog_compiler_c_o, $1)=yes
- fi
- fi
- chmod u+w . 2>&AS_MESSAGE_LOG_FD
- $rm conftest*
- # SGI C++ compiler will create directory out/ii_files/ for
- # template instantiation
- test -d out/ii_files && $rm out/ii_files/* && rmdir out/ii_files
- $rm out/* && rmdir out
- cd ..
- rmdir conftest
- $rm conftest*
-])
-])# AC_LIBTOOL_PROG_CC_C_O
-
-
-# AC_LIBTOOL_SYS_HARD_LINK_LOCKS([TAGNAME])
-# -----------------------------------------
-# Check to see if we can do hard links to lock some files if needed
-AC_DEFUN([AC_LIBTOOL_SYS_HARD_LINK_LOCKS],
-[AC_REQUIRE([_LT_AC_LOCK])dnl
-
-hard_links="nottested"
-if test "$_LT_AC_TAGVAR(lt_cv_prog_compiler_c_o, $1)" = no && test "$need_locks" != no; then
- # do not overwrite the value of need_locks provided by the user
- AC_MSG_CHECKING([if we can lock with hard links])
- hard_links=yes
- $rm conftest*
- ln conftest.a conftest.b 2>/dev/null && hard_links=no
- touch conftest.a
- ln conftest.a conftest.b 2>&5 || hard_links=no
- ln conftest.a conftest.b 2>/dev/null && hard_links=no
- AC_MSG_RESULT([$hard_links])
- if test "$hard_links" = no; then
- AC_MSG_WARN([`$CC' does not support `-c -o', so `make -j' may be unsafe])
- need_locks=warn
- fi
-else
- need_locks=no
-fi
-])# AC_LIBTOOL_SYS_HARD_LINK_LOCKS
-
-
-# AC_LIBTOOL_OBJDIR
-# -----------------
-AC_DEFUN([AC_LIBTOOL_OBJDIR],
-[AC_CACHE_CHECK([for objdir], [lt_cv_objdir],
-[rm -f .libs 2>/dev/null
-mkdir .libs 2>/dev/null
-if test -d .libs; then
- lt_cv_objdir=.libs
-else
- # MS-DOS does not allow filenames that begin with a dot.
- lt_cv_objdir=_libs
-fi
-rmdir .libs 2>/dev/null])
-objdir=$lt_cv_objdir
-])# AC_LIBTOOL_OBJDIR
-
-
-# AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH([TAGNAME])
-# ----------------------------------------------
-# Check hardcoding attributes.
-AC_DEFUN([AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH],
-[AC_MSG_CHECKING([how to hardcode library paths into programs])
-_LT_AC_TAGVAR(hardcode_action, $1)=
-if test -n "$_LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)" || \
- test -n "$_LT_AC_TAGVAR(runpath_var, $1)" || \
- test "X$_LT_AC_TAGVAR(hardcode_automatic, $1)" = "Xyes" ; then
-
- # We can hardcode non-existant directories.
- if test "$_LT_AC_TAGVAR(hardcode_direct, $1)" != no &&
- # If the only mechanism to avoid hardcoding is shlibpath_var, we
- # have to relink, otherwise we might link with an installed library
- # when we should be linking with a yet-to-be-installed one
- ## test "$_LT_AC_TAGVAR(hardcode_shlibpath_var, $1)" != no &&
- test "$_LT_AC_TAGVAR(hardcode_minus_L, $1)" != no; then
- # Linking always hardcodes the temporary library directory.
- _LT_AC_TAGVAR(hardcode_action, $1)=relink
- else
- # We can link without hardcoding, and we can hardcode nonexisting dirs.
- _LT_AC_TAGVAR(hardcode_action, $1)=immediate
- fi
-else
- # We cannot hardcode anything, or else we can only hardcode existing
- # directories.
- _LT_AC_TAGVAR(hardcode_action, $1)=unsupported
-fi
-AC_MSG_RESULT([$_LT_AC_TAGVAR(hardcode_action, $1)])
-
-if test "$_LT_AC_TAGVAR(hardcode_action, $1)" = relink; then
- # Fast installation is not supported
- enable_fast_install=no
-elif test "$shlibpath_overrides_runpath" = yes ||
- test "$enable_shared" = no; then
- # Fast installation is not necessary
- enable_fast_install=needless
-fi
-])# AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH
-
-
-# AC_LIBTOOL_SYS_LIB_STRIP
-# ------------------------
-AC_DEFUN([AC_LIBTOOL_SYS_LIB_STRIP],
-[striplib=
-old_striplib=
-AC_MSG_CHECKING([whether stripping libraries is possible])
-if test -n "$STRIP" && $STRIP -V 2>&1 | grep "GNU strip" >/dev/null; then
- test -z "$old_striplib" && old_striplib="$STRIP --strip-debug"
- test -z "$striplib" && striplib="$STRIP --strip-unneeded"
- AC_MSG_RESULT([yes])
-else
-# FIXME - insert some real tests, host_os isn't really good enough
- case $host_os in
- darwin*)
- if test -n "$STRIP" ; then
- striplib="$STRIP -x"
- AC_MSG_RESULT([yes])
- else
- AC_MSG_RESULT([no])
-fi
- ;;
- *)
- AC_MSG_RESULT([no])
- ;;
- esac
-fi
-])# AC_LIBTOOL_SYS_LIB_STRIP
-
-
-# AC_LIBTOOL_SYS_DYNAMIC_LINKER
-# -----------------------------
-# PORTME Fill in your ld.so characteristics
-AC_DEFUN([AC_LIBTOOL_SYS_DYNAMIC_LINKER],
-[AC_MSG_CHECKING([dynamic linker characteristics])
-library_names_spec=
-libname_spec='lib$name'
-soname_spec=
-shrext_cmds=".so"
-postinstall_cmds=
-postuninstall_cmds=
-finish_cmds=
-finish_eval=
-shlibpath_var=
-shlibpath_overrides_runpath=unknown
-version_type=none
-dynamic_linker="$host_os ld.so"
-sys_lib_dlsearch_path_spec="/lib /usr/lib"
-if test "$GCC" = yes; then
- sys_lib_search_path_spec=`$CC -print-search-dirs | grep "^libraries:" | $SED -e "s/^libraries://" -e "s,=/,/,g"`
- if echo "$sys_lib_search_path_spec" | grep ';' >/dev/null ; then
- # if the path contains ";" then we assume it to be the separator
- # otherwise default to the standard path separator (i.e. ":") - it is
- # assumed that no part of a normal pathname contains ";" but that should
- # okay in the real world where ";" in dirpaths is itself problematic.
- sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'`
- else
- sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"`
- fi
-else
- sys_lib_search_path_spec="/lib /usr/lib /usr/local/lib"
-fi
-need_lib_prefix=unknown
-hardcode_into_libs=no
-
-# when you set need_version to no, make sure it does not cause -set_version
-# flags to be left without arguments
-need_version=unknown
-
-case $host_os in
-aix3*)
- version_type=linux
- library_names_spec='${libname}${release}${shared_ext}$versuffix $libname.a'
- shlibpath_var=LIBPATH
-
- # AIX 3 has no versioning support, so we append a major version to the name.
- soname_spec='${libname}${release}${shared_ext}$major'
- ;;
-
-aix4* | aix5*)
- version_type=linux
- need_lib_prefix=no
- need_version=no
- hardcode_into_libs=yes
- if test "$host_cpu" = ia64; then
- # AIX 5 supports IA64
- library_names_spec='${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext}$versuffix $libname${shared_ext}'
- shlibpath_var=LD_LIBRARY_PATH
- else
- # With GCC up to 2.95.x, collect2 would create an import file
- # for dependence libraries. The import file would start with
- # the line `#! .'. This would cause the generated library to
- # depend on `.', always an invalid library. This was fixed in
- # development snapshots of GCC prior to 3.0.
- case $host_os in
- aix4 | aix4.[[01]] | aix4.[[01]].*)
- if { echo '#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 97)'
- echo ' yes '
- echo '#endif'; } | ${CC} -E - | grep yes > /dev/null; then
- :
- else
- can_build_shared=no
- fi
- ;;
- esac
- # AIX (on Power*) has no versioning support, so currently we can not hardcode correct
- # soname into executable. Probably we can add versioning support to
- # collect2, so additional links can be useful in future.
- if test "$aix_use_runtimelinking" = yes; then
- # If using run time linking (on AIX 4.2 or later) use lib<name>.so
- # instead of lib<name>.a to let people know that these are not
- # typical AIX shared libraries.
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
- else
- # We preserve .a as extension for shared libraries through AIX4.2
- # and later when we are not doing run time linking.
- library_names_spec='${libname}${release}.a $libname.a'
- soname_spec='${libname}${release}${shared_ext}$major'
- fi
- shlibpath_var=LIBPATH
- fi
- ;;
-
-amigaos*)
- library_names_spec='$libname.ixlibrary $libname.a'
- # Create ${libname}_ixlibrary.a entries in /sys/libs.
- finish_eval='for lib in `ls $libdir/*.ixlibrary 2>/dev/null`; do libname=`$echo "X$lib" | $Xsed -e '\''s%^.*/\([[^/]]*\)\.ixlibrary$%\1%'\''`; test $rm /sys/libs/${libname}_ixlibrary.a; $show "cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a"; cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a || exit 1; done'
- ;;
-
-beos*)
- library_names_spec='${libname}${shared_ext}'
- dynamic_linker="$host_os ld.so"
- shlibpath_var=LIBRARY_PATH
- ;;
-
-bsdi[[45]]*)
- version_type=linux
- need_version=no
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
- soname_spec='${libname}${release}${shared_ext}$major'
- finish_cmds='PATH="\$PATH:/sbin" ldconfig $libdir'
- shlibpath_var=LD_LIBRARY_PATH
- sys_lib_search_path_spec="/shlib /usr/lib /usr/X11/lib /usr/contrib/lib /lib /usr/local/lib"
- sys_lib_dlsearch_path_spec="/shlib /usr/lib /usr/local/lib"
- # the default ld.so.conf also contains /usr/contrib/lib and
- # /usr/X11R6/lib (/usr/X11 is a link to /usr/X11R6), but let us allow
- # libtool to hard-code these into programs
- ;;
-
-cygwin* | mingw* | pw32*)
- version_type=windows
- shrext_cmds=".dll"
- need_version=no
- need_lib_prefix=no
-
- case $GCC,$host_os in
- yes,cygwin* | yes,mingw* | yes,pw32*)
- library_names_spec='$libname.dll.a'
- # DLL is installed to $(libdir)/../bin by postinstall_cmds
- postinstall_cmds='base_file=`basename \${file}`~
- dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i;echo \$dlname'\''`~
- dldir=$destdir/`dirname \$dlpath`~
- test -d \$dldir || mkdir -p \$dldir~
- $install_prog $dir/$dlname \$dldir/$dlname~
- chmod a+x \$dldir/$dlname'
- postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~
- dlpath=$dir/\$dldll~
- $rm \$dlpath'
- shlibpath_overrides_runpath=yes
-
- case $host_os in
- cygwin*)
- # Cygwin DLLs use 'cyg' prefix rather than 'lib'
- soname_spec='`echo ${libname} | sed -e 's/^lib/cyg/'``echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}'
- sys_lib_search_path_spec="/usr/lib /lib/w32api /lib /usr/local/lib"
- ;;
- mingw*)
- # MinGW DLLs use traditional 'lib' prefix
- soname_spec='${libname}`echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}'
- sys_lib_search_path_spec=`$CC -print-search-dirs | grep "^libraries:" | $SED -e "s/^libraries://" -e "s,=/,/,g"`
- if echo "$sys_lib_search_path_spec" | [grep ';[c-zC-Z]:/' >/dev/null]; then
- # It is most probably a Windows format PATH printed by
- # mingw gcc, but we are running on Cygwin. Gcc prints its search
- # path with ; separators, and with drive letters. We can handle the
- # drive letters (cygwin fileutils understands them), so leave them,
- # especially as we might pass files found there to a mingw objdump,
- # which wouldn't understand a cygwinified path. Ahh.
- sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'`
- else
- sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"`
- fi
- ;;
- pw32*)
- # pw32 DLLs use 'pw' prefix rather than 'lib'
- library_names_spec='`echo ${libname} | sed -e 's/^lib/pw/'``echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}'
- ;;
- esac
- ;;
-
- *)
- library_names_spec='${libname}`echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext} $libname.lib'
- ;;
- esac
- dynamic_linker='Win32 ld.exe'
- # FIXME: first we should search . and the directory the executable is in
- shlibpath_var=PATH
- ;;
-
-darwin* | rhapsody*)
- dynamic_linker="$host_os dyld"
- version_type=darwin
- need_lib_prefix=no
- need_version=no
- library_names_spec='${libname}${release}${versuffix}$shared_ext ${libname}${release}${major}$shared_ext ${libname}$shared_ext'
- soname_spec='${libname}${release}${major}$shared_ext'
- shlibpath_overrides_runpath=yes
- shlibpath_var=DYLD_LIBRARY_PATH
- shrext_cmds='`test .$module = .yes && echo .so || echo .dylib`'
- # Apple's gcc prints 'gcc -print-search-dirs' doesn't operate the same.
- if test "$GCC" = yes; then
- sys_lib_search_path_spec=`$CC -print-search-dirs | tr "\n" "$PATH_SEPARATOR" | sed -e 's/libraries:/@libraries:/' | tr "@" "\n" | grep "^libraries:" | sed -e "s/^libraries://" -e "s,=/,/,g" -e "s,$PATH_SEPARATOR, ,g" -e "s,.*,& /lib /usr/lib /usr/local/lib,g"`
- else
- sys_lib_search_path_spec='/lib /usr/lib /usr/local/lib'
- fi
- sys_lib_dlsearch_path_spec='/usr/local/lib /lib /usr/lib'
- ;;
-
-dgux*)
- version_type=linux
- need_lib_prefix=no
- need_version=no
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname$shared_ext'
- soname_spec='${libname}${release}${shared_ext}$major'
- shlibpath_var=LD_LIBRARY_PATH
- ;;
-
-freebsd1*)
- dynamic_linker=no
- ;;
-
-kfreebsd*-gnu)
- version_type=linux
- need_lib_prefix=no
- need_version=no
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
- soname_spec='${libname}${release}${shared_ext}$major'
- shlibpath_var=LD_LIBRARY_PATH
- shlibpath_overrides_runpath=no
- hardcode_into_libs=yes
- dynamic_linker='GNU ld.so'
- ;;
-
-freebsd* | dragonfly*)
- # DragonFly does not have aout. When/if they implement a new
- # versioning mechanism, adjust this.
- if test -x /usr/bin/objformat; then
- objformat=`/usr/bin/objformat`
- else
- case $host_os in
- freebsd[[123]]*) objformat=aout ;;
- *) objformat=elf ;;
- esac
- fi
- version_type=freebsd-$objformat
- case $version_type in
- freebsd-elf*)
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}'
- need_version=no
- need_lib_prefix=no
- ;;
- freebsd-*)
- library_names_spec='${libname}${release}${shared_ext}$versuffix $libname${shared_ext}$versuffix'
- need_version=yes
- ;;
- esac
- shlibpath_var=LD_LIBRARY_PATH
- case $host_os in
- freebsd2*)
- shlibpath_overrides_runpath=yes
- ;;
- freebsd3.[[01]]* | freebsdelf3.[[01]]*)
- shlibpath_overrides_runpath=yes
- hardcode_into_libs=yes
- ;;
- freebsd3.[[2-9]]* | freebsdelf3.[[2-9]]* | \
- freebsd4.[[0-5]] | freebsdelf4.[[0-5]] | freebsd4.1.1 | freebsdelf4.1.1)
- shlibpath_overrides_runpath=no
- hardcode_into_libs=yes
- ;;
- freebsd*) # from 4.6 on
- shlibpath_overrides_runpath=yes
- hardcode_into_libs=yes
- ;;
- esac
- ;;
-
-gnu*)
- version_type=linux
- need_lib_prefix=no
- need_version=no
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}'
- soname_spec='${libname}${release}${shared_ext}$major'
- shlibpath_var=LD_LIBRARY_PATH
- hardcode_into_libs=yes
- ;;
-
-hpux9* | hpux10* | hpux11*)
- # Give a soname corresponding to the major version so that dld.sl refuses to
- # link against other versions.
- version_type=sunos
- need_lib_prefix=no
- need_version=no
- case $host_cpu in
- ia64*)
- shrext_cmds='.so'
- hardcode_into_libs=yes
- dynamic_linker="$host_os dld.so"
- shlibpath_var=LD_LIBRARY_PATH
- shlibpath_overrides_runpath=yes # Unless +noenvvar is specified.
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
- soname_spec='${libname}${release}${shared_ext}$major'
- if test "X$HPUX_IA64_MODE" = X32; then
- sys_lib_search_path_spec="/usr/lib/hpux32 /usr/local/lib/hpux32 /usr/local/lib"
- else
- sys_lib_search_path_spec="/usr/lib/hpux64 /usr/local/lib/hpux64"
- fi
- sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec
- ;;
- hppa*64*)
- shrext_cmds='.sl'
- hardcode_into_libs=yes
- dynamic_linker="$host_os dld.sl"
- shlibpath_var=LD_LIBRARY_PATH # How should we handle SHLIB_PATH
- shlibpath_overrides_runpath=yes # Unless +noenvvar is specified.
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
- soname_spec='${libname}${release}${shared_ext}$major'
- sys_lib_search_path_spec="/usr/lib/pa20_64 /usr/ccs/lib/pa20_64"
- sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec
- ;;
- *)
- shrext_cmds='.sl'
- dynamic_linker="$host_os dld.sl"
- shlibpath_var=SHLIB_PATH
- shlibpath_overrides_runpath=no # +s is required to enable SHLIB_PATH
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
- soname_spec='${libname}${release}${shared_ext}$major'
- ;;
- esac
- # HP-UX runs *really* slowly unless shared libraries are mode 555.
- postinstall_cmds='chmod 555 $lib'
- ;;
-
-interix3*)
- version_type=linux
- need_lib_prefix=no
- need_version=no
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
- soname_spec='${libname}${release}${shared_ext}$major'
- dynamic_linker='Interix 3.x ld.so.1 (PE, like ELF)'
- shlibpath_var=LD_LIBRARY_PATH
- shlibpath_overrides_runpath=no
- hardcode_into_libs=yes
- ;;
-
-irix5* | irix6* | nonstopux*)
- case $host_os in
- nonstopux*) version_type=nonstopux ;;
- *)
- if test "$lt_cv_prog_gnu_ld" = yes; then
- version_type=linux
- else
- version_type=irix
- fi ;;
- esac
- need_lib_prefix=no
- need_version=no
- soname_spec='${libname}${release}${shared_ext}$major'
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext} $libname${shared_ext}'
- case $host_os in
- irix5* | nonstopux*)
- libsuff= shlibsuff=
- ;;
- *)
- case $LD in # libtool.m4 will add one of these switches to LD
- *-32|*"-32 "|*-melf32bsmip|*"-melf32bsmip ")
- libsuff= shlibsuff= libmagic=32-bit;;
- *-n32|*"-n32 "|*-melf32bmipn32|*"-melf32bmipn32 ")
- libsuff=32 shlibsuff=N32 libmagic=N32;;
- *-64|*"-64 "|*-melf64bmip|*"-melf64bmip ")
- libsuff=64 shlibsuff=64 libmagic=64-bit;;
- *) libsuff= shlibsuff= libmagic=never-match;;
- esac
- ;;
- esac
- shlibpath_var=LD_LIBRARY${shlibsuff}_PATH
- shlibpath_overrides_runpath=no
- sys_lib_search_path_spec="/usr/lib${libsuff} /lib${libsuff} /usr/local/lib${libsuff}"
- sys_lib_dlsearch_path_spec="/usr/lib${libsuff} /lib${libsuff}"
- hardcode_into_libs=yes
- ;;
-
-# No shared lib support for Linux oldld, aout, or coff.
-linux*oldld* | linux*aout* | linux*coff*)
- dynamic_linker=no
- ;;
-
-# This must be Linux ELF.
-linux*)
- version_type=linux
- need_lib_prefix=no
- need_version=no
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
- soname_spec='${libname}${release}${shared_ext}$major'
- finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir'
- shlibpath_var=LD_LIBRARY_PATH
- shlibpath_overrides_runpath=no
- # This implies no fast_install, which is unacceptable.
- # Some rework will be needed to allow for fast_install
- # before this can be enabled.
- hardcode_into_libs=yes
-
- # Append ld.so.conf contents to the search path
- if test -f /etc/ld.so.conf; then
- lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s", \[$]2)); skip = 1; } { if (!skip) print \[$]0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;s/[:, ]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;/^$/d' | tr '\n' ' '`
- sys_lib_dlsearch_path_spec="/lib /usr/lib $lt_ld_extra"
- fi
-
- # We used to test for /lib/ld.so.1 and disable shared libraries on
- # powerpc, because MkLinux only supported shared libraries with the
- # GNU dynamic linker. Since this was broken with cross compilers,
- # most powerpc-linux boxes support dynamic linking these days and
- # people can always --disable-shared, the test was removed, and we
- # assume the GNU/Linux dynamic linker is in use.
- dynamic_linker='GNU/Linux ld.so'
- ;;
-
-netbsdelf*-gnu)
- version_type=linux
- need_lib_prefix=no
- need_version=no
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
- soname_spec='${libname}${release}${shared_ext}$major'
- shlibpath_var=LD_LIBRARY_PATH
- shlibpath_overrides_runpath=no
- hardcode_into_libs=yes
- dynamic_linker='NetBSD ld.elf_so'
- ;;
-
-knetbsd*-gnu)
- version_type=linux
- need_lib_prefix=no
- need_version=no
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
- soname_spec='${libname}${release}${shared_ext}$major'
- shlibpath_var=LD_LIBRARY_PATH
- shlibpath_overrides_runpath=no
- hardcode_into_libs=yes
- dynamic_linker='GNU ld.so'
- ;;
-
-netbsd*)
- version_type=sunos
- need_lib_prefix=no
- need_version=no
- if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
- finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir'
- dynamic_linker='NetBSD (a.out) ld.so'
- else
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
- soname_spec='${libname}${release}${shared_ext}$major'
- dynamic_linker='NetBSD ld.elf_so'
- fi
- shlibpath_var=LD_LIBRARY_PATH
- shlibpath_overrides_runpath=yes
- hardcode_into_libs=yes
- ;;
-
-newsos6)
- version_type=linux
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
- shlibpath_var=LD_LIBRARY_PATH
- shlibpath_overrides_runpath=yes
- ;;
-
-nto-qnx*)
- version_type=linux
- need_lib_prefix=no
- need_version=no
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
- soname_spec='${libname}${release}${shared_ext}$major'
- shlibpath_var=LD_LIBRARY_PATH
- shlibpath_overrides_runpath=yes
- ;;
-
-openbsd*)
- version_type=sunos
- sys_lib_dlsearch_path_spec="/usr/lib"
- need_lib_prefix=no
- # Some older versions of OpenBSD (3.3 at least) *do* need versioned libs.
- case $host_os in
- openbsd3.3 | openbsd3.3.*) need_version=yes ;;
- *) need_version=no ;;
- esac
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
- finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir'
- shlibpath_var=LD_LIBRARY_PATH
- if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
- case $host_os in
- openbsd2.[[89]] | openbsd2.[[89]].*)
- shlibpath_overrides_runpath=no
- ;;
- *)
- shlibpath_overrides_runpath=yes
- ;;
- esac
- else
- shlibpath_overrides_runpath=yes
- fi
- ;;
-
-os2*)
- libname_spec='$name'
- shrext_cmds=".dll"
- need_lib_prefix=no
- library_names_spec='$libname${shared_ext} $libname.a'
- dynamic_linker='OS/2 ld.exe'
- shlibpath_var=LIBPATH
- ;;
-
-osf3* | osf4* | osf5*)
- version_type=osf
- need_lib_prefix=no
- need_version=no
- soname_spec='${libname}${release}${shared_ext}$major'
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
- shlibpath_var=LD_LIBRARY_PATH
- sys_lib_search_path_spec="/usr/shlib /usr/ccs/lib /usr/lib/cmplrs/cc /usr/lib /usr/local/lib /var/shlib"
- sys_lib_dlsearch_path_spec="$sys_lib_search_path_spec"
- ;;
-
-solaris*)
- version_type=linux
- need_lib_prefix=no
- need_version=no
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
- soname_spec='${libname}${release}${shared_ext}$major'
- shlibpath_var=LD_LIBRARY_PATH
- shlibpath_overrides_runpath=yes
- hardcode_into_libs=yes
- # ldd complains unless libraries are executable
- postinstall_cmds='chmod +x $lib'
- ;;
-
-sunos4*)
- version_type=sunos
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
- finish_cmds='PATH="\$PATH:/usr/etc" ldconfig $libdir'
- shlibpath_var=LD_LIBRARY_PATH
- shlibpath_overrides_runpath=yes
- if test "$with_gnu_ld" = yes; then
- need_lib_prefix=no
- fi
- need_version=yes
- ;;
-
-sysv4 | sysv4.3*)
- version_type=linux
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
- soname_spec='${libname}${release}${shared_ext}$major'
- shlibpath_var=LD_LIBRARY_PATH
- case $host_vendor in
- sni)
- shlibpath_overrides_runpath=no
- need_lib_prefix=no
- export_dynamic_flag_spec='${wl}-Blargedynsym'
- runpath_var=LD_RUN_PATH
- ;;
- siemens)
- need_lib_prefix=no
- ;;
- motorola)
- need_lib_prefix=no
- need_version=no
- shlibpath_overrides_runpath=no
- sys_lib_search_path_spec='/lib /usr/lib /usr/ccs/lib'
- ;;
- esac
- ;;
-
-sysv4*MP*)
- if test -d /usr/nec ;then
- version_type=linux
- library_names_spec='$libname${shared_ext}.$versuffix $libname${shared_ext}.$major $libname${shared_ext}'
- soname_spec='$libname${shared_ext}.$major'
- shlibpath_var=LD_LIBRARY_PATH
- fi
- ;;
-
-sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*)
- version_type=freebsd-elf
- need_lib_prefix=no
- need_version=no
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}'
- soname_spec='${libname}${release}${shared_ext}$major'
- shlibpath_var=LD_LIBRARY_PATH
- hardcode_into_libs=yes
- if test "$with_gnu_ld" = yes; then
- sys_lib_search_path_spec='/usr/local/lib /usr/gnu/lib /usr/ccs/lib /usr/lib /lib'
- shlibpath_overrides_runpath=no
- else
- sys_lib_search_path_spec='/usr/ccs/lib /usr/lib'
- shlibpath_overrides_runpath=yes
- case $host_os in
- sco3.2v5*)
- sys_lib_search_path_spec="$sys_lib_search_path_spec /lib"
- ;;
- esac
- fi
- sys_lib_dlsearch_path_spec='/usr/lib'
- ;;
-
-uts4*)
- version_type=linux
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
- soname_spec='${libname}${release}${shared_ext}$major'
- shlibpath_var=LD_LIBRARY_PATH
- ;;
-
-*)
- dynamic_linker=no
- ;;
-esac
-AC_MSG_RESULT([$dynamic_linker])
-test "$dynamic_linker" = no && can_build_shared=no
-
-variables_saved_for_relink="PATH $shlibpath_var $runpath_var"
-if test "$GCC" = yes; then
- variables_saved_for_relink="$variables_saved_for_relink GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH"
-fi
-])# AC_LIBTOOL_SYS_DYNAMIC_LINKER
-
-
-# _LT_AC_TAGCONFIG
-# ----------------
-AC_DEFUN([_LT_AC_TAGCONFIG],
-[AC_ARG_WITH([tags],
- [AC_HELP_STRING([--with-tags@<:@=TAGS@:>@],
- [include additional configurations @<:@automatic@:>@])],
- [tagnames="$withval"])
-
-if test -f "$ltmain" && test -n "$tagnames"; then
- if test ! -f "${ofile}"; then
- AC_MSG_WARN([output file `$ofile' does not exist])
- fi
-
- if test -z "$LTCC"; then
- eval "`$SHELL ${ofile} --config | grep '^LTCC='`"
- if test -z "$LTCC"; then
- AC_MSG_WARN([output file `$ofile' does not look like a libtool script])
- else
- AC_MSG_WARN([using `LTCC=$LTCC', extracted from `$ofile'])
- fi
- fi
- if test -z "$LTCFLAGS"; then
- eval "`$SHELL ${ofile} --config | grep '^LTCFLAGS='`"
- fi
-
- # Extract list of available tagged configurations in $ofile.
- # Note that this assumes the entire list is on one line.
- available_tags=`grep "^available_tags=" "${ofile}" | $SED -e 's/available_tags=\(.*$\)/\1/' -e 's/\"//g'`
-
- lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR,"
- for tagname in $tagnames; do
- IFS="$lt_save_ifs"
- # Check whether tagname contains only valid characters
- case `$echo "X$tagname" | $Xsed -e 's:[[-_ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890,/]]::g'` in
- "") ;;
- *) AC_MSG_ERROR([invalid tag name: $tagname])
- ;;
- esac
-
- if grep "^# ### BEGIN LIBTOOL TAG CONFIG: $tagname$" < "${ofile}" > /dev/null
- then
- AC_MSG_ERROR([tag name \"$tagname\" already exists])
- fi
-
- # Update the list of available tags.
- if test -n "$tagname"; then
- echo appending configuration tag \"$tagname\" to $ofile
-
- case $tagname in
- CXX)
- if test -n "$CXX" && ( test "X$CXX" != "Xno" &&
- ( (test "X$CXX" = "Xg++" && `g++ -v >/dev/null 2>&1` ) ||
- (test "X$CXX" != "Xg++"))) ; then
- AC_LIBTOOL_LANG_CXX_CONFIG
- else
- tagname=""
- fi
- ;;
-
- F77)
- if test -n "$F77" && test "X$F77" != "Xno"; then
- AC_LIBTOOL_LANG_F77_CONFIG
- else
- tagname=""
- fi
- ;;
-
- GCJ)
- if test -n "$GCJ" && test "X$GCJ" != "Xno"; then
- AC_LIBTOOL_LANG_GCJ_CONFIG
- else
- tagname=""
- fi
- ;;
-
- RC)
- AC_LIBTOOL_LANG_RC_CONFIG
- ;;
-
- *)
- AC_MSG_ERROR([Unsupported tag name: $tagname])
- ;;
- esac
-
- # Append the new tag name to the list of available tags.
- if test -n "$tagname" ; then
- available_tags="$available_tags $tagname"
- fi
- fi
- done
- IFS="$lt_save_ifs"
-
- # Now substitute the updated list of available tags.
- if eval "sed -e 's/^available_tags=.*\$/available_tags=\"$available_tags\"/' \"$ofile\" > \"${ofile}T\""; then
- mv "${ofile}T" "$ofile"
- chmod +x "$ofile"
- else
- rm -f "${ofile}T"
- AC_MSG_ERROR([unable to update list of available tagged configurations.])
- fi
-fi
-])# _LT_AC_TAGCONFIG
-
-
-# AC_LIBTOOL_DLOPEN
-# -----------------
-# enable checks for dlopen support
-AC_DEFUN([AC_LIBTOOL_DLOPEN],
- [AC_BEFORE([$0],[AC_LIBTOOL_SETUP])
-])# AC_LIBTOOL_DLOPEN
-
-
-# AC_LIBTOOL_WIN32_DLL
-# --------------------
-# declare package support for building win32 DLLs
-AC_DEFUN([AC_LIBTOOL_WIN32_DLL],
-[AC_BEFORE([$0], [AC_LIBTOOL_SETUP])
-])# AC_LIBTOOL_WIN32_DLL
-
-
-# AC_ENABLE_SHARED([DEFAULT])
-# ---------------------------
-# implement the --enable-shared flag
-# DEFAULT is either `yes' or `no'. If omitted, it defaults to `yes'.
-AC_DEFUN([AC_ENABLE_SHARED],
-[define([AC_ENABLE_SHARED_DEFAULT], ifelse($1, no, no, yes))dnl
-AC_ARG_ENABLE([shared],
- [AC_HELP_STRING([--enable-shared@<:@=PKGS@:>@],
- [build shared libraries @<:@default=]AC_ENABLE_SHARED_DEFAULT[@:>@])],
- [p=${PACKAGE-default}
- case $enableval in
- yes) enable_shared=yes ;;
- no) enable_shared=no ;;
- *)
- enable_shared=no
- # Look at the argument we got. We use all the common list separators.
- lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR,"
- for pkg in $enableval; do
- IFS="$lt_save_ifs"
- if test "X$pkg" = "X$p"; then
- enable_shared=yes
- fi
- done
- IFS="$lt_save_ifs"
- ;;
- esac],
- [enable_shared=]AC_ENABLE_SHARED_DEFAULT)
-])# AC_ENABLE_SHARED
-
-
-# AC_DISABLE_SHARED
-# -----------------
-# set the default shared flag to --disable-shared
-AC_DEFUN([AC_DISABLE_SHARED],
-[AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl
-AC_ENABLE_SHARED(no)
-])# AC_DISABLE_SHARED
-
-
-# AC_ENABLE_STATIC([DEFAULT])
-# ---------------------------
-# implement the --enable-static flag
-# DEFAULT is either `yes' or `no'. If omitted, it defaults to `yes'.
-AC_DEFUN([AC_ENABLE_STATIC],
-[define([AC_ENABLE_STATIC_DEFAULT], ifelse($1, no, no, yes))dnl
-AC_ARG_ENABLE([static],
- [AC_HELP_STRING([--enable-static@<:@=PKGS@:>@],
- [build static libraries @<:@default=]AC_ENABLE_STATIC_DEFAULT[@:>@])],
- [p=${PACKAGE-default}
- case $enableval in
- yes) enable_static=yes ;;
- no) enable_static=no ;;
- *)
- enable_static=no
- # Look at the argument we got. We use all the common list separators.
- lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR,"
- for pkg in $enableval; do
- IFS="$lt_save_ifs"
- if test "X$pkg" = "X$p"; then
- enable_static=yes
- fi
- done
- IFS="$lt_save_ifs"
- ;;
- esac],
- [enable_static=]AC_ENABLE_STATIC_DEFAULT)
-])# AC_ENABLE_STATIC
-
-
-# AC_DISABLE_STATIC
-# -----------------
-# set the default static flag to --disable-static
-AC_DEFUN([AC_DISABLE_STATIC],
-[AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl
-AC_ENABLE_STATIC(no)
-])# AC_DISABLE_STATIC
-
-
-# AC_ENABLE_FAST_INSTALL([DEFAULT])
-# ---------------------------------
-# implement the --enable-fast-install flag
-# DEFAULT is either `yes' or `no'. If omitted, it defaults to `yes'.
-AC_DEFUN([AC_ENABLE_FAST_INSTALL],
-[define([AC_ENABLE_FAST_INSTALL_DEFAULT], ifelse($1, no, no, yes))dnl
-AC_ARG_ENABLE([fast-install],
- [AC_HELP_STRING([--enable-fast-install@<:@=PKGS@:>@],
- [optimize for fast installation @<:@default=]AC_ENABLE_FAST_INSTALL_DEFAULT[@:>@])],
- [p=${PACKAGE-default}
- case $enableval in
- yes) enable_fast_install=yes ;;
- no) enable_fast_install=no ;;
- *)
- enable_fast_install=no
- # Look at the argument we got. We use all the common list separators.
- lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR,"
- for pkg in $enableval; do
- IFS="$lt_save_ifs"
- if test "X$pkg" = "X$p"; then
- enable_fast_install=yes
- fi
- done
- IFS="$lt_save_ifs"
- ;;
- esac],
- [enable_fast_install=]AC_ENABLE_FAST_INSTALL_DEFAULT)
-])# AC_ENABLE_FAST_INSTALL
-
-
-# AC_DISABLE_FAST_INSTALL
-# -----------------------
-# set the default to --disable-fast-install
-AC_DEFUN([AC_DISABLE_FAST_INSTALL],
-[AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl
-AC_ENABLE_FAST_INSTALL(no)
-])# AC_DISABLE_FAST_INSTALL
-
-
-# AC_LIBTOOL_PICMODE([MODE])
-# --------------------------
-# implement the --with-pic flag
-# MODE is either `yes' or `no'. If omitted, it defaults to `both'.
-AC_DEFUN([AC_LIBTOOL_PICMODE],
-[AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl
-pic_mode=ifelse($#,1,$1,default)
-])# AC_LIBTOOL_PICMODE
-
-
-# AC_PROG_EGREP
-# -------------
-# This is predefined starting with Autoconf 2.54, so this conditional
-# definition can be removed once we require Autoconf 2.54 or later.
-m4_ifndef([AC_PROG_EGREP], [AC_DEFUN([AC_PROG_EGREP],
-[AC_CACHE_CHECK([for egrep], [ac_cv_prog_egrep],
- [if echo a | (grep -E '(a|b)') >/dev/null 2>&1
- then ac_cv_prog_egrep='grep -E'
- else ac_cv_prog_egrep='egrep'
- fi])
- EGREP=$ac_cv_prog_egrep
- AC_SUBST([EGREP])
-])])
-
-
-# AC_PATH_TOOL_PREFIX
-# -------------------
-# find a file program which can recognise shared library
-AC_DEFUN([AC_PATH_TOOL_PREFIX],
-[AC_REQUIRE([AC_PROG_EGREP])dnl
-AC_MSG_CHECKING([for $1])
-AC_CACHE_VAL(lt_cv_path_MAGIC_CMD,
-[case $MAGIC_CMD in
-[[\\/*] | ?:[\\/]*])
- lt_cv_path_MAGIC_CMD="$MAGIC_CMD" # Let the user override the test with a path.
- ;;
-*)
- lt_save_MAGIC_CMD="$MAGIC_CMD"
- lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
-dnl $ac_dummy forces splitting on constant user-supplied paths.
-dnl POSIX.2 word splitting is done only on the output of word expansions,
-dnl not every word. This closes a longstanding sh security hole.
- ac_dummy="ifelse([$2], , $PATH, [$2])"
- for ac_dir in $ac_dummy; do
- IFS="$lt_save_ifs"
- test -z "$ac_dir" && ac_dir=.
- if test -f $ac_dir/$1; then
- lt_cv_path_MAGIC_CMD="$ac_dir/$1"
- if test -n "$file_magic_test_file"; then
- case $deplibs_check_method in
- "file_magic "*)
- file_magic_regex=`expr "$deplibs_check_method" : "file_magic \(.*\)"`
- MAGIC_CMD="$lt_cv_path_MAGIC_CMD"
- if eval $file_magic_cmd \$file_magic_test_file 2> /dev/null |
- $EGREP "$file_magic_regex" > /dev/null; then
- :
- else
- cat <<EOF 1>&2
-
-*** Warning: the command libtool uses to detect shared libraries,
-*** $file_magic_cmd, produces output that libtool cannot recognize.
-*** The result is that libtool may fail to recognize shared libraries
-*** as such. This will affect the creation of libtool libraries that
-*** depend on shared libraries, but programs linked with such libtool
-*** libraries will work regardless of this problem. Nevertheless, you
-*** may want to report the problem to your system manager and/or to
-*** bug-libtool@gnu.org
-
-EOF
- fi ;;
- esac
- fi
- break
- fi
- done
- IFS="$lt_save_ifs"
- MAGIC_CMD="$lt_save_MAGIC_CMD"
- ;;
-esac])
-MAGIC_CMD="$lt_cv_path_MAGIC_CMD"
-if test -n "$MAGIC_CMD"; then
- AC_MSG_RESULT($MAGIC_CMD)
-else
- AC_MSG_RESULT(no)
-fi
-])# AC_PATH_TOOL_PREFIX
-
-
-# AC_PATH_MAGIC
-# -------------
-# find a file program which can recognise a shared library
-AC_DEFUN([AC_PATH_MAGIC],
-[AC_PATH_TOOL_PREFIX(${ac_tool_prefix}file, /usr/bin$PATH_SEPARATOR$PATH)
-if test -z "$lt_cv_path_MAGIC_CMD"; then
- if test -n "$ac_tool_prefix"; then
- AC_PATH_TOOL_PREFIX(file, /usr/bin$PATH_SEPARATOR$PATH)
- else
- MAGIC_CMD=:
- fi
-fi
-])# AC_PATH_MAGIC
-
-
-# AC_PROG_LD
-# ----------
-# find the pathname to the GNU or non-GNU linker
-AC_DEFUN([AC_PROG_LD],
-[AC_ARG_WITH([gnu-ld],
- [AC_HELP_STRING([--with-gnu-ld],
- [assume the C compiler uses GNU ld @<:@default=no@:>@])],
- [test "$withval" = no || with_gnu_ld=yes],
- [with_gnu_ld=no])
-AC_REQUIRE([LT_AC_PROG_SED])dnl
-AC_REQUIRE([AC_PROG_CC])dnl
-AC_REQUIRE([AC_CANONICAL_HOST])dnl
-AC_REQUIRE([AC_CANONICAL_BUILD])dnl
-ac_prog=ld
-if test "$GCC" = yes; then
- # Check if gcc -print-prog-name=ld gives a path.
- AC_MSG_CHECKING([for ld used by $CC])
- case $host in
- *-*-mingw*)
- # gcc leaves a trailing carriage return which upsets mingw
- ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;;
- *)
- ac_prog=`($CC -print-prog-name=ld) 2>&5` ;;
- esac
- case $ac_prog in
- # Accept absolute paths.
- [[\\/]]* | ?:[[\\/]]*)
- re_direlt='/[[^/]][[^/]]*/\.\./'
- # Canonicalize the pathname of ld
- ac_prog=`echo $ac_prog| $SED 's%\\\\%/%g'`
- while echo $ac_prog | grep "$re_direlt" > /dev/null 2>&1; do
- ac_prog=`echo $ac_prog| $SED "s%$re_direlt%/%"`
- done
- test -z "$LD" && LD="$ac_prog"
- ;;
- "")
- # If it fails, then pretend we aren't using GCC.
- ac_prog=ld
- ;;
- *)
- # If it is relative, then search for the first ld in PATH.
- with_gnu_ld=unknown
- ;;
- esac
-elif test "$with_gnu_ld" = yes; then
- AC_MSG_CHECKING([for GNU ld])
-else
- AC_MSG_CHECKING([for non-GNU ld])
-fi
-AC_CACHE_VAL(lt_cv_path_LD,
-[if test -z "$LD"; then
- lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
- for ac_dir in $PATH; do
- IFS="$lt_save_ifs"
- test -z "$ac_dir" && ac_dir=.
- if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then
- lt_cv_path_LD="$ac_dir/$ac_prog"
- # Check to see if the program is GNU ld. I'd rather use --version,
- # but apparently some variants of GNU ld only accept -v.
- # Break only if it was the GNU/non-GNU ld that we prefer.
- case `"$lt_cv_path_LD" -v 2>&1 </dev/null` in
- *GNU* | *'with BFD'*)
- test "$with_gnu_ld" != no && break
- ;;
- *)
- test "$with_gnu_ld" != yes && break
- ;;
- esac
- fi
- done
- IFS="$lt_save_ifs"
-else
- lt_cv_path_LD="$LD" # Let the user override the test with a path.
-fi])
-LD="$lt_cv_path_LD"
-if test -n "$LD"; then
- AC_MSG_RESULT($LD)
-else
- AC_MSG_RESULT(no)
-fi
-test -z "$LD" && AC_MSG_ERROR([no acceptable ld found in \$PATH])
-AC_PROG_LD_GNU
-])# AC_PROG_LD
-
-
-# AC_PROG_LD_GNU
-# --------------
-AC_DEFUN([AC_PROG_LD_GNU],
-[AC_REQUIRE([AC_PROG_EGREP])dnl
-AC_CACHE_CHECK([if the linker ($LD) is GNU ld], lt_cv_prog_gnu_ld,
-[# I'd rather use --version here, but apparently some GNU lds only accept -v.
-case `$LD -v 2>&1 </dev/null` in
-*GNU* | *'with BFD'*)
- lt_cv_prog_gnu_ld=yes
- ;;
-*)
- lt_cv_prog_gnu_ld=no
- ;;
-esac])
-with_gnu_ld=$lt_cv_prog_gnu_ld
-])# AC_PROG_LD_GNU
-
-
-# AC_PROG_LD_RELOAD_FLAG
-# ----------------------
-# find reload flag for linker
-# -- PORTME Some linkers may need a different reload flag.
-AC_DEFUN([AC_PROG_LD_RELOAD_FLAG],
-[AC_CACHE_CHECK([for $LD option to reload object files],
- lt_cv_ld_reload_flag,
- [lt_cv_ld_reload_flag='-r'])
-reload_flag=$lt_cv_ld_reload_flag
-case $reload_flag in
-"" | " "*) ;;
-*) reload_flag=" $reload_flag" ;;
-esac
-reload_cmds='$LD$reload_flag -o $output$reload_objs'
-case $host_os in
- darwin*)
- if test "$GCC" = yes; then
- reload_cmds='$LTCC $LTCFLAGS -nostdlib ${wl}-r -o $output$reload_objs'
- else
- reload_cmds='$LD$reload_flag -o $output$reload_objs'
- fi
- ;;
-esac
-])# AC_PROG_LD_RELOAD_FLAG
-
-
-# AC_DEPLIBS_CHECK_METHOD
-# -----------------------
-# how to check for library dependencies
-# -- PORTME fill in with the dynamic library characteristics
-AC_DEFUN([AC_DEPLIBS_CHECK_METHOD],
-[AC_CACHE_CHECK([how to recognise dependent libraries],
-lt_cv_deplibs_check_method,
-[lt_cv_file_magic_cmd='$MAGIC_CMD'
-lt_cv_file_magic_test_file=
-lt_cv_deplibs_check_method='unknown'
-# Need to set the preceding variable on all platforms that support
-# interlibrary dependencies.
-# 'none' -- dependencies not supported.
-# `unknown' -- same as none, but documents that we really don't know.
-# 'pass_all' -- all dependencies passed with no checks.
-# 'test_compile' -- check by making test program.
-# 'file_magic [[regex]]' -- check by looking for files in library path
-# which responds to the $file_magic_cmd with a given extended regex.
-# If you have `file' or equivalent on your system and you're not sure
-# whether `pass_all' will *always* work, you probably want this one.
-
-case $host_os in
-aix4* | aix5*)
- lt_cv_deplibs_check_method=pass_all
- ;;
-
-beos*)
- lt_cv_deplibs_check_method=pass_all
- ;;
-
-bsdi[[45]]*)
- lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[ML]]SB (shared object|dynamic lib)'
- lt_cv_file_magic_cmd='/usr/bin/file -L'
- lt_cv_file_magic_test_file=/shlib/libc.so
- ;;
-
-cygwin*)
- # func_win32_libid is a shell function defined in ltmain.sh
- lt_cv_deplibs_check_method='file_magic ^x86 archive import|^x86 DLL'
- lt_cv_file_magic_cmd='func_win32_libid'
- ;;
-
-mingw* | pw32*)
- # Base MSYS/MinGW do not provide the 'file' command needed by
- # func_win32_libid shell function, so use a weaker test based on 'objdump'.
- lt_cv_deplibs_check_method='file_magic file format pei*-i386(.*architecture: i386)?'
- lt_cv_file_magic_cmd='$OBJDUMP -f'
- ;;
-
-darwin* | rhapsody*)
- lt_cv_deplibs_check_method=pass_all
- ;;
-
-freebsd* | kfreebsd*-gnu | dragonfly*)
- if echo __ELF__ | $CC -E - | grep __ELF__ > /dev/null; then
- case $host_cpu in
- i*86 )
- # Not sure whether the presence of OpenBSD here was a mistake.
- # Let's accept both of them until this is cleared up.
- lt_cv_deplibs_check_method='file_magic (FreeBSD|OpenBSD|DragonFly)/i[[3-9]]86 (compact )?demand paged shared library'
- lt_cv_file_magic_cmd=/usr/bin/file
- lt_cv_file_magic_test_file=`echo /usr/lib/libc.so.*`
- ;;
- esac
- else
- lt_cv_deplibs_check_method=pass_all
- fi
- ;;
-
-gnu*)
- lt_cv_deplibs_check_method=pass_all
- ;;
-
-hpux10.20* | hpux11*)
- lt_cv_file_magic_cmd=/usr/bin/file
- case $host_cpu in
- ia64*)
- lt_cv_deplibs_check_method='file_magic (s[[0-9]][[0-9]][[0-9]]|ELF-[[0-9]][[0-9]]) shared object file - IA64'
- lt_cv_file_magic_test_file=/usr/lib/hpux32/libc.so
- ;;
- hppa*64*)
- [lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|ELF-[0-9][0-9]) shared object file - PA-RISC [0-9].[0-9]']
- lt_cv_file_magic_test_file=/usr/lib/pa20_64/libc.sl
- ;;
- *)
- lt_cv_deplibs_check_method='file_magic (s[[0-9]][[0-9]][[0-9]]|PA-RISC[[0-9]].[[0-9]]) shared library'
- lt_cv_file_magic_test_file=/usr/lib/libc.sl
- ;;
- esac
- ;;
-
-interix3*)
- # PIC code is broken on Interix 3.x, that's why |\.a not |_pic\.a here
- lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so|\.a)$'
- ;;
-
-irix5* | irix6* | nonstopux*)
- case $LD in
- *-32|*"-32 ") libmagic=32-bit;;
- *-n32|*"-n32 ") libmagic=N32;;
- *-64|*"-64 ") libmagic=64-bit;;
- *) libmagic=never-match;;
- esac
- lt_cv_deplibs_check_method=pass_all
- ;;
-
-# This must be Linux ELF.
-linux*)
- lt_cv_deplibs_check_method=pass_all
- ;;
-
-netbsd* | netbsdelf*-gnu | knetbsd*-gnu)
- if echo __ELF__ | $CC -E - | grep __ELF__ > /dev/null; then
- lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so\.[[0-9]]+\.[[0-9]]+|_pic\.a)$'
- else
- lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so|_pic\.a)$'
- fi
- ;;
-
-newos6*)
- lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[ML]]SB (executable|dynamic lib)'
- lt_cv_file_magic_cmd=/usr/bin/file
- lt_cv_file_magic_test_file=/usr/lib/libnls.so
- ;;
-
-nto-qnx*)
- lt_cv_deplibs_check_method=unknown
- ;;
-
-openbsd*)
- if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
- lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so\.[[0-9]]+\.[[0-9]]+|\.so|_pic\.a)$'
- else
- lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so\.[[0-9]]+\.[[0-9]]+|_pic\.a)$'
- fi
- ;;
-
-osf3* | osf4* | osf5*)
- lt_cv_deplibs_check_method=pass_all
- ;;
-
-solaris*)
- lt_cv_deplibs_check_method=pass_all
- ;;
-
-sysv4 | sysv4.3*)
- case $host_vendor in
- motorola)
- lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[ML]]SB (shared object|dynamic lib) M[[0-9]][[0-9]]* Version [[0-9]]'
- lt_cv_file_magic_test_file=`echo /usr/lib/libc.so*`
- ;;
- ncr)
- lt_cv_deplibs_check_method=pass_all
- ;;
- sequent)
- lt_cv_file_magic_cmd='/bin/file'
- lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[LM]]SB (shared object|dynamic lib )'
- ;;
- sni)
- lt_cv_file_magic_cmd='/bin/file'
- lt_cv_deplibs_check_method="file_magic ELF [[0-9]][[0-9]]*-bit [[LM]]SB dynamic lib"
- lt_cv_file_magic_test_file=/lib/libc.so
- ;;
- siemens)
- lt_cv_deplibs_check_method=pass_all
- ;;
- pc)
- lt_cv_deplibs_check_method=pass_all
- ;;
- esac
- ;;
-
-sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*)
- lt_cv_deplibs_check_method=pass_all
- ;;
-esac
-])
-file_magic_cmd=$lt_cv_file_magic_cmd
-deplibs_check_method=$lt_cv_deplibs_check_method
-test -z "$deplibs_check_method" && deplibs_check_method=unknown
-])# AC_DEPLIBS_CHECK_METHOD
-
-
-# AC_PROG_NM
-# ----------
-# find the pathname to a BSD-compatible name lister
-AC_DEFUN([AC_PROG_NM],
-[AC_CACHE_CHECK([for BSD-compatible nm], lt_cv_path_NM,
-[if test -n "$NM"; then
- # Let the user override the test.
- lt_cv_path_NM="$NM"
-else
- lt_nm_to_check="${ac_tool_prefix}nm"
- if test -n "$ac_tool_prefix" && test "$build" = "$host"; then
- lt_nm_to_check="$lt_nm_to_check nm"
- fi
- for lt_tmp_nm in $lt_nm_to_check; do
- lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
- for ac_dir in $PATH /usr/ccs/bin/elf /usr/ccs/bin /usr/ucb /bin; do
- IFS="$lt_save_ifs"
- test -z "$ac_dir" && ac_dir=.
- tmp_nm="$ac_dir/$lt_tmp_nm"
- if test -f "$tmp_nm" || test -f "$tmp_nm$ac_exeext" ; then
- # Check to see if the nm accepts a BSD-compat flag.
- # Adding the `sed 1q' prevents false positives on HP-UX, which says:
- # nm: unknown option "B" ignored
- # Tru64's nm complains that /dev/null is an invalid object file
- case `"$tmp_nm" -B /dev/null 2>&1 | sed '1q'` in
- */dev/null* | *'Invalid file or object type'*)
- lt_cv_path_NM="$tmp_nm -B"
- break
- ;;
- *)
- case `"$tmp_nm" -p /dev/null 2>&1 | sed '1q'` in
- */dev/null*)
- lt_cv_path_NM="$tmp_nm -p"
- break
- ;;
- *)
- lt_cv_path_NM=${lt_cv_path_NM="$tmp_nm"} # keep the first match, but
- continue # so that we can try to find one that supports BSD flags
- ;;
- esac
- ;;
- esac
- fi
- done
- IFS="$lt_save_ifs"
- done
- test -z "$lt_cv_path_NM" && lt_cv_path_NM=nm
-fi])
-NM="$lt_cv_path_NM"
-])# AC_PROG_NM
-
-
-# AC_CHECK_LIBM
-# -------------
-# check for math library
-AC_DEFUN([AC_CHECK_LIBM],
-[AC_REQUIRE([AC_CANONICAL_HOST])dnl
-LIBM=
-case $host in
-*-*-beos* | *-*-cygwin* | *-*-pw32* | *-*-darwin*)
- # These system don't have libm, or don't need it
- ;;
-*-ncr-sysv4.3*)
- AC_CHECK_LIB(mw, _mwvalidcheckl, LIBM="-lmw")
- AC_CHECK_LIB(m, cos, LIBM="$LIBM -lm")
- ;;
-*)
- AC_CHECK_LIB(m, cos, LIBM="-lm")
- ;;
-esac
-])# AC_CHECK_LIBM
-
-
-# AC_LIBLTDL_CONVENIENCE([DIRECTORY])
-# -----------------------------------
-# sets LIBLTDL to the link flags for the libltdl convenience library and
-# LTDLINCL to the include flags for the libltdl header and adds
-# --enable-ltdl-convenience to the configure arguments. Note that
-# AC_CONFIG_SUBDIRS is not called here. If DIRECTORY is not provided,
-# it is assumed to be `libltdl'. LIBLTDL will be prefixed with
-# '${top_builddir}/' and LTDLINCL will be prefixed with '${top_srcdir}/'
-# (note the single quotes!). If your package is not flat and you're not
-# using automake, define top_builddir and top_srcdir appropriately in
-# the Makefiles.
-AC_DEFUN([AC_LIBLTDL_CONVENIENCE],
-[AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl
- case $enable_ltdl_convenience in
- no) AC_MSG_ERROR([this package needs a convenience libltdl]) ;;
- "") enable_ltdl_convenience=yes
- ac_configure_args="$ac_configure_args --enable-ltdl-convenience" ;;
- esac
- LIBLTDL='${top_builddir}/'ifelse($#,1,[$1],['libltdl'])/libltdlc.la
- LTDLINCL='-I${top_srcdir}/'ifelse($#,1,[$1],['libltdl'])
- # For backwards non-gettext consistent compatibility...
- INCLTDL="$LTDLINCL"
-])# AC_LIBLTDL_CONVENIENCE
-
-
-# AC_LIBLTDL_INSTALLABLE([DIRECTORY])
-# -----------------------------------
-# sets LIBLTDL to the link flags for the libltdl installable library and
-# LTDLINCL to the include flags for the libltdl header and adds
-# --enable-ltdl-install to the configure arguments. Note that
-# AC_CONFIG_SUBDIRS is not called here. If DIRECTORY is not provided,
-# and an installed libltdl is not found, it is assumed to be `libltdl'.
-# LIBLTDL will be prefixed with '${top_builddir}/'# and LTDLINCL with
-# '${top_srcdir}/' (note the single quotes!). If your package is not
-# flat and you're not using automake, define top_builddir and top_srcdir
-# appropriately in the Makefiles.
-# In the future, this macro may have to be called after AC_PROG_LIBTOOL.
-AC_DEFUN([AC_LIBLTDL_INSTALLABLE],
-[AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl
- AC_CHECK_LIB(ltdl, lt_dlinit,
- [test x"$enable_ltdl_install" != xyes && enable_ltdl_install=no],
- [if test x"$enable_ltdl_install" = xno; then
- AC_MSG_WARN([libltdl not installed, but installation disabled])
- else
- enable_ltdl_install=yes
- fi
- ])
- if test x"$enable_ltdl_install" = x"yes"; then
- ac_configure_args="$ac_configure_args --enable-ltdl-install"
- LIBLTDL='${top_builddir}/'ifelse($#,1,[$1],['libltdl'])/libltdl.la
- LTDLINCL='-I${top_srcdir}/'ifelse($#,1,[$1],['libltdl'])
- else
- ac_configure_args="$ac_configure_args --enable-ltdl-install=no"
- LIBLTDL="-lltdl"
- LTDLINCL=
- fi
- # For backwards non-gettext consistent compatibility...
- INCLTDL="$LTDLINCL"
-])# AC_LIBLTDL_INSTALLABLE
-
-
-# AC_LIBTOOL_CXX
-# --------------
-# enable support for C++ libraries
-AC_DEFUN([AC_LIBTOOL_CXX],
-[AC_REQUIRE([_LT_AC_LANG_CXX])
-])# AC_LIBTOOL_CXX
-
-
-# _LT_AC_LANG_CXX
-# ---------------
-AC_DEFUN([_LT_AC_LANG_CXX],
-[AC_REQUIRE([AC_PROG_CXX])
-AC_REQUIRE([_LT_AC_PROG_CXXCPP])
-_LT_AC_SHELL_INIT([tagnames=${tagnames+${tagnames},}CXX])
-])# _LT_AC_LANG_CXX
-
-# _LT_AC_PROG_CXXCPP
-# ------------------
-AC_DEFUN([_LT_AC_PROG_CXXCPP],
-[
-AC_REQUIRE([AC_PROG_CXX])
-if test -n "$CXX" && ( test "X$CXX" != "Xno" &&
- ( (test "X$CXX" = "Xg++" && `g++ -v >/dev/null 2>&1` ) ||
- (test "X$CXX" != "Xg++"))) ; then
- AC_PROG_CXXCPP
-fi
-])# _LT_AC_PROG_CXXCPP
-
-# AC_LIBTOOL_F77
-# --------------
-# enable support for Fortran 77 libraries
-AC_DEFUN([AC_LIBTOOL_F77],
-[AC_REQUIRE([_LT_AC_LANG_F77])
-])# AC_LIBTOOL_F77
-
-
-# _LT_AC_LANG_F77
-# ---------------
-AC_DEFUN([_LT_AC_LANG_F77],
-[AC_REQUIRE([AC_PROG_F77])
-_LT_AC_SHELL_INIT([tagnames=${tagnames+${tagnames},}F77])
-])# _LT_AC_LANG_F77
-
-
-# AC_LIBTOOL_GCJ
-# --------------
-# enable support for GCJ libraries
-AC_DEFUN([AC_LIBTOOL_GCJ],
-[AC_REQUIRE([_LT_AC_LANG_GCJ])
-])# AC_LIBTOOL_GCJ
-
-
-# _LT_AC_LANG_GCJ
-# ---------------
-AC_DEFUN([_LT_AC_LANG_GCJ],
-[AC_PROVIDE_IFELSE([AC_PROG_GCJ],[],
- [AC_PROVIDE_IFELSE([A][M_PROG_GCJ],[],
- [AC_PROVIDE_IFELSE([LT_AC_PROG_GCJ],[],
- [ifdef([AC_PROG_GCJ],[AC_REQUIRE([AC_PROG_GCJ])],
- [ifdef([A][M_PROG_GCJ],[AC_REQUIRE([A][M_PROG_GCJ])],
- [AC_REQUIRE([A][C_PROG_GCJ_OR_A][M_PROG_GCJ])])])])])])
-_LT_AC_SHELL_INIT([tagnames=${tagnames+${tagnames},}GCJ])
-])# _LT_AC_LANG_GCJ
-
-
-# AC_LIBTOOL_RC
-# -------------
-# enable support for Windows resource files
-AC_DEFUN([AC_LIBTOOL_RC],
-[AC_REQUIRE([LT_AC_PROG_RC])
-_LT_AC_SHELL_INIT([tagnames=${tagnames+${tagnames},}RC])
-])# AC_LIBTOOL_RC
-
-
-# AC_LIBTOOL_LANG_C_CONFIG
-# ------------------------
-# Ensure that the configuration vars for the C compiler are
-# suitably defined. Those variables are subsequently used by
-# AC_LIBTOOL_CONFIG to write the compiler configuration to `libtool'.
-AC_DEFUN([AC_LIBTOOL_LANG_C_CONFIG], [_LT_AC_LANG_C_CONFIG])
-AC_DEFUN([_LT_AC_LANG_C_CONFIG],
-[lt_save_CC="$CC"
-AC_LANG_PUSH(C)
-
-# Source file extension for C test sources.
-ac_ext=c
-
-# Object file extension for compiled C test sources.
-objext=o
-_LT_AC_TAGVAR(objext, $1)=$objext
-
-# Code to be used in simple compile tests
-lt_simple_compile_test_code="int some_variable = 0;\n"
-
-# Code to be used in simple link tests
-lt_simple_link_test_code='int main(){return(0);}\n'
-
-_LT_AC_SYS_COMPILER
-
-# save warnings/boilerplate of simple test code
-_LT_COMPILER_BOILERPLATE
-_LT_LINKER_BOILERPLATE
-
-AC_LIBTOOL_PROG_COMPILER_NO_RTTI($1)
-AC_LIBTOOL_PROG_COMPILER_PIC($1)
-AC_LIBTOOL_PROG_CC_C_O($1)
-AC_LIBTOOL_SYS_HARD_LINK_LOCKS($1)
-AC_LIBTOOL_PROG_LD_SHLIBS($1)
-AC_LIBTOOL_SYS_DYNAMIC_LINKER($1)
-AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH($1)
-AC_LIBTOOL_SYS_LIB_STRIP
-AC_LIBTOOL_DLOPEN_SELF
-
-# Report which library types will actually be built
-AC_MSG_CHECKING([if libtool supports shared libraries])
-AC_MSG_RESULT([$can_build_shared])
-
-AC_MSG_CHECKING([whether to build shared libraries])
-test "$can_build_shared" = "no" && enable_shared=no
-
-# On AIX, shared libraries and static libraries use the same namespace, and
-# are all built from PIC.
-case $host_os in
-aix3*)
- test "$enable_shared" = yes && enable_static=no
- if test -n "$RANLIB"; then
- archive_cmds="$archive_cmds~\$RANLIB \$lib"
- postinstall_cmds='$RANLIB $lib'
- fi
- ;;
-
-aix4* | aix5*)
- if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then
- test "$enable_shared" = yes && enable_static=no
- fi
- ;;
-esac
-AC_MSG_RESULT([$enable_shared])
-
-AC_MSG_CHECKING([whether to build static libraries])
-# Make sure either enable_shared or enable_static is yes.
-test "$enable_shared" = yes || enable_static=yes
-AC_MSG_RESULT([$enable_static])
-
-AC_LIBTOOL_CONFIG($1)
-
-AC_LANG_POP
-CC="$lt_save_CC"
-])# AC_LIBTOOL_LANG_C_CONFIG
-
-
-# AC_LIBTOOL_LANG_CXX_CONFIG
-# --------------------------
-# Ensure that the configuration vars for the C compiler are
-# suitably defined. Those variables are subsequently used by
-# AC_LIBTOOL_CONFIG to write the compiler configuration to `libtool'.
-AC_DEFUN([AC_LIBTOOL_LANG_CXX_CONFIG], [_LT_AC_LANG_CXX_CONFIG(CXX)])
-AC_DEFUN([_LT_AC_LANG_CXX_CONFIG],
-[AC_LANG_PUSH(C++)
-AC_REQUIRE([AC_PROG_CXX])
-AC_REQUIRE([_LT_AC_PROG_CXXCPP])
-
-_LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no
-_LT_AC_TAGVAR(allow_undefined_flag, $1)=
-_LT_AC_TAGVAR(always_export_symbols, $1)=no
-_LT_AC_TAGVAR(archive_expsym_cmds, $1)=
-_LT_AC_TAGVAR(export_dynamic_flag_spec, $1)=
-_LT_AC_TAGVAR(hardcode_direct, $1)=no
-_LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)=
-_LT_AC_TAGVAR(hardcode_libdir_flag_spec_ld, $1)=
-_LT_AC_TAGVAR(hardcode_libdir_separator, $1)=
-_LT_AC_TAGVAR(hardcode_minus_L, $1)=no
-_LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=unsupported
-_LT_AC_TAGVAR(hardcode_automatic, $1)=no
-_LT_AC_TAGVAR(module_cmds, $1)=
-_LT_AC_TAGVAR(module_expsym_cmds, $1)=
-_LT_AC_TAGVAR(link_all_deplibs, $1)=unknown
-_LT_AC_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds
-_LT_AC_TAGVAR(no_undefined_flag, $1)=
-_LT_AC_TAGVAR(whole_archive_flag_spec, $1)=
-_LT_AC_TAGVAR(enable_shared_with_static_runtimes, $1)=no
-
-# Dependencies to place before and after the object being linked:
-_LT_AC_TAGVAR(predep_objects, $1)=
-_LT_AC_TAGVAR(postdep_objects, $1)=
-_LT_AC_TAGVAR(predeps, $1)=
-_LT_AC_TAGVAR(postdeps, $1)=
-_LT_AC_TAGVAR(compiler_lib_search_path, $1)=
-
-# Source file extension for C++ test sources.
-ac_ext=cpp
-
-# Object file extension for compiled C++ test sources.
-objext=o
-_LT_AC_TAGVAR(objext, $1)=$objext
-
-# Code to be used in simple compile tests
-lt_simple_compile_test_code="int some_variable = 0;\n"
-
-# Code to be used in simple link tests
-lt_simple_link_test_code='int main(int, char *[[]]) { return(0); }\n'
-
-# ltmain only uses $CC for tagged configurations so make sure $CC is set.
-_LT_AC_SYS_COMPILER
-
-# save warnings/boilerplate of simple test code
-_LT_COMPILER_BOILERPLATE
-_LT_LINKER_BOILERPLATE
-
-# Allow CC to be a program name with arguments.
-lt_save_CC=$CC
-lt_save_LD=$LD
-lt_save_GCC=$GCC
-GCC=$GXX
-lt_save_with_gnu_ld=$with_gnu_ld
-lt_save_path_LD=$lt_cv_path_LD
-if test -n "${lt_cv_prog_gnu_ldcxx+set}"; then
- lt_cv_prog_gnu_ld=$lt_cv_prog_gnu_ldcxx
-else
- $as_unset lt_cv_prog_gnu_ld
-fi
-if test -n "${lt_cv_path_LDCXX+set}"; then
- lt_cv_path_LD=$lt_cv_path_LDCXX
-else
- $as_unset lt_cv_path_LD
-fi
-test -z "${LDCXX+set}" || LD=$LDCXX
-CC=${CXX-"c++"}
-compiler=$CC
-_LT_AC_TAGVAR(compiler, $1)=$CC
-_LT_CC_BASENAME([$compiler])
-
-# We don't want -fno-exception wen compiling C++ code, so set the
-# no_builtin_flag separately
-if test "$GXX" = yes; then
- _LT_AC_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=' -fno-builtin'
-else
- _LT_AC_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=
-fi
-
-if test "$GXX" = yes; then
- # Set up default GNU C++ configuration
-
- AC_PROG_LD
-
- # Check if GNU C++ uses GNU ld as the underlying linker, since the
- # archiving commands below assume that GNU ld is being used.
- if test "$with_gnu_ld" = yes; then
- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib'
- _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
-
- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}--rpath ${wl}$libdir'
- _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic'
-
- # If archive_cmds runs LD, not CC, wlarc should be empty
- # XXX I think wlarc can be eliminated in ltcf-cxx, but I need to
- # investigate it a little bit more. (MM)
- wlarc='${wl}'
-
- # ancient GNU ld didn't support --whole-archive et. al.
- if eval "`$CC -print-prog-name=ld` --help 2>&1" | \
- grep 'no-whole-archive' > /dev/null; then
- _LT_AC_TAGVAR(whole_archive_flag_spec, $1)="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive'
- else
- _LT_AC_TAGVAR(whole_archive_flag_spec, $1)=
- fi
- else
- with_gnu_ld=no
- wlarc=
-
- # A generic and very simple default shared library creation
- # command for GNU C++ for the case where it uses the native
- # linker, instead of GNU ld. If possible, this setting should
- # overridden to take advantage of the native linker features on
- # the platform it is being used on.
- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $lib'
- fi
-
- # Commands to make compiler produce verbose output that lists
- # what "hidden" libraries, object files and flags are used when
- # linking a shared library.
- output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep "\-L"'
-
-else
- GXX=no
- with_gnu_ld=no
- wlarc=
-fi
-
-# PORTME: fill in a description of your system's C++ link characteristics
-AC_MSG_CHECKING([whether the $compiler linker ($LD) supports shared libraries])
-_LT_AC_TAGVAR(ld_shlibs, $1)=yes
-case $host_os in
- aix3*)
- # FIXME: insert proper C++ library support
- _LT_AC_TAGVAR(ld_shlibs, $1)=no
- ;;
- aix4* | aix5*)
- if test "$host_cpu" = ia64; then
- # On IA64, the linker does run time linking by default, so we don't
- # have to do anything special.
- aix_use_runtimelinking=no
- exp_sym_flag='-Bexport'
- no_entry_flag=""
- else
- aix_use_runtimelinking=no
-
- # Test if we are trying to use run time linking or normal
- # AIX style linking. If -brtl is somewhere in LDFLAGS, we
- # need to do runtime linking.
- case $host_os in aix4.[[23]]|aix4.[[23]].*|aix5*)
- for ld_flag in $LDFLAGS; do
- case $ld_flag in
- *-brtl*)
- aix_use_runtimelinking=yes
- break
- ;;
- esac
- done
- ;;
- esac
-
- exp_sym_flag='-bexport'
- no_entry_flag='-bnoentry'
- fi
-
- # When large executables or shared objects are built, AIX ld can
- # have problems creating the table of contents. If linking a library
- # or program results in "error TOC overflow" add -mminimal-toc to
- # CXXFLAGS/CFLAGS for g++/gcc. In the cases where that is not
- # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS.
-
- _LT_AC_TAGVAR(archive_cmds, $1)=''
- _LT_AC_TAGVAR(hardcode_direct, $1)=yes
- _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=':'
- _LT_AC_TAGVAR(link_all_deplibs, $1)=yes
-
- if test "$GXX" = yes; then
- case $host_os in aix4.[[012]]|aix4.[[012]].*)
- # We only want to do this on AIX 4.2 and lower, the check
- # below for broken collect2 doesn't work under 4.3+
- collect2name=`${CC} -print-prog-name=collect2`
- if test -f "$collect2name" && \
- strings "$collect2name" | grep resolve_lib_name >/dev/null
- then
- # We have reworked collect2
- _LT_AC_TAGVAR(hardcode_direct, $1)=yes
- else
- # We have old collect2
- _LT_AC_TAGVAR(hardcode_direct, $1)=unsupported
- # It fails to find uninstalled libraries when the uninstalled
- # path is not listed in the libpath. Setting hardcode_minus_L
- # to unsupported forces relinking
- _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes
- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
- _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=
- fi
- ;;
- esac
- shared_flag='-shared'
- if test "$aix_use_runtimelinking" = yes; then
- shared_flag="$shared_flag "'${wl}-G'
- fi
- else
- # not using gcc
- if test "$host_cpu" = ia64; then
- # VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release
- # chokes on -Wl,-G. The following line is correct:
- shared_flag='-G'
- else
- if test "$aix_use_runtimelinking" = yes; then
- shared_flag='${wl}-G'
- else
- shared_flag='${wl}-bM:SRE'
- fi
- fi
- fi
-
- # It seems that -bexpall does not export symbols beginning with
- # underscore (_), so it is better to generate a list of symbols to export.
- _LT_AC_TAGVAR(always_export_symbols, $1)=yes
- if test "$aix_use_runtimelinking" = yes; then
- # Warning - without using the other runtime loading flags (-brtl),
- # -berok will link without error, but may produce a broken library.
- _LT_AC_TAGVAR(allow_undefined_flag, $1)='-berok'
- # Determine the default libpath from the value encoded in an empty executable.
- _LT_AC_SYS_LIBPATH_AIX
- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath"
-
- _LT_AC_TAGVAR(archive_expsym_cmds, $1)="\$CC"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then echo "${wl}${allow_undefined_flag}"; else :; fi` '"\${wl}$exp_sym_flag:\$export_symbols $shared_flag"
- else
- if test "$host_cpu" = ia64; then
- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R $libdir:/usr/lib:/lib'
- _LT_AC_TAGVAR(allow_undefined_flag, $1)="-z nodefs"
- _LT_AC_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$exp_sym_flag:\$export_symbols"
- else
- # Determine the default libpath from the value encoded in an empty executable.
- _LT_AC_SYS_LIBPATH_AIX
- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath"
- # Warning - without using the other run time loading flags,
- # -berok will link without error, but may produce a broken library.
- _LT_AC_TAGVAR(no_undefined_flag, $1)=' ${wl}-bernotok'
- _LT_AC_TAGVAR(allow_undefined_flag, $1)=' ${wl}-berok'
- # Exported symbols can be pulled into shared objects from archives
- _LT_AC_TAGVAR(whole_archive_flag_spec, $1)='$convenience'
- _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=yes
- # This is similar to how AIX traditionally builds its shared libraries.
- _LT_AC_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs ${wl}-bnoentry $compiler_flags ${wl}-bE:$export_symbols${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname'
- fi
- fi
- ;;
-
- beos*)
- if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
- _LT_AC_TAGVAR(allow_undefined_flag, $1)=unsupported
- # Joseph Beckenbach <jrb3@best.com> says some releases of gcc
- # support --undefined. This deserves some investigation. FIXME
- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
- else
- _LT_AC_TAGVAR(ld_shlibs, $1)=no
- fi
- ;;
-
- chorus*)
- case $cc_basename in
- *)
- # FIXME: insert proper C++ library support
- _LT_AC_TAGVAR(ld_shlibs, $1)=no
- ;;
- esac
- ;;
-
- cygwin* | mingw* | pw32*)
- # _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1) is actually meaningless,
- # as there is no search path for DLLs.
- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
- _LT_AC_TAGVAR(allow_undefined_flag, $1)=unsupported
- _LT_AC_TAGVAR(always_export_symbols, $1)=no
- _LT_AC_TAGVAR(enable_shared_with_static_runtimes, $1)=yes
-
- if $LD --help 2>&1 | grep 'auto-import' > /dev/null; then
- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
- # If the export-symbols file already is a .def file (1st line
- # is EXPORTS), use it as is; otherwise, prepend...
- _LT_AC_TAGVAR(archive_expsym_cmds, $1)='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then
- cp $export_symbols $output_objdir/$soname.def;
- else
- echo EXPORTS > $output_objdir/$soname.def;
- cat $export_symbols >> $output_objdir/$soname.def;
- fi~
- $CC -shared -nostdlib $output_objdir/$soname.def $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
- else
- _LT_AC_TAGVAR(ld_shlibs, $1)=no
- fi
- ;;
- darwin* | rhapsody*)
- case $host_os in
- rhapsody* | darwin1.[[012]])
- _LT_AC_TAGVAR(allow_undefined_flag, $1)='${wl}-undefined ${wl}suppress'
- ;;
- *) # Darwin 1.3 on
- if test -z ${MACOSX_DEPLOYMENT_TARGET} ; then
- _LT_AC_TAGVAR(allow_undefined_flag, $1)='${wl}-flat_namespace ${wl}-undefined ${wl}suppress'
- else
- case ${MACOSX_DEPLOYMENT_TARGET} in
- 10.[[012]])
- _LT_AC_TAGVAR(allow_undefined_flag, $1)='${wl}-flat_namespace ${wl}-undefined ${wl}suppress'
- ;;
- 10.*)
- _LT_AC_TAGVAR(allow_undefined_flag, $1)='${wl}-undefined ${wl}dynamic_lookup'
- ;;
- esac
- fi
- ;;
- esac
- _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no
- _LT_AC_TAGVAR(hardcode_direct, $1)=no
- _LT_AC_TAGVAR(hardcode_automatic, $1)=yes
- _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=unsupported
- _LT_AC_TAGVAR(whole_archive_flag_spec, $1)=''
- _LT_AC_TAGVAR(link_all_deplibs, $1)=yes
-
- if test "$GXX" = yes ; then
- lt_int_apple_cc_single_mod=no
- output_verbose_link_cmd='echo'
- if $CC -dumpspecs 2>&1 | $EGREP 'single_module' >/dev/null ; then
- lt_int_apple_cc_single_mod=yes
- fi
- if test "X$lt_int_apple_cc_single_mod" = Xyes ; then
- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -dynamiclib -single_module $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring'
- else
- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -r -keep_private_externs -nostdlib -o ${lib}-master.o $libobjs~$CC -dynamiclib $allow_undefined_flag -o $lib ${lib}-master.o $deplibs $compiler_flags -install_name $rpath/$soname $verstring'
- fi
- _LT_AC_TAGVAR(module_cmds, $1)='$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags'
- # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin lds
- if test "X$lt_int_apple_cc_single_mod" = Xyes ; then
- _LT_AC_TAGVAR(archive_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -dynamiclib -single_module $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
- else
- _LT_AC_TAGVAR(archive_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -r -keep_private_externs -nostdlib -o ${lib}-master.o $libobjs~$CC -dynamiclib $allow_undefined_flag -o $lib ${lib}-master.o $deplibs $compiler_flags -install_name $rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
- fi
- _LT_AC_TAGVAR(module_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
- else
- case $cc_basename in
- xlc*)
- output_verbose_link_cmd='echo'
- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -qmkshrobj ${wl}-single_module $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-install_name ${wl}`echo $rpath/$soname` $verstring'
- _LT_AC_TAGVAR(module_cmds, $1)='$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags'
- # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin lds
- _LT_AC_TAGVAR(archive_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -qmkshrobj ${wl}-single_module $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-install_name ${wl}$rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
- _LT_AC_TAGVAR(module_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
- ;;
- *)
- _LT_AC_TAGVAR(ld_shlibs, $1)=no
- ;;
- esac
- fi
- ;;
-
- dgux*)
- case $cc_basename in
- ec++*)
- # FIXME: insert proper C++ library support
- _LT_AC_TAGVAR(ld_shlibs, $1)=no
- ;;
- ghcx*)
- # Green Hills C++ Compiler
- # FIXME: insert proper C++ library support
- _LT_AC_TAGVAR(ld_shlibs, $1)=no
- ;;
- *)
- # FIXME: insert proper C++ library support
- _LT_AC_TAGVAR(ld_shlibs, $1)=no
- ;;
- esac
- ;;
- freebsd[[12]]*)
- # C++ shared libraries reported to be fairly broken before switch to ELF
- _LT_AC_TAGVAR(ld_shlibs, $1)=no
- ;;
- freebsd-elf*)
- _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no
- ;;
- freebsd* | kfreebsd*-gnu | dragonfly*)
- # FreeBSD 3 and later use GNU C++ and GNU ld with standard ELF
- # conventions
- _LT_AC_TAGVAR(ld_shlibs, $1)=yes
- ;;
- gnu*)
- ;;
- hpux9*)
- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir'
- _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=:
- _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
- _LT_AC_TAGVAR(hardcode_direct, $1)=yes
- _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes # Not in the search PATH,
- # but as the default
- # location of the library.
-
- case $cc_basename in
- CC*)
- # FIXME: insert proper C++ library support
- _LT_AC_TAGVAR(ld_shlibs, $1)=no
- ;;
- aCC*)
- _LT_AC_TAGVAR(archive_cmds, $1)='$rm $output_objdir/$soname~$CC -b ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
- # Commands to make compiler produce verbose output that lists
- # what "hidden" libraries, object files and flags are used when
- # linking a shared library.
- #
- # There doesn't appear to be a way to prevent this compiler from
- # explicitly linking system object files so we need to strip them
- # from the output so that they don't get included in the library
- # dependencies.
- output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | grep "[[-]]L"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; echo $list'
- ;;
- *)
- if test "$GXX" = yes; then
- _LT_AC_TAGVAR(archive_cmds, $1)='$rm $output_objdir/$soname~$CC -shared -nostdlib -fPIC ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
- else
- # FIXME: insert proper C++ library support
- _LT_AC_TAGVAR(ld_shlibs, $1)=no
- fi
- ;;
- esac
- ;;
- hpux10*|hpux11*)
- if test $with_gnu_ld = no; then
- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir'
- _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=:
-
- case $host_cpu in
- hppa*64*|ia64*)
- _LT_AC_TAGVAR(hardcode_libdir_flag_spec_ld, $1)='+b $libdir'
- ;;
- *)
- _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
- ;;
- esac
- fi
- case $host_cpu in
- hppa*64*|ia64*)
- _LT_AC_TAGVAR(hardcode_direct, $1)=no
- _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
- ;;
- *)
- _LT_AC_TAGVAR(hardcode_direct, $1)=yes
- _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes # Not in the search PATH,
- # but as the default
- # location of the library.
- ;;
- esac
-
- case $cc_basename in
- CC*)
- # FIXME: insert proper C++ library support
- _LT_AC_TAGVAR(ld_shlibs, $1)=no
- ;;
- aCC*)
- case $host_cpu in
- hppa*64*)
- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
- ;;
- ia64*)
- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
- ;;
- *)
- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
- ;;
- esac
- # Commands to make compiler produce verbose output that lists
- # what "hidden" libraries, object files and flags are used when
- # linking a shared library.
- #
- # There doesn't appear to be a way to prevent this compiler from
- # explicitly linking system object files so we need to strip them
- # from the output so that they don't get included in the library
- # dependencies.
- output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | grep "\-L"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; echo $list'
- ;;
- *)
- if test "$GXX" = yes; then
- if test $with_gnu_ld = no; then
- case $host_cpu in
- hppa*64*)
- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib -fPIC ${wl}+h ${wl}$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
- ;;
- ia64*)
- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib -fPIC ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
- ;;
- *)
- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
- ;;
- esac
- fi
- else
- # FIXME: insert proper C++ library support
- _LT_AC_TAGVAR(ld_shlibs, $1)=no
- fi
- ;;
- esac
- ;;
- interix3*)
- _LT_AC_TAGVAR(hardcode_direct, $1)=no
- _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
- _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
- # Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc.
- # Instead, shared libraries are loaded at an image base (0x10000000 by
- # default) and relocated if they conflict, which is a slow very memory
- # consuming and fragmenting process. To avoid this, we pick a random,
- # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link
- # time. Moving up from 0x10000000 also allows more sbrk(2) space.
- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
- _LT_AC_TAGVAR(archive_expsym_cmds, $1)='sed "s,^,_," $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--retain-symbols-file,$output_objdir/$soname.expsym ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
- ;;
- irix5* | irix6*)
- case $cc_basename in
- CC*)
- # SGI C++
- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -all -multigot $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib'
-
- # Archives containing C++ object files must be created using
- # "CC -ar", where "CC" is the IRIX C++ compiler. This is
- # necessary to make sure instantiated templates are included
- # in the archive.
- _LT_AC_TAGVAR(old_archive_cmds, $1)='$CC -ar -WR,-u -o $oldlib $oldobjs'
- ;;
- *)
- if test "$GXX" = yes; then
- if test "$with_gnu_ld" = no; then
- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
- else
- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` -o $lib'
- fi
- fi
- _LT_AC_TAGVAR(link_all_deplibs, $1)=yes
- ;;
- esac
- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
- _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=:
- ;;
- linux*)
- case $cc_basename in
- KCC*)
- # Kuck and Associates, Inc. (KAI) C++ Compiler
-
- # KCC will only create a shared library if the output file
- # ends with ".so" (or ".sl" for HP-UX), so rename the library
- # to its proper name (with version) after linking.
- _LT_AC_TAGVAR(archive_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib'
- _LT_AC_TAGVAR(archive_expsym_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib ${wl}-retain-symbols-file,$export_symbols; mv \$templib $lib'
- # Commands to make compiler produce verbose output that lists
- # what "hidden" libraries, object files and flags are used when
- # linking a shared library.
- #
- # There doesn't appear to be a way to prevent this compiler from
- # explicitly linking system object files so we need to strip them
- # from the output so that they don't get included in the library
- # dependencies.
- output_verbose_link_cmd='templist=`$CC $CFLAGS -v conftest.$objext -o libconftest$shared_ext 2>&1 | grep "ld"`; rm -f libconftest$shared_ext; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; echo $list'
-
- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}--rpath,$libdir'
- _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic'
-
- # Archives containing C++ object files must be created using
- # "CC -Bstatic", where "CC" is the KAI C++ compiler.
- _LT_AC_TAGVAR(old_archive_cmds, $1)='$CC -Bstatic -o $oldlib $oldobjs'
- ;;
- icpc*)
- # Intel C++
- with_gnu_ld=yes
- # version 8.0 and above of icpc choke on multiply defined symbols
- # if we add $predep_objects and $postdep_objects, however 7.1 and
- # earlier do not add the objects themselves.
- case `$CC -V 2>&1` in
- *"Version 7."*)
- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib'
- _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
- ;;
- *) # Version 8.0 or newer
- tmp_idyn=
- case $host_cpu in
- ia64*) tmp_idyn=' -i_dynamic';;
- esac
- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared'"$tmp_idyn"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
- _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared'"$tmp_idyn"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
- ;;
- esac
- _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no
- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
- _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic'
- _LT_AC_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive$convenience ${wl}--no-whole-archive'
- ;;
- pgCC*)
- # Portland Group C++ compiler
- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname -o $lib'
- _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname ${wl}-retain-symbols-file ${wl}$export_symbols -o $lib'
-
- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}--rpath ${wl}$libdir'
- _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic'
- _LT_AC_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}--no-whole-archive'
- ;;
- cxx*)
- # Compaq C++
- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib'
- _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib ${wl}-retain-symbols-file $wl$export_symbols'
-
- runpath_var=LD_RUN_PATH
- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-rpath $libdir'
- _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=:
-
- # Commands to make compiler produce verbose output that lists
- # what "hidden" libraries, object files and flags are used when
- # linking a shared library.
- #
- # There doesn't appear to be a way to prevent this compiler from
- # explicitly linking system object files so we need to strip them
- # from the output so that they don't get included in the library
- # dependencies.
- output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep "ld"`; templist=`echo $templist | $SED "s/\(^.*ld.*\)\( .*ld .*$\)/\1/"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; echo $list'
- ;;
- esac
- ;;
- lynxos*)
- # FIXME: insert proper C++ library support
- _LT_AC_TAGVAR(ld_shlibs, $1)=no
- ;;
- m88k*)
- # FIXME: insert proper C++ library support
- _LT_AC_TAGVAR(ld_shlibs, $1)=no
- ;;
- mvs*)
- case $cc_basename in
- cxx*)
- # FIXME: insert proper C++ library support
- _LT_AC_TAGVAR(ld_shlibs, $1)=no
- ;;
- *)
- # FIXME: insert proper C++ library support
- _LT_AC_TAGVAR(ld_shlibs, $1)=no
- ;;
- esac
- ;;
- netbsd* | netbsdelf*-gnu | knetbsd*-gnu)
- if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then
- _LT_AC_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $predep_objects $libobjs $deplibs $postdep_objects $linker_flags'
- wlarc=
- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
- _LT_AC_TAGVAR(hardcode_direct, $1)=yes
- _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
- fi
- # Workaround some broken pre-1.5 toolchains
- output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep conftest.$objext | $SED -e "s:-lgcc -lc -lgcc::"'
- ;;
- openbsd2*)
- # C++ shared libraries are fairly broken
- _LT_AC_TAGVAR(ld_shlibs, $1)=no
- ;;
- openbsd*)
- _LT_AC_TAGVAR(hardcode_direct, $1)=yes
- _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $lib'
- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
- if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
- _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-retain-symbols-file,$export_symbols -o $lib'
- _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
- _LT_AC_TAGVAR(whole_archive_flag_spec, $1)="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive'
- fi
- output_verbose_link_cmd='echo'
- ;;
- osf3*)
- case $cc_basename in
- KCC*)
- # Kuck and Associates, Inc. (KAI) C++ Compiler
-
- # KCC will only create a shared library if the output file
- # ends with ".so" (or ".sl" for HP-UX), so rename the library
- # to its proper name (with version) after linking.
- _LT_AC_TAGVAR(archive_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib'
-
- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
- _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=:
-
- # Archives containing C++ object files must be created using
- # "CC -Bstatic", where "CC" is the KAI C++ compiler.
- _LT_AC_TAGVAR(old_archive_cmds, $1)='$CC -Bstatic -o $oldlib $oldobjs'
-
- ;;
- RCC*)
- # Rational C++ 2.4.1
- # FIXME: insert proper C++ library support
- _LT_AC_TAGVAR(ld_shlibs, $1)=no
- ;;
- cxx*)
- _LT_AC_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*'
- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $soname `test -n "$verstring" && echo ${wl}-set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib'
-
- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
- _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=:
-
- # Commands to make compiler produce verbose output that lists
- # what "hidden" libraries, object files and flags are used when
- # linking a shared library.
- #
- # There doesn't appear to be a way to prevent this compiler from
- # explicitly linking system object files so we need to strip them
- # from the output so that they don't get included in the library
- # dependencies.
- output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep "ld" | grep -v "ld:"`; templist=`echo $templist | $SED "s/\(^.*ld.*\)\( .*ld.*$\)/\1/"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; echo $list'
- ;;
- *)
- if test "$GXX" = yes && test "$with_gnu_ld" = no; then
- _LT_AC_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*'
- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib ${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
-
- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
- _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=:
-
- # Commands to make compiler produce verbose output that lists
- # what "hidden" libraries, object files and flags are used when
- # linking a shared library.
- output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep "\-L"'
-
- else
- # FIXME: insert proper C++ library support
- _LT_AC_TAGVAR(ld_shlibs, $1)=no
- fi
- ;;
- esac
- ;;
- osf4* | osf5*)
- case $cc_basename in
- KCC*)
- # Kuck and Associates, Inc. (KAI) C++ Compiler
-
- # KCC will only create a shared library if the output file
- # ends with ".so" (or ".sl" for HP-UX), so rename the library
- # to its proper name (with version) after linking.
- _LT_AC_TAGVAR(archive_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib'
-
- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
- _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=:
-
- # Archives containing C++ object files must be created using
- # the KAI C++ compiler.
- _LT_AC_TAGVAR(old_archive_cmds, $1)='$CC -o $oldlib $oldobjs'
- ;;
- RCC*)
- # Rational C++ 2.4.1
- # FIXME: insert proper C++ library support
- _LT_AC_TAGVAR(ld_shlibs, $1)=no
- ;;
- cxx*)
- _LT_AC_TAGVAR(allow_undefined_flag, $1)=' -expect_unresolved \*'
- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib'
- _LT_AC_TAGVAR(archive_expsym_cmds, $1)='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done~
- echo "-hidden">> $lib.exp~
- $CC -shared$allow_undefined_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname -Wl,-input -Wl,$lib.exp `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib~
- $rm $lib.exp'
-
- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-rpath $libdir'
- _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=:
-
- # Commands to make compiler produce verbose output that lists
- # what "hidden" libraries, object files and flags are used when
- # linking a shared library.
- #
- # There doesn't appear to be a way to prevent this compiler from
- # explicitly linking system object files so we need to strip them
- # from the output so that they don't get included in the library
- # dependencies.
- output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep "ld" | grep -v "ld:"`; templist=`echo $templist | $SED "s/\(^.*ld.*\)\( .*ld.*$\)/\1/"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; echo $list'
- ;;
- *)
- if test "$GXX" = yes && test "$with_gnu_ld" = no; then
- _LT_AC_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*'
- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib ${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
-
- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
- _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=:
-
- # Commands to make compiler produce verbose output that lists
- # what "hidden" libraries, object files and flags are used when
- # linking a shared library.
- output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep "\-L"'
-
- else
- # FIXME: insert proper C++ library support
- _LT_AC_TAGVAR(ld_shlibs, $1)=no
- fi
- ;;
- esac
- ;;
- psos*)
- # FIXME: insert proper C++ library support
- _LT_AC_TAGVAR(ld_shlibs, $1)=no
- ;;
- sunos4*)
- case $cc_basename in
- CC*)
- # Sun C++ 4.x
- # FIXME: insert proper C++ library support
- _LT_AC_TAGVAR(ld_shlibs, $1)=no
- ;;
- lcc*)
- # Lucid
- # FIXME: insert proper C++ library support
- _LT_AC_TAGVAR(ld_shlibs, $1)=no
- ;;
- *)
- # FIXME: insert proper C++ library support
- _LT_AC_TAGVAR(ld_shlibs, $1)=no
- ;;
- esac
- ;;
- solaris*)
- case $cc_basename in
- CC*)
- # Sun C++ 4.2, 5.x and Centerline C++
- _LT_AC_TAGVAR(archive_cmds_need_lc,$1)=yes
- _LT_AC_TAGVAR(no_undefined_flag, $1)=' -zdefs'
- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -G${allow_undefined_flag} -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
- _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~
- $CC -G${allow_undefined_flag} ${wl}-M ${wl}$lib.exp -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$rm $lib.exp'
-
- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
- _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
- case $host_os in
- solaris2.[[0-5]] | solaris2.[[0-5]].*) ;;
- *)
- # The C++ compiler is used as linker so we must use $wl
- # flag to pass the commands to the underlying system
- # linker. We must also pass each convience library through
- # to the system linker between allextract/defaultextract.
- # The C++ compiler will combine linker options so we
- # cannot just pass the convience library names through
- # without $wl.
- # Supported since Solaris 2.6 (maybe 2.5.1?)
- _LT_AC_TAGVAR(whole_archive_flag_spec, $1)='${wl}-z ${wl}allextract`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}-z ${wl}defaultextract'
- ;;
- esac
- _LT_AC_TAGVAR(link_all_deplibs, $1)=yes
-
- output_verbose_link_cmd='echo'
-
- # Archives containing C++ object files must be created using
- # "CC -xar", where "CC" is the Sun C++ compiler. This is
- # necessary to make sure instantiated templates are included
- # in the archive.
- _LT_AC_TAGVAR(old_archive_cmds, $1)='$CC -xar -o $oldlib $oldobjs'
- ;;
- gcx*)
- # Green Hills C++ Compiler
- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib'
-
- # The C++ compiler must be used to create the archive.
- _LT_AC_TAGVAR(old_archive_cmds, $1)='$CC $LDFLAGS -archive -o $oldlib $oldobjs'
- ;;
- *)
- # GNU C++ compiler with Solaris linker
- if test "$GXX" = yes && test "$with_gnu_ld" = no; then
- _LT_AC_TAGVAR(no_undefined_flag, $1)=' ${wl}-z ${wl}defs'
- if $CC --version | grep -v '^2\.7' > /dev/null; then
- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $LDFLAGS $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib'
- _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~
- $CC -shared -nostdlib ${wl}-M $wl$lib.exp -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$rm $lib.exp'
-
- # Commands to make compiler produce verbose output that lists
- # what "hidden" libraries, object files and flags are used when
- # linking a shared library.
- output_verbose_link_cmd="$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep \"\-L\""
- else
- # g++ 2.7 appears to require `-G' NOT `-shared' on this
- # platform.
- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -G -nostdlib $LDFLAGS $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib'
- _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~
- $CC -G -nostdlib ${wl}-M $wl$lib.exp -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$rm $lib.exp'
-
- # Commands to make compiler produce verbose output that lists
- # what "hidden" libraries, object files and flags are used when
- # linking a shared library.
- output_verbose_link_cmd="$CC -G $CFLAGS -v conftest.$objext 2>&1 | grep \"\-L\""
- fi
-
- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R $wl$libdir'
- fi
- ;;
- esac
- ;;
- sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[[01]].[[10]]* | unixware7* | sco3.2v5.0.[[024]]*)
- _LT_AC_TAGVAR(no_undefined_flag, $1)='${wl}-z,text'
- _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no
- _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
- runpath_var='LD_RUN_PATH'
-
- case $cc_basename in
- CC*)
- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
- _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
- ;;
- *)
- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
- _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
- ;;
- esac
- ;;
- sysv5* | sco3.2v5* | sco5v6*)
- # Note: We can NOT use -z defs as we might desire, because we do not
- # link with -lc, and that would cause any symbols used from libc to
- # always be unresolved, which means just about no library would
- # ever link correctly. If we're not using GNU ld we use -z text
- # though, which does catch some bad symbols but isn't as heavy-handed
- # as -z defs.
- # For security reasons, it is highly recommended that you always
- # use absolute paths for naming shared libraries, and exclude the
- # DT_RUNPATH tag from executables and libraries. But doing so
- # requires that you compile everything twice, which is a pain.
- # So that behaviour is only enabled if SCOABSPATH is set to a
- # non-empty value in the environment. Most likely only useful for
- # creating official distributions of packages.
- # This is a hack until libtool officially supports absolute path
- # names for shared libraries.
- _LT_AC_TAGVAR(no_undefined_flag, $1)='${wl}-z,text'
- _LT_AC_TAGVAR(allow_undefined_flag, $1)='${wl}-z,nodefs'
- _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no
- _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='`test -z "$SCOABSPATH" && echo ${wl}-R,$libdir`'
- _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=':'
- _LT_AC_TAGVAR(link_all_deplibs, $1)=yes
- _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-Bexport'
- runpath_var='LD_RUN_PATH'
-
- case $cc_basename in
- CC*)
- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags'
- _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags'
- ;;
- *)
- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags'
- _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags'
- ;;
- esac
- ;;
- tandem*)
- case $cc_basename in
- NCC*)
- # NonStop-UX NCC 3.20
- # FIXME: insert proper C++ library support
- _LT_AC_TAGVAR(ld_shlibs, $1)=no
- ;;
- *)
- # FIXME: insert proper C++ library support
- _LT_AC_TAGVAR(ld_shlibs, $1)=no
- ;;
- esac
- ;;
- vxworks*)
- # FIXME: insert proper C++ library support
- _LT_AC_TAGVAR(ld_shlibs, $1)=no
- ;;
- *)
- # FIXME: insert proper C++ library support
- _LT_AC_TAGVAR(ld_shlibs, $1)=no
- ;;
-esac
-AC_MSG_RESULT([$_LT_AC_TAGVAR(ld_shlibs, $1)])
-test "$_LT_AC_TAGVAR(ld_shlibs, $1)" = no && can_build_shared=no
-
-_LT_AC_TAGVAR(GCC, $1)="$GXX"
-_LT_AC_TAGVAR(LD, $1)="$LD"
-
-AC_LIBTOOL_POSTDEP_PREDEP($1)
-AC_LIBTOOL_PROG_COMPILER_PIC($1)
-AC_LIBTOOL_PROG_CC_C_O($1)
-AC_LIBTOOL_SYS_HARD_LINK_LOCKS($1)
-AC_LIBTOOL_PROG_LD_SHLIBS($1)
-AC_LIBTOOL_SYS_DYNAMIC_LINKER($1)
-AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH($1)
-
-AC_LIBTOOL_CONFIG($1)
-
-AC_LANG_POP
-CC=$lt_save_CC
-LDCXX=$LD
-LD=$lt_save_LD
-GCC=$lt_save_GCC
-with_gnu_ldcxx=$with_gnu_ld
-with_gnu_ld=$lt_save_with_gnu_ld
-lt_cv_path_LDCXX=$lt_cv_path_LD
-lt_cv_path_LD=$lt_save_path_LD
-lt_cv_prog_gnu_ldcxx=$lt_cv_prog_gnu_ld
-lt_cv_prog_gnu_ld=$lt_save_with_gnu_ld
-])# AC_LIBTOOL_LANG_CXX_CONFIG
-
-# AC_LIBTOOL_POSTDEP_PREDEP([TAGNAME])
-# ------------------------------------
-# Figure out "hidden" library dependencies from verbose
-# compiler output when linking a shared library.
-# Parse the compiler output and extract the necessary
-# objects, libraries and library flags.
-AC_DEFUN([AC_LIBTOOL_POSTDEP_PREDEP],[
-dnl we can't use the lt_simple_compile_test_code here,
-dnl because it contains code intended for an executable,
-dnl not a library. It's possible we should let each
-dnl tag define a new lt_????_link_test_code variable,
-dnl but it's only used here...
-ifelse([$1],[],[cat > conftest.$ac_ext <<EOF
-int a;
-void foo (void) { a = 0; }
-EOF
-],[$1],[CXX],[cat > conftest.$ac_ext <<EOF
-class Foo
-{
-public:
- Foo (void) { a = 0; }
-private:
- int a;
-};
-EOF
-],[$1],[F77],[cat > conftest.$ac_ext <<EOF
- subroutine foo
- implicit none
- integer*4 a
- a=0
- return
- end
-EOF
-],[$1],[GCJ],[cat > conftest.$ac_ext <<EOF
-public class foo {
- private int a;
- public void bar (void) {
- a = 0;
- }
-};
-EOF
-])
-dnl Parse the compiler output and extract the necessary
-dnl objects, libraries and library flags.
-if AC_TRY_EVAL(ac_compile); then
- # Parse the compiler output and extract the necessary
- # objects, libraries and library flags.
-
- # Sentinel used to keep track of whether or not we are before
- # the conftest object file.
- pre_test_object_deps_done=no
-
- # The `*' in the case matches for architectures that use `case' in
- # $output_verbose_cmd can trigger glob expansion during the loop
- # eval without this substitution.
- output_verbose_link_cmd=`$echo "X$output_verbose_link_cmd" | $Xsed -e "$no_glob_subst"`
-
- for p in `eval $output_verbose_link_cmd`; do
- case $p in
-
- -L* | -R* | -l*)
- # Some compilers place space between "-{L,R}" and the path.
- # Remove the space.
- if test $p = "-L" \
- || test $p = "-R"; then
- prev=$p
- continue
- else
- prev=
- fi
-
- if test "$pre_test_object_deps_done" = no; then
- case $p in
- -L* | -R*)
- # Internal compiler library paths should come after those
- # provided the user. The postdeps already come after the
- # user supplied libs so there is no need to process them.
- if test -z "$_LT_AC_TAGVAR(compiler_lib_search_path, $1)"; then
- _LT_AC_TAGVAR(compiler_lib_search_path, $1)="${prev}${p}"
- else
- _LT_AC_TAGVAR(compiler_lib_search_path, $1)="${_LT_AC_TAGVAR(compiler_lib_search_path, $1)} ${prev}${p}"
- fi
- ;;
- # The "-l" case would never come before the object being
- # linked, so don't bother handling this case.
- esac
- else
- if test -z "$_LT_AC_TAGVAR(postdeps, $1)"; then
- _LT_AC_TAGVAR(postdeps, $1)="${prev}${p}"
- else
- _LT_AC_TAGVAR(postdeps, $1)="${_LT_AC_TAGVAR(postdeps, $1)} ${prev}${p}"
- fi
- fi
- ;;
-
- *.$objext)
- # This assumes that the test object file only shows up
- # once in the compiler output.
- if test "$p" = "conftest.$objext"; then
- pre_test_object_deps_done=yes
- continue
- fi
-
- if test "$pre_test_object_deps_done" = no; then
- if test -z "$_LT_AC_TAGVAR(predep_objects, $1)"; then
- _LT_AC_TAGVAR(predep_objects, $1)="$p"
- else
- _LT_AC_TAGVAR(predep_objects, $1)="$_LT_AC_TAGVAR(predep_objects, $1) $p"
- fi
- else
- if test -z "$_LT_AC_TAGVAR(postdep_objects, $1)"; then
- _LT_AC_TAGVAR(postdep_objects, $1)="$p"
- else
- _LT_AC_TAGVAR(postdep_objects, $1)="$_LT_AC_TAGVAR(postdep_objects, $1) $p"
- fi
- fi
- ;;
-
- *) ;; # Ignore the rest.
-
- esac
- done
-
- # Clean up.
- rm -f a.out a.exe
-else
- echo "libtool.m4: error: problem compiling $1 test program"
-fi
-
-$rm -f confest.$objext
-
-# PORTME: override above test on systems where it is broken
-ifelse([$1],[CXX],
-[case $host_os in
-interix3*)
- # Interix 3.5 installs completely hosed .la files for C++, so rather than
- # hack all around it, let's just trust "g++" to DTRT.
- _LT_AC_TAGVAR(predep_objects,$1)=
- _LT_AC_TAGVAR(postdep_objects,$1)=
- _LT_AC_TAGVAR(postdeps,$1)=
- ;;
-
-solaris*)
- case $cc_basename in
- CC*)
- # Adding this requires a known-good setup of shared libraries for
- # Sun compiler versions before 5.6, else PIC objects from an old
- # archive will be linked into the output, leading to subtle bugs.
- _LT_AC_TAGVAR(postdeps,$1)='-lCstd -lCrun'
- ;;
- esac
- ;;
-esac
-])
-
-case " $_LT_AC_TAGVAR(postdeps, $1) " in
-*" -lc "*) _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no ;;
-esac
-])# AC_LIBTOOL_POSTDEP_PREDEP
-
-# AC_LIBTOOL_LANG_F77_CONFIG
-# --------------------------
-# Ensure that the configuration vars for the C compiler are
-# suitably defined. Those variables are subsequently used by
-# AC_LIBTOOL_CONFIG to write the compiler configuration to `libtool'.
-AC_DEFUN([AC_LIBTOOL_LANG_F77_CONFIG], [_LT_AC_LANG_F77_CONFIG(F77)])
-AC_DEFUN([_LT_AC_LANG_F77_CONFIG],
-[AC_REQUIRE([AC_PROG_F77])
-AC_LANG_PUSH(Fortran 77)
-
-_LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no
-_LT_AC_TAGVAR(allow_undefined_flag, $1)=
-_LT_AC_TAGVAR(always_export_symbols, $1)=no
-_LT_AC_TAGVAR(archive_expsym_cmds, $1)=
-_LT_AC_TAGVAR(export_dynamic_flag_spec, $1)=
-_LT_AC_TAGVAR(hardcode_direct, $1)=no
-_LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)=
-_LT_AC_TAGVAR(hardcode_libdir_flag_spec_ld, $1)=
-_LT_AC_TAGVAR(hardcode_libdir_separator, $1)=
-_LT_AC_TAGVAR(hardcode_minus_L, $1)=no
-_LT_AC_TAGVAR(hardcode_automatic, $1)=no
-_LT_AC_TAGVAR(module_cmds, $1)=
-_LT_AC_TAGVAR(module_expsym_cmds, $1)=
-_LT_AC_TAGVAR(link_all_deplibs, $1)=unknown
-_LT_AC_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds
-_LT_AC_TAGVAR(no_undefined_flag, $1)=
-_LT_AC_TAGVAR(whole_archive_flag_spec, $1)=
-_LT_AC_TAGVAR(enable_shared_with_static_runtimes, $1)=no
-
-# Source file extension for f77 test sources.
-ac_ext=f
-
-# Object file extension for compiled f77 test sources.
-objext=o
-_LT_AC_TAGVAR(objext, $1)=$objext
-
-# Code to be used in simple compile tests
-lt_simple_compile_test_code=" subroutine t\n return\n end\n"
-
-# Code to be used in simple link tests
-lt_simple_link_test_code=" program t\n end\n"
-
-# ltmain only uses $CC for tagged configurations so make sure $CC is set.
-_LT_AC_SYS_COMPILER
-
-# save warnings/boilerplate of simple test code
-_LT_COMPILER_BOILERPLATE
-_LT_LINKER_BOILERPLATE
-
-# Allow CC to be a program name with arguments.
-lt_save_CC="$CC"
-CC=${F77-"f77"}
-compiler=$CC
-_LT_AC_TAGVAR(compiler, $1)=$CC
-_LT_CC_BASENAME([$compiler])
-
-AC_MSG_CHECKING([if libtool supports shared libraries])
-AC_MSG_RESULT([$can_build_shared])
-
-AC_MSG_CHECKING([whether to build shared libraries])
-test "$can_build_shared" = "no" && enable_shared=no
-
-# On AIX, shared libraries and static libraries use the same namespace, and
-# are all built from PIC.
-case $host_os in
-aix3*)
- test "$enable_shared" = yes && enable_static=no
- if test -n "$RANLIB"; then
- archive_cmds="$archive_cmds~\$RANLIB \$lib"
- postinstall_cmds='$RANLIB $lib'
- fi
- ;;
-aix4* | aix5*)
- if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then
- test "$enable_shared" = yes && enable_static=no
- fi
- ;;
-esac
-AC_MSG_RESULT([$enable_shared])
-
-AC_MSG_CHECKING([whether to build static libraries])
-# Make sure either enable_shared or enable_static is yes.
-test "$enable_shared" = yes || enable_static=yes
-AC_MSG_RESULT([$enable_static])
-
-_LT_AC_TAGVAR(GCC, $1)="$G77"
-_LT_AC_TAGVAR(LD, $1)="$LD"
-
-AC_LIBTOOL_PROG_COMPILER_PIC($1)
-AC_LIBTOOL_PROG_CC_C_O($1)
-AC_LIBTOOL_SYS_HARD_LINK_LOCKS($1)
-AC_LIBTOOL_PROG_LD_SHLIBS($1)
-AC_LIBTOOL_SYS_DYNAMIC_LINKER($1)
-AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH($1)
-
-AC_LIBTOOL_CONFIG($1)
-
-AC_LANG_POP
-CC="$lt_save_CC"
-])# AC_LIBTOOL_LANG_F77_CONFIG
-
-
-# AC_LIBTOOL_LANG_GCJ_CONFIG
-# --------------------------
-# Ensure that the configuration vars for the C compiler are
-# suitably defined. Those variables are subsequently used by
-# AC_LIBTOOL_CONFIG to write the compiler configuration to `libtool'.
-AC_DEFUN([AC_LIBTOOL_LANG_GCJ_CONFIG], [_LT_AC_LANG_GCJ_CONFIG(GCJ)])
-AC_DEFUN([_LT_AC_LANG_GCJ_CONFIG],
-[AC_LANG_SAVE
-
-# Source file extension for Java test sources.
-ac_ext=java
-
-# Object file extension for compiled Java test sources.
-objext=o
-_LT_AC_TAGVAR(objext, $1)=$objext
-
-# Code to be used in simple compile tests
-lt_simple_compile_test_code="class foo {}\n"
-
-# Code to be used in simple link tests
-lt_simple_link_test_code='public class conftest { public static void main(String[[]] argv) {}; }\n'
-
-# ltmain only uses $CC for tagged configurations so make sure $CC is set.
-_LT_AC_SYS_COMPILER
-
-# save warnings/boilerplate of simple test code
-_LT_COMPILER_BOILERPLATE
-_LT_LINKER_BOILERPLATE
-
-# Allow CC to be a program name with arguments.
-lt_save_CC="$CC"
-CC=${GCJ-"gcj"}
-compiler=$CC
-_LT_AC_TAGVAR(compiler, $1)=$CC
-_LT_CC_BASENAME([$compiler])
-
-# GCJ did not exist at the time GCC didn't implicitly link libc in.
-_LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no
-
-_LT_AC_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds
-
-AC_LIBTOOL_PROG_COMPILER_NO_RTTI($1)
-AC_LIBTOOL_PROG_COMPILER_PIC($1)
-AC_LIBTOOL_PROG_CC_C_O($1)
-AC_LIBTOOL_SYS_HARD_LINK_LOCKS($1)
-AC_LIBTOOL_PROG_LD_SHLIBS($1)
-AC_LIBTOOL_SYS_DYNAMIC_LINKER($1)
-AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH($1)
-
-AC_LIBTOOL_CONFIG($1)
-
-AC_LANG_RESTORE
-CC="$lt_save_CC"
-])# AC_LIBTOOL_LANG_GCJ_CONFIG
-
-
-# AC_LIBTOOL_LANG_RC_CONFIG
-# -------------------------
-# Ensure that the configuration vars for the Windows resource compiler are
-# suitably defined. Those variables are subsequently used by
-# AC_LIBTOOL_CONFIG to write the compiler configuration to `libtool'.
-AC_DEFUN([AC_LIBTOOL_LANG_RC_CONFIG], [_LT_AC_LANG_RC_CONFIG(RC)])
-AC_DEFUN([_LT_AC_LANG_RC_CONFIG],
-[AC_LANG_SAVE
-
-# Source file extension for RC test sources.
-ac_ext=rc
-
-# Object file extension for compiled RC test sources.
-objext=o
-_LT_AC_TAGVAR(objext, $1)=$objext
-
-# Code to be used in simple compile tests
-lt_simple_compile_test_code='sample MENU { MENUITEM "&Soup", 100, CHECKED }\n'
-
-# Code to be used in simple link tests
-lt_simple_link_test_code="$lt_simple_compile_test_code"
-
-# ltmain only uses $CC for tagged configurations so make sure $CC is set.
-_LT_AC_SYS_COMPILER
-
-# save warnings/boilerplate of simple test code
-_LT_COMPILER_BOILERPLATE
-_LT_LINKER_BOILERPLATE
-
-# Allow CC to be a program name with arguments.
-lt_save_CC="$CC"
-CC=${RC-"windres"}
-compiler=$CC
-_LT_AC_TAGVAR(compiler, $1)=$CC
-_LT_CC_BASENAME([$compiler])
-_LT_AC_TAGVAR(lt_cv_prog_compiler_c_o, $1)=yes
-
-AC_LIBTOOL_CONFIG($1)
-
-AC_LANG_RESTORE
-CC="$lt_save_CC"
-])# AC_LIBTOOL_LANG_RC_CONFIG
-
-
-# AC_LIBTOOL_CONFIG([TAGNAME])
-# ----------------------------
-# If TAGNAME is not passed, then create an initial libtool script
-# with a default configuration from the untagged config vars. Otherwise
-# add code to config.status for appending the configuration named by
-# TAGNAME from the matching tagged config vars.
-AC_DEFUN([AC_LIBTOOL_CONFIG],
-[# The else clause should only fire when bootstrapping the
-# libtool distribution, otherwise you forgot to ship ltmain.sh
-# with your package, and you will get complaints that there are
-# no rules to generate ltmain.sh.
-if test -f "$ltmain"; then
- # See if we are running on zsh, and set the options which allow our commands through
- # without removal of \ escapes.
- if test -n "${ZSH_VERSION+set}" ; then
- setopt NO_GLOB_SUBST
- fi
- # Now quote all the things that may contain metacharacters while being
- # careful not to overquote the AC_SUBSTed values. We take copies of the
- # variables and quote the copies for generation of the libtool script.
- for var in echo old_CC old_CFLAGS AR AR_FLAGS EGREP RANLIB LN_S LTCC LTCFLAGS NM \
- SED SHELL STRIP \
- libname_spec library_names_spec soname_spec extract_expsyms_cmds \
- old_striplib striplib file_magic_cmd finish_cmds finish_eval \
- deplibs_check_method reload_flag reload_cmds need_locks \
- lt_cv_sys_global_symbol_pipe lt_cv_sys_global_symbol_to_cdecl \
- lt_cv_sys_global_symbol_to_c_name_address \
- sys_lib_search_path_spec sys_lib_dlsearch_path_spec \
- old_postinstall_cmds old_postuninstall_cmds \
- _LT_AC_TAGVAR(compiler, $1) \
- _LT_AC_TAGVAR(CC, $1) \
- _LT_AC_TAGVAR(LD, $1) \
- _LT_AC_TAGVAR(lt_prog_compiler_wl, $1) \
- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1) \
- _LT_AC_TAGVAR(lt_prog_compiler_static, $1) \
- _LT_AC_TAGVAR(lt_prog_compiler_no_builtin_flag, $1) \
- _LT_AC_TAGVAR(export_dynamic_flag_spec, $1) \
- _LT_AC_TAGVAR(thread_safe_flag_spec, $1) \
- _LT_AC_TAGVAR(whole_archive_flag_spec, $1) \
- _LT_AC_TAGVAR(enable_shared_with_static_runtimes, $1) \
- _LT_AC_TAGVAR(old_archive_cmds, $1) \
- _LT_AC_TAGVAR(old_archive_from_new_cmds, $1) \
- _LT_AC_TAGVAR(predep_objects, $1) \
- _LT_AC_TAGVAR(postdep_objects, $1) \
- _LT_AC_TAGVAR(predeps, $1) \
- _LT_AC_TAGVAR(postdeps, $1) \
- _LT_AC_TAGVAR(compiler_lib_search_path, $1) \
- _LT_AC_TAGVAR(archive_cmds, $1) \
- _LT_AC_TAGVAR(archive_expsym_cmds, $1) \
- _LT_AC_TAGVAR(postinstall_cmds, $1) \
- _LT_AC_TAGVAR(postuninstall_cmds, $1) \
- _LT_AC_TAGVAR(old_archive_from_expsyms_cmds, $1) \
- _LT_AC_TAGVAR(allow_undefined_flag, $1) \
- _LT_AC_TAGVAR(no_undefined_flag, $1) \
- _LT_AC_TAGVAR(export_symbols_cmds, $1) \
- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1) \
- _LT_AC_TAGVAR(hardcode_libdir_flag_spec_ld, $1) \
- _LT_AC_TAGVAR(hardcode_libdir_separator, $1) \
- _LT_AC_TAGVAR(hardcode_automatic, $1) \
- _LT_AC_TAGVAR(module_cmds, $1) \
- _LT_AC_TAGVAR(module_expsym_cmds, $1) \
- _LT_AC_TAGVAR(lt_cv_prog_compiler_c_o, $1) \
- _LT_AC_TAGVAR(exclude_expsyms, $1) \
- _LT_AC_TAGVAR(include_expsyms, $1); do
-
- case $var in
- _LT_AC_TAGVAR(old_archive_cmds, $1) | \
- _LT_AC_TAGVAR(old_archive_from_new_cmds, $1) | \
- _LT_AC_TAGVAR(archive_cmds, $1) | \
- _LT_AC_TAGVAR(archive_expsym_cmds, $1) | \
- _LT_AC_TAGVAR(module_cmds, $1) | \
- _LT_AC_TAGVAR(module_expsym_cmds, $1) | \
- _LT_AC_TAGVAR(old_archive_from_expsyms_cmds, $1) | \
- _LT_AC_TAGVAR(export_symbols_cmds, $1) | \
- extract_expsyms_cmds | reload_cmds | finish_cmds | \
- postinstall_cmds | postuninstall_cmds | \
- old_postinstall_cmds | old_postuninstall_cmds | \
- sys_lib_search_path_spec | sys_lib_dlsearch_path_spec)
- # Double-quote double-evaled strings.
- eval "lt_$var=\\\"\`\$echo \"X\$$var\" | \$Xsed -e \"\$double_quote_subst\" -e \"\$sed_quote_subst\" -e \"\$delay_variable_subst\"\`\\\""
- ;;
- *)
- eval "lt_$var=\\\"\`\$echo \"X\$$var\" | \$Xsed -e \"\$sed_quote_subst\"\`\\\""
- ;;
- esac
- done
-
- case $lt_echo in
- *'\[$]0 --fallback-echo"')
- lt_echo=`$echo "X$lt_echo" | $Xsed -e 's/\\\\\\\[$]0 --fallback-echo"[$]/[$]0 --fallback-echo"/'`
- ;;
- esac
-
-ifelse([$1], [],
- [cfgfile="${ofile}T"
- trap "$rm \"$cfgfile\"; exit 1" 1 2 15
- $rm -f "$cfgfile"
- AC_MSG_NOTICE([creating $ofile])],
- [cfgfile="$ofile"])
-
- cat <<__EOF__ >> "$cfgfile"
-ifelse([$1], [],
-[#! $SHELL
-
-# `$echo "$cfgfile" | sed 's%^.*/%%'` - Provide generalized library-building support services.
-# Generated automatically by $PROGRAM (GNU $PACKAGE $VERSION$TIMESTAMP)
-# NOTE: Changes made to this file will be lost: look at ltmain.sh.
-#
-# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001
-# Free Software Foundation, Inc.
-#
-# This file is part of GNU Libtool:
-# Originally by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-#
-# This program 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 this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-#
-# As a special exception to the GNU General Public License, if you
-# distribute this file as part of a program that contains a
-# configuration script generated by Autoconf, you may include it under
-# the same distribution terms that you use for the rest of that program.
-
-# A sed program that does not truncate output.
-SED=$lt_SED
-
-# Sed that helps us avoid accidentally triggering echo(1) options like -n.
-Xsed="$SED -e 1s/^X//"
-
-# The HP-UX ksh and POSIX shell print the target directory to stdout
-# if CDPATH is set.
-(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
-
-# The names of the tagged configurations supported by this script.
-available_tags=
-
-# ### BEGIN LIBTOOL CONFIG],
-[# ### BEGIN LIBTOOL TAG CONFIG: $tagname])
-
-# Libtool was configured on host `(hostname || uname -n) 2>/dev/null | sed 1q`:
-
-# Shell to use when invoking shell scripts.
-SHELL=$lt_SHELL
-
-# Whether or not to build shared libraries.
-build_libtool_libs=$enable_shared
-
-# Whether or not to build static libraries.
-build_old_libs=$enable_static
-
-# Whether or not to add -lc for building shared libraries.
-build_libtool_need_lc=$_LT_AC_TAGVAR(archive_cmds_need_lc, $1)
-
-# Whether or not to disallow shared libs when runtime libs are static
-allow_libtool_libs_with_static_runtimes=$_LT_AC_TAGVAR(enable_shared_with_static_runtimes, $1)
-
-# Whether or not to optimize for fast installation.
-fast_install=$enable_fast_install
-
-# The host system.
-host_alias=$host_alias
-host=$host
-host_os=$host_os
-
-# The build system.
-build_alias=$build_alias
-build=$build
-build_os=$build_os
-
-# An echo program that does not interpret backslashes.
-echo=$lt_echo
-
-# The archiver.
-AR=$lt_AR
-AR_FLAGS=$lt_AR_FLAGS
-
-# A C compiler.
-LTCC=$lt_LTCC
-
-# LTCC compiler flags.
-LTCFLAGS=$lt_LTCFLAGS
-
-# A language-specific compiler.
-CC=$lt_[]_LT_AC_TAGVAR(compiler, $1)
-
-# Is the compiler the GNU C compiler?
-with_gcc=$_LT_AC_TAGVAR(GCC, $1)
-
-# An ERE matcher.
-EGREP=$lt_EGREP
-
-# The linker used to build libraries.
-LD=$lt_[]_LT_AC_TAGVAR(LD, $1)
-
-# Whether we need hard or soft links.
-LN_S=$lt_LN_S
-
-# A BSD-compatible nm program.
-NM=$lt_NM
-
-# A symbol stripping program
-STRIP=$lt_STRIP
-
-# Used to examine libraries when file_magic_cmd begins "file"
-MAGIC_CMD=$MAGIC_CMD
-
-# Used on cygwin: DLL creation program.
-DLLTOOL="$DLLTOOL"
-
-# Used on cygwin: object dumper.
-OBJDUMP="$OBJDUMP"
-
-# Used on cygwin: assembler.
-AS="$AS"
-
-# The name of the directory that contains temporary libtool files.
-objdir=$objdir
-
-# How to create reloadable object files.
-reload_flag=$lt_reload_flag
-reload_cmds=$lt_reload_cmds
-
-# How to pass a linker flag through the compiler.
-wl=$lt_[]_LT_AC_TAGVAR(lt_prog_compiler_wl, $1)
-
-# Object file suffix (normally "o").
-objext="$ac_objext"
-
-# Old archive suffix (normally "a").
-libext="$libext"
-
-# Shared library suffix (normally ".so").
-shrext_cmds='$shrext_cmds'
-
-# Executable file suffix (normally "").
-exeext="$exeext"
-
-# Additional compiler flags for building library objects.
-pic_flag=$lt_[]_LT_AC_TAGVAR(lt_prog_compiler_pic, $1)
-pic_mode=$pic_mode
-
-# What is the maximum length of a command?
-max_cmd_len=$lt_cv_sys_max_cmd_len
-
-# Does compiler simultaneously support -c and -o options?
-compiler_c_o=$lt_[]_LT_AC_TAGVAR(lt_cv_prog_compiler_c_o, $1)
-
-# Must we lock files when doing compilation?
-need_locks=$lt_need_locks
-
-# Do we need the lib prefix for modules?
-need_lib_prefix=$need_lib_prefix
-
-# Do we need a version for libraries?
-need_version=$need_version
-
-# Whether dlopen is supported.
-dlopen_support=$enable_dlopen
-
-# Whether dlopen of programs is supported.
-dlopen_self=$enable_dlopen_self
-
-# Whether dlopen of statically linked programs is supported.
-dlopen_self_static=$enable_dlopen_self_static
-
-# Compiler flag to prevent dynamic linking.
-link_static_flag=$lt_[]_LT_AC_TAGVAR(lt_prog_compiler_static, $1)
-
-# Compiler flag to turn off builtin functions.
-no_builtin_flag=$lt_[]_LT_AC_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)
-
-# Compiler flag to allow reflexive dlopens.
-export_dynamic_flag_spec=$lt_[]_LT_AC_TAGVAR(export_dynamic_flag_spec, $1)
-
-# Compiler flag to generate shared objects directly from archives.
-whole_archive_flag_spec=$lt_[]_LT_AC_TAGVAR(whole_archive_flag_spec, $1)
-
-# Compiler flag to generate thread-safe objects.
-thread_safe_flag_spec=$lt_[]_LT_AC_TAGVAR(thread_safe_flag_spec, $1)
-
-# Library versioning type.
-version_type=$version_type
-
-# Format of library name prefix.
-libname_spec=$lt_libname_spec
-
-# List of archive names. First name is the real one, the rest are links.
-# The last name is the one that the linker finds with -lNAME.
-library_names_spec=$lt_library_names_spec
-
-# The coded name of the library, if different from the real name.
-soname_spec=$lt_soname_spec
-
-# Commands used to build and install an old-style archive.
-RANLIB=$lt_RANLIB
-old_archive_cmds=$lt_[]_LT_AC_TAGVAR(old_archive_cmds, $1)
-old_postinstall_cmds=$lt_old_postinstall_cmds
-old_postuninstall_cmds=$lt_old_postuninstall_cmds
-
-# Create an old-style archive from a shared archive.
-old_archive_from_new_cmds=$lt_[]_LT_AC_TAGVAR(old_archive_from_new_cmds, $1)
-
-# Create a temporary old-style archive to link instead of a shared archive.
-old_archive_from_expsyms_cmds=$lt_[]_LT_AC_TAGVAR(old_archive_from_expsyms_cmds, $1)
-
-# Commands used to build and install a shared archive.
-archive_cmds=$lt_[]_LT_AC_TAGVAR(archive_cmds, $1)
-archive_expsym_cmds=$lt_[]_LT_AC_TAGVAR(archive_expsym_cmds, $1)
-postinstall_cmds=$lt_postinstall_cmds
-postuninstall_cmds=$lt_postuninstall_cmds
-
-# Commands used to build a loadable module (assumed same as above if empty)
-module_cmds=$lt_[]_LT_AC_TAGVAR(module_cmds, $1)
-module_expsym_cmds=$lt_[]_LT_AC_TAGVAR(module_expsym_cmds, $1)
-
-# Commands to strip libraries.
-old_striplib=$lt_old_striplib
-striplib=$lt_striplib
-
-# Dependencies to place before the objects being linked to create a
-# shared library.
-predep_objects=$lt_[]_LT_AC_TAGVAR(predep_objects, $1)
-
-# Dependencies to place after the objects being linked to create a
-# shared library.
-postdep_objects=$lt_[]_LT_AC_TAGVAR(postdep_objects, $1)
-
-# Dependencies to place before the objects being linked to create a
-# shared library.
-predeps=$lt_[]_LT_AC_TAGVAR(predeps, $1)
-
-# Dependencies to place after the objects being linked to create a
-# shared library.
-postdeps=$lt_[]_LT_AC_TAGVAR(postdeps, $1)
-
-# The library search path used internally by the compiler when linking
-# a shared library.
-compiler_lib_search_path=$lt_[]_LT_AC_TAGVAR(compiler_lib_search_path, $1)
-
-# Method to check whether dependent libraries are shared objects.
-deplibs_check_method=$lt_deplibs_check_method
-
-# Command to use when deplibs_check_method == file_magic.
-file_magic_cmd=$lt_file_magic_cmd
-
-# Flag that allows shared libraries with undefined symbols to be built.
-allow_undefined_flag=$lt_[]_LT_AC_TAGVAR(allow_undefined_flag, $1)
-
-# Flag that forces no undefined symbols.
-no_undefined_flag=$lt_[]_LT_AC_TAGVAR(no_undefined_flag, $1)
-
-# Commands used to finish a libtool library installation in a directory.
-finish_cmds=$lt_finish_cmds
-
-# Same as above, but a single script fragment to be evaled but not shown.
-finish_eval=$lt_finish_eval
-
-# Take the output of nm and produce a listing of raw symbols and C names.
-global_symbol_pipe=$lt_lt_cv_sys_global_symbol_pipe
-
-# Transform the output of nm in a proper C declaration
-global_symbol_to_cdecl=$lt_lt_cv_sys_global_symbol_to_cdecl
-
-# Transform the output of nm in a C name address pair
-global_symbol_to_c_name_address=$lt_lt_cv_sys_global_symbol_to_c_name_address
-
-# This is the shared library runtime path variable.
-runpath_var=$runpath_var
-
-# This is the shared library path variable.
-shlibpath_var=$shlibpath_var
-
-# Is shlibpath searched before the hard-coded library search path?
-shlibpath_overrides_runpath=$shlibpath_overrides_runpath
-
-# How to hardcode a shared library path into an executable.
-hardcode_action=$_LT_AC_TAGVAR(hardcode_action, $1)
-
-# Whether we should hardcode library paths into libraries.
-hardcode_into_libs=$hardcode_into_libs
-
-# Flag to hardcode \$libdir into a binary during linking.
-# This must work even if \$libdir does not exist.
-hardcode_libdir_flag_spec=$lt_[]_LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)
-
-# If ld is used when linking, flag to hardcode \$libdir into
-# a binary during linking. This must work even if \$libdir does
-# not exist.
-hardcode_libdir_flag_spec_ld=$lt_[]_LT_AC_TAGVAR(hardcode_libdir_flag_spec_ld, $1)
-
-# Whether we need a single -rpath flag with a separated argument.
-hardcode_libdir_separator=$lt_[]_LT_AC_TAGVAR(hardcode_libdir_separator, $1)
-
-# Set to yes if using DIR/libNAME${shared_ext} during linking hardcodes DIR into the
-# resulting binary.
-hardcode_direct=$_LT_AC_TAGVAR(hardcode_direct, $1)
-
-# Set to yes if using the -LDIR flag during linking hardcodes DIR into the
-# resulting binary.
-hardcode_minus_L=$_LT_AC_TAGVAR(hardcode_minus_L, $1)
-
-# Set to yes if using SHLIBPATH_VAR=DIR during linking hardcodes DIR into
-# the resulting binary.
-hardcode_shlibpath_var=$_LT_AC_TAGVAR(hardcode_shlibpath_var, $1)
-
-# Set to yes if building a shared library automatically hardcodes DIR into the library
-# and all subsequent libraries and executables linked against it.
-hardcode_automatic=$_LT_AC_TAGVAR(hardcode_automatic, $1)
-
-# Variables whose values should be saved in libtool wrapper scripts and
-# restored at relink time.
-variables_saved_for_relink="$variables_saved_for_relink"
-
-# Whether libtool must link a program against all its dependency libraries.
-link_all_deplibs=$_LT_AC_TAGVAR(link_all_deplibs, $1)
-
-# Compile-time system search path for libraries
-sys_lib_search_path_spec=$lt_sys_lib_search_path_spec
-
-# Run-time system search path for libraries
-sys_lib_dlsearch_path_spec=$lt_sys_lib_dlsearch_path_spec
-
-# Fix the shell variable \$srcfile for the compiler.
-fix_srcfile_path="$_LT_AC_TAGVAR(fix_srcfile_path, $1)"
-
-# Set to yes if exported symbols are required.
-always_export_symbols=$_LT_AC_TAGVAR(always_export_symbols, $1)
-
-# The commands to list exported symbols.
-export_symbols_cmds=$lt_[]_LT_AC_TAGVAR(export_symbols_cmds, $1)
-
-# The commands to extract the exported symbol list from a shared archive.
-extract_expsyms_cmds=$lt_extract_expsyms_cmds
-
-# Symbols that should not be listed in the preloaded symbols.
-exclude_expsyms=$lt_[]_LT_AC_TAGVAR(exclude_expsyms, $1)
-
-# Symbols that must always be exported.
-include_expsyms=$lt_[]_LT_AC_TAGVAR(include_expsyms, $1)
-
-ifelse([$1],[],
-[# ### END LIBTOOL CONFIG],
-[# ### END LIBTOOL TAG CONFIG: $tagname])
-
-__EOF__
-
-ifelse([$1],[], [
- case $host_os in
- aix3*)
- cat <<\EOF >> "$cfgfile"
-
-# AIX sometimes has problems with the GCC collect2 program. For some
-# reason, if we set the COLLECT_NAMES environment variable, the problems
-# vanish in a puff of smoke.
-if test "X${COLLECT_NAMES+set}" != Xset; then
- COLLECT_NAMES=
- export COLLECT_NAMES
-fi
-EOF
- ;;
- esac
-
- # We use sed instead of cat because bash on DJGPP gets confused if
- # if finds mixed CR/LF and LF-only lines. Since sed operates in
- # text mode, it properly converts lines to CR/LF. This bash problem
- # is reportedly fixed, but why not run on old versions too?
- sed '$q' "$ltmain" >> "$cfgfile" || (rm -f "$cfgfile"; exit 1)
-
- mv -f "$cfgfile" "$ofile" || \
- (rm -f "$ofile" && cp "$cfgfile" "$ofile" && rm -f "$cfgfile")
- chmod +x "$ofile"
-])
-else
- # If there is no Makefile yet, we rely on a make rule to execute
- # `config.status --recheck' to rerun these tests and create the
- # libtool script then.
- ltmain_in=`echo $ltmain | sed -e 's/\.sh$/.in/'`
- if test -f "$ltmain_in"; then
- test -f Makefile && make "$ltmain"
- fi
-fi
-])# AC_LIBTOOL_CONFIG
-
-
-# AC_LIBTOOL_PROG_COMPILER_NO_RTTI([TAGNAME])
-# -------------------------------------------
-AC_DEFUN([AC_LIBTOOL_PROG_COMPILER_NO_RTTI],
-[AC_REQUIRE([_LT_AC_SYS_COMPILER])dnl
-
-_LT_AC_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=
-
-if test "$GCC" = yes; then
- _LT_AC_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=' -fno-builtin'
-
- AC_LIBTOOL_COMPILER_OPTION([if $compiler supports -fno-rtti -fno-exceptions],
- lt_cv_prog_compiler_rtti_exceptions,
- [-fno-rtti -fno-exceptions], [],
- [_LT_AC_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)="$_LT_AC_TAGVAR(lt_prog_compiler_no_builtin_flag, $1) -fno-rtti -fno-exceptions"])
-fi
-])# AC_LIBTOOL_PROG_COMPILER_NO_RTTI
-
-
-# AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE
-# ---------------------------------
-AC_DEFUN([AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE],
-[AC_REQUIRE([AC_CANONICAL_HOST])
-AC_REQUIRE([AC_PROG_NM])
-AC_REQUIRE([AC_OBJEXT])
-# Check for command to grab the raw symbol name followed by C symbol from nm.
-AC_MSG_CHECKING([command to parse $NM output from $compiler object])
-AC_CACHE_VAL([lt_cv_sys_global_symbol_pipe],
-[
-# These are sane defaults that work on at least a few old systems.
-# [They come from Ultrix. What could be older than Ultrix?!! ;)]
-
-# Character class describing NM global symbol codes.
-symcode='[[BCDEGRST]]'
-
-# Regexp to match symbols that can be accessed directly from C.
-sympat='\([[_A-Za-z]][[_A-Za-z0-9]]*\)'
-
-# Transform an extracted symbol line into a proper C declaration
-lt_cv_sys_global_symbol_to_cdecl="sed -n -e 's/^. .* \(.*\)$/extern int \1;/p'"
-
-# Transform an extracted symbol line into symbol name and symbol address
-lt_cv_sys_global_symbol_to_c_name_address="sed -n -e 's/^: \([[^ ]]*\) $/ {\\\"\1\\\", (lt_ptr) 0},/p' -e 's/^$symcode \([[^ ]]*\) \([[^ ]]*\)$/ {\"\2\", (lt_ptr) \&\2},/p'"
-
-# Define system-specific variables.
-case $host_os in
-aix*)
- symcode='[[BCDT]]'
- ;;
-cygwin* | mingw* | pw32*)
- symcode='[[ABCDGISTW]]'
- ;;
-hpux*) # Its linker distinguishes data from code symbols
- if test "$host_cpu" = ia64; then
- symcode='[[ABCDEGRST]]'
- fi
- lt_cv_sys_global_symbol_to_cdecl="sed -n -e 's/^T .* \(.*\)$/extern int \1();/p' -e 's/^$symcode* .* \(.*\)$/extern char \1;/p'"
- lt_cv_sys_global_symbol_to_c_name_address="sed -n -e 's/^: \([[^ ]]*\) $/ {\\\"\1\\\", (lt_ptr) 0},/p' -e 's/^$symcode* \([[^ ]]*\) \([[^ ]]*\)$/ {\"\2\", (lt_ptr) \&\2},/p'"
- ;;
-linux*)
- if test "$host_cpu" = ia64; then
- symcode='[[ABCDGIRSTW]]'
- lt_cv_sys_global_symbol_to_cdecl="sed -n -e 's/^T .* \(.*\)$/extern int \1();/p' -e 's/^$symcode* .* \(.*\)$/extern char \1;/p'"
- lt_cv_sys_global_symbol_to_c_name_address="sed -n -e 's/^: \([[^ ]]*\) $/ {\\\"\1\\\", (lt_ptr) 0},/p' -e 's/^$symcode* \([[^ ]]*\) \([[^ ]]*\)$/ {\"\2\", (lt_ptr) \&\2},/p'"
- fi
- ;;
-irix* | nonstopux*)
- symcode='[[BCDEGRST]]'
- ;;
-osf*)
- symcode='[[BCDEGQRST]]'
- ;;
-solaris*)
- symcode='[[BDRT]]'
- ;;
-sco3.2v5*)
- symcode='[[DT]]'
- ;;
-sysv4.2uw2*)
- symcode='[[DT]]'
- ;;
-sysv5* | sco5v6* | unixware* | OpenUNIX*)
- symcode='[[ABDT]]'
- ;;
-sysv4)
- symcode='[[DFNSTU]]'
- ;;
-esac
-
-# Handle CRLF in mingw tool chain
-opt_cr=
-case $build_os in
-mingw*)
- opt_cr=`echo 'x\{0,1\}' | tr x '\015'` # option cr in regexp
- ;;
-esac
-
-# If we're using GNU nm, then use its standard symbol codes.
-case `$NM -V 2>&1` in
-*GNU* | *'with BFD'*)
- symcode='[[ABCDGIRSTW]]' ;;
-esac
-
-# Try without a prefix undercore, then with it.
-for ac_symprfx in "" "_"; do
-
- # Transform symcode, sympat, and symprfx into a raw symbol and a C symbol.
- symxfrm="\\1 $ac_symprfx\\2 \\2"
-
- # Write the raw and C identifiers.
- lt_cv_sys_global_symbol_pipe="sed -n -e 's/^.*[[ ]]\($symcode$symcode*\)[[ ]][[ ]]*$ac_symprfx$sympat$opt_cr$/$symxfrm/p'"
-
- # Check to see that the pipe works correctly.
- pipe_works=no
-
- rm -f conftest*
- cat > conftest.$ac_ext <<EOF
-#ifdef __cplusplus
-extern "C" {
-#endif
-char nm_test_var;
-void nm_test_func(){}
-#ifdef __cplusplus
-}
-#endif
-int main(){nm_test_var='a';nm_test_func();return(0);}
-EOF
-
- if AC_TRY_EVAL(ac_compile); then
- # Now try to grab the symbols.
- nlist=conftest.nm
- if AC_TRY_EVAL(NM conftest.$ac_objext \| $lt_cv_sys_global_symbol_pipe \> $nlist) && test -s "$nlist"; then
- # Try sorting and uniquifying the output.
- if sort "$nlist" | uniq > "$nlist"T; then
- mv -f "$nlist"T "$nlist"
- else
- rm -f "$nlist"T
- fi
-
- # Make sure that we snagged all the symbols we need.
- if grep ' nm_test_var$' "$nlist" >/dev/null; then
- if grep ' nm_test_func$' "$nlist" >/dev/null; then
- cat <<EOF > conftest.$ac_ext
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-EOF
- # Now generate the symbol file.
- eval "$lt_cv_sys_global_symbol_to_cdecl"' < "$nlist" | grep -v main >> conftest.$ac_ext'
-
- cat <<EOF >> conftest.$ac_ext
-#if defined (__STDC__) && __STDC__
-# define lt_ptr_t void *
-#else
-# define lt_ptr_t char *
-# define const
-#endif
-
-/* The mapping between symbol names and symbols. */
-const struct {
- const char *name;
- lt_ptr_t address;
-}
-lt_preloaded_symbols[[]] =
-{
-EOF
- $SED "s/^$symcode$symcode* \(.*\) \(.*\)$/ {\"\2\", (lt_ptr_t) \&\2},/" < "$nlist" | grep -v main >> conftest.$ac_ext
- cat <<\EOF >> conftest.$ac_ext
- {0, (lt_ptr_t) 0}
-};
-
-#ifdef __cplusplus
-}
-#endif
-EOF
- # Now try linking the two files.
- mv conftest.$ac_objext conftstm.$ac_objext
- lt_save_LIBS="$LIBS"
- lt_save_CFLAGS="$CFLAGS"
- LIBS="conftstm.$ac_objext"
- CFLAGS="$CFLAGS$_LT_AC_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)"
- if AC_TRY_EVAL(ac_link) && test -s conftest${ac_exeext}; then
- pipe_works=yes
- fi
- LIBS="$lt_save_LIBS"
- CFLAGS="$lt_save_CFLAGS"
- else
- echo "cannot find nm_test_func in $nlist" >&AS_MESSAGE_LOG_FD
- fi
- else
- echo "cannot find nm_test_var in $nlist" >&AS_MESSAGE_LOG_FD
- fi
- else
- echo "cannot run $lt_cv_sys_global_symbol_pipe" >&AS_MESSAGE_LOG_FD
- fi
- else
- echo "$progname: failed program was:" >&AS_MESSAGE_LOG_FD
- cat conftest.$ac_ext >&5
- fi
- rm -f conftest* conftst*
-
- # Do not use the global_symbol_pipe unless it works.
- if test "$pipe_works" = yes; then
- break
- else
- lt_cv_sys_global_symbol_pipe=
- fi
-done
-])
-if test -z "$lt_cv_sys_global_symbol_pipe"; then
- lt_cv_sys_global_symbol_to_cdecl=
-fi
-if test -z "$lt_cv_sys_global_symbol_pipe$lt_cv_sys_global_symbol_to_cdecl"; then
- AC_MSG_RESULT(failed)
-else
- AC_MSG_RESULT(ok)
-fi
-]) # AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE
-
-
-# AC_LIBTOOL_PROG_COMPILER_PIC([TAGNAME])
-# ---------------------------------------
-AC_DEFUN([AC_LIBTOOL_PROG_COMPILER_PIC],
-[_LT_AC_TAGVAR(lt_prog_compiler_wl, $1)=
-_LT_AC_TAGVAR(lt_prog_compiler_pic, $1)=
-_LT_AC_TAGVAR(lt_prog_compiler_static, $1)=
-
-AC_MSG_CHECKING([for $compiler option to produce PIC])
- ifelse([$1],[CXX],[
- # C++ specific cases for pic, static, wl, etc.
- if test "$GXX" = yes; then
- _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
- _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-static'
-
- case $host_os in
- aix*)
- # All AIX code is PIC.
- if test "$host_cpu" = ia64; then
- # AIX 5 now supports IA64 processor
- _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
- fi
- ;;
- amigaos*)
- # FIXME: we need at least 68020 code to build shared libraries, but
- # adding the `-m68020' flag to GCC prevents building anything better,
- # like `-m68040'.
- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-m68020 -resident32 -malways-restore-a4'
- ;;
- beos* | cygwin* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*)
- # PIC is the default for these OSes.
- ;;
- mingw* | os2* | pw32*)
- # This hack is so that the source file can tell whether it is being
- # built for inclusion in a dll (and should export symbols for example).
- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT'
- ;;
- darwin* | rhapsody*)
- # PIC is the default on this platform
- # Common symbols not allowed in MH_DYLIB files
- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-fno-common'
- ;;
- *djgpp*)
- # DJGPP does not support shared libraries at all
- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)=
- ;;
- interix3*)
- # Interix 3.x gcc -fpic/-fPIC options generate broken code.
- # Instead, we relocate shared libraries at runtime.
- ;;
- sysv4*MP*)
- if test -d /usr/nec; then
- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)=-Kconform_pic
- fi
- ;;
- hpux*)
- # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but
- # not for PA HP-UX.
- case $host_cpu in
- hppa*64*|ia64*)
- ;;
- *)
- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
- ;;
- esac
- ;;
- *)
- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
- ;;
- esac
- else
- case $host_os in
- aix4* | aix5*)
- # All AIX code is PIC.
- if test "$host_cpu" = ia64; then
- # AIX 5 now supports IA64 processor
- _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
- else
- _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-bnso -bI:/lib/syscalls.exp'
- fi
- ;;
- chorus*)
- case $cc_basename in
- cxch68*)
- # Green Hills C++ Compiler
- # _LT_AC_TAGVAR(lt_prog_compiler_static, $1)="--no_auto_instantiation -u __main -u __premain -u _abort -r $COOL_DIR/lib/libOrb.a $MVME_DIR/lib/CC/libC.a $MVME_DIR/lib/classix/libcx.s.a"
- ;;
- esac
- ;;
- darwin*)
- # PIC is the default on this platform
- # Common symbols not allowed in MH_DYLIB files
- case $cc_basename in
- xlc*)
- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-qnocommon'
- _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
- ;;
- esac
- ;;
- dgux*)
- case $cc_basename in
- ec++*)
- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
- ;;
- ghcx*)
- # Green Hills C++ Compiler
- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-pic'
- ;;
- *)
- ;;
- esac
- ;;
- freebsd* | kfreebsd*-gnu | dragonfly*)
- # FreeBSD uses GNU C++
- ;;
- hpux9* | hpux10* | hpux11*)
- case $cc_basename in
- CC*)
- _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
- _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='${wl}-a ${wl}archive'
- if test "$host_cpu" != ia64; then
- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='+Z'
- fi
- ;;
- aCC*)
- _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
- _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='${wl}-a ${wl}archive'
- case $host_cpu in
- hppa*64*|ia64*)
- # +Z the default
- ;;
- *)
- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='+Z'
- ;;
- esac
- ;;
- *)
- ;;
- esac
- ;;
- interix*)
- # This is c89, which is MS Visual C++ (no shared libs)
- # Anyone wants to do a port?
- ;;
- irix5* | irix6* | nonstopux*)
- case $cc_basename in
- CC*)
- _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
- _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-non_shared'
- # CC pic flag -KPIC is the default.
- ;;
- *)
- ;;
- esac
- ;;
- linux*)
- case $cc_basename in
- KCC*)
- # KAI C++ Compiler
- _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='--backend -Wl,'
- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
- ;;
- icpc* | ecpc*)
- # Intel C++
- _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
- _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-static'
- ;;
- pgCC*)
- # Portland Group C++ compiler.
- _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-fpic'
- _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
- ;;
- cxx*)
- # Compaq C++
- # Make sure the PIC flag is empty. It appears that all Alpha
- # Linux and Compaq Tru64 Unix objects are PIC.
- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)=
- _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-non_shared'
- ;;
- *)
- ;;
- esac
- ;;
- lynxos*)
- ;;
- m88k*)
- ;;
- mvs*)
- case $cc_basename in
- cxx*)
- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-W c,exportall'
- ;;
- *)
- ;;
- esac
- ;;
- netbsd* | netbsdelf*-gnu | knetbsd*-gnu)
- ;;
- osf3* | osf4* | osf5*)
- case $cc_basename in
- KCC*)
- _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='--backend -Wl,'
- ;;
- RCC*)
- # Rational C++ 2.4.1
- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-pic'
- ;;
- cxx*)
- # Digital/Compaq C++
- _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
- # Make sure the PIC flag is empty. It appears that all Alpha
- # Linux and Compaq Tru64 Unix objects are PIC.
- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)=
- _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-non_shared'
- ;;
- *)
- ;;
- esac
- ;;
- psos*)
- ;;
- solaris*)
- case $cc_basename in
- CC*)
- # Sun C++ 4.2, 5.x and Centerline C++
- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
- _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
- _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld '
- ;;
- gcx*)
- # Green Hills C++ Compiler
- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-PIC'
- ;;
- *)
- ;;
- esac
- ;;
- sunos4*)
- case $cc_basename in
- CC*)
- # Sun C++ 4.x
- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-pic'
- _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
- ;;
- lcc*)
- # Lucid
- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-pic'
- ;;
- *)
- ;;
- esac
- ;;
- tandem*)
- case $cc_basename in
- NCC*)
- # NonStop-UX NCC 3.20
- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
- ;;
- *)
- ;;
- esac
- ;;
- sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*)
- case $cc_basename in
- CC*)
- _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
- _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
- ;;
- esac
- ;;
- vxworks*)
- ;;
- *)
- _LT_AC_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no
- ;;
- esac
- fi
-],
-[
- if test "$GCC" = yes; then
- _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
- _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-static'
-
- case $host_os in
- aix*)
- # All AIX code is PIC.
- if test "$host_cpu" = ia64; then
- # AIX 5 now supports IA64 processor
- _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
- fi
- ;;
-
- amigaos*)
- # FIXME: we need at least 68020 code to build shared libraries, but
- # adding the `-m68020' flag to GCC prevents building anything better,
- # like `-m68040'.
- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-m68020 -resident32 -malways-restore-a4'
- ;;
-
- beos* | cygwin* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*)
- # PIC is the default for these OSes.
- ;;
-
- mingw* | pw32* | os2*)
- # This hack is so that the source file can tell whether it is being
- # built for inclusion in a dll (and should export symbols for example).
- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT'
- ;;
-
- darwin* | rhapsody*)
- # PIC is the default on this platform
- # Common symbols not allowed in MH_DYLIB files
- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-fno-common'
- ;;
-
- interix3*)
- # Interix 3.x gcc -fpic/-fPIC options generate broken code.
- # Instead, we relocate shared libraries at runtime.
- ;;
-
- msdosdjgpp*)
- # Just because we use GCC doesn't mean we suddenly get shared libraries
- # on systems that don't support them.
- _LT_AC_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no
- enable_shared=no
- ;;
-
- sysv4*MP*)
- if test -d /usr/nec; then
- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)=-Kconform_pic
- fi
- ;;
-
- hpux*)
- # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but
- # not for PA HP-UX.
- case $host_cpu in
- hppa*64*|ia64*)
- # +Z the default
- ;;
- *)
- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
- ;;
- esac
- ;;
-
- *)
- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
- ;;
- esac
- else
- # PORTME Check for flag to pass linker flags through the system compiler.
- case $host_os in
- aix*)
- _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
- if test "$host_cpu" = ia64; then
- # AIX 5 now supports IA64 processor
- _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
- else
- _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-bnso -bI:/lib/syscalls.exp'
- fi
- ;;
- darwin*)
- # PIC is the default on this platform
- # Common symbols not allowed in MH_DYLIB files
- case $cc_basename in
- xlc*)
- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-qnocommon'
- _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
- ;;
- esac
- ;;
-
- mingw* | pw32* | os2*)
- # This hack is so that the source file can tell whether it is being
- # built for inclusion in a dll (and should export symbols for example).
- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT'
- ;;
-
- hpux9* | hpux10* | hpux11*)
- _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
- # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but
- # not for PA HP-UX.
- case $host_cpu in
- hppa*64*|ia64*)
- # +Z the default
- ;;
- *)
- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='+Z'
- ;;
- esac
- # Is there a better lt_prog_compiler_static that works with the bundled CC?
- _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='${wl}-a ${wl}archive'
- ;;
-
- irix5* | irix6* | nonstopux*)
- _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
- # PIC (with -KPIC) is the default.
- _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-non_shared'
- ;;
-
- newsos6)
- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
- _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
- ;;
-
- linux*)
- case $cc_basename in
- icc* | ecc*)
- _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
- _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-static'
- ;;
- pgcc* | pgf77* | pgf90* | pgf95*)
- # Portland Group compilers (*not* the Pentium gcc compiler,
- # which looks to be a dead project)
- _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-fpic'
- _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
- ;;
- ccc*)
- _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
- # All Alpha code is PIC.
- _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-non_shared'
- ;;
- esac
- ;;
-
- osf3* | osf4* | osf5*)
- _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
- # All OSF/1 code is PIC.
- _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-non_shared'
- ;;
-
- solaris*)
- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
- _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
- case $cc_basename in
- f77* | f90* | f95*)
- _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld ';;
- *)
- _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,';;
- esac
- ;;
-
- sunos4*)
- _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld '
- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-PIC'
- _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
- ;;
-
- sysv4 | sysv4.2uw2* | sysv4.3*)
- _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
- _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
- ;;
-
- sysv4*MP*)
- if test -d /usr/nec ;then
- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-Kconform_pic'
- _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
- fi
- ;;
-
- sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*)
- _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
- _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
- ;;
-
- unicos*)
- _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
- _LT_AC_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no
- ;;
-
- uts4*)
- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-pic'
- _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
- ;;
-
- *)
- _LT_AC_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no
- ;;
- esac
- fi
-])
-AC_MSG_RESULT([$_LT_AC_TAGVAR(lt_prog_compiler_pic, $1)])
-
-#
-# Check to make sure the PIC flag actually works.
-#
-if test -n "$_LT_AC_TAGVAR(lt_prog_compiler_pic, $1)"; then
- AC_LIBTOOL_COMPILER_OPTION([if $compiler PIC flag $_LT_AC_TAGVAR(lt_prog_compiler_pic, $1) works],
- _LT_AC_TAGVAR(lt_prog_compiler_pic_works, $1),
- [$_LT_AC_TAGVAR(lt_prog_compiler_pic, $1)ifelse([$1],[],[ -DPIC],[ifelse([$1],[CXX],[ -DPIC],[])])], [],
- [case $_LT_AC_TAGVAR(lt_prog_compiler_pic, $1) in
- "" | " "*) ;;
- *) _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)=" $_LT_AC_TAGVAR(lt_prog_compiler_pic, $1)" ;;
- esac],
- [_LT_AC_TAGVAR(lt_prog_compiler_pic, $1)=
- _LT_AC_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no])
-fi
-case $host_os in
- # For platforms which do not support PIC, -DPIC is meaningless:
- *djgpp*)
- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)=
- ;;
- *)
- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)="$_LT_AC_TAGVAR(lt_prog_compiler_pic, $1)ifelse([$1],[],[ -DPIC],[ifelse([$1],[CXX],[ -DPIC],[])])"
- ;;
-esac
-
-#
-# Check to make sure the static flag actually works.
-#
-wl=$_LT_AC_TAGVAR(lt_prog_compiler_wl, $1) eval lt_tmp_static_flag=\"$_LT_AC_TAGVAR(lt_prog_compiler_static, $1)\"
-AC_LIBTOOL_LINKER_OPTION([if $compiler static flag $lt_tmp_static_flag works],
- _LT_AC_TAGVAR(lt_prog_compiler_static_works, $1),
- $lt_tmp_static_flag,
- [],
- [_LT_AC_TAGVAR(lt_prog_compiler_static, $1)=])
-])
-
-
-# AC_LIBTOOL_PROG_LD_SHLIBS([TAGNAME])
-# ------------------------------------
-# See if the linker supports building shared libraries.
-AC_DEFUN([AC_LIBTOOL_PROG_LD_SHLIBS],
-[AC_MSG_CHECKING([whether the $compiler linker ($LD) supports shared libraries])
-ifelse([$1],[CXX],[
- _LT_AC_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols'
- case $host_os in
- aix4* | aix5*)
- # If we're using GNU nm, then we don't want the "-C" option.
- # -C means demangle to AIX nm, but means don't demangle with GNU nm
- if $NM -V 2>&1 | grep 'GNU' > /dev/null; then
- _LT_AC_TAGVAR(export_symbols_cmds, $1)='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\[$]2 == "T") || (\[$]2 == "D") || (\[$]2 == "B")) && ([substr](\[$]3,1,1) != ".")) { print \[$]3 } }'\'' | sort -u > $export_symbols'
- else
- _LT_AC_TAGVAR(export_symbols_cmds, $1)='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\[$]2 == "T") || (\[$]2 == "D") || (\[$]2 == "B")) && ([substr](\[$]3,1,1) != ".")) { print \[$]3 } }'\'' | sort -u > $export_symbols'
- fi
- ;;
- pw32*)
- _LT_AC_TAGVAR(export_symbols_cmds, $1)="$ltdll_cmds"
- ;;
- cygwin* | mingw*)
- _LT_AC_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[[BCDGRS]] /s/.* \([[^ ]]*\)/\1 DATA/;/^.* __nm__/s/^.* __nm__\([[^ ]]*\) [[^ ]]*/\1 DATA/;/^I /d;/^[[AITW]] /s/.* //'\'' | sort | uniq > $export_symbols'
- ;;
- kfreebsd*-gnu)
- _LT_AC_TAGVAR(link_all_deplibs, $1)=no
- ;;
- linux*)
- _LT_AC_TAGVAR(link_all_deplibs, $1)=no
- ;;
- *)
- _LT_AC_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols'
- ;;
- esac
-],[
- runpath_var=
- _LT_AC_TAGVAR(allow_undefined_flag, $1)=
- _LT_AC_TAGVAR(enable_shared_with_static_runtimes, $1)=no
- _LT_AC_TAGVAR(archive_cmds, $1)=
- _LT_AC_TAGVAR(archive_expsym_cmds, $1)=
- _LT_AC_TAGVAR(old_archive_From_new_cmds, $1)=
- _LT_AC_TAGVAR(old_archive_from_expsyms_cmds, $1)=
- _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)=
- _LT_AC_TAGVAR(whole_archive_flag_spec, $1)=
- _LT_AC_TAGVAR(thread_safe_flag_spec, $1)=
- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)=
- _LT_AC_TAGVAR(hardcode_libdir_flag_spec_ld, $1)=
- _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=
- _LT_AC_TAGVAR(hardcode_direct, $1)=no
- _LT_AC_TAGVAR(hardcode_minus_L, $1)=no
- _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=unsupported
- _LT_AC_TAGVAR(link_all_deplibs, $1)=unknown
- _LT_AC_TAGVAR(hardcode_automatic, $1)=no
- _LT_AC_TAGVAR(module_cmds, $1)=
- _LT_AC_TAGVAR(module_expsym_cmds, $1)=
- _LT_AC_TAGVAR(always_export_symbols, $1)=no
- _LT_AC_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols'
- # include_expsyms should be a list of space-separated symbols to be *always*
- # included in the symbol list
- _LT_AC_TAGVAR(include_expsyms, $1)=
- # exclude_expsyms can be an extended regexp of symbols to exclude
- # it will be wrapped by ` (' and `)$', so one must not match beginning or
- # end of line. Example: `a|bc|.*d.*' will exclude the symbols `a' and `bc',
- # as well as any symbol that contains `d'.
- _LT_AC_TAGVAR(exclude_expsyms, $1)="_GLOBAL_OFFSET_TABLE_"
- # Although _GLOBAL_OFFSET_TABLE_ is a valid symbol C name, most a.out
- # platforms (ab)use it in PIC code, but their linkers get confused if
- # the symbol is explicitly referenced. Since portable code cannot
- # rely on this symbol name, it's probably fine to never include it in
- # preloaded symbol tables.
- extract_expsyms_cmds=
- # Just being paranoid about ensuring that cc_basename is set.
- _LT_CC_BASENAME([$compiler])
- case $host_os in
- cygwin* | mingw* | pw32*)
- # FIXME: the MSVC++ port hasn't been tested in a loooong time
- # When not using gcc, we currently assume that we are using
- # Microsoft Visual C++.
- if test "$GCC" != yes; then
- with_gnu_ld=no
- fi
- ;;
- interix*)
- # we just hope/assume this is gcc and not c89 (= MSVC++)
- with_gnu_ld=yes
- ;;
- openbsd*)
- with_gnu_ld=no
- ;;
- esac
-
- _LT_AC_TAGVAR(ld_shlibs, $1)=yes
- if test "$with_gnu_ld" = yes; then
- # If archive_cmds runs LD, not CC, wlarc should be empty
- wlarc='${wl}'
-
- # Set some defaults for GNU ld with shared library support. These
- # are reset later if shared libraries are not supported. Putting them
- # here allows them to be overridden if necessary.
- runpath_var=LD_RUN_PATH
- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}--rpath ${wl}$libdir'
- _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic'
- # ancient GNU ld didn't support --whole-archive et. al.
- if $LD --help 2>&1 | grep 'no-whole-archive' > /dev/null; then
- _LT_AC_TAGVAR(whole_archive_flag_spec, $1)="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive'
- else
- _LT_AC_TAGVAR(whole_archive_flag_spec, $1)=
- fi
- supports_anon_versioning=no
- case `$LD -v 2>/dev/null` in
- *\ [[01]].* | *\ 2.[[0-9]].* | *\ 2.10.*) ;; # catch versions < 2.11
- *\ 2.11.93.0.2\ *) supports_anon_versioning=yes ;; # RH7.3 ...
- *\ 2.11.92.0.12\ *) supports_anon_versioning=yes ;; # Mandrake 8.2 ...
- *\ 2.11.*) ;; # other 2.11 versions
- *) supports_anon_versioning=yes ;;
- esac
-
- # See if GNU ld supports shared libraries.
- case $host_os in
- aix3* | aix4* | aix5*)
- # On AIX/PPC, the GNU linker is very broken
- if test "$host_cpu" != ia64; then
- _LT_AC_TAGVAR(ld_shlibs, $1)=no
- cat <<EOF 1>&2
-
-*** Warning: the GNU linker, at least up to release 2.9.1, is reported
-*** to be unable to reliably create shared libraries on AIX.
-*** Therefore, libtool is disabling shared libraries support. If you
-*** really care for shared libraries, you may want to modify your PATH
-*** so that a non-GNU linker is found, and then restart.
-
-EOF
- fi
- ;;
-
- amigaos*)
- _LT_AC_TAGVAR(archive_cmds, $1)='$rm $output_objdir/a2ixlibrary.data~$echo "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$echo "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$echo "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$echo "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)'
- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
- _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes
-
- # Samuel A. Falvo II <kc5tja@dolphin.openprojects.net> reports
- # that the semantics of dynamic libraries on AmigaOS, at least up
- # to version 4, is to share data among multiple programs linked
- # with the same dynamic library. Since this doesn't match the
- # behavior of shared libraries on other platforms, we can't use
- # them.
- _LT_AC_TAGVAR(ld_shlibs, $1)=no
- ;;
-
- beos*)
- if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
- _LT_AC_TAGVAR(allow_undefined_flag, $1)=unsupported
- # Joseph Beckenbach <jrb3@best.com> says some releases of gcc
- # support --undefined. This deserves some investigation. FIXME
- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
- else
- _LT_AC_TAGVAR(ld_shlibs, $1)=no
- fi
- ;;
-
- cygwin* | mingw* | pw32*)
- # _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1) is actually meaningless,
- # as there is no search path for DLLs.
- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
- _LT_AC_TAGVAR(allow_undefined_flag, $1)=unsupported
- _LT_AC_TAGVAR(always_export_symbols, $1)=no
- _LT_AC_TAGVAR(enable_shared_with_static_runtimes, $1)=yes
- _LT_AC_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[[BCDGRS]] /s/.* \([[^ ]]*\)/\1 DATA/'\'' | $SED -e '\''/^[[AITW]] /s/.* //'\'' | sort | uniq > $export_symbols'
-
- if $LD --help 2>&1 | grep 'auto-import' > /dev/null; then
- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
- # If the export-symbols file already is a .def file (1st line
- # is EXPORTS), use it as is; otherwise, prepend...
- _LT_AC_TAGVAR(archive_expsym_cmds, $1)='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then
- cp $export_symbols $output_objdir/$soname.def;
- else
- echo EXPORTS > $output_objdir/$soname.def;
- cat $export_symbols >> $output_objdir/$soname.def;
- fi~
- $CC -shared $output_objdir/$soname.def $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
- else
- _LT_AC_TAGVAR(ld_shlibs, $1)=no
- fi
- ;;
-
- interix3*)
- _LT_AC_TAGVAR(hardcode_direct, $1)=no
- _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
- _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
- # Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc.
- # Instead, shared libraries are loaded at an image base (0x10000000 by
- # default) and relocated if they conflict, which is a slow very memory
- # consuming and fragmenting process. To avoid this, we pick a random,
- # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link
- # time. Moving up from 0x10000000 also allows more sbrk(2) space.
- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
- _LT_AC_TAGVAR(archive_expsym_cmds, $1)='sed "s,^,_," $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--retain-symbols-file,$output_objdir/$soname.expsym ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
- ;;
-
- linux*)
- if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
- tmp_addflag=
- case $cc_basename,$host_cpu in
- pgcc*) # Portland Group C compiler
- _LT_AC_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}--no-whole-archive'
- tmp_addflag=' $pic_flag'
- ;;
- pgf77* | pgf90* | pgf95*) # Portland Group f77 and f90 compilers
- _LT_AC_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}--no-whole-archive'
- tmp_addflag=' $pic_flag -Mnomain' ;;
- ecc*,ia64* | icc*,ia64*) # Intel C compiler on ia64
- tmp_addflag=' -i_dynamic' ;;
- efc*,ia64* | ifort*,ia64*) # Intel Fortran compiler on ia64
- tmp_addflag=' -i_dynamic -nofor_main' ;;
- ifc* | ifort*) # Intel Fortran compiler
- tmp_addflag=' -nofor_main' ;;
- esac
- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared'"$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
-
- if test $supports_anon_versioning = yes; then
- _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$echo "{ global:" > $output_objdir/$libname.ver~
- cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~
- $echo "local: *; };" >> $output_objdir/$libname.ver~
- $CC -shared'"$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib'
- fi
- _LT_AC_TAGVAR(link_all_deplibs, $1)=no
- else
- _LT_AC_TAGVAR(ld_shlibs, $1)=no
- fi
- ;;
-
- netbsd* | netbsdelf*-gnu | knetbsd*-gnu)
- if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then
- _LT_AC_TAGVAR(archive_cmds, $1)='$LD -Bshareable $libobjs $deplibs $linker_flags -o $lib'
- wlarc=
- else
- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
- _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
- fi
- ;;
-
- solaris*)
- if $LD -v 2>&1 | grep 'BFD 2\.8' > /dev/null; then
- _LT_AC_TAGVAR(ld_shlibs, $1)=no
- cat <<EOF 1>&2
-
-*** Warning: The releases 2.8.* of the GNU linker cannot reliably
-*** create shared libraries on Solaris systems. Therefore, libtool
-*** is disabling shared libraries support. We urge you to upgrade GNU
-*** binutils to release 2.9.1 or newer. Another option is to modify
-*** your PATH or compiler configuration so that the native linker is
-*** used, and then restart.
-
-EOF
- elif $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
- _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
- else
- _LT_AC_TAGVAR(ld_shlibs, $1)=no
- fi
- ;;
-
- sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX*)
- case `$LD -v 2>&1` in
- *\ [[01]].* | *\ 2.[[0-9]].* | *\ 2.1[[0-5]].*)
- _LT_AC_TAGVAR(ld_shlibs, $1)=no
- cat <<_LT_EOF 1>&2
-
-*** Warning: Releases of the GNU linker prior to 2.16.91.0.3 can not
-*** reliably create shared libraries on SCO systems. Therefore, libtool
-*** is disabling shared libraries support. We urge you to upgrade GNU
-*** binutils to release 2.16.91.0.3 or newer. Another option is to modify
-*** your PATH or compiler configuration so that the native linker is
-*** used, and then restart.
-
-_LT_EOF
- ;;
- *)
- if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='`test -z "$SCOABSPATH" && echo ${wl}-rpath,$libdir`'
- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib'
- _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname,\${SCOABSPATH:+${install_libdir}/}$soname,-retain-symbols-file,$export_symbols -o $lib'
- else
- _LT_AC_TAGVAR(ld_shlibs, $1)=no
- fi
- ;;
- esac
- ;;
-
- sunos4*)
- _LT_AC_TAGVAR(archive_cmds, $1)='$LD -assert pure-text -Bshareable -o $lib $libobjs $deplibs $linker_flags'
- wlarc=
- _LT_AC_TAGVAR(hardcode_direct, $1)=yes
- _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
- ;;
-
- *)
- if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
- _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
- else
- _LT_AC_TAGVAR(ld_shlibs, $1)=no
- fi
- ;;
- esac
-
- if test "$_LT_AC_TAGVAR(ld_shlibs, $1)" = no; then
- runpath_var=
- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)=
- _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)=
- _LT_AC_TAGVAR(whole_archive_flag_spec, $1)=
- fi
- else
- # PORTME fill in a description of your system's linker (not GNU ld)
- case $host_os in
- aix3*)
- _LT_AC_TAGVAR(allow_undefined_flag, $1)=unsupported
- _LT_AC_TAGVAR(always_export_symbols, $1)=yes
- _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$LD -o $output_objdir/$soname $libobjs $deplibs $linker_flags -bE:$export_symbols -T512 -H512 -bM:SRE~$AR $AR_FLAGS $lib $output_objdir/$soname'
- # Note: this linker hardcodes the directories in LIBPATH if there
- # are no directories specified by -L.
- _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes
- if test "$GCC" = yes && test -z "$lt_prog_compiler_static"; then
- # Neither direct hardcoding nor static linking is supported with a
- # broken collect2.
- _LT_AC_TAGVAR(hardcode_direct, $1)=unsupported
- fi
- ;;
-
- aix4* | aix5*)
- if test "$host_cpu" = ia64; then
- # On IA64, the linker does run time linking by default, so we don't
- # have to do anything special.
- aix_use_runtimelinking=no
- exp_sym_flag='-Bexport'
- no_entry_flag=""
- else
- # If we're using GNU nm, then we don't want the "-C" option.
- # -C means demangle to AIX nm, but means don't demangle with GNU nm
- if $NM -V 2>&1 | grep 'GNU' > /dev/null; then
- _LT_AC_TAGVAR(export_symbols_cmds, $1)='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\[$]2 == "T") || (\[$]2 == "D") || (\[$]2 == "B")) && ([substr](\[$]3,1,1) != ".")) { print \[$]3 } }'\'' | sort -u > $export_symbols'
- else
- _LT_AC_TAGVAR(export_symbols_cmds, $1)='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\[$]2 == "T") || (\[$]2 == "D") || (\[$]2 == "B")) && ([substr](\[$]3,1,1) != ".")) { print \[$]3 } }'\'' | sort -u > $export_symbols'
- fi
- aix_use_runtimelinking=no
-
- # Test if we are trying to use run time linking or normal
- # AIX style linking. If -brtl is somewhere in LDFLAGS, we
- # need to do runtime linking.
- case $host_os in aix4.[[23]]|aix4.[[23]].*|aix5*)
- for ld_flag in $LDFLAGS; do
- if (test $ld_flag = "-brtl" || test $ld_flag = "-Wl,-brtl"); then
- aix_use_runtimelinking=yes
- break
- fi
- done
- ;;
- esac
-
- exp_sym_flag='-bexport'
- no_entry_flag='-bnoentry'
- fi
-
- # When large executables or shared objects are built, AIX ld can
- # have problems creating the table of contents. If linking a library
- # or program results in "error TOC overflow" add -mminimal-toc to
- # CXXFLAGS/CFLAGS for g++/gcc. In the cases where that is not
- # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS.
-
- _LT_AC_TAGVAR(archive_cmds, $1)=''
- _LT_AC_TAGVAR(hardcode_direct, $1)=yes
- _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=':'
- _LT_AC_TAGVAR(link_all_deplibs, $1)=yes
-
- if test "$GCC" = yes; then
- case $host_os in aix4.[[012]]|aix4.[[012]].*)
- # We only want to do this on AIX 4.2 and lower, the check
- # below for broken collect2 doesn't work under 4.3+
- collect2name=`${CC} -print-prog-name=collect2`
- if test -f "$collect2name" && \
- strings "$collect2name" | grep resolve_lib_name >/dev/null
- then
- # We have reworked collect2
- _LT_AC_TAGVAR(hardcode_direct, $1)=yes
- else
- # We have old collect2
- _LT_AC_TAGVAR(hardcode_direct, $1)=unsupported
- # It fails to find uninstalled libraries when the uninstalled
- # path is not listed in the libpath. Setting hardcode_minus_L
- # to unsupported forces relinking
- _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes
- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
- _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=
- fi
- ;;
- esac
- shared_flag='-shared'
- if test "$aix_use_runtimelinking" = yes; then
- shared_flag="$shared_flag "'${wl}-G'
- fi
- else
- # not using gcc
- if test "$host_cpu" = ia64; then
- # VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release
- # chokes on -Wl,-G. The following line is correct:
- shared_flag='-G'
- else
- if test "$aix_use_runtimelinking" = yes; then
- shared_flag='${wl}-G'
- else
- shared_flag='${wl}-bM:SRE'
- fi
- fi
- fi
-
- # It seems that -bexpall does not export symbols beginning with
- # underscore (_), so it is better to generate a list of symbols to export.
- _LT_AC_TAGVAR(always_export_symbols, $1)=yes
- if test "$aix_use_runtimelinking" = yes; then
- # Warning - without using the other runtime loading flags (-brtl),
- # -berok will link without error, but may produce a broken library.
- _LT_AC_TAGVAR(allow_undefined_flag, $1)='-berok'
- # Determine the default libpath from the value encoded in an empty executable.
- _LT_AC_SYS_LIBPATH_AIX
- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath"
- _LT_AC_TAGVAR(archive_expsym_cmds, $1)="\$CC"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then echo "${wl}${allow_undefined_flag}"; else :; fi` '"\${wl}$exp_sym_flag:\$export_symbols $shared_flag"
- else
- if test "$host_cpu" = ia64; then
- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R $libdir:/usr/lib:/lib'
- _LT_AC_TAGVAR(allow_undefined_flag, $1)="-z nodefs"
- _LT_AC_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$exp_sym_flag:\$export_symbols"
- else
- # Determine the default libpath from the value encoded in an empty executable.
- _LT_AC_SYS_LIBPATH_AIX
- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath"
- # Warning - without using the other run time loading flags,
- # -berok will link without error, but may produce a broken library.
- _LT_AC_TAGVAR(no_undefined_flag, $1)=' ${wl}-bernotok'
- _LT_AC_TAGVAR(allow_undefined_flag, $1)=' ${wl}-berok'
- # Exported symbols can be pulled into shared objects from archives
- _LT_AC_TAGVAR(whole_archive_flag_spec, $1)='$convenience'
- _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=yes
- # This is similar to how AIX traditionally builds its shared libraries.
- _LT_AC_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs ${wl}-bnoentry $compiler_flags ${wl}-bE:$export_symbols${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname'
- fi
- fi
- ;;
-
- amigaos*)
- _LT_AC_TAGVAR(archive_cmds, $1)='$rm $output_objdir/a2ixlibrary.data~$echo "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$echo "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$echo "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$echo "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)'
- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
- _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes
- # see comment about different semantics on the GNU ld section
- _LT_AC_TAGVAR(ld_shlibs, $1)=no
- ;;
-
- bsdi[[45]]*)
- _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)=-rdynamic
- ;;
-
- cygwin* | mingw* | pw32*)
- # When not using gcc, we currently assume that we are using
- # Microsoft Visual C++.
- # hardcode_libdir_flag_spec is actually meaningless, as there is
- # no search path for DLLs.
- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)=' '
- _LT_AC_TAGVAR(allow_undefined_flag, $1)=unsupported
- # Tell ltmain to make .lib files, not .a files.
- libext=lib
- # Tell ltmain to make .dll files, not .so files.
- shrext_cmds=".dll"
- # FIXME: Setting linknames here is a bad hack.
- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -o $lib $libobjs $compiler_flags `echo "$deplibs" | $SED -e '\''s/ -lc$//'\''` -link -dll~linknames='
- # The linker will automatically build a .lib file if we build a DLL.
- _LT_AC_TAGVAR(old_archive_From_new_cmds, $1)='true'
- # FIXME: Should let the user specify the lib program.
- _LT_AC_TAGVAR(old_archive_cmds, $1)='lib /OUT:$oldlib$oldobjs$old_deplibs'
- _LT_AC_TAGVAR(fix_srcfile_path, $1)='`cygpath -w "$srcfile"`'
- _LT_AC_TAGVAR(enable_shared_with_static_runtimes, $1)=yes
- ;;
-
- darwin* | rhapsody*)
- case $host_os in
- rhapsody* | darwin1.[[012]])
- _LT_AC_TAGVAR(allow_undefined_flag, $1)='${wl}-undefined ${wl}suppress'
- ;;
- *) # Darwin 1.3 on
- if test -z ${MACOSX_DEPLOYMENT_TARGET} ; then
- _LT_AC_TAGVAR(allow_undefined_flag, $1)='${wl}-flat_namespace ${wl}-undefined ${wl}suppress'
- else
- case ${MACOSX_DEPLOYMENT_TARGET} in
- 10.[[012]])
- _LT_AC_TAGVAR(allow_undefined_flag, $1)='${wl}-flat_namespace ${wl}-undefined ${wl}suppress'
- ;;
- 10.*)
- _LT_AC_TAGVAR(allow_undefined_flag, $1)='${wl}-undefined ${wl}dynamic_lookup'
- ;;
- esac
- fi
- ;;
- esac
- _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no
- _LT_AC_TAGVAR(hardcode_direct, $1)=no
- _LT_AC_TAGVAR(hardcode_automatic, $1)=yes
- _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=unsupported
- _LT_AC_TAGVAR(whole_archive_flag_spec, $1)=''
- _LT_AC_TAGVAR(link_all_deplibs, $1)=yes
- if test "$GCC" = yes ; then
- output_verbose_link_cmd='echo'
- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -dynamiclib $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring'
- _LT_AC_TAGVAR(module_cmds, $1)='$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags'
- # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin lds
- _LT_AC_TAGVAR(archive_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -dynamiclib $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
- _LT_AC_TAGVAR(module_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
- else
- case $cc_basename in
- xlc*)
- output_verbose_link_cmd='echo'
- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -qmkshrobj $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-install_name ${wl}`echo $rpath/$soname` $verstring'
- _LT_AC_TAGVAR(module_cmds, $1)='$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags'
- # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin lds
- _LT_AC_TAGVAR(archive_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -qmkshrobj $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-install_name ${wl}$rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
- _LT_AC_TAGVAR(module_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
- ;;
- *)
- _LT_AC_TAGVAR(ld_shlibs, $1)=no
- ;;
- esac
- fi
- ;;
-
- dgux*)
- _LT_AC_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
- _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
- ;;
-
- freebsd1*)
- _LT_AC_TAGVAR(ld_shlibs, $1)=no
- ;;
-
- # FreeBSD 2.2.[012] allows us to include c++rt0.o to get C++ constructor
- # support. Future versions do this automatically, but an explicit c++rt0.o
- # does not break anything, and helps significantly (at the cost of a little
- # extra space).
- freebsd2.2*)
- _LT_AC_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags /usr/lib/c++rt0.o'
- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
- _LT_AC_TAGVAR(hardcode_direct, $1)=yes
- _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
- ;;
-
- # Unfortunately, older versions of FreeBSD 2 do not have this feature.
- freebsd2*)
- _LT_AC_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags'
- _LT_AC_TAGVAR(hardcode_direct, $1)=yes
- _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes
- _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
- ;;
-
- # FreeBSD 3 and greater uses gcc -shared to do shared libraries.
- freebsd* | dragonfly*)
- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -o $lib $libobjs $deplibs $compiler_flags'
- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
- _LT_AC_TAGVAR(hardcode_direct, $1)=yes
- _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
- ;;
-
- # GNU/kFreeBSD uses gcc -shared to do shared libraries.
- kfreebsd*-gnu)
- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -o $lib $libobjs $deplibs $compiler_flags'
- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
- _LT_AC_TAGVAR(hardcode_direct, $1)=yes
- _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
- _LT_AC_TAGVAR(link_all_deplibs, $1)=no
- ;;
-
- hpux9*)
- if test "$GCC" = yes; then
- _LT_AC_TAGVAR(archive_cmds, $1)='$rm $output_objdir/$soname~$CC -shared -fPIC ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $libobjs $deplibs $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
- else
- _LT_AC_TAGVAR(archive_cmds, $1)='$rm $output_objdir/$soname~$LD -b +b $install_libdir -o $output_objdir/$soname $libobjs $deplibs $linker_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
- fi
- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir'
- _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=:
- _LT_AC_TAGVAR(hardcode_direct, $1)=yes
-
- # hardcode_minus_L: Not really in the search PATH,
- # but as the default location of the library.
- _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes
- _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
- ;;
-
- hpux10*)
- if test "$GCC" = yes -a "$with_gnu_ld" = no; then
- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
- else
- _LT_AC_TAGVAR(archive_cmds, $1)='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags'
- fi
- if test "$with_gnu_ld" = no; then
- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir'
- _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=:
-
- _LT_AC_TAGVAR(hardcode_direct, $1)=yes
- _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
-
- # hardcode_minus_L: Not really in the search PATH,
- # but as the default location of the library.
- _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes
- fi
- ;;
-
- hpux11*)
- if test "$GCC" = yes -a "$with_gnu_ld" = no; then
- case $host_cpu in
- hppa*64*)
- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
- ;;
- ia64*)
- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags'
- ;;
- *)
- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
- ;;
- esac
- else
- case $host_cpu in
- hppa*64*)
- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
- ;;
- ia64*)
- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags'
- ;;
- *)
- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
- ;;
- esac
- fi
- if test "$with_gnu_ld" = no; then
- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir'
- _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=:
-
- case $host_cpu in
- hppa*64*|ia64*)
- _LT_AC_TAGVAR(hardcode_libdir_flag_spec_ld, $1)='+b $libdir'
- _LT_AC_TAGVAR(hardcode_direct, $1)=no
- _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
- ;;
- *)
- _LT_AC_TAGVAR(hardcode_direct, $1)=yes
- _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
-
- # hardcode_minus_L: Not really in the search PATH,
- # but as the default location of the library.
- _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes
- ;;
- esac
- fi
- ;;
-
- irix5* | irix6* | nonstopux*)
- if test "$GCC" = yes; then
- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
- else
- _LT_AC_TAGVAR(archive_cmds, $1)='$LD -shared $libobjs $deplibs $linker_flags -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib'
- _LT_AC_TAGVAR(hardcode_libdir_flag_spec_ld, $1)='-rpath $libdir'
- fi
- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
- _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=:
- _LT_AC_TAGVAR(link_all_deplibs, $1)=yes
- ;;
-
- netbsd* | netbsdelf*-gnu | knetbsd*-gnu)
- if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then
- _LT_AC_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' # a.out
- else
- _LT_AC_TAGVAR(archive_cmds, $1)='$LD -shared -o $lib $libobjs $deplibs $linker_flags' # ELF
- fi
- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
- _LT_AC_TAGVAR(hardcode_direct, $1)=yes
- _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
- ;;
-
- newsos6)
- _LT_AC_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
- _LT_AC_TAGVAR(hardcode_direct, $1)=yes
- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
- _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=:
- _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
- ;;
-
- openbsd*)
- _LT_AC_TAGVAR(hardcode_direct, $1)=yes
- _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
- if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags'
- _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-retain-symbols-file,$export_symbols'
- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
- _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
- else
- case $host_os in
- openbsd[[01]].* | openbsd2.[[0-7]] | openbsd2.[[0-7]].*)
- _LT_AC_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags'
- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
- ;;
- *)
- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags'
- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
- ;;
- esac
- fi
- ;;
-
- os2*)
- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
- _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes
- _LT_AC_TAGVAR(allow_undefined_flag, $1)=unsupported
- _LT_AC_TAGVAR(archive_cmds, $1)='$echo "LIBRARY $libname INITINSTANCE" > $output_objdir/$libname.def~$echo "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~$echo DATA >> $output_objdir/$libname.def~$echo " SINGLE NONSHARED" >> $output_objdir/$libname.def~$echo EXPORTS >> $output_objdir/$libname.def~emxexp $libobjs >> $output_objdir/$libname.def~$CC -Zdll -Zcrtdll -o $lib $libobjs $deplibs $compiler_flags $output_objdir/$libname.def'
- _LT_AC_TAGVAR(old_archive_From_new_cmds, $1)='emximp -o $output_objdir/$libname.a $output_objdir/$libname.def'
- ;;
-
- osf3*)
- if test "$GCC" = yes; then
- _LT_AC_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*'
- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
- else
- _LT_AC_TAGVAR(allow_undefined_flag, $1)=' -expect_unresolved \*'
- _LT_AC_TAGVAR(archive_cmds, $1)='$LD -shared${allow_undefined_flag} $libobjs $deplibs $linker_flags -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib'
- fi
- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
- _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=:
- ;;
-
- osf4* | osf5*) # as osf3* with the addition of -msym flag
- if test "$GCC" = yes; then
- _LT_AC_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*'
- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
- else
- _LT_AC_TAGVAR(allow_undefined_flag, $1)=' -expect_unresolved \*'
- _LT_AC_TAGVAR(archive_cmds, $1)='$LD -shared${allow_undefined_flag} $libobjs $deplibs $linker_flags -msym -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib'
- _LT_AC_TAGVAR(archive_expsym_cmds, $1)='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done; echo "-hidden">> $lib.exp~
- $LD -shared${allow_undefined_flag} -input $lib.exp $linker_flags $libobjs $deplibs -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib~$rm $lib.exp'
-
- # Both c and cxx compiler support -rpath directly
- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-rpath $libdir'
- fi
- _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=:
- ;;
-
- solaris*)
- _LT_AC_TAGVAR(no_undefined_flag, $1)=' -z text'
- if test "$GCC" = yes; then
- wlarc='${wl}'
- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
- _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~
- $CC -shared ${wl}-M ${wl}$lib.exp ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags~$rm $lib.exp'
- else
- wlarc=''
- _LT_AC_TAGVAR(archive_cmds, $1)='$LD -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $linker_flags'
- _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~
- $LD -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linker_flags~$rm $lib.exp'
- fi
- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
- _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
- case $host_os in
- solaris2.[[0-5]] | solaris2.[[0-5]].*) ;;
- *)
- # The compiler driver will combine linker options so we
- # cannot just pass the convience library names through
- # without $wl, iff we do not link with $LD.
- # Luckily, gcc supports the same syntax we need for Sun Studio.
- # Supported since Solaris 2.6 (maybe 2.5.1?)
- case $wlarc in
- '')
- _LT_AC_TAGVAR(whole_archive_flag_spec, $1)='-z allextract$convenience -z defaultextract' ;;
- *)
- _LT_AC_TAGVAR(whole_archive_flag_spec, $1)='${wl}-z ${wl}allextract`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}-z ${wl}defaultextract' ;;
- esac ;;
- esac
- _LT_AC_TAGVAR(link_all_deplibs, $1)=yes
- ;;
-
- sunos4*)
- if test "x$host_vendor" = xsequent; then
- # Use $CC to link under sequent, because it throws in some extra .o
- # files that make .init and .fini sections work.
- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h $soname -o $lib $libobjs $deplibs $compiler_flags'
- else
- _LT_AC_TAGVAR(archive_cmds, $1)='$LD -assert pure-text -Bstatic -o $lib $libobjs $deplibs $linker_flags'
- fi
- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
- _LT_AC_TAGVAR(hardcode_direct, $1)=yes
- _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes
- _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
- ;;
-
- sysv4)
- case $host_vendor in
- sni)
- _LT_AC_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
- _LT_AC_TAGVAR(hardcode_direct, $1)=yes # is this really true???
- ;;
- siemens)
- ## LD is ld it makes a PLAMLIB
- ## CC just makes a GrossModule.
- _LT_AC_TAGVAR(archive_cmds, $1)='$LD -G -o $lib $libobjs $deplibs $linker_flags'
- _LT_AC_TAGVAR(reload_cmds, $1)='$CC -r -o $output$reload_objs'
- _LT_AC_TAGVAR(hardcode_direct, $1)=no
- ;;
- motorola)
- _LT_AC_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
- _LT_AC_TAGVAR(hardcode_direct, $1)=no #Motorola manual says yes, but my tests say they lie
- ;;
- esac
- runpath_var='LD_RUN_PATH'
- _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
- ;;
-
- sysv4.3*)
- _LT_AC_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
- _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
- _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='-Bexport'
- ;;
-
- sysv4*MP*)
- if test -d /usr/nec; then
- _LT_AC_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
- _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
- runpath_var=LD_RUN_PATH
- hardcode_runpath_var=yes
- _LT_AC_TAGVAR(ld_shlibs, $1)=yes
- fi
- ;;
-
- sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[[01]].[[10]]* | unixware7*)
- _LT_AC_TAGVAR(no_undefined_flag, $1)='${wl}-z,text'
- _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no
- _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
- runpath_var='LD_RUN_PATH'
-
- if test "$GCC" = yes; then
- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
- _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
- else
- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
- _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
- fi
- ;;
-
- sysv5* | sco3.2v5* | sco5v6*)
- # Note: We can NOT use -z defs as we might desire, because we do not
- # link with -lc, and that would cause any symbols used from libc to
- # always be unresolved, which means just about no library would
- # ever link correctly. If we're not using GNU ld we use -z text
- # though, which does catch some bad symbols but isn't as heavy-handed
- # as -z defs.
- _LT_AC_TAGVAR(no_undefined_flag, $1)='${wl}-z,text'
- _LT_AC_TAGVAR(allow_undefined_flag, $1)='${wl}-z,nodefs'
- _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no
- _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='`test -z "$SCOABSPATH" && echo ${wl}-R,$libdir`'
- _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=':'
- _LT_AC_TAGVAR(link_all_deplibs, $1)=yes
- _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-Bexport'
- runpath_var='LD_RUN_PATH'
-
- if test "$GCC" = yes; then
- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags'
- _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags'
- else
- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags'
- _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags'
- fi
- ;;
-
- uts4*)
- _LT_AC_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
- _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
- ;;
-
- *)
- _LT_AC_TAGVAR(ld_shlibs, $1)=no
- ;;
- esac
- fi
-])
-AC_MSG_RESULT([$_LT_AC_TAGVAR(ld_shlibs, $1)])
-test "$_LT_AC_TAGVAR(ld_shlibs, $1)" = no && can_build_shared=no
-
-#
-# Do we need to explicitly link libc?
-#
-case "x$_LT_AC_TAGVAR(archive_cmds_need_lc, $1)" in
-x|xyes)
- # Assume -lc should be added
- _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=yes
-
- if test "$enable_shared" = yes && test "$GCC" = yes; then
- case $_LT_AC_TAGVAR(archive_cmds, $1) in
- *'~'*)
- # FIXME: we may have to deal with multi-command sequences.
- ;;
- '$CC '*)
- # Test whether the compiler implicitly links with -lc since on some
- # systems, -lgcc has to come before -lc. If gcc already passes -lc
- # to ld, don't add -lc before -lgcc.
- AC_MSG_CHECKING([whether -lc should be explicitly linked in])
- $rm conftest*
- printf "$lt_simple_compile_test_code" > conftest.$ac_ext
-
- if AC_TRY_EVAL(ac_compile) 2>conftest.err; then
- soname=conftest
- lib=conftest
- libobjs=conftest.$ac_objext
- deplibs=
- wl=$_LT_AC_TAGVAR(lt_prog_compiler_wl, $1)
- pic_flag=$_LT_AC_TAGVAR(lt_prog_compiler_pic, $1)
- compiler_flags=-v
- linker_flags=-v
- verstring=
- output_objdir=.
- libname=conftest
- lt_save_allow_undefined_flag=$_LT_AC_TAGVAR(allow_undefined_flag, $1)
- _LT_AC_TAGVAR(allow_undefined_flag, $1)=
- if AC_TRY_EVAL(_LT_AC_TAGVAR(archive_cmds, $1) 2\>\&1 \| grep \" -lc \" \>/dev/null 2\>\&1)
- then
- _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no
- else
- _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=yes
- fi
- _LT_AC_TAGVAR(allow_undefined_flag, $1)=$lt_save_allow_undefined_flag
- else
- cat conftest.err 1>&5
- fi
- $rm conftest*
- AC_MSG_RESULT([$_LT_AC_TAGVAR(archive_cmds_need_lc, $1)])
- ;;
- esac
- fi
- ;;
-esac
-])# AC_LIBTOOL_PROG_LD_SHLIBS
-
-
-# _LT_AC_FILE_LTDLL_C
-# -------------------
-# Be careful that the start marker always follows a newline.
-AC_DEFUN([_LT_AC_FILE_LTDLL_C], [
-# /* ltdll.c starts here */
-# #define WIN32_LEAN_AND_MEAN
-# #include <windows.h>
-# #undef WIN32_LEAN_AND_MEAN
-# #include <stdio.h>
-#
-# #ifndef __CYGWIN__
-# # ifdef __CYGWIN32__
-# # define __CYGWIN__ __CYGWIN32__
-# # endif
-# #endif
-#
-# #ifdef __cplusplus
-# extern "C" {
-# #endif
-# BOOL APIENTRY DllMain (HINSTANCE hInst, DWORD reason, LPVOID reserved);
-# #ifdef __cplusplus
-# }
-# #endif
-#
-# #ifdef __CYGWIN__
-# #include <cygwin/cygwin_dll.h>
-# DECLARE_CYGWIN_DLL( DllMain );
-# #endif
-# HINSTANCE __hDllInstance_base;
-#
-# BOOL APIENTRY
-# DllMain (HINSTANCE hInst, DWORD reason, LPVOID reserved)
-# {
-# __hDllInstance_base = hInst;
-# return TRUE;
-# }
-# /* ltdll.c ends here */
-])# _LT_AC_FILE_LTDLL_C
-
-
-# _LT_AC_TAGVAR(VARNAME, [TAGNAME])
-# ---------------------------------
-AC_DEFUN([_LT_AC_TAGVAR], [ifelse([$2], [], [$1], [$1_$2])])
-
-
-# old names
-AC_DEFUN([AM_PROG_LIBTOOL], [AC_PROG_LIBTOOL])
-AC_DEFUN([AM_ENABLE_SHARED], [AC_ENABLE_SHARED($@)])
-AC_DEFUN([AM_ENABLE_STATIC], [AC_ENABLE_STATIC($@)])
-AC_DEFUN([AM_DISABLE_SHARED], [AC_DISABLE_SHARED($@)])
-AC_DEFUN([AM_DISABLE_STATIC], [AC_DISABLE_STATIC($@)])
-AC_DEFUN([AM_PROG_LD], [AC_PROG_LD])
-AC_DEFUN([AM_PROG_NM], [AC_PROG_NM])
-
-# This is just to silence aclocal about the macro not being used
-ifelse([AC_DISABLE_FAST_INSTALL])
-
-AC_DEFUN([LT_AC_PROG_GCJ],
-[AC_CHECK_TOOL(GCJ, gcj, no)
- test "x${GCJFLAGS+set}" = xset || GCJFLAGS="-g -O2"
- AC_SUBST(GCJFLAGS)
-])
-
-AC_DEFUN([LT_AC_PROG_RC],
-[AC_CHECK_TOOL(RC, windres, no)
-])
-
-# NOTE: This macro has been submitted for inclusion into #
-# GNU Autoconf as AC_PROG_SED. When it is available in #
-# a released version of Autoconf we should remove this #
-# macro and use it instead. #
-# LT_AC_PROG_SED
-# --------------
-# Check for a fully-functional sed program, that truncates
-# as few characters as possible. Prefer GNU sed if found.
-AC_DEFUN([LT_AC_PROG_SED],
-[AC_MSG_CHECKING([for a sed that does not truncate output])
-AC_CACHE_VAL(lt_cv_path_SED,
-[# Loop through the user's path and test for sed and gsed.
-# Then use that list of sed's as ones to test for truncation.
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
- IFS=$as_save_IFS
- test -z "$as_dir" && as_dir=.
- for lt_ac_prog in sed gsed; do
- for ac_exec_ext in '' $ac_executable_extensions; do
- if $as_executable_p "$as_dir/$lt_ac_prog$ac_exec_ext"; then
- lt_ac_sed_list="$lt_ac_sed_list $as_dir/$lt_ac_prog$ac_exec_ext"
- fi
- done
- done
-done
-lt_ac_max=0
-lt_ac_count=0
-# Add /usr/xpg4/bin/sed as it is typically found on Solaris
-# along with /bin/sed that truncates output.
-for lt_ac_sed in $lt_ac_sed_list /usr/xpg4/bin/sed; do
- test ! -f $lt_ac_sed && continue
- cat /dev/null > conftest.in
- lt_ac_count=0
- echo $ECHO_N "0123456789$ECHO_C" >conftest.in
- # Check for GNU sed and select it if it is found.
- if "$lt_ac_sed" --version 2>&1 < /dev/null | grep 'GNU' > /dev/null; then
- lt_cv_path_SED=$lt_ac_sed
- break
- fi
- while true; do
- cat conftest.in conftest.in >conftest.tmp
- mv conftest.tmp conftest.in
- cp conftest.in conftest.nl
- echo >>conftest.nl
- $lt_ac_sed -e 's/a$//' < conftest.nl >conftest.out || break
- cmp -s conftest.out conftest.nl || break
- # 10000 chars as input seems more than enough
- test $lt_ac_count -gt 10 && break
- lt_ac_count=`expr $lt_ac_count + 1`
- if test $lt_ac_count -gt $lt_ac_max; then
- lt_ac_max=$lt_ac_count
- lt_cv_path_SED=$lt_ac_sed
- fi
- done
-done
-])
-SED=$lt_cv_path_SED
-AC_MSG_RESULT([$SED])
-])
-
-# Copyright (C) 2002, 2003, 2005 Free Software Foundation, Inc.
-#
-# This file is free software; the Free Software Foundation
-# gives unlimited permission to copy and/or distribute it,
-# with or without modifications, as long as this notice is preserved.
-
-# AM_AUTOMAKE_VERSION(VERSION)
-# ----------------------------
-# Automake X.Y traces this macro to ensure aclocal.m4 has been
-# generated from the m4 files accompanying Automake X.Y.
-AC_DEFUN([AM_AUTOMAKE_VERSION], [am__api_version="1.9"])
-
-# AM_SET_CURRENT_AUTOMAKE_VERSION
-# -------------------------------
-# Call AM_AUTOMAKE_VERSION so it can be traced.
-# This function is AC_REQUIREd by AC_INIT_AUTOMAKE.
-AC_DEFUN([AM_SET_CURRENT_AUTOMAKE_VERSION],
- [AM_AUTOMAKE_VERSION([1.9.6])])
-
-# AM_AUX_DIR_EXPAND -*- Autoconf -*-
-
-# Copyright (C) 2001, 2003, 2005 Free Software Foundation, Inc.
-#
-# This file is free software; the Free Software Foundation
-# gives unlimited permission to copy and/or distribute it,
-# with or without modifications, as long as this notice is preserved.
-
-# For projects using AC_CONFIG_AUX_DIR([foo]), Autoconf sets
-# $ac_aux_dir to `$srcdir/foo'. In other projects, it is set to
-# `$srcdir', `$srcdir/..', or `$srcdir/../..'.
-#
-# Of course, Automake must honor this variable whenever it calls a
-# tool from the auxiliary directory. The problem is that $srcdir (and
-# therefore $ac_aux_dir as well) can be either absolute or relative,
-# depending on how configure is run. This is pretty annoying, since
-# it makes $ac_aux_dir quite unusable in subdirectories: in the top
-# source directory, any form will work fine, but in subdirectories a
-# relative path needs to be adjusted first.
-#
-# $ac_aux_dir/missing
-# fails when called from a subdirectory if $ac_aux_dir is relative
-# $top_srcdir/$ac_aux_dir/missing
-# fails if $ac_aux_dir is absolute,
-# fails when called from a subdirectory in a VPATH build with
-# a relative $ac_aux_dir
-#
-# The reason of the latter failure is that $top_srcdir and $ac_aux_dir
-# are both prefixed by $srcdir. In an in-source build this is usually
-# harmless because $srcdir is `.', but things will broke when you
-# start a VPATH build or use an absolute $srcdir.
-#
-# So we could use something similar to $top_srcdir/$ac_aux_dir/missing,
-# iff we strip the leading $srcdir from $ac_aux_dir. That would be:
-# am_aux_dir='\$(top_srcdir)/'`expr "$ac_aux_dir" : "$srcdir//*\(.*\)"`
-# and then we would define $MISSING as
-# MISSING="\${SHELL} $am_aux_dir/missing"
-# This will work as long as MISSING is not called from configure, because
-# unfortunately $(top_srcdir) has no meaning in configure.
-# However there are other variables, like CC, which are often used in
-# configure, and could therefore not use this "fixed" $ac_aux_dir.
-#
-# Another solution, used here, is to always expand $ac_aux_dir to an
-# absolute PATH. The drawback is that using absolute paths prevent a
-# configured tree to be moved without reconfiguration.
-
-AC_DEFUN([AM_AUX_DIR_EXPAND],
-[dnl Rely on autoconf to set up CDPATH properly.
-AC_PREREQ([2.50])dnl
-# expand $ac_aux_dir to an absolute path
-am_aux_dir=`cd $ac_aux_dir && pwd`
-])
-
-# AM_CONDITIONAL -*- Autoconf -*-
-
-# Copyright (C) 1997, 2000, 2001, 2003, 2004, 2005
-# Free Software Foundation, Inc.
-#
-# This file is free software; the Free Software Foundation
-# gives unlimited permission to copy and/or distribute it,
-# with or without modifications, as long as this notice is preserved.
-
-# serial 7
-
-# AM_CONDITIONAL(NAME, SHELL-CONDITION)
-# -------------------------------------
-# Define a conditional.
-AC_DEFUN([AM_CONDITIONAL],
-[AC_PREREQ(2.52)dnl
- ifelse([$1], [TRUE], [AC_FATAL([$0: invalid condition: $1])],
- [$1], [FALSE], [AC_FATAL([$0: invalid condition: $1])])dnl
-AC_SUBST([$1_TRUE])
-AC_SUBST([$1_FALSE])
-if $2; then
- $1_TRUE=
- $1_FALSE='#'
-else
- $1_TRUE='#'
- $1_FALSE=
-fi
-AC_CONFIG_COMMANDS_PRE(
-[if test -z "${$1_TRUE}" && test -z "${$1_FALSE}"; then
- AC_MSG_ERROR([[conditional "$1" was never defined.
-Usually this means the macro was only invoked conditionally.]])
-fi])])
-
-
-# Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005
-# Free Software Foundation, Inc.
-#
-# This file is free software; the Free Software Foundation
-# gives unlimited permission to copy and/or distribute it,
-# with or without modifications, as long as this notice is preserved.
-
-# serial 8
-
-# There are a few dirty hacks below to avoid letting `AC_PROG_CC' be
-# written in clear, in which case automake, when reading aclocal.m4,
-# will think it sees a *use*, and therefore will trigger all it's
-# C support machinery. Also note that it means that autoscan, seeing
-# CC etc. in the Makefile, will ask for an AC_PROG_CC use...
-
-
-# _AM_DEPENDENCIES(NAME)
-# ----------------------
-# See how the compiler implements dependency checking.
-# NAME is "CC", "CXX", "GCJ", or "OBJC".
-# We try a few techniques and use that to set a single cache variable.
-#
-# We don't AC_REQUIRE the corresponding AC_PROG_CC since the latter was
-# modified to invoke _AM_DEPENDENCIES(CC); we would have a circular
-# dependency, and given that the user is not expected to run this macro,
-# just rely on AC_PROG_CC.
-AC_DEFUN([_AM_DEPENDENCIES],
-[AC_REQUIRE([AM_SET_DEPDIR])dnl
-AC_REQUIRE([AM_OUTPUT_DEPENDENCY_COMMANDS])dnl
-AC_REQUIRE([AM_MAKE_INCLUDE])dnl
-AC_REQUIRE([AM_DEP_TRACK])dnl
-
-ifelse([$1], CC, [depcc="$CC" am_compiler_list=],
- [$1], CXX, [depcc="$CXX" am_compiler_list=],
- [$1], OBJC, [depcc="$OBJC" am_compiler_list='gcc3 gcc'],
- [$1], GCJ, [depcc="$GCJ" am_compiler_list='gcc3 gcc'],
- [depcc="$$1" am_compiler_list=])
-
-AC_CACHE_CHECK([dependency style of $depcc],
- [am_cv_$1_dependencies_compiler_type],
-[if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then
- # We make a subdir and do the tests there. Otherwise we can end up
- # making bogus files that we don't know about and never remove. For
- # instance it was reported that on HP-UX the gcc test will end up
- # making a dummy file named `D' -- because `-MD' means `put the output
- # in D'.
- mkdir conftest.dir
- # Copy depcomp to subdir because otherwise we won't find it if we're
- # using a relative directory.
- cp "$am_depcomp" conftest.dir
- cd conftest.dir
- # We will build objects and dependencies in a subdirectory because
- # it helps to detect inapplicable dependency modes. For instance
- # both Tru64's cc and ICC support -MD to output dependencies as a
- # side effect of compilation, but ICC will put the dependencies in
- # the current directory while Tru64 will put them in the object
- # directory.
- mkdir sub
-
- am_cv_$1_dependencies_compiler_type=none
- if test "$am_compiler_list" = ""; then
- am_compiler_list=`sed -n ['s/^#*\([a-zA-Z0-9]*\))$/\1/p'] < ./depcomp`
- fi
- for depmode in $am_compiler_list; do
- # Setup a source with many dependencies, because some compilers
- # like to wrap large dependency lists on column 80 (with \), and
- # we should not choose a depcomp mode which is confused by this.
- #
- # We need to recreate these files for each test, as the compiler may
- # overwrite some of them when testing with obscure command lines.
- # This happens at least with the AIX C compiler.
- : > sub/conftest.c
- for i in 1 2 3 4 5 6; do
- echo '#include "conftst'$i'.h"' >> sub/conftest.c
- # Using `: > sub/conftst$i.h' creates only sub/conftst1.h with
- # Solaris 8's {/usr,}/bin/sh.
- touch sub/conftst$i.h
- done
- echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf
-
- case $depmode in
- nosideeffect)
- # after this tag, mechanisms are not by side-effect, so they'll
- # only be used when explicitly requested
- if test "x$enable_dependency_tracking" = xyes; then
- continue
- else
- break
- fi
- ;;
- none) break ;;
- esac
- # We check with `-c' and `-o' for the sake of the "dashmstdout"
- # mode. It turns out that the SunPro C++ compiler does not properly
- # handle `-M -o', and we need to detect this.
- if depmode=$depmode \
- source=sub/conftest.c object=sub/conftest.${OBJEXT-o} \
- depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \
- $SHELL ./depcomp $depcc -c -o sub/conftest.${OBJEXT-o} sub/conftest.c \
- >/dev/null 2>conftest.err &&
- grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 &&
- grep sub/conftest.${OBJEXT-o} sub/conftest.Po > /dev/null 2>&1 &&
- ${MAKE-make} -s -f confmf > /dev/null 2>&1; then
- # icc doesn't choke on unknown options, it will just issue warnings
- # or remarks (even with -Werror). So we grep stderr for any message
- # that says an option was ignored or not supported.
- # When given -MP, icc 7.0 and 7.1 complain thusly:
- # icc: Command line warning: ignoring option '-M'; no argument required
- # The diagnosis changed in icc 8.0:
- # icc: Command line remark: option '-MP' not supported
- if (grep 'ignoring option' conftest.err ||
- grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else
- am_cv_$1_dependencies_compiler_type=$depmode
- break
- fi
- fi
- done
-
- cd ..
- rm -rf conftest.dir
-else
- am_cv_$1_dependencies_compiler_type=none
-fi
-])
-AC_SUBST([$1DEPMODE], [depmode=$am_cv_$1_dependencies_compiler_type])
-AM_CONDITIONAL([am__fastdep$1], [
- test "x$enable_dependency_tracking" != xno \
- && test "$am_cv_$1_dependencies_compiler_type" = gcc3])
-])
-
-
-# AM_SET_DEPDIR
-# -------------
-# Choose a directory name for dependency files.
-# This macro is AC_REQUIREd in _AM_DEPENDENCIES
-AC_DEFUN([AM_SET_DEPDIR],
-[AC_REQUIRE([AM_SET_LEADING_DOT])dnl
-AC_SUBST([DEPDIR], ["${am__leading_dot}deps"])dnl
-])
-
-
-# AM_DEP_TRACK
-# ------------
-AC_DEFUN([AM_DEP_TRACK],
-[AC_ARG_ENABLE(dependency-tracking,
-[ --disable-dependency-tracking speeds up one-time build
- --enable-dependency-tracking do not reject slow dependency extractors])
-if test "x$enable_dependency_tracking" != xno; then
- am_depcomp="$ac_aux_dir/depcomp"
- AMDEPBACKSLASH='\'
-fi
-AM_CONDITIONAL([AMDEP], [test "x$enable_dependency_tracking" != xno])
-AC_SUBST([AMDEPBACKSLASH])
-])
-
-# Generate code to set up dependency tracking. -*- Autoconf -*-
-
-# Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005
-# Free Software Foundation, Inc.
-#
-# This file is free software; the Free Software Foundation
-# gives unlimited permission to copy and/or distribute it,
-# with or without modifications, as long as this notice is preserved.
-
-#serial 3
-
-# _AM_OUTPUT_DEPENDENCY_COMMANDS
-# ------------------------------
-AC_DEFUN([_AM_OUTPUT_DEPENDENCY_COMMANDS],
-[for mf in $CONFIG_FILES; do
- # Strip MF so we end up with the name of the file.
- mf=`echo "$mf" | sed -e 's/:.*$//'`
- # Check whether this is an Automake generated Makefile or not.
- # We used to match only the files named `Makefile.in', but
- # some people rename them; so instead we look at the file content.
- # Grep'ing the first line is not enough: some people post-process
- # each Makefile.in and add a new line on top of each file to say so.
- # So let's grep whole file.
- if grep '^#.*generated by automake' $mf > /dev/null 2>&1; then
- dirpart=`AS_DIRNAME("$mf")`
- else
- continue
- fi
- # Extract the definition of DEPDIR, am__include, and am__quote
- # from the Makefile without running `make'.
- DEPDIR=`sed -n 's/^DEPDIR = //p' < "$mf"`
- test -z "$DEPDIR" && continue
- am__include=`sed -n 's/^am__include = //p' < "$mf"`
- test -z "am__include" && continue
- am__quote=`sed -n 's/^am__quote = //p' < "$mf"`
- # When using ansi2knr, U may be empty or an underscore; expand it
- U=`sed -n 's/^U = //p' < "$mf"`
- # Find all dependency output files, they are included files with
- # $(DEPDIR) in their names. We invoke sed twice because it is the
- # simplest approach to changing $(DEPDIR) to its actual value in the
- # expansion.
- for file in `sed -n "
- s/^$am__include $am__quote\(.*(DEPDIR).*\)$am__quote"'$/\1/p' <"$mf" | \
- sed -e 's/\$(DEPDIR)/'"$DEPDIR"'/g' -e 's/\$U/'"$U"'/g'`; do
- # Make sure the directory exists.
- test -f "$dirpart/$file" && continue
- fdir=`AS_DIRNAME(["$file"])`
- AS_MKDIR_P([$dirpart/$fdir])
- # echo "creating $dirpart/$file"
- echo '# dummy' > "$dirpart/$file"
- done
-done
-])# _AM_OUTPUT_DEPENDENCY_COMMANDS
-
-
-# AM_OUTPUT_DEPENDENCY_COMMANDS
-# -----------------------------
-# This macro should only be invoked once -- use via AC_REQUIRE.
-#
-# This code is only required when automatic dependency tracking
-# is enabled. FIXME. This creates each `.P' file that we will
-# need in order to bootstrap the dependency handling code.
-AC_DEFUN([AM_OUTPUT_DEPENDENCY_COMMANDS],
-[AC_CONFIG_COMMANDS([depfiles],
- [test x"$AMDEP_TRUE" != x"" || _AM_OUTPUT_DEPENDENCY_COMMANDS],
- [AMDEP_TRUE="$AMDEP_TRUE" ac_aux_dir="$ac_aux_dir"])
-])
-
-# Copyright (C) 1996, 1997, 2000, 2001, 2003, 2005
-# Free Software Foundation, Inc.
-#
-# This file is free software; the Free Software Foundation
-# gives unlimited permission to copy and/or distribute it,
-# with or without modifications, as long as this notice is preserved.
-
-# serial 8
-
-# AM_CONFIG_HEADER is obsolete. It has been replaced by AC_CONFIG_HEADERS.
-AU_DEFUN([AM_CONFIG_HEADER], [AC_CONFIG_HEADERS($@)])
-
-# Do all the work for Automake. -*- Autoconf -*-
-
-# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005
-# Free Software Foundation, Inc.
-#
-# This file is free software; the Free Software Foundation
-# gives unlimited permission to copy and/or distribute it,
-# with or without modifications, as long as this notice is preserved.
-
-# serial 12
-
-# This macro actually does too much. Some checks are only needed if
-# your package does certain things. But this isn't really a big deal.
-
-# AM_INIT_AUTOMAKE(PACKAGE, VERSION, [NO-DEFINE])
-# AM_INIT_AUTOMAKE([OPTIONS])
-# -----------------------------------------------
-# The call with PACKAGE and VERSION arguments is the old style
-# call (pre autoconf-2.50), which is being phased out. PACKAGE
-# and VERSION should now be passed to AC_INIT and removed from
-# the call to AM_INIT_AUTOMAKE.
-# We support both call styles for the transition. After
-# the next Automake release, Autoconf can make the AC_INIT
-# arguments mandatory, and then we can depend on a new Autoconf
-# release and drop the old call support.
-AC_DEFUN([AM_INIT_AUTOMAKE],
-[AC_PREREQ([2.58])dnl
-dnl Autoconf wants to disallow AM_ names. We explicitly allow
-dnl the ones we care about.
-m4_pattern_allow([^AM_[A-Z]+FLAGS$])dnl
-AC_REQUIRE([AM_SET_CURRENT_AUTOMAKE_VERSION])dnl
-AC_REQUIRE([AC_PROG_INSTALL])dnl
-# test to see if srcdir already configured
-if test "`cd $srcdir && pwd`" != "`pwd`" &&
- test -f $srcdir/config.status; then
- AC_MSG_ERROR([source directory already configured; run "make distclean" there first])
-fi
-
-# test whether we have cygpath
-if test -z "$CYGPATH_W"; then
- if (cygpath --version) >/dev/null 2>/dev/null; then
- CYGPATH_W='cygpath -w'
- else
- CYGPATH_W=echo
- fi
-fi
-AC_SUBST([CYGPATH_W])
-
-# Define the identity of the package.
-dnl Distinguish between old-style and new-style calls.
-m4_ifval([$2],
-[m4_ifval([$3], [_AM_SET_OPTION([no-define])])dnl
- AC_SUBST([PACKAGE], [$1])dnl
- AC_SUBST([VERSION], [$2])],
-[_AM_SET_OPTIONS([$1])dnl
- AC_SUBST([PACKAGE], ['AC_PACKAGE_TARNAME'])dnl
- AC_SUBST([VERSION], ['AC_PACKAGE_VERSION'])])dnl
-
-_AM_IF_OPTION([no-define],,
-[AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE", [Name of package])
- AC_DEFINE_UNQUOTED(VERSION, "$VERSION", [Version number of package])])dnl
-
-# Some tools Automake needs.
-AC_REQUIRE([AM_SANITY_CHECK])dnl
-AC_REQUIRE([AC_ARG_PROGRAM])dnl
-AM_MISSING_PROG(ACLOCAL, aclocal-${am__api_version})
-AM_MISSING_PROG(AUTOCONF, autoconf)
-AM_MISSING_PROG(AUTOMAKE, automake-${am__api_version})
-AM_MISSING_PROG(AUTOHEADER, autoheader)
-AM_MISSING_PROG(MAKEINFO, makeinfo)
-AM_PROG_INSTALL_SH
-AM_PROG_INSTALL_STRIP
-AC_REQUIRE([AM_PROG_MKDIR_P])dnl
-# We need awk for the "check" target. The system "awk" is bad on
-# some platforms.
-AC_REQUIRE([AC_PROG_AWK])dnl
-AC_REQUIRE([AC_PROG_MAKE_SET])dnl
-AC_REQUIRE([AM_SET_LEADING_DOT])dnl
-_AM_IF_OPTION([tar-ustar], [_AM_PROG_TAR([ustar])],
- [_AM_IF_OPTION([tar-pax], [_AM_PROG_TAR([pax])],
- [_AM_PROG_TAR([v7])])])
-_AM_IF_OPTION([no-dependencies],,
-[AC_PROVIDE_IFELSE([AC_PROG_CC],
- [_AM_DEPENDENCIES(CC)],
- [define([AC_PROG_CC],
- defn([AC_PROG_CC])[_AM_DEPENDENCIES(CC)])])dnl
-AC_PROVIDE_IFELSE([AC_PROG_CXX],
- [_AM_DEPENDENCIES(CXX)],
- [define([AC_PROG_CXX],
- defn([AC_PROG_CXX])[_AM_DEPENDENCIES(CXX)])])dnl
-])
-])
-
-
-# When config.status generates a header, we must update the stamp-h file.
-# This file resides in the same directory as the config header
-# that is generated. The stamp files are numbered to have different names.
-
-# Autoconf calls _AC_AM_CONFIG_HEADER_HOOK (when defined) in the
-# loop where config.status creates the headers, so we can generate
-# our stamp files there.
-AC_DEFUN([_AC_AM_CONFIG_HEADER_HOOK],
-[# Compute $1's index in $config_headers.
-_am_stamp_count=1
-for _am_header in $config_headers :; do
- case $_am_header in
- $1 | $1:* )
- break ;;
- * )
- _am_stamp_count=`expr $_am_stamp_count + 1` ;;
- esac
-done
-echo "timestamp for $1" >`AS_DIRNAME([$1])`/stamp-h[]$_am_stamp_count])
-
-# Copyright (C) 2001, 2003, 2005 Free Software Foundation, Inc.
-#
-# This file is free software; the Free Software Foundation
-# gives unlimited permission to copy and/or distribute it,
-# with or without modifications, as long as this notice is preserved.
-
-# AM_PROG_INSTALL_SH
-# ------------------
-# Define $install_sh.
-AC_DEFUN([AM_PROG_INSTALL_SH],
-[AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl
-install_sh=${install_sh-"$am_aux_dir/install-sh"}
-AC_SUBST(install_sh)])
-
-# Copyright (C) 2003, 2005 Free Software Foundation, Inc.
-#
-# This file is free software; the Free Software Foundation
-# gives unlimited permission to copy and/or distribute it,
-# with or without modifications, as long as this notice is preserved.
-
-# serial 2
-
-# Check whether the underlying file-system supports filenames
-# with a leading dot. For instance MS-DOS doesn't.
-AC_DEFUN([AM_SET_LEADING_DOT],
-[rm -rf .tst 2>/dev/null
-mkdir .tst 2>/dev/null
-if test -d .tst; then
- am__leading_dot=.
-else
- am__leading_dot=_
-fi
-rmdir .tst 2>/dev/null
-AC_SUBST([am__leading_dot])])
-
-# Check to see how 'make' treats includes. -*- Autoconf -*-
-
-# Copyright (C) 2001, 2002, 2003, 2005 Free Software Foundation, Inc.
-#
-# This file is free software; the Free Software Foundation
-# gives unlimited permission to copy and/or distribute it,
-# with or without modifications, as long as this notice is preserved.
-
-# serial 3
-
-# AM_MAKE_INCLUDE()
-# -----------------
-# Check to see how make treats includes.
-AC_DEFUN([AM_MAKE_INCLUDE],
-[am_make=${MAKE-make}
-cat > confinc << 'END'
-am__doit:
- @echo done
-.PHONY: am__doit
-END
-# If we don't find an include directive, just comment out the code.
-AC_MSG_CHECKING([for style of include used by $am_make])
-am__include="#"
-am__quote=
-_am_result=none
-# First try GNU make style include.
-echo "include confinc" > confmf
-# We grep out `Entering directory' and `Leaving directory'
-# messages which can occur if `w' ends up in MAKEFLAGS.
-# In particular we don't look at `^make:' because GNU make might
-# be invoked under some other name (usually "gmake"), in which
-# case it prints its new name instead of `make'.
-if test "`$am_make -s -f confmf 2> /dev/null | grep -v 'ing directory'`" = "done"; then
- am__include=include
- am__quote=
- _am_result=GNU
-fi
-# Now try BSD make style include.
-if test "$am__include" = "#"; then
- echo '.include "confinc"' > confmf
- if test "`$am_make -s -f confmf 2> /dev/null`" = "done"; then
- am__include=.include
- am__quote="\""
- _am_result=BSD
- fi
-fi
-AC_SUBST([am__include])
-AC_SUBST([am__quote])
-AC_MSG_RESULT([$_am_result])
-rm -f confinc confmf
-])
-
-# Fake the existence of programs that GNU maintainers use. -*- Autoconf -*-
-
-# Copyright (C) 1997, 1999, 2000, 2001, 2003, 2005
-# Free Software Foundation, Inc.
-#
-# This file is free software; the Free Software Foundation
-# gives unlimited permission to copy and/or distribute it,
-# with or without modifications, as long as this notice is preserved.
-
-# serial 4
-
-# AM_MISSING_PROG(NAME, PROGRAM)
-# ------------------------------
-AC_DEFUN([AM_MISSING_PROG],
-[AC_REQUIRE([AM_MISSING_HAS_RUN])
-$1=${$1-"${am_missing_run}$2"}
-AC_SUBST($1)])
-
-
-# AM_MISSING_HAS_RUN
-# ------------------
-# Define MISSING if not defined so far and test if it supports --run.
-# If it does, set am_missing_run to use it, otherwise, to nothing.
-AC_DEFUN([AM_MISSING_HAS_RUN],
-[AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl
-test x"${MISSING+set}" = xset || MISSING="\${SHELL} $am_aux_dir/missing"
-# Use eval to expand $SHELL
-if eval "$MISSING --run true"; then
- am_missing_run="$MISSING --run "
-else
- am_missing_run=
- AC_MSG_WARN([`missing' script is too old or missing])
-fi
-])
-
-# Copyright (C) 2003, 2004, 2005 Free Software Foundation, Inc.
-#
-# This file is free software; the Free Software Foundation
-# gives unlimited permission to copy and/or distribute it,
-# with or without modifications, as long as this notice is preserved.
-
-# AM_PROG_MKDIR_P
-# ---------------
-# Check whether `mkdir -p' is supported, fallback to mkinstalldirs otherwise.
-#
-# Automake 1.8 used `mkdir -m 0755 -p --' to ensure that directories
-# created by `make install' are always world readable, even if the
-# installer happens to have an overly restrictive umask (e.g. 077).
-# This was a mistake. There are at least two reasons why we must not
-# use `-m 0755':
-# - it causes special bits like SGID to be ignored,
-# - it may be too restrictive (some setups expect 775 directories).
-#
-# Do not use -m 0755 and let people choose whatever they expect by
-# setting umask.
-#
-# We cannot accept any implementation of `mkdir' that recognizes `-p'.
-# Some implementations (such as Solaris 8's) are not thread-safe: if a
-# parallel make tries to run `mkdir -p a/b' and `mkdir -p a/c'
-# concurrently, both version can detect that a/ is missing, but only
-# one can create it and the other will error out. Consequently we
-# restrict ourselves to GNU make (using the --version option ensures
-# this.)
-AC_DEFUN([AM_PROG_MKDIR_P],
-[if mkdir -p --version . >/dev/null 2>&1 && test ! -d ./--version; then
- # We used to keeping the `.' as first argument, in order to
- # allow $(mkdir_p) to be used without argument. As in
- # $(mkdir_p) $(somedir)
- # where $(somedir) is conditionally defined. However this is wrong
- # for two reasons:
- # 1. if the package is installed by a user who cannot write `.'
- # make install will fail,
- # 2. the above comment should most certainly read
- # $(mkdir_p) $(DESTDIR)$(somedir)
- # so it does not work when $(somedir) is undefined and
- # $(DESTDIR) is not.
- # To support the latter case, we have to write
- # test -z "$(somedir)" || $(mkdir_p) $(DESTDIR)$(somedir),
- # so the `.' trick is pointless.
- mkdir_p='mkdir -p --'
-else
- # On NextStep and OpenStep, the `mkdir' command does not
- # recognize any option. It will interpret all options as
- # directories to create, and then abort because `.' already
- # exists.
- for d in ./-p ./--version;
- do
- test -d $d && rmdir $d
- done
- # $(mkinstalldirs) is defined by Automake if mkinstalldirs exists.
- if test -f "$ac_aux_dir/mkinstalldirs"; then
- mkdir_p='$(mkinstalldirs)'
- else
- mkdir_p='$(install_sh) -d'
- fi
-fi
-AC_SUBST([mkdir_p])])
-
-# Helper functions for option handling. -*- Autoconf -*-
-
-# Copyright (C) 2001, 2002, 2003, 2005 Free Software Foundation, Inc.
-#
-# This file is free software; the Free Software Foundation
-# gives unlimited permission to copy and/or distribute it,
-# with or without modifications, as long as this notice is preserved.
-
-# serial 3
-
-# _AM_MANGLE_OPTION(NAME)
-# -----------------------
-AC_DEFUN([_AM_MANGLE_OPTION],
-[[_AM_OPTION_]m4_bpatsubst($1, [[^a-zA-Z0-9_]], [_])])
-
-# _AM_SET_OPTION(NAME)
-# ------------------------------
-# Set option NAME. Presently that only means defining a flag for this option.
-AC_DEFUN([_AM_SET_OPTION],
-[m4_define(_AM_MANGLE_OPTION([$1]), 1)])
-
-# _AM_SET_OPTIONS(OPTIONS)
-# ----------------------------------
-# OPTIONS is a space-separated list of Automake options.
-AC_DEFUN([_AM_SET_OPTIONS],
-[AC_FOREACH([_AM_Option], [$1], [_AM_SET_OPTION(_AM_Option)])])
-
-# _AM_IF_OPTION(OPTION, IF-SET, [IF-NOT-SET])
-# -------------------------------------------
-# Execute IF-SET if OPTION is set, IF-NOT-SET otherwise.
-AC_DEFUN([_AM_IF_OPTION],
-[m4_ifset(_AM_MANGLE_OPTION([$1]), [$2], [$3])])
-
-# Check to make sure that the build environment is sane. -*- Autoconf -*-
-
-# Copyright (C) 1996, 1997, 2000, 2001, 2003, 2005
-# Free Software Foundation, Inc.
-#
-# This file is free software; the Free Software Foundation
-# gives unlimited permission to copy and/or distribute it,
-# with or without modifications, as long as this notice is preserved.
-
-# serial 4
-
-# AM_SANITY_CHECK
-# ---------------
-AC_DEFUN([AM_SANITY_CHECK],
-[AC_MSG_CHECKING([whether build environment is sane])
-# Just in case
-sleep 1
-echo timestamp > conftest.file
-# Do `set' in a subshell so we don't clobber the current shell's
-# arguments. Must try -L first in case configure is actually a
-# symlink; some systems play weird games with the mod time of symlinks
-# (eg FreeBSD returns the mod time of the symlink's containing
-# directory).
-if (
- set X `ls -Lt $srcdir/configure conftest.file 2> /dev/null`
- if test "$[*]" = "X"; then
- # -L didn't work.
- set X `ls -t $srcdir/configure conftest.file`
- fi
- rm -f conftest.file
- if test "$[*]" != "X $srcdir/configure conftest.file" \
- && test "$[*]" != "X conftest.file $srcdir/configure"; then
-
- # If neither matched, then we have a broken ls. This can happen
- # if, for instance, CONFIG_SHELL is bash and it inherits a
- # broken ls alias from the environment. This has actually
- # happened. Such a system could not be considered "sane".
- AC_MSG_ERROR([ls -t appears to fail. Make sure there is not a broken
-alias in your environment])
- fi
-
- test "$[2]" = conftest.file
- )
-then
- # Ok.
- :
-else
- AC_MSG_ERROR([newly created file is older than distributed files!
-Check your system clock])
-fi
-AC_MSG_RESULT(yes)])
-
-# Copyright (C) 2001, 2003, 2005 Free Software Foundation, Inc.
-#
-# This file is free software; the Free Software Foundation
-# gives unlimited permission to copy and/or distribute it,
-# with or without modifications, as long as this notice is preserved.
-
-# AM_PROG_INSTALL_STRIP
-# ---------------------
-# One issue with vendor `install' (even GNU) is that you can't
-# specify the program used to strip binaries. This is especially
-# annoying in cross-compiling environments, where the build's strip
-# is unlikely to handle the host's binaries.
-# Fortunately install-sh will honor a STRIPPROG variable, so we
-# always use install-sh in `make install-strip', and initialize
-# STRIPPROG with the value of the STRIP variable (set by the user).
-AC_DEFUN([AM_PROG_INSTALL_STRIP],
-[AC_REQUIRE([AM_PROG_INSTALL_SH])dnl
-# Installed binaries are usually stripped using `strip' when the user
-# run `make install-strip'. However `strip' might not be the right
-# tool to use in cross-compilation environments, therefore Automake
-# will honor the `STRIP' environment variable to overrule this program.
-dnl Don't test for $cross_compiling = yes, because it might be `maybe'.
-if test "$cross_compiling" != no; then
- AC_CHECK_TOOL([STRIP], [strip], :)
-fi
-INSTALL_STRIP_PROGRAM="\${SHELL} \$(install_sh) -c -s"
-AC_SUBST([INSTALL_STRIP_PROGRAM])])
-
-# Check how to create a tarball. -*- Autoconf -*-
-
-# Copyright (C) 2004, 2005 Free Software Foundation, Inc.
-#
-# This file is free software; the Free Software Foundation
-# gives unlimited permission to copy and/or distribute it,
-# with or without modifications, as long as this notice is preserved.
-
-# serial 2
-
-# _AM_PROG_TAR(FORMAT)
-# --------------------
-# Check how to create a tarball in format FORMAT.
-# FORMAT should be one of `v7', `ustar', or `pax'.
-#
-# Substitute a variable $(am__tar) that is a command
-# writing to stdout a FORMAT-tarball containing the directory
-# $tardir.
-# tardir=directory && $(am__tar) > result.tar
-#
-# Substitute a variable $(am__untar) that extract such
-# a tarball read from stdin.
-# $(am__untar) < result.tar
-AC_DEFUN([_AM_PROG_TAR],
-[# Always define AMTAR for backward compatibility.
-AM_MISSING_PROG([AMTAR], [tar])
-m4_if([$1], [v7],
- [am__tar='${AMTAR} chof - "$$tardir"'; am__untar='${AMTAR} xf -'],
- [m4_case([$1], [ustar],, [pax],,
- [m4_fatal([Unknown tar format])])
-AC_MSG_CHECKING([how to create a $1 tar archive])
-# Loop over all known methods to create a tar archive until one works.
-_am_tools='gnutar m4_if([$1], [ustar], [plaintar]) pax cpio none'
-_am_tools=${am_cv_prog_tar_$1-$_am_tools}
-# Do not fold the above two line into one, because Tru64 sh and
-# Solaris sh will not grok spaces in the rhs of `-'.
-for _am_tool in $_am_tools
-do
- case $_am_tool in
- gnutar)
- for _am_tar in tar gnutar gtar;
- do
- AM_RUN_LOG([$_am_tar --version]) && break
- done
- am__tar="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$$tardir"'
- am__tar_="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$tardir"'
- am__untar="$_am_tar -xf -"
- ;;
- plaintar)
- # Must skip GNU tar: if it does not support --format= it doesn't create
- # ustar tarball either.
- (tar --version) >/dev/null 2>&1 && continue
- am__tar='tar chf - "$$tardir"'
- am__tar_='tar chf - "$tardir"'
- am__untar='tar xf -'
- ;;
- pax)
- am__tar='pax -L -x $1 -w "$$tardir"'
- am__tar_='pax -L -x $1 -w "$tardir"'
- am__untar='pax -r'
- ;;
- cpio)
- am__tar='find "$$tardir" -print | cpio -o -H $1 -L'
- am__tar_='find "$tardir" -print | cpio -o -H $1 -L'
- am__untar='cpio -i -H $1 -d'
- ;;
- none)
- am__tar=false
- am__tar_=false
- am__untar=false
- ;;
- esac
-
- # If the value was cached, stop now. We just wanted to have am__tar
- # and am__untar set.
- test -n "${am_cv_prog_tar_$1}" && break
-
- # tar/untar a dummy directory, and stop if the command works
- rm -rf conftest.dir
- mkdir conftest.dir
- echo GrepMe > conftest.dir/file
- AM_RUN_LOG([tardir=conftest.dir && eval $am__tar_ >conftest.tar])
- rm -rf conftest.dir
- if test -s conftest.tar; then
- AM_RUN_LOG([$am__untar <conftest.tar])
- grep GrepMe conftest.dir/file >/dev/null 2>&1 && break
- fi
-done
-rm -rf conftest.dir
-
-AC_CACHE_VAL([am_cv_prog_tar_$1], [am_cv_prog_tar_$1=$_am_tool])
-AC_MSG_RESULT([$am_cv_prog_tar_$1])])
-AC_SUBST([am__tar])
-AC_SUBST([am__untar])
-]) # _AM_PROG_TAR
-
diff --git a/contrib/ofed/libibcm/cm.c b/contrib/ofed/libibcm/cm.c
new file mode 100644
index 0000000..07ba481
--- /dev/null
+++ b/contrib/ofed/libibcm/cm.c
@@ -0,0 +1,1023 @@
+/*
+ * Copyright (c) 2005 Topspin Communications. All rights reserved.
+ * Copyright (c) 2005-2006 Intel Corporation. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ * $Id$
+ */
+#define _GNU_SOURCE
+#include <config.h>
+
+#include <stdlib.h>
+#include <string.h>
+#include <stdio.h>
+#include <fcntl.h>
+#include <errno.h>
+#include <unistd.h>
+#include <pthread.h>
+#include <stddef.h>
+
+#include <infiniband/cm.h>
+#include <rdma/ib_user_cm.h>
+#include <infiniband/driver.h>
+#include <infiniband/marshall.h>
+
+#define PFX "libibcm: "
+
+#define IB_USER_CM_MIN_ABI_VERSION 4
+#define IB_USER_CM_MAX_ABI_VERSION 5
+
+static int abi_ver;
+static pthread_mutex_t mut = PTHREAD_MUTEX_INITIALIZER;
+
+enum {
+ IB_UCM_MAX_DEVICES = 32
+};
+
+static inline int ERR(int err)
+{
+ errno = err;
+ return -1;
+}
+
+
+#define CM_CREATE_MSG_CMD_RESP(msg, cmd, resp, type, size) \
+do { \
+ struct ib_ucm_cmd_hdr *hdr; \
+ \
+ size = sizeof(*hdr) + sizeof(*cmd); \
+ msg = alloca(size); \
+ if (!msg) \
+ return ERR(ENOMEM); \
+ hdr = msg; \
+ cmd = msg + sizeof(*hdr); \
+ hdr->cmd = type; \
+ hdr->in = sizeof(*cmd); \
+ hdr->out = sizeof(*resp); \
+ memset(cmd, 0, sizeof(*cmd)); \
+ resp = alloca(sizeof(*resp)); \
+ if (!resp) \
+ return ERR(ENOMEM); \
+ cmd->response = (uintptr_t)resp;\
+} while (0)
+
+#define CM_CREATE_MSG_CMD(msg, cmd, type, size) \
+do { \
+ struct ib_ucm_cmd_hdr *hdr; \
+ \
+ size = sizeof(*hdr) + sizeof(*cmd); \
+ msg = alloca(size); \
+ if (!msg) \
+ return ERR(ENOMEM); \
+ hdr = msg; \
+ cmd = msg + sizeof(*hdr); \
+ hdr->cmd = type; \
+ hdr->in = sizeof(*cmd); \
+ hdr->out = 0; \
+ memset(cmd, 0, sizeof(*cmd)); \
+} while (0)
+
+struct cm_id_private {
+ struct ib_cm_id id;
+ int events_completed;
+ pthread_cond_t cond;
+ pthread_mutex_t mut;
+};
+
+static int check_abi_version(void)
+{
+ char value[8];
+
+ if (ibv_read_sysfs_file(ibv_get_sysfs_path(),
+ "class/infiniband_cm/abi_version",
+ value, sizeof value) < 0) {
+ fprintf(stderr, PFX "couldn't read ABI version\n");
+ return 0;
+ }
+
+ abi_ver = strtol(value, NULL, 10);
+ if (abi_ver < IB_USER_CM_MIN_ABI_VERSION ||
+ abi_ver > IB_USER_CM_MAX_ABI_VERSION) {
+ fprintf(stderr, PFX "kernel ABI version %d "
+ "doesn't match library version %d.\n",
+ abi_ver, IB_USER_CM_MAX_ABI_VERSION);
+ return -1;
+ }
+ return 0;
+}
+
+static int ucm_init(void)
+{
+ int ret = 0;
+
+ pthread_mutex_lock(&mut);
+ if (!abi_ver)
+ ret = check_abi_version();
+ pthread_mutex_unlock(&mut);
+
+ return ret;
+}
+
+static int ucm_get_dev_index(char *dev_name)
+{
+ char *dev_path;
+ char ibdev[IBV_SYSFS_NAME_MAX];
+ int i, ret;
+
+ for (i = 0; i < IB_UCM_MAX_DEVICES; i++) {
+ ret = asprintf(&dev_path, "/sys/class/infiniband_cm/ucm%d", i);
+ if (ret < 0)
+ return -1;
+
+ ret = ibv_read_sysfs_file(dev_path, "ibdev", ibdev, sizeof ibdev);
+ if (ret < 0)
+ continue;
+
+ if (!strcmp(dev_name, ibdev)) {
+ free(dev_path);
+ return i;
+ }
+
+ free(dev_path);
+ }
+ return -1;
+}
+
+struct ib_cm_device* ib_cm_open_device(struct ibv_context *device_context)
+{
+ struct ib_cm_device *dev;
+ char *dev_path;
+ int index, ret;
+
+ if (ucm_init())
+ return NULL;
+
+ index = ucm_get_dev_index(device_context->device->name);
+ if (index < 0)
+ return NULL;
+
+ dev = malloc(sizeof *dev);
+ if (!dev)
+ return NULL;
+
+ dev->device_context = device_context;
+
+ ret = asprintf(&dev_path, "/dev/ucm%d", index);
+ if (ret < 0)
+ goto err1;
+
+ dev->fd = open(dev_path, O_RDWR);
+ if (dev->fd < 0)
+ goto err2;
+
+ free(dev_path);
+ return dev;
+
+err2:
+ free(dev_path);
+err1:
+ free(dev);
+ return NULL;
+}
+
+void ib_cm_close_device(struct ib_cm_device *device)
+{
+ close(device->fd);
+ free(device);
+}
+
+static void ib_cm_free_id(struct cm_id_private *cm_id_priv)
+{
+ pthread_cond_destroy(&cm_id_priv->cond);
+ pthread_mutex_destroy(&cm_id_priv->mut);
+ free(cm_id_priv);
+}
+
+static struct cm_id_private *ib_cm_alloc_id(struct ib_cm_device *device,
+ void *context)
+{
+ struct cm_id_private *cm_id_priv;
+
+ cm_id_priv = malloc(sizeof *cm_id_priv);
+ if (!cm_id_priv)
+ return NULL;
+
+ memset(cm_id_priv, 0, sizeof *cm_id_priv);
+ cm_id_priv->id.device = device;
+ cm_id_priv->id.context = context;
+ pthread_mutex_init(&cm_id_priv->mut, NULL);
+ if (pthread_cond_init(&cm_id_priv->cond, NULL))
+ goto err;
+
+ return cm_id_priv;
+
+err: ib_cm_free_id(cm_id_priv);
+ return NULL;
+}
+
+int ib_cm_create_id(struct ib_cm_device *device,
+ struct ib_cm_id **cm_id, void *context)
+{
+ struct ib_ucm_create_id_resp *resp;
+ struct ib_ucm_create_id *cmd;
+ struct cm_id_private *cm_id_priv;
+ void *msg;
+ int result;
+ int size;
+
+ cm_id_priv = ib_cm_alloc_id(device, context);
+ if (!cm_id_priv)
+ return ERR(ENOMEM);
+
+ CM_CREATE_MSG_CMD_RESP(msg, cmd, resp, IB_USER_CM_CMD_CREATE_ID, size);
+ cmd->uid = (uintptr_t) cm_id_priv;
+
+ result = write(device->fd, msg, size);
+ if (result != size)
+ goto err;
+
+ VALGRIND_MAKE_MEM_DEFINED(resp, sizeof *resp);
+
+ cm_id_priv->id.handle = resp->id;
+ *cm_id = &cm_id_priv->id;
+ return 0;
+
+err: ib_cm_free_id(cm_id_priv);
+ return result;
+}
+
+int ib_cm_destroy_id(struct ib_cm_id *cm_id)
+{
+ struct ib_ucm_destroy_id_resp *resp;
+ struct ib_ucm_destroy_id *cmd;
+ struct cm_id_private *cm_id_priv;
+ void *msg;
+ int result;
+ int size;
+
+ CM_CREATE_MSG_CMD_RESP(msg, cmd, resp, IB_USER_CM_CMD_DESTROY_ID, size);
+ cmd->id = cm_id->handle;
+
+ result = write(cm_id->device->fd, msg, size);
+ if (result != size)
+ return (result >= 0) ? ERR(ENODATA) : -1;
+
+ VALGRIND_MAKE_MEM_DEFINED(resp, sizeof *resp);
+
+ cm_id_priv = container_of(cm_id, struct cm_id_private, id);
+
+ pthread_mutex_lock(&cm_id_priv->mut);
+ while (cm_id_priv->events_completed < resp->events_reported)
+ pthread_cond_wait(&cm_id_priv->cond, &cm_id_priv->mut);
+ pthread_mutex_unlock(&cm_id_priv->mut);
+
+ ib_cm_free_id(cm_id_priv);
+ return 0;
+}
+
+int ib_cm_attr_id(struct ib_cm_id *cm_id, struct ib_cm_attr_param *param)
+{
+ struct ib_ucm_attr_id_resp *resp;
+ struct ib_ucm_attr_id *cmd;
+ void *msg;
+ int result;
+ int size;
+
+ if (!param)
+ return ERR(EINVAL);
+
+ CM_CREATE_MSG_CMD_RESP(msg, cmd, resp, IB_USER_CM_CMD_ATTR_ID, size);
+ cmd->id = cm_id->handle;
+
+ result = write(cm_id->device->fd, msg, size);
+ if (result != size)
+ return (result >= 0) ? ERR(ENODATA) : -1;
+
+ VALGRIND_MAKE_MEM_DEFINED(resp, sizeof *resp);
+
+ param->service_id = resp->service_id;
+ param->service_mask = resp->service_mask;
+ param->local_id = resp->local_id;
+ param->remote_id = resp->remote_id;
+ return 0;
+}
+
+int ib_cm_init_qp_attr(struct ib_cm_id *cm_id,
+ struct ibv_qp_attr *qp_attr,
+ int *qp_attr_mask)
+{
+ struct ibv_kern_qp_attr *resp;
+ struct ib_ucm_init_qp_attr *cmd;
+ void *msg;
+ int result;
+ int size;
+
+ if (!qp_attr || !qp_attr_mask)
+ return ERR(EINVAL);
+
+ CM_CREATE_MSG_CMD_RESP(msg, cmd, resp, IB_USER_CM_CMD_INIT_QP_ATTR, size);
+ cmd->id = cm_id->handle;
+ cmd->qp_state = qp_attr->qp_state;
+
+ result = write(cm_id->device->fd, msg, size);
+ if (result != size)
+ return (result >= 0) ? ERR(ENODATA) : result;
+
+ VALGRIND_MAKE_MEM_DEFINED(resp, sizeof *resp);
+
+ *qp_attr_mask = resp->qp_attr_mask;
+ ibv_copy_qp_attr_from_kern(qp_attr, resp);
+
+ return 0;
+}
+
+int ib_cm_listen(struct ib_cm_id *cm_id,
+ __be64 service_id,
+ __be64 service_mask)
+{
+ struct ib_ucm_listen *cmd;
+ void *msg;
+ int result;
+ int size;
+
+ CM_CREATE_MSG_CMD(msg, cmd, IB_USER_CM_CMD_LISTEN, size);
+ cmd->id = cm_id->handle;
+ cmd->service_id = service_id;
+ cmd->service_mask = service_mask;
+
+ result = write(cm_id->device->fd, msg, size);
+ if (result != size)
+ return (result >= 0) ? ERR(ENODATA) : -1;
+
+ return 0;
+}
+
+int ib_cm_send_req(struct ib_cm_id *cm_id, struct ib_cm_req_param *param)
+{
+ struct ib_user_path_rec p_path;
+ struct ib_user_path_rec *a_path;
+ struct ib_ucm_req *cmd;
+ void *msg;
+ int result;
+ int size;
+
+ if (!param || !param->primary_path)
+ return ERR(EINVAL);
+
+ CM_CREATE_MSG_CMD(msg, cmd, IB_USER_CM_CMD_SEND_REQ, size);
+ cmd->id = cm_id->handle;
+ cmd->qpn = param->qp_num;
+ cmd->qp_type = param->qp_type;
+ cmd->psn = param->starting_psn;
+ cmd->sid = param->service_id;
+ cmd->peer_to_peer = param->peer_to_peer;
+ cmd->responder_resources = param->responder_resources;
+ cmd->initiator_depth = param->initiator_depth;
+ cmd->remote_cm_response_timeout = param->remote_cm_response_timeout;
+ cmd->flow_control = param->flow_control;
+ cmd->local_cm_response_timeout = param->local_cm_response_timeout;
+ cmd->retry_count = param->retry_count;
+ cmd->rnr_retry_count = param->rnr_retry_count;
+ cmd->max_cm_retries = param->max_cm_retries;
+ cmd->srq = param->srq;
+
+ ibv_copy_path_rec_to_kern(&p_path, param->primary_path);
+ cmd->primary_path = (uintptr_t) &p_path;
+
+ if (param->alternate_path) {
+ a_path = alloca(sizeof(*a_path));
+ if (!a_path)
+ return ERR(ENOMEM);
+
+ ibv_copy_path_rec_to_kern(a_path, param->alternate_path);
+ cmd->alternate_path = (uintptr_t) a_path;
+ }
+
+ if (param->private_data && param->private_data_len) {
+ cmd->data = (uintptr_t) param->private_data;
+ cmd->len = param->private_data_len;
+ }
+
+ result = write(cm_id->device->fd, msg, size);
+ if (result != size)
+ return (result >= 0) ? ERR(ENODATA) : -1;
+
+ return 0;
+}
+
+int ib_cm_send_rep(struct ib_cm_id *cm_id, struct ib_cm_rep_param *param)
+{
+ struct ib_ucm_rep *cmd;
+ void *msg;
+ int result;
+ int size;
+
+ if (!param)
+ return ERR(EINVAL);
+
+ CM_CREATE_MSG_CMD(msg, cmd, IB_USER_CM_CMD_SEND_REP, size);
+ cmd->uid = (uintptr_t) container_of(cm_id, struct cm_id_private, id);
+ cmd->id = cm_id->handle;
+ cmd->qpn = param->qp_num;
+ cmd->psn = param->starting_psn;
+ cmd->responder_resources = param->responder_resources;
+ cmd->initiator_depth = param->initiator_depth;
+ cmd->target_ack_delay = param->target_ack_delay;
+ cmd->failover_accepted = param->failover_accepted;
+ cmd->flow_control = param->flow_control;
+ cmd->rnr_retry_count = param->rnr_retry_count;
+ cmd->srq = param->srq;
+
+ if (param->private_data && param->private_data_len) {
+ cmd->data = (uintptr_t) param->private_data;
+ cmd->len = param->private_data_len;
+ }
+
+ result = write(cm_id->device->fd, msg, size);
+ if (result != size)
+ return (result >= 0) ? ERR(ENODATA) : -1;
+
+ return 0;
+}
+
+static inline int cm_send_private_data(struct ib_cm_id *cm_id,
+ uint32_t type,
+ void *private_data,
+ uint8_t private_data_len)
+{
+ struct ib_ucm_private_data *cmd;
+ void *msg;
+ int result;
+ int size;
+
+ CM_CREATE_MSG_CMD(msg, cmd, type, size);
+ cmd->id = cm_id->handle;
+
+ if (private_data && private_data_len) {
+ cmd->data = (uintptr_t) private_data;
+ cmd->len = private_data_len;
+ }
+
+ result = write(cm_id->device->fd, msg, size);
+ if (result != size)
+ return (result >= 0) ? ERR(ENODATA) : -1;
+
+ return 0;
+}
+
+int ib_cm_send_rtu(struct ib_cm_id *cm_id,
+ void *private_data,
+ uint8_t private_data_len)
+{
+ return cm_send_private_data(cm_id, IB_USER_CM_CMD_SEND_RTU,
+ private_data, private_data_len);
+}
+
+int ib_cm_send_dreq(struct ib_cm_id *cm_id,
+ void *private_data,
+ uint8_t private_data_len)
+{
+ return cm_send_private_data(cm_id, IB_USER_CM_CMD_SEND_DREQ,
+ private_data, private_data_len);
+}
+
+int ib_cm_send_drep(struct ib_cm_id *cm_id,
+ void *private_data,
+ uint8_t private_data_len)
+{
+ return cm_send_private_data(cm_id, IB_USER_CM_CMD_SEND_DREP,
+ private_data, private_data_len);
+}
+
+static int cm_establish(struct ib_cm_id *cm_id)
+{
+ /* In kernel ABI 4 ESTABLISH was repurposed as NOTIFY and gained an
+ extra field. For some reason the compat definitions were deleted
+ from the uapi headers :( */
+#define IB_USER_CM_CMD_ESTABLISH IB_USER_CM_CMD_NOTIFY
+ struct cm_abi_establish { /* ABI 4 support */
+ __u32 id;
+ };
+
+ struct cm_abi_establish *cmd;
+ void *msg;
+ int result;
+ int size;
+
+ CM_CREATE_MSG_CMD(msg, cmd, IB_USER_CM_CMD_ESTABLISH, size);
+ cmd->id = cm_id->handle;
+
+ result = write(cm_id->device->fd, msg, size);
+ if (result != size)
+ return (result >= 0) ? ERR(ENODATA) : -1;
+
+ return 0;
+}
+
+int ib_cm_notify(struct ib_cm_id *cm_id, enum ibv_event_type event)
+{
+ struct ib_ucm_notify *cmd;
+ void *msg;
+ int result;
+ int size;
+
+ if (abi_ver == 4) {
+ if (event == IBV_EVENT_COMM_EST)
+ return cm_establish(cm_id);
+ else
+ return ERR(EINVAL);
+ }
+
+ CM_CREATE_MSG_CMD(msg, cmd, IB_USER_CM_CMD_NOTIFY, size);
+ cmd->id = cm_id->handle;
+ cmd->event = event;
+
+ result = write(cm_id->device->fd, msg, size);
+ if (result != size)
+ return (result >= 0) ? ERR(ENODATA) : -1;
+
+ return 0;
+}
+
+static inline int cm_send_status(struct ib_cm_id *cm_id,
+ uint32_t type,
+ int status,
+ void *info,
+ uint8_t info_length,
+ void *private_data,
+ uint8_t private_data_len)
+{
+ struct ib_ucm_info *cmd;
+ void *msg;
+ int result;
+ int size;
+
+ CM_CREATE_MSG_CMD(msg, cmd, type, size);
+ cmd->id = cm_id->handle;
+ cmd->status = status;
+
+ if (private_data && private_data_len) {
+ cmd->data = (uintptr_t) private_data;
+ cmd->data_len = private_data_len;
+ }
+
+ if (info && info_length) {
+ cmd->info = (uintptr_t) info;
+ cmd->info_len = info_length;
+ }
+
+ result = write(cm_id->device->fd, msg, size);
+ if (result != size)
+ return (result >= 0) ? ERR(ENODATA) : -1;
+
+ return 0;
+}
+
+int ib_cm_send_rej(struct ib_cm_id *cm_id,
+ enum ib_cm_rej_reason reason,
+ void *ari,
+ uint8_t ari_length,
+ void *private_data,
+ uint8_t private_data_len)
+{
+ return cm_send_status(cm_id, IB_USER_CM_CMD_SEND_REJ, reason,
+ ari, ari_length,
+ private_data, private_data_len);
+}
+
+int ib_cm_send_apr(struct ib_cm_id *cm_id,
+ enum ib_cm_apr_status status,
+ void *info,
+ uint8_t info_length,
+ void *private_data,
+ uint8_t private_data_len)
+{
+ return cm_send_status(cm_id, IB_USER_CM_CMD_SEND_APR, status,
+ info, info_length,
+ private_data, private_data_len);
+}
+
+int ib_cm_send_mra(struct ib_cm_id *cm_id,
+ uint8_t service_timeout,
+ void *private_data,
+ uint8_t private_data_len)
+{
+ struct ib_ucm_mra *cmd;
+ void *msg;
+ int result;
+ int size;
+
+ CM_CREATE_MSG_CMD(msg, cmd, IB_USER_CM_CMD_SEND_MRA, size);
+ cmd->id = cm_id->handle;
+ cmd->timeout = service_timeout;
+
+ if (private_data && private_data_len) {
+ cmd->data = (uintptr_t) private_data;
+ cmd->len = private_data_len;
+ }
+
+ result = write(cm_id->device->fd, msg, size);
+ if (result != size)
+ return (result >= 0) ? ERR(ENODATA) : result;
+
+ return 0;
+}
+
+int ib_cm_send_lap(struct ib_cm_id *cm_id,
+ struct ibv_sa_path_rec *alternate_path,
+ void *private_data,
+ uint8_t private_data_len)
+{
+ struct ib_user_path_rec abi_path;
+ struct ib_ucm_lap *cmd;
+ void *msg;
+ int result;
+ int size;
+
+ CM_CREATE_MSG_CMD(msg, cmd, IB_USER_CM_CMD_SEND_LAP, size);
+ cmd->id = cm_id->handle;
+
+ ibv_copy_path_rec_to_kern(&abi_path, alternate_path);
+ cmd->path = (uintptr_t) &abi_path;
+
+ if (private_data && private_data_len) {
+ cmd->data = (uintptr_t) private_data;
+ cmd->len = private_data_len;
+ }
+
+ result = write(cm_id->device->fd, msg, size);
+ if (result != size)
+ return (result >= 0) ? ERR(ENODATA) : -1;
+
+ return 0;
+}
+
+int ib_cm_send_sidr_req(struct ib_cm_id *cm_id,
+ struct ib_cm_sidr_req_param *param)
+{
+ struct ib_user_path_rec abi_path;
+ struct ib_ucm_sidr_req *cmd;
+ void *msg;
+ int result;
+ int size;
+
+ if (!param || !param->path)
+ return ERR(EINVAL);
+
+ CM_CREATE_MSG_CMD(msg, cmd, IB_USER_CM_CMD_SEND_SIDR_REQ, size);
+ cmd->id = cm_id->handle;
+ cmd->sid = param->service_id;
+ cmd->timeout = param->timeout_ms;
+ cmd->max_cm_retries = param->max_cm_retries;
+
+ ibv_copy_path_rec_to_kern(&abi_path, param->path);
+ cmd->path = (uintptr_t) &abi_path;
+
+ if (param->private_data && param->private_data_len) {
+ cmd->data = (uintptr_t) param->private_data;
+ cmd->len = param->private_data_len;
+ }
+
+ result = write(cm_id->device->fd, msg, size);
+ if (result != size)
+ return (result >= 0) ? ERR(ENODATA) : result;
+
+ return 0;
+}
+
+int ib_cm_send_sidr_rep(struct ib_cm_id *cm_id,
+ struct ib_cm_sidr_rep_param *param)
+{
+ struct ib_ucm_sidr_rep *cmd;
+ void *msg;
+ int result;
+ int size;
+
+ if (!param)
+ return ERR(EINVAL);
+
+ CM_CREATE_MSG_CMD(msg, cmd, IB_USER_CM_CMD_SEND_SIDR_REP, size);
+ cmd->id = cm_id->handle;
+ cmd->qpn = param->qp_num;
+ cmd->qkey = param->qkey;
+ cmd->status = param->status;
+
+ if (param->private_data && param->private_data_len) {
+ cmd->data = (uintptr_t) param->private_data;
+ cmd->data_len = param->private_data_len;
+ }
+
+ if (param->info && param->info_length) {
+ cmd->info = (uintptr_t) param->info;
+ cmd->info_len = param->info_length;
+ }
+
+ result = write(cm_id->device->fd, msg, size);
+ if (result != size)
+ return (result >= 0) ? ERR(ENODATA) : -1;
+
+ return 0;
+}
+
+static void cm_event_req_get(struct ib_cm_req_event_param *ureq,
+ struct ib_ucm_req_event_resp *kreq)
+{
+ ureq->remote_ca_guid = kreq->remote_ca_guid;
+ ureq->remote_qkey = kreq->remote_qkey;
+ ureq->remote_qpn = kreq->remote_qpn;
+ ureq->qp_type = kreq->qp_type;
+ ureq->starting_psn = kreq->starting_psn;
+ ureq->responder_resources = kreq->responder_resources;
+ ureq->initiator_depth = kreq->initiator_depth;
+ ureq->local_cm_response_timeout = kreq->local_cm_response_timeout;
+ ureq->flow_control = kreq->flow_control;
+ ureq->remote_cm_response_timeout = kreq->remote_cm_response_timeout;
+ ureq->retry_count = kreq->retry_count;
+ ureq->rnr_retry_count = kreq->rnr_retry_count;
+ ureq->srq = kreq->srq;
+ ureq->port = kreq->port;
+
+ ibv_copy_path_rec_from_kern(ureq->primary_path, &kreq->primary_path);
+ if (ureq->alternate_path)
+ ibv_copy_path_rec_from_kern(ureq->alternate_path,
+ &kreq->alternate_path);
+}
+
+static void cm_event_rep_get(struct ib_cm_rep_event_param *urep,
+ struct ib_ucm_rep_event_resp *krep)
+{
+ urep->remote_ca_guid = krep->remote_ca_guid;
+ urep->remote_qkey = krep->remote_qkey;
+ urep->remote_qpn = krep->remote_qpn;
+ urep->starting_psn = krep->starting_psn;
+ urep->responder_resources = krep->responder_resources;
+ urep->initiator_depth = krep->initiator_depth;
+ urep->target_ack_delay = krep->target_ack_delay;
+ urep->failover_accepted = krep->failover_accepted;
+ urep->flow_control = krep->flow_control;
+ urep->rnr_retry_count = krep->rnr_retry_count;
+ urep->srq = krep->srq;
+}
+
+static void cm_event_sidr_rep_get(struct ib_cm_sidr_rep_event_param *urep,
+ struct ib_ucm_sidr_rep_event_resp *krep)
+{
+ urep->status = krep->status;
+ urep->qkey = krep->qkey;
+ urep->qpn = krep->qpn;
+};
+
+int ib_cm_get_event(struct ib_cm_device *device, struct ib_cm_event **event)
+{
+ struct cm_id_private *cm_id_priv;
+ struct ib_ucm_cmd_hdr *hdr;
+ struct ib_ucm_event_get *cmd;
+ struct ib_ucm_event_resp *resp;
+ struct ib_cm_event *evt = NULL;
+ struct ibv_sa_path_rec *path_a = NULL;
+ struct ibv_sa_path_rec *path_b = NULL;
+ void *data = NULL;
+ void *info = NULL;
+ void *msg;
+ int result = 0;
+ int size;
+
+ if (!event)
+ return ERR(EINVAL);
+
+ size = sizeof(*hdr) + sizeof(*cmd);
+ msg = alloca(size);
+ if (!msg)
+ return ERR(ENOMEM);
+
+ hdr = msg;
+ cmd = msg + sizeof(*hdr);
+
+ hdr->cmd = IB_USER_CM_CMD_EVENT;
+ hdr->in = sizeof(*cmd);
+ hdr->out = sizeof(*resp);
+
+ memset(cmd, 0, sizeof(*cmd));
+
+ resp = alloca(sizeof(*resp));
+ if (!resp)
+ return ERR(ENOMEM);
+
+ cmd->response = (uintptr_t) resp;
+ cmd->data_len = (uint8_t)(~0U);
+ cmd->info_len = (uint8_t)(~0U);
+
+ data = malloc(cmd->data_len);
+ if (!data) {
+ result = ERR(ENOMEM);
+ goto done;
+ }
+
+ info = malloc(cmd->info_len);
+ if (!info) {
+ result = ERR(ENOMEM);
+ goto done;
+ }
+
+ cmd->data = (uintptr_t) data;
+ cmd->info = (uintptr_t) info;
+
+ result = write(device->fd, msg, size);
+ if (result != size) {
+ result = (result >= 0) ? ERR(ENODATA) : -1;
+ goto done;
+ }
+
+ VALGRIND_MAKE_MEM_DEFINED(resp, sizeof *resp);
+
+ /*
+ * decode event.
+ */
+ evt = malloc(sizeof(*evt));
+ if (!evt) {
+ result = ERR(ENOMEM);
+ goto done;
+ }
+ memset(evt, 0, sizeof(*evt));
+ evt->cm_id = (void *) (uintptr_t) resp->uid;
+ evt->event = resp->event;
+
+ if (resp->present & IB_UCM_PRES_PRIMARY) {
+ path_a = malloc(sizeof(*path_a));
+ if (!path_a) {
+ result = ERR(ENOMEM);
+ goto done;
+ }
+ }
+
+ if (resp->present & IB_UCM_PRES_ALTERNATE) {
+ path_b = malloc(sizeof(*path_b));
+ if (!path_b) {
+ result = ERR(ENOMEM);
+ goto done;
+ }
+ }
+
+ switch (evt->event) {
+ case IB_CM_REQ_RECEIVED:
+ evt->param.req_rcvd.listen_id = evt->cm_id;
+ cm_id_priv = ib_cm_alloc_id(evt->cm_id->device,
+ evt->cm_id->context);
+ if (!cm_id_priv) {
+ result = ERR(ENOMEM);
+ goto done;
+ }
+ cm_id_priv->id.handle = resp->id;
+ evt->cm_id = &cm_id_priv->id;
+ evt->param.req_rcvd.primary_path = path_a;
+ evt->param.req_rcvd.alternate_path = path_b;
+ path_a = NULL;
+ path_b = NULL;
+ cm_event_req_get(&evt->param.req_rcvd, &resp->u.req_resp);
+ break;
+ case IB_CM_REP_RECEIVED:
+ cm_event_rep_get(&evt->param.rep_rcvd, &resp->u.rep_resp);
+ break;
+ case IB_CM_MRA_RECEIVED:
+ evt->param.mra_rcvd.service_timeout = resp->u.mra_resp.timeout;
+ break;
+ case IB_CM_REJ_RECEIVED:
+ evt->param.rej_rcvd.reason = resp->u.rej_resp.reason;
+ evt->param.rej_rcvd.ari = info;
+ info = NULL;
+ break;
+ case IB_CM_LAP_RECEIVED:
+ evt->param.lap_rcvd.alternate_path = path_b;
+ path_b = NULL;
+ ibv_copy_path_rec_from_kern(evt->param.lap_rcvd.alternate_path,
+ &resp->u.lap_resp.path);
+ break;
+ case IB_CM_APR_RECEIVED:
+ evt->param.apr_rcvd.ap_status = resp->u.apr_resp.status;
+ evt->param.apr_rcvd.apr_info = info;
+ info = NULL;
+ break;
+ case IB_CM_SIDR_REQ_RECEIVED:
+ evt->param.sidr_req_rcvd.listen_id = evt->cm_id;
+ cm_id_priv = ib_cm_alloc_id(evt->cm_id->device,
+ evt->cm_id->context);
+ if (!cm_id_priv) {
+ result = ERR(ENOMEM);
+ goto done;
+ }
+ cm_id_priv->id.handle = resp->id;
+ evt->cm_id = &cm_id_priv->id;
+ evt->param.sidr_req_rcvd.pkey = resp->u.sidr_req_resp.pkey;
+ evt->param.sidr_req_rcvd.port = resp->u.sidr_req_resp.port;
+ break;
+ case IB_CM_SIDR_REP_RECEIVED:
+ cm_event_sidr_rep_get(&evt->param.sidr_rep_rcvd,
+ &resp->u.sidr_rep_resp);
+ evt->param.sidr_rep_rcvd.info = info;
+ info = NULL;
+ break;
+ default:
+ evt->param.send_status = resp->u.send_status;
+ break;
+ }
+
+ if (resp->present & IB_UCM_PRES_DATA) {
+ evt->private_data = data;
+ data = NULL;
+ }
+
+ *event = evt;
+ evt = NULL;
+ result = 0;
+done:
+ if (data)
+ free(data);
+ if (info)
+ free(info);
+ if (path_a)
+ free(path_a);
+ if (path_b)
+ free(path_b);
+ if (evt)
+ free(evt);
+
+ return result;
+}
+
+int ib_cm_ack_event(struct ib_cm_event *event)
+{
+ struct cm_id_private *cm_id_priv;
+
+ if (!event)
+ return ERR(EINVAL);
+
+ if (event->private_data)
+ free(event->private_data);
+
+ cm_id_priv = container_of(event->cm_id, struct cm_id_private, id);
+
+ switch (event->event) {
+ case IB_CM_REQ_RECEIVED:
+ cm_id_priv = container_of(event->param.req_rcvd.listen_id,
+ struct cm_id_private, id);
+ free(event->param.req_rcvd.primary_path);
+ if (event->param.req_rcvd.alternate_path)
+ free(event->param.req_rcvd.alternate_path);
+ break;
+ case IB_CM_REJ_RECEIVED:
+ if (event->param.rej_rcvd.ari)
+ free(event->param.rej_rcvd.ari);
+ break;
+ case IB_CM_LAP_RECEIVED:
+ free(event->param.lap_rcvd.alternate_path);
+ break;
+ case IB_CM_APR_RECEIVED:
+ if (event->param.apr_rcvd.apr_info)
+ free(event->param.apr_rcvd.apr_info);
+ break;
+ case IB_CM_SIDR_REQ_RECEIVED:
+ cm_id_priv = container_of(event->param.sidr_req_rcvd.listen_id,
+ struct cm_id_private, id);
+ break;
+ case IB_CM_SIDR_REP_RECEIVED:
+ if (event->param.sidr_rep_rcvd.info)
+ free(event->param.sidr_rep_rcvd.info);
+ default:
+ break;
+ }
+
+ pthread_mutex_lock(&cm_id_priv->mut);
+ cm_id_priv->events_completed++;
+ pthread_cond_signal(&cm_id_priv->cond);
+ pthread_mutex_unlock(&cm_id_priv->mut);
+
+ free(event);
+ return 0;
+}
diff --git a/contrib/ofed/libibcm/cm.h b/contrib/ofed/libibcm/cm.h
new file mode 100644
index 0000000..e442f97
--- /dev/null
+++ b/contrib/ofed/libibcm/cm.h
@@ -0,0 +1,592 @@
+/*
+ * Copyright (c) 2004-2006 Intel Corporation. All rights reserved.
+ * Copyright (c) 2004 Topspin Corporation. All rights reserved.
+ * Copyright (c) 2004 Voltaire Corporation. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ * $Id$
+ */
+#if !defined(CM_H)
+#define CM_H
+
+#include <infiniband/verbs.h>
+#include <infiniband/sa.h>
+#ifdef _KERNEL
+#include <linux/types.h>
+#include <sys/endian.h>
+#else
+#include <infiniband/types.h>
+#include <infiniband/endian.h>
+#endif
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+enum ib_cm_event_type {
+ IB_CM_REQ_ERROR,
+ IB_CM_REQ_RECEIVED,
+ IB_CM_REP_ERROR,
+ IB_CM_REP_RECEIVED,
+ IB_CM_RTU_RECEIVED,
+ IB_CM_USER_ESTABLISHED,
+ IB_CM_DREQ_ERROR,
+ IB_CM_DREQ_RECEIVED,
+ IB_CM_DREP_RECEIVED,
+ IB_CM_TIMEWAIT_EXIT,
+ IB_CM_MRA_RECEIVED,
+ IB_CM_REJ_RECEIVED,
+ IB_CM_LAP_ERROR,
+ IB_CM_LAP_RECEIVED,
+ IB_CM_APR_RECEIVED,
+ IB_CM_SIDR_REQ_ERROR,
+ IB_CM_SIDR_REQ_RECEIVED,
+ IB_CM_SIDR_REP_RECEIVED
+};
+
+enum ib_cm_data_size {
+ IB_CM_REQ_PRIVATE_DATA_SIZE = 92,
+ IB_CM_MRA_PRIVATE_DATA_SIZE = 222,
+ IB_CM_REJ_PRIVATE_DATA_SIZE = 148,
+ IB_CM_REP_PRIVATE_DATA_SIZE = 196,
+ IB_CM_RTU_PRIVATE_DATA_SIZE = 224,
+ IB_CM_DREQ_PRIVATE_DATA_SIZE = 220,
+ IB_CM_DREP_PRIVATE_DATA_SIZE = 224,
+ IB_CM_REJ_ARI_LENGTH = 72,
+ IB_CM_LAP_PRIVATE_DATA_SIZE = 168,
+ IB_CM_APR_PRIVATE_DATA_SIZE = 148,
+ IB_CM_APR_INFO_LENGTH = 72,
+ IB_CM_SIDR_REQ_PRIVATE_DATA_SIZE = 216,
+ IB_CM_SIDR_REP_PRIVATE_DATA_SIZE = 136,
+ IB_CM_SIDR_REP_INFO_LENGTH = 72
+};
+
+struct ib_cm_device {
+ struct ibv_context *device_context;
+ int fd;
+};
+
+struct ib_cm_id {
+ void *context;
+ struct ib_cm_device *device;
+ uint32_t handle;
+};
+
+struct ib_cm_req_event_param {
+ struct ib_cm_id *listen_id;
+ uint8_t port;
+
+ struct ibv_sa_path_rec *primary_path;
+ struct ibv_sa_path_rec *alternate_path;
+
+ __be64 remote_ca_guid;
+ uint32_t remote_qkey;
+ uint32_t remote_qpn;
+ enum ibv_qp_type qp_type;
+
+ uint32_t starting_psn;
+ uint8_t responder_resources;
+ uint8_t initiator_depth;
+ unsigned int local_cm_response_timeout:5;
+ unsigned int flow_control:1;
+ unsigned int remote_cm_response_timeout:5;
+ unsigned int retry_count:3;
+ unsigned int rnr_retry_count:3;
+ unsigned int srq:1;
+};
+
+struct ib_cm_rep_event_param {
+ __be64 remote_ca_guid;
+ uint32_t remote_qkey;
+ uint32_t remote_qpn;
+ uint32_t starting_psn;
+ uint8_t responder_resources;
+ uint8_t initiator_depth;
+ unsigned int target_ack_delay:5;
+ unsigned int failover_accepted:2;
+ unsigned int flow_control:1;
+ unsigned int rnr_retry_count:3;
+ unsigned int srq:1;
+};
+
+enum ib_cm_rej_reason {
+ IB_CM_REJ_NO_QP = 1,
+ IB_CM_REJ_NO_EEC = 2,
+ IB_CM_REJ_NO_RESOURCES = 3,
+ IB_CM_REJ_TIMEOUT = 4,
+ IB_CM_REJ_UNSUPPORTED = 5,
+ IB_CM_REJ_INVALID_COMM_ID = 6,
+ IB_CM_REJ_INVALID_COMM_INSTANCE = 7,
+ IB_CM_REJ_INVALID_SERVICE_ID = 8,
+ IB_CM_REJ_INVALID_TRANSPORT_TYPE = 9,
+ IB_CM_REJ_STALE_CONN = 10,
+ IB_CM_REJ_RDC_NOT_EXIST = 11,
+ IB_CM_REJ_INVALID_GID = 12,
+ IB_CM_REJ_INVALID_LID = 13,
+ IB_CM_REJ_INVALID_SL = 14,
+ IB_CM_REJ_INVALID_TRAFFIC_CLASS = 15,
+ IB_CM_REJ_INVALID_HOP_LIMIT = 16,
+ IB_CM_REJ_INVALID_PACKET_RATE = 17,
+ IB_CM_REJ_INVALID_ALT_GID = 18,
+ IB_CM_REJ_INVALID_ALT_LID = 19,
+ IB_CM_REJ_INVALID_ALT_SL = 20,
+ IB_CM_REJ_INVALID_ALT_TRAFFIC_CLASS = 21,
+ IB_CM_REJ_INVALID_ALT_HOP_LIMIT = 22,
+ IB_CM_REJ_INVALID_ALT_PACKET_RATE = 23,
+ IB_CM_REJ_PORT_CM_REDIRECT = 24,
+ IB_CM_REJ_PORT_REDIRECT = 25,
+ IB_CM_REJ_INVALID_MTU = 26,
+ IB_CM_REJ_INSUFFICIENT_RESP_RESOURCES = 27,
+ IB_CM_REJ_CONSUMER_DEFINED = 28,
+ IB_CM_REJ_INVALID_RNR_RETRY = 29,
+ IB_CM_REJ_DUPLICATE_LOCAL_COMM_ID = 30,
+ IB_CM_REJ_INVALID_CLASS_VERSION = 31,
+ IB_CM_REJ_INVALID_FLOW_LABEL = 32,
+ IB_CM_REJ_INVALID_ALT_FLOW_LABEL = 33
+};
+
+struct ib_cm_rej_event_param {
+ enum ib_cm_rej_reason reason;
+ void *ari;
+ uint8_t ari_length;
+};
+
+struct ib_cm_mra_event_param {
+ uint8_t service_timeout;
+};
+
+struct ib_cm_lap_event_param {
+ struct ibv_sa_path_rec *alternate_path;
+};
+
+enum ib_cm_apr_status {
+ IB_CM_APR_SUCCESS,
+ IB_CM_APR_INVALID_COMM_ID,
+ IB_CM_APR_UNSUPPORTED,
+ IB_CM_APR_REJECT,
+ IB_CM_APR_REDIRECT,
+ IB_CM_APR_IS_CURRENT,
+ IB_CM_APR_INVALID_QPN_EECN,
+ IB_CM_APR_INVALID_LID,
+ IB_CM_APR_INVALID_GID,
+ IB_CM_APR_INVALID_FLOW_LABEL,
+ IB_CM_APR_INVALID_TCLASS,
+ IB_CM_APR_INVALID_HOP_LIMIT,
+ IB_CM_APR_INVALID_PACKET_RATE,
+ IB_CM_APR_INVALID_SL
+};
+
+struct ib_cm_apr_event_param {
+ enum ib_cm_apr_status ap_status;
+ void *apr_info;
+ uint8_t info_len;
+};
+
+struct ib_cm_sidr_req_event_param {
+ struct ib_cm_id *listen_id;
+ uint8_t port;
+ uint16_t pkey;
+};
+
+enum ib_cm_sidr_status {
+ IB_SIDR_SUCCESS,
+ IB_SIDR_UNSUPPORTED,
+ IB_SIDR_REJECT,
+ IB_SIDR_NO_QP,
+ IB_SIDR_REDIRECT,
+ IB_SIDR_UNSUPPORTED_VERSION
+};
+
+struct ib_cm_sidr_rep_event_param {
+ enum ib_cm_sidr_status status;
+ uint32_t qkey;
+ uint32_t qpn;
+ void *info;
+ uint8_t info_len;
+};
+
+struct ib_cm_event {
+ struct ib_cm_id *cm_id;
+ enum ib_cm_event_type event;
+ union {
+ struct ib_cm_req_event_param req_rcvd;
+ struct ib_cm_rep_event_param rep_rcvd;
+ /* No data for RTU received events. */
+ struct ib_cm_rej_event_param rej_rcvd;
+ struct ib_cm_mra_event_param mra_rcvd;
+ struct ib_cm_lap_event_param lap_rcvd;
+ struct ib_cm_apr_event_param apr_rcvd;
+ /* No data for DREQ/DREP received events. */
+ struct ib_cm_sidr_req_event_param sidr_req_rcvd;
+ struct ib_cm_sidr_rep_event_param sidr_rep_rcvd;
+ enum ibv_wc_status send_status;
+ } param;
+
+ void *private_data;
+};
+
+/**
+ * ib_cm_get_event - Retrieves the next pending communications event,
+ * if no event is pending waits for an event.
+ * @device: CM device to retrieve the event.
+ * @event: Allocated information about the next communication event.
+ * Event should be freed using ib_cm_ack_event()
+ *
+ * IB_CM_REQ_RECEIVED and IB_CM_SIDR_REQ_RECEIVED communication events
+ * generated as a result of listen requests result in the allocation of a
+ * new @cm_id.
+ * Clients are responsible for destroying the new @cm_id. For peer-to-peer
+ * IB_CM_REQ_RECEIVED and all other events, the returned @cm_id corresponds
+ * to a user's existing communication identifier.
+ */
+int ib_cm_get_event(struct ib_cm_device *device, struct ib_cm_event **event);
+
+/**
+ * ib_cm_ack_event - Free a communications event.
+ * @event: Event to be released.
+ *
+ * All events which are allocated by ib_cm_get_event() must be released,
+ * there should be a one-to-one correspondence between successful gets
+ * and puts.
+ */
+int ib_cm_ack_event(struct ib_cm_event *event);
+
+/**
+ * ib_cm_open_device - Returns the device the CM uses to submit requests
+ * and retrieve events, corresponding to the specified verbs device.
+ *
+ * The CM device contains the file descriptor that the CM uses to
+ * communicate with the kernel CM component. The primary use of the
+ * file descriptor is to test for CM readiness events. When the CM
+ * becomes ready to READ there is a pending event ready, and a subsequent
+ * call to ib_cm_get_event will not block.
+ * Note: The user should not read or write directly to the CM file
+ * descriptor, it will likely result in an error or unexpected
+ * results.
+ */
+struct ib_cm_device* ib_cm_open_device(struct ibv_context *device_context);
+
+/**
+ * ib_cm_close_device - Close a CM device.
+ * @device: Device to close.
+ */
+void ib_cm_close_device(struct ib_cm_device *device);
+
+/**
+ * ib_cm_create_id - Allocate a communication identifier.
+ *
+ * Communication identifiers are used to track connection states, service
+ * ID resolution requests, and listen requests.
+ */
+int ib_cm_create_id(struct ib_cm_device *device,
+ struct ib_cm_id **cm_id, void *context);
+
+/**
+ * ib_cm_destroy_id - Destroy a connection identifier.
+ * @cm_id: Connection identifier to destroy.
+ */
+int ib_cm_destroy_id(struct ib_cm_id *cm_id);
+
+struct ib_cm_attr_param {
+ __be64 service_id;
+ __be64 service_mask;
+ __be32 local_id;
+ __be32 remote_id;
+};
+
+/**
+ * ib_cm_attr_id - Get connection identifier attributes.
+ * @cm_id: Connection identifier to retrieve attributes.
+ * @param: Destination of retreived parameters.
+ *
+ * Not all parameters are valid during all connection states.
+ */
+int ib_cm_attr_id(struct ib_cm_id *cm_id,
+ struct ib_cm_attr_param *param);
+
+#define IB_CM_ASSIGN_SERVICE_ID_MASK htobe64(0xFF00000000000000ULL)
+#define IB_CM_ASSIGN_SERVICE_ID htobe64(0x0200000000000000ULL)
+
+/**
+ * ib_cm_listen - Initiates listening on the specified service ID for
+ * connection and service ID resolution requests.
+ * @cm_id: Connection identifier associated with the listen request.
+ * @service_id: Service identifier matched against incoming connection
+ * and service ID resolution requests. The service ID should be specified
+ * network-byte order.
+ * @service_mask: Mask applied to service ID used to listen across a
+ * range of service IDs. If set to 0, the service ID is matched
+ * exactly.
+ */
+int ib_cm_listen(struct ib_cm_id *cm_id,
+ __be64 service_id,
+ __be64 service_mask);
+
+struct ib_cm_req_param {
+ struct ibv_sa_path_rec *primary_path;
+ struct ibv_sa_path_rec *alternate_path;
+ __be64 service_id;
+ uint32_t qp_num;
+ enum ibv_qp_type qp_type;
+ uint32_t starting_psn;
+ void *private_data;
+ uint8_t private_data_len;
+ uint8_t peer_to_peer;
+ uint8_t responder_resources;
+ uint8_t initiator_depth;
+ uint8_t remote_cm_response_timeout;
+ uint8_t flow_control;
+ uint8_t local_cm_response_timeout;
+ uint8_t retry_count;
+ uint8_t rnr_retry_count;
+ uint8_t max_cm_retries;
+ uint8_t srq;
+};
+
+/**
+ * ib_cm_send_req - Sends a connection request to the remote node.
+ * @cm_id: Connection identifier that will be associated with the
+ * connection request.
+ * @param: Connection request information needed to establish the
+ * connection.
+ */
+int ib_cm_send_req(struct ib_cm_id *cm_id,
+ struct ib_cm_req_param *param);
+
+struct ib_cm_rep_param {
+ uint32_t qp_num;
+ uint32_t starting_psn;
+ void *private_data;
+ uint8_t private_data_len;
+ uint8_t responder_resources;
+ uint8_t initiator_depth;
+ uint8_t target_ack_delay;
+ uint8_t failover_accepted;
+ uint8_t flow_control;
+ uint8_t rnr_retry_count;
+ uint8_t srq;
+};
+
+/**
+ * ib_cm_send_rep - Sends a connection reply in response to a connection
+ * request.
+ * @cm_id: Connection identifier that will be associated with the
+ * connection request.
+ * @param: Connection reply information needed to establish the
+ * connection.
+ */
+int ib_cm_send_rep(struct ib_cm_id *cm_id,
+ struct ib_cm_rep_param *param);
+
+/**
+ * ib_cm_send_rtu - Sends a connection ready to use message in response
+ * to a connection reply message.
+ * @cm_id: Connection identifier associated with the connection request.
+ * @private_data: Optional user-defined private data sent with the
+ * ready to use message.
+ * @private_data_len: Size of the private data buffer, in bytes.
+ */
+int ib_cm_send_rtu(struct ib_cm_id *cm_id,
+ void *private_data,
+ uint8_t private_data_len);
+
+/**
+ * ib_cm_send_dreq - Sends a disconnection request for an existing
+ * connection.
+ * @cm_id: Connection identifier associated with the connection being
+ * released.
+ * @private_data: Optional user-defined private data sent with the
+ * disconnection request message.
+ * @private_data_len: Size of the private data buffer, in bytes.
+ */
+int ib_cm_send_dreq(struct ib_cm_id *cm_id,
+ void *private_data,
+ uint8_t private_data_len);
+
+/**
+ * ib_cm_send_drep - Sends a disconnection reply to a disconnection request.
+ * @cm_id: Connection identifier associated with the connection being
+ * released.
+ * @private_data: Optional user-defined private data sent with the
+ * disconnection reply message.
+ * @private_data_len: Size of the private data buffer, in bytes.
+ */
+int ib_cm_send_drep(struct ib_cm_id *cm_id,
+ void *private_data,
+ uint8_t private_data_len);
+
+/**
+ * ib_cm_notify - Notifies the CM of an event reported to the consumer.
+ * @cm_id: Connection identifier to transition to established.
+ * @event: Type of event.
+ *
+ * This routine should be invoked by users to notify the CM of relevant
+ * communication events. Events that should be reported to the CM and
+ * when to report them are:
+ *
+ * IBV_EVENT_COMM_EST - Used when a message is received on a connected
+ * QP before an RTU has been received.
+ * IBV_EVENT_PATH_MIG - Notifies the CM that the connection has failed over
+ * to the alternate path.
+ */
+int ib_cm_notify(struct ib_cm_id *cm_id, enum ibv_event_type event);
+
+/**
+ * ib_cm_send_rej - Sends a connection rejection message to the
+ * remote node.
+ * @cm_id: Connection identifier associated with the connection being
+ * rejected.
+ * @reason: Reason for the connection request rejection.
+ * @ari: Optional additional rejection information.
+ * @ari_length: Size of the additional rejection information, in bytes.
+ * @private_data: Optional user-defined private data sent with the
+ * rejection message.
+ * @private_data_len: Size of the private data buffer, in bytes.
+ */
+int ib_cm_send_rej(struct ib_cm_id *cm_id,
+ enum ib_cm_rej_reason reason,
+ void *ari,
+ uint8_t ari_length,
+ void *private_data,
+ uint8_t private_data_len);
+
+/**
+ * ib_cm_send_mra - Sends a message receipt acknowledgement to a connection
+ * message.
+ * @cm_id: Connection identifier associated with the connection message.
+ * @service_timeout: The maximum time required for the sender to reply to
+ * to the connection message.
+ * @private_data: Optional user-defined private data sent with the
+ * message receipt acknowledgement.
+ * @private_data_len: Size of the private data buffer, in bytes.
+ */
+int ib_cm_send_mra(struct ib_cm_id *cm_id,
+ uint8_t service_timeout,
+ void *private_data,
+ uint8_t private_data_len);
+
+/**
+ * ib_cm_send_lap - Sends a load alternate path request.
+ * @cm_id: Connection identifier associated with the load alternate path
+ * message.
+ * @alternate_path: A path record that identifies the alternate path to
+ * load.
+ * @private_data: Optional user-defined private data sent with the
+ * load alternate path message.
+ * @private_data_len: Size of the private data buffer, in bytes.
+ */
+int ib_cm_send_lap(struct ib_cm_id *cm_id,
+ struct ibv_sa_path_rec *alternate_path,
+ void *private_data,
+ uint8_t private_data_len);
+
+/**
+ * ib_cm_init_qp_attr - Initializes the QP attributes for use in transitioning
+ * to a specified QP state.
+ * @cm_id: Communication identifier associated with the QP attributes to
+ * initialize.
+ * @qp_attr: On input, specifies the desired QP state. On output, the
+ * mandatory and desired optional attributes will be set in order to
+ * modify the QP to the specified state.
+ * @qp_attr_mask: The QP attribute mask that may be used to transition the
+ * QP to the specified state.
+ *
+ * Users must set the @qp_attr->qp_state to the desired QP state. This call
+ * will set all required attributes for the given transition, along with
+ * known optional attributes. Users may override the attributes returned from
+ * this call before calling ib_modify_qp.
+ */
+int ib_cm_init_qp_attr(struct ib_cm_id *cm_id,
+ struct ibv_qp_attr *qp_attr,
+ int *qp_attr_mask);
+
+/**
+ * ib_cm_send_apr - Sends an alternate path response message in response to
+ * a load alternate path request.
+ * @cm_id: Connection identifier associated with the alternate path response.
+ * @status: Reply status sent with the alternate path response.
+ * @info: Optional additional information sent with the alternate path
+ * response.
+ * @info_length: Size of the additional information, in bytes.
+ * @private_data: Optional user-defined private data sent with the
+ * alternate path response message.
+ * @private_data_len: Size of the private data buffer, in bytes.
+ */
+int ib_cm_send_apr(struct ib_cm_id *cm_id,
+ enum ib_cm_apr_status status,
+ void *info,
+ uint8_t info_length,
+ void *private_data,
+ uint8_t private_data_len);
+
+struct ib_cm_sidr_req_param {
+ struct ibv_sa_path_rec *path;
+ __be64 service_id;
+ int timeout_ms;
+ void *private_data;
+ uint8_t private_data_len;
+ uint8_t max_cm_retries;
+};
+
+/**
+ * ib_cm_send_sidr_req - Sends a service ID resolution request to the
+ * remote node.
+ * @cm_id: Communication identifier that will be associated with the
+ * service ID resolution request.
+ * @param: Service ID resolution request information.
+ */
+int ib_cm_send_sidr_req(struct ib_cm_id *cm_id,
+ struct ib_cm_sidr_req_param *param);
+
+struct ib_cm_sidr_rep_param {
+ uint32_t qp_num;
+ uint32_t qkey;
+ enum ib_cm_sidr_status status;
+ void *info;
+ uint8_t info_length;
+ void *private_data;
+ uint8_t private_data_len;
+};
+
+/**
+ * ib_cm_send_sidr_rep - Sends a service ID resolution reply to the
+ * remote node.
+ * @cm_id: Communication identifier associated with the received service ID
+ * resolution request.
+ * @param: Service ID resolution reply information.
+ */
+int ib_cm_send_sidr_rep(struct ib_cm_id *cm_id,
+ struct ib_cm_sidr_rep_param *param);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* CM_H */
diff --git a/contrib/ofed/libibcm/cm_abi.h b/contrib/ofed/libibcm/cm_abi.h
new file mode 100644
index 0000000..8b76dc1
--- /dev/null
+++ b/contrib/ofed/libibcm/cm_abi.h
@@ -0,0 +1,73 @@
+/*
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#ifndef INFINIBAND_CM_ABI_H
+#define INFINIBAND_CM_ABI_H
+
+#warning "This header is obsolete, use rdma/ib_user_cm.h instead"
+
+#include <rdma/ib_user_cm.h>
+
+#define cm_abi_cmd_hdr ib_ucm_cmd_hdr
+#define cm_abi_create_id ib_ucm_create_id
+#define cm_abi_create_id_resp ib_ucm_create_id_resp
+#define cm_abi_destroy_id ib_ucm_destroy_id
+#define cm_abi_destroy_id_resp ib_ucm_destroy_id_resp
+#define cm_abi_attr_id ib_ucm_attr_id
+#define cm_abi_attr_id_resp ib_ucm_attr_id_resp
+#define cm_abi_init_qp_attr ib_ucm_init_qp_attr
+#define cm_abi_listen ib_ucm_listen
+#define cm_abi_establish ib_ucm_establish
+#define cm_abi_notify ib_ucm_notify
+#define cm_abi_private_data ib_ucm_private_data
+#define cm_abi_req ib_ucm_req
+#define cm_abi_rep ib_ucm_rep
+#define cm_abi_info ib_ucm_info
+#define cm_abi_mra ib_ucm_mra
+#define cm_abi_lap ib_ucm_lap
+#define cm_abi_sidr_req ib_ucm_sidr_req
+#define cm_abi_sidr_rep ib_ucm_sidr_rep
+#define cm_abi_event_get ib_ucm_event_get
+#define cm_abi_req_event_resp ib_ucm_req_event_resp
+#define cm_abi_rep_event_resp ib_ucm_rep_event_resp
+#define cm_abi_rej_event_resp ib_ucm_rej_event_resp
+#define cm_abi_mra_event_resp ib_ucm_mra_event_resp
+#define cm_abi_lap_event_resp ib_ucm_lap_event_resp
+#define cm_abi_apr_event_resp ib_ucm_apr_event_resp
+#define cm_abi_sidr_req_event_resp ib_ucm_sidr_req_event_resp
+#define cm_abi_sidr_rep_event_resp ib_ucm_sidr_rep_event_resp
+#define cm_abi_event_resp ib_ucm_event_resp
+
+#define CM_ABI_PRES_DATA IB_UCM_PRES_DATA
+#define CM_ABI_PRES_INFO IB_UCM_PRES_INFO
+#define CM_ABI_PRES_PRIMARY IB_UCM_PRES_PRIMARY
+#define CM_ABI_PRES_ALTERNATE IB_UCM_PRES_ALTERNATE
+
+#endif
diff --git a/contrib/ofed/libibcm/config.h b/contrib/ofed/libibcm/config.h
new file mode 100644
index 0000000..cdac8f7
--- /dev/null
+++ b/contrib/ofed/libibcm/config.h
@@ -0,0 +1,5 @@
+/* $FreeBSD$ */
+
+#define VALGRIND_MAKE_MEM_DEFINED(...) 0
+
+#define ENODATA ECONNREFUSED
diff --git a/contrib/ofed/libibcm/config.h.in b/contrib/ofed/libibcm/config.h.in
deleted file mode 100644
index 48a9db8..0000000
--- a/contrib/ofed/libibcm/config.h.in
+++ /dev/null
@@ -1,67 +0,0 @@
-/* config.h.in. Generated from configure.in by autoheader. */
-
-/* Define to 1 if you have the <dlfcn.h> header file. */
-#undef HAVE_DLFCN_H
-
-/* Define to 1 if you have the <inttypes.h> header file. */
-#undef HAVE_INTTYPES_H
-
-/* Define to 1 if you have the `ibverbs' library (-libverbs). */
-#undef HAVE_LIBIBVERBS
-
-/* Define to 1 if you have the <memory.h> header file. */
-#undef HAVE_MEMORY_H
-
-/* Define to 1 if you have the <stdint.h> header file. */
-#undef HAVE_STDINT_H
-
-/* Define to 1 if you have the <stdlib.h> header file. */
-#undef HAVE_STDLIB_H
-
-/* Define to 1 if you have the <strings.h> header file. */
-#undef HAVE_STRINGS_H
-
-/* Define to 1 if you have the <string.h> header file. */
-#undef HAVE_STRING_H
-
-/* Define to 1 if you have the <sys/stat.h> header file. */
-#undef HAVE_SYS_STAT_H
-
-/* Define to 1 if you have the <sys/types.h> header file. */
-#undef HAVE_SYS_TYPES_H
-
-/* Define to 1 if you have the <unistd.h> header file. */
-#undef HAVE_UNISTD_H
-
-/* Define to 1 to enable valgrind annotations */
-#undef INCLUDE_VALGRIND
-
-/* Name of package */
-#undef PACKAGE
-
-/* Define to the address where bug reports for this package should be sent. */
-#undef PACKAGE_BUGREPORT
-
-/* Define to the full name of this package. */
-#undef PACKAGE_NAME
-
-/* Define to the full name and version of this package. */
-#undef PACKAGE_STRING
-
-/* Define to the one symbol short name of this package. */
-#undef PACKAGE_TARNAME
-
-/* Define to the version of this package. */
-#undef PACKAGE_VERSION
-
-/* The size of a `long', as computed by sizeof. */
-#undef SIZEOF_LONG
-
-/* Define to 1 if you have the ANSI C header files. */
-#undef STDC_HEADERS
-
-/* Version number of package */
-#undef VERSION
-
-/* Define to empty if `const' does not conform to ANSI C. */
-#undef const
diff --git a/contrib/ofed/libibcm/config/compile b/contrib/ofed/libibcm/config/compile
deleted file mode 100755
index 1b1d232..0000000
--- a/contrib/ofed/libibcm/config/compile
+++ /dev/null
@@ -1,142 +0,0 @@
-#! /bin/sh
-# Wrapper for compilers which do not understand `-c -o'.
-
-scriptversion=2005-05-14.22
-
-# Copyright (C) 1999, 2000, 2003, 2004, 2005 Free Software Foundation, Inc.
-# Written by Tom Tromey <tromey@cygnus.com>.
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2, or (at your option)
-# any later version.
-#
-# This program 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 this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-
-# As a special exception to the GNU General Public License, if you
-# distribute this file as part of a program that contains a
-# configuration script generated by Autoconf, you may include it under
-# the same distribution terms that you use for the rest of that program.
-
-# This file is maintained in Automake, please report
-# bugs to <bug-automake@gnu.org> or send patches to
-# <automake-patches@gnu.org>.
-
-case $1 in
- '')
- echo "$0: No command. Try \`$0 --help' for more information." 1>&2
- exit 1;
- ;;
- -h | --h*)
- cat <<\EOF
-Usage: compile [--help] [--version] PROGRAM [ARGS]
-
-Wrapper for compilers which do not understand `-c -o'.
-Remove `-o dest.o' from ARGS, run PROGRAM with the remaining
-arguments, and rename the output as expected.
-
-If you are trying to build a whole package this is not the
-right script to run: please start by reading the file `INSTALL'.
-
-Report bugs to <bug-automake@gnu.org>.
-EOF
- exit $?
- ;;
- -v | --v*)
- echo "compile $scriptversion"
- exit $?
- ;;
-esac
-
-ofile=
-cfile=
-eat=
-
-for arg
-do
- if test -n "$eat"; then
- eat=
- else
- case $1 in
- -o)
- # configure might choose to run compile as `compile cc -o foo foo.c'.
- # So we strip `-o arg' only if arg is an object.
- eat=1
- case $2 in
- *.o | *.obj)
- ofile=$2
- ;;
- *)
- set x "$@" -o "$2"
- shift
- ;;
- esac
- ;;
- *.c)
- cfile=$1
- set x "$@" "$1"
- shift
- ;;
- *)
- set x "$@" "$1"
- shift
- ;;
- esac
- fi
- shift
-done
-
-if test -z "$ofile" || test -z "$cfile"; then
- # If no `-o' option was seen then we might have been invoked from a
- # pattern rule where we don't need one. That is ok -- this is a
- # normal compilation that the losing compiler can handle. If no
- # `.c' file was seen then we are probably linking. That is also
- # ok.
- exec "$@"
-fi
-
-# Name of file we expect compiler to create.
-cofile=`echo "$cfile" | sed -e 's|^.*/||' -e 's/\.c$/.o/'`
-
-# Create the lock directory.
-# Note: use `[/.-]' here to ensure that we don't use the same name
-# that we are using for the .o file. Also, base the name on the expected
-# object file name, since that is what matters with a parallel build.
-lockdir=`echo "$cofile" | sed -e 's|[/.-]|_|g'`.d
-while true; do
- if mkdir "$lockdir" >/dev/null 2>&1; then
- break
- fi
- sleep 1
-done
-# FIXME: race condition here if user kills between mkdir and trap.
-trap "rmdir '$lockdir'; exit 1" 1 2 15
-
-# Run the compile.
-"$@"
-ret=$?
-
-if test -f "$cofile"; then
- mv "$cofile" "$ofile"
-elif test -f "${cofile}bj"; then
- mv "${cofile}bj" "$ofile"
-fi
-
-rmdir "$lockdir"
-exit $ret
-
-# Local Variables:
-# mode: shell-script
-# sh-indentation: 2
-# eval: (add-hook 'write-file-hooks 'time-stamp)
-# time-stamp-start: "scriptversion="
-# time-stamp-format: "%:y-%02m-%02d.%02H"
-# time-stamp-end: "$"
-# End:
diff --git a/contrib/ofed/libibcm/config/config.guess b/contrib/ofed/libibcm/config/config.guess
deleted file mode 100755
index ad5281e..0000000
--- a/contrib/ofed/libibcm/config/config.guess
+++ /dev/null
@@ -1,1466 +0,0 @@
-#! /bin/sh
-# Attempt to guess a canonical system name.
-# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
-# 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
-
-timestamp='2005-08-03'
-
-# This file is free software; you can redistribute it and/or modify it
-# under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-#
-# This program 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 this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA
-# 02110-1301, USA.
-#
-# As a special exception to the GNU General Public License, if you
-# distribute this file as part of a program that contains a
-# configuration script generated by Autoconf, you may include it under
-# the same distribution terms that you use for the rest of that program.
-
-
-# Originally written by Per Bothner <per@bothner.com>.
-# Please send patches to <config-patches@gnu.org>. Submit a context
-# diff and a properly formatted ChangeLog entry.
-#
-# This script attempts to guess a canonical system name similar to
-# config.sub. If it succeeds, it prints the system name on stdout, and
-# exits with 0. Otherwise, it exits with 1.
-#
-# The plan is that this can be called by configure scripts if you
-# don't specify an explicit build system type.
-
-me=`echo "$0" | sed -e 's,.*/,,'`
-
-usage="\
-Usage: $0 [OPTION]
-
-Output the configuration name of the system \`$me' is run on.
-
-Operation modes:
- -h, --help print this help, then exit
- -t, --time-stamp print date of last modification, then exit
- -v, --version print version number, then exit
-
-Report bugs and patches to <config-patches@gnu.org>."
-
-version="\
-GNU config.guess ($timestamp)
-
-Originally written by Per Bothner.
-Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005
-Free Software Foundation, Inc.
-
-This is free software; see the source for copying conditions. There is NO
-warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
-
-help="
-Try \`$me --help' for more information."
-
-# Parse command line
-while test $# -gt 0 ; do
- case $1 in
- --time-stamp | --time* | -t )
- echo "$timestamp" ; exit ;;
- --version | -v )
- echo "$version" ; exit ;;
- --help | --h* | -h )
- echo "$usage"; exit ;;
- -- ) # Stop option processing
- shift; break ;;
- - ) # Use stdin as input.
- break ;;
- -* )
- echo "$me: invalid option $1$help" >&2
- exit 1 ;;
- * )
- break ;;
- esac
-done
-
-if test $# != 0; then
- echo "$me: too many arguments$help" >&2
- exit 1
-fi
-
-trap 'exit 1' 1 2 15
-
-# CC_FOR_BUILD -- compiler used by this script. Note that the use of a
-# compiler to aid in system detection is discouraged as it requires
-# temporary files to be created and, as you can see below, it is a
-# headache to deal with in a portable fashion.
-
-# Historically, `CC_FOR_BUILD' used to be named `HOST_CC'. We still
-# use `HOST_CC' if defined, but it is deprecated.
-
-# Portable tmp directory creation inspired by the Autoconf team.
-
-set_cc_for_build='
-trap "exitcode=\$?; (rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null) && exit \$exitcode" 0 ;
-trap "rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null; exit 1" 1 2 13 15 ;
-: ${TMPDIR=/tmp} ;
- { tmp=`(umask 077 && mktemp -d -q "$TMPDIR/cgXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" ; } ||
- { test -n "$RANDOM" && tmp=$TMPDIR/cg$$-$RANDOM && (umask 077 && mkdir $tmp) ; } ||
- { tmp=$TMPDIR/cg-$$ && (umask 077 && mkdir $tmp) && echo "Warning: creating insecure temp directory" >&2 ; } ||
- { echo "$me: cannot create a temporary directory in $TMPDIR" >&2 ; exit 1 ; } ;
-dummy=$tmp/dummy ;
-tmpfiles="$dummy.c $dummy.o $dummy.rel $dummy" ;
-case $CC_FOR_BUILD,$HOST_CC,$CC in
- ,,) echo "int x;" > $dummy.c ;
- for c in cc gcc c89 c99 ; do
- if ($c -c -o $dummy.o $dummy.c) >/dev/null 2>&1 ; then
- CC_FOR_BUILD="$c"; break ;
- fi ;
- done ;
- if test x"$CC_FOR_BUILD" = x ; then
- CC_FOR_BUILD=no_compiler_found ;
- fi
- ;;
- ,,*) CC_FOR_BUILD=$CC ;;
- ,*,*) CC_FOR_BUILD=$HOST_CC ;;
-esac ; set_cc_for_build= ;'
-
-# This is needed to find uname on a Pyramid OSx when run in the BSD universe.
-# (ghazi@noc.rutgers.edu 1994-08-24)
-if (test -f /.attbin/uname) >/dev/null 2>&1 ; then
- PATH=$PATH:/.attbin ; export PATH
-fi
-
-UNAME_MACHINE=`(uname -m) 2>/dev/null` || UNAME_MACHINE=unknown
-UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown
-UNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown
-UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown
-
-# Note: order is significant - the case branches are not exclusive.
-
-case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
- *:NetBSD:*:*)
- # NetBSD (nbsd) targets should (where applicable) match one or
- # more of the tupples: *-*-netbsdelf*, *-*-netbsdaout*,
- # *-*-netbsdecoff* and *-*-netbsd*. For targets that recently
- # switched to ELF, *-*-netbsd* would select the old
- # object file format. This provides both forward
- # compatibility and a consistent mechanism for selecting the
- # object file format.
- #
- # Note: NetBSD doesn't particularly care about the vendor
- # portion of the name. We always set it to "unknown".
- sysctl="sysctl -n hw.machine_arch"
- UNAME_MACHINE_ARCH=`(/sbin/$sysctl 2>/dev/null || \
- /usr/sbin/$sysctl 2>/dev/null || echo unknown)`
- case "${UNAME_MACHINE_ARCH}" in
- armeb) machine=armeb-unknown ;;
- arm*) machine=arm-unknown ;;
- sh3el) machine=shl-unknown ;;
- sh3eb) machine=sh-unknown ;;
- *) machine=${UNAME_MACHINE_ARCH}-unknown ;;
- esac
- # The Operating System including object format, if it has switched
- # to ELF recently, or will in the future.
- case "${UNAME_MACHINE_ARCH}" in
- arm*|i386|m68k|ns32k|sh3*|sparc|vax)
- eval $set_cc_for_build
- if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \
- | grep __ELF__ >/dev/null
- then
- # Once all utilities can be ECOFF (netbsdecoff) or a.out (netbsdaout).
- # Return netbsd for either. FIX?
- os=netbsd
- else
- os=netbsdelf
- fi
- ;;
- *)
- os=netbsd
- ;;
- esac
- # The OS release
- # Debian GNU/NetBSD machines have a different userland, and
- # thus, need a distinct triplet. However, they do not need
- # kernel version information, so it can be replaced with a
- # suitable tag, in the style of linux-gnu.
- case "${UNAME_VERSION}" in
- Debian*)
- release='-gnu'
- ;;
- *)
- release=`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'`
- ;;
- esac
- # Since CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM:
- # contains redundant information, the shorter form:
- # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used.
- echo "${machine}-${os}${release}"
- exit ;;
- *:OpenBSD:*:*)
- UNAME_MACHINE_ARCH=`arch | sed 's/OpenBSD.//'`
- echo ${UNAME_MACHINE_ARCH}-unknown-openbsd${UNAME_RELEASE}
- exit ;;
- *:ekkoBSD:*:*)
- echo ${UNAME_MACHINE}-unknown-ekkobsd${UNAME_RELEASE}
- exit ;;
- macppc:MirBSD:*:*)
- echo powerppc-unknown-mirbsd${UNAME_RELEASE}
- exit ;;
- *:MirBSD:*:*)
- echo ${UNAME_MACHINE}-unknown-mirbsd${UNAME_RELEASE}
- exit ;;
- alpha:OSF1:*:*)
- case $UNAME_RELEASE in
- *4.0)
- UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'`
- ;;
- *5.*)
- UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $4}'`
- ;;
- esac
- # According to Compaq, /usr/sbin/psrinfo has been available on
- # OSF/1 and Tru64 systems produced since 1995. I hope that
- # covers most systems running today. This code pipes the CPU
- # types through head -n 1, so we only detect the type of CPU 0.
- ALPHA_CPU_TYPE=`/usr/sbin/psrinfo -v | sed -n -e 's/^ The alpha \(.*\) processor.*$/\1/p' | head -n 1`
- case "$ALPHA_CPU_TYPE" in
- "EV4 (21064)")
- UNAME_MACHINE="alpha" ;;
- "EV4.5 (21064)")
- UNAME_MACHINE="alpha" ;;
- "LCA4 (21066/21068)")
- UNAME_MACHINE="alpha" ;;
- "EV5 (21164)")
- UNAME_MACHINE="alphaev5" ;;
- "EV5.6 (21164A)")
- UNAME_MACHINE="alphaev56" ;;
- "EV5.6 (21164PC)")
- UNAME_MACHINE="alphapca56" ;;
- "EV5.7 (21164PC)")
- UNAME_MACHINE="alphapca57" ;;
- "EV6 (21264)")
- UNAME_MACHINE="alphaev6" ;;
- "EV6.7 (21264A)")
- UNAME_MACHINE="alphaev67" ;;
- "EV6.8CB (21264C)")
- UNAME_MACHINE="alphaev68" ;;
- "EV6.8AL (21264B)")
- UNAME_MACHINE="alphaev68" ;;
- "EV6.8CX (21264D)")
- UNAME_MACHINE="alphaev68" ;;
- "EV6.9A (21264/EV69A)")
- UNAME_MACHINE="alphaev69" ;;
- "EV7 (21364)")
- UNAME_MACHINE="alphaev7" ;;
- "EV7.9 (21364A)")
- UNAME_MACHINE="alphaev79" ;;
- esac
- # A Pn.n version is a patched version.
- # A Vn.n version is a released version.
- # A Tn.n version is a released field test version.
- # A Xn.n version is an unreleased experimental baselevel.
- # 1.2 uses "1.2" for uname -r.
- echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[PVTX]//' | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'`
- exit ;;
- Alpha\ *:Windows_NT*:*)
- # How do we know it's Interix rather than the generic POSIX subsystem?
- # Should we change UNAME_MACHINE based on the output of uname instead
- # of the specific Alpha model?
- echo alpha-pc-interix
- exit ;;
- 21064:Windows_NT:50:3)
- echo alpha-dec-winnt3.5
- exit ;;
- Amiga*:UNIX_System_V:4.0:*)
- echo m68k-unknown-sysv4
- exit ;;
- *:[Aa]miga[Oo][Ss]:*:*)
- echo ${UNAME_MACHINE}-unknown-amigaos
- exit ;;
- *:[Mm]orph[Oo][Ss]:*:*)
- echo ${UNAME_MACHINE}-unknown-morphos
- exit ;;
- *:OS/390:*:*)
- echo i370-ibm-openedition
- exit ;;
- *:z/VM:*:*)
- echo s390-ibm-zvmoe
- exit ;;
- *:OS400:*:*)
- echo powerpc-ibm-os400
- exit ;;
- arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*)
- echo arm-acorn-riscix${UNAME_RELEASE}
- exit ;;
- arm:riscos:*:*|arm:RISCOS:*:*)
- echo arm-unknown-riscos
- exit ;;
- SR2?01:HI-UX/MPP:*:* | SR8000:HI-UX/MPP:*:*)
- echo hppa1.1-hitachi-hiuxmpp
- exit ;;
- Pyramid*:OSx*:*:* | MIS*:OSx*:*:* | MIS*:SMP_DC-OSx*:*:*)
- # akee@wpdis03.wpafb.af.mil (Earle F. Ake) contributed MIS and NILE.
- if test "`(/bin/universe) 2>/dev/null`" = att ; then
- echo pyramid-pyramid-sysv3
- else
- echo pyramid-pyramid-bsd
- fi
- exit ;;
- NILE*:*:*:dcosx)
- echo pyramid-pyramid-svr4
- exit ;;
- DRS?6000:unix:4.0:6*)
- echo sparc-icl-nx6
- exit ;;
- DRS?6000:UNIX_SV:4.2*:7* | DRS?6000:isis:4.2*:7*)
- case `/usr/bin/uname -p` in
- sparc) echo sparc-icl-nx7; exit ;;
- esac ;;
- sun4H:SunOS:5.*:*)
- echo sparc-hal-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
- exit ;;
- sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*)
- echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
- exit ;;
- i86pc:SunOS:5.*:*)
- echo i386-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
- exit ;;
- sun4*:SunOS:6*:*)
- # According to config.sub, this is the proper way to canonicalize
- # SunOS6. Hard to guess exactly what SunOS6 will be like, but
- # it's likely to be more like Solaris than SunOS4.
- echo sparc-sun-solaris3`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
- exit ;;
- sun4*:SunOS:*:*)
- case "`/usr/bin/arch -k`" in
- Series*|S4*)
- UNAME_RELEASE=`uname -v`
- ;;
- esac
- # Japanese Language versions have a version number like `4.1.3-JL'.
- echo sparc-sun-sunos`echo ${UNAME_RELEASE}|sed -e 's/-/_/'`
- exit ;;
- sun3*:SunOS:*:*)
- echo m68k-sun-sunos${UNAME_RELEASE}
- exit ;;
- sun*:*:4.2BSD:*)
- UNAME_RELEASE=`(sed 1q /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null`
- test "x${UNAME_RELEASE}" = "x" && UNAME_RELEASE=3
- case "`/bin/arch`" in
- sun3)
- echo m68k-sun-sunos${UNAME_RELEASE}
- ;;
- sun4)
- echo sparc-sun-sunos${UNAME_RELEASE}
- ;;
- esac
- exit ;;
- aushp:SunOS:*:*)
- echo sparc-auspex-sunos${UNAME_RELEASE}
- exit ;;
- # The situation for MiNT is a little confusing. The machine name
- # can be virtually everything (everything which is not
- # "atarist" or "atariste" at least should have a processor
- # > m68000). The system name ranges from "MiNT" over "FreeMiNT"
- # to the lowercase version "mint" (or "freemint"). Finally
- # the system name "TOS" denotes a system which is actually not
- # MiNT. But MiNT is downward compatible to TOS, so this should
- # be no problem.
- atarist[e]:*MiNT:*:* | atarist[e]:*mint:*:* | atarist[e]:*TOS:*:*)
- echo m68k-atari-mint${UNAME_RELEASE}
- exit ;;
- atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*)
- echo m68k-atari-mint${UNAME_RELEASE}
- exit ;;
- *falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*)
- echo m68k-atari-mint${UNAME_RELEASE}
- exit ;;
- milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*)
- echo m68k-milan-mint${UNAME_RELEASE}
- exit ;;
- hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*)
- echo m68k-hades-mint${UNAME_RELEASE}
- exit ;;
- *:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*)
- echo m68k-unknown-mint${UNAME_RELEASE}
- exit ;;
- m68k:machten:*:*)
- echo m68k-apple-machten${UNAME_RELEASE}
- exit ;;
- powerpc:machten:*:*)
- echo powerpc-apple-machten${UNAME_RELEASE}
- exit ;;
- RISC*:Mach:*:*)
- echo mips-dec-mach_bsd4.3
- exit ;;
- RISC*:ULTRIX:*:*)
- echo mips-dec-ultrix${UNAME_RELEASE}
- exit ;;
- VAX*:ULTRIX*:*:*)
- echo vax-dec-ultrix${UNAME_RELEASE}
- exit ;;
- 2020:CLIX:*:* | 2430:CLIX:*:*)
- echo clipper-intergraph-clix${UNAME_RELEASE}
- exit ;;
- mips:*:*:UMIPS | mips:*:*:RISCos)
- eval $set_cc_for_build
- sed 's/^ //' << EOF >$dummy.c
-#ifdef __cplusplus
-#include <stdio.h> /* for printf() prototype */
- int main (int argc, char *argv[]) {
-#else
- int main (argc, argv) int argc; char *argv[]; {
-#endif
- #if defined (host_mips) && defined (MIPSEB)
- #if defined (SYSTYPE_SYSV)
- printf ("mips-mips-riscos%ssysv\n", argv[1]); exit (0);
- #endif
- #if defined (SYSTYPE_SVR4)
- printf ("mips-mips-riscos%ssvr4\n", argv[1]); exit (0);
- #endif
- #if defined (SYSTYPE_BSD43) || defined(SYSTYPE_BSD)
- printf ("mips-mips-riscos%sbsd\n", argv[1]); exit (0);
- #endif
- #endif
- exit (-1);
- }
-EOF
- $CC_FOR_BUILD -o $dummy $dummy.c &&
- dummyarg=`echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` &&
- SYSTEM_NAME=`$dummy $dummyarg` &&
- { echo "$SYSTEM_NAME"; exit; }
- echo mips-mips-riscos${UNAME_RELEASE}
- exit ;;
- Motorola:PowerMAX_OS:*:*)
- echo powerpc-motorola-powermax
- exit ;;
- Motorola:*:4.3:PL8-*)
- echo powerpc-harris-powermax
- exit ;;
- Night_Hawk:*:*:PowerMAX_OS | Synergy:PowerMAX_OS:*:*)
- echo powerpc-harris-powermax
- exit ;;
- Night_Hawk:Power_UNIX:*:*)
- echo powerpc-harris-powerunix
- exit ;;
- m88k:CX/UX:7*:*)
- echo m88k-harris-cxux7
- exit ;;
- m88k:*:4*:R4*)
- echo m88k-motorola-sysv4
- exit ;;
- m88k:*:3*:R3*)
- echo m88k-motorola-sysv3
- exit ;;
- AViiON:dgux:*:*)
- # DG/UX returns AViiON for all architectures
- UNAME_PROCESSOR=`/usr/bin/uname -p`
- if [ $UNAME_PROCESSOR = mc88100 ] || [ $UNAME_PROCESSOR = mc88110 ]
- then
- if [ ${TARGET_BINARY_INTERFACE}x = m88kdguxelfx ] || \
- [ ${TARGET_BINARY_INTERFACE}x = x ]
- then
- echo m88k-dg-dgux${UNAME_RELEASE}
- else
- echo m88k-dg-dguxbcs${UNAME_RELEASE}
- fi
- else
- echo i586-dg-dgux${UNAME_RELEASE}
- fi
- exit ;;
- M88*:DolphinOS:*:*) # DolphinOS (SVR3)
- echo m88k-dolphin-sysv3
- exit ;;
- M88*:*:R3*:*)
- # Delta 88k system running SVR3
- echo m88k-motorola-sysv3
- exit ;;
- XD88*:*:*:*) # Tektronix XD88 system running UTekV (SVR3)
- echo m88k-tektronix-sysv3
- exit ;;
- Tek43[0-9][0-9]:UTek:*:*) # Tektronix 4300 system running UTek (BSD)
- echo m68k-tektronix-bsd
- exit ;;
- *:IRIX*:*:*)
- echo mips-sgi-irix`echo ${UNAME_RELEASE}|sed -e 's/-/_/g'`
- exit ;;
- ????????:AIX?:[12].1:2) # AIX 2.2.1 or AIX 2.1.1 is RT/PC AIX.
- echo romp-ibm-aix # uname -m gives an 8 hex-code CPU id
- exit ;; # Note that: echo "'`uname -s`'" gives 'AIX '
- i*86:AIX:*:*)
- echo i386-ibm-aix
- exit ;;
- ia64:AIX:*:*)
- if [ -x /usr/bin/oslevel ] ; then
- IBM_REV=`/usr/bin/oslevel`
- else
- IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE}
- fi
- echo ${UNAME_MACHINE}-ibm-aix${IBM_REV}
- exit ;;
- *:AIX:2:3)
- if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then
- eval $set_cc_for_build
- sed 's/^ //' << EOF >$dummy.c
- #include <sys/systemcfg.h>
-
- main()
- {
- if (!__power_pc())
- exit(1);
- puts("powerpc-ibm-aix3.2.5");
- exit(0);
- }
-EOF
- if $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy`
- then
- echo "$SYSTEM_NAME"
- else
- echo rs6000-ibm-aix3.2.5
- fi
- elif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then
- echo rs6000-ibm-aix3.2.4
- else
- echo rs6000-ibm-aix3.2
- fi
- exit ;;
- *:AIX:*:[45])
- IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | sed 1q | awk '{ print $1 }'`
- if /usr/sbin/lsattr -El ${IBM_CPU_ID} | grep ' POWER' >/dev/null 2>&1; then
- IBM_ARCH=rs6000
- else
- IBM_ARCH=powerpc
- fi
- if [ -x /usr/bin/oslevel ] ; then
- IBM_REV=`/usr/bin/oslevel`
- else
- IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE}
- fi
- echo ${IBM_ARCH}-ibm-aix${IBM_REV}
- exit ;;
- *:AIX:*:*)
- echo rs6000-ibm-aix
- exit ;;
- ibmrt:4.4BSD:*|romp-ibm:BSD:*)
- echo romp-ibm-bsd4.4
- exit ;;
- ibmrt:*BSD:*|romp-ibm:BSD:*) # covers RT/PC BSD and
- echo romp-ibm-bsd${UNAME_RELEASE} # 4.3 with uname added to
- exit ;; # report: romp-ibm BSD 4.3
- *:BOSX:*:*)
- echo rs6000-bull-bosx
- exit ;;
- DPX/2?00:B.O.S.:*:*)
- echo m68k-bull-sysv3
- exit ;;
- 9000/[34]??:4.3bsd:1.*:*)
- echo m68k-hp-bsd
- exit ;;
- hp300:4.4BSD:*:* | 9000/[34]??:4.3bsd:2.*:*)
- echo m68k-hp-bsd4.4
- exit ;;
- 9000/[34678]??:HP-UX:*:*)
- HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'`
- case "${UNAME_MACHINE}" in
- 9000/31? ) HP_ARCH=m68000 ;;
- 9000/[34]?? ) HP_ARCH=m68k ;;
- 9000/[678][0-9][0-9])
- if [ -x /usr/bin/getconf ]; then
- sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null`
- sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null`
- case "${sc_cpu_version}" in
- 523) HP_ARCH="hppa1.0" ;; # CPU_PA_RISC1_0
- 528) HP_ARCH="hppa1.1" ;; # CPU_PA_RISC1_1
- 532) # CPU_PA_RISC2_0
- case "${sc_kernel_bits}" in
- 32) HP_ARCH="hppa2.0n" ;;
- 64) HP_ARCH="hppa2.0w" ;;
- '') HP_ARCH="hppa2.0" ;; # HP-UX 10.20
- esac ;;
- esac
- fi
- if [ "${HP_ARCH}" = "" ]; then
- eval $set_cc_for_build
- sed 's/^ //' << EOF >$dummy.c
-
- #define _HPUX_SOURCE
- #include <stdlib.h>
- #include <unistd.h>
-
- int main ()
- {
- #if defined(_SC_KERNEL_BITS)
- long bits = sysconf(_SC_KERNEL_BITS);
- #endif
- long cpu = sysconf (_SC_CPU_VERSION);
-
- switch (cpu)
- {
- case CPU_PA_RISC1_0: puts ("hppa1.0"); break;
- case CPU_PA_RISC1_1: puts ("hppa1.1"); break;
- case CPU_PA_RISC2_0:
- #if defined(_SC_KERNEL_BITS)
- switch (bits)
- {
- case 64: puts ("hppa2.0w"); break;
- case 32: puts ("hppa2.0n"); break;
- default: puts ("hppa2.0"); break;
- } break;
- #else /* !defined(_SC_KERNEL_BITS) */
- puts ("hppa2.0"); break;
- #endif
- default: puts ("hppa1.0"); break;
- }
- exit (0);
- }
-EOF
- (CCOPTS= $CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null) && HP_ARCH=`$dummy`
- test -z "$HP_ARCH" && HP_ARCH=hppa
- fi ;;
- esac
- if [ ${HP_ARCH} = "hppa2.0w" ]
- then
- eval $set_cc_for_build
-
- # hppa2.0w-hp-hpux* has a 64-bit kernel and a compiler generating
- # 32-bit code. hppa64-hp-hpux* has the same kernel and a compiler
- # generating 64-bit code. GNU and HP use different nomenclature:
- #
- # $ CC_FOR_BUILD=cc ./config.guess
- # => hppa2.0w-hp-hpux11.23
- # $ CC_FOR_BUILD="cc +DA2.0w" ./config.guess
- # => hppa64-hp-hpux11.23
-
- if echo __LP64__ | (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) |
- grep __LP64__ >/dev/null
- then
- HP_ARCH="hppa2.0w"
- else
- HP_ARCH="hppa64"
- fi
- fi
- echo ${HP_ARCH}-hp-hpux${HPUX_REV}
- exit ;;
- ia64:HP-UX:*:*)
- HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'`
- echo ia64-hp-hpux${HPUX_REV}
- exit ;;
- 3050*:HI-UX:*:*)
- eval $set_cc_for_build
- sed 's/^ //' << EOF >$dummy.c
- #include <unistd.h>
- int
- main ()
- {
- long cpu = sysconf (_SC_CPU_VERSION);
- /* The order matters, because CPU_IS_HP_MC68K erroneously returns
- true for CPU_PA_RISC1_0. CPU_IS_PA_RISC returns correct
- results, however. */
- if (CPU_IS_PA_RISC (cpu))
- {
- switch (cpu)
- {
- case CPU_PA_RISC1_0: puts ("hppa1.0-hitachi-hiuxwe2"); break;
- case CPU_PA_RISC1_1: puts ("hppa1.1-hitachi-hiuxwe2"); break;
- case CPU_PA_RISC2_0: puts ("hppa2.0-hitachi-hiuxwe2"); break;
- default: puts ("hppa-hitachi-hiuxwe2"); break;
- }
- }
- else if (CPU_IS_HP_MC68K (cpu))
- puts ("m68k-hitachi-hiuxwe2");
- else puts ("unknown-hitachi-hiuxwe2");
- exit (0);
- }
-EOF
- $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy` &&
- { echo "$SYSTEM_NAME"; exit; }
- echo unknown-hitachi-hiuxwe2
- exit ;;
- 9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:* )
- echo hppa1.1-hp-bsd
- exit ;;
- 9000/8??:4.3bsd:*:*)
- echo hppa1.0-hp-bsd
- exit ;;
- *9??*:MPE/iX:*:* | *3000*:MPE/iX:*:*)
- echo hppa1.0-hp-mpeix
- exit ;;
- hp7??:OSF1:*:* | hp8?[79]:OSF1:*:* )
- echo hppa1.1-hp-osf
- exit ;;
- hp8??:OSF1:*:*)
- echo hppa1.0-hp-osf
- exit ;;
- i*86:OSF1:*:*)
- if [ -x /usr/sbin/sysversion ] ; then
- echo ${UNAME_MACHINE}-unknown-osf1mk
- else
- echo ${UNAME_MACHINE}-unknown-osf1
- fi
- exit ;;
- parisc*:Lites*:*:*)
- echo hppa1.1-hp-lites
- exit ;;
- C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*)
- echo c1-convex-bsd
- exit ;;
- C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*)
- if getsysinfo -f scalar_acc
- then echo c32-convex-bsd
- else echo c2-convex-bsd
- fi
- exit ;;
- C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*)
- echo c34-convex-bsd
- exit ;;
- C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*)
- echo c38-convex-bsd
- exit ;;
- C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*)
- echo c4-convex-bsd
- exit ;;
- CRAY*Y-MP:*:*:*)
- echo ymp-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
- exit ;;
- CRAY*[A-Z]90:*:*:*)
- echo ${UNAME_MACHINE}-cray-unicos${UNAME_RELEASE} \
- | sed -e 's/CRAY.*\([A-Z]90\)/\1/' \
- -e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/ \
- -e 's/\.[^.]*$/.X/'
- exit ;;
- CRAY*TS:*:*:*)
- echo t90-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
- exit ;;
- CRAY*T3E:*:*:*)
- echo alphaev5-cray-unicosmk${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
- exit ;;
- CRAY*SV1:*:*:*)
- echo sv1-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
- exit ;;
- *:UNICOS/mp:*:*)
- echo craynv-cray-unicosmp${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
- exit ;;
- F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*)
- FUJITSU_PROC=`uname -m | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'`
- FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'`
- FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'`
- echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}"
- exit ;;
- 5000:UNIX_System_V:4.*:*)
- FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'`
- FUJITSU_REL=`echo ${UNAME_RELEASE} | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/ /_/'`
- echo "sparc-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}"
- exit ;;
- i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*)
- echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE}
- exit ;;
- sparc*:BSD/OS:*:*)
- echo sparc-unknown-bsdi${UNAME_RELEASE}
- exit ;;
- *:BSD/OS:*:*)
- echo ${UNAME_MACHINE}-unknown-bsdi${UNAME_RELEASE}
- exit ;;
- *:FreeBSD:*:*)
- echo ${UNAME_MACHINE}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`
- exit ;;
- i*:CYGWIN*:*)
- echo ${UNAME_MACHINE}-pc-cygwin
- exit ;;
- i*:MINGW*:*)
- echo ${UNAME_MACHINE}-pc-mingw32
- exit ;;
- i*:windows32*:*)
- # uname -m includes "-pc" on this system.
- echo ${UNAME_MACHINE}-mingw32
- exit ;;
- i*:PW*:*)
- echo ${UNAME_MACHINE}-pc-pw32
- exit ;;
- x86:Interix*:[34]*)
- echo i586-pc-interix${UNAME_RELEASE}|sed -e 's/\..*//'
- exit ;;
- [345]86:Windows_95:* | [345]86:Windows_98:* | [345]86:Windows_NT:*)
- echo i${UNAME_MACHINE}-pc-mks
- exit ;;
- i*:Windows_NT*:* | Pentium*:Windows_NT*:*)
- # How do we know it's Interix rather than the generic POSIX subsystem?
- # It also conflicts with pre-2.0 versions of AT&T UWIN. Should we
- # UNAME_MACHINE based on the output of uname instead of i386?
- echo i586-pc-interix
- exit ;;
- i*:UWIN*:*)
- echo ${UNAME_MACHINE}-pc-uwin
- exit ;;
- amd64:CYGWIN*:*:* | x86_64:CYGWIN*:*:*)
- echo x86_64-unknown-cygwin
- exit ;;
- p*:CYGWIN*:*)
- echo powerpcle-unknown-cygwin
- exit ;;
- prep*:SunOS:5.*:*)
- echo powerpcle-unknown-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
- exit ;;
- *:GNU:*:*)
- # the GNU system
- echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-gnu`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'`
- exit ;;
- *:GNU/*:*:*)
- # other systems with GNU libc and userland
- echo ${UNAME_MACHINE}-unknown-`echo ${UNAME_SYSTEM} | sed 's,^[^/]*/,,' | tr '[A-Z]' '[a-z]'``echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`-gnu
- exit ;;
- i*86:Minix:*:*)
- echo ${UNAME_MACHINE}-pc-minix
- exit ;;
- arm*:Linux:*:*)
- echo ${UNAME_MACHINE}-unknown-linux-gnu
- exit ;;
- cris:Linux:*:*)
- echo cris-axis-linux-gnu
- exit ;;
- crisv32:Linux:*:*)
- echo crisv32-axis-linux-gnu
- exit ;;
- frv:Linux:*:*)
- echo frv-unknown-linux-gnu
- exit ;;
- ia64:Linux:*:*)
- echo ${UNAME_MACHINE}-unknown-linux-gnu
- exit ;;
- m32r*:Linux:*:*)
- echo ${UNAME_MACHINE}-unknown-linux-gnu
- exit ;;
- m68*:Linux:*:*)
- echo ${UNAME_MACHINE}-unknown-linux-gnu
- exit ;;
- mips:Linux:*:*)
- eval $set_cc_for_build
- sed 's/^ //' << EOF >$dummy.c
- #undef CPU
- #undef mips
- #undef mipsel
- #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL)
- CPU=mipsel
- #else
- #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB)
- CPU=mips
- #else
- CPU=
- #endif
- #endif
-EOF
- eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep ^CPU=`
- test x"${CPU}" != x && { echo "${CPU}-unknown-linux-gnu"; exit; }
- ;;
- mips64:Linux:*:*)
- eval $set_cc_for_build
- sed 's/^ //' << EOF >$dummy.c
- #undef CPU
- #undef mips64
- #undef mips64el
- #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL)
- CPU=mips64el
- #else
- #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB)
- CPU=mips64
- #else
- CPU=
- #endif
- #endif
-EOF
- eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep ^CPU=`
- test x"${CPU}" != x && { echo "${CPU}-unknown-linux-gnu"; exit; }
- ;;
- or32:Linux:*:*)
- echo or32-unknown-linux-gnu
- exit ;;
- ppc:Linux:*:*)
- echo powerpc-unknown-linux-gnu
- exit ;;
- ppc64:Linux:*:*)
- echo powerpc64-unknown-linux-gnu
- exit ;;
- alpha:Linux:*:*)
- case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in
- EV5) UNAME_MACHINE=alphaev5 ;;
- EV56) UNAME_MACHINE=alphaev56 ;;
- PCA56) UNAME_MACHINE=alphapca56 ;;
- PCA57) UNAME_MACHINE=alphapca56 ;;
- EV6) UNAME_MACHINE=alphaev6 ;;
- EV67) UNAME_MACHINE=alphaev67 ;;
- EV68*) UNAME_MACHINE=alphaev68 ;;
- esac
- objdump --private-headers /bin/sh | grep ld.so.1 >/dev/null
- if test "$?" = 0 ; then LIBC="libc1" ; else LIBC="" ; fi
- echo ${UNAME_MACHINE}-unknown-linux-gnu${LIBC}
- exit ;;
- parisc:Linux:*:* | hppa:Linux:*:*)
- # Look for CPU level
- case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in
- PA7*) echo hppa1.1-unknown-linux-gnu ;;
- PA8*) echo hppa2.0-unknown-linux-gnu ;;
- *) echo hppa-unknown-linux-gnu ;;
- esac
- exit ;;
- parisc64:Linux:*:* | hppa64:Linux:*:*)
- echo hppa64-unknown-linux-gnu
- exit ;;
- s390:Linux:*:* | s390x:Linux:*:*)
- echo ${UNAME_MACHINE}-ibm-linux
- exit ;;
- sh64*:Linux:*:*)
- echo ${UNAME_MACHINE}-unknown-linux-gnu
- exit ;;
- sh*:Linux:*:*)
- echo ${UNAME_MACHINE}-unknown-linux-gnu
- exit ;;
- sparc:Linux:*:* | sparc64:Linux:*:*)
- echo ${UNAME_MACHINE}-unknown-linux-gnu
- exit ;;
- x86_64:Linux:*:*)
- echo x86_64-unknown-linux-gnu
- exit ;;
- i*86:Linux:*:*)
- # The BFD linker knows what the default object file format is, so
- # first see if it will tell us. cd to the root directory to prevent
- # problems with other programs or directories called `ld' in the path.
- # Set LC_ALL=C to ensure ld outputs messages in English.
- ld_supported_targets=`cd /; LC_ALL=C ld --help 2>&1 \
- | sed -ne '/supported targets:/!d
- s/[ ][ ]*/ /g
- s/.*supported targets: *//
- s/ .*//
- p'`
- case "$ld_supported_targets" in
- elf32-i386)
- TENTATIVE="${UNAME_MACHINE}-pc-linux-gnu"
- ;;
- a.out-i386-linux)
- echo "${UNAME_MACHINE}-pc-linux-gnuaout"
- exit ;;
- coff-i386)
- echo "${UNAME_MACHINE}-pc-linux-gnucoff"
- exit ;;
- "")
- # Either a pre-BFD a.out linker (linux-gnuoldld) or
- # one that does not give us useful --help.
- echo "${UNAME_MACHINE}-pc-linux-gnuoldld"
- exit ;;
- esac
- # Determine whether the default compiler is a.out or elf
- eval $set_cc_for_build
- sed 's/^ //' << EOF >$dummy.c
- #include <features.h>
- #ifdef __ELF__
- # ifdef __GLIBC__
- # if __GLIBC__ >= 2
- LIBC=gnu
- # else
- LIBC=gnulibc1
- # endif
- # else
- LIBC=gnulibc1
- # endif
- #else
- #ifdef __INTEL_COMPILER
- LIBC=gnu
- #else
- LIBC=gnuaout
- #endif
- #endif
- #ifdef __dietlibc__
- LIBC=dietlibc
- #endif
-EOF
- eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep ^LIBC=`
- test x"${LIBC}" != x && {
- echo "${UNAME_MACHINE}-pc-linux-${LIBC}"
- exit
- }
- test x"${TENTATIVE}" != x && { echo "${TENTATIVE}"; exit; }
- ;;
- i*86:DYNIX/ptx:4*:*)
- # ptx 4.0 does uname -s correctly, with DYNIX/ptx in there.
- # earlier versions are messed up and put the nodename in both
- # sysname and nodename.
- echo i386-sequent-sysv4
- exit ;;
- i*86:UNIX_SV:4.2MP:2.*)
- # Unixware is an offshoot of SVR4, but it has its own version
- # number series starting with 2...
- # I am not positive that other SVR4 systems won't match this,
- # I just have to hope. -- rms.
- # Use sysv4.2uw... so that sysv4* matches it.
- echo ${UNAME_MACHINE}-pc-sysv4.2uw${UNAME_VERSION}
- exit ;;
- i*86:OS/2:*:*)
- # If we were able to find `uname', then EMX Unix compatibility
- # is probably installed.
- echo ${UNAME_MACHINE}-pc-os2-emx
- exit ;;
- i*86:XTS-300:*:STOP)
- echo ${UNAME_MACHINE}-unknown-stop
- exit ;;
- i*86:atheos:*:*)
- echo ${UNAME_MACHINE}-unknown-atheos
- exit ;;
- i*86:syllable:*:*)
- echo ${UNAME_MACHINE}-pc-syllable
- exit ;;
- i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.0*:*)
- echo i386-unknown-lynxos${UNAME_RELEASE}
- exit ;;
- i*86:*DOS:*:*)
- echo ${UNAME_MACHINE}-pc-msdosdjgpp
- exit ;;
- i*86:*:4.*:* | i*86:SYSTEM_V:4.*:*)
- UNAME_REL=`echo ${UNAME_RELEASE} | sed 's/\/MP$//'`
- if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then
- echo ${UNAME_MACHINE}-univel-sysv${UNAME_REL}
- else
- echo ${UNAME_MACHINE}-pc-sysv${UNAME_REL}
- fi
- exit ;;
- i*86:*:5:[678]*)
- # UnixWare 7.x, OpenUNIX and OpenServer 6.
- case `/bin/uname -X | grep "^Machine"` in
- *486*) UNAME_MACHINE=i486 ;;
- *Pentium) UNAME_MACHINE=i586 ;;
- *Pent*|*Celeron) UNAME_MACHINE=i686 ;;
- esac
- echo ${UNAME_MACHINE}-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}${UNAME_VERSION}
- exit ;;
- i*86:*:3.2:*)
- if test -f /usr/options/cb.name; then
- UNAME_REL=`sed -n 's/.*Version //p' </usr/options/cb.name`
- echo ${UNAME_MACHINE}-pc-isc$UNAME_REL
- elif /bin/uname -X 2>/dev/null >/dev/null ; then
- UNAME_REL=`(/bin/uname -X|grep Release|sed -e 's/.*= //')`
- (/bin/uname -X|grep i80486 >/dev/null) && UNAME_MACHINE=i486
- (/bin/uname -X|grep '^Machine.*Pentium' >/dev/null) \
- && UNAME_MACHINE=i586
- (/bin/uname -X|grep '^Machine.*Pent *II' >/dev/null) \
- && UNAME_MACHINE=i686
- (/bin/uname -X|grep '^Machine.*Pentium Pro' >/dev/null) \
- && UNAME_MACHINE=i686
- echo ${UNAME_MACHINE}-pc-sco$UNAME_REL
- else
- echo ${UNAME_MACHINE}-pc-sysv32
- fi
- exit ;;
- pc:*:*:*)
- # Left here for compatibility:
- # uname -m prints for DJGPP always 'pc', but it prints nothing about
- # the processor, so we play safe by assuming i386.
- echo i386-pc-msdosdjgpp
- exit ;;
- Intel:Mach:3*:*)
- echo i386-pc-mach3
- exit ;;
- paragon:*:*:*)
- echo i860-intel-osf1
- exit ;;
- i860:*:4.*:*) # i860-SVR4
- if grep Stardent /usr/include/sys/uadmin.h >/dev/null 2>&1 ; then
- echo i860-stardent-sysv${UNAME_RELEASE} # Stardent Vistra i860-SVR4
- else # Add other i860-SVR4 vendors below as they are discovered.
- echo i860-unknown-sysv${UNAME_RELEASE} # Unknown i860-SVR4
- fi
- exit ;;
- mini*:CTIX:SYS*5:*)
- # "miniframe"
- echo m68010-convergent-sysv
- exit ;;
- mc68k:UNIX:SYSTEM5:3.51m)
- echo m68k-convergent-sysv
- exit ;;
- M680?0:D-NIX:5.3:*)
- echo m68k-diab-dnix
- exit ;;
- M68*:*:R3V[5678]*:*)
- test -r /sysV68 && { echo 'm68k-motorola-sysv'; exit; } ;;
- 3[345]??:*:4.0:3.0 | 3[34]??A:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 3[34]??/*:*:4.0:3.0 | 4400:*:4.0:3.0 | 4850:*:4.0:3.0 | SKA40:*:4.0:3.0 | SDS2:*:4.0:3.0 | SHG2:*:4.0:3.0 | S7501*:*:4.0:3.0)
- OS_REL=''
- test -r /etc/.relid \
- && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid`
- /bin/uname -p 2>/dev/null | grep 86 >/dev/null \
- && { echo i486-ncr-sysv4.3${OS_REL}; exit; }
- /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \
- && { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;;
- 3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*)
- /bin/uname -p 2>/dev/null | grep 86 >/dev/null \
- && { echo i486-ncr-sysv4; exit; } ;;
- m68*:LynxOS:2.*:* | m68*:LynxOS:3.0*:*)
- echo m68k-unknown-lynxos${UNAME_RELEASE}
- exit ;;
- mc68030:UNIX_System_V:4.*:*)
- echo m68k-atari-sysv4
- exit ;;
- TSUNAMI:LynxOS:2.*:*)
- echo sparc-unknown-lynxos${UNAME_RELEASE}
- exit ;;
- rs6000:LynxOS:2.*:*)
- echo rs6000-unknown-lynxos${UNAME_RELEASE}
- exit ;;
- PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.0*:*)
- echo powerpc-unknown-lynxos${UNAME_RELEASE}
- exit ;;
- SM[BE]S:UNIX_SV:*:*)
- echo mips-dde-sysv${UNAME_RELEASE}
- exit ;;
- RM*:ReliantUNIX-*:*:*)
- echo mips-sni-sysv4
- exit ;;
- RM*:SINIX-*:*:*)
- echo mips-sni-sysv4
- exit ;;
- *:SINIX-*:*:*)
- if uname -p 2>/dev/null >/dev/null ; then
- UNAME_MACHINE=`(uname -p) 2>/dev/null`
- echo ${UNAME_MACHINE}-sni-sysv4
- else
- echo ns32k-sni-sysv
- fi
- exit ;;
- PENTIUM:*:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort
- # says <Richard.M.Bartel@ccMail.Census.GOV>
- echo i586-unisys-sysv4
- exit ;;
- *:UNIX_System_V:4*:FTX*)
- # From Gerald Hewes <hewes@openmarket.com>.
- # How about differentiating between stratus architectures? -djm
- echo hppa1.1-stratus-sysv4
- exit ;;
- *:*:*:FTX*)
- # From seanf@swdc.stratus.com.
- echo i860-stratus-sysv4
- exit ;;
- i*86:VOS:*:*)
- # From Paul.Green@stratus.com.
- echo ${UNAME_MACHINE}-stratus-vos
- exit ;;
- *:VOS:*:*)
- # From Paul.Green@stratus.com.
- echo hppa1.1-stratus-vos
- exit ;;
- mc68*:A/UX:*:*)
- echo m68k-apple-aux${UNAME_RELEASE}
- exit ;;
- news*:NEWS-OS:6*:*)
- echo mips-sony-newsos6
- exit ;;
- R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*)
- if [ -d /usr/nec ]; then
- echo mips-nec-sysv${UNAME_RELEASE}
- else
- echo mips-unknown-sysv${UNAME_RELEASE}
- fi
- exit ;;
- BeBox:BeOS:*:*) # BeOS running on hardware made by Be, PPC only.
- echo powerpc-be-beos
- exit ;;
- BeMac:BeOS:*:*) # BeOS running on Mac or Mac clone, PPC only.
- echo powerpc-apple-beos
- exit ;;
- BePC:BeOS:*:*) # BeOS running on Intel PC compatible.
- echo i586-pc-beos
- exit ;;
- SX-4:SUPER-UX:*:*)
- echo sx4-nec-superux${UNAME_RELEASE}
- exit ;;
- SX-5:SUPER-UX:*:*)
- echo sx5-nec-superux${UNAME_RELEASE}
- exit ;;
- SX-6:SUPER-UX:*:*)
- echo sx6-nec-superux${UNAME_RELEASE}
- exit ;;
- Power*:Rhapsody:*:*)
- echo powerpc-apple-rhapsody${UNAME_RELEASE}
- exit ;;
- *:Rhapsody:*:*)
- echo ${UNAME_MACHINE}-apple-rhapsody${UNAME_RELEASE}
- exit ;;
- *:Darwin:*:*)
- UNAME_PROCESSOR=`uname -p` || UNAME_PROCESSOR=unknown
- case $UNAME_PROCESSOR in
- *86) UNAME_PROCESSOR=i686 ;;
- unknown) UNAME_PROCESSOR=powerpc ;;
- esac
- echo ${UNAME_PROCESSOR}-apple-darwin${UNAME_RELEASE}
- exit ;;
- *:procnto*:*:* | *:QNX:[0123456789]*:*)
- UNAME_PROCESSOR=`uname -p`
- if test "$UNAME_PROCESSOR" = "x86"; then
- UNAME_PROCESSOR=i386
- UNAME_MACHINE=pc
- fi
- echo ${UNAME_PROCESSOR}-${UNAME_MACHINE}-nto-qnx${UNAME_RELEASE}
- exit ;;
- *:QNX:*:4*)
- echo i386-pc-qnx
- exit ;;
- NSE-?:NONSTOP_KERNEL:*:*)
- echo nse-tandem-nsk${UNAME_RELEASE}
- exit ;;
- NSR-?:NONSTOP_KERNEL:*:*)
- echo nsr-tandem-nsk${UNAME_RELEASE}
- exit ;;
- *:NonStop-UX:*:*)
- echo mips-compaq-nonstopux
- exit ;;
- BS2000:POSIX*:*:*)
- echo bs2000-siemens-sysv
- exit ;;
- DS/*:UNIX_System_V:*:*)
- echo ${UNAME_MACHINE}-${UNAME_SYSTEM}-${UNAME_RELEASE}
- exit ;;
- *:Plan9:*:*)
- # "uname -m" is not consistent, so use $cputype instead. 386
- # is converted to i386 for consistency with other x86
- # operating systems.
- if test "$cputype" = "386"; then
- UNAME_MACHINE=i386
- else
- UNAME_MACHINE="$cputype"
- fi
- echo ${UNAME_MACHINE}-unknown-plan9
- exit ;;
- *:TOPS-10:*:*)
- echo pdp10-unknown-tops10
- exit ;;
- *:TENEX:*:*)
- echo pdp10-unknown-tenex
- exit ;;
- KS10:TOPS-20:*:* | KL10:TOPS-20:*:* | TYPE4:TOPS-20:*:*)
- echo pdp10-dec-tops20
- exit ;;
- XKL-1:TOPS-20:*:* | TYPE5:TOPS-20:*:*)
- echo pdp10-xkl-tops20
- exit ;;
- *:TOPS-20:*:*)
- echo pdp10-unknown-tops20
- exit ;;
- *:ITS:*:*)
- echo pdp10-unknown-its
- exit ;;
- SEI:*:*:SEIUX)
- echo mips-sei-seiux${UNAME_RELEASE}
- exit ;;
- *:DragonFly:*:*)
- echo ${UNAME_MACHINE}-unknown-dragonfly`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`
- exit ;;
- *:*VMS:*:*)
- UNAME_MACHINE=`(uname -p) 2>/dev/null`
- case "${UNAME_MACHINE}" in
- A*) echo alpha-dec-vms ; exit ;;
- I*) echo ia64-dec-vms ; exit ;;
- V*) echo vax-dec-vms ; exit ;;
- esac ;;
- *:XENIX:*:SysV)
- echo i386-pc-xenix
- exit ;;
- i*86:skyos:*:*)
- echo ${UNAME_MACHINE}-pc-skyos`echo ${UNAME_RELEASE}` | sed -e 's/ .*$//'
- exit ;;
-esac
-
-#echo '(No uname command or uname output not recognized.)' 1>&2
-#echo "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" 1>&2
-
-eval $set_cc_for_build
-cat >$dummy.c <<EOF
-#ifdef _SEQUENT_
-# include <sys/types.h>
-# include <sys/utsname.h>
-#endif
-main ()
-{
-#if defined (sony)
-#if defined (MIPSEB)
- /* BFD wants "bsd" instead of "newsos". Perhaps BFD should be changed,
- I don't know.... */
- printf ("mips-sony-bsd\n"); exit (0);
-#else
-#include <sys/param.h>
- printf ("m68k-sony-newsos%s\n",
-#ifdef NEWSOS4
- "4"
-#else
- ""
-#endif
- ); exit (0);
-#endif
-#endif
-
-#if defined (__arm) && defined (__acorn) && defined (__unix)
- printf ("arm-acorn-riscix\n"); exit (0);
-#endif
-
-#if defined (hp300) && !defined (hpux)
- printf ("m68k-hp-bsd\n"); exit (0);
-#endif
-
-#if defined (NeXT)
-#if !defined (__ARCHITECTURE__)
-#define __ARCHITECTURE__ "m68k"
-#endif
- int version;
- version=`(hostinfo | sed -n 's/.*NeXT Mach \([0-9]*\).*/\1/p') 2>/dev/null`;
- if (version < 4)
- printf ("%s-next-nextstep%d\n", __ARCHITECTURE__, version);
- else
- printf ("%s-next-openstep%d\n", __ARCHITECTURE__, version);
- exit (0);
-#endif
-
-#if defined (MULTIMAX) || defined (n16)
-#if defined (UMAXV)
- printf ("ns32k-encore-sysv\n"); exit (0);
-#else
-#if defined (CMU)
- printf ("ns32k-encore-mach\n"); exit (0);
-#else
- printf ("ns32k-encore-bsd\n"); exit (0);
-#endif
-#endif
-#endif
-
-#if defined (__386BSD__)
- printf ("i386-pc-bsd\n"); exit (0);
-#endif
-
-#if defined (sequent)
-#if defined (i386)
- printf ("i386-sequent-dynix\n"); exit (0);
-#endif
-#if defined (ns32000)
- printf ("ns32k-sequent-dynix\n"); exit (0);
-#endif
-#endif
-
-#if defined (_SEQUENT_)
- struct utsname un;
-
- uname(&un);
-
- if (strncmp(un.version, "V2", 2) == 0) {
- printf ("i386-sequent-ptx2\n"); exit (0);
- }
- if (strncmp(un.version, "V1", 2) == 0) { /* XXX is V1 correct? */
- printf ("i386-sequent-ptx1\n"); exit (0);
- }
- printf ("i386-sequent-ptx\n"); exit (0);
-
-#endif
-
-#if defined (vax)
-# if !defined (ultrix)
-# include <sys/param.h>
-# if defined (BSD)
-# if BSD == 43
- printf ("vax-dec-bsd4.3\n"); exit (0);
-# else
-# if BSD == 199006
- printf ("vax-dec-bsd4.3reno\n"); exit (0);
-# else
- printf ("vax-dec-bsd\n"); exit (0);
-# endif
-# endif
-# else
- printf ("vax-dec-bsd\n"); exit (0);
-# endif
-# else
- printf ("vax-dec-ultrix\n"); exit (0);
-# endif
-#endif
-
-#if defined (alliant) && defined (i860)
- printf ("i860-alliant-bsd\n"); exit (0);
-#endif
-
- exit (1);
-}
-EOF
-
-$CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null && SYSTEM_NAME=`$dummy` &&
- { echo "$SYSTEM_NAME"; exit; }
-
-# Apollos put the system type in the environment.
-
-test -d /usr/apollo && { echo ${ISP}-apollo-${SYSTYPE}; exit; }
-
-# Convex versions that predate uname can use getsysinfo(1)
-
-if [ -x /usr/convex/getsysinfo ]
-then
- case `getsysinfo -f cpu_type` in
- c1*)
- echo c1-convex-bsd
- exit ;;
- c2*)
- if getsysinfo -f scalar_acc
- then echo c32-convex-bsd
- else echo c2-convex-bsd
- fi
- exit ;;
- c34*)
- echo c34-convex-bsd
- exit ;;
- c38*)
- echo c38-convex-bsd
- exit ;;
- c4*)
- echo c4-convex-bsd
- exit ;;
- esac
-fi
-
-cat >&2 <<EOF
-$0: unable to guess system type
-
-This script, last modified $timestamp, has failed to recognize
-the operating system you are using. It is advised that you
-download the most up to date version of the config scripts from
-
- http://savannah.gnu.org/cgi-bin/viewcvs/*checkout*/config/config/config.guess
-and
- http://savannah.gnu.org/cgi-bin/viewcvs/*checkout*/config/config/config.sub
-
-If the version you run ($0) is already up to date, please
-send the following data and any information you think might be
-pertinent to <config-patches@gnu.org> in order to provide the needed
-information to handle your system.
-
-config.guess timestamp = $timestamp
-
-uname -m = `(uname -m) 2>/dev/null || echo unknown`
-uname -r = `(uname -r) 2>/dev/null || echo unknown`
-uname -s = `(uname -s) 2>/dev/null || echo unknown`
-uname -v = `(uname -v) 2>/dev/null || echo unknown`
-
-/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null`
-/bin/uname -X = `(/bin/uname -X) 2>/dev/null`
-
-hostinfo = `(hostinfo) 2>/dev/null`
-/bin/universe = `(/bin/universe) 2>/dev/null`
-/usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null`
-/bin/arch = `(/bin/arch) 2>/dev/null`
-/usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null`
-/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null`
-
-UNAME_MACHINE = ${UNAME_MACHINE}
-UNAME_RELEASE = ${UNAME_RELEASE}
-UNAME_SYSTEM = ${UNAME_SYSTEM}
-UNAME_VERSION = ${UNAME_VERSION}
-EOF
-
-exit 1
-
-# Local variables:
-# eval: (add-hook 'write-file-hooks 'time-stamp)
-# time-stamp-start: "timestamp='"
-# time-stamp-format: "%:y-%02m-%02d"
-# time-stamp-end: "'"
-# End:
diff --git a/contrib/ofed/libibcm/config/config.sub b/contrib/ofed/libibcm/config/config.sub
deleted file mode 100755
index 1c366df..0000000
--- a/contrib/ofed/libibcm/config/config.sub
+++ /dev/null
@@ -1,1579 +0,0 @@
-#! /bin/sh
-# Configuration validation subroutine script.
-# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
-# 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
-
-timestamp='2005-07-08'
-
-# This file is (in principle) common to ALL GNU software.
-# The presence of a machine in this file suggests that SOME GNU software
-# can handle that machine. It does not imply ALL GNU software can.
-#
-# This file is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-#
-# This program 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 this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA
-# 02110-1301, USA.
-#
-# As a special exception to the GNU General Public License, if you
-# distribute this file as part of a program that contains a
-# configuration script generated by Autoconf, you may include it under
-# the same distribution terms that you use for the rest of that program.
-
-
-# Please send patches to <config-patches@gnu.org>. Submit a context
-# diff and a properly formatted ChangeLog entry.
-#
-# Configuration subroutine to validate and canonicalize a configuration type.
-# Supply the specified configuration type as an argument.
-# If it is invalid, we print an error message on stderr and exit with code 1.
-# Otherwise, we print the canonical config type on stdout and succeed.
-
-# This file is supposed to be the same for all GNU packages
-# and recognize all the CPU types, system types and aliases
-# that are meaningful with *any* GNU software.
-# Each package is responsible for reporting which valid configurations
-# it does not support. The user should be able to distinguish
-# a failure to support a valid configuration from a meaningless
-# configuration.
-
-# The goal of this file is to map all the various variations of a given
-# machine specification into a single specification in the form:
-# CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM
-# or in some cases, the newer four-part form:
-# CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM
-# It is wrong to echo any other type of specification.
-
-me=`echo "$0" | sed -e 's,.*/,,'`
-
-usage="\
-Usage: $0 [OPTION] CPU-MFR-OPSYS
- $0 [OPTION] ALIAS
-
-Canonicalize a configuration name.
-
-Operation modes:
- -h, --help print this help, then exit
- -t, --time-stamp print date of last modification, then exit
- -v, --version print version number, then exit
-
-Report bugs and patches to <config-patches@gnu.org>."
-
-version="\
-GNU config.sub ($timestamp)
-
-Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005
-Free Software Foundation, Inc.
-
-This is free software; see the source for copying conditions. There is NO
-warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
-
-help="
-Try \`$me --help' for more information."
-
-# Parse command line
-while test $# -gt 0 ; do
- case $1 in
- --time-stamp | --time* | -t )
- echo "$timestamp" ; exit ;;
- --version | -v )
- echo "$version" ; exit ;;
- --help | --h* | -h )
- echo "$usage"; exit ;;
- -- ) # Stop option processing
- shift; break ;;
- - ) # Use stdin as input.
- break ;;
- -* )
- echo "$me: invalid option $1$help"
- exit 1 ;;
-
- *local*)
- # First pass through any local machine types.
- echo $1
- exit ;;
-
- * )
- break ;;
- esac
-done
-
-case $# in
- 0) echo "$me: missing argument$help" >&2
- exit 1;;
- 1) ;;
- *) echo "$me: too many arguments$help" >&2
- exit 1;;
-esac
-
-# Separate what the user gave into CPU-COMPANY and OS or KERNEL-OS (if any).
-# Here we must recognize all the valid KERNEL-OS combinations.
-maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'`
-case $maybe_os in
- nto-qnx* | linux-gnu* | linux-dietlibc | linux-uclibc* | uclinux-uclibc* | uclinux-gnu* | \
- kfreebsd*-gnu* | knetbsd*-gnu* | netbsd*-gnu* | storm-chaos* | os2-emx* | rtmk-nova*)
- os=-$maybe_os
- basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`
- ;;
- *)
- basic_machine=`echo $1 | sed 's/-[^-]*$//'`
- if [ $basic_machine != $1 ]
- then os=`echo $1 | sed 's/.*-/-/'`
- else os=; fi
- ;;
-esac
-
-### Let's recognize common machines as not being operating systems so
-### that things like config.sub decstation-3100 work. We also
-### recognize some manufacturers as not being operating systems, so we
-### can provide default operating systems below.
-case $os in
- -sun*os*)
- # Prevent following clause from handling this invalid input.
- ;;
- -dec* | -mips* | -sequent* | -encore* | -pc532* | -sgi* | -sony* | \
- -att* | -7300* | -3300* | -delta* | -motorola* | -sun[234]* | \
- -unicom* | -ibm* | -next | -hp | -isi* | -apollo | -altos* | \
- -convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\
- -c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \
- -harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \
- -apple | -axis | -knuth | -cray)
- os=
- basic_machine=$1
- ;;
- -sim | -cisco | -oki | -wec | -winbond)
- os=
- basic_machine=$1
- ;;
- -scout)
- ;;
- -wrs)
- os=-vxworks
- basic_machine=$1
- ;;
- -chorusos*)
- os=-chorusos
- basic_machine=$1
- ;;
- -chorusrdb)
- os=-chorusrdb
- basic_machine=$1
- ;;
- -hiux*)
- os=-hiuxwe2
- ;;
- -sco5)
- os=-sco3.2v5
- basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
- ;;
- -sco4)
- os=-sco3.2v4
- basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
- ;;
- -sco3.2.[4-9]*)
- os=`echo $os | sed -e 's/sco3.2./sco3.2v/'`
- basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
- ;;
- -sco3.2v[4-9]*)
- # Don't forget version if it is 3.2v4 or newer.
- basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
- ;;
- -sco*)
- os=-sco3.2v2
- basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
- ;;
- -udk*)
- basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
- ;;
- -isc)
- os=-isc2.2
- basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
- ;;
- -clix*)
- basic_machine=clipper-intergraph
- ;;
- -isc*)
- basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
- ;;
- -lynx*)
- os=-lynxos
- ;;
- -ptx*)
- basic_machine=`echo $1 | sed -e 's/86-.*/86-sequent/'`
- ;;
- -windowsnt*)
- os=`echo $os | sed -e 's/windowsnt/winnt/'`
- ;;
- -psos*)
- os=-psos
- ;;
- -mint | -mint[0-9]*)
- basic_machine=m68k-atari
- os=-mint
- ;;
-esac
-
-# Decode aliases for certain CPU-COMPANY combinations.
-case $basic_machine in
- # Recognize the basic CPU types without company name.
- # Some are omitted here because they have special meanings below.
- 1750a | 580 \
- | a29k \
- | alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \
- | alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | alpha64pca5[67] \
- | am33_2.0 \
- | arc | arm | arm[bl]e | arme[lb] | armv[2345] | armv[345][lb] | avr \
- | bfin \
- | c4x | clipper \
- | d10v | d30v | dlx | dsp16xx \
- | fr30 | frv \
- | h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \
- | i370 | i860 | i960 | ia64 \
- | ip2k | iq2000 \
- | m32r | m32rle | m68000 | m68k | m88k | maxq | mcore \
- | mips | mipsbe | mipseb | mipsel | mipsle \
- | mips16 \
- | mips64 | mips64el \
- | mips64vr | mips64vrel \
- | mips64orion | mips64orionel \
- | mips64vr4100 | mips64vr4100el \
- | mips64vr4300 | mips64vr4300el \
- | mips64vr5000 | mips64vr5000el \
- | mips64vr5900 | mips64vr5900el \
- | mipsisa32 | mipsisa32el \
- | mipsisa32r2 | mipsisa32r2el \
- | mipsisa64 | mipsisa64el \
- | mipsisa64r2 | mipsisa64r2el \
- | mipsisa64sb1 | mipsisa64sb1el \
- | mipsisa64sr71k | mipsisa64sr71kel \
- | mipstx39 | mipstx39el \
- | mn10200 | mn10300 \
- | ms1 \
- | msp430 \
- | ns16k | ns32k \
- | or32 \
- | pdp10 | pdp11 | pj | pjl \
- | powerpc | powerpc64 | powerpc64le | powerpcle | ppcbe \
- | pyramid \
- | sh | sh[1234] | sh[24]a | sh[23]e | sh[34]eb | shbe | shle | sh[1234]le | sh3ele \
- | sh64 | sh64le \
- | sparc | sparc64 | sparc64b | sparc86x | sparclet | sparclite \
- | sparcv8 | sparcv9 | sparcv9b \
- | strongarm \
- | tahoe | thumb | tic4x | tic80 | tron \
- | v850 | v850e \
- | we32k \
- | x86 | xscale | xscalee[bl] | xstormy16 | xtensa \
- | z8k)
- basic_machine=$basic_machine-unknown
- ;;
- m32c)
- basic_machine=$basic_machine-unknown
- ;;
- m6811 | m68hc11 | m6812 | m68hc12)
- # Motorola 68HC11/12.
- basic_machine=$basic_machine-unknown
- os=-none
- ;;
- m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | v70 | w65 | z8k)
- ;;
-
- # We use `pc' rather than `unknown'
- # because (1) that's what they normally are, and
- # (2) the word "unknown" tends to confuse beginning users.
- i*86 | x86_64)
- basic_machine=$basic_machine-pc
- ;;
- # Object if more than one company name word.
- *-*-*)
- echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2
- exit 1
- ;;
- # Recognize the basic CPU types with company name.
- 580-* \
- | a29k-* \
- | alpha-* | alphaev[4-8]-* | alphaev56-* | alphaev6[78]-* \
- | alpha64-* | alpha64ev[4-8]-* | alpha64ev56-* | alpha64ev6[78]-* \
- | alphapca5[67]-* | alpha64pca5[67]-* | arc-* \
- | arm-* | armbe-* | armle-* | armeb-* | armv*-* \
- | avr-* \
- | bfin-* | bs2000-* \
- | c[123]* | c30-* | [cjt]90-* | c4x-* | c54x-* | c55x-* | c6x-* \
- | clipper-* | craynv-* | cydra-* \
- | d10v-* | d30v-* | dlx-* \
- | elxsi-* \
- | f30[01]-* | f700-* | fr30-* | frv-* | fx80-* \
- | h8300-* | h8500-* \
- | hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \
- | i*86-* | i860-* | i960-* | ia64-* \
- | ip2k-* | iq2000-* \
- | m32r-* | m32rle-* \
- | m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \
- | m88110-* | m88k-* | maxq-* | mcore-* \
- | mips-* | mipsbe-* | mipseb-* | mipsel-* | mipsle-* \
- | mips16-* \
- | mips64-* | mips64el-* \
- | mips64vr-* | mips64vrel-* \
- | mips64orion-* | mips64orionel-* \
- | mips64vr4100-* | mips64vr4100el-* \
- | mips64vr4300-* | mips64vr4300el-* \
- | mips64vr5000-* | mips64vr5000el-* \
- | mips64vr5900-* | mips64vr5900el-* \
- | mipsisa32-* | mipsisa32el-* \
- | mipsisa32r2-* | mipsisa32r2el-* \
- | mipsisa64-* | mipsisa64el-* \
- | mipsisa64r2-* | mipsisa64r2el-* \
- | mipsisa64sb1-* | mipsisa64sb1el-* \
- | mipsisa64sr71k-* | mipsisa64sr71kel-* \
- | mipstx39-* | mipstx39el-* \
- | mmix-* \
- | ms1-* \
- | msp430-* \
- | none-* | np1-* | ns16k-* | ns32k-* \
- | orion-* \
- | pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \
- | powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* | ppcbe-* \
- | pyramid-* \
- | romp-* | rs6000-* \
- | sh-* | sh[1234]-* | sh[24]a-* | sh[23]e-* | sh[34]eb-* | shbe-* \
- | shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \
- | sparc-* | sparc64-* | sparc64b-* | sparc86x-* | sparclet-* \
- | sparclite-* \
- | sparcv8-* | sparcv9-* | sparcv9b-* | strongarm-* | sv1-* | sx?-* \
- | tahoe-* | thumb-* \
- | tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* \
- | tron-* \
- | v850-* | v850e-* | vax-* \
- | we32k-* \
- | x86-* | x86_64-* | xps100-* | xscale-* | xscalee[bl]-* \
- | xstormy16-* | xtensa-* \
- | ymp-* \
- | z8k-*)
- ;;
- m32c-*)
- ;;
- # Recognize the various machine names and aliases which stand
- # for a CPU type and a company and sometimes even an OS.
- 386bsd)
- basic_machine=i386-unknown
- os=-bsd
- ;;
- 3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc)
- basic_machine=m68000-att
- ;;
- 3b*)
- basic_machine=we32k-att
- ;;
- a29khif)
- basic_machine=a29k-amd
- os=-udi
- ;;
- abacus)
- basic_machine=abacus-unknown
- ;;
- adobe68k)
- basic_machine=m68010-adobe
- os=-scout
- ;;
- alliant | fx80)
- basic_machine=fx80-alliant
- ;;
- altos | altos3068)
- basic_machine=m68k-altos
- ;;
- am29k)
- basic_machine=a29k-none
- os=-bsd
- ;;
- amd64)
- basic_machine=x86_64-pc
- ;;
- amd64-*)
- basic_machine=x86_64-`echo $basic_machine | sed 's/^[^-]*-//'`
- ;;
- amdahl)
- basic_machine=580-amdahl
- os=-sysv
- ;;
- amiga | amiga-*)
- basic_machine=m68k-unknown
- ;;
- amigaos | amigados)
- basic_machine=m68k-unknown
- os=-amigaos
- ;;
- amigaunix | amix)
- basic_machine=m68k-unknown
- os=-sysv4
- ;;
- apollo68)
- basic_machine=m68k-apollo
- os=-sysv
- ;;
- apollo68bsd)
- basic_machine=m68k-apollo
- os=-bsd
- ;;
- aux)
- basic_machine=m68k-apple
- os=-aux
- ;;
- balance)
- basic_machine=ns32k-sequent
- os=-dynix
- ;;
- c90)
- basic_machine=c90-cray
- os=-unicos
- ;;
- convex-c1)
- basic_machine=c1-convex
- os=-bsd
- ;;
- convex-c2)
- basic_machine=c2-convex
- os=-bsd
- ;;
- convex-c32)
- basic_machine=c32-convex
- os=-bsd
- ;;
- convex-c34)
- basic_machine=c34-convex
- os=-bsd
- ;;
- convex-c38)
- basic_machine=c38-convex
- os=-bsd
- ;;
- cray | j90)
- basic_machine=j90-cray
- os=-unicos
- ;;
- craynv)
- basic_machine=craynv-cray
- os=-unicosmp
- ;;
- cr16c)
- basic_machine=cr16c-unknown
- os=-elf
- ;;
- crds | unos)
- basic_machine=m68k-crds
- ;;
- crisv32 | crisv32-* | etraxfs*)
- basic_machine=crisv32-axis
- ;;
- cris | cris-* | etrax*)
- basic_machine=cris-axis
- ;;
- crx)
- basic_machine=crx-unknown
- os=-elf
- ;;
- da30 | da30-*)
- basic_machine=m68k-da30
- ;;
- decstation | decstation-3100 | pmax | pmax-* | pmin | dec3100 | decstatn)
- basic_machine=mips-dec
- ;;
- decsystem10* | dec10*)
- basic_machine=pdp10-dec
- os=-tops10
- ;;
- decsystem20* | dec20*)
- basic_machine=pdp10-dec
- os=-tops20
- ;;
- delta | 3300 | motorola-3300 | motorola-delta \
- | 3300-motorola | delta-motorola)
- basic_machine=m68k-motorola
- ;;
- delta88)
- basic_machine=m88k-motorola
- os=-sysv3
- ;;
- djgpp)
- basic_machine=i586-pc
- os=-msdosdjgpp
- ;;
- dpx20 | dpx20-*)
- basic_machine=rs6000-bull
- os=-bosx
- ;;
- dpx2* | dpx2*-bull)
- basic_machine=m68k-bull
- os=-sysv3
- ;;
- ebmon29k)
- basic_machine=a29k-amd
- os=-ebmon
- ;;
- elxsi)
- basic_machine=elxsi-elxsi
- os=-bsd
- ;;
- encore | umax | mmax)
- basic_machine=ns32k-encore
- ;;
- es1800 | OSE68k | ose68k | ose | OSE)
- basic_machine=m68k-ericsson
- os=-ose
- ;;
- fx2800)
- basic_machine=i860-alliant
- ;;
- genix)
- basic_machine=ns32k-ns
- ;;
- gmicro)
- basic_machine=tron-gmicro
- os=-sysv
- ;;
- go32)
- basic_machine=i386-pc
- os=-go32
- ;;
- h3050r* | hiux*)
- basic_machine=hppa1.1-hitachi
- os=-hiuxwe2
- ;;
- h8300hms)
- basic_machine=h8300-hitachi
- os=-hms
- ;;
- h8300xray)
- basic_machine=h8300-hitachi
- os=-xray
- ;;
- h8500hms)
- basic_machine=h8500-hitachi
- os=-hms
- ;;
- harris)
- basic_machine=m88k-harris
- os=-sysv3
- ;;
- hp300-*)
- basic_machine=m68k-hp
- ;;
- hp300bsd)
- basic_machine=m68k-hp
- os=-bsd
- ;;
- hp300hpux)
- basic_machine=m68k-hp
- os=-hpux
- ;;
- hp3k9[0-9][0-9] | hp9[0-9][0-9])
- basic_machine=hppa1.0-hp
- ;;
- hp9k2[0-9][0-9] | hp9k31[0-9])
- basic_machine=m68000-hp
- ;;
- hp9k3[2-9][0-9])
- basic_machine=m68k-hp
- ;;
- hp9k6[0-9][0-9] | hp6[0-9][0-9])
- basic_machine=hppa1.0-hp
- ;;
- hp9k7[0-79][0-9] | hp7[0-79][0-9])
- basic_machine=hppa1.1-hp
- ;;
- hp9k78[0-9] | hp78[0-9])
- # FIXME: really hppa2.0-hp
- basic_machine=hppa1.1-hp
- ;;
- hp9k8[67]1 | hp8[67]1 | hp9k80[24] | hp80[24] | hp9k8[78]9 | hp8[78]9 | hp9k893 | hp893)
- # FIXME: really hppa2.0-hp
- basic_machine=hppa1.1-hp
- ;;
- hp9k8[0-9][13679] | hp8[0-9][13679])
- basic_machine=hppa1.1-hp
- ;;
- hp9k8[0-9][0-9] | hp8[0-9][0-9])
- basic_machine=hppa1.0-hp
- ;;
- hppa-next)
- os=-nextstep3
- ;;
- hppaosf)
- basic_machine=hppa1.1-hp
- os=-osf
- ;;
- hppro)
- basic_machine=hppa1.1-hp
- os=-proelf
- ;;
- i370-ibm* | ibm*)
- basic_machine=i370-ibm
- ;;
-# I'm not sure what "Sysv32" means. Should this be sysv3.2?
- i*86v32)
- basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
- os=-sysv32
- ;;
- i*86v4*)
- basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
- os=-sysv4
- ;;
- i*86v)
- basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
- os=-sysv
- ;;
- i*86sol2)
- basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
- os=-solaris2
- ;;
- i386mach)
- basic_machine=i386-mach
- os=-mach
- ;;
- i386-vsta | vsta)
- basic_machine=i386-unknown
- os=-vsta
- ;;
- iris | iris4d)
- basic_machine=mips-sgi
- case $os in
- -irix*)
- ;;
- *)
- os=-irix4
- ;;
- esac
- ;;
- isi68 | isi)
- basic_machine=m68k-isi
- os=-sysv
- ;;
- m88k-omron*)
- basic_machine=m88k-omron
- ;;
- magnum | m3230)
- basic_machine=mips-mips
- os=-sysv
- ;;
- merlin)
- basic_machine=ns32k-utek
- os=-sysv
- ;;
- mingw32)
- basic_machine=i386-pc
- os=-mingw32
- ;;
- miniframe)
- basic_machine=m68000-convergent
- ;;
- *mint | -mint[0-9]* | *MiNT | *MiNT[0-9]*)
- basic_machine=m68k-atari
- os=-mint
- ;;
- mips3*-*)
- basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`
- ;;
- mips3*)
- basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`-unknown
- ;;
- monitor)
- basic_machine=m68k-rom68k
- os=-coff
- ;;
- morphos)
- basic_machine=powerpc-unknown
- os=-morphos
- ;;
- msdos)
- basic_machine=i386-pc
- os=-msdos
- ;;
- mvs)
- basic_machine=i370-ibm
- os=-mvs
- ;;
- ncr3000)
- basic_machine=i486-ncr
- os=-sysv4
- ;;
- netbsd386)
- basic_machine=i386-unknown
- os=-netbsd
- ;;
- netwinder)
- basic_machine=armv4l-rebel
- os=-linux
- ;;
- news | news700 | news800 | news900)
- basic_machine=m68k-sony
- os=-newsos
- ;;
- news1000)
- basic_machine=m68030-sony
- os=-newsos
- ;;
- news-3600 | risc-news)
- basic_machine=mips-sony
- os=-newsos
- ;;
- necv70)
- basic_machine=v70-nec
- os=-sysv
- ;;
- next | m*-next )
- basic_machine=m68k-next
- case $os in
- -nextstep* )
- ;;
- -ns2*)
- os=-nextstep2
- ;;
- *)
- os=-nextstep3
- ;;
- esac
- ;;
- nh3000)
- basic_machine=m68k-harris
- os=-cxux
- ;;
- nh[45]000)
- basic_machine=m88k-harris
- os=-cxux
- ;;
- nindy960)
- basic_machine=i960-intel
- os=-nindy
- ;;
- mon960)
- basic_machine=i960-intel
- os=-mon960
- ;;
- nonstopux)
- basic_machine=mips-compaq
- os=-nonstopux
- ;;
- np1)
- basic_machine=np1-gould
- ;;
- nsr-tandem)
- basic_machine=nsr-tandem
- ;;
- op50n-* | op60c-*)
- basic_machine=hppa1.1-oki
- os=-proelf
- ;;
- openrisc | openrisc-*)
- basic_machine=or32-unknown
- ;;
- os400)
- basic_machine=powerpc-ibm
- os=-os400
- ;;
- OSE68000 | ose68000)
- basic_machine=m68000-ericsson
- os=-ose
- ;;
- os68k)
- basic_machine=m68k-none
- os=-os68k
- ;;
- pa-hitachi)
- basic_machine=hppa1.1-hitachi
- os=-hiuxwe2
- ;;
- paragon)
- basic_machine=i860-intel
- os=-osf
- ;;
- pbd)
- basic_machine=sparc-tti
- ;;
- pbb)
- basic_machine=m68k-tti
- ;;
- pc532 | pc532-*)
- basic_machine=ns32k-pc532
- ;;
- pentium | p5 | k5 | k6 | nexgen | viac3)
- basic_machine=i586-pc
- ;;
- pentiumpro | p6 | 6x86 | athlon | athlon_*)
- basic_machine=i686-pc
- ;;
- pentiumii | pentium2 | pentiumiii | pentium3)
- basic_machine=i686-pc
- ;;
- pentium4)
- basic_machine=i786-pc
- ;;
- pentium-* | p5-* | k5-* | k6-* | nexgen-* | viac3-*)
- basic_machine=i586-`echo $basic_machine | sed 's/^[^-]*-//'`
- ;;
- pentiumpro-* | p6-* | 6x86-* | athlon-*)
- basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'`
- ;;
- pentiumii-* | pentium2-* | pentiumiii-* | pentium3-*)
- basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'`
- ;;
- pentium4-*)
- basic_machine=i786-`echo $basic_machine | sed 's/^[^-]*-//'`
- ;;
- pn)
- basic_machine=pn-gould
- ;;
- power) basic_machine=power-ibm
- ;;
- ppc) basic_machine=powerpc-unknown
- ;;
- ppc-*) basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'`
- ;;
- ppcle | powerpclittle | ppc-le | powerpc-little)
- basic_machine=powerpcle-unknown
- ;;
- ppcle-* | powerpclittle-*)
- basic_machine=powerpcle-`echo $basic_machine | sed 's/^[^-]*-//'`
- ;;
- ppc64) basic_machine=powerpc64-unknown
- ;;
- ppc64-*) basic_machine=powerpc64-`echo $basic_machine | sed 's/^[^-]*-//'`
- ;;
- ppc64le | powerpc64little | ppc64-le | powerpc64-little)
- basic_machine=powerpc64le-unknown
- ;;
- ppc64le-* | powerpc64little-*)
- basic_machine=powerpc64le-`echo $basic_machine | sed 's/^[^-]*-//'`
- ;;
- ps2)
- basic_machine=i386-ibm
- ;;
- pw32)
- basic_machine=i586-unknown
- os=-pw32
- ;;
- rom68k)
- basic_machine=m68k-rom68k
- os=-coff
- ;;
- rm[46]00)
- basic_machine=mips-siemens
- ;;
- rtpc | rtpc-*)
- basic_machine=romp-ibm
- ;;
- s390 | s390-*)
- basic_machine=s390-ibm
- ;;
- s390x | s390x-*)
- basic_machine=s390x-ibm
- ;;
- sa29200)
- basic_machine=a29k-amd
- os=-udi
- ;;
- sb1)
- basic_machine=mipsisa64sb1-unknown
- ;;
- sb1el)
- basic_machine=mipsisa64sb1el-unknown
- ;;
- sei)
- basic_machine=mips-sei
- os=-seiux
- ;;
- sequent)
- basic_machine=i386-sequent
- ;;
- sh)
- basic_machine=sh-hitachi
- os=-hms
- ;;
- sh64)
- basic_machine=sh64-unknown
- ;;
- sparclite-wrs | simso-wrs)
- basic_machine=sparclite-wrs
- os=-vxworks
- ;;
- sps7)
- basic_machine=m68k-bull
- os=-sysv2
- ;;
- spur)
- basic_machine=spur-unknown
- ;;
- st2000)
- basic_machine=m68k-tandem
- ;;
- stratus)
- basic_machine=i860-stratus
- os=-sysv4
- ;;
- sun2)
- basic_machine=m68000-sun
- ;;
- sun2os3)
- basic_machine=m68000-sun
- os=-sunos3
- ;;
- sun2os4)
- basic_machine=m68000-sun
- os=-sunos4
- ;;
- sun3os3)
- basic_machine=m68k-sun
- os=-sunos3
- ;;
- sun3os4)
- basic_machine=m68k-sun
- os=-sunos4
- ;;
- sun4os3)
- basic_machine=sparc-sun
- os=-sunos3
- ;;
- sun4os4)
- basic_machine=sparc-sun
- os=-sunos4
- ;;
- sun4sol2)
- basic_machine=sparc-sun
- os=-solaris2
- ;;
- sun3 | sun3-*)
- basic_machine=m68k-sun
- ;;
- sun4)
- basic_machine=sparc-sun
- ;;
- sun386 | sun386i | roadrunner)
- basic_machine=i386-sun
- ;;
- sv1)
- basic_machine=sv1-cray
- os=-unicos
- ;;
- symmetry)
- basic_machine=i386-sequent
- os=-dynix
- ;;
- t3e)
- basic_machine=alphaev5-cray
- os=-unicos
- ;;
- t90)
- basic_machine=t90-cray
- os=-unicos
- ;;
- tic54x | c54x*)
- basic_machine=tic54x-unknown
- os=-coff
- ;;
- tic55x | c55x*)
- basic_machine=tic55x-unknown
- os=-coff
- ;;
- tic6x | c6x*)
- basic_machine=tic6x-unknown
- os=-coff
- ;;
- tx39)
- basic_machine=mipstx39-unknown
- ;;
- tx39el)
- basic_machine=mipstx39el-unknown
- ;;
- toad1)
- basic_machine=pdp10-xkl
- os=-tops20
- ;;
- tower | tower-32)
- basic_machine=m68k-ncr
- ;;
- tpf)
- basic_machine=s390x-ibm
- os=-tpf
- ;;
- udi29k)
- basic_machine=a29k-amd
- os=-udi
- ;;
- ultra3)
- basic_machine=a29k-nyu
- os=-sym1
- ;;
- v810 | necv810)
- basic_machine=v810-nec
- os=-none
- ;;
- vaxv)
- basic_machine=vax-dec
- os=-sysv
- ;;
- vms)
- basic_machine=vax-dec
- os=-vms
- ;;
- vpp*|vx|vx-*)
- basic_machine=f301-fujitsu
- ;;
- vxworks960)
- basic_machine=i960-wrs
- os=-vxworks
- ;;
- vxworks68)
- basic_machine=m68k-wrs
- os=-vxworks
- ;;
- vxworks29k)
- basic_machine=a29k-wrs
- os=-vxworks
- ;;
- w65*)
- basic_machine=w65-wdc
- os=-none
- ;;
- w89k-*)
- basic_machine=hppa1.1-winbond
- os=-proelf
- ;;
- xbox)
- basic_machine=i686-pc
- os=-mingw32
- ;;
- xps | xps100)
- basic_machine=xps100-honeywell
- ;;
- ymp)
- basic_machine=ymp-cray
- os=-unicos
- ;;
- z8k-*-coff)
- basic_machine=z8k-unknown
- os=-sim
- ;;
- none)
- basic_machine=none-none
- os=-none
- ;;
-
-# Here we handle the default manufacturer of certain CPU types. It is in
-# some cases the only manufacturer, in others, it is the most popular.
- w89k)
- basic_machine=hppa1.1-winbond
- ;;
- op50n)
- basic_machine=hppa1.1-oki
- ;;
- op60c)
- basic_machine=hppa1.1-oki
- ;;
- romp)
- basic_machine=romp-ibm
- ;;
- mmix)
- basic_machine=mmix-knuth
- ;;
- rs6000)
- basic_machine=rs6000-ibm
- ;;
- vax)
- basic_machine=vax-dec
- ;;
- pdp10)
- # there are many clones, so DEC is not a safe bet
- basic_machine=pdp10-unknown
- ;;
- pdp11)
- basic_machine=pdp11-dec
- ;;
- we32k)
- basic_machine=we32k-att
- ;;
- sh[1234] | sh[24]a | sh[34]eb | sh[1234]le | sh[23]ele)
- basic_machine=sh-unknown
- ;;
- sparc | sparcv8 | sparcv9 | sparcv9b)
- basic_machine=sparc-sun
- ;;
- cydra)
- basic_machine=cydra-cydrome
- ;;
- orion)
- basic_machine=orion-highlevel
- ;;
- orion105)
- basic_machine=clipper-highlevel
- ;;
- mac | mpw | mac-mpw)
- basic_machine=m68k-apple
- ;;
- pmac | pmac-mpw)
- basic_machine=powerpc-apple
- ;;
- *-unknown)
- # Make sure to match an already-canonicalized machine name.
- ;;
- *)
- echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2
- exit 1
- ;;
-esac
-
-# Here we canonicalize certain aliases for manufacturers.
-case $basic_machine in
- *-digital*)
- basic_machine=`echo $basic_machine | sed 's/digital.*/dec/'`
- ;;
- *-commodore*)
- basic_machine=`echo $basic_machine | sed 's/commodore.*/cbm/'`
- ;;
- *)
- ;;
-esac
-
-# Decode manufacturer-specific aliases for certain operating systems.
-
-if [ x"$os" != x"" ]
-then
-case $os in
- # First match some system type aliases
- # that might get confused with valid system types.
- # -solaris* is a basic system type, with this one exception.
- -solaris1 | -solaris1.*)
- os=`echo $os | sed -e 's|solaris1|sunos4|'`
- ;;
- -solaris)
- os=-solaris2
- ;;
- -svr4*)
- os=-sysv4
- ;;
- -unixware*)
- os=-sysv4.2uw
- ;;
- -gnu/linux*)
- os=`echo $os | sed -e 's|gnu/linux|linux-gnu|'`
- ;;
- # First accept the basic system types.
- # The portable systems comes first.
- # Each alternative MUST END IN A *, to match a version number.
- # -sysv* is not here because it comes later, after sysvr4.
- -gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \
- | -*vms* | -sco* | -esix* | -isc* | -aix* | -sunos | -sunos[34]*\
- | -hpux* | -unos* | -osf* | -luna* | -dgux* | -solaris* | -sym* \
- | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \
- | -aos* \
- | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \
- | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \
- | -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* | -openbsd* \
- | -ekkobsd* | -kfreebsd* | -freebsd* | -riscix* | -lynxos* \
- | -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \
- | -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \
- | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \
- | -chorusos* | -chorusrdb* \
- | -cygwin* | -pe* | -psos* | -moss* | -proelf* | -rtems* \
- | -mingw32* | -linux-gnu* | -linux-uclibc* | -uxpv* | -beos* | -mpeix* | -udk* \
- | -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \
- | -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \
- | -storm-chaos* | -tops10* | -tenex* | -tops20* | -its* \
- | -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \
- | -morphos* | -superux* | -rtmk* | -rtmk-nova* | -windiss* \
- | -powermax* | -dnix* | -nx6 | -nx7 | -sei* | -dragonfly* \
- | -skyos* | -haiku*)
- # Remember, each alternative MUST END IN *, to match a version number.
- ;;
- -qnx*)
- case $basic_machine in
- x86-* | i*86-*)
- ;;
- *)
- os=-nto$os
- ;;
- esac
- ;;
- -nto-qnx*)
- ;;
- -nto*)
- os=`echo $os | sed -e 's|nto|nto-qnx|'`
- ;;
- -sim | -es1800* | -hms* | -xray | -os68k* | -none* | -v88r* \
- | -windows* | -osx | -abug | -netware* | -os9* | -beos* | -haiku* \
- | -macos* | -mpw* | -magic* | -mmixware* | -mon960* | -lnews*)
- ;;
- -mac*)
- os=`echo $os | sed -e 's|mac|macos|'`
- ;;
- -linux-dietlibc)
- os=-linux-dietlibc
- ;;
- -linux*)
- os=`echo $os | sed -e 's|linux|linux-gnu|'`
- ;;
- -sunos5*)
- os=`echo $os | sed -e 's|sunos5|solaris2|'`
- ;;
- -sunos6*)
- os=`echo $os | sed -e 's|sunos6|solaris3|'`
- ;;
- -opened*)
- os=-openedition
- ;;
- -os400*)
- os=-os400
- ;;
- -wince*)
- os=-wince
- ;;
- -osfrose*)
- os=-osfrose
- ;;
- -osf*)
- os=-osf
- ;;
- -utek*)
- os=-bsd
- ;;
- -dynix*)
- os=-bsd
- ;;
- -acis*)
- os=-aos
- ;;
- -atheos*)
- os=-atheos
- ;;
- -syllable*)
- os=-syllable
- ;;
- -386bsd)
- os=-bsd
- ;;
- -ctix* | -uts*)
- os=-sysv
- ;;
- -nova*)
- os=-rtmk-nova
- ;;
- -ns2 )
- os=-nextstep2
- ;;
- -nsk*)
- os=-nsk
- ;;
- # Preserve the version number of sinix5.
- -sinix5.*)
- os=`echo $os | sed -e 's|sinix|sysv|'`
- ;;
- -sinix*)
- os=-sysv4
- ;;
- -tpf*)
- os=-tpf
- ;;
- -triton*)
- os=-sysv3
- ;;
- -oss*)
- os=-sysv3
- ;;
- -svr4)
- os=-sysv4
- ;;
- -svr3)
- os=-sysv3
- ;;
- -sysvr4)
- os=-sysv4
- ;;
- # This must come after -sysvr4.
- -sysv*)
- ;;
- -ose*)
- os=-ose
- ;;
- -es1800*)
- os=-ose
- ;;
- -xenix)
- os=-xenix
- ;;
- -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*)
- os=-mint
- ;;
- -aros*)
- os=-aros
- ;;
- -kaos*)
- os=-kaos
- ;;
- -zvmoe)
- os=-zvmoe
- ;;
- -none)
- ;;
- *)
- # Get rid of the `-' at the beginning of $os.
- os=`echo $os | sed 's/[^-]*-//'`
- echo Invalid configuration \`$1\': system \`$os\' not recognized 1>&2
- exit 1
- ;;
-esac
-else
-
-# Here we handle the default operating systems that come with various machines.
-# The value should be what the vendor currently ships out the door with their
-# machine or put another way, the most popular os provided with the machine.
-
-# Note that if you're going to try to match "-MANUFACTURER" here (say,
-# "-sun"), then you have to tell the case statement up towards the top
-# that MANUFACTURER isn't an operating system. Otherwise, code above
-# will signal an error saying that MANUFACTURER isn't an operating
-# system, and we'll never get to this point.
-
-case $basic_machine in
- *-acorn)
- os=-riscix1.2
- ;;
- arm*-rebel)
- os=-linux
- ;;
- arm*-semi)
- os=-aout
- ;;
- c4x-* | tic4x-*)
- os=-coff
- ;;
- # This must come before the *-dec entry.
- pdp10-*)
- os=-tops20
- ;;
- pdp11-*)
- os=-none
- ;;
- *-dec | vax-*)
- os=-ultrix4.2
- ;;
- m68*-apollo)
- os=-domain
- ;;
- i386-sun)
- os=-sunos4.0.2
- ;;
- m68000-sun)
- os=-sunos3
- # This also exists in the configure program, but was not the
- # default.
- # os=-sunos4
- ;;
- m68*-cisco)
- os=-aout
- ;;
- mips*-cisco)
- os=-elf
- ;;
- mips*-*)
- os=-elf
- ;;
- or32-*)
- os=-coff
- ;;
- *-tti) # must be before sparc entry or we get the wrong os.
- os=-sysv3
- ;;
- sparc-* | *-sun)
- os=-sunos4.1.1
- ;;
- *-be)
- os=-beos
- ;;
- *-haiku)
- os=-haiku
- ;;
- *-ibm)
- os=-aix
- ;;
- *-knuth)
- os=-mmixware
- ;;
- *-wec)
- os=-proelf
- ;;
- *-winbond)
- os=-proelf
- ;;
- *-oki)
- os=-proelf
- ;;
- *-hp)
- os=-hpux
- ;;
- *-hitachi)
- os=-hiux
- ;;
- i860-* | *-att | *-ncr | *-altos | *-motorola | *-convergent)
- os=-sysv
- ;;
- *-cbm)
- os=-amigaos
- ;;
- *-dg)
- os=-dgux
- ;;
- *-dolphin)
- os=-sysv3
- ;;
- m68k-ccur)
- os=-rtu
- ;;
- m88k-omron*)
- os=-luna
- ;;
- *-next )
- os=-nextstep
- ;;
- *-sequent)
- os=-ptx
- ;;
- *-crds)
- os=-unos
- ;;
- *-ns)
- os=-genix
- ;;
- i370-*)
- os=-mvs
- ;;
- *-next)
- os=-nextstep3
- ;;
- *-gould)
- os=-sysv
- ;;
- *-highlevel)
- os=-bsd
- ;;
- *-encore)
- os=-bsd
- ;;
- *-sgi)
- os=-irix
- ;;
- *-siemens)
- os=-sysv4
- ;;
- *-masscomp)
- os=-rtu
- ;;
- f30[01]-fujitsu | f700-fujitsu)
- os=-uxpv
- ;;
- *-rom68k)
- os=-coff
- ;;
- *-*bug)
- os=-coff
- ;;
- *-apple)
- os=-macos
- ;;
- *-atari*)
- os=-mint
- ;;
- *)
- os=-none
- ;;
-esac
-fi
-
-# Here we handle the case where we know the os, and the CPU type, but not the
-# manufacturer. We pick the logical manufacturer.
-vendor=unknown
-case $basic_machine in
- *-unknown)
- case $os in
- -riscix*)
- vendor=acorn
- ;;
- -sunos*)
- vendor=sun
- ;;
- -aix*)
- vendor=ibm
- ;;
- -beos*)
- vendor=be
- ;;
- -hpux*)
- vendor=hp
- ;;
- -mpeix*)
- vendor=hp
- ;;
- -hiux*)
- vendor=hitachi
- ;;
- -unos*)
- vendor=crds
- ;;
- -dgux*)
- vendor=dg
- ;;
- -luna*)
- vendor=omron
- ;;
- -genix*)
- vendor=ns
- ;;
- -mvs* | -opened*)
- vendor=ibm
- ;;
- -os400*)
- vendor=ibm
- ;;
- -ptx*)
- vendor=sequent
- ;;
- -tpf*)
- vendor=ibm
- ;;
- -vxsim* | -vxworks* | -windiss*)
- vendor=wrs
- ;;
- -aux*)
- vendor=apple
- ;;
- -hms*)
- vendor=hitachi
- ;;
- -mpw* | -macos*)
- vendor=apple
- ;;
- -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*)
- vendor=atari
- ;;
- -vos*)
- vendor=stratus
- ;;
- esac
- basic_machine=`echo $basic_machine | sed "s/unknown/$vendor/"`
- ;;
-esac
-
-echo $basic_machine$os
-exit
-
-# Local variables:
-# eval: (add-hook 'write-file-hooks 'time-stamp)
-# time-stamp-start: "timestamp='"
-# time-stamp-format: "%:y-%02m-%02d"
-# time-stamp-end: "'"
-# End:
diff --git a/contrib/ofed/libibcm/config/depcomp b/contrib/ofed/libibcm/config/depcomp
deleted file mode 100755
index 04701da..0000000
--- a/contrib/ofed/libibcm/config/depcomp
+++ /dev/null
@@ -1,530 +0,0 @@
-#! /bin/sh
-# depcomp - compile a program generating dependencies as side-effects
-
-scriptversion=2005-07-09.11
-
-# Copyright (C) 1999, 2000, 2003, 2004, 2005 Free Software Foundation, Inc.
-
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2, or (at your option)
-# any later version.
-
-# This program 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 this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
-# 02110-1301, USA.
-
-# As a special exception to the GNU General Public License, if you
-# distribute this file as part of a program that contains a
-# configuration script generated by Autoconf, you may include it under
-# the same distribution terms that you use for the rest of that program.
-
-# Originally written by Alexandre Oliva <oliva@dcc.unicamp.br>.
-
-case $1 in
- '')
- echo "$0: No command. Try \`$0 --help' for more information." 1>&2
- exit 1;
- ;;
- -h | --h*)
- cat <<\EOF
-Usage: depcomp [--help] [--version] PROGRAM [ARGS]
-
-Run PROGRAMS ARGS to compile a file, generating dependencies
-as side-effects.
-
-Environment variables:
- depmode Dependency tracking mode.
- source Source file read by `PROGRAMS ARGS'.
- object Object file output by `PROGRAMS ARGS'.
- DEPDIR directory where to store dependencies.
- depfile Dependency file to output.
- tmpdepfile Temporary file to use when outputing dependencies.
- libtool Whether libtool is used (yes/no).
-
-Report bugs to <bug-automake@gnu.org>.
-EOF
- exit $?
- ;;
- -v | --v*)
- echo "depcomp $scriptversion"
- exit $?
- ;;
-esac
-
-if test -z "$depmode" || test -z "$source" || test -z "$object"; then
- echo "depcomp: Variables source, object and depmode must be set" 1>&2
- exit 1
-fi
-
-# Dependencies for sub/bar.o or sub/bar.obj go into sub/.deps/bar.Po.
-depfile=${depfile-`echo "$object" |
- sed 's|[^\\/]*$|'${DEPDIR-.deps}'/&|;s|\.\([^.]*\)$|.P\1|;s|Pobj$|Po|'`}
-tmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`}
-
-rm -f "$tmpdepfile"
-
-# Some modes work just like other modes, but use different flags. We
-# parameterize here, but still list the modes in the big case below,
-# to make depend.m4 easier to write. Note that we *cannot* use a case
-# here, because this file can only contain one case statement.
-if test "$depmode" = hp; then
- # HP compiler uses -M and no extra arg.
- gccflag=-M
- depmode=gcc
-fi
-
-if test "$depmode" = dashXmstdout; then
- # This is just like dashmstdout with a different argument.
- dashmflag=-xM
- depmode=dashmstdout
-fi
-
-case "$depmode" in
-gcc3)
-## gcc 3 implements dependency tracking that does exactly what
-## we want. Yay! Note: for some reason libtool 1.4 doesn't like
-## it if -MD -MP comes after the -MF stuff. Hmm.
- "$@" -MT "$object" -MD -MP -MF "$tmpdepfile"
- stat=$?
- if test $stat -eq 0; then :
- else
- rm -f "$tmpdepfile"
- exit $stat
- fi
- mv "$tmpdepfile" "$depfile"
- ;;
-
-gcc)
-## There are various ways to get dependency output from gcc. Here's
-## why we pick this rather obscure method:
-## - Don't want to use -MD because we'd like the dependencies to end
-## up in a subdir. Having to rename by hand is ugly.
-## (We might end up doing this anyway to support other compilers.)
-## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like
-## -MM, not -M (despite what the docs say).
-## - Using -M directly means running the compiler twice (even worse
-## than renaming).
- if test -z "$gccflag"; then
- gccflag=-MD,
- fi
- "$@" -Wp,"$gccflag$tmpdepfile"
- stat=$?
- if test $stat -eq 0; then :
- else
- rm -f "$tmpdepfile"
- exit $stat
- fi
- rm -f "$depfile"
- echo "$object : \\" > "$depfile"
- alpha=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz
-## The second -e expression handles DOS-style file names with drive letters.
- sed -e 's/^[^:]*: / /' \
- -e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile"
-## This next piece of magic avoids the `deleted header file' problem.
-## The problem is that when a header file which appears in a .P file
-## is deleted, the dependency causes make to die (because there is
-## typically no way to rebuild the header). We avoid this by adding
-## dummy dependencies for each header file. Too bad gcc doesn't do
-## this for us directly.
- tr ' ' '
-' < "$tmpdepfile" |
-## Some versions of gcc put a space before the `:'. On the theory
-## that the space means something, we add a space to the output as
-## well.
-## Some versions of the HPUX 10.20 sed can't process this invocation
-## correctly. Breaking it into two sed invocations is a workaround.
- sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
- rm -f "$tmpdepfile"
- ;;
-
-hp)
- # This case exists only to let depend.m4 do its work. It works by
- # looking at the text of this script. This case will never be run,
- # since it is checked for above.
- exit 1
- ;;
-
-sgi)
- if test "$libtool" = yes; then
- "$@" "-Wp,-MDupdate,$tmpdepfile"
- else
- "$@" -MDupdate "$tmpdepfile"
- fi
- stat=$?
- if test $stat -eq 0; then :
- else
- rm -f "$tmpdepfile"
- exit $stat
- fi
- rm -f "$depfile"
-
- if test -f "$tmpdepfile"; then # yes, the sourcefile depend on other files
- echo "$object : \\" > "$depfile"
-
- # Clip off the initial element (the dependent). Don't try to be
- # clever and replace this with sed code, as IRIX sed won't handle
- # lines with more than a fixed number of characters (4096 in
- # IRIX 6.2 sed, 8192 in IRIX 6.5). We also remove comment lines;
- # the IRIX cc adds comments like `#:fec' to the end of the
- # dependency line.
- tr ' ' '
-' < "$tmpdepfile" \
- | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' | \
- tr '
-' ' ' >> $depfile
- echo >> $depfile
-
- # The second pass generates a dummy entry for each header file.
- tr ' ' '
-' < "$tmpdepfile" \
- | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \
- >> $depfile
- else
- # The sourcefile does not contain any dependencies, so just
- # store a dummy comment line, to avoid errors with the Makefile
- # "include basename.Plo" scheme.
- echo "#dummy" > "$depfile"
- fi
- rm -f "$tmpdepfile"
- ;;
-
-aix)
- # The C for AIX Compiler uses -M and outputs the dependencies
- # in a .u file. In older versions, this file always lives in the
- # current directory. Also, the AIX compiler puts `$object:' at the
- # start of each line; $object doesn't have directory information.
- # Version 6 uses the directory in both cases.
- stripped=`echo "$object" | sed 's/\(.*\)\..*$/\1/'`
- tmpdepfile="$stripped.u"
- if test "$libtool" = yes; then
- "$@" -Wc,-M
- else
- "$@" -M
- fi
- stat=$?
-
- if test -f "$tmpdepfile"; then :
- else
- stripped=`echo "$stripped" | sed 's,^.*/,,'`
- tmpdepfile="$stripped.u"
- fi
-
- if test $stat -eq 0; then :
- else
- rm -f "$tmpdepfile"
- exit $stat
- fi
-
- if test -f "$tmpdepfile"; then
- outname="$stripped.o"
- # Each line is of the form `foo.o: dependent.h'.
- # Do two passes, one to just change these to
- # `$object: dependent.h' and one to simply `dependent.h:'.
- sed -e "s,^$outname:,$object :," < "$tmpdepfile" > "$depfile"
- sed -e "s,^$outname: \(.*\)$,\1:," < "$tmpdepfile" >> "$depfile"
- else
- # The sourcefile does not contain any dependencies, so just
- # store a dummy comment line, to avoid errors with the Makefile
- # "include basename.Plo" scheme.
- echo "#dummy" > "$depfile"
- fi
- rm -f "$tmpdepfile"
- ;;
-
-icc)
- # Intel's C compiler understands `-MD -MF file'. However on
- # icc -MD -MF foo.d -c -o sub/foo.o sub/foo.c
- # ICC 7.0 will fill foo.d with something like
- # foo.o: sub/foo.c
- # foo.o: sub/foo.h
- # which is wrong. We want:
- # sub/foo.o: sub/foo.c
- # sub/foo.o: sub/foo.h
- # sub/foo.c:
- # sub/foo.h:
- # ICC 7.1 will output
- # foo.o: sub/foo.c sub/foo.h
- # and will wrap long lines using \ :
- # foo.o: sub/foo.c ... \
- # sub/foo.h ... \
- # ...
-
- "$@" -MD -MF "$tmpdepfile"
- stat=$?
- if test $stat -eq 0; then :
- else
- rm -f "$tmpdepfile"
- exit $stat
- fi
- rm -f "$depfile"
- # Each line is of the form `foo.o: dependent.h',
- # or `foo.o: dep1.h dep2.h \', or ` dep3.h dep4.h \'.
- # Do two passes, one to just change these to
- # `$object: dependent.h' and one to simply `dependent.h:'.
- sed "s,^[^:]*:,$object :," < "$tmpdepfile" > "$depfile"
- # Some versions of the HPUX 10.20 sed can't process this invocation
- # correctly. Breaking it into two sed invocations is a workaround.
- sed 's,^[^:]*: \(.*\)$,\1,;s/^\\$//;/^$/d;/:$/d' < "$tmpdepfile" |
- sed -e 's/$/ :/' >> "$depfile"
- rm -f "$tmpdepfile"
- ;;
-
-tru64)
- # The Tru64 compiler uses -MD to generate dependencies as a side
- # effect. `cc -MD -o foo.o ...' puts the dependencies into `foo.o.d'.
- # At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put
- # dependencies in `foo.d' instead, so we check for that too.
- # Subdirectories are respected.
- dir=`echo "$object" | sed -e 's|/[^/]*$|/|'`
- test "x$dir" = "x$object" && dir=
- base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'`
-
- if test "$libtool" = yes; then
- # With Tru64 cc, shared objects can also be used to make a
- # static library. This mecanism is used in libtool 1.4 series to
- # handle both shared and static libraries in a single compilation.
- # With libtool 1.4, dependencies were output in $dir.libs/$base.lo.d.
- #
- # With libtool 1.5 this exception was removed, and libtool now
- # generates 2 separate objects for the 2 libraries. These two
- # compilations output dependencies in in $dir.libs/$base.o.d and
- # in $dir$base.o.d. We have to check for both files, because
- # one of the two compilations can be disabled. We should prefer
- # $dir$base.o.d over $dir.libs/$base.o.d because the latter is
- # automatically cleaned when .libs/ is deleted, while ignoring
- # the former would cause a distcleancheck panic.
- tmpdepfile1=$dir.libs/$base.lo.d # libtool 1.4
- tmpdepfile2=$dir$base.o.d # libtool 1.5
- tmpdepfile3=$dir.libs/$base.o.d # libtool 1.5
- tmpdepfile4=$dir.libs/$base.d # Compaq CCC V6.2-504
- "$@" -Wc,-MD
- else
- tmpdepfile1=$dir$base.o.d
- tmpdepfile2=$dir$base.d
- tmpdepfile3=$dir$base.d
- tmpdepfile4=$dir$base.d
- "$@" -MD
- fi
-
- stat=$?
- if test $stat -eq 0; then :
- else
- rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4"
- exit $stat
- fi
-
- for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4"
- do
- test -f "$tmpdepfile" && break
- done
- if test -f "$tmpdepfile"; then
- sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile"
- # That's a tab and a space in the [].
- sed -e 's,^.*\.[a-z]*:[ ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile"
- else
- echo "#dummy" > "$depfile"
- fi
- rm -f "$tmpdepfile"
- ;;
-
-#nosideeffect)
- # This comment above is used by automake to tell side-effect
- # dependency tracking mechanisms from slower ones.
-
-dashmstdout)
- # Important note: in order to support this mode, a compiler *must*
- # always write the preprocessed file to stdout, regardless of -o.
- "$@" || exit $?
-
- # Remove the call to Libtool.
- if test "$libtool" = yes; then
- while test $1 != '--mode=compile'; do
- shift
- done
- shift
- fi
-
- # Remove `-o $object'.
- IFS=" "
- for arg
- do
- case $arg in
- -o)
- shift
- ;;
- $object)
- shift
- ;;
- *)
- set fnord "$@" "$arg"
- shift # fnord
- shift # $arg
- ;;
- esac
- done
-
- test -z "$dashmflag" && dashmflag=-M
- # Require at least two characters before searching for `:'
- # in the target name. This is to cope with DOS-style filenames:
- # a dependency such as `c:/foo/bar' could be seen as target `c' otherwise.
- "$@" $dashmflag |
- sed 's:^[ ]*[^: ][^:][^:]*\:[ ]*:'"$object"'\: :' > "$tmpdepfile"
- rm -f "$depfile"
- cat < "$tmpdepfile" > "$depfile"
- tr ' ' '
-' < "$tmpdepfile" | \
-## Some versions of the HPUX 10.20 sed can't process this invocation
-## correctly. Breaking it into two sed invocations is a workaround.
- sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
- rm -f "$tmpdepfile"
- ;;
-
-dashXmstdout)
- # This case only exists to satisfy depend.m4. It is never actually
- # run, as this mode is specially recognized in the preamble.
- exit 1
- ;;
-
-makedepend)
- "$@" || exit $?
- # Remove any Libtool call
- if test "$libtool" = yes; then
- while test $1 != '--mode=compile'; do
- shift
- done
- shift
- fi
- # X makedepend
- shift
- cleared=no
- for arg in "$@"; do
- case $cleared in
- no)
- set ""; shift
- cleared=yes ;;
- esac
- case "$arg" in
- -D*|-I*)
- set fnord "$@" "$arg"; shift ;;
- # Strip any option that makedepend may not understand. Remove
- # the object too, otherwise makedepend will parse it as a source file.
- -*|$object)
- ;;
- *)
- set fnord "$@" "$arg"; shift ;;
- esac
- done
- obj_suffix="`echo $object | sed 's/^.*\././'`"
- touch "$tmpdepfile"
- ${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@"
- rm -f "$depfile"
- cat < "$tmpdepfile" > "$depfile"
- sed '1,2d' "$tmpdepfile" | tr ' ' '
-' | \
-## Some versions of the HPUX 10.20 sed can't process this invocation
-## correctly. Breaking it into two sed invocations is a workaround.
- sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
- rm -f "$tmpdepfile" "$tmpdepfile".bak
- ;;
-
-cpp)
- # Important note: in order to support this mode, a compiler *must*
- # always write the preprocessed file to stdout.
- "$@" || exit $?
-
- # Remove the call to Libtool.
- if test "$libtool" = yes; then
- while test $1 != '--mode=compile'; do
- shift
- done
- shift
- fi
-
- # Remove `-o $object'.
- IFS=" "
- for arg
- do
- case $arg in
- -o)
- shift
- ;;
- $object)
- shift
- ;;
- *)
- set fnord "$@" "$arg"
- shift # fnord
- shift # $arg
- ;;
- esac
- done
-
- "$@" -E |
- sed -n -e '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \
- -e '/^#line [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' |
- sed '$ s: \\$::' > "$tmpdepfile"
- rm -f "$depfile"
- echo "$object : \\" > "$depfile"
- cat < "$tmpdepfile" >> "$depfile"
- sed < "$tmpdepfile" '/^$/d;s/^ //;s/ \\$//;s/$/ :/' >> "$depfile"
- rm -f "$tmpdepfile"
- ;;
-
-msvisualcpp)
- # Important note: in order to support this mode, a compiler *must*
- # always write the preprocessed file to stdout, regardless of -o,
- # because we must use -o when running libtool.
- "$@" || exit $?
- IFS=" "
- for arg
- do
- case "$arg" in
- "-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI")
- set fnord "$@"
- shift
- shift
- ;;
- *)
- set fnord "$@" "$arg"
- shift
- shift
- ;;
- esac
- done
- "$@" -E |
- sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::echo "`cygpath -u \\"\1\\"`":p' | sort | uniq > "$tmpdepfile"
- rm -f "$depfile"
- echo "$object : \\" > "$depfile"
- . "$tmpdepfile" | sed 's% %\\ %g' | sed -n '/^\(.*\)$/ s:: \1 \\:p' >> "$depfile"
- echo " " >> "$depfile"
- . "$tmpdepfile" | sed 's% %\\ %g' | sed -n '/^\(.*\)$/ s::\1\::p' >> "$depfile"
- rm -f "$tmpdepfile"
- ;;
-
-none)
- exec "$@"
- ;;
-
-*)
- echo "Unknown depmode $depmode" 1>&2
- exit 1
- ;;
-esac
-
-exit 0
-
-# Local Variables:
-# mode: shell-script
-# sh-indentation: 2
-# eval: (add-hook 'write-file-hooks 'time-stamp)
-# time-stamp-start: "scriptversion="
-# time-stamp-format: "%:y-%02m-%02d.%02H"
-# time-stamp-end: "$"
-# End:
diff --git a/contrib/ofed/libibcm/config/install-sh b/contrib/ofed/libibcm/config/install-sh
deleted file mode 100755
index 4d4a951..0000000
--- a/contrib/ofed/libibcm/config/install-sh
+++ /dev/null
@@ -1,323 +0,0 @@
-#!/bin/sh
-# install - install a program, script, or datafile
-
-scriptversion=2005-05-14.22
-
-# This originates from X11R5 (mit/util/scripts/install.sh), which was
-# later released in X11R6 (xc/config/util/install.sh) with the
-# following copyright and license.
-#
-# Copyright (C) 1994 X Consortium
-#
-# Permission is hereby granted, free of charge, to any person obtaining a copy
-# of this software and associated documentation files (the "Software"), to
-# deal in the Software without restriction, including without limitation the
-# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
-# sell copies of the Software, and to permit persons to whom the Software is
-# furnished to do so, subject to the following conditions:
-#
-# The above copyright notice and this permission notice shall be included in
-# all copies or substantial portions of the Software.
-#
-# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-# X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
-# AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNEC-
-# TION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-#
-# Except as contained in this notice, the name of the X Consortium shall not
-# be used in advertising or otherwise to promote the sale, use or other deal-
-# ings in this Software without prior written authorization from the X Consor-
-# tium.
-#
-#
-# FSF changes to this file are in the public domain.
-#
-# Calling this script install-sh is preferred over install.sh, to prevent
-# `make' implicit rules from creating a file called install from it
-# when there is no Makefile.
-#
-# This script is compatible with the BSD install script, but was written
-# from scratch. It can only install one file at a time, a restriction
-# shared with many OS's install programs.
-
-# set DOITPROG to echo to test this script
-
-# Don't use :- since 4.3BSD and earlier shells don't like it.
-doit="${DOITPROG-}"
-
-# put in absolute paths if you don't have them in your path; or use env. vars.
-
-mvprog="${MVPROG-mv}"
-cpprog="${CPPROG-cp}"
-chmodprog="${CHMODPROG-chmod}"
-chownprog="${CHOWNPROG-chown}"
-chgrpprog="${CHGRPPROG-chgrp}"
-stripprog="${STRIPPROG-strip}"
-rmprog="${RMPROG-rm}"
-mkdirprog="${MKDIRPROG-mkdir}"
-
-chmodcmd="$chmodprog 0755"
-chowncmd=
-chgrpcmd=
-stripcmd=
-rmcmd="$rmprog -f"
-mvcmd="$mvprog"
-src=
-dst=
-dir_arg=
-dstarg=
-no_target_directory=
-
-usage="Usage: $0 [OPTION]... [-T] SRCFILE DSTFILE
- or: $0 [OPTION]... SRCFILES... DIRECTORY
- or: $0 [OPTION]... -t DIRECTORY SRCFILES...
- or: $0 [OPTION]... -d DIRECTORIES...
-
-In the 1st form, copy SRCFILE to DSTFILE.
-In the 2nd and 3rd, copy all SRCFILES to DIRECTORY.
-In the 4th, create DIRECTORIES.
-
-Options:
--c (ignored)
--d create directories instead of installing files.
--g GROUP $chgrpprog installed files to GROUP.
--m MODE $chmodprog installed files to MODE.
--o USER $chownprog installed files to USER.
--s $stripprog installed files.
--t DIRECTORY install into DIRECTORY.
--T report an error if DSTFILE is a directory.
---help display this help and exit.
---version display version info and exit.
-
-Environment variables override the default commands:
- CHGRPPROG CHMODPROG CHOWNPROG CPPROG MKDIRPROG MVPROG RMPROG STRIPPROG
-"
-
-while test -n "$1"; do
- case $1 in
- -c) shift
- continue;;
-
- -d) dir_arg=true
- shift
- continue;;
-
- -g) chgrpcmd="$chgrpprog $2"
- shift
- shift
- continue;;
-
- --help) echo "$usage"; exit $?;;
-
- -m) chmodcmd="$chmodprog $2"
- shift
- shift
- continue;;
-
- -o) chowncmd="$chownprog $2"
- shift
- shift
- continue;;
-
- -s) stripcmd=$stripprog
- shift
- continue;;
-
- -t) dstarg=$2
- shift
- shift
- continue;;
-
- -T) no_target_directory=true
- shift
- continue;;
-
- --version) echo "$0 $scriptversion"; exit $?;;
-
- *) # When -d is used, all remaining arguments are directories to create.
- # When -t is used, the destination is already specified.
- test -n "$dir_arg$dstarg" && break
- # Otherwise, the last argument is the destination. Remove it from $@.
- for arg
- do
- if test -n "$dstarg"; then
- # $@ is not empty: it contains at least $arg.
- set fnord "$@" "$dstarg"
- shift # fnord
- fi
- shift # arg
- dstarg=$arg
- done
- break;;
- esac
-done
-
-if test -z "$1"; then
- if test -z "$dir_arg"; then
- echo "$0: no input file specified." >&2
- exit 1
- fi
- # It's OK to call `install-sh -d' without argument.
- # This can happen when creating conditional directories.
- exit 0
-fi
-
-for src
-do
- # Protect names starting with `-'.
- case $src in
- -*) src=./$src ;;
- esac
-
- if test -n "$dir_arg"; then
- dst=$src
- src=
-
- if test -d "$dst"; then
- mkdircmd=:
- chmodcmd=
- else
- mkdircmd=$mkdirprog
- fi
- else
- # Waiting for this to be detected by the "$cpprog $src $dsttmp" command
- # might cause directories to be created, which would be especially bad
- # if $src (and thus $dsttmp) contains '*'.
- if test ! -f "$src" && test ! -d "$src"; then
- echo "$0: $src does not exist." >&2
- exit 1
- fi
-
- if test -z "$dstarg"; then
- echo "$0: no destination specified." >&2
- exit 1
- fi
-
- dst=$dstarg
- # Protect names starting with `-'.
- case $dst in
- -*) dst=./$dst ;;
- esac
-
- # If destination is a directory, append the input filename; won't work
- # if double slashes aren't ignored.
- if test -d "$dst"; then
- if test -n "$no_target_directory"; then
- echo "$0: $dstarg: Is a directory" >&2
- exit 1
- fi
- dst=$dst/`basename "$src"`
- fi
- fi
-
- # This sed command emulates the dirname command.
- dstdir=`echo "$dst" | sed -e 's,/*$,,;s,[^/]*$,,;s,/*$,,;s,^$,.,'`
-
- # Make sure that the destination directory exists.
-
- # Skip lots of stat calls in the usual case.
- if test ! -d "$dstdir"; then
- defaultIFS='
- '
- IFS="${IFS-$defaultIFS}"
-
- oIFS=$IFS
- # Some sh's can't handle IFS=/ for some reason.
- IFS='%'
- set x `echo "$dstdir" | sed -e 's@/@%@g' -e 's@^%@/@'`
- shift
- IFS=$oIFS
-
- pathcomp=
-
- while test $# -ne 0 ; do
- pathcomp=$pathcomp$1
- shift
- if test ! -d "$pathcomp"; then
- $mkdirprog "$pathcomp"
- # mkdir can fail with a `File exist' error in case several
- # install-sh are creating the directory concurrently. This
- # is OK.
- test -d "$pathcomp" || exit
- fi
- pathcomp=$pathcomp/
- done
- fi
-
- if test -n "$dir_arg"; then
- $doit $mkdircmd "$dst" \
- && { test -z "$chowncmd" || $doit $chowncmd "$dst"; } \
- && { test -z "$chgrpcmd" || $doit $chgrpcmd "$dst"; } \
- && { test -z "$stripcmd" || $doit $stripcmd "$dst"; } \
- && { test -z "$chmodcmd" || $doit $chmodcmd "$dst"; }
-
- else
- dstfile=`basename "$dst"`
-
- # Make a couple of temp file names in the proper directory.
- dsttmp=$dstdir/_inst.$$_
- rmtmp=$dstdir/_rm.$$_
-
- # Trap to clean up those temp files at exit.
- trap 'ret=$?; rm -f "$dsttmp" "$rmtmp" && exit $ret' 0
- trap '(exit $?); exit' 1 2 13 15
-
- # Copy the file name to the temp name.
- $doit $cpprog "$src" "$dsttmp" &&
-
- # and set any options; do chmod last to preserve setuid bits.
- #
- # If any of these fail, we abort the whole thing. If we want to
- # ignore errors from any of these, just make sure not to ignore
- # errors from the above "$doit $cpprog $src $dsttmp" command.
- #
- { test -z "$chowncmd" || $doit $chowncmd "$dsttmp"; } \
- && { test -z "$chgrpcmd" || $doit $chgrpcmd "$dsttmp"; } \
- && { test -z "$stripcmd" || $doit $stripcmd "$dsttmp"; } \
- && { test -z "$chmodcmd" || $doit $chmodcmd "$dsttmp"; } &&
-
- # Now rename the file to the real destination.
- { $doit $mvcmd -f "$dsttmp" "$dstdir/$dstfile" 2>/dev/null \
- || {
- # The rename failed, perhaps because mv can't rename something else
- # to itself, or perhaps because mv is so ancient that it does not
- # support -f.
-
- # Now remove or move aside any old file at destination location.
- # We try this two ways since rm can't unlink itself on some
- # systems and the destination file might be busy for other
- # reasons. In this case, the final cleanup might fail but the new
- # file should still install successfully.
- {
- if test -f "$dstdir/$dstfile"; then
- $doit $rmcmd -f "$dstdir/$dstfile" 2>/dev/null \
- || $doit $mvcmd -f "$dstdir/$dstfile" "$rmtmp" 2>/dev/null \
- || {
- echo "$0: cannot unlink or rename $dstdir/$dstfile" >&2
- (exit 1); exit 1
- }
- else
- :
- fi
- } &&
-
- # Now rename the file to the real destination.
- $doit $mvcmd "$dsttmp" "$dstdir/$dstfile"
- }
- }
- fi || { (exit 1); exit 1; }
-done
-
-# The final little trick to "correctly" pass the exit status to the exit trap.
-{
- (exit 0); exit 0
-}
-
-# Local variables:
-# eval: (add-hook 'write-file-hooks 'time-stamp)
-# time-stamp-start: "scriptversion="
-# time-stamp-format: "%:y-%02m-%02d.%02H"
-# time-stamp-end: "$"
-# End:
diff --git a/contrib/ofed/libibcm/config/ltmain.sh b/contrib/ofed/libibcm/config/ltmain.sh
deleted file mode 100644
index 8fc56db..0000000
--- a/contrib/ofed/libibcm/config/ltmain.sh
+++ /dev/null
@@ -1,6871 +0,0 @@
-# ltmain.sh - Provide generalized library-building support services.
-# NOTE: Changing this file will not affect anything until you rerun configure.
-#
-# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005
-# Free Software Foundation, Inc.
-# Originally by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-#
-# This program 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 this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-#
-# As a special exception to the GNU General Public License, if you
-# distribute this file as part of a program that contains a
-# configuration script generated by Autoconf, you may include it under
-# the same distribution terms that you use for the rest of that program.
-
-basename="s,^.*/,,g"
-
-# Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh
-# is ksh but when the shell is invoked as "sh" and the current value of
-# the _XPG environment variable is not equal to 1 (one), the special
-# positional parameter $0, within a function call, is the name of the
-# function.
-progpath="$0"
-
-# The name of this program:
-progname=`echo "$progpath" | $SED $basename`
-modename="$progname"
-
-# Global variables:
-EXIT_SUCCESS=0
-EXIT_FAILURE=1
-
-PROGRAM=ltmain.sh
-PACKAGE=libtool
-VERSION="1.5.22 Debian 1.5.22-2"
-TIMESTAMP=" (1.1220.2.365 2005/12/18 22:14:06)"
-
-# See if we are running on zsh, and set the options which allow our
-# commands through without removal of \ escapes.
-if test -n "${ZSH_VERSION+set}" ; then
- setopt NO_GLOB_SUBST
-fi
-
-# Check that we have a working $echo.
-if test "X$1" = X--no-reexec; then
- # Discard the --no-reexec flag, and continue.
- shift
-elif test "X$1" = X--fallback-echo; then
- # Avoid inline document here, it may be left over
- :
-elif test "X`($echo '\t') 2>/dev/null`" = 'X\t'; then
- # Yippee, $echo works!
- :
-else
- # Restart under the correct shell, and then maybe $echo will work.
- exec $SHELL "$progpath" --no-reexec ${1+"$@"}
-fi
-
-if test "X$1" = X--fallback-echo; then
- # used as fallback echo
- shift
- cat <<EOF
-$*
-EOF
- exit $EXIT_SUCCESS
-fi
-
-default_mode=
-help="Try \`$progname --help' for more information."
-magic="%%%MAGIC variable%%%"
-mkdir="mkdir"
-mv="mv -f"
-rm="rm -f"
-
-# Sed substitution that helps us do robust quoting. It backslashifies
-# metacharacters that are still active within double-quoted strings.
-Xsed="${SED}"' -e 1s/^X//'
-sed_quote_subst='s/\([\\`\\"$\\\\]\)/\\\1/g'
-# test EBCDIC or ASCII
-case `echo X|tr X '\101'` in
- A) # ASCII based system
- # \n is not interpreted correctly by Solaris 8 /usr/ucb/tr
- SP2NL='tr \040 \012'
- NL2SP='tr \015\012 \040\040'
- ;;
- *) # EBCDIC based system
- SP2NL='tr \100 \n'
- NL2SP='tr \r\n \100\100'
- ;;
-esac
-
-# NLS nuisances.
-# Only set LANG and LC_ALL to C if already set.
-# These must not be set unconditionally because not all systems understand
-# e.g. LANG=C (notably SCO).
-# We save the old values to restore during execute mode.
-if test "${LC_ALL+set}" = set; then
- save_LC_ALL="$LC_ALL"; LC_ALL=C; export LC_ALL
-fi
-if test "${LANG+set}" = set; then
- save_LANG="$LANG"; LANG=C; export LANG
-fi
-
-# Make sure IFS has a sensible default
-lt_nl='
-'
-IFS=" $lt_nl"
-
-if test "$build_libtool_libs" != yes && test "$build_old_libs" != yes; then
- $echo "$modename: not configured to build any kind of library" 1>&2
- $echo "Fatal configuration error. See the $PACKAGE docs for more information." 1>&2
- exit $EXIT_FAILURE
-fi
-
-# Global variables.
-mode=$default_mode
-nonopt=
-prev=
-prevopt=
-run=
-show="$echo"
-show_help=
-execute_dlfiles=
-duplicate_deps=no
-preserve_args=
-lo2o="s/\\.lo\$/.${objext}/"
-o2lo="s/\\.${objext}\$/.lo/"
-
-#####################################
-# Shell function definitions:
-# This seems to be the best place for them
-
-# func_mktempdir [string]
-# Make a temporary directory that won't clash with other running
-# libtool processes, and avoids race conditions if possible. If
-# given, STRING is the basename for that directory.
-func_mktempdir ()
-{
- my_template="${TMPDIR-/tmp}/${1-$progname}"
-
- if test "$run" = ":"; then
- # Return a directory name, but don't create it in dry-run mode
- my_tmpdir="${my_template}-$$"
- else
-
- # If mktemp works, use that first and foremost
- my_tmpdir=`mktemp -d "${my_template}-XXXXXXXX" 2>/dev/null`
-
- if test ! -d "$my_tmpdir"; then
- # Failing that, at least try and use $RANDOM to avoid a race
- my_tmpdir="${my_template}-${RANDOM-0}$$"
-
- save_mktempdir_umask=`umask`
- umask 0077
- $mkdir "$my_tmpdir"
- umask $save_mktempdir_umask
- fi
-
- # If we're not in dry-run mode, bomb out on failure
- test -d "$my_tmpdir" || {
- $echo "cannot create temporary directory \`$my_tmpdir'" 1>&2
- exit $EXIT_FAILURE
- }
- fi
-
- $echo "X$my_tmpdir" | $Xsed
-}
-
-
-# func_win32_libid arg
-# return the library type of file 'arg'
-#
-# Need a lot of goo to handle *both* DLLs and import libs
-# Has to be a shell function in order to 'eat' the argument
-# that is supplied when $file_magic_command is called.
-func_win32_libid ()
-{
- win32_libid_type="unknown"
- win32_fileres=`file -L $1 2>/dev/null`
- case $win32_fileres in
- *ar\ archive\ import\ library*) # definitely import
- win32_libid_type="x86 archive import"
- ;;
- *ar\ archive*) # could be an import, or static
- if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null | \
- $EGREP -e 'file format pe-i386(.*architecture: i386)?' >/dev/null ; then
- win32_nmres=`eval $NM -f posix -A $1 | \
- $SED -n -e '1,100{/ I /{s,.*,import,;p;q;};}'`
- case $win32_nmres in
- import*) win32_libid_type="x86 archive import";;
- *) win32_libid_type="x86 archive static";;
- esac
- fi
- ;;
- *DLL*)
- win32_libid_type="x86 DLL"
- ;;
- *executable*) # but shell scripts are "executable" too...
- case $win32_fileres in
- *MS\ Windows\ PE\ Intel*)
- win32_libid_type="x86 DLL"
- ;;
- esac
- ;;
- esac
- $echo $win32_libid_type
-}
-
-
-# func_infer_tag arg
-# Infer tagged configuration to use if any are available and
-# if one wasn't chosen via the "--tag" command line option.
-# Only attempt this if the compiler in the base compile
-# command doesn't match the default compiler.
-# arg is usually of the form 'gcc ...'
-func_infer_tag ()
-{
- if test -n "$available_tags" && test -z "$tagname"; then
- CC_quoted=
- for arg in $CC; do
- case $arg in
- *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"")
- arg="\"$arg\""
- ;;
- esac
- CC_quoted="$CC_quoted $arg"
- done
- case $@ in
- # Blanks in the command may have been stripped by the calling shell,
- # but not from the CC environment variable when configure was run.
- " $CC "* | "$CC "* | " `$echo $CC` "* | "`$echo $CC` "* | " $CC_quoted"* | "$CC_quoted "* | " `$echo $CC_quoted` "* | "`$echo $CC_quoted` "*) ;;
- # Blanks at the start of $base_compile will cause this to fail
- # if we don't check for them as well.
- *)
- for z in $available_tags; do
- if grep "^# ### BEGIN LIBTOOL TAG CONFIG: $z$" < "$progpath" > /dev/null; then
- # Evaluate the configuration.
- eval "`${SED} -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $progpath`"
- CC_quoted=
- for arg in $CC; do
- # Double-quote args containing other shell metacharacters.
- case $arg in
- *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"")
- arg="\"$arg\""
- ;;
- esac
- CC_quoted="$CC_quoted $arg"
- done
- case "$@ " in
- " $CC "* | "$CC "* | " `$echo $CC` "* | "`$echo $CC` "* | " $CC_quoted"* | "$CC_quoted "* | " `$echo $CC_quoted` "* | "`$echo $CC_quoted` "*)
- # The compiler in the base compile command matches
- # the one in the tagged configuration.
- # Assume this is the tagged configuration we want.
- tagname=$z
- break
- ;;
- esac
- fi
- done
- # If $tagname still isn't set, then no tagged configuration
- # was found and let the user know that the "--tag" command
- # line option must be used.
- if test -z "$tagname"; then
- $echo "$modename: unable to infer tagged configuration"
- $echo "$modename: specify a tag with \`--tag'" 1>&2
- exit $EXIT_FAILURE
-# else
-# $echo "$modename: using $tagname tagged configuration"
- fi
- ;;
- esac
- fi
-}
-
-
-# func_extract_an_archive dir oldlib
-func_extract_an_archive ()
-{
- f_ex_an_ar_dir="$1"; shift
- f_ex_an_ar_oldlib="$1"
-
- $show "(cd $f_ex_an_ar_dir && $AR x $f_ex_an_ar_oldlib)"
- $run eval "(cd \$f_ex_an_ar_dir && $AR x \$f_ex_an_ar_oldlib)" || exit $?
- if ($AR t "$f_ex_an_ar_oldlib" | sort | sort -uc >/dev/null 2>&1); then
- :
- else
- $echo "$modename: ERROR: object name conflicts: $f_ex_an_ar_dir/$f_ex_an_ar_oldlib" 1>&2
- exit $EXIT_FAILURE
- fi
-}
-
-# func_extract_archives gentop oldlib ...
-func_extract_archives ()
-{
- my_gentop="$1"; shift
- my_oldlibs=${1+"$@"}
- my_oldobjs=""
- my_xlib=""
- my_xabs=""
- my_xdir=""
- my_status=""
-
- $show "${rm}r $my_gentop"
- $run ${rm}r "$my_gentop"
- $show "$mkdir $my_gentop"
- $run $mkdir "$my_gentop"
- my_status=$?
- if test "$my_status" -ne 0 && test ! -d "$my_gentop"; then
- exit $my_status
- fi
-
- for my_xlib in $my_oldlibs; do
- # Extract the objects.
- case $my_xlib in
- [\\/]* | [A-Za-z]:[\\/]*) my_xabs="$my_xlib" ;;
- *) my_xabs=`pwd`"/$my_xlib" ;;
- esac
- my_xlib=`$echo "X$my_xlib" | $Xsed -e 's%^.*/%%'`
- my_xdir="$my_gentop/$my_xlib"
-
- $show "${rm}r $my_xdir"
- $run ${rm}r "$my_xdir"
- $show "$mkdir $my_xdir"
- $run $mkdir "$my_xdir"
- exit_status=$?
- if test "$exit_status" -ne 0 && test ! -d "$my_xdir"; then
- exit $exit_status
- fi
- case $host in
- *-darwin*)
- $show "Extracting $my_xabs"
- # Do not bother doing anything if just a dry run
- if test -z "$run"; then
- darwin_orig_dir=`pwd`
- cd $my_xdir || exit $?
- darwin_archive=$my_xabs
- darwin_curdir=`pwd`
- darwin_base_archive=`$echo "X$darwin_archive" | $Xsed -e 's%^.*/%%'`
- darwin_arches=`lipo -info "$darwin_archive" 2>/dev/null | $EGREP Architectures 2>/dev/null`
- if test -n "$darwin_arches"; then
- darwin_arches=`echo "$darwin_arches" | $SED -e 's/.*are://'`
- darwin_arch=
- $show "$darwin_base_archive has multiple architectures $darwin_arches"
- for darwin_arch in $darwin_arches ; do
- mkdir -p "unfat-$$/${darwin_base_archive}-${darwin_arch}"
- lipo -thin $darwin_arch -output "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}" "${darwin_archive}"
- cd "unfat-$$/${darwin_base_archive}-${darwin_arch}"
- func_extract_an_archive "`pwd`" "${darwin_base_archive}"
- cd "$darwin_curdir"
- $rm "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}"
- done # $darwin_arches
- ## Okay now we have a bunch of thin objects, gotta fatten them up :)
- darwin_filelist=`find unfat-$$ -type f -name \*.o -print -o -name \*.lo -print| xargs basename | sort -u | $NL2SP`
- darwin_file=
- darwin_files=
- for darwin_file in $darwin_filelist; do
- darwin_files=`find unfat-$$ -name $darwin_file -print | $NL2SP`
- lipo -create -output "$darwin_file" $darwin_files
- done # $darwin_filelist
- ${rm}r unfat-$$
- cd "$darwin_orig_dir"
- else
- cd "$darwin_orig_dir"
- func_extract_an_archive "$my_xdir" "$my_xabs"
- fi # $darwin_arches
- fi # $run
- ;;
- *)
- func_extract_an_archive "$my_xdir" "$my_xabs"
- ;;
- esac
- my_oldobjs="$my_oldobjs "`find $my_xdir -name \*.$objext -print -o -name \*.lo -print | $NL2SP`
- done
- func_extract_archives_result="$my_oldobjs"
-}
-# End of Shell function definitions
-#####################################
-
-# Darwin sucks
-eval std_shrext=\"$shrext_cmds\"
-
-disable_libs=no
-
-# Parse our command line options once, thoroughly.
-while test "$#" -gt 0
-do
- arg="$1"
- shift
-
- case $arg in
- -*=*) optarg=`$echo "X$arg" | $Xsed -e 's/[-_a-zA-Z0-9]*=//'` ;;
- *) optarg= ;;
- esac
-
- # If the previous option needs an argument, assign it.
- if test -n "$prev"; then
- case $prev in
- execute_dlfiles)
- execute_dlfiles="$execute_dlfiles $arg"
- ;;
- tag)
- tagname="$arg"
- preserve_args="${preserve_args}=$arg"
-
- # Check whether tagname contains only valid characters
- case $tagname in
- *[!-_A-Za-z0-9,/]*)
- $echo "$progname: invalid tag name: $tagname" 1>&2
- exit $EXIT_FAILURE
- ;;
- esac
-
- case $tagname in
- CC)
- # Don't test for the "default" C tag, as we know, it's there, but
- # not specially marked.
- ;;
- *)
- if grep "^# ### BEGIN LIBTOOL TAG CONFIG: $tagname$" < "$progpath" > /dev/null; then
- taglist="$taglist $tagname"
- # Evaluate the configuration.
- eval "`${SED} -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$tagname'$/,/^# ### END LIBTOOL TAG CONFIG: '$tagname'$/p' < $progpath`"
- else
- $echo "$progname: ignoring unknown tag $tagname" 1>&2
- fi
- ;;
- esac
- ;;
- *)
- eval "$prev=\$arg"
- ;;
- esac
-
- prev=
- prevopt=
- continue
- fi
-
- # Have we seen a non-optional argument yet?
- case $arg in
- --help)
- show_help=yes
- ;;
-
- --version)
- $echo "$PROGRAM (GNU $PACKAGE) $VERSION$TIMESTAMP"
- $echo
- $echo "Copyright (C) 2005 Free Software Foundation, Inc."
- $echo "This is free software; see the source for copying conditions. There is NO"
- $echo "warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
- exit $?
- ;;
-
- --config)
- ${SED} -e '1,/^# ### BEGIN LIBTOOL CONFIG/d' -e '/^# ### END LIBTOOL CONFIG/,$d' $progpath
- # Now print the configurations for the tags.
- for tagname in $taglist; do
- ${SED} -n -e "/^# ### BEGIN LIBTOOL TAG CONFIG: $tagname$/,/^# ### END LIBTOOL TAG CONFIG: $tagname$/p" < "$progpath"
- done
- exit $?
- ;;
-
- --debug)
- $echo "$progname: enabling shell trace mode"
- set -x
- preserve_args="$preserve_args $arg"
- ;;
-
- --dry-run | -n)
- run=:
- ;;
-
- --features)
- $echo "host: $host"
- if test "$build_libtool_libs" = yes; then
- $echo "enable shared libraries"
- else
- $echo "disable shared libraries"
- fi
- if test "$build_old_libs" = yes; then
- $echo "enable static libraries"
- else
- $echo "disable static libraries"
- fi
- exit $?
- ;;
-
- --finish) mode="finish" ;;
-
- --mode) prevopt="--mode" prev=mode ;;
- --mode=*) mode="$optarg" ;;
-
- --preserve-dup-deps) duplicate_deps="yes" ;;
-
- --quiet | --silent)
- show=:
- preserve_args="$preserve_args $arg"
- ;;
-
- --tag)
- prevopt="--tag"
- prev=tag
- preserve_args="$preserve_args --tag"
- ;;
- --tag=*)
- set tag "$optarg" ${1+"$@"}
- shift
- prev=tag
- preserve_args="$preserve_args --tag"
- ;;
-
- -dlopen)
- prevopt="-dlopen"
- prev=execute_dlfiles
- ;;
-
- -*)
- $echo "$modename: unrecognized option \`$arg'" 1>&2
- $echo "$help" 1>&2
- exit $EXIT_FAILURE
- ;;
-
- *)
- nonopt="$arg"
- break
- ;;
- esac
-done
-
-if test -n "$prevopt"; then
- $echo "$modename: option \`$prevopt' requires an argument" 1>&2
- $echo "$help" 1>&2
- exit $EXIT_FAILURE
-fi
-
-case $disable_libs in
-no)
- ;;
-shared)
- build_libtool_libs=no
- build_old_libs=yes
- ;;
-static)
- build_old_libs=`case $build_libtool_libs in yes) echo no;; *) echo yes;; esac`
- ;;
-esac
-
-# If this variable is set in any of the actions, the command in it
-# will be execed at the end. This prevents here-documents from being
-# left over by shells.
-exec_cmd=
-
-if test -z "$show_help"; then
-
- # Infer the operation mode.
- if test -z "$mode"; then
- $echo "*** Warning: inferring the mode of operation is deprecated." 1>&2
- $echo "*** Future versions of Libtool will require --mode=MODE be specified." 1>&2
- case $nonopt in
- *cc | cc* | *++ | gcc* | *-gcc* | g++* | xlc*)
- mode=link
- for arg
- do
- case $arg in
- -c)
- mode=compile
- break
- ;;
- esac
- done
- ;;
- *db | *dbx | *strace | *truss)
- mode=execute
- ;;
- *install*|cp|mv)
- mode=install
- ;;
- *rm)
- mode=uninstall
- ;;
- *)
- # If we have no mode, but dlfiles were specified, then do execute mode.
- test -n "$execute_dlfiles" && mode=execute
-
- # Just use the default operation mode.
- if test -z "$mode"; then
- if test -n "$nonopt"; then
- $echo "$modename: warning: cannot infer operation mode from \`$nonopt'" 1>&2
- else
- $echo "$modename: warning: cannot infer operation mode without MODE-ARGS" 1>&2
- fi
- fi
- ;;
- esac
- fi
-
- # Only execute mode is allowed to have -dlopen flags.
- if test -n "$execute_dlfiles" && test "$mode" != execute; then
- $echo "$modename: unrecognized option \`-dlopen'" 1>&2
- $echo "$help" 1>&2
- exit $EXIT_FAILURE
- fi
-
- # Change the help message to a mode-specific one.
- generic_help="$help"
- help="Try \`$modename --help --mode=$mode' for more information."
-
- # These modes are in order of execution frequency so that they run quickly.
- case $mode in
- # libtool compile mode
- compile)
- modename="$modename: compile"
- # Get the compilation command and the source file.
- base_compile=
- srcfile="$nonopt" # always keep a non-empty value in "srcfile"
- suppress_opt=yes
- suppress_output=
- arg_mode=normal
- libobj=
- later=
-
- for arg
- do
- case $arg_mode in
- arg )
- # do not "continue". Instead, add this to base_compile
- lastarg="$arg"
- arg_mode=normal
- ;;
-
- target )
- libobj="$arg"
- arg_mode=normal
- continue
- ;;
-
- normal )
- # Accept any command-line options.
- case $arg in
- -o)
- if test -n "$libobj" ; then
- $echo "$modename: you cannot specify \`-o' more than once" 1>&2
- exit $EXIT_FAILURE
- fi
- arg_mode=target
- continue
- ;;
-
- -static | -prefer-pic | -prefer-non-pic)
- later="$later $arg"
- continue
- ;;
-
- -no-suppress)
- suppress_opt=no
- continue
- ;;
-
- -Xcompiler)
- arg_mode=arg # the next one goes into the "base_compile" arg list
- continue # The current "srcfile" will either be retained or
- ;; # replaced later. I would guess that would be a bug.
-
- -Wc,*)
- args=`$echo "X$arg" | $Xsed -e "s/^-Wc,//"`
- lastarg=
- save_ifs="$IFS"; IFS=','
- for arg in $args; do
- IFS="$save_ifs"
-
- # Double-quote args containing other shell metacharacters.
- # Many Bourne shells cannot handle close brackets correctly
- # in scan sets, so we specify it separately.
- case $arg in
- *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"")
- arg="\"$arg\""
- ;;
- esac
- lastarg="$lastarg $arg"
- done
- IFS="$save_ifs"
- lastarg=`$echo "X$lastarg" | $Xsed -e "s/^ //"`
-
- # Add the arguments to base_compile.
- base_compile="$base_compile $lastarg"
- continue
- ;;
-
- * )
- # Accept the current argument as the source file.
- # The previous "srcfile" becomes the current argument.
- #
- lastarg="$srcfile"
- srcfile="$arg"
- ;;
- esac # case $arg
- ;;
- esac # case $arg_mode
-
- # Aesthetically quote the previous argument.
- lastarg=`$echo "X$lastarg" | $Xsed -e "$sed_quote_subst"`
-
- case $lastarg in
- # Double-quote args containing other shell metacharacters.
- # Many Bourne shells cannot handle close brackets correctly
- # in scan sets, and some SunOS ksh mistreat backslash-escaping
- # in scan sets (worked around with variable expansion),
- # and furthermore cannot handle '|' '&' '(' ')' in scan sets
- # at all, so we specify them separately.
- *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"")
- lastarg="\"$lastarg\""
- ;;
- esac
-
- base_compile="$base_compile $lastarg"
- done # for arg
-
- case $arg_mode in
- arg)
- $echo "$modename: you must specify an argument for -Xcompile"
- exit $EXIT_FAILURE
- ;;
- target)
- $echo "$modename: you must specify a target with \`-o'" 1>&2
- exit $EXIT_FAILURE
- ;;
- *)
- # Get the name of the library object.
- [ -z "$libobj" ] && libobj=`$echo "X$srcfile" | $Xsed -e 's%^.*/%%'`
- ;;
- esac
-
- # Recognize several different file suffixes.
- # If the user specifies -o file.o, it is replaced with file.lo
- xform='[cCFSifmso]'
- case $libobj in
- *.ada) xform=ada ;;
- *.adb) xform=adb ;;
- *.ads) xform=ads ;;
- *.asm) xform=asm ;;
- *.c++) xform=c++ ;;
- *.cc) xform=cc ;;
- *.ii) xform=ii ;;
- *.class) xform=class ;;
- *.cpp) xform=cpp ;;
- *.cxx) xform=cxx ;;
- *.f90) xform=f90 ;;
- *.for) xform=for ;;
- *.java) xform=java ;;
- esac
-
- libobj=`$echo "X$libobj" | $Xsed -e "s/\.$xform$/.lo/"`
-
- case $libobj in
- *.lo) obj=`$echo "X$libobj" | $Xsed -e "$lo2o"` ;;
- *)
- $echo "$modename: cannot determine name of library object from \`$libobj'" 1>&2
- exit $EXIT_FAILURE
- ;;
- esac
-
- func_infer_tag $base_compile
-
- for arg in $later; do
- case $arg in
- -static)
- build_old_libs=yes
- continue
- ;;
-
- -prefer-pic)
- pic_mode=yes
- continue
- ;;
-
- -prefer-non-pic)
- pic_mode=no
- continue
- ;;
- esac
- done
-
- qlibobj=`$echo "X$libobj" | $Xsed -e "$sed_quote_subst"`
- case $qlibobj in
- *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"")
- qlibobj="\"$qlibobj\"" ;;
- esac
- test "X$libobj" != "X$qlibobj" \
- && $echo "X$libobj" | grep '[]~#^*{};<>?"'"'"' &()|`$[]' \
- && $echo "$modename: libobj name \`$libobj' may not contain shell special characters."
- objname=`$echo "X$obj" | $Xsed -e 's%^.*/%%'`
- xdir=`$echo "X$obj" | $Xsed -e 's%/[^/]*$%%'`
- if test "X$xdir" = "X$obj"; then
- xdir=
- else
- xdir=$xdir/
- fi
- lobj=${xdir}$objdir/$objname
-
- if test -z "$base_compile"; then
- $echo "$modename: you must specify a compilation command" 1>&2
- $echo "$help" 1>&2
- exit $EXIT_FAILURE
- fi
-
- # Delete any leftover library objects.
- if test "$build_old_libs" = yes; then
- removelist="$obj $lobj $libobj ${libobj}T"
- else
- removelist="$lobj $libobj ${libobj}T"
- fi
-
- $run $rm $removelist
- trap "$run $rm $removelist; exit $EXIT_FAILURE" 1 2 15
-
- # On Cygwin there's no "real" PIC flag so we must build both object types
- case $host_os in
- cygwin* | mingw* | pw32* | os2*)
- pic_mode=default
- ;;
- esac
- if test "$pic_mode" = no && test "$deplibs_check_method" != pass_all; then
- # non-PIC code in shared libraries is not supported
- pic_mode=default
- fi
-
- # Calculate the filename of the output object if compiler does
- # not support -o with -c
- if test "$compiler_c_o" = no; then
- output_obj=`$echo "X$srcfile" | $Xsed -e 's%^.*/%%' -e 's%\.[^.]*$%%'`.${objext}
- lockfile="$output_obj.lock"
- removelist="$removelist $output_obj $lockfile"
- trap "$run $rm $removelist; exit $EXIT_FAILURE" 1 2 15
- else
- output_obj=
- need_locks=no
- lockfile=
- fi
-
- # Lock this critical section if it is needed
- # We use this script file to make the link, it avoids creating a new file
- if test "$need_locks" = yes; then
- until $run ln "$progpath" "$lockfile" 2>/dev/null; do
- $show "Waiting for $lockfile to be removed"
- sleep 2
- done
- elif test "$need_locks" = warn; then
- if test -f "$lockfile"; then
- $echo "\
-*** ERROR, $lockfile exists and contains:
-`cat $lockfile 2>/dev/null`
-
-This indicates that another process is trying to use the same
-temporary object file, and libtool could not work around it because
-your compiler does not support \`-c' and \`-o' together. If you
-repeat this compilation, it may succeed, by chance, but you had better
-avoid parallel builds (make -j) in this platform, or get a better
-compiler."
-
- $run $rm $removelist
- exit $EXIT_FAILURE
- fi
- $echo "$srcfile" > "$lockfile"
- fi
-
- if test -n "$fix_srcfile_path"; then
- eval srcfile=\"$fix_srcfile_path\"
- fi
- qsrcfile=`$echo "X$srcfile" | $Xsed -e "$sed_quote_subst"`
- case $qsrcfile in
- *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"")
- qsrcfile="\"$qsrcfile\"" ;;
- esac
-
- $run $rm "$libobj" "${libobj}T"
-
- # Create a libtool object file (analogous to a ".la" file),
- # but don't create it if we're doing a dry run.
- test -z "$run" && cat > ${libobj}T <<EOF
-# $libobj - a libtool object file
-# Generated by $PROGRAM - GNU $PACKAGE $VERSION$TIMESTAMP
-#
-# Please DO NOT delete this file!
-# It is necessary for linking the library.
-
-# Name of the PIC object.
-EOF
-
- # Only build a PIC object if we are building libtool libraries.
- if test "$build_libtool_libs" = yes; then
- # Without this assignment, base_compile gets emptied.
- fbsd_hideous_sh_bug=$base_compile
-
- if test "$pic_mode" != no; then
- command="$base_compile $qsrcfile $pic_flag"
- else
- # Don't build PIC code
- command="$base_compile $qsrcfile"
- fi
-
- if test ! -d "${xdir}$objdir"; then
- $show "$mkdir ${xdir}$objdir"
- $run $mkdir ${xdir}$objdir
- exit_status=$?
- if test "$exit_status" -ne 0 && test ! -d "${xdir}$objdir"; then
- exit $exit_status
- fi
- fi
-
- if test -z "$output_obj"; then
- # Place PIC objects in $objdir
- command="$command -o $lobj"
- fi
-
- $run $rm "$lobj" "$output_obj"
-
- $show "$command"
- if $run eval "$command"; then :
- else
- test -n "$output_obj" && $run $rm $removelist
- exit $EXIT_FAILURE
- fi
-
- if test "$need_locks" = warn &&
- test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then
- $echo "\
-*** ERROR, $lockfile contains:
-`cat $lockfile 2>/dev/null`
-
-but it should contain:
-$srcfile
-
-This indicates that another process is trying to use the same
-temporary object file, and libtool could not work around it because
-your compiler does not support \`-c' and \`-o' together. If you
-repeat this compilation, it may succeed, by chance, but you had better
-avoid parallel builds (make -j) in this platform, or get a better
-compiler."
-
- $run $rm $removelist
- exit $EXIT_FAILURE
- fi
-
- # Just move the object if needed, then go on to compile the next one
- if test -n "$output_obj" && test "X$output_obj" != "X$lobj"; then
- $show "$mv $output_obj $lobj"
- if $run $mv $output_obj $lobj; then :
- else
- error=$?
- $run $rm $removelist
- exit $error
- fi
- fi
-
- # Append the name of the PIC object to the libtool object file.
- test -z "$run" && cat >> ${libobj}T <<EOF
-pic_object='$objdir/$objname'
-
-EOF
-
- # Allow error messages only from the first compilation.
- if test "$suppress_opt" = yes; then
- suppress_output=' >/dev/null 2>&1'
- fi
- else
- # No PIC object so indicate it doesn't exist in the libtool
- # object file.
- test -z "$run" && cat >> ${libobj}T <<EOF
-pic_object=none
-
-EOF
- fi
-
- # Only build a position-dependent object if we build old libraries.
- if test "$build_old_libs" = yes; then
- if test "$pic_mode" != yes; then
- # Don't build PIC code
- command="$base_compile $qsrcfile"
- else
- command="$base_compile $qsrcfile $pic_flag"
- fi
- if test "$compiler_c_o" = yes; then
- command="$command -o $obj"
- fi
-
- # Suppress compiler output if we already did a PIC compilation.
- command="$command$suppress_output"
- $run $rm "$obj" "$output_obj"
- $show "$command"
- if $run eval "$command"; then :
- else
- $run $rm $removelist
- exit $EXIT_FAILURE
- fi
-
- if test "$need_locks" = warn &&
- test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then
- $echo "\
-*** ERROR, $lockfile contains:
-`cat $lockfile 2>/dev/null`
-
-but it should contain:
-$srcfile
-
-This indicates that another process is trying to use the same
-temporary object file, and libtool could not work around it because
-your compiler does not support \`-c' and \`-o' together. If you
-repeat this compilation, it may succeed, by chance, but you had better
-avoid parallel builds (make -j) in this platform, or get a better
-compiler."
-
- $run $rm $removelist
- exit $EXIT_FAILURE
- fi
-
- # Just move the object if needed
- if test -n "$output_obj" && test "X$output_obj" != "X$obj"; then
- $show "$mv $output_obj $obj"
- if $run $mv $output_obj $obj; then :
- else
- error=$?
- $run $rm $removelist
- exit $error
- fi
- fi
-
- # Append the name of the non-PIC object the libtool object file.
- # Only append if the libtool object file exists.
- test -z "$run" && cat >> ${libobj}T <<EOF
-# Name of the non-PIC object.
-non_pic_object='$objname'
-
-EOF
- else
- # Append the name of the non-PIC object the libtool object file.
- # Only append if the libtool object file exists.
- test -z "$run" && cat >> ${libobj}T <<EOF
-# Name of the non-PIC object.
-non_pic_object=none
-
-EOF
- fi
-
- $run $mv "${libobj}T" "${libobj}"
-
- # Unlock the critical section if it was locked
- if test "$need_locks" != no; then
- $run $rm "$lockfile"
- fi
-
- exit $EXIT_SUCCESS
- ;;
-
- # libtool link mode
- link | relink)
- modename="$modename: link"
- case $host in
- *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2*)
- # It is impossible to link a dll without this setting, and
- # we shouldn't force the makefile maintainer to figure out
- # which system we are compiling for in order to pass an extra
- # flag for every libtool invocation.
- # allow_undefined=no
-
- # FIXME: Unfortunately, there are problems with the above when trying
- # to make a dll which has undefined symbols, in which case not
- # even a static library is built. For now, we need to specify
- # -no-undefined on the libtool link line when we can be certain
- # that all symbols are satisfied, otherwise we get a static library.
- allow_undefined=yes
- ;;
- *)
- allow_undefined=yes
- ;;
- esac
- libtool_args="$nonopt"
- base_compile="$nonopt $@"
- compile_command="$nonopt"
- finalize_command="$nonopt"
-
- compile_rpath=
- finalize_rpath=
- compile_shlibpath=
- finalize_shlibpath=
- convenience=
- old_convenience=
- deplibs=
- old_deplibs=
- compiler_flags=
- linker_flags=
- dllsearchpath=
- lib_search_path=`pwd`
- inst_prefix_dir=
-
- avoid_version=no
- dlfiles=
- dlprefiles=
- dlself=no
- export_dynamic=no
- export_symbols=
- export_symbols_regex=
- generated=
- libobjs=
- ltlibs=
- module=no
- no_install=no
- objs=
- non_pic_objects=
- notinst_path= # paths that contain not-installed libtool libraries
- precious_files_regex=
- prefer_static_libs=no
- preload=no
- prev=
- prevarg=
- release=
- rpath=
- xrpath=
- perm_rpath=
- temp_rpath=
- thread_safe=no
- vinfo=
- vinfo_number=no
-
- func_infer_tag $base_compile
-
- # We need to know -static, to get the right output filenames.
- for arg
- do
- case $arg in
- -all-static | -static)
- if test "X$arg" = "X-all-static"; then
- if test "$build_libtool_libs" = yes && test -z "$link_static_flag"; then
- $echo "$modename: warning: complete static linking is impossible in this configuration" 1>&2
- fi
- if test -n "$link_static_flag"; then
- dlopen_self=$dlopen_self_static
- fi
- prefer_static_libs=yes
- else
- if test -z "$pic_flag" && test -n "$link_static_flag"; then
- dlopen_self=$dlopen_self_static
- fi
- prefer_static_libs=built
- fi
- build_libtool_libs=no
- build_old_libs=yes
- break
- ;;
- esac
- done
-
- # See if our shared archives depend on static archives.
- test -n "$old_archive_from_new_cmds" && build_old_libs=yes
-
- # Go through the arguments, transforming them on the way.
- while test "$#" -gt 0; do
- arg="$1"
- shift
- case $arg in
- *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"")
- qarg=\"`$echo "X$arg" | $Xsed -e "$sed_quote_subst"`\" ### testsuite: skip nested quoting test
- ;;
- *) qarg=$arg ;;
- esac
- libtool_args="$libtool_args $qarg"
-
- # If the previous option needs an argument, assign it.
- if test -n "$prev"; then
- case $prev in
- output)
- compile_command="$compile_command @OUTPUT@"
- finalize_command="$finalize_command @OUTPUT@"
- ;;
- esac
-
- case $prev in
- dlfiles|dlprefiles)
- if test "$preload" = no; then
- # Add the symbol object into the linking commands.
- compile_command="$compile_command @SYMFILE@"
- finalize_command="$finalize_command @SYMFILE@"
- preload=yes
- fi
- case $arg in
- *.la | *.lo) ;; # We handle these cases below.
- force)
- if test "$dlself" = no; then
- dlself=needless
- export_dynamic=yes
- fi
- prev=
- continue
- ;;
- self)
- if test "$prev" = dlprefiles; then
- dlself=yes
- elif test "$prev" = dlfiles && test "$dlopen_self" != yes; then
- dlself=yes
- else
- dlself=needless
- export_dynamic=yes
- fi
- prev=
- continue
- ;;
- *)
- if test "$prev" = dlfiles; then
- dlfiles="$dlfiles $arg"
- else
- dlprefiles="$dlprefiles $arg"
- fi
- prev=
- continue
- ;;
- esac
- ;;
- expsyms)
- export_symbols="$arg"
- if test ! -f "$arg"; then
- $echo "$modename: symbol file \`$arg' does not exist"
- exit $EXIT_FAILURE
- fi
- prev=
- continue
- ;;
- expsyms_regex)
- export_symbols_regex="$arg"
- prev=
- continue
- ;;
- inst_prefix)
- inst_prefix_dir="$arg"
- prev=
- continue
- ;;
- precious_regex)
- precious_files_regex="$arg"
- prev=
- continue
- ;;
- release)
- release="-$arg"
- prev=
- continue
- ;;
- objectlist)
- if test -f "$arg"; then
- save_arg=$arg
- moreargs=
- for fil in `cat $save_arg`
- do
-# moreargs="$moreargs $fil"
- arg=$fil
- # A libtool-controlled object.
-
- # Check to see that this really is a libtool object.
- if (${SED} -e '2q' $arg | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then
- pic_object=
- non_pic_object=
-
- # Read the .lo file
- # If there is no directory component, then add one.
- case $arg in
- */* | *\\*) . $arg ;;
- *) . ./$arg ;;
- esac
-
- if test -z "$pic_object" || \
- test -z "$non_pic_object" ||
- test "$pic_object" = none && \
- test "$non_pic_object" = none; then
- $echo "$modename: cannot find name of object for \`$arg'" 1>&2
- exit $EXIT_FAILURE
- fi
-
- # Extract subdirectory from the argument.
- xdir=`$echo "X$arg" | $Xsed -e 's%/[^/]*$%%'`
- if test "X$xdir" = "X$arg"; then
- xdir=
- else
- xdir="$xdir/"
- fi
-
- if test "$pic_object" != none; then
- # Prepend the subdirectory the object is found in.
- pic_object="$xdir$pic_object"
-
- if test "$prev" = dlfiles; then
- if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then
- dlfiles="$dlfiles $pic_object"
- prev=
- continue
- else
- # If libtool objects are unsupported, then we need to preload.
- prev=dlprefiles
- fi
- fi
-
- # CHECK ME: I think I busted this. -Ossama
- if test "$prev" = dlprefiles; then
- # Preload the old-style object.
- dlprefiles="$dlprefiles $pic_object"
- prev=
- fi
-
- # A PIC object.
- libobjs="$libobjs $pic_object"
- arg="$pic_object"
- fi
-
- # Non-PIC object.
- if test "$non_pic_object" != none; then
- # Prepend the subdirectory the object is found in.
- non_pic_object="$xdir$non_pic_object"
-
- # A standard non-PIC object
- non_pic_objects="$non_pic_objects $non_pic_object"
- if test -z "$pic_object" || test "$pic_object" = none ; then
- arg="$non_pic_object"
- fi
- else
- # If the PIC object exists, use it instead.
- # $xdir was prepended to $pic_object above.
- non_pic_object="$pic_object"
- non_pic_objects="$non_pic_objects $non_pic_object"
- fi
- else
- # Only an error if not doing a dry-run.
- if test -z "$run"; then
- $echo "$modename: \`$arg' is not a valid libtool object" 1>&2
- exit $EXIT_FAILURE
- else
- # Dry-run case.
-
- # Extract subdirectory from the argument.
- xdir=`$echo "X$arg" | $Xsed -e 's%/[^/]*$%%'`
- if test "X$xdir" = "X$arg"; then
- xdir=
- else
- xdir="$xdir/"
- fi
-
- pic_object=`$echo "X${xdir}${objdir}/${arg}" | $Xsed -e "$lo2o"`
- non_pic_object=`$echo "X${xdir}${arg}" | $Xsed -e "$lo2o"`
- libobjs="$libobjs $pic_object"
- non_pic_objects="$non_pic_objects $non_pic_object"
- fi
- fi
- done
- else
- $echo "$modename: link input file \`$save_arg' does not exist"
- exit $EXIT_FAILURE
- fi
- arg=$save_arg
- prev=
- continue
- ;;
- rpath | xrpath)
- # We need an absolute path.
- case $arg in
- [\\/]* | [A-Za-z]:[\\/]*) ;;
- *)
- $echo "$modename: only absolute run-paths are allowed" 1>&2
- exit $EXIT_FAILURE
- ;;
- esac
- if test "$prev" = rpath; then
- case "$rpath " in
- *" $arg "*) ;;
- *) rpath="$rpath $arg" ;;
- esac
- else
- case "$xrpath " in
- *" $arg "*) ;;
- *) xrpath="$xrpath $arg" ;;
- esac
- fi
- prev=
- continue
- ;;
- xcompiler)
- compiler_flags="$compiler_flags $qarg"
- prev=
- compile_command="$compile_command $qarg"
- finalize_command="$finalize_command $qarg"
- continue
- ;;
- xlinker)
- linker_flags="$linker_flags $qarg"
- compiler_flags="$compiler_flags $wl$qarg"
- prev=
- compile_command="$compile_command $wl$qarg"
- finalize_command="$finalize_command $wl$qarg"
- continue
- ;;
- xcclinker)
- linker_flags="$linker_flags $qarg"
- compiler_flags="$compiler_flags $qarg"
- prev=
- compile_command="$compile_command $qarg"
- finalize_command="$finalize_command $qarg"
- continue
- ;;
- shrext)
- shrext_cmds="$arg"
- prev=
- continue
- ;;
- darwin_framework|darwin_framework_skip)
- test "$prev" = "darwin_framework" && compiler_flags="$compiler_flags $arg"
- compile_command="$compile_command $arg"
- finalize_command="$finalize_command $arg"
- prev=
- continue
- ;;
- *)
- eval "$prev=\"\$arg\""
- prev=
- continue
- ;;
- esac
- fi # test -n "$prev"
-
- prevarg="$arg"
-
- case $arg in
- -all-static)
- if test -n "$link_static_flag"; then
- compile_command="$compile_command $link_static_flag"
- finalize_command="$finalize_command $link_static_flag"
- fi
- continue
- ;;
-
- -allow-undefined)
- # FIXME: remove this flag sometime in the future.
- $echo "$modename: \`-allow-undefined' is deprecated because it is the default" 1>&2
- continue
- ;;
-
- -avoid-version)
- avoid_version=yes
- continue
- ;;
-
- -dlopen)
- prev=dlfiles
- continue
- ;;
-
- -dlpreopen)
- prev=dlprefiles
- continue
- ;;
-
- -export-dynamic)
- export_dynamic=yes
- continue
- ;;
-
- -export-symbols | -export-symbols-regex)
- if test -n "$export_symbols" || test -n "$export_symbols_regex"; then
- $echo "$modename: more than one -exported-symbols argument is not allowed"
- exit $EXIT_FAILURE
- fi
- if test "X$arg" = "X-export-symbols"; then
- prev=expsyms
- else
- prev=expsyms_regex
- fi
- continue
- ;;
-
- -framework|-arch|-isysroot)
- case " $CC " in
- *" ${arg} ${1} "* | *" ${arg} ${1} "*)
- prev=darwin_framework_skip ;;
- *) compiler_flags="$compiler_flags $arg"
- prev=darwin_framework ;;
- esac
- compile_command="$compile_command $arg"
- finalize_command="$finalize_command $arg"
- continue
- ;;
-
- -inst-prefix-dir)
- prev=inst_prefix
- continue
- ;;
-
- # The native IRIX linker understands -LANG:*, -LIST:* and -LNO:*
- # so, if we see these flags be careful not to treat them like -L
- -L[A-Z][A-Z]*:*)
- case $with_gcc/$host in
- no/*-*-irix* | /*-*-irix*)
- compile_command="$compile_command $arg"
- finalize_command="$finalize_command $arg"
- ;;
- esac
- continue
- ;;
-
- -L*)
- dir=`$echo "X$arg" | $Xsed -e 's/^-L//'`
- # We need an absolute path.
- case $dir in
- [\\/]* | [A-Za-z]:[\\/]*) ;;
- *)
- absdir=`cd "$dir" && pwd`
- if test -z "$absdir"; then
- $echo "$modename: cannot determine absolute directory name of \`$dir'" 1>&2
- absdir="$dir"
- notinst_path="$notinst_path $dir"
- fi
- dir="$absdir"
- ;;
- esac
- case "$deplibs " in
- *" -L$dir "*) ;;
- *)
- deplibs="$deplibs -L$dir"
- lib_search_path="$lib_search_path $dir"
- ;;
- esac
- case $host in
- *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2*)
- testbindir=`$echo "X$dir" | $Xsed -e 's*/lib$*/bin*'`
- case :$dllsearchpath: in
- *":$dir:"*) ;;
- *) dllsearchpath="$dllsearchpath:$dir";;
- esac
- case :$dllsearchpath: in
- *":$testbindir:"*) ;;
- *) dllsearchpath="$dllsearchpath:$testbindir";;
- esac
- ;;
- esac
- continue
- ;;
-
- -l*)
- if test "X$arg" = "X-lc" || test "X$arg" = "X-lm"; then
- case $host in
- *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-beos*)
- # These systems don't actually have a C or math library (as such)
- continue
- ;;
- *-*-os2*)
- # These systems don't actually have a C library (as such)
- test "X$arg" = "X-lc" && continue
- ;;
- *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
- # Do not include libc due to us having libc/libc_r.
- test "X$arg" = "X-lc" && continue
- ;;
- *-*-rhapsody* | *-*-darwin1.[012])
- # Rhapsody C and math libraries are in the System framework
- deplibs="$deplibs -framework System"
- continue
- ;;
- *-*-sco3.2v5* | *-*-sco5v6*)
- # Causes problems with __ctype
- test "X$arg" = "X-lc" && continue
- ;;
- *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*)
- # Compiler inserts libc in the correct place for threads to work
- test "X$arg" = "X-lc" && continue
- ;;
- esac
- elif test "X$arg" = "X-lc_r"; then
- case $host in
- *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
- # Do not include libc_r directly, use -pthread flag.
- continue
- ;;
- esac
- fi
- deplibs="$deplibs $arg"
- continue
- ;;
-
- # Tru64 UNIX uses -model [arg] to determine the layout of C++
- # classes, name mangling, and exception handling.
- -model)
- compile_command="$compile_command $arg"
- compiler_flags="$compiler_flags $arg"
- finalize_command="$finalize_command $arg"
- prev=xcompiler
- continue
- ;;
-
- -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe)
- compiler_flags="$compiler_flags $arg"
- compile_command="$compile_command $arg"
- finalize_command="$finalize_command $arg"
- continue
- ;;
-
- -module)
- module=yes
- continue
- ;;
-
- # -64, -mips[0-9] enable 64-bit mode on the SGI compiler
- # -r[0-9][0-9]* specifies the processor on the SGI compiler
- # -xarch=*, -xtarget=* enable 64-bit mode on the Sun compiler
- # +DA*, +DD* enable 64-bit mode on the HP compiler
- # -q* pass through compiler args for the IBM compiler
- # -m* pass through architecture-specific compiler args for GCC
- # -m*, -t[45]*, -txscale* pass through architecture-specific
- # compiler args for GCC
- # -pg pass through profiling flag for GCC
- # @file GCC response files
- -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*|-pg| \
- -t[45]*|-txscale*|@*)
-
- # Unknown arguments in both finalize_command and compile_command need
- # to be aesthetically quoted because they are evaled later.
- arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"`
- case $arg in
- *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"")
- arg="\"$arg\""
- ;;
- esac
- compile_command="$compile_command $arg"
- finalize_command="$finalize_command $arg"
- compiler_flags="$compiler_flags $arg"
- continue
- ;;
-
- -shrext)
- prev=shrext
- continue
- ;;
-
- -no-fast-install)
- fast_install=no
- continue
- ;;
-
- -no-install)
- case $host in
- *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2*)
- # The PATH hackery in wrapper scripts is required on Windows
- # in order for the loader to find any dlls it needs.
- $echo "$modename: warning: \`-no-install' is ignored for $host" 1>&2
- $echo "$modename: warning: assuming \`-no-fast-install' instead" 1>&2
- fast_install=no
- ;;
- *) no_install=yes ;;
- esac
- continue
- ;;
-
- -no-undefined)
- allow_undefined=no
- continue
- ;;
-
- -objectlist)
- prev=objectlist
- continue
- ;;
-
- -o) prev=output ;;
-
- -precious-files-regex)
- prev=precious_regex
- continue
- ;;
-
- -release)
- prev=release
- continue
- ;;
-
- -rpath)
- prev=rpath
- continue
- ;;
-
- -R)
- prev=xrpath
- continue
- ;;
-
- -R*)
- dir=`$echo "X$arg" | $Xsed -e 's/^-R//'`
- # We need an absolute path.
- case $dir in
- [\\/]* | [A-Za-z]:[\\/]*) ;;
- *)
- $echo "$modename: only absolute run-paths are allowed" 1>&2
- exit $EXIT_FAILURE
- ;;
- esac
- case "$xrpath " in
- *" $dir "*) ;;
- *) xrpath="$xrpath $dir" ;;
- esac
- continue
- ;;
-
- -static)
- # The effects of -static are defined in a previous loop.
- # We used to do the same as -all-static on platforms that
- # didn't have a PIC flag, but the assumption that the effects
- # would be equivalent was wrong. It would break on at least
- # Digital Unix and AIX.
- continue
- ;;
-
- -thread-safe)
- thread_safe=yes
- continue
- ;;
-
- -version-info)
- prev=vinfo
- continue
- ;;
- -version-number)
- prev=vinfo
- vinfo_number=yes
- continue
- ;;
-
- -Wc,*)
- args=`$echo "X$arg" | $Xsed -e "$sed_quote_subst" -e 's/^-Wc,//'`
- arg=
- save_ifs="$IFS"; IFS=','
- for flag in $args; do
- IFS="$save_ifs"
- case $flag in
- *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"")
- flag="\"$flag\""
- ;;
- esac
- arg="$arg $wl$flag"
- compiler_flags="$compiler_flags $flag"
- done
- IFS="$save_ifs"
- arg=`$echo "X$arg" | $Xsed -e "s/^ //"`
- ;;
-
- -Wl,*)
- args=`$echo "X$arg" | $Xsed -e "$sed_quote_subst" -e 's/^-Wl,//'`
- arg=
- save_ifs="$IFS"; IFS=','
- for flag in $args; do
- IFS="$save_ifs"
- case $flag in
- *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"")
- flag="\"$flag\""
- ;;
- esac
- arg="$arg $wl$flag"
- compiler_flags="$compiler_flags $wl$flag"
- linker_flags="$linker_flags $flag"
- done
- IFS="$save_ifs"
- arg=`$echo "X$arg" | $Xsed -e "s/^ //"`
- ;;
-
- -Xcompiler)
- prev=xcompiler
- continue
- ;;
-
- -Xlinker)
- prev=xlinker
- continue
- ;;
-
- -XCClinker)
- prev=xcclinker
- continue
- ;;
-
- # Some other compiler flag.
- -* | +*)
- # Unknown arguments in both finalize_command and compile_command need
- # to be aesthetically quoted because they are evaled later.
- arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"`
- case $arg in
- *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"")
- arg="\"$arg\""
- ;;
- esac
- ;;
-
- *.$objext)
- # A standard object.
- objs="$objs $arg"
- ;;
-
- *.lo)
- # A libtool-controlled object.
-
- # Check to see that this really is a libtool object.
- if (${SED} -e '2q' $arg | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then
- pic_object=
- non_pic_object=
-
- # Read the .lo file
- # If there is no directory component, then add one.
- case $arg in
- */* | *\\*) . $arg ;;
- *) . ./$arg ;;
- esac
-
- if test -z "$pic_object" || \
- test -z "$non_pic_object" ||
- test "$pic_object" = none && \
- test "$non_pic_object" = none; then
- $echo "$modename: cannot find name of object for \`$arg'" 1>&2
- exit $EXIT_FAILURE
- fi
-
- # Extract subdirectory from the argument.
- xdir=`$echo "X$arg" | $Xsed -e 's%/[^/]*$%%'`
- if test "X$xdir" = "X$arg"; then
- xdir=
- else
- xdir="$xdir/"
- fi
-
- if test "$pic_object" != none; then
- # Prepend the subdirectory the object is found in.
- pic_object="$xdir$pic_object"
-
- if test "$prev" = dlfiles; then
- if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then
- dlfiles="$dlfiles $pic_object"
- prev=
- continue
- else
- # If libtool objects are unsupported, then we need to preload.
- prev=dlprefiles
- fi
- fi
-
- # CHECK ME: I think I busted this. -Ossama
- if test "$prev" = dlprefiles; then
- # Preload the old-style object.
- dlprefiles="$dlprefiles $pic_object"
- prev=
- fi
-
- # A PIC object.
- libobjs="$libobjs $pic_object"
- arg="$pic_object"
- fi
-
- # Non-PIC object.
- if test "$non_pic_object" != none; then
- # Prepend the subdirectory the object is found in.
- non_pic_object="$xdir$non_pic_object"
-
- # A standard non-PIC object
- non_pic_objects="$non_pic_objects $non_pic_object"
- if test -z "$pic_object" || test "$pic_object" = none ; then
- arg="$non_pic_object"
- fi
- else
- # If the PIC object exists, use it instead.
- # $xdir was prepended to $pic_object above.
- non_pic_object="$pic_object"
- non_pic_objects="$non_pic_objects $non_pic_object"
- fi
- else
- # Only an error if not doing a dry-run.
- if test -z "$run"; then
- $echo "$modename: \`$arg' is not a valid libtool object" 1>&2
- exit $EXIT_FAILURE
- else
- # Dry-run case.
-
- # Extract subdirectory from the argument.
- xdir=`$echo "X$arg" | $Xsed -e 's%/[^/]*$%%'`
- if test "X$xdir" = "X$arg"; then
- xdir=
- else
- xdir="$xdir/"
- fi
-
- pic_object=`$echo "X${xdir}${objdir}/${arg}" | $Xsed -e "$lo2o"`
- non_pic_object=`$echo "X${xdir}${arg}" | $Xsed -e "$lo2o"`
- libobjs="$libobjs $pic_object"
- non_pic_objects="$non_pic_objects $non_pic_object"
- fi
- fi
- ;;
-
- *.$libext)
- # An archive.
- deplibs="$deplibs $arg"
- old_deplibs="$old_deplibs $arg"
- continue
- ;;
-
- *.la)
- # A libtool-controlled library.
-
- if test "$prev" = dlfiles; then
- # This library was specified with -dlopen.
- dlfiles="$dlfiles $arg"
- prev=
- elif test "$prev" = dlprefiles; then
- # The library was specified with -dlpreopen.
- dlprefiles="$dlprefiles $arg"
- prev=
- else
- deplibs="$deplibs $arg"
- fi
- continue
- ;;
-
- # Some other compiler argument.
- *)
- # Unknown arguments in both finalize_command and compile_command need
- # to be aesthetically quoted because they are evaled later.
- arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"`
- case $arg in
- *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"")
- arg="\"$arg\""
- ;;
- esac
- ;;
- esac # arg
-
- # Now actually substitute the argument into the commands.
- if test -n "$arg"; then
- compile_command="$compile_command $arg"
- finalize_command="$finalize_command $arg"
- fi
- done # argument parsing loop
-
- if test -n "$prev"; then
- $echo "$modename: the \`$prevarg' option requires an argument" 1>&2
- $echo "$help" 1>&2
- exit $EXIT_FAILURE
- fi
-
- if test "$export_dynamic" = yes && test -n "$export_dynamic_flag_spec"; then
- eval arg=\"$export_dynamic_flag_spec\"
- compile_command="$compile_command $arg"
- finalize_command="$finalize_command $arg"
- fi
-
- oldlibs=
- # calculate the name of the file, without its directory
- outputname=`$echo "X$output" | $Xsed -e 's%^.*/%%'`
- libobjs_save="$libobjs"
-
- if test -n "$shlibpath_var"; then
- # get the directories listed in $shlibpath_var
- eval shlib_search_path=\`\$echo \"X\${$shlibpath_var}\" \| \$Xsed -e \'s/:/ /g\'\`
- else
- shlib_search_path=
- fi
- eval sys_lib_search_path=\"$sys_lib_search_path_spec\"
- eval sys_lib_dlsearch_path=\"$sys_lib_dlsearch_path_spec\"
-
- output_objdir=`$echo "X$output" | $Xsed -e 's%/[^/]*$%%'`
- if test "X$output_objdir" = "X$output"; then
- output_objdir="$objdir"
- else
- output_objdir="$output_objdir/$objdir"
- fi
- # Create the object directory.
- if test ! -d "$output_objdir"; then
- $show "$mkdir $output_objdir"
- $run $mkdir $output_objdir
- exit_status=$?
- if test "$exit_status" -ne 0 && test ! -d "$output_objdir"; then
- exit $exit_status
- fi
- fi
-
- # Determine the type of output
- case $output in
- "")
- $echo "$modename: you must specify an output file" 1>&2
- $echo "$help" 1>&2
- exit $EXIT_FAILURE
- ;;
- *.$libext) linkmode=oldlib ;;
- *.lo | *.$objext) linkmode=obj ;;
- *.la) linkmode=lib ;;
- *) linkmode=prog ;; # Anything else should be a program.
- esac
-
- case $host in
- *cygwin* | *mingw* | *pw32*)
- # don't eliminate duplications in $postdeps and $predeps
- duplicate_compiler_generated_deps=yes
- ;;
- *)
- duplicate_compiler_generated_deps=$duplicate_deps
- ;;
- esac
- specialdeplibs=
-
- libs=
- # Find all interdependent deplibs by searching for libraries
- # that are linked more than once (e.g. -la -lb -la)
- for deplib in $deplibs; do
- if test "X$duplicate_deps" = "Xyes" ; then
- case "$libs " in
- *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;;
- esac
- fi
- libs="$libs $deplib"
- done
-
- if test "$linkmode" = lib; then
- libs="$predeps $libs $compiler_lib_search_path $postdeps"
-
- # Compute libraries that are listed more than once in $predeps
- # $postdeps and mark them as special (i.e., whose duplicates are
- # not to be eliminated).
- pre_post_deps=
- if test "X$duplicate_compiler_generated_deps" = "Xyes" ; then
- for pre_post_dep in $predeps $postdeps; do
- case "$pre_post_deps " in
- *" $pre_post_dep "*) specialdeplibs="$specialdeplibs $pre_post_deps" ;;
- esac
- pre_post_deps="$pre_post_deps $pre_post_dep"
- done
- fi
- pre_post_deps=
- fi
-
- deplibs=
- newdependency_libs=
- newlib_search_path=
- need_relink=no # whether we're linking any uninstalled libtool libraries
- notinst_deplibs= # not-installed libtool libraries
- case $linkmode in
- lib)
- passes="conv link"
- for file in $dlfiles $dlprefiles; do
- case $file in
- *.la) ;;
- *)
- $echo "$modename: libraries can \`-dlopen' only libtool libraries: $file" 1>&2
- exit $EXIT_FAILURE
- ;;
- esac
- done
- ;;
- prog)
- compile_deplibs=
- finalize_deplibs=
- alldeplibs=no
- newdlfiles=
- newdlprefiles=
- passes="conv scan dlopen dlpreopen link"
- ;;
- *) passes="conv"
- ;;
- esac
- for pass in $passes; do
- if test "$linkmode,$pass" = "lib,link" ||
- test "$linkmode,$pass" = "prog,scan"; then
- libs="$deplibs"
- deplibs=
- fi
- if test "$linkmode" = prog; then
- case $pass in
- dlopen) libs="$dlfiles" ;;
- dlpreopen) libs="$dlprefiles" ;;
- link)
- libs="$deplibs %DEPLIBS%"
- test "X$link_all_deplibs" != Xno && libs="$libs $dependency_libs"
- ;;
- esac
- fi
- if test "$pass" = dlopen; then
- # Collect dlpreopened libraries
- save_deplibs="$deplibs"
- deplibs=
- fi
- for deplib in $libs; do
- lib=
- found=no
- case $deplib in
- -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe)
- if test "$linkmode,$pass" = "prog,link"; then
- compile_deplibs="$deplib $compile_deplibs"
- finalize_deplibs="$deplib $finalize_deplibs"
- else
- compiler_flags="$compiler_flags $deplib"
- fi
- continue
- ;;
- -l*)
- if test "$linkmode" != lib && test "$linkmode" != prog; then
- $echo "$modename: warning: \`-l' is ignored for archives/objects" 1>&2
- continue
- fi
- name=`$echo "X$deplib" | $Xsed -e 's/^-l//'`
- for searchdir in $newlib_search_path $lib_search_path $sys_lib_search_path $shlib_search_path; do
- for search_ext in .la $std_shrext .so .a; do
- # Search the libtool library
- lib="$searchdir/lib${name}${search_ext}"
- if test -f "$lib"; then
- if test "$search_ext" = ".la"; then
- found=yes
- else
- found=no
- fi
- break 2
- fi
- done
- done
- if test "$found" != yes; then
- # deplib doesn't seem to be a libtool library
- if test "$linkmode,$pass" = "prog,link"; then
- compile_deplibs="$deplib $compile_deplibs"
- finalize_deplibs="$deplib $finalize_deplibs"
- else
- deplibs="$deplib $deplibs"
- test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs"
- fi
- continue
- else # deplib is a libtool library
- # If $allow_libtool_libs_with_static_runtimes && $deplib is a stdlib,
- # We need to do some special things here, and not later.
- if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
- case " $predeps $postdeps " in
- *" $deplib "*)
- if (${SED} -e '2q' $lib |
- grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then
- library_names=
- old_library=
- case $lib in
- */* | *\\*) . $lib ;;
- *) . ./$lib ;;
- esac
- for l in $old_library $library_names; do
- ll="$l"
- done
- if test "X$ll" = "X$old_library" ; then # only static version available
- found=no
- ladir=`$echo "X$lib" | $Xsed -e 's%/[^/]*$%%'`
- test "X$ladir" = "X$lib" && ladir="."
- lib=$ladir/$old_library
- if test "$linkmode,$pass" = "prog,link"; then
- compile_deplibs="$deplib $compile_deplibs"
- finalize_deplibs="$deplib $finalize_deplibs"
- else
- deplibs="$deplib $deplibs"
- test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs"
- fi
- continue
- fi
- fi
- ;;
- *) ;;
- esac
- fi
- fi
- ;; # -l
- -L*)
- case $linkmode in
- lib)
- deplibs="$deplib $deplibs"
- test "$pass" = conv && continue
- newdependency_libs="$deplib $newdependency_libs"
- newlib_search_path="$newlib_search_path "`$echo "X$deplib" | $Xsed -e 's/^-L//'`
- ;;
- prog)
- if test "$pass" = conv; then
- deplibs="$deplib $deplibs"
- continue
- fi
- if test "$pass" = scan; then
- deplibs="$deplib $deplibs"
- else
- compile_deplibs="$deplib $compile_deplibs"
- finalize_deplibs="$deplib $finalize_deplibs"
- fi
- newlib_search_path="$newlib_search_path "`$echo "X$deplib" | $Xsed -e 's/^-L//'`
- ;;
- *)
- $echo "$modename: warning: \`-L' is ignored for archives/objects" 1>&2
- ;;
- esac # linkmode
- continue
- ;; # -L
- -R*)
- if test "$pass" = link; then
- dir=`$echo "X$deplib" | $Xsed -e 's/^-R//'`
- # Make sure the xrpath contains only unique directories.
- case "$xrpath " in
- *" $dir "*) ;;
- *) xrpath="$xrpath $dir" ;;
- esac
- fi
- deplibs="$deplib $deplibs"
- continue
- ;;
- *.la) lib="$deplib" ;;
- *.$libext)
- if test "$pass" = conv; then
- deplibs="$deplib $deplibs"
- continue
- fi
- case $linkmode in
- lib)
- valid_a_lib=no
- case $deplibs_check_method in
- match_pattern*)
- set dummy $deplibs_check_method
- match_pattern_regex=`expr "$deplibs_check_method" : "$2 \(.*\)"`
- if eval $echo \"$deplib\" 2>/dev/null \
- | $SED 10q \
- | $EGREP "$match_pattern_regex" > /dev/null; then
- valid_a_lib=yes
- fi
- ;;
- pass_all)
- valid_a_lib=yes
- ;;
- esac
- if test "$valid_a_lib" != yes; then
- $echo
- $echo "*** Warning: Trying to link with static lib archive $deplib."
- $echo "*** I have the capability to make that library automatically link in when"
- $echo "*** you link to this library. But I can only do this if you have a"
- $echo "*** shared version of the library, which you do not appear to have"
- $echo "*** because the file extensions .$libext of this argument makes me believe"
- $echo "*** that it is just a static archive that I should not used here."
- else
- $echo
- $echo "*** Warning: Linking the shared library $output against the"
- $echo "*** static library $deplib is not portable!"
- deplibs="$deplib $deplibs"
- fi
- continue
- ;;
- prog)
- if test "$pass" != link; then
- deplibs="$deplib $deplibs"
- else
- compile_deplibs="$deplib $compile_deplibs"
- finalize_deplibs="$deplib $finalize_deplibs"
- fi
- continue
- ;;
- esac # linkmode
- ;; # *.$libext
- *.lo | *.$objext)
- if test "$pass" = conv; then
- deplibs="$deplib $deplibs"
- elif test "$linkmode" = prog; then
- if test "$pass" = dlpreopen || test "$dlopen_support" != yes || test "$build_libtool_libs" = no; then
- # If there is no dlopen support or we're linking statically,
- # we need to preload.
- newdlprefiles="$newdlprefiles $deplib"
- compile_deplibs="$deplib $compile_deplibs"
- finalize_deplibs="$deplib $finalize_deplibs"
- else
- newdlfiles="$newdlfiles $deplib"
- fi
- fi
- continue
- ;;
- %DEPLIBS%)
- alldeplibs=yes
- continue
- ;;
- esac # case $deplib
- if test "$found" = yes || test -f "$lib"; then :
- else
- $echo "$modename: cannot find the library \`$lib' or unhandled argument \`$deplib'" 1>&2
- exit $EXIT_FAILURE
- fi
-
- # Check to see that this really is a libtool archive.
- if (${SED} -e '2q' $lib | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then :
- else
- $echo "$modename: \`$lib' is not a valid libtool archive" 1>&2
- exit $EXIT_FAILURE
- fi
-
- ladir=`$echo "X$lib" | $Xsed -e 's%/[^/]*$%%'`
- test "X$ladir" = "X$lib" && ladir="."
-
- dlname=
- dlopen=
- dlpreopen=
- libdir=
- library_names=
- old_library=
- # If the library was installed with an old release of libtool,
- # it will not redefine variables installed, or shouldnotlink
- installed=yes
- shouldnotlink=no
- avoidtemprpath=
-
-
- # Read the .la file
- case $lib in
- */* | *\\*) . $lib ;;
- *) . ./$lib ;;
- esac
-
- if test "$linkmode,$pass" = "lib,link" ||
- test "$linkmode,$pass" = "prog,scan" ||
- { test "$linkmode" != prog && test "$linkmode" != lib; }; then
- test -n "$dlopen" && dlfiles="$dlfiles $dlopen"
- test -n "$dlpreopen" && dlprefiles="$dlprefiles $dlpreopen"
- fi
-
- if test "$pass" = conv; then
- # Only check for convenience libraries
- deplibs="$lib $deplibs"
- if test -z "$libdir"; then
- if test -z "$old_library"; then
- $echo "$modename: cannot find name of link library for \`$lib'" 1>&2
- exit $EXIT_FAILURE
- fi
- # It is a libtool convenience library, so add in its objects.
- convenience="$convenience $ladir/$objdir/$old_library"
- old_convenience="$old_convenience $ladir/$objdir/$old_library"
- tmp_libs=
- for deplib in $dependency_libs; do
- deplibs="$deplib $deplibs"
- if test "X$duplicate_deps" = "Xyes" ; then
- case "$tmp_libs " in
- *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;;
- esac
- fi
- tmp_libs="$tmp_libs $deplib"
- done
- elif test "$linkmode" != prog && test "$linkmode" != lib; then
- $echo "$modename: \`$lib' is not a convenience library" 1>&2
- exit $EXIT_FAILURE
- fi
- continue
- fi # $pass = conv
-
-
- # Get the name of the library we link against.
- linklib=
- for l in $old_library $library_names; do
- linklib="$l"
- done
- if test -z "$linklib"; then
- $echo "$modename: cannot find name of link library for \`$lib'" 1>&2
- exit $EXIT_FAILURE
- fi
-
- # This library was specified with -dlopen.
- if test "$pass" = dlopen; then
- if test -z "$libdir"; then
- $echo "$modename: cannot -dlopen a convenience library: \`$lib'" 1>&2
- exit $EXIT_FAILURE
- fi
- if test -z "$dlname" ||
- test "$dlopen_support" != yes ||
- test "$build_libtool_libs" = no; then
- # If there is no dlname, no dlopen support or we're linking
- # statically, we need to preload. We also need to preload any
- # dependent libraries so libltdl's deplib preloader doesn't
- # bomb out in the load deplibs phase.
- dlprefiles="$dlprefiles $lib $dependency_libs"
- else
- newdlfiles="$newdlfiles $lib"
- fi
- continue
- fi # $pass = dlopen
-
- # We need an absolute path.
- case $ladir in
- [\\/]* | [A-Za-z]:[\\/]*) abs_ladir="$ladir" ;;
- *)
- abs_ladir=`cd "$ladir" && pwd`
- if test -z "$abs_ladir"; then
- $echo "$modename: warning: cannot determine absolute directory name of \`$ladir'" 1>&2
- $echo "$modename: passing it literally to the linker, although it might fail" 1>&2
- abs_ladir="$ladir"
- fi
- ;;
- esac
- laname=`$echo "X$lib" | $Xsed -e 's%^.*/%%'`
-
- # Find the relevant object directory and library name.
- if test "X$installed" = Xyes; then
- if test ! -f "$libdir/$linklib" && test -f "$abs_ladir/$linklib"; then
- $echo "$modename: warning: library \`$lib' was moved." 1>&2
- dir="$ladir"
- absdir="$abs_ladir"
- libdir="$abs_ladir"
- else
- dir="$libdir"
- absdir="$libdir"
- fi
- test "X$hardcode_automatic" = Xyes && avoidtemprpath=yes
- else
- if test ! -f "$ladir/$objdir/$linklib" && test -f "$abs_ladir/$linklib"; then
- dir="$ladir"
- absdir="$abs_ladir"
- # Remove this search path later
- notinst_path="$notinst_path $abs_ladir"
- else
- dir="$ladir/$objdir"
- absdir="$abs_ladir/$objdir"
- # Remove this search path later
- notinst_path="$notinst_path $abs_ladir"
- fi
- fi # $installed = yes
- name=`$echo "X$laname" | $Xsed -e 's/\.la$//' -e 's/^lib//'`
-
- # This library was specified with -dlpreopen.
- if test "$pass" = dlpreopen; then
- if test -z "$libdir"; then
- $echo "$modename: cannot -dlpreopen a convenience library: \`$lib'" 1>&2
- exit $EXIT_FAILURE
- fi
- # Prefer using a static library (so that no silly _DYNAMIC symbols
- # are required to link).
- if test -n "$old_library"; then
- newdlprefiles="$newdlprefiles $dir/$old_library"
- # Otherwise, use the dlname, so that lt_dlopen finds it.
- elif test -n "$dlname"; then
- newdlprefiles="$newdlprefiles $dir/$dlname"
- else
- newdlprefiles="$newdlprefiles $dir/$linklib"
- fi
- fi # $pass = dlpreopen
-
- if test -z "$libdir"; then
- # Link the convenience library
- if test "$linkmode" = lib; then
- deplibs="$dir/$old_library $deplibs"
- elif test "$linkmode,$pass" = "prog,link"; then
- compile_deplibs="$dir/$old_library $compile_deplibs"
- finalize_deplibs="$dir/$old_library $finalize_deplibs"
- else
- deplibs="$lib $deplibs" # used for prog,scan pass
- fi
- continue
- fi
-
-
- if test "$linkmode" = prog && test "$pass" != link; then
- newlib_search_path="$newlib_search_path $ladir"
- deplibs="$lib $deplibs"
-
- linkalldeplibs=no
- if test "$link_all_deplibs" != no || test -z "$library_names" ||
- test "$build_libtool_libs" = no; then
- linkalldeplibs=yes
- fi
-
- tmp_libs=
- for deplib in $dependency_libs; do
- case $deplib in
- -L*) newlib_search_path="$newlib_search_path "`$echo "X$deplib" | $Xsed -e 's/^-L//'`;; ### testsuite: skip nested quoting test
- esac
- # Need to link against all dependency_libs?
- if test "$linkalldeplibs" = yes; then
- deplibs="$deplib $deplibs"
- else
- # Need to hardcode shared library paths
- # or/and link against static libraries
- newdependency_libs="$deplib $newdependency_libs"
- fi
- if test "X$duplicate_deps" = "Xyes" ; then
- case "$tmp_libs " in
- *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;;
- esac
- fi
- tmp_libs="$tmp_libs $deplib"
- done # for deplib
- continue
- fi # $linkmode = prog...
-
- if test "$linkmode,$pass" = "prog,link"; then
- if test -n "$library_names" &&
- { test "$prefer_static_libs" = no || test -z "$old_library"; }; then
- # We need to hardcode the library path
- if test -n "$shlibpath_var" && test -z "$avoidtemprpath" ; then
- # Make sure the rpath contains only unique directories.
- case "$temp_rpath " in
- *" $dir "*) ;;
- *" $absdir "*) ;;
- *) temp_rpath="$temp_rpath $absdir" ;;
- esac
- fi
-
- # Hardcode the library path.
- # Skip directories that are in the system default run-time
- # search path.
- case " $sys_lib_dlsearch_path " in
- *" $absdir "*) ;;
- *)
- case "$compile_rpath " in
- *" $absdir "*) ;;
- *) compile_rpath="$compile_rpath $absdir"
- esac
- ;;
- esac
- case " $sys_lib_dlsearch_path " in
- *" $libdir "*) ;;
- *)
- case "$finalize_rpath " in
- *" $libdir "*) ;;
- *) finalize_rpath="$finalize_rpath $libdir"
- esac
- ;;
- esac
- fi # $linkmode,$pass = prog,link...
-
- if test "$alldeplibs" = yes &&
- { test "$deplibs_check_method" = pass_all ||
- { test "$build_libtool_libs" = yes &&
- test -n "$library_names"; }; }; then
- # We only need to search for static libraries
- continue
- fi
- fi
-
- link_static=no # Whether the deplib will be linked statically
- use_static_libs=$prefer_static_libs
- if test "$use_static_libs" = built && test "$installed" = yes ; then
- use_static_libs=no
- fi
- if test -n "$library_names" &&
- { test "$use_static_libs" = no || test -z "$old_library"; }; then
- if test "$installed" = no; then
- notinst_deplibs="$notinst_deplibs $lib"
- need_relink=yes
- fi
- # This is a shared library
-
- # Warn about portability, can't link against -module's on
- # some systems (darwin)
- if test "$shouldnotlink" = yes && test "$pass" = link ; then
- $echo
- if test "$linkmode" = prog; then
- $echo "*** Warning: Linking the executable $output against the loadable module"
- else
- $echo "*** Warning: Linking the shared library $output against the loadable module"
- fi
- $echo "*** $linklib is not portable!"
- fi
- if test "$linkmode" = lib &&
- test "$hardcode_into_libs" = yes; then
- # Hardcode the library path.
- # Skip directories that are in the system default run-time
- # search path.
- case " $sys_lib_dlsearch_path " in
- *" $absdir "*) ;;
- *)
- case "$compile_rpath " in
- *" $absdir "*) ;;
- *) compile_rpath="$compile_rpath $absdir"
- esac
- ;;
- esac
- case " $sys_lib_dlsearch_path " in
- *" $libdir "*) ;;
- *)
- case "$finalize_rpath " in
- *" $libdir "*) ;;
- *) finalize_rpath="$finalize_rpath $libdir"
- esac
- ;;
- esac
- fi
-
- if test -n "$old_archive_from_expsyms_cmds"; then
- # figure out the soname
- set dummy $library_names
- realname="$2"
- shift; shift
- libname=`eval \\$echo \"$libname_spec\"`
- # use dlname if we got it. it's perfectly good, no?
- if test -n "$dlname"; then
- soname="$dlname"
- elif test -n "$soname_spec"; then
- # bleh windows
- case $host in
- *cygwin* | mingw*)
- major=`expr $current - $age`
- versuffix="-$major"
- ;;
- esac
- eval soname=\"$soname_spec\"
- else
- soname="$realname"
- fi
-
- # Make a new name for the extract_expsyms_cmds to use
- soroot="$soname"
- soname=`$echo $soroot | ${SED} -e 's/^.*\///'`
- newlib="libimp-`$echo $soname | ${SED} 's/^lib//;s/\.dll$//'`.a"
-
- # If the library has no export list, then create one now
- if test -f "$output_objdir/$soname-def"; then :
- else
- $show "extracting exported symbol list from \`$soname'"
- save_ifs="$IFS"; IFS='~'
- cmds=$extract_expsyms_cmds
- for cmd in $cmds; do
- IFS="$save_ifs"
- eval cmd=\"$cmd\"
- $show "$cmd"
- $run eval "$cmd" || exit $?
- done
- IFS="$save_ifs"
- fi
-
- # Create $newlib
- if test -f "$output_objdir/$newlib"; then :; else
- $show "generating import library for \`$soname'"
- save_ifs="$IFS"; IFS='~'
- cmds=$old_archive_from_expsyms_cmds
- for cmd in $cmds; do
- IFS="$save_ifs"
- eval cmd=\"$cmd\"
- $show "$cmd"
- $run eval "$cmd" || exit $?
- done
- IFS="$save_ifs"
- fi
- # make sure the library variables are pointing to the new library
- dir=$output_objdir
- linklib=$newlib
- fi # test -n "$old_archive_from_expsyms_cmds"
-
- if test "$linkmode" = prog || test "$mode" != relink; then
- add_shlibpath=
- add_dir=
- add=
- lib_linked=yes
- case $hardcode_action in
- immediate | unsupported)
- if test "$hardcode_direct" = no; then
- add="$dir/$linklib"
- case $host in
- *-*-sco3.2v5.0.[024]*) add_dir="-L$dir" ;;
- *-*-sysv4*uw2*) add_dir="-L$dir" ;;
- *-*-sysv5OpenUNIX* | *-*-sysv5UnixWare7.[01].[10]* | \
- *-*-unixware7*) add_dir="-L$dir" ;;
- *-*-darwin* )
- # if the lib is a module then we can not link against
- # it, someone is ignoring the new warnings I added
- if /usr/bin/file -L $add 2> /dev/null |
- $EGREP ": [^:]* bundle" >/dev/null ; then
- $echo "** Warning, lib $linklib is a module, not a shared library"
- if test -z "$old_library" ; then
- $echo
- $echo "** And there doesn't seem to be a static archive available"
- $echo "** The link will probably fail, sorry"
- else
- add="$dir/$old_library"
- fi
- fi
- esac
- elif test "$hardcode_minus_L" = no; then
- case $host in
- *-*-sunos*) add_shlibpath="$dir" ;;
- esac
- add_dir="-L$dir"
- add="-l$name"
- elif test "$hardcode_shlibpath_var" = no; then
- add_shlibpath="$dir"
- add="-l$name"
- else
- lib_linked=no
- fi
- ;;
- relink)
- if test "$hardcode_direct" = yes; then
- add="$dir/$linklib"
- elif test "$hardcode_minus_L" = yes; then
- add_dir="-L$dir"
- # Try looking first in the location we're being installed to.
- if test -n "$inst_prefix_dir"; then
- case $libdir in
- [\\/]*)
- add_dir="$add_dir -L$inst_prefix_dir$libdir"
- ;;
- esac
- fi
- add="-l$name"
- elif test "$hardcode_shlibpath_var" = yes; then
- add_shlibpath="$dir"
- add="-l$name"
- else
- lib_linked=no
- fi
- ;;
- *) lib_linked=no ;;
- esac
-
- if test "$lib_linked" != yes; then
- $echo "$modename: configuration error: unsupported hardcode properties"
- exit $EXIT_FAILURE
- fi
-
- if test -n "$add_shlibpath"; then
- case :$compile_shlibpath: in
- *":$add_shlibpath:"*) ;;
- *) compile_shlibpath="$compile_shlibpath$add_shlibpath:" ;;
- esac
- fi
- if test "$linkmode" = prog; then
- test -n "$add_dir" && compile_deplibs="$add_dir $compile_deplibs"
- test -n "$add" && compile_deplibs="$add $compile_deplibs"
- else
- test -n "$add_dir" && deplibs="$add_dir $deplibs"
- test -n "$add" && deplibs="$add $deplibs"
- if test "$hardcode_direct" != yes && \
- test "$hardcode_minus_L" != yes && \
- test "$hardcode_shlibpath_var" = yes; then
- case :$finalize_shlibpath: in
- *":$libdir:"*) ;;
- *) finalize_shlibpath="$finalize_shlibpath$libdir:" ;;
- esac
- fi
- fi
- fi
-
- if test "$linkmode" = prog || test "$mode" = relink; then
- add_shlibpath=
- add_dir=
- add=
- # Finalize command for both is simple: just hardcode it.
- if test "$hardcode_direct" = yes; then
- add="$libdir/$linklib"
- elif test "$hardcode_minus_L" = yes; then
- add_dir="-L$libdir"
- add="-l$name"
- elif test "$hardcode_shlibpath_var" = yes; then
- case :$finalize_shlibpath: in
- *":$libdir:"*) ;;
- *) finalize_shlibpath="$finalize_shlibpath$libdir:" ;;
- esac
- add="-l$name"
- elif test "$hardcode_automatic" = yes; then
- if test -n "$inst_prefix_dir" &&
- test -f "$inst_prefix_dir$libdir/$linklib" ; then
- add="$inst_prefix_dir$libdir/$linklib"
- else
- add="$libdir/$linklib"
- fi
- else
- # We cannot seem to hardcode it, guess we'll fake it.
- add_dir="-L$libdir"
- # Try looking first in the location we're being installed to.
- if test -n "$inst_prefix_dir"; then
- case $libdir in
- [\\/]*)
- add_dir="$add_dir -L$inst_prefix_dir$libdir"
- ;;
- esac
- fi
- add="-l$name"
- fi
-
- if test "$linkmode" = prog; then
- test -n "$add_dir" && finalize_deplibs="$add_dir $finalize_deplibs"
- test -n "$add" && finalize_deplibs="$add $finalize_deplibs"
- else
- test -n "$add_dir" && deplibs="$add_dir $deplibs"
- test -n "$add" && deplibs="$add $deplibs"
- fi
- fi
- elif test "$linkmode" = prog; then
- # Here we assume that one of hardcode_direct or hardcode_minus_L
- # is not unsupported. This is valid on all known static and
- # shared platforms.
- if test "$hardcode_direct" != unsupported; then
- test -n "$old_library" && linklib="$old_library"
- compile_deplibs="$dir/$linklib $compile_deplibs"
- finalize_deplibs="$dir/$linklib $finalize_deplibs"
- else
- compile_deplibs="-l$name -L$dir $compile_deplibs"
- finalize_deplibs="-l$name -L$dir $finalize_deplibs"
- fi
- elif test "$build_libtool_libs" = yes; then
- # Not a shared library
- if test "$deplibs_check_method" != pass_all; then
- # We're trying link a shared library against a static one
- # but the system doesn't support it.
-
- # Just print a warning and add the library to dependency_libs so
- # that the program can be linked against the static library.
- $echo
- $echo "*** Warning: This system can not link to static lib archive $lib."
- $echo "*** I have the capability to make that library automatically link in when"
- $echo "*** you link to this library. But I can only do this if you have a"
- $echo "*** shared version of the library, which you do not appear to have."
- if test "$module" = yes; then
- $echo "*** But as you try to build a module library, libtool will still create "
- $echo "*** a static module, that should work as long as the dlopening application"
- $echo "*** is linked with the -dlopen flag to resolve symbols at runtime."
- if test -z "$global_symbol_pipe"; then
- $echo
- $echo "*** However, this would only work if libtool was able to extract symbol"
- $echo "*** lists from a program, using \`nm' or equivalent, but libtool could"
- $echo "*** not find such a program. So, this module is probably useless."
- $echo "*** \`nm' from GNU binutils and a full rebuild may help."
- fi
- if test "$build_old_libs" = no; then
- build_libtool_libs=module
- build_old_libs=yes
- else
- build_libtool_libs=no
- fi
- fi
- else
- deplibs="$dir/$old_library $deplibs"
- link_static=yes
- fi
- fi # link shared/static library?
-
- if test "$linkmode" = lib; then
- if test -n "$dependency_libs" &&
- { test "$hardcode_into_libs" != yes ||
- test "$build_old_libs" = yes ||
- test "$link_static" = yes; }; then
- # Extract -R from dependency_libs
- temp_deplibs=
- for libdir in $dependency_libs; do
- case $libdir in
- -R*) temp_xrpath=`$echo "X$libdir" | $Xsed -e 's/^-R//'`
- case " $xrpath " in
- *" $temp_xrpath "*) ;;
- *) xrpath="$xrpath $temp_xrpath";;
- esac;;
- *) temp_deplibs="$temp_deplibs $libdir";;
- esac
- done
- dependency_libs="$temp_deplibs"
- fi
-
- newlib_search_path="$newlib_search_path $absdir"
- # Link against this library
- test "$link_static" = no && newdependency_libs="$abs_ladir/$laname $newdependency_libs"
- # ... and its dependency_libs
- tmp_libs=
- for deplib in $dependency_libs; do
- newdependency_libs="$deplib $newdependency_libs"
- if test "X$duplicate_deps" = "Xyes" ; then
- case "$tmp_libs " in
- *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;;
- esac
- fi
- tmp_libs="$tmp_libs $deplib"
- done
-
- if test "$link_all_deplibs" != no; then
- # Add the search paths of all dependency libraries
- for deplib in $dependency_libs; do
- case $deplib in
- -L*) path="$deplib" ;;
- *.la)
- dir=`$echo "X$deplib" | $Xsed -e 's%/[^/]*$%%'`
- test "X$dir" = "X$deplib" && dir="."
- # We need an absolute path.
- case $dir in
- [\\/]* | [A-Za-z]:[\\/]*) absdir="$dir" ;;
- *)
- absdir=`cd "$dir" && pwd`
- if test -z "$absdir"; then
- $echo "$modename: warning: cannot determine absolute directory name of \`$dir'" 1>&2
- absdir="$dir"
- fi
- ;;
- esac
- if grep "^installed=no" $deplib > /dev/null; then
- path="$absdir/$objdir"
- else
- eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib`
- if test -z "$libdir"; then
- $echo "$modename: \`$deplib' is not a valid libtool archive" 1>&2
- exit $EXIT_FAILURE
- fi
- if test "$absdir" != "$libdir"; then
- $echo "$modename: warning: \`$deplib' seems to be moved" 1>&2
- fi
- path="$absdir"
- fi
- depdepl=
- case $host in
- *-*-darwin*)
- # we do not want to link against static libs,
- # but need to link against shared
- eval deplibrary_names=`${SED} -n -e 's/^library_names=\(.*\)$/\1/p' $deplib`
- if test -n "$deplibrary_names" ; then
- for tmp in $deplibrary_names ; do
- depdepl=$tmp
- done
- if test -f "$path/$depdepl" ; then
- depdepl="$path/$depdepl"
- fi
- # do not add paths which are already there
- case " $newlib_search_path " in
- *" $path "*) ;;
- *) newlib_search_path="$newlib_search_path $path";;
- esac
- fi
- path=""
- ;;
- *)
- path="-L$path"
- ;;
- esac
- ;;
- -l*)
- case $host in
- *-*-darwin*)
- # Again, we only want to link against shared libraries
- eval tmp_libs=`$echo "X$deplib" | $Xsed -e "s,^\-l,,"`
- for tmp in $newlib_search_path ; do
- if test -f "$tmp/lib$tmp_libs.dylib" ; then
- eval depdepl="$tmp/lib$tmp_libs.dylib"
- break
- fi
- done
- path=""
- ;;
- *) continue ;;
- esac
- ;;
- *) continue ;;
- esac
- case " $deplibs " in
- *" $path "*) ;;
- *) deplibs="$path $deplibs" ;;
- esac
- case " $deplibs " in
- *" $depdepl "*) ;;
- *) deplibs="$depdepl $deplibs" ;;
- esac
- done
- fi # link_all_deplibs != no
- fi # linkmode = lib
- done # for deplib in $libs
- dependency_libs="$newdependency_libs"
- if test "$pass" = dlpreopen; then
- # Link the dlpreopened libraries before other libraries
- for deplib in $save_deplibs; do
- deplibs="$deplib $deplibs"
- done
- fi
- if test "$pass" != dlopen; then
- if test "$pass" != conv; then
- # Make sure lib_search_path contains only unique directories.
- lib_search_path=
- for dir in $newlib_search_path; do
- case "$lib_search_path " in
- *" $dir "*) ;;
- *) lib_search_path="$lib_search_path $dir" ;;
- esac
- done
- newlib_search_path=
- fi
-
- if test "$linkmode,$pass" != "prog,link"; then
- vars="deplibs"
- else
- vars="compile_deplibs finalize_deplibs"
- fi
- for var in $vars dependency_libs; do
- # Add libraries to $var in reverse order
- eval tmp_libs=\"\$$var\"
- new_libs=
- for deplib in $tmp_libs; do
- # FIXME: Pedantically, this is the right thing to do, so
- # that some nasty dependency loop isn't accidentally
- # broken:
- #new_libs="$deplib $new_libs"
- # Pragmatically, this seems to cause very few problems in
- # practice:
- case $deplib in
- -L*) new_libs="$deplib $new_libs" ;;
- -R*) ;;
- *)
- # And here is the reason: when a library appears more
- # than once as an explicit dependence of a library, or
- # is implicitly linked in more than once by the
- # compiler, it is considered special, and multiple
- # occurrences thereof are not removed. Compare this
- # with having the same library being listed as a
- # dependency of multiple other libraries: in this case,
- # we know (pedantically, we assume) the library does not
- # need to be listed more than once, so we keep only the
- # last copy. This is not always right, but it is rare
- # enough that we require users that really mean to play
- # such unportable linking tricks to link the library
- # using -Wl,-lname, so that libtool does not consider it
- # for duplicate removal.
- case " $specialdeplibs " in
- *" $deplib "*) new_libs="$deplib $new_libs" ;;
- *)
- case " $new_libs " in
- *" $deplib "*) ;;
- *) new_libs="$deplib $new_libs" ;;
- esac
- ;;
- esac
- ;;
- esac
- done
- tmp_libs=
- for deplib in $new_libs; do
- case $deplib in
- -L*)
- case " $tmp_libs " in
- *" $deplib "*) ;;
- *) tmp_libs="$tmp_libs $deplib" ;;
- esac
- ;;
- *) tmp_libs="$tmp_libs $deplib" ;;
- esac
- done
- eval $var=\"$tmp_libs\"
- done # for var
- fi
- # Last step: remove runtime libs from dependency_libs
- # (they stay in deplibs)
- tmp_libs=
- for i in $dependency_libs ; do
- case " $predeps $postdeps $compiler_lib_search_path " in
- *" $i "*)
- i=""
- ;;
- esac
- if test -n "$i" ; then
- tmp_libs="$tmp_libs $i"
- fi
- done
- dependency_libs=$tmp_libs
- done # for pass
- if test "$linkmode" = prog; then
- dlfiles="$newdlfiles"
- dlprefiles="$newdlprefiles"
- fi
-
- case $linkmode in
- oldlib)
- if test -n "$deplibs"; then
- $echo "$modename: warning: \`-l' and \`-L' are ignored for archives" 1>&2
- fi
-
- if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
- $echo "$modename: warning: \`-dlopen' is ignored for archives" 1>&2
- fi
-
- if test -n "$rpath"; then
- $echo "$modename: warning: \`-rpath' is ignored for archives" 1>&2
- fi
-
- if test -n "$xrpath"; then
- $echo "$modename: warning: \`-R' is ignored for archives" 1>&2
- fi
-
- if test -n "$vinfo"; then
- $echo "$modename: warning: \`-version-info/-version-number' is ignored for archives" 1>&2
- fi
-
- if test -n "$release"; then
- $echo "$modename: warning: \`-release' is ignored for archives" 1>&2
- fi
-
- if test -n "$export_symbols" || test -n "$export_symbols_regex"; then
- $echo "$modename: warning: \`-export-symbols' is ignored for archives" 1>&2
- fi
-
- # Now set the variables for building old libraries.
- build_libtool_libs=no
- oldlibs="$output"
- objs="$objs$old_deplibs"
- ;;
-
- lib)
- # Make sure we only generate libraries of the form `libNAME.la'.
- case $outputname in
- lib*)
- name=`$echo "X$outputname" | $Xsed -e 's/\.la$//' -e 's/^lib//'`
- eval shared_ext=\"$shrext_cmds\"
- eval libname=\"$libname_spec\"
- ;;
- *)
- if test "$module" = no; then
- $echo "$modename: libtool library \`$output' must begin with \`lib'" 1>&2
- $echo "$help" 1>&2
- exit $EXIT_FAILURE
- fi
- if test "$need_lib_prefix" != no; then
- # Add the "lib" prefix for modules if required
- name=`$echo "X$outputname" | $Xsed -e 's/\.la$//'`
- eval shared_ext=\"$shrext_cmds\"
- eval libname=\"$libname_spec\"
- else
- libname=`$echo "X$outputname" | $Xsed -e 's/\.la$//'`
- fi
- ;;
- esac
-
- if test -n "$objs"; then
- if test "$deplibs_check_method" != pass_all; then
- $echo "$modename: cannot build libtool library \`$output' from non-libtool objects on this host:$objs" 2>&1
- exit $EXIT_FAILURE
- else
- $echo
- $echo "*** Warning: Linking the shared library $output against the non-libtool"
- $echo "*** objects $objs is not portable!"
- libobjs="$libobjs $objs"
- fi
- fi
-
- if test "$dlself" != no; then
- $echo "$modename: warning: \`-dlopen self' is ignored for libtool libraries" 1>&2
- fi
-
- set dummy $rpath
- if test "$#" -gt 2; then
- $echo "$modename: warning: ignoring multiple \`-rpath's for a libtool library" 1>&2
- fi
- install_libdir="$2"
-
- oldlibs=
- if test -z "$rpath"; then
- if test "$build_libtool_libs" = yes; then
- # Building a libtool convenience library.
- # Some compilers have problems with a `.al' extension so
- # convenience libraries should have the same extension an
- # archive normally would.
- oldlibs="$output_objdir/$libname.$libext $oldlibs"
- build_libtool_libs=convenience
- build_old_libs=yes
- fi
-
- if test -n "$vinfo"; then
- $echo "$modename: warning: \`-version-info/-version-number' is ignored for convenience libraries" 1>&2
- fi
-
- if test -n "$release"; then
- $echo "$modename: warning: \`-release' is ignored for convenience libraries" 1>&2
- fi
- else
-
- # Parse the version information argument.
- save_ifs="$IFS"; IFS=':'
- set dummy $vinfo 0 0 0
- IFS="$save_ifs"
-
- if test -n "$8"; then
- $echo "$modename: too many parameters to \`-version-info'" 1>&2
- $echo "$help" 1>&2
- exit $EXIT_FAILURE
- fi
-
- # convert absolute version numbers to libtool ages
- # this retains compatibility with .la files and attempts
- # to make the code below a bit more comprehensible
-
- case $vinfo_number in
- yes)
- number_major="$2"
- number_minor="$3"
- number_revision="$4"
- #
- # There are really only two kinds -- those that
- # use the current revision as the major version
- # and those that subtract age and use age as
- # a minor version. But, then there is irix
- # which has an extra 1 added just for fun
- #
- case $version_type in
- darwin|linux|osf|windows)
- current=`expr $number_major + $number_minor`
- age="$number_minor"
- revision="$number_revision"
- ;;
- freebsd-aout|freebsd-elf|sunos)
- current="$number_major"
- revision="$number_minor"
- age="0"
- ;;
- irix|nonstopux)
- current=`expr $number_major + $number_minor - 1`
- age="$number_minor"
- revision="$number_minor"
- ;;
- *)
- $echo "$modename: unknown library version type \`$version_type'" 1>&2
- $echo "Fatal configuration error. See the $PACKAGE docs for more information." 1>&2
- exit $EXIT_FAILURE
- ;;
- esac
- ;;
- no)
- current="$2"
- revision="$3"
- age="$4"
- ;;
- esac
-
- # Check that each of the things are valid numbers.
- case $current in
- 0|[1-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|[1-9][0-9][0-9][0-9][0-9]) ;;
- *)
- $echo "$modename: CURRENT \`$current' must be a nonnegative integer" 1>&2
- $echo "$modename: \`$vinfo' is not valid version information" 1>&2
- exit $EXIT_FAILURE
- ;;
- esac
-
- case $revision in
- 0|[1-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|[1-9][0-9][0-9][0-9][0-9]) ;;
- *)
- $echo "$modename: REVISION \`$revision' must be a nonnegative integer" 1>&2
- $echo "$modename: \`$vinfo' is not valid version information" 1>&2
- exit $EXIT_FAILURE
- ;;
- esac
-
- case $age in
- 0|[1-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|[1-9][0-9][0-9][0-9][0-9]) ;;
- *)
- $echo "$modename: AGE \`$age' must be a nonnegative integer" 1>&2
- $echo "$modename: \`$vinfo' is not valid version information" 1>&2
- exit $EXIT_FAILURE
- ;;
- esac
-
- if test "$age" -gt "$current"; then
- $echo "$modename: AGE \`$age' is greater than the current interface number \`$current'" 1>&2
- $echo "$modename: \`$vinfo' is not valid version information" 1>&2
- exit $EXIT_FAILURE
- fi
-
- # Calculate the version variables.
- major=
- versuffix=
- verstring=
- case $version_type in
- none) ;;
-
- darwin)
- # Like Linux, but with the current version available in
- # verstring for coding it into the library header
- major=.`expr $current - $age`
- versuffix="$major.$age.$revision"
- # Darwin ld doesn't like 0 for these options...
- minor_current=`expr $current + 1`
- verstring="${wl}-compatibility_version ${wl}$minor_current ${wl}-current_version ${wl}$minor_current.$revision"
- ;;
-
- freebsd-aout)
- major=".$current"
- versuffix=".$current.$revision";
- ;;
-
- freebsd-elf)
- major=".$current"
- versuffix=".$current";
- ;;
-
- irix | nonstopux)
- major=`expr $current - $age + 1`
-
- case $version_type in
- nonstopux) verstring_prefix=nonstopux ;;
- *) verstring_prefix=sgi ;;
- esac
- verstring="$verstring_prefix$major.$revision"
-
- # Add in all the interfaces that we are compatible with.
- loop=$revision
- while test "$loop" -ne 0; do
- iface=`expr $revision - $loop`
- loop=`expr $loop - 1`
- verstring="$verstring_prefix$major.$iface:$verstring"
- done
-
- # Before this point, $major must not contain `.'.
- major=.$major
- versuffix="$major.$revision"
- ;;
-
- linux)
- major=.`expr $current - $age`
- versuffix="$major.$age.$revision"
- ;;
-
- osf)
- major=.`expr $current - $age`
- versuffix=".$current.$age.$revision"
- verstring="$current.$age.$revision"
-
- # Add in all the interfaces that we are compatible with.
- loop=$age
- while test "$loop" -ne 0; do
- iface=`expr $current - $loop`
- loop=`expr $loop - 1`
- verstring="$verstring:${iface}.0"
- done
-
- # Make executables depend on our current version.
- verstring="$verstring:${current}.0"
- ;;
-
- sunos)
- major=".$current"
- versuffix=".$current.$revision"
- ;;
-
- windows)
- # Use '-' rather than '.', since we only want one
- # extension on DOS 8.3 filesystems.
- major=`expr $current - $age`
- versuffix="-$major"
- ;;
-
- *)
- $echo "$modename: unknown library version type \`$version_type'" 1>&2
- $echo "Fatal configuration error. See the $PACKAGE docs for more information." 1>&2
- exit $EXIT_FAILURE
- ;;
- esac
-
- # Clear the version info if we defaulted, and they specified a release.
- if test -z "$vinfo" && test -n "$release"; then
- major=
- case $version_type in
- darwin)
- # we can't check for "0.0" in archive_cmds due to quoting
- # problems, so we reset it completely
- verstring=
- ;;
- *)
- verstring="0.0"
- ;;
- esac
- if test "$need_version" = no; then
- versuffix=
- else
- versuffix=".0.0"
- fi
- fi
-
- # Remove version info from name if versioning should be avoided
- if test "$avoid_version" = yes && test "$need_version" = no; then
- major=
- versuffix=
- verstring=""
- fi
-
- # Check to see if the archive will have undefined symbols.
- if test "$allow_undefined" = yes; then
- if test "$allow_undefined_flag" = unsupported; then
- $echo "$modename: warning: undefined symbols not allowed in $host shared libraries" 1>&2
- build_libtool_libs=no
- build_old_libs=yes
- fi
- else
- # Don't allow undefined symbols.
- allow_undefined_flag="$no_undefined_flag"
- fi
- fi
-
- if test "$mode" != relink; then
- # Remove our outputs, but don't remove object files since they
- # may have been created when compiling PIC objects.
- removelist=
- tempremovelist=`$echo "$output_objdir/*"`
- for p in $tempremovelist; do
- case $p in
- *.$objext)
- ;;
- $output_objdir/$outputname | $output_objdir/$libname.* | $output_objdir/${libname}${release}.*)
- if test "X$precious_files_regex" != "X"; then
- if echo $p | $EGREP -e "$precious_files_regex" >/dev/null 2>&1
- then
- continue
- fi
- fi
- removelist="$removelist $p"
- ;;
- *) ;;
- esac
- done
- if test -n "$removelist"; then
- $show "${rm}r $removelist"
- $run ${rm}r $removelist
- fi
- fi
-
- # Now set the variables for building old libraries.
- if test "$build_old_libs" = yes && test "$build_libtool_libs" != convenience ; then
- oldlibs="$oldlibs $output_objdir/$libname.$libext"
-
- # Transform .lo files to .o files.
- oldobjs="$objs "`$echo "X$libobjs" | $SP2NL | $Xsed -e '/\.'${libext}'$/d' -e "$lo2o" | $NL2SP`
- fi
-
- # Eliminate all temporary directories.
- for path in $notinst_path; do
- lib_search_path=`$echo "$lib_search_path " | ${SED} -e "s% $path % %g"`
- deplibs=`$echo "$deplibs " | ${SED} -e "s% -L$path % %g"`
- dependency_libs=`$echo "$dependency_libs " | ${SED} -e "s% -L$path % %g"`
- done
-
- if test -n "$xrpath"; then
- # If the user specified any rpath flags, then add them.
- temp_xrpath=
- for libdir in $xrpath; do
- temp_xrpath="$temp_xrpath -R$libdir"
- case "$finalize_rpath " in
- *" $libdir "*) ;;
- *) finalize_rpath="$finalize_rpath $libdir" ;;
- esac
- done
- if test "$hardcode_into_libs" != yes || test "$build_old_libs" = yes; then
- dependency_libs="$temp_xrpath $dependency_libs"
- fi
- fi
-
- # Make sure dlfiles contains only unique files that won't be dlpreopened
- old_dlfiles="$dlfiles"
- dlfiles=
- for lib in $old_dlfiles; do
- case " $dlprefiles $dlfiles " in
- *" $lib "*) ;;
- *) dlfiles="$dlfiles $lib" ;;
- esac
- done
-
- # Make sure dlprefiles contains only unique files
- old_dlprefiles="$dlprefiles"
- dlprefiles=
- for lib in $old_dlprefiles; do
- case "$dlprefiles " in
- *" $lib "*) ;;
- *) dlprefiles="$dlprefiles $lib" ;;
- esac
- done
-
- if test "$build_libtool_libs" = yes; then
- if test -n "$rpath"; then
- case $host in
- *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-beos*)
- # these systems don't actually have a c library (as such)!
- ;;
- *-*-rhapsody* | *-*-darwin1.[012])
- # Rhapsody C library is in the System framework
- deplibs="$deplibs -framework System"
- ;;
- *-*-netbsd*)
- # Don't link with libc until the a.out ld.so is fixed.
- ;;
- *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
- # Do not include libc due to us having libc/libc_r.
- ;;
- *-*-sco3.2v5* | *-*-sco5v6*)
- # Causes problems with __ctype
- ;;
- *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*)
- # Compiler inserts libc in the correct place for threads to work
- ;;
- *)
- # Add libc to deplibs on all other systems if necessary.
- if test "$build_libtool_need_lc" = "yes"; then
- deplibs="$deplibs -lc"
- fi
- ;;
- esac
- fi
-
- # Transform deplibs into only deplibs that can be linked in shared.
- name_save=$name
- libname_save=$libname
- release_save=$release
- versuffix_save=$versuffix
- major_save=$major
- # I'm not sure if I'm treating the release correctly. I think
- # release should show up in the -l (ie -lgmp5) so we don't want to
- # add it in twice. Is that correct?
- release=""
- versuffix=""
- major=""
- newdeplibs=
- droppeddeps=no
- case $deplibs_check_method in
- pass_all)
- # Don't check for shared/static. Everything works.
- # This might be a little naive. We might want to check
- # whether the library exists or not. But this is on
- # osf3 & osf4 and I'm not really sure... Just
- # implementing what was already the behavior.
- newdeplibs=$deplibs
- ;;
- test_compile)
- # This code stresses the "libraries are programs" paradigm to its
- # limits. Maybe even breaks it. We compile a program, linking it
- # against the deplibs as a proxy for the library. Then we can check
- # whether they linked in statically or dynamically with ldd.
- $rm conftest.c
- cat > conftest.c <<EOF
- int main() { return 0; }
-EOF
- $rm conftest
- $LTCC $LTCFLAGS -o conftest conftest.c $deplibs
- if test "$?" -eq 0 ; then
- ldd_output=`ldd conftest`
- for i in $deplibs; do
- name=`expr $i : '-l\(.*\)'`
- # If $name is empty we are operating on a -L argument.
- if test "$name" != "" && test "$name" -ne "0"; then
- if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
- case " $predeps $postdeps " in
- *" $i "*)
- newdeplibs="$newdeplibs $i"
- i=""
- ;;
- esac
- fi
- if test -n "$i" ; then
- libname=`eval \\$echo \"$libname_spec\"`
- deplib_matches=`eval \\$echo \"$library_names_spec\"`
- set dummy $deplib_matches
- deplib_match=$2
- if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then
- newdeplibs="$newdeplibs $i"
- else
- droppeddeps=yes
- $echo
- $echo "*** Warning: dynamic linker does not accept needed library $i."
- $echo "*** I have the capability to make that library automatically link in when"
- $echo "*** you link to this library. But I can only do this if you have a"
- $echo "*** shared version of the library, which I believe you do not have"
- $echo "*** because a test_compile did reveal that the linker did not use it for"
- $echo "*** its dynamic dependency list that programs get resolved with at runtime."
- fi
- fi
- else
- newdeplibs="$newdeplibs $i"
- fi
- done
- else
- # Error occurred in the first compile. Let's try to salvage
- # the situation: Compile a separate program for each library.
- for i in $deplibs; do
- name=`expr $i : '-l\(.*\)'`
- # If $name is empty we are operating on a -L argument.
- if test "$name" != "" && test "$name" != "0"; then
- $rm conftest
- $LTCC $LTCFLAGS -o conftest conftest.c $i
- # Did it work?
- if test "$?" -eq 0 ; then
- ldd_output=`ldd conftest`
- if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
- case " $predeps $postdeps " in
- *" $i "*)
- newdeplibs="$newdeplibs $i"
- i=""
- ;;
- esac
- fi
- if test -n "$i" ; then
- libname=`eval \\$echo \"$libname_spec\"`
- deplib_matches=`eval \\$echo \"$library_names_spec\"`
- set dummy $deplib_matches
- deplib_match=$2
- if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then
- newdeplibs="$newdeplibs $i"
- else
- droppeddeps=yes
- $echo
- $echo "*** Warning: dynamic linker does not accept needed library $i."
- $echo "*** I have the capability to make that library automatically link in when"
- $echo "*** you link to this library. But I can only do this if you have a"
- $echo "*** shared version of the library, which you do not appear to have"
- $echo "*** because a test_compile did reveal that the linker did not use this one"
- $echo "*** as a dynamic dependency that programs can get resolved with at runtime."
- fi
- fi
- else
- droppeddeps=yes
- $echo
- $echo "*** Warning! Library $i is needed by this library but I was not able to"
- $echo "*** make it link in! You will probably need to install it or some"
- $echo "*** library that it depends on before this library will be fully"
- $echo "*** functional. Installing it before continuing would be even better."
- fi
- else
- newdeplibs="$newdeplibs $i"
- fi
- done
- fi
- ;;
- file_magic*)
- set dummy $deplibs_check_method
- file_magic_regex=`expr "$deplibs_check_method" : "$2 \(.*\)"`
- for a_deplib in $deplibs; do
- name=`expr $a_deplib : '-l\(.*\)'`
- # If $name is empty we are operating on a -L argument.
- if test "$name" != "" && test "$name" != "0"; then
- if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
- case " $predeps $postdeps " in
- *" $a_deplib "*)
- newdeplibs="$newdeplibs $a_deplib"
- a_deplib=""
- ;;
- esac
- fi
- if test -n "$a_deplib" ; then
- libname=`eval \\$echo \"$libname_spec\"`
- for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do
- potential_libs=`ls $i/$libname[.-]* 2>/dev/null`
- for potent_lib in $potential_libs; do
- # Follow soft links.
- if ls -lLd "$potent_lib" 2>/dev/null \
- | grep " -> " >/dev/null; then
- continue
- fi
- # The statement above tries to avoid entering an
- # endless loop below, in case of cyclic links.
- # We might still enter an endless loop, since a link
- # loop can be closed while we follow links,
- # but so what?
- potlib="$potent_lib"
- while test -h "$potlib" 2>/dev/null; do
- potliblink=`ls -ld $potlib | ${SED} 's/.* -> //'`
- case $potliblink in
- [\\/]* | [A-Za-z]:[\\/]*) potlib="$potliblink";;
- *) potlib=`$echo "X$potlib" | $Xsed -e 's,[^/]*$,,'`"$potliblink";;
- esac
- done
- if eval $file_magic_cmd \"\$potlib\" 2>/dev/null \
- | ${SED} 10q \
- | $EGREP "$file_magic_regex" > /dev/null; then
- newdeplibs="$newdeplibs $a_deplib"
- a_deplib=""
- break 2
- fi
- done
- done
- fi
- if test -n "$a_deplib" ; then
- droppeddeps=yes
- $echo
- $echo "*** Warning: linker path does not have real file for library $a_deplib."
- $echo "*** I have the capability to make that library automatically link in when"
- $echo "*** you link to this library. But I can only do this if you have a"
- $echo "*** shared version of the library, which you do not appear to have"
- $echo "*** because I did check the linker path looking for a file starting"
- if test -z "$potlib" ; then
- $echo "*** with $libname but no candidates were found. (...for file magic test)"
- else
- $echo "*** with $libname and none of the candidates passed a file format test"
- $echo "*** using a file magic. Last file checked: $potlib"
- fi
- fi
- else
- # Add a -L argument.
- newdeplibs="$newdeplibs $a_deplib"
- fi
- done # Gone through all deplibs.
- ;;
- match_pattern*)
- set dummy $deplibs_check_method
- match_pattern_regex=`expr "$deplibs_check_method" : "$2 \(.*\)"`
- for a_deplib in $deplibs; do
- name=`expr $a_deplib : '-l\(.*\)'`
- # If $name is empty we are operating on a -L argument.
- if test -n "$name" && test "$name" != "0"; then
- if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
- case " $predeps $postdeps " in
- *" $a_deplib "*)
- newdeplibs="$newdeplibs $a_deplib"
- a_deplib=""
- ;;
- esac
- fi
- if test -n "$a_deplib" ; then
- libname=`eval \\$echo \"$libname_spec\"`
- for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do
- potential_libs=`ls $i/$libname[.-]* 2>/dev/null`
- for potent_lib in $potential_libs; do
- potlib="$potent_lib" # see symlink-check above in file_magic test
- if eval $echo \"$potent_lib\" 2>/dev/null \
- | ${SED} 10q \
- | $EGREP "$match_pattern_regex" > /dev/null; then
- newdeplibs="$newdeplibs $a_deplib"
- a_deplib=""
- break 2
- fi
- done
- done
- fi
- if test -n "$a_deplib" ; then
- droppeddeps=yes
- $echo
- $echo "*** Warning: linker path does not have real file for library $a_deplib."
- $echo "*** I have the capability to make that library automatically link in when"
- $echo "*** you link to this library. But I can only do this if you have a"
- $echo "*** shared version of the library, which you do not appear to have"
- $echo "*** because I did check the linker path looking for a file starting"
- if test -z "$potlib" ; then
- $echo "*** with $libname but no candidates were found. (...for regex pattern test)"
- else
- $echo "*** with $libname and none of the candidates passed a file format test"
- $echo "*** using a regex pattern. Last file checked: $potlib"
- fi
- fi
- else
- # Add a -L argument.
- newdeplibs="$newdeplibs $a_deplib"
- fi
- done # Gone through all deplibs.
- ;;
- none | unknown | *)
- newdeplibs=""
- tmp_deplibs=`$echo "X $deplibs" | $Xsed -e 's/ -lc$//' \
- -e 's/ -[LR][^ ]*//g'`
- if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
- for i in $predeps $postdeps ; do
- # can't use Xsed below, because $i might contain '/'
- tmp_deplibs=`$echo "X $tmp_deplibs" | ${SED} -e "1s,^X,," -e "s,$i,,"`
- done
- fi
- if $echo "X $tmp_deplibs" | $Xsed -e 's/[ ]//g' \
- | grep . >/dev/null; then
- $echo
- if test "X$deplibs_check_method" = "Xnone"; then
- $echo "*** Warning: inter-library dependencies are not supported in this platform."
- else
- $echo "*** Warning: inter-library dependencies are not known to be supported."
- fi
- $echo "*** All declared inter-library dependencies are being dropped."
- droppeddeps=yes
- fi
- ;;
- esac
- versuffix=$versuffix_save
- major=$major_save
- release=$release_save
- libname=$libname_save
- name=$name_save
-
- case $host in
- *-*-rhapsody* | *-*-darwin1.[012])
- # On Rhapsody replace the C library is the System framework
- newdeplibs=`$echo "X $newdeplibs" | $Xsed -e 's/ -lc / -framework System /'`
- ;;
- esac
-
- if test "$droppeddeps" = yes; then
- if test "$module" = yes; then
- $echo
- $echo "*** Warning: libtool could not satisfy all declared inter-library"
- $echo "*** dependencies of module $libname. Therefore, libtool will create"
- $echo "*** a static module, that should work as long as the dlopening"
- $echo "*** application is linked with the -dlopen flag."
- if test -z "$global_symbol_pipe"; then
- $echo
- $echo "*** However, this would only work if libtool was able to extract symbol"
- $echo "*** lists from a program, using \`nm' or equivalent, but libtool could"
- $echo "*** not find such a program. So, this module is probably useless."
- $echo "*** \`nm' from GNU binutils and a full rebuild may help."
- fi
- if test "$build_old_libs" = no; then
- oldlibs="$output_objdir/$libname.$libext"
- build_libtool_libs=module
- build_old_libs=yes
- else
- build_libtool_libs=no
- fi
- else
- $echo "*** The inter-library dependencies that have been dropped here will be"
- $echo "*** automatically added whenever a program is linked with this library"
- $echo "*** or is declared to -dlopen it."
-
- if test "$allow_undefined" = no; then
- $echo
- $echo "*** Since this library must not contain undefined symbols,"
- $echo "*** because either the platform does not support them or"
- $echo "*** it was explicitly requested with -no-undefined,"
- $echo "*** libtool will only create a static version of it."
- if test "$build_old_libs" = no; then
- oldlibs="$output_objdir/$libname.$libext"
- build_libtool_libs=module
- build_old_libs=yes
- else
- build_libtool_libs=no
- fi
- fi
- fi
- fi
- # Done checking deplibs!
- deplibs=$newdeplibs
- fi
-
-
- # move library search paths that coincide with paths to not yet
- # installed libraries to the beginning of the library search list
- new_libs=
- for path in $notinst_path; do
- case " $new_libs " in
- *" -L$path/$objdir "*) ;;
- *)
- case " $deplibs " in
- *" -L$path/$objdir "*)
- new_libs="$new_libs -L$path/$objdir" ;;
- esac
- ;;
- esac
- done
- for deplib in $deplibs; do
- case $deplib in
- -L*)
- case " $new_libs " in
- *" $deplib "*) ;;
- *) new_libs="$new_libs $deplib" ;;
- esac
- ;;
- *) new_libs="$new_libs $deplib" ;;
- esac
- done
- deplibs="$new_libs"
-
-
- # All the library-specific variables (install_libdir is set above).
- library_names=
- old_library=
- dlname=
-
- # Test again, we may have decided not to build it any more
- if test "$build_libtool_libs" = yes; then
- if test "$hardcode_into_libs" = yes; then
- # Hardcode the library paths
- hardcode_libdirs=
- dep_rpath=
- rpath="$finalize_rpath"
- test "$mode" != relink && rpath="$compile_rpath$rpath"
- for libdir in $rpath; do
- if test -n "$hardcode_libdir_flag_spec"; then
- if test -n "$hardcode_libdir_separator"; then
- if test -z "$hardcode_libdirs"; then
- hardcode_libdirs="$libdir"
- else
- # Just accumulate the unique libdirs.
- case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
- *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
- ;;
- *)
- hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir"
- ;;
- esac
- fi
- else
- eval flag=\"$hardcode_libdir_flag_spec\"
- dep_rpath="$dep_rpath $flag"
- fi
- elif test -n "$runpath_var"; then
- case "$perm_rpath " in
- *" $libdir "*) ;;
- *) perm_rpath="$perm_rpath $libdir" ;;
- esac
- fi
- done
- # Substitute the hardcoded libdirs into the rpath.
- if test -n "$hardcode_libdir_separator" &&
- test -n "$hardcode_libdirs"; then
- libdir="$hardcode_libdirs"
- if test -n "$hardcode_libdir_flag_spec_ld"; then
- eval dep_rpath=\"$hardcode_libdir_flag_spec_ld\"
- else
- eval dep_rpath=\"$hardcode_libdir_flag_spec\"
- fi
- fi
- if test -n "$runpath_var" && test -n "$perm_rpath"; then
- # We should set the runpath_var.
- rpath=
- for dir in $perm_rpath; do
- rpath="$rpath$dir:"
- done
- eval "$runpath_var='$rpath\$$runpath_var'; export $runpath_var"
- fi
- test -n "$dep_rpath" && deplibs="$dep_rpath $deplibs"
- fi
-
- shlibpath="$finalize_shlibpath"
- test "$mode" != relink && shlibpath="$compile_shlibpath$shlibpath"
- if test -n "$shlibpath"; then
- eval "$shlibpath_var='$shlibpath\$$shlibpath_var'; export $shlibpath_var"
- fi
-
- # Get the real and link names of the library.
- eval shared_ext=\"$shrext_cmds\"
- eval library_names=\"$library_names_spec\"
- set dummy $library_names
- realname="$2"
- shift; shift
-
- if test -n "$soname_spec"; then
- eval soname=\"$soname_spec\"
- else
- soname="$realname"
- fi
- if test -z "$dlname"; then
- dlname=$soname
- fi
-
- lib="$output_objdir/$realname"
- linknames=
- for link
- do
- linknames="$linknames $link"
- done
-
- # Use standard objects if they are pic
- test -z "$pic_flag" && libobjs=`$echo "X$libobjs" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP`
-
- # Prepare the list of exported symbols
- if test -z "$export_symbols"; then
- if test "$always_export_symbols" = yes || test -n "$export_symbols_regex"; then
- $show "generating symbol list for \`$libname.la'"
- export_symbols="$output_objdir/$libname.exp"
- $run $rm $export_symbols
- cmds=$export_symbols_cmds
- save_ifs="$IFS"; IFS='~'
- for cmd in $cmds; do
- IFS="$save_ifs"
- eval cmd=\"$cmd\"
- if len=`expr "X$cmd" : ".*"` &&
- test "$len" -le "$max_cmd_len" || test "$max_cmd_len" -le -1; then
- $show "$cmd"
- $run eval "$cmd" || exit $?
- skipped_export=false
- else
- # The command line is too long to execute in one step.
- $show "using reloadable object file for export list..."
- skipped_export=:
- # Break out early, otherwise skipped_export may be
- # set to false by a later but shorter cmd.
- break
- fi
- done
- IFS="$save_ifs"
- if test -n "$export_symbols_regex"; then
- $show "$EGREP -e \"$export_symbols_regex\" \"$export_symbols\" > \"${export_symbols}T\""
- $run eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"'
- $show "$mv \"${export_symbols}T\" \"$export_symbols\""
- $run eval '$mv "${export_symbols}T" "$export_symbols"'
- fi
- fi
- fi
-
- if test -n "$export_symbols" && test -n "$include_expsyms"; then
- $run eval '$echo "X$include_expsyms" | $SP2NL >> "$export_symbols"'
- fi
-
- tmp_deplibs=
- for test_deplib in $deplibs; do
- case " $convenience " in
- *" $test_deplib "*) ;;
- *)
- tmp_deplibs="$tmp_deplibs $test_deplib"
- ;;
- esac
- done
- deplibs="$tmp_deplibs"
-
- if test -n "$convenience"; then
- if test -n "$whole_archive_flag_spec"; then
- save_libobjs=$libobjs
- eval libobjs=\"\$libobjs $whole_archive_flag_spec\"
- else
- gentop="$output_objdir/${outputname}x"
- generated="$generated $gentop"
-
- func_extract_archives $gentop $convenience
- libobjs="$libobjs $func_extract_archives_result"
- fi
- fi
-
- if test "$thread_safe" = yes && test -n "$thread_safe_flag_spec"; then
- eval flag=\"$thread_safe_flag_spec\"
- linker_flags="$linker_flags $flag"
- fi
-
- # Make a backup of the uninstalled library when relinking
- if test "$mode" = relink; then
- $run eval '(cd $output_objdir && $rm ${realname}U && $mv $realname ${realname}U)' || exit $?
- fi
-
- # Do each of the archive commands.
- if test "$module" = yes && test -n "$module_cmds" ; then
- if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then
- eval test_cmds=\"$module_expsym_cmds\"
- cmds=$module_expsym_cmds
- else
- eval test_cmds=\"$module_cmds\"
- cmds=$module_cmds
- fi
- else
- if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then
- eval test_cmds=\"$archive_expsym_cmds\"
- cmds=$archive_expsym_cmds
- else
- eval test_cmds=\"$archive_cmds\"
- cmds=$archive_cmds
- fi
- fi
-
- if test "X$skipped_export" != "X:" &&
- len=`expr "X$test_cmds" : ".*" 2>/dev/null` &&
- test "$len" -le "$max_cmd_len" || test "$max_cmd_len" -le -1; then
- :
- else
- # The command line is too long to link in one step, link piecewise.
- $echo "creating reloadable object files..."
-
- # Save the value of $output and $libobjs because we want to
- # use them later. If we have whole_archive_flag_spec, we
- # want to use save_libobjs as it was before
- # whole_archive_flag_spec was expanded, because we can't
- # assume the linker understands whole_archive_flag_spec.
- # This may have to be revisited, in case too many
- # convenience libraries get linked in and end up exceeding
- # the spec.
- if test -z "$convenience" || test -z "$whole_archive_flag_spec"; then
- save_libobjs=$libobjs
- fi
- save_output=$output
- output_la=`$echo "X$output" | $Xsed -e "$basename"`
-
- # Clear the reloadable object creation command queue and
- # initialize k to one.
- test_cmds=
- concat_cmds=
- objlist=
- delfiles=
- last_robj=
- k=1
- output=$output_objdir/$output_la-${k}.$objext
- # Loop over the list of objects to be linked.
- for obj in $save_libobjs
- do
- eval test_cmds=\"$reload_cmds $objlist $last_robj\"
- if test "X$objlist" = X ||
- { len=`expr "X$test_cmds" : ".*" 2>/dev/null` &&
- test "$len" -le "$max_cmd_len"; }; then
- objlist="$objlist $obj"
- else
- # The command $test_cmds is almost too long, add a
- # command to the queue.
- if test "$k" -eq 1 ; then
- # The first file doesn't have a previous command to add.
- eval concat_cmds=\"$reload_cmds $objlist $last_robj\"
- else
- # All subsequent reloadable object files will link in
- # the last one created.
- eval concat_cmds=\"\$concat_cmds~$reload_cmds $objlist $last_robj\"
- fi
- last_robj=$output_objdir/$output_la-${k}.$objext
- k=`expr $k + 1`
- output=$output_objdir/$output_la-${k}.$objext
- objlist=$obj
- len=1
- fi
- done
- # Handle the remaining objects by creating one last
- # reloadable object file. All subsequent reloadable object
- # files will link in the last one created.
- test -z "$concat_cmds" || concat_cmds=$concat_cmds~
- eval concat_cmds=\"\${concat_cmds}$reload_cmds $objlist $last_robj\"
-
- if ${skipped_export-false}; then
- $show "generating symbol list for \`$libname.la'"
- export_symbols="$output_objdir/$libname.exp"
- $run $rm $export_symbols
- libobjs=$output
- # Append the command to create the export file.
- eval concat_cmds=\"\$concat_cmds~$export_symbols_cmds\"
- fi
-
- # Set up a command to remove the reloadable object files
- # after they are used.
- i=0
- while test "$i" -lt "$k"
- do
- i=`expr $i + 1`
- delfiles="$delfiles $output_objdir/$output_la-${i}.$objext"
- done
-
- $echo "creating a temporary reloadable object file: $output"
-
- # Loop through the commands generated above and execute them.
- save_ifs="$IFS"; IFS='~'
- for cmd in $concat_cmds; do
- IFS="$save_ifs"
- $show "$cmd"
- $run eval "$cmd" || exit $?
- done
- IFS="$save_ifs"
-
- libobjs=$output
- # Restore the value of output.
- output=$save_output
-
- if test -n "$convenience" && test -n "$whole_archive_flag_spec"; then
- eval libobjs=\"\$libobjs $whole_archive_flag_spec\"
- fi
- # Expand the library linking commands again to reset the
- # value of $libobjs for piecewise linking.
-
- # Do each of the archive commands.
- if test "$module" = yes && test -n "$module_cmds" ; then
- if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then
- cmds=$module_expsym_cmds
- else
- cmds=$module_cmds
- fi
- else
- if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then
- cmds=$archive_expsym_cmds
- else
- cmds=$archive_cmds
- fi
- fi
-
- # Append the command to remove the reloadable object files
- # to the just-reset $cmds.
- eval cmds=\"\$cmds~\$rm $delfiles\"
- fi
- save_ifs="$IFS"; IFS='~'
- for cmd in $cmds; do
- IFS="$save_ifs"
- eval cmd=\"$cmd\"
- $show "$cmd"
- $run eval "$cmd" || {
- lt_exit=$?
-
- # Restore the uninstalled library and exit
- if test "$mode" = relink; then
- $run eval '(cd $output_objdir && $rm ${realname}T && $mv ${realname}U $realname)'
- fi
-
- exit $lt_exit
- }
- done
- IFS="$save_ifs"
-
- # Restore the uninstalled library and exit
- if test "$mode" = relink; then
- $run eval '(cd $output_objdir && $rm ${realname}T && $mv $realname ${realname}T && $mv "$realname"U $realname)' || exit $?
-
- if test -n "$convenience"; then
- if test -z "$whole_archive_flag_spec"; then
- $show "${rm}r $gentop"
- $run ${rm}r "$gentop"
- fi
- fi
-
- exit $EXIT_SUCCESS
- fi
-
- # Create links to the real library.
- for linkname in $linknames; do
- if test "$realname" != "$linkname"; then
- $show "(cd $output_objdir && $rm $linkname && $LN_S $realname $linkname)"
- $run eval '(cd $output_objdir && $rm $linkname && $LN_S $realname $linkname)' || exit $?
- fi
- done
-
- # If -module or -export-dynamic was specified, set the dlname.
- if test "$module" = yes || test "$export_dynamic" = yes; then
- # On all known operating systems, these are identical.
- dlname="$soname"
- fi
- fi
- ;;
-
- obj)
- if test -n "$deplibs"; then
- $echo "$modename: warning: \`-l' and \`-L' are ignored for objects" 1>&2
- fi
-
- if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
- $echo "$modename: warning: \`-dlopen' is ignored for objects" 1>&2
- fi
-
- if test -n "$rpath"; then
- $echo "$modename: warning: \`-rpath' is ignored for objects" 1>&2
- fi
-
- if test -n "$xrpath"; then
- $echo "$modename: warning: \`-R' is ignored for objects" 1>&2
- fi
-
- if test -n "$vinfo"; then
- $echo "$modename: warning: \`-version-info' is ignored for objects" 1>&2
- fi
-
- if test -n "$release"; then
- $echo "$modename: warning: \`-release' is ignored for objects" 1>&2
- fi
-
- case $output in
- *.lo)
- if test -n "$objs$old_deplibs"; then
- $echo "$modename: cannot build library object \`$output' from non-libtool objects" 1>&2
- exit $EXIT_FAILURE
- fi
- libobj="$output"
- obj=`$echo "X$output" | $Xsed -e "$lo2o"`
- ;;
- *)
- libobj=
- obj="$output"
- ;;
- esac
-
- # Delete the old objects.
- $run $rm $obj $libobj
-
- # Objects from convenience libraries. This assumes
- # single-version convenience libraries. Whenever we create
- # different ones for PIC/non-PIC, this we'll have to duplicate
- # the extraction.
- reload_conv_objs=
- gentop=
- # reload_cmds runs $LD directly, so let us get rid of
- # -Wl from whole_archive_flag_spec
- wl=
-
- if test -n "$convenience"; then
- if test -n "$whole_archive_flag_spec"; then
- eval reload_conv_objs=\"\$reload_objs $whole_archive_flag_spec\"
- else
- gentop="$output_objdir/${obj}x"
- generated="$generated $gentop"
-
- func_extract_archives $gentop $convenience
- reload_conv_objs="$reload_objs $func_extract_archives_result"
- fi
- fi
-
- # Create the old-style object.
- reload_objs="$objs$old_deplibs "`$echo "X$libobjs" | $SP2NL | $Xsed -e '/\.'${libext}$'/d' -e '/\.lib$/d' -e "$lo2o" | $NL2SP`" $reload_conv_objs" ### testsuite: skip nested quoting test
-
- output="$obj"
- cmds=$reload_cmds
- save_ifs="$IFS"; IFS='~'
- for cmd in $cmds; do
- IFS="$save_ifs"
- eval cmd=\"$cmd\"
- $show "$cmd"
- $run eval "$cmd" || exit $?
- done
- IFS="$save_ifs"
-
- # Exit if we aren't doing a library object file.
- if test -z "$libobj"; then
- if test -n "$gentop"; then
- $show "${rm}r $gentop"
- $run ${rm}r $gentop
- fi
-
- exit $EXIT_SUCCESS
- fi
-
- if test "$build_libtool_libs" != yes; then
- if test -n "$gentop"; then
- $show "${rm}r $gentop"
- $run ${rm}r $gentop
- fi
-
- # Create an invalid libtool object if no PIC, so that we don't
- # accidentally link it into a program.
- # $show "echo timestamp > $libobj"
- # $run eval "echo timestamp > $libobj" || exit $?
- exit $EXIT_SUCCESS
- fi
-
- if test -n "$pic_flag" || test "$pic_mode" != default; then
- # Only do commands if we really have different PIC objects.
- reload_objs="$libobjs $reload_conv_objs"
- output="$libobj"
- cmds=$reload_cmds
- save_ifs="$IFS"; IFS='~'
- for cmd in $cmds; do
- IFS="$save_ifs"
- eval cmd=\"$cmd\"
- $show "$cmd"
- $run eval "$cmd" || exit $?
- done
- IFS="$save_ifs"
- fi
-
- if test -n "$gentop"; then
- $show "${rm}r $gentop"
- $run ${rm}r $gentop
- fi
-
- exit $EXIT_SUCCESS
- ;;
-
- prog)
- case $host in
- *cygwin*) output=`$echo $output | ${SED} -e 's,.exe$,,;s,$,.exe,'` ;;
- esac
- if test -n "$vinfo"; then
- $echo "$modename: warning: \`-version-info' is ignored for programs" 1>&2
- fi
-
- if test -n "$release"; then
- $echo "$modename: warning: \`-release' is ignored for programs" 1>&2
- fi
-
- if test "$preload" = yes; then
- if test "$dlopen_support" = unknown && test "$dlopen_self" = unknown &&
- test "$dlopen_self_static" = unknown; then
- $echo "$modename: warning: \`AC_LIBTOOL_DLOPEN' not used. Assuming no dlopen support."
- fi
- fi
-
- case $host in
- *-*-rhapsody* | *-*-darwin1.[012])
- # On Rhapsody replace the C library is the System framework
- compile_deplibs=`$echo "X $compile_deplibs" | $Xsed -e 's/ -lc / -framework System /'`
- finalize_deplibs=`$echo "X $finalize_deplibs" | $Xsed -e 's/ -lc / -framework System /'`
- ;;
- esac
-
- case $host in
- *darwin*)
- # Don't allow lazy linking, it breaks C++ global constructors
- if test "$tagname" = CXX ; then
- compile_command="$compile_command ${wl}-bind_at_load"
- finalize_command="$finalize_command ${wl}-bind_at_load"
- fi
- ;;
- esac
-
-
- # move library search paths that coincide with paths to not yet
- # installed libraries to the beginning of the library search list
- new_libs=
- for path in $notinst_path; do
- case " $new_libs " in
- *" -L$path/$objdir "*) ;;
- *)
- case " $compile_deplibs " in
- *" -L$path/$objdir "*)
- new_libs="$new_libs -L$path/$objdir" ;;
- esac
- ;;
- esac
- done
- for deplib in $compile_deplibs; do
- case $deplib in
- -L*)
- case " $new_libs " in
- *" $deplib "*) ;;
- *) new_libs="$new_libs $deplib" ;;
- esac
- ;;
- *) new_libs="$new_libs $deplib" ;;
- esac
- done
- compile_deplibs="$new_libs"
-
-
- compile_command="$compile_command $compile_deplibs"
- finalize_command="$finalize_command $finalize_deplibs"
-
- if test -n "$rpath$xrpath"; then
- # If the user specified any rpath flags, then add them.
- for libdir in $rpath $xrpath; do
- # This is the magic to use -rpath.
- case "$finalize_rpath " in
- *" $libdir "*) ;;
- *) finalize_rpath="$finalize_rpath $libdir" ;;
- esac
- done
- fi
-
- # Now hardcode the library paths
- rpath=
- hardcode_libdirs=
- for libdir in $compile_rpath $finalize_rpath; do
- if test -n "$hardcode_libdir_flag_spec"; then
- if test -n "$hardcode_libdir_separator"; then
- if test -z "$hardcode_libdirs"; then
- hardcode_libdirs="$libdir"
- else
- # Just accumulate the unique libdirs.
- case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
- *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
- ;;
- *)
- hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir"
- ;;
- esac
- fi
- else
- eval flag=\"$hardcode_libdir_flag_spec\"
- rpath="$rpath $flag"
- fi
- elif test -n "$runpath_var"; then
- case "$perm_rpath " in
- *" $libdir "*) ;;
- *) perm_rpath="$perm_rpath $libdir" ;;
- esac
- fi
- case $host in
- *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2*)
- testbindir=`$echo "X$libdir" | $Xsed -e 's*/lib$*/bin*'`
- case :$dllsearchpath: in
- *":$libdir:"*) ;;
- *) dllsearchpath="$dllsearchpath:$libdir";;
- esac
- case :$dllsearchpath: in
- *":$testbindir:"*) ;;
- *) dllsearchpath="$dllsearchpath:$testbindir";;
- esac
- ;;
- esac
- done
- # Substitute the hardcoded libdirs into the rpath.
- if test -n "$hardcode_libdir_separator" &&
- test -n "$hardcode_libdirs"; then
- libdir="$hardcode_libdirs"
- eval rpath=\" $hardcode_libdir_flag_spec\"
- fi
- compile_rpath="$rpath"
-
- rpath=
- hardcode_libdirs=
- for libdir in $finalize_rpath; do
- if test -n "$hardcode_libdir_flag_spec"; then
- if test -n "$hardcode_libdir_separator"; then
- if test -z "$hardcode_libdirs"; then
- hardcode_libdirs="$libdir"
- else
- # Just accumulate the unique libdirs.
- case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
- *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
- ;;
- *)
- hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir"
- ;;
- esac
- fi
- else
- eval flag=\"$hardcode_libdir_flag_spec\"
- rpath="$rpath $flag"
- fi
- elif test -n "$runpath_var"; then
- case "$finalize_perm_rpath " in
- *" $libdir "*) ;;
- *) finalize_perm_rpath="$finalize_perm_rpath $libdir" ;;
- esac
- fi
- done
- # Substitute the hardcoded libdirs into the rpath.
- if test -n "$hardcode_libdir_separator" &&
- test -n "$hardcode_libdirs"; then
- libdir="$hardcode_libdirs"
- eval rpath=\" $hardcode_libdir_flag_spec\"
- fi
- finalize_rpath="$rpath"
-
- if test -n "$libobjs" && test "$build_old_libs" = yes; then
- # Transform all the library objects into standard objects.
- compile_command=`$echo "X$compile_command" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP`
- finalize_command=`$echo "X$finalize_command" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP`
- fi
-
- dlsyms=
- if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
- if test -n "$NM" && test -n "$global_symbol_pipe"; then
- dlsyms="${outputname}S.c"
- else
- $echo "$modename: not configured to extract global symbols from dlpreopened files" 1>&2
- fi
- fi
-
- if test -n "$dlsyms"; then
- case $dlsyms in
- "") ;;
- *.c)
- # Discover the nlist of each of the dlfiles.
- nlist="$output_objdir/${outputname}.nm"
-
- $show "$rm $nlist ${nlist}S ${nlist}T"
- $run $rm "$nlist" "${nlist}S" "${nlist}T"
-
- # Parse the name list into a source file.
- $show "creating $output_objdir/$dlsyms"
-
- test -z "$run" && $echo > "$output_objdir/$dlsyms" "\
-/* $dlsyms - symbol resolution table for \`$outputname' dlsym emulation. */
-/* Generated by $PROGRAM - GNU $PACKAGE $VERSION$TIMESTAMP */
-
-#ifdef __cplusplus
-extern \"C\" {
-#endif
-
-/* Prevent the only kind of declaration conflicts we can make. */
-#define lt_preloaded_symbols some_other_symbol
-
-/* External symbol declarations for the compiler. */\
-"
-
- if test "$dlself" = yes; then
- $show "generating symbol list for \`$output'"
-
- test -z "$run" && $echo ': @PROGRAM@ ' > "$nlist"
-
- # Add our own program objects to the symbol list.
- progfiles=`$echo "X$objs$old_deplibs" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP`
- for arg in $progfiles; do
- $show "extracting global C symbols from \`$arg'"
- $run eval "$NM $arg | $global_symbol_pipe >> '$nlist'"
- done
-
- if test -n "$exclude_expsyms"; then
- $run eval '$EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T'
- $run eval '$mv "$nlist"T "$nlist"'
- fi
-
- if test -n "$export_symbols_regex"; then
- $run eval '$EGREP -e "$export_symbols_regex" "$nlist" > "$nlist"T'
- $run eval '$mv "$nlist"T "$nlist"'
- fi
-
- # Prepare the list of exported symbols
- if test -z "$export_symbols"; then
- export_symbols="$output_objdir/$outputname.exp"
- $run $rm $export_symbols
- $run eval "${SED} -n -e '/^: @PROGRAM@ $/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"'
- case $host in
- *cygwin* | *mingw* )
- $run eval "echo EXPORTS "'> "$output_objdir/$outputname.def"'
- $run eval 'cat "$export_symbols" >> "$output_objdir/$outputname.def"'
- ;;
- esac
- else
- $run eval "${SED} -e 's/\([].[*^$]\)/\\\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$outputname.exp"'
- $run eval 'grep -f "$output_objdir/$outputname.exp" < "$nlist" > "$nlist"T'
- $run eval 'mv "$nlist"T "$nlist"'
- case $host in
- *cygwin* | *mingw* )
- $run eval "echo EXPORTS "'> "$output_objdir/$outputname.def"'
- $run eval 'cat "$nlist" >> "$output_objdir/$outputname.def"'
- ;;
- esac
- fi
- fi
-
- for arg in $dlprefiles; do
- $show "extracting global C symbols from \`$arg'"
- name=`$echo "$arg" | ${SED} -e 's%^.*/%%'`
- $run eval '$echo ": $name " >> "$nlist"'
- $run eval "$NM $arg | $global_symbol_pipe >> '$nlist'"
- done
-
- if test -z "$run"; then
- # Make sure we have at least an empty file.
- test -f "$nlist" || : > "$nlist"
-
- if test -n "$exclude_expsyms"; then
- $EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T
- $mv "$nlist"T "$nlist"
- fi
-
- # Try sorting and uniquifying the output.
- if grep -v "^: " < "$nlist" |
- if sort -k 3 </dev/null >/dev/null 2>&1; then
- sort -k 3
- else
- sort +2
- fi |
- uniq > "$nlist"S; then
- :
- else
- grep -v "^: " < "$nlist" > "$nlist"S
- fi
-
- if test -f "$nlist"S; then
- eval "$global_symbol_to_cdecl"' < "$nlist"S >> "$output_objdir/$dlsyms"'
- else
- $echo '/* NONE */' >> "$output_objdir/$dlsyms"
- fi
-
- $echo >> "$output_objdir/$dlsyms" "\
-
-#undef lt_preloaded_symbols
-
-#if defined (__STDC__) && __STDC__
-# define lt_ptr void *
-#else
-# define lt_ptr char *
-# define const
-#endif
-
-/* The mapping between symbol names and symbols. */
-"
-
- case $host in
- *cygwin* | *mingw* )
- $echo >> "$output_objdir/$dlsyms" "\
-/* DATA imports from DLLs on WIN32 can't be const, because
- runtime relocations are performed -- see ld's documentation
- on pseudo-relocs */
-struct {
-"
- ;;
- * )
- $echo >> "$output_objdir/$dlsyms" "\
-const struct {
-"
- ;;
- esac
-
-
- $echo >> "$output_objdir/$dlsyms" "\
- const char *name;
- lt_ptr address;
-}
-lt_preloaded_symbols[] =
-{\
-"
-
- eval "$global_symbol_to_c_name_address" < "$nlist" >> "$output_objdir/$dlsyms"
-
- $echo >> "$output_objdir/$dlsyms" "\
- {0, (lt_ptr) 0}
-};
-
-/* This works around a problem in FreeBSD linker */
-#ifdef FREEBSD_WORKAROUND
-static const void *lt_preloaded_setup() {
- return lt_preloaded_symbols;
-}
-#endif
-
-#ifdef __cplusplus
-}
-#endif\
-"
- fi
-
- pic_flag_for_symtable=
- case $host in
- # compiling the symbol table file with pic_flag works around
- # a FreeBSD bug that causes programs to crash when -lm is
- # linked before any other PIC object. But we must not use
- # pic_flag when linking with -static. The problem exists in
- # FreeBSD 2.2.6 and is fixed in FreeBSD 3.1.
- *-*-freebsd2*|*-*-freebsd3.0*|*-*-freebsdelf3.0*)
- case "$compile_command " in
- *" -static "*) ;;
- *) pic_flag_for_symtable=" $pic_flag -DFREEBSD_WORKAROUND";;
- esac;;
- *-*-hpux*)
- case "$compile_command " in
- *" -static "*) ;;
- *) pic_flag_for_symtable=" $pic_flag";;
- esac
- esac
-
- # Now compile the dynamic symbol file.
- $show "(cd $output_objdir && $LTCC $LTCFLAGS -c$no_builtin_flag$pic_flag_for_symtable \"$dlsyms\")"
- $run eval '(cd $output_objdir && $LTCC $LTCFLAGS -c$no_builtin_flag$pic_flag_for_symtable "$dlsyms")' || exit $?
-
- # Clean up the generated files.
- $show "$rm $output_objdir/$dlsyms $nlist ${nlist}S ${nlist}T"
- $run $rm "$output_objdir/$dlsyms" "$nlist" "${nlist}S" "${nlist}T"
-
- # Transform the symbol file into the correct name.
- case $host in
- *cygwin* | *mingw* )
- if test -f "$output_objdir/${outputname}.def" ; then
- compile_command=`$echo "X$compile_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}.def $output_objdir/${outputname}S.${objext}%"`
- finalize_command=`$echo "X$finalize_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}.def $output_objdir/${outputname}S.${objext}%"`
- else
- compile_command=`$echo "X$compile_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}S.${objext}%"`
- finalize_command=`$echo "X$finalize_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}S.${objext}%"`
- fi
- ;;
- * )
- compile_command=`$echo "X$compile_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}S.${objext}%"`
- finalize_command=`$echo "X$finalize_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}S.${objext}%"`
- ;;
- esac
- ;;
- *)
- $echo "$modename: unknown suffix for \`$dlsyms'" 1>&2
- exit $EXIT_FAILURE
- ;;
- esac
- else
- # We keep going just in case the user didn't refer to
- # lt_preloaded_symbols. The linker will fail if global_symbol_pipe
- # really was required.
-
- # Nullify the symbol file.
- compile_command=`$echo "X$compile_command" | $Xsed -e "s% @SYMFILE@%%"`
- finalize_command=`$echo "X$finalize_command" | $Xsed -e "s% @SYMFILE@%%"`
- fi
-
- if test "$need_relink" = no || test "$build_libtool_libs" != yes; then
- # Replace the output file specification.
- compile_command=`$echo "X$compile_command" | $Xsed -e 's%@OUTPUT@%'"$output"'%g'`
- link_command="$compile_command$compile_rpath"
-
- # We have no uninstalled library dependencies, so finalize right now.
- $show "$link_command"
- $run eval "$link_command"
- exit_status=$?
-
- # Delete the generated files.
- if test -n "$dlsyms"; then
- $show "$rm $output_objdir/${outputname}S.${objext}"
- $run $rm "$output_objdir/${outputname}S.${objext}"
- fi
-
- exit $exit_status
- fi
-
- if test -n "$shlibpath_var"; then
- # We should set the shlibpath_var
- rpath=
- for dir in $temp_rpath; do
- case $dir in
- [\\/]* | [A-Za-z]:[\\/]*)
- # Absolute path.
- rpath="$rpath$dir:"
- ;;
- *)
- # Relative path: add a thisdir entry.
- rpath="$rpath\$thisdir/$dir:"
- ;;
- esac
- done
- temp_rpath="$rpath"
- fi
-
- if test -n "$compile_shlibpath$finalize_shlibpath"; then
- compile_command="$shlibpath_var=\"$compile_shlibpath$finalize_shlibpath\$$shlibpath_var\" $compile_command"
- fi
- if test -n "$finalize_shlibpath"; then
- finalize_command="$shlibpath_var=\"$finalize_shlibpath\$$shlibpath_var\" $finalize_command"
- fi
-
- compile_var=
- finalize_var=
- if test -n "$runpath_var"; then
- if test -n "$perm_rpath"; then
- # We should set the runpath_var.
- rpath=
- for dir in $perm_rpath; do
- rpath="$rpath$dir:"
- done
- compile_var="$runpath_var=\"$rpath\$$runpath_var\" "
- fi
- if test -n "$finalize_perm_rpath"; then
- # We should set the runpath_var.
- rpath=
- for dir in $finalize_perm_rpath; do
- rpath="$rpath$dir:"
- done
- finalize_var="$runpath_var=\"$rpath\$$runpath_var\" "
- fi
- fi
-
- if test "$no_install" = yes; then
- # We don't need to create a wrapper script.
- link_command="$compile_var$compile_command$compile_rpath"
- # Replace the output file specification.
- link_command=`$echo "X$link_command" | $Xsed -e 's%@OUTPUT@%'"$output"'%g'`
- # Delete the old output file.
- $run $rm $output
- # Link the executable and exit
- $show "$link_command"
- $run eval "$link_command" || exit $?
- exit $EXIT_SUCCESS
- fi
-
- if test "$hardcode_action" = relink; then
- # Fast installation is not supported
- link_command="$compile_var$compile_command$compile_rpath"
- relink_command="$finalize_var$finalize_command$finalize_rpath"
-
- $echo "$modename: warning: this platform does not like uninstalled shared libraries" 1>&2
- $echo "$modename: \`$output' will be relinked during installation" 1>&2
- else
- if test "$fast_install" != no; then
- link_command="$finalize_var$compile_command$finalize_rpath"
- if test "$fast_install" = yes; then
- relink_command=`$echo "X$compile_var$compile_command$compile_rpath" | $Xsed -e 's%@OUTPUT@%\$progdir/\$file%g'`
- else
- # fast_install is set to needless
- relink_command=
- fi
- else
- link_command="$compile_var$compile_command$compile_rpath"
- relink_command="$finalize_var$finalize_command$finalize_rpath"
- fi
- fi
-
- # Replace the output file specification.
- link_command=`$echo "X$link_command" | $Xsed -e 's%@OUTPUT@%'"$output_objdir/$outputname"'%g'`
-
- # Delete the old output files.
- $run $rm $output $output_objdir/$outputname $output_objdir/lt-$outputname
-
- $show "$link_command"
- $run eval "$link_command" || exit $?
-
- # Now create the wrapper script.
- $show "creating $output"
-
- # Quote the relink command for shipping.
- if test -n "$relink_command"; then
- # Preserve any variables that may affect compiler behavior
- for var in $variables_saved_for_relink; do
- if eval test -z \"\${$var+set}\"; then
- relink_command="{ test -z \"\${$var+set}\" || unset $var || { $var=; export $var; }; }; $relink_command"
- elif eval var_value=\$$var; test -z "$var_value"; then
- relink_command="$var=; export $var; $relink_command"
- else
- var_value=`$echo "X$var_value" | $Xsed -e "$sed_quote_subst"`
- relink_command="$var=\"$var_value\"; export $var; $relink_command"
- fi
- done
- relink_command="(cd `pwd`; $relink_command)"
- relink_command=`$echo "X$relink_command" | $Xsed -e "$sed_quote_subst"`
- fi
-
- # Quote $echo for shipping.
- if test "X$echo" = "X$SHELL $progpath --fallback-echo"; then
- case $progpath in
- [\\/]* | [A-Za-z]:[\\/]*) qecho="$SHELL $progpath --fallback-echo";;
- *) qecho="$SHELL `pwd`/$progpath --fallback-echo";;
- esac
- qecho=`$echo "X$qecho" | $Xsed -e "$sed_quote_subst"`
- else
- qecho=`$echo "X$echo" | $Xsed -e "$sed_quote_subst"`
- fi
-
- # Only actually do things if our run command is non-null.
- if test -z "$run"; then
- # win32 will think the script is a binary if it has
- # a .exe suffix, so we strip it off here.
- case $output in
- *.exe) output=`$echo $output|${SED} 's,.exe$,,'` ;;
- esac
- # test for cygwin because mv fails w/o .exe extensions
- case $host in
- *cygwin*)
- exeext=.exe
- outputname=`$echo $outputname|${SED} 's,.exe$,,'` ;;
- *) exeext= ;;
- esac
- case $host in
- *cygwin* | *mingw* )
- output_name=`basename $output`
- output_path=`dirname $output`
- cwrappersource="$output_path/$objdir/lt-$output_name.c"
- cwrapper="$output_path/$output_name.exe"
- $rm $cwrappersource $cwrapper
- trap "$rm $cwrappersource $cwrapper; exit $EXIT_FAILURE" 1 2 15
-
- cat > $cwrappersource <<EOF
-
-/* $cwrappersource - temporary wrapper executable for $objdir/$outputname
- Generated by $PROGRAM - GNU $PACKAGE $VERSION$TIMESTAMP
-
- The $output program cannot be directly executed until all the libtool
- libraries that it depends on are installed.
-
- This wrapper executable should never be moved out of the build directory.
- If it is, it will not operate correctly.
-
- Currently, it simply execs the wrapper *script* "/bin/sh $output",
- but could eventually absorb all of the scripts functionality and
- exec $objdir/$outputname directly.
-*/
-EOF
- cat >> $cwrappersource<<"EOF"
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <malloc.h>
-#include <stdarg.h>
-#include <assert.h>
-#include <string.h>
-#include <ctype.h>
-#include <sys/stat.h>
-
-#if defined(PATH_MAX)
-# define LT_PATHMAX PATH_MAX
-#elif defined(MAXPATHLEN)
-# define LT_PATHMAX MAXPATHLEN
-#else
-# define LT_PATHMAX 1024
-#endif
-
-#ifndef DIR_SEPARATOR
-# define DIR_SEPARATOR '/'
-# define PATH_SEPARATOR ':'
-#endif
-
-#if defined (_WIN32) || defined (__MSDOS__) || defined (__DJGPP__) || \
- defined (__OS2__)
-# define HAVE_DOS_BASED_FILE_SYSTEM
-# ifndef DIR_SEPARATOR_2
-# define DIR_SEPARATOR_2 '\\'
-# endif
-# ifndef PATH_SEPARATOR_2
-# define PATH_SEPARATOR_2 ';'
-# endif
-#endif
-
-#ifndef DIR_SEPARATOR_2
-# define IS_DIR_SEPARATOR(ch) ((ch) == DIR_SEPARATOR)
-#else /* DIR_SEPARATOR_2 */
-# define IS_DIR_SEPARATOR(ch) \
- (((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2))
-#endif /* DIR_SEPARATOR_2 */
-
-#ifndef PATH_SEPARATOR_2
-# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR)
-#else /* PATH_SEPARATOR_2 */
-# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR_2)
-#endif /* PATH_SEPARATOR_2 */
-
-#define XMALLOC(type, num) ((type *) xmalloc ((num) * sizeof(type)))
-#define XFREE(stale) do { \
- if (stale) { free ((void *) stale); stale = 0; } \
-} while (0)
-
-/* -DDEBUG is fairly common in CFLAGS. */
-#undef DEBUG
-#if defined DEBUGWRAPPER
-# define DEBUG(format, ...) fprintf(stderr, format, __VA_ARGS__)
-#else
-# define DEBUG(format, ...)
-#endif
-
-const char *program_name = NULL;
-
-void * xmalloc (size_t num);
-char * xstrdup (const char *string);
-const char * base_name (const char *name);
-char * find_executable(const char *wrapper);
-int check_executable(const char *path);
-char * strendzap(char *str, const char *pat);
-void lt_fatal (const char *message, ...);
-
-int
-main (int argc, char *argv[])
-{
- char **newargz;
- int i;
-
- program_name = (char *) xstrdup (base_name (argv[0]));
- DEBUG("(main) argv[0] : %s\n",argv[0]);
- DEBUG("(main) program_name : %s\n",program_name);
- newargz = XMALLOC(char *, argc+2);
-EOF
-
- cat >> $cwrappersource <<EOF
- newargz[0] = (char *) xstrdup("$SHELL");
-EOF
-
- cat >> $cwrappersource <<"EOF"
- newargz[1] = find_executable(argv[0]);
- if (newargz[1] == NULL)
- lt_fatal("Couldn't find %s", argv[0]);
- DEBUG("(main) found exe at : %s\n",newargz[1]);
- /* we know the script has the same name, without the .exe */
- /* so make sure newargz[1] doesn't end in .exe */
- strendzap(newargz[1],".exe");
- for (i = 1; i < argc; i++)
- newargz[i+1] = xstrdup(argv[i]);
- newargz[argc+1] = NULL;
-
- for (i=0; i<argc+1; i++)
- {
- DEBUG("(main) newargz[%d] : %s\n",i,newargz[i]);
- ;
- }
-
-EOF
-
- case $host_os in
- mingw*)
- cat >> $cwrappersource <<EOF
- execv("$SHELL",(char const **)newargz);
-EOF
- ;;
- *)
- cat >> $cwrappersource <<EOF
- execv("$SHELL",newargz);
-EOF
- ;;
- esac
-
- cat >> $cwrappersource <<"EOF"
- return 127;
-}
-
-void *
-xmalloc (size_t num)
-{
- void * p = (void *) malloc (num);
- if (!p)
- lt_fatal ("Memory exhausted");
-
- return p;
-}
-
-char *
-xstrdup (const char *string)
-{
- return string ? strcpy ((char *) xmalloc (strlen (string) + 1), string) : NULL
-;
-}
-
-const char *
-base_name (const char *name)
-{
- const char *base;
-
-#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
- /* Skip over the disk name in MSDOS pathnames. */
- if (isalpha ((unsigned char)name[0]) && name[1] == ':')
- name += 2;
-#endif
-
- for (base = name; *name; name++)
- if (IS_DIR_SEPARATOR (*name))
- base = name + 1;
- return base;
-}
-
-int
-check_executable(const char * path)
-{
- struct stat st;
-
- DEBUG("(check_executable) : %s\n", path ? (*path ? path : "EMPTY!") : "NULL!");
- if ((!path) || (!*path))
- return 0;
-
- if ((stat (path, &st) >= 0) &&
- (
- /* MinGW & native WIN32 do not support S_IXOTH or S_IXGRP */
-#if defined (S_IXOTH)
- ((st.st_mode & S_IXOTH) == S_IXOTH) ||
-#endif
-#if defined (S_IXGRP)
- ((st.st_mode & S_IXGRP) == S_IXGRP) ||
-#endif
- ((st.st_mode & S_IXUSR) == S_IXUSR))
- )
- return 1;
- else
- return 0;
-}
-
-/* Searches for the full path of the wrapper. Returns
- newly allocated full path name if found, NULL otherwise */
-char *
-find_executable (const char* wrapper)
-{
- int has_slash = 0;
- const char* p;
- const char* p_next;
- /* static buffer for getcwd */
- char tmp[LT_PATHMAX + 1];
- int tmp_len;
- char* concat_name;
-
- DEBUG("(find_executable) : %s\n", wrapper ? (*wrapper ? wrapper : "EMPTY!") : "NULL!");
-
- if ((wrapper == NULL) || (*wrapper == '\0'))
- return NULL;
-
- /* Absolute path? */
-#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
- if (isalpha ((unsigned char)wrapper[0]) && wrapper[1] == ':')
- {
- concat_name = xstrdup (wrapper);
- if (check_executable(concat_name))
- return concat_name;
- XFREE(concat_name);
- }
- else
- {
-#endif
- if (IS_DIR_SEPARATOR (wrapper[0]))
- {
- concat_name = xstrdup (wrapper);
- if (check_executable(concat_name))
- return concat_name;
- XFREE(concat_name);
- }
-#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
- }
-#endif
-
- for (p = wrapper; *p; p++)
- if (*p == '/')
- {
- has_slash = 1;
- break;
- }
- if (!has_slash)
- {
- /* no slashes; search PATH */
- const char* path = getenv ("PATH");
- if (path != NULL)
- {
- for (p = path; *p; p = p_next)
- {
- const char* q;
- size_t p_len;
- for (q = p; *q; q++)
- if (IS_PATH_SEPARATOR(*q))
- break;
- p_len = q - p;
- p_next = (*q == '\0' ? q : q + 1);
- if (p_len == 0)
- {
- /* empty path: current directory */
- if (getcwd (tmp, LT_PATHMAX) == NULL)
- lt_fatal ("getcwd failed");
- tmp_len = strlen(tmp);
- concat_name = XMALLOC(char, tmp_len + 1 + strlen(wrapper) + 1);
- memcpy (concat_name, tmp, tmp_len);
- concat_name[tmp_len] = '/';
- strcpy (concat_name + tmp_len + 1, wrapper);
- }
- else
- {
- concat_name = XMALLOC(char, p_len + 1 + strlen(wrapper) + 1);
- memcpy (concat_name, p, p_len);
- concat_name[p_len] = '/';
- strcpy (concat_name + p_len + 1, wrapper);
- }
- if (check_executable(concat_name))
- return concat_name;
- XFREE(concat_name);
- }
- }
- /* not found in PATH; assume curdir */
- }
- /* Relative path | not found in path: prepend cwd */
- if (getcwd (tmp, LT_PATHMAX) == NULL)
- lt_fatal ("getcwd failed");
- tmp_len = strlen(tmp);
- concat_name = XMALLOC(char, tmp_len + 1 + strlen(wrapper) + 1);
- memcpy (concat_name, tmp, tmp_len);
- concat_name[tmp_len] = '/';
- strcpy (concat_name + tmp_len + 1, wrapper);
-
- if (check_executable(concat_name))
- return concat_name;
- XFREE(concat_name);
- return NULL;
-}
-
-char *
-strendzap(char *str, const char *pat)
-{
- size_t len, patlen;
-
- assert(str != NULL);
- assert(pat != NULL);
-
- len = strlen(str);
- patlen = strlen(pat);
-
- if (patlen <= len)
- {
- str += len - patlen;
- if (strcmp(str, pat) == 0)
- *str = '\0';
- }
- return str;
-}
-
-static void
-lt_error_core (int exit_status, const char * mode,
- const char * message, va_list ap)
-{
- fprintf (stderr, "%s: %s: ", program_name, mode);
- vfprintf (stderr, message, ap);
- fprintf (stderr, ".\n");
-
- if (exit_status >= 0)
- exit (exit_status);
-}
-
-void
-lt_fatal (const char *message, ...)
-{
- va_list ap;
- va_start (ap, message);
- lt_error_core (EXIT_FAILURE, "FATAL", message, ap);
- va_end (ap);
-}
-EOF
- # we should really use a build-platform specific compiler
- # here, but OTOH, the wrappers (shell script and this C one)
- # are only useful if you want to execute the "real" binary.
- # Since the "real" binary is built for $host, then this
- # wrapper might as well be built for $host, too.
- $run $LTCC $LTCFLAGS -s -o $cwrapper $cwrappersource
- ;;
- esac
- $rm $output
- trap "$rm $output; exit $EXIT_FAILURE" 1 2 15
-
- $echo > $output "\
-#! $SHELL
-
-# $output - temporary wrapper script for $objdir/$outputname
-# Generated by $PROGRAM - GNU $PACKAGE $VERSION$TIMESTAMP
-#
-# The $output program cannot be directly executed until all the libtool
-# libraries that it depends on are installed.
-#
-# This wrapper script should never be moved out of the build directory.
-# If it is, it will not operate correctly.
-
-# Sed substitution that helps us do robust quoting. It backslashifies
-# metacharacters that are still active within double-quoted strings.
-Xsed='${SED} -e 1s/^X//'
-sed_quote_subst='$sed_quote_subst'
-
-# The HP-UX ksh and POSIX shell print the target directory to stdout
-# if CDPATH is set.
-(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
-
-relink_command=\"$relink_command\"
-
-# This environment variable determines our operation mode.
-if test \"\$libtool_install_magic\" = \"$magic\"; then
- # install mode needs the following variable:
- notinst_deplibs='$notinst_deplibs'
-else
- # When we are sourced in execute mode, \$file and \$echo are already set.
- if test \"\$libtool_execute_magic\" != \"$magic\"; then
- echo=\"$qecho\"
- file=\"\$0\"
- # Make sure echo works.
- if test \"X\$1\" = X--no-reexec; then
- # Discard the --no-reexec flag, and continue.
- shift
- elif test \"X\`(\$echo '\t') 2>/dev/null\`\" = 'X\t'; then
- # Yippee, \$echo works!
- :
- else
- # Restart under the correct shell, and then maybe \$echo will work.
- exec $SHELL \"\$0\" --no-reexec \${1+\"\$@\"}
- fi
- fi\
-"
- $echo >> $output "\
-
- # Find the directory that this script lives in.
- thisdir=\`\$echo \"X\$file\" | \$Xsed -e 's%/[^/]*$%%'\`
- test \"x\$thisdir\" = \"x\$file\" && thisdir=.
-
- # Follow symbolic links until we get to the real thisdir.
- file=\`ls -ld \"\$file\" | ${SED} -n 's/.*-> //p'\`
- while test -n \"\$file\"; do
- destdir=\`\$echo \"X\$file\" | \$Xsed -e 's%/[^/]*\$%%'\`
-
- # If there was a directory component, then change thisdir.
- if test \"x\$destdir\" != \"x\$file\"; then
- case \"\$destdir\" in
- [\\\\/]* | [A-Za-z]:[\\\\/]*) thisdir=\"\$destdir\" ;;
- *) thisdir=\"\$thisdir/\$destdir\" ;;
- esac
- fi
-
- file=\`\$echo \"X\$file\" | \$Xsed -e 's%^.*/%%'\`
- file=\`ls -ld \"\$thisdir/\$file\" | ${SED} -n 's/.*-> //p'\`
- done
-
- # Try to get the absolute directory name.
- absdir=\`cd \"\$thisdir\" && pwd\`
- test -n \"\$absdir\" && thisdir=\"\$absdir\"
-"
-
- if test "$fast_install" = yes; then
- $echo >> $output "\
- program=lt-'$outputname'$exeext
- progdir=\"\$thisdir/$objdir\"
-
- if test ! -f \"\$progdir/\$program\" || \\
- { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | ${SED} 1q\`; \\
- test \"X\$file\" != \"X\$progdir/\$program\"; }; then
-
- file=\"\$\$-\$program\"
-
- if test ! -d \"\$progdir\"; then
- $mkdir \"\$progdir\"
- else
- $rm \"\$progdir/\$file\"
- fi"
-
- $echo >> $output "\
-
- # relink executable if necessary
- if test -n \"\$relink_command\"; then
- if relink_command_output=\`eval \$relink_command 2>&1\`; then :
- else
- $echo \"\$relink_command_output\" >&2
- $rm \"\$progdir/\$file\"
- exit $EXIT_FAILURE
- fi
- fi
-
- $mv \"\$progdir/\$file\" \"\$progdir/\$program\" 2>/dev/null ||
- { $rm \"\$progdir/\$program\";
- $mv \"\$progdir/\$file\" \"\$progdir/\$program\"; }
- $rm \"\$progdir/\$file\"
- fi"
- else
- $echo >> $output "\
- program='$outputname'
- progdir=\"\$thisdir/$objdir\"
-"
- fi
-
- $echo >> $output "\
-
- if test -f \"\$progdir/\$program\"; then"
-
- # Export our shlibpath_var if we have one.
- if test "$shlibpath_overrides_runpath" = yes && test -n "$shlibpath_var" && test -n "$temp_rpath"; then
- $echo >> $output "\
- # Add our own library path to $shlibpath_var
- $shlibpath_var=\"$temp_rpath\$$shlibpath_var\"
-
- # Some systems cannot cope with colon-terminated $shlibpath_var
- # The second colon is a workaround for a bug in BeOS R4 sed
- $shlibpath_var=\`\$echo \"X\$$shlibpath_var\" | \$Xsed -e 's/::*\$//'\`
-
- export $shlibpath_var
-"
- fi
-
- # fixup the dll searchpath if we need to.
- if test -n "$dllsearchpath"; then
- $echo >> $output "\
- # Add the dll search path components to the executable PATH
- PATH=$dllsearchpath:\$PATH
-"
- fi
-
- $echo >> $output "\
- if test \"\$libtool_execute_magic\" != \"$magic\"; then
- # Run the actual program with our arguments.
-"
- case $host in
- # Backslashes separate directories on plain windows
- *-*-mingw | *-*-os2*)
- $echo >> $output "\
- exec \"\$progdir\\\\\$program\" \${1+\"\$@\"}
-"
- ;;
-
- *)
- $echo >> $output "\
- exec \"\$progdir/\$program\" \${1+\"\$@\"}
-"
- ;;
- esac
- $echo >> $output "\
- \$echo \"\$0: cannot exec \$program \${1+\"\$@\"}\"
- exit $EXIT_FAILURE
- fi
- else
- # The program doesn't exist.
- \$echo \"\$0: error: \\\`\$progdir/\$program' does not exist\" 1>&2
- \$echo \"This script is just a wrapper for \$program.\" 1>&2
- $echo \"See the $PACKAGE documentation for more information.\" 1>&2
- exit $EXIT_FAILURE
- fi
-fi\
-"
- chmod +x $output
- fi
- exit $EXIT_SUCCESS
- ;;
- esac
-
- # See if we need to build an old-fashioned archive.
- for oldlib in $oldlibs; do
-
- if test "$build_libtool_libs" = convenience; then
- oldobjs="$libobjs_save"
- addlibs="$convenience"
- build_libtool_libs=no
- else
- if test "$build_libtool_libs" = module; then
- oldobjs="$libobjs_save"
- build_libtool_libs=no
- else
- oldobjs="$old_deplibs $non_pic_objects"
- fi
- addlibs="$old_convenience"
- fi
-
- if test -n "$addlibs"; then
- gentop="$output_objdir/${outputname}x"
- generated="$generated $gentop"
-
- func_extract_archives $gentop $addlibs
- oldobjs="$oldobjs $func_extract_archives_result"
- fi
-
- # Do each command in the archive commands.
- if test -n "$old_archive_from_new_cmds" && test "$build_libtool_libs" = yes; then
- cmds=$old_archive_from_new_cmds
- else
- # POSIX demands no paths to be encoded in archives. We have
- # to avoid creating archives with duplicate basenames if we
- # might have to extract them afterwards, e.g., when creating a
- # static archive out of a convenience library, or when linking
- # the entirety of a libtool archive into another (currently
- # not supported by libtool).
- if (for obj in $oldobjs
- do
- $echo "X$obj" | $Xsed -e 's%^.*/%%'
- done | sort | sort -uc >/dev/null 2>&1); then
- :
- else
- $echo "copying selected object files to avoid basename conflicts..."
-
- if test -z "$gentop"; then
- gentop="$output_objdir/${outputname}x"
- generated="$generated $gentop"
-
- $show "${rm}r $gentop"
- $run ${rm}r "$gentop"
- $show "$mkdir $gentop"
- $run $mkdir "$gentop"
- exit_status=$?
- if test "$exit_status" -ne 0 && test ! -d "$gentop"; then
- exit $exit_status
- fi
- fi
-
- save_oldobjs=$oldobjs
- oldobjs=
- counter=1
- for obj in $save_oldobjs
- do
- objbase=`$echo "X$obj" | $Xsed -e 's%^.*/%%'`
- case " $oldobjs " in
- " ") oldobjs=$obj ;;
- *[\ /]"$objbase "*)
- while :; do
- # Make sure we don't pick an alternate name that also
- # overlaps.
- newobj=lt$counter-$objbase
- counter=`expr $counter + 1`
- case " $oldobjs " in
- *[\ /]"$newobj "*) ;;
- *) if test ! -f "$gentop/$newobj"; then break; fi ;;
- esac
- done
- $show "ln $obj $gentop/$newobj || cp $obj $gentop/$newobj"
- $run ln "$obj" "$gentop/$newobj" ||
- $run cp "$obj" "$gentop/$newobj"
- oldobjs="$oldobjs $gentop/$newobj"
- ;;
- *) oldobjs="$oldobjs $obj" ;;
- esac
- done
- fi
-
- eval cmds=\"$old_archive_cmds\"
-
- if len=`expr "X$cmds" : ".*"` &&
- test "$len" -le "$max_cmd_len" || test "$max_cmd_len" -le -1; then
- cmds=$old_archive_cmds
- else
- # the command line is too long to link in one step, link in parts
- $echo "using piecewise archive linking..."
- save_RANLIB=$RANLIB
- RANLIB=:
- objlist=
- concat_cmds=
- save_oldobjs=$oldobjs
-
- # Is there a better way of finding the last object in the list?
- for obj in $save_oldobjs
- do
- last_oldobj=$obj
- done
- for obj in $save_oldobjs
- do
- oldobjs="$objlist $obj"
- objlist="$objlist $obj"
- eval test_cmds=\"$old_archive_cmds\"
- if len=`expr "X$test_cmds" : ".*" 2>/dev/null` &&
- test "$len" -le "$max_cmd_len"; then
- :
- else
- # the above command should be used before it gets too long
- oldobjs=$objlist
- if test "$obj" = "$last_oldobj" ; then
- RANLIB=$save_RANLIB
- fi
- test -z "$concat_cmds" || concat_cmds=$concat_cmds~
- eval concat_cmds=\"\${concat_cmds}$old_archive_cmds\"
- objlist=
- fi
- done
- RANLIB=$save_RANLIB
- oldobjs=$objlist
- if test "X$oldobjs" = "X" ; then
- eval cmds=\"\$concat_cmds\"
- else
- eval cmds=\"\$concat_cmds~\$old_archive_cmds\"
- fi
- fi
- fi
- save_ifs="$IFS"; IFS='~'
- for cmd in $cmds; do
- eval cmd=\"$cmd\"
- IFS="$save_ifs"
- $show "$cmd"
- $run eval "$cmd" || exit $?
- done
- IFS="$save_ifs"
- done
-
- if test -n "$generated"; then
- $show "${rm}r$generated"
- $run ${rm}r$generated
- fi
-
- # Now create the libtool archive.
- case $output in
- *.la)
- old_library=
- test "$build_old_libs" = yes && old_library="$libname.$libext"
- $show "creating $output"
-
- # Preserve any variables that may affect compiler behavior
- for var in $variables_saved_for_relink; do
- if eval test -z \"\${$var+set}\"; then
- relink_command="{ test -z \"\${$var+set}\" || unset $var || { $var=; export $var; }; }; $relink_command"
- elif eval var_value=\$$var; test -z "$var_value"; then
- relink_command="$var=; export $var; $relink_command"
- else
- var_value=`$echo "X$var_value" | $Xsed -e "$sed_quote_subst"`
- relink_command="$var=\"$var_value\"; export $var; $relink_command"
- fi
- done
- # Quote the link command for shipping.
- relink_command="(cd `pwd`; $SHELL $progpath $preserve_args --mode=relink $libtool_args @inst_prefix_dir@)"
- relink_command=`$echo "X$relink_command" | $Xsed -e "$sed_quote_subst"`
- if test "$hardcode_automatic" = yes ; then
- relink_command=
- fi
-
-
- # Only create the output if not a dry run.
- if test -z "$run"; then
- for installed in no yes; do
- if test "$installed" = yes; then
- if test -z "$install_libdir"; then
- break
- fi
- output="$output_objdir/$outputname"i
- # Replace all uninstalled libtool libraries with the installed ones
- newdependency_libs=
- for deplib in $dependency_libs; do
- case $deplib in
- *.la)
- name=`$echo "X$deplib" | $Xsed -e 's%^.*/%%'`
- eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib`
- if test -z "$libdir"; then
- $echo "$modename: \`$deplib' is not a valid libtool archive" 1>&2
- exit $EXIT_FAILURE
- fi
- newdependency_libs="$newdependency_libs $libdir/$name"
- ;;
- *) newdependency_libs="$newdependency_libs $deplib" ;;
- esac
- done
- dependency_libs="$newdependency_libs"
- newdlfiles=
- for lib in $dlfiles; do
- name=`$echo "X$lib" | $Xsed -e 's%^.*/%%'`
- eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib`
- if test -z "$libdir"; then
- $echo "$modename: \`$lib' is not a valid libtool archive" 1>&2
- exit $EXIT_FAILURE
- fi
- newdlfiles="$newdlfiles $libdir/$name"
- done
- dlfiles="$newdlfiles"
- newdlprefiles=
- for lib in $dlprefiles; do
- name=`$echo "X$lib" | $Xsed -e 's%^.*/%%'`
- eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib`
- if test -z "$libdir"; then
- $echo "$modename: \`$lib' is not a valid libtool archive" 1>&2
- exit $EXIT_FAILURE
- fi
- newdlprefiles="$newdlprefiles $libdir/$name"
- done
- dlprefiles="$newdlprefiles"
- else
- newdlfiles=
- for lib in $dlfiles; do
- case $lib in
- [\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;;
- *) abs=`pwd`"/$lib" ;;
- esac
- newdlfiles="$newdlfiles $abs"
- done
- dlfiles="$newdlfiles"
- newdlprefiles=
- for lib in $dlprefiles; do
- case $lib in
- [\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;;
- *) abs=`pwd`"/$lib" ;;
- esac
- newdlprefiles="$newdlprefiles $abs"
- done
- dlprefiles="$newdlprefiles"
- fi
- $rm $output
- # place dlname in correct position for cygwin
- tdlname=$dlname
- case $host,$output,$installed,$module,$dlname in
- *cygwin*,*lai,yes,no,*.dll | *mingw*,*lai,yes,no,*.dll) tdlname=../bin/$dlname ;;
- esac
- $echo > $output "\
-# $outputname - a libtool library file
-# Generated by $PROGRAM - GNU $PACKAGE $VERSION$TIMESTAMP
-#
-# Please DO NOT delete this file!
-# It is necessary for linking the library.
-
-# The name that we can dlopen(3).
-dlname='$tdlname'
-
-# Names of this library.
-library_names='$library_names'
-
-# The name of the static archive.
-old_library='$old_library'
-
-# Libraries that this one depends upon.
-dependency_libs='$dependency_libs'
-
-# Version information for $libname.
-current=$current
-age=$age
-revision=$revision
-
-# Is this an already installed library?
-installed=$installed
-
-# Should we warn about portability when linking against -modules?
-shouldnotlink=$module
-
-# Files to dlopen/dlpreopen
-dlopen='$dlfiles'
-dlpreopen='$dlprefiles'
-
-# Directory that this library needs to be installed in:
-libdir='$install_libdir'"
- if test "$installed" = no && test "$need_relink" = yes; then
- $echo >> $output "\
-relink_command=\"$relink_command\""
- fi
- done
- fi
-
- # Do a symbolic link so that the libtool archive can be found in
- # LD_LIBRARY_PATH before the program is installed.
- $show "(cd $output_objdir && $rm $outputname && $LN_S ../$outputname $outputname)"
- $run eval '(cd $output_objdir && $rm $outputname && $LN_S ../$outputname $outputname)' || exit $?
- ;;
- esac
- exit $EXIT_SUCCESS
- ;;
-
- # libtool install mode
- install)
- modename="$modename: install"
-
- # There may be an optional sh(1) argument at the beginning of
- # install_prog (especially on Windows NT).
- if test "$nonopt" = "$SHELL" || test "$nonopt" = /bin/sh ||
- # Allow the use of GNU shtool's install command.
- $echo "X$nonopt" | grep shtool > /dev/null; then
- # Aesthetically quote it.
- arg=`$echo "X$nonopt" | $Xsed -e "$sed_quote_subst"`
- case $arg in
- *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"")
- arg="\"$arg\""
- ;;
- esac
- install_prog="$arg "
- arg="$1"
- shift
- else
- install_prog=
- arg=$nonopt
- fi
-
- # The real first argument should be the name of the installation program.
- # Aesthetically quote it.
- arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"`
- case $arg in
- *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"")
- arg="\"$arg\""
- ;;
- esac
- install_prog="$install_prog$arg"
-
- # We need to accept at least all the BSD install flags.
- dest=
- files=
- opts=
- prev=
- install_type=
- isdir=no
- stripme=
- for arg
- do
- if test -n "$dest"; then
- files="$files $dest"
- dest=$arg
- continue
- fi
-
- case $arg in
- -d) isdir=yes ;;
- -f)
- case " $install_prog " in
- *[\\\ /]cp\ *) ;;
- *) prev=$arg ;;
- esac
- ;;
- -g | -m | -o) prev=$arg ;;
- -s)
- stripme=" -s"
- continue
- ;;
- -*)
- ;;
- *)
- # If the previous option needed an argument, then skip it.
- if test -n "$prev"; then
- prev=
- else
- dest=$arg
- continue
- fi
- ;;
- esac
-
- # Aesthetically quote the argument.
- arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"`
- case $arg in
- *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"")
- arg="\"$arg\""
- ;;
- esac
- install_prog="$install_prog $arg"
- done
-
- if test -z "$install_prog"; then
- $echo "$modename: you must specify an install program" 1>&2
- $echo "$help" 1>&2
- exit $EXIT_FAILURE
- fi
-
- if test -n "$prev"; then
- $echo "$modename: the \`$prev' option requires an argument" 1>&2
- $echo "$help" 1>&2
- exit $EXIT_FAILURE
- fi
-
- if test -z "$files"; then
- if test -z "$dest"; then
- $echo "$modename: no file or destination specified" 1>&2
- else
- $echo "$modename: you must specify a destination" 1>&2
- fi
- $echo "$help" 1>&2
- exit $EXIT_FAILURE
- fi
-
- # Strip any trailing slash from the destination.
- dest=`$echo "X$dest" | $Xsed -e 's%/$%%'`
-
- # Check to see that the destination is a directory.
- test -d "$dest" && isdir=yes
- if test "$isdir" = yes; then
- destdir="$dest"
- destname=
- else
- destdir=`$echo "X$dest" | $Xsed -e 's%/[^/]*$%%'`
- test "X$destdir" = "X$dest" && destdir=.
- destname=`$echo "X$dest" | $Xsed -e 's%^.*/%%'`
-
- # Not a directory, so check to see that there is only one file specified.
- set dummy $files
- if test "$#" -gt 2; then
- $echo "$modename: \`$dest' is not a directory" 1>&2
- $echo "$help" 1>&2
- exit $EXIT_FAILURE
- fi
- fi
- case $destdir in
- [\\/]* | [A-Za-z]:[\\/]*) ;;
- *)
- for file in $files; do
- case $file in
- *.lo) ;;
- *)
- $echo "$modename: \`$destdir' must be an absolute directory name" 1>&2
- $echo "$help" 1>&2
- exit $EXIT_FAILURE
- ;;
- esac
- done
- ;;
- esac
-
- # This variable tells wrapper scripts just to set variables rather
- # than running their programs.
- libtool_install_magic="$magic"
-
- staticlibs=
- future_libdirs=
- current_libdirs=
- for file in $files; do
-
- # Do each installation.
- case $file in
- *.$libext)
- # Do the static libraries later.
- staticlibs="$staticlibs $file"
- ;;
-
- *.la)
- # Check to see that this really is a libtool archive.
- if (${SED} -e '2q' $file | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then :
- else
- $echo "$modename: \`$file' is not a valid libtool archive" 1>&2
- $echo "$help" 1>&2
- exit $EXIT_FAILURE
- fi
-
- library_names=
- old_library=
- relink_command=
- # If there is no directory component, then add one.
- case $file in
- */* | *\\*) . $file ;;
- *) . ./$file ;;
- esac
-
- # Add the libdir to current_libdirs if it is the destination.
- if test "X$destdir" = "X$libdir"; then
- case "$current_libdirs " in
- *" $libdir "*) ;;
- *) current_libdirs="$current_libdirs $libdir" ;;
- esac
- else
- # Note the libdir as a future libdir.
- case "$future_libdirs " in
- *" $libdir "*) ;;
- *) future_libdirs="$future_libdirs $libdir" ;;
- esac
- fi
-
- dir=`$echo "X$file" | $Xsed -e 's%/[^/]*$%%'`/
- test "X$dir" = "X$file/" && dir=
- dir="$dir$objdir"
-
- if test -n "$relink_command"; then
- # Determine the prefix the user has applied to our future dir.
- inst_prefix_dir=`$echo "$destdir" | $SED "s%$libdir\$%%"`
-
- # Don't allow the user to place us outside of our expected
- # location b/c this prevents finding dependent libraries that
- # are installed to the same prefix.
- # At present, this check doesn't affect windows .dll's that
- # are installed into $libdir/../bin (currently, that works fine)
- # but it's something to keep an eye on.
- if test "$inst_prefix_dir" = "$destdir"; then
- $echo "$modename: error: cannot install \`$file' to a directory not ending in $libdir" 1>&2
- exit $EXIT_FAILURE
- fi
-
- if test -n "$inst_prefix_dir"; then
- # Stick the inst_prefix_dir data into the link command.
- relink_command=`$echo "$relink_command" | $SED "s%@inst_prefix_dir@%-inst-prefix-dir $inst_prefix_dir%"`
- else
- relink_command=`$echo "$relink_command" | $SED "s%@inst_prefix_dir@%%"`
- fi
-
- $echo "$modename: warning: relinking \`$file'" 1>&2
- $show "$relink_command"
- if $run eval "$relink_command"; then :
- else
- $echo "$modename: error: relink \`$file' with the above command before installing it" 1>&2
- exit $EXIT_FAILURE
- fi
- fi
-
- # See the names of the shared library.
- set dummy $library_names
- if test -n "$2"; then
- realname="$2"
- shift
- shift
-
- srcname="$realname"
- test -n "$relink_command" && srcname="$realname"T
-
- # Install the shared library and build the symlinks.
- $show "$install_prog $dir/$srcname $destdir/$realname"
- $run eval "$install_prog $dir/$srcname $destdir/$realname" || exit $?
- if test -n "$stripme" && test -n "$striplib"; then
- $show "$striplib $destdir/$realname"
- $run eval "$striplib $destdir/$realname" || exit $?
- fi
-
- if test "$#" -gt 0; then
- # Delete the old symlinks, and create new ones.
- # Try `ln -sf' first, because the `ln' binary might depend on
- # the symlink we replace! Solaris /bin/ln does not understand -f,
- # so we also need to try rm && ln -s.
- for linkname
- do
- if test "$linkname" != "$realname"; then
- $show "(cd $destdir && { $LN_S -f $realname $linkname || { $rm $linkname && $LN_S $realname $linkname; }; })"
- $run eval "(cd $destdir && { $LN_S -f $realname $linkname || { $rm $linkname && $LN_S $realname $linkname; }; })"
- fi
- done
- fi
-
- # Do each command in the postinstall commands.
- lib="$destdir/$realname"
- cmds=$postinstall_cmds
- save_ifs="$IFS"; IFS='~'
- for cmd in $cmds; do
- IFS="$save_ifs"
- eval cmd=\"$cmd\"
- $show "$cmd"
- $run eval "$cmd" || {
- lt_exit=$?
-
- # Restore the uninstalled library and exit
- if test "$mode" = relink; then
- $run eval '(cd $output_objdir && $rm ${realname}T && $mv ${realname}U $realname)'
- fi
-
- exit $lt_exit
- }
- done
- IFS="$save_ifs"
- fi
-
- # Install the pseudo-library for information purposes.
- name=`$echo "X$file" | $Xsed -e 's%^.*/%%'`
- instname="$dir/$name"i
- $show "$install_prog $instname $destdir/$name"
- $run eval "$install_prog $instname $destdir/$name" || exit $?
-
- # Maybe install the static library, too.
- test -n "$old_library" && staticlibs="$staticlibs $dir/$old_library"
- ;;
-
- *.lo)
- # Install (i.e. copy) a libtool object.
-
- # Figure out destination file name, if it wasn't already specified.
- if test -n "$destname"; then
- destfile="$destdir/$destname"
- else
- destfile=`$echo "X$file" | $Xsed -e 's%^.*/%%'`
- destfile="$destdir/$destfile"
- fi
-
- # Deduce the name of the destination old-style object file.
- case $destfile in
- *.lo)
- staticdest=`$echo "X$destfile" | $Xsed -e "$lo2o"`
- ;;
- *.$objext)
- staticdest="$destfile"
- destfile=
- ;;
- *)
- $echo "$modename: cannot copy a libtool object to \`$destfile'" 1>&2
- $echo "$help" 1>&2
- exit $EXIT_FAILURE
- ;;
- esac
-
- # Install the libtool object if requested.
- if test -n "$destfile"; then
- $show "$install_prog $file $destfile"
- $run eval "$install_prog $file $destfile" || exit $?
- fi
-
- # Install the old object if enabled.
- if test "$build_old_libs" = yes; then
- # Deduce the name of the old-style object file.
- staticobj=`$echo "X$file" | $Xsed -e "$lo2o"`
-
- $show "$install_prog $staticobj $staticdest"
- $run eval "$install_prog \$staticobj \$staticdest" || exit $?
- fi
- exit $EXIT_SUCCESS
- ;;
-
- *)
- # Figure out destination file name, if it wasn't already specified.
- if test -n "$destname"; then
- destfile="$destdir/$destname"
- else
- destfile=`$echo "X$file" | $Xsed -e 's%^.*/%%'`
- destfile="$destdir/$destfile"
- fi
-
- # If the file is missing, and there is a .exe on the end, strip it
- # because it is most likely a libtool script we actually want to
- # install
- stripped_ext=""
- case $file in
- *.exe)
- if test ! -f "$file"; then
- file=`$echo $file|${SED} 's,.exe$,,'`
- stripped_ext=".exe"
- fi
- ;;
- esac
-
- # Do a test to see if this is really a libtool program.
- case $host in
- *cygwin*|*mingw*)
- wrapper=`$echo $file | ${SED} -e 's,.exe$,,'`
- ;;
- *)
- wrapper=$file
- ;;
- esac
- if (${SED} -e '4q' $wrapper | grep "^# Generated by .*$PACKAGE")>/dev/null 2>&1; then
- notinst_deplibs=
- relink_command=
-
- # Note that it is not necessary on cygwin/mingw to append a dot to
- # foo even if both foo and FILE.exe exist: automatic-append-.exe
- # behavior happens only for exec(3), not for open(2)! Also, sourcing
- # `FILE.' does not work on cygwin managed mounts.
- #
- # If there is no directory component, then add one.
- case $wrapper in
- */* | *\\*) . ${wrapper} ;;
- *) . ./${wrapper} ;;
- esac
-
- # Check the variables that should have been set.
- if test -z "$notinst_deplibs"; then
- $echo "$modename: invalid libtool wrapper script \`$wrapper'" 1>&2
- exit $EXIT_FAILURE
- fi
-
- finalize=yes
- for lib in $notinst_deplibs; do
- # Check to see that each library is installed.
- libdir=
- if test -f "$lib"; then
- # If there is no directory component, then add one.
- case $lib in
- */* | *\\*) . $lib ;;
- *) . ./$lib ;;
- esac
- fi
- libfile="$libdir/"`$echo "X$lib" | $Xsed -e 's%^.*/%%g'` ### testsuite: skip nested quoting test
- if test -n "$libdir" && test ! -f "$libfile"; then
- $echo "$modename: warning: \`$lib' has not been installed in \`$libdir'" 1>&2
- finalize=no
- fi
- done
-
- relink_command=
- # Note that it is not necessary on cygwin/mingw to append a dot to
- # foo even if both foo and FILE.exe exist: automatic-append-.exe
- # behavior happens only for exec(3), not for open(2)! Also, sourcing
- # `FILE.' does not work on cygwin managed mounts.
- #
- # If there is no directory component, then add one.
- case $wrapper in
- */* | *\\*) . ${wrapper} ;;
- *) . ./${wrapper} ;;
- esac
-
- outputname=
- if test "$fast_install" = no && test -n "$relink_command"; then
- if test "$finalize" = yes && test -z "$run"; then
- tmpdir=`func_mktempdir`
- file=`$echo "X$file$stripped_ext" | $Xsed -e 's%^.*/%%'`
- outputname="$tmpdir/$file"
- # Replace the output file specification.
- relink_command=`$echo "X$relink_command" | $Xsed -e 's%@OUTPUT@%'"$outputname"'%g'`
-
- $show "$relink_command"
- if $run eval "$relink_command"; then :
- else
- $echo "$modename: error: relink \`$file' with the above command before installing it" 1>&2
- ${rm}r "$tmpdir"
- continue
- fi
- file="$outputname"
- else
- $echo "$modename: warning: cannot relink \`$file'" 1>&2
- fi
- else
- # Install the binary that we compiled earlier.
- file=`$echo "X$file$stripped_ext" | $Xsed -e "s%\([^/]*\)$%$objdir/\1%"`
- fi
- fi
-
- # remove .exe since cygwin /usr/bin/install will append another
- # one anyway
- case $install_prog,$host in
- */usr/bin/install*,*cygwin*)
- case $file:$destfile in
- *.exe:*.exe)
- # this is ok
- ;;
- *.exe:*)
- destfile=$destfile.exe
- ;;
- *:*.exe)
- destfile=`$echo $destfile | ${SED} -e 's,.exe$,,'`
- ;;
- esac
- ;;
- esac
- $show "$install_prog$stripme $file $destfile"
- $run eval "$install_prog\$stripme \$file \$destfile" || exit $?
- test -n "$outputname" && ${rm}r "$tmpdir"
- ;;
- esac
- done
-
- for file in $staticlibs; do
- name=`$echo "X$file" | $Xsed -e 's%^.*/%%'`
-
- # Set up the ranlib parameters.
- oldlib="$destdir/$name"
-
- $show "$install_prog $file $oldlib"
- $run eval "$install_prog \$file \$oldlib" || exit $?
-
- if test -n "$stripme" && test -n "$old_striplib"; then
- $show "$old_striplib $oldlib"
- $run eval "$old_striplib $oldlib" || exit $?
- fi
-
- # Do each command in the postinstall commands.
- cmds=$old_postinstall_cmds
- save_ifs="$IFS"; IFS='~'
- for cmd in $cmds; do
- IFS="$save_ifs"
- eval cmd=\"$cmd\"
- $show "$cmd"
- $run eval "$cmd" || exit $?
- done
- IFS="$save_ifs"
- done
-
- if test -n "$future_libdirs"; then
- $echo "$modename: warning: remember to run \`$progname --finish$future_libdirs'" 1>&2
- fi
-
- if test -n "$current_libdirs"; then
- # Maybe just do a dry run.
- test -n "$run" && current_libdirs=" -n$current_libdirs"
- exec_cmd='$SHELL $progpath $preserve_args --finish$current_libdirs'
- else
- exit $EXIT_SUCCESS
- fi
- ;;
-
- # libtool finish mode
- finish)
- modename="$modename: finish"
- libdirs="$nonopt"
- admincmds=
-
- if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then
- for dir
- do
- libdirs="$libdirs $dir"
- done
-
- for libdir in $libdirs; do
- if test -n "$finish_cmds"; then
- # Do each command in the finish commands.
- cmds=$finish_cmds
- save_ifs="$IFS"; IFS='~'
- for cmd in $cmds; do
- IFS="$save_ifs"
- eval cmd=\"$cmd\"
- $show "$cmd"
- $run eval "$cmd" || admincmds="$admincmds
- $cmd"
- done
- IFS="$save_ifs"
- fi
- if test -n "$finish_eval"; then
- # Do the single finish_eval.
- eval cmds=\"$finish_eval\"
- $run eval "$cmds" || admincmds="$admincmds
- $cmds"
- fi
- done
- fi
-
- # Exit here if they wanted silent mode.
- test "$show" = : && exit $EXIT_SUCCESS
-
- $echo "X----------------------------------------------------------------------" | $Xsed
- $echo "Libraries have been installed in:"
- for libdir in $libdirs; do
- $echo " $libdir"
- done
- $echo
- $echo "If you ever happen to want to link against installed libraries"
- $echo "in a given directory, LIBDIR, you must either use libtool, and"
- $echo "specify the full pathname of the library, or use the \`-LLIBDIR'"
- $echo "flag during linking and do at least one of the following:"
- if test -n "$shlibpath_var"; then
- $echo " - add LIBDIR to the \`$shlibpath_var' environment variable"
- $echo " during execution"
- fi
- if test -n "$runpath_var"; then
- $echo " - add LIBDIR to the \`$runpath_var' environment variable"
- $echo " during linking"
- fi
- if test -n "$hardcode_libdir_flag_spec"; then
- libdir=LIBDIR
- eval flag=\"$hardcode_libdir_flag_spec\"
-
- $echo " - use the \`$flag' linker flag"
- fi
- if test -n "$admincmds"; then
- $echo " - have your system administrator run these commands:$admincmds"
- fi
- if test -f /etc/ld.so.conf; then
- $echo " - have your system administrator add LIBDIR to \`/etc/ld.so.conf'"
- fi
- $echo
- $echo "See any operating system documentation about shared libraries for"
- $echo "more information, such as the ld(1) and ld.so(8) manual pages."
- $echo "X----------------------------------------------------------------------" | $Xsed
- exit $EXIT_SUCCESS
- ;;
-
- # libtool execute mode
- execute)
- modename="$modename: execute"
-
- # The first argument is the command name.
- cmd="$nonopt"
- if test -z "$cmd"; then
- $echo "$modename: you must specify a COMMAND" 1>&2
- $echo "$help"
- exit $EXIT_FAILURE
- fi
-
- # Handle -dlopen flags immediately.
- for file in $execute_dlfiles; do
- if test ! -f "$file"; then
- $echo "$modename: \`$file' is not a file" 1>&2
- $echo "$help" 1>&2
- exit $EXIT_FAILURE
- fi
-
- dir=
- case $file in
- *.la)
- # Check to see that this really is a libtool archive.
- if (${SED} -e '2q' $file | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then :
- else
- $echo "$modename: \`$lib' is not a valid libtool archive" 1>&2
- $echo "$help" 1>&2
- exit $EXIT_FAILURE
- fi
-
- # Read the libtool library.
- dlname=
- library_names=
-
- # If there is no directory component, then add one.
- case $file in
- */* | *\\*) . $file ;;
- *) . ./$file ;;
- esac
-
- # Skip this library if it cannot be dlopened.
- if test -z "$dlname"; then
- # Warn if it was a shared library.
- test -n "$library_names" && $echo "$modename: warning: \`$file' was not linked with \`-export-dynamic'"
- continue
- fi
-
- dir=`$echo "X$file" | $Xsed -e 's%/[^/]*$%%'`
- test "X$dir" = "X$file" && dir=.
-
- if test -f "$dir/$objdir/$dlname"; then
- dir="$dir/$objdir"
- else
- $echo "$modename: cannot find \`$dlname' in \`$dir' or \`$dir/$objdir'" 1>&2
- exit $EXIT_FAILURE
- fi
- ;;
-
- *.lo)
- # Just add the directory containing the .lo file.
- dir=`$echo "X$file" | $Xsed -e 's%/[^/]*$%%'`
- test "X$dir" = "X$file" && dir=.
- ;;
-
- *)
- $echo "$modename: warning \`-dlopen' is ignored for non-libtool libraries and objects" 1>&2
- continue
- ;;
- esac
-
- # Get the absolute pathname.
- absdir=`cd "$dir" && pwd`
- test -n "$absdir" && dir="$absdir"
-
- # Now add the directory to shlibpath_var.
- if eval "test -z \"\$$shlibpath_var\""; then
- eval "$shlibpath_var=\"\$dir\""
- else
- eval "$shlibpath_var=\"\$dir:\$$shlibpath_var\""
- fi
- done
-
- # This variable tells wrapper scripts just to set shlibpath_var
- # rather than running their programs.
- libtool_execute_magic="$magic"
-
- # Check if any of the arguments is a wrapper script.
- args=
- for file
- do
- case $file in
- -*) ;;
- *)
- # Do a test to see if this is really a libtool program.
- if (${SED} -e '4q' $file | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then
- # If there is no directory component, then add one.
- case $file in
- */* | *\\*) . $file ;;
- *) . ./$file ;;
- esac
-
- # Transform arg to wrapped name.
- file="$progdir/$program"
- fi
- ;;
- esac
- # Quote arguments (to preserve shell metacharacters).
- file=`$echo "X$file" | $Xsed -e "$sed_quote_subst"`
- args="$args \"$file\""
- done
-
- if test -z "$run"; then
- if test -n "$shlibpath_var"; then
- # Export the shlibpath_var.
- eval "export $shlibpath_var"
- fi
-
- # Restore saved environment variables
- if test "${save_LC_ALL+set}" = set; then
- LC_ALL="$save_LC_ALL"; export LC_ALL
- fi
- if test "${save_LANG+set}" = set; then
- LANG="$save_LANG"; export LANG
- fi
-
- # Now prepare to actually exec the command.
- exec_cmd="\$cmd$args"
- else
- # Display what would be done.
- if test -n "$shlibpath_var"; then
- eval "\$echo \"\$shlibpath_var=\$$shlibpath_var\""
- $echo "export $shlibpath_var"
- fi
- $echo "$cmd$args"
- exit $EXIT_SUCCESS
- fi
- ;;
-
- # libtool clean and uninstall mode
- clean | uninstall)
- modename="$modename: $mode"
- rm="$nonopt"
- files=
- rmforce=
- exit_status=0
-
- # This variable tells wrapper scripts just to set variables rather
- # than running their programs.
- libtool_install_magic="$magic"
-
- for arg
- do
- case $arg in
- -f) rm="$rm $arg"; rmforce=yes ;;
- -*) rm="$rm $arg" ;;
- *) files="$files $arg" ;;
- esac
- done
-
- if test -z "$rm"; then
- $echo "$modename: you must specify an RM program" 1>&2
- $echo "$help" 1>&2
- exit $EXIT_FAILURE
- fi
-
- rmdirs=
-
- origobjdir="$objdir"
- for file in $files; do
- dir=`$echo "X$file" | $Xsed -e 's%/[^/]*$%%'`
- if test "X$dir" = "X$file"; then
- dir=.
- objdir="$origobjdir"
- else
- objdir="$dir/$origobjdir"
- fi
- name=`$echo "X$file" | $Xsed -e 's%^.*/%%'`
- test "$mode" = uninstall && objdir="$dir"
-
- # Remember objdir for removal later, being careful to avoid duplicates
- if test "$mode" = clean; then
- case " $rmdirs " in
- *" $objdir "*) ;;
- *) rmdirs="$rmdirs $objdir" ;;
- esac
- fi
-
- # Don't error if the file doesn't exist and rm -f was used.
- if (test -L "$file") >/dev/null 2>&1 \
- || (test -h "$file") >/dev/null 2>&1 \
- || test -f "$file"; then
- :
- elif test -d "$file"; then
- exit_status=1
- continue
- elif test "$rmforce" = yes; then
- continue
- fi
-
- rmfiles="$file"
-
- case $name in
- *.la)
- # Possibly a libtool archive, so verify it.
- if (${SED} -e '2q' $file | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then
- . $dir/$name
-
- # Delete the libtool libraries and symlinks.
- for n in $library_names; do
- rmfiles="$rmfiles $objdir/$n"
- done
- test -n "$old_library" && rmfiles="$rmfiles $objdir/$old_library"
-
- case "$mode" in
- clean)
- case " $library_names " in
- # " " in the beginning catches empty $dlname
- *" $dlname "*) ;;
- *) rmfiles="$rmfiles $objdir/$dlname" ;;
- esac
- test -n "$libdir" && rmfiles="$rmfiles $objdir/$name $objdir/${name}i"
- ;;
- uninstall)
- if test -n "$library_names"; then
- # Do each command in the postuninstall commands.
- cmds=$postuninstall_cmds
- save_ifs="$IFS"; IFS='~'
- for cmd in $cmds; do
- IFS="$save_ifs"
- eval cmd=\"$cmd\"
- $show "$cmd"
- $run eval "$cmd"
- if test "$?" -ne 0 && test "$rmforce" != yes; then
- exit_status=1
- fi
- done
- IFS="$save_ifs"
- fi
-
- if test -n "$old_library"; then
- # Do each command in the old_postuninstall commands.
- cmds=$old_postuninstall_cmds
- save_ifs="$IFS"; IFS='~'
- for cmd in $cmds; do
- IFS="$save_ifs"
- eval cmd=\"$cmd\"
- $show "$cmd"
- $run eval "$cmd"
- if test "$?" -ne 0 && test "$rmforce" != yes; then
- exit_status=1
- fi
- done
- IFS="$save_ifs"
- fi
- # FIXME: should reinstall the best remaining shared library.
- ;;
- esac
- fi
- ;;
-
- *.lo)
- # Possibly a libtool object, so verify it.
- if (${SED} -e '2q' $file | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then
-
- # Read the .lo file
- . $dir/$name
-
- # Add PIC object to the list of files to remove.
- if test -n "$pic_object" \
- && test "$pic_object" != none; then
- rmfiles="$rmfiles $dir/$pic_object"
- fi
-
- # Add non-PIC object to the list of files to remove.
- if test -n "$non_pic_object" \
- && test "$non_pic_object" != none; then
- rmfiles="$rmfiles $dir/$non_pic_object"
- fi
- fi
- ;;
-
- *)
- if test "$mode" = clean ; then
- noexename=$name
- case $file in
- *.exe)
- file=`$echo $file|${SED} 's,.exe$,,'`
- noexename=`$echo $name|${SED} 's,.exe$,,'`
- # $file with .exe has already been added to rmfiles,
- # add $file without .exe
- rmfiles="$rmfiles $file"
- ;;
- esac
- # Do a test to see if this is a libtool program.
- if (${SED} -e '4q' $file | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then
- relink_command=
- . $dir/$noexename
-
- # note $name still contains .exe if it was in $file originally
- # as does the version of $file that was added into $rmfiles
- rmfiles="$rmfiles $objdir/$name $objdir/${name}S.${objext}"
- if test "$fast_install" = yes && test -n "$relink_command"; then
- rmfiles="$rmfiles $objdir/lt-$name"
- fi
- if test "X$noexename" != "X$name" ; then
- rmfiles="$rmfiles $objdir/lt-${noexename}.c"
- fi
- fi
- fi
- ;;
- esac
- $show "$rm $rmfiles"
- $run $rm $rmfiles || exit_status=1
- done
- objdir="$origobjdir"
-
- # Try to remove the ${objdir}s in the directories where we deleted files
- for dir in $rmdirs; do
- if test -d "$dir"; then
- $show "rmdir $dir"
- $run rmdir $dir >/dev/null 2>&1
- fi
- done
-
- exit $exit_status
- ;;
-
- "")
- $echo "$modename: you must specify a MODE" 1>&2
- $echo "$generic_help" 1>&2
- exit $EXIT_FAILURE
- ;;
- esac
-
- if test -z "$exec_cmd"; then
- $echo "$modename: invalid operation mode \`$mode'" 1>&2
- $echo "$generic_help" 1>&2
- exit $EXIT_FAILURE
- fi
-fi # test -z "$show_help"
-
-if test -n "$exec_cmd"; then
- eval exec $exec_cmd
- exit $EXIT_FAILURE
-fi
-
-# We need to display help for each of the modes.
-case $mode in
-"") $echo \
-"Usage: $modename [OPTION]... [MODE-ARG]...
-
-Provide generalized library-building support services.
-
- --config show all configuration variables
- --debug enable verbose shell tracing
--n, --dry-run display commands without modifying any files
- --features display basic configuration information and exit
- --finish same as \`--mode=finish'
- --help display this help message and exit
- --mode=MODE use operation mode MODE [default=inferred from MODE-ARGS]
- --quiet same as \`--silent'
- --silent don't print informational messages
- --tag=TAG use configuration variables from tag TAG
- --version print version information
-
-MODE must be one of the following:
-
- clean remove files from the build directory
- compile compile a source file into a libtool object
- execute automatically set library path, then run a program
- finish complete the installation of libtool libraries
- install install libraries or executables
- link create a library or an executable
- uninstall remove libraries from an installed directory
-
-MODE-ARGS vary depending on the MODE. Try \`$modename --help --mode=MODE' for
-a more detailed description of MODE.
-
-Report bugs to <bug-libtool@gnu.org>."
- exit $EXIT_SUCCESS
- ;;
-
-clean)
- $echo \
-"Usage: $modename [OPTION]... --mode=clean RM [RM-OPTION]... FILE...
-
-Remove files from the build directory.
-
-RM is the name of the program to use to delete files associated with each FILE
-(typically \`/bin/rm'). RM-OPTIONS are options (such as \`-f') to be passed
-to RM.
-
-If FILE is a libtool library, object or program, all the files associated
-with it are deleted. Otherwise, only FILE itself is deleted using RM."
- ;;
-
-compile)
- $echo \
-"Usage: $modename [OPTION]... --mode=compile COMPILE-COMMAND... SOURCEFILE
-
-Compile a source file into a libtool library object.
-
-This mode accepts the following additional options:
-
- -o OUTPUT-FILE set the output file name to OUTPUT-FILE
- -prefer-pic try to building PIC objects only
- -prefer-non-pic try to building non-PIC objects only
- -static always build a \`.o' file suitable for static linking
-
-COMPILE-COMMAND is a command to be used in creating a \`standard' object file
-from the given SOURCEFILE.
-
-The output file name is determined by removing the directory component from
-SOURCEFILE, then substituting the C source code suffix \`.c' with the
-library object suffix, \`.lo'."
- ;;
-
-execute)
- $echo \
-"Usage: $modename [OPTION]... --mode=execute COMMAND [ARGS]...
-
-Automatically set library path, then run a program.
-
-This mode accepts the following additional options:
-
- -dlopen FILE add the directory containing FILE to the library path
-
-This mode sets the library path environment variable according to \`-dlopen'
-flags.
-
-If any of the ARGS are libtool executable wrappers, then they are translated
-into their corresponding uninstalled binary, and any of their required library
-directories are added to the library path.
-
-Then, COMMAND is executed, with ARGS as arguments."
- ;;
-
-finish)
- $echo \
-"Usage: $modename [OPTION]... --mode=finish [LIBDIR]...
-
-Complete the installation of libtool libraries.
-
-Each LIBDIR is a directory that contains libtool libraries.
-
-The commands that this mode executes may require superuser privileges. Use
-the \`--dry-run' option if you just want to see what would be executed."
- ;;
-
-install)
- $echo \
-"Usage: $modename [OPTION]... --mode=install INSTALL-COMMAND...
-
-Install executables or libraries.
-
-INSTALL-COMMAND is the installation command. The first component should be
-either the \`install' or \`cp' program.
-
-The rest of the components are interpreted as arguments to that command (only
-BSD-compatible install options are recognized)."
- ;;
-
-link)
- $echo \
-"Usage: $modename [OPTION]... --mode=link LINK-COMMAND...
-
-Link object files or libraries together to form another library, or to
-create an executable program.
-
-LINK-COMMAND is a command using the C compiler that you would use to create
-a program from several object files.
-
-The following components of LINK-COMMAND are treated specially:
-
- -all-static do not do any dynamic linking at all
- -avoid-version do not add a version suffix if possible
- -dlopen FILE \`-dlpreopen' FILE if it cannot be dlopened at runtime
- -dlpreopen FILE link in FILE and add its symbols to lt_preloaded_symbols
- -export-dynamic allow symbols from OUTPUT-FILE to be resolved with dlsym(3)
- -export-symbols SYMFILE
- try to export only the symbols listed in SYMFILE
- -export-symbols-regex REGEX
- try to export only the symbols matching REGEX
- -LLIBDIR search LIBDIR for required installed libraries
- -lNAME OUTPUT-FILE requires the installed library libNAME
- -module build a library that can dlopened
- -no-fast-install disable the fast-install mode
- -no-install link a not-installable executable
- -no-undefined declare that a library does not refer to external symbols
- -o OUTPUT-FILE create OUTPUT-FILE from the specified objects
- -objectlist FILE Use a list of object files found in FILE to specify objects
- -precious-files-regex REGEX
- don't remove output files matching REGEX
- -release RELEASE specify package release information
- -rpath LIBDIR the created library will eventually be installed in LIBDIR
- -R[ ]LIBDIR add LIBDIR to the runtime path of programs and libraries
- -static do not do any dynamic linking of libtool libraries
- -version-info CURRENT[:REVISION[:AGE]]
- specify library version info [each variable defaults to 0]
-
-All other options (arguments beginning with \`-') are ignored.
-
-Every other argument is treated as a filename. Files ending in \`.la' are
-treated as uninstalled libtool libraries, other files are standard or library
-object files.
-
-If the OUTPUT-FILE ends in \`.la', then a libtool library is created,
-only library objects (\`.lo' files) may be specified, and \`-rpath' is
-required, except when creating a convenience library.
-
-If OUTPUT-FILE ends in \`.a' or \`.lib', then a standard library is created
-using \`ar' and \`ranlib', or on Windows using \`lib'.
-
-If OUTPUT-FILE ends in \`.lo' or \`.${objext}', then a reloadable object file
-is created, otherwise an executable program is created."
- ;;
-
-uninstall)
- $echo \
-"Usage: $modename [OPTION]... --mode=uninstall RM [RM-OPTION]... FILE...
-
-Remove libraries from an installation directory.
-
-RM is the name of the program to use to delete files associated with each FILE
-(typically \`/bin/rm'). RM-OPTIONS are options (such as \`-f') to be passed
-to RM.
-
-If FILE is a libtool library, all the files associated with it are deleted.
-Otherwise, only FILE itself is deleted using RM."
- ;;
-
-*)
- $echo "$modename: invalid operation mode \`$mode'" 1>&2
- $echo "$help" 1>&2
- exit $EXIT_FAILURE
- ;;
-esac
-
-$echo
-$echo "Try \`$modename --help' for more information about other modes."
-
-exit $?
-
-# The TAGs below are defined such that we never get into a situation
-# in which we disable both kinds of libraries. Given conflicting
-# choices, we go for a static library, that is the most portable,
-# since we can't tell whether shared libraries were disabled because
-# the user asked for that or because the platform doesn't support
-# them. This is particularly important on AIX, because we don't
-# support having both static and shared libraries enabled at the same
-# time on that platform, so we default to a shared-only configuration.
-# If a disable-shared tag is given, we'll fallback to a static-only
-# configuration. But we'll never go from static-only to shared-only.
-
-# ### BEGIN LIBTOOL TAG CONFIG: disable-shared
-disable_libs=shared
-# ### END LIBTOOL TAG CONFIG: disable-shared
-
-# ### BEGIN LIBTOOL TAG CONFIG: disable-static
-disable_libs=static
-# ### END LIBTOOL TAG CONFIG: disable-static
-
-# Local Variables:
-# mode:shell-script
-# sh-indentation:2
-# End:
diff --git a/contrib/ofed/libibcm/config/missing b/contrib/ofed/libibcm/config/missing
deleted file mode 100755
index 894e786..0000000
--- a/contrib/ofed/libibcm/config/missing
+++ /dev/null
@@ -1,360 +0,0 @@
-#! /bin/sh
-# Common stub for a few missing GNU programs while installing.
-
-scriptversion=2005-06-08.21
-
-# Copyright (C) 1996, 1997, 1999, 2000, 2002, 2003, 2004, 2005
-# Free Software Foundation, Inc.
-# Originally by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996.
-
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2, or (at your option)
-# any later version.
-
-# This program 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 this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
-# 02110-1301, USA.
-
-# As a special exception to the GNU General Public License, if you
-# distribute this file as part of a program that contains a
-# configuration script generated by Autoconf, you may include it under
-# the same distribution terms that you use for the rest of that program.
-
-if test $# -eq 0; then
- echo 1>&2 "Try \`$0 --help' for more information"
- exit 1
-fi
-
-run=:
-
-# In the cases where this matters, `missing' is being run in the
-# srcdir already.
-if test -f configure.ac; then
- configure_ac=configure.ac
-else
- configure_ac=configure.in
-fi
-
-msg="missing on your system"
-
-case "$1" in
---run)
- # Try to run requested program, and just exit if it succeeds.
- run=
- shift
- "$@" && exit 0
- # Exit code 63 means version mismatch. This often happens
- # when the user try to use an ancient version of a tool on
- # a file that requires a minimum version. In this case we
- # we should proceed has if the program had been absent, or
- # if --run hadn't been passed.
- if test $? = 63; then
- run=:
- msg="probably too old"
- fi
- ;;
-
- -h|--h|--he|--hel|--help)
- echo "\
-$0 [OPTION]... PROGRAM [ARGUMENT]...
-
-Handle \`PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an
-error status if there is no known handling for PROGRAM.
-
-Options:
- -h, --help display this help and exit
- -v, --version output version information and exit
- --run try to run the given command, and emulate it if it fails
-
-Supported PROGRAM values:
- aclocal touch file \`aclocal.m4'
- autoconf touch file \`configure'
- autoheader touch file \`config.h.in'
- automake touch all \`Makefile.in' files
- bison create \`y.tab.[ch]', if possible, from existing .[ch]
- flex create \`lex.yy.c', if possible, from existing .c
- help2man touch the output file
- lex create \`lex.yy.c', if possible, from existing .c
- makeinfo touch the output file
- tar try tar, gnutar, gtar, then tar without non-portable flags
- yacc create \`y.tab.[ch]', if possible, from existing .[ch]
-
-Send bug reports to <bug-automake@gnu.org>."
- exit $?
- ;;
-
- -v|--v|--ve|--ver|--vers|--versi|--versio|--version)
- echo "missing $scriptversion (GNU Automake)"
- exit $?
- ;;
-
- -*)
- echo 1>&2 "$0: Unknown \`$1' option"
- echo 1>&2 "Try \`$0 --help' for more information"
- exit 1
- ;;
-
-esac
-
-# Now exit if we have it, but it failed. Also exit now if we
-# don't have it and --version was passed (most likely to detect
-# the program).
-case "$1" in
- lex|yacc)
- # Not GNU programs, they don't have --version.
- ;;
-
- tar)
- if test -n "$run"; then
- echo 1>&2 "ERROR: \`tar' requires --run"
- exit 1
- elif test "x$2" = "x--version" || test "x$2" = "x--help"; then
- exit 1
- fi
- ;;
-
- *)
- if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
- # We have it, but it failed.
- exit 1
- elif test "x$2" = "x--version" || test "x$2" = "x--help"; then
- # Could not run --version or --help. This is probably someone
- # running `$TOOL --version' or `$TOOL --help' to check whether
- # $TOOL exists and not knowing $TOOL uses missing.
- exit 1
- fi
- ;;
-esac
-
-# If it does not exist, or fails to run (possibly an outdated version),
-# try to emulate it.
-case "$1" in
- aclocal*)
- echo 1>&2 "\
-WARNING: \`$1' is $msg. You should only need it if
- you modified \`acinclude.m4' or \`${configure_ac}'. You might want
- to install the \`Automake' and \`Perl' packages. Grab them from
- any GNU archive site."
- touch aclocal.m4
- ;;
-
- autoconf)
- echo 1>&2 "\
-WARNING: \`$1' is $msg. You should only need it if
- you modified \`${configure_ac}'. You might want to install the
- \`Autoconf' and \`GNU m4' packages. Grab them from any GNU
- archive site."
- touch configure
- ;;
-
- autoheader)
- echo 1>&2 "\
-WARNING: \`$1' is $msg. You should only need it if
- you modified \`acconfig.h' or \`${configure_ac}'. You might want
- to install the \`Autoconf' and \`GNU m4' packages. Grab them
- from any GNU archive site."
- files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' ${configure_ac}`
- test -z "$files" && files="config.h"
- touch_files=
- for f in $files; do
- case "$f" in
- *:*) touch_files="$touch_files "`echo "$f" |
- sed -e 's/^[^:]*://' -e 's/:.*//'`;;
- *) touch_files="$touch_files $f.in";;
- esac
- done
- touch $touch_files
- ;;
-
- automake*)
- echo 1>&2 "\
-WARNING: \`$1' is $msg. You should only need it if
- you modified \`Makefile.am', \`acinclude.m4' or \`${configure_ac}'.
- You might want to install the \`Automake' and \`Perl' packages.
- Grab them from any GNU archive site."
- find . -type f -name Makefile.am -print |
- sed 's/\.am$/.in/' |
- while read f; do touch "$f"; done
- ;;
-
- autom4te)
- echo 1>&2 "\
-WARNING: \`$1' is needed, but is $msg.
- You might have modified some files without having the
- proper tools for further handling them.
- You can get \`$1' as part of \`Autoconf' from any GNU
- archive site."
-
- file=`echo "$*" | sed -n 's/.*--output[ =]*\([^ ]*\).*/\1/p'`
- test -z "$file" && file=`echo "$*" | sed -n 's/.*-o[ ]*\([^ ]*\).*/\1/p'`
- if test -f "$file"; then
- touch $file
- else
- test -z "$file" || exec >$file
- echo "#! /bin/sh"
- echo "# Created by GNU Automake missing as a replacement of"
- echo "# $ $@"
- echo "exit 0"
- chmod +x $file
- exit 1
- fi
- ;;
-
- bison|yacc)
- echo 1>&2 "\
-WARNING: \`$1' $msg. You should only need it if
- you modified a \`.y' file. You may need the \`Bison' package
- in order for those modifications to take effect. You can get
- \`Bison' from any GNU archive site."
- rm -f y.tab.c y.tab.h
- if [ $# -ne 1 ]; then
- eval LASTARG="\${$#}"
- case "$LASTARG" in
- *.y)
- SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'`
- if [ -f "$SRCFILE" ]; then
- cp "$SRCFILE" y.tab.c
- fi
- SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'`
- if [ -f "$SRCFILE" ]; then
- cp "$SRCFILE" y.tab.h
- fi
- ;;
- esac
- fi
- if [ ! -f y.tab.h ]; then
- echo >y.tab.h
- fi
- if [ ! -f y.tab.c ]; then
- echo 'main() { return 0; }' >y.tab.c
- fi
- ;;
-
- lex|flex)
- echo 1>&2 "\
-WARNING: \`$1' is $msg. You should only need it if
- you modified a \`.l' file. You may need the \`Flex' package
- in order for those modifications to take effect. You can get
- \`Flex' from any GNU archive site."
- rm -f lex.yy.c
- if [ $# -ne 1 ]; then
- eval LASTARG="\${$#}"
- case "$LASTARG" in
- *.l)
- SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'`
- if [ -f "$SRCFILE" ]; then
- cp "$SRCFILE" lex.yy.c
- fi
- ;;
- esac
- fi
- if [ ! -f lex.yy.c ]; then
- echo 'main() { return 0; }' >lex.yy.c
- fi
- ;;
-
- help2man)
- echo 1>&2 "\
-WARNING: \`$1' is $msg. You should only need it if
- you modified a dependency of a manual page. You may need the
- \`Help2man' package in order for those modifications to take
- effect. You can get \`Help2man' from any GNU archive site."
-
- file=`echo "$*" | sed -n 's/.*-o \([^ ]*\).*/\1/p'`
- if test -z "$file"; then
- file=`echo "$*" | sed -n 's/.*--output=\([^ ]*\).*/\1/p'`
- fi
- if [ -f "$file" ]; then
- touch $file
- else
- test -z "$file" || exec >$file
- echo ".ab help2man is required to generate this page"
- exit 1
- fi
- ;;
-
- makeinfo)
- echo 1>&2 "\
-WARNING: \`$1' is $msg. You should only need it if
- you modified a \`.texi' or \`.texinfo' file, or any other file
- indirectly affecting the aspect of the manual. The spurious
- call might also be the consequence of using a buggy \`make' (AIX,
- DU, IRIX). You might want to install the \`Texinfo' package or
- the \`GNU make' package. Grab either from any GNU archive site."
- # The file to touch is that specified with -o ...
- file=`echo "$*" | sed -n 's/.*-o \([^ ]*\).*/\1/p'`
- if test -z "$file"; then
- # ... or it is the one specified with @setfilename ...
- infile=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'`
- file=`sed -n '/^@setfilename/ { s/.* \([^ ]*\) *$/\1/; p; q; }' $infile`
- # ... or it is derived from the source name (dir/f.texi becomes f.info)
- test -z "$file" && file=`echo "$infile" | sed 's,.*/,,;s,.[^.]*$,,'`.info
- fi
- # If the file does not exist, the user really needs makeinfo;
- # let's fail without touching anything.
- test -f $file || exit 1
- touch $file
- ;;
-
- tar)
- shift
-
- # We have already tried tar in the generic part.
- # Look for gnutar/gtar before invocation to avoid ugly error
- # messages.
- if (gnutar --version > /dev/null 2>&1); then
- gnutar "$@" && exit 0
- fi
- if (gtar --version > /dev/null 2>&1); then
- gtar "$@" && exit 0
- fi
- firstarg="$1"
- if shift; then
- case "$firstarg" in
- *o*)
- firstarg=`echo "$firstarg" | sed s/o//`
- tar "$firstarg" "$@" && exit 0
- ;;
- esac
- case "$firstarg" in
- *h*)
- firstarg=`echo "$firstarg" | sed s/h//`
- tar "$firstarg" "$@" && exit 0
- ;;
- esac
- fi
-
- echo 1>&2 "\
-WARNING: I can't seem to be able to run \`tar' with the given arguments.
- You may want to install GNU tar or Free paxutils, or check the
- command line arguments."
- exit 1
- ;;
-
- *)
- echo 1>&2 "\
-WARNING: \`$1' is needed, and is $msg.
- You might have modified some files without having the
- proper tools for further handling them. Check the \`README' file,
- it often tells you about the needed prerequisites for installing
- this package. You may also peek at any GNU archive site, in case
- some other package would contain this missing \`$1' program."
- exit 1
- ;;
-esac
-
-exit 0
-
-# Local variables:
-# eval: (add-hook 'write-file-hooks 'time-stamp)
-# time-stamp-start: "scriptversion="
-# time-stamp-format: "%:y-%02m-%02d.%02H"
-# time-stamp-end: "$"
-# End:
diff --git a/contrib/ofed/libibcm/configure b/contrib/ofed/libibcm/configure
deleted file mode 100755
index 2735510..0000000
--- a/contrib/ofed/libibcm/configure
+++ /dev/null
@@ -1,22105 +0,0 @@
-#! /bin/sh
-# Guess values for system-dependent variables and create Makefiles.
-# Generated by GNU Autoconf 2.59 for libibcm 1.0.5.
-#
-# Report bugs to <general@lists@openfabrics.org>.
-#
-# Copyright (C) 2003 Free Software Foundation, Inc.
-# This configure script is free software; the Free Software Foundation
-# gives unlimited permission to copy, distribute and modify it.
-## --------------------- ##
-## M4sh Initialization. ##
-## --------------------- ##
-
-# Be Bourne compatible
-if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then
- emulate sh
- NULLCMD=:
- # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which
- # is contrary to our usage. Disable this feature.
- alias -g '${1+"$@"}'='"$@"'
-elif test -n "${BASH_VERSION+set}" && (set -o posix) >/dev/null 2>&1; then
- set -o posix
-fi
-DUALCASE=1; export DUALCASE # for MKS sh
-
-# Support unset when possible.
-if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then
- as_unset=unset
-else
- as_unset=false
-fi
-
-
-# Work around bugs in pre-3.0 UWIN ksh.
-$as_unset ENV MAIL MAILPATH
-PS1='$ '
-PS2='> '
-PS4='+ '
-
-# NLS nuisances.
-for as_var in \
- LANG LANGUAGE LC_ADDRESS LC_ALL LC_COLLATE LC_CTYPE LC_IDENTIFICATION \
- LC_MEASUREMENT LC_MESSAGES LC_MONETARY LC_NAME LC_NUMERIC LC_PAPER \
- LC_TELEPHONE LC_TIME
-do
- if (set +x; test -z "`(eval $as_var=C; export $as_var) 2>&1`"); then
- eval $as_var=C; export $as_var
- else
- $as_unset $as_var
- fi
-done
-
-# Required to use basename.
-if expr a : '\(a\)' >/dev/null 2>&1; then
- as_expr=expr
-else
- as_expr=false
-fi
-
-if (basename /) >/dev/null 2>&1 && test "X`basename / 2>&1`" = "X/"; then
- as_basename=basename
-else
- as_basename=false
-fi
-
-
-# Name of the executable.
-as_me=`$as_basename "$0" ||
-$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \
- X"$0" : 'X\(//\)$' \| \
- X"$0" : 'X\(/\)$' \| \
- . : '\(.\)' 2>/dev/null ||
-echo X/"$0" |
- sed '/^.*\/\([^/][^/]*\)\/*$/{ s//\1/; q; }
- /^X\/\(\/\/\)$/{ s//\1/; q; }
- /^X\/\(\/\).*/{ s//\1/; q; }
- s/.*/./; q'`
-
-
-# PATH needs CR, and LINENO needs CR and PATH.
-# Avoid depending upon Character Ranges.
-as_cr_letters='abcdefghijklmnopqrstuvwxyz'
-as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ'
-as_cr_Letters=$as_cr_letters$as_cr_LETTERS
-as_cr_digits='0123456789'
-as_cr_alnum=$as_cr_Letters$as_cr_digits
-
-# The user is always right.
-if test "${PATH_SEPARATOR+set}" != set; then
- echo "#! /bin/sh" >conf$$.sh
- echo "exit 0" >>conf$$.sh
- chmod +x conf$$.sh
- if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then
- PATH_SEPARATOR=';'
- else
- PATH_SEPARATOR=:
- fi
- rm -f conf$$.sh
-fi
-
-
- as_lineno_1=$LINENO
- as_lineno_2=$LINENO
- as_lineno_3=`(expr $as_lineno_1 + 1) 2>/dev/null`
- test "x$as_lineno_1" != "x$as_lineno_2" &&
- test "x$as_lineno_3" = "x$as_lineno_2" || {
- # Find who we are. Look in the path if we contain no path at all
- # relative or not.
- case $0 in
- *[\\/]* ) as_myself=$0 ;;
- *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
- IFS=$as_save_IFS
- test -z "$as_dir" && as_dir=.
- test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break
-done
-
- ;;
- esac
- # We did not find ourselves, most probably we were run as `sh COMMAND'
- # in which case we are not to be found in the path.
- if test "x$as_myself" = x; then
- as_myself=$0
- fi
- if test ! -f "$as_myself"; then
- { echo "$as_me: error: cannot find myself; rerun with an absolute path" >&2
- { (exit 1); exit 1; }; }
- fi
- case $CONFIG_SHELL in
- '')
- as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH
-do
- IFS=$as_save_IFS
- test -z "$as_dir" && as_dir=.
- for as_base in sh bash ksh sh5; do
- case $as_dir in
- /*)
- if ("$as_dir/$as_base" -c '
- as_lineno_1=$LINENO
- as_lineno_2=$LINENO
- as_lineno_3=`(expr $as_lineno_1 + 1) 2>/dev/null`
- test "x$as_lineno_1" != "x$as_lineno_2" &&
- test "x$as_lineno_3" = "x$as_lineno_2" ') 2>/dev/null; then
- $as_unset BASH_ENV || test "${BASH_ENV+set}" != set || { BASH_ENV=; export BASH_ENV; }
- $as_unset ENV || test "${ENV+set}" != set || { ENV=; export ENV; }
- CONFIG_SHELL=$as_dir/$as_base
- export CONFIG_SHELL
- exec "$CONFIG_SHELL" "$0" ${1+"$@"}
- fi;;
- esac
- done
-done
-;;
- esac
-
- # Create $as_me.lineno as a copy of $as_myself, but with $LINENO
- # uniformly replaced by the line number. The first 'sed' inserts a
- # line-number line before each line; the second 'sed' does the real
- # work. The second script uses 'N' to pair each line-number line
- # with the numbered line, and appends trailing '-' during
- # substitution so that $LINENO is not a special case at line end.
- # (Raja R Harinath suggested sed '=', and Paul Eggert wrote the
- # second 'sed' script. Blame Lee E. McMahon for sed's syntax. :-)
- sed '=' <$as_myself |
- sed '
- N
- s,$,-,
- : loop
- s,^\(['$as_cr_digits']*\)\(.*\)[$]LINENO\([^'$as_cr_alnum'_]\),\1\2\1\3,
- t loop
- s,-$,,
- s,^['$as_cr_digits']*\n,,
- ' >$as_me.lineno &&
- chmod +x $as_me.lineno ||
- { echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2
- { (exit 1); exit 1; }; }
-
- # Don't try to exec as it changes $[0], causing all sort of problems
- # (the dirname of $[0] is not the place where we might find the
- # original and so on. Autoconf is especially sensible to this).
- . ./$as_me.lineno
- # Exit status is that of the last command.
- exit
-}
-
-
-case `echo "testing\c"; echo 1,2,3`,`echo -n testing; echo 1,2,3` in
- *c*,-n*) ECHO_N= ECHO_C='
-' ECHO_T=' ' ;;
- *c*,* ) ECHO_N=-n ECHO_C= ECHO_T= ;;
- *) ECHO_N= ECHO_C='\c' ECHO_T= ;;
-esac
-
-if expr a : '\(a\)' >/dev/null 2>&1; then
- as_expr=expr
-else
- as_expr=false
-fi
-
-rm -f conf$$ conf$$.exe conf$$.file
-echo >conf$$.file
-if ln -s conf$$.file conf$$ 2>/dev/null; then
- # We could just check for DJGPP; but this test a) works b) is more generic
- # and c) will remain valid once DJGPP supports symlinks (DJGPP 2.04).
- if test -f conf$$.exe; then
- # Don't use ln at all; we don't have any links
- as_ln_s='cp -p'
- else
- as_ln_s='ln -s'
- fi
-elif ln conf$$.file conf$$ 2>/dev/null; then
- as_ln_s=ln
-else
- as_ln_s='cp -p'
-fi
-rm -f conf$$ conf$$.exe conf$$.file
-
-if mkdir -p . 2>/dev/null; then
- as_mkdir_p=:
-else
- test -d ./-p && rmdir ./-p
- as_mkdir_p=false
-fi
-
-as_executable_p="test -f"
-
-# Sed expression to map a string onto a valid CPP name.
-as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'"
-
-# Sed expression to map a string onto a valid variable name.
-as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'"
-
-
-# IFS
-# We need space, tab and new line, in precisely that order.
-as_nl='
-'
-IFS=" $as_nl"
-
-# CDPATH.
-$as_unset CDPATH
-
-
-
-# Check that we are running under the correct shell.
-SHELL=${CONFIG_SHELL-/bin/sh}
-
-case X$ECHO in
-X*--fallback-echo)
- # Remove one level of quotation (which was required for Make).
- ECHO=`echo "$ECHO" | sed 's,\\\\\$\\$0,'$0','`
- ;;
-esac
-
-echo=${ECHO-echo}
-if test "X$1" = X--no-reexec; then
- # Discard the --no-reexec flag, and continue.
- shift
-elif test "X$1" = X--fallback-echo; then
- # Avoid inline document here, it may be left over
- :
-elif test "X`($echo '\t') 2>/dev/null`" = 'X\t' ; then
- # Yippee, $echo works!
- :
-else
- # Restart under the correct shell.
- exec $SHELL "$0" --no-reexec ${1+"$@"}
-fi
-
-if test "X$1" = X--fallback-echo; then
- # used as fallback echo
- shift
- cat <<EOF
-$*
-EOF
- exit 0
-fi
-
-# The HP-UX ksh and POSIX shell print the target directory to stdout
-# if CDPATH is set.
-(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
-
-if test -z "$ECHO"; then
-if test "X${echo_test_string+set}" != Xset; then
-# find a string as large as possible, as long as the shell can cope with it
- for cmd in 'sed 50q "$0"' 'sed 20q "$0"' 'sed 10q "$0"' 'sed 2q "$0"' 'echo test'; do
- # expected sizes: less than 2Kb, 1Kb, 512 bytes, 16 bytes, ...
- if (echo_test_string=`eval $cmd`) 2>/dev/null &&
- echo_test_string=`eval $cmd` &&
- (test "X$echo_test_string" = "X$echo_test_string") 2>/dev/null
- then
- break
- fi
- done
-fi
-
-if test "X`($echo '\t') 2>/dev/null`" = 'X\t' &&
- echo_testing_string=`($echo "$echo_test_string") 2>/dev/null` &&
- test "X$echo_testing_string" = "X$echo_test_string"; then
- :
-else
- # The Solaris, AIX, and Digital Unix default echo programs unquote
- # backslashes. This makes it impossible to quote backslashes using
- # echo "$something" | sed 's/\\/\\\\/g'
- #
- # So, first we look for a working echo in the user's PATH.
-
- lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
- for dir in $PATH /usr/ucb; do
- IFS="$lt_save_ifs"
- if (test -f $dir/echo || test -f $dir/echo$ac_exeext) &&
- test "X`($dir/echo '\t') 2>/dev/null`" = 'X\t' &&
- echo_testing_string=`($dir/echo "$echo_test_string") 2>/dev/null` &&
- test "X$echo_testing_string" = "X$echo_test_string"; then
- echo="$dir/echo"
- break
- fi
- done
- IFS="$lt_save_ifs"
-
- if test "X$echo" = Xecho; then
- # We didn't find a better echo, so look for alternatives.
- if test "X`(print -r '\t') 2>/dev/null`" = 'X\t' &&
- echo_testing_string=`(print -r "$echo_test_string") 2>/dev/null` &&
- test "X$echo_testing_string" = "X$echo_test_string"; then
- # This shell has a builtin print -r that does the trick.
- echo='print -r'
- elif (test -f /bin/ksh || test -f /bin/ksh$ac_exeext) &&
- test "X$CONFIG_SHELL" != X/bin/ksh; then
- # If we have ksh, try running configure again with it.
- ORIGINAL_CONFIG_SHELL=${CONFIG_SHELL-/bin/sh}
- export ORIGINAL_CONFIG_SHELL
- CONFIG_SHELL=/bin/ksh
- export CONFIG_SHELL
- exec $CONFIG_SHELL "$0" --no-reexec ${1+"$@"}
- else
- # Try using printf.
- echo='printf %s\n'
- if test "X`($echo '\t') 2>/dev/null`" = 'X\t' &&
- echo_testing_string=`($echo "$echo_test_string") 2>/dev/null` &&
- test "X$echo_testing_string" = "X$echo_test_string"; then
- # Cool, printf works
- :
- elif echo_testing_string=`($ORIGINAL_CONFIG_SHELL "$0" --fallback-echo '\t') 2>/dev/null` &&
- test "X$echo_testing_string" = 'X\t' &&
- echo_testing_string=`($ORIGINAL_CONFIG_SHELL "$0" --fallback-echo "$echo_test_string") 2>/dev/null` &&
- test "X$echo_testing_string" = "X$echo_test_string"; then
- CONFIG_SHELL=$ORIGINAL_CONFIG_SHELL
- export CONFIG_SHELL
- SHELL="$CONFIG_SHELL"
- export SHELL
- echo="$CONFIG_SHELL $0 --fallback-echo"
- elif echo_testing_string=`($CONFIG_SHELL "$0" --fallback-echo '\t') 2>/dev/null` &&
- test "X$echo_testing_string" = 'X\t' &&
- echo_testing_string=`($CONFIG_SHELL "$0" --fallback-echo "$echo_test_string") 2>/dev/null` &&
- test "X$echo_testing_string" = "X$echo_test_string"; then
- echo="$CONFIG_SHELL $0 --fallback-echo"
- else
- # maybe with a smaller string...
- prev=:
-
- for cmd in 'echo test' 'sed 2q "$0"' 'sed 10q "$0"' 'sed 20q "$0"' 'sed 50q "$0"'; do
- if (test "X$echo_test_string" = "X`eval $cmd`") 2>/dev/null
- then
- break
- fi
- prev="$cmd"
- done
-
- if test "$prev" != 'sed 50q "$0"'; then
- echo_test_string=`eval $prev`
- export echo_test_string
- exec ${ORIGINAL_CONFIG_SHELL-${CONFIG_SHELL-/bin/sh}} "$0" ${1+"$@"}
- else
- # Oops. We lost completely, so just stick with echo.
- echo=echo
- fi
- fi
- fi
- fi
-fi
-fi
-
-# Copy echo and quote the copy suitably for passing to libtool from
-# the Makefile, instead of quoting the original, which is used later.
-ECHO=$echo
-if test "X$ECHO" = "X$CONFIG_SHELL $0 --fallback-echo"; then
- ECHO="$CONFIG_SHELL \\\$\$0 --fallback-echo"
-fi
-
-
-
-
-tagnames=${tagnames+${tagnames},}CXX
-
-tagnames=${tagnames+${tagnames},}F77
-
-# Name of the host.
-# hostname on some systems (SVR3.2, Linux) returns a bogus exit status,
-# so uname gets run too.
-ac_hostname=`(hostname || uname -n) 2>/dev/null | sed 1q`
-
-exec 6>&1
-
-#
-# Initializations.
-#
-ac_default_prefix=/usr/local
-ac_config_libobj_dir=.
-cross_compiling=no
-subdirs=
-MFLAGS=
-MAKEFLAGS=
-SHELL=${CONFIG_SHELL-/bin/sh}
-
-# Maximum number of lines to put in a shell here document.
-# This variable seems obsolete. It should probably be removed, and
-# only ac_max_sed_lines should be used.
-: ${ac_max_here_lines=38}
-
-# Identity of this package.
-PACKAGE_NAME='libibcm'
-PACKAGE_TARNAME='libibcm'
-PACKAGE_VERSION='1.0.5'
-PACKAGE_STRING='libibcm 1.0.5'
-PACKAGE_BUGREPORT='general@lists@openfabrics.org'
-
-ac_unique_file="src/cm.c"
-# Factoring default headers for most tests.
-ac_includes_default="\
-#include <stdio.h>
-#if HAVE_SYS_TYPES_H
-# include <sys/types.h>
-#endif
-#if HAVE_SYS_STAT_H
-# include <sys/stat.h>
-#endif
-#if STDC_HEADERS
-# include <stdlib.h>
-# include <stddef.h>
-#else
-# if HAVE_STDLIB_H
-# include <stdlib.h>
-# endif
-#endif
-#if HAVE_STRING_H
-# if !STDC_HEADERS && HAVE_MEMORY_H
-# include <memory.h>
-# endif
-# include <string.h>
-#endif
-#if HAVE_STRINGS_H
-# include <strings.h>
-#endif
-#if HAVE_INTTYPES_H
-# include <inttypes.h>
-#else
-# if HAVE_STDINT_H
-# include <stdint.h>
-# endif
-#endif
-#if HAVE_UNISTD_H
-# include <unistd.h>
-#endif"
-
-ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS INSTALL_PROGRAM INSTALL_SCRIPT INSTALL_DATA CYGPATH_W PACKAGE VERSION ACLOCAL AUTOCONF AUTOMAKE AUTOHEADER MAKEINFO install_sh STRIP ac_ct_STRIP INSTALL_STRIP_PROGRAM mkdir_p AWK SET_MAKE am__leading_dot AMTAR am__tar am__untar build build_cpu build_vendor build_os host host_cpu host_vendor host_os CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC EXEEXT OBJEXT DEPDIR am__include am__quote AMDEP_TRUE AMDEP_FALSE AMDEPBACKSLASH CCDEPMODE am__fastdepCC_TRUE am__fastdepCC_FALSE EGREP LN_S ECHO AR ac_ct_AR RANLIB ac_ct_RANLIB CPP CXX CXXFLAGS ac_ct_CXX CXXDEPMODE am__fastdepCXX_TRUE am__fastdepCXX_FALSE CXXCPP F77 FFLAGS ac_ct_F77 LIBTOOL HAVE_LD_VERSION_SCRIPT_TRUE HAVE_LD_VERSION_SCRIPT_FALSE LIBOBJS LTLIBOBJS'
-ac_subst_files=''
-
-# Initialize some variables set by options.
-ac_init_help=
-ac_init_version=false
-# The variables have the same names as the options, with
-# dashes changed to underlines.
-cache_file=/dev/null
-exec_prefix=NONE
-no_create=
-no_recursion=
-prefix=NONE
-program_prefix=NONE
-program_suffix=NONE
-program_transform_name=s,x,x,
-silent=
-site=
-srcdir=
-verbose=
-x_includes=NONE
-x_libraries=NONE
-
-# Installation directory options.
-# These are left unexpanded so users can "make install exec_prefix=/foo"
-# and all the variables that are supposed to be based on exec_prefix
-# by default will actually change.
-# Use braces instead of parens because sh, perl, etc. also accept them.
-bindir='${exec_prefix}/bin'
-sbindir='${exec_prefix}/sbin'
-libexecdir='${exec_prefix}/libexec'
-datadir='${prefix}/share'
-sysconfdir='${prefix}/etc'
-sharedstatedir='${prefix}/com'
-localstatedir='${prefix}/var'
-libdir='${exec_prefix}/lib'
-includedir='${prefix}/include'
-oldincludedir='/usr/include'
-infodir='${prefix}/info'
-mandir='${prefix}/man'
-
-ac_prev=
-for ac_option
-do
- # If the previous option needs an argument, assign it.
- if test -n "$ac_prev"; then
- eval "$ac_prev=\$ac_option"
- ac_prev=
- continue
- fi
-
- ac_optarg=`expr "x$ac_option" : 'x[^=]*=\(.*\)'`
-
- # Accept the important Cygnus configure options, so we can diagnose typos.
-
- case $ac_option in
-
- -bindir | --bindir | --bindi | --bind | --bin | --bi)
- ac_prev=bindir ;;
- -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*)
- bindir=$ac_optarg ;;
-
- -build | --build | --buil | --bui | --bu)
- ac_prev=build_alias ;;
- -build=* | --build=* | --buil=* | --bui=* | --bu=*)
- build_alias=$ac_optarg ;;
-
- -cache-file | --cache-file | --cache-fil | --cache-fi \
- | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c)
- ac_prev=cache_file ;;
- -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \
- | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*)
- cache_file=$ac_optarg ;;
-
- --config-cache | -C)
- cache_file=config.cache ;;
-
- -datadir | --datadir | --datadi | --datad | --data | --dat | --da)
- ac_prev=datadir ;;
- -datadir=* | --datadir=* | --datadi=* | --datad=* | --data=* | --dat=* \
- | --da=*)
- datadir=$ac_optarg ;;
-
- -disable-* | --disable-*)
- ac_feature=`expr "x$ac_option" : 'x-*disable-\(.*\)'`
- # Reject names that are not valid shell variable names.
- expr "x$ac_feature" : ".*[^-_$as_cr_alnum]" >/dev/null &&
- { echo "$as_me: error: invalid feature name: $ac_feature" >&2
- { (exit 1); exit 1; }; }
- ac_feature=`echo $ac_feature | sed 's/-/_/g'`
- eval "enable_$ac_feature=no" ;;
-
- -enable-* | --enable-*)
- ac_feature=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'`
- # Reject names that are not valid shell variable names.
- expr "x$ac_feature" : ".*[^-_$as_cr_alnum]" >/dev/null &&
- { echo "$as_me: error: invalid feature name: $ac_feature" >&2
- { (exit 1); exit 1; }; }
- ac_feature=`echo $ac_feature | sed 's/-/_/g'`
- case $ac_option in
- *=*) ac_optarg=`echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"`;;
- *) ac_optarg=yes ;;
- esac
- eval "enable_$ac_feature='$ac_optarg'" ;;
-
- -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \
- | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \
- | --exec | --exe | --ex)
- ac_prev=exec_prefix ;;
- -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \
- | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \
- | --exec=* | --exe=* | --ex=*)
- exec_prefix=$ac_optarg ;;
-
- -gas | --gas | --ga | --g)
- # Obsolete; use --with-gas.
- with_gas=yes ;;
-
- -help | --help | --hel | --he | -h)
- ac_init_help=long ;;
- -help=r* | --help=r* | --hel=r* | --he=r* | -hr*)
- ac_init_help=recursive ;;
- -help=s* | --help=s* | --hel=s* | --he=s* | -hs*)
- ac_init_help=short ;;
-
- -host | --host | --hos | --ho)
- ac_prev=host_alias ;;
- -host=* | --host=* | --hos=* | --ho=*)
- host_alias=$ac_optarg ;;
-
- -includedir | --includedir | --includedi | --included | --include \
- | --includ | --inclu | --incl | --inc)
- ac_prev=includedir ;;
- -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \
- | --includ=* | --inclu=* | --incl=* | --inc=*)
- includedir=$ac_optarg ;;
-
- -infodir | --infodir | --infodi | --infod | --info | --inf)
- ac_prev=infodir ;;
- -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*)
- infodir=$ac_optarg ;;
-
- -libdir | --libdir | --libdi | --libd)
- ac_prev=libdir ;;
- -libdir=* | --libdir=* | --libdi=* | --libd=*)
- libdir=$ac_optarg ;;
-
- -libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \
- | --libexe | --libex | --libe)
- ac_prev=libexecdir ;;
- -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \
- | --libexe=* | --libex=* | --libe=*)
- libexecdir=$ac_optarg ;;
-
- -localstatedir | --localstatedir | --localstatedi | --localstated \
- | --localstate | --localstat | --localsta | --localst \
- | --locals | --local | --loca | --loc | --lo)
- ac_prev=localstatedir ;;
- -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \
- | --localstate=* | --localstat=* | --localsta=* | --localst=* \
- | --locals=* | --local=* | --loca=* | --loc=* | --lo=*)
- localstatedir=$ac_optarg ;;
-
- -mandir | --mandir | --mandi | --mand | --man | --ma | --m)
- ac_prev=mandir ;;
- -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*)
- mandir=$ac_optarg ;;
-
- -nfp | --nfp | --nf)
- # Obsolete; use --without-fp.
- with_fp=no ;;
-
- -no-create | --no-create | --no-creat | --no-crea | --no-cre \
- | --no-cr | --no-c | -n)
- no_create=yes ;;
-
- -no-recursion | --no-recursion | --no-recursio | --no-recursi \
- | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r)
- no_recursion=yes ;;
-
- -oldincludedir | --oldincludedir | --oldincludedi | --oldincluded \
- | --oldinclude | --oldinclud | --oldinclu | --oldincl | --oldinc \
- | --oldin | --oldi | --old | --ol | --o)
- ac_prev=oldincludedir ;;
- -oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \
- | --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \
- | --oldin=* | --oldi=* | --old=* | --ol=* | --o=*)
- oldincludedir=$ac_optarg ;;
-
- -prefix | --prefix | --prefi | --pref | --pre | --pr | --p)
- ac_prev=prefix ;;
- -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*)
- prefix=$ac_optarg ;;
-
- -program-prefix | --program-prefix | --program-prefi | --program-pref \
- | --program-pre | --program-pr | --program-p)
- ac_prev=program_prefix ;;
- -program-prefix=* | --program-prefix=* | --program-prefi=* \
- | --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*)
- program_prefix=$ac_optarg ;;
-
- -program-suffix | --program-suffix | --program-suffi | --program-suff \
- | --program-suf | --program-su | --program-s)
- ac_prev=program_suffix ;;
- -program-suffix=* | --program-suffix=* | --program-suffi=* \
- | --program-suff=* | --program-suf=* | --program-su=* | --program-s=*)
- program_suffix=$ac_optarg ;;
-
- -program-transform-name | --program-transform-name \
- | --program-transform-nam | --program-transform-na \
- | --program-transform-n | --program-transform- \
- | --program-transform | --program-transfor \
- | --program-transfo | --program-transf \
- | --program-trans | --program-tran \
- | --progr-tra | --program-tr | --program-t)
- ac_prev=program_transform_name ;;
- -program-transform-name=* | --program-transform-name=* \
- | --program-transform-nam=* | --program-transform-na=* \
- | --program-transform-n=* | --program-transform-=* \
- | --program-transform=* | --program-transfor=* \
- | --program-transfo=* | --program-transf=* \
- | --program-trans=* | --program-tran=* \
- | --progr-tra=* | --program-tr=* | --program-t=*)
- program_transform_name=$ac_optarg ;;
-
- -q | -quiet | --quiet | --quie | --qui | --qu | --q \
- | -silent | --silent | --silen | --sile | --sil)
- silent=yes ;;
-
- -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb)
- ac_prev=sbindir ;;
- -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \
- | --sbi=* | --sb=*)
- sbindir=$ac_optarg ;;
-
- -sharedstatedir | --sharedstatedir | --sharedstatedi \
- | --sharedstated | --sharedstate | --sharedstat | --sharedsta \
- | --sharedst | --shareds | --shared | --share | --shar \
- | --sha | --sh)
- ac_prev=sharedstatedir ;;
- -sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \
- | --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \
- | --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \
- | --sha=* | --sh=*)
- sharedstatedir=$ac_optarg ;;
-
- -site | --site | --sit)
- ac_prev=site ;;
- -site=* | --site=* | --sit=*)
- site=$ac_optarg ;;
-
- -srcdir | --srcdir | --srcdi | --srcd | --src | --sr)
- ac_prev=srcdir ;;
- -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*)
- srcdir=$ac_optarg ;;
-
- -sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \
- | --syscon | --sysco | --sysc | --sys | --sy)
- ac_prev=sysconfdir ;;
- -sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \
- | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*)
- sysconfdir=$ac_optarg ;;
-
- -target | --target | --targe | --targ | --tar | --ta | --t)
- ac_prev=target_alias ;;
- -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*)
- target_alias=$ac_optarg ;;
-
- -v | -verbose | --verbose | --verbos | --verbo | --verb)
- verbose=yes ;;
-
- -version | --version | --versio | --versi | --vers | -V)
- ac_init_version=: ;;
-
- -with-* | --with-*)
- ac_package=`expr "x$ac_option" : 'x-*with-\([^=]*\)'`
- # Reject names that are not valid shell variable names.
- expr "x$ac_package" : ".*[^-_$as_cr_alnum]" >/dev/null &&
- { echo "$as_me: error: invalid package name: $ac_package" >&2
- { (exit 1); exit 1; }; }
- ac_package=`echo $ac_package| sed 's/-/_/g'`
- case $ac_option in
- *=*) ac_optarg=`echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"`;;
- *) ac_optarg=yes ;;
- esac
- eval "with_$ac_package='$ac_optarg'" ;;
-
- -without-* | --without-*)
- ac_package=`expr "x$ac_option" : 'x-*without-\(.*\)'`
- # Reject names that are not valid shell variable names.
- expr "x$ac_package" : ".*[^-_$as_cr_alnum]" >/dev/null &&
- { echo "$as_me: error: invalid package name: $ac_package" >&2
- { (exit 1); exit 1; }; }
- ac_package=`echo $ac_package | sed 's/-/_/g'`
- eval "with_$ac_package=no" ;;
-
- --x)
- # Obsolete; use --with-x.
- with_x=yes ;;
-
- -x-includes | --x-includes | --x-include | --x-includ | --x-inclu \
- | --x-incl | --x-inc | --x-in | --x-i)
- ac_prev=x_includes ;;
- -x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \
- | --x-incl=* | --x-inc=* | --x-in=* | --x-i=*)
- x_includes=$ac_optarg ;;
-
- -x-libraries | --x-libraries | --x-librarie | --x-librari \
- | --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l)
- ac_prev=x_libraries ;;
- -x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \
- | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*)
- x_libraries=$ac_optarg ;;
-
- -*) { echo "$as_me: error: unrecognized option: $ac_option
-Try \`$0 --help' for more information." >&2
- { (exit 1); exit 1; }; }
- ;;
-
- *=*)
- ac_envvar=`expr "x$ac_option" : 'x\([^=]*\)='`
- # Reject names that are not valid shell variable names.
- expr "x$ac_envvar" : ".*[^_$as_cr_alnum]" >/dev/null &&
- { echo "$as_me: error: invalid variable name: $ac_envvar" >&2
- { (exit 1); exit 1; }; }
- ac_optarg=`echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"`
- eval "$ac_envvar='$ac_optarg'"
- export $ac_envvar ;;
-
- *)
- # FIXME: should be removed in autoconf 3.0.
- echo "$as_me: WARNING: you should use --build, --host, --target" >&2
- expr "x$ac_option" : ".*[^-._$as_cr_alnum]" >/dev/null &&
- echo "$as_me: WARNING: invalid host type: $ac_option" >&2
- : ${build_alias=$ac_option} ${host_alias=$ac_option} ${target_alias=$ac_option}
- ;;
-
- esac
-done
-
-if test -n "$ac_prev"; then
- ac_option=--`echo $ac_prev | sed 's/_/-/g'`
- { echo "$as_me: error: missing argument to $ac_option" >&2
- { (exit 1); exit 1; }; }
-fi
-
-# Be sure to have absolute paths.
-for ac_var in exec_prefix prefix
-do
- eval ac_val=$`echo $ac_var`
- case $ac_val in
- [\\/$]* | ?:[\\/]* | NONE | '' ) ;;
- *) { echo "$as_me: error: expected an absolute directory name for --$ac_var: $ac_val" >&2
- { (exit 1); exit 1; }; };;
- esac
-done
-
-# Be sure to have absolute paths.
-for ac_var in bindir sbindir libexecdir datadir sysconfdir sharedstatedir \
- localstatedir libdir includedir oldincludedir infodir mandir
-do
- eval ac_val=$`echo $ac_var`
- case $ac_val in
- [\\/$]* | ?:[\\/]* ) ;;
- *) { echo "$as_me: error: expected an absolute directory name for --$ac_var: $ac_val" >&2
- { (exit 1); exit 1; }; };;
- esac
-done
-
-# There might be people who depend on the old broken behavior: `$host'
-# used to hold the argument of --host etc.
-# FIXME: To remove some day.
-build=$build_alias
-host=$host_alias
-target=$target_alias
-
-# FIXME: To remove some day.
-if test "x$host_alias" != x; then
- if test "x$build_alias" = x; then
- cross_compiling=maybe
- echo "$as_me: WARNING: If you wanted to set the --build type, don't use --host.
- If a cross compiler is detected then cross compile mode will be used." >&2
- elif test "x$build_alias" != "x$host_alias"; then
- cross_compiling=yes
- fi
-fi
-
-ac_tool_prefix=
-test -n "$host_alias" && ac_tool_prefix=$host_alias-
-
-test "$silent" = yes && exec 6>/dev/null
-
-
-# Find the source files, if location was not specified.
-if test -z "$srcdir"; then
- ac_srcdir_defaulted=yes
- # Try the directory containing this script, then its parent.
- ac_confdir=`(dirname "$0") 2>/dev/null ||
-$as_expr X"$0" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
- X"$0" : 'X\(//\)[^/]' \| \
- X"$0" : 'X\(//\)$' \| \
- X"$0" : 'X\(/\)' \| \
- . : '\(.\)' 2>/dev/null ||
-echo X"$0" |
- sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; }
- /^X\(\/\/\)[^/].*/{ s//\1/; q; }
- /^X\(\/\/\)$/{ s//\1/; q; }
- /^X\(\/\).*/{ s//\1/; q; }
- s/.*/./; q'`
- srcdir=$ac_confdir
- if test ! -r $srcdir/$ac_unique_file; then
- srcdir=..
- fi
-else
- ac_srcdir_defaulted=no
-fi
-if test ! -r $srcdir/$ac_unique_file; then
- if test "$ac_srcdir_defaulted" = yes; then
- { echo "$as_me: error: cannot find sources ($ac_unique_file) in $ac_confdir or .." >&2
- { (exit 1); exit 1; }; }
- else
- { echo "$as_me: error: cannot find sources ($ac_unique_file) in $srcdir" >&2
- { (exit 1); exit 1; }; }
- fi
-fi
-(cd $srcdir && test -r ./$ac_unique_file) 2>/dev/null ||
- { echo "$as_me: error: sources are in $srcdir, but \`cd $srcdir' does not work" >&2
- { (exit 1); exit 1; }; }
-srcdir=`echo "$srcdir" | sed 's%\([^\\/]\)[\\/]*$%\1%'`
-ac_env_build_alias_set=${build_alias+set}
-ac_env_build_alias_value=$build_alias
-ac_cv_env_build_alias_set=${build_alias+set}
-ac_cv_env_build_alias_value=$build_alias
-ac_env_host_alias_set=${host_alias+set}
-ac_env_host_alias_value=$host_alias
-ac_cv_env_host_alias_set=${host_alias+set}
-ac_cv_env_host_alias_value=$host_alias
-ac_env_target_alias_set=${target_alias+set}
-ac_env_target_alias_value=$target_alias
-ac_cv_env_target_alias_set=${target_alias+set}
-ac_cv_env_target_alias_value=$target_alias
-ac_env_CC_set=${CC+set}
-ac_env_CC_value=$CC
-ac_cv_env_CC_set=${CC+set}
-ac_cv_env_CC_value=$CC
-ac_env_CFLAGS_set=${CFLAGS+set}
-ac_env_CFLAGS_value=$CFLAGS
-ac_cv_env_CFLAGS_set=${CFLAGS+set}
-ac_cv_env_CFLAGS_value=$CFLAGS
-ac_env_LDFLAGS_set=${LDFLAGS+set}
-ac_env_LDFLAGS_value=$LDFLAGS
-ac_cv_env_LDFLAGS_set=${LDFLAGS+set}
-ac_cv_env_LDFLAGS_value=$LDFLAGS
-ac_env_CPPFLAGS_set=${CPPFLAGS+set}
-ac_env_CPPFLAGS_value=$CPPFLAGS
-ac_cv_env_CPPFLAGS_set=${CPPFLAGS+set}
-ac_cv_env_CPPFLAGS_value=$CPPFLAGS
-ac_env_CPP_set=${CPP+set}
-ac_env_CPP_value=$CPP
-ac_cv_env_CPP_set=${CPP+set}
-ac_cv_env_CPP_value=$CPP
-ac_env_CXX_set=${CXX+set}
-ac_env_CXX_value=$CXX
-ac_cv_env_CXX_set=${CXX+set}
-ac_cv_env_CXX_value=$CXX
-ac_env_CXXFLAGS_set=${CXXFLAGS+set}
-ac_env_CXXFLAGS_value=$CXXFLAGS
-ac_cv_env_CXXFLAGS_set=${CXXFLAGS+set}
-ac_cv_env_CXXFLAGS_value=$CXXFLAGS
-ac_env_CXXCPP_set=${CXXCPP+set}
-ac_env_CXXCPP_value=$CXXCPP
-ac_cv_env_CXXCPP_set=${CXXCPP+set}
-ac_cv_env_CXXCPP_value=$CXXCPP
-ac_env_F77_set=${F77+set}
-ac_env_F77_value=$F77
-ac_cv_env_F77_set=${F77+set}
-ac_cv_env_F77_value=$F77
-ac_env_FFLAGS_set=${FFLAGS+set}
-ac_env_FFLAGS_value=$FFLAGS
-ac_cv_env_FFLAGS_set=${FFLAGS+set}
-ac_cv_env_FFLAGS_value=$FFLAGS
-
-#
-# Report the --help message.
-#
-if test "$ac_init_help" = "long"; then
- # Omit some internal or obsolete options to make the list less imposing.
- # This message is too long to be a string in the A/UX 3.1 sh.
- cat <<_ACEOF
-\`configure' configures libibcm 1.0.5 to adapt to many kinds of systems.
-
-Usage: $0 [OPTION]... [VAR=VALUE]...
-
-To assign environment variables (e.g., CC, CFLAGS...), specify them as
-VAR=VALUE. See below for descriptions of some of the useful variables.
-
-Defaults for the options are specified in brackets.
-
-Configuration:
- -h, --help display this help and exit
- --help=short display options specific to this package
- --help=recursive display the short help of all the included packages
- -V, --version display version information and exit
- -q, --quiet, --silent do not print \`checking...' messages
- --cache-file=FILE cache test results in FILE [disabled]
- -C, --config-cache alias for \`--cache-file=config.cache'
- -n, --no-create do not create output files
- --srcdir=DIR find the sources in DIR [configure dir or \`..']
-
-_ACEOF
-
- cat <<_ACEOF
-Installation directories:
- --prefix=PREFIX install architecture-independent files in PREFIX
- [$ac_default_prefix]
- --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX
- [PREFIX]
-
-By default, \`make install' will install all the files in
-\`$ac_default_prefix/bin', \`$ac_default_prefix/lib' etc. You can specify
-an installation prefix other than \`$ac_default_prefix' using \`--prefix',
-for instance \`--prefix=\$HOME'.
-
-For better control, use the options below.
-
-Fine tuning of the installation directories:
- --bindir=DIR user executables [EPREFIX/bin]
- --sbindir=DIR system admin executables [EPREFIX/sbin]
- --libexecdir=DIR program executables [EPREFIX/libexec]
- --datadir=DIR read-only architecture-independent data [PREFIX/share]
- --sysconfdir=DIR read-only single-machine data [PREFIX/etc]
- --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com]
- --localstatedir=DIR modifiable single-machine data [PREFIX/var]
- --libdir=DIR object code libraries [EPREFIX/lib]
- --includedir=DIR C header files [PREFIX/include]
- --oldincludedir=DIR C header files for non-gcc [/usr/include]
- --infodir=DIR info documentation [PREFIX/info]
- --mandir=DIR man documentation [PREFIX/man]
-_ACEOF
-
- cat <<\_ACEOF
-
-Program names:
- --program-prefix=PREFIX prepend PREFIX to installed program names
- --program-suffix=SUFFIX append SUFFIX to installed program names
- --program-transform-name=PROGRAM run sed PROGRAM on installed program names
-
-System types:
- --build=BUILD configure for building on BUILD [guessed]
- --host=HOST cross-compile to build programs to run on HOST [BUILD]
-_ACEOF
-fi
-
-if test -n "$ac_init_help"; then
- case $ac_init_help in
- short | recursive ) echo "Configuration of libibcm 1.0.5:";;
- esac
- cat <<\_ACEOF
-
-Optional Features:
- --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no)
- --enable-FEATURE[=ARG] include FEATURE [ARG=yes]
- --enable-shared[=PKGS]
- build shared libraries [default=yes]
- --enable-static[=PKGS]
- build static libraries [default=yes]
- --enable-fast-install[=PKGS]
- optimize for fast installation [default=yes]
- --disable-dependency-tracking speeds up one-time build
- --enable-dependency-tracking do not reject slow dependency extractors
- --disable-libtool-lock avoid locking (might break parallel builds)
- --disable-libcheck do not test for presence of ib libraries
-
-Optional Packages:
- --with-PACKAGE[=ARG] use PACKAGE [ARG=yes]
- --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no)
- --with-gnu-ld assume the C compiler uses GNU ld [default=no]
- --with-pic try to use only PIC/non-PIC objects [default=use
- both]
- --with-tags[=TAGS]
- include additional configurations [automatic]
- --with-valgrind Enable valgrind annotations - default NO
-
-Some influential environment variables:
- CC C compiler command
- CFLAGS C compiler flags
- LDFLAGS linker flags, e.g. -L<lib dir> if you have libraries in a
- nonstandard directory <lib dir>
- CPPFLAGS C/C++ preprocessor flags, e.g. -I<include dir> if you have
- headers in a nonstandard directory <include dir>
- CPP C preprocessor
- CXX C++ compiler command
- CXXFLAGS C++ compiler flags
- CXXCPP C++ preprocessor
- F77 Fortran 77 compiler command
- FFLAGS Fortran 77 compiler flags
-
-Use these variables to override the choices made by `configure' or to help
-it to find libraries and programs with nonstandard names/locations.
-
-Report bugs to <general@lists@openfabrics.org>.
-_ACEOF
-fi
-
-if test "$ac_init_help" = "recursive"; then
- # If there are subdirs, report their specific --help.
- ac_popdir=`pwd`
- for ac_dir in : $ac_subdirs_all; do test "x$ac_dir" = x: && continue
- test -d $ac_dir || continue
- ac_builddir=.
-
-if test "$ac_dir" != .; then
- ac_dir_suffix=/`echo "$ac_dir" | sed 's,^\.[\\/],,'`
- # A "../" for each directory in $ac_dir_suffix.
- ac_top_builddir=`echo "$ac_dir_suffix" | sed 's,/[^\\/]*,../,g'`
-else
- ac_dir_suffix= ac_top_builddir=
-fi
-
-case $srcdir in
- .) # No --srcdir option. We are building in place.
- ac_srcdir=.
- if test -z "$ac_top_builddir"; then
- ac_top_srcdir=.
- else
- ac_top_srcdir=`echo $ac_top_builddir | sed 's,/$,,'`
- fi ;;
- [\\/]* | ?:[\\/]* ) # Absolute path.
- ac_srcdir=$srcdir$ac_dir_suffix;
- ac_top_srcdir=$srcdir ;;
- *) # Relative path.
- ac_srcdir=$ac_top_builddir$srcdir$ac_dir_suffix
- ac_top_srcdir=$ac_top_builddir$srcdir ;;
-esac
-
-# Do not use `cd foo && pwd` to compute absolute paths, because
-# the directories may not exist.
-case `pwd` in
-.) ac_abs_builddir="$ac_dir";;
-*)
- case "$ac_dir" in
- .) ac_abs_builddir=`pwd`;;
- [\\/]* | ?:[\\/]* ) ac_abs_builddir="$ac_dir";;
- *) ac_abs_builddir=`pwd`/"$ac_dir";;
- esac;;
-esac
-case $ac_abs_builddir in
-.) ac_abs_top_builddir=${ac_top_builddir}.;;
-*)
- case ${ac_top_builddir}. in
- .) ac_abs_top_builddir=$ac_abs_builddir;;
- [\\/]* | ?:[\\/]* ) ac_abs_top_builddir=${ac_top_builddir}.;;
- *) ac_abs_top_builddir=$ac_abs_builddir/${ac_top_builddir}.;;
- esac;;
-esac
-case $ac_abs_builddir in
-.) ac_abs_srcdir=$ac_srcdir;;
-*)
- case $ac_srcdir in
- .) ac_abs_srcdir=$ac_abs_builddir;;
- [\\/]* | ?:[\\/]* ) ac_abs_srcdir=$ac_srcdir;;
- *) ac_abs_srcdir=$ac_abs_builddir/$ac_srcdir;;
- esac;;
-esac
-case $ac_abs_builddir in
-.) ac_abs_top_srcdir=$ac_top_srcdir;;
-*)
- case $ac_top_srcdir in
- .) ac_abs_top_srcdir=$ac_abs_builddir;;
- [\\/]* | ?:[\\/]* ) ac_abs_top_srcdir=$ac_top_srcdir;;
- *) ac_abs_top_srcdir=$ac_abs_builddir/$ac_top_srcdir;;
- esac;;
-esac
-
- cd $ac_dir
- # Check for guested configure; otherwise get Cygnus style configure.
- if test -f $ac_srcdir/configure.gnu; then
- echo
- $SHELL $ac_srcdir/configure.gnu --help=recursive
- elif test -f $ac_srcdir/configure; then
- echo
- $SHELL $ac_srcdir/configure --help=recursive
- elif test -f $ac_srcdir/configure.ac ||
- test -f $ac_srcdir/configure.in; then
- echo
- $ac_configure --help
- else
- echo "$as_me: WARNING: no configuration information is in $ac_dir" >&2
- fi
- cd "$ac_popdir"
- done
-fi
-
-test -n "$ac_init_help" && exit 0
-if $ac_init_version; then
- cat <<\_ACEOF
-libibcm configure 1.0.5
-generated by GNU Autoconf 2.59
-
-Copyright (C) 2003 Free Software Foundation, Inc.
-This configure script is free software; the Free Software Foundation
-gives unlimited permission to copy, distribute and modify it.
-_ACEOF
- exit 0
-fi
-exec 5>config.log
-cat >&5 <<_ACEOF
-This file contains any messages produced by compilers while
-running configure, to aid debugging if configure makes a mistake.
-
-It was created by libibcm $as_me 1.0.5, which was
-generated by GNU Autoconf 2.59. Invocation command line was
-
- $ $0 $@
-
-_ACEOF
-{
-cat <<_ASUNAME
-## --------- ##
-## Platform. ##
-## --------- ##
-
-hostname = `(hostname || uname -n) 2>/dev/null | sed 1q`
-uname -m = `(uname -m) 2>/dev/null || echo unknown`
-uname -r = `(uname -r) 2>/dev/null || echo unknown`
-uname -s = `(uname -s) 2>/dev/null || echo unknown`
-uname -v = `(uname -v) 2>/dev/null || echo unknown`
-
-/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null || echo unknown`
-/bin/uname -X = `(/bin/uname -X) 2>/dev/null || echo unknown`
-
-/bin/arch = `(/bin/arch) 2>/dev/null || echo unknown`
-/usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null || echo unknown`
-/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null || echo unknown`
-hostinfo = `(hostinfo) 2>/dev/null || echo unknown`
-/bin/machine = `(/bin/machine) 2>/dev/null || echo unknown`
-/usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null || echo unknown`
-/bin/universe = `(/bin/universe) 2>/dev/null || echo unknown`
-
-_ASUNAME
-
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
- IFS=$as_save_IFS
- test -z "$as_dir" && as_dir=.
- echo "PATH: $as_dir"
-done
-
-} >&5
-
-cat >&5 <<_ACEOF
-
-
-## ----------- ##
-## Core tests. ##
-## ----------- ##
-
-_ACEOF
-
-
-# Keep a trace of the command line.
-# Strip out --no-create and --no-recursion so they do not pile up.
-# Strip out --silent because we don't want to record it for future runs.
-# Also quote any args containing shell meta-characters.
-# Make two passes to allow for proper duplicate-argument suppression.
-ac_configure_args=
-ac_configure_args0=
-ac_configure_args1=
-ac_sep=
-ac_must_keep_next=false
-for ac_pass in 1 2
-do
- for ac_arg
- do
- case $ac_arg in
- -no-create | --no-c* | -n | -no-recursion | --no-r*) continue ;;
- -q | -quiet | --quiet | --quie | --qui | --qu | --q \
- | -silent | --silent | --silen | --sile | --sil)
- continue ;;
- *" "*|*" "*|*[\[\]\~\#\$\^\&\*\(\)\{\}\\\|\;\<\>\?\"\']*)
- ac_arg=`echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;;
- esac
- case $ac_pass in
- 1) ac_configure_args0="$ac_configure_args0 '$ac_arg'" ;;
- 2)
- ac_configure_args1="$ac_configure_args1 '$ac_arg'"
- if test $ac_must_keep_next = true; then
- ac_must_keep_next=false # Got value, back to normal.
- else
- case $ac_arg in
- *=* | --config-cache | -C | -disable-* | --disable-* \
- | -enable-* | --enable-* | -gas | --g* | -nfp | --nf* \
- | -q | -quiet | --q* | -silent | --sil* | -v | -verb* \
- | -with-* | --with-* | -without-* | --without-* | --x)
- case "$ac_configure_args0 " in
- "$ac_configure_args1"*" '$ac_arg' "* ) continue ;;
- esac
- ;;
- -* ) ac_must_keep_next=true ;;
- esac
- fi
- ac_configure_args="$ac_configure_args$ac_sep'$ac_arg'"
- # Get rid of the leading space.
- ac_sep=" "
- ;;
- esac
- done
-done
-$as_unset ac_configure_args0 || test "${ac_configure_args0+set}" != set || { ac_configure_args0=; export ac_configure_args0; }
-$as_unset ac_configure_args1 || test "${ac_configure_args1+set}" != set || { ac_configure_args1=; export ac_configure_args1; }
-
-# When interrupted or exit'd, cleanup temporary files, and complete
-# config.log. We remove comments because anyway the quotes in there
-# would cause problems or look ugly.
-# WARNING: Be sure not to use single quotes in there, as some shells,
-# such as our DU 5.0 friend, will then `close' the trap.
-trap 'exit_status=$?
- # Save into config.log some information that might help in debugging.
- {
- echo
-
- cat <<\_ASBOX
-## ---------------- ##
-## Cache variables. ##
-## ---------------- ##
-_ASBOX
- echo
- # The following way of writing the cache mishandles newlines in values,
-{
- (set) 2>&1 |
- case `(ac_space='"'"' '"'"'; set | grep ac_space) 2>&1` in
- *ac_space=\ *)
- sed -n \
- "s/'"'"'/'"'"'\\\\'"'"''"'"'/g;
- s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='"'"'\\2'"'"'/p"
- ;;
- *)
- sed -n \
- "s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1=\\2/p"
- ;;
- esac;
-}
- echo
-
- cat <<\_ASBOX
-## ----------------- ##
-## Output variables. ##
-## ----------------- ##
-_ASBOX
- echo
- for ac_var in $ac_subst_vars
- do
- eval ac_val=$`echo $ac_var`
- echo "$ac_var='"'"'$ac_val'"'"'"
- done | sort
- echo
-
- if test -n "$ac_subst_files"; then
- cat <<\_ASBOX
-## ------------- ##
-## Output files. ##
-## ------------- ##
-_ASBOX
- echo
- for ac_var in $ac_subst_files
- do
- eval ac_val=$`echo $ac_var`
- echo "$ac_var='"'"'$ac_val'"'"'"
- done | sort
- echo
- fi
-
- if test -s confdefs.h; then
- cat <<\_ASBOX
-## ----------- ##
-## confdefs.h. ##
-## ----------- ##
-_ASBOX
- echo
- sed "/^$/d" confdefs.h | sort
- echo
- fi
- test "$ac_signal" != 0 &&
- echo "$as_me: caught signal $ac_signal"
- echo "$as_me: exit $exit_status"
- } >&5
- rm -f core *.core &&
- rm -rf conftest* confdefs* conf$$* $ac_clean_files &&
- exit $exit_status
- ' 0
-for ac_signal in 1 2 13 15; do
- trap 'ac_signal='$ac_signal'; { (exit 1); exit 1; }' $ac_signal
-done
-ac_signal=0
-
-# confdefs.h avoids OS command line length limits that DEFS can exceed.
-rm -rf conftest* confdefs.h
-# AIX cpp loses on an empty file, so make sure it contains at least a newline.
-echo >confdefs.h
-
-# Predefined preprocessor variables.
-
-cat >>confdefs.h <<_ACEOF
-#define PACKAGE_NAME "$PACKAGE_NAME"
-_ACEOF
-
-
-cat >>confdefs.h <<_ACEOF
-#define PACKAGE_TARNAME "$PACKAGE_TARNAME"
-_ACEOF
-
-
-cat >>confdefs.h <<_ACEOF
-#define PACKAGE_VERSION "$PACKAGE_VERSION"
-_ACEOF
-
-
-cat >>confdefs.h <<_ACEOF
-#define PACKAGE_STRING "$PACKAGE_STRING"
-_ACEOF
-
-
-cat >>confdefs.h <<_ACEOF
-#define PACKAGE_BUGREPORT "$PACKAGE_BUGREPORT"
-_ACEOF
-
-
-# Let the site file select an alternate cache file if it wants to.
-# Prefer explicitly selected file to automatically selected ones.
-if test -z "$CONFIG_SITE"; then
- if test "x$prefix" != xNONE; then
- CONFIG_SITE="$prefix/share/config.site $prefix/etc/config.site"
- else
- CONFIG_SITE="$ac_default_prefix/share/config.site $ac_default_prefix/etc/config.site"
- fi
-fi
-for ac_site_file in $CONFIG_SITE; do
- if test -r "$ac_site_file"; then
- { echo "$as_me:$LINENO: loading site script $ac_site_file" >&5
-echo "$as_me: loading site script $ac_site_file" >&6;}
- sed 's/^/| /' "$ac_site_file" >&5
- . "$ac_site_file"
- fi
-done
-
-if test -r "$cache_file"; then
- # Some versions of bash will fail to source /dev/null (special
- # files actually), so we avoid doing that.
- if test -f "$cache_file"; then
- { echo "$as_me:$LINENO: loading cache $cache_file" >&5
-echo "$as_me: loading cache $cache_file" >&6;}
- case $cache_file in
- [\\/]* | ?:[\\/]* ) . $cache_file;;
- *) . ./$cache_file;;
- esac
- fi
-else
- { echo "$as_me:$LINENO: creating cache $cache_file" >&5
-echo "$as_me: creating cache $cache_file" >&6;}
- >$cache_file
-fi
-
-# Check that the precious variables saved in the cache have kept the same
-# value.
-ac_cache_corrupted=false
-for ac_var in `(set) 2>&1 |
- sed -n 's/^ac_env_\([a-zA-Z_0-9]*\)_set=.*/\1/p'`; do
- eval ac_old_set=\$ac_cv_env_${ac_var}_set
- eval ac_new_set=\$ac_env_${ac_var}_set
- eval ac_old_val="\$ac_cv_env_${ac_var}_value"
- eval ac_new_val="\$ac_env_${ac_var}_value"
- case $ac_old_set,$ac_new_set in
- set,)
- { echo "$as_me:$LINENO: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5
-echo "$as_me: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&2;}
- ac_cache_corrupted=: ;;
- ,set)
- { echo "$as_me:$LINENO: error: \`$ac_var' was not set in the previous run" >&5
-echo "$as_me: error: \`$ac_var' was not set in the previous run" >&2;}
- ac_cache_corrupted=: ;;
- ,);;
- *)
- if test "x$ac_old_val" != "x$ac_new_val"; then
- { echo "$as_me:$LINENO: error: \`$ac_var' has changed since the previous run:" >&5
-echo "$as_me: error: \`$ac_var' has changed since the previous run:" >&2;}
- { echo "$as_me:$LINENO: former value: $ac_old_val" >&5
-echo "$as_me: former value: $ac_old_val" >&2;}
- { echo "$as_me:$LINENO: current value: $ac_new_val" >&5
-echo "$as_me: current value: $ac_new_val" >&2;}
- ac_cache_corrupted=:
- fi;;
- esac
- # Pass precious variables to config.status.
- if test "$ac_new_set" = set; then
- case $ac_new_val in
- *" "*|*" "*|*[\[\]\~\#\$\^\&\*\(\)\{\}\\\|\;\<\>\?\"\']*)
- ac_arg=$ac_var=`echo "$ac_new_val" | sed "s/'/'\\\\\\\\''/g"` ;;
- *) ac_arg=$ac_var=$ac_new_val ;;
- esac
- case " $ac_configure_args " in
- *" '$ac_arg' "*) ;; # Avoid dups. Use of quotes ensures accuracy.
- *) ac_configure_args="$ac_configure_args '$ac_arg'" ;;
- esac
- fi
-done
-if $ac_cache_corrupted; then
- { echo "$as_me:$LINENO: error: changes in the environment can compromise the build" >&5
-echo "$as_me: error: changes in the environment can compromise the build" >&2;}
- { { echo "$as_me:$LINENO: error: run \`make distclean' and/or \`rm $cache_file' and start over" >&5
-echo "$as_me: error: run \`make distclean' and/or \`rm $cache_file' and start over" >&2;}
- { (exit 1); exit 1; }; }
-fi
-
-ac_ext=c
-ac_cpp='$CPP $CPPFLAGS'
-ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
-ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
-ac_compiler_gnu=$ac_cv_c_compiler_gnu
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-ac_aux_dir=
-for ac_dir in config $srcdir/config; do
- if test -f $ac_dir/install-sh; then
- ac_aux_dir=$ac_dir
- ac_install_sh="$ac_aux_dir/install-sh -c"
- break
- elif test -f $ac_dir/install.sh; then
- ac_aux_dir=$ac_dir
- ac_install_sh="$ac_aux_dir/install.sh -c"
- break
- elif test -f $ac_dir/shtool; then
- ac_aux_dir=$ac_dir
- ac_install_sh="$ac_aux_dir/shtool install -c"
- break
- fi
-done
-if test -z "$ac_aux_dir"; then
- { { echo "$as_me:$LINENO: error: cannot find install-sh or install.sh in config $srcdir/config" >&5
-echo "$as_me: error: cannot find install-sh or install.sh in config $srcdir/config" >&2;}
- { (exit 1); exit 1; }; }
-fi
-ac_config_guess="$SHELL $ac_aux_dir/config.guess"
-ac_config_sub="$SHELL $ac_aux_dir/config.sub"
-ac_configure="$SHELL $ac_aux_dir/configure" # This should be Cygnus configure.
-
- ac_config_headers="$ac_config_headers config.h"
-
-am__api_version="1.9"
-# Find a good install program. We prefer a C program (faster),
-# so one script is as good as another. But avoid the broken or
-# incompatible versions:
-# SysV /etc/install, /usr/sbin/install
-# SunOS /usr/etc/install
-# IRIX /sbin/install
-# AIX /bin/install
-# AmigaOS /C/install, which installs bootblocks on floppy discs
-# AIX 4 /usr/bin/installbsd, which doesn't work without a -g flag
-# AFS /usr/afsws/bin/install, which mishandles nonexistent args
-# SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff"
-# OS/2's system install, which has a completely different semantic
-# ./install, which can be erroneously created by make from ./install.sh.
-echo "$as_me:$LINENO: checking for a BSD-compatible install" >&5
-echo $ECHO_N "checking for a BSD-compatible install... $ECHO_C" >&6
-if test -z "$INSTALL"; then
-if test "${ac_cv_path_install+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
- IFS=$as_save_IFS
- test -z "$as_dir" && as_dir=.
- # Account for people who put trailing slashes in PATH elements.
-case $as_dir/ in
- ./ | .// | /cC/* | \
- /etc/* | /usr/sbin/* | /usr/etc/* | /sbin/* | /usr/afsws/bin/* | \
- ?:\\/os2\\/install\\/* | ?:\\/OS2\\/INSTALL\\/* | \
- /usr/ucb/* ) ;;
- *)
- # OSF1 and SCO ODT 3.0 have their own names for install.
- # Don't use installbsd from OSF since it installs stuff as root
- # by default.
- for ac_prog in ginstall scoinst install; do
- for ac_exec_ext in '' $ac_executable_extensions; do
- if $as_executable_p "$as_dir/$ac_prog$ac_exec_ext"; then
- if test $ac_prog = install &&
- grep dspmsg "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then
- # AIX install. It has an incompatible calling convention.
- :
- elif test $ac_prog = install &&
- grep pwplus "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then
- # program-specific install script used by HP pwplus--don't use.
- :
- else
- ac_cv_path_install="$as_dir/$ac_prog$ac_exec_ext -c"
- break 3
- fi
- fi
- done
- done
- ;;
-esac
-done
-
-
-fi
- if test "${ac_cv_path_install+set}" = set; then
- INSTALL=$ac_cv_path_install
- else
- # As a last resort, use the slow shell script. We don't cache a
- # path for INSTALL within a source directory, because that will
- # break other packages using the cache if that directory is
- # removed, or if the path is relative.
- INSTALL=$ac_install_sh
- fi
-fi
-echo "$as_me:$LINENO: result: $INSTALL" >&5
-echo "${ECHO_T}$INSTALL" >&6
-
-# Use test -z because SunOS4 sh mishandles braces in ${var-val}.
-# It thinks the first close brace ends the variable substitution.
-test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}'
-
-test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL}'
-
-test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644'
-
-echo "$as_me:$LINENO: checking whether build environment is sane" >&5
-echo $ECHO_N "checking whether build environment is sane... $ECHO_C" >&6
-# Just in case
-sleep 1
-echo timestamp > conftest.file
-# Do `set' in a subshell so we don't clobber the current shell's
-# arguments. Must try -L first in case configure is actually a
-# symlink; some systems play weird games with the mod time of symlinks
-# (eg FreeBSD returns the mod time of the symlink's containing
-# directory).
-if (
- set X `ls -Lt $srcdir/configure conftest.file 2> /dev/null`
- if test "$*" = "X"; then
- # -L didn't work.
- set X `ls -t $srcdir/configure conftest.file`
- fi
- rm -f conftest.file
- if test "$*" != "X $srcdir/configure conftest.file" \
- && test "$*" != "X conftest.file $srcdir/configure"; then
-
- # If neither matched, then we have a broken ls. This can happen
- # if, for instance, CONFIG_SHELL is bash and it inherits a
- # broken ls alias from the environment. This has actually
- # happened. Such a system could not be considered "sane".
- { { echo "$as_me:$LINENO: error: ls -t appears to fail. Make sure there is not a broken
-alias in your environment" >&5
-echo "$as_me: error: ls -t appears to fail. Make sure there is not a broken
-alias in your environment" >&2;}
- { (exit 1); exit 1; }; }
- fi
-
- test "$2" = conftest.file
- )
-then
- # Ok.
- :
-else
- { { echo "$as_me:$LINENO: error: newly created file is older than distributed files!
-Check your system clock" >&5
-echo "$as_me: error: newly created file is older than distributed files!
-Check your system clock" >&2;}
- { (exit 1); exit 1; }; }
-fi
-echo "$as_me:$LINENO: result: yes" >&5
-echo "${ECHO_T}yes" >&6
-test "$program_prefix" != NONE &&
- program_transform_name="s,^,$program_prefix,;$program_transform_name"
-# Use a double $ so make ignores it.
-test "$program_suffix" != NONE &&
- program_transform_name="s,\$,$program_suffix,;$program_transform_name"
-# Double any \ or $. echo might interpret backslashes.
-# By default was `s,x,x', remove it if useless.
-cat <<\_ACEOF >conftest.sed
-s/[\\$]/&&/g;s/;s,x,x,$//
-_ACEOF
-program_transform_name=`echo $program_transform_name | sed -f conftest.sed`
-rm conftest.sed
-
-# expand $ac_aux_dir to an absolute path
-am_aux_dir=`cd $ac_aux_dir && pwd`
-
-test x"${MISSING+set}" = xset || MISSING="\${SHELL} $am_aux_dir/missing"
-# Use eval to expand $SHELL
-if eval "$MISSING --run true"; then
- am_missing_run="$MISSING --run "
-else
- am_missing_run=
- { echo "$as_me:$LINENO: WARNING: \`missing' script is too old or missing" >&5
-echo "$as_me: WARNING: \`missing' script is too old or missing" >&2;}
-fi
-
-if mkdir -p --version . >/dev/null 2>&1 && test ! -d ./--version; then
- # We used to keeping the `.' as first argument, in order to
- # allow $(mkdir_p) to be used without argument. As in
- # $(mkdir_p) $(somedir)
- # where $(somedir) is conditionally defined. However this is wrong
- # for two reasons:
- # 1. if the package is installed by a user who cannot write `.'
- # make install will fail,
- # 2. the above comment should most certainly read
- # $(mkdir_p) $(DESTDIR)$(somedir)
- # so it does not work when $(somedir) is undefined and
- # $(DESTDIR) is not.
- # To support the latter case, we have to write
- # test -z "$(somedir)" || $(mkdir_p) $(DESTDIR)$(somedir),
- # so the `.' trick is pointless.
- mkdir_p='mkdir -p --'
-else
- # On NextStep and OpenStep, the `mkdir' command does not
- # recognize any option. It will interpret all options as
- # directories to create, and then abort because `.' already
- # exists.
- for d in ./-p ./--version;
- do
- test -d $d && rmdir $d
- done
- # $(mkinstalldirs) is defined by Automake if mkinstalldirs exists.
- if test -f "$ac_aux_dir/mkinstalldirs"; then
- mkdir_p='$(mkinstalldirs)'
- else
- mkdir_p='$(install_sh) -d'
- fi
-fi
-
-for ac_prog in gawk mawk nawk awk
-do
- # Extract the first word of "$ac_prog", so it can be a program name with args.
-set dummy $ac_prog; ac_word=$2
-echo "$as_me:$LINENO: checking for $ac_word" >&5
-echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
-if test "${ac_cv_prog_AWK+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- if test -n "$AWK"; then
- ac_cv_prog_AWK="$AWK" # Let the user override the test.
-else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
- IFS=$as_save_IFS
- test -z "$as_dir" && as_dir=.
- for ac_exec_ext in '' $ac_executable_extensions; do
- if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
- ac_cv_prog_AWK="$ac_prog"
- echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
- break 2
- fi
-done
-done
-
-fi
-fi
-AWK=$ac_cv_prog_AWK
-if test -n "$AWK"; then
- echo "$as_me:$LINENO: result: $AWK" >&5
-echo "${ECHO_T}$AWK" >&6
-else
- echo "$as_me:$LINENO: result: no" >&5
-echo "${ECHO_T}no" >&6
-fi
-
- test -n "$AWK" && break
-done
-
-echo "$as_me:$LINENO: checking whether ${MAKE-make} sets \$(MAKE)" >&5
-echo $ECHO_N "checking whether ${MAKE-make} sets \$(MAKE)... $ECHO_C" >&6
-set dummy ${MAKE-make}; ac_make=`echo "$2" | sed 'y,:./+-,___p_,'`
-if eval "test \"\${ac_cv_prog_make_${ac_make}_set+set}\" = set"; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- cat >conftest.make <<\_ACEOF
-all:
- @echo 'ac_maketemp="$(MAKE)"'
-_ACEOF
-# GNU make sometimes prints "make[1]: Entering...", which would confuse us.
-eval `${MAKE-make} -f conftest.make 2>/dev/null | grep temp=`
-if test -n "$ac_maketemp"; then
- eval ac_cv_prog_make_${ac_make}_set=yes
-else
- eval ac_cv_prog_make_${ac_make}_set=no
-fi
-rm -f conftest.make
-fi
-if eval "test \"`echo '$ac_cv_prog_make_'${ac_make}_set`\" = yes"; then
- echo "$as_me:$LINENO: result: yes" >&5
-echo "${ECHO_T}yes" >&6
- SET_MAKE=
-else
- echo "$as_me:$LINENO: result: no" >&5
-echo "${ECHO_T}no" >&6
- SET_MAKE="MAKE=${MAKE-make}"
-fi
-
-rm -rf .tst 2>/dev/null
-mkdir .tst 2>/dev/null
-if test -d .tst; then
- am__leading_dot=.
-else
- am__leading_dot=_
-fi
-rmdir .tst 2>/dev/null
-
-# test to see if srcdir already configured
-if test "`cd $srcdir && pwd`" != "`pwd`" &&
- test -f $srcdir/config.status; then
- { { echo "$as_me:$LINENO: error: source directory already configured; run \"make distclean\" there first" >&5
-echo "$as_me: error: source directory already configured; run \"make distclean\" there first" >&2;}
- { (exit 1); exit 1; }; }
-fi
-
-# test whether we have cygpath
-if test -z "$CYGPATH_W"; then
- if (cygpath --version) >/dev/null 2>/dev/null; then
- CYGPATH_W='cygpath -w'
- else
- CYGPATH_W=echo
- fi
-fi
-
-
-# Define the identity of the package.
- PACKAGE=libibcm
- VERSION=1.0.5
-
-
-cat >>confdefs.h <<_ACEOF
-#define PACKAGE "$PACKAGE"
-_ACEOF
-
-
-cat >>confdefs.h <<_ACEOF
-#define VERSION "$VERSION"
-_ACEOF
-
-# Some tools Automake needs.
-
-ACLOCAL=${ACLOCAL-"${am_missing_run}aclocal-${am__api_version}"}
-
-
-AUTOCONF=${AUTOCONF-"${am_missing_run}autoconf"}
-
-
-AUTOMAKE=${AUTOMAKE-"${am_missing_run}automake-${am__api_version}"}
-
-
-AUTOHEADER=${AUTOHEADER-"${am_missing_run}autoheader"}
-
-
-MAKEINFO=${MAKEINFO-"${am_missing_run}makeinfo"}
-
-install_sh=${install_sh-"$am_aux_dir/install-sh"}
-
-# Installed binaries are usually stripped using `strip' when the user
-# run `make install-strip'. However `strip' might not be the right
-# tool to use in cross-compilation environments, therefore Automake
-# will honor the `STRIP' environment variable to overrule this program.
-if test "$cross_compiling" != no; then
- if test -n "$ac_tool_prefix"; then
- # Extract the first word of "${ac_tool_prefix}strip", so it can be a program name with args.
-set dummy ${ac_tool_prefix}strip; ac_word=$2
-echo "$as_me:$LINENO: checking for $ac_word" >&5
-echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
-if test "${ac_cv_prog_STRIP+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- if test -n "$STRIP"; then
- ac_cv_prog_STRIP="$STRIP" # Let the user override the test.
-else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
- IFS=$as_save_IFS
- test -z "$as_dir" && as_dir=.
- for ac_exec_ext in '' $ac_executable_extensions; do
- if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
- ac_cv_prog_STRIP="${ac_tool_prefix}strip"
- echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
- break 2
- fi
-done
-done
-
-fi
-fi
-STRIP=$ac_cv_prog_STRIP
-if test -n "$STRIP"; then
- echo "$as_me:$LINENO: result: $STRIP" >&5
-echo "${ECHO_T}$STRIP" >&6
-else
- echo "$as_me:$LINENO: result: no" >&5
-echo "${ECHO_T}no" >&6
-fi
-
-fi
-if test -z "$ac_cv_prog_STRIP"; then
- ac_ct_STRIP=$STRIP
- # Extract the first word of "strip", so it can be a program name with args.
-set dummy strip; ac_word=$2
-echo "$as_me:$LINENO: checking for $ac_word" >&5
-echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
-if test "${ac_cv_prog_ac_ct_STRIP+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- if test -n "$ac_ct_STRIP"; then
- ac_cv_prog_ac_ct_STRIP="$ac_ct_STRIP" # Let the user override the test.
-else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
- IFS=$as_save_IFS
- test -z "$as_dir" && as_dir=.
- for ac_exec_ext in '' $ac_executable_extensions; do
- if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
- ac_cv_prog_ac_ct_STRIP="strip"
- echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
- break 2
- fi
-done
-done
-
- test -z "$ac_cv_prog_ac_ct_STRIP" && ac_cv_prog_ac_ct_STRIP=":"
-fi
-fi
-ac_ct_STRIP=$ac_cv_prog_ac_ct_STRIP
-if test -n "$ac_ct_STRIP"; then
- echo "$as_me:$LINENO: result: $ac_ct_STRIP" >&5
-echo "${ECHO_T}$ac_ct_STRIP" >&6
-else
- echo "$as_me:$LINENO: result: no" >&5
-echo "${ECHO_T}no" >&6
-fi
-
- STRIP=$ac_ct_STRIP
-else
- STRIP="$ac_cv_prog_STRIP"
-fi
-
-fi
-INSTALL_STRIP_PROGRAM="\${SHELL} \$(install_sh) -c -s"
-
-# We need awk for the "check" target. The system "awk" is bad on
-# some platforms.
-# Always define AMTAR for backward compatibility.
-
-AMTAR=${AMTAR-"${am_missing_run}tar"}
-
-am__tar='${AMTAR} chof - "$$tardir"'; am__untar='${AMTAR} xf -'
-
-
-
-
-
-
-# Check whether --enable-shared or --disable-shared was given.
-if test "${enable_shared+set}" = set; then
- enableval="$enable_shared"
- p=${PACKAGE-default}
- case $enableval in
- yes) enable_shared=yes ;;
- no) enable_shared=no ;;
- *)
- enable_shared=no
- # Look at the argument we got. We use all the common list separators.
- lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR,"
- for pkg in $enableval; do
- IFS="$lt_save_ifs"
- if test "X$pkg" = "X$p"; then
- enable_shared=yes
- fi
- done
- IFS="$lt_save_ifs"
- ;;
- esac
-else
- enable_shared=yes
-fi;
-
-# Check whether --enable-static or --disable-static was given.
-if test "${enable_static+set}" = set; then
- enableval="$enable_static"
- p=${PACKAGE-default}
- case $enableval in
- yes) enable_static=yes ;;
- no) enable_static=no ;;
- *)
- enable_static=no
- # Look at the argument we got. We use all the common list separators.
- lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR,"
- for pkg in $enableval; do
- IFS="$lt_save_ifs"
- if test "X$pkg" = "X$p"; then
- enable_static=yes
- fi
- done
- IFS="$lt_save_ifs"
- ;;
- esac
-else
- enable_static=yes
-fi;
-
-# Check whether --enable-fast-install or --disable-fast-install was given.
-if test "${enable_fast_install+set}" = set; then
- enableval="$enable_fast_install"
- p=${PACKAGE-default}
- case $enableval in
- yes) enable_fast_install=yes ;;
- no) enable_fast_install=no ;;
- *)
- enable_fast_install=no
- # Look at the argument we got. We use all the common list separators.
- lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR,"
- for pkg in $enableval; do
- IFS="$lt_save_ifs"
- if test "X$pkg" = "X$p"; then
- enable_fast_install=yes
- fi
- done
- IFS="$lt_save_ifs"
- ;;
- esac
-else
- enable_fast_install=yes
-fi;
-
-# Make sure we can run config.sub.
-$ac_config_sub sun4 >/dev/null 2>&1 ||
- { { echo "$as_me:$LINENO: error: cannot run $ac_config_sub" >&5
-echo "$as_me: error: cannot run $ac_config_sub" >&2;}
- { (exit 1); exit 1; }; }
-
-echo "$as_me:$LINENO: checking build system type" >&5
-echo $ECHO_N "checking build system type... $ECHO_C" >&6
-if test "${ac_cv_build+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- ac_cv_build_alias=$build_alias
-test -z "$ac_cv_build_alias" &&
- ac_cv_build_alias=`$ac_config_guess`
-test -z "$ac_cv_build_alias" &&
- { { echo "$as_me:$LINENO: error: cannot guess build type; you must specify one" >&5
-echo "$as_me: error: cannot guess build type; you must specify one" >&2;}
- { (exit 1); exit 1; }; }
-ac_cv_build=`$ac_config_sub $ac_cv_build_alias` ||
- { { echo "$as_me:$LINENO: error: $ac_config_sub $ac_cv_build_alias failed" >&5
-echo "$as_me: error: $ac_config_sub $ac_cv_build_alias failed" >&2;}
- { (exit 1); exit 1; }; }
-
-fi
-echo "$as_me:$LINENO: result: $ac_cv_build" >&5
-echo "${ECHO_T}$ac_cv_build" >&6
-build=$ac_cv_build
-build_cpu=`echo $ac_cv_build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'`
-build_vendor=`echo $ac_cv_build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'`
-build_os=`echo $ac_cv_build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'`
-
-
-echo "$as_me:$LINENO: checking host system type" >&5
-echo $ECHO_N "checking host system type... $ECHO_C" >&6
-if test "${ac_cv_host+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- ac_cv_host_alias=$host_alias
-test -z "$ac_cv_host_alias" &&
- ac_cv_host_alias=$ac_cv_build_alias
-ac_cv_host=`$ac_config_sub $ac_cv_host_alias` ||
- { { echo "$as_me:$LINENO: error: $ac_config_sub $ac_cv_host_alias failed" >&5
-echo "$as_me: error: $ac_config_sub $ac_cv_host_alias failed" >&2;}
- { (exit 1); exit 1; }; }
-
-fi
-echo "$as_me:$LINENO: result: $ac_cv_host" >&5
-echo "${ECHO_T}$ac_cv_host" >&6
-host=$ac_cv_host
-host_cpu=`echo $ac_cv_host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'`
-host_vendor=`echo $ac_cv_host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'`
-host_os=`echo $ac_cv_host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'`
-
-
-DEPDIR="${am__leading_dot}deps"
-
- ac_config_commands="$ac_config_commands depfiles"
-
-
-am_make=${MAKE-make}
-cat > confinc << 'END'
-am__doit:
- @echo done
-.PHONY: am__doit
-END
-# If we don't find an include directive, just comment out the code.
-echo "$as_me:$LINENO: checking for style of include used by $am_make" >&5
-echo $ECHO_N "checking for style of include used by $am_make... $ECHO_C" >&6
-am__include="#"
-am__quote=
-_am_result=none
-# First try GNU make style include.
-echo "include confinc" > confmf
-# We grep out `Entering directory' and `Leaving directory'
-# messages which can occur if `w' ends up in MAKEFLAGS.
-# In particular we don't look at `^make:' because GNU make might
-# be invoked under some other name (usually "gmake"), in which
-# case it prints its new name instead of `make'.
-if test "`$am_make -s -f confmf 2> /dev/null | grep -v 'ing directory'`" = "done"; then
- am__include=include
- am__quote=
- _am_result=GNU
-fi
-# Now try BSD make style include.
-if test "$am__include" = "#"; then
- echo '.include "confinc"' > confmf
- if test "`$am_make -s -f confmf 2> /dev/null`" = "done"; then
- am__include=.include
- am__quote="\""
- _am_result=BSD
- fi
-fi
-
-
-echo "$as_me:$LINENO: result: $_am_result" >&5
-echo "${ECHO_T}$_am_result" >&6
-rm -f confinc confmf
-
-# Check whether --enable-dependency-tracking or --disable-dependency-tracking was given.
-if test "${enable_dependency_tracking+set}" = set; then
- enableval="$enable_dependency_tracking"
-
-fi;
-if test "x$enable_dependency_tracking" != xno; then
- am_depcomp="$ac_aux_dir/depcomp"
- AMDEPBACKSLASH='\'
-fi
-
-
-if test "x$enable_dependency_tracking" != xno; then
- AMDEP_TRUE=
- AMDEP_FALSE='#'
-else
- AMDEP_TRUE='#'
- AMDEP_FALSE=
-fi
-
-
-
-ac_ext=c
-ac_cpp='$CPP $CPPFLAGS'
-ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
-ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
-ac_compiler_gnu=$ac_cv_c_compiler_gnu
-if test -n "$ac_tool_prefix"; then
- # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args.
-set dummy ${ac_tool_prefix}gcc; ac_word=$2
-echo "$as_me:$LINENO: checking for $ac_word" >&5
-echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
-if test "${ac_cv_prog_CC+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- if test -n "$CC"; then
- ac_cv_prog_CC="$CC" # Let the user override the test.
-else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
- IFS=$as_save_IFS
- test -z "$as_dir" && as_dir=.
- for ac_exec_ext in '' $ac_executable_extensions; do
- if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
- ac_cv_prog_CC="${ac_tool_prefix}gcc"
- echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
- break 2
- fi
-done
-done
-
-fi
-fi
-CC=$ac_cv_prog_CC
-if test -n "$CC"; then
- echo "$as_me:$LINENO: result: $CC" >&5
-echo "${ECHO_T}$CC" >&6
-else
- echo "$as_me:$LINENO: result: no" >&5
-echo "${ECHO_T}no" >&6
-fi
-
-fi
-if test -z "$ac_cv_prog_CC"; then
- ac_ct_CC=$CC
- # Extract the first word of "gcc", so it can be a program name with args.
-set dummy gcc; ac_word=$2
-echo "$as_me:$LINENO: checking for $ac_word" >&5
-echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
-if test "${ac_cv_prog_ac_ct_CC+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- if test -n "$ac_ct_CC"; then
- ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test.
-else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
- IFS=$as_save_IFS
- test -z "$as_dir" && as_dir=.
- for ac_exec_ext in '' $ac_executable_extensions; do
- if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
- ac_cv_prog_ac_ct_CC="gcc"
- echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
- break 2
- fi
-done
-done
-
-fi
-fi
-ac_ct_CC=$ac_cv_prog_ac_ct_CC
-if test -n "$ac_ct_CC"; then
- echo "$as_me:$LINENO: result: $ac_ct_CC" >&5
-echo "${ECHO_T}$ac_ct_CC" >&6
-else
- echo "$as_me:$LINENO: result: no" >&5
-echo "${ECHO_T}no" >&6
-fi
-
- CC=$ac_ct_CC
-else
- CC="$ac_cv_prog_CC"
-fi
-
-if test -z "$CC"; then
- if test -n "$ac_tool_prefix"; then
- # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args.
-set dummy ${ac_tool_prefix}cc; ac_word=$2
-echo "$as_me:$LINENO: checking for $ac_word" >&5
-echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
-if test "${ac_cv_prog_CC+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- if test -n "$CC"; then
- ac_cv_prog_CC="$CC" # Let the user override the test.
-else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
- IFS=$as_save_IFS
- test -z "$as_dir" && as_dir=.
- for ac_exec_ext in '' $ac_executable_extensions; do
- if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
- ac_cv_prog_CC="${ac_tool_prefix}cc"
- echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
- break 2
- fi
-done
-done
-
-fi
-fi
-CC=$ac_cv_prog_CC
-if test -n "$CC"; then
- echo "$as_me:$LINENO: result: $CC" >&5
-echo "${ECHO_T}$CC" >&6
-else
- echo "$as_me:$LINENO: result: no" >&5
-echo "${ECHO_T}no" >&6
-fi
-
-fi
-if test -z "$ac_cv_prog_CC"; then
- ac_ct_CC=$CC
- # Extract the first word of "cc", so it can be a program name with args.
-set dummy cc; ac_word=$2
-echo "$as_me:$LINENO: checking for $ac_word" >&5
-echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
-if test "${ac_cv_prog_ac_ct_CC+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- if test -n "$ac_ct_CC"; then
- ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test.
-else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
- IFS=$as_save_IFS
- test -z "$as_dir" && as_dir=.
- for ac_exec_ext in '' $ac_executable_extensions; do
- if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
- ac_cv_prog_ac_ct_CC="cc"
- echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
- break 2
- fi
-done
-done
-
-fi
-fi
-ac_ct_CC=$ac_cv_prog_ac_ct_CC
-if test -n "$ac_ct_CC"; then
- echo "$as_me:$LINENO: result: $ac_ct_CC" >&5
-echo "${ECHO_T}$ac_ct_CC" >&6
-else
- echo "$as_me:$LINENO: result: no" >&5
-echo "${ECHO_T}no" >&6
-fi
-
- CC=$ac_ct_CC
-else
- CC="$ac_cv_prog_CC"
-fi
-
-fi
-if test -z "$CC"; then
- # Extract the first word of "cc", so it can be a program name with args.
-set dummy cc; ac_word=$2
-echo "$as_me:$LINENO: checking for $ac_word" >&5
-echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
-if test "${ac_cv_prog_CC+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- if test -n "$CC"; then
- ac_cv_prog_CC="$CC" # Let the user override the test.
-else
- ac_prog_rejected=no
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
- IFS=$as_save_IFS
- test -z "$as_dir" && as_dir=.
- for ac_exec_ext in '' $ac_executable_extensions; do
- if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
- if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then
- ac_prog_rejected=yes
- continue
- fi
- ac_cv_prog_CC="cc"
- echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
- break 2
- fi
-done
-done
-
-if test $ac_prog_rejected = yes; then
- # We found a bogon in the path, so make sure we never use it.
- set dummy $ac_cv_prog_CC
- shift
- if test $# != 0; then
- # We chose a different compiler from the bogus one.
- # However, it has the same basename, so the bogon will be chosen
- # first if we set CC to just the basename; use the full file name.
- shift
- ac_cv_prog_CC="$as_dir/$ac_word${1+' '}$@"
- fi
-fi
-fi
-fi
-CC=$ac_cv_prog_CC
-if test -n "$CC"; then
- echo "$as_me:$LINENO: result: $CC" >&5
-echo "${ECHO_T}$CC" >&6
-else
- echo "$as_me:$LINENO: result: no" >&5
-echo "${ECHO_T}no" >&6
-fi
-
-fi
-if test -z "$CC"; then
- if test -n "$ac_tool_prefix"; then
- for ac_prog in cl
- do
- # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args.
-set dummy $ac_tool_prefix$ac_prog; ac_word=$2
-echo "$as_me:$LINENO: checking for $ac_word" >&5
-echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
-if test "${ac_cv_prog_CC+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- if test -n "$CC"; then
- ac_cv_prog_CC="$CC" # Let the user override the test.
-else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
- IFS=$as_save_IFS
- test -z "$as_dir" && as_dir=.
- for ac_exec_ext in '' $ac_executable_extensions; do
- if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
- ac_cv_prog_CC="$ac_tool_prefix$ac_prog"
- echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
- break 2
- fi
-done
-done
-
-fi
-fi
-CC=$ac_cv_prog_CC
-if test -n "$CC"; then
- echo "$as_me:$LINENO: result: $CC" >&5
-echo "${ECHO_T}$CC" >&6
-else
- echo "$as_me:$LINENO: result: no" >&5
-echo "${ECHO_T}no" >&6
-fi
-
- test -n "$CC" && break
- done
-fi
-if test -z "$CC"; then
- ac_ct_CC=$CC
- for ac_prog in cl
-do
- # Extract the first word of "$ac_prog", so it can be a program name with args.
-set dummy $ac_prog; ac_word=$2
-echo "$as_me:$LINENO: checking for $ac_word" >&5
-echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
-if test "${ac_cv_prog_ac_ct_CC+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- if test -n "$ac_ct_CC"; then
- ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test.
-else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
- IFS=$as_save_IFS
- test -z "$as_dir" && as_dir=.
- for ac_exec_ext in '' $ac_executable_extensions; do
- if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
- ac_cv_prog_ac_ct_CC="$ac_prog"
- echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
- break 2
- fi
-done
-done
-
-fi
-fi
-ac_ct_CC=$ac_cv_prog_ac_ct_CC
-if test -n "$ac_ct_CC"; then
- echo "$as_me:$LINENO: result: $ac_ct_CC" >&5
-echo "${ECHO_T}$ac_ct_CC" >&6
-else
- echo "$as_me:$LINENO: result: no" >&5
-echo "${ECHO_T}no" >&6
-fi
-
- test -n "$ac_ct_CC" && break
-done
-
- CC=$ac_ct_CC
-fi
-
-fi
-
-
-test -z "$CC" && { { echo "$as_me:$LINENO: error: no acceptable C compiler found in \$PATH
-See \`config.log' for more details." >&5
-echo "$as_me: error: no acceptable C compiler found in \$PATH
-See \`config.log' for more details." >&2;}
- { (exit 1); exit 1; }; }
-
-# Provide some information about the compiler.
-echo "$as_me:$LINENO:" \
- "checking for C compiler version" >&5
-ac_compiler=`set X $ac_compile; echo $2`
-{ (eval echo "$as_me:$LINENO: \"$ac_compiler --version </dev/null >&5\"") >&5
- (eval $ac_compiler --version </dev/null >&5) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }
-{ (eval echo "$as_me:$LINENO: \"$ac_compiler -v </dev/null >&5\"") >&5
- (eval $ac_compiler -v </dev/null >&5) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }
-{ (eval echo "$as_me:$LINENO: \"$ac_compiler -V </dev/null >&5\"") >&5
- (eval $ac_compiler -V </dev/null >&5) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }
-
-cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-
-int
-main ()
-{
-
- ;
- return 0;
-}
-_ACEOF
-ac_clean_files_save=$ac_clean_files
-ac_clean_files="$ac_clean_files a.out a.exe b.out"
-# Try to create an executable without -o first, disregard a.out.
-# It will help us diagnose broken compilers, and finding out an intuition
-# of exeext.
-echo "$as_me:$LINENO: checking for C compiler default output file name" >&5
-echo $ECHO_N "checking for C compiler default output file name... $ECHO_C" >&6
-ac_link_default=`echo "$ac_link" | sed 's/ -o *conftest[^ ]*//'`
-if { (eval echo "$as_me:$LINENO: \"$ac_link_default\"") >&5
- (eval $ac_link_default) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; then
- # Find the output, starting from the most likely. This scheme is
-# not robust to junk in `.', hence go to wildcards (a.*) only as a last
-# resort.
-
-# Be careful to initialize this variable, since it used to be cached.
-# Otherwise an old cache value of `no' led to `EXEEXT = no' in a Makefile.
-ac_cv_exeext=
-# b.out is created by i960 compilers.
-for ac_file in a_out.exe a.exe conftest.exe a.out conftest a.* conftest.* b.out
-do
- test -f "$ac_file" || continue
- case $ac_file in
- *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.o | *.obj )
- ;;
- conftest.$ac_ext )
- # This is the source file.
- ;;
- [ab].out )
- # We found the default executable, but exeext='' is most
- # certainly right.
- break;;
- *.* )
- ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'`
- # FIXME: I believe we export ac_cv_exeext for Libtool,
- # but it would be cool to find out if it's true. Does anybody
- # maintain Libtool? --akim.
- export ac_cv_exeext
- break;;
- * )
- break;;
- esac
-done
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-{ { echo "$as_me:$LINENO: error: C compiler cannot create executables
-See \`config.log' for more details." >&5
-echo "$as_me: error: C compiler cannot create executables
-See \`config.log' for more details." >&2;}
- { (exit 77); exit 77; }; }
-fi
-
-ac_exeext=$ac_cv_exeext
-echo "$as_me:$LINENO: result: $ac_file" >&5
-echo "${ECHO_T}$ac_file" >&6
-
-# Check the compiler produces executables we can run. If not, either
-# the compiler is broken, or we cross compile.
-echo "$as_me:$LINENO: checking whether the C compiler works" >&5
-echo $ECHO_N "checking whether the C compiler works... $ECHO_C" >&6
-# FIXME: These cross compiler hacks should be removed for Autoconf 3.0
-# If not cross compiling, check that we can run a simple program.
-if test "$cross_compiling" != yes; then
- if { ac_try='./$ac_file'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
- cross_compiling=no
- else
- if test "$cross_compiling" = maybe; then
- cross_compiling=yes
- else
- { { echo "$as_me:$LINENO: error: cannot run C compiled programs.
-If you meant to cross compile, use \`--host'.
-See \`config.log' for more details." >&5
-echo "$as_me: error: cannot run C compiled programs.
-If you meant to cross compile, use \`--host'.
-See \`config.log' for more details." >&2;}
- { (exit 1); exit 1; }; }
- fi
- fi
-fi
-echo "$as_me:$LINENO: result: yes" >&5
-echo "${ECHO_T}yes" >&6
-
-rm -f a.out a.exe conftest$ac_cv_exeext b.out
-ac_clean_files=$ac_clean_files_save
-# Check the compiler produces executables we can run. If not, either
-# the compiler is broken, or we cross compile.
-echo "$as_me:$LINENO: checking whether we are cross compiling" >&5
-echo $ECHO_N "checking whether we are cross compiling... $ECHO_C" >&6
-echo "$as_me:$LINENO: result: $cross_compiling" >&5
-echo "${ECHO_T}$cross_compiling" >&6
-
-echo "$as_me:$LINENO: checking for suffix of executables" >&5
-echo $ECHO_N "checking for suffix of executables... $ECHO_C" >&6
-if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
- (eval $ac_link) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; then
- # If both `conftest.exe' and `conftest' are `present' (well, observable)
-# catch `conftest.exe'. For instance with Cygwin, `ls conftest' will
-# work properly (i.e., refer to `conftest.exe'), while it won't with
-# `rm'.
-for ac_file in conftest.exe conftest conftest.*; do
- test -f "$ac_file" || continue
- case $ac_file in
- *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.o | *.obj ) ;;
- *.* ) ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'`
- export ac_cv_exeext
- break;;
- * ) break;;
- esac
-done
-else
- { { echo "$as_me:$LINENO: error: cannot compute suffix of executables: cannot compile and link
-See \`config.log' for more details." >&5
-echo "$as_me: error: cannot compute suffix of executables: cannot compile and link
-See \`config.log' for more details." >&2;}
- { (exit 1); exit 1; }; }
-fi
-
-rm -f conftest$ac_cv_exeext
-echo "$as_me:$LINENO: result: $ac_cv_exeext" >&5
-echo "${ECHO_T}$ac_cv_exeext" >&6
-
-rm -f conftest.$ac_ext
-EXEEXT=$ac_cv_exeext
-ac_exeext=$EXEEXT
-echo "$as_me:$LINENO: checking for suffix of object files" >&5
-echo $ECHO_N "checking for suffix of object files... $ECHO_C" >&6
-if test "${ac_cv_objext+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-
-int
-main ()
-{
-
- ;
- return 0;
-}
-_ACEOF
-rm -f conftest.o conftest.obj
-if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
- (eval $ac_compile) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; then
- for ac_file in `(ls conftest.o conftest.obj; ls conftest.*) 2>/dev/null`; do
- case $ac_file in
- *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg ) ;;
- *) ac_cv_objext=`expr "$ac_file" : '.*\.\(.*\)'`
- break;;
- esac
-done
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-{ { echo "$as_me:$LINENO: error: cannot compute suffix of object files: cannot compile
-See \`config.log' for more details." >&5
-echo "$as_me: error: cannot compute suffix of object files: cannot compile
-See \`config.log' for more details." >&2;}
- { (exit 1); exit 1; }; }
-fi
-
-rm -f conftest.$ac_cv_objext conftest.$ac_ext
-fi
-echo "$as_me:$LINENO: result: $ac_cv_objext" >&5
-echo "${ECHO_T}$ac_cv_objext" >&6
-OBJEXT=$ac_cv_objext
-ac_objext=$OBJEXT
-echo "$as_me:$LINENO: checking whether we are using the GNU C compiler" >&5
-echo $ECHO_N "checking whether we are using the GNU C compiler... $ECHO_C" >&6
-if test "${ac_cv_c_compiler_gnu+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-
-int
-main ()
-{
-#ifndef __GNUC__
- choke me
-#endif
-
- ;
- return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
- (eval $ac_compile) 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } &&
- { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; } &&
- { ac_try='test -s conftest.$ac_objext'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
- ac_compiler_gnu=yes
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-ac_compiler_gnu=no
-fi
-rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
-ac_cv_c_compiler_gnu=$ac_compiler_gnu
-
-fi
-echo "$as_me:$LINENO: result: $ac_cv_c_compiler_gnu" >&5
-echo "${ECHO_T}$ac_cv_c_compiler_gnu" >&6
-GCC=`test $ac_compiler_gnu = yes && echo yes`
-ac_test_CFLAGS=${CFLAGS+set}
-ac_save_CFLAGS=$CFLAGS
-CFLAGS="-g"
-echo "$as_me:$LINENO: checking whether $CC accepts -g" >&5
-echo $ECHO_N "checking whether $CC accepts -g... $ECHO_C" >&6
-if test "${ac_cv_prog_cc_g+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-
-int
-main ()
-{
-
- ;
- return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
- (eval $ac_compile) 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } &&
- { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; } &&
- { ac_try='test -s conftest.$ac_objext'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
- ac_cv_prog_cc_g=yes
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-ac_cv_prog_cc_g=no
-fi
-rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
-fi
-echo "$as_me:$LINENO: result: $ac_cv_prog_cc_g" >&5
-echo "${ECHO_T}$ac_cv_prog_cc_g" >&6
-if test "$ac_test_CFLAGS" = set; then
- CFLAGS=$ac_save_CFLAGS
-elif test $ac_cv_prog_cc_g = yes; then
- if test "$GCC" = yes; then
- CFLAGS="-g -O2"
- else
- CFLAGS="-g"
- fi
-else
- if test "$GCC" = yes; then
- CFLAGS="-O2"
- else
- CFLAGS=
- fi
-fi
-echo "$as_me:$LINENO: checking for $CC option to accept ANSI C" >&5
-echo $ECHO_N "checking for $CC option to accept ANSI C... $ECHO_C" >&6
-if test "${ac_cv_prog_cc_stdc+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- ac_cv_prog_cc_stdc=no
-ac_save_CC=$CC
-cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-#include <stdarg.h>
-#include <stdio.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-/* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */
-struct buf { int x; };
-FILE * (*rcsopen) (struct buf *, struct stat *, int);
-static char *e (p, i)
- char **p;
- int i;
-{
- return p[i];
-}
-static char *f (char * (*g) (char **, int), char **p, ...)
-{
- char *s;
- va_list v;
- va_start (v,p);
- s = g (p, va_arg (v,int));
- va_end (v);
- return s;
-}
-
-/* OSF 4.0 Compaq cc is some sort of almost-ANSI by default. It has
- function prototypes and stuff, but not '\xHH' hex character constants.
- These don't provoke an error unfortunately, instead are silently treated
- as 'x'. The following induces an error, until -std1 is added to get
- proper ANSI mode. Curiously '\x00'!='x' always comes out true, for an
- array size at least. It's necessary to write '\x00'==0 to get something
- that's true only with -std1. */
-int osf4_cc_array ['\x00' == 0 ? 1 : -1];
-
-int test (int i, double x);
-struct s1 {int (*f) (int a);};
-struct s2 {int (*f) (double a);};
-int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int);
-int argc;
-char **argv;
-int
-main ()
-{
-return f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1];
- ;
- return 0;
-}
-_ACEOF
-# Don't try gcc -ansi; that turns off useful extensions and
-# breaks some systems' header files.
-# AIX -qlanglvl=ansi
-# Ultrix and OSF/1 -std1
-# HP-UX 10.20 and later -Ae
-# HP-UX older versions -Aa -D_HPUX_SOURCE
-# SVR4 -Xc -D__EXTENSIONS__
-for ac_arg in "" -qlanglvl=ansi -std1 -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__"
-do
- CC="$ac_save_CC $ac_arg"
- rm -f conftest.$ac_objext
-if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
- (eval $ac_compile) 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } &&
- { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; } &&
- { ac_try='test -s conftest.$ac_objext'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
- ac_cv_prog_cc_stdc=$ac_arg
-break
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-fi
-rm -f conftest.err conftest.$ac_objext
-done
-rm -f conftest.$ac_ext conftest.$ac_objext
-CC=$ac_save_CC
-
-fi
-
-case "x$ac_cv_prog_cc_stdc" in
- x|xno)
- echo "$as_me:$LINENO: result: none needed" >&5
-echo "${ECHO_T}none needed" >&6 ;;
- *)
- echo "$as_me:$LINENO: result: $ac_cv_prog_cc_stdc" >&5
-echo "${ECHO_T}$ac_cv_prog_cc_stdc" >&6
- CC="$CC $ac_cv_prog_cc_stdc" ;;
-esac
-
-# Some people use a C++ compiler to compile C. Since we use `exit',
-# in C++ we need to declare it. In case someone uses the same compiler
-# for both compiling C and C++ we need to have the C++ compiler decide
-# the declaration of exit, since it's the most demanding environment.
-cat >conftest.$ac_ext <<_ACEOF
-#ifndef __cplusplus
- choke me
-#endif
-_ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
- (eval $ac_compile) 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } &&
- { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; } &&
- { ac_try='test -s conftest.$ac_objext'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
- for ac_declaration in \
- '' \
- 'extern "C" void std::exit (int) throw (); using std::exit;' \
- 'extern "C" void std::exit (int); using std::exit;' \
- 'extern "C" void exit (int) throw ();' \
- 'extern "C" void exit (int);' \
- 'void exit (int);'
-do
- cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-$ac_declaration
-#include <stdlib.h>
-int
-main ()
-{
-exit (42);
- ;
- return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
- (eval $ac_compile) 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } &&
- { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; } &&
- { ac_try='test -s conftest.$ac_objext'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
- :
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-continue
-fi
-rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
- cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-$ac_declaration
-int
-main ()
-{
-exit (42);
- ;
- return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
- (eval $ac_compile) 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } &&
- { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; } &&
- { ac_try='test -s conftest.$ac_objext'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
- break
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-fi
-rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
-done
-rm -f conftest*
-if test -n "$ac_declaration"; then
- echo '#ifdef __cplusplus' >>confdefs.h
- echo $ac_declaration >>confdefs.h
- echo '#endif' >>confdefs.h
-fi
-
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-fi
-rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
-ac_ext=c
-ac_cpp='$CPP $CPPFLAGS'
-ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
-ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
-ac_compiler_gnu=$ac_cv_c_compiler_gnu
-
-depcc="$CC" am_compiler_list=
-
-echo "$as_me:$LINENO: checking dependency style of $depcc" >&5
-echo $ECHO_N "checking dependency style of $depcc... $ECHO_C" >&6
-if test "${am_cv_CC_dependencies_compiler_type+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then
- # We make a subdir and do the tests there. Otherwise we can end up
- # making bogus files that we don't know about and never remove. For
- # instance it was reported that on HP-UX the gcc test will end up
- # making a dummy file named `D' -- because `-MD' means `put the output
- # in D'.
- mkdir conftest.dir
- # Copy depcomp to subdir because otherwise we won't find it if we're
- # using a relative directory.
- cp "$am_depcomp" conftest.dir
- cd conftest.dir
- # We will build objects and dependencies in a subdirectory because
- # it helps to detect inapplicable dependency modes. For instance
- # both Tru64's cc and ICC support -MD to output dependencies as a
- # side effect of compilation, but ICC will put the dependencies in
- # the current directory while Tru64 will put them in the object
- # directory.
- mkdir sub
-
- am_cv_CC_dependencies_compiler_type=none
- if test "$am_compiler_list" = ""; then
- am_compiler_list=`sed -n 's/^#*\([a-zA-Z0-9]*\))$/\1/p' < ./depcomp`
- fi
- for depmode in $am_compiler_list; do
- # Setup a source with many dependencies, because some compilers
- # like to wrap large dependency lists on column 80 (with \), and
- # we should not choose a depcomp mode which is confused by this.
- #
- # We need to recreate these files for each test, as the compiler may
- # overwrite some of them when testing with obscure command lines.
- # This happens at least with the AIX C compiler.
- : > sub/conftest.c
- for i in 1 2 3 4 5 6; do
- echo '#include "conftst'$i'.h"' >> sub/conftest.c
- # Using `: > sub/conftst$i.h' creates only sub/conftst1.h with
- # Solaris 8's {/usr,}/bin/sh.
- touch sub/conftst$i.h
- done
- echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf
-
- case $depmode in
- nosideeffect)
- # after this tag, mechanisms are not by side-effect, so they'll
- # only be used when explicitly requested
- if test "x$enable_dependency_tracking" = xyes; then
- continue
- else
- break
- fi
- ;;
- none) break ;;
- esac
- # We check with `-c' and `-o' for the sake of the "dashmstdout"
- # mode. It turns out that the SunPro C++ compiler does not properly
- # handle `-M -o', and we need to detect this.
- if depmode=$depmode \
- source=sub/conftest.c object=sub/conftest.${OBJEXT-o} \
- depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \
- $SHELL ./depcomp $depcc -c -o sub/conftest.${OBJEXT-o} sub/conftest.c \
- >/dev/null 2>conftest.err &&
- grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 &&
- grep sub/conftest.${OBJEXT-o} sub/conftest.Po > /dev/null 2>&1 &&
- ${MAKE-make} -s -f confmf > /dev/null 2>&1; then
- # icc doesn't choke on unknown options, it will just issue warnings
- # or remarks (even with -Werror). So we grep stderr for any message
- # that says an option was ignored or not supported.
- # When given -MP, icc 7.0 and 7.1 complain thusly:
- # icc: Command line warning: ignoring option '-M'; no argument required
- # The diagnosis changed in icc 8.0:
- # icc: Command line remark: option '-MP' not supported
- if (grep 'ignoring option' conftest.err ||
- grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else
- am_cv_CC_dependencies_compiler_type=$depmode
- break
- fi
- fi
- done
-
- cd ..
- rm -rf conftest.dir
-else
- am_cv_CC_dependencies_compiler_type=none
-fi
-
-fi
-echo "$as_me:$LINENO: result: $am_cv_CC_dependencies_compiler_type" >&5
-echo "${ECHO_T}$am_cv_CC_dependencies_compiler_type" >&6
-CCDEPMODE=depmode=$am_cv_CC_dependencies_compiler_type
-
-
-
-if
- test "x$enable_dependency_tracking" != xno \
- && test "$am_cv_CC_dependencies_compiler_type" = gcc3; then
- am__fastdepCC_TRUE=
- am__fastdepCC_FALSE='#'
-else
- am__fastdepCC_TRUE='#'
- am__fastdepCC_FALSE=
-fi
-
-
-echo "$as_me:$LINENO: checking for a sed that does not truncate output" >&5
-echo $ECHO_N "checking for a sed that does not truncate output... $ECHO_C" >&6
-if test "${lt_cv_path_SED+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- # Loop through the user's path and test for sed and gsed.
-# Then use that list of sed's as ones to test for truncation.
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
- IFS=$as_save_IFS
- test -z "$as_dir" && as_dir=.
- for lt_ac_prog in sed gsed; do
- for ac_exec_ext in '' $ac_executable_extensions; do
- if $as_executable_p "$as_dir/$lt_ac_prog$ac_exec_ext"; then
- lt_ac_sed_list="$lt_ac_sed_list $as_dir/$lt_ac_prog$ac_exec_ext"
- fi
- done
- done
-done
-lt_ac_max=0
-lt_ac_count=0
-# Add /usr/xpg4/bin/sed as it is typically found on Solaris
-# along with /bin/sed that truncates output.
-for lt_ac_sed in $lt_ac_sed_list /usr/xpg4/bin/sed; do
- test ! -f $lt_ac_sed && continue
- cat /dev/null > conftest.in
- lt_ac_count=0
- echo $ECHO_N "0123456789$ECHO_C" >conftest.in
- # Check for GNU sed and select it if it is found.
- if "$lt_ac_sed" --version 2>&1 < /dev/null | grep 'GNU' > /dev/null; then
- lt_cv_path_SED=$lt_ac_sed
- break
- fi
- while true; do
- cat conftest.in conftest.in >conftest.tmp
- mv conftest.tmp conftest.in
- cp conftest.in conftest.nl
- echo >>conftest.nl
- $lt_ac_sed -e 's/a$//' < conftest.nl >conftest.out || break
- cmp -s conftest.out conftest.nl || break
- # 10000 chars as input seems more than enough
- test $lt_ac_count -gt 10 && break
- lt_ac_count=`expr $lt_ac_count + 1`
- if test $lt_ac_count -gt $lt_ac_max; then
- lt_ac_max=$lt_ac_count
- lt_cv_path_SED=$lt_ac_sed
- fi
- done
-done
-
-fi
-
-SED=$lt_cv_path_SED
-echo "$as_me:$LINENO: result: $SED" >&5
-echo "${ECHO_T}$SED" >&6
-
-echo "$as_me:$LINENO: checking for egrep" >&5
-echo $ECHO_N "checking for egrep... $ECHO_C" >&6
-if test "${ac_cv_prog_egrep+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- if echo a | (grep -E '(a|b)') >/dev/null 2>&1
- then ac_cv_prog_egrep='grep -E'
- else ac_cv_prog_egrep='egrep'
- fi
-fi
-echo "$as_me:$LINENO: result: $ac_cv_prog_egrep" >&5
-echo "${ECHO_T}$ac_cv_prog_egrep" >&6
- EGREP=$ac_cv_prog_egrep
-
-
-
-# Check whether --with-gnu-ld or --without-gnu-ld was given.
-if test "${with_gnu_ld+set}" = set; then
- withval="$with_gnu_ld"
- test "$withval" = no || with_gnu_ld=yes
-else
- with_gnu_ld=no
-fi;
-ac_prog=ld
-if test "$GCC" = yes; then
- # Check if gcc -print-prog-name=ld gives a path.
- echo "$as_me:$LINENO: checking for ld used by $CC" >&5
-echo $ECHO_N "checking for ld used by $CC... $ECHO_C" >&6
- case $host in
- *-*-mingw*)
- # gcc leaves a trailing carriage return which upsets mingw
- ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;;
- *)
- ac_prog=`($CC -print-prog-name=ld) 2>&5` ;;
- esac
- case $ac_prog in
- # Accept absolute paths.
- [\\/]* | ?:[\\/]*)
- re_direlt='/[^/][^/]*/\.\./'
- # Canonicalize the pathname of ld
- ac_prog=`echo $ac_prog| $SED 's%\\\\%/%g'`
- while echo $ac_prog | grep "$re_direlt" > /dev/null 2>&1; do
- ac_prog=`echo $ac_prog| $SED "s%$re_direlt%/%"`
- done
- test -z "$LD" && LD="$ac_prog"
- ;;
- "")
- # If it fails, then pretend we aren't using GCC.
- ac_prog=ld
- ;;
- *)
- # If it is relative, then search for the first ld in PATH.
- with_gnu_ld=unknown
- ;;
- esac
-elif test "$with_gnu_ld" = yes; then
- echo "$as_me:$LINENO: checking for GNU ld" >&5
-echo $ECHO_N "checking for GNU ld... $ECHO_C" >&6
-else
- echo "$as_me:$LINENO: checking for non-GNU ld" >&5
-echo $ECHO_N "checking for non-GNU ld... $ECHO_C" >&6
-fi
-if test "${lt_cv_path_LD+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- if test -z "$LD"; then
- lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
- for ac_dir in $PATH; do
- IFS="$lt_save_ifs"
- test -z "$ac_dir" && ac_dir=.
- if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then
- lt_cv_path_LD="$ac_dir/$ac_prog"
- # Check to see if the program is GNU ld. I'd rather use --version,
- # but apparently some variants of GNU ld only accept -v.
- # Break only if it was the GNU/non-GNU ld that we prefer.
- case `"$lt_cv_path_LD" -v 2>&1 </dev/null` in
- *GNU* | *'with BFD'*)
- test "$with_gnu_ld" != no && break
- ;;
- *)
- test "$with_gnu_ld" != yes && break
- ;;
- esac
- fi
- done
- IFS="$lt_save_ifs"
-else
- lt_cv_path_LD="$LD" # Let the user override the test with a path.
-fi
-fi
-
-LD="$lt_cv_path_LD"
-if test -n "$LD"; then
- echo "$as_me:$LINENO: result: $LD" >&5
-echo "${ECHO_T}$LD" >&6
-else
- echo "$as_me:$LINENO: result: no" >&5
-echo "${ECHO_T}no" >&6
-fi
-test -z "$LD" && { { echo "$as_me:$LINENO: error: no acceptable ld found in \$PATH" >&5
-echo "$as_me: error: no acceptable ld found in \$PATH" >&2;}
- { (exit 1); exit 1; }; }
-echo "$as_me:$LINENO: checking if the linker ($LD) is GNU ld" >&5
-echo $ECHO_N "checking if the linker ($LD) is GNU ld... $ECHO_C" >&6
-if test "${lt_cv_prog_gnu_ld+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- # I'd rather use --version here, but apparently some GNU lds only accept -v.
-case `$LD -v 2>&1 </dev/null` in
-*GNU* | *'with BFD'*)
- lt_cv_prog_gnu_ld=yes
- ;;
-*)
- lt_cv_prog_gnu_ld=no
- ;;
-esac
-fi
-echo "$as_me:$LINENO: result: $lt_cv_prog_gnu_ld" >&5
-echo "${ECHO_T}$lt_cv_prog_gnu_ld" >&6
-with_gnu_ld=$lt_cv_prog_gnu_ld
-
-
-echo "$as_me:$LINENO: checking for $LD option to reload object files" >&5
-echo $ECHO_N "checking for $LD option to reload object files... $ECHO_C" >&6
-if test "${lt_cv_ld_reload_flag+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- lt_cv_ld_reload_flag='-r'
-fi
-echo "$as_me:$LINENO: result: $lt_cv_ld_reload_flag" >&5
-echo "${ECHO_T}$lt_cv_ld_reload_flag" >&6
-reload_flag=$lt_cv_ld_reload_flag
-case $reload_flag in
-"" | " "*) ;;
-*) reload_flag=" $reload_flag" ;;
-esac
-reload_cmds='$LD$reload_flag -o $output$reload_objs'
-case $host_os in
- darwin*)
- if test "$GCC" = yes; then
- reload_cmds='$LTCC $LTCFLAGS -nostdlib ${wl}-r -o $output$reload_objs'
- else
- reload_cmds='$LD$reload_flag -o $output$reload_objs'
- fi
- ;;
-esac
-
-echo "$as_me:$LINENO: checking for BSD-compatible nm" >&5
-echo $ECHO_N "checking for BSD-compatible nm... $ECHO_C" >&6
-if test "${lt_cv_path_NM+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- if test -n "$NM"; then
- # Let the user override the test.
- lt_cv_path_NM="$NM"
-else
- lt_nm_to_check="${ac_tool_prefix}nm"
- if test -n "$ac_tool_prefix" && test "$build" = "$host"; then
- lt_nm_to_check="$lt_nm_to_check nm"
- fi
- for lt_tmp_nm in $lt_nm_to_check; do
- lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
- for ac_dir in $PATH /usr/ccs/bin/elf /usr/ccs/bin /usr/ucb /bin; do
- IFS="$lt_save_ifs"
- test -z "$ac_dir" && ac_dir=.
- tmp_nm="$ac_dir/$lt_tmp_nm"
- if test -f "$tmp_nm" || test -f "$tmp_nm$ac_exeext" ; then
- # Check to see if the nm accepts a BSD-compat flag.
- # Adding the `sed 1q' prevents false positives on HP-UX, which says:
- # nm: unknown option "B" ignored
- # Tru64's nm complains that /dev/null is an invalid object file
- case `"$tmp_nm" -B /dev/null 2>&1 | sed '1q'` in
- */dev/null* | *'Invalid file or object type'*)
- lt_cv_path_NM="$tmp_nm -B"
- break
- ;;
- *)
- case `"$tmp_nm" -p /dev/null 2>&1 | sed '1q'` in
- */dev/null*)
- lt_cv_path_NM="$tmp_nm -p"
- break
- ;;
- *)
- lt_cv_path_NM=${lt_cv_path_NM="$tmp_nm"} # keep the first match, but
- continue # so that we can try to find one that supports BSD flags
- ;;
- esac
- ;;
- esac
- fi
- done
- IFS="$lt_save_ifs"
- done
- test -z "$lt_cv_path_NM" && lt_cv_path_NM=nm
-fi
-fi
-echo "$as_me:$LINENO: result: $lt_cv_path_NM" >&5
-echo "${ECHO_T}$lt_cv_path_NM" >&6
-NM="$lt_cv_path_NM"
-
-echo "$as_me:$LINENO: checking whether ln -s works" >&5
-echo $ECHO_N "checking whether ln -s works... $ECHO_C" >&6
-LN_S=$as_ln_s
-if test "$LN_S" = "ln -s"; then
- echo "$as_me:$LINENO: result: yes" >&5
-echo "${ECHO_T}yes" >&6
-else
- echo "$as_me:$LINENO: result: no, using $LN_S" >&5
-echo "${ECHO_T}no, using $LN_S" >&6
-fi
-
-echo "$as_me:$LINENO: checking how to recognise dependent libraries" >&5
-echo $ECHO_N "checking how to recognise dependent libraries... $ECHO_C" >&6
-if test "${lt_cv_deplibs_check_method+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- lt_cv_file_magic_cmd='$MAGIC_CMD'
-lt_cv_file_magic_test_file=
-lt_cv_deplibs_check_method='unknown'
-# Need to set the preceding variable on all platforms that support
-# interlibrary dependencies.
-# 'none' -- dependencies not supported.
-# `unknown' -- same as none, but documents that we really don't know.
-# 'pass_all' -- all dependencies passed with no checks.
-# 'test_compile' -- check by making test program.
-# 'file_magic [[regex]]' -- check by looking for files in library path
-# which responds to the $file_magic_cmd with a given extended regex.
-# If you have `file' or equivalent on your system and you're not sure
-# whether `pass_all' will *always* work, you probably want this one.
-
-case $host_os in
-aix4* | aix5*)
- lt_cv_deplibs_check_method=pass_all
- ;;
-
-beos*)
- lt_cv_deplibs_check_method=pass_all
- ;;
-
-bsdi[45]*)
- lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [ML]SB (shared object|dynamic lib)'
- lt_cv_file_magic_cmd='/usr/bin/file -L'
- lt_cv_file_magic_test_file=/shlib/libc.so
- ;;
-
-cygwin*)
- # func_win32_libid is a shell function defined in ltmain.sh
- lt_cv_deplibs_check_method='file_magic ^x86 archive import|^x86 DLL'
- lt_cv_file_magic_cmd='func_win32_libid'
- ;;
-
-mingw* | pw32*)
- # Base MSYS/MinGW do not provide the 'file' command needed by
- # func_win32_libid shell function, so use a weaker test based on 'objdump'.
- lt_cv_deplibs_check_method='file_magic file format pei*-i386(.*architecture: i386)?'
- lt_cv_file_magic_cmd='$OBJDUMP -f'
- ;;
-
-darwin* | rhapsody*)
- lt_cv_deplibs_check_method=pass_all
- ;;
-
-freebsd* | kfreebsd*-gnu | dragonfly*)
- if echo __ELF__ | $CC -E - | grep __ELF__ > /dev/null; then
- case $host_cpu in
- i*86 )
- # Not sure whether the presence of OpenBSD here was a mistake.
- # Let's accept both of them until this is cleared up.
- lt_cv_deplibs_check_method='file_magic (FreeBSD|OpenBSD|DragonFly)/i[3-9]86 (compact )?demand paged shared library'
- lt_cv_file_magic_cmd=/usr/bin/file
- lt_cv_file_magic_test_file=`echo /usr/lib/libc.so.*`
- ;;
- esac
- else
- lt_cv_deplibs_check_method=pass_all
- fi
- ;;
-
-gnu*)
- lt_cv_deplibs_check_method=pass_all
- ;;
-
-hpux10.20* | hpux11*)
- lt_cv_file_magic_cmd=/usr/bin/file
- case $host_cpu in
- ia64*)
- lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|ELF-[0-9][0-9]) shared object file - IA64'
- lt_cv_file_magic_test_file=/usr/lib/hpux32/libc.so
- ;;
- hppa*64*)
- lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|ELF-[0-9][0-9]) shared object file - PA-RISC [0-9].[0-9]'
- lt_cv_file_magic_test_file=/usr/lib/pa20_64/libc.sl
- ;;
- *)
- lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|PA-RISC[0-9].[0-9]) shared library'
- lt_cv_file_magic_test_file=/usr/lib/libc.sl
- ;;
- esac
- ;;
-
-interix3*)
- # PIC code is broken on Interix 3.x, that's why |\.a not |_pic\.a here
- lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so|\.a)$'
- ;;
-
-irix5* | irix6* | nonstopux*)
- case $LD in
- *-32|*"-32 ") libmagic=32-bit;;
- *-n32|*"-n32 ") libmagic=N32;;
- *-64|*"-64 ") libmagic=64-bit;;
- *) libmagic=never-match;;
- esac
- lt_cv_deplibs_check_method=pass_all
- ;;
-
-# This must be Linux ELF.
-linux*)
- lt_cv_deplibs_check_method=pass_all
- ;;
-
-netbsd* | netbsdelf*-gnu | knetbsd*-gnu)
- if echo __ELF__ | $CC -E - | grep __ELF__ > /dev/null; then
- lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so\.[0-9]+\.[0-9]+|_pic\.a)$'
- else
- lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so|_pic\.a)$'
- fi
- ;;
-
-newos6*)
- lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [ML]SB (executable|dynamic lib)'
- lt_cv_file_magic_cmd=/usr/bin/file
- lt_cv_file_magic_test_file=/usr/lib/libnls.so
- ;;
-
-nto-qnx*)
- lt_cv_deplibs_check_method=unknown
- ;;
-
-openbsd*)
- if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
- lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so\.[0-9]+\.[0-9]+|\.so|_pic\.a)$'
- else
- lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so\.[0-9]+\.[0-9]+|_pic\.a)$'
- fi
- ;;
-
-osf3* | osf4* | osf5*)
- lt_cv_deplibs_check_method=pass_all
- ;;
-
-solaris*)
- lt_cv_deplibs_check_method=pass_all
- ;;
-
-sysv4 | sysv4.3*)
- case $host_vendor in
- motorola)
- lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [ML]SB (shared object|dynamic lib) M[0-9][0-9]* Version [0-9]'
- lt_cv_file_magic_test_file=`echo /usr/lib/libc.so*`
- ;;
- ncr)
- lt_cv_deplibs_check_method=pass_all
- ;;
- sequent)
- lt_cv_file_magic_cmd='/bin/file'
- lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [LM]SB (shared object|dynamic lib )'
- ;;
- sni)
- lt_cv_file_magic_cmd='/bin/file'
- lt_cv_deplibs_check_method="file_magic ELF [0-9][0-9]*-bit [LM]SB dynamic lib"
- lt_cv_file_magic_test_file=/lib/libc.so
- ;;
- siemens)
- lt_cv_deplibs_check_method=pass_all
- ;;
- pc)
- lt_cv_deplibs_check_method=pass_all
- ;;
- esac
- ;;
-
-sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*)
- lt_cv_deplibs_check_method=pass_all
- ;;
-esac
-
-fi
-echo "$as_me:$LINENO: result: $lt_cv_deplibs_check_method" >&5
-echo "${ECHO_T}$lt_cv_deplibs_check_method" >&6
-file_magic_cmd=$lt_cv_file_magic_cmd
-deplibs_check_method=$lt_cv_deplibs_check_method
-test -z "$deplibs_check_method" && deplibs_check_method=unknown
-
-
-
-
-# If no C compiler was specified, use CC.
-LTCC=${LTCC-"$CC"}
-
-# If no C compiler flags were specified, use CFLAGS.
-LTCFLAGS=${LTCFLAGS-"$CFLAGS"}
-
-# Allow CC to be a program name with arguments.
-compiler=$CC
-
-
-# Check whether --enable-libtool-lock or --disable-libtool-lock was given.
-if test "${enable_libtool_lock+set}" = set; then
- enableval="$enable_libtool_lock"
-
-fi;
-test "x$enable_libtool_lock" != xno && enable_libtool_lock=yes
-
-# Some flags need to be propagated to the compiler or linker for good
-# libtool support.
-case $host in
-ia64-*-hpux*)
- # Find out which ABI we are using.
- echo 'int i;' > conftest.$ac_ext
- if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
- (eval $ac_compile) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; then
- case `/usr/bin/file conftest.$ac_objext` in
- *ELF-32*)
- HPUX_IA64_MODE="32"
- ;;
- *ELF-64*)
- HPUX_IA64_MODE="64"
- ;;
- esac
- fi
- rm -rf conftest*
- ;;
-*-*-irix6*)
- # Find out which ABI we are using.
- echo '#line 3673 "configure"' > conftest.$ac_ext
- if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
- (eval $ac_compile) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; then
- if test "$lt_cv_prog_gnu_ld" = yes; then
- case `/usr/bin/file conftest.$ac_objext` in
- *32-bit*)
- LD="${LD-ld} -melf32bsmip"
- ;;
- *N32*)
- LD="${LD-ld} -melf32bmipn32"
- ;;
- *64-bit*)
- LD="${LD-ld} -melf64bmip"
- ;;
- esac
- else
- case `/usr/bin/file conftest.$ac_objext` in
- *32-bit*)
- LD="${LD-ld} -32"
- ;;
- *N32*)
- LD="${LD-ld} -n32"
- ;;
- *64-bit*)
- LD="${LD-ld} -64"
- ;;
- esac
- fi
- fi
- rm -rf conftest*
- ;;
-
-x86_64-*linux*|ppc*-*linux*|powerpc*-*linux*|s390*-*linux*|sparc*-*linux*)
- # Find out which ABI we are using.
- echo 'int i;' > conftest.$ac_ext
- if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
- (eval $ac_compile) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; then
- case `/usr/bin/file conftest.o` in
- *32-bit*)
- case $host in
- x86_64-*linux*)
- LD="${LD-ld} -m elf_i386"
- ;;
- ppc64-*linux*|powerpc64-*linux*)
- LD="${LD-ld} -m elf32ppclinux"
- ;;
- s390x-*linux*)
- LD="${LD-ld} -m elf_s390"
- ;;
- sparc64-*linux*)
- LD="${LD-ld} -m elf32_sparc"
- ;;
- esac
- ;;
- *64-bit*)
- case $host in
- x86_64-*linux*)
- LD="${LD-ld} -m elf_x86_64"
- ;;
- ppc*-*linux*|powerpc*-*linux*)
- LD="${LD-ld} -m elf64ppc"
- ;;
- s390*-*linux*)
- LD="${LD-ld} -m elf64_s390"
- ;;
- sparc*-*linux*)
- LD="${LD-ld} -m elf64_sparc"
- ;;
- esac
- ;;
- esac
- fi
- rm -rf conftest*
- ;;
-
-*-*-sco3.2v5*)
- # On SCO OpenServer 5, we need -belf to get full-featured binaries.
- SAVE_CFLAGS="$CFLAGS"
- CFLAGS="$CFLAGS -belf"
- echo "$as_me:$LINENO: checking whether the C compiler needs -belf" >&5
-echo $ECHO_N "checking whether the C compiler needs -belf... $ECHO_C" >&6
-if test "${lt_cv_cc_needs_belf+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- ac_ext=c
-ac_cpp='$CPP $CPPFLAGS'
-ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
-ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
-ac_compiler_gnu=$ac_cv_c_compiler_gnu
-
- cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-
-int
-main ()
-{
-
- ;
- return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
- (eval $ac_link) 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } &&
- { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; } &&
- { ac_try='test -s conftest$ac_exeext'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
- lt_cv_cc_needs_belf=yes
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-lt_cv_cc_needs_belf=no
-fi
-rm -f conftest.err conftest.$ac_objext \
- conftest$ac_exeext conftest.$ac_ext
- ac_ext=c
-ac_cpp='$CPP $CPPFLAGS'
-ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
-ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
-ac_compiler_gnu=$ac_cv_c_compiler_gnu
-
-fi
-echo "$as_me:$LINENO: result: $lt_cv_cc_needs_belf" >&5
-echo "${ECHO_T}$lt_cv_cc_needs_belf" >&6
- if test x"$lt_cv_cc_needs_belf" != x"yes"; then
- # this is probably gcc 2.8.0, egcs 1.0 or newer; no need for -belf
- CFLAGS="$SAVE_CFLAGS"
- fi
- ;;
-sparc*-*solaris*)
- # Find out which ABI we are using.
- echo 'int i;' > conftest.$ac_ext
- if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
- (eval $ac_compile) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; then
- case `/usr/bin/file conftest.o` in
- *64-bit*)
- case $lt_cv_prog_gnu_ld in
- yes*) LD="${LD-ld} -m elf64_sparc" ;;
- *) LD="${LD-ld} -64" ;;
- esac
- ;;
- esac
- fi
- rm -rf conftest*
- ;;
-
-
-esac
-
-need_locks="$enable_libtool_lock"
-
-
-ac_ext=c
-ac_cpp='$CPP $CPPFLAGS'
-ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
-ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
-ac_compiler_gnu=$ac_cv_c_compiler_gnu
-echo "$as_me:$LINENO: checking how to run the C preprocessor" >&5
-echo $ECHO_N "checking how to run the C preprocessor... $ECHO_C" >&6
-# On Suns, sometimes $CPP names a directory.
-if test -n "$CPP" && test -d "$CPP"; then
- CPP=
-fi
-if test -z "$CPP"; then
- if test "${ac_cv_prog_CPP+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- # Double quotes because CPP needs to be expanded
- for CPP in "$CC -E" "$CC -E -traditional-cpp" "/lib/cpp"
- do
- ac_preproc_ok=false
-for ac_c_preproc_warn_flag in '' yes
-do
- # Use a header file that comes with gcc, so configuring glibc
- # with a fresh cross-compiler works.
- # Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
- # <limits.h> exists even on freestanding compilers.
- # On the NeXT, cc -E runs the code through the compiler's parser,
- # not just through cpp. "Syntax error" is here to catch this case.
- cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-#ifdef __STDC__
-# include <limits.h>
-#else
-# include <assert.h>
-#endif
- Syntax error
-_ACEOF
-if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5
- (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } >/dev/null; then
- if test -s conftest.err; then
- ac_cpp_err=$ac_c_preproc_warn_flag
- ac_cpp_err=$ac_cpp_err$ac_c_werror_flag
- else
- ac_cpp_err=
- fi
-else
- ac_cpp_err=yes
-fi
-if test -z "$ac_cpp_err"; then
- :
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
- # Broken: fails on valid input.
-continue
-fi
-rm -f conftest.err conftest.$ac_ext
-
- # OK, works on sane cases. Now check whether non-existent headers
- # can be detected and how.
- cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-#include <ac_nonexistent.h>
-_ACEOF
-if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5
- (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } >/dev/null; then
- if test -s conftest.err; then
- ac_cpp_err=$ac_c_preproc_warn_flag
- ac_cpp_err=$ac_cpp_err$ac_c_werror_flag
- else
- ac_cpp_err=
- fi
-else
- ac_cpp_err=yes
-fi
-if test -z "$ac_cpp_err"; then
- # Broken: success on invalid input.
-continue
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
- # Passes both tests.
-ac_preproc_ok=:
-break
-fi
-rm -f conftest.err conftest.$ac_ext
-
-done
-# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped.
-rm -f conftest.err conftest.$ac_ext
-if $ac_preproc_ok; then
- break
-fi
-
- done
- ac_cv_prog_CPP=$CPP
-
-fi
- CPP=$ac_cv_prog_CPP
-else
- ac_cv_prog_CPP=$CPP
-fi
-echo "$as_me:$LINENO: result: $CPP" >&5
-echo "${ECHO_T}$CPP" >&6
-ac_preproc_ok=false
-for ac_c_preproc_warn_flag in '' yes
-do
- # Use a header file that comes with gcc, so configuring glibc
- # with a fresh cross-compiler works.
- # Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
- # <limits.h> exists even on freestanding compilers.
- # On the NeXT, cc -E runs the code through the compiler's parser,
- # not just through cpp. "Syntax error" is here to catch this case.
- cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-#ifdef __STDC__
-# include <limits.h>
-#else
-# include <assert.h>
-#endif
- Syntax error
-_ACEOF
-if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5
- (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } >/dev/null; then
- if test -s conftest.err; then
- ac_cpp_err=$ac_c_preproc_warn_flag
- ac_cpp_err=$ac_cpp_err$ac_c_werror_flag
- else
- ac_cpp_err=
- fi
-else
- ac_cpp_err=yes
-fi
-if test -z "$ac_cpp_err"; then
- :
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
- # Broken: fails on valid input.
-continue
-fi
-rm -f conftest.err conftest.$ac_ext
-
- # OK, works on sane cases. Now check whether non-existent headers
- # can be detected and how.
- cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-#include <ac_nonexistent.h>
-_ACEOF
-if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5
- (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } >/dev/null; then
- if test -s conftest.err; then
- ac_cpp_err=$ac_c_preproc_warn_flag
- ac_cpp_err=$ac_cpp_err$ac_c_werror_flag
- else
- ac_cpp_err=
- fi
-else
- ac_cpp_err=yes
-fi
-if test -z "$ac_cpp_err"; then
- # Broken: success on invalid input.
-continue
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
- # Passes both tests.
-ac_preproc_ok=:
-break
-fi
-rm -f conftest.err conftest.$ac_ext
-
-done
-# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped.
-rm -f conftest.err conftest.$ac_ext
-if $ac_preproc_ok; then
- :
-else
- { { echo "$as_me:$LINENO: error: C preprocessor \"$CPP\" fails sanity check
-See \`config.log' for more details." >&5
-echo "$as_me: error: C preprocessor \"$CPP\" fails sanity check
-See \`config.log' for more details." >&2;}
- { (exit 1); exit 1; }; }
-fi
-
-ac_ext=c
-ac_cpp='$CPP $CPPFLAGS'
-ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
-ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
-ac_compiler_gnu=$ac_cv_c_compiler_gnu
-
-
-echo "$as_me:$LINENO: checking for ANSI C header files" >&5
-echo $ECHO_N "checking for ANSI C header files... $ECHO_C" >&6
-if test "${ac_cv_header_stdc+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-#include <stdlib.h>
-#include <stdarg.h>
-#include <string.h>
-#include <float.h>
-
-int
-main ()
-{
-
- ;
- return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
- (eval $ac_compile) 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } &&
- { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; } &&
- { ac_try='test -s conftest.$ac_objext'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
- ac_cv_header_stdc=yes
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-ac_cv_header_stdc=no
-fi
-rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
-
-if test $ac_cv_header_stdc = yes; then
- # SunOS 4.x string.h does not declare mem*, contrary to ANSI.
- cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-#include <string.h>
-
-_ACEOF
-if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
- $EGREP "memchr" >/dev/null 2>&1; then
- :
-else
- ac_cv_header_stdc=no
-fi
-rm -f conftest*
-
-fi
-
-if test $ac_cv_header_stdc = yes; then
- # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI.
- cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-#include <stdlib.h>
-
-_ACEOF
-if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
- $EGREP "free" >/dev/null 2>&1; then
- :
-else
- ac_cv_header_stdc=no
-fi
-rm -f conftest*
-
-fi
-
-if test $ac_cv_header_stdc = yes; then
- # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi.
- if test "$cross_compiling" = yes; then
- :
-else
- cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-#include <ctype.h>
-#if ((' ' & 0x0FF) == 0x020)
-# define ISLOWER(c) ('a' <= (c) && (c) <= 'z')
-# define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c))
-#else
-# define ISLOWER(c) \
- (('a' <= (c) && (c) <= 'i') \
- || ('j' <= (c) && (c) <= 'r') \
- || ('s' <= (c) && (c) <= 'z'))
-# define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c))
-#endif
-
-#define XOR(e, f) (((e) && !(f)) || (!(e) && (f)))
-int
-main ()
-{
- int i;
- for (i = 0; i < 256; i++)
- if (XOR (islower (i), ISLOWER (i))
- || toupper (i) != TOUPPER (i))
- exit(2);
- exit (0);
-}
-_ACEOF
-rm -f conftest$ac_exeext
-if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
- (eval $ac_link) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
- :
-else
- echo "$as_me: program exited with status $ac_status" >&5
-echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-( exit $ac_status )
-ac_cv_header_stdc=no
-fi
-rm -f core *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
-fi
-fi
-fi
-echo "$as_me:$LINENO: result: $ac_cv_header_stdc" >&5
-echo "${ECHO_T}$ac_cv_header_stdc" >&6
-if test $ac_cv_header_stdc = yes; then
-
-cat >>confdefs.h <<\_ACEOF
-#define STDC_HEADERS 1
-_ACEOF
-
-fi
-
-# On IRIX 5.3, sys/types and inttypes.h are conflicting.
-
-
-
-
-
-
-
-
-
-for ac_header in sys/types.h sys/stat.h stdlib.h string.h memory.h strings.h \
- inttypes.h stdint.h unistd.h
-do
-as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
-echo "$as_me:$LINENO: checking for $ac_header" >&5
-echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
-if eval "test \"\${$as_ac_Header+set}\" = set"; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-$ac_includes_default
-
-#include <$ac_header>
-_ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
- (eval $ac_compile) 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } &&
- { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; } &&
- { ac_try='test -s conftest.$ac_objext'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
- eval "$as_ac_Header=yes"
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-eval "$as_ac_Header=no"
-fi
-rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
-fi
-echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5
-echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6
-if test `eval echo '${'$as_ac_Header'}'` = yes; then
- cat >>confdefs.h <<_ACEOF
-#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1
-_ACEOF
-
-fi
-
-done
-
-
-
-for ac_header in dlfcn.h
-do
-as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
-if eval "test \"\${$as_ac_Header+set}\" = set"; then
- echo "$as_me:$LINENO: checking for $ac_header" >&5
-echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
-if eval "test \"\${$as_ac_Header+set}\" = set"; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-fi
-echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5
-echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6
-else
- # Is the header compilable?
-echo "$as_me:$LINENO: checking $ac_header usability" >&5
-echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6
-cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-$ac_includes_default
-#include <$ac_header>
-_ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
- (eval $ac_compile) 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } &&
- { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; } &&
- { ac_try='test -s conftest.$ac_objext'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
- ac_header_compiler=yes
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-ac_header_compiler=no
-fi
-rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
-echo "$as_me:$LINENO: result: $ac_header_compiler" >&5
-echo "${ECHO_T}$ac_header_compiler" >&6
-
-# Is the header present?
-echo "$as_me:$LINENO: checking $ac_header presence" >&5
-echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6
-cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-#include <$ac_header>
-_ACEOF
-if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5
- (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } >/dev/null; then
- if test -s conftest.err; then
- ac_cpp_err=$ac_c_preproc_warn_flag
- ac_cpp_err=$ac_cpp_err$ac_c_werror_flag
- else
- ac_cpp_err=
- fi
-else
- ac_cpp_err=yes
-fi
-if test -z "$ac_cpp_err"; then
- ac_header_preproc=yes
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
- ac_header_preproc=no
-fi
-rm -f conftest.err conftest.$ac_ext
-echo "$as_me:$LINENO: result: $ac_header_preproc" >&5
-echo "${ECHO_T}$ac_header_preproc" >&6
-
-# So? What about this header?
-case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in
- yes:no: )
- { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5
-echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;}
- { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5
-echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;}
- ac_header_preproc=yes
- ;;
- no:yes:* )
- { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5
-echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;}
- { echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5
-echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;}
- { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5
-echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;}
- { echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5
-echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;}
- { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5
-echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;}
- { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5
-echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;}
- (
- cat <<\_ASBOX
-## -------------------------------------------- ##
-## Report this to general@lists@openfabrics.org ##
-## -------------------------------------------- ##
-_ASBOX
- ) |
- sed "s/^/$as_me: WARNING: /" >&2
- ;;
-esac
-echo "$as_me:$LINENO: checking for $ac_header" >&5
-echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
-if eval "test \"\${$as_ac_Header+set}\" = set"; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- eval "$as_ac_Header=\$ac_header_preproc"
-fi
-echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5
-echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6
-
-fi
-if test `eval echo '${'$as_ac_Header'}'` = yes; then
- cat >>confdefs.h <<_ACEOF
-#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1
-_ACEOF
-
-fi
-
-done
-
-ac_ext=cc
-ac_cpp='$CXXCPP $CPPFLAGS'
-ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
-ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
-ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
-if test -n "$ac_tool_prefix"; then
- for ac_prog in $CCC g++ c++ gpp aCC CC cxx cc++ cl FCC KCC RCC xlC_r xlC
- do
- # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args.
-set dummy $ac_tool_prefix$ac_prog; ac_word=$2
-echo "$as_me:$LINENO: checking for $ac_word" >&5
-echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
-if test "${ac_cv_prog_CXX+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- if test -n "$CXX"; then
- ac_cv_prog_CXX="$CXX" # Let the user override the test.
-else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
- IFS=$as_save_IFS
- test -z "$as_dir" && as_dir=.
- for ac_exec_ext in '' $ac_executable_extensions; do
- if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
- ac_cv_prog_CXX="$ac_tool_prefix$ac_prog"
- echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
- break 2
- fi
-done
-done
-
-fi
-fi
-CXX=$ac_cv_prog_CXX
-if test -n "$CXX"; then
- echo "$as_me:$LINENO: result: $CXX" >&5
-echo "${ECHO_T}$CXX" >&6
-else
- echo "$as_me:$LINENO: result: no" >&5
-echo "${ECHO_T}no" >&6
-fi
-
- test -n "$CXX" && break
- done
-fi
-if test -z "$CXX"; then
- ac_ct_CXX=$CXX
- for ac_prog in $CCC g++ c++ gpp aCC CC cxx cc++ cl FCC KCC RCC xlC_r xlC
-do
- # Extract the first word of "$ac_prog", so it can be a program name with args.
-set dummy $ac_prog; ac_word=$2
-echo "$as_me:$LINENO: checking for $ac_word" >&5
-echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
-if test "${ac_cv_prog_ac_ct_CXX+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- if test -n "$ac_ct_CXX"; then
- ac_cv_prog_ac_ct_CXX="$ac_ct_CXX" # Let the user override the test.
-else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
- IFS=$as_save_IFS
- test -z "$as_dir" && as_dir=.
- for ac_exec_ext in '' $ac_executable_extensions; do
- if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
- ac_cv_prog_ac_ct_CXX="$ac_prog"
- echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
- break 2
- fi
-done
-done
-
-fi
-fi
-ac_ct_CXX=$ac_cv_prog_ac_ct_CXX
-if test -n "$ac_ct_CXX"; then
- echo "$as_me:$LINENO: result: $ac_ct_CXX" >&5
-echo "${ECHO_T}$ac_ct_CXX" >&6
-else
- echo "$as_me:$LINENO: result: no" >&5
-echo "${ECHO_T}no" >&6
-fi
-
- test -n "$ac_ct_CXX" && break
-done
-test -n "$ac_ct_CXX" || ac_ct_CXX="g++"
-
- CXX=$ac_ct_CXX
-fi
-
-
-# Provide some information about the compiler.
-echo "$as_me:$LINENO:" \
- "checking for C++ compiler version" >&5
-ac_compiler=`set X $ac_compile; echo $2`
-{ (eval echo "$as_me:$LINENO: \"$ac_compiler --version </dev/null >&5\"") >&5
- (eval $ac_compiler --version </dev/null >&5) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }
-{ (eval echo "$as_me:$LINENO: \"$ac_compiler -v </dev/null >&5\"") >&5
- (eval $ac_compiler -v </dev/null >&5) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }
-{ (eval echo "$as_me:$LINENO: \"$ac_compiler -V </dev/null >&5\"") >&5
- (eval $ac_compiler -V </dev/null >&5) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }
-
-echo "$as_me:$LINENO: checking whether we are using the GNU C++ compiler" >&5
-echo $ECHO_N "checking whether we are using the GNU C++ compiler... $ECHO_C" >&6
-if test "${ac_cv_cxx_compiler_gnu+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-
-int
-main ()
-{
-#ifndef __GNUC__
- choke me
-#endif
-
- ;
- return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
- (eval $ac_compile) 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } &&
- { ac_try='test -z "$ac_cxx_werror_flag" || test ! -s conftest.err'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; } &&
- { ac_try='test -s conftest.$ac_objext'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
- ac_compiler_gnu=yes
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-ac_compiler_gnu=no
-fi
-rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
-ac_cv_cxx_compiler_gnu=$ac_compiler_gnu
-
-fi
-echo "$as_me:$LINENO: result: $ac_cv_cxx_compiler_gnu" >&5
-echo "${ECHO_T}$ac_cv_cxx_compiler_gnu" >&6
-GXX=`test $ac_compiler_gnu = yes && echo yes`
-ac_test_CXXFLAGS=${CXXFLAGS+set}
-ac_save_CXXFLAGS=$CXXFLAGS
-CXXFLAGS="-g"
-echo "$as_me:$LINENO: checking whether $CXX accepts -g" >&5
-echo $ECHO_N "checking whether $CXX accepts -g... $ECHO_C" >&6
-if test "${ac_cv_prog_cxx_g+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-
-int
-main ()
-{
-
- ;
- return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
- (eval $ac_compile) 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } &&
- { ac_try='test -z "$ac_cxx_werror_flag" || test ! -s conftest.err'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; } &&
- { ac_try='test -s conftest.$ac_objext'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
- ac_cv_prog_cxx_g=yes
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-ac_cv_prog_cxx_g=no
-fi
-rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
-fi
-echo "$as_me:$LINENO: result: $ac_cv_prog_cxx_g" >&5
-echo "${ECHO_T}$ac_cv_prog_cxx_g" >&6
-if test "$ac_test_CXXFLAGS" = set; then
- CXXFLAGS=$ac_save_CXXFLAGS
-elif test $ac_cv_prog_cxx_g = yes; then
- if test "$GXX" = yes; then
- CXXFLAGS="-g -O2"
- else
- CXXFLAGS="-g"
- fi
-else
- if test "$GXX" = yes; then
- CXXFLAGS="-O2"
- else
- CXXFLAGS=
- fi
-fi
-for ac_declaration in \
- '' \
- 'extern "C" void std::exit (int) throw (); using std::exit;' \
- 'extern "C" void std::exit (int); using std::exit;' \
- 'extern "C" void exit (int) throw ();' \
- 'extern "C" void exit (int);' \
- 'void exit (int);'
-do
- cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-$ac_declaration
-#include <stdlib.h>
-int
-main ()
-{
-exit (42);
- ;
- return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
- (eval $ac_compile) 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } &&
- { ac_try='test -z "$ac_cxx_werror_flag" || test ! -s conftest.err'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; } &&
- { ac_try='test -s conftest.$ac_objext'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
- :
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-continue
-fi
-rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
- cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-$ac_declaration
-int
-main ()
-{
-exit (42);
- ;
- return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
- (eval $ac_compile) 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } &&
- { ac_try='test -z "$ac_cxx_werror_flag" || test ! -s conftest.err'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; } &&
- { ac_try='test -s conftest.$ac_objext'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
- break
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-fi
-rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
-done
-rm -f conftest*
-if test -n "$ac_declaration"; then
- echo '#ifdef __cplusplus' >>confdefs.h
- echo $ac_declaration >>confdefs.h
- echo '#endif' >>confdefs.h
-fi
-
-ac_ext=cc
-ac_cpp='$CXXCPP $CPPFLAGS'
-ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
-ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
-ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
-
-depcc="$CXX" am_compiler_list=
-
-echo "$as_me:$LINENO: checking dependency style of $depcc" >&5
-echo $ECHO_N "checking dependency style of $depcc... $ECHO_C" >&6
-if test "${am_cv_CXX_dependencies_compiler_type+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then
- # We make a subdir and do the tests there. Otherwise we can end up
- # making bogus files that we don't know about and never remove. For
- # instance it was reported that on HP-UX the gcc test will end up
- # making a dummy file named `D' -- because `-MD' means `put the output
- # in D'.
- mkdir conftest.dir
- # Copy depcomp to subdir because otherwise we won't find it if we're
- # using a relative directory.
- cp "$am_depcomp" conftest.dir
- cd conftest.dir
- # We will build objects and dependencies in a subdirectory because
- # it helps to detect inapplicable dependency modes. For instance
- # both Tru64's cc and ICC support -MD to output dependencies as a
- # side effect of compilation, but ICC will put the dependencies in
- # the current directory while Tru64 will put them in the object
- # directory.
- mkdir sub
-
- am_cv_CXX_dependencies_compiler_type=none
- if test "$am_compiler_list" = ""; then
- am_compiler_list=`sed -n 's/^#*\([a-zA-Z0-9]*\))$/\1/p' < ./depcomp`
- fi
- for depmode in $am_compiler_list; do
- # Setup a source with many dependencies, because some compilers
- # like to wrap large dependency lists on column 80 (with \), and
- # we should not choose a depcomp mode which is confused by this.
- #
- # We need to recreate these files for each test, as the compiler may
- # overwrite some of them when testing with obscure command lines.
- # This happens at least with the AIX C compiler.
- : > sub/conftest.c
- for i in 1 2 3 4 5 6; do
- echo '#include "conftst'$i'.h"' >> sub/conftest.c
- # Using `: > sub/conftst$i.h' creates only sub/conftst1.h with
- # Solaris 8's {/usr,}/bin/sh.
- touch sub/conftst$i.h
- done
- echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf
-
- case $depmode in
- nosideeffect)
- # after this tag, mechanisms are not by side-effect, so they'll
- # only be used when explicitly requested
- if test "x$enable_dependency_tracking" = xyes; then
- continue
- else
- break
- fi
- ;;
- none) break ;;
- esac
- # We check with `-c' and `-o' for the sake of the "dashmstdout"
- # mode. It turns out that the SunPro C++ compiler does not properly
- # handle `-M -o', and we need to detect this.
- if depmode=$depmode \
- source=sub/conftest.c object=sub/conftest.${OBJEXT-o} \
- depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \
- $SHELL ./depcomp $depcc -c -o sub/conftest.${OBJEXT-o} sub/conftest.c \
- >/dev/null 2>conftest.err &&
- grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 &&
- grep sub/conftest.${OBJEXT-o} sub/conftest.Po > /dev/null 2>&1 &&
- ${MAKE-make} -s -f confmf > /dev/null 2>&1; then
- # icc doesn't choke on unknown options, it will just issue warnings
- # or remarks (even with -Werror). So we grep stderr for any message
- # that says an option was ignored or not supported.
- # When given -MP, icc 7.0 and 7.1 complain thusly:
- # icc: Command line warning: ignoring option '-M'; no argument required
- # The diagnosis changed in icc 8.0:
- # icc: Command line remark: option '-MP' not supported
- if (grep 'ignoring option' conftest.err ||
- grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else
- am_cv_CXX_dependencies_compiler_type=$depmode
- break
- fi
- fi
- done
-
- cd ..
- rm -rf conftest.dir
-else
- am_cv_CXX_dependencies_compiler_type=none
-fi
-
-fi
-echo "$as_me:$LINENO: result: $am_cv_CXX_dependencies_compiler_type" >&5
-echo "${ECHO_T}$am_cv_CXX_dependencies_compiler_type" >&6
-CXXDEPMODE=depmode=$am_cv_CXX_dependencies_compiler_type
-
-
-
-if
- test "x$enable_dependency_tracking" != xno \
- && test "$am_cv_CXX_dependencies_compiler_type" = gcc3; then
- am__fastdepCXX_TRUE=
- am__fastdepCXX_FALSE='#'
-else
- am__fastdepCXX_TRUE='#'
- am__fastdepCXX_FALSE=
-fi
-
-
-
-
-if test -n "$CXX" && ( test "X$CXX" != "Xno" &&
- ( (test "X$CXX" = "Xg++" && `g++ -v >/dev/null 2>&1` ) ||
- (test "X$CXX" != "Xg++"))) ; then
- ac_ext=cc
-ac_cpp='$CXXCPP $CPPFLAGS'
-ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
-ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
-ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
-echo "$as_me:$LINENO: checking how to run the C++ preprocessor" >&5
-echo $ECHO_N "checking how to run the C++ preprocessor... $ECHO_C" >&6
-if test -z "$CXXCPP"; then
- if test "${ac_cv_prog_CXXCPP+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- # Double quotes because CXXCPP needs to be expanded
- for CXXCPP in "$CXX -E" "/lib/cpp"
- do
- ac_preproc_ok=false
-for ac_cxx_preproc_warn_flag in '' yes
-do
- # Use a header file that comes with gcc, so configuring glibc
- # with a fresh cross-compiler works.
- # Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
- # <limits.h> exists even on freestanding compilers.
- # On the NeXT, cc -E runs the code through the compiler's parser,
- # not just through cpp. "Syntax error" is here to catch this case.
- cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-#ifdef __STDC__
-# include <limits.h>
-#else
-# include <assert.h>
-#endif
- Syntax error
-_ACEOF
-if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5
- (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } >/dev/null; then
- if test -s conftest.err; then
- ac_cpp_err=$ac_cxx_preproc_warn_flag
- ac_cpp_err=$ac_cpp_err$ac_cxx_werror_flag
- else
- ac_cpp_err=
- fi
-else
- ac_cpp_err=yes
-fi
-if test -z "$ac_cpp_err"; then
- :
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
- # Broken: fails on valid input.
-continue
-fi
-rm -f conftest.err conftest.$ac_ext
-
- # OK, works on sane cases. Now check whether non-existent headers
- # can be detected and how.
- cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-#include <ac_nonexistent.h>
-_ACEOF
-if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5
- (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } >/dev/null; then
- if test -s conftest.err; then
- ac_cpp_err=$ac_cxx_preproc_warn_flag
- ac_cpp_err=$ac_cpp_err$ac_cxx_werror_flag
- else
- ac_cpp_err=
- fi
-else
- ac_cpp_err=yes
-fi
-if test -z "$ac_cpp_err"; then
- # Broken: success on invalid input.
-continue
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
- # Passes both tests.
-ac_preproc_ok=:
-break
-fi
-rm -f conftest.err conftest.$ac_ext
-
-done
-# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped.
-rm -f conftest.err conftest.$ac_ext
-if $ac_preproc_ok; then
- break
-fi
-
- done
- ac_cv_prog_CXXCPP=$CXXCPP
-
-fi
- CXXCPP=$ac_cv_prog_CXXCPP
-else
- ac_cv_prog_CXXCPP=$CXXCPP
-fi
-echo "$as_me:$LINENO: result: $CXXCPP" >&5
-echo "${ECHO_T}$CXXCPP" >&6
-ac_preproc_ok=false
-for ac_cxx_preproc_warn_flag in '' yes
-do
- # Use a header file that comes with gcc, so configuring glibc
- # with a fresh cross-compiler works.
- # Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
- # <limits.h> exists even on freestanding compilers.
- # On the NeXT, cc -E runs the code through the compiler's parser,
- # not just through cpp. "Syntax error" is here to catch this case.
- cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-#ifdef __STDC__
-# include <limits.h>
-#else
-# include <assert.h>
-#endif
- Syntax error
-_ACEOF
-if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5
- (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } >/dev/null; then
- if test -s conftest.err; then
- ac_cpp_err=$ac_cxx_preproc_warn_flag
- ac_cpp_err=$ac_cpp_err$ac_cxx_werror_flag
- else
- ac_cpp_err=
- fi
-else
- ac_cpp_err=yes
-fi
-if test -z "$ac_cpp_err"; then
- :
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
- # Broken: fails on valid input.
-continue
-fi
-rm -f conftest.err conftest.$ac_ext
-
- # OK, works on sane cases. Now check whether non-existent headers
- # can be detected and how.
- cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-#include <ac_nonexistent.h>
-_ACEOF
-if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5
- (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } >/dev/null; then
- if test -s conftest.err; then
- ac_cpp_err=$ac_cxx_preproc_warn_flag
- ac_cpp_err=$ac_cpp_err$ac_cxx_werror_flag
- else
- ac_cpp_err=
- fi
-else
- ac_cpp_err=yes
-fi
-if test -z "$ac_cpp_err"; then
- # Broken: success on invalid input.
-continue
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
- # Passes both tests.
-ac_preproc_ok=:
-break
-fi
-rm -f conftest.err conftest.$ac_ext
-
-done
-# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped.
-rm -f conftest.err conftest.$ac_ext
-if $ac_preproc_ok; then
- :
-else
- { { echo "$as_me:$LINENO: error: C++ preprocessor \"$CXXCPP\" fails sanity check
-See \`config.log' for more details." >&5
-echo "$as_me: error: C++ preprocessor \"$CXXCPP\" fails sanity check
-See \`config.log' for more details." >&2;}
- { (exit 1); exit 1; }; }
-fi
-
-ac_ext=cc
-ac_cpp='$CXXCPP $CPPFLAGS'
-ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
-ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
-ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
-
-fi
-
-
-ac_ext=f
-ac_compile='$F77 -c $FFLAGS conftest.$ac_ext >&5'
-ac_link='$F77 -o conftest$ac_exeext $FFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
-ac_compiler_gnu=$ac_cv_f77_compiler_gnu
-if test -n "$ac_tool_prefix"; then
- for ac_prog in g77 f77 xlf frt pgf77 fort77 fl32 af77 f90 xlf90 pgf90 epcf90 f95 fort xlf95 ifc efc pgf95 lf95 gfortran
- do
- # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args.
-set dummy $ac_tool_prefix$ac_prog; ac_word=$2
-echo "$as_me:$LINENO: checking for $ac_word" >&5
-echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
-if test "${ac_cv_prog_F77+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- if test -n "$F77"; then
- ac_cv_prog_F77="$F77" # Let the user override the test.
-else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
- IFS=$as_save_IFS
- test -z "$as_dir" && as_dir=.
- for ac_exec_ext in '' $ac_executable_extensions; do
- if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
- ac_cv_prog_F77="$ac_tool_prefix$ac_prog"
- echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
- break 2
- fi
-done
-done
-
-fi
-fi
-F77=$ac_cv_prog_F77
-if test -n "$F77"; then
- echo "$as_me:$LINENO: result: $F77" >&5
-echo "${ECHO_T}$F77" >&6
-else
- echo "$as_me:$LINENO: result: no" >&5
-echo "${ECHO_T}no" >&6
-fi
-
- test -n "$F77" && break
- done
-fi
-if test -z "$F77"; then
- ac_ct_F77=$F77
- for ac_prog in g77 f77 xlf frt pgf77 fort77 fl32 af77 f90 xlf90 pgf90 epcf90 f95 fort xlf95 ifc efc pgf95 lf95 gfortran
-do
- # Extract the first word of "$ac_prog", so it can be a program name with args.
-set dummy $ac_prog; ac_word=$2
-echo "$as_me:$LINENO: checking for $ac_word" >&5
-echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
-if test "${ac_cv_prog_ac_ct_F77+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- if test -n "$ac_ct_F77"; then
- ac_cv_prog_ac_ct_F77="$ac_ct_F77" # Let the user override the test.
-else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
- IFS=$as_save_IFS
- test -z "$as_dir" && as_dir=.
- for ac_exec_ext in '' $ac_executable_extensions; do
- if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
- ac_cv_prog_ac_ct_F77="$ac_prog"
- echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
- break 2
- fi
-done
-done
-
-fi
-fi
-ac_ct_F77=$ac_cv_prog_ac_ct_F77
-if test -n "$ac_ct_F77"; then
- echo "$as_me:$LINENO: result: $ac_ct_F77" >&5
-echo "${ECHO_T}$ac_ct_F77" >&6
-else
- echo "$as_me:$LINENO: result: no" >&5
-echo "${ECHO_T}no" >&6
-fi
-
- test -n "$ac_ct_F77" && break
-done
-
- F77=$ac_ct_F77
-fi
-
-
-# Provide some information about the compiler.
-echo "$as_me:5264:" \
- "checking for Fortran 77 compiler version" >&5
-ac_compiler=`set X $ac_compile; echo $2`
-{ (eval echo "$as_me:$LINENO: \"$ac_compiler --version </dev/null >&5\"") >&5
- (eval $ac_compiler --version </dev/null >&5) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }
-{ (eval echo "$as_me:$LINENO: \"$ac_compiler -v </dev/null >&5\"") >&5
- (eval $ac_compiler -v </dev/null >&5) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }
-{ (eval echo "$as_me:$LINENO: \"$ac_compiler -V </dev/null >&5\"") >&5
- (eval $ac_compiler -V </dev/null >&5) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }
-rm -f a.out
-
-# If we don't use `.F' as extension, the preprocessor is not run on the
-# input file. (Note that this only needs to work for GNU compilers.)
-ac_save_ext=$ac_ext
-ac_ext=F
-echo "$as_me:$LINENO: checking whether we are using the GNU Fortran 77 compiler" >&5
-echo $ECHO_N "checking whether we are using the GNU Fortran 77 compiler... $ECHO_C" >&6
-if test "${ac_cv_f77_compiler_gnu+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- cat >conftest.$ac_ext <<_ACEOF
- program main
-#ifndef __GNUC__
- choke me
-#endif
-
- end
-_ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
- (eval $ac_compile) 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } &&
- { ac_try='test -z "$ac_f77_werror_flag" || test ! -s conftest.err'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; } &&
- { ac_try='test -s conftest.$ac_objext'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
- ac_compiler_gnu=yes
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-ac_compiler_gnu=no
-fi
-rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
-ac_cv_f77_compiler_gnu=$ac_compiler_gnu
-
-fi
-echo "$as_me:$LINENO: result: $ac_cv_f77_compiler_gnu" >&5
-echo "${ECHO_T}$ac_cv_f77_compiler_gnu" >&6
-ac_ext=$ac_save_ext
-ac_test_FFLAGS=${FFLAGS+set}
-ac_save_FFLAGS=$FFLAGS
-FFLAGS=
-echo "$as_me:$LINENO: checking whether $F77 accepts -g" >&5
-echo $ECHO_N "checking whether $F77 accepts -g... $ECHO_C" >&6
-if test "${ac_cv_prog_f77_g+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- FFLAGS=-g
-cat >conftest.$ac_ext <<_ACEOF
- program main
-
- end
-_ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
- (eval $ac_compile) 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } &&
- { ac_try='test -z "$ac_f77_werror_flag" || test ! -s conftest.err'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; } &&
- { ac_try='test -s conftest.$ac_objext'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
- ac_cv_prog_f77_g=yes
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-ac_cv_prog_f77_g=no
-fi
-rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
-
-fi
-echo "$as_me:$LINENO: result: $ac_cv_prog_f77_g" >&5
-echo "${ECHO_T}$ac_cv_prog_f77_g" >&6
-if test "$ac_test_FFLAGS" = set; then
- FFLAGS=$ac_save_FFLAGS
-elif test $ac_cv_prog_f77_g = yes; then
- if test "x$ac_cv_f77_compiler_gnu" = xyes; then
- FFLAGS="-g -O2"
- else
- FFLAGS="-g"
- fi
-else
- if test "x$ac_cv_f77_compiler_gnu" = xyes; then
- FFLAGS="-O2"
- else
- FFLAGS=
- fi
-fi
-
-G77=`test $ac_compiler_gnu = yes && echo yes`
-ac_ext=c
-ac_cpp='$CPP $CPPFLAGS'
-ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
-ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
-ac_compiler_gnu=$ac_cv_c_compiler_gnu
-
-
-
-# Autoconf 2.13's AC_OBJEXT and AC_EXEEXT macros only works for C compilers!
-
-# find the maximum length of command line arguments
-echo "$as_me:$LINENO: checking the maximum length of command line arguments" >&5
-echo $ECHO_N "checking the maximum length of command line arguments... $ECHO_C" >&6
-if test "${lt_cv_sys_max_cmd_len+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- i=0
- teststring="ABCD"
-
- case $build_os in
- msdosdjgpp*)
- # On DJGPP, this test can blow up pretty badly due to problems in libc
- # (any single argument exceeding 2000 bytes causes a buffer overrun
- # during glob expansion). Even if it were fixed, the result of this
- # check would be larger than it should be.
- lt_cv_sys_max_cmd_len=12288; # 12K is about right
- ;;
-
- gnu*)
- # Under GNU Hurd, this test is not required because there is
- # no limit to the length of command line arguments.
- # Libtool will interpret -1 as no limit whatsoever
- lt_cv_sys_max_cmd_len=-1;
- ;;
-
- cygwin* | mingw*)
- # On Win9x/ME, this test blows up -- it succeeds, but takes
- # about 5 minutes as the teststring grows exponentially.
- # Worse, since 9x/ME are not pre-emptively multitasking,
- # you end up with a "frozen" computer, even though with patience
- # the test eventually succeeds (with a max line length of 256k).
- # Instead, let's just punt: use the minimum linelength reported by
- # all of the supported platforms: 8192 (on NT/2K/XP).
- lt_cv_sys_max_cmd_len=8192;
- ;;
-
- amigaos*)
- # On AmigaOS with pdksh, this test takes hours, literally.
- # So we just punt and use a minimum line length of 8192.
- lt_cv_sys_max_cmd_len=8192;
- ;;
-
- netbsd* | freebsd* | openbsd* | darwin* | dragonfly*)
- # This has been around since 386BSD, at least. Likely further.
- if test -x /sbin/sysctl; then
- lt_cv_sys_max_cmd_len=`/sbin/sysctl -n kern.argmax`
- elif test -x /usr/sbin/sysctl; then
- lt_cv_sys_max_cmd_len=`/usr/sbin/sysctl -n kern.argmax`
- else
- lt_cv_sys_max_cmd_len=65536 # usable default for all BSDs
- fi
- # And add a safety zone
- lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4`
- lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3`
- ;;
-
- interix*)
- # We know the value 262144 and hardcode it with a safety zone (like BSD)
- lt_cv_sys_max_cmd_len=196608
- ;;
-
- osf*)
- # Dr. Hans Ekkehard Plesser reports seeing a kernel panic running configure
- # due to this test when exec_disable_arg_limit is 1 on Tru64. It is not
- # nice to cause kernel panics so lets avoid the loop below.
- # First set a reasonable default.
- lt_cv_sys_max_cmd_len=16384
- #
- if test -x /sbin/sysconfig; then
- case `/sbin/sysconfig -q proc exec_disable_arg_limit` in
- *1*) lt_cv_sys_max_cmd_len=-1 ;;
- esac
- fi
- ;;
- sco3.2v5*)
- lt_cv_sys_max_cmd_len=102400
- ;;
- sysv5* | sco5v6* | sysv4.2uw2*)
- kargmax=`grep ARG_MAX /etc/conf/cf.d/stune 2>/dev/null`
- if test -n "$kargmax"; then
- lt_cv_sys_max_cmd_len=`echo $kargmax | sed 's/.*[ ]//'`
- else
- lt_cv_sys_max_cmd_len=32768
- fi
- ;;
- *)
- # If test is not a shell built-in, we'll probably end up computing a
- # maximum length that is only half of the actual maximum length, but
- # we can't tell.
- SHELL=${SHELL-${CONFIG_SHELL-/bin/sh}}
- while (test "X"`$SHELL $0 --fallback-echo "X$teststring" 2>/dev/null` \
- = "XX$teststring") >/dev/null 2>&1 &&
- new_result=`expr "X$teststring" : ".*" 2>&1` &&
- lt_cv_sys_max_cmd_len=$new_result &&
- test $i != 17 # 1/2 MB should be enough
- do
- i=`expr $i + 1`
- teststring=$teststring$teststring
- done
- teststring=
- # Add a significant safety factor because C++ compilers can tack on massive
- # amounts of additional arguments before passing them to the linker.
- # It appears as though 1/2 is a usable value.
- lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 2`
- ;;
- esac
-
-fi
-
-if test -n $lt_cv_sys_max_cmd_len ; then
- echo "$as_me:$LINENO: result: $lt_cv_sys_max_cmd_len" >&5
-echo "${ECHO_T}$lt_cv_sys_max_cmd_len" >&6
-else
- echo "$as_me:$LINENO: result: none" >&5
-echo "${ECHO_T}none" >&6
-fi
-
-
-
-
-# Check for command to grab the raw symbol name followed by C symbol from nm.
-echo "$as_me:$LINENO: checking command to parse $NM output from $compiler object" >&5
-echo $ECHO_N "checking command to parse $NM output from $compiler object... $ECHO_C" >&6
-if test "${lt_cv_sys_global_symbol_pipe+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-
-# These are sane defaults that work on at least a few old systems.
-# [They come from Ultrix. What could be older than Ultrix?!! ;)]
-
-# Character class describing NM global symbol codes.
-symcode='[BCDEGRST]'
-
-# Regexp to match symbols that can be accessed directly from C.
-sympat='\([_A-Za-z][_A-Za-z0-9]*\)'
-
-# Transform an extracted symbol line into a proper C declaration
-lt_cv_sys_global_symbol_to_cdecl="sed -n -e 's/^. .* \(.*\)$/extern int \1;/p'"
-
-# Transform an extracted symbol line into symbol name and symbol address
-lt_cv_sys_global_symbol_to_c_name_address="sed -n -e 's/^: \([^ ]*\) $/ {\\\"\1\\\", (lt_ptr) 0},/p' -e 's/^$symcode \([^ ]*\) \([^ ]*\)$/ {\"\2\", (lt_ptr) \&\2},/p'"
-
-# Define system-specific variables.
-case $host_os in
-aix*)
- symcode='[BCDT]'
- ;;
-cygwin* | mingw* | pw32*)
- symcode='[ABCDGISTW]'
- ;;
-hpux*) # Its linker distinguishes data from code symbols
- if test "$host_cpu" = ia64; then
- symcode='[ABCDEGRST]'
- fi
- lt_cv_sys_global_symbol_to_cdecl="sed -n -e 's/^T .* \(.*\)$/extern int \1();/p' -e 's/^$symcode* .* \(.*\)$/extern char \1;/p'"
- lt_cv_sys_global_symbol_to_c_name_address="sed -n -e 's/^: \([^ ]*\) $/ {\\\"\1\\\", (lt_ptr) 0},/p' -e 's/^$symcode* \([^ ]*\) \([^ ]*\)$/ {\"\2\", (lt_ptr) \&\2},/p'"
- ;;
-linux*)
- if test "$host_cpu" = ia64; then
- symcode='[ABCDGIRSTW]'
- lt_cv_sys_global_symbol_to_cdecl="sed -n -e 's/^T .* \(.*\)$/extern int \1();/p' -e 's/^$symcode* .* \(.*\)$/extern char \1;/p'"
- lt_cv_sys_global_symbol_to_c_name_address="sed -n -e 's/^: \([^ ]*\) $/ {\\\"\1\\\", (lt_ptr) 0},/p' -e 's/^$symcode* \([^ ]*\) \([^ ]*\)$/ {\"\2\", (lt_ptr) \&\2},/p'"
- fi
- ;;
-irix* | nonstopux*)
- symcode='[BCDEGRST]'
- ;;
-osf*)
- symcode='[BCDEGQRST]'
- ;;
-solaris*)
- symcode='[BDRT]'
- ;;
-sco3.2v5*)
- symcode='[DT]'
- ;;
-sysv4.2uw2*)
- symcode='[DT]'
- ;;
-sysv5* | sco5v6* | unixware* | OpenUNIX*)
- symcode='[ABDT]'
- ;;
-sysv4)
- symcode='[DFNSTU]'
- ;;
-esac
-
-# Handle CRLF in mingw tool chain
-opt_cr=
-case $build_os in
-mingw*)
- opt_cr=`echo 'x\{0,1\}' | tr x '\015'` # option cr in regexp
- ;;
-esac
-
-# If we're using GNU nm, then use its standard symbol codes.
-case `$NM -V 2>&1` in
-*GNU* | *'with BFD'*)
- symcode='[ABCDGIRSTW]' ;;
-esac
-
-# Try without a prefix undercore, then with it.
-for ac_symprfx in "" "_"; do
-
- # Transform symcode, sympat, and symprfx into a raw symbol and a C symbol.
- symxfrm="\\1 $ac_symprfx\\2 \\2"
-
- # Write the raw and C identifiers.
- lt_cv_sys_global_symbol_pipe="sed -n -e 's/^.*[ ]\($symcode$symcode*\)[ ][ ]*$ac_symprfx$sympat$opt_cr$/$symxfrm/p'"
-
- # Check to see that the pipe works correctly.
- pipe_works=no
-
- rm -f conftest*
- cat > conftest.$ac_ext <<EOF
-#ifdef __cplusplus
-extern "C" {
-#endif
-char nm_test_var;
-void nm_test_func(){}
-#ifdef __cplusplus
-}
-#endif
-int main(){nm_test_var='a';nm_test_func();return(0);}
-EOF
-
- if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
- (eval $ac_compile) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; then
- # Now try to grab the symbols.
- nlist=conftest.nm
- if { (eval echo "$as_me:$LINENO: \"$NM conftest.$ac_objext \| $lt_cv_sys_global_symbol_pipe \> $nlist\"") >&5
- (eval $NM conftest.$ac_objext \| $lt_cv_sys_global_symbol_pipe \> $nlist) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } && test -s "$nlist"; then
- # Try sorting and uniquifying the output.
- if sort "$nlist" | uniq > "$nlist"T; then
- mv -f "$nlist"T "$nlist"
- else
- rm -f "$nlist"T
- fi
-
- # Make sure that we snagged all the symbols we need.
- if grep ' nm_test_var$' "$nlist" >/dev/null; then
- if grep ' nm_test_func$' "$nlist" >/dev/null; then
- cat <<EOF > conftest.$ac_ext
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-EOF
- # Now generate the symbol file.
- eval "$lt_cv_sys_global_symbol_to_cdecl"' < "$nlist" | grep -v main >> conftest.$ac_ext'
-
- cat <<EOF >> conftest.$ac_ext
-#if defined (__STDC__) && __STDC__
-# define lt_ptr_t void *
-#else
-# define lt_ptr_t char *
-# define const
-#endif
-
-/* The mapping between symbol names and symbols. */
-const struct {
- const char *name;
- lt_ptr_t address;
-}
-lt_preloaded_symbols[] =
-{
-EOF
- $SED "s/^$symcode$symcode* \(.*\) \(.*\)$/ {\"\2\", (lt_ptr_t) \&\2},/" < "$nlist" | grep -v main >> conftest.$ac_ext
- cat <<\EOF >> conftest.$ac_ext
- {0, (lt_ptr_t) 0}
-};
-
-#ifdef __cplusplus
-}
-#endif
-EOF
- # Now try linking the two files.
- mv conftest.$ac_objext conftstm.$ac_objext
- lt_save_LIBS="$LIBS"
- lt_save_CFLAGS="$CFLAGS"
- LIBS="conftstm.$ac_objext"
- CFLAGS="$CFLAGS$lt_prog_compiler_no_builtin_flag"
- if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
- (eval $ac_link) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } && test -s conftest${ac_exeext}; then
- pipe_works=yes
- fi
- LIBS="$lt_save_LIBS"
- CFLAGS="$lt_save_CFLAGS"
- else
- echo "cannot find nm_test_func in $nlist" >&5
- fi
- else
- echo "cannot find nm_test_var in $nlist" >&5
- fi
- else
- echo "cannot run $lt_cv_sys_global_symbol_pipe" >&5
- fi
- else
- echo "$progname: failed program was:" >&5
- cat conftest.$ac_ext >&5
- fi
- rm -f conftest* conftst*
-
- # Do not use the global_symbol_pipe unless it works.
- if test "$pipe_works" = yes; then
- break
- else
- lt_cv_sys_global_symbol_pipe=
- fi
-done
-
-fi
-
-if test -z "$lt_cv_sys_global_symbol_pipe"; then
- lt_cv_sys_global_symbol_to_cdecl=
-fi
-if test -z "$lt_cv_sys_global_symbol_pipe$lt_cv_sys_global_symbol_to_cdecl"; then
- echo "$as_me:$LINENO: result: failed" >&5
-echo "${ECHO_T}failed" >&6
-else
- echo "$as_me:$LINENO: result: ok" >&5
-echo "${ECHO_T}ok" >&6
-fi
-
-echo "$as_me:$LINENO: checking for objdir" >&5
-echo $ECHO_N "checking for objdir... $ECHO_C" >&6
-if test "${lt_cv_objdir+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- rm -f .libs 2>/dev/null
-mkdir .libs 2>/dev/null
-if test -d .libs; then
- lt_cv_objdir=.libs
-else
- # MS-DOS does not allow filenames that begin with a dot.
- lt_cv_objdir=_libs
-fi
-rmdir .libs 2>/dev/null
-fi
-echo "$as_me:$LINENO: result: $lt_cv_objdir" >&5
-echo "${ECHO_T}$lt_cv_objdir" >&6
-objdir=$lt_cv_objdir
-
-
-
-
-
-case $host_os in
-aix3*)
- # AIX sometimes has problems with the GCC collect2 program. For some
- # reason, if we set the COLLECT_NAMES environment variable, the problems
- # vanish in a puff of smoke.
- if test "X${COLLECT_NAMES+set}" != Xset; then
- COLLECT_NAMES=
- export COLLECT_NAMES
- fi
- ;;
-esac
-
-# Sed substitution that helps us do robust quoting. It backslashifies
-# metacharacters that are still active within double-quoted strings.
-Xsed='sed -e 1s/^X//'
-sed_quote_subst='s/\([\\"\\`$\\\\]\)/\\\1/g'
-
-# Same as above, but do not quote variable references.
-double_quote_subst='s/\([\\"\\`\\\\]\)/\\\1/g'
-
-# Sed substitution to delay expansion of an escaped shell variable in a
-# double_quote_subst'ed string.
-delay_variable_subst='s/\\\\\\\\\\\$/\\\\\\$/g'
-
-# Sed substitution to avoid accidental globbing in evaled expressions
-no_glob_subst='s/\*/\\\*/g'
-
-# Constants:
-rm="rm -f"
-
-# Global variables:
-default_ofile=libtool
-can_build_shared=yes
-
-# All known linkers require a `.a' archive for static linking (except MSVC,
-# which needs '.lib').
-libext=a
-ltmain="$ac_aux_dir/ltmain.sh"
-ofile="$default_ofile"
-with_gnu_ld="$lt_cv_prog_gnu_ld"
-
-if test -n "$ac_tool_prefix"; then
- # Extract the first word of "${ac_tool_prefix}ar", so it can be a program name with args.
-set dummy ${ac_tool_prefix}ar; ac_word=$2
-echo "$as_me:$LINENO: checking for $ac_word" >&5
-echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
-if test "${ac_cv_prog_AR+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- if test -n "$AR"; then
- ac_cv_prog_AR="$AR" # Let the user override the test.
-else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
- IFS=$as_save_IFS
- test -z "$as_dir" && as_dir=.
- for ac_exec_ext in '' $ac_executable_extensions; do
- if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
- ac_cv_prog_AR="${ac_tool_prefix}ar"
- echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
- break 2
- fi
-done
-done
-
-fi
-fi
-AR=$ac_cv_prog_AR
-if test -n "$AR"; then
- echo "$as_me:$LINENO: result: $AR" >&5
-echo "${ECHO_T}$AR" >&6
-else
- echo "$as_me:$LINENO: result: no" >&5
-echo "${ECHO_T}no" >&6
-fi
-
-fi
-if test -z "$ac_cv_prog_AR"; then
- ac_ct_AR=$AR
- # Extract the first word of "ar", so it can be a program name with args.
-set dummy ar; ac_word=$2
-echo "$as_me:$LINENO: checking for $ac_word" >&5
-echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
-if test "${ac_cv_prog_ac_ct_AR+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- if test -n "$ac_ct_AR"; then
- ac_cv_prog_ac_ct_AR="$ac_ct_AR" # Let the user override the test.
-else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
- IFS=$as_save_IFS
- test -z "$as_dir" && as_dir=.
- for ac_exec_ext in '' $ac_executable_extensions; do
- if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
- ac_cv_prog_ac_ct_AR="ar"
- echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
- break 2
- fi
-done
-done
-
- test -z "$ac_cv_prog_ac_ct_AR" && ac_cv_prog_ac_ct_AR="false"
-fi
-fi
-ac_ct_AR=$ac_cv_prog_ac_ct_AR
-if test -n "$ac_ct_AR"; then
- echo "$as_me:$LINENO: result: $ac_ct_AR" >&5
-echo "${ECHO_T}$ac_ct_AR" >&6
-else
- echo "$as_me:$LINENO: result: no" >&5
-echo "${ECHO_T}no" >&6
-fi
-
- AR=$ac_ct_AR
-else
- AR="$ac_cv_prog_AR"
-fi
-
-if test -n "$ac_tool_prefix"; then
- # Extract the first word of "${ac_tool_prefix}ranlib", so it can be a program name with args.
-set dummy ${ac_tool_prefix}ranlib; ac_word=$2
-echo "$as_me:$LINENO: checking for $ac_word" >&5
-echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
-if test "${ac_cv_prog_RANLIB+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- if test -n "$RANLIB"; then
- ac_cv_prog_RANLIB="$RANLIB" # Let the user override the test.
-else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
- IFS=$as_save_IFS
- test -z "$as_dir" && as_dir=.
- for ac_exec_ext in '' $ac_executable_extensions; do
- if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
- ac_cv_prog_RANLIB="${ac_tool_prefix}ranlib"
- echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
- break 2
- fi
-done
-done
-
-fi
-fi
-RANLIB=$ac_cv_prog_RANLIB
-if test -n "$RANLIB"; then
- echo "$as_me:$LINENO: result: $RANLIB" >&5
-echo "${ECHO_T}$RANLIB" >&6
-else
- echo "$as_me:$LINENO: result: no" >&5
-echo "${ECHO_T}no" >&6
-fi
-
-fi
-if test -z "$ac_cv_prog_RANLIB"; then
- ac_ct_RANLIB=$RANLIB
- # Extract the first word of "ranlib", so it can be a program name with args.
-set dummy ranlib; ac_word=$2
-echo "$as_me:$LINENO: checking for $ac_word" >&5
-echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
-if test "${ac_cv_prog_ac_ct_RANLIB+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- if test -n "$ac_ct_RANLIB"; then
- ac_cv_prog_ac_ct_RANLIB="$ac_ct_RANLIB" # Let the user override the test.
-else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
- IFS=$as_save_IFS
- test -z "$as_dir" && as_dir=.
- for ac_exec_ext in '' $ac_executable_extensions; do
- if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
- ac_cv_prog_ac_ct_RANLIB="ranlib"
- echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
- break 2
- fi
-done
-done
-
- test -z "$ac_cv_prog_ac_ct_RANLIB" && ac_cv_prog_ac_ct_RANLIB=":"
-fi
-fi
-ac_ct_RANLIB=$ac_cv_prog_ac_ct_RANLIB
-if test -n "$ac_ct_RANLIB"; then
- echo "$as_me:$LINENO: result: $ac_ct_RANLIB" >&5
-echo "${ECHO_T}$ac_ct_RANLIB" >&6
-else
- echo "$as_me:$LINENO: result: no" >&5
-echo "${ECHO_T}no" >&6
-fi
-
- RANLIB=$ac_ct_RANLIB
-else
- RANLIB="$ac_cv_prog_RANLIB"
-fi
-
-if test -n "$ac_tool_prefix"; then
- # Extract the first word of "${ac_tool_prefix}strip", so it can be a program name with args.
-set dummy ${ac_tool_prefix}strip; ac_word=$2
-echo "$as_me:$LINENO: checking for $ac_word" >&5
-echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
-if test "${ac_cv_prog_STRIP+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- if test -n "$STRIP"; then
- ac_cv_prog_STRIP="$STRIP" # Let the user override the test.
-else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
- IFS=$as_save_IFS
- test -z "$as_dir" && as_dir=.
- for ac_exec_ext in '' $ac_executable_extensions; do
- if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
- ac_cv_prog_STRIP="${ac_tool_prefix}strip"
- echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
- break 2
- fi
-done
-done
-
-fi
-fi
-STRIP=$ac_cv_prog_STRIP
-if test -n "$STRIP"; then
- echo "$as_me:$LINENO: result: $STRIP" >&5
-echo "${ECHO_T}$STRIP" >&6
-else
- echo "$as_me:$LINENO: result: no" >&5
-echo "${ECHO_T}no" >&6
-fi
-
-fi
-if test -z "$ac_cv_prog_STRIP"; then
- ac_ct_STRIP=$STRIP
- # Extract the first word of "strip", so it can be a program name with args.
-set dummy strip; ac_word=$2
-echo "$as_me:$LINENO: checking for $ac_word" >&5
-echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
-if test "${ac_cv_prog_ac_ct_STRIP+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- if test -n "$ac_ct_STRIP"; then
- ac_cv_prog_ac_ct_STRIP="$ac_ct_STRIP" # Let the user override the test.
-else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
- IFS=$as_save_IFS
- test -z "$as_dir" && as_dir=.
- for ac_exec_ext in '' $ac_executable_extensions; do
- if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
- ac_cv_prog_ac_ct_STRIP="strip"
- echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
- break 2
- fi
-done
-done
-
- test -z "$ac_cv_prog_ac_ct_STRIP" && ac_cv_prog_ac_ct_STRIP=":"
-fi
-fi
-ac_ct_STRIP=$ac_cv_prog_ac_ct_STRIP
-if test -n "$ac_ct_STRIP"; then
- echo "$as_me:$LINENO: result: $ac_ct_STRIP" >&5
-echo "${ECHO_T}$ac_ct_STRIP" >&6
-else
- echo "$as_me:$LINENO: result: no" >&5
-echo "${ECHO_T}no" >&6
-fi
-
- STRIP=$ac_ct_STRIP
-else
- STRIP="$ac_cv_prog_STRIP"
-fi
-
-
-old_CC="$CC"
-old_CFLAGS="$CFLAGS"
-
-# Set sane defaults for various variables
-test -z "$AR" && AR=ar
-test -z "$AR_FLAGS" && AR_FLAGS=cru
-test -z "$AS" && AS=as
-test -z "$CC" && CC=cc
-test -z "$LTCC" && LTCC=$CC
-test -z "$LTCFLAGS" && LTCFLAGS=$CFLAGS
-test -z "$DLLTOOL" && DLLTOOL=dlltool
-test -z "$LD" && LD=ld
-test -z "$LN_S" && LN_S="ln -s"
-test -z "$MAGIC_CMD" && MAGIC_CMD=file
-test -z "$NM" && NM=nm
-test -z "$SED" && SED=sed
-test -z "$OBJDUMP" && OBJDUMP=objdump
-test -z "$RANLIB" && RANLIB=:
-test -z "$STRIP" && STRIP=:
-test -z "$ac_objext" && ac_objext=o
-
-# Determine commands to create old-style static archives.
-old_archive_cmds='$AR $AR_FLAGS $oldlib$oldobjs$old_deplibs'
-old_postinstall_cmds='chmod 644 $oldlib'
-old_postuninstall_cmds=
-
-if test -n "$RANLIB"; then
- case $host_os in
- openbsd*)
- old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB -t \$oldlib"
- ;;
- *)
- old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB \$oldlib"
- ;;
- esac
- old_archive_cmds="$old_archive_cmds~\$RANLIB \$oldlib"
-fi
-
-for cc_temp in $compiler""; do
- case $cc_temp in
- compile | *[\\/]compile | ccache | *[\\/]ccache ) ;;
- distcc | *[\\/]distcc | purify | *[\\/]purify ) ;;
- \-*) ;;
- *) break;;
- esac
-done
-cc_basename=`$echo "X$cc_temp" | $Xsed -e 's%.*/%%' -e "s%^$host_alias-%%"`
-
-
-# Only perform the check for file, if the check method requires it
-case $deplibs_check_method in
-file_magic*)
- if test "$file_magic_cmd" = '$MAGIC_CMD'; then
- echo "$as_me:$LINENO: checking for ${ac_tool_prefix}file" >&5
-echo $ECHO_N "checking for ${ac_tool_prefix}file... $ECHO_C" >&6
-if test "${lt_cv_path_MAGIC_CMD+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- case $MAGIC_CMD in
-[\\/*] | ?:[\\/]*)
- lt_cv_path_MAGIC_CMD="$MAGIC_CMD" # Let the user override the test with a path.
- ;;
-*)
- lt_save_MAGIC_CMD="$MAGIC_CMD"
- lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
- ac_dummy="/usr/bin$PATH_SEPARATOR$PATH"
- for ac_dir in $ac_dummy; do
- IFS="$lt_save_ifs"
- test -z "$ac_dir" && ac_dir=.
- if test -f $ac_dir/${ac_tool_prefix}file; then
- lt_cv_path_MAGIC_CMD="$ac_dir/${ac_tool_prefix}file"
- if test -n "$file_magic_test_file"; then
- case $deplibs_check_method in
- "file_magic "*)
- file_magic_regex=`expr "$deplibs_check_method" : "file_magic \(.*\)"`
- MAGIC_CMD="$lt_cv_path_MAGIC_CMD"
- if eval $file_magic_cmd \$file_magic_test_file 2> /dev/null |
- $EGREP "$file_magic_regex" > /dev/null; then
- :
- else
- cat <<EOF 1>&2
-
-*** Warning: the command libtool uses to detect shared libraries,
-*** $file_magic_cmd, produces output that libtool cannot recognize.
-*** The result is that libtool may fail to recognize shared libraries
-*** as such. This will affect the creation of libtool libraries that
-*** depend on shared libraries, but programs linked with such libtool
-*** libraries will work regardless of this problem. Nevertheless, you
-*** may want to report the problem to your system manager and/or to
-*** bug-libtool@gnu.org
-
-EOF
- fi ;;
- esac
- fi
- break
- fi
- done
- IFS="$lt_save_ifs"
- MAGIC_CMD="$lt_save_MAGIC_CMD"
- ;;
-esac
-fi
-
-MAGIC_CMD="$lt_cv_path_MAGIC_CMD"
-if test -n "$MAGIC_CMD"; then
- echo "$as_me:$LINENO: result: $MAGIC_CMD" >&5
-echo "${ECHO_T}$MAGIC_CMD" >&6
-else
- echo "$as_me:$LINENO: result: no" >&5
-echo "${ECHO_T}no" >&6
-fi
-
-if test -z "$lt_cv_path_MAGIC_CMD"; then
- if test -n "$ac_tool_prefix"; then
- echo "$as_me:$LINENO: checking for file" >&5
-echo $ECHO_N "checking for file... $ECHO_C" >&6
-if test "${lt_cv_path_MAGIC_CMD+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- case $MAGIC_CMD in
-[\\/*] | ?:[\\/]*)
- lt_cv_path_MAGIC_CMD="$MAGIC_CMD" # Let the user override the test with a path.
- ;;
-*)
- lt_save_MAGIC_CMD="$MAGIC_CMD"
- lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
- ac_dummy="/usr/bin$PATH_SEPARATOR$PATH"
- for ac_dir in $ac_dummy; do
- IFS="$lt_save_ifs"
- test -z "$ac_dir" && ac_dir=.
- if test -f $ac_dir/file; then
- lt_cv_path_MAGIC_CMD="$ac_dir/file"
- if test -n "$file_magic_test_file"; then
- case $deplibs_check_method in
- "file_magic "*)
- file_magic_regex=`expr "$deplibs_check_method" : "file_magic \(.*\)"`
- MAGIC_CMD="$lt_cv_path_MAGIC_CMD"
- if eval $file_magic_cmd \$file_magic_test_file 2> /dev/null |
- $EGREP "$file_magic_regex" > /dev/null; then
- :
- else
- cat <<EOF 1>&2
-
-*** Warning: the command libtool uses to detect shared libraries,
-*** $file_magic_cmd, produces output that libtool cannot recognize.
-*** The result is that libtool may fail to recognize shared libraries
-*** as such. This will affect the creation of libtool libraries that
-*** depend on shared libraries, but programs linked with such libtool
-*** libraries will work regardless of this problem. Nevertheless, you
-*** may want to report the problem to your system manager and/or to
-*** bug-libtool@gnu.org
-
-EOF
- fi ;;
- esac
- fi
- break
- fi
- done
- IFS="$lt_save_ifs"
- MAGIC_CMD="$lt_save_MAGIC_CMD"
- ;;
-esac
-fi
-
-MAGIC_CMD="$lt_cv_path_MAGIC_CMD"
-if test -n "$MAGIC_CMD"; then
- echo "$as_me:$LINENO: result: $MAGIC_CMD" >&5
-echo "${ECHO_T}$MAGIC_CMD" >&6
-else
- echo "$as_me:$LINENO: result: no" >&5
-echo "${ECHO_T}no" >&6
-fi
-
- else
- MAGIC_CMD=:
- fi
-fi
-
- fi
- ;;
-esac
-
-enable_dlopen=no
-enable_win32_dll=no
-
-# Check whether --enable-libtool-lock or --disable-libtool-lock was given.
-if test "${enable_libtool_lock+set}" = set; then
- enableval="$enable_libtool_lock"
-
-fi;
-test "x$enable_libtool_lock" != xno && enable_libtool_lock=yes
-
-
-# Check whether --with-pic or --without-pic was given.
-if test "${with_pic+set}" = set; then
- withval="$with_pic"
- pic_mode="$withval"
-else
- pic_mode=default
-fi;
-test -z "$pic_mode" && pic_mode=default
-
-# Use C for the default configuration in the libtool script
-tagname=
-lt_save_CC="$CC"
-ac_ext=c
-ac_cpp='$CPP $CPPFLAGS'
-ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
-ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
-ac_compiler_gnu=$ac_cv_c_compiler_gnu
-
-
-# Source file extension for C test sources.
-ac_ext=c
-
-# Object file extension for compiled C test sources.
-objext=o
-objext=$objext
-
-# Code to be used in simple compile tests
-lt_simple_compile_test_code="int some_variable = 0;\n"
-
-# Code to be used in simple link tests
-lt_simple_link_test_code='int main(){return(0);}\n'
-
-
-# If no C compiler was specified, use CC.
-LTCC=${LTCC-"$CC"}
-
-# If no C compiler flags were specified, use CFLAGS.
-LTCFLAGS=${LTCFLAGS-"$CFLAGS"}
-
-# Allow CC to be a program name with arguments.
-compiler=$CC
-
-
-# save warnings/boilerplate of simple test code
-ac_outfile=conftest.$ac_objext
-printf "$lt_simple_compile_test_code" >conftest.$ac_ext
-eval "$ac_compile" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err
-_lt_compiler_boilerplate=`cat conftest.err`
-$rm conftest*
-
-ac_outfile=conftest.$ac_objext
-printf "$lt_simple_link_test_code" >conftest.$ac_ext
-eval "$ac_link" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err
-_lt_linker_boilerplate=`cat conftest.err`
-$rm conftest*
-
-
-
-lt_prog_compiler_no_builtin_flag=
-
-if test "$GCC" = yes; then
- lt_prog_compiler_no_builtin_flag=' -fno-builtin'
-
-
-echo "$as_me:$LINENO: checking if $compiler supports -fno-rtti -fno-exceptions" >&5
-echo $ECHO_N "checking if $compiler supports -fno-rtti -fno-exceptions... $ECHO_C" >&6
-if test "${lt_cv_prog_compiler_rtti_exceptions+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- lt_cv_prog_compiler_rtti_exceptions=no
- ac_outfile=conftest.$ac_objext
- printf "$lt_simple_compile_test_code" > conftest.$ac_ext
- lt_compiler_flag="-fno-rtti -fno-exceptions"
- # Insert the option either (1) after the last *FLAGS variable, or
- # (2) before a word containing "conftest.", or (3) at the end.
- # Note that $ac_compile itself does not contain backslashes and begins
- # with a dollar sign (not a hyphen), so the echo should work correctly.
- # The option is referenced via a variable to avoid confusing sed.
- lt_compile=`echo "$ac_compile" | $SED \
- -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
- -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
- -e 's:$: $lt_compiler_flag:'`
- (eval echo "\"\$as_me:6325: $lt_compile\"" >&5)
- (eval "$lt_compile" 2>conftest.err)
- ac_status=$?
- cat conftest.err >&5
- echo "$as_me:6329: \$? = $ac_status" >&5
- if (exit $ac_status) && test -s "$ac_outfile"; then
- # The compiler can only warn and ignore the option if not recognized
- # So say no if there are warnings other than the usual output.
- $echo "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' >conftest.exp
- $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2
- if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then
- lt_cv_prog_compiler_rtti_exceptions=yes
- fi
- fi
- $rm conftest*
-
-fi
-echo "$as_me:$LINENO: result: $lt_cv_prog_compiler_rtti_exceptions" >&5
-echo "${ECHO_T}$lt_cv_prog_compiler_rtti_exceptions" >&6
-
-if test x"$lt_cv_prog_compiler_rtti_exceptions" = xyes; then
- lt_prog_compiler_no_builtin_flag="$lt_prog_compiler_no_builtin_flag -fno-rtti -fno-exceptions"
-else
- :
-fi
-
-fi
-
-lt_prog_compiler_wl=
-lt_prog_compiler_pic=
-lt_prog_compiler_static=
-
-echo "$as_me:$LINENO: checking for $compiler option to produce PIC" >&5
-echo $ECHO_N "checking for $compiler option to produce PIC... $ECHO_C" >&6
-
- if test "$GCC" = yes; then
- lt_prog_compiler_wl='-Wl,'
- lt_prog_compiler_static='-static'
-
- case $host_os in
- aix*)
- # All AIX code is PIC.
- if test "$host_cpu" = ia64; then
- # AIX 5 now supports IA64 processor
- lt_prog_compiler_static='-Bstatic'
- fi
- ;;
-
- amigaos*)
- # FIXME: we need at least 68020 code to build shared libraries, but
- # adding the `-m68020' flag to GCC prevents building anything better,
- # like `-m68040'.
- lt_prog_compiler_pic='-m68020 -resident32 -malways-restore-a4'
- ;;
-
- beos* | cygwin* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*)
- # PIC is the default for these OSes.
- ;;
-
- mingw* | pw32* | os2*)
- # This hack is so that the source file can tell whether it is being
- # built for inclusion in a dll (and should export symbols for example).
- lt_prog_compiler_pic='-DDLL_EXPORT'
- ;;
-
- darwin* | rhapsody*)
- # PIC is the default on this platform
- # Common symbols not allowed in MH_DYLIB files
- lt_prog_compiler_pic='-fno-common'
- ;;
-
- interix3*)
- # Interix 3.x gcc -fpic/-fPIC options generate broken code.
- # Instead, we relocate shared libraries at runtime.
- ;;
-
- msdosdjgpp*)
- # Just because we use GCC doesn't mean we suddenly get shared libraries
- # on systems that don't support them.
- lt_prog_compiler_can_build_shared=no
- enable_shared=no
- ;;
-
- sysv4*MP*)
- if test -d /usr/nec; then
- lt_prog_compiler_pic=-Kconform_pic
- fi
- ;;
-
- hpux*)
- # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but
- # not for PA HP-UX.
- case $host_cpu in
- hppa*64*|ia64*)
- # +Z the default
- ;;
- *)
- lt_prog_compiler_pic='-fPIC'
- ;;
- esac
- ;;
-
- *)
- lt_prog_compiler_pic='-fPIC'
- ;;
- esac
- else
- # PORTME Check for flag to pass linker flags through the system compiler.
- case $host_os in
- aix*)
- lt_prog_compiler_wl='-Wl,'
- if test "$host_cpu" = ia64; then
- # AIX 5 now supports IA64 processor
- lt_prog_compiler_static='-Bstatic'
- else
- lt_prog_compiler_static='-bnso -bI:/lib/syscalls.exp'
- fi
- ;;
- darwin*)
- # PIC is the default on this platform
- # Common symbols not allowed in MH_DYLIB files
- case $cc_basename in
- xlc*)
- lt_prog_compiler_pic='-qnocommon'
- lt_prog_compiler_wl='-Wl,'
- ;;
- esac
- ;;
-
- mingw* | pw32* | os2*)
- # This hack is so that the source file can tell whether it is being
- # built for inclusion in a dll (and should export symbols for example).
- lt_prog_compiler_pic='-DDLL_EXPORT'
- ;;
-
- hpux9* | hpux10* | hpux11*)
- lt_prog_compiler_wl='-Wl,'
- # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but
- # not for PA HP-UX.
- case $host_cpu in
- hppa*64*|ia64*)
- # +Z the default
- ;;
- *)
- lt_prog_compiler_pic='+Z'
- ;;
- esac
- # Is there a better lt_prog_compiler_static that works with the bundled CC?
- lt_prog_compiler_static='${wl}-a ${wl}archive'
- ;;
-
- irix5* | irix6* | nonstopux*)
- lt_prog_compiler_wl='-Wl,'
- # PIC (with -KPIC) is the default.
- lt_prog_compiler_static='-non_shared'
- ;;
-
- newsos6)
- lt_prog_compiler_pic='-KPIC'
- lt_prog_compiler_static='-Bstatic'
- ;;
-
- linux*)
- case $cc_basename in
- icc* | ecc*)
- lt_prog_compiler_wl='-Wl,'
- lt_prog_compiler_pic='-KPIC'
- lt_prog_compiler_static='-static'
- ;;
- pgcc* | pgf77* | pgf90* | pgf95*)
- # Portland Group compilers (*not* the Pentium gcc compiler,
- # which looks to be a dead project)
- lt_prog_compiler_wl='-Wl,'
- lt_prog_compiler_pic='-fpic'
- lt_prog_compiler_static='-Bstatic'
- ;;
- ccc*)
- lt_prog_compiler_wl='-Wl,'
- # All Alpha code is PIC.
- lt_prog_compiler_static='-non_shared'
- ;;
- esac
- ;;
-
- osf3* | osf4* | osf5*)
- lt_prog_compiler_wl='-Wl,'
- # All OSF/1 code is PIC.
- lt_prog_compiler_static='-non_shared'
- ;;
-
- solaris*)
- lt_prog_compiler_pic='-KPIC'
- lt_prog_compiler_static='-Bstatic'
- case $cc_basename in
- f77* | f90* | f95*)
- lt_prog_compiler_wl='-Qoption ld ';;
- *)
- lt_prog_compiler_wl='-Wl,';;
- esac
- ;;
-
- sunos4*)
- lt_prog_compiler_wl='-Qoption ld '
- lt_prog_compiler_pic='-PIC'
- lt_prog_compiler_static='-Bstatic'
- ;;
-
- sysv4 | sysv4.2uw2* | sysv4.3*)
- lt_prog_compiler_wl='-Wl,'
- lt_prog_compiler_pic='-KPIC'
- lt_prog_compiler_static='-Bstatic'
- ;;
-
- sysv4*MP*)
- if test -d /usr/nec ;then
- lt_prog_compiler_pic='-Kconform_pic'
- lt_prog_compiler_static='-Bstatic'
- fi
- ;;
-
- sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*)
- lt_prog_compiler_wl='-Wl,'
- lt_prog_compiler_pic='-KPIC'
- lt_prog_compiler_static='-Bstatic'
- ;;
-
- unicos*)
- lt_prog_compiler_wl='-Wl,'
- lt_prog_compiler_can_build_shared=no
- ;;
-
- uts4*)
- lt_prog_compiler_pic='-pic'
- lt_prog_compiler_static='-Bstatic'
- ;;
-
- *)
- lt_prog_compiler_can_build_shared=no
- ;;
- esac
- fi
-
-echo "$as_me:$LINENO: result: $lt_prog_compiler_pic" >&5
-echo "${ECHO_T}$lt_prog_compiler_pic" >&6
-
-#
-# Check to make sure the PIC flag actually works.
-#
-if test -n "$lt_prog_compiler_pic"; then
-
-echo "$as_me:$LINENO: checking if $compiler PIC flag $lt_prog_compiler_pic works" >&5
-echo $ECHO_N "checking if $compiler PIC flag $lt_prog_compiler_pic works... $ECHO_C" >&6
-if test "${lt_prog_compiler_pic_works+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- lt_prog_compiler_pic_works=no
- ac_outfile=conftest.$ac_objext
- printf "$lt_simple_compile_test_code" > conftest.$ac_ext
- lt_compiler_flag="$lt_prog_compiler_pic -DPIC"
- # Insert the option either (1) after the last *FLAGS variable, or
- # (2) before a word containing "conftest.", or (3) at the end.
- # Note that $ac_compile itself does not contain backslashes and begins
- # with a dollar sign (not a hyphen), so the echo should work correctly.
- # The option is referenced via a variable to avoid confusing sed.
- lt_compile=`echo "$ac_compile" | $SED \
- -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
- -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
- -e 's:$: $lt_compiler_flag:'`
- (eval echo "\"\$as_me:6593: $lt_compile\"" >&5)
- (eval "$lt_compile" 2>conftest.err)
- ac_status=$?
- cat conftest.err >&5
- echo "$as_me:6597: \$? = $ac_status" >&5
- if (exit $ac_status) && test -s "$ac_outfile"; then
- # The compiler can only warn and ignore the option if not recognized
- # So say no if there are warnings other than the usual output.
- $echo "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' >conftest.exp
- $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2
- if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then
- lt_prog_compiler_pic_works=yes
- fi
- fi
- $rm conftest*
-
-fi
-echo "$as_me:$LINENO: result: $lt_prog_compiler_pic_works" >&5
-echo "${ECHO_T}$lt_prog_compiler_pic_works" >&6
-
-if test x"$lt_prog_compiler_pic_works" = xyes; then
- case $lt_prog_compiler_pic in
- "" | " "*) ;;
- *) lt_prog_compiler_pic=" $lt_prog_compiler_pic" ;;
- esac
-else
- lt_prog_compiler_pic=
- lt_prog_compiler_can_build_shared=no
-fi
-
-fi
-case $host_os in
- # For platforms which do not support PIC, -DPIC is meaningless:
- *djgpp*)
- lt_prog_compiler_pic=
- ;;
- *)
- lt_prog_compiler_pic="$lt_prog_compiler_pic -DPIC"
- ;;
-esac
-
-#
-# Check to make sure the static flag actually works.
-#
-wl=$lt_prog_compiler_wl eval lt_tmp_static_flag=\"$lt_prog_compiler_static\"
-echo "$as_me:$LINENO: checking if $compiler static flag $lt_tmp_static_flag works" >&5
-echo $ECHO_N "checking if $compiler static flag $lt_tmp_static_flag works... $ECHO_C" >&6
-if test "${lt_prog_compiler_static_works+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- lt_prog_compiler_static_works=no
- save_LDFLAGS="$LDFLAGS"
- LDFLAGS="$LDFLAGS $lt_tmp_static_flag"
- printf "$lt_simple_link_test_code" > conftest.$ac_ext
- if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then
- # The linker can only warn and ignore the option if not recognized
- # So say no if there are warnings
- if test -s conftest.err; then
- # Append any errors to the config.log.
- cat conftest.err 1>&5
- $echo "X$_lt_linker_boilerplate" | $Xsed -e '/^$/d' > conftest.exp
- $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2
- if diff conftest.exp conftest.er2 >/dev/null; then
- lt_prog_compiler_static_works=yes
- fi
- else
- lt_prog_compiler_static_works=yes
- fi
- fi
- $rm conftest*
- LDFLAGS="$save_LDFLAGS"
-
-fi
-echo "$as_me:$LINENO: result: $lt_prog_compiler_static_works" >&5
-echo "${ECHO_T}$lt_prog_compiler_static_works" >&6
-
-if test x"$lt_prog_compiler_static_works" = xyes; then
- :
-else
- lt_prog_compiler_static=
-fi
-
-
-echo "$as_me:$LINENO: checking if $compiler supports -c -o file.$ac_objext" >&5
-echo $ECHO_N "checking if $compiler supports -c -o file.$ac_objext... $ECHO_C" >&6
-if test "${lt_cv_prog_compiler_c_o+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- lt_cv_prog_compiler_c_o=no
- $rm -r conftest 2>/dev/null
- mkdir conftest
- cd conftest
- mkdir out
- printf "$lt_simple_compile_test_code" > conftest.$ac_ext
-
- lt_compiler_flag="-o out/conftest2.$ac_objext"
- # Insert the option either (1) after the last *FLAGS variable, or
- # (2) before a word containing "conftest.", or (3) at the end.
- # Note that $ac_compile itself does not contain backslashes and begins
- # with a dollar sign (not a hyphen), so the echo should work correctly.
- lt_compile=`echo "$ac_compile" | $SED \
- -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
- -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
- -e 's:$: $lt_compiler_flag:'`
- (eval echo "\"\$as_me:6697: $lt_compile\"" >&5)
- (eval "$lt_compile" 2>out/conftest.err)
- ac_status=$?
- cat out/conftest.err >&5
- echo "$as_me:6701: \$? = $ac_status" >&5
- if (exit $ac_status) && test -s out/conftest2.$ac_objext
- then
- # The compiler can only warn and ignore the option if not recognized
- # So say no if there are warnings
- $echo "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' > out/conftest.exp
- $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2
- if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then
- lt_cv_prog_compiler_c_o=yes
- fi
- fi
- chmod u+w . 2>&5
- $rm conftest*
- # SGI C++ compiler will create directory out/ii_files/ for
- # template instantiation
- test -d out/ii_files && $rm out/ii_files/* && rmdir out/ii_files
- $rm out/* && rmdir out
- cd ..
- rmdir conftest
- $rm conftest*
-
-fi
-echo "$as_me:$LINENO: result: $lt_cv_prog_compiler_c_o" >&5
-echo "${ECHO_T}$lt_cv_prog_compiler_c_o" >&6
-
-
-hard_links="nottested"
-if test "$lt_cv_prog_compiler_c_o" = no && test "$need_locks" != no; then
- # do not overwrite the value of need_locks provided by the user
- echo "$as_me:$LINENO: checking if we can lock with hard links" >&5
-echo $ECHO_N "checking if we can lock with hard links... $ECHO_C" >&6
- hard_links=yes
- $rm conftest*
- ln conftest.a conftest.b 2>/dev/null && hard_links=no
- touch conftest.a
- ln conftest.a conftest.b 2>&5 || hard_links=no
- ln conftest.a conftest.b 2>/dev/null && hard_links=no
- echo "$as_me:$LINENO: result: $hard_links" >&5
-echo "${ECHO_T}$hard_links" >&6
- if test "$hard_links" = no; then
- { echo "$as_me:$LINENO: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&5
-echo "$as_me: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&2;}
- need_locks=warn
- fi
-else
- need_locks=no
-fi
-
-echo "$as_me:$LINENO: checking whether the $compiler linker ($LD) supports shared libraries" >&5
-echo $ECHO_N "checking whether the $compiler linker ($LD) supports shared libraries... $ECHO_C" >&6
-
- runpath_var=
- allow_undefined_flag=
- enable_shared_with_static_runtimes=no
- archive_cmds=
- archive_expsym_cmds=
- old_archive_From_new_cmds=
- old_archive_from_expsyms_cmds=
- export_dynamic_flag_spec=
- whole_archive_flag_spec=
- thread_safe_flag_spec=
- hardcode_libdir_flag_spec=
- hardcode_libdir_flag_spec_ld=
- hardcode_libdir_separator=
- hardcode_direct=no
- hardcode_minus_L=no
- hardcode_shlibpath_var=unsupported
- link_all_deplibs=unknown
- hardcode_automatic=no
- module_cmds=
- module_expsym_cmds=
- always_export_symbols=no
- export_symbols_cmds='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols'
- # include_expsyms should be a list of space-separated symbols to be *always*
- # included in the symbol list
- include_expsyms=
- # exclude_expsyms can be an extended regexp of symbols to exclude
- # it will be wrapped by ` (' and `)$', so one must not match beginning or
- # end of line. Example: `a|bc|.*d.*' will exclude the symbols `a' and `bc',
- # as well as any symbol that contains `d'.
- exclude_expsyms="_GLOBAL_OFFSET_TABLE_"
- # Although _GLOBAL_OFFSET_TABLE_ is a valid symbol C name, most a.out
- # platforms (ab)use it in PIC code, but their linkers get confused if
- # the symbol is explicitly referenced. Since portable code cannot
- # rely on this symbol name, it's probably fine to never include it in
- # preloaded symbol tables.
- extract_expsyms_cmds=
- # Just being paranoid about ensuring that cc_basename is set.
- for cc_temp in $compiler""; do
- case $cc_temp in
- compile | *[\\/]compile | ccache | *[\\/]ccache ) ;;
- distcc | *[\\/]distcc | purify | *[\\/]purify ) ;;
- \-*) ;;
- *) break;;
- esac
-done
-cc_basename=`$echo "X$cc_temp" | $Xsed -e 's%.*/%%' -e "s%^$host_alias-%%"`
-
- case $host_os in
- cygwin* | mingw* | pw32*)
- # FIXME: the MSVC++ port hasn't been tested in a loooong time
- # When not using gcc, we currently assume that we are using
- # Microsoft Visual C++.
- if test "$GCC" != yes; then
- with_gnu_ld=no
- fi
- ;;
- interix*)
- # we just hope/assume this is gcc and not c89 (= MSVC++)
- with_gnu_ld=yes
- ;;
- openbsd*)
- with_gnu_ld=no
- ;;
- esac
-
- ld_shlibs=yes
- if test "$with_gnu_ld" = yes; then
- # If archive_cmds runs LD, not CC, wlarc should be empty
- wlarc='${wl}'
-
- # Set some defaults for GNU ld with shared library support. These
- # are reset later if shared libraries are not supported. Putting them
- # here allows them to be overridden if necessary.
- runpath_var=LD_RUN_PATH
- hardcode_libdir_flag_spec='${wl}--rpath ${wl}$libdir'
- export_dynamic_flag_spec='${wl}--export-dynamic'
- # ancient GNU ld didn't support --whole-archive et. al.
- if $LD --help 2>&1 | grep 'no-whole-archive' > /dev/null; then
- whole_archive_flag_spec="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive'
- else
- whole_archive_flag_spec=
- fi
- supports_anon_versioning=no
- case `$LD -v 2>/dev/null` in
- *\ [01].* | *\ 2.[0-9].* | *\ 2.10.*) ;; # catch versions < 2.11
- *\ 2.11.93.0.2\ *) supports_anon_versioning=yes ;; # RH7.3 ...
- *\ 2.11.92.0.12\ *) supports_anon_versioning=yes ;; # Mandrake 8.2 ...
- *\ 2.11.*) ;; # other 2.11 versions
- *) supports_anon_versioning=yes ;;
- esac
-
- # See if GNU ld supports shared libraries.
- case $host_os in
- aix3* | aix4* | aix5*)
- # On AIX/PPC, the GNU linker is very broken
- if test "$host_cpu" != ia64; then
- ld_shlibs=no
- cat <<EOF 1>&2
-
-*** Warning: the GNU linker, at least up to release 2.9.1, is reported
-*** to be unable to reliably create shared libraries on AIX.
-*** Therefore, libtool is disabling shared libraries support. If you
-*** really care for shared libraries, you may want to modify your PATH
-*** so that a non-GNU linker is found, and then restart.
-
-EOF
- fi
- ;;
-
- amigaos*)
- archive_cmds='$rm $output_objdir/a2ixlibrary.data~$echo "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$echo "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$echo "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$echo "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)'
- hardcode_libdir_flag_spec='-L$libdir'
- hardcode_minus_L=yes
-
- # Samuel A. Falvo II <kc5tja@dolphin.openprojects.net> reports
- # that the semantics of dynamic libraries on AmigaOS, at least up
- # to version 4, is to share data among multiple programs linked
- # with the same dynamic library. Since this doesn't match the
- # behavior of shared libraries on other platforms, we can't use
- # them.
- ld_shlibs=no
- ;;
-
- beos*)
- if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
- allow_undefined_flag=unsupported
- # Joseph Beckenbach <jrb3@best.com> says some releases of gcc
- # support --undefined. This deserves some investigation. FIXME
- archive_cmds='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
- else
- ld_shlibs=no
- fi
- ;;
-
- cygwin* | mingw* | pw32*)
- # _LT_AC_TAGVAR(hardcode_libdir_flag_spec, ) is actually meaningless,
- # as there is no search path for DLLs.
- hardcode_libdir_flag_spec='-L$libdir'
- allow_undefined_flag=unsupported
- always_export_symbols=no
- enable_shared_with_static_runtimes=yes
- export_symbols_cmds='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[BCDGRS] /s/.* \([^ ]*\)/\1 DATA/'\'' | $SED -e '\''/^[AITW] /s/.* //'\'' | sort | uniq > $export_symbols'
-
- if $LD --help 2>&1 | grep 'auto-import' > /dev/null; then
- archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
- # If the export-symbols file already is a .def file (1st line
- # is EXPORTS), use it as is; otherwise, prepend...
- archive_expsym_cmds='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then
- cp $export_symbols $output_objdir/$soname.def;
- else
- echo EXPORTS > $output_objdir/$soname.def;
- cat $export_symbols >> $output_objdir/$soname.def;
- fi~
- $CC -shared $output_objdir/$soname.def $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
- else
- ld_shlibs=no
- fi
- ;;
-
- interix3*)
- hardcode_direct=no
- hardcode_shlibpath_var=no
- hardcode_libdir_flag_spec='${wl}-rpath,$libdir'
- export_dynamic_flag_spec='${wl}-E'
- # Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc.
- # Instead, shared libraries are loaded at an image base (0x10000000 by
- # default) and relocated if they conflict, which is a slow very memory
- # consuming and fragmenting process. To avoid this, we pick a random,
- # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link
- # time. Moving up from 0x10000000 also allows more sbrk(2) space.
- archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
- archive_expsym_cmds='sed "s,^,_," $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--retain-symbols-file,$output_objdir/$soname.expsym ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
- ;;
-
- linux*)
- if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
- tmp_addflag=
- case $cc_basename,$host_cpu in
- pgcc*) # Portland Group C compiler
- whole_archive_flag_spec='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}--no-whole-archive'
- tmp_addflag=' $pic_flag'
- ;;
- pgf77* | pgf90* | pgf95*) # Portland Group f77 and f90 compilers
- whole_archive_flag_spec='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}--no-whole-archive'
- tmp_addflag=' $pic_flag -Mnomain' ;;
- ecc*,ia64* | icc*,ia64*) # Intel C compiler on ia64
- tmp_addflag=' -i_dynamic' ;;
- efc*,ia64* | ifort*,ia64*) # Intel Fortran compiler on ia64
- tmp_addflag=' -i_dynamic -nofor_main' ;;
- ifc* | ifort*) # Intel Fortran compiler
- tmp_addflag=' -nofor_main' ;;
- esac
- archive_cmds='$CC -shared'"$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
-
- if test $supports_anon_versioning = yes; then
- archive_expsym_cmds='$echo "{ global:" > $output_objdir/$libname.ver~
- cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~
- $echo "local: *; };" >> $output_objdir/$libname.ver~
- $CC -shared'"$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib'
- fi
- link_all_deplibs=no
- else
- ld_shlibs=no
- fi
- ;;
-
- netbsd* | netbsdelf*-gnu | knetbsd*-gnu)
- if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then
- archive_cmds='$LD -Bshareable $libobjs $deplibs $linker_flags -o $lib'
- wlarc=
- else
- archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
- archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
- fi
- ;;
-
- solaris*)
- if $LD -v 2>&1 | grep 'BFD 2\.8' > /dev/null; then
- ld_shlibs=no
- cat <<EOF 1>&2
-
-*** Warning: The releases 2.8.* of the GNU linker cannot reliably
-*** create shared libraries on Solaris systems. Therefore, libtool
-*** is disabling shared libraries support. We urge you to upgrade GNU
-*** binutils to release 2.9.1 or newer. Another option is to modify
-*** your PATH or compiler configuration so that the native linker is
-*** used, and then restart.
-
-EOF
- elif $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
- archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
- archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
- else
- ld_shlibs=no
- fi
- ;;
-
- sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX*)
- case `$LD -v 2>&1` in
- *\ [01].* | *\ 2.[0-9].* | *\ 2.1[0-5].*)
- ld_shlibs=no
- cat <<_LT_EOF 1>&2
-
-*** Warning: Releases of the GNU linker prior to 2.16.91.0.3 can not
-*** reliably create shared libraries on SCO systems. Therefore, libtool
-*** is disabling shared libraries support. We urge you to upgrade GNU
-*** binutils to release 2.16.91.0.3 or newer. Another option is to modify
-*** your PATH or compiler configuration so that the native linker is
-*** used, and then restart.
-
-_LT_EOF
- ;;
- *)
- if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
- hardcode_libdir_flag_spec='`test -z "$SCOABSPATH" && echo ${wl}-rpath,$libdir`'
- archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib'
- archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname,\${SCOABSPATH:+${install_libdir}/}$soname,-retain-symbols-file,$export_symbols -o $lib'
- else
- ld_shlibs=no
- fi
- ;;
- esac
- ;;
-
- sunos4*)
- archive_cmds='$LD -assert pure-text -Bshareable -o $lib $libobjs $deplibs $linker_flags'
- wlarc=
- hardcode_direct=yes
- hardcode_shlibpath_var=no
- ;;
-
- *)
- if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
- archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
- archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
- else
- ld_shlibs=no
- fi
- ;;
- esac
-
- if test "$ld_shlibs" = no; then
- runpath_var=
- hardcode_libdir_flag_spec=
- export_dynamic_flag_spec=
- whole_archive_flag_spec=
- fi
- else
- # PORTME fill in a description of your system's linker (not GNU ld)
- case $host_os in
- aix3*)
- allow_undefined_flag=unsupported
- always_export_symbols=yes
- archive_expsym_cmds='$LD -o $output_objdir/$soname $libobjs $deplibs $linker_flags -bE:$export_symbols -T512 -H512 -bM:SRE~$AR $AR_FLAGS $lib $output_objdir/$soname'
- # Note: this linker hardcodes the directories in LIBPATH if there
- # are no directories specified by -L.
- hardcode_minus_L=yes
- if test "$GCC" = yes && test -z "$lt_prog_compiler_static"; then
- # Neither direct hardcoding nor static linking is supported with a
- # broken collect2.
- hardcode_direct=unsupported
- fi
- ;;
-
- aix4* | aix5*)
- if test "$host_cpu" = ia64; then
- # On IA64, the linker does run time linking by default, so we don't
- # have to do anything special.
- aix_use_runtimelinking=no
- exp_sym_flag='-Bexport'
- no_entry_flag=""
- else
- # If we're using GNU nm, then we don't want the "-C" option.
- # -C means demangle to AIX nm, but means don't demangle with GNU nm
- if $NM -V 2>&1 | grep 'GNU' > /dev/null; then
- export_symbols_cmds='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$2 == "T") || (\$2 == "D") || (\$2 == "B")) && (substr(\$3,1,1) != ".")) { print \$3 } }'\'' | sort -u > $export_symbols'
- else
- export_symbols_cmds='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\$2 == "T") || (\$2 == "D") || (\$2 == "B")) && (substr(\$3,1,1) != ".")) { print \$3 } }'\'' | sort -u > $export_symbols'
- fi
- aix_use_runtimelinking=no
-
- # Test if we are trying to use run time linking or normal
- # AIX style linking. If -brtl is somewhere in LDFLAGS, we
- # need to do runtime linking.
- case $host_os in aix4.[23]|aix4.[23].*|aix5*)
- for ld_flag in $LDFLAGS; do
- if (test $ld_flag = "-brtl" || test $ld_flag = "-Wl,-brtl"); then
- aix_use_runtimelinking=yes
- break
- fi
- done
- ;;
- esac
-
- exp_sym_flag='-bexport'
- no_entry_flag='-bnoentry'
- fi
-
- # When large executables or shared objects are built, AIX ld can
- # have problems creating the table of contents. If linking a library
- # or program results in "error TOC overflow" add -mminimal-toc to
- # CXXFLAGS/CFLAGS for g++/gcc. In the cases where that is not
- # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS.
-
- archive_cmds=''
- hardcode_direct=yes
- hardcode_libdir_separator=':'
- link_all_deplibs=yes
-
- if test "$GCC" = yes; then
- case $host_os in aix4.[012]|aix4.[012].*)
- # We only want to do this on AIX 4.2 and lower, the check
- # below for broken collect2 doesn't work under 4.3+
- collect2name=`${CC} -print-prog-name=collect2`
- if test -f "$collect2name" && \
- strings "$collect2name" | grep resolve_lib_name >/dev/null
- then
- # We have reworked collect2
- hardcode_direct=yes
- else
- # We have old collect2
- hardcode_direct=unsupported
- # It fails to find uninstalled libraries when the uninstalled
- # path is not listed in the libpath. Setting hardcode_minus_L
- # to unsupported forces relinking
- hardcode_minus_L=yes
- hardcode_libdir_flag_spec='-L$libdir'
- hardcode_libdir_separator=
- fi
- ;;
- esac
- shared_flag='-shared'
- if test "$aix_use_runtimelinking" = yes; then
- shared_flag="$shared_flag "'${wl}-G'
- fi
- else
- # not using gcc
- if test "$host_cpu" = ia64; then
- # VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release
- # chokes on -Wl,-G. The following line is correct:
- shared_flag='-G'
- else
- if test "$aix_use_runtimelinking" = yes; then
- shared_flag='${wl}-G'
- else
- shared_flag='${wl}-bM:SRE'
- fi
- fi
- fi
-
- # It seems that -bexpall does not export symbols beginning with
- # underscore (_), so it is better to generate a list of symbols to export.
- always_export_symbols=yes
- if test "$aix_use_runtimelinking" = yes; then
- # Warning - without using the other runtime loading flags (-brtl),
- # -berok will link without error, but may produce a broken library.
- allow_undefined_flag='-berok'
- # Determine the default libpath from the value encoded in an empty executable.
- cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-
-int
-main ()
-{
-
- ;
- return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
- (eval $ac_link) 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } &&
- { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; } &&
- { ac_try='test -s conftest$ac_exeext'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
-
-aix_libpath=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; }
-}'`
-# Check for a 64-bit object if we didn't find anything.
-if test -z "$aix_libpath"; then aix_libpath=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; }
-}'`; fi
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-fi
-rm -f conftest.err conftest.$ac_objext \
- conftest$ac_exeext conftest.$ac_ext
-if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
-
- hardcode_libdir_flag_spec='${wl}-blibpath:$libdir:'"$aix_libpath"
- archive_expsym_cmds="\$CC"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then echo "${wl}${allow_undefined_flag}"; else :; fi` '"\${wl}$exp_sym_flag:\$export_symbols $shared_flag"
- else
- if test "$host_cpu" = ia64; then
- hardcode_libdir_flag_spec='${wl}-R $libdir:/usr/lib:/lib'
- allow_undefined_flag="-z nodefs"
- archive_expsym_cmds="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$exp_sym_flag:\$export_symbols"
- else
- # Determine the default libpath from the value encoded in an empty executable.
- cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-
-int
-main ()
-{
-
- ;
- return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
- (eval $ac_link) 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } &&
- { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; } &&
- { ac_try='test -s conftest$ac_exeext'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
-
-aix_libpath=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; }
-}'`
-# Check for a 64-bit object if we didn't find anything.
-if test -z "$aix_libpath"; then aix_libpath=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; }
-}'`; fi
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-fi
-rm -f conftest.err conftest.$ac_objext \
- conftest$ac_exeext conftest.$ac_ext
-if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
-
- hardcode_libdir_flag_spec='${wl}-blibpath:$libdir:'"$aix_libpath"
- # Warning - without using the other run time loading flags,
- # -berok will link without error, but may produce a broken library.
- no_undefined_flag=' ${wl}-bernotok'
- allow_undefined_flag=' ${wl}-berok'
- # Exported symbols can be pulled into shared objects from archives
- whole_archive_flag_spec='$convenience'
- archive_cmds_need_lc=yes
- # This is similar to how AIX traditionally builds its shared libraries.
- archive_expsym_cmds="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs ${wl}-bnoentry $compiler_flags ${wl}-bE:$export_symbols${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname'
- fi
- fi
- ;;
-
- amigaos*)
- archive_cmds='$rm $output_objdir/a2ixlibrary.data~$echo "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$echo "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$echo "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$echo "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)'
- hardcode_libdir_flag_spec='-L$libdir'
- hardcode_minus_L=yes
- # see comment about different semantics on the GNU ld section
- ld_shlibs=no
- ;;
-
- bsdi[45]*)
- export_dynamic_flag_spec=-rdynamic
- ;;
-
- cygwin* | mingw* | pw32*)
- # When not using gcc, we currently assume that we are using
- # Microsoft Visual C++.
- # hardcode_libdir_flag_spec is actually meaningless, as there is
- # no search path for DLLs.
- hardcode_libdir_flag_spec=' '
- allow_undefined_flag=unsupported
- # Tell ltmain to make .lib files, not .a files.
- libext=lib
- # Tell ltmain to make .dll files, not .so files.
- shrext_cmds=".dll"
- # FIXME: Setting linknames here is a bad hack.
- archive_cmds='$CC -o $lib $libobjs $compiler_flags `echo "$deplibs" | $SED -e '\''s/ -lc$//'\''` -link -dll~linknames='
- # The linker will automatically build a .lib file if we build a DLL.
- old_archive_From_new_cmds='true'
- # FIXME: Should let the user specify the lib program.
- old_archive_cmds='lib /OUT:$oldlib$oldobjs$old_deplibs'
- fix_srcfile_path='`cygpath -w "$srcfile"`'
- enable_shared_with_static_runtimes=yes
- ;;
-
- darwin* | rhapsody*)
- case $host_os in
- rhapsody* | darwin1.[012])
- allow_undefined_flag='${wl}-undefined ${wl}suppress'
- ;;
- *) # Darwin 1.3 on
- if test -z ${MACOSX_DEPLOYMENT_TARGET} ; then
- allow_undefined_flag='${wl}-flat_namespace ${wl}-undefined ${wl}suppress'
- else
- case ${MACOSX_DEPLOYMENT_TARGET} in
- 10.[012])
- allow_undefined_flag='${wl}-flat_namespace ${wl}-undefined ${wl}suppress'
- ;;
- 10.*)
- allow_undefined_flag='${wl}-undefined ${wl}dynamic_lookup'
- ;;
- esac
- fi
- ;;
- esac
- archive_cmds_need_lc=no
- hardcode_direct=no
- hardcode_automatic=yes
- hardcode_shlibpath_var=unsupported
- whole_archive_flag_spec=''
- link_all_deplibs=yes
- if test "$GCC" = yes ; then
- output_verbose_link_cmd='echo'
- archive_cmds='$CC -dynamiclib $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring'
- module_cmds='$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags'
- # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin lds
- archive_expsym_cmds='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -dynamiclib $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
- module_expsym_cmds='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
- else
- case $cc_basename in
- xlc*)
- output_verbose_link_cmd='echo'
- archive_cmds='$CC -qmkshrobj $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-install_name ${wl}`echo $rpath/$soname` $verstring'
- module_cmds='$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags'
- # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin lds
- archive_expsym_cmds='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -qmkshrobj $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-install_name ${wl}$rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
- module_expsym_cmds='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
- ;;
- *)
- ld_shlibs=no
- ;;
- esac
- fi
- ;;
-
- dgux*)
- archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
- hardcode_libdir_flag_spec='-L$libdir'
- hardcode_shlibpath_var=no
- ;;
-
- freebsd1*)
- ld_shlibs=no
- ;;
-
- # FreeBSD 2.2.[012] allows us to include c++rt0.o to get C++ constructor
- # support. Future versions do this automatically, but an explicit c++rt0.o
- # does not break anything, and helps significantly (at the cost of a little
- # extra space).
- freebsd2.2*)
- archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags /usr/lib/c++rt0.o'
- hardcode_libdir_flag_spec='-R$libdir'
- hardcode_direct=yes
- hardcode_shlibpath_var=no
- ;;
-
- # Unfortunately, older versions of FreeBSD 2 do not have this feature.
- freebsd2*)
- archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags'
- hardcode_direct=yes
- hardcode_minus_L=yes
- hardcode_shlibpath_var=no
- ;;
-
- # FreeBSD 3 and greater uses gcc -shared to do shared libraries.
- freebsd* | dragonfly*)
- archive_cmds='$CC -shared -o $lib $libobjs $deplibs $compiler_flags'
- hardcode_libdir_flag_spec='-R$libdir'
- hardcode_direct=yes
- hardcode_shlibpath_var=no
- ;;
-
- # GNU/kFreeBSD uses gcc -shared to do shared libraries.
- kfreebsd*-gnu)
- archive_cmds='$CC -shared -o $lib $libobjs $deplibs $compiler_flags'
- hardcode_libdir_flag_spec='-R$libdir'
- hardcode_direct=yes
- hardcode_shlibpath_var=no
- link_all_deplibs=no
- ;;
-
- hpux9*)
- if test "$GCC" = yes; then
- archive_cmds='$rm $output_objdir/$soname~$CC -shared -fPIC ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $libobjs $deplibs $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
- else
- archive_cmds='$rm $output_objdir/$soname~$LD -b +b $install_libdir -o $output_objdir/$soname $libobjs $deplibs $linker_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
- fi
- hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir'
- hardcode_libdir_separator=:
- hardcode_direct=yes
-
- # hardcode_minus_L: Not really in the search PATH,
- # but as the default location of the library.
- hardcode_minus_L=yes
- export_dynamic_flag_spec='${wl}-E'
- ;;
-
- hpux10*)
- if test "$GCC" = yes -a "$with_gnu_ld" = no; then
- archive_cmds='$CC -shared -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
- else
- archive_cmds='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags'
- fi
- if test "$with_gnu_ld" = no; then
- hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir'
- hardcode_libdir_separator=:
-
- hardcode_direct=yes
- export_dynamic_flag_spec='${wl}-E'
-
- # hardcode_minus_L: Not really in the search PATH,
- # but as the default location of the library.
- hardcode_minus_L=yes
- fi
- ;;
-
- hpux11*)
- if test "$GCC" = yes -a "$with_gnu_ld" = no; then
- case $host_cpu in
- hppa*64*)
- archive_cmds='$CC -shared ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
- ;;
- ia64*)
- archive_cmds='$CC -shared ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags'
- ;;
- *)
- archive_cmds='$CC -shared -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
- ;;
- esac
- else
- case $host_cpu in
- hppa*64*)
- archive_cmds='$CC -b ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
- ;;
- ia64*)
- archive_cmds='$CC -b ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags'
- ;;
- *)
- archive_cmds='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
- ;;
- esac
- fi
- if test "$with_gnu_ld" = no; then
- hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir'
- hardcode_libdir_separator=:
-
- case $host_cpu in
- hppa*64*|ia64*)
- hardcode_libdir_flag_spec_ld='+b $libdir'
- hardcode_direct=no
- hardcode_shlibpath_var=no
- ;;
- *)
- hardcode_direct=yes
- export_dynamic_flag_spec='${wl}-E'
-
- # hardcode_minus_L: Not really in the search PATH,
- # but as the default location of the library.
- hardcode_minus_L=yes
- ;;
- esac
- fi
- ;;
-
- irix5* | irix6* | nonstopux*)
- if test "$GCC" = yes; then
- archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
- else
- archive_cmds='$LD -shared $libobjs $deplibs $linker_flags -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib'
- hardcode_libdir_flag_spec_ld='-rpath $libdir'
- fi
- hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
- hardcode_libdir_separator=:
- link_all_deplibs=yes
- ;;
-
- netbsd* | netbsdelf*-gnu | knetbsd*-gnu)
- if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then
- archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' # a.out
- else
- archive_cmds='$LD -shared -o $lib $libobjs $deplibs $linker_flags' # ELF
- fi
- hardcode_libdir_flag_spec='-R$libdir'
- hardcode_direct=yes
- hardcode_shlibpath_var=no
- ;;
-
- newsos6)
- archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
- hardcode_direct=yes
- hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
- hardcode_libdir_separator=:
- hardcode_shlibpath_var=no
- ;;
-
- openbsd*)
- hardcode_direct=yes
- hardcode_shlibpath_var=no
- if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
- archive_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags'
- archive_expsym_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-retain-symbols-file,$export_symbols'
- hardcode_libdir_flag_spec='${wl}-rpath,$libdir'
- export_dynamic_flag_spec='${wl}-E'
- else
- case $host_os in
- openbsd[01].* | openbsd2.[0-7] | openbsd2.[0-7].*)
- archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags'
- hardcode_libdir_flag_spec='-R$libdir'
- ;;
- *)
- archive_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags'
- hardcode_libdir_flag_spec='${wl}-rpath,$libdir'
- ;;
- esac
- fi
- ;;
-
- os2*)
- hardcode_libdir_flag_spec='-L$libdir'
- hardcode_minus_L=yes
- allow_undefined_flag=unsupported
- archive_cmds='$echo "LIBRARY $libname INITINSTANCE" > $output_objdir/$libname.def~$echo "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~$echo DATA >> $output_objdir/$libname.def~$echo " SINGLE NONSHARED" >> $output_objdir/$libname.def~$echo EXPORTS >> $output_objdir/$libname.def~emxexp $libobjs >> $output_objdir/$libname.def~$CC -Zdll -Zcrtdll -o $lib $libobjs $deplibs $compiler_flags $output_objdir/$libname.def'
- old_archive_From_new_cmds='emximp -o $output_objdir/$libname.a $output_objdir/$libname.def'
- ;;
-
- osf3*)
- if test "$GCC" = yes; then
- allow_undefined_flag=' ${wl}-expect_unresolved ${wl}\*'
- archive_cmds='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
- else
- allow_undefined_flag=' -expect_unresolved \*'
- archive_cmds='$LD -shared${allow_undefined_flag} $libobjs $deplibs $linker_flags -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib'
- fi
- hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
- hardcode_libdir_separator=:
- ;;
-
- osf4* | osf5*) # as osf3* with the addition of -msym flag
- if test "$GCC" = yes; then
- allow_undefined_flag=' ${wl}-expect_unresolved ${wl}\*'
- archive_cmds='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
- hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
- else
- allow_undefined_flag=' -expect_unresolved \*'
- archive_cmds='$LD -shared${allow_undefined_flag} $libobjs $deplibs $linker_flags -msym -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib'
- archive_expsym_cmds='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done; echo "-hidden">> $lib.exp~
- $LD -shared${allow_undefined_flag} -input $lib.exp $linker_flags $libobjs $deplibs -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib~$rm $lib.exp'
-
- # Both c and cxx compiler support -rpath directly
- hardcode_libdir_flag_spec='-rpath $libdir'
- fi
- hardcode_libdir_separator=:
- ;;
-
- solaris*)
- no_undefined_flag=' -z text'
- if test "$GCC" = yes; then
- wlarc='${wl}'
- archive_cmds='$CC -shared ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
- archive_expsym_cmds='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~
- $CC -shared ${wl}-M ${wl}$lib.exp ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags~$rm $lib.exp'
- else
- wlarc=''
- archive_cmds='$LD -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $linker_flags'
- archive_expsym_cmds='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~
- $LD -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linker_flags~$rm $lib.exp'
- fi
- hardcode_libdir_flag_spec='-R$libdir'
- hardcode_shlibpath_var=no
- case $host_os in
- solaris2.[0-5] | solaris2.[0-5].*) ;;
- *)
- # The compiler driver will combine linker options so we
- # cannot just pass the convience library names through
- # without $wl, iff we do not link with $LD.
- # Luckily, gcc supports the same syntax we need for Sun Studio.
- # Supported since Solaris 2.6 (maybe 2.5.1?)
- case $wlarc in
- '')
- whole_archive_flag_spec='-z allextract$convenience -z defaultextract' ;;
- *)
- whole_archive_flag_spec='${wl}-z ${wl}allextract`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}-z ${wl}defaultextract' ;;
- esac ;;
- esac
- link_all_deplibs=yes
- ;;
-
- sunos4*)
- if test "x$host_vendor" = xsequent; then
- # Use $CC to link under sequent, because it throws in some extra .o
- # files that make .init and .fini sections work.
- archive_cmds='$CC -G ${wl}-h $soname -o $lib $libobjs $deplibs $compiler_flags'
- else
- archive_cmds='$LD -assert pure-text -Bstatic -o $lib $libobjs $deplibs $linker_flags'
- fi
- hardcode_libdir_flag_spec='-L$libdir'
- hardcode_direct=yes
- hardcode_minus_L=yes
- hardcode_shlibpath_var=no
- ;;
-
- sysv4)
- case $host_vendor in
- sni)
- archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
- hardcode_direct=yes # is this really true???
- ;;
- siemens)
- ## LD is ld it makes a PLAMLIB
- ## CC just makes a GrossModule.
- archive_cmds='$LD -G -o $lib $libobjs $deplibs $linker_flags'
- reload_cmds='$CC -r -o $output$reload_objs'
- hardcode_direct=no
- ;;
- motorola)
- archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
- hardcode_direct=no #Motorola manual says yes, but my tests say they lie
- ;;
- esac
- runpath_var='LD_RUN_PATH'
- hardcode_shlibpath_var=no
- ;;
-
- sysv4.3*)
- archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
- hardcode_shlibpath_var=no
- export_dynamic_flag_spec='-Bexport'
- ;;
-
- sysv4*MP*)
- if test -d /usr/nec; then
- archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
- hardcode_shlibpath_var=no
- runpath_var=LD_RUN_PATH
- hardcode_runpath_var=yes
- ld_shlibs=yes
- fi
- ;;
-
- sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[01].[10]* | unixware7*)
- no_undefined_flag='${wl}-z,text'
- archive_cmds_need_lc=no
- hardcode_shlibpath_var=no
- runpath_var='LD_RUN_PATH'
-
- if test "$GCC" = yes; then
- archive_cmds='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
- archive_expsym_cmds='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
- else
- archive_cmds='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
- archive_expsym_cmds='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
- fi
- ;;
-
- sysv5* | sco3.2v5* | sco5v6*)
- # Note: We can NOT use -z defs as we might desire, because we do not
- # link with -lc, and that would cause any symbols used from libc to
- # always be unresolved, which means just about no library would
- # ever link correctly. If we're not using GNU ld we use -z text
- # though, which does catch some bad symbols but isn't as heavy-handed
- # as -z defs.
- no_undefined_flag='${wl}-z,text'
- allow_undefined_flag='${wl}-z,nodefs'
- archive_cmds_need_lc=no
- hardcode_shlibpath_var=no
- hardcode_libdir_flag_spec='`test -z "$SCOABSPATH" && echo ${wl}-R,$libdir`'
- hardcode_libdir_separator=':'
- link_all_deplibs=yes
- export_dynamic_flag_spec='${wl}-Bexport'
- runpath_var='LD_RUN_PATH'
-
- if test "$GCC" = yes; then
- archive_cmds='$CC -shared ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags'
- archive_expsym_cmds='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags'
- else
- archive_cmds='$CC -G ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags'
- archive_expsym_cmds='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags'
- fi
- ;;
-
- uts4*)
- archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
- hardcode_libdir_flag_spec='-L$libdir'
- hardcode_shlibpath_var=no
- ;;
-
- *)
- ld_shlibs=no
- ;;
- esac
- fi
-
-echo "$as_me:$LINENO: result: $ld_shlibs" >&5
-echo "${ECHO_T}$ld_shlibs" >&6
-test "$ld_shlibs" = no && can_build_shared=no
-
-#
-# Do we need to explicitly link libc?
-#
-case "x$archive_cmds_need_lc" in
-x|xyes)
- # Assume -lc should be added
- archive_cmds_need_lc=yes
-
- if test "$enable_shared" = yes && test "$GCC" = yes; then
- case $archive_cmds in
- *'~'*)
- # FIXME: we may have to deal with multi-command sequences.
- ;;
- '$CC '*)
- # Test whether the compiler implicitly links with -lc since on some
- # systems, -lgcc has to come before -lc. If gcc already passes -lc
- # to ld, don't add -lc before -lgcc.
- echo "$as_me:$LINENO: checking whether -lc should be explicitly linked in" >&5
-echo $ECHO_N "checking whether -lc should be explicitly linked in... $ECHO_C" >&6
- $rm conftest*
- printf "$lt_simple_compile_test_code" > conftest.$ac_ext
-
- if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
- (eval $ac_compile) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } 2>conftest.err; then
- soname=conftest
- lib=conftest
- libobjs=conftest.$ac_objext
- deplibs=
- wl=$lt_prog_compiler_wl
- pic_flag=$lt_prog_compiler_pic
- compiler_flags=-v
- linker_flags=-v
- verstring=
- output_objdir=.
- libname=conftest
- lt_save_allow_undefined_flag=$allow_undefined_flag
- allow_undefined_flag=
- if { (eval echo "$as_me:$LINENO: \"$archive_cmds 2\>\&1 \| grep \" -lc \" \>/dev/null 2\>\&1\"") >&5
- (eval $archive_cmds 2\>\&1 \| grep \" -lc \" \>/dev/null 2\>\&1) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }
- then
- archive_cmds_need_lc=no
- else
- archive_cmds_need_lc=yes
- fi
- allow_undefined_flag=$lt_save_allow_undefined_flag
- else
- cat conftest.err 1>&5
- fi
- $rm conftest*
- echo "$as_me:$LINENO: result: $archive_cmds_need_lc" >&5
-echo "${ECHO_T}$archive_cmds_need_lc" >&6
- ;;
- esac
- fi
- ;;
-esac
-
-echo "$as_me:$LINENO: checking dynamic linker characteristics" >&5
-echo $ECHO_N "checking dynamic linker characteristics... $ECHO_C" >&6
-library_names_spec=
-libname_spec='lib$name'
-soname_spec=
-shrext_cmds=".so"
-postinstall_cmds=
-postuninstall_cmds=
-finish_cmds=
-finish_eval=
-shlibpath_var=
-shlibpath_overrides_runpath=unknown
-version_type=none
-dynamic_linker="$host_os ld.so"
-sys_lib_dlsearch_path_spec="/lib /usr/lib"
-if test "$GCC" = yes; then
- sys_lib_search_path_spec=`$CC -print-search-dirs | grep "^libraries:" | $SED -e "s/^libraries://" -e "s,=/,/,g"`
- if echo "$sys_lib_search_path_spec" | grep ';' >/dev/null ; then
- # if the path contains ";" then we assume it to be the separator
- # otherwise default to the standard path separator (i.e. ":") - it is
- # assumed that no part of a normal pathname contains ";" but that should
- # okay in the real world where ";" in dirpaths is itself problematic.
- sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'`
- else
- sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"`
- fi
-else
- sys_lib_search_path_spec="/lib /usr/lib /usr/local/lib"
-fi
-need_lib_prefix=unknown
-hardcode_into_libs=no
-
-# when you set need_version to no, make sure it does not cause -set_version
-# flags to be left without arguments
-need_version=unknown
-
-case $host_os in
-aix3*)
- version_type=linux
- library_names_spec='${libname}${release}${shared_ext}$versuffix $libname.a'
- shlibpath_var=LIBPATH
-
- # AIX 3 has no versioning support, so we append a major version to the name.
- soname_spec='${libname}${release}${shared_ext}$major'
- ;;
-
-aix4* | aix5*)
- version_type=linux
- need_lib_prefix=no
- need_version=no
- hardcode_into_libs=yes
- if test "$host_cpu" = ia64; then
- # AIX 5 supports IA64
- library_names_spec='${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext}$versuffix $libname${shared_ext}'
- shlibpath_var=LD_LIBRARY_PATH
- else
- # With GCC up to 2.95.x, collect2 would create an import file
- # for dependence libraries. The import file would start with
- # the line `#! .'. This would cause the generated library to
- # depend on `.', always an invalid library. This was fixed in
- # development snapshots of GCC prior to 3.0.
- case $host_os in
- aix4 | aix4.[01] | aix4.[01].*)
- if { echo '#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 97)'
- echo ' yes '
- echo '#endif'; } | ${CC} -E - | grep yes > /dev/null; then
- :
- else
- can_build_shared=no
- fi
- ;;
- esac
- # AIX (on Power*) has no versioning support, so currently we can not hardcode correct
- # soname into executable. Probably we can add versioning support to
- # collect2, so additional links can be useful in future.
- if test "$aix_use_runtimelinking" = yes; then
- # If using run time linking (on AIX 4.2 or later) use lib<name>.so
- # instead of lib<name>.a to let people know that these are not
- # typical AIX shared libraries.
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
- else
- # We preserve .a as extension for shared libraries through AIX4.2
- # and later when we are not doing run time linking.
- library_names_spec='${libname}${release}.a $libname.a'
- soname_spec='${libname}${release}${shared_ext}$major'
- fi
- shlibpath_var=LIBPATH
- fi
- ;;
-
-amigaos*)
- library_names_spec='$libname.ixlibrary $libname.a'
- # Create ${libname}_ixlibrary.a entries in /sys/libs.
- finish_eval='for lib in `ls $libdir/*.ixlibrary 2>/dev/null`; do libname=`$echo "X$lib" | $Xsed -e '\''s%^.*/\([^/]*\)\.ixlibrary$%\1%'\''`; test $rm /sys/libs/${libname}_ixlibrary.a; $show "cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a"; cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a || exit 1; done'
- ;;
-
-beos*)
- library_names_spec='${libname}${shared_ext}'
- dynamic_linker="$host_os ld.so"
- shlibpath_var=LIBRARY_PATH
- ;;
-
-bsdi[45]*)
- version_type=linux
- need_version=no
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
- soname_spec='${libname}${release}${shared_ext}$major'
- finish_cmds='PATH="\$PATH:/sbin" ldconfig $libdir'
- shlibpath_var=LD_LIBRARY_PATH
- sys_lib_search_path_spec="/shlib /usr/lib /usr/X11/lib /usr/contrib/lib /lib /usr/local/lib"
- sys_lib_dlsearch_path_spec="/shlib /usr/lib /usr/local/lib"
- # the default ld.so.conf also contains /usr/contrib/lib and
- # /usr/X11R6/lib (/usr/X11 is a link to /usr/X11R6), but let us allow
- # libtool to hard-code these into programs
- ;;
-
-cygwin* | mingw* | pw32*)
- version_type=windows
- shrext_cmds=".dll"
- need_version=no
- need_lib_prefix=no
-
- case $GCC,$host_os in
- yes,cygwin* | yes,mingw* | yes,pw32*)
- library_names_spec='$libname.dll.a'
- # DLL is installed to $(libdir)/../bin by postinstall_cmds
- postinstall_cmds='base_file=`basename \${file}`~
- dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i;echo \$dlname'\''`~
- dldir=$destdir/`dirname \$dlpath`~
- test -d \$dldir || mkdir -p \$dldir~
- $install_prog $dir/$dlname \$dldir/$dlname~
- chmod a+x \$dldir/$dlname'
- postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~
- dlpath=$dir/\$dldll~
- $rm \$dlpath'
- shlibpath_overrides_runpath=yes
-
- case $host_os in
- cygwin*)
- # Cygwin DLLs use 'cyg' prefix rather than 'lib'
- soname_spec='`echo ${libname} | sed -e 's/^lib/cyg/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}'
- sys_lib_search_path_spec="/usr/lib /lib/w32api /lib /usr/local/lib"
- ;;
- mingw*)
- # MinGW DLLs use traditional 'lib' prefix
- soname_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}'
- sys_lib_search_path_spec=`$CC -print-search-dirs | grep "^libraries:" | $SED -e "s/^libraries://" -e "s,=/,/,g"`
- if echo "$sys_lib_search_path_spec" | grep ';[c-zC-Z]:/' >/dev/null; then
- # It is most probably a Windows format PATH printed by
- # mingw gcc, but we are running on Cygwin. Gcc prints its search
- # path with ; separators, and with drive letters. We can handle the
- # drive letters (cygwin fileutils understands them), so leave them,
- # especially as we might pass files found there to a mingw objdump,
- # which wouldn't understand a cygwinified path. Ahh.
- sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'`
- else
- sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"`
- fi
- ;;
- pw32*)
- # pw32 DLLs use 'pw' prefix rather than 'lib'
- library_names_spec='`echo ${libname} | sed -e 's/^lib/pw/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}'
- ;;
- esac
- ;;
-
- *)
- library_names_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext} $libname.lib'
- ;;
- esac
- dynamic_linker='Win32 ld.exe'
- # FIXME: first we should search . and the directory the executable is in
- shlibpath_var=PATH
- ;;
-
-darwin* | rhapsody*)
- dynamic_linker="$host_os dyld"
- version_type=darwin
- need_lib_prefix=no
- need_version=no
- library_names_spec='${libname}${release}${versuffix}$shared_ext ${libname}${release}${major}$shared_ext ${libname}$shared_ext'
- soname_spec='${libname}${release}${major}$shared_ext'
- shlibpath_overrides_runpath=yes
- shlibpath_var=DYLD_LIBRARY_PATH
- shrext_cmds='`test .$module = .yes && echo .so || echo .dylib`'
- # Apple's gcc prints 'gcc -print-search-dirs' doesn't operate the same.
- if test "$GCC" = yes; then
- sys_lib_search_path_spec=`$CC -print-search-dirs | tr "\n" "$PATH_SEPARATOR" | sed -e 's/libraries:/@libraries:/' | tr "@" "\n" | grep "^libraries:" | sed -e "s/^libraries://" -e "s,=/,/,g" -e "s,$PATH_SEPARATOR, ,g" -e "s,.*,& /lib /usr/lib /usr/local/lib,g"`
- else
- sys_lib_search_path_spec='/lib /usr/lib /usr/local/lib'
- fi
- sys_lib_dlsearch_path_spec='/usr/local/lib /lib /usr/lib'
- ;;
-
-dgux*)
- version_type=linux
- need_lib_prefix=no
- need_version=no
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname$shared_ext'
- soname_spec='${libname}${release}${shared_ext}$major'
- shlibpath_var=LD_LIBRARY_PATH
- ;;
-
-freebsd1*)
- dynamic_linker=no
- ;;
-
-kfreebsd*-gnu)
- version_type=linux
- need_lib_prefix=no
- need_version=no
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
- soname_spec='${libname}${release}${shared_ext}$major'
- shlibpath_var=LD_LIBRARY_PATH
- shlibpath_overrides_runpath=no
- hardcode_into_libs=yes
- dynamic_linker='GNU ld.so'
- ;;
-
-freebsd* | dragonfly*)
- # DragonFly does not have aout. When/if they implement a new
- # versioning mechanism, adjust this.
- if test -x /usr/bin/objformat; then
- objformat=`/usr/bin/objformat`
- else
- case $host_os in
- freebsd[123]*) objformat=aout ;;
- *) objformat=elf ;;
- esac
- fi
- version_type=freebsd-$objformat
- case $version_type in
- freebsd-elf*)
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}'
- need_version=no
- need_lib_prefix=no
- ;;
- freebsd-*)
- library_names_spec='${libname}${release}${shared_ext}$versuffix $libname${shared_ext}$versuffix'
- need_version=yes
- ;;
- esac
- shlibpath_var=LD_LIBRARY_PATH
- case $host_os in
- freebsd2*)
- shlibpath_overrides_runpath=yes
- ;;
- freebsd3.[01]* | freebsdelf3.[01]*)
- shlibpath_overrides_runpath=yes
- hardcode_into_libs=yes
- ;;
- freebsd3.[2-9]* | freebsdelf3.[2-9]* | \
- freebsd4.[0-5] | freebsdelf4.[0-5] | freebsd4.1.1 | freebsdelf4.1.1)
- shlibpath_overrides_runpath=no
- hardcode_into_libs=yes
- ;;
- freebsd*) # from 4.6 on
- shlibpath_overrides_runpath=yes
- hardcode_into_libs=yes
- ;;
- esac
- ;;
-
-gnu*)
- version_type=linux
- need_lib_prefix=no
- need_version=no
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}'
- soname_spec='${libname}${release}${shared_ext}$major'
- shlibpath_var=LD_LIBRARY_PATH
- hardcode_into_libs=yes
- ;;
-
-hpux9* | hpux10* | hpux11*)
- # Give a soname corresponding to the major version so that dld.sl refuses to
- # link against other versions.
- version_type=sunos
- need_lib_prefix=no
- need_version=no
- case $host_cpu in
- ia64*)
- shrext_cmds='.so'
- hardcode_into_libs=yes
- dynamic_linker="$host_os dld.so"
- shlibpath_var=LD_LIBRARY_PATH
- shlibpath_overrides_runpath=yes # Unless +noenvvar is specified.
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
- soname_spec='${libname}${release}${shared_ext}$major'
- if test "X$HPUX_IA64_MODE" = X32; then
- sys_lib_search_path_spec="/usr/lib/hpux32 /usr/local/lib/hpux32 /usr/local/lib"
- else
- sys_lib_search_path_spec="/usr/lib/hpux64 /usr/local/lib/hpux64"
- fi
- sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec
- ;;
- hppa*64*)
- shrext_cmds='.sl'
- hardcode_into_libs=yes
- dynamic_linker="$host_os dld.sl"
- shlibpath_var=LD_LIBRARY_PATH # How should we handle SHLIB_PATH
- shlibpath_overrides_runpath=yes # Unless +noenvvar is specified.
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
- soname_spec='${libname}${release}${shared_ext}$major'
- sys_lib_search_path_spec="/usr/lib/pa20_64 /usr/ccs/lib/pa20_64"
- sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec
- ;;
- *)
- shrext_cmds='.sl'
- dynamic_linker="$host_os dld.sl"
- shlibpath_var=SHLIB_PATH
- shlibpath_overrides_runpath=no # +s is required to enable SHLIB_PATH
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
- soname_spec='${libname}${release}${shared_ext}$major'
- ;;
- esac
- # HP-UX runs *really* slowly unless shared libraries are mode 555.
- postinstall_cmds='chmod 555 $lib'
- ;;
-
-interix3*)
- version_type=linux
- need_lib_prefix=no
- need_version=no
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
- soname_spec='${libname}${release}${shared_ext}$major'
- dynamic_linker='Interix 3.x ld.so.1 (PE, like ELF)'
- shlibpath_var=LD_LIBRARY_PATH
- shlibpath_overrides_runpath=no
- hardcode_into_libs=yes
- ;;
-
-irix5* | irix6* | nonstopux*)
- case $host_os in
- nonstopux*) version_type=nonstopux ;;
- *)
- if test "$lt_cv_prog_gnu_ld" = yes; then
- version_type=linux
- else
- version_type=irix
- fi ;;
- esac
- need_lib_prefix=no
- need_version=no
- soname_spec='${libname}${release}${shared_ext}$major'
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext} $libname${shared_ext}'
- case $host_os in
- irix5* | nonstopux*)
- libsuff= shlibsuff=
- ;;
- *)
- case $LD in # libtool.m4 will add one of these switches to LD
- *-32|*"-32 "|*-melf32bsmip|*"-melf32bsmip ")
- libsuff= shlibsuff= libmagic=32-bit;;
- *-n32|*"-n32 "|*-melf32bmipn32|*"-melf32bmipn32 ")
- libsuff=32 shlibsuff=N32 libmagic=N32;;
- *-64|*"-64 "|*-melf64bmip|*"-melf64bmip ")
- libsuff=64 shlibsuff=64 libmagic=64-bit;;
- *) libsuff= shlibsuff= libmagic=never-match;;
- esac
- ;;
- esac
- shlibpath_var=LD_LIBRARY${shlibsuff}_PATH
- shlibpath_overrides_runpath=no
- sys_lib_search_path_spec="/usr/lib${libsuff} /lib${libsuff} /usr/local/lib${libsuff}"
- sys_lib_dlsearch_path_spec="/usr/lib${libsuff} /lib${libsuff}"
- hardcode_into_libs=yes
- ;;
-
-# No shared lib support for Linux oldld, aout, or coff.
-linux*oldld* | linux*aout* | linux*coff*)
- dynamic_linker=no
- ;;
-
-# This must be Linux ELF.
-linux*)
- version_type=linux
- need_lib_prefix=no
- need_version=no
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
- soname_spec='${libname}${release}${shared_ext}$major'
- finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir'
- shlibpath_var=LD_LIBRARY_PATH
- shlibpath_overrides_runpath=no
- # This implies no fast_install, which is unacceptable.
- # Some rework will be needed to allow for fast_install
- # before this can be enabled.
- hardcode_into_libs=yes
-
- # Append ld.so.conf contents to the search path
- if test -f /etc/ld.so.conf; then
- lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s", \$2)); skip = 1; } { if (!skip) print \$0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;s/[:, ]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;/^$/d' | tr '\n' ' '`
- sys_lib_dlsearch_path_spec="/lib /usr/lib $lt_ld_extra"
- fi
-
- # We used to test for /lib/ld.so.1 and disable shared libraries on
- # powerpc, because MkLinux only supported shared libraries with the
- # GNU dynamic linker. Since this was broken with cross compilers,
- # most powerpc-linux boxes support dynamic linking these days and
- # people can always --disable-shared, the test was removed, and we
- # assume the GNU/Linux dynamic linker is in use.
- dynamic_linker='GNU/Linux ld.so'
- ;;
-
-netbsdelf*-gnu)
- version_type=linux
- need_lib_prefix=no
- need_version=no
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
- soname_spec='${libname}${release}${shared_ext}$major'
- shlibpath_var=LD_LIBRARY_PATH
- shlibpath_overrides_runpath=no
- hardcode_into_libs=yes
- dynamic_linker='NetBSD ld.elf_so'
- ;;
-
-knetbsd*-gnu)
- version_type=linux
- need_lib_prefix=no
- need_version=no
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
- soname_spec='${libname}${release}${shared_ext}$major'
- shlibpath_var=LD_LIBRARY_PATH
- shlibpath_overrides_runpath=no
- hardcode_into_libs=yes
- dynamic_linker='GNU ld.so'
- ;;
-
-netbsd*)
- version_type=sunos
- need_lib_prefix=no
- need_version=no
- if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
- finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir'
- dynamic_linker='NetBSD (a.out) ld.so'
- else
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
- soname_spec='${libname}${release}${shared_ext}$major'
- dynamic_linker='NetBSD ld.elf_so'
- fi
- shlibpath_var=LD_LIBRARY_PATH
- shlibpath_overrides_runpath=yes
- hardcode_into_libs=yes
- ;;
-
-newsos6)
- version_type=linux
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
- shlibpath_var=LD_LIBRARY_PATH
- shlibpath_overrides_runpath=yes
- ;;
-
-nto-qnx*)
- version_type=linux
- need_lib_prefix=no
- need_version=no
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
- soname_spec='${libname}${release}${shared_ext}$major'
- shlibpath_var=LD_LIBRARY_PATH
- shlibpath_overrides_runpath=yes
- ;;
-
-openbsd*)
- version_type=sunos
- sys_lib_dlsearch_path_spec="/usr/lib"
- need_lib_prefix=no
- # Some older versions of OpenBSD (3.3 at least) *do* need versioned libs.
- case $host_os in
- openbsd3.3 | openbsd3.3.*) need_version=yes ;;
- *) need_version=no ;;
- esac
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
- finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir'
- shlibpath_var=LD_LIBRARY_PATH
- if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
- case $host_os in
- openbsd2.[89] | openbsd2.[89].*)
- shlibpath_overrides_runpath=no
- ;;
- *)
- shlibpath_overrides_runpath=yes
- ;;
- esac
- else
- shlibpath_overrides_runpath=yes
- fi
- ;;
-
-os2*)
- libname_spec='$name'
- shrext_cmds=".dll"
- need_lib_prefix=no
- library_names_spec='$libname${shared_ext} $libname.a'
- dynamic_linker='OS/2 ld.exe'
- shlibpath_var=LIBPATH
- ;;
-
-osf3* | osf4* | osf5*)
- version_type=osf
- need_lib_prefix=no
- need_version=no
- soname_spec='${libname}${release}${shared_ext}$major'
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
- shlibpath_var=LD_LIBRARY_PATH
- sys_lib_search_path_spec="/usr/shlib /usr/ccs/lib /usr/lib/cmplrs/cc /usr/lib /usr/local/lib /var/shlib"
- sys_lib_dlsearch_path_spec="$sys_lib_search_path_spec"
- ;;
-
-solaris*)
- version_type=linux
- need_lib_prefix=no
- need_version=no
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
- soname_spec='${libname}${release}${shared_ext}$major'
- shlibpath_var=LD_LIBRARY_PATH
- shlibpath_overrides_runpath=yes
- hardcode_into_libs=yes
- # ldd complains unless libraries are executable
- postinstall_cmds='chmod +x $lib'
- ;;
-
-sunos4*)
- version_type=sunos
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
- finish_cmds='PATH="\$PATH:/usr/etc" ldconfig $libdir'
- shlibpath_var=LD_LIBRARY_PATH
- shlibpath_overrides_runpath=yes
- if test "$with_gnu_ld" = yes; then
- need_lib_prefix=no
- fi
- need_version=yes
- ;;
-
-sysv4 | sysv4.3*)
- version_type=linux
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
- soname_spec='${libname}${release}${shared_ext}$major'
- shlibpath_var=LD_LIBRARY_PATH
- case $host_vendor in
- sni)
- shlibpath_overrides_runpath=no
- need_lib_prefix=no
- export_dynamic_flag_spec='${wl}-Blargedynsym'
- runpath_var=LD_RUN_PATH
- ;;
- siemens)
- need_lib_prefix=no
- ;;
- motorola)
- need_lib_prefix=no
- need_version=no
- shlibpath_overrides_runpath=no
- sys_lib_search_path_spec='/lib /usr/lib /usr/ccs/lib'
- ;;
- esac
- ;;
-
-sysv4*MP*)
- if test -d /usr/nec ;then
- version_type=linux
- library_names_spec='$libname${shared_ext}.$versuffix $libname${shared_ext}.$major $libname${shared_ext}'
- soname_spec='$libname${shared_ext}.$major'
- shlibpath_var=LD_LIBRARY_PATH
- fi
- ;;
-
-sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*)
- version_type=freebsd-elf
- need_lib_prefix=no
- need_version=no
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}'
- soname_spec='${libname}${release}${shared_ext}$major'
- shlibpath_var=LD_LIBRARY_PATH
- hardcode_into_libs=yes
- if test "$with_gnu_ld" = yes; then
- sys_lib_search_path_spec='/usr/local/lib /usr/gnu/lib /usr/ccs/lib /usr/lib /lib'
- shlibpath_overrides_runpath=no
- else
- sys_lib_search_path_spec='/usr/ccs/lib /usr/lib'
- shlibpath_overrides_runpath=yes
- case $host_os in
- sco3.2v5*)
- sys_lib_search_path_spec="$sys_lib_search_path_spec /lib"
- ;;
- esac
- fi
- sys_lib_dlsearch_path_spec='/usr/lib'
- ;;
-
-uts4*)
- version_type=linux
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
- soname_spec='${libname}${release}${shared_ext}$major'
- shlibpath_var=LD_LIBRARY_PATH
- ;;
-
-*)
- dynamic_linker=no
- ;;
-esac
-echo "$as_me:$LINENO: result: $dynamic_linker" >&5
-echo "${ECHO_T}$dynamic_linker" >&6
-test "$dynamic_linker" = no && can_build_shared=no
-
-variables_saved_for_relink="PATH $shlibpath_var $runpath_var"
-if test "$GCC" = yes; then
- variables_saved_for_relink="$variables_saved_for_relink GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH"
-fi
-
-echo "$as_me:$LINENO: checking how to hardcode library paths into programs" >&5
-echo $ECHO_N "checking how to hardcode library paths into programs... $ECHO_C" >&6
-hardcode_action=
-if test -n "$hardcode_libdir_flag_spec" || \
- test -n "$runpath_var" || \
- test "X$hardcode_automatic" = "Xyes" ; then
-
- # We can hardcode non-existant directories.
- if test "$hardcode_direct" != no &&
- # If the only mechanism to avoid hardcoding is shlibpath_var, we
- # have to relink, otherwise we might link with an installed library
- # when we should be linking with a yet-to-be-installed one
- ## test "$_LT_AC_TAGVAR(hardcode_shlibpath_var, )" != no &&
- test "$hardcode_minus_L" != no; then
- # Linking always hardcodes the temporary library directory.
- hardcode_action=relink
- else
- # We can link without hardcoding, and we can hardcode nonexisting dirs.
- hardcode_action=immediate
- fi
-else
- # We cannot hardcode anything, or else we can only hardcode existing
- # directories.
- hardcode_action=unsupported
-fi
-echo "$as_me:$LINENO: result: $hardcode_action" >&5
-echo "${ECHO_T}$hardcode_action" >&6
-
-if test "$hardcode_action" = relink; then
- # Fast installation is not supported
- enable_fast_install=no
-elif test "$shlibpath_overrides_runpath" = yes ||
- test "$enable_shared" = no; then
- # Fast installation is not necessary
- enable_fast_install=needless
-fi
-
-striplib=
-old_striplib=
-echo "$as_me:$LINENO: checking whether stripping libraries is possible" >&5
-echo $ECHO_N "checking whether stripping libraries is possible... $ECHO_C" >&6
-if test -n "$STRIP" && $STRIP -V 2>&1 | grep "GNU strip" >/dev/null; then
- test -z "$old_striplib" && old_striplib="$STRIP --strip-debug"
- test -z "$striplib" && striplib="$STRIP --strip-unneeded"
- echo "$as_me:$LINENO: result: yes" >&5
-echo "${ECHO_T}yes" >&6
-else
-# FIXME - insert some real tests, host_os isn't really good enough
- case $host_os in
- darwin*)
- if test -n "$STRIP" ; then
- striplib="$STRIP -x"
- echo "$as_me:$LINENO: result: yes" >&5
-echo "${ECHO_T}yes" >&6
- else
- echo "$as_me:$LINENO: result: no" >&5
-echo "${ECHO_T}no" >&6
-fi
- ;;
- *)
- echo "$as_me:$LINENO: result: no" >&5
-echo "${ECHO_T}no" >&6
- ;;
- esac
-fi
-
-if test "x$enable_dlopen" != xyes; then
- enable_dlopen=unknown
- enable_dlopen_self=unknown
- enable_dlopen_self_static=unknown
-else
- lt_cv_dlopen=no
- lt_cv_dlopen_libs=
-
- case $host_os in
- beos*)
- lt_cv_dlopen="load_add_on"
- lt_cv_dlopen_libs=
- lt_cv_dlopen_self=yes
- ;;
-
- mingw* | pw32*)
- lt_cv_dlopen="LoadLibrary"
- lt_cv_dlopen_libs=
- ;;
-
- cygwin*)
- lt_cv_dlopen="dlopen"
- lt_cv_dlopen_libs=
- ;;
-
- darwin*)
- # if libdl is installed we need to link against it
- echo "$as_me:$LINENO: checking for dlopen in -ldl" >&5
-echo $ECHO_N "checking for dlopen in -ldl... $ECHO_C" >&6
-if test "${ac_cv_lib_dl_dlopen+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- ac_check_lib_save_LIBS=$LIBS
-LIBS="-ldl $LIBS"
-cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-
-/* Override any gcc2 internal prototype to avoid an error. */
-#ifdef __cplusplus
-extern "C"
-#endif
-/* We use char because int might match the return type of a gcc2
- builtin and then its argument prototype would still apply. */
-char dlopen ();
-int
-main ()
-{
-dlopen ();
- ;
- return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
- (eval $ac_link) 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } &&
- { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; } &&
- { ac_try='test -s conftest$ac_exeext'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
- ac_cv_lib_dl_dlopen=yes
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-ac_cv_lib_dl_dlopen=no
-fi
-rm -f conftest.err conftest.$ac_objext \
- conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
-fi
-echo "$as_me:$LINENO: result: $ac_cv_lib_dl_dlopen" >&5
-echo "${ECHO_T}$ac_cv_lib_dl_dlopen" >&6
-if test $ac_cv_lib_dl_dlopen = yes; then
- lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl"
-else
-
- lt_cv_dlopen="dyld"
- lt_cv_dlopen_libs=
- lt_cv_dlopen_self=yes
-
-fi
-
- ;;
-
- *)
- echo "$as_me:$LINENO: checking for shl_load" >&5
-echo $ECHO_N "checking for shl_load... $ECHO_C" >&6
-if test "${ac_cv_func_shl_load+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-/* Define shl_load to an innocuous variant, in case <limits.h> declares shl_load.
- For example, HP-UX 11i <limits.h> declares gettimeofday. */
-#define shl_load innocuous_shl_load
-
-/* System header to define __stub macros and hopefully few prototypes,
- which can conflict with char shl_load (); below.
- Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
- <limits.h> exists even on freestanding compilers. */
-
-#ifdef __STDC__
-# include <limits.h>
-#else
-# include <assert.h>
-#endif
-
-#undef shl_load
-
-/* Override any gcc2 internal prototype to avoid an error. */
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-/* We use char because int might match the return type of a gcc2
- builtin and then its argument prototype would still apply. */
-char shl_load ();
-/* The GNU C library defines this for functions which it implements
- to always fail with ENOSYS. Some functions are actually named
- something starting with __ and the normal name is an alias. */
-#if defined (__stub_shl_load) || defined (__stub___shl_load)
-choke me
-#else
-char (*f) () = shl_load;
-#endif
-#ifdef __cplusplus
-}
-#endif
-
-int
-main ()
-{
-return f != shl_load;
- ;
- return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
- (eval $ac_link) 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } &&
- { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; } &&
- { ac_try='test -s conftest$ac_exeext'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
- ac_cv_func_shl_load=yes
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-ac_cv_func_shl_load=no
-fi
-rm -f conftest.err conftest.$ac_objext \
- conftest$ac_exeext conftest.$ac_ext
-fi
-echo "$as_me:$LINENO: result: $ac_cv_func_shl_load" >&5
-echo "${ECHO_T}$ac_cv_func_shl_load" >&6
-if test $ac_cv_func_shl_load = yes; then
- lt_cv_dlopen="shl_load"
-else
- echo "$as_me:$LINENO: checking for shl_load in -ldld" >&5
-echo $ECHO_N "checking for shl_load in -ldld... $ECHO_C" >&6
-if test "${ac_cv_lib_dld_shl_load+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- ac_check_lib_save_LIBS=$LIBS
-LIBS="-ldld $LIBS"
-cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-
-/* Override any gcc2 internal prototype to avoid an error. */
-#ifdef __cplusplus
-extern "C"
-#endif
-/* We use char because int might match the return type of a gcc2
- builtin and then its argument prototype would still apply. */
-char shl_load ();
-int
-main ()
-{
-shl_load ();
- ;
- return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
- (eval $ac_link) 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } &&
- { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; } &&
- { ac_try='test -s conftest$ac_exeext'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
- ac_cv_lib_dld_shl_load=yes
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-ac_cv_lib_dld_shl_load=no
-fi
-rm -f conftest.err conftest.$ac_objext \
- conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
-fi
-echo "$as_me:$LINENO: result: $ac_cv_lib_dld_shl_load" >&5
-echo "${ECHO_T}$ac_cv_lib_dld_shl_load" >&6
-if test $ac_cv_lib_dld_shl_load = yes; then
- lt_cv_dlopen="shl_load" lt_cv_dlopen_libs="-dld"
-else
- echo "$as_me:$LINENO: checking for dlopen" >&5
-echo $ECHO_N "checking for dlopen... $ECHO_C" >&6
-if test "${ac_cv_func_dlopen+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-/* Define dlopen to an innocuous variant, in case <limits.h> declares dlopen.
- For example, HP-UX 11i <limits.h> declares gettimeofday. */
-#define dlopen innocuous_dlopen
-
-/* System header to define __stub macros and hopefully few prototypes,
- which can conflict with char dlopen (); below.
- Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
- <limits.h> exists even on freestanding compilers. */
-
-#ifdef __STDC__
-# include <limits.h>
-#else
-# include <assert.h>
-#endif
-
-#undef dlopen
-
-/* Override any gcc2 internal prototype to avoid an error. */
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-/* We use char because int might match the return type of a gcc2
- builtin and then its argument prototype would still apply. */
-char dlopen ();
-/* The GNU C library defines this for functions which it implements
- to always fail with ENOSYS. Some functions are actually named
- something starting with __ and the normal name is an alias. */
-#if defined (__stub_dlopen) || defined (__stub___dlopen)
-choke me
-#else
-char (*f) () = dlopen;
-#endif
-#ifdef __cplusplus
-}
-#endif
-
-int
-main ()
-{
-return f != dlopen;
- ;
- return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
- (eval $ac_link) 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } &&
- { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; } &&
- { ac_try='test -s conftest$ac_exeext'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
- ac_cv_func_dlopen=yes
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-ac_cv_func_dlopen=no
-fi
-rm -f conftest.err conftest.$ac_objext \
- conftest$ac_exeext conftest.$ac_ext
-fi
-echo "$as_me:$LINENO: result: $ac_cv_func_dlopen" >&5
-echo "${ECHO_T}$ac_cv_func_dlopen" >&6
-if test $ac_cv_func_dlopen = yes; then
- lt_cv_dlopen="dlopen"
-else
- echo "$as_me:$LINENO: checking for dlopen in -ldl" >&5
-echo $ECHO_N "checking for dlopen in -ldl... $ECHO_C" >&6
-if test "${ac_cv_lib_dl_dlopen+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- ac_check_lib_save_LIBS=$LIBS
-LIBS="-ldl $LIBS"
-cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-
-/* Override any gcc2 internal prototype to avoid an error. */
-#ifdef __cplusplus
-extern "C"
-#endif
-/* We use char because int might match the return type of a gcc2
- builtin and then its argument prototype would still apply. */
-char dlopen ();
-int
-main ()
-{
-dlopen ();
- ;
- return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
- (eval $ac_link) 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } &&
- { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; } &&
- { ac_try='test -s conftest$ac_exeext'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
- ac_cv_lib_dl_dlopen=yes
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-ac_cv_lib_dl_dlopen=no
-fi
-rm -f conftest.err conftest.$ac_objext \
- conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
-fi
-echo "$as_me:$LINENO: result: $ac_cv_lib_dl_dlopen" >&5
-echo "${ECHO_T}$ac_cv_lib_dl_dlopen" >&6
-if test $ac_cv_lib_dl_dlopen = yes; then
- lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl"
-else
- echo "$as_me:$LINENO: checking for dlopen in -lsvld" >&5
-echo $ECHO_N "checking for dlopen in -lsvld... $ECHO_C" >&6
-if test "${ac_cv_lib_svld_dlopen+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- ac_check_lib_save_LIBS=$LIBS
-LIBS="-lsvld $LIBS"
-cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-
-/* Override any gcc2 internal prototype to avoid an error. */
-#ifdef __cplusplus
-extern "C"
-#endif
-/* We use char because int might match the return type of a gcc2
- builtin and then its argument prototype would still apply. */
-char dlopen ();
-int
-main ()
-{
-dlopen ();
- ;
- return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
- (eval $ac_link) 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } &&
- { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; } &&
- { ac_try='test -s conftest$ac_exeext'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
- ac_cv_lib_svld_dlopen=yes
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-ac_cv_lib_svld_dlopen=no
-fi
-rm -f conftest.err conftest.$ac_objext \
- conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
-fi
-echo "$as_me:$LINENO: result: $ac_cv_lib_svld_dlopen" >&5
-echo "${ECHO_T}$ac_cv_lib_svld_dlopen" >&6
-if test $ac_cv_lib_svld_dlopen = yes; then
- lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-lsvld"
-else
- echo "$as_me:$LINENO: checking for dld_link in -ldld" >&5
-echo $ECHO_N "checking for dld_link in -ldld... $ECHO_C" >&6
-if test "${ac_cv_lib_dld_dld_link+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- ac_check_lib_save_LIBS=$LIBS
-LIBS="-ldld $LIBS"
-cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-
-/* Override any gcc2 internal prototype to avoid an error. */
-#ifdef __cplusplus
-extern "C"
-#endif
-/* We use char because int might match the return type of a gcc2
- builtin and then its argument prototype would still apply. */
-char dld_link ();
-int
-main ()
-{
-dld_link ();
- ;
- return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
- (eval $ac_link) 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } &&
- { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; } &&
- { ac_try='test -s conftest$ac_exeext'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
- ac_cv_lib_dld_dld_link=yes
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-ac_cv_lib_dld_dld_link=no
-fi
-rm -f conftest.err conftest.$ac_objext \
- conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
-fi
-echo "$as_me:$LINENO: result: $ac_cv_lib_dld_dld_link" >&5
-echo "${ECHO_T}$ac_cv_lib_dld_dld_link" >&6
-if test $ac_cv_lib_dld_dld_link = yes; then
- lt_cv_dlopen="dld_link" lt_cv_dlopen_libs="-dld"
-fi
-
-
-fi
-
-
-fi
-
-
-fi
-
-
-fi
-
-
-fi
-
- ;;
- esac
-
- if test "x$lt_cv_dlopen" != xno; then
- enable_dlopen=yes
- else
- enable_dlopen=no
- fi
-
- case $lt_cv_dlopen in
- dlopen)
- save_CPPFLAGS="$CPPFLAGS"
- test "x$ac_cv_header_dlfcn_h" = xyes && CPPFLAGS="$CPPFLAGS -DHAVE_DLFCN_H"
-
- save_LDFLAGS="$LDFLAGS"
- wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $export_dynamic_flag_spec\"
-
- save_LIBS="$LIBS"
- LIBS="$lt_cv_dlopen_libs $LIBS"
-
- echo "$as_me:$LINENO: checking whether a program can dlopen itself" >&5
-echo $ECHO_N "checking whether a program can dlopen itself... $ECHO_C" >&6
-if test "${lt_cv_dlopen_self+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- if test "$cross_compiling" = yes; then :
- lt_cv_dlopen_self=cross
-else
- lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
- lt_status=$lt_dlunknown
- cat > conftest.$ac_ext <<EOF
-#line 9055 "configure"
-#include "confdefs.h"
-
-#if HAVE_DLFCN_H
-#include <dlfcn.h>
-#endif
-
-#include <stdio.h>
-
-#ifdef RTLD_GLOBAL
-# define LT_DLGLOBAL RTLD_GLOBAL
-#else
-# ifdef DL_GLOBAL
-# define LT_DLGLOBAL DL_GLOBAL
-# else
-# define LT_DLGLOBAL 0
-# endif
-#endif
-
-/* We may have to define LT_DLLAZY_OR_NOW in the command line if we
- find out it does not work in some platform. */
-#ifndef LT_DLLAZY_OR_NOW
-# ifdef RTLD_LAZY
-# define LT_DLLAZY_OR_NOW RTLD_LAZY
-# else
-# ifdef DL_LAZY
-# define LT_DLLAZY_OR_NOW DL_LAZY
-# else
-# ifdef RTLD_NOW
-# define LT_DLLAZY_OR_NOW RTLD_NOW
-# else
-# ifdef DL_NOW
-# define LT_DLLAZY_OR_NOW DL_NOW
-# else
-# define LT_DLLAZY_OR_NOW 0
-# endif
-# endif
-# endif
-# endif
-#endif
-
-#ifdef __cplusplus
-extern "C" void exit (int);
-#endif
-
-void fnord() { int i=42;}
-int main ()
-{
- void *self = dlopen (0, LT_DLGLOBAL|LT_DLLAZY_OR_NOW);
- int status = $lt_dlunknown;
-
- if (self)
- {
- if (dlsym (self,"fnord")) status = $lt_dlno_uscore;
- else if (dlsym( self,"_fnord")) status = $lt_dlneed_uscore;
- /* dlclose (self); */
- }
- else
- puts (dlerror ());
-
- exit (status);
-}
-EOF
- if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
- (eval $ac_link) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } && test -s conftest${ac_exeext} 2>/dev/null; then
- (./conftest; exit; ) >&5 2>/dev/null
- lt_status=$?
- case x$lt_status in
- x$lt_dlno_uscore) lt_cv_dlopen_self=yes ;;
- x$lt_dlneed_uscore) lt_cv_dlopen_self=yes ;;
- x$lt_dlunknown|x*) lt_cv_dlopen_self=no ;;
- esac
- else :
- # compilation failed
- lt_cv_dlopen_self=no
- fi
-fi
-rm -fr conftest*
-
-
-fi
-echo "$as_me:$LINENO: result: $lt_cv_dlopen_self" >&5
-echo "${ECHO_T}$lt_cv_dlopen_self" >&6
-
- if test "x$lt_cv_dlopen_self" = xyes; then
- wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $lt_prog_compiler_static\"
- echo "$as_me:$LINENO: checking whether a statically linked program can dlopen itself" >&5
-echo $ECHO_N "checking whether a statically linked program can dlopen itself... $ECHO_C" >&6
-if test "${lt_cv_dlopen_self_static+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- if test "$cross_compiling" = yes; then :
- lt_cv_dlopen_self_static=cross
-else
- lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
- lt_status=$lt_dlunknown
- cat > conftest.$ac_ext <<EOF
-#line 9155 "configure"
-#include "confdefs.h"
-
-#if HAVE_DLFCN_H
-#include <dlfcn.h>
-#endif
-
-#include <stdio.h>
-
-#ifdef RTLD_GLOBAL
-# define LT_DLGLOBAL RTLD_GLOBAL
-#else
-# ifdef DL_GLOBAL
-# define LT_DLGLOBAL DL_GLOBAL
-# else
-# define LT_DLGLOBAL 0
-# endif
-#endif
-
-/* We may have to define LT_DLLAZY_OR_NOW in the command line if we
- find out it does not work in some platform. */
-#ifndef LT_DLLAZY_OR_NOW
-# ifdef RTLD_LAZY
-# define LT_DLLAZY_OR_NOW RTLD_LAZY
-# else
-# ifdef DL_LAZY
-# define LT_DLLAZY_OR_NOW DL_LAZY
-# else
-# ifdef RTLD_NOW
-# define LT_DLLAZY_OR_NOW RTLD_NOW
-# else
-# ifdef DL_NOW
-# define LT_DLLAZY_OR_NOW DL_NOW
-# else
-# define LT_DLLAZY_OR_NOW 0
-# endif
-# endif
-# endif
-# endif
-#endif
-
-#ifdef __cplusplus
-extern "C" void exit (int);
-#endif
-
-void fnord() { int i=42;}
-int main ()
-{
- void *self = dlopen (0, LT_DLGLOBAL|LT_DLLAZY_OR_NOW);
- int status = $lt_dlunknown;
-
- if (self)
- {
- if (dlsym (self,"fnord")) status = $lt_dlno_uscore;
- else if (dlsym( self,"_fnord")) status = $lt_dlneed_uscore;
- /* dlclose (self); */
- }
- else
- puts (dlerror ());
-
- exit (status);
-}
-EOF
- if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
- (eval $ac_link) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } && test -s conftest${ac_exeext} 2>/dev/null; then
- (./conftest; exit; ) >&5 2>/dev/null
- lt_status=$?
- case x$lt_status in
- x$lt_dlno_uscore) lt_cv_dlopen_self_static=yes ;;
- x$lt_dlneed_uscore) lt_cv_dlopen_self_static=yes ;;
- x$lt_dlunknown|x*) lt_cv_dlopen_self_static=no ;;
- esac
- else :
- # compilation failed
- lt_cv_dlopen_self_static=no
- fi
-fi
-rm -fr conftest*
-
-
-fi
-echo "$as_me:$LINENO: result: $lt_cv_dlopen_self_static" >&5
-echo "${ECHO_T}$lt_cv_dlopen_self_static" >&6
- fi
-
- CPPFLAGS="$save_CPPFLAGS"
- LDFLAGS="$save_LDFLAGS"
- LIBS="$save_LIBS"
- ;;
- esac
-
- case $lt_cv_dlopen_self in
- yes|no) enable_dlopen_self=$lt_cv_dlopen_self ;;
- *) enable_dlopen_self=unknown ;;
- esac
-
- case $lt_cv_dlopen_self_static in
- yes|no) enable_dlopen_self_static=$lt_cv_dlopen_self_static ;;
- *) enable_dlopen_self_static=unknown ;;
- esac
-fi
-
-
-# Report which library types will actually be built
-echo "$as_me:$LINENO: checking if libtool supports shared libraries" >&5
-echo $ECHO_N "checking if libtool supports shared libraries... $ECHO_C" >&6
-echo "$as_me:$LINENO: result: $can_build_shared" >&5
-echo "${ECHO_T}$can_build_shared" >&6
-
-echo "$as_me:$LINENO: checking whether to build shared libraries" >&5
-echo $ECHO_N "checking whether to build shared libraries... $ECHO_C" >&6
-test "$can_build_shared" = "no" && enable_shared=no
-
-# On AIX, shared libraries and static libraries use the same namespace, and
-# are all built from PIC.
-case $host_os in
-aix3*)
- test "$enable_shared" = yes && enable_static=no
- if test -n "$RANLIB"; then
- archive_cmds="$archive_cmds~\$RANLIB \$lib"
- postinstall_cmds='$RANLIB $lib'
- fi
- ;;
-
-aix4* | aix5*)
- if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then
- test "$enable_shared" = yes && enable_static=no
- fi
- ;;
-esac
-echo "$as_me:$LINENO: result: $enable_shared" >&5
-echo "${ECHO_T}$enable_shared" >&6
-
-echo "$as_me:$LINENO: checking whether to build static libraries" >&5
-echo $ECHO_N "checking whether to build static libraries... $ECHO_C" >&6
-# Make sure either enable_shared or enable_static is yes.
-test "$enable_shared" = yes || enable_static=yes
-echo "$as_me:$LINENO: result: $enable_static" >&5
-echo "${ECHO_T}$enable_static" >&6
-
-# The else clause should only fire when bootstrapping the
-# libtool distribution, otherwise you forgot to ship ltmain.sh
-# with your package, and you will get complaints that there are
-# no rules to generate ltmain.sh.
-if test -f "$ltmain"; then
- # See if we are running on zsh, and set the options which allow our commands through
- # without removal of \ escapes.
- if test -n "${ZSH_VERSION+set}" ; then
- setopt NO_GLOB_SUBST
- fi
- # Now quote all the things that may contain metacharacters while being
- # careful not to overquote the AC_SUBSTed values. We take copies of the
- # variables and quote the copies for generation of the libtool script.
- for var in echo old_CC old_CFLAGS AR AR_FLAGS EGREP RANLIB LN_S LTCC LTCFLAGS NM \
- SED SHELL STRIP \
- libname_spec library_names_spec soname_spec extract_expsyms_cmds \
- old_striplib striplib file_magic_cmd finish_cmds finish_eval \
- deplibs_check_method reload_flag reload_cmds need_locks \
- lt_cv_sys_global_symbol_pipe lt_cv_sys_global_symbol_to_cdecl \
- lt_cv_sys_global_symbol_to_c_name_address \
- sys_lib_search_path_spec sys_lib_dlsearch_path_spec \
- old_postinstall_cmds old_postuninstall_cmds \
- compiler \
- CC \
- LD \
- lt_prog_compiler_wl \
- lt_prog_compiler_pic \
- lt_prog_compiler_static \
- lt_prog_compiler_no_builtin_flag \
- export_dynamic_flag_spec \
- thread_safe_flag_spec \
- whole_archive_flag_spec \
- enable_shared_with_static_runtimes \
- old_archive_cmds \
- old_archive_from_new_cmds \
- predep_objects \
- postdep_objects \
- predeps \
- postdeps \
- compiler_lib_search_path \
- archive_cmds \
- archive_expsym_cmds \
- postinstall_cmds \
- postuninstall_cmds \
- old_archive_from_expsyms_cmds \
- allow_undefined_flag \
- no_undefined_flag \
- export_symbols_cmds \
- hardcode_libdir_flag_spec \
- hardcode_libdir_flag_spec_ld \
- hardcode_libdir_separator \
- hardcode_automatic \
- module_cmds \
- module_expsym_cmds \
- lt_cv_prog_compiler_c_o \
- exclude_expsyms \
- include_expsyms; do
-
- case $var in
- old_archive_cmds | \
- old_archive_from_new_cmds | \
- archive_cmds | \
- archive_expsym_cmds | \
- module_cmds | \
- module_expsym_cmds | \
- old_archive_from_expsyms_cmds | \
- export_symbols_cmds | \
- extract_expsyms_cmds | reload_cmds | finish_cmds | \
- postinstall_cmds | postuninstall_cmds | \
- old_postinstall_cmds | old_postuninstall_cmds | \
- sys_lib_search_path_spec | sys_lib_dlsearch_path_spec)
- # Double-quote double-evaled strings.
- eval "lt_$var=\\\"\`\$echo \"X\$$var\" | \$Xsed -e \"\$double_quote_subst\" -e \"\$sed_quote_subst\" -e \"\$delay_variable_subst\"\`\\\""
- ;;
- *)
- eval "lt_$var=\\\"\`\$echo \"X\$$var\" | \$Xsed -e \"\$sed_quote_subst\"\`\\\""
- ;;
- esac
- done
-
- case $lt_echo in
- *'\$0 --fallback-echo"')
- lt_echo=`$echo "X$lt_echo" | $Xsed -e 's/\\\\\\\$0 --fallback-echo"$/$0 --fallback-echo"/'`
- ;;
- esac
-
-cfgfile="${ofile}T"
- trap "$rm \"$cfgfile\"; exit 1" 1 2 15
- $rm -f "$cfgfile"
- { echo "$as_me:$LINENO: creating $ofile" >&5
-echo "$as_me: creating $ofile" >&6;}
-
- cat <<__EOF__ >> "$cfgfile"
-#! $SHELL
-
-# `$echo "$cfgfile" | sed 's%^.*/%%'` - Provide generalized library-building support services.
-# Generated automatically by $PROGRAM (GNU $PACKAGE $VERSION$TIMESTAMP)
-# NOTE: Changes made to this file will be lost: look at ltmain.sh.
-#
-# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001
-# Free Software Foundation, Inc.
-#
-# This file is part of GNU Libtool:
-# Originally by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-#
-# This program 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 this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-#
-# As a special exception to the GNU General Public License, if you
-# distribute this file as part of a program that contains a
-# configuration script generated by Autoconf, you may include it under
-# the same distribution terms that you use for the rest of that program.
-
-# A sed program that does not truncate output.
-SED=$lt_SED
-
-# Sed that helps us avoid accidentally triggering echo(1) options like -n.
-Xsed="$SED -e 1s/^X//"
-
-# The HP-UX ksh and POSIX shell print the target directory to stdout
-# if CDPATH is set.
-(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
-
-# The names of the tagged configurations supported by this script.
-available_tags=
-
-# ### BEGIN LIBTOOL CONFIG
-
-# Libtool was configured on host `(hostname || uname -n) 2>/dev/null | sed 1q`:
-
-# Shell to use when invoking shell scripts.
-SHELL=$lt_SHELL
-
-# Whether or not to build shared libraries.
-build_libtool_libs=$enable_shared
-
-# Whether or not to build static libraries.
-build_old_libs=$enable_static
-
-# Whether or not to add -lc for building shared libraries.
-build_libtool_need_lc=$archive_cmds_need_lc
-
-# Whether or not to disallow shared libs when runtime libs are static
-allow_libtool_libs_with_static_runtimes=$enable_shared_with_static_runtimes
-
-# Whether or not to optimize for fast installation.
-fast_install=$enable_fast_install
-
-# The host system.
-host_alias=$host_alias
-host=$host
-host_os=$host_os
-
-# The build system.
-build_alias=$build_alias
-build=$build
-build_os=$build_os
-
-# An echo program that does not interpret backslashes.
-echo=$lt_echo
-
-# The archiver.
-AR=$lt_AR
-AR_FLAGS=$lt_AR_FLAGS
-
-# A C compiler.
-LTCC=$lt_LTCC
-
-# LTCC compiler flags.
-LTCFLAGS=$lt_LTCFLAGS
-
-# A language-specific compiler.
-CC=$lt_compiler
-
-# Is the compiler the GNU C compiler?
-with_gcc=$GCC
-
-# An ERE matcher.
-EGREP=$lt_EGREP
-
-# The linker used to build libraries.
-LD=$lt_LD
-
-# Whether we need hard or soft links.
-LN_S=$lt_LN_S
-
-# A BSD-compatible nm program.
-NM=$lt_NM
-
-# A symbol stripping program
-STRIP=$lt_STRIP
-
-# Used to examine libraries when file_magic_cmd begins "file"
-MAGIC_CMD=$MAGIC_CMD
-
-# Used on cygwin: DLL creation program.
-DLLTOOL="$DLLTOOL"
-
-# Used on cygwin: object dumper.
-OBJDUMP="$OBJDUMP"
-
-# Used on cygwin: assembler.
-AS="$AS"
-
-# The name of the directory that contains temporary libtool files.
-objdir=$objdir
-
-# How to create reloadable object files.
-reload_flag=$lt_reload_flag
-reload_cmds=$lt_reload_cmds
-
-# How to pass a linker flag through the compiler.
-wl=$lt_lt_prog_compiler_wl
-
-# Object file suffix (normally "o").
-objext="$ac_objext"
-
-# Old archive suffix (normally "a").
-libext="$libext"
-
-# Shared library suffix (normally ".so").
-shrext_cmds='$shrext_cmds'
-
-# Executable file suffix (normally "").
-exeext="$exeext"
-
-# Additional compiler flags for building library objects.
-pic_flag=$lt_lt_prog_compiler_pic
-pic_mode=$pic_mode
-
-# What is the maximum length of a command?
-max_cmd_len=$lt_cv_sys_max_cmd_len
-
-# Does compiler simultaneously support -c and -o options?
-compiler_c_o=$lt_lt_cv_prog_compiler_c_o
-
-# Must we lock files when doing compilation?
-need_locks=$lt_need_locks
-
-# Do we need the lib prefix for modules?
-need_lib_prefix=$need_lib_prefix
-
-# Do we need a version for libraries?
-need_version=$need_version
-
-# Whether dlopen is supported.
-dlopen_support=$enable_dlopen
-
-# Whether dlopen of programs is supported.
-dlopen_self=$enable_dlopen_self
-
-# Whether dlopen of statically linked programs is supported.
-dlopen_self_static=$enable_dlopen_self_static
-
-# Compiler flag to prevent dynamic linking.
-link_static_flag=$lt_lt_prog_compiler_static
-
-# Compiler flag to turn off builtin functions.
-no_builtin_flag=$lt_lt_prog_compiler_no_builtin_flag
-
-# Compiler flag to allow reflexive dlopens.
-export_dynamic_flag_spec=$lt_export_dynamic_flag_spec
-
-# Compiler flag to generate shared objects directly from archives.
-whole_archive_flag_spec=$lt_whole_archive_flag_spec
-
-# Compiler flag to generate thread-safe objects.
-thread_safe_flag_spec=$lt_thread_safe_flag_spec
-
-# Library versioning type.
-version_type=$version_type
-
-# Format of library name prefix.
-libname_spec=$lt_libname_spec
-
-# List of archive names. First name is the real one, the rest are links.
-# The last name is the one that the linker finds with -lNAME.
-library_names_spec=$lt_library_names_spec
-
-# The coded name of the library, if different from the real name.
-soname_spec=$lt_soname_spec
-
-# Commands used to build and install an old-style archive.
-RANLIB=$lt_RANLIB
-old_archive_cmds=$lt_old_archive_cmds
-old_postinstall_cmds=$lt_old_postinstall_cmds
-old_postuninstall_cmds=$lt_old_postuninstall_cmds
-
-# Create an old-style archive from a shared archive.
-old_archive_from_new_cmds=$lt_old_archive_from_new_cmds
-
-# Create a temporary old-style archive to link instead of a shared archive.
-old_archive_from_expsyms_cmds=$lt_old_archive_from_expsyms_cmds
-
-# Commands used to build and install a shared archive.
-archive_cmds=$lt_archive_cmds
-archive_expsym_cmds=$lt_archive_expsym_cmds
-postinstall_cmds=$lt_postinstall_cmds
-postuninstall_cmds=$lt_postuninstall_cmds
-
-# Commands used to build a loadable module (assumed same as above if empty)
-module_cmds=$lt_module_cmds
-module_expsym_cmds=$lt_module_expsym_cmds
-
-# Commands to strip libraries.
-old_striplib=$lt_old_striplib
-striplib=$lt_striplib
-
-# Dependencies to place before the objects being linked to create a
-# shared library.
-predep_objects=$lt_predep_objects
-
-# Dependencies to place after the objects being linked to create a
-# shared library.
-postdep_objects=$lt_postdep_objects
-
-# Dependencies to place before the objects being linked to create a
-# shared library.
-predeps=$lt_predeps
-
-# Dependencies to place after the objects being linked to create a
-# shared library.
-postdeps=$lt_postdeps
-
-# The library search path used internally by the compiler when linking
-# a shared library.
-compiler_lib_search_path=$lt_compiler_lib_search_path
-
-# Method to check whether dependent libraries are shared objects.
-deplibs_check_method=$lt_deplibs_check_method
-
-# Command to use when deplibs_check_method == file_magic.
-file_magic_cmd=$lt_file_magic_cmd
-
-# Flag that allows shared libraries with undefined symbols to be built.
-allow_undefined_flag=$lt_allow_undefined_flag
-
-# Flag that forces no undefined symbols.
-no_undefined_flag=$lt_no_undefined_flag
-
-# Commands used to finish a libtool library installation in a directory.
-finish_cmds=$lt_finish_cmds
-
-# Same as above, but a single script fragment to be evaled but not shown.
-finish_eval=$lt_finish_eval
-
-# Take the output of nm and produce a listing of raw symbols and C names.
-global_symbol_pipe=$lt_lt_cv_sys_global_symbol_pipe
-
-# Transform the output of nm in a proper C declaration
-global_symbol_to_cdecl=$lt_lt_cv_sys_global_symbol_to_cdecl
-
-# Transform the output of nm in a C name address pair
-global_symbol_to_c_name_address=$lt_lt_cv_sys_global_symbol_to_c_name_address
-
-# This is the shared library runtime path variable.
-runpath_var=$runpath_var
-
-# This is the shared library path variable.
-shlibpath_var=$shlibpath_var
-
-# Is shlibpath searched before the hard-coded library search path?
-shlibpath_overrides_runpath=$shlibpath_overrides_runpath
-
-# How to hardcode a shared library path into an executable.
-hardcode_action=$hardcode_action
-
-# Whether we should hardcode library paths into libraries.
-hardcode_into_libs=$hardcode_into_libs
-
-# Flag to hardcode \$libdir into a binary during linking.
-# This must work even if \$libdir does not exist.
-hardcode_libdir_flag_spec=$lt_hardcode_libdir_flag_spec
-
-# If ld is used when linking, flag to hardcode \$libdir into
-# a binary during linking. This must work even if \$libdir does
-# not exist.
-hardcode_libdir_flag_spec_ld=$lt_hardcode_libdir_flag_spec_ld
-
-# Whether we need a single -rpath flag with a separated argument.
-hardcode_libdir_separator=$lt_hardcode_libdir_separator
-
-# Set to yes if using DIR/libNAME${shared_ext} during linking hardcodes DIR into the
-# resulting binary.
-hardcode_direct=$hardcode_direct
-
-# Set to yes if using the -LDIR flag during linking hardcodes DIR into the
-# resulting binary.
-hardcode_minus_L=$hardcode_minus_L
-
-# Set to yes if using SHLIBPATH_VAR=DIR during linking hardcodes DIR into
-# the resulting binary.
-hardcode_shlibpath_var=$hardcode_shlibpath_var
-
-# Set to yes if building a shared library automatically hardcodes DIR into the library
-# and all subsequent libraries and executables linked against it.
-hardcode_automatic=$hardcode_automatic
-
-# Variables whose values should be saved in libtool wrapper scripts and
-# restored at relink time.
-variables_saved_for_relink="$variables_saved_for_relink"
-
-# Whether libtool must link a program against all its dependency libraries.
-link_all_deplibs=$link_all_deplibs
-
-# Compile-time system search path for libraries
-sys_lib_search_path_spec=$lt_sys_lib_search_path_spec
-
-# Run-time system search path for libraries
-sys_lib_dlsearch_path_spec=$lt_sys_lib_dlsearch_path_spec
-
-# Fix the shell variable \$srcfile for the compiler.
-fix_srcfile_path="$fix_srcfile_path"
-
-# Set to yes if exported symbols are required.
-always_export_symbols=$always_export_symbols
-
-# The commands to list exported symbols.
-export_symbols_cmds=$lt_export_symbols_cmds
-
-# The commands to extract the exported symbol list from a shared archive.
-extract_expsyms_cmds=$lt_extract_expsyms_cmds
-
-# Symbols that should not be listed in the preloaded symbols.
-exclude_expsyms=$lt_exclude_expsyms
-
-# Symbols that must always be exported.
-include_expsyms=$lt_include_expsyms
-
-# ### END LIBTOOL CONFIG
-
-__EOF__
-
-
- case $host_os in
- aix3*)
- cat <<\EOF >> "$cfgfile"
-
-# AIX sometimes has problems with the GCC collect2 program. For some
-# reason, if we set the COLLECT_NAMES environment variable, the problems
-# vanish in a puff of smoke.
-if test "X${COLLECT_NAMES+set}" != Xset; then
- COLLECT_NAMES=
- export COLLECT_NAMES
-fi
-EOF
- ;;
- esac
-
- # We use sed instead of cat because bash on DJGPP gets confused if
- # if finds mixed CR/LF and LF-only lines. Since sed operates in
- # text mode, it properly converts lines to CR/LF. This bash problem
- # is reportedly fixed, but why not run on old versions too?
- sed '$q' "$ltmain" >> "$cfgfile" || (rm -f "$cfgfile"; exit 1)
-
- mv -f "$cfgfile" "$ofile" || \
- (rm -f "$ofile" && cp "$cfgfile" "$ofile" && rm -f "$cfgfile")
- chmod +x "$ofile"
-
-else
- # If there is no Makefile yet, we rely on a make rule to execute
- # `config.status --recheck' to rerun these tests and create the
- # libtool script then.
- ltmain_in=`echo $ltmain | sed -e 's/\.sh$/.in/'`
- if test -f "$ltmain_in"; then
- test -f Makefile && make "$ltmain"
- fi
-fi
-
-
-ac_ext=c
-ac_cpp='$CPP $CPPFLAGS'
-ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
-ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
-ac_compiler_gnu=$ac_cv_c_compiler_gnu
-
-CC="$lt_save_CC"
-
-
-# Check whether --with-tags or --without-tags was given.
-if test "${with_tags+set}" = set; then
- withval="$with_tags"
- tagnames="$withval"
-fi;
-
-if test -f "$ltmain" && test -n "$tagnames"; then
- if test ! -f "${ofile}"; then
- { echo "$as_me:$LINENO: WARNING: output file \`$ofile' does not exist" >&5
-echo "$as_me: WARNING: output file \`$ofile' does not exist" >&2;}
- fi
-
- if test -z "$LTCC"; then
- eval "`$SHELL ${ofile} --config | grep '^LTCC='`"
- if test -z "$LTCC"; then
- { echo "$as_me:$LINENO: WARNING: output file \`$ofile' does not look like a libtool script" >&5
-echo "$as_me: WARNING: output file \`$ofile' does not look like a libtool script" >&2;}
- else
- { echo "$as_me:$LINENO: WARNING: using \`LTCC=$LTCC', extracted from \`$ofile'" >&5
-echo "$as_me: WARNING: using \`LTCC=$LTCC', extracted from \`$ofile'" >&2;}
- fi
- fi
- if test -z "$LTCFLAGS"; then
- eval "`$SHELL ${ofile} --config | grep '^LTCFLAGS='`"
- fi
-
- # Extract list of available tagged configurations in $ofile.
- # Note that this assumes the entire list is on one line.
- available_tags=`grep "^available_tags=" "${ofile}" | $SED -e 's/available_tags=\(.*$\)/\1/' -e 's/\"//g'`
-
- lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR,"
- for tagname in $tagnames; do
- IFS="$lt_save_ifs"
- # Check whether tagname contains only valid characters
- case `$echo "X$tagname" | $Xsed -e 's:[-_ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890,/]::g'` in
- "") ;;
- *) { { echo "$as_me:$LINENO: error: invalid tag name: $tagname" >&5
-echo "$as_me: error: invalid tag name: $tagname" >&2;}
- { (exit 1); exit 1; }; }
- ;;
- esac
-
- if grep "^# ### BEGIN LIBTOOL TAG CONFIG: $tagname$" < "${ofile}" > /dev/null
- then
- { { echo "$as_me:$LINENO: error: tag name \"$tagname\" already exists" >&5
-echo "$as_me: error: tag name \"$tagname\" already exists" >&2;}
- { (exit 1); exit 1; }; }
- fi
-
- # Update the list of available tags.
- if test -n "$tagname"; then
- echo appending configuration tag \"$tagname\" to $ofile
-
- case $tagname in
- CXX)
- if test -n "$CXX" && ( test "X$CXX" != "Xno" &&
- ( (test "X$CXX" = "Xg++" && `g++ -v >/dev/null 2>&1` ) ||
- (test "X$CXX" != "Xg++"))) ; then
- ac_ext=cc
-ac_cpp='$CXXCPP $CPPFLAGS'
-ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
-ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
-ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
-
-
-
-
-archive_cmds_need_lc_CXX=no
-allow_undefined_flag_CXX=
-always_export_symbols_CXX=no
-archive_expsym_cmds_CXX=
-export_dynamic_flag_spec_CXX=
-hardcode_direct_CXX=no
-hardcode_libdir_flag_spec_CXX=
-hardcode_libdir_flag_spec_ld_CXX=
-hardcode_libdir_separator_CXX=
-hardcode_minus_L_CXX=no
-hardcode_shlibpath_var_CXX=unsupported
-hardcode_automatic_CXX=no
-module_cmds_CXX=
-module_expsym_cmds_CXX=
-link_all_deplibs_CXX=unknown
-old_archive_cmds_CXX=$old_archive_cmds
-no_undefined_flag_CXX=
-whole_archive_flag_spec_CXX=
-enable_shared_with_static_runtimes_CXX=no
-
-# Dependencies to place before and after the object being linked:
-predep_objects_CXX=
-postdep_objects_CXX=
-predeps_CXX=
-postdeps_CXX=
-compiler_lib_search_path_CXX=
-
-# Source file extension for C++ test sources.
-ac_ext=cpp
-
-# Object file extension for compiled C++ test sources.
-objext=o
-objext_CXX=$objext
-
-# Code to be used in simple compile tests
-lt_simple_compile_test_code="int some_variable = 0;\n"
-
-# Code to be used in simple link tests
-lt_simple_link_test_code='int main(int, char *[]) { return(0); }\n'
-
-# ltmain only uses $CC for tagged configurations so make sure $CC is set.
-
-# If no C compiler was specified, use CC.
-LTCC=${LTCC-"$CC"}
-
-# If no C compiler flags were specified, use CFLAGS.
-LTCFLAGS=${LTCFLAGS-"$CFLAGS"}
-
-# Allow CC to be a program name with arguments.
-compiler=$CC
-
-
-# save warnings/boilerplate of simple test code
-ac_outfile=conftest.$ac_objext
-printf "$lt_simple_compile_test_code" >conftest.$ac_ext
-eval "$ac_compile" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err
-_lt_compiler_boilerplate=`cat conftest.err`
-$rm conftest*
-
-ac_outfile=conftest.$ac_objext
-printf "$lt_simple_link_test_code" >conftest.$ac_ext
-eval "$ac_link" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err
-_lt_linker_boilerplate=`cat conftest.err`
-$rm conftest*
-
-
-# Allow CC to be a program name with arguments.
-lt_save_CC=$CC
-lt_save_LD=$LD
-lt_save_GCC=$GCC
-GCC=$GXX
-lt_save_with_gnu_ld=$with_gnu_ld
-lt_save_path_LD=$lt_cv_path_LD
-if test -n "${lt_cv_prog_gnu_ldcxx+set}"; then
- lt_cv_prog_gnu_ld=$lt_cv_prog_gnu_ldcxx
-else
- $as_unset lt_cv_prog_gnu_ld
-fi
-if test -n "${lt_cv_path_LDCXX+set}"; then
- lt_cv_path_LD=$lt_cv_path_LDCXX
-else
- $as_unset lt_cv_path_LD
-fi
-test -z "${LDCXX+set}" || LD=$LDCXX
-CC=${CXX-"c++"}
-compiler=$CC
-compiler_CXX=$CC
-for cc_temp in $compiler""; do
- case $cc_temp in
- compile | *[\\/]compile | ccache | *[\\/]ccache ) ;;
- distcc | *[\\/]distcc | purify | *[\\/]purify ) ;;
- \-*) ;;
- *) break;;
- esac
-done
-cc_basename=`$echo "X$cc_temp" | $Xsed -e 's%.*/%%' -e "s%^$host_alias-%%"`
-
-
-# We don't want -fno-exception wen compiling C++ code, so set the
-# no_builtin_flag separately
-if test "$GXX" = yes; then
- lt_prog_compiler_no_builtin_flag_CXX=' -fno-builtin'
-else
- lt_prog_compiler_no_builtin_flag_CXX=
-fi
-
-if test "$GXX" = yes; then
- # Set up default GNU C++ configuration
-
-
-# Check whether --with-gnu-ld or --without-gnu-ld was given.
-if test "${with_gnu_ld+set}" = set; then
- withval="$with_gnu_ld"
- test "$withval" = no || with_gnu_ld=yes
-else
- with_gnu_ld=no
-fi;
-ac_prog=ld
-if test "$GCC" = yes; then
- # Check if gcc -print-prog-name=ld gives a path.
- echo "$as_me:$LINENO: checking for ld used by $CC" >&5
-echo $ECHO_N "checking for ld used by $CC... $ECHO_C" >&6
- case $host in
- *-*-mingw*)
- # gcc leaves a trailing carriage return which upsets mingw
- ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;;
- *)
- ac_prog=`($CC -print-prog-name=ld) 2>&5` ;;
- esac
- case $ac_prog in
- # Accept absolute paths.
- [\\/]* | ?:[\\/]*)
- re_direlt='/[^/][^/]*/\.\./'
- # Canonicalize the pathname of ld
- ac_prog=`echo $ac_prog| $SED 's%\\\\%/%g'`
- while echo $ac_prog | grep "$re_direlt" > /dev/null 2>&1; do
- ac_prog=`echo $ac_prog| $SED "s%$re_direlt%/%"`
- done
- test -z "$LD" && LD="$ac_prog"
- ;;
- "")
- # If it fails, then pretend we aren't using GCC.
- ac_prog=ld
- ;;
- *)
- # If it is relative, then search for the first ld in PATH.
- with_gnu_ld=unknown
- ;;
- esac
-elif test "$with_gnu_ld" = yes; then
- echo "$as_me:$LINENO: checking for GNU ld" >&5
-echo $ECHO_N "checking for GNU ld... $ECHO_C" >&6
-else
- echo "$as_me:$LINENO: checking for non-GNU ld" >&5
-echo $ECHO_N "checking for non-GNU ld... $ECHO_C" >&6
-fi
-if test "${lt_cv_path_LD+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- if test -z "$LD"; then
- lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
- for ac_dir in $PATH; do
- IFS="$lt_save_ifs"
- test -z "$ac_dir" && ac_dir=.
- if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then
- lt_cv_path_LD="$ac_dir/$ac_prog"
- # Check to see if the program is GNU ld. I'd rather use --version,
- # but apparently some variants of GNU ld only accept -v.
- # Break only if it was the GNU/non-GNU ld that we prefer.
- case `"$lt_cv_path_LD" -v 2>&1 </dev/null` in
- *GNU* | *'with BFD'*)
- test "$with_gnu_ld" != no && break
- ;;
- *)
- test "$with_gnu_ld" != yes && break
- ;;
- esac
- fi
- done
- IFS="$lt_save_ifs"
-else
- lt_cv_path_LD="$LD" # Let the user override the test with a path.
-fi
-fi
-
-LD="$lt_cv_path_LD"
-if test -n "$LD"; then
- echo "$as_me:$LINENO: result: $LD" >&5
-echo "${ECHO_T}$LD" >&6
-else
- echo "$as_me:$LINENO: result: no" >&5
-echo "${ECHO_T}no" >&6
-fi
-test -z "$LD" && { { echo "$as_me:$LINENO: error: no acceptable ld found in \$PATH" >&5
-echo "$as_me: error: no acceptable ld found in \$PATH" >&2;}
- { (exit 1); exit 1; }; }
-echo "$as_me:$LINENO: checking if the linker ($LD) is GNU ld" >&5
-echo $ECHO_N "checking if the linker ($LD) is GNU ld... $ECHO_C" >&6
-if test "${lt_cv_prog_gnu_ld+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- # I'd rather use --version here, but apparently some GNU lds only accept -v.
-case `$LD -v 2>&1 </dev/null` in
-*GNU* | *'with BFD'*)
- lt_cv_prog_gnu_ld=yes
- ;;
-*)
- lt_cv_prog_gnu_ld=no
- ;;
-esac
-fi
-echo "$as_me:$LINENO: result: $lt_cv_prog_gnu_ld" >&5
-echo "${ECHO_T}$lt_cv_prog_gnu_ld" >&6
-with_gnu_ld=$lt_cv_prog_gnu_ld
-
-
-
- # Check if GNU C++ uses GNU ld as the underlying linker, since the
- # archiving commands below assume that GNU ld is being used.
- if test "$with_gnu_ld" = yes; then
- archive_cmds_CXX='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib'
- archive_expsym_cmds_CXX='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
-
- hardcode_libdir_flag_spec_CXX='${wl}--rpath ${wl}$libdir'
- export_dynamic_flag_spec_CXX='${wl}--export-dynamic'
-
- # If archive_cmds runs LD, not CC, wlarc should be empty
- # XXX I think wlarc can be eliminated in ltcf-cxx, but I need to
- # investigate it a little bit more. (MM)
- wlarc='${wl}'
-
- # ancient GNU ld didn't support --whole-archive et. al.
- if eval "`$CC -print-prog-name=ld` --help 2>&1" | \
- grep 'no-whole-archive' > /dev/null; then
- whole_archive_flag_spec_CXX="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive'
- else
- whole_archive_flag_spec_CXX=
- fi
- else
- with_gnu_ld=no
- wlarc=
-
- # A generic and very simple default shared library creation
- # command for GNU C++ for the case where it uses the native
- # linker, instead of GNU ld. If possible, this setting should
- # overridden to take advantage of the native linker features on
- # the platform it is being used on.
- archive_cmds_CXX='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $lib'
- fi
-
- # Commands to make compiler produce verbose output that lists
- # what "hidden" libraries, object files and flags are used when
- # linking a shared library.
- output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep "\-L"'
-
-else
- GXX=no
- with_gnu_ld=no
- wlarc=
-fi
-
-# PORTME: fill in a description of your system's C++ link characteristics
-echo "$as_me:$LINENO: checking whether the $compiler linker ($LD) supports shared libraries" >&5
-echo $ECHO_N "checking whether the $compiler linker ($LD) supports shared libraries... $ECHO_C" >&6
-ld_shlibs_CXX=yes
-case $host_os in
- aix3*)
- # FIXME: insert proper C++ library support
- ld_shlibs_CXX=no
- ;;
- aix4* | aix5*)
- if test "$host_cpu" = ia64; then
- # On IA64, the linker does run time linking by default, so we don't
- # have to do anything special.
- aix_use_runtimelinking=no
- exp_sym_flag='-Bexport'
- no_entry_flag=""
- else
- aix_use_runtimelinking=no
-
- # Test if we are trying to use run time linking or normal
- # AIX style linking. If -brtl is somewhere in LDFLAGS, we
- # need to do runtime linking.
- case $host_os in aix4.[23]|aix4.[23].*|aix5*)
- for ld_flag in $LDFLAGS; do
- case $ld_flag in
- *-brtl*)
- aix_use_runtimelinking=yes
- break
- ;;
- esac
- done
- ;;
- esac
-
- exp_sym_flag='-bexport'
- no_entry_flag='-bnoentry'
- fi
-
- # When large executables or shared objects are built, AIX ld can
- # have problems creating the table of contents. If linking a library
- # or program results in "error TOC overflow" add -mminimal-toc to
- # CXXFLAGS/CFLAGS for g++/gcc. In the cases where that is not
- # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS.
-
- archive_cmds_CXX=''
- hardcode_direct_CXX=yes
- hardcode_libdir_separator_CXX=':'
- link_all_deplibs_CXX=yes
-
- if test "$GXX" = yes; then
- case $host_os in aix4.[012]|aix4.[012].*)
- # We only want to do this on AIX 4.2 and lower, the check
- # below for broken collect2 doesn't work under 4.3+
- collect2name=`${CC} -print-prog-name=collect2`
- if test -f "$collect2name" && \
- strings "$collect2name" | grep resolve_lib_name >/dev/null
- then
- # We have reworked collect2
- hardcode_direct_CXX=yes
- else
- # We have old collect2
- hardcode_direct_CXX=unsupported
- # It fails to find uninstalled libraries when the uninstalled
- # path is not listed in the libpath. Setting hardcode_minus_L
- # to unsupported forces relinking
- hardcode_minus_L_CXX=yes
- hardcode_libdir_flag_spec_CXX='-L$libdir'
- hardcode_libdir_separator_CXX=
- fi
- ;;
- esac
- shared_flag='-shared'
- if test "$aix_use_runtimelinking" = yes; then
- shared_flag="$shared_flag "'${wl}-G'
- fi
- else
- # not using gcc
- if test "$host_cpu" = ia64; then
- # VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release
- # chokes on -Wl,-G. The following line is correct:
- shared_flag='-G'
- else
- if test "$aix_use_runtimelinking" = yes; then
- shared_flag='${wl}-G'
- else
- shared_flag='${wl}-bM:SRE'
- fi
- fi
- fi
-
- # It seems that -bexpall does not export symbols beginning with
- # underscore (_), so it is better to generate a list of symbols to export.
- always_export_symbols_CXX=yes
- if test "$aix_use_runtimelinking" = yes; then
- # Warning - without using the other runtime loading flags (-brtl),
- # -berok will link without error, but may produce a broken library.
- allow_undefined_flag_CXX='-berok'
- # Determine the default libpath from the value encoded in an empty executable.
- cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-
-int
-main ()
-{
-
- ;
- return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
- (eval $ac_link) 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } &&
- { ac_try='test -z "$ac_cxx_werror_flag" || test ! -s conftest.err'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; } &&
- { ac_try='test -s conftest$ac_exeext'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
-
-aix_libpath=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; }
-}'`
-# Check for a 64-bit object if we didn't find anything.
-if test -z "$aix_libpath"; then aix_libpath=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; }
-}'`; fi
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-fi
-rm -f conftest.err conftest.$ac_objext \
- conftest$ac_exeext conftest.$ac_ext
-if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
-
- hardcode_libdir_flag_spec_CXX='${wl}-blibpath:$libdir:'"$aix_libpath"
-
- archive_expsym_cmds_CXX="\$CC"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then echo "${wl}${allow_undefined_flag}"; else :; fi` '"\${wl}$exp_sym_flag:\$export_symbols $shared_flag"
- else
- if test "$host_cpu" = ia64; then
- hardcode_libdir_flag_spec_CXX='${wl}-R $libdir:/usr/lib:/lib'
- allow_undefined_flag_CXX="-z nodefs"
- archive_expsym_cmds_CXX="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$exp_sym_flag:\$export_symbols"
- else
- # Determine the default libpath from the value encoded in an empty executable.
- cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-
-int
-main ()
-{
-
- ;
- return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
- (eval $ac_link) 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } &&
- { ac_try='test -z "$ac_cxx_werror_flag" || test ! -s conftest.err'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; } &&
- { ac_try='test -s conftest$ac_exeext'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
-
-aix_libpath=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; }
-}'`
-# Check for a 64-bit object if we didn't find anything.
-if test -z "$aix_libpath"; then aix_libpath=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; }
-}'`; fi
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-fi
-rm -f conftest.err conftest.$ac_objext \
- conftest$ac_exeext conftest.$ac_ext
-if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
-
- hardcode_libdir_flag_spec_CXX='${wl}-blibpath:$libdir:'"$aix_libpath"
- # Warning - without using the other run time loading flags,
- # -berok will link without error, but may produce a broken library.
- no_undefined_flag_CXX=' ${wl}-bernotok'
- allow_undefined_flag_CXX=' ${wl}-berok'
- # Exported symbols can be pulled into shared objects from archives
- whole_archive_flag_spec_CXX='$convenience'
- archive_cmds_need_lc_CXX=yes
- # This is similar to how AIX traditionally builds its shared libraries.
- archive_expsym_cmds_CXX="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs ${wl}-bnoentry $compiler_flags ${wl}-bE:$export_symbols${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname'
- fi
- fi
- ;;
-
- beos*)
- if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
- allow_undefined_flag_CXX=unsupported
- # Joseph Beckenbach <jrb3@best.com> says some releases of gcc
- # support --undefined. This deserves some investigation. FIXME
- archive_cmds_CXX='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
- else
- ld_shlibs_CXX=no
- fi
- ;;
-
- chorus*)
- case $cc_basename in
- *)
- # FIXME: insert proper C++ library support
- ld_shlibs_CXX=no
- ;;
- esac
- ;;
-
- cygwin* | mingw* | pw32*)
- # _LT_AC_TAGVAR(hardcode_libdir_flag_spec, CXX) is actually meaningless,
- # as there is no search path for DLLs.
- hardcode_libdir_flag_spec_CXX='-L$libdir'
- allow_undefined_flag_CXX=unsupported
- always_export_symbols_CXX=no
- enable_shared_with_static_runtimes_CXX=yes
-
- if $LD --help 2>&1 | grep 'auto-import' > /dev/null; then
- archive_cmds_CXX='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
- # If the export-symbols file already is a .def file (1st line
- # is EXPORTS), use it as is; otherwise, prepend...
- archive_expsym_cmds_CXX='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then
- cp $export_symbols $output_objdir/$soname.def;
- else
- echo EXPORTS > $output_objdir/$soname.def;
- cat $export_symbols >> $output_objdir/$soname.def;
- fi~
- $CC -shared -nostdlib $output_objdir/$soname.def $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
- else
- ld_shlibs_CXX=no
- fi
- ;;
- darwin* | rhapsody*)
- case $host_os in
- rhapsody* | darwin1.[012])
- allow_undefined_flag_CXX='${wl}-undefined ${wl}suppress'
- ;;
- *) # Darwin 1.3 on
- if test -z ${MACOSX_DEPLOYMENT_TARGET} ; then
- allow_undefined_flag_CXX='${wl}-flat_namespace ${wl}-undefined ${wl}suppress'
- else
- case ${MACOSX_DEPLOYMENT_TARGET} in
- 10.[012])
- allow_undefined_flag_CXX='${wl}-flat_namespace ${wl}-undefined ${wl}suppress'
- ;;
- 10.*)
- allow_undefined_flag_CXX='${wl}-undefined ${wl}dynamic_lookup'
- ;;
- esac
- fi
- ;;
- esac
- archive_cmds_need_lc_CXX=no
- hardcode_direct_CXX=no
- hardcode_automatic_CXX=yes
- hardcode_shlibpath_var_CXX=unsupported
- whole_archive_flag_spec_CXX=''
- link_all_deplibs_CXX=yes
-
- if test "$GXX" = yes ; then
- lt_int_apple_cc_single_mod=no
- output_verbose_link_cmd='echo'
- if $CC -dumpspecs 2>&1 | $EGREP 'single_module' >/dev/null ; then
- lt_int_apple_cc_single_mod=yes
- fi
- if test "X$lt_int_apple_cc_single_mod" = Xyes ; then
- archive_cmds_CXX='$CC -dynamiclib -single_module $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring'
- else
- archive_cmds_CXX='$CC -r -keep_private_externs -nostdlib -o ${lib}-master.o $libobjs~$CC -dynamiclib $allow_undefined_flag -o $lib ${lib}-master.o $deplibs $compiler_flags -install_name $rpath/$soname $verstring'
- fi
- module_cmds_CXX='$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags'
- # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin lds
- if test "X$lt_int_apple_cc_single_mod" = Xyes ; then
- archive_expsym_cmds_CXX='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -dynamiclib -single_module $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
- else
- archive_expsym_cmds_CXX='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -r -keep_private_externs -nostdlib -o ${lib}-master.o $libobjs~$CC -dynamiclib $allow_undefined_flag -o $lib ${lib}-master.o $deplibs $compiler_flags -install_name $rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
- fi
- module_expsym_cmds_CXX='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
- else
- case $cc_basename in
- xlc*)
- output_verbose_link_cmd='echo'
- archive_cmds_CXX='$CC -qmkshrobj ${wl}-single_module $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-install_name ${wl}`echo $rpath/$soname` $verstring'
- module_cmds_CXX='$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags'
- # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin lds
- archive_expsym_cmds_CXX='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -qmkshrobj ${wl}-single_module $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-install_name ${wl}$rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
- module_expsym_cmds_CXX='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
- ;;
- *)
- ld_shlibs_CXX=no
- ;;
- esac
- fi
- ;;
-
- dgux*)
- case $cc_basename in
- ec++*)
- # FIXME: insert proper C++ library support
- ld_shlibs_CXX=no
- ;;
- ghcx*)
- # Green Hills C++ Compiler
- # FIXME: insert proper C++ library support
- ld_shlibs_CXX=no
- ;;
- *)
- # FIXME: insert proper C++ library support
- ld_shlibs_CXX=no
- ;;
- esac
- ;;
- freebsd[12]*)
- # C++ shared libraries reported to be fairly broken before switch to ELF
- ld_shlibs_CXX=no
- ;;
- freebsd-elf*)
- archive_cmds_need_lc_CXX=no
- ;;
- freebsd* | kfreebsd*-gnu | dragonfly*)
- # FreeBSD 3 and later use GNU C++ and GNU ld with standard ELF
- # conventions
- ld_shlibs_CXX=yes
- ;;
- gnu*)
- ;;
- hpux9*)
- hardcode_libdir_flag_spec_CXX='${wl}+b ${wl}$libdir'
- hardcode_libdir_separator_CXX=:
- export_dynamic_flag_spec_CXX='${wl}-E'
- hardcode_direct_CXX=yes
- hardcode_minus_L_CXX=yes # Not in the search PATH,
- # but as the default
- # location of the library.
-
- case $cc_basename in
- CC*)
- # FIXME: insert proper C++ library support
- ld_shlibs_CXX=no
- ;;
- aCC*)
- archive_cmds_CXX='$rm $output_objdir/$soname~$CC -b ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
- # Commands to make compiler produce verbose output that lists
- # what "hidden" libraries, object files and flags are used when
- # linking a shared library.
- #
- # There doesn't appear to be a way to prevent this compiler from
- # explicitly linking system object files so we need to strip them
- # from the output so that they don't get included in the library
- # dependencies.
- output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | grep "[-]L"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; echo $list'
- ;;
- *)
- if test "$GXX" = yes; then
- archive_cmds_CXX='$rm $output_objdir/$soname~$CC -shared -nostdlib -fPIC ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
- else
- # FIXME: insert proper C++ library support
- ld_shlibs_CXX=no
- fi
- ;;
- esac
- ;;
- hpux10*|hpux11*)
- if test $with_gnu_ld = no; then
- hardcode_libdir_flag_spec_CXX='${wl}+b ${wl}$libdir'
- hardcode_libdir_separator_CXX=:
-
- case $host_cpu in
- hppa*64*|ia64*)
- hardcode_libdir_flag_spec_ld_CXX='+b $libdir'
- ;;
- *)
- export_dynamic_flag_spec_CXX='${wl}-E'
- ;;
- esac
- fi
- case $host_cpu in
- hppa*64*|ia64*)
- hardcode_direct_CXX=no
- hardcode_shlibpath_var_CXX=no
- ;;
- *)
- hardcode_direct_CXX=yes
- hardcode_minus_L_CXX=yes # Not in the search PATH,
- # but as the default
- # location of the library.
- ;;
- esac
-
- case $cc_basename in
- CC*)
- # FIXME: insert proper C++ library support
- ld_shlibs_CXX=no
- ;;
- aCC*)
- case $host_cpu in
- hppa*64*)
- archive_cmds_CXX='$CC -b ${wl}+h ${wl}$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
- ;;
- ia64*)
- archive_cmds_CXX='$CC -b ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
- ;;
- *)
- archive_cmds_CXX='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
- ;;
- esac
- # Commands to make compiler produce verbose output that lists
- # what "hidden" libraries, object files and flags are used when
- # linking a shared library.
- #
- # There doesn't appear to be a way to prevent this compiler from
- # explicitly linking system object files so we need to strip them
- # from the output so that they don't get included in the library
- # dependencies.
- output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | grep "\-L"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; echo $list'
- ;;
- *)
- if test "$GXX" = yes; then
- if test $with_gnu_ld = no; then
- case $host_cpu in
- hppa*64*)
- archive_cmds_CXX='$CC -shared -nostdlib -fPIC ${wl}+h ${wl}$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
- ;;
- ia64*)
- archive_cmds_CXX='$CC -shared -nostdlib -fPIC ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
- ;;
- *)
- archive_cmds_CXX='$CC -shared -nostdlib -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
- ;;
- esac
- fi
- else
- # FIXME: insert proper C++ library support
- ld_shlibs_CXX=no
- fi
- ;;
- esac
- ;;
- interix3*)
- hardcode_direct_CXX=no
- hardcode_shlibpath_var_CXX=no
- hardcode_libdir_flag_spec_CXX='${wl}-rpath,$libdir'
- export_dynamic_flag_spec_CXX='${wl}-E'
- # Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc.
- # Instead, shared libraries are loaded at an image base (0x10000000 by
- # default) and relocated if they conflict, which is a slow very memory
- # consuming and fragmenting process. To avoid this, we pick a random,
- # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link
- # time. Moving up from 0x10000000 also allows more sbrk(2) space.
- archive_cmds_CXX='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
- archive_expsym_cmds_CXX='sed "s,^,_," $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--retain-symbols-file,$output_objdir/$soname.expsym ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
- ;;
- irix5* | irix6*)
- case $cc_basename in
- CC*)
- # SGI C++
- archive_cmds_CXX='$CC -shared -all -multigot $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib'
-
- # Archives containing C++ object files must be created using
- # "CC -ar", where "CC" is the IRIX C++ compiler. This is
- # necessary to make sure instantiated templates are included
- # in the archive.
- old_archive_cmds_CXX='$CC -ar -WR,-u -o $oldlib $oldobjs'
- ;;
- *)
- if test "$GXX" = yes; then
- if test "$with_gnu_ld" = no; then
- archive_cmds_CXX='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
- else
- archive_cmds_CXX='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` -o $lib'
- fi
- fi
- link_all_deplibs_CXX=yes
- ;;
- esac
- hardcode_libdir_flag_spec_CXX='${wl}-rpath ${wl}$libdir'
- hardcode_libdir_separator_CXX=:
- ;;
- linux*)
- case $cc_basename in
- KCC*)
- # Kuck and Associates, Inc. (KAI) C++ Compiler
-
- # KCC will only create a shared library if the output file
- # ends with ".so" (or ".sl" for HP-UX), so rename the library
- # to its proper name (with version) after linking.
- archive_cmds_CXX='tempext=`echo $shared_ext | $SED -e '\''s/\([^()0-9A-Za-z{}]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib'
- archive_expsym_cmds_CXX='tempext=`echo $shared_ext | $SED -e '\''s/\([^()0-9A-Za-z{}]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib ${wl}-retain-symbols-file,$export_symbols; mv \$templib $lib'
- # Commands to make compiler produce verbose output that lists
- # what "hidden" libraries, object files and flags are used when
- # linking a shared library.
- #
- # There doesn't appear to be a way to prevent this compiler from
- # explicitly linking system object files so we need to strip them
- # from the output so that they don't get included in the library
- # dependencies.
- output_verbose_link_cmd='templist=`$CC $CFLAGS -v conftest.$objext -o libconftest$shared_ext 2>&1 | grep "ld"`; rm -f libconftest$shared_ext; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; echo $list'
-
- hardcode_libdir_flag_spec_CXX='${wl}--rpath,$libdir'
- export_dynamic_flag_spec_CXX='${wl}--export-dynamic'
-
- # Archives containing C++ object files must be created using
- # "CC -Bstatic", where "CC" is the KAI C++ compiler.
- old_archive_cmds_CXX='$CC -Bstatic -o $oldlib $oldobjs'
- ;;
- icpc*)
- # Intel C++
- with_gnu_ld=yes
- # version 8.0 and above of icpc choke on multiply defined symbols
- # if we add $predep_objects and $postdep_objects, however 7.1 and
- # earlier do not add the objects themselves.
- case `$CC -V 2>&1` in
- *"Version 7."*)
- archive_cmds_CXX='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib'
- archive_expsym_cmds_CXX='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
- ;;
- *) # Version 8.0 or newer
- tmp_idyn=
- case $host_cpu in
- ia64*) tmp_idyn=' -i_dynamic';;
- esac
- archive_cmds_CXX='$CC -shared'"$tmp_idyn"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
- archive_expsym_cmds_CXX='$CC -shared'"$tmp_idyn"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
- ;;
- esac
- archive_cmds_need_lc_CXX=no
- hardcode_libdir_flag_spec_CXX='${wl}-rpath,$libdir'
- export_dynamic_flag_spec_CXX='${wl}--export-dynamic'
- whole_archive_flag_spec_CXX='${wl}--whole-archive$convenience ${wl}--no-whole-archive'
- ;;
- pgCC*)
- # Portland Group C++ compiler
- archive_cmds_CXX='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname -o $lib'
- archive_expsym_cmds_CXX='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname ${wl}-retain-symbols-file ${wl}$export_symbols -o $lib'
-
- hardcode_libdir_flag_spec_CXX='${wl}--rpath ${wl}$libdir'
- export_dynamic_flag_spec_CXX='${wl}--export-dynamic'
- whole_archive_flag_spec_CXX='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}--no-whole-archive'
- ;;
- cxx*)
- # Compaq C++
- archive_cmds_CXX='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib'
- archive_expsym_cmds_CXX='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib ${wl}-retain-symbols-file $wl$export_symbols'
-
- runpath_var=LD_RUN_PATH
- hardcode_libdir_flag_spec_CXX='-rpath $libdir'
- hardcode_libdir_separator_CXX=:
-
- # Commands to make compiler produce verbose output that lists
- # what "hidden" libraries, object files and flags are used when
- # linking a shared library.
- #
- # There doesn't appear to be a way to prevent this compiler from
- # explicitly linking system object files so we need to strip them
- # from the output so that they don't get included in the library
- # dependencies.
- output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep "ld"`; templist=`echo $templist | $SED "s/\(^.*ld.*\)\( .*ld .*$\)/\1/"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; echo $list'
- ;;
- esac
- ;;
- lynxos*)
- # FIXME: insert proper C++ library support
- ld_shlibs_CXX=no
- ;;
- m88k*)
- # FIXME: insert proper C++ library support
- ld_shlibs_CXX=no
- ;;
- mvs*)
- case $cc_basename in
- cxx*)
- # FIXME: insert proper C++ library support
- ld_shlibs_CXX=no
- ;;
- *)
- # FIXME: insert proper C++ library support
- ld_shlibs_CXX=no
- ;;
- esac
- ;;
- netbsd* | netbsdelf*-gnu | knetbsd*-gnu)
- if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then
- archive_cmds_CXX='$LD -Bshareable -o $lib $predep_objects $libobjs $deplibs $postdep_objects $linker_flags'
- wlarc=
- hardcode_libdir_flag_spec_CXX='-R$libdir'
- hardcode_direct_CXX=yes
- hardcode_shlibpath_var_CXX=no
- fi
- # Workaround some broken pre-1.5 toolchains
- output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep conftest.$objext | $SED -e "s:-lgcc -lc -lgcc::"'
- ;;
- openbsd2*)
- # C++ shared libraries are fairly broken
- ld_shlibs_CXX=no
- ;;
- openbsd*)
- hardcode_direct_CXX=yes
- hardcode_shlibpath_var_CXX=no
- archive_cmds_CXX='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $lib'
- hardcode_libdir_flag_spec_CXX='${wl}-rpath,$libdir'
- if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
- archive_expsym_cmds_CXX='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-retain-symbols-file,$export_symbols -o $lib'
- export_dynamic_flag_spec_CXX='${wl}-E'
- whole_archive_flag_spec_CXX="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive'
- fi
- output_verbose_link_cmd='echo'
- ;;
- osf3*)
- case $cc_basename in
- KCC*)
- # Kuck and Associates, Inc. (KAI) C++ Compiler
-
- # KCC will only create a shared library if the output file
- # ends with ".so" (or ".sl" for HP-UX), so rename the library
- # to its proper name (with version) after linking.
- archive_cmds_CXX='tempext=`echo $shared_ext | $SED -e '\''s/\([^()0-9A-Za-z{}]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib'
-
- hardcode_libdir_flag_spec_CXX='${wl}-rpath,$libdir'
- hardcode_libdir_separator_CXX=:
-
- # Archives containing C++ object files must be created using
- # "CC -Bstatic", where "CC" is the KAI C++ compiler.
- old_archive_cmds_CXX='$CC -Bstatic -o $oldlib $oldobjs'
-
- ;;
- RCC*)
- # Rational C++ 2.4.1
- # FIXME: insert proper C++ library support
- ld_shlibs_CXX=no
- ;;
- cxx*)
- allow_undefined_flag_CXX=' ${wl}-expect_unresolved ${wl}\*'
- archive_cmds_CXX='$CC -shared${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $soname `test -n "$verstring" && echo ${wl}-set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib'
-
- hardcode_libdir_flag_spec_CXX='${wl}-rpath ${wl}$libdir'
- hardcode_libdir_separator_CXX=:
-
- # Commands to make compiler produce verbose output that lists
- # what "hidden" libraries, object files and flags are used when
- # linking a shared library.
- #
- # There doesn't appear to be a way to prevent this compiler from
- # explicitly linking system object files so we need to strip them
- # from the output so that they don't get included in the library
- # dependencies.
- output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep "ld" | grep -v "ld:"`; templist=`echo $templist | $SED "s/\(^.*ld.*\)\( .*ld.*$\)/\1/"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; echo $list'
- ;;
- *)
- if test "$GXX" = yes && test "$with_gnu_ld" = no; then
- allow_undefined_flag_CXX=' ${wl}-expect_unresolved ${wl}\*'
- archive_cmds_CXX='$CC -shared -nostdlib ${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
-
- hardcode_libdir_flag_spec_CXX='${wl}-rpath ${wl}$libdir'
- hardcode_libdir_separator_CXX=:
-
- # Commands to make compiler produce verbose output that lists
- # what "hidden" libraries, object files and flags are used when
- # linking a shared library.
- output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep "\-L"'
-
- else
- # FIXME: insert proper C++ library support
- ld_shlibs_CXX=no
- fi
- ;;
- esac
- ;;
- osf4* | osf5*)
- case $cc_basename in
- KCC*)
- # Kuck and Associates, Inc. (KAI) C++ Compiler
-
- # KCC will only create a shared library if the output file
- # ends with ".so" (or ".sl" for HP-UX), so rename the library
- # to its proper name (with version) after linking.
- archive_cmds_CXX='tempext=`echo $shared_ext | $SED -e '\''s/\([^()0-9A-Za-z{}]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib'
-
- hardcode_libdir_flag_spec_CXX='${wl}-rpath,$libdir'
- hardcode_libdir_separator_CXX=:
-
- # Archives containing C++ object files must be created using
- # the KAI C++ compiler.
- old_archive_cmds_CXX='$CC -o $oldlib $oldobjs'
- ;;
- RCC*)
- # Rational C++ 2.4.1
- # FIXME: insert proper C++ library support
- ld_shlibs_CXX=no
- ;;
- cxx*)
- allow_undefined_flag_CXX=' -expect_unresolved \*'
- archive_cmds_CXX='$CC -shared${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib'
- archive_expsym_cmds_CXX='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done~
- echo "-hidden">> $lib.exp~
- $CC -shared$allow_undefined_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname -Wl,-input -Wl,$lib.exp `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib~
- $rm $lib.exp'
-
- hardcode_libdir_flag_spec_CXX='-rpath $libdir'
- hardcode_libdir_separator_CXX=:
-
- # Commands to make compiler produce verbose output that lists
- # what "hidden" libraries, object files and flags are used when
- # linking a shared library.
- #
- # There doesn't appear to be a way to prevent this compiler from
- # explicitly linking system object files so we need to strip them
- # from the output so that they don't get included in the library
- # dependencies.
- output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep "ld" | grep -v "ld:"`; templist=`echo $templist | $SED "s/\(^.*ld.*\)\( .*ld.*$\)/\1/"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; echo $list'
- ;;
- *)
- if test "$GXX" = yes && test "$with_gnu_ld" = no; then
- allow_undefined_flag_CXX=' ${wl}-expect_unresolved ${wl}\*'
- archive_cmds_CXX='$CC -shared -nostdlib ${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
-
- hardcode_libdir_flag_spec_CXX='${wl}-rpath ${wl}$libdir'
- hardcode_libdir_separator_CXX=:
-
- # Commands to make compiler produce verbose output that lists
- # what "hidden" libraries, object files and flags are used when
- # linking a shared library.
- output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep "\-L"'
-
- else
- # FIXME: insert proper C++ library support
- ld_shlibs_CXX=no
- fi
- ;;
- esac
- ;;
- psos*)
- # FIXME: insert proper C++ library support
- ld_shlibs_CXX=no
- ;;
- sunos4*)
- case $cc_basename in
- CC*)
- # Sun C++ 4.x
- # FIXME: insert proper C++ library support
- ld_shlibs_CXX=no
- ;;
- lcc*)
- # Lucid
- # FIXME: insert proper C++ library support
- ld_shlibs_CXX=no
- ;;
- *)
- # FIXME: insert proper C++ library support
- ld_shlibs_CXX=no
- ;;
- esac
- ;;
- solaris*)
- case $cc_basename in
- CC*)
- # Sun C++ 4.2, 5.x and Centerline C++
- archive_cmds_need_lc_CXX=yes
- no_undefined_flag_CXX=' -zdefs'
- archive_cmds_CXX='$CC -G${allow_undefined_flag} -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
- archive_expsym_cmds_CXX='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~
- $CC -G${allow_undefined_flag} ${wl}-M ${wl}$lib.exp -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$rm $lib.exp'
-
- hardcode_libdir_flag_spec_CXX='-R$libdir'
- hardcode_shlibpath_var_CXX=no
- case $host_os in
- solaris2.[0-5] | solaris2.[0-5].*) ;;
- *)
- # The C++ compiler is used as linker so we must use $wl
- # flag to pass the commands to the underlying system
- # linker. We must also pass each convience library through
- # to the system linker between allextract/defaultextract.
- # The C++ compiler will combine linker options so we
- # cannot just pass the convience library names through
- # without $wl.
- # Supported since Solaris 2.6 (maybe 2.5.1?)
- whole_archive_flag_spec_CXX='${wl}-z ${wl}allextract`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}-z ${wl}defaultextract'
- ;;
- esac
- link_all_deplibs_CXX=yes
-
- output_verbose_link_cmd='echo'
-
- # Archives containing C++ object files must be created using
- # "CC -xar", where "CC" is the Sun C++ compiler. This is
- # necessary to make sure instantiated templates are included
- # in the archive.
- old_archive_cmds_CXX='$CC -xar -o $oldlib $oldobjs'
- ;;
- gcx*)
- # Green Hills C++ Compiler
- archive_cmds_CXX='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib'
-
- # The C++ compiler must be used to create the archive.
- old_archive_cmds_CXX='$CC $LDFLAGS -archive -o $oldlib $oldobjs'
- ;;
- *)
- # GNU C++ compiler with Solaris linker
- if test "$GXX" = yes && test "$with_gnu_ld" = no; then
- no_undefined_flag_CXX=' ${wl}-z ${wl}defs'
- if $CC --version | grep -v '^2\.7' > /dev/null; then
- archive_cmds_CXX='$CC -shared -nostdlib $LDFLAGS $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib'
- archive_expsym_cmds_CXX='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~
- $CC -shared -nostdlib ${wl}-M $wl$lib.exp -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$rm $lib.exp'
-
- # Commands to make compiler produce verbose output that lists
- # what "hidden" libraries, object files and flags are used when
- # linking a shared library.
- output_verbose_link_cmd="$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep \"\-L\""
- else
- # g++ 2.7 appears to require `-G' NOT `-shared' on this
- # platform.
- archive_cmds_CXX='$CC -G -nostdlib $LDFLAGS $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib'
- archive_expsym_cmds_CXX='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~
- $CC -G -nostdlib ${wl}-M $wl$lib.exp -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$rm $lib.exp'
-
- # Commands to make compiler produce verbose output that lists
- # what "hidden" libraries, object files and flags are used when
- # linking a shared library.
- output_verbose_link_cmd="$CC -G $CFLAGS -v conftest.$objext 2>&1 | grep \"\-L\""
- fi
-
- hardcode_libdir_flag_spec_CXX='${wl}-R $wl$libdir'
- fi
- ;;
- esac
- ;;
- sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[01].[10]* | unixware7* | sco3.2v5.0.[024]*)
- no_undefined_flag_CXX='${wl}-z,text'
- archive_cmds_need_lc_CXX=no
- hardcode_shlibpath_var_CXX=no
- runpath_var='LD_RUN_PATH'
-
- case $cc_basename in
- CC*)
- archive_cmds_CXX='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
- archive_expsym_cmds_CXX='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
- ;;
- *)
- archive_cmds_CXX='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
- archive_expsym_cmds_CXX='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
- ;;
- esac
- ;;
- sysv5* | sco3.2v5* | sco5v6*)
- # Note: We can NOT use -z defs as we might desire, because we do not
- # link with -lc, and that would cause any symbols used from libc to
- # always be unresolved, which means just about no library would
- # ever link correctly. If we're not using GNU ld we use -z text
- # though, which does catch some bad symbols but isn't as heavy-handed
- # as -z defs.
- # For security reasons, it is highly recommended that you always
- # use absolute paths for naming shared libraries, and exclude the
- # DT_RUNPATH tag from executables and libraries. But doing so
- # requires that you compile everything twice, which is a pain.
- # So that behaviour is only enabled if SCOABSPATH is set to a
- # non-empty value in the environment. Most likely only useful for
- # creating official distributions of packages.
- # This is a hack until libtool officially supports absolute path
- # names for shared libraries.
- no_undefined_flag_CXX='${wl}-z,text'
- allow_undefined_flag_CXX='${wl}-z,nodefs'
- archive_cmds_need_lc_CXX=no
- hardcode_shlibpath_var_CXX=no
- hardcode_libdir_flag_spec_CXX='`test -z "$SCOABSPATH" && echo ${wl}-R,$libdir`'
- hardcode_libdir_separator_CXX=':'
- link_all_deplibs_CXX=yes
- export_dynamic_flag_spec_CXX='${wl}-Bexport'
- runpath_var='LD_RUN_PATH'
-
- case $cc_basename in
- CC*)
- archive_cmds_CXX='$CC -G ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags'
- archive_expsym_cmds_CXX='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags'
- ;;
- *)
- archive_cmds_CXX='$CC -shared ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags'
- archive_expsym_cmds_CXX='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags'
- ;;
- esac
- ;;
- tandem*)
- case $cc_basename in
- NCC*)
- # NonStop-UX NCC 3.20
- # FIXME: insert proper C++ library support
- ld_shlibs_CXX=no
- ;;
- *)
- # FIXME: insert proper C++ library support
- ld_shlibs_CXX=no
- ;;
- esac
- ;;
- vxworks*)
- # FIXME: insert proper C++ library support
- ld_shlibs_CXX=no
- ;;
- *)
- # FIXME: insert proper C++ library support
- ld_shlibs_CXX=no
- ;;
-esac
-echo "$as_me:$LINENO: result: $ld_shlibs_CXX" >&5
-echo "${ECHO_T}$ld_shlibs_CXX" >&6
-test "$ld_shlibs_CXX" = no && can_build_shared=no
-
-GCC_CXX="$GXX"
-LD_CXX="$LD"
-
-
-cat > conftest.$ac_ext <<EOF
-class Foo
-{
-public:
- Foo (void) { a = 0; }
-private:
- int a;
-};
-EOF
-
-if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
- (eval $ac_compile) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; then
- # Parse the compiler output and extract the necessary
- # objects, libraries and library flags.
-
- # Sentinel used to keep track of whether or not we are before
- # the conftest object file.
- pre_test_object_deps_done=no
-
- # The `*' in the case matches for architectures that use `case' in
- # $output_verbose_cmd can trigger glob expansion during the loop
- # eval without this substitution.
- output_verbose_link_cmd=`$echo "X$output_verbose_link_cmd" | $Xsed -e "$no_glob_subst"`
-
- for p in `eval $output_verbose_link_cmd`; do
- case $p in
-
- -L* | -R* | -l*)
- # Some compilers place space between "-{L,R}" and the path.
- # Remove the space.
- if test $p = "-L" \
- || test $p = "-R"; then
- prev=$p
- continue
- else
- prev=
- fi
-
- if test "$pre_test_object_deps_done" = no; then
- case $p in
- -L* | -R*)
- # Internal compiler library paths should come after those
- # provided the user. The postdeps already come after the
- # user supplied libs so there is no need to process them.
- if test -z "$compiler_lib_search_path_CXX"; then
- compiler_lib_search_path_CXX="${prev}${p}"
- else
- compiler_lib_search_path_CXX="${compiler_lib_search_path_CXX} ${prev}${p}"
- fi
- ;;
- # The "-l" case would never come before the object being
- # linked, so don't bother handling this case.
- esac
- else
- if test -z "$postdeps_CXX"; then
- postdeps_CXX="${prev}${p}"
- else
- postdeps_CXX="${postdeps_CXX} ${prev}${p}"
- fi
- fi
- ;;
-
- *.$objext)
- # This assumes that the test object file only shows up
- # once in the compiler output.
- if test "$p" = "conftest.$objext"; then
- pre_test_object_deps_done=yes
- continue
- fi
-
- if test "$pre_test_object_deps_done" = no; then
- if test -z "$predep_objects_CXX"; then
- predep_objects_CXX="$p"
- else
- predep_objects_CXX="$predep_objects_CXX $p"
- fi
- else
- if test -z "$postdep_objects_CXX"; then
- postdep_objects_CXX="$p"
- else
- postdep_objects_CXX="$postdep_objects_CXX $p"
- fi
- fi
- ;;
-
- *) ;; # Ignore the rest.
-
- esac
- done
-
- # Clean up.
- rm -f a.out a.exe
-else
- echo "libtool.m4: error: problem compiling CXX test program"
-fi
-
-$rm -f confest.$objext
-
-# PORTME: override above test on systems where it is broken
-case $host_os in
-interix3*)
- # Interix 3.5 installs completely hosed .la files for C++, so rather than
- # hack all around it, let's just trust "g++" to DTRT.
- predep_objects_CXX=
- postdep_objects_CXX=
- postdeps_CXX=
- ;;
-
-solaris*)
- case $cc_basename in
- CC*)
- # Adding this requires a known-good setup of shared libraries for
- # Sun compiler versions before 5.6, else PIC objects from an old
- # archive will be linked into the output, leading to subtle bugs.
- postdeps_CXX='-lCstd -lCrun'
- ;;
- esac
- ;;
-esac
-
-
-case " $postdeps_CXX " in
-*" -lc "*) archive_cmds_need_lc_CXX=no ;;
-esac
-
-lt_prog_compiler_wl_CXX=
-lt_prog_compiler_pic_CXX=
-lt_prog_compiler_static_CXX=
-
-echo "$as_me:$LINENO: checking for $compiler option to produce PIC" >&5
-echo $ECHO_N "checking for $compiler option to produce PIC... $ECHO_C" >&6
-
- # C++ specific cases for pic, static, wl, etc.
- if test "$GXX" = yes; then
- lt_prog_compiler_wl_CXX='-Wl,'
- lt_prog_compiler_static_CXX='-static'
-
- case $host_os in
- aix*)
- # All AIX code is PIC.
- if test "$host_cpu" = ia64; then
- # AIX 5 now supports IA64 processor
- lt_prog_compiler_static_CXX='-Bstatic'
- fi
- ;;
- amigaos*)
- # FIXME: we need at least 68020 code to build shared libraries, but
- # adding the `-m68020' flag to GCC prevents building anything better,
- # like `-m68040'.
- lt_prog_compiler_pic_CXX='-m68020 -resident32 -malways-restore-a4'
- ;;
- beos* | cygwin* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*)
- # PIC is the default for these OSes.
- ;;
- mingw* | os2* | pw32*)
- # This hack is so that the source file can tell whether it is being
- # built for inclusion in a dll (and should export symbols for example).
- lt_prog_compiler_pic_CXX='-DDLL_EXPORT'
- ;;
- darwin* | rhapsody*)
- # PIC is the default on this platform
- # Common symbols not allowed in MH_DYLIB files
- lt_prog_compiler_pic_CXX='-fno-common'
- ;;
- *djgpp*)
- # DJGPP does not support shared libraries at all
- lt_prog_compiler_pic_CXX=
- ;;
- interix3*)
- # Interix 3.x gcc -fpic/-fPIC options generate broken code.
- # Instead, we relocate shared libraries at runtime.
- ;;
- sysv4*MP*)
- if test -d /usr/nec; then
- lt_prog_compiler_pic_CXX=-Kconform_pic
- fi
- ;;
- hpux*)
- # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but
- # not for PA HP-UX.
- case $host_cpu in
- hppa*64*|ia64*)
- ;;
- *)
- lt_prog_compiler_pic_CXX='-fPIC'
- ;;
- esac
- ;;
- *)
- lt_prog_compiler_pic_CXX='-fPIC'
- ;;
- esac
- else
- case $host_os in
- aix4* | aix5*)
- # All AIX code is PIC.
- if test "$host_cpu" = ia64; then
- # AIX 5 now supports IA64 processor
- lt_prog_compiler_static_CXX='-Bstatic'
- else
- lt_prog_compiler_static_CXX='-bnso -bI:/lib/syscalls.exp'
- fi
- ;;
- chorus*)
- case $cc_basename in
- cxch68*)
- # Green Hills C++ Compiler
- # _LT_AC_TAGVAR(lt_prog_compiler_static, CXX)="--no_auto_instantiation -u __main -u __premain -u _abort -r $COOL_DIR/lib/libOrb.a $MVME_DIR/lib/CC/libC.a $MVME_DIR/lib/classix/libcx.s.a"
- ;;
- esac
- ;;
- darwin*)
- # PIC is the default on this platform
- # Common symbols not allowed in MH_DYLIB files
- case $cc_basename in
- xlc*)
- lt_prog_compiler_pic_CXX='-qnocommon'
- lt_prog_compiler_wl_CXX='-Wl,'
- ;;
- esac
- ;;
- dgux*)
- case $cc_basename in
- ec++*)
- lt_prog_compiler_pic_CXX='-KPIC'
- ;;
- ghcx*)
- # Green Hills C++ Compiler
- lt_prog_compiler_pic_CXX='-pic'
- ;;
- *)
- ;;
- esac
- ;;
- freebsd* | kfreebsd*-gnu | dragonfly*)
- # FreeBSD uses GNU C++
- ;;
- hpux9* | hpux10* | hpux11*)
- case $cc_basename in
- CC*)
- lt_prog_compiler_wl_CXX='-Wl,'
- lt_prog_compiler_static_CXX='${wl}-a ${wl}archive'
- if test "$host_cpu" != ia64; then
- lt_prog_compiler_pic_CXX='+Z'
- fi
- ;;
- aCC*)
- lt_prog_compiler_wl_CXX='-Wl,'
- lt_prog_compiler_static_CXX='${wl}-a ${wl}archive'
- case $host_cpu in
- hppa*64*|ia64*)
- # +Z the default
- ;;
- *)
- lt_prog_compiler_pic_CXX='+Z'
- ;;
- esac
- ;;
- *)
- ;;
- esac
- ;;
- interix*)
- # This is c89, which is MS Visual C++ (no shared libs)
- # Anyone wants to do a port?
- ;;
- irix5* | irix6* | nonstopux*)
- case $cc_basename in
- CC*)
- lt_prog_compiler_wl_CXX='-Wl,'
- lt_prog_compiler_static_CXX='-non_shared'
- # CC pic flag -KPIC is the default.
- ;;
- *)
- ;;
- esac
- ;;
- linux*)
- case $cc_basename in
- KCC*)
- # KAI C++ Compiler
- lt_prog_compiler_wl_CXX='--backend -Wl,'
- lt_prog_compiler_pic_CXX='-fPIC'
- ;;
- icpc* | ecpc*)
- # Intel C++
- lt_prog_compiler_wl_CXX='-Wl,'
- lt_prog_compiler_pic_CXX='-KPIC'
- lt_prog_compiler_static_CXX='-static'
- ;;
- pgCC*)
- # Portland Group C++ compiler.
- lt_prog_compiler_wl_CXX='-Wl,'
- lt_prog_compiler_pic_CXX='-fpic'
- lt_prog_compiler_static_CXX='-Bstatic'
- ;;
- cxx*)
- # Compaq C++
- # Make sure the PIC flag is empty. It appears that all Alpha
- # Linux and Compaq Tru64 Unix objects are PIC.
- lt_prog_compiler_pic_CXX=
- lt_prog_compiler_static_CXX='-non_shared'
- ;;
- *)
- ;;
- esac
- ;;
- lynxos*)
- ;;
- m88k*)
- ;;
- mvs*)
- case $cc_basename in
- cxx*)
- lt_prog_compiler_pic_CXX='-W c,exportall'
- ;;
- *)
- ;;
- esac
- ;;
- netbsd* | netbsdelf*-gnu | knetbsd*-gnu)
- ;;
- osf3* | osf4* | osf5*)
- case $cc_basename in
- KCC*)
- lt_prog_compiler_wl_CXX='--backend -Wl,'
- ;;
- RCC*)
- # Rational C++ 2.4.1
- lt_prog_compiler_pic_CXX='-pic'
- ;;
- cxx*)
- # Digital/Compaq C++
- lt_prog_compiler_wl_CXX='-Wl,'
- # Make sure the PIC flag is empty. It appears that all Alpha
- # Linux and Compaq Tru64 Unix objects are PIC.
- lt_prog_compiler_pic_CXX=
- lt_prog_compiler_static_CXX='-non_shared'
- ;;
- *)
- ;;
- esac
- ;;
- psos*)
- ;;
- solaris*)
- case $cc_basename in
- CC*)
- # Sun C++ 4.2, 5.x and Centerline C++
- lt_prog_compiler_pic_CXX='-KPIC'
- lt_prog_compiler_static_CXX='-Bstatic'
- lt_prog_compiler_wl_CXX='-Qoption ld '
- ;;
- gcx*)
- # Green Hills C++ Compiler
- lt_prog_compiler_pic_CXX='-PIC'
- ;;
- *)
- ;;
- esac
- ;;
- sunos4*)
- case $cc_basename in
- CC*)
- # Sun C++ 4.x
- lt_prog_compiler_pic_CXX='-pic'
- lt_prog_compiler_static_CXX='-Bstatic'
- ;;
- lcc*)
- # Lucid
- lt_prog_compiler_pic_CXX='-pic'
- ;;
- *)
- ;;
- esac
- ;;
- tandem*)
- case $cc_basename in
- NCC*)
- # NonStop-UX NCC 3.20
- lt_prog_compiler_pic_CXX='-KPIC'
- ;;
- *)
- ;;
- esac
- ;;
- sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*)
- case $cc_basename in
- CC*)
- lt_prog_compiler_wl_CXX='-Wl,'
- lt_prog_compiler_pic_CXX='-KPIC'
- lt_prog_compiler_static_CXX='-Bstatic'
- ;;
- esac
- ;;
- vxworks*)
- ;;
- *)
- lt_prog_compiler_can_build_shared_CXX=no
- ;;
- esac
- fi
-
-echo "$as_me:$LINENO: result: $lt_prog_compiler_pic_CXX" >&5
-echo "${ECHO_T}$lt_prog_compiler_pic_CXX" >&6
-
-#
-# Check to make sure the PIC flag actually works.
-#
-if test -n "$lt_prog_compiler_pic_CXX"; then
-
-echo "$as_me:$LINENO: checking if $compiler PIC flag $lt_prog_compiler_pic_CXX works" >&5
-echo $ECHO_N "checking if $compiler PIC flag $lt_prog_compiler_pic_CXX works... $ECHO_C" >&6
-if test "${lt_prog_compiler_pic_works_CXX+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- lt_prog_compiler_pic_works_CXX=no
- ac_outfile=conftest.$ac_objext
- printf "$lt_simple_compile_test_code" > conftest.$ac_ext
- lt_compiler_flag="$lt_prog_compiler_pic_CXX -DPIC"
- # Insert the option either (1) after the last *FLAGS variable, or
- # (2) before a word containing "conftest.", or (3) at the end.
- # Note that $ac_compile itself does not contain backslashes and begins
- # with a dollar sign (not a hyphen), so the echo should work correctly.
- # The option is referenced via a variable to avoid confusing sed.
- lt_compile=`echo "$ac_compile" | $SED \
- -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
- -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
- -e 's:$: $lt_compiler_flag:'`
- (eval echo "\"\$as_me:11493: $lt_compile\"" >&5)
- (eval "$lt_compile" 2>conftest.err)
- ac_status=$?
- cat conftest.err >&5
- echo "$as_me:11497: \$? = $ac_status" >&5
- if (exit $ac_status) && test -s "$ac_outfile"; then
- # The compiler can only warn and ignore the option if not recognized
- # So say no if there are warnings other than the usual output.
- $echo "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' >conftest.exp
- $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2
- if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then
- lt_prog_compiler_pic_works_CXX=yes
- fi
- fi
- $rm conftest*
-
-fi
-echo "$as_me:$LINENO: result: $lt_prog_compiler_pic_works_CXX" >&5
-echo "${ECHO_T}$lt_prog_compiler_pic_works_CXX" >&6
-
-if test x"$lt_prog_compiler_pic_works_CXX" = xyes; then
- case $lt_prog_compiler_pic_CXX in
- "" | " "*) ;;
- *) lt_prog_compiler_pic_CXX=" $lt_prog_compiler_pic_CXX" ;;
- esac
-else
- lt_prog_compiler_pic_CXX=
- lt_prog_compiler_can_build_shared_CXX=no
-fi
-
-fi
-case $host_os in
- # For platforms which do not support PIC, -DPIC is meaningless:
- *djgpp*)
- lt_prog_compiler_pic_CXX=
- ;;
- *)
- lt_prog_compiler_pic_CXX="$lt_prog_compiler_pic_CXX -DPIC"
- ;;
-esac
-
-#
-# Check to make sure the static flag actually works.
-#
-wl=$lt_prog_compiler_wl_CXX eval lt_tmp_static_flag=\"$lt_prog_compiler_static_CXX\"
-echo "$as_me:$LINENO: checking if $compiler static flag $lt_tmp_static_flag works" >&5
-echo $ECHO_N "checking if $compiler static flag $lt_tmp_static_flag works... $ECHO_C" >&6
-if test "${lt_prog_compiler_static_works_CXX+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- lt_prog_compiler_static_works_CXX=no
- save_LDFLAGS="$LDFLAGS"
- LDFLAGS="$LDFLAGS $lt_tmp_static_flag"
- printf "$lt_simple_link_test_code" > conftest.$ac_ext
- if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then
- # The linker can only warn and ignore the option if not recognized
- # So say no if there are warnings
- if test -s conftest.err; then
- # Append any errors to the config.log.
- cat conftest.err 1>&5
- $echo "X$_lt_linker_boilerplate" | $Xsed -e '/^$/d' > conftest.exp
- $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2
- if diff conftest.exp conftest.er2 >/dev/null; then
- lt_prog_compiler_static_works_CXX=yes
- fi
- else
- lt_prog_compiler_static_works_CXX=yes
- fi
- fi
- $rm conftest*
- LDFLAGS="$save_LDFLAGS"
-
-fi
-echo "$as_me:$LINENO: result: $lt_prog_compiler_static_works_CXX" >&5
-echo "${ECHO_T}$lt_prog_compiler_static_works_CXX" >&6
-
-if test x"$lt_prog_compiler_static_works_CXX" = xyes; then
- :
-else
- lt_prog_compiler_static_CXX=
-fi
-
-
-echo "$as_me:$LINENO: checking if $compiler supports -c -o file.$ac_objext" >&5
-echo $ECHO_N "checking if $compiler supports -c -o file.$ac_objext... $ECHO_C" >&6
-if test "${lt_cv_prog_compiler_c_o_CXX+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- lt_cv_prog_compiler_c_o_CXX=no
- $rm -r conftest 2>/dev/null
- mkdir conftest
- cd conftest
- mkdir out
- printf "$lt_simple_compile_test_code" > conftest.$ac_ext
-
- lt_compiler_flag="-o out/conftest2.$ac_objext"
- # Insert the option either (1) after the last *FLAGS variable, or
- # (2) before a word containing "conftest.", or (3) at the end.
- # Note that $ac_compile itself does not contain backslashes and begins
- # with a dollar sign (not a hyphen), so the echo should work correctly.
- lt_compile=`echo "$ac_compile" | $SED \
- -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
- -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
- -e 's:$: $lt_compiler_flag:'`
- (eval echo "\"\$as_me:11597: $lt_compile\"" >&5)
- (eval "$lt_compile" 2>out/conftest.err)
- ac_status=$?
- cat out/conftest.err >&5
- echo "$as_me:11601: \$? = $ac_status" >&5
- if (exit $ac_status) && test -s out/conftest2.$ac_objext
- then
- # The compiler can only warn and ignore the option if not recognized
- # So say no if there are warnings
- $echo "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' > out/conftest.exp
- $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2
- if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then
- lt_cv_prog_compiler_c_o_CXX=yes
- fi
- fi
- chmod u+w . 2>&5
- $rm conftest*
- # SGI C++ compiler will create directory out/ii_files/ for
- # template instantiation
- test -d out/ii_files && $rm out/ii_files/* && rmdir out/ii_files
- $rm out/* && rmdir out
- cd ..
- rmdir conftest
- $rm conftest*
-
-fi
-echo "$as_me:$LINENO: result: $lt_cv_prog_compiler_c_o_CXX" >&5
-echo "${ECHO_T}$lt_cv_prog_compiler_c_o_CXX" >&6
-
-
-hard_links="nottested"
-if test "$lt_cv_prog_compiler_c_o_CXX" = no && test "$need_locks" != no; then
- # do not overwrite the value of need_locks provided by the user
- echo "$as_me:$LINENO: checking if we can lock with hard links" >&5
-echo $ECHO_N "checking if we can lock with hard links... $ECHO_C" >&6
- hard_links=yes
- $rm conftest*
- ln conftest.a conftest.b 2>/dev/null && hard_links=no
- touch conftest.a
- ln conftest.a conftest.b 2>&5 || hard_links=no
- ln conftest.a conftest.b 2>/dev/null && hard_links=no
- echo "$as_me:$LINENO: result: $hard_links" >&5
-echo "${ECHO_T}$hard_links" >&6
- if test "$hard_links" = no; then
- { echo "$as_me:$LINENO: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&5
-echo "$as_me: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&2;}
- need_locks=warn
- fi
-else
- need_locks=no
-fi
-
-echo "$as_me:$LINENO: checking whether the $compiler linker ($LD) supports shared libraries" >&5
-echo $ECHO_N "checking whether the $compiler linker ($LD) supports shared libraries... $ECHO_C" >&6
-
- export_symbols_cmds_CXX='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols'
- case $host_os in
- aix4* | aix5*)
- # If we're using GNU nm, then we don't want the "-C" option.
- # -C means demangle to AIX nm, but means don't demangle with GNU nm
- if $NM -V 2>&1 | grep 'GNU' > /dev/null; then
- export_symbols_cmds_CXX='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$2 == "T") || (\$2 == "D") || (\$2 == "B")) && (substr(\$3,1,1) != ".")) { print \$3 } }'\'' | sort -u > $export_symbols'
- else
- export_symbols_cmds_CXX='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\$2 == "T") || (\$2 == "D") || (\$2 == "B")) && (substr(\$3,1,1) != ".")) { print \$3 } }'\'' | sort -u > $export_symbols'
- fi
- ;;
- pw32*)
- export_symbols_cmds_CXX="$ltdll_cmds"
- ;;
- cygwin* | mingw*)
- export_symbols_cmds_CXX='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[BCDGRS] /s/.* \([^ ]*\)/\1 DATA/;/^.* __nm__/s/^.* __nm__\([^ ]*\) [^ ]*/\1 DATA/;/^I /d;/^[AITW] /s/.* //'\'' | sort | uniq > $export_symbols'
- ;;
- kfreebsd*-gnu)
- link_all_deplibs_CXX=no
- ;;
- linux*)
- link_all_deplibs_CXX=no
- ;;
- *)
- export_symbols_cmds_CXX='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols'
- ;;
- esac
-
-echo "$as_me:$LINENO: result: $ld_shlibs_CXX" >&5
-echo "${ECHO_T}$ld_shlibs_CXX" >&6
-test "$ld_shlibs_CXX" = no && can_build_shared=no
-
-#
-# Do we need to explicitly link libc?
-#
-case "x$archive_cmds_need_lc_CXX" in
-x|xyes)
- # Assume -lc should be added
- archive_cmds_need_lc_CXX=yes
-
- if test "$enable_shared" = yes && test "$GCC" = yes; then
- case $archive_cmds_CXX in
- *'~'*)
- # FIXME: we may have to deal with multi-command sequences.
- ;;
- '$CC '*)
- # Test whether the compiler implicitly links with -lc since on some
- # systems, -lgcc has to come before -lc. If gcc already passes -lc
- # to ld, don't add -lc before -lgcc.
- echo "$as_me:$LINENO: checking whether -lc should be explicitly linked in" >&5
-echo $ECHO_N "checking whether -lc should be explicitly linked in... $ECHO_C" >&6
- $rm conftest*
- printf "$lt_simple_compile_test_code" > conftest.$ac_ext
-
- if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
- (eval $ac_compile) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } 2>conftest.err; then
- soname=conftest
- lib=conftest
- libobjs=conftest.$ac_objext
- deplibs=
- wl=$lt_prog_compiler_wl_CXX
- pic_flag=$lt_prog_compiler_pic_CXX
- compiler_flags=-v
- linker_flags=-v
- verstring=
- output_objdir=.
- libname=conftest
- lt_save_allow_undefined_flag=$allow_undefined_flag_CXX
- allow_undefined_flag_CXX=
- if { (eval echo "$as_me:$LINENO: \"$archive_cmds_CXX 2\>\&1 \| grep \" -lc \" \>/dev/null 2\>\&1\"") >&5
- (eval $archive_cmds_CXX 2\>\&1 \| grep \" -lc \" \>/dev/null 2\>\&1) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }
- then
- archive_cmds_need_lc_CXX=no
- else
- archive_cmds_need_lc_CXX=yes
- fi
- allow_undefined_flag_CXX=$lt_save_allow_undefined_flag
- else
- cat conftest.err 1>&5
- fi
- $rm conftest*
- echo "$as_me:$LINENO: result: $archive_cmds_need_lc_CXX" >&5
-echo "${ECHO_T}$archive_cmds_need_lc_CXX" >&6
- ;;
- esac
- fi
- ;;
-esac
-
-echo "$as_me:$LINENO: checking dynamic linker characteristics" >&5
-echo $ECHO_N "checking dynamic linker characteristics... $ECHO_C" >&6
-library_names_spec=
-libname_spec='lib$name'
-soname_spec=
-shrext_cmds=".so"
-postinstall_cmds=
-postuninstall_cmds=
-finish_cmds=
-finish_eval=
-shlibpath_var=
-shlibpath_overrides_runpath=unknown
-version_type=none
-dynamic_linker="$host_os ld.so"
-sys_lib_dlsearch_path_spec="/lib /usr/lib"
-if test "$GCC" = yes; then
- sys_lib_search_path_spec=`$CC -print-search-dirs | grep "^libraries:" | $SED -e "s/^libraries://" -e "s,=/,/,g"`
- if echo "$sys_lib_search_path_spec" | grep ';' >/dev/null ; then
- # if the path contains ";" then we assume it to be the separator
- # otherwise default to the standard path separator (i.e. ":") - it is
- # assumed that no part of a normal pathname contains ";" but that should
- # okay in the real world where ";" in dirpaths is itself problematic.
- sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'`
- else
- sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"`
- fi
-else
- sys_lib_search_path_spec="/lib /usr/lib /usr/local/lib"
-fi
-need_lib_prefix=unknown
-hardcode_into_libs=no
-
-# when you set need_version to no, make sure it does not cause -set_version
-# flags to be left without arguments
-need_version=unknown
-
-case $host_os in
-aix3*)
- version_type=linux
- library_names_spec='${libname}${release}${shared_ext}$versuffix $libname.a'
- shlibpath_var=LIBPATH
-
- # AIX 3 has no versioning support, so we append a major version to the name.
- soname_spec='${libname}${release}${shared_ext}$major'
- ;;
-
-aix4* | aix5*)
- version_type=linux
- need_lib_prefix=no
- need_version=no
- hardcode_into_libs=yes
- if test "$host_cpu" = ia64; then
- # AIX 5 supports IA64
- library_names_spec='${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext}$versuffix $libname${shared_ext}'
- shlibpath_var=LD_LIBRARY_PATH
- else
- # With GCC up to 2.95.x, collect2 would create an import file
- # for dependence libraries. The import file would start with
- # the line `#! .'. This would cause the generated library to
- # depend on `.', always an invalid library. This was fixed in
- # development snapshots of GCC prior to 3.0.
- case $host_os in
- aix4 | aix4.[01] | aix4.[01].*)
- if { echo '#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 97)'
- echo ' yes '
- echo '#endif'; } | ${CC} -E - | grep yes > /dev/null; then
- :
- else
- can_build_shared=no
- fi
- ;;
- esac
- # AIX (on Power*) has no versioning support, so currently we can not hardcode correct
- # soname into executable. Probably we can add versioning support to
- # collect2, so additional links can be useful in future.
- if test "$aix_use_runtimelinking" = yes; then
- # If using run time linking (on AIX 4.2 or later) use lib<name>.so
- # instead of lib<name>.a to let people know that these are not
- # typical AIX shared libraries.
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
- else
- # We preserve .a as extension for shared libraries through AIX4.2
- # and later when we are not doing run time linking.
- library_names_spec='${libname}${release}.a $libname.a'
- soname_spec='${libname}${release}${shared_ext}$major'
- fi
- shlibpath_var=LIBPATH
- fi
- ;;
-
-amigaos*)
- library_names_spec='$libname.ixlibrary $libname.a'
- # Create ${libname}_ixlibrary.a entries in /sys/libs.
- finish_eval='for lib in `ls $libdir/*.ixlibrary 2>/dev/null`; do libname=`$echo "X$lib" | $Xsed -e '\''s%^.*/\([^/]*\)\.ixlibrary$%\1%'\''`; test $rm /sys/libs/${libname}_ixlibrary.a; $show "cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a"; cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a || exit 1; done'
- ;;
-
-beos*)
- library_names_spec='${libname}${shared_ext}'
- dynamic_linker="$host_os ld.so"
- shlibpath_var=LIBRARY_PATH
- ;;
-
-bsdi[45]*)
- version_type=linux
- need_version=no
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
- soname_spec='${libname}${release}${shared_ext}$major'
- finish_cmds='PATH="\$PATH:/sbin" ldconfig $libdir'
- shlibpath_var=LD_LIBRARY_PATH
- sys_lib_search_path_spec="/shlib /usr/lib /usr/X11/lib /usr/contrib/lib /lib /usr/local/lib"
- sys_lib_dlsearch_path_spec="/shlib /usr/lib /usr/local/lib"
- # the default ld.so.conf also contains /usr/contrib/lib and
- # /usr/X11R6/lib (/usr/X11 is a link to /usr/X11R6), but let us allow
- # libtool to hard-code these into programs
- ;;
-
-cygwin* | mingw* | pw32*)
- version_type=windows
- shrext_cmds=".dll"
- need_version=no
- need_lib_prefix=no
-
- case $GCC,$host_os in
- yes,cygwin* | yes,mingw* | yes,pw32*)
- library_names_spec='$libname.dll.a'
- # DLL is installed to $(libdir)/../bin by postinstall_cmds
- postinstall_cmds='base_file=`basename \${file}`~
- dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i;echo \$dlname'\''`~
- dldir=$destdir/`dirname \$dlpath`~
- test -d \$dldir || mkdir -p \$dldir~
- $install_prog $dir/$dlname \$dldir/$dlname~
- chmod a+x \$dldir/$dlname'
- postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~
- dlpath=$dir/\$dldll~
- $rm \$dlpath'
- shlibpath_overrides_runpath=yes
-
- case $host_os in
- cygwin*)
- # Cygwin DLLs use 'cyg' prefix rather than 'lib'
- soname_spec='`echo ${libname} | sed -e 's/^lib/cyg/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}'
- sys_lib_search_path_spec="/usr/lib /lib/w32api /lib /usr/local/lib"
- ;;
- mingw*)
- # MinGW DLLs use traditional 'lib' prefix
- soname_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}'
- sys_lib_search_path_spec=`$CC -print-search-dirs | grep "^libraries:" | $SED -e "s/^libraries://" -e "s,=/,/,g"`
- if echo "$sys_lib_search_path_spec" | grep ';[c-zC-Z]:/' >/dev/null; then
- # It is most probably a Windows format PATH printed by
- # mingw gcc, but we are running on Cygwin. Gcc prints its search
- # path with ; separators, and with drive letters. We can handle the
- # drive letters (cygwin fileutils understands them), so leave them,
- # especially as we might pass files found there to a mingw objdump,
- # which wouldn't understand a cygwinified path. Ahh.
- sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'`
- else
- sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"`
- fi
- ;;
- pw32*)
- # pw32 DLLs use 'pw' prefix rather than 'lib'
- library_names_spec='`echo ${libname} | sed -e 's/^lib/pw/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}'
- ;;
- esac
- ;;
-
- *)
- library_names_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext} $libname.lib'
- ;;
- esac
- dynamic_linker='Win32 ld.exe'
- # FIXME: first we should search . and the directory the executable is in
- shlibpath_var=PATH
- ;;
-
-darwin* | rhapsody*)
- dynamic_linker="$host_os dyld"
- version_type=darwin
- need_lib_prefix=no
- need_version=no
- library_names_spec='${libname}${release}${versuffix}$shared_ext ${libname}${release}${major}$shared_ext ${libname}$shared_ext'
- soname_spec='${libname}${release}${major}$shared_ext'
- shlibpath_overrides_runpath=yes
- shlibpath_var=DYLD_LIBRARY_PATH
- shrext_cmds='`test .$module = .yes && echo .so || echo .dylib`'
- # Apple's gcc prints 'gcc -print-search-dirs' doesn't operate the same.
- if test "$GCC" = yes; then
- sys_lib_search_path_spec=`$CC -print-search-dirs | tr "\n" "$PATH_SEPARATOR" | sed -e 's/libraries:/@libraries:/' | tr "@" "\n" | grep "^libraries:" | sed -e "s/^libraries://" -e "s,=/,/,g" -e "s,$PATH_SEPARATOR, ,g" -e "s,.*,& /lib /usr/lib /usr/local/lib,g"`
- else
- sys_lib_search_path_spec='/lib /usr/lib /usr/local/lib'
- fi
- sys_lib_dlsearch_path_spec='/usr/local/lib /lib /usr/lib'
- ;;
-
-dgux*)
- version_type=linux
- need_lib_prefix=no
- need_version=no
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname$shared_ext'
- soname_spec='${libname}${release}${shared_ext}$major'
- shlibpath_var=LD_LIBRARY_PATH
- ;;
-
-freebsd1*)
- dynamic_linker=no
- ;;
-
-kfreebsd*-gnu)
- version_type=linux
- need_lib_prefix=no
- need_version=no
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
- soname_spec='${libname}${release}${shared_ext}$major'
- shlibpath_var=LD_LIBRARY_PATH
- shlibpath_overrides_runpath=no
- hardcode_into_libs=yes
- dynamic_linker='GNU ld.so'
- ;;
-
-freebsd* | dragonfly*)
- # DragonFly does not have aout. When/if they implement a new
- # versioning mechanism, adjust this.
- if test -x /usr/bin/objformat; then
- objformat=`/usr/bin/objformat`
- else
- case $host_os in
- freebsd[123]*) objformat=aout ;;
- *) objformat=elf ;;
- esac
- fi
- version_type=freebsd-$objformat
- case $version_type in
- freebsd-elf*)
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}'
- need_version=no
- need_lib_prefix=no
- ;;
- freebsd-*)
- library_names_spec='${libname}${release}${shared_ext}$versuffix $libname${shared_ext}$versuffix'
- need_version=yes
- ;;
- esac
- shlibpath_var=LD_LIBRARY_PATH
- case $host_os in
- freebsd2*)
- shlibpath_overrides_runpath=yes
- ;;
- freebsd3.[01]* | freebsdelf3.[01]*)
- shlibpath_overrides_runpath=yes
- hardcode_into_libs=yes
- ;;
- freebsd3.[2-9]* | freebsdelf3.[2-9]* | \
- freebsd4.[0-5] | freebsdelf4.[0-5] | freebsd4.1.1 | freebsdelf4.1.1)
- shlibpath_overrides_runpath=no
- hardcode_into_libs=yes
- ;;
- freebsd*) # from 4.6 on
- shlibpath_overrides_runpath=yes
- hardcode_into_libs=yes
- ;;
- esac
- ;;
-
-gnu*)
- version_type=linux
- need_lib_prefix=no
- need_version=no
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}'
- soname_spec='${libname}${release}${shared_ext}$major'
- shlibpath_var=LD_LIBRARY_PATH
- hardcode_into_libs=yes
- ;;
-
-hpux9* | hpux10* | hpux11*)
- # Give a soname corresponding to the major version so that dld.sl refuses to
- # link against other versions.
- version_type=sunos
- need_lib_prefix=no
- need_version=no
- case $host_cpu in
- ia64*)
- shrext_cmds='.so'
- hardcode_into_libs=yes
- dynamic_linker="$host_os dld.so"
- shlibpath_var=LD_LIBRARY_PATH
- shlibpath_overrides_runpath=yes # Unless +noenvvar is specified.
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
- soname_spec='${libname}${release}${shared_ext}$major'
- if test "X$HPUX_IA64_MODE" = X32; then
- sys_lib_search_path_spec="/usr/lib/hpux32 /usr/local/lib/hpux32 /usr/local/lib"
- else
- sys_lib_search_path_spec="/usr/lib/hpux64 /usr/local/lib/hpux64"
- fi
- sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec
- ;;
- hppa*64*)
- shrext_cmds='.sl'
- hardcode_into_libs=yes
- dynamic_linker="$host_os dld.sl"
- shlibpath_var=LD_LIBRARY_PATH # How should we handle SHLIB_PATH
- shlibpath_overrides_runpath=yes # Unless +noenvvar is specified.
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
- soname_spec='${libname}${release}${shared_ext}$major'
- sys_lib_search_path_spec="/usr/lib/pa20_64 /usr/ccs/lib/pa20_64"
- sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec
- ;;
- *)
- shrext_cmds='.sl'
- dynamic_linker="$host_os dld.sl"
- shlibpath_var=SHLIB_PATH
- shlibpath_overrides_runpath=no # +s is required to enable SHLIB_PATH
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
- soname_spec='${libname}${release}${shared_ext}$major'
- ;;
- esac
- # HP-UX runs *really* slowly unless shared libraries are mode 555.
- postinstall_cmds='chmod 555 $lib'
- ;;
-
-interix3*)
- version_type=linux
- need_lib_prefix=no
- need_version=no
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
- soname_spec='${libname}${release}${shared_ext}$major'
- dynamic_linker='Interix 3.x ld.so.1 (PE, like ELF)'
- shlibpath_var=LD_LIBRARY_PATH
- shlibpath_overrides_runpath=no
- hardcode_into_libs=yes
- ;;
-
-irix5* | irix6* | nonstopux*)
- case $host_os in
- nonstopux*) version_type=nonstopux ;;
- *)
- if test "$lt_cv_prog_gnu_ld" = yes; then
- version_type=linux
- else
- version_type=irix
- fi ;;
- esac
- need_lib_prefix=no
- need_version=no
- soname_spec='${libname}${release}${shared_ext}$major'
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext} $libname${shared_ext}'
- case $host_os in
- irix5* | nonstopux*)
- libsuff= shlibsuff=
- ;;
- *)
- case $LD in # libtool.m4 will add one of these switches to LD
- *-32|*"-32 "|*-melf32bsmip|*"-melf32bsmip ")
- libsuff= shlibsuff= libmagic=32-bit;;
- *-n32|*"-n32 "|*-melf32bmipn32|*"-melf32bmipn32 ")
- libsuff=32 shlibsuff=N32 libmagic=N32;;
- *-64|*"-64 "|*-melf64bmip|*"-melf64bmip ")
- libsuff=64 shlibsuff=64 libmagic=64-bit;;
- *) libsuff= shlibsuff= libmagic=never-match;;
- esac
- ;;
- esac
- shlibpath_var=LD_LIBRARY${shlibsuff}_PATH
- shlibpath_overrides_runpath=no
- sys_lib_search_path_spec="/usr/lib${libsuff} /lib${libsuff} /usr/local/lib${libsuff}"
- sys_lib_dlsearch_path_spec="/usr/lib${libsuff} /lib${libsuff}"
- hardcode_into_libs=yes
- ;;
-
-# No shared lib support for Linux oldld, aout, or coff.
-linux*oldld* | linux*aout* | linux*coff*)
- dynamic_linker=no
- ;;
-
-# This must be Linux ELF.
-linux*)
- version_type=linux
- need_lib_prefix=no
- need_version=no
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
- soname_spec='${libname}${release}${shared_ext}$major'
- finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir'
- shlibpath_var=LD_LIBRARY_PATH
- shlibpath_overrides_runpath=no
- # This implies no fast_install, which is unacceptable.
- # Some rework will be needed to allow for fast_install
- # before this can be enabled.
- hardcode_into_libs=yes
-
- # Append ld.so.conf contents to the search path
- if test -f /etc/ld.so.conf; then
- lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s", \$2)); skip = 1; } { if (!skip) print \$0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;s/[:, ]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;/^$/d' | tr '\n' ' '`
- sys_lib_dlsearch_path_spec="/lib /usr/lib $lt_ld_extra"
- fi
-
- # We used to test for /lib/ld.so.1 and disable shared libraries on
- # powerpc, because MkLinux only supported shared libraries with the
- # GNU dynamic linker. Since this was broken with cross compilers,
- # most powerpc-linux boxes support dynamic linking these days and
- # people can always --disable-shared, the test was removed, and we
- # assume the GNU/Linux dynamic linker is in use.
- dynamic_linker='GNU/Linux ld.so'
- ;;
-
-netbsdelf*-gnu)
- version_type=linux
- need_lib_prefix=no
- need_version=no
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
- soname_spec='${libname}${release}${shared_ext}$major'
- shlibpath_var=LD_LIBRARY_PATH
- shlibpath_overrides_runpath=no
- hardcode_into_libs=yes
- dynamic_linker='NetBSD ld.elf_so'
- ;;
-
-knetbsd*-gnu)
- version_type=linux
- need_lib_prefix=no
- need_version=no
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
- soname_spec='${libname}${release}${shared_ext}$major'
- shlibpath_var=LD_LIBRARY_PATH
- shlibpath_overrides_runpath=no
- hardcode_into_libs=yes
- dynamic_linker='GNU ld.so'
- ;;
-
-netbsd*)
- version_type=sunos
- need_lib_prefix=no
- need_version=no
- if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
- finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir'
- dynamic_linker='NetBSD (a.out) ld.so'
- else
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
- soname_spec='${libname}${release}${shared_ext}$major'
- dynamic_linker='NetBSD ld.elf_so'
- fi
- shlibpath_var=LD_LIBRARY_PATH
- shlibpath_overrides_runpath=yes
- hardcode_into_libs=yes
- ;;
-
-newsos6)
- version_type=linux
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
- shlibpath_var=LD_LIBRARY_PATH
- shlibpath_overrides_runpath=yes
- ;;
-
-nto-qnx*)
- version_type=linux
- need_lib_prefix=no
- need_version=no
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
- soname_spec='${libname}${release}${shared_ext}$major'
- shlibpath_var=LD_LIBRARY_PATH
- shlibpath_overrides_runpath=yes
- ;;
-
-openbsd*)
- version_type=sunos
- sys_lib_dlsearch_path_spec="/usr/lib"
- need_lib_prefix=no
- # Some older versions of OpenBSD (3.3 at least) *do* need versioned libs.
- case $host_os in
- openbsd3.3 | openbsd3.3.*) need_version=yes ;;
- *) need_version=no ;;
- esac
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
- finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir'
- shlibpath_var=LD_LIBRARY_PATH
- if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
- case $host_os in
- openbsd2.[89] | openbsd2.[89].*)
- shlibpath_overrides_runpath=no
- ;;
- *)
- shlibpath_overrides_runpath=yes
- ;;
- esac
- else
- shlibpath_overrides_runpath=yes
- fi
- ;;
-
-os2*)
- libname_spec='$name'
- shrext_cmds=".dll"
- need_lib_prefix=no
- library_names_spec='$libname${shared_ext} $libname.a'
- dynamic_linker='OS/2 ld.exe'
- shlibpath_var=LIBPATH
- ;;
-
-osf3* | osf4* | osf5*)
- version_type=osf
- need_lib_prefix=no
- need_version=no
- soname_spec='${libname}${release}${shared_ext}$major'
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
- shlibpath_var=LD_LIBRARY_PATH
- sys_lib_search_path_spec="/usr/shlib /usr/ccs/lib /usr/lib/cmplrs/cc /usr/lib /usr/local/lib /var/shlib"
- sys_lib_dlsearch_path_spec="$sys_lib_search_path_spec"
- ;;
-
-solaris*)
- version_type=linux
- need_lib_prefix=no
- need_version=no
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
- soname_spec='${libname}${release}${shared_ext}$major'
- shlibpath_var=LD_LIBRARY_PATH
- shlibpath_overrides_runpath=yes
- hardcode_into_libs=yes
- # ldd complains unless libraries are executable
- postinstall_cmds='chmod +x $lib'
- ;;
-
-sunos4*)
- version_type=sunos
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
- finish_cmds='PATH="\$PATH:/usr/etc" ldconfig $libdir'
- shlibpath_var=LD_LIBRARY_PATH
- shlibpath_overrides_runpath=yes
- if test "$with_gnu_ld" = yes; then
- need_lib_prefix=no
- fi
- need_version=yes
- ;;
-
-sysv4 | sysv4.3*)
- version_type=linux
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
- soname_spec='${libname}${release}${shared_ext}$major'
- shlibpath_var=LD_LIBRARY_PATH
- case $host_vendor in
- sni)
- shlibpath_overrides_runpath=no
- need_lib_prefix=no
- export_dynamic_flag_spec='${wl}-Blargedynsym'
- runpath_var=LD_RUN_PATH
- ;;
- siemens)
- need_lib_prefix=no
- ;;
- motorola)
- need_lib_prefix=no
- need_version=no
- shlibpath_overrides_runpath=no
- sys_lib_search_path_spec='/lib /usr/lib /usr/ccs/lib'
- ;;
- esac
- ;;
-
-sysv4*MP*)
- if test -d /usr/nec ;then
- version_type=linux
- library_names_spec='$libname${shared_ext}.$versuffix $libname${shared_ext}.$major $libname${shared_ext}'
- soname_spec='$libname${shared_ext}.$major'
- shlibpath_var=LD_LIBRARY_PATH
- fi
- ;;
-
-sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*)
- version_type=freebsd-elf
- need_lib_prefix=no
- need_version=no
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}'
- soname_spec='${libname}${release}${shared_ext}$major'
- shlibpath_var=LD_LIBRARY_PATH
- hardcode_into_libs=yes
- if test "$with_gnu_ld" = yes; then
- sys_lib_search_path_spec='/usr/local/lib /usr/gnu/lib /usr/ccs/lib /usr/lib /lib'
- shlibpath_overrides_runpath=no
- else
- sys_lib_search_path_spec='/usr/ccs/lib /usr/lib'
- shlibpath_overrides_runpath=yes
- case $host_os in
- sco3.2v5*)
- sys_lib_search_path_spec="$sys_lib_search_path_spec /lib"
- ;;
- esac
- fi
- sys_lib_dlsearch_path_spec='/usr/lib'
- ;;
-
-uts4*)
- version_type=linux
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
- soname_spec='${libname}${release}${shared_ext}$major'
- shlibpath_var=LD_LIBRARY_PATH
- ;;
-
-*)
- dynamic_linker=no
- ;;
-esac
-echo "$as_me:$LINENO: result: $dynamic_linker" >&5
-echo "${ECHO_T}$dynamic_linker" >&6
-test "$dynamic_linker" = no && can_build_shared=no
-
-variables_saved_for_relink="PATH $shlibpath_var $runpath_var"
-if test "$GCC" = yes; then
- variables_saved_for_relink="$variables_saved_for_relink GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH"
-fi
-
-echo "$as_me:$LINENO: checking how to hardcode library paths into programs" >&5
-echo $ECHO_N "checking how to hardcode library paths into programs... $ECHO_C" >&6
-hardcode_action_CXX=
-if test -n "$hardcode_libdir_flag_spec_CXX" || \
- test -n "$runpath_var_CXX" || \
- test "X$hardcode_automatic_CXX" = "Xyes" ; then
-
- # We can hardcode non-existant directories.
- if test "$hardcode_direct_CXX" != no &&
- # If the only mechanism to avoid hardcoding is shlibpath_var, we
- # have to relink, otherwise we might link with an installed library
- # when we should be linking with a yet-to-be-installed one
- ## test "$_LT_AC_TAGVAR(hardcode_shlibpath_var, CXX)" != no &&
- test "$hardcode_minus_L_CXX" != no; then
- # Linking always hardcodes the temporary library directory.
- hardcode_action_CXX=relink
- else
- # We can link without hardcoding, and we can hardcode nonexisting dirs.
- hardcode_action_CXX=immediate
- fi
-else
- # We cannot hardcode anything, or else we can only hardcode existing
- # directories.
- hardcode_action_CXX=unsupported
-fi
-echo "$as_me:$LINENO: result: $hardcode_action_CXX" >&5
-echo "${ECHO_T}$hardcode_action_CXX" >&6
-
-if test "$hardcode_action_CXX" = relink; then
- # Fast installation is not supported
- enable_fast_install=no
-elif test "$shlibpath_overrides_runpath" = yes ||
- test "$enable_shared" = no; then
- # Fast installation is not necessary
- enable_fast_install=needless
-fi
-
-
-# The else clause should only fire when bootstrapping the
-# libtool distribution, otherwise you forgot to ship ltmain.sh
-# with your package, and you will get complaints that there are
-# no rules to generate ltmain.sh.
-if test -f "$ltmain"; then
- # See if we are running on zsh, and set the options which allow our commands through
- # without removal of \ escapes.
- if test -n "${ZSH_VERSION+set}" ; then
- setopt NO_GLOB_SUBST
- fi
- # Now quote all the things that may contain metacharacters while being
- # careful not to overquote the AC_SUBSTed values. We take copies of the
- # variables and quote the copies for generation of the libtool script.
- for var in echo old_CC old_CFLAGS AR AR_FLAGS EGREP RANLIB LN_S LTCC LTCFLAGS NM \
- SED SHELL STRIP \
- libname_spec library_names_spec soname_spec extract_expsyms_cmds \
- old_striplib striplib file_magic_cmd finish_cmds finish_eval \
- deplibs_check_method reload_flag reload_cmds need_locks \
- lt_cv_sys_global_symbol_pipe lt_cv_sys_global_symbol_to_cdecl \
- lt_cv_sys_global_symbol_to_c_name_address \
- sys_lib_search_path_spec sys_lib_dlsearch_path_spec \
- old_postinstall_cmds old_postuninstall_cmds \
- compiler_CXX \
- CC_CXX \
- LD_CXX \
- lt_prog_compiler_wl_CXX \
- lt_prog_compiler_pic_CXX \
- lt_prog_compiler_static_CXX \
- lt_prog_compiler_no_builtin_flag_CXX \
- export_dynamic_flag_spec_CXX \
- thread_safe_flag_spec_CXX \
- whole_archive_flag_spec_CXX \
- enable_shared_with_static_runtimes_CXX \
- old_archive_cmds_CXX \
- old_archive_from_new_cmds_CXX \
- predep_objects_CXX \
- postdep_objects_CXX \
- predeps_CXX \
- postdeps_CXX \
- compiler_lib_search_path_CXX \
- archive_cmds_CXX \
- archive_expsym_cmds_CXX \
- postinstall_cmds_CXX \
- postuninstall_cmds_CXX \
- old_archive_from_expsyms_cmds_CXX \
- allow_undefined_flag_CXX \
- no_undefined_flag_CXX \
- export_symbols_cmds_CXX \
- hardcode_libdir_flag_spec_CXX \
- hardcode_libdir_flag_spec_ld_CXX \
- hardcode_libdir_separator_CXX \
- hardcode_automatic_CXX \
- module_cmds_CXX \
- module_expsym_cmds_CXX \
- lt_cv_prog_compiler_c_o_CXX \
- exclude_expsyms_CXX \
- include_expsyms_CXX; do
-
- case $var in
- old_archive_cmds_CXX | \
- old_archive_from_new_cmds_CXX | \
- archive_cmds_CXX | \
- archive_expsym_cmds_CXX | \
- module_cmds_CXX | \
- module_expsym_cmds_CXX | \
- old_archive_from_expsyms_cmds_CXX | \
- export_symbols_cmds_CXX | \
- extract_expsyms_cmds | reload_cmds | finish_cmds | \
- postinstall_cmds | postuninstall_cmds | \
- old_postinstall_cmds | old_postuninstall_cmds | \
- sys_lib_search_path_spec | sys_lib_dlsearch_path_spec)
- # Double-quote double-evaled strings.
- eval "lt_$var=\\\"\`\$echo \"X\$$var\" | \$Xsed -e \"\$double_quote_subst\" -e \"\$sed_quote_subst\" -e \"\$delay_variable_subst\"\`\\\""
- ;;
- *)
- eval "lt_$var=\\\"\`\$echo \"X\$$var\" | \$Xsed -e \"\$sed_quote_subst\"\`\\\""
- ;;
- esac
- done
-
- case $lt_echo in
- *'\$0 --fallback-echo"')
- lt_echo=`$echo "X$lt_echo" | $Xsed -e 's/\\\\\\\$0 --fallback-echo"$/$0 --fallback-echo"/'`
- ;;
- esac
-
-cfgfile="$ofile"
-
- cat <<__EOF__ >> "$cfgfile"
-# ### BEGIN LIBTOOL TAG CONFIG: $tagname
-
-# Libtool was configured on host `(hostname || uname -n) 2>/dev/null | sed 1q`:
-
-# Shell to use when invoking shell scripts.
-SHELL=$lt_SHELL
-
-# Whether or not to build shared libraries.
-build_libtool_libs=$enable_shared
-
-# Whether or not to build static libraries.
-build_old_libs=$enable_static
-
-# Whether or not to add -lc for building shared libraries.
-build_libtool_need_lc=$archive_cmds_need_lc_CXX
-
-# Whether or not to disallow shared libs when runtime libs are static
-allow_libtool_libs_with_static_runtimes=$enable_shared_with_static_runtimes_CXX
-
-# Whether or not to optimize for fast installation.
-fast_install=$enable_fast_install
-
-# The host system.
-host_alias=$host_alias
-host=$host
-host_os=$host_os
-
-# The build system.
-build_alias=$build_alias
-build=$build
-build_os=$build_os
-
-# An echo program that does not interpret backslashes.
-echo=$lt_echo
-
-# The archiver.
-AR=$lt_AR
-AR_FLAGS=$lt_AR_FLAGS
-
-# A C compiler.
-LTCC=$lt_LTCC
-
-# LTCC compiler flags.
-LTCFLAGS=$lt_LTCFLAGS
-
-# A language-specific compiler.
-CC=$lt_compiler_CXX
-
-# Is the compiler the GNU C compiler?
-with_gcc=$GCC_CXX
-
-# An ERE matcher.
-EGREP=$lt_EGREP
-
-# The linker used to build libraries.
-LD=$lt_LD_CXX
-
-# Whether we need hard or soft links.
-LN_S=$lt_LN_S
-
-# A BSD-compatible nm program.
-NM=$lt_NM
-
-# A symbol stripping program
-STRIP=$lt_STRIP
-
-# Used to examine libraries when file_magic_cmd begins "file"
-MAGIC_CMD=$MAGIC_CMD
-
-# Used on cygwin: DLL creation program.
-DLLTOOL="$DLLTOOL"
-
-# Used on cygwin: object dumper.
-OBJDUMP="$OBJDUMP"
-
-# Used on cygwin: assembler.
-AS="$AS"
-
-# The name of the directory that contains temporary libtool files.
-objdir=$objdir
-
-# How to create reloadable object files.
-reload_flag=$lt_reload_flag
-reload_cmds=$lt_reload_cmds
-
-# How to pass a linker flag through the compiler.
-wl=$lt_lt_prog_compiler_wl_CXX
-
-# Object file suffix (normally "o").
-objext="$ac_objext"
-
-# Old archive suffix (normally "a").
-libext="$libext"
-
-# Shared library suffix (normally ".so").
-shrext_cmds='$shrext_cmds'
-
-# Executable file suffix (normally "").
-exeext="$exeext"
-
-# Additional compiler flags for building library objects.
-pic_flag=$lt_lt_prog_compiler_pic_CXX
-pic_mode=$pic_mode
-
-# What is the maximum length of a command?
-max_cmd_len=$lt_cv_sys_max_cmd_len
-
-# Does compiler simultaneously support -c and -o options?
-compiler_c_o=$lt_lt_cv_prog_compiler_c_o_CXX
-
-# Must we lock files when doing compilation?
-need_locks=$lt_need_locks
-
-# Do we need the lib prefix for modules?
-need_lib_prefix=$need_lib_prefix
-
-# Do we need a version for libraries?
-need_version=$need_version
-
-# Whether dlopen is supported.
-dlopen_support=$enable_dlopen
-
-# Whether dlopen of programs is supported.
-dlopen_self=$enable_dlopen_self
-
-# Whether dlopen of statically linked programs is supported.
-dlopen_self_static=$enable_dlopen_self_static
-
-# Compiler flag to prevent dynamic linking.
-link_static_flag=$lt_lt_prog_compiler_static_CXX
-
-# Compiler flag to turn off builtin functions.
-no_builtin_flag=$lt_lt_prog_compiler_no_builtin_flag_CXX
-
-# Compiler flag to allow reflexive dlopens.
-export_dynamic_flag_spec=$lt_export_dynamic_flag_spec_CXX
-
-# Compiler flag to generate shared objects directly from archives.
-whole_archive_flag_spec=$lt_whole_archive_flag_spec_CXX
-
-# Compiler flag to generate thread-safe objects.
-thread_safe_flag_spec=$lt_thread_safe_flag_spec_CXX
-
-# Library versioning type.
-version_type=$version_type
-
-# Format of library name prefix.
-libname_spec=$lt_libname_spec
-
-# List of archive names. First name is the real one, the rest are links.
-# The last name is the one that the linker finds with -lNAME.
-library_names_spec=$lt_library_names_spec
-
-# The coded name of the library, if different from the real name.
-soname_spec=$lt_soname_spec
-
-# Commands used to build and install an old-style archive.
-RANLIB=$lt_RANLIB
-old_archive_cmds=$lt_old_archive_cmds_CXX
-old_postinstall_cmds=$lt_old_postinstall_cmds
-old_postuninstall_cmds=$lt_old_postuninstall_cmds
-
-# Create an old-style archive from a shared archive.
-old_archive_from_new_cmds=$lt_old_archive_from_new_cmds_CXX
-
-# Create a temporary old-style archive to link instead of a shared archive.
-old_archive_from_expsyms_cmds=$lt_old_archive_from_expsyms_cmds_CXX
-
-# Commands used to build and install a shared archive.
-archive_cmds=$lt_archive_cmds_CXX
-archive_expsym_cmds=$lt_archive_expsym_cmds_CXX
-postinstall_cmds=$lt_postinstall_cmds
-postuninstall_cmds=$lt_postuninstall_cmds
-
-# Commands used to build a loadable module (assumed same as above if empty)
-module_cmds=$lt_module_cmds_CXX
-module_expsym_cmds=$lt_module_expsym_cmds_CXX
-
-# Commands to strip libraries.
-old_striplib=$lt_old_striplib
-striplib=$lt_striplib
-
-# Dependencies to place before the objects being linked to create a
-# shared library.
-predep_objects=$lt_predep_objects_CXX
-
-# Dependencies to place after the objects being linked to create a
-# shared library.
-postdep_objects=$lt_postdep_objects_CXX
-
-# Dependencies to place before the objects being linked to create a
-# shared library.
-predeps=$lt_predeps_CXX
-
-# Dependencies to place after the objects being linked to create a
-# shared library.
-postdeps=$lt_postdeps_CXX
-
-# The library search path used internally by the compiler when linking
-# a shared library.
-compiler_lib_search_path=$lt_compiler_lib_search_path_CXX
-
-# Method to check whether dependent libraries are shared objects.
-deplibs_check_method=$lt_deplibs_check_method
-
-# Command to use when deplibs_check_method == file_magic.
-file_magic_cmd=$lt_file_magic_cmd
-
-# Flag that allows shared libraries with undefined symbols to be built.
-allow_undefined_flag=$lt_allow_undefined_flag_CXX
-
-# Flag that forces no undefined symbols.
-no_undefined_flag=$lt_no_undefined_flag_CXX
-
-# Commands used to finish a libtool library installation in a directory.
-finish_cmds=$lt_finish_cmds
-
-# Same as above, but a single script fragment to be evaled but not shown.
-finish_eval=$lt_finish_eval
-
-# Take the output of nm and produce a listing of raw symbols and C names.
-global_symbol_pipe=$lt_lt_cv_sys_global_symbol_pipe
-
-# Transform the output of nm in a proper C declaration
-global_symbol_to_cdecl=$lt_lt_cv_sys_global_symbol_to_cdecl
-
-# Transform the output of nm in a C name address pair
-global_symbol_to_c_name_address=$lt_lt_cv_sys_global_symbol_to_c_name_address
-
-# This is the shared library runtime path variable.
-runpath_var=$runpath_var
-
-# This is the shared library path variable.
-shlibpath_var=$shlibpath_var
-
-# Is shlibpath searched before the hard-coded library search path?
-shlibpath_overrides_runpath=$shlibpath_overrides_runpath
-
-# How to hardcode a shared library path into an executable.
-hardcode_action=$hardcode_action_CXX
-
-# Whether we should hardcode library paths into libraries.
-hardcode_into_libs=$hardcode_into_libs
-
-# Flag to hardcode \$libdir into a binary during linking.
-# This must work even if \$libdir does not exist.
-hardcode_libdir_flag_spec=$lt_hardcode_libdir_flag_spec_CXX
-
-# If ld is used when linking, flag to hardcode \$libdir into
-# a binary during linking. This must work even if \$libdir does
-# not exist.
-hardcode_libdir_flag_spec_ld=$lt_hardcode_libdir_flag_spec_ld_CXX
-
-# Whether we need a single -rpath flag with a separated argument.
-hardcode_libdir_separator=$lt_hardcode_libdir_separator_CXX
-
-# Set to yes if using DIR/libNAME${shared_ext} during linking hardcodes DIR into the
-# resulting binary.
-hardcode_direct=$hardcode_direct_CXX
-
-# Set to yes if using the -LDIR flag during linking hardcodes DIR into the
-# resulting binary.
-hardcode_minus_L=$hardcode_minus_L_CXX
-
-# Set to yes if using SHLIBPATH_VAR=DIR during linking hardcodes DIR into
-# the resulting binary.
-hardcode_shlibpath_var=$hardcode_shlibpath_var_CXX
-
-# Set to yes if building a shared library automatically hardcodes DIR into the library
-# and all subsequent libraries and executables linked against it.
-hardcode_automatic=$hardcode_automatic_CXX
-
-# Variables whose values should be saved in libtool wrapper scripts and
-# restored at relink time.
-variables_saved_for_relink="$variables_saved_for_relink"
-
-# Whether libtool must link a program against all its dependency libraries.
-link_all_deplibs=$link_all_deplibs_CXX
-
-# Compile-time system search path for libraries
-sys_lib_search_path_spec=$lt_sys_lib_search_path_spec
-
-# Run-time system search path for libraries
-sys_lib_dlsearch_path_spec=$lt_sys_lib_dlsearch_path_spec
-
-# Fix the shell variable \$srcfile for the compiler.
-fix_srcfile_path="$fix_srcfile_path_CXX"
-
-# Set to yes if exported symbols are required.
-always_export_symbols=$always_export_symbols_CXX
-
-# The commands to list exported symbols.
-export_symbols_cmds=$lt_export_symbols_cmds_CXX
-
-# The commands to extract the exported symbol list from a shared archive.
-extract_expsyms_cmds=$lt_extract_expsyms_cmds
-
-# Symbols that should not be listed in the preloaded symbols.
-exclude_expsyms=$lt_exclude_expsyms_CXX
-
-# Symbols that must always be exported.
-include_expsyms=$lt_include_expsyms_CXX
-
-# ### END LIBTOOL TAG CONFIG: $tagname
-
-__EOF__
-
-
-else
- # If there is no Makefile yet, we rely on a make rule to execute
- # `config.status --recheck' to rerun these tests and create the
- # libtool script then.
- ltmain_in=`echo $ltmain | sed -e 's/\.sh$/.in/'`
- if test -f "$ltmain_in"; then
- test -f Makefile && make "$ltmain"
- fi
-fi
-
-
-ac_ext=c
-ac_cpp='$CPP $CPPFLAGS'
-ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
-ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
-ac_compiler_gnu=$ac_cv_c_compiler_gnu
-
-CC=$lt_save_CC
-LDCXX=$LD
-LD=$lt_save_LD
-GCC=$lt_save_GCC
-with_gnu_ldcxx=$with_gnu_ld
-with_gnu_ld=$lt_save_with_gnu_ld
-lt_cv_path_LDCXX=$lt_cv_path_LD
-lt_cv_path_LD=$lt_save_path_LD
-lt_cv_prog_gnu_ldcxx=$lt_cv_prog_gnu_ld
-lt_cv_prog_gnu_ld=$lt_save_with_gnu_ld
-
- else
- tagname=""
- fi
- ;;
-
- F77)
- if test -n "$F77" && test "X$F77" != "Xno"; then
-
-ac_ext=f
-ac_compile='$F77 -c $FFLAGS conftest.$ac_ext >&5'
-ac_link='$F77 -o conftest$ac_exeext $FFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
-ac_compiler_gnu=$ac_cv_f77_compiler_gnu
-
-
-archive_cmds_need_lc_F77=no
-allow_undefined_flag_F77=
-always_export_symbols_F77=no
-archive_expsym_cmds_F77=
-export_dynamic_flag_spec_F77=
-hardcode_direct_F77=no
-hardcode_libdir_flag_spec_F77=
-hardcode_libdir_flag_spec_ld_F77=
-hardcode_libdir_separator_F77=
-hardcode_minus_L_F77=no
-hardcode_automatic_F77=no
-module_cmds_F77=
-module_expsym_cmds_F77=
-link_all_deplibs_F77=unknown
-old_archive_cmds_F77=$old_archive_cmds
-no_undefined_flag_F77=
-whole_archive_flag_spec_F77=
-enable_shared_with_static_runtimes_F77=no
-
-# Source file extension for f77 test sources.
-ac_ext=f
-
-# Object file extension for compiled f77 test sources.
-objext=o
-objext_F77=$objext
-
-# Code to be used in simple compile tests
-lt_simple_compile_test_code=" subroutine t\n return\n end\n"
-
-# Code to be used in simple link tests
-lt_simple_link_test_code=" program t\n end\n"
-
-# ltmain only uses $CC for tagged configurations so make sure $CC is set.
-
-# If no C compiler was specified, use CC.
-LTCC=${LTCC-"$CC"}
-
-# If no C compiler flags were specified, use CFLAGS.
-LTCFLAGS=${LTCFLAGS-"$CFLAGS"}
-
-# Allow CC to be a program name with arguments.
-compiler=$CC
-
-
-# save warnings/boilerplate of simple test code
-ac_outfile=conftest.$ac_objext
-printf "$lt_simple_compile_test_code" >conftest.$ac_ext
-eval "$ac_compile" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err
-_lt_compiler_boilerplate=`cat conftest.err`
-$rm conftest*
-
-ac_outfile=conftest.$ac_objext
-printf "$lt_simple_link_test_code" >conftest.$ac_ext
-eval "$ac_link" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err
-_lt_linker_boilerplate=`cat conftest.err`
-$rm conftest*
-
-
-# Allow CC to be a program name with arguments.
-lt_save_CC="$CC"
-CC=${F77-"f77"}
-compiler=$CC
-compiler_F77=$CC
-for cc_temp in $compiler""; do
- case $cc_temp in
- compile | *[\\/]compile | ccache | *[\\/]ccache ) ;;
- distcc | *[\\/]distcc | purify | *[\\/]purify ) ;;
- \-*) ;;
- *) break;;
- esac
-done
-cc_basename=`$echo "X$cc_temp" | $Xsed -e 's%.*/%%' -e "s%^$host_alias-%%"`
-
-
-echo "$as_me:$LINENO: checking if libtool supports shared libraries" >&5
-echo $ECHO_N "checking if libtool supports shared libraries... $ECHO_C" >&6
-echo "$as_me:$LINENO: result: $can_build_shared" >&5
-echo "${ECHO_T}$can_build_shared" >&6
-
-echo "$as_me:$LINENO: checking whether to build shared libraries" >&5
-echo $ECHO_N "checking whether to build shared libraries... $ECHO_C" >&6
-test "$can_build_shared" = "no" && enable_shared=no
-
-# On AIX, shared libraries and static libraries use the same namespace, and
-# are all built from PIC.
-case $host_os in
-aix3*)
- test "$enable_shared" = yes && enable_static=no
- if test -n "$RANLIB"; then
- archive_cmds="$archive_cmds~\$RANLIB \$lib"
- postinstall_cmds='$RANLIB $lib'
- fi
- ;;
-aix4* | aix5*)
- if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then
- test "$enable_shared" = yes && enable_static=no
- fi
- ;;
-esac
-echo "$as_me:$LINENO: result: $enable_shared" >&5
-echo "${ECHO_T}$enable_shared" >&6
-
-echo "$as_me:$LINENO: checking whether to build static libraries" >&5
-echo $ECHO_N "checking whether to build static libraries... $ECHO_C" >&6
-# Make sure either enable_shared or enable_static is yes.
-test "$enable_shared" = yes || enable_static=yes
-echo "$as_me:$LINENO: result: $enable_static" >&5
-echo "${ECHO_T}$enable_static" >&6
-
-GCC_F77="$G77"
-LD_F77="$LD"
-
-lt_prog_compiler_wl_F77=
-lt_prog_compiler_pic_F77=
-lt_prog_compiler_static_F77=
-
-echo "$as_me:$LINENO: checking for $compiler option to produce PIC" >&5
-echo $ECHO_N "checking for $compiler option to produce PIC... $ECHO_C" >&6
-
- if test "$GCC" = yes; then
- lt_prog_compiler_wl_F77='-Wl,'
- lt_prog_compiler_static_F77='-static'
-
- case $host_os in
- aix*)
- # All AIX code is PIC.
- if test "$host_cpu" = ia64; then
- # AIX 5 now supports IA64 processor
- lt_prog_compiler_static_F77='-Bstatic'
- fi
- ;;
-
- amigaos*)
- # FIXME: we need at least 68020 code to build shared libraries, but
- # adding the `-m68020' flag to GCC prevents building anything better,
- # like `-m68040'.
- lt_prog_compiler_pic_F77='-m68020 -resident32 -malways-restore-a4'
- ;;
-
- beos* | cygwin* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*)
- # PIC is the default for these OSes.
- ;;
-
- mingw* | pw32* | os2*)
- # This hack is so that the source file can tell whether it is being
- # built for inclusion in a dll (and should export symbols for example).
- lt_prog_compiler_pic_F77='-DDLL_EXPORT'
- ;;
-
- darwin* | rhapsody*)
- # PIC is the default on this platform
- # Common symbols not allowed in MH_DYLIB files
- lt_prog_compiler_pic_F77='-fno-common'
- ;;
-
- interix3*)
- # Interix 3.x gcc -fpic/-fPIC options generate broken code.
- # Instead, we relocate shared libraries at runtime.
- ;;
-
- msdosdjgpp*)
- # Just because we use GCC doesn't mean we suddenly get shared libraries
- # on systems that don't support them.
- lt_prog_compiler_can_build_shared_F77=no
- enable_shared=no
- ;;
-
- sysv4*MP*)
- if test -d /usr/nec; then
- lt_prog_compiler_pic_F77=-Kconform_pic
- fi
- ;;
-
- hpux*)
- # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but
- # not for PA HP-UX.
- case $host_cpu in
- hppa*64*|ia64*)
- # +Z the default
- ;;
- *)
- lt_prog_compiler_pic_F77='-fPIC'
- ;;
- esac
- ;;
-
- *)
- lt_prog_compiler_pic_F77='-fPIC'
- ;;
- esac
- else
- # PORTME Check for flag to pass linker flags through the system compiler.
- case $host_os in
- aix*)
- lt_prog_compiler_wl_F77='-Wl,'
- if test "$host_cpu" = ia64; then
- # AIX 5 now supports IA64 processor
- lt_prog_compiler_static_F77='-Bstatic'
- else
- lt_prog_compiler_static_F77='-bnso -bI:/lib/syscalls.exp'
- fi
- ;;
- darwin*)
- # PIC is the default on this platform
- # Common symbols not allowed in MH_DYLIB files
- case $cc_basename in
- xlc*)
- lt_prog_compiler_pic_F77='-qnocommon'
- lt_prog_compiler_wl_F77='-Wl,'
- ;;
- esac
- ;;
-
- mingw* | pw32* | os2*)
- # This hack is so that the source file can tell whether it is being
- # built for inclusion in a dll (and should export symbols for example).
- lt_prog_compiler_pic_F77='-DDLL_EXPORT'
- ;;
-
- hpux9* | hpux10* | hpux11*)
- lt_prog_compiler_wl_F77='-Wl,'
- # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but
- # not for PA HP-UX.
- case $host_cpu in
- hppa*64*|ia64*)
- # +Z the default
- ;;
- *)
- lt_prog_compiler_pic_F77='+Z'
- ;;
- esac
- # Is there a better lt_prog_compiler_static that works with the bundled CC?
- lt_prog_compiler_static_F77='${wl}-a ${wl}archive'
- ;;
-
- irix5* | irix6* | nonstopux*)
- lt_prog_compiler_wl_F77='-Wl,'
- # PIC (with -KPIC) is the default.
- lt_prog_compiler_static_F77='-non_shared'
- ;;
-
- newsos6)
- lt_prog_compiler_pic_F77='-KPIC'
- lt_prog_compiler_static_F77='-Bstatic'
- ;;
-
- linux*)
- case $cc_basename in
- icc* | ecc*)
- lt_prog_compiler_wl_F77='-Wl,'
- lt_prog_compiler_pic_F77='-KPIC'
- lt_prog_compiler_static_F77='-static'
- ;;
- pgcc* | pgf77* | pgf90* | pgf95*)
- # Portland Group compilers (*not* the Pentium gcc compiler,
- # which looks to be a dead project)
- lt_prog_compiler_wl_F77='-Wl,'
- lt_prog_compiler_pic_F77='-fpic'
- lt_prog_compiler_static_F77='-Bstatic'
- ;;
- ccc*)
- lt_prog_compiler_wl_F77='-Wl,'
- # All Alpha code is PIC.
- lt_prog_compiler_static_F77='-non_shared'
- ;;
- esac
- ;;
-
- osf3* | osf4* | osf5*)
- lt_prog_compiler_wl_F77='-Wl,'
- # All OSF/1 code is PIC.
- lt_prog_compiler_static_F77='-non_shared'
- ;;
-
- solaris*)
- lt_prog_compiler_pic_F77='-KPIC'
- lt_prog_compiler_static_F77='-Bstatic'
- case $cc_basename in
- f77* | f90* | f95*)
- lt_prog_compiler_wl_F77='-Qoption ld ';;
- *)
- lt_prog_compiler_wl_F77='-Wl,';;
- esac
- ;;
-
- sunos4*)
- lt_prog_compiler_wl_F77='-Qoption ld '
- lt_prog_compiler_pic_F77='-PIC'
- lt_prog_compiler_static_F77='-Bstatic'
- ;;
-
- sysv4 | sysv4.2uw2* | sysv4.3*)
- lt_prog_compiler_wl_F77='-Wl,'
- lt_prog_compiler_pic_F77='-KPIC'
- lt_prog_compiler_static_F77='-Bstatic'
- ;;
-
- sysv4*MP*)
- if test -d /usr/nec ;then
- lt_prog_compiler_pic_F77='-Kconform_pic'
- lt_prog_compiler_static_F77='-Bstatic'
- fi
- ;;
-
- sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*)
- lt_prog_compiler_wl_F77='-Wl,'
- lt_prog_compiler_pic_F77='-KPIC'
- lt_prog_compiler_static_F77='-Bstatic'
- ;;
-
- unicos*)
- lt_prog_compiler_wl_F77='-Wl,'
- lt_prog_compiler_can_build_shared_F77=no
- ;;
-
- uts4*)
- lt_prog_compiler_pic_F77='-pic'
- lt_prog_compiler_static_F77='-Bstatic'
- ;;
-
- *)
- lt_prog_compiler_can_build_shared_F77=no
- ;;
- esac
- fi
-
-echo "$as_me:$LINENO: result: $lt_prog_compiler_pic_F77" >&5
-echo "${ECHO_T}$lt_prog_compiler_pic_F77" >&6
-
-#
-# Check to make sure the PIC flag actually works.
-#
-if test -n "$lt_prog_compiler_pic_F77"; then
-
-echo "$as_me:$LINENO: checking if $compiler PIC flag $lt_prog_compiler_pic_F77 works" >&5
-echo $ECHO_N "checking if $compiler PIC flag $lt_prog_compiler_pic_F77 works... $ECHO_C" >&6
-if test "${lt_prog_compiler_pic_works_F77+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- lt_prog_compiler_pic_works_F77=no
- ac_outfile=conftest.$ac_objext
- printf "$lt_simple_compile_test_code" > conftest.$ac_ext
- lt_compiler_flag="$lt_prog_compiler_pic_F77"
- # Insert the option either (1) after the last *FLAGS variable, or
- # (2) before a word containing "conftest.", or (3) at the end.
- # Note that $ac_compile itself does not contain backslashes and begins
- # with a dollar sign (not a hyphen), so the echo should work correctly.
- # The option is referenced via a variable to avoid confusing sed.
- lt_compile=`echo "$ac_compile" | $SED \
- -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
- -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
- -e 's:$: $lt_compiler_flag:'`
- (eval echo "\"\$as_me:13185: $lt_compile\"" >&5)
- (eval "$lt_compile" 2>conftest.err)
- ac_status=$?
- cat conftest.err >&5
- echo "$as_me:13189: \$? = $ac_status" >&5
- if (exit $ac_status) && test -s "$ac_outfile"; then
- # The compiler can only warn and ignore the option if not recognized
- # So say no if there are warnings other than the usual output.
- $echo "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' >conftest.exp
- $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2
- if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then
- lt_prog_compiler_pic_works_F77=yes
- fi
- fi
- $rm conftest*
-
-fi
-echo "$as_me:$LINENO: result: $lt_prog_compiler_pic_works_F77" >&5
-echo "${ECHO_T}$lt_prog_compiler_pic_works_F77" >&6
-
-if test x"$lt_prog_compiler_pic_works_F77" = xyes; then
- case $lt_prog_compiler_pic_F77 in
- "" | " "*) ;;
- *) lt_prog_compiler_pic_F77=" $lt_prog_compiler_pic_F77" ;;
- esac
-else
- lt_prog_compiler_pic_F77=
- lt_prog_compiler_can_build_shared_F77=no
-fi
-
-fi
-case $host_os in
- # For platforms which do not support PIC, -DPIC is meaningless:
- *djgpp*)
- lt_prog_compiler_pic_F77=
- ;;
- *)
- lt_prog_compiler_pic_F77="$lt_prog_compiler_pic_F77"
- ;;
-esac
-
-#
-# Check to make sure the static flag actually works.
-#
-wl=$lt_prog_compiler_wl_F77 eval lt_tmp_static_flag=\"$lt_prog_compiler_static_F77\"
-echo "$as_me:$LINENO: checking if $compiler static flag $lt_tmp_static_flag works" >&5
-echo $ECHO_N "checking if $compiler static flag $lt_tmp_static_flag works... $ECHO_C" >&6
-if test "${lt_prog_compiler_static_works_F77+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- lt_prog_compiler_static_works_F77=no
- save_LDFLAGS="$LDFLAGS"
- LDFLAGS="$LDFLAGS $lt_tmp_static_flag"
- printf "$lt_simple_link_test_code" > conftest.$ac_ext
- if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then
- # The linker can only warn and ignore the option if not recognized
- # So say no if there are warnings
- if test -s conftest.err; then
- # Append any errors to the config.log.
- cat conftest.err 1>&5
- $echo "X$_lt_linker_boilerplate" | $Xsed -e '/^$/d' > conftest.exp
- $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2
- if diff conftest.exp conftest.er2 >/dev/null; then
- lt_prog_compiler_static_works_F77=yes
- fi
- else
- lt_prog_compiler_static_works_F77=yes
- fi
- fi
- $rm conftest*
- LDFLAGS="$save_LDFLAGS"
-
-fi
-echo "$as_me:$LINENO: result: $lt_prog_compiler_static_works_F77" >&5
-echo "${ECHO_T}$lt_prog_compiler_static_works_F77" >&6
-
-if test x"$lt_prog_compiler_static_works_F77" = xyes; then
- :
-else
- lt_prog_compiler_static_F77=
-fi
-
-
-echo "$as_me:$LINENO: checking if $compiler supports -c -o file.$ac_objext" >&5
-echo $ECHO_N "checking if $compiler supports -c -o file.$ac_objext... $ECHO_C" >&6
-if test "${lt_cv_prog_compiler_c_o_F77+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- lt_cv_prog_compiler_c_o_F77=no
- $rm -r conftest 2>/dev/null
- mkdir conftest
- cd conftest
- mkdir out
- printf "$lt_simple_compile_test_code" > conftest.$ac_ext
-
- lt_compiler_flag="-o out/conftest2.$ac_objext"
- # Insert the option either (1) after the last *FLAGS variable, or
- # (2) before a word containing "conftest.", or (3) at the end.
- # Note that $ac_compile itself does not contain backslashes and begins
- # with a dollar sign (not a hyphen), so the echo should work correctly.
- lt_compile=`echo "$ac_compile" | $SED \
- -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
- -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
- -e 's:$: $lt_compiler_flag:'`
- (eval echo "\"\$as_me:13289: $lt_compile\"" >&5)
- (eval "$lt_compile" 2>out/conftest.err)
- ac_status=$?
- cat out/conftest.err >&5
- echo "$as_me:13293: \$? = $ac_status" >&5
- if (exit $ac_status) && test -s out/conftest2.$ac_objext
- then
- # The compiler can only warn and ignore the option if not recognized
- # So say no if there are warnings
- $echo "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' > out/conftest.exp
- $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2
- if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then
- lt_cv_prog_compiler_c_o_F77=yes
- fi
- fi
- chmod u+w . 2>&5
- $rm conftest*
- # SGI C++ compiler will create directory out/ii_files/ for
- # template instantiation
- test -d out/ii_files && $rm out/ii_files/* && rmdir out/ii_files
- $rm out/* && rmdir out
- cd ..
- rmdir conftest
- $rm conftest*
-
-fi
-echo "$as_me:$LINENO: result: $lt_cv_prog_compiler_c_o_F77" >&5
-echo "${ECHO_T}$lt_cv_prog_compiler_c_o_F77" >&6
-
-
-hard_links="nottested"
-if test "$lt_cv_prog_compiler_c_o_F77" = no && test "$need_locks" != no; then
- # do not overwrite the value of need_locks provided by the user
- echo "$as_me:$LINENO: checking if we can lock with hard links" >&5
-echo $ECHO_N "checking if we can lock with hard links... $ECHO_C" >&6
- hard_links=yes
- $rm conftest*
- ln conftest.a conftest.b 2>/dev/null && hard_links=no
- touch conftest.a
- ln conftest.a conftest.b 2>&5 || hard_links=no
- ln conftest.a conftest.b 2>/dev/null && hard_links=no
- echo "$as_me:$LINENO: result: $hard_links" >&5
-echo "${ECHO_T}$hard_links" >&6
- if test "$hard_links" = no; then
- { echo "$as_me:$LINENO: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&5
-echo "$as_me: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&2;}
- need_locks=warn
- fi
-else
- need_locks=no
-fi
-
-echo "$as_me:$LINENO: checking whether the $compiler linker ($LD) supports shared libraries" >&5
-echo $ECHO_N "checking whether the $compiler linker ($LD) supports shared libraries... $ECHO_C" >&6
-
- runpath_var=
- allow_undefined_flag_F77=
- enable_shared_with_static_runtimes_F77=no
- archive_cmds_F77=
- archive_expsym_cmds_F77=
- old_archive_From_new_cmds_F77=
- old_archive_from_expsyms_cmds_F77=
- export_dynamic_flag_spec_F77=
- whole_archive_flag_spec_F77=
- thread_safe_flag_spec_F77=
- hardcode_libdir_flag_spec_F77=
- hardcode_libdir_flag_spec_ld_F77=
- hardcode_libdir_separator_F77=
- hardcode_direct_F77=no
- hardcode_minus_L_F77=no
- hardcode_shlibpath_var_F77=unsupported
- link_all_deplibs_F77=unknown
- hardcode_automatic_F77=no
- module_cmds_F77=
- module_expsym_cmds_F77=
- always_export_symbols_F77=no
- export_symbols_cmds_F77='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols'
- # include_expsyms should be a list of space-separated symbols to be *always*
- # included in the symbol list
- include_expsyms_F77=
- # exclude_expsyms can be an extended regexp of symbols to exclude
- # it will be wrapped by ` (' and `)$', so one must not match beginning or
- # end of line. Example: `a|bc|.*d.*' will exclude the symbols `a' and `bc',
- # as well as any symbol that contains `d'.
- exclude_expsyms_F77="_GLOBAL_OFFSET_TABLE_"
- # Although _GLOBAL_OFFSET_TABLE_ is a valid symbol C name, most a.out
- # platforms (ab)use it in PIC code, but their linkers get confused if
- # the symbol is explicitly referenced. Since portable code cannot
- # rely on this symbol name, it's probably fine to never include it in
- # preloaded symbol tables.
- extract_expsyms_cmds=
- # Just being paranoid about ensuring that cc_basename is set.
- for cc_temp in $compiler""; do
- case $cc_temp in
- compile | *[\\/]compile | ccache | *[\\/]ccache ) ;;
- distcc | *[\\/]distcc | purify | *[\\/]purify ) ;;
- \-*) ;;
- *) break;;
- esac
-done
-cc_basename=`$echo "X$cc_temp" | $Xsed -e 's%.*/%%' -e "s%^$host_alias-%%"`
-
- case $host_os in
- cygwin* | mingw* | pw32*)
- # FIXME: the MSVC++ port hasn't been tested in a loooong time
- # When not using gcc, we currently assume that we are using
- # Microsoft Visual C++.
- if test "$GCC" != yes; then
- with_gnu_ld=no
- fi
- ;;
- interix*)
- # we just hope/assume this is gcc and not c89 (= MSVC++)
- with_gnu_ld=yes
- ;;
- openbsd*)
- with_gnu_ld=no
- ;;
- esac
-
- ld_shlibs_F77=yes
- if test "$with_gnu_ld" = yes; then
- # If archive_cmds runs LD, not CC, wlarc should be empty
- wlarc='${wl}'
-
- # Set some defaults for GNU ld with shared library support. These
- # are reset later if shared libraries are not supported. Putting them
- # here allows them to be overridden if necessary.
- runpath_var=LD_RUN_PATH
- hardcode_libdir_flag_spec_F77='${wl}--rpath ${wl}$libdir'
- export_dynamic_flag_spec_F77='${wl}--export-dynamic'
- # ancient GNU ld didn't support --whole-archive et. al.
- if $LD --help 2>&1 | grep 'no-whole-archive' > /dev/null; then
- whole_archive_flag_spec_F77="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive'
- else
- whole_archive_flag_spec_F77=
- fi
- supports_anon_versioning=no
- case `$LD -v 2>/dev/null` in
- *\ [01].* | *\ 2.[0-9].* | *\ 2.10.*) ;; # catch versions < 2.11
- *\ 2.11.93.0.2\ *) supports_anon_versioning=yes ;; # RH7.3 ...
- *\ 2.11.92.0.12\ *) supports_anon_versioning=yes ;; # Mandrake 8.2 ...
- *\ 2.11.*) ;; # other 2.11 versions
- *) supports_anon_versioning=yes ;;
- esac
-
- # See if GNU ld supports shared libraries.
- case $host_os in
- aix3* | aix4* | aix5*)
- # On AIX/PPC, the GNU linker is very broken
- if test "$host_cpu" != ia64; then
- ld_shlibs_F77=no
- cat <<EOF 1>&2
-
-*** Warning: the GNU linker, at least up to release 2.9.1, is reported
-*** to be unable to reliably create shared libraries on AIX.
-*** Therefore, libtool is disabling shared libraries support. If you
-*** really care for shared libraries, you may want to modify your PATH
-*** so that a non-GNU linker is found, and then restart.
-
-EOF
- fi
- ;;
-
- amigaos*)
- archive_cmds_F77='$rm $output_objdir/a2ixlibrary.data~$echo "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$echo "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$echo "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$echo "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)'
- hardcode_libdir_flag_spec_F77='-L$libdir'
- hardcode_minus_L_F77=yes
-
- # Samuel A. Falvo II <kc5tja@dolphin.openprojects.net> reports
- # that the semantics of dynamic libraries on AmigaOS, at least up
- # to version 4, is to share data among multiple programs linked
- # with the same dynamic library. Since this doesn't match the
- # behavior of shared libraries on other platforms, we can't use
- # them.
- ld_shlibs_F77=no
- ;;
-
- beos*)
- if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
- allow_undefined_flag_F77=unsupported
- # Joseph Beckenbach <jrb3@best.com> says some releases of gcc
- # support --undefined. This deserves some investigation. FIXME
- archive_cmds_F77='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
- else
- ld_shlibs_F77=no
- fi
- ;;
-
- cygwin* | mingw* | pw32*)
- # _LT_AC_TAGVAR(hardcode_libdir_flag_spec, F77) is actually meaningless,
- # as there is no search path for DLLs.
- hardcode_libdir_flag_spec_F77='-L$libdir'
- allow_undefined_flag_F77=unsupported
- always_export_symbols_F77=no
- enable_shared_with_static_runtimes_F77=yes
- export_symbols_cmds_F77='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[BCDGRS] /s/.* \([^ ]*\)/\1 DATA/'\'' | $SED -e '\''/^[AITW] /s/.* //'\'' | sort | uniq > $export_symbols'
-
- if $LD --help 2>&1 | grep 'auto-import' > /dev/null; then
- archive_cmds_F77='$CC -shared $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
- # If the export-symbols file already is a .def file (1st line
- # is EXPORTS), use it as is; otherwise, prepend...
- archive_expsym_cmds_F77='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then
- cp $export_symbols $output_objdir/$soname.def;
- else
- echo EXPORTS > $output_objdir/$soname.def;
- cat $export_symbols >> $output_objdir/$soname.def;
- fi~
- $CC -shared $output_objdir/$soname.def $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
- else
- ld_shlibs_F77=no
- fi
- ;;
-
- interix3*)
- hardcode_direct_F77=no
- hardcode_shlibpath_var_F77=no
- hardcode_libdir_flag_spec_F77='${wl}-rpath,$libdir'
- export_dynamic_flag_spec_F77='${wl}-E'
- # Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc.
- # Instead, shared libraries are loaded at an image base (0x10000000 by
- # default) and relocated if they conflict, which is a slow very memory
- # consuming and fragmenting process. To avoid this, we pick a random,
- # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link
- # time. Moving up from 0x10000000 also allows more sbrk(2) space.
- archive_cmds_F77='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
- archive_expsym_cmds_F77='sed "s,^,_," $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--retain-symbols-file,$output_objdir/$soname.expsym ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
- ;;
-
- linux*)
- if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
- tmp_addflag=
- case $cc_basename,$host_cpu in
- pgcc*) # Portland Group C compiler
- whole_archive_flag_spec_F77='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}--no-whole-archive'
- tmp_addflag=' $pic_flag'
- ;;
- pgf77* | pgf90* | pgf95*) # Portland Group f77 and f90 compilers
- whole_archive_flag_spec_F77='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}--no-whole-archive'
- tmp_addflag=' $pic_flag -Mnomain' ;;
- ecc*,ia64* | icc*,ia64*) # Intel C compiler on ia64
- tmp_addflag=' -i_dynamic' ;;
- efc*,ia64* | ifort*,ia64*) # Intel Fortran compiler on ia64
- tmp_addflag=' -i_dynamic -nofor_main' ;;
- ifc* | ifort*) # Intel Fortran compiler
- tmp_addflag=' -nofor_main' ;;
- esac
- archive_cmds_F77='$CC -shared'"$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
-
- if test $supports_anon_versioning = yes; then
- archive_expsym_cmds_F77='$echo "{ global:" > $output_objdir/$libname.ver~
- cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~
- $echo "local: *; };" >> $output_objdir/$libname.ver~
- $CC -shared'"$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib'
- fi
- link_all_deplibs_F77=no
- else
- ld_shlibs_F77=no
- fi
- ;;
-
- netbsd* | netbsdelf*-gnu | knetbsd*-gnu)
- if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then
- archive_cmds_F77='$LD -Bshareable $libobjs $deplibs $linker_flags -o $lib'
- wlarc=
- else
- archive_cmds_F77='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
- archive_expsym_cmds_F77='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
- fi
- ;;
-
- solaris*)
- if $LD -v 2>&1 | grep 'BFD 2\.8' > /dev/null; then
- ld_shlibs_F77=no
- cat <<EOF 1>&2
-
-*** Warning: The releases 2.8.* of the GNU linker cannot reliably
-*** create shared libraries on Solaris systems. Therefore, libtool
-*** is disabling shared libraries support. We urge you to upgrade GNU
-*** binutils to release 2.9.1 or newer. Another option is to modify
-*** your PATH or compiler configuration so that the native linker is
-*** used, and then restart.
-
-EOF
- elif $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
- archive_cmds_F77='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
- archive_expsym_cmds_F77='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
- else
- ld_shlibs_F77=no
- fi
- ;;
-
- sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX*)
- case `$LD -v 2>&1` in
- *\ [01].* | *\ 2.[0-9].* | *\ 2.1[0-5].*)
- ld_shlibs_F77=no
- cat <<_LT_EOF 1>&2
-
-*** Warning: Releases of the GNU linker prior to 2.16.91.0.3 can not
-*** reliably create shared libraries on SCO systems. Therefore, libtool
-*** is disabling shared libraries support. We urge you to upgrade GNU
-*** binutils to release 2.16.91.0.3 or newer. Another option is to modify
-*** your PATH or compiler configuration so that the native linker is
-*** used, and then restart.
-
-_LT_EOF
- ;;
- *)
- if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
- hardcode_libdir_flag_spec_F77='`test -z "$SCOABSPATH" && echo ${wl}-rpath,$libdir`'
- archive_cmds_F77='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib'
- archive_expsym_cmds_F77='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname,\${SCOABSPATH:+${install_libdir}/}$soname,-retain-symbols-file,$export_symbols -o $lib'
- else
- ld_shlibs_F77=no
- fi
- ;;
- esac
- ;;
-
- sunos4*)
- archive_cmds_F77='$LD -assert pure-text -Bshareable -o $lib $libobjs $deplibs $linker_flags'
- wlarc=
- hardcode_direct_F77=yes
- hardcode_shlibpath_var_F77=no
- ;;
-
- *)
- if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
- archive_cmds_F77='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
- archive_expsym_cmds_F77='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
- else
- ld_shlibs_F77=no
- fi
- ;;
- esac
-
- if test "$ld_shlibs_F77" = no; then
- runpath_var=
- hardcode_libdir_flag_spec_F77=
- export_dynamic_flag_spec_F77=
- whole_archive_flag_spec_F77=
- fi
- else
- # PORTME fill in a description of your system's linker (not GNU ld)
- case $host_os in
- aix3*)
- allow_undefined_flag_F77=unsupported
- always_export_symbols_F77=yes
- archive_expsym_cmds_F77='$LD -o $output_objdir/$soname $libobjs $deplibs $linker_flags -bE:$export_symbols -T512 -H512 -bM:SRE~$AR $AR_FLAGS $lib $output_objdir/$soname'
- # Note: this linker hardcodes the directories in LIBPATH if there
- # are no directories specified by -L.
- hardcode_minus_L_F77=yes
- if test "$GCC" = yes && test -z "$lt_prog_compiler_static"; then
- # Neither direct hardcoding nor static linking is supported with a
- # broken collect2.
- hardcode_direct_F77=unsupported
- fi
- ;;
-
- aix4* | aix5*)
- if test "$host_cpu" = ia64; then
- # On IA64, the linker does run time linking by default, so we don't
- # have to do anything special.
- aix_use_runtimelinking=no
- exp_sym_flag='-Bexport'
- no_entry_flag=""
- else
- # If we're using GNU nm, then we don't want the "-C" option.
- # -C means demangle to AIX nm, but means don't demangle with GNU nm
- if $NM -V 2>&1 | grep 'GNU' > /dev/null; then
- export_symbols_cmds_F77='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$2 == "T") || (\$2 == "D") || (\$2 == "B")) && (substr(\$3,1,1) != ".")) { print \$3 } }'\'' | sort -u > $export_symbols'
- else
- export_symbols_cmds_F77='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\$2 == "T") || (\$2 == "D") || (\$2 == "B")) && (substr(\$3,1,1) != ".")) { print \$3 } }'\'' | sort -u > $export_symbols'
- fi
- aix_use_runtimelinking=no
-
- # Test if we are trying to use run time linking or normal
- # AIX style linking. If -brtl is somewhere in LDFLAGS, we
- # need to do runtime linking.
- case $host_os in aix4.[23]|aix4.[23].*|aix5*)
- for ld_flag in $LDFLAGS; do
- if (test $ld_flag = "-brtl" || test $ld_flag = "-Wl,-brtl"); then
- aix_use_runtimelinking=yes
- break
- fi
- done
- ;;
- esac
-
- exp_sym_flag='-bexport'
- no_entry_flag='-bnoentry'
- fi
-
- # When large executables or shared objects are built, AIX ld can
- # have problems creating the table of contents. If linking a library
- # or program results in "error TOC overflow" add -mminimal-toc to
- # CXXFLAGS/CFLAGS for g++/gcc. In the cases where that is not
- # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS.
-
- archive_cmds_F77=''
- hardcode_direct_F77=yes
- hardcode_libdir_separator_F77=':'
- link_all_deplibs_F77=yes
-
- if test "$GCC" = yes; then
- case $host_os in aix4.[012]|aix4.[012].*)
- # We only want to do this on AIX 4.2 and lower, the check
- # below for broken collect2 doesn't work under 4.3+
- collect2name=`${CC} -print-prog-name=collect2`
- if test -f "$collect2name" && \
- strings "$collect2name" | grep resolve_lib_name >/dev/null
- then
- # We have reworked collect2
- hardcode_direct_F77=yes
- else
- # We have old collect2
- hardcode_direct_F77=unsupported
- # It fails to find uninstalled libraries when the uninstalled
- # path is not listed in the libpath. Setting hardcode_minus_L
- # to unsupported forces relinking
- hardcode_minus_L_F77=yes
- hardcode_libdir_flag_spec_F77='-L$libdir'
- hardcode_libdir_separator_F77=
- fi
- ;;
- esac
- shared_flag='-shared'
- if test "$aix_use_runtimelinking" = yes; then
- shared_flag="$shared_flag "'${wl}-G'
- fi
- else
- # not using gcc
- if test "$host_cpu" = ia64; then
- # VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release
- # chokes on -Wl,-G. The following line is correct:
- shared_flag='-G'
- else
- if test "$aix_use_runtimelinking" = yes; then
- shared_flag='${wl}-G'
- else
- shared_flag='${wl}-bM:SRE'
- fi
- fi
- fi
-
- # It seems that -bexpall does not export symbols beginning with
- # underscore (_), so it is better to generate a list of symbols to export.
- always_export_symbols_F77=yes
- if test "$aix_use_runtimelinking" = yes; then
- # Warning - without using the other runtime loading flags (-brtl),
- # -berok will link without error, but may produce a broken library.
- allow_undefined_flag_F77='-berok'
- # Determine the default libpath from the value encoded in an empty executable.
- cat >conftest.$ac_ext <<_ACEOF
- program main
-
- end
-_ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
- (eval $ac_link) 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } &&
- { ac_try='test -z "$ac_f77_werror_flag" || test ! -s conftest.err'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; } &&
- { ac_try='test -s conftest$ac_exeext'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
-
-aix_libpath=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; }
-}'`
-# Check for a 64-bit object if we didn't find anything.
-if test -z "$aix_libpath"; then aix_libpath=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; }
-}'`; fi
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-fi
-rm -f conftest.err conftest.$ac_objext \
- conftest$ac_exeext conftest.$ac_ext
-if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
-
- hardcode_libdir_flag_spec_F77='${wl}-blibpath:$libdir:'"$aix_libpath"
- archive_expsym_cmds_F77="\$CC"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then echo "${wl}${allow_undefined_flag}"; else :; fi` '"\${wl}$exp_sym_flag:\$export_symbols $shared_flag"
- else
- if test "$host_cpu" = ia64; then
- hardcode_libdir_flag_spec_F77='${wl}-R $libdir:/usr/lib:/lib'
- allow_undefined_flag_F77="-z nodefs"
- archive_expsym_cmds_F77="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$exp_sym_flag:\$export_symbols"
- else
- # Determine the default libpath from the value encoded in an empty executable.
- cat >conftest.$ac_ext <<_ACEOF
- program main
-
- end
-_ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
- (eval $ac_link) 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } &&
- { ac_try='test -z "$ac_f77_werror_flag" || test ! -s conftest.err'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; } &&
- { ac_try='test -s conftest$ac_exeext'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
-
-aix_libpath=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; }
-}'`
-# Check for a 64-bit object if we didn't find anything.
-if test -z "$aix_libpath"; then aix_libpath=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; }
-}'`; fi
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-fi
-rm -f conftest.err conftest.$ac_objext \
- conftest$ac_exeext conftest.$ac_ext
-if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
-
- hardcode_libdir_flag_spec_F77='${wl}-blibpath:$libdir:'"$aix_libpath"
- # Warning - without using the other run time loading flags,
- # -berok will link without error, but may produce a broken library.
- no_undefined_flag_F77=' ${wl}-bernotok'
- allow_undefined_flag_F77=' ${wl}-berok'
- # Exported symbols can be pulled into shared objects from archives
- whole_archive_flag_spec_F77='$convenience'
- archive_cmds_need_lc_F77=yes
- # This is similar to how AIX traditionally builds its shared libraries.
- archive_expsym_cmds_F77="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs ${wl}-bnoentry $compiler_flags ${wl}-bE:$export_symbols${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname'
- fi
- fi
- ;;
-
- amigaos*)
- archive_cmds_F77='$rm $output_objdir/a2ixlibrary.data~$echo "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$echo "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$echo "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$echo "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)'
- hardcode_libdir_flag_spec_F77='-L$libdir'
- hardcode_minus_L_F77=yes
- # see comment about different semantics on the GNU ld section
- ld_shlibs_F77=no
- ;;
-
- bsdi[45]*)
- export_dynamic_flag_spec_F77=-rdynamic
- ;;
-
- cygwin* | mingw* | pw32*)
- # When not using gcc, we currently assume that we are using
- # Microsoft Visual C++.
- # hardcode_libdir_flag_spec is actually meaningless, as there is
- # no search path for DLLs.
- hardcode_libdir_flag_spec_F77=' '
- allow_undefined_flag_F77=unsupported
- # Tell ltmain to make .lib files, not .a files.
- libext=lib
- # Tell ltmain to make .dll files, not .so files.
- shrext_cmds=".dll"
- # FIXME: Setting linknames here is a bad hack.
- archive_cmds_F77='$CC -o $lib $libobjs $compiler_flags `echo "$deplibs" | $SED -e '\''s/ -lc$//'\''` -link -dll~linknames='
- # The linker will automatically build a .lib file if we build a DLL.
- old_archive_From_new_cmds_F77='true'
- # FIXME: Should let the user specify the lib program.
- old_archive_cmds_F77='lib /OUT:$oldlib$oldobjs$old_deplibs'
- fix_srcfile_path_F77='`cygpath -w "$srcfile"`'
- enable_shared_with_static_runtimes_F77=yes
- ;;
-
- darwin* | rhapsody*)
- case $host_os in
- rhapsody* | darwin1.[012])
- allow_undefined_flag_F77='${wl}-undefined ${wl}suppress'
- ;;
- *) # Darwin 1.3 on
- if test -z ${MACOSX_DEPLOYMENT_TARGET} ; then
- allow_undefined_flag_F77='${wl}-flat_namespace ${wl}-undefined ${wl}suppress'
- else
- case ${MACOSX_DEPLOYMENT_TARGET} in
- 10.[012])
- allow_undefined_flag_F77='${wl}-flat_namespace ${wl}-undefined ${wl}suppress'
- ;;
- 10.*)
- allow_undefined_flag_F77='${wl}-undefined ${wl}dynamic_lookup'
- ;;
- esac
- fi
- ;;
- esac
- archive_cmds_need_lc_F77=no
- hardcode_direct_F77=no
- hardcode_automatic_F77=yes
- hardcode_shlibpath_var_F77=unsupported
- whole_archive_flag_spec_F77=''
- link_all_deplibs_F77=yes
- if test "$GCC" = yes ; then
- output_verbose_link_cmd='echo'
- archive_cmds_F77='$CC -dynamiclib $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring'
- module_cmds_F77='$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags'
- # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin lds
- archive_expsym_cmds_F77='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -dynamiclib $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
- module_expsym_cmds_F77='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
- else
- case $cc_basename in
- xlc*)
- output_verbose_link_cmd='echo'
- archive_cmds_F77='$CC -qmkshrobj $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-install_name ${wl}`echo $rpath/$soname` $verstring'
- module_cmds_F77='$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags'
- # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin lds
- archive_expsym_cmds_F77='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -qmkshrobj $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-install_name ${wl}$rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
- module_expsym_cmds_F77='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
- ;;
- *)
- ld_shlibs_F77=no
- ;;
- esac
- fi
- ;;
-
- dgux*)
- archive_cmds_F77='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
- hardcode_libdir_flag_spec_F77='-L$libdir'
- hardcode_shlibpath_var_F77=no
- ;;
-
- freebsd1*)
- ld_shlibs_F77=no
- ;;
-
- # FreeBSD 2.2.[012] allows us to include c++rt0.o to get C++ constructor
- # support. Future versions do this automatically, but an explicit c++rt0.o
- # does not break anything, and helps significantly (at the cost of a little
- # extra space).
- freebsd2.2*)
- archive_cmds_F77='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags /usr/lib/c++rt0.o'
- hardcode_libdir_flag_spec_F77='-R$libdir'
- hardcode_direct_F77=yes
- hardcode_shlibpath_var_F77=no
- ;;
-
- # Unfortunately, older versions of FreeBSD 2 do not have this feature.
- freebsd2*)
- archive_cmds_F77='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags'
- hardcode_direct_F77=yes
- hardcode_minus_L_F77=yes
- hardcode_shlibpath_var_F77=no
- ;;
-
- # FreeBSD 3 and greater uses gcc -shared to do shared libraries.
- freebsd* | dragonfly*)
- archive_cmds_F77='$CC -shared -o $lib $libobjs $deplibs $compiler_flags'
- hardcode_libdir_flag_spec_F77='-R$libdir'
- hardcode_direct_F77=yes
- hardcode_shlibpath_var_F77=no
- ;;
-
- # GNU/kFreeBSD uses gcc -shared to do shared libraries.
- kfreebsd*-gnu)
- archive_cmds_F77='$CC -shared -o $lib $libobjs $deplibs $compiler_flags'
- hardcode_libdir_flag_spec_F77='-R$libdir'
- hardcode_direct_F77=yes
- hardcode_shlibpath_var_F77=no
- link_all_deplibs_F77=no
- ;;
-
- hpux9*)
- if test "$GCC" = yes; then
- archive_cmds_F77='$rm $output_objdir/$soname~$CC -shared -fPIC ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $libobjs $deplibs $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
- else
- archive_cmds_F77='$rm $output_objdir/$soname~$LD -b +b $install_libdir -o $output_objdir/$soname $libobjs $deplibs $linker_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
- fi
- hardcode_libdir_flag_spec_F77='${wl}+b ${wl}$libdir'
- hardcode_libdir_separator_F77=:
- hardcode_direct_F77=yes
-
- # hardcode_minus_L: Not really in the search PATH,
- # but as the default location of the library.
- hardcode_minus_L_F77=yes
- export_dynamic_flag_spec_F77='${wl}-E'
- ;;
-
- hpux10*)
- if test "$GCC" = yes -a "$with_gnu_ld" = no; then
- archive_cmds_F77='$CC -shared -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
- else
- archive_cmds_F77='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags'
- fi
- if test "$with_gnu_ld" = no; then
- hardcode_libdir_flag_spec_F77='${wl}+b ${wl}$libdir'
- hardcode_libdir_separator_F77=:
-
- hardcode_direct_F77=yes
- export_dynamic_flag_spec_F77='${wl}-E'
-
- # hardcode_minus_L: Not really in the search PATH,
- # but as the default location of the library.
- hardcode_minus_L_F77=yes
- fi
- ;;
-
- hpux11*)
- if test "$GCC" = yes -a "$with_gnu_ld" = no; then
- case $host_cpu in
- hppa*64*)
- archive_cmds_F77='$CC -shared ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
- ;;
- ia64*)
- archive_cmds_F77='$CC -shared ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags'
- ;;
- *)
- archive_cmds_F77='$CC -shared -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
- ;;
- esac
- else
- case $host_cpu in
- hppa*64*)
- archive_cmds_F77='$CC -b ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
- ;;
- ia64*)
- archive_cmds_F77='$CC -b ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags'
- ;;
- *)
- archive_cmds_F77='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
- ;;
- esac
- fi
- if test "$with_gnu_ld" = no; then
- hardcode_libdir_flag_spec_F77='${wl}+b ${wl}$libdir'
- hardcode_libdir_separator_F77=:
-
- case $host_cpu in
- hppa*64*|ia64*)
- hardcode_libdir_flag_spec_ld_F77='+b $libdir'
- hardcode_direct_F77=no
- hardcode_shlibpath_var_F77=no
- ;;
- *)
- hardcode_direct_F77=yes
- export_dynamic_flag_spec_F77='${wl}-E'
-
- # hardcode_minus_L: Not really in the search PATH,
- # but as the default location of the library.
- hardcode_minus_L_F77=yes
- ;;
- esac
- fi
- ;;
-
- irix5* | irix6* | nonstopux*)
- if test "$GCC" = yes; then
- archive_cmds_F77='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
- else
- archive_cmds_F77='$LD -shared $libobjs $deplibs $linker_flags -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib'
- hardcode_libdir_flag_spec_ld_F77='-rpath $libdir'
- fi
- hardcode_libdir_flag_spec_F77='${wl}-rpath ${wl}$libdir'
- hardcode_libdir_separator_F77=:
- link_all_deplibs_F77=yes
- ;;
-
- netbsd* | netbsdelf*-gnu | knetbsd*-gnu)
- if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then
- archive_cmds_F77='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' # a.out
- else
- archive_cmds_F77='$LD -shared -o $lib $libobjs $deplibs $linker_flags' # ELF
- fi
- hardcode_libdir_flag_spec_F77='-R$libdir'
- hardcode_direct_F77=yes
- hardcode_shlibpath_var_F77=no
- ;;
-
- newsos6)
- archive_cmds_F77='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
- hardcode_direct_F77=yes
- hardcode_libdir_flag_spec_F77='${wl}-rpath ${wl}$libdir'
- hardcode_libdir_separator_F77=:
- hardcode_shlibpath_var_F77=no
- ;;
-
- openbsd*)
- hardcode_direct_F77=yes
- hardcode_shlibpath_var_F77=no
- if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
- archive_cmds_F77='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags'
- archive_expsym_cmds_F77='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-retain-symbols-file,$export_symbols'
- hardcode_libdir_flag_spec_F77='${wl}-rpath,$libdir'
- export_dynamic_flag_spec_F77='${wl}-E'
- else
- case $host_os in
- openbsd[01].* | openbsd2.[0-7] | openbsd2.[0-7].*)
- archive_cmds_F77='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags'
- hardcode_libdir_flag_spec_F77='-R$libdir'
- ;;
- *)
- archive_cmds_F77='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags'
- hardcode_libdir_flag_spec_F77='${wl}-rpath,$libdir'
- ;;
- esac
- fi
- ;;
-
- os2*)
- hardcode_libdir_flag_spec_F77='-L$libdir'
- hardcode_minus_L_F77=yes
- allow_undefined_flag_F77=unsupported
- archive_cmds_F77='$echo "LIBRARY $libname INITINSTANCE" > $output_objdir/$libname.def~$echo "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~$echo DATA >> $output_objdir/$libname.def~$echo " SINGLE NONSHARED" >> $output_objdir/$libname.def~$echo EXPORTS >> $output_objdir/$libname.def~emxexp $libobjs >> $output_objdir/$libname.def~$CC -Zdll -Zcrtdll -o $lib $libobjs $deplibs $compiler_flags $output_objdir/$libname.def'
- old_archive_From_new_cmds_F77='emximp -o $output_objdir/$libname.a $output_objdir/$libname.def'
- ;;
-
- osf3*)
- if test "$GCC" = yes; then
- allow_undefined_flag_F77=' ${wl}-expect_unresolved ${wl}\*'
- archive_cmds_F77='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
- else
- allow_undefined_flag_F77=' -expect_unresolved \*'
- archive_cmds_F77='$LD -shared${allow_undefined_flag} $libobjs $deplibs $linker_flags -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib'
- fi
- hardcode_libdir_flag_spec_F77='${wl}-rpath ${wl}$libdir'
- hardcode_libdir_separator_F77=:
- ;;
-
- osf4* | osf5*) # as osf3* with the addition of -msym flag
- if test "$GCC" = yes; then
- allow_undefined_flag_F77=' ${wl}-expect_unresolved ${wl}\*'
- archive_cmds_F77='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
- hardcode_libdir_flag_spec_F77='${wl}-rpath ${wl}$libdir'
- else
- allow_undefined_flag_F77=' -expect_unresolved \*'
- archive_cmds_F77='$LD -shared${allow_undefined_flag} $libobjs $deplibs $linker_flags -msym -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib'
- archive_expsym_cmds_F77='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done; echo "-hidden">> $lib.exp~
- $LD -shared${allow_undefined_flag} -input $lib.exp $linker_flags $libobjs $deplibs -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib~$rm $lib.exp'
-
- # Both c and cxx compiler support -rpath directly
- hardcode_libdir_flag_spec_F77='-rpath $libdir'
- fi
- hardcode_libdir_separator_F77=:
- ;;
-
- solaris*)
- no_undefined_flag_F77=' -z text'
- if test "$GCC" = yes; then
- wlarc='${wl}'
- archive_cmds_F77='$CC -shared ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
- archive_expsym_cmds_F77='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~
- $CC -shared ${wl}-M ${wl}$lib.exp ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags~$rm $lib.exp'
- else
- wlarc=''
- archive_cmds_F77='$LD -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $linker_flags'
- archive_expsym_cmds_F77='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~
- $LD -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linker_flags~$rm $lib.exp'
- fi
- hardcode_libdir_flag_spec_F77='-R$libdir'
- hardcode_shlibpath_var_F77=no
- case $host_os in
- solaris2.[0-5] | solaris2.[0-5].*) ;;
- *)
- # The compiler driver will combine linker options so we
- # cannot just pass the convience library names through
- # without $wl, iff we do not link with $LD.
- # Luckily, gcc supports the same syntax we need for Sun Studio.
- # Supported since Solaris 2.6 (maybe 2.5.1?)
- case $wlarc in
- '')
- whole_archive_flag_spec_F77='-z allextract$convenience -z defaultextract' ;;
- *)
- whole_archive_flag_spec_F77='${wl}-z ${wl}allextract`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}-z ${wl}defaultextract' ;;
- esac ;;
- esac
- link_all_deplibs_F77=yes
- ;;
-
- sunos4*)
- if test "x$host_vendor" = xsequent; then
- # Use $CC to link under sequent, because it throws in some extra .o
- # files that make .init and .fini sections work.
- archive_cmds_F77='$CC -G ${wl}-h $soname -o $lib $libobjs $deplibs $compiler_flags'
- else
- archive_cmds_F77='$LD -assert pure-text -Bstatic -o $lib $libobjs $deplibs $linker_flags'
- fi
- hardcode_libdir_flag_spec_F77='-L$libdir'
- hardcode_direct_F77=yes
- hardcode_minus_L_F77=yes
- hardcode_shlibpath_var_F77=no
- ;;
-
- sysv4)
- case $host_vendor in
- sni)
- archive_cmds_F77='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
- hardcode_direct_F77=yes # is this really true???
- ;;
- siemens)
- ## LD is ld it makes a PLAMLIB
- ## CC just makes a GrossModule.
- archive_cmds_F77='$LD -G -o $lib $libobjs $deplibs $linker_flags'
- reload_cmds_F77='$CC -r -o $output$reload_objs'
- hardcode_direct_F77=no
- ;;
- motorola)
- archive_cmds_F77='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
- hardcode_direct_F77=no #Motorola manual says yes, but my tests say they lie
- ;;
- esac
- runpath_var='LD_RUN_PATH'
- hardcode_shlibpath_var_F77=no
- ;;
-
- sysv4.3*)
- archive_cmds_F77='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
- hardcode_shlibpath_var_F77=no
- export_dynamic_flag_spec_F77='-Bexport'
- ;;
-
- sysv4*MP*)
- if test -d /usr/nec; then
- archive_cmds_F77='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
- hardcode_shlibpath_var_F77=no
- runpath_var=LD_RUN_PATH
- hardcode_runpath_var=yes
- ld_shlibs_F77=yes
- fi
- ;;
-
- sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[01].[10]* | unixware7*)
- no_undefined_flag_F77='${wl}-z,text'
- archive_cmds_need_lc_F77=no
- hardcode_shlibpath_var_F77=no
- runpath_var='LD_RUN_PATH'
-
- if test "$GCC" = yes; then
- archive_cmds_F77='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
- archive_expsym_cmds_F77='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
- else
- archive_cmds_F77='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
- archive_expsym_cmds_F77='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
- fi
- ;;
-
- sysv5* | sco3.2v5* | sco5v6*)
- # Note: We can NOT use -z defs as we might desire, because we do not
- # link with -lc, and that would cause any symbols used from libc to
- # always be unresolved, which means just about no library would
- # ever link correctly. If we're not using GNU ld we use -z text
- # though, which does catch some bad symbols but isn't as heavy-handed
- # as -z defs.
- no_undefined_flag_F77='${wl}-z,text'
- allow_undefined_flag_F77='${wl}-z,nodefs'
- archive_cmds_need_lc_F77=no
- hardcode_shlibpath_var_F77=no
- hardcode_libdir_flag_spec_F77='`test -z "$SCOABSPATH" && echo ${wl}-R,$libdir`'
- hardcode_libdir_separator_F77=':'
- link_all_deplibs_F77=yes
- export_dynamic_flag_spec_F77='${wl}-Bexport'
- runpath_var='LD_RUN_PATH'
-
- if test "$GCC" = yes; then
- archive_cmds_F77='$CC -shared ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags'
- archive_expsym_cmds_F77='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags'
- else
- archive_cmds_F77='$CC -G ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags'
- archive_expsym_cmds_F77='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags'
- fi
- ;;
-
- uts4*)
- archive_cmds_F77='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
- hardcode_libdir_flag_spec_F77='-L$libdir'
- hardcode_shlibpath_var_F77=no
- ;;
-
- *)
- ld_shlibs_F77=no
- ;;
- esac
- fi
-
-echo "$as_me:$LINENO: result: $ld_shlibs_F77" >&5
-echo "${ECHO_T}$ld_shlibs_F77" >&6
-test "$ld_shlibs_F77" = no && can_build_shared=no
-
-#
-# Do we need to explicitly link libc?
-#
-case "x$archive_cmds_need_lc_F77" in
-x|xyes)
- # Assume -lc should be added
- archive_cmds_need_lc_F77=yes
-
- if test "$enable_shared" = yes && test "$GCC" = yes; then
- case $archive_cmds_F77 in
- *'~'*)
- # FIXME: we may have to deal with multi-command sequences.
- ;;
- '$CC '*)
- # Test whether the compiler implicitly links with -lc since on some
- # systems, -lgcc has to come before -lc. If gcc already passes -lc
- # to ld, don't add -lc before -lgcc.
- echo "$as_me:$LINENO: checking whether -lc should be explicitly linked in" >&5
-echo $ECHO_N "checking whether -lc should be explicitly linked in... $ECHO_C" >&6
- $rm conftest*
- printf "$lt_simple_compile_test_code" > conftest.$ac_ext
-
- if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
- (eval $ac_compile) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } 2>conftest.err; then
- soname=conftest
- lib=conftest
- libobjs=conftest.$ac_objext
- deplibs=
- wl=$lt_prog_compiler_wl_F77
- pic_flag=$lt_prog_compiler_pic_F77
- compiler_flags=-v
- linker_flags=-v
- verstring=
- output_objdir=.
- libname=conftest
- lt_save_allow_undefined_flag=$allow_undefined_flag_F77
- allow_undefined_flag_F77=
- if { (eval echo "$as_me:$LINENO: \"$archive_cmds_F77 2\>\&1 \| grep \" -lc \" \>/dev/null 2\>\&1\"") >&5
- (eval $archive_cmds_F77 2\>\&1 \| grep \" -lc \" \>/dev/null 2\>\&1) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }
- then
- archive_cmds_need_lc_F77=no
- else
- archive_cmds_need_lc_F77=yes
- fi
- allow_undefined_flag_F77=$lt_save_allow_undefined_flag
- else
- cat conftest.err 1>&5
- fi
- $rm conftest*
- echo "$as_me:$LINENO: result: $archive_cmds_need_lc_F77" >&5
-echo "${ECHO_T}$archive_cmds_need_lc_F77" >&6
- ;;
- esac
- fi
- ;;
-esac
-
-echo "$as_me:$LINENO: checking dynamic linker characteristics" >&5
-echo $ECHO_N "checking dynamic linker characteristics... $ECHO_C" >&6
-library_names_spec=
-libname_spec='lib$name'
-soname_spec=
-shrext_cmds=".so"
-postinstall_cmds=
-postuninstall_cmds=
-finish_cmds=
-finish_eval=
-shlibpath_var=
-shlibpath_overrides_runpath=unknown
-version_type=none
-dynamic_linker="$host_os ld.so"
-sys_lib_dlsearch_path_spec="/lib /usr/lib"
-if test "$GCC" = yes; then
- sys_lib_search_path_spec=`$CC -print-search-dirs | grep "^libraries:" | $SED -e "s/^libraries://" -e "s,=/,/,g"`
- if echo "$sys_lib_search_path_spec" | grep ';' >/dev/null ; then
- # if the path contains ";" then we assume it to be the separator
- # otherwise default to the standard path separator (i.e. ":") - it is
- # assumed that no part of a normal pathname contains ";" but that should
- # okay in the real world where ";" in dirpaths is itself problematic.
- sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'`
- else
- sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"`
- fi
-else
- sys_lib_search_path_spec="/lib /usr/lib /usr/local/lib"
-fi
-need_lib_prefix=unknown
-hardcode_into_libs=no
-
-# when you set need_version to no, make sure it does not cause -set_version
-# flags to be left without arguments
-need_version=unknown
-
-case $host_os in
-aix3*)
- version_type=linux
- library_names_spec='${libname}${release}${shared_ext}$versuffix $libname.a'
- shlibpath_var=LIBPATH
-
- # AIX 3 has no versioning support, so we append a major version to the name.
- soname_spec='${libname}${release}${shared_ext}$major'
- ;;
-
-aix4* | aix5*)
- version_type=linux
- need_lib_prefix=no
- need_version=no
- hardcode_into_libs=yes
- if test "$host_cpu" = ia64; then
- # AIX 5 supports IA64
- library_names_spec='${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext}$versuffix $libname${shared_ext}'
- shlibpath_var=LD_LIBRARY_PATH
- else
- # With GCC up to 2.95.x, collect2 would create an import file
- # for dependence libraries. The import file would start with
- # the line `#! .'. This would cause the generated library to
- # depend on `.', always an invalid library. This was fixed in
- # development snapshots of GCC prior to 3.0.
- case $host_os in
- aix4 | aix4.[01] | aix4.[01].*)
- if { echo '#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 97)'
- echo ' yes '
- echo '#endif'; } | ${CC} -E - | grep yes > /dev/null; then
- :
- else
- can_build_shared=no
- fi
- ;;
- esac
- # AIX (on Power*) has no versioning support, so currently we can not hardcode correct
- # soname into executable. Probably we can add versioning support to
- # collect2, so additional links can be useful in future.
- if test "$aix_use_runtimelinking" = yes; then
- # If using run time linking (on AIX 4.2 or later) use lib<name>.so
- # instead of lib<name>.a to let people know that these are not
- # typical AIX shared libraries.
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
- else
- # We preserve .a as extension for shared libraries through AIX4.2
- # and later when we are not doing run time linking.
- library_names_spec='${libname}${release}.a $libname.a'
- soname_spec='${libname}${release}${shared_ext}$major'
- fi
- shlibpath_var=LIBPATH
- fi
- ;;
-
-amigaos*)
- library_names_spec='$libname.ixlibrary $libname.a'
- # Create ${libname}_ixlibrary.a entries in /sys/libs.
- finish_eval='for lib in `ls $libdir/*.ixlibrary 2>/dev/null`; do libname=`$echo "X$lib" | $Xsed -e '\''s%^.*/\([^/]*\)\.ixlibrary$%\1%'\''`; test $rm /sys/libs/${libname}_ixlibrary.a; $show "cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a"; cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a || exit 1; done'
- ;;
-
-beos*)
- library_names_spec='${libname}${shared_ext}'
- dynamic_linker="$host_os ld.so"
- shlibpath_var=LIBRARY_PATH
- ;;
-
-bsdi[45]*)
- version_type=linux
- need_version=no
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
- soname_spec='${libname}${release}${shared_ext}$major'
- finish_cmds='PATH="\$PATH:/sbin" ldconfig $libdir'
- shlibpath_var=LD_LIBRARY_PATH
- sys_lib_search_path_spec="/shlib /usr/lib /usr/X11/lib /usr/contrib/lib /lib /usr/local/lib"
- sys_lib_dlsearch_path_spec="/shlib /usr/lib /usr/local/lib"
- # the default ld.so.conf also contains /usr/contrib/lib and
- # /usr/X11R6/lib (/usr/X11 is a link to /usr/X11R6), but let us allow
- # libtool to hard-code these into programs
- ;;
-
-cygwin* | mingw* | pw32*)
- version_type=windows
- shrext_cmds=".dll"
- need_version=no
- need_lib_prefix=no
-
- case $GCC,$host_os in
- yes,cygwin* | yes,mingw* | yes,pw32*)
- library_names_spec='$libname.dll.a'
- # DLL is installed to $(libdir)/../bin by postinstall_cmds
- postinstall_cmds='base_file=`basename \${file}`~
- dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i;echo \$dlname'\''`~
- dldir=$destdir/`dirname \$dlpath`~
- test -d \$dldir || mkdir -p \$dldir~
- $install_prog $dir/$dlname \$dldir/$dlname~
- chmod a+x \$dldir/$dlname'
- postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~
- dlpath=$dir/\$dldll~
- $rm \$dlpath'
- shlibpath_overrides_runpath=yes
-
- case $host_os in
- cygwin*)
- # Cygwin DLLs use 'cyg' prefix rather than 'lib'
- soname_spec='`echo ${libname} | sed -e 's/^lib/cyg/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}'
- sys_lib_search_path_spec="/usr/lib /lib/w32api /lib /usr/local/lib"
- ;;
- mingw*)
- # MinGW DLLs use traditional 'lib' prefix
- soname_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}'
- sys_lib_search_path_spec=`$CC -print-search-dirs | grep "^libraries:" | $SED -e "s/^libraries://" -e "s,=/,/,g"`
- if echo "$sys_lib_search_path_spec" | grep ';[c-zC-Z]:/' >/dev/null; then
- # It is most probably a Windows format PATH printed by
- # mingw gcc, but we are running on Cygwin. Gcc prints its search
- # path with ; separators, and with drive letters. We can handle the
- # drive letters (cygwin fileutils understands them), so leave them,
- # especially as we might pass files found there to a mingw objdump,
- # which wouldn't understand a cygwinified path. Ahh.
- sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'`
- else
- sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"`
- fi
- ;;
- pw32*)
- # pw32 DLLs use 'pw' prefix rather than 'lib'
- library_names_spec='`echo ${libname} | sed -e 's/^lib/pw/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}'
- ;;
- esac
- ;;
-
- *)
- library_names_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext} $libname.lib'
- ;;
- esac
- dynamic_linker='Win32 ld.exe'
- # FIXME: first we should search . and the directory the executable is in
- shlibpath_var=PATH
- ;;
-
-darwin* | rhapsody*)
- dynamic_linker="$host_os dyld"
- version_type=darwin
- need_lib_prefix=no
- need_version=no
- library_names_spec='${libname}${release}${versuffix}$shared_ext ${libname}${release}${major}$shared_ext ${libname}$shared_ext'
- soname_spec='${libname}${release}${major}$shared_ext'
- shlibpath_overrides_runpath=yes
- shlibpath_var=DYLD_LIBRARY_PATH
- shrext_cmds='`test .$module = .yes && echo .so || echo .dylib`'
- # Apple's gcc prints 'gcc -print-search-dirs' doesn't operate the same.
- if test "$GCC" = yes; then
- sys_lib_search_path_spec=`$CC -print-search-dirs | tr "\n" "$PATH_SEPARATOR" | sed -e 's/libraries:/@libraries:/' | tr "@" "\n" | grep "^libraries:" | sed -e "s/^libraries://" -e "s,=/,/,g" -e "s,$PATH_SEPARATOR, ,g" -e "s,.*,& /lib /usr/lib /usr/local/lib,g"`
- else
- sys_lib_search_path_spec='/lib /usr/lib /usr/local/lib'
- fi
- sys_lib_dlsearch_path_spec='/usr/local/lib /lib /usr/lib'
- ;;
-
-dgux*)
- version_type=linux
- need_lib_prefix=no
- need_version=no
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname$shared_ext'
- soname_spec='${libname}${release}${shared_ext}$major'
- shlibpath_var=LD_LIBRARY_PATH
- ;;
-
-freebsd1*)
- dynamic_linker=no
- ;;
-
-kfreebsd*-gnu)
- version_type=linux
- need_lib_prefix=no
- need_version=no
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
- soname_spec='${libname}${release}${shared_ext}$major'
- shlibpath_var=LD_LIBRARY_PATH
- shlibpath_overrides_runpath=no
- hardcode_into_libs=yes
- dynamic_linker='GNU ld.so'
- ;;
-
-freebsd* | dragonfly*)
- # DragonFly does not have aout. When/if they implement a new
- # versioning mechanism, adjust this.
- if test -x /usr/bin/objformat; then
- objformat=`/usr/bin/objformat`
- else
- case $host_os in
- freebsd[123]*) objformat=aout ;;
- *) objformat=elf ;;
- esac
- fi
- version_type=freebsd-$objformat
- case $version_type in
- freebsd-elf*)
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}'
- need_version=no
- need_lib_prefix=no
- ;;
- freebsd-*)
- library_names_spec='${libname}${release}${shared_ext}$versuffix $libname${shared_ext}$versuffix'
- need_version=yes
- ;;
- esac
- shlibpath_var=LD_LIBRARY_PATH
- case $host_os in
- freebsd2*)
- shlibpath_overrides_runpath=yes
- ;;
- freebsd3.[01]* | freebsdelf3.[01]*)
- shlibpath_overrides_runpath=yes
- hardcode_into_libs=yes
- ;;
- freebsd3.[2-9]* | freebsdelf3.[2-9]* | \
- freebsd4.[0-5] | freebsdelf4.[0-5] | freebsd4.1.1 | freebsdelf4.1.1)
- shlibpath_overrides_runpath=no
- hardcode_into_libs=yes
- ;;
- freebsd*) # from 4.6 on
- shlibpath_overrides_runpath=yes
- hardcode_into_libs=yes
- ;;
- esac
- ;;
-
-gnu*)
- version_type=linux
- need_lib_prefix=no
- need_version=no
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}'
- soname_spec='${libname}${release}${shared_ext}$major'
- shlibpath_var=LD_LIBRARY_PATH
- hardcode_into_libs=yes
- ;;
-
-hpux9* | hpux10* | hpux11*)
- # Give a soname corresponding to the major version so that dld.sl refuses to
- # link against other versions.
- version_type=sunos
- need_lib_prefix=no
- need_version=no
- case $host_cpu in
- ia64*)
- shrext_cmds='.so'
- hardcode_into_libs=yes
- dynamic_linker="$host_os dld.so"
- shlibpath_var=LD_LIBRARY_PATH
- shlibpath_overrides_runpath=yes # Unless +noenvvar is specified.
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
- soname_spec='${libname}${release}${shared_ext}$major'
- if test "X$HPUX_IA64_MODE" = X32; then
- sys_lib_search_path_spec="/usr/lib/hpux32 /usr/local/lib/hpux32 /usr/local/lib"
- else
- sys_lib_search_path_spec="/usr/lib/hpux64 /usr/local/lib/hpux64"
- fi
- sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec
- ;;
- hppa*64*)
- shrext_cmds='.sl'
- hardcode_into_libs=yes
- dynamic_linker="$host_os dld.sl"
- shlibpath_var=LD_LIBRARY_PATH # How should we handle SHLIB_PATH
- shlibpath_overrides_runpath=yes # Unless +noenvvar is specified.
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
- soname_spec='${libname}${release}${shared_ext}$major'
- sys_lib_search_path_spec="/usr/lib/pa20_64 /usr/ccs/lib/pa20_64"
- sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec
- ;;
- *)
- shrext_cmds='.sl'
- dynamic_linker="$host_os dld.sl"
- shlibpath_var=SHLIB_PATH
- shlibpath_overrides_runpath=no # +s is required to enable SHLIB_PATH
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
- soname_spec='${libname}${release}${shared_ext}$major'
- ;;
- esac
- # HP-UX runs *really* slowly unless shared libraries are mode 555.
- postinstall_cmds='chmod 555 $lib'
- ;;
-
-interix3*)
- version_type=linux
- need_lib_prefix=no
- need_version=no
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
- soname_spec='${libname}${release}${shared_ext}$major'
- dynamic_linker='Interix 3.x ld.so.1 (PE, like ELF)'
- shlibpath_var=LD_LIBRARY_PATH
- shlibpath_overrides_runpath=no
- hardcode_into_libs=yes
- ;;
-
-irix5* | irix6* | nonstopux*)
- case $host_os in
- nonstopux*) version_type=nonstopux ;;
- *)
- if test "$lt_cv_prog_gnu_ld" = yes; then
- version_type=linux
- else
- version_type=irix
- fi ;;
- esac
- need_lib_prefix=no
- need_version=no
- soname_spec='${libname}${release}${shared_ext}$major'
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext} $libname${shared_ext}'
- case $host_os in
- irix5* | nonstopux*)
- libsuff= shlibsuff=
- ;;
- *)
- case $LD in # libtool.m4 will add one of these switches to LD
- *-32|*"-32 "|*-melf32bsmip|*"-melf32bsmip ")
- libsuff= shlibsuff= libmagic=32-bit;;
- *-n32|*"-n32 "|*-melf32bmipn32|*"-melf32bmipn32 ")
- libsuff=32 shlibsuff=N32 libmagic=N32;;
- *-64|*"-64 "|*-melf64bmip|*"-melf64bmip ")
- libsuff=64 shlibsuff=64 libmagic=64-bit;;
- *) libsuff= shlibsuff= libmagic=never-match;;
- esac
- ;;
- esac
- shlibpath_var=LD_LIBRARY${shlibsuff}_PATH
- shlibpath_overrides_runpath=no
- sys_lib_search_path_spec="/usr/lib${libsuff} /lib${libsuff} /usr/local/lib${libsuff}"
- sys_lib_dlsearch_path_spec="/usr/lib${libsuff} /lib${libsuff}"
- hardcode_into_libs=yes
- ;;
-
-# No shared lib support for Linux oldld, aout, or coff.
-linux*oldld* | linux*aout* | linux*coff*)
- dynamic_linker=no
- ;;
-
-# This must be Linux ELF.
-linux*)
- version_type=linux
- need_lib_prefix=no
- need_version=no
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
- soname_spec='${libname}${release}${shared_ext}$major'
- finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir'
- shlibpath_var=LD_LIBRARY_PATH
- shlibpath_overrides_runpath=no
- # This implies no fast_install, which is unacceptable.
- # Some rework will be needed to allow for fast_install
- # before this can be enabled.
- hardcode_into_libs=yes
-
- # Append ld.so.conf contents to the search path
- if test -f /etc/ld.so.conf; then
- lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s", \$2)); skip = 1; } { if (!skip) print \$0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;s/[:, ]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;/^$/d' | tr '\n' ' '`
- sys_lib_dlsearch_path_spec="/lib /usr/lib $lt_ld_extra"
- fi
-
- # We used to test for /lib/ld.so.1 and disable shared libraries on
- # powerpc, because MkLinux only supported shared libraries with the
- # GNU dynamic linker. Since this was broken with cross compilers,
- # most powerpc-linux boxes support dynamic linking these days and
- # people can always --disable-shared, the test was removed, and we
- # assume the GNU/Linux dynamic linker is in use.
- dynamic_linker='GNU/Linux ld.so'
- ;;
-
-netbsdelf*-gnu)
- version_type=linux
- need_lib_prefix=no
- need_version=no
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
- soname_spec='${libname}${release}${shared_ext}$major'
- shlibpath_var=LD_LIBRARY_PATH
- shlibpath_overrides_runpath=no
- hardcode_into_libs=yes
- dynamic_linker='NetBSD ld.elf_so'
- ;;
-
-knetbsd*-gnu)
- version_type=linux
- need_lib_prefix=no
- need_version=no
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
- soname_spec='${libname}${release}${shared_ext}$major'
- shlibpath_var=LD_LIBRARY_PATH
- shlibpath_overrides_runpath=no
- hardcode_into_libs=yes
- dynamic_linker='GNU ld.so'
- ;;
-
-netbsd*)
- version_type=sunos
- need_lib_prefix=no
- need_version=no
- if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
- finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir'
- dynamic_linker='NetBSD (a.out) ld.so'
- else
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
- soname_spec='${libname}${release}${shared_ext}$major'
- dynamic_linker='NetBSD ld.elf_so'
- fi
- shlibpath_var=LD_LIBRARY_PATH
- shlibpath_overrides_runpath=yes
- hardcode_into_libs=yes
- ;;
-
-newsos6)
- version_type=linux
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
- shlibpath_var=LD_LIBRARY_PATH
- shlibpath_overrides_runpath=yes
- ;;
-
-nto-qnx*)
- version_type=linux
- need_lib_prefix=no
- need_version=no
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
- soname_spec='${libname}${release}${shared_ext}$major'
- shlibpath_var=LD_LIBRARY_PATH
- shlibpath_overrides_runpath=yes
- ;;
-
-openbsd*)
- version_type=sunos
- sys_lib_dlsearch_path_spec="/usr/lib"
- need_lib_prefix=no
- # Some older versions of OpenBSD (3.3 at least) *do* need versioned libs.
- case $host_os in
- openbsd3.3 | openbsd3.3.*) need_version=yes ;;
- *) need_version=no ;;
- esac
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
- finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir'
- shlibpath_var=LD_LIBRARY_PATH
- if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
- case $host_os in
- openbsd2.[89] | openbsd2.[89].*)
- shlibpath_overrides_runpath=no
- ;;
- *)
- shlibpath_overrides_runpath=yes
- ;;
- esac
- else
- shlibpath_overrides_runpath=yes
- fi
- ;;
-
-os2*)
- libname_spec='$name'
- shrext_cmds=".dll"
- need_lib_prefix=no
- library_names_spec='$libname${shared_ext} $libname.a'
- dynamic_linker='OS/2 ld.exe'
- shlibpath_var=LIBPATH
- ;;
-
-osf3* | osf4* | osf5*)
- version_type=osf
- need_lib_prefix=no
- need_version=no
- soname_spec='${libname}${release}${shared_ext}$major'
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
- shlibpath_var=LD_LIBRARY_PATH
- sys_lib_search_path_spec="/usr/shlib /usr/ccs/lib /usr/lib/cmplrs/cc /usr/lib /usr/local/lib /var/shlib"
- sys_lib_dlsearch_path_spec="$sys_lib_search_path_spec"
- ;;
-
-solaris*)
- version_type=linux
- need_lib_prefix=no
- need_version=no
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
- soname_spec='${libname}${release}${shared_ext}$major'
- shlibpath_var=LD_LIBRARY_PATH
- shlibpath_overrides_runpath=yes
- hardcode_into_libs=yes
- # ldd complains unless libraries are executable
- postinstall_cmds='chmod +x $lib'
- ;;
-
-sunos4*)
- version_type=sunos
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
- finish_cmds='PATH="\$PATH:/usr/etc" ldconfig $libdir'
- shlibpath_var=LD_LIBRARY_PATH
- shlibpath_overrides_runpath=yes
- if test "$with_gnu_ld" = yes; then
- need_lib_prefix=no
- fi
- need_version=yes
- ;;
-
-sysv4 | sysv4.3*)
- version_type=linux
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
- soname_spec='${libname}${release}${shared_ext}$major'
- shlibpath_var=LD_LIBRARY_PATH
- case $host_vendor in
- sni)
- shlibpath_overrides_runpath=no
- need_lib_prefix=no
- export_dynamic_flag_spec='${wl}-Blargedynsym'
- runpath_var=LD_RUN_PATH
- ;;
- siemens)
- need_lib_prefix=no
- ;;
- motorola)
- need_lib_prefix=no
- need_version=no
- shlibpath_overrides_runpath=no
- sys_lib_search_path_spec='/lib /usr/lib /usr/ccs/lib'
- ;;
- esac
- ;;
-
-sysv4*MP*)
- if test -d /usr/nec ;then
- version_type=linux
- library_names_spec='$libname${shared_ext}.$versuffix $libname${shared_ext}.$major $libname${shared_ext}'
- soname_spec='$libname${shared_ext}.$major'
- shlibpath_var=LD_LIBRARY_PATH
- fi
- ;;
-
-sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*)
- version_type=freebsd-elf
- need_lib_prefix=no
- need_version=no
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}'
- soname_spec='${libname}${release}${shared_ext}$major'
- shlibpath_var=LD_LIBRARY_PATH
- hardcode_into_libs=yes
- if test "$with_gnu_ld" = yes; then
- sys_lib_search_path_spec='/usr/local/lib /usr/gnu/lib /usr/ccs/lib /usr/lib /lib'
- shlibpath_overrides_runpath=no
- else
- sys_lib_search_path_spec='/usr/ccs/lib /usr/lib'
- shlibpath_overrides_runpath=yes
- case $host_os in
- sco3.2v5*)
- sys_lib_search_path_spec="$sys_lib_search_path_spec /lib"
- ;;
- esac
- fi
- sys_lib_dlsearch_path_spec='/usr/lib'
- ;;
-
-uts4*)
- version_type=linux
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
- soname_spec='${libname}${release}${shared_ext}$major'
- shlibpath_var=LD_LIBRARY_PATH
- ;;
-
-*)
- dynamic_linker=no
- ;;
-esac
-echo "$as_me:$LINENO: result: $dynamic_linker" >&5
-echo "${ECHO_T}$dynamic_linker" >&6
-test "$dynamic_linker" = no && can_build_shared=no
-
-variables_saved_for_relink="PATH $shlibpath_var $runpath_var"
-if test "$GCC" = yes; then
- variables_saved_for_relink="$variables_saved_for_relink GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH"
-fi
-
-echo "$as_me:$LINENO: checking how to hardcode library paths into programs" >&5
-echo $ECHO_N "checking how to hardcode library paths into programs... $ECHO_C" >&6
-hardcode_action_F77=
-if test -n "$hardcode_libdir_flag_spec_F77" || \
- test -n "$runpath_var_F77" || \
- test "X$hardcode_automatic_F77" = "Xyes" ; then
-
- # We can hardcode non-existant directories.
- if test "$hardcode_direct_F77" != no &&
- # If the only mechanism to avoid hardcoding is shlibpath_var, we
- # have to relink, otherwise we might link with an installed library
- # when we should be linking with a yet-to-be-installed one
- ## test "$_LT_AC_TAGVAR(hardcode_shlibpath_var, F77)" != no &&
- test "$hardcode_minus_L_F77" != no; then
- # Linking always hardcodes the temporary library directory.
- hardcode_action_F77=relink
- else
- # We can link without hardcoding, and we can hardcode nonexisting dirs.
- hardcode_action_F77=immediate
- fi
-else
- # We cannot hardcode anything, or else we can only hardcode existing
- # directories.
- hardcode_action_F77=unsupported
-fi
-echo "$as_me:$LINENO: result: $hardcode_action_F77" >&5
-echo "${ECHO_T}$hardcode_action_F77" >&6
-
-if test "$hardcode_action_F77" = relink; then
- # Fast installation is not supported
- enable_fast_install=no
-elif test "$shlibpath_overrides_runpath" = yes ||
- test "$enable_shared" = no; then
- # Fast installation is not necessary
- enable_fast_install=needless
-fi
-
-
-# The else clause should only fire when bootstrapping the
-# libtool distribution, otherwise you forgot to ship ltmain.sh
-# with your package, and you will get complaints that there are
-# no rules to generate ltmain.sh.
-if test -f "$ltmain"; then
- # See if we are running on zsh, and set the options which allow our commands through
- # without removal of \ escapes.
- if test -n "${ZSH_VERSION+set}" ; then
- setopt NO_GLOB_SUBST
- fi
- # Now quote all the things that may contain metacharacters while being
- # careful not to overquote the AC_SUBSTed values. We take copies of the
- # variables and quote the copies for generation of the libtool script.
- for var in echo old_CC old_CFLAGS AR AR_FLAGS EGREP RANLIB LN_S LTCC LTCFLAGS NM \
- SED SHELL STRIP \
- libname_spec library_names_spec soname_spec extract_expsyms_cmds \
- old_striplib striplib file_magic_cmd finish_cmds finish_eval \
- deplibs_check_method reload_flag reload_cmds need_locks \
- lt_cv_sys_global_symbol_pipe lt_cv_sys_global_symbol_to_cdecl \
- lt_cv_sys_global_symbol_to_c_name_address \
- sys_lib_search_path_spec sys_lib_dlsearch_path_spec \
- old_postinstall_cmds old_postuninstall_cmds \
- compiler_F77 \
- CC_F77 \
- LD_F77 \
- lt_prog_compiler_wl_F77 \
- lt_prog_compiler_pic_F77 \
- lt_prog_compiler_static_F77 \
- lt_prog_compiler_no_builtin_flag_F77 \
- export_dynamic_flag_spec_F77 \
- thread_safe_flag_spec_F77 \
- whole_archive_flag_spec_F77 \
- enable_shared_with_static_runtimes_F77 \
- old_archive_cmds_F77 \
- old_archive_from_new_cmds_F77 \
- predep_objects_F77 \
- postdep_objects_F77 \
- predeps_F77 \
- postdeps_F77 \
- compiler_lib_search_path_F77 \
- archive_cmds_F77 \
- archive_expsym_cmds_F77 \
- postinstall_cmds_F77 \
- postuninstall_cmds_F77 \
- old_archive_from_expsyms_cmds_F77 \
- allow_undefined_flag_F77 \
- no_undefined_flag_F77 \
- export_symbols_cmds_F77 \
- hardcode_libdir_flag_spec_F77 \
- hardcode_libdir_flag_spec_ld_F77 \
- hardcode_libdir_separator_F77 \
- hardcode_automatic_F77 \
- module_cmds_F77 \
- module_expsym_cmds_F77 \
- lt_cv_prog_compiler_c_o_F77 \
- exclude_expsyms_F77 \
- include_expsyms_F77; do
-
- case $var in
- old_archive_cmds_F77 | \
- old_archive_from_new_cmds_F77 | \
- archive_cmds_F77 | \
- archive_expsym_cmds_F77 | \
- module_cmds_F77 | \
- module_expsym_cmds_F77 | \
- old_archive_from_expsyms_cmds_F77 | \
- export_symbols_cmds_F77 | \
- extract_expsyms_cmds | reload_cmds | finish_cmds | \
- postinstall_cmds | postuninstall_cmds | \
- old_postinstall_cmds | old_postuninstall_cmds | \
- sys_lib_search_path_spec | sys_lib_dlsearch_path_spec)
- # Double-quote double-evaled strings.
- eval "lt_$var=\\\"\`\$echo \"X\$$var\" | \$Xsed -e \"\$double_quote_subst\" -e \"\$sed_quote_subst\" -e \"\$delay_variable_subst\"\`\\\""
- ;;
- *)
- eval "lt_$var=\\\"\`\$echo \"X\$$var\" | \$Xsed -e \"\$sed_quote_subst\"\`\\\""
- ;;
- esac
- done
-
- case $lt_echo in
- *'\$0 --fallback-echo"')
- lt_echo=`$echo "X$lt_echo" | $Xsed -e 's/\\\\\\\$0 --fallback-echo"$/$0 --fallback-echo"/'`
- ;;
- esac
-
-cfgfile="$ofile"
-
- cat <<__EOF__ >> "$cfgfile"
-# ### BEGIN LIBTOOL TAG CONFIG: $tagname
-
-# Libtool was configured on host `(hostname || uname -n) 2>/dev/null | sed 1q`:
-
-# Shell to use when invoking shell scripts.
-SHELL=$lt_SHELL
-
-# Whether or not to build shared libraries.
-build_libtool_libs=$enable_shared
-
-# Whether or not to build static libraries.
-build_old_libs=$enable_static
-
-# Whether or not to add -lc for building shared libraries.
-build_libtool_need_lc=$archive_cmds_need_lc_F77
-
-# Whether or not to disallow shared libs when runtime libs are static
-allow_libtool_libs_with_static_runtimes=$enable_shared_with_static_runtimes_F77
-
-# Whether or not to optimize for fast installation.
-fast_install=$enable_fast_install
-
-# The host system.
-host_alias=$host_alias
-host=$host
-host_os=$host_os
-
-# The build system.
-build_alias=$build_alias
-build=$build
-build_os=$build_os
-
-# An echo program that does not interpret backslashes.
-echo=$lt_echo
-
-# The archiver.
-AR=$lt_AR
-AR_FLAGS=$lt_AR_FLAGS
-
-# A C compiler.
-LTCC=$lt_LTCC
-
-# LTCC compiler flags.
-LTCFLAGS=$lt_LTCFLAGS
-
-# A language-specific compiler.
-CC=$lt_compiler_F77
-
-# Is the compiler the GNU C compiler?
-with_gcc=$GCC_F77
-
-# An ERE matcher.
-EGREP=$lt_EGREP
-
-# The linker used to build libraries.
-LD=$lt_LD_F77
-
-# Whether we need hard or soft links.
-LN_S=$lt_LN_S
-
-# A BSD-compatible nm program.
-NM=$lt_NM
-
-# A symbol stripping program
-STRIP=$lt_STRIP
-
-# Used to examine libraries when file_magic_cmd begins "file"
-MAGIC_CMD=$MAGIC_CMD
-
-# Used on cygwin: DLL creation program.
-DLLTOOL="$DLLTOOL"
-
-# Used on cygwin: object dumper.
-OBJDUMP="$OBJDUMP"
-
-# Used on cygwin: assembler.
-AS="$AS"
-
-# The name of the directory that contains temporary libtool files.
-objdir=$objdir
-
-# How to create reloadable object files.
-reload_flag=$lt_reload_flag
-reload_cmds=$lt_reload_cmds
-
-# How to pass a linker flag through the compiler.
-wl=$lt_lt_prog_compiler_wl_F77
-
-# Object file suffix (normally "o").
-objext="$ac_objext"
-
-# Old archive suffix (normally "a").
-libext="$libext"
-
-# Shared library suffix (normally ".so").
-shrext_cmds='$shrext_cmds'
-
-# Executable file suffix (normally "").
-exeext="$exeext"
-
-# Additional compiler flags for building library objects.
-pic_flag=$lt_lt_prog_compiler_pic_F77
-pic_mode=$pic_mode
-
-# What is the maximum length of a command?
-max_cmd_len=$lt_cv_sys_max_cmd_len
-
-# Does compiler simultaneously support -c and -o options?
-compiler_c_o=$lt_lt_cv_prog_compiler_c_o_F77
-
-# Must we lock files when doing compilation?
-need_locks=$lt_need_locks
-
-# Do we need the lib prefix for modules?
-need_lib_prefix=$need_lib_prefix
-
-# Do we need a version for libraries?
-need_version=$need_version
-
-# Whether dlopen is supported.
-dlopen_support=$enable_dlopen
-
-# Whether dlopen of programs is supported.
-dlopen_self=$enable_dlopen_self
-
-# Whether dlopen of statically linked programs is supported.
-dlopen_self_static=$enable_dlopen_self_static
-
-# Compiler flag to prevent dynamic linking.
-link_static_flag=$lt_lt_prog_compiler_static_F77
-
-# Compiler flag to turn off builtin functions.
-no_builtin_flag=$lt_lt_prog_compiler_no_builtin_flag_F77
-
-# Compiler flag to allow reflexive dlopens.
-export_dynamic_flag_spec=$lt_export_dynamic_flag_spec_F77
-
-# Compiler flag to generate shared objects directly from archives.
-whole_archive_flag_spec=$lt_whole_archive_flag_spec_F77
-
-# Compiler flag to generate thread-safe objects.
-thread_safe_flag_spec=$lt_thread_safe_flag_spec_F77
-
-# Library versioning type.
-version_type=$version_type
-
-# Format of library name prefix.
-libname_spec=$lt_libname_spec
-
-# List of archive names. First name is the real one, the rest are links.
-# The last name is the one that the linker finds with -lNAME.
-library_names_spec=$lt_library_names_spec
-
-# The coded name of the library, if different from the real name.
-soname_spec=$lt_soname_spec
-
-# Commands used to build and install an old-style archive.
-RANLIB=$lt_RANLIB
-old_archive_cmds=$lt_old_archive_cmds_F77
-old_postinstall_cmds=$lt_old_postinstall_cmds
-old_postuninstall_cmds=$lt_old_postuninstall_cmds
-
-# Create an old-style archive from a shared archive.
-old_archive_from_new_cmds=$lt_old_archive_from_new_cmds_F77
-
-# Create a temporary old-style archive to link instead of a shared archive.
-old_archive_from_expsyms_cmds=$lt_old_archive_from_expsyms_cmds_F77
-
-# Commands used to build and install a shared archive.
-archive_cmds=$lt_archive_cmds_F77
-archive_expsym_cmds=$lt_archive_expsym_cmds_F77
-postinstall_cmds=$lt_postinstall_cmds
-postuninstall_cmds=$lt_postuninstall_cmds
-
-# Commands used to build a loadable module (assumed same as above if empty)
-module_cmds=$lt_module_cmds_F77
-module_expsym_cmds=$lt_module_expsym_cmds_F77
-
-# Commands to strip libraries.
-old_striplib=$lt_old_striplib
-striplib=$lt_striplib
-
-# Dependencies to place before the objects being linked to create a
-# shared library.
-predep_objects=$lt_predep_objects_F77
-
-# Dependencies to place after the objects being linked to create a
-# shared library.
-postdep_objects=$lt_postdep_objects_F77
-
-# Dependencies to place before the objects being linked to create a
-# shared library.
-predeps=$lt_predeps_F77
-
-# Dependencies to place after the objects being linked to create a
-# shared library.
-postdeps=$lt_postdeps_F77
-
-# The library search path used internally by the compiler when linking
-# a shared library.
-compiler_lib_search_path=$lt_compiler_lib_search_path_F77
-
-# Method to check whether dependent libraries are shared objects.
-deplibs_check_method=$lt_deplibs_check_method
-
-# Command to use when deplibs_check_method == file_magic.
-file_magic_cmd=$lt_file_magic_cmd
-
-# Flag that allows shared libraries with undefined symbols to be built.
-allow_undefined_flag=$lt_allow_undefined_flag_F77
-
-# Flag that forces no undefined symbols.
-no_undefined_flag=$lt_no_undefined_flag_F77
-
-# Commands used to finish a libtool library installation in a directory.
-finish_cmds=$lt_finish_cmds
-
-# Same as above, but a single script fragment to be evaled but not shown.
-finish_eval=$lt_finish_eval
-
-# Take the output of nm and produce a listing of raw symbols and C names.
-global_symbol_pipe=$lt_lt_cv_sys_global_symbol_pipe
-
-# Transform the output of nm in a proper C declaration
-global_symbol_to_cdecl=$lt_lt_cv_sys_global_symbol_to_cdecl
-
-# Transform the output of nm in a C name address pair
-global_symbol_to_c_name_address=$lt_lt_cv_sys_global_symbol_to_c_name_address
-
-# This is the shared library runtime path variable.
-runpath_var=$runpath_var
-
-# This is the shared library path variable.
-shlibpath_var=$shlibpath_var
-
-# Is shlibpath searched before the hard-coded library search path?
-shlibpath_overrides_runpath=$shlibpath_overrides_runpath
-
-# How to hardcode a shared library path into an executable.
-hardcode_action=$hardcode_action_F77
-
-# Whether we should hardcode library paths into libraries.
-hardcode_into_libs=$hardcode_into_libs
-
-# Flag to hardcode \$libdir into a binary during linking.
-# This must work even if \$libdir does not exist.
-hardcode_libdir_flag_spec=$lt_hardcode_libdir_flag_spec_F77
-
-# If ld is used when linking, flag to hardcode \$libdir into
-# a binary during linking. This must work even if \$libdir does
-# not exist.
-hardcode_libdir_flag_spec_ld=$lt_hardcode_libdir_flag_spec_ld_F77
-
-# Whether we need a single -rpath flag with a separated argument.
-hardcode_libdir_separator=$lt_hardcode_libdir_separator_F77
-
-# Set to yes if using DIR/libNAME${shared_ext} during linking hardcodes DIR into the
-# resulting binary.
-hardcode_direct=$hardcode_direct_F77
-
-# Set to yes if using the -LDIR flag during linking hardcodes DIR into the
-# resulting binary.
-hardcode_minus_L=$hardcode_minus_L_F77
-
-# Set to yes if using SHLIBPATH_VAR=DIR during linking hardcodes DIR into
-# the resulting binary.
-hardcode_shlibpath_var=$hardcode_shlibpath_var_F77
-
-# Set to yes if building a shared library automatically hardcodes DIR into the library
-# and all subsequent libraries and executables linked against it.
-hardcode_automatic=$hardcode_automatic_F77
-
-# Variables whose values should be saved in libtool wrapper scripts and
-# restored at relink time.
-variables_saved_for_relink="$variables_saved_for_relink"
-
-# Whether libtool must link a program against all its dependency libraries.
-link_all_deplibs=$link_all_deplibs_F77
-
-# Compile-time system search path for libraries
-sys_lib_search_path_spec=$lt_sys_lib_search_path_spec
-
-# Run-time system search path for libraries
-sys_lib_dlsearch_path_spec=$lt_sys_lib_dlsearch_path_spec
-
-# Fix the shell variable \$srcfile for the compiler.
-fix_srcfile_path="$fix_srcfile_path_F77"
-
-# Set to yes if exported symbols are required.
-always_export_symbols=$always_export_symbols_F77
-
-# The commands to list exported symbols.
-export_symbols_cmds=$lt_export_symbols_cmds_F77
-
-# The commands to extract the exported symbol list from a shared archive.
-extract_expsyms_cmds=$lt_extract_expsyms_cmds
-
-# Symbols that should not be listed in the preloaded symbols.
-exclude_expsyms=$lt_exclude_expsyms_F77
-
-# Symbols that must always be exported.
-include_expsyms=$lt_include_expsyms_F77
-
-# ### END LIBTOOL TAG CONFIG: $tagname
-
-__EOF__
-
-
-else
- # If there is no Makefile yet, we rely on a make rule to execute
- # `config.status --recheck' to rerun these tests and create the
- # libtool script then.
- ltmain_in=`echo $ltmain | sed -e 's/\.sh$/.in/'`
- if test -f "$ltmain_in"; then
- test -f Makefile && make "$ltmain"
- fi
-fi
-
-
-ac_ext=c
-ac_cpp='$CPP $CPPFLAGS'
-ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
-ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
-ac_compiler_gnu=$ac_cv_c_compiler_gnu
-
-CC="$lt_save_CC"
-
- else
- tagname=""
- fi
- ;;
-
- GCJ)
- if test -n "$GCJ" && test "X$GCJ" != "Xno"; then
-
-
-
-# Source file extension for Java test sources.
-ac_ext=java
-
-# Object file extension for compiled Java test sources.
-objext=o
-objext_GCJ=$objext
-
-# Code to be used in simple compile tests
-lt_simple_compile_test_code="class foo {}\n"
-
-# Code to be used in simple link tests
-lt_simple_link_test_code='public class conftest { public static void main(String[] argv) {}; }\n'
-
-# ltmain only uses $CC for tagged configurations so make sure $CC is set.
-
-# If no C compiler was specified, use CC.
-LTCC=${LTCC-"$CC"}
-
-# If no C compiler flags were specified, use CFLAGS.
-LTCFLAGS=${LTCFLAGS-"$CFLAGS"}
-
-# Allow CC to be a program name with arguments.
-compiler=$CC
-
-
-# save warnings/boilerplate of simple test code
-ac_outfile=conftest.$ac_objext
-printf "$lt_simple_compile_test_code" >conftest.$ac_ext
-eval "$ac_compile" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err
-_lt_compiler_boilerplate=`cat conftest.err`
-$rm conftest*
-
-ac_outfile=conftest.$ac_objext
-printf "$lt_simple_link_test_code" >conftest.$ac_ext
-eval "$ac_link" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err
-_lt_linker_boilerplate=`cat conftest.err`
-$rm conftest*
-
-
-# Allow CC to be a program name with arguments.
-lt_save_CC="$CC"
-CC=${GCJ-"gcj"}
-compiler=$CC
-compiler_GCJ=$CC
-for cc_temp in $compiler""; do
- case $cc_temp in
- compile | *[\\/]compile | ccache | *[\\/]ccache ) ;;
- distcc | *[\\/]distcc | purify | *[\\/]purify ) ;;
- \-*) ;;
- *) break;;
- esac
-done
-cc_basename=`$echo "X$cc_temp" | $Xsed -e 's%.*/%%' -e "s%^$host_alias-%%"`
-
-
-# GCJ did not exist at the time GCC didn't implicitly link libc in.
-archive_cmds_need_lc_GCJ=no
-
-old_archive_cmds_GCJ=$old_archive_cmds
-
-
-lt_prog_compiler_no_builtin_flag_GCJ=
-
-if test "$GCC" = yes; then
- lt_prog_compiler_no_builtin_flag_GCJ=' -fno-builtin'
-
-
-echo "$as_me:$LINENO: checking if $compiler supports -fno-rtti -fno-exceptions" >&5
-echo $ECHO_N "checking if $compiler supports -fno-rtti -fno-exceptions... $ECHO_C" >&6
-if test "${lt_cv_prog_compiler_rtti_exceptions+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- lt_cv_prog_compiler_rtti_exceptions=no
- ac_outfile=conftest.$ac_objext
- printf "$lt_simple_compile_test_code" > conftest.$ac_ext
- lt_compiler_flag="-fno-rtti -fno-exceptions"
- # Insert the option either (1) after the last *FLAGS variable, or
- # (2) before a word containing "conftest.", or (3) at the end.
- # Note that $ac_compile itself does not contain backslashes and begins
- # with a dollar sign (not a hyphen), so the echo should work correctly.
- # The option is referenced via a variable to avoid confusing sed.
- lt_compile=`echo "$ac_compile" | $SED \
- -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
- -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
- -e 's:$: $lt_compiler_flag:'`
- (eval echo "\"\$as_me:15512: $lt_compile\"" >&5)
- (eval "$lt_compile" 2>conftest.err)
- ac_status=$?
- cat conftest.err >&5
- echo "$as_me:15516: \$? = $ac_status" >&5
- if (exit $ac_status) && test -s "$ac_outfile"; then
- # The compiler can only warn and ignore the option if not recognized
- # So say no if there are warnings other than the usual output.
- $echo "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' >conftest.exp
- $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2
- if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then
- lt_cv_prog_compiler_rtti_exceptions=yes
- fi
- fi
- $rm conftest*
-
-fi
-echo "$as_me:$LINENO: result: $lt_cv_prog_compiler_rtti_exceptions" >&5
-echo "${ECHO_T}$lt_cv_prog_compiler_rtti_exceptions" >&6
-
-if test x"$lt_cv_prog_compiler_rtti_exceptions" = xyes; then
- lt_prog_compiler_no_builtin_flag_GCJ="$lt_prog_compiler_no_builtin_flag_GCJ -fno-rtti -fno-exceptions"
-else
- :
-fi
-
-fi
-
-lt_prog_compiler_wl_GCJ=
-lt_prog_compiler_pic_GCJ=
-lt_prog_compiler_static_GCJ=
-
-echo "$as_me:$LINENO: checking for $compiler option to produce PIC" >&5
-echo $ECHO_N "checking for $compiler option to produce PIC... $ECHO_C" >&6
-
- if test "$GCC" = yes; then
- lt_prog_compiler_wl_GCJ='-Wl,'
- lt_prog_compiler_static_GCJ='-static'
-
- case $host_os in
- aix*)
- # All AIX code is PIC.
- if test "$host_cpu" = ia64; then
- # AIX 5 now supports IA64 processor
- lt_prog_compiler_static_GCJ='-Bstatic'
- fi
- ;;
-
- amigaos*)
- # FIXME: we need at least 68020 code to build shared libraries, but
- # adding the `-m68020' flag to GCC prevents building anything better,
- # like `-m68040'.
- lt_prog_compiler_pic_GCJ='-m68020 -resident32 -malways-restore-a4'
- ;;
-
- beos* | cygwin* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*)
- # PIC is the default for these OSes.
- ;;
-
- mingw* | pw32* | os2*)
- # This hack is so that the source file can tell whether it is being
- # built for inclusion in a dll (and should export symbols for example).
- lt_prog_compiler_pic_GCJ='-DDLL_EXPORT'
- ;;
-
- darwin* | rhapsody*)
- # PIC is the default on this platform
- # Common symbols not allowed in MH_DYLIB files
- lt_prog_compiler_pic_GCJ='-fno-common'
- ;;
-
- interix3*)
- # Interix 3.x gcc -fpic/-fPIC options generate broken code.
- # Instead, we relocate shared libraries at runtime.
- ;;
-
- msdosdjgpp*)
- # Just because we use GCC doesn't mean we suddenly get shared libraries
- # on systems that don't support them.
- lt_prog_compiler_can_build_shared_GCJ=no
- enable_shared=no
- ;;
-
- sysv4*MP*)
- if test -d /usr/nec; then
- lt_prog_compiler_pic_GCJ=-Kconform_pic
- fi
- ;;
-
- hpux*)
- # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but
- # not for PA HP-UX.
- case $host_cpu in
- hppa*64*|ia64*)
- # +Z the default
- ;;
- *)
- lt_prog_compiler_pic_GCJ='-fPIC'
- ;;
- esac
- ;;
-
- *)
- lt_prog_compiler_pic_GCJ='-fPIC'
- ;;
- esac
- else
- # PORTME Check for flag to pass linker flags through the system compiler.
- case $host_os in
- aix*)
- lt_prog_compiler_wl_GCJ='-Wl,'
- if test "$host_cpu" = ia64; then
- # AIX 5 now supports IA64 processor
- lt_prog_compiler_static_GCJ='-Bstatic'
- else
- lt_prog_compiler_static_GCJ='-bnso -bI:/lib/syscalls.exp'
- fi
- ;;
- darwin*)
- # PIC is the default on this platform
- # Common symbols not allowed in MH_DYLIB files
- case $cc_basename in
- xlc*)
- lt_prog_compiler_pic_GCJ='-qnocommon'
- lt_prog_compiler_wl_GCJ='-Wl,'
- ;;
- esac
- ;;
-
- mingw* | pw32* | os2*)
- # This hack is so that the source file can tell whether it is being
- # built for inclusion in a dll (and should export symbols for example).
- lt_prog_compiler_pic_GCJ='-DDLL_EXPORT'
- ;;
-
- hpux9* | hpux10* | hpux11*)
- lt_prog_compiler_wl_GCJ='-Wl,'
- # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but
- # not for PA HP-UX.
- case $host_cpu in
- hppa*64*|ia64*)
- # +Z the default
- ;;
- *)
- lt_prog_compiler_pic_GCJ='+Z'
- ;;
- esac
- # Is there a better lt_prog_compiler_static that works with the bundled CC?
- lt_prog_compiler_static_GCJ='${wl}-a ${wl}archive'
- ;;
-
- irix5* | irix6* | nonstopux*)
- lt_prog_compiler_wl_GCJ='-Wl,'
- # PIC (with -KPIC) is the default.
- lt_prog_compiler_static_GCJ='-non_shared'
- ;;
-
- newsos6)
- lt_prog_compiler_pic_GCJ='-KPIC'
- lt_prog_compiler_static_GCJ='-Bstatic'
- ;;
-
- linux*)
- case $cc_basename in
- icc* | ecc*)
- lt_prog_compiler_wl_GCJ='-Wl,'
- lt_prog_compiler_pic_GCJ='-KPIC'
- lt_prog_compiler_static_GCJ='-static'
- ;;
- pgcc* | pgf77* | pgf90* | pgf95*)
- # Portland Group compilers (*not* the Pentium gcc compiler,
- # which looks to be a dead project)
- lt_prog_compiler_wl_GCJ='-Wl,'
- lt_prog_compiler_pic_GCJ='-fpic'
- lt_prog_compiler_static_GCJ='-Bstatic'
- ;;
- ccc*)
- lt_prog_compiler_wl_GCJ='-Wl,'
- # All Alpha code is PIC.
- lt_prog_compiler_static_GCJ='-non_shared'
- ;;
- esac
- ;;
-
- osf3* | osf4* | osf5*)
- lt_prog_compiler_wl_GCJ='-Wl,'
- # All OSF/1 code is PIC.
- lt_prog_compiler_static_GCJ='-non_shared'
- ;;
-
- solaris*)
- lt_prog_compiler_pic_GCJ='-KPIC'
- lt_prog_compiler_static_GCJ='-Bstatic'
- case $cc_basename in
- f77* | f90* | f95*)
- lt_prog_compiler_wl_GCJ='-Qoption ld ';;
- *)
- lt_prog_compiler_wl_GCJ='-Wl,';;
- esac
- ;;
-
- sunos4*)
- lt_prog_compiler_wl_GCJ='-Qoption ld '
- lt_prog_compiler_pic_GCJ='-PIC'
- lt_prog_compiler_static_GCJ='-Bstatic'
- ;;
-
- sysv4 | sysv4.2uw2* | sysv4.3*)
- lt_prog_compiler_wl_GCJ='-Wl,'
- lt_prog_compiler_pic_GCJ='-KPIC'
- lt_prog_compiler_static_GCJ='-Bstatic'
- ;;
-
- sysv4*MP*)
- if test -d /usr/nec ;then
- lt_prog_compiler_pic_GCJ='-Kconform_pic'
- lt_prog_compiler_static_GCJ='-Bstatic'
- fi
- ;;
-
- sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*)
- lt_prog_compiler_wl_GCJ='-Wl,'
- lt_prog_compiler_pic_GCJ='-KPIC'
- lt_prog_compiler_static_GCJ='-Bstatic'
- ;;
-
- unicos*)
- lt_prog_compiler_wl_GCJ='-Wl,'
- lt_prog_compiler_can_build_shared_GCJ=no
- ;;
-
- uts4*)
- lt_prog_compiler_pic_GCJ='-pic'
- lt_prog_compiler_static_GCJ='-Bstatic'
- ;;
-
- *)
- lt_prog_compiler_can_build_shared_GCJ=no
- ;;
- esac
- fi
-
-echo "$as_me:$LINENO: result: $lt_prog_compiler_pic_GCJ" >&5
-echo "${ECHO_T}$lt_prog_compiler_pic_GCJ" >&6
-
-#
-# Check to make sure the PIC flag actually works.
-#
-if test -n "$lt_prog_compiler_pic_GCJ"; then
-
-echo "$as_me:$LINENO: checking if $compiler PIC flag $lt_prog_compiler_pic_GCJ works" >&5
-echo $ECHO_N "checking if $compiler PIC flag $lt_prog_compiler_pic_GCJ works... $ECHO_C" >&6
-if test "${lt_prog_compiler_pic_works_GCJ+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- lt_prog_compiler_pic_works_GCJ=no
- ac_outfile=conftest.$ac_objext
- printf "$lt_simple_compile_test_code" > conftest.$ac_ext
- lt_compiler_flag="$lt_prog_compiler_pic_GCJ"
- # Insert the option either (1) after the last *FLAGS variable, or
- # (2) before a word containing "conftest.", or (3) at the end.
- # Note that $ac_compile itself does not contain backslashes and begins
- # with a dollar sign (not a hyphen), so the echo should work correctly.
- # The option is referenced via a variable to avoid confusing sed.
- lt_compile=`echo "$ac_compile" | $SED \
- -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
- -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
- -e 's:$: $lt_compiler_flag:'`
- (eval echo "\"\$as_me:15780: $lt_compile\"" >&5)
- (eval "$lt_compile" 2>conftest.err)
- ac_status=$?
- cat conftest.err >&5
- echo "$as_me:15784: \$? = $ac_status" >&5
- if (exit $ac_status) && test -s "$ac_outfile"; then
- # The compiler can only warn and ignore the option if not recognized
- # So say no if there are warnings other than the usual output.
- $echo "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' >conftest.exp
- $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2
- if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then
- lt_prog_compiler_pic_works_GCJ=yes
- fi
- fi
- $rm conftest*
-
-fi
-echo "$as_me:$LINENO: result: $lt_prog_compiler_pic_works_GCJ" >&5
-echo "${ECHO_T}$lt_prog_compiler_pic_works_GCJ" >&6
-
-if test x"$lt_prog_compiler_pic_works_GCJ" = xyes; then
- case $lt_prog_compiler_pic_GCJ in
- "" | " "*) ;;
- *) lt_prog_compiler_pic_GCJ=" $lt_prog_compiler_pic_GCJ" ;;
- esac
-else
- lt_prog_compiler_pic_GCJ=
- lt_prog_compiler_can_build_shared_GCJ=no
-fi
-
-fi
-case $host_os in
- # For platforms which do not support PIC, -DPIC is meaningless:
- *djgpp*)
- lt_prog_compiler_pic_GCJ=
- ;;
- *)
- lt_prog_compiler_pic_GCJ="$lt_prog_compiler_pic_GCJ"
- ;;
-esac
-
-#
-# Check to make sure the static flag actually works.
-#
-wl=$lt_prog_compiler_wl_GCJ eval lt_tmp_static_flag=\"$lt_prog_compiler_static_GCJ\"
-echo "$as_me:$LINENO: checking if $compiler static flag $lt_tmp_static_flag works" >&5
-echo $ECHO_N "checking if $compiler static flag $lt_tmp_static_flag works... $ECHO_C" >&6
-if test "${lt_prog_compiler_static_works_GCJ+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- lt_prog_compiler_static_works_GCJ=no
- save_LDFLAGS="$LDFLAGS"
- LDFLAGS="$LDFLAGS $lt_tmp_static_flag"
- printf "$lt_simple_link_test_code" > conftest.$ac_ext
- if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then
- # The linker can only warn and ignore the option if not recognized
- # So say no if there are warnings
- if test -s conftest.err; then
- # Append any errors to the config.log.
- cat conftest.err 1>&5
- $echo "X$_lt_linker_boilerplate" | $Xsed -e '/^$/d' > conftest.exp
- $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2
- if diff conftest.exp conftest.er2 >/dev/null; then
- lt_prog_compiler_static_works_GCJ=yes
- fi
- else
- lt_prog_compiler_static_works_GCJ=yes
- fi
- fi
- $rm conftest*
- LDFLAGS="$save_LDFLAGS"
-
-fi
-echo "$as_me:$LINENO: result: $lt_prog_compiler_static_works_GCJ" >&5
-echo "${ECHO_T}$lt_prog_compiler_static_works_GCJ" >&6
-
-if test x"$lt_prog_compiler_static_works_GCJ" = xyes; then
- :
-else
- lt_prog_compiler_static_GCJ=
-fi
-
-
-echo "$as_me:$LINENO: checking if $compiler supports -c -o file.$ac_objext" >&5
-echo $ECHO_N "checking if $compiler supports -c -o file.$ac_objext... $ECHO_C" >&6
-if test "${lt_cv_prog_compiler_c_o_GCJ+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- lt_cv_prog_compiler_c_o_GCJ=no
- $rm -r conftest 2>/dev/null
- mkdir conftest
- cd conftest
- mkdir out
- printf "$lt_simple_compile_test_code" > conftest.$ac_ext
-
- lt_compiler_flag="-o out/conftest2.$ac_objext"
- # Insert the option either (1) after the last *FLAGS variable, or
- # (2) before a word containing "conftest.", or (3) at the end.
- # Note that $ac_compile itself does not contain backslashes and begins
- # with a dollar sign (not a hyphen), so the echo should work correctly.
- lt_compile=`echo "$ac_compile" | $SED \
- -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
- -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
- -e 's:$: $lt_compiler_flag:'`
- (eval echo "\"\$as_me:15884: $lt_compile\"" >&5)
- (eval "$lt_compile" 2>out/conftest.err)
- ac_status=$?
- cat out/conftest.err >&5
- echo "$as_me:15888: \$? = $ac_status" >&5
- if (exit $ac_status) && test -s out/conftest2.$ac_objext
- then
- # The compiler can only warn and ignore the option if not recognized
- # So say no if there are warnings
- $echo "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' > out/conftest.exp
- $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2
- if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then
- lt_cv_prog_compiler_c_o_GCJ=yes
- fi
- fi
- chmod u+w . 2>&5
- $rm conftest*
- # SGI C++ compiler will create directory out/ii_files/ for
- # template instantiation
- test -d out/ii_files && $rm out/ii_files/* && rmdir out/ii_files
- $rm out/* && rmdir out
- cd ..
- rmdir conftest
- $rm conftest*
-
-fi
-echo "$as_me:$LINENO: result: $lt_cv_prog_compiler_c_o_GCJ" >&5
-echo "${ECHO_T}$lt_cv_prog_compiler_c_o_GCJ" >&6
-
-
-hard_links="nottested"
-if test "$lt_cv_prog_compiler_c_o_GCJ" = no && test "$need_locks" != no; then
- # do not overwrite the value of need_locks provided by the user
- echo "$as_me:$LINENO: checking if we can lock with hard links" >&5
-echo $ECHO_N "checking if we can lock with hard links... $ECHO_C" >&6
- hard_links=yes
- $rm conftest*
- ln conftest.a conftest.b 2>/dev/null && hard_links=no
- touch conftest.a
- ln conftest.a conftest.b 2>&5 || hard_links=no
- ln conftest.a conftest.b 2>/dev/null && hard_links=no
- echo "$as_me:$LINENO: result: $hard_links" >&5
-echo "${ECHO_T}$hard_links" >&6
- if test "$hard_links" = no; then
- { echo "$as_me:$LINENO: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&5
-echo "$as_me: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&2;}
- need_locks=warn
- fi
-else
- need_locks=no
-fi
-
-echo "$as_me:$LINENO: checking whether the $compiler linker ($LD) supports shared libraries" >&5
-echo $ECHO_N "checking whether the $compiler linker ($LD) supports shared libraries... $ECHO_C" >&6
-
- runpath_var=
- allow_undefined_flag_GCJ=
- enable_shared_with_static_runtimes_GCJ=no
- archive_cmds_GCJ=
- archive_expsym_cmds_GCJ=
- old_archive_From_new_cmds_GCJ=
- old_archive_from_expsyms_cmds_GCJ=
- export_dynamic_flag_spec_GCJ=
- whole_archive_flag_spec_GCJ=
- thread_safe_flag_spec_GCJ=
- hardcode_libdir_flag_spec_GCJ=
- hardcode_libdir_flag_spec_ld_GCJ=
- hardcode_libdir_separator_GCJ=
- hardcode_direct_GCJ=no
- hardcode_minus_L_GCJ=no
- hardcode_shlibpath_var_GCJ=unsupported
- link_all_deplibs_GCJ=unknown
- hardcode_automatic_GCJ=no
- module_cmds_GCJ=
- module_expsym_cmds_GCJ=
- always_export_symbols_GCJ=no
- export_symbols_cmds_GCJ='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols'
- # include_expsyms should be a list of space-separated symbols to be *always*
- # included in the symbol list
- include_expsyms_GCJ=
- # exclude_expsyms can be an extended regexp of symbols to exclude
- # it will be wrapped by ` (' and `)$', so one must not match beginning or
- # end of line. Example: `a|bc|.*d.*' will exclude the symbols `a' and `bc',
- # as well as any symbol that contains `d'.
- exclude_expsyms_GCJ="_GLOBAL_OFFSET_TABLE_"
- # Although _GLOBAL_OFFSET_TABLE_ is a valid symbol C name, most a.out
- # platforms (ab)use it in PIC code, but their linkers get confused if
- # the symbol is explicitly referenced. Since portable code cannot
- # rely on this symbol name, it's probably fine to never include it in
- # preloaded symbol tables.
- extract_expsyms_cmds=
- # Just being paranoid about ensuring that cc_basename is set.
- for cc_temp in $compiler""; do
- case $cc_temp in
- compile | *[\\/]compile | ccache | *[\\/]ccache ) ;;
- distcc | *[\\/]distcc | purify | *[\\/]purify ) ;;
- \-*) ;;
- *) break;;
- esac
-done
-cc_basename=`$echo "X$cc_temp" | $Xsed -e 's%.*/%%' -e "s%^$host_alias-%%"`
-
- case $host_os in
- cygwin* | mingw* | pw32*)
- # FIXME: the MSVC++ port hasn't been tested in a loooong time
- # When not using gcc, we currently assume that we are using
- # Microsoft Visual C++.
- if test "$GCC" != yes; then
- with_gnu_ld=no
- fi
- ;;
- interix*)
- # we just hope/assume this is gcc and not c89 (= MSVC++)
- with_gnu_ld=yes
- ;;
- openbsd*)
- with_gnu_ld=no
- ;;
- esac
-
- ld_shlibs_GCJ=yes
- if test "$with_gnu_ld" = yes; then
- # If archive_cmds runs LD, not CC, wlarc should be empty
- wlarc='${wl}'
-
- # Set some defaults for GNU ld with shared library support. These
- # are reset later if shared libraries are not supported. Putting them
- # here allows them to be overridden if necessary.
- runpath_var=LD_RUN_PATH
- hardcode_libdir_flag_spec_GCJ='${wl}--rpath ${wl}$libdir'
- export_dynamic_flag_spec_GCJ='${wl}--export-dynamic'
- # ancient GNU ld didn't support --whole-archive et. al.
- if $LD --help 2>&1 | grep 'no-whole-archive' > /dev/null; then
- whole_archive_flag_spec_GCJ="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive'
- else
- whole_archive_flag_spec_GCJ=
- fi
- supports_anon_versioning=no
- case `$LD -v 2>/dev/null` in
- *\ [01].* | *\ 2.[0-9].* | *\ 2.10.*) ;; # catch versions < 2.11
- *\ 2.11.93.0.2\ *) supports_anon_versioning=yes ;; # RH7.3 ...
- *\ 2.11.92.0.12\ *) supports_anon_versioning=yes ;; # Mandrake 8.2 ...
- *\ 2.11.*) ;; # other 2.11 versions
- *) supports_anon_versioning=yes ;;
- esac
-
- # See if GNU ld supports shared libraries.
- case $host_os in
- aix3* | aix4* | aix5*)
- # On AIX/PPC, the GNU linker is very broken
- if test "$host_cpu" != ia64; then
- ld_shlibs_GCJ=no
- cat <<EOF 1>&2
-
-*** Warning: the GNU linker, at least up to release 2.9.1, is reported
-*** to be unable to reliably create shared libraries on AIX.
-*** Therefore, libtool is disabling shared libraries support. If you
-*** really care for shared libraries, you may want to modify your PATH
-*** so that a non-GNU linker is found, and then restart.
-
-EOF
- fi
- ;;
-
- amigaos*)
- archive_cmds_GCJ='$rm $output_objdir/a2ixlibrary.data~$echo "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$echo "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$echo "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$echo "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)'
- hardcode_libdir_flag_spec_GCJ='-L$libdir'
- hardcode_minus_L_GCJ=yes
-
- # Samuel A. Falvo II <kc5tja@dolphin.openprojects.net> reports
- # that the semantics of dynamic libraries on AmigaOS, at least up
- # to version 4, is to share data among multiple programs linked
- # with the same dynamic library. Since this doesn't match the
- # behavior of shared libraries on other platforms, we can't use
- # them.
- ld_shlibs_GCJ=no
- ;;
-
- beos*)
- if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
- allow_undefined_flag_GCJ=unsupported
- # Joseph Beckenbach <jrb3@best.com> says some releases of gcc
- # support --undefined. This deserves some investigation. FIXME
- archive_cmds_GCJ='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
- else
- ld_shlibs_GCJ=no
- fi
- ;;
-
- cygwin* | mingw* | pw32*)
- # _LT_AC_TAGVAR(hardcode_libdir_flag_spec, GCJ) is actually meaningless,
- # as there is no search path for DLLs.
- hardcode_libdir_flag_spec_GCJ='-L$libdir'
- allow_undefined_flag_GCJ=unsupported
- always_export_symbols_GCJ=no
- enable_shared_with_static_runtimes_GCJ=yes
- export_symbols_cmds_GCJ='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[BCDGRS] /s/.* \([^ ]*\)/\1 DATA/'\'' | $SED -e '\''/^[AITW] /s/.* //'\'' | sort | uniq > $export_symbols'
-
- if $LD --help 2>&1 | grep 'auto-import' > /dev/null; then
- archive_cmds_GCJ='$CC -shared $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
- # If the export-symbols file already is a .def file (1st line
- # is EXPORTS), use it as is; otherwise, prepend...
- archive_expsym_cmds_GCJ='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then
- cp $export_symbols $output_objdir/$soname.def;
- else
- echo EXPORTS > $output_objdir/$soname.def;
- cat $export_symbols >> $output_objdir/$soname.def;
- fi~
- $CC -shared $output_objdir/$soname.def $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
- else
- ld_shlibs_GCJ=no
- fi
- ;;
-
- interix3*)
- hardcode_direct_GCJ=no
- hardcode_shlibpath_var_GCJ=no
- hardcode_libdir_flag_spec_GCJ='${wl}-rpath,$libdir'
- export_dynamic_flag_spec_GCJ='${wl}-E'
- # Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc.
- # Instead, shared libraries are loaded at an image base (0x10000000 by
- # default) and relocated if they conflict, which is a slow very memory
- # consuming and fragmenting process. To avoid this, we pick a random,
- # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link
- # time. Moving up from 0x10000000 also allows more sbrk(2) space.
- archive_cmds_GCJ='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
- archive_expsym_cmds_GCJ='sed "s,^,_," $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--retain-symbols-file,$output_objdir/$soname.expsym ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
- ;;
-
- linux*)
- if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
- tmp_addflag=
- case $cc_basename,$host_cpu in
- pgcc*) # Portland Group C compiler
- whole_archive_flag_spec_GCJ='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}--no-whole-archive'
- tmp_addflag=' $pic_flag'
- ;;
- pgf77* | pgf90* | pgf95*) # Portland Group f77 and f90 compilers
- whole_archive_flag_spec_GCJ='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}--no-whole-archive'
- tmp_addflag=' $pic_flag -Mnomain' ;;
- ecc*,ia64* | icc*,ia64*) # Intel C compiler on ia64
- tmp_addflag=' -i_dynamic' ;;
- efc*,ia64* | ifort*,ia64*) # Intel Fortran compiler on ia64
- tmp_addflag=' -i_dynamic -nofor_main' ;;
- ifc* | ifort*) # Intel Fortran compiler
- tmp_addflag=' -nofor_main' ;;
- esac
- archive_cmds_GCJ='$CC -shared'"$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
-
- if test $supports_anon_versioning = yes; then
- archive_expsym_cmds_GCJ='$echo "{ global:" > $output_objdir/$libname.ver~
- cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~
- $echo "local: *; };" >> $output_objdir/$libname.ver~
- $CC -shared'"$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib'
- fi
- link_all_deplibs_GCJ=no
- else
- ld_shlibs_GCJ=no
- fi
- ;;
-
- netbsd* | netbsdelf*-gnu | knetbsd*-gnu)
- if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then
- archive_cmds_GCJ='$LD -Bshareable $libobjs $deplibs $linker_flags -o $lib'
- wlarc=
- else
- archive_cmds_GCJ='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
- archive_expsym_cmds_GCJ='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
- fi
- ;;
-
- solaris*)
- if $LD -v 2>&1 | grep 'BFD 2\.8' > /dev/null; then
- ld_shlibs_GCJ=no
- cat <<EOF 1>&2
-
-*** Warning: The releases 2.8.* of the GNU linker cannot reliably
-*** create shared libraries on Solaris systems. Therefore, libtool
-*** is disabling shared libraries support. We urge you to upgrade GNU
-*** binutils to release 2.9.1 or newer. Another option is to modify
-*** your PATH or compiler configuration so that the native linker is
-*** used, and then restart.
-
-EOF
- elif $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
- archive_cmds_GCJ='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
- archive_expsym_cmds_GCJ='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
- else
- ld_shlibs_GCJ=no
- fi
- ;;
-
- sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX*)
- case `$LD -v 2>&1` in
- *\ [01].* | *\ 2.[0-9].* | *\ 2.1[0-5].*)
- ld_shlibs_GCJ=no
- cat <<_LT_EOF 1>&2
-
-*** Warning: Releases of the GNU linker prior to 2.16.91.0.3 can not
-*** reliably create shared libraries on SCO systems. Therefore, libtool
-*** is disabling shared libraries support. We urge you to upgrade GNU
-*** binutils to release 2.16.91.0.3 or newer. Another option is to modify
-*** your PATH or compiler configuration so that the native linker is
-*** used, and then restart.
-
-_LT_EOF
- ;;
- *)
- if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
- hardcode_libdir_flag_spec_GCJ='`test -z "$SCOABSPATH" && echo ${wl}-rpath,$libdir`'
- archive_cmds_GCJ='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib'
- archive_expsym_cmds_GCJ='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname,\${SCOABSPATH:+${install_libdir}/}$soname,-retain-symbols-file,$export_symbols -o $lib'
- else
- ld_shlibs_GCJ=no
- fi
- ;;
- esac
- ;;
-
- sunos4*)
- archive_cmds_GCJ='$LD -assert pure-text -Bshareable -o $lib $libobjs $deplibs $linker_flags'
- wlarc=
- hardcode_direct_GCJ=yes
- hardcode_shlibpath_var_GCJ=no
- ;;
-
- *)
- if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
- archive_cmds_GCJ='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
- archive_expsym_cmds_GCJ='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
- else
- ld_shlibs_GCJ=no
- fi
- ;;
- esac
-
- if test "$ld_shlibs_GCJ" = no; then
- runpath_var=
- hardcode_libdir_flag_spec_GCJ=
- export_dynamic_flag_spec_GCJ=
- whole_archive_flag_spec_GCJ=
- fi
- else
- # PORTME fill in a description of your system's linker (not GNU ld)
- case $host_os in
- aix3*)
- allow_undefined_flag_GCJ=unsupported
- always_export_symbols_GCJ=yes
- archive_expsym_cmds_GCJ='$LD -o $output_objdir/$soname $libobjs $deplibs $linker_flags -bE:$export_symbols -T512 -H512 -bM:SRE~$AR $AR_FLAGS $lib $output_objdir/$soname'
- # Note: this linker hardcodes the directories in LIBPATH if there
- # are no directories specified by -L.
- hardcode_minus_L_GCJ=yes
- if test "$GCC" = yes && test -z "$lt_prog_compiler_static"; then
- # Neither direct hardcoding nor static linking is supported with a
- # broken collect2.
- hardcode_direct_GCJ=unsupported
- fi
- ;;
-
- aix4* | aix5*)
- if test "$host_cpu" = ia64; then
- # On IA64, the linker does run time linking by default, so we don't
- # have to do anything special.
- aix_use_runtimelinking=no
- exp_sym_flag='-Bexport'
- no_entry_flag=""
- else
- # If we're using GNU nm, then we don't want the "-C" option.
- # -C means demangle to AIX nm, but means don't demangle with GNU nm
- if $NM -V 2>&1 | grep 'GNU' > /dev/null; then
- export_symbols_cmds_GCJ='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$2 == "T") || (\$2 == "D") || (\$2 == "B")) && (substr(\$3,1,1) != ".")) { print \$3 } }'\'' | sort -u > $export_symbols'
- else
- export_symbols_cmds_GCJ='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\$2 == "T") || (\$2 == "D") || (\$2 == "B")) && (substr(\$3,1,1) != ".")) { print \$3 } }'\'' | sort -u > $export_symbols'
- fi
- aix_use_runtimelinking=no
-
- # Test if we are trying to use run time linking or normal
- # AIX style linking. If -brtl is somewhere in LDFLAGS, we
- # need to do runtime linking.
- case $host_os in aix4.[23]|aix4.[23].*|aix5*)
- for ld_flag in $LDFLAGS; do
- if (test $ld_flag = "-brtl" || test $ld_flag = "-Wl,-brtl"); then
- aix_use_runtimelinking=yes
- break
- fi
- done
- ;;
- esac
-
- exp_sym_flag='-bexport'
- no_entry_flag='-bnoentry'
- fi
-
- # When large executables or shared objects are built, AIX ld can
- # have problems creating the table of contents. If linking a library
- # or program results in "error TOC overflow" add -mminimal-toc to
- # CXXFLAGS/CFLAGS for g++/gcc. In the cases where that is not
- # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS.
-
- archive_cmds_GCJ=''
- hardcode_direct_GCJ=yes
- hardcode_libdir_separator_GCJ=':'
- link_all_deplibs_GCJ=yes
-
- if test "$GCC" = yes; then
- case $host_os in aix4.[012]|aix4.[012].*)
- # We only want to do this on AIX 4.2 and lower, the check
- # below for broken collect2 doesn't work under 4.3+
- collect2name=`${CC} -print-prog-name=collect2`
- if test -f "$collect2name" && \
- strings "$collect2name" | grep resolve_lib_name >/dev/null
- then
- # We have reworked collect2
- hardcode_direct_GCJ=yes
- else
- # We have old collect2
- hardcode_direct_GCJ=unsupported
- # It fails to find uninstalled libraries when the uninstalled
- # path is not listed in the libpath. Setting hardcode_minus_L
- # to unsupported forces relinking
- hardcode_minus_L_GCJ=yes
- hardcode_libdir_flag_spec_GCJ='-L$libdir'
- hardcode_libdir_separator_GCJ=
- fi
- ;;
- esac
- shared_flag='-shared'
- if test "$aix_use_runtimelinking" = yes; then
- shared_flag="$shared_flag "'${wl}-G'
- fi
- else
- # not using gcc
- if test "$host_cpu" = ia64; then
- # VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release
- # chokes on -Wl,-G. The following line is correct:
- shared_flag='-G'
- else
- if test "$aix_use_runtimelinking" = yes; then
- shared_flag='${wl}-G'
- else
- shared_flag='${wl}-bM:SRE'
- fi
- fi
- fi
-
- # It seems that -bexpall does not export symbols beginning with
- # underscore (_), so it is better to generate a list of symbols to export.
- always_export_symbols_GCJ=yes
- if test "$aix_use_runtimelinking" = yes; then
- # Warning - without using the other runtime loading flags (-brtl),
- # -berok will link without error, but may produce a broken library.
- allow_undefined_flag_GCJ='-berok'
- # Determine the default libpath from the value encoded in an empty executable.
- cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-
-int
-main ()
-{
-
- ;
- return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
- (eval $ac_link) 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } &&
- { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; } &&
- { ac_try='test -s conftest$ac_exeext'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
-
-aix_libpath=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; }
-}'`
-# Check for a 64-bit object if we didn't find anything.
-if test -z "$aix_libpath"; then aix_libpath=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; }
-}'`; fi
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-fi
-rm -f conftest.err conftest.$ac_objext \
- conftest$ac_exeext conftest.$ac_ext
-if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
-
- hardcode_libdir_flag_spec_GCJ='${wl}-blibpath:$libdir:'"$aix_libpath"
- archive_expsym_cmds_GCJ="\$CC"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then echo "${wl}${allow_undefined_flag}"; else :; fi` '"\${wl}$exp_sym_flag:\$export_symbols $shared_flag"
- else
- if test "$host_cpu" = ia64; then
- hardcode_libdir_flag_spec_GCJ='${wl}-R $libdir:/usr/lib:/lib'
- allow_undefined_flag_GCJ="-z nodefs"
- archive_expsym_cmds_GCJ="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$exp_sym_flag:\$export_symbols"
- else
- # Determine the default libpath from the value encoded in an empty executable.
- cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-
-int
-main ()
-{
-
- ;
- return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
- (eval $ac_link) 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } &&
- { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; } &&
- { ac_try='test -s conftest$ac_exeext'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
-
-aix_libpath=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; }
-}'`
-# Check for a 64-bit object if we didn't find anything.
-if test -z "$aix_libpath"; then aix_libpath=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; }
-}'`; fi
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-fi
-rm -f conftest.err conftest.$ac_objext \
- conftest$ac_exeext conftest.$ac_ext
-if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
-
- hardcode_libdir_flag_spec_GCJ='${wl}-blibpath:$libdir:'"$aix_libpath"
- # Warning - without using the other run time loading flags,
- # -berok will link without error, but may produce a broken library.
- no_undefined_flag_GCJ=' ${wl}-bernotok'
- allow_undefined_flag_GCJ=' ${wl}-berok'
- # Exported symbols can be pulled into shared objects from archives
- whole_archive_flag_spec_GCJ='$convenience'
- archive_cmds_need_lc_GCJ=yes
- # This is similar to how AIX traditionally builds its shared libraries.
- archive_expsym_cmds_GCJ="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs ${wl}-bnoentry $compiler_flags ${wl}-bE:$export_symbols${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname'
- fi
- fi
- ;;
-
- amigaos*)
- archive_cmds_GCJ='$rm $output_objdir/a2ixlibrary.data~$echo "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$echo "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$echo "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$echo "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)'
- hardcode_libdir_flag_spec_GCJ='-L$libdir'
- hardcode_minus_L_GCJ=yes
- # see comment about different semantics on the GNU ld section
- ld_shlibs_GCJ=no
- ;;
-
- bsdi[45]*)
- export_dynamic_flag_spec_GCJ=-rdynamic
- ;;
-
- cygwin* | mingw* | pw32*)
- # When not using gcc, we currently assume that we are using
- # Microsoft Visual C++.
- # hardcode_libdir_flag_spec is actually meaningless, as there is
- # no search path for DLLs.
- hardcode_libdir_flag_spec_GCJ=' '
- allow_undefined_flag_GCJ=unsupported
- # Tell ltmain to make .lib files, not .a files.
- libext=lib
- # Tell ltmain to make .dll files, not .so files.
- shrext_cmds=".dll"
- # FIXME: Setting linknames here is a bad hack.
- archive_cmds_GCJ='$CC -o $lib $libobjs $compiler_flags `echo "$deplibs" | $SED -e '\''s/ -lc$//'\''` -link -dll~linknames='
- # The linker will automatically build a .lib file if we build a DLL.
- old_archive_From_new_cmds_GCJ='true'
- # FIXME: Should let the user specify the lib program.
- old_archive_cmds_GCJ='lib /OUT:$oldlib$oldobjs$old_deplibs'
- fix_srcfile_path_GCJ='`cygpath -w "$srcfile"`'
- enable_shared_with_static_runtimes_GCJ=yes
- ;;
-
- darwin* | rhapsody*)
- case $host_os in
- rhapsody* | darwin1.[012])
- allow_undefined_flag_GCJ='${wl}-undefined ${wl}suppress'
- ;;
- *) # Darwin 1.3 on
- if test -z ${MACOSX_DEPLOYMENT_TARGET} ; then
- allow_undefined_flag_GCJ='${wl}-flat_namespace ${wl}-undefined ${wl}suppress'
- else
- case ${MACOSX_DEPLOYMENT_TARGET} in
- 10.[012])
- allow_undefined_flag_GCJ='${wl}-flat_namespace ${wl}-undefined ${wl}suppress'
- ;;
- 10.*)
- allow_undefined_flag_GCJ='${wl}-undefined ${wl}dynamic_lookup'
- ;;
- esac
- fi
- ;;
- esac
- archive_cmds_need_lc_GCJ=no
- hardcode_direct_GCJ=no
- hardcode_automatic_GCJ=yes
- hardcode_shlibpath_var_GCJ=unsupported
- whole_archive_flag_spec_GCJ=''
- link_all_deplibs_GCJ=yes
- if test "$GCC" = yes ; then
- output_verbose_link_cmd='echo'
- archive_cmds_GCJ='$CC -dynamiclib $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring'
- module_cmds_GCJ='$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags'
- # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin lds
- archive_expsym_cmds_GCJ='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -dynamiclib $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
- module_expsym_cmds_GCJ='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
- else
- case $cc_basename in
- xlc*)
- output_verbose_link_cmd='echo'
- archive_cmds_GCJ='$CC -qmkshrobj $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-install_name ${wl}`echo $rpath/$soname` $verstring'
- module_cmds_GCJ='$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags'
- # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin lds
- archive_expsym_cmds_GCJ='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -qmkshrobj $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-install_name ${wl}$rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
- module_expsym_cmds_GCJ='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
- ;;
- *)
- ld_shlibs_GCJ=no
- ;;
- esac
- fi
- ;;
-
- dgux*)
- archive_cmds_GCJ='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
- hardcode_libdir_flag_spec_GCJ='-L$libdir'
- hardcode_shlibpath_var_GCJ=no
- ;;
-
- freebsd1*)
- ld_shlibs_GCJ=no
- ;;
-
- # FreeBSD 2.2.[012] allows us to include c++rt0.o to get C++ constructor
- # support. Future versions do this automatically, but an explicit c++rt0.o
- # does not break anything, and helps significantly (at the cost of a little
- # extra space).
- freebsd2.2*)
- archive_cmds_GCJ='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags /usr/lib/c++rt0.o'
- hardcode_libdir_flag_spec_GCJ='-R$libdir'
- hardcode_direct_GCJ=yes
- hardcode_shlibpath_var_GCJ=no
- ;;
-
- # Unfortunately, older versions of FreeBSD 2 do not have this feature.
- freebsd2*)
- archive_cmds_GCJ='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags'
- hardcode_direct_GCJ=yes
- hardcode_minus_L_GCJ=yes
- hardcode_shlibpath_var_GCJ=no
- ;;
-
- # FreeBSD 3 and greater uses gcc -shared to do shared libraries.
- freebsd* | dragonfly*)
- archive_cmds_GCJ='$CC -shared -o $lib $libobjs $deplibs $compiler_flags'
- hardcode_libdir_flag_spec_GCJ='-R$libdir'
- hardcode_direct_GCJ=yes
- hardcode_shlibpath_var_GCJ=no
- ;;
-
- # GNU/kFreeBSD uses gcc -shared to do shared libraries.
- kfreebsd*-gnu)
- archive_cmds_GCJ='$CC -shared -o $lib $libobjs $deplibs $compiler_flags'
- hardcode_libdir_flag_spec_GCJ='-R$libdir'
- hardcode_direct_GCJ=yes
- hardcode_shlibpath_var_GCJ=no
- link_all_deplibs_GCJ=no
- ;;
-
- hpux9*)
- if test "$GCC" = yes; then
- archive_cmds_GCJ='$rm $output_objdir/$soname~$CC -shared -fPIC ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $libobjs $deplibs $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
- else
- archive_cmds_GCJ='$rm $output_objdir/$soname~$LD -b +b $install_libdir -o $output_objdir/$soname $libobjs $deplibs $linker_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
- fi
- hardcode_libdir_flag_spec_GCJ='${wl}+b ${wl}$libdir'
- hardcode_libdir_separator_GCJ=:
- hardcode_direct_GCJ=yes
-
- # hardcode_minus_L: Not really in the search PATH,
- # but as the default location of the library.
- hardcode_minus_L_GCJ=yes
- export_dynamic_flag_spec_GCJ='${wl}-E'
- ;;
-
- hpux10*)
- if test "$GCC" = yes -a "$with_gnu_ld" = no; then
- archive_cmds_GCJ='$CC -shared -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
- else
- archive_cmds_GCJ='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags'
- fi
- if test "$with_gnu_ld" = no; then
- hardcode_libdir_flag_spec_GCJ='${wl}+b ${wl}$libdir'
- hardcode_libdir_separator_GCJ=:
-
- hardcode_direct_GCJ=yes
- export_dynamic_flag_spec_GCJ='${wl}-E'
-
- # hardcode_minus_L: Not really in the search PATH,
- # but as the default location of the library.
- hardcode_minus_L_GCJ=yes
- fi
- ;;
-
- hpux11*)
- if test "$GCC" = yes -a "$with_gnu_ld" = no; then
- case $host_cpu in
- hppa*64*)
- archive_cmds_GCJ='$CC -shared ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
- ;;
- ia64*)
- archive_cmds_GCJ='$CC -shared ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags'
- ;;
- *)
- archive_cmds_GCJ='$CC -shared -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
- ;;
- esac
- else
- case $host_cpu in
- hppa*64*)
- archive_cmds_GCJ='$CC -b ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
- ;;
- ia64*)
- archive_cmds_GCJ='$CC -b ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags'
- ;;
- *)
- archive_cmds_GCJ='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
- ;;
- esac
- fi
- if test "$with_gnu_ld" = no; then
- hardcode_libdir_flag_spec_GCJ='${wl}+b ${wl}$libdir'
- hardcode_libdir_separator_GCJ=:
-
- case $host_cpu in
- hppa*64*|ia64*)
- hardcode_libdir_flag_spec_ld_GCJ='+b $libdir'
- hardcode_direct_GCJ=no
- hardcode_shlibpath_var_GCJ=no
- ;;
- *)
- hardcode_direct_GCJ=yes
- export_dynamic_flag_spec_GCJ='${wl}-E'
-
- # hardcode_minus_L: Not really in the search PATH,
- # but as the default location of the library.
- hardcode_minus_L_GCJ=yes
- ;;
- esac
- fi
- ;;
-
- irix5* | irix6* | nonstopux*)
- if test "$GCC" = yes; then
- archive_cmds_GCJ='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
- else
- archive_cmds_GCJ='$LD -shared $libobjs $deplibs $linker_flags -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib'
- hardcode_libdir_flag_spec_ld_GCJ='-rpath $libdir'
- fi
- hardcode_libdir_flag_spec_GCJ='${wl}-rpath ${wl}$libdir'
- hardcode_libdir_separator_GCJ=:
- link_all_deplibs_GCJ=yes
- ;;
-
- netbsd* | netbsdelf*-gnu | knetbsd*-gnu)
- if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then
- archive_cmds_GCJ='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' # a.out
- else
- archive_cmds_GCJ='$LD -shared -o $lib $libobjs $deplibs $linker_flags' # ELF
- fi
- hardcode_libdir_flag_spec_GCJ='-R$libdir'
- hardcode_direct_GCJ=yes
- hardcode_shlibpath_var_GCJ=no
- ;;
-
- newsos6)
- archive_cmds_GCJ='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
- hardcode_direct_GCJ=yes
- hardcode_libdir_flag_spec_GCJ='${wl}-rpath ${wl}$libdir'
- hardcode_libdir_separator_GCJ=:
- hardcode_shlibpath_var_GCJ=no
- ;;
-
- openbsd*)
- hardcode_direct_GCJ=yes
- hardcode_shlibpath_var_GCJ=no
- if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
- archive_cmds_GCJ='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags'
- archive_expsym_cmds_GCJ='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-retain-symbols-file,$export_symbols'
- hardcode_libdir_flag_spec_GCJ='${wl}-rpath,$libdir'
- export_dynamic_flag_spec_GCJ='${wl}-E'
- else
- case $host_os in
- openbsd[01].* | openbsd2.[0-7] | openbsd2.[0-7].*)
- archive_cmds_GCJ='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags'
- hardcode_libdir_flag_spec_GCJ='-R$libdir'
- ;;
- *)
- archive_cmds_GCJ='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags'
- hardcode_libdir_flag_spec_GCJ='${wl}-rpath,$libdir'
- ;;
- esac
- fi
- ;;
-
- os2*)
- hardcode_libdir_flag_spec_GCJ='-L$libdir'
- hardcode_minus_L_GCJ=yes
- allow_undefined_flag_GCJ=unsupported
- archive_cmds_GCJ='$echo "LIBRARY $libname INITINSTANCE" > $output_objdir/$libname.def~$echo "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~$echo DATA >> $output_objdir/$libname.def~$echo " SINGLE NONSHARED" >> $output_objdir/$libname.def~$echo EXPORTS >> $output_objdir/$libname.def~emxexp $libobjs >> $output_objdir/$libname.def~$CC -Zdll -Zcrtdll -o $lib $libobjs $deplibs $compiler_flags $output_objdir/$libname.def'
- old_archive_From_new_cmds_GCJ='emximp -o $output_objdir/$libname.a $output_objdir/$libname.def'
- ;;
-
- osf3*)
- if test "$GCC" = yes; then
- allow_undefined_flag_GCJ=' ${wl}-expect_unresolved ${wl}\*'
- archive_cmds_GCJ='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
- else
- allow_undefined_flag_GCJ=' -expect_unresolved \*'
- archive_cmds_GCJ='$LD -shared${allow_undefined_flag} $libobjs $deplibs $linker_flags -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib'
- fi
- hardcode_libdir_flag_spec_GCJ='${wl}-rpath ${wl}$libdir'
- hardcode_libdir_separator_GCJ=:
- ;;
-
- osf4* | osf5*) # as osf3* with the addition of -msym flag
- if test "$GCC" = yes; then
- allow_undefined_flag_GCJ=' ${wl}-expect_unresolved ${wl}\*'
- archive_cmds_GCJ='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
- hardcode_libdir_flag_spec_GCJ='${wl}-rpath ${wl}$libdir'
- else
- allow_undefined_flag_GCJ=' -expect_unresolved \*'
- archive_cmds_GCJ='$LD -shared${allow_undefined_flag} $libobjs $deplibs $linker_flags -msym -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib'
- archive_expsym_cmds_GCJ='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done; echo "-hidden">> $lib.exp~
- $LD -shared${allow_undefined_flag} -input $lib.exp $linker_flags $libobjs $deplibs -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib~$rm $lib.exp'
-
- # Both c and cxx compiler support -rpath directly
- hardcode_libdir_flag_spec_GCJ='-rpath $libdir'
- fi
- hardcode_libdir_separator_GCJ=:
- ;;
-
- solaris*)
- no_undefined_flag_GCJ=' -z text'
- if test "$GCC" = yes; then
- wlarc='${wl}'
- archive_cmds_GCJ='$CC -shared ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
- archive_expsym_cmds_GCJ='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~
- $CC -shared ${wl}-M ${wl}$lib.exp ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags~$rm $lib.exp'
- else
- wlarc=''
- archive_cmds_GCJ='$LD -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $linker_flags'
- archive_expsym_cmds_GCJ='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~
- $LD -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linker_flags~$rm $lib.exp'
- fi
- hardcode_libdir_flag_spec_GCJ='-R$libdir'
- hardcode_shlibpath_var_GCJ=no
- case $host_os in
- solaris2.[0-5] | solaris2.[0-5].*) ;;
- *)
- # The compiler driver will combine linker options so we
- # cannot just pass the convience library names through
- # without $wl, iff we do not link with $LD.
- # Luckily, gcc supports the same syntax we need for Sun Studio.
- # Supported since Solaris 2.6 (maybe 2.5.1?)
- case $wlarc in
- '')
- whole_archive_flag_spec_GCJ='-z allextract$convenience -z defaultextract' ;;
- *)
- whole_archive_flag_spec_GCJ='${wl}-z ${wl}allextract`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}-z ${wl}defaultextract' ;;
- esac ;;
- esac
- link_all_deplibs_GCJ=yes
- ;;
-
- sunos4*)
- if test "x$host_vendor" = xsequent; then
- # Use $CC to link under sequent, because it throws in some extra .o
- # files that make .init and .fini sections work.
- archive_cmds_GCJ='$CC -G ${wl}-h $soname -o $lib $libobjs $deplibs $compiler_flags'
- else
- archive_cmds_GCJ='$LD -assert pure-text -Bstatic -o $lib $libobjs $deplibs $linker_flags'
- fi
- hardcode_libdir_flag_spec_GCJ='-L$libdir'
- hardcode_direct_GCJ=yes
- hardcode_minus_L_GCJ=yes
- hardcode_shlibpath_var_GCJ=no
- ;;
-
- sysv4)
- case $host_vendor in
- sni)
- archive_cmds_GCJ='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
- hardcode_direct_GCJ=yes # is this really true???
- ;;
- siemens)
- ## LD is ld it makes a PLAMLIB
- ## CC just makes a GrossModule.
- archive_cmds_GCJ='$LD -G -o $lib $libobjs $deplibs $linker_flags'
- reload_cmds_GCJ='$CC -r -o $output$reload_objs'
- hardcode_direct_GCJ=no
- ;;
- motorola)
- archive_cmds_GCJ='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
- hardcode_direct_GCJ=no #Motorola manual says yes, but my tests say they lie
- ;;
- esac
- runpath_var='LD_RUN_PATH'
- hardcode_shlibpath_var_GCJ=no
- ;;
-
- sysv4.3*)
- archive_cmds_GCJ='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
- hardcode_shlibpath_var_GCJ=no
- export_dynamic_flag_spec_GCJ='-Bexport'
- ;;
-
- sysv4*MP*)
- if test -d /usr/nec; then
- archive_cmds_GCJ='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
- hardcode_shlibpath_var_GCJ=no
- runpath_var=LD_RUN_PATH
- hardcode_runpath_var=yes
- ld_shlibs_GCJ=yes
- fi
- ;;
-
- sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[01].[10]* | unixware7*)
- no_undefined_flag_GCJ='${wl}-z,text'
- archive_cmds_need_lc_GCJ=no
- hardcode_shlibpath_var_GCJ=no
- runpath_var='LD_RUN_PATH'
-
- if test "$GCC" = yes; then
- archive_cmds_GCJ='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
- archive_expsym_cmds_GCJ='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
- else
- archive_cmds_GCJ='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
- archive_expsym_cmds_GCJ='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
- fi
- ;;
-
- sysv5* | sco3.2v5* | sco5v6*)
- # Note: We can NOT use -z defs as we might desire, because we do not
- # link with -lc, and that would cause any symbols used from libc to
- # always be unresolved, which means just about no library would
- # ever link correctly. If we're not using GNU ld we use -z text
- # though, which does catch some bad symbols but isn't as heavy-handed
- # as -z defs.
- no_undefined_flag_GCJ='${wl}-z,text'
- allow_undefined_flag_GCJ='${wl}-z,nodefs'
- archive_cmds_need_lc_GCJ=no
- hardcode_shlibpath_var_GCJ=no
- hardcode_libdir_flag_spec_GCJ='`test -z "$SCOABSPATH" && echo ${wl}-R,$libdir`'
- hardcode_libdir_separator_GCJ=':'
- link_all_deplibs_GCJ=yes
- export_dynamic_flag_spec_GCJ='${wl}-Bexport'
- runpath_var='LD_RUN_PATH'
-
- if test "$GCC" = yes; then
- archive_cmds_GCJ='$CC -shared ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags'
- archive_expsym_cmds_GCJ='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags'
- else
- archive_cmds_GCJ='$CC -G ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags'
- archive_expsym_cmds_GCJ='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags'
- fi
- ;;
-
- uts4*)
- archive_cmds_GCJ='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
- hardcode_libdir_flag_spec_GCJ='-L$libdir'
- hardcode_shlibpath_var_GCJ=no
- ;;
-
- *)
- ld_shlibs_GCJ=no
- ;;
- esac
- fi
-
-echo "$as_me:$LINENO: result: $ld_shlibs_GCJ" >&5
-echo "${ECHO_T}$ld_shlibs_GCJ" >&6
-test "$ld_shlibs_GCJ" = no && can_build_shared=no
-
-#
-# Do we need to explicitly link libc?
-#
-case "x$archive_cmds_need_lc_GCJ" in
-x|xyes)
- # Assume -lc should be added
- archive_cmds_need_lc_GCJ=yes
-
- if test "$enable_shared" = yes && test "$GCC" = yes; then
- case $archive_cmds_GCJ in
- *'~'*)
- # FIXME: we may have to deal with multi-command sequences.
- ;;
- '$CC '*)
- # Test whether the compiler implicitly links with -lc since on some
- # systems, -lgcc has to come before -lc. If gcc already passes -lc
- # to ld, don't add -lc before -lgcc.
- echo "$as_me:$LINENO: checking whether -lc should be explicitly linked in" >&5
-echo $ECHO_N "checking whether -lc should be explicitly linked in... $ECHO_C" >&6
- $rm conftest*
- printf "$lt_simple_compile_test_code" > conftest.$ac_ext
-
- if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
- (eval $ac_compile) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } 2>conftest.err; then
- soname=conftest
- lib=conftest
- libobjs=conftest.$ac_objext
- deplibs=
- wl=$lt_prog_compiler_wl_GCJ
- pic_flag=$lt_prog_compiler_pic_GCJ
- compiler_flags=-v
- linker_flags=-v
- verstring=
- output_objdir=.
- libname=conftest
- lt_save_allow_undefined_flag=$allow_undefined_flag_GCJ
- allow_undefined_flag_GCJ=
- if { (eval echo "$as_me:$LINENO: \"$archive_cmds_GCJ 2\>\&1 \| grep \" -lc \" \>/dev/null 2\>\&1\"") >&5
- (eval $archive_cmds_GCJ 2\>\&1 \| grep \" -lc \" \>/dev/null 2\>\&1) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }
- then
- archive_cmds_need_lc_GCJ=no
- else
- archive_cmds_need_lc_GCJ=yes
- fi
- allow_undefined_flag_GCJ=$lt_save_allow_undefined_flag
- else
- cat conftest.err 1>&5
- fi
- $rm conftest*
- echo "$as_me:$LINENO: result: $archive_cmds_need_lc_GCJ" >&5
-echo "${ECHO_T}$archive_cmds_need_lc_GCJ" >&6
- ;;
- esac
- fi
- ;;
-esac
-
-echo "$as_me:$LINENO: checking dynamic linker characteristics" >&5
-echo $ECHO_N "checking dynamic linker characteristics... $ECHO_C" >&6
-library_names_spec=
-libname_spec='lib$name'
-soname_spec=
-shrext_cmds=".so"
-postinstall_cmds=
-postuninstall_cmds=
-finish_cmds=
-finish_eval=
-shlibpath_var=
-shlibpath_overrides_runpath=unknown
-version_type=none
-dynamic_linker="$host_os ld.so"
-sys_lib_dlsearch_path_spec="/lib /usr/lib"
-if test "$GCC" = yes; then
- sys_lib_search_path_spec=`$CC -print-search-dirs | grep "^libraries:" | $SED -e "s/^libraries://" -e "s,=/,/,g"`
- if echo "$sys_lib_search_path_spec" | grep ';' >/dev/null ; then
- # if the path contains ";" then we assume it to be the separator
- # otherwise default to the standard path separator (i.e. ":") - it is
- # assumed that no part of a normal pathname contains ";" but that should
- # okay in the real world where ";" in dirpaths is itself problematic.
- sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'`
- else
- sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"`
- fi
-else
- sys_lib_search_path_spec="/lib /usr/lib /usr/local/lib"
-fi
-need_lib_prefix=unknown
-hardcode_into_libs=no
-
-# when you set need_version to no, make sure it does not cause -set_version
-# flags to be left without arguments
-need_version=unknown
-
-case $host_os in
-aix3*)
- version_type=linux
- library_names_spec='${libname}${release}${shared_ext}$versuffix $libname.a'
- shlibpath_var=LIBPATH
-
- # AIX 3 has no versioning support, so we append a major version to the name.
- soname_spec='${libname}${release}${shared_ext}$major'
- ;;
-
-aix4* | aix5*)
- version_type=linux
- need_lib_prefix=no
- need_version=no
- hardcode_into_libs=yes
- if test "$host_cpu" = ia64; then
- # AIX 5 supports IA64
- library_names_spec='${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext}$versuffix $libname${shared_ext}'
- shlibpath_var=LD_LIBRARY_PATH
- else
- # With GCC up to 2.95.x, collect2 would create an import file
- # for dependence libraries. The import file would start with
- # the line `#! .'. This would cause the generated library to
- # depend on `.', always an invalid library. This was fixed in
- # development snapshots of GCC prior to 3.0.
- case $host_os in
- aix4 | aix4.[01] | aix4.[01].*)
- if { echo '#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 97)'
- echo ' yes '
- echo '#endif'; } | ${CC} -E - | grep yes > /dev/null; then
- :
- else
- can_build_shared=no
- fi
- ;;
- esac
- # AIX (on Power*) has no versioning support, so currently we can not hardcode correct
- # soname into executable. Probably we can add versioning support to
- # collect2, so additional links can be useful in future.
- if test "$aix_use_runtimelinking" = yes; then
- # If using run time linking (on AIX 4.2 or later) use lib<name>.so
- # instead of lib<name>.a to let people know that these are not
- # typical AIX shared libraries.
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
- else
- # We preserve .a as extension for shared libraries through AIX4.2
- # and later when we are not doing run time linking.
- library_names_spec='${libname}${release}.a $libname.a'
- soname_spec='${libname}${release}${shared_ext}$major'
- fi
- shlibpath_var=LIBPATH
- fi
- ;;
-
-amigaos*)
- library_names_spec='$libname.ixlibrary $libname.a'
- # Create ${libname}_ixlibrary.a entries in /sys/libs.
- finish_eval='for lib in `ls $libdir/*.ixlibrary 2>/dev/null`; do libname=`$echo "X$lib" | $Xsed -e '\''s%^.*/\([^/]*\)\.ixlibrary$%\1%'\''`; test $rm /sys/libs/${libname}_ixlibrary.a; $show "cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a"; cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a || exit 1; done'
- ;;
-
-beos*)
- library_names_spec='${libname}${shared_ext}'
- dynamic_linker="$host_os ld.so"
- shlibpath_var=LIBRARY_PATH
- ;;
-
-bsdi[45]*)
- version_type=linux
- need_version=no
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
- soname_spec='${libname}${release}${shared_ext}$major'
- finish_cmds='PATH="\$PATH:/sbin" ldconfig $libdir'
- shlibpath_var=LD_LIBRARY_PATH
- sys_lib_search_path_spec="/shlib /usr/lib /usr/X11/lib /usr/contrib/lib /lib /usr/local/lib"
- sys_lib_dlsearch_path_spec="/shlib /usr/lib /usr/local/lib"
- # the default ld.so.conf also contains /usr/contrib/lib and
- # /usr/X11R6/lib (/usr/X11 is a link to /usr/X11R6), but let us allow
- # libtool to hard-code these into programs
- ;;
-
-cygwin* | mingw* | pw32*)
- version_type=windows
- shrext_cmds=".dll"
- need_version=no
- need_lib_prefix=no
-
- case $GCC,$host_os in
- yes,cygwin* | yes,mingw* | yes,pw32*)
- library_names_spec='$libname.dll.a'
- # DLL is installed to $(libdir)/../bin by postinstall_cmds
- postinstall_cmds='base_file=`basename \${file}`~
- dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i;echo \$dlname'\''`~
- dldir=$destdir/`dirname \$dlpath`~
- test -d \$dldir || mkdir -p \$dldir~
- $install_prog $dir/$dlname \$dldir/$dlname~
- chmod a+x \$dldir/$dlname'
- postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~
- dlpath=$dir/\$dldll~
- $rm \$dlpath'
- shlibpath_overrides_runpath=yes
-
- case $host_os in
- cygwin*)
- # Cygwin DLLs use 'cyg' prefix rather than 'lib'
- soname_spec='`echo ${libname} | sed -e 's/^lib/cyg/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}'
- sys_lib_search_path_spec="/usr/lib /lib/w32api /lib /usr/local/lib"
- ;;
- mingw*)
- # MinGW DLLs use traditional 'lib' prefix
- soname_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}'
- sys_lib_search_path_spec=`$CC -print-search-dirs | grep "^libraries:" | $SED -e "s/^libraries://" -e "s,=/,/,g"`
- if echo "$sys_lib_search_path_spec" | grep ';[c-zC-Z]:/' >/dev/null; then
- # It is most probably a Windows format PATH printed by
- # mingw gcc, but we are running on Cygwin. Gcc prints its search
- # path with ; separators, and with drive letters. We can handle the
- # drive letters (cygwin fileutils understands them), so leave them,
- # especially as we might pass files found there to a mingw objdump,
- # which wouldn't understand a cygwinified path. Ahh.
- sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'`
- else
- sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"`
- fi
- ;;
- pw32*)
- # pw32 DLLs use 'pw' prefix rather than 'lib'
- library_names_spec='`echo ${libname} | sed -e 's/^lib/pw/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}'
- ;;
- esac
- ;;
-
- *)
- library_names_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext} $libname.lib'
- ;;
- esac
- dynamic_linker='Win32 ld.exe'
- # FIXME: first we should search . and the directory the executable is in
- shlibpath_var=PATH
- ;;
-
-darwin* | rhapsody*)
- dynamic_linker="$host_os dyld"
- version_type=darwin
- need_lib_prefix=no
- need_version=no
- library_names_spec='${libname}${release}${versuffix}$shared_ext ${libname}${release}${major}$shared_ext ${libname}$shared_ext'
- soname_spec='${libname}${release}${major}$shared_ext'
- shlibpath_overrides_runpath=yes
- shlibpath_var=DYLD_LIBRARY_PATH
- shrext_cmds='`test .$module = .yes && echo .so || echo .dylib`'
- # Apple's gcc prints 'gcc -print-search-dirs' doesn't operate the same.
- if test "$GCC" = yes; then
- sys_lib_search_path_spec=`$CC -print-search-dirs | tr "\n" "$PATH_SEPARATOR" | sed -e 's/libraries:/@libraries:/' | tr "@" "\n" | grep "^libraries:" | sed -e "s/^libraries://" -e "s,=/,/,g" -e "s,$PATH_SEPARATOR, ,g" -e "s,.*,& /lib /usr/lib /usr/local/lib,g"`
- else
- sys_lib_search_path_spec='/lib /usr/lib /usr/local/lib'
- fi
- sys_lib_dlsearch_path_spec='/usr/local/lib /lib /usr/lib'
- ;;
-
-dgux*)
- version_type=linux
- need_lib_prefix=no
- need_version=no
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname$shared_ext'
- soname_spec='${libname}${release}${shared_ext}$major'
- shlibpath_var=LD_LIBRARY_PATH
- ;;
-
-freebsd1*)
- dynamic_linker=no
- ;;
-
-kfreebsd*-gnu)
- version_type=linux
- need_lib_prefix=no
- need_version=no
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
- soname_spec='${libname}${release}${shared_ext}$major'
- shlibpath_var=LD_LIBRARY_PATH
- shlibpath_overrides_runpath=no
- hardcode_into_libs=yes
- dynamic_linker='GNU ld.so'
- ;;
-
-freebsd* | dragonfly*)
- # DragonFly does not have aout. When/if they implement a new
- # versioning mechanism, adjust this.
- if test -x /usr/bin/objformat; then
- objformat=`/usr/bin/objformat`
- else
- case $host_os in
- freebsd[123]*) objformat=aout ;;
- *) objformat=elf ;;
- esac
- fi
- version_type=freebsd-$objformat
- case $version_type in
- freebsd-elf*)
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}'
- need_version=no
- need_lib_prefix=no
- ;;
- freebsd-*)
- library_names_spec='${libname}${release}${shared_ext}$versuffix $libname${shared_ext}$versuffix'
- need_version=yes
- ;;
- esac
- shlibpath_var=LD_LIBRARY_PATH
- case $host_os in
- freebsd2*)
- shlibpath_overrides_runpath=yes
- ;;
- freebsd3.[01]* | freebsdelf3.[01]*)
- shlibpath_overrides_runpath=yes
- hardcode_into_libs=yes
- ;;
- freebsd3.[2-9]* | freebsdelf3.[2-9]* | \
- freebsd4.[0-5] | freebsdelf4.[0-5] | freebsd4.1.1 | freebsdelf4.1.1)
- shlibpath_overrides_runpath=no
- hardcode_into_libs=yes
- ;;
- freebsd*) # from 4.6 on
- shlibpath_overrides_runpath=yes
- hardcode_into_libs=yes
- ;;
- esac
- ;;
-
-gnu*)
- version_type=linux
- need_lib_prefix=no
- need_version=no
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}'
- soname_spec='${libname}${release}${shared_ext}$major'
- shlibpath_var=LD_LIBRARY_PATH
- hardcode_into_libs=yes
- ;;
-
-hpux9* | hpux10* | hpux11*)
- # Give a soname corresponding to the major version so that dld.sl refuses to
- # link against other versions.
- version_type=sunos
- need_lib_prefix=no
- need_version=no
- case $host_cpu in
- ia64*)
- shrext_cmds='.so'
- hardcode_into_libs=yes
- dynamic_linker="$host_os dld.so"
- shlibpath_var=LD_LIBRARY_PATH
- shlibpath_overrides_runpath=yes # Unless +noenvvar is specified.
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
- soname_spec='${libname}${release}${shared_ext}$major'
- if test "X$HPUX_IA64_MODE" = X32; then
- sys_lib_search_path_spec="/usr/lib/hpux32 /usr/local/lib/hpux32 /usr/local/lib"
- else
- sys_lib_search_path_spec="/usr/lib/hpux64 /usr/local/lib/hpux64"
- fi
- sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec
- ;;
- hppa*64*)
- shrext_cmds='.sl'
- hardcode_into_libs=yes
- dynamic_linker="$host_os dld.sl"
- shlibpath_var=LD_LIBRARY_PATH # How should we handle SHLIB_PATH
- shlibpath_overrides_runpath=yes # Unless +noenvvar is specified.
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
- soname_spec='${libname}${release}${shared_ext}$major'
- sys_lib_search_path_spec="/usr/lib/pa20_64 /usr/ccs/lib/pa20_64"
- sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec
- ;;
- *)
- shrext_cmds='.sl'
- dynamic_linker="$host_os dld.sl"
- shlibpath_var=SHLIB_PATH
- shlibpath_overrides_runpath=no # +s is required to enable SHLIB_PATH
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
- soname_spec='${libname}${release}${shared_ext}$major'
- ;;
- esac
- # HP-UX runs *really* slowly unless shared libraries are mode 555.
- postinstall_cmds='chmod 555 $lib'
- ;;
-
-interix3*)
- version_type=linux
- need_lib_prefix=no
- need_version=no
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
- soname_spec='${libname}${release}${shared_ext}$major'
- dynamic_linker='Interix 3.x ld.so.1 (PE, like ELF)'
- shlibpath_var=LD_LIBRARY_PATH
- shlibpath_overrides_runpath=no
- hardcode_into_libs=yes
- ;;
-
-irix5* | irix6* | nonstopux*)
- case $host_os in
- nonstopux*) version_type=nonstopux ;;
- *)
- if test "$lt_cv_prog_gnu_ld" = yes; then
- version_type=linux
- else
- version_type=irix
- fi ;;
- esac
- need_lib_prefix=no
- need_version=no
- soname_spec='${libname}${release}${shared_ext}$major'
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext} $libname${shared_ext}'
- case $host_os in
- irix5* | nonstopux*)
- libsuff= shlibsuff=
- ;;
- *)
- case $LD in # libtool.m4 will add one of these switches to LD
- *-32|*"-32 "|*-melf32bsmip|*"-melf32bsmip ")
- libsuff= shlibsuff= libmagic=32-bit;;
- *-n32|*"-n32 "|*-melf32bmipn32|*"-melf32bmipn32 ")
- libsuff=32 shlibsuff=N32 libmagic=N32;;
- *-64|*"-64 "|*-melf64bmip|*"-melf64bmip ")
- libsuff=64 shlibsuff=64 libmagic=64-bit;;
- *) libsuff= shlibsuff= libmagic=never-match;;
- esac
- ;;
- esac
- shlibpath_var=LD_LIBRARY${shlibsuff}_PATH
- shlibpath_overrides_runpath=no
- sys_lib_search_path_spec="/usr/lib${libsuff} /lib${libsuff} /usr/local/lib${libsuff}"
- sys_lib_dlsearch_path_spec="/usr/lib${libsuff} /lib${libsuff}"
- hardcode_into_libs=yes
- ;;
-
-# No shared lib support for Linux oldld, aout, or coff.
-linux*oldld* | linux*aout* | linux*coff*)
- dynamic_linker=no
- ;;
-
-# This must be Linux ELF.
-linux*)
- version_type=linux
- need_lib_prefix=no
- need_version=no
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
- soname_spec='${libname}${release}${shared_ext}$major'
- finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir'
- shlibpath_var=LD_LIBRARY_PATH
- shlibpath_overrides_runpath=no
- # This implies no fast_install, which is unacceptable.
- # Some rework will be needed to allow for fast_install
- # before this can be enabled.
- hardcode_into_libs=yes
-
- # Append ld.so.conf contents to the search path
- if test -f /etc/ld.so.conf; then
- lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s", \$2)); skip = 1; } { if (!skip) print \$0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;s/[:, ]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;/^$/d' | tr '\n' ' '`
- sys_lib_dlsearch_path_spec="/lib /usr/lib $lt_ld_extra"
- fi
-
- # We used to test for /lib/ld.so.1 and disable shared libraries on
- # powerpc, because MkLinux only supported shared libraries with the
- # GNU dynamic linker. Since this was broken with cross compilers,
- # most powerpc-linux boxes support dynamic linking these days and
- # people can always --disable-shared, the test was removed, and we
- # assume the GNU/Linux dynamic linker is in use.
- dynamic_linker='GNU/Linux ld.so'
- ;;
-
-netbsdelf*-gnu)
- version_type=linux
- need_lib_prefix=no
- need_version=no
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
- soname_spec='${libname}${release}${shared_ext}$major'
- shlibpath_var=LD_LIBRARY_PATH
- shlibpath_overrides_runpath=no
- hardcode_into_libs=yes
- dynamic_linker='NetBSD ld.elf_so'
- ;;
-
-knetbsd*-gnu)
- version_type=linux
- need_lib_prefix=no
- need_version=no
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
- soname_spec='${libname}${release}${shared_ext}$major'
- shlibpath_var=LD_LIBRARY_PATH
- shlibpath_overrides_runpath=no
- hardcode_into_libs=yes
- dynamic_linker='GNU ld.so'
- ;;
-
-netbsd*)
- version_type=sunos
- need_lib_prefix=no
- need_version=no
- if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
- finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir'
- dynamic_linker='NetBSD (a.out) ld.so'
- else
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
- soname_spec='${libname}${release}${shared_ext}$major'
- dynamic_linker='NetBSD ld.elf_so'
- fi
- shlibpath_var=LD_LIBRARY_PATH
- shlibpath_overrides_runpath=yes
- hardcode_into_libs=yes
- ;;
-
-newsos6)
- version_type=linux
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
- shlibpath_var=LD_LIBRARY_PATH
- shlibpath_overrides_runpath=yes
- ;;
-
-nto-qnx*)
- version_type=linux
- need_lib_prefix=no
- need_version=no
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
- soname_spec='${libname}${release}${shared_ext}$major'
- shlibpath_var=LD_LIBRARY_PATH
- shlibpath_overrides_runpath=yes
- ;;
-
-openbsd*)
- version_type=sunos
- sys_lib_dlsearch_path_spec="/usr/lib"
- need_lib_prefix=no
- # Some older versions of OpenBSD (3.3 at least) *do* need versioned libs.
- case $host_os in
- openbsd3.3 | openbsd3.3.*) need_version=yes ;;
- *) need_version=no ;;
- esac
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
- finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir'
- shlibpath_var=LD_LIBRARY_PATH
- if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
- case $host_os in
- openbsd2.[89] | openbsd2.[89].*)
- shlibpath_overrides_runpath=no
- ;;
- *)
- shlibpath_overrides_runpath=yes
- ;;
- esac
- else
- shlibpath_overrides_runpath=yes
- fi
- ;;
-
-os2*)
- libname_spec='$name'
- shrext_cmds=".dll"
- need_lib_prefix=no
- library_names_spec='$libname${shared_ext} $libname.a'
- dynamic_linker='OS/2 ld.exe'
- shlibpath_var=LIBPATH
- ;;
-
-osf3* | osf4* | osf5*)
- version_type=osf
- need_lib_prefix=no
- need_version=no
- soname_spec='${libname}${release}${shared_ext}$major'
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
- shlibpath_var=LD_LIBRARY_PATH
- sys_lib_search_path_spec="/usr/shlib /usr/ccs/lib /usr/lib/cmplrs/cc /usr/lib /usr/local/lib /var/shlib"
- sys_lib_dlsearch_path_spec="$sys_lib_search_path_spec"
- ;;
-
-solaris*)
- version_type=linux
- need_lib_prefix=no
- need_version=no
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
- soname_spec='${libname}${release}${shared_ext}$major'
- shlibpath_var=LD_LIBRARY_PATH
- shlibpath_overrides_runpath=yes
- hardcode_into_libs=yes
- # ldd complains unless libraries are executable
- postinstall_cmds='chmod +x $lib'
- ;;
-
-sunos4*)
- version_type=sunos
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
- finish_cmds='PATH="\$PATH:/usr/etc" ldconfig $libdir'
- shlibpath_var=LD_LIBRARY_PATH
- shlibpath_overrides_runpath=yes
- if test "$with_gnu_ld" = yes; then
- need_lib_prefix=no
- fi
- need_version=yes
- ;;
-
-sysv4 | sysv4.3*)
- version_type=linux
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
- soname_spec='${libname}${release}${shared_ext}$major'
- shlibpath_var=LD_LIBRARY_PATH
- case $host_vendor in
- sni)
- shlibpath_overrides_runpath=no
- need_lib_prefix=no
- export_dynamic_flag_spec='${wl}-Blargedynsym'
- runpath_var=LD_RUN_PATH
- ;;
- siemens)
- need_lib_prefix=no
- ;;
- motorola)
- need_lib_prefix=no
- need_version=no
- shlibpath_overrides_runpath=no
- sys_lib_search_path_spec='/lib /usr/lib /usr/ccs/lib'
- ;;
- esac
- ;;
-
-sysv4*MP*)
- if test -d /usr/nec ;then
- version_type=linux
- library_names_spec='$libname${shared_ext}.$versuffix $libname${shared_ext}.$major $libname${shared_ext}'
- soname_spec='$libname${shared_ext}.$major'
- shlibpath_var=LD_LIBRARY_PATH
- fi
- ;;
-
-sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*)
- version_type=freebsd-elf
- need_lib_prefix=no
- need_version=no
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}'
- soname_spec='${libname}${release}${shared_ext}$major'
- shlibpath_var=LD_LIBRARY_PATH
- hardcode_into_libs=yes
- if test "$with_gnu_ld" = yes; then
- sys_lib_search_path_spec='/usr/local/lib /usr/gnu/lib /usr/ccs/lib /usr/lib /lib'
- shlibpath_overrides_runpath=no
- else
- sys_lib_search_path_spec='/usr/ccs/lib /usr/lib'
- shlibpath_overrides_runpath=yes
- case $host_os in
- sco3.2v5*)
- sys_lib_search_path_spec="$sys_lib_search_path_spec /lib"
- ;;
- esac
- fi
- sys_lib_dlsearch_path_spec='/usr/lib'
- ;;
-
-uts4*)
- version_type=linux
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
- soname_spec='${libname}${release}${shared_ext}$major'
- shlibpath_var=LD_LIBRARY_PATH
- ;;
-
-*)
- dynamic_linker=no
- ;;
-esac
-echo "$as_me:$LINENO: result: $dynamic_linker" >&5
-echo "${ECHO_T}$dynamic_linker" >&6
-test "$dynamic_linker" = no && can_build_shared=no
-
-variables_saved_for_relink="PATH $shlibpath_var $runpath_var"
-if test "$GCC" = yes; then
- variables_saved_for_relink="$variables_saved_for_relink GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH"
-fi
-
-echo "$as_me:$LINENO: checking how to hardcode library paths into programs" >&5
-echo $ECHO_N "checking how to hardcode library paths into programs... $ECHO_C" >&6
-hardcode_action_GCJ=
-if test -n "$hardcode_libdir_flag_spec_GCJ" || \
- test -n "$runpath_var_GCJ" || \
- test "X$hardcode_automatic_GCJ" = "Xyes" ; then
-
- # We can hardcode non-existant directories.
- if test "$hardcode_direct_GCJ" != no &&
- # If the only mechanism to avoid hardcoding is shlibpath_var, we
- # have to relink, otherwise we might link with an installed library
- # when we should be linking with a yet-to-be-installed one
- ## test "$_LT_AC_TAGVAR(hardcode_shlibpath_var, GCJ)" != no &&
- test "$hardcode_minus_L_GCJ" != no; then
- # Linking always hardcodes the temporary library directory.
- hardcode_action_GCJ=relink
- else
- # We can link without hardcoding, and we can hardcode nonexisting dirs.
- hardcode_action_GCJ=immediate
- fi
-else
- # We cannot hardcode anything, or else we can only hardcode existing
- # directories.
- hardcode_action_GCJ=unsupported
-fi
-echo "$as_me:$LINENO: result: $hardcode_action_GCJ" >&5
-echo "${ECHO_T}$hardcode_action_GCJ" >&6
-
-if test "$hardcode_action_GCJ" = relink; then
- # Fast installation is not supported
- enable_fast_install=no
-elif test "$shlibpath_overrides_runpath" = yes ||
- test "$enable_shared" = no; then
- # Fast installation is not necessary
- enable_fast_install=needless
-fi
-
-
-# The else clause should only fire when bootstrapping the
-# libtool distribution, otherwise you forgot to ship ltmain.sh
-# with your package, and you will get complaints that there are
-# no rules to generate ltmain.sh.
-if test -f "$ltmain"; then
- # See if we are running on zsh, and set the options which allow our commands through
- # without removal of \ escapes.
- if test -n "${ZSH_VERSION+set}" ; then
- setopt NO_GLOB_SUBST
- fi
- # Now quote all the things that may contain metacharacters while being
- # careful not to overquote the AC_SUBSTed values. We take copies of the
- # variables and quote the copies for generation of the libtool script.
- for var in echo old_CC old_CFLAGS AR AR_FLAGS EGREP RANLIB LN_S LTCC LTCFLAGS NM \
- SED SHELL STRIP \
- libname_spec library_names_spec soname_spec extract_expsyms_cmds \
- old_striplib striplib file_magic_cmd finish_cmds finish_eval \
- deplibs_check_method reload_flag reload_cmds need_locks \
- lt_cv_sys_global_symbol_pipe lt_cv_sys_global_symbol_to_cdecl \
- lt_cv_sys_global_symbol_to_c_name_address \
- sys_lib_search_path_spec sys_lib_dlsearch_path_spec \
- old_postinstall_cmds old_postuninstall_cmds \
- compiler_GCJ \
- CC_GCJ \
- LD_GCJ \
- lt_prog_compiler_wl_GCJ \
- lt_prog_compiler_pic_GCJ \
- lt_prog_compiler_static_GCJ \
- lt_prog_compiler_no_builtin_flag_GCJ \
- export_dynamic_flag_spec_GCJ \
- thread_safe_flag_spec_GCJ \
- whole_archive_flag_spec_GCJ \
- enable_shared_with_static_runtimes_GCJ \
- old_archive_cmds_GCJ \
- old_archive_from_new_cmds_GCJ \
- predep_objects_GCJ \
- postdep_objects_GCJ \
- predeps_GCJ \
- postdeps_GCJ \
- compiler_lib_search_path_GCJ \
- archive_cmds_GCJ \
- archive_expsym_cmds_GCJ \
- postinstall_cmds_GCJ \
- postuninstall_cmds_GCJ \
- old_archive_from_expsyms_cmds_GCJ \
- allow_undefined_flag_GCJ \
- no_undefined_flag_GCJ \
- export_symbols_cmds_GCJ \
- hardcode_libdir_flag_spec_GCJ \
- hardcode_libdir_flag_spec_ld_GCJ \
- hardcode_libdir_separator_GCJ \
- hardcode_automatic_GCJ \
- module_cmds_GCJ \
- module_expsym_cmds_GCJ \
- lt_cv_prog_compiler_c_o_GCJ \
- exclude_expsyms_GCJ \
- include_expsyms_GCJ; do
-
- case $var in
- old_archive_cmds_GCJ | \
- old_archive_from_new_cmds_GCJ | \
- archive_cmds_GCJ | \
- archive_expsym_cmds_GCJ | \
- module_cmds_GCJ | \
- module_expsym_cmds_GCJ | \
- old_archive_from_expsyms_cmds_GCJ | \
- export_symbols_cmds_GCJ | \
- extract_expsyms_cmds | reload_cmds | finish_cmds | \
- postinstall_cmds | postuninstall_cmds | \
- old_postinstall_cmds | old_postuninstall_cmds | \
- sys_lib_search_path_spec | sys_lib_dlsearch_path_spec)
- # Double-quote double-evaled strings.
- eval "lt_$var=\\\"\`\$echo \"X\$$var\" | \$Xsed -e \"\$double_quote_subst\" -e \"\$sed_quote_subst\" -e \"\$delay_variable_subst\"\`\\\""
- ;;
- *)
- eval "lt_$var=\\\"\`\$echo \"X\$$var\" | \$Xsed -e \"\$sed_quote_subst\"\`\\\""
- ;;
- esac
- done
-
- case $lt_echo in
- *'\$0 --fallback-echo"')
- lt_echo=`$echo "X$lt_echo" | $Xsed -e 's/\\\\\\\$0 --fallback-echo"$/$0 --fallback-echo"/'`
- ;;
- esac
-
-cfgfile="$ofile"
-
- cat <<__EOF__ >> "$cfgfile"
-# ### BEGIN LIBTOOL TAG CONFIG: $tagname
-
-# Libtool was configured on host `(hostname || uname -n) 2>/dev/null | sed 1q`:
-
-# Shell to use when invoking shell scripts.
-SHELL=$lt_SHELL
-
-# Whether or not to build shared libraries.
-build_libtool_libs=$enable_shared
-
-# Whether or not to build static libraries.
-build_old_libs=$enable_static
-
-# Whether or not to add -lc for building shared libraries.
-build_libtool_need_lc=$archive_cmds_need_lc_GCJ
-
-# Whether or not to disallow shared libs when runtime libs are static
-allow_libtool_libs_with_static_runtimes=$enable_shared_with_static_runtimes_GCJ
-
-# Whether or not to optimize for fast installation.
-fast_install=$enable_fast_install
-
-# The host system.
-host_alias=$host_alias
-host=$host
-host_os=$host_os
-
-# The build system.
-build_alias=$build_alias
-build=$build
-build_os=$build_os
-
-# An echo program that does not interpret backslashes.
-echo=$lt_echo
-
-# The archiver.
-AR=$lt_AR
-AR_FLAGS=$lt_AR_FLAGS
-
-# A C compiler.
-LTCC=$lt_LTCC
-
-# LTCC compiler flags.
-LTCFLAGS=$lt_LTCFLAGS
-
-# A language-specific compiler.
-CC=$lt_compiler_GCJ
-
-# Is the compiler the GNU C compiler?
-with_gcc=$GCC_GCJ
-
-# An ERE matcher.
-EGREP=$lt_EGREP
-
-# The linker used to build libraries.
-LD=$lt_LD_GCJ
-
-# Whether we need hard or soft links.
-LN_S=$lt_LN_S
-
-# A BSD-compatible nm program.
-NM=$lt_NM
-
-# A symbol stripping program
-STRIP=$lt_STRIP
-
-# Used to examine libraries when file_magic_cmd begins "file"
-MAGIC_CMD=$MAGIC_CMD
-
-# Used on cygwin: DLL creation program.
-DLLTOOL="$DLLTOOL"
-
-# Used on cygwin: object dumper.
-OBJDUMP="$OBJDUMP"
-
-# Used on cygwin: assembler.
-AS="$AS"
-
-# The name of the directory that contains temporary libtool files.
-objdir=$objdir
-
-# How to create reloadable object files.
-reload_flag=$lt_reload_flag
-reload_cmds=$lt_reload_cmds
-
-# How to pass a linker flag through the compiler.
-wl=$lt_lt_prog_compiler_wl_GCJ
-
-# Object file suffix (normally "o").
-objext="$ac_objext"
-
-# Old archive suffix (normally "a").
-libext="$libext"
-
-# Shared library suffix (normally ".so").
-shrext_cmds='$shrext_cmds'
-
-# Executable file suffix (normally "").
-exeext="$exeext"
-
-# Additional compiler flags for building library objects.
-pic_flag=$lt_lt_prog_compiler_pic_GCJ
-pic_mode=$pic_mode
-
-# What is the maximum length of a command?
-max_cmd_len=$lt_cv_sys_max_cmd_len
-
-# Does compiler simultaneously support -c and -o options?
-compiler_c_o=$lt_lt_cv_prog_compiler_c_o_GCJ
-
-# Must we lock files when doing compilation?
-need_locks=$lt_need_locks
-
-# Do we need the lib prefix for modules?
-need_lib_prefix=$need_lib_prefix
-
-# Do we need a version for libraries?
-need_version=$need_version
-
-# Whether dlopen is supported.
-dlopen_support=$enable_dlopen
-
-# Whether dlopen of programs is supported.
-dlopen_self=$enable_dlopen_self
-
-# Whether dlopen of statically linked programs is supported.
-dlopen_self_static=$enable_dlopen_self_static
-
-# Compiler flag to prevent dynamic linking.
-link_static_flag=$lt_lt_prog_compiler_static_GCJ
-
-# Compiler flag to turn off builtin functions.
-no_builtin_flag=$lt_lt_prog_compiler_no_builtin_flag_GCJ
-
-# Compiler flag to allow reflexive dlopens.
-export_dynamic_flag_spec=$lt_export_dynamic_flag_spec_GCJ
-
-# Compiler flag to generate shared objects directly from archives.
-whole_archive_flag_spec=$lt_whole_archive_flag_spec_GCJ
-
-# Compiler flag to generate thread-safe objects.
-thread_safe_flag_spec=$lt_thread_safe_flag_spec_GCJ
-
-# Library versioning type.
-version_type=$version_type
-
-# Format of library name prefix.
-libname_spec=$lt_libname_spec
-
-# List of archive names. First name is the real one, the rest are links.
-# The last name is the one that the linker finds with -lNAME.
-library_names_spec=$lt_library_names_spec
-
-# The coded name of the library, if different from the real name.
-soname_spec=$lt_soname_spec
-
-# Commands used to build and install an old-style archive.
-RANLIB=$lt_RANLIB
-old_archive_cmds=$lt_old_archive_cmds_GCJ
-old_postinstall_cmds=$lt_old_postinstall_cmds
-old_postuninstall_cmds=$lt_old_postuninstall_cmds
-
-# Create an old-style archive from a shared archive.
-old_archive_from_new_cmds=$lt_old_archive_from_new_cmds_GCJ
-
-# Create a temporary old-style archive to link instead of a shared archive.
-old_archive_from_expsyms_cmds=$lt_old_archive_from_expsyms_cmds_GCJ
-
-# Commands used to build and install a shared archive.
-archive_cmds=$lt_archive_cmds_GCJ
-archive_expsym_cmds=$lt_archive_expsym_cmds_GCJ
-postinstall_cmds=$lt_postinstall_cmds
-postuninstall_cmds=$lt_postuninstall_cmds
-
-# Commands used to build a loadable module (assumed same as above if empty)
-module_cmds=$lt_module_cmds_GCJ
-module_expsym_cmds=$lt_module_expsym_cmds_GCJ
-
-# Commands to strip libraries.
-old_striplib=$lt_old_striplib
-striplib=$lt_striplib
-
-# Dependencies to place before the objects being linked to create a
-# shared library.
-predep_objects=$lt_predep_objects_GCJ
-
-# Dependencies to place after the objects being linked to create a
-# shared library.
-postdep_objects=$lt_postdep_objects_GCJ
-
-# Dependencies to place before the objects being linked to create a
-# shared library.
-predeps=$lt_predeps_GCJ
-
-# Dependencies to place after the objects being linked to create a
-# shared library.
-postdeps=$lt_postdeps_GCJ
-
-# The library search path used internally by the compiler when linking
-# a shared library.
-compiler_lib_search_path=$lt_compiler_lib_search_path_GCJ
-
-# Method to check whether dependent libraries are shared objects.
-deplibs_check_method=$lt_deplibs_check_method
-
-# Command to use when deplibs_check_method == file_magic.
-file_magic_cmd=$lt_file_magic_cmd
-
-# Flag that allows shared libraries with undefined symbols to be built.
-allow_undefined_flag=$lt_allow_undefined_flag_GCJ
-
-# Flag that forces no undefined symbols.
-no_undefined_flag=$lt_no_undefined_flag_GCJ
-
-# Commands used to finish a libtool library installation in a directory.
-finish_cmds=$lt_finish_cmds
-
-# Same as above, but a single script fragment to be evaled but not shown.
-finish_eval=$lt_finish_eval
-
-# Take the output of nm and produce a listing of raw symbols and C names.
-global_symbol_pipe=$lt_lt_cv_sys_global_symbol_pipe
-
-# Transform the output of nm in a proper C declaration
-global_symbol_to_cdecl=$lt_lt_cv_sys_global_symbol_to_cdecl
-
-# Transform the output of nm in a C name address pair
-global_symbol_to_c_name_address=$lt_lt_cv_sys_global_symbol_to_c_name_address
-
-# This is the shared library runtime path variable.
-runpath_var=$runpath_var
-
-# This is the shared library path variable.
-shlibpath_var=$shlibpath_var
-
-# Is shlibpath searched before the hard-coded library search path?
-shlibpath_overrides_runpath=$shlibpath_overrides_runpath
-
-# How to hardcode a shared library path into an executable.
-hardcode_action=$hardcode_action_GCJ
-
-# Whether we should hardcode library paths into libraries.
-hardcode_into_libs=$hardcode_into_libs
-
-# Flag to hardcode \$libdir into a binary during linking.
-# This must work even if \$libdir does not exist.
-hardcode_libdir_flag_spec=$lt_hardcode_libdir_flag_spec_GCJ
-
-# If ld is used when linking, flag to hardcode \$libdir into
-# a binary during linking. This must work even if \$libdir does
-# not exist.
-hardcode_libdir_flag_spec_ld=$lt_hardcode_libdir_flag_spec_ld_GCJ
-
-# Whether we need a single -rpath flag with a separated argument.
-hardcode_libdir_separator=$lt_hardcode_libdir_separator_GCJ
-
-# Set to yes if using DIR/libNAME${shared_ext} during linking hardcodes DIR into the
-# resulting binary.
-hardcode_direct=$hardcode_direct_GCJ
-
-# Set to yes if using the -LDIR flag during linking hardcodes DIR into the
-# resulting binary.
-hardcode_minus_L=$hardcode_minus_L_GCJ
-
-# Set to yes if using SHLIBPATH_VAR=DIR during linking hardcodes DIR into
-# the resulting binary.
-hardcode_shlibpath_var=$hardcode_shlibpath_var_GCJ
-
-# Set to yes if building a shared library automatically hardcodes DIR into the library
-# and all subsequent libraries and executables linked against it.
-hardcode_automatic=$hardcode_automatic_GCJ
-
-# Variables whose values should be saved in libtool wrapper scripts and
-# restored at relink time.
-variables_saved_for_relink="$variables_saved_for_relink"
-
-# Whether libtool must link a program against all its dependency libraries.
-link_all_deplibs=$link_all_deplibs_GCJ
-
-# Compile-time system search path for libraries
-sys_lib_search_path_spec=$lt_sys_lib_search_path_spec
-
-# Run-time system search path for libraries
-sys_lib_dlsearch_path_spec=$lt_sys_lib_dlsearch_path_spec
-
-# Fix the shell variable \$srcfile for the compiler.
-fix_srcfile_path="$fix_srcfile_path_GCJ"
-
-# Set to yes if exported symbols are required.
-always_export_symbols=$always_export_symbols_GCJ
-
-# The commands to list exported symbols.
-export_symbols_cmds=$lt_export_symbols_cmds_GCJ
-
-# The commands to extract the exported symbol list from a shared archive.
-extract_expsyms_cmds=$lt_extract_expsyms_cmds
-
-# Symbols that should not be listed in the preloaded symbols.
-exclude_expsyms=$lt_exclude_expsyms_GCJ
-
-# Symbols that must always be exported.
-include_expsyms=$lt_include_expsyms_GCJ
-
-# ### END LIBTOOL TAG CONFIG: $tagname
-
-__EOF__
-
-
-else
- # If there is no Makefile yet, we rely on a make rule to execute
- # `config.status --recheck' to rerun these tests and create the
- # libtool script then.
- ltmain_in=`echo $ltmain | sed -e 's/\.sh$/.in/'`
- if test -f "$ltmain_in"; then
- test -f Makefile && make "$ltmain"
- fi
-fi
-
-
-ac_ext=c
-ac_cpp='$CPP $CPPFLAGS'
-ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
-ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
-ac_compiler_gnu=$ac_cv_c_compiler_gnu
-
-CC="$lt_save_CC"
-
- else
- tagname=""
- fi
- ;;
-
- RC)
-
-
-
-# Source file extension for RC test sources.
-ac_ext=rc
-
-# Object file extension for compiled RC test sources.
-objext=o
-objext_RC=$objext
-
-# Code to be used in simple compile tests
-lt_simple_compile_test_code='sample MENU { MENUITEM "&Soup", 100, CHECKED }\n'
-
-# Code to be used in simple link tests
-lt_simple_link_test_code="$lt_simple_compile_test_code"
-
-# ltmain only uses $CC for tagged configurations so make sure $CC is set.
-
-# If no C compiler was specified, use CC.
-LTCC=${LTCC-"$CC"}
-
-# If no C compiler flags were specified, use CFLAGS.
-LTCFLAGS=${LTCFLAGS-"$CFLAGS"}
-
-# Allow CC to be a program name with arguments.
-compiler=$CC
-
-
-# save warnings/boilerplate of simple test code
-ac_outfile=conftest.$ac_objext
-printf "$lt_simple_compile_test_code" >conftest.$ac_ext
-eval "$ac_compile" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err
-_lt_compiler_boilerplate=`cat conftest.err`
-$rm conftest*
-
-ac_outfile=conftest.$ac_objext
-printf "$lt_simple_link_test_code" >conftest.$ac_ext
-eval "$ac_link" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err
-_lt_linker_boilerplate=`cat conftest.err`
-$rm conftest*
-
-
-# Allow CC to be a program name with arguments.
-lt_save_CC="$CC"
-CC=${RC-"windres"}
-compiler=$CC
-compiler_RC=$CC
-for cc_temp in $compiler""; do
- case $cc_temp in
- compile | *[\\/]compile | ccache | *[\\/]ccache ) ;;
- distcc | *[\\/]distcc | purify | *[\\/]purify ) ;;
- \-*) ;;
- *) break;;
- esac
-done
-cc_basename=`$echo "X$cc_temp" | $Xsed -e 's%.*/%%' -e "s%^$host_alias-%%"`
-
-lt_cv_prog_compiler_c_o_RC=yes
-
-# The else clause should only fire when bootstrapping the
-# libtool distribution, otherwise you forgot to ship ltmain.sh
-# with your package, and you will get complaints that there are
-# no rules to generate ltmain.sh.
-if test -f "$ltmain"; then
- # See if we are running on zsh, and set the options which allow our commands through
- # without removal of \ escapes.
- if test -n "${ZSH_VERSION+set}" ; then
- setopt NO_GLOB_SUBST
- fi
- # Now quote all the things that may contain metacharacters while being
- # careful not to overquote the AC_SUBSTed values. We take copies of the
- # variables and quote the copies for generation of the libtool script.
- for var in echo old_CC old_CFLAGS AR AR_FLAGS EGREP RANLIB LN_S LTCC LTCFLAGS NM \
- SED SHELL STRIP \
- libname_spec library_names_spec soname_spec extract_expsyms_cmds \
- old_striplib striplib file_magic_cmd finish_cmds finish_eval \
- deplibs_check_method reload_flag reload_cmds need_locks \
- lt_cv_sys_global_symbol_pipe lt_cv_sys_global_symbol_to_cdecl \
- lt_cv_sys_global_symbol_to_c_name_address \
- sys_lib_search_path_spec sys_lib_dlsearch_path_spec \
- old_postinstall_cmds old_postuninstall_cmds \
- compiler_RC \
- CC_RC \
- LD_RC \
- lt_prog_compiler_wl_RC \
- lt_prog_compiler_pic_RC \
- lt_prog_compiler_static_RC \
- lt_prog_compiler_no_builtin_flag_RC \
- export_dynamic_flag_spec_RC \
- thread_safe_flag_spec_RC \
- whole_archive_flag_spec_RC \
- enable_shared_with_static_runtimes_RC \
- old_archive_cmds_RC \
- old_archive_from_new_cmds_RC \
- predep_objects_RC \
- postdep_objects_RC \
- predeps_RC \
- postdeps_RC \
- compiler_lib_search_path_RC \
- archive_cmds_RC \
- archive_expsym_cmds_RC \
- postinstall_cmds_RC \
- postuninstall_cmds_RC \
- old_archive_from_expsyms_cmds_RC \
- allow_undefined_flag_RC \
- no_undefined_flag_RC \
- export_symbols_cmds_RC \
- hardcode_libdir_flag_spec_RC \
- hardcode_libdir_flag_spec_ld_RC \
- hardcode_libdir_separator_RC \
- hardcode_automatic_RC \
- module_cmds_RC \
- module_expsym_cmds_RC \
- lt_cv_prog_compiler_c_o_RC \
- exclude_expsyms_RC \
- include_expsyms_RC; do
-
- case $var in
- old_archive_cmds_RC | \
- old_archive_from_new_cmds_RC | \
- archive_cmds_RC | \
- archive_expsym_cmds_RC | \
- module_cmds_RC | \
- module_expsym_cmds_RC | \
- old_archive_from_expsyms_cmds_RC | \
- export_symbols_cmds_RC | \
- extract_expsyms_cmds | reload_cmds | finish_cmds | \
- postinstall_cmds | postuninstall_cmds | \
- old_postinstall_cmds | old_postuninstall_cmds | \
- sys_lib_search_path_spec | sys_lib_dlsearch_path_spec)
- # Double-quote double-evaled strings.
- eval "lt_$var=\\\"\`\$echo \"X\$$var\" | \$Xsed -e \"\$double_quote_subst\" -e \"\$sed_quote_subst\" -e \"\$delay_variable_subst\"\`\\\""
- ;;
- *)
- eval "lt_$var=\\\"\`\$echo \"X\$$var\" | \$Xsed -e \"\$sed_quote_subst\"\`\\\""
- ;;
- esac
- done
-
- case $lt_echo in
- *'\$0 --fallback-echo"')
- lt_echo=`$echo "X$lt_echo" | $Xsed -e 's/\\\\\\\$0 --fallback-echo"$/$0 --fallback-echo"/'`
- ;;
- esac
-
-cfgfile="$ofile"
-
- cat <<__EOF__ >> "$cfgfile"
-# ### BEGIN LIBTOOL TAG CONFIG: $tagname
-
-# Libtool was configured on host `(hostname || uname -n) 2>/dev/null | sed 1q`:
-
-# Shell to use when invoking shell scripts.
-SHELL=$lt_SHELL
-
-# Whether or not to build shared libraries.
-build_libtool_libs=$enable_shared
-
-# Whether or not to build static libraries.
-build_old_libs=$enable_static
-
-# Whether or not to add -lc for building shared libraries.
-build_libtool_need_lc=$archive_cmds_need_lc_RC
-
-# Whether or not to disallow shared libs when runtime libs are static
-allow_libtool_libs_with_static_runtimes=$enable_shared_with_static_runtimes_RC
-
-# Whether or not to optimize for fast installation.
-fast_install=$enable_fast_install
-
-# The host system.
-host_alias=$host_alias
-host=$host
-host_os=$host_os
-
-# The build system.
-build_alias=$build_alias
-build=$build
-build_os=$build_os
-
-# An echo program that does not interpret backslashes.
-echo=$lt_echo
-
-# The archiver.
-AR=$lt_AR
-AR_FLAGS=$lt_AR_FLAGS
-
-# A C compiler.
-LTCC=$lt_LTCC
-
-# LTCC compiler flags.
-LTCFLAGS=$lt_LTCFLAGS
-
-# A language-specific compiler.
-CC=$lt_compiler_RC
-
-# Is the compiler the GNU C compiler?
-with_gcc=$GCC_RC
-
-# An ERE matcher.
-EGREP=$lt_EGREP
-
-# The linker used to build libraries.
-LD=$lt_LD_RC
-
-# Whether we need hard or soft links.
-LN_S=$lt_LN_S
-
-# A BSD-compatible nm program.
-NM=$lt_NM
-
-# A symbol stripping program
-STRIP=$lt_STRIP
-
-# Used to examine libraries when file_magic_cmd begins "file"
-MAGIC_CMD=$MAGIC_CMD
-
-# Used on cygwin: DLL creation program.
-DLLTOOL="$DLLTOOL"
-
-# Used on cygwin: object dumper.
-OBJDUMP="$OBJDUMP"
-
-# Used on cygwin: assembler.
-AS="$AS"
-
-# The name of the directory that contains temporary libtool files.
-objdir=$objdir
-
-# How to create reloadable object files.
-reload_flag=$lt_reload_flag
-reload_cmds=$lt_reload_cmds
-
-# How to pass a linker flag through the compiler.
-wl=$lt_lt_prog_compiler_wl_RC
-
-# Object file suffix (normally "o").
-objext="$ac_objext"
-
-# Old archive suffix (normally "a").
-libext="$libext"
-
-# Shared library suffix (normally ".so").
-shrext_cmds='$shrext_cmds'
-
-# Executable file suffix (normally "").
-exeext="$exeext"
-
-# Additional compiler flags for building library objects.
-pic_flag=$lt_lt_prog_compiler_pic_RC
-pic_mode=$pic_mode
-
-# What is the maximum length of a command?
-max_cmd_len=$lt_cv_sys_max_cmd_len
-
-# Does compiler simultaneously support -c and -o options?
-compiler_c_o=$lt_lt_cv_prog_compiler_c_o_RC
-
-# Must we lock files when doing compilation?
-need_locks=$lt_need_locks
-
-# Do we need the lib prefix for modules?
-need_lib_prefix=$need_lib_prefix
-
-# Do we need a version for libraries?
-need_version=$need_version
-
-# Whether dlopen is supported.
-dlopen_support=$enable_dlopen
-
-# Whether dlopen of programs is supported.
-dlopen_self=$enable_dlopen_self
-
-# Whether dlopen of statically linked programs is supported.
-dlopen_self_static=$enable_dlopen_self_static
-
-# Compiler flag to prevent dynamic linking.
-link_static_flag=$lt_lt_prog_compiler_static_RC
-
-# Compiler flag to turn off builtin functions.
-no_builtin_flag=$lt_lt_prog_compiler_no_builtin_flag_RC
-
-# Compiler flag to allow reflexive dlopens.
-export_dynamic_flag_spec=$lt_export_dynamic_flag_spec_RC
-
-# Compiler flag to generate shared objects directly from archives.
-whole_archive_flag_spec=$lt_whole_archive_flag_spec_RC
-
-# Compiler flag to generate thread-safe objects.
-thread_safe_flag_spec=$lt_thread_safe_flag_spec_RC
-
-# Library versioning type.
-version_type=$version_type
-
-# Format of library name prefix.
-libname_spec=$lt_libname_spec
-
-# List of archive names. First name is the real one, the rest are links.
-# The last name is the one that the linker finds with -lNAME.
-library_names_spec=$lt_library_names_spec
-
-# The coded name of the library, if different from the real name.
-soname_spec=$lt_soname_spec
-
-# Commands used to build and install an old-style archive.
-RANLIB=$lt_RANLIB
-old_archive_cmds=$lt_old_archive_cmds_RC
-old_postinstall_cmds=$lt_old_postinstall_cmds
-old_postuninstall_cmds=$lt_old_postuninstall_cmds
-
-# Create an old-style archive from a shared archive.
-old_archive_from_new_cmds=$lt_old_archive_from_new_cmds_RC
-
-# Create a temporary old-style archive to link instead of a shared archive.
-old_archive_from_expsyms_cmds=$lt_old_archive_from_expsyms_cmds_RC
-
-# Commands used to build and install a shared archive.
-archive_cmds=$lt_archive_cmds_RC
-archive_expsym_cmds=$lt_archive_expsym_cmds_RC
-postinstall_cmds=$lt_postinstall_cmds
-postuninstall_cmds=$lt_postuninstall_cmds
-
-# Commands used to build a loadable module (assumed same as above if empty)
-module_cmds=$lt_module_cmds_RC
-module_expsym_cmds=$lt_module_expsym_cmds_RC
-
-# Commands to strip libraries.
-old_striplib=$lt_old_striplib
-striplib=$lt_striplib
-
-# Dependencies to place before the objects being linked to create a
-# shared library.
-predep_objects=$lt_predep_objects_RC
-
-# Dependencies to place after the objects being linked to create a
-# shared library.
-postdep_objects=$lt_postdep_objects_RC
-
-# Dependencies to place before the objects being linked to create a
-# shared library.
-predeps=$lt_predeps_RC
-
-# Dependencies to place after the objects being linked to create a
-# shared library.
-postdeps=$lt_postdeps_RC
-
-# The library search path used internally by the compiler when linking
-# a shared library.
-compiler_lib_search_path=$lt_compiler_lib_search_path_RC
-
-# Method to check whether dependent libraries are shared objects.
-deplibs_check_method=$lt_deplibs_check_method
-
-# Command to use when deplibs_check_method == file_magic.
-file_magic_cmd=$lt_file_magic_cmd
-
-# Flag that allows shared libraries with undefined symbols to be built.
-allow_undefined_flag=$lt_allow_undefined_flag_RC
-
-# Flag that forces no undefined symbols.
-no_undefined_flag=$lt_no_undefined_flag_RC
-
-# Commands used to finish a libtool library installation in a directory.
-finish_cmds=$lt_finish_cmds
-
-# Same as above, but a single script fragment to be evaled but not shown.
-finish_eval=$lt_finish_eval
-
-# Take the output of nm and produce a listing of raw symbols and C names.
-global_symbol_pipe=$lt_lt_cv_sys_global_symbol_pipe
-
-# Transform the output of nm in a proper C declaration
-global_symbol_to_cdecl=$lt_lt_cv_sys_global_symbol_to_cdecl
-
-# Transform the output of nm in a C name address pair
-global_symbol_to_c_name_address=$lt_lt_cv_sys_global_symbol_to_c_name_address
-
-# This is the shared library runtime path variable.
-runpath_var=$runpath_var
-
-# This is the shared library path variable.
-shlibpath_var=$shlibpath_var
-
-# Is shlibpath searched before the hard-coded library search path?
-shlibpath_overrides_runpath=$shlibpath_overrides_runpath
-
-# How to hardcode a shared library path into an executable.
-hardcode_action=$hardcode_action_RC
-
-# Whether we should hardcode library paths into libraries.
-hardcode_into_libs=$hardcode_into_libs
-
-# Flag to hardcode \$libdir into a binary during linking.
-# This must work even if \$libdir does not exist.
-hardcode_libdir_flag_spec=$lt_hardcode_libdir_flag_spec_RC
-
-# If ld is used when linking, flag to hardcode \$libdir into
-# a binary during linking. This must work even if \$libdir does
-# not exist.
-hardcode_libdir_flag_spec_ld=$lt_hardcode_libdir_flag_spec_ld_RC
-
-# Whether we need a single -rpath flag with a separated argument.
-hardcode_libdir_separator=$lt_hardcode_libdir_separator_RC
-
-# Set to yes if using DIR/libNAME${shared_ext} during linking hardcodes DIR into the
-# resulting binary.
-hardcode_direct=$hardcode_direct_RC
-
-# Set to yes if using the -LDIR flag during linking hardcodes DIR into the
-# resulting binary.
-hardcode_minus_L=$hardcode_minus_L_RC
-
-# Set to yes if using SHLIBPATH_VAR=DIR during linking hardcodes DIR into
-# the resulting binary.
-hardcode_shlibpath_var=$hardcode_shlibpath_var_RC
-
-# Set to yes if building a shared library automatically hardcodes DIR into the library
-# and all subsequent libraries and executables linked against it.
-hardcode_automatic=$hardcode_automatic_RC
-
-# Variables whose values should be saved in libtool wrapper scripts and
-# restored at relink time.
-variables_saved_for_relink="$variables_saved_for_relink"
-
-# Whether libtool must link a program against all its dependency libraries.
-link_all_deplibs=$link_all_deplibs_RC
-
-# Compile-time system search path for libraries
-sys_lib_search_path_spec=$lt_sys_lib_search_path_spec
-
-# Run-time system search path for libraries
-sys_lib_dlsearch_path_spec=$lt_sys_lib_dlsearch_path_spec
-
-# Fix the shell variable \$srcfile for the compiler.
-fix_srcfile_path="$fix_srcfile_path_RC"
-
-# Set to yes if exported symbols are required.
-always_export_symbols=$always_export_symbols_RC
-
-# The commands to list exported symbols.
-export_symbols_cmds=$lt_export_symbols_cmds_RC
-
-# The commands to extract the exported symbol list from a shared archive.
-extract_expsyms_cmds=$lt_extract_expsyms_cmds
-
-# Symbols that should not be listed in the preloaded symbols.
-exclude_expsyms=$lt_exclude_expsyms_RC
-
-# Symbols that must always be exported.
-include_expsyms=$lt_include_expsyms_RC
-
-# ### END LIBTOOL TAG CONFIG: $tagname
-
-__EOF__
-
-
-else
- # If there is no Makefile yet, we rely on a make rule to execute
- # `config.status --recheck' to rerun these tests and create the
- # libtool script then.
- ltmain_in=`echo $ltmain | sed -e 's/\.sh$/.in/'`
- if test -f "$ltmain_in"; then
- test -f Makefile && make "$ltmain"
- fi
-fi
-
-
-ac_ext=c
-ac_cpp='$CPP $CPPFLAGS'
-ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
-ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
-ac_compiler_gnu=$ac_cv_c_compiler_gnu
-
-CC="$lt_save_CC"
-
- ;;
-
- *)
- { { echo "$as_me:$LINENO: error: Unsupported tag name: $tagname" >&5
-echo "$as_me: error: Unsupported tag name: $tagname" >&2;}
- { (exit 1); exit 1; }; }
- ;;
- esac
-
- # Append the new tag name to the list of available tags.
- if test -n "$tagname" ; then
- available_tags="$available_tags $tagname"
- fi
- fi
- done
- IFS="$lt_save_ifs"
-
- # Now substitute the updated list of available tags.
- if eval "sed -e 's/^available_tags=.*\$/available_tags=\"$available_tags\"/' \"$ofile\" > \"${ofile}T\""; then
- mv "${ofile}T" "$ofile"
- chmod +x "$ofile"
- else
- rm -f "${ofile}T"
- { { echo "$as_me:$LINENO: error: unable to update list of available tagged configurations." >&5
-echo "$as_me: error: unable to update list of available tagged configurations." >&2;}
- { (exit 1); exit 1; }; }
- fi
-fi
-
-
-
-# This can be used to rebuild libtool when needed
-LIBTOOL_DEPS="$ac_aux_dir/ltmain.sh"
-
-# Always use our own libtool.
-LIBTOOL='$(SHELL) $(top_builddir)/libtool'
-
-# Prevent multiple expansion
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-# Check whether --with-valgrind or --without-valgrind was given.
-if test "${with_valgrind+set}" = set; then
- withval="$with_valgrind"
-
-fi;
-
-if test "$with_valgrind" != "" && test "$with_valgrind" != "no"; then
-
-cat >>confdefs.h <<\_ACEOF
-#define INCLUDE_VALGRIND 1
-_ACEOF
-
- if test -d $with_valgrind; then
- CPPFLAGS="$CPPLFAGS -I$with_valgrind/include"
- fi
-fi
-
-# Check whether --enable-libcheck or --disable-libcheck was given.
-if test "${enable_libcheck+set}" = set; then
- enableval="$enable_libcheck"
- if test "$enableval" = "no"; then
- disable_libcheck=yes
- fi
-
-fi;
-
-ac_ext=c
-ac_cpp='$CPP $CPPFLAGS'
-ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
-ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
-ac_compiler_gnu=$ac_cv_c_compiler_gnu
-if test -n "$ac_tool_prefix"; then
- # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args.
-set dummy ${ac_tool_prefix}gcc; ac_word=$2
-echo "$as_me:$LINENO: checking for $ac_word" >&5
-echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
-if test "${ac_cv_prog_CC+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- if test -n "$CC"; then
- ac_cv_prog_CC="$CC" # Let the user override the test.
-else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
- IFS=$as_save_IFS
- test -z "$as_dir" && as_dir=.
- for ac_exec_ext in '' $ac_executable_extensions; do
- if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
- ac_cv_prog_CC="${ac_tool_prefix}gcc"
- echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
- break 2
- fi
-done
-done
-
-fi
-fi
-CC=$ac_cv_prog_CC
-if test -n "$CC"; then
- echo "$as_me:$LINENO: result: $CC" >&5
-echo "${ECHO_T}$CC" >&6
-else
- echo "$as_me:$LINENO: result: no" >&5
-echo "${ECHO_T}no" >&6
-fi
-
-fi
-if test -z "$ac_cv_prog_CC"; then
- ac_ct_CC=$CC
- # Extract the first word of "gcc", so it can be a program name with args.
-set dummy gcc; ac_word=$2
-echo "$as_me:$LINENO: checking for $ac_word" >&5
-echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
-if test "${ac_cv_prog_ac_ct_CC+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- if test -n "$ac_ct_CC"; then
- ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test.
-else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
- IFS=$as_save_IFS
- test -z "$as_dir" && as_dir=.
- for ac_exec_ext in '' $ac_executable_extensions; do
- if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
- ac_cv_prog_ac_ct_CC="gcc"
- echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
- break 2
- fi
-done
-done
-
-fi
-fi
-ac_ct_CC=$ac_cv_prog_ac_ct_CC
-if test -n "$ac_ct_CC"; then
- echo "$as_me:$LINENO: result: $ac_ct_CC" >&5
-echo "${ECHO_T}$ac_ct_CC" >&6
-else
- echo "$as_me:$LINENO: result: no" >&5
-echo "${ECHO_T}no" >&6
-fi
-
- CC=$ac_ct_CC
-else
- CC="$ac_cv_prog_CC"
-fi
-
-if test -z "$CC"; then
- if test -n "$ac_tool_prefix"; then
- # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args.
-set dummy ${ac_tool_prefix}cc; ac_word=$2
-echo "$as_me:$LINENO: checking for $ac_word" >&5
-echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
-if test "${ac_cv_prog_CC+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- if test -n "$CC"; then
- ac_cv_prog_CC="$CC" # Let the user override the test.
-else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
- IFS=$as_save_IFS
- test -z "$as_dir" && as_dir=.
- for ac_exec_ext in '' $ac_executable_extensions; do
- if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
- ac_cv_prog_CC="${ac_tool_prefix}cc"
- echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
- break 2
- fi
-done
-done
-
-fi
-fi
-CC=$ac_cv_prog_CC
-if test -n "$CC"; then
- echo "$as_me:$LINENO: result: $CC" >&5
-echo "${ECHO_T}$CC" >&6
-else
- echo "$as_me:$LINENO: result: no" >&5
-echo "${ECHO_T}no" >&6
-fi
-
-fi
-if test -z "$ac_cv_prog_CC"; then
- ac_ct_CC=$CC
- # Extract the first word of "cc", so it can be a program name with args.
-set dummy cc; ac_word=$2
-echo "$as_me:$LINENO: checking for $ac_word" >&5
-echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
-if test "${ac_cv_prog_ac_ct_CC+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- if test -n "$ac_ct_CC"; then
- ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test.
-else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
- IFS=$as_save_IFS
- test -z "$as_dir" && as_dir=.
- for ac_exec_ext in '' $ac_executable_extensions; do
- if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
- ac_cv_prog_ac_ct_CC="cc"
- echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
- break 2
- fi
-done
-done
-
-fi
-fi
-ac_ct_CC=$ac_cv_prog_ac_ct_CC
-if test -n "$ac_ct_CC"; then
- echo "$as_me:$LINENO: result: $ac_ct_CC" >&5
-echo "${ECHO_T}$ac_ct_CC" >&6
-else
- echo "$as_me:$LINENO: result: no" >&5
-echo "${ECHO_T}no" >&6
-fi
-
- CC=$ac_ct_CC
-else
- CC="$ac_cv_prog_CC"
-fi
-
-fi
-if test -z "$CC"; then
- # Extract the first word of "cc", so it can be a program name with args.
-set dummy cc; ac_word=$2
-echo "$as_me:$LINENO: checking for $ac_word" >&5
-echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
-if test "${ac_cv_prog_CC+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- if test -n "$CC"; then
- ac_cv_prog_CC="$CC" # Let the user override the test.
-else
- ac_prog_rejected=no
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
- IFS=$as_save_IFS
- test -z "$as_dir" && as_dir=.
- for ac_exec_ext in '' $ac_executable_extensions; do
- if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
- if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then
- ac_prog_rejected=yes
- continue
- fi
- ac_cv_prog_CC="cc"
- echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
- break 2
- fi
-done
-done
-
-if test $ac_prog_rejected = yes; then
- # We found a bogon in the path, so make sure we never use it.
- set dummy $ac_cv_prog_CC
- shift
- if test $# != 0; then
- # We chose a different compiler from the bogus one.
- # However, it has the same basename, so the bogon will be chosen
- # first if we set CC to just the basename; use the full file name.
- shift
- ac_cv_prog_CC="$as_dir/$ac_word${1+' '}$@"
- fi
-fi
-fi
-fi
-CC=$ac_cv_prog_CC
-if test -n "$CC"; then
- echo "$as_me:$LINENO: result: $CC" >&5
-echo "${ECHO_T}$CC" >&6
-else
- echo "$as_me:$LINENO: result: no" >&5
-echo "${ECHO_T}no" >&6
-fi
-
-fi
-if test -z "$CC"; then
- if test -n "$ac_tool_prefix"; then
- for ac_prog in cl
- do
- # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args.
-set dummy $ac_tool_prefix$ac_prog; ac_word=$2
-echo "$as_me:$LINENO: checking for $ac_word" >&5
-echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
-if test "${ac_cv_prog_CC+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- if test -n "$CC"; then
- ac_cv_prog_CC="$CC" # Let the user override the test.
-else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
- IFS=$as_save_IFS
- test -z "$as_dir" && as_dir=.
- for ac_exec_ext in '' $ac_executable_extensions; do
- if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
- ac_cv_prog_CC="$ac_tool_prefix$ac_prog"
- echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
- break 2
- fi
-done
-done
-
-fi
-fi
-CC=$ac_cv_prog_CC
-if test -n "$CC"; then
- echo "$as_me:$LINENO: result: $CC" >&5
-echo "${ECHO_T}$CC" >&6
-else
- echo "$as_me:$LINENO: result: no" >&5
-echo "${ECHO_T}no" >&6
-fi
-
- test -n "$CC" && break
- done
-fi
-if test -z "$CC"; then
- ac_ct_CC=$CC
- for ac_prog in cl
-do
- # Extract the first word of "$ac_prog", so it can be a program name with args.
-set dummy $ac_prog; ac_word=$2
-echo "$as_me:$LINENO: checking for $ac_word" >&5
-echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
-if test "${ac_cv_prog_ac_ct_CC+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- if test -n "$ac_ct_CC"; then
- ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test.
-else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
- IFS=$as_save_IFS
- test -z "$as_dir" && as_dir=.
- for ac_exec_ext in '' $ac_executable_extensions; do
- if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
- ac_cv_prog_ac_ct_CC="$ac_prog"
- echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
- break 2
- fi
-done
-done
-
-fi
-fi
-ac_ct_CC=$ac_cv_prog_ac_ct_CC
-if test -n "$ac_ct_CC"; then
- echo "$as_me:$LINENO: result: $ac_ct_CC" >&5
-echo "${ECHO_T}$ac_ct_CC" >&6
-else
- echo "$as_me:$LINENO: result: no" >&5
-echo "${ECHO_T}no" >&6
-fi
-
- test -n "$ac_ct_CC" && break
-done
-
- CC=$ac_ct_CC
-fi
-
-fi
-
-
-test -z "$CC" && { { echo "$as_me:$LINENO: error: no acceptable C compiler found in \$PATH
-See \`config.log' for more details." >&5
-echo "$as_me: error: no acceptable C compiler found in \$PATH
-See \`config.log' for more details." >&2;}
- { (exit 1); exit 1; }; }
-
-# Provide some information about the compiler.
-echo "$as_me:$LINENO:" \
- "checking for C compiler version" >&5
-ac_compiler=`set X $ac_compile; echo $2`
-{ (eval echo "$as_me:$LINENO: \"$ac_compiler --version </dev/null >&5\"") >&5
- (eval $ac_compiler --version </dev/null >&5) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }
-{ (eval echo "$as_me:$LINENO: \"$ac_compiler -v </dev/null >&5\"") >&5
- (eval $ac_compiler -v </dev/null >&5) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }
-{ (eval echo "$as_me:$LINENO: \"$ac_compiler -V </dev/null >&5\"") >&5
- (eval $ac_compiler -V </dev/null >&5) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }
-
-echo "$as_me:$LINENO: checking whether we are using the GNU C compiler" >&5
-echo $ECHO_N "checking whether we are using the GNU C compiler... $ECHO_C" >&6
-if test "${ac_cv_c_compiler_gnu+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-
-int
-main ()
-{
-#ifndef __GNUC__
- choke me
-#endif
-
- ;
- return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
- (eval $ac_compile) 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } &&
- { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; } &&
- { ac_try='test -s conftest.$ac_objext'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
- ac_compiler_gnu=yes
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-ac_compiler_gnu=no
-fi
-rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
-ac_cv_c_compiler_gnu=$ac_compiler_gnu
-
-fi
-echo "$as_me:$LINENO: result: $ac_cv_c_compiler_gnu" >&5
-echo "${ECHO_T}$ac_cv_c_compiler_gnu" >&6
-GCC=`test $ac_compiler_gnu = yes && echo yes`
-ac_test_CFLAGS=${CFLAGS+set}
-ac_save_CFLAGS=$CFLAGS
-CFLAGS="-g"
-echo "$as_me:$LINENO: checking whether $CC accepts -g" >&5
-echo $ECHO_N "checking whether $CC accepts -g... $ECHO_C" >&6
-if test "${ac_cv_prog_cc_g+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-
-int
-main ()
-{
-
- ;
- return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
- (eval $ac_compile) 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } &&
- { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; } &&
- { ac_try='test -s conftest.$ac_objext'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
- ac_cv_prog_cc_g=yes
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-ac_cv_prog_cc_g=no
-fi
-rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
-fi
-echo "$as_me:$LINENO: result: $ac_cv_prog_cc_g" >&5
-echo "${ECHO_T}$ac_cv_prog_cc_g" >&6
-if test "$ac_test_CFLAGS" = set; then
- CFLAGS=$ac_save_CFLAGS
-elif test $ac_cv_prog_cc_g = yes; then
- if test "$GCC" = yes; then
- CFLAGS="-g -O2"
- else
- CFLAGS="-g"
- fi
-else
- if test "$GCC" = yes; then
- CFLAGS="-O2"
- else
- CFLAGS=
- fi
-fi
-echo "$as_me:$LINENO: checking for $CC option to accept ANSI C" >&5
-echo $ECHO_N "checking for $CC option to accept ANSI C... $ECHO_C" >&6
-if test "${ac_cv_prog_cc_stdc+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- ac_cv_prog_cc_stdc=no
-ac_save_CC=$CC
-cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-#include <stdarg.h>
-#include <stdio.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-/* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */
-struct buf { int x; };
-FILE * (*rcsopen) (struct buf *, struct stat *, int);
-static char *e (p, i)
- char **p;
- int i;
-{
- return p[i];
-}
-static char *f (char * (*g) (char **, int), char **p, ...)
-{
- char *s;
- va_list v;
- va_start (v,p);
- s = g (p, va_arg (v,int));
- va_end (v);
- return s;
-}
-
-/* OSF 4.0 Compaq cc is some sort of almost-ANSI by default. It has
- function prototypes and stuff, but not '\xHH' hex character constants.
- These don't provoke an error unfortunately, instead are silently treated
- as 'x'. The following induces an error, until -std1 is added to get
- proper ANSI mode. Curiously '\x00'!='x' always comes out true, for an
- array size at least. It's necessary to write '\x00'==0 to get something
- that's true only with -std1. */
-int osf4_cc_array ['\x00' == 0 ? 1 : -1];
-
-int test (int i, double x);
-struct s1 {int (*f) (int a);};
-struct s2 {int (*f) (double a);};
-int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int);
-int argc;
-char **argv;
-int
-main ()
-{
-return f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1];
- ;
- return 0;
-}
-_ACEOF
-# Don't try gcc -ansi; that turns off useful extensions and
-# breaks some systems' header files.
-# AIX -qlanglvl=ansi
-# Ultrix and OSF/1 -std1
-# HP-UX 10.20 and later -Ae
-# HP-UX older versions -Aa -D_HPUX_SOURCE
-# SVR4 -Xc -D__EXTENSIONS__
-for ac_arg in "" -qlanglvl=ansi -std1 -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__"
-do
- CC="$ac_save_CC $ac_arg"
- rm -f conftest.$ac_objext
-if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
- (eval $ac_compile) 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } &&
- { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; } &&
- { ac_try='test -s conftest.$ac_objext'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
- ac_cv_prog_cc_stdc=$ac_arg
-break
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-fi
-rm -f conftest.err conftest.$ac_objext
-done
-rm -f conftest.$ac_ext conftest.$ac_objext
-CC=$ac_save_CC
-
-fi
-
-case "x$ac_cv_prog_cc_stdc" in
- x|xno)
- echo "$as_me:$LINENO: result: none needed" >&5
-echo "${ECHO_T}none needed" >&6 ;;
- *)
- echo "$as_me:$LINENO: result: $ac_cv_prog_cc_stdc" >&5
-echo "${ECHO_T}$ac_cv_prog_cc_stdc" >&6
- CC="$CC $ac_cv_prog_cc_stdc" ;;
-esac
-
-# Some people use a C++ compiler to compile C. Since we use `exit',
-# in C++ we need to declare it. In case someone uses the same compiler
-# for both compiling C and C++ we need to have the C++ compiler decide
-# the declaration of exit, since it's the most demanding environment.
-cat >conftest.$ac_ext <<_ACEOF
-#ifndef __cplusplus
- choke me
-#endif
-_ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
- (eval $ac_compile) 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } &&
- { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; } &&
- { ac_try='test -s conftest.$ac_objext'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
- for ac_declaration in \
- '' \
- 'extern "C" void std::exit (int) throw (); using std::exit;' \
- 'extern "C" void std::exit (int); using std::exit;' \
- 'extern "C" void exit (int) throw ();' \
- 'extern "C" void exit (int);' \
- 'void exit (int);'
-do
- cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-$ac_declaration
-#include <stdlib.h>
-int
-main ()
-{
-exit (42);
- ;
- return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
- (eval $ac_compile) 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } &&
- { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; } &&
- { ac_try='test -s conftest.$ac_objext'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
- :
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-continue
-fi
-rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
- cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-$ac_declaration
-int
-main ()
-{
-exit (42);
- ;
- return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
- (eval $ac_compile) 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } &&
- { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; } &&
- { ac_try='test -s conftest.$ac_objext'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
- break
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-fi
-rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
-done
-rm -f conftest*
-if test -n "$ac_declaration"; then
- echo '#ifdef __cplusplus' >>confdefs.h
- echo $ac_declaration >>confdefs.h
- echo '#endif' >>confdefs.h
-fi
-
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-fi
-rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
-ac_ext=c
-ac_cpp='$CPP $CPPFLAGS'
-ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
-ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
-ac_compiler_gnu=$ac_cv_c_compiler_gnu
-
-depcc="$CC" am_compiler_list=
-
-echo "$as_me:$LINENO: checking dependency style of $depcc" >&5
-echo $ECHO_N "checking dependency style of $depcc... $ECHO_C" >&6
-if test "${am_cv_CC_dependencies_compiler_type+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then
- # We make a subdir and do the tests there. Otherwise we can end up
- # making bogus files that we don't know about and never remove. For
- # instance it was reported that on HP-UX the gcc test will end up
- # making a dummy file named `D' -- because `-MD' means `put the output
- # in D'.
- mkdir conftest.dir
- # Copy depcomp to subdir because otherwise we won't find it if we're
- # using a relative directory.
- cp "$am_depcomp" conftest.dir
- cd conftest.dir
- # We will build objects and dependencies in a subdirectory because
- # it helps to detect inapplicable dependency modes. For instance
- # both Tru64's cc and ICC support -MD to output dependencies as a
- # side effect of compilation, but ICC will put the dependencies in
- # the current directory while Tru64 will put them in the object
- # directory.
- mkdir sub
-
- am_cv_CC_dependencies_compiler_type=none
- if test "$am_compiler_list" = ""; then
- am_compiler_list=`sed -n 's/^#*\([a-zA-Z0-9]*\))$/\1/p' < ./depcomp`
- fi
- for depmode in $am_compiler_list; do
- # Setup a source with many dependencies, because some compilers
- # like to wrap large dependency lists on column 80 (with \), and
- # we should not choose a depcomp mode which is confused by this.
- #
- # We need to recreate these files for each test, as the compiler may
- # overwrite some of them when testing with obscure command lines.
- # This happens at least with the AIX C compiler.
- : > sub/conftest.c
- for i in 1 2 3 4 5 6; do
- echo '#include "conftst'$i'.h"' >> sub/conftest.c
- # Using `: > sub/conftst$i.h' creates only sub/conftst1.h with
- # Solaris 8's {/usr,}/bin/sh.
- touch sub/conftst$i.h
- done
- echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf
-
- case $depmode in
- nosideeffect)
- # after this tag, mechanisms are not by side-effect, so they'll
- # only be used when explicitly requested
- if test "x$enable_dependency_tracking" = xyes; then
- continue
- else
- break
- fi
- ;;
- none) break ;;
- esac
- # We check with `-c' and `-o' for the sake of the "dashmstdout"
- # mode. It turns out that the SunPro C++ compiler does not properly
- # handle `-M -o', and we need to detect this.
- if depmode=$depmode \
- source=sub/conftest.c object=sub/conftest.${OBJEXT-o} \
- depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \
- $SHELL ./depcomp $depcc -c -o sub/conftest.${OBJEXT-o} sub/conftest.c \
- >/dev/null 2>conftest.err &&
- grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 &&
- grep sub/conftest.${OBJEXT-o} sub/conftest.Po > /dev/null 2>&1 &&
- ${MAKE-make} -s -f confmf > /dev/null 2>&1; then
- # icc doesn't choke on unknown options, it will just issue warnings
- # or remarks (even with -Werror). So we grep stderr for any message
- # that says an option was ignored or not supported.
- # When given -MP, icc 7.0 and 7.1 complain thusly:
- # icc: Command line warning: ignoring option '-M'; no argument required
- # The diagnosis changed in icc 8.0:
- # icc: Command line remark: option '-MP' not supported
- if (grep 'ignoring option' conftest.err ||
- grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else
- am_cv_CC_dependencies_compiler_type=$depmode
- break
- fi
- fi
- done
-
- cd ..
- rm -rf conftest.dir
-else
- am_cv_CC_dependencies_compiler_type=none
-fi
-
-fi
-echo "$as_me:$LINENO: result: $am_cv_CC_dependencies_compiler_type" >&5
-echo "${ECHO_T}$am_cv_CC_dependencies_compiler_type" >&6
-CCDEPMODE=depmode=$am_cv_CC_dependencies_compiler_type
-
-
-
-if
- test "x$enable_dependency_tracking" != xno \
- && test "$am_cv_CC_dependencies_compiler_type" = gcc3; then
- am__fastdepCC_TRUE=
- am__fastdepCC_FALSE='#'
-else
- am__fastdepCC_TRUE='#'
- am__fastdepCC_FALSE=
-fi
-
-
-
-echo "$as_me:$LINENO: checking for an ANSI C-conforming const" >&5
-echo $ECHO_N "checking for an ANSI C-conforming const... $ECHO_C" >&6
-if test "${ac_cv_c_const+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-
-int
-main ()
-{
-/* FIXME: Include the comments suggested by Paul. */
-#ifndef __cplusplus
- /* Ultrix mips cc rejects this. */
- typedef int charset[2];
- const charset x;
- /* SunOS 4.1.1 cc rejects this. */
- char const *const *ccp;
- char **p;
- /* NEC SVR4.0.2 mips cc rejects this. */
- struct point {int x, y;};
- static struct point const zero = {0,0};
- /* AIX XL C 1.02.0.0 rejects this.
- It does not let you subtract one const X* pointer from another in
- an arm of an if-expression whose if-part is not a constant
- expression */
- const char *g = "string";
- ccp = &g + (g ? g-g : 0);
- /* HPUX 7.0 cc rejects these. */
- ++ccp;
- p = (char**) ccp;
- ccp = (char const *const *) p;
- { /* SCO 3.2v4 cc rejects this. */
- char *t;
- char const *s = 0 ? (char *) 0 : (char const *) 0;
-
- *t++ = 0;
- }
- { /* Someone thinks the Sun supposedly-ANSI compiler will reject this. */
- int x[] = {25, 17};
- const int *foo = &x[0];
- ++foo;
- }
- { /* Sun SC1.0 ANSI compiler rejects this -- but not the above. */
- typedef const int *iptr;
- iptr p = 0;
- ++p;
- }
- { /* AIX XL C 1.02.0.0 rejects this saying
- "k.c", line 2.27: 1506-025 (S) Operand must be a modifiable lvalue. */
- struct s { int j; const int *ap[3]; };
- struct s *b; b->j = 5;
- }
- { /* ULTRIX-32 V3.1 (Rev 9) vcc rejects this */
- const int foo = 10;
- }
-#endif
-
- ;
- return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
- (eval $ac_compile) 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } &&
- { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; } &&
- { ac_try='test -s conftest.$ac_objext'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
- ac_cv_c_const=yes
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-ac_cv_c_const=no
-fi
-rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
-fi
-echo "$as_me:$LINENO: result: $ac_cv_c_const" >&5
-echo "${ECHO_T}$ac_cv_c_const" >&6
-if test $ac_cv_c_const = no; then
-
-cat >>confdefs.h <<\_ACEOF
-#define const
-_ACEOF
-
-fi
-
-echo "$as_me:$LINENO: checking for long" >&5
-echo $ECHO_N "checking for long... $ECHO_C" >&6
-if test "${ac_cv_type_long+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-$ac_includes_default
-int
-main ()
-{
-if ((long *) 0)
- return 0;
-if (sizeof (long))
- return 0;
- ;
- return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
- (eval $ac_compile) 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } &&
- { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; } &&
- { ac_try='test -s conftest.$ac_objext'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
- ac_cv_type_long=yes
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-ac_cv_type_long=no
-fi
-rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
-fi
-echo "$as_me:$LINENO: result: $ac_cv_type_long" >&5
-echo "${ECHO_T}$ac_cv_type_long" >&6
-
-echo "$as_me:$LINENO: checking size of long" >&5
-echo $ECHO_N "checking size of long... $ECHO_C" >&6
-if test "${ac_cv_sizeof_long+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- if test "$ac_cv_type_long" = yes; then
- # The cast to unsigned long works around a bug in the HP C Compiler
- # version HP92453-01 B.11.11.23709.GP, which incorrectly rejects
- # declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'.
- # This bug is HP SR number 8606223364.
- if test "$cross_compiling" = yes; then
- # Depending upon the size, compute the lo and hi bounds.
-cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-$ac_includes_default
-int
-main ()
-{
-static int test_array [1 - 2 * !(((long) (sizeof (long))) >= 0)];
-test_array [0] = 0
-
- ;
- return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
- (eval $ac_compile) 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } &&
- { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; } &&
- { ac_try='test -s conftest.$ac_objext'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
- ac_lo=0 ac_mid=0
- while :; do
- cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-$ac_includes_default
-int
-main ()
-{
-static int test_array [1 - 2 * !(((long) (sizeof (long))) <= $ac_mid)];
-test_array [0] = 0
-
- ;
- return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
- (eval $ac_compile) 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } &&
- { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; } &&
- { ac_try='test -s conftest.$ac_objext'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
- ac_hi=$ac_mid; break
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-ac_lo=`expr $ac_mid + 1`
- if test $ac_lo -le $ac_mid; then
- ac_lo= ac_hi=
- break
- fi
- ac_mid=`expr 2 '*' $ac_mid + 1`
-fi
-rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
- done
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-$ac_includes_default
-int
-main ()
-{
-static int test_array [1 - 2 * !(((long) (sizeof (long))) < 0)];
-test_array [0] = 0
-
- ;
- return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
- (eval $ac_compile) 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } &&
- { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; } &&
- { ac_try='test -s conftest.$ac_objext'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
- ac_hi=-1 ac_mid=-1
- while :; do
- cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-$ac_includes_default
-int
-main ()
-{
-static int test_array [1 - 2 * !(((long) (sizeof (long))) >= $ac_mid)];
-test_array [0] = 0
-
- ;
- return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
- (eval $ac_compile) 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } &&
- { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; } &&
- { ac_try='test -s conftest.$ac_objext'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
- ac_lo=$ac_mid; break
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-ac_hi=`expr '(' $ac_mid ')' - 1`
- if test $ac_mid -le $ac_hi; then
- ac_lo= ac_hi=
- break
- fi
- ac_mid=`expr 2 '*' $ac_mid`
-fi
-rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
- done
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-ac_lo= ac_hi=
-fi
-rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
-fi
-rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
-# Binary search between lo and hi bounds.
-while test "x$ac_lo" != "x$ac_hi"; do
- ac_mid=`expr '(' $ac_hi - $ac_lo ')' / 2 + $ac_lo`
- cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-$ac_includes_default
-int
-main ()
-{
-static int test_array [1 - 2 * !(((long) (sizeof (long))) <= $ac_mid)];
-test_array [0] = 0
-
- ;
- return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
- (eval $ac_compile) 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } &&
- { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; } &&
- { ac_try='test -s conftest.$ac_objext'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
- ac_hi=$ac_mid
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-ac_lo=`expr '(' $ac_mid ')' + 1`
-fi
-rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
-done
-case $ac_lo in
-?*) ac_cv_sizeof_long=$ac_lo;;
-'') { { echo "$as_me:$LINENO: error: cannot compute sizeof (long), 77
-See \`config.log' for more details." >&5
-echo "$as_me: error: cannot compute sizeof (long), 77
-See \`config.log' for more details." >&2;}
- { (exit 1); exit 1; }; } ;;
-esac
-else
- if test "$cross_compiling" = yes; then
- { { echo "$as_me:$LINENO: error: internal error: not reached in cross-compile" >&5
-echo "$as_me: error: internal error: not reached in cross-compile" >&2;}
- { (exit 1); exit 1; }; }
-else
- cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-$ac_includes_default
-long longval () { return (long) (sizeof (long)); }
-unsigned long ulongval () { return (long) (sizeof (long)); }
-#include <stdio.h>
-#include <stdlib.h>
-int
-main ()
-{
-
- FILE *f = fopen ("conftest.val", "w");
- if (! f)
- exit (1);
- if (((long) (sizeof (long))) < 0)
- {
- long i = longval ();
- if (i != ((long) (sizeof (long))))
- exit (1);
- fprintf (f, "%ld\n", i);
- }
- else
- {
- unsigned long i = ulongval ();
- if (i != ((long) (sizeof (long))))
- exit (1);
- fprintf (f, "%lu\n", i);
- }
- exit (ferror (f) || fclose (f) != 0);
-
- ;
- return 0;
-}
-_ACEOF
-rm -f conftest$ac_exeext
-if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
- (eval $ac_link) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
- ac_cv_sizeof_long=`cat conftest.val`
-else
- echo "$as_me: program exited with status $ac_status" >&5
-echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-( exit $ac_status )
-{ { echo "$as_me:$LINENO: error: cannot compute sizeof (long), 77
-See \`config.log' for more details." >&5
-echo "$as_me: error: cannot compute sizeof (long), 77
-See \`config.log' for more details." >&2;}
- { (exit 1); exit 1; }; }
-fi
-rm -f core *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
-fi
-fi
-rm -f conftest.val
-else
- ac_cv_sizeof_long=0
-fi
-fi
-echo "$as_me:$LINENO: result: $ac_cv_sizeof_long" >&5
-echo "${ECHO_T}$ac_cv_sizeof_long" >&6
-cat >>confdefs.h <<_ACEOF
-#define SIZEOF_LONG $ac_cv_sizeof_long
-_ACEOF
-
-
-
-if test "$disable_libcheck" != "yes"; then
-
-echo "$as_me:$LINENO: checking for ibv_get_device_list in -libverbs" >&5
-echo $ECHO_N "checking for ibv_get_device_list in -libverbs... $ECHO_C" >&6
-if test "${ac_cv_lib_ibverbs_ibv_get_device_list+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- ac_check_lib_save_LIBS=$LIBS
-LIBS="-libverbs $LIBS"
-cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-
-/* Override any gcc2 internal prototype to avoid an error. */
-#ifdef __cplusplus
-extern "C"
-#endif
-/* We use char because int might match the return type of a gcc2
- builtin and then its argument prototype would still apply. */
-char ibv_get_device_list ();
-int
-main ()
-{
-ibv_get_device_list ();
- ;
- return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
- (eval $ac_link) 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } &&
- { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; } &&
- { ac_try='test -s conftest$ac_exeext'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
- ac_cv_lib_ibverbs_ibv_get_device_list=yes
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-ac_cv_lib_ibverbs_ibv_get_device_list=no
-fi
-rm -f conftest.err conftest.$ac_objext \
- conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
-fi
-echo "$as_me:$LINENO: result: $ac_cv_lib_ibverbs_ibv_get_device_list" >&5
-echo "${ECHO_T}$ac_cv_lib_ibverbs_ibv_get_device_list" >&6
-if test $ac_cv_lib_ibverbs_ibv_get_device_list = yes; then
- cat >>confdefs.h <<_ACEOF
-#define HAVE_LIBIBVERBS 1
-_ACEOF
-
- LIBS="-libverbs $LIBS"
-
-else
- { { echo "$as_me:$LINENO: error: ibv_get_device_list() not found. libibcm requires libibverbs." >&5
-echo "$as_me: error: ibv_get_device_list() not found. libibcm requires libibverbs." >&2;}
- { (exit 1); exit 1; }; }
-fi
-
-#Need librdmacm for cmpost test program.
-#AC_CHECK_LIB(rdmacm, rdma_create_id, [],
-# AC_MSG_ERROR([rdma_create_id() not found. ucmpost requires librdmacm.]))
-fi
-
-echo "$as_me:$LINENO: checking for ANSI C header files" >&5
-echo $ECHO_N "checking for ANSI C header files... $ECHO_C" >&6
-if test "${ac_cv_header_stdc+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-#include <stdlib.h>
-#include <stdarg.h>
-#include <string.h>
-#include <float.h>
-
-int
-main ()
-{
-
- ;
- return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
- (eval $ac_compile) 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } &&
- { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; } &&
- { ac_try='test -s conftest.$ac_objext'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
- ac_cv_header_stdc=yes
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-ac_cv_header_stdc=no
-fi
-rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
-
-if test $ac_cv_header_stdc = yes; then
- # SunOS 4.x string.h does not declare mem*, contrary to ANSI.
- cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-#include <string.h>
-
-_ACEOF
-if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
- $EGREP "memchr" >/dev/null 2>&1; then
- :
-else
- ac_cv_header_stdc=no
-fi
-rm -f conftest*
-
-fi
-
-if test $ac_cv_header_stdc = yes; then
- # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI.
- cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-#include <stdlib.h>
-
-_ACEOF
-if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
- $EGREP "free" >/dev/null 2>&1; then
- :
-else
- ac_cv_header_stdc=no
-fi
-rm -f conftest*
-
-fi
-
-if test $ac_cv_header_stdc = yes; then
- # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi.
- if test "$cross_compiling" = yes; then
- :
-else
- cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-#include <ctype.h>
-#if ((' ' & 0x0FF) == 0x020)
-# define ISLOWER(c) ('a' <= (c) && (c) <= 'z')
-# define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c))
-#else
-# define ISLOWER(c) \
- (('a' <= (c) && (c) <= 'i') \
- || ('j' <= (c) && (c) <= 'r') \
- || ('s' <= (c) && (c) <= 'z'))
-# define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c))
-#endif
-
-#define XOR(e, f) (((e) && !(f)) || (!(e) && (f)))
-int
-main ()
-{
- int i;
- for (i = 0; i < 256; i++)
- if (XOR (islower (i), ISLOWER (i))
- || toupper (i) != TOUPPER (i))
- exit(2);
- exit (0);
-}
-_ACEOF
-rm -f conftest$ac_exeext
-if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
- (eval $ac_link) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
- :
-else
- echo "$as_me: program exited with status $ac_status" >&5
-echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-( exit $ac_status )
-ac_cv_header_stdc=no
-fi
-rm -f core *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
-fi
-fi
-fi
-echo "$as_me:$LINENO: result: $ac_cv_header_stdc" >&5
-echo "${ECHO_T}$ac_cv_header_stdc" >&6
-if test $ac_cv_header_stdc = yes; then
-
-cat >>confdefs.h <<\_ACEOF
-#define STDC_HEADERS 1
-_ACEOF
-
-fi
-
-if test "$disable_libcheck" != "yes"; then
-if test "${ac_cv_header_infiniband_verbs_h+set}" = set; then
- echo "$as_me:$LINENO: checking for infiniband/verbs.h" >&5
-echo $ECHO_N "checking for infiniband/verbs.h... $ECHO_C" >&6
-if test "${ac_cv_header_infiniband_verbs_h+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-fi
-echo "$as_me:$LINENO: result: $ac_cv_header_infiniband_verbs_h" >&5
-echo "${ECHO_T}$ac_cv_header_infiniband_verbs_h" >&6
-else
- # Is the header compilable?
-echo "$as_me:$LINENO: checking infiniband/verbs.h usability" >&5
-echo $ECHO_N "checking infiniband/verbs.h usability... $ECHO_C" >&6
-cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-$ac_includes_default
-#include <infiniband/verbs.h>
-_ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
- (eval $ac_compile) 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } &&
- { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; } &&
- { ac_try='test -s conftest.$ac_objext'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
- ac_header_compiler=yes
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-ac_header_compiler=no
-fi
-rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
-echo "$as_me:$LINENO: result: $ac_header_compiler" >&5
-echo "${ECHO_T}$ac_header_compiler" >&6
-
-# Is the header present?
-echo "$as_me:$LINENO: checking infiniband/verbs.h presence" >&5
-echo $ECHO_N "checking infiniband/verbs.h presence... $ECHO_C" >&6
-cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-#include <infiniband/verbs.h>
-_ACEOF
-if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5
- (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } >/dev/null; then
- if test -s conftest.err; then
- ac_cpp_err=$ac_c_preproc_warn_flag
- ac_cpp_err=$ac_cpp_err$ac_c_werror_flag
- else
- ac_cpp_err=
- fi
-else
- ac_cpp_err=yes
-fi
-if test -z "$ac_cpp_err"; then
- ac_header_preproc=yes
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
- ac_header_preproc=no
-fi
-rm -f conftest.err conftest.$ac_ext
-echo "$as_me:$LINENO: result: $ac_header_preproc" >&5
-echo "${ECHO_T}$ac_header_preproc" >&6
-
-# So? What about this header?
-case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in
- yes:no: )
- { echo "$as_me:$LINENO: WARNING: infiniband/verbs.h: accepted by the compiler, rejected by the preprocessor!" >&5
-echo "$as_me: WARNING: infiniband/verbs.h: accepted by the compiler, rejected by the preprocessor!" >&2;}
- { echo "$as_me:$LINENO: WARNING: infiniband/verbs.h: proceeding with the compiler's result" >&5
-echo "$as_me: WARNING: infiniband/verbs.h: proceeding with the compiler's result" >&2;}
- ac_header_preproc=yes
- ;;
- no:yes:* )
- { echo "$as_me:$LINENO: WARNING: infiniband/verbs.h: present but cannot be compiled" >&5
-echo "$as_me: WARNING: infiniband/verbs.h: present but cannot be compiled" >&2;}
- { echo "$as_me:$LINENO: WARNING: infiniband/verbs.h: check for missing prerequisite headers?" >&5
-echo "$as_me: WARNING: infiniband/verbs.h: check for missing prerequisite headers?" >&2;}
- { echo "$as_me:$LINENO: WARNING: infiniband/verbs.h: see the Autoconf documentation" >&5
-echo "$as_me: WARNING: infiniband/verbs.h: see the Autoconf documentation" >&2;}
- { echo "$as_me:$LINENO: WARNING: infiniband/verbs.h: section \"Present But Cannot Be Compiled\"" >&5
-echo "$as_me: WARNING: infiniband/verbs.h: section \"Present But Cannot Be Compiled\"" >&2;}
- { echo "$as_me:$LINENO: WARNING: infiniband/verbs.h: proceeding with the preprocessor's result" >&5
-echo "$as_me: WARNING: infiniband/verbs.h: proceeding with the preprocessor's result" >&2;}
- { echo "$as_me:$LINENO: WARNING: infiniband/verbs.h: in the future, the compiler will take precedence" >&5
-echo "$as_me: WARNING: infiniband/verbs.h: in the future, the compiler will take precedence" >&2;}
- (
- cat <<\_ASBOX
-## -------------------------------------------- ##
-## Report this to general@lists@openfabrics.org ##
-## -------------------------------------------- ##
-_ASBOX
- ) |
- sed "s/^/$as_me: WARNING: /" >&2
- ;;
-esac
-echo "$as_me:$LINENO: checking for infiniband/verbs.h" >&5
-echo $ECHO_N "checking for infiniband/verbs.h... $ECHO_C" >&6
-if test "${ac_cv_header_infiniband_verbs_h+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- ac_cv_header_infiniband_verbs_h=$ac_header_preproc
-fi
-echo "$as_me:$LINENO: result: $ac_cv_header_infiniband_verbs_h" >&5
-echo "${ECHO_T}$ac_cv_header_infiniband_verbs_h" >&6
-
-fi
-if test $ac_cv_header_infiniband_verbs_h = yes; then
- :
-else
- { { echo "$as_me:$LINENO: error: <infiniband/verbs.h> not found. Is libibverbs installed?" >&5
-echo "$as_me: error: <infiniband/verbs.h> not found. Is libibverbs installed?" >&2;}
- { (exit 1); exit 1; }; }
-fi
-
-
-if test "${ac_cv_header_infiniband_marshall_h+set}" = set; then
- echo "$as_me:$LINENO: checking for infiniband/marshall.h" >&5
-echo $ECHO_N "checking for infiniband/marshall.h... $ECHO_C" >&6
-if test "${ac_cv_header_infiniband_marshall_h+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-fi
-echo "$as_me:$LINENO: result: $ac_cv_header_infiniband_marshall_h" >&5
-echo "${ECHO_T}$ac_cv_header_infiniband_marshall_h" >&6
-else
- # Is the header compilable?
-echo "$as_me:$LINENO: checking infiniband/marshall.h usability" >&5
-echo $ECHO_N "checking infiniband/marshall.h usability... $ECHO_C" >&6
-cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-$ac_includes_default
-#include <infiniband/marshall.h>
-_ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
- (eval $ac_compile) 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } &&
- { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; } &&
- { ac_try='test -s conftest.$ac_objext'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
- ac_header_compiler=yes
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-ac_header_compiler=no
-fi
-rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
-echo "$as_me:$LINENO: result: $ac_header_compiler" >&5
-echo "${ECHO_T}$ac_header_compiler" >&6
-
-# Is the header present?
-echo "$as_me:$LINENO: checking infiniband/marshall.h presence" >&5
-echo $ECHO_N "checking infiniband/marshall.h presence... $ECHO_C" >&6
-cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-#include <infiniband/marshall.h>
-_ACEOF
-if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5
- (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } >/dev/null; then
- if test -s conftest.err; then
- ac_cpp_err=$ac_c_preproc_warn_flag
- ac_cpp_err=$ac_cpp_err$ac_c_werror_flag
- else
- ac_cpp_err=
- fi
-else
- ac_cpp_err=yes
-fi
-if test -z "$ac_cpp_err"; then
- ac_header_preproc=yes
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
- ac_header_preproc=no
-fi
-rm -f conftest.err conftest.$ac_ext
-echo "$as_me:$LINENO: result: $ac_header_preproc" >&5
-echo "${ECHO_T}$ac_header_preproc" >&6
-
-# So? What about this header?
-case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in
- yes:no: )
- { echo "$as_me:$LINENO: WARNING: infiniband/marshall.h: accepted by the compiler, rejected by the preprocessor!" >&5
-echo "$as_me: WARNING: infiniband/marshall.h: accepted by the compiler, rejected by the preprocessor!" >&2;}
- { echo "$as_me:$LINENO: WARNING: infiniband/marshall.h: proceeding with the compiler's result" >&5
-echo "$as_me: WARNING: infiniband/marshall.h: proceeding with the compiler's result" >&2;}
- ac_header_preproc=yes
- ;;
- no:yes:* )
- { echo "$as_me:$LINENO: WARNING: infiniband/marshall.h: present but cannot be compiled" >&5
-echo "$as_me: WARNING: infiniband/marshall.h: present but cannot be compiled" >&2;}
- { echo "$as_me:$LINENO: WARNING: infiniband/marshall.h: check for missing prerequisite headers?" >&5
-echo "$as_me: WARNING: infiniband/marshall.h: check for missing prerequisite headers?" >&2;}
- { echo "$as_me:$LINENO: WARNING: infiniband/marshall.h: see the Autoconf documentation" >&5
-echo "$as_me: WARNING: infiniband/marshall.h: see the Autoconf documentation" >&2;}
- { echo "$as_me:$LINENO: WARNING: infiniband/marshall.h: section \"Present But Cannot Be Compiled\"" >&5
-echo "$as_me: WARNING: infiniband/marshall.h: section \"Present But Cannot Be Compiled\"" >&2;}
- { echo "$as_me:$LINENO: WARNING: infiniband/marshall.h: proceeding with the preprocessor's result" >&5
-echo "$as_me: WARNING: infiniband/marshall.h: proceeding with the preprocessor's result" >&2;}
- { echo "$as_me:$LINENO: WARNING: infiniband/marshall.h: in the future, the compiler will take precedence" >&5
-echo "$as_me: WARNING: infiniband/marshall.h: in the future, the compiler will take precedence" >&2;}
- (
- cat <<\_ASBOX
-## -------------------------------------------- ##
-## Report this to general@lists@openfabrics.org ##
-## -------------------------------------------- ##
-_ASBOX
- ) |
- sed "s/^/$as_me: WARNING: /" >&2
- ;;
-esac
-echo "$as_me:$LINENO: checking for infiniband/marshall.h" >&5
-echo $ECHO_N "checking for infiniband/marshall.h... $ECHO_C" >&6
-if test "${ac_cv_header_infiniband_marshall_h+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- ac_cv_header_infiniband_marshall_h=$ac_header_preproc
-fi
-echo "$as_me:$LINENO: result: $ac_cv_header_infiniband_marshall_h" >&5
-echo "${ECHO_T}$ac_cv_header_infiniband_marshall_h" >&6
-
-fi
-if test $ac_cv_header_infiniband_marshall_h = yes; then
- :
-else
- { { echo "$as_me:$LINENO: error: <infiniband/marshall.h> not found. Is libibverbs installed?" >&5
-echo "$as_me: error: <infiniband/marshall.h> not found. Is libibverbs installed?" >&2;}
- { (exit 1); exit 1; }; }
-fi
-
-
-
-if test "$with_valgrind" != "" && test "$with_valgrind" != "no"; then
-if test "${ac_cv_header_valgrind_memcheck_h+set}" = set; then
- echo "$as_me:$LINENO: checking for valgrind/memcheck.h" >&5
-echo $ECHO_N "checking for valgrind/memcheck.h... $ECHO_C" >&6
-if test "${ac_cv_header_valgrind_memcheck_h+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-fi
-echo "$as_me:$LINENO: result: $ac_cv_header_valgrind_memcheck_h" >&5
-echo "${ECHO_T}$ac_cv_header_valgrind_memcheck_h" >&6
-else
- # Is the header compilable?
-echo "$as_me:$LINENO: checking valgrind/memcheck.h usability" >&5
-echo $ECHO_N "checking valgrind/memcheck.h usability... $ECHO_C" >&6
-cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-$ac_includes_default
-#include <valgrind/memcheck.h>
-_ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
- (eval $ac_compile) 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } &&
- { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; } &&
- { ac_try='test -s conftest.$ac_objext'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
- ac_header_compiler=yes
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-ac_header_compiler=no
-fi
-rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
-echo "$as_me:$LINENO: result: $ac_header_compiler" >&5
-echo "${ECHO_T}$ac_header_compiler" >&6
-
-# Is the header present?
-echo "$as_me:$LINENO: checking valgrind/memcheck.h presence" >&5
-echo $ECHO_N "checking valgrind/memcheck.h presence... $ECHO_C" >&6
-cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-#include <valgrind/memcheck.h>
-_ACEOF
-if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5
- (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } >/dev/null; then
- if test -s conftest.err; then
- ac_cpp_err=$ac_c_preproc_warn_flag
- ac_cpp_err=$ac_cpp_err$ac_c_werror_flag
- else
- ac_cpp_err=
- fi
-else
- ac_cpp_err=yes
-fi
-if test -z "$ac_cpp_err"; then
- ac_header_preproc=yes
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
- ac_header_preproc=no
-fi
-rm -f conftest.err conftest.$ac_ext
-echo "$as_me:$LINENO: result: $ac_header_preproc" >&5
-echo "${ECHO_T}$ac_header_preproc" >&6
-
-# So? What about this header?
-case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in
- yes:no: )
- { echo "$as_me:$LINENO: WARNING: valgrind/memcheck.h: accepted by the compiler, rejected by the preprocessor!" >&5
-echo "$as_me: WARNING: valgrind/memcheck.h: accepted by the compiler, rejected by the preprocessor!" >&2;}
- { echo "$as_me:$LINENO: WARNING: valgrind/memcheck.h: proceeding with the compiler's result" >&5
-echo "$as_me: WARNING: valgrind/memcheck.h: proceeding with the compiler's result" >&2;}
- ac_header_preproc=yes
- ;;
- no:yes:* )
- { echo "$as_me:$LINENO: WARNING: valgrind/memcheck.h: present but cannot be compiled" >&5
-echo "$as_me: WARNING: valgrind/memcheck.h: present but cannot be compiled" >&2;}
- { echo "$as_me:$LINENO: WARNING: valgrind/memcheck.h: check for missing prerequisite headers?" >&5
-echo "$as_me: WARNING: valgrind/memcheck.h: check for missing prerequisite headers?" >&2;}
- { echo "$as_me:$LINENO: WARNING: valgrind/memcheck.h: see the Autoconf documentation" >&5
-echo "$as_me: WARNING: valgrind/memcheck.h: see the Autoconf documentation" >&2;}
- { echo "$as_me:$LINENO: WARNING: valgrind/memcheck.h: section \"Present But Cannot Be Compiled\"" >&5
-echo "$as_me: WARNING: valgrind/memcheck.h: section \"Present But Cannot Be Compiled\"" >&2;}
- { echo "$as_me:$LINENO: WARNING: valgrind/memcheck.h: proceeding with the preprocessor's result" >&5
-echo "$as_me: WARNING: valgrind/memcheck.h: proceeding with the preprocessor's result" >&2;}
- { echo "$as_me:$LINENO: WARNING: valgrind/memcheck.h: in the future, the compiler will take precedence" >&5
-echo "$as_me: WARNING: valgrind/memcheck.h: in the future, the compiler will take precedence" >&2;}
- (
- cat <<\_ASBOX
-## -------------------------------------------- ##
-## Report this to general@lists@openfabrics.org ##
-## -------------------------------------------- ##
-_ASBOX
- ) |
- sed "s/^/$as_me: WARNING: /" >&2
- ;;
-esac
-echo "$as_me:$LINENO: checking for valgrind/memcheck.h" >&5
-echo $ECHO_N "checking for valgrind/memcheck.h... $ECHO_C" >&6
-if test "${ac_cv_header_valgrind_memcheck_h+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- ac_cv_header_valgrind_memcheck_h=$ac_header_preproc
-fi
-echo "$as_me:$LINENO: result: $ac_cv_header_valgrind_memcheck_h" >&5
-echo "${ECHO_T}$ac_cv_header_valgrind_memcheck_h" >&6
-
-fi
-if test $ac_cv_header_valgrind_memcheck_h = yes; then
- :
-else
- { { echo "$as_me:$LINENO: error: valgrind requested but <valgrind/memcheck.h> not found." >&5
-echo "$as_me: error: valgrind requested but <valgrind/memcheck.h> not found." >&2;}
- { (exit 1); exit 1; }; }
-fi
-
-
-fi
-
-fi
-
-echo "$as_me:$LINENO: checking whether ld accepts --version-script" >&5
-echo $ECHO_N "checking whether ld accepts --version-script... $ECHO_C" >&6
-if test "${ac_cv_version_script+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- if test -n "`$LD --help < /dev/null 2>/dev/null | grep version-script`"; then
- ac_cv_version_script=yes
- else
- ac_cv_version_script=no
- fi
-fi
-echo "$as_me:$LINENO: result: $ac_cv_version_script" >&5
-echo "${ECHO_T}$ac_cv_version_script" >&6
-
-
-
-if test "$ac_cv_version_script" = "yes"; then
- HAVE_LD_VERSION_SCRIPT_TRUE=
- HAVE_LD_VERSION_SCRIPT_FALSE='#'
-else
- HAVE_LD_VERSION_SCRIPT_TRUE='#'
- HAVE_LD_VERSION_SCRIPT_FALSE=
-fi
-
-
- ac_config_files="$ac_config_files Makefile libibcm.spec"
-
-cat >confcache <<\_ACEOF
-# This file is a shell script that caches the results of configure
-# tests run on this system so they can be shared between configure
-# scripts and configure runs, see configure's option --config-cache.
-# It is not useful on other systems. If it contains results you don't
-# want to keep, you may remove or edit it.
-#
-# config.status only pays attention to the cache file if you give it
-# the --recheck option to rerun configure.
-#
-# `ac_cv_env_foo' variables (set or unset) will be overridden when
-# loading this file, other *unset* `ac_cv_foo' will be assigned the
-# following values.
-
-_ACEOF
-
-# The following way of writing the cache mishandles newlines in values,
-# but we know of no workaround that is simple, portable, and efficient.
-# So, don't put newlines in cache variables' values.
-# Ultrix sh set writes to stderr and can't be redirected directly,
-# and sets the high bit in the cache file unless we assign to the vars.
-{
- (set) 2>&1 |
- case `(ac_space=' '; set | grep ac_space) 2>&1` in
- *ac_space=\ *)
- # `set' does not quote correctly, so add quotes (double-quote
- # substitution turns \\\\ into \\, and sed turns \\ into \).
- sed -n \
- "s/'/'\\\\''/g;
- s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\\2'/p"
- ;;
- *)
- # `set' quotes correctly as required by POSIX, so do not add quotes.
- sed -n \
- "s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1=\\2/p"
- ;;
- esac;
-} |
- sed '
- t clear
- : clear
- s/^\([^=]*\)=\(.*[{}].*\)$/test "${\1+set}" = set || &/
- t end
- /^ac_cv_env/!s/^\([^=]*\)=\(.*\)$/\1=${\1=\2}/
- : end' >>confcache
-if diff $cache_file confcache >/dev/null 2>&1; then :; else
- if test -w $cache_file; then
- test "x$cache_file" != "x/dev/null" && echo "updating cache $cache_file"
- cat confcache >$cache_file
- else
- echo "not updating unwritable cache $cache_file"
- fi
-fi
-rm -f confcache
-
-test "x$prefix" = xNONE && prefix=$ac_default_prefix
-# Let make expand exec_prefix.
-test "x$exec_prefix" = xNONE && exec_prefix='${prefix}'
-
-# VPATH may cause trouble with some makes, so we remove $(srcdir),
-# ${srcdir} and @srcdir@ from VPATH if srcdir is ".", strip leading and
-# trailing colons and then remove the whole line if VPATH becomes empty
-# (actually we leave an empty line to preserve line numbers).
-if test "x$srcdir" = x.; then
- ac_vpsub='/^[ ]*VPATH[ ]*=/{
-s/:*\$(srcdir):*/:/;
-s/:*\${srcdir}:*/:/;
-s/:*@srcdir@:*/:/;
-s/^\([^=]*=[ ]*\):*/\1/;
-s/:*$//;
-s/^[^=]*=[ ]*$//;
-}'
-fi
-
-DEFS=-DHAVE_CONFIG_H
-
-ac_libobjs=
-ac_ltlibobjs=
-for ac_i in : $LIBOBJS; do test "x$ac_i" = x: && continue
- # 1. Remove the extension, and $U if already installed.
- ac_i=`echo "$ac_i" |
- sed 's/\$U\././;s/\.o$//;s/\.obj$//'`
- # 2. Add them.
- ac_libobjs="$ac_libobjs $ac_i\$U.$ac_objext"
- ac_ltlibobjs="$ac_ltlibobjs $ac_i"'$U.lo'
-done
-LIBOBJS=$ac_libobjs
-
-LTLIBOBJS=$ac_ltlibobjs
-
-
-if test -z "${AMDEP_TRUE}" && test -z "${AMDEP_FALSE}"; then
- { { echo "$as_me:$LINENO: error: conditional \"AMDEP\" was never defined.
-Usually this means the macro was only invoked conditionally." >&5
-echo "$as_me: error: conditional \"AMDEP\" was never defined.
-Usually this means the macro was only invoked conditionally." >&2;}
- { (exit 1); exit 1; }; }
-fi
-if test -z "${am__fastdepCC_TRUE}" && test -z "${am__fastdepCC_FALSE}"; then
- { { echo "$as_me:$LINENO: error: conditional \"am__fastdepCC\" was never defined.
-Usually this means the macro was only invoked conditionally." >&5
-echo "$as_me: error: conditional \"am__fastdepCC\" was never defined.
-Usually this means the macro was only invoked conditionally." >&2;}
- { (exit 1); exit 1; }; }
-fi
-if test -z "${am__fastdepCXX_TRUE}" && test -z "${am__fastdepCXX_FALSE}"; then
- { { echo "$as_me:$LINENO: error: conditional \"am__fastdepCXX\" was never defined.
-Usually this means the macro was only invoked conditionally." >&5
-echo "$as_me: error: conditional \"am__fastdepCXX\" was never defined.
-Usually this means the macro was only invoked conditionally." >&2;}
- { (exit 1); exit 1; }; }
-fi
-if test -z "${am__fastdepCC_TRUE}" && test -z "${am__fastdepCC_FALSE}"; then
- { { echo "$as_me:$LINENO: error: conditional \"am__fastdepCC\" was never defined.
-Usually this means the macro was only invoked conditionally." >&5
-echo "$as_me: error: conditional \"am__fastdepCC\" was never defined.
-Usually this means the macro was only invoked conditionally." >&2;}
- { (exit 1); exit 1; }; }
-fi
-if test -z "${HAVE_LD_VERSION_SCRIPT_TRUE}" && test -z "${HAVE_LD_VERSION_SCRIPT_FALSE}"; then
- { { echo "$as_me:$LINENO: error: conditional \"HAVE_LD_VERSION_SCRIPT\" was never defined.
-Usually this means the macro was only invoked conditionally." >&5
-echo "$as_me: error: conditional \"HAVE_LD_VERSION_SCRIPT\" was never defined.
-Usually this means the macro was only invoked conditionally." >&2;}
- { (exit 1); exit 1; }; }
-fi
-
-: ${CONFIG_STATUS=./config.status}
-ac_clean_files_save=$ac_clean_files
-ac_clean_files="$ac_clean_files $CONFIG_STATUS"
-{ echo "$as_me:$LINENO: creating $CONFIG_STATUS" >&5
-echo "$as_me: creating $CONFIG_STATUS" >&6;}
-cat >$CONFIG_STATUS <<_ACEOF
-#! $SHELL
-# Generated by $as_me.
-# Run this file to recreate the current configuration.
-# Compiler output produced by configure, useful for debugging
-# configure, is in config.log if it exists.
-
-debug=false
-ac_cs_recheck=false
-ac_cs_silent=false
-SHELL=\${CONFIG_SHELL-$SHELL}
-_ACEOF
-
-cat >>$CONFIG_STATUS <<\_ACEOF
-## --------------------- ##
-## M4sh Initialization. ##
-## --------------------- ##
-
-# Be Bourne compatible
-if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then
- emulate sh
- NULLCMD=:
- # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which
- # is contrary to our usage. Disable this feature.
- alias -g '${1+"$@"}'='"$@"'
-elif test -n "${BASH_VERSION+set}" && (set -o posix) >/dev/null 2>&1; then
- set -o posix
-fi
-DUALCASE=1; export DUALCASE # for MKS sh
-
-# Support unset when possible.
-if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then
- as_unset=unset
-else
- as_unset=false
-fi
-
-
-# Work around bugs in pre-3.0 UWIN ksh.
-$as_unset ENV MAIL MAILPATH
-PS1='$ '
-PS2='> '
-PS4='+ '
-
-# NLS nuisances.
-for as_var in \
- LANG LANGUAGE LC_ADDRESS LC_ALL LC_COLLATE LC_CTYPE LC_IDENTIFICATION \
- LC_MEASUREMENT LC_MESSAGES LC_MONETARY LC_NAME LC_NUMERIC LC_PAPER \
- LC_TELEPHONE LC_TIME
-do
- if (set +x; test -z "`(eval $as_var=C; export $as_var) 2>&1`"); then
- eval $as_var=C; export $as_var
- else
- $as_unset $as_var
- fi
-done
-
-# Required to use basename.
-if expr a : '\(a\)' >/dev/null 2>&1; then
- as_expr=expr
-else
- as_expr=false
-fi
-
-if (basename /) >/dev/null 2>&1 && test "X`basename / 2>&1`" = "X/"; then
- as_basename=basename
-else
- as_basename=false
-fi
-
-
-# Name of the executable.
-as_me=`$as_basename "$0" ||
-$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \
- X"$0" : 'X\(//\)$' \| \
- X"$0" : 'X\(/\)$' \| \
- . : '\(.\)' 2>/dev/null ||
-echo X/"$0" |
- sed '/^.*\/\([^/][^/]*\)\/*$/{ s//\1/; q; }
- /^X\/\(\/\/\)$/{ s//\1/; q; }
- /^X\/\(\/\).*/{ s//\1/; q; }
- s/.*/./; q'`
-
-
-# PATH needs CR, and LINENO needs CR and PATH.
-# Avoid depending upon Character Ranges.
-as_cr_letters='abcdefghijklmnopqrstuvwxyz'
-as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ'
-as_cr_Letters=$as_cr_letters$as_cr_LETTERS
-as_cr_digits='0123456789'
-as_cr_alnum=$as_cr_Letters$as_cr_digits
-
-# The user is always right.
-if test "${PATH_SEPARATOR+set}" != set; then
- echo "#! /bin/sh" >conf$$.sh
- echo "exit 0" >>conf$$.sh
- chmod +x conf$$.sh
- if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then
- PATH_SEPARATOR=';'
- else
- PATH_SEPARATOR=:
- fi
- rm -f conf$$.sh
-fi
-
-
- as_lineno_1=$LINENO
- as_lineno_2=$LINENO
- as_lineno_3=`(expr $as_lineno_1 + 1) 2>/dev/null`
- test "x$as_lineno_1" != "x$as_lineno_2" &&
- test "x$as_lineno_3" = "x$as_lineno_2" || {
- # Find who we are. Look in the path if we contain no path at all
- # relative or not.
- case $0 in
- *[\\/]* ) as_myself=$0 ;;
- *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
- IFS=$as_save_IFS
- test -z "$as_dir" && as_dir=.
- test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break
-done
-
- ;;
- esac
- # We did not find ourselves, most probably we were run as `sh COMMAND'
- # in which case we are not to be found in the path.
- if test "x$as_myself" = x; then
- as_myself=$0
- fi
- if test ! -f "$as_myself"; then
- { { echo "$as_me:$LINENO: error: cannot find myself; rerun with an absolute path" >&5
-echo "$as_me: error: cannot find myself; rerun with an absolute path" >&2;}
- { (exit 1); exit 1; }; }
- fi
- case $CONFIG_SHELL in
- '')
- as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH
-do
- IFS=$as_save_IFS
- test -z "$as_dir" && as_dir=.
- for as_base in sh bash ksh sh5; do
- case $as_dir in
- /*)
- if ("$as_dir/$as_base" -c '
- as_lineno_1=$LINENO
- as_lineno_2=$LINENO
- as_lineno_3=`(expr $as_lineno_1 + 1) 2>/dev/null`
- test "x$as_lineno_1" != "x$as_lineno_2" &&
- test "x$as_lineno_3" = "x$as_lineno_2" ') 2>/dev/null; then
- $as_unset BASH_ENV || test "${BASH_ENV+set}" != set || { BASH_ENV=; export BASH_ENV; }
- $as_unset ENV || test "${ENV+set}" != set || { ENV=; export ENV; }
- CONFIG_SHELL=$as_dir/$as_base
- export CONFIG_SHELL
- exec "$CONFIG_SHELL" "$0" ${1+"$@"}
- fi;;
- esac
- done
-done
-;;
- esac
-
- # Create $as_me.lineno as a copy of $as_myself, but with $LINENO
- # uniformly replaced by the line number. The first 'sed' inserts a
- # line-number line before each line; the second 'sed' does the real
- # work. The second script uses 'N' to pair each line-number line
- # with the numbered line, and appends trailing '-' during
- # substitution so that $LINENO is not a special case at line end.
- # (Raja R Harinath suggested sed '=', and Paul Eggert wrote the
- # second 'sed' script. Blame Lee E. McMahon for sed's syntax. :-)
- sed '=' <$as_myself |
- sed '
- N
- s,$,-,
- : loop
- s,^\(['$as_cr_digits']*\)\(.*\)[$]LINENO\([^'$as_cr_alnum'_]\),\1\2\1\3,
- t loop
- s,-$,,
- s,^['$as_cr_digits']*\n,,
- ' >$as_me.lineno &&
- chmod +x $as_me.lineno ||
- { { echo "$as_me:$LINENO: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&5
-echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2;}
- { (exit 1); exit 1; }; }
-
- # Don't try to exec as it changes $[0], causing all sort of problems
- # (the dirname of $[0] is not the place where we might find the
- # original and so on. Autoconf is especially sensible to this).
- . ./$as_me.lineno
- # Exit status is that of the last command.
- exit
-}
-
-
-case `echo "testing\c"; echo 1,2,3`,`echo -n testing; echo 1,2,3` in
- *c*,-n*) ECHO_N= ECHO_C='
-' ECHO_T=' ' ;;
- *c*,* ) ECHO_N=-n ECHO_C= ECHO_T= ;;
- *) ECHO_N= ECHO_C='\c' ECHO_T= ;;
-esac
-
-if expr a : '\(a\)' >/dev/null 2>&1; then
- as_expr=expr
-else
- as_expr=false
-fi
-
-rm -f conf$$ conf$$.exe conf$$.file
-echo >conf$$.file
-if ln -s conf$$.file conf$$ 2>/dev/null; then
- # We could just check for DJGPP; but this test a) works b) is more generic
- # and c) will remain valid once DJGPP supports symlinks (DJGPP 2.04).
- if test -f conf$$.exe; then
- # Don't use ln at all; we don't have any links
- as_ln_s='cp -p'
- else
- as_ln_s='ln -s'
- fi
-elif ln conf$$.file conf$$ 2>/dev/null; then
- as_ln_s=ln
-else
- as_ln_s='cp -p'
-fi
-rm -f conf$$ conf$$.exe conf$$.file
-
-if mkdir -p . 2>/dev/null; then
- as_mkdir_p=:
-else
- test -d ./-p && rmdir ./-p
- as_mkdir_p=false
-fi
-
-as_executable_p="test -f"
-
-# Sed expression to map a string onto a valid CPP name.
-as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'"
-
-# Sed expression to map a string onto a valid variable name.
-as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'"
-
-
-# IFS
-# We need space, tab and new line, in precisely that order.
-as_nl='
-'
-IFS=" $as_nl"
-
-# CDPATH.
-$as_unset CDPATH
-
-exec 6>&1
-
-# Open the log real soon, to keep \$[0] and so on meaningful, and to
-# report actual input values of CONFIG_FILES etc. instead of their
-# values after options handling. Logging --version etc. is OK.
-exec 5>>config.log
-{
- echo
- sed 'h;s/./-/g;s/^.../## /;s/...$/ ##/;p;x;p;x' <<_ASBOX
-## Running $as_me. ##
-_ASBOX
-} >&5
-cat >&5 <<_CSEOF
-
-This file was extended by libibcm $as_me 1.0.5, which was
-generated by GNU Autoconf 2.59. Invocation command line was
-
- CONFIG_FILES = $CONFIG_FILES
- CONFIG_HEADERS = $CONFIG_HEADERS
- CONFIG_LINKS = $CONFIG_LINKS
- CONFIG_COMMANDS = $CONFIG_COMMANDS
- $ $0 $@
-
-_CSEOF
-echo "on `(hostname || uname -n) 2>/dev/null | sed 1q`" >&5
-echo >&5
-_ACEOF
-
-# Files that config.status was made for.
-if test -n "$ac_config_files"; then
- echo "config_files=\"$ac_config_files\"" >>$CONFIG_STATUS
-fi
-
-if test -n "$ac_config_headers"; then
- echo "config_headers=\"$ac_config_headers\"" >>$CONFIG_STATUS
-fi
-
-if test -n "$ac_config_links"; then
- echo "config_links=\"$ac_config_links\"" >>$CONFIG_STATUS
-fi
-
-if test -n "$ac_config_commands"; then
- echo "config_commands=\"$ac_config_commands\"" >>$CONFIG_STATUS
-fi
-
-cat >>$CONFIG_STATUS <<\_ACEOF
-
-ac_cs_usage="\
-\`$as_me' instantiates files from templates according to the
-current configuration.
-
-Usage: $0 [OPTIONS] [FILE]...
-
- -h, --help print this help, then exit
- -V, --version print version number, then exit
- -q, --quiet do not print progress messages
- -d, --debug don't remove temporary files
- --recheck update $as_me by reconfiguring in the same conditions
- --file=FILE[:TEMPLATE]
- instantiate the configuration file FILE
- --header=FILE[:TEMPLATE]
- instantiate the configuration header FILE
-
-Configuration files:
-$config_files
-
-Configuration headers:
-$config_headers
-
-Configuration commands:
-$config_commands
-
-Report bugs to <bug-autoconf@gnu.org>."
-_ACEOF
-
-cat >>$CONFIG_STATUS <<_ACEOF
-ac_cs_version="\\
-libibcm config.status 1.0.5
-configured by $0, generated by GNU Autoconf 2.59,
- with options \\"`echo "$ac_configure_args" | sed 's/[\\""\`\$]/\\\\&/g'`\\"
-
-Copyright (C) 2003 Free Software Foundation, Inc.
-This config.status script is free software; the Free Software Foundation
-gives unlimited permission to copy, distribute and modify it."
-srcdir=$srcdir
-INSTALL="$INSTALL"
-_ACEOF
-
-cat >>$CONFIG_STATUS <<\_ACEOF
-# If no file are specified by the user, then we need to provide default
-# value. By we need to know if files were specified by the user.
-ac_need_defaults=:
-while test $# != 0
-do
- case $1 in
- --*=*)
- ac_option=`expr "x$1" : 'x\([^=]*\)='`
- ac_optarg=`expr "x$1" : 'x[^=]*=\(.*\)'`
- ac_shift=:
- ;;
- -*)
- ac_option=$1
- ac_optarg=$2
- ac_shift=shift
- ;;
- *) # This is not an option, so the user has probably given explicit
- # arguments.
- ac_option=$1
- ac_need_defaults=false;;
- esac
-
- case $ac_option in
- # Handling of the options.
-_ACEOF
-cat >>$CONFIG_STATUS <<\_ACEOF
- -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r)
- ac_cs_recheck=: ;;
- --version | --vers* | -V )
- echo "$ac_cs_version"; exit 0 ;;
- --he | --h)
- # Conflict between --help and --header
- { { echo "$as_me:$LINENO: error: ambiguous option: $1
-Try \`$0 --help' for more information." >&5
-echo "$as_me: error: ambiguous option: $1
-Try \`$0 --help' for more information." >&2;}
- { (exit 1); exit 1; }; };;
- --help | --hel | -h )
- echo "$ac_cs_usage"; exit 0 ;;
- --debug | --d* | -d )
- debug=: ;;
- --file | --fil | --fi | --f )
- $ac_shift
- CONFIG_FILES="$CONFIG_FILES $ac_optarg"
- ac_need_defaults=false;;
- --header | --heade | --head | --hea )
- $ac_shift
- CONFIG_HEADERS="$CONFIG_HEADERS $ac_optarg"
- ac_need_defaults=false;;
- -q | -quiet | --quiet | --quie | --qui | --qu | --q \
- | -silent | --silent | --silen | --sile | --sil | --si | --s)
- ac_cs_silent=: ;;
-
- # This is an error.
- -*) { { echo "$as_me:$LINENO: error: unrecognized option: $1
-Try \`$0 --help' for more information." >&5
-echo "$as_me: error: unrecognized option: $1
-Try \`$0 --help' for more information." >&2;}
- { (exit 1); exit 1; }; } ;;
-
- *) ac_config_targets="$ac_config_targets $1" ;;
-
- esac
- shift
-done
-
-ac_configure_extra_args=
-
-if $ac_cs_silent; then
- exec 6>/dev/null
- ac_configure_extra_args="$ac_configure_extra_args --silent"
-fi
-
-_ACEOF
-cat >>$CONFIG_STATUS <<_ACEOF
-if \$ac_cs_recheck; then
- echo "running $SHELL $0 " $ac_configure_args \$ac_configure_extra_args " --no-create --no-recursion" >&6
- exec $SHELL $0 $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion
-fi
-
-_ACEOF
-
-cat >>$CONFIG_STATUS <<_ACEOF
-#
-# INIT-COMMANDS section.
-#
-
-AMDEP_TRUE="$AMDEP_TRUE" ac_aux_dir="$ac_aux_dir"
-
-_ACEOF
-
-
-
-cat >>$CONFIG_STATUS <<\_ACEOF
-for ac_config_target in $ac_config_targets
-do
- case "$ac_config_target" in
- # Handling of arguments.
- "Makefile" ) CONFIG_FILES="$CONFIG_FILES Makefile" ;;
- "libibcm.spec" ) CONFIG_FILES="$CONFIG_FILES libibcm.spec" ;;
- "depfiles" ) CONFIG_COMMANDS="$CONFIG_COMMANDS depfiles" ;;
- "config.h" ) CONFIG_HEADERS="$CONFIG_HEADERS config.h" ;;
- *) { { echo "$as_me:$LINENO: error: invalid argument: $ac_config_target" >&5
-echo "$as_me: error: invalid argument: $ac_config_target" >&2;}
- { (exit 1); exit 1; }; };;
- esac
-done
-
-# If the user did not use the arguments to specify the items to instantiate,
-# then the envvar interface is used. Set only those that are not.
-# We use the long form for the default assignment because of an extremely
-# bizarre bug on SunOS 4.1.3.
-if $ac_need_defaults; then
- test "${CONFIG_FILES+set}" = set || CONFIG_FILES=$config_files
- test "${CONFIG_HEADERS+set}" = set || CONFIG_HEADERS=$config_headers
- test "${CONFIG_COMMANDS+set}" = set || CONFIG_COMMANDS=$config_commands
-fi
-
-# Have a temporary directory for convenience. Make it in the build tree
-# simply because there is no reason to put it here, and in addition,
-# creating and moving files from /tmp can sometimes cause problems.
-# Create a temporary directory, and hook for its removal unless debugging.
-$debug ||
-{
- trap 'exit_status=$?; rm -rf $tmp && exit $exit_status' 0
- trap '{ (exit 1); exit 1; }' 1 2 13 15
-}
-
-# Create a (secure) tmp directory for tmp files.
-
-{
- tmp=`(umask 077 && mktemp -d -q "./confstatXXXXXX") 2>/dev/null` &&
- test -n "$tmp" && test -d "$tmp"
-} ||
-{
- tmp=./confstat$$-$RANDOM
- (umask 077 && mkdir $tmp)
-} ||
-{
- echo "$me: cannot create a temporary directory in ." >&2
- { (exit 1); exit 1; }
-}
-
-_ACEOF
-
-cat >>$CONFIG_STATUS <<_ACEOF
-
-#
-# CONFIG_FILES section.
-#
-
-# No need to generate the scripts if there are no CONFIG_FILES.
-# This happens for instance when ./config.status config.h
-if test -n "\$CONFIG_FILES"; then
- # Protect against being on the right side of a sed subst in config.status.
- sed 's/,@/@@/; s/@,/@@/; s/,;t t\$/@;t t/; /@;t t\$/s/[\\\\&,]/\\\\&/g;
- s/@@/,@/; s/@@/@,/; s/@;t t\$/,;t t/' >\$tmp/subs.sed <<\\CEOF
-s,@SHELL@,$SHELL,;t t
-s,@PATH_SEPARATOR@,$PATH_SEPARATOR,;t t
-s,@PACKAGE_NAME@,$PACKAGE_NAME,;t t
-s,@PACKAGE_TARNAME@,$PACKAGE_TARNAME,;t t
-s,@PACKAGE_VERSION@,$PACKAGE_VERSION,;t t
-s,@PACKAGE_STRING@,$PACKAGE_STRING,;t t
-s,@PACKAGE_BUGREPORT@,$PACKAGE_BUGREPORT,;t t
-s,@exec_prefix@,$exec_prefix,;t t
-s,@prefix@,$prefix,;t t
-s,@program_transform_name@,$program_transform_name,;t t
-s,@bindir@,$bindir,;t t
-s,@sbindir@,$sbindir,;t t
-s,@libexecdir@,$libexecdir,;t t
-s,@datadir@,$datadir,;t t
-s,@sysconfdir@,$sysconfdir,;t t
-s,@sharedstatedir@,$sharedstatedir,;t t
-s,@localstatedir@,$localstatedir,;t t
-s,@libdir@,$libdir,;t t
-s,@includedir@,$includedir,;t t
-s,@oldincludedir@,$oldincludedir,;t t
-s,@infodir@,$infodir,;t t
-s,@mandir@,$mandir,;t t
-s,@build_alias@,$build_alias,;t t
-s,@host_alias@,$host_alias,;t t
-s,@target_alias@,$target_alias,;t t
-s,@DEFS@,$DEFS,;t t
-s,@ECHO_C@,$ECHO_C,;t t
-s,@ECHO_N@,$ECHO_N,;t t
-s,@ECHO_T@,$ECHO_T,;t t
-s,@LIBS@,$LIBS,;t t
-s,@INSTALL_PROGRAM@,$INSTALL_PROGRAM,;t t
-s,@INSTALL_SCRIPT@,$INSTALL_SCRIPT,;t t
-s,@INSTALL_DATA@,$INSTALL_DATA,;t t
-s,@CYGPATH_W@,$CYGPATH_W,;t t
-s,@PACKAGE@,$PACKAGE,;t t
-s,@VERSION@,$VERSION,;t t
-s,@ACLOCAL@,$ACLOCAL,;t t
-s,@AUTOCONF@,$AUTOCONF,;t t
-s,@AUTOMAKE@,$AUTOMAKE,;t t
-s,@AUTOHEADER@,$AUTOHEADER,;t t
-s,@MAKEINFO@,$MAKEINFO,;t t
-s,@install_sh@,$install_sh,;t t
-s,@STRIP@,$STRIP,;t t
-s,@ac_ct_STRIP@,$ac_ct_STRIP,;t t
-s,@INSTALL_STRIP_PROGRAM@,$INSTALL_STRIP_PROGRAM,;t t
-s,@mkdir_p@,$mkdir_p,;t t
-s,@AWK@,$AWK,;t t
-s,@SET_MAKE@,$SET_MAKE,;t t
-s,@am__leading_dot@,$am__leading_dot,;t t
-s,@AMTAR@,$AMTAR,;t t
-s,@am__tar@,$am__tar,;t t
-s,@am__untar@,$am__untar,;t t
-s,@build@,$build,;t t
-s,@build_cpu@,$build_cpu,;t t
-s,@build_vendor@,$build_vendor,;t t
-s,@build_os@,$build_os,;t t
-s,@host@,$host,;t t
-s,@host_cpu@,$host_cpu,;t t
-s,@host_vendor@,$host_vendor,;t t
-s,@host_os@,$host_os,;t t
-s,@CC@,$CC,;t t
-s,@CFLAGS@,$CFLAGS,;t t
-s,@LDFLAGS@,$LDFLAGS,;t t
-s,@CPPFLAGS@,$CPPFLAGS,;t t
-s,@ac_ct_CC@,$ac_ct_CC,;t t
-s,@EXEEXT@,$EXEEXT,;t t
-s,@OBJEXT@,$OBJEXT,;t t
-s,@DEPDIR@,$DEPDIR,;t t
-s,@am__include@,$am__include,;t t
-s,@am__quote@,$am__quote,;t t
-s,@AMDEP_TRUE@,$AMDEP_TRUE,;t t
-s,@AMDEP_FALSE@,$AMDEP_FALSE,;t t
-s,@AMDEPBACKSLASH@,$AMDEPBACKSLASH,;t t
-s,@CCDEPMODE@,$CCDEPMODE,;t t
-s,@am__fastdepCC_TRUE@,$am__fastdepCC_TRUE,;t t
-s,@am__fastdepCC_FALSE@,$am__fastdepCC_FALSE,;t t
-s,@EGREP@,$EGREP,;t t
-s,@LN_S@,$LN_S,;t t
-s,@ECHO@,$ECHO,;t t
-s,@AR@,$AR,;t t
-s,@ac_ct_AR@,$ac_ct_AR,;t t
-s,@RANLIB@,$RANLIB,;t t
-s,@ac_ct_RANLIB@,$ac_ct_RANLIB,;t t
-s,@CPP@,$CPP,;t t
-s,@CXX@,$CXX,;t t
-s,@CXXFLAGS@,$CXXFLAGS,;t t
-s,@ac_ct_CXX@,$ac_ct_CXX,;t t
-s,@CXXDEPMODE@,$CXXDEPMODE,;t t
-s,@am__fastdepCXX_TRUE@,$am__fastdepCXX_TRUE,;t t
-s,@am__fastdepCXX_FALSE@,$am__fastdepCXX_FALSE,;t t
-s,@CXXCPP@,$CXXCPP,;t t
-s,@F77@,$F77,;t t
-s,@FFLAGS@,$FFLAGS,;t t
-s,@ac_ct_F77@,$ac_ct_F77,;t t
-s,@LIBTOOL@,$LIBTOOL,;t t
-s,@HAVE_LD_VERSION_SCRIPT_TRUE@,$HAVE_LD_VERSION_SCRIPT_TRUE,;t t
-s,@HAVE_LD_VERSION_SCRIPT_FALSE@,$HAVE_LD_VERSION_SCRIPT_FALSE,;t t
-s,@LIBOBJS@,$LIBOBJS,;t t
-s,@LTLIBOBJS@,$LTLIBOBJS,;t t
-CEOF
-
-_ACEOF
-
- cat >>$CONFIG_STATUS <<\_ACEOF
- # Split the substitutions into bite-sized pieces for seds with
- # small command number limits, like on Digital OSF/1 and HP-UX.
- ac_max_sed_lines=48
- ac_sed_frag=1 # Number of current file.
- ac_beg=1 # First line for current file.
- ac_end=$ac_max_sed_lines # Line after last line for current file.
- ac_more_lines=:
- ac_sed_cmds=
- while $ac_more_lines; do
- if test $ac_beg -gt 1; then
- sed "1,${ac_beg}d; ${ac_end}q" $tmp/subs.sed >$tmp/subs.frag
- else
- sed "${ac_end}q" $tmp/subs.sed >$tmp/subs.frag
- fi
- if test ! -s $tmp/subs.frag; then
- ac_more_lines=false
- else
- # The purpose of the label and of the branching condition is to
- # speed up the sed processing (if there are no `@' at all, there
- # is no need to browse any of the substitutions).
- # These are the two extra sed commands mentioned above.
- (echo ':t
- /@[a-zA-Z_][a-zA-Z_0-9]*@/!b' && cat $tmp/subs.frag) >$tmp/subs-$ac_sed_frag.sed
- if test -z "$ac_sed_cmds"; then
- ac_sed_cmds="sed -f $tmp/subs-$ac_sed_frag.sed"
- else
- ac_sed_cmds="$ac_sed_cmds | sed -f $tmp/subs-$ac_sed_frag.sed"
- fi
- ac_sed_frag=`expr $ac_sed_frag + 1`
- ac_beg=$ac_end
- ac_end=`expr $ac_end + $ac_max_sed_lines`
- fi
- done
- if test -z "$ac_sed_cmds"; then
- ac_sed_cmds=cat
- fi
-fi # test -n "$CONFIG_FILES"
-
-_ACEOF
-cat >>$CONFIG_STATUS <<\_ACEOF
-for ac_file in : $CONFIG_FILES; do test "x$ac_file" = x: && continue
- # Support "outfile[:infile[:infile...]]", defaulting infile="outfile.in".
- case $ac_file in
- - | *:- | *:-:* ) # input from stdin
- cat >$tmp/stdin
- ac_file_in=`echo "$ac_file" | sed 's,[^:]*:,,'`
- ac_file=`echo "$ac_file" | sed 's,:.*,,'` ;;
- *:* ) ac_file_in=`echo "$ac_file" | sed 's,[^:]*:,,'`
- ac_file=`echo "$ac_file" | sed 's,:.*,,'` ;;
- * ) ac_file_in=$ac_file.in ;;
- esac
-
- # Compute @srcdir@, @top_srcdir@, and @INSTALL@ for subdirectories.
- ac_dir=`(dirname "$ac_file") 2>/dev/null ||
-$as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
- X"$ac_file" : 'X\(//\)[^/]' \| \
- X"$ac_file" : 'X\(//\)$' \| \
- X"$ac_file" : 'X\(/\)' \| \
- . : '\(.\)' 2>/dev/null ||
-echo X"$ac_file" |
- sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; }
- /^X\(\/\/\)[^/].*/{ s//\1/; q; }
- /^X\(\/\/\)$/{ s//\1/; q; }
- /^X\(\/\).*/{ s//\1/; q; }
- s/.*/./; q'`
- { if $as_mkdir_p; then
- mkdir -p "$ac_dir"
- else
- as_dir="$ac_dir"
- as_dirs=
- while test ! -d "$as_dir"; do
- as_dirs="$as_dir $as_dirs"
- as_dir=`(dirname "$as_dir") 2>/dev/null ||
-$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
- X"$as_dir" : 'X\(//\)[^/]' \| \
- X"$as_dir" : 'X\(//\)$' \| \
- X"$as_dir" : 'X\(/\)' \| \
- . : '\(.\)' 2>/dev/null ||
-echo X"$as_dir" |
- sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; }
- /^X\(\/\/\)[^/].*/{ s//\1/; q; }
- /^X\(\/\/\)$/{ s//\1/; q; }
- /^X\(\/\).*/{ s//\1/; q; }
- s/.*/./; q'`
- done
- test ! -n "$as_dirs" || mkdir $as_dirs
- fi || { { echo "$as_me:$LINENO: error: cannot create directory \"$ac_dir\"" >&5
-echo "$as_me: error: cannot create directory \"$ac_dir\"" >&2;}
- { (exit 1); exit 1; }; }; }
-
- ac_builddir=.
-
-if test "$ac_dir" != .; then
- ac_dir_suffix=/`echo "$ac_dir" | sed 's,^\.[\\/],,'`
- # A "../" for each directory in $ac_dir_suffix.
- ac_top_builddir=`echo "$ac_dir_suffix" | sed 's,/[^\\/]*,../,g'`
-else
- ac_dir_suffix= ac_top_builddir=
-fi
-
-case $srcdir in
- .) # No --srcdir option. We are building in place.
- ac_srcdir=.
- if test -z "$ac_top_builddir"; then
- ac_top_srcdir=.
- else
- ac_top_srcdir=`echo $ac_top_builddir | sed 's,/$,,'`
- fi ;;
- [\\/]* | ?:[\\/]* ) # Absolute path.
- ac_srcdir=$srcdir$ac_dir_suffix;
- ac_top_srcdir=$srcdir ;;
- *) # Relative path.
- ac_srcdir=$ac_top_builddir$srcdir$ac_dir_suffix
- ac_top_srcdir=$ac_top_builddir$srcdir ;;
-esac
-
-# Do not use `cd foo && pwd` to compute absolute paths, because
-# the directories may not exist.
-case `pwd` in
-.) ac_abs_builddir="$ac_dir";;
-*)
- case "$ac_dir" in
- .) ac_abs_builddir=`pwd`;;
- [\\/]* | ?:[\\/]* ) ac_abs_builddir="$ac_dir";;
- *) ac_abs_builddir=`pwd`/"$ac_dir";;
- esac;;
-esac
-case $ac_abs_builddir in
-.) ac_abs_top_builddir=${ac_top_builddir}.;;
-*)
- case ${ac_top_builddir}. in
- .) ac_abs_top_builddir=$ac_abs_builddir;;
- [\\/]* | ?:[\\/]* ) ac_abs_top_builddir=${ac_top_builddir}.;;
- *) ac_abs_top_builddir=$ac_abs_builddir/${ac_top_builddir}.;;
- esac;;
-esac
-case $ac_abs_builddir in
-.) ac_abs_srcdir=$ac_srcdir;;
-*)
- case $ac_srcdir in
- .) ac_abs_srcdir=$ac_abs_builddir;;
- [\\/]* | ?:[\\/]* ) ac_abs_srcdir=$ac_srcdir;;
- *) ac_abs_srcdir=$ac_abs_builddir/$ac_srcdir;;
- esac;;
-esac
-case $ac_abs_builddir in
-.) ac_abs_top_srcdir=$ac_top_srcdir;;
-*)
- case $ac_top_srcdir in
- .) ac_abs_top_srcdir=$ac_abs_builddir;;
- [\\/]* | ?:[\\/]* ) ac_abs_top_srcdir=$ac_top_srcdir;;
- *) ac_abs_top_srcdir=$ac_abs_builddir/$ac_top_srcdir;;
- esac;;
-esac
-
-
- case $INSTALL in
- [\\/$]* | ?:[\\/]* ) ac_INSTALL=$INSTALL ;;
- *) ac_INSTALL=$ac_top_builddir$INSTALL ;;
- esac
-
- # Let's still pretend it is `configure' which instantiates (i.e., don't
- # use $as_me), people would be surprised to read:
- # /* config.h. Generated by config.status. */
- if test x"$ac_file" = x-; then
- configure_input=
- else
- configure_input="$ac_file. "
- fi
- configure_input=$configure_input"Generated from `echo $ac_file_in |
- sed 's,.*/,,'` by configure."
-
- # First look for the input files in the build tree, otherwise in the
- # src tree.
- ac_file_inputs=`IFS=:
- for f in $ac_file_in; do
- case $f in
- -) echo $tmp/stdin ;;
- [\\/$]*)
- # Absolute (can't be DOS-style, as IFS=:)
- test -f "$f" || { { echo "$as_me:$LINENO: error: cannot find input file: $f" >&5
-echo "$as_me: error: cannot find input file: $f" >&2;}
- { (exit 1); exit 1; }; }
- echo "$f";;
- *) # Relative
- if test -f "$f"; then
- # Build tree
- echo "$f"
- elif test -f "$srcdir/$f"; then
- # Source tree
- echo "$srcdir/$f"
- else
- # /dev/null tree
- { { echo "$as_me:$LINENO: error: cannot find input file: $f" >&5
-echo "$as_me: error: cannot find input file: $f" >&2;}
- { (exit 1); exit 1; }; }
- fi;;
- esac
- done` || { (exit 1); exit 1; }
-
- if test x"$ac_file" != x-; then
- { echo "$as_me:$LINENO: creating $ac_file" >&5
-echo "$as_me: creating $ac_file" >&6;}
- rm -f "$ac_file"
- fi
-_ACEOF
-cat >>$CONFIG_STATUS <<_ACEOF
- sed "$ac_vpsub
-$extrasub
-_ACEOF
-cat >>$CONFIG_STATUS <<\_ACEOF
-:t
-/@[a-zA-Z_][a-zA-Z_0-9]*@/!b
-s,@configure_input@,$configure_input,;t t
-s,@srcdir@,$ac_srcdir,;t t
-s,@abs_srcdir@,$ac_abs_srcdir,;t t
-s,@top_srcdir@,$ac_top_srcdir,;t t
-s,@abs_top_srcdir@,$ac_abs_top_srcdir,;t t
-s,@builddir@,$ac_builddir,;t t
-s,@abs_builddir@,$ac_abs_builddir,;t t
-s,@top_builddir@,$ac_top_builddir,;t t
-s,@abs_top_builddir@,$ac_abs_top_builddir,;t t
-s,@INSTALL@,$ac_INSTALL,;t t
-" $ac_file_inputs | (eval "$ac_sed_cmds") >$tmp/out
- rm -f $tmp/stdin
- if test x"$ac_file" != x-; then
- mv $tmp/out $ac_file
- else
- cat $tmp/out
- rm -f $tmp/out
- fi
-
-done
-_ACEOF
-cat >>$CONFIG_STATUS <<\_ACEOF
-
-#
-# CONFIG_HEADER section.
-#
-
-# These sed commands are passed to sed as "A NAME B NAME C VALUE D", where
-# NAME is the cpp macro being defined and VALUE is the value it is being given.
-#
-# ac_d sets the value in "#define NAME VALUE" lines.
-ac_dA='s,^\([ ]*\)#\([ ]*define[ ][ ]*\)'
-ac_dB='[ ].*$,\1#\2'
-ac_dC=' '
-ac_dD=',;t'
-# ac_u turns "#undef NAME" without trailing blanks into "#define NAME VALUE".
-ac_uA='s,^\([ ]*\)#\([ ]*\)undef\([ ][ ]*\)'
-ac_uB='$,\1#\2define\3'
-ac_uC=' '
-ac_uD=',;t'
-
-for ac_file in : $CONFIG_HEADERS; do test "x$ac_file" = x: && continue
- # Support "outfile[:infile[:infile...]]", defaulting infile="outfile.in".
- case $ac_file in
- - | *:- | *:-:* ) # input from stdin
- cat >$tmp/stdin
- ac_file_in=`echo "$ac_file" | sed 's,[^:]*:,,'`
- ac_file=`echo "$ac_file" | sed 's,:.*,,'` ;;
- *:* ) ac_file_in=`echo "$ac_file" | sed 's,[^:]*:,,'`
- ac_file=`echo "$ac_file" | sed 's,:.*,,'` ;;
- * ) ac_file_in=$ac_file.in ;;
- esac
-
- test x"$ac_file" != x- && { echo "$as_me:$LINENO: creating $ac_file" >&5
-echo "$as_me: creating $ac_file" >&6;}
-
- # First look for the input files in the build tree, otherwise in the
- # src tree.
- ac_file_inputs=`IFS=:
- for f in $ac_file_in; do
- case $f in
- -) echo $tmp/stdin ;;
- [\\/$]*)
- # Absolute (can't be DOS-style, as IFS=:)
- test -f "$f" || { { echo "$as_me:$LINENO: error: cannot find input file: $f" >&5
-echo "$as_me: error: cannot find input file: $f" >&2;}
- { (exit 1); exit 1; }; }
- # Do quote $f, to prevent DOS paths from being IFS'd.
- echo "$f";;
- *) # Relative
- if test -f "$f"; then
- # Build tree
- echo "$f"
- elif test -f "$srcdir/$f"; then
- # Source tree
- echo "$srcdir/$f"
- else
- # /dev/null tree
- { { echo "$as_me:$LINENO: error: cannot find input file: $f" >&5
-echo "$as_me: error: cannot find input file: $f" >&2;}
- { (exit 1); exit 1; }; }
- fi;;
- esac
- done` || { (exit 1); exit 1; }
- # Remove the trailing spaces.
- sed 's/[ ]*$//' $ac_file_inputs >$tmp/in
-
-_ACEOF
-
-# Transform confdefs.h into two sed scripts, `conftest.defines' and
-# `conftest.undefs', that substitutes the proper values into
-# config.h.in to produce config.h. The first handles `#define'
-# templates, and the second `#undef' templates.
-# And first: Protect against being on the right side of a sed subst in
-# config.status. Protect against being in an unquoted here document
-# in config.status.
-rm -f conftest.defines conftest.undefs
-# Using a here document instead of a string reduces the quoting nightmare.
-# Putting comments in sed scripts is not portable.
-#
-# `end' is used to avoid that the second main sed command (meant for
-# 0-ary CPP macros) applies to n-ary macro definitions.
-# See the Autoconf documentation for `clear'.
-cat >confdef2sed.sed <<\_ACEOF
-s/[\\&,]/\\&/g
-s,[\\$`],\\&,g
-t clear
-: clear
-s,^[ ]*#[ ]*define[ ][ ]*\([^ (][^ (]*\)\(([^)]*)\)[ ]*\(.*\)$,${ac_dA}\1${ac_dB}\1\2${ac_dC}\3${ac_dD},gp
-t end
-s,^[ ]*#[ ]*define[ ][ ]*\([^ ][^ ]*\)[ ]*\(.*\)$,${ac_dA}\1${ac_dB}\1${ac_dC}\2${ac_dD},gp
-: end
-_ACEOF
-# If some macros were called several times there might be several times
-# the same #defines, which is useless. Nevertheless, we may not want to
-# sort them, since we want the *last* AC-DEFINE to be honored.
-uniq confdefs.h | sed -n -f confdef2sed.sed >conftest.defines
-sed 's/ac_d/ac_u/g' conftest.defines >conftest.undefs
-rm -f confdef2sed.sed
-
-# This sed command replaces #undef with comments. This is necessary, for
-# example, in the case of _POSIX_SOURCE, which is predefined and required
-# on some systems where configure will not decide to define it.
-cat >>conftest.undefs <<\_ACEOF
-s,^[ ]*#[ ]*undef[ ][ ]*[a-zA-Z_][a-zA-Z_0-9]*,/* & */,
-_ACEOF
-
-# Break up conftest.defines because some shells have a limit on the size
-# of here documents, and old seds have small limits too (100 cmds).
-echo ' # Handle all the #define templates only if necessary.' >>$CONFIG_STATUS
-echo ' if grep "^[ ]*#[ ]*define" $tmp/in >/dev/null; then' >>$CONFIG_STATUS
-echo ' # If there are no defines, we may have an empty if/fi' >>$CONFIG_STATUS
-echo ' :' >>$CONFIG_STATUS
-rm -f conftest.tail
-while grep . conftest.defines >/dev/null
-do
- # Write a limited-size here document to $tmp/defines.sed.
- echo ' cat >$tmp/defines.sed <<CEOF' >>$CONFIG_STATUS
- # Speed up: don't consider the non `#define' lines.
- echo '/^[ ]*#[ ]*define/!b' >>$CONFIG_STATUS
- # Work around the forget-to-reset-the-flag bug.
- echo 't clr' >>$CONFIG_STATUS
- echo ': clr' >>$CONFIG_STATUS
- sed ${ac_max_here_lines}q conftest.defines >>$CONFIG_STATUS
- echo 'CEOF
- sed -f $tmp/defines.sed $tmp/in >$tmp/out
- rm -f $tmp/in
- mv $tmp/out $tmp/in
-' >>$CONFIG_STATUS
- sed 1,${ac_max_here_lines}d conftest.defines >conftest.tail
- rm -f conftest.defines
- mv conftest.tail conftest.defines
-done
-rm -f conftest.defines
-echo ' fi # grep' >>$CONFIG_STATUS
-echo >>$CONFIG_STATUS
-
-# Break up conftest.undefs because some shells have a limit on the size
-# of here documents, and old seds have small limits too (100 cmds).
-echo ' # Handle all the #undef templates' >>$CONFIG_STATUS
-rm -f conftest.tail
-while grep . conftest.undefs >/dev/null
-do
- # Write a limited-size here document to $tmp/undefs.sed.
- echo ' cat >$tmp/undefs.sed <<CEOF' >>$CONFIG_STATUS
- # Speed up: don't consider the non `#undef'
- echo '/^[ ]*#[ ]*undef/!b' >>$CONFIG_STATUS
- # Work around the forget-to-reset-the-flag bug.
- echo 't clr' >>$CONFIG_STATUS
- echo ': clr' >>$CONFIG_STATUS
- sed ${ac_max_here_lines}q conftest.undefs >>$CONFIG_STATUS
- echo 'CEOF
- sed -f $tmp/undefs.sed $tmp/in >$tmp/out
- rm -f $tmp/in
- mv $tmp/out $tmp/in
-' >>$CONFIG_STATUS
- sed 1,${ac_max_here_lines}d conftest.undefs >conftest.tail
- rm -f conftest.undefs
- mv conftest.tail conftest.undefs
-done
-rm -f conftest.undefs
-
-cat >>$CONFIG_STATUS <<\_ACEOF
- # Let's still pretend it is `configure' which instantiates (i.e., don't
- # use $as_me), people would be surprised to read:
- # /* config.h. Generated by config.status. */
- if test x"$ac_file" = x-; then
- echo "/* Generated by configure. */" >$tmp/config.h
- else
- echo "/* $ac_file. Generated by configure. */" >$tmp/config.h
- fi
- cat $tmp/in >>$tmp/config.h
- rm -f $tmp/in
- if test x"$ac_file" != x-; then
- if diff $ac_file $tmp/config.h >/dev/null 2>&1; then
- { echo "$as_me:$LINENO: $ac_file is unchanged" >&5
-echo "$as_me: $ac_file is unchanged" >&6;}
- else
- ac_dir=`(dirname "$ac_file") 2>/dev/null ||
-$as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
- X"$ac_file" : 'X\(//\)[^/]' \| \
- X"$ac_file" : 'X\(//\)$' \| \
- X"$ac_file" : 'X\(/\)' \| \
- . : '\(.\)' 2>/dev/null ||
-echo X"$ac_file" |
- sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; }
- /^X\(\/\/\)[^/].*/{ s//\1/; q; }
- /^X\(\/\/\)$/{ s//\1/; q; }
- /^X\(\/\).*/{ s//\1/; q; }
- s/.*/./; q'`
- { if $as_mkdir_p; then
- mkdir -p "$ac_dir"
- else
- as_dir="$ac_dir"
- as_dirs=
- while test ! -d "$as_dir"; do
- as_dirs="$as_dir $as_dirs"
- as_dir=`(dirname "$as_dir") 2>/dev/null ||
-$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
- X"$as_dir" : 'X\(//\)[^/]' \| \
- X"$as_dir" : 'X\(//\)$' \| \
- X"$as_dir" : 'X\(/\)' \| \
- . : '\(.\)' 2>/dev/null ||
-echo X"$as_dir" |
- sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; }
- /^X\(\/\/\)[^/].*/{ s//\1/; q; }
- /^X\(\/\/\)$/{ s//\1/; q; }
- /^X\(\/\).*/{ s//\1/; q; }
- s/.*/./; q'`
- done
- test ! -n "$as_dirs" || mkdir $as_dirs
- fi || { { echo "$as_me:$LINENO: error: cannot create directory \"$ac_dir\"" >&5
-echo "$as_me: error: cannot create directory \"$ac_dir\"" >&2;}
- { (exit 1); exit 1; }; }; }
-
- rm -f $ac_file
- mv $tmp/config.h $ac_file
- fi
- else
- cat $tmp/config.h
- rm -f $tmp/config.h
- fi
-# Compute $ac_file's index in $config_headers.
-_am_stamp_count=1
-for _am_header in $config_headers :; do
- case $_am_header in
- $ac_file | $ac_file:* )
- break ;;
- * )
- _am_stamp_count=`expr $_am_stamp_count + 1` ;;
- esac
-done
-echo "timestamp for $ac_file" >`(dirname $ac_file) 2>/dev/null ||
-$as_expr X$ac_file : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
- X$ac_file : 'X\(//\)[^/]' \| \
- X$ac_file : 'X\(//\)$' \| \
- X$ac_file : 'X\(/\)' \| \
- . : '\(.\)' 2>/dev/null ||
-echo X$ac_file |
- sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; }
- /^X\(\/\/\)[^/].*/{ s//\1/; q; }
- /^X\(\/\/\)$/{ s//\1/; q; }
- /^X\(\/\).*/{ s//\1/; q; }
- s/.*/./; q'`/stamp-h$_am_stamp_count
-done
-_ACEOF
-cat >>$CONFIG_STATUS <<\_ACEOF
-
-#
-# CONFIG_COMMANDS section.
-#
-for ac_file in : $CONFIG_COMMANDS; do test "x$ac_file" = x: && continue
- ac_dest=`echo "$ac_file" | sed 's,:.*,,'`
- ac_source=`echo "$ac_file" | sed 's,[^:]*:,,'`
- ac_dir=`(dirname "$ac_dest") 2>/dev/null ||
-$as_expr X"$ac_dest" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
- X"$ac_dest" : 'X\(//\)[^/]' \| \
- X"$ac_dest" : 'X\(//\)$' \| \
- X"$ac_dest" : 'X\(/\)' \| \
- . : '\(.\)' 2>/dev/null ||
-echo X"$ac_dest" |
- sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; }
- /^X\(\/\/\)[^/].*/{ s//\1/; q; }
- /^X\(\/\/\)$/{ s//\1/; q; }
- /^X\(\/\).*/{ s//\1/; q; }
- s/.*/./; q'`
- { if $as_mkdir_p; then
- mkdir -p "$ac_dir"
- else
- as_dir="$ac_dir"
- as_dirs=
- while test ! -d "$as_dir"; do
- as_dirs="$as_dir $as_dirs"
- as_dir=`(dirname "$as_dir") 2>/dev/null ||
-$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
- X"$as_dir" : 'X\(//\)[^/]' \| \
- X"$as_dir" : 'X\(//\)$' \| \
- X"$as_dir" : 'X\(/\)' \| \
- . : '\(.\)' 2>/dev/null ||
-echo X"$as_dir" |
- sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; }
- /^X\(\/\/\)[^/].*/{ s//\1/; q; }
- /^X\(\/\/\)$/{ s//\1/; q; }
- /^X\(\/\).*/{ s//\1/; q; }
- s/.*/./; q'`
- done
- test ! -n "$as_dirs" || mkdir $as_dirs
- fi || { { echo "$as_me:$LINENO: error: cannot create directory \"$ac_dir\"" >&5
-echo "$as_me: error: cannot create directory \"$ac_dir\"" >&2;}
- { (exit 1); exit 1; }; }; }
-
- ac_builddir=.
-
-if test "$ac_dir" != .; then
- ac_dir_suffix=/`echo "$ac_dir" | sed 's,^\.[\\/],,'`
- # A "../" for each directory in $ac_dir_suffix.
- ac_top_builddir=`echo "$ac_dir_suffix" | sed 's,/[^\\/]*,../,g'`
-else
- ac_dir_suffix= ac_top_builddir=
-fi
-
-case $srcdir in
- .) # No --srcdir option. We are building in place.
- ac_srcdir=.
- if test -z "$ac_top_builddir"; then
- ac_top_srcdir=.
- else
- ac_top_srcdir=`echo $ac_top_builddir | sed 's,/$,,'`
- fi ;;
- [\\/]* | ?:[\\/]* ) # Absolute path.
- ac_srcdir=$srcdir$ac_dir_suffix;
- ac_top_srcdir=$srcdir ;;
- *) # Relative path.
- ac_srcdir=$ac_top_builddir$srcdir$ac_dir_suffix
- ac_top_srcdir=$ac_top_builddir$srcdir ;;
-esac
-
-# Do not use `cd foo && pwd` to compute absolute paths, because
-# the directories may not exist.
-case `pwd` in
-.) ac_abs_builddir="$ac_dir";;
-*)
- case "$ac_dir" in
- .) ac_abs_builddir=`pwd`;;
- [\\/]* | ?:[\\/]* ) ac_abs_builddir="$ac_dir";;
- *) ac_abs_builddir=`pwd`/"$ac_dir";;
- esac;;
-esac
-case $ac_abs_builddir in
-.) ac_abs_top_builddir=${ac_top_builddir}.;;
-*)
- case ${ac_top_builddir}. in
- .) ac_abs_top_builddir=$ac_abs_builddir;;
- [\\/]* | ?:[\\/]* ) ac_abs_top_builddir=${ac_top_builddir}.;;
- *) ac_abs_top_builddir=$ac_abs_builddir/${ac_top_builddir}.;;
- esac;;
-esac
-case $ac_abs_builddir in
-.) ac_abs_srcdir=$ac_srcdir;;
-*)
- case $ac_srcdir in
- .) ac_abs_srcdir=$ac_abs_builddir;;
- [\\/]* | ?:[\\/]* ) ac_abs_srcdir=$ac_srcdir;;
- *) ac_abs_srcdir=$ac_abs_builddir/$ac_srcdir;;
- esac;;
-esac
-case $ac_abs_builddir in
-.) ac_abs_top_srcdir=$ac_top_srcdir;;
-*)
- case $ac_top_srcdir in
- .) ac_abs_top_srcdir=$ac_abs_builddir;;
- [\\/]* | ?:[\\/]* ) ac_abs_top_srcdir=$ac_top_srcdir;;
- *) ac_abs_top_srcdir=$ac_abs_builddir/$ac_top_srcdir;;
- esac;;
-esac
-
-
- { echo "$as_me:$LINENO: executing $ac_dest commands" >&5
-echo "$as_me: executing $ac_dest commands" >&6;}
- case $ac_dest in
- depfiles ) test x"$AMDEP_TRUE" != x"" || for mf in $CONFIG_FILES; do
- # Strip MF so we end up with the name of the file.
- mf=`echo "$mf" | sed -e 's/:.*$//'`
- # Check whether this is an Automake generated Makefile or not.
- # We used to match only the files named `Makefile.in', but
- # some people rename them; so instead we look at the file content.
- # Grep'ing the first line is not enough: some people post-process
- # each Makefile.in and add a new line on top of each file to say so.
- # So let's grep whole file.
- if grep '^#.*generated by automake' $mf > /dev/null 2>&1; then
- dirpart=`(dirname "$mf") 2>/dev/null ||
-$as_expr X"$mf" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
- X"$mf" : 'X\(//\)[^/]' \| \
- X"$mf" : 'X\(//\)$' \| \
- X"$mf" : 'X\(/\)' \| \
- . : '\(.\)' 2>/dev/null ||
-echo X"$mf" |
- sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; }
- /^X\(\/\/\)[^/].*/{ s//\1/; q; }
- /^X\(\/\/\)$/{ s//\1/; q; }
- /^X\(\/\).*/{ s//\1/; q; }
- s/.*/./; q'`
- else
- continue
- fi
- # Extract the definition of DEPDIR, am__include, and am__quote
- # from the Makefile without running `make'.
- DEPDIR=`sed -n 's/^DEPDIR = //p' < "$mf"`
- test -z "$DEPDIR" && continue
- am__include=`sed -n 's/^am__include = //p' < "$mf"`
- test -z "am__include" && continue
- am__quote=`sed -n 's/^am__quote = //p' < "$mf"`
- # When using ansi2knr, U may be empty or an underscore; expand it
- U=`sed -n 's/^U = //p' < "$mf"`
- # Find all dependency output files, they are included files with
- # $(DEPDIR) in their names. We invoke sed twice because it is the
- # simplest approach to changing $(DEPDIR) to its actual value in the
- # expansion.
- for file in `sed -n "
- s/^$am__include $am__quote\(.*(DEPDIR).*\)$am__quote"'$/\1/p' <"$mf" | \
- sed -e 's/\$(DEPDIR)/'"$DEPDIR"'/g' -e 's/\$U/'"$U"'/g'`; do
- # Make sure the directory exists.
- test -f "$dirpart/$file" && continue
- fdir=`(dirname "$file") 2>/dev/null ||
-$as_expr X"$file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
- X"$file" : 'X\(//\)[^/]' \| \
- X"$file" : 'X\(//\)$' \| \
- X"$file" : 'X\(/\)' \| \
- . : '\(.\)' 2>/dev/null ||
-echo X"$file" |
- sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; }
- /^X\(\/\/\)[^/].*/{ s//\1/; q; }
- /^X\(\/\/\)$/{ s//\1/; q; }
- /^X\(\/\).*/{ s//\1/; q; }
- s/.*/./; q'`
- { if $as_mkdir_p; then
- mkdir -p $dirpart/$fdir
- else
- as_dir=$dirpart/$fdir
- as_dirs=
- while test ! -d "$as_dir"; do
- as_dirs="$as_dir $as_dirs"
- as_dir=`(dirname "$as_dir") 2>/dev/null ||
-$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
- X"$as_dir" : 'X\(//\)[^/]' \| \
- X"$as_dir" : 'X\(//\)$' \| \
- X"$as_dir" : 'X\(/\)' \| \
- . : '\(.\)' 2>/dev/null ||
-echo X"$as_dir" |
- sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; }
- /^X\(\/\/\)[^/].*/{ s//\1/; q; }
- /^X\(\/\/\)$/{ s//\1/; q; }
- /^X\(\/\).*/{ s//\1/; q; }
- s/.*/./; q'`
- done
- test ! -n "$as_dirs" || mkdir $as_dirs
- fi || { { echo "$as_me:$LINENO: error: cannot create directory $dirpart/$fdir" >&5
-echo "$as_me: error: cannot create directory $dirpart/$fdir" >&2;}
- { (exit 1); exit 1; }; }; }
-
- # echo "creating $dirpart/$file"
- echo '# dummy' > "$dirpart/$file"
- done
-done
- ;;
- esac
-done
-_ACEOF
-
-cat >>$CONFIG_STATUS <<\_ACEOF
-
-{ (exit 0); exit 0; }
-_ACEOF
-chmod +x $CONFIG_STATUS
-ac_clean_files=$ac_clean_files_save
-
-
-# configure is writing to config.log, and then calls config.status.
-# config.status does its own redirection, appending to config.log.
-# Unfortunately, on DOS this fails, as config.log is still kept open
-# by configure, so config.status won't be able to write to it; its
-# output is simply discarded. So we exec the FD to /dev/null,
-# effectively closing config.log, so it can be properly (re)opened and
-# appended to by config.status. When coming back to configure, we
-# need to make the FD available again.
-if test "$no_create" != yes; then
- ac_cs_success=:
- ac_config_status_args=
- test "$silent" = yes &&
- ac_config_status_args="$ac_config_status_args --quiet"
- exec 5>/dev/null
- $SHELL $CONFIG_STATUS $ac_config_status_args || ac_cs_success=false
- exec 5>>config.log
- # Use ||, not &&, to avoid exiting from the if with $? = 1, which
- # would make configure fail if this is the last instruction.
- $ac_cs_success || { (exit 1); exit 1; }
-fi
-
diff --git a/contrib/ofed/libibcm/configure.in b/contrib/ofed/libibcm/configure.in
deleted file mode 100644
index 2712969..0000000
--- a/contrib/ofed/libibcm/configure.in
+++ /dev/null
@@ -1,71 +0,0 @@
-dnl Process this file with autoconf to produce a configure script.
-
-AC_PREREQ(2.57)
-AC_INIT(libibcm, 1.0.5, general@lists@openfabrics.org)
-AC_CONFIG_SRCDIR([src/cm.c])
-AC_CONFIG_AUX_DIR(config)
-AM_CONFIG_HEADER(config.h)
-AM_INIT_AUTOMAKE(libibcm, 1.0.5)
-
-AM_PROG_LIBTOOL
-
-AC_ARG_WITH([valgrind],
- AC_HELP_STRING([--with-valgrind],
- [Enable valgrind annotations - default NO]))
-
-if test "$with_valgrind" != "" && test "$with_valgrind" != "no"; then
- AC_DEFINE([INCLUDE_VALGRIND], 1,
- [Define to 1 to enable valgrind annotations])
- if test -d $with_valgrind; then
- CPPFLAGS="$CPPLFAGS -I$with_valgrind/include"
- fi
-fi
-
-AC_ARG_ENABLE(libcheck, [ --disable-libcheck do not test for presence of ib libraries],
-[ if test "$enableval" = "no"; then
- disable_libcheck=yes
- fi
-])
-
-dnl Checks for programs
-AC_PROG_CC
-
-dnl Checks for typedefs, structures, and compiler characteristics.
-AC_C_CONST
-AC_CHECK_SIZEOF(long)
-
-dnl Checks for libraries
-if test "$disable_libcheck" != "yes"; then
-AC_CHECK_LIB(ibverbs, ibv_get_device_list, [],
- AC_MSG_ERROR([ibv_get_device_list() not found. libibcm requires libibverbs.]))
-#Need librdmacm for cmpost test program.
-#AC_CHECK_LIB(rdmacm, rdma_create_id, [],
-# AC_MSG_ERROR([rdma_create_id() not found. ucmpost requires librdmacm.]))
-fi
-
-dnl Checks for header files.
-AC_HEADER_STDC
-if test "$disable_libcheck" != "yes"; then
-AC_CHECK_HEADER(infiniband/verbs.h, [],
- AC_MSG_ERROR([<infiniband/verbs.h> not found. Is libibverbs installed?]))
-AC_CHECK_HEADER(infiniband/marshall.h, [],
- AC_MSG_ERROR([<infiniband/marshall.h> not found. Is libibverbs installed?]))
-
-if test "$with_valgrind" != "" && test "$with_valgrind" != "no"; then
-AC_CHECK_HEADER(valgrind/memcheck.h, [],
- AC_MSG_ERROR([valgrind requested but <valgrind/memcheck.h> not found.]))
-fi
-
-fi
-
-AC_CACHE_CHECK(whether ld accepts --version-script, ac_cv_version_script,
- if test -n "`$LD --help < /dev/null 2>/dev/null | grep version-script`"; then
- ac_cv_version_script=yes
- else
- ac_cv_version_script=no
- fi)
-
-AM_CONDITIONAL(HAVE_LD_VERSION_SCRIPT, test "$ac_cv_version_script" = "yes")
-
-AC_CONFIG_FILES([Makefile libibcm.spec])
-AC_OUTPUT
diff --git a/contrib/ofed/libibcm/include/infiniband/cm.h b/contrib/ofed/libibcm/include/infiniband/cm.h
deleted file mode 100644
index 7fd2e48..0000000
--- a/contrib/ofed/libibcm/include/infiniband/cm.h
+++ /dev/null
@@ -1,586 +0,0 @@
-/*
- * Copyright (c) 2004-2006 Intel Corporation. All rights reserved.
- * Copyright (c) 2004 Topspin Corporation. All rights reserved.
- * Copyright (c) 2004 Voltaire Corporation. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- * $Id$
- */
-#if !defined(CM_H)
-#define CM_H
-
-#include <infiniband/verbs.h>
-#include <infiniband/sa.h>
-#include <infiniband/byteorder.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-enum ib_cm_event_type {
- IB_CM_REQ_ERROR,
- IB_CM_REQ_RECEIVED,
- IB_CM_REP_ERROR,
- IB_CM_REP_RECEIVED,
- IB_CM_RTU_RECEIVED,
- IB_CM_USER_ESTABLISHED,
- IB_CM_DREQ_ERROR,
- IB_CM_DREQ_RECEIVED,
- IB_CM_DREP_RECEIVED,
- IB_CM_TIMEWAIT_EXIT,
- IB_CM_MRA_RECEIVED,
- IB_CM_REJ_RECEIVED,
- IB_CM_LAP_ERROR,
- IB_CM_LAP_RECEIVED,
- IB_CM_APR_RECEIVED,
- IB_CM_SIDR_REQ_ERROR,
- IB_CM_SIDR_REQ_RECEIVED,
- IB_CM_SIDR_REP_RECEIVED
-};
-
-enum ib_cm_data_size {
- IB_CM_REQ_PRIVATE_DATA_SIZE = 92,
- IB_CM_MRA_PRIVATE_DATA_SIZE = 222,
- IB_CM_REJ_PRIVATE_DATA_SIZE = 148,
- IB_CM_REP_PRIVATE_DATA_SIZE = 196,
- IB_CM_RTU_PRIVATE_DATA_SIZE = 224,
- IB_CM_DREQ_PRIVATE_DATA_SIZE = 220,
- IB_CM_DREP_PRIVATE_DATA_SIZE = 224,
- IB_CM_REJ_ARI_LENGTH = 72,
- IB_CM_LAP_PRIVATE_DATA_SIZE = 168,
- IB_CM_APR_PRIVATE_DATA_SIZE = 148,
- IB_CM_APR_INFO_LENGTH = 72,
- IB_CM_SIDR_REQ_PRIVATE_DATA_SIZE = 216,
- IB_CM_SIDR_REP_PRIVATE_DATA_SIZE = 136,
- IB_CM_SIDR_REP_INFO_LENGTH = 72
-};
-
-struct ib_cm_device {
- struct ibv_context *device_context;
- int fd;
-};
-
-struct ib_cm_id {
- void *context;
- struct ib_cm_device *device;
- uint32_t handle;
-};
-
-struct ib_cm_req_event_param {
- struct ib_cm_id *listen_id;
- uint8_t port;
-
- struct ibv_sa_path_rec *primary_path;
- struct ibv_sa_path_rec *alternate_path;
-
- uint64_t remote_ca_guid; /* netork-byte order */
- uint32_t remote_qkey;
- uint32_t remote_qpn;
- enum ibv_qp_type qp_type;
-
- uint32_t starting_psn;
- uint8_t responder_resources;
- uint8_t initiator_depth;
- unsigned int local_cm_response_timeout:5;
- unsigned int flow_control:1;
- unsigned int remote_cm_response_timeout:5;
- unsigned int retry_count:3;
- unsigned int rnr_retry_count:3;
- unsigned int srq:1;
-};
-
-struct ib_cm_rep_event_param {
- uint64_t remote_ca_guid; /* network-byte order */
- uint32_t remote_qkey;
- uint32_t remote_qpn;
- uint32_t starting_psn;
- uint8_t responder_resources;
- uint8_t initiator_depth;
- unsigned int target_ack_delay:5;
- unsigned int failover_accepted:2;
- unsigned int flow_control:1;
- unsigned int rnr_retry_count:3;
- unsigned int srq:1;
-};
-
-enum ib_cm_rej_reason {
- IB_CM_REJ_NO_QP = 1,
- IB_CM_REJ_NO_EEC = 2,
- IB_CM_REJ_NO_RESOURCES = 3,
- IB_CM_REJ_TIMEOUT = 4,
- IB_CM_REJ_UNSUPPORTED = 5,
- IB_CM_REJ_INVALID_COMM_ID = 6,
- IB_CM_REJ_INVALID_COMM_INSTANCE = 7,
- IB_CM_REJ_INVALID_SERVICE_ID = 8,
- IB_CM_REJ_INVALID_TRANSPORT_TYPE = 9,
- IB_CM_REJ_STALE_CONN = 10,
- IB_CM_REJ_RDC_NOT_EXIST = 11,
- IB_CM_REJ_INVALID_GID = 12,
- IB_CM_REJ_INVALID_LID = 13,
- IB_CM_REJ_INVALID_SL = 14,
- IB_CM_REJ_INVALID_TRAFFIC_CLASS = 15,
- IB_CM_REJ_INVALID_HOP_LIMIT = 16,
- IB_CM_REJ_INVALID_PACKET_RATE = 17,
- IB_CM_REJ_INVALID_ALT_GID = 18,
- IB_CM_REJ_INVALID_ALT_LID = 19,
- IB_CM_REJ_INVALID_ALT_SL = 20,
- IB_CM_REJ_INVALID_ALT_TRAFFIC_CLASS = 21,
- IB_CM_REJ_INVALID_ALT_HOP_LIMIT = 22,
- IB_CM_REJ_INVALID_ALT_PACKET_RATE = 23,
- IB_CM_REJ_PORT_CM_REDIRECT = 24,
- IB_CM_REJ_PORT_REDIRECT = 25,
- IB_CM_REJ_INVALID_MTU = 26,
- IB_CM_REJ_INSUFFICIENT_RESP_RESOURCES = 27,
- IB_CM_REJ_CONSUMER_DEFINED = 28,
- IB_CM_REJ_INVALID_RNR_RETRY = 29,
- IB_CM_REJ_DUPLICATE_LOCAL_COMM_ID = 30,
- IB_CM_REJ_INVALID_CLASS_VERSION = 31,
- IB_CM_REJ_INVALID_FLOW_LABEL = 32,
- IB_CM_REJ_INVALID_ALT_FLOW_LABEL = 33
-};
-
-struct ib_cm_rej_event_param {
- enum ib_cm_rej_reason reason;
- void *ari;
- uint8_t ari_length;
-};
-
-struct ib_cm_mra_event_param {
- uint8_t service_timeout;
-};
-
-struct ib_cm_lap_event_param {
- struct ibv_sa_path_rec *alternate_path;
-};
-
-enum ib_cm_apr_status {
- IB_CM_APR_SUCCESS,
- IB_CM_APR_INVALID_COMM_ID,
- IB_CM_APR_UNSUPPORTED,
- IB_CM_APR_REJECT,
- IB_CM_APR_REDIRECT,
- IB_CM_APR_IS_CURRENT,
- IB_CM_APR_INVALID_QPN_EECN,
- IB_CM_APR_INVALID_LID,
- IB_CM_APR_INVALID_GID,
- IB_CM_APR_INVALID_FLOW_LABEL,
- IB_CM_APR_INVALID_TCLASS,
- IB_CM_APR_INVALID_HOP_LIMIT,
- IB_CM_APR_INVALID_PACKET_RATE,
- IB_CM_APR_INVALID_SL
-};
-
-struct ib_cm_apr_event_param {
- enum ib_cm_apr_status ap_status;
- void *apr_info;
- uint8_t info_len;
-};
-
-struct ib_cm_sidr_req_event_param {
- struct ib_cm_id *listen_id;
- uint8_t port;
- uint16_t pkey;
-};
-
-enum ib_cm_sidr_status {
- IB_SIDR_SUCCESS,
- IB_SIDR_UNSUPPORTED,
- IB_SIDR_REJECT,
- IB_SIDR_NO_QP,
- IB_SIDR_REDIRECT,
- IB_SIDR_UNSUPPORTED_VERSION
-};
-
-struct ib_cm_sidr_rep_event_param {
- enum ib_cm_sidr_status status;
- uint32_t qkey;
- uint32_t qpn;
- void *info;
- uint8_t info_len;
-};
-
-struct ib_cm_event {
- struct ib_cm_id *cm_id;
- enum ib_cm_event_type event;
- union {
- struct ib_cm_req_event_param req_rcvd;
- struct ib_cm_rep_event_param rep_rcvd;
- /* No data for RTU received events. */
- struct ib_cm_rej_event_param rej_rcvd;
- struct ib_cm_mra_event_param mra_rcvd;
- struct ib_cm_lap_event_param lap_rcvd;
- struct ib_cm_apr_event_param apr_rcvd;
- /* No data for DREQ/DREP received events. */
- struct ib_cm_sidr_req_event_param sidr_req_rcvd;
- struct ib_cm_sidr_rep_event_param sidr_rep_rcvd;
- enum ibv_wc_status send_status;
- } param;
-
- void *private_data;
-};
-
-/**
- * ib_cm_get_event - Retrieves the next pending communications event,
- * if no event is pending waits for an event.
- * @device: CM device to retrieve the event.
- * @event: Allocated information about the next communication event.
- * Event should be freed using ib_cm_ack_event()
- *
- * IB_CM_REQ_RECEIVED and IB_CM_SIDR_REQ_RECEIVED communication events
- * generated as a result of listen requests result in the allocation of a
- * new @cm_id.
- * Clients are responsible for destroying the new @cm_id. For peer-to-peer
- * IB_CM_REQ_RECEIVED and all other events, the returned @cm_id corresponds
- * to a user's existing communication identifier.
- */
-int ib_cm_get_event(struct ib_cm_device *device, struct ib_cm_event **event);
-
-/**
- * ib_cm_ack_event - Free a communications event.
- * @event: Event to be released.
- *
- * All events which are allocated by ib_cm_get_event() must be released,
- * there should be a one-to-one correspondence between successful gets
- * and puts.
- */
-int ib_cm_ack_event(struct ib_cm_event *event);
-
-/**
- * ib_cm_open_device - Returns the device the CM uses to submit requests
- * and retrieve events, corresponding to the specified verbs device.
- *
- * The CM device contains the file descriptor that the CM uses to
- * communicate with the kernel CM component. The primary use of the
- * file descriptor is to test for CM readiness events. When the CM
- * becomes ready to READ there is a pending event ready, and a subsequent
- * call to ib_cm_get_event will not block.
- * Note: The user should not read or write directly to the CM file
- * descriptor, it will likely result in an error or unexpected
- * results.
- */
-struct ib_cm_device* ib_cm_open_device(struct ibv_context *device_context);
-
-/**
- * ib_cm_close_device - Close a CM device.
- * @device: Device to close.
- */
-void ib_cm_close_device(struct ib_cm_device *device);
-
-/**
- * ib_cm_create_id - Allocate a communication identifier.
- *
- * Communication identifiers are used to track connection states, service
- * ID resolution requests, and listen requests.
- */
-int ib_cm_create_id(struct ib_cm_device *device,
- struct ib_cm_id **cm_id, void *context);
-
-/**
- * ib_cm_destroy_id - Destroy a connection identifier.
- * @cm_id: Connection identifier to destroy.
- */
-int ib_cm_destroy_id(struct ib_cm_id *cm_id);
-
-struct ib_cm_attr_param {
- uint64_t service_id; /* network-byte order */
- uint64_t service_mask; /* network-byte order */
- uint32_t local_id;
- uint32_t remote_id;
-};
-
-/**
- * ib_cm_attr_id - Get connection identifier attributes.
- * @cm_id: Connection identifier to retrieve attributes.
- * @param: Destination of retreived parameters.
- *
- * Not all parameters are valid during all connection states.
- */
-int ib_cm_attr_id(struct ib_cm_id *cm_id,
- struct ib_cm_attr_param *param);
-
-#define IB_CM_ASSIGN_SERVICE_ID_MASK __constant_cpu_to_be64(0xFF00000000000000ULL)
-#define IB_CM_ASSIGN_SERVICE_ID __constant_cpu_to_be64(0x0200000000000000ULL)
-
-/**
- * ib_cm_listen - Initiates listening on the specified service ID for
- * connection and service ID resolution requests.
- * @cm_id: Connection identifier associated with the listen request.
- * @service_id: Service identifier matched against incoming connection
- * and service ID resolution requests. The service ID should be specified
- * network-byte order.
- * @service_mask: Mask applied to service ID used to listen across a
- * range of service IDs. If set to 0, the service ID is matched
- * exactly.
- */
-int ib_cm_listen(struct ib_cm_id *cm_id,
- uint64_t service_id,
- uint64_t service_mask);
-
-struct ib_cm_req_param {
- struct ibv_sa_path_rec *primary_path;
- struct ibv_sa_path_rec *alternate_path;
- uint64_t service_id; /* network-byte order */
- uint32_t qp_num;
- enum ibv_qp_type qp_type;
- uint32_t starting_psn;
- void *private_data;
- uint8_t private_data_len;
- uint8_t peer_to_peer;
- uint8_t responder_resources;
- uint8_t initiator_depth;
- uint8_t remote_cm_response_timeout;
- uint8_t flow_control;
- uint8_t local_cm_response_timeout;
- uint8_t retry_count;
- uint8_t rnr_retry_count;
- uint8_t max_cm_retries;
- uint8_t srq;
-};
-
-/**
- * ib_cm_send_req - Sends a connection request to the remote node.
- * @cm_id: Connection identifier that will be associated with the
- * connection request.
- * @param: Connection request information needed to establish the
- * connection.
- */
-int ib_cm_send_req(struct ib_cm_id *cm_id,
- struct ib_cm_req_param *param);
-
-struct ib_cm_rep_param {
- uint32_t qp_num;
- uint32_t starting_psn;
- void *private_data;
- uint8_t private_data_len;
- uint8_t responder_resources;
- uint8_t initiator_depth;
- uint8_t target_ack_delay;
- uint8_t failover_accepted;
- uint8_t flow_control;
- uint8_t rnr_retry_count;
- uint8_t srq;
-};
-
-/**
- * ib_cm_send_rep - Sends a connection reply in response to a connection
- * request.
- * @cm_id: Connection identifier that will be associated with the
- * connection request.
- * @param: Connection reply information needed to establish the
- * connection.
- */
-int ib_cm_send_rep(struct ib_cm_id *cm_id,
- struct ib_cm_rep_param *param);
-
-/**
- * ib_cm_send_rtu - Sends a connection ready to use message in response
- * to a connection reply message.
- * @cm_id: Connection identifier associated with the connection request.
- * @private_data: Optional user-defined private data sent with the
- * ready to use message.
- * @private_data_len: Size of the private data buffer, in bytes.
- */
-int ib_cm_send_rtu(struct ib_cm_id *cm_id,
- void *private_data,
- uint8_t private_data_len);
-
-/**
- * ib_cm_send_dreq - Sends a disconnection request for an existing
- * connection.
- * @cm_id: Connection identifier associated with the connection being
- * released.
- * @private_data: Optional user-defined private data sent with the
- * disconnection request message.
- * @private_data_len: Size of the private data buffer, in bytes.
- */
-int ib_cm_send_dreq(struct ib_cm_id *cm_id,
- void *private_data,
- uint8_t private_data_len);
-
-/**
- * ib_cm_send_drep - Sends a disconnection reply to a disconnection request.
- * @cm_id: Connection identifier associated with the connection being
- * released.
- * @private_data: Optional user-defined private data sent with the
- * disconnection reply message.
- * @private_data_len: Size of the private data buffer, in bytes.
- */
-int ib_cm_send_drep(struct ib_cm_id *cm_id,
- void *private_data,
- uint8_t private_data_len);
-
-/**
- * ib_cm_notify - Notifies the CM of an event reported to the consumer.
- * @cm_id: Connection identifier to transition to established.
- * @event: Type of event.
- *
- * This routine should be invoked by users to notify the CM of relevant
- * communication events. Events that should be reported to the CM and
- * when to report them are:
- *
- * IBV_EVENT_COMM_EST - Used when a message is received on a connected
- * QP before an RTU has been received.
- * IBV_EVENT_PATH_MIG - Notifies the CM that the connection has failed over
- * to the alternate path.
- */
-int ib_cm_notify(struct ib_cm_id *cm_id, enum ibv_event_type event);
-
-/**
- * ib_cm_send_rej - Sends a connection rejection message to the
- * remote node.
- * @cm_id: Connection identifier associated with the connection being
- * rejected.
- * @reason: Reason for the connection request rejection.
- * @ari: Optional additional rejection information.
- * @ari_length: Size of the additional rejection information, in bytes.
- * @private_data: Optional user-defined private data sent with the
- * rejection message.
- * @private_data_len: Size of the private data buffer, in bytes.
- */
-int ib_cm_send_rej(struct ib_cm_id *cm_id,
- enum ib_cm_rej_reason reason,
- void *ari,
- uint8_t ari_length,
- void *private_data,
- uint8_t private_data_len);
-
-/**
- * ib_cm_send_mra - Sends a message receipt acknowledgement to a connection
- * message.
- * @cm_id: Connection identifier associated with the connection message.
- * @service_timeout: The maximum time required for the sender to reply to
- * to the connection message.
- * @private_data: Optional user-defined private data sent with the
- * message receipt acknowledgement.
- * @private_data_len: Size of the private data buffer, in bytes.
- */
-int ib_cm_send_mra(struct ib_cm_id *cm_id,
- uint8_t service_timeout,
- void *private_data,
- uint8_t private_data_len);
-
-/**
- * ib_cm_send_lap - Sends a load alternate path request.
- * @cm_id: Connection identifier associated with the load alternate path
- * message.
- * @alternate_path: A path record that identifies the alternate path to
- * load.
- * @private_data: Optional user-defined private data sent with the
- * load alternate path message.
- * @private_data_len: Size of the private data buffer, in bytes.
- */
-int ib_cm_send_lap(struct ib_cm_id *cm_id,
- struct ibv_sa_path_rec *alternate_path,
- void *private_data,
- uint8_t private_data_len);
-
-/**
- * ib_cm_init_qp_attr - Initializes the QP attributes for use in transitioning
- * to a specified QP state.
- * @cm_id: Communication identifier associated with the QP attributes to
- * initialize.
- * @qp_attr: On input, specifies the desired QP state. On output, the
- * mandatory and desired optional attributes will be set in order to
- * modify the QP to the specified state.
- * @qp_attr_mask: The QP attribute mask that may be used to transition the
- * QP to the specified state.
- *
- * Users must set the @qp_attr->qp_state to the desired QP state. This call
- * will set all required attributes for the given transition, along with
- * known optional attributes. Users may override the attributes returned from
- * this call before calling ib_modify_qp.
- */
-int ib_cm_init_qp_attr(struct ib_cm_id *cm_id,
- struct ibv_qp_attr *qp_attr,
- int *qp_attr_mask);
-
-/**
- * ib_cm_send_apr - Sends an alternate path response message in response to
- * a load alternate path request.
- * @cm_id: Connection identifier associated with the alternate path response.
- * @status: Reply status sent with the alternate path response.
- * @info: Optional additional information sent with the alternate path
- * response.
- * @info_length: Size of the additional information, in bytes.
- * @private_data: Optional user-defined private data sent with the
- * alternate path response message.
- * @private_data_len: Size of the private data buffer, in bytes.
- */
-int ib_cm_send_apr(struct ib_cm_id *cm_id,
- enum ib_cm_apr_status status,
- void *info,
- uint8_t info_length,
- void *private_data,
- uint8_t private_data_len);
-
-struct ib_cm_sidr_req_param {
- struct ibv_sa_path_rec *path;
- uint64_t service_id; /* network-byte order */
- int timeout_ms;
- void *private_data;
- uint8_t private_data_len;
- uint8_t max_cm_retries;
-};
-
-/**
- * ib_cm_send_sidr_req - Sends a service ID resolution request to the
- * remote node.
- * @cm_id: Communication identifier that will be associated with the
- * service ID resolution request.
- * @param: Service ID resolution request information.
- */
-int ib_cm_send_sidr_req(struct ib_cm_id *cm_id,
- struct ib_cm_sidr_req_param *param);
-
-struct ib_cm_sidr_rep_param {
- uint32_t qp_num;
- uint32_t qkey;
- enum ib_cm_sidr_status status;
- void *info;
- uint8_t info_length;
- void *private_data;
- uint8_t private_data_len;
-};
-
-/**
- * ib_cm_send_sidr_rep - Sends a service ID resolution reply to the
- * remote node.
- * @cm_id: Communication identifier associated with the received service ID
- * resolution request.
- * @param: Service ID resolution reply information.
- */
-int ib_cm_send_sidr_rep(struct ib_cm_id *cm_id,
- struct ib_cm_sidr_rep_param *param);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* CM_H */
diff --git a/contrib/ofed/libibcm/include/infiniband/cm_abi.h b/contrib/ofed/libibcm/include/infiniband/cm_abi.h
deleted file mode 100644
index d998b69..0000000
--- a/contrib/ofed/libibcm/include/infiniband/cm_abi.h
+++ /dev/null
@@ -1,338 +0,0 @@
-/*
- * Copyright (c) 2005 Topspin Communications. All rights reserved.
- * Copyright (c) 2005 Intel Corporation. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- * $Id$
- */
-
-#ifndef CM_ABI_H
-#define CM_ABI_H
-
-#include <infiniband/types.h>
-#include <infiniband/sa.h>
-#include <infiniband/marshall.h>
-
-/*
- * This file must be kept in sync with the kernel's version of ib_user_cm.h
- */
-
-#define IB_USER_CM_MIN_ABI_VERSION 4
-#define IB_USER_CM_MAX_ABI_VERSION 5
-
-enum {
- IB_USER_CM_CMD_CREATE_ID,
- IB_USER_CM_CMD_DESTROY_ID,
- IB_USER_CM_CMD_ATTR_ID,
-
- IB_USER_CM_CMD_LISTEN,
- IB_USER_CM_CMD_NOTIFY,
- IB_USER_CM_CMD_ESTABLISH = IB_USER_CM_CMD_NOTIFY, /* ABI 4 support */
-
- IB_USER_CM_CMD_SEND_REQ,
- IB_USER_CM_CMD_SEND_REP,
- IB_USER_CM_CMD_SEND_RTU,
- IB_USER_CM_CMD_SEND_DREQ,
- IB_USER_CM_CMD_SEND_DREP,
- IB_USER_CM_CMD_SEND_REJ,
- IB_USER_CM_CMD_SEND_MRA,
- IB_USER_CM_CMD_SEND_LAP,
- IB_USER_CM_CMD_SEND_APR,
- IB_USER_CM_CMD_SEND_SIDR_REQ,
- IB_USER_CM_CMD_SEND_SIDR_REP,
-
- IB_USER_CM_CMD_EVENT,
- IB_USER_CM_CMD_INIT_QP_ATTR,
-};
-/*
- * command ABI structures.
- */
-struct cm_abi_cmd_hdr {
- __u32 cmd;
- __u16 in;
- __u16 out;
-};
-
-struct cm_abi_create_id {
- __u64 uid;
- __u64 response;
-};
-
-struct cm_abi_create_id_resp {
- __u32 id;
-};
-
-struct cm_abi_destroy_id {
- __u64 response;
- __u32 id;
- __u32 reserved;
-};
-
-struct cm_abi_destroy_id_resp {
- __u32 events_reported;
-};
-
-struct cm_abi_attr_id {
- __u64 response;
- __u32 id;
- __u32 reserved;
-};
-
-struct cm_abi_attr_id_resp {
- __u64 service_id;
- __u64 service_mask;
- __u32 local_id;
- __u32 remote_id;
-};
-
-struct cm_abi_init_qp_attr {
- __u64 response;
- __u32 id;
- __u32 qp_state;
-};
-
-struct cm_abi_listen {
- __u64 service_id;
- __u64 service_mask;
- __u32 id;
- __u32 reserved;
-};
-
-struct cm_abi_establish { /* ABI 4 support */
- __u32 id;
-};
-
-struct cm_abi_notify {
- __u32 id;
- __u32 event;
-};
-
-struct cm_abi_private_data {
- __u64 data;
- __u32 id;
- __u8 len;
- __u8 reserved[3];
-};
-
-struct cm_abi_req {
- __u32 id;
- __u32 qpn;
- __u32 qp_type;
- __u32 psn;
- __u64 sid;
- __u64 data;
- __u64 primary_path;
- __u64 alternate_path;
- __u8 len;
- __u8 peer_to_peer;
- __u8 responder_resources;
- __u8 initiator_depth;
- __u8 remote_cm_response_timeout;
- __u8 flow_control;
- __u8 local_cm_response_timeout;
- __u8 retry_count;
- __u8 rnr_retry_count;
- __u8 max_cm_retries;
- __u8 srq;
- __u8 reserved[5];
-};
-
-struct cm_abi_rep {
- __u64 uid;
- __u64 data;
- __u32 id;
- __u32 qpn;
- __u32 psn;
- __u8 len;
- __u8 responder_resources;
- __u8 initiator_depth;
- __u8 target_ack_delay;
- __u8 failover_accepted;
- __u8 flow_control;
- __u8 rnr_retry_count;
- __u8 srq;
- __u8 reserved[4];
-};
-
-struct cm_abi_info {
- __u32 id;
- __u32 status;
- __u64 info;
- __u64 data;
- __u8 info_len;
- __u8 data_len;
- __u8 reserved[6];
-};
-
-struct cm_abi_mra {
- __u64 data;
- __u32 id;
- __u8 len;
- __u8 timeout;
- __u8 reserved[2];
-};
-
-struct cm_abi_lap {
- __u64 path;
- __u64 data;
- __u32 id;
- __u8 len;
- __u8 reserved[3];
-};
-
-struct cm_abi_sidr_req {
- __u32 id;
- __u32 timeout;
- __u64 sid;
- __u64 data;
- __u64 path;
- __u16 pkey;
- __u8 len;
- __u8 max_cm_retries;
- __u8 reserved[4];
-};
-
-struct cm_abi_sidr_rep {
- __u32 id;
- __u32 qpn;
- __u32 qkey;
- __u32 status;
- __u64 info;
- __u64 data;
- __u8 info_len;
- __u8 data_len;
- __u8 reserved[6];
-};
-/*
- * event notification ABI structures.
- */
-struct cm_abi_event_get {
- __u64 response;
- __u64 data;
- __u64 info;
- __u8 data_len;
- __u8 info_len;
- __u8 reserved[6];
-};
-
-struct cm_abi_req_event_resp {
- struct ibv_kern_path_rec primary_path;
- struct ibv_kern_path_rec alternate_path;
- __u64 remote_ca_guid;
- __u32 remote_qkey;
- __u32 remote_qpn;
- __u32 qp_type;
- __u32 starting_psn;
- __u8 responder_resources;
- __u8 initiator_depth;
- __u8 local_cm_response_timeout;
- __u8 flow_control;
- __u8 remote_cm_response_timeout;
- __u8 retry_count;
- __u8 rnr_retry_count;
- __u8 srq;
- __u8 port;
- __u8 reserved[7];
-};
-
-struct cm_abi_rep_event_resp {
- __u64 remote_ca_guid;
- __u32 remote_qkey;
- __u32 remote_qpn;
- __u32 starting_psn;
- __u8 responder_resources;
- __u8 initiator_depth;
- __u8 target_ack_delay;
- __u8 failover_accepted;
- __u8 flow_control;
- __u8 rnr_retry_count;
- __u8 srq;
- __u8 reserved[5];
-};
-
-struct cm_abi_rej_event_resp {
- __u32 reason;
- /* ari in cm_abi_event_get info field. */
-};
-
-struct cm_abi_mra_event_resp {
- __u8 timeout;
- __u8 reserved[3];
-};
-
-struct cm_abi_lap_event_resp {
- struct ibv_kern_path_rec path;
-};
-
-struct cm_abi_apr_event_resp {
- __u32 status;
- /* apr info in cm_abi_event_get info field. */
-};
-
-struct cm_abi_sidr_req_event_resp {
- __u16 pkey;
- __u8 port;
- __u8 reserved;
-};
-
-struct cm_abi_sidr_rep_event_resp {
- __u32 status;
- __u32 qkey;
- __u32 qpn;
- /* info in cm_abi_event_get info field. */
-};
-
-#define CM_ABI_PRES_DATA 0x01
-#define CM_ABI_PRES_INFO 0x02
-#define CM_ABI_PRES_PRIMARY 0x04
-#define CM_ABI_PRES_ALTERNATE 0x08
-
-struct cm_abi_event_resp {
- __u64 uid;
- __u32 id;
- __u32 event;
- __u32 present;
- __u32 reserved;
- union {
- struct cm_abi_req_event_resp req_resp;
- struct cm_abi_rep_event_resp rep_resp;
- struct cm_abi_rej_event_resp rej_resp;
- struct cm_abi_mra_event_resp mra_resp;
- struct cm_abi_lap_event_resp lap_resp;
- struct cm_abi_apr_event_resp apr_resp;
-
- struct cm_abi_sidr_req_event_resp sidr_req_resp;
- struct cm_abi_sidr_rep_event_resp sidr_rep_resp;
-
- __u32 send_status;
- } u;
-};
-
-#endif /* CM_ABI_H */
diff --git a/contrib/ofed/libibcm/libibcm.map b/contrib/ofed/libibcm/libibcm.map
new file mode 100644
index 0000000..c94e420
--- /dev/null
+++ b/contrib/ofed/libibcm/libibcm.map
@@ -0,0 +1,26 @@
+/* Do not change this file without reading Documentation/versioning.md */
+IBCM_1.0 {
+ global:
+ ib_cm_open_device;
+ ib_cm_close_device;
+ ib_cm_get_event;
+ ib_cm_ack_event;
+ ib_cm_create_id;
+ ib_cm_destroy_id;
+ ib_cm_attr_id;
+ ib_cm_listen;
+ ib_cm_send_req;
+ ib_cm_send_rep;
+ ib_cm_send_rtu;
+ ib_cm_send_dreq;
+ ib_cm_send_drep;
+ ib_cm_notify;
+ ib_cm_send_rej;
+ ib_cm_send_mra;
+ ib_cm_send_lap;
+ ib_cm_send_apr;
+ ib_cm_send_sidr_req;
+ ib_cm_send_sidr_rep;
+ ib_cm_init_qp_attr;
+ local: *;
+};
diff --git a/contrib/ofed/libibcm/libibcm.spec b/contrib/ofed/libibcm/libibcm.spec
deleted file mode 100644
index 6d893eb..0000000
--- a/contrib/ofed/libibcm/libibcm.spec
+++ /dev/null
@@ -1,53 +0,0 @@
-%define ver 1.0.5
-
-Name: libibcm
-Version: 1.0.5
-Release: 1%{?dist}
-Summary: Userspace InfiniBand Communication Manager.
-
-Group: System Environment/Libraries
-License: GPL/BSD
-Url: http://www.openfabrics.org/
-Source: http://www.openfabrics.org/downloads/%{name}-%{version}.tar.gz
-BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
-
-%description
-libibcm provides a userspace InfiniBand Communication Managment library.
-
-%package devel
-Summary: Development files for the libibcm library
-Group: System Environment/Libraries
-Requires: %{name} = %{version}-%{release} %{_includedir}/infiniband/verbs.h
-
-%description devel
-Development files for the libibcm library.
-
-%prep
-%setup -q -n %{name}-%{ver}
-
-%build
-%configure
-make %{?_smp_mflags}
-
-%install
-rm -rf $RPM_BUILD_ROOT
-%makeinstall
-# remove unpackaged files from the buildroot
-rm -f $RPM_BUILD_ROOT%{_libdir}/*.la
-
-%clean
-rm -rf $RPM_BUILD_ROOT
-
-%post -p /sbin/ldconfig
-%postun -p /sbin/ldconfig
-
-%files
-%defattr(-,root,root,-)
-%{_libdir}/libibcm*.so.*
-%doc AUTHORS COPYING ChangeLog README
-
-%files devel
-%defattr(-,root,root,-)
-%{_libdir}/lib*.so
-%{_libdir}/*.a
-%{_includedir}/*
diff --git a/contrib/ofed/libibcm/libibcm.spec.in b/contrib/ofed/libibcm/libibcm.spec.in
deleted file mode 100644
index ce08272..0000000
--- a/contrib/ofed/libibcm/libibcm.spec.in
+++ /dev/null
@@ -1,53 +0,0 @@
-%define ver @VERSION@
-
-Name: libibcm
-Version: 1.0.5
-Release: 1%{?dist}
-Summary: Userspace InfiniBand Communication Manager.
-
-Group: System Environment/Libraries
-License: GPL/BSD
-Url: http://www.openfabrics.org/
-Source: http://www.openfabrics.org/downloads/%{name}-%{version}.tar.gz
-BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
-
-%description
-libibcm provides a userspace InfiniBand Communication Managment library.
-
-%package devel
-Summary: Development files for the libibcm library
-Group: System Environment/Libraries
-Requires: %{name} = %{version}-%{release} %{_includedir}/infiniband/verbs.h
-
-%description devel
-Development files for the libibcm library.
-
-%prep
-%setup -q -n %{name}-%{ver}
-
-%build
-%configure
-make %{?_smp_mflags}
-
-%install
-rm -rf $RPM_BUILD_ROOT
-%makeinstall
-# remove unpackaged files from the buildroot
-rm -f $RPM_BUILD_ROOT%{_libdir}/*.la
-
-%clean
-rm -rf $RPM_BUILD_ROOT
-
-%post -p /sbin/ldconfig
-%postun -p /sbin/ldconfig
-
-%files
-%defattr(-,root,root,-)
-%{_libdir}/libibcm*.so.*
-%doc AUTHORS COPYING ChangeLog README
-
-%files devel
-%defattr(-,root,root,-)
-%{_libdir}/lib*.so
-%{_libdir}/*.a
-%{_includedir}/*
diff --git a/contrib/ofed/libibcm/src/cm.c b/contrib/ofed/libibcm/src/cm.c
deleted file mode 100644
index 1de3d8d..0000000
--- a/contrib/ofed/libibcm/src/cm.c
+++ /dev/null
@@ -1,1047 +0,0 @@
-/*
- * Copyright (c) 2005 Topspin Communications. All rights reserved.
- * Copyright (c) 2005-2006 Intel Corporation. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- * $Id$
- */
-
-#if HAVE_CONFIG_H
-# include <config.h>
-#endif /* HAVE_CONFIG_H */
-
-#include <stdlib.h>
-#include <string.h>
-#include <stdio.h>
-#include <fcntl.h>
-#include <errno.h>
-#include <unistd.h>
-#include <pthread.h>
-#include <stddef.h>
-
-#include <infiniband/cm.h>
-#include <infiniband/cm_abi.h>
-#include <infiniband/driver.h>
-#include <infiniband/marshall.h>
-
-#ifdef INCLUDE_VALGRIND
-# include <valgrind/memcheck.h>
-# ifndef VALGRIND_MAKE_MEM_DEFINED
-# warning "Valgrind requested, but VALGRIND_MAKE_MEM_DEFINED undefined"
-# endif
-#endif
-
-#ifndef VALGRIND_MAKE_MEM_DEFINED
-# define VALGRIND_MAKE_MEM_DEFINED(addr,len)
-#endif
-
-#define PFX "libibcm: "
-
-static int abi_ver;
-static pthread_mutex_t mut = PTHREAD_MUTEX_INITIALIZER;
-
-enum {
- IB_UCM_MAX_DEVICES = 32
-};
-
-static inline int ERR(int err)
-{
- errno = err;
- return -1;
-}
-
-
-#define CM_CREATE_MSG_CMD_RESP(msg, cmd, resp, type, size) \
-do { \
- struct cm_abi_cmd_hdr *hdr; \
- \
- size = sizeof(*hdr) + sizeof(*cmd); \
- msg = alloca(size); \
- if (!msg) \
- return ERR(ENOMEM); \
- hdr = msg; \
- cmd = msg + sizeof(*hdr); \
- hdr->cmd = type; \
- hdr->in = sizeof(*cmd); \
- hdr->out = sizeof(*resp); \
- memset(cmd, 0, sizeof(*cmd)); \
- resp = alloca(sizeof(*resp)); \
- if (!resp) \
- return ERR(ENOMEM); \
- cmd->response = (uintptr_t)resp;\
-} while (0)
-
-#define CM_CREATE_MSG_CMD(msg, cmd, type, size) \
-do { \
- struct cm_abi_cmd_hdr *hdr; \
- \
- size = sizeof(*hdr) + sizeof(*cmd); \
- msg = alloca(size); \
- if (!msg) \
- return ERR(ENOMEM); \
- hdr = msg; \
- cmd = msg + sizeof(*hdr); \
- hdr->cmd = type; \
- hdr->in = sizeof(*cmd); \
- hdr->out = 0; \
- memset(cmd, 0, sizeof(*cmd)); \
-} while (0)
-
-struct cm_id_private {
- struct ib_cm_id id;
- int events_completed;
- pthread_cond_t cond;
- pthread_mutex_t mut;
-};
-
-#define container_of(ptr, type, field) \
- ((type *) ((void *)ptr - offsetof(type, field)))
-
-static int check_abi_version(void)
-{
- char value[8];
-
- if (ibv_read_sysfs_file(ibv_get_sysfs_path(),
- "class/infiniband_cm/abi_version",
- value, sizeof value) < 0) {
- fprintf(stderr, PFX "couldn't read ABI version\n");
- return 0;
- }
-
- abi_ver = strtol(value, NULL, 10);
- if (abi_ver < IB_USER_CM_MIN_ABI_VERSION ||
- abi_ver > IB_USER_CM_MAX_ABI_VERSION) {
- fprintf(stderr, PFX "kernel ABI version %d "
- "doesn't match library version %d.\n",
- abi_ver, IB_USER_CM_MAX_ABI_VERSION);
- return -1;
- }
- return 0;
-}
-
-static int ucm_init(void)
-{
- int ret = 0;
-
- pthread_mutex_lock(&mut);
- if (!abi_ver)
- ret = check_abi_version();
- pthread_mutex_unlock(&mut);
-
- return ret;
-}
-
-static int ucm_get_dev_index(char *dev_name)
-{
- char *dev_path;
- char ibdev[IBV_SYSFS_NAME_MAX];
- int i, ret;
-
- for (i = 0; i < IB_UCM_MAX_DEVICES; i++) {
- ret = asprintf(&dev_path, "/sys/class/infiniband_cm/ucm%d", i);
- if (ret < 0)
- return -1;
-
- ret = ibv_read_sysfs_file(dev_path, "ibdev", ibdev, sizeof ibdev);
- if (ret < 0)
- continue;
-
- if (!strcmp(dev_name, ibdev)) {
- free(dev_path);
- return i;
- }
-
- free(dev_path);
- }
- return -1;
-}
-
-struct ib_cm_device* ib_cm_open_device(struct ibv_context *device_context)
-{
- struct ib_cm_device *dev;
- char *dev_path;
- int index, ret;
-
- if (ucm_init())
- return NULL;
-
- index = ucm_get_dev_index(device_context->device->name);
- if (index < 0)
- return NULL;
-
- dev = malloc(sizeof *dev);
- if (!dev)
- return NULL;
-
- dev->device_context = device_context;
-
- ret = asprintf(&dev_path, "/dev/infiniband/ucm%d", index);
- if (ret < 0)
- goto err1;
-
- dev->fd = open(dev_path, O_RDWR);
- if (dev->fd < 0)
- goto err2;
-
- free(dev_path);
- return dev;
-
-err2:
- free(dev_path);
-err1:
- free(dev);
- return NULL;
-}
-
-void ib_cm_close_device(struct ib_cm_device *device)
-{
- close(device->fd);
- free(device);
-}
-
-static void ib_cm_free_id(struct cm_id_private *cm_id_priv)
-{
- pthread_cond_destroy(&cm_id_priv->cond);
- pthread_mutex_destroy(&cm_id_priv->mut);
- free(cm_id_priv);
-}
-
-static struct cm_id_private *ib_cm_alloc_id(struct ib_cm_device *device,
- void *context)
-{
- struct cm_id_private *cm_id_priv;
-
- cm_id_priv = malloc(sizeof *cm_id_priv);
- if (!cm_id_priv)
- return NULL;
-
- memset(cm_id_priv, 0, sizeof *cm_id_priv);
- cm_id_priv->id.device = device;
- cm_id_priv->id.context = context;
- pthread_mutex_init(&cm_id_priv->mut, NULL);
- if (pthread_cond_init(&cm_id_priv->cond, NULL))
- goto err;
-
- return cm_id_priv;
-
-err: ib_cm_free_id(cm_id_priv);
- return NULL;
-}
-
-int ib_cm_create_id(struct ib_cm_device *device,
- struct ib_cm_id **cm_id, void *context)
-{
- struct cm_abi_create_id_resp *resp;
- struct cm_abi_create_id *cmd;
- struct cm_id_private *cm_id_priv;
- void *msg;
- int result;
- int size;
-
- cm_id_priv = ib_cm_alloc_id(device, context);
- if (!cm_id_priv)
- return ERR(ENOMEM);
-
- CM_CREATE_MSG_CMD_RESP(msg, cmd, resp, IB_USER_CM_CMD_CREATE_ID, size);
- cmd->uid = (uintptr_t) cm_id_priv;
-
- result = write(device->fd, msg, size);
- if (result != size)
- goto err;
-
- VALGRIND_MAKE_MEM_DEFINED(resp, sizeof *resp);
-
- cm_id_priv->id.handle = resp->id;
- *cm_id = &cm_id_priv->id;
- return 0;
-
-err: ib_cm_free_id(cm_id_priv);
- return result;
-}
-
-int ib_cm_destroy_id(struct ib_cm_id *cm_id)
-{
- struct cm_abi_destroy_id_resp *resp;
- struct cm_abi_destroy_id *cmd;
- struct cm_id_private *cm_id_priv;
- void *msg;
- int result;
- int size;
-
- CM_CREATE_MSG_CMD_RESP(msg, cmd, resp, IB_USER_CM_CMD_DESTROY_ID, size);
- cmd->id = cm_id->handle;
-
- result = write(cm_id->device->fd, msg, size);
- if (result != size)
- return (result >= 0) ? ERR(ECONNREFUSED) : -1;
-
- VALGRIND_MAKE_MEM_DEFINED(resp, sizeof *resp);
-
- cm_id_priv = container_of(cm_id, struct cm_id_private, id);
-
- pthread_mutex_lock(&cm_id_priv->mut);
- while (cm_id_priv->events_completed < resp->events_reported)
- pthread_cond_wait(&cm_id_priv->cond, &cm_id_priv->mut);
- pthread_mutex_unlock(&cm_id_priv->mut);
-
- ib_cm_free_id(cm_id_priv);
- return 0;
-}
-
-int ib_cm_attr_id(struct ib_cm_id *cm_id, struct ib_cm_attr_param *param)
-{
- struct cm_abi_attr_id_resp *resp;
- struct cm_abi_attr_id *cmd;
- void *msg;
- int result;
- int size;
-
- if (!param)
- return ERR(EINVAL);
-
- CM_CREATE_MSG_CMD_RESP(msg, cmd, resp, IB_USER_CM_CMD_ATTR_ID, size);
- cmd->id = cm_id->handle;
-
- result = write(cm_id->device->fd, msg, size);
- if (result != size)
- return (result >= 0) ? ERR(ECONNREFUSED) : -1;
-
- VALGRIND_MAKE_MEM_DEFINED(resp, sizeof *resp);
-
- param->service_id = resp->service_id;
- param->service_mask = resp->service_mask;
- param->local_id = resp->local_id;
- param->remote_id = resp->remote_id;
- return 0;
-}
-
-int ib_cm_init_qp_attr(struct ib_cm_id *cm_id,
- struct ibv_qp_attr *qp_attr,
- int *qp_attr_mask)
-{
- struct ibv_kern_qp_attr *resp;
- struct cm_abi_init_qp_attr *cmd;
- void *msg;
- int result;
- int size;
-
- if (!qp_attr || !qp_attr_mask)
- return ERR(EINVAL);
-
- CM_CREATE_MSG_CMD_RESP(msg, cmd, resp, IB_USER_CM_CMD_INIT_QP_ATTR, size);
- cmd->id = cm_id->handle;
- cmd->qp_state = qp_attr->qp_state;
-
- result = write(cm_id->device->fd, msg, size);
- if (result != size)
- return (result >= 0) ? ERR(ECONNREFUSED) : result;
-
- VALGRIND_MAKE_MEM_DEFINED(resp, sizeof *resp);
-
- *qp_attr_mask = resp->qp_attr_mask;
- ibv_copy_qp_attr_from_kern(qp_attr, resp);
-
- return 0;
-}
-
-int ib_cm_listen(struct ib_cm_id *cm_id,
- uint64_t service_id,
- uint64_t service_mask)
-{
- struct cm_abi_listen *cmd;
- void *msg;
- int result;
- int size;
-
- CM_CREATE_MSG_CMD(msg, cmd, IB_USER_CM_CMD_LISTEN, size);
- cmd->id = cm_id->handle;
- cmd->service_id = service_id;
- cmd->service_mask = service_mask;
-
- result = write(cm_id->device->fd, msg, size);
- if (result != size)
- return (result >= 0) ? ERR(ECONNREFUSED) : -1;
-
- return 0;
-}
-
-int ib_cm_send_req(struct ib_cm_id *cm_id, struct ib_cm_req_param *param)
-{
- struct ibv_kern_path_rec *p_path;
- struct ibv_kern_path_rec *a_path;
- struct cm_abi_req *cmd;
- void *msg;
- int result;
- int size;
-
- if (!param)
- return ERR(EINVAL);
-
- CM_CREATE_MSG_CMD(msg, cmd, IB_USER_CM_CMD_SEND_REQ, size);
- cmd->id = cm_id->handle;
- cmd->qpn = param->qp_num;
- cmd->qp_type = param->qp_type;
- cmd->psn = param->starting_psn;
- cmd->sid = param->service_id;
- cmd->peer_to_peer = param->peer_to_peer;
- cmd->responder_resources = param->responder_resources;
- cmd->initiator_depth = param->initiator_depth;
- cmd->remote_cm_response_timeout = param->remote_cm_response_timeout;
- cmd->flow_control = param->flow_control;
- cmd->local_cm_response_timeout = param->local_cm_response_timeout;
- cmd->retry_count = param->retry_count;
- cmd->rnr_retry_count = param->rnr_retry_count;
- cmd->max_cm_retries = param->max_cm_retries;
- cmd->srq = param->srq;
-
- if (param->primary_path) {
- p_path = alloca(sizeof(*p_path));
- if (!p_path)
- return ERR(ENOMEM);
-
- ibv_copy_path_rec_to_kern(p_path, param->primary_path);
- cmd->primary_path = (uintptr_t) p_path;
- }
-
- if (param->alternate_path) {
- a_path = alloca(sizeof(*a_path));
- if (!a_path)
- return ERR(ENOMEM);
-
- ibv_copy_path_rec_to_kern(a_path, param->alternate_path);
- cmd->alternate_path = (uintptr_t) a_path;
- }
-
- if (param->private_data && param->private_data_len) {
- cmd->data = (uintptr_t) param->private_data;
- cmd->len = param->private_data_len;
- }
-
- result = write(cm_id->device->fd, msg, size);
- if (result != size)
- return (result >= 0) ? ERR(ECONNREFUSED) : -1;
-
- return 0;
-}
-
-int ib_cm_send_rep(struct ib_cm_id *cm_id, struct ib_cm_rep_param *param)
-{
- struct cm_abi_rep *cmd;
- void *msg;
- int result;
- int size;
-
- if (!param)
- return ERR(EINVAL);
-
- CM_CREATE_MSG_CMD(msg, cmd, IB_USER_CM_CMD_SEND_REP, size);
- cmd->uid = (uintptr_t) container_of(cm_id, struct cm_id_private, id);
- cmd->id = cm_id->handle;
- cmd->qpn = param->qp_num;
- cmd->psn = param->starting_psn;
- cmd->responder_resources = param->responder_resources;
- cmd->initiator_depth = param->initiator_depth;
- cmd->target_ack_delay = param->target_ack_delay;
- cmd->failover_accepted = param->failover_accepted;
- cmd->flow_control = param->flow_control;
- cmd->rnr_retry_count = param->rnr_retry_count;
- cmd->srq = param->srq;
-
- if (param->private_data && param->private_data_len) {
- cmd->data = (uintptr_t) param->private_data;
- cmd->len = param->private_data_len;
- }
-
- result = write(cm_id->device->fd, msg, size);
- if (result != size)
- return (result >= 0) ? ERR(ECONNREFUSED) : -1;
-
- return 0;
-}
-
-static inline int cm_send_private_data(struct ib_cm_id *cm_id,
- uint32_t type,
- void *private_data,
- uint8_t private_data_len)
-{
- struct cm_abi_private_data *cmd;
- void *msg;
- int result;
- int size;
-
- CM_CREATE_MSG_CMD(msg, cmd, type, size);
- cmd->id = cm_id->handle;
-
- if (private_data && private_data_len) {
- cmd->data = (uintptr_t) private_data;
- cmd->len = private_data_len;
- }
-
- result = write(cm_id->device->fd, msg, size);
- if (result != size)
- return (result >= 0) ? ERR(ECONNREFUSED) : -1;
-
- return 0;
-}
-
-int ib_cm_send_rtu(struct ib_cm_id *cm_id,
- void *private_data,
- uint8_t private_data_len)
-{
- return cm_send_private_data(cm_id, IB_USER_CM_CMD_SEND_RTU,
- private_data, private_data_len);
-}
-
-int ib_cm_send_dreq(struct ib_cm_id *cm_id,
- void *private_data,
- uint8_t private_data_len)
-{
- return cm_send_private_data(cm_id, IB_USER_CM_CMD_SEND_DREQ,
- private_data, private_data_len);
-}
-
-int ib_cm_send_drep(struct ib_cm_id *cm_id,
- void *private_data,
- uint8_t private_data_len)
-{
- return cm_send_private_data(cm_id, IB_USER_CM_CMD_SEND_DREP,
- private_data, private_data_len);
-}
-
-static int cm_establish(struct ib_cm_id *cm_id)
-{
- struct cm_abi_establish *cmd;
- void *msg;
- int result;
- int size;
-
- CM_CREATE_MSG_CMD(msg, cmd, IB_USER_CM_CMD_ESTABLISH, size);
- cmd->id = cm_id->handle;
-
- result = write(cm_id->device->fd, msg, size);
- if (result != size)
- return (result >= 0) ? ERR(ECONNREFUSED) : -1;
-
- return 0;
-}
-
-int ib_cm_notify(struct ib_cm_id *cm_id, enum ibv_event_type event)
-{
- struct cm_abi_notify *cmd;
- void *msg;
- int result;
- int size;
-
- if (abi_ver == 4) {
- if (event == IBV_EVENT_COMM_EST)
- return cm_establish(cm_id);
- else
- return ERR(EINVAL);
- }
-
- CM_CREATE_MSG_CMD(msg, cmd, IB_USER_CM_CMD_NOTIFY, size);
- cmd->id = cm_id->handle;
- cmd->event = event;
-
- result = write(cm_id->device->fd, msg, size);
- if (result != size)
- return (result >= 0) ? ERR(ECONNREFUSED) : -1;
-
- return 0;
-}
-
-static inline int cm_send_status(struct ib_cm_id *cm_id,
- uint32_t type,
- int status,
- void *info,
- uint8_t info_length,
- void *private_data,
- uint8_t private_data_len)
-{
- struct cm_abi_info *cmd;
- void *msg;
- int result;
- int size;
-
- CM_CREATE_MSG_CMD(msg, cmd, type, size);
- cmd->id = cm_id->handle;
- cmd->status = status;
-
- if (private_data && private_data_len) {
- cmd->data = (uintptr_t) private_data;
- cmd->data_len = private_data_len;
- }
-
- if (info && info_length) {
- cmd->info = (uintptr_t) info;
- cmd->info_len = info_length;
- }
-
- result = write(cm_id->device->fd, msg, size);
- if (result != size)
- return (result >= 0) ? ERR(ECONNREFUSED) : -1;
-
- return 0;
-}
-
-int ib_cm_send_rej(struct ib_cm_id *cm_id,
- enum ib_cm_rej_reason reason,
- void *ari,
- uint8_t ari_length,
- void *private_data,
- uint8_t private_data_len)
-{
- return cm_send_status(cm_id, IB_USER_CM_CMD_SEND_REJ, reason,
- ari, ari_length,
- private_data, private_data_len);
-}
-
-int ib_cm_send_apr(struct ib_cm_id *cm_id,
- enum ib_cm_apr_status status,
- void *info,
- uint8_t info_length,
- void *private_data,
- uint8_t private_data_len)
-{
- return cm_send_status(cm_id, IB_USER_CM_CMD_SEND_APR, status,
- info, info_length,
- private_data, private_data_len);
-}
-
-int ib_cm_send_mra(struct ib_cm_id *cm_id,
- uint8_t service_timeout,
- void *private_data,
- uint8_t private_data_len)
-{
- struct cm_abi_mra *cmd;
- void *msg;
- int result;
- int size;
-
- CM_CREATE_MSG_CMD(msg, cmd, IB_USER_CM_CMD_SEND_MRA, size);
- cmd->id = cm_id->handle;
- cmd->timeout = service_timeout;
-
- if (private_data && private_data_len) {
- cmd->data = (uintptr_t) private_data;
- cmd->len = private_data_len;
- }
-
- result = write(cm_id->device->fd, msg, size);
- if (result != size)
- return (result >= 0) ? ERR(ECONNREFUSED) : result;
-
- return 0;
-}
-
-int ib_cm_send_lap(struct ib_cm_id *cm_id,
- struct ibv_sa_path_rec *alternate_path,
- void *private_data,
- uint8_t private_data_len)
-{
- struct ibv_kern_path_rec *abi_path;
- struct cm_abi_lap *cmd;
- void *msg;
- int result;
- int size;
-
- CM_CREATE_MSG_CMD(msg, cmd, IB_USER_CM_CMD_SEND_LAP, size);
- cmd->id = cm_id->handle;
-
- if (alternate_path) {
- abi_path = alloca(sizeof(*abi_path));
- if (!abi_path)
- return ERR(ENOMEM);
-
- ibv_copy_path_rec_to_kern(abi_path, alternate_path);
- cmd->path = (uintptr_t) abi_path;
- }
-
- if (private_data && private_data_len) {
- cmd->data = (uintptr_t) private_data;
- cmd->len = private_data_len;
- }
-
- result = write(cm_id->device->fd, msg, size);
- if (result != size)
- return (result >= 0) ? ERR(ECONNREFUSED) : -1;
-
- return 0;
-}
-
-int ib_cm_send_sidr_req(struct ib_cm_id *cm_id,
- struct ib_cm_sidr_req_param *param)
-{
- struct ibv_kern_path_rec *abi_path;
- struct cm_abi_sidr_req *cmd;
- void *msg;
- int result;
- int size;
-
- if (!param)
- return ERR(EINVAL);
-
- CM_CREATE_MSG_CMD(msg, cmd, IB_USER_CM_CMD_SEND_SIDR_REQ, size);
- cmd->id = cm_id->handle;
- cmd->sid = param->service_id;
- cmd->timeout = param->timeout_ms;
- cmd->pkey = param->path->pkey;
- cmd->max_cm_retries = param->max_cm_retries;
-
- if (param->path) {
- abi_path = alloca(sizeof(*abi_path));
- if (!abi_path)
- return ERR(ENOMEM);
-
- ibv_copy_path_rec_to_kern(abi_path, param->path);
- cmd->path = (uintptr_t) abi_path;
- }
-
- if (param->private_data && param->private_data_len) {
- cmd->data = (uintptr_t) param->private_data;
- cmd->len = param->private_data_len;
- }
-
- result = write(cm_id->device->fd, msg, size);
- if (result != size)
- return (result >= 0) ? ERR(ECONNREFUSED) : result;
-
- return 0;
-}
-
-int ib_cm_send_sidr_rep(struct ib_cm_id *cm_id,
- struct ib_cm_sidr_rep_param *param)
-{
- struct cm_abi_sidr_rep *cmd;
- void *msg;
- int result;
- int size;
-
- if (!param)
- return ERR(EINVAL);
-
- CM_CREATE_MSG_CMD(msg, cmd, IB_USER_CM_CMD_SEND_SIDR_REP, size);
- cmd->id = cm_id->handle;
- cmd->qpn = param->qp_num;
- cmd->qkey = param->qkey;
- cmd->status = param->status;
-
- if (param->private_data && param->private_data_len) {
- cmd->data = (uintptr_t) param->private_data;
- cmd->data_len = param->private_data_len;
- }
-
- if (param->info && param->info_length) {
- cmd->info = (uintptr_t) param->info;
- cmd->info_len = param->info_length;
- }
-
- result = write(cm_id->device->fd, msg, size);
- if (result != size)
- return (result >= 0) ? ERR(ECONNREFUSED) : -1;
-
- return 0;
-}
-
-static void cm_event_req_get(struct ib_cm_req_event_param *ureq,
- struct cm_abi_req_event_resp *kreq)
-{
- ureq->remote_ca_guid = kreq->remote_ca_guid;
- ureq->remote_qkey = kreq->remote_qkey;
- ureq->remote_qpn = kreq->remote_qpn;
- ureq->qp_type = kreq->qp_type;
- ureq->starting_psn = kreq->starting_psn;
- ureq->responder_resources = kreq->responder_resources;
- ureq->initiator_depth = kreq->initiator_depth;
- ureq->local_cm_response_timeout = kreq->local_cm_response_timeout;
- ureq->flow_control = kreq->flow_control;
- ureq->remote_cm_response_timeout = kreq->remote_cm_response_timeout;
- ureq->retry_count = kreq->retry_count;
- ureq->rnr_retry_count = kreq->rnr_retry_count;
- ureq->srq = kreq->srq;
- ureq->port = kreq->port;
-
- ibv_copy_path_rec_from_kern(ureq->primary_path, &kreq->primary_path);
- if (ureq->alternate_path)
- ibv_copy_path_rec_from_kern(ureq->alternate_path,
- &kreq->alternate_path);
-}
-
-static void cm_event_rep_get(struct ib_cm_rep_event_param *urep,
- struct cm_abi_rep_event_resp *krep)
-{
- urep->remote_ca_guid = krep->remote_ca_guid;
- urep->remote_qkey = krep->remote_qkey;
- urep->remote_qpn = krep->remote_qpn;
- urep->starting_psn = krep->starting_psn;
- urep->responder_resources = krep->responder_resources;
- urep->initiator_depth = krep->initiator_depth;
- urep->target_ack_delay = krep->target_ack_delay;
- urep->failover_accepted = krep->failover_accepted;
- urep->flow_control = krep->flow_control;
- urep->rnr_retry_count = krep->rnr_retry_count;
- urep->srq = krep->srq;
-}
-
-static void cm_event_sidr_rep_get(struct ib_cm_sidr_rep_event_param *urep,
- struct cm_abi_sidr_rep_event_resp *krep)
-{
- urep->status = krep->status;
- urep->qkey = krep->qkey;
- urep->qpn = krep->qpn;
-};
-
-int ib_cm_get_event(struct ib_cm_device *device, struct ib_cm_event **event)
-{
- struct cm_id_private *cm_id_priv;
- struct cm_abi_cmd_hdr *hdr;
- struct cm_abi_event_get *cmd;
- struct cm_abi_event_resp *resp;
- struct ib_cm_event *evt = NULL;
- struct ibv_sa_path_rec *path_a = NULL;
- struct ibv_sa_path_rec *path_b = NULL;
- void *data = NULL;
- void *info = NULL;
- void *msg;
- int result = 0;
- int size;
-
- if (!event)
- return ERR(EINVAL);
-
- size = sizeof(*hdr) + sizeof(*cmd);
- msg = alloca(size);
- if (!msg)
- return ERR(ENOMEM);
-
- hdr = msg;
- cmd = msg + sizeof(*hdr);
-
- hdr->cmd = IB_USER_CM_CMD_EVENT;
- hdr->in = sizeof(*cmd);
- hdr->out = sizeof(*resp);
-
- memset(cmd, 0, sizeof(*cmd));
-
- resp = alloca(sizeof(*resp));
- if (!resp)
- return ERR(ENOMEM);
-
- cmd->response = (uintptr_t) resp;
- cmd->data_len = (uint8_t)(~0U);
- cmd->info_len = (uint8_t)(~0U);
-
- data = malloc(cmd->data_len);
- if (!data) {
- result = ERR(ENOMEM);
- goto done;
- }
-
- info = malloc(cmd->info_len);
- if (!info) {
- result = ERR(ENOMEM);
- goto done;
- }
-
- cmd->data = (uintptr_t) data;
- cmd->info = (uintptr_t) info;
-
- result = write(device->fd, msg, size);
- if (result != size) {
- result = (result >= 0) ? ERR(ECONNREFUSED) : -1;
- goto done;
- }
-
- VALGRIND_MAKE_MEM_DEFINED(resp, sizeof *resp);
-
- /*
- * decode event.
- */
- evt = malloc(sizeof(*evt));
- if (!evt) {
- result = ERR(ENOMEM);
- goto done;
- }
- memset(evt, 0, sizeof(*evt));
- evt->cm_id = (void *) (uintptr_t) resp->uid;
- evt->event = resp->event;
-
- if (resp->present & CM_ABI_PRES_PRIMARY) {
- path_a = malloc(sizeof(*path_a));
- if (!path_a) {
- result = ERR(ENOMEM);
- goto done;
- }
- }
-
- if (resp->present & CM_ABI_PRES_ALTERNATE) {
- path_b = malloc(sizeof(*path_b));
- if (!path_b) {
- result = ERR(ENOMEM);
- goto done;
- }
- }
-
- switch (evt->event) {
- case IB_CM_REQ_RECEIVED:
- evt->param.req_rcvd.listen_id = evt->cm_id;
- cm_id_priv = ib_cm_alloc_id(evt->cm_id->device,
- evt->cm_id->context);
- if (!cm_id_priv) {
- result = ERR(ENOMEM);
- goto done;
- }
- cm_id_priv->id.handle = resp->id;
- evt->cm_id = &cm_id_priv->id;
- evt->param.req_rcvd.primary_path = path_a;
- evt->param.req_rcvd.alternate_path = path_b;
- path_a = NULL;
- path_b = NULL;
- cm_event_req_get(&evt->param.req_rcvd, &resp->u.req_resp);
- break;
- case IB_CM_REP_RECEIVED:
- cm_event_rep_get(&evt->param.rep_rcvd, &resp->u.rep_resp);
- break;
- case IB_CM_MRA_RECEIVED:
- evt->param.mra_rcvd.service_timeout = resp->u.mra_resp.timeout;
- break;
- case IB_CM_REJ_RECEIVED:
- evt->param.rej_rcvd.reason = resp->u.rej_resp.reason;
- evt->param.rej_rcvd.ari = info;
- info = NULL;
- break;
- case IB_CM_LAP_RECEIVED:
- evt->param.lap_rcvd.alternate_path = path_b;
- path_b = NULL;
- ibv_copy_path_rec_from_kern(evt->param.lap_rcvd.alternate_path,
- &resp->u.lap_resp.path);
- break;
- case IB_CM_APR_RECEIVED:
- evt->param.apr_rcvd.ap_status = resp->u.apr_resp.status;
- evt->param.apr_rcvd.apr_info = info;
- info = NULL;
- break;
- case IB_CM_SIDR_REQ_RECEIVED:
- evt->param.sidr_req_rcvd.listen_id = evt->cm_id;
- cm_id_priv = ib_cm_alloc_id(evt->cm_id->device,
- evt->cm_id->context);
- if (!cm_id_priv) {
- result = ERR(ENOMEM);
- goto done;
- }
- cm_id_priv->id.handle = resp->id;
- evt->cm_id = &cm_id_priv->id;
- evt->param.sidr_req_rcvd.pkey = resp->u.sidr_req_resp.pkey;
- evt->param.sidr_req_rcvd.port = resp->u.sidr_req_resp.port;
- break;
- case IB_CM_SIDR_REP_RECEIVED:
- cm_event_sidr_rep_get(&evt->param.sidr_rep_rcvd,
- &resp->u.sidr_rep_resp);
- evt->param.sidr_rep_rcvd.info = info;
- info = NULL;
- break;
- default:
- evt->param.send_status = resp->u.send_status;
- break;
- }
-
- if (resp->present & CM_ABI_PRES_DATA) {
- evt->private_data = data;
- data = NULL;
- }
-
- *event = evt;
- evt = NULL;
- result = 0;
-done:
- if (data)
- free(data);
- if (info)
- free(info);
- if (path_a)
- free(path_a);
- if (path_b)
- free(path_b);
- if (evt)
- free(evt);
-
- return result;
-}
-
-int ib_cm_ack_event(struct ib_cm_event *event)
-{
- struct cm_id_private *cm_id_priv;
-
- if (!event)
- return ERR(EINVAL);
-
- if (event->private_data)
- free(event->private_data);
-
- cm_id_priv = container_of(event->cm_id, struct cm_id_private, id);
-
- switch (event->event) {
- case IB_CM_REQ_RECEIVED:
- cm_id_priv = container_of(event->param.req_rcvd.listen_id,
- struct cm_id_private, id);
- free(event->param.req_rcvd.primary_path);
- if (event->param.req_rcvd.alternate_path)
- free(event->param.req_rcvd.alternate_path);
- break;
- case IB_CM_REJ_RECEIVED:
- if (event->param.rej_rcvd.ari)
- free(event->param.rej_rcvd.ari);
- break;
- case IB_CM_LAP_RECEIVED:
- free(event->param.lap_rcvd.alternate_path);
- break;
- case IB_CM_APR_RECEIVED:
- if (event->param.apr_rcvd.apr_info)
- free(event->param.apr_rcvd.apr_info);
- break;
- case IB_CM_SIDR_REQ_RECEIVED:
- cm_id_priv = container_of(event->param.sidr_req_rcvd.listen_id,
- struct cm_id_private, id);
- break;
- case IB_CM_SIDR_REP_RECEIVED:
- if (event->param.sidr_rep_rcvd.info)
- free(event->param.sidr_rep_rcvd.info);
- default:
- break;
- }
-
- pthread_mutex_lock(&cm_id_priv->mut);
- cm_id_priv->events_completed++;
- pthread_cond_signal(&cm_id_priv->cond);
- pthread_mutex_unlock(&cm_id_priv->mut);
-
- free(event);
- return 0;
-}
diff --git a/contrib/ofed/libibcm/src/libibcm.map b/contrib/ofed/libibcm/src/libibcm.map
deleted file mode 100644
index 3d83e48..0000000
--- a/contrib/ofed/libibcm/src/libibcm.map
+++ /dev/null
@@ -1,25 +0,0 @@
-IBCM_1.0 {
- global:
- ib_cm_open_device;
- ib_cm_close_device;
- ib_cm_get_event;
- ib_cm_ack_event;
- ib_cm_create_id;
- ib_cm_destroy_id;
- ib_cm_attr_id;
- ib_cm_listen;
- ib_cm_send_req;
- ib_cm_send_rep;
- ib_cm_send_rtu;
- ib_cm_send_dreq;
- ib_cm_send_drep;
- ib_cm_notify;
- ib_cm_send_rej;
- ib_cm_send_mra;
- ib_cm_send_lap;
- ib_cm_send_apr;
- ib_cm_send_sidr_req;
- ib_cm_send_sidr_rep;
- ib_cm_init_qp_attr;
- local: *;
-};
diff --git a/contrib/ofed/libibmad/Makefile b/contrib/ofed/libibmad/Makefile
new file mode 100644
index 0000000..ceef5eb
--- /dev/null
+++ b/contrib/ofed/libibmad/Makefile
@@ -0,0 +1,32 @@
+# $FreeBSD$
+
+.PATH: ${.CURDIR}
+
+SHLIBDIR?= /usr/lib
+LIB= ibmad
+SHLIB_MAJOR= 5
+MK_PROFILE= no
+
+SRCS= \
+bm.c \
+cc.c \
+dump.c \
+fields.c \
+gs.c \
+mad.c \
+portid.c \
+register.c \
+resolve.c \
+rpc.c \
+sa.c \
+serv.c \
+smp.c \
+vendor.c
+
+LIBADD= ibumad
+CFLAGS+= -DHAVE_CONFIG_H=1
+CFLAGS+= -I${.CURDIR}
+VERSION_MAP= ${.CURDIR}/libibmad.map
+
+.include <bsd.lib.mk>
+
diff --git a/contrib/ofed/libibmad/bm.c b/contrib/ofed/libibmad/bm.c
new file mode 100644
index 0000000..3181451
--- /dev/null
+++ b/contrib/ofed/libibmad/bm.c
@@ -0,0 +1,107 @@
+/*
+ * Copyright (c) 2004-2009 Voltaire Inc. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+#if HAVE_CONFIG_H
+# include <config.h>
+#endif /* HAVE_CONFIG_H */
+
+#include <string.h>
+
+#include <infiniband/mad.h>
+
+#undef DEBUG
+#define DEBUG if (ibdebug) IBWARN
+
+static inline int response_expected(int method)
+{
+ return method == IB_MAD_METHOD_GET ||
+ method == IB_MAD_METHOD_SET || method == IB_MAD_METHOD_TRAP;
+}
+
+uint8_t *bm_call_via(void *data, ib_portid_t * portid, ib_bm_call_t * call,
+ struct ibmad_port * srcport)
+{
+ ib_rpc_t rpc = { 0 };
+ int resp_expected;
+ struct {
+ uint64_t bkey;
+ uint8_t reserved[32];
+ uint8_t data[IB_BM_DATA_SZ];
+ } bm_data;
+
+ DEBUG("route %s data %p", portid2str(portid), data);
+ if (portid->lid <= 0) {
+ IBWARN("only lid routes are supported");
+ return NULL;
+ }
+
+ resp_expected = response_expected(call->method);
+
+ rpc.mgtclass = IB_BOARD_MGMT_CLASS;
+
+ rpc.method = call->method;
+ rpc.attr.id = call->attrid;
+ rpc.attr.mod = call->mod;
+ rpc.timeout = resp_expected ? call->timeout : 0;
+ // send data and bkey
+ rpc.datasz = IB_BM_BKEY_AND_DATA_SZ;
+ rpc.dataoffs = IB_BM_BKEY_OFFS;
+
+ // copy data to a buffer which also includes the bkey
+ bm_data.bkey = htonll(call->bkey);
+ memset(bm_data.reserved, 0, sizeof(bm_data.reserved));
+ memcpy(bm_data.data, data, IB_BM_DATA_SZ);
+
+ DEBUG
+ ("method 0x%x attr 0x%x mod 0x%x datasz %d off %d res_ex %d bkey 0x%08x%08x",
+ rpc.method, rpc.attr.id, rpc.attr.mod, rpc.datasz, rpc.dataoffs,
+ resp_expected, (int)(call->bkey >> 32), (int)call->bkey);
+
+ portid->qp = 1;
+ if (!portid->qkey)
+ portid->qkey = IB_DEFAULT_QP1_QKEY;
+
+ if (resp_expected) {
+ /* FIXME: no RMPP for now */
+ if (mad_rpc(srcport, &rpc, portid, &bm_data, &bm_data))
+ goto return_ok;
+ return NULL;
+ }
+
+ if (mad_send_via(&rpc, portid, 0, &bm_data, srcport) < 0)
+ return NULL;
+
+return_ok:
+ memcpy(data, bm_data.data, IB_BM_DATA_SZ);
+ return data;
+}
diff --git a/contrib/ofed/libibmad/cc.c b/contrib/ofed/libibmad/cc.c
new file mode 100644
index 0000000..2334015
--- /dev/null
+++ b/contrib/ofed/libibmad/cc.c
@@ -0,0 +1,119 @@
+/*
+ * Copyright (c) 2011 Lawrence Livermore National Lab. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+#if HAVE_CONFIG_H
+# include <config.h>
+#endif /* HAVE_CONFIG_H */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include <infiniband/umad.h>
+#include <infiniband/mad.h>
+#include "mad_internal.h"
+
+#undef DEBUG
+#define DEBUG if (ibdebug) IBWARN
+
+void *cc_query_status_via(void *rcvbuf, ib_portid_t * portid,
+ unsigned attrid, unsigned mod, unsigned timeout,
+ int *rstatus, const struct ibmad_port * srcport,
+ uint64_t cckey)
+{
+ ib_rpc_cc_t rpc = { 0 };
+ void *res;
+
+ DEBUG("attr 0x%x mod 0x%x route %s", attrid, mod, portid2str(portid));
+ rpc.method = IB_MAD_METHOD_GET;
+ rpc.attr.id = attrid;
+ rpc.attr.mod = mod;
+ rpc.timeout = timeout;
+ if (attrid == IB_CC_ATTR_CONGESTION_LOG) {
+ rpc.datasz = IB_CC_LOG_DATA_SZ;
+ rpc.dataoffs = IB_CC_LOG_DATA_OFFS;
+ }
+ else {
+ rpc.datasz = IB_CC_DATA_SZ;
+ rpc.dataoffs = IB_CC_DATA_OFFS;
+ }
+ rpc.mgtclass = IB_CC_CLASS;
+ rpc.cckey = cckey;
+
+ portid->qp = 1;
+ if (!portid->qkey)
+ portid->qkey = IB_DEFAULT_QP1_QKEY;
+
+ res = mad_rpc(srcport, (ib_rpc_t *)&rpc, portid, rcvbuf, rcvbuf);
+ if (rstatus)
+ *rstatus = rpc.rstatus;
+
+ return res;
+}
+
+void *cc_config_status_via(void *payload, void *rcvbuf, ib_portid_t * portid,
+ unsigned attrid, unsigned mod, unsigned timeout,
+ int *rstatus, const struct ibmad_port * srcport,
+ uint64_t cckey)
+{
+ ib_rpc_cc_t rpc = { 0 };
+ void *res;
+
+ DEBUG("attr 0x%x mod 0x%x route %s", attrid, mod, portid2str(portid));
+ rpc.method = IB_MAD_METHOD_SET;
+ rpc.attr.id = attrid;
+ rpc.attr.mod = mod;
+ rpc.timeout = timeout;
+ if (attrid == IB_CC_ATTR_CONGESTION_LOG) {
+ rpc.datasz = IB_CC_LOG_DATA_SZ;
+ rpc.dataoffs = IB_CC_LOG_DATA_OFFS;
+ }
+ else {
+ rpc.datasz = IB_CC_DATA_SZ;
+ rpc.dataoffs = IB_CC_DATA_OFFS;
+ }
+ rpc.mgtclass = IB_CC_CLASS;
+ rpc.cckey = cckey;
+
+ portid->qp = 1;
+ if (!portid->qkey)
+ portid->qkey = IB_DEFAULT_QP1_QKEY;
+
+ res = mad_rpc(srcport, (ib_rpc_t *)&rpc, portid, payload, rcvbuf);
+ if (rstatus)
+ *rstatus = rpc.rstatus;
+
+ return res;
+}
+
+
diff --git a/contrib/ofed/libibmad/config.h b/contrib/ofed/libibmad/config.h
new file mode 100644
index 0000000..9333552
--- /dev/null
+++ b/contrib/ofed/libibmad/config.h
@@ -0,0 +1,89 @@
+/* config.h. Generated from config.h.in by configure. */
+/* config.h.in. Generated from configure.ac by autoheader. */
+
+/* Define to 1 if you have the <dlfcn.h> header file. */
+#define HAVE_DLFCN_H 1
+
+/* Define to 1 if you have the <inttypes.h> header file. */
+#define HAVE_INTTYPES_H 1
+
+/* Define to 1 if you have the `ibumad' library (-libumad). */
+#define HAVE_LIBIBUMAD 1
+
+/* Define to 1 if you have the <memory.h> header file. */
+#define HAVE_MEMORY_H 1
+
+/* Define to 1 if you have the `memset' function. */
+#define HAVE_MEMSET 1
+
+/* Define to 1 if you have the <netinet/in.h> header file. */
+#define HAVE_NETINET_IN_H 1
+
+/* Define to 1 if you have the <stdint.h> header file. */
+#define HAVE_STDINT_H 1
+
+/* Define to 1 if you have the <stdlib.h> header file. */
+#define HAVE_STDLIB_H 1
+
+/* Define to 1 if you have the <strings.h> header file. */
+#define HAVE_STRINGS_H 1
+
+/* Define to 1 if you have the <string.h> header file. */
+#define HAVE_STRING_H 1
+
+/* Define to 1 if you have the `strrchr' function. */
+#define HAVE_STRRCHR 1
+
+/* Define to 1 if you have the `strtol' function. */
+#define HAVE_STRTOL 1
+
+/* Define to 1 if you have the <sys/stat.h> header file. */
+#define HAVE_SYS_STAT_H 1
+
+/* Define to 1 if you have the <sys/time.h> header file. */
+#define HAVE_SYS_TIME_H 1
+
+/* Define to 1 if you have the <sys/types.h> header file. */
+#define HAVE_SYS_TYPES_H 1
+
+/* Define to 1 if you have the <unistd.h> header file. */
+#define HAVE_UNISTD_H 1
+
+/* Define to the sub-directory where libtool stores uninstalled libraries. */
+#define LT_OBJDIR ".libs/"
+
+/* Name of package */
+#define PACKAGE "libibmad"
+
+/* Define to the address where bug reports for this package should be sent. */
+#define PACKAGE_BUGREPORT "linux-rdma@vger.kernel.org"
+
+/* Define to the full name of this package. */
+#define PACKAGE_NAME "libibmad"
+
+/* Define to the full name and version of this package. */
+#define PACKAGE_STRING "libibmad 1.3.13"
+
+/* Define to the one symbol short name of this package. */
+#define PACKAGE_TARNAME "libibmad"
+
+/* Define to the home page for this package. */
+#define PACKAGE_URL ""
+
+/* Define to the version of this package. */
+#define PACKAGE_VERSION "1.3.13"
+
+/* Define to 1 if you have the ANSI C header files. */
+#define STDC_HEADERS 1
+
+/* Version number of package */
+#define VERSION "1.3.13"
+
+/* Define to empty if `const' does not conform to ANSI C. */
+/* #undef const */
+
+/* Define to `__inline__' or `__inline' if that's what the C compiler
+ calls it, or to nothing if 'inline' is not supported under any name. */
+#ifndef __cplusplus
+/* #undef inline */
+#endif
diff --git a/contrib/ofed/libibmad/dump.c b/contrib/ofed/libibmad/dump.c
new file mode 100644
index 0000000..00b9211
--- /dev/null
+++ b/contrib/ofed/libibmad/dump.c
@@ -0,0 +1,1221 @@
+/*
+ * Copyright (c) 2004-2009 Voltaire Inc. All rights reserved.
+ * Copyright (c) 2007 Xsigo Systems Inc. All rights reserved.
+ * Copyright (c) 2009-2011 Mellanox Technologies LTD. All rights reserved.
+ * Copyright (c) 2009 HNR Consulting. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+#if HAVE_CONFIG_H
+# include <config.h>
+#endif /* HAVE_CONFIG_H */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include <infiniband/mad.h>
+
+void mad_dump_int(char *buf, int bufsz, void *val, int valsz)
+{
+ switch (valsz) {
+ case 1:
+ snprintf(buf, bufsz, "%d", *(uint32_t *) val & 0xff);
+ break;
+ case 2:
+ snprintf(buf, bufsz, "%d", *(uint32_t *) val & 0xffff);
+ break;
+ case 3:
+ case 4:
+ snprintf(buf, bufsz, "%d", *(uint32_t *) val);
+ break;
+ case 5:
+ case 6:
+ case 7:
+ case 8:
+ snprintf(buf, bufsz, "%" PRIu64, *(uint64_t *) val);
+ break;
+ default:
+ IBWARN("bad int sz %d", valsz);
+ buf[0] = 0;
+ }
+}
+
+void mad_dump_uint(char *buf, int bufsz, void *val, int valsz)
+{
+ switch (valsz) {
+ case 1:
+ snprintf(buf, bufsz, "%u", *(uint32_t *) val & 0xff);
+ break;
+ case 2:
+ snprintf(buf, bufsz, "%u", *(uint32_t *) val & 0xffff);
+ break;
+ case 3:
+ case 4:
+ snprintf(buf, bufsz, "%u", *(uint32_t *) val);
+ break;
+ case 5:
+ case 6:
+ case 7:
+ case 8:
+ snprintf(buf, bufsz, "%" PRIu64, *(uint64_t *) val);
+ break;
+ default:
+ IBWARN("bad int sz %u", valsz);
+ buf[0] = 0;
+ }
+}
+
+void mad_dump_hex(char *buf, int bufsz, void *val, int valsz)
+{
+ switch (valsz) {
+ case 1:
+ snprintf(buf, bufsz, "0x%02x", *(uint32_t *) val & 0xff);
+ break;
+ case 2:
+ snprintf(buf, bufsz, "0x%04x", *(uint32_t *) val & 0xffff);
+ break;
+ case 3:
+ snprintf(buf, bufsz, "0x%06x", *(uint32_t *) val & 0xffffff);
+ break;
+ case 4:
+ snprintf(buf, bufsz, "0x%08x", *(uint32_t *) val);
+ break;
+ case 5:
+ snprintf(buf, bufsz, "0x%010" PRIx64,
+ *(uint64_t *) val & (uint64_t) 0xffffffffffULL);
+ break;
+ case 6:
+ snprintf(buf, bufsz, "0x%012" PRIx64,
+ *(uint64_t *) val & (uint64_t) 0xffffffffffffULL);
+ break;
+ case 7:
+ snprintf(buf, bufsz, "0x%014" PRIx64,
+ *(uint64_t *) val & (uint64_t) 0xffffffffffffffULL);
+ break;
+ case 8:
+ snprintf(buf, bufsz, "0x%016" PRIx64, *(uint64_t *) val);
+ break;
+ default:
+ IBWARN("bad int sz %d", valsz);
+ buf[0] = 0;
+ }
+}
+
+void mad_dump_rhex(char *buf, int bufsz, void *val, int valsz)
+{
+ switch (valsz) {
+ case 1:
+ snprintf(buf, bufsz, "%02x", *(uint32_t *) val & 0xff);
+ break;
+ case 2:
+ snprintf(buf, bufsz, "%04x", *(uint32_t *) val & 0xffff);
+ break;
+ case 3:
+ snprintf(buf, bufsz, "%06x", *(uint32_t *) val & 0xffffff);
+ break;
+ case 4:
+ snprintf(buf, bufsz, "%08x", *(uint32_t *) val);
+ break;
+ case 5:
+ snprintf(buf, bufsz, "%010" PRIx64,
+ *(uint64_t *) val & (uint64_t) 0xffffffffffULL);
+ break;
+ case 6:
+ snprintf(buf, bufsz, "%012" PRIx64,
+ *(uint64_t *) val & (uint64_t) 0xffffffffffffULL);
+ break;
+ case 7:
+ snprintf(buf, bufsz, "%014" PRIx64,
+ *(uint64_t *) val & (uint64_t) 0xffffffffffffffULL);
+ break;
+ case 8:
+ snprintf(buf, bufsz, "%016" PRIx64, *(uint64_t *) val);
+ break;
+ default:
+ IBWARN("bad int sz %d", valsz);
+ buf[0] = 0;
+ }
+}
+
+void mad_dump_linkwidth(char *buf, int bufsz, void *val, int valsz)
+{
+ int width = *(int *)val;
+
+ switch (width) {
+ case 1:
+ snprintf(buf, bufsz, "1X");
+ break;
+ case 2:
+ snprintf(buf, bufsz, "4X");
+ break;
+ case 4:
+ snprintf(buf, bufsz, "8X");
+ break;
+ case 8:
+ snprintf(buf, bufsz, "12X");
+ break;
+ case 16:
+ snprintf(buf, bufsz, "2X");
+ break;
+ default:
+ IBWARN("bad width %d", width);
+ snprintf(buf, bufsz, "undefined (%d)", width);
+ break;
+ }
+}
+
+static void dump_linkwidth(char *buf, int bufsz, int width)
+{
+ int n = 0;
+
+ if (width & 0x1)
+ n += snprintf(buf + n, bufsz - n, "1X or ");
+ if (n < bufsz && (width & 0x2))
+ n += snprintf(buf + n, bufsz - n, "4X or ");
+ if (n < bufsz && (width & 0x4))
+ n += snprintf(buf + n, bufsz - n, "8X or ");
+ if (n < bufsz && (width & 0x8))
+ n += snprintf(buf + n, bufsz - n, "12X or ");
+ if (n < bufsz && (width & 0x10))
+ n += snprintf(buf + n, bufsz - n, "2X or ");
+
+ if (n >= bufsz)
+ return;
+ else if (width == 0 || (width >> 5))
+ snprintf(buf + n, bufsz - n, "undefined (%d)", width);
+ else if (bufsz > 3)
+ buf[n - 4] = '\0';
+}
+
+void mad_dump_linkwidthsup(char *buf, int bufsz, void *val, int valsz)
+{
+ int width = *(int *)val;
+
+ dump_linkwidth(buf, bufsz, width);
+
+ switch (width) {
+ case 1:
+ case 3:
+ case 7:
+ case 11:
+ case 15:
+ case 17:
+ case 19:
+ case 23:
+ case 27:
+ case 31:
+ break;
+
+ default:
+ if (!(width >> 5))
+ snprintf(buf + strlen(buf), bufsz - strlen(buf),
+ " (IBA extension)");
+ break;
+ }
+}
+
+void mad_dump_linkwidthen(char *buf, int bufsz, void *val, int valsz)
+{
+ int width = *(int *)val;
+
+ dump_linkwidth(buf, bufsz, width);
+}
+
+void mad_dump_linkspeed(char *buf, int bufsz, void *val, int valsz)
+{
+ int speed = *(int *)val;
+
+ switch (speed) {
+ case 0:
+ snprintf(buf, bufsz, "Extended speed");
+ break;
+ case 1:
+ snprintf(buf, bufsz, "2.5 Gbps");
+ break;
+ case 2:
+ snprintf(buf, bufsz, "5.0 Gbps");
+ break;
+ case 4:
+ snprintf(buf, bufsz, "10.0 Gbps");
+ break;
+ default:
+ snprintf(buf, bufsz, "undefined (%d)", speed);
+ break;
+ }
+}
+
+static void dump_linkspeed(char *buf, int bufsz, int speed)
+{
+ int n = 0;
+
+ if (speed & 0x1)
+ n += snprintf(buf + n, bufsz - n, "2.5 Gbps or ");
+ if (n < bufsz && (speed & 0x2))
+ n += snprintf(buf + n, bufsz - n, "5.0 Gbps or ");
+ if (n < bufsz && (speed & 0x4))
+ n += snprintf(buf + n, bufsz - n, "10.0 Gbps or ");
+
+ if (n >= bufsz)
+ return;
+ else if (speed == 0 || (speed >> 3)) {
+ n += snprintf(buf + n, bufsz - n, "undefined (%d)", speed);
+ if (n >= bufsz)
+ return;
+ } else if (bufsz > 3) {
+ buf[n - 4] = '\0';
+ n -= 4;
+ }
+
+ switch (speed) {
+ case 1:
+ case 3:
+ case 5:
+ case 7:
+ break;
+ default:
+ if (!(speed >> 3))
+ snprintf(buf + n, bufsz - n, " (IBA extension)");
+ break;
+ }
+}
+
+void mad_dump_linkspeedsup(char *buf, int bufsz, void *val, int valsz)
+{
+ int speed = *(int *)val;
+
+ dump_linkspeed(buf, bufsz, speed);
+}
+
+void mad_dump_linkspeeden(char *buf, int bufsz, void *val, int valsz)
+{
+ int speed = *(int *)val;
+
+ dump_linkspeed(buf, bufsz, speed);
+}
+
+void mad_dump_linkspeedext(char *buf, int bufsz, void *val, int valsz)
+{
+ int speed = *(int *)val;
+
+ switch (speed) {
+ case 0:
+ snprintf(buf, bufsz, "No Extended Speed");
+ break;
+ case 1:
+ snprintf(buf, bufsz, "14.0625 Gbps");
+ break;
+ case 2:
+ snprintf(buf, bufsz, "25.78125 Gbps");
+ break;
+ default:
+ snprintf(buf, bufsz, "undefined (%d)", speed);
+ break;
+ }
+}
+
+static void dump_linkspeedext(char *buf, int bufsz, int speed)
+{
+ int n = 0;
+
+ if (speed == 0) {
+ sprintf(buf, "%d", speed);
+ return;
+ }
+
+ if (speed & 0x1)
+ n += snprintf(buf + n, bufsz - n, "14.0625 Gbps or ");
+ if (n < bufsz && speed & 0x2)
+ n += snprintf(buf + n, bufsz - n, "25.78125 Gbps or ");
+ if (n >= bufsz) {
+ if (bufsz > 3)
+ buf[n - 4] = '\0';
+ return;
+ }
+
+ if (speed >> 2) {
+ n += snprintf(buf + n, bufsz - n, "undefined (%d)", speed);
+ return;
+ } else if (bufsz > 3)
+ buf[n - 4] = '\0';
+}
+
+void mad_dump_linkspeedextsup(char *buf, int bufsz, void *val, int valsz)
+{
+ int speed = *(int *)val;
+
+ dump_linkspeedext(buf, bufsz, speed);
+}
+
+void mad_dump_linkspeedexten(char *buf, int bufsz, void *val, int valsz)
+{
+ int speed = *(int *)val;
+
+ if (speed == 30) {
+ sprintf(buf, "%s", "Extended link speeds disabled");
+ return;
+ }
+ dump_linkspeedext(buf, bufsz, speed);
+}
+
+void mad_dump_portstate(char *buf, int bufsz, void *val, int valsz)
+{
+ int state = *(int *)val;
+
+ switch (state) {
+ case 0:
+ snprintf(buf, bufsz, "NoChange");
+ break;
+ case 1:
+ snprintf(buf, bufsz, "Down");
+ break;
+ case 2:
+ snprintf(buf, bufsz, "Initialize");
+ break;
+ case 3:
+ snprintf(buf, bufsz, "Armed");
+ break;
+ case 4:
+ snprintf(buf, bufsz, "Active");
+ break;
+ default:
+ snprintf(buf, bufsz, "?(%d)", state);
+ }
+}
+
+void mad_dump_linkdowndefstate(char *buf, int bufsz, void *val, int valsz)
+{
+ int state = *(int *)val;
+
+ switch (state) {
+ case 0:
+ snprintf(buf, bufsz, "NoChange");
+ break;
+ case 1:
+ snprintf(buf, bufsz, "Sleep");
+ break;
+ case 2:
+ snprintf(buf, bufsz, "Polling");
+ break;
+ default:
+ snprintf(buf, bufsz, "?(%d)", state);
+ break;
+ }
+}
+
+void mad_dump_physportstate(char *buf, int bufsz, void *val, int valsz)
+{
+ int state = *(int *)val;
+
+ switch (state) {
+ case 0:
+ snprintf(buf, bufsz, "NoChange");
+ break;
+ case 1:
+ snprintf(buf, bufsz, "Sleep");
+ break;
+ case 2:
+ snprintf(buf, bufsz, "Polling");
+ break;
+ case 3:
+ snprintf(buf, bufsz, "Disabled");
+ break;
+ case 4:
+ snprintf(buf, bufsz, "PortConfigurationTraining");
+ break;
+ case 5:
+ snprintf(buf, bufsz, "LinkUp");
+ break;
+ case 6:
+ snprintf(buf, bufsz, "LinkErrorRecovery");
+ break;
+ case 7:
+ snprintf(buf, bufsz, "PhyTest");
+ break;
+ default:
+ snprintf(buf, bufsz, "?(%d)", state);
+ }
+}
+
+void mad_dump_mtu(char *buf, int bufsz, void *val, int valsz)
+{
+ int mtu = *(int *)val;
+
+ switch (mtu) {
+ case 1:
+ snprintf(buf, bufsz, "256");
+ break;
+ case 2:
+ snprintf(buf, bufsz, "512");
+ break;
+ case 3:
+ snprintf(buf, bufsz, "1024");
+ break;
+ case 4:
+ snprintf(buf, bufsz, "2048");
+ break;
+ case 5:
+ snprintf(buf, bufsz, "4096");
+ break;
+ default:
+ snprintf(buf, bufsz, "?(%d)", mtu);
+ }
+}
+
+void mad_dump_vlcap(char *buf, int bufsz, void *val, int valsz)
+{
+ int vlcap = *(int *)val;
+
+ switch (vlcap) {
+ case 1:
+ snprintf(buf, bufsz, "VL0");
+ break;
+ case 2:
+ snprintf(buf, bufsz, "VL0-1");
+ break;
+ case 3:
+ snprintf(buf, bufsz, "VL0-3");
+ break;
+ case 4:
+ snprintf(buf, bufsz, "VL0-7");
+ break;
+ case 5:
+ snprintf(buf, bufsz, "VL0-14");
+ break;
+ default:
+ snprintf(buf, bufsz, "?(%d)", vlcap);
+ }
+}
+
+void mad_dump_opervls(char *buf, int bufsz, void *val, int valsz)
+{
+ int opervls = *(int *)val;
+
+ switch (opervls) {
+ case 0:
+ snprintf(buf, bufsz, "No change");
+ break;
+ case 1:
+ snprintf(buf, bufsz, "VL0");
+ break;
+ case 2:
+ snprintf(buf, bufsz, "VL0-1");
+ break;
+ case 3:
+ snprintf(buf, bufsz, "VL0-3");
+ break;
+ case 4:
+ snprintf(buf, bufsz, "VL0-7");
+ break;
+ case 5:
+ snprintf(buf, bufsz, "VL0-14");
+ break;
+ default:
+ snprintf(buf, bufsz, "?(%d)", opervls);
+ }
+}
+
+void mad_dump_portcapmask(char *buf, int bufsz, void *val, int valsz)
+{
+ unsigned mask = *(unsigned *)val;
+ char *s = buf;
+
+ s += sprintf(s, "0x%x\n", mask);
+ if (mask & (1 << 1))
+ s += sprintf(s, "\t\t\t\tIsSM\n");
+ if (mask & (1 << 2))
+ s += sprintf(s, "\t\t\t\tIsNoticeSupported\n");
+ if (mask & (1 << 3))
+ s += sprintf(s, "\t\t\t\tIsTrapSupported\n");
+ if (mask & (1 << 4))
+ s += sprintf(s, "\t\t\t\tIsOptionalIPDSupported\n");
+ if (mask & (1 << 5))
+ s += sprintf(s, "\t\t\t\tIsAutomaticMigrationSupported\n");
+ if (mask & (1 << 6))
+ s += sprintf(s, "\t\t\t\tIsSLMappingSupported\n");
+ if (mask & (1 << 7))
+ s += sprintf(s, "\t\t\t\tIsMKeyNVRAM\n");
+ if (mask & (1 << 8))
+ s += sprintf(s, "\t\t\t\tIsPKeyNVRAM\n");
+ if (mask & (1 << 9))
+ s += sprintf(s, "\t\t\t\tIsLedInfoSupported\n");
+ if (mask & (1 << 10))
+ s += sprintf(s, "\t\t\t\tIsSMdisabled\n");
+ if (mask & (1 << 11))
+ s += sprintf(s, "\t\t\t\tIsSystemImageGUIDsupported\n");
+ if (mask & (1 << 12))
+ s += sprintf(s,
+ "\t\t\t\tIsPkeySwitchExternalPortTrapSupported\n");
+ if (mask & (1 << 14))
+ s += sprintf(s, "\t\t\t\tIsExtendedSpeedsSupported\n");
+ if (mask & (1 << 15))
+ s += sprintf(s, "\t\t\t\tIsCapabilityMask2Supported\n");
+ if (mask & (1 << 16))
+ s += sprintf(s, "\t\t\t\tIsCommunicatonManagementSupported\n");
+ if (mask & (1 << 17))
+ s += sprintf(s, "\t\t\t\tIsSNMPTunnelingSupported\n");
+ if (mask & (1 << 18))
+ s += sprintf(s, "\t\t\t\tIsReinitSupported\n");
+ if (mask & (1 << 19))
+ s += sprintf(s, "\t\t\t\tIsDeviceManagementSupported\n");
+ if (mask & (1 << 20))
+ s += sprintf(s, "\t\t\t\tIsVendorClassSupported\n");
+ if (mask & (1 << 21))
+ s += sprintf(s, "\t\t\t\tIsDRNoticeSupported\n");
+ if (mask & (1 << 22))
+ s += sprintf(s, "\t\t\t\tIsCapabilityMaskNoticeSupported\n");
+ if (mask & (1 << 23))
+ s += sprintf(s, "\t\t\t\tIsBootManagementSupported\n");
+ if (mask & (1 << 24))
+ s += sprintf(s, "\t\t\t\tIsLinkRoundTripLatencySupported\n");
+ if (mask & (1 << 25))
+ s += sprintf(s, "\t\t\t\tIsClientRegistrationSupported\n");
+ if (mask & (1 << 26))
+ s += sprintf(s, "\t\t\t\tIsOtherLocalChangesNoticeSupported\n");
+ if (mask & (1 << 27))
+ s += sprintf(s,
+ "\t\t\t\tIsLinkSpeedWidthPairsTableSupported\n");
+ if (mask & (1 << 28))
+ s += sprintf(s, "\t\t\t\tIsVendorSpecificMadsTableSupported\n");
+ if (mask & (1 << 29))
+ s += sprintf(s, "\t\t\t\tIsMcastPkeyTrapSuppressionSupported\n");
+ if (mask & (1 << 30))
+ s += sprintf(s, "\t\t\t\tIsMulticastFDBTopSupported\n");
+ if (mask & (1 << 31))
+ s += sprintf(s, "\t\t\t\tIsHierarchyInfoSupported\n");
+
+ if (s != buf)
+ *(--s) = 0;
+}
+
+void mad_dump_portcapmask2(char *buf, int bufsz, void *val, int valsz)
+{
+ int mask = *(int *)val;
+ char *s = buf;
+
+ s += sprintf(s, "0x%x\n", mask);
+ if (mask & (1 << 0))
+ s += sprintf(s, "\t\t\t\tIsSetNodeDescriptionSupported\n");
+ if (mask & (1 << 1))
+ s += sprintf(s, "\t\t\t\tIsPortInfoExtendedSupported\n");
+ if (mask & (1 << 2))
+ s += sprintf(s, "\t\t\t\tIsVirtualizationSupported\n");
+ if (mask & (1 << 3))
+ s += sprintf(s, "\t\t\t\tIsSwitchPortStateTableSupported\n");
+ if (mask & (1 << 4))
+ s += sprintf(s, "\t\t\t\tIsLinkWidth2xSupported\n");
+
+ if (s != buf)
+ *(--s) = 0;
+}
+
+void mad_dump_bitfield(char *buf, int bufsz, void *val, int valsz)
+{
+ snprintf(buf, bufsz, "0x%x", *(uint32_t *) val);
+}
+
+void mad_dump_array(char *buf, int bufsz, void *val, int valsz)
+{
+ uint8_t *p = val, *e;
+ char *s = buf;
+
+ if (bufsz < valsz * 2)
+ valsz = bufsz / 2;
+
+ for (p = val, e = p + valsz; p < e; p++, s += 2)
+ sprintf(s, "%02x", *p);
+}
+
+void mad_dump_string(char *buf, int bufsz, void *val, int valsz)
+{
+ if (bufsz < valsz)
+ valsz = bufsz;
+
+ snprintf(buf, valsz, "'%s'", (char *)val);
+}
+
+void mad_dump_node_type(char *buf, int bufsz, void *val, int valsz)
+{
+ int nodetype = *(int *)val;
+
+ switch (nodetype) {
+ case 1:
+ snprintf(buf, bufsz, "Channel Adapter");
+ break;
+ case 2:
+ snprintf(buf, bufsz, "Switch");
+ break;
+ case 3:
+ snprintf(buf, bufsz, "Router");
+ break;
+ default:
+ snprintf(buf, bufsz, "?(%d)?", nodetype);
+ break;
+ }
+}
+
+#define IB_MAX_NUM_VLS 16
+#define IB_MAX_NUM_VLS_TO_U8 ((IB_MAX_NUM_VLS)/2)
+
+typedef struct _ib_slvl_table {
+ uint8_t vl_by_sl_num[IB_MAX_NUM_VLS_TO_U8];
+} ib_slvl_table_t;
+
+static inline void ib_slvl_get_i(ib_slvl_table_t * tbl, int i, uint8_t * vl)
+{
+ *vl = (tbl->vl_by_sl_num[i >> 1] >> ((!(i & 1)) << 2)) & 0xf;
+}
+
+#define IB_NUM_VL_ARB_ELEMENTS_IN_BLOCK 32
+
+typedef struct _ib_vl_arb_table {
+ struct {
+ uint8_t res_vl;
+ uint8_t weight;
+ } vl_entry[IB_NUM_VL_ARB_ELEMENTS_IN_BLOCK];
+} ib_vl_arb_table_t;
+
+static inline void ib_vl_arb_get_vl(uint8_t res_vl, uint8_t * const vl)
+{
+ *vl = res_vl & 0x0F;
+}
+
+void mad_dump_sltovl(char *buf, int bufsz, void *val, int valsz)
+{
+ ib_slvl_table_t *p_slvl_tbl = val;
+ uint8_t vl;
+ int i, n = 0;
+ n = snprintf(buf, bufsz, "|");
+ for (i = 0; i < 16; i++) {
+ ib_slvl_get_i(p_slvl_tbl, i, &vl);
+ n += snprintf(buf + n, bufsz - n, "%2u|", vl);
+ if (n >= bufsz)
+ break;
+ }
+ snprintf(buf + n, bufsz - n, "\n");
+}
+
+void mad_dump_vlarbitration(char *buf, int bufsz, void *val, int num)
+{
+ ib_vl_arb_table_t *p_vla_tbl = val;
+ int i, n;
+ uint8_t vl;
+
+ num /= sizeof(p_vla_tbl->vl_entry[0]);
+
+ n = snprintf(buf, bufsz, "\nVL : |");
+ if (n >= bufsz)
+ return;
+ for (i = 0; i < num; i++) {
+ ib_vl_arb_get_vl(p_vla_tbl->vl_entry[i].res_vl, &vl);
+ n += snprintf(buf + n, bufsz - n, "0x%-2X|", vl);
+ if (n >= bufsz)
+ return;
+ }
+
+ n += snprintf(buf + n, bufsz - n, "\nWEIGHT: |");
+ if (n >= bufsz)
+ return;
+ for (i = 0; i < num; i++) {
+ n += snprintf(buf + n, bufsz - n, "0x%-2X|",
+ p_vla_tbl->vl_entry[i].weight);
+ if (n >= bufsz)
+ return;
+ }
+
+ snprintf(buf + n, bufsz - n, "\n");
+}
+
+static int _dump_fields(char *buf, int bufsz, void *data, int start, int end)
+{
+ char val[64];
+ char *s = buf;
+ int n, field;
+
+ for (field = start; field < end && bufsz > 0; field++) {
+ mad_decode_field(data, field, val);
+ if (!mad_dump_field(field, s, bufsz-1, val))
+ return -1;
+ n = strlen(s);
+ s += n;
+ *s++ = '\n';
+ *s = 0;
+ n++;
+ bufsz -= n;
+ }
+
+ return (int)(s - buf);
+}
+
+void mad_dump_fields(char *buf, int bufsz, void *val, int valsz, int start,
+ int end)
+{
+ _dump_fields(buf, bufsz, val, start, end);
+}
+
+void mad_dump_nodedesc(char *buf, int bufsz, void *val, int valsz)
+{
+ strncpy(buf, val, bufsz);
+
+ if (valsz < bufsz)
+ buf[valsz] = 0;
+}
+
+void mad_dump_nodeinfo(char *buf, int bufsz, void *val, int valsz)
+{
+ _dump_fields(buf, bufsz, val, IB_NODE_FIRST_F, IB_NODE_LAST_F);
+}
+
+void mad_dump_portinfo(char *buf, int bufsz, void *val, int valsz)
+{
+ int cnt;
+
+ cnt = _dump_fields(buf, bufsz, val, IB_PORT_FIRST_F, IB_PORT_LAST_F);
+ if (cnt < 0)
+ return;
+
+ _dump_fields(buf + cnt, bufsz - cnt, val,
+ IB_PORT_CAPMASK2_F, IB_PORT_LINK_SPEED_EXT_LAST_F);
+}
+
+void mad_dump_portstates(char *buf, int bufsz, void *val, int valsz)
+{
+ _dump_fields(buf, bufsz, val, IB_PORT_STATE_F, IB_PORT_LINK_DOWN_DEF_F);
+}
+
+void mad_dump_switchinfo(char *buf, int bufsz, void *val, int valsz)
+{
+ _dump_fields(buf, bufsz, val, IB_SW_FIRST_F, IB_SW_LAST_F);
+}
+
+void mad_dump_perfcounters(char *buf, int bufsz, void *val, int valsz)
+{
+ int cnt, cnt2;
+
+ cnt = _dump_fields(buf, bufsz, val,
+ IB_PC_FIRST_F, IB_PC_VL15_DROPPED_F);
+ if (cnt < 0)
+ return;
+
+ cnt2 = _dump_fields(buf + cnt, bufsz - cnt, val,
+ IB_PC_QP1_DROP_F, IB_PC_QP1_DROP_F + 1);
+ if (cnt2 < 0)
+ return;
+
+ _dump_fields(buf + cnt + cnt2, bufsz - cnt - cnt2, val,
+ IB_PC_VL15_DROPPED_F, IB_PC_LAST_F);
+}
+
+void mad_dump_perfcounters_ext(char *buf, int bufsz, void *val, int valsz)
+{
+ int cnt;
+
+ cnt = _dump_fields(buf, bufsz, val, IB_PC_EXT_FIRST_F, IB_PC_EXT_LAST_F);
+ if (cnt < 0)
+ return;
+
+ _dump_fields(buf + cnt, bufsz - cnt, val,
+ IB_PC_EXT_COUNTER_SELECT2_F, IB_PC_EXT_ERR_LAST_F);
+}
+
+void mad_dump_perfcounters_xmt_sl(char *buf, int bufsz, void *val, int valsz)
+{
+ int cnt;
+
+ cnt = _dump_fields(buf, bufsz, val, IB_PC_EXT_PORT_SELECT_F,
+ IB_PC_EXT_XMT_BYTES_F);
+ if (cnt < 0)
+ return;
+
+ _dump_fields(buf + cnt, bufsz - cnt, val, IB_PC_XMT_DATA_SL_FIRST_F,
+ IB_PC_XMT_DATA_SL_LAST_F);
+}
+
+void mad_dump_perfcounters_rcv_sl(char *buf, int bufsz, void *val, int valsz)
+{
+ int cnt;
+
+ cnt = _dump_fields(buf, bufsz, val, IB_PC_EXT_PORT_SELECT_F,
+ IB_PC_EXT_XMT_BYTES_F);
+ if (cnt < 0)
+ return;
+
+ _dump_fields(buf + cnt, bufsz - cnt, val, IB_PC_RCV_DATA_SL_FIRST_F,
+ IB_PC_RCV_DATA_SL_LAST_F);
+}
+
+void mad_dump_perfcounters_xmt_disc(char *buf, int bufsz, void *val, int valsz)
+{
+ int cnt;
+
+ cnt = _dump_fields(buf, bufsz, val, IB_PC_EXT_PORT_SELECT_F,
+ IB_PC_EXT_XMT_BYTES_F);
+ if (cnt < 0)
+ return;
+
+ _dump_fields(buf + cnt, bufsz - cnt, val, IB_PC_XMT_INACT_DISC_F,
+ IB_PC_XMT_DISC_LAST_F);
+}
+
+void mad_dump_perfcounters_rcv_err(char *buf, int bufsz, void *val, int valsz)
+{
+ int cnt;
+
+ cnt = _dump_fields(buf, bufsz, val, IB_PC_EXT_PORT_SELECT_F,
+ IB_PC_EXT_XMT_BYTES_F);
+ if (cnt < 0)
+ return;
+
+ _dump_fields(buf + cnt, bufsz - cnt, val, IB_PC_RCV_LOCAL_PHY_ERR_F,
+ IB_PC_RCV_ERR_LAST_F);
+}
+
+void mad_dump_portsamples_control(char *buf, int bufsz, void *val, int valsz)
+{
+ _dump_fields(buf, bufsz, val, IB_PSC_OPCODE_F, IB_PSC_LAST_F);
+}
+
+void mad_dump_port_ext_speeds_counters_rsfec_active(char *buf, int bufsz,
+ void *val, int valsz)
+{
+ _dump_fields(buf, bufsz, val, IB_PESC_RSFEC_PORT_SELECT_F,
+ IB_PESC_RSFEC_LAST_F);
+}
+
+void mad_dump_port_ext_speeds_counters(char *buf, int bufsz, void *val, int valsz)
+{
+ _dump_fields(buf, bufsz, val, IB_PESC_PORT_SELECT_F, IB_PESC_LAST_F);
+}
+
+void mad_dump_perfcounters_port_op_rcv_counters(char *buf, int bufsz, void *val, int valsz)
+{
+ int cnt;
+
+ cnt = _dump_fields(buf, bufsz, val, IB_PC_EXT_PORT_SELECT_F,
+ IB_PC_EXT_XMT_BYTES_F);
+ if (cnt < 0)
+ return;
+
+ _dump_fields(buf + cnt, bufsz - cnt, val, IB_PC_PORT_OP_RCV_COUNTERS_FIRST_F,
+ IB_PC_PORT_OP_RCV_COUNTERS_LAST_F);
+}
+
+void mad_dump_perfcounters_port_flow_ctl_counters(char *buf, int bufsz, void *val, int valsz)
+{
+ int cnt;
+
+ cnt = _dump_fields(buf, bufsz, val, IB_PC_EXT_PORT_SELECT_F,
+ IB_PC_EXT_XMT_BYTES_F);
+ if (cnt < 0)
+ return;
+
+ _dump_fields(buf + cnt, bufsz - cnt, val, IB_PC_PORT_FLOW_CTL_COUNTERS_FIRST_F,
+ IB_PC_PORT_FLOW_CTL_COUNTERS_LAST_F);
+}
+
+void mad_dump_perfcounters_port_vl_op_packet(char *buf, int bufsz, void *val, int valsz)
+{
+ int cnt;
+
+ cnt = _dump_fields(buf, bufsz, val, IB_PC_EXT_PORT_SELECT_F,
+ IB_PC_EXT_XMT_BYTES_F);
+ if (cnt < 0)
+ return;
+
+ _dump_fields(buf + cnt, bufsz - cnt, val, IB_PC_PORT_VL_OP_PACKETS_FIRST_F,
+ IB_PC_PORT_VL_OP_PACKETS_LAST_F);
+}
+
+void mad_dump_perfcounters_port_vl_op_data(char *buf, int bufsz, void *val, int valsz)
+{
+ int cnt;
+
+ cnt = _dump_fields(buf, bufsz, val, IB_PC_EXT_PORT_SELECT_F,
+ IB_PC_EXT_XMT_BYTES_F);
+ if (cnt < 0)
+ return;
+
+ _dump_fields(buf + cnt, bufsz - cnt, val, IB_PC_PORT_VL_OP_DATA_FIRST_F,
+ IB_PC_PORT_VL_OP_DATA_LAST_F);
+}
+
+void mad_dump_perfcounters_port_vl_xmit_flow_ctl_update_errors(char *buf, int bufsz, void *val, int valsz)
+{
+ int cnt;
+
+ cnt = _dump_fields(buf, bufsz, val, IB_PC_EXT_PORT_SELECT_F,
+ IB_PC_EXT_XMT_BYTES_F);
+ if (cnt < 0)
+ return;
+
+ _dump_fields(buf + cnt, bufsz - cnt, val, IB_PC_PORT_VL_XMIT_FLOW_CTL_UPDATE_ERRORS_FIRST_F,
+ IB_PC_PORT_VL_XMIT_FLOW_CTL_UPDATE_ERRORS_LAST_F);
+}
+
+void mad_dump_perfcounters_port_vl_xmit_wait_counters(char *buf, int bufsz, void *val, int valsz)
+{
+ int cnt;
+
+ cnt = _dump_fields(buf, bufsz, val, IB_PC_EXT_PORT_SELECT_F,
+ IB_PC_EXT_XMT_BYTES_F);
+ if (cnt < 0)
+ return;
+
+ _dump_fields(buf + cnt, bufsz - cnt, val, IB_PC_PORT_VL_XMIT_WAIT_COUNTERS_FIRST_F,
+ IB_PC_PORT_VL_XMIT_WAIT_COUNTERS_LAST_F);
+}
+
+void mad_dump_perfcounters_sw_port_vl_congestion(char *buf, int bufsz, void *val, int valsz)
+{
+ int cnt;
+
+ cnt = _dump_fields(buf, bufsz, val, IB_PC_EXT_PORT_SELECT_F,
+ IB_PC_EXT_XMT_BYTES_F);
+ if (cnt < 0)
+ return;
+
+ _dump_fields(buf + cnt, bufsz - cnt, val, IB_PC_SW_PORT_VL_CONGESTION_FIRST_F,
+ IB_PC_SW_PORT_VL_CONGESTION_LAST_F);
+}
+
+void mad_dump_perfcounters_rcv_con_ctrl(char *buf, int bufsz, void *val, int valsz)
+{
+ int cnt;
+
+ cnt = _dump_fields(buf, bufsz, val, IB_PC_EXT_PORT_SELECT_F,
+ IB_PC_EXT_XMT_BYTES_F);
+ if (cnt < 0)
+ return;
+
+ _dump_fields(buf + cnt, bufsz - cnt, val, IB_PC_RCV_CON_CTRL_FIRST_F,
+ IB_PC_RCV_CON_CTRL_LAST_F);
+}
+
+
+void mad_dump_perfcounters_sl_rcv_fecn(char *buf, int bufsz, void *val, int valsz)
+{
+ int cnt;
+
+ cnt = _dump_fields(buf, bufsz, val, IB_PC_EXT_PORT_SELECT_F,
+ IB_PC_EXT_XMT_BYTES_F);
+ if (cnt < 0)
+ return;
+
+ _dump_fields(buf + cnt, bufsz - cnt, val, IB_PC_SL_RCV_FECN_FIRST_F,
+ IB_PC_SL_RCV_FECN_LAST_F);
+}
+
+void mad_dump_perfcounters_sl_rcv_becn(char *buf, int bufsz, void *val, int valsz)
+{
+ int cnt;
+
+ cnt = _dump_fields(buf, bufsz, val, IB_PC_EXT_PORT_SELECT_F,
+ IB_PC_EXT_XMT_BYTES_F);
+ if (cnt < 0)
+ return;
+
+ _dump_fields(buf + cnt, bufsz - cnt, val, IB_PC_SL_RCV_BECN_FIRST_F,
+ IB_PC_SL_RCV_BECN_LAST_F);
+}
+
+void mad_dump_perfcounters_xmit_con_ctrl(char *buf, int bufsz, void *val, int valsz)
+{
+ int cnt;
+
+ cnt = _dump_fields(buf, bufsz, val, IB_PC_EXT_PORT_SELECT_F,
+ IB_PC_EXT_XMT_BYTES_F);
+ if (cnt < 0)
+ return;
+
+ _dump_fields(buf + cnt, bufsz - cnt, val, IB_PC_XMIT_CON_CTRL_FIRST_F,
+ IB_PC_XMIT_CON_CTRL_LAST_F);
+}
+
+void mad_dump_perfcounters_vl_xmit_time_cong(char *buf, int bufsz, void *val, int valsz)
+{
+ int cnt;
+
+ cnt = _dump_fields(buf, bufsz, val, IB_PC_EXT_PORT_SELECT_F,
+ IB_PC_EXT_XMT_BYTES_F);
+ if (cnt < 0)
+ return;
+
+ _dump_fields(buf + cnt, bufsz - cnt, val, IB_PC_VL_XMIT_TIME_CONG_FIRST_F,
+ IB_PC_VL_XMIT_TIME_CONG_LAST_F);
+}
+
+void mad_dump_mlnx_ext_port_info(char *buf, int bufsz, void *val, int valsz)
+{
+ _dump_fields(buf, bufsz, val, IB_MLNX_EXT_PORT_STATE_CHG_ENABLE_F,
+ IB_MLNX_EXT_PORT_LAST_F);
+}
+
+void mad_dump_portsamples_result(char *buf, int bufsz, void *val, int valsz)
+{
+ _dump_fields(buf, bufsz, val, IB_PSR_TAG_F, IB_PSR_LAST_F);
+}
+
+void mad_dump_cc_congestioninfo(char *buf, int bufsz, void *val, int valsz)
+{
+ _dump_fields(buf, bufsz, val, IB_CC_CONGESTION_INFO_FIRST_F,
+ IB_CC_CONGESTION_INFO_LAST_F);
+}
+
+void mad_dump_cc_congestionkeyinfo(char *buf, int bufsz, void *val, int valsz)
+{
+ _dump_fields(buf, bufsz, val, IB_CC_CONGESTION_KEY_INFO_FIRST_F,
+ IB_CC_CONGESTION_KEY_INFO_LAST_F);
+}
+
+void mad_dump_cc_congestionlog(char *buf, int bufsz, void *val, int valsz)
+{
+ _dump_fields(buf, bufsz, val, IB_CC_CONGESTION_LOG_FIRST_F,
+ IB_CC_CONGESTION_LOG_LAST_F);
+}
+
+void mad_dump_cc_congestionlogswitch(char *buf, int bufsz, void *val, int valsz)
+{
+ _dump_fields(buf, bufsz, val, IB_CC_CONGESTION_LOG_SWITCH_FIRST_F,
+ IB_CC_CONGESTION_LOG_SWITCH_LAST_F);
+}
+
+void mad_dump_cc_congestionlogentryswitch(char *buf, int bufsz, void *val, int valsz)
+{
+ _dump_fields(buf, bufsz, val, IB_CC_CONGESTION_LOG_ENTRY_SWITCH_FIRST_F,
+ IB_CC_CONGESTION_LOG_ENTRY_SWITCH_LAST_F);
+}
+
+void mad_dump_cc_congestionlogca(char *buf, int bufsz, void *val, int valsz)
+{
+ _dump_fields(buf, bufsz, val, IB_CC_CONGESTION_LOG_CA_FIRST_F,
+ IB_CC_CONGESTION_LOG_CA_LAST_F);
+}
+
+void mad_dump_cc_congestionlogentryca(char *buf, int bufsz, void *val, int valsz)
+{
+ _dump_fields(buf, bufsz, val, IB_CC_CONGESTION_LOG_ENTRY_CA_FIRST_F,
+ IB_CC_CONGESTION_LOG_ENTRY_CA_LAST_F);
+}
+
+void mad_dump_cc_switchcongestionsetting(char *buf, int bufsz, void *val, int valsz)
+{
+ _dump_fields(buf, bufsz, val, IB_CC_SWITCH_CONGESTION_SETTING_FIRST_F,
+ IB_CC_SWITCH_CONGESTION_SETTING_LAST_F);
+}
+
+void mad_dump_cc_switchportcongestionsettingelement(char *buf, int bufsz, void *val, int valsz)
+{
+ _dump_fields(buf, bufsz, val, IB_CC_SWITCH_PORT_CONGESTION_SETTING_ELEMENT_FIRST_F,
+ IB_CC_SWITCH_PORT_CONGESTION_SETTING_ELEMENT_LAST_F);
+}
+
+void mad_dump_cc_cacongestionsetting(char *buf, int bufsz, void *val, int valsz)
+{
+ _dump_fields(buf, bufsz, val, IB_CC_CA_CONGESTION_SETTING_FIRST_F,
+ IB_CC_CA_CONGESTION_SETTING_LAST_F);
+}
+
+void mad_dump_cc_cacongestionentry(char *buf, int bufsz, void *val, int valsz)
+{
+ _dump_fields(buf, bufsz, val, IB_CC_CA_CONGESTION_ENTRY_FIRST_F,
+ IB_CC_CA_CONGESTION_ENTRY_LAST_F);
+}
+
+void mad_dump_cc_congestioncontroltable(char *buf, int bufsz, void *val, int valsz)
+{
+ _dump_fields(buf, bufsz, val, IB_CC_CONGESTION_CONTROL_TABLE_FIRST_F,
+ IB_CC_CONGESTION_CONTROL_TABLE_LAST_F);
+}
+
+void mad_dump_cc_congestioncontroltableentry(char *buf, int bufsz, void *val, int valsz)
+{
+ _dump_fields(buf, bufsz, val, IB_CC_CONGESTION_CONTROL_TABLE_ENTRY_FIRST_F,
+ IB_CC_CONGESTION_CONTROL_TABLE_ENTRY_LAST_F);
+}
+
+void mad_dump_cc_timestamp(char *buf, int bufsz, void *val, int valsz)
+{
+ _dump_fields(buf, bufsz, val, IB_CC_TIMESTAMP_FIRST_F,
+ IB_CC_TIMESTAMP_LAST_F);
+}
+
+void mad_dump_classportinfo(char *buf, int bufsz, void *val, int valsz)
+{
+ /* no FIRST_F and LAST_F for CPI field enums, must do a hack */
+ _dump_fields(buf, bufsz, val, IB_CPI_BASEVER_F, IB_CPI_TRAP_QKEY_F + 1);
+}
+
+void mad_dump_portmirror_route(char *buf, int bufsz, void *val, int valsz)
+{
+ _dump_fields(buf, bufsz, val, IB_PMR_FIRST_F, IB_PMR_LAST_F);
+}
+
+void mad_dump_portmirror_filter(char *buf, int bufsz, void *val, int valsz)
+{
+ _dump_fields(buf, bufsz, val, IB_PMF_FIRST_F, IB_PMF_LAST_F);
+}
+
+void mad_dump_portmirror_ports(char *buf, int bufsz, void *val, int valsz)
+{
+ _dump_fields(buf, bufsz, val, IB_PMP_FIRST_F, IB_PMP_LAST_F);
+}
+
+void mad_dump_portinfo_ext(char *buf, int bufsz, void *val, int valsz)
+{
+ _dump_fields(buf, bufsz, val, IB_PORT_EXT_CAPMASK_F,
+ IB_PORT_EXT_LAST_F);
+}
+
+void xdump(FILE * file, char *msg, void *p, int size)
+{
+#define HEX(x) ((x) < 10 ? '0' + (x) : 'a' + ((x) -10))
+ uint8_t *cp = p;
+ int i;
+
+ if (msg)
+ fputs(msg, file);
+
+ for (i = 0; i < size;) {
+ fputc(HEX(*cp >> 4), file);
+ fputc(HEX(*cp & 0xf), file);
+ if (++i >= size)
+ break;
+ fputc(HEX(cp[1] >> 4), file);
+ fputc(HEX(cp[1] & 0xf), file);
+ if ((++i) % 16)
+ fputc(' ', file);
+ else
+ fputc('\n', file);
+ cp += 2;
+ }
+ if (i % 16)
+ fputc('\n', file);
+}
diff --git a/contrib/ofed/libibmad/fields.c b/contrib/ofed/libibmad/fields.c
new file mode 100644
index 0000000..45aa286
--- /dev/null
+++ b/contrib/ofed/libibmad/fields.c
@@ -0,0 +1,1380 @@
+/*
+ * Copyright (c) 2004-2009 Voltaire Inc. All rights reserved.
+ * Copyright (c) 2009 HNR Consulting. All rights reserved.
+ * Copyright (c) 2009-2011 Mellanox Technologies LTD. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+#if HAVE_CONFIG_H
+# include <config.h>
+#endif /* HAVE_CONFIG_H */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include <infiniband/mad.h>
+
+/*
+ * BITSOFFS and BE_OFFS are required due the fact that the bit offsets are inconsistently
+ * encoded in the IB spec - IB headers are encoded such that the bit offsets
+ * are in big endian convention (BE_OFFS), while the SMI/GSI queries data fields bit
+ * offsets are specified using real bit offset (?!)
+ * The following macros normalize everything to big endian offsets.
+ */
+#define BITSOFFS(o, w) (((o) & ~31) | ((32 - ((o) & 31) - (w)))), (w)
+#define BE_OFFS(o, w) (o), (w)
+#define BE_TO_BITSOFFS(o, w) (((o) & ~31) | ((32 - ((o) & 31) - (w))))
+
+static const ib_field_t ib_mad_f[] = {
+ {0, 0}, /* IB_NO_FIELD - reserved as invalid */
+
+ {0, 64, "GidPrefix", mad_dump_rhex},
+ {64, 64, "GidGuid", mad_dump_rhex},
+
+ /*
+ * MAD: common MAD fields (IB spec 13.4.2)
+ * SMP: Subnet Management packets - lid routed (IB spec 14.2.1.1)
+ * DSMP: Subnet Management packets - direct route (IB spec 14.2.1.2)
+ * SA: Subnet Administration packets (IB spec 15.2.1.1)
+ */
+
+ /* first MAD word (0-3 bytes) */
+ {BE_OFFS(0, 7), "MadMethod", mad_dump_hex}, /* TODO: add dumper */
+ {BE_OFFS(7, 1), "MadIsResponse", mad_dump_uint}, /* TODO: add dumper */
+ {BE_OFFS(8, 8), "MadClassVersion", mad_dump_uint},
+ {BE_OFFS(16, 8), "MadMgmtClass", mad_dump_uint}, /* TODO: add dumper */
+ {BE_OFFS(24, 8), "MadBaseVersion", mad_dump_uint},
+
+ /* second MAD word (4-7 bytes) */
+ {BE_OFFS(48, 16), "MadStatus", mad_dump_hex}, /* TODO: add dumper */
+
+ /* DR SMP only */
+ {BE_OFFS(32, 8), "DrSmpHopCnt", mad_dump_uint},
+ {BE_OFFS(40, 8), "DrSmpHopPtr", mad_dump_uint},
+ {BE_OFFS(48, 15), "DrSmpStatus", mad_dump_hex}, /* TODO: add dumper */
+ {BE_OFFS(63, 1), "DrSmpDirection", mad_dump_uint}, /* TODO: add dumper */
+
+ /* words 3,4,5,6 (8-23 bytes) */
+ {64, 64, "MadTRID", mad_dump_hex},
+ {BE_OFFS(144, 16), "MadAttr", mad_dump_hex}, /* TODO: add dumper */
+ {160, 32, "MadModifier", mad_dump_hex}, /* TODO: add dumper */
+
+ /* word 7,8 (24-31 bytes) */
+ {192, 64, "MadMkey", mad_dump_hex},
+
+ /* word 9 (32-37 bytes) */
+ {BE_OFFS(256, 16), "DrSmpDLID", mad_dump_uint},
+ {BE_OFFS(272, 16), "DrSmpSLID", mad_dump_uint},
+
+ /* word 10,11 (36-43 bytes) */
+ {288, 64, "SaSMkey", mad_dump_hex},
+
+ /* word 12 (44-47 bytes) */
+ {BE_OFFS(46 * 8, 16), "SaAttrOffs", mad_dump_uint},
+
+ /* word 13,14 (48-55 bytes) */
+ {48 * 8, 64, "SaCompMask", mad_dump_hex},
+
+ /* word 13,14 (56-255 bytes) */
+ {56 * 8, (256 - 56) * 8, "SaData", mad_dump_hex},
+
+ /* bytes 64 - 127 */
+ {0, 0}, /* IB_SM_DATA_F - reserved as invalid */
+
+ /* bytes 64 - 256 */
+ {64 * 8, (256 - 64) * 8, "GsData", mad_dump_hex},
+
+ /* bytes 128 - 191 */
+ {1024, 512, "DrSmpPath", mad_dump_hex},
+
+ /* bytes 192 - 255 */
+ {1536, 512, "DrSmpRetPath", mad_dump_hex},
+
+ /*
+ * PortInfo fields
+ */
+ {0, 64, "Mkey", mad_dump_hex},
+ {64, 64, "GidPrefix", mad_dump_hex},
+ {BITSOFFS(128, 16), "Lid", mad_dump_uint},
+ {BITSOFFS(144, 16), "SMLid", mad_dump_uint},
+ {160, 32, "CapMask", mad_dump_portcapmask},
+ {BITSOFFS(192, 16), "DiagCode", mad_dump_hex},
+ {BITSOFFS(208, 16), "MkeyLeasePeriod", mad_dump_uint},
+ {BITSOFFS(224, 8), "LocalPort", mad_dump_uint},
+ {BITSOFFS(232, 8), "LinkWidthEnabled", mad_dump_linkwidthen},
+ {BITSOFFS(240, 8), "LinkWidthSupported", mad_dump_linkwidthsup},
+ {BITSOFFS(248, 8), "LinkWidthActive", mad_dump_linkwidth},
+ {BITSOFFS(256, 4), "LinkSpeedSupported", mad_dump_linkspeedsup},
+ {BITSOFFS(260, 4), "LinkState", mad_dump_portstate},
+ {BITSOFFS(264, 4), "PhysLinkState", mad_dump_physportstate},
+ {BITSOFFS(268, 4), "LinkDownDefState", mad_dump_linkdowndefstate},
+ {BITSOFFS(272, 2), "ProtectBits", mad_dump_uint},
+ {BITSOFFS(277, 3), "LMC", mad_dump_uint},
+ {BITSOFFS(280, 4), "LinkSpeedActive", mad_dump_linkspeed},
+ {BITSOFFS(284, 4), "LinkSpeedEnabled", mad_dump_linkspeeden},
+ {BITSOFFS(288, 4), "NeighborMTU", mad_dump_mtu},
+ {BITSOFFS(292, 4), "SMSL", mad_dump_uint},
+ {BITSOFFS(296, 4), "VLCap", mad_dump_vlcap},
+ {BITSOFFS(300, 4), "InitType", mad_dump_hex},
+ {BITSOFFS(304, 8), "VLHighLimit", mad_dump_uint},
+ {BITSOFFS(312, 8), "VLArbHighCap", mad_dump_uint},
+ {BITSOFFS(320, 8), "VLArbLowCap", mad_dump_uint},
+ {BITSOFFS(328, 4), "InitReply", mad_dump_hex},
+ {BITSOFFS(332, 4), "MtuCap", mad_dump_mtu},
+ {BITSOFFS(336, 3), "VLStallCount", mad_dump_uint},
+ {BITSOFFS(339, 5), "HoqLife", mad_dump_uint},
+ {BITSOFFS(344, 4), "OperVLs", mad_dump_opervls},
+ {BITSOFFS(348, 1), "PartEnforceInb", mad_dump_uint},
+ {BITSOFFS(349, 1), "PartEnforceOutb", mad_dump_uint},
+ {BITSOFFS(350, 1), "FilterRawInb", mad_dump_uint},
+ {BITSOFFS(351, 1), "FilterRawOutb", mad_dump_uint},
+ {BITSOFFS(352, 16), "MkeyViolations", mad_dump_uint},
+ {BITSOFFS(368, 16), "PkeyViolations", mad_dump_uint},
+ {BITSOFFS(384, 16), "QkeyViolations", mad_dump_uint},
+ {BITSOFFS(400, 8), "GuidCap", mad_dump_uint},
+ {BITSOFFS(408, 1), "ClientReregister", mad_dump_uint},
+ {BITSOFFS(409, 1), "McastPkeyTrapSuppressionEnabled", mad_dump_uint},
+ {BITSOFFS(411, 5), "SubnetTimeout", mad_dump_uint},
+ {BITSOFFS(419, 5), "RespTimeVal", mad_dump_uint},
+ {BITSOFFS(424, 4), "LocalPhysErr", mad_dump_uint},
+ {BITSOFFS(428, 4), "OverrunErr", mad_dump_uint},
+ {BITSOFFS(432, 16), "MaxCreditHint", mad_dump_uint},
+ {BITSOFFS(456, 24), "RoundTrip", mad_dump_uint},
+ {0, 0}, /* IB_PORT_LAST_F */
+
+ /*
+ * NodeInfo fields
+ */
+ {BITSOFFS(0, 8), "BaseVers", mad_dump_uint},
+ {BITSOFFS(8, 8), "ClassVers", mad_dump_uint},
+ {BITSOFFS(16, 8), "NodeType", mad_dump_node_type},
+ {BITSOFFS(24, 8), "NumPorts", mad_dump_uint},
+ {32, 64, "SystemGuid", mad_dump_hex},
+ {96, 64, "Guid", mad_dump_hex},
+ {160, 64, "PortGuid", mad_dump_hex},
+ {BITSOFFS(224, 16), "PartCap", mad_dump_uint},
+ {BITSOFFS(240, 16), "DevId", mad_dump_hex},
+ {256, 32, "Revision", mad_dump_hex},
+ {BITSOFFS(288, 8), "LocalPort", mad_dump_uint},
+ {BITSOFFS(296, 24), "VendorId", mad_dump_hex},
+ {0, 0}, /* IB_NODE_LAST_F */
+
+ /*
+ * SwitchInfo fields
+ */
+ {BITSOFFS(0, 16), "LinearFdbCap", mad_dump_uint},
+ {BITSOFFS(16, 16), "RandomFdbCap", mad_dump_uint},
+ {BITSOFFS(32, 16), "McastFdbCap", mad_dump_uint},
+ {BITSOFFS(48, 16), "LinearFdbTop", mad_dump_uint},
+ {BITSOFFS(64, 8), "DefPort", mad_dump_uint},
+ {BITSOFFS(72, 8), "DefMcastPrimPort", mad_dump_uint},
+ {BITSOFFS(80, 8), "DefMcastNotPrimPort", mad_dump_uint},
+ {BITSOFFS(88, 5), "LifeTime", mad_dump_uint},
+ {BITSOFFS(93, 1), "StateChange", mad_dump_uint},
+ {BITSOFFS(94, 2), "OptSLtoVLMapping", mad_dump_uint},
+ {BITSOFFS(96, 16), "LidsPerPort", mad_dump_uint},
+ {BITSOFFS(112, 16), "PartEnforceCap", mad_dump_uint},
+ {BITSOFFS(128, 1), "InboundPartEnf", mad_dump_uint},
+ {BITSOFFS(129, 1), "OutboundPartEnf", mad_dump_uint},
+ {BITSOFFS(130, 1), "FilterRawInbound", mad_dump_uint},
+ {BITSOFFS(131, 1), "FilterRawOutbound", mad_dump_uint},
+ {BITSOFFS(132, 1), "EnhancedPort0", mad_dump_uint},
+ {BITSOFFS(144, 16), "MulticastFDBTop", mad_dump_hex},
+ {0, 0}, /* IB_SW_LAST_F */
+
+ /*
+ * SwitchLinearForwardingTable fields
+ */
+ {0, 512, "LinearForwTbl", mad_dump_array},
+
+ /*
+ * SwitchMulticastForwardingTable fields
+ */
+ {0, 512, "MulticastForwTbl", mad_dump_array},
+
+ /*
+ * NodeDescription fields
+ */
+ {0, 64 * 8, "NodeDesc", mad_dump_string},
+
+ /*
+ * Notice/Trap fields
+ */
+ {BITSOFFS(0, 1), "NoticeIsGeneric", mad_dump_uint},
+ {BITSOFFS(1, 7), "NoticeType", mad_dump_uint},
+ {BITSOFFS(8, 24), "NoticeProducerType", mad_dump_node_type},
+ {BITSOFFS(32, 16), "NoticeTrapNumber", mad_dump_uint},
+ {BITSOFFS(48, 16), "NoticeIssuerLID", mad_dump_uint},
+ {BITSOFFS(64, 1), "NoticeToggle", mad_dump_uint},
+ {BITSOFFS(65, 15), "NoticeCount", mad_dump_uint},
+ {80, 432, "NoticeDataDetails", mad_dump_array},
+ {BITSOFFS(80, 16), "NoticeDataLID", mad_dump_uint},
+ {BITSOFFS(96, 16), "NoticeDataTrap144LID", mad_dump_uint},
+ {BITSOFFS(128, 32), "NoticeDataTrap144CapMask", mad_dump_uint},
+
+ /*
+ * Port counters
+ */
+ {BITSOFFS(8, 8), "PortSelect", mad_dump_uint},
+ {BITSOFFS(16, 16), "CounterSelect", mad_dump_hex},
+ {BITSOFFS(32, 16), "SymbolErrorCounter", mad_dump_uint},
+ {BITSOFFS(48, 8), "LinkErrorRecoveryCounter", mad_dump_uint},
+ {BITSOFFS(56, 8), "LinkDownedCounter", mad_dump_uint},
+ {BITSOFFS(64, 16), "PortRcvErrors", mad_dump_uint},
+ {BITSOFFS(80, 16), "PortRcvRemotePhysicalErrors", mad_dump_uint},
+ {BITSOFFS(96, 16), "PortRcvSwitchRelayErrors", mad_dump_uint},
+ {BITSOFFS(112, 16), "PortXmitDiscards", mad_dump_uint},
+ {BITSOFFS(128, 8), "PortXmitConstraintErrors", mad_dump_uint},
+ {BITSOFFS(136, 8), "PortRcvConstraintErrors", mad_dump_uint},
+ {BITSOFFS(144, 8), "CounterSelect2", mad_dump_hex},
+ {BITSOFFS(152, 4), "LocalLinkIntegrityErrors", mad_dump_uint},
+ {BITSOFFS(156, 4), "ExcessiveBufferOverrunErrors", mad_dump_uint},
+ {BITSOFFS(176, 16), "VL15Dropped", mad_dump_uint},
+ {192, 32, "PortXmitData", mad_dump_uint},
+ {224, 32, "PortRcvData", mad_dump_uint},
+ {256, 32, "PortXmitPkts", mad_dump_uint},
+ {288, 32, "PortRcvPkts", mad_dump_uint},
+ {320, 32, "PortXmitWait", mad_dump_uint},
+ {0, 0}, /* IB_PC_LAST_F */
+
+ /*
+ * SMInfo
+ */
+ {0, 64, "SmInfoGuid", mad_dump_hex},
+ {64, 64, "SmInfoKey", mad_dump_hex},
+ {128, 32, "SmActivity", mad_dump_uint},
+ {BITSOFFS(160, 4), "SmPriority", mad_dump_uint},
+ {BITSOFFS(164, 4), "SmState", mad_dump_uint},
+
+ /*
+ * SA RMPP
+ */
+ {BE_OFFS(24 * 8 + 24, 8), "RmppVers", mad_dump_uint},
+ {BE_OFFS(24 * 8 + 16, 8), "RmppType", mad_dump_uint},
+ {BE_OFFS(24 * 8 + 11, 5), "RmppResp", mad_dump_uint},
+ {BE_OFFS(24 * 8 + 8, 3), "RmppFlags", mad_dump_hex},
+ {BE_OFFS(24 * 8 + 0, 8), "RmppStatus", mad_dump_hex},
+
+ /* data1 */
+ {28 * 8, 32, "RmppData1", mad_dump_hex},
+ {28 * 8, 32, "RmppSegNum", mad_dump_uint},
+ /* data2 */
+ {32 * 8, 32, "RmppData2", mad_dump_hex},
+ {32 * 8, 32, "RmppPayload", mad_dump_uint},
+ {32 * 8, 32, "RmppNewWin", mad_dump_uint},
+
+ /*
+ * SA Get Multi Path
+ */
+ {BITSOFFS(41, 7), "MultiPathNumPath", mad_dump_uint},
+ {BITSOFFS(120, 8), "MultiPathNumSrc", mad_dump_uint},
+ {BITSOFFS(128, 8), "MultiPathNumDest", mad_dump_uint},
+ {192, 128, "MultiPathGid", mad_dump_array},
+
+ /*
+ * SA Path rec
+ */
+ {64, 128, "PathRecDGid", mad_dump_array},
+ {192, 128, "PathRecSGid", mad_dump_array},
+ {BITSOFFS(320, 16), "PathRecDLid", mad_dump_uint},
+ {BITSOFFS(336, 16), "PathRecSLid", mad_dump_uint},
+ {BITSOFFS(393, 7), "PathRecNumPath", mad_dump_uint},
+ {BITSOFFS(428, 4), "PathRecSL", mad_dump_uint},
+
+ /*
+ * MC Member rec
+ */
+ {0, 128, "McastMemMGid", mad_dump_array},
+ {128, 128, "McastMemPortGid", mad_dump_array},
+ {256, 32, "McastMemQkey", mad_dump_hex},
+ {BITSOFFS(288, 16), "McastMemMLid", mad_dump_hex},
+ {BITSOFFS(352, 4), "McastMemSL", mad_dump_uint},
+ {BITSOFFS(306, 6), "McastMemMTU", mad_dump_uint},
+ {BITSOFFS(338, 6), "McastMemRate", mad_dump_uint},
+ {BITSOFFS(312, 8), "McastMemTClass", mad_dump_uint},
+ {BITSOFFS(320, 16), "McastMemPkey", mad_dump_uint},
+ {BITSOFFS(356, 20), "McastMemFlowLbl", mad_dump_uint},
+ {BITSOFFS(388, 4), "McastMemJoinState", mad_dump_uint},
+ {BITSOFFS(392, 1), "McastMemProxyJoin", mad_dump_uint},
+
+ /*
+ * Service record
+ */
+ {0, 64, "ServRecID", mad_dump_hex},
+ {64, 128, "ServRecGid", mad_dump_array},
+ {BITSOFFS(192, 16), "ServRecPkey", mad_dump_hex},
+ {224, 32, "ServRecLease", mad_dump_hex},
+ {256, 128, "ServRecKey", mad_dump_hex},
+ {384, 512, "ServRecName", mad_dump_string},
+ {896, 512, "ServRecData", mad_dump_array}, /* ATS for example */
+
+ /*
+ * ATS SM record - within SA_SR_DATA
+ */
+ {12 * 8, 32, "ATSNodeAddr", mad_dump_hex},
+ {BITSOFFS(16 * 8, 16), "ATSMagicKey", mad_dump_hex},
+ {BITSOFFS(18 * 8, 16), "ATSNodeType", mad_dump_hex},
+ {32 * 8, 32 * 8, "ATSNodeName", mad_dump_string},
+
+ /*
+ * SLTOVL MAPPING TABLE
+ */
+ {0, 64, "SLToVLMap", mad_dump_hex},
+
+ /*
+ * VL ARBITRATION TABLE
+ */
+ {0, 512, "VLArbTbl", mad_dump_array},
+
+ /*
+ * IB vendor classes range 2
+ */
+ {BE_OFFS(36 * 8, 24), "OUI", mad_dump_array},
+ {40 * 8, (256 - 40) * 8, "Vendor2Data", mad_dump_array},
+
+ /*
+ * Extended port counters
+ */
+ {BITSOFFS(8, 8), "PortSelect", mad_dump_uint},
+ {BITSOFFS(16, 16), "CounterSelect", mad_dump_hex},
+ {64, 64, "PortXmitData", mad_dump_uint},
+ {128, 64, "PortRcvData", mad_dump_uint},
+ {192, 64, "PortXmitPkts", mad_dump_uint},
+ {256, 64, "PortRcvPkts", mad_dump_uint},
+ {320, 64, "PortUnicastXmitPkts", mad_dump_uint},
+ {384, 64, "PortUnicastRcvPkts", mad_dump_uint},
+ {448, 64, "PortMulticastXmitPkts", mad_dump_uint},
+ {512, 64, "PortMulticastRcvPkts", mad_dump_uint},
+ {0, 0}, /* IB_PC_EXT_LAST_F */
+
+ /*
+ * GUIDInfo fields
+ */
+ {0, 64, "GUID0", mad_dump_hex},
+
+ /*
+ * ClassPortInfo fields
+ */
+ {BITSOFFS(0, 8), "BaseVersion", mad_dump_uint},
+ {BITSOFFS(8, 8), "ClassVersion", mad_dump_uint},
+ {BITSOFFS(16, 16), "CapabilityMask", mad_dump_hex},
+ {BITSOFFS(32, 27), "CapabilityMask2", mad_dump_hex},
+ {BITSOFFS(59, 5), "RespTimeVal", mad_dump_uint},
+ {64, 128, "RedirectGID", mad_dump_array},
+ {BITSOFFS(192, 8), "RedirectTC", mad_dump_hex},
+ {BITSOFFS(200, 4), "RedirectSL", mad_dump_uint},
+ {BITSOFFS(204, 20), "RedirectFL", mad_dump_hex},
+ {BITSOFFS(224, 16), "RedirectLID", mad_dump_uint},
+ {BITSOFFS(240, 16), "RedirectPKey", mad_dump_hex},
+ {BITSOFFS(264, 24), "RedirectQP", mad_dump_hex},
+ {288, 32, "RedirectQKey", mad_dump_hex},
+ {320, 128, "TrapGID", mad_dump_array},
+ {BITSOFFS(448, 8), "TrapTC", mad_dump_hex},
+ {BITSOFFS(456, 4), "TrapSL", mad_dump_uint},
+ {BITSOFFS(460, 20), "TrapFL", mad_dump_hex},
+ {BITSOFFS(480, 16), "TrapLID", mad_dump_uint},
+ {BITSOFFS(496, 16), "TrapPKey", mad_dump_hex},
+ {BITSOFFS(512, 8), "TrapHL", mad_dump_uint},
+ {BITSOFFS(520, 24), "TrapQP", mad_dump_hex},
+ {544, 32, "TrapQKey", mad_dump_hex},
+
+ /*
+ * PortXmitDataSL fields
+ */
+ {32, 32, "XmtDataSL0", mad_dump_uint},
+ {64, 32, "XmtDataSL1", mad_dump_uint},
+ {96, 32, "XmtDataSL2", mad_dump_uint},
+ {128, 32, "XmtDataSL3", mad_dump_uint},
+ {160, 32, "XmtDataSL4", mad_dump_uint},
+ {192, 32, "XmtDataSL5", mad_dump_uint},
+ {224, 32, "XmtDataSL6", mad_dump_uint},
+ {256, 32, "XmtDataSL7", mad_dump_uint},
+ {288, 32, "XmtDataSL8", mad_dump_uint},
+ {320, 32, "XmtDataSL9", mad_dump_uint},
+ {352, 32, "XmtDataSL10", mad_dump_uint},
+ {384, 32, "XmtDataSL11", mad_dump_uint},
+ {416, 32, "XmtDataSL12", mad_dump_uint},
+ {448, 32, "XmtDataSL13", mad_dump_uint},
+ {480, 32, "XmtDataSL14", mad_dump_uint},
+ {512, 32, "XmtDataSL15", mad_dump_uint},
+ {0, 0}, /* IB_PC_XMT_DATA_SL_LAST_F */
+
+ /*
+ * PortRcvDataSL fields
+ */
+ {32, 32, "RcvDataSL0", mad_dump_uint},
+ {64, 32, "RcvDataSL1", mad_dump_uint},
+ {96, 32, "RcvDataSL2", mad_dump_uint},
+ {128, 32, "RcvDataSL3", mad_dump_uint},
+ {160, 32, "RcvDataSL4", mad_dump_uint},
+ {192, 32, "RcvDataSL5", mad_dump_uint},
+ {224, 32, "RcvDataSL6", mad_dump_uint},
+ {256, 32, "RcvDataSL7", mad_dump_uint},
+ {288, 32, "RcvDataSL8", mad_dump_uint},
+ {320, 32, "RcvDataSL9", mad_dump_uint},
+ {352, 32, "RcvDataSL10", mad_dump_uint},
+ {384, 32, "RcvDataSL11", mad_dump_uint},
+ {416, 32, "RcvDataSL12", mad_dump_uint},
+ {448, 32, "RcvDataSL13", mad_dump_uint},
+ {480, 32, "RcvDataSL14", mad_dump_uint},
+ {512, 32, "RcvDataSL15", mad_dump_uint},
+ {0, 0}, /* IB_PC_RCV_DATA_SL_LAST_F */
+
+ /*
+ * PortXmitDiscardDetails fields
+ */
+ {BITSOFFS(32, 16), "PortInactiveDiscards", mad_dump_uint},
+ {BITSOFFS(48, 16), "PortNeighborMTUDiscards", mad_dump_uint},
+ {BITSOFFS(64, 16), "PortSwLifetimeLimitDiscards", mad_dump_uint},
+ {BITSOFFS(80, 16), "PortSwHOQLifetimeLimitDiscards", mad_dump_uint},
+ {0, 0}, /* IB_PC_XMT_DISC_LAST_F */
+
+ /*
+ * PortRcvErrorDetails fields
+ */
+ {BITSOFFS(32, 16), "PortLocalPhysicalErrors", mad_dump_uint},
+ {BITSOFFS(48, 16), "PortMalformedPktErrors", mad_dump_uint},
+ {BITSOFFS(64, 16), "PortBufferOverrunErrors", mad_dump_uint},
+ {BITSOFFS(80, 16), "PortDLIDMappingErrors", mad_dump_uint},
+ {BITSOFFS(96, 16), "PortVLMappingErrors", mad_dump_uint},
+ {BITSOFFS(112, 16), "PortLoopingErrors", mad_dump_uint},
+ {0, 0}, /* IB_PC_RCV_ERR_LAST_F */
+
+ /*
+ * PortSamplesControl fields
+ */
+ {BITSOFFS(0, 8), "OpCode", mad_dump_hex},
+ {BITSOFFS(8, 8), "PortSelect", mad_dump_uint},
+ {BITSOFFS(16, 8), "Tick", mad_dump_hex},
+ {BITSOFFS(29, 3), "CounterWidth", mad_dump_uint},
+ {BITSOFFS(34, 3), "CounterMask0", mad_dump_hex},
+ {BITSOFFS(37, 27), "CounterMasks1to9", mad_dump_hex},
+ {BITSOFFS(65, 15), "CounterMasks10to14", mad_dump_hex},
+ {BITSOFFS(80, 8), "SampleMechanisms", mad_dump_uint},
+ {BITSOFFS(94, 2), "SampleStatus", mad_dump_uint},
+ {96, 64, "OptionMask", mad_dump_hex},
+ {160, 64, "VendorMask", mad_dump_hex},
+ {224, 32, "SampleStart", mad_dump_uint},
+ {256, 32, "SampleInterval", mad_dump_uint},
+ {BITSOFFS(288, 16), "Tag", mad_dump_hex},
+ {BITSOFFS(304, 16), "CounterSelect0", mad_dump_hex},
+ {BITSOFFS(320, 16), "CounterSelect1", mad_dump_hex},
+ {BITSOFFS(336, 16), "CounterSelect2", mad_dump_hex},
+ {BITSOFFS(352, 16), "CounterSelect3", mad_dump_hex},
+ {BITSOFFS(368, 16), "CounterSelect4", mad_dump_hex},
+ {BITSOFFS(384, 16), "CounterSelect5", mad_dump_hex},
+ {BITSOFFS(400, 16), "CounterSelect6", mad_dump_hex},
+ {BITSOFFS(416, 16), "CounterSelect7", mad_dump_hex},
+ {BITSOFFS(432, 16), "CounterSelect8", mad_dump_hex},
+ {BITSOFFS(448, 16), "CounterSelect9", mad_dump_hex},
+ {BITSOFFS(464, 16), "CounterSelect10", mad_dump_hex},
+ {BITSOFFS(480, 16), "CounterSelect11", mad_dump_hex},
+ {BITSOFFS(496, 16), "CounterSelect12", mad_dump_hex},
+ {BITSOFFS(512, 16), "CounterSelect13", mad_dump_hex},
+ {BITSOFFS(528, 16), "CounterSelect14", mad_dump_hex},
+ {576, 64, "SamplesOnlyOptionMask", mad_dump_hex},
+ {0, 0}, /* IB_PSC_LAST_F */
+
+ /* GUIDInfo fields */
+ {0, 64, "GUID0", mad_dump_hex},
+ {64, 64, "GUID1", mad_dump_hex},
+ {128, 64, "GUID2", mad_dump_hex},
+ {192, 64, "GUID3", mad_dump_hex},
+ {256, 64, "GUID4", mad_dump_hex},
+ {320, 64, "GUID5", mad_dump_hex},
+ {384, 64, "GUID6", mad_dump_hex},
+ {448, 64, "GUID7", mad_dump_hex},
+
+ /* GUID Info Record */
+ {BITSOFFS(0, 16), "Lid", mad_dump_uint},
+ {BITSOFFS(16, 8), "BlockNum", mad_dump_uint},
+ {64, 64, "Guid0", mad_dump_hex},
+ {128, 64, "Guid1", mad_dump_hex},
+ {192, 64, "Guid2", mad_dump_hex},
+ {256, 64, "Guid3", mad_dump_hex},
+ {320, 64, "Guid4", mad_dump_hex},
+ {384, 64, "Guid5", mad_dump_hex},
+ {448, 64, "Guid6", mad_dump_hex},
+ {512, 64, "Guid7", mad_dump_hex},
+
+ /*
+ * More PortInfo fields
+ */
+ {BITSOFFS(480, 16), "CapabilityMask2", mad_dump_portcapmask2},
+ {BITSOFFS(496, 4), "LinkSpeedExtActive", mad_dump_linkspeedext},
+ {BITSOFFS(500, 4), "LinkSpeedExtSupported", mad_dump_linkspeedextsup},
+ {BITSOFFS(507, 5), "LinkSpeedExtEnabled", mad_dump_linkspeedexten},
+ {0, 0}, /* IB_PORT_LINK_SPEED_EXT_LAST_F */
+
+ /*
+ * PortExtendedSpeedsCounters fields
+ */
+ {BITSOFFS(8, 8), "PortSelect", mad_dump_uint},
+ {64, 64, "CounterSelect", mad_dump_hex},
+ {BITSOFFS(128, 16), "SyncHeaderErrorCounter", mad_dump_uint},
+ {BITSOFFS(144, 16), "UnknownBlockCounter", mad_dump_uint},
+ {BITSOFFS(160, 16), "ErrorDetectionCounterLane0", mad_dump_uint},
+ {BITSOFFS(176, 16), "ErrorDetectionCounterLane1", mad_dump_uint},
+ {BITSOFFS(192, 16), "ErrorDetectionCounterLane2", mad_dump_uint},
+ {BITSOFFS(208, 16), "ErrorDetectionCounterLane3", mad_dump_uint},
+ {BITSOFFS(224, 16), "ErrorDetectionCounterLane4", mad_dump_uint},
+ {BITSOFFS(240, 16), "ErrorDetectionCounterLane5", mad_dump_uint},
+ {BITSOFFS(256, 16), "ErrorDetectionCounterLane6", mad_dump_uint},
+ {BITSOFFS(272, 16), "ErrorDetectionCounterLane7", mad_dump_uint},
+ {BITSOFFS(288, 16), "ErrorDetectionCounterLane8", mad_dump_uint},
+ {BITSOFFS(304, 16), "ErrorDetectionCounterLane9", mad_dump_uint},
+ {BITSOFFS(320, 16), "ErrorDetectionCounterLane10", mad_dump_uint},
+ {BITSOFFS(336, 16), "ErrorDetectionCounterLane11", mad_dump_uint},
+ {352, 32, "FECCorrectableBlockCtrLane0", mad_dump_uint},
+ {384, 32, "FECCorrectableBlockCtrLane1", mad_dump_uint},
+ {416, 32, "FECCorrectableBlockCtrLane2", mad_dump_uint},
+ {448, 32, "FECCorrectableBlockCtrLane3", mad_dump_uint},
+ {480, 32, "FECCorrectableBlockCtrLane4", mad_dump_uint},
+ {512, 32, "FECCorrectableBlockCtrLane5", mad_dump_uint},
+ {544, 32, "FECCorrectableBlockCtrLane6", mad_dump_uint},
+ {576, 32, "FECCorrectableBlockCtrLane7", mad_dump_uint},
+ {608, 32, "FECCorrectableBlockCtrLane8", mad_dump_uint},
+ {640, 32, "FECCorrectableBlockCtrLane9", mad_dump_uint},
+ {672, 32, "FECCorrectableBlockCtrLane10", mad_dump_uint},
+ {704, 32, "FECCorrectableBlockCtrLane11", mad_dump_uint},
+ {736, 32, "FECUncorrectableBlockCtrLane0", mad_dump_uint},
+ {768, 32, "FECUncorrectableBlockCtrLane1", mad_dump_uint},
+ {800, 32, "FECUncorrectableBlockCtrLane2", mad_dump_uint},
+ {832, 32, "FECUncorrectableBlockCtrLane3", mad_dump_uint},
+ {864, 32, "FECUncorrectableBlockCtrLane4", mad_dump_uint},
+ {896, 32, "FECUncorrectableBlockCtrLane5", mad_dump_uint},
+ {928, 32, "FECUncorrectableBlockCtrLane6", mad_dump_uint},
+ {960, 32, "FECUncorrectableBlockCtrLane7", mad_dump_uint},
+ {992, 32, "FECUncorrectableBlockCtrLane8", mad_dump_uint},
+ {1024, 32, "FECUncorrectableBlockCtrLane9", mad_dump_uint},
+ {1056, 32, "FECUncorrectableBlockCtrLane10", mad_dump_uint},
+ {1088, 32, "FECUncorrectableBlockCtrLane11", mad_dump_uint},
+ {0, 0}, /* IB_PESC_LAST_F */
+
+
+
+ /*
+ * PortOpRcvCounters fields
+ */
+ {32, 32, "PortOpRcvPkts", mad_dump_uint},
+ {64, 32, "PortOpRcvData", mad_dump_uint},
+ {0, 0}, /* IB_PC_PORT_OP_RCV_COUNTERS_LAST_F */
+
+ /*
+ * PortFlowCtlCounters fields
+ */
+ {32, 32, "PortXmitFlowPkts", mad_dump_uint},
+ {64, 32, "PortRcvFlowPkts", mad_dump_uint},
+ {0, 0}, /* IB_PC_PORT_FLOW_CTL_COUNTERS_LAST_F */
+
+ /*
+ * PortVLOpPackets fields
+ */
+ {BITSOFFS(32, 16), "PortVLOpPackets0", mad_dump_uint},
+ {BITSOFFS(48, 16), "PortVLOpPackets1", mad_dump_uint},
+ {BITSOFFS(64, 16), "PortVLOpPackets2", mad_dump_uint},
+ {BITSOFFS(80, 16), "PortVLOpPackets3", mad_dump_uint},
+ {BITSOFFS(96, 16), "PortVLOpPackets4", mad_dump_uint},
+ {BITSOFFS(112, 16), "PortVLOpPackets5", mad_dump_uint},
+ {BITSOFFS(128, 16), "PortVLOpPackets6", mad_dump_uint},
+ {BITSOFFS(144, 16), "PortVLOpPackets7", mad_dump_uint},
+ {BITSOFFS(160, 16), "PortVLOpPackets8", mad_dump_uint},
+ {BITSOFFS(176, 16), "PortVLOpPackets9", mad_dump_uint},
+ {BITSOFFS(192, 16), "PortVLOpPackets10", mad_dump_uint},
+ {BITSOFFS(208, 16), "PortVLOpPackets11", mad_dump_uint},
+ {BITSOFFS(224, 16), "PortVLOpPackets12", mad_dump_uint},
+ {BITSOFFS(240, 16), "PortVLOpPackets13", mad_dump_uint},
+ {BITSOFFS(256, 16), "PortVLOpPackets14", mad_dump_uint},
+ {BITSOFFS(272, 16), "PortVLOpPackets15", mad_dump_uint},
+ {0, 0}, /* IB_PC_PORT_VL_OP_PACKETS_LAST_F */
+
+ /*
+ * PortVLOpData fields
+ */
+ {32, 32, "PortVLOpData0", mad_dump_uint},
+ {64, 32, "PortVLOpData1", mad_dump_uint},
+ {96, 32, "PortVLOpData2", mad_dump_uint},
+ {128, 32, "PortVLOpData3", mad_dump_uint},
+ {160, 32, "PortVLOpData4", mad_dump_uint},
+ {192, 32, "PortVLOpData5", mad_dump_uint},
+ {224, 32, "PortVLOpData6", mad_dump_uint},
+ {256, 32, "PortVLOpData7", mad_dump_uint},
+ {288, 32, "PortVLOpData8", mad_dump_uint},
+ {320, 32, "PortVLOpData9", mad_dump_uint},
+ {352, 32, "PortVLOpData10", mad_dump_uint},
+ {384, 32, "PortVLOpData11", mad_dump_uint},
+ {416, 32, "PortVLOpData12", mad_dump_uint},
+ {448, 32, "PortVLOpData13", mad_dump_uint},
+ {480, 32, "PortVLOpData14", mad_dump_uint},
+ {512, 32, "PortVLOpData15", mad_dump_uint},
+ {0, 0}, /* IB_PC_PORT_VL_OP_DATA_LAST_F */
+
+ /*
+ * PortVLXmitFlowCtlUpdateErrors fields
+ */
+ {BITSOFFS(32, 2), "PortVLXmitFlowCtlUpdateErrors0", mad_dump_uint},
+ {BITSOFFS(34, 2), "PortVLXmitFlowCtlUpdateErrors1", mad_dump_uint},
+ {BITSOFFS(36, 2), "PortVLXmitFlowCtlUpdateErrors2", mad_dump_uint},
+ {BITSOFFS(38, 2), "PortVLXmitFlowCtlUpdateErrors3", mad_dump_uint},
+ {BITSOFFS(40, 2), "PortVLXmitFlowCtlUpdateErrors4", mad_dump_uint},
+ {BITSOFFS(42, 2), "PortVLXmitFlowCtlUpdateErrors5", mad_dump_uint},
+ {BITSOFFS(44, 2), "PortVLXmitFlowCtlUpdateErrors6", mad_dump_uint},
+ {BITSOFFS(46, 2), "PortVLXmitFlowCtlUpdateErrors7", mad_dump_uint},
+ {BITSOFFS(48, 2), "PortVLXmitFlowCtlUpdateErrors8", mad_dump_uint},
+ {BITSOFFS(50, 2), "PortVLXmitFlowCtlUpdateErrors9", mad_dump_uint},
+ {BITSOFFS(52, 2), "PortVLXmitFlowCtlUpdateErrors10", mad_dump_uint},
+ {BITSOFFS(54, 2), "PortVLXmitFlowCtlUpdateErrors11", mad_dump_uint},
+ {BITSOFFS(56, 2), "PortVLXmitFlowCtlUpdateErrors12", mad_dump_uint},
+ {BITSOFFS(58, 2), "PortVLXmitFlowCtlUpdateErrors13", mad_dump_uint},
+ {BITSOFFS(60, 2), "PortVLXmitFlowCtlUpdateErrors14", mad_dump_uint},
+ {BITSOFFS(62, 2), "PortVLXmitFlowCtlUpdateErrors15", mad_dump_uint},
+ {0, 0}, /* IB_PC_PORT_VL_XMIT_FLOW_CTL_UPDATE_ERRORS_LAST_F */
+
+ /*
+ * PortVLXmitWaitCounters fields
+ */
+ {BITSOFFS(32, 16), "PortVLXmitWait0", mad_dump_uint},
+ {BITSOFFS(48, 16), "PortVLXmitWait1", mad_dump_uint},
+ {BITSOFFS(64, 16), "PortVLXmitWait2", mad_dump_uint},
+ {BITSOFFS(80, 16), "PortVLXmitWait3", mad_dump_uint},
+ {BITSOFFS(96, 16), "PortVLXmitWait4", mad_dump_uint},
+ {BITSOFFS(112, 16), "PortVLXmitWait5", mad_dump_uint},
+ {BITSOFFS(128, 16), "PortVLXmitWait6", mad_dump_uint},
+ {BITSOFFS(144, 16), "PortVLXmitWait7", mad_dump_uint},
+ {BITSOFFS(160, 16), "PortVLXmitWait8", mad_dump_uint},
+ {BITSOFFS(176, 16), "PortVLXmitWait9", mad_dump_uint},
+ {BITSOFFS(192, 16), "PortVLXmitWait10", mad_dump_uint},
+ {BITSOFFS(208, 16), "PortVLXmitWait11", mad_dump_uint},
+ {BITSOFFS(224, 16), "PortVLXmitWait12", mad_dump_uint},
+ {BITSOFFS(240, 16), "PortVLXmitWait13", mad_dump_uint},
+ {BITSOFFS(256, 16), "PortVLXmitWait14", mad_dump_uint},
+ {BITSOFFS(272, 16), "PortVLXmitWait15", mad_dump_uint},
+ {0, 0}, /* IB_PC_PORT_VL_XMIT_WAIT_COUNTERS_LAST_F */
+
+ /*
+ * SwPortVLCongestion fields
+ */
+ {BITSOFFS(32, 16), "SWPortVLCongestion0", mad_dump_uint},
+ {BITSOFFS(48, 16), "SWPortVLCongestion1", mad_dump_uint},
+ {BITSOFFS(64, 16), "SWPortVLCongestion2", mad_dump_uint},
+ {BITSOFFS(80, 16), "SWPortVLCongestion3", mad_dump_uint},
+ {BITSOFFS(96, 16), "SWPortVLCongestion4", mad_dump_uint},
+ {BITSOFFS(112, 16), "SWPortVLCongestion5", mad_dump_uint},
+ {BITSOFFS(128, 16), "SWPortVLCongestion6", mad_dump_uint},
+ {BITSOFFS(144, 16), "SWPortVLCongestion7", mad_dump_uint},
+ {BITSOFFS(160, 16), "SWPortVLCongestion8", mad_dump_uint},
+ {BITSOFFS(176, 16), "SWPortVLCongestion9", mad_dump_uint},
+ {BITSOFFS(192, 16), "SWPortVLCongestion10", mad_dump_uint},
+ {BITSOFFS(208, 16), "SWPortVLCongestion11", mad_dump_uint},
+ {BITSOFFS(224, 16), "SWPortVLCongestion12", mad_dump_uint},
+ {BITSOFFS(240, 16), "SWPortVLCongestion13", mad_dump_uint},
+ {BITSOFFS(256, 16), "SWPortVLCongestion14", mad_dump_uint},
+ {BITSOFFS(272, 16), "SWPortVLCongestion15", mad_dump_uint},
+ {0, 0}, /* IB_PC_SW_PORT_VL_CONGESTION_LAST_F */
+
+ /*
+ * PortRcvConCtrl fields
+ */
+ {32, 32, "PortPktRcvFECN", mad_dump_uint},
+ {64, 32, "PortPktRcvBECN", mad_dump_uint},
+ {0, 0}, /* IB_PC_RCV_CON_CTRL_LAST_F */
+
+ /*
+ * PortSLRcvFECN fields
+ */
+ {32, 32, "PortSLRcvFECN0", mad_dump_uint},
+ {64, 32, "PortSLRcvFECN1", mad_dump_uint},
+ {96, 32, "PortSLRcvFECN2", mad_dump_uint},
+ {128, 32, "PortSLRcvFECN3", mad_dump_uint},
+ {160, 32, "PortSLRcvFECN4", mad_dump_uint},
+ {192, 32, "PortSLRcvFECN5", mad_dump_uint},
+ {224, 32, "PortSLRcvFECN6", mad_dump_uint},
+ {256, 32, "PortSLRcvFECN7", mad_dump_uint},
+ {288, 32, "PortSLRcvFECN8", mad_dump_uint},
+ {320, 32, "PortSLRcvFECN9", mad_dump_uint},
+ {352, 32, "PortSLRcvFECN10", mad_dump_uint},
+ {384, 32, "PortSLRcvFECN11", mad_dump_uint},
+ {416, 32, "PortSLRcvFECN12", mad_dump_uint},
+ {448, 32, "PortSLRcvFECN13", mad_dump_uint},
+ {480, 32, "PortSLRcvFECN14", mad_dump_uint},
+ {512, 32, "PortSLRcvFECN15", mad_dump_uint},
+ {0, 0}, /* IB_PC_SL_RCV_FECN_LAST_F */
+
+ /*
+ * PortSLRcvBECN fields
+ */
+ {32, 32, "PortSLRcvBECN0", mad_dump_uint},
+ {64, 32, "PortSLRcvBECN1", mad_dump_uint},
+ {96, 32, "PortSLRcvBECN2", mad_dump_uint},
+ {128, 32, "PortSLRcvBECN3", mad_dump_uint},
+ {160, 32, "PortSLRcvBECN4", mad_dump_uint},
+ {192, 32, "PortSLRcvBECN5", mad_dump_uint},
+ {224, 32, "PortSLRcvBECN6", mad_dump_uint},
+ {256, 32, "PortSLRcvBECN7", mad_dump_uint},
+ {288, 32, "PortSLRcvBECN8", mad_dump_uint},
+ {320, 32, "PortSLRcvBECN9", mad_dump_uint},
+ {352, 32, "PortSLRcvBECN10", mad_dump_uint},
+ {384, 32, "PortSLRcvBECN11", mad_dump_uint},
+ {416, 32, "PortSLRcvBECN12", mad_dump_uint},
+ {448, 32, "PortSLRcvBECN13", mad_dump_uint},
+ {480, 32, "PortSLRcvBECN14", mad_dump_uint},
+ {512, 32, "PortSLRcvBECN15", mad_dump_uint},
+ {0, 0}, /* IB_PC_SL_RCV_BECN_LAST_F */
+
+ /*
+ * PortXmitConCtrl fields
+ */
+ {32, 32, "PortXmitTimeCong", mad_dump_uint},
+ {0, 0}, /* IB_PC_XMIT_CON_CTRL_LAST_F */
+
+ /*
+ * PortVLXmitTimeCong fields
+ */
+ {32, 32, "PortVLXmitTimeCong0", mad_dump_uint},
+ {64, 32, "PortVLXmitTimeCong1", mad_dump_uint},
+ {96, 32, "PortVLXmitTimeCong2", mad_dump_uint},
+ {128, 32, "PortVLXmitTimeCong3", mad_dump_uint},
+ {160, 32, "PortVLXmitTimeCong4", mad_dump_uint},
+ {192, 32, "PortVLXmitTimeCong5", mad_dump_uint},
+ {224, 32, "PortVLXmitTimeCong6", mad_dump_uint},
+ {256, 32, "PortVLXmitTimeCong7", mad_dump_uint},
+ {288, 32, "PortVLXmitTimeCong8", mad_dump_uint},
+ {320, 32, "PortVLXmitTimeCong9", mad_dump_uint},
+ {352, 32, "PortVLXmitTimeCong10", mad_dump_uint},
+ {384, 32, "PortVLXmitTimeCong11", mad_dump_uint},
+ {416, 32, "PortVLXmitTimeCong12", mad_dump_uint},
+ {448, 32, "PortVLXmitTimeCong13", mad_dump_uint},
+ {480, 32, "PortVLXmitTimeCong14", mad_dump_uint},
+ {0, 0}, /* IB_PC_VL_XMIT_TIME_CONG_LAST_F */
+
+ /*
+ * Mellanox ExtendedPortInfo fields
+ */
+ {BITSOFFS(24, 8), "StateChangeEnable", mad_dump_hex},
+ {BITSOFFS(56, 8), "LinkSpeedSupported", mad_dump_hex},
+ {BITSOFFS(88, 8), "LinkSpeedEnabled", mad_dump_hex},
+ {BITSOFFS(120, 8), "LinkSpeedActive", mad_dump_hex},
+ {0, 0}, /* IB_MLNX_EXT_PORT_LAST_F */
+
+ /*
+ * Congestion Control Mad fields
+ * bytes 24-31 of congestion control mad
+ */
+ {192, 64, "CC_Key", mad_dump_hex}, /* IB_CC_CCKEY_F */
+
+ /*
+ * CongestionInfo fields
+ */
+ {BITSOFFS(0, 16), "CongestionInfo", mad_dump_hex},
+ {BITSOFFS(16, 8), "ControlTableCap", mad_dump_uint},
+ {0, 0}, /* IB_CC_CONGESTION_INFO_LAST_F */
+
+ /*
+ * CongestionKeyInfo fields
+ */
+ {0, 64, "CC_Key", mad_dump_hex},
+ {BITSOFFS(64, 1), "CC_KeyProtectBit", mad_dump_uint},
+ {BITSOFFS(80, 16), "CC_KeyLeasePeriod", mad_dump_uint},
+ {BITSOFFS(96, 16), "CC_KeyViolations", mad_dump_uint},
+ {0, 0}, /* IB_CC_CONGESTION_KEY_INFO_LAST_F */
+
+ /*
+ * CongestionLog (common) fields
+ */
+ {BITSOFFS(0, 8), "LogType", mad_dump_uint},
+ {BITSOFFS(8, 8), "CongestionFlags", mad_dump_hex},
+ {0, 0}, /* IB_CC_CONGESTION_LOG_LAST_F */
+
+ /*
+ * CongestionLog (Switch) fields
+ */
+ {BITSOFFS(16, 16), "LogEventsCounter", mad_dump_uint},
+ {32, 32, "CurrentTimeStamp", mad_dump_uint},
+ {64, 256, "PortMap", mad_dump_array},
+ {0, 0}, /* IB_CC_CONGESTION_LOG_SWITCH_LAST_F */
+
+ /*
+ * CongestionLogEvent (Switch) fields
+ */
+ {BITSOFFS(0, 16), "SLID", mad_dump_uint},
+ {BITSOFFS(16, 16), "DLID", mad_dump_uint},
+ {BITSOFFS(32, 4), "SL", mad_dump_uint},
+ {64, 32, "Timestamp", mad_dump_uint},
+ {0, 0}, /* IB_CC_CONGESTION_LOG_ENTRY_SWITCH_LAST_F */
+
+ /*
+ * CongestionLog (CA) fields
+ */
+ {BITSOFFS(16, 16), "ThresholdEventCounter", mad_dump_uint},
+ {BITSOFFS(32, 16), "ThresholdCongestionEventMap", mad_dump_hex},
+ /* XXX: Q3/2010 errata lists offset 48, but that means field is not
+ * word aligned. Assume will be aligned to offset 64 later.
+ */
+ {BITSOFFS(64, 32), "CurrentTimeStamp", mad_dump_uint},
+ {0, 0}, /* IB_CC_CONGESTION_LOG_CA_LAST_F */
+
+ /*
+ * CongestionLogEvent (CA) fields
+ */
+ {BITSOFFS(0, 24), "Local_QP_CN_Entry", mad_dump_uint},
+ {BITSOFFS(24, 4), "SL_CN_Entry", mad_dump_uint},
+ {BITSOFFS(28, 4), "Service_Type_CN_Entry", mad_dump_hex},
+ {BITSOFFS(32, 24), "Remote_QP_Number_CN_Entry", mad_dump_uint},
+ {BITSOFFS(64, 16), "Local_LID_CN", mad_dump_uint},
+ {BITSOFFS(80, 16), "Remote_LID_CN_Entry", mad_dump_uint},
+ {BITSOFFS(96, 32), "Timestamp_CN_Entry", mad_dump_uint},
+ {0, 0}, /* IB_CC_CONGESTION_LOG_ENTRY_CA_LAST_F */
+
+ /*
+ * SwitchCongestionSetting fields
+ */
+ {0, 32, "Control_Map", mad_dump_hex},
+ {32, 256, "Victim_Mask", mad_dump_array},
+ {288, 256, "Credit_Mask", mad_dump_array},
+ {BITSOFFS(544, 4), "Threshold", mad_dump_hex},
+ {BITSOFFS(552, 8), "Packet_Size", mad_dump_uint},
+ {BITSOFFS(560, 4), "CS_Threshold", mad_dump_hex},
+ {BITSOFFS(576, 16), "CS_ReturnDelay", mad_dump_hex}, /* TODO: CCT dump */
+ {BITSOFFS(592, 16), "Marking_Rate", mad_dump_uint},
+ {0, 0}, /* IB_CC_SWITCH_CONGESTION_SETTING_LAST_F */
+
+ /*
+ * SwitchPortCongestionSettingElement fields
+ */
+ {BITSOFFS(0, 1), "Valid", mad_dump_uint},
+ {BITSOFFS(1, 1), "Control_Type", mad_dump_uint},
+ {BITSOFFS(4, 4), "Threshold", mad_dump_hex},
+ {BITSOFFS(8, 8), "Packet_Size", mad_dump_uint},
+ {BITSOFFS(16, 16), "Cong_Parm_Marking_Rate", mad_dump_uint},
+ {0, 0}, /* IB_CC_SWITCH_PORT_CONGESTION_SETTING_ELEMENT_LAST_F */
+
+ /*
+ * CACongestionSetting fields
+ */
+ {BITSOFFS(0, 16), "Port_Control", mad_dump_hex},
+ {BITSOFFS(16, 16), "Control_Map", mad_dump_hex},
+ {0, 0}, /* IB_CC_CA_CONGESTION_SETTING_LAST_F */
+
+ /*
+ * CACongestionEntry fields
+ */
+ {BITSOFFS(0, 16), "CCTI_Timer", mad_dump_uint},
+ {BITSOFFS(16, 8), "CCTI_Increase", mad_dump_uint},
+ {BITSOFFS(24, 8), "Trigger_Threshold", mad_dump_uint},
+ {BITSOFFS(32, 8), "CCTI_Min", mad_dump_uint},
+ {0, 0}, /* IB_CC_CA_CONGESTION_SETTING_ENTRY_LAST_F */
+
+ /*
+ * CongestionControlTable fields
+ */
+ {BITSOFFS(0, 16), "CCTI_Limit", mad_dump_uint},
+ {0, 0}, /* IB_CC_CONGESTION_CONTROL_TABLE_LAST_F */
+
+ /*
+ * CongestionControlTableEntry fields
+ */
+ {BITSOFFS(0, 2), "CCT_Shift", mad_dump_uint},
+ {BITSOFFS(2, 14), "CCT_Multiplier", mad_dump_uint},
+ {0, 0}, /* IB_CC_CONGESTION_CONTROL_TABLE_ENTRY_LAST_F */
+
+ /*
+ * Timestamp fields
+ */
+ {0, 32, "Timestamp", mad_dump_uint},
+ {0, 0}, /* IB_CC_TIMESTAMP_LAST_F */
+
+ /* Node Record */
+ {BITSOFFS(0, 16), "Lid", mad_dump_uint},
+ {BITSOFFS(32, 8), "BaseVers", mad_dump_uint},
+ {BITSOFFS(40, 8), "ClassVers", mad_dump_uint},
+ {BITSOFFS(48, 8), "NodeType", mad_dump_node_type},
+ {BITSOFFS(56, 8), "NumPorts", mad_dump_uint},
+ {64, 64, "SystemGuid", mad_dump_hex},
+ {128, 64, "Guid", mad_dump_hex},
+ {192, 64, "PortGuid", mad_dump_hex},
+ {BITSOFFS(256, 16), "PartCap", mad_dump_uint},
+ {BITSOFFS(272, 16), "DevId", mad_dump_hex},
+ {288, 32, "Revision", mad_dump_hex},
+ {BITSOFFS(320, 8), "LocalPort", mad_dump_uint},
+ {BITSOFFS(328, 24), "VendorId", mad_dump_hex},
+ {352, 64 * 8, "NodeDesc", mad_dump_string},
+ {0, 0}, /* IB_SA_NR_LAST_F */
+
+ /*
+ * PortMirrorRoute fields
+ */
+ {BITSOFFS(0, 16), "EncapRawEthType", mad_dump_hex},
+ {BITSOFFS(20, 12), "MaxMirrorLen", mad_dump_hex},
+ {BITSOFFS(32, 3), "MT", mad_dump_hex},
+ {BITSOFFS(35, 1), "BF", mad_dump_hex},
+ {BITSOFFS(56, 8), "NMPort", mad_dump_hex},
+ {BITSOFFS(64, 4), "EncapLRHVL", mad_dump_hex},
+ {BITSOFFS(68, 4), "EncapLRHLVer", mad_dump_hex},
+ {BITSOFFS(72, 4), "EncapLRHSL", mad_dump_hex},
+ {BITSOFFS(78, 2), "EncapLRHLNH", mad_dump_hex},
+ {BITSOFFS(80, 16), "EncapLRHDLID", mad_dump_hex},
+ {BITSOFFS(101, 11), "EncapLRHLength", mad_dump_hex},
+ {BITSOFFS(112, 16), "EncapLRHSLID", mad_dump_hex},
+ {0, 0}, /* IB_PMR_LAST_F */
+
+ /*
+ * PortMirrorFilter fields
+ */
+ {0, 32, "MirrorFilter0", mad_dump_hex},
+ {32, 32, "MirrorFilter1", mad_dump_hex},
+ {64, 32, "MirrorMask0", mad_dump_hex},
+ {96, 32, "MirrorMask1", mad_dump_hex},
+ {128, 32, "MirrorMask2", mad_dump_hex},
+ {160, 32, "MirrorMask3", mad_dump_hex},
+ {BITSOFFS(192, 1), "B0", mad_dump_hex},
+ {BITSOFFS(196, 12), "MirrorMaskOffset0", mad_dump_hex},
+ {BITSOFFS(208, 1), "B1", mad_dump_hex},
+ {BITSOFFS(212, 12), "MirrorMaskOffset1", mad_dump_hex},
+ {BITSOFFS(224, 1), "B2", mad_dump_hex},
+ {BITSOFFS(228, 12), "MirrorMaskOffset2", mad_dump_hex},
+ {BITSOFFS(240, 1), "B3", mad_dump_hex},
+ {BITSOFFS(244, 12), "MirrorMaskOffset3", mad_dump_hex},
+ {0, 0}, /* IB_PMF_LAST_F */
+
+ /*
+ * PortMirrorPorts fields
+ */
+ {BITSOFFS(10, 2), "TQ1", mad_dump_hex},
+ {BITSOFFS(14, 2), "RQ1", mad_dump_hex},
+ {BITSOFFS(18, 2), "TQ2", mad_dump_hex},
+ {BITSOFFS(22, 2), "RQ2", mad_dump_hex},
+ {BITSOFFS(26, 2), "TQ3", mad_dump_hex},
+ {BITSOFFS(30, 2), "RQ3", mad_dump_hex},
+ {BITSOFFS(34, 2), "TQ4", mad_dump_hex},
+ {BITSOFFS(38, 2), "RQ4", mad_dump_hex},
+ {BITSOFFS(42, 2), "TQ5", mad_dump_hex},
+ {BITSOFFS(46, 2), "RQ5", mad_dump_hex},
+ {BITSOFFS(50, 2), "TQ6", mad_dump_hex},
+ {BITSOFFS(54, 2), "RQ6", mad_dump_hex},
+ {BITSOFFS(58, 2), "TQ7", mad_dump_hex},
+ {BITSOFFS(62, 2), "RQ7", mad_dump_hex},
+ {BITSOFFS(66, 2), "TQ8", mad_dump_hex},
+ {BITSOFFS(70, 2), "RQ8", mad_dump_hex},
+ {BITSOFFS(74, 2), "TQ9", mad_dump_hex},
+ {BITSOFFS(78, 2), "RQ9", mad_dump_hex},
+ {BITSOFFS(82, 2), "TQ10", mad_dump_hex},
+ {BITSOFFS(86, 2), "RQ10", mad_dump_hex},
+ {BITSOFFS(90, 2), "TQ11", mad_dump_hex},
+ {BITSOFFS(94, 2), "RQ11", mad_dump_hex},
+ {BITSOFFS(98, 2), "TQ12", mad_dump_hex},
+ {BITSOFFS(102, 2), "RQ12", mad_dump_hex},
+ {BITSOFFS(106, 2), "TQ13", mad_dump_hex},
+ {BITSOFFS(110, 2), "RQ13", mad_dump_hex},
+ {BITSOFFS(114, 2), "TQ14", mad_dump_hex},
+ {BITSOFFS(118, 2), "RQ14", mad_dump_hex},
+ {BITSOFFS(122, 2), "TQ15", mad_dump_hex},
+ {BITSOFFS(126, 2), "RQ15", mad_dump_hex},
+ {BITSOFFS(130, 2), "TQ16", mad_dump_hex},
+ {BITSOFFS(134, 2), "RQ16", mad_dump_hex},
+ {BITSOFFS(138, 2), "TQ17", mad_dump_hex},
+ {BITSOFFS(142, 2), "RQ17", mad_dump_hex},
+ {BITSOFFS(146, 2), "TQ18", mad_dump_hex},
+ {BITSOFFS(150, 2), "RQ18", mad_dump_hex},
+ {BITSOFFS(154, 2), "TQ19", mad_dump_hex},
+ {BITSOFFS(158, 2), "RQ19", mad_dump_hex},
+ {BITSOFFS(162, 2), "TQ20", mad_dump_hex},
+ {BITSOFFS(166, 2), "RQ20", mad_dump_hex},
+ {BITSOFFS(170, 2), "TQ21", mad_dump_hex},
+ {BITSOFFS(174, 2), "RQ21", mad_dump_hex},
+ {BITSOFFS(178, 2), "TQ22", mad_dump_hex},
+ {BITSOFFS(182, 2), "RQ22", mad_dump_hex},
+ {BITSOFFS(186, 2), "TQ23", mad_dump_hex},
+ {BITSOFFS(190, 2), "RQ23", mad_dump_hex},
+ {BITSOFFS(194, 2), "TQ24", mad_dump_hex},
+ {BITSOFFS(198, 2), "RQ24", mad_dump_hex},
+ {BITSOFFS(202, 2), "TQ25", mad_dump_hex},
+ {BITSOFFS(206, 2), "RQ25", mad_dump_hex},
+ {BITSOFFS(210, 2), "TQ26", mad_dump_hex},
+ {BITSOFFS(214, 2), "RQ26", mad_dump_hex},
+ {BITSOFFS(218, 2), "TQ27", mad_dump_hex},
+ {BITSOFFS(222, 2), "RQ27", mad_dump_hex},
+ {BITSOFFS(226, 2), "TQ28", mad_dump_hex},
+ {BITSOFFS(230, 2), "RQ28", mad_dump_hex},
+ {BITSOFFS(234, 2), "TQ29", mad_dump_hex},
+ {BITSOFFS(238, 2), "RQ29", mad_dump_hex},
+ {BITSOFFS(242, 2), "TQ30", mad_dump_hex},
+ {BITSOFFS(246, 2), "RQ30", mad_dump_hex},
+ {BITSOFFS(250, 2), "TQ31", mad_dump_hex},
+ {BITSOFFS(254, 2), "RQ31", mad_dump_hex},
+ {BITSOFFS(258, 2), "TQ32", mad_dump_hex},
+ {BITSOFFS(262, 2), "RQ32", mad_dump_hex},
+ {BITSOFFS(266, 2), "TQ33", mad_dump_hex},
+ {BITSOFFS(270, 2), "RQ33", mad_dump_hex},
+ {BITSOFFS(274, 2), "TQ34", mad_dump_hex},
+ {BITSOFFS(278, 2), "RQ34", mad_dump_hex},
+ {BITSOFFS(282, 2), "TQ35", mad_dump_hex},
+ {BITSOFFS(286, 2), "RQ35", mad_dump_hex},
+ {BITSOFFS(290, 2), "TQ36", mad_dump_hex},
+ {BITSOFFS(294, 2), "RQ36", mad_dump_hex},
+ {0, 0}, /* IB_FIELD_LAST_ */
+
+ /*
+ * PortSamplesResult fields
+ */
+ {BITSOFFS(0, 16), "Tag", mad_dump_hex},
+ {BITSOFFS(30, 2), "SampleStatus", mad_dump_hex},
+ {32, 32, "Counter0", mad_dump_uint},
+ {64, 32, "Counter1", mad_dump_uint},
+ {96, 32, "Counter2", mad_dump_uint},
+ {128, 32, "Counter3", mad_dump_uint},
+ {160, 32, "Counter4", mad_dump_uint},
+ {192, 32, "Counter5", mad_dump_uint},
+ {224, 32, "Counter6", mad_dump_uint},
+ {256, 32, "Counter7", mad_dump_uint},
+ {288, 32, "Counter8", mad_dump_uint},
+ {320, 32, "Counter9", mad_dump_uint},
+ {352, 32, "Counter10", mad_dump_uint},
+ {384, 32, "Counter11", mad_dump_uint},
+ {416, 32, "Counter12", mad_dump_uint},
+ {448, 32, "Counter13", mad_dump_uint},
+ {480, 32, "Counter14", mad_dump_uint},
+ {0, 0}, /* IB_PSR_LAST_F */
+
+ /*
+ * PortInfoExtended fields
+ */
+ {0, 32, "CapMask", mad_dump_hex},
+ {BITSOFFS(32, 16), "FECModeActive", mad_dump_uint},
+ {BITSOFFS(48, 16), "FDRFECModeSupported", mad_dump_uint},
+ {BITSOFFS(64, 16), "FDRFECModeEnabled", mad_dump_uint},
+ {BITSOFFS(80, 16), "EDRFECModeSupported", mad_dump_uint},
+ {BITSOFFS(96, 16), "EDRFECModeEnabled", mad_dump_uint},
+ {0, 0}, /* IB_PORT_EXT_LAST_F */
+
+ /*
+ * PortExtendedSpeedsCounters RSFEC Active fields
+ */
+ {BITSOFFS(8, 8), "PortSelect", mad_dump_uint},
+ {64, 64, "CounterSelect", mad_dump_hex},
+ {BITSOFFS(128, 16), "SyncHeaderErrorCounter", mad_dump_uint},
+ {BITSOFFS(144, 16), "UnknownBlockCounter", mad_dump_uint},
+ {352, 32, "FECCorrectableSymbolCtrLane0", mad_dump_uint},
+ {384, 32, "FECCorrectableSymbolCtrLane1", mad_dump_uint},
+ {416, 32, "FECCorrectableSymbolCtrLane2", mad_dump_uint},
+ {448, 32, "FECCorrectableSymbolCtrLane3", mad_dump_uint},
+ {480, 32, "FECCorrectableSymbolCtrLane4", mad_dump_uint},
+ {512, 32, "FECCorrectableSymbolCtrLane5", mad_dump_uint},
+ {544, 32, "FECCorrectableSymbolCtrLane6", mad_dump_uint},
+ {576, 32, "FECCorrectableSymbolCtrLane7", mad_dump_uint},
+ {608, 32, "FECCorrectableSymbolCtrLane8", mad_dump_uint},
+ {640, 32, "FECCorrectableSymbolCtrLane9", mad_dump_uint},
+ {672, 32, "FECCorrectableSymbolCtrLane10", mad_dump_uint},
+ {704, 32, "FECCorrectableSymbolCtrLane11", mad_dump_uint},
+ {1120, 32, "PortFECCorrectableBlockCtr", mad_dump_uint},
+ {1152, 32, "PortFECUncorrectableBlockCtr", mad_dump_uint},
+ {1184, 32, "PortFECCorrectedSymbolCtr", mad_dump_uint},
+ {0, 0}, /* IB_PESC_RSFEC_LAST_F */
+
+ /*
+ * More PortCountersExtended fields
+ */
+ {32, 32, "CounterSelect2", mad_dump_hex},
+ {576, 64, "SymbolErrorCounter", mad_dump_uint},
+ {640, 64, "LinkErrorRecoveryCounter", mad_dump_uint},
+ {704, 64, "LinkDownedCounter", mad_dump_uint},
+ {768, 64, "PortRcvErrors", mad_dump_uint},
+ {832, 64, "PortRcvRemotePhysicalErrors", mad_dump_uint},
+ {896, 64, "PortRcvSwitchRelayErrors", mad_dump_uint},
+ {960, 64, "PortXmitDiscards", mad_dump_uint},
+ {1024, 64, "PortXmitConstraintErrors", mad_dump_uint},
+ {1088, 64, "PortRcvConstraintErrors", mad_dump_uint},
+ {1152, 64, "LocalLinkIntegrityErrors", mad_dump_uint},
+ {1216, 64, "ExcessiveBufferOverrunErrors", mad_dump_uint},
+ {1280, 64, "VL15Dropped", mad_dump_uint},
+ {1344, 64, "PortXmitWait", mad_dump_uint},
+ {1408, 64, "QP1Dropped", mad_dump_uint},
+ {0, 0}, /* IB_PC_EXT_ERR_LAST_F */
+
+ /*
+ * Another PortCounters field
+ */
+ {160, 16, "QP1Dropped", mad_dump_uint},
+
+ {0, 0} /* IB_FIELD_LAST_ */
+};
+
+static void _set_field64(void *buf, int base_offs, const ib_field_t * f,
+ uint64_t val)
+{
+ uint64_t nval;
+
+ nval = htonll(val);
+ memcpy(((void *)(char *)buf + base_offs + f->bitoffs / 8),
+ (void *)&nval, sizeof(uint64_t));
+}
+
+static uint64_t _get_field64(void *buf, int base_offs, const ib_field_t * f)
+{
+ uint64_t val;
+ memcpy((void *)&val, (void *)((char *)buf + base_offs + f->bitoffs / 8),
+ sizeof(uint64_t));
+ return ntohll(val);
+}
+
+static void _set_field(void *buf, int base_offs, const ib_field_t * f,
+ uint32_t val)
+{
+ int prebits = (8 - (f->bitoffs & 7)) & 7;
+ int postbits = (f->bitoffs + f->bitlen) & 7;
+ int bytelen = f->bitlen / 8;
+ unsigned idx = base_offs + f->bitoffs / 8;
+ char *p = (char *)buf;
+
+ if (!bytelen && (f->bitoffs & 7) + f->bitlen < 8) {
+ p[3 ^ idx] &= ~((((1 << f->bitlen) - 1)) << (f->bitoffs & 7));
+ p[3 ^ idx] |=
+ (val & ((1 << f->bitlen) - 1)) << (f->bitoffs & 7);
+ return;
+ }
+
+ if (prebits) { /* val lsb in byte msb */
+ p[3 ^ idx] &= (1 << (8 - prebits)) - 1;
+ p[3 ^ idx++] |= (val & ((1 << prebits) - 1)) << (8 - prebits);
+ val >>= prebits;
+ }
+
+ /* BIG endian byte order */
+ for (; bytelen--; val >>= 8)
+ p[3 ^ idx++] = val & 0xff;
+
+ if (postbits) { /* val msb in byte lsb */
+ p[3 ^ idx] &= ~((1 << postbits) - 1);
+ p[3 ^ idx] |= val;
+ }
+}
+
+static uint32_t _get_field(void *buf, int base_offs, const ib_field_t * f)
+{
+ int prebits = (8 - (f->bitoffs & 7)) & 7;
+ int postbits = (f->bitoffs + f->bitlen) & 7;
+ int bytelen = f->bitlen / 8;
+ unsigned idx = base_offs + f->bitoffs / 8;
+ uint8_t *p = (uint8_t *) buf;
+ uint32_t val = 0, v = 0, i;
+
+ if (!bytelen && (f->bitoffs & 7) + f->bitlen < 8)
+ return (p[3 ^ idx] >> (f->bitoffs & 7)) & ((1 << f->bitlen) -
+ 1);
+
+ if (prebits) /* val lsb from byte msb */
+ v = p[3 ^ idx++] >> (8 - prebits);
+
+ if (postbits) { /* val msb from byte lsb */
+ i = base_offs + (f->bitoffs + f->bitlen) / 8;
+ val = (p[3 ^ i] & ((1 << postbits) - 1));
+ }
+
+ /* BIG endian byte order */
+ for (idx += bytelen - 1; bytelen--; idx--)
+ val = (val << 8) | p[3 ^ idx];
+
+ return (val << prebits) | v;
+}
+
+/* field must be byte aligned */
+static void _set_array(void *buf, int base_offs, const ib_field_t * f,
+ void *val)
+{
+ int bitoffs = f->bitoffs;
+
+ if (f->bitlen < 32)
+ bitoffs = BE_TO_BITSOFFS(bitoffs, f->bitlen);
+
+ memcpy((uint8_t *) buf + base_offs + bitoffs / 8, val, f->bitlen / 8);
+}
+
+static void _get_array(void *buf, int base_offs, const ib_field_t * f,
+ void *val)
+{
+ int bitoffs = f->bitoffs;
+
+ if (f->bitlen < 32)
+ bitoffs = BE_TO_BITSOFFS(bitoffs, f->bitlen);
+
+ memcpy(val, (uint8_t *) buf + base_offs + bitoffs / 8, f->bitlen / 8);
+}
+
+uint32_t mad_get_field(void *buf, int base_offs, enum MAD_FIELDS field)
+{
+ return _get_field(buf, base_offs, ib_mad_f + field);
+}
+
+void mad_set_field(void *buf, int base_offs, enum MAD_FIELDS field,
+ uint32_t val)
+{
+ _set_field(buf, base_offs, ib_mad_f + field, val);
+}
+
+uint64_t mad_get_field64(void *buf, int base_offs, enum MAD_FIELDS field)
+{
+ return _get_field64(buf, base_offs, ib_mad_f + field);
+}
+
+void mad_set_field64(void *buf, int base_offs, enum MAD_FIELDS field,
+ uint64_t val)
+{
+ _set_field64(buf, base_offs, ib_mad_f + field, val);
+}
+
+void mad_set_array(void *buf, int base_offs, enum MAD_FIELDS field, void *val)
+{
+ _set_array(buf, base_offs, ib_mad_f + field, val);
+}
+
+void mad_get_array(void *buf, int base_offs, enum MAD_FIELDS field, void *val)
+{
+ _get_array(buf, base_offs, ib_mad_f + field, val);
+}
+
+void mad_decode_field(uint8_t * buf, enum MAD_FIELDS field, void *val)
+{
+ const ib_field_t *f = ib_mad_f + field;
+
+ if (!field) {
+ *(int *)val = *(int *)buf;
+ return;
+ }
+ if (f->bitlen <= 32) {
+ *(uint32_t *) val = _get_field(buf, 0, f);
+ return;
+ }
+ if (f->bitlen == 64) {
+ *(uint64_t *) val = _get_field64(buf, 0, f);
+ return;
+ }
+ _get_array(buf, 0, f, val);
+}
+
+void mad_encode_field(uint8_t * buf, enum MAD_FIELDS field, void *val)
+{
+ const ib_field_t *f = ib_mad_f + field;
+
+ if (!field) {
+ *(int *)buf = *(int *)val;
+ return;
+ }
+ if (f->bitlen <= 32) {
+ _set_field(buf, 0, f, *(uint32_t *) val);
+ return;
+ }
+ if (f->bitlen == 64) {
+ _set_field64(buf, 0, f, *(uint64_t *) val);
+ return;
+ }
+ _set_array(buf, 0, f, val);
+}
+
+/************************/
+
+static char *_mad_dump_val(const ib_field_t * f, char *buf, int bufsz,
+ void *val)
+{
+ f->def_dump_fn(buf, bufsz, val, ALIGN(f->bitlen, 8) / 8);
+ buf[bufsz - 1] = 0;
+
+ return buf;
+}
+
+static char *_mad_dump_field(const ib_field_t * f, const char *name, char *buf,
+ int bufsz, void *val)
+{
+ char dots[128];
+ int l, n;
+
+ if (bufsz <= 32)
+ return NULL; /* buf too small */
+
+ if (!name)
+ name = f->name;
+
+ l = strlen(name);
+ if (l < 32) {
+ memset(dots, '.', 32 - l);
+ dots[32 - l] = 0;
+ }
+
+ n = snprintf(buf, bufsz, "%s:%s", name, dots);
+ _mad_dump_val(f, buf + n, bufsz - n, val);
+ buf[bufsz - 1] = 0;
+
+ return buf;
+}
+
+static int _mad_dump(ib_mad_dump_fn * fn, const char *name, void *val,
+ int valsz)
+{
+ ib_field_t f;
+ char buf[512];
+
+ f.def_dump_fn = fn;
+ f.bitlen = valsz * 8;
+
+ return printf("%s\n", _mad_dump_field(&f, name, buf, sizeof buf, val));
+}
+
+static int _mad_print_field(const ib_field_t * f, const char *name, void *val,
+ int valsz)
+{
+ return _mad_dump(f->def_dump_fn, name ? name : f->name, val,
+ valsz ? valsz : ALIGN(f->bitlen, 8) / 8);
+}
+
+int mad_print_field(enum MAD_FIELDS field, const char *name, void *val)
+{
+ if (field <= IB_NO_FIELD || field >= IB_FIELD_LAST_)
+ return -1;
+ return _mad_print_field(ib_mad_f + field, name, val, 0);
+}
+
+char *mad_dump_field(enum MAD_FIELDS field, char *buf, int bufsz, void *val)
+{
+ if (field <= IB_NO_FIELD || field >= IB_FIELD_LAST_)
+ return NULL;
+ return _mad_dump_field(ib_mad_f + field, 0, buf, bufsz, val);
+}
+
+char *mad_dump_val(enum MAD_FIELDS field, char *buf, int bufsz, void *val)
+{
+ if (field <= IB_NO_FIELD || field >= IB_FIELD_LAST_)
+ return NULL;
+ return _mad_dump_val(ib_mad_f + field, buf, bufsz, val);
+}
+
+const char *mad_field_name(enum MAD_FIELDS field)
+{
+ return (ib_mad_f[field].name);
+}
diff --git a/contrib/ofed/libibmad/gs.c b/contrib/ofed/libibmad/gs.c
new file mode 100644
index 0000000..90db7e2
--- /dev/null
+++ b/contrib/ofed/libibmad/gs.c
@@ -0,0 +1,133 @@
+/*
+ * Copyright (c) 2004-2009 Voltaire Inc. All rights reserved.
+ * Copyright (c) 2011 Mellanox Technologies LTD. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+#if HAVE_CONFIG_H
+# include <config.h>
+#endif /* HAVE_CONFIG_H */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
+
+#include <infiniband/umad.h>
+#include <infiniband/mad.h>
+
+#undef DEBUG
+#define DEBUG if (ibdebug) IBWARN
+
+uint8_t *pma_query_via(void *rcvbuf, ib_portid_t * dest, int port,
+ unsigned timeout, unsigned id,
+ const struct ibmad_port * srcport)
+{
+ ib_rpc_v1_t rpc = { 0 };
+ ib_rpc_t *rpcold = (ib_rpc_t *)(void *)&rpc;
+ int lid = dest->lid;
+ void *p_ret;
+
+ DEBUG("lid %u port %d", lid, port);
+
+ if (lid == -1) {
+ IBWARN("only lid routed is supported");
+ return NULL;
+ }
+
+ rpc.mgtclass = IB_PERFORMANCE_CLASS | IB_MAD_RPC_VERSION1;
+ rpc.method = IB_MAD_METHOD_GET;
+ rpc.attr.id = id;
+
+ /* Same for attribute IDs */
+ mad_set_field(rcvbuf, 0, IB_PC_PORT_SELECT_F, port);
+ rpc.attr.mod = 0;
+ rpc.timeout = timeout;
+ rpc.datasz = IB_PC_DATA_SZ;
+ rpc.dataoffs = IB_PC_DATA_OFFS;
+
+ if (!dest->qp)
+ dest->qp = 1;
+ if (!dest->qkey)
+ dest->qkey = IB_DEFAULT_QP1_QKEY;
+
+ p_ret = mad_rpc(srcport, rpcold, dest, rcvbuf, rcvbuf);
+ errno = rpc.error;
+ return p_ret;
+}
+
+uint8_t *performance_reset_via(void *rcvbuf, ib_portid_t * dest,
+ int port, unsigned mask, unsigned timeout,
+ unsigned id, const struct ibmad_port * srcport)
+{
+ ib_rpc_v1_t rpc = { 0 };
+ ib_rpc_t *rpcold = (ib_rpc_t *)(void *)&rpc;
+
+ int lid = dest->lid;
+ void *p_ret;
+
+ DEBUG("lid %u port %d mask 0x%x", lid, port, mask);
+
+ if (lid == -1) {
+ IBWARN("only lid routed is supported");
+ return NULL;
+ }
+
+ if (!mask)
+ mask = ~0;
+
+ rpc.mgtclass = IB_PERFORMANCE_CLASS | IB_MAD_RPC_VERSION1;
+ rpc.method = IB_MAD_METHOD_SET;
+ rpc.attr.id = id;
+
+ memset(rcvbuf, 0, IB_MAD_SIZE);
+
+ /* Next 2 lines - same for attribute IDs */
+ mad_set_field(rcvbuf, 0, IB_PC_PORT_SELECT_F, port);
+ mad_set_field(rcvbuf, 0, IB_PC_COUNTER_SELECT_F, mask);
+ mask = mask >> 16;
+ if (id == IB_GSI_PORT_COUNTERS_EXT)
+ mad_set_field(rcvbuf, 0, IB_PC_EXT_COUNTER_SELECT2_F, mask);
+ else
+ mad_set_field(rcvbuf, 0, IB_PC_COUNTER_SELECT2_F, mask);
+ rpc.attr.mod = 0;
+ rpc.timeout = timeout;
+ rpc.datasz = IB_PC_DATA_SZ;
+ rpc.dataoffs = IB_PC_DATA_OFFS;
+ if (!dest->qp)
+ dest->qp = 1;
+ if (!dest->qkey)
+ dest->qkey = IB_DEFAULT_QP1_QKEY;
+
+ p_ret = mad_rpc(srcport, rpcold, dest, rcvbuf, rcvbuf);
+ errno = rpc.error;
+ return p_ret;
+}
diff --git a/contrib/ofed/libibmad/libibmad.map b/contrib/ofed/libibmad/libibmad.map
new file mode 100644
index 0000000..2329ee0
--- /dev/null
+++ b/contrib/ofed/libibmad/libibmad.map
@@ -0,0 +1,160 @@
+IBMAD_1.3 {
+ global:
+ xdump;
+ mad_dump_field;
+ mad_dump_val;
+ mad_print_field;
+ mad_dump_array;
+ mad_dump_bitfield;
+ mad_dump_hex;
+ mad_dump_int;
+ mad_dump_linkdowndefstate;
+ mad_dump_linkspeed;
+ mad_dump_linkspeeden;
+ mad_dump_linkspeedsup;
+ mad_dump_linkspeedext;
+ mad_dump_linkspeedexten;
+ mad_dump_linkspeedextsup;
+ mad_dump_linkwidth;
+ mad_dump_linkwidthen;
+ mad_dump_linkwidthsup;
+ mad_dump_mlnx_ext_port_info;
+ mad_dump_portinfo_ext;
+ mad_dump_mtu;
+ mad_dump_node_type;
+ mad_dump_nodedesc;
+ mad_dump_nodeinfo;
+ mad_dump_opervls;
+ mad_dump_fields;
+ mad_dump_perfcounters;
+ mad_dump_perfcounters_ext;
+ mad_dump_perfcounters_xmt_sl;
+ mad_dump_perfcounters_rcv_sl;
+ mad_dump_perfcounters_xmt_disc;
+ mad_dump_perfcounters_rcv_err;
+ mad_dump_physportstate;
+ mad_dump_portcapmask;
+ mad_dump_portcapmask2;
+ mad_dump_portinfo;
+ mad_dump_portsamples_control;
+ mad_dump_portsamples_result;
+ mad_dump_perfcounters_port_op_rcv_counters;
+ mad_dump_perfcounters_port_flow_ctl_counters;
+ mad_dump_perfcounters_port_vl_op_packet;
+ mad_dump_perfcounters_port_vl_op_data;
+ mad_dump_perfcounters_port_vl_xmit_flow_ctl_update_errors;
+ mad_dump_perfcounters_port_vl_xmit_wait_counters;
+ mad_dump_perfcounters_sw_port_vl_congestion;
+ mad_dump_perfcounters_rcv_con_ctrl;
+ mad_dump_perfcounters_sl_rcv_fecn;
+ mad_dump_perfcounters_sl_rcv_becn;
+ mad_dump_perfcounters_xmit_con_ctrl;
+ mad_dump_perfcounters_vl_xmit_time_cong;
+ mad_dump_cc_congestioninfo;
+ mad_dump_cc_congestionkeyinfo;
+ mad_dump_cc_congestionlog;
+ mad_dump_cc_congestionlogswitch;
+ mad_dump_cc_congestionlogentryswitch;
+ mad_dump_cc_congestionlogca;
+ mad_dump_cc_congestionlogentryca;
+ mad_dump_cc_switchcongestionsetting;
+ mad_dump_cc_switchportcongestionsettingelement;
+ mad_dump_cc_cacongestionsetting;
+ mad_dump_cc_cacongestionentry;
+ mad_dump_cc_congestioncontroltable;
+ mad_dump_cc_congestioncontroltableentry;
+ mad_dump_cc_timestamp;
+ mad_dump_classportinfo;
+ mad_dump_portmirror_route;
+ mad_dump_portmirror_filter;
+ mad_dump_portmirror_ports;
+ mad_dump_portstates;
+ mad_dump_portstate;
+ mad_dump_rhex;
+ mad_dump_sltovl;
+ mad_dump_string;
+ mad_dump_switchinfo;
+ mad_dump_uint;
+ mad_dump_vlarbitration;
+ mad_dump_vlcap;
+ mad_get_field;
+ mad_set_field;
+ mad_get_field64;
+ mad_set_field64;
+ mad_get_array;
+ mad_set_array;
+ pma_query_via;
+ performance_reset_via;
+ mad_build_pkt;
+ mad_decode_field;
+ mad_encode;
+ mad_encode_field;
+ mad_trid;
+ portid2portnum;
+ portid2str;
+ str2drpath;
+ drpath2str;
+ mad_class_agent;
+ mad_register_client;
+ mad_register_server;
+ mad_register_client_via;
+ mad_register_server_via;
+ ib_resolve_portid_str;
+ ib_resolve_self;
+ ib_resolve_smlid;
+ ibdebug;
+ mad_rpc_open_port;
+ mad_rpc_close_port;
+ mad_rpc;
+ mad_rpc_rmpp;
+ mad_rpc_portid;
+ mad_rpc_class_agent;
+ mad_rpc_set_retries;
+ mad_rpc_set_timeout;
+ mad_get_timeout;
+ mad_get_retries;
+ madrpc;
+ madrpc_def_timeout;
+ madrpc_init;
+ madrpc_portid;
+ madrpc_rmpp;
+ madrpc_save_mad;
+ madrpc_set_retries;
+ madrpc_set_timeout;
+ madrpc_show_errors;
+ ib_path_query;
+ sa_call;
+ sa_rpc_call;
+ mad_alloc;
+ mad_free;
+ mad_receive;
+ mad_respond;
+ mad_receive_via;
+ mad_respond_via;
+ mad_send;
+ mad_send_via;
+ smp_query;
+ smp_set;
+ ib_vendor_call;
+ ib_vendor_call_via;
+ smp_query_via;
+ smp_query_status_via;
+ smp_set_via;
+ smp_set_status_via;
+ ib_path_query_via;
+ ib_resolve_smlid_via;
+ ib_resolve_guid_via;
+ ib_resolve_gid_via;
+ ib_resolve_portid_str_via;
+ ib_resolve_self_via;
+ mad_field_name;
+ bm_call_via;
+ mad_dump_port_ext_speeds_counters;
+ mad_dump_port_ext_speeds_counters_rsfec_active;
+ cc_query_status_via;
+ cc_config_status_via;
+ smp_mkey_get;
+ smp_mkey_set;
+ ib_node_query_via;
+ local: *;
+};
diff --git a/contrib/ofed/libibmad/mad.c b/contrib/ofed/libibmad/mad.c
new file mode 100644
index 0000000..5deefa2
--- /dev/null
+++ b/contrib/ofed/libibmad/mad.c
@@ -0,0 +1,211 @@
+/*
+ * Copyright (c) 2004-2009 Voltaire Inc. All rights reserved.
+ * Copyright (c) 2009 HNR Consulting. All rights reserved.
+ * Copyright (c) 2011 Mellanox Technologies LTD. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+#if HAVE_CONFIG_H
+# include <config.h>
+#endif /* HAVE_CONFIG_H */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <time.h>
+#include <errno.h>
+
+#include <infiniband/umad.h>
+#include <infiniband/mad.h>
+
+#include "mad_internal.h"
+
+#undef DEBUG
+#define DEBUG if (ibdebug) IBWARN
+
+#define GET_IB_USERLAND_TID(tid) (tid & 0x00000000ffffffff)
+/*
+ * Generate the 64 bit MAD transaction ID. The upper 32 bits are reserved for
+ * use by the kernel. We clear the upper 32 bits here, but MADs received from
+ * the kernel may contain kernel specific data in these bits, consequently
+ * userland TID matching should only be done on the lower 32 bits.
+ */
+uint64_t mad_trid(void)
+{
+ static uint64_t trid;
+ uint64_t next;
+
+ if (!trid) {
+ srandom((int)time(0) * getpid());
+ trid = random();
+ }
+ next = ++trid;
+ next = GET_IB_USERLAND_TID(next);
+ return next;
+}
+
+int mad_get_timeout(const struct ibmad_port *srcport, int override_ms)
+{
+ return (override_ms ? override_ms :
+ srcport->timeout ? srcport->timeout : madrpc_timeout);
+}
+
+int mad_get_retries(const struct ibmad_port *srcport)
+{
+ return (srcport->retries ? srcport->retries : madrpc_retries);
+}
+
+void *mad_encode(void *buf, ib_rpc_t * rpc, ib_dr_path_t * drpath, void *data)
+{
+ int is_resp = rpc->method & IB_MAD_RESPONSE;
+ int mgtclass;
+
+ /* first word */
+ mad_set_field(buf, 0, IB_MAD_METHOD_F, rpc->method);
+ mad_set_field(buf, 0, IB_MAD_RESPONSE_F, is_resp ? 1 : 0);
+ mgtclass = rpc->mgtclass & 0xff;
+ if (mgtclass == IB_SA_CLASS || mgtclass == IB_CC_CLASS)
+ mad_set_field(buf, 0, IB_MAD_CLASSVER_F, 2);
+ else
+ mad_set_field(buf, 0, IB_MAD_CLASSVER_F, 1);
+ mad_set_field(buf, 0, IB_MAD_MGMTCLASS_F, rpc->mgtclass & 0xff);
+ mad_set_field(buf, 0, IB_MAD_BASEVER_F, 1);
+
+ /* second word */
+ if ((rpc->mgtclass & 0xff) == IB_SMI_DIRECT_CLASS) {
+ if (!drpath) {
+ IBWARN("encoding dr mad without drpath (null)");
+ errno = EINVAL;
+ return NULL;
+ }
+ if (drpath->cnt >= IB_SUBNET_PATH_HOPS_MAX) {
+ IBWARN("dr path with hop count %d", drpath->cnt);
+ errno = EINVAL;
+ return NULL;
+ }
+ mad_set_field(buf, 0, IB_DRSMP_HOPCNT_F, drpath->cnt);
+ mad_set_field(buf, 0, IB_DRSMP_HOPPTR_F,
+ is_resp ? drpath->cnt + 1 : 0x0);
+ mad_set_field(buf, 0, IB_DRSMP_STATUS_F, rpc->rstatus);
+ mad_set_field(buf, 0, IB_DRSMP_DIRECTION_F, is_resp ? 1 : 0); /* out */
+ } else
+ mad_set_field(buf, 0, IB_MAD_STATUS_F, rpc->rstatus);
+
+ /* words 3,4,5,6 */
+ if (!rpc->trid)
+ rpc->trid = mad_trid();
+
+ mad_set_field64(buf, 0, IB_MAD_TRID_F, rpc->trid);
+ mad_set_field(buf, 0, IB_MAD_ATTRID_F, rpc->attr.id);
+ mad_set_field(buf, 0, IB_MAD_ATTRMOD_F, rpc->attr.mod);
+
+ /* words 7,8 */
+ mad_set_field64(buf, 0, IB_MAD_MKEY_F, rpc->mkey);
+
+ if ((rpc->mgtclass & 0xff) == IB_SMI_DIRECT_CLASS) {
+ /* word 9 */
+ mad_set_field(buf, 0, IB_DRSMP_DRDLID_F,
+ drpath->drdlid ? drpath->drdlid : 0xffff);
+ mad_set_field(buf, 0, IB_DRSMP_DRSLID_F,
+ drpath->drslid ? drpath->drslid : 0xffff);
+
+ /* bytes 128 - 256 - by default should be zero due to memset */
+ if (is_resp)
+ mad_set_array(buf, 0, IB_DRSMP_RPATH_F, drpath->p);
+ else
+ mad_set_array(buf, 0, IB_DRSMP_PATH_F, drpath->p);
+ }
+
+ if ((rpc->mgtclass & 0xff) == IB_SA_CLASS)
+ mad_set_field64(buf, 0, IB_SA_COMPMASK_F, rpc->mask);
+
+ if ((rpc->mgtclass & 0xff) == IB_CC_CLASS) {
+ ib_rpc_cc_t *rpccc = (ib_rpc_cc_t *)rpc;
+ mad_set_field64(buf, 0, IB_CC_CCKEY_F, rpccc->cckey);
+ }
+
+ if (data)
+ memcpy((char *)buf + rpc->dataoffs, data, rpc->datasz);
+
+ /* vendor mads range 2 */
+ if (mad_is_vendor_range2(rpc->mgtclass & 0xff))
+ mad_set_field(buf, 0, IB_VEND2_OUI_F, rpc->oui);
+
+ return (uint8_t *) buf + IB_MAD_SIZE;
+}
+
+int mad_build_pkt(void *umad, ib_rpc_t * rpc, ib_portid_t * dport,
+ ib_rmpp_hdr_t * rmpp, void *data)
+{
+ uint8_t *p, *mad;
+ int lid_routed = (rpc->mgtclass & 0xff) != IB_SMI_DIRECT_CLASS;
+ int is_smi = ((rpc->mgtclass & 0xff) == IB_SMI_CLASS ||
+ (rpc->mgtclass & 0xff) == IB_SMI_DIRECT_CLASS);
+ struct ib_mad_addr addr;
+
+ if (!is_smi)
+ umad_set_addr(umad, dport->lid, dport->qp, dport->sl,
+ dport->qkey);
+ else if (lid_routed)
+ umad_set_addr(umad, dport->lid, dport->qp, 0, 0);
+ else if ((dport->drpath.drslid != 0xffff) && (dport->lid > 0))
+ umad_set_addr(umad, dport->lid, 0, 0, 0);
+ else
+ umad_set_addr(umad, 0xffff, 0, 0, 0);
+
+ if (dport->grh_present && !is_smi) {
+ addr.grh_present = 1;
+ memcpy(addr.gid, dport->gid, 16);
+ addr.hop_limit = 0xff;
+ addr.traffic_class = 0;
+ addr.flow_label = 0;
+ umad_set_grh(umad, &addr);
+ } else
+ umad_set_grh(umad, 0);
+ umad_set_pkey(umad, is_smi ? 0 : dport->pkey_idx);
+
+ mad = umad_get_mad(umad);
+ p = mad_encode(mad, rpc, lid_routed ? 0 : &dport->drpath, data);
+ if (!p)
+ return -1;
+
+ if (!is_smi && rmpp) {
+ mad_set_field(mad, 0, IB_SA_RMPP_VERS_F, 1);
+ mad_set_field(mad, 0, IB_SA_RMPP_TYPE_F, rmpp->type);
+ mad_set_field(mad, 0, IB_SA_RMPP_RESP_F, 0x3f);
+ mad_set_field(mad, 0, IB_SA_RMPP_FLAGS_F, rmpp->flags);
+ mad_set_field(mad, 0, IB_SA_RMPP_STATUS_F, rmpp->status);
+ mad_set_field(mad, 0, IB_SA_RMPP_D1_F, rmpp->d1.u);
+ mad_set_field(mad, 0, IB_SA_RMPP_D2_F, rmpp->d2.u);
+ }
+
+ return ((int)(p - mad));
+}
diff --git a/contrib/ofed/libibmad/mad.h b/contrib/ofed/libibmad/mad.h
new file mode 100644
index 0000000..706e09f
--- /dev/null
+++ b/contrib/ofed/libibmad/mad.h
@@ -0,0 +1,1843 @@
+/*
+ * Copyright (c) 2004-2009 Voltaire Inc. All rights reserved.
+ * Copyright (c) 2009 HNR Consulting. All rights reserved.
+ * Copyright (c) 2009-2011 Mellanox Technologies LTD. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+#ifndef _MAD_H_
+#define _MAD_H_
+
+#include <infiniband/mad_osd.h>
+
+#ifdef __cplusplus
+# define BEGIN_C_DECLS extern "C" {
+# define END_C_DECLS }
+#else /* !__cplusplus */
+# define BEGIN_C_DECLS
+# define END_C_DECLS
+#endif /* __cplusplus */
+
+BEGIN_C_DECLS
+#define IB_MAD_RPC_VERSION_MASK 0x0f00
+#define IB_MAD_RPC_VERSION1 (1<<8)
+
+#define IB_SUBNET_PATH_HOPS_MAX 64
+#define IB_DEFAULT_SUBN_PREFIX 0xfe80000000000000ULL
+#define IB_DEFAULT_QP1_QKEY 0x80010000
+#define IB_MAD_SIZE 256
+#define IB_SMP_DATA_OFFS 64
+#define IB_SMP_DATA_SIZE 64
+#define IB_VENDOR_RANGE1_DATA_OFFS 24
+#define IB_VENDOR_RANGE1_DATA_SIZE (IB_MAD_SIZE - IB_VENDOR_RANGE1_DATA_OFFS)
+#define IB_VENDOR_RANGE2_DATA_OFFS 40
+#define IB_VENDOR_RANGE2_DATA_SIZE (IB_MAD_SIZE - IB_VENDOR_RANGE2_DATA_OFFS)
+#define IB_SA_DATA_SIZE 200
+#define IB_SA_DATA_OFFS 56
+#define IB_PC_DATA_OFFS 64
+#define IB_PC_DATA_SZ (IB_MAD_SIZE - IB_PC_DATA_OFFS)
+#define IB_SA_MCM_RECSZ 53
+#define IB_SA_PR_RECSZ 64
+#define IB_SA_NR_RECSZ 108
+#define IB_SA_GIR_RECSZ 72
+#define IB_BM_DATA_OFFS 64
+#define IB_BM_DATA_SZ (IB_MAD_SIZE - IB_BM_DATA_OFFS)
+#define IB_BM_BKEY_OFFS 24
+#define IB_BM_BKEY_AND_DATA_SZ (IB_MAD_SIZE - IB_BM_BKEY_OFFS)
+#define IB_CC_DATA_OFFS 64
+#define IB_CC_DATA_SZ (IB_MAD_SIZE - IB_CC_DATA_OFFS)
+#define IB_CC_LOG_DATA_OFFS 32
+#define IB_CC_LOG_DATA_SZ (IB_MAD_SIZE - IB_CC_LOG_DATA_OFFS)
+
+enum MAD_CLASSES {
+ IB_SMI_CLASS = 0x1,
+ IB_SMI_DIRECT_CLASS = 0x81,
+ IB_SA_CLASS = 0x3,
+ IB_PERFORMANCE_CLASS = 0x4,
+ IB_BOARD_MGMT_CLASS = 0x5,
+ IB_DEVICE_MGMT_CLASS = 0x6,
+ IB_CM_CLASS = 0x7,
+ IB_SNMP_CLASS = 0x8,
+ IB_VENDOR_RANGE1_START_CLASS = 0x9,
+ IB_VENDOR_RANGE1_END_CLASS = 0x0f,
+ IB_CC_CLASS = 0x21,
+ IB_VENDOR_RANGE2_START_CLASS = 0x30,
+ IB_VENDOR_RANGE2_END_CLASS = 0x4f,
+};
+
+enum MAD_METHODS {
+ IB_MAD_METHOD_GET = 0x1,
+ IB_MAD_METHOD_SET = 0x2,
+ IB_MAD_METHOD_GET_RESPONSE = 0x81,
+
+ IB_MAD_METHOD_SEND = 0x3,
+ IB_MAD_METHOD_TRAP = 0x5,
+ IB_MAD_METHOD_TRAP_REPRESS = 0x7,
+
+ IB_MAD_METHOD_REPORT = 0x6,
+ IB_MAD_METHOD_REPORT_RESPONSE = 0x86,
+ IB_MAD_METHOD_GET_TABLE = 0x12,
+ IB_MAD_METHOD_GET_TABLE_RESPONSE = 0x92,
+ IB_MAD_METHOD_GET_TRACE_TABLE = 0x13,
+ IB_MAD_METHOD_GET_TRACE_TABLE_RESPONSE = 0x93,
+ IB_MAD_METHOD_GETMULTI = 0x14,
+ IB_MAD_METHOD_GETMULTI_RESPONSE = 0x94,
+ IB_MAD_METHOD_DELETE = 0x15,
+ IB_MAD_METHOD_DELETE_RESPONSE = 0x95,
+
+ IB_MAD_RESPONSE = 0x80,
+};
+
+enum MAD_ATTR_ID {
+ CLASS_PORT_INFO = 0x1,
+ NOTICE = 0x2,
+ INFORM_INFO = 0x3,
+};
+
+enum MAD_STATUS {
+ IB_MAD_STS_OK = (0 << 2),
+ IB_MAD_STS_BUSY = (1 << 0),
+ IB_MAD_STS_REDIRECT = (1 << 1),
+ IB_MAD_STS_BAD_BASE_VER_OR_CLASS = (1 << 2),
+ IB_MAD_STS_METHOD_NOT_SUPPORTED = (2 << 2),
+ IB_MAD_STS_METHOD_ATTR_NOT_SUPPORTED = (3 << 2),
+ IB_MAD_STS_INV_ATTR_VALUE = (7 << 2),
+};
+
+enum SMI_ATTR_ID {
+ IB_ATTR_NODE_DESC = 0x10,
+ IB_ATTR_NODE_INFO = 0x11,
+ IB_ATTR_SWITCH_INFO = 0x12,
+ IB_ATTR_GUID_INFO = 0x14,
+ IB_ATTR_PORT_INFO = 0x15,
+ IB_ATTR_PKEY_TBL = 0x16,
+ IB_ATTR_SLVL_TABLE = 0x17,
+ IB_ATTR_VL_ARBITRATION = 0x18,
+ IB_ATTR_LINEARFORWTBL = 0x19,
+ IB_ATTR_MULTICASTFORWTBL = 0x1b,
+ IB_ATTR_LINKSPEEDWIDTHPAIRSTBL = 0x1c,
+ IB_ATTR_VENDORMADSTBL = 0x1d,
+ IB_ATTR_SMINFO = 0x20,
+ IB_ATTR_PORT_INFO_EXT = 0x33,
+ IB_ATTR_LAST,
+
+ IB_ATTR_MLNX_EXT_PORT_INFO = 0xff90,
+};
+
+enum SA_ATTR_ID {
+ IB_SA_ATTR_NOTICE = 0x02,
+ IB_SA_ATTR_INFORMINFO = 0x03,
+ IB_SA_ATTR_NODERECORD = 0x11,
+ IB_SA_ATTR_PORTINFORECORD = 0x12,
+ IB_SA_ATTR_SL2VLTABLERECORD = 0x13,
+ IB_SA_ATTR_SWITCHINFORECORD = 0x14,
+ IB_SA_ATTR_LFTRECORD = 0x15,
+ IB_SA_ATTR_RFTRECORD = 0x16,
+ IB_SA_ATTR_MFTRECORD = 0x17,
+ IB_SA_ATTR_SMINFORECORD = 0x18,
+ IB_SA_ATTR_LINKRECORD = 0x20,
+ IB_SA_ATTR_GUIDINFORECORD = 0x30,
+ IB_SA_ATTR_SERVICERECORD = 0x31,
+ IB_SA_ATTR_PKEYTABLERECORD = 0x33,
+ IB_SA_ATTR_PATHRECORD = 0x35,
+ IB_SA_ATTR_VLARBTABLERECORD = 0x36,
+ IB_SA_ATTR_MCRECORD = 0x38,
+ IB_SA_ATTR_MULTIPATH = 0x3a,
+ IB_SA_ATTR_INFORMINFORECORD = 0xf3,
+
+ IB_SA_ATTR_LAST
+};
+
+enum GSI_ATTR_ID {
+ IB_GSI_PORT_SAMPLES_CONTROL = 0x10,
+ IB_GSI_PORT_SAMPLES_RESULT = 0x11,
+ IB_GSI_PORT_COUNTERS = 0x12,
+ IB_GSI_PORT_RCV_ERROR_DETAILS = 0x15,
+ IB_GSI_PORT_XMIT_DISCARD_DETAILS = 0x16,
+ IB_GSI_PORT_PORT_OP_RCV_COUNTERS = 0x17,
+ IB_GSI_PORT_PORT_FLOW_CTL_COUNTERS = 0x18,
+ IB_GSI_PORT_PORT_VL_OP_PACKETS = 0x19,
+ IB_GSI_PORT_PORT_VL_OP_DATA = 0x1A,
+ IB_GSI_PORT_PORT_VL_XMIT_FLOW_CTL_UPDATE_ERRORS = 0x1B,
+ IB_GSI_PORT_PORT_VL_XMIT_WAIT_COUNTERS = 0x1C,
+ IB_GSI_PORT_COUNTERS_EXT = 0x1D,
+ IB_GSI_PORT_EXT_SPEEDS_COUNTERS = 0x1F,
+ IB_GSI_SW_PORT_VL_CONGESTION = 0x30,
+ IB_GSI_PORT_RCV_CON_CTRL = 0x31,
+ IB_GSI_PORT_SL_RCV_FECN = 0x32,
+ IB_GSI_PORT_SL_RCV_BECN = 0x33,
+ IB_GSI_PORT_XMIT_CON_CTRL = 0x34,
+ IB_GSI_PORT_VL_XMIT_TIME_CONG = 0x35,
+ IB_GSI_PORT_XMIT_DATA_SL = 0x36,
+ IB_GSI_PORT_RCV_DATA_SL = 0x37,
+ IB_GSI_ATTR_LAST
+};
+
+enum BM_ATTR_ID {
+ IB_BM_ATTR_BKEYINFO = 0x10,
+ IB_BM_ATTR_WRITE_VPD = 0x20,
+ IB_BM_ATTR_READ_VPD = 0x21,
+ IB_BM_ATTR_RESET_IBML = 0x22,
+ IB_BM_ATTR_SET_MODULE_PM_CONTROL = 0x23,
+ IB_BM_ATTR_GET_MODULE_PM_CONTROL = 0x24,
+ IB_BM_ATTR_SET_UNIT_PM_CONTROL = 0x25,
+ IB_BM_ATTR_GET_UNIT_PM_CONTROL = 0x26,
+ IB_BM_ATTR_SET_IOC_PM_CONTROL = 0x27,
+ IB_BM_ATTR_GET_IOC_PM_CONTROL = 0x28,
+ IB_BM_ATTR_SET_MODULE_STATE = 0x29,
+ IB_BM_ATTR_SET_MODULE_ATTENTION = 0x2A,
+ IB_BM_ATTR_GET_MODULE_STATUS = 0x2B,
+ IB_BM_ATTR_IB2IBML = 0x2C,
+ IB_BM_ATTR_IB2CME = 0x2D,
+ IB_BM_ATTR_IB2MME = 0x2E,
+ IB_BM_ATTR_OEM = 0x2F,
+
+ IB_BM_ATTR_LAST
+};
+
+enum CC_ATTRI_ID {
+ IB_CC_ATTR_CONGESTION_INFO = 0x11,
+ IB_CC_ATTR_CONGESTION_KEY_INFO = 0x12,
+ IB_CC_ATTR_CONGESTION_LOG = 0x13,
+ IB_CC_ATTR_SWITCH_CONGESTION_SETTING = 0x14,
+ IB_CC_ATTR_SWITCH_PORT_CONGESTION_SETTING = 0x15,
+ IB_CC_ATTR_CA_CONGESTION_SETTING = 0x16,
+ IB_CC_ATTR_CONGESTION_CONTROL_TABLE = 0x17,
+ IB_CC_ATTR_TIMESTAMP = 0x18,
+};
+
+#define IB_VENDOR_OPENIB_PING_CLASS (IB_VENDOR_RANGE2_START_CLASS + 2)
+#define IB_VENDOR_OPENIB_SYSSTAT_CLASS (IB_VENDOR_RANGE2_START_CLASS + 3)
+#define IB_OPENIB_OUI (0x001405)
+
+typedef uint8_t ibmad_gid_t[16];
+#ifdef USE_DEPRECATED_IB_GID_T
+typedef ibmad_gid_t ib_gid_t __attribute__ ((deprecated));
+#endif
+
+typedef struct {
+ int cnt;
+ uint8_t p[IB_SUBNET_PATH_HOPS_MAX];
+ uint16_t drslid;
+ uint16_t drdlid;
+} ib_dr_path_t;
+
+typedef struct {
+ unsigned id;
+ unsigned mod;
+} ib_attr_t;
+
+typedef struct {
+ int mgtclass;
+ int method;
+ ib_attr_t attr;
+ uint32_t rstatus; /* return status */
+ int dataoffs;
+ int datasz;
+ uint64_t mkey;
+ uint64_t trid; /* used for out mad if nonzero, return real val */
+ uint64_t mask; /* for sa mads */
+ unsigned recsz; /* for sa mads (attribute offset) */
+ int timeout;
+ uint32_t oui; /* for vendor range 2 mads */
+} ib_rpc_t;
+
+typedef struct {
+ int mgtclass;
+ int method;
+ ib_attr_t attr;
+ uint32_t rstatus; /* return status */
+ int dataoffs;
+ int datasz;
+ uint64_t mkey;
+ uint64_t trid; /* used for out mad if nonzero, return real val */
+ uint64_t mask; /* for sa mads */
+ unsigned recsz; /* for sa mads (attribute offset) */
+ int timeout;
+ uint32_t oui; /* for vendor range 2 mads */
+ int error; /* errno */
+} ib_rpc_v1_t;
+
+typedef struct {
+ int mgtclass;
+ int method;
+ ib_attr_t attr;
+ uint32_t rstatus; /* return status */
+ int dataoffs;
+ int datasz;
+ uint64_t mkey;
+ uint64_t trid; /* used for out mad if nonzero, return real val */
+ uint64_t mask; /* for sa mads */
+ unsigned recsz; /* for sa mads (attribute offset) */
+ int timeout;
+ uint32_t oui; /* for vendor range 2 mads */
+ int error; /* errno */
+ uint64_t cckey;
+} ib_rpc_cc_t;
+
+typedef struct portid {
+ int lid; /* lid or 0 if directed route */
+ ib_dr_path_t drpath;
+ int grh_present; /* flag */
+ ibmad_gid_t gid;
+ uint32_t qp;
+ uint32_t qkey;
+ uint8_t sl;
+ unsigned pkey_idx;
+} ib_portid_t;
+
+typedef void (ib_mad_dump_fn) (char *buf, int bufsz, void *val, int valsz);
+
+#define IB_FIELD_NAME_LEN 32
+
+typedef struct ib_field {
+ int bitoffs;
+ int bitlen;
+ char name[IB_FIELD_NAME_LEN];
+ ib_mad_dump_fn *def_dump_fn;
+} ib_field_t;
+
+enum MAD_FIELDS {
+ IB_NO_FIELD,
+
+ IB_GID_PREFIX_F,
+ IB_GID_GUID_F,
+
+ /* first MAD word (0-3 bytes) */
+ IB_MAD_METHOD_F,
+ IB_MAD_RESPONSE_F,
+ IB_MAD_CLASSVER_F,
+ IB_MAD_MGMTCLASS_F,
+ IB_MAD_BASEVER_F,
+
+ /* second MAD word (4-7 bytes) */
+ IB_MAD_STATUS_F,
+
+ /* DRSMP only */
+ IB_DRSMP_HOPCNT_F,
+ IB_DRSMP_HOPPTR_F,
+ IB_DRSMP_STATUS_F,
+ IB_DRSMP_DIRECTION_F,
+
+ /* words 3,4,5,6 (8-23 bytes) */
+ IB_MAD_TRID_F,
+ IB_MAD_ATTRID_F,
+ IB_MAD_ATTRMOD_F,
+
+ /* word 7,8 (24-31 bytes) */
+ IB_MAD_MKEY_F,
+
+ /* word 9 (32-37 bytes) */
+ IB_DRSMP_DRDLID_F,
+ IB_DRSMP_DRSLID_F,
+
+ /* word 10,11 (36-43 bytes) */
+ IB_SA_MKEY_F,
+
+ /* word 12 (44-47 bytes) */
+ IB_SA_ATTROFFS_F,
+
+ /* word 13,14 (48-55 bytes) */
+ IB_SA_COMPMASK_F,
+
+ /* word 13,14 (56-255 bytes) */
+ IB_SA_DATA_F,
+
+ /* bytes 64 - 127 */
+ IB_SM_DATA_F,
+
+ /* bytes 64 - 256 */
+ IB_GS_DATA_F,
+
+ /* bytes 128 - 191 */
+ IB_DRSMP_PATH_F,
+
+ /* bytes 192 - 255 */
+ IB_DRSMP_RPATH_F,
+
+ /*
+ * PortInfo fields
+ */
+ IB_PORT_FIRST_F,
+ IB_PORT_MKEY_F = IB_PORT_FIRST_F,
+ IB_PORT_GID_PREFIX_F,
+ IB_PORT_LID_F,
+ IB_PORT_SMLID_F,
+ IB_PORT_CAPMASK_F,
+ IB_PORT_DIAG_F,
+ IB_PORT_MKEY_LEASE_F,
+ IB_PORT_LOCAL_PORT_F,
+ IB_PORT_LINK_WIDTH_ENABLED_F,
+ IB_PORT_LINK_WIDTH_SUPPORTED_F,
+ IB_PORT_LINK_WIDTH_ACTIVE_F,
+ IB_PORT_LINK_SPEED_SUPPORTED_F,
+ IB_PORT_STATE_F,
+ IB_PORT_PHYS_STATE_F,
+ IB_PORT_LINK_DOWN_DEF_F,
+ IB_PORT_MKEY_PROT_BITS_F,
+ IB_PORT_LMC_F,
+ IB_PORT_LINK_SPEED_ACTIVE_F,
+ IB_PORT_LINK_SPEED_ENABLED_F,
+ IB_PORT_NEIGHBOR_MTU_F,
+ IB_PORT_SMSL_F,
+ IB_PORT_VL_CAP_F,
+ IB_PORT_INIT_TYPE_F,
+ IB_PORT_VL_HIGH_LIMIT_F,
+ IB_PORT_VL_ARBITRATION_HIGH_CAP_F,
+ IB_PORT_VL_ARBITRATION_LOW_CAP_F,
+ IB_PORT_INIT_TYPE_REPLY_F,
+ IB_PORT_MTU_CAP_F,
+ IB_PORT_VL_STALL_COUNT_F,
+ IB_PORT_HOQ_LIFE_F,
+ IB_PORT_OPER_VLS_F,
+ IB_PORT_PART_EN_INB_F,
+ IB_PORT_PART_EN_OUTB_F,
+ IB_PORT_FILTER_RAW_INB_F,
+ IB_PORT_FILTER_RAW_OUTB_F,
+ IB_PORT_MKEY_VIOL_F,
+ IB_PORT_PKEY_VIOL_F,
+ IB_PORT_QKEY_VIOL_F,
+ IB_PORT_GUID_CAP_F,
+ IB_PORT_CLIENT_REREG_F,
+ IB_PORT_MCAST_PKEY_SUPR_ENAB_F,
+ IB_PORT_SUBN_TIMEOUT_F,
+ IB_PORT_RESP_TIME_VAL_F,
+ IB_PORT_LOCAL_PHYS_ERR_F,
+ IB_PORT_OVERRUN_ERR_F,
+ IB_PORT_MAX_CREDIT_HINT_F,
+ IB_PORT_LINK_ROUND_TRIP_F,
+ IB_PORT_LAST_F,
+
+ /*
+ * NodeInfo fields
+ */
+ IB_NODE_FIRST_F,
+ IB_NODE_BASE_VERS_F = IB_NODE_FIRST_F,
+ IB_NODE_CLASS_VERS_F,
+ IB_NODE_TYPE_F,
+ IB_NODE_NPORTS_F,
+ IB_NODE_SYSTEM_GUID_F,
+ IB_NODE_GUID_F,
+ IB_NODE_PORT_GUID_F,
+ IB_NODE_PARTITION_CAP_F,
+ IB_NODE_DEVID_F,
+ IB_NODE_REVISION_F,
+ IB_NODE_LOCAL_PORT_F,
+ IB_NODE_VENDORID_F,
+ IB_NODE_LAST_F,
+
+ /*
+ * SwitchInfo fields
+ */
+ IB_SW_FIRST_F,
+ IB_SW_LINEAR_FDB_CAP_F = IB_SW_FIRST_F,
+ IB_SW_RANDOM_FDB_CAP_F,
+ IB_SW_MCAST_FDB_CAP_F,
+ IB_SW_LINEAR_FDB_TOP_F,
+ IB_SW_DEF_PORT_F,
+ IB_SW_DEF_MCAST_PRIM_F,
+ IB_SW_DEF_MCAST_NOT_PRIM_F,
+ IB_SW_LIFE_TIME_F,
+ IB_SW_STATE_CHANGE_F,
+ IB_SW_OPT_SLTOVL_MAPPING_F,
+ IB_SW_LIDS_PER_PORT_F,
+ IB_SW_PARTITION_ENFORCE_CAP_F,
+ IB_SW_PARTITION_ENF_INB_F,
+ IB_SW_PARTITION_ENF_OUTB_F,
+ IB_SW_FILTER_RAW_INB_F,
+ IB_SW_FILTER_RAW_OUTB_F,
+ IB_SW_ENHANCED_PORT0_F,
+ IB_SW_MCAST_FDB_TOP_F,
+ IB_SW_LAST_F,
+
+ /*
+ * SwitchLinearForwardingTable fields
+ */
+ IB_LINEAR_FORW_TBL_F,
+
+ /*
+ * SwitchMulticastForwardingTable fields
+ */
+ IB_MULTICAST_FORW_TBL_F,
+
+ /*
+ * NodeDescription fields
+ */
+ IB_NODE_DESC_F,
+
+ /*
+ * Notice/Trap fields
+ */
+ IB_NOTICE_IS_GENERIC_F,
+ IB_NOTICE_TYPE_F,
+ IB_NOTICE_PRODUCER_F,
+ IB_NOTICE_TRAP_NUMBER_F,
+ IB_NOTICE_ISSUER_LID_F,
+ IB_NOTICE_TOGGLE_F,
+ IB_NOTICE_COUNT_F,
+ IB_NOTICE_DATA_DETAILS_F,
+ IB_NOTICE_DATA_LID_F,
+ IB_NOTICE_DATA_144_LID_F,
+ IB_NOTICE_DATA_144_CAPMASK_F,
+
+ /*
+ * GS Performance
+ */
+ IB_PC_FIRST_F,
+ IB_PC_PORT_SELECT_F = IB_PC_FIRST_F,
+ IB_PC_COUNTER_SELECT_F,
+ IB_PC_ERR_SYM_F,
+ IB_PC_LINK_RECOVERS_F,
+ IB_PC_LINK_DOWNED_F,
+ IB_PC_ERR_RCV_F,
+ IB_PC_ERR_PHYSRCV_F,
+ IB_PC_ERR_SWITCH_REL_F,
+ IB_PC_XMT_DISCARDS_F,
+ IB_PC_ERR_XMTCONSTR_F,
+ IB_PC_ERR_RCVCONSTR_F,
+ IB_PC_COUNTER_SELECT2_F,
+ IB_PC_ERR_LOCALINTEG_F,
+ IB_PC_ERR_EXCESS_OVR_F,
+ IB_PC_VL15_DROPPED_F,
+ IB_PC_XMT_BYTES_F,
+ IB_PC_RCV_BYTES_F,
+ IB_PC_XMT_PKTS_F,
+ IB_PC_RCV_PKTS_F,
+ IB_PC_XMT_WAIT_F,
+ IB_PC_LAST_F,
+
+ /*
+ * SMInfo
+ */
+ IB_SMINFO_GUID_F,
+ IB_SMINFO_KEY_F,
+ IB_SMINFO_ACT_F,
+ IB_SMINFO_PRIO_F,
+ IB_SMINFO_STATE_F,
+
+ /*
+ * SA RMPP
+ */
+ IB_SA_RMPP_VERS_F,
+ IB_SA_RMPP_TYPE_F,
+ IB_SA_RMPP_RESP_F,
+ IB_SA_RMPP_FLAGS_F,
+ IB_SA_RMPP_STATUS_F,
+
+ /* data1 */
+ IB_SA_RMPP_D1_F,
+ IB_SA_RMPP_SEGNUM_F,
+ /* data2 */
+ IB_SA_RMPP_D2_F,
+ IB_SA_RMPP_LEN_F, /* DATA: Payload len */
+ IB_SA_RMPP_NEWWIN_F, /* ACK: new window last */
+
+ /*
+ * SA Multi Path rec
+ */
+ IB_SA_MP_NPATH_F,
+ IB_SA_MP_NSRC_F,
+ IB_SA_MP_NDEST_F,
+ IB_SA_MP_GID0_F,
+
+ /*
+ * SA Path rec
+ */
+ IB_SA_PR_DGID_F,
+ IB_SA_PR_SGID_F,
+ IB_SA_PR_DLID_F,
+ IB_SA_PR_SLID_F,
+ IB_SA_PR_NPATH_F,
+ IB_SA_PR_SL_F,
+
+ /*
+ * MC Member rec
+ */
+ IB_SA_MCM_MGID_F,
+ IB_SA_MCM_PORTGID_F,
+ IB_SA_MCM_QKEY_F,
+ IB_SA_MCM_MLID_F,
+ IB_SA_MCM_SL_F,
+ IB_SA_MCM_MTU_F,
+ IB_SA_MCM_RATE_F,
+ IB_SA_MCM_TCLASS_F,
+ IB_SA_MCM_PKEY_F,
+ IB_SA_MCM_FLOW_LABEL_F,
+ IB_SA_MCM_JOIN_STATE_F,
+ IB_SA_MCM_PROXY_JOIN_F,
+
+ /*
+ * Service record
+ */
+ IB_SA_SR_ID_F,
+ IB_SA_SR_GID_F,
+ IB_SA_SR_PKEY_F,
+ IB_SA_SR_LEASE_F,
+ IB_SA_SR_KEY_F,
+ IB_SA_SR_NAME_F,
+ IB_SA_SR_DATA_F,
+
+ /*
+ * ATS SM record - within SA_SR_DATA
+ */
+ IB_ATS_SM_NODE_ADDR_F,
+ IB_ATS_SM_MAGIC_KEY_F,
+ IB_ATS_SM_NODE_TYPE_F,
+ IB_ATS_SM_NODE_NAME_F,
+
+ /*
+ * SLTOVL MAPPING TABLE
+ */
+ IB_SLTOVL_MAPPING_TABLE_F,
+
+ /*
+ * VL ARBITRATION TABLE
+ */
+ IB_VL_ARBITRATION_TABLE_F,
+
+ /*
+ * IB vendor class range 2
+ */
+ IB_VEND2_OUI_F,
+ IB_VEND2_DATA_F,
+
+ /*
+ * PortCountersExtended
+ */
+ IB_PC_EXT_FIRST_F,
+ IB_PC_EXT_PORT_SELECT_F = IB_PC_EXT_FIRST_F,
+ IB_PC_EXT_COUNTER_SELECT_F,
+ IB_PC_EXT_XMT_BYTES_F,
+ IB_PC_EXT_RCV_BYTES_F,
+ IB_PC_EXT_XMT_PKTS_F,
+ IB_PC_EXT_RCV_PKTS_F,
+ IB_PC_EXT_XMT_UPKTS_F,
+ IB_PC_EXT_RCV_UPKTS_F,
+ IB_PC_EXT_XMT_MPKTS_F,
+ IB_PC_EXT_RCV_MPKTS_F,
+ IB_PC_EXT_LAST_F,
+
+ /*
+ * GUIDInfo fields
+ */
+ IB_GUID_GUID0_F, /* Obsolete, kept for compatibility
+ Use IB_GI_GUID0_F going forward */
+
+ /*
+ * ClassPortInfo fields
+ */
+ IB_CPI_BASEVER_F,
+ IB_CPI_CLASSVER_F,
+ IB_CPI_CAPMASK_F,
+ IB_CPI_CAPMASK2_F,
+ IB_CPI_RESP_TIME_VALUE_F,
+ IB_CPI_REDIRECT_GID_F,
+ IB_CPI_REDIRECT_TC_F,
+ IB_CPI_REDIRECT_SL_F,
+ IB_CPI_REDIRECT_FL_F,
+ IB_CPI_REDIRECT_LID_F,
+ IB_CPI_REDIRECT_PKEY_F,
+ IB_CPI_REDIRECT_QP_F,
+ IB_CPI_REDIRECT_QKEY_F,
+ IB_CPI_TRAP_GID_F,
+ IB_CPI_TRAP_TC_F,
+ IB_CPI_TRAP_SL_F,
+ IB_CPI_TRAP_FL_F,
+ IB_CPI_TRAP_LID_F,
+ IB_CPI_TRAP_PKEY_F,
+ IB_CPI_TRAP_HL_F,
+ IB_CPI_TRAP_QP_F,
+ IB_CPI_TRAP_QKEY_F,
+
+ /*
+ * PortXmitDataSL fields
+ */
+ IB_PC_XMT_DATA_SL_FIRST_F, /* for PortSelect and CounterSelect, use IB_PC_PORT_SELECT_F and IB_PC_COUNTER_SELECT_F */
+ IB_PC_XMT_DATA_SL0_F = IB_PC_XMT_DATA_SL_FIRST_F,
+ IB_PC_XMT_DATA_SL1_F,
+ IB_PC_XMT_DATA_SL2_F,
+ IB_PC_XMT_DATA_SL3_F,
+ IB_PC_XMT_DATA_SL4_F,
+ IB_PC_XMT_DATA_SL5_F,
+ IB_PC_XMT_DATA_SL6_F,
+ IB_PC_XMT_DATA_SL7_F,
+ IB_PC_XMT_DATA_SL8_F,
+ IB_PC_XMT_DATA_SL9_F,
+ IB_PC_XMT_DATA_SL10_F,
+ IB_PC_XMT_DATA_SL11_F,
+ IB_PC_XMT_DATA_SL12_F,
+ IB_PC_XMT_DATA_SL13_F,
+ IB_PC_XMT_DATA_SL14_F,
+ IB_PC_XMT_DATA_SL15_F,
+ IB_PC_XMT_DATA_SL_LAST_F,
+
+ /*
+ * PortRcvDataSL fields
+ */
+ IB_PC_RCV_DATA_SL_FIRST_F, /* for PortSelect and CounterSelect, use IB_PC_PORT_SELECT_F and IB_PC_COUNTER_SELECT_F */
+ IB_PC_RCV_DATA_SL0_F = IB_PC_RCV_DATA_SL_FIRST_F,
+ IB_PC_RCV_DATA_SL1_F,
+ IB_PC_RCV_DATA_SL2_F,
+ IB_PC_RCV_DATA_SL3_F,
+ IB_PC_RCV_DATA_SL4_F,
+ IB_PC_RCV_DATA_SL5_F,
+ IB_PC_RCV_DATA_SL6_F,
+ IB_PC_RCV_DATA_SL7_F,
+ IB_PC_RCV_DATA_SL8_F,
+ IB_PC_RCV_DATA_SL9_F,
+ IB_PC_RCV_DATA_SL10_F,
+ IB_PC_RCV_DATA_SL11_F,
+ IB_PC_RCV_DATA_SL12_F,
+ IB_PC_RCV_DATA_SL13_F,
+ IB_PC_RCV_DATA_SL14_F,
+ IB_PC_RCV_DATA_SL15_F,
+ IB_PC_RCV_DATA_SL_LAST_F,
+
+ /*
+ * PortXmitDiscardDetails fields
+ */
+ /* for PortSelect and CounterSelect, use IB_PC_PORT_SELECT_F and IB_PC_COUNTER_SELECT_F */
+ IB_PC_XMT_INACT_DISC_F,
+ IB_PC_XMT_NEIGH_MTU_DISC_F,
+ IB_PC_XMT_SW_LIFE_DISC_F,
+ IB_PC_XMT_SW_HOL_DISC_F,
+ IB_PC_XMT_DISC_LAST_F,
+
+ /*
+ * PortRcvErrorDetails fields
+ */
+ /* for PortSelect and CounterSelect, use IB_PC_PORT_SELECT_F and IB_PC_COUNTER_SELECT_F */
+ IB_PC_RCV_LOCAL_PHY_ERR_F,
+ IB_PC_RCV_MALFORMED_PKT_ERR_F,
+ IB_PC_RCV_BUF_OVR_ERR_F,
+ IB_PC_RCV_DLID_MAP_ERR_F,
+ IB_PC_RCV_VL_MAP_ERR_F,
+ IB_PC_RCV_LOOPING_ERR_F,
+ IB_PC_RCV_ERR_LAST_F,
+
+ /*
+ * PortSamplesControl fields
+ */
+ IB_PSC_OPCODE_F,
+ IB_PSC_PORT_SELECT_F,
+ IB_PSC_TICK_F,
+ IB_PSC_COUNTER_WIDTH_F,
+ IB_PSC_COUNTER_MASK0_F,
+ IB_PSC_COUNTER_MASKS1TO9_F,
+ IB_PSC_COUNTER_MASKS10TO14_F,
+ IB_PSC_SAMPLE_MECHS_F,
+ IB_PSC_SAMPLE_STATUS_F,
+ IB_PSC_OPTION_MASK_F,
+ IB_PSC_VENDOR_MASK_F,
+ IB_PSC_SAMPLE_START_F,
+ IB_PSC_SAMPLE_INTVL_F,
+ IB_PSC_TAG_F,
+ IB_PSC_COUNTER_SEL0_F,
+ IB_PSC_COUNTER_SEL1_F,
+ IB_PSC_COUNTER_SEL2_F,
+ IB_PSC_COUNTER_SEL3_F,
+ IB_PSC_COUNTER_SEL4_F,
+ IB_PSC_COUNTER_SEL5_F,
+ IB_PSC_COUNTER_SEL6_F,
+ IB_PSC_COUNTER_SEL7_F,
+ IB_PSC_COUNTER_SEL8_F,
+ IB_PSC_COUNTER_SEL9_F,
+ IB_PSC_COUNTER_SEL10_F,
+ IB_PSC_COUNTER_SEL11_F,
+ IB_PSC_COUNTER_SEL12_F,
+ IB_PSC_COUNTER_SEL13_F,
+ IB_PSC_COUNTER_SEL14_F,
+ IB_PSC_SAMPLES_ONLY_OPT_MASK_F,
+ IB_PSC_LAST_F,
+
+ /*
+ * GUIDInfo fields
+ */
+ IB_GI_GUID0_F, /* a duplicate of IB_GUID_GUID0_F for backwards
+ compatibility */
+ IB_GI_GUID1_F,
+ IB_GI_GUID2_F,
+ IB_GI_GUID3_F,
+ IB_GI_GUID4_F,
+ IB_GI_GUID5_F,
+ IB_GI_GUID6_F,
+ IB_GI_GUID7_F,
+
+ /*
+ * GUID Info Record
+ */
+ IB_SA_GIR_LID_F,
+ IB_SA_GIR_BLOCKNUM_F,
+ IB_SA_GIR_GUID0_F,
+ IB_SA_GIR_GUID1_F,
+ IB_SA_GIR_GUID2_F,
+ IB_SA_GIR_GUID3_F,
+ IB_SA_GIR_GUID4_F,
+ IB_SA_GIR_GUID5_F,
+ IB_SA_GIR_GUID6_F,
+ IB_SA_GIR_GUID7_F,
+
+ /*
+ * More PortInfo fields
+ */
+ IB_PORT_CAPMASK2_F,
+ IB_PORT_LINK_SPEED_EXT_ACTIVE_F,
+ IB_PORT_LINK_SPEED_EXT_SUPPORTED_F,
+ IB_PORT_LINK_SPEED_EXT_ENABLED_F,
+ IB_PORT_LINK_SPEED_EXT_LAST_F,
+
+ /*
+ * PortExtendedSpeedsCounters fields
+ */
+ IB_PESC_PORT_SELECT_F,
+ IB_PESC_COUNTER_SELECT_F,
+ IB_PESC_SYNC_HDR_ERR_CTR_F,
+ IB_PESC_UNK_BLOCK_CTR_F,
+ IB_PESC_ERR_DET_CTR_LANE0_F,
+ IB_PESC_ERR_DET_CTR_LANE1_F,
+ IB_PESC_ERR_DET_CTR_LANE2_F,
+ IB_PESC_ERR_DET_CTR_LANE3_F,
+ IB_PESC_ERR_DET_CTR_LANE4_F,
+ IB_PESC_ERR_DET_CTR_LANE5_F,
+ IB_PESC_ERR_DET_CTR_LANE6_F,
+ IB_PESC_ERR_DET_CTR_LANE7_F,
+ IB_PESC_ERR_DET_CTR_LANE8_F,
+ IB_PESC_ERR_DET_CTR_LANE9_F,
+ IB_PESC_ERR_DET_CTR_LANE10_F,
+ IB_PESC_ERR_DET_CTR_LANE11_F,
+ IB_PESC_FEC_CORR_BLOCK_CTR_LANE0_F,
+ IB_PESC_FEC_CORR_BLOCK_CTR_LANE1_F,
+ IB_PESC_FEC_CORR_BLOCK_CTR_LANE2_F,
+ IB_PESC_FEC_CORR_BLOCK_CTR_LANE3_F,
+ IB_PESC_FEC_CORR_BLOCK_CTR_LANE4_F,
+ IB_PESC_FEC_CORR_BLOCK_CTR_LANE5_F,
+ IB_PESC_FEC_CORR_BLOCK_CTR_LANE6_F,
+ IB_PESC_FEC_CORR_BLOCK_CTR_LANE7_F,
+ IB_PESC_FEC_CORR_BLOCK_CTR_LANE8_F,
+ IB_PESC_FEC_CORR_BLOCK_CTR_LANE9_F,
+ IB_PESC_FEC_CORR_BLOCK_CTR_LANE10_F,
+ IB_PESC_FEC_CORR_BLOCK_CTR_LANE11_F,
+ IB_PESC_FEC_UNCORR_BLOCK_CTR_LANE0_F,
+ IB_PESC_FEC_UNCORR_BLOCK_CTR_LANE1_F,
+ IB_PESC_FEC_UNCORR_BLOCK_CTR_LANE2_F,
+ IB_PESC_FEC_UNCORR_BLOCK_CTR_LANE3_F,
+ IB_PESC_FEC_UNCORR_BLOCK_CTR_LANE4_F,
+ IB_PESC_FEC_UNCORR_BLOCK_CTR_LANE5_F,
+ IB_PESC_FEC_UNCORR_BLOCK_CTR_LANE6_F,
+ IB_PESC_FEC_UNCORR_BLOCK_CTR_LANE7_F,
+ IB_PESC_FEC_UNCORR_BLOCK_CTR_LANE8_F,
+ IB_PESC_FEC_UNCORR_BLOCK_CTR_LANE9_F,
+ IB_PESC_FEC_UNCORR_BLOCK_CTR_LANE10_F,
+ IB_PESC_FEC_UNCORR_BLOCK_CTR_LANE11_F,
+ IB_PESC_LAST_F,
+
+ /*
+ * PortOpRcvCounters fields
+ */
+ IB_PC_PORT_OP_RCV_COUNTERS_FIRST_F, /* for PortSelect and CounterSelect, use IB_PC_PORT_SELECT_F and IB_PC_COUNTER_SELECT_F */
+ IB_PC_PORT_OP_RCV_PKTS_F = IB_PC_PORT_OP_RCV_COUNTERS_FIRST_F,
+ IB_PC_PORT_OP_RCV_DATA_F,
+ IB_PC_PORT_OP_RCV_COUNTERS_LAST_F,
+
+ /*
+ * PortFlowCtlCounters fields
+ */
+ IB_PC_PORT_FLOW_CTL_COUNTERS_FIRST_F, /* for PortSelect and CounterSelect, use IB_PC_PORT_SELECT_F and IB_PC_COUNTER_SELECT_F */
+ IB_PC_PORT_XMIT_FLOW_PKTS_F = IB_PC_PORT_FLOW_CTL_COUNTERS_FIRST_F,
+ IB_PC_PORT_RCV_FLOW_PKTS_F,
+ IB_PC_PORT_FLOW_CTL_COUNTERS_LAST_F,
+
+ /*
+ * PortVLOpPackets fields
+ */
+ IB_PC_PORT_VL_OP_PACKETS_FIRST_F, /* for PortSelect and CounterSelect, use IB_PC_PORT_SELECT_F and IB_PC_COUNTER_SELECT_F */
+ IB_PC_PORT_VL_OP_PACKETS0_F = IB_PC_PORT_VL_OP_PACKETS_FIRST_F,
+ IB_PC_PORT_VL_OP_PACKETS1_F,
+ IB_PC_PORT_VL_OP_PACKETS2_F,
+ IB_PC_PORT_VL_OP_PACKETS3_F,
+ IB_PC_PORT_VL_OP_PACKETS4_F,
+ IB_PC_PORT_VL_OP_PACKETS5_F,
+ IB_PC_PORT_VL_OP_PACKETS6_F,
+ IB_PC_PORT_VL_OP_PACKETS7_F,
+ IB_PC_PORT_VL_OP_PACKETS8_F,
+ IB_PC_PORT_VL_OP_PACKETS9_F,
+ IB_PC_PORT_VL_OP_PACKETS10_F,
+ IB_PC_PORT_VL_OP_PACKETS11_F,
+ IB_PC_PORT_VL_OP_PACKETS12_F,
+ IB_PC_PORT_VL_OP_PACKETS13_F,
+ IB_PC_PORT_VL_OP_PACKETS14_F,
+ IB_PC_PORT_VL_OP_PACKETS15_F,
+ IB_PC_PORT_VL_OP_PACKETS_LAST_F,
+
+ /*
+ * PortVLOpData fields
+ */
+ IB_PC_PORT_VL_OP_DATA_FIRST_F, /* for PortSelect and CounterSelect, use IB_PC_PORT_SELECT_F and IB_PC_COUNTER_SELECT_F */
+ IB_PC_PORT_VL_OP_DATA0_F = IB_PC_PORT_VL_OP_DATA_FIRST_F,
+ IB_PC_PORT_VL_OP_DATA1_F,
+ IB_PC_PORT_VL_OP_DATA2_F,
+ IB_PC_PORT_VL_OP_DATA3_F,
+ IB_PC_PORT_VL_OP_DATA4_F,
+ IB_PC_PORT_VL_OP_DATA5_F,
+ IB_PC_PORT_VL_OP_DATA6_F,
+ IB_PC_PORT_VL_OP_DATA7_F,
+ IB_PC_PORT_VL_OP_DATA8_F,
+ IB_PC_PORT_VL_OP_DATA9_F,
+ IB_PC_PORT_VL_OP_DATA10_F,
+ IB_PC_PORT_VL_OP_DATA11_F,
+ IB_PC_PORT_VL_OP_DATA12_F,
+ IB_PC_PORT_VL_OP_DATA13_F,
+ IB_PC_PORT_VL_OP_DATA14_F,
+ IB_PC_PORT_VL_OP_DATA15_F,
+ IB_PC_PORT_VL_OP_DATA_LAST_F,
+
+ /*
+ * PortVLXmitFlowCtlUpdateErrors fields
+ */
+ IB_PC_PORT_VL_XMIT_FLOW_CTL_UPDATE_ERRORS_FIRST_F, /* for PortSelect and CounterSelect, use IB_PC_PORT_SELECT_F and IB_PC_COUNTER_SELECT_F */
+ IB_PC_PORT_VL_XMIT_FLOW_CTL_UPDATE_ERRORS0_F = IB_PC_PORT_VL_XMIT_FLOW_CTL_UPDATE_ERRORS_FIRST_F,
+ IB_PC_PORT_VL_XMIT_FLOW_CTL_UPDATE_ERRORS1_F,
+ IB_PC_PORT_VL_XMIT_FLOW_CTL_UPDATE_ERRORS2_F,
+ IB_PC_PORT_VL_XMIT_FLOW_CTL_UPDATE_ERRORS3_F,
+ IB_PC_PORT_VL_XMIT_FLOW_CTL_UPDATE_ERRORS4_F,
+ IB_PC_PORT_VL_XMIT_FLOW_CTL_UPDATE_ERRORS5_F,
+ IB_PC_PORT_VL_XMIT_FLOW_CTL_UPDATE_ERRORS6_F,
+ IB_PC_PORT_VL_XMIT_FLOW_CTL_UPDATE_ERRORS7_F,
+ IB_PC_PORT_VL_XMIT_FLOW_CTL_UPDATE_ERRORS8_F,
+ IB_PC_PORT_VL_XMIT_FLOW_CTL_UPDATE_ERRORS9_F,
+ IB_PC_PORT_VL_XMIT_FLOW_CTL_UPDATE_ERRORS10_F,
+ IB_PC_PORT_VL_XMIT_FLOW_CTL_UPDATE_ERRORS11_F,
+ IB_PC_PORT_VL_XMIT_FLOW_CTL_UPDATE_ERRORS12_F,
+ IB_PC_PORT_VL_XMIT_FLOW_CTL_UPDATE_ERRORS13_F,
+ IB_PC_PORT_VL_XMIT_FLOW_CTL_UPDATE_ERRORS14_F,
+ IB_PC_PORT_VL_XMIT_FLOW_CTL_UPDATE_ERRORS15_F,
+ IB_PC_PORT_VL_XMIT_FLOW_CTL_UPDATE_ERRORS_LAST_F,
+
+ /*
+ * PortVLXmitWaitCounters fields
+ */
+ IB_PC_PORT_VL_XMIT_WAIT_COUNTERS_FIRST_F, /* for PortSelect and CounterSelect, use IB_PC_PORT_SELECT_F and IB_PC_COUNTER_SELECT_F */
+ IB_PC_PORT_VL_XMIT_WAIT0_F = IB_PC_PORT_VL_XMIT_WAIT_COUNTERS_FIRST_F,
+ IB_PC_PORT_VL_XMIT_WAIT1_F,
+ IB_PC_PORT_VL_XMIT_WAIT2_F,
+ IB_PC_PORT_VL_XMIT_WAIT3_F,
+ IB_PC_PORT_VL_XMIT_WAIT4_F,
+ IB_PC_PORT_VL_XMIT_WAIT5_F,
+ IB_PC_PORT_VL_XMIT_WAIT6_F,
+ IB_PC_PORT_VL_XMIT_WAIT7_F,
+ IB_PC_PORT_VL_XMIT_WAIT8_F,
+ IB_PC_PORT_VL_XMIT_WAIT9_F,
+ IB_PC_PORT_VL_XMIT_WAIT10_F,
+ IB_PC_PORT_VL_XMIT_WAIT11_F,
+ IB_PC_PORT_VL_XMIT_WAIT12_F,
+ IB_PC_PORT_VL_XMIT_WAIT13_F,
+ IB_PC_PORT_VL_XMIT_WAIT14_F,
+ IB_PC_PORT_VL_XMIT_WAIT15_F,
+ IB_PC_PORT_VL_XMIT_WAIT_COUNTERS_LAST_F,
+
+ /*
+ * SwPortVLCongestion fields
+ */
+ IB_PC_SW_PORT_VL_CONGESTION_FIRST_F, /* for PortSelect and CounterSelect, use IB_PC_PORT_SELECT_F and IB_PC_COUNTER_SELECT_F */
+ IB_PC_SW_PORT_VL_CONGESTION0_F = IB_PC_SW_PORT_VL_CONGESTION_FIRST_F,
+ IB_PC_SW_PORT_VL_CONGESTION1_F,
+ IB_PC_SW_PORT_VL_CONGESTION2_F,
+ IB_PC_SW_PORT_VL_CONGESTION3_F,
+ IB_PC_SW_PORT_VL_CONGESTION4_F,
+ IB_PC_SW_PORT_VL_CONGESTION5_F,
+ IB_PC_SW_PORT_VL_CONGESTION6_F,
+ IB_PC_SW_PORT_VL_CONGESTION7_F,
+ IB_PC_SW_PORT_VL_CONGESTION8_F,
+ IB_PC_SW_PORT_VL_CONGESTION9_F,
+ IB_PC_SW_PORT_VL_CONGESTION10_F,
+ IB_PC_SW_PORT_VL_CONGESTION11_F,
+ IB_PC_SW_PORT_VL_CONGESTION12_F,
+ IB_PC_SW_PORT_VL_CONGESTION13_F,
+ IB_PC_SW_PORT_VL_CONGESTION14_F,
+ IB_PC_SW_PORT_VL_CONGESTION15_F,
+ IB_PC_SW_PORT_VL_CONGESTION_LAST_F,
+
+ /*
+ * PortRcvConCtrl fields
+ */
+ IB_PC_RCV_CON_CTRL_FIRST_F, /* for PortSelect and CounterSelect, use IB_PC_PORT_SELECT_F and IB_PC_COUNTER_SELECT_F */
+ IB_PC_RCV_CON_CTRL_PKT_RCV_FECN_F = IB_PC_RCV_CON_CTRL_FIRST_F,
+ IB_PC_RCV_CON_CTRL_PKT_RCV_BECN_F,
+ IB_PC_RCV_CON_CTRL_LAST_F,
+
+ /*
+ * PortSLRcvFECN fields
+ */
+ IB_PC_SL_RCV_FECN_FIRST_F, /* for PortSelect and CounterSelect, use IB_PC_PORT_SELECT_F and IB_PC_COUNTER_SELECT_F */
+ IB_PC_SL_RCV_FECN0_F = IB_PC_SL_RCV_FECN_FIRST_F,
+ IB_PC_SL_RCV_FECN1_F,
+ IB_PC_SL_RCV_FECN2_F,
+ IB_PC_SL_RCV_FECN3_F,
+ IB_PC_SL_RCV_FECN4_F,
+ IB_PC_SL_RCV_FECN5_F,
+ IB_PC_SL_RCV_FECN6_F,
+ IB_PC_SL_RCV_FECN7_F,
+ IB_PC_SL_RCV_FECN8_F,
+ IB_PC_SL_RCV_FECN9_F,
+ IB_PC_SL_RCV_FECN10_F,
+ IB_PC_SL_RCV_FECN11_F,
+ IB_PC_SL_RCV_FECN12_F,
+ IB_PC_SL_RCV_FECN13_F,
+ IB_PC_SL_RCV_FECN14_F,
+ IB_PC_SL_RCV_FECN15_F,
+ IB_PC_SL_RCV_FECN_LAST_F,
+
+ /*
+ * PortSLRcvBECN fields
+ */
+ IB_PC_SL_RCV_BECN_FIRST_F, /* for PortSelect and CounterSelect, use IB_PC_PORT_SELECT_F and IB_PC_COUNTER_SELECT_F */
+ IB_PC_SL_RCV_BECN0_F = IB_PC_SL_RCV_BECN_FIRST_F,
+ IB_PC_SL_RCV_BECN1_F,
+ IB_PC_SL_RCV_BECN2_F,
+ IB_PC_SL_RCV_BECN3_F,
+ IB_PC_SL_RCV_BECN4_F,
+ IB_PC_SL_RCV_BECN5_F,
+ IB_PC_SL_RCV_BECN6_F,
+ IB_PC_SL_RCV_BECN7_F,
+ IB_PC_SL_RCV_BECN8_F,
+ IB_PC_SL_RCV_BECN9_F,
+ IB_PC_SL_RCV_BECN10_F,
+ IB_PC_SL_RCV_BECN11_F,
+ IB_PC_SL_RCV_BECN12_F,
+ IB_PC_SL_RCV_BECN13_F,
+ IB_PC_SL_RCV_BECN14_F,
+ IB_PC_SL_RCV_BECN15_F,
+ IB_PC_SL_RCV_BECN_LAST_F,
+
+ /*
+ * PortXmitConCtrl fields
+ */
+ IB_PC_XMIT_CON_CTRL_FIRST_F, /* for PortSelect and CounterSelect, use IB_PC_PORT_SELECT_F and IB_PC_COUNTER_SELECT_F */
+ IB_PC_XMIT_CON_CTRL_TIME_CONG_F = IB_PC_XMIT_CON_CTRL_FIRST_F,
+ IB_PC_XMIT_CON_CTRL_LAST_F,
+
+ /*
+ * PortVLXmitTimeCong fields
+ */
+ IB_PC_VL_XMIT_TIME_CONG_FIRST_F, /* for PortSelect and CounterSelect, use IB_PC_PORT_SELECT_F and IB_PC_COUNTER_SELECT_F */
+ IB_PC_VL_XMIT_TIME_CONG0_F = IB_PC_VL_XMIT_TIME_CONG_FIRST_F,
+ IB_PC_VL_XMIT_TIME_CONG1_F,
+ IB_PC_VL_XMIT_TIME_CONG2_F,
+ IB_PC_VL_XMIT_TIME_CONG3_F,
+ IB_PC_VL_XMIT_TIME_CONG4_F,
+ IB_PC_VL_XMIT_TIME_CONG5_F,
+ IB_PC_VL_XMIT_TIME_CONG6_F,
+ IB_PC_VL_XMIT_TIME_CONG7_F,
+ IB_PC_VL_XMIT_TIME_CONG8_F,
+ IB_PC_VL_XMIT_TIME_CONG9_F,
+ IB_PC_VL_XMIT_TIME_CONG10_F,
+ IB_PC_VL_XMIT_TIME_CONG11_F,
+ IB_PC_VL_XMIT_TIME_CONG12_F,
+ IB_PC_VL_XMIT_TIME_CONG13_F,
+ IB_PC_VL_XMIT_TIME_CONG14_F,
+ IB_PC_VL_XMIT_TIME_CONG_LAST_F,
+
+ /*
+ * Mellanox ExtendedPortInfo fields
+ */
+ IB_MLNX_EXT_PORT_STATE_CHG_ENABLE_F,
+ IB_MLNX_EXT_PORT_LINK_SPEED_SUPPORTED_F,
+ IB_MLNX_EXT_PORT_LINK_SPEED_ENABLED_F,
+ IB_MLNX_EXT_PORT_LINK_SPEED_ACTIVE_F,
+ IB_MLNX_EXT_PORT_LAST_F,
+
+ /*
+ * Congestion Control Mad fields
+ * bytes 24-31 of congestion control mad
+ */
+ IB_CC_CCKEY_F,
+
+ /*
+ * CongestionInfo fields
+ */
+ IB_CC_CONGESTION_INFO_FIRST_F,
+ IB_CC_CONGESTION_INFO_F = IB_CC_CONGESTION_INFO_FIRST_F,
+ IB_CC_CONGESTION_INFO_CONTROL_TABLE_CAP_F,
+ IB_CC_CONGESTION_INFO_LAST_F,
+
+ /*
+ * CongestionKeyInfo fields
+ */
+ IB_CC_CONGESTION_KEY_INFO_FIRST_F,
+ IB_CC_CONGESTION_KEY_INFO_CC_KEY_F = IB_CC_CONGESTION_KEY_INFO_FIRST_F,
+ IB_CC_CONGESTION_KEY_INFO_CC_KEY_PROTECT_BIT_F,
+ IB_CC_CONGESTION_KEY_INFO_CC_KEY_LEASE_PERIOD_F,
+ IB_CC_CONGESTION_KEY_INFO_CC_KEY_VIOLATIONS_F,
+ IB_CC_CONGESTION_KEY_INFO_LAST_F,
+
+ /*
+ * CongestionLog (common) fields
+ */
+ IB_CC_CONGESTION_LOG_FIRST_F,
+ IB_CC_CONGESTION_LOG_LOGTYPE_F = IB_CC_CONGESTION_LOG_FIRST_F,
+ IB_CC_CONGESTION_LOG_CONGESTION_FLAGS_F,
+ IB_CC_CONGESTION_LOG_LAST_F,
+
+ /*
+ * CongestionLog (Switch) fields
+ */
+ IB_CC_CONGESTION_LOG_SWITCH_FIRST_F,
+ IB_CC_CONGESTION_LOG_SWITCH_LOG_EVENTS_COUNTER_F = IB_CC_CONGESTION_LOG_SWITCH_FIRST_F,
+ IB_CC_CONGESTION_LOG_SWITCH_CURRENT_TIME_STAMP_F,
+ IB_CC_CONGESTION_LOG_SWITCH_PORTMAP_F,
+ IB_CC_CONGESTION_LOG_SWITCH_LAST_F,
+
+ /*
+ * CongestionLogEvent (Switch) fields
+ */
+ IB_CC_CONGESTION_LOG_ENTRY_SWITCH_FIRST_F,
+ IB_CC_CONGESTION_LOG_ENTRY_SWITCH_SLID_F = IB_CC_CONGESTION_LOG_ENTRY_SWITCH_FIRST_F,
+ IB_CC_CONGESTION_LOG_ENTRY_SWITCH_DLID_F,
+ IB_CC_CONGESTION_LOG_ENTRY_SWITCH_SL_F,
+ IB_CC_CONGESTION_LOG_ENTRY_SWITCH_TIMESTAMP_F,
+ IB_CC_CONGESTION_LOG_ENTRY_SWITCH_LAST_F,
+
+ /*
+ * CongestionLog (CA) fields
+ */
+ IB_CC_CONGESTION_LOG_CA_FIRST_F,
+ IB_CC_CONGESTION_LOG_CA_THRESHOLD_EVENT_COUNTER_F = IB_CC_CONGESTION_LOG_CA_FIRST_F,
+ IB_CC_CONGESTION_LOG_CA_THRESHOLD_CONGESTION_EVENT_MAP_F,
+ IB_CC_CONGESTION_LOG_CA_CURRENT_TIMESTAMP_F,
+ IB_CC_CONGESTION_LOG_CA_LAST_F,
+
+ /*
+ * CongestionLogEvent (CA) fields
+ */
+ IB_CC_CONGESTION_LOG_ENTRY_CA_FIRST_F,
+ IB_CC_CONGESTION_LOG_ENTRY_CA_LOCAL_QP_CN_ENTRY_F = IB_CC_CONGESTION_LOG_ENTRY_CA_FIRST_F,
+ IB_CC_CONGESTION_LOG_ENTRY_CA_SL_CN_ENTRY_F,
+ IB_CC_CONGESTION_LOG_ENTRY_CA_SERVICE_TYPE_CN_ENTRY_F,
+ IB_CC_CONGESTION_LOG_ENTRY_CA_REMOTE_QP_NUMBER_CN_ENTRY_F,
+ IB_CC_CONGESTION_LOG_ENTRY_CA_LOCAL_LID_CN_F,
+ IB_CC_CONGESTION_LOG_ENTRY_CA_REMOTE_LID_CN_ENTRY_F,
+ IB_CC_CONGESTION_LOG_ENTRY_CA_TIMESTAMP_CN_ENTRY_F,
+ IB_CC_CONGESTION_LOG_ENTRY_CA_LAST_F,
+
+ /*
+ * SwitchCongestionSetting fields
+ */
+ IB_CC_SWITCH_CONGESTION_SETTING_FIRST_F,
+ IB_CC_SWITCH_CONGESTION_SETTING_CONTROL_MAP_F = IB_CC_SWITCH_CONGESTION_SETTING_FIRST_F,
+ IB_CC_SWITCH_CONGESTION_SETTING_VICTIM_MASK_F,
+ IB_CC_SWITCH_CONGESTION_SETTING_CREDIT_MASK_F,
+ IB_CC_SWITCH_CONGESTION_SETTING_THRESHOLD_F,
+ IB_CC_SWITCH_CONGESTION_SETTING_PACKET_SIZE_F,
+ IB_CC_SWITCH_CONGESTION_SETTING_CS_THRESHOLD_F,
+ IB_CC_SWITCH_CONGESTION_SETTING_CS_RETURN_DELAY_F,
+ IB_CC_SWITCH_CONGESTION_SETTING_MARKING_RATE_F,
+ IB_CC_SWITCH_CONGESTION_SETTING_LAST_F,
+
+ /*
+ * SwitchPortCongestionSettingElement fields
+ */
+ IB_CC_SWITCH_PORT_CONGESTION_SETTING_ELEMENT_FIRST_F,
+ IB_CC_SWITCH_PORT_CONGESTION_SETTING_ELEMENT_VALID_F = IB_CC_SWITCH_PORT_CONGESTION_SETTING_ELEMENT_FIRST_F,
+ IB_CC_SWITCH_PORT_CONGESTION_SETTING_ELEMENT_CONTROL_TYPE_F,
+ IB_CC_SWITCH_PORT_CONGESTION_SETTING_ELEMENT_THRESHOLD_F,
+ IB_CC_SWITCH_PORT_CONGESTION_SETTING_ELEMENT_PACKET_SIZE_F,
+ IB_CC_SWITCH_PORT_CONGESTION_SETTING_ELEMENT_CONG_PARM_MARKING_RATE_F,
+ IB_CC_SWITCH_PORT_CONGESTION_SETTING_ELEMENT_LAST_F,
+
+ /*
+ * CACongestionSetting fields
+ */
+ IB_CC_CA_CONGESTION_SETTING_FIRST_F,
+ IB_CC_CA_CONGESTION_SETTING_PORT_CONTROL_F = IB_CC_CA_CONGESTION_SETTING_FIRST_F,
+ IB_CC_CA_CONGESTION_SETTING_CONTROL_MAP_F,
+ IB_CC_CA_CONGESTION_SETTING_LAST_F,
+
+ /*
+ * CACongestionEntry fields
+ */
+ IB_CC_CA_CONGESTION_ENTRY_FIRST_F,
+ IB_CC_CA_CONGESTION_ENTRY_CCTI_TIMER_F = IB_CC_CA_CONGESTION_ENTRY_FIRST_F,
+ IB_CC_CA_CONGESTION_ENTRY_CCTI_INCREASE_F,
+ IB_CC_CA_CONGESTION_ENTRY_TRIGGER_THRESHOLD_F,
+ IB_CC_CA_CONGESTION_ENTRY_CCTI_MIN_F,
+ IB_CC_CA_CONGESTION_ENTRY_LAST_F,
+
+ /*
+ * CongestionControlTable fields
+ */
+ IB_CC_CONGESTION_CONTROL_TABLE_FIRST_F,
+ IB_CC_CONGESTION_CONTROL_TABLE_CCTI_LIMIT_F = IB_CC_CONGESTION_CONTROL_TABLE_FIRST_F,
+ IB_CC_CONGESTION_CONTROL_TABLE_LAST_F,
+
+ /*
+ * CongestionControlTableEntry fields
+ */
+ IB_CC_CONGESTION_CONTROL_TABLE_ENTRY_FIRST_F,
+ IB_CC_CONGESTION_CONTROL_TABLE_ENTRY_CCT_SHIFT_F = IB_CC_CONGESTION_CONTROL_TABLE_ENTRY_FIRST_F,
+ IB_CC_CONGESTION_CONTROL_TABLE_ENTRY_CCT_MULTIPLIER_F,
+ IB_CC_CONGESTION_CONTROL_TABLE_ENTRY_LAST_F,
+
+ /*
+ * Timestamp fields
+ */
+ IB_CC_TIMESTAMP_FIRST_F,
+ IB_CC_TIMESTAMP_F = IB_CC_TIMESTAMP_FIRST_F,
+ IB_CC_TIMESTAMP_LAST_F,
+
+ /*
+ * Node Record
+ */
+ IB_SA_NR_FIRST_F,
+ IB_SA_NR_LID_F = IB_SA_NR_FIRST_F,
+ IB_SA_NR_BASEVER_F,
+ IB_SA_NR_CLASSVER_F,
+ IB_SA_NR_TYPE_F,
+ IB_SA_NR_NPORTS_F,
+ IB_SA_NR_SYSTEM_GUID_F,
+ IB_SA_NR_GUID_F,
+ IB_SA_NR_PORT_GUID_F,
+ IB_SA_NR_PARTITION_CAP_F,
+ IB_SA_NR_DEVID_F,
+ IB_SA_NR_REVISION_F,
+ IB_SA_NR_LOCAL_PORT_F,
+ IB_SA_NR_VENDORID_F,
+ IB_SA_NR_NODEDESC_F,
+ IB_SA_NR_LAST_F,
+
+ /*
+ * PortMirrorRoute fields
+ */
+ IB_PMR_FIRST_F,
+ IB_PMR_ENCAP_RAW_ETH_TYPE_F = IB_PMR_FIRST_F,
+ IB_PMR_MAX_MIRROR_LEN_F,
+ IB_PMR_MT_F,
+ IB_PMR_BF_F,
+ IB_PMR_NM_PORT_F,
+ IB_PMR_LRH_VL_F,
+ IB_PMR_LRH_LVER_F,
+ IB_PMR_LRH_SL_F,
+ IB_PMR_LRH_LNH_F,
+ IB_PMR_LRH_DLID_F,
+ IB_PMR_LRH_LEN_F,
+ IB_PMR_LRH_SLID_F,
+ IB_PMR_LAST_F,
+
+ /*
+ * PortMirrorFilter fields
+ */
+ IB_PMF_FIRST_F,
+ IB_PMF_MIRROR_FILTER0_F = IB_PMF_FIRST_F,
+ IB_PMF_MIRROR_FILTER1_F,
+ IB_PMF_MIRROR_MASK0_F,
+ IB_PMF_MIRROR_MASK1_F,
+ IB_PMF_MIRROR_MASK2_F,
+ IB_PMF_MIRROR_MASK3_F,
+ IB_PMF_B0_F,
+ IB_PMF_MIRROR_MASK_OFFS_0,
+ IB_PMF_B1_F,
+ IB_PMF_MIRROR_MASK_OFFS_1,
+ IB_PMF_B2_F,
+ IB_PMF_MIRROR_MASK_OFFS_2,
+ IB_PMF_B3_F,
+ IB_PMF_MIRROR_MASK_OFFS_3,
+ IB_PMF_LAST_F,
+
+ /*
+ * PortMirrorPorts fields
+ */
+ IB_PMP_FIRST_F,
+ IB_PMP_TQ_1_F = IB_PMP_FIRST_F,
+ IB_PMP_RQ_1_F,
+ IB_PMP_TQ_2_F,
+ IB_PMP_RQ_2_F,
+ IB_PMP_TQ_3_F,
+ IB_PMP_RQ_3_F,
+ IB_PMP_TQ_4_F,
+ IB_PMP_RQ_4_F,
+ IB_PMP_TQ_5_F,
+ IB_PMP_RQ_5_F,
+ IB_PMP_TQ_6_F,
+ IB_PMP_RQ_6_F,
+ IB_PMP_TQ_7_F,
+ IB_PMP_RQ_7_F,
+ IB_PMP_TQ_8_F,
+ IB_PMP_RQ_8_F,
+ IB_PMP_TQ_9_F,
+ IB_PMP_RQ_9_F,
+ IB_PMP_TQ_10_F,
+ IB_PMP_RQ_10_F,
+ IB_PMP_TQ_11_F,
+ IB_PMP_RQ_11_F,
+ IB_PMP_TQ_12_F,
+ IB_PMP_RQ_12_F,
+ IB_PMP_TQ_13_F,
+ IB_PMP_RQ_13_F,
+ IB_PMP_TQ_14_F,
+ IB_PMP_RQ_14_F,
+ IB_PMP_TQ_15_F,
+ IB_PMP_RQ_15_F,
+ IB_PMP_TQ_16_F,
+ IB_PMP_RQ_16_F,
+ IB_PMP_TQ_17_F,
+ IB_PMP_RQ_17_F,
+ IB_PMP_TQ_18_F,
+ IB_PMP_RQ_18_F,
+ IB_PMP_TQ_19_F,
+ IB_PMP_RQ_19_F,
+ IB_PMP_TQ_20_F,
+ IB_PMP_RQ_20_F,
+ IB_PMP_TQ_21_F,
+ IB_PMP_RQ_21_F,
+ IB_PMP_TQ_22_F,
+ IB_PMP_RQ_22_F,
+ IB_PMP_TQ_23_F,
+ IB_PMP_RQ_23_F,
+ IB_PMP_TQ_24_F,
+ IB_PMP_RQ_24_F,
+ IB_PMP_TQ_25_F,
+ IB_PMP_RQ_25_F,
+ IB_PMP_TQ_26_F,
+ IB_PMP_RQ_26_F,
+ IB_PMP_TQ_27_F,
+ IB_PMP_RQ_27_F,
+ IB_PMP_TQ_28_F,
+ IB_PMP_RQ_28_F,
+ IB_PMP_TQ_29_F,
+ IB_PMP_RQ_29_F,
+ IB_PMP_TQ_30_F,
+ IB_PMP_RQ_30_F,
+ IB_PMP_TQ_31_F,
+ IB_PMP_RQ_31_F,
+ IB_PMP_TQ_32_F,
+ IB_PMP_RQ_32_F,
+ IB_PMP_TQ_33_F,
+ IB_PMP_RQ_33_F,
+ IB_PMP_TQ_34_F,
+ IB_PMP_RQ_34_F,
+ IB_PMP_TQ_35_F,
+ IB_PMP_RQ_35_F,
+ IB_PMP_TQ_36_F,
+ IB_PMP_RQ_36_F,
+ IB_PMP_LAST_F,
+
+ /*
+ * PortSamplesResult fields
+ */
+ IB_PSR_TAG_F,
+ IB_PSR_SAMPLE_STATUS_F,
+ IB_PSR_COUNTER0_F,
+ IB_PSR_COUNTER1_F,
+ IB_PSR_COUNTER2_F,
+ IB_PSR_COUNTER3_F,
+ IB_PSR_COUNTER4_F,
+ IB_PSR_COUNTER5_F,
+ IB_PSR_COUNTER6_F,
+ IB_PSR_COUNTER7_F,
+ IB_PSR_COUNTER8_F,
+ IB_PSR_COUNTER9_F,
+ IB_PSR_COUNTER10_F,
+ IB_PSR_COUNTER11_F,
+ IB_PSR_COUNTER12_F,
+ IB_PSR_COUNTER13_F,
+ IB_PSR_COUNTER14_F,
+ IB_PSR_LAST_F,
+
+ /*
+ * PortInfoExtended fields
+ */
+ IB_PORT_EXT_FIRST_F,
+ IB_PORT_EXT_CAPMASK_F = IB_PORT_EXT_FIRST_F,
+ IB_PORT_EXT_FEC_MODE_ACTIVE_F,
+ IB_PORT_EXT_FDR_FEC_MODE_SUPPORTED_F,
+ IB_PORT_EXT_FDR_FEC_MODE_ENABLED_F,
+ IB_PORT_EXT_EDR_FEC_MODE_SUPPORTED_F,
+ IB_PORT_EXT_EDR_FEC_MODE_ENABLED_F,
+ IB_PORT_EXT_LAST_F,
+
+ /*
+ * PortExtendedSpeedsCounters RSFEC active fields
+ */
+ IB_PESC_RSFEC_PORT_SELECT_F,
+ IB_PESC_RSFEC_COUNTER_SELECT_F,
+ IB_PESC_RSFEC_SYNC_HDR_ERR_CTR_F,
+ IB_PESC_RSFEC_UNK_BLOCK_CTR_F,
+ IB_PESC_RSFEC_FEC_CORR_SYMBOL_CTR_LANE0_F,
+ IB_PESC_RSFEC_FEC_CORR_SYMBOL_CTR_LANE1_F,
+ IB_PESC_RSFEC_FEC_CORR_SYMBOL_CTR_LANE2_F,
+ IB_PESC_RSFEC_FEC_CORR_SYMBOL_CTR_LANE3_F,
+ IB_PESC_RSFEC_FEC_CORR_SYMBOL_CTR_LANE4_F,
+ IB_PESC_RSFEC_FEC_CORR_SYMBOL_CTR_LANE5_F,
+ IB_PESC_RSFEC_FEC_CORR_SYMBOL_CTR_LANE6_F,
+ IB_PESC_RSFEC_FEC_CORR_SYMBOL_CTR_LANE7_F,
+ IB_PESC_RSFEC_FEC_CORR_SYMBOL_CTR_LANE8_F,
+ IB_PESC_RSFEC_FEC_CORR_SYMBOL_CTR_LANE9_F,
+ IB_PESC_RSFEC_FEC_CORR_SYMBOL_CTR_LANE10_F,
+ IB_PESC_RSFEC_FEC_CORR_SYMBOL_CTR_LANE11_F,
+ IB_PESC_PORT_FEC_CORR_BLOCK_CTR_F,
+ IB_PESC_PORT_FEC_UNCORR_BLOCK_CTR_F,
+ IB_PESC_PORT_FEC_CORR_SYMBOL_CTR_F,
+ IB_PESC_RSFEC_LAST_F,
+
+ /*
+ * More PortCountersExtended fields
+ */
+ IB_PC_EXT_COUNTER_SELECT2_F,
+ IB_PC_EXT_ERR_SYM_F,
+ IB_PC_EXT_LINK_RECOVERS_F,
+ IB_PC_EXT_LINK_DOWNED_F,
+ IB_PC_EXT_ERR_RCV_F,
+ IB_PC_EXT_ERR_PHYSRCV_F,
+ IB_PC_EXT_ERR_SWITCH_REL_F,
+ IB_PC_EXT_XMT_DISCARDS_F,
+ IB_PC_EXT_ERR_XMTCONSTR_F,
+ IB_PC_EXT_ERR_RCVCONSTR_F,
+ IB_PC_EXT_ERR_LOCALINTEG_F,
+ IB_PC_EXT_ERR_EXCESS_OVR_F,
+ IB_PC_EXT_VL15_DROPPED_F,
+ IB_PC_EXT_XMT_WAIT_F,
+ IB_PC_EXT_QP1_DROP_F,
+ IB_PC_EXT_ERR_LAST_F,
+
+ /*
+ * Another PortCounters field
+ */
+ IB_PC_QP1_DROP_F,
+
+ IB_FIELD_LAST_ /* must be last */
+};
+
+/*
+ * SA RMPP section
+ */
+enum RMPP_TYPE_ENUM {
+ IB_RMPP_TYPE_NONE,
+ IB_RMPP_TYPE_DATA,
+ IB_RMPP_TYPE_ACK,
+ IB_RMPP_TYPE_STOP,
+ IB_RMPP_TYPE_ABORT,
+};
+
+enum RMPP_FLAGS_ENUM {
+ IB_RMPP_FLAG_ACTIVE = 1 << 0,
+ IB_RMPP_FLAG_FIRST = 1 << 1,
+ IB_RMPP_FLAG_LAST = 1 << 2,
+};
+
+typedef struct {
+ int type;
+ int flags;
+ int status;
+ union {
+ uint32_t u;
+ uint32_t segnum;
+ } d1;
+ union {
+ uint32_t u;
+ uint32_t len;
+ uint32_t newwin;
+ } d2;
+} ib_rmpp_hdr_t;
+
+enum SA_SIZES_ENUM {
+ SA_HEADER_SZ = 20,
+};
+
+typedef struct ib_sa_call {
+ unsigned attrid;
+ unsigned mod;
+ uint64_t mask;
+ unsigned method;
+
+ uint64_t trid; /* used for out mad if nonzero, return real val */
+ unsigned recsz; /* return field */
+ ib_rmpp_hdr_t rmpp;
+} ib_sa_call_t;
+
+typedef struct ib_vendor_call {
+ unsigned method;
+ unsigned mgmt_class;
+ unsigned attrid;
+ unsigned mod;
+ uint32_t oui;
+ unsigned timeout;
+ ib_rmpp_hdr_t rmpp;
+} ib_vendor_call_t;
+
+typedef struct ib_bm_call {
+ unsigned method;
+ unsigned attrid;
+ unsigned mod;
+ unsigned timeout;
+ uint64_t bkey;
+} ib_bm_call_t;
+
+#define IB_MIN_UCAST_LID 1
+#define IB_MAX_UCAST_LID (0xc000-1)
+#define IB_MIN_MCAST_LID 0xc000
+#define IB_MAX_MCAST_LID (0xffff-1)
+
+#define IB_LID_VALID(lid) ((lid) >= IB_MIN_UCAST_LID && lid <= IB_MAX_UCAST_LID)
+#define IB_MLID_VALID(lid) ((lid) >= IB_MIN_MCAST_LID && lid <= IB_MAX_MCAST_LID)
+
+#define MAD_DEF_RETRIES 3
+#define MAD_DEF_TIMEOUT_MS 1000
+
+enum MAD_DEST {
+ IB_DEST_LID,
+ IB_DEST_DRPATH,
+ IB_DEST_GUID,
+ IB_DEST_DRSLID,
+ IB_DEST_GID
+};
+
+enum MAD_NODE_TYPE {
+ IB_NODE_CA = 1,
+ IB_NODE_SWITCH,
+ IB_NODE_ROUTER,
+ NODE_RNIC,
+
+ IB_NODE_MAX = NODE_RNIC
+};
+
+/******************************************************************************/
+
+/* portid.c */
+MAD_EXPORT char *portid2str(ib_portid_t * portid);
+MAD_EXPORT int portid2portnum(ib_portid_t * portid);
+MAD_EXPORT int str2drpath(ib_dr_path_t * path, char *routepath, int drslid,
+ int drdlid);
+MAD_EXPORT char *drpath2str(ib_dr_path_t * path, char *dstr, size_t dstr_size);
+
+static inline int ib_portid_set(ib_portid_t * portid, int lid, int qp, int qkey)
+{
+ portid->lid = lid;
+ portid->qp = qp;
+ portid->qkey = qkey;
+ portid->grh_present = 0;
+
+ return 0;
+}
+
+/* fields.c */
+MAD_EXPORT uint32_t mad_get_field(void *buf, int base_offs,
+ enum MAD_FIELDS field);
+MAD_EXPORT void mad_set_field(void *buf, int base_offs, enum MAD_FIELDS field,
+ uint32_t val);
+/* field must be byte aligned */
+MAD_EXPORT uint64_t mad_get_field64(void *buf, int base_offs,
+ enum MAD_FIELDS field);
+MAD_EXPORT void mad_set_field64(void *buf, int base_offs, enum MAD_FIELDS field,
+ uint64_t val);
+MAD_EXPORT void mad_set_array(void *buf, int base_offs, enum MAD_FIELDS field,
+ void *val);
+MAD_EXPORT void mad_get_array(void *buf, int base_offs, enum MAD_FIELDS field,
+ void *val);
+MAD_EXPORT void mad_decode_field(uint8_t * buf, enum MAD_FIELDS field,
+ void *val);
+MAD_EXPORT void mad_encode_field(uint8_t * buf, enum MAD_FIELDS field,
+ void *val);
+MAD_EXPORT int mad_print_field(enum MAD_FIELDS field, const char *name,
+ void *val);
+MAD_EXPORT char *mad_dump_field(enum MAD_FIELDS field, char *buf, int bufsz,
+ void *val);
+MAD_EXPORT char *mad_dump_val(enum MAD_FIELDS field, char *buf, int bufsz,
+ void *val);
+MAD_EXPORT const char *mad_field_name(enum MAD_FIELDS field);
+
+/* mad.c */
+MAD_EXPORT void *mad_encode(void *buf, ib_rpc_t * rpc, ib_dr_path_t * drpath,
+ void *data);
+MAD_EXPORT uint64_t mad_trid(void);
+MAD_EXPORT int mad_build_pkt(void *umad, ib_rpc_t * rpc, ib_portid_t * dport,
+ ib_rmpp_hdr_t * rmpp, void *data);
+
+/* New interface */
+MAD_EXPORT void madrpc_show_errors(int set);
+MAD_EXPORT int madrpc_set_retries(int retries);
+MAD_EXPORT int madrpc_set_timeout(int timeout);
+MAD_EXPORT struct ibmad_port *mad_rpc_open_port(char *dev_name, int dev_port,
+ int *mgmt_classes,
+ int num_classes);
+MAD_EXPORT void mad_rpc_close_port(struct ibmad_port *srcport);
+
+/*
+ * On redirection, the dport argument is updated with the redirection target,
+ * so subsequent MADs will not go through the redirection process again but
+ * reach the target directly.
+ */
+MAD_EXPORT void *mad_rpc(const struct ibmad_port *srcport, ib_rpc_t * rpc,
+ ib_portid_t * dport, void *payload, void *rcvdata);
+
+MAD_EXPORT void *mad_rpc_rmpp(const struct ibmad_port *srcport, ib_rpc_t * rpc,
+ ib_portid_t * dport, ib_rmpp_hdr_t * rmpp,
+ void *data);
+MAD_EXPORT int mad_rpc_portid(struct ibmad_port *srcport);
+MAD_EXPORT void mad_rpc_set_retries(struct ibmad_port *port, int retries);
+MAD_EXPORT void mad_rpc_set_timeout(struct ibmad_port *port, int timeout);
+MAD_EXPORT int mad_rpc_class_agent(struct ibmad_port *srcport, int cls);
+
+MAD_EXPORT int mad_get_timeout(const struct ibmad_port *srcport,
+ int override_ms);
+MAD_EXPORT int mad_get_retries(const struct ibmad_port *srcport);
+
+/* register.c */
+MAD_EXPORT int mad_register_port_client(int port_id, int mgmt,
+ uint8_t rmpp_version);
+MAD_EXPORT int mad_register_client(int mgmt, uint8_t rmpp_version) DEPRECATED;
+MAD_EXPORT int mad_register_server(int mgmt, uint8_t rmpp_version,
+ long method_mask[16 / sizeof(long)],
+ uint32_t class_oui) DEPRECATED;
+/* register.c new interface */
+MAD_EXPORT int mad_register_client_via(int mgmt, uint8_t rmpp_version,
+ struct ibmad_port *srcport);
+MAD_EXPORT int mad_register_server_via(int mgmt, uint8_t rmpp_version,
+ long method_mask[16 / sizeof(long)],
+ uint32_t class_oui,
+ struct ibmad_port *srcport);
+MAD_EXPORT int mad_class_agent(int mgmt) DEPRECATED;
+
+/* serv.c */
+MAD_EXPORT int mad_send(ib_rpc_t * rpc, ib_portid_t * dport,
+ ib_rmpp_hdr_t * rmpp, void *data) DEPRECATED;
+MAD_EXPORT void *mad_receive(void *umad, int timeout) DEPRECATED;
+MAD_EXPORT int mad_respond(void *umad, ib_portid_t * portid, uint32_t rstatus)
+ DEPRECATED;
+
+/* serv.c new interface */
+MAD_EXPORT int mad_send_via(ib_rpc_t * rpc, ib_portid_t * dport,
+ ib_rmpp_hdr_t * rmpp, void *data,
+ struct ibmad_port *srcport);
+MAD_EXPORT void *mad_receive_via(void *umad, int timeout,
+ struct ibmad_port *srcport);
+MAD_EXPORT int mad_respond_via(void *umad, ib_portid_t * portid,
+ uint32_t rstatus, struct ibmad_port *srcport);
+MAD_EXPORT void *mad_alloc(void);
+MAD_EXPORT void mad_free(void *umad);
+
+/* vendor.c */
+MAD_EXPORT uint8_t *ib_vendor_call(void *data, ib_portid_t * portid,
+ ib_vendor_call_t * call) DEPRECATED;
+
+/* vendor.c new interface */
+MAD_EXPORT uint8_t *ib_vendor_call_via(void *data, ib_portid_t * portid,
+ ib_vendor_call_t * call,
+ struct ibmad_port *srcport);
+
+static inline int mad_is_vendor_range1(int mgmt)
+{
+ return mgmt >= 0x9 && mgmt <= 0xf;
+}
+
+static inline int mad_is_vendor_range2(int mgmt)
+{
+ return mgmt >= 0x30 && mgmt <= 0x4f;
+}
+
+/* rpc.c */
+MAD_EXPORT int madrpc_portid(void) DEPRECATED;
+void *madrpc(ib_rpc_t * rpc, ib_portid_t * dport, void *payload, void *rcvdata)
+ DEPRECATED;
+void *madrpc_rmpp(ib_rpc_t * rpc, ib_portid_t * dport, ib_rmpp_hdr_t * rmpp,
+ void *data) DEPRECATED;
+MAD_EXPORT void madrpc_init(char *dev_name, int dev_port, int *mgmt_classes,
+ int num_classes) DEPRECATED;
+void madrpc_save_mad(void *madbuf, int len) DEPRECATED;
+
+/* smp.c */
+MAD_EXPORT uint8_t *smp_query(void *buf, ib_portid_t * id, unsigned attrid,
+ unsigned mod, unsigned timeout) DEPRECATED;
+MAD_EXPORT uint8_t *smp_set(void *buf, ib_portid_t * id, unsigned attrid,
+ unsigned mod, unsigned timeout) DEPRECATED;
+
+/* smp.c new interface */
+MAD_EXPORT uint8_t *smp_query_via(void *buf, ib_portid_t * id, unsigned attrid,
+ unsigned mod, unsigned timeout,
+ const struct ibmad_port *srcport);
+MAD_EXPORT uint8_t *smp_set_via(void *buf, ib_portid_t * id, unsigned attrid,
+ unsigned mod, unsigned timeout,
+ const struct ibmad_port *srcport);
+MAD_EXPORT uint8_t *smp_query_status_via(void *rcvbuf, ib_portid_t * portid,
+ unsigned attrid, unsigned mod,
+ unsigned timeout, int *rstatus,
+ const struct ibmad_port *srcport);
+MAD_EXPORT uint8_t *smp_set_status_via(void *data, ib_portid_t * portid,
+ unsigned attrid, unsigned mod,
+ unsigned timeout, int *rstatus,
+ const struct ibmad_port *srcport);
+MAD_EXPORT void smp_mkey_set(struct ibmad_port *srcport, uint64_t mkey);
+MAD_EXPORT uint64_t smp_mkey_get(const struct ibmad_port *srcport);
+
+/* cc.c */
+MAD_EXPORT void *cc_query_status_via(void *rcvbuf, ib_portid_t * portid,
+ unsigned attrid, unsigned mod, unsigned timeout,
+ int *rstatus, const struct ibmad_port * srcport,
+ uint64_t cckey);
+
+MAD_EXPORT void *cc_config_status_via(void *payload, void *rcvbuf, ib_portid_t * portid,
+ unsigned attrid, unsigned mod, unsigned timeout,
+ int *rstatus, const struct ibmad_port * srcport,
+ uint64_t cckey);
+
+/* sa.c */
+uint8_t *sa_call(void *rcvbuf, ib_portid_t * portid, ib_sa_call_t * sa,
+ unsigned timeout) DEPRECATED;
+MAD_EXPORT int ib_path_query(ibmad_gid_t srcgid, ibmad_gid_t destgid,
+ ib_portid_t * sm_id, void *buf) DEPRECATED;
+
+/* sa.c new interface */
+MAD_EXPORT uint8_t *sa_rpc_call(const struct ibmad_port *srcport, void *rcvbuf,
+ ib_portid_t * portid, ib_sa_call_t * sa,
+ unsigned timeout);
+MAD_EXPORT int ib_path_query_via(const struct ibmad_port *srcport,
+ ibmad_gid_t srcgid, ibmad_gid_t destgid,
+ ib_portid_t * sm_id, void *buf);
+ /* returns lid */
+MAD_EXPORT int ib_node_query_via(const struct ibmad_port *srcport,
+ uint64_t guid, ib_portid_t * sm_id,
+ void *buf);
+
+/* resolve.c */
+MAD_EXPORT int ib_resolve_smlid(ib_portid_t * sm_id, int timeout) DEPRECATED;
+MAD_EXPORT int ib_resolve_portid_str(ib_portid_t * portid, char *addr_str,
+ enum MAD_DEST dest, ib_portid_t * sm_id)
+ DEPRECATED;
+MAD_EXPORT int ib_resolve_self(ib_portid_t * portid, int *portnum,
+ ibmad_gid_t * gid) DEPRECATED;
+
+/* resolve.c new interface */
+MAD_EXPORT int ib_resolve_smlid_via(ib_portid_t * sm_id, int timeout,
+ const struct ibmad_port *srcport);
+MAD_EXPORT int ib_resolve_guid_via(ib_portid_t * portid, uint64_t * guid,
+ ib_portid_t * sm_id, int timeout,
+ const struct ibmad_port *srcport);
+MAD_EXPORT int ib_resolve_gid_via(ib_portid_t * portid, ibmad_gid_t gid,
+ ib_portid_t * sm_id, int timeout,
+ const struct ibmad_port *srcport);
+MAD_EXPORT int ib_resolve_portid_str_via(ib_portid_t * portid, char *addr_str,
+ enum MAD_DEST dest,
+ ib_portid_t * sm_id,
+ const struct ibmad_port *srcport);
+MAD_EXPORT int ib_resolve_self_via(ib_portid_t * portid, int *portnum,
+ ibmad_gid_t * gid,
+ const struct ibmad_port *srcport);
+
+/* gs.c new interface */
+MAD_EXPORT uint8_t *pma_query_via(void *rcvbuf, ib_portid_t * dest, int port,
+ unsigned timeout, unsigned id,
+ const struct ibmad_port *srcport);
+MAD_EXPORT uint8_t *performance_reset_via(void *rcvbuf, ib_portid_t * dest,
+ int port, unsigned mask,
+ unsigned timeout, unsigned id,
+ const struct ibmad_port *srcport);
+
+/* bm.c */
+MAD_EXPORT uint8_t *bm_call_via(void *data, ib_portid_t * portid,
+ ib_bm_call_t * call,
+ struct ibmad_port *srcport);
+
+/* dump.c */
+MAD_EXPORT ib_mad_dump_fn
+ mad_dump_int, mad_dump_uint, mad_dump_hex, mad_dump_rhex,
+ mad_dump_bitfield, mad_dump_array, mad_dump_string,
+ mad_dump_linkwidth, mad_dump_linkwidthsup, mad_dump_linkwidthen,
+ mad_dump_linkdowndefstate,
+ mad_dump_linkspeed, mad_dump_linkspeedsup, mad_dump_linkspeeden,
+ mad_dump_linkspeedext, mad_dump_linkspeedextsup, mad_dump_linkspeedexten,
+ mad_dump_portstate, mad_dump_portstates,
+ mad_dump_physportstate, mad_dump_portcapmask, mad_dump_portcapmask2,
+ mad_dump_mtu, mad_dump_vlcap, mad_dump_opervls,
+ mad_dump_node_type, mad_dump_sltovl, mad_dump_vlarbitration,
+ mad_dump_nodedesc, mad_dump_nodeinfo, mad_dump_portinfo,
+ mad_dump_switchinfo, mad_dump_perfcounters, mad_dump_perfcounters_ext,
+ mad_dump_perfcounters_xmt_sl, mad_dump_perfcounters_rcv_sl,
+ mad_dump_perfcounters_xmt_disc, mad_dump_perfcounters_rcv_err,
+ mad_dump_portsamples_control, mad_dump_port_ext_speeds_counters,
+ mad_dump_perfcounters_port_op_rcv_counters, mad_dump_perfcounters_port_flow_ctl_counters,
+ mad_dump_perfcounters_port_vl_op_packet, mad_dump_perfcounters_port_vl_op_data,
+ mad_dump_perfcounters_port_vl_xmit_flow_ctl_update_errors, mad_dump_perfcounters_port_vl_xmit_wait_counters,
+ mad_dump_perfcounters_sw_port_vl_congestion, mad_dump_perfcounters_rcv_con_ctrl,
+ mad_dump_perfcounters_sl_rcv_fecn, mad_dump_perfcounters_sl_rcv_becn,
+ mad_dump_perfcounters_xmit_con_ctrl, mad_dump_perfcounters_vl_xmit_time_cong,
+ mad_dump_mlnx_ext_port_info, mad_dump_cc_congestioninfo, mad_dump_cc_congestionkeyinfo,
+ mad_dump_cc_congestionlog, mad_dump_cc_congestionlogswitch,
+ mad_dump_cc_congestionlogentryswitch, mad_dump_cc_congestionlogca,
+ mad_dump_cc_congestionlogentryca, mad_dump_cc_switchcongestionsetting,
+ mad_dump_cc_switchportcongestionsettingelement, mad_dump_cc_cacongestionsetting,
+ mad_dump_cc_cacongestionentry, mad_dump_cc_congestioncontroltable,
+ mad_dump_cc_congestioncontroltableentry, mad_dump_cc_timestamp,
+ mad_dump_classportinfo, mad_dump_portmirror_route,
+ mad_dump_portmirror_ports, mad_dump_portsamples_result,
+ mad_dump_portinfo_ext, mad_dump_port_ext_speeds_counters_rsfec_active;
+
+MAD_EXPORT void mad_dump_fields(char *buf, int bufsz, void *val, int valsz,
+ int start, int end);
+
+extern MAD_EXPORT int ibdebug;
+
+#if __BYTE_ORDER == __LITTLE_ENDIAN
+#ifndef ntohll
+#define ntohll bswap_64
+#endif
+#ifndef htonll
+#define htonll bswap_64
+#endif
+#elif __BYTE_ORDER == __BIG_ENDIAN
+#ifndef ntohll
+#define ntohll(x) (x)
+#endif
+#ifndef htonll
+#define htonll(x) (x)
+#endif
+#endif /* __BYTE_ORDER == __BIG_ENDIAN */
+
+/* Misc. macros: */
+/** align value \a l to \a size (ceil) */
+#define ALIGN(l, size) (((l) + ((size) - 1)) / (size) * (size))
+
+/** printf style warning MACRO, includes name of function and pid */
+#define IBWARN(fmt, ...) fprintf(stderr, "ibwarn: [%d] %s: " fmt "\n", \
+(int)getpid(), __func__, ## __VA_ARGS__)
+
+#define IBDEBUG(fmt, ...) fprintf(stdout, "ibdebug: [%d] %s: " fmt "\n", \
+(int)getpid(), __func__, ## __VA_ARGS__)
+
+#define IBVERBOSE(fmt, ...) fprintf(stdout, "[%d] %s: " fmt "\n", \
+(int)getpid(), __func__, ## __VA_ARGS__)
+
+#define IBPANIC(fmt, ...) do { \
+ fprintf(stderr, "ibpanic: [%d] %s: " fmt ": %m\n", \
+ (int)getpid(), __func__, ## __VA_ARGS__); \
+ exit(-1); \
+} while(0)
+
+MAD_EXPORT void xdump(FILE * file, char *msg, void *p, int size);
+
+END_C_DECLS
+#endif /* _MAD_H_ */
diff --git a/contrib/ofed/libibmad/mad_internal.h b/contrib/ofed/libibmad/mad_internal.h
new file mode 100644
index 0000000..f5522db
--- /dev/null
+++ b/contrib/ofed/libibmad/mad_internal.h
@@ -0,0 +1,52 @@
+/*
+ * Copyright (c) 2004-2009 Voltaire Inc. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+#ifndef _MAD_INTERNAL_H_
+#define _MAD_INTERNAL_H_
+
+#define MAX_CLASS 256
+
+struct ibmad_port {
+ int port_id; /* file descriptor returned by umad_open() */
+ int class_agents[MAX_CLASS]; /* class2agent mapper */
+ int timeout, retries;
+ uint64_t smp_mkey;
+ char ca_name[UMAD_CA_NAME_LEN];
+ int portnum;
+};
+
+extern struct ibmad_port *ibmp;
+extern int madrpc_timeout;
+extern int madrpc_retries;
+
+#endif /* _MAD_INTERNAL_H_ */
diff --git a/contrib/ofed/libibmad/mad_osd.h b/contrib/ofed/libibmad/mad_osd.h
new file mode 100644
index 0000000..afca11d
--- /dev/null
+++ b/contrib/ofed/libibmad/mad_osd.h
@@ -0,0 +1,50 @@
+/*
+ * Copyright (c) 2004-2009 Voltaire Inc. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+#ifndef _MAD_OSD_H_
+#define _MAD_OSD_H_
+
+#include <stdint.h>
+#include <string.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <sys/types.h>
+#include <unistd.h>
+#include <infiniband/byteswap.h>
+#include <inttypes.h>
+#include <arpa/inet.h>
+#include <sys/socket.h>
+
+#define MAD_EXPORT
+#define DEPRECATED __attribute__ ((deprecated))
+
+#endif /* _MAD_OSD_H_ */
diff --git a/contrib/ofed/libibmad/portid.c b/contrib/ofed/libibmad/portid.c
new file mode 100644
index 0000000..40754fe
--- /dev/null
+++ b/contrib/ofed/libibmad/portid.c
@@ -0,0 +1,127 @@
+/*
+ * Copyright (c) 2004-2009 Voltaire Inc. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+#if HAVE_CONFIG_H
+# include <config.h>
+#endif /* HAVE_CONFIG_H */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <arpa/inet.h>
+
+#include <infiniband/mad.h>
+
+#undef DEBUG
+#define DEBUG if (ibdebug) IBWARN
+
+int portid2portnum(ib_portid_t * portid)
+{
+ if (portid->lid > 0)
+ return -1;
+
+ if (portid->drpath.cnt == 0)
+ return 0;
+
+ return portid->drpath.p[(portid->drpath.cnt - 1)];
+}
+
+char *portid2str(ib_portid_t * portid)
+{
+ static char buf[1024] = "local";
+ int n = 0;
+
+ if (portid->lid > 0) {
+ n += sprintf(buf + n, "Lid %d", portid->lid);
+ if (portid->grh_present) {
+ char gid[sizeof
+ "ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff"];
+ if (inet_ntop(AF_INET6, portid->gid, gid, sizeof(gid)))
+ n += sprintf(buf + n, " Gid %s", gid);
+ }
+ if (portid->drpath.cnt)
+ n += sprintf(buf + n, " ");
+ else
+ return buf;
+ }
+ n += sprintf(buf + n, "DR path ");
+ drpath2str(&(portid->drpath), buf + n, sizeof(buf) - n);
+
+ return buf;
+}
+
+int str2drpath(ib_dr_path_t * path, char *routepath, int drslid, int drdlid)
+{
+ char *s, *str;
+ char *tmp;
+
+ path->cnt = -1;
+
+ if (!routepath || !(tmp = strdup(routepath)))
+ goto Exit;
+
+ DEBUG("DR str: %s", routepath);
+
+ str = tmp;
+
+ while (str && *str) {
+ if ((s = strchr(str, ',')))
+ *s = 0;
+ path->p[++path->cnt] = (uint8_t) atoi(str);
+ if (!s)
+ break;
+ str = s + 1;
+ }
+ free(tmp);
+
+Exit:
+ path->drdlid = drdlid ? drdlid : 0xffff;
+ path->drslid = drslid ? drslid : 0xffff;
+
+ return path->cnt;
+}
+
+char *drpath2str(ib_dr_path_t * path, char *dstr, size_t dstr_size)
+{
+ int i = 0;
+ int rc = snprintf(dstr, dstr_size, "slid %u; dlid %u; %d",
+ path->drslid, path->drdlid, path->p[0]);
+ if (rc >= (int)dstr_size)
+ return dstr;
+ for (i = 1; i <= path->cnt; i++) {
+ rc += snprintf(dstr + rc, dstr_size - rc, ",%d", path->p[i]);
+ if (rc >= (int)dstr_size)
+ break;
+ }
+ return (dstr);
+}
diff --git a/contrib/ofed/libibmad/register.c b/contrib/ofed/libibmad/register.c
new file mode 100644
index 0000000..1fdb64a
--- /dev/null
+++ b/contrib/ofed/libibmad/register.c
@@ -0,0 +1,178 @@
+/*
+ * Copyright (c) 2004-2009 Voltaire Inc. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+#if HAVE_CONFIG_H
+# include <config.h>
+#endif /* HAVE_CONFIG_H */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
+
+#include <infiniband/umad.h>
+#include <infiniband/mad.h>
+
+#include "mad_internal.h"
+
+#undef DEBUG
+#define DEBUG if (ibdebug) IBWARN
+
+static int mgmt_class_vers(int mgmt_class)
+{
+ if ((mgmt_class >= IB_VENDOR_RANGE1_START_CLASS &&
+ mgmt_class <= IB_VENDOR_RANGE1_END_CLASS) ||
+ (mgmt_class >= IB_VENDOR_RANGE2_START_CLASS &&
+ mgmt_class <= IB_VENDOR_RANGE2_END_CLASS))
+ return 1;
+
+ switch (mgmt_class) {
+ case IB_SMI_CLASS:
+ case IB_SMI_DIRECT_CLASS:
+ return 1;
+ case IB_SA_CLASS:
+ return 2;
+ case IB_PERFORMANCE_CLASS:
+ return 1;
+ case IB_DEVICE_MGMT_CLASS:
+ return 1;
+ case IB_CC_CLASS:
+ return 2;
+ case IB_BOARD_MGMT_CLASS:
+ return 1;
+ }
+
+ return 0;
+}
+
+int mad_class_agent(int mgmt)
+{
+ if (mgmt < 1 || mgmt >= MAX_CLASS)
+ return -1;
+ return ibmp->class_agents[mgmt];
+}
+
+int mad_register_port_client(int port_id, int mgmt, uint8_t rmpp_version)
+{
+ int vers, agent;
+
+ if ((vers = mgmt_class_vers(mgmt)) <= 0) {
+ DEBUG("Unknown class %d mgmt_class", mgmt);
+ return -1;
+ }
+
+ agent = umad_register(port_id, mgmt, vers, rmpp_version, 0);
+ if (agent < 0)
+ DEBUG("Can't register agent for class %d", mgmt);
+
+ return agent;
+}
+
+int mad_register_client(int mgmt, uint8_t rmpp_version)
+{
+ return mad_register_client_via(mgmt, rmpp_version, ibmp);
+}
+
+int mad_register_client_via(int mgmt, uint8_t rmpp_version,
+ struct ibmad_port *srcport)
+{
+ int agent;
+
+ if (!srcport)
+ return -1;
+
+ agent = mad_register_port_client(mad_rpc_portid(srcport), mgmt,
+ rmpp_version);
+ if (agent < 0)
+ return agent;
+
+ srcport->class_agents[mgmt] = agent;
+ return 0;
+}
+
+int mad_register_server(int mgmt, uint8_t rmpp_version,
+ long method_mask[], uint32_t class_oui)
+{
+ return mad_register_server_via(mgmt, rmpp_version, method_mask,
+ class_oui, ibmp);
+}
+
+int mad_register_server_via(int mgmt, uint8_t rmpp_version,
+ long method_mask[], uint32_t class_oui,
+ struct ibmad_port *srcport)
+{
+ long class_method_mask[16 / sizeof(long)];
+ uint8_t oui[3];
+ int agent, vers;
+
+ if (method_mask)
+ memcpy(class_method_mask, method_mask,
+ sizeof class_method_mask);
+ else
+ memset(class_method_mask, 0xff, sizeof(class_method_mask));
+
+ if (!srcport)
+ return -1;
+
+ if (srcport->class_agents[mgmt] >= 0) {
+ DEBUG("Class 0x%x already registered %d",
+ mgmt, srcport->class_agents[mgmt]);
+ return -1;
+ }
+ if ((vers = mgmt_class_vers(mgmt)) <= 0) {
+ DEBUG("Unknown class 0x%x mgmt_class", mgmt);
+ return -1;
+ }
+ if (mgmt >= IB_VENDOR_RANGE2_START_CLASS &&
+ mgmt <= IB_VENDOR_RANGE2_END_CLASS) {
+ oui[0] = (class_oui >> 16) & 0xff;
+ oui[1] = (class_oui >> 8) & 0xff;
+ oui[2] = class_oui & 0xff;
+ if ((agent =
+ umad_register_oui(srcport->port_id, mgmt, rmpp_version,
+ oui, class_method_mask)) < 0) {
+ DEBUG("Can't register agent for class %d", mgmt);
+ return -1;
+ }
+ } else
+ if ((agent =
+ umad_register(srcport->port_id, mgmt, vers, rmpp_version,
+ class_method_mask)) < 0) {
+ DEBUG("Can't register agent for class %d", mgmt);
+ return -1;
+ }
+
+ srcport->class_agents[mgmt] = agent;
+
+ return agent;
+}
diff --git a/contrib/ofed/libibmad/resolve.c b/contrib/ofed/libibmad/resolve.c
new file mode 100644
index 0000000..1e40357
--- /dev/null
+++ b/contrib/ofed/libibmad/resolve.c
@@ -0,0 +1,249 @@
+/*
+ * Copyright (c) 2004-2009 Voltaire Inc. All rights reserved.
+ * Copyright (c) 2009 HNR Consulting. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+#if HAVE_CONFIG_H
+# include <config.h>
+#endif /* HAVE_CONFIG_H */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <arpa/inet.h>
+#include <errno.h>
+
+#include <infiniband/umad.h>
+#include <infiniband/mad.h>
+#include "mad_internal.h"
+
+#undef DEBUG
+#define DEBUG if (ibdebug) IBWARN
+
+int ib_resolve_smlid_via(ib_portid_t * sm_id, int timeout,
+ const struct ibmad_port *srcport)
+{
+ umad_port_t port;
+ int ret;
+
+ memset(sm_id, 0, sizeof(*sm_id));
+
+ ret = umad_get_port(srcport->ca_name, srcport->portnum, &port);
+ if (ret)
+ return -1;
+
+ if (!IB_LID_VALID(port.sm_lid)) {
+ errno = ENXIO;
+ return -1;
+ }
+ sm_id->sl = port.sm_sl;
+
+ ret = ib_portid_set(sm_id, port.sm_lid, 0, 0);
+ umad_release_port(&port);
+ return ret;
+}
+
+int ib_resolve_smlid(ib_portid_t * sm_id, int timeout)
+{
+ return ib_resolve_smlid_via(sm_id, timeout, ibmp);
+}
+
+int ib_resolve_gid_via(ib_portid_t * portid, ibmad_gid_t gid,
+ ib_portid_t * sm_id, int timeout,
+ const struct ibmad_port *srcport)
+{
+ ib_portid_t sm_portid = { 0 };
+ char buf[IB_SA_DATA_SIZE] = { 0 };
+
+ if (!sm_id)
+ sm_id = &sm_portid;
+
+ if (!IB_LID_VALID(sm_id->lid)) {
+ if (ib_resolve_smlid_via(sm_id, timeout, srcport) < 0)
+ return -1;
+ }
+
+ if ((portid->lid =
+ ib_path_query_via(srcport, gid, gid, sm_id, buf)) < 0)
+ return -1;
+
+ return 0;
+}
+
+int ib_resolve_guid_via(ib_portid_t * portid, uint64_t * guid,
+ ib_portid_t * sm_id, int timeout,
+ const struct ibmad_port *srcport)
+{
+ ib_portid_t sm_portid = { 0 };
+ uint8_t buf[IB_SA_DATA_SIZE] = { 0 };
+ uint64_t prefix;
+ ibmad_gid_t selfgid;
+ umad_port_t port;
+
+ if (!sm_id)
+ sm_id = &sm_portid;
+
+ if (!IB_LID_VALID(sm_id->lid)) {
+ if (ib_resolve_smlid_via(sm_id, timeout, srcport) < 0)
+ return -1;
+ }
+
+ if (umad_get_port(srcport->ca_name, srcport->portnum, &port))
+ return -1;
+
+ mad_set_field64(selfgid, 0, IB_GID_PREFIX_F, ntohll(port.gid_prefix));
+ mad_set_field64(selfgid, 0, IB_GID_GUID_F, ntohll(port.port_guid));
+ umad_release_port(&port);
+
+ memcpy(&prefix, portid->gid, sizeof(prefix));
+ if (!prefix)
+ mad_set_field64(portid->gid, 0, IB_GID_PREFIX_F,
+ IB_DEFAULT_SUBN_PREFIX);
+ if (guid)
+ mad_set_field64(portid->gid, 0, IB_GID_GUID_F, *guid);
+
+ if ((portid->lid =
+ ib_path_query_via(srcport, selfgid, portid->gid, sm_id, buf)) < 0)
+ return -1;
+
+ mad_decode_field(buf, IB_SA_PR_SL_F, &portid->sl);
+ return 0;
+}
+
+int ib_resolve_portid_str_via(ib_portid_t * portid, char *addr_str,
+ enum MAD_DEST dest_type, ib_portid_t * sm_id,
+ const struct ibmad_port *srcport)
+{
+ ibmad_gid_t gid;
+ uint64_t guid;
+ int lid;
+ char *routepath;
+ ib_portid_t selfportid = { 0 };
+ int selfport = 0;
+
+ memset(portid, 0, sizeof *portid);
+
+ switch (dest_type) {
+ case IB_DEST_LID:
+ lid = strtol(addr_str, 0, 0);
+ if (!IB_LID_VALID(lid)) {
+ errno = EINVAL;
+ return -1;
+ }
+ return ib_portid_set(portid, lid, 0, 0);
+
+ case IB_DEST_DRPATH:
+ if (str2drpath(&portid->drpath, addr_str, 0, 0) < 0) {
+ errno = EINVAL;
+ return -1;
+ }
+ return 0;
+
+ case IB_DEST_GUID:
+ if (!(guid = strtoull(addr_str, 0, 0))) {
+ errno = EINVAL;
+ return -1;
+ }
+
+ /* keep guid in portid? */
+ return ib_resolve_guid_via(portid, &guid, sm_id, 0, srcport);
+
+ case IB_DEST_DRSLID:
+ lid = strtol(addr_str, &routepath, 0);
+ routepath++;
+ if (!IB_LID_VALID(lid)) {
+ errno = EINVAL;
+ return -1;
+ }
+ ib_portid_set(portid, lid, 0, 0);
+
+ /* handle DR parsing and set DrSLID to local lid */
+ if (ib_resolve_self_via(&selfportid, &selfport, 0, srcport) < 0)
+ return -1;
+ if (str2drpath(&portid->drpath, routepath, selfportid.lid, 0) <
+ 0) {
+ errno = EINVAL;
+ return -1;
+ }
+ return 0;
+
+ case IB_DEST_GID:
+ if (inet_pton(AF_INET6, addr_str, &gid) <= 0)
+ return -1;
+ return ib_resolve_gid_via(portid, gid, sm_id, 0, srcport);
+ default:
+ IBWARN("bad dest_type %d", dest_type);
+ errno = EINVAL;
+ }
+
+ return -1;
+}
+
+int ib_resolve_portid_str(ib_portid_t * portid, char *addr_str,
+ enum MAD_DEST dest_type, ib_portid_t * sm_id)
+{
+ return ib_resolve_portid_str_via(portid, addr_str, dest_type,
+ sm_id, ibmp);
+}
+
+int ib_resolve_self_via(ib_portid_t * portid, int *portnum, ibmad_gid_t * gid,
+ const struct ibmad_port *srcport)
+{
+ ib_portid_t self = { 0 };
+ uint8_t portinfo[64];
+ uint8_t nodeinfo[64];
+ uint64_t guid, prefix;
+
+ if (!smp_query_via(nodeinfo, &self, IB_ATTR_NODE_INFO, 0, 0, srcport))
+ return -1;
+
+ if (!smp_query_via(portinfo, &self, IB_ATTR_PORT_INFO, 0, 0, srcport))
+ return -1;
+
+ mad_decode_field(portinfo, IB_PORT_LID_F, &portid->lid);
+ mad_decode_field(portinfo, IB_PORT_SMSL_F, &portid->sl);
+ mad_decode_field(portinfo, IB_PORT_GID_PREFIX_F, &prefix);
+ mad_decode_field(nodeinfo, IB_NODE_PORT_GUID_F, &guid);
+
+ if (portnum)
+ mad_decode_field(nodeinfo, IB_NODE_LOCAL_PORT_F, portnum);
+ if (gid) {
+ mad_encode_field(*gid, IB_GID_PREFIX_F, &prefix);
+ mad_encode_field(*gid, IB_GID_GUID_F, &guid);
+ }
+ return 0;
+}
+
+int ib_resolve_self(ib_portid_t * portid, int *portnum, ibmad_gid_t * gid)
+{
+ return ib_resolve_self_via(portid, portnum, gid, ibmp);
+}
diff --git a/contrib/ofed/libibmad/rpc.c b/contrib/ofed/libibmad/rpc.c
new file mode 100644
index 0000000..a7d29e3
--- /dev/null
+++ b/contrib/ofed/libibmad/rpc.c
@@ -0,0 +1,456 @@
+/*
+ * Copyright (c) 2004-2009 Voltaire Inc. All rights reserved.
+ * Copyright (c) 2009 HNR Consulting. All rights reserved.
+ * Copyright (c) 2011 Mellanox Technologies LTD. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+#if HAVE_CONFIG_H
+# include <config.h>
+#endif /* HAVE_CONFIG_H */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
+
+#include <infiniband/umad.h>
+#include <infiniband/mad.h>
+
+#include "mad_internal.h"
+
+int ibdebug;
+
+static struct ibmad_port mad_port;
+struct ibmad_port *ibmp = &mad_port;
+
+static int iberrs;
+
+int madrpc_retries = MAD_DEF_RETRIES;
+int madrpc_timeout = MAD_DEF_TIMEOUT_MS;
+
+static void *save_mad;
+static int save_mad_len = 256;
+
+#undef DEBUG
+#define DEBUG if (ibdebug) IBWARN
+#define ERRS(fmt, ...) do { \
+ if (iberrs || ibdebug) \
+ IBWARN(fmt, ## __VA_ARGS__); \
+} while (0)
+
+#define MAD_TID(mad) (*((uint64_t *)((char *)(mad) + 8)))
+
+void madrpc_show_errors(int set)
+{
+ iberrs = set;
+}
+
+void madrpc_save_mad(void *madbuf, int len)
+{
+ save_mad = madbuf;
+ save_mad_len = len;
+}
+
+int madrpc_set_retries(int retries)
+{
+ if (retries > 0)
+ madrpc_retries = retries;
+ return madrpc_retries;
+}
+
+int madrpc_set_timeout(int timeout)
+{
+ madrpc_timeout = timeout;
+ return 0;
+}
+
+void mad_rpc_set_retries(struct ibmad_port *port, int retries)
+{
+ port->retries = retries;
+}
+
+void mad_rpc_set_timeout(struct ibmad_port *port, int timeout)
+{
+ port->timeout = timeout;
+}
+
+int madrpc_def_timeout(void)
+{
+ return madrpc_timeout;
+}
+
+int madrpc_portid(void)
+{
+ return ibmp->port_id;
+}
+
+int mad_rpc_portid(struct ibmad_port *srcport)
+{
+ return srcport->port_id;
+}
+
+int mad_rpc_class_agent(struct ibmad_port *port, int class)
+{
+ if (class < 1 || class >= MAX_CLASS)
+ return -1;
+ return port->class_agents[class];
+}
+
+static int
+_do_madrpc(int port_id, void *sndbuf, void *rcvbuf, int agentid, int len,
+ int timeout, int max_retries, int *p_error)
+{
+ uint32_t trid; /* only low 32 bits - see mad_trid() */
+ int retries;
+ int length, status;
+
+ if (ibdebug > 1) {
+ IBWARN(">>> sending: len %d pktsz %zu", len, umad_size() + len);
+ xdump(stderr, "send buf\n", sndbuf, umad_size() + len);
+ }
+
+ if (save_mad) {
+ memcpy(save_mad, umad_get_mad(sndbuf),
+ save_mad_len < len ? save_mad_len : len);
+ save_mad = 0;
+ }
+
+ if (max_retries <= 0) {
+ errno = EINVAL;
+ *p_error = EINVAL;
+ ERRS("max_retries %d <= 0", max_retries);
+ return -1;
+ }
+
+ trid =
+ (uint32_t) mad_get_field64(umad_get_mad(sndbuf), 0, IB_MAD_TRID_F);
+
+ for (retries = 0; retries < max_retries; retries++) {
+ if (retries)
+ ERRS("retry %d (timeout %d ms)", retries, timeout);
+
+ length = len;
+ if (umad_send(port_id, agentid, sndbuf, length, timeout, 0) < 0) {
+ IBWARN("send failed; %s", strerror(errno));
+ return -1;
+ }
+
+ /* Use same timeout on receive side just in case */
+ /* send packet is lost somewhere. */
+ do {
+ length = len;
+ if (umad_recv(port_id, rcvbuf, &length, timeout) < 0) {
+ IBWARN("recv failed: %s", strerror(errno));
+ return -1;
+ }
+
+ if (ibdebug > 2)
+ umad_addr_dump(umad_get_mad_addr(rcvbuf));
+ if (ibdebug > 1) {
+ IBWARN("rcv buf:");
+ xdump(stderr, "rcv buf\n", umad_get_mad(rcvbuf),
+ IB_MAD_SIZE);
+ }
+ } while ((uint32_t)
+ mad_get_field64(umad_get_mad(rcvbuf), 0,
+ IB_MAD_TRID_F) != trid);
+
+ status = umad_status(rcvbuf);
+ if (!status)
+ return length; /* done */
+ if (status == ENOMEM)
+ return length;
+ }
+
+ errno = status;
+ *p_error = ETIMEDOUT;
+ ERRS("timeout after %d retries, %d ms", retries, timeout * retries);
+ return -1;
+}
+
+static int redirect_port(ib_portid_t * port, uint8_t * mad)
+{
+ port->lid = mad_get_field(mad, 64, IB_CPI_REDIRECT_LID_F);
+ if (!port->lid) {
+ IBWARN("GID-based redirection is not supported");
+ return -1;
+ }
+
+ port->qp = mad_get_field(mad, 64, IB_CPI_REDIRECT_QP_F);
+ port->qkey = mad_get_field(mad, 64, IB_CPI_REDIRECT_QKEY_F);
+ port->sl = (uint8_t) mad_get_field(mad, 64, IB_CPI_REDIRECT_SL_F);
+
+ /* TODO: Reverse map redirection P_Key to P_Key index */
+
+ if (ibdebug)
+ IBWARN("redirected to lid %d, qp 0x%x, qkey 0x%x, sl 0x%x",
+ port->lid, port->qp, port->qkey, port->sl);
+
+ return 0;
+}
+
+void *mad_rpc(const struct ibmad_port *port, ib_rpc_t * rpc,
+ ib_portid_t * dport, void *payload, void *rcvdata)
+{
+ int status, len;
+ uint8_t sndbuf[1024], rcvbuf[1024], *mad;
+ ib_rpc_v1_t *rpcv1 = (ib_rpc_v1_t *)rpc;
+ int error = 0;
+
+ if ((rpc->mgtclass & IB_MAD_RPC_VERSION_MASK) == IB_MAD_RPC_VERSION1)
+ rpcv1->error = 0;
+ do {
+ len = 0;
+ memset(sndbuf, 0, umad_size() + IB_MAD_SIZE);
+
+ if ((len = mad_build_pkt(sndbuf, rpc, dport, 0, payload)) < 0)
+ return NULL;
+
+ if ((len = _do_madrpc(port->port_id, sndbuf, rcvbuf,
+ port->class_agents[rpc->mgtclass & 0xff],
+ len, mad_get_timeout(port, rpc->timeout),
+ mad_get_retries(port), &error)) < 0) {
+ if ((rpc->mgtclass & IB_MAD_RPC_VERSION_MASK) ==
+ IB_MAD_RPC_VERSION1)
+ rpcv1->error = error;
+ IBWARN("_do_madrpc failed; dport (%s)",
+ portid2str(dport));
+ return NULL;
+ }
+
+ mad = umad_get_mad(rcvbuf);
+ status = mad_get_field(mad, 0, IB_DRSMP_STATUS_F);
+
+ /* check for exact match instead of only the redirect bit;
+ * that way, weird statuses cause an error, too */
+ if (status == IB_MAD_STS_REDIRECT) {
+ /* update dport for next request and retry */
+ /* bail if redirection fails */
+ if (redirect_port(dport, mad))
+ break;
+ } else
+ break;
+ } while (1);
+
+ if ((rpc->mgtclass & IB_MAD_RPC_VERSION_MASK) == IB_MAD_RPC_VERSION1)
+ rpcv1->error = error;
+ rpc->rstatus = status;
+
+ if (status != 0) {
+ ERRS("MAD completed with error status 0x%x; dport (%s)",
+ status, portid2str(dport));
+ errno = EIO;
+ return NULL;
+ }
+
+ if (ibdebug) {
+ IBWARN("data offs %d sz %d", rpc->dataoffs, rpc->datasz);
+ xdump(stderr, "mad data\n", mad + rpc->dataoffs, rpc->datasz);
+ }
+
+ if (rcvdata)
+ memcpy(rcvdata, mad + rpc->dataoffs, rpc->datasz);
+
+ return rcvdata;
+}
+
+void *mad_rpc_rmpp(const struct ibmad_port *port, ib_rpc_t * rpc,
+ ib_portid_t * dport, ib_rmpp_hdr_t * rmpp, void *data)
+{
+ int status, len;
+ uint8_t sndbuf[1024], rcvbuf[1024], *mad;
+ ib_rpc_v1_t *rpcv1 = (ib_rpc_v1_t *)rpc;
+ int error = 0;
+
+ memset(sndbuf, 0, umad_size() + IB_MAD_SIZE);
+
+ DEBUG("rmpp %p data %p", rmpp, data);
+
+ if ((rpc->mgtclass & IB_MAD_RPC_VERSION_MASK) == IB_MAD_RPC_VERSION1)
+ rpcv1->error = 0;
+ if ((len = mad_build_pkt(sndbuf, rpc, dport, rmpp, data)) < 0)
+ return NULL;
+
+ if ((len = _do_madrpc(port->port_id, sndbuf, rcvbuf,
+ port->class_agents[rpc->mgtclass & 0xff],
+ len, mad_get_timeout(port, rpc->timeout),
+ mad_get_retries(port), &error)) < 0) {
+ if ((rpc->mgtclass & IB_MAD_RPC_VERSION_MASK) == IB_MAD_RPC_VERSION1)
+ rpcv1->error = error;
+ IBWARN("_do_madrpc failed; dport (%s)", portid2str(dport));
+ return NULL;
+ }
+
+ if ((rpc->mgtclass & IB_MAD_RPC_VERSION_MASK) == IB_MAD_RPC_VERSION1)
+ rpcv1->error = error;
+
+ mad = umad_get_mad(rcvbuf);
+
+ if ((status = mad_get_field(mad, 0, IB_MAD_STATUS_F)) != 0) {
+ ERRS("MAD completed with error status 0x%x; dport (%s)",
+ status, portid2str(dport));
+ errno = EIO;
+ return NULL;
+ }
+
+ if (ibdebug) {
+ IBWARN("data offs %d sz %d", rpc->dataoffs, rpc->datasz);
+ xdump(stderr, "rmpp mad data\n", mad + rpc->dataoffs,
+ rpc->datasz);
+ }
+
+ if (rmpp) {
+ rmpp->flags = mad_get_field(mad, 0, IB_SA_RMPP_FLAGS_F);
+ if ((rmpp->flags & 0x3) &&
+ mad_get_field(mad, 0, IB_SA_RMPP_VERS_F) != 1) {
+ IBWARN("bad rmpp version");
+ return NULL;
+ }
+ rmpp->type = mad_get_field(mad, 0, IB_SA_RMPP_TYPE_F);
+ rmpp->status = mad_get_field(mad, 0, IB_SA_RMPP_STATUS_F);
+ DEBUG("rmpp type %d status %d", rmpp->type, rmpp->status);
+ rmpp->d1.u = mad_get_field(mad, 0, IB_SA_RMPP_D1_F);
+ rmpp->d2.u = mad_get_field(mad, 0, IB_SA_RMPP_D2_F);
+ }
+
+ if (data)
+ memcpy(data, mad + rpc->dataoffs, rpc->datasz);
+
+ rpc->recsz = mad_get_field(mad, 0, IB_SA_ATTROFFS_F);
+
+ return data;
+}
+
+void *madrpc(ib_rpc_t * rpc, ib_portid_t * dport, void *payload, void *rcvdata)
+{
+ return mad_rpc(ibmp, rpc, dport, payload, rcvdata);
+}
+
+void *madrpc_rmpp(ib_rpc_t * rpc, ib_portid_t * dport, ib_rmpp_hdr_t * rmpp,
+ void *data)
+{
+ return mad_rpc_rmpp(ibmp, rpc, dport, rmpp, data);
+}
+
+void
+madrpc_init(char *dev_name, int dev_port, int *mgmt_classes, int num_classes)
+{
+ int fd;
+
+ if (umad_init() < 0)
+ IBPANIC("can't init UMAD library");
+
+ if ((fd = umad_open_port(dev_name, dev_port)) < 0)
+ IBPANIC("can't open UMAD port (%s:%d)",
+ dev_name ? dev_name : "(nil)", dev_port);
+
+ if (num_classes >= MAX_CLASS)
+ IBPANIC("too many classes %d requested", num_classes);
+
+ ibmp->port_id = fd;
+ memset(ibmp->class_agents, 0xff, sizeof ibmp->class_agents);
+ while (num_classes--) {
+ uint8_t rmpp_version = 0;
+ int mgmt = *mgmt_classes++;
+
+ if (mgmt == IB_SA_CLASS)
+ rmpp_version = 1;
+ if (mad_register_client_via(mgmt, rmpp_version, ibmp) < 0)
+ IBPANIC("client_register for mgmt class %d failed",
+ mgmt);
+ }
+}
+
+struct ibmad_port *mad_rpc_open_port(char *dev_name, int dev_port,
+ int *mgmt_classes, int num_classes)
+{
+ struct ibmad_port *p;
+ int port_id;
+
+ if (num_classes >= MAX_CLASS) {
+ IBWARN("too many classes %d requested", num_classes);
+ errno = EINVAL;
+ return NULL;
+ }
+
+ if (umad_init() < 0) {
+ IBWARN("can't init UMAD library");
+ errno = ENODEV;
+ return NULL;
+ }
+
+ p = malloc(sizeof(*p));
+ if (!p) {
+ errno = ENOMEM;
+ return NULL;
+ }
+ memset(p, 0, sizeof(*p));
+
+ if ((port_id = umad_open_port(dev_name, dev_port)) < 0) {
+ IBWARN("can't open UMAD port (%s:%d)", dev_name, dev_port);
+ if (!errno)
+ errno = EIO;
+ free(p);
+ return NULL;
+ }
+
+ p->port_id = port_id;
+ if (dev_name)
+ strncpy(p->ca_name, dev_name, sizeof p->ca_name - 1);
+ p->portnum = dev_port;
+
+ memset(p->class_agents, 0xff, sizeof p->class_agents);
+ while (num_classes--) {
+ uint8_t rmpp_version = 0;
+ int mgmt = *mgmt_classes++;
+
+ if (mgmt == IB_SA_CLASS)
+ rmpp_version = 1;
+ if (mgmt < 0 || mgmt >= MAX_CLASS ||
+ mad_register_client_via(mgmt, rmpp_version, p) < 0) {
+ IBWARN("client_register for mgmt %d failed", mgmt);
+ if (!errno)
+ errno = EINVAL;
+ umad_close_port(port_id);
+ free(p);
+ return NULL;
+ }
+ }
+
+ return p;
+}
+
+void mad_rpc_close_port(struct ibmad_port *port)
+{
+ umad_close_port(port->port_id);
+ free(port);
+}
diff --git a/contrib/ofed/libibmad/sa.c b/contrib/ofed/libibmad/sa.c
new file mode 100644
index 0000000..9a9da21
--- /dev/null
+++ b/contrib/ofed/libibmad/sa.c
@@ -0,0 +1,192 @@
+/*
+ * Copyright (c) 2004-2009 Voltaire Inc. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+#if HAVE_CONFIG_H
+# include <config.h>
+#endif /* HAVE_CONFIG_H */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include <infiniband/umad.h>
+#include <infiniband/mad.h>
+#include "mad_internal.h"
+
+#undef DEBUG
+#define DEBUG if (ibdebug) IBWARN
+
+uint8_t *sa_rpc_call(const struct ibmad_port *ibmad_port, void *rcvbuf,
+ ib_portid_t * portid, ib_sa_call_t * sa, unsigned timeout)
+{
+ ib_rpc_t rpc = { 0 };
+ uint8_t *p;
+
+ DEBUG("attr 0x%x mod 0x%x route %s", sa->attrid, sa->mod,
+ portid2str(portid));
+
+ if (portid->lid <= 0) {
+ IBWARN("only lid routes are supported");
+ return NULL;
+ }
+
+ rpc.mgtclass = IB_SA_CLASS;
+ rpc.method = sa->method;
+ rpc.attr.id = sa->attrid;
+ rpc.attr.mod = sa->mod;
+ rpc.mask = sa->mask;
+ rpc.timeout = timeout;
+ rpc.datasz = IB_SA_DATA_SIZE;
+ rpc.dataoffs = IB_SA_DATA_OFFS;
+ rpc.trid = sa->trid;
+
+ portid->qp = 1;
+ if (!portid->qkey)
+ portid->qkey = IB_DEFAULT_QP1_QKEY;
+
+ p = mad_rpc_rmpp(ibmad_port, &rpc, portid, 0 /*&sa->rmpp */ , rcvbuf); /* TODO: RMPP */
+
+ sa->recsz = rpc.recsz;
+
+ return p;
+}
+
+uint8_t *sa_call(void *rcvbuf, ib_portid_t * portid, ib_sa_call_t * sa,
+ unsigned timeout)
+{
+ return sa_rpc_call(ibmp, rcvbuf, portid, sa, timeout);
+}
+
+/* PathRecord */
+#define IB_PR_COMPMASK_DGID (1ull<<2)
+#define IB_PR_COMPMASK_SGID (1ull<<3)
+#define IB_PR_COMPMASK_DLID (1ull<<4)
+#define IB_PR_COMPMASK_SLID (1ull<<5)
+#define IB_PR_COMPMASK_RAWTRAFIC (1ull<<6)
+#define IB_PR_COMPMASK_RESV0 (1ull<<7)
+#define IB_PR_COMPMASK_FLOWLABEL (1ull<<8)
+#define IB_PR_COMPMASK_HOPLIMIT (1ull<<9)
+#define IB_PR_COMPMASK_TCLASS (1ull<<10)
+#define IB_PR_COMPMASK_REVERSIBLE (1ull<<11)
+#define IB_PR_COMPMASK_NUMBPATH (1ull<<12)
+#define IB_PR_COMPMASK_PKEY (1ull<<13)
+#define IB_PR_COMPMASK_RESV1 (1ull<<14)
+#define IB_PR_COMPMASK_SL (1ull<<15)
+#define IB_PR_COMPMASK_MTUSELEC (1ull<<16)
+#define IB_PR_COMPMASK_MTU (1ull<<17)
+#define IB_PR_COMPMASK_RATESELEC (1ull<<18)
+#define IB_PR_COMPMASK_RATE (1ull<<19)
+#define IB_PR_COMPMASK_PKTLIFETIMESELEC (1ull<<20)
+#define IB_PR_COMPMASK_PKTLIFETIME (1ull<<21)
+#define IB_PR_COMPMASK_PREFERENCE (1ull<<22)
+
+#define IB_PR_DEF_MASK (IB_PR_COMPMASK_DGID |\
+ IB_PR_COMPMASK_SGID)
+
+int ib_path_query_via(const struct ibmad_port *srcport, ibmad_gid_t srcgid,
+ ibmad_gid_t destgid, ib_portid_t * sm_id, void *buf)
+{
+ ib_sa_call_t sa = { 0 };
+ uint8_t *p;
+ int dlid;
+
+ memset(&sa, 0, sizeof sa);
+ sa.method = IB_MAD_METHOD_GET;
+ sa.attrid = IB_SA_ATTR_PATHRECORD;
+ sa.mask = IB_PR_DEF_MASK;
+ sa.trid = mad_trid();
+
+ memset(buf, 0, IB_SA_PR_RECSZ);
+
+ mad_encode_field(buf, IB_SA_PR_DGID_F, destgid);
+ mad_encode_field(buf, IB_SA_PR_SGID_F, srcgid);
+
+ p = sa_rpc_call(srcport, buf, sm_id, &sa, 0);
+ if (!p) {
+ IBWARN("sa call path_query failed");
+ return -1;
+ }
+
+ mad_decode_field(p, IB_SA_PR_DLID_F, &dlid);
+ return dlid;
+}
+
+int ib_path_query(ibmad_gid_t srcgid, ibmad_gid_t destgid, ib_portid_t * sm_id,
+ void *buf)
+{
+ return ib_path_query_via(ibmp, srcgid, destgid, sm_id, buf);
+}
+
+/* NodeRecord */
+#define IB_NR_COMPMASK_LID (1ull<<0)
+#define IB_NR_COMPMASK_RESERVED1 (1ull<<1)
+#define IB_NR_COMPMASK_BASEVERSION (1ull<<2)
+#define IB_NR_COMPMASK_CLASSVERSION (1ull<<3)
+#define IB_NR_COMPMASK_NODETYPE (1ull<<4)
+#define IB_NR_COMPMASK_NUMPORTS (1ull<<5)
+#define IB_NR_COMPMASK_SYSIMAGEGUID (1ull<<6)
+#define IB_NR_COMPMASK_NODEGUID (1ull<<7)
+#define IB_NR_COMPMASK_PORTGUID (1ull<<8)
+#define IB_NR_COMPMASK_PARTCAP (1ull<<9)
+#define IB_NR_COMPMASK_DEVID (1ull<<10)
+#define IB_NR_COMPMASK_REV (1ull<<11)
+#define IB_NR_COMPMASK_PORTNUM (1ull<<12)
+#define IB_NR_COMPMASK_VENDID (1ull<<13)
+#define IB_NR_COMPMASK_NODEDESC (1ull<<14)
+
+#define IB_NR_DEF_MASK IB_NR_COMPMASK_PORTGUID
+
+int ib_node_query_via(const struct ibmad_port *srcport, uint64_t guid,
+ ib_portid_t * sm_id, void *buf)
+{
+ ib_sa_call_t sa = { 0 };
+ uint8_t *p;
+
+ memset(&sa, 0, sizeof sa);
+ sa.method = IB_MAD_METHOD_GET;
+ sa.attrid = IB_SA_ATTR_NODERECORD;
+ sa.mask = IB_NR_DEF_MASK;
+ sa.trid = mad_trid();
+
+ memset(buf, 0, IB_SA_NR_RECSZ);
+
+ mad_encode_field(buf, IB_SA_NR_PORT_GUID_F, &guid);
+
+ p = sa_rpc_call(srcport, buf, sm_id, &sa, 0);
+ if (!p) {
+ IBWARN("sa call node_query failed");
+ return -1;
+ }
+
+ return 0;
+}
diff --git a/contrib/ofed/libibmad/serv.c b/contrib/ofed/libibmad/serv.c
new file mode 100644
index 0000000..26d6d13
--- /dev/null
+++ b/contrib/ofed/libibmad/serv.c
@@ -0,0 +1,205 @@
+/*
+ * Copyright (c) 2004-2009 Voltaire Inc. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+#if HAVE_CONFIG_H
+# include <config.h>
+#endif /* HAVE_CONFIG_H */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
+
+#include <infiniband/umad.h>
+#include <infiniband/mad.h>
+
+#include "mad_internal.h"
+
+#undef DEBUG
+#define DEBUG if (ibdebug) IBWARN
+
+int mad_send(ib_rpc_t * rpc, ib_portid_t * dport, ib_rmpp_hdr_t * rmpp,
+ void *data)
+{
+ return mad_send_via(rpc, dport, rmpp, data, ibmp);
+}
+
+int mad_send_via(ib_rpc_t * rpc, ib_portid_t * dport, ib_rmpp_hdr_t * rmpp,
+ void *data, struct ibmad_port *srcport)
+{
+ uint8_t pktbuf[1024];
+ void *umad = pktbuf;
+
+ memset(pktbuf, 0, umad_size() + IB_MAD_SIZE);
+
+ DEBUG("rmpp %p data %p", rmpp, data);
+
+ if (mad_build_pkt(umad, rpc, dport, rmpp, data) < 0)
+ return -1;
+
+ if (ibdebug) {
+ IBWARN("data offs %d sz %d", rpc->dataoffs, rpc->datasz);
+ xdump(stderr, "mad send data\n",
+ (char *)umad_get_mad(umad) + rpc->dataoffs, rpc->datasz);
+ }
+
+ if (umad_send(srcport->port_id, srcport->class_agents[rpc->mgtclass & 0xff],
+ umad, IB_MAD_SIZE, mad_get_timeout(srcport, rpc->timeout),
+ 0) < 0) {
+ IBWARN("send failed; %s", strerror(errno));
+ return -1;
+ }
+
+ return 0;
+}
+
+int mad_respond(void *umad, ib_portid_t * portid, uint32_t rstatus)
+{
+ return mad_respond_via(umad, portid, rstatus, ibmp);
+}
+
+int mad_respond_via(void *umad, ib_portid_t * portid, uint32_t rstatus,
+ struct ibmad_port *srcport)
+{
+ uint8_t *mad = umad_get_mad(umad);
+ ib_mad_addr_t *mad_addr;
+ ib_rpc_t rpc = { 0 };
+ ib_portid_t rport;
+ int is_smi;
+
+ if (!portid) {
+ if (!(mad_addr = umad_get_mad_addr(umad))) {
+ errno = EINVAL;
+ return -1;
+ }
+
+ memset(&rport, 0, sizeof(rport));
+
+ rport.lid = ntohs(mad_addr->lid);
+ rport.qp = ntohl(mad_addr->qpn);
+ rport.qkey = ntohl(mad_addr->qkey);
+ rport.sl = mad_addr->sl;
+
+ if (mad_addr->grh_present) {
+ rport.grh_present = 1;
+ memcpy(&rport.gid, &mad_addr->gid, sizeof(rport.gid));
+ }
+
+ portid = &rport;
+ }
+
+ DEBUG("dest %s", portid2str(portid));
+
+ rpc.mgtclass = mad_get_field(mad, 0, IB_MAD_MGMTCLASS_F);
+
+ rpc.method = mad_get_field(mad, 0, IB_MAD_METHOD_F);
+ if (rpc.method == IB_MAD_METHOD_SET)
+ rpc.method = IB_MAD_METHOD_GET;
+ if (rpc.method != IB_MAD_METHOD_SEND)
+ rpc.method |= IB_MAD_RESPONSE;
+
+ rpc.attr.id = mad_get_field(mad, 0, IB_MAD_ATTRID_F);
+ rpc.attr.mod = mad_get_field(mad, 0, IB_MAD_ATTRMOD_F);
+ if (rpc.mgtclass == IB_SA_CLASS)
+ rpc.recsz = mad_get_field(mad, 0, IB_SA_ATTROFFS_F);
+ if (mad_is_vendor_range2(rpc.mgtclass))
+ rpc.oui = mad_get_field(mad, 0, IB_VEND2_OUI_F);
+
+ rpc.trid = mad_get_field64(mad, 0, IB_MAD_TRID_F);
+ rpc.rstatus = rstatus;
+
+ /* cleared by default: timeout, datasz, dataoffs, mkey, mask */
+
+ is_smi = rpc.mgtclass == IB_SMI_CLASS ||
+ rpc.mgtclass == IB_SMI_DIRECT_CLASS;
+
+ if (is_smi)
+ portid->qp = 0;
+ else if (!portid->qp)
+ portid->qp = 1;
+
+ if (!portid->qkey && portid->qp == 1)
+ portid->qkey = IB_DEFAULT_QP1_QKEY;
+
+ DEBUG
+ ("qp 0x%x class 0x%x method %d attr 0x%x mod 0x%x datasz %d off %d qkey %x",
+ portid->qp, rpc.mgtclass, rpc.method, rpc.attr.id, rpc.attr.mod,
+ rpc.datasz, rpc.dataoffs, portid->qkey);
+
+ if (mad_build_pkt(umad, &rpc, portid, 0, 0) < 0)
+ return -1;
+
+ if (ibdebug > 1)
+ xdump(stderr, "mad respond pkt\n", mad, IB_MAD_SIZE);
+
+ if (umad_send
+ (srcport->port_id, srcport->class_agents[rpc.mgtclass], umad,
+ IB_MAD_SIZE, mad_get_timeout(srcport, rpc.timeout), 0) < 0) {
+ DEBUG("send failed; %s", strerror(errno));
+ return -1;
+ }
+
+ return 0;
+}
+
+void *mad_receive(void *umad, int timeout)
+{
+ return mad_receive_via(umad, timeout, ibmp);
+}
+
+void *mad_receive_via(void *umad, int timeout, struct ibmad_port *srcport)
+{
+ void *mad = umad ? umad : umad_alloc(1, umad_size() + IB_MAD_SIZE);
+ int agent;
+ int length = IB_MAD_SIZE;
+
+ if ((agent = umad_recv(srcport->port_id, mad, &length,
+ mad_get_timeout(srcport, timeout))) < 0) {
+ if (!umad)
+ umad_free(mad);
+ DEBUG("recv failed: %s", strerror(errno));
+ return 0;
+ }
+
+ return mad;
+}
+
+void *mad_alloc(void)
+{
+ return umad_alloc(1, umad_size() + IB_MAD_SIZE);
+}
+
+void mad_free(void *umad)
+{
+ umad_free(umad);
+}
diff --git a/contrib/ofed/libibmad/smp.c b/contrib/ofed/libibmad/smp.c
new file mode 100644
index 0000000..c5471e9
--- /dev/null
+++ b/contrib/ofed/libibmad/smp.c
@@ -0,0 +1,150 @@
+/*
+ * Copyright (c) 2004-2009 Voltaire Inc. All rights reserved.
+ * Copyright (c) 2011 Mellanox Technologies LTD. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+#if HAVE_CONFIG_H
+# include <config.h>
+#endif /* HAVE_CONFIG_H */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include <infiniband/umad.h>
+#include <infiniband/mad.h>
+#include "mad_internal.h"
+
+#undef DEBUG
+#define DEBUG if (ibdebug) IBWARN
+
+void smp_mkey_set(struct ibmad_port *srcport, uint64_t mkey)
+{
+ srcport->smp_mkey = mkey;
+}
+
+uint64_t smp_mkey_get(const struct ibmad_port *srcport)
+{
+ return srcport->smp_mkey;
+}
+
+uint8_t *smp_set_status_via(void *data, ib_portid_t * portid, unsigned attrid,
+ unsigned mod, unsigned timeout, int *rstatus,
+ const struct ibmad_port *srcport)
+{
+ ib_rpc_t rpc = { 0 };
+ uint8_t *res;
+
+ DEBUG("attr 0x%x mod 0x%x route %s", attrid, mod, portid2str(portid));
+ if ((portid->lid <= 0) ||
+ (portid->drpath.drslid == 0xffff) ||
+ (portid->drpath.drdlid == 0xffff))
+ rpc.mgtclass = IB_SMI_DIRECT_CLASS; /* direct SMI */
+ else
+ rpc.mgtclass = IB_SMI_CLASS; /* Lid routed SMI */
+
+ rpc.method = IB_MAD_METHOD_SET;
+ rpc.attr.id = attrid;
+ rpc.attr.mod = mod;
+ rpc.timeout = timeout;
+ rpc.datasz = IB_SMP_DATA_SIZE;
+ rpc.dataoffs = IB_SMP_DATA_OFFS;
+ rpc.mkey = srcport->smp_mkey;
+
+ portid->sl = 0;
+ portid->qp = 0;
+
+ res = mad_rpc(srcport, &rpc, portid, data, data);
+ if (rstatus)
+ *rstatus = rpc.rstatus;
+ return res;
+}
+
+uint8_t *smp_set_via(void *data, ib_portid_t * portid, unsigned attrid,
+ unsigned mod, unsigned timeout,
+ const struct ibmad_port *srcport)
+{
+ return smp_set_status_via(data, portid, attrid, mod, timeout, NULL,
+ srcport);
+}
+
+uint8_t *smp_set(void *data, ib_portid_t * portid, unsigned attrid,
+ unsigned mod, unsigned timeout)
+{
+ return smp_set_via(data, portid, attrid, mod, timeout, ibmp);
+}
+
+uint8_t *smp_query_status_via(void *rcvbuf, ib_portid_t * portid,
+ unsigned attrid, unsigned mod, unsigned timeout,
+ int *rstatus, const struct ibmad_port * srcport)
+{
+ ib_rpc_t rpc = { 0 };
+ uint8_t *res;
+
+ DEBUG("attr 0x%x mod 0x%x route %s", attrid, mod, portid2str(portid));
+ rpc.method = IB_MAD_METHOD_GET;
+ rpc.attr.id = attrid;
+ rpc.attr.mod = mod;
+ rpc.timeout = timeout;
+ rpc.datasz = IB_SMP_DATA_SIZE;
+ rpc.dataoffs = IB_SMP_DATA_OFFS;
+ rpc.mkey = srcport->smp_mkey;
+
+ if ((portid->lid <= 0) ||
+ (portid->drpath.drslid == 0xffff) ||
+ (portid->drpath.drdlid == 0xffff))
+ rpc.mgtclass = IB_SMI_DIRECT_CLASS; /* direct SMI */
+ else
+ rpc.mgtclass = IB_SMI_CLASS; /* Lid routed SMI */
+
+ portid->sl = 0;
+ portid->qp = 0;
+
+ res = mad_rpc(srcport, &rpc, portid, rcvbuf, rcvbuf);
+ if (rstatus)
+ *rstatus = rpc.rstatus;
+ return res;
+}
+
+uint8_t *smp_query_via(void *rcvbuf, ib_portid_t * portid, unsigned attrid,
+ unsigned mod, unsigned timeout,
+ const struct ibmad_port * srcport)
+{
+ return smp_query_status_via(rcvbuf, portid, attrid, mod, timeout, NULL,
+ srcport);
+}
+
+uint8_t *smp_query(void *rcvbuf, ib_portid_t * portid, unsigned attrid,
+ unsigned mod, unsigned timeout)
+{
+ return smp_query_via(rcvbuf, portid, attrid, mod, timeout, ibmp);
+}
diff --git a/contrib/ofed/libibmad/vendor.c b/contrib/ofed/libibmad/vendor.c
new file mode 100644
index 0000000..20abf5c
--- /dev/null
+++ b/contrib/ofed/libibmad/vendor.c
@@ -0,0 +1,112 @@
+/*
+ * Copyright (c) 2004-2009 Voltaire Inc. All rights reserved.
+ * Copyright (c) 2011 Mellanox Technologies LTD. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+#if HAVE_CONFIG_H
+# include <config.h>
+#endif /* HAVE_CONFIG_H */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
+
+#include <infiniband/umad.h>
+#include <infiniband/mad.h>
+#include "mad_internal.h"
+
+#undef DEBUG
+#define DEBUG if (ibdebug) IBWARN
+
+static inline int response_expected(int method)
+{
+ return method == IB_MAD_METHOD_GET ||
+ method == IB_MAD_METHOD_SET || method == IB_MAD_METHOD_TRAP;
+}
+
+uint8_t *ib_vendor_call(void *data, ib_portid_t * portid,
+ ib_vendor_call_t * call)
+{
+ return ib_vendor_call_via(data, portid, call, ibmp);
+}
+
+uint8_t *ib_vendor_call_via(void *data, ib_portid_t * portid,
+ ib_vendor_call_t * call,
+ struct ibmad_port * srcport)
+{
+ ib_rpc_v1_t rpc = { 0 };
+ ib_rpc_t *rpcold = (ib_rpc_t *)(void *)&rpc;
+ int range1 = 0, resp_expected;
+ void *p_ret;
+
+ DEBUG("route %s data %p", portid2str(portid), data);
+ if (portid->lid <= 0)
+ return NULL; /* no direct SMI */
+
+ if (!(range1 = mad_is_vendor_range1(call->mgmt_class)) &&
+ !(mad_is_vendor_range2(call->mgmt_class)))
+ return NULL;
+
+ resp_expected = response_expected(call->method);
+
+ rpc.mgtclass = call->mgmt_class | IB_MAD_RPC_VERSION1;
+
+ rpc.method = call->method;
+ rpc.attr.id = call->attrid;
+ rpc.attr.mod = call->mod;
+ rpc.timeout = resp_expected ? call->timeout : 0;
+ rpc.datasz =
+ range1 ? IB_VENDOR_RANGE1_DATA_SIZE : IB_VENDOR_RANGE2_DATA_SIZE;
+ rpc.dataoffs =
+ range1 ? IB_VENDOR_RANGE1_DATA_OFFS : IB_VENDOR_RANGE2_DATA_OFFS;
+
+ if (!range1)
+ rpc.oui = call->oui;
+
+ DEBUG
+ ("class 0x%x method 0x%x attr 0x%x mod 0x%x datasz %d off %d res_ex %d",
+ rpc.mgtclass, rpc.method, rpc.attr.id, rpc.attr.mod, rpc.datasz,
+ rpc.dataoffs, resp_expected);
+
+ portid->qp = 1;
+ if (!portid->qkey)
+ portid->qkey = IB_DEFAULT_QP1_QKEY;
+
+ if (resp_expected) {
+ p_ret = mad_rpc_rmpp(srcport, rpcold, portid, 0, data); /* FIXME: no RMPP for now */
+ errno = rpc.error;
+ return p_ret;
+ }
+
+ return mad_send_via(rpcold, portid, 0, data, srcport) < 0 ? 0 : data; /* FIXME: no RMPP for now */
+}
diff --git a/contrib/ofed/libibnetdisc/Makefile b/contrib/ofed/libibnetdisc/Makefile
new file mode 100644
index 0000000..5bd622d
--- /dev/null
+++ b/contrib/ofed/libibnetdisc/Makefile
@@ -0,0 +1,38 @@
+# $FreeBSD$
+
+.include <src.opts.mk>
+
+.PATH: ${.CURDIR} ${.CURDIR}/man
+
+SHLIBDIR?= /usr/lib
+LIB_CXX= ibnetdisc
+SHLIB_MAJOR= 5
+MK_PROFILE= no
+
+SRCS= \
+chassis.c \
+g_hash_table.cpp \
+ibnetdisc.c \
+ibnetdisc_cache.c \
+query_smp.c
+
+MAN= \
+ibnd_debug.3 \
+ibnd_destroy_fabric.3 \
+ibnd_discover_fabric.3 \
+ibnd_find_node_dr.3 \
+ibnd_find_node_guid.3 \
+ibnd_iter_nodes.3 \
+ibnd_iter_nodes_type.3 \
+ibnd_show_progress.3
+
+LIBADD= osmcomp ibmad ibumad
+CFLAGS+= -DHAVE_CONFIG_H=1
+CFLAGS+= -I${.CURDIR}
+CFLAGS+= -I${SYSROOT:U${DESTDIR}}/${INCLUDEDIR}/infiniband
+.if ${COMPILER_FEATURES:Mc++11}
+CXXFLAGS+= -std=c++11
+.endif
+VERSION_MAP= ${.CURDIR}/libibnetdisc.map
+
+.include <bsd.lib.mk>
diff --git a/contrib/ofed/libibnetdisc/chassis.c b/contrib/ofed/libibnetdisc/chassis.c
new file mode 100644
index 0000000..5726f8e
--- /dev/null
+++ b/contrib/ofed/libibnetdisc/chassis.c
@@ -0,0 +1,1344 @@
+/*
+ * Copyright (c) 2004-2009 Voltaire Inc. All rights reserved.
+ * Copyright (c) 2007 Xsigo Systems Inc. All rights reserved.
+ * Copyright (c) 2008 Lawrence Livermore National Lab. All rights reserved.
+ * Copyright (c) 2010 HNR Consulting. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+/*========================================================*/
+/* FABRIC SCANNER SPECIFIC DATA */
+/*========================================================*/
+
+#if HAVE_CONFIG_H
+#include <config.h>
+#endif /* HAVE_CONFIG_H */
+
+#include <stdlib.h>
+#include <inttypes.h>
+
+#include <infiniband/mad.h>
+
+#include "internal.h"
+#include "chassis.h"
+
+static char *ChassisTypeStr[] =
+{ "", "ISR9288", "ISR9096", "ISR2012", "ISR2004", "ISR4700", "ISR4200" };
+static char *ChassisSlotTypeStr[] = { "", "Line", "Spine", "SRBD" };
+
+typedef struct chassis_scan {
+ ibnd_chassis_t *first_chassis;
+ ibnd_chassis_t *current_chassis;
+ ibnd_chassis_t *last_chassis;
+} chassis_scan_t;
+
+char *ibnd_get_chassis_type(ibnd_node_t * node)
+{
+ int chassis_type;
+
+ if (!node) {
+ IBND_DEBUG("node parameter NULL\n");
+ return NULL;
+ }
+
+ if (!node->chassis)
+ return NULL;
+
+ chassis_type = mad_get_field(node->info, 0, IB_NODE_VENDORID_F);
+
+ switch (chassis_type)
+ {
+ case VTR_VENDOR_ID: /* Voltaire chassis */
+ {
+ if (node->ch_type == UNRESOLVED_CT || node->ch_type > ISR4200_CT)
+ return NULL;
+ return ChassisTypeStr[node->ch_type];
+ }
+ case MLX_VENDOR_ID:
+ {
+ if (node->ch_type_str[0] == '\0')
+ return NULL;
+ return node->ch_type_str;
+ }
+ default:
+ {
+ break;
+ }
+ }
+ return NULL;
+}
+
+char *ibnd_get_chassis_slot_str(ibnd_node_t * node, char *str, size_t size)
+{
+ int vendor_id;
+
+ if (!node) {
+ IBND_DEBUG("node parameter NULL\n");
+ return NULL;
+ }
+
+ /* Currently, only if Voltaire or Mellanox chassis */
+ vendor_id = mad_get_field(node->info, 0,IB_NODE_VENDORID_F);
+
+ if ((vendor_id != VTR_VENDOR_ID) && (vendor_id != MLX_VENDOR_ID))
+ return NULL;
+ if (!node->chassis)
+ return NULL;
+ if (node->ch_slot == UNRESOLVED_CS || node->ch_slot > SRBD_CS)
+ return NULL;
+ if (!str)
+ return NULL;
+ snprintf(str, size, "%s %d Chip %d", ChassisSlotTypeStr[node->ch_slot],
+ node->ch_slotnum, node->ch_anafanum);
+ return str;
+}
+
+static ibnd_chassis_t *find_chassisnum(ibnd_fabric_t * fabric,
+ unsigned char chassisnum)
+{
+ ibnd_chassis_t *current;
+
+ for (current = fabric->chassis; current; current = current->next)
+ if (current->chassisnum == chassisnum)
+ return current;
+
+ return NULL;
+}
+
+static uint64_t topspin_chassisguid(uint64_t guid)
+{
+ /* Byte 3 in system image GUID is chassis type, and */
+ /* Byte 4 is location ID (slot) so just mask off byte 4 */
+ return guid & 0xffffffff00ffffffULL;
+}
+
+int ibnd_is_xsigo_guid(uint64_t guid)
+{
+ if ((guid & 0xffffff0000000000ULL) == 0x0013970000000000ULL)
+ return 1;
+ else
+ return 0;
+}
+
+static int is_xsigo_leafone(uint64_t guid)
+{
+ if ((guid & 0xffffffffff000000ULL) == 0x0013970102000000ULL)
+ return 1;
+ else
+ return 0;
+}
+
+int ibnd_is_xsigo_hca(uint64_t guid)
+{
+ /* NodeType 2 is HCA */
+ if ((guid & 0xffffffff00000000ULL) == 0x0013970200000000ULL)
+ return 1;
+ else
+ return 0;
+}
+
+int ibnd_is_xsigo_tca(uint64_t guid)
+{
+ /* NodeType 3 is TCA */
+ if ((guid & 0xffffffff00000000ULL) == 0x0013970300000000ULL)
+ return 1;
+ else
+ return 0;
+}
+
+static int is_xsigo_ca(uint64_t guid)
+{
+ if (ibnd_is_xsigo_hca(guid) || ibnd_is_xsigo_tca(guid))
+ return 1;
+ else
+ return 0;
+}
+
+static int is_xsigo_switch(uint64_t guid)
+{
+ if ((guid & 0xffffffff00000000ULL) == 0x0013970100000000ULL)
+ return 1;
+ else
+ return 0;
+}
+
+static uint64_t xsigo_chassisguid(ibnd_node_t * node)
+{
+ uint64_t sysimgguid =
+ mad_get_field64(node->info, 0, IB_NODE_SYSTEM_GUID_F);
+ uint64_t remote_sysimgguid;
+
+ if (!is_xsigo_ca(sysimgguid)) {
+ /* Byte 3 is NodeType and byte 4 is PortType */
+ /* If NodeType is 1 (switch), PortType is masked */
+ if (is_xsigo_switch(sysimgguid))
+ return sysimgguid & 0xffffffff00ffffffULL;
+ else
+ return sysimgguid;
+ } else {
+ if (!node->ports || !node->ports[1])
+ return 0;
+
+ /* Is there a peer port ? */
+ if (!node->ports[1]->remoteport)
+ return sysimgguid;
+
+ /* If peer port is Leaf 1, use its chassis GUID */
+ remote_sysimgguid =
+ mad_get_field64(node->ports[1]->remoteport->node->info, 0,
+ IB_NODE_SYSTEM_GUID_F);
+ if (is_xsigo_leafone(remote_sysimgguid))
+ return remote_sysimgguid & 0xffffffff00ffffffULL;
+ else
+ return sysimgguid;
+ }
+}
+
+static uint64_t get_chassisguid(ibnd_node_t * node)
+{
+ uint32_t vendid = mad_get_field(node->info, 0, IB_NODE_VENDORID_F);
+ uint64_t sysimgguid =
+ mad_get_field64(node->info, 0, IB_NODE_SYSTEM_GUID_F);
+
+ if (vendid == TS_VENDOR_ID || vendid == SS_VENDOR_ID)
+ return topspin_chassisguid(sysimgguid);
+ else if (vendid == XS_VENDOR_ID || ibnd_is_xsigo_guid(sysimgguid))
+ return xsigo_chassisguid(node);
+ else
+ return sysimgguid;
+}
+
+static ibnd_chassis_t *find_chassisguid(ibnd_fabric_t * fabric,
+ ibnd_node_t * node)
+{
+ ibnd_chassis_t *current;
+ uint64_t chguid;
+
+ chguid = get_chassisguid(node);
+ for (current = fabric->chassis; current; current = current->next)
+ if (current->chassisguid == chguid)
+ return current;
+
+ return NULL;
+}
+
+uint64_t ibnd_get_chassis_guid(ibnd_fabric_t * fabric, unsigned char chassisnum)
+{
+ ibnd_chassis_t *chassis;
+
+ if (!fabric) {
+ IBND_DEBUG("fabric parameter NULL\n");
+ return 0;
+ }
+
+ chassis = find_chassisnum(fabric, chassisnum);
+ if (chassis)
+ return chassis->chassisguid;
+ else
+ return 0;
+}
+
+static int is_router(ibnd_node_t * n)
+{
+ uint32_t devid = mad_get_field(n->info, 0, IB_NODE_DEVID_F);
+ return (devid == VTR_DEVID_IB_FC_ROUTER ||
+ devid == VTR_DEVID_IB_IP_ROUTER);
+}
+
+static int is_spine_9096(ibnd_node_t * n)
+{
+ uint32_t devid = mad_get_field(n->info, 0, IB_NODE_DEVID_F);
+ return (devid == VTR_DEVID_SFB4 || devid == VTR_DEVID_SFB4_DDR);
+}
+
+static int is_spine_9288(ibnd_node_t * n)
+{
+ uint32_t devid = mad_get_field(n->info, 0, IB_NODE_DEVID_F);
+ return (devid == VTR_DEVID_SFB12 || devid == VTR_DEVID_SFB12_DDR);
+}
+
+static int is_spine_2004(ibnd_node_t * n)
+{
+ uint32_t devid = mad_get_field(n->info, 0, IB_NODE_DEVID_F);
+ return (devid == VTR_DEVID_SFB2004);
+}
+
+static int is_spine_2012(ibnd_node_t * n)
+{
+ uint32_t devid = mad_get_field(n->info, 0, IB_NODE_DEVID_F);
+ return (devid == VTR_DEVID_SFB2012);
+}
+
+static int is_spine_4700(ibnd_node_t * n)
+{
+ uint32_t devid = mad_get_field(n->info, 0, IB_NODE_DEVID_F);
+ return (devid == VTR_DEVID_SFB4700);
+}
+
+static int is_spine_4700x2(ibnd_node_t * n)
+{
+ uint32_t devid = mad_get_field(n->info, 0, IB_NODE_DEVID_F);
+ return (devid == VTR_DEVID_SFB4700X2);
+}
+
+static int is_spine_4200(ibnd_node_t * n)
+{
+ uint32_t devid = mad_get_field(n->info, 0, IB_NODE_DEVID_F);
+ return (devid == VTR_DEVID_SFB4200);
+}
+
+static int is_spine(ibnd_node_t * n)
+{
+ return (is_spine_9096(n) || is_spine_9288(n) ||
+ is_spine_2004(n) || is_spine_2012(n) ||
+ is_spine_4700(n) || is_spine_4700x2(n) ||
+ is_spine_4200(n));
+}
+
+static int is_line_24(ibnd_node_t * n)
+{
+ uint32_t devid = mad_get_field(n->info, 0, IB_NODE_DEVID_F);
+ return (devid == VTR_DEVID_SLB24 ||
+ devid == VTR_DEVID_SLB24_DDR || devid == VTR_DEVID_SRB2004);
+}
+
+static int is_line_8(ibnd_node_t * n)
+{
+ uint32_t devid = mad_get_field(n->info, 0, IB_NODE_DEVID_F);
+ return (devid == VTR_DEVID_SLB8);
+}
+
+static int is_line_2024(ibnd_node_t * n)
+{
+ uint32_t devid = mad_get_field(n->info, 0, IB_NODE_DEVID_F);
+ return (devid == VTR_DEVID_SLB2024);
+}
+
+static int is_line_4700(ibnd_node_t * n)
+{
+ uint32_t devid = mad_get_field(n->info, 0, IB_NODE_DEVID_F);
+ return (devid == VTR_DEVID_SLB4018);
+}
+
+static int is_line(ibnd_node_t * n)
+{
+ return (is_line_24(n) || is_line_8(n) ||
+ is_line_2024(n) || is_line_4700(n));
+}
+
+int is_chassis_switch(ibnd_node_t * n)
+{
+ return (is_spine(n) || is_line(n));
+}
+
+/* these structs help find Line (Anafa) slot number while using spine portnum */
+char line_slot_2_sfb4[37] = {
+ 0,
+ 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3,
+ 4, 4, 4, 4, 4, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
+};
+char anafa_line_slot_2_sfb4[37] = {
+ 0,
+ 1, 1, 1, 2, 2, 2, 1, 1, 1, 2, 2, 2, 1, 1, 1, 2, 2, 2,
+ 1, 1, 1, 2, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
+};
+
+char line_slot_2_sfb12[37] = {
+ 0,
+ 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9,
+ 10, 10, 11, 11, 12, 12, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
+};
+char anafa_line_slot_2_sfb12[37] = {
+ 0,
+ 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2,
+ 1, 2, 1, 2, 1, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
+};
+
+/* LB slot = table[spine port] */
+char line_slot_2_sfb18[37] = {
+ 0,
+ 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9,
+ 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16, 17, 17, 18, 18};
+/* LB asic num = table[spine port] */
+char anafa_line_slot_2_sfb18[37] = {
+ 0,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
+};
+
+/* LB slot = table[spine port] */
+char line_slot_2_sfb18x2[37] = {
+ 0,
+ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
+/* LB asic num = table[spine port] */
+char anafa_line_slot_2_sfb18x2[37] = {
+ 0,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
+};
+
+/* LB slot = table[spine port] */
+char line_slot_2_sfb4200[37] = {
+ 0,
+ 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5,
+ 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 8, 9, 9, 9, 9};
+/* LB asic num = table[spine port] */
+char anafa_line_slot_2_sfb4200[37] = {
+ 0,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
+};
+
+/* IPR FCR modules connectivity while using sFB4 port as reference */
+char ipr_slot_2_sfb4_port[37] = {
+ 0,
+ 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1,
+ 3, 2, 1, 3, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
+};
+
+/* these structs help find Spine (Anafa) slot number while using spine portnum */
+char spine12_slot_2_slb[37] = {
+ 0,
+ 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
+};
+char anafa_spine12_slot_2_slb[37] = {
+ 0,
+ 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
+};
+
+char spine4_slot_2_slb[37] = {
+ 0,
+ 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
+};
+char anafa_spine4_slot_2_slb[37] = {
+ 0,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
+};
+
+/* FB slot = table[line port] */
+char spine18_slot_2_slb[37] = {
+ 0,
+ 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
+};
+/* FB asic = table[line port] */
+char anafa_spine18_slot_2_slb[37] = {
+ 0,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
+};
+char anafa_spine18x2_slot_2_slb[37] = {
+ 0,
+ 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
+};
+
+/* FB slot = table[line port] */
+char sfb4200_slot_2_slb[37] = {
+ 0,
+ 1, 1, 1, 1, 0, 0, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
+};
+/* FB asic = table[line port] */
+char anafa_sfb4200_slot_2_slb[37] = {
+ 0,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
+};
+
+/* reference { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24 }; */
+
+static int get_sfb_slot(ibnd_node_t * n, ibnd_port_t * lineport)
+{
+ n->ch_slot = SPINE_CS;
+ if (is_spine_9096(n)) {
+ n->ch_type = ISR9096_CT;
+ n->ch_slotnum = spine4_slot_2_slb[lineport->portnum];
+ n->ch_anafanum = anafa_spine4_slot_2_slb[lineport->portnum];
+ } else if (is_spine_9288(n)) {
+ n->ch_type = ISR9288_CT;
+ n->ch_slotnum = spine12_slot_2_slb[lineport->portnum];
+ n->ch_anafanum = anafa_spine12_slot_2_slb[lineport->portnum];
+ } else if (is_spine_2012(n)) {
+ n->ch_type = ISR2012_CT;
+ n->ch_slotnum = spine12_slot_2_slb[lineport->portnum];
+ n->ch_anafanum = anafa_spine12_slot_2_slb[lineport->portnum];
+ } else if (is_spine_2004(n)) {
+ n->ch_type = ISR2004_CT;
+ n->ch_slotnum = spine4_slot_2_slb[lineport->portnum];
+ n->ch_anafanum = anafa_spine4_slot_2_slb[lineport->portnum];
+ } else if (is_spine_4700(n)) {
+ n->ch_type = ISR4700_CT;
+ n->ch_slotnum = spine18_slot_2_slb[lineport->portnum];
+ n->ch_anafanum = anafa_spine18_slot_2_slb[lineport->portnum];
+ } else if (is_spine_4700x2(n)) {
+ n->ch_type = ISR4700_CT;
+ n->ch_slotnum = spine18_slot_2_slb[lineport->portnum];
+ n->ch_anafanum = anafa_spine18x2_slot_2_slb[lineport->portnum];
+ } else if (is_spine_4200(n)) {
+ n->ch_type = ISR4200_CT;
+ n->ch_slotnum = sfb4200_slot_2_slb[lineport->portnum];
+ n->ch_anafanum = anafa_sfb4200_slot_2_slb[lineport->portnum];
+ } else {
+ IBND_ERROR("Unexpected node found: guid 0x%016" PRIx64 "\n",
+ n->guid);
+ }
+ return 0;
+}
+
+static int get_router_slot(ibnd_node_t * n, ibnd_port_t * spineport)
+{
+ uint64_t guessnum = 0;
+
+ n->ch_found = 1;
+
+ n->ch_slot = SRBD_CS;
+ if (is_spine_9096(spineport->node)) {
+ n->ch_type = ISR9096_CT;
+ n->ch_slotnum = line_slot_2_sfb4[spineport->portnum];
+ n->ch_anafanum = ipr_slot_2_sfb4_port[spineport->portnum];
+ } else if (is_spine_9288(spineport->node)) {
+ n->ch_type = ISR9288_CT;
+ n->ch_slotnum = line_slot_2_sfb12[spineport->portnum];
+ /* this is a smart guess based on nodeguids order on sFB-12 module */
+ guessnum = spineport->node->guid % 4;
+ /* module 1 <--> remote anafa 3 */
+ /* module 2 <--> remote anafa 2 */
+ /* module 3 <--> remote anafa 1 */
+ n->ch_anafanum = (guessnum == 3 ? 1 : (guessnum == 1 ? 3 : 2));
+ } else if (is_spine_2012(spineport->node)) {
+ n->ch_type = ISR2012_CT;
+ n->ch_slotnum = line_slot_2_sfb12[spineport->portnum];
+ /* this is a smart guess based on nodeguids order on sFB-12 module */
+ guessnum = spineport->node->guid % 4;
+ // module 1 <--> remote anafa 3
+ // module 2 <--> remote anafa 2
+ // module 3 <--> remote anafa 1
+ n->ch_anafanum = (guessnum == 3 ? 1 : (guessnum == 1 ? 3 : 2));
+ } else if (is_spine_2004(spineport->node)) {
+ n->ch_type = ISR2004_CT;
+ n->ch_slotnum = line_slot_2_sfb4[spineport->portnum];
+ n->ch_anafanum = ipr_slot_2_sfb4_port[spineport->portnum];
+ } else {
+ IBND_ERROR("Unexpected node found: guid 0x%016" PRIx64 "\n",
+ spineport->node->guid);
+ }
+ return 0;
+}
+
+static int get_slb_slot(ibnd_node_t * n, ibnd_port_t * spineport)
+{
+ n->ch_slot = LINE_CS;
+ if (is_spine_9096(spineport->node)) {
+ n->ch_type = ISR9096_CT;
+ n->ch_slotnum = line_slot_2_sfb4[spineport->portnum];
+ n->ch_anafanum = anafa_line_slot_2_sfb4[spineport->portnum];
+ } else if (is_spine_9288(spineport->node)) {
+ n->ch_type = ISR9288_CT;
+ n->ch_slotnum = line_slot_2_sfb12[spineport->portnum];
+ n->ch_anafanum = anafa_line_slot_2_sfb12[spineport->portnum];
+ } else if (is_spine_2012(spineport->node)) {
+ n->ch_type = ISR2012_CT;
+ n->ch_slotnum = line_slot_2_sfb12[spineport->portnum];
+ n->ch_anafanum = anafa_line_slot_2_sfb12[spineport->portnum];
+ } else if (is_spine_2004(spineport->node)) {
+ n->ch_type = ISR2004_CT;
+ n->ch_slotnum = line_slot_2_sfb4[spineport->portnum];
+ n->ch_anafanum = anafa_line_slot_2_sfb4[spineport->portnum];
+ } else if (is_spine_4700(spineport->node)) {
+ n->ch_type = ISR4700_CT;
+ n->ch_slotnum = line_slot_2_sfb18[spineport->portnum];
+ n->ch_anafanum = anafa_line_slot_2_sfb18[spineport->portnum];
+ } else if (is_spine_4700x2(spineport->node)) {
+ n->ch_type = ISR4700_CT;
+ n->ch_slotnum = line_slot_2_sfb18x2[spineport->portnum];
+ n->ch_anafanum = anafa_line_slot_2_sfb18x2[spineport->portnum];
+ } else if (is_spine_4200(spineport->node)) {
+ n->ch_type = ISR4200_CT;
+ n->ch_slotnum = line_slot_2_sfb4200[spineport->portnum];
+ n->ch_anafanum = anafa_line_slot_2_sfb4200[spineport->portnum];
+ } else {
+ IBND_ERROR("Unexpected node found: guid 0x%016" PRIx64 "\n",
+ spineport->node->guid);
+ }
+ return 0;
+}
+
+
+/*
+ This function called for every Mellanox node in fabric
+*/
+static int fill_mellanox_chassis_record(ibnd_node_t * node)
+{
+ int p = 0;
+ ibnd_port_t *port;
+
+ char node_desc[IB_SMP_DATA_SIZE];
+ char *system_name;
+ char *system_type;
+ char *system_slot_name;
+ char *node_index;
+ char *iter;
+ int dev_id;
+
+ /*
+ The node description has the following format:
+
+ 'MF0;<system name>:<system type>/<system slot name>[:board type]/U<node index>'
+
+ - System slot name in our systems can be L[01-36] , S[01-18]
+ - Node index is always 1 (we don.t have boards with multiple IS4 chips).
+ - System name is taken from the currently configured host name.
+ -The board type is optional and we don.t set it currently - A leaf or spine slot can currently hold a single type of board.
+ */
+
+ memcpy(node_desc, node->nodedesc, IB_SMP_DATA_SIZE);
+
+ IBND_DEBUG("fill_mellanox_chassis_record: node_desc:%s \n",node_desc);
+
+ if (node->ch_found) /* somehow this node has already been passed */
+ return 0;
+
+ /* All mellanox IS4 switches have the same vendor id*/
+ dev_id = mad_get_field(node->info, 0,IB_NODE_DEVID_F);
+ if (dev_id != MLX_DEVID_IS4)
+ return 0;
+
+ if((node_desc[0] != 'M') ||
+ (node_desc[1] != 'F') ||
+ (node_desc[2] != '0') ||
+ (node_desc[3] != ';')) {
+ IBND_DEBUG("fill_mellanox_chassis_record: Unsupported node description format:%s \n",node_desc);
+ return 0;
+ }
+
+ /* parse system name*/
+ system_name = &node_desc[4];
+ for (iter = system_name ; (*iter != ':') && (*iter != '\0') ; iter++);
+ if(*iter == '\0'){
+ IBND_DEBUG("fill_mellanox_chassis_record: Unsupported node description format:%s - (get system_name failed) \n",node_desc);
+ return 0;
+ }
+ *iter = '\0';
+ iter++;
+ /* parse system type*/
+ system_type = iter;
+ for ( ; (*iter != '/') && (*iter != '\0') ; iter++);
+ if(*iter == '\0'){
+ IBND_DEBUG("fill_mellanox_chassis_record: Unsupported node description format:%s - (get system_type failed) \n",node_desc);
+ return 0;
+ }
+ *iter = '\0';
+ iter++;
+ /* parse system slot name*/
+ system_slot_name = iter;
+ for ( ; (*iter != '/') && (*iter != ':') && (*iter != '\0') ; iter++);
+ if(*iter == '\0'){
+ IBND_DEBUG("fill_mellanox_chassis_record: Unsupported node description format:%s - (get system_slot_name failed) \n",node_desc);
+ return 0;
+ }
+ if(*iter == ':'){
+ *iter = '\0';
+ iter++;
+ for ( ; (*iter != '/') && (*iter != '\0') ; iter++);
+ if(*iter == '\0'){
+ IBND_DEBUG("fill_mellanox_chassis_record: Unsupported node description format:%s - (get board type failed) \n",node_desc);
+ return 0;
+ }
+ }
+ *iter = '\0';
+ iter++;
+ node_index = iter;
+ if(node_index[0] != 'U'){
+ IBND_DEBUG("fill_mellanox_chassis_record: Unsupported node description format:%s - (get node index) \n",node_desc);
+ return 0;
+ }
+
+ /* set Chip number (node index) */
+ node->ch_anafanum = (unsigned char) atoi(&node_index[1]);
+ if(node->ch_anafanum != 1){
+ IBND_DEBUG("Unexpected Chip number:%d \n",node->ch_anafanum);
+ }
+
+
+ /* set Line Spine numbers */
+ if(system_slot_name[0] == 'L')
+ node->ch_slot = LINE_CS;
+ else if(system_slot_name[0] == 'S')
+ node->ch_slot = SPINE_CS;
+ else{
+ IBND_DEBUG("fill_mellanox_chassis_record: Unsupported system_slot_name:%s \n",system_slot_name);
+ return 0;
+ }
+
+ /* The switch will be displayed under Line or Spine and not under Chassis switches */
+ node->ch_found = 1;
+
+ node->ch_slotnum = (unsigned char) atoi(&system_slot_name[1]);
+ if((node->ch_slot == LINE_CS && (node->ch_slotnum > (LINES_MAX_NUM + 1))) ||
+ (node->ch_slot == SPINE_CS && (node->ch_slotnum > (SPINES_MAX_NUM + 1)))){
+ IBND_ERROR("fill_mellanox_chassis_record: invalid slot number:%d \n",node->ch_slotnum);
+ node->ch_slotnum = 0;
+ return 0;
+ }
+
+ /*set ch_type_str*/
+ strncpy(node->ch_type_str , system_type, sizeof(node->ch_type_str)-1);
+
+ /* Line ports 1-18 are mapped to external ports 1-18*/
+ if(node->ch_slot == LINE_CS)
+ {
+ for (p = 1; p <= node->numports && p <= 18 ; p++) {
+ port = node->ports[p];
+ if (!port)
+ continue;
+ port->ext_portnum = p;
+ }
+ }
+
+ return 0;
+}
+
+static int insert_mellanox_line_and_spine(ibnd_node_t * node, ibnd_chassis_t * chassis)
+{
+ if (node->ch_slot == LINE_CS){
+
+ if (chassis->linenode[node->ch_slotnum])
+ return 0; /* already filled slot */
+
+ chassis->linenode[node->ch_slotnum] = node;
+ }
+ else if (node->ch_slot == SPINE_CS){
+
+ if (chassis->spinenode[node->ch_slotnum])
+ return 0; /* already filled slot */
+
+ chassis->spinenode[node->ch_slotnum] = node;
+ }
+ else
+ return 0;
+
+ node->chassis = chassis;
+
+ return 0;
+}
+
+
+/* forward declare this */
+static void voltaire_portmap(ibnd_port_t * port);
+/*
+ This function called for every Voltaire node in fabric
+ It could be optimized so, but time overhead is very small
+ and its only diag.util
+*/
+static int fill_voltaire_chassis_record(ibnd_node_t * node)
+{
+ int p = 0;
+ ibnd_port_t *port;
+ ibnd_node_t *remnode = 0;
+
+ if (node->ch_found) /* somehow this node has already been passed */
+ return 0;
+ node->ch_found = 1;
+
+ /* node is router only in case of using unique lid */
+ /* (which is lid of chassis router port) */
+ /* in such case node->ports is actually a requested port... */
+ if (is_router(node))
+ /* find the remote node */
+ for (p = 1; p <= node->numports; p++) {
+ port = node->ports[p];
+ if (port && is_spine(port->remoteport->node))
+ get_router_slot(node, port->remoteport);
+ }
+ else if (is_spine(node)) {
+ int is_4700x2 = is_spine_4700x2(node);
+
+ for (p = 1; p <= node->numports; p++) {
+ port = node->ports[p];
+ if (!port || !port->remoteport)
+ continue;
+
+ /*
+ * Skip ISR4700 double density fabric boards ports 19-36
+ * as they are chassis external ports
+ */
+ if (is_4700x2 && (port->portnum > 18))
+ continue;
+
+ remnode = port->remoteport->node;
+ if (remnode->type != IB_NODE_SWITCH) {
+ if (!remnode->ch_found)
+ get_router_slot(remnode, port);
+ continue;
+ }
+ if (!node->ch_type)
+ /* we assume here that remoteport belongs to line */
+ get_sfb_slot(node, port->remoteport);
+
+ /* we could break here, but need to find if more routers connected */
+ }
+
+ } else if (is_line(node)) {
+ int is_4700_line = is_line_4700(node);
+
+ for (p = 1; p <= node->numports; p++) {
+ port = node->ports[p];
+ if (!port || !port->remoteport)
+ continue;
+
+ if ((is_4700_line && (port->portnum > 18)) ||
+ (!is_4700_line && (port->portnum > 12)))
+ continue;
+
+ /* we assume here that remoteport belongs to spine */
+ get_slb_slot(node, port->remoteport);
+ break;
+ }
+ }
+
+ /* for each port of this node, map external ports */
+ for (p = 1; p <= node->numports; p++) {
+ port = node->ports[p];
+ if (!port)
+ continue;
+ voltaire_portmap(port);
+ }
+
+ return 0;
+}
+
+static int get_line_index(ibnd_node_t * node)
+{
+ int retval;
+
+ if (is_line_4700(node))
+ retval = node->ch_slotnum;
+ else
+ retval = 3 * (node->ch_slotnum - 1) + node->ch_anafanum;
+
+ if (retval > LINES_MAX_NUM || retval < 1) {
+ printf("%s: retval = %d\n", __FUNCTION__, retval);
+ IBND_ERROR("Internal error\n");
+ return -1;
+ }
+ return retval;
+}
+
+static int get_spine_index(ibnd_node_t * node)
+{
+ int retval;
+
+ if (is_spine_9288(node) || is_spine_2012(node))
+ retval = 3 * (node->ch_slotnum - 1) + node->ch_anafanum;
+ else if (is_spine_4700(node) || is_spine_4700x2(node))
+ retval = 2 * (node->ch_slotnum - 1) + node->ch_anafanum;
+ else
+ retval = node->ch_slotnum;
+
+ if (retval > SPINES_MAX_NUM || retval < 1) {
+ IBND_ERROR("Internal error\n");
+ return -1;
+ }
+ return retval;
+}
+
+static int insert_line_router(ibnd_node_t * node, ibnd_chassis_t * chassis)
+{
+ int i = get_line_index(node);
+
+ if (i < 0)
+ return i;
+
+ if (chassis->linenode[i])
+ return 0; /* already filled slot */
+
+ chassis->linenode[i] = node;
+ node->chassis = chassis;
+ return 0;
+}
+
+static int insert_spine(ibnd_node_t * node, ibnd_chassis_t * chassis)
+{
+ int i = get_spine_index(node);
+
+ if (i < 0)
+ return i;
+
+ if (chassis->spinenode[i])
+ return 0; /* already filled slot */
+
+ chassis->spinenode[i] = node;
+ node->chassis = chassis;
+ return 0;
+}
+
+static int pass_on_lines_catch_spines(ibnd_chassis_t * chassis)
+{
+ ibnd_node_t *node, *remnode;
+ ibnd_port_t *port;
+ int i, p;
+
+ for (i = 1; i <= LINES_MAX_NUM; i++) {
+ int is_4700_line;
+
+ node = chassis->linenode[i];
+
+ if (!(node && is_line(node)))
+ continue; /* empty slot or router */
+
+ is_4700_line = is_line_4700(node);
+
+ for (p = 1; p <= node->numports; p++) {
+
+ port = node->ports[p];
+ if (!port || !port->remoteport)
+ continue;
+
+ if ((is_4700_line && (port->portnum > 18)) ||
+ (!is_4700_line && (port->portnum > 12)))
+ continue;
+
+ remnode = port->remoteport->node;
+
+ if (!remnode->ch_found)
+ continue; /* some error - spine not initialized ? FIXME */
+ if (insert_spine(remnode, chassis))
+ return -1;
+ }
+ }
+ return 0;
+}
+
+static int pass_on_spines_catch_lines(ibnd_chassis_t * chassis)
+{
+ ibnd_node_t *node, *remnode;
+ ibnd_port_t *port;
+ int i, p;
+
+ for (i = 1; i <= SPINES_MAX_NUM; i++) {
+ int is_4700x2;
+
+ node = chassis->spinenode[i];
+ if (!node)
+ continue; /* empty slot */
+
+ is_4700x2 = is_spine_4700x2(node);
+
+ for (p = 1; p <= node->numports; p++) {
+ port = node->ports[p];
+ if (!port || !port->remoteport)
+ continue;
+
+ /*
+ * ISR4700 double density fabric board ports 19-36 are
+ * chassis external ports, so skip them
+ */
+ if (is_4700x2 && (port->portnum > 18))
+ continue;
+
+ remnode = port->remoteport->node;
+
+ if (!remnode->ch_found)
+ continue; /* some error - line/router not initialized ? FIXME */
+
+ if (insert_line_router(remnode, chassis))
+ return -1;
+ }
+ }
+ return 0;
+}
+
+/*
+ Stupid interpolation algorithm...
+ But nothing to do - have to be compliant with VoltaireSM/NMS
+*/
+static void pass_on_spines_interpolate_chguid(ibnd_chassis_t * chassis)
+{
+ ibnd_node_t *node;
+ int i;
+
+ for (i = 1; i <= SPINES_MAX_NUM; i++) {
+ node = chassis->spinenode[i];
+ if (!node)
+ continue; /* skip the empty slots */
+
+ /* take first guid minus one to be consistent with SM */
+ chassis->chassisguid = node->guid - 1;
+ break;
+ }
+}
+
+/*
+ This function fills chassis structure with all nodes
+ in that chassis
+ chassis structure = structure of one standalone chassis
+*/
+static int build_chassis(ibnd_node_t * node, ibnd_chassis_t * chassis)
+{
+ int p = 0;
+ ibnd_node_t *remnode = 0;
+ ibnd_port_t *port = 0;
+
+ /* we get here with node = chassis_spine */
+ if (insert_spine(node, chassis))
+ return -1;
+
+ /* loop: pass on all ports of node */
+ for (p = 1; p <= node->numports; p++) {
+
+ port = node->ports[p];
+ if (!port || !port->remoteport)
+ continue;
+
+ /*
+ * ISR4700 double density fabric board ports 19-36 are
+ * chassis external ports, so skip them
+ */
+ if (is_spine_4700x2(node) && (port->portnum > 18))
+ continue;
+
+ remnode = port->remoteport->node;
+
+ if (!remnode->ch_found)
+ continue; /* some error - line or router not initialized ? FIXME */
+
+ insert_line_router(remnode, chassis);
+ }
+
+ if (pass_on_lines_catch_spines(chassis))
+ return -1;
+ /* this pass needed for to catch routers, since routers connected only */
+ /* to spines in slot 1 or 4 and we could miss them first time */
+ if (pass_on_spines_catch_lines(chassis))
+ return -1;
+
+ /* additional 2 passes needed for to overcome a problem of pure "in-chassis" */
+ /* connectivity - extra pass to ensure that all related chips/modules */
+ /* inserted into the chassis */
+ if (pass_on_lines_catch_spines(chassis))
+ return -1;
+ if (pass_on_spines_catch_lines(chassis))
+ return -1;
+ pass_on_spines_interpolate_chguid(chassis);
+
+ return 0;
+}
+
+/*========================================================*/
+/* INTERNAL TO EXTERNAL PORT MAPPING */
+/*========================================================*/
+
+/*
+Description : On ISR9288/9096 external ports indexing
+ is not matching the internal ( anafa ) port
+ indexes. Use this MAP to translate the data you get from
+ the OpenIB diagnostics (smpquery, ibroute, ibtracert, etc.)
+
+Module : sLB-24
+ anafa 1 anafa 2
+ext port | 13 14 15 16 17 18 | 19 20 21 22 23 24
+int port | 22 23 24 18 17 16 | 22 23 24 18 17 16
+ext port | 1 2 3 4 5 6 | 7 8 9 10 11 12
+int port | 19 20 21 15 14 13 | 19 20 21 15 14 13
+------------------------------------------------
+
+Module : sLB-8
+ anafa 1 anafa 2
+ext port | 13 14 15 16 17 18 | 19 20 21 22 23 24
+int port | 24 23 22 18 17 16 | 24 23 22 18 17 16
+ext port | 1 2 3 4 5 6 | 7 8 9 10 11 12
+int port | 21 20 19 15 14 13 | 21 20 19 15 14 13
+
+----------->
+ anafa 1 anafa 2
+ext port | - - 5 - - 6 | - - 7 - - 8
+int port | 24 23 22 18 17 16 | 24 23 22 18 17 16
+ext port | - - 1 - - 2 | - - 3 - - 4
+int port | 21 20 19 15 14 13 | 21 20 19 15 14 13
+------------------------------------------------
+
+Module : sLB-2024
+
+ext port | 13 14 15 16 17 18 19 20 21 22 23 24
+A1 int port| 13 14 15 16 17 18 19 20 21 22 23 24
+ext port | 1 2 3 4 5 6 7 8 9 10 11 12
+A2 int port| 13 14 15 16 17 18 19 20 21 22 23 24
+---------------------------------------------------
+
+Module : sLB-4018
+
+int port | 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
+ext port | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
+---------------------------------------------------
+
+Module : sFB-4700X2
+
+ 12X port -> 3 x 4X ports:
+
+A1 int port | 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
+ ext port | 7 7 7 8 8 8 9 9 9 10 10 10 11 11 11 12 12 12
+A2 int port | 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
+ ext port | 1 1 1 2 2 2 3 3 3 4 4 4 5 5 5 6 6 6
+
+*/
+
+int int2ext_map_slb24[2][25] = {
+ {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6, 5, 4, 18, 17, 16, 1, 2, 3,
+ 13, 14, 15},
+ {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 12, 11, 10, 24, 23, 22, 7, 8, 9,
+ 19, 20, 21}
+};
+
+int int2ext_map_slb8[2][25] = {
+ {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 2, 2, 6, 6, 6, 1, 1, 1, 5, 5,
+ 5},
+ {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 4, 4, 8, 8, 8, 3, 3, 3, 7, 7,
+ 7}
+};
+
+int int2ext_map_slb2024[2][25] = {
+ {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 13, 14, 15, 16, 17, 18, 19, 20,
+ 21, 22, 23, 24},
+ {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10,
+ 11, 12}
+};
+
+int int2ext_map_slb4018[37] = {
+ 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18
+};
+
+int int2ext_map_sfb4700x2[2][37] = {
+ {0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 7, 7, 7, 8, 8, 8, 9, 9, 9, 10, 10, 10, 11, 11, 11, 12, 12, 12},
+ {0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6}
+};
+
+/* reference { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24 }; */
+
+/* map internal ports to external ports if appropriate */
+static void voltaire_portmap(ibnd_port_t * port)
+{
+ int portnum = port->portnum;
+ int chipnum = 0;
+ ibnd_node_t *node = port->node;
+ int is_4700_line = is_line_4700(node);
+ int is_4700x2_spine = is_spine_4700x2(node);
+
+ if (!node->ch_found || (!is_line(node) && !is_4700x2_spine)) {
+ port->ext_portnum = 0;
+ return;
+ }
+
+ if (((is_4700_line || is_4700x2_spine) &&
+ (portnum < 19 || portnum > 36)) ||
+ ((!is_4700_line && !is_4700x2_spine) &&
+ (portnum < 13 || portnum > 24))) {
+ port->ext_portnum = 0;
+ return;
+ }
+
+ if (port->node->ch_anafanum < 1 || port->node->ch_anafanum > 2) {
+ port->ext_portnum = 0;
+ return;
+ }
+
+ chipnum = port->node->ch_anafanum - 1;
+
+ if (is_line_24(node))
+ port->ext_portnum = int2ext_map_slb24[chipnum][portnum];
+ else if (is_line_2024(node))
+ port->ext_portnum = int2ext_map_slb2024[chipnum][portnum];
+ /* sLB-4018: Only one asic per LB */
+ else if (is_4700_line)
+ port->ext_portnum = int2ext_map_slb4018[portnum];
+ /* sFB-4700X2 4X port */
+ else if (is_4700x2_spine)
+ port->ext_portnum = int2ext_map_sfb4700x2[chipnum][portnum];
+ else
+ port->ext_portnum = int2ext_map_slb8[chipnum][portnum];
+}
+
+static int add_chassis(chassis_scan_t * chassis_scan)
+{
+ if (!(chassis_scan->current_chassis =
+ calloc(1, sizeof(ibnd_chassis_t)))) {
+ IBND_ERROR("OOM: failed to allocate chassis object\n");
+ return -1;
+ }
+
+ if (chassis_scan->first_chassis == NULL) {
+ chassis_scan->first_chassis = chassis_scan->current_chassis;
+ chassis_scan->last_chassis = chassis_scan->current_chassis;
+ } else {
+ chassis_scan->last_chassis->next =
+ chassis_scan->current_chassis;
+ chassis_scan->last_chassis = chassis_scan->current_chassis;
+ }
+ return 0;
+}
+
+static void add_node_to_chassis(ibnd_chassis_t * chassis, ibnd_node_t * node)
+{
+ node->chassis = chassis;
+ node->next_chassis_node = chassis->nodes;
+ chassis->nodes = node;
+}
+
+/*
+ Main grouping function
+ Algorithm:
+ 1. pass on every Voltaire node
+ 2. catch spine chip for every Voltaire node
+ 2.1 build/interpolate chassis around this chip
+ 2.2 go to 1.
+ 3. pass on non Voltaire nodes (SystemImageGUID based grouping)
+ 4. now group non Voltaire nodes by SystemImageGUID
+ Returns:
+ 0 on success, -1 on failure
+*/
+int group_nodes(ibnd_fabric_t * fabric)
+{
+ ibnd_node_t *node;
+ int chassisnum = 0;
+ ibnd_chassis_t *chassis;
+ ibnd_chassis_t *ch, *ch_next;
+ chassis_scan_t chassis_scan;
+ int vendor_id;
+
+ chassis_scan.first_chassis = NULL;
+ chassis_scan.current_chassis = NULL;
+ chassis_scan.last_chassis = NULL;
+
+ /* first pass on switches and build for every Voltaire node */
+ /* an appropriate chassis record (slotnum and position) */
+ /* according to internal connectivity */
+ /* not very efficient but clear code so... */
+ for (node = fabric->switches; node; node = node->type_next) {
+
+ vendor_id = mad_get_field(node->info, 0,IB_NODE_VENDORID_F);
+
+ if (vendor_id == VTR_VENDOR_ID
+ && fill_voltaire_chassis_record(node))
+ goto cleanup;
+ else if (vendor_id == MLX_VENDOR_ID
+ && fill_mellanox_chassis_record(node))
+ goto cleanup;
+
+ }
+
+ /* separate every Voltaire chassis from each other and build linked list of them */
+ /* algorithm: catch spine and find all surrounding nodes */
+ for (node = fabric->switches; node; node = node->type_next) {
+ if (mad_get_field(node->info, 0,
+ IB_NODE_VENDORID_F) != VTR_VENDOR_ID)
+ continue;
+ if (!node->ch_found
+ || (node->chassis && node->chassis->chassisnum)
+ || !is_spine(node))
+ continue;
+ if (add_chassis(&chassis_scan))
+ goto cleanup;
+ chassis_scan.current_chassis->chassisnum = ++chassisnum;
+ if (build_chassis(node, chassis_scan.current_chassis))
+ goto cleanup;
+ }
+
+ /* now make pass on nodes for chassis which are not Voltaire */
+ /* grouped by common SystemImageGUID */
+ for (node = fabric->nodes; node; node = node->next) {
+ if (mad_get_field(node->info, 0,
+ IB_NODE_VENDORID_F) == VTR_VENDOR_ID)
+ continue;
+ if (mad_get_field64(node->info, 0, IB_NODE_SYSTEM_GUID_F)) {
+ chassis = find_chassisguid(fabric, node);
+ if (chassis)
+ chassis->nodecount++;
+ else {
+ /* Possible new chassis */
+ if (add_chassis(&chassis_scan))
+ goto cleanup;
+ chassis_scan.current_chassis->chassisguid =
+ get_chassisguid(node);
+ chassis_scan.current_chassis->nodecount = 1;
+ if (!fabric->chassis)
+ fabric->chassis = chassis_scan.first_chassis;
+ }
+ }
+ }
+
+ /* now, make another pass to see which nodes are part of chassis */
+ /* (defined as chassis->nodecount > 1) */
+ for (node = fabric->nodes; node; node = node->next) {
+
+ vendor_id = mad_get_field(node->info, 0,IB_NODE_VENDORID_F);
+
+ if (vendor_id == VTR_VENDOR_ID)
+ continue;
+ if (mad_get_field64(node->info, 0, IB_NODE_SYSTEM_GUID_F)) {
+ chassis = find_chassisguid(fabric, node);
+ if (chassis && chassis->nodecount > 1) {
+ if (!chassis->chassisnum)
+ chassis->chassisnum = ++chassisnum;
+ if (!node->ch_found) {
+ node->ch_found = 1;
+ add_node_to_chassis(chassis, node);
+ }
+ else if (vendor_id == MLX_VENDOR_ID){
+ insert_mellanox_line_and_spine(node, chassis);
+ }
+ }
+ }
+ }
+
+ fabric->chassis = chassis_scan.first_chassis;
+ return 0;
+
+cleanup:
+ ch = chassis_scan.first_chassis;
+ while (ch) {
+ ch_next = ch->next;
+ free(ch);
+ ch = ch_next;
+ }
+ fabric->chassis = NULL;
+ return -1;
+}
diff --git a/contrib/ofed/libibnetdisc/chassis.h b/contrib/ofed/libibnetdisc/chassis.h
new file mode 100644
index 0000000..7a91be3
--- /dev/null
+++ b/contrib/ofed/libibnetdisc/chassis.h
@@ -0,0 +1,95 @@
+/*
+ * Copyright (c) 2004-2007 Voltaire Inc. All rights reserved.
+ * Copyright (c) 2007 Xsigo Systems Inc. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+#ifndef _CHASSIS_H_
+#define _CHASSIS_H_
+
+#include <infiniband/ibnetdisc.h>
+
+#include "internal.h"
+
+/*========================================================*/
+/* CHASSIS RECOGNITION SPECIFIC DATA */
+/*========================================================*/
+
+/* Device IDs */
+#define VTR_DEVID_IB_FC_ROUTER 0x5a00
+#define VTR_DEVID_IB_IP_ROUTER 0x5a01
+#define VTR_DEVID_ISR9600_SPINE 0x5a02
+#define VTR_DEVID_ISR9600_LEAF 0x5a03
+#define VTR_DEVID_HCA1 0x5a04
+#define VTR_DEVID_HCA2 0x5a44
+#define VTR_DEVID_HCA3 0x6278
+#define VTR_DEVID_SW_6IB4 0x5a05
+#define VTR_DEVID_ISR9024 0x5a06
+#define VTR_DEVID_ISR9288 0x5a07
+#define VTR_DEVID_SLB24 0x5a09
+#define VTR_DEVID_SFB12 0x5a08
+#define VTR_DEVID_SFB4 0x5a0b
+#define VTR_DEVID_ISR9024_12 0x5a0c
+#define VTR_DEVID_SLB8 0x5a0d
+#define VTR_DEVID_RLX_SWITCH_BLADE 0x5a20
+#define VTR_DEVID_ISR9024_DDR 0x5a31
+#define VTR_DEVID_SFB12_DDR 0x5a32
+#define VTR_DEVID_SFB4_DDR 0x5a33
+#define VTR_DEVID_SLB24_DDR 0x5a34
+#define VTR_DEVID_SFB2012 0x5a37
+#define VTR_DEVID_SLB2024 0x5a38
+#define VTR_DEVID_ISR2012 0x5a39
+#define VTR_DEVID_SFB2004 0x5a40
+#define VTR_DEVID_ISR2004 0x5a41
+#define VTR_DEVID_SRB2004 0x5a42
+#define VTR_DEVID_SLB4018 0x5a5b
+#define VTR_DEVID_SFB4700 0x5a5c
+#define VTR_DEVID_SFB4700X2 0x5a5d
+#define VTR_DEVID_SFB4200 0x5a60
+
+#define MLX_DEVID_IS4 0xbd36
+
+/* Vendor IDs (for chassis based systems) */
+#define VTR_VENDOR_ID 0x8f1 /* Voltaire */
+#define MLX_VENDOR_ID 0x2c9 /* Mellanox */
+#define TS_VENDOR_ID 0x5ad /* Cisco */
+#define SS_VENDOR_ID 0x66a /* InfiniCon */
+#define XS_VENDOR_ID 0x1397 /* Xsigo */
+
+enum ibnd_chassis_type {
+ UNRESOLVED_CT, ISR9288_CT, ISR9096_CT, ISR2012_CT, ISR2004_CT,
+ ISR4700_CT, ISR4200_CT
+};
+enum ibnd_chassis_slot_type { UNRESOLVED_CS, LINE_CS, SPINE_CS, SRBD_CS };
+
+int group_nodes(struct ibnd_fabric *fabric);
+
+#endif /* _CHASSIS_H_ */
diff --git a/contrib/ofed/libibnetdisc/config.h b/contrib/ofed/libibnetdisc/config.h
new file mode 100644
index 0000000..d203120
--- /dev/null
+++ b/contrib/ofed/libibnetdisc/config.h
@@ -0,0 +1,125 @@
+/* config.h. Generated from config.h.in by configure. */
+/* config.h.in. Generated from configure.ac by autoheader. */
+
+/* Define to 1 if you have the <dlfcn.h> header file. */
+#define HAVE_DLFCN_H 1
+
+/* Define to 1 if you don't have `vprintf' but do have `_doprnt.' */
+/* #undef HAVE_DOPRNT */
+
+/* Define to 1 if you have the <fcntl.h> header file. */
+#define HAVE_FCNTL_H 1
+
+/* Define to 1 to indicate GLIB support */
+/* #undef HAVE_GLIB */
+
+/* Define if IB_PC_QP1_DROP_F exists in mad.h enum MAD_FIELDS. */
+#define HAVE_IB_PC_QP1_DROP_F 1
+
+/* Define to 1 if you have the <inttypes.h> header file. */
+#define HAVE_INTTYPES_H 1
+
+/* Define to 1 if you have the `ibmad' library (-libmad). */
+#define HAVE_LIBIBMAD 1
+
+/* Define to 1 if you have the `ibumad' library (-libumad). */
+#define HAVE_LIBIBUMAD 1
+
+/* Define to 1 if you have the `osmcomp' library (-losmcomp). */
+#define HAVE_LIBOSMCOMP 1
+
+/* Define to 1 if you have the `udev' library (-ludev). */
+/* #undef HAVE_LIBUDEV */
+
+/* Define to 1 if you have the <memory.h> header file. */
+#define HAVE_MEMORY_H 1
+
+/* Define to 1 if you have the `memset' function. */
+#define HAVE_MEMSET 1
+
+/* Define to 1 if you have the <netinet/in.h> header file. */
+#define HAVE_NETINET_IN_H 1
+
+/* Define to 1 if you have the <stdint.h> header file. */
+#define HAVE_STDINT_H 1
+
+/* Define to 1 if you have the <stdlib.h> header file. */
+#define HAVE_STDLIB_H 1
+
+/* Define to 1 if you have the `strchr' function. */
+#define HAVE_STRCHR 1
+
+/* Define to 1 if you have the <strings.h> header file. */
+#define HAVE_STRINGS_H 1
+
+/* Define to 1 if you have the <string.h> header file. */
+#define HAVE_STRING_H 1
+
+/* Define to 1 if you have the `strrchr' function. */
+#define HAVE_STRRCHR 1
+
+/* Define to 1 if you have the `strtol' function. */
+#define HAVE_STRTOL 1
+
+/* Define to 1 if you have the `strtoul' function. */
+#define HAVE_STRTOUL 1
+
+/* Define to 1 if you have the `strtoull' function. */
+#define HAVE_STRTOULL 1
+
+/* Define to 1 if you have the <sys/ioctl.h> header file. */
+#define HAVE_SYS_IOCTL_H 1
+
+/* Define to 1 if you have the <sys/stat.h> header file. */
+#define HAVE_SYS_STAT_H 1
+
+/* Define to 1 if you have the <sys/types.h> header file. */
+#define HAVE_SYS_TYPES_H 1
+
+/* Define to 1 if you have the `udev_get_sys_path' function. */
+/* #undef HAVE_UDEV_GET_SYS_PATH */
+
+/* Define to 1 if struct umad_port has link_layer member */
+#define HAVE_UMAD_PORT_LINK_LAYER 1
+
+/* Define to 1 if you have the <unistd.h> header file. */
+#define HAVE_UNISTD_H 1
+
+/* Define to 1 if you have the `vprintf' function. */
+#define HAVE_VPRINTF 1
+
+/* Define the path to configurations */
+#define IBDIAG_CONFIG_PATH "/etc/infiniband-diags"
+
+/* Define to the sub-directory where libtool stores uninstalled libraries. */
+#define LT_OBJDIR ".libs/"
+
+/* Name of package */
+#define PACKAGE "infiniband-diags"
+
+/* Define to the address where bug reports for this package should be sent. */
+#define PACKAGE_BUGREPORT "linux-rdma@vger.kernel.org"
+
+/* Define to the full name of this package. */
+#define PACKAGE_NAME "infiniband-diags"
+
+/* Define to the full name and version of this package. */
+#define PACKAGE_STRING "infiniband-diags 1.6.7"
+
+/* Define to the one symbol short name of this package. */
+#define PACKAGE_TARNAME "infiniband-diags"
+
+/* Define to the home page for this package. */
+#define PACKAGE_URL ""
+
+/* Define to the version of this package. */
+#define PACKAGE_VERSION "1.6.7"
+
+/* Define to 1 if you have the ANSI C header files. */
+#define STDC_HEADERS 1
+
+/* Version number of package */
+#define VERSION "1.6.7"
+
+/* Define to empty if `const' does not conform to ANSI C. */
+/* #undef const */
diff --git a/contrib/ofed/libibnetdisc/g_hash_table.cpp b/contrib/ofed/libibnetdisc/g_hash_table.cpp
new file mode 100644
index 0000000..457eed3
--- /dev/null
+++ b/contrib/ofed/libibnetdisc/g_hash_table.cpp
@@ -0,0 +1,86 @@
+/*
+ * Copyright (c) 2017 Mellanox Technologies LTD. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+#if __cplusplus >= 201103L
+#include <unordered_map>
+#define UM_NAMESPACE std
+#else
+#include <tr1/unordered_map>
+#define UM_NAMESPACE std::tr1
+#endif
+
+class HashTable {
+public:
+ UM_NAMESPACE::unordered_map<void *, void *> map;
+ HashTable() { };
+ ~HashTable() { };
+};
+
+extern "C" {
+
+#if HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "internal.h"
+
+GHashTable *
+GHashTableNew(void)
+{
+ return ((GHashTable *)(new HashTable()));
+}
+
+void
+GHashTableDestroy(GHashTable *ght)
+{
+ delete (HashTable *)ght;
+}
+
+void
+GHashTableInsert(GHashTable *ght, void *key, void *value)
+{
+ HashTable *ht = (HashTable *)ght;
+ ht->map[key] = value;
+}
+
+void *
+GHashTableLookup(GHashTable *ght, void *key)
+{
+ HashTable *ht = (HashTable *)ght;
+
+ if (ht->map.find(key) == ht->map.end())
+ return (NULL);
+ return (ht->map[key]);
+}
+
+}
diff --git a/contrib/ofed/libibnetdisc/ibnetdisc.c b/contrib/ofed/libibnetdisc/ibnetdisc.c
new file mode 100644
index 0000000..61e30d4
--- /dev/null
+++ b/contrib/ofed/libibnetdisc/ibnetdisc.c
@@ -0,0 +1,1003 @@
+/*
+ * Copyright (c) 2004-2009 Voltaire Inc. All rights reserved.
+ * Copyright (c) 2007 Xsigo Systems Inc. All rights reserved.
+ * Copyright (c) 2008 Lawrence Livermore National Laboratory
+ * Copyright (c) 2010-2011 Mellanox Technologies LTD. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+#if HAVE_CONFIG_H
+#include <config.h>
+#endif /* HAVE_CONFIG_H */
+
+#define _GNU_SOURCE
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <string.h>
+#include <errno.h>
+#include <inttypes.h>
+
+#include <infiniband/umad.h>
+#include <infiniband/mad.h>
+
+#include <infiniband/ibnetdisc.h>
+#include <complib/cl_nodenamemap.h>
+
+#include "internal.h"
+#include "chassis.h"
+
+/* forward declarations */
+struct ni_cbdata
+{
+ ibnd_node_t *node;
+ int port_num;
+};
+static int query_node_info(smp_engine_t * engine, ib_portid_t * portid,
+ struct ni_cbdata * cbdata);
+static int query_port_info(smp_engine_t * engine, ib_portid_t * portid,
+ ibnd_node_t * node, int portnum);
+ibnd_port_t *ibnd_find_port_dr(ibnd_fabric_t * fabric, char *dr_str);
+
+static int recv_switch_info(smp_engine_t * engine, ibnd_smp_t * smp,
+ uint8_t * mad, void *cb_data)
+{
+ uint8_t *switch_info = mad + IB_SMP_DATA_OFFS;
+ ibnd_node_t *node = cb_data;
+ memcpy(node->switchinfo, switch_info, sizeof(node->switchinfo));
+ mad_decode_field(node->switchinfo, IB_SW_ENHANCED_PORT0_F,
+ &node->smaenhsp0);
+ return 0;
+}
+
+static int query_switch_info(smp_engine_t * engine, ib_portid_t * portid,
+ ibnd_node_t * node)
+{
+ node->smaenhsp0 = 0; /* assume base SP0 */
+ return issue_smp(engine, portid, IB_ATTR_SWITCH_INFO, 0,
+ recv_switch_info, node);
+}
+
+static int add_port_to_dpath(ib_dr_path_t * path, int nextport)
+{
+ if (path->cnt > sizeof(path->p) - 2)
+ return -1;
+ ++path->cnt;
+ path->p[path->cnt] = (uint8_t) nextport;
+ return path->cnt;
+}
+
+static int retract_dpath(smp_engine_t * engine, ib_portid_t * portid)
+{
+ ibnd_scan_t *scan = engine->user_data;
+ f_internal_t *f_int = scan->f_int;
+
+ if (scan->cfg->max_hops &&
+ f_int->fabric.maxhops_discovered > scan->cfg->max_hops)
+ return 0;
+
+ /* this may seem wrong but the only time we would retract the path is
+ * if the user specified a CA for the DR path and we are retracting
+ * from that to find the node it is connected to. This counts as a
+ * positive hop discovered
+ */
+ f_int->fabric.maxhops_discovered++;
+ portid->drpath.p[portid->drpath.cnt] = 0;
+ portid->drpath.cnt--;
+ return 1;
+}
+
+static int extend_dpath(smp_engine_t * engine, ib_portid_t * portid,
+ int nextport)
+{
+ ibnd_scan_t *scan = engine->user_data;
+ f_internal_t *f_int = scan->f_int;
+
+ if (scan->cfg->max_hops &&
+ f_int->fabric.maxhops_discovered > scan->cfg->max_hops)
+ return 0;
+
+ if (portid->lid) {
+ /* If we were LID routed we need to set up the drslid */
+ portid->drpath.drslid = (uint16_t) scan->selfportid.lid;
+ portid->drpath.drdlid = 0xFFFF;
+ }
+
+ if (add_port_to_dpath(&portid->drpath, nextport) < 0) {
+ IBND_ERROR("add port %d to DR path failed; %s\n", nextport,
+ portid2str(portid));
+ return -1;
+ }
+
+ if (((unsigned) portid->drpath.cnt - scan->initial_hops) >
+ f_int->fabric.maxhops_discovered)
+ f_int->fabric.maxhops_discovered++;
+
+ return 1;
+}
+
+static int recv_node_desc(smp_engine_t * engine, ibnd_smp_t * smp,
+ uint8_t * mad, void *cb_data)
+{
+ uint8_t *node_desc = mad + IB_SMP_DATA_OFFS;
+ ibnd_node_t *node = cb_data;
+ memcpy(node->nodedesc, node_desc, sizeof(node->nodedesc));
+ return 0;
+}
+
+static int query_node_desc(smp_engine_t * engine, ib_portid_t * portid,
+ ibnd_node_t * node)
+{
+ return issue_smp(engine, portid, IB_ATTR_NODE_DESC, 0,
+ recv_node_desc, node);
+}
+
+static void debug_port(ib_portid_t * portid, ibnd_port_t * port)
+{
+ char width[64], speed[64];
+ int iwidth;
+ int ispeed, fdr10, espeed;
+ uint8_t *info;
+ uint32_t cap_mask;
+
+ iwidth = mad_get_field(port->info, 0, IB_PORT_LINK_WIDTH_ACTIVE_F);
+ ispeed = mad_get_field(port->info, 0, IB_PORT_LINK_SPEED_ACTIVE_F);
+ fdr10 = mad_get_field(port->ext_info, 0,
+ IB_MLNX_EXT_PORT_LINK_SPEED_ACTIVE_F);
+
+ if (port->node->type == IB_NODE_SWITCH)
+ info = (uint8_t *)&port->node->ports[0]->info;
+ else
+ info = (uint8_t *)&port->info;
+ cap_mask = mad_get_field(info, 0, IB_PORT_CAPMASK_F);
+ if (cap_mask & CL_NTOH32(IB_PORT_CAP_HAS_EXT_SPEEDS))
+ espeed = mad_get_field(port->info, 0, IB_PORT_LINK_SPEED_EXT_ACTIVE_F);
+ else
+ espeed = 0;
+ IBND_DEBUG
+ ("portid %s portnum %d: base lid %d state %d physstate %d %s %s %s %s\n",
+ portid2str(portid), port->portnum, port->base_lid,
+ mad_get_field(port->info, 0, IB_PORT_STATE_F),
+ mad_get_field(port->info, 0, IB_PORT_PHYS_STATE_F),
+ mad_dump_val(IB_PORT_LINK_WIDTH_ACTIVE_F, width, 64, &iwidth),
+ mad_dump_val(IB_PORT_LINK_SPEED_ACTIVE_F, speed, 64, &ispeed),
+ (fdr10 & FDR10) ? "FDR10" : "",
+ mad_dump_val(IB_PORT_LINK_SPEED_EXT_ACTIVE_F, speed, 64, &espeed));
+}
+
+static int is_mlnx_ext_port_info_supported(ibnd_port_t * port)
+{
+ uint16_t devid = (uint16_t) mad_get_field(port->node->info, 0, IB_NODE_DEVID_F);
+ uint32_t vendorid = (uint32_t) mad_get_field(port->node->info, 0, IB_NODE_VENDORID_F);
+
+ if ((devid >= 0xc738 && devid <= 0xc73b) || devid == 0xcb20 || devid == 0xcf08 ||
+ ((vendorid == 0x119f) &&
+ /* Bull SwitchX */
+ (devid == 0x1b02 || devid == 0x1b50 ||
+ /* Bull SwitchIB and SwitchIB2 */
+ devid == 0x1ba0 ||
+ (devid >= 0x1bd0 && devid <= 0x1bd5))))
+ return 1;
+ if ((devid >= 0x1003 && devid <= 0x1017) ||
+ ((vendorid == 0x119f) &&
+ /* Bull ConnectX3 */
+ (devid == 0x1b33 || devid == 0x1b73 ||
+ devid == 0x1b40 || devid == 0x1b41 ||
+ devid == 0x1b60 || devid == 0x1b61 ||
+ /* Bull ConnectIB */
+ devid == 0x1b83 ||
+ devid == 0x1b93 || devid == 0x1b94 ||
+ /* Bull ConnectX4 */
+ devid == 0x1bb4 || devid == 0x1bb5 ||
+ devid == 0x1bc4)))
+ return 1;
+ return 0;
+}
+
+int mlnx_ext_port_info_err(smp_engine_t * engine, ibnd_smp_t * smp,
+ uint8_t * mad, void *cb_data)
+{
+ f_internal_t *f_int = ((ibnd_scan_t *) engine->user_data)->f_int;
+ ibnd_node_t *node = cb_data;
+ ibnd_port_t *port;
+ uint8_t port_num, local_port;
+
+ port_num = (uint8_t) mad_get_field(mad, 0, IB_MAD_ATTRMOD_F);
+ port = node->ports[port_num];
+ if (!port) {
+ IBND_ERROR("Failed to find 0x%" PRIx64 " port %u\n",
+ node->guid, port_num);
+ return -1;
+ }
+
+ local_port = (uint8_t) mad_get_field(port->info, 0, IB_PORT_LOCAL_PORT_F);
+ debug_port(&smp->path, port);
+
+ if (port_num && mad_get_field(port->info, 0, IB_PORT_PHYS_STATE_F)
+ == IB_PORT_PHYS_STATE_LINKUP
+ && ((node->type == IB_NODE_SWITCH && port_num != local_port) ||
+ (node == f_int->fabric.from_node && port_num == f_int->fabric.from_portnum))) {
+ int rc = 0;
+ ib_portid_t path = smp->path;
+
+ if (node->type != IB_NODE_SWITCH &&
+ node == f_int->fabric.from_node &&
+ path.drpath.cnt > 1)
+ rc = retract_dpath(engine, &path);
+ else {
+ /* we can't proceed through an HCA with DR */
+ if (path.lid == 0 || node->type == IB_NODE_SWITCH)
+ rc = extend_dpath(engine, &path, port_num);
+ }
+
+ if (rc > 0) {
+ struct ni_cbdata * cbdata = malloc(sizeof(*cbdata));
+ cbdata->node = node;
+ cbdata->port_num = port_num;
+ query_node_info(engine, &path, cbdata);
+ }
+ }
+
+ return 0;
+}
+
+static int recv_mlnx_ext_port_info(smp_engine_t * engine, ibnd_smp_t * smp,
+ uint8_t * mad, void *cb_data)
+{
+ f_internal_t *f_int = ((ibnd_scan_t *) engine->user_data)->f_int;
+ ibnd_node_t *node = cb_data;
+ ibnd_port_t *port;
+ uint8_t *ext_port_info = mad + IB_SMP_DATA_OFFS;
+ uint8_t port_num, local_port;
+
+ port_num = (uint8_t) mad_get_field(mad, 0, IB_MAD_ATTRMOD_F);
+ port = node->ports[port_num];
+ if (!port) {
+ IBND_ERROR("Failed to find 0x%" PRIx64 " port %u\n",
+ node->guid, port_num);
+ return -1;
+ }
+
+ memcpy(port->ext_info, ext_port_info, sizeof(port->ext_info));
+ local_port = (uint8_t) mad_get_field(port->info, 0, IB_PORT_LOCAL_PORT_F);
+ debug_port(&smp->path, port);
+
+ if (port_num && mad_get_field(port->info, 0, IB_PORT_PHYS_STATE_F)
+ == IB_PORT_PHYS_STATE_LINKUP
+ && ((node->type == IB_NODE_SWITCH && port_num != local_port) ||
+ (node == f_int->fabric.from_node && port_num == f_int->fabric.from_portnum))) {
+ int rc = 0;
+ ib_portid_t path = smp->path;
+
+ if (node->type != IB_NODE_SWITCH &&
+ node == f_int->fabric.from_node &&
+ path.drpath.cnt > 1)
+ rc = retract_dpath(engine, &path);
+ else {
+ /* we can't proceed through an HCA with DR */
+ if (path.lid == 0 || node->type == IB_NODE_SWITCH)
+ rc = extend_dpath(engine, &path, port_num);
+ }
+
+ if (rc > 0) {
+ struct ni_cbdata * cbdata = malloc(sizeof(*cbdata));
+ cbdata->node = node;
+ cbdata->port_num = port_num;
+ query_node_info(engine, &path, cbdata);
+ }
+ }
+
+ return 0;
+}
+
+static int query_mlnx_ext_port_info(smp_engine_t * engine, ib_portid_t * portid,
+ ibnd_node_t * node, int portnum)
+{
+ IBND_DEBUG("Query MLNX Extended Port Info; %s (0x%" PRIx64 "):%d\n",
+ portid2str(portid), node->guid, portnum);
+ return issue_smp(engine, portid, IB_ATTR_MLNX_EXT_PORT_INFO, portnum,
+ recv_mlnx_ext_port_info, node);
+}
+
+static int recv_port_info(smp_engine_t * engine, ibnd_smp_t * smp,
+ uint8_t * mad, void *cb_data)
+{
+ ibnd_scan_t *scan = (ibnd_scan_t *)engine->user_data;
+ f_internal_t *f_int = scan->f_int;
+ ibnd_node_t *node = cb_data;
+ ibnd_port_t *port;
+ uint8_t *port_info = mad + IB_SMP_DATA_OFFS;
+ uint8_t port_num, local_port;
+ int phystate, ispeed, espeed;
+ uint8_t *info;
+ uint32_t cap_mask;
+
+ port_num = (uint8_t) mad_get_field(mad, 0, IB_MAD_ATTRMOD_F);
+ local_port = (uint8_t) mad_get_field(port_info, 0, IB_PORT_LOCAL_PORT_F);
+
+ /* this may have been created before */
+ port = node->ports[port_num];
+ if (!port) {
+ port = node->ports[port_num] = calloc(1, sizeof(*port));
+ if (!port) {
+ IBND_ERROR("Failed to allocate 0x%" PRIx64 " port %u\n",
+ node->guid, port_num);
+ return -1;
+ }
+ port->guid =
+ mad_get_field64(node->info, 0, IB_NODE_PORT_GUID_F);
+ }
+
+ memcpy(port->info, port_info, sizeof(port->info));
+ port->node = node;
+ port->portnum = port_num;
+ port->ext_portnum = 0;
+ port->base_lid = (uint16_t) mad_get_field(port->info, 0, IB_PORT_LID_F);
+ port->lmc = (uint8_t) mad_get_field(port->info, 0, IB_PORT_LMC_F);
+
+ if (port_num == 0) {
+ node->smalid = port->base_lid;
+ node->smalmc = port->lmc;
+ } else if (node->type == IB_NODE_SWITCH) {
+ port->base_lid = node->smalid;
+ port->lmc = node->smalmc;
+ }
+
+ int rc1 = add_to_portguid_hash(port, f_int->fabric.portstbl);
+ if (rc1)
+ IBND_ERROR("Error Occurred when trying"
+ " to insert new port guid 0x%016" PRIx64 " to DB\n",
+ port->guid);
+
+ add_to_portlid_hash(port, f_int->lid2guid);
+
+ if ((scan->cfg->flags & IBND_CONFIG_MLX_EPI)
+ && is_mlnx_ext_port_info_supported(port)) {
+ phystate = mad_get_field(port->info, 0, IB_PORT_PHYS_STATE_F);
+ ispeed = mad_get_field(port->info, 0, IB_PORT_LINK_SPEED_ACTIVE_F);
+ if (port->node->type == IB_NODE_SWITCH)
+ info = (uint8_t *)&port->node->ports[0]->info;
+ else
+ info = (uint8_t *)&port->info;
+ cap_mask = mad_get_field(info, 0, IB_PORT_CAPMASK_F);
+ if (cap_mask & CL_NTOH32(IB_PORT_CAP_HAS_EXT_SPEEDS))
+ espeed = mad_get_field(port->info, 0, IB_PORT_LINK_SPEED_EXT_ACTIVE_F);
+ else
+ espeed = 0;
+
+ if (phystate == IB_PORT_PHYS_STATE_LINKUP &&
+ ispeed == IB_LINK_SPEED_ACTIVE_10 &&
+ espeed == IB_LINK_SPEED_EXT_ACTIVE_NONE) { /* LinkUp/QDR */
+ query_mlnx_ext_port_info(engine, &smp->path,
+ node, port_num);
+ return 0;
+ }
+ }
+
+ debug_port(&smp->path, port);
+
+ if (port_num && mad_get_field(port->info, 0, IB_PORT_PHYS_STATE_F)
+ == IB_PORT_PHYS_STATE_LINKUP
+ && ((node->type == IB_NODE_SWITCH && port_num != local_port) ||
+ (node == f_int->fabric.from_node && port_num == f_int->fabric.from_portnum))) {
+
+ int rc = 0;
+ ib_portid_t path = smp->path;
+
+ if (node->type != IB_NODE_SWITCH &&
+ node == f_int->fabric.from_node &&
+ path.drpath.cnt > 1)
+ rc = retract_dpath(engine, &path);
+ else {
+ /* we can't proceed through an HCA with DR */
+ if (path.lid == 0 || node->type == IB_NODE_SWITCH)
+ rc = extend_dpath(engine, &path, port_num);
+ }
+
+ if (rc > 0) {
+ struct ni_cbdata * cbdata = malloc(sizeof(*cbdata));
+ cbdata->node = node;
+ cbdata->port_num = port_num;
+ query_node_info(engine, &path, cbdata);
+ }
+ }
+
+ return 0;
+}
+
+static int recv_port0_info(smp_engine_t * engine, ibnd_smp_t * smp,
+ uint8_t * mad, void *cb_data)
+{
+ ibnd_node_t *node = cb_data;
+ int i, status;
+
+ status = recv_port_info(engine, smp, mad, cb_data);
+ /* Query PortInfo on switch external/physical ports */
+ for (i = 1; i <= node->numports; i++)
+ query_port_info(engine, &smp->path, node, i);
+
+ return status;
+}
+
+static int query_port_info(smp_engine_t * engine, ib_portid_t * portid,
+ ibnd_node_t * node, int portnum)
+{
+ IBND_DEBUG("Query Port Info; %s (0x%" PRIx64 "):%d\n",
+ portid2str(portid), node->guid, portnum);
+ return issue_smp(engine, portid, IB_ATTR_PORT_INFO, portnum,
+ portnum ? recv_port_info : recv_port0_info, node);
+}
+
+static ibnd_node_t *create_node(smp_engine_t * engine, ib_portid_t * path,
+ uint8_t * node_info)
+{
+ f_internal_t *f_int = ((ibnd_scan_t *) engine->user_data)->f_int;
+ ibnd_node_t *rc = calloc(1, sizeof(*rc));
+ if (!rc) {
+ IBND_ERROR("OOM: node creation failed\n");
+ return NULL;
+ }
+
+ /* decode just a couple of fields for quicker reference. */
+ mad_decode_field(node_info, IB_NODE_GUID_F, &rc->guid);
+ mad_decode_field(node_info, IB_NODE_TYPE_F, &rc->type);
+ mad_decode_field(node_info, IB_NODE_NPORTS_F, &rc->numports);
+
+ rc->ports = calloc(rc->numports + 1, sizeof(*rc->ports));
+ if (!rc->ports) {
+ free(rc);
+ IBND_ERROR("OOM: Failed to allocate the ports array\n");
+ return NULL;
+ }
+
+ rc->path_portid = *path;
+ memcpy(rc->info, node_info, sizeof(rc->info));
+
+ int rc1 = add_to_nodeguid_hash(rc, f_int->fabric.nodestbl);
+ if (rc1)
+ IBND_ERROR("Error Occurred when trying"
+ " to insert new node guid 0x%016" PRIx64 " to DB\n",
+ rc->guid);
+
+ /* add this to the all nodes list */
+ rc->next = f_int->fabric.nodes;
+ f_int->fabric.nodes = rc;
+
+ add_to_type_list(rc, f_int);
+
+ return rc;
+}
+
+static void link_ports(ibnd_node_t * node, ibnd_port_t * port,
+ ibnd_node_t * remotenode, ibnd_port_t * remoteport)
+{
+ IBND_DEBUG("linking: 0x%" PRIx64 " %p->%p:%u and 0x%" PRIx64
+ " %p->%p:%u\n", node->guid, node, port, port->portnum,
+ remotenode->guid, remotenode, remoteport,
+ remoteport->portnum);
+ if (port->remoteport)
+ port->remoteport->remoteport = NULL;
+ if (remoteport->remoteport)
+ remoteport->remoteport->remoteport = NULL;
+ port->remoteport = remoteport;
+ remoteport->remoteport = port;
+}
+
+static void dump_endnode(ib_portid_t * path, char *prompt,
+ ibnd_node_t * node, ibnd_port_t * port)
+{
+ char type[64];
+ mad_dump_node_type(type, sizeof(type), &node->type, sizeof(int));
+ printf("%s -> %s %s {%016" PRIx64 "} portnum %d lid %d-%d \"%s\"\n",
+ portid2str(path), prompt, type, node->guid,
+ node->type == IB_NODE_SWITCH ? 0 : port->portnum,
+ port->base_lid, port->base_lid + (1 << port->lmc) - 1,
+ node->nodedesc);
+}
+
+static int recv_node_info(smp_engine_t * engine, ibnd_smp_t * smp,
+ uint8_t * mad, void *cb_data)
+{
+ ibnd_scan_t *scan = engine->user_data;
+ f_internal_t *f_int = scan->f_int;
+ uint8_t *node_info = mad + IB_SMP_DATA_OFFS;
+ struct ni_cbdata *ni_cbdata = (struct ni_cbdata *)cb_data;
+ ibnd_node_t *rem_node = NULL;
+ int rem_port_num = 0;
+ ibnd_node_t *node;
+ int node_is_new = 0;
+ uint64_t node_guid = mad_get_field64(node_info, 0, IB_NODE_GUID_F);
+ uint64_t port_guid = mad_get_field64(node_info, 0, IB_NODE_PORT_GUID_F);
+ int port_num = mad_get_field(node_info, 0, IB_NODE_LOCAL_PORT_F);
+ ibnd_port_t *port = NULL;
+
+ if (ni_cbdata) {
+ rem_node = ni_cbdata->node;
+ rem_port_num = ni_cbdata->port_num;
+ free(ni_cbdata);
+ }
+
+ node = ibnd_find_node_guid(&f_int->fabric, node_guid);
+ if (!node) {
+ node = create_node(engine, &smp->path, node_info);
+ if (!node)
+ return -1;
+ node_is_new = 1;
+ }
+ IBND_DEBUG("Found %s node GUID 0x%" PRIx64 " (%s)\n",
+ node_is_new ? "new" : "old", node->guid,
+ portid2str(&smp->path));
+
+ port = node->ports[port_num];
+ if (!port) {
+ /* If we have not see this port before create a shell for it */
+ port = node->ports[port_num] = calloc(1, sizeof(*port));
+ if (!port)
+ return -1;
+ port->node = node;
+ port->portnum = port_num;
+ }
+ port->guid = port_guid;
+
+ if (scan->cfg->show_progress)
+ dump_endnode(&smp->path, node_is_new ? "new" : "known",
+ node, port);
+
+ if (rem_node == NULL) { /* this is the start node */
+ f_int->fabric.from_node = node;
+ f_int->fabric.from_portnum = port_num;
+ } else {
+ /* link ports... */
+ if (!rem_node->ports[rem_port_num]) {
+ IBND_ERROR("Internal Error; "
+ "Node(%p) 0x%" PRIx64
+ " Port %d no port created!?!?!?\n\n",
+ rem_node, rem_node->guid, rem_port_num);
+ return -1;
+ }
+
+ link_ports(node, port, rem_node, rem_node->ports[rem_port_num]);
+ }
+
+ if (node_is_new) {
+ query_node_desc(engine, &smp->path, node);
+
+ if (node->type == IB_NODE_SWITCH) {
+ query_switch_info(engine, &smp->path, node);
+ /* Query PortInfo on Switch Port 0 first */
+ query_port_info(engine, &smp->path, node, 0);
+ }
+ }
+
+ if (node->type != IB_NODE_SWITCH)
+ query_port_info(engine, &smp->path, node, port_num);
+
+ return 0;
+}
+
+static int query_node_info(smp_engine_t * engine, ib_portid_t * portid,
+ struct ni_cbdata * cbdata)
+{
+ IBND_DEBUG("Query Node Info; %s\n", portid2str(portid));
+ return issue_smp(engine, portid, IB_ATTR_NODE_INFO, 0,
+ recv_node_info, (void *)cbdata);
+}
+
+ibnd_node_t *ibnd_find_node_guid(ibnd_fabric_t * fabric, uint64_t guid)
+{
+ int hash = HASHGUID(guid) % HTSZ;
+ ibnd_node_t *node;
+
+ if (!fabric) {
+ IBND_DEBUG("fabric parameter NULL\n");
+ return NULL;
+ }
+
+ for (node = fabric->nodestbl[hash]; node; node = node->htnext)
+ if (node->guid == guid)
+ return node;
+
+ return NULL;
+}
+
+ibnd_node_t *ibnd_find_node_dr(ibnd_fabric_t * fabric, char *dr_str)
+{
+ ibnd_port_t *rc = ibnd_find_port_dr(fabric, dr_str);
+ return rc->node;
+}
+
+int add_to_nodeguid_hash(ibnd_node_t * node, ibnd_node_t * hash[])
+{
+ int rc = 0;
+ ibnd_node_t *tblnode;
+ int hash_idx = HASHGUID(node->guid) % HTSZ;
+
+ for (tblnode = hash[hash_idx]; tblnode; tblnode = tblnode->htnext) {
+ if (tblnode == node) {
+ IBND_ERROR("Duplicate Node: Node with guid 0x%016"
+ PRIx64 " already exists in nodes DB\n",
+ node->guid);
+ return 1;
+ }
+ }
+ node->htnext = hash[hash_idx];
+ hash[hash_idx] = node;
+ return rc;
+}
+
+int add_to_portguid_hash(ibnd_port_t * port, ibnd_port_t * hash[])
+{
+ int rc = 0;
+ ibnd_port_t *tblport;
+ int hash_idx = HASHGUID(port->guid) % HTSZ;
+
+ for (tblport = hash[hash_idx]; tblport; tblport = tblport->htnext) {
+ if (tblport == port) {
+ IBND_ERROR("Duplicate Port: Port with guid 0x%016"
+ PRIx64 " already exists in ports DB\n",
+ port->guid);
+ return 1;
+ }
+ }
+ port->htnext = hash[hash_idx];
+ hash[hash_idx] = port;
+ return rc;
+}
+
+void create_lid2guid(f_internal_t *f_int)
+{
+ f_int->lid2guid = g_hash_table_new_full(g_direct_hash, g_direct_equal,
+ NULL, NULL);
+}
+
+void destroy_lid2guid(f_internal_t *f_int)
+{
+ if (f_int->lid2guid) {
+ g_hash_table_destroy(f_int->lid2guid);
+ }
+}
+
+void add_to_portlid_hash(ibnd_port_t * port, GHashTable *htable)
+{
+ uint16_t base_lid = port->base_lid;
+ uint16_t lid_mask = ((1 << port->lmc) -1);
+ uint16_t lid = 0;
+ /* 0 < valid lid <= 0xbfff */
+ if (base_lid > 0 && base_lid <= 0xbfff) {
+ /* We add the port for all lids
+ * so it is easier to find any "random" lid specified */
+ for (lid = base_lid; lid <= (base_lid + lid_mask); lid++) {
+ g_hash_table_insert(htable, GINT_TO_POINTER(lid), port);
+ }
+ }
+}
+
+void add_to_type_list(ibnd_node_t * node, f_internal_t * f_int)
+{
+ ibnd_fabric_t *fabric = &f_int->fabric;
+ switch (node->type) {
+ case IB_NODE_CA:
+ node->type_next = fabric->ch_adapters;
+ fabric->ch_adapters = node;
+ break;
+ case IB_NODE_SWITCH:
+ node->type_next = fabric->switches;
+ fabric->switches = node;
+ break;
+ case IB_NODE_ROUTER:
+ node->type_next = fabric->routers;
+ fabric->routers = node;
+ break;
+ }
+}
+
+static int set_config(struct ibnd_config *config, struct ibnd_config *cfg)
+{
+ if (!config)
+ return (-EINVAL);
+
+ if (cfg)
+ memcpy(config, cfg, sizeof(*config));
+
+ if (!config->max_smps)
+ config->max_smps = DEFAULT_MAX_SMP_ON_WIRE;
+ if (!config->timeout_ms)
+ config->timeout_ms = DEFAULT_TIMEOUT;
+ if (!config->retries)
+ config->retries = DEFAULT_RETRIES;
+
+ return (0);
+}
+
+f_internal_t *allocate_fabric_internal(void)
+{
+ f_internal_t *f = calloc(1, sizeof(*f));
+ if (f)
+ create_lid2guid(f);
+
+ return (f);
+}
+
+ibnd_fabric_t *ibnd_discover_fabric(char * ca_name, int ca_port,
+ ib_portid_t * from,
+ struct ibnd_config *cfg)
+{
+ struct ibnd_config config = { 0 };
+ f_internal_t *f_int = NULL;
+ ib_portid_t my_portid = { 0 };
+ smp_engine_t engine;
+ ibnd_scan_t scan;
+ struct ibmad_port *ibmad_port;
+ int nc = 2;
+ int mc[2] = { IB_SMI_CLASS, IB_SMI_DIRECT_CLASS };
+
+ /* If not specified start from "my" port */
+ if (!from)
+ from = &my_portid;
+
+ if (set_config(&config, cfg)) {
+ IBND_ERROR("Invalid ibnd_config\n");
+ return NULL;
+ }
+
+ f_int = allocate_fabric_internal();
+ if (!f_int) {
+ IBND_ERROR("OOM: failed to calloc ibnd_fabric_t\n");
+ return NULL;
+ }
+
+ memset(&scan.selfportid, 0, sizeof(scan.selfportid));
+ scan.f_int = f_int;
+ scan.cfg = &config;
+ scan.initial_hops = from->drpath.cnt;
+
+ ibmad_port = mad_rpc_open_port(ca_name, ca_port, mc, nc);
+ if (!ibmad_port) {
+ IBND_ERROR("can't open MAD port (%s:%d)\n", ca_name, ca_port);
+ return (NULL);
+ }
+ mad_rpc_set_timeout(ibmad_port, cfg->timeout_ms);
+ mad_rpc_set_retries(ibmad_port, cfg->retries);
+ smp_mkey_set(ibmad_port, cfg->mkey);
+
+ if (ib_resolve_self_via(&scan.selfportid,
+ NULL, NULL, ibmad_port) < 0) {
+ IBND_ERROR("Failed to resolve self\n");
+ mad_rpc_close_port(ibmad_port);
+ return NULL;
+ }
+ mad_rpc_close_port(ibmad_port);
+
+ if (smp_engine_init(&engine, ca_name, ca_port, &scan, &config)) {
+ free(f_int);
+ return (NULL);
+ }
+
+ IBND_DEBUG("from %s\n", portid2str(from));
+
+ if (!query_node_info(&engine, from, NULL))
+ if (process_mads(&engine) != 0)
+ goto error;
+
+ f_int->fabric.total_mads_used = engine.total_smps;
+ f_int->fabric.maxhops_discovered += scan.initial_hops;
+
+ if (group_nodes(&f_int->fabric))
+ goto error;
+
+ smp_engine_destroy(&engine);
+ return (ibnd_fabric_t *)f_int;
+error:
+ smp_engine_destroy(&engine);
+ ibnd_destroy_fabric(&f_int->fabric);
+ return NULL;
+}
+
+void destroy_node(ibnd_node_t * node)
+{
+ int p = 0;
+
+ if (node->ports) {
+ for (p = 0; p <= node->numports; p++)
+ free(node->ports[p]);
+ free(node->ports);
+ }
+ free(node);
+}
+
+void ibnd_destroy_fabric(ibnd_fabric_t * fabric)
+{
+ ibnd_node_t *node = NULL;
+ ibnd_node_t *next = NULL;
+ ibnd_chassis_t *ch, *ch_next;
+
+ if (!fabric)
+ return;
+
+ ch = fabric->chassis;
+ while (ch) {
+ ch_next = ch->next;
+ free(ch);
+ ch = ch_next;
+ }
+ node = fabric->nodes;
+ while (node) {
+ next = node->next;
+ destroy_node(node);
+ node = next;
+ }
+ destroy_lid2guid((f_internal_t *)fabric);
+ free(fabric);
+}
+
+void ibnd_iter_nodes(ibnd_fabric_t * fabric, ibnd_iter_node_func_t func,
+ void *user_data)
+{
+ ibnd_node_t *cur = NULL;
+
+ if (!fabric) {
+ IBND_DEBUG("fabric parameter NULL\n");
+ return;
+ }
+
+ if (!func) {
+ IBND_DEBUG("func parameter NULL\n");
+ return;
+ }
+
+ for (cur = fabric->nodes; cur; cur = cur->next)
+ func(cur, user_data);
+}
+
+void ibnd_iter_nodes_type(ibnd_fabric_t * fabric, ibnd_iter_node_func_t func,
+ int node_type, void *user_data)
+{
+ ibnd_node_t *list = NULL;
+ ibnd_node_t *cur = NULL;
+
+ if (!fabric) {
+ IBND_DEBUG("fabric parameter NULL\n");
+ return;
+ }
+
+ if (!func) {
+ IBND_DEBUG("func parameter NULL\n");
+ return;
+ }
+
+ switch (node_type) {
+ case IB_NODE_SWITCH:
+ list = fabric->switches;
+ break;
+ case IB_NODE_CA:
+ list = fabric->ch_adapters;
+ break;
+ case IB_NODE_ROUTER:
+ list = fabric->routers;
+ break;
+ default:
+ IBND_DEBUG("Invalid node_type specified %d\n", node_type);
+ break;
+ }
+
+ for (cur = list; cur; cur = cur->type_next)
+ func(cur, user_data);
+}
+
+ibnd_port_t *ibnd_find_port_lid(ibnd_fabric_t * fabric,
+ uint16_t lid)
+{
+ ibnd_port_t *port;
+ f_internal_t *f = (f_internal_t *)fabric;
+
+ port = (ibnd_port_t *)g_hash_table_lookup(f->lid2guid,
+ GINT_TO_POINTER(lid));
+
+ return port;
+}
+
+ibnd_port_t *ibnd_find_port_guid(ibnd_fabric_t * fabric, uint64_t guid)
+{
+ int hash = HASHGUID(guid) % HTSZ;
+ ibnd_port_t *port;
+
+ if (!fabric) {
+ IBND_DEBUG("fabric parameter NULL\n");
+ return NULL;
+ }
+
+ for (port = fabric->portstbl[hash]; port; port = port->htnext)
+ if (port->guid == guid)
+ return port;
+
+ return NULL;
+}
+
+ibnd_port_t *ibnd_find_port_dr(ibnd_fabric_t * fabric, char *dr_str)
+{
+ int i = 0;
+ ibnd_node_t *cur_node;
+ ibnd_port_t *rc = NULL;
+ ib_dr_path_t path;
+
+ if (!fabric) {
+ IBND_DEBUG("fabric parameter NULL\n");
+ return NULL;
+ }
+
+ if (!dr_str) {
+ IBND_DEBUG("dr_str parameter NULL\n");
+ return NULL;
+ }
+
+ cur_node = fabric->from_node;
+
+ if (str2drpath(&path, dr_str, 0, 0) == -1)
+ return NULL;
+
+ for (i = 0; i <= path.cnt; i++) {
+ ibnd_port_t *remote_port = NULL;
+ if (path.p[i] == 0)
+ continue;
+ if (!cur_node->ports)
+ return NULL;
+
+ remote_port = cur_node->ports[path.p[i]]->remoteport;
+ if (!remote_port)
+ return NULL;
+
+ rc = remote_port;
+ cur_node = remote_port->node;
+ }
+
+ return rc;
+}
+
+void ibnd_iter_ports(ibnd_fabric_t * fabric, ibnd_iter_port_func_t func,
+ void *user_data)
+{
+ int i = 0;
+ ibnd_port_t *cur = NULL;
+
+ if (!fabric) {
+ IBND_DEBUG("fabric parameter NULL\n");
+ return;
+ }
+
+ if (!func) {
+ IBND_DEBUG("func parameter NULL\n");
+ return;
+ }
+
+ for (i = 0; i<HTSZ; i++)
+ for (cur = fabric->portstbl[i]; cur; cur = cur->htnext)
+ func(cur, user_data);
+}
diff --git a/contrib/ofed/libibnetdisc/ibnetdisc.h b/contrib/ofed/libibnetdisc/ibnetdisc.h
new file mode 100644
index 0000000..acde1dc
--- /dev/null
+++ b/contrib/ofed/libibnetdisc/ibnetdisc.h
@@ -0,0 +1,258 @@
+/*
+ * Copyright (c) 2009 Voltaire, Inc. All rights reserved.
+ * Copyright (c) 2008 Lawrence Livermore National Lab. All rights reserved.
+ * Copyright (c) 2010-2011 Mellanox Technologies LTD. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+#ifndef _IBNETDISC_H_
+#define _IBNETDISC_H_
+
+#include <stdio.h>
+#include <infiniband/mad.h>
+#include <iba/ib_types.h>
+
+#include <infiniband/ibnetdisc_osd.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+struct ibnd_chassis; /* forward declare */
+struct ibnd_port; /* forward declare */
+
+#define CHASSIS_TYPE_SIZE 20
+
+/** =========================================================================
+ * Node
+ */
+typedef struct ibnd_node {
+ struct ibnd_node *next; /* all node list in fabric */
+
+ ib_portid_t path_portid; /* path from "from_node" */
+ /* NOTE: this is not valid on a fabric
+ * read from a cache file */
+ uint16_t smalid;
+ uint8_t smalmc;
+
+ /* quick cache of switchinfo below */
+ int smaenhsp0;
+ /* use libibmad decoder functions for switchinfo */
+ uint8_t switchinfo[IB_SMP_DATA_SIZE];
+
+ /* quick cache of info below */
+ uint64_t guid;
+ int type;
+ int numports;
+ /* use libibmad decoder functions for info */
+ uint8_t info[IB_SMP_DATA_SIZE];
+
+ char nodedesc[IB_SMP_DATA_SIZE];
+
+ struct ibnd_port **ports; /* array of ports, indexed by port number
+ ports[1] == port 1,
+ ports[2] == port 2,
+ etc...
+ Any port in the array MAY BE NULL!
+ Most notable is non-switches have no
+ port 0 therefore node.ports[0] == NULL
+ for those nodes */
+
+ /* chassis info */
+ struct ibnd_node *next_chassis_node; /* next node in ibnd_chassis_t->nodes */
+ struct ibnd_chassis *chassis; /* if != NULL the chassis this node belongs to */
+ unsigned char ch_type;
+ char ch_type_str[CHASSIS_TYPE_SIZE];
+ unsigned char ch_anafanum;
+ unsigned char ch_slotnum;
+ unsigned char ch_slot;
+
+ /* internal use only */
+ unsigned char ch_found;
+ struct ibnd_node *htnext; /* hash table list */
+ struct ibnd_node *type_next; /* next based on type */
+} ibnd_node_t;
+
+/** =========================================================================
+ * Port
+ */
+typedef struct ibnd_port {
+ uint64_t guid;
+ int portnum;
+ int ext_portnum; /* optional if != 0 external port num */
+ ibnd_node_t *node; /* node this port belongs to */
+ struct ibnd_port *remoteport; /* null if SMA, or does not exist */
+ /* quick cache of info below */
+ uint16_t base_lid;
+ uint8_t lmc;
+ /* use libibmad decoder functions for info */
+ uint8_t info[IB_SMP_DATA_SIZE];
+ uint8_t ext_info[IB_SMP_DATA_SIZE];
+
+ /* internal use only */
+ struct ibnd_port *htnext;
+} ibnd_port_t;
+
+/** =========================================================================
+ * Chassis
+ */
+typedef struct ibnd_chassis {
+ struct ibnd_chassis *next;
+ uint64_t chassisguid;
+ unsigned char chassisnum;
+
+ /* generic grouping by SystemImageGUID */
+ unsigned char nodecount;
+ ibnd_node_t *nodes;
+
+ /* specific to voltaire type nodes */
+#define SPINES_MAX_NUM 18
+#define LINES_MAX_NUM 36
+ ibnd_node_t *spinenode[SPINES_MAX_NUM + 1];
+ ibnd_node_t *linenode[LINES_MAX_NUM + 1];
+} ibnd_chassis_t;
+
+#define HTSZ 137
+
+/* define config flags */
+#define IBND_CONFIG_MLX_EPI (1 << 0)
+
+typedef struct ibnd_config {
+ unsigned max_smps;
+ unsigned show_progress;
+ unsigned max_hops;
+ unsigned debug;
+ unsigned timeout_ms;
+ unsigned retries;
+ uint32_t flags;
+ uint64_t mkey;
+ uint8_t pad[44];
+} ibnd_config_t;
+
+/** =========================================================================
+ * Fabric
+ * Main fabric object which is returned and represents the data discovered
+ */
+typedef struct ibnd_fabric {
+ /* the node the discover was initiated from
+ * "from" parameter in ibnd_discover_fabric
+ * or by default the node you ar running on
+ */
+ ibnd_node_t *from_node;
+ int from_portnum;
+
+ /* NULL term list of all nodes in the fabric */
+ ibnd_node_t *nodes;
+ /* NULL terminated list of all chassis found in the fabric */
+ ibnd_chassis_t *chassis;
+ unsigned maxhops_discovered;
+ unsigned total_mads_used;
+
+ /* internal use only */
+ ibnd_node_t *nodestbl[HTSZ];
+ ibnd_port_t *portstbl[HTSZ];
+ ibnd_node_t *switches;
+ ibnd_node_t *ch_adapters;
+ ibnd_node_t *routers;
+} ibnd_fabric_t;
+
+/** =========================================================================
+ * Initialization (fabric operations)
+ */
+
+IBND_EXPORT ibnd_fabric_t *ibnd_discover_fabric(char * ca_name,
+ int ca_port,
+ ib_portid_t * from,
+ struct ibnd_config *config);
+ /**
+ * ca_name: (optional) name of the CA to use
+ * ca_port: (optional) CA port to use
+ * from: (optional) specify the node to start scanning from.
+ * If NULL start from the CA/CA port specified
+ * config: (optional) additional config options for the scan
+ */
+IBND_EXPORT void ibnd_destroy_fabric(ibnd_fabric_t * fabric);
+
+IBND_EXPORT ibnd_fabric_t *ibnd_load_fabric(const char *file,
+ unsigned int flags);
+
+IBND_EXPORT int ibnd_cache_fabric(ibnd_fabric_t * fabric, const char *file,
+ unsigned int flags);
+
+#define IBND_CACHE_FABRIC_FLAG_DEFAULT 0x0000
+#define IBND_CACHE_FABRIC_FLAG_NO_OVERWRITE 0x0001
+
+/** =========================================================================
+ * Node operations
+ */
+IBND_EXPORT ibnd_node_t *ibnd_find_node_guid(ibnd_fabric_t * fabric,
+ uint64_t guid);
+IBND_EXPORT ibnd_node_t *ibnd_find_node_dr(ibnd_fabric_t * fabric, char *dr_str);
+
+typedef void (*ibnd_iter_node_func_t) (ibnd_node_t * node, void *user_data);
+IBND_EXPORT void ibnd_iter_nodes(ibnd_fabric_t * fabric,
+ ibnd_iter_node_func_t func, void *user_data);
+IBND_EXPORT void ibnd_iter_nodes_type(ibnd_fabric_t * fabric,
+ ibnd_iter_node_func_t func,
+ int node_type, void *user_data);
+
+/** =========================================================================
+ * Port operations
+ */
+IBND_EXPORT ibnd_port_t *ibnd_find_port_guid(ibnd_fabric_t * fabric,
+ uint64_t guid);
+IBND_EXPORT ibnd_port_t *ibnd_find_port_dr(ibnd_fabric_t * fabric,
+ char *dr_str);
+IBND_EXPORT ibnd_port_t *ibnd_find_port_lid(ibnd_fabric_t * fabric,
+ uint16_t lid);
+
+typedef void (*ibnd_iter_port_func_t) (ibnd_port_t * port, void *user_data);
+IBND_EXPORT void ibnd_iter_ports(ibnd_fabric_t * fabric,
+ ibnd_iter_port_func_t func, void *user_data);
+
+/** =========================================================================
+ * Chassis queries
+ */
+IBND_EXPORT uint64_t ibnd_get_chassis_guid(ibnd_fabric_t * fabric,
+ unsigned char chassisnum);
+IBND_EXPORT char *ibnd_get_chassis_type(ibnd_node_t * node);
+IBND_EXPORT char *ibnd_get_chassis_slot_str(ibnd_node_t * node,
+ char *str, size_t size);
+
+IBND_EXPORT int ibnd_is_xsigo_guid(uint64_t guid);
+IBND_EXPORT int ibnd_is_xsigo_tca(uint64_t guid);
+IBND_EXPORT int ibnd_is_xsigo_hca(uint64_t guid);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _IBNETDISC_H_ */
diff --git a/contrib/ofed/libibnetdisc/ibnetdisc_cache.c b/contrib/ofed/libibnetdisc/ibnetdisc_cache.c
new file mode 100644
index 0000000..94dd004
--- /dev/null
+++ b/contrib/ofed/libibnetdisc/ibnetdisc_cache.c
@@ -0,0 +1,967 @@
+/*
+ * Copyright (c) 2004-2007 Voltaire Inc. All rights reserved.
+ * Copyright (c) 2007 Xsigo Systems Inc. All rights reserved.
+ * Copyright (c) 2008 Lawrence Livermore National Laboratory
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+#if HAVE_CONFIG_H
+#include <config.h>
+#endif /* HAVE_CONFIG_H */
+
+#define _GNU_SOURCE
+#include <stdio.h>
+#include <stdlib.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <string.h>
+#include <errno.h>
+#include <inttypes.h>
+
+#include <infiniband/ibnetdisc.h>
+
+#include "internal.h"
+#include "chassis.h"
+
+/* For this caching lib, we always cache little endian */
+
+/* Cache format
+ *
+ * Bytes 1-4 - magic number
+ * Bytes 5-8 - version number
+ * Bytes 9-12 - node count
+ * Bytes 13-16 - port count
+ * Bytes 17-24 - "from node" guid
+ * Bytes 25-28 - maxhops discovered
+ * Bytes X-Y - nodes (variable length)
+ * Bytes X-Y - ports (variable length)
+ *
+ * Nodes are cached as
+ *
+ * 2 bytes - smalid
+ * 1 byte - smalmc
+ * 1 byte - smaenhsp0 flag
+ * IB_SMP_DATA_SIZE bytes - switchinfo
+ * 8 bytes - guid
+ * 1 byte - type
+ * 1 byte - numports
+ * IB_SMP_DATA_SIZE bytes - info
+ * IB_SMP_DATA_SIZE bytes - nodedesc
+ * 1 byte - number of ports stored
+ * 8 bytes - portguid A
+ * 1 byte - port num A
+ * 8 bytes - portguid B
+ * 1 byte - port num B
+ * ... etc., depending on number of ports stored
+ *
+ * Ports are cached as
+ *
+ * 8 bytes - guid
+ * 1 byte - portnum
+ * 1 byte - external portnum
+ * 2 bytes - base lid
+ * 1 byte - lmc
+ * IB_SMP_DATA_SIZE bytes - info
+ * 8 bytes - node guid port "owned" by
+ * 1 byte - flag indicating if remote port exists
+ * 8 bytes - port guid remotely connected to
+ * 1 byte - port num remotely connected to
+ */
+
+/* Structs that hold cache info temporarily before
+ * the real structs can be reconstructed.
+ */
+
+typedef struct ibnd_port_cache_key {
+ uint64_t guid;
+ uint8_t portnum;
+} ibnd_port_cache_key_t;
+
+typedef struct ibnd_node_cache {
+ ibnd_node_t *node;
+ uint8_t ports_stored_count;
+ ibnd_port_cache_key_t *port_cache_keys;
+ struct ibnd_node_cache *next;
+ struct ibnd_node_cache *htnext;
+ int node_stored_to_fabric;
+} ibnd_node_cache_t;
+
+typedef struct ibnd_port_cache {
+ ibnd_port_t *port;
+ uint64_t node_guid;
+ uint8_t remoteport_flag;
+ ibnd_port_cache_key_t remoteport_cache_key;
+ struct ibnd_port_cache *next;
+ struct ibnd_port_cache *htnext;
+ int port_stored_to_fabric;
+} ibnd_port_cache_t;
+
+typedef struct ibnd_fabric_cache {
+ f_internal_t *f_int;
+ uint64_t from_node_guid;
+ ibnd_node_cache_t *nodes_cache;
+ ibnd_port_cache_t *ports_cache;
+ ibnd_node_cache_t *nodescachetbl[HTSZ];
+ ibnd_port_cache_t *portscachetbl[HTSZ];
+} ibnd_fabric_cache_t;
+
+#define IBND_FABRIC_CACHE_BUFLEN 4096
+#define IBND_FABRIC_CACHE_MAGIC 0x8FE7832B
+#define IBND_FABRIC_CACHE_VERSION 0x00000001
+
+#define IBND_FABRIC_CACHE_COUNT_OFFSET 8
+
+#define IBND_FABRIC_CACHE_HEADER_LEN (28)
+#define IBND_NODE_CACHE_HEADER_LEN (15 + IB_SMP_DATA_SIZE*3)
+#define IBND_PORT_CACHE_KEY_LEN (8 + 1)
+#define IBND_PORT_CACHE_LEN (31 + IB_SMP_DATA_SIZE)
+
+static ssize_t ibnd_read(int fd, void *buf, size_t count)
+{
+ size_t count_done = 0;
+ ssize_t ret;
+
+ while ((count - count_done) > 0) {
+ ret = read(fd, ((char *) buf) + count_done, count - count_done);
+ if (ret < 0) {
+ if (errno == EINTR)
+ continue;
+ else {
+ IBND_DEBUG("read: %s\n", strerror(errno));
+ return -1;
+ }
+ }
+ if (!ret)
+ break;
+ count_done += ret;
+ }
+
+ if (count_done != count) {
+ IBND_DEBUG("read: read short\n");
+ return -1;
+ }
+
+ return count_done;
+}
+
+static size_t _unmarshall8(uint8_t * inbuf, uint8_t * num)
+{
+ (*num) = inbuf[0];
+
+ return (sizeof(*num));
+}
+
+static size_t _unmarshall16(uint8_t * inbuf, uint16_t * num)
+{
+ (*num) = ((uint16_t) inbuf[1] << 8) | inbuf[0];
+
+ return (sizeof(*num));
+}
+
+static size_t _unmarshall32(uint8_t * inbuf, uint32_t * num)
+{
+ (*num) = (uint32_t) inbuf[0];
+ (*num) |= ((uint32_t) inbuf[1] << 8);
+ (*num) |= ((uint32_t) inbuf[2] << 16);
+ (*num) |= ((uint32_t) inbuf[3] << 24);
+
+ return (sizeof(*num));
+}
+
+static size_t _unmarshall64(uint8_t * inbuf, uint64_t * num)
+{
+ (*num) = (uint64_t) inbuf[0];
+ (*num) |= ((uint64_t) inbuf[1] << 8);
+ (*num) |= ((uint64_t) inbuf[2] << 16);
+ (*num) |= ((uint64_t) inbuf[3] << 24);
+ (*num) |= ((uint64_t) inbuf[4] << 32);
+ (*num) |= ((uint64_t) inbuf[5] << 40);
+ (*num) |= ((uint64_t) inbuf[6] << 48);
+ (*num) |= ((uint64_t) inbuf[7] << 56);
+
+ return (sizeof(*num));
+}
+
+static size_t _unmarshall_buf(const void *inbuf, void *outbuf, unsigned int len)
+{
+ memcpy(outbuf, inbuf, len);
+
+ return len;
+}
+
+static int _load_header_info(int fd, ibnd_fabric_cache_t * fabric_cache,
+ unsigned int *node_count, unsigned int *port_count)
+{
+ uint8_t buf[IBND_FABRIC_CACHE_BUFLEN];
+ uint32_t magic = 0;
+ uint32_t version = 0;
+ size_t offset = 0;
+ uint32_t tmp32;
+
+ if (ibnd_read(fd, buf, IBND_FABRIC_CACHE_HEADER_LEN) < 0)
+ return -1;
+
+ offset += _unmarshall32(buf + offset, &magic);
+
+ if (magic != IBND_FABRIC_CACHE_MAGIC) {
+ IBND_DEBUG("invalid fabric cache file\n");
+ return -1;
+ }
+
+ offset += _unmarshall32(buf + offset, &version);
+
+ if (version != IBND_FABRIC_CACHE_VERSION) {
+ IBND_DEBUG("invalid fabric cache version\n");
+ return -1;
+ }
+
+ offset += _unmarshall32(buf + offset, node_count);
+ offset += _unmarshall32(buf + offset, port_count);
+
+ offset += _unmarshall64(buf + offset, &fabric_cache->from_node_guid);
+ offset += _unmarshall32(buf + offset, &tmp32);
+ fabric_cache->f_int->fabric.maxhops_discovered = tmp32;
+
+ return 0;
+}
+
+static void _destroy_ibnd_node_cache(ibnd_node_cache_t * node_cache)
+{
+ free(node_cache->port_cache_keys);
+ if (!node_cache->node_stored_to_fabric && node_cache->node)
+ destroy_node(node_cache->node);
+ free(node_cache);
+}
+
+static void _destroy_ibnd_fabric_cache(ibnd_fabric_cache_t * fabric_cache)
+{
+ ibnd_node_cache_t *node_cache;
+ ibnd_node_cache_t *node_cache_next;
+ ibnd_port_cache_t *port_cache;
+ ibnd_port_cache_t *port_cache_next;
+
+ if (!fabric_cache)
+ return;
+
+ node_cache = fabric_cache->nodes_cache;
+ while (node_cache) {
+ node_cache_next = node_cache->next;
+
+ _destroy_ibnd_node_cache(node_cache);
+
+ node_cache = node_cache_next;
+ }
+
+ port_cache = fabric_cache->ports_cache;
+ while (port_cache) {
+ port_cache_next = port_cache->next;
+
+ if (!port_cache->port_stored_to_fabric && port_cache->port)
+ free(port_cache->port);
+ free(port_cache);
+
+ port_cache = port_cache_next;
+ }
+
+ free(fabric_cache);
+}
+
+static void store_node_cache(ibnd_node_cache_t * node_cache,
+ ibnd_fabric_cache_t * fabric_cache)
+{
+ int hash_indx = HASHGUID(node_cache->node->guid) % HTSZ;
+
+ node_cache->next = fabric_cache->nodes_cache;
+ fabric_cache->nodes_cache = node_cache;
+
+ node_cache->htnext = fabric_cache->nodescachetbl[hash_indx];
+ fabric_cache->nodescachetbl[hash_indx] = node_cache;
+}
+
+static int _load_node(int fd, ibnd_fabric_cache_t * fabric_cache)
+{
+ uint8_t buf[IBND_FABRIC_CACHE_BUFLEN];
+ ibnd_node_cache_t *node_cache = NULL;
+ ibnd_node_t *node = NULL;
+ size_t offset = 0;
+ uint8_t tmp8;
+
+ node_cache = (ibnd_node_cache_t *) malloc(sizeof(ibnd_node_cache_t));
+ if (!node_cache) {
+ IBND_DEBUG("OOM: node_cache\n");
+ return -1;
+ }
+ memset(node_cache, '\0', sizeof(ibnd_node_cache_t));
+
+ node = (ibnd_node_t *) malloc(sizeof(ibnd_node_t));
+ if (!node) {
+ IBND_DEBUG("OOM: node\n");
+ free(node_cache);
+ return -1;
+ }
+ memset(node, '\0', sizeof(ibnd_node_t));
+
+ node_cache->node = node;
+
+ if (ibnd_read(fd, buf, IBND_NODE_CACHE_HEADER_LEN) < 0)
+ goto cleanup;
+
+ offset += _unmarshall16(buf + offset, &node->smalid);
+ offset += _unmarshall8(buf + offset, &node->smalmc);
+ offset += _unmarshall8(buf + offset, &tmp8);
+ node->smaenhsp0 = tmp8;
+ offset += _unmarshall_buf(buf + offset, node->switchinfo,
+ IB_SMP_DATA_SIZE);
+ offset += _unmarshall64(buf + offset, &node->guid);
+ offset += _unmarshall8(buf + offset, &tmp8);
+ node->type = tmp8;
+ offset += _unmarshall8(buf + offset, &tmp8);
+ node->numports = tmp8;
+ offset += _unmarshall_buf(buf + offset, node->info, IB_SMP_DATA_SIZE);
+ offset += _unmarshall_buf(buf + offset, node->nodedesc,
+ IB_SMP_DATA_SIZE);
+
+ offset += _unmarshall8(buf + offset, &node_cache->ports_stored_count);
+
+ if (node_cache->ports_stored_count) {
+ unsigned int tomalloc = 0;
+ unsigned int toread = 0;
+ unsigned int i;
+
+ tomalloc =
+ sizeof(ibnd_port_cache_key_t) *
+ node_cache->ports_stored_count;
+
+ toread =
+ IBND_PORT_CACHE_KEY_LEN * node_cache->ports_stored_count;
+
+ node_cache->port_cache_keys =
+ (ibnd_port_cache_key_t *) malloc(tomalloc);
+ if (!node_cache->port_cache_keys) {
+ IBND_DEBUG("OOM: node_cache port_cache_keys\n");
+ goto cleanup;
+ }
+
+ if (ibnd_read(fd, buf, toread) < 0)
+ goto cleanup;
+
+ offset = 0;
+
+ for (i = 0; i < node_cache->ports_stored_count; i++) {
+ offset +=
+ _unmarshall64(buf + offset,
+ &node_cache->port_cache_keys[i].guid);
+ offset +=
+ _unmarshall8(buf + offset,
+ &node_cache->
+ port_cache_keys[i].portnum);
+ }
+ }
+
+ store_node_cache(node_cache, fabric_cache);
+
+ return 0;
+
+cleanup:
+ _destroy_ibnd_node_cache(node_cache);
+ return -1;
+}
+
+static void store_port_cache(ibnd_port_cache_t * port_cache,
+ ibnd_fabric_cache_t * fabric_cache)
+{
+ int hash_indx = HASHGUID(port_cache->port->guid) % HTSZ;
+
+ port_cache->next = fabric_cache->ports_cache;
+ fabric_cache->ports_cache = port_cache;
+
+ port_cache->htnext = fabric_cache->portscachetbl[hash_indx];
+ fabric_cache->portscachetbl[hash_indx] = port_cache;
+}
+
+static int _load_port(int fd, ibnd_fabric_cache_t * fabric_cache)
+{
+ uint8_t buf[IBND_FABRIC_CACHE_BUFLEN];
+ ibnd_port_cache_t *port_cache = NULL;
+ ibnd_port_t *port = NULL;
+ size_t offset = 0;
+ uint8_t tmp8;
+
+ port_cache = (ibnd_port_cache_t *) malloc(sizeof(ibnd_port_cache_t));
+ if (!port_cache) {
+ IBND_DEBUG("OOM: port_cache\n");
+ return -1;
+ }
+ memset(port_cache, '\0', sizeof(ibnd_port_cache_t));
+
+ port = (ibnd_port_t *) malloc(sizeof(ibnd_port_t));
+ if (!port) {
+ IBND_DEBUG("OOM: port\n");
+ free(port_cache);
+ return -1;
+ }
+ memset(port, '\0', sizeof(ibnd_port_t));
+
+ port_cache->port = port;
+
+ if (ibnd_read(fd, buf, IBND_PORT_CACHE_LEN) < 0)
+ goto cleanup;
+
+ offset += _unmarshall64(buf + offset, &port->guid);
+ offset += _unmarshall8(buf + offset, &tmp8);
+ port->portnum = tmp8;
+ offset += _unmarshall8(buf + offset, &tmp8);
+ port->ext_portnum = tmp8;
+ offset += _unmarshall16(buf + offset, &port->base_lid);
+ offset += _unmarshall8(buf + offset, &port->lmc);
+ offset += _unmarshall_buf(buf + offset, port->info, IB_SMP_DATA_SIZE);
+ offset += _unmarshall64(buf + offset, &port_cache->node_guid);
+ offset += _unmarshall8(buf + offset, &port_cache->remoteport_flag);
+ offset +=
+ _unmarshall64(buf + offset, &port_cache->remoteport_cache_key.guid);
+ offset +=
+ _unmarshall8(buf + offset,
+ &port_cache->remoteport_cache_key.portnum);
+
+ store_port_cache(port_cache, fabric_cache);
+
+ return 0;
+
+cleanup:
+ free(port);
+ free(port_cache);
+ return -1;
+}
+
+static ibnd_port_cache_t *_find_port(ibnd_fabric_cache_t * fabric_cache,
+ ibnd_port_cache_key_t * port_cache_key)
+{
+ int hash_indx = HASHGUID(port_cache_key->guid) % HTSZ;
+ ibnd_port_cache_t *port_cache;
+
+ for (port_cache = fabric_cache->portscachetbl[hash_indx];
+ port_cache; port_cache = port_cache->htnext) {
+ if (port_cache->port->guid == port_cache_key->guid
+ && port_cache->port->portnum == port_cache_key->portnum)
+ return port_cache;
+ }
+
+ return NULL;
+}
+
+static ibnd_node_cache_t *_find_node(ibnd_fabric_cache_t * fabric_cache,
+ uint64_t guid)
+{
+ int hash_indx = HASHGUID(guid) % HTSZ;
+ ibnd_node_cache_t *node_cache;
+
+ for (node_cache = fabric_cache->nodescachetbl[hash_indx];
+ node_cache; node_cache = node_cache->htnext) {
+ if (node_cache->node->guid == guid)
+ return node_cache;
+ }
+
+ return NULL;
+}
+
+static int _fill_port(ibnd_fabric_cache_t * fabric_cache, ibnd_node_t * node,
+ ibnd_port_cache_key_t * port_cache_key)
+{
+ ibnd_port_cache_t *port_cache;
+
+ if (!(port_cache = _find_port(fabric_cache, port_cache_key))) {
+ IBND_DEBUG("Cache invalid: cannot find port\n");
+ return -1;
+ }
+
+ if (port_cache->port_stored_to_fabric) {
+ IBND_DEBUG("Cache invalid: duplicate port discovered\n");
+ return -1;
+ }
+
+ node->ports[port_cache->port->portnum] = port_cache->port;
+ port_cache->port_stored_to_fabric++;
+
+ /* achu: needed if user wishes to re-cache a loaded fabric.
+ * Otherwise, mostly unnecessary to do this.
+ */
+ int rc = add_to_portguid_hash(port_cache->port,
+ fabric_cache->f_int->fabric.portstbl);
+ if (rc) {
+ IBND_DEBUG("Error Occurred when trying"
+ " to insert new port guid 0x%016" PRIx64 " to DB\n",
+ port_cache->port->guid);
+ }
+ return 0;
+}
+
+static int _rebuild_nodes(ibnd_fabric_cache_t * fabric_cache)
+{
+ ibnd_node_cache_t *node_cache;
+ ibnd_node_cache_t *node_cache_next;
+
+ node_cache = fabric_cache->nodes_cache;
+ while (node_cache) {
+ ibnd_node_t *node;
+ int i;
+
+ node_cache_next = node_cache->next;
+
+ node = node_cache->node;
+
+ /* Insert node into appropriate data structures */
+
+ node->next = fabric_cache->f_int->fabric.nodes;
+ fabric_cache->f_int->fabric.nodes = node;
+
+ int rc = add_to_nodeguid_hash(node_cache->node,
+ fabric_cache->
+ f_int->
+ fabric.nodestbl);
+ if (rc) {
+ IBND_DEBUG("Error Occurred when trying"
+ " to insert new node guid 0x%016" PRIx64 " to DB\n",
+ node_cache->node->guid);
+ }
+
+ add_to_type_list(node_cache->node, fabric_cache->f_int);
+
+ node_cache->node_stored_to_fabric++;
+
+ /* Rebuild node ports array */
+
+ if (!(node->ports =
+ calloc(sizeof(*node->ports), node->numports + 1))) {
+ IBND_DEBUG("OOM: node->ports\n");
+ return -1;
+ }
+
+ for (i = 0; i < node_cache->ports_stored_count; i++) {
+ if (_fill_port(fabric_cache, node,
+ &node_cache->port_cache_keys[i]) < 0)
+ return -1;
+ }
+
+ node_cache = node_cache_next;
+ }
+
+ return 0;
+}
+
+static int _rebuild_ports(ibnd_fabric_cache_t * fabric_cache)
+{
+ ibnd_port_cache_t *port_cache;
+ ibnd_port_cache_t *port_cache_next;
+
+ port_cache = fabric_cache->ports_cache;
+ while (port_cache) {
+ ibnd_node_cache_t *node_cache;
+ ibnd_port_cache_t *remoteport_cache;
+ ibnd_port_t *port;
+
+ port_cache_next = port_cache->next;
+
+ port = port_cache->port;
+
+ if (!(node_cache =
+ _find_node(fabric_cache, port_cache->node_guid))) {
+ IBND_DEBUG("Cache invalid: cannot find node\n");
+ return -1;
+ }
+
+ port->node = node_cache->node;
+
+ if (port_cache->remoteport_flag) {
+ if (!(remoteport_cache = _find_port(fabric_cache,
+ &port_cache->remoteport_cache_key)))
+ {
+ IBND_DEBUG
+ ("Cache invalid: cannot find remote port\n");
+ return -1;
+ }
+
+ port->remoteport = remoteport_cache->port;
+ } else
+ port->remoteport = NULL;
+
+ add_to_portlid_hash(port, fabric_cache->f_int->lid2guid);
+ port_cache = port_cache_next;
+ }
+
+ return 0;
+}
+
+ibnd_fabric_t *ibnd_load_fabric(const char *file, unsigned int flags)
+{
+ unsigned int node_count = 0;
+ unsigned int port_count = 0;
+ ibnd_fabric_cache_t *fabric_cache = NULL;
+ f_internal_t *f_int = NULL;
+ ibnd_node_cache_t *node_cache = NULL;
+ int fd = -1;
+ unsigned int i;
+
+ if (!file) {
+ IBND_DEBUG("file parameter NULL\n");
+ return NULL;
+ }
+
+ if ((fd = open(file, O_RDONLY)) < 0) {
+ IBND_DEBUG("open: %s\n", strerror(errno));
+ return NULL;
+ }
+
+ fabric_cache =
+ (ibnd_fabric_cache_t *) malloc(sizeof(ibnd_fabric_cache_t));
+ if (!fabric_cache) {
+ IBND_DEBUG("OOM: fabric_cache\n");
+ goto cleanup;
+ }
+ memset(fabric_cache, '\0', sizeof(ibnd_fabric_cache_t));
+
+ f_int = allocate_fabric_internal();
+ if (!f_int) {
+ IBND_DEBUG("OOM: fabric\n");
+ goto cleanup;
+ }
+
+ fabric_cache->f_int = f_int;
+
+ if (_load_header_info(fd, fabric_cache, &node_count, &port_count) < 0)
+ goto cleanup;
+
+ for (i = 0; i < node_count; i++) {
+ if (_load_node(fd, fabric_cache) < 0)
+ goto cleanup;
+ }
+
+ for (i = 0; i < port_count; i++) {
+ if (_load_port(fd, fabric_cache) < 0)
+ goto cleanup;
+ }
+
+ /* Special case - find from node */
+ if (!(node_cache =
+ _find_node(fabric_cache, fabric_cache->from_node_guid))) {
+ IBND_DEBUG("Cache invalid: cannot find from node\n");
+ goto cleanup;
+ }
+ f_int->fabric.from_node = node_cache->node;
+
+ if (_rebuild_nodes(fabric_cache) < 0)
+ goto cleanup;
+
+ if (_rebuild_ports(fabric_cache) < 0)
+ goto cleanup;
+
+ if (group_nodes(&f_int->fabric))
+ goto cleanup;
+
+ _destroy_ibnd_fabric_cache(fabric_cache);
+ close(fd);
+ return (ibnd_fabric_t *)&f_int->fabric;
+
+cleanup:
+ ibnd_destroy_fabric((ibnd_fabric_t *)f_int);
+ _destroy_ibnd_fabric_cache(fabric_cache);
+ close(fd);
+ return NULL;
+}
+
+static ssize_t ibnd_write(int fd, const void *buf, size_t count)
+{
+ size_t count_done = 0;
+ ssize_t ret;
+
+ while ((count - count_done) > 0) {
+ ret = write(fd, ((char *) buf) + count_done, count - count_done);
+ if (ret < 0) {
+ if (errno == EINTR)
+ continue;
+ else {
+ IBND_DEBUG("write: %s\n", strerror(errno));
+ return -1;
+ }
+ }
+ count_done += ret;
+ }
+ return count_done;
+}
+
+static size_t _marshall8(uint8_t * outbuf, uint8_t num)
+{
+ outbuf[0] = num;
+
+ return (sizeof(num));
+}
+
+static size_t _marshall16(uint8_t * outbuf, uint16_t num)
+{
+ outbuf[0] = num & 0x00FF;
+ outbuf[1] = (num & 0xFF00) >> 8;
+
+ return (sizeof(num));
+}
+
+static size_t _marshall32(uint8_t * outbuf, uint32_t num)
+{
+ outbuf[0] = num & 0x000000FF;
+ outbuf[1] = (num & 0x0000FF00) >> 8;
+ outbuf[2] = (num & 0x00FF0000) >> 16;
+ outbuf[3] = (num & 0xFF000000) >> 24;
+
+ return (sizeof(num));
+}
+
+static size_t _marshall64(uint8_t * outbuf, uint64_t num)
+{
+ outbuf[0] = (uint8_t) num;
+ outbuf[1] = (uint8_t) (num >> 8);
+ outbuf[2] = (uint8_t) (num >> 16);
+ outbuf[3] = (uint8_t) (num >> 24);
+ outbuf[4] = (uint8_t) (num >> 32);
+ outbuf[5] = (uint8_t) (num >> 40);
+ outbuf[6] = (uint8_t) (num >> 48);
+ outbuf[7] = (uint8_t) (num >> 56);
+
+ return (sizeof(num));
+}
+
+static size_t _marshall_buf(void *outbuf, const void *inbuf, unsigned int len)
+{
+ memcpy(outbuf, inbuf, len);
+
+ return len;
+}
+
+static int _cache_header_info(int fd, ibnd_fabric_t * fabric)
+{
+ uint8_t buf[IBND_FABRIC_CACHE_BUFLEN];
+ size_t offset = 0;
+
+ /* Store magic number, version, and other important info */
+ /* For this caching lib, we always assume cached as little endian */
+
+ offset += _marshall32(buf + offset, IBND_FABRIC_CACHE_MAGIC);
+ offset += _marshall32(buf + offset, IBND_FABRIC_CACHE_VERSION);
+ /* save space for node count */
+ offset += _marshall32(buf + offset, 0);
+ /* save space for port count */
+ offset += _marshall32(buf + offset, 0);
+ offset += _marshall64(buf + offset, fabric->from_node->guid);
+ offset += _marshall32(buf + offset, fabric->maxhops_discovered);
+
+ if (ibnd_write(fd, buf, offset) < 0)
+ return -1;
+
+ return 0;
+}
+
+static int _cache_header_counts(int fd, unsigned int node_count,
+ unsigned int port_count)
+{
+ uint8_t buf[IBND_FABRIC_CACHE_BUFLEN];
+ size_t offset = 0;
+
+ offset += _marshall32(buf + offset, node_count);
+ offset += _marshall32(buf + offset, port_count);
+
+ if (lseek(fd, IBND_FABRIC_CACHE_COUNT_OFFSET, SEEK_SET) < 0) {
+ IBND_DEBUG("lseek: %s\n", strerror(errno));
+ return -1;
+ }
+
+ if (ibnd_write(fd, buf, offset) < 0)
+ return -1;
+
+ return 0;
+}
+
+static int _cache_node(int fd, ibnd_node_t * node)
+{
+ uint8_t buf[IBND_FABRIC_CACHE_BUFLEN];
+ size_t offset = 0;
+ size_t ports_stored_offset = 0;
+ uint8_t ports_stored_count = 0;
+ int i;
+
+ offset += _marshall16(buf + offset, node->smalid);
+ offset += _marshall8(buf + offset, node->smalmc);
+ offset += _marshall8(buf + offset, (uint8_t) node->smaenhsp0);
+ offset += _marshall_buf(buf + offset, node->switchinfo,
+ IB_SMP_DATA_SIZE);
+ offset += _marshall64(buf + offset, node->guid);
+ offset += _marshall8(buf + offset, (uint8_t) node->type);
+ offset += _marshall8(buf + offset, (uint8_t) node->numports);
+ offset += _marshall_buf(buf + offset, node->info, IB_SMP_DATA_SIZE);
+ offset += _marshall_buf(buf + offset, node->nodedesc, IB_SMP_DATA_SIZE);
+ /* need to come back later and store number of stored ports
+ * because port entries can be NULL or (in the case of switches)
+ * there is an additional port 0 not accounted for in numports.
+ */
+ ports_stored_offset = offset;
+ offset += sizeof(uint8_t);
+
+ for (i = 0; i <= node->numports; i++) {
+ if (node->ports[i]) {
+ offset += _marshall64(buf + offset,
+ node->ports[i]->guid);
+ offset += _marshall8(buf + offset,
+ (uint8_t) node->ports[i]->portnum);
+ ports_stored_count++;
+ }
+ }
+
+ /* go back and store number of port keys stored */
+ _marshall8(buf + ports_stored_offset, ports_stored_count);
+
+ if (ibnd_write(fd, buf, offset) < 0)
+ return -1;
+
+ return 0;
+}
+
+static int _cache_port(int fd, ibnd_port_t * port)
+{
+ uint8_t buf[IBND_FABRIC_CACHE_BUFLEN];
+ size_t offset = 0;
+
+ offset += _marshall64(buf + offset, port->guid);
+ offset += _marshall8(buf + offset, (uint8_t) port->portnum);
+ offset += _marshall8(buf + offset, (uint8_t) port->ext_portnum);
+ offset += _marshall16(buf + offset, port->base_lid);
+ offset += _marshall8(buf + offset, port->lmc);
+ offset += _marshall_buf(buf + offset, port->info, IB_SMP_DATA_SIZE);
+ offset += _marshall64(buf + offset, port->node->guid);
+ if (port->remoteport) {
+ offset += _marshall8(buf + offset, 1);
+ offset += _marshall64(buf + offset, port->remoteport->guid);
+ offset += _marshall8(buf + offset, (uint8_t) port->remoteport->portnum);
+ } else {
+ offset += _marshall8(buf + offset, 0);
+ offset += _marshall64(buf + offset, 0);
+ offset += _marshall8(buf + offset, 0);
+ }
+
+ if (ibnd_write(fd, buf, offset) < 0)
+ return -1;
+
+ return 0;
+}
+
+int ibnd_cache_fabric(ibnd_fabric_t * fabric, const char *file,
+ unsigned int flags)
+{
+ struct stat statbuf;
+ ibnd_node_t *node = NULL;
+ ibnd_node_t *node_next = NULL;
+ unsigned int node_count = 0;
+ ibnd_port_t *port = NULL;
+ ibnd_port_t *port_next = NULL;
+ unsigned int port_count = 0;
+ int fd;
+ int i;
+
+ if (!fabric) {
+ IBND_DEBUG("fabric parameter NULL\n");
+ return -1;
+ }
+
+ if (!file) {
+ IBND_DEBUG("file parameter NULL\n");
+ return -1;
+ }
+
+ if (!(flags & IBND_CACHE_FABRIC_FLAG_NO_OVERWRITE)) {
+ if (!stat(file, &statbuf)) {
+ if (unlink(file) < 0) {
+ IBND_DEBUG("error removing '%s': %s\n",
+ file, strerror(errno));
+ return -1;
+ }
+ }
+ }
+ else {
+ if (!stat(file, &statbuf)) {
+ IBND_DEBUG("file '%s' already exists\n", file);
+ return -1;
+ }
+ }
+
+ if ((fd = open(file, O_CREAT | O_EXCL | O_WRONLY, 0644)) < 0) {
+ IBND_DEBUG("open: %s\n", strerror(errno));
+ return -1;
+ }
+
+ if (_cache_header_info(fd, fabric) < 0)
+ goto cleanup;
+
+ node = fabric->nodes;
+ while (node) {
+ node_next = node->next;
+
+ if (_cache_node(fd, node) < 0)
+ goto cleanup;
+
+ node_count++;
+ node = node_next;
+ }
+
+ for (i = 0; i < HTSZ; i++) {
+ port = fabric->portstbl[i];
+ while (port) {
+ port_next = port->htnext;
+
+ if (_cache_port(fd, port) < 0)
+ goto cleanup;
+
+ port_count++;
+ port = port_next;
+ }
+ }
+
+ if (_cache_header_counts(fd, node_count, port_count) < 0)
+ goto cleanup;
+
+ if (close(fd) < 0) {
+ IBND_DEBUG("close: %s\n", strerror(errno));
+ goto cleanup;
+ }
+
+ return 0;
+
+cleanup:
+ unlink(file);
+ close(fd);
+ return -1;
+}
diff --git a/contrib/ofed/libibnetdisc/ibnetdisc_osd.h b/contrib/ofed/libibnetdisc/ibnetdisc_osd.h
new file mode 100644
index 0000000..44288d3
--- /dev/null
+++ b/contrib/ofed/libibnetdisc/ibnetdisc_osd.h
@@ -0,0 +1,50 @@
+/*
+ * Copyright (c) 2011 Lawrence Livermore National Security. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+#ifndef _IBNETDISC_OSD_H_
+#define _IBNETDISC_OSD_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* Define OS specific bits */
+
+/* Linux */
+#define IBND_EXPORT
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _IBNETDISC_OSD_H_ */
diff --git a/contrib/ofed/libibnetdisc/internal.h b/contrib/ofed/libibnetdisc/internal.h
new file mode 100644
index 0000000..f2e08e8
--- /dev/null
+++ b/contrib/ofed/libibnetdisc/internal.h
@@ -0,0 +1,130 @@
+/*
+ * Copyright (c) 2008 Lawrence Livermore National Laboratory
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+/** =========================================================================
+ * Define the internal data structures.
+ */
+
+#ifndef _INTERNAL_H_
+#define _INTERNAL_H_
+
+#include <infiniband/ibnetdisc.h>
+#include <complib/cl_qmap.h>
+
+#define IBND_DEBUG(fmt, ...) \
+ if (ibdebug) { \
+ printf("%s:%u; " fmt, __FILE__, __LINE__, ## __VA_ARGS__); \
+ }
+#define IBND_ERROR(fmt, ...) \
+ fprintf(stderr, "%s:%u; " fmt, __FILE__, __LINE__, ## __VA_ARGS__)
+
+/* HASH table defines */
+#define HASHGUID(guid) ((uint32_t)(((uint32_t)(guid) * 101) ^ ((uint32_t)((guid) >> 32) * 103)))
+
+#define MAXHOPS 63
+
+#define DEFAULT_MAX_SMP_ON_WIRE 2
+#define DEFAULT_TIMEOUT 1000
+#define DEFAULT_RETRIES 3
+
+#define GINT_TO_POINTER(x) ((void *)(uintptr_t)(x))
+
+typedef struct GHashTable GHashTable;
+
+#define g_hash_table_new_full(...) GHashTableNew()
+#define g_hash_table_destroy(...) GHashTableDestroy(__VA_ARGS__)
+#define g_hash_table_insert(...) GHashTableInsert(__VA_ARGS__)
+#define g_hash_table_lookup(...) GHashTableLookup(__VA_ARGS__)
+
+extern GHashTable *GHashTableNew(void);
+extern void GHashTableDestroy(GHashTable *);
+extern void GHashTableInsert(GHashTable *, void *key, void *value);
+extern void *GHashTableLookup(GHashTable *, void *key);
+
+typedef struct f_internal {
+ ibnd_fabric_t fabric;
+ GHashTable *lid2guid;
+} f_internal_t;
+f_internal_t *allocate_fabric_internal(void);
+void create_lid2guid(f_internal_t *f_int);
+void destroy_lid2guid(f_internal_t *f_int);
+void add_to_portlid_hash(ibnd_port_t * port, GHashTable *htable);
+
+typedef struct ibnd_scan {
+ ib_portid_t selfportid;
+ f_internal_t *f_int;
+ struct ibnd_config *cfg;
+ unsigned initial_hops;
+} ibnd_scan_t;
+
+typedef struct ibnd_smp ibnd_smp_t;
+typedef struct smp_engine smp_engine_t;
+typedef int (*smp_comp_cb_t) (smp_engine_t * engine, ibnd_smp_t * smp,
+ uint8_t * mad_resp, void *cb_data);
+struct ibnd_smp {
+ cl_map_item_t on_wire;
+ struct ibnd_smp *qnext;
+ smp_comp_cb_t cb;
+ void *cb_data;
+ ib_portid_t path;
+ ib_rpc_t rpc;
+};
+
+struct smp_engine {
+ int umad_fd;
+ int smi_agent;
+ int smi_dir_agent;
+ ibnd_smp_t *smp_queue_head;
+ ibnd_smp_t *smp_queue_tail;
+ void *user_data;
+ cl_qmap_t smps_on_wire;
+ struct ibnd_config *cfg;
+ unsigned total_smps;
+};
+
+int smp_engine_init(smp_engine_t * engine, char * ca_name, int ca_port,
+ void *user_data, ibnd_config_t *cfg);
+int issue_smp(smp_engine_t * engine, ib_portid_t * portid,
+ unsigned attrid, unsigned mod, smp_comp_cb_t cb, void *cb_data);
+int process_mads(smp_engine_t * engine);
+void smp_engine_destroy(smp_engine_t * engine);
+
+int add_to_nodeguid_hash(ibnd_node_t * node, ibnd_node_t * hash[]);
+
+int add_to_portguid_hash(ibnd_port_t * port, ibnd_port_t * hash[]);
+
+void add_to_type_list(ibnd_node_t * node, f_internal_t * fabric);
+
+void destroy_node(ibnd_node_t * node);
+
+#endif /* _INTERNAL_H_ */
diff --git a/contrib/ofed/libibnetdisc/libibnetdisc.map b/contrib/ofed/libibnetdisc/libibnetdisc.map
new file mode 100644
index 0000000..f1b7229
--- /dev/null
+++ b/contrib/ofed/libibnetdisc/libibnetdisc.map
@@ -0,0 +1,22 @@
+IBNETDISC_1.0 {
+ global:
+ ibnd_discover_fabric;
+ ibnd_destroy_fabric;
+ ibnd_load_fabric;
+ ibnd_cache_fabric;
+ ibnd_find_node_guid;
+ ibnd_find_node_dr;
+ ibnd_is_xsigo_guid;
+ ibnd_is_xsigo_tca;
+ ibnd_is_xsigo_hca;
+ ibnd_get_chassis_guid;
+ ibnd_get_chassis_type;
+ ibnd_get_chassis_slot_str;
+ ibnd_iter_nodes;
+ ibnd_iter_nodes_type;
+ ibnd_find_port_guid;
+ ibnd_find_port_dr;
+ ibnd_find_port_lid;
+ ibnd_iter_ports;
+ local: *;
+};
diff --git a/contrib/ofed/libibnetdisc/man/ibnd_debug.3 b/contrib/ofed/libibnetdisc/man/ibnd_debug.3
new file mode 100644
index 0000000..a4076fc
--- /dev/null
+++ b/contrib/ofed/libibnetdisc/man/ibnd_debug.3
@@ -0,0 +1,2 @@
+.\".TH IBND_DEBUG 3 "Aug 04, 2008" "OpenIB" "OpenIB Programmer's Manual"
+.so man3/ibnd_discover_fabric.3
diff --git a/contrib/ofed/libibnetdisc/man/ibnd_destroy_fabric.3 b/contrib/ofed/libibnetdisc/man/ibnd_destroy_fabric.3
new file mode 100644
index 0000000..8fe20ae
--- /dev/null
+++ b/contrib/ofed/libibnetdisc/man/ibnd_destroy_fabric.3
@@ -0,0 +1,2 @@
+.\".TH IBND_DESTROY_FABRIC 3 "Aug 04, 2008" "OpenIB" "OpenIB Programmer's Manual"
+.so man3/ibnd_discover_fabric.3
diff --git a/contrib/ofed/libibnetdisc/man/ibnd_discover_fabric.3 b/contrib/ofed/libibnetdisc/man/ibnd_discover_fabric.3
new file mode 100644
index 0000000..5471af0
--- /dev/null
+++ b/contrib/ofed/libibnetdisc/man/ibnd_discover_fabric.3
@@ -0,0 +1,65 @@
+.TH IBND_DISCOVER_FABRIC 3 "July 25, 2008" "OpenIB" "OpenIB Programmer's Manual"
+.SH "NAME"
+ibnd_discover_fabric, ibnd_destroy_fabric, ibnd_debug ibnd_show_progress \- initialize ibnetdiscover library.
+.SH "SYNOPSIS"
+.nf
+.B #include <infiniband/ibnetdisc.h>
+.sp
+.bi "ibnd_fabric_t *ibnd_discover_fabric(struct ibmad_port *ibmad_port, int timeout_ms, ib_portid_t *from, int hops)"
+.BI "void ibnd_destroy_fabric(ibnd_fabric_t *fabric)"
+.BI "void ibnd_debug(int i)"
+.BI "void ibnd_show_progress(int i)"
+.BI "int ibnd_set_max_smps_on_wire(int i)"
+.SH "DESCRIPTION"
+.B ibnd_discover_fabric()
+Discover the fabric connected to the port specified by ibmad_port, using a timeout specified. The "from" and "hops" parameters are optional and allow one to scan part of a fabric by specifying a node "from" and a number of hops away from that node to scan, "hops". This gives the user a "sub-fabric" which is "centered" anywhere they chose.
+
+ibmad_port must be opened with at least IB_SMI_CLASS and IB_SMI_DIRECT_CLASS
+classes for ibnd_discover_fabric to work.
+
+.B ibnd_destroy_fabric()
+free all memory and resources associated with the fabric.
+
+.B ibnd_debug()
+Set the debug level to be printed as library operations take place.
+
+.B ibnd_show_progress()
+Indicate that the library should print debug output which shows it's progress
+through the fabric.
+
+.B ibnd_set_max_smps_on_wire()
+Set the number of SMP\'s which will be issued on the wire simultaneously.
+
+.SH "RETURN VALUE"
+.B ibnd_discover_fabric()
+return NULL on failure, otherwise a valid ibnd_fabric_t object.
+
+.B ibnd_destory_fabric(), ibnd_debug()
+NONE
+
+.B ibnd_set_max_smps_on_wire()
+The previous value is returned
+
+.SH "EXAMPLES"
+
+.B Discover the entire fabric connected to device "mthca0", port 1.
+
+ int mgmt_classes[2] = {IB_SMI_CLASS, IB_SMI_DIRECT_CLASS};
+ struct ibmad_port *ibmad_port = mad_rpc_open_port(ca, ca_port, mgmt_classes, 2);
+ ibnd_fabric_t *fabric = ibnd_discover_fabric(ibmad_port, 100, NULL, 0);
+ ...
+ ibnd_destroy_fabric(fabric);
+ mad_rpc_close_port(ibmad_port);
+
+.B Discover only a single node and those nodes connected to it.
+
+ ...
+ str2drpath(&(port_id.drpath), from, 0, 0);
+ ...
+ ibnd_discover_fabric(ibmad_port, 100, &port_id, 1);
+ ...
+.SH "SEE ALSO"
+ libibmad, mad_rpc_open_port
+.SH "AUTHORS"
+.TP
+Ira Weiny <weiny2@llnl.gov>
diff --git a/contrib/ofed/libibnetdisc/man/ibnd_find_node_dr.3 b/contrib/ofed/libibnetdisc/man/ibnd_find_node_dr.3
new file mode 100644
index 0000000..612e501
--- /dev/null
+++ b/contrib/ofed/libibnetdisc/man/ibnd_find_node_dr.3
@@ -0,0 +1,2 @@
+.\".TH IBND_FIND_NODE_DR 3 "Aug 04, 2008" "OpenIB" "OpenIB Programmer's Manual"
+.so man3/ibnd_find_node_guid.3
diff --git a/contrib/ofed/libibnetdisc/man/ibnd_find_node_guid.3 b/contrib/ofed/libibnetdisc/man/ibnd_find_node_guid.3
new file mode 100644
index 0000000..2d0cb63
--- /dev/null
+++ b/contrib/ofed/libibnetdisc/man/ibnd_find_node_guid.3
@@ -0,0 +1,21 @@
+.TH IBND_FIND_NODE_GUID 3 "July 25, 2008" "OpenIB" "OpenIB Programmer's Manual"
+.SH "NAME"
+ibnd_find_node_guid, ibnd_find_node_dr \- given a fabric object find the node object within it which matches the guid or directed route specified.
+.SH "SYNOPSIS"
+.nf
+.B #include <infiniband/ibnetdisc.h>
+.sp
+.BI "ibnd_node_t *ibnd_find_node_guid(ibnd_fabric_t *fabric, uint64_t guid)"
+.BI "ibnd_node_t *ibnd_find_node_dr(ibnd_fabric_t *fabric, char *dr_str)"
+.SH "DESCRIPTION"
+.B ibnd_find_node_guid()
+Given a fabric object and a guid, return the ibnd_node_t object with that node guid.
+.B ibnd_find_node_dr()
+Given a fabric object and a directed route, return the ibnd_node_t object with
+that directed route.
+.SH "RETURN VALUE"
+.B ibnd_find_node_guid(), ibnd_find_node_dr()
+return NULL on failure, otherwise a valid ibnd_node_t object.
+.SH "AUTHORS"
+.TP
+Ira Weiny <weiny2@llnl.gov>
diff --git a/contrib/ofed/libibnetdisc/man/ibnd_iter_nodes.3 b/contrib/ofed/libibnetdisc/man/ibnd_iter_nodes.3
new file mode 100644
index 0000000..469f07b
--- /dev/null
+++ b/contrib/ofed/libibnetdisc/man/ibnd_iter_nodes.3
@@ -0,0 +1,20 @@
+.TH IBND_ITER_NODES 3 "July 25, 2008" "OpenIB" "OpenIB Programmer's Manual"
+.SH "NAME"
+ibnd_iter_nodes, ibnd_iter_nodes_type \- given a fabric object and a function itterate over the nodes in the fabric.
+.SH "SYNOPSIS"
+.nf
+.B #include <infiniband/ibnetdisc.h>
+.sp
+.BI "void ibnd_iter_nodes(ibnd_fabric_t *fabric, ibnd_iter_func_t func, void *user_data)"
+.BI "void ibnd_iter_nodes_type(ibnd_fabric_t *fabric, ibnd_iter_func_t func, ibnd_node_type_t type, void *user_data)"
+.SH "DESCRIPTION"
+.B ibnd_iter_nodes()
+Itterate through all the nodes in the fabric and call "func" on them.
+.B ibnd_iter_nodes_type()
+The same as ibnd_iter_nodes except to limit the iteration to the nodes with the specified type.
+.SH "RETURN VALUE"
+.B ibnd_iter_nodes(), ibnd_iter_nodes_type()
+NONE
+.SH "AUTHORS"
+.TP
+Ira Weiny <weiny2@llnl.gov>
diff --git a/contrib/ofed/libibnetdisc/man/ibnd_iter_nodes_type.3 b/contrib/ofed/libibnetdisc/man/ibnd_iter_nodes_type.3
new file mode 100644
index 0000000..dc3ac8f
--- /dev/null
+++ b/contrib/ofed/libibnetdisc/man/ibnd_iter_nodes_type.3
@@ -0,0 +1,2 @@
+.\".TH IBND_FIND_NODES_TYPE 3 "Aug 04, 2008" "OpenIB" "OpenIB Programmer's Manual"
+.so man3/ibnd_iter_nodes.3
diff --git a/contrib/ofed/libibnetdisc/man/ibnd_show_progress.3 b/contrib/ofed/libibnetdisc/man/ibnd_show_progress.3
new file mode 100644
index 0000000..280af31
--- /dev/null
+++ b/contrib/ofed/libibnetdisc/man/ibnd_show_progress.3
@@ -0,0 +1,2 @@
+.\".TH IBND_SHOW_PROGRESS 3 "Nov 26, 2008" "OpenIB" "OpenIB Programmer's Manual"
+.so man3/ibnd_discover_fabric.3
diff --git a/contrib/ofed/libibnetdisc/query_smp.c b/contrib/ofed/libibnetdisc/query_smp.c
new file mode 100644
index 0000000..8f179e4
--- /dev/null
+++ b/contrib/ofed/libibnetdisc/query_smp.c
@@ -0,0 +1,286 @@
+/*
+ * Copyright (c) 2010 Lawrence Livermore National Laboratory
+ * Copyright (c) 2011 Mellanox Technologies LTD. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+#if HAVE_CONFIG_H
+# include <config.h>
+#endif /* HAVE_CONFIG_H */
+
+#include <errno.h>
+#include <infiniband/ibnetdisc.h>
+#include <infiniband/umad.h>
+#include "internal.h"
+
+extern int mlnx_ext_port_info_err(smp_engine_t * engine, ibnd_smp_t * smp,
+ uint8_t * mad, void *cb_data);
+
+static void queue_smp(smp_engine_t * engine, ibnd_smp_t * smp)
+{
+ smp->qnext = NULL;
+ if (!engine->smp_queue_head) {
+ engine->smp_queue_head = smp;
+ engine->smp_queue_tail = smp;
+ } else {
+ engine->smp_queue_tail->qnext = smp;
+ engine->smp_queue_tail = smp;
+ }
+}
+
+static ibnd_smp_t *get_smp(smp_engine_t * engine)
+{
+ ibnd_smp_t *head = engine->smp_queue_head;
+ ibnd_smp_t *tail = engine->smp_queue_tail;
+ ibnd_smp_t *rc = head;
+ if (head) {
+ if (tail == head)
+ engine->smp_queue_tail = NULL;
+ engine->smp_queue_head = head->qnext;
+ }
+ return rc;
+}
+
+static int send_smp(ibnd_smp_t * smp, smp_engine_t * engine)
+{
+ int rc = 0;
+ uint8_t umad[1024];
+ ib_rpc_t *rpc = &smp->rpc;
+ int agent = 0;
+
+ memset(umad, 0, umad_size() + IB_MAD_SIZE);
+
+ if (rpc->mgtclass == IB_SMI_CLASS) {
+ agent = engine->smi_agent;
+ } else if (rpc->mgtclass == IB_SMI_DIRECT_CLASS) {
+ agent = engine->smi_dir_agent;
+ } else {
+ IBND_ERROR("Invalid class for RPC\n");
+ return (-EIO);
+ }
+
+ if ((rc = mad_build_pkt(umad, &smp->rpc, &smp->path, NULL, NULL))
+ < 0) {
+ IBND_ERROR("mad_build_pkt failed; %d\n", rc);
+ return rc;
+ }
+
+ if ((rc = umad_send(engine->umad_fd, agent, umad, IB_MAD_SIZE,
+ engine->cfg->timeout_ms, engine->cfg->retries)) < 0) {
+ IBND_ERROR("send failed; %d\n", rc);
+ return rc;
+ }
+
+ return 0;
+}
+
+static int process_smp_queue(smp_engine_t * engine)
+{
+ int rc = 0;
+ ibnd_smp_t *smp;
+ while (cl_qmap_count(&engine->smps_on_wire)
+ < engine->cfg->max_smps) {
+ smp = get_smp(engine);
+ if (!smp)
+ return 0;
+
+ if ((rc = send_smp(smp, engine)) != 0) {
+ free(smp);
+ return rc;
+ }
+ cl_qmap_insert(&engine->smps_on_wire, (uint32_t) smp->rpc.trid,
+ (cl_map_item_t *) smp);
+ engine->total_smps++;
+ }
+ return 0;
+}
+
+int issue_smp(smp_engine_t * engine, ib_portid_t * portid,
+ unsigned attrid, unsigned mod, smp_comp_cb_t cb, void *cb_data)
+{
+ ibnd_smp_t *smp = calloc(1, sizeof *smp);
+ if (!smp) {
+ IBND_ERROR("OOM\n");
+ return -ENOMEM;
+ }
+
+ smp->cb = cb;
+ smp->cb_data = cb_data;
+ smp->path = *portid;
+ smp->rpc.method = IB_MAD_METHOD_GET;
+ smp->rpc.attr.id = attrid;
+ smp->rpc.attr.mod = mod;
+ smp->rpc.timeout = engine->cfg->timeout_ms;
+ smp->rpc.datasz = IB_SMP_DATA_SIZE;
+ smp->rpc.dataoffs = IB_SMP_DATA_OFFS;
+ smp->rpc.trid = mad_trid();
+ smp->rpc.mkey = engine->cfg->mkey;
+
+ if (portid->lid <= 0 || portid->drpath.drslid == 0xffff ||
+ portid->drpath.drdlid == 0xffff)
+ smp->rpc.mgtclass = IB_SMI_DIRECT_CLASS; /* direct SMI */
+ else
+ smp->rpc.mgtclass = IB_SMI_CLASS; /* Lid routed SMI */
+
+ portid->sl = 0;
+ portid->qp = 0;
+
+ queue_smp(engine, smp);
+ return process_smp_queue(engine);
+}
+
+static int process_one_recv(smp_engine_t * engine)
+{
+ int rc = 0;
+ int status = 0;
+ ibnd_smp_t *smp;
+ uint8_t *mad;
+ uint32_t trid;
+ uint8_t umad[sizeof(struct ib_user_mad) + IB_MAD_SIZE];
+ int length = umad_size() + IB_MAD_SIZE;
+
+ memset(umad, 0, sizeof(umad));
+
+ /* wait for the next message */
+ if ((rc = umad_recv(engine->umad_fd, umad, &length,
+ -1)) < 0) {
+ IBND_ERROR("umad_recv failed: %d\n", rc);
+ return -1;
+ }
+
+ mad = umad_get_mad(umad);
+ trid = (uint32_t) mad_get_field64(mad, 0, IB_MAD_TRID_F);
+
+ smp = (ibnd_smp_t *) cl_qmap_remove(&engine->smps_on_wire, trid);
+ if ((cl_map_item_t *) smp == cl_qmap_end(&engine->smps_on_wire)) {
+ IBND_ERROR("Failed to find matching smp for trid (%x)\n", trid);
+ return -1;
+ }
+
+ rc = process_smp_queue(engine);
+ if (rc)
+ goto error;
+
+ if ((status = umad_status(umad))) {
+ IBND_ERROR("umad (%s Attr 0x%x:%u) bad status %d; %s\n",
+ portid2str(&smp->path), smp->rpc.attr.id,
+ smp->rpc.attr.mod, status, strerror(status));
+ if (smp->rpc.attr.id == IB_ATTR_MLNX_EXT_PORT_INFO)
+ rc = mlnx_ext_port_info_err(engine, smp, mad,
+ smp->cb_data);
+ } else if ((status = mad_get_field(mad, 0, IB_DRSMP_STATUS_F))) {
+ IBND_ERROR("mad (%s Attr 0x%x:%u) bad status 0x%x\n",
+ portid2str(&smp->path), smp->rpc.attr.id,
+ smp->rpc.attr.mod, status);
+ if (smp->rpc.attr.id == IB_ATTR_MLNX_EXT_PORT_INFO)
+ rc = mlnx_ext_port_info_err(engine, smp, mad,
+ smp->cb_data);
+ } else
+ rc = smp->cb(engine, smp, mad, smp->cb_data);
+
+error:
+ free(smp);
+ return rc;
+}
+
+int smp_engine_init(smp_engine_t * engine, char * ca_name, int ca_port,
+ void *user_data, ibnd_config_t *cfg)
+{
+ memset(engine, 0, sizeof(*engine));
+
+ if (umad_init() < 0) {
+ IBND_ERROR("umad_init failed\n");
+ return -EIO;
+ }
+
+ engine->umad_fd = umad_open_port(ca_name, ca_port);
+ if (engine->umad_fd < 0) {
+ IBND_ERROR("can't open UMAD port (%s:%d)\n", ca_name, ca_port);
+ return -EIO;
+ }
+
+ if ((engine->smi_agent = umad_register(engine->umad_fd,
+ IB_SMI_CLASS, 1, 0, 0)) < 0) {
+ IBND_ERROR("Failed to register SMI agent on (%s:%d)\n",
+ ca_name, ca_port);
+ goto eio_close;
+ }
+
+ if ((engine->smi_dir_agent = umad_register(engine->umad_fd,
+ IB_SMI_DIRECT_CLASS, 1, 0, 0)) < 0) {
+ IBND_ERROR("Failed to register SMI_DIRECT agent on (%s:%d)\n",
+ ca_name, ca_port);
+ goto eio_close;
+ }
+
+ engine->user_data = user_data;
+ cl_qmap_init(&engine->smps_on_wire);
+ engine->cfg = cfg;
+ return (0);
+
+eio_close:
+ umad_close_port(engine->umad_fd);
+ return (-EIO);
+}
+
+void smp_engine_destroy(smp_engine_t * engine)
+{
+ cl_map_item_t *item;
+ ibnd_smp_t *smp;
+
+ /* remove queued smps */
+ smp = get_smp(engine);
+ if (smp)
+ IBND_ERROR("outstanding SMP's\n");
+ for ( /* */ ; smp; smp = get_smp(engine))
+ free(smp);
+
+ /* remove smps from the wire queue */
+ item = cl_qmap_head(&engine->smps_on_wire);
+ if (item != cl_qmap_end(&engine->smps_on_wire))
+ IBND_ERROR("outstanding SMP's on wire\n");
+ for ( /* */ ; item != cl_qmap_end(&engine->smps_on_wire);
+ item = cl_qmap_head(&engine->smps_on_wire)) {
+ cl_qmap_remove_item(&engine->smps_on_wire, item);
+ free(item);
+ }
+
+ umad_close_port(engine->umad_fd);
+}
+
+int process_mads(smp_engine_t * engine)
+{
+ int rc;
+ while (!cl_is_qmap_empty(&engine->smps_on_wire))
+ if ((rc = process_one_recv(engine)) != 0)
+ return rc;
+ return 0;
+}
diff --git a/contrib/ofed/libibumad/Makefile b/contrib/ofed/libibumad/Makefile
new file mode 100644
index 0000000..af7ac3f
--- /dev/null
+++ b/contrib/ofed/libibumad/Makefile
@@ -0,0 +1,16 @@
+# $FreeBSD$
+
+.PATH: ${.CURDIR}
+
+SHLIBDIR?= /usr/lib
+LIB= ibumad
+SHLIB_MAJOR= 1
+MK_PROFILE= no
+SRCS= \
+umad.c \
+umad_str.c \
+sysfs.c
+CFLAGS+= -I${.CURDIR}
+VERSION_MAP= ${.CURDIR}/libibumad.map
+
+.include <bsd.lib.mk>
diff --git a/contrib/ofed/libibumad/config.h b/contrib/ofed/libibumad/config.h
new file mode 100644
index 0000000..85bb772
--- /dev/null
+++ b/contrib/ofed/libibumad/config.h
@@ -0,0 +1,3 @@
+#include <sys/socket.h>
+
+#define VALGRIND_MAKE_MEM_DEFINED(...) 0
diff --git a/contrib/ofed/libibumad/libibumad.map b/contrib/ofed/libibumad/libibumad.map
new file mode 100644
index 0000000..8bf474e
--- /dev/null
+++ b/contrib/ofed/libibumad/libibumad.map
@@ -0,0 +1,41 @@
+/* Do not change this file without reading Documentation/versioning.md */
+IBUMAD_1.0 {
+ global:
+ umad_init;
+ umad_done;
+ umad_get_cas_names;
+ umad_get_ca_portguids;
+ umad_open_port;
+ umad_get_ca;
+ umad_release_ca;
+ umad_get_port;
+ umad_release_port;
+ umad_close_port;
+ umad_get_mad;
+ umad_get_issm_path;
+ umad_size;
+ umad_set_grh;
+ umad_set_pkey;
+ umad_get_pkey;
+ umad_set_addr;
+ umad_set_addr_net;
+ umad_send;
+ umad_recv;
+ umad_poll;
+ umad_get_fd;
+ umad_register;
+ umad_register2;
+ umad_register_oui;
+ umad_unregister;
+ umad_status;
+ umad_get_mad_addr;
+ umad_debug;
+ umad_addr_dump;
+ umad_dump;
+ umad_class_str;
+ umad_method_str;
+ umad_common_mad_status_str;
+ umad_sa_mad_status_str;
+ umad_attribute_str;
+ local: *;
+};
diff --git a/contrib/ofed/libibumad/sysfs.c b/contrib/ofed/libibumad/sysfs.c
new file mode 100644
index 0000000..dfdcadf
--- /dev/null
+++ b/contrib/ofed/libibumad/sysfs.c
@@ -0,0 +1,273 @@
+/*
+ * Copyright (c) 2004-2008 Voltaire Inc. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+#include <config.h>
+
+#include <infiniband/endian.h>
+#include <inttypes.h>
+#include <string.h>
+#include <errno.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <sys/sysctl.h>
+#include <fcntl.h>
+#include <dirent.h>
+#include "sysfs.h"
+
+static int ret_code(void)
+{
+ int e = errno;
+
+ if (e > 0)
+ return -e;
+ return e;
+}
+
+int sys_read_string(const char *dir_name, const char *file_name, char *str, int max_len)
+{
+ char path[256], *s;
+ size_t len;
+
+ snprintf(path, sizeof(path), "%s/%s", dir_name, file_name);
+
+ for (s = &path[0]; *s != '\0'; s++)
+ if (*s == '/')
+ *s = '.';
+
+ len = max_len;
+ if (sysctlbyname(&path[1], str, &len, NULL, 0) == -1)
+ return ret_code();
+
+ str[(len < max_len) ? len : max_len - 1] = 0;
+
+ if ((s = strrchr(str, '\n')))
+ *s = 0;
+
+ return 0;
+}
+
+int sys_read_guid(const char *dir_name, const char *file_name, __be64 *net_guid)
+{
+ char buf[32], *str, *s;
+ uint64_t guid;
+ int r, i;
+
+ if ((r = sys_read_string(dir_name, file_name, buf, sizeof(buf))) < 0)
+ return r;
+
+ guid = 0;
+
+ for (s = buf, i = 0; i < 4; i++) {
+ if (!(str = strsep(&s, ": \t\n")))
+ return -EINVAL;
+ guid = (guid << 16) | (strtoul(str, NULL, 16) & 0xffff);
+ }
+
+ *net_guid = htobe64(guid);
+
+ return 0;
+}
+
+int sys_read_gid(const char *dir_name, const char *file_name,
+ union umad_gid *gid)
+{
+ char buf[64], *str, *s;
+ __be16 *ugid = (__be16 *) gid;
+ int r, i;
+
+ if ((r = sys_read_string(dir_name, file_name, buf, sizeof(buf))) < 0)
+ return r;
+
+ for (s = buf, i = 0; i < 8; i++) {
+ if (!(str = strsep(&s, ": \t\n")))
+ return -EINVAL;
+ ugid[i] = htobe16(strtoul(str, NULL, 16) & 0xffff);
+ }
+
+ return 0;
+}
+
+int sys_read_uint64(const char *dir_name, const char *file_name, uint64_t * u)
+{
+ char buf[32];
+ int r;
+
+ if ((r = sys_read_string(dir_name, file_name, buf, sizeof(buf))) < 0)
+ return r;
+
+ *u = strtoull(buf, NULL, 0);
+
+ return 0;
+}
+
+int sys_read_uint(const char *dir_name, const char *file_name, unsigned *u)
+{
+ char buf[32];
+ int r;
+
+ if ((r = sys_read_string(dir_name, file_name, buf, sizeof(buf))) < 0)
+ return r;
+
+ *u = strtoul(buf, NULL, 0);
+
+ return 0;
+}
+
+#define DIRECTSIZ(namlen) \
+ (((uintptr_t)&((struct dirent *)0)->d_name + \
+ ((namlen)+1)*sizeof(((struct dirent *)0)->d_name[0]) + 3) & ~3)
+
+int
+sys_scandir(const char *dirname, struct dirent ***namelist,
+ int (*select)(const struct dirent *),
+ int (*compar)(const struct dirent **, const struct dirent **))
+{
+ struct dirent **names;
+ struct dirent **names2;
+ struct dirent *dp;
+ char name[1024];
+ int lsname[22];
+ int chname[22];
+ int name2[22];
+ int oid[22];
+ char *s;
+ size_t n1, n2;
+ size_t len, oidlen, namlen;
+ int cnt, max;
+ int err;
+ int i;
+
+ *namelist = NULL;
+ /* Skip the leading / */
+ strncpy(name, &dirname[1], sizeof(name));
+ for (s = &name[0]; *s != '\0'; s++)
+ if (*s == '/')
+ *s = '.';
+ /*
+ * Resolve the path.
+ */
+ len = sizeof(oid) / sizeof(int);
+ namlen = strlen(name) + 1;
+ if (sysctlnametomib(name, oid, &len) != 0)
+ return (-errno);
+ lsname[0] = 0; /* Root */
+ lsname[1] = 2; /* Get next */
+ memcpy(lsname+2, oid, len * sizeof(int));
+ n1 = 2 + len;
+ oidlen = len;
+ /*
+ * Setup the return list of dirents.
+ */
+ cnt = 0;
+ max = 64;
+ names = malloc(max * sizeof(void *));
+ if (names == NULL)
+ return (-ENOMEM);
+
+ for (;;) {
+ n2 = sizeof(name2);
+ if (sysctl(lsname, n1, name2, &n2, 0, 0) < 0) {
+ if (errno == ENOENT)
+ break;
+ goto errout;
+ }
+ n2 /= sizeof(int);
+ if (n2 < oidlen)
+ break;
+ for (i = 0; i < oidlen; i++)
+ if (name2[i] != oid[i])
+ goto out;
+ chname[0] = 0; /* root */
+ chname[1] = 1; /* oid name */
+ memcpy(chname + 2, name2, n2 * sizeof(int));
+ memcpy(lsname + 2, name2, n2 * sizeof(int));
+ n1 = 2 + n2;
+ /*
+ * scandir() is not supposed to go deeper than the requested
+ * directory but sysctl also doesn't return a node for
+ * 'subdirectories' so we have to find a file in the subdir
+ * and then truncate the name to report it.
+ */
+ if (n2 > oidlen + 1) {
+ /* Skip to the next name after this one. */
+ n1 = 2 + oidlen + 1;
+ lsname[n1 - 1]++;
+ }
+ len = sizeof(name);
+ if (sysctl(chname, n2 + 2, name, &len, 0, 0) < 0)
+ goto errout;
+ if (len <= 0 || len < namlen)
+ goto out;
+ s = name + namlen;
+ /* Just keep the first level name. */
+ if (strchr(s, '.'))
+ *strchr(s, '.') = '\0';
+ len = strlen(s) + 1;
+ dp = malloc(DIRECTSIZ(len));
+ dp->d_reclen = DIRECTSIZ(len);
+ dp->d_namlen = len;
+ memcpy(&dp->d_name, s, len);
+ if (select && !select(dp)) {
+ free(dp);
+ continue;
+ }
+ if (cnt == max) {
+ max *= 2;
+ names2 = realloc(names, max * sizeof(void *));
+ if (names2 == NULL) {
+ errno = ENOMEM;
+ free(dp);
+ goto errout;
+ }
+ names = names2;
+ }
+ names[cnt++] = dp;
+ }
+out:
+ if (cnt && compar)
+ qsort(names, cnt, sizeof(struct dirent *),
+ (int (*)(const void *, const void *))compar);
+
+ *namelist = names;
+
+ return (cnt);
+
+errout:
+ err = errno;
+ for (i = 0; i < cnt; i++)
+ free(names[i]);
+ free(names);
+ return (-err);
+}
diff --git a/contrib/ofed/libibumad/sysfs.h b/contrib/ofed/libibumad/sysfs.h
new file mode 100644
index 0000000..414a122
--- /dev/null
+++ b/contrib/ofed/libibumad/sysfs.h
@@ -0,0 +1,52 @@
+/*
+ * Copyright (c) 2008 Voltaire Inc. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+#ifndef _UMAD_SYSFS_H
+#define _UMAD_SYSFS_H
+
+#include <stdint.h>
+#include <infiniband/types.h>
+#include <infiniband/umad.h>
+
+struct dirent;
+
+extern int sys_read_string(const char *dir_name, const char *file_name, char *str, int len);
+extern int sys_read_guid(const char *dir_name, const char *file_name, __be64 * net_guid);
+extern int sys_read_gid(const char *dir_name, const char *file_name,
+ union umad_gid *gid);
+extern int sys_read_uint64(const char *dir_name, const char *file_name, uint64_t * u);
+extern int sys_read_uint(const char *dir_name, const char *file_name, unsigned *u);
+extern int sys_scandir(const char *dirname, struct dirent ***namelist,
+ int (*select)(const struct dirent *),
+ int (*compar)(const struct dirent **, const struct dirent **));
+
+#endif /* _UMAD_SYSFS_H */
diff --git a/contrib/ofed/libibumad/umad.c b/contrib/ofed/libibumad/umad.c
new file mode 100644
index 0000000..dbcfc0b
--- /dev/null
+++ b/contrib/ofed/libibumad/umad.c
@@ -0,0 +1,1112 @@
+/*
+ * Copyright (c) 2004-2009 Voltaire Inc. All rights reserved.
+ * Copyright (c) 2014 Intel Corporation. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+#include <config.h>
+
+#include <sys/poll.h>
+#include <unistd.h>
+#include <string.h>
+#include <stdio.h>
+#include <errno.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <sys/ioctl.h>
+#include <dirent.h>
+#include <ctype.h>
+#include <inttypes.h>
+#include <assert.h>
+
+#include <infiniband/umad.h>
+
+#define IB_OPENIB_OUI (0x001405)
+
+#include "sysfs.h"
+
+typedef struct ib_user_mad_reg_req {
+ uint32_t id;
+ uint32_t method_mask[4];
+ uint8_t qpn;
+ uint8_t mgmt_class;
+ uint8_t mgmt_class_version;
+ uint8_t oui[3];
+ uint8_t rmpp_version;
+} ib_user_mad_reg_req_t;
+
+static_assert(sizeof(struct ib_user_mad_reg_req) == IOCPARM_LEN(IB_USER_MAD_REGISTER_AGENT),
+ "Invalid structure size");
+
+struct ib_user_mad_reg_req2 {
+ uint32_t id;
+ uint32_t qpn;
+ uint8_t mgmt_class;
+ uint8_t mgmt_class_version;
+ uint16_t res;
+ uint32_t flags;
+ uint64_t method_mask[2];
+ uint32_t oui;
+ uint8_t rmpp_version;
+ uint8_t reserved[3];
+};
+
+static_assert(sizeof(struct ib_user_mad_reg_req2) == IOCPARM_LEN(IB_USER_MAD_REGISTER_AGENT2),
+ "Invalid structure size");
+
+#define IBWARN(fmt, args...) fprintf(stderr, "ibwarn: [%d] %s: " fmt "\n", getpid(), __func__, ## args)
+
+#define TRACE if (umaddebug) IBWARN
+#define DEBUG if (umaddebug) IBWARN
+
+static int umaddebug = 0;
+
+#define UMAD_DEV_FILE_SZ 256
+
+static const char *def_ca_name = "mthca0";
+static int def_ca_port = 1;
+
+static unsigned abi_version;
+static unsigned new_user_mad_api;
+
+/*************************************
+ * Port
+ */
+static int find_cached_ca(const char *ca_name, umad_ca_t * ca)
+{
+ return 0; /* caching not implemented yet */
+}
+
+static int put_ca(umad_ca_t * ca)
+{
+ return 0; /* caching not implemented yet */
+}
+
+static int release_port(umad_port_t * port)
+{
+ free(port->pkeys);
+ port->pkeys = NULL;
+ port->pkeys_size = 0;
+ return 0;
+}
+
+static int check_for_digit_name(const struct dirent *dent)
+{
+ const char *p = dent->d_name;
+ while (*p && isdigit(*p))
+ p++;
+ return *p ? 0 : 1;
+}
+
+static int get_port(const char *ca_name, const char *dir, int portnum, umad_port_t * port)
+{
+ char port_dir[256];
+ union umad_gid gid;
+ struct dirent **namelist = NULL;
+ int i, len, num_pkeys = 0;
+ uint32_t capmask;
+
+ strncpy(port->ca_name, ca_name, sizeof port->ca_name - 1);
+ port->portnum = portnum;
+ port->pkeys = NULL;
+
+ len = snprintf(port_dir, sizeof(port_dir), "%s/%d", dir, portnum);
+ if (len < 0 || len > sizeof(port_dir))
+ goto clean;
+
+ if (sys_read_uint(port_dir, SYS_PORT_LMC, &port->lmc) < 0)
+ goto clean;
+ if (sys_read_uint(port_dir, SYS_PORT_SMLID, &port->sm_lid) < 0)
+ goto clean;
+ if (sys_read_uint(port_dir, SYS_PORT_SMSL, &port->sm_sl) < 0)
+ goto clean;
+ if (sys_read_uint(port_dir, SYS_PORT_LID, &port->base_lid) < 0)
+ goto clean;
+ if (sys_read_uint(port_dir, SYS_PORT_STATE, &port->state) < 0)
+ goto clean;
+ if (sys_read_uint(port_dir, SYS_PORT_PHY_STATE, &port->phys_state) < 0)
+ goto clean;
+ if (sys_read_uint(port_dir, SYS_PORT_RATE, &port->rate) < 0)
+ goto clean;
+ if (sys_read_uint(port_dir, SYS_PORT_CAPMASK, &capmask) < 0)
+ goto clean;
+
+ if (sys_read_string(port_dir, SYS_PORT_LINK_LAYER,
+ port->link_layer, UMAD_CA_NAME_LEN) < 0)
+ /* assume IB by default */
+ sprintf(port->link_layer, "IB");
+
+ port->capmask = htobe32(capmask);
+
+ if (sys_read_gid(port_dir, SYS_PORT_GID, &gid) < 0)
+ goto clean;
+
+ port->gid_prefix = gid.global.subnet_prefix;
+ port->port_guid = gid.global.interface_id;
+
+ snprintf(port_dir + len, sizeof(port_dir) - len, "/pkeys");
+ num_pkeys = sys_scandir(port_dir, &namelist, check_for_digit_name, NULL);
+ if (num_pkeys <= 0) {
+ IBWARN("no pkeys found for %s:%u (at dir %s)...",
+ port->ca_name, port->portnum, port_dir);
+ goto clean;
+ }
+ port->pkeys = calloc(num_pkeys, sizeof(port->pkeys[0]));
+ if (!port->pkeys) {
+ IBWARN("get_port: calloc failed: %s", strerror(errno));
+ goto clean;
+ }
+ for (i = 0; i < num_pkeys; i++) {
+ unsigned idx, val;
+ idx = strtoul(namelist[i]->d_name, NULL, 0);
+ sys_read_uint(port_dir, namelist[i]->d_name, &val);
+ port->pkeys[idx] = val;
+ free(namelist[i]);
+ }
+ port->pkeys_size = num_pkeys;
+ free(namelist);
+ namelist = NULL;
+ port_dir[len] = '\0';
+
+ /* FIXME: handle gids */
+
+ return 0;
+
+clean:
+ if (namelist) {
+ for (i = 0; i < num_pkeys; i++)
+ free(namelist[i]);
+ free(namelist);
+ }
+ if (port->pkeys)
+ free(port->pkeys);
+ return -EIO;
+}
+
+static int release_ca(umad_ca_t * ca)
+{
+ int i;
+
+ for (i = 0; i <= ca->numports; i++) {
+ if (!ca->ports[i])
+ continue;
+ release_port(ca->ports[i]);
+ free(ca->ports[i]);
+ ca->ports[i] = NULL;
+ }
+ return 0;
+}
+
+/*
+ * if *port > 0, check ca[port] state. Otherwise set *port to
+ * the first port that is active, and if such is not found, to
+ * the first port that is link up and if none are linkup, then
+ * the first port that is not disabled. Otherwise return -1.
+ */
+static int resolve_ca_port(const char *ca_name, int *port)
+{
+ umad_ca_t ca;
+ int active = -1, up = -1;
+ int i, ret = 0;
+
+ TRACE("checking ca '%s'", ca_name);
+
+ if (umad_get_ca(ca_name, &ca) < 0)
+ return -1;
+
+ if (ca.node_type == 2) {
+ *port = 0; /* switch sma port 0 */
+ ret = 1;
+ goto Exit;
+ }
+
+ if (*port > 0) { /* check only the port the user wants */
+ if (*port > ca.numports) {
+ ret = -1;
+ goto Exit;
+ }
+ if (!ca.ports[*port]) {
+ ret = -1;
+ goto Exit;
+ }
+ if (strcmp(ca.ports[*port]->link_layer, "InfiniBand") &&
+ strcmp(ca.ports[*port]->link_layer, "IB")) {
+ ret = -1;
+ goto Exit;
+ }
+ if (ca.ports[*port]->state == 4) {
+ ret = 1;
+ goto Exit;
+ }
+ if (ca.ports[*port]->phys_state != 3)
+ goto Exit;
+ ret = -1;
+ goto Exit;
+ }
+
+ for (i = 0; i <= ca.numports; i++) {
+ DEBUG("checking port %d", i);
+ if (!ca.ports[i])
+ continue;
+ if (strcmp(ca.ports[i]->link_layer, "InfiniBand") &&
+ strcmp(ca.ports[i]->link_layer, "IB"))
+ continue;
+ if (up < 0 && ca.ports[i]->phys_state == 5)
+ up = *port = i;
+ if (ca.ports[i]->state == 4) {
+ active = *port = i;
+ DEBUG("found active port %d", i);
+ break;
+ }
+ }
+
+ if (active == -1 && up == -1) { /* no active or linkup port found */
+ for (i = 0; i <= ca.numports; i++) {
+ DEBUG("checking port %d", i);
+ if (!ca.ports[i])
+ continue;
+ if (ca.ports[i]->phys_state != 3) {
+ up = *port = i;
+ break;
+ }
+ }
+ }
+
+ if (active >= 0) {
+ ret = 1;
+ goto Exit;
+ }
+ if (up >= 0) {
+ ret = 0;
+ goto Exit;
+ }
+ ret = -1;
+Exit:
+ release_ca(&ca);
+ return ret;
+}
+
+static const char *resolve_ca_name(const char *ca_name, int *best_port)
+{
+ static char names[UMAD_MAX_DEVICES][UMAD_CA_NAME_LEN];
+ int phys_found = -1, port_found = 0, port, port_type;
+ int caidx, n;
+
+ if (ca_name && (!best_port || *best_port))
+ return ca_name;
+
+ if (ca_name) {
+ if (resolve_ca_port(ca_name, best_port) < 0)
+ return NULL;
+ return ca_name;
+ }
+
+ /* Get the list of CA names */
+ if ((n = umad_get_cas_names((void *)names, UMAD_MAX_DEVICES)) < 0)
+ return NULL;
+
+ /* Find the first existing CA with an active port */
+ for (caidx = 0; caidx < n; caidx++) {
+ TRACE("checking ca '%s'", names[caidx]);
+
+ port = best_port ? *best_port : 0;
+ if ((port_type = resolve_ca_port(names[caidx], &port)) < 0)
+ continue;
+
+ DEBUG("found ca %s with port %d type %d",
+ names[caidx], port, port_type);
+
+ if (port_type > 0) {
+ if (best_port)
+ *best_port = port;
+ DEBUG("found ca %s with active port %d",
+ names[caidx], port);
+ return (char *)(names + caidx);
+ }
+
+ if (phys_found == -1) {
+ phys_found = caidx;
+ port_found = port;
+ }
+ }
+
+ DEBUG("phys found %d on %s port %d",
+ phys_found, phys_found >= 0 ? names[phys_found] : NULL,
+ port_found);
+ if (phys_found >= 0) {
+ if (best_port)
+ *best_port = port_found;
+ return names[phys_found];
+ }
+
+ if (best_port)
+ *best_port = def_ca_port;
+ return def_ca_name;
+}
+
+static int get_ca(const char *ca_name, umad_ca_t * ca)
+{
+ char dir_name[256];
+ struct dirent **namelist;
+ int r, i, ret;
+ int portnum;
+
+ ca->numports = 0;
+ memset(ca->ports, 0, sizeof ca->ports);
+ strncpy(ca->ca_name, ca_name, sizeof(ca->ca_name) - 1);
+
+ snprintf(dir_name, sizeof(dir_name), "%s/%s", SYS_INFINIBAND,
+ ca->ca_name);
+
+ if ((r = sys_read_uint(dir_name, SYS_NODE_TYPE, &ca->node_type)) < 0)
+ return r;
+ if (sys_read_string(dir_name, SYS_CA_FW_VERS, ca->fw_ver,
+ sizeof ca->fw_ver) < 0)
+ ca->fw_ver[0] = '\0';
+ if (sys_read_string(dir_name, SYS_CA_HW_VERS, ca->hw_ver,
+ sizeof ca->hw_ver) < 0)
+ ca->hw_ver[0] = '\0';
+ if ((r = sys_read_string(dir_name, SYS_CA_TYPE, ca->ca_type,
+ sizeof ca->ca_type)) < 0)
+ ca->ca_type[0] = '\0';
+ if ((r = sys_read_guid(dir_name, SYS_CA_NODE_GUID, &ca->node_guid)) < 0)
+ return r;
+ if ((r =
+ sys_read_guid(dir_name, SYS_CA_SYS_GUID, &ca->system_guid)) < 0)
+ return r;
+
+ snprintf(dir_name, sizeof(dir_name), "%s/%s/%s",
+ SYS_INFINIBAND, ca->ca_name, SYS_CA_PORTS_DIR);
+
+ if ((r = sys_scandir(dir_name, &namelist, NULL, alphasort)) < 0) {
+ ret = errno < 0 ? errno : -EIO;
+ goto error;
+ }
+
+ ret = 0;
+ for (i = 0; i < r; i++) {
+ portnum = 0;
+ if (!strcmp(".", namelist[i]->d_name) ||
+ !strcmp("..", namelist[i]->d_name))
+ continue;
+ if (strcmp("0", namelist[i]->d_name) &&
+ ((portnum = atoi(namelist[i]->d_name)) <= 0 ||
+ portnum >= UMAD_CA_MAX_PORTS)) {
+ ret = -EIO;
+ goto clean;
+ }
+ if (!(ca->ports[portnum] =
+ calloc(1, sizeof(*ca->ports[portnum])))) {
+ ret = -ENOMEM;
+ goto clean;
+ }
+ if (get_port(ca_name, dir_name, portnum, ca->ports[portnum]) <
+ 0) {
+ free(ca->ports[portnum]);
+ ca->ports[portnum] = NULL;
+ ret = -EIO;
+ goto clean;
+ }
+ if (ca->numports < portnum)
+ ca->numports = portnum;
+ }
+
+ for (i = 0; i < r; i++)
+ free(namelist[i]);
+ free(namelist);
+
+ put_ca(ca);
+ return 0;
+
+clean:
+ for (i = 0; i < r; i++)
+ free(namelist[i]);
+ free(namelist);
+error:
+ release_ca(ca);
+
+ return ret;
+}
+
+static int umad_id_to_dev(int umad_id, char *dev, unsigned *port)
+{
+ char path[256];
+ int r;
+
+ snprintf(path, sizeof(path), SYS_INFINIBAND_MAD "/umad%d", umad_id);
+
+ if ((r =
+ sys_read_string(path, SYS_IB_MAD_DEV, dev, UMAD_CA_NAME_LEN)) < 0)
+ return r;
+
+ if ((r = sys_read_uint(path, SYS_IB_MAD_PORT, port)) < 0)
+ return r;
+
+ return 0;
+}
+
+static int dev_to_umad_id(const char *dev, unsigned port)
+{
+ char umad_dev[UMAD_CA_NAME_LEN];
+ unsigned umad_port;
+ int id;
+
+ for (id = 0; id < UMAD_MAX_PORTS; id++) {
+ if (umad_id_to_dev(id, umad_dev, &umad_port) < 0)
+ continue;
+ if (strncmp(dev, umad_dev, UMAD_CA_NAME_LEN))
+ continue;
+ if (port != umad_port)
+ continue;
+
+ DEBUG("mapped %s %d to %d", dev, port, id);
+ return id;
+ }
+
+ return -1; /* not found */
+}
+
+/*******************************
+ * Public interface
+ */
+
+int umad_init(void)
+{
+ TRACE("umad_init");
+ if (sys_read_uint(IB_UMAD_ABI_DIR, IB_UMAD_ABI_FILE, &abi_version) < 0) {
+ IBWARN
+ ("can't read ABI version from %s/%s (%m): is ib_umad module loaded?",
+ IB_UMAD_ABI_DIR, IB_UMAD_ABI_FILE);
+ return -1;
+ }
+ if (abi_version < IB_UMAD_ABI_VERSION) {
+ IBWARN
+ ("wrong ABI version: %s/%s is %d but library minimal ABI is %d",
+ IB_UMAD_ABI_DIR, IB_UMAD_ABI_FILE, abi_version,
+ IB_UMAD_ABI_VERSION);
+ return -1;
+ }
+ return 0;
+}
+
+int umad_done(void)
+{
+ TRACE("umad_done");
+ /* FIXME - verify that all ports are closed */
+ return 0;
+}
+
+static unsigned is_ib_type(const char *ca_name)
+{
+ char dir_name[256];
+ unsigned type;
+
+ snprintf(dir_name, sizeof(dir_name), "%s/%s", SYS_INFINIBAND, ca_name);
+
+ if (sys_read_uint(dir_name, SYS_NODE_TYPE, &type) < 0)
+ return 0;
+
+ return type >= 1 && type <= 3 ? 1 : 0;
+}
+
+int umad_get_cas_names(char cas[][UMAD_CA_NAME_LEN], int max)
+{
+ struct dirent **namelist;
+ int n, i, j = 0;
+
+ TRACE("max %d", max);
+
+ n = sys_scandir(SYS_INFINIBAND, &namelist, NULL, alphasort);
+ if (n > 0) {
+ for (i = 0; i < n; i++) {
+ if (strcmp(namelist[i]->d_name, ".") &&
+ strcmp(namelist[i]->d_name, "..")) {
+ if (j < max && is_ib_type(namelist[i]->d_name))
+ strncpy(cas[j++], namelist[i]->d_name,
+ UMAD_CA_NAME_LEN);
+ }
+ free(namelist[i]);
+ }
+ DEBUG("return %d cas", j);
+ } else {
+ /* Is this still needed ? */
+ strncpy((char *)cas, def_ca_name, UMAD_CA_NAME_LEN);
+ DEBUG("return 1 ca");
+ j = 1;
+ }
+ if (n >= 0)
+ free(namelist);
+ return j;
+}
+
+int umad_get_ca_portguids(const char *ca_name, __be64 *portguids, int max)
+{
+ umad_ca_t ca;
+ int ports = 0, i;
+
+ TRACE("ca name %s max port guids %d", ca_name, max);
+ if (!(ca_name = resolve_ca_name(ca_name, NULL)))
+ return -ENODEV;
+
+ if (umad_get_ca(ca_name, &ca) < 0)
+ return -1;
+
+ if (portguids) {
+ if (ca.numports + 1 > max) {
+ release_ca(&ca);
+ return -ENOMEM;
+ }
+
+ for (i = 0; i <= ca.numports; i++)
+ portguids[ports++] = ca.ports[i] ?
+ ca.ports[i]->port_guid : htobe64(0);
+ }
+
+ release_ca(&ca);
+ DEBUG("%s: %d ports", ca_name, ports);
+
+ return ports;
+}
+
+int umad_get_issm_path(const char *ca_name, int portnum, char path[], int max)
+{
+ int umad_id;
+
+ TRACE("ca %s port %d", ca_name, portnum);
+
+ if (!(ca_name = resolve_ca_name(ca_name, &portnum)))
+ return -ENODEV;
+
+ if ((umad_id = dev_to_umad_id(ca_name, portnum)) < 0)
+ return -EINVAL;
+
+ snprintf(path, max, "%s/issm%u", UMAD_DEV_DIR, umad_id);
+
+ return 0;
+}
+
+int umad_open_port(const char *ca_name, int portnum)
+{
+ char dev_file[UMAD_DEV_FILE_SZ];
+ int umad_id, fd;
+
+ TRACE("ca %s port %d", ca_name, portnum);
+
+ if (!(ca_name = resolve_ca_name(ca_name, &portnum)))
+ return -ENODEV;
+
+ DEBUG("opening %s port %d", ca_name, portnum);
+
+ if ((umad_id = dev_to_umad_id(ca_name, portnum)) < 0)
+ return -EINVAL;
+
+ snprintf(dev_file, sizeof(dev_file), "%s/umad%d",
+ UMAD_DEV_DIR, umad_id);
+
+ if ((fd = open(dev_file, O_RDWR | O_NONBLOCK)) < 0) {
+ DEBUG("open %s failed: %s", dev_file, strerror(errno));
+ return -EIO;
+ }
+
+ if (abi_version > 5 || !ioctl(fd, IB_USER_MAD_ENABLE_PKEY, NULL))
+ new_user_mad_api = 1;
+ else
+ new_user_mad_api = 0;
+
+ DEBUG("opened %s fd %d portid %d", dev_file, fd, umad_id);
+ return fd;
+}
+
+int umad_get_ca(const char *ca_name, umad_ca_t * ca)
+{
+ int r;
+
+ TRACE("ca_name %s", ca_name);
+ if (!(ca_name = resolve_ca_name(ca_name, NULL)))
+ return -ENODEV;
+
+ if (find_cached_ca(ca_name, ca) > 0)
+ return 0;
+
+ if ((r = get_ca(ca_name, ca)) < 0)
+ return r;
+
+ DEBUG("opened %s", ca_name);
+ return 0;
+}
+
+int umad_release_ca(umad_ca_t * ca)
+{
+ int r;
+
+ TRACE("ca_name %s", ca->ca_name);
+ if (!ca)
+ return -ENODEV;
+
+ if ((r = release_ca(ca)) < 0)
+ return r;
+
+ DEBUG("releasing %s", ca->ca_name);
+ return 0;
+}
+
+int umad_get_port(const char *ca_name, int portnum, umad_port_t * port)
+{
+ char dir_name[256];
+
+ TRACE("ca_name %s portnum %d", ca_name, portnum);
+
+ if (!(ca_name = resolve_ca_name(ca_name, &portnum)))
+ return -ENODEV;
+
+ snprintf(dir_name, sizeof(dir_name), "%s/%s/%s",
+ SYS_INFINIBAND, ca_name, SYS_CA_PORTS_DIR);
+
+ return get_port(ca_name, dir_name, portnum, port);
+}
+
+int umad_release_port(umad_port_t * port)
+{
+ int r;
+
+ TRACE("port %s:%d", port->ca_name, port->portnum);
+ if (!port)
+ return -ENODEV;
+
+ if ((r = release_port(port)) < 0)
+ return r;
+
+ DEBUG("releasing %s:%d", port->ca_name, port->portnum);
+ return 0;
+}
+
+int umad_close_port(int fd)
+{
+ close(fd);
+ DEBUG("closed fd %d", fd);
+ return 0;
+}
+
+void *umad_get_mad(void *umad)
+{
+ return new_user_mad_api ? ((struct ib_user_mad *)umad)->data :
+ (void *)&((struct ib_user_mad *)umad)->addr.pkey_index;
+}
+
+size_t umad_size(void)
+{
+ return new_user_mad_api ? sizeof(struct ib_user_mad) :
+ sizeof(struct ib_user_mad) - 8;
+}
+
+int umad_set_grh(void *umad, void *mad_addr)
+{
+ struct ib_user_mad *mad = umad;
+ struct ib_mad_addr *addr = mad_addr;
+
+ if (mad_addr) {
+ mad->addr.grh_present = 1;
+ mad->addr.ib_gid = addr->ib_gid;
+ /* The definition for umad_set_grh requires that the input be
+ * in host order */
+ mad->addr.flow_label = htobe32((uint32_t)addr->flow_label);
+ mad->addr.hop_limit = addr->hop_limit;
+ mad->addr.traffic_class = addr->traffic_class;
+ } else
+ mad->addr.grh_present = 0;
+ return 0;
+}
+
+int umad_set_pkey(void *umad, int pkey_index)
+{
+ struct ib_user_mad *mad = umad;
+
+ if (new_user_mad_api)
+ mad->addr.pkey_index = pkey_index;
+
+ return 0;
+}
+
+int umad_get_pkey(void *umad)
+{
+ struct ib_user_mad *mad = umad;
+
+ if (new_user_mad_api)
+ return mad->addr.pkey_index;
+
+ return 0;
+}
+
+int umad_set_addr(void *umad, int dlid, int dqp, int sl, int qkey)
+{
+ struct ib_user_mad *mad = umad;
+
+ TRACE("umad %p dlid %u dqp %d sl %d, qkey %x",
+ umad, dlid, dqp, sl, qkey);
+ mad->addr.qpn = htobe32(dqp);
+ mad->addr.lid = htobe16(dlid);
+ mad->addr.qkey = htobe32(qkey);
+ mad->addr.sl = sl;
+
+ return 0;
+}
+
+int umad_set_addr_net(void *umad, __be16 dlid, __be32 dqp, int sl, __be32 qkey)
+{
+ struct ib_user_mad *mad = umad;
+
+ TRACE("umad %p dlid %u dqp %d sl %d qkey %x",
+ umad, be16toh(dlid), be32toh(dqp), sl, be32toh(qkey));
+ mad->addr.qpn = dqp;
+ mad->addr.lid = dlid;
+ mad->addr.qkey = qkey;
+ mad->addr.sl = sl;
+
+ return 0;
+}
+
+int umad_send(int fd, int agentid, void *umad, int length,
+ int timeout_ms, int retries)
+{
+ struct ib_user_mad *mad = umad;
+ int n;
+
+ TRACE("fd %d agentid %d umad %p timeout %u",
+ fd, agentid, umad, timeout_ms);
+ errno = 0;
+
+ mad->timeout_ms = timeout_ms;
+ mad->retries = retries;
+ mad->agent_id = agentid;
+
+ if (umaddebug > 1)
+ umad_dump(mad);
+
+ n = write(fd, mad, length + umad_size());
+ if (n == length + umad_size())
+ return 0;
+
+ DEBUG("write returned %d != sizeof umad %zu + length %d (%m)",
+ n, umad_size(), length);
+ if (!errno)
+ errno = EIO;
+ return -EIO;
+}
+
+static int dev_poll(int fd, int timeout_ms)
+{
+ struct pollfd ufds;
+ int n;
+
+ ufds.fd = fd;
+ ufds.events = POLLIN;
+
+ if ((n = poll(&ufds, 1, timeout_ms)) == 1)
+ return 0;
+
+ if (n == 0)
+ return -ETIMEDOUT;
+
+ return -EIO;
+}
+
+int umad_recv(int fd, void *umad, int *length, int timeout_ms)
+{
+ struct ib_user_mad *mad = umad;
+ int n;
+
+ errno = 0;
+ TRACE("fd %d umad %p timeout %u", fd, umad, timeout_ms);
+
+ if (!umad || !length) {
+ errno = EINVAL;
+ return -EINVAL;
+ }
+
+ if (timeout_ms && (n = dev_poll(fd, timeout_ms)) < 0) {
+ if (!errno)
+ errno = -n;
+ return n;
+ }
+
+ n = read(fd, umad, umad_size() + *length);
+
+ VALGRIND_MAKE_MEM_DEFINED(umad, umad_size() + *length);
+
+ if ((n >= 0) && (n <= umad_size() + *length)) {
+ DEBUG("mad received by agent %d length %d", mad->agent_id, n);
+ if (n > umad_size())
+ *length = n - umad_size();
+ else
+ *length = 0;
+ return mad->agent_id;
+ }
+
+ if (n == -EWOULDBLOCK) {
+ if (!errno)
+ errno = EWOULDBLOCK;
+ return n;
+ }
+
+ DEBUG("read returned %zu > sizeof umad %zu + length %d (%m)",
+ mad->length - umad_size(), umad_size(), *length);
+
+ *length = mad->length - umad_size();
+ if (!errno)
+ errno = EIO;
+ return -errno;
+}
+
+int umad_poll(int fd, int timeout_ms)
+{
+ TRACE("fd %d timeout %u", fd, timeout_ms);
+ return dev_poll(fd, timeout_ms);
+}
+
+int umad_get_fd(int fd)
+{
+ TRACE("fd %d", fd);
+ return fd;
+}
+
+int umad_register_oui(int fd, int mgmt_class, uint8_t rmpp_version,
+ uint8_t oui[3], long method_mask[])
+{
+ struct ib_user_mad_reg_req req;
+
+ TRACE("fd %d mgmt_class %u rmpp_version %d oui 0x%x%x%x method_mask %p",
+ fd, mgmt_class, (int)rmpp_version, (int)oui[0], (int)oui[1],
+ (int)oui[2], method_mask);
+
+ if (mgmt_class < 0x30 || mgmt_class > 0x4f) {
+ DEBUG("mgmt class %d not in vendor range 2", mgmt_class);
+ return -EINVAL;
+ }
+
+ req.qpn = 1;
+ req.mgmt_class = mgmt_class;
+ req.mgmt_class_version = 1;
+ memcpy(req.oui, oui, sizeof req.oui);
+ req.rmpp_version = rmpp_version;
+
+ if (method_mask)
+ memcpy(req.method_mask, method_mask, sizeof req.method_mask);
+ else
+ memset(req.method_mask, 0, sizeof req.method_mask);
+
+ VALGRIND_MAKE_MEM_DEFINED(&req, sizeof req);
+
+ if (!ioctl(fd, IB_USER_MAD_REGISTER_AGENT, (void *)&req)) {
+ DEBUG
+ ("fd %d registered to use agent %d qp %d class 0x%x oui %p",
+ fd, req.id, req.qpn, req.mgmt_class, oui);
+ return req.id; /* return agentid */
+ }
+
+ DEBUG("fd %d registering qp %d class 0x%x version %d oui %p failed: %m",
+ fd, req.qpn, req.mgmt_class, req.mgmt_class_version, oui);
+ return -EPERM;
+}
+
+int umad_register(int fd, int mgmt_class, int mgmt_version,
+ uint8_t rmpp_version, long method_mask[])
+{
+ struct ib_user_mad_reg_req req;
+ __be32 oui = htobe32(IB_OPENIB_OUI);
+ int qp;
+
+ TRACE
+ ("fd %d mgmt_class %u mgmt_version %u rmpp_version %d method_mask %p",
+ fd, mgmt_class, mgmt_version, rmpp_version, method_mask);
+
+ req.qpn = qp = (mgmt_class == 0x1 || mgmt_class == 0x81) ? 0 : 1;
+ req.mgmt_class = mgmt_class;
+ req.mgmt_class_version = mgmt_version;
+ req.rmpp_version = rmpp_version;
+
+ if (method_mask)
+ memcpy(req.method_mask, method_mask, sizeof req.method_mask);
+ else
+ memset(req.method_mask, 0, sizeof req.method_mask);
+
+ memcpy(&req.oui, (char *)&oui + 1, sizeof req.oui);
+
+ VALGRIND_MAKE_MEM_DEFINED(&req, sizeof req);
+
+ if (!ioctl(fd, IB_USER_MAD_REGISTER_AGENT, (void *)&req)) {
+ DEBUG("fd %d registered to use agent %d qp %d", fd, req.id, qp);
+ return req.id; /* return agentid */
+ }
+
+ DEBUG("fd %d registering qp %d class 0x%x version %d failed: %m",
+ fd, qp, mgmt_class, mgmt_version);
+ return -EPERM;
+}
+
+int umad_register2(int port_fd, struct umad_reg_attr *attr, uint32_t *agent_id)
+{
+ struct ib_user_mad_reg_req2 req;
+ int rc;
+
+ if (!attr || !agent_id)
+ return EINVAL;
+
+ TRACE("fd %d mgmt_class %u mgmt_class_version %u flags 0x%08x "
+ "method_mask 0x%016" PRIx64 " %016" PRIx64
+ "oui 0x%06x rmpp_version %u ",
+ port_fd, attr->mgmt_class, attr->mgmt_class_version,
+ attr->flags, attr->method_mask[0], attr->method_mask[1],
+ attr->oui, attr->rmpp_version);
+
+ if (attr->mgmt_class >= 0x30 && attr->mgmt_class <= 0x4f &&
+ ((attr->oui & 0x00ffffff) == 0 || (attr->oui & 0xff000000) != 0)) {
+ DEBUG("mgmt class %d is in vendor range 2 but oui (0x%08x) is invalid",
+ attr->mgmt_class, attr->oui);
+ return EINVAL;
+ }
+
+ memset(&req, 0, sizeof(req));
+
+ req.mgmt_class = attr->mgmt_class;
+ req.mgmt_class_version = attr->mgmt_class_version;
+ req.qpn = (attr->mgmt_class == 0x1 || attr->mgmt_class == 0x81) ? 0 : 1;
+ req.flags = attr->flags;
+ memcpy(req.method_mask, attr->method_mask, sizeof req.method_mask);
+ req.oui = attr->oui;
+ req.rmpp_version = attr->rmpp_version;
+
+ VALGRIND_MAKE_MEM_DEFINED(&req, sizeof req);
+
+ if ((rc = ioctl(port_fd, IB_USER_MAD_REGISTER_AGENT2, (void *)&req)) == 0) {
+ DEBUG("fd %d registered to use agent %d qp %d class 0x%x oui 0x%06x",
+ port_fd, req.id, req.qpn, req.mgmt_class, attr->oui);
+ *agent_id = req.id;
+ return 0;
+ }
+
+ if (errno == ENOTTY || errno == EINVAL) {
+
+ TRACE("no kernel support for registration flags");
+ req.flags = 0;
+
+ if (attr->flags == 0) {
+ struct ib_user_mad_reg_req req_v1;
+
+ TRACE("attempting original register ioctl");
+
+ memset(&req_v1, 0, sizeof(req_v1));
+ req_v1.mgmt_class = req.mgmt_class;
+ req_v1.mgmt_class_version = req.mgmt_class_version;
+ req_v1.qpn = req.qpn;
+ req_v1.rmpp_version = req.rmpp_version;
+ req_v1.oui[0] = (req.oui & 0xff0000) >> 16;
+ req_v1.oui[1] = (req.oui & 0x00ff00) >> 8;
+ req_v1.oui[2] = req.oui & 0x0000ff;
+
+ memcpy(req_v1.method_mask, req.method_mask, sizeof req_v1.method_mask);
+
+ if ((rc = ioctl(port_fd, IB_USER_MAD_REGISTER_AGENT,
+ (void *)&req_v1)) == 0) {
+ DEBUG("fd %d registered to use agent %d qp %d class 0x%x oui 0x%06x",
+ port_fd, req_v1.id, req_v1.qpn, req_v1.mgmt_class, attr->oui);
+ *agent_id = req_v1.id;
+ return 0;
+ }
+ }
+ }
+
+ rc = errno;
+ attr->flags = req.flags;
+
+ DEBUG("fd %d registering qp %d class 0x%x version %d "
+ "oui 0x%06x failed flags returned 0x%x : %m",
+ port_fd, req.qpn, req.mgmt_class, req.mgmt_class_version,
+ attr->oui, req.flags);
+
+ return rc;
+}
+
+int umad_unregister(int fd, int agentid)
+{
+ TRACE("fd %d unregistering agent %d", fd, agentid);
+ return ioctl(fd, IB_USER_MAD_UNREGISTER_AGENT, &agentid);
+}
+
+int umad_status(void *umad)
+{
+ struct ib_user_mad *mad = umad;
+
+ return mad->status;
+}
+
+ib_mad_addr_t *umad_get_mad_addr(void *umad)
+{
+ struct ib_user_mad *mad = umad;
+
+ return &mad->addr;
+}
+
+int umad_debug(int level)
+{
+ if (level >= 0)
+ umaddebug = level;
+ return umaddebug;
+}
+
+void umad_addr_dump(ib_mad_addr_t * addr)
+{
+#define HEX(x) ((x) < 10 ? '0' + (x) : 'a' + ((x) -10))
+ char gid_str[64];
+ int i;
+
+ for (i = 0; i < sizeof addr->gid; i++) {
+ gid_str[i * 2] = HEX(addr->gid[i] >> 4);
+ gid_str[i * 2 + 1] = HEX(addr->gid[i] & 0xf);
+ }
+ gid_str[i * 2] = 0;
+ IBWARN("qpn %d qkey 0x%x lid %u sl %d\n"
+ "grh_present %d gid_index %d hop_limit %d traffic_class %d flow_label 0x%x pkey_index 0x%x\n"
+ "Gid 0x%s",
+ be32toh(addr->qpn), be32toh(addr->qkey), be16toh(addr->lid), addr->sl,
+ addr->grh_present, (int)addr->gid_index, (int)addr->hop_limit,
+ (int)addr->traffic_class, addr->flow_label, addr->pkey_index,
+ gid_str);
+}
+
+void umad_dump(void *umad)
+{
+ struct ib_user_mad *mad = umad;
+
+ IBWARN("agent id %d status %x timeout %d",
+ mad->agent_id, mad->status, mad->timeout_ms);
+ umad_addr_dump(&mad->addr);
+}
diff --git a/contrib/ofed/libibumad/umad.h b/contrib/ofed/libibumad/umad.h
new file mode 100644
index 0000000..e426c3c
--- /dev/null
+++ b/contrib/ofed/libibumad/umad.h
@@ -0,0 +1,269 @@
+/*
+ * Copyright (c) 2004-2009 Voltaire Inc. All rights reserved.
+ * Copyright (c) 2014 Intel Corporation. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+#ifndef _UMAD_H
+#define _UMAD_H
+
+#include <stdint.h>
+#include <stdlib.h>
+#include <arpa/inet.h>
+
+#ifdef _KERNEL
+#include <sys/endian.h>
+#include <linux/types.h> /* __be16, __be32 and __be64 */
+#else
+#include <infiniband/endian.h>
+#include <infiniband/types.h>
+#endif
+
+#ifdef __cplusplus
+# define BEGIN_C_DECLS extern "C" {
+# define END_C_DECLS }
+#else /* !__cplusplus */
+# define BEGIN_C_DECLS
+# define END_C_DECLS
+#endif /* __cplusplus */
+
+BEGIN_C_DECLS
+
+typedef __be16 __attribute__((deprecated)) be16_t;
+typedef __be32 __attribute__((deprecated)) be32_t;
+typedef __be64 __attribute__((deprecated)) be64_t;
+
+/*
+ * A GID data structure that may be used in definitions of on-the-wire data
+ * structures. Do not cast umad_gid pointers to ibv_gid pointers because the
+ * alignment of these two data structures is different.
+ */
+union umad_gid {
+ uint8_t raw[16];
+ __be16 raw_be16[8];
+ struct {
+ __be64 subnet_prefix;
+ __be64 interface_id;
+ } global;
+} __attribute__((aligned(4))) __attribute__((packed));
+
+#define UMAD_MAX_DEVICES 32
+#define UMAD_ANY_PORT 0
+typedef struct ib_mad_addr {
+ __be32 qpn;
+ __be32 qkey;
+ __be16 lid;
+ uint8_t sl;
+ uint8_t path_bits;
+ uint8_t grh_present;
+ uint8_t gid_index;
+ uint8_t hop_limit;
+ uint8_t traffic_class;
+ union {
+ uint8_t gid[16]; /* network-byte order */
+ union umad_gid ib_gid;
+ };
+ __be32 flow_label;
+ uint16_t pkey_index;
+ uint8_t reserved[6];
+} ib_mad_addr_t;
+
+typedef struct ib_user_mad {
+ uint32_t agent_id;
+ uint32_t status;
+ uint32_t timeout_ms;
+ uint32_t retries;
+ uint32_t length;
+ ib_mad_addr_t addr;
+ uint8_t data[0];
+} ib_user_mad_t;
+
+#define IB_UMAD_ABI_VERSION 5
+#define IB_UMAD_ABI_DIR "/sys/class/infiniband_mad"
+#define IB_UMAD_ABI_FILE "abi_version"
+
+#define IB_IOCTL_MAGIC 0x1b
+
+#define IB_USER_MAD_REGISTER_AGENT \
+ _IOWR(IB_IOCTL_MAGIC, 1, uint8_t [28] /* struct ib_user_mad_reg_req */)
+#define IB_USER_MAD_UNREGISTER_AGENT _IOW(IB_IOCTL_MAGIC, 2, uint32_t)
+#define IB_USER_MAD_ENABLE_PKEY _IO(IB_IOCTL_MAGIC, 3)
+#define IB_USER_MAD_REGISTER_AGENT2 \
+ _IOWR(IB_IOCTL_MAGIC, 4, uint8_t [40] /* struct ib_user_mad_reg_req2 */)
+
+#define UMAD_CA_NAME_LEN 20
+#define UMAD_CA_MAX_PORTS 10 /* 0 - 9 */
+#define UMAD_CA_MAX_AGENTS 32
+
+#define SYS_INFINIBAND "/sys/class/infiniband"
+
+#define SYS_INFINIBAND_MAD "/sys/class/infiniband_mad"
+#define SYS_IB_MAD_PORT "port"
+#define SYS_IB_MAD_DEV "ibdev"
+
+#define UMAD_MAX_PORTS 64
+
+#define UMAD_DEV_DIR "/dev"
+
+#define SYS_CA_PORTS_DIR "ports"
+
+#define SYS_NODE_TYPE "node_type"
+#define SYS_CA_FW_VERS "fw_ver"
+#define SYS_CA_HW_VERS "hw_rev"
+#define SYS_CA_TYPE "hca_type"
+#define SYS_CA_NODE_GUID "node_guid"
+#define SYS_CA_SYS_GUID "sys_image_guid"
+
+#define SYS_PORT_LMC "lid_mask_count"
+#define SYS_PORT_SMLID "sm_lid"
+#define SYS_PORT_SMSL "sm_sl"
+#define SYS_PORT_LID "lid"
+#define SYS_PORT_STATE "state"
+#define SYS_PORT_PHY_STATE "phys_state"
+#define SYS_PORT_CAPMASK "cap_mask"
+#define SYS_PORT_RATE "rate"
+#define SYS_PORT_GUID "port_guid"
+#define SYS_PORT_GID "gids/0"
+#define SYS_PORT_LINK_LAYER "link_layer"
+
+typedef struct umad_port {
+ char ca_name[UMAD_CA_NAME_LEN];
+ int portnum;
+ unsigned base_lid;
+ unsigned lmc;
+ unsigned sm_lid;
+ unsigned sm_sl;
+ unsigned state;
+ unsigned phys_state;
+ unsigned rate;
+ __be32 capmask;
+ __be64 gid_prefix;
+ __be64 port_guid;
+ unsigned pkeys_size;
+ uint16_t *pkeys;
+ char link_layer[UMAD_CA_NAME_LEN];
+} umad_port_t;
+
+typedef struct umad_ca {
+ char ca_name[UMAD_CA_NAME_LEN];
+ unsigned node_type;
+ int numports;
+ char fw_ver[20];
+ char ca_type[40];
+ char hw_ver[20];
+ __be64 node_guid;
+ __be64 system_guid;
+ umad_port_t *ports[UMAD_CA_MAX_PORTS];
+} umad_ca_t;
+
+int umad_init(void);
+int umad_done(void);
+
+int umad_get_cas_names(char cas[][UMAD_CA_NAME_LEN], int max);
+int umad_get_ca_portguids(const char *ca_name, __be64 *portguids, int max);
+
+int umad_get_ca(const char *ca_name, umad_ca_t * ca);
+int umad_release_ca(umad_ca_t * ca);
+int umad_get_port(const char *ca_name, int portnum, umad_port_t * port);
+int umad_release_port(umad_port_t * port);
+
+int umad_get_issm_path(const char *ca_name, int portnum, char path[], int max);
+
+int umad_open_port(const char *ca_name, int portnum);
+int umad_close_port(int portid);
+
+void *umad_get_mad(void *umad);
+size_t umad_size(void);
+int umad_status(void *umad);
+
+ib_mad_addr_t *umad_get_mad_addr(void *umad);
+int umad_set_grh_net(void *umad, void *mad_addr);
+int umad_set_grh(void *umad, void *mad_addr);
+int umad_set_addr_net(void *umad, __be16 dlid, __be32 dqp, int sl, __be32 qkey);
+int umad_set_addr(void *umad, int dlid, int dqp, int sl, int qkey);
+int umad_set_pkey(void *umad, int pkey_index);
+int umad_get_pkey(void *umad);
+
+int umad_send(int portid, int agentid, void *umad, int length,
+ int timeout_ms, int retries);
+int umad_recv(int portid, void *umad, int *length, int timeout_ms);
+int umad_poll(int portid, int timeout_ms);
+int umad_get_fd(int portid);
+
+int umad_register(int portid, int mgmt_class, int mgmt_version,
+ uint8_t rmpp_version, long method_mask[16 / sizeof(long)]);
+int umad_register_oui(int portid, int mgmt_class, uint8_t rmpp_version,
+ uint8_t oui[3], long method_mask[16 / sizeof(long)]);
+int umad_unregister(int portid, int agentid);
+
+enum {
+ UMAD_USER_RMPP = (1 << 0)
+};
+
+struct umad_reg_attr {
+ uint8_t mgmt_class;
+ uint8_t mgmt_class_version;
+ uint32_t flags;
+ uint64_t method_mask[2];
+ uint32_t oui;
+ uint8_t rmpp_version;
+};
+
+int umad_register2(int port_fd, struct umad_reg_attr *attr,
+ uint32_t *agent_id);
+
+int umad_debug(int level);
+void umad_addr_dump(ib_mad_addr_t * addr);
+void umad_dump(void *umad);
+
+static inline void *umad_alloc(int num, size_t size)
+{ /* alloc array of umad buffers */
+ return calloc(num, size);
+}
+
+static inline void umad_free(void *umad)
+{
+ free(umad);
+}
+
+/* Users should use the glibc functions directly, not these wrappers */
+#ifndef ntohll
+#undef ntohll
+static inline __attribute__((deprecated)) uint64_t ntohll(uint64_t x) { return be64toh(x); }
+#define ntohll ntohll
+#endif
+#ifndef htonll
+#undef htonll
+static inline __attribute__((deprecated)) uint64_t htonll(uint64_t x) { return htobe64(x); }
+#define htonll htonll
+#endif
+
+END_C_DECLS
+#endif /* _UMAD_H */
diff --git a/contrib/ofed/libibumad/umad_cm.h b/contrib/ofed/libibumad/umad_cm.h
new file mode 100644
index 0000000..e063f8a
--- /dev/null
+++ b/contrib/ofed/libibumad/umad_cm.h
@@ -0,0 +1,67 @@
+/*
+ * Copyright (c) 2010 Intel Corporation. All rights reserved.
+ * Copyright (c) 2014 Mellanox Technologies LTD. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#ifndef _UMAD_CM_H
+#define _UMAD_CM_H
+
+#include <infiniband/umad_types.h>
+
+#ifdef __cplusplus
+# define BEGIN_C_DECLS extern "C" {
+# define END_C_DECLS }
+#else /* !__cplusplus */
+# define BEGIN_C_DECLS
+# define END_C_DECLS
+#endif /* __cplusplus */
+
+BEGIN_C_DECLS
+
+/* Communication management attributes */
+enum {
+ UMAD_CM_ATTR_REQ = 0x0010,
+ UMAD_CM_ATTR_MRA = 0x0011,
+ UMAD_CM_ATTR_REJ = 0x0012,
+ UMAD_CM_ATTR_REP = 0x0013,
+ UMAD_CM_ATTR_RTU = 0x0014,
+ UMAD_CM_ATTR_DREQ = 0x0015,
+ UMAD_CM_ATTR_DREP = 0x0016,
+ UMAD_CM_ATTR_SIDR_REQ = 0x0017,
+ UMAD_CM_ATTR_SIDR_REP = 0x0018,
+ UMAD_CM_ATTR_LAP = 0x0019,
+ UMAD_CM_ATTR_APR = 0x001A,
+ UMAD_CM_ATTR_SAP = 0x001B,
+ UMAD_CM_ATTR_SPR = 0x001C,
+};
+
+END_C_DECLS
+#endif /* _UMAD_CM_H */
diff --git a/contrib/ofed/libibumad/umad_sa.h b/contrib/ofed/libibumad/umad_sa.h
new file mode 100644
index 0000000..3f0f877
--- /dev/null
+++ b/contrib/ofed/libibumad/umad_sa.h
@@ -0,0 +1,148 @@
+/*
+ * Copyright (c) 2004 Topspin Communications. All rights reserved.
+ * Copyright (c) 2005 Voltaire, Inc. All rights reserved.
+ * Copyright (c) 2006, 2010 Intel Corporation. All rights reserved.
+ * Copyright (c) 2014 Mellanox Technologies LTD. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+#ifndef _UMAD_SA_H
+#define _UMAD_SA_H
+
+#include <infiniband/umad_types.h>
+
+#ifdef __cplusplus
+# define BEGIN_C_DECLS extern "C" {
+# define END_C_DECLS }
+#else /* !__cplusplus */
+# define BEGIN_C_DECLS
+# define END_C_DECLS
+#endif /* __cplusplus */
+
+BEGIN_C_DECLS
+
+/* SA specific methods */
+enum {
+ UMAD_SA_CLASS_VERSION = 2, /* IB spec version 1.1/1.2 */
+
+ UMAD_SA_METHOD_GET_TABLE = 0x12,
+ UMAD_SA_METHOD_GET_TABLE_RESP = 0x92,
+ UMAD_SA_METHOD_DELETE = 0x15,
+ UMAD_SA_METHOD_DELETE_RESP = 0x95,
+ UMAD_SA_METHOD_GET_MULTI = 0x14,
+ UMAD_SA_METHOD_GET_MULTI_RESP = 0x94,
+ UMAD_SA_METHOD_GET_TRACE_TABLE = 0x13
+};
+
+enum {
+ UMAD_SA_STATUS_SUCCESS = 0,
+ UMAD_SA_STATUS_NO_RESOURCES = 1,
+ UMAD_SA_STATUS_REQ_INVALID = 2,
+ UMAD_SA_STATUS_NO_RECORDS = 3,
+ UMAD_SA_STATUS_TOO_MANY_RECORDS = 4,
+ UMAD_SA_STATUS_INVALID_GID = 5,
+ UMAD_SA_STATUS_INSUF_COMPS = 6,
+ UMAD_SA_STATUS_REQ_DENIED = 7,
+ UMAD_SA_STATUS_PRI_SUGGESTED = 8
+};
+
+/* SA attributes */
+enum {
+ UMAD_SA_ATTR_NODE_REC = 0x0011,
+ UMAD_SA_ATTR_PORT_INFO_REC = 0x0012,
+ UMAD_SA_ATTR_SLVL_REC = 0x0013,
+ UMAD_SA_ATTR_SWITCH_INFO_REC = 0x0014,
+ UMAD_SA_ATTR_LINEAR_FT_REC = 0x0015,
+ UMAD_SA_ATTR_RANDOM_FT_REC = 0x0016,
+ UMAD_SA_ATTR_MCAST_FT_REC = 0x0017,
+ UMAD_SA_ATTR_SM_INFO_REC = 0x0018,
+ UMAD_SA_ATTR_LINK_SPD_WIDTH_TABLE_REC = 0x0019,
+ UMAD_SA_ATTR_INFORM_INFO_REC = 0x00F3,
+ UMAD_SA_ATTR_LINK_REC = 0x0020,
+ UMAD_SA_ATTR_GUID_INFO_REC = 0x0030,
+ UMAD_SA_ATTR_SERVICE_REC = 0x0031,
+ UMAD_SA_ATTR_PKEY_TABLE_REC = 0x0033,
+ UMAD_SA_ATTR_PATH_REC = 0x0035,
+ UMAD_SA_ATTR_VL_ARB_REC = 0x0036,
+ UMAD_SA_ATTR_MCMEMBER_REC = 0x0038,
+ UMAD_SA_ATTR_TRACE_REC = 0x0039,
+ UMAD_SA_ATTR_MULTI_PATH_REC = 0x003A,
+ UMAD_SA_ATTR_SERVICE_ASSOC_REC = 0x003B,
+ UMAD_SA_ATTR_HIERARCHY_INFO_REC = 0x003C,
+ UMAD_SA_ATTR_CABLE_INFO_REC = 0x003D,
+ UMAD_SA_ATTR_PORT_INFO_EXT_REC = 0x003E
+};
+
+enum {
+ UMAD_LEN_SA_DATA = 200
+};
+
+/* CM bits */
+enum {
+ UMAD_SA_CAP_MASK_IS_SUBNET_OPT_REC_SUP = (1 << 8),
+ UMAD_SA_CAP_MASK_IS_UD_MCAST_SUP = (1 << 9),
+ UMAD_SA_CAP_MASK_IS_MULTIPATH_SUP = (1 << 10),
+ UMAD_SA_CAP_MASK_IS_REINIT_SUP = (1 << 11),
+ UMAD_SA_CAP_MASK_IS_GID_SCOPED_MULTIPATH_SUP = (1 << 12),
+ UMAD_SA_CAP_MASK_IS_PORTINFO_CAP_MASK_MATCH_SUP = (1 << 13),
+ UMAD_SA_CAP_MASK_IS_LINK_SPEED_WIDTH_PAIRS_REC_SUP = (1 << 14),
+ UMAD_SA_CAP_MASK_IS_PA_SERVICES_SUP = (1 << 15)
+};
+/* CM2 bits */
+enum {
+ UMAD_SA_CAP_MASK2_IS_UNPATH_REPATH_SUP = (1 << 0),
+ UMAD_SA_CAP_MASK2_IS_QOS_SUP = (1 << 1),
+ UMAD_SA_CAP_MASK2_IS_REV_PATH_PKEY_MEM_BIT_SUP = (1 << 2),
+ UMAD_SA_CAP_MASK2_IS_MCAST_TOP_SUP = (1 << 3),
+ UMAD_SA_CAP_MASK2_IS_HIERARCHY_INFO_SUP = (1 << 4),
+ UMAD_SA_CAP_MASK2_IS_ADDITIONAL_GUID_SUP = (1 << 5),
+ UMAD_SA_CAP_MASK2_IS_FULL_PORTINFO_REC_SUP = (1 << 6),
+ UMAD_SA_CAP_MASK2_IS_EXT_SPEEDS_SUP = (1 << 7),
+ UMAD_SA_CAP_MASK2_IS_MCAST_SERVICE_REC_SUP = (1 << 8),
+ UMAD_SA_CAP_MASK2_IS_CABLE_INFO_REC_SUP = (1 << 9),
+ UMAD_SA_CAP_MASK2_IS_PORT_INFO_CAPMASK2_MATCH_SUP = (1 << 10),
+ UMAD_SA_CAP_MASK2_IS_PORT_INFO_EXT_REC_SUP = (1 << 11)
+};
+
+/*
+ * sm_key is not aligned on an 8-byte boundary, so is defined as a byte array
+ */
+struct umad_sa_packet {
+ struct umad_hdr mad_hdr;
+ struct umad_rmpp_hdr rmpp_hdr;
+ uint8_t sm_key[8]; /* network-byte order */
+ __be16 attr_offset;
+ __be16 reserved;
+ __be64 comp_mask;
+ uint8_t data[UMAD_LEN_SA_DATA]; /* network-byte order */
+};
+
+END_C_DECLS
+#endif /* _UMAD_SA_H */
diff --git a/contrib/ofed/libibumad/umad_sm.h b/contrib/ofed/libibumad/umad_sm.h
new file mode 100644
index 0000000..d912608
--- /dev/null
+++ b/contrib/ofed/libibumad/umad_sm.h
@@ -0,0 +1,128 @@
+/*
+ * Copyright (c) 2004-2014 Mellanox Technologies Ltd. All rights reserved.
+ * Copyright (c) 2004 Infinicon Corporation. All rights reserved.
+ * Copyright (c) 2004 Intel Corporation. All rights reserved.
+ * Copyright (c) 2004 Topspin Corporation. All rights reserved.
+ * Copyright (c) 2004 Voltaire Corporation. All rights reserved.
+ * Copyright (c) 2013 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#ifndef _UMAD_SM_H
+#define _UMAD_SM_H
+
+#include <infiniband/umad_types.h>
+
+#ifdef __cplusplus
+# define BEGIN_C_DECLS extern "C" {
+# define END_C_DECLS }
+#else /* !__cplusplus */
+# define BEGIN_C_DECLS
+# define END_C_DECLS
+#endif /* __cplusplus */
+
+BEGIN_C_DECLS
+
+enum {
+ UMAD_SMP_DIRECTION = 0x8000,
+};
+
+/* Subnet management attributes */
+enum {
+ UMAD_SM_ATTR_NODE_DESC = 0x0010,
+ UMAD_SM_ATTR_NODE_INFO = 0x0011,
+ UMAD_SM_ATTR_SWITCH_INFO = 0x0012,
+ UMAD_SM_ATTR_GUID_INFO = 0x0014,
+ UMAD_SM_ATTR_PORT_INFO = 0x0015,
+ UMAD_SM_ATTR_PKEY_TABLE = 0x0016,
+ UMAD_SM_ATTR_SLVL_TABLE = 0x0017,
+ UMAD_SM_ATTR_VL_ARB_TABLE = 0x0018,
+ UMAD_SM_ATTR_LINEAR_FT = 0x0019,
+ UMAD_SM_ATTR_RANDOM_FT = 0x001A,
+ UMAD_SM_ATTR_MCAST_FT = 0x001B,
+ UMAD_SM_ATTR_LINK_SPD_WIDTH_TABLE = 0x001C,
+ UMAD_SM_ATTR_VENDOR_MADS_TABLE = 0x001D,
+ UMAD_SM_ATTR_HIERARCHY_INFO = 0x001E,
+ UMAD_SM_ATTR_SM_INFO = 0x0020,
+ UMAD_SM_ATTR_VENDOR_DIAG = 0x0030,
+ UMAD_SM_ATTR_LED_INFO = 0x0031,
+ UMAD_SM_ATTR_CABLE_INFO = 0x0032,
+ UMAD_SM_ATTR_PORT_INFO_EXT = 0x0033,
+ UMAD_SM_ATTR_VENDOR_MASK = 0xFF00,
+ UMAD_SM_ATTR_MLNX_EXT_PORT_INFO = 0xFF90
+};
+
+enum {
+ UMAD_SM_GID_IN_SERVICE_TRAP = 64,
+ UMAD_SM_GID_OUT_OF_SERVICE_TRAP = 65,
+ UMAD_SM_MGID_CREATED_TRAP = 66,
+ UMAD_SM_MGID_DESTROYED_TRAP = 67,
+ UMAD_SM_UNPATH_TRAP = 68,
+ UMAD_SM_REPATH_TRAP = 69,
+ UMAD_SM_LINK_STATE_CHANGED_TRAP = 128,
+ UMAD_SM_LINK_INTEGRITY_THRESHOLD_TRAP = 129,
+ UMAD_SM_BUFFER_OVERRUN_THRESHOLD_TRAP = 130,
+ UMAD_SM_WATCHDOG_TIMER_EXPIRED_TRAP = 131,
+ UMAD_SM_LOCAL_CHANGES_TRAP = 144,
+ UMAD_SM_SYS_IMG_GUID_CHANGED_TRAP = 145,
+ UMAD_SM_BAD_MKEY_TRAP = 256,
+ UMAD_SM_BAD_PKEY_TRAP = 257,
+ UMAD_SM_BAD_QKEY_TRAP = 258,
+ UMAD_SM_BAD_SWITCH_PKEY_TRAP = 259
+};
+
+enum {
+ UMAD_LEN_SMP_DATA = 64,
+ UMAD_SMP_MAX_HOPS = 64
+};
+
+struct umad_smp {
+ uint8_t base_version;
+ uint8_t mgmt_class;
+ uint8_t class_version;
+ uint8_t method;
+ __be16 status;
+ uint8_t hop_ptr;
+ uint8_t hop_cnt;
+ __be64 tid;
+ __be16 attr_id;
+ __be16 resv;
+ __be32 attr_mod;
+ __be64 mkey;
+ __be16 dr_slid;
+ __be16 dr_dlid;
+ uint8_t reserved[28];
+ uint8_t data[UMAD_LEN_SMP_DATA];
+ uint8_t initial_path[UMAD_SMP_MAX_HOPS];
+ uint8_t return_path[UMAD_SMP_MAX_HOPS];
+};
+
+END_C_DECLS
+#endif /* _UMAD_SM_H */
diff --git a/contrib/ofed/libibumad/umad_str.c b/contrib/ofed/libibumad/umad_str.c
new file mode 100644
index 0000000..0a014f7
--- /dev/null
+++ b/contrib/ofed/libibumad/umad_str.c
@@ -0,0 +1,355 @@
+/*
+ * Copyright (c) 2004, 2005, 2010 Intel Corporation. All rights reserved.
+ * Copyright (c) 2013 Lawrence Livermore National Security. All rights reserved.
+ * Copyright (c) 2014 Mellanox Technologies LTD. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+#include <stdio.h>
+#include <infiniband/endian.h>
+#include <infiniband/umad.h>
+#include <infiniband/umad_types.h>
+#include <infiniband/umad_sm.h>
+#include <infiniband/umad_sa.h>
+#include <infiniband/umad_cm.h>
+#include "umad_str.h"
+
+const char * umad_class_str(uint8_t mgmt_class)
+{
+ switch (mgmt_class) {
+ case UMAD_CLASS_SUBN_LID_ROUTED:
+ case UMAD_CLASS_SUBN_DIRECTED_ROUTE:
+ return("Subn");
+ case UMAD_CLASS_SUBN_ADM:
+ return("SubnAdm");
+ case UMAD_CLASS_PERF_MGMT:
+ return("Perf");
+ case UMAD_CLASS_BM:
+ return("BM");
+ case UMAD_CLASS_DEVICE_MGMT:
+ return("DevMgt");
+ case UMAD_CLASS_CM:
+ return("ComMgt");
+ case UMAD_CLASS_SNMP:
+ return("SNMP");
+ case UMAD_CLASS_DEVICE_ADM:
+ return("DevAdm");
+ case UMAD_CLASS_BOOT_MGMT:
+ return("BootMgt");
+ case UMAD_CLASS_BIS:
+ return("BIS");
+ case UMAD_CLASS_CONG_MGMT:
+ return("CongestionManagment");
+ default:
+ break;
+ }
+
+ if ((UMAD_CLASS_VENDOR_RANGE1_START <= mgmt_class
+ && mgmt_class <= UMAD_CLASS_VENDOR_RANGE1_END)
+ || (UMAD_CLASS_VENDOR_RANGE2_START <= mgmt_class
+ && mgmt_class <= UMAD_CLASS_VENDOR_RANGE2_END))
+ return("Vendor");
+
+ if (UMAD_CLASS_APPLICATION_START <= mgmt_class
+ && mgmt_class <= UMAD_CLASS_APPLICATION_END) {
+ return("Application");
+ }
+ return ("<unknown>");
+}
+
+static const char * umad_common_method_str(uint8_t method)
+{
+ switch(method) {
+ case UMAD_METHOD_GET:
+ return ("Get");
+ case UMAD_METHOD_SET:
+ return ("Set");
+ case UMAD_METHOD_GET_RESP:
+ return ("GetResp");
+ case UMAD_METHOD_SEND:
+ return ("Send");
+ case UMAD_METHOD_TRAP:
+ return ("Trap");
+ case UMAD_METHOD_REPORT:
+ return ("Report");
+ case UMAD_METHOD_REPORT_RESP:
+ return ("ReportResp");
+ case UMAD_METHOD_TRAP_REPRESS:
+ return ("TrapRepress");
+ default:
+ return ("<unknown");
+ }
+}
+
+static const char * umad_sa_method_str(uint8_t method)
+{
+ switch(method) {
+ case UMAD_SA_METHOD_GET_TABLE:
+ return ("GetTable");
+ case UMAD_SA_METHOD_GET_TABLE_RESP:
+ return ("GetTableResp");
+ case UMAD_SA_METHOD_DELETE:
+ return ("Delete");
+ case UMAD_SA_METHOD_DELETE_RESP:
+ return ("DeleteResp");
+ case UMAD_SA_METHOD_GET_MULTI:
+ return ("GetMulti");
+ case UMAD_SA_METHOD_GET_MULTI_RESP:
+ return ("GetMultiResp");
+ case UMAD_SA_METHOD_GET_TRACE_TABLE:
+ return ("GetTraceTable");
+ default:
+ return (umad_common_method_str(method));
+ }
+}
+
+const char * umad_method_str(uint8_t mgmt_class, uint8_t method)
+{
+ if (mgmt_class == UMAD_CLASS_SUBN_ADM)
+ return(umad_sa_method_str(method));
+
+ return (umad_common_method_str(method));
+}
+
+const char * umad_common_mad_status_str(__be16 _status)
+{
+ uint16_t status = be16toh(_status);
+
+ if (status & UMAD_STATUS_BUSY)
+ return ("Busy");
+
+ if (status & UMAD_STATUS_REDIRECT)
+ return ("Redirection required");
+
+ switch(status & UMAD_STATUS_INVALID_FIELD_MASK) {
+ case UMAD_STATUS_BAD_VERSION:
+ return ("Bad Version");
+ case UMAD_STATUS_METHOD_NOT_SUPPORTED:
+ return ("Method not supported");
+ case UMAD_STATUS_ATTR_NOT_SUPPORTED:
+ return ("Method/Attribute combo not supported");
+ case UMAD_STATUS_INVALID_ATTR_VALUE:
+ return ("Invalid attribute/modifier field");
+ }
+ return ("Success");
+}
+
+const char * umad_sa_mad_status_str(__be16 _status)
+{
+ uint16_t status = be16toh(_status);
+ switch((status & UMAD_STATUS_CLASS_MASK) >> 8) {
+ case UMAD_SA_STATUS_SUCCESS:
+ return ("Success");
+ case UMAD_SA_STATUS_NO_RESOURCES:
+ return ("No Resources");
+ case UMAD_SA_STATUS_REQ_INVALID:
+ return ("Request Invalid");
+ case UMAD_SA_STATUS_NO_RECORDS:
+ return ("No Records");
+ case UMAD_SA_STATUS_TOO_MANY_RECORDS:
+ return ("Too Many Records");
+ case UMAD_SA_STATUS_INVALID_GID:
+ return ("Invalid GID");
+ case UMAD_SA_STATUS_INSUF_COMPS:
+ return ("Insufficient Components");
+ case UMAD_SA_STATUS_REQ_DENIED:
+ return ("Request Denied");
+ case UMAD_SA_STATUS_PRI_SUGGESTED:
+ return ("Priority Suggested");
+ }
+ return ("Undefined Error");
+}
+
+static const char *umad_common_attr_str(__be16 attr_id)
+{
+ switch(be16toh(attr_id)) {
+ case UMAD_ATTR_CLASS_PORT_INFO:
+ return "Class Port Info";
+ case UMAD_ATTR_NOTICE:
+ return "Notice";
+ case UMAD_ATTR_INFORM_INFO:
+ return "Inform Info";
+ default:
+ return "<unknown>";
+ }
+}
+
+static const char * umad_sm_attr_str(__be16 attr_id)
+{
+ switch(be16toh(attr_id)) {
+ case UMAD_SM_ATTR_NODE_DESC:
+ return ("NodeDescription");
+ case UMAD_SM_ATTR_NODE_INFO:
+ return ("NodeInfo");
+ case UMAD_SM_ATTR_SWITCH_INFO:
+ return ("SwitchInfo");
+ case UMAD_SM_ATTR_GUID_INFO:
+ return ("GUIDInfo");
+ case UMAD_SM_ATTR_PORT_INFO:
+ return ("PortInfo");
+ case UMAD_SM_ATTR_PKEY_TABLE:
+ return ("P_KeyTable");
+ case UMAD_SM_ATTR_SLVL_TABLE:
+ return ("SLtoVLMappingTable");
+ case UMAD_SM_ATTR_VL_ARB_TABLE:
+ return ("VLArbitrationTable");
+ case UMAD_SM_ATTR_LINEAR_FT:
+ return ("LinearForwardingTable");
+ case UMAD_SM_ATTR_RANDOM_FT:
+ return ("RandomForwardingTable");
+ case UMAD_SM_ATTR_MCAST_FT:
+ return ("MulticastForwardingTable");
+ case UMAD_SM_ATTR_SM_INFO:
+ return ("SMInfo");
+ case UMAD_SM_ATTR_VENDOR_DIAG:
+ return ("VendorDiag");
+ case UMAD_SM_ATTR_LED_INFO:
+ return ("LedInfo");
+ case UMAD_SM_ATTR_LINK_SPD_WIDTH_TABLE:
+ return ("LinkSpeedWidthPairsTable");
+ case UMAD_SM_ATTR_VENDOR_MADS_TABLE:
+ return ("VendorSpecificMadsTable");
+ case UMAD_SM_ATTR_HIERARCHY_INFO:
+ return ("HierarchyInfo");
+ case UMAD_SM_ATTR_CABLE_INFO:
+ return ("CableInfo");
+ case UMAD_SM_ATTR_PORT_INFO_EXT:
+ return ("PortInfoExtended");
+ default:
+ return (umad_common_attr_str(attr_id));
+ }
+ return ("<unknown>");
+}
+
+static const char * umad_sa_attr_str(__be16 attr_id)
+{
+ switch(be16toh(attr_id)) {
+ case UMAD_SA_ATTR_NODE_REC:
+ return ("NodeRecord");
+ case UMAD_SA_ATTR_PORT_INFO_REC:
+ return ("PortInfoRecord");
+ case UMAD_SA_ATTR_SLVL_REC:
+ return ("SLtoVLMappingTableRecord");
+ case UMAD_SA_ATTR_SWITCH_INFO_REC:
+ return ("SwitchInfoRecord");
+ case UMAD_SA_ATTR_LINEAR_FT_REC:
+ return ("LinearForwardingTableRecord");
+ case UMAD_SA_ATTR_RANDOM_FT_REC:
+ return ("RandomForwardingTableRecord");
+ case UMAD_SA_ATTR_MCAST_FT_REC:
+ return ("MulticastForwardingTableRecord");
+ case UMAD_SA_ATTR_SM_INFO_REC:
+ return ("SMInfoRecord");
+ case UMAD_SA_ATTR_INFORM_INFO_REC:
+ return ("InformInfoRecord");
+ case UMAD_SA_ATTR_LINK_REC:
+ return ("LinkRecord");
+ case UMAD_SA_ATTR_GUID_INFO_REC:
+ return ("GuidInfoRecord");
+ case UMAD_SA_ATTR_SERVICE_REC:
+ return ("ServiceRecord");
+ case UMAD_SA_ATTR_PKEY_TABLE_REC:
+ return ("P_KeyTableRecord");
+ case UMAD_SA_ATTR_PATH_REC:
+ return ("PathRecord");
+ case UMAD_SA_ATTR_VL_ARB_REC:
+ return ("VLArbitrationTableRecord");
+ case UMAD_SA_ATTR_MCMEMBER_REC:
+ return ("MCMemberRecord");
+ case UMAD_SA_ATTR_TRACE_REC:
+ return ("TraceRecord");
+ case UMAD_SA_ATTR_MULTI_PATH_REC:
+ return ("MultiPathRecord");
+ case UMAD_SA_ATTR_SERVICE_ASSOC_REC:
+ return ("ServiceAssociationRecord");
+ case UMAD_SA_ATTR_LINK_SPD_WIDTH_TABLE_REC:
+ return ("LinkSpeedWidthPairsTableRecord");
+ case UMAD_SA_ATTR_HIERARCHY_INFO_REC:
+ return ("HierarchyInfoRecord");
+ case UMAD_SA_ATTR_CABLE_INFO_REC:
+ return ("CableInfoRecord");
+ case UMAD_SA_ATTR_PORT_INFO_EXT_REC:
+ return ("PortInfoExtendedRecord");
+ default:
+ return (umad_common_attr_str(attr_id));
+ }
+ return ("<unknown>");
+}
+
+static const char * umad_cm_attr_str(__be16 attr_id)
+{
+ switch(be16toh(attr_id)) {
+ case UMAD_CM_ATTR_REQ:
+ return "ConnectRequest";
+ case UMAD_CM_ATTR_MRA:
+ return "MsgRcptAck";
+ case UMAD_CM_ATTR_REJ:
+ return "ConnectReject";
+ case UMAD_CM_ATTR_REP:
+ return "ConnectReply";
+ case UMAD_CM_ATTR_RTU:
+ return "ReadyToUse";
+ case UMAD_CM_ATTR_DREQ:
+ return "DisconnectRequest";
+ case UMAD_CM_ATTR_DREP:
+ return "DisconnectReply";
+ case UMAD_CM_ATTR_SIDR_REQ:
+ return "ServiceIDResReq";
+ case UMAD_CM_ATTR_SIDR_REP:
+ return "ServiceIDResReqResp";
+ case UMAD_CM_ATTR_LAP:
+ return "LoadAlternatePath";
+ case UMAD_CM_ATTR_APR:
+ return "AlternatePathResponse";
+ case UMAD_CM_ATTR_SAP:
+ return "SuggestAlternatePath";
+ case UMAD_CM_ATTR_SPR:
+ return "SuggestPathResponse";
+ default:
+ return (umad_common_attr_str(attr_id));
+ }
+ return ("<unknown>");
+}
+
+const char * umad_attribute_str(uint8_t mgmt_class, __be16 attr_id)
+{
+ switch (mgmt_class) {
+ case UMAD_CLASS_SUBN_LID_ROUTED:
+ case UMAD_CLASS_SUBN_DIRECTED_ROUTE:
+ return(umad_sm_attr_str(attr_id));
+ case UMAD_CLASS_SUBN_ADM:
+ return(umad_sa_attr_str(attr_id));
+ case UMAD_CLASS_CM:
+ return(umad_cm_attr_str(attr_id));
+ }
+
+ return (umad_common_attr_str(attr_id));
+}
diff --git a/contrib/ofed/libibumad/umad_str.h b/contrib/ofed/libibumad/umad_str.h
new file mode 100644
index 0000000..f343942
--- /dev/null
+++ b/contrib/ofed/libibumad/umad_str.h
@@ -0,0 +1,57 @@
+/*
+ * Copyright (c) 2004, 2005, 2010 Intel Corporation. All rights reserved.
+ * Copyright (c) 2013 Lawrence Livermore National Security. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+#ifndef _UMAD_STR_H
+#define _UMAD_STR_H
+
+#include <infiniband/umad.h>
+
+#ifdef __cplusplus
+# define BEGIN_C_DECLS extern "C" {
+# define END_C_DECLS }
+#else /* !__cplusplus */
+# define BEGIN_C_DECLS
+# define END_C_DECLS
+#endif /* __cplusplus */
+
+BEGIN_C_DECLS
+
+const char * umad_class_str(uint8_t mgmt_class);
+const char * umad_method_str(uint8_t mgmt_class, uint8_t method);
+const char * umad_attribute_str(uint8_t mgmt_class, __be16 attr_id);
+
+const char * umad_common_mad_status_str(__be16 status);
+const char * umad_sa_mad_status_str(__be16 status);
+
+END_C_DECLS
+#endif /* _UMAD_STR_H */
diff --git a/contrib/ofed/libibumad/umad_types.h b/contrib/ofed/libibumad/umad_types.h
new file mode 100644
index 0000000..7d29dd4
--- /dev/null
+++ b/contrib/ofed/libibumad/umad_types.h
@@ -0,0 +1,217 @@
+/*
+ * Copyright (c) 2004 Mellanox Technologies Ltd. All rights reserved.
+ * Copyright (c) 2004 Infinicon Corporation. All rights reserved.
+ * Copyright (c) 2004, 2010 Intel Corporation. All rights reserved.
+ * Copyright (c) 2004 Topspin Corporation. All rights reserved.
+ * Copyright (c) 2004-2006 Voltaire Corporation. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+#ifndef _UMAD_TYPES_H
+#define _UMAD_TYPES_H
+
+#include <stdint.h>
+#include <infiniband/umad.h>
+
+#ifdef __cplusplus
+# define BEGIN_C_DECLS extern "C" {
+# define END_C_DECLS }
+#else /* !__cplusplus */
+# define BEGIN_C_DECLS
+# define END_C_DECLS
+#endif /* __cplusplus */
+
+BEGIN_C_DECLS
+
+#define UMAD_BASE_VERSION 1
+#define UMAD_QKEY 0x80010000
+
+/* Management classes */
+enum {
+ UMAD_CLASS_SUBN_LID_ROUTED = 0x01,
+ UMAD_CLASS_SUBN_DIRECTED_ROUTE = 0x81,
+ UMAD_CLASS_SUBN_ADM = 0x03,
+ UMAD_CLASS_PERF_MGMT = 0x04,
+ UMAD_CLASS_BM = 0x05,
+ UMAD_CLASS_DEVICE_MGMT = 0x06,
+ UMAD_CLASS_CM = 0x07,
+ UMAD_CLASS_SNMP = 0x08,
+ UMAD_CLASS_VENDOR_RANGE1_START = 0x09,
+ UMAD_CLASS_VENDOR_RANGE1_END = 0x0F,
+ UMAD_CLASS_APPLICATION_START = 0x10,
+ UMAD_CLASS_DEVICE_ADM = UMAD_CLASS_APPLICATION_START,
+ UMAD_CLASS_BOOT_MGMT = 0x11,
+ UMAD_CLASS_BIS = 0x12,
+ UMAD_CLASS_CONG_MGMT = 0x21,
+ UMAD_CLASS_APPLICATION_END = 0x2F,
+ UMAD_CLASS_VENDOR_RANGE2_START = 0x30,
+ UMAD_CLASS_VENDOR_RANGE2_END = 0x4F
+};
+
+/* Management methods */
+enum {
+ UMAD_METHOD_GET = 0x01,
+ UMAD_METHOD_SET = 0x02,
+ UMAD_METHOD_GET_RESP = 0x81,
+ UMAD_METHOD_SEND = 0x03,
+ UMAD_METHOD_TRAP = 0x05,
+ UMAD_METHOD_REPORT = 0x06,
+ UMAD_METHOD_REPORT_RESP = 0x86,
+ UMAD_METHOD_TRAP_REPRESS = 0x07,
+ UMAD_METHOD_RESP_MASK = 0x80
+};
+
+enum {
+ UMAD_STATUS_SUCCESS = 0x0000,
+ UMAD_STATUS_BUSY = 0x0001,
+ UMAD_STATUS_REDIRECT = 0x0002,
+
+ /* Invalid fields, bits 2-4 */
+ UMAD_STATUS_BAD_VERSION = (1 << 2),
+ UMAD_STATUS_METHOD_NOT_SUPPORTED = (2 << 2),
+ UMAD_STATUS_ATTR_NOT_SUPPORTED = (3 << 2),
+ UMAD_STATUS_INVALID_ATTR_VALUE = (7 << 2),
+
+ UMAD_STATUS_INVALID_FIELD_MASK = 0x001C,
+ UMAD_STATUS_CLASS_MASK = 0xFF00
+};
+
+/* Attributes common to multiple classes */
+enum {
+ UMAD_ATTR_CLASS_PORT_INFO = 0x0001,
+ UMAD_ATTR_NOTICE = 0x0002,
+ UMAD_ATTR_INFORM_INFO = 0x0003
+};
+
+/* RMPP information */
+#define UMAD_RMPP_VERSION 1
+enum {
+ UMAD_RMPP_FLAG_ACTIVE = 1,
+};
+
+enum {
+ UMAD_LEN_DATA = 232,
+ UMAD_LEN_RMPP_DATA = 220,
+ UMAD_LEN_DM_DATA = 192,
+ UMAD_LEN_VENDOR_DATA = 216,
+};
+
+struct umad_hdr {
+ uint8_t base_version;
+ uint8_t mgmt_class;
+ uint8_t class_version;
+ uint8_t method;
+ __be16 status;
+ __be16 class_specific;
+ __be64 tid;
+ __be16 attr_id;
+ __be16 resv;
+ __be32 attr_mod;
+};
+
+struct umad_rmpp_hdr {
+ uint8_t rmpp_version;
+ uint8_t rmpp_type;
+ uint8_t rmpp_rtime_flags;
+ uint8_t rmpp_status;
+ __be32 seg_num;
+ __be32 paylen_newwin;
+};
+
+struct umad_packet {
+ struct umad_hdr mad_hdr;
+ uint8_t data[UMAD_LEN_DATA]; /* network-byte order */
+};
+
+struct umad_rmpp_packet {
+ struct umad_hdr mad_hdr;
+ struct umad_rmpp_hdr rmpp_hdr;
+ uint8_t data[UMAD_LEN_RMPP_DATA]; /* network-byte order */
+};
+
+struct umad_dm_packet {
+ struct umad_hdr mad_hdr;
+ uint8_t reserved[40];
+ uint8_t data[UMAD_LEN_DM_DATA]; /* network-byte order */
+};
+
+struct umad_vendor_packet {
+ struct umad_hdr mad_hdr;
+ struct umad_rmpp_hdr rmpp_hdr;
+ uint8_t reserved;
+ uint8_t oui[3]; /* network-byte order */
+ uint8_t data[UMAD_LEN_VENDOR_DATA]; /* network-byte order */
+};
+
+enum {
+ UMAD_OPENIB_OUI = 0x001405
+};
+
+enum {
+ UMAD_CLASS_RESP_TIME_MASK = 0x1F
+};
+struct umad_class_port_info {
+ uint8_t base_ver;
+ uint8_t class_ver;
+ __be16 cap_mask;
+ __be32 cap_mask2_resp_time;
+ union {
+ uint8_t redir_gid[16] __attribute__((deprecated)); /* network byte order */
+ union umad_gid redirgid;
+ };
+ __be32 redir_tc_sl_fl;
+ __be16 redir_lid;
+ __be16 redir_pkey;
+ __be32 redir_qp;
+ __be32 redir_qkey;
+ union {
+ uint8_t trap_gid[16] __attribute__((deprecated)); /* network byte order */
+ union umad_gid trapgid;
+ };
+ __be32 trap_tc_sl_fl;
+ __be16 trap_lid;
+ __be16 trap_pkey;
+ __be32 trap_hl_qp;
+ __be32 trap_qkey;
+};
+static inline uint32_t
+umad_class_cap_mask2(struct umad_class_port_info *cpi)
+{
+ return (be32toh(cpi->cap_mask2_resp_time) >> 5);
+}
+static inline uint8_t
+umad_class_resp_time(struct umad_class_port_info *cpi)
+{
+ return (uint8_t)(be32toh(cpi->cap_mask2_resp_time)
+ & UMAD_CLASS_RESP_TIME_MASK);
+}
+
+END_C_DECLS
+#endif /* _UMAD_TYPES_H */
diff --git a/contrib/ofed/libibverbs/AUTHORS b/contrib/ofed/libibverbs/AUTHORS
deleted file mode 100644
index e2dc298..0000000
--- a/contrib/ofed/libibverbs/AUTHORS
+++ /dev/null
@@ -1,4 +0,0 @@
-Roland Dreier <roland@topspin.com>
-Dotan Barak <dotanb@mellanox.co.il>
-Sean Hefty <sean.hefty@intel.com>
-Michael S. Tsirkin <mst@mellanox.co.il>
diff --git a/contrib/ofed/libibverbs/COPYING b/contrib/ofed/libibverbs/COPYING
deleted file mode 100644
index ee1a79ff..0000000
--- a/contrib/ofed/libibverbs/COPYING
+++ /dev/null
@@ -1,378 +0,0 @@
-This software is available to you under a choice of one of two
-licenses. You may choose to be licensed under the terms of the the
-OpenIB.org BSD license or the GNU General Public License (GPL) Version
-2, both included below.
-
-Copyright (c) 2004 Topspin Communications. All rights reserved.
-
-==================================================================
-
- OpenIB.org BSD license
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions
-are met:
-
- * Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
-
- * Redistributions in binary form must reproduce the above
- copyright notice, this list of conditions and the following
- disclaimer in the documentation and/or other materials provided
- with the distribution.
-
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
-FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
-COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
-INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
-BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
-LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
-CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
-ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-POSSIBILITY OF SUCH DAMAGE.
-
-==================================================================
-
- GNU GENERAL PUBLIC LICENSE
- Version 2, June 1991
-
- Copyright (C) 1989, 1991 Free Software Foundation, Inc.
- 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- Everyone is permitted to copy and distribute verbatim copies
- of this license document, but changing it is not allowed.
-
- Preamble
-
- The licenses for most software are designed to take away your
-freedom to share and change it. By contrast, the GNU General Public
-License is intended to guarantee your freedom to share and change free
-software--to make sure the software is free for all its users. This
-General Public License applies to most of the Free Software
-Foundation's software and to any other program whose authors commit to
-using it. (Some other Free Software Foundation software is covered by
-the GNU Library General Public License instead.) You can apply it to
-your programs, too.
-
- When we speak of free software, we are referring to freedom, not
-price. Our General Public Licenses are designed to make sure that you
-have the freedom to distribute copies of free software (and charge for
-this service if you wish), that you receive source code or can get it
-if you want it, that you can change the software or use pieces of it
-in new free programs; and that you know you can do these things.
-
- To protect your rights, we need to make restrictions that forbid
-anyone to deny you these rights or to ask you to surrender the rights.
-These restrictions translate to certain responsibilities for you if you
-distribute copies of the software, or if you modify it.
-
- For example, if you distribute copies of such a program, whether
-gratis or for a fee, you must give the recipients all the rights that
-you have. You must make sure that they, too, receive or can get the
-source code. And you must show them these terms so they know their
-rights.
-
- We protect your rights with two steps: (1) copyright the software, and
-(2) offer you this license which gives you legal permission to copy,
-distribute and/or modify the software.
-
- Also, for each author's protection and ours, we want to make certain
-that everyone understands that there is no warranty for this free
-software. If the software is modified by someone else and passed on, we
-want its recipients to know that what they have is not the original, so
-that any problems introduced by others will not reflect on the original
-authors' reputations.
-
- Finally, any free program is threatened constantly by software
-patents. We wish to avoid the danger that redistributors of a free
-program will individually obtain patent licenses, in effect making the
-program proprietary. To prevent this, we have made it clear that any
-patent must be licensed for everyone's free use or not licensed at all.
-
- The precise terms and conditions for copying, distribution and
-modification follow.
-
- GNU GENERAL PUBLIC LICENSE
- TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
-
- 0. This License applies to any program or other work which contains
-a notice placed by the copyright holder saying it may be distributed
-under the terms of this General Public License. The "Program", below,
-refers to any such program or work, and a "work based on the Program"
-means either the Program or any derivative work under copyright law:
-that is to say, a work containing the Program or a portion of it,
-either verbatim or with modifications and/or translated into another
-language. (Hereinafter, translation is included without limitation in
-the term "modification".) Each licensee is addressed as "you".
-
-Activities other than copying, distribution and modification are not
-covered by this License; they are outside its scope. The act of
-running the Program is not restricted, and the output from the Program
-is covered only if its contents constitute a work based on the
-Program (independent of having been made by running the Program).
-Whether that is true depends on what the Program does.
-
- 1. You may copy and distribute verbatim copies of the Program's
-source code as you receive it, in any medium, provided that you
-conspicuously and appropriately publish on each copy an appropriate
-copyright notice and disclaimer of warranty; keep intact all the
-notices that refer to this License and to the absence of any warranty;
-and give any other recipients of the Program a copy of this License
-along with the Program.
-
-You may charge a fee for the physical act of transferring a copy, and
-you may at your option offer warranty protection in exchange for a fee.
-
- 2. You may modify your copy or copies of the Program or any portion
-of it, thus forming a work based on the Program, and copy and
-distribute such modifications or work under the terms of Section 1
-above, provided that you also meet all of these conditions:
-
- a) You must cause the modified files to carry prominent notices
- stating that you changed the files and the date of any change.
-
- b) You must cause any work that you distribute or publish, that in
- whole or in part contains or is derived from the Program or any
- part thereof, to be licensed as a whole at no charge to all third
- parties under the terms of this License.
-
- c) If the modified program normally reads commands interactively
- when run, you must cause it, when started running for such
- interactive use in the most ordinary way, to print or display an
- announcement including an appropriate copyright notice and a
- notice that there is no warranty (or else, saying that you provide
- a warranty) and that users may redistribute the program under
- these conditions, and telling the user how to view a copy of this
- License. (Exception: if the Program itself is interactive but
- does not normally print such an announcement, your work based on
- the Program is not required to print an announcement.)
-
-These requirements apply to the modified work as a whole. If
-identifiable sections of that work are not derived from the Program,
-and can be reasonably considered independent and separate works in
-themselves, then this License, and its terms, do not apply to those
-sections when you distribute them as separate works. But when you
-distribute the same sections as part of a whole which is a work based
-on the Program, the distribution of the whole must be on the terms of
-this License, whose permissions for other licensees extend to the
-entire whole, and thus to each and every part regardless of who wrote it.
-
-Thus, it is not the intent of this section to claim rights or contest
-your rights to work written entirely by you; rather, the intent is to
-exercise the right to control the distribution of derivative or
-collective works based on the Program.
-
-In addition, mere aggregation of another work not based on the Program
-with the Program (or with a work based on the Program) on a volume of
-a storage or distribution medium does not bring the other work under
-the scope of this License.
-
- 3. You may copy and distribute the Program (or a work based on it,
-under Section 2) in object code or executable form under the terms of
-Sections 1 and 2 above provided that you also do one of the following:
-
- a) Accompany it with the complete corresponding machine-readable
- source code, which must be distributed under the terms of Sections
- 1 and 2 above on a medium customarily used for software interchange; or,
-
- b) Accompany it with a written offer, valid for at least three
- years, to give any third party, for a charge no more than your
- cost of physically performing source distribution, a complete
- machine-readable copy of the corresponding source code, to be
- distributed under the terms of Sections 1 and 2 above on a medium
- customarily used for software interchange; or,
-
- c) Accompany it with the information you received as to the offer
- to distribute corresponding source code. (This alternative is
- allowed only for noncommercial distribution and only if you
- received the program in object code or executable form with such
- an offer, in accord with Subsection b above.)
-
-The source code for a work means the preferred form of the work for
-making modifications to it. For an executable work, complete source
-code means all the source code for all modules it contains, plus any
-associated interface definition files, plus the scripts used to
-control compilation and installation of the executable. However, as a
-special exception, the source code distributed need not include
-anything that is normally distributed (in either source or binary
-form) with the major components (compiler, kernel, and so on) of the
-operating system on which the executable runs, unless that component
-itself accompanies the executable.
-
-If distribution of executable or object code is made by offering
-access to copy from a designated place, then offering equivalent
-access to copy the source code from the same place counts as
-distribution of the source code, even though third parties are not
-compelled to copy the source along with the object code.
-
- 4. You may not copy, modify, sublicense, or distribute the Program
-except as expressly provided under this License. Any attempt
-otherwise to copy, modify, sublicense or distribute the Program is
-void, and will automatically terminate your rights under this License.
-However, parties who have received copies, or rights, from you under
-this License will not have their licenses terminated so long as such
-parties remain in full compliance.
-
- 5. You are not required to accept this License, since you have not
-signed it. However, nothing else grants you permission to modify or
-distribute the Program or its derivative works. These actions are
-prohibited by law if you do not accept this License. Therefore, by
-modifying or distributing the Program (or any work based on the
-Program), you indicate your acceptance of this License to do so, and
-all its terms and conditions for copying, distributing or modifying
-the Program or works based on it.
-
- 6. Each time you redistribute the Program (or any work based on the
-Program), the recipient automatically receives a license from the
-original licensor to copy, distribute or modify the Program subject to
-these terms and conditions. You may not impose any further
-restrictions on the recipients' exercise of the rights granted herein.
-You are not responsible for enforcing compliance by third parties to
-this License.
-
- 7. If, as a consequence of a court judgment or allegation of patent
-infringement or for any other reason (not limited to patent issues),
-conditions are imposed on you (whether by court order, agreement or
-otherwise) that contradict the conditions of this License, they do not
-excuse you from the conditions of this License. If you cannot
-distribute so as to satisfy simultaneously your obligations under this
-License and any other pertinent obligations, then as a consequence you
-may not distribute the Program at all. For example, if a patent
-license would not permit royalty-free redistribution of the Program by
-all those who receive copies directly or indirectly through you, then
-the only way you could satisfy both it and this License would be to
-refrain entirely from distribution of the Program.
-
-If any portion of this section is held invalid or unenforceable under
-any particular circumstance, the balance of the section is intended to
-apply and the section as a whole is intended to apply in other
-circumstances.
-
-It is not the purpose of this section to induce you to infringe any
-patents or other property right claims or to contest validity of any
-such claims; this section has the sole purpose of protecting the
-integrity of the free software distribution system, which is
-implemented by public license practices. Many people have made
-generous contributions to the wide range of software distributed
-through that system in reliance on consistent application of that
-system; it is up to the author/donor to decide if he or she is willing
-to distribute software through any other system and a licensee cannot
-impose that choice.
-
-This section is intended to make thoroughly clear what is believed to
-be a consequence of the rest of this License.
-
- 8. If the distribution and/or use of the Program is restricted in
-certain countries either by patents or by copyrighted interfaces, the
-original copyright holder who places the Program under this License
-may add an explicit geographical distribution limitation excluding
-those countries, so that distribution is permitted only in or among
-countries not thus excluded. In such case, this License incorporates
-the limitation as if written in the body of this License.
-
- 9. The Free Software Foundation may publish revised and/or new versions
-of the General Public License from time to time. Such new versions will
-be similar in spirit to the present version, but may differ in detail to
-address new problems or concerns.
-
-Each version is given a distinguishing version number. If the Program
-specifies a version number of this License which applies to it and "any
-later version", you have the option of following the terms and conditions
-either of that version or of any later version published by the Free
-Software Foundation. If the Program does not specify a version number of
-this License, you may choose any version ever published by the Free Software
-Foundation.
-
- 10. If you wish to incorporate parts of the Program into other free
-programs whose distribution conditions are different, write to the author
-to ask for permission. For software which is copyrighted by the Free
-Software Foundation, write to the Free Software Foundation; we sometimes
-make exceptions for this. Our decision will be guided by the two goals
-of preserving the free status of all derivatives of our free software and
-of promoting the sharing and reuse of software generally.
-
- NO WARRANTY
-
- 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
-FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
-OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
-PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
-OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
-MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
-TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
-PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
-REPAIR OR CORRECTION.
-
- 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
-WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
-REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
-INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
-OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
-TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
-YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
-PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
-POSSIBILITY OF SUCH DAMAGES.
-
- END OF TERMS AND CONDITIONS
-
- How to Apply These Terms to Your New Programs
-
- If you develop a new program, and you want it to be of the greatest
-possible use to the public, the best way to achieve this is to make it
-free software which everyone can redistribute and change under these terms.
-
- To do so, attach the following notices to the program. It is safest
-to attach them to the start of each source file to most effectively
-convey the exclusion of warranty; and each file should have at least
-the "copyright" line and a pointer to where the full notice is found.
-
- <one line to give the program's name and a brief idea of what it does.>
- Copyright (C) <year> <name of author>
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program 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 this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-
-Also add information on how to contact you by electronic and paper mail.
-
-If the program is interactive, make it output a short notice like this
-when it starts in an interactive mode:
-
- Gnomovision version 69, Copyright (C) year name of author
- Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
- This is free software, and you are welcome to redistribute it
- under certain conditions; type `show c' for details.
-
-The hypothetical commands `show w' and `show c' should show the appropriate
-parts of the General Public License. Of course, the commands you use may
-be called something other than `show w' and `show c'; they could even be
-mouse-clicks or menu items--whatever suits your program.
-
-You should also get your employer (if you work as a programmer) or your
-school, if any, to sign a "copyright disclaimer" for the program, if
-necessary. Here is a sample; alter the names:
-
- Yoyodyne, Inc., hereby disclaims all copyright interest in the program
- `Gnomovision' (which makes passes at compilers) written by James Hacker.
-
- <signature of Ty Coon>, 1 April 1989
- Ty Coon, President of Vice
-
-This General Public License does not permit incorporating your program into
-proprietary programs. If your program is a subroutine library, you may
-consider it more useful to permit linking proprietary applications with the
-library. If this is what you want to do, use the GNU Library General
-Public License instead of this License.
diff --git a/contrib/ofed/libibverbs/ChangeLog b/contrib/ofed/libibverbs/ChangeLog
deleted file mode 100644
index 27ee956..0000000
--- a/contrib/ofed/libibverbs/ChangeLog
+++ /dev/null
@@ -1,583 +0,0 @@
-2006-10-30 Jack Morgenstein <jackm@mellanox.co.il>
-
- * src/cmd.c (ibv_cmd_query_qp): Unmarshall sq_draining instead of
- en_sqd_async_notify.
-
- * include/infiniband/kern-abi.h: Change en_sqd_async_notify member
- of struct ibv_query_qp_resp to sq_draining.
-
-2006-10-30 Roland Dreier <rdreier@cisco.com>
-
- * src/init.c (find_drivers): Make find_drivers() take a const
- directory name, and tweak how we strip trailing /s so that we
- don't have to modify the directory name passed in. Constify
- default_path too.
-
-2006-10-25 Roland Dreier <rdreier@cisco.com>
-
- * src/init.c (init_drivers): Remove assignment to dev->driver now
- that it is gone for good.
-
- * include/infiniband/verbs.h: Remove .driver member of struct
- ibv_device, since it is never really used.
-
-2006-10-17 Roland Dreier <rdreier@cisco.com>
-
- * include/infiniband/arch.h: Update i386 and x86_64 memory barrier
- macros to be more than compiler barriers, to guard against
- out-of-order speculative reads.
-
- * include/infiniband/arch.h: Add rmb() and wmb() macros in
- addition to the full mb(), so that low-level drivers can ask for
- weaker ordering if that's all that is needed.
-
-2006-10-03 Roland Dreier <rdreier@cisco.com>
-
- * src/cmd.c (ibv_cmd_get_context_v2, ibv_cmd_get_context)
- (ibv_cmd_query_device, ibv_cmd_query_port, ibv_cmd_alloc_pd)
- (ibv_cmd_reg_mr, ibv_cmd_create_cq_v2, ibv_cmd_create_cq)
- (ibv_cmd_poll_cq, ibv_cmd_resize_cq, ibv_cmd_destroy_cq)
- (ibv_cmd_create_srq, ibv_cmd_create_qp, ibv_cmd_post_send)
- (ibv_cmd_post_recv, ibv_cmd_post_srq_recv, ibv_cmd_create_ah)
- (ibv_cmd_destroy_qp): Annotate so that Valgrind knows responses
- are defined after write() succeeds. The kernel writes into the
- response structure directly, so without these, Valgrind thinks
- that response structures are undefined memory. This is based on
- patches and suggestions by Rainer Keller <keller@hlrs.de>, Jeff
- Squyres <jsquyres@cisco.com> and Siqing Fan.
-
- * src/ibverbs.h: Add wrapper for VALGRIND_MAKE_MEM_DEFINED so that
- it can be used in .c files without worrying about whether Valgrind
- is installed or enabled.
-
- * configure.in: Add support for Valgrind annotation (enabled with
- --with-valgrind option to configure).
-
- * src/cmd.c (ibv_cmd_query_port, ibv_cmd_create_cq,
- ibv_cmd_modify_qp): Set reserved fields to 0 to avoid future
- problems and also to make Valgrind a little quieter.
-
- * src/init.c (init_drivers): Set node_type and transport_type
- values of device being created.
-
- * include/infiniband/verbs.h: Add ibv_node_type enum value
- IBV_NODE_RNIC, and add enum ibv_transport_type. Add node_type and
- transport_type fields to struct ibv_device.
-
-2006-09-12 Roland Dreier <rdreier@cisco.com>
-
- * include/infiniband/verbs.h: Swap wr_id and next members of
- struct ibv_send_wr and struct ibv_recv_wr. This allows wr_id to
- be naturally aligned without padding on 32-bit platforms.
-
-2006-08-23 Roland Dreier <rdreier@cisco.com>
-
- * include/infiniband/driver.h: Add a definition of the macro
- IBV_CMD_RESIZE_CQ_HAS_RESP_PARAMS so that low-level driver plugins
- can detect the changed signature of ibv_cmd_resize_cq().
-
-2006-08-23 Ralph Campbell <ralph.campbell@qlogic.com>
-
- * src/cmd.c (ibv_cmd_resize_cq): Add resp and resp_size parameters
- so that the low-level driver in the kernel can return
- device-specific information from the resize CQ operation.
-
-2006-07-26 Roland Dreier <rdreier@cisco.com>
-
- * src/verbs.c (ibv_reg_mr, ibv_dereg_mr): Add calls to
- ibv_dontfork_range() and ibv_dofork_range() for memory regions
- registered by library consumers.
-
- * include/infiniband/verbs.h: Add declaration of ibv_fork_init().
-
- * include/infiniband/driver.h: Add declarations of
- ibv_dontfork_range() and ibv_dofork_range().
-
- * src/memory.c: Rewrite to use a red-black tree instead of a
- linked list. Change from doing mlock()/munlock() to
- madvise(..., MADV_DONTFORK) and madvise(..., MADV_DOFORK), and
- change the name of the entry points to ibv_dontfork_range() and
- ibv_dofork_range(). Add ibv_fork_init() for applications to
- request fork-safe behavior.
-
- * src/ibverbs.h: Kill off unused declarations.
-
- * src/init.c (ibverbs_init): Get rid of call to ibv_init_mem_map().
-
- * include/infiniband/verbs.h: Add addr and length field to struct
- ibv_mr so that memory regions can be madvised(). This changes the
- ABI, since the layout of struct ibv_mr is changed.
-
-2006-07-04 Roland Dreier <rdreier@cisco.com>
-
- * include/infiniband/arch.h: Fix typo in sparc mb()
- implementation: the asm should just be empty -- the "sync"
- instruction was mistakenly cut and pasted from the ppc version.
-
-2006-06-07 Sean Hefty <sean.hefty@intel.com>
-
- * src/verbs.c include/infiniband/verbs.h: Add new routines:
- ibv_init_ah_from_wc() and ibv_create_ah_from_wc() to simplify UD QP
- communication.
-
- * src/marshall.c include/infiniband/marshall.h: Expose
- ibv_copy_ah_attr_from_kern to retrieve ibv_ah_attr from kernel for
- a UD QP.
-
-2006-06-01 Roland Dreier <rdreier@cisco.com>
-
- * src/device.c (ibv_get_device_list): Actually return a
- NULL-terminated array as the documentation promises.
-
-2006-05-31 Roland Dreier <rdreier@cisco.com>
-
- * src/init.c (find_drivers): Fix memory leak: the result of
- asprintf() needs to be freed when we're done with it.
-
- * examples/asyncwatch.c (event_name_str): Print human-readable
- form of IBV_EVENT_CLIENT_REREGISTER.
-
-2006-05-31 Leonid Arsh <leonida@voltaire.com>
-
- * include/infiniband/verbs.h: Add IBV_EVENT_CLIENT_REREGISTER.
-
-2006-05-22 Roland Dreier <rdreier@cisco.com>
-
- * examples/devinfo.c (print_hca_cap): Read board_id attribute from
- sysfs using ibv_read_sysfs_file() instead of libsysfs.
-
- * src/cmd.c, src/marshall.c, src/sysfs.c: Include <string.h>,
- since it is no longer implicitly included via <sysfs/libsysfs.h>.
-
- * include/infiniband/driver.h, include/infiniband/verbs.h,
- src/device.c, src/init.c, src/verbs.c: Remove dependency on
- libsysfs by implementing what is required directly on top of
- filesystem operations.
-
- * include/infiniband/driver.h, src/init.c: Change name of driver
- entry point to ibv_driver_init(), and update prototype to remove
- libsysfs dependency.
-
- * src/marshall.c, include/infiniband/marshall.h,
- include/infiniband/sa.h: Remove deprecated ib_xxx symbols.
-
- * Makefile.am: Bump SONAME to 2, since libibverbs 1.1 will be
- ABI-incompatible with libibverbs 1.0.
-
- * Create libibverbs 1.1 branch and bump version number to 1.1-pre1.
-
-2006-05-22 Michael S. Tsirkin <mst@mellanox.co.il>
-
- * include/infiniband/verbs.h: Remove trailing commas from
- enumerators to quiet warnings from obsolete compilers.
-
-2006-05-02 Roland Dreier <rdreier@cisco.com>
-
- * Release version 1.0.3.
-
-2006-05-01 Roland Dreier <rdreier@cisco.com>
-
- * include/infiniband/arch.h: Only SPARC V9 ISA supports membar.
- So just use generic memory barrier for older sparc archs.
-
-2006-04-11 Roland Dreier <rdreier@cisco.com>
-
- * src/sysfs.c (ibv_read_sysfs_file): Fix memory leak if open fails.
-
- * src/device.c (ibv_get_device_guid), src/verbs.c (ibv_query_gid,
- ibv_query_pkey), src/init.c (init_drivers, check_abi_version): Use
- libibverbs functions instead of libsysfs functions to get to sysfs.
-
- * src/sysfs.c (ibv_get_sysfs_path, ibv_read_sysfs_file): Add some
- simple functions for accessing sysfs without using libsysfs.
-
- * include/infiniband/sa-kern-abi.h: Deprecate struct
- ib_kern_path_rec name; struct ibv_kern_path_rec is now preferred.
-
- * include/infiniband/sa.h: Deprecate struct ib_sa_XXX names;
- struct ibv_sa_XXX is now preferred.
-
- * src/marshall.c, include/infiniband/marshall.h: Deprecate
- ib_copy_XXX() names; ibv_copy_XXX() is preferred. Add stub
- wrappers with the old names so old binaries still work.
-
-2006-04-11 Hoang-Nam Nguyen <HNGUYEN@de.ibm.com>
-
- * src/verbs.c (ibv_rate_to_mult, mult_to_ibv_rate): Add new
- functions to convert between IB rate enums and multiples of the
- base 2.5 Gb/sec rate.
-
-2006-04-11 Roland Dreier <rdreier@cisco.com>
-
- * include/infiniband/verbs.h: Add __attribute_const macro to
- portably mark functions as __attribute__((const))
-
-2006-03-28 Roland Dreier <rdreier@cisco.com>
-
- * src/init.c (load_driver): Print warning if dlopen() of a driver
- plugin fails.
-
-2006-03-22 Dotan Barak <dotanb@mellanox.co.il>
-
- * examples/asyncwatch.c: Print asynchronous event name as well as
- raw integer value.
-
-2006-03-22 Roland Dreier <rdreier@cisco.com>
-
- * include/infiniband/verbs.h (ibv_req_notify_cq): Document
- parameters better.
-
-2006-03-16 Roland Dreier <rdreier@cisco.com>
-
- * src/cmd.c, src/device.c, src/memory.c, src/verbs.c: Add include
- of <stdlib.h> to get a declaration of free() and avoid compile
- warnings.
-
-2006-03-14 Roland Dreier <rdreier@cisco.com>
-
- * Release version 1.0.2.
-
- * Makefile.am (EXTRA_DIST): Remove debian/ directory from
- tarballs, since Debian policy is that upstream tarballs should not
- include it.
-
-2006-03-13 Roland Dreier <rdreier@cisco.com>
-
- * Release version 1.0.1.
-
- * src/init.c (check_abi_version), src/verbs.c (ibv_query_gid,
- ibv_query_pkey): Use sysfs_open_attribute() and
- sysfs_read_attribute() instead of the deprecated function
- sysfs_read_attribute_value(), which is no longer present in
- libsysfs2 (which is already in Debian and Ubuntu).
-
- * Release version 1.0.
-
-2006-03-06 Roland Dreier <rdreier@cisco.com>
-
- * include/infiniband/verbs.h: Add enum ibv_rate to define encoding
- of static_rate field (based on a patch from Jack Morgenstein
- <jackm@mellanox.co.il>).
-
-2006-03-06 Ralph Campbell <ralphc@pathscale.com>
-
- * src/init.c (find_drivers): Fix minor memory leak: call
- globfree() to free memory allocated by glob().
-
-2006-02-23 Dotan Barak <dotanb@mellanox.co.il>
-
- * src/cmd.c (ibv_cmd_create_srq): Add support for kernel ABI
- version 6 (take SRQ capacity from kernel response to create SRQ).
-
-2006-02-16 Roland Dreier <rdreier@cisco.com>
-
- * Release version 1.0-rc7.
-
- * src/cmd.c (ibv_cmd_create_qp): Add support for kernel ABI
- version 5 (properly aligned struct ibv_create_qp_resp).
-
-2006-02-15 Roland Dreier <rdreier@cisco.com>
-
- * src/cmd.c (ibv_cmd_create_qp): Allow userspace device-specific
- driver to pass in a response buffer, so that the low-level driver
- in the kernel can pass back device-specific information. This
- changes the userspace driver API, since the signature of
- ibv_cmd_create_qp() is changed.
-
-2006-02-14 Roland Dreier <rdreier@cisco.com>
-
- * Release version 1.0-rc6.
-
-2006-02-13 Dotan Barak <dotanb@mellanox.co.il>
-
- * examples/devinfo.c (print_hca_cap): Print board_id from sysfs,
- if present.
-
-2006-02-13 Roland Dreier <rdreier@cisco.com>
-
- * examples/asyncwatch.c, examples/device_list.c,
- examples/devinfo.c: Remove cpu_to_be64()/be64_to_cpu() and use
- htonll()/ntohll() from <infiniband/arch.h>.
-
-2006-02-13 Dotan Barak <dotanb@mellanox.co.il>
-
- * src/cmd.c (ibv_cmd_query_qp, ibv_cmd_query_srq),
- include/infiniband/driver.h: Add driver interface for calling
- query QP and query SRQ kernel commands.
-
- * include/infiniband/kern-abi.h: Add kernel ABI for query QP and
- query SRQ.
-
- * src/verbs.c (ibv_query_qp, ibv_query_srq),
- include/infiniband/verbs.h: Add query QP and query SRQ library
- APIs. This changes the provider ABI, since new fields are added
- to struct ibv_context_ops; source compatibility with provider
- libraries is preserved, but binaries will have to be recompiled.
- Neither source nor binary compatibility with consumers of
- libibverbs is affected.
-
-2006-02-01 Roland Dreier <rdreier@cisco.com>
-
- * examples/rc_pingpong.c, examples/uc_pingpong.c,
- examples/ud_pingpong.c, examples/srq_pingpong.c: Fix bug in
- searching for device by name when there's more than one device.
-
-2006-01-31 Roland Dreier <rdreier@cisco.com>
-
- * include/infiniband/verbs.h, include/infiniband/driver.h: Remove
- useless "extern" from function declarations.
-
-2006-01-26 Roland Dreier <rdreier@cisco.com>
-
- * include/infiniband/driver.h, src/cmd.c (ibv_cmd_resize_cq): Add
- driver interface for calling resize CQ kernel command.
-
- * include/infiniband/kern-abi.h: Add resize CQ kernel ABI.
-
- * include/infiniband/verbs.h, src/verbs.c (ibv_resize_cq): Add
- resize CQ library API. This changes the provider ABI, since a new
- field is added to struct ibv_context_ops; source compatibility
- with provider libraries is preserved, but binaries will have to be
- recompiled. Neither source nor binary compatibility with
- consumers of libibverbs is affected.
-
-2006-01-25 Roland Dreier <rdreier@cisco.com>
-
- * examples/pingpong.c, examples/pingpong.h,
- examples/rc_pingpong.c, examples/uc_pingpong.c,
- examples/srq_pingpong.c: Move pp_get_local_lid() to pingpong.c to
- reduce code duplication.
-
-2006-01-22 Roland Dreier <rdreier@cisco.com>
-
- * Release version 1.0-rc5.
-
-2006-01-22 Dotan Barak <dotanb@mellanox.co.il>
-
- * examples/devinfo.c (main): Make ibv_devinfo list all IB devices
- by default, rather than the first device only.
-
-2006-01-20 Roland Dreier <rdreier@cisco.com>
-
- * examples/rc_pingpong.c, examples/uc_pingpong.c,
- examples/srq_pingpong.c: Add "-m/--mtu=" option to set path MTU.
- (Based on a patch from Ralph Campbell <ralphc@pathscale.com>)
-
- * examples/pingpong.c, examples/pingpong.h: Create generic
- pingpong files so that we can start factoring out common code from
- the pingpong examples. Start with functions to convert MTU to an
- IBV enum value.
-
-2006-01-17 Ralph Campbell <ralphc@pathscale.com>
-
- * examples/rc_pingpong.c (main), examples/srq_pingpong.c (main),
- examples/uc_pingpong.c (main), examples/ud_pingpong.c (main): Fix
- race when using CQ events by arming CQ before allowing remote side
- to start sending.
-
-2006-01-06 Roland Dreier <rdreier@cisco.com>
-
- * examples/srq_pingpong.c (main): Fix SRQ example to avoid
- problems with many QPs and events. Based on a patch from Dotan
- Barak (who also found the problem).
-
-2006-01-06 Ralph Campbell <ralphc@pathscale.com>
-
- * examples/rc_pingpong.c (main), examples/srq_pingpong.c (main),
- examples/uc_pingpong.c (main), examples/ud_pingpong.c (main): Fix
- test of return value of ibv_poll_cq().
-
-2006-01-04 Dotan Barak <dotanb@mellanox.co.il>
-
- * include/infiniband/verbs.h: Fix mask names in description of
- ibv_modify_srq.
-
-2006-01-04 Michael S. Tsirkin <mst@mellanox.co.il>
-
- * src/init.c (ibverbs_init): Fix ibverbs_init for multiple adapters.
- Noted by Christoph Raisch.
-
-2005-12-15 Roland Dreier <rdreier@cisco.com>
-
- * include/infiniband/verbs.h: Document that devices must be opened
- before calling ibv_free_device_list().
-
- * src/verbs.c (ibv_create_srq): Not all provider libraries will
- support SRQs, so check if the create_srq method is defined before
- calling it. (Based on a patch from Shirley Ma <xma@us.ibm.com>)
-
-2005-11-11 Roland Dreier <roland@cisco.com>
-
- * examples/asyncwatch.c, examples/rc_pingpong.c,
- examples/srq_pingpong.c, examples/uc_pingpong.c,
- examples/ud_pingpong.c, examples/device_list.c,
- examples/devinfo.c: Update examples to match new API.
-
- * include/infiniband/verbs.h, src/device.c, src/init.c,
- src/ibverbs.h: Change from dlist-based ibv_get_devices() API to
- simpler ibv_get_device_list() and ibv_free_device_list() API.
-
-2005-11-10 Sean Hefty <sean.hefty@intel.com>
-
- * include/infiniband/sa-kern-abi.h: New include file to contain
- definitions of SA structures passed between userspace and kernel.
-
- * include/infiniband/sa.h: New include file for definitions of
- SA structures used by multiple libraries.
-
- * include/infiniband/marshall.h src/marshall.c: New files to define
- routines used to exchange data with kernel modules.
-
- * include/infiniband/kern-abi.h: Added data structures used to exchange
- QP attribute with kernel modules.
-
-2005-11-09 Michael S. Tsirkin <mst@mellanox.co.il>
-
- * src/device.c (ibv_get_devices): Make function reentrant by using
- a mutex to make sure we initialize the device list at most once.
-
-2005-11-08 Roland Dreier <roland@cisco.com>
-
- * src/cmd.c (ibv_cmd_create_qp): Add handling for new create QP
- interface, which has the kernel return QP capabilities.
-
- * src/cmd.c (ibv_cmd_modify_srq): Split off handling of modify SRQ
- for ABI versions 3 and older, which passed max_sge as part of command.
-
-2005-10-30 Roland Dreier <roland@cisco.com>
-
- * examples/srq_pingpong.c (pp_init_ctx): Create CQ with rx_depth +
- num_qp entries, instead of just rx_depth + 1 entries, because
- there can be one send completion pending for each QP.
-
-2005-10-25 Roland Dreier <roland@cisco.com>
-
- * Release version 1.0-rc4.
-
- * examples/uc_pingpong.c (pp_connect_ctx): Fix QP attribute masks
- used to modify QP to RTR and RTS -- we should not be setting
- RDMA/atomic attributes for UC QPs. Now that the mthca kernel
- driver bug is fixed, the error is exposed here.
-
- * examples/rc_pingpong.c, examples/srq_pingpong.c,
- examples/uc_pingpong.c, examples/ud_pingpong.c: Keep track of
- whether send and/or receive is pending. This avoids failures when
- the remote side receives data and posts a send very quickly, and
- the local side completes the receive before the previous send.
- With the old code, this could result in posting a send before the
- previous send completed, and therefore overrun the send queue.
-
-2005-10-23 Roland Dreier <roland@cisco.com>
-
- * src/cmd.c (ibv_cmd_get_context_v2): Correct silly mistake in
- computation of size of buffer for old ABI command: we need to use
- sizeof *cmd instead of sizeof cmd, since cmd is a pointer.
-
-2005-10-21 Roland Dreier <roland@cisco.com>
-
- * src/cmd.c (ibv_cmd_post_send, ibv_cmd_post_recv,
- ibv_cmd_post_srq_recv): Correct value that we check write() return
- value against so that we check against the size we actually try to
- write, instead of just sizeof cmd.
-
-2005-10-19 Roland Dreier <roland@cisco.com>
-
- * src/cmd.c (ibv_cmd_req_notify_cq): Correct how we pass
- solicited_only flag into the kernel.
-
-2005-10-13 Roland Dreier <roland@cisco.com>
-
- * include/infiniband/driver.h, src/cmd.c, src/libibverbs.map: Add
- command functions for calling new kernel commands.
-
- * include/infiniband/verbs.h: Add qp_type to struct ibv_qp so that
- we know when we're posting a send on a UD QP, and add kernel
- handle member to struct ibv_ah so we can handle drivers that do
- create AH and destroy AH operations in the kernel.
-
- * include/infiniband/kern-abi.h: Add new command structures for
- poll CQ, request notification for CQ, post send, post receive,
- post SRQ receive, create AH and destroy AH commands. These will
- be used by the PathScale userspace driver.
-
-2005-10-12 Roland Dreier <roland@cisco.com>
-
- * examples/srq_pingpong.c (main): Zero out unused entries in
- my_dest array to avoid string overflows when we send to the other
- side.
-
-2005-10-09 Roland Dreier <roland@cisco.com>
-
- * examples/devinfo.c (print_hca_cap): Only print max_mr_size and
- page_size_cap if verbose is set.
-
-2005-10-05 Roland Dreier <roland@cisco.com>
-
- * src/cmd.c (ibv_cmd_modify_srq): Add function for marshalling
- modify SRQ command.
-
-2005-09-29 Roland Dreier <roland@cisco.com>
-
- * examples/devinfo.c (print_hca_cap): Get rid of formatting of
- firmware version in what should be device-independent code.
-
- * include/infiniband/driver.h, include/infiniband/verbs.h,
- src/cmd.c (ibv_cmd_query_device): Change firmware version in
- struct ibv_device_attr to be a string formatted by device-specific
- library.
-
-2005-09-25 Roland Dreier <roland@cisco.com>
-
- * examples/rc_pingpong.c, examples/srq_pingpong.c,
- examples/uc_pingpong.c, examples/ud_pingpong.c: Update to match
- new completion channel and CQ creation API.
-
- * include/infiniband/driver.h, include/infiniband/verbs.h,
- src/device.c, src/ibverbs.h, src/verbs.c, src/cmd.c: Add notion of
- "completion channel" that allows consumers to dynamically create
- and destroy file descriptors for retrieving completion events.
- Completion channels are handled natively with kernel ABI version 3
- and simulated with backwards compatibility implementations for ABI
- versions 1 and 2.
-
- * include/infiniband/kern-abi.h: Update to match kernel ABI
- version 3.
-
-2005-09-07 Roland Dreier <roland@cisco.com>
-
- * src/device.c (ibv_get_device_guid): Use htonll() instead of
- relying on pointer aliasing (which seems to break for some gcc
- versions).
-
- * include/infiniband/arch.h: Add htonll() and ntohll() functions.
-
-2005-09-06 Roland Dreier <roland@cisco.com>
-
- * include/infiniband/kern-abi.h, include/infiniband/verbs.h,
- src/cmd.c, src/device.c, src/verbs.c, examples/asyncwatch.c:
- Update to handle new kernel ABI for avoiding stale completion
- events. This is completely analogous to the previous asynchronous
- event change.
-
-2005-08-31 Roland Dreier <roland@cisco.com>
-
- * include/infiniband/kern-abi.h, include/infiniband/verbs.h,
- src/cmd.c, src/device.c, src/ibverbs.h, src/init.c, src/verbs.c,
- examples/asyncwatch.c: Update to handle new kernel ABI for
- avoiding stale asynchronous events. When a CQ, QP or SRQ is
- destroyed, the kernel reports the number of events it has given to
- userspace, and we wait until we've handled the same number of
- events.
-
- This does introduce a library API change: consumers are now
- required to call ibv_put_async_event() to release every
- asynchronous event that they retrieve via ibv_get_async_event().
-
-2005-08-30 Roland Dreier <roland@cisco.com>
-
- * man/ibv_asyncwatch.1, man/ibv_devices.1, man/ibv_devinfo.1,
- man/ibv_rc_pingpong.1, man/ibv_srq_pingpong.1,
- man/ibv_uc_pingpong.1, man/ibv_ud_pingpong.1: Add man pages for
- example programs.
-
- * examples/devinfo.c: Merge with Dotan Barak's vstat tool.
diff --git a/contrib/ofed/libibverbs/Makefile b/contrib/ofed/libibverbs/Makefile
new file mode 100644
index 0000000..846bad0
--- /dev/null
+++ b/contrib/ofed/libibverbs/Makefile
@@ -0,0 +1,75 @@
+# $FreeBSD$
+
+.PATH: ${.CURDIR} ${.CURDIR}/man
+
+LIB= ibverbs
+SHLIB_MAJOR= 1
+SHLIBDIR?= /usr/lib
+MK_PROFILE= no
+VERSION_MAP= ${.CURDIR}/libibverbs.map
+
+CFLAGS+= -I${.CURDIR}
+
+SRCS= \
+cmd.c \
+compat-1_0.c \
+device.c \
+enum_strs.c \
+init.c \
+marshall.c \
+memory.c \
+sysfs.c \
+verbs.c
+
+MAN= \
+ibv_alloc_mw.3 \
+ibv_alloc_pd.3 \
+ibv_attach_mcast.3 \
+ibv_bind_mw.3 \
+ibv_create_ah.3 \
+ibv_create_ah_from_wc.3 \
+ibv_create_comp_channel.3 \
+ibv_create_cq.3 \
+ibv_create_cq_ex.3 \
+ibv_create_flow.3 \
+ibv_create_qp.3 \
+ibv_create_qp_ex.3 \
+ibv_create_rwq_ind_table.3 \
+ibv_create_srq.3 \
+ibv_create_srq_ex.3 \
+ibv_create_wq.3 \
+ibv_event_type_str.3 \
+ibv_fork_init.3 \
+ibv_get_async_event.3 \
+ibv_get_cq_event.3 \
+ibv_get_device_guid.3 \
+ibv_get_device_list.3 \
+ibv_get_device_name.3 \
+ibv_get_srq_num.3 \
+ibv_inc_rkey.3 \
+ibv_modify_qp.3 \
+ibv_modify_srq.3 \
+ibv_modify_wq.3 \
+ibv_open_device.3 \
+ibv_open_qp.3 \
+ibv_open_xrcd.3 \
+ibv_poll_cq.3 \
+ibv_post_recv.3 \
+ibv_post_send.3 \
+ibv_post_srq_recv.3 \
+ibv_query_device.3 \
+ibv_query_device_ex.3 \
+ibv_query_gid.3 \
+ibv_query_pkey.3 \
+ibv_query_port.3 \
+ibv_query_qp.3 \
+ibv_query_rt_values_ex.3 \
+ibv_query_srq.3 \
+ibv_rate_to_mbps.3 \
+ibv_rate_to_mult.3 \
+ibv_reg_mr.3 \
+ibv_req_notify_cq.3 \
+ibv_rereg_mr.3 \
+ibv_resize_cq.3
+
+.include <bsd.lib.mk>
diff --git a/contrib/ofed/libibverbs/Makefile.am b/contrib/ofed/libibverbs/Makefile.am
deleted file mode 100644
index 5f9c45c..0000000
--- a/contrib/ofed/libibverbs/Makefile.am
+++ /dev/null
@@ -1,114 +0,0 @@
-INCLUDES = -I$(srcdir)/include
-
-lib_LTLIBRARIES = src/libibverbs.la
-
-AM_CFLAGS = -g -Wall -D_GNU_SOURCE
-
-src_libibverbs_la_CFLAGS = $(AM_CFLAGS) -DIBV_CONFIG_DIR=\"$(sysconfdir)/libibverbs.d\"
-
-libibverbs_version_script = @LIBIBVERBS_VERSION_SCRIPT@
-
-src_libibverbs_la_SOURCES = src/cmd.c src/compat-1_0.c src/device.c src/init.c \
- src/marshall.c src/memory.c src/sysfs.c src/verbs.c \
- src/enum_strs.c
-src_libibverbs_la_LDFLAGS = -version-info 1 -export-dynamic \
- $(libibverbs_version_script)
-src_libibverbs_la_DEPENDENCIES = $(srcdir)/src/libibverbs.map
-
-bin_PROGRAMS = examples/ibv_devices examples/ibv_devinfo \
- examples/ibv_asyncwatch examples/ibv_rc_pingpong examples/ibv_uc_pingpong \
- examples/ibv_ud_pingpong examples/ibv_srq_pingpong
-examples_ibv_devices_SOURCES = examples/device_list.c
-examples_ibv_devices_LDADD = $(top_builddir)/src/libibverbs.la
-examples_ibv_devinfo_SOURCES = examples/devinfo.c
-examples_ibv_devinfo_LDADD = $(top_builddir)/src/libibverbs.la
-examples_ibv_rc_pingpong_SOURCES = examples/rc_pingpong.c examples/pingpong.c
-examples_ibv_rc_pingpong_LDADD = $(top_builddir)/src/libibverbs.la
-examples_ibv_uc_pingpong_SOURCES = examples/uc_pingpong.c examples/pingpong.c
-examples_ibv_uc_pingpong_LDADD = $(top_builddir)/src/libibverbs.la
-examples_ibv_ud_pingpong_SOURCES = examples/ud_pingpong.c examples/pingpong.c
-examples_ibv_ud_pingpong_LDADD = $(top_builddir)/src/libibverbs.la
-examples_ibv_srq_pingpong_SOURCES = examples/srq_pingpong.c examples/pingpong.c
-examples_ibv_srq_pingpong_LDADD = $(top_builddir)/src/libibverbs.la
-examples_ibv_asyncwatch_SOURCES = examples/asyncwatch.c
-examples_ibv_asyncwatch_LDADD = $(top_builddir)/src/libibverbs.la
-
-libibverbsincludedir = $(includedir)/infiniband
-
-libibverbsinclude_HEADERS = include/infiniband/arch.h include/infiniband/driver.h \
- include/infiniband/kern-abi.h include/infiniband/opcode.h include/infiniband/verbs.h \
- include/infiniband/sa-kern-abi.h include/infiniband/sa.h include/infiniband/marshall.h
-
-man_MANS = man/ibv_asyncwatch.1 man/ibv_devices.1 man/ibv_devinfo.1 \
- man/ibv_rc_pingpong.1 man/ibv_uc_pingpong.1 man/ibv_ud_pingpong.1 \
- man/ibv_srq_pingpong.1 man/ibv_alloc_pd.3 man/ibv_attach_mcast.3 \
- man/ibv_create_ah.3 man/ibv_create_ah_from_wc.3 \
- man/ibv_create_comp_channel.3 man/ibv_create_cq.3 \
- man/ibv_create_qp.3 man/ibv_create_srq.3 \
- man/ibv_create_xrc_rcv_qp.3 man/ibv_event_type_str.3 \
- man/ibv_fork_init.3 man/ibv_get_async_event.3 \
- man/ibv_get_cq_event.3 man/ibv_get_device_guid.3 \
- man/ibv_get_device_list.3 man/ibv_get_device_name.3 \
- man/ibv_modify_qp.3 man/ibv_modify_srq.3 man/ibv_modify_xrc_rcv_qp.3 \
- man/ibv_open_device.3 man/ibv_open_xrc_domain.3 \
- man/ibv_poll_cq.3 man/ibv_post_recv.3 man/ibv_post_send.3 \
- man/ibv_post_srq_recv.3 man/ibv_query_device.3 man/ibv_query_gid.3 \
- man/ibv_query_pkey.3 man/ibv_query_port.3 man/ibv_query_qp.3 \
- man/ibv_query_srq.3 man/ibv_query_xrc_rcv_qp.3 \
- man/ibv_rate_to_mult.3 man/ibv_reg_mr.3 man/ibv_reg_xrc_rcv_qp.3 \
- man/ibv_req_notify_cq.3 man/ibv_resize_cq.3 man/verbs.7
-
-DEBIAN = debian/changelog debian/compat debian/control debian/copyright \
- debian/ibverbs-utils.install debian/libibverbs1.install \
- debian/libibverbs1.postinst debian/libibverbs-dev.install \
- debian/rules
-
-EXTRA_DIST = include/infiniband/driver.h include/infiniband/kern-abi.h \
- include/infiniband/opcode.h include/infiniband/verbs.h include/infiniband/marshall.h \
- include/infiniband/sa-kern-abi.h include/infiniband/sa.h \
- src/ibverbs.h examples/pingpong.h \
- src/libibverbs.map libibverbs.spec.in $(man_MANS)
-
-dist-hook: libibverbs.spec
- cp libibverbs.spec $(distdir)
-
-install-data-hook:
- cd $(DESTDIR)$(mandir)/man3 && \
- $(RM) ibv_ack_async_event.3 && \
- $(RM) ibv_ack_cq_events.3 && \
- $(RM) ibv_close_device.3 && \
- $(RM) ibv_close_xrc_domain.3 && \
- $(RM) ibv_create_xrc_srq.3 && \
- $(RM) ibv_dealloc_pd.3 && \
- $(RM) ibv_dereg_mr.3 && \
- $(RM) ibv_destroy_ah.3 && \
- $(RM) ibv_destroy_comp_channel.3 && \
- $(RM) ibv_destroy_cq.3 && \
- $(RM) ibv_destroy_qp.3 && \
- $(RM) ibv_destroy_srq.3 && \
- $(RM) ibv_detach_mcast.3 && \
- $(RM) ibv_free_device_list.3 && \
- $(RM) ibv_init_ah_from_wc.3 && \
- $(RM) ibv_unreg_xrc_rcv_qp.3 && \
- $(RM) mult_to_ibv_rate.3 && \
- $(RM) ibv_node_type_str.3 && \
- $(RM) ibv_port_state_str.3 && \
- $(LN_S) ibv_get_async_event.3 ibv_ack_async_event.3 && \
- $(LN_S) ibv_get_cq_event.3 ibv_ack_cq_events.3 && \
- $(LN_S) ibv_open_device.3 ibv_close_device.3 && \
- $(LN_S) ibv_open_xrc_domain.3 ibv_close_xrc_domain.3 && \
- $(LN_S) ibv_create_srq.3 ibv_create_xrc_srq.3 && \
- $(LN_S) ibv_alloc_pd.3 ibv_dealloc_pd.3 && \
- $(LN_S) ibv_reg_mr.3 ibv_dereg_mr.3 && \
- $(LN_S) ibv_create_ah.3 ibv_destroy_ah.3 && \
- $(LN_S) ibv_create_comp_channel.3 ibv_destroy_comp_channel.3 && \
- $(LN_S) ibv_create_cq.3 ibv_destroy_cq.3 && \
- $(LN_S) ibv_create_qp.3 ibv_destroy_qp.3 && \
- $(LN_S) ibv_create_srq.3 ibv_destroy_srq.3 && \
- $(LN_S) ibv_attach_mcast.3 ibv_detach_mcast.3 && \
- $(LN_S) ibv_get_device_list.3 ibv_free_device_list.3 && \
- $(LN_S) ibv_create_ah_from_wc.3 ibv_init_ah_from_wc.3 && \
- $(LN_S) ibv_reg_xrc_rcv_qp.3 ibv_unreg_xrc_rcv_qp.3 && \
- $(LN_S) ibv_rate_to_mult.3 mult_to_ibv_rate.3 && \
- $(LN_S) ibv_event_type_str.3 ibv_node_type_str.3 && \
- $(LN_S) ibv_event_type_str.3 ibv_port_state_str.3
diff --git a/contrib/ofed/libibverbs/README b/contrib/ofed/libibverbs/README
deleted file mode 100644
index 848eb05..0000000
--- a/contrib/ofed/libibverbs/README
+++ /dev/null
@@ -1,164 +0,0 @@
-Introduction
-============
-
-libibverbs is a library that allows programs to use RDMA "verbs" for
-direct access to RDMA (currently InfiniBand and iWARP) hardware from
-userspace. For more information on RDMA verbs, see the InfiniBand
-Architecture Specification vol. 1, especially chapter 11, and the RDMA
-Consortium's RDMA Protocol Verbs Specification.
-
-Using libibverbs
-================
-
-Device nodes
-------------
-
-The verbs library expects special character device files named
-/dev/infiniband/uverbsN to be created. When you load the kernel
-modules, including both the low-level driver for your IB hardware as
-well as the ib_uverbs module, you should see one or more uverbsN
-entries in /sys/class/infiniband_verbs in addition to the
-/dev/infiniband/uverbsN character device files.
-
-To create the appropriate character device files automatically with
-udev, a rule like
-
- KERNEL="uverbs*", NAME="infiniband/%k"
-
-can be used. This will create device nodes named
-
- /dev/infiniband/uverbs0
-
-and so on. Since the RDMA userspace verbs should be safe for use by
-non-privileged users, you may want to add an appropriate MODE or GROUP
-to your udev rule.
-
-Permissions
------------
-
-To use IB verbs from userspace, a process must be able to access the
-appropriate /dev/infiniband/uverbsN special device file. You can
-check the permissions on this file with the command
-
- ls -l /dev/infiniband/uverbs*
-
-Make sure that the permissions on these files are such that the
-user/group that your verbs program runs as can access the device file.
-
-To use IB verbs from userspace, a process must also have permission to
-tell the kernel to lock sufficient memory for all of your registered
-memory regions as well as the memory used internally by IB resources
-such as queue pairs (QPs) and completion queues (CQs). To check your
-resource limits, use the command
-
- ulimit -l
-
-(or "limit memorylocked" for csh-like shells).
-
-If you see a small number such as 32 (the units are KB) then you will
-need to increase this limit. This is usually done for ordinary users
-via the file /etc/security/limits.conf. More configuration may be
-necessary if you are logging in via OpenSSH and your sshd is
-configured to use privilege separation.
-
-Valgrind support
-----------------
-
-When running applications that use libibverbs under the Valgrind
-memory-checking debugger, Valgrind will falsely report "read from
-uninitialized" for memory that was initialized by the kernel drivers.
-Specifically, Valgrind cannot see when kernel drivers write to
-userspace memory, so when the process reads from that memory, Valgrind
-incorrectly assumes that the memory contents are uninitialized, and
-therefore raises a warning.
-
-libibverbs can be built with specific support for the Valgrind
-memory-checking debugger by specifying the --with-valgrind command
-line argument to configure. This flag enables code in libibverbs to
-tell Valgrind "this memory may look uninitialized, but it's really
-OK," which therefore suppresses the incorrect "read from
-uninitialized" warnings. This code adds trivial overhead to the
-critical performance path, so it is disabled by default. The intent
-is that production users can use a "normal" build of libibverbs and
-developers can use the "valgrind debug" build by simply switching
-their LD_LIBRARY_PATH environment variables.
-
-Libibverbs needs some header files from Valgrind in order to compile
-this support; it is important to use the header files from the same
-version of Valgrind that will be used at run time. You may need to
-specify the directory where Valgrind's header files are installed as
-an argument to --with-valgrind. For example
-
- ./configure --with-valgrind=/opt/valgrind
-
-will make the libibverbs build look for valgrind headers in
-/opt/valgrind/include
-
-Reporting bugs
-==============
-
-Bugs should be reported to the OpenFabrics mailing list
-<general@lists.openfabrics.org>. In your bug report, please include:
-
- * Information about your system:
- - Linux distribution and version
- - Linux kernel and version
- - InfiniBand/iWARP hardware and firmware version
- - ... any other relevant information
-
- * How to reproduce the bug. Command line arguments for a libibverbs
- example program or source code that other developers can
- compile and run is most convenient.
-
- * If the bug is a crash, the exact output printed out when the crash
- occurred, including any kernel messages produced.
-
- * If a verbs call is mysteriously returning an error or failing, the
- output of "strace -ewrite -ewrite=all <command>".
-
-Submitting patches
-==================
-
-Patches should also be submitted to the OpenFabrics mailing list
-<general@lists.openfabrics.org>. Please use unified diff form (the -u
-option to GNU diff), and include a good description of what your patch
-does and why it should be applied. If your patch fixes a bug, please
-make sure to describe the bug and how your fix works.
-
-Please include a change to the ChangeLog file (in standard GNU
-changelog format) as part of your patch.
-
-Make sure that your contribution can be licensed under the same
-license as the original code you are patching, and that you have all
-necessary permissions to release your work.
-
-TODO
-====
-
-1.1 series
-----------
-
-The libibverbs API and ABI are frozen for all releases in the 1.1
-series. Methods were added to struct ibv_context to implement the
-following features, so it should be possible to add them in a future
-release in the 1.1 series:
-
- * Memory window (MW) support.
-
- * Implement the reregister memory region (MR) verb. We will add an
- extension to the IB spec to allow the application to indicate that
- the region is only being extended, and that operations in progress
- should _not_ fail (contrary to the IB spec, which states that
- reregister must be implemented so that it behaves equivalently to a
- deregister followed by a register).
-
-Other possibilities
--------------------
-
-There are no plans to implement the following features, which would be
-needed for completeness but don't seem particularly useful. However,
-if there is demand from application developers or an implementation is
-contributed, then the feature may be added.
-
- * Implement the query address handle (AH) verb.
- * Implement the query memory region (MR) verb.
diff --git a/contrib/ofed/usr.lib/libibverbs/alloca.h b/contrib/ofed/libibverbs/alloca.h
index b0311c0..b0311c0 100644
--- a/contrib/ofed/usr.lib/libibverbs/alloca.h
+++ b/contrib/ofed/libibverbs/alloca.h
diff --git a/contrib/ofed/libibverbs/arch.h b/contrib/ofed/libibverbs/arch.h
new file mode 100644
index 0000000..18277c0
--- /dev/null
+++ b/contrib/ofed/libibverbs/arch.h
@@ -0,0 +1,51 @@
+/*
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#ifndef INFINIBAND_ARCH_H
+#define INFINIBAND_ARCH_H
+
+#include <stdint.h>
+#include <infiniband/endian.h>
+
+#warning "This header is obsolete."
+
+#ifndef ntohll
+#undef htonll
+#undef ntohll
+/* Users should use the glibc functions directly, not these wrappers */
+static inline __attribute__((deprecated)) uint64_t htonll(uint64_t x) { return htobe64(x); }
+static inline __attribute__((deprecated)) uint64_t ntohll(uint64_t x) { return be64toh(x); }
+#define htonll htonll
+#define ntohll ntohll
+#endif
+
+/* Barrier macros are no longer provided by libibverbs */
+
+#endif /* INFINIBAND_ARCH_H */
diff --git a/contrib/ofed/libibverbs/autogen.sh b/contrib/ofed/libibverbs/autogen.sh
deleted file mode 100755
index fd47839..0000000
--- a/contrib/ofed/libibverbs/autogen.sh
+++ /dev/null
@@ -1,8 +0,0 @@
-#! /bin/sh
-
-set -x
-aclocal -I config
-libtoolize --force --copy
-autoheader
-automake --foreign --add-missing --copy
-autoconf
diff --git a/contrib/ofed/libibverbs/cmd.c b/contrib/ofed/libibverbs/cmd.c
new file mode 100644
index 0000000..0a9cc38
--- /dev/null
+++ b/contrib/ofed/libibverbs/cmd.c
@@ -0,0 +1,2090 @@
+/*
+ * Copyright (c) 2005 Topspin Communications. All rights reserved.
+ * Copyright (c) 2005 PathScale, Inc. All rights reserved.
+ * Copyright (c) 2006 Cisco Systems, Inc. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#include <config.h>
+
+#include <stdio.h>
+#include <unistd.h>
+#include <stdlib.h>
+#include <errno.h>
+#include <alloca.h>
+#include <string.h>
+
+#include "ibverbs.h"
+#include <sys/param.h>
+
+int ibv_cmd_get_context(struct ibv_context *context, struct ibv_get_context *cmd,
+ size_t cmd_size, struct ibv_get_context_resp *resp,
+ size_t resp_size)
+{
+ if (abi_ver < IB_USER_VERBS_MIN_ABI_VERSION)
+ return ENOSYS;
+
+ IBV_INIT_CMD_RESP(cmd, cmd_size, GET_CONTEXT, resp, resp_size);
+
+ if (write(context->cmd_fd, cmd, cmd_size) != cmd_size)
+ return errno;
+
+ (void) VALGRIND_MAKE_MEM_DEFINED(resp, resp_size);
+
+ context->async_fd = resp->async_fd;
+ context->num_comp_vectors = resp->num_comp_vectors;
+
+ return 0;
+}
+
+static void copy_query_dev_fields(struct ibv_device_attr *device_attr,
+ struct ibv_query_device_resp *resp,
+ uint64_t *raw_fw_ver)
+{
+ *raw_fw_ver = resp->fw_ver;
+ device_attr->node_guid = resp->node_guid;
+ device_attr->sys_image_guid = resp->sys_image_guid;
+ device_attr->max_mr_size = resp->max_mr_size;
+ device_attr->page_size_cap = resp->page_size_cap;
+ device_attr->vendor_id = resp->vendor_id;
+ device_attr->vendor_part_id = resp->vendor_part_id;
+ device_attr->hw_ver = resp->hw_ver;
+ device_attr->max_qp = resp->max_qp;
+ device_attr->max_qp_wr = resp->max_qp_wr;
+ device_attr->device_cap_flags = resp->device_cap_flags;
+ device_attr->max_sge = resp->max_sge;
+ device_attr->max_sge_rd = resp->max_sge_rd;
+ device_attr->max_cq = resp->max_cq;
+ device_attr->max_cqe = resp->max_cqe;
+ device_attr->max_mr = resp->max_mr;
+ device_attr->max_pd = resp->max_pd;
+ device_attr->max_qp_rd_atom = resp->max_qp_rd_atom;
+ device_attr->max_ee_rd_atom = resp->max_ee_rd_atom;
+ device_attr->max_res_rd_atom = resp->max_res_rd_atom;
+ device_attr->max_qp_init_rd_atom = resp->max_qp_init_rd_atom;
+ device_attr->max_ee_init_rd_atom = resp->max_ee_init_rd_atom;
+ device_attr->atomic_cap = resp->atomic_cap;
+ device_attr->max_ee = resp->max_ee;
+ device_attr->max_rdd = resp->max_rdd;
+ device_attr->max_mw = resp->max_mw;
+ device_attr->max_raw_ipv6_qp = resp->max_raw_ipv6_qp;
+ device_attr->max_raw_ethy_qp = resp->max_raw_ethy_qp;
+ device_attr->max_mcast_grp = resp->max_mcast_grp;
+ device_attr->max_mcast_qp_attach = resp->max_mcast_qp_attach;
+ device_attr->max_total_mcast_qp_attach = resp->max_total_mcast_qp_attach;
+ device_attr->max_ah = resp->max_ah;
+ device_attr->max_fmr = resp->max_fmr;
+ device_attr->max_map_per_fmr = resp->max_map_per_fmr;
+ device_attr->max_srq = resp->max_srq;
+ device_attr->max_srq_wr = resp->max_srq_wr;
+ device_attr->max_srq_sge = resp->max_srq_sge;
+ device_attr->max_pkeys = resp->max_pkeys;
+ device_attr->local_ca_ack_delay = resp->local_ca_ack_delay;
+ device_attr->phys_port_cnt = resp->phys_port_cnt;
+}
+
+int ibv_cmd_query_device(struct ibv_context *context,
+ struct ibv_device_attr *device_attr,
+ uint64_t *raw_fw_ver,
+ struct ibv_query_device *cmd, size_t cmd_size)
+{
+ struct ibv_query_device_resp resp;
+
+ IBV_INIT_CMD_RESP(cmd, cmd_size, QUERY_DEVICE, &resp, sizeof resp);
+
+ if (write(context->cmd_fd, cmd, cmd_size) != cmd_size)
+ return errno;
+
+ (void) VALGRIND_MAKE_MEM_DEFINED(&resp, sizeof resp);
+
+ memset(device_attr->fw_ver, 0, sizeof device_attr->fw_ver);
+ copy_query_dev_fields(device_attr, &resp, raw_fw_ver);
+
+ return 0;
+}
+
+int ibv_cmd_query_device_ex(struct ibv_context *context,
+ const struct ibv_query_device_ex_input *input,
+ struct ibv_device_attr_ex *attr, size_t attr_size,
+ uint64_t *raw_fw_ver,
+ struct ibv_query_device_ex *cmd,
+ size_t cmd_core_size,
+ size_t cmd_size,
+ struct ibv_query_device_resp_ex *resp,
+ size_t resp_core_size,
+ size_t resp_size)
+{
+ int err;
+
+ if (input && input->comp_mask)
+ return EINVAL;
+
+ if (attr_size < offsetof(struct ibv_device_attr_ex, comp_mask) +
+ sizeof(attr->comp_mask))
+ return EINVAL;
+
+ if (resp_core_size < offsetof(struct ibv_query_device_resp_ex,
+ response_length) +
+ sizeof(resp->response_length))
+ return EINVAL;
+
+ IBV_INIT_CMD_RESP_EX_V(cmd, cmd_core_size, cmd_size,
+ QUERY_DEVICE_EX, resp, resp_core_size,
+ resp_size);
+ cmd->comp_mask = 0;
+ cmd->reserved = 0;
+ memset(attr->orig_attr.fw_ver, 0, sizeof(attr->orig_attr.fw_ver));
+ memset(&attr->comp_mask, 0, attr_size - sizeof(attr->orig_attr));
+ err = write(context->cmd_fd, cmd, cmd_size);
+ if (err != cmd_size)
+ return errno;
+
+ (void)VALGRIND_MAKE_MEM_DEFINED(resp, resp_size);
+ copy_query_dev_fields(&attr->orig_attr, &resp->base, raw_fw_ver);
+ /* Report back supported comp_mask bits. For now no comp_mask bit is
+ * defined */
+ attr->comp_mask = resp->comp_mask & 0;
+ if (attr_size >= offsetof(struct ibv_device_attr_ex, odp_caps) +
+ sizeof(attr->odp_caps)) {
+ if (resp->response_length >=
+ offsetof(struct ibv_query_device_resp_ex, odp_caps) +
+ sizeof(resp->odp_caps)) {
+ attr->odp_caps.general_caps = resp->odp_caps.general_caps;
+ attr->odp_caps.per_transport_caps.rc_odp_caps =
+ resp->odp_caps.per_transport_caps.rc_odp_caps;
+ attr->odp_caps.per_transport_caps.uc_odp_caps =
+ resp->odp_caps.per_transport_caps.uc_odp_caps;
+ attr->odp_caps.per_transport_caps.ud_odp_caps =
+ resp->odp_caps.per_transport_caps.ud_odp_caps;
+ }
+ }
+
+ if (attr_size >= offsetof(struct ibv_device_attr_ex,
+ completion_timestamp_mask) +
+ sizeof(attr->completion_timestamp_mask)) {
+ if (resp->response_length >=
+ offsetof(struct ibv_query_device_resp_ex, timestamp_mask) +
+ sizeof(resp->timestamp_mask))
+ attr->completion_timestamp_mask = resp->timestamp_mask;
+ }
+
+ if (attr_size >= offsetof(struct ibv_device_attr_ex, hca_core_clock) +
+ sizeof(attr->hca_core_clock)) {
+ if (resp->response_length >=
+ offsetof(struct ibv_query_device_resp_ex, hca_core_clock) +
+ sizeof(resp->hca_core_clock))
+ attr->hca_core_clock = resp->hca_core_clock;
+ }
+
+ if (attr_size >= offsetof(struct ibv_device_attr_ex, device_cap_flags_ex) +
+ sizeof(attr->device_cap_flags_ex)) {
+ if (resp->response_length >=
+ offsetof(struct ibv_query_device_resp_ex, device_cap_flags_ex) +
+ sizeof(resp->device_cap_flags_ex))
+ attr->device_cap_flags_ex = resp->device_cap_flags_ex;
+ }
+
+ if (attr_size >= offsetof(struct ibv_device_attr_ex, rss_caps) +
+ sizeof(attr->rss_caps)) {
+ if (resp->response_length >=
+ offsetof(struct ibv_query_device_resp_ex, rss_caps) +
+ sizeof(resp->rss_caps)) {
+ attr->rss_caps.supported_qpts = resp->rss_caps.supported_qpts;
+ attr->rss_caps.max_rwq_indirection_tables = resp->rss_caps.max_rwq_indirection_tables;
+ attr->rss_caps.max_rwq_indirection_table_size = resp->rss_caps.max_rwq_indirection_table_size;
+ }
+ }
+
+ if (attr_size >= offsetof(struct ibv_device_attr_ex, max_wq_type_rq) +
+ sizeof(attr->max_wq_type_rq)) {
+ if (resp->response_length >=
+ offsetof(struct ibv_query_device_resp_ex, max_wq_type_rq) +
+ sizeof(resp->max_wq_type_rq))
+ attr->max_wq_type_rq = resp->max_wq_type_rq;
+ }
+
+ if (attr_size >= offsetof(struct ibv_device_attr_ex, raw_packet_caps) +
+ sizeof(attr->raw_packet_caps)) {
+ if (resp->response_length >=
+ offsetof(struct ibv_query_device_resp_ex, raw_packet_caps) +
+ sizeof(resp->raw_packet_caps))
+ attr->raw_packet_caps = resp->raw_packet_caps;
+ }
+
+ return 0;
+}
+
+int ibv_cmd_query_port(struct ibv_context *context, uint8_t port_num,
+ struct ibv_port_attr *port_attr,
+ struct ibv_query_port *cmd, size_t cmd_size)
+{
+ struct ibv_query_port_resp resp;
+
+ IBV_INIT_CMD_RESP(cmd, cmd_size, QUERY_PORT, &resp, sizeof resp);
+ cmd->port_num = port_num;
+ memset(cmd->reserved, 0, sizeof cmd->reserved);
+
+ if (write(context->cmd_fd, cmd, cmd_size) != cmd_size)
+ return errno;
+
+ (void) VALGRIND_MAKE_MEM_DEFINED(&resp, sizeof resp);
+
+ port_attr->state = resp.state;
+ port_attr->max_mtu = resp.max_mtu;
+ port_attr->active_mtu = resp.active_mtu;
+ port_attr->gid_tbl_len = resp.gid_tbl_len;
+ port_attr->port_cap_flags = resp.port_cap_flags;
+ port_attr->max_msg_sz = resp.max_msg_sz;
+ port_attr->bad_pkey_cntr = resp.bad_pkey_cntr;
+ port_attr->qkey_viol_cntr = resp.qkey_viol_cntr;
+ port_attr->pkey_tbl_len = resp.pkey_tbl_len;
+ port_attr->lid = resp.lid;
+ port_attr->sm_lid = resp.sm_lid;
+ port_attr->lmc = resp.lmc;
+ port_attr->max_vl_num = resp.max_vl_num;
+ port_attr->sm_sl = resp.sm_sl;
+ port_attr->subnet_timeout = resp.subnet_timeout;
+ port_attr->init_type_reply = resp.init_type_reply;
+ port_attr->active_width = resp.active_width;
+ port_attr->active_speed = resp.active_speed;
+ port_attr->phys_state = resp.phys_state;
+ port_attr->link_layer = resp.link_layer;
+
+ return 0;
+}
+
+int ibv_cmd_alloc_pd(struct ibv_context *context, struct ibv_pd *pd,
+ struct ibv_alloc_pd *cmd, size_t cmd_size,
+ struct ibv_alloc_pd_resp *resp, size_t resp_size)
+{
+ IBV_INIT_CMD_RESP(cmd, cmd_size, ALLOC_PD, resp, resp_size);
+
+ if (write(context->cmd_fd, cmd, cmd_size) != cmd_size)
+ return errno;
+
+ (void) VALGRIND_MAKE_MEM_DEFINED(resp, resp_size);
+
+ pd->handle = resp->pd_handle;
+ pd->context = context;
+
+ return 0;
+}
+
+int ibv_cmd_dealloc_pd(struct ibv_pd *pd)
+{
+ struct ibv_dealloc_pd cmd;
+
+ IBV_INIT_CMD(&cmd, sizeof cmd, DEALLOC_PD);
+ cmd.pd_handle = pd->handle;
+
+ if (write(pd->context->cmd_fd, &cmd, sizeof cmd) != sizeof cmd)
+ return errno;
+
+ return 0;
+}
+
+int ibv_cmd_open_xrcd(struct ibv_context *context, struct verbs_xrcd *xrcd,
+ int vxrcd_size,
+ struct ibv_xrcd_init_attr *attr,
+ struct ibv_open_xrcd *cmd, size_t cmd_size,
+ struct ibv_open_xrcd_resp *resp, size_t resp_size)
+{
+ IBV_INIT_CMD_RESP(cmd, cmd_size, OPEN_XRCD, resp, resp_size);
+
+ if (attr->comp_mask >= IBV_XRCD_INIT_ATTR_RESERVED)
+ return ENOSYS;
+
+ if (!(attr->comp_mask & IBV_XRCD_INIT_ATTR_FD) ||
+ !(attr->comp_mask & IBV_XRCD_INIT_ATTR_OFLAGS))
+ return EINVAL;
+
+ cmd->fd = attr->fd;
+ cmd->oflags = attr->oflags;
+ if (write(context->cmd_fd, cmd, cmd_size) != cmd_size)
+ return errno;
+
+ (void) VALGRIND_MAKE_MEM_DEFINED(resp, resp_size);
+
+ xrcd->xrcd.context = context;
+ xrcd->comp_mask = 0;
+ if (vext_field_avail(struct verbs_xrcd, handle, vxrcd_size)) {
+ xrcd->comp_mask = VERBS_XRCD_HANDLE;
+ xrcd->handle = resp->xrcd_handle;
+ }
+
+ return 0;
+}
+
+int ibv_cmd_close_xrcd(struct verbs_xrcd *xrcd)
+{
+ struct ibv_close_xrcd cmd;
+
+ IBV_INIT_CMD(&cmd, sizeof cmd, CLOSE_XRCD);
+ cmd.xrcd_handle = xrcd->handle;
+
+ if (write(xrcd->xrcd.context->cmd_fd, &cmd, sizeof cmd) != sizeof cmd)
+ return errno;
+
+ return 0;
+}
+
+int ibv_cmd_reg_mr(struct ibv_pd *pd, void *addr, size_t length,
+ uint64_t hca_va, int access,
+ struct ibv_mr *mr, struct ibv_reg_mr *cmd,
+ size_t cmd_size,
+ struct ibv_reg_mr_resp *resp, size_t resp_size)
+{
+
+ IBV_INIT_CMD_RESP(cmd, cmd_size, REG_MR, resp, resp_size);
+
+ cmd->start = (uintptr_t) addr;
+ cmd->length = length;
+ cmd->hca_va = hca_va;
+ cmd->pd_handle = pd->handle;
+ cmd->access_flags = access;
+
+ if (write(pd->context->cmd_fd, cmd, cmd_size) != cmd_size)
+ return errno;
+
+ (void) VALGRIND_MAKE_MEM_DEFINED(resp, resp_size);
+
+ mr->handle = resp->mr_handle;
+ mr->lkey = resp->lkey;
+ mr->rkey = resp->rkey;
+ mr->context = pd->context;
+
+ return 0;
+}
+
+int ibv_cmd_rereg_mr(struct ibv_mr *mr, uint32_t flags, void *addr,
+ size_t length, uint64_t hca_va, int access,
+ struct ibv_pd *pd, struct ibv_rereg_mr *cmd,
+ size_t cmd_sz, struct ibv_rereg_mr_resp *resp,
+ size_t resp_sz)
+{
+ IBV_INIT_CMD_RESP(cmd, cmd_sz, REREG_MR, resp, resp_sz);
+
+ cmd->mr_handle = mr->handle;
+ cmd->flags = flags;
+ cmd->start = (uintptr_t)addr;
+ cmd->length = length;
+ cmd->hca_va = hca_va;
+ cmd->pd_handle = (flags & IBV_REREG_MR_CHANGE_PD) ? pd->handle : 0;
+ cmd->access_flags = access;
+
+ if (write(mr->context->cmd_fd, cmd, cmd_sz) != cmd_sz)
+ return errno;
+
+ (void)VALGRIND_MAKE_MEM_DEFINED(resp, resp_sz);
+
+ mr->lkey = resp->lkey;
+ mr->rkey = resp->rkey;
+ if (flags & IBV_REREG_MR_CHANGE_PD)
+ mr->context = pd->context;
+
+ return 0;
+}
+
+int ibv_cmd_dereg_mr(struct ibv_mr *mr)
+{
+ struct ibv_dereg_mr cmd;
+
+ IBV_INIT_CMD(&cmd, sizeof cmd, DEREG_MR);
+ cmd.mr_handle = mr->handle;
+
+ if (write(mr->context->cmd_fd, &cmd, sizeof cmd) != sizeof cmd)
+ return errno;
+
+ return 0;
+}
+
+int ibv_cmd_alloc_mw(struct ibv_pd *pd, enum ibv_mw_type type,
+ struct ibv_mw *mw, struct ibv_alloc_mw *cmd,
+ size_t cmd_size,
+ struct ibv_alloc_mw_resp *resp, size_t resp_size)
+{
+ IBV_INIT_CMD_RESP(cmd, cmd_size, ALLOC_MW, resp, resp_size);
+ cmd->pd_handle = pd->handle;
+ cmd->mw_type = type;
+ memset(cmd->reserved, 0, sizeof(cmd->reserved));
+
+ if (write(pd->context->cmd_fd, cmd, cmd_size) != cmd_size)
+ return errno;
+
+ (void) VALGRIND_MAKE_MEM_DEFINED(resp, resp_size);
+
+ mw->context = pd->context;
+ mw->pd = pd;
+ mw->rkey = resp->rkey;
+ mw->handle = resp->mw_handle;
+ mw->type = type;
+
+ return 0;
+}
+
+int ibv_cmd_dealloc_mw(struct ibv_mw *mw,
+ struct ibv_dealloc_mw *cmd, size_t cmd_size)
+{
+ IBV_INIT_CMD(cmd, cmd_size, DEALLOC_MW);
+ cmd->mw_handle = mw->handle;
+ cmd->reserved = 0;
+
+ if (write(mw->context->cmd_fd, cmd, cmd_size) != cmd_size)
+ return errno;
+
+ return 0;
+}
+
+int ibv_cmd_create_cq(struct ibv_context *context, int cqe,
+ struct ibv_comp_channel *channel,
+ int comp_vector, struct ibv_cq *cq,
+ struct ibv_create_cq *cmd, size_t cmd_size,
+ struct ibv_create_cq_resp *resp, size_t resp_size)
+{
+ IBV_INIT_CMD_RESP(cmd, cmd_size, CREATE_CQ, resp, resp_size);
+ cmd->user_handle = (uintptr_t) cq;
+ cmd->cqe = cqe;
+ cmd->comp_vector = comp_vector;
+ cmd->comp_channel = channel ? channel->fd : -1;
+ cmd->reserved = 0;
+
+ if (write(context->cmd_fd, cmd, cmd_size) != cmd_size)
+ return errno;
+
+ (void) VALGRIND_MAKE_MEM_DEFINED(resp, resp_size);
+
+ cq->handle = resp->cq_handle;
+ cq->cqe = resp->cqe;
+ cq->context = context;
+
+ return 0;
+}
+
+int ibv_cmd_create_cq_ex(struct ibv_context *context,
+ struct ibv_cq_init_attr_ex *cq_attr,
+ struct ibv_cq_ex *cq,
+ struct ibv_create_cq_ex *cmd,
+ size_t cmd_core_size,
+ size_t cmd_size,
+ struct ibv_create_cq_resp_ex *resp,
+ size_t resp_core_size,
+ size_t resp_size)
+{
+ int err;
+
+ memset(cmd, 0, cmd_core_size);
+ IBV_INIT_CMD_RESP_EX_V(cmd, cmd_core_size, cmd_size, CREATE_CQ_EX, resp,
+ resp_core_size, resp_size);
+
+ if (cq_attr->comp_mask & ~(IBV_CQ_INIT_ATTR_MASK_RESERVED - 1))
+ return EINVAL;
+
+ cmd->user_handle = (uintptr_t)cq;
+ cmd->cqe = cq_attr->cqe;
+ cmd->comp_vector = cq_attr->comp_vector;
+ cmd->comp_channel = cq_attr->channel ? cq_attr->channel->fd : -1;
+ cmd->comp_mask = 0;
+
+ if (cmd_core_size >= offsetof(struct ibv_create_cq_ex, flags) +
+ sizeof(cmd->flags)) {
+ if ((cq_attr->comp_mask & IBV_CQ_INIT_ATTR_MASK_FLAGS) &&
+ (cq_attr->flags & ~(IBV_CREATE_CQ_ATTR_RESERVED - 1)))
+ return EOPNOTSUPP;
+
+ if (cq_attr->wc_flags & IBV_WC_EX_WITH_COMPLETION_TIMESTAMP)
+ cmd->flags |= IBV_CREATE_CQ_EX_KERNEL_FLAG_COMPLETION_TIMESTAMP;
+ }
+
+ err = write(context->cmd_fd, cmd, cmd_size);
+ if (err != cmd_size)
+ return errno;
+
+ (void)VALGRIND_MAKE_MEM_DEFINED(resp, resp_size);
+
+ cq->handle = resp->base.cq_handle;
+ cq->cqe = resp->base.cqe;
+ cq->context = context;
+
+ return 0;
+}
+
+int ibv_cmd_poll_cq(struct ibv_cq *ibcq, int ne, struct ibv_wc *wc)
+{
+ struct ibv_poll_cq cmd;
+ struct ibv_poll_cq_resp *resp;
+ int i;
+ int rsize;
+ int ret;
+
+ rsize = sizeof *resp + ne * sizeof(struct ibv_kern_wc);
+ resp = malloc(rsize);
+ if (!resp)
+ return -1;
+
+ IBV_INIT_CMD_RESP(&cmd, sizeof cmd, POLL_CQ, resp, rsize);
+ cmd.cq_handle = ibcq->handle;
+ cmd.ne = ne;
+
+ if (write(ibcq->context->cmd_fd, &cmd, sizeof cmd) != sizeof cmd) {
+ ret = -1;
+ goto out;
+ }
+
+ (void) VALGRIND_MAKE_MEM_DEFINED(resp, rsize);
+
+ for (i = 0; i < resp->count; i++) {
+ wc[i].wr_id = resp->wc[i].wr_id;
+ wc[i].status = resp->wc[i].status;
+ wc[i].opcode = resp->wc[i].opcode;
+ wc[i].vendor_err = resp->wc[i].vendor_err;
+ wc[i].byte_len = resp->wc[i].byte_len;
+ wc[i].imm_data = resp->wc[i].imm_data;
+ wc[i].qp_num = resp->wc[i].qp_num;
+ wc[i].src_qp = resp->wc[i].src_qp;
+ wc[i].wc_flags = resp->wc[i].wc_flags;
+ wc[i].pkey_index = resp->wc[i].pkey_index;
+ wc[i].slid = resp->wc[i].slid;
+ wc[i].sl = resp->wc[i].sl;
+ wc[i].dlid_path_bits = resp->wc[i].dlid_path_bits;
+ }
+
+ ret = resp->count;
+
+out:
+ free(resp);
+ return ret;
+}
+
+int ibv_cmd_req_notify_cq(struct ibv_cq *ibcq, int solicited_only)
+{
+ struct ibv_req_notify_cq cmd;
+
+ IBV_INIT_CMD(&cmd, sizeof cmd, REQ_NOTIFY_CQ);
+ cmd.cq_handle = ibcq->handle;
+ cmd.solicited = !!solicited_only;
+
+ if (write(ibcq->context->cmd_fd, &cmd, sizeof cmd) != sizeof cmd)
+ return errno;
+
+ return 0;
+}
+
+int ibv_cmd_resize_cq(struct ibv_cq *cq, int cqe,
+ struct ibv_resize_cq *cmd, size_t cmd_size,
+ struct ibv_resize_cq_resp *resp, size_t resp_size)
+{
+ IBV_INIT_CMD_RESP(cmd, cmd_size, RESIZE_CQ, resp, resp_size);
+ cmd->cq_handle = cq->handle;
+ cmd->cqe = cqe;
+
+ if (write(cq->context->cmd_fd, cmd, cmd_size) != cmd_size)
+ return errno;
+
+ (void) VALGRIND_MAKE_MEM_DEFINED(resp, resp_size);
+
+ cq->cqe = resp->cqe;
+
+ return 0;
+}
+
+int ibv_cmd_destroy_cq(struct ibv_cq *cq)
+{
+ struct ibv_destroy_cq cmd;
+ struct ibv_destroy_cq_resp resp;
+
+ IBV_INIT_CMD_RESP(&cmd, sizeof cmd, DESTROY_CQ, &resp, sizeof resp);
+ cmd.cq_handle = cq->handle;
+ cmd.reserved = 0;
+
+ if (write(cq->context->cmd_fd, &cmd, sizeof cmd) != sizeof cmd)
+ return errno;
+
+ (void) VALGRIND_MAKE_MEM_DEFINED(&resp, sizeof resp);
+
+ pthread_mutex_lock(&cq->mutex);
+ while (cq->comp_events_completed != resp.comp_events_reported ||
+ cq->async_events_completed != resp.async_events_reported)
+ pthread_cond_wait(&cq->cond, &cq->mutex);
+ pthread_mutex_unlock(&cq->mutex);
+
+ return 0;
+}
+
+int ibv_cmd_create_srq(struct ibv_pd *pd,
+ struct ibv_srq *srq, struct ibv_srq_init_attr *attr,
+ struct ibv_create_srq *cmd, size_t cmd_size,
+ struct ibv_create_srq_resp *resp, size_t resp_size)
+{
+ IBV_INIT_CMD_RESP(cmd, cmd_size, CREATE_SRQ, resp, resp_size);
+ cmd->user_handle = (uintptr_t) srq;
+ cmd->pd_handle = pd->handle;
+ cmd->max_wr = attr->attr.max_wr;
+ cmd->max_sge = attr->attr.max_sge;
+ cmd->srq_limit = attr->attr.srq_limit;
+
+ if (write(pd->context->cmd_fd, cmd, cmd_size) != cmd_size)
+ return errno;
+
+ (void) VALGRIND_MAKE_MEM_DEFINED(resp, resp_size);
+
+ srq->handle = resp->srq_handle;
+ srq->context = pd->context;
+
+ if (abi_ver > 5) {
+ attr->attr.max_wr = resp->max_wr;
+ attr->attr.max_sge = resp->max_sge;
+ } else {
+ struct ibv_create_srq_resp_v5 *resp_v5 =
+ (struct ibv_create_srq_resp_v5 *) resp;
+
+ memmove((void *) resp + sizeof *resp,
+ (void *) resp_v5 + sizeof *resp_v5,
+ resp_size - sizeof *resp);
+ }
+
+ return 0;
+}
+
+int ibv_cmd_create_srq_ex(struct ibv_context *context,
+ struct verbs_srq *srq, int vsrq_sz,
+ struct ibv_srq_init_attr_ex *attr_ex,
+ struct ibv_create_xsrq *cmd, size_t cmd_size,
+ struct ibv_create_srq_resp *resp, size_t resp_size)
+{
+ struct verbs_xrcd *vxrcd = NULL;
+
+ IBV_INIT_CMD_RESP(cmd, cmd_size, CREATE_XSRQ, resp, resp_size);
+
+ if (attr_ex->comp_mask >= IBV_SRQ_INIT_ATTR_RESERVED)
+ return ENOSYS;
+
+ if (!(attr_ex->comp_mask & IBV_SRQ_INIT_ATTR_PD))
+ return EINVAL;
+
+ cmd->user_handle = (uintptr_t) srq;
+ cmd->pd_handle = attr_ex->pd->handle;
+ cmd->max_wr = attr_ex->attr.max_wr;
+ cmd->max_sge = attr_ex->attr.max_sge;
+ cmd->srq_limit = attr_ex->attr.srq_limit;
+
+ cmd->srq_type = (attr_ex->comp_mask & IBV_SRQ_INIT_ATTR_TYPE) ?
+ attr_ex->srq_type : IBV_SRQT_BASIC;
+ if (attr_ex->comp_mask & IBV_SRQ_INIT_ATTR_XRCD) {
+ if (!(attr_ex->comp_mask & IBV_SRQ_INIT_ATTR_CQ))
+ return EINVAL;
+
+ vxrcd = container_of(attr_ex->xrcd, struct verbs_xrcd, xrcd);
+ cmd->xrcd_handle = vxrcd->handle;
+ cmd->cq_handle = attr_ex->cq->handle;
+ }
+
+ if (write(context->cmd_fd, cmd, cmd_size) != cmd_size)
+ return errno;
+
+ (void) VALGRIND_MAKE_MEM_DEFINED(resp, resp_size);
+
+ srq->srq.handle = resp->srq_handle;
+ srq->srq.context = context;
+ srq->srq.srq_context = attr_ex->srq_context;
+ srq->srq.pd = attr_ex->pd;
+ srq->srq.events_completed = 0;
+ pthread_mutex_init(&srq->srq.mutex, NULL);
+ pthread_cond_init(&srq->srq.cond, NULL);
+
+ /*
+ * check that the last field is available.
+ * If it is than all the others exist as well
+ */
+ if (vext_field_avail(struct verbs_srq, srq_num, vsrq_sz)) {
+ srq->comp_mask = IBV_SRQ_INIT_ATTR_TYPE;
+ srq->srq_type = (attr_ex->comp_mask & IBV_SRQ_INIT_ATTR_TYPE) ?
+ attr_ex->srq_type : IBV_SRQT_BASIC;
+ if (srq->srq_type == IBV_SRQT_XRC) {
+ srq->comp_mask |= VERBS_SRQ_NUM;
+ srq->srq_num = resp->srqn;
+ }
+ if (attr_ex->comp_mask & IBV_SRQ_INIT_ATTR_XRCD) {
+ srq->comp_mask |= VERBS_SRQ_XRCD;
+ srq->xrcd = vxrcd;
+ }
+ if (attr_ex->comp_mask & IBV_SRQ_INIT_ATTR_CQ) {
+ srq->comp_mask |= VERBS_SRQ_CQ;
+ srq->cq = attr_ex->cq;
+ }
+ }
+
+ attr_ex->attr.max_wr = resp->max_wr;
+ attr_ex->attr.max_sge = resp->max_sge;
+
+ return 0;
+}
+
+
+static int ibv_cmd_modify_srq_v3(struct ibv_srq *srq,
+ struct ibv_srq_attr *srq_attr,
+ int srq_attr_mask,
+ struct ibv_modify_srq *new_cmd,
+ size_t new_cmd_size)
+{
+ struct ibv_modify_srq_v3 *cmd;
+ size_t cmd_size;
+
+ cmd_size = sizeof *cmd + new_cmd_size - sizeof *new_cmd;
+ cmd = alloca(cmd_size);
+ memcpy(cmd->driver_data, new_cmd->driver_data, new_cmd_size - sizeof *new_cmd);
+
+ IBV_INIT_CMD(cmd, cmd_size, MODIFY_SRQ);
+
+ cmd->srq_handle = srq->handle;
+ cmd->attr_mask = srq_attr_mask;
+ cmd->max_wr = srq_attr->max_wr;
+ cmd->srq_limit = srq_attr->srq_limit;
+ cmd->max_sge = 0;
+ cmd->reserved = 0;
+
+ if (write(srq->context->cmd_fd, cmd, cmd_size) != cmd_size)
+ return errno;
+
+ return 0;
+}
+
+int ibv_cmd_modify_srq(struct ibv_srq *srq,
+ struct ibv_srq_attr *srq_attr,
+ int srq_attr_mask,
+ struct ibv_modify_srq *cmd, size_t cmd_size)
+{
+ if (abi_ver == 3)
+ return ibv_cmd_modify_srq_v3(srq, srq_attr, srq_attr_mask,
+ cmd, cmd_size);
+
+ IBV_INIT_CMD(cmd, cmd_size, MODIFY_SRQ);
+
+ cmd->srq_handle = srq->handle;
+ cmd->attr_mask = srq_attr_mask;
+ cmd->max_wr = srq_attr->max_wr;
+ cmd->srq_limit = srq_attr->srq_limit;
+
+ if (write(srq->context->cmd_fd, cmd, cmd_size) != cmd_size)
+ return errno;
+
+ return 0;
+}
+
+int ibv_cmd_query_srq(struct ibv_srq *srq, struct ibv_srq_attr *srq_attr,
+ struct ibv_query_srq *cmd, size_t cmd_size)
+{
+ struct ibv_query_srq_resp resp;
+
+ IBV_INIT_CMD_RESP(cmd, cmd_size, QUERY_SRQ, &resp, sizeof resp);
+ cmd->srq_handle = srq->handle;
+ cmd->reserved = 0;
+
+ if (write(srq->context->cmd_fd, cmd, cmd_size) != cmd_size)
+ return errno;
+
+ (void) VALGRIND_MAKE_MEM_DEFINED(&resp, sizeof resp);
+
+ srq_attr->max_wr = resp.max_wr;
+ srq_attr->max_sge = resp.max_sge;
+ srq_attr->srq_limit = resp.srq_limit;
+
+ return 0;
+}
+
+int ibv_cmd_destroy_srq(struct ibv_srq *srq)
+{
+ struct ibv_destroy_srq cmd;
+ struct ibv_destroy_srq_resp resp;
+
+ IBV_INIT_CMD_RESP(&cmd, sizeof cmd, DESTROY_SRQ, &resp, sizeof resp);
+ cmd.srq_handle = srq->handle;
+ cmd.reserved = 0;
+
+ if (write(srq->context->cmd_fd, &cmd, sizeof cmd) != sizeof cmd)
+ return errno;
+
+ (void) VALGRIND_MAKE_MEM_DEFINED(&resp, sizeof resp);
+
+ pthread_mutex_lock(&srq->mutex);
+ while (srq->events_completed != resp.events_reported)
+ pthread_cond_wait(&srq->cond, &srq->mutex);
+ pthread_mutex_unlock(&srq->mutex);
+
+ return 0;
+}
+
+static int create_qp_ex_common(struct verbs_qp *qp,
+ struct ibv_qp_init_attr_ex *qp_attr,
+ struct verbs_xrcd *vxrcd,
+ struct ibv_create_qp_common *cmd)
+{
+ cmd->user_handle = (uintptr_t)qp;
+
+ if (qp_attr->comp_mask & IBV_QP_INIT_ATTR_XRCD) {
+ vxrcd = container_of(qp_attr->xrcd, struct verbs_xrcd, xrcd);
+ cmd->pd_handle = vxrcd->handle;
+ } else {
+ if (!(qp_attr->comp_mask & IBV_QP_INIT_ATTR_PD))
+ return EINVAL;
+
+ cmd->pd_handle = qp_attr->pd->handle;
+ if (qp_attr->comp_mask & IBV_QP_INIT_ATTR_IND_TABLE) {
+ if (cmd->max_recv_wr || cmd->max_recv_sge ||
+ cmd->recv_cq_handle || qp_attr->srq)
+ return EINVAL;
+
+ /* send_cq is optinal */
+ if (qp_attr->cap.max_send_wr)
+ cmd->send_cq_handle = qp_attr->send_cq->handle;
+ } else {
+ cmd->send_cq_handle = qp_attr->send_cq->handle;
+
+ if (qp_attr->qp_type != IBV_QPT_XRC_SEND) {
+ cmd->recv_cq_handle = qp_attr->recv_cq->handle;
+ cmd->srq_handle = qp_attr->srq ? qp_attr->srq->handle :
+ 0;
+ }
+ }
+ }
+
+ cmd->max_send_wr = qp_attr->cap.max_send_wr;
+ cmd->max_recv_wr = qp_attr->cap.max_recv_wr;
+ cmd->max_send_sge = qp_attr->cap.max_send_sge;
+ cmd->max_recv_sge = qp_attr->cap.max_recv_sge;
+ cmd->max_inline_data = qp_attr->cap.max_inline_data;
+ cmd->sq_sig_all = qp_attr->sq_sig_all;
+ cmd->qp_type = qp_attr->qp_type;
+ cmd->is_srq = !!qp_attr->srq;
+ cmd->reserved = 0;
+
+ return 0;
+}
+
+static void create_qp_handle_resp_common(struct ibv_context *context,
+ struct verbs_qp *qp,
+ struct ibv_qp_init_attr_ex *qp_attr,
+ struct ibv_create_qp_resp *resp,
+ struct verbs_xrcd *vxrcd,
+ int vqp_sz)
+{
+ if (abi_ver > 3) {
+ qp_attr->cap.max_recv_sge = resp->max_recv_sge;
+ qp_attr->cap.max_send_sge = resp->max_send_sge;
+ qp_attr->cap.max_recv_wr = resp->max_recv_wr;
+ qp_attr->cap.max_send_wr = resp->max_send_wr;
+ qp_attr->cap.max_inline_data = resp->max_inline_data;
+ }
+
+ qp->qp.handle = resp->qp_handle;
+ qp->qp.qp_num = resp->qpn;
+ qp->qp.context = context;
+ qp->qp.qp_context = qp_attr->qp_context;
+ qp->qp.pd = qp_attr->pd;
+ qp->qp.send_cq = qp_attr->send_cq;
+ qp->qp.recv_cq = qp_attr->recv_cq;
+ qp->qp.srq = qp_attr->srq;
+ qp->qp.qp_type = qp_attr->qp_type;
+ qp->qp.state = IBV_QPS_RESET;
+ qp->qp.events_completed = 0;
+ pthread_mutex_init(&qp->qp.mutex, NULL);
+ pthread_cond_init(&qp->qp.cond, NULL);
+
+ qp->comp_mask = 0;
+ if (vext_field_avail(struct verbs_qp, xrcd, vqp_sz) &&
+ (qp_attr->comp_mask & IBV_QP_INIT_ATTR_XRCD)) {
+ qp->comp_mask |= VERBS_QP_XRCD;
+ qp->xrcd = vxrcd;
+ }
+}
+
+enum {
+ CREATE_QP_EX2_SUP_CREATE_FLAGS = IBV_QP_CREATE_BLOCK_SELF_MCAST_LB |
+ IBV_QP_CREATE_SCATTER_FCS |
+ IBV_QP_CREATE_CVLAN_STRIPPING,
+};
+
+int ibv_cmd_create_qp_ex2(struct ibv_context *context,
+ struct verbs_qp *qp, int vqp_sz,
+ struct ibv_qp_init_attr_ex *qp_attr,
+ struct ibv_create_qp_ex *cmd,
+ size_t cmd_core_size,
+ size_t cmd_size,
+ struct ibv_create_qp_resp_ex *resp,
+ size_t resp_core_size,
+ size_t resp_size)
+{
+ struct verbs_xrcd *vxrcd = NULL;
+ int err;
+
+ if (qp_attr->comp_mask >= IBV_QP_INIT_ATTR_RESERVED)
+ return EINVAL;
+
+ if (resp_core_size <
+ offsetof(struct ibv_create_qp_resp_ex, response_length) +
+ sizeof(resp->response_length))
+ return EINVAL;
+
+ memset(cmd, 0, cmd_core_size);
+
+ IBV_INIT_CMD_RESP_EX_V(cmd, cmd_core_size, cmd_size, CREATE_QP_EX, resp,
+ resp_core_size, resp_size);
+
+ err = create_qp_ex_common(qp, qp_attr, vxrcd, &cmd->base);
+ if (err)
+ return err;
+
+ if (qp_attr->comp_mask & IBV_QP_INIT_ATTR_CREATE_FLAGS) {
+ if (qp_attr->create_flags & ~CREATE_QP_EX2_SUP_CREATE_FLAGS)
+ return EINVAL;
+ if (cmd_core_size < offsetof(struct ibv_create_qp_ex, create_flags) +
+ sizeof(qp_attr->create_flags))
+ return EINVAL;
+ cmd->create_flags = qp_attr->create_flags;
+ }
+
+ if (qp_attr->comp_mask & IBV_QP_INIT_ATTR_IND_TABLE) {
+ if (cmd_core_size < offsetof(struct ibv_create_qp_ex, ind_tbl_handle) +
+ sizeof(cmd->ind_tbl_handle))
+ return EINVAL;
+ cmd->ind_tbl_handle = qp_attr->rwq_ind_tbl->ind_tbl_handle;
+ cmd->comp_mask = IBV_CREATE_QP_EX_KERNEL_MASK_IND_TABLE;
+ }
+
+ err = write(context->cmd_fd, cmd, cmd_size);
+ if (err != cmd_size)
+ return errno;
+
+ (void)VALGRIND_MAKE_MEM_DEFINED(resp, resp_size);
+
+ create_qp_handle_resp_common(context, qp, qp_attr, &resp->base, vxrcd,
+ vqp_sz);
+
+ return 0;
+}
+
+int ibv_cmd_create_qp_ex(struct ibv_context *context,
+ struct verbs_qp *qp, int vqp_sz,
+ struct ibv_qp_init_attr_ex *attr_ex,
+ struct ibv_create_qp *cmd, size_t cmd_size,
+ struct ibv_create_qp_resp *resp, size_t resp_size)
+{
+ struct verbs_xrcd *vxrcd = NULL;
+ int err;
+
+ IBV_INIT_CMD_RESP(cmd, cmd_size, CREATE_QP, resp, resp_size);
+
+ if (attr_ex->comp_mask > (IBV_QP_INIT_ATTR_XRCD | IBV_QP_INIT_ATTR_PD))
+ return ENOSYS;
+
+ err = create_qp_ex_common(qp, attr_ex, vxrcd,
+ (struct ibv_create_qp_common *)&cmd->user_handle);
+ if (err)
+ return err;
+
+ if (write(context->cmd_fd, cmd, cmd_size) != cmd_size)
+ return errno;
+
+ (void)VALGRIND_MAKE_MEM_DEFINED(resp, resp_size);
+
+ if (abi_ver == 4) {
+ struct ibv_create_qp_resp_v4 *resp_v4 =
+ (struct ibv_create_qp_resp_v4 *)resp;
+
+ memmove((void *)resp + sizeof *resp,
+ (void *)resp_v4 + sizeof *resp_v4,
+ resp_size - sizeof *resp);
+ } else if (abi_ver <= 3) {
+ struct ibv_create_qp_resp_v3 *resp_v3 =
+ (struct ibv_create_qp_resp_v3 *)resp;
+
+ memmove((void *)resp + sizeof *resp,
+ (void *)resp_v3 + sizeof *resp_v3,
+ resp_size - sizeof *resp);
+ }
+
+ create_qp_handle_resp_common(context, qp, attr_ex, resp, vxrcd, vqp_sz);
+
+ return 0;
+}
+
+int ibv_cmd_create_qp(struct ibv_pd *pd,
+ struct ibv_qp *qp, struct ibv_qp_init_attr *attr,
+ struct ibv_create_qp *cmd, size_t cmd_size,
+ struct ibv_create_qp_resp *resp, size_t resp_size)
+{
+ IBV_INIT_CMD_RESP(cmd, cmd_size, CREATE_QP, resp, resp_size);
+
+ cmd->user_handle = (uintptr_t) qp;
+ cmd->pd_handle = pd->handle;
+ cmd->send_cq_handle = attr->send_cq->handle;
+ cmd->recv_cq_handle = attr->recv_cq->handle;
+ cmd->srq_handle = attr->srq ? attr->srq->handle : 0;
+ cmd->max_send_wr = attr->cap.max_send_wr;
+ cmd->max_recv_wr = attr->cap.max_recv_wr;
+ cmd->max_send_sge = attr->cap.max_send_sge;
+ cmd->max_recv_sge = attr->cap.max_recv_sge;
+ cmd->max_inline_data = attr->cap.max_inline_data;
+ cmd->sq_sig_all = attr->sq_sig_all;
+ cmd->qp_type = attr->qp_type;
+ cmd->is_srq = !!attr->srq;
+ cmd->reserved = 0;
+
+ if (write(pd->context->cmd_fd, cmd, cmd_size) != cmd_size)
+ return errno;
+
+ (void) VALGRIND_MAKE_MEM_DEFINED(resp, resp_size);
+
+ qp->handle = resp->qp_handle;
+ qp->qp_num = resp->qpn;
+ qp->context = pd->context;
+
+ if (abi_ver > 3) {
+ attr->cap.max_recv_sge = resp->max_recv_sge;
+ attr->cap.max_send_sge = resp->max_send_sge;
+ attr->cap.max_recv_wr = resp->max_recv_wr;
+ attr->cap.max_send_wr = resp->max_send_wr;
+ attr->cap.max_inline_data = resp->max_inline_data;
+ }
+
+ if (abi_ver == 4) {
+ struct ibv_create_qp_resp_v4 *resp_v4 =
+ (struct ibv_create_qp_resp_v4 *) resp;
+
+ memmove((void *) resp + sizeof *resp,
+ (void *) resp_v4 + sizeof *resp_v4,
+ resp_size - sizeof *resp);
+ } else if (abi_ver <= 3) {
+ struct ibv_create_qp_resp_v3 *resp_v3 =
+ (struct ibv_create_qp_resp_v3 *) resp;
+
+ memmove((void *) resp + sizeof *resp,
+ (void *) resp_v3 + sizeof *resp_v3,
+ resp_size - sizeof *resp);
+ }
+
+ return 0;
+}
+
+int ibv_cmd_open_qp(struct ibv_context *context, struct verbs_qp *qp,
+ int vqp_sz,
+ struct ibv_qp_open_attr *attr,
+ struct ibv_open_qp *cmd, size_t cmd_size,
+ struct ibv_create_qp_resp *resp, size_t resp_size)
+{
+ struct verbs_xrcd *xrcd;
+ IBV_INIT_CMD_RESP(cmd, cmd_size, OPEN_QP, resp, resp_size);
+
+ if (attr->comp_mask >= IBV_QP_OPEN_ATTR_RESERVED)
+ return ENOSYS;
+
+ if (!(attr->comp_mask & IBV_QP_OPEN_ATTR_XRCD) ||
+ !(attr->comp_mask & IBV_QP_OPEN_ATTR_NUM) ||
+ !(attr->comp_mask & IBV_QP_OPEN_ATTR_TYPE))
+ return EINVAL;
+
+ xrcd = container_of(attr->xrcd, struct verbs_xrcd, xrcd);
+ cmd->user_handle = (uintptr_t) qp;
+ cmd->pd_handle = xrcd->handle;
+ cmd->qpn = attr->qp_num;
+ cmd->qp_type = attr->qp_type;
+
+ if (write(context->cmd_fd, cmd, cmd_size) != cmd_size)
+ return errno;
+
+ (void) VALGRIND_MAKE_MEM_DEFINED(resp, resp_size);
+
+ qp->qp.handle = resp->qp_handle;
+ qp->qp.context = context;
+ qp->qp.qp_context = attr->qp_context;
+ qp->qp.pd = NULL;
+ qp->qp.send_cq = NULL;
+ qp->qp.recv_cq = NULL;
+ qp->qp.srq = NULL;
+ qp->qp.qp_num = attr->qp_num;
+ qp->qp.qp_type = attr->qp_type;
+ qp->qp.state = IBV_QPS_UNKNOWN;
+ qp->qp.events_completed = 0;
+ pthread_mutex_init(&qp->qp.mutex, NULL);
+ pthread_cond_init(&qp->qp.cond, NULL);
+ qp->comp_mask = 0;
+ if (vext_field_avail(struct verbs_qp, xrcd, vqp_sz)) {
+ qp->comp_mask = VERBS_QP_XRCD;
+ qp->xrcd = xrcd;
+ }
+
+ return 0;
+}
+
+int ibv_cmd_query_qp(struct ibv_qp *qp, struct ibv_qp_attr *attr,
+ int attr_mask,
+ struct ibv_qp_init_attr *init_attr,
+ struct ibv_query_qp *cmd, size_t cmd_size)
+{
+ struct ibv_query_qp_resp resp;
+
+ /*
+ * Masks over IBV_QP_DEST_QPN are not supported by
+ * that not extended command.
+ */
+ if (attr_mask & ~((IBV_QP_DEST_QPN << 1) - 1))
+ return EOPNOTSUPP;
+
+ IBV_INIT_CMD_RESP(cmd, cmd_size, QUERY_QP, &resp, sizeof resp);
+ cmd->qp_handle = qp->handle;
+ cmd->attr_mask = attr_mask;
+
+ if (write(qp->context->cmd_fd, cmd, cmd_size) != cmd_size)
+ return errno;
+
+ (void) VALGRIND_MAKE_MEM_DEFINED(&resp, sizeof resp);
+
+ attr->qkey = resp.qkey;
+ attr->rq_psn = resp.rq_psn;
+ attr->sq_psn = resp.sq_psn;
+ attr->dest_qp_num = resp.dest_qp_num;
+ attr->qp_access_flags = resp.qp_access_flags;
+ attr->pkey_index = resp.pkey_index;
+ attr->alt_pkey_index = resp.alt_pkey_index;
+ attr->qp_state = resp.qp_state;
+ attr->cur_qp_state = resp.cur_qp_state;
+ attr->path_mtu = resp.path_mtu;
+ attr->path_mig_state = resp.path_mig_state;
+ attr->sq_draining = resp.sq_draining;
+ attr->max_rd_atomic = resp.max_rd_atomic;
+ attr->max_dest_rd_atomic = resp.max_dest_rd_atomic;
+ attr->min_rnr_timer = resp.min_rnr_timer;
+ attr->port_num = resp.port_num;
+ attr->timeout = resp.timeout;
+ attr->retry_cnt = resp.retry_cnt;
+ attr->rnr_retry = resp.rnr_retry;
+ attr->alt_port_num = resp.alt_port_num;
+ attr->alt_timeout = resp.alt_timeout;
+ attr->cap.max_send_wr = resp.max_send_wr;
+ attr->cap.max_recv_wr = resp.max_recv_wr;
+ attr->cap.max_send_sge = resp.max_send_sge;
+ attr->cap.max_recv_sge = resp.max_recv_sge;
+ attr->cap.max_inline_data = resp.max_inline_data;
+
+ memcpy(attr->ah_attr.grh.dgid.raw, resp.dest.dgid, 16);
+ attr->ah_attr.grh.flow_label = resp.dest.flow_label;
+ attr->ah_attr.dlid = resp.dest.dlid;
+ attr->ah_attr.grh.sgid_index = resp.dest.sgid_index;
+ attr->ah_attr.grh.hop_limit = resp.dest.hop_limit;
+ attr->ah_attr.grh.traffic_class = resp.dest.traffic_class;
+ attr->ah_attr.sl = resp.dest.sl;
+ attr->ah_attr.src_path_bits = resp.dest.src_path_bits;
+ attr->ah_attr.static_rate = resp.dest.static_rate;
+ attr->ah_attr.is_global = resp.dest.is_global;
+ attr->ah_attr.port_num = resp.dest.port_num;
+
+ memcpy(attr->alt_ah_attr.grh.dgid.raw, resp.alt_dest.dgid, 16);
+ attr->alt_ah_attr.grh.flow_label = resp.alt_dest.flow_label;
+ attr->alt_ah_attr.dlid = resp.alt_dest.dlid;
+ attr->alt_ah_attr.grh.sgid_index = resp.alt_dest.sgid_index;
+ attr->alt_ah_attr.grh.hop_limit = resp.alt_dest.hop_limit;
+ attr->alt_ah_attr.grh.traffic_class = resp.alt_dest.traffic_class;
+ attr->alt_ah_attr.sl = resp.alt_dest.sl;
+ attr->alt_ah_attr.src_path_bits = resp.alt_dest.src_path_bits;
+ attr->alt_ah_attr.static_rate = resp.alt_dest.static_rate;
+ attr->alt_ah_attr.is_global = resp.alt_dest.is_global;
+ attr->alt_ah_attr.port_num = resp.alt_dest.port_num;
+
+ init_attr->qp_context = qp->qp_context;
+ init_attr->send_cq = qp->send_cq;
+ init_attr->recv_cq = qp->recv_cq;
+ init_attr->srq = qp->srq;
+ init_attr->qp_type = qp->qp_type;
+ init_attr->cap.max_send_wr = resp.max_send_wr;
+ init_attr->cap.max_recv_wr = resp.max_recv_wr;
+ init_attr->cap.max_send_sge = resp.max_send_sge;
+ init_attr->cap.max_recv_sge = resp.max_recv_sge;
+ init_attr->cap.max_inline_data = resp.max_inline_data;
+ init_attr->sq_sig_all = resp.sq_sig_all;
+
+ return 0;
+}
+
+static void copy_modify_qp_fields(struct ibv_qp *qp, struct ibv_qp_attr *attr,
+ int attr_mask,
+ struct ibv_modify_qp_common *cmd)
+{
+ cmd->qp_handle = qp->handle;
+ cmd->attr_mask = attr_mask;
+
+ if (attr_mask & IBV_QP_STATE)
+ cmd->qp_state = attr->qp_state;
+ if (attr_mask & IBV_QP_CUR_STATE)
+ cmd->cur_qp_state = attr->cur_qp_state;
+ if (attr_mask & IBV_QP_EN_SQD_ASYNC_NOTIFY)
+ cmd->en_sqd_async_notify = attr->en_sqd_async_notify;
+ if (attr_mask & IBV_QP_ACCESS_FLAGS)
+ cmd->qp_access_flags = attr->qp_access_flags;
+ if (attr_mask & IBV_QP_PKEY_INDEX)
+ cmd->pkey_index = attr->pkey_index;
+ if (attr_mask & IBV_QP_PORT)
+ cmd->port_num = attr->port_num;
+ if (attr_mask & IBV_QP_QKEY)
+ cmd->qkey = attr->qkey;
+
+ if (attr_mask & IBV_QP_AV) {
+ memcpy(cmd->dest.dgid, attr->ah_attr.grh.dgid.raw, 16);
+ cmd->dest.flow_label = attr->ah_attr.grh.flow_label;
+ cmd->dest.dlid = attr->ah_attr.dlid;
+ cmd->dest.reserved = 0;
+ cmd->dest.sgid_index = attr->ah_attr.grh.sgid_index;
+ cmd->dest.hop_limit = attr->ah_attr.grh.hop_limit;
+ cmd->dest.traffic_class = attr->ah_attr.grh.traffic_class;
+ cmd->dest.sl = attr->ah_attr.sl;
+ cmd->dest.src_path_bits = attr->ah_attr.src_path_bits;
+ cmd->dest.static_rate = attr->ah_attr.static_rate;
+ cmd->dest.is_global = attr->ah_attr.is_global;
+ cmd->dest.port_num = attr->ah_attr.port_num;
+ }
+
+ if (attr_mask & IBV_QP_PATH_MTU)
+ cmd->path_mtu = attr->path_mtu;
+ if (attr_mask & IBV_QP_TIMEOUT)
+ cmd->timeout = attr->timeout;
+ if (attr_mask & IBV_QP_RETRY_CNT)
+ cmd->retry_cnt = attr->retry_cnt;
+ if (attr_mask & IBV_QP_RNR_RETRY)
+ cmd->rnr_retry = attr->rnr_retry;
+ if (attr_mask & IBV_QP_RQ_PSN)
+ cmd->rq_psn = attr->rq_psn;
+ if (attr_mask & IBV_QP_MAX_QP_RD_ATOMIC)
+ cmd->max_rd_atomic = attr->max_rd_atomic;
+
+ if (attr_mask & IBV_QP_ALT_PATH) {
+ cmd->alt_pkey_index = attr->alt_pkey_index;
+ cmd->alt_port_num = attr->alt_port_num;
+ cmd->alt_timeout = attr->alt_timeout;
+
+ memcpy(cmd->alt_dest.dgid, attr->alt_ah_attr.grh.dgid.raw, 16);
+ cmd->alt_dest.flow_label = attr->alt_ah_attr.grh.flow_label;
+ cmd->alt_dest.dlid = attr->alt_ah_attr.dlid;
+ cmd->alt_dest.reserved = 0;
+ cmd->alt_dest.sgid_index = attr->alt_ah_attr.grh.sgid_index;
+ cmd->alt_dest.hop_limit = attr->alt_ah_attr.grh.hop_limit;
+ cmd->alt_dest.traffic_class =
+ attr->alt_ah_attr.grh.traffic_class;
+ cmd->alt_dest.sl = attr->alt_ah_attr.sl;
+ cmd->alt_dest.src_path_bits = attr->alt_ah_attr.src_path_bits;
+ cmd->alt_dest.static_rate = attr->alt_ah_attr.static_rate;
+ cmd->alt_dest.is_global = attr->alt_ah_attr.is_global;
+ cmd->alt_dest.port_num = attr->alt_ah_attr.port_num;
+ }
+
+ if (attr_mask & IBV_QP_MIN_RNR_TIMER)
+ cmd->min_rnr_timer = attr->min_rnr_timer;
+ if (attr_mask & IBV_QP_SQ_PSN)
+ cmd->sq_psn = attr->sq_psn;
+ if (attr_mask & IBV_QP_MAX_DEST_RD_ATOMIC)
+ cmd->max_dest_rd_atomic = attr->max_dest_rd_atomic;
+ if (attr_mask & IBV_QP_PATH_MIG_STATE)
+ cmd->path_mig_state = attr->path_mig_state;
+ if (attr_mask & IBV_QP_DEST_QPN)
+ cmd->dest_qp_num = attr->dest_qp_num;
+
+ cmd->reserved[0] = cmd->reserved[1] = 0;
+}
+
+int ibv_cmd_modify_qp(struct ibv_qp *qp, struct ibv_qp_attr *attr,
+ int attr_mask,
+ struct ibv_modify_qp *cmd, size_t cmd_size)
+{
+ /*
+ * Masks over IBV_QP_DEST_QPN are only supported by
+ * ibv_cmd_modify_qp_ex.
+ */
+ if (attr_mask & ~((IBV_QP_DEST_QPN << 1) - 1))
+ return EOPNOTSUPP;
+
+ IBV_INIT_CMD(cmd, cmd_size, MODIFY_QP);
+
+ copy_modify_qp_fields(qp, attr, attr_mask, &cmd->base);
+
+ if (write(qp->context->cmd_fd, cmd, cmd_size) != cmd_size)
+ return errno;
+
+ return 0;
+}
+
+int ibv_cmd_modify_qp_ex(struct ibv_qp *qp, struct ibv_qp_attr *attr,
+ int attr_mask, struct ibv_modify_qp_ex *cmd,
+ size_t cmd_core_size, size_t cmd_size,
+ struct ibv_modify_qp_resp_ex *resp,
+ size_t resp_core_size, size_t resp_size)
+{
+ if (resp_core_size < offsetof(struct ibv_modify_qp_resp_ex,
+ response_length) + sizeof(resp->response_length))
+ return EINVAL;
+
+ IBV_INIT_CMD_RESP_EX_V(cmd, cmd_core_size, cmd_size, MODIFY_QP_EX,
+ resp, resp_core_size, resp_size);
+
+ copy_modify_qp_fields(qp, attr, attr_mask, &cmd->base);
+
+ if (attr_mask & IBV_QP_RATE_LIMIT) {
+ if (cmd_size >= offsetof(struct ibv_modify_qp_ex, rate_limit) +
+ sizeof(cmd->rate_limit))
+ cmd->rate_limit = attr->rate_limit;
+ else
+ return EINVAL;
+ }
+
+ if (write(qp->context->cmd_fd, cmd, cmd_size) != cmd_size)
+ return errno;
+
+ (void)VALGRIND_MAKE_MEM_DEFINED(resp, resp_size);
+
+ return 0;
+}
+
+int ibv_cmd_post_send(struct ibv_qp *ibqp, struct ibv_send_wr *wr,
+ struct ibv_send_wr **bad_wr)
+{
+ struct ibv_post_send *cmd;
+ struct ibv_post_send_resp resp;
+ struct ibv_send_wr *i;
+ struct ibv_kern_send_wr *n, *tmp;
+ struct ibv_sge *s;
+ unsigned wr_count = 0;
+ unsigned sge_count = 0;
+ int cmd_size;
+ int ret = 0;
+
+ for (i = wr; i; i = i->next) {
+ wr_count++;
+ sge_count += i->num_sge;
+ }
+
+ cmd_size = sizeof *cmd + wr_count * sizeof *n + sge_count * sizeof *s;
+ cmd = alloca(cmd_size);
+
+ IBV_INIT_CMD_RESP(cmd, cmd_size, POST_SEND, &resp, sizeof resp);
+ cmd->qp_handle = ibqp->handle;
+ cmd->wr_count = wr_count;
+ cmd->sge_count = sge_count;
+ cmd->wqe_size = sizeof *n;
+
+ n = (struct ibv_kern_send_wr *) ((void *) cmd + sizeof *cmd);
+ s = (struct ibv_sge *) (n + wr_count);
+
+ tmp = n;
+ for (i = wr; i; i = i->next) {
+ tmp->wr_id = i->wr_id;
+ tmp->num_sge = i->num_sge;
+ tmp->opcode = i->opcode;
+ tmp->send_flags = i->send_flags;
+ tmp->imm_data = i->imm_data;
+ if (ibqp->qp_type == IBV_QPT_UD) {
+ tmp->wr.ud.ah = i->wr.ud.ah->handle;
+ tmp->wr.ud.remote_qpn = i->wr.ud.remote_qpn;
+ tmp->wr.ud.remote_qkey = i->wr.ud.remote_qkey;
+ } else {
+ switch (i->opcode) {
+ case IBV_WR_RDMA_WRITE:
+ case IBV_WR_RDMA_WRITE_WITH_IMM:
+ case IBV_WR_RDMA_READ:
+ tmp->wr.rdma.remote_addr =
+ i->wr.rdma.remote_addr;
+ tmp->wr.rdma.rkey = i->wr.rdma.rkey;
+ break;
+ case IBV_WR_ATOMIC_CMP_AND_SWP:
+ case IBV_WR_ATOMIC_FETCH_AND_ADD:
+ tmp->wr.atomic.remote_addr =
+ i->wr.atomic.remote_addr;
+ tmp->wr.atomic.compare_add =
+ i->wr.atomic.compare_add;
+ tmp->wr.atomic.swap = i->wr.atomic.swap;
+ tmp->wr.atomic.rkey = i->wr.atomic.rkey;
+ break;
+ default:
+ break;
+ }
+ }
+
+ if (tmp->num_sge) {
+ memcpy(s, i->sg_list, tmp->num_sge * sizeof *s);
+ s += tmp->num_sge;
+ }
+
+ tmp++;
+ }
+
+ resp.bad_wr = 0;
+ if (write(ibqp->context->cmd_fd, cmd, cmd_size) != cmd_size)
+ ret = errno;
+
+ (void) VALGRIND_MAKE_MEM_DEFINED(&resp, sizeof resp);
+
+ wr_count = resp.bad_wr;
+ if (wr_count) {
+ i = wr;
+ while (--wr_count)
+ i = i->next;
+ *bad_wr = i;
+ } else if (ret)
+ *bad_wr = wr;
+
+ return ret;
+}
+
+int ibv_cmd_post_recv(struct ibv_qp *ibqp, struct ibv_recv_wr *wr,
+ struct ibv_recv_wr **bad_wr)
+{
+ struct ibv_post_recv *cmd;
+ struct ibv_post_recv_resp resp;
+ struct ibv_recv_wr *i;
+ struct ibv_kern_recv_wr *n, *tmp;
+ struct ibv_sge *s;
+ unsigned wr_count = 0;
+ unsigned sge_count = 0;
+ int cmd_size;
+ int ret = 0;
+
+ for (i = wr; i; i = i->next) {
+ wr_count++;
+ sge_count += i->num_sge;
+ }
+
+ cmd_size = sizeof *cmd + wr_count * sizeof *n + sge_count * sizeof *s;
+ cmd = alloca(cmd_size);
+
+ IBV_INIT_CMD_RESP(cmd, cmd_size, POST_RECV, &resp, sizeof resp);
+ cmd->qp_handle = ibqp->handle;
+ cmd->wr_count = wr_count;
+ cmd->sge_count = sge_count;
+ cmd->wqe_size = sizeof *n;
+
+ n = (struct ibv_kern_recv_wr *) ((void *) cmd + sizeof *cmd);
+ s = (struct ibv_sge *) (n + wr_count);
+
+ tmp = n;
+ for (i = wr; i; i = i->next) {
+ tmp->wr_id = i->wr_id;
+ tmp->num_sge = i->num_sge;
+
+ if (tmp->num_sge) {
+ memcpy(s, i->sg_list, tmp->num_sge * sizeof *s);
+ s += tmp->num_sge;
+ }
+
+ tmp++;
+ }
+
+ resp.bad_wr = 0;
+ if (write(ibqp->context->cmd_fd, cmd, cmd_size) != cmd_size)
+ ret = errno;
+
+ (void) VALGRIND_MAKE_MEM_DEFINED(&resp, sizeof resp);
+
+ wr_count = resp.bad_wr;
+ if (wr_count) {
+ i = wr;
+ while (--wr_count)
+ i = i->next;
+ *bad_wr = i;
+ } else if (ret)
+ *bad_wr = wr;
+
+ return ret;
+}
+
+int ibv_cmd_post_srq_recv(struct ibv_srq *srq, struct ibv_recv_wr *wr,
+ struct ibv_recv_wr **bad_wr)
+{
+ struct ibv_post_srq_recv *cmd;
+ struct ibv_post_srq_recv_resp resp;
+ struct ibv_recv_wr *i;
+ struct ibv_kern_recv_wr *n, *tmp;
+ struct ibv_sge *s;
+ unsigned wr_count = 0;
+ unsigned sge_count = 0;
+ int cmd_size;
+ int ret = 0;
+
+ for (i = wr; i; i = i->next) {
+ wr_count++;
+ sge_count += i->num_sge;
+ }
+
+ cmd_size = sizeof *cmd + wr_count * sizeof *n + sge_count * sizeof *s;
+ cmd = alloca(cmd_size);
+
+ IBV_INIT_CMD_RESP(cmd, cmd_size, POST_SRQ_RECV, &resp, sizeof resp);
+ cmd->srq_handle = srq->handle;
+ cmd->wr_count = wr_count;
+ cmd->sge_count = sge_count;
+ cmd->wqe_size = sizeof *n;
+
+ n = (struct ibv_kern_recv_wr *) ((void *) cmd + sizeof *cmd);
+ s = (struct ibv_sge *) (n + wr_count);
+
+ tmp = n;
+ for (i = wr; i; i = i->next) {
+ tmp->wr_id = i->wr_id;
+ tmp->num_sge = i->num_sge;
+
+ if (tmp->num_sge) {
+ memcpy(s, i->sg_list, tmp->num_sge * sizeof *s);
+ s += tmp->num_sge;
+ }
+
+ tmp++;
+ }
+
+ resp.bad_wr = 0;
+ if (write(srq->context->cmd_fd, cmd, cmd_size) != cmd_size)
+ ret = errno;
+
+ (void) VALGRIND_MAKE_MEM_DEFINED(&resp, sizeof resp);
+
+ wr_count = resp.bad_wr;
+ if (wr_count) {
+ i = wr;
+ while (--wr_count)
+ i = i->next;
+ *bad_wr = i;
+ } else if (ret)
+ *bad_wr = wr;
+
+ return ret;
+}
+
+int ibv_cmd_create_ah(struct ibv_pd *pd, struct ibv_ah *ah,
+ struct ibv_ah_attr *attr,
+ struct ibv_create_ah_resp *resp,
+ size_t resp_size)
+{
+ struct ibv_create_ah cmd;
+
+ IBV_INIT_CMD_RESP(&cmd, sizeof cmd, CREATE_AH, resp, resp_size);
+ cmd.user_handle = (uintptr_t) ah;
+ cmd.pd_handle = pd->handle;
+ cmd.attr.dlid = attr->dlid;
+ cmd.attr.sl = attr->sl;
+ cmd.attr.src_path_bits = attr->src_path_bits;
+ cmd.attr.static_rate = attr->static_rate;
+ cmd.attr.is_global = attr->is_global;
+ cmd.attr.port_num = attr->port_num;
+ cmd.attr.grh.flow_label = attr->grh.flow_label;
+ cmd.attr.grh.sgid_index = attr->grh.sgid_index;
+ cmd.attr.grh.hop_limit = attr->grh.hop_limit;
+ cmd.attr.grh.traffic_class = attr->grh.traffic_class;
+ memcpy(cmd.attr.grh.dgid, attr->grh.dgid.raw, 16);
+
+ if (write(pd->context->cmd_fd, &cmd, sizeof cmd) != sizeof cmd)
+ return errno;
+
+ (void) VALGRIND_MAKE_MEM_DEFINED(resp, resp_size);
+
+ ah->handle = resp->handle;
+ ah->context = pd->context;
+
+ return 0;
+}
+
+int ibv_cmd_destroy_ah(struct ibv_ah *ah)
+{
+ struct ibv_destroy_ah cmd;
+
+ IBV_INIT_CMD(&cmd, sizeof cmd, DESTROY_AH);
+ cmd.ah_handle = ah->handle;
+
+ if (write(ah->context->cmd_fd, &cmd, sizeof cmd) != sizeof cmd)
+ return errno;
+
+ return 0;
+}
+
+int ibv_cmd_destroy_qp(struct ibv_qp *qp)
+{
+ struct ibv_destroy_qp cmd;
+ struct ibv_destroy_qp_resp resp;
+
+ IBV_INIT_CMD_RESP(&cmd, sizeof cmd, DESTROY_QP, &resp, sizeof resp);
+ cmd.qp_handle = qp->handle;
+ cmd.reserved = 0;
+
+ if (write(qp->context->cmd_fd, &cmd, sizeof cmd) != sizeof cmd)
+ return errno;
+
+ (void) VALGRIND_MAKE_MEM_DEFINED(&resp, sizeof resp);
+
+ pthread_mutex_lock(&qp->mutex);
+ while (qp->events_completed != resp.events_reported)
+ pthread_cond_wait(&qp->cond, &qp->mutex);
+ pthread_mutex_unlock(&qp->mutex);
+
+ return 0;
+}
+
+int ibv_cmd_attach_mcast(struct ibv_qp *qp, const union ibv_gid *gid, uint16_t lid)
+{
+ struct ibv_attach_mcast cmd;
+
+ IBV_INIT_CMD(&cmd, sizeof cmd, ATTACH_MCAST);
+ memcpy(cmd.gid, gid->raw, sizeof cmd.gid);
+ cmd.qp_handle = qp->handle;
+ cmd.mlid = lid;
+ cmd.reserved = 0;
+
+ if (write(qp->context->cmd_fd, &cmd, sizeof cmd) != sizeof cmd)
+ return errno;
+
+ return 0;
+}
+
+int ibv_cmd_detach_mcast(struct ibv_qp *qp, const union ibv_gid *gid, uint16_t lid)
+{
+ struct ibv_detach_mcast cmd;
+
+ IBV_INIT_CMD(&cmd, sizeof cmd, DETACH_MCAST);
+ memcpy(cmd.gid, gid->raw, sizeof cmd.gid);
+ cmd.qp_handle = qp->handle;
+ cmd.mlid = lid;
+ cmd.reserved = 0;
+
+ if (write(qp->context->cmd_fd, &cmd, sizeof cmd) != sizeof cmd)
+ return errno;
+
+ return 0;
+}
+
+static int buffer_is_zero(char *addr, ssize_t size)
+{
+ return addr[0] == 0 && !memcmp(addr, addr + 1, size - 1);
+}
+
+static int get_filters_size(struct ibv_flow_spec *ib_spec,
+ struct ibv_kern_spec *kern_spec,
+ int *ib_filter_size, int *kern_filter_size,
+ enum ibv_flow_spec_type type)
+{
+ void *ib_spec_filter_mask;
+ int curr_kern_filter_size;
+ int min_filter_size;
+
+ *ib_filter_size = (ib_spec->hdr.size - sizeof(ib_spec->hdr)) / 2;
+
+ switch (type) {
+ case IBV_FLOW_SPEC_IPV4_EXT:
+ min_filter_size =
+ offsetof(struct ibv_kern_ipv4_ext_filter, flags) +
+ sizeof(kern_spec->ipv4_ext.mask.flags);
+ curr_kern_filter_size = min_filter_size;
+ ib_spec_filter_mask = (void *)&ib_spec->ipv4_ext.val +
+ *ib_filter_size;
+ break;
+ case IBV_FLOW_SPEC_IPV6:
+ min_filter_size =
+ offsetof(struct ibv_kern_ipv6_filter, hop_limit) +
+ sizeof(kern_spec->ipv6.mask.hop_limit);
+ curr_kern_filter_size = min_filter_size;
+ ib_spec_filter_mask = (void *)&ib_spec->ipv6.val +
+ *ib_filter_size;
+ break;
+ case IBV_FLOW_SPEC_VXLAN_TUNNEL:
+ min_filter_size =
+ offsetof(struct ibv_kern_tunnel_filter,
+ tunnel_id) +
+ sizeof(kern_spec->tunnel.mask.tunnel_id);
+ curr_kern_filter_size = min_filter_size;
+ ib_spec_filter_mask = (void *)&ib_spec->tunnel.val +
+ *ib_filter_size;
+ break;
+ default:
+ return EINVAL;
+ }
+
+ if (*ib_filter_size < min_filter_size)
+ return EINVAL;
+
+ if (*ib_filter_size > curr_kern_filter_size &&
+ !buffer_is_zero(ib_spec_filter_mask + curr_kern_filter_size,
+ *ib_filter_size - curr_kern_filter_size))
+ return EOPNOTSUPP;
+
+ *kern_filter_size = min_t(int, curr_kern_filter_size, *ib_filter_size);
+
+ return 0;
+}
+
+static int ib_spec_to_kern_spec(struct ibv_flow_spec *ib_spec,
+ struct ibv_kern_spec *kern_spec)
+{
+ int kern_filter_size;
+ int ib_filter_size;
+ int ret;
+
+ kern_spec->hdr.type = ib_spec->hdr.type;
+
+ switch (kern_spec->hdr.type) {
+ case IBV_FLOW_SPEC_ETH:
+ case IBV_FLOW_SPEC_ETH | IBV_FLOW_SPEC_INNER:
+ kern_spec->eth.size = sizeof(struct ibv_kern_spec_eth);
+ memcpy(&kern_spec->eth.val, &ib_spec->eth.val,
+ sizeof(struct ibv_flow_eth_filter));
+ memcpy(&kern_spec->eth.mask, &ib_spec->eth.mask,
+ sizeof(struct ibv_flow_eth_filter));
+ break;
+ case IBV_FLOW_SPEC_IPV4:
+ case IBV_FLOW_SPEC_IPV4 | IBV_FLOW_SPEC_INNER:
+ kern_spec->ipv4.size = sizeof(struct ibv_kern_spec_ipv4);
+ memcpy(&kern_spec->ipv4.val, &ib_spec->ipv4.val,
+ sizeof(struct ibv_flow_ipv4_filter));
+ memcpy(&kern_spec->ipv4.mask, &ib_spec->ipv4.mask,
+ sizeof(struct ibv_flow_ipv4_filter));
+ break;
+ case IBV_FLOW_SPEC_IPV4_EXT:
+ case IBV_FLOW_SPEC_IPV4_EXT | IBV_FLOW_SPEC_INNER:
+ ret = get_filters_size(ib_spec, kern_spec,
+ &ib_filter_size, &kern_filter_size,
+ IBV_FLOW_SPEC_IPV4_EXT);
+ if (ret)
+ return ret;
+
+ kern_spec->hdr.type = IBV_FLOW_SPEC_IPV4 |
+ (IBV_FLOW_SPEC_INNER & ib_spec->hdr.type);
+ kern_spec->ipv4_ext.size = sizeof(struct
+ ibv_kern_spec_ipv4_ext);
+ memcpy(&kern_spec->ipv4_ext.val, &ib_spec->ipv4_ext.val,
+ kern_filter_size);
+ memcpy(&kern_spec->ipv4_ext.mask, (void *)&ib_spec->ipv4_ext.val
+ + ib_filter_size, kern_filter_size);
+ break;
+ case IBV_FLOW_SPEC_IPV6:
+ case IBV_FLOW_SPEC_IPV6 | IBV_FLOW_SPEC_INNER:
+ ret = get_filters_size(ib_spec, kern_spec,
+ &ib_filter_size, &kern_filter_size,
+ IBV_FLOW_SPEC_IPV6);
+ if (ret)
+ return ret;
+
+ kern_spec->ipv6.size = sizeof(struct ibv_kern_spec_ipv6);
+ memcpy(&kern_spec->ipv6.val, &ib_spec->ipv6.val,
+ kern_filter_size);
+ memcpy(&kern_spec->ipv6.mask, (void *)&ib_spec->ipv6.val
+ + ib_filter_size, kern_filter_size);
+ break;
+ case IBV_FLOW_SPEC_TCP:
+ case IBV_FLOW_SPEC_UDP:
+ case IBV_FLOW_SPEC_TCP | IBV_FLOW_SPEC_INNER:
+ case IBV_FLOW_SPEC_UDP | IBV_FLOW_SPEC_INNER:
+ kern_spec->tcp_udp.size = sizeof(struct ibv_kern_spec_tcp_udp);
+ memcpy(&kern_spec->tcp_udp.val, &ib_spec->tcp_udp.val,
+ sizeof(struct ibv_flow_ipv4_filter));
+ memcpy(&kern_spec->tcp_udp.mask, &ib_spec->tcp_udp.mask,
+ sizeof(struct ibv_flow_tcp_udp_filter));
+ break;
+ case IBV_FLOW_SPEC_VXLAN_TUNNEL:
+ ret = get_filters_size(ib_spec, kern_spec,
+ &ib_filter_size, &kern_filter_size,
+ IBV_FLOW_SPEC_VXLAN_TUNNEL);
+ if (ret)
+ return ret;
+
+ kern_spec->tunnel.size = sizeof(struct ibv_kern_spec_tunnel);
+ memcpy(&kern_spec->tunnel.val, &ib_spec->tunnel.val,
+ kern_filter_size);
+ memcpy(&kern_spec->tunnel.mask, (void *)&ib_spec->tunnel.val
+ + ib_filter_size, kern_filter_size);
+ break;
+ case IBV_FLOW_SPEC_ACTION_TAG:
+ kern_spec->flow_tag.size =
+ sizeof(struct ibv_kern_spec_action_tag);
+ kern_spec->flow_tag.tag_id = ib_spec->flow_tag.tag_id;
+ break;
+ case IBV_FLOW_SPEC_ACTION_DROP:
+ kern_spec->drop.size = sizeof(struct ibv_kern_spec_action_drop);
+ break;
+ default:
+ return EINVAL;
+ }
+ return 0;
+}
+
+struct ibv_flow *ibv_cmd_create_flow(struct ibv_qp *qp,
+ struct ibv_flow_attr *flow_attr)
+{
+ struct ibv_create_flow *cmd;
+ struct ibv_create_flow_resp resp;
+ struct ibv_flow *flow_id;
+ size_t cmd_size;
+ size_t written_size;
+ int i, err;
+ void *kern_spec;
+ void *ib_spec;
+
+ cmd_size = sizeof(*cmd) + (flow_attr->num_of_specs *
+ sizeof(struct ibv_kern_spec));
+ cmd = alloca(cmd_size);
+ flow_id = malloc(sizeof(*flow_id));
+ if (!flow_id)
+ return NULL;
+ memset(cmd, 0, cmd_size);
+
+ cmd->qp_handle = qp->handle;
+
+ cmd->flow_attr.type = flow_attr->type;
+ cmd->flow_attr.priority = flow_attr->priority;
+ cmd->flow_attr.num_of_specs = flow_attr->num_of_specs;
+ cmd->flow_attr.port = flow_attr->port;
+ cmd->flow_attr.flags = flow_attr->flags;
+
+ kern_spec = cmd + 1;
+ ib_spec = flow_attr + 1;
+ for (i = 0; i < flow_attr->num_of_specs; i++) {
+ err = ib_spec_to_kern_spec(ib_spec, kern_spec);
+ if (err) {
+ errno = err;
+ goto err;
+ }
+ cmd->flow_attr.size +=
+ ((struct ibv_kern_spec *)kern_spec)->hdr.size;
+ kern_spec += ((struct ibv_kern_spec *)kern_spec)->hdr.size;
+ ib_spec += ((struct ibv_flow_spec *)ib_spec)->hdr.size;
+ }
+
+ written_size = sizeof(*cmd) + cmd->flow_attr.size;
+ IBV_INIT_CMD_RESP_EX_VCMD(cmd, written_size, written_size, CREATE_FLOW,
+ &resp, sizeof(resp));
+ if (write(qp->context->cmd_fd, cmd, written_size) != written_size)
+ goto err;
+
+ (void) VALGRIND_MAKE_MEM_DEFINED(&resp, sizeof(resp));
+
+ flow_id->context = qp->context;
+ flow_id->handle = resp.flow_handle;
+ return flow_id;
+err:
+ free(flow_id);
+ return NULL;
+}
+
+int ibv_cmd_destroy_flow(struct ibv_flow *flow_id)
+{
+ struct ibv_destroy_flow cmd;
+ int ret = 0;
+
+ memset(&cmd, 0, sizeof(cmd));
+ IBV_INIT_CMD_EX(&cmd, sizeof(cmd), DESTROY_FLOW);
+ cmd.flow_handle = flow_id->handle;
+
+ if (write(flow_id->context->cmd_fd, &cmd, sizeof(cmd)) != sizeof(cmd))
+ ret = errno;
+ free(flow_id);
+ return ret;
+}
+
+int ibv_cmd_create_wq(struct ibv_context *context,
+ struct ibv_wq_init_attr *wq_init_attr,
+ struct ibv_wq *wq,
+ struct ibv_create_wq *cmd,
+ size_t cmd_core_size,
+ size_t cmd_size,
+ struct ibv_create_wq_resp *resp,
+ size_t resp_core_size,
+ size_t resp_size)
+{
+ int err;
+
+ if (wq_init_attr->comp_mask >= IBV_WQ_INIT_ATTR_RESERVED)
+ return EINVAL;
+
+ IBV_INIT_CMD_RESP_EX_V(cmd, cmd_core_size, cmd_size,
+ CREATE_WQ, resp,
+ resp_core_size, resp_size);
+
+ cmd->user_handle = (uintptr_t)wq;
+ cmd->pd_handle = wq_init_attr->pd->handle;
+ cmd->cq_handle = wq_init_attr->cq->handle;
+ cmd->wq_type = wq_init_attr->wq_type;
+ cmd->max_sge = wq_init_attr->max_sge;
+ cmd->max_wr = wq_init_attr->max_wr;
+ cmd->comp_mask = 0;
+
+ if (cmd_core_size >= offsetof(struct ibv_create_wq, create_flags) +
+ sizeof(cmd->create_flags)) {
+ if (wq_init_attr->comp_mask & IBV_WQ_INIT_ATTR_FLAGS) {
+ if (wq_init_attr->create_flags & ~(IBV_WQ_FLAGS_RESERVED - 1))
+ return EOPNOTSUPP;
+ cmd->create_flags = wq_init_attr->create_flags;
+ }
+ }
+
+ err = write(context->cmd_fd, cmd, cmd_size);
+ if (err != cmd_size)
+ return errno;
+
+ (void) VALGRIND_MAKE_MEM_DEFINED(resp, resp_size);
+
+ if (resp->response_length < resp_core_size)
+ return EINVAL;
+
+ wq->handle = resp->wq_handle;
+ wq_init_attr->max_wr = resp->max_wr;
+ wq_init_attr->max_sge = resp->max_sge;
+ wq->wq_num = resp->wqn;
+ wq->context = context;
+ wq->cq = wq_init_attr->cq;
+ wq->pd = wq_init_attr->pd;
+ wq->wq_type = wq_init_attr->wq_type;
+
+ return 0;
+}
+
+int ibv_cmd_modify_wq(struct ibv_wq *wq, struct ibv_wq_attr *attr,
+ struct ibv_modify_wq *cmd, size_t cmd_core_size,
+ size_t cmd_size)
+{
+ if (attr->attr_mask >= IBV_WQ_ATTR_RESERVED)
+ return EINVAL;
+
+ memset(cmd, 0, cmd_core_size);
+ IBV_INIT_CMD_EX(cmd, cmd_size, MODIFY_WQ);
+
+ cmd->curr_wq_state = attr->curr_wq_state;
+ cmd->wq_state = attr->wq_state;
+ if (cmd_core_size >= offsetof(struct ibv_modify_wq, flags_mask) +
+ sizeof(cmd->flags_mask)) {
+ if (attr->attr_mask & IBV_WQ_ATTR_FLAGS) {
+ if (attr->flags_mask & ~(IBV_WQ_FLAGS_RESERVED - 1))
+ return EOPNOTSUPP;
+ cmd->flags = attr->flags;
+ cmd->flags_mask = attr->flags_mask;
+ }
+ }
+ cmd->wq_handle = wq->handle;
+ cmd->attr_mask = attr->attr_mask;
+
+ if (write(wq->context->cmd_fd, cmd, cmd_size) != cmd_size)
+ return errno;
+
+ if (attr->attr_mask & IBV_WQ_ATTR_STATE)
+ wq->state = attr->wq_state;
+
+ return 0;
+}
+
+int ibv_cmd_destroy_wq(struct ibv_wq *wq)
+{
+ struct ibv_destroy_wq cmd;
+ struct ibv_destroy_wq_resp resp;
+ int ret = 0;
+
+ memset(&cmd, 0, sizeof(cmd));
+ memset(&resp, 0, sizeof(resp));
+
+ IBV_INIT_CMD_RESP_EX(&cmd, sizeof(cmd), DESTROY_WQ, &resp, sizeof(resp));
+ cmd.wq_handle = wq->handle;
+
+ if (write(wq->context->cmd_fd, &cmd, sizeof(cmd)) != sizeof(cmd))
+ return errno;
+
+ if (resp.response_length < sizeof(resp))
+ return EINVAL;
+
+ pthread_mutex_lock(&wq->mutex);
+ while (wq->events_completed != resp.events_reported)
+ pthread_cond_wait(&wq->cond, &wq->mutex);
+ pthread_mutex_unlock(&wq->mutex);
+
+ return ret;
+}
+
+int ibv_cmd_create_rwq_ind_table(struct ibv_context *context,
+ struct ibv_rwq_ind_table_init_attr *init_attr,
+ struct ibv_rwq_ind_table *rwq_ind_table,
+ struct ibv_create_rwq_ind_table *cmd,
+ size_t cmd_core_size,
+ size_t cmd_size,
+ struct ibv_create_rwq_ind_table_resp *resp,
+ size_t resp_core_size,
+ size_t resp_size)
+{
+ int err, i;
+ uint32_t required_tbl_size, alloc_tbl_size;
+ uint32_t *tbl_start;
+ int num_tbl_entries;
+
+ if (init_attr->comp_mask >= IBV_CREATE_IND_TABLE_RESERVED)
+ return EINVAL;
+
+ alloc_tbl_size = cmd_core_size - sizeof(*cmd);
+ num_tbl_entries = 1 << init_attr->log_ind_tbl_size;
+
+ /* Data must be u64 aligned */
+ required_tbl_size = (num_tbl_entries * sizeof(uint32_t)) < sizeof(uint64_t) ?
+ sizeof(uint64_t) : (num_tbl_entries * sizeof(uint32_t));
+
+ if (alloc_tbl_size < required_tbl_size)
+ return EINVAL;
+
+ tbl_start = (uint32_t *)((uint8_t *)cmd + sizeof(*cmd));
+ for (i = 0; i < num_tbl_entries; i++)
+ tbl_start[i] = init_attr->ind_tbl[i]->handle;
+
+ IBV_INIT_CMD_RESP_EX_V(cmd, cmd_core_size, cmd_size,
+ CREATE_RWQ_IND_TBL, resp,
+ resp_core_size, resp_size);
+ cmd->log_ind_tbl_size = init_attr->log_ind_tbl_size;
+ cmd->comp_mask = 0;
+
+ err = write(context->cmd_fd, cmd, cmd_size);
+ if (err != cmd_size)
+ return errno;
+
+ (void) VALGRIND_MAKE_MEM_DEFINED(resp, resp_size);
+
+ if (resp->response_length < resp_core_size)
+ return EINVAL;
+
+ rwq_ind_table->ind_tbl_handle = resp->ind_tbl_handle;
+ rwq_ind_table->ind_tbl_num = resp->ind_tbl_num;
+ rwq_ind_table->context = context;
+ return 0;
+}
+
+int ibv_cmd_destroy_rwq_ind_table(struct ibv_rwq_ind_table *rwq_ind_table)
+{
+ struct ibv_destroy_rwq_ind_table cmd;
+ int ret = 0;
+
+ memset(&cmd, 0, sizeof(cmd));
+ IBV_INIT_CMD_EX(&cmd, sizeof(cmd), DESTROY_RWQ_IND_TBL);
+ cmd.ind_tbl_handle = rwq_ind_table->ind_tbl_handle;
+
+ if (write(rwq_ind_table->context->cmd_fd, &cmd, sizeof(cmd)) != sizeof(cmd))
+ ret = errno;
+
+ return ret;
+}
diff --git a/contrib/ofed/libibverbs/compat-1_0.c b/contrib/ofed/libibverbs/compat-1_0.c
new file mode 100644
index 0000000..d63bd55
--- /dev/null
+++ b/contrib/ofed/libibverbs/compat-1_0.c
@@ -0,0 +1,1009 @@
+/*
+ * Copyright (c) 2007 Cisco Systems, Inc. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#include <config.h>
+
+#include <string.h>
+#include <stddef.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <alloca.h>
+
+#include "ibverbs.h"
+
+struct ibv_pd_1_0 {
+ struct ibv_context_1_0 *context;
+ uint32_t handle;
+
+ struct ibv_pd *real_pd;
+};
+
+struct ibv_mr_1_0 {
+ struct ibv_context_1_0 *context;
+ struct ibv_pd_1_0 *pd;
+ uint32_t handle;
+ uint32_t lkey;
+ uint32_t rkey;
+
+ struct ibv_mr *real_mr;
+};
+
+struct ibv_srq_1_0 {
+ struct ibv_context_1_0 *context;
+ void *srq_context;
+ struct ibv_pd_1_0 *pd;
+ uint32_t handle;
+
+ pthread_mutex_t mutex;
+ pthread_cond_t cond;
+ uint32_t events_completed;
+
+ struct ibv_srq *real_srq;
+};
+
+struct ibv_qp_init_attr_1_0 {
+ void *qp_context;
+ struct ibv_cq_1_0 *send_cq;
+ struct ibv_cq_1_0 *recv_cq;
+ struct ibv_srq_1_0 *srq;
+ struct ibv_qp_cap cap;
+ enum ibv_qp_type qp_type;
+ int sq_sig_all;
+};
+
+struct ibv_send_wr_1_0 {
+ struct ibv_send_wr_1_0 *next;
+ uint64_t wr_id;
+ struct ibv_sge *sg_list;
+ int num_sge;
+ enum ibv_wr_opcode opcode;
+ int send_flags;
+ __be32 imm_data;
+ union {
+ struct {
+ uint64_t remote_addr;
+ uint32_t rkey;
+ } rdma;
+ struct {
+ uint64_t remote_addr;
+ uint64_t compare_add;
+ uint64_t swap;
+ uint32_t rkey;
+ } atomic;
+ struct {
+ struct ibv_ah_1_0 *ah;
+ uint32_t remote_qpn;
+ uint32_t remote_qkey;
+ } ud;
+ } wr;
+};
+
+struct ibv_recv_wr_1_0 {
+ struct ibv_recv_wr_1_0 *next;
+ uint64_t wr_id;
+ struct ibv_sge *sg_list;
+ int num_sge;
+};
+
+struct ibv_qp_1_0 {
+ struct ibv_context_1_0 *context;
+ void *qp_context;
+ struct ibv_pd_1_0 *pd;
+ struct ibv_cq_1_0 *send_cq;
+ struct ibv_cq_1_0 *recv_cq;
+ struct ibv_srq_1_0 *srq;
+ uint32_t handle;
+ uint32_t qp_num;
+ enum ibv_qp_state state;
+ enum ibv_qp_type qp_type;
+
+ pthread_mutex_t mutex;
+ pthread_cond_t cond;
+ uint32_t events_completed;
+
+ struct ibv_qp *real_qp;
+};
+
+struct ibv_cq_1_0 {
+ struct ibv_context_1_0 *context;
+ void *cq_context;
+ uint32_t handle;
+ int cqe;
+
+ pthread_mutex_t mutex;
+ pthread_cond_t cond;
+ uint32_t comp_events_completed;
+ uint32_t async_events_completed;
+
+ struct ibv_cq *real_cq;
+};
+
+struct ibv_ah_1_0 {
+ struct ibv_context_1_0 *context;
+ struct ibv_pd_1_0 *pd;
+ uint32_t handle;
+
+ struct ibv_ah *real_ah;
+};
+
+struct ibv_device_1_0 {
+ void *obsolete_sysfs_dev;
+ void *obsolete_sysfs_ibdev;
+ struct ibv_device *real_device; /* was obsolete driver member */
+ struct _ibv_device_ops _ops;
+};
+
+struct ibv_context_ops_1_0 {
+ int (*query_device)(struct ibv_context *context,
+ struct ibv_device_attr *device_attr);
+ int (*query_port)(struct ibv_context *context, uint8_t port_num,
+ struct ibv_port_attr *port_attr);
+ struct ibv_pd * (*alloc_pd)(struct ibv_context *context);
+ int (*dealloc_pd)(struct ibv_pd *pd);
+ struct ibv_mr * (*reg_mr)(struct ibv_pd *pd, void *addr, size_t length,
+ int access);
+ int (*dereg_mr)(struct ibv_mr *mr);
+ struct ibv_cq * (*create_cq)(struct ibv_context *context, int cqe,
+ struct ibv_comp_channel *channel,
+ int comp_vector);
+ int (*poll_cq)(struct ibv_cq_1_0 *cq, int num_entries,
+ struct ibv_wc *wc);
+ int (*req_notify_cq)(struct ibv_cq_1_0 *cq,
+ int solicited_only);
+ void (*cq_event)(struct ibv_cq *cq);
+ int (*resize_cq)(struct ibv_cq *cq, int cqe);
+ int (*destroy_cq)(struct ibv_cq *cq);
+ struct ibv_srq * (*create_srq)(struct ibv_pd *pd,
+ struct ibv_srq_init_attr *srq_init_attr);
+ int (*modify_srq)(struct ibv_srq *srq,
+ struct ibv_srq_attr *srq_attr,
+ int srq_attr_mask);
+ int (*query_srq)(struct ibv_srq *srq,
+ struct ibv_srq_attr *srq_attr);
+ int (*destroy_srq)(struct ibv_srq *srq);
+ int (*post_srq_recv)(struct ibv_srq_1_0 *srq,
+ struct ibv_recv_wr_1_0 *recv_wr,
+ struct ibv_recv_wr_1_0 **bad_recv_wr);
+ struct ibv_qp * (*create_qp)(struct ibv_pd *pd, struct ibv_qp_init_attr *attr);
+ int (*query_qp)(struct ibv_qp *qp, struct ibv_qp_attr *attr,
+ int attr_mask,
+ struct ibv_qp_init_attr *init_attr);
+ int (*modify_qp)(struct ibv_qp *qp, struct ibv_qp_attr *attr,
+ int attr_mask);
+ int (*destroy_qp)(struct ibv_qp *qp);
+ int (*post_send)(struct ibv_qp_1_0 *qp,
+ struct ibv_send_wr_1_0 *wr,
+ struct ibv_send_wr_1_0 **bad_wr);
+ int (*post_recv)(struct ibv_qp_1_0 *qp,
+ struct ibv_recv_wr_1_0 *wr,
+ struct ibv_recv_wr_1_0 **bad_wr);
+ struct ibv_ah * (*create_ah)(struct ibv_pd *pd, struct ibv_ah_attr *attr);
+ int (*destroy_ah)(struct ibv_ah *ah);
+ int (*attach_mcast)(struct ibv_qp *qp, union ibv_gid *gid,
+ uint16_t lid);
+ int (*detach_mcast)(struct ibv_qp *qp, union ibv_gid *gid,
+ uint16_t lid);
+};
+
+struct ibv_context_1_0 {
+ struct ibv_device_1_0 *device;
+ struct ibv_context_ops_1_0 ops;
+ int cmd_fd;
+ int async_fd;
+ int num_comp_vectors;
+
+ struct ibv_context *real_context; /* was abi_compat member */
+};
+
+typedef struct ibv_device *(*ibv_driver_init_func_1_1)(const char *uverbs_sys_path,
+ int abi_version);
+
+/* Hack to avoid GCC's -Wmissing-prototypes and the similar error from sparse
+ with these prototypes. Symbol versionining requires the goofy names, the
+ prototype must match the version in the historical 1.0 verbs.h.
+ */
+struct ibv_device_1_0 **__ibv_get_device_list_1_0(int *num);
+void __ibv_free_device_list_1_0(struct ibv_device_1_0 **list);
+const char *__ibv_get_device_name_1_0(struct ibv_device_1_0 *device);
+__be64 __ibv_get_device_guid_1_0(struct ibv_device_1_0 *device);
+struct ibv_context_1_0 *__ibv_open_device_1_0(struct ibv_device_1_0 *device);
+int __ibv_close_device_1_0(struct ibv_context_1_0 *context);
+int __ibv_get_async_event_1_0(struct ibv_context_1_0 *context,
+ struct ibv_async_event *event);
+void __ibv_ack_async_event_1_0(struct ibv_async_event *event);
+int __ibv_query_device_1_0(struct ibv_context_1_0 *context,
+ struct ibv_device_attr *device_attr);
+int __ibv_query_port_1_0(struct ibv_context_1_0 *context, uint8_t port_num,
+ struct ibv_port_attr *port_attr);
+int __ibv_query_gid_1_0(struct ibv_context_1_0 *context, uint8_t port_num,
+ int index, union ibv_gid *gid);
+int __ibv_query_pkey_1_0(struct ibv_context_1_0 *context, uint8_t port_num,
+ int index, __be16 *pkey);
+struct ibv_pd_1_0 *__ibv_alloc_pd_1_0(struct ibv_context_1_0 *context);
+int __ibv_dealloc_pd_1_0(struct ibv_pd_1_0 *pd);
+struct ibv_mr_1_0 *__ibv_reg_mr_1_0(struct ibv_pd_1_0 *pd, void *addr,
+ size_t length, int access);
+int __ibv_dereg_mr_1_0(struct ibv_mr_1_0 *mr);
+struct ibv_cq_1_0 *__ibv_create_cq_1_0(struct ibv_context_1_0 *context, int cqe,
+ void *cq_context,
+ struct ibv_comp_channel *channel,
+ int comp_vector);
+int __ibv_resize_cq_1_0(struct ibv_cq_1_0 *cq, int cqe);
+int __ibv_destroy_cq_1_0(struct ibv_cq_1_0 *cq);
+int __ibv_get_cq_event_1_0(struct ibv_comp_channel *channel,
+ struct ibv_cq_1_0 **cq, void **cq_context);
+void __ibv_ack_cq_events_1_0(struct ibv_cq_1_0 *cq, unsigned int nevents);
+struct ibv_srq_1_0 *
+__ibv_create_srq_1_0(struct ibv_pd_1_0 *pd,
+ struct ibv_srq_init_attr *srq_init_attr);
+int __ibv_modify_srq_1_0(struct ibv_srq_1_0 *srq, struct ibv_srq_attr *srq_attr,
+ int srq_attr_mask);
+int __ibv_query_srq_1_0(struct ibv_srq_1_0 *srq, struct ibv_srq_attr *srq_attr);
+int __ibv_destroy_srq_1_0(struct ibv_srq_1_0 *srq);
+struct ibv_qp_1_0 *
+__ibv_create_qp_1_0(struct ibv_pd_1_0 *pd,
+ struct ibv_qp_init_attr_1_0 *qp_init_attr);
+int __ibv_query_qp_1_0(struct ibv_qp_1_0 *qp, struct ibv_qp_attr *attr,
+ int attr_mask, struct ibv_qp_init_attr_1_0 *init_attr);
+int __ibv_modify_qp_1_0(struct ibv_qp_1_0 *qp, struct ibv_qp_attr *attr,
+ int attr_mask);
+int __ibv_destroy_qp_1_0(struct ibv_qp_1_0 *qp);
+struct ibv_ah_1_0 *__ibv_create_ah_1_0(struct ibv_pd_1_0 *pd,
+ struct ibv_ah_attr *attr);
+int __ibv_destroy_ah_1_0(struct ibv_ah_1_0 *ah);
+int __ibv_attach_mcast_1_0(struct ibv_qp_1_0 *qp, union ibv_gid *gid,
+ uint16_t lid);
+int __ibv_detach_mcast_1_0(struct ibv_qp_1_0 *qp, union ibv_gid *gid,
+ uint16_t lid);
+void __ibv_register_driver_1_1(const char *name,
+ ibv_driver_init_func_1_1 init_func);
+
+struct ibv_device_1_0 **__ibv_get_device_list_1_0(int *num)
+{
+ struct ibv_device **real_list;
+ struct ibv_device_1_0 **l;
+ int i, n;
+
+ real_list = ibv_get_device_list(&n);
+ if (!real_list)
+ return NULL;
+
+ l = calloc(n + 2, sizeof (struct ibv_device_1_0 *));
+ if (!l)
+ goto free_device_list;
+
+ l[0] = (void *) real_list;
+
+ for (i = 0; i < n; ++i) {
+ l[i + 1] = calloc(1, sizeof (struct ibv_device_1_0));
+ if (!l[i + 1])
+ goto fail;
+ l[i + 1]->real_device = real_list[i];
+ }
+
+ if (num)
+ *num = n;
+
+ return l + 1;
+
+fail:
+ for (i = 1; i <= n; ++i)
+ if (l[i])
+ free(l[i]);
+ free(l);
+
+free_device_list:
+ ibv_free_device_list(real_list);
+ return NULL;
+}
+symver(__ibv_get_device_list_1_0, ibv_get_device_list, IBVERBS_1.0);
+
+void __ibv_free_device_list_1_0(struct ibv_device_1_0 **list)
+{
+ struct ibv_device_1_0 **l = list;
+
+ while (*l) {
+ free(*l);
+ ++l;
+ }
+
+ ibv_free_device_list((void *) list[-1]);
+ free(list - 1);
+}
+symver(__ibv_free_device_list_1_0, ibv_free_device_list, IBVERBS_1.0);
+
+const char *__ibv_get_device_name_1_0(struct ibv_device_1_0 *device)
+{
+ return ibv_get_device_name(device->real_device);
+}
+symver(__ibv_get_device_name_1_0, ibv_get_device_name, IBVERBS_1.0);
+
+__be64 __ibv_get_device_guid_1_0(struct ibv_device_1_0 *device)
+{
+ return ibv_get_device_guid(device->real_device);
+}
+symver(__ibv_get_device_guid_1_0, ibv_get_device_guid, IBVERBS_1.0);
+
+static int poll_cq_wrapper_1_0(struct ibv_cq_1_0 *cq, int num_entries,
+ struct ibv_wc *wc)
+{
+ return cq->context->real_context->ops.poll_cq(cq->real_cq, num_entries, wc);
+}
+
+static int req_notify_cq_wrapper_1_0(struct ibv_cq_1_0 *cq, int sol_only)
+{
+ return cq->context->real_context->ops.req_notify_cq(cq->real_cq, sol_only);
+}
+
+static int post_srq_recv_wrapper_1_0(struct ibv_srq_1_0 *srq, struct ibv_recv_wr_1_0 *wr,
+ struct ibv_recv_wr_1_0 **bad_wr)
+{
+ struct ibv_recv_wr_1_0 *w;
+ struct ibv_recv_wr *real_wr, *head_wr = NULL, *tail_wr = NULL, *real_bad_wr;
+ int ret;
+
+ for (w = wr; w; w = w->next) {
+ real_wr = alloca(sizeof *real_wr);
+ real_wr->wr_id = w->wr_id;
+ real_wr->sg_list = w->sg_list;
+ real_wr->num_sge = w->num_sge;
+ real_wr->next = NULL;
+ if (tail_wr)
+ tail_wr->next = real_wr;
+ else
+ head_wr = real_wr;
+
+ tail_wr = real_wr;
+ }
+
+ ret = srq->context->real_context->ops.post_srq_recv(srq->real_srq, head_wr,
+ &real_bad_wr);
+
+ if (ret) {
+ for (real_wr = head_wr, w = wr;
+ real_wr;
+ real_wr = real_wr->next, w = w->next)
+ if (real_wr == real_bad_wr) {
+ *bad_wr = w;
+ break;
+ }
+ }
+
+ return ret;
+}
+
+static int post_send_wrapper_1_0(struct ibv_qp_1_0 *qp, struct ibv_send_wr_1_0 *wr,
+ struct ibv_send_wr_1_0 **bad_wr)
+{
+ struct ibv_send_wr_1_0 *w;
+ struct ibv_send_wr *real_wr, *head_wr = NULL, *tail_wr = NULL, *real_bad_wr;
+ int is_ud = qp->qp_type == IBV_QPT_UD;
+ int ret;
+
+ for (w = wr; w; w = w->next) {
+ real_wr = alloca(sizeof *real_wr);
+ real_wr->wr_id = w->wr_id;
+ real_wr->next = NULL;
+
+#define TEST_SIZE_2_POINT(f1, f2) \
+ ((offsetof(struct ibv_send_wr, f1) - offsetof(struct ibv_send_wr, f2)) \
+ == offsetof(struct ibv_send_wr_1_0, f1) - offsetof(struct ibv_send_wr_1_0, f2))
+#define TEST_SIZE_TO_END(f1) \
+ ((sizeof(struct ibv_send_wr) - offsetof(struct ibv_send_wr, f1)) == \
+ (sizeof(struct ibv_send_wr_1_0) - offsetof(struct ibv_send_wr_1_0, f1)))
+
+ if (TEST_SIZE_TO_END (sg_list))
+ memcpy(&real_wr->sg_list, &w->sg_list, sizeof *real_wr
+ - offsetof(struct ibv_send_wr, sg_list));
+ else if (TEST_SIZE_2_POINT (imm_data, sg_list) &&
+ TEST_SIZE_TO_END (wr)) {
+ /* we have alignment up to wr, but padding between
+ * imm_data and wr, and we know wr itself is the
+ * same size */
+ memcpy(&real_wr->sg_list, &w->sg_list,
+ offsetof(struct ibv_send_wr, imm_data) -
+ offsetof(struct ibv_send_wr, sg_list) +
+ sizeof real_wr->imm_data);
+ memcpy(&real_wr->wr, &w->wr, sizeof real_wr->wr);
+ } else {
+ real_wr->sg_list = w->sg_list;
+ real_wr->num_sge = w->num_sge;
+ real_wr->opcode = w->opcode;
+ real_wr->send_flags = w->send_flags;
+ real_wr->imm_data = w->imm_data;
+ if (TEST_SIZE_TO_END (wr))
+ memcpy(&real_wr->wr, &w->wr,
+ sizeof real_wr->wr);
+ else {
+ real_wr->wr.atomic.remote_addr =
+ w->wr.atomic.remote_addr;
+ real_wr->wr.atomic.compare_add =
+ w->wr.atomic.compare_add;
+ real_wr->wr.atomic.swap =
+ w->wr.atomic.swap;
+ real_wr->wr.atomic.rkey =
+ w->wr.atomic.rkey;
+ }
+ }
+
+ if (is_ud)
+ real_wr->wr.ud.ah = w->wr.ud.ah->real_ah;
+
+ if (tail_wr)
+ tail_wr->next = real_wr;
+ else
+ head_wr = real_wr;
+
+ tail_wr = real_wr;
+ }
+
+ ret = qp->context->real_context->ops.post_send(qp->real_qp, head_wr,
+ &real_bad_wr);
+
+ if (ret) {
+ for (real_wr = head_wr, w = wr;
+ real_wr;
+ real_wr = real_wr->next, w = w->next)
+ if (real_wr == real_bad_wr) {
+ *bad_wr = w;
+ break;
+ }
+ }
+
+ return ret;
+}
+
+static int post_recv_wrapper_1_0(struct ibv_qp_1_0 *qp, struct ibv_recv_wr_1_0 *wr,
+ struct ibv_recv_wr_1_0 **bad_wr)
+{
+ struct ibv_recv_wr_1_0 *w;
+ struct ibv_recv_wr *real_wr, *head_wr = NULL, *tail_wr = NULL, *real_bad_wr;
+ int ret;
+
+ for (w = wr; w; w = w->next) {
+ real_wr = alloca(sizeof *real_wr);
+ real_wr->wr_id = w->wr_id;
+ real_wr->sg_list = w->sg_list;
+ real_wr->num_sge = w->num_sge;
+ real_wr->next = NULL;
+ if (tail_wr)
+ tail_wr->next = real_wr;
+ else
+ head_wr = real_wr;
+
+ tail_wr = real_wr;
+ }
+
+ ret = qp->context->real_context->ops.post_recv(qp->real_qp, head_wr,
+ &real_bad_wr);
+
+ if (ret) {
+ for (real_wr = head_wr, w = wr;
+ real_wr;
+ real_wr = real_wr->next, w = w->next)
+ if (real_wr == real_bad_wr) {
+ *bad_wr = w;
+ break;
+ }
+ }
+
+ return ret;
+}
+
+struct ibv_context_1_0 *__ibv_open_device_1_0(struct ibv_device_1_0 *device)
+{
+ struct ibv_context *real_ctx;
+ struct ibv_context_1_0 *ctx;
+
+ ctx = malloc(sizeof *ctx);
+ if (!ctx)
+ return NULL;
+
+ real_ctx = ibv_open_device(device->real_device);
+ if (!real_ctx) {
+ free(ctx);
+ return NULL;
+ }
+
+ ctx->device = device;
+ ctx->real_context = real_ctx;
+
+ ctx->ops.poll_cq = poll_cq_wrapper_1_0;
+ ctx->ops.req_notify_cq = req_notify_cq_wrapper_1_0;
+ ctx->ops.post_send = post_send_wrapper_1_0;
+ ctx->ops.post_recv = post_recv_wrapper_1_0;
+ ctx->ops.post_srq_recv = post_srq_recv_wrapper_1_0;
+
+ return ctx;
+}
+symver(__ibv_open_device_1_0, ibv_open_device, IBVERBS_1.0);
+
+int __ibv_close_device_1_0(struct ibv_context_1_0 *context)
+{
+ int ret;
+
+ ret = ibv_close_device(context->real_context);
+ if (ret)
+ return ret;
+
+ free(context);
+ return 0;
+}
+symver(__ibv_close_device_1_0, ibv_close_device, IBVERBS_1.0);
+
+int __ibv_get_async_event_1_0(struct ibv_context_1_0 *context,
+ struct ibv_async_event *event)
+{
+ int ret;
+
+ ret = ibv_get_async_event(context->real_context, event);
+ if (ret)
+ return ret;
+
+ switch (event->event_type) {
+ case IBV_EVENT_CQ_ERR:
+ event->element.cq = event->element.cq->cq_context;
+ break;
+
+ case IBV_EVENT_QP_FATAL:
+ case IBV_EVENT_QP_REQ_ERR:
+ case IBV_EVENT_QP_ACCESS_ERR:
+ case IBV_EVENT_COMM_EST:
+ case IBV_EVENT_SQ_DRAINED:
+ case IBV_EVENT_PATH_MIG:
+ case IBV_EVENT_PATH_MIG_ERR:
+ case IBV_EVENT_QP_LAST_WQE_REACHED:
+ event->element.qp = event->element.qp->qp_context;
+ break;
+
+ case IBV_EVENT_SRQ_ERR:
+ case IBV_EVENT_SRQ_LIMIT_REACHED:
+ event->element.srq = event->element.srq->srq_context;
+ break;
+
+ default:
+ break;
+ }
+
+ return ret;
+}
+symver(__ibv_get_async_event_1_0, ibv_get_async_event, IBVERBS_1.0);
+
+void __ibv_ack_async_event_1_0(struct ibv_async_event *event)
+{
+ struct ibv_async_event real_event = *event;
+
+ switch (event->event_type) {
+ case IBV_EVENT_CQ_ERR:
+ real_event.element.cq =
+ ((struct ibv_cq_1_0 *) event->element.cq)->real_cq;
+ break;
+
+ case IBV_EVENT_QP_FATAL:
+ case IBV_EVENT_QP_REQ_ERR:
+ case IBV_EVENT_QP_ACCESS_ERR:
+ case IBV_EVENT_COMM_EST:
+ case IBV_EVENT_SQ_DRAINED:
+ case IBV_EVENT_PATH_MIG:
+ case IBV_EVENT_PATH_MIG_ERR:
+ case IBV_EVENT_QP_LAST_WQE_REACHED:
+ real_event.element.qp =
+ ((struct ibv_qp_1_0 *) event->element.qp)->real_qp;
+ break;
+
+ case IBV_EVENT_SRQ_ERR:
+ case IBV_EVENT_SRQ_LIMIT_REACHED:
+ real_event.element.srq =
+ ((struct ibv_srq_1_0 *) event->element.srq)->real_srq;
+ break;
+
+ default:
+ break;
+ }
+
+ ibv_ack_async_event(&real_event);
+}
+symver(__ibv_ack_async_event_1_0, ibv_ack_async_event, IBVERBS_1.0);
+
+int __ibv_query_device_1_0(struct ibv_context_1_0 *context,
+ struct ibv_device_attr *device_attr)
+{
+ return ibv_query_device(context->real_context, device_attr);
+}
+symver(__ibv_query_device_1_0, ibv_query_device, IBVERBS_1.0);
+
+int __ibv_query_port_1_0(struct ibv_context_1_0 *context, uint8_t port_num,
+ struct ibv_port_attr *port_attr)
+{
+ return ibv_query_port(context->real_context, port_num, port_attr);
+}
+symver(__ibv_query_port_1_0, ibv_query_port, IBVERBS_1.0);
+
+int __ibv_query_gid_1_0(struct ibv_context_1_0 *context, uint8_t port_num,
+ int index, union ibv_gid *gid)
+{
+ return ibv_query_gid(context->real_context, port_num, index, gid);
+}
+symver(__ibv_query_gid_1_0, ibv_query_gid, IBVERBS_1.0);
+
+int __ibv_query_pkey_1_0(struct ibv_context_1_0 *context, uint8_t port_num,
+ int index, __be16 *pkey)
+{
+ return ibv_query_pkey(context->real_context, port_num, index, pkey);
+}
+symver(__ibv_query_pkey_1_0, ibv_query_pkey, IBVERBS_1.0);
+
+struct ibv_pd_1_0 *__ibv_alloc_pd_1_0(struct ibv_context_1_0 *context)
+{
+ struct ibv_pd *real_pd;
+ struct ibv_pd_1_0 *pd;
+
+ pd = malloc(sizeof *pd);
+ if (!pd)
+ return NULL;
+
+ real_pd = ibv_alloc_pd(context->real_context);
+ if (!real_pd) {
+ free(pd);
+ return NULL;
+ }
+
+ pd->context = context;
+ pd->real_pd = real_pd;
+
+ return pd;
+}
+symver(__ibv_alloc_pd_1_0, ibv_alloc_pd, IBVERBS_1.0);
+
+int __ibv_dealloc_pd_1_0(struct ibv_pd_1_0 *pd)
+{
+ int ret;
+
+ ret = ibv_dealloc_pd(pd->real_pd);
+ if (ret)
+ return ret;
+
+ free(pd);
+ return 0;
+}
+symver(__ibv_dealloc_pd_1_0, ibv_dealloc_pd, IBVERBS_1.0);
+
+struct ibv_mr_1_0 *__ibv_reg_mr_1_0(struct ibv_pd_1_0 *pd, void *addr,
+ size_t length, int access)
+{
+ struct ibv_mr *real_mr;
+ struct ibv_mr_1_0 *mr;
+
+ mr = malloc(sizeof *mr);
+ if (!mr)
+ return NULL;
+
+ real_mr = ibv_reg_mr(pd->real_pd, addr, length, access);
+ if (!real_mr) {
+ free(mr);
+ return NULL;
+ }
+
+ mr->context = pd->context;
+ mr->pd = pd;
+ mr->lkey = real_mr->lkey;
+ mr->rkey = real_mr->rkey;
+ mr->real_mr = real_mr;
+
+ return mr;
+}
+symver(__ibv_reg_mr_1_0, ibv_reg_mr, IBVERBS_1.0);
+
+int __ibv_dereg_mr_1_0(struct ibv_mr_1_0 *mr)
+{
+ int ret;
+
+ ret = ibv_dereg_mr(mr->real_mr);
+ if (ret)
+ return ret;
+
+ free(mr);
+ return 0;
+}
+symver(__ibv_dereg_mr_1_0, ibv_dereg_mr, IBVERBS_1.0);
+
+struct ibv_cq_1_0 *__ibv_create_cq_1_0(struct ibv_context_1_0 *context, int cqe,
+ void *cq_context,
+ struct ibv_comp_channel *channel,
+ int comp_vector)
+{
+ struct ibv_cq *real_cq;
+ struct ibv_cq_1_0 *cq;
+
+ cq = malloc(sizeof *cq);
+ if (!cq)
+ return NULL;
+
+ real_cq = ibv_create_cq(context->real_context, cqe, cq_context,
+ channel, comp_vector);
+ if (!real_cq) {
+ free(cq);
+ return NULL;
+ }
+
+ cq->context = context;
+ cq->cq_context = cq_context;
+ cq->cqe = cqe;
+ cq->real_cq = real_cq;
+
+ real_cq->cq_context = cq;
+
+ return cq;
+}
+symver(__ibv_create_cq_1_0, ibv_create_cq, IBVERBS_1.0);
+
+int __ibv_resize_cq_1_0(struct ibv_cq_1_0 *cq, int cqe)
+{
+ return ibv_resize_cq(cq->real_cq, cqe);
+}
+symver(__ibv_resize_cq_1_0, ibv_resize_cq, IBVERBS_1.0);
+
+int __ibv_destroy_cq_1_0(struct ibv_cq_1_0 *cq)
+{
+ int ret;
+
+ ret = ibv_destroy_cq(cq->real_cq);
+ if (ret)
+ return ret;
+
+ free(cq);
+ return 0;
+}
+symver(__ibv_destroy_cq_1_0, ibv_destroy_cq, IBVERBS_1.0);
+
+int __ibv_get_cq_event_1_0(struct ibv_comp_channel *channel,
+ struct ibv_cq_1_0 **cq, void **cq_context)
+{
+ struct ibv_cq *real_cq;
+ void *cq_ptr;
+ int ret;
+
+ ret = ibv_get_cq_event(channel, &real_cq, &cq_ptr);
+ if (ret)
+ return ret;
+
+ *cq = cq_ptr;
+ *cq_context = (*cq)->cq_context;
+
+ return 0;
+}
+symver(__ibv_get_cq_event_1_0, ibv_get_cq_event, IBVERBS_1.0);
+
+void __ibv_ack_cq_events_1_0(struct ibv_cq_1_0 *cq, unsigned int nevents)
+{
+ ibv_ack_cq_events(cq->real_cq, nevents);
+}
+symver(__ibv_ack_cq_events_1_0, ibv_ack_cq_events, IBVERBS_1.0);
+
+struct ibv_srq_1_0 *__ibv_create_srq_1_0(struct ibv_pd_1_0 *pd,
+ struct ibv_srq_init_attr *srq_init_attr)
+{
+ struct ibv_srq *real_srq;
+ struct ibv_srq_1_0 *srq;
+
+ srq = malloc(sizeof *srq);
+ if (!srq)
+ return NULL;
+
+ real_srq = ibv_create_srq(pd->real_pd, srq_init_attr);
+ if (!real_srq) {
+ free(srq);
+ return NULL;
+ }
+
+ srq->context = pd->context;
+ srq->srq_context = srq_init_attr->srq_context;
+ srq->pd = pd;
+ srq->real_srq = real_srq;
+
+ real_srq->srq_context = srq;
+
+ return srq;
+}
+symver(__ibv_create_srq_1_0, ibv_create_srq, IBVERBS_1.0);
+
+int __ibv_modify_srq_1_0(struct ibv_srq_1_0 *srq,
+ struct ibv_srq_attr *srq_attr,
+ int srq_attr_mask)
+{
+ return ibv_modify_srq(srq->real_srq, srq_attr, srq_attr_mask);
+}
+symver(__ibv_modify_srq_1_0, ibv_modify_srq, IBVERBS_1.0);
+
+int __ibv_query_srq_1_0(struct ibv_srq_1_0 *srq, struct ibv_srq_attr *srq_attr)
+{
+ return ibv_query_srq(srq->real_srq, srq_attr);
+}
+symver(__ibv_query_srq_1_0, ibv_query_srq, IBVERBS_1.0);
+
+int __ibv_destroy_srq_1_0(struct ibv_srq_1_0 *srq)
+{
+ int ret;
+
+ ret = ibv_destroy_srq(srq->real_srq);
+ if (ret)
+ return ret;
+
+ free(srq);
+ return 0;
+}
+symver(__ibv_destroy_srq_1_0, ibv_destroy_srq, IBVERBS_1.0);
+
+struct ibv_qp_1_0 *__ibv_create_qp_1_0(struct ibv_pd_1_0 *pd,
+ struct ibv_qp_init_attr_1_0 *qp_init_attr)
+{
+ struct ibv_qp *real_qp;
+ struct ibv_qp_1_0 *qp;
+ struct ibv_qp_init_attr real_init_attr;
+
+ qp = malloc(sizeof *qp);
+ if (!qp)
+ return NULL;
+
+ real_init_attr.qp_context = qp_init_attr->qp_context;
+ real_init_attr.send_cq = qp_init_attr->send_cq->real_cq;
+ real_init_attr.recv_cq = qp_init_attr->recv_cq->real_cq;
+ real_init_attr.srq = qp_init_attr->srq ?
+ qp_init_attr->srq->real_srq : NULL;
+ real_init_attr.cap = qp_init_attr->cap;
+ real_init_attr.qp_type = qp_init_attr->qp_type;
+ real_init_attr.sq_sig_all = qp_init_attr->sq_sig_all;
+
+ real_qp = ibv_create_qp(pd->real_pd, &real_init_attr);
+ if (!real_qp) {
+ free(qp);
+ return NULL;
+ }
+
+ qp->context = pd->context;
+ qp->qp_context = qp_init_attr->qp_context;
+ qp->pd = pd;
+ qp->send_cq = qp_init_attr->send_cq;
+ qp->recv_cq = qp_init_attr->recv_cq;
+ qp->srq = qp_init_attr->srq;
+ qp->qp_type = qp_init_attr->qp_type;
+ qp->qp_num = real_qp->qp_num;
+ qp->real_qp = real_qp;
+
+ qp_init_attr->cap = real_init_attr.cap;
+
+ real_qp->qp_context = qp;
+
+ return qp;
+}
+symver(__ibv_create_qp_1_0, ibv_create_qp, IBVERBS_1.0);
+
+int __ibv_query_qp_1_0(struct ibv_qp_1_0 *qp, struct ibv_qp_attr *attr,
+ int attr_mask,
+ struct ibv_qp_init_attr_1_0 *init_attr)
+{
+ struct ibv_qp_init_attr real_init_attr;
+ int ret;
+
+ ret = ibv_query_qp(qp->real_qp, attr, attr_mask, &real_init_attr);
+ if (ret)
+ return ret;
+
+ init_attr->qp_context = qp->qp_context;
+ init_attr->send_cq = real_init_attr.send_cq->cq_context;
+ init_attr->recv_cq = real_init_attr.recv_cq->cq_context;
+ init_attr->srq = real_init_attr.srq->srq_context;
+ init_attr->qp_type = real_init_attr.qp_type;
+ init_attr->cap = real_init_attr.cap;
+ init_attr->sq_sig_all = real_init_attr.sq_sig_all;
+
+ return 0;
+}
+symver(__ibv_query_qp_1_0, ibv_query_qp, IBVERBS_1.0);
+
+int __ibv_modify_qp_1_0(struct ibv_qp_1_0 *qp, struct ibv_qp_attr *attr,
+ int attr_mask)
+{
+ return ibv_modify_qp(qp->real_qp, attr, attr_mask);
+}
+symver(__ibv_modify_qp_1_0, ibv_modify_qp, IBVERBS_1.0);
+
+int __ibv_destroy_qp_1_0(struct ibv_qp_1_0 *qp)
+{
+ int ret;
+
+ ret = ibv_destroy_qp(qp->real_qp);
+ if (ret)
+ return ret;
+
+ free(qp);
+ return 0;
+}
+symver(__ibv_destroy_qp_1_0, ibv_destroy_qp, IBVERBS_1.0);
+
+struct ibv_ah_1_0 *__ibv_create_ah_1_0(struct ibv_pd_1_0 *pd,
+ struct ibv_ah_attr *attr)
+{
+ struct ibv_ah *real_ah;
+ struct ibv_ah_1_0 *ah;
+
+ ah = malloc(sizeof *ah);
+ if (!ah)
+ return NULL;
+
+ real_ah = ibv_create_ah(pd->real_pd, attr);
+ if (!real_ah) {
+ free(ah);
+ return NULL;
+ }
+
+ ah->context = pd->context;
+ ah->pd = pd;
+ ah->real_ah = real_ah;
+
+ return ah;
+}
+symver(__ibv_create_ah_1_0, ibv_create_ah, IBVERBS_1.0);
+
+int __ibv_destroy_ah_1_0(struct ibv_ah_1_0 *ah)
+{
+ int ret;
+
+ ret = ibv_destroy_ah(ah->real_ah);
+ if (ret)
+ return ret;
+
+ free(ah);
+ return 0;
+}
+symver(__ibv_destroy_ah_1_0, ibv_destroy_ah, IBVERBS_1.0);
+
+int __ibv_attach_mcast_1_0(struct ibv_qp_1_0 *qp, union ibv_gid *gid, uint16_t lid)
+{
+ return ibv_attach_mcast(qp->real_qp, gid, lid);
+}
+symver(__ibv_attach_mcast_1_0, ibv_attach_mcast, IBVERBS_1.0);
+
+int __ibv_detach_mcast_1_0(struct ibv_qp_1_0 *qp, union ibv_gid *gid, uint16_t lid)
+{
+ return ibv_detach_mcast(qp->real_qp, gid, lid);
+}
+symver(__ibv_detach_mcast_1_0, ibv_detach_mcast, IBVERBS_1.0);
+
+void __ibv_register_driver_1_1(const char *name, ibv_driver_init_func_1_1 init_func)
+{
+ /* The driver interface is private as of rdma-core 13. This stub is
+ * left to preserve dynamic-link compatibility with old libfabrics
+ * usnic providers which use this function only to suppress a fprintf
+ * in old versions of libibverbs. */
+}
+symver(__ibv_register_driver_1_1, ibv_register_driver, IBVERBS_1.1);
diff --git a/contrib/ofed/libibverbs/config.h b/contrib/ofed/libibverbs/config.h
new file mode 100644
index 0000000..88722ee
--- /dev/null
+++ b/contrib/ofed/libibverbs/config.h
@@ -0,0 +1,41 @@
+/* $FreeBSD$ */
+
+#include "alloca.h"
+
+#define memalign(align, size) ({ \
+ void *__ptr; \
+ if (posix_memalign(&__ptr, (align), (size))) \
+ __ptr = NULL; \
+ __ptr; \
+})
+
+/*
+ * Return true if the snprintf succeeded, false if there was
+ * truncation or error:
+ */
+#define check_snprintf(buf, len, fmt, ...) ({ \
+ int rc = snprintf(buf, len, fmt, ##__VA_ARGS__); \
+ (rc < len && rc >= 0); \
+})
+
+#define min_t(type, x, y) ({ \
+ type __min1 = (x); \
+ type __min2 = (y); \
+ __min1 < __min2 ? __min1 : __min2; })
+
+#define freeaddrinfo_null(x) do { \
+ if ((x) != NULL) \
+ freeaddrinfo(x); \
+} while (0)
+
+#define VALGRIND_MAKE_MEM_DEFINED(...) 0
+#define s6_addr32 __u6_addr.__u6_addr32
+#define __sum16 uint16_t
+#define NRESOLVE_NEIGH 1
+#define STREAM_CLOEXEC "e"
+#define VERBS_PROVIDER_DIR "/usr/lib/"
+#define IBV_CONFIG_DIR "/etc/ibverbs/"
+#define MADV_DONTFORK MADV_NORMAL
+#define MADV_DOFORK MADV_NORMAL
+#define SWITCH_FALLTHROUGH (void)0
+
diff --git a/contrib/ofed/libibverbs/configure.in b/contrib/ofed/libibverbs/configure.in
deleted file mode 100644
index d0678c8..0000000
--- a/contrib/ofed/libibverbs/configure.in
+++ /dev/null
@@ -1,77 +0,0 @@
-dnl Process this file with autoconf to produce a configure script.
-
-AC_PREREQ(2.57)
-AC_INIT(libibverbs, 1.1.4, general@lists.openfabrics.org)
-AC_CONFIG_SRCDIR([src/ibverbs.h])
-AC_CONFIG_AUX_DIR(config)
-AC_CONFIG_HEADER(config.h)
-AM_INIT_AUTOMAKE(libibverbs, 1.1.4)
-m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
-
-dnl Checks for programs
-AC_PROG_CC
-AC_GNU_SOURCE
-AC_PROG_LN_S
-
-AC_PROG_LIBTOOL
-LT_INIT
-
-AC_ARG_WITH([valgrind],
- AC_HELP_STRING([--with-valgrind],
- [Enable Valgrind annotations (small runtime overhead, default NO)]))
-if test x$with_valgrind = x || test x$with_valgrind = xno; then
- want_valgrind=no
- AC_DEFINE([NVALGRIND], 1, [Define to 1 to disable Valgrind annotations.])
-else
- want_valgrind=yes
- if test -d $with_valgrind; then
- CPPFLAGS="$CPPFLAGS -I$with_valgrind/include"
- fi
-fi
-
-dnl Checks for programs
-AC_PROG_CC
-AC_PROG_LN_S
-
-dnl Checks for libraries
-AC_CHECK_LIB(dl, dlsym, [],
- AC_MSG_ERROR([dlsym() not found. libibverbs requires libdl.]))
-AC_CHECK_LIB(pthread, pthread_mutex_init, [],
- AC_MSG_ERROR([pthread_mutex_init() not found. libibverbs requires libpthread.]))
-
-dnl Checks for header files.
-AC_HEADER_STDC
-AC_CHECK_HEADER(valgrind/memcheck.h,
- [AC_DEFINE(HAVE_VALGRIND_MEMCHECK_H, 1,
- [Define to 1 if you have the <valgrind/memcheck.h> header file.])],
- [if test $want_valgrind = yes; then
- AC_MSG_ERROR([Valgrind memcheck support requested, but <valgrind/memcheck.h> not found.])
- fi])
-
-dnl Checks for typedefs, structures, and compiler characteristics.
-AC_C_CONST
-
-AC_CACHE_CHECK(whether ld accepts --version-script, ac_cv_version_script,
- [if test -n "`$LD --help < /dev/null 2>/dev/null | grep version-script`"; then
- ac_cv_version_script=yes
- else
- ac_cv_version_script=no
- fi])
-
-if test $ac_cv_version_script = yes; then
- LIBIBVERBS_VERSION_SCRIPT='-Wl,--version-script=$(srcdir)/src/libibverbs.map'
-else
- LIBIBVERBS_VERSION_SCRIPT=
-fi
-AC_SUBST(LIBIBVERBS_VERSION_SCRIPT)
-
-AC_CACHE_CHECK(for .symver assembler support, ac_cv_asm_symver_support,
- [AC_TRY_COMPILE(, [asm("symbol:\n.symver symbol, api@ABI\n");],
- ac_cv_asm_symver_support=yes,
- ac_cv_asm_symver_support=no)])
-if test $ac_cv_asm_symver_support = yes; then
- AC_DEFINE([HAVE_SYMVER_SUPPORT], 1, [assembler has .symver support])
-fi
-
-AC_CONFIG_FILES([Makefile libibverbs.spec])
-AC_OUTPUT
diff --git a/contrib/ofed/libibverbs/debian/changelog b/contrib/ofed/libibverbs/debian/changelog
deleted file mode 100644
index 2278511..0000000
--- a/contrib/ofed/libibverbs/debian/changelog
+++ /dev/null
@@ -1,78 +0,0 @@
-libibverbs (1.1.2-1) unstable; urgency=low
-
- * New upstream release.
- - Fix memory registration failure cause by too-big madvise()
- - Fix many Valgrind false positives
- - Add functions to convert enum values to strings
- * Replace deprecated ${Source-Version} with ${binary:Version}
- * Use DEB_DH_MAKESHLIBS_ARGS_ALL to pass appropriate -V option to
- dh_makeshlibs, since new symbols were added in libibverbs 1.1.2.
- (Closes: #465435)
- * Add debian/watch file.
- * Update control file to talk about generic RDMA and iWARP, not just
- InfiniBand, since libibverbs works with both IB and iWARP.
- * Acknowledge NMU (Closes: #442638).
-
- -- Roland Dreier <rolandd@cisco.com> Fri, 18 Apr 2008 15:08:52 -0700
-
-libibverbs (1.1.1-1.1) unstable; urgency=low
-
- * Non-maintainer upload.
- * Re-generated autotools files to fix double build bug, closes: #442638
- * Bumped Standards-Version to 3.7.3, no change needed.
-
- -- Michael Meskes <meskes@debian.org> Mon, 14 Apr 2008 10:07:58 +0000
-
-libibverbs (1.1.1-1) unstable; urgency=low
-
- * New upstream release.
- - Initialize state of newly created QPs to RESET (fixes problems
- with libmlx4/ConnectX HCAs).
- - Don't warn root about RLIMIT_MEMLOCK, since it doesn't matter.
- - Fix free() errors in ibv_xx_pingpong examples.
-
- -- Roland Dreier <rolandd@cisco.com> Fri, 15 Jun 2007 12:49:02 -0700
-
-libibverbs (1.1-1) unstable; urgency=low
-
- * New upstream release.
- - Add support for use of fork() in applications.
- - Add manual pages documenting API in section 3.
- - New method of finding and loading device-specific drivers.
- - Add basic support for iWARP devices.
- - Provide compatible ABI for applications linked against libibverbs 1.0.
- * Update libtool during build to avoid setting RPATH in binaries on amd64.
-
- -- Roland Dreier <rolandd@cisco.com> Sat, 28 Apr 2007 14:15:29 -0700
-
-libibverbs (1.0.4-1) unstable; urgency=low
-
- * New upstream release.
- - Fix static linking so it has a chance of working.
- - Fix cut-and-paste error in sparc mb() macro.
- - Other miscellaneous fixes.
- * Improve package description.
-
- -- Roland Dreier <rolandd@cisco.com> Tue, 31 Oct 2006 15:04:33 -0800
-
-libibverbs (1.0.3-1) unstable; urgency=low
-
- * Change priority to extra, since libibverbs depends on libsysfs2, which
- has priority extra. (Debian policy section 2.5 states that a package
- may not depend on another package of lower priority)
- * New upstream release:
- - For sparc, only generate membar instruction if compiling for V9
- instruction set. (Closes: #365559)
- - Reduce (but not yet eliminate) dependency on libsysfs.
- - Deprecate some ib_XXX symbol names and introduce ibv_XXX
- replacements for internal consistency.
- - Other minor fixes.
- * Update to Standards-Version: 3.7.2.
-
- -- Roland Dreier <rolandd@cisco.com> Tue, 2 May 2006 15:33:14 -0700
-
-libibverbs (1.0.2-1) unstable; urgency=low
-
- * Initial Release. (Closes: #325752)
-
- -- Roland Dreier <rolandd@cisco.com> Wed, 15 Feb 2006 11:21:59 -0700
diff --git a/contrib/ofed/libibverbs/debian/compat b/contrib/ofed/libibverbs/debian/compat
deleted file mode 100644
index 7ed6ff8..0000000
--- a/contrib/ofed/libibverbs/debian/compat
+++ /dev/null
@@ -1 +0,0 @@
-5
diff --git a/contrib/ofed/libibverbs/debian/control.in b/contrib/ofed/libibverbs/debian/control.in
deleted file mode 100644
index d86c0b3..0000000
--- a/contrib/ofed/libibverbs/debian/control.in
+++ /dev/null
@@ -1,80 +0,0 @@
-Source: libibverbs
-Priority: extra
-Maintainer: Roland Dreier <rolandd@cisco.com>
-Build-Depends: @cdbs@, dpkg-dev (>= 1.13.19)
-Standards-Version: 3.7.3
-Section: libs
-Homepage: http://www.openfabrics.org/
-
-Package: libibverbs1
-Section: libs
-Architecture: any
-Depends: ${shlibs:Depends}, ${misc:Depends}, adduser
-Description: A library for direct userspace use of RDMA (InfiniBand/iWARP)
- libibverbs is a library that allows userspace processes to use RDMA
- "verbs" as described in the InfiniBand Architecture Specification and
- the RDMA Protocol Verbs Specification. iWARP ethernet NICs support
- RDMA over hardware-offloaded TCP/IP, while InfiniBand is a
- high-throughput, low-latency networking technology. InfiniBand host
- channel adapters (HCAs) and iWARP NICs commonly support direct
- hardware access from userspace (kernel bypass), and libibverbs
- supports this when available.
- .
- For this library to be useful, a device-specific plug-in module
- should also be installed.
- .
- This package contains the shared library.
-
-Package: libibverbs-dev
-Section: libdevel
-Architecture: any
-Depends: ${misc:Depends}, libibverbs1 (= ${binary:Version})
-Description: Development files for the libibverbs library
- libibverbs is a library that allows userspace processes to use RDMA
- "verbs" as described in the InfiniBand Architecture Specification and
- the RDMA Protocol Verbs Specification. iWARP ethernet NICs support
- RDMA over hardware-offloaded TCP/IP, while InfiniBand is a
- high-throughput, low-latency networking technology. InfiniBand host
- channel adapters (HCAs) and iWARP NICs commonly support direct
- hardware access from userspace (kernel bypass), and libibverbs
- supports this when available.
- .
- This package is needed to compile programs against libibverbs1.
- It contains the header files and static libraries (optionally)
- needed for compiling.
-
-Package: libibverbs1-dbg
-Section: libdevel
-Priority: extra
-Architecture: any
-Depends: ${misc:Depends}, libibverbs1 (= ${binary:Version})
-Description: Debugging symbols for the libibverbs library
- libibverbs is a library that allows userspace processes to use RDMA
- "verbs" as described in the InfiniBand Architecture Specification and
- the RDMA Protocol Verbs Specification. iWARP ethernet NICs support
- RDMA over hardware-offloaded TCP/IP, while InfiniBand is a
- high-throughput, low-latency networking technology. InfiniBand host
- channel adapters (HCAs) and iWARP NICs commonly support direct
- hardware access from userspace (kernel bypass), and libibverbs
- supports this when available.
- .
- This package contains the debugging symbols associated with
- libibverbs1. They will automatically be used by gdb for debugging
- libibverbs-related issues.
-
-Package: ibverbs-utils
-Section: net
-Architecture: any
-Depends: ${shlibs:Depends}, ${misc:Depends}
-Description: Examples for the libibverbs library
- libibverbs is a library that allows userspace processes to use RDMA
- "verbs" as described in the InfiniBand Architecture Specification and
- the RDMA Protocol Verbs Specification. iWARP ethernet NICs support
- RDMA over hardware-offloaded TCP/IP, while InfiniBand is a
- high-throughput, low-latency networking technology. InfiniBand host
- channel adapters (HCAs) and iWARP NICs commonly support direct
- hardware access from userspace (kernel bypass), and libibverbs
- supports this when available.
- .
- This package contains useful libibverbs1 example programs such as
- ibv_devinfo, which displays information about InfiniBand devices.
diff --git a/contrib/ofed/libibverbs/debian/copyright b/contrib/ofed/libibverbs/debian/copyright
deleted file mode 100644
index 58a8e6c..0000000
--- a/contrib/ofed/libibverbs/debian/copyright
+++ /dev/null
@@ -1,49 +0,0 @@
-Initial Debianization:
-This package was debianized by Roland Dreier <rolandd@cisco.com> on
-Mon, 25 Apr 2005 10:21:08 -0700.
-
-Source:
-It was downloaded from the OpenIB web site at
-<https://openib.org/downloads.html>
-
-Authors:
- Roland Dreier <roland@topspin.com>
- Dotan Barak <dotanb@mellanox.co.il>
- Sean Hefty <sean.hefty@intel.com>
- Michael S. Tsirkin <mst@mellanox.co.il>
-
-Portions are copyrighted by:
- * Copyright (c) 2005, 2006 Cisco Systems. All rights reserved.
- * Copyright (c) 2004, 2005 Intel Corporation. All rights reserved.
- * Copyright (c) 2005 Mellanox Technologies Ltd. All rights reserved.
- * Copyright (c) 2005 PathScale, Inc. All rights reserved.
- * Copyright (c) 2004, 2005 Topspin Communications. All rights reserved.
- * Copyright (c) 2005 Voltaire, Inc. All rights reserved.
-
-libibverbs is licensed under a choice of one of two licenses. You may
-choose to be licensed under the terms of the GNU General Public
-License (GPL) Version 2, available from the file
-/usr/share/common-licenses/GPL-2 on your Debian system, or the
-OpenIB.org BSD license below:
-
- Redistribution and use in source and binary forms, with or
- without modification, are permitted provided that the following
- conditions are met:
-
- - Redistributions of source code must retain the above
- copyright notice, this list of conditions and the following
- disclaimer.
-
- - Redistributions in binary form must reproduce the above
- copyright notice, this list of conditions and the following
- disclaimer in the documentation and/or other materials
- provided with the distribution.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
-BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
-ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
-CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-SOFTWARE.
diff --git a/contrib/ofed/libibverbs/debian/ibverbs-utils.install b/contrib/ofed/libibverbs/debian/ibverbs-utils.install
deleted file mode 100644
index 98d1583..0000000
--- a/contrib/ofed/libibverbs/debian/ibverbs-utils.install
+++ /dev/null
@@ -1,2 +0,0 @@
-usr/bin
-usr/share/man/man1
diff --git a/contrib/ofed/libibverbs/debian/libibverbs-dev.install b/contrib/ofed/libibverbs/debian/libibverbs-dev.install
deleted file mode 100644
index d4b7db7..0000000
--- a/contrib/ofed/libibverbs/debian/libibverbs-dev.install
+++ /dev/null
@@ -1,3 +0,0 @@
-usr/include
-usr/lib/libibverbs*.{a,la,so}
-usr/share/man/man3
diff --git a/contrib/ofed/libibverbs/debian/libibverbs-dev.links b/contrib/ofed/libibverbs/debian/libibverbs-dev.links
deleted file mode 100644
index 7029028..0000000
--- a/contrib/ofed/libibverbs/debian/libibverbs-dev.links
+++ /dev/null
@@ -1,16 +0,0 @@
-usr/share/man/man3/ibv_get_async_event.3 usr/share/man/man3/ibv_ack_async_event.3
-usr/share/man/man3/ibv_get_cq_event.3 usr/share/man/man3/ibv_ack_cq_events.3
-usr/share/man/man3/ibv_open_device.3 usr/share/man/man3/ibv_close_device.3
-usr/share/man/man3/ibv_alloc_pd.3 usr/share/man/man3/ibv_dealloc_pd.3
-usr/share/man/man3/ibv_reg_mr.3 usr/share/man/man3/ibv_dereg_mr.3
-usr/share/man/man3/ibv_create_ah.3 usr/share/man/man3/ibv_destroy_ah.3
-usr/share/man/man3/ibv_create_comp_channel.3 usr/share/man/man3/ibv_destroy_comp_channel.3
-usr/share/man/man3/ibv_create_cq.3 usr/share/man/man3/ibv_destroy_cq.3
-usr/share/man/man3/ibv_create_qp.3 usr/share/man/man3/ibv_destroy_qp.3
-usr/share/man/man3/ibv_create_srq.3 usr/share/man/man3/ibv_destroy_srq.3
-usr/share/man/man3/ibv_attach_mcast.3 usr/share/man/man3/ibv_detach_mcast.3
-usr/share/man/man3/ibv_get_device_list.3 usr/share/man/man3/ibv_free_device_list.3
-usr/share/man/man3/ibv_create_ah_from_wc.3 usr/share/man/man3/ibv_init_ah_from_wc.3
-usr/share/man/man3/ibv_rate_to_mult.3 usr/share/man/man3/mult_to_ibv_rate.3
-usr/share/man/man3/ibv_event_type_str.3 usr/share/man/man3/ibv_node_type_str.3
-usr/share/man/man3/ibv_event_type_str.3 usr/share/man/man3/ibv_port_state_str.3
diff --git a/contrib/ofed/libibverbs/debian/libibverbs1.install b/contrib/ofed/libibverbs/debian/libibverbs1.install
deleted file mode 100644
index 0f3523d..0000000
--- a/contrib/ofed/libibverbs/debian/libibverbs1.install
+++ /dev/null
@@ -1 +0,0 @@
-usr/lib/libibverbs*.so.*
diff --git a/contrib/ofed/libibverbs/debian/libibverbs1.postinst b/contrib/ofed/libibverbs/debian/libibverbs1.postinst
deleted file mode 100644
index f7d2ee6..0000000
--- a/contrib/ofed/libibverbs/debian/libibverbs1.postinst
+++ /dev/null
@@ -1,12 +0,0 @@
-#!/bin/sh
-# postinst script for libibverbs1
-
-set -e
-
-if [ "$1" != configure ]; then
- exit 0
-fi
-
-getent group rdma > /dev/null 2>&1 || addgroup --system --quiet rdma
-
-#DEBHELPER#
diff --git a/contrib/ofed/libibverbs/debian/rules b/contrib/ofed/libibverbs/debian/rules
deleted file mode 100755
index 5b40388..0000000
--- a/contrib/ofed/libibverbs/debian/rules
+++ /dev/null
@@ -1,9 +0,0 @@
-#!/usr/bin/make -f
-# -*- mode: makefile; coding: utf-8 -*-
-
-DEB_DH_INSTALL_SOURCEDIR := debian/tmp
-DEB_AUTO_UPDATE_LIBTOOL := post
-DEB_DH_MAKESHLIBS_ARGS_ALL := -V 'libibverbs1 (>= 1.1.2)'
-
-include /usr/share/cdbs/1/rules/debhelper.mk
-include /usr/share/cdbs/1/class/autotools.mk
diff --git a/contrib/ofed/libibverbs/debian/watch b/contrib/ofed/libibverbs/debian/watch
deleted file mode 100644
index eff271a..0000000
--- a/contrib/ofed/libibverbs/debian/watch
+++ /dev/null
@@ -1,3 +0,0 @@
-version=3
-opts="uversionmangle=s/-rc/~rc/" \
- http://www.openfabrics.org/downloads/verbs/libibverbs-(.+)\.tar\.gz
diff --git a/contrib/ofed/libibverbs/device.c b/contrib/ofed/libibverbs/device.c
new file mode 100644
index 0000000..8b52dd5
--- /dev/null
+++ b/contrib/ofed/libibverbs/device.c
@@ -0,0 +1,398 @@
+/*
+ * Copyright (c) 2004, 2005 Topspin Communications. All rights reserved.
+ * Copyright (c) 2006, 2007 Cisco Systems, Inc. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+#define _GNU_SOURCE
+#include <config.h>
+
+#include <infiniband/endian.h>
+#include <stdio.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <stdlib.h>
+#include <alloca.h>
+#include <errno.h>
+
+#include "ibverbs.h"
+
+/* Hack to avoid GCC's -Wmissing-prototypes and the similar error from sparse
+ with these prototypes. Symbol versionining requires the goofy names, the
+ prototype must match the version in verbs.h.
+ */
+struct ibv_device **__ibv_get_device_list(int *num_devices);
+void __ibv_free_device_list(struct ibv_device **list);
+const char *__ibv_get_device_name(struct ibv_device *device);
+__be64 __ibv_get_device_guid(struct ibv_device *device);
+struct ibv_context *__ibv_open_device(struct ibv_device *device);
+int __ibv_close_device(struct ibv_context *context);
+int __ibv_get_async_event(struct ibv_context *context,
+ struct ibv_async_event *event);
+void __ibv_ack_async_event(struct ibv_async_event *event);
+
+static pthread_once_t device_list_once = PTHREAD_ONCE_INIT;
+static int num_devices;
+static struct ibv_device **device_list;
+
+static void count_devices(void)
+{
+ num_devices = ibverbs_init(&device_list);
+}
+
+struct ibv_device **__ibv_get_device_list(int *num)
+{
+ struct ibv_device **l;
+ int i;
+
+ if (num)
+ *num = 0;
+
+ pthread_once(&device_list_once, count_devices);
+
+ if (num_devices < 0) {
+ errno = -num_devices;
+ return NULL;
+ }
+
+ l = calloc(num_devices + 1, sizeof (struct ibv_device *));
+ if (!l) {
+ errno = ENOMEM;
+ return NULL;
+ }
+
+ for (i = 0; i < num_devices; ++i)
+ l[i] = device_list[i];
+ if (num)
+ *num = num_devices;
+
+ return l;
+}
+default_symver(__ibv_get_device_list, ibv_get_device_list);
+
+void __ibv_free_device_list(struct ibv_device **list)
+{
+ free(list);
+}
+default_symver(__ibv_free_device_list, ibv_free_device_list);
+
+const char *__ibv_get_device_name(struct ibv_device *device)
+{
+ return device->name;
+}
+default_symver(__ibv_get_device_name, ibv_get_device_name);
+
+__be64 __ibv_get_device_guid(struct ibv_device *device)
+{
+ char attr[24];
+ uint64_t guid = 0;
+ uint16_t parts[4];
+ int i;
+
+ if (ibv_read_sysfs_file(device->ibdev_path, "node_guid",
+ attr, sizeof attr) < 0)
+ return 0;
+
+ if (sscanf(attr, "%hx:%hx:%hx:%hx",
+ parts, parts + 1, parts + 2, parts + 3) != 4)
+ return 0;
+
+ for (i = 0; i < 4; ++i)
+ guid = (guid << 16) | parts[i];
+
+ return htobe64(guid);
+}
+default_symver(__ibv_get_device_guid, ibv_get_device_guid);
+
+void verbs_init_cq(struct ibv_cq *cq, struct ibv_context *context,
+ struct ibv_comp_channel *channel,
+ void *cq_context)
+{
+ cq->context = context;
+ cq->channel = channel;
+
+ if (cq->channel) {
+ pthread_mutex_lock(&context->mutex);
+ ++cq->channel->refcnt;
+ pthread_mutex_unlock(&context->mutex);
+ }
+
+ cq->cq_context = cq_context;
+ cq->comp_events_completed = 0;
+ cq->async_events_completed = 0;
+ pthread_mutex_init(&cq->mutex, NULL);
+ pthread_cond_init(&cq->cond, NULL);
+}
+
+static struct ibv_cq_ex *
+__lib_ibv_create_cq_ex(struct ibv_context *context,
+ struct ibv_cq_init_attr_ex *cq_attr)
+{
+ struct verbs_context *vctx = verbs_get_ctx(context);
+ struct ibv_cq_ex *cq;
+
+ if (cq_attr->wc_flags & ~IBV_CREATE_CQ_SUP_WC_FLAGS) {
+ errno = EOPNOTSUPP;
+ return NULL;
+ }
+
+ cq = vctx->priv->create_cq_ex(context, cq_attr);
+
+ if (cq)
+ verbs_init_cq(ibv_cq_ex_to_cq(cq), context,
+ cq_attr->channel, cq_attr->cq_context);
+
+ return cq;
+}
+
+struct ibv_context *__ibv_open_device(struct ibv_device *device)
+{
+ struct verbs_device *verbs_device = verbs_get_device(device);
+ char *devpath;
+ int cmd_fd, ret;
+ struct ibv_context *context;
+ struct verbs_context *context_ex;
+
+ if (asprintf(&devpath, "/dev/%s", device->dev_name) < 0)
+ return NULL;
+
+ /*
+ * We'll only be doing writes, but we need O_RDWR in case the
+ * provider needs to mmap() the file.
+ */
+ cmd_fd = open(devpath, O_RDWR | O_CLOEXEC);
+ free(devpath);
+
+ if (cmd_fd < 0)
+ return NULL;
+
+ if (!verbs_device->ops->init_context) {
+ context = verbs_device->ops->alloc_context(device, cmd_fd);
+ if (!context)
+ goto err;
+ } else {
+ struct verbs_ex_private *priv;
+
+ /* Library now allocates the context */
+ context_ex = calloc(1, sizeof(*context_ex) +
+ verbs_device->size_of_context);
+ if (!context_ex) {
+ errno = ENOMEM;
+ goto err;
+ }
+
+ priv = calloc(1, sizeof(*priv));
+ if (!priv) {
+ errno = ENOMEM;
+ free(context_ex);
+ goto err;
+ }
+
+ context_ex->priv = priv;
+ context_ex->context.abi_compat = __VERBS_ABI_IS_EXTENDED;
+ context_ex->sz = sizeof(*context_ex);
+
+ context = &context_ex->context;
+ ret = verbs_device->ops->init_context(verbs_device, context, cmd_fd);
+ if (ret)
+ goto verbs_err;
+ /*
+ * In order to maintain backward/forward binary compatibility
+ * with apps compiled against libibverbs-1.1.8 that use the
+ * flow steering addition, we need to set the two
+ * ABI_placeholder entries to match the driver set flow
+ * entries. This is because apps compiled against
+ * libibverbs-1.1.8 use an inline ibv_create_flow and
+ * ibv_destroy_flow function that looks in the placeholder
+ * spots for the proper entry points. For apps compiled
+ * against libibverbs-1.1.9 and later, the inline functions
+ * will be looking in the right place.
+ */
+ context_ex->ABI_placeholder1 = (void (*)(void)) context_ex->ibv_create_flow;
+ context_ex->ABI_placeholder2 = (void (*)(void)) context_ex->ibv_destroy_flow;
+
+ if (context_ex->create_cq_ex) {
+ priv->create_cq_ex = context_ex->create_cq_ex;
+ context_ex->create_cq_ex = __lib_ibv_create_cq_ex;
+ }
+ }
+
+ context->device = device;
+ context->cmd_fd = cmd_fd;
+ pthread_mutex_init(&context->mutex, NULL);
+
+ return context;
+
+verbs_err:
+ free(context_ex->priv);
+ free(context_ex);
+err:
+ close(cmd_fd);
+ return NULL;
+}
+default_symver(__ibv_open_device, ibv_open_device);
+
+int __ibv_close_device(struct ibv_context *context)
+{
+ int async_fd = context->async_fd;
+ int cmd_fd = context->cmd_fd;
+ int cq_fd = -1;
+ struct verbs_context *context_ex;
+ struct verbs_device *verbs_device = verbs_get_device(context->device);
+
+ context_ex = verbs_get_ctx(context);
+ if (context_ex) {
+ verbs_device->ops->uninit_context(verbs_device, context);
+ free(context_ex->priv);
+ free(context_ex);
+ } else {
+ verbs_device->ops->free_context(context);
+ }
+
+ close(async_fd);
+ close(cmd_fd);
+ if (abi_ver <= 2)
+ close(cq_fd);
+
+ return 0;
+}
+default_symver(__ibv_close_device, ibv_close_device);
+
+int __ibv_get_async_event(struct ibv_context *context,
+ struct ibv_async_event *event)
+{
+ struct ibv_kern_async_event ev;
+
+ if (read(context->async_fd, &ev, sizeof ev) != sizeof ev)
+ return -1;
+
+ event->event_type = ev.event_type;
+
+ switch (event->event_type) {
+ case IBV_EVENT_CQ_ERR:
+ event->element.cq = (void *) (uintptr_t) ev.element;
+ break;
+
+ case IBV_EVENT_QP_FATAL:
+ case IBV_EVENT_QP_REQ_ERR:
+ case IBV_EVENT_QP_ACCESS_ERR:
+ case IBV_EVENT_COMM_EST:
+ case IBV_EVENT_SQ_DRAINED:
+ case IBV_EVENT_PATH_MIG:
+ case IBV_EVENT_PATH_MIG_ERR:
+ case IBV_EVENT_QP_LAST_WQE_REACHED:
+ event->element.qp = (void *) (uintptr_t) ev.element;
+ break;
+
+ case IBV_EVENT_SRQ_ERR:
+ case IBV_EVENT_SRQ_LIMIT_REACHED:
+ event->element.srq = (void *) (uintptr_t) ev.element;
+ break;
+
+ case IBV_EVENT_WQ_FATAL:
+ event->element.wq = (void *) (uintptr_t) ev.element;
+ break;
+ default:
+ event->element.port_num = ev.element;
+ break;
+ }
+
+ if (context->ops.async_event)
+ context->ops.async_event(event);
+
+ return 0;
+}
+default_symver(__ibv_get_async_event, ibv_get_async_event);
+
+void __ibv_ack_async_event(struct ibv_async_event *event)
+{
+ switch (event->event_type) {
+ case IBV_EVENT_CQ_ERR:
+ {
+ struct ibv_cq *cq = event->element.cq;
+
+ pthread_mutex_lock(&cq->mutex);
+ ++cq->async_events_completed;
+ pthread_cond_signal(&cq->cond);
+ pthread_mutex_unlock(&cq->mutex);
+
+ return;
+ }
+
+ case IBV_EVENT_QP_FATAL:
+ case IBV_EVENT_QP_REQ_ERR:
+ case IBV_EVENT_QP_ACCESS_ERR:
+ case IBV_EVENT_COMM_EST:
+ case IBV_EVENT_SQ_DRAINED:
+ case IBV_EVENT_PATH_MIG:
+ case IBV_EVENT_PATH_MIG_ERR:
+ case IBV_EVENT_QP_LAST_WQE_REACHED:
+ {
+ struct ibv_qp *qp = event->element.qp;
+
+ pthread_mutex_lock(&qp->mutex);
+ ++qp->events_completed;
+ pthread_cond_signal(&qp->cond);
+ pthread_mutex_unlock(&qp->mutex);
+
+ return;
+ }
+
+ case IBV_EVENT_SRQ_ERR:
+ case IBV_EVENT_SRQ_LIMIT_REACHED:
+ {
+ struct ibv_srq *srq = event->element.srq;
+
+ pthread_mutex_lock(&srq->mutex);
+ ++srq->events_completed;
+ pthread_cond_signal(&srq->cond);
+ pthread_mutex_unlock(&srq->mutex);
+
+ return;
+ }
+
+ case IBV_EVENT_WQ_FATAL:
+ {
+ struct ibv_wq *wq = event->element.wq;
+
+ pthread_mutex_lock(&wq->mutex);
+ ++wq->events_completed;
+ pthread_cond_signal(&wq->cond);
+ pthread_mutex_unlock(&wq->mutex);
+
+ return;
+ }
+
+ default:
+ return;
+ }
+}
+default_symver(__ibv_ack_async_event, ibv_ack_async_event);
diff --git a/contrib/ofed/libibverbs/driver.h b/contrib/ofed/libibverbs/driver.h
new file mode 100644
index 0000000..ec87afd
--- /dev/null
+++ b/contrib/ofed/libibverbs/driver.h
@@ -0,0 +1,325 @@
+/*
+ * Copyright (c) 2004, 2005 Topspin Communications. All rights reserved.
+ * Copyright (c) 2005, 2006 Cisco Systems, Inc. All rights reserved.
+ * Copyright (c) 2005 PathScale, Inc. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#ifndef INFINIBAND_DRIVER_H
+#define INFINIBAND_DRIVER_H
+
+#include <infiniband/verbs.h>
+#include <infiniband/kern-abi.h>
+
+#ifdef __cplusplus
+# define BEGIN_C_DECLS extern "C" {
+# define END_C_DECLS }
+#else /* !__cplusplus */
+# define BEGIN_C_DECLS
+# define END_C_DECLS
+#endif /* __cplusplus */
+
+/*
+ * Extension that low-level drivers should add to their .so filename
+ * (probably via libtool "-release" option). For example a low-level
+ * driver named "libfoo" should build a plug-in named "libfoo-rdmav2.so".
+ */
+#define IBV_DEVICE_LIBRARY_EXTENSION rdmav2
+
+struct verbs_device;
+
+enum verbs_xrcd_mask {
+ VERBS_XRCD_HANDLE = 1 << 0,
+ VERBS_XRCD_RESERVED = 1 << 1
+};
+
+struct verbs_xrcd {
+ struct ibv_xrcd xrcd;
+ uint32_t comp_mask;
+ uint32_t handle;
+};
+
+enum verbs_srq_mask {
+ VERBS_SRQ_TYPE = 1 << 0,
+ VERBS_SRQ_XRCD = 1 << 1,
+ VERBS_SRQ_CQ = 1 << 2,
+ VERBS_SRQ_NUM = 1 << 3,
+ VERBS_SRQ_RESERVED = 1 << 4
+};
+
+struct verbs_srq {
+ struct ibv_srq srq;
+ uint32_t comp_mask;
+ enum ibv_srq_type srq_type;
+ struct verbs_xrcd *xrcd;
+ struct ibv_cq *cq;
+ uint32_t srq_num;
+};
+
+enum verbs_qp_mask {
+ VERBS_QP_XRCD = 1 << 0,
+ VERBS_QP_RESERVED = 1 << 1
+};
+
+enum ibv_gid_type {
+ IBV_GID_TYPE_IB_ROCE_V1,
+ IBV_GID_TYPE_ROCE_V2,
+};
+
+struct verbs_qp {
+ struct ibv_qp qp;
+ uint32_t comp_mask;
+ struct verbs_xrcd *xrcd;
+};
+
+/* Must change the PRIVATE IBVERBS_PRIVATE_ symbol if this is changed */
+struct verbs_device_ops {
+ /* Old interface, do not use in new code. */
+ struct ibv_context *(*alloc_context)(struct ibv_device *device,
+ int cmd_fd);
+ void (*free_context)(struct ibv_context *context);
+
+ /* New interface */
+ int (*init_context)(struct verbs_device *device,
+ struct ibv_context *ctx, int cmd_fd);
+ void (*uninit_context)(struct verbs_device *device,
+ struct ibv_context *ctx);
+};
+
+/* Must change the PRIVATE IBVERBS_PRIVATE_ symbol if this is changed */
+struct verbs_device {
+ struct ibv_device device; /* Must be first */
+ const struct verbs_device_ops *ops;
+ size_t sz;
+ size_t size_of_context;
+};
+
+static inline struct verbs_device *
+verbs_get_device(const struct ibv_device *dev)
+{
+ return container_of(dev, struct verbs_device, device);
+}
+
+typedef struct verbs_device *(*verbs_driver_init_func)(const char *uverbs_sys_path,
+ int abi_version);
+void verbs_register_driver(const char *name, verbs_driver_init_func init_func);
+void verbs_init_cq(struct ibv_cq *cq, struct ibv_context *context,
+ struct ibv_comp_channel *channel,
+ void *cq_context);
+
+int ibv_cmd_get_context(struct ibv_context *context, struct ibv_get_context *cmd,
+ size_t cmd_size, struct ibv_get_context_resp *resp,
+ size_t resp_size);
+int ibv_cmd_query_device(struct ibv_context *context,
+ struct ibv_device_attr *device_attr,
+ uint64_t *raw_fw_ver,
+ struct ibv_query_device *cmd, size_t cmd_size);
+int ibv_cmd_query_device_ex(struct ibv_context *context,
+ const struct ibv_query_device_ex_input *input,
+ struct ibv_device_attr_ex *attr, size_t attr_size,
+ uint64_t *raw_fw_ver,
+ struct ibv_query_device_ex *cmd,
+ size_t cmd_core_size,
+ size_t cmd_size,
+ struct ibv_query_device_resp_ex *resp,
+ size_t resp_core_size,
+ size_t resp_size);
+int ibv_cmd_query_port(struct ibv_context *context, uint8_t port_num,
+ struct ibv_port_attr *port_attr,
+ struct ibv_query_port *cmd, size_t cmd_size);
+int ibv_cmd_alloc_pd(struct ibv_context *context, struct ibv_pd *pd,
+ struct ibv_alloc_pd *cmd, size_t cmd_size,
+ struct ibv_alloc_pd_resp *resp, size_t resp_size);
+int ibv_cmd_dealloc_pd(struct ibv_pd *pd);
+int ibv_cmd_open_xrcd(struct ibv_context *context, struct verbs_xrcd *xrcd,
+ int vxrcd_size,
+ struct ibv_xrcd_init_attr *attr,
+ struct ibv_open_xrcd *cmd, size_t cmd_size,
+ struct ibv_open_xrcd_resp *resp, size_t resp_size);
+int ibv_cmd_close_xrcd(struct verbs_xrcd *xrcd);
+#define IBV_CMD_REG_MR_HAS_RESP_PARAMS
+int ibv_cmd_reg_mr(struct ibv_pd *pd, void *addr, size_t length,
+ uint64_t hca_va, int access,
+ struct ibv_mr *mr, struct ibv_reg_mr *cmd,
+ size_t cmd_size,
+ struct ibv_reg_mr_resp *resp, size_t resp_size);
+int ibv_cmd_rereg_mr(struct ibv_mr *mr, uint32_t flags, void *addr,
+ size_t length, uint64_t hca_va, int access,
+ struct ibv_pd *pd, struct ibv_rereg_mr *cmd,
+ size_t cmd_sz, struct ibv_rereg_mr_resp *resp,
+ size_t resp_sz);
+int ibv_cmd_dereg_mr(struct ibv_mr *mr);
+int ibv_cmd_alloc_mw(struct ibv_pd *pd, enum ibv_mw_type type,
+ struct ibv_mw *mw, struct ibv_alloc_mw *cmd,
+ size_t cmd_size,
+ struct ibv_alloc_mw_resp *resp, size_t resp_size);
+int ibv_cmd_dealloc_mw(struct ibv_mw *mw,
+ struct ibv_dealloc_mw *cmd, size_t cmd_size);
+int ibv_cmd_create_cq(struct ibv_context *context, int cqe,
+ struct ibv_comp_channel *channel,
+ int comp_vector, struct ibv_cq *cq,
+ struct ibv_create_cq *cmd, size_t cmd_size,
+ struct ibv_create_cq_resp *resp, size_t resp_size);
+int ibv_cmd_create_cq_ex(struct ibv_context *context,
+ struct ibv_cq_init_attr_ex *cq_attr,
+ struct ibv_cq_ex *cq,
+ struct ibv_create_cq_ex *cmd,
+ size_t cmd_core_size,
+ size_t cmd_size,
+ struct ibv_create_cq_resp_ex *resp,
+ size_t resp_core_size,
+ size_t resp_size);
+int ibv_cmd_poll_cq(struct ibv_cq *cq, int ne, struct ibv_wc *wc);
+int ibv_cmd_req_notify_cq(struct ibv_cq *cq, int solicited_only);
+#define IBV_CMD_RESIZE_CQ_HAS_RESP_PARAMS
+int ibv_cmd_resize_cq(struct ibv_cq *cq, int cqe,
+ struct ibv_resize_cq *cmd, size_t cmd_size,
+ struct ibv_resize_cq_resp *resp, size_t resp_size);
+int ibv_cmd_destroy_cq(struct ibv_cq *cq);
+
+int ibv_cmd_create_srq(struct ibv_pd *pd,
+ struct ibv_srq *srq, struct ibv_srq_init_attr *attr,
+ struct ibv_create_srq *cmd, size_t cmd_size,
+ struct ibv_create_srq_resp *resp, size_t resp_size);
+int ibv_cmd_create_srq_ex(struct ibv_context *context,
+ struct verbs_srq *srq, int vsrq_sz,
+ struct ibv_srq_init_attr_ex *attr_ex,
+ struct ibv_create_xsrq *cmd, size_t cmd_size,
+ struct ibv_create_srq_resp *resp, size_t resp_size);
+int ibv_cmd_modify_srq(struct ibv_srq *srq,
+ struct ibv_srq_attr *srq_attr,
+ int srq_attr_mask,
+ struct ibv_modify_srq *cmd, size_t cmd_size);
+int ibv_cmd_query_srq(struct ibv_srq *srq,
+ struct ibv_srq_attr *srq_attr,
+ struct ibv_query_srq *cmd, size_t cmd_size);
+int ibv_cmd_destroy_srq(struct ibv_srq *srq);
+
+int ibv_cmd_create_qp(struct ibv_pd *pd,
+ struct ibv_qp *qp, struct ibv_qp_init_attr *attr,
+ struct ibv_create_qp *cmd, size_t cmd_size,
+ struct ibv_create_qp_resp *resp, size_t resp_size);
+int ibv_cmd_create_qp_ex(struct ibv_context *context,
+ struct verbs_qp *qp, int vqp_sz,
+ struct ibv_qp_init_attr_ex *attr_ex,
+ struct ibv_create_qp *cmd, size_t cmd_size,
+ struct ibv_create_qp_resp *resp, size_t resp_size);
+int ibv_cmd_create_qp_ex2(struct ibv_context *context,
+ struct verbs_qp *qp, int vqp_sz,
+ struct ibv_qp_init_attr_ex *qp_attr,
+ struct ibv_create_qp_ex *cmd,
+ size_t cmd_core_size,
+ size_t cmd_size,
+ struct ibv_create_qp_resp_ex *resp,
+ size_t resp_core_size,
+ size_t resp_size);
+int ibv_cmd_open_qp(struct ibv_context *context,
+ struct verbs_qp *qp, int vqp_sz,
+ struct ibv_qp_open_attr *attr,
+ struct ibv_open_qp *cmd, size_t cmd_size,
+ struct ibv_create_qp_resp *resp, size_t resp_size);
+int ibv_cmd_query_qp(struct ibv_qp *qp, struct ibv_qp_attr *qp_attr,
+ int attr_mask,
+ struct ibv_qp_init_attr *qp_init_attr,
+ struct ibv_query_qp *cmd, size_t cmd_size);
+int ibv_cmd_modify_qp(struct ibv_qp *qp, struct ibv_qp_attr *attr,
+ int attr_mask,
+ struct ibv_modify_qp *cmd, size_t cmd_size);
+int ibv_cmd_modify_qp_ex(struct ibv_qp *qp, struct ibv_qp_attr *attr,
+ int attr_mask, struct ibv_modify_qp_ex *cmd,
+ size_t cmd_core_size, size_t cmd_size,
+ struct ibv_modify_qp_resp_ex *resp,
+ size_t resp_core_size, size_t resp_size);
+int ibv_cmd_destroy_qp(struct ibv_qp *qp);
+int ibv_cmd_post_send(struct ibv_qp *ibqp, struct ibv_send_wr *wr,
+ struct ibv_send_wr **bad_wr);
+int ibv_cmd_post_recv(struct ibv_qp *ibqp, struct ibv_recv_wr *wr,
+ struct ibv_recv_wr **bad_wr);
+int ibv_cmd_post_srq_recv(struct ibv_srq *srq, struct ibv_recv_wr *wr,
+ struct ibv_recv_wr **bad_wr);
+int ibv_cmd_create_ah(struct ibv_pd *pd, struct ibv_ah *ah,
+ struct ibv_ah_attr *attr,
+ struct ibv_create_ah_resp *resp,
+ size_t resp_size);
+int ibv_cmd_destroy_ah(struct ibv_ah *ah);
+int ibv_cmd_attach_mcast(struct ibv_qp *qp, const union ibv_gid *gid, uint16_t lid);
+int ibv_cmd_detach_mcast(struct ibv_qp *qp, const union ibv_gid *gid, uint16_t lid);
+
+struct ibv_flow *ibv_cmd_create_flow(struct ibv_qp *qp,
+ struct ibv_flow_attr *flow_attr);
+int ibv_cmd_destroy_flow(struct ibv_flow *flow_id);
+int ibv_cmd_create_wq(struct ibv_context *context,
+ struct ibv_wq_init_attr *wq_init_attr,
+ struct ibv_wq *wq,
+ struct ibv_create_wq *cmd,
+ size_t cmd_core_size,
+ size_t cmd_size,
+ struct ibv_create_wq_resp *resp,
+ size_t resp_core_size,
+ size_t resp_size);
+
+int ibv_cmd_modify_wq(struct ibv_wq *wq, struct ibv_wq_attr *attr,
+ struct ibv_modify_wq *cmd, size_t cmd_core_size,
+ size_t cmd_size);
+int ibv_cmd_destroy_wq(struct ibv_wq *wq);
+int ibv_cmd_create_rwq_ind_table(struct ibv_context *context,
+ struct ibv_rwq_ind_table_init_attr *init_attr,
+ struct ibv_rwq_ind_table *rwq_ind_table,
+ struct ibv_create_rwq_ind_table *cmd,
+ size_t cmd_core_size,
+ size_t cmd_size,
+ struct ibv_create_rwq_ind_table_resp *resp,
+ size_t resp_core_size,
+ size_t resp_size);
+int ibv_cmd_destroy_rwq_ind_table(struct ibv_rwq_ind_table *rwq_ind_table);
+int ibv_dontfork_range(void *base, size_t size);
+int ibv_dofork_range(void *base, size_t size);
+
+/*
+ * sysfs helper functions
+ */
+const char *ibv_get_sysfs_path(void);
+
+int ibv_read_sysfs_file(const char *dir, const char *file,
+ char *buf, size_t size);
+
+static inline int verbs_get_srq_num(struct ibv_srq *srq, uint32_t *srq_num)
+{
+ struct verbs_srq *vsrq = container_of(srq, struct verbs_srq, srq);
+ if (vsrq->comp_mask & VERBS_SRQ_NUM) {
+ *srq_num = vsrq->srq_num;
+ return 0;
+ }
+ return ENOSYS;
+}
+
+int ibv_query_gid_type(struct ibv_context *context, uint8_t port_num,
+ unsigned int index, enum ibv_gid_type *type);
+#endif /* INFINIBAND_DRIVER_H */
diff --git a/contrib/ofed/libibverbs/enum_strs.c b/contrib/ofed/libibverbs/enum_strs.c
new file mode 100644
index 0000000..93ffe32
--- /dev/null
+++ b/contrib/ofed/libibverbs/enum_strs.c
@@ -0,0 +1,130 @@
+/*
+ * Copyright (c) 2008 Lawrence Livermore National Laboratory
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#include <infiniband/verbs.h>
+
+const char *ibv_node_type_str(enum ibv_node_type node_type)
+{
+ static const char *const node_type_str[] = {
+ [IBV_NODE_CA] = "InfiniBand channel adapter",
+ [IBV_NODE_SWITCH] = "InfiniBand switch",
+ [IBV_NODE_ROUTER] = "InfiniBand router",
+ [IBV_NODE_RNIC] = "iWARP NIC",
+ [IBV_NODE_USNIC] = "usNIC",
+ [IBV_NODE_USNIC_UDP] = "usNIC UDP",
+ };
+
+ if (node_type < IBV_NODE_CA || node_type > IBV_NODE_USNIC_UDP)
+ return "unknown";
+
+ return node_type_str[node_type];
+}
+
+const char *ibv_port_state_str(enum ibv_port_state port_state)
+{
+ static const char *const port_state_str[] = {
+ [IBV_PORT_NOP] = "no state change (NOP)",
+ [IBV_PORT_DOWN] = "down",
+ [IBV_PORT_INIT] = "init",
+ [IBV_PORT_ARMED] = "armed",
+ [IBV_PORT_ACTIVE] = "active",
+ [IBV_PORT_ACTIVE_DEFER] = "active defer"
+ };
+
+ if (port_state < IBV_PORT_NOP || port_state > IBV_PORT_ACTIVE_DEFER)
+ return "unknown";
+
+ return port_state_str[port_state];
+}
+
+const char *ibv_event_type_str(enum ibv_event_type event)
+{
+ static const char *const event_type_str[] = {
+ [IBV_EVENT_CQ_ERR] = "CQ error",
+ [IBV_EVENT_QP_FATAL] = "local work queue catastrophic error",
+ [IBV_EVENT_QP_REQ_ERR] = "invalid request local work queue error",
+ [IBV_EVENT_QP_ACCESS_ERR] = "local access violation work queue error",
+ [IBV_EVENT_COMM_EST] = "communication established",
+ [IBV_EVENT_SQ_DRAINED] = "send queue drained",
+ [IBV_EVENT_PATH_MIG] = "path migrated",
+ [IBV_EVENT_PATH_MIG_ERR] = "path migration request error",
+ [IBV_EVENT_DEVICE_FATAL] = "local catastrophic error",
+ [IBV_EVENT_PORT_ACTIVE] = "port active",
+ [IBV_EVENT_PORT_ERR] = "port error",
+ [IBV_EVENT_LID_CHANGE] = "LID change",
+ [IBV_EVENT_PKEY_CHANGE] = "P_Key change",
+ [IBV_EVENT_SM_CHANGE] = "SM change",
+ [IBV_EVENT_SRQ_ERR] = "SRQ catastrophic error",
+ [IBV_EVENT_SRQ_LIMIT_REACHED] = "SRQ limit reached",
+ [IBV_EVENT_QP_LAST_WQE_REACHED] = "last WQE reached",
+ [IBV_EVENT_CLIENT_REREGISTER] = "client reregistration",
+ [IBV_EVENT_GID_CHANGE] = "GID table change"
+ };
+
+ if (event < IBV_EVENT_CQ_ERR || event > IBV_EVENT_GID_CHANGE)
+ return "unknown";
+
+ return event_type_str[event];
+}
+
+const char *ibv_wc_status_str(enum ibv_wc_status status)
+{
+ static const char *const wc_status_str[] = {
+ [IBV_WC_SUCCESS] = "success",
+ [IBV_WC_LOC_LEN_ERR] = "local length error",
+ [IBV_WC_LOC_QP_OP_ERR] = "local QP operation error",
+ [IBV_WC_LOC_EEC_OP_ERR] = "local EE context operation error",
+ [IBV_WC_LOC_PROT_ERR] = "local protection error",
+ [IBV_WC_WR_FLUSH_ERR] = "Work Request Flushed Error",
+ [IBV_WC_MW_BIND_ERR] = "memory management operation error",
+ [IBV_WC_BAD_RESP_ERR] = "bad response error",
+ [IBV_WC_LOC_ACCESS_ERR] = "local access error",
+ [IBV_WC_REM_INV_REQ_ERR] = "remote invalid request error",
+ [IBV_WC_REM_ACCESS_ERR] = "remote access error",
+ [IBV_WC_REM_OP_ERR] = "remote operation error",
+ [IBV_WC_RETRY_EXC_ERR] = "transport retry counter exceeded",
+ [IBV_WC_RNR_RETRY_EXC_ERR] = "RNR retry counter exceeded",
+ [IBV_WC_LOC_RDD_VIOL_ERR] = "local RDD violation error",
+ [IBV_WC_REM_INV_RD_REQ_ERR] = "remote invalid RD request",
+ [IBV_WC_REM_ABORT_ERR] = "aborted error",
+ [IBV_WC_INV_EECN_ERR] = "invalid EE context number",
+ [IBV_WC_INV_EEC_STATE_ERR] = "invalid EE context state",
+ [IBV_WC_FATAL_ERR] = "fatal error",
+ [IBV_WC_RESP_TIMEOUT_ERR] = "response timeout error",
+ [IBV_WC_GENERAL_ERR] = "general error"
+ };
+
+ if (status < IBV_WC_SUCCESS || status > IBV_WC_GENERAL_ERR)
+ return "unknown";
+
+ return wc_status_str[status];
+}
diff --git a/contrib/ofed/libibverbs/examples/asyncwatch.c b/contrib/ofed/libibverbs/examples/asyncwatch.c
index 0c82dee..4522a05 100644
--- a/contrib/ofed/libibverbs/examples/asyncwatch.c
+++ b/contrib/ofed/libibverbs/examples/asyncwatch.c
@@ -29,12 +29,13 @@
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
-
-#if HAVE_CONFIG_H
-# include <config.h>
-#endif /* HAVE_CONFIG_H */
+#define _GNU_SOURCE
+#include <config.h>
#include <stdio.h>
+#include <infiniband/endian.h>
+#include <getopt.h>
+#include <string.h>
#include <infiniband/verbs.h>
@@ -74,35 +75,78 @@ static const char *event_name_str(enum ibv_event_type event_type)
}
}
+static void usage(const char *argv0)
+{
+ printf("Usage:\n");
+ printf(" %s start an asyncwatch process\n", argv0);
+ printf("\n");
+ printf("Options:\n");
+ printf(" -d, --ib-dev=<dev> use IB device <dev> (default first device found)\n");
+ printf(" -h, --help print a help text and exit\n");
+}
+
int main(int argc, char *argv[])
{
struct ibv_device **dev_list;
struct ibv_context *context;
struct ibv_async_event event;
+ char *ib_devname = NULL;
+ int i = 0;
/* Force line-buffering in case stdout is redirected */
setvbuf(stdout, NULL, _IOLBF, 0);
+ while (1) {
+ int ret = 1;
+ int c;
+ static struct option long_options[] = {
+ { .name = "ib-dev", .has_arg = 1, .val = 'd' },
+ { .name = "help", .has_arg = 0, .val = 'h' },
+ {}
+ };
+
+ c = getopt_long(argc, argv, "d:h", long_options, NULL);
+ if (c == -1)
+ break;
+ switch (c) {
+ case 'd':
+ ib_devname = strdupa(optarg);
+ break;
+ case 'h':
+ ret = 0;
+ SWITCH_FALLTHROUGH;
+ default:
+ usage(argv[0]);
+ return ret;
+ }
+ }
dev_list = ibv_get_device_list(NULL);
if (!dev_list) {
perror("Failed to get IB devices list");
return 1;
}
+ if (ib_devname) {
+ for (; dev_list[i]; ++i) {
+ if (!strcmp(ibv_get_device_name(dev_list[i]), ib_devname))
+ break;
+ }
+ }
- if (!*dev_list) {
- fprintf(stderr, "No IB devices found\n");
+ if (!dev_list[i]) {
+ fprintf(stderr, "IB device %s not found\n",
+ ib_devname ? ib_devname : "");
return 1;
}
- context = ibv_open_device(*dev_list);
+ context = ibv_open_device(dev_list[i]);
if (!context) {
fprintf(stderr, "Couldn't get context for %s\n",
- ibv_get_device_name(*dev_list));
+ ibv_get_device_name(dev_list[i]));
return 1;
}
printf("%s: async event FD %d\n",
- ibv_get_device_name(*dev_list), context->async_fd);
+ ibv_get_device_name(dev_list[i]), context->async_fd);
while (1) {
if (ibv_get_async_event(context, &event))
diff --git a/contrib/ofed/libibverbs/examples/build/Makefile b/contrib/ofed/libibverbs/examples/build/Makefile
index 311899d..b2b8ebe 100644
--- a/contrib/ofed/libibverbs/examples/build/Makefile
+++ b/contrib/ofed/libibverbs/examples/build/Makefile
@@ -1,4 +1,10 @@
-SUBDIR= asyncwatch devinfo device_list rc_pingpong \
- srq_pingpong uc_pingpong ud_pingpong
+SUBDIR= \
+asyncwatch \
+devinfo \
+devices \
+rc_pingpong \
+srq_pingpong \
+uc_pingpong \
+ud_pingpong
.include <bsd.subdir.mk>
diff --git a/contrib/ofed/libibverbs/examples/build/Makefile.inc b/contrib/ofed/libibverbs/examples/build/Makefile.inc
index fd45554..6c285e0 100644
--- a/contrib/ofed/libibverbs/examples/build/Makefile.inc
+++ b/contrib/ofed/libibverbs/examples/build/Makefile.inc
@@ -1,9 +1,4 @@
-BINDIR?= /usr/bin
-
-CFLAGS+= \
- -I../../../../../../sys/ofed/include \
- -I../../../../libibverbs/include \
- -I../../../../include
-
-LDADD+= -libverbs -lmlx4 -lmthca -pthread
+BINDIR?= /usr/bin
+CFLAGS+= -I${.CURDIR}/../../..
+LDFLAGS+= -libverbs -lmlx4 -lmlx5 -lcxgb4 -lpthread
diff --git a/contrib/ofed/libibverbs/examples/build/asyncwatch/Makefile b/contrib/ofed/libibverbs/examples/build/asyncwatch/Makefile
index 7a0a5b2..cf3eb15 100644
--- a/contrib/ofed/libibverbs/examples/build/asyncwatch/Makefile
+++ b/contrib/ofed/libibverbs/examples/build/asyncwatch/Makefile
@@ -1,9 +1,8 @@
-#
# $FreeBSD$
-#
-.PATH: ${.CURDIR}/../..
-PROG= asyncwatch
-MAN=
+.PATH: ${.CURDIR}/../.. ${.CURDIR}/../../../man
+
+PROG= ibv_asyncwatch
+MAN= ibv_asyncwatch.1
SRCS= asyncwatch.c
.include <bsd.prog.mk>
diff --git a/contrib/ofed/libibverbs/examples/build/device_list/Makefile b/contrib/ofed/libibverbs/examples/build/device_list/Makefile
deleted file mode 100644
index 4cdeff5..0000000
--- a/contrib/ofed/libibverbs/examples/build/device_list/Makefile
+++ /dev/null
@@ -1,9 +0,0 @@
-#
-# $FreeBSD$
-#
-.PATH: ${.CURDIR}/../..
-PROG= device_list
-MAN=
-SRCS= device_list.c
-
-.include <bsd.prog.mk>
diff --git a/contrib/ofed/libibverbs/examples/build/devices/Makefile b/contrib/ofed/libibverbs/examples/build/devices/Makefile
new file mode 100644
index 0000000..9c981d3
--- /dev/null
+++ b/contrib/ofed/libibverbs/examples/build/devices/Makefile
@@ -0,0 +1,8 @@
+# $FreeBSD$
+.PATH: ${.CURDIR}/../.. ${.CURDIR}/../../../man
+
+PROG= ibv_devices
+MAN= ibv_devices.1
+SRCS= device_list.c
+
+.include <bsd.prog.mk>
diff --git a/contrib/ofed/libibverbs/examples/build/devinfo/Makefile b/contrib/ofed/libibverbs/examples/build/devinfo/Makefile
index ca6fb6c..8ecd9c7 100644
--- a/contrib/ofed/libibverbs/examples/build/devinfo/Makefile
+++ b/contrib/ofed/libibverbs/examples/build/devinfo/Makefile
@@ -1,9 +1,8 @@
-#
# $FreeBSD$
-#
-.PATH: ${.CURDIR}/../..
-PROG= devinfo
-MAN=
+.PATH: ${.CURDIR}/../.. ${.CURDIR}/../../../man
+
+PROG= ibv_devinfo
+MAN= ibv_devinfo.1
SRCS= devinfo.c
.include <bsd.prog.mk>
diff --git a/contrib/ofed/libibverbs/examples/build/rc_pingpong/Makefile b/contrib/ofed/libibverbs/examples/build/rc_pingpong/Makefile
index 824b08e..2abc22b 100644
--- a/contrib/ofed/libibverbs/examples/build/rc_pingpong/Makefile
+++ b/contrib/ofed/libibverbs/examples/build/rc_pingpong/Makefile
@@ -1,9 +1,8 @@
-#
# $FreeBSD$
-#
-.PATH: ${.CURDIR}/../..
-PROG= rc_pingpong
-MAN=
+.PATH: ${.CURDIR}/../.. ${.CURDIR}/../../../man
+
+PROG= ibv_rc_pingpong
+MAN= ibv_rc_pingpong.1
SRCS= rc_pingpong.c pingpong.c
.include <bsd.prog.mk>
diff --git a/contrib/ofed/libibverbs/examples/build/srq_pingpong/Makefile b/contrib/ofed/libibverbs/examples/build/srq_pingpong/Makefile
index c485d50..460ec9a 100644
--- a/contrib/ofed/libibverbs/examples/build/srq_pingpong/Makefile
+++ b/contrib/ofed/libibverbs/examples/build/srq_pingpong/Makefile
@@ -1,9 +1,8 @@
-#
# $FreeBSD$
-#
-.PATH: ${.CURDIR}/../..
-PROG= srq_pingpong
-MAN=
+.PATH: ${.CURDIR}/../.. ${.CURDIR}/../../../man
+
+PROG= ibv_srq_pingpong
+MAN= ibv_srq_pingpong.1
SRCS= srq_pingpong.c pingpong.c
.include <bsd.prog.mk>
diff --git a/contrib/ofed/libibverbs/examples/build/uc_pingpong/Makefile b/contrib/ofed/libibverbs/examples/build/uc_pingpong/Makefile
index 7427eb9..8e4b617 100644
--- a/contrib/ofed/libibverbs/examples/build/uc_pingpong/Makefile
+++ b/contrib/ofed/libibverbs/examples/build/uc_pingpong/Makefile
@@ -1,9 +1,8 @@
-#
# $FreeBSD$
-#
-.PATH: ${.CURDIR}/../..
-PROG= uc_pingpong
-MAN=
+.PATH: ${.CURDIR}/../.. ${.CURDIR}/../../../man
+
+PROG= ibv_uc_pingpong
+MAN= ibv_uc_pingpong.1
SRCS= uc_pingpong.c pingpong.c
.include <bsd.prog.mk>
diff --git a/contrib/ofed/libibverbs/examples/build/ud_pingpong/Makefile b/contrib/ofed/libibverbs/examples/build/ud_pingpong/Makefile
index 8a0f8e8..f2f967ac 100644
--- a/contrib/ofed/libibverbs/examples/build/ud_pingpong/Makefile
+++ b/contrib/ofed/libibverbs/examples/build/ud_pingpong/Makefile
@@ -1,9 +1,8 @@
-#
# $FreeBSD$
-#
-.PATH: ${.CURDIR}/../..
-PROG= ud_pingpong
-MAN=
+.PATH: ${.CURDIR}/../.. ${.CURDIR}/../../../man
+
+PROG= ibv_ud_pingpong
+MAN= ibv_ud_pingpong.1
SRCS= ud_pingpong.c pingpong.c
.include <bsd.prog.mk>
diff --git a/contrib/ofed/libibverbs/examples/device_list.c b/contrib/ofed/libibverbs/examples/device_list.c
index d1b8051..a7f0636 100644
--- a/contrib/ofed/libibverbs/examples/device_list.c
+++ b/contrib/ofed/libibverbs/examples/device_list.c
@@ -30,14 +30,13 @@
* SOFTWARE.
*/
-#if HAVE_CONFIG_H
-# include <config.h>
-#endif /* HAVE_CONFIG_H */
+#include <config.h>
#include <stdio.h>
+#include <infiniband/endian.h>
+
#include <infiniband/verbs.h>
-#include <infiniband/arch.h>
int main(int argc, char *argv[])
{
@@ -56,7 +55,7 @@ int main(int argc, char *argv[])
for (i = 0; i < num_devices; ++i) {
printf(" %-16s\t%016llx\n",
ibv_get_device_name(dev_list[i]),
- (unsigned long long) ntohll(ibv_get_device_guid(dev_list[i])));
+ (unsigned long long) be64toh(ibv_get_device_guid(dev_list[i])));
}
ibv_free_device_list(dev_list);
diff --git a/contrib/ofed/libibverbs/examples/devinfo.c b/contrib/ofed/libibverbs/examples/devinfo.c
index 4bcb911..94f16e1 100644
--- a/contrib/ofed/libibverbs/examples/devinfo.c
+++ b/contrib/ofed/libibverbs/examples/devinfo.c
@@ -31,20 +31,18 @@
* SOFTWARE.
*/
-#if HAVE_CONFIG_H
-# include <config.h>
-#endif /* HAVE_CONFIG_H */
+#include <config.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <getopt.h>
-#include <netinet/in.h>
+#include <infiniband/endian.h>
+#include <inttypes.h>
#include <infiniband/verbs.h>
#include <infiniband/driver.h>
-#include <infiniband/arch.h>
static int verbose;
@@ -54,9 +52,9 @@ static int null_gid(union ibv_gid *gid)
gid->raw[12] | gid->raw[13] | gid->raw[14] | gid->raw[15]);
}
-static const char *guid_str(uint64_t node_guid, char *str)
+static const char *guid_str(__be64 _node_guid, char *str)
{
- node_guid = ntohll(node_guid);
+ uint64_t node_guid = be64toh(_node_guid);
sprintf(str, "%04x:%04x:%04x:%04x",
(unsigned) (node_guid >> 48) & 0xffff,
(unsigned) (node_guid >> 32) & 0xffff,
@@ -68,9 +66,11 @@ static const char *guid_str(uint64_t node_guid, char *str)
static const char *transport_str(enum ibv_transport_type transport)
{
switch (transport) {
- case IBV_TRANSPORT_IB: return "InfiniBand";
- case IBV_TRANSPORT_IWARP: return "iWARP";
- default: return "invalid transport";
+ case IBV_TRANSPORT_IB: return "InfiniBand";
+ case IBV_TRANSPORT_IWARP: return "iWARP";
+ case IBV_TRANSPORT_USNIC: return "usNIC";
+ case IBV_TRANSPORT_USNIC_UDP: return "usNIC UDP";
+ default: return "invalid transport";
}
}
@@ -137,7 +137,12 @@ static const char *speed_str(uint8_t speed)
switch (speed) {
case 1: return "2.5 Gbps";
case 2: return "5.0 Gbps";
- case 4: return "10.0 Gbps";
+
+ case 4: /* fall through */
+ case 8: return "10.0 Gbps";
+
+ case 16: return "14.0 Gbps";
+ case 32: return "25.0 Gbps";
default: return "invalid speed";
}
}
@@ -187,7 +192,7 @@ static const char *link_layer_str(uint8_t link_layer)
switch (link_layer) {
case IBV_LINK_LAYER_UNSPECIFIED:
case IBV_LINK_LAYER_INFINIBAND:
- return "IB";
+ return "InfiniBand";
case IBV_LINK_LAYER_ETHERNET:
return "Ethernet";
default:
@@ -195,10 +200,222 @@ static const char *link_layer_str(uint8_t link_layer)
}
}
+static void print_device_cap_flags(uint32_t dev_cap_flags)
+{
+ uint32_t unknown_flags = ~(IBV_DEVICE_RESIZE_MAX_WR |
+ IBV_DEVICE_BAD_PKEY_CNTR |
+ IBV_DEVICE_BAD_QKEY_CNTR |
+ IBV_DEVICE_RAW_MULTI |
+ IBV_DEVICE_AUTO_PATH_MIG |
+ IBV_DEVICE_CHANGE_PHY_PORT |
+ IBV_DEVICE_UD_AV_PORT_ENFORCE |
+ IBV_DEVICE_CURR_QP_STATE_MOD |
+ IBV_DEVICE_SHUTDOWN_PORT |
+ IBV_DEVICE_INIT_TYPE |
+ IBV_DEVICE_PORT_ACTIVE_EVENT |
+ IBV_DEVICE_SYS_IMAGE_GUID |
+ IBV_DEVICE_RC_RNR_NAK_GEN |
+ IBV_DEVICE_SRQ_RESIZE |
+ IBV_DEVICE_N_NOTIFY_CQ |
+ IBV_DEVICE_MEM_WINDOW |
+ IBV_DEVICE_UD_IP_CSUM |
+ IBV_DEVICE_XRC |
+ IBV_DEVICE_MEM_MGT_EXTENSIONS |
+ IBV_DEVICE_MEM_WINDOW_TYPE_2A |
+ IBV_DEVICE_MEM_WINDOW_TYPE_2B |
+ IBV_DEVICE_RC_IP_CSUM |
+ IBV_DEVICE_RAW_IP_CSUM |
+ IBV_DEVICE_MANAGED_FLOW_STEERING);
+
+ if (dev_cap_flags & IBV_DEVICE_RESIZE_MAX_WR)
+ printf("\t\t\t\t\tRESIZE_MAX_WR\n");
+ if (dev_cap_flags & IBV_DEVICE_BAD_PKEY_CNTR)
+ printf("\t\t\t\t\tBAD_PKEY_CNTR\n");
+ if (dev_cap_flags & IBV_DEVICE_BAD_QKEY_CNTR)
+ printf("\t\t\t\t\tBAD_QKEY_CNTR\n");
+ if (dev_cap_flags & IBV_DEVICE_RAW_MULTI)
+ printf("\t\t\t\t\tRAW_MULTI\n");
+ if (dev_cap_flags & IBV_DEVICE_AUTO_PATH_MIG)
+ printf("\t\t\t\t\tAUTO_PATH_MIG\n");
+ if (dev_cap_flags & IBV_DEVICE_CHANGE_PHY_PORT)
+ printf("\t\t\t\t\tCHANGE_PHY_PORT\n");
+ if (dev_cap_flags & IBV_DEVICE_UD_AV_PORT_ENFORCE)
+ printf("\t\t\t\t\tUD_AV_PORT_ENFORCE\n");
+ if (dev_cap_flags & IBV_DEVICE_CURR_QP_STATE_MOD)
+ printf("\t\t\t\t\tCURR_QP_STATE_MOD\n");
+ if (dev_cap_flags & IBV_DEVICE_SHUTDOWN_PORT)
+ printf("\t\t\t\t\tSHUTDOWN_PORT\n");
+ if (dev_cap_flags & IBV_DEVICE_INIT_TYPE)
+ printf("\t\t\t\t\tINIT_TYPE\n");
+ if (dev_cap_flags & IBV_DEVICE_PORT_ACTIVE_EVENT)
+ printf("\t\t\t\t\tPORT_ACTIVE_EVENT\n");
+ if (dev_cap_flags & IBV_DEVICE_SYS_IMAGE_GUID)
+ printf("\t\t\t\t\tSYS_IMAGE_GUID\n");
+ if (dev_cap_flags & IBV_DEVICE_RC_RNR_NAK_GEN)
+ printf("\t\t\t\t\tRC_RNR_NAK_GEN\n");
+ if (dev_cap_flags & IBV_DEVICE_SRQ_RESIZE)
+ printf("\t\t\t\t\tSRQ_RESIZE\n");
+ if (dev_cap_flags & IBV_DEVICE_N_NOTIFY_CQ)
+ printf("\t\t\t\t\tN_NOTIFY_CQ\n");
+ if (dev_cap_flags & IBV_DEVICE_MEM_WINDOW)
+ printf("\t\t\t\t\tMEM_WINDOW\n");
+ if (dev_cap_flags & IBV_DEVICE_UD_IP_CSUM)
+ printf("\t\t\t\t\tUD_IP_CSUM\n");
+ if (dev_cap_flags & IBV_DEVICE_XRC)
+ printf("\t\t\t\t\tXRC\n");
+ if (dev_cap_flags & IBV_DEVICE_MEM_MGT_EXTENSIONS)
+ printf("\t\t\t\t\tMEM_MGT_EXTENSIONS\n");
+ if (dev_cap_flags & IBV_DEVICE_MEM_WINDOW_TYPE_2A)
+ printf("\t\t\t\t\tMEM_WINDOW_TYPE_2A\n");
+ if (dev_cap_flags & IBV_DEVICE_MEM_WINDOW_TYPE_2B)
+ printf("\t\t\t\t\tMEM_WINDOW_TYPE_2B\n");
+ if (dev_cap_flags & IBV_DEVICE_RC_IP_CSUM)
+ printf("\t\t\t\t\tRC_IP_CSUM\n");
+ if (dev_cap_flags & IBV_DEVICE_RAW_IP_CSUM)
+ printf("\t\t\t\t\tRAW_IP_CSUM\n");
+ if (dev_cap_flags & IBV_DEVICE_MANAGED_FLOW_STEERING)
+ printf("\t\t\t\t\tMANAGED_FLOW_STEERING\n");
+ if (dev_cap_flags & unknown_flags)
+ printf("\t\t\t\t\tUnknown flags: 0x%" PRIX32 "\n",
+ dev_cap_flags & unknown_flags);
+}
+
+static void print_odp_trans_caps(uint32_t trans)
+{
+ uint32_t unknown_transport_caps = ~(IBV_ODP_SUPPORT_SEND |
+ IBV_ODP_SUPPORT_RECV |
+ IBV_ODP_SUPPORT_WRITE |
+ IBV_ODP_SUPPORT_READ |
+ IBV_ODP_SUPPORT_ATOMIC);
+
+ if (!trans) {
+ printf("\t\t\t\t\tNO SUPPORT\n");
+ } else {
+ if (trans & IBV_ODP_SUPPORT_SEND)
+ printf("\t\t\t\t\tSUPPORT_SEND\n");
+ if (trans & IBV_ODP_SUPPORT_RECV)
+ printf("\t\t\t\t\tSUPPORT_RECV\n");
+ if (trans & IBV_ODP_SUPPORT_WRITE)
+ printf("\t\t\t\t\tSUPPORT_WRITE\n");
+ if (trans & IBV_ODP_SUPPORT_READ)
+ printf("\t\t\t\t\tSUPPORT_READ\n");
+ if (trans & IBV_ODP_SUPPORT_ATOMIC)
+ printf("\t\t\t\t\tSUPPORT_ATOMIC\n");
+ if (trans & unknown_transport_caps)
+ printf("\t\t\t\t\tUnknown flags: 0x%" PRIX32 "\n",
+ trans & unknown_transport_caps);
+ }
+}
+
+static void print_odp_caps(const struct ibv_odp_caps *caps)
+{
+ uint64_t unknown_general_caps = ~(IBV_ODP_SUPPORT);
+
+ /* general odp caps */
+ printf("\tgeneral_odp_caps:\n");
+ if (caps->general_caps & IBV_ODP_SUPPORT)
+ printf("\t\t\t\t\tODP_SUPPORT\n");
+ if (caps->general_caps & unknown_general_caps)
+ printf("\t\t\t\t\tUnknown flags: 0x%" PRIX64 "\n",
+ caps->general_caps & unknown_general_caps);
+
+ /* RC transport */
+ printf("\trc_odp_caps:\n");
+ print_odp_trans_caps(caps->per_transport_caps.rc_odp_caps);
+ printf("\tuc_odp_caps:\n");
+ print_odp_trans_caps(caps->per_transport_caps.uc_odp_caps);
+ printf("\tud_odp_caps:\n");
+ print_odp_trans_caps(caps->per_transport_caps.ud_odp_caps);
+}
+
+static void print_device_cap_flags_ex(uint64_t device_cap_flags_ex)
+{
+ uint64_t ex_flags = device_cap_flags_ex & 0xffffffff00000000ULL;
+ uint64_t unknown_flags = ~(IBV_DEVICE_RAW_SCATTER_FCS);
+
+ if (ex_flags & IBV_DEVICE_RAW_SCATTER_FCS)
+ printf("\t\t\t\t\tRAW_SCATTER_FCS\n");
+ if (ex_flags & unknown_flags)
+ printf("\t\t\t\t\tUnknown flags: 0x%" PRIX64 "\n",
+ ex_flags & unknown_flags);
+}
+
+static void print_tso_caps(const struct ibv_tso_caps *caps)
+{
+ uint32_t unknown_general_caps = ~(1 << IBV_QPT_RAW_PACKET |
+ 1 << IBV_QPT_UD);
+ printf("\ttso_caps:\n");
+ printf("\tmax_tso:\t\t\t%d\n", caps->max_tso);
+
+ if (caps->max_tso) {
+ printf("\tsupported_qp:\n");
+ if (ibv_is_qpt_supported(caps->supported_qpts, IBV_QPT_RAW_PACKET))
+ printf("\t\t\t\t\tSUPPORT_RAW_PACKET\n");
+ if (ibv_is_qpt_supported(caps->supported_qpts, IBV_QPT_UD))
+ printf("\t\t\t\t\tSUPPORT_UD\n");
+ if (caps->supported_qpts & unknown_general_caps)
+ printf("\t\t\t\t\tUnknown flags: 0x%" PRIX32 "\n",
+ caps->supported_qpts & unknown_general_caps);
+ }
+}
+
+static void print_rss_caps(const struct ibv_rss_caps *caps)
+{
+ uint32_t unknown_general_caps = ~(1 << IBV_QPT_RAW_PACKET |
+ 1 << IBV_QPT_UD);
+ printf("\trss_caps:\n");
+ printf("\t\tmax_rwq_indirection_tables:\t\t\t%u\n", caps->max_rwq_indirection_tables);
+ printf("\t\tmax_rwq_indirection_table_size:\t\t\t%u\n", caps->max_rwq_indirection_table_size);
+ printf("\t\trx_hash_function:\t\t\t\t0x%x\n", caps->rx_hash_function);
+ printf("\t\trx_hash_fields_mask:\t\t\t\t0x%" PRIX64 "\n", caps->rx_hash_fields_mask);
+
+ if (caps->supported_qpts) {
+ printf("\t\tsupported_qp:\n");
+ if (ibv_is_qpt_supported(caps->supported_qpts, IBV_QPT_RAW_PACKET))
+ printf("\t\t\t\t\tSUPPORT_RAW_PACKET\n");
+ if (ibv_is_qpt_supported(caps->supported_qpts, IBV_QPT_UD))
+ printf("\t\t\t\t\tSUPPORT_UD\n");
+ if (caps->supported_qpts & unknown_general_caps)
+ printf("\t\t\t\t\tUnknown flags: 0x%" PRIX32 "\n",
+ caps->supported_qpts & unknown_general_caps);
+ }
+}
+
+static void print_packet_pacing_caps(const struct ibv_packet_pacing_caps *caps)
+{
+ uint32_t unknown_general_caps = ~(1 << IBV_QPT_RAW_PACKET |
+ 1 << IBV_QPT_UD);
+ printf("\tpacket_pacing_caps:\n");
+ printf("\t\tqp_rate_limit_min:\t%ukbps\n", caps->qp_rate_limit_min);
+ printf("\t\tqp_rate_limit_max:\t%ukbps\n", caps->qp_rate_limit_max);
+
+ if (caps->qp_rate_limit_max) {
+ printf("\t\tsupported_qp:\n");
+ if (ibv_is_qpt_supported(caps->supported_qpts, IBV_QPT_RAW_PACKET))
+ printf("\t\t\t\t\tSUPPORT_RAW_PACKET\n");
+ if (ibv_is_qpt_supported(caps->supported_qpts, IBV_QPT_UD))
+ printf("\t\t\t\t\tSUPPORT_UD\n");
+ if (caps->supported_qpts & unknown_general_caps)
+ printf("\t\t\t\t\tUnknown flags: 0x%" PRIX32 "\n",
+ caps->supported_qpts & unknown_general_caps);
+ }
+}
+
+static void print_raw_packet_caps(uint32_t raw_packet_caps)
+{
+ printf("\traw packet caps:\n");
+ if (raw_packet_caps & IBV_RAW_PACKET_CAP_CVLAN_STRIPPING)
+ printf("\t\t\t\t\tC-VLAN stripping offload\n");
+ if (raw_packet_caps & IBV_RAW_PACKET_CAP_SCATTER_FCS)
+ printf("\t\t\t\t\tScatter FCS offload\n");
+ if (raw_packet_caps & IBV_RAW_PACKET_CAP_IP_CSUM)
+ printf("\t\t\t\t\tIP csum offload\n");
+}
+
static int print_hca_cap(struct ibv_device *ib_dev, uint8_t ib_port)
{
struct ibv_context *ctx;
- struct ibv_device_attr device_attr;
+ struct ibv_device_attr_ex device_attr;
struct ibv_port_attr port_attr;
int rc = 0;
uint8_t port;
@@ -210,72 +427,101 @@ static int print_hca_cap(struct ibv_device *ib_dev, uint8_t ib_port)
rc = 1;
goto cleanup;
}
- if (ibv_query_device(ctx, &device_attr)) {
- fprintf(stderr, "Failed to query device props");
+ if (ibv_query_device_ex(ctx, NULL, &device_attr)) {
+ fprintf(stderr, "Failed to query device props\n");
rc = 2;
goto cleanup;
}
+ if (ib_port && ib_port > device_attr.orig_attr.phys_port_cnt) {
+ fprintf(stderr, "Invalid port requested for device\n");
+ /* rc = 3 is taken by failure to clean up */
+ rc = 4;
+ goto cleanup;
+ }
printf("hca_id:\t%s\n", ibv_get_device_name(ib_dev));
printf("\ttransport:\t\t\t%s (%d)\n",
transport_str(ib_dev->transport_type), ib_dev->transport_type);
- if (strlen(device_attr.fw_ver))
- printf("\tfw_ver:\t\t\t\t%s\n", device_attr.fw_ver);
- printf("\tnode_guid:\t\t\t%s\n", guid_str(device_attr.node_guid, buf));
- printf("\tsys_image_guid:\t\t\t%s\n", guid_str(device_attr.sys_image_guid, buf));
- printf("\tvendor_id:\t\t\t0x%04x\n", device_attr.vendor_id);
- printf("\tvendor_part_id:\t\t\t%d\n", device_attr.vendor_part_id);
- printf("\thw_ver:\t\t\t\t0x%X\n", device_attr.hw_ver);
+ if (strlen(device_attr.orig_attr.fw_ver))
+ printf("\tfw_ver:\t\t\t\t%s\n", device_attr.orig_attr.fw_ver);
+ printf("\tnode_guid:\t\t\t%s\n", guid_str(device_attr.orig_attr.node_guid, buf));
+ printf("\tsys_image_guid:\t\t\t%s\n", guid_str(device_attr.orig_attr.sys_image_guid, buf));
+ printf("\tvendor_id:\t\t\t0x%04x\n", device_attr.orig_attr.vendor_id);
+ printf("\tvendor_part_id:\t\t\t%d\n", device_attr.orig_attr.vendor_part_id);
+ printf("\thw_ver:\t\t\t\t0x%X\n", device_attr.orig_attr.hw_ver);
if (ibv_read_sysfs_file(ib_dev->ibdev_path, "board_id", buf, sizeof buf) > 0)
printf("\tboard_id:\t\t\t%s\n", buf);
- printf("\tphys_port_cnt:\t\t\t%d\n", device_attr.phys_port_cnt);
+ printf("\tphys_port_cnt:\t\t\t%d\n", device_attr.orig_attr.phys_port_cnt);
if (verbose) {
printf("\tmax_mr_size:\t\t\t0x%llx\n",
- (unsigned long long) device_attr.max_mr_size);
+ (unsigned long long) device_attr.orig_attr.max_mr_size);
printf("\tpage_size_cap:\t\t\t0x%llx\n",
- (unsigned long long) device_attr.page_size_cap);
- printf("\tmax_qp:\t\t\t\t%d\n", device_attr.max_qp);
- printf("\tmax_qp_wr:\t\t\t%d\n", device_attr.max_qp_wr);
- printf("\tdevice_cap_flags:\t\t0x%08x\n", device_attr.device_cap_flags);
- printf("\tmax_sge:\t\t\t%d\n", device_attr.max_sge);
- printf("\tmax_sge_rd:\t\t\t%d\n", device_attr.max_sge_rd);
- printf("\tmax_cq:\t\t\t\t%d\n", device_attr.max_cq);
- printf("\tmax_cqe:\t\t\t%d\n", device_attr.max_cqe);
- printf("\tmax_mr:\t\t\t\t%d\n", device_attr.max_mr);
- printf("\tmax_pd:\t\t\t\t%d\n", device_attr.max_pd);
- printf("\tmax_qp_rd_atom:\t\t\t%d\n", device_attr.max_qp_rd_atom);
- printf("\tmax_ee_rd_atom:\t\t\t%d\n", device_attr.max_ee_rd_atom);
- printf("\tmax_res_rd_atom:\t\t%d\n", device_attr.max_res_rd_atom);
- printf("\tmax_qp_init_rd_atom:\t\t%d\n", device_attr.max_qp_init_rd_atom);
- printf("\tmax_ee_init_rd_atom:\t\t%d\n", device_attr.max_ee_init_rd_atom);
+ (unsigned long long) device_attr.orig_attr.page_size_cap);
+ printf("\tmax_qp:\t\t\t\t%d\n", device_attr.orig_attr.max_qp);
+ printf("\tmax_qp_wr:\t\t\t%d\n", device_attr.orig_attr.max_qp_wr);
+ printf("\tdevice_cap_flags:\t\t0x%08x\n", device_attr.orig_attr.device_cap_flags);
+ print_device_cap_flags(device_attr.orig_attr.device_cap_flags);
+ printf("\tmax_sge:\t\t\t%d\n", device_attr.orig_attr.max_sge);
+ printf("\tmax_sge_rd:\t\t\t%d\n", device_attr.orig_attr.max_sge_rd);
+ printf("\tmax_cq:\t\t\t\t%d\n", device_attr.orig_attr.max_cq);
+ printf("\tmax_cqe:\t\t\t%d\n", device_attr.orig_attr.max_cqe);
+ printf("\tmax_mr:\t\t\t\t%d\n", device_attr.orig_attr.max_mr);
+ printf("\tmax_pd:\t\t\t\t%d\n", device_attr.orig_attr.max_pd);
+ printf("\tmax_qp_rd_atom:\t\t\t%d\n", device_attr.orig_attr.max_qp_rd_atom);
+ printf("\tmax_ee_rd_atom:\t\t\t%d\n", device_attr.orig_attr.max_ee_rd_atom);
+ printf("\tmax_res_rd_atom:\t\t%d\n", device_attr.orig_attr.max_res_rd_atom);
+ printf("\tmax_qp_init_rd_atom:\t\t%d\n", device_attr.orig_attr.max_qp_init_rd_atom);
+ printf("\tmax_ee_init_rd_atom:\t\t%d\n", device_attr.orig_attr.max_ee_init_rd_atom);
printf("\tatomic_cap:\t\t\t%s (%d)\n",
- atomic_cap_str(device_attr.atomic_cap), device_attr.atomic_cap);
- printf("\tmax_ee:\t\t\t\t%d\n", device_attr.max_ee);
- printf("\tmax_rdd:\t\t\t%d\n", device_attr.max_rdd);
- printf("\tmax_mw:\t\t\t\t%d\n", device_attr.max_mw);
- printf("\tmax_raw_ipv6_qp:\t\t%d\n", device_attr.max_raw_ipv6_qp);
- printf("\tmax_raw_ethy_qp:\t\t%d\n", device_attr.max_raw_ethy_qp);
- printf("\tmax_mcast_grp:\t\t\t%d\n", device_attr.max_mcast_grp);
- printf("\tmax_mcast_qp_attach:\t\t%d\n", device_attr.max_mcast_qp_attach);
+ atomic_cap_str(device_attr.orig_attr.atomic_cap), device_attr.orig_attr.atomic_cap);
+ printf("\tmax_ee:\t\t\t\t%d\n", device_attr.orig_attr.max_ee);
+ printf("\tmax_rdd:\t\t\t%d\n", device_attr.orig_attr.max_rdd);
+ printf("\tmax_mw:\t\t\t\t%d\n", device_attr.orig_attr.max_mw);
+ printf("\tmax_raw_ipv6_qp:\t\t%d\n", device_attr.orig_attr.max_raw_ipv6_qp);
+ printf("\tmax_raw_ethy_qp:\t\t%d\n", device_attr.orig_attr.max_raw_ethy_qp);
+ printf("\tmax_mcast_grp:\t\t\t%d\n", device_attr.orig_attr.max_mcast_grp);
+ printf("\tmax_mcast_qp_attach:\t\t%d\n", device_attr.orig_attr.max_mcast_qp_attach);
printf("\tmax_total_mcast_qp_attach:\t%d\n",
- device_attr.max_total_mcast_qp_attach);
- printf("\tmax_ah:\t\t\t\t%d\n", device_attr.max_ah);
- printf("\tmax_fmr:\t\t\t%d\n", device_attr.max_fmr);
- if (device_attr.max_fmr)
- printf("\tmax_map_per_fmr:\t\t%d\n", device_attr.max_map_per_fmr);
- printf("\tmax_srq:\t\t\t%d\n", device_attr.max_srq);
- if (device_attr.max_srq) {
- printf("\tmax_srq_wr:\t\t\t%d\n", device_attr.max_srq_wr);
- printf("\tmax_srq_sge:\t\t\t%d\n", device_attr.max_srq_sge);
+ device_attr.orig_attr.max_total_mcast_qp_attach);
+ printf("\tmax_ah:\t\t\t\t%d\n", device_attr.orig_attr.max_ah);
+ printf("\tmax_fmr:\t\t\t%d\n", device_attr.orig_attr.max_fmr);
+ if (device_attr.orig_attr.max_fmr)
+ printf("\tmax_map_per_fmr:\t\t%d\n", device_attr.orig_attr.max_map_per_fmr);
+ printf("\tmax_srq:\t\t\t%d\n", device_attr.orig_attr.max_srq);
+ if (device_attr.orig_attr.max_srq) {
+ printf("\tmax_srq_wr:\t\t\t%d\n", device_attr.orig_attr.max_srq_wr);
+ printf("\tmax_srq_sge:\t\t\t%d\n", device_attr.orig_attr.max_srq_sge);
}
- printf("\tmax_pkeys:\t\t\t%d\n", device_attr.max_pkeys);
- printf("\tlocal_ca_ack_delay:\t\t%d\n", device_attr.local_ca_ack_delay);
+ printf("\tmax_pkeys:\t\t\t%d\n", device_attr.orig_attr.max_pkeys);
+ printf("\tlocal_ca_ack_delay:\t\t%d\n", device_attr.orig_attr.local_ca_ack_delay);
+
+ print_odp_caps(&device_attr.odp_caps);
+ if (device_attr.completion_timestamp_mask)
+ printf("\tcompletion timestamp_mask:\t\t\t0x%016" PRIx64 "\n",
+ device_attr.completion_timestamp_mask);
+ else
+ printf("\tcompletion_timestamp_mask not supported\n");
+
+ if (device_attr.hca_core_clock)
+ printf("\thca_core_clock:\t\t\t%" PRIu64 "kHZ\n", device_attr.hca_core_clock);
+ else
+ printf("\tcore clock not supported\n");
+
+ if (device_attr.raw_packet_caps)
+ print_raw_packet_caps(device_attr.raw_packet_caps);
+
+ printf("\tdevice_cap_flags_ex:\t\t0x%" PRIX64 "\n", device_attr.device_cap_flags_ex);
+ print_device_cap_flags_ex(device_attr.device_cap_flags_ex);
+ print_tso_caps(&device_attr.tso_caps);
+ print_rss_caps(&device_attr.rss_caps);
+ printf("\tmax_wq_type_rq:\t\t\t%u\n", device_attr.max_wq_type_rq);
+ print_packet_pacing_caps(&device_attr.packet_pacing_caps);
}
- for (port = 1; port <= device_attr.phys_port_cnt; ++port) {
+ for (port = 1; port <= device_attr.orig_attr.phys_port_cnt; ++port) {
/* if in the command line the user didn't ask for info about this port */
if ((ib_port) && (port != ib_port))
continue;
@@ -295,7 +541,8 @@ static int print_hca_cap(struct ibv_device *ib_dev, uint8_t ib_port)
printf("\t\t\tsm_lid:\t\t\t%d\n", port_attr.sm_lid);
printf("\t\t\tport_lid:\t\t%d\n", port_attr.lid);
printf("\t\t\tport_lmc:\t\t0x%02x\n", port_attr.lmc);
- printf("\t\t\tlink_layer:\t\t%s\n", link_layer_str(port_attr.link_layer));
+ printf("\t\t\tlink_layer:\t\t%s\n",
+ link_layer_str(port_attr.link_layer));
if (verbose) {
printf("\t\t\tmax_msg_sz:\t\t0x%x\n", port_attr.max_msg_sz);
@@ -313,8 +560,9 @@ static int print_hca_cap(struct ibv_device *ib_dev, uint8_t ib_port)
width_str(port_attr.active_width), port_attr.active_width);
printf("\t\t\tactive_speed:\t\t%s (%d)\n",
speed_str(port_attr.active_speed), port_attr.active_speed);
- printf("\t\t\tphys_state:\t\t%s (%d)\n",
- port_phy_state_str(port_attr.phys_state), port_attr.phys_state);
+ if (ib_dev->transport_type == IBV_TRANSPORT_IB)
+ printf("\t\t\tphys_state:\t\t%s (%d)\n",
+ port_phy_state_str(port_attr.phys_state), port_attr.phys_state);
if (print_all_port_gids(ctx, port, port_attr.gid_tbl_len))
goto cleanup;
@@ -357,7 +605,7 @@ int main(int argc, char *argv[])
{ .name = "ib-port", .has_arg = 1, .val = 'i' },
{ .name = "list", .has_arg = 0, .val = 'l' },
{ .name = "verbose", .has_arg = 0, .val = 'v' },
- { 0, 0, 0, 0}
+ { }
};
c = getopt_long(argc, argv, "d:i:lv", long_options, NULL);
@@ -371,7 +619,7 @@ int main(int argc, char *argv[])
case 'i':
ib_port = strtol(optarg, NULL, 0);
- if (ib_port < 0) {
+ if (ib_port <= 0) {
usage(argv[0]);
return 1;
}
diff --git a/contrib/ofed/libibverbs/examples/pingpong.c b/contrib/ofed/libibverbs/examples/pingpong.c
index 806f446..72757cb 100644
--- a/contrib/ofed/libibverbs/examples/pingpong.c
+++ b/contrib/ofed/libibverbs/examples/pingpong.c
@@ -31,7 +31,7 @@
*/
#include "pingpong.h"
-#include <arpa/inet.h>
+#include <infiniband/endian.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
@@ -44,20 +44,10 @@ enum ibv_mtu pp_mtu_to_enum(int mtu)
case 1024: return IBV_MTU_1024;
case 2048: return IBV_MTU_2048;
case 4096: return IBV_MTU_4096;
- default: return -1;
+ default: return 0;
}
}
-uint16_t pp_get_local_lid(struct ibv_context *context, int port)
-{
- struct ibv_port_attr attr;
-
- if (ibv_query_port(context, port, &attr))
- return 0;
-
- return attr.lid;
-}
-
int pp_get_port_info(struct ibv_context *context, int port,
struct ibv_port_attr *attr)
{
@@ -67,20 +57,24 @@ int pp_get_port_info(struct ibv_context *context, int port,
void wire_gid_to_gid(const char *wgid, union ibv_gid *gid)
{
char tmp[9];
- uint32_t v32;
+ __be32 v32;
int i;
+ uint32_t tmp_gid[4];
for (tmp[8] = 0, i = 0; i < 4; ++i) {
memcpy(tmp, wgid + i * 8, 8);
sscanf(tmp, "%x", &v32);
- *(uint32_t *)(&gid->raw[i * 4]) = ntohl(v32);
+ tmp_gid[i] = be32toh(v32);
}
+ memcpy(gid, tmp_gid, sizeof(*gid));
}
void gid_to_wire_gid(const union ibv_gid *gid, char wgid[])
{
+ uint32_t tmp_gid[4];
int i;
+ memcpy(tmp_gid, gid, sizeof(tmp_gid));
for (i = 0; i < 4; ++i)
- sprintf(&wgid[i * 8], "%08x", htonl(*(uint32_t *)(gid->raw + i * 4)));
+ sprintf(&wgid[i * 8], "%08x", htobe32(tmp_gid[i]));
}
diff --git a/contrib/ofed/libibverbs/examples/pingpong.h b/contrib/ofed/libibverbs/examples/pingpong.h
index 829ceee..8dc5dd0 100644
--- a/contrib/ofed/libibverbs/examples/pingpong.h
+++ b/contrib/ofed/libibverbs/examples/pingpong.h
@@ -33,12 +33,9 @@
#ifndef IBV_PINGPONG_H
#define IBV_PINGPONG_H
-#include <sys/param.h>
-
#include <infiniband/verbs.h>
enum ibv_mtu pp_mtu_to_enum(int mtu);
-uint16_t pp_get_local_lid(struct ibv_context *context, int port);
int pp_get_port_info(struct ibv_context *context, int port,
struct ibv_port_attr *attr);
void wire_gid_to_gid(const char *wgid, union ibv_gid *gid);
diff --git a/contrib/ofed/libibverbs/examples/rc_pingpong.c b/contrib/ofed/libibverbs/examples/rc_pingpong.c
index ced7192..a607ef4 100644
--- a/contrib/ofed/libibverbs/examples/rc_pingpong.c
+++ b/contrib/ofed/libibverbs/examples/rc_pingpong.c
@@ -29,10 +29,8 @@
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
-
-#if HAVE_CONFIG_H
-# include <config.h>
-#endif /* HAVE_CONFIG_H */
+#define _GNU_SOURCE
+#include <config.h>
#include <stdio.h>
#include <stdlib.h>
@@ -46,30 +44,46 @@
#include <getopt.h>
#include <arpa/inet.h>
#include <time.h>
+#include <inttypes.h>
#include "pingpong.h"
+#include <sys/param.h>
+
enum {
PINGPONG_RECV_WRID = 1,
PINGPONG_SEND_WRID = 2,
};
static int page_size;
+static int use_odp;
+static int use_ts;
struct pingpong_context {
struct ibv_context *context;
struct ibv_comp_channel *channel;
struct ibv_pd *pd;
struct ibv_mr *mr;
- struct ibv_cq *cq;
+ union {
+ struct ibv_cq *cq;
+ struct ibv_cq_ex *cq_ex;
+ } cq_s;
struct ibv_qp *qp;
void *buf;
int size;
+ int send_flags;
int rx_depth;
int pending;
struct ibv_port_attr portinfo;
+ uint64_t completion_timestamp_mask;
};
+static struct ibv_cq *pp_cq(struct pingpong_context *ctx)
+{
+ return use_ts ? ibv_cq_ex_to_cq(ctx->cq_s.cq_ex) :
+ ctx->cq_s.cq;
+}
+
struct pingpong_dest {
int lid;
int qpn;
@@ -171,7 +185,7 @@ static struct pingpong_dest *pp_client_exch_dest(const char *servername, int por
}
}
- freeaddrinfo(res);
+ freeaddrinfo_null(res);
free(service);
if (sockfd < 0) {
@@ -180,25 +194,26 @@ static struct pingpong_dest *pp_client_exch_dest(const char *servername, int por
}
gid_to_wire_gid(&my_dest->gid, gid);
- sprintf(msg, "%04x:%06x:%06x:%s", my_dest->lid, my_dest->qpn, my_dest->psn, gid);
+ sprintf(msg, "%04x:%06x:%06x:%s", my_dest->lid, my_dest->qpn,
+ my_dest->psn, gid);
if (write(sockfd, msg, sizeof msg) != sizeof msg) {
fprintf(stderr, "Couldn't send local address\n");
goto out;
}
- if (read(sockfd, msg, sizeof msg) != sizeof msg) {
- perror("client read");
- fprintf(stderr, "Couldn't read remote address\n");
+ if (read(sockfd, msg, sizeof msg) != sizeof msg ||
+ write(sockfd, "done", sizeof "done") != sizeof "done") {
+ perror("client read/write");
+ fprintf(stderr, "Couldn't read/write remote address\n");
goto out;
}
- write(sockfd, "done", sizeof "done");
-
rem_dest = malloc(sizeof *rem_dest);
if (!rem_dest)
goto out;
- sscanf(msg, "%x:%x:%x:%s", &rem_dest->lid, &rem_dest->qpn, &rem_dest->psn, gid);
+ sscanf(msg, "%x:%x:%x:%s", &rem_dest->lid, &rem_dest->qpn,
+ &rem_dest->psn, gid);
wire_gid_to_gid(gid, &rem_dest->gid);
out:
@@ -250,7 +265,7 @@ static struct pingpong_dest *pp_server_exch_dest(struct pingpong_context *ctx,
}
}
- freeaddrinfo(res);
+ freeaddrinfo_null(res);
free(service);
if (sockfd < 0) {
@@ -259,7 +274,7 @@ static struct pingpong_dest *pp_server_exch_dest(struct pingpong_context *ctx,
}
listen(sockfd, 1);
- connfd = accept(sockfd, NULL, 0);
+ connfd = accept(sockfd, NULL, NULL);
close(sockfd);
if (connfd < 0) {
fprintf(stderr, "accept() failed\n");
@@ -277,10 +292,12 @@ static struct pingpong_dest *pp_server_exch_dest(struct pingpong_context *ctx,
if (!rem_dest)
goto out;
- sscanf(msg, "%x:%x:%x:%s", &rem_dest->lid, &rem_dest->qpn, &rem_dest->psn, gid);
+ sscanf(msg, "%x:%x:%x:%s", &rem_dest->lid, &rem_dest->qpn,
+ &rem_dest->psn, gid);
wire_gid_to_gid(gid, &rem_dest->gid);
- if (pp_connect_ctx(ctx, ib_port, my_dest->psn, mtu, sl, rem_dest, sgid_idx)) {
+ if (pp_connect_ctx(ctx, ib_port, my_dest->psn, mtu, sl, rem_dest,
+ sgid_idx)) {
fprintf(stderr, "Couldn't connect to remote QP\n");
free(rem_dest);
rem_dest = NULL;
@@ -289,56 +306,58 @@ static struct pingpong_dest *pp_server_exch_dest(struct pingpong_context *ctx,
gid_to_wire_gid(&my_dest->gid, gid);
- sprintf(msg, "%04x:%06x:%06x:%s", my_dest->lid, my_dest->qpn, my_dest->psn, gid);
- if (write(connfd, msg, sizeof msg) != sizeof msg) {
- fprintf(stderr, "Couldn't send local address\n");
+ sprintf(msg, "%04x:%06x:%06x:%s", my_dest->lid, my_dest->qpn,
+ my_dest->psn, gid);
+ if (write(connfd, msg, sizeof msg) != sizeof msg ||
+ read(connfd, msg, sizeof msg) != sizeof "done") {
+ fprintf(stderr, "Couldn't send/recv local address\n");
free(rem_dest);
rem_dest = NULL;
goto out;
}
- read(connfd, msg, sizeof msg);
out:
close(connfd);
return rem_dest;
}
-#include <sys/param.h>
-
static struct pingpong_context *pp_init_ctx(struct ibv_device *ib_dev, int size,
int rx_depth, int port,
- int use_event, int is_server)
+ int use_event)
{
struct pingpong_context *ctx;
+ int access_flags = IBV_ACCESS_LOCAL_WRITE;
ctx = calloc(1, sizeof *ctx);
if (!ctx)
return NULL;
- ctx->size = size;
- ctx->rx_depth = rx_depth;
+ ctx->size = size;
+ ctx->send_flags = IBV_SEND_SIGNALED;
+ ctx->rx_depth = rx_depth;
- ctx->buf = malloc(roundup(size, page_size));
+ ctx->buf = memalign(page_size, size);
if (!ctx->buf) {
fprintf(stderr, "Couldn't allocate work buf.\n");
- return NULL;
+ goto clean_ctx;
}
- memset(ctx->buf, 0x7b + is_server, size);
+ /* FIXME memset(ctx->buf, 0, size); */
+ memset(ctx->buf, 0x7b, size);
ctx->context = ibv_open_device(ib_dev);
if (!ctx->context) {
fprintf(stderr, "Couldn't get context for %s\n",
ibv_get_device_name(ib_dev));
- return NULL;
+ goto clean_buffer;
}
if (use_event) {
ctx->channel = ibv_create_comp_channel(ctx->context);
if (!ctx->channel) {
fprintf(stderr, "Couldn't create completion channel\n");
- return NULL;
+ goto clean_device;
}
} else
ctx->channel = NULL;
@@ -346,26 +365,68 @@ static struct pingpong_context *pp_init_ctx(struct ibv_device *ib_dev, int size,
ctx->pd = ibv_alloc_pd(ctx->context);
if (!ctx->pd) {
fprintf(stderr, "Couldn't allocate PD\n");
- return NULL;
+ goto clean_comp_channel;
+ }
+
+ if (use_odp || use_ts) {
+ const uint32_t rc_caps_mask = IBV_ODP_SUPPORT_SEND |
+ IBV_ODP_SUPPORT_RECV;
+ struct ibv_device_attr_ex attrx;
+
+ if (ibv_query_device_ex(ctx->context, NULL, &attrx)) {
+ fprintf(stderr, "Couldn't query device for its features\n");
+ goto clean_comp_channel;
+ }
+
+ if (use_odp) {
+ if (!(attrx.odp_caps.general_caps & IBV_ODP_SUPPORT) ||
+ (attrx.odp_caps.per_transport_caps.rc_odp_caps & rc_caps_mask) != rc_caps_mask) {
+ fprintf(stderr, "The device isn't ODP capable or does not support RC send and receive with ODP\n");
+ goto clean_comp_channel;
+ }
+ access_flags |= IBV_ACCESS_ON_DEMAND;
+ }
+
+ if (use_ts) {
+ if (!attrx.completion_timestamp_mask) {
+ fprintf(stderr, "The device isn't completion timestamp capable\n");
+ goto clean_comp_channel;
+ }
+ ctx->completion_timestamp_mask = attrx.completion_timestamp_mask;
+ }
}
+ ctx->mr = ibv_reg_mr(ctx->pd, ctx->buf, size, access_flags);
- ctx->mr = ibv_reg_mr(ctx->pd, ctx->buf, size, IBV_ACCESS_LOCAL_WRITE);
if (!ctx->mr) {
fprintf(stderr, "Couldn't register MR\n");
- return NULL;
+ goto clean_pd;
}
- ctx->cq = ibv_create_cq(ctx->context, rx_depth + 1, NULL,
- ctx->channel, 0);
- if (!ctx->cq) {
+ if (use_ts) {
+ struct ibv_cq_init_attr_ex attr_ex = {
+ .cqe = rx_depth + 1,
+ .cq_context = NULL,
+ .channel = ctx->channel,
+ .comp_vector = 0,
+ .wc_flags = IBV_WC_EX_WITH_COMPLETION_TIMESTAMP
+ };
+
+ ctx->cq_s.cq_ex = ibv_create_cq_ex(ctx->context, &attr_ex);
+ } else {
+ ctx->cq_s.cq = ibv_create_cq(ctx->context, rx_depth + 1, NULL,
+ ctx->channel, 0);
+ }
+
+ if (!pp_cq(ctx)) {
fprintf(stderr, "Couldn't create CQ\n");
- return NULL;
+ goto clean_mr;
}
{
- struct ibv_qp_init_attr attr = {
- .send_cq = ctx->cq,
- .recv_cq = ctx->cq,
+ struct ibv_qp_attr attr;
+ struct ibv_qp_init_attr init_attr = {
+ .send_cq = pp_cq(ctx),
+ .recv_cq = pp_cq(ctx),
.cap = {
.max_send_wr = 1,
.max_recv_wr = rx_depth,
@@ -375,10 +436,15 @@ static struct pingpong_context *pp_init_ctx(struct ibv_device *ib_dev, int size,
.qp_type = IBV_QPT_RC
};
- ctx->qp = ibv_create_qp(ctx->pd, &attr);
+ ctx->qp = ibv_create_qp(ctx->pd, &init_attr);
if (!ctx->qp) {
fprintf(stderr, "Couldn't create QP\n");
- return NULL;
+ goto clean_cq;
+ }
+
+ ibv_query_qp(ctx->qp, &attr, IBV_QP_CAP, &init_attr);
+ if (init_attr.cap.max_inline_data >= size) {
+ ctx->send_flags |= IBV_SEND_INLINE;
}
}
@@ -396,21 +462,48 @@ static struct pingpong_context *pp_init_ctx(struct ibv_device *ib_dev, int size,
IBV_QP_PORT |
IBV_QP_ACCESS_FLAGS)) {
fprintf(stderr, "Failed to modify QP to INIT\n");
- return NULL;
+ goto clean_qp;
}
}
return ctx;
+
+clean_qp:
+ ibv_destroy_qp(ctx->qp);
+
+clean_cq:
+ ibv_destroy_cq(pp_cq(ctx));
+
+clean_mr:
+ ibv_dereg_mr(ctx->mr);
+
+clean_pd:
+ ibv_dealloc_pd(ctx->pd);
+
+clean_comp_channel:
+ if (ctx->channel)
+ ibv_destroy_comp_channel(ctx->channel);
+
+clean_device:
+ ibv_close_device(ctx->context);
+
+clean_buffer:
+ free(ctx->buf);
+
+clean_ctx:
+ free(ctx);
+
+ return NULL;
}
-int pp_close_ctx(struct pingpong_context *ctx)
+static int pp_close_ctx(struct pingpong_context *ctx)
{
if (ibv_destroy_qp(ctx->qp)) {
fprintf(stderr, "Couldn't destroy QP\n");
return 1;
}
- if (ibv_destroy_cq(ctx->cq)) {
+ if (ibv_destroy_cq(pp_cq(ctx))) {
fprintf(stderr, "Couldn't destroy CQ\n");
return 1;
}
@@ -477,13 +570,96 @@ static int pp_post_send(struct pingpong_context *ctx)
.sg_list = &list,
.num_sge = 1,
.opcode = IBV_WR_SEND,
- .send_flags = IBV_SEND_SIGNALED,
+ .send_flags = ctx->send_flags,
};
struct ibv_send_wr *bad_wr;
return ibv_post_send(ctx->qp, &wr, &bad_wr);
}
+struct ts_params {
+ uint64_t comp_recv_max_time_delta;
+ uint64_t comp_recv_min_time_delta;
+ uint64_t comp_recv_total_time_delta;
+ uint64_t comp_recv_prev_time;
+ int last_comp_with_ts;
+ unsigned int comp_with_time_iters;
+};
+
+static inline int parse_single_wc(struct pingpong_context *ctx, int *scnt,
+ int *rcnt, int *routs, int iters,
+ uint64_t wr_id, enum ibv_wc_status status,
+ uint64_t completion_timestamp,
+ struct ts_params *ts)
+{
+ if (status != IBV_WC_SUCCESS) {
+ fprintf(stderr, "Failed status %s (%d) for wr_id %d\n",
+ ibv_wc_status_str(status),
+ status, (int)wr_id);
+ return 1;
+ }
+
+ switch ((int)wr_id) {
+ case PINGPONG_SEND_WRID:
+ ++(*scnt);
+ break;
+
+ case PINGPONG_RECV_WRID:
+ if (--(*routs) <= 1) {
+ *routs += pp_post_recv(ctx, ctx->rx_depth - *routs);
+ if (*routs < ctx->rx_depth) {
+ fprintf(stderr,
+ "Couldn't post receive (%d)\n",
+ *routs);
+ return 1;
+ }
+ }
+
+ ++(*rcnt);
+ if (use_ts) {
+ if (ts->last_comp_with_ts) {
+ uint64_t delta;
+
+ /* checking whether the clock was wrapped around */
+ if (completion_timestamp >= ts->comp_recv_prev_time)
+ delta = completion_timestamp - ts->comp_recv_prev_time;
+ else
+ delta = ctx->completion_timestamp_mask - ts->comp_recv_prev_time +
+ completion_timestamp + 1;
+
+ ts->comp_recv_max_time_delta = MAX(ts->comp_recv_max_time_delta, delta);
+ ts->comp_recv_min_time_delta = MIN(ts->comp_recv_min_time_delta, delta);
+ ts->comp_recv_total_time_delta += delta;
+ ts->comp_with_time_iters++;
+ }
+
+ ts->comp_recv_prev_time = completion_timestamp;
+ ts->last_comp_with_ts = 1;
+ } else {
+ ts->last_comp_with_ts = 0;
+ }
+
+ break;
+
+ default:
+ fprintf(stderr, "Completion for unknown wr_id %d\n",
+ (int)wr_id);
+ return 1;
+ }
+
+ ctx->pending &= ~(int)wr_id;
+ if (*scnt < iters && !ctx->pending) {
+ if (pp_post_send(ctx)) {
+ fprintf(stderr, "Couldn't post send\n");
+ return 1;
+ }
+ ctx->pending = PINGPONG_RECV_WRID |
+ PINGPONG_SEND_WRID;
+ }
+
+ return 0;
+}
+
static void usage(const char *argv0)
{
printf("Usage:\n");
@@ -501,6 +677,8 @@ static void usage(const char *argv0)
printf(" -l, --sl=<sl> service level value\n");
printf(" -e, --events sleep on CQ events (default poll)\n");
printf(" -g, --gid-idx=<gid index> local port gid index\n");
+ printf(" -o, --odp use on demand paging\n");
+ printf(" -t, --ts get CQE with timestamp\n");
}
int main(int argc, char *argv[])
@@ -513,12 +691,12 @@ int main(int argc, char *argv[])
struct timeval start, end;
char *ib_devname = NULL;
char *servername = NULL;
- int port = 18515;
+ unsigned int port = 18515;
int ib_port = 1;
- int size = 4096;
+ unsigned int size = 4096;
enum ibv_mtu mtu = IBV_MTU_1024;
- int rx_depth = 500;
- int iters = 1000;
+ unsigned int rx_depth = 500;
+ unsigned int iters = 1000;
int use_event = 0;
int routs;
int rcnt, scnt;
@@ -526,6 +704,7 @@ int main(int argc, char *argv[])
int sl = 0;
int gidx = -1;
char gid[33];
+ struct ts_params ts;
srand48(getpid() * time(NULL));
@@ -543,52 +722,56 @@ int main(int argc, char *argv[])
{ .name = "sl", .has_arg = 1, .val = 'l' },
{ .name = "events", .has_arg = 0, .val = 'e' },
{ .name = "gid-idx", .has_arg = 1, .val = 'g' },
- { 0 }
+ { .name = "odp", .has_arg = 0, .val = 'o' },
+ { .name = "ts", .has_arg = 0, .val = 't' },
+ {}
};
- c = getopt_long(argc, argv, "p:d:i:s:m:r:n:l:eg:", long_options, NULL);
+ c = getopt_long(argc, argv, "p:d:i:s:m:r:n:l:eg:ot",
+ long_options, NULL);
+
if (c == -1)
break;
switch (c) {
case 'p':
- port = strtol(optarg, NULL, 0);
- if (port < 0 || port > 65535) {
+ port = strtoul(optarg, NULL, 0);
+ if (port > 65535) {
usage(argv[0]);
return 1;
}
break;
case 'd':
- ib_devname = strdup(optarg);
+ ib_devname = strdupa(optarg);
break;
case 'i':
ib_port = strtol(optarg, NULL, 0);
- if (ib_port < 0) {
+ if (ib_port < 1) {
usage(argv[0]);
return 1;
}
break;
case 's':
- size = strtol(optarg, NULL, 0);
+ size = strtoul(optarg, NULL, 0);
break;
case 'm':
mtu = pp_mtu_to_enum(strtol(optarg, NULL, 0));
- if (mtu < 0) {
+ if (mtu == 0) {
usage(argv[0]);
return 1;
}
break;
case 'r':
- rx_depth = strtol(optarg, NULL, 0);
+ rx_depth = strtoul(optarg, NULL, 0);
break;
case 'n':
- iters = strtol(optarg, NULL, 0);
+ iters = strtoul(optarg, NULL, 0);
break;
case 'l':
@@ -603,6 +786,13 @@ int main(int argc, char *argv[])
gidx = strtol(optarg, NULL, 0);
break;
+ case 'o':
+ use_odp = 1;
+ break;
+ case 't':
+ use_ts = 1;
+ break;
+
default:
usage(argv[0]);
return 1;
@@ -610,12 +800,21 @@ int main(int argc, char *argv[])
}
if (optind == argc - 1)
- servername = strdup(argv[optind]);
+ servername = strdupa(argv[optind]);
else if (optind < argc) {
usage(argv[0]);
return 1;
}
+ if (use_ts) {
+ ts.comp_recv_max_time_delta = 0;
+ ts.comp_recv_min_time_delta = 0xffffffff;
+ ts.comp_recv_total_time_delta = 0;
+ ts.comp_recv_prev_time = 0;
+ ts.last_comp_with_ts = 0;
+ ts.comp_with_time_iters = 0;
+ }
+
page_size = sysconf(_SC_PAGESIZE);
dev_list = ibv_get_device_list(NULL);
@@ -642,7 +841,7 @@ int main(int argc, char *argv[])
}
}
- ctx = pp_init_ctx(ib_dev, size, rx_depth, ib_port, use_event, !servername);
+ ctx = pp_init_ctx(ib_dev, size, rx_depth, ib_port, use_event);
if (!ctx)
return 1;
@@ -653,7 +852,7 @@ int main(int argc, char *argv[])
}
if (use_event)
- if (ibv_req_notify_cq(ctx->cq, 0)) {
+ if (ibv_req_notify_cq(pp_cq(ctx), 0)) {
fprintf(stderr, "Couldn't request CQ notification\n");
return 1;
}
@@ -665,14 +864,15 @@ int main(int argc, char *argv[])
}
my_dest.lid = ctx->portinfo.lid;
- if (ctx->portinfo.link_layer == IBV_LINK_LAYER_INFINIBAND && !my_dest.lid) {
+ if (ctx->portinfo.link_layer != IBV_LINK_LAYER_ETHERNET &&
+ !my_dest.lid) {
fprintf(stderr, "Couldn't get local LID\n");
return 1;
}
if (gidx >= 0) {
if (ibv_query_gid(ctx->context, ib_port, gidx, &my_dest.gid)) {
- fprintf(stderr, "Could not get local gid for gid index %d\n", gidx);
+ fprintf(stderr, "can't read sgid of index %d\n", gidx);
return 1;
}
} else
@@ -688,7 +888,8 @@ int main(int argc, char *argv[])
if (servername)
rem_dest = pp_client_exch_dest(servername, port, &my_dest);
else
- rem_dest = pp_server_exch_dest(ctx, ib_port, mtu, port, sl, &my_dest, gidx);
+ rem_dest = pp_server_exch_dest(ctx, ib_port, mtu, port, sl,
+ &my_dest, gidx);
if (!rem_dest)
return 1;
@@ -698,7 +899,8 @@ int main(int argc, char *argv[])
rem_dest->lid, rem_dest->qpn, rem_dest->psn, gid);
if (servername)
- if (pp_connect_ctx(ctx, ib_port, my_dest.psn, mtu, sl, rem_dest, gidx))
+ if (pp_connect_ctx(ctx, ib_port, my_dest.psn, mtu, sl, rem_dest,
+ gidx))
return 1;
ctx->pending = PINGPONG_RECV_WRID;
@@ -718,6 +920,8 @@ int main(int argc, char *argv[])
rcnt = scnt = 0;
while (rcnt < iters || scnt < iters) {
+ int ret;
+
if (use_event) {
struct ibv_cq *ev_cq;
void *ev_ctx;
@@ -729,72 +933,73 @@ int main(int argc, char *argv[])
++num_cq_events;
- if (ev_cq != ctx->cq) {
+ if (ev_cq != pp_cq(ctx)) {
fprintf(stderr, "CQ event for unknown CQ %p\n", ev_cq);
return 1;
}
- if (ibv_req_notify_cq(ctx->cq, 0)) {
+ if (ibv_req_notify_cq(pp_cq(ctx), 0)) {
fprintf(stderr, "Couldn't request CQ notification\n");
return 1;
}
}
- {
- struct ibv_wc wc[2];
+ if (use_ts) {
+ struct ibv_poll_cq_attr attr = {};
+
+ do {
+ ret = ibv_start_poll(ctx->cq_s.cq_ex, &attr);
+ } while (!use_event && ret == ENOENT);
+
+ if (ret) {
+ fprintf(stderr, "poll CQ failed %d\n", ret);
+ return ret;
+ }
+ ret = parse_single_wc(ctx, &scnt, &rcnt, &routs,
+ iters,
+ ctx->cq_s.cq_ex->wr_id,
+ ctx->cq_s.cq_ex->status,
+ ibv_wc_read_completion_ts(ctx->cq_s.cq_ex),
+ &ts);
+ if (ret) {
+ ibv_end_poll(ctx->cq_s.cq_ex);
+ return ret;
+ }
+ ret = ibv_next_poll(ctx->cq_s.cq_ex);
+ if (!ret)
+ ret = parse_single_wc(ctx, &scnt, &rcnt, &routs,
+ iters,
+ ctx->cq_s.cq_ex->wr_id,
+ ctx->cq_s.cq_ex->status,
+ ibv_wc_read_completion_ts(ctx->cq_s.cq_ex),
+ &ts);
+ ibv_end_poll(ctx->cq_s.cq_ex);
+ if (ret && ret != ENOENT) {
+ fprintf(stderr, "poll CQ failed %d\n", ret);
+ return ret;
+ }
+ } else {
int ne, i;
+ struct ibv_wc wc[2];
do {
- ne = ibv_poll_cq(ctx->cq, 2, wc);
+ ne = ibv_poll_cq(pp_cq(ctx), 2, wc);
if (ne < 0) {
fprintf(stderr, "poll CQ failed %d\n", ne);
return 1;
}
-
} while (!use_event && ne < 1);
for (i = 0; i < ne; ++i) {
- if (wc[i].status != IBV_WC_SUCCESS) {
- fprintf(stderr, "Failed status %s (%d) for wr_id %d\n",
- ibv_wc_status_str(wc[i].status),
- wc[i].status, (int) wc[i].wr_id);
+ ret = parse_single_wc(ctx, &scnt, &rcnt, &routs,
+ iters,
+ wc[i].wr_id,
+ wc[i].status,
+ 0, &ts);
+ if (ret) {
+ fprintf(stderr, "parse WC failed %d\n", ne);
return 1;
}
-
- switch ((int) wc[i].wr_id) {
- case PINGPONG_SEND_WRID:
- ++scnt;
- break;
-
- case PINGPONG_RECV_WRID:
- if (--routs <= 1) {
- routs += pp_post_recv(ctx, ctx->rx_depth - routs);
- if (routs < ctx->rx_depth) {
- fprintf(stderr,
- "Couldn't post receive (%d)\n",
- routs);
- return 1;
- }
- }
-
- ++rcnt;
- break;
-
- default:
- fprintf(stderr, "Completion for unknown wr_id %d\n",
- (int) wc[i].wr_id);
- return 1;
- }
-
- ctx->pending &= ~(int) wc[i].wr_id;
- if (scnt < iters && !ctx->pending) {
- if (pp_post_send(ctx)) {
- fprintf(stderr, "Couldn't post send\n");
- return 1;
- }
- ctx->pending = PINGPONG_RECV_WRID |
- PINGPONG_SEND_WRID;
- }
}
}
}
@@ -813,9 +1018,18 @@ int main(int argc, char *argv[])
bytes, usec / 1000000., bytes * 8. / usec);
printf("%d iters in %.2f seconds = %.2f usec/iter\n",
iters, usec / 1000000., usec / iters);
+
+ if (use_ts && ts.comp_with_time_iters) {
+ printf("Max receive completion clock cycles = %" PRIu64 "\n",
+ ts.comp_recv_max_time_delta);
+ printf("Min receive completion clock cycles = %" PRIu64 "\n",
+ ts.comp_recv_min_time_delta);
+ printf("Average receive completion clock cycles = %f\n",
+ (double)ts.comp_recv_total_time_delta / ts.comp_with_time_iters);
+ }
}
- ibv_ack_cq_events(ctx->cq, num_cq_events);
+ ibv_ack_cq_events(pp_cq(ctx), num_cq_events);
if (pp_close_ctx(ctx))
return 1;
diff --git a/contrib/ofed/libibverbs/examples/srq_pingpong.c b/contrib/ofed/libibverbs/examples/srq_pingpong.c
index 907eaf6..ff3a1f3 100644
--- a/contrib/ofed/libibverbs/examples/srq_pingpong.c
+++ b/contrib/ofed/libibverbs/examples/srq_pingpong.c
@@ -29,10 +29,8 @@
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
-
-#if HAVE_CONFIG_H
-# include <config.h>
-#endif /* HAVE_CONFIG_H */
+#define _GNU_SOURCE
+#include <config.h>
#include <stdio.h>
#include <stdlib.h>
@@ -42,6 +40,7 @@
#include <sys/socket.h>
#include <sys/time.h>
#include <netdb.h>
+#include <stdlib.h>
#include <getopt.h>
#include <arpa/inet.h>
#include <time.h>
@@ -67,6 +66,7 @@ struct pingpong_context {
struct ibv_qp *qp[MAX_QP];
void *buf;
int size;
+ int send_flags;
int num_qp;
int rx_depth;
int pending[MAX_QP];
@@ -180,7 +180,7 @@ static struct pingpong_dest *pp_client_exch_dest(const char *servername, int por
}
}
- freeaddrinfo(res);
+ freeaddrinfo_null(res);
free(service);
if (sockfd < 0) {
@@ -190,7 +190,8 @@ static struct pingpong_dest *pp_client_exch_dest(const char *servername, int por
for (i = 0; i < MAX_QP; ++i) {
gid_to_wire_gid(&my_dest[i].gid, gid);
- sprintf(msg, "%04x:%06x:%06x:%s", my_dest[i].lid, my_dest[i].qpn, my_dest[i].psn, gid);
+ sprintf(msg, "%04x:%06x:%06x:%s", my_dest[i].lid,
+ my_dest[i].qpn, my_dest[i].psn, gid);
if (write(sockfd, msg, sizeof msg) != sizeof msg) {
fprintf(stderr, "Couldn't send local address\n");
goto out;
@@ -214,13 +215,15 @@ static struct pingpong_dest *pp_client_exch_dest(const char *servername, int por
n += r;
}
- sscanf(msg, "%x:%x:%x:%s",
- &rem_dest[i].lid, &rem_dest[i].qpn, &rem_dest[i].psn, gid);
+ sscanf(msg, "%x:%x:%x:%s", &rem_dest[i].lid, &rem_dest[i].qpn,
+ &rem_dest[i].psn, gid);
wire_gid_to_gid(gid, &rem_dest[i].gid);
}
- write(sockfd, "done", sizeof "done");
-
+ if (write(sockfd, "done", sizeof "done") != sizeof "done") {
+ perror("client write");
+ goto out;
+ }
out:
close(sockfd);
return rem_dest;
@@ -272,7 +275,7 @@ static struct pingpong_dest *pp_server_exch_dest(struct pingpong_context *ctx,
}
}
- freeaddrinfo(res);
+ freeaddrinfo_null(res);
free(service);
if (sockfd < 0) {
@@ -281,7 +284,7 @@ static struct pingpong_dest *pp_server_exch_dest(struct pingpong_context *ctx,
}
listen(sockfd, 1);
- connfd = accept(sockfd, NULL, 0);
+ connfd = accept(sockfd, NULL, NULL);
close(sockfd);
if (connfd < 0) {
fprintf(stderr, "accept() failed\n");
@@ -305,12 +308,13 @@ static struct pingpong_dest *pp_server_exch_dest(struct pingpong_context *ctx,
n += r;
}
- sscanf(msg, "%x:%x:%x:%s",
- &rem_dest[i].lid, &rem_dest[i].qpn, &rem_dest[i].psn, gid);
+ sscanf(msg, "%x:%x:%x:%s", &rem_dest[i].lid, &rem_dest[i].qpn,
+ &rem_dest[i].psn, gid);
wire_gid_to_gid(gid, &rem_dest[i].gid);
}
- if (pp_connect_ctx(ctx, ib_port, mtu, sl, my_dest, rem_dest, sgid_idx)) {
+ if (pp_connect_ctx(ctx, ib_port, mtu, sl, my_dest, rem_dest,
+ sgid_idx)) {
fprintf(stderr, "Couldn't connect to remote QP\n");
free(rem_dest);
rem_dest = NULL;
@@ -319,7 +323,8 @@ static struct pingpong_dest *pp_server_exch_dest(struct pingpong_context *ctx,
for (i = 0; i < MAX_QP; ++i) {
gid_to_wire_gid(&my_dest[i].gid, gid);
- sprintf(msg, "%04x:%06x:%06x:%s", my_dest[i].lid, my_dest[i].qpn, my_dest[i].psn, gid);
+ sprintf(msg, "%04x:%06x:%06x:%s", my_dest[i].lid,
+ my_dest[i].qpn, my_dest[i].psn, gid);
if (write(connfd, msg, sizeof msg) != sizeof msg) {
fprintf(stderr, "Couldn't send local address\n");
free(rem_dest);
@@ -328,7 +333,12 @@ static struct pingpong_dest *pp_server_exch_dest(struct pingpong_context *ctx,
}
}
- read(connfd, msg, sizeof msg);
+ if (read(connfd, msg, sizeof msg) != sizeof "done") {
+ perror("client write");
+ free(rem_dest);
+ rem_dest = NULL;
+ goto out;
+ }
out:
close(connfd);
@@ -346,14 +356,15 @@ static struct pingpong_context *pp_init_ctx(struct ibv_device *ib_dev, int size,
if (!ctx)
return NULL;
- ctx->size = size;
- ctx->num_qp = num_qp;
- ctx->rx_depth = rx_depth;
+ ctx->size = size;
+ ctx->send_flags = IBV_SEND_SIGNALED;
+ ctx->num_qp = num_qp;
+ ctx->rx_depth = rx_depth;
- ctx->buf = malloc(roundup(size, page_size));
+ ctx->buf = memalign(page_size, size);
if (!ctx->buf) {
fprintf(stderr, "Couldn't allocate work buf.\n");
- return NULL;
+ goto clean_ctx;
}
memset(ctx->buf, 0, size);
@@ -362,14 +373,14 @@ static struct pingpong_context *pp_init_ctx(struct ibv_device *ib_dev, int size,
if (!ctx->context) {
fprintf(stderr, "Couldn't get context for %s\n",
ibv_get_device_name(ib_dev));
- return NULL;
+ goto clean_buffer;
}
if (use_event) {
ctx->channel = ibv_create_comp_channel(ctx->context);
if (!ctx->channel) {
fprintf(stderr, "Couldn't create completion channel\n");
- return NULL;
+ goto clean_device;
}
} else
ctx->channel = NULL;
@@ -377,20 +388,20 @@ static struct pingpong_context *pp_init_ctx(struct ibv_device *ib_dev, int size,
ctx->pd = ibv_alloc_pd(ctx->context);
if (!ctx->pd) {
fprintf(stderr, "Couldn't allocate PD\n");
- return NULL;
+ goto clean_comp_channel;
}
ctx->mr = ibv_reg_mr(ctx->pd, ctx->buf, size, IBV_ACCESS_LOCAL_WRITE);
if (!ctx->mr) {
fprintf(stderr, "Couldn't register MR\n");
- return NULL;
+ goto clean_pd;
}
ctx->cq = ibv_create_cq(ctx->context, rx_depth + num_qp, NULL,
ctx->channel, 0);
if (!ctx->cq) {
fprintf(stderr, "Couldn't create CQ\n");
- return NULL;
+ goto clean_mr;
}
{
@@ -404,12 +415,13 @@ static struct pingpong_context *pp_init_ctx(struct ibv_device *ib_dev, int size,
ctx->srq = ibv_create_srq(ctx->pd, &attr);
if (!ctx->srq) {
fprintf(stderr, "Couldn't create SRQ\n");
- return NULL;
+ goto clean_cq;
}
}
for (i = 0; i < num_qp; ++i) {
- struct ibv_qp_init_attr attr = {
+ struct ibv_qp_attr attr;
+ struct ibv_qp_init_attr init_attr = {
.send_cq = ctx->cq,
.recv_cq = ctx->cq,
.srq = ctx->srq,
@@ -420,10 +432,14 @@ static struct pingpong_context *pp_init_ctx(struct ibv_device *ib_dev, int size,
.qp_type = IBV_QPT_RC
};
- ctx->qp[i] = ibv_create_qp(ctx->pd, &attr);
+ ctx->qp[i] = ibv_create_qp(ctx->pd, &init_attr);
if (!ctx->qp[i]) {
fprintf(stderr, "Couldn't create QP[%d]\n", i);
- return NULL;
+ goto clean_qps;
+ }
+ ibv_query_qp(ctx->qp[i], &attr, IBV_QP_CAP, &init_attr);
+ if (init_attr.cap.max_inline_data >= size) {
+ ctx->send_flags |= IBV_SEND_INLINE;
}
}
@@ -441,14 +457,47 @@ static struct pingpong_context *pp_init_ctx(struct ibv_device *ib_dev, int size,
IBV_QP_PORT |
IBV_QP_ACCESS_FLAGS)) {
fprintf(stderr, "Failed to modify QP[%d] to INIT\n", i);
- return NULL;
+ goto clean_qps_full;
}
}
return ctx;
+
+clean_qps_full:
+ i = num_qp;
+
+clean_qps:
+ for (--i; i >= 0; --i)
+ ibv_destroy_qp(ctx->qp[i]);
+
+ ibv_destroy_srq(ctx->srq);
+
+clean_cq:
+ ibv_destroy_cq(ctx->cq);
+
+clean_mr:
+ ibv_dereg_mr(ctx->mr);
+
+clean_pd:
+ ibv_dealloc_pd(ctx->pd);
+
+clean_comp_channel:
+ if (ctx->channel)
+ ibv_destroy_comp_channel(ctx->channel);
+
+clean_device:
+ ibv_close_device(ctx->context);
+
+clean_buffer:
+ free(ctx->buf);
+
+clean_ctx:
+ free(ctx);
+
+ return NULL;
}
-int pp_close_ctx(struct pingpong_context *ctx, int num_qp)
+static int pp_close_ctx(struct pingpong_context *ctx, int num_qp)
{
int i;
@@ -531,7 +580,7 @@ static int pp_post_send(struct pingpong_context *ctx, int qp_index)
.sg_list = &list,
.num_sge = 1,
.opcode = IBV_WR_SEND,
- .send_flags = IBV_SEND_SIGNALED,
+ .send_flags = ctx->send_flags,
};
struct ibv_send_wr *bad_wr;
@@ -580,13 +629,13 @@ int main(int argc, char *argv[])
struct timeval start, end;
char *ib_devname = NULL;
char *servername = NULL;
- int port = 18515;
+ unsigned int port = 18515;
int ib_port = 1;
- int size = 4096;
+ unsigned int size = 4096;
enum ibv_mtu mtu = IBV_MTU_1024;
- int num_qp = 16;
- int rx_depth = 500;
- int iters = 1000;
+ unsigned int num_qp = 16;
+ unsigned int rx_depth = 500;
+ unsigned int iters = 1000;
int use_event = 0;
int routs;
int rcnt, scnt;
@@ -614,56 +663,61 @@ int main(int argc, char *argv[])
{ .name = "sl", .has_arg = 1, .val = 'l' },
{ .name = "events", .has_arg = 0, .val = 'e' },
{ .name = "gid-idx", .has_arg = 1, .val = 'g' },
- { 0 }
+ {}
};
- c = getopt_long(argc, argv, "p:d:i:s:m:q:r:n:l:eg:", long_options, NULL);
+ c = getopt_long(argc, argv, "p:d:i:s:m:q:r:n:l:eg:",
+ long_options, NULL);
if (c == -1)
break;
switch (c) {
case 'p':
- port = strtol(optarg, NULL, 0);
- if (port < 0 || port > 65535) {
+ port = strtoul(optarg, NULL, 0);
+ if (port > 65535) {
usage(argv[0]);
return 1;
}
break;
case 'd':
- ib_devname = strdup(optarg);
+ ib_devname = strdupa(optarg);
break;
case 'i':
ib_port = strtol(optarg, NULL, 0);
- if (ib_port < 0) {
+ if (ib_port < 1) {
usage(argv[0]);
return 1;
}
break;
case 's':
- size = strtol(optarg, NULL, 0);
+ size = strtoul(optarg, NULL, 0);
+ if (size < 1) {
+ usage(argv[0]);
+ return 1;
+ }
break;
case 'm':
mtu = pp_mtu_to_enum(strtol(optarg, NULL, 0));
- if (mtu < 0) {
+ if (mtu == 0) {
usage(argv[0]);
return 1;
}
break;
case 'q':
- num_qp = strtol(optarg, NULL, 0);
+ num_qp = strtoul(optarg, NULL, 0);
break;
case 'r':
- rx_depth = strtol(optarg, NULL, 0);
+ rx_depth = strtoul(optarg, NULL, 0);
break;
case 'n':
- iters = strtol(optarg, NULL, 0);
+ iters = strtoul(optarg, NULL, 0);
break;
case 'l':
@@ -685,7 +739,7 @@ int main(int argc, char *argv[])
}
if (optind == argc - 1)
- servername = strdup(argv[optind]);
+ servername = strdupa(argv[optind]);
else if (optind < argc) {
usage(argv[0]);
return 1;
@@ -716,7 +770,6 @@ int main(int argc, char *argv[])
return 1;
}
} else {
- int i;
for (i = 0; dev_list[i]; ++i)
if (!strcmp(ibv_get_device_name(dev_list[i]), ib_devname))
break;
@@ -753,28 +806,33 @@ int main(int argc, char *argv[])
my_dest[i].qpn = ctx->qp[i]->qp_num;
my_dest[i].psn = lrand48() & 0xffffff;
my_dest[i].lid = ctx->portinfo.lid;
- if (ctx->portinfo.link_layer == IBV_LINK_LAYER_INFINIBAND && !my_dest[i].lid) {
+ if (ctx->portinfo.link_layer != IBV_LINK_LAYER_ETHERNET
+ && !my_dest[i].lid) {
fprintf(stderr, "Couldn't get local LID\n");
return 1;
}
if (gidx >= 0) {
- if (ibv_query_gid(ctx->context, ib_port, gidx, &my_dest[i].gid)) {
- fprintf(stderr, "Could not get local gid for gid index %d\n", gidx);
+ if (ibv_query_gid(ctx->context, ib_port, gidx,
+ &my_dest[i].gid)) {
+ fprintf(stderr, "Could not get local gid for "
+ "gid index %d\n", gidx);
return 1;
}
} else
memset(&my_dest[i].gid, 0, sizeof my_dest[i].gid);
inet_ntop(AF_INET6, &my_dest[i].gid, gid, sizeof gid);
- printf(" local address: LID 0x%04x, QPN 0x%06x, PSN 0x%06x, GID %s\n",
- my_dest[i].lid, my_dest[i].qpn, my_dest[i].psn, gid);
+ printf(" local address: LID 0x%04x, QPN 0x%06x, PSN 0x%06x, "
+ "GID %s\n", my_dest[i].lid, my_dest[i].qpn,
+ my_dest[i].psn, gid);
}
if (servername)
rem_dest = pp_client_exch_dest(servername, port, my_dest);
else
- rem_dest = pp_server_exch_dest(ctx, ib_port, mtu, port, sl, my_dest, gidx);
+ rem_dest = pp_server_exch_dest(ctx, ib_port, mtu, port, sl,
+ my_dest, gidx);
if (!rem_dest)
return 1;
@@ -783,12 +841,14 @@ int main(int argc, char *argv[])
for (i = 0; i < num_qp; ++i) {
inet_ntop(AF_INET6, &rem_dest[i].gid, gid, sizeof gid);
- printf(" remote address: LID 0x%04x, QPN 0x%06x, PSN 0x%06x, GID %s\n",
- rem_dest[i].lid, rem_dest[i].qpn, rem_dest[i].psn, gid);
+ printf(" remote address: LID 0x%04x, QPN 0x%06x, PSN 0x%06x, "
+ "GID %s\n", rem_dest[i].lid, rem_dest[i].qpn,
+ rem_dest[i].psn, gid);
}
if (servername)
- if (pp_connect_ctx(ctx, ib_port, mtu, sl, my_dest, rem_dest, gidx))
+ if (pp_connect_ctx(ctx, ib_port, mtu, sl, my_dest, rem_dest,
+ gidx))
return 1;
if (servername)
diff --git a/contrib/ofed/libibverbs/examples/uc_pingpong.c b/contrib/ofed/libibverbs/examples/uc_pingpong.c
index 85bdcda..712007c 100644
--- a/contrib/ofed/libibverbs/examples/uc_pingpong.c
+++ b/contrib/ofed/libibverbs/examples/uc_pingpong.c
@@ -29,10 +29,8 @@
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
-
-#if HAVE_CONFIG_H
-# include <config.h>
-#endif /* HAVE_CONFIG_H */
+#define _GNU_SOURCE
+#include <config.h>
#include <stdio.h>
#include <stdlib.h>
@@ -42,6 +40,7 @@
#include <sys/socket.h>
#include <sys/time.h>
#include <netdb.h>
+#include <stdlib.h>
#include <getopt.h>
#include <arpa/inet.h>
#include <time.h>
@@ -64,9 +63,10 @@ struct pingpong_context {
struct ibv_qp *qp;
void *buf;
int size;
+ int send_flags;
int rx_depth;
int pending;
- struct ibv_port_attr portinfo;
+ struct ibv_port_attr portinfo;
};
struct pingpong_dest {
@@ -100,7 +100,6 @@ static int pp_connect_ctx(struct pingpong_context *ctx, int port, int my_psn,
attr.ah_attr.grh.dgid = dest->gid;
attr.ah_attr.grh.sgid_index = sgid_idx;
}
-
if (ibv_modify_qp(ctx->qp, &attr,
IBV_QP_STATE |
IBV_QP_AV |
@@ -159,7 +158,7 @@ static struct pingpong_dest *pp_client_exch_dest(const char *servername, int por
}
}
- freeaddrinfo(res);
+ freeaddrinfo_null(res);
free(service);
if (sockfd < 0) {
@@ -168,25 +167,27 @@ static struct pingpong_dest *pp_client_exch_dest(const char *servername, int por
}
gid_to_wire_gid(&my_dest->gid, gid);
- sprintf(msg, "%04x:%06x:%06x:%s", my_dest->lid, my_dest->qpn, my_dest->psn, gid);
+ sprintf(msg, "%04x:%06x:%06x:%s", my_dest->lid, my_dest->qpn,
+ my_dest->psn, gid);
if (write(sockfd, msg, sizeof msg) != sizeof msg) {
fprintf(stderr, "Couldn't send local address\n");
goto out;
}
- if (read(sockfd, msg, sizeof msg) != sizeof msg) {
- perror("client read");
- fprintf(stderr, "Couldn't read remote address\n");
+ if (read(sockfd, msg, sizeof msg) != sizeof msg ||
+ write(sockfd, "done", sizeof "done") != sizeof "done") {
+ perror("client read/write");
+ fprintf(stderr, "Couldn't read/write remote address\n");
goto out;
}
- write(sockfd, "done", sizeof "done");
rem_dest = malloc(sizeof *rem_dest);
if (!rem_dest)
goto out;
- sscanf(msg, "%x:%x:%x:%s", &rem_dest->lid, &rem_dest->qpn, &rem_dest->psn, gid);
+ sscanf(msg, "%x:%x:%x:%s", &rem_dest->lid, &rem_dest->qpn,
+ &rem_dest->psn, gid);
wire_gid_to_gid(gid, &rem_dest->gid);
out:
@@ -238,7 +239,7 @@ static struct pingpong_dest *pp_server_exch_dest(struct pingpong_context *ctx,
}
}
- freeaddrinfo(res);
+ freeaddrinfo_null(res);
free(service);
if (sockfd < 0) {
@@ -247,7 +248,7 @@ static struct pingpong_dest *pp_server_exch_dest(struct pingpong_context *ctx,
}
listen(sockfd, 1);
- connfd = accept(sockfd, NULL, 0);
+ connfd = accept(sockfd, NULL, NULL);
close(sockfd);
if (connfd < 0) {
fprintf(stderr, "accept() failed\n");
@@ -265,27 +266,30 @@ static struct pingpong_dest *pp_server_exch_dest(struct pingpong_context *ctx,
if (!rem_dest)
goto out;
- sscanf(msg, "%x:%x:%x:%s", &rem_dest->lid, &rem_dest->qpn, &rem_dest->psn, gid);
+ sscanf(msg, "%x:%x:%x:%s", &rem_dest->lid, &rem_dest->qpn,
+ &rem_dest->psn, gid);
wire_gid_to_gid(gid, &rem_dest->gid);
- if (pp_connect_ctx(ctx, ib_port, my_dest->psn, mtu, sl, rem_dest, sgid_idx)) {
+ if (pp_connect_ctx(ctx, ib_port, my_dest->psn, mtu, sl, rem_dest,
+ sgid_idx)) {
fprintf(stderr, "Couldn't connect to remote QP\n");
free(rem_dest);
rem_dest = NULL;
goto out;
}
+
gid_to_wire_gid(&my_dest->gid, gid);
- sprintf(msg, "%04x:%06x:%06x:%s", my_dest->lid, my_dest->qpn, my_dest->psn, gid);
- if (write(connfd, msg, sizeof msg) != sizeof msg) {
- fprintf(stderr, "Couldn't send local address\n");
+ sprintf(msg, "%04x:%06x:%06x:%s", my_dest->lid, my_dest->qpn,
+ my_dest->psn, gid);
+ if (write(connfd, msg, sizeof msg) != sizeof msg ||
+ read(connfd, msg, sizeof msg) != sizeof "done") {
+ fprintf(stderr, "Couldn't send/recv local address\n");
free(rem_dest);
rem_dest = NULL;
goto out;
}
- read(connfd, msg, sizeof msg);
-
out:
close(connfd);
return rem_dest;
@@ -301,29 +305,31 @@ static struct pingpong_context *pp_init_ctx(struct ibv_device *ib_dev, int size,
if (!ctx)
return NULL;
- ctx->size = size;
- ctx->rx_depth = rx_depth;
+ ctx->size = size;
+ ctx->send_flags = IBV_SEND_SIGNALED;
+ ctx->rx_depth = rx_depth;
- ctx->buf = malloc(roundup(size, page_size));
+ ctx->buf = memalign(page_size, size);
if (!ctx->buf) {
fprintf(stderr, "Couldn't allocate work buf.\n");
- return NULL;
+ goto clean_ctx;
}
- memset(ctx->buf, 0, size);
+ /* FIXME memset(ctx->buf, 0, size); */
+ memset(ctx->buf, 0x7b, size);
ctx->context = ibv_open_device(ib_dev);
if (!ctx->context) {
fprintf(stderr, "Couldn't get context for %s\n",
ibv_get_device_name(ib_dev));
- return NULL;
+ goto clean_buffer;
}
if (use_event) {
ctx->channel = ibv_create_comp_channel(ctx->context);
if (!ctx->channel) {
fprintf(stderr, "Couldn't create completion channel\n");
- return NULL;
+ goto clean_device;
}
} else
ctx->channel = NULL;
@@ -331,24 +337,25 @@ static struct pingpong_context *pp_init_ctx(struct ibv_device *ib_dev, int size,
ctx->pd = ibv_alloc_pd(ctx->context);
if (!ctx->pd) {
fprintf(stderr, "Couldn't allocate PD\n");
- return NULL;
+ goto clean_comp_channel;
}
ctx->mr = ibv_reg_mr(ctx->pd, ctx->buf, size, IBV_ACCESS_LOCAL_WRITE);
if (!ctx->mr) {
fprintf(stderr, "Couldn't register MR\n");
- return NULL;
+ goto clean_pd;
}
ctx->cq = ibv_create_cq(ctx->context, rx_depth + 1, NULL,
ctx->channel, 0);
if (!ctx->cq) {
fprintf(stderr, "Couldn't create CQ\n");
- return NULL;
+ goto clean_mr;
}
{
- struct ibv_qp_init_attr attr = {
+ struct ibv_qp_attr attr;
+ struct ibv_qp_init_attr init_attr = {
.send_cq = ctx->cq,
.recv_cq = ctx->cq,
.cap = {
@@ -360,10 +367,14 @@ static struct pingpong_context *pp_init_ctx(struct ibv_device *ib_dev, int size,
.qp_type = IBV_QPT_UC
};
- ctx->qp = ibv_create_qp(ctx->pd, &attr);
+ ctx->qp = ibv_create_qp(ctx->pd, &init_attr);
if (!ctx->qp) {
fprintf(stderr, "Couldn't create QP\n");
- return NULL;
+ goto clean_cq;
+ }
+ ibv_query_qp(ctx->qp, &attr, IBV_QP_CAP, &init_attr);
+ if (init_attr.cap.max_inline_data >= size) {
+ ctx->send_flags |= IBV_SEND_INLINE;
}
}
@@ -381,14 +392,41 @@ static struct pingpong_context *pp_init_ctx(struct ibv_device *ib_dev, int size,
IBV_QP_PORT |
IBV_QP_ACCESS_FLAGS)) {
fprintf(stderr, "Failed to modify QP to INIT\n");
- return NULL;
+ goto clean_qp;
}
}
return ctx;
+
+clean_qp:
+ ibv_destroy_qp(ctx->qp);
+
+clean_cq:
+ ibv_destroy_cq(ctx->cq);
+
+clean_mr:
+ ibv_dereg_mr(ctx->mr);
+
+clean_pd:
+ ibv_dealloc_pd(ctx->pd);
+
+clean_comp_channel:
+ if (ctx->channel)
+ ibv_destroy_comp_channel(ctx->channel);
+
+clean_device:
+ ibv_close_device(ctx->context);
+
+clean_buffer:
+ free(ctx->buf);
+
+clean_ctx:
+ free(ctx);
+
+ return NULL;
}
-int pp_close_ctx(struct pingpong_context *ctx)
+static int pp_close_ctx(struct pingpong_context *ctx)
{
if (ibv_destroy_qp(ctx->qp)) {
fprintf(stderr, "Couldn't destroy QP\n");
@@ -462,7 +500,7 @@ static int pp_post_send(struct pingpong_context *ctx)
.sg_list = &list,
.num_sge = 1,
.opcode = IBV_WR_SEND,
- .send_flags = IBV_SEND_SIGNALED,
+ .send_flags = ctx->send_flags,
};
struct ibv_send_wr *bad_wr;
@@ -498,12 +536,12 @@ int main(int argc, char *argv[])
struct timeval start, end;
char *ib_devname = NULL;
char *servername = NULL;
- int port = 18515;
+ unsigned int port = 18515;
int ib_port = 1;
- int size = 4096;
+ unsigned int size = 4096;
enum ibv_mtu mtu = IBV_MTU_1024;
- int rx_depth = 500;
- int iters = 1000;
+ unsigned int rx_depth = 500;
+ unsigned int iters = 1000;
int use_event = 0;
int routs;
int rcnt, scnt;
@@ -528,52 +566,53 @@ int main(int argc, char *argv[])
{ .name = "sl", .has_arg = 1, .val = 'l' },
{ .name = "events", .has_arg = 0, .val = 'e' },
{ .name = "gid-idx", .has_arg = 1, .val = 'g' },
- { 0 }
+ {}
};
- c = getopt_long(argc, argv, "p:d:i:s:m:r:n:l:eg:", long_options, NULL);
+ c = getopt_long(argc, argv, "p:d:i:s:m:r:n:l:eg:",
+ long_options, NULL);
if (c == -1)
break;
switch (c) {
case 'p':
- port = strtol(optarg, NULL, 0);
- if (port < 0 || port > 65535) {
+ port = strtoul(optarg, NULL, 0);
+ if (port > 65535) {
usage(argv[0]);
return 1;
}
break;
case 'd':
- ib_devname = strdup(optarg);
+ ib_devname = strdupa(optarg);
break;
case 'i':
ib_port = strtol(optarg, NULL, 0);
- if (ib_port < 0) {
+ if (ib_port < 1) {
usage(argv[0]);
return 1;
}
break;
case 's':
- size = strtol(optarg, NULL, 0);
+ size = strtoul(optarg, NULL, 0);
break;
case 'm':
mtu = pp_mtu_to_enum(strtol(optarg, NULL, 0));
- if (mtu < 0) {
+ if (mtu == 0) {
usage(argv[0]);
return 1;
}
break;
case 'r':
- rx_depth = strtol(optarg, NULL, 0);
+ rx_depth = strtoul(optarg, NULL, 0);
break;
case 'n':
- iters = strtol(optarg, NULL, 0);
+ iters = strtoul(optarg, NULL, 0);
break;
case 'l':
@@ -595,7 +634,7 @@ int main(int argc, char *argv[])
}
if (optind == argc - 1)
- servername = strdup(argv[optind]);
+ servername = strdupa(argv[optind]);
else if (optind < argc) {
usage(argv[0]);
return 1;
@@ -643,20 +682,22 @@ int main(int argc, char *argv[])
return 1;
}
+
if (pp_get_port_info(ctx->context, ib_port, &ctx->portinfo)) {
fprintf(stderr, "Couldn't get port info\n");
return 1;
}
my_dest.lid = ctx->portinfo.lid;
- if (ctx->portinfo.link_layer == IBV_LINK_LAYER_INFINIBAND && !my_dest.lid) {
+ if (ctx->portinfo.link_layer != IBV_LINK_LAYER_ETHERNET &&
+ !my_dest.lid) {
fprintf(stderr, "Couldn't get local LID\n");
return 1;
}
if (gidx >= 0) {
if (ibv_query_gid(ctx->context, ib_port, gidx, &my_dest.gid)) {
- fprintf(stderr, "Could not get local gid for gid index %d\n", gidx);
+ fprintf(stderr, "can't read sgid of index %d\n", gidx);
return 1;
}
} else
@@ -668,10 +709,12 @@ int main(int argc, char *argv[])
printf(" local address: LID 0x%04x, QPN 0x%06x, PSN 0x%06x, GID %s\n",
my_dest.lid, my_dest.qpn, my_dest.psn, gid);
+
if (servername)
rem_dest = pp_client_exch_dest(servername, port, &my_dest);
else
- rem_dest = pp_server_exch_dest(ctx, ib_port, mtu, port, sl, &my_dest, gidx);
+ rem_dest = pp_server_exch_dest(ctx, ib_port, mtu, port, sl,
+ &my_dest, gidx);
if (!rem_dest)
return 1;
@@ -681,7 +724,8 @@ int main(int argc, char *argv[])
rem_dest->lid, rem_dest->qpn, rem_dest->psn, gid);
if (servername)
- if (pp_connect_ctx(ctx, ib_port, my_dest.psn, mtu, sl, rem_dest, gidx))
+ if (pp_connect_ctx(ctx, ib_port, my_dest.psn, mtu, sl, rem_dest,
+ gidx))
return 1;
ctx->pending = PINGPONG_RECV_WRID;
@@ -733,6 +777,7 @@ int main(int argc, char *argv[])
fprintf(stderr, "poll CQ failed %d\n", ne);
return 1;
}
+
} while (!use_event && ne < 1);
for (i = 0; i < ne; ++i) {
diff --git a/contrib/ofed/libibverbs/examples/ud_pingpong.c b/contrib/ofed/libibverbs/examples/ud_pingpong.c
index d7c1059..59e2df0 100644
--- a/contrib/ofed/libibverbs/examples/ud_pingpong.c
+++ b/contrib/ofed/libibverbs/examples/ud_pingpong.c
@@ -29,10 +29,8 @@
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
-
-#if HAVE_CONFIG_H
-# include <config.h>
-#endif /* HAVE_CONFIG_H */
+#define _GNU_SOURCE
+#include <config.h>
#include <stdio.h>
#include <stdlib.h>
@@ -42,6 +40,7 @@
#include <sys/socket.h>
#include <sys/time.h>
#include <netdb.h>
+#include <stdlib.h>
#include <getopt.h>
#include <arpa/inet.h>
#include <time.h>
@@ -65,6 +64,7 @@ struct pingpong_context {
struct ibv_ah *ah;
void *buf;
int size;
+ int send_flags;
int rx_depth;
int pending;
struct ibv_port_attr portinfo;
@@ -158,7 +158,7 @@ static struct pingpong_dest *pp_client_exch_dest(const char *servername, int por
}
}
- freeaddrinfo(res);
+ freeaddrinfo_null(res);
free(service);
if (sockfd < 0) {
@@ -167,25 +167,26 @@ static struct pingpong_dest *pp_client_exch_dest(const char *servername, int por
}
gid_to_wire_gid(&my_dest->gid, gid);
- sprintf(msg, "%04x:%06x:%06x:%s", my_dest->lid, my_dest->qpn, my_dest->psn, gid);
+ sprintf(msg, "%04x:%06x:%06x:%s", my_dest->lid, my_dest->qpn,
+ my_dest->psn, gid);
if (write(sockfd, msg, sizeof msg) != sizeof msg) {
fprintf(stderr, "Couldn't send local address\n");
goto out;
}
- if (read(sockfd, msg, sizeof msg) != sizeof msg) {
- perror("client read");
- fprintf(stderr, "Couldn't read remote address\n");
+ if (read(sockfd, msg, sizeof msg) != sizeof msg ||
+ write(sockfd, "done", sizeof "done") != sizeof "done") {
+ perror("client read/write");
+ fprintf(stderr, "Couldn't read/write remote address\n");
goto out;
}
- write(sockfd, "done", sizeof "done");
-
rem_dest = malloc(sizeof *rem_dest);
if (!rem_dest)
goto out;
- sscanf(msg, "%x:%x:%x:%s", &rem_dest->lid, &rem_dest->qpn, &rem_dest->psn, gid);
+ sscanf(msg, "%x:%x:%x:%s", &rem_dest->lid, &rem_dest->qpn,
+ &rem_dest->psn, gid);
wire_gid_to_gid(gid, &rem_dest->gid);
out:
@@ -236,7 +237,7 @@ static struct pingpong_dest *pp_server_exch_dest(struct pingpong_context *ctx,
}
}
- freeaddrinfo(res);
+ freeaddrinfo_null(res);
free(service);
if (sockfd < 0) {
@@ -245,7 +246,7 @@ static struct pingpong_dest *pp_server_exch_dest(struct pingpong_context *ctx,
}
listen(sockfd, 1);
- connfd = accept(sockfd, NULL, 0);
+ connfd = accept(sockfd, NULL, NULL);
close(sockfd);
if (connfd < 0) {
fprintf(stderr, "accept() failed\n");
@@ -263,10 +264,12 @@ static struct pingpong_dest *pp_server_exch_dest(struct pingpong_context *ctx,
if (!rem_dest)
goto out;
- sscanf(msg, "%x:%x:%x:%s", &rem_dest->lid, &rem_dest->qpn, &rem_dest->psn, gid);
+ sscanf(msg, "%x:%x:%x:%s", &rem_dest->lid, &rem_dest->qpn,
+ &rem_dest->psn, gid);
wire_gid_to_gid(gid, &rem_dest->gid);
- if (pp_connect_ctx(ctx, ib_port, my_dest->psn, sl, rem_dest, sgid_idx)) {
+ if (pp_connect_ctx(ctx, ib_port, my_dest->psn, sl, rem_dest,
+ sgid_idx)) {
fprintf(stderr, "Couldn't connect to remote QP\n");
free(rem_dest);
rem_dest = NULL;
@@ -274,16 +277,15 @@ static struct pingpong_dest *pp_server_exch_dest(struct pingpong_context *ctx,
}
gid_to_wire_gid(&my_dest->gid, gid);
- sprintf(msg, "%04x:%06x:%06x:%s", my_dest->lid, my_dest->qpn, my_dest->psn, gid);
- if (write(connfd, msg, sizeof msg) != sizeof msg) {
- fprintf(stderr, "Couldn't send local address\n");
+ sprintf(msg, "%04x:%06x:%06x:%s", my_dest->lid, my_dest->qpn,
+ my_dest->psn, gid);
+ if (write(connfd, msg, sizeof msg) != sizeof msg ||
+ read(connfd, msg, sizeof msg) != sizeof "done") {
+ fprintf(stderr, "Couldn't send/recv local address\n");
free(rem_dest);
rem_dest = NULL;
goto out;
}
-
- read(connfd, msg, sizeof msg);
-
out:
close(connfd);
return rem_dest;
@@ -299,29 +301,46 @@ static struct pingpong_context *pp_init_ctx(struct ibv_device *ib_dev, int size,
if (!ctx)
return NULL;
- ctx->size = size;
- ctx->rx_depth = rx_depth;
+ ctx->size = size;
+ ctx->send_flags = IBV_SEND_SIGNALED;
+ ctx->rx_depth = rx_depth;
- ctx->buf = malloc(roundup(size + 40, page_size));
+ ctx->buf = memalign(page_size, size + 40);
if (!ctx->buf) {
fprintf(stderr, "Couldn't allocate work buf.\n");
- return NULL;
+ goto clean_ctx;
}
- memset(ctx->buf, 0, size + 40);
+ /* FIXME memset(ctx->buf, 0, size + 40); */
+ memset(ctx->buf, 0x7b, size + 40);
ctx->context = ibv_open_device(ib_dev);
if (!ctx->context) {
fprintf(stderr, "Couldn't get context for %s\n",
ibv_get_device_name(ib_dev));
- return NULL;
+ goto clean_buffer;
+ }
+
+ {
+ struct ibv_port_attr port_info = {};
+ int mtu;
+
+ if (ibv_query_port(ctx->context, port, &port_info)) {
+ fprintf(stderr, "Unable to query port info for port %d\n", port);
+ goto clean_device;
+ }
+ mtu = 1 << (port_info.active_mtu + 7);
+ if (size > mtu) {
+ fprintf(stderr, "Requested size larger than port MTU (%d)\n", mtu);
+ goto clean_device;
+ }
}
if (use_event) {
ctx->channel = ibv_create_comp_channel(ctx->context);
if (!ctx->channel) {
fprintf(stderr, "Couldn't create completion channel\n");
- return NULL;
+ goto clean_device;
}
} else
ctx->channel = NULL;
@@ -329,24 +348,25 @@ static struct pingpong_context *pp_init_ctx(struct ibv_device *ib_dev, int size,
ctx->pd = ibv_alloc_pd(ctx->context);
if (!ctx->pd) {
fprintf(stderr, "Couldn't allocate PD\n");
- return NULL;
+ goto clean_comp_channel;
}
ctx->mr = ibv_reg_mr(ctx->pd, ctx->buf, size + 40, IBV_ACCESS_LOCAL_WRITE);
if (!ctx->mr) {
fprintf(stderr, "Couldn't register MR\n");
- return NULL;
+ goto clean_pd;
}
ctx->cq = ibv_create_cq(ctx->context, rx_depth + 1, NULL,
ctx->channel, 0);
if (!ctx->cq) {
fprintf(stderr, "Couldn't create CQ\n");
- return NULL;
+ goto clean_mr;
}
{
- struct ibv_qp_init_attr attr = {
+ struct ibv_qp_attr attr;
+ struct ibv_qp_init_attr init_attr = {
.send_cq = ctx->cq,
.recv_cq = ctx->cq,
.cap = {
@@ -358,10 +378,15 @@ static struct pingpong_context *pp_init_ctx(struct ibv_device *ib_dev, int size,
.qp_type = IBV_QPT_UD,
};
- ctx->qp = ibv_create_qp(ctx->pd, &attr);
+ ctx->qp = ibv_create_qp(ctx->pd, &init_attr);
if (!ctx->qp) {
fprintf(stderr, "Couldn't create QP\n");
- return NULL;
+ goto clean_cq;
+ }
+
+ ibv_query_qp(ctx->qp, &attr, IBV_QP_CAP, &init_attr);
+ if (init_attr.cap.max_inline_data >= size) {
+ ctx->send_flags |= IBV_SEND_INLINE;
}
}
@@ -379,14 +404,41 @@ static struct pingpong_context *pp_init_ctx(struct ibv_device *ib_dev, int size,
IBV_QP_PORT |
IBV_QP_QKEY)) {
fprintf(stderr, "Failed to modify QP to INIT\n");
- return NULL;
+ goto clean_qp;
}
}
return ctx;
+
+clean_qp:
+ ibv_destroy_qp(ctx->qp);
+
+clean_cq:
+ ibv_destroy_cq(ctx->cq);
+
+clean_mr:
+ ibv_dereg_mr(ctx->mr);
+
+clean_pd:
+ ibv_dealloc_pd(ctx->pd);
+
+clean_comp_channel:
+ if (ctx->channel)
+ ibv_destroy_comp_channel(ctx->channel);
+
+clean_device:
+ ibv_close_device(ctx->context);
+
+clean_buffer:
+ free(ctx->buf);
+
+clean_ctx:
+ free(ctx);
+
+ return NULL;
}
-int pp_close_ctx(struct pingpong_context *ctx)
+static int pp_close_ctx(struct pingpong_context *ctx)
{
if (ibv_destroy_qp(ctx->qp)) {
fprintf(stderr, "Couldn't destroy QP\n");
@@ -465,7 +517,7 @@ static int pp_post_send(struct pingpong_context *ctx, uint32_t qpn)
.sg_list = &list,
.num_sge = 1,
.opcode = IBV_WR_SEND,
- .send_flags = IBV_SEND_SIGNALED,
+ .send_flags = ctx->send_flags,
.wr = {
.ud = {
.ah = ctx->ah,
@@ -489,9 +541,10 @@ static void usage(const char *argv0)
printf(" -p, --port=<port> listen on/connect to port <port> (default 18515)\n");
printf(" -d, --ib-dev=<dev> use IB device <dev> (default first device found)\n");
printf(" -i, --ib-port=<port> use port <port> of IB device (default 1)\n");
- printf(" -s, --size=<size> size of message to exchange (default 1024)\n");
+ printf(" -s, --size=<size> size of message to exchange (default 2048)\n");
printf(" -r, --rx-depth=<dep> number of receives to post at a time (default 500)\n");
printf(" -n, --iters=<iters> number of exchanges (default 1000)\n");
+ printf(" -l, --sl=<SL> send messages with service level <SL> (default 0)\n");
printf(" -e, --events sleep on CQ events (default poll)\n");
printf(" -g, --gid-idx=<gid index> local port gid index\n");
}
@@ -506,17 +559,17 @@ int main(int argc, char *argv[])
struct timeval start, end;
char *ib_devname = NULL;
char *servername = NULL;
- int port = 18515;
+ unsigned int port = 18515;
int ib_port = 1;
- int size = 1024;
- int rx_depth = 500;
- int iters = 1000;
+ unsigned int size = 2048;
+ unsigned int rx_depth = 500;
+ unsigned int iters = 1000;
int use_event = 0;
int routs;
int rcnt, scnt;
int num_cq_events = 0;
int sl = 0;
- int gidx = -1;
+ int gidx = -1;
char gid[33];
srand48(getpid() * time(NULL));
@@ -534,44 +587,45 @@ int main(int argc, char *argv[])
{ .name = "sl", .has_arg = 1, .val = 'l' },
{ .name = "events", .has_arg = 0, .val = 'e' },
{ .name = "gid-idx", .has_arg = 1, .val = 'g' },
- { 0 }
+ {}
};
- c = getopt_long(argc, argv, "p:d:i:s:r:n:l:eg:", long_options, NULL);
+ c = getopt_long(argc, argv, "p:d:i:s:r:n:l:eg:",
+ long_options, NULL);
if (c == -1)
break;
switch (c) {
case 'p':
port = strtol(optarg, NULL, 0);
- if (port < 0 || port > 65535) {
+ if (port > 65535) {
usage(argv[0]);
return 1;
}
break;
case 'd':
- ib_devname = strdup(optarg);
+ ib_devname = strdupa(optarg);
break;
case 'i':
ib_port = strtol(optarg, NULL, 0);
- if (ib_port < 0) {
+ if (ib_port < 1) {
usage(argv[0]);
return 1;
}
break;
case 's':
- size = strtol(optarg, NULL, 0);
+ size = strtoul(optarg, NULL, 0);
break;
case 'r':
- rx_depth = strtol(optarg, NULL, 0);
+ rx_depth = strtoul(optarg, NULL, 0);
break;
case 'n':
- iters = strtol(optarg, NULL, 0);
+ iters = strtoul(optarg, NULL, 0);
break;
case 'l':
@@ -593,7 +647,7 @@ int main(int argc, char *argv[])
}
if (optind == argc - 1)
- servername = strdup(argv[optind]);
+ servername = strdupa(argv[optind]);
else if (optind < argc) {
usage(argv[0]);
return 1;
@@ -652,7 +706,8 @@ int main(int argc, char *argv[])
if (gidx >= 0) {
if (ibv_query_gid(ctx->context, ib_port, gidx, &my_dest.gid)) {
- fprintf(stderr, "Could not get local gid for gid index %d\n", gidx);
+ fprintf(stderr, "Could not get local gid for gid index "
+ "%d\n", gidx);
return 1;
}
} else
@@ -665,7 +720,8 @@ int main(int argc, char *argv[])
if (servername)
rem_dest = pp_client_exch_dest(servername, port, &my_dest);
else
- rem_dest = pp_server_exch_dest(ctx, ib_port, port, sl, &my_dest, gidx);
+ rem_dest = pp_server_exch_dest(ctx, ib_port, port, sl,
+ &my_dest, gidx);
if (!rem_dest)
return 1;
@@ -675,7 +731,8 @@ int main(int argc, char *argv[])
rem_dest->lid, rem_dest->qpn, rem_dest->psn, gid);
if (servername)
- if (pp_connect_ctx(ctx, ib_port, my_dest.psn, sl, rem_dest, gidx))
+ if (pp_connect_ctx(ctx, ib_port, my_dest.psn, sl, rem_dest,
+ gidx))
return 1;
ctx->pending = PINGPONG_RECV_WRID;
diff --git a/contrib/ofed/libibverbs/examples/xsrq_pingpong.c b/contrib/ofed/libibverbs/examples/xsrq_pingpong.c
new file mode 100644
index 0000000..42996cf
--- /dev/null
+++ b/contrib/ofed/libibverbs/examples/xsrq_pingpong.c
@@ -0,0 +1,1022 @@
+/*
+ * Copyright (c) 2005 Topspin Communications. All rights reserved.
+ * Copyright (c) 2011 Intel Corporation, Inc. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+#define _GNU_SOURCE
+#include <config.h>
+
+#include <stdio.h>
+#include <fcntl.h>
+#include <errno.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <string.h>
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <sys/time.h>
+#include <netdb.h>
+#include <malloc.h>
+#include <getopt.h>
+#include <arpa/inet.h>
+#include <time.h>
+
+#include "pingpong.h"
+
+#define MSG_FORMAT "%04x:%06x:%06x:%06x:%06x:%32s"
+#define MSG_SIZE 66
+#define MSG_SSCAN "%x:%x:%x:%x:%x:%s"
+#define ADDR_FORMAT \
+ "%8s: LID %04x, QPN RECV %06x SEND %06x, PSN %06x, SRQN %06x, GID %s\n"
+#define TERMINATION_FORMAT "%s"
+#define TERMINATION_MSG_SIZE 4
+#define TERMINATION_MSG "END"
+static int page_size;
+
+struct pingpong_dest {
+ union ibv_gid gid;
+ int lid;
+ int recv_qpn;
+ int send_qpn;
+ int recv_psn;
+ int send_psn;
+ int srqn;
+ int pp_cnt;
+ int sockfd;
+};
+
+struct pingpong_context {
+ struct ibv_context *context;
+ struct ibv_comp_channel *channel;
+ struct ibv_pd *pd;
+ struct ibv_mr *mr;
+ struct ibv_cq *send_cq;
+ struct ibv_cq *recv_cq;
+ struct ibv_srq *srq;
+ struct ibv_xrcd *xrcd;
+ struct ibv_qp **recv_qp;
+ struct ibv_qp **send_qp;
+ struct pingpong_dest *rem_dest;
+ void *buf;
+ int lid;
+ int sl;
+ enum ibv_mtu mtu;
+ int ib_port;
+ int fd;
+ int size;
+ int num_clients;
+ int num_tests;
+ int use_event;
+ int gidx;
+};
+
+static struct pingpong_context ctx;
+
+
+static int open_device(char *ib_devname)
+{
+ struct ibv_device **dev_list;
+ int i = 0;
+
+ dev_list = ibv_get_device_list(NULL);
+ if (!dev_list) {
+ fprintf(stderr, "Failed to get IB devices list");
+ return -1;
+ }
+
+ if (ib_devname) {
+ for (; dev_list[i]; ++i) {
+ if (!strcmp(ibv_get_device_name(dev_list[i]), ib_devname))
+ break;
+ }
+ }
+ if (!dev_list[i]) {
+ fprintf(stderr, "IB device %s not found\n",
+ ib_devname ? ib_devname : "");
+ return -1;
+ }
+
+ ctx.context = ibv_open_device(dev_list[i]);
+ if (!ctx.context) {
+ fprintf(stderr, "Couldn't get context for %s\n",
+ ibv_get_device_name(dev_list[i]));
+ return -1;
+ }
+
+ ibv_free_device_list(dev_list);
+ return 0;
+}
+
+static int create_qps(void)
+{
+ struct ibv_qp_init_attr_ex init;
+ struct ibv_qp_attr mod;
+ int i;
+
+ for (i = 0; i < ctx.num_clients; ++i) {
+
+ memset(&init, 0, sizeof init);
+ init.qp_type = IBV_QPT_XRC_RECV;
+ init.comp_mask = IBV_QP_INIT_ATTR_XRCD;
+ init.xrcd = ctx.xrcd;
+
+ ctx.recv_qp[i] = ibv_create_qp_ex(ctx.context, &init);
+ if (!ctx.recv_qp[i]) {
+ fprintf(stderr, "Couldn't create recv QP[%d] errno %d\n",
+ i, errno);
+ return 1;
+ }
+
+ mod.qp_state = IBV_QPS_INIT;
+ mod.pkey_index = 0;
+ mod.port_num = ctx.ib_port;
+ mod.qp_access_flags = IBV_ACCESS_REMOTE_WRITE | IBV_ACCESS_REMOTE_READ;
+
+ if (ibv_modify_qp(ctx.recv_qp[i], &mod,
+ IBV_QP_STATE | IBV_QP_PKEY_INDEX |
+ IBV_QP_PORT | IBV_QP_ACCESS_FLAGS)) {
+ fprintf(stderr, "Failed to modify recv QP[%d] to INIT\n", i);
+ return 1;
+ }
+
+ memset(&init, 0, sizeof init);
+ init.qp_type = IBV_QPT_XRC_SEND;
+ init.send_cq = ctx.send_cq;
+ init.cap.max_send_wr = ctx.num_clients * ctx.num_tests;
+ init.cap.max_send_sge = 1;
+ init.comp_mask = IBV_QP_INIT_ATTR_PD;
+ init.pd = ctx.pd;
+
+ ctx.send_qp[i] = ibv_create_qp_ex(ctx.context, &init);
+ if (!ctx.send_qp[i]) {
+ fprintf(stderr, "Couldn't create send QP[%d] errno %d\n",
+ i, errno);
+ return 1;
+ }
+
+ mod.qp_state = IBV_QPS_INIT;
+ mod.pkey_index = 0;
+ mod.port_num = ctx.ib_port;
+ mod.qp_access_flags = 0;
+
+ if (ibv_modify_qp(ctx.send_qp[i], &mod,
+ IBV_QP_STATE | IBV_QP_PKEY_INDEX |
+ IBV_QP_PORT | IBV_QP_ACCESS_FLAGS)) {
+ fprintf(stderr, "Failed to modify send QP[%d] to INIT\n", i);
+ return 1;
+ }
+ }
+
+ return 0;
+}
+
+static int pp_init_ctx(char *ib_devname)
+{
+ struct ibv_srq_init_attr_ex attr;
+ struct ibv_xrcd_init_attr xrcd_attr;
+ struct ibv_port_attr port_attr;
+
+ ctx.recv_qp = calloc(ctx.num_clients, sizeof *ctx.recv_qp);
+ ctx.send_qp = calloc(ctx.num_clients, sizeof *ctx.send_qp);
+ ctx.rem_dest = calloc(ctx.num_clients, sizeof *ctx.rem_dest);
+ if (!ctx.recv_qp || !ctx.send_qp || !ctx.rem_dest)
+ return 1;
+
+ if (open_device(ib_devname)) {
+ fprintf(stderr, "Failed to open device\n");
+ return 1;
+ }
+
+ if (pp_get_port_info(ctx.context, ctx.ib_port, &port_attr)) {
+ fprintf(stderr, "Failed to get port info\n");
+ return 1;
+ }
+
+ ctx.lid = port_attr.lid;
+ if (port_attr.link_layer != IBV_LINK_LAYER_ETHERNET && !ctx.lid) {
+ fprintf(stderr, "Couldn't get local LID\n");
+ return 1;
+ }
+
+ ctx.buf = memalign(page_size, ctx.size);
+ if (!ctx.buf) {
+ fprintf(stderr, "Couldn't allocate work buf.\n");
+ return 1;
+ }
+
+ memset(ctx.buf, 0, ctx.size);
+
+ if (ctx.use_event) {
+ ctx.channel = ibv_create_comp_channel(ctx.context);
+ if (!ctx.channel) {
+ fprintf(stderr, "Couldn't create completion channel\n");
+ return 1;
+ }
+ }
+
+ ctx.pd = ibv_alloc_pd(ctx.context);
+ if (!ctx.pd) {
+ fprintf(stderr, "Couldn't allocate PD\n");
+ return 1;
+ }
+
+ ctx.mr = ibv_reg_mr(ctx.pd, ctx.buf, ctx.size, IBV_ACCESS_LOCAL_WRITE);
+ if (!ctx.mr) {
+ fprintf(stderr, "Couldn't register MR\n");
+ return 1;
+ }
+
+ ctx.fd = open("/tmp/xrc_domain", O_RDONLY | O_CREAT, S_IRUSR | S_IRGRP);
+ if (ctx.fd < 0) {
+ fprintf(stderr,
+ "Couldn't create the file for the XRC Domain "
+ "but not stopping %d\n", errno);
+ ctx.fd = -1;
+ }
+
+ memset(&xrcd_attr, 0, sizeof xrcd_attr);
+ xrcd_attr.comp_mask = IBV_XRCD_INIT_ATTR_FD | IBV_XRCD_INIT_ATTR_OFLAGS;
+ xrcd_attr.fd = ctx.fd;
+ xrcd_attr.oflags = O_CREAT;
+ ctx.xrcd = ibv_open_xrcd(ctx.context, &xrcd_attr);
+ if (!ctx.xrcd) {
+ fprintf(stderr, "Couldn't Open the XRC Domain %d\n", errno);
+ return 1;
+ }
+
+ ctx.recv_cq = ibv_create_cq(ctx.context, ctx.num_clients, &ctx.recv_cq,
+ ctx.channel, 0);
+ if (!ctx.recv_cq) {
+ fprintf(stderr, "Couldn't create recv CQ\n");
+ return 1;
+ }
+
+ if (ctx.use_event) {
+ if (ibv_req_notify_cq(ctx.recv_cq, 0)) {
+ fprintf(stderr, "Couldn't request CQ notification\n");
+ return 1;
+ }
+ }
+
+ ctx.send_cq = ibv_create_cq(ctx.context, ctx.num_clients, NULL, NULL, 0);
+ if (!ctx.send_cq) {
+ fprintf(stderr, "Couldn't create send CQ\n");
+ return 1;
+ }
+
+ memset(&attr, 0, sizeof attr);
+ attr.attr.max_wr = ctx.num_clients;
+ attr.attr.max_sge = 1;
+ attr.comp_mask = IBV_SRQ_INIT_ATTR_TYPE | IBV_SRQ_INIT_ATTR_XRCD |
+ IBV_SRQ_INIT_ATTR_CQ | IBV_SRQ_INIT_ATTR_PD;
+ attr.srq_type = IBV_SRQT_XRC;
+ attr.xrcd = ctx.xrcd;
+ attr.cq = ctx.recv_cq;
+ attr.pd = ctx.pd;
+
+ ctx.srq = ibv_create_srq_ex(ctx.context, &attr);
+ if (!ctx.srq) {
+ fprintf(stderr, "Couldn't create SRQ\n");
+ return 1;
+ }
+
+ if (create_qps())
+ return 1;
+
+ return 0;
+}
+
+static int recv_termination_ack(int index)
+{
+ char msg[TERMINATION_MSG_SIZE];
+ int n = 0, r;
+ int sockfd = ctx.rem_dest[index].sockfd;
+
+ while (n < TERMINATION_MSG_SIZE) {
+ r = read(sockfd, msg + n, TERMINATION_MSG_SIZE - n);
+ if (r < 0) {
+ perror("client read");
+ fprintf(stderr,
+ "%d/%d: Couldn't read remote termination ack\n",
+ n, TERMINATION_MSG_SIZE);
+ return 1;
+ }
+ n += r;
+ }
+
+ if (strcmp(msg, TERMINATION_MSG)) {
+ fprintf(stderr, "Invalid termination ack was accepted\n");
+ return 1;
+ }
+
+ return 0;
+}
+
+static int send_termination_ack(int index)
+{
+ char msg[TERMINATION_MSG_SIZE];
+ int sockfd = ctx.rem_dest[index].sockfd;
+
+ sprintf(msg, TERMINATION_FORMAT, TERMINATION_MSG);
+
+ if (write(sockfd, msg, TERMINATION_MSG_SIZE) != TERMINATION_MSG_SIZE) {
+ fprintf(stderr, "Couldn't send termination ack\n");
+ return 1;
+ }
+
+ return 0;
+}
+
+static int pp_client_termination(void)
+{
+ if (send_termination_ack(0))
+ return 1;
+ if (recv_termination_ack(0))
+ return 1;
+
+ return 0;
+}
+
+static int pp_server_termination(void)
+{
+ int i;
+
+ for (i = 0; i < ctx.num_clients; i++) {
+ if (recv_termination_ack(i))
+ return 1;
+ }
+
+ for (i = 0; i < ctx.num_clients; i++) {
+ if (send_termination_ack(i))
+ return 1;
+ }
+
+ return 0;
+}
+
+static int send_local_dest(int sockfd, int index)
+{
+ char msg[MSG_SIZE];
+ char gid[33];
+ uint32_t srq_num;
+ union ibv_gid local_gid;
+
+ if (ctx.gidx >= 0) {
+ if (ibv_query_gid(ctx.context, ctx.ib_port, ctx.gidx,
+ &local_gid)) {
+ fprintf(stderr, "can't read sgid of index %d\n",
+ ctx.gidx);
+ return -1;
+ }
+ } else {
+ memset(&local_gid, 0, sizeof(local_gid));
+ }
+
+ ctx.rem_dest[index].recv_psn = lrand48() & 0xffffff;
+ if (ibv_get_srq_num(ctx.srq, &srq_num)) {
+ fprintf(stderr, "Couldn't get SRQ num\n");
+ return -1;
+ }
+
+ inet_ntop(AF_INET6, &local_gid, gid, sizeof(gid));
+ printf(ADDR_FORMAT, "local", ctx.lid, ctx.recv_qp[index]->qp_num,
+ ctx.send_qp[index]->qp_num, ctx.rem_dest[index].recv_psn,
+ srq_num, gid);
+
+ gid_to_wire_gid(&local_gid, gid);
+ sprintf(msg, MSG_FORMAT, ctx.lid, ctx.recv_qp[index]->qp_num,
+ ctx.send_qp[index]->qp_num, ctx.rem_dest[index].recv_psn,
+ srq_num, gid);
+
+ if (write(sockfd, msg, MSG_SIZE) != MSG_SIZE) {
+ fprintf(stderr, "Couldn't send local address\n");
+ return -1;
+ }
+
+ return 0;
+}
+
+static int recv_remote_dest(int sockfd, int index)
+{
+ struct pingpong_dest *rem_dest;
+ char msg[MSG_SIZE];
+ char gid[33];
+ int n = 0, r;
+
+ while (n < MSG_SIZE) {
+ r = read(sockfd, msg + n, MSG_SIZE - n);
+ if (r < 0) {
+ perror("client read");
+ fprintf(stderr,
+ "%d/%d: Couldn't read remote address [%d]\n",
+ n, MSG_SIZE, index);
+ return -1;
+ }
+ n += r;
+ }
+
+ rem_dest = &ctx.rem_dest[index];
+ sscanf(msg, MSG_SSCAN, &rem_dest->lid, &rem_dest->recv_qpn,
+ &rem_dest->send_qpn, &rem_dest->send_psn, &rem_dest->srqn, gid);
+
+ wire_gid_to_gid(gid, &rem_dest->gid);
+ inet_ntop(AF_INET6, &rem_dest->gid, gid, sizeof(gid));
+ printf(ADDR_FORMAT, "remote", rem_dest->lid, rem_dest->recv_qpn,
+ rem_dest->send_qpn, rem_dest->send_psn, rem_dest->srqn,
+ gid);
+
+ rem_dest->sockfd = sockfd;
+ return 0;
+}
+
+static void set_ah_attr(struct ibv_ah_attr *attr, struct pingpong_context *myctx,
+ int index)
+{
+ attr->is_global = 1;
+ attr->grh.hop_limit = 5;
+ attr->grh.dgid = myctx->rem_dest[index].gid;
+ attr->grh.sgid_index = myctx->gidx;
+}
+
+static int connect_qps(int index)
+{
+ struct ibv_qp_attr attr;
+
+ memset(&attr, 0, sizeof attr);
+ attr.qp_state = IBV_QPS_RTR;
+ attr.dest_qp_num = ctx.rem_dest[index].send_qpn;
+ attr.path_mtu = ctx.mtu;
+ attr.rq_psn = ctx.rem_dest[index].send_psn;
+ attr.min_rnr_timer = 12;
+ attr.ah_attr.dlid = ctx.rem_dest[index].lid;
+ attr.ah_attr.sl = ctx.sl;
+ attr.ah_attr.port_num = ctx.ib_port;
+
+ if (ctx.rem_dest[index].gid.global.interface_id)
+ set_ah_attr(&attr.ah_attr, &ctx, index);
+
+ if (ibv_modify_qp(ctx.recv_qp[index], &attr,
+ IBV_QP_STATE | IBV_QP_AV | IBV_QP_PATH_MTU |
+ IBV_QP_DEST_QPN | IBV_QP_RQ_PSN |
+ IBV_QP_MAX_DEST_RD_ATOMIC | IBV_QP_MIN_RNR_TIMER)) {
+ fprintf(stderr, "Failed to modify recv QP[%d] to RTR\n", index);
+ return 1;
+ }
+
+ memset(&attr, 0, sizeof attr);
+ attr.qp_state = IBV_QPS_RTS;
+ attr.timeout = 14;
+ attr.sq_psn = ctx.rem_dest[index].recv_psn;
+
+ if (ibv_modify_qp(ctx.recv_qp[index], &attr,
+ IBV_QP_STATE | IBV_QP_TIMEOUT | IBV_QP_SQ_PSN)) {
+ fprintf(stderr, "Failed to modify recv QP[%d] to RTS\n", index);
+ return 1;
+ }
+
+ memset(&attr, 0, sizeof attr);
+ attr.qp_state = IBV_QPS_RTR;
+ attr.dest_qp_num = ctx.rem_dest[index].recv_qpn;
+ attr.path_mtu = ctx.mtu;
+ attr.rq_psn = ctx.rem_dest[index].send_psn;
+ attr.ah_attr.dlid = ctx.rem_dest[index].lid;
+ attr.ah_attr.sl = ctx.sl;
+ attr.ah_attr.port_num = ctx.ib_port;
+
+ if (ctx.rem_dest[index].gid.global.interface_id)
+ set_ah_attr(&attr.ah_attr, &ctx, index);
+
+ if (ibv_modify_qp(ctx.send_qp[index], &attr,
+ IBV_QP_STATE | IBV_QP_AV | IBV_QP_PATH_MTU |
+ IBV_QP_DEST_QPN | IBV_QP_RQ_PSN)) {
+ fprintf(stderr, "Failed to modify send QP[%d] to RTR\n", index);
+ return 1;
+ }
+
+ memset(&attr, 0, sizeof attr);
+ attr.qp_state = IBV_QPS_RTS;
+ attr.timeout = 14;
+ attr.retry_cnt = 7;
+ attr.rnr_retry = 7;
+ attr.sq_psn = ctx.rem_dest[index].recv_psn;
+
+ if (ibv_modify_qp(ctx.send_qp[index], &attr,
+ IBV_QP_STATE | IBV_QP_TIMEOUT | IBV_QP_SQ_PSN |
+ IBV_QP_RETRY_CNT | IBV_QP_RNR_RETRY | IBV_QP_MAX_QP_RD_ATOMIC)) {
+ fprintf(stderr, "Failed to modify send QP[%d] to RTS\n", index);
+ return 1;
+ }
+
+ return 0;
+}
+
+static int pp_client_connect(const char *servername, int port)
+{
+ struct addrinfo *res, *t;
+ char *service;
+ int ret;
+ int sockfd = -1;
+ struct addrinfo hints = {
+ .ai_family = AF_INET,
+ .ai_socktype = SOCK_STREAM
+ };
+
+ if (asprintf(&service, "%d", port) < 0)
+ return 1;
+
+ ret = getaddrinfo(servername, service, &hints, &res);
+ if (ret < 0) {
+ fprintf(stderr, "%s for %s:%d\n", gai_strerror(ret), servername, port);
+ free(service);
+ return 1;
+ }
+
+ for (t = res; t; t = t->ai_next) {
+ sockfd = socket(t->ai_family, t->ai_socktype, t->ai_protocol);
+ if (sockfd >= 0) {
+ if (!connect(sockfd, t->ai_addr, t->ai_addrlen))
+ break;
+ close(sockfd);
+ sockfd = -1;
+ }
+ }
+
+ freeaddrinfo_null(res);
+ free(service);
+
+ if (sockfd < 0) {
+ fprintf(stderr, "Couldn't connect to %s:%d\n", servername, port);
+ return 1;
+ }
+
+ if (send_local_dest(sockfd, 0))
+ return 1;
+
+ if (recv_remote_dest(sockfd, 0))
+ return 1;
+
+ if (connect_qps(0))
+ return 1;
+
+ return 0;
+}
+
+static int pp_server_connect(int port)
+{
+ struct addrinfo *res, *t;
+ char *service;
+ int ret, i, n;
+ int sockfd = -1, connfd;
+ struct addrinfo hints = {
+ .ai_flags = AI_PASSIVE,
+ .ai_family = AF_INET,
+ .ai_socktype = SOCK_STREAM
+ };
+
+ if (asprintf(&service, "%d", port) < 0)
+ return 1;
+
+ ret = getaddrinfo(NULL, service, &hints, &res);
+ if (ret < 0) {
+ fprintf(stderr, "%s for port %d\n", gai_strerror(ret), port);
+ free(service);
+ return 1;
+ }
+
+ for (t = res; t; t = t->ai_next) {
+ sockfd = socket(t->ai_family, t->ai_socktype, t->ai_protocol);
+ if (sockfd >= 0) {
+ n = 1;
+ setsockopt(sockfd, SOL_SOCKET, SO_REUSEADDR, &n, sizeof n);
+ if (!bind(sockfd, t->ai_addr, t->ai_addrlen))
+ break;
+ close(sockfd);
+ sockfd = -1;
+ }
+ }
+
+ freeaddrinfo_null(res);
+ free(service);
+
+ if (sockfd < 0) {
+ fprintf(stderr, "Couldn't listen to port %d\n", port);
+ return 1;
+ }
+
+ listen(sockfd, ctx.num_clients);
+
+ for (i = 0; i < ctx.num_clients; i++) {
+ connfd = accept(sockfd, NULL, NULL);
+ if (connfd < 0) {
+ fprintf(stderr, "accept() failed for client %d\n", i);
+ return 1;
+ }
+
+ if (recv_remote_dest(connfd, i))
+ return 1;
+
+ if (send_local_dest(connfd, i))
+ return 1;
+
+ if (connect_qps(i))
+ return 1;
+ }
+
+ close(sockfd);
+ return 0;
+}
+
+
+static int pp_close_ctx(void)
+{
+ int i;
+
+ for (i = 0; i < ctx.num_clients; ++i) {
+
+ if (ibv_destroy_qp(ctx.send_qp[i])) {
+ fprintf(stderr, "Couldn't destroy INI QP[%d]\n", i);
+ return 1;
+ }
+
+ if (ibv_destroy_qp(ctx.recv_qp[i])) {
+ fprintf(stderr, "Couldn't destroy TGT QP[%d]\n", i);
+ return 1;
+ }
+
+ if (ctx.rem_dest[i].sockfd)
+ close(ctx.rem_dest[i].sockfd);
+ }
+
+ if (ibv_destroy_srq(ctx.srq)) {
+ fprintf(stderr, "Couldn't destroy SRQ\n");
+ return 1;
+ }
+
+ if (ctx.xrcd && ibv_close_xrcd(ctx.xrcd)) {
+ fprintf(stderr, "Couldn't close the XRC Domain\n");
+ return 1;
+ }
+ if (ctx.fd >= 0 && close(ctx.fd)) {
+ fprintf(stderr, "Couldn't close the file for the XRC Domain\n");
+ return 1;
+ }
+
+ if (ibv_destroy_cq(ctx.send_cq)) {
+ fprintf(stderr, "Couldn't destroy send CQ\n");
+ return 1;
+ }
+
+ if (ibv_destroy_cq(ctx.recv_cq)) {
+ fprintf(stderr, "Couldn't destroy recv CQ\n");
+ return 1;
+ }
+
+ if (ibv_dereg_mr(ctx.mr)) {
+ fprintf(stderr, "Couldn't deregister MR\n");
+ return 1;
+ }
+
+ if (ibv_dealloc_pd(ctx.pd)) {
+ fprintf(stderr, "Couldn't deallocate PD\n");
+ return 1;
+ }
+
+ if (ctx.channel) {
+ if (ibv_destroy_comp_channel(ctx.channel)) {
+ fprintf(stderr,
+ "Couldn't destroy completion channel\n");
+ return 1;
+ }
+ }
+
+ if (ibv_close_device(ctx.context)) {
+ fprintf(stderr, "Couldn't release context\n");
+ return 1;
+ }
+
+ free(ctx.buf);
+ free(ctx.rem_dest);
+ free(ctx.send_qp);
+ free(ctx.recv_qp);
+ return 0;
+}
+
+static int pp_post_recv(int cnt)
+{
+ struct ibv_sge sge;
+ struct ibv_recv_wr wr, *bad_wr;
+
+ sge.addr = (uintptr_t) ctx.buf;
+ sge.length = ctx.size;
+ sge.lkey = ctx.mr->lkey;
+
+ wr.next = NULL;
+ wr.wr_id = (uintptr_t) &ctx;
+ wr.sg_list = &sge;
+ wr.num_sge = 1;
+
+ while (cnt--) {
+ if (ibv_post_srq_recv(ctx.srq, &wr, &bad_wr)) {
+ fprintf(stderr, "Failed to post receive to SRQ\n");
+ return 1;
+ }
+ }
+ return 0;
+}
+
+/*
+ * Send to each client round robin on each set of xrc send/recv qp.
+ * Generate a completion on the last send.
+ */
+static int pp_post_send(int index)
+{
+ struct ibv_sge sge;
+ struct ibv_send_wr wr, *bad_wr;
+ int qpi;
+
+ sge.addr = (uintptr_t) ctx.buf;
+ sge.length = ctx.size;
+ sge.lkey = ctx.mr->lkey;
+
+ wr.wr_id = (uintptr_t) index;
+ wr.next = NULL;
+ wr.sg_list = &sge;
+ wr.num_sge = 1;
+ wr.opcode = IBV_WR_SEND;
+ wr.qp_type.xrc.remote_srqn = ctx.rem_dest[index].srqn;
+
+ qpi = (index + ctx.rem_dest[index].pp_cnt) % ctx.num_clients;
+ wr.send_flags = (++ctx.rem_dest[index].pp_cnt >= ctx.num_tests) ?
+ IBV_SEND_SIGNALED : 0;
+
+ return ibv_post_send(ctx.send_qp[qpi], &wr, &bad_wr);
+}
+
+static int find_qp(int qpn)
+{
+ int i;
+
+ if (ctx.num_clients == 1)
+ return 0;
+
+ for (i = 0; i < ctx.num_clients; ++i)
+ if (ctx.recv_qp[i]->qp_num == qpn)
+ return i;
+
+ fprintf(stderr, "Unable to find qp %x\n", qpn);
+ return 0;
+}
+
+static int get_cq_event(void)
+{
+ struct ibv_cq *ev_cq;
+ void *ev_ctx;
+
+ if (ibv_get_cq_event(ctx.channel, &ev_cq, &ev_ctx)) {
+ fprintf(stderr, "Failed to get cq_event\n");
+ return 1;
+ }
+
+ if (ev_cq != ctx.recv_cq) {
+ fprintf(stderr, "CQ event for unknown CQ %p\n", ev_cq);
+ return 1;
+ }
+
+ if (ibv_req_notify_cq(ctx.recv_cq, 0)) {
+ fprintf(stderr, "Couldn't request CQ notification\n");
+ return 1;
+ }
+
+ return 0;
+}
+
+static void init(void)
+{
+ srand48(getpid() * time(NULL));
+
+ ctx.size = 4096;
+ ctx.ib_port = 1;
+ ctx.num_clients = 1;
+ ctx.num_tests = 5;
+ ctx.mtu = IBV_MTU_2048;
+ ctx.sl = 0;
+ ctx.gidx = -1;
+}
+
+static void usage(const char *argv0)
+{
+ printf("Usage:\n");
+ printf(" %s start a server and wait for connection\n", argv0);
+ printf(" %s <host> connect to server at <host>\n", argv0);
+ printf("\n");
+ printf("Options:\n");
+ printf(" -p, --port=<port> listen on/connect to port <port> (default 18515)\n");
+ printf(" -d, --ib-dev=<dev> use IB device <dev> (default first device found)\n");
+ printf(" -i, --ib-port=<port> use port <port> of IB device (default 1)\n");
+ printf(" -s, --size=<size> size of message to exchange (default 4096)\n");
+ printf(" -m, --mtu=<size> path MTU (default 2048)\n");
+ printf(" -c, --clients=<n> number of clients (on server only, default 1)\n");
+ printf(" -n, --num_tests=<n> number of tests per client (default 5)\n");
+ printf(" -l, --sl=<sl> service level value\n");
+ printf(" -e, --events sleep on CQ events (default poll)\n");
+ printf(" -g, --gid-idx=<gid index> local port gid index\n");
+}
+
+int main(int argc, char *argv[])
+{
+ char *ib_devname = NULL;
+ char *servername = NULL;
+ int port = 18515;
+ int i, total, cnt = 0;
+ int ne, qpi, num_cq_events = 0;
+ struct ibv_wc wc;
+
+ init();
+ while (1) {
+ int c;
+
+ static struct option long_options[] = {
+ { .name = "port", .has_arg = 1, .val = 'p' },
+ { .name = "ib-dev", .has_arg = 1, .val = 'd' },
+ { .name = "ib-port", .has_arg = 1, .val = 'i' },
+ { .name = "size", .has_arg = 1, .val = 's' },
+ { .name = "mtu", .has_arg = 1, .val = 'm' },
+ { .name = "clients", .has_arg = 1, .val = 'c' },
+ { .name = "num_tests", .has_arg = 1, .val = 'n' },
+ { .name = "sl", .has_arg = 1, .val = 'l' },
+ { .name = "events", .has_arg = 0, .val = 'e' },
+ { .name = "gid-idx", .has_arg = 1, .val = 'g' },
+ {}
+ };
+
+ c = getopt_long(argc, argv, "p:d:i:s:m:c:n:l:eg:", long_options,
+ NULL);
+ if (c == -1)
+ break;
+
+ switch (c) {
+ case 'p':
+ port = strtol(optarg, NULL, 0);
+ if (port < 0 || port > 65535) {
+ usage(argv[0]);
+ return 1;
+ }
+ break;
+ case 'd':
+ ib_devname = strdupa(optarg);
+ break;
+ case 'i':
+ ctx.ib_port = strtol(optarg, NULL, 0);
+ if (ctx.ib_port < 0) {
+ usage(argv[0]);
+ return 1;
+ }
+ break;
+ case 's':
+ ctx.size = strtol(optarg, NULL, 0);
+ break;
+ case 'm':
+ ctx.mtu = pp_mtu_to_enum(strtol(optarg, NULL, 0));
+ if (ctx.mtu == 0) {
+ usage(argv[0]);
+ return 1;
+ }
+ break;
+ case 'c':
+ ctx.num_clients = strtol(optarg, NULL, 0);
+ break;
+ case 'n':
+ ctx.num_tests = strtol(optarg, NULL, 0);
+ break;
+ case 'l':
+ ctx.sl = strtol(optarg, NULL, 0);
+ break;
+ case 'g':
+ ctx.gidx = strtol(optarg, NULL, 0);
+ break;
+ case 'e':
+ ctx.use_event = 1;
+ break;
+ default:
+ usage(argv[0]);
+ return 1;
+ }
+ }
+
+ if (optind == argc - 1) {
+ servername = strdupa(argv[optind]);
+ ctx.num_clients = 1;
+ } else if (optind < argc) {
+ usage(argv[0]);
+ return 1;
+ }
+
+ page_size = sysconf(_SC_PAGESIZE);
+
+ if (pp_init_ctx(ib_devname))
+ return 1;
+
+ if (pp_post_recv(ctx.num_clients)) {
+ fprintf(stderr, "Couldn't post receives\n");
+ return 1;
+ }
+
+ if (servername) {
+ if (pp_client_connect(servername, port))
+ return 1;
+ } else {
+ if (pp_server_connect(port))
+ return 1;
+
+ for (i = 0; i < ctx.num_clients; i++)
+ pp_post_send(i);
+ }
+
+ total = ctx.num_clients * ctx.num_tests;
+ while (cnt < total) {
+ if (ctx.use_event) {
+ if (get_cq_event())
+ return 1;
+
+ ++num_cq_events;
+ }
+
+ do {
+ ne = ibv_poll_cq(ctx.recv_cq, 1, &wc);
+ if (ne < 0) {
+ fprintf(stderr, "Error polling cq %d\n", ne);
+ return 1;
+ } else if (ne == 0) {
+ break;
+ }
+
+ if (wc.status) {
+ fprintf(stderr, "Work completion error %d\n", wc.status);
+ return 1;
+ }
+
+ pp_post_recv(ne);
+ qpi = find_qp(wc.qp_num);
+ if (ctx.rem_dest[qpi].pp_cnt < ctx.num_tests)
+ pp_post_send(qpi);
+ cnt += ne;
+ } while (ne > 0);
+ }
+
+ for (cnt = 0; cnt < ctx.num_clients; cnt += ne) {
+ ne = ibv_poll_cq(ctx.send_cq, 1, &wc);
+ if (ne < 0) {
+ fprintf(stderr, "Error polling cq %d\n", ne);
+ return 1;
+ }
+ }
+
+ if (ctx.use_event)
+ ibv_ack_cq_events(ctx.recv_cq, num_cq_events);
+
+ /* Process should get an ack from the daemon to close its resources to
+ * make sure latest daemon's response sent via its target QP destined
+ * to an XSRQ created by another client won't be lost.
+ * Failure to do so may cause the other client to wait for that sent
+ * message forever. See comment on pp_post_send.
+ */
+ if (servername) {
+ if (pp_client_termination())
+ return 1;
+ } else if (pp_server_termination()) {
+ return 1;
+ }
+
+ if (pp_close_ctx())
+ return 1;
+
+ printf("success\n");
+ return 0;
+}
diff --git a/contrib/ofed/libibverbs/fixes/XRC_RCV_QP.patch b/contrib/ofed/libibverbs/fixes/XRC_RCV_QP.patch
deleted file mode 100644
index bfa6cc9..0000000
--- a/contrib/ofed/libibverbs/fixes/XRC_RCV_QP.patch
+++ /dev/null
@@ -1,702 +0,0 @@
-Added support for XRC receive-only QPs.
-(OFED 1.3 libibverbs commit 6e99cddf835d4715ea7ca3641944e6285f27f2df)
-
-V2:
-1. checkpatch.pl cleanups
-2. Fixed u64 alignment problems in kern-abi.h
-3. eliminated unneeded default_symvers
-4. Added ibv_xrc_rcv_xxx lines to libibverbs.map IBVERBS_1.1
-
-Signed-off-by: Jack Morgenstein <jackm@dev.mellanox.co.il>
----
- include/infiniband/driver.h | 12 ++-
- include/infiniband/kern-abi.h | 99 +++++++++++++++++++-
- include/infiniband/verbs.h | 123 +++++++++++++++++++++++
- src/cmd.c | 215 +++++++++++++++++++++++++++++++++++++++++
- src/device.c | 52 +++++-----
- src/libibverbs.map | 10 ++
- src/verbs.c | 59 +++++++++++
- 7 files changed, 543 insertions(+), 27 deletions(-)
-
-Index: libibverbs/include/infiniband/driver.h
-===================================================================
---- libibverbs.orig/include/infiniband/driver.h 2009-11-01 15:18:20.624171000 +0200
-+++ libibverbs/include/infiniband/driver.h 2009-11-01 15:18:24.572283000 +0200
-@@ -144,7 +144,17 @@ int ibv_cmd_open_xrc_domain(struct ibv_c
- struct ibv_open_xrc_domain_resp *resp,
- size_t resp_size);
- int ibv_cmd_close_xrc_domain(struct ibv_xrc_domain *d);
--
-+int ibv_cmd_create_xrc_rcv_qp(struct ibv_qp_init_attr *init_attr,
-+ uint32_t *xrc_rcv_qpn);
-+int ibv_cmd_modify_xrc_rcv_qp(struct ibv_xrc_domain *d, uint32_t xrc_rcv_qpn,
-+ struct ibv_qp_attr *attr, int attr_mask);
-+int ibv_cmd_query_xrc_rcv_qp(struct ibv_xrc_domain *d, uint32_t xrc_rcv_qpn,
-+ struct ibv_qp_attr *attr, int attr_mask,
-+ struct ibv_qp_init_attr *init_attr);
-+int ibv_cmd_reg_xrc_rcv_qp(struct ibv_xrc_domain *xrc_domain,
-+ uint32_t xrc_qp_num);
-+int ibv_cmd_unreg_xrc_rcv_qp(struct ibv_xrc_domain *xrc_domain,
-+ uint32_t xrc_qp_num);
-
- /*
- * sysfs helper functions
-Index: libibverbs/include/infiniband/kern-abi.h
-===================================================================
---- libibverbs.orig/include/infiniband/kern-abi.h 2009-11-01 15:18:20.629168000 +0200
-+++ libibverbs/include/infiniband/kern-abi.h 2009-11-01 15:18:24.577283000 +0200
-@@ -88,7 +88,12 @@ enum {
- IB_USER_VERBS_CMD_POST_SRQ_RECV,
- IB_USER_VERBS_CMD_CREATE_XRC_SRQ,
- IB_USER_VERBS_CMD_OPEN_XRC_DOMAIN,
-- IB_USER_VERBS_CMD_CLOSE_XRC_DOMAIN
-+ IB_USER_VERBS_CMD_CLOSE_XRC_DOMAIN,
-+ IB_USER_VERBS_CMD_CREATE_XRC_RCV_QP,
-+ IB_USER_VERBS_CMD_MODIFY_XRC_RCV_QP,
-+ IB_USER_VERBS_CMD_QUERY_XRC_RCV_QP,
-+ IB_USER_VERBS_CMD_REG_XRC_RCV_QP,
-+ IB_USER_VERBS_CMD_UNREG_XRC_RCV_QP,
- };
-
- /*
-@@ -570,6 +575,93 @@ struct ibv_destroy_qp_resp {
- __u32 events_reported;
- };
-
-+struct ibv_create_xrc_rcv_qp {
-+ __u32 command;
-+ __u16 in_words;
-+ __u16 out_words;
-+ __u64 response;
-+ __u64 user_handle;
-+ __u32 xrc_domain_handle;
-+ __u32 max_send_wr;
-+ __u32 max_recv_wr;
-+ __u32 max_send_sge;
-+ __u32 max_recv_sge;
-+ __u32 max_inline_data;
-+ __u8 sq_sig_all;
-+ __u8 qp_type;
-+ __u8 reserved[6];
-+ __u64 driver_data[0];
-+};
-+
-+struct ibv_create_xrc_rcv_qp_resp {
-+ __u32 qpn;
-+ __u32 reserved;
-+};
-+
-+struct ibv_modify_xrc_rcv_qp {
-+ __u32 command;
-+ __u16 in_words;
-+ __u16 out_words;
-+ __u32 xrc_domain_handle;
-+ __u32 qp_num;
-+ struct ibv_qp_dest dest;
-+ struct ibv_qp_dest alt_dest;
-+ __u32 attr_mask;
-+ __u32 qkey;
-+ __u32 rq_psn;
-+ __u32 sq_psn;
-+ __u32 dest_qp_num;
-+ __u32 qp_access_flags;
-+ __u16 pkey_index;
-+ __u16 alt_pkey_index;
-+ __u8 qp_state;
-+ __u8 cur_qp_state;
-+ __u8 path_mtu;
-+ __u8 path_mig_state;
-+ __u8 en_sqd_async_notify;
-+ __u8 max_rd_atomic;
-+ __u8 max_dest_rd_atomic;
-+ __u8 min_rnr_timer;
-+ __u8 port_num;
-+ __u8 timeout;
-+ __u8 retry_cnt;
-+ __u8 rnr_retry;
-+ __u8 alt_port_num;
-+ __u8 alt_timeout;
-+ __u8 reserved[6];
-+ __u64 driver_data[0];
-+};
-+
-+struct ibv_query_xrc_rcv_qp {
-+ __u32 command;
-+ __u16 in_words;
-+ __u16 out_words;
-+ __u64 response;
-+ __u32 xrc_domain_handle;
-+ __u32 qp_num;
-+ __u32 attr_mask;
-+ __u32 reserved;
-+ __u64 driver_data[0];
-+};
-+
-+struct ibv_reg_xrc_rcv_qp {
-+ __u32 command;
-+ __u16 in_words;
-+ __u16 out_words;
-+ __u32 xrc_domain_handle;
-+ __u32 qp_num;
-+ __u64 driver_data[0];
-+};
-+
-+struct ibv_unreg_xrc_rcv_qp {
-+ __u32 command;
-+ __u16 in_words;
-+ __u16 out_words;
-+ __u32 xrc_domain_handle;
-+ __u32 qp_num;
-+ __u64 driver_data[0];
-+};
-+
- struct ibv_kern_send_wr {
- __u64 wr_id;
- __u32 num_sge;
-@@ -848,6 +940,11 @@ enum {
- IB_USER_VERBS_CMD_CREATE_XRC_SRQ_V2 = -1,
- IB_USER_VERBS_CMD_OPEN_XRC_DOMAIN_V2 = -1,
- IB_USER_VERBS_CMD_CLOSE_XRC_DOMAIN_V2 = -1,
-+ IB_USER_VERBS_CMD_CREATE_XRC_RCV_QP_V2 = -1,
-+ IB_USER_VERBS_CMD_MODIFY_XRC_RCV_QP_V2 = -1,
-+ IB_USER_VERBS_CMD_QUERY_XRC_RCV_QP_V2 = -1,
-+ IB_USER_VERBS_CMD_REG_XRC_RCV_QP_V2 = -1,
-+ IB_USER_VERBS_CMD_UNREG_XRC_RCV_QP_V2 = -1,
- };
-
- struct ibv_destroy_cq_v1 {
-Index: libibverbs/include/infiniband/verbs.h
-===================================================================
---- libibverbs.orig/include/infiniband/verbs.h 2009-11-01 15:18:20.635171000 +0200
-+++ libibverbs/include/infiniband/verbs.h 2009-11-01 15:18:24.585280000 +0200
-@@ -205,12 +205,17 @@ enum ibv_event_type {
- IBV_EVENT_CLIENT_REREGISTER
- };
-
-+enum ibv_event_flags {
-+ IBV_XRC_QP_EVENT_FLAG = 0x80000000,
-+};
-+
- struct ibv_async_event {
- union {
- struct ibv_cq *cq;
- struct ibv_qp *qp;
- struct ibv_srq *srq;
- int port_num;
-+ uint32_t xrc_qp_num;
- } element;
- enum ibv_event_type event_type;
- };
-@@ -648,6 +653,22 @@ struct ibv_more_ops {
- struct ibv_xrc_domain * (*open_xrc_domain)(struct ibv_context *context,
- int fd, int oflag);
- int (*close_xrc_domain)(struct ibv_xrc_domain *d);
-+ int (*create_xrc_rcv_qp)(struct ibv_qp_init_attr *init_attr,
-+ uint32_t *xrc_qp_num);
-+ int (*modify_xrc_rcv_qp)(struct ibv_xrc_domain *xrc_domain,
-+ uint32_t xrc_qp_num,
-+ struct ibv_qp_attr *attr,
-+ int attr_mask);
-+ int (*query_xrc_rcv_qp)(struct ibv_xrc_domain *xrc_domain,
-+ uint32_t xrc_qp_num,
-+ struct ibv_qp_attr *attr,
-+ int attr_mask,
-+ struct ibv_qp_init_attr *init_attr);
-+ int (*reg_xrc_rcv_qp)(struct ibv_xrc_domain *xrc_domain,
-+ uint32_t xrc_qp_num);
-+ int (*unreg_xrc_rcv_qp)(struct ibv_xrc_domain *xrc_domain,
-+ uint32_t xrc_qp_num);
-+
- };
-
- struct ibv_context_ops {
-@@ -1174,6 +1195,108 @@ struct ibv_xrc_domain *ibv_open_xrc_doma
- */
- int ibv_close_xrc_domain(struct ibv_xrc_domain *d);
-
-+/**
-+ * ibv_create_xrc_rcv_qp - creates an XRC QP for serving as a receive-side-only QP,
-+ *
-+ * This QP is created in kernel space, and persists until the last process
-+ * registered for the QP calls ibv_unreg_xrc_rcv_qp() (at which time the QP
-+ * is destroyed).
-+ *
-+ * @init_attr: init attributes to use for QP. xrc domain MUST be included here.
-+ * All other fields are ignored.
-+ *
-+ * @xrc_rcv_qpn: qp_num of created QP (if success). To be passed to the
-+ * remote node (sender). The remote node will use xrc_rcv_qpn
-+ * in ibv_post_send when sending to XRC SRQ's on this host
-+ * in the same xrc domain.
-+ *
-+ * RETURNS: success (0), or a (negative) error value.
-+ *
-+ * NOTE: this verb also registers the calling user-process with the QP at its
-+ * creation time (implicit call to ibv_reg_xrc_rcv_qp), to avoid race
-+ * conditions. The creating process will need to call ibv_unreg_xrc_qp()
-+ * for the QP to release it from this process.
-+ */
-+int ibv_create_xrc_rcv_qp(struct ibv_qp_init_attr *init_attr,
-+ uint32_t *xrc_rcv_qpn);
-+
-+/**
-+ * ibv_modify_xrc_rcv_qp - modifies an xrc_rcv qp.
-+ *
-+ * @xrc_domain: xrc domain the QP belongs to (for verification).
-+ * @xrc_qp_num: The (24 bit) number of the XRC QP.
-+ * @attr: modify-qp attributes. The following fields must be specified:
-+ * for RESET_2_INIT: qp_state, pkey_index , port, qp_access_flags
-+ * for INIT_2_RTR: qp_state, path_mtu, dest_qp_num, rq_psn,
-+ * max_dest_rd_atomic, min_rnr_timer, ah_attr
-+ * The QP need not be brought to RTS for the QP to operate as a
-+ * receive-only QP.
-+ * @attr_mask: bitmap indicating which attributes are provided in the attr
-+ * struct. Used for validity checking.
-+ * The following bits must be set:
-+ * for RESET_2_INIT: IBV_QP_PKEY_INDEX, IBV_QP_PORT,
-+ * IBV_QP_ACCESS_FLAGS, IBV_QP_STATE
-+ * for INIT_2_RTR: IBV_QP_AV, IBV_QP_PATH_MTU, IBV_QP_DEST_QPN,
-+ * IBV_QP_RQ_PSN, IBV_QP_MAX_DEST_RD_ATOMIC,
-+ * IBV_QP_MIN_RNR_TIMER, IBV_QP_STATE
-+ *
-+ * RETURNS: success (0), or a (positive) error value.
-+ *
-+ */
-+int ibv_modify_xrc_rcv_qp(struct ibv_xrc_domain *xrc_domain,
-+ uint32_t xrc_qp_num,
-+ struct ibv_qp_attr *attr, int attr_mask);
-+
-+/**
-+ * ibv_query_xrc_rcv_qp - queries an xrc_rcv qp.
-+ *
-+ * @xrc_domain: xrc domain the QP belongs to (for verification).
-+ * @xrc_qp_num: The (24 bit) number of the XRC QP.
-+ * @attr: for returning qp attributes.
-+ * @attr_mask: bitmap indicating which attributes to return.
-+ * @init_attr: for returning the init attributes
-+ *
-+ * RETURNS: success (0), or a (positive) error value.
-+ *
-+ */
-+int ibv_query_xrc_rcv_qp(struct ibv_xrc_domain *xrc_domain, uint32_t xrc_qp_num,
-+ struct ibv_qp_attr *attr, int attr_mask,
-+ struct ibv_qp_init_attr *init_attr);
-+
-+/**
-+ * ibv_reg_xrc_rcv_qp: registers a user process with an XRC QP which serves as
-+ * a receive-side only QP.
-+ *
-+ * @xrc_domain: xrc domain the QP belongs to (for verification).
-+ * @xrc_qp_num: The (24 bit) number of the XRC QP.
-+ *
-+ * RETURNS: success (0),
-+ * or error (EINVAL), if:
-+ * 1. There is no such QP_num allocated.
-+ * 2. The QP is allocated, but is not an receive XRC QP
-+ * 3. The XRC QP does not belong to the given domain.
-+ */
-+int ibv_reg_xrc_rcv_qp(struct ibv_xrc_domain *xrc_domain, uint32_t xrc_qp_num);
-+
-+/**
-+ * ibv_unreg_xrc_rcv_qp: detaches a user process from an XRC QP serving as
-+ * a receive-side only QP. If as a result, there are no remaining
-+ * userspace processes registered for this XRC QP, it is destroyed.
-+ *
-+ * @xrc_domain: xrc domain the QP belongs to (for verification).
-+ * @xrc_qp_num: The (24 bit) number of the XRC QP.
-+ *
-+ * RETURNS: success (0),
-+ * or error (EINVAL), if:
-+ * 1. There is no such QP_num allocated.
-+ * 2. The QP is allocated, but is not an XRC QP
-+ * 3. The XRC QP does not belong to the given domain.
-+ * NOTE: There is no reason to return a special code if the QP is destroyed.
-+ * The unregister simply succeeds.
-+ */
-+int ibv_unreg_xrc_rcv_qp(struct ibv_xrc_domain *xrc_domain,
-+ uint32_t xrc_qp_num);
-+
- END_C_DECLS
-
- # undef __attribute_const
-Index: libibverbs/src/cmd.c
-===================================================================
---- libibverbs.orig/src/cmd.c 2009-11-01 15:18:20.643167000 +0200
-+++ libibverbs/src/cmd.c 2009-11-01 15:18:24.592284000 +0200
-@@ -828,6 +828,188 @@ int ibv_cmd_modify_qp(struct ibv_qp *qp,
- return 0;
- }
-
-+int ibv_cmd_create_xrc_rcv_qp(struct ibv_qp_init_attr *init_attr,
-+ uint32_t *xrc_rcv_qpn)
-+{
-+ struct ibv_create_xrc_rcv_qp cmd;
-+ struct ibv_create_xrc_rcv_qp_resp resp;
-+
-+ if (abi_ver < 6)
-+ return ENOSYS;
-+
-+ IBV_INIT_CMD_RESP(&cmd, sizeof cmd, CREATE_XRC_RCV_QP, &resp,
-+ sizeof resp);
-+
-+ cmd.xrc_domain_handle = init_attr->xrc_domain->handle;
-+ cmd.max_send_wr = init_attr->cap.max_send_wr;
-+ cmd.max_recv_wr = init_attr->cap.max_recv_wr;
-+ cmd.max_send_sge = init_attr->cap.max_send_sge;
-+ cmd.max_recv_sge = init_attr->cap.max_recv_sge;
-+ cmd.max_inline_data = init_attr->cap.max_inline_data;
-+ cmd.sq_sig_all = init_attr->sq_sig_all;
-+ cmd.qp_type = init_attr->qp_type;
-+ cmd.reserved[0] = cmd.reserved[1] = 0;
-+
-+ if (write(init_attr->xrc_domain->context->cmd_fd, &cmd, sizeof cmd) !=
-+ sizeof cmd)
-+ return errno;
-+
-+ *xrc_rcv_qpn = resp.qpn;
-+
-+ return 0;
-+}
-+
-+int ibv_cmd_modify_xrc_rcv_qp(struct ibv_xrc_domain *d, uint32_t xrc_qp_num,
-+ struct ibv_qp_attr *attr, int attr_mask)
-+{
-+ struct ibv_modify_xrc_rcv_qp cmd;
-+
-+ if (abi_ver < 6)
-+ return ENOSYS;
-+
-+ IBV_INIT_CMD(&cmd, sizeof cmd, MODIFY_XRC_RCV_QP);
-+
-+ cmd.xrc_domain_handle = d->handle;
-+ cmd.qp_num = xrc_qp_num;
-+ cmd.attr_mask = attr_mask;
-+ cmd.qkey = attr->qkey;
-+ cmd.rq_psn = attr->rq_psn;
-+ cmd.sq_psn = attr->sq_psn;
-+ cmd.dest_qp_num = attr->dest_qp_num;
-+ cmd.qp_access_flags = attr->qp_access_flags;
-+ cmd.pkey_index = attr->pkey_index;
-+ cmd.alt_pkey_index = attr->alt_pkey_index;
-+ cmd.qp_state = attr->qp_state;
-+ cmd.cur_qp_state = attr->cur_qp_state;
-+ cmd.path_mtu = attr->path_mtu;
-+ cmd.path_mig_state = attr->path_mig_state;
-+ cmd.en_sqd_async_notify = attr->en_sqd_async_notify;
-+ cmd.max_rd_atomic = attr->max_rd_atomic;
-+ cmd.max_dest_rd_atomic = attr->max_dest_rd_atomic;
-+ cmd.min_rnr_timer = attr->min_rnr_timer;
-+ cmd.port_num = attr->port_num;
-+ cmd.timeout = attr->timeout;
-+ cmd.retry_cnt = attr->retry_cnt;
-+ cmd.rnr_retry = attr->rnr_retry;
-+ cmd.alt_port_num = attr->alt_port_num;
-+ cmd.alt_timeout = attr->alt_timeout;
-+
-+ memcpy(cmd.dest.dgid, attr->ah_attr.grh.dgid.raw, 16);
-+ cmd.dest.flow_label = attr->ah_attr.grh.flow_label;
-+ cmd.dest.dlid = attr->ah_attr.dlid;
-+ cmd.dest.reserved = 0;
-+ cmd.dest.sgid_index = attr->ah_attr.grh.sgid_index;
-+ cmd.dest.hop_limit = attr->ah_attr.grh.hop_limit;
-+ cmd.dest.traffic_class = attr->ah_attr.grh.traffic_class;
-+ cmd.dest.sl = attr->ah_attr.sl;
-+ cmd.dest.src_path_bits = attr->ah_attr.src_path_bits;
-+ cmd.dest.static_rate = attr->ah_attr.static_rate;
-+ cmd.dest.is_global = attr->ah_attr.is_global;
-+ cmd.dest.port_num = attr->ah_attr.port_num;
-+
-+ memcpy(cmd.alt_dest.dgid, attr->alt_ah_attr.grh.dgid.raw, 16);
-+ cmd.alt_dest.flow_label = attr->alt_ah_attr.grh.flow_label;
-+ cmd.alt_dest.dlid = attr->alt_ah_attr.dlid;
-+ cmd.alt_dest.reserved = 0;
-+ cmd.alt_dest.sgid_index = attr->alt_ah_attr.grh.sgid_index;
-+ cmd.alt_dest.hop_limit = attr->alt_ah_attr.grh.hop_limit;
-+ cmd.alt_dest.traffic_class = attr->alt_ah_attr.grh.traffic_class;
-+ cmd.alt_dest.sl = attr->alt_ah_attr.sl;
-+ cmd.alt_dest.src_path_bits = attr->alt_ah_attr.src_path_bits;
-+ cmd.alt_dest.static_rate = attr->alt_ah_attr.static_rate;
-+ cmd.alt_dest.is_global = attr->alt_ah_attr.is_global;
-+ cmd.alt_dest.port_num = attr->alt_ah_attr.port_num;
-+
-+ cmd.reserved[0] = cmd.reserved[1] = 0;
-+
-+ if (write(d->context->cmd_fd, &cmd, sizeof cmd) != sizeof cmd)
-+ return errno;
-+
-+ return 0;
-+}
-+
-+int ibv_cmd_query_xrc_rcv_qp(struct ibv_xrc_domain *d, uint32_t xrc_qp_num,
-+ struct ibv_qp_attr *attr, int attr_mask,
-+ struct ibv_qp_init_attr *init_attr)
-+{
-+ struct ibv_query_xrc_rcv_qp cmd;
-+ struct ibv_query_qp_resp resp;
-+
-+ if (abi_ver < 6)
-+ return ENOSYS;
-+
-+ IBV_INIT_CMD_RESP(&cmd, sizeof cmd, QUERY_XRC_RCV_QP, &resp,
-+ sizeof resp);
-+ cmd.xrc_domain_handle = d->handle;
-+ cmd.qp_num = xrc_qp_num;
-+ cmd.attr_mask = attr_mask;
-+
-+ if (write(d->context->cmd_fd, &cmd, sizeof cmd) != sizeof cmd)
-+ return errno;
-+
-+ VALGRIND_MAKE_MEM_DEFINED(&resp, sizeof resp);
-+
-+ attr->qkey = resp.qkey;
-+ attr->rq_psn = resp.rq_psn;
-+ attr->sq_psn = resp.sq_psn;
-+ attr->dest_qp_num = resp.dest_qp_num;
-+ attr->qp_access_flags = resp.qp_access_flags;
-+ attr->pkey_index = resp.pkey_index;
-+ attr->alt_pkey_index = resp.alt_pkey_index;
-+ attr->qp_state = resp.qp_state;
-+ attr->cur_qp_state = resp.cur_qp_state;
-+ attr->path_mtu = resp.path_mtu;
-+ attr->path_mig_state = resp.path_mig_state;
-+ attr->sq_draining = resp.sq_draining;
-+ attr->max_rd_atomic = resp.max_rd_atomic;
-+ attr->max_dest_rd_atomic = resp.max_dest_rd_atomic;
-+ attr->min_rnr_timer = resp.min_rnr_timer;
-+ attr->port_num = resp.port_num;
-+ attr->timeout = resp.timeout;
-+ attr->retry_cnt = resp.retry_cnt;
-+ attr->rnr_retry = resp.rnr_retry;
-+ attr->alt_port_num = resp.alt_port_num;
-+ attr->alt_timeout = resp.alt_timeout;
-+ attr->cap.max_send_wr = resp.max_send_wr;
-+ attr->cap.max_recv_wr = resp.max_recv_wr;
-+ attr->cap.max_send_sge = resp.max_send_sge;
-+ attr->cap.max_recv_sge = resp.max_recv_sge;
-+ attr->cap.max_inline_data = resp.max_inline_data;
-+
-+ memcpy(attr->ah_attr.grh.dgid.raw, resp.dest.dgid, 16);
-+ attr->ah_attr.grh.flow_label = resp.dest.flow_label;
-+ attr->ah_attr.dlid = resp.dest.dlid;
-+ attr->ah_attr.grh.sgid_index = resp.dest.sgid_index;
-+ attr->ah_attr.grh.hop_limit = resp.dest.hop_limit;
-+ attr->ah_attr.grh.traffic_class = resp.dest.traffic_class;
-+ attr->ah_attr.sl = resp.dest.sl;
-+ attr->ah_attr.src_path_bits = resp.dest.src_path_bits;
-+ attr->ah_attr.static_rate = resp.dest.static_rate;
-+ attr->ah_attr.is_global = resp.dest.is_global;
-+ attr->ah_attr.port_num = resp.dest.port_num;
-+
-+ memcpy(attr->alt_ah_attr.grh.dgid.raw, resp.alt_dest.dgid, 16);
-+ attr->alt_ah_attr.grh.flow_label = resp.alt_dest.flow_label;
-+ attr->alt_ah_attr.dlid = resp.alt_dest.dlid;
-+ attr->alt_ah_attr.grh.sgid_index = resp.alt_dest.sgid_index;
-+ attr->alt_ah_attr.grh.hop_limit = resp.alt_dest.hop_limit;
-+ attr->alt_ah_attr.grh.traffic_class = resp.alt_dest.traffic_class;
-+ attr->alt_ah_attr.sl = resp.alt_dest.sl;
-+ attr->alt_ah_attr.src_path_bits = resp.alt_dest.src_path_bits;
-+ attr->alt_ah_attr.static_rate = resp.alt_dest.static_rate;
-+ attr->alt_ah_attr.is_global = resp.alt_dest.is_global;
-+ attr->alt_ah_attr.port_num = resp.alt_dest.port_num;
-+
-+ init_attr->cap.max_send_wr = resp.max_send_wr;
-+ init_attr->cap.max_recv_wr = resp.max_recv_wr;
-+ init_attr->cap.max_send_sge = resp.max_send_sge;
-+ init_attr->cap.max_recv_sge = resp.max_recv_sge;
-+ init_attr->cap.max_inline_data = resp.max_inline_data;
-+ init_attr->sq_sig_all = resp.sq_sig_all;
-+
-+ return 0;
-+}
-+
- static int ibv_cmd_destroy_qp_v1(struct ibv_qp *qp)
- {
- struct ibv_destroy_qp_v1 cmd;
-@@ -1192,3 +1374,36 @@ int ibv_cmd_close_xrc_domain(struct ibv_
- return 0;
- }
-
-+int ibv_cmd_reg_xrc_rcv_qp(struct ibv_xrc_domain *d, uint32_t xrc_qp_num)
-+{
-+ struct ibv_reg_xrc_rcv_qp cmd;
-+
-+ if (abi_ver < 6)
-+ return ENOSYS;
-+
-+ IBV_INIT_CMD(&cmd, sizeof cmd, REG_XRC_RCV_QP);
-+ cmd.xrc_domain_handle = d->handle;
-+ cmd.qp_num = xrc_qp_num;
-+
-+ if (write(d->context->cmd_fd, &cmd, sizeof cmd) != sizeof cmd)
-+ return errno;
-+ return 0;
-+}
-+
-+int ibv_cmd_unreg_xrc_rcv_qp(struct ibv_xrc_domain *d, uint32_t xrc_qp_num)
-+{
-+ struct ibv_unreg_xrc_rcv_qp cmd;
-+
-+ if (abi_ver < 6)
-+ return ENOSYS;
-+
-+ IBV_INIT_CMD(&cmd, sizeof cmd, UNREG_XRC_RCV_QP);
-+ cmd.xrc_domain_handle = d->handle;
-+ cmd.qp_num = xrc_qp_num;
-+
-+ if (write(d->context->cmd_fd, &cmd, sizeof cmd) != sizeof cmd)
-+ return errno;
-+ return 0;
-+}
-+
-+
-Index: libibverbs/src/device.c
-===================================================================
---- libibverbs.orig/src/device.c 2009-11-01 15:18:17.794116000 +0200
-+++ libibverbs/src/device.c 2009-11-01 15:18:24.597279000 +0200
-@@ -191,31 +191,33 @@ int __ibv_get_async_event(struct ibv_con
-
- event->event_type = ev.event_type;
-
-- switch (event->event_type) {
-- case IBV_EVENT_CQ_ERR:
-- event->element.cq = (void *) (uintptr_t) ev.element;
-- break;
--
-- case IBV_EVENT_QP_FATAL:
-- case IBV_EVENT_QP_REQ_ERR:
-- case IBV_EVENT_QP_ACCESS_ERR:
-- case IBV_EVENT_COMM_EST:
-- case IBV_EVENT_SQ_DRAINED:
-- case IBV_EVENT_PATH_MIG:
-- case IBV_EVENT_PATH_MIG_ERR:
-- case IBV_EVENT_QP_LAST_WQE_REACHED:
-- event->element.qp = (void *) (uintptr_t) ev.element;
-- break;
--
-- case IBV_EVENT_SRQ_ERR:
-- case IBV_EVENT_SRQ_LIMIT_REACHED:
-- event->element.srq = (void *) (uintptr_t) ev.element;
-- break;
--
-- default:
-- event->element.port_num = ev.element;
-- break;
-- }
-+ if (event->event_type & IBV_XRC_QP_EVENT_FLAG) {
-+ event->element.xrc_qp_num = ev.element;
-+ } else
-+ switch (event->event_type) {
-+ case IBV_EVENT_CQ_ERR:
-+ event->element.cq = (void *) (uintptr_t) ev.element;
-+ break;
-+
-+ case IBV_EVENT_QP_FATAL:
-+ case IBV_EVENT_QP_REQ_ERR:
-+ case IBV_EVENT_QP_ACCESS_ERR:
-+ case IBV_EVENT_COMM_EST:
-+ case IBV_EVENT_SQ_DRAINED:
-+ case IBV_EVENT_PATH_MIG:
-+ case IBV_EVENT_PATH_MIG_ERR:
-+ case IBV_EVENT_QP_LAST_WQE_REACHED:
-+ event->element.qp = (void *) (uintptr_t) ev.element;
-+ break;
-+
-+ case IBV_EVENT_SRQ_ERR:
-+ case IBV_EVENT_SRQ_LIMIT_REACHED:
-+ event->element.srq = (void *) (uintptr_t) ev.element;
-+ break;
-+ default:
-+ event->element.port_num = ev.element;
-+ break;
-+ }
-
- if (context->ops.async_event)
- context->ops.async_event(event);
-Index: libibverbs/src/libibverbs.map
-===================================================================
---- libibverbs.orig/src/libibverbs.map 2009-11-01 15:18:20.646169000 +0200
-+++ libibverbs/src/libibverbs.map 2009-11-01 15:18:24.600279000 +0200
-@@ -97,6 +97,16 @@ IBVERBS_1.1 {
- ibv_cmd_open_xrc_domain;
- ibv_close_xrc_domain;
- ibv_cmd_close_xrc_domain;
-+ ibv_create_xrc_rcv_qp;
-+ ibv_cmd_create_xrc_rcv_qp;
-+ ibv_modify_xrc_rcv_qp;
-+ ibv_cmd_modify_xrc_rcv_qp;
-+ ibv_query_xrc_rcv_qp;
-+ ibv_cmd_query_xrc_rcv_qp;
-+ ibv_reg_xrc_rcv_qp;
-+ ibv_cmd_reg_xrc_rcv_qp;
-+ ibv_unreg_xrc_rcv_qp;
-+ ibv_cmd_unreg_xrc_rcv_qp;
-
- ibv_node_type_str;
- ibv_port_state_str;
-Index: libibverbs/src/verbs.c
-===================================================================
---- libibverbs.orig/src/verbs.c 2009-11-01 15:18:20.650169000 +0200
-+++ libibverbs/src/verbs.c 2009-11-01 15:18:24.604279000 +0200
-@@ -597,3 +597,62 @@ int ibv_close_xrc_domain(struct ibv_xrc_
-
- return d->context->more_ops->close_xrc_domain(d);
- }
-+
-+int ibv_create_xrc_rcv_qp(struct ibv_qp_init_attr *init_attr,
-+ uint32_t *xrc_rcv_qpn)
-+{
-+ struct ibv_context *c;
-+ if (!init_attr || !(init_attr->xrc_domain))
-+ return EINVAL;
-+
-+ c = init_attr->xrc_domain->context;
-+ if (!c->more_ops)
-+ return ENOSYS;
-+
-+ return c->more_ops->create_xrc_rcv_qp(init_attr,
-+ xrc_rcv_qpn);
-+}
-+
-+int ibv_modify_xrc_rcv_qp(struct ibv_xrc_domain *d,
-+ uint32_t xrc_rcv_qpn,
-+ struct ibv_qp_attr *attr,
-+ int attr_mask)
-+{
-+ if (!d || !attr)
-+ return EINVAL;
-+
-+ if (!d->context->more_ops)
-+ return ENOSYS;
-+
-+ return d->context->more_ops->modify_xrc_rcv_qp(d, xrc_rcv_qpn, attr,
-+ attr_mask);
-+}
-+
-+int ibv_query_xrc_rcv_qp(struct ibv_xrc_domain *d,
-+ uint32_t xrc_rcv_qpn,
-+ struct ibv_qp_attr *attr,
-+ int attr_mask,
-+ struct ibv_qp_init_attr *init_attr)
-+{
-+ if (!d)
-+ return EINVAL;
-+
-+ if (!d->context->more_ops)
-+ return ENOSYS;
-+
-+ return d->context->more_ops->query_xrc_rcv_qp(d, xrc_rcv_qpn, attr,
-+ attr_mask, init_attr);
-+}
-+
-+int ibv_reg_xrc_rcv_qp(struct ibv_xrc_domain *d,
-+ uint32_t xrc_rcv_qpn)
-+{
-+ return d->context->more_ops->reg_xrc_rcv_qp(d, xrc_rcv_qpn);
-+}
-+
-+int ibv_unreg_xrc_rcv_qp(struct ibv_xrc_domain *d,
-+ uint32_t xrc_rcv_qpn)
-+{
-+ return d->context->more_ops->unreg_xrc_rcv_qp(d, xrc_rcv_qpn);
-+}
-+
diff --git a/contrib/ofed/libibverbs/fixes/XRC_base_implementation.patch b/contrib/ofed/libibverbs/fixes/XRC_base_implementation.patch
deleted file mode 100644
index b4706a8..0000000
--- a/contrib/ofed/libibverbs/fixes/XRC_base_implementation.patch
+++ /dev/null
@@ -1,503 +0,0 @@
-This patch includes the following commits from OFED 1.3 libibverbs:
-Implement eXtended Reliable Connections (a7df4af8eb84738f36db4161a4272fa02fc6741e)
-Re-define IBV_DEVICE_XRC to conform to its new position (5042a9cab0ae2f7ad61bdf88dfed6fb10b700797)
-Set "is_srq" flag only when the QP has an SRQ (6f6d29e74ca0c19a8821990aad603e3c575b7f4d)
-for XRC QPs, return xrc_domain in ibv_query_qp (018c44a44ff0344dfe7cf5f6598f81d81769164e)
-
-V2:
-1. checkpatch.pl cleanups
-2. fixed u64 alignment problems in uverbs.h ABI structs
-3. eliminated unnecessary default_symvers
-4. modified xrc_ops to more_ops
-
-Signed-off-by: Jack Morgenstein <jackm@dev.mellanox.co.il>
- include/infiniband/driver.h | 11 +++++
- include/infiniband/kern-abi.h | 47 ++++++++++++++++++++++-
- include/infiniband/verbs.h | 85 ++++++++++++++++++++++++++++++++++++++++-
- src/cmd.c | 72 ++++++++++++++++++++++++++++++++++-
- src/libibverbs.map | 6 +++
- src/verbs.c | 54 ++++++++++++++++++++++++++
- 6 files changed, 271 insertions(+), 4 deletions(-)
-
-Index: libibverbs/include/infiniband/driver.h
-===================================================================
---- libibverbs.orig/include/infiniband/driver.h 2009-11-01 15:18:17.920111000 +0200
-+++ libibverbs/include/infiniband/driver.h 2009-11-01 15:18:20.624171000 +0200
-@@ -99,6 +99,11 @@ int ibv_cmd_create_srq(struct ibv_pd *pd
- struct ibv_srq *srq, struct ibv_srq_init_attr *attr,
- struct ibv_create_srq *cmd, size_t cmd_size,
- struct ibv_create_srq_resp *resp, size_t resp_size);
-+int ibv_cmd_create_xrc_srq(struct ibv_pd *pd,
-+ struct ibv_srq *srq, struct ibv_srq_init_attr *attr,
-+ uint32_t xrc_domain, uint32_t xrc_cq,
-+ struct ibv_create_xrc_srq *cmd, size_t cmd_size,
-+ struct ibv_create_srq_resp *resp, size_t resp_size);
- int ibv_cmd_modify_srq(struct ibv_srq *srq,
- struct ibv_srq_attr *srq_attr,
- int srq_attr_mask,
-@@ -134,6 +139,12 @@ int ibv_cmd_detach_mcast(struct ibv_qp *
-
- int ibv_dontfork_range(void *base, size_t size);
- int ibv_dofork_range(void *base, size_t size);
-+int ibv_cmd_open_xrc_domain(struct ibv_context *context, int fd, int oflag,
-+ struct ibv_xrc_domain *d,
-+ struct ibv_open_xrc_domain_resp *resp,
-+ size_t resp_size);
-+int ibv_cmd_close_xrc_domain(struct ibv_xrc_domain *d);
-+
-
- /*
- * sysfs helper functions
-Index: libibverbs/include/infiniband/kern-abi.h
-===================================================================
---- libibverbs.orig/include/infiniband/kern-abi.h 2009-11-01 15:18:17.921121000 +0200
-+++ libibverbs/include/infiniband/kern-abi.h 2009-11-01 15:18:20.629168000 +0200
-@@ -85,7 +85,10 @@ enum {
- IB_USER_VERBS_CMD_MODIFY_SRQ,
- IB_USER_VERBS_CMD_QUERY_SRQ,
- IB_USER_VERBS_CMD_DESTROY_SRQ,
-- IB_USER_VERBS_CMD_POST_SRQ_RECV
-+ IB_USER_VERBS_CMD_POST_SRQ_RECV,
-+ IB_USER_VERBS_CMD_CREATE_XRC_SRQ,
-+ IB_USER_VERBS_CMD_OPEN_XRC_DOMAIN,
-+ IB_USER_VERBS_CMD_CLOSE_XRC_DOMAIN
- };
-
- /*
-@@ -706,6 +709,21 @@ struct ibv_create_srq {
- __u64 driver_data[0];
- };
-
-+struct ibv_create_xrc_srq {
-+ __u32 command;
-+ __u16 in_words;
-+ __u16 out_words;
-+ __u64 response;
-+ __u64 user_handle;
-+ __u32 pd_handle;
-+ __u32 max_wr;
-+ __u32 max_sge;
-+ __u32 srq_limit;
-+ __u32 xrcd_handle;
-+ __u32 xrc_cq;
-+ __u64 driver_data[0];
-+};
-+
- struct ibv_create_srq_resp {
- __u32 srq_handle;
- __u32 max_wr;
-@@ -754,6 +772,30 @@ struct ibv_destroy_srq_resp {
- __u32 events_reported;
- };
-
-+struct ibv_open_xrc_domain {
-+ __u32 command;
-+ __u16 in_words;
-+ __u16 out_words;
-+ __u64 response;
-+ __u32 fd;
-+ __u32 oflags;
-+ __u64 driver_data[0];
-+};
-+
-+struct ibv_open_xrc_domain_resp {
-+ __u32 xrcd_handle;
-+};
-+
-+struct ibv_close_xrc_domain {
-+ __u32 command;
-+ __u16 in_words;
-+ __u16 out_words;
-+ __u64 response;
-+ __u32 xrcd_handle;
-+ __u32 reserved;
-+ __u64 driver_data[0];
-+};
-+
- /*
- * Compatibility with older ABI versions
- */
-@@ -803,6 +845,9 @@ enum {
- * trick opcodes in IBV_INIT_CMD() doesn't break.
- */
- IB_USER_VERBS_CMD_CREATE_COMP_CHANNEL_V2 = -1,
-+ IB_USER_VERBS_CMD_CREATE_XRC_SRQ_V2 = -1,
-+ IB_USER_VERBS_CMD_OPEN_XRC_DOMAIN_V2 = -1,
-+ IB_USER_VERBS_CMD_CLOSE_XRC_DOMAIN_V2 = -1,
- };
-
- struct ibv_destroy_cq_v1 {
-Index: libibverbs/include/infiniband/verbs.h
-===================================================================
---- libibverbs.orig/include/infiniband/verbs.h 2009-11-01 15:18:17.924118000 +0200
-+++ libibverbs/include/infiniband/verbs.h 2009-11-01 15:18:20.635171000 +0200
-@@ -92,7 +92,8 @@ enum ibv_device_cap_flags {
- IBV_DEVICE_SYS_IMAGE_GUID = 1 << 11,
- IBV_DEVICE_RC_RNR_NAK_GEN = 1 << 12,
- IBV_DEVICE_SRQ_RESIZE = 1 << 13,
-- IBV_DEVICE_N_NOTIFY_CQ = 1 << 14
-+ IBV_DEVICE_N_NOTIFY_CQ = 1 << 14,
-+ IBV_DEVICE_XRC = 1 << 20
- };
-
- enum ibv_atomic_cap {
-@@ -371,6 +372,11 @@ struct ibv_ah_attr {
- uint8_t port_num;
- };
-
-+struct ibv_xrc_domain {
-+ struct ibv_context *context;
-+ uint32_t handle;
-+};
-+
- enum ibv_srq_attr_mask {
- IBV_SRQ_MAX_WR = 1 << 0,
- IBV_SRQ_LIMIT = 1 << 1
-@@ -390,7 +396,8 @@ struct ibv_srq_init_attr {
- enum ibv_qp_type {
- IBV_QPT_RC = 2,
- IBV_QPT_UC,
-- IBV_QPT_UD
-+ IBV_QPT_UD,
-+ IBV_QPT_XRC
- };
-
- struct ibv_qp_cap {
-@@ -409,6 +416,7 @@ struct ibv_qp_init_attr {
- struct ibv_qp_cap cap;
- enum ibv_qp_type qp_type;
- int sq_sig_all;
-+ struct ibv_xrc_domain *xrc_domain;
- };
-
- enum ibv_qp_attr_mask {
-@@ -527,6 +535,7 @@ struct ibv_send_wr {
- uint32_t remote_qkey;
- } ud;
- } wr;
-+ uint32_t xrc_remote_srq_num;
- };
-
- struct ibv_recv_wr {
-@@ -554,6 +563,10 @@ struct ibv_srq {
- pthread_mutex_t mutex;
- pthread_cond_t cond;
- uint32_t events_completed;
-+
-+ uint32_t xrc_srq_num;
-+ struct ibv_xrc_domain *xrc_domain;
-+ struct ibv_cq *xrc_cq;
- };
-
- struct ibv_qp {
-@@ -571,6 +584,8 @@ struct ibv_qp {
- pthread_mutex_t mutex;
- pthread_cond_t cond;
- uint32_t events_completed;
-+
-+ struct ibv_xrc_domain *xrc_domain;
- };
-
- struct ibv_comp_channel {
-@@ -625,6 +640,16 @@ struct ibv_device {
- char ibdev_path[IBV_SYSFS_PATH_MAX];
- };
-
-+struct ibv_more_ops {
-+ struct ibv_srq * (*create_xrc_srq)(struct ibv_pd *pd,
-+ struct ibv_xrc_domain *xrc_domain,
-+ struct ibv_cq *xrc_cq,
-+ struct ibv_srq_init_attr *srq_init_attr);
-+ struct ibv_xrc_domain * (*open_xrc_domain)(struct ibv_context *context,
-+ int fd, int oflag);
-+ int (*close_xrc_domain)(struct ibv_xrc_domain *d);
-+};
-+
- struct ibv_context_ops {
- int (*query_device)(struct ibv_context *context,
- struct ibv_device_attr *device_attr);
-@@ -691,6 +716,7 @@ struct ibv_context {
- int num_comp_vectors;
- pthread_mutex_t mutex;
- void *abi_compat;
-+ struct ibv_more_ops *more_ops;
- };
-
- /**
-@@ -913,6 +939,25 @@ struct ibv_srq *ibv_create_srq(struct ib
- struct ibv_srq_init_attr *srq_init_attr);
-
- /**
-+ * ibv_create_xrc_srq - Creates a SRQ associated with the specified protection
-+ * domain and xrc domain.
-+ * @pd: The protection domain associated with the SRQ.
-+ * @xrc_domain: The XRC domain associated with the SRQ.
-+ * @xrc_cq: CQ to report completions for XRC packets on.
-+ *
-+ * @srq_init_attr: A list of initial attributes required to create the SRQ.
-+ *
-+ * srq_attr->max_wr and srq_attr->max_sge are read the determine the
-+ * requested size of the SRQ, and set to the actual values allocated
-+ * on return. If ibv_create_srq() succeeds, then max_wr and max_sge
-+ * will always be at least as large as the requested values.
-+ */
-+struct ibv_srq *ibv_create_xrc_srq(struct ibv_pd *pd,
-+ struct ibv_xrc_domain *xrc_domain,
-+ struct ibv_cq *xrc_cq,
-+ struct ibv_srq_init_attr *srq_init_attr);
-+
-+/**
- * ibv_modify_srq - Modifies the attributes for the specified SRQ.
- * @srq: The SRQ to modify.
- * @srq_attr: On input, specifies the SRQ attributes to modify. On output,
-@@ -1093,6 +1138,42 @@ const char *ibv_port_state_str(enum ibv_
- */
- const char *ibv_event_type_str(enum ibv_event_type event);
-
-+/**
-+ * ibv_open_xrc_domain - open an XRC domain
-+ * Returns a reference to an XRC domain.
-+ *
-+ * @context: Device context
-+ * @fd: descriptor for inode associated with the domain
-+ * If fd == -1, no inode is associated with the domain; in this ca= se,
-+ * the only legal value for oflag is O_CREAT
-+ *
-+ * @oflag: oflag values are constructed by OR-ing flags from the following list
-+ *
-+ * O_CREAT
-+ * If a domain belonging to device named by context is already associated
-+ * with the inode, this flag has no effect, except as noted under O_EXCL
-+ * below. Otherwise, a new XRC domain is created and is associated with
-+ * inode specified by fd.
-+ *
-+ * O_EXCL
-+ * If O_EXCL and O_CREAT are set, open will fail if a domain associated with
-+ * the inode exists. The check for the existence of the domain and creation
-+ * of the domain if it does not exist is atomic with respect to other
-+ * processes executing open with fd naming the same inode.
-+ */
-+struct ibv_xrc_domain *ibv_open_xrc_domain(struct ibv_context *context,
-+ int fd, int oflag);
-+
-+/**
-+ * ibv_close_xrc_domain - close an XRC domain
-+ * If this is the last reference, destroys the domain.
-+ *
-+ * @d: reference to XRC domain to close
-+ *
-+ * close is implicitly performed at process exit.
-+ */
-+int ibv_close_xrc_domain(struct ibv_xrc_domain *d);
-+
- END_C_DECLS
-
- # undef __attribute_const
-Index: libibverbs/src/cmd.c
-===================================================================
---- libibverbs.orig/src/cmd.c 2009-11-01 15:18:17.927111000 +0200
-+++ libibverbs/src/cmd.c 2009-11-01 15:18:20.643167000 +0200
-@@ -483,6 +483,34 @@ int ibv_cmd_create_srq(struct ibv_pd *pd
- return 0;
- }
-
-+int ibv_cmd_create_xrc_srq(struct ibv_pd *pd,
-+ struct ibv_srq *srq, struct ibv_srq_init_attr *attr,
-+ uint32_t xrcd_handle, uint32_t xrc_cq,
-+ struct ibv_create_xrc_srq *cmd, size_t cmd_size,
-+ struct ibv_create_srq_resp *resp, size_t resp_size)
-+{
-+ IBV_INIT_CMD_RESP(cmd, cmd_size, CREATE_XRC_SRQ, resp, resp_size);
-+ cmd->user_handle = (uintptr_t) srq;
-+ cmd->pd_handle = pd->handle;
-+ cmd->max_wr = attr->attr.max_wr;
-+ cmd->max_sge = attr->attr.max_sge;
-+ cmd->srq_limit = attr->attr.srq_limit;
-+ cmd->xrcd_handle = xrcd_handle;
-+ cmd->xrc_cq = xrc_cq;
-+
-+ if (write(pd->context->cmd_fd, cmd, cmd_size) != cmd_size)
-+ return errno;
-+
-+ VALGRIND_MAKE_MEM_DEFINED(resp, resp_size);
-+
-+ srq->handle = resp->srq_handle;
-+ srq->context = pd->context;
-+ attr->attr.max_wr = resp->max_wr;
-+ attr->attr.max_sge = resp->max_sge;
-+
-+ return 0;
-+}
-+
- static int ibv_cmd_modify_srq_v3(struct ibv_srq *srq,
- struct ibv_srq_attr *srq_attr,
- int srq_attr_mask,
-@@ -603,7 +631,6 @@ int ibv_cmd_create_qp(struct ibv_pd *pd,
- cmd->pd_handle = pd->handle;
- cmd->send_cq_handle = attr->send_cq->handle;
- cmd->recv_cq_handle = attr->recv_cq->handle;
-- cmd->srq_handle = attr->srq ? attr->srq->handle : 0;
- cmd->max_send_wr = attr->cap.max_send_wr;
- cmd->max_recv_wr = attr->cap.max_recv_wr;
- cmd->max_send_sge = attr->cap.max_send_sge;
-@@ -612,6 +639,9 @@ int ibv_cmd_create_qp(struct ibv_pd *pd,
- cmd->sq_sig_all = attr->sq_sig_all;
- cmd->qp_type = attr->qp_type;
- cmd->is_srq = !!attr->srq;
-+ cmd->srq_handle = attr->qp_type == IBV_QPT_XRC ?
-+ (attr->xrc_domain ? attr->xrc_domain->handle : 0) :
-+ (attr->srq ? attr->srq->handle : 0);
- cmd->reserved = 0;
-
- if (write(pd->context->cmd_fd, cmd, cmd_size) != cmd_size)
-@@ -722,6 +752,8 @@ int ibv_cmd_query_qp(struct ibv_qp *qp,
- init_attr->recv_cq = qp->recv_cq;
- init_attr->srq = qp->srq;
- init_attr->qp_type = qp->qp_type;
-+ if (qp->qp_type == IBV_QPT_XRC)
-+ init_attr->xrc_domain = qp->xrc_domain;
- init_attr->cap.max_send_wr = resp.max_send_wr;
- init_attr->cap.max_recv_wr = resp.max_recv_wr;
- init_attr->cap.max_send_sge = resp.max_send_sge;
-@@ -1122,3 +1154,41 @@ int ibv_cmd_detach_mcast(struct ibv_qp *
-
- return 0;
- }
-+
-+int ibv_cmd_open_xrc_domain(struct ibv_context *context, int fd, int oflag,
-+ struct ibv_xrc_domain *d,
-+ struct ibv_open_xrc_domain_resp *resp,
-+ size_t resp_size)
-+{
-+ struct ibv_open_xrc_domain cmd;
-+
-+ if (abi_ver < 6)
-+ return ENOSYS;
-+
-+ IBV_INIT_CMD_RESP(&cmd, sizeof cmd, OPEN_XRC_DOMAIN, resp, resp_size);
-+ cmd.fd = fd;
-+ cmd.oflags = oflag;
-+
-+ if (write(context->cmd_fd, &cmd, sizeof cmd) != sizeof cmd)
-+ return errno;
-+
-+ d->handle = resp->xrcd_handle;
-+
-+ return 0;
-+}
-+
-+int ibv_cmd_close_xrc_domain(struct ibv_xrc_domain *d)
-+{
-+ struct ibv_close_xrc_domain cmd;
-+
-+ if (abi_ver < 6)
-+ return ENOSYS;
-+
-+ IBV_INIT_CMD(&cmd, sizeof cmd, CLOSE_XRC_DOMAIN);
-+ cmd.xrcd_handle = d->handle;
-+
-+ if (write(d->context->cmd_fd, &cmd, sizeof cmd) != sizeof cmd)
-+ return errno;
-+ return 0;
-+}
-+
-Index: libibverbs/src/libibverbs.map
-===================================================================
---- libibverbs.orig/src/libibverbs.map 2009-11-01 15:18:17.928115000 +0200
-+++ libibverbs/src/libibverbs.map 2009-11-01 15:18:20.646169000 +0200
-@@ -91,6 +91,12 @@ IBVERBS_1.1 {
- ibv_dontfork_range;
- ibv_dofork_range;
- ibv_register_driver;
-+ ibv_create_xrc_srq;
-+ ibv_cmd_create_xrc_srq;
-+ ibv_open_xrc_domain;
-+ ibv_cmd_open_xrc_domain;
-+ ibv_close_xrc_domain;
-+ ibv_cmd_close_xrc_domain;
-
- ibv_node_type_str;
- ibv_port_state_str;
-Index: libibverbs/src/verbs.c
-===================================================================
---- libibverbs.orig/src/verbs.c 2009-11-01 15:18:17.931119000 +0200
-+++ libibverbs/src/verbs.c 2009-11-01 15:18:20.650169000 +0200
-@@ -366,6 +366,9 @@ struct ibv_srq *__ibv_create_srq(struct
- srq->context = pd->context;
- srq->srq_context = srq_init_attr->srq_context;
- srq->pd = pd;
-+ srq->xrc_domain = NULL;
-+ srq->xrc_cq = NULL;
-+ srq->xrc_srq_num = 0;
- srq->events_completed = 0;
- pthread_mutex_init(&srq->mutex, NULL);
- pthread_cond_init(&srq->cond, NULL);
-@@ -375,6 +378,32 @@ struct ibv_srq *__ibv_create_srq(struct
- }
- default_symver(__ibv_create_srq, ibv_create_srq);
-
-+struct ibv_srq *ibv_create_xrc_srq(struct ibv_pd *pd,
-+ struct ibv_xrc_domain *xrc_domain,
-+ struct ibv_cq *xrc_cq,
-+ struct ibv_srq_init_attr *srq_init_attr)
-+{
-+ struct ibv_srq *srq;
-+
-+ if (!pd->context->more_ops)
-+ return NULL;
-+
-+ srq = pd->context->more_ops->create_xrc_srq(pd, xrc_domain,
-+ xrc_cq, srq_init_attr);
-+ if (srq) {
-+ srq->context = pd->context;
-+ srq->srq_context = srq_init_attr->srq_context;
-+ srq->pd = pd;
-+ srq->xrc_domain = xrc_domain;
-+ srq->xrc_cq = xrc_cq;
-+ srq->events_completed = 0;
-+ pthread_mutex_init(&srq->mutex, NULL);
-+ pthread_cond_init(&srq->cond, NULL);
-+ }
-+
-+ return srq;
-+}
-+
- int __ibv_modify_srq(struct ibv_srq *srq,
- struct ibv_srq_attr *srq_attr,
- int srq_attr_mask)
-@@ -410,6 +439,8 @@ struct ibv_qp *__ibv_create_qp(struct ib
- qp->qp_type = qp_init_attr->qp_type;
- qp->state = IBV_QPS_RESET;
- qp->events_completed = 0;
-+ qp->xrc_domain = qp_init_attr->qp_type == IBV_QPT_XRC ?
-+ qp_init_attr->xrc_domain : NULL;
- pthread_mutex_init(&qp->mutex, NULL);
- pthread_cond_init(&qp->cond, NULL);
- }
-@@ -543,3 +574,26 @@ int __ibv_detach_mcast(struct ibv_qp *qp
- return qp->context->ops.detach_mcast(qp, gid, lid);
- }
- default_symver(__ibv_detach_mcast, ibv_detach_mcast);
-+
-+struct ibv_xrc_domain *ibv_open_xrc_domain(struct ibv_context *context,
-+ int fd, int oflag)
-+{
-+ struct ibv_xrc_domain *d;
-+
-+ if (!context->more_ops)
-+ return NULL;
-+
-+ d = context->more_ops->open_xrc_domain(context, fd, oflag);
-+ if (d)
-+ d->context = context;
-+
-+ return d;
-+}
-+
-+int ibv_close_xrc_domain(struct ibv_xrc_domain *d)
-+{
-+ if (!d->context->more_ops)
-+ return 0;
-+
-+ return d->context->more_ops->close_xrc_domain(d);
-+}
diff --git a/contrib/ofed/libibverbs/fixes/XRC_man_pages.patch b/contrib/ofed/libibverbs/fixes/XRC_man_pages.patch
deleted file mode 100644
index d332fd0a..0000000
--- a/contrib/ofed/libibverbs/fixes/XRC_man_pages.patch
+++ /dev/null
@@ -1,686 +0,0 @@
-commit b7c5820ce48a4fc3c8464872f0a554df6e7bbb47
-Author: Dotan Barak <dotanb@mellanox.co.il>
-Date: Mon Feb 25 16:50:38 2008 +0200
-
- Add XRC (eXtended Reliable Connection) support to all of the relevant man pages
- and add new man pages to new XRC verbs.
-
- Signed-off-by: Dotan Barak <dotanb@dev.mellanox.co.il>
- Signed-off-by: Jack Morgenstein <jackm@dev.mellanox.co.il>
-
-diff --git a/man/ibv_create_qp.3 b/man/ibv_create_qp.3
-index abd5449..fb6f041 100644
-Index: libibverbs/man/ibv_create_qp.3
-===================================================================
---- libibverbs.orig/man/ibv_create_qp.3 2008-06-05 15:21:54.000000000 +0300
-+++ libibverbs/man/ibv_create_qp.3 2008-06-05 16:25:21.000000000 +0300
-@@ -28,8 +28,9 @@ struct ibv_cq *send_cq;
- struct ibv_cq *recv_cq; /* CQ to be associated with the Receive Queue (RQ) */
- struct ibv_srq *srq; /* SRQ handle if QP is to be associated with an SRQ, otherwise NULL */
- struct ibv_qp_cap cap; /* QP capabilities */
--enum ibv_qp_type qp_type; /* QP Transport Service Type: IBV_QPT_RC, IBV_QPT_UC, or IBV_QPT_UD */
-+enum ibv_qp_type qp_type; /* QP Transport Service Type: IBV_QPT_RC, IBV_QPT_UC, IBV_QPT_UD or IBV_QPT_XRC */
- int sq_sig_all; /* If set, each Work Request (WR) submitted to the SQ generates a completion entry */
-+struct ibv_xrc_domain *xrc_domain; /* XRC domain the QP will be associated with (valid only for IBV_QPT_XRC QP), otherwise NULL */
- .in -8
- };
- .sp
-Index: libibverbs/man/ibv_create_srq.3
-===================================================================
---- libibverbs.orig/man/ibv_create_srq.3 2008-06-05 15:21:54.000000000 +0300
-+++ libibverbs/man/ibv_create_srq.3 2008-06-05 16:25:21.000000000 +0300
-@@ -10,12 +10,26 @@ ibv_create_srq, ibv_destroy_srq \- creat
- .BI "struct ibv_srq *ibv_create_srq(struct ibv_pd " "*pd" ", struct "
- .BI " ibv_srq_init_attr " "*srq_init_attr" );
- .sp
-+.BI "struct ibv_srq *ibv_create_xrc_srq(struct ibv_pd " "*pd" ",
-+.BI " struct ibv_xrc_domain " "*xrc_domain" ",
-+.BI " struct ibv_cq " "*xrc_cq" ",
-+.BI " struct ibv_srq_init_attr " "*srq_init_attr" );
-+.sp
- .BI "int ibv_destroy_srq(struct ibv_srq " "*srq" );
- .fi
- .SH "DESCRIPTION"
- .B ibv_create_srq()
- creates a shared receive queue (SRQ) associated with the protection domain
- .I pd\fR.
-+.PP
-+.B ibv_create_xrc_srq()
-+creates an XRC shared receive queue (SRQ) associated with the protection domain
-+.I pd\fR,
-+the XRC domain
-+.I xrc_domain
-+and the CQ which will hold the XRC completion
-+.I xrc_cq\fR.
-+.PP
- The argument
- .I srq_init_attr
- is an ibv_srq_init_attr struct, as defined in <infiniband/verbs.h>.
-Index: libibverbs/man/ibv_create_xrc_rcv_qp.3
-===================================================================
---- /dev/null 1970-01-01 00:00:00.000000000 +0000
-+++ libibverbs/man/ibv_create_xrc_rcv_qp.3 2008-06-05 16:25:21.000000000 +0300
-@@ -0,0 +1,70 @@
-+.\" -*- nroff -*-
-+.\"
-+.TH IBV_CREATE_XRC_RCV_QP 3 2008-02-10 libibverbs "Libibverbs Programmer's Manual"
-+.SH "NAME"
-+ibv_create_xrc_rcv_qp \- create an XRC queue pair (QP) for serving as a receive-side only QP
-+.SH "SYNOPSIS"
-+.nf
-+.B #include <infiniband/verbs.h>
-+.sp
-+.BI "int ibv_create_xrc_rcv_qp(struct ibv_qp_init_attr " "*init_attr" ,
-+.BI " uint32_t " "*xrc_rcv_qpn" );
-+.fi
-+.SH "DESCRIPTION"
-+.B ibv_create_xrc_rcv_qp()
-+creates an XRC queue pair (QP) for serving as a receive-side only QP and returns its number through the pointer
-+.I xrc_rcv_qpn\fR.
-+This QP number should be passed to the remote node (sender).
-+The remote node will use
-+.I xrc_rcv_qpn
-+in
-+.B ibv_post_send()
-+when sending to an XRC SRQ on this host in the same xrc domain as the XRC receive QP.
-+This QP is created in kernel space, and persists until the last process registered for the QP
-+calls
-+.B ibv_unreg_xrc_rcv_qp()
-+(at which time the QP is destroyed).
-+.PP
-+The process which creates this QP is automatically registered for it, and should also call
-+.B ibv_unreg_xrc_rcv_qp()
-+at some point, to unregister.
-+
-+Processes which wish to receive on an XRC SRQ via this QP should call
-+.B ibv_reg_xrc_rcv_qp()
-+for this QP, to guarantee that the QP will not be destroyed while they are still using it for receiving on the XRC SRQ.
-+.PP
-+The argument
-+.I qp_init_attr
-+is an ibv_qp_init_attr struct, as defined in <infiniband/verbs.h>.
-+.PP
-+.nf
-+struct ibv_qp_init_attr {
-+.in +8
-+void *qp_context; /* value is being ignored */
-+struct ibv_cq *send_cq; /* value is being ignored */
-+struct ibv_cq *recv_cq; /* value is being ignored */
-+struct ibv_srq *srq; /* value is being ignored */
-+struct ibv_qp_cap cap; /* value is being ignored */
-+enum ibv_qp_type qp_type; /* value is being ignored */
-+int sq_sig_all; /* value is being ignored */
-+struct ibv_xrc_domain *xrc_domain; /* XRC domain the QP will be associated with */
-+.in -8
-+};
-+.fi
-+.PP
-+Most of the attributes in
-+.I qp_init_attr
-+are being ignored because this QP is a receive only QP and all RR are being posted to an SRQ.
-+.SH "RETURN VALUE"
-+.B ibv_create_xrc_rcv_qp()
-+returns 0 on success, or the value of errno on failure (which indicates the failure reason).
-+.SH "SEE ALSO"
-+.BR ibv_open_xrc_domain (3),
-+.BR ibv_modify_xrc_rcv_qp (3),
-+.BR ibv_query_xrc_rcv_qp (3),
-+.BR ibv_reg_xrc_rcv_qp (3),
-+.BR ibv_unreg_xrc_rcv_qp (3),
-+.BR ibv_post_send (3)
-+.SH "AUTHORS"
-+.TP
-+Dotan Barak <dotanb@mellanox.co.il>
-Index: libibverbs/man/ibv_modify_xrc_rcv_qp.3
-===================================================================
---- /dev/null 1970-01-01 00:00:00.000000000 +0000
-+++ libibverbs/man/ibv_modify_xrc_rcv_qp.3 2008-06-05 16:25:21.000000000 +0300
-@@ -0,0 +1,141 @@
-+.\" -*- nroff -*-
-+.\"
-+.TH IBV_MODIFY_XRC_RCV_QP 3 2008-02-10 libibverbs "Libibverbs Programmer's Manual"
-+.SH "NAME"
-+ibv_modify_xrc_rcv_qp \- modify the attributes of an XRC receive queue pair (QP)
-+.SH "SYNOPSIS"
-+.nf
-+.B #include <infiniband/verbs.h>
-+.sp
-+.BI "int ibv_modify_xrc_rcv_qp(struct ibv_xrc_domain " "*xrc_domain" ", uint32_t " "xrc_qp_num" ,
-+.BI " struct ibv_qp_attr " "*attr" ", int " "attr_mask" );
-+.fi
-+.SH "DESCRIPTION"
-+.B ibv_modify_qp()
-+modifies the attributes of an XRC receive QP with the number
-+.I xrc_qp_num
-+which is associated with the XRC domain
-+.I xrc_domain
-+with the attributes in
-+.I attr
-+according to the mask
-+.I attr_mask
-+and move the QP state through the following transitions: Reset -> Init -> RTR.
-+.I attr_mask
-+should indicate all of the attributes which will be used in this QP transition and the following masks (at least) should be set:
-+.PP
-+.nf
-+Next state Required attributes
-+\-\-\-\-\-\-\-\-\-\- \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-
-+Init \fB IBV_QP_STATE, IBV_QP_PKEY_INDEX, IBV_QP_PORT, \fR
-+ \fB IBV_QP_ACCESS_FLAGS \fR
-+RTR \fB IBV_QP_STATE, IBV_QP_AV, IBV_QP_PATH_MTU, \fR
-+ \fB IBV_QP_DEST_QPN, IBV_QP_RQ_PSN, \fR
-+ \fB IBV_QP_MAX_DEST_RD_ATOMIC, IBV_QP_MIN_RNR_TIMER \fR
-+.fi
-+.PP
-+The user can add optional attributes as well.
-+.PP
-+The argument \fIattr\fR is an ibv_qp_attr struct, as defined in <infiniband/verbs.h>.
-+.PP
-+.nf
-+struct ibv_qp_attr {
-+.in +8
-+enum ibv_qp_state qp_state; /* Move the QP to this state */
-+enum ibv_qp_state cur_qp_state; /* Assume this is the current QP state */
-+enum ibv_mtu path_mtu; /* Path MTU (valid only for RC/UC QPs) */
-+enum ibv_mig_state path_mig_state; /* Path migration state (valid if HCA supports APM) */
-+uint32_t qkey; /* Q_Key for the QP (valid only for UD QPs) */
-+uint32_t rq_psn; /* PSN for receive queue (valid only for RC/UC QPs) */
-+uint32_t sq_psn; /* PSN for send queue (valid only for RC/UC QPs) */
-+uint32_t dest_qp_num; /* Destination QP number (valid only for RC/UC QPs) */
-+int qp_access_flags; /* Mask of enabled remote access operations (valid only for RC/UC QPs) */
-+struct ibv_qp_cap cap; /* QP capabilities (valid if HCA supports QP resizing) */
-+struct ibv_ah_attr ah_attr; /* Primary path address vector (valid only for RC/UC QPs) */
-+struct ibv_ah_attr alt_ah_attr; /* Alternate path address vector (valid only for RC/UC QPs) */
-+uint16_t pkey_index; /* Primary P_Key index */
-+uint16_t alt_pkey_index; /* Alternate P_Key index */
-+uint8_t en_sqd_async_notify; /* Enable SQD.drained async notification (Valid only if qp_state is SQD) */
-+uint8_t sq_draining; /* Is the QP draining? Irrelevant for ibv_modify_qp() */
-+uint8_t max_rd_atomic; /* Number of outstanding RDMA reads & atomic operations on the destination QP (valid only for RC QPs) */
-+uint8_t max_dest_rd_atomic; /* Number of responder resources for handling incoming RDMA reads & atomic operations (valid only for RC QPs) */
-+uint8_t min_rnr_timer; /* Minimum RNR NAK timer (valid only for RC QPs) */
-+uint8_t port_num; /* Primary port number */
-+uint8_t timeout; /* Local ack timeout for primary path (valid only for RC QPs) */
-+uint8_t retry_cnt; /* Retry count (valid only for RC QPs) */
-+uint8_t rnr_retry; /* RNR retry (valid only for RC QPs) */
-+uint8_t alt_port_num; /* Alternate port number */
-+uint8_t alt_timeout; /* Local ack timeout for alternate path (valid only for RC QPs) */
-+.in -8
-+};
-+.fi
-+.PP
-+For details on struct ibv_qp_cap see the description of
-+.B ibv_create_qp()\fR.
-+For details on struct ibv_ah_attr see the description of
-+.B ibv_create_ah()\fR.
-+.PP
-+The argument
-+.I attr_mask
-+specifies the QP attributes to be modified.
-+The argument is either 0 or the bitwise OR of one or more of the following flags:
-+.PP
-+.TP
-+.B IBV_QP_STATE \fR Modify qp_state
-+.TP
-+.B IBV_QP_CUR_STATE \fR Set cur_qp_state
-+.TP
-+.B IBV_QP_EN_SQD_ASYNC_NOTIFY \fR Set en_sqd_async_notify
-+.TP
-+.B IBV_QP_ACCESS_FLAGS \fR Set qp_access_flags
-+.TP
-+.B IBV_QP_PKEY_INDEX \fR Set pkey_index
-+.TP
-+.B IBV_QP_PORT \fR Set port_num
-+.TP
-+.B IBV_QP_QKEY \fR Set qkey
-+.TP
-+.B IBV_QP_AV \fR Set ah_attr
-+.TP
-+.B IBV_QP_PATH_MTU \fR Set path_mtu
-+.TP
-+.B IBV_QP_TIMEOUT \fR Set timeout
-+.TP
-+.B IBV_QP_RETRY_CNT \fR Set retry_cnt
-+.TP
-+.B IBV_QP_RNR_RETRY \fR Set rnr_retry
-+.TP
-+.B IBV_QP_RQ_PSN \fR Set rq_psn
-+.TP
-+.B IBV_QP_MAX_QP_RD_ATOMIC \fR Set max_rd_atomic
-+.TP
-+.B IBV_QP_ALT_PATH \fR Set the alternative path via: alt_ah_attr, alt_pkey_index, alt_port_num, alt_timeout
-+.TP
-+.B IBV_QP_MIN_RNR_TIMER \fR Set min_rnr_timer
-+.TP
-+.B IBV_QP_SQ_PSN \fR Set sq_psn
-+.TP
-+.B IBV_QP_MAX_DEST_RD_ATOMIC \fR Set max_dest_rd_atomic
-+.TP
-+.B IBV_QP_PATH_MIG_STATE \fR Set path_mig_state
-+.TP
-+.B IBV_QP_CAP \fR Set cap
-+.TP
-+.B IBV_QP_DEST_QPN \fR Set dest_qp_num
-+.SH "RETURN VALUE"
-+.B ibv_modify_xrc_rcv_qp()
-+returns 0 on success, or the value of errno on failure (which indicates the failure reason).
-+.SH "NOTES"
-+If any of the modify attributes or the modify mask are invalid, none
-+of the attributes will be modified (including the QP state).
-+.PP
-+Not all devices support alternate paths. To check if a device supports it, check if the
-+.B IBV_DEVICE_AUTO_PATH_MIG
-+bit is set in the device capabilities flags.
-+.SH "SEE ALSO"
-+.BR ibv_open_xrc_domain (3),
-+.BR ibv_create_xrc_rcv_qp (3),
-+.BR ibv_query_xrc_rcv_qp (3)
-+.SH "AUTHORS"
-+.TP
-+Dotan Barak <dotanb@mellanox.co.il>
-Index: libibverbs/man/ibv_open_xrc_domain.3
-===================================================================
---- /dev/null 1970-01-01 00:00:00.000000000 +0000
-+++ libibverbs/man/ibv_open_xrc_domain.3 2008-06-05 16:25:21.000000000 +0300
-@@ -0,0 +1,80 @@
-+.\" -*- nroff -*-
-+.\"
-+.TH IBV_OPEN_XRC_DOMAIN 3 2008-02-10 libibverbs "Libibverbs Programmer's Manual"
-+.SH "NAME"
-+ibv_open_xrc_domain, ibv_close_xrc_domain \- open or close an eXtended Reliable Connection (XRC) domain
-+.SH "SYNOPSIS"
-+.nf
-+.B #include <fcntl.h>
-+.B #include <infiniband/verbs.h>
-+.sp
-+.BI "struct ibv_xrc_domain *ibv_open_xrc_domain(struct ibv_context " "*context" ","
-+.BI " int " "fd" ", int " "oflag" );
-+.nl
-+.BI "int ibv_close_xrc_domain(struct ibv_xrc_domain " "*d" );
-+.fi
-+.SH "DESCRIPTION"
-+.B ibv_open_xrc_domain()
-+open an XRC domain for the InfiniBand device context
-+.I context
-+or return a reference to an opened one\fR.
-+.I fd
-+is the file descriptor to be associated with the XRC domain.
-+The argument
-+.I oflag
-+describes the desired file creation attributes; it is either 0 or the bitwise OR of one or more of the following flags:
-+.PP
-+.TP
-+.B O_CREAT
-+If a domain belonging to device named by context is already associated with the inode, this flag has
-+no effect, except as noted under
-+.BR O_EXCL
-+below. Otherwise, a new XRC domain is created and is associated with inode specified by
-+.IR fd\fR.
-+.TP
-+.B O_EXCL
-+If
-+.BR O_EXCL
-+and
-+.BR O_CREAT
-+are set, open will fail if a domain associated with the inode exists.
-+The check for the existence of the domain and creation
-+of the domain if it does not exist is atomic with respect to other
-+processes executing open with
-+.IR fd
-+naming the same inode.
-+.PP
-+If
-+.I fd
-+equals -1, no inode is is associated with the domain, and the only valid value for
-+.I oflag
-+is
-+.B O_CREAT\fR.
-+.PP
-+.B ibv_close_xrc_domain()
-+closes the XRC domain
-+.I d\fR.
-+If this is the last reference, the XRC domain will be destroyed.
-+.SH "RETURN VALUE"
-+.B ibv_open_xrc_domain()
-+returns a pointer to an opened XRC, or NULL if the request fails.
-+.PP
-+.B ibv_close_xrc_domain()
-+returns 0 on success, or the value of errno on failure (which indicates the failure reason).
-+.SH "NOTES"
-+Not all devices support XRC. To check if a device supports it, check if the
-+.B IBV_DEVICE_XRC
-+bit is set in the device capabilities flags.
-+.PP
-+.B ibv_close_xrc_domain()
-+may fail if any QP or SRQ are still associated with the XRC domain being closed.
-+.SH "SEE ALSO"
-+.BR ibv_create_xrc_srq (3),
-+.BR ibv_create_qp (3),
-+.BR ibv_create_xrc_rcv_qp (3),
-+.BR ibv_modify_xrc_rcv_qp (3),
-+.BR ibv_query_xrc_rcv_qp (3),
-+.BR ibv_reg_xrc_rcv_qp (3)
-+.SH "AUTHORS"
-+.TP
-+Dotan Barak <dotanb@mellanox.co.il>
-Index: libibverbs/man/ibv_post_send.3
-===================================================================
---- libibverbs.orig/man/ibv_post_send.3 2008-06-05 15:21:55.000000000 +0300
-+++ libibverbs/man/ibv_post_send.3 2008-06-05 16:25:21.000000000 +0300
-@@ -60,6 +60,7 @@ uint32_t remote_qkey; /* Q_Key
- } ud;
- .in -8
- } wr;
-+uint32_t xrc_remote_srq_num; /* SRQ number of the destination XRC */
- .in -8
- };
- .sp
-@@ -76,15 +77,15 @@ uint32_t lkey;
- Each QP Transport Service Type supports a specific set of opcodes, as shown in the following table:
- .PP
- .nf
--OPCODE | IBV_QPT_UD | IBV_QPT_UC | IBV_QPT_RC
--\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-+\-\-\-\-\-\-\-\-\-\-\-\-+\-\-\-\-\-\-\-\-\-\-\-\-+\-\-\-\-\-\-\-\-\-\-\-
--IBV_WR_SEND | X | X | X
--IBV_WR_SEND_WITH_IMM | X | X | X
--IBV_WR_RDMA_WRITE | | X | X
--IBV_WR_RDMA_WRITE_WITH_IMM | | X | X
--IBV_WR_RDMA_READ | | | X
--IBV_WR_ATOMIC_CMP_AND_SWP | | | X
--IBV_WR_ATOMIC_FETCH_AND_ADD | | | X
-+OPCODE | IBV_QPT_UD | IBV_QPT_UC | IBV_QPT_RC | IBV_QPT_XRC
-+\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-+\-\-\-\-\-\-\-\-\-\-\-\-+\-\-\-\-\-\-\-\-\-\-\-\-+\-\-\-\-\-\-\-\-\-\-\-\-+\-\-\-\-\-\-\-\-\-\-\-\-
-+IBV_WR_SEND | X | X | X | X
-+IBV_WR_SEND_WITH_IMM | X | X | X | X
-+IBV_WR_RDMA_WRITE | | X | X | X
-+IBV_WR_RDMA_WRITE_WITH_IMM | | X | X | X
-+IBV_WR_RDMA_READ | | | X | X
-+IBV_WR_ATOMIC_CMP_AND_SWP | | | X | X
-+IBV_WR_ATOMIC_FETCH_AND_ADD | | | X | X
- .fi
- .PP
- The attribute send_flags describes the properties of the \s-1WR\s0. It is either 0 or the bitwise \s-1OR\s0 of one or more of the following flags:
-@@ -114,6 +115,7 @@ IBV_SEND_INLINE flag was set, the buffer
- after the call returns.
- .SH "SEE ALSO"
- .BR ibv_create_qp (3),
-+.BR ibv_create_xrc_rcv_qp (3),
- .BR ibv_create_ah (3),
- .BR ibv_post_recv (3),
- .BR ibv_post_srq_recv (3),
-Index: libibverbs/man/ibv_query_xrc_rcv_qp.3
-===================================================================
---- /dev/null 1970-01-01 00:00:00.000000000 +0000
-+++ libibverbs/man/ibv_query_xrc_rcv_qp.3 2008-06-05 16:25:21.000000000 +0300
-@@ -0,0 +1,89 @@
-+.\" -*- nroff -*-
-+.\"
-+.TH IBV_QUERY_XRC_RCV_QP 3 2008-02-10 libibverbs "Libibverbs Programmer's Manual"
-+.SH "NAME"
-+ibv_query_xrc_rcv_qp \- get the attributes of an XRC receive queue pair (QP)
-+.SH "SYNOPSIS"
-+.nf
-+.B #include <infiniband/verbs.h>
-+.sp
-+.BI "int ibv_query_xrc_rcv_qp(struct ibv_xrc_domain " "*xrc_domain" ", uint32_t " "xrc_qp_num" ,
-+.BI " struct ibv_qp_attr " "*attr" ", int " "attr_mask" ,
-+.BI " struct ibv_qp_init_attr " "*init_attr" );
-+.fi
-+.SH "DESCRIPTION"
-+.B ibv_query_xrc_rcv_qp()
-+gets the attributes specified in
-+.I attr_mask
-+for the XRC receive QP with the number
-+.I xrc_qp_num
-+which is associated with the XRC domain
-+.I xrc_domain
-+and returns them through the pointers
-+.I attr
-+and
-+.I init_attr\fR.
-+The argument
-+.I attr
-+is an ibv_qp_attr struct, as defined in <infiniband/verbs.h>.
-+.PP
-+.nf
-+struct ibv_qp_attr {
-+.in +8
-+enum ibv_qp_state qp_state; /* Current QP state */
-+enum ibv_qp_state cur_qp_state; /* Current QP state - irrelevant for ibv_query_qp */
-+enum ibv_mtu path_mtu; /* Path MTU (valid only for RC/UC QPs) */
-+enum ibv_mig_state path_mig_state; /* Path migration state (valid if HCA supports APM) */
-+uint32_t qkey; /* Q_Key of the QP (valid only for UD QPs) */
-+uint32_t rq_psn; /* PSN for receive queue (valid only for RC/UC QPs) */
-+uint32_t sq_psn; /* PSN for send queue (valid only for RC/UC QPs) */
-+uint32_t dest_qp_num; /* Destination QP number (valid only for RC/UC QPs) */
-+int qp_access_flags; /* Mask of enabled remote access operations (valid only for RC/UC QPs) */
-+struct ibv_qp_cap cap; /* QP capabilities */
-+struct ibv_ah_attr ah_attr; /* Primary path address vector (valid only for RC/UC QPs) */
-+struct ibv_ah_attr alt_ah_attr; /* Alternate path address vector (valid only for RC/UC QPs) */
-+uint16_t pkey_index; /* Primary P_Key index */
-+uint16_t alt_pkey_index; /* Alternate P_Key index */
-+uint8_t en_sqd_async_notify; /* Enable SQD.drained async notification - irrelevant for ibv_query_qp */
-+uint8_t sq_draining; /* Is the QP draining? (Valid only if qp_state is SQD) */
-+uint8_t max_rd_atomic; /* Number of outstanding RDMA reads & atomic operations on the destination QP (valid only for RC QPs) */
-+uint8_t max_dest_rd_atomic; /* Number of responder resources for handling incoming RDMA reads & atomic operations (valid only for RC QPs) */
-+uint8_t min_rnr_timer; /* Minimum RNR NAK timer (valid only for RC QPs) */
-+uint8_t port_num; /* Primary port number */
-+uint8_t timeout; /* Local ack timeout for primary path (valid only for RC QPs) */
-+uint8_t retry_cnt; /* Retry count (valid only for RC QPs) */
-+uint8_t rnr_retry; /* RNR retry (valid only for RC QPs) */
-+uint8_t alt_port_num; /* Alternate port number */
-+uint8_t alt_timeout; /* Local ack timeout for alternate path (valid only for RC QPs) */
-+.in -8
-+};
-+.fi
-+.PP
-+For details on struct ibv_qp_cap see the description of
-+.B ibv_create_qp()\fR.
-+For details on struct ibv_ah_attr see the description of
-+.B ibv_create_ah()\fR.
-+.SH "RETURN VALUE"
-+.B ibv_query_xrc_rcv_qp()
-+returns 0 on success, or the value of errno on failure (which indicates the failure reason).
-+.SH "NOTES"
-+The argument
-+.I attr_mask
-+is a hint that specifies the minimum list of attributes to retrieve.
-+Some InfiniBand devices may return extra attributes not requested, for
-+example if the value can be returned cheaply.
-+.PP
-+Attribute values are valid if they have been set using
-+.B ibv_modify_xrc_rcv_qp()\fR.
-+The exact list of valid attributes depends on the QP state.
-+.PP
-+Multiple calls to
-+.B ibv_query_xrc_rcv_qp()
-+may yield some differences in the values returned for the following attributes: qp_state, path_mig_state, sq_draining, ah_attr (if APM is enabled).
-+.SH "SEE ALSO"
-+.BR ibv_open_xrc_domain (3),
-+.BR ibv_create_xrc_rcv_qp (3),
-+.BR ibv_modify_xrc_rcv_qp (3)
-+.SH "AUTHORS"
-+.TP
-+Dotan Barak <dotanb@mellanox.co.il>
-Index: libibverbs/man/ibv_reg_xrc_rcv_qp.3
-===================================================================
---- /dev/null 1970-01-01 00:00:00.000000000 +0000
-+++ libibverbs/man/ibv_reg_xrc_rcv_qp.3 2008-06-05 16:25:21.000000000 +0300
-@@ -0,0 +1,57 @@
-+.\" -*- nroff -*-
-+.\"
-+.TH IBV_REG_XRC_RCV_QP 3 2008-10-02 libibverbs "Libibverbs Programmer's Manual"
-+.SH "NAME"
-+ibv_reg_xrc_rcv_qp, ibv_unreg_xrc_rcv_qp \- register and unregister a user process with an XRC receive queue pair (QP)
-+.SH "SYNOPSIS"
-+.nf
-+.B #include <infiniband/verbs.h>
-+.sp
-+.BI "int ibv_reg_xrc_rcv_qp(struct ibv_xrc_domain " "*xrc_domain" ", uint32_t " "xrc_qp_num" ");
-+.nl
-+.BI "int ibv_unreg_xrc_rcv_qp(struct ibv_xrc_domain " "*xrc_domain" ", uint32_t " "xrc_qp_num" ");
-+.fi
-+.SH "DESCRIPTION"
-+.B ibv_reg_xrc_rcv_qp()
-+registers a user process with the XRC receive QP (created via
-+.B ibv_create_xrc_rcv_qp()
-+) whose number is
-+.I xrc_qp_num\fR,
-+and which is associated with the XRC domain
-+.I xrc_domain\fR.
-+.PP
-+.B ibv_unreg_xrc_rcv_qp()
-+unregisters a user process from the XRC receive QP number
-+.I xrc_qp_num\fR,
-+which is associated with the XRC domain
-+.I xrc_domain\fR.
-+When the number of user processes registered with this XRC receive QP drops to zero, the QP is destroyed.
-+.SH "RETURN VALUE"
-+.B ibv_reg_xrc_rcv_qp()
-+and
-+.B ibv_unreg_xrc_rcv_qp()
-+returns 0 on success, or the value of errno on failure (which indicates the failure reason).
-+.SH "NOTES"
-+.B ibv_reg_xrc_rcv_qp()
-+and
-+.B ibv_unreg_xrc_rcv_qp()
-+may fail if the number
-+.I xrc_qp_num
-+is not a number of a valid XRC receive QP (the QP is not allocated or it is the number of a non-XRC QP), or
-+the XRC receive QP was created with an XRC domain other than
-+.I xrc_domain\fR.
-+
-+If a process is still registered with any XRC RCV QPs belonging to some domain,
-+.B ibv_close_xrc_domain()
-+will return failure if called for that domain in that process.
-+
-+.B ibv_create_xrc_rcv_qp()
-+performs an implicit registration for the creating process; when that process is finished with the XRC RCV QP, it should call
-+.B ibv_unreg_xrc_rcv_qp()
-+for that QP. Note that if no other processes are registered with the QP at this time, its registration count will drop to zero and it will be destroyed.
-+.SH "SEE ALSO"
-+.BR ibv_open_xrc_domain (3),
-+.BR ibv_create_xrc_rcv_qp (3)
-+.SH "AUTHORS"
-+.TP
-+Dotan Barak <dotanb@mellanox.co.il>
-Index: libibverbs/man/verbs.7
-===================================================================
---- libibverbs.orig/man/verbs.7 2008-06-05 15:24:00.000000000 +0300
-+++ libibverbs/man/verbs.7 2008-06-05 16:25:21.000000000 +0300
-@@ -1,6 +1,6 @@
- .\" -*- nroff -*-
- .\"
--.TH VERBS 7 2008-01-17 libibverbs "Libibverbs Programmer's Manual"
-+.TH VERBS 7 2008-02-25 libibverbs "Libibverbs Programmer's Manual"
- .SH "NAME"
- verbs \- Infiniband verbs library
- .SH "SYNOPSIS"
-@@ -8,7 +8,7 @@ verbs \- Infiniband verbs library
- .B #include <infiniband/verbs.h>
- .fi
- .SH "DESCRIPTION"
--This library is an implementation of the verbs according to the Infiniband specification volume 1.2. It handles the control path of creating, modifying, querying and destroying resources such as Protection Domains (PD), Completion Queues (CQ), Queue-Pairs (QP), Shared Receive Queues (SRQ), Address Handles (AH), Memory Regions (MR). It also handles sending and receiving data posted to QPs and SRQs, getting completions from CQs using polling and completions events.
-+This library is an implementation of the verbs based on the Infiniband specification volume 1.2 chapter 11. It handles the control path of creating, modifying, querying and destroying resources such as Protection Domains (PD), Completion Queues (CQ), Queue-Pairs (QP), Shared Receive Queues (SRQ), Address Handles (AH), Memory Regions (MR). It also handles sending and receiving data posted to QPs and SRQs, getting completions from CQs using polling and completions events.
-
- The control path is implemented through system calls to the uverbs kernel module which further calls the low level HW driver. The data path is implemented through calls made to low level HW library which in most cases interacts directly with the HW providing kernel and network stack bypass (saving context/mode switches) along with zero copy and an asynchronous I/O model.
-
-@@ -117,6 +117,25 @@ int ibv_modify_srq(struct ibv_srq *srq,
- enum ibv_srq_attr_mask srq_attr_mask);
- int ibv_query_srq(struct ibv_srq *srq, struct ibv_srq_attr *srq_attr);
-
-+.B eXtended Reliable Connection control
-+
-+struct ibv_xrc_domain *ibv_open_xrc_domain(struct ibv_context *context,
-+ int fd, int oflag);
-+int ibv_close_xrc_domain(struct ibv_xrc_domain *d);
-+struct ibv_srq *ibv_create_xrc_srq(struct ibv_pd *pd,
-+ struct ibv_xrc_domain *xrc_domain,
-+ struct ibv_cq *xrc_cq,
-+ struct ibv_srq_init_attr *srq_init_attr);
-+int ibv_create_xrc_rcv_qp(struct ibv_qp_init_attr *init_attr,
-+ uint32_t *xrc_rcv_qpn);
-+int ibv_modify_xrc_rcv_qp(struct ibv_xrc_domain *xrc_domain, uint32_t xrc_qp_num,
-+ struct ibv_qp_attr *attr, int attr_mask);
-+int ibv_query_xrc_rcv_qp(struct ibv_xrc_domain *xrc_domain, uint32_t xrc_qp_num,
-+ struct ibv_qp_attr *attr, int attr_mask,
-+ struct ibv_qp_init_attr *init_attr);
-+int ibv_reg_xrc_rcv_qp(struct ibv_xrc_domain *xrc_domain, uint32_t xrc_qp_num);
-+int ibv_unreg_xrc_rcv_qp(struct ibv_xrc_domain *xrc_domain, uint32_t xrc_qp_num);
-+
- .B Queue Pair control
-
- struct ibv_qp *ibv_create_qp(struct ibv_pd *pd,
-@@ -183,6 +202,14 @@ enum ibv_rate mult_to_ibv_rate(int mult)
- \fIibv_destroy_srq\fP(),
- \fIibv_modify_srq\fP(),
- \fIibv_query_srq\fP(),
-+\fIibv_open_xrc_domain\fP(),
-+\fIibv_close_xrc_domain\fP(),
-+\fIibv_create_xrc_srq\fP(),
-+\fIibv_create_xrc_rcv_qp\fP(),
-+\fIibv_modify_xrc_rcv_qp\fP(),
-+\fIibv_query_xrc_rcv_qp\fP(),
-+\fIibv_reg_xrc_rcv_qp\fP(),
-+\fIibv_unreg_xrc_rcv_qp\fP(),
- \fIibv_post_srq_recv\fP(),
- \fIibv_create_qp\fP(),
- \fIibv_destroy_qp\fP(),
-Index: libibverbs/Makefile.am
-===================================================================
---- libibverbs.orig/Makefile.am 2008-06-05 15:24:00.000000000 +0300
-+++ libibverbs/Makefile.am 2008-06-05 16:39:27.000000000 +0300
-@@ -44,15 +44,18 @@ man_MANS = man/ibv_asyncwatch.1 man/ibv_
- man/ibv_srq_pingpong.1 man/ibv_alloc_pd.3 man/ibv_attach_mcast.3 \
- man/ibv_create_ah.3 man/ibv_create_ah_from_wc.3 \
- man/ibv_create_comp_channel.3 man/ibv_create_cq.3 \
-- man/ibv_create_qp.3 man/ibv_create_srq.3 man/ibv_event_type_str.3 \
-+ man/ibv_create_qp.3 man/ibv_create_srq.3 \
-+ man/ibv_create_xrc_rcv_qp.3 man/ibv_event_type_str.3 \
- man/ibv_fork_init.3 man/ibv_get_async_event.3 \
- man/ibv_get_cq_event.3 man/ibv_get_device_guid.3 \
- man/ibv_get_device_list.3 man/ibv_get_device_name.3 \
-- man/ibv_modify_qp.3 man/ibv_modify_srq.3 man/ibv_open_device.3 \
-+ man/ibv_modify_qp.3 man/ibv_modify_srq.3 man/ibv_modify_xrc_rcv_qp.3 \
-+ man/ibv_open_device.3 man/ibv_open_xrc_domain.3 \
- man/ibv_poll_cq.3 man/ibv_post_recv.3 man/ibv_post_send.3 \
- man/ibv_post_srq_recv.3 man/ibv_query_device.3 man/ibv_query_gid.3 \
- man/ibv_query_pkey.3 man/ibv_query_port.3 man/ibv_query_qp.3 \
-- man/ibv_query_srq.3 man/ibv_rate_to_mult.3 man/ibv_reg_mr.3 \
-+ man/ibv_query_srq.3 man/ibv_query_xrc_rcv_qp.3 \
-+ man/ibv_rate_to_mult.3 man/ibv_reg_mr.3 man/ibv_reg_xrc_rcv_qp.3 \
- man/ibv_req_notify_cq.3 man/ibv_resize_cq.3 man/verbs.7
-
- DEBIAN = debian/changelog debian/compat debian/control debian/copyright \
-@@ -74,6 +77,8 @@ install-data-hook:
- $(RM) ibv_ack_async_event.3 && \
- $(RM) ibv_ack_cq_events.3 && \
- $(RM) ibv_close_device.3 && \
-+ $(RM) ibv_close_xrc_domain.3 && \
-+ $(RM) ibv_create_xrc_srq.3 && \
- $(RM) ibv_dealloc_pd.3 && \
- $(RM) ibv_dereg_mr.3 && \
- $(RM) ibv_destroy_ah.3 && \
-@@ -84,12 +89,15 @@ install-data-hook:
- $(RM) ibv_detach_mcast.3 && \
- $(RM) ibv_free_device_list.3 && \
- $(RM) ibv_init_ah_from_wc.3 && \
-+ $(RM) ibv_unreg_xrc_rcv_qp.3 && \
- $(RM) mult_to_ibv_rate.3 && \
- $(RM) ibv_node_type_str.3 && \
- $(RM) ibv_port_state_str.3 && \
- $(LN_S) ibv_get_async_event.3 ibv_ack_async_event.3 && \
- $(LN_S) ibv_get_cq_event.3 ibv_ack_cq_events.3 && \
- $(LN_S) ibv_open_device.3 ibv_close_device.3 && \
-+ $(LN_S) ibv_open_xrc_domain.3 ibv_close_xrc_domain.3 && \
-+ $(LN_S) ibv_create_srq.3 ibv_create_xrc_srq.3 && \
- $(LN_S) ibv_alloc_pd.3 ibv_dealloc_pd.3 && \
- $(LN_S) ibv_reg_mr.3 ibv_dereg_mr.3 && \
- $(LN_S) ibv_create_ah.3 ibv_destroy_ah.3 && \
-@@ -100,6 +108,7 @@ install-data-hook:
- $(LN_S) ibv_attach_mcast.3 ibv_detach_mcast.3 && \
- $(LN_S) ibv_get_device_list.3 ibv_free_device_list.3 && \
- $(LN_S) ibv_create_ah_from_wc.3 ibv_init_ah_from_wc.3 && \
-+ $(LN_S) ibv_reg_xrc_rcv_qp.3 ibv_unreg_xrc_rcv_qp.3 && \
- $(LN_S) ibv_rate_to_mult.3 mult_to_ibv_rate.3 && \
- $(LN_S) ibv_event_type_str.3 ibv_node_type_str.3 && \
- $(LN_S) ibv_event_type_str.3 ibv_port_state_str.3
diff --git a/contrib/ofed/libibverbs/fixes/configure_in-AC_PROG_LIBTOOL-for-automake.patch b/contrib/ofed/libibverbs/fixes/configure_in-AC_PROG_LIBTOOL-for-automake.patch
deleted file mode 100644
index caf8a98..0000000
--- a/contrib/ofed/libibverbs/fixes/configure_in-AC_PROG_LIBTOOL-for-automake.patch
+++ /dev/null
@@ -1,25 +0,0 @@
-From 8f2b7717984fe025d357023bdd2e1b17cd7bcb0b Mon Sep 17 00:00:00 2001
-From: Jack Morgenstein <jackm@dev.mellanox.co.il>
-Date: Mon, 7 Jun 2010 18:21:53 +0300
-Subject: configure.in -- add AC_PROG_LIBTOOL for earlier versions of automake.
-
-Signed-off-by: Jack Morgenstein <jackm@dev.mellanox.co.il>
----
- configure.in | 1 +
- 1 files changed, 1 insertions(+), 0 deletions(-)
-
-diff --git a/configure.in b/configure.in
-index 83368a9..d0678c8 100644
---- a/configure.in
-+++ b/configure.in
-@@ -13,6 +13,7 @@ AC_PROG_CC
- AC_GNU_SOURCE
- AC_PROG_LN_S
-
-+AC_PROG_LIBTOOL
- LT_INIT
-
- AC_ARG_WITH([valgrind],
---
-1.6.3.2
-
diff --git a/contrib/ofed/libibverbs/fixes/pthread_cond_t_fields.patch b/contrib/ofed/libibverbs/fixes/pthread_cond_t_fields.patch
deleted file mode 100644
index 4a62b14..0000000
--- a/contrib/ofed/libibverbs/fixes/pthread_cond_t_fields.patch
+++ /dev/null
@@ -1,62 +0,0 @@
-move pthread_cond_t fields to the end of structs, because
-their size changed from RHAS4 to RHAS5. In all the cases,
-the intervening entries were not accessed outside libibverbs
-(in non-XRC applications).
-
-The structs modified are: ibv_cq, ibv_srq, and ibv_qp.
-(OFED 1.3 libibverbs commit 4c29c266a3c0932cd06e8f2b4e238aecd3c65dcc)
-
-Pointed out by: Changqing Tang <changquing.tang@hp.com>
-
-Signed-off-by: Jack Morgenstein <jackm@dev.mellanox.co.il>
-
-Index: libibverbs/include/infiniband/verbs.h
-===================================================================
---- libibverbs.orig/include/infiniband/verbs.h 2009-11-01 15:18:24.585280000 +0200
-+++ libibverbs/include/infiniband/verbs.h 2009-11-01 15:18:28.759417000 +0200
-@@ -565,13 +565,14 @@ struct ibv_srq {
- struct ibv_pd *pd;
- uint32_t handle;
-
-- pthread_mutex_t mutex;
-- pthread_cond_t cond;
- uint32_t events_completed;
-
- uint32_t xrc_srq_num;
- struct ibv_xrc_domain *xrc_domain;
- struct ibv_cq *xrc_cq;
-+
-+ pthread_mutex_t mutex;
-+ pthread_cond_t cond;
- };
-
- struct ibv_qp {
-@@ -586,11 +587,12 @@ struct ibv_qp {
- enum ibv_qp_state state;
- enum ibv_qp_type qp_type;
-
-- pthread_mutex_t mutex;
-- pthread_cond_t cond;
- uint32_t events_completed;
-
- struct ibv_xrc_domain *xrc_domain;
-+
-+ pthread_mutex_t mutex;
-+ pthread_cond_t cond;
- };
-
- struct ibv_comp_channel {
-@@ -606,10 +608,11 @@ struct ibv_cq {
- uint32_t handle;
- int cqe;
-
-- pthread_mutex_t mutex;
-- pthread_cond_t cond;
- uint32_t comp_events_completed;
- uint32_t async_events_completed;
-+
-+ pthread_mutex_t mutex;
-+ pthread_cond_t cond;
- };
-
- struct ibv_ah {
diff --git a/contrib/ofed/libibverbs/fixes/qpt_raw_eth.patch b/contrib/ofed/libibverbs/fixes/qpt_raw_eth.patch
deleted file mode 100644
index 67869f4..0000000
--- a/contrib/ofed/libibverbs/fixes/qpt_raw_eth.patch
+++ /dev/null
@@ -1,28 +0,0 @@
-libibverbs: add raw ethernet QP type IBV_QPT_RAW_ETH=7
-
-The patch enables usage of L2 raw ethernet QP type for user-space
-applications.
-
-Miroslaw Walukiewicz
-
-
-Signed-off-by: Mirek Walukiewicz <miroslaw.walukiewicz@intel.com>
----
- include/infiniband/verbs.h | 3 ++-
- 1 files changed, 2 insertions(+), 1 deletions(-)
-
-
-diff --git a/include/infiniband/verbs.h b/include/infiniband/verbs.h
-index fe9ab62..a340ffb 100644
---- a/include/infiniband/verbs.h
-+++ b/include/infiniband/verbs.h
-@@ -397,7 +397,8 @@ enum ibv_qp_type {
- IBV_QPT_RC = 2,
- IBV_QPT_UC,
- IBV_QPT_UD,
-- IBV_QPT_XRC
-+ IBV_QPT_XRC,
-+ IBV_QPT_RAW_ETH = 8
- };
-
- struct ibv_qp_cap {
diff --git a/contrib/ofed/libibverbs/fixes/rocee_examples.patch b/contrib/ofed/libibverbs/fixes/rocee_examples.patch
deleted file mode 100644
index eda5a40..0000000
--- a/contrib/ofed/libibverbs/fixes/rocee_examples.patch
+++ /dev/null
@@ -1,1051 +0,0 @@
-[PATCH 4/4] libibverbs: Update examples
-
-Since RDMAoE requires usage of GRH, update ibv_*_pinpong examples to accept
-GIDs. GIDs are given as an index to the local port's table and are exchanged
-between the client and the server through the socket connection.
-
-Signed-off-by: Eli Cohen <eli@mellanox.co.il>
----
- examples/devinfo.c | 14 ++++++++
- examples/pingpong.c | 31 ++++++++++++++++++
- examples/pingpong.h | 4 ++
- examples/rc_pingpong.c | 79 +++++++++++++++++++++++++++++++++++-----------
- examples/srq_pingpong.c | 72 ++++++++++++++++++++++++++++++++----------
- examples/uc_pingpong.c | 70 ++++++++++++++++++++++++++++++++---------
- examples/ud_pingpong.c | 69 ++++++++++++++++++++++++++++++-----------
- 7 files changed, 269 insertions(+), 70 deletions(-)
-
-Index: libibverbs/examples/devinfo.c
-===================================================================
---- libibverbs.orig/examples/devinfo.c 2010-02-08 15:04:24.369329000 +0200
-+++ libibverbs/examples/devinfo.c 2010-03-17 14:08:48.404754000 +0200
-@@ -184,6 +184,19 @@ static int print_all_port_gids(struct ib
- return rc;
- }
-
-+static const char *link_layer_str(uint8_t link_layer)
-+{
-+ switch (link_layer) {
-+ case IBV_LINK_LAYER_UNSPECIFIED:
-+ case IBV_LINK_LAYER_INFINIBAND:
-+ return "IB";
-+ case IBV_LINK_LAYER_ETHERNET:
-+ return "Ethernet";
-+ default:
-+ return "Unknown";
-+ }
-+}
-+
- static int print_hca_cap(struct ibv_device *ib_dev, uint8_t ib_port)
- {
- struct ibv_context *ctx;
-@@ -284,6 +297,7 @@ static int print_hca_cap(struct ibv_devi
- printf("\t\t\tsm_lid:\t\t\t%d\n", port_attr.sm_lid);
- printf("\t\t\tport_lid:\t\t%d\n", port_attr.lid);
- printf("\t\t\tport_lmc:\t\t0x%02x\n", port_attr.lmc);
-+ printf("\t\t\tlink_layer:\t\t%s\n", link_layer_str(port_attr.link_layer));
-
- if (verbose) {
- printf("\t\t\tmax_msg_sz:\t\t0x%x\n", port_attr.max_msg_sz);
-Index: libibverbs/examples/pingpong.c
-===================================================================
---- libibverbs.orig/examples/pingpong.c 2010-02-08 15:04:24.372330000 +0200
-+++ libibverbs/examples/pingpong.c 2010-03-17 14:08:48.433754000 +0200
-@@ -31,6 +31,10 @@
- */
-
- #include "pingpong.h"
-+#include <arpa/inet.h>
-+#include <stdlib.h>
-+#include <stdio.h>
-+#include <string.h>
-
- enum ibv_mtu pp_mtu_to_enum(int mtu)
- {
-@@ -53,3 +57,30 @@ uint16_t pp_get_local_lid(struct ibv_con
-
- return attr.lid;
- }
-+
-+int pp_get_port_info(struct ibv_context *context, int port,
-+ struct ibv_port_attr *attr)
-+{
-+ return ibv_query_port(context, port, attr);
-+}
-+
-+void wire_gid_to_gid(const char *wgid, union ibv_gid *gid)
-+{
-+ char tmp[9];
-+ uint32_t v32;
-+ int i;
-+
-+ for (tmp[8] = 0, i = 0; i < 4; ++i) {
-+ memcpy(tmp, wgid + i * 8, 8);
-+ sscanf(tmp, "%x", &v32);
-+ *(uint32_t *)(&gid->raw[i * 4]) = ntohl(v32);
-+ }
-+}
-+
-+void gid_to_wire_gid(const union ibv_gid *gid, char wgid[])
-+{
-+ int i;
-+
-+ for (i = 0; i < 4; ++i)
-+ sprintf(&wgid[i * 8], "%08x", htonl(*(uint32_t *)(gid->raw + i * 4)));
-+}
-Index: libibverbs/examples/pingpong.h
-===================================================================
---- libibverbs.orig/examples/pingpong.h 2010-02-08 15:04:24.375328000 +0200
-+++ libibverbs/examples/pingpong.h 2010-03-17 14:08:48.443756000 +0200
-@@ -37,5 +37,9 @@
-
- enum ibv_mtu pp_mtu_to_enum(int mtu);
- uint16_t pp_get_local_lid(struct ibv_context *context, int port);
-+int pp_get_port_info(struct ibv_context *context, int port,
-+ struct ibv_port_attr *attr);
-+void wire_gid_to_gid(const char *wgid, union ibv_gid *gid);
-+void gid_to_wire_gid(const union ibv_gid *gid, char wgid[]);
-
- #endif /* IBV_PINGPONG_H */
-Index: libibverbs/examples/rc_pingpong.c
-===================================================================
---- libibverbs.orig/examples/rc_pingpong.c 2010-02-08 15:04:24.378329000 +0200
-+++ libibverbs/examples/rc_pingpong.c 2010-03-17 14:11:16.145313000 +0200
-@@ -67,17 +67,19 @@ struct pingpong_context {
- int size;
- int rx_depth;
- int pending;
-+ struct ibv_port_attr portinfo;
- };
-
- struct pingpong_dest {
- int lid;
- int qpn;
- int psn;
-+ union ibv_gid gid;
- };
-
- static int pp_connect_ctx(struct pingpong_context *ctx, int port, int my_psn,
- enum ibv_mtu mtu, int sl,
-- struct pingpong_dest *dest)
-+ struct pingpong_dest *dest, int sgid_idx)
- {
- struct ibv_qp_attr attr = {
- .qp_state = IBV_QPS_RTR,
-@@ -94,6 +96,13 @@ static int pp_connect_ctx(struct pingpon
- .port_num = port
- }
- };
-+
-+ if (dest->gid.global.interface_id) {
-+ attr.ah_attr.is_global = 1;
-+ attr.ah_attr.grh.hop_limit = 1;
-+ attr.ah_attr.grh.dgid = dest->gid;
-+ attr.ah_attr.grh.sgid_index = sgid_idx;
-+ }
- if (ibv_modify_qp(ctx->qp, &attr,
- IBV_QP_STATE |
- IBV_QP_AV |
-@@ -135,10 +144,11 @@ static struct pingpong_dest *pp_client_e
- .ai_socktype = SOCK_STREAM
- };
- char *service;
-- char msg[sizeof "0000:000000:000000"];
-+ char msg[sizeof "0000:000000:000000:00000000000000000000000000000000"];
- int n;
- int sockfd = -1;
- struct pingpong_dest *rem_dest = NULL;
-+ char gid[33];
-
- if (asprintf(&service, "%d", port) < 0)
- return NULL;
-@@ -169,7 +179,8 @@ static struct pingpong_dest *pp_client_e
- return NULL;
- }
-
-- sprintf(msg, "%04x:%06x:%06x", my_dest->lid, my_dest->qpn, my_dest->psn);
-+ gid_to_wire_gid(&my_dest->gid, gid);
-+ sprintf(msg, "%04x:%06x:%06x:%s", my_dest->lid, my_dest->qpn, my_dest->psn, gid);
- if (write(sockfd, msg, sizeof msg) != sizeof msg) {
- fprintf(stderr, "Couldn't send local address\n");
- goto out;
-@@ -187,7 +198,8 @@ static struct pingpong_dest *pp_client_e
- if (!rem_dest)
- goto out;
-
-- sscanf(msg, "%x:%x:%x", &rem_dest->lid, &rem_dest->qpn, &rem_dest->psn);
-+ sscanf(msg, "%x:%x:%x:%s", &rem_dest->lid, &rem_dest->qpn, &rem_dest->psn, gid);
-+ wire_gid_to_gid(gid, &rem_dest->gid);
-
- out:
- close(sockfd);
-@@ -197,7 +209,8 @@ out:
- static struct pingpong_dest *pp_server_exch_dest(struct pingpong_context *ctx,
- int ib_port, enum ibv_mtu mtu,
- int port, int sl,
-- const struct pingpong_dest *my_dest)
-+ const struct pingpong_dest *my_dest,
-+ int sgid_idx)
- {
- struct addrinfo *res, *t;
- struct addrinfo hints = {
-@@ -206,10 +219,11 @@ static struct pingpong_dest *pp_server_e
- .ai_socktype = SOCK_STREAM
- };
- char *service;
-- char msg[sizeof "0000:000000:000000"];
-+ char msg[sizeof "0000:000000:000000:00000000000000000000000000000000"];
- int n;
- int sockfd = -1, connfd;
- struct pingpong_dest *rem_dest = NULL;
-+ char gid[33];
-
- if (asprintf(&service, "%d", port) < 0)
- return NULL;
-@@ -263,16 +277,19 @@ static struct pingpong_dest *pp_server_e
- if (!rem_dest)
- goto out;
-
-- sscanf(msg, "%x:%x:%x", &rem_dest->lid, &rem_dest->qpn, &rem_dest->psn);
-+ sscanf(msg, "%x:%x:%x:%s", &rem_dest->lid, &rem_dest->qpn, &rem_dest->psn, gid);
-+ wire_gid_to_gid(gid, &rem_dest->gid);
-
-- if (pp_connect_ctx(ctx, ib_port, my_dest->psn, mtu, sl, rem_dest)) {
-+ if (pp_connect_ctx(ctx, ib_port, my_dest->psn, mtu, sl, rem_dest, sgid_idx)) {
- fprintf(stderr, "Couldn't connect to remote QP\n");
- free(rem_dest);
- rem_dest = NULL;
- goto out;
- }
-
-- sprintf(msg, "%04x:%06x:%06x", my_dest->lid, my_dest->qpn, my_dest->psn);
-+
-+ gid_to_wire_gid(&my_dest->gid, gid);
-+ sprintf(msg, "%04x:%06x:%06x:%s", my_dest->lid, my_dest->qpn, my_dest->psn, gid);
- if (write(connfd, msg, sizeof msg) != sizeof msg) {
- fprintf(stderr, "Couldn't send local address\n");
- free(rem_dest);
-@@ -289,11 +306,11 @@ out:
-
- static struct pingpong_context *pp_init_ctx(struct ibv_device *ib_dev, int size,
- int rx_depth, int port,
-- int use_event)
-+ int use_event, int is_server)
- {
- struct pingpong_context *ctx;
-
-- ctx = malloc(sizeof *ctx);
-+ ctx = calloc(1, sizeof *ctx);
- if (!ctx)
- return NULL;
-
-@@ -306,7 +323,7 @@ static struct pingpong_context *pp_init_
- return NULL;
- }
-
-- memset(ctx->buf, 0, size);
-+ memset(ctx->buf, 0x7b + is_server, size);
-
- ctx->context = ibv_open_device(ib_dev);
- if (!ctx->context) {
-@@ -481,6 +498,7 @@ static void usage(const char *argv0)
- printf(" -n, --iters=<iters> number of exchanges (default 1000)\n");
- printf(" -l, --sl=<sl> service level value\n");
- printf(" -e, --events sleep on CQ events (default poll)\n");
-+ printf(" -g, --gid-idx=<gid index> local port gid index\n");
- }
-
- int main(int argc, char *argv[])
-@@ -504,6 +522,8 @@ int main(int argc, char *argv[])
- int rcnt, scnt;
- int num_cq_events = 0;
- int sl = 0;
-+ int gidx = -1;
-+ char gid[33];
-
- srand48(getpid() * time(NULL));
-
-@@ -520,10 +540,11 @@ int main(int argc, char *argv[])
- { .name = "iters", .has_arg = 1, .val = 'n' },
- { .name = "sl", .has_arg = 1, .val = 'l' },
- { .name = "events", .has_arg = 0, .val = 'e' },
-+ { .name = "gid-idx", .has_arg = 1, .val = 'g' },
- { 0 }
- };
-
-- c = getopt_long(argc, argv, "p:d:i:s:m:r:n:l:e", long_options, NULL);
-+ c = getopt_long(argc, argv, "p:d:i:s:m:r:n:l:eg:", long_options, NULL);
- if (c == -1)
- break;
-
-@@ -576,6 +597,10 @@ int main(int argc, char *argv[])
- ++use_event;
- break;
-
-+ case 'g':
-+ gidx = strtol(optarg, NULL, 0);
-+ break;
-+
- default:
- usage(argv[0]);
- return 1;
-@@ -615,7 +640,7 @@ int main(int argc, char *argv[])
- }
- }
-
-- ctx = pp_init_ctx(ib_dev, size, rx_depth, ib_port, use_event);
-+ ctx = pp_init_ctx(ib_dev, size, rx_depth, ib_port, use_event, !servername);
- if (!ctx)
- return 1;
-
-@@ -631,30 +656,47 @@ int main(int argc, char *argv[])
- return 1;
- }
-
-- my_dest.lid = pp_get_local_lid(ctx->context, ib_port);
-- my_dest.qpn = ctx->qp->qp_num;
-- my_dest.psn = lrand48() & 0xffffff;
-- if (!my_dest.lid) {
-+
-+ if (pp_get_port_info(ctx->context, ib_port, &ctx->portinfo)) {
-+ fprintf(stderr, "Couldn't get port info\n");
-+ return 1;
-+ }
-+
-+ my_dest.lid = ctx->portinfo.lid;
-+ if (ctx->portinfo.link_layer == IBV_LINK_LAYER_INFINIBAND && !my_dest.lid) {
- fprintf(stderr, "Couldn't get local LID\n");
- return 1;
- }
-
-- printf(" local address: LID 0x%04x, QPN 0x%06x, PSN 0x%06x\n",
-- my_dest.lid, my_dest.qpn, my_dest.psn);
-+ if (gidx >= 0) {
-+ if (ibv_query_gid(ctx->context, ib_port, gidx, &my_dest.gid)) {
-+ fprintf(stderr, "Could not get local gid for gid index %d\n", gidx);
-+ return 1;
-+ }
-+ } else
-+ memset(&my_dest.gid, 0, sizeof my_dest.gid);
-+
-+ my_dest.qpn = ctx->qp->qp_num;
-+ my_dest.psn = lrand48() & 0xffffff;
-+ inet_ntop(AF_INET6, &my_dest.gid, gid, sizeof gid);
-+ printf(" local address: LID 0x%04x, QPN 0x%06x, PSN 0x%06x, GID %s\n",
-+ my_dest.lid, my_dest.qpn, my_dest.psn, gid);
-+
-
- if (servername)
- rem_dest = pp_client_exch_dest(servername, port, &my_dest);
- else
-- rem_dest = pp_server_exch_dest(ctx, ib_port, mtu, port, sl, &my_dest);
-+ rem_dest = pp_server_exch_dest(ctx, ib_port, mtu, port, sl, &my_dest, gidx);
-
- if (!rem_dest)
- return 1;
-
-- printf(" remote address: LID 0x%04x, QPN 0x%06x, PSN 0x%06x\n",
-- rem_dest->lid, rem_dest->qpn, rem_dest->psn);
-+ inet_ntop(AF_INET6, &rem_dest->gid, gid, sizeof gid);
-+ printf(" remote address: LID 0x%04x, QPN 0x%06x, PSN 0x%06x, GID %s\n",
-+ rem_dest->lid, rem_dest->qpn, rem_dest->psn, gid);
-
- if (servername)
-- if (pp_connect_ctx(ctx, ib_port, my_dest.psn, mtu, sl, rem_dest))
-+ if (pp_connect_ctx(ctx, ib_port, my_dest.psn, mtu, sl, rem_dest, gidx))
- return 1;
-
- ctx->pending = PINGPONG_RECV_WRID;
-@@ -706,6 +748,7 @@ int main(int argc, char *argv[])
- fprintf(stderr, "poll CQ failed %d\n", ne);
- return 1;
- }
-+
- } while (!use_event && ne < 1);
-
- for (i = 0; i < ne; ++i) {
-Index: libibverbs/examples/srq_pingpong.c
-===================================================================
---- libibverbs.orig/examples/srq_pingpong.c 2010-02-08 15:04:24.382329000 +0200
-+++ libibverbs/examples/srq_pingpong.c 2010-03-17 14:13:22.332220000 +0200
-@@ -71,17 +71,19 @@ struct pingpong_context {
- int num_qp;
- int rx_depth;
- int pending[MAX_QP];
-+ struct ibv_port_attr portinfo;
- };
-
- struct pingpong_dest {
- int lid;
- int qpn;
- int psn;
-+ union ibv_gid gid;
- };
-
- static int pp_connect_ctx(struct pingpong_context *ctx, int port, enum ibv_mtu mtu,
- int sl, const struct pingpong_dest *my_dest,
-- const struct pingpong_dest *dest)
-+ const struct pingpong_dest *dest, int sgid_idx)
- {
- int i;
-
-@@ -101,6 +103,13 @@ static int pp_connect_ctx(struct pingpon
- .port_num = port
- }
- };
-+
-+ if (dest->gid.global.interface_id) {
-+ attr.ah_attr.is_global = 1;
-+ attr.ah_attr.grh.hop_limit = 1;
-+ attr.ah_attr.grh.dgid = dest->gid;
-+ attr.ah_attr.grh.sgid_index = sgid_idx;
-+ }
- if (ibv_modify_qp(ctx->qp[i], &attr,
- IBV_QP_STATE |
- IBV_QP_AV |
-@@ -143,12 +152,13 @@ static struct pingpong_dest *pp_client_e
- .ai_socktype = SOCK_STREAM
- };
- char *service;
-- char msg[sizeof "0000:000000:000000"];
-+ char msg[sizeof "0000:000000:000000:00000000000000000000000000000000"];
- int n;
- int r;
- int i;
- int sockfd = -1;
- struct pingpong_dest *rem_dest = NULL;
-+ char gid[33];
-
- if (asprintf(&service, "%d", port) < 0)
- return NULL;
-@@ -180,7 +190,8 @@ static struct pingpong_dest *pp_client_e
- }
-
- for (i = 0; i < MAX_QP; ++i) {
-- sprintf(msg, "%04x:%06x:%06x", my_dest[i].lid, my_dest[i].qpn, my_dest[i].psn);
-+ gid_to_wire_gid(&my_dest[i].gid, gid);
-+ sprintf(msg, "%04x:%06x:%06x:%s", my_dest[i].lid, my_dest[i].qpn, my_dest[i].psn, gid);
- if (write(sockfd, msg, sizeof msg) != sizeof msg) {
- fprintf(stderr, "Couldn't send local address\n");
- goto out;
-@@ -204,8 +215,9 @@ static struct pingpong_dest *pp_client_e
- n += r;
- }
-
-- sscanf(msg, "%x:%x:%x",
-- &rem_dest[i].lid, &rem_dest[i].qpn, &rem_dest[i].psn);
-+ sscanf(msg, "%x:%x:%x:%s",
-+ &rem_dest[i].lid, &rem_dest[i].qpn, &rem_dest[i].psn, gid);
-+ wire_gid_to_gid(gid, &rem_dest[i].gid);
- }
-
- write(sockfd, "done", sizeof "done");
-@@ -218,7 +230,8 @@ out:
- static struct pingpong_dest *pp_server_exch_dest(struct pingpong_context *ctx,
- int ib_port, enum ibv_mtu mtu,
- int port, int sl,
-- const struct pingpong_dest *my_dest)
-+ const struct pingpong_dest *my_dest,
-+ int sgid_idx)
- {
- struct addrinfo *res, *t;
- struct addrinfo hints = {
-@@ -227,12 +240,13 @@ static struct pingpong_dest *pp_server_e
- .ai_socktype = SOCK_STREAM
- };
- char *service;
-- char msg[sizeof "0000:000000:000000"];
-+ char msg[sizeof "0000:000000:000000:00000000000000000000000000000000"];
- int n;
- int r;
- int i;
- int sockfd = -1, connfd;
- struct pingpong_dest *rem_dest = NULL;
-+ char gid[33];
-
- if (asprintf(&service, "%d", port) < 0)
- return NULL;
-@@ -292,11 +306,12 @@ static struct pingpong_dest *pp_server_e
- n += r;
- }
-
-- sscanf(msg, "%x:%x:%x",
-- &rem_dest[i].lid, &rem_dest[i].qpn, &rem_dest[i].psn);
-+ sscanf(msg, "%x:%x:%x:%s",
-+ &rem_dest[i].lid, &rem_dest[i].qpn, &rem_dest[i].psn, gid);
-+ wire_gid_to_gid(gid, &rem_dest[i].gid);
- }
-
-- if (pp_connect_ctx(ctx, ib_port, mtu, sl, my_dest, rem_dest)) {
-+ if (pp_connect_ctx(ctx, ib_port, mtu, sl, my_dest, rem_dest, sgid_idx)) {
- fprintf(stderr, "Couldn't connect to remote QP\n");
- free(rem_dest);
- rem_dest = NULL;
-@@ -304,7 +319,8 @@ static struct pingpong_dest *pp_server_e
- }
-
- for (i = 0; i < MAX_QP; ++i) {
-- sprintf(msg, "%04x:%06x:%06x", my_dest[i].lid, my_dest[i].qpn, my_dest[i].psn);
-+ gid_to_wire_gid(&my_dest[i].gid, gid);
-+ sprintf(msg, "%04x:%06x:%06x:%s", my_dest[i].lid, my_dest[i].qpn, my_dest[i].psn, gid);
- if (write(connfd, msg, sizeof msg) != sizeof msg) {
- fprintf(stderr, "Couldn't send local address\n");
- free(rem_dest);
-@@ -327,7 +343,7 @@ static struct pingpong_context *pp_init_
- struct pingpong_context *ctx;
- int i;
-
-- ctx = malloc(sizeof *ctx);
-+ ctx = calloc(1, sizeof *ctx);
- if (!ctx)
- return NULL;
-
-@@ -551,6 +567,7 @@ static void usage(const char *argv0)
- printf(" -n, --iters=<iters> number of exchanges per QP(default 1000)\n");
- printf(" -l, --sl=<sl> service level value\n");
- printf(" -e, --events sleep on CQ events (default poll)\n");
-+ printf(" -g, --gid-idx=<gid index> local port gid index\n");
- }
-
- int main(int argc, char *argv[])
-@@ -578,6 +595,8 @@ int main(int argc, char *argv[])
- int i;
- int num_cq_events = 0;
- int sl = 0;
-+ int gidx = -1;
-+ char gid[33];
-
- srand48(getpid() * time(NULL));
-
-@@ -595,10 +614,11 @@ int main(int argc, char *argv[])
- { .name = "iters", .has_arg = 1, .val = 'n' },
- { .name = "sl", .has_arg = 1, .val = 'l' },
- { .name = "events", .has_arg = 0, .val = 'e' },
-+ { .name = "gid-idx", .has_arg = 1, .val = 'g' },
- { 0 }
- };
-
-- c = getopt_long(argc, argv, "p:d:i:s:m:q:r:n:l:e", long_options, NULL);
-+ c = getopt_long(argc, argv, "p:d:i:s:m:q:r:n:l:eg:", long_options, NULL);
- if (c == -1)
- break;
-
-@@ -655,6 +675,10 @@ int main(int argc, char *argv[])
- ++use_event;
- break;
-
-+ case 'g':
-+ gidx = strtol(optarg, NULL, 0);
-+ break;
-+
- default:
- usage(argv[0]);
- return 1;
-@@ -722,33 +746,50 @@ int main(int argc, char *argv[])
-
- memset(my_dest, 0, sizeof my_dest);
-
-+ if (pp_get_port_info(ctx->context, ib_port, &ctx->portinfo)) {
-+ fprintf(stderr, "Couldn't get port info\n");
-+ return 1;
-+ }
- for (i = 0; i < num_qp; ++i) {
- my_dest[i].qpn = ctx->qp[i]->qp_num;
- my_dest[i].psn = lrand48() & 0xffffff;
-- my_dest[i].lid = pp_get_local_lid(ctx->context, ib_port);
-- if (!my_dest[i].lid) {
-+ my_dest[i].lid = ctx->portinfo.lid;
-+ if (ctx->portinfo.link_layer == IBV_LINK_LAYER_INFINIBAND && !my_dest[i].lid) {
- fprintf(stderr, "Couldn't get local LID\n");
- return 1;
- }
-
-- printf(" local address: LID 0x%04x, QPN 0x%06x, PSN 0x%06x\n",
-- my_dest[i].lid, my_dest[i].qpn, my_dest[i].psn);
-+ if (gidx >= 0) {
-+ if (ibv_query_gid(ctx->context, ib_port, gidx, &my_dest[i].gid)) {
-+ fprintf(stderr, "Could not get local gid for gid index %d\n", gidx);
-+ return 1;
-+ }
-+ } else
-+ memset(&my_dest[i].gid, 0, sizeof my_dest[i].gid);
-+
-+ inet_ntop(AF_INET6, &my_dest[i].gid, gid, sizeof gid);
-+ printf(" local address: LID 0x%04x, QPN 0x%06x, PSN 0x%06x, GID %s\n",
-+ my_dest[i].lid, my_dest[i].qpn, my_dest[i].psn, gid);
- }
-
- if (servername)
- rem_dest = pp_client_exch_dest(servername, port, my_dest);
- else
-- rem_dest = pp_server_exch_dest(ctx, ib_port, mtu, port, sl, my_dest);
-+ rem_dest = pp_server_exch_dest(ctx, ib_port, mtu, port, sl, my_dest, gidx);
-
- if (!rem_dest)
- return 1;
-
-- for (i = 0; i < num_qp; ++i)
-- printf(" remote address: LID 0x%04x, QPN 0x%06x, PSN 0x%06x\n",
-- rem_dest[i].lid, rem_dest[i].qpn, rem_dest[i].psn);
-+ inet_ntop(AF_INET6, &rem_dest->gid, gid, sizeof gid);
-+
-+ for (i = 0; i < num_qp; ++i) {
-+ inet_ntop(AF_INET6, &rem_dest[i].gid, gid, sizeof gid);
-+ printf(" remote address: LID 0x%04x, QPN 0x%06x, PSN 0x%06x, GID %s\n",
-+ rem_dest[i].lid, rem_dest[i].qpn, rem_dest[i].psn, gid);
-+ }
-
- if (servername)
-- if (pp_connect_ctx(ctx, ib_port, mtu, sl, my_dest, rem_dest))
-+ if (pp_connect_ctx(ctx, ib_port, mtu, sl, my_dest, rem_dest, gidx))
- return 1;
-
- if (servername)
-Index: libibverbs/examples/uc_pingpong.c
-===================================================================
---- libibverbs.orig/examples/uc_pingpong.c 2010-02-08 15:04:24.386328000 +0200
-+++ libibverbs/examples/uc_pingpong.c 2010-03-17 14:14:23.573114000 +0200
-@@ -67,17 +67,19 @@ struct pingpong_context {
- int size;
- int rx_depth;
- int pending;
-+ struct ibv_port_attr portinfo;
- };
-
- struct pingpong_dest {
- int lid;
- int qpn;
- int psn;
-+ union ibv_gid gid;
- };
-
- static int pp_connect_ctx(struct pingpong_context *ctx, int port, int my_psn,
- enum ibv_mtu mtu, int sl,
-- struct pingpong_dest *dest)
-+ struct pingpong_dest *dest, int sgid_idx)
- {
- struct ibv_qp_attr attr = {
- .qp_state = IBV_QPS_RTR,
-@@ -92,6 +94,14 @@ static int pp_connect_ctx(struct pingpon
- .port_num = port
- }
- };
-+
-+ if (dest->gid.global.interface_id) {
-+ attr.ah_attr.is_global = 1;
-+ attr.ah_attr.grh.hop_limit = 1;
-+ attr.ah_attr.grh.dgid = dest->gid;
-+ attr.ah_attr.grh.sgid_index = sgid_idx;
-+ }
-+
- if (ibv_modify_qp(ctx->qp, &attr,
- IBV_QP_STATE |
- IBV_QP_AV |
-@@ -123,10 +133,11 @@ static struct pingpong_dest *pp_client_e
- .ai_socktype = SOCK_STREAM
- };
- char *service;
-- char msg[sizeof "0000:000000:000000"];
-+ char msg[sizeof "0000:000000:000000:00000000000000000000000000000000"];
- int n;
- int sockfd = -1;
- struct pingpong_dest *rem_dest = NULL;
-+ char gid[33];
-
- if (asprintf(&service, "%d", port) < 0)
- return NULL;
-@@ -157,7 +168,8 @@ static struct pingpong_dest *pp_client_e
- return NULL;
- }
-
-- sprintf(msg, "%04x:%06x:%06x", my_dest->lid, my_dest->qpn, my_dest->psn);
-+ gid_to_wire_gid(&my_dest->gid, gid);
-+ sprintf(msg, "%04x:%06x:%06x:%s", my_dest->lid, my_dest->qpn, my_dest->psn, gid);
- if (write(sockfd, msg, sizeof msg) != sizeof msg) {
- fprintf(stderr, "Couldn't send local address\n");
- goto out;
-@@ -175,7 +187,8 @@ static struct pingpong_dest *pp_client_e
- if (!rem_dest)
- goto out;
-
-- sscanf(msg, "%x:%x:%x", &rem_dest->lid, &rem_dest->qpn, &rem_dest->psn);
-+ sscanf(msg, "%x:%x:%x:%s", &rem_dest->lid, &rem_dest->qpn, &rem_dest->psn, gid);
-+ wire_gid_to_gid(gid, &rem_dest->gid);
-
- out:
- close(sockfd);
-@@ -185,7 +198,8 @@ out:
- static struct pingpong_dest *pp_server_exch_dest(struct pingpong_context *ctx,
- int ib_port, enum ibv_mtu mtu,
- int port, int sl,
-- const struct pingpong_dest *my_dest)
-+ const struct pingpong_dest *my_dest,
-+ int sgid_idx)
- {
- struct addrinfo *res, *t;
- struct addrinfo hints = {
-@@ -194,10 +208,11 @@ static struct pingpong_dest *pp_server_e
- .ai_socktype = SOCK_STREAM
- };
- char *service;
-- char msg[sizeof "0000:000000:000000"];
-+ char msg[sizeof "0000:000000:000000:00000000000000000000000000000000"];
- int n;
- int sockfd = -1, connfd;
- struct pingpong_dest *rem_dest = NULL;
-+ char gid[33];
-
- if (asprintf(&service, "%d", port) < 0)
- return NULL;
-@@ -251,16 +266,18 @@ static struct pingpong_dest *pp_server_e
- if (!rem_dest)
- goto out;
-
-- sscanf(msg, "%x:%x:%x", &rem_dest->lid, &rem_dest->qpn, &rem_dest->psn);
-+ sscanf(msg, "%x:%x:%x:%s", &rem_dest->lid, &rem_dest->qpn, &rem_dest->psn, gid);
-+ wire_gid_to_gid(gid, &rem_dest->gid);
-
-- if (pp_connect_ctx(ctx, ib_port, my_dest->psn, mtu, sl, rem_dest)) {
-+ if (pp_connect_ctx(ctx, ib_port, my_dest->psn, mtu, sl, rem_dest, sgid_idx)) {
- fprintf(stderr, "Couldn't connect to remote QP\n");
- free(rem_dest);
- rem_dest = NULL;
- goto out;
- }
-
-- sprintf(msg, "%04x:%06x:%06x", my_dest->lid, my_dest->qpn, my_dest->psn);
-+ gid_to_wire_gid(&my_dest->gid, gid);
-+ sprintf(msg, "%04x:%06x:%06x:%s", my_dest->lid, my_dest->qpn, my_dest->psn, gid);
- if (write(connfd, msg, sizeof msg) != sizeof msg) {
- fprintf(stderr, "Couldn't send local address\n");
- free(rem_dest);
-@@ -281,7 +298,7 @@ static struct pingpong_context *pp_init_
- {
- struct pingpong_context *ctx;
-
-- ctx = malloc(sizeof *ctx);
-+ ctx = calloc(1, sizeof *ctx);
- if (!ctx)
- return NULL;
-
-@@ -469,6 +486,7 @@ static void usage(const char *argv0)
- printf(" -n, --iters=<iters> number of exchanges (default 1000)\n");
- printf(" -l, --sl=<sl> service level value\n");
- printf(" -e, --events sleep on CQ events (default poll)\n");
-+ printf(" -g, --gid-idx=<gid index> local port gid index\n");
- }
-
- int main(int argc, char *argv[])
-@@ -492,6 +510,8 @@ int main(int argc, char *argv[])
- int rcnt, scnt;
- int num_cq_events = 0;
- int sl = 0;
-+ int gidx = -1;
-+ char gid[33];
-
- srand48(getpid() * time(NULL));
-
-@@ -508,10 +528,11 @@ int main(int argc, char *argv[])
- { .name = "iters", .has_arg = 1, .val = 'n' },
- { .name = "sl", .has_arg = 1, .val = 'l' },
- { .name = "events", .has_arg = 0, .val = 'e' },
-+ { .name = "gid-idx", .has_arg = 1, .val = 'g' },
- { 0 }
- };
-
-- c = getopt_long(argc, argv, "p:d:i:s:m:r:n:l:e", long_options, NULL);
-+ c = getopt_long(argc, argv, "p:d:i:s:m:r:n:l:eg:", long_options, NULL);
- if (c == -1)
- break;
-
-@@ -564,6 +585,10 @@ int main(int argc, char *argv[])
- ++use_event;
- break;
-
-+ case 'g':
-+ gidx = strtol(optarg, NULL, 0);
-+ break;
-+
- default:
- usage(argv[0]);
- return 1;
-@@ -619,30 +644,45 @@ int main(int argc, char *argv[])
- return 1;
- }
-
-- my_dest.lid = pp_get_local_lid(ctx->context, ib_port);
-- my_dest.qpn = ctx->qp->qp_num;
-- my_dest.psn = lrand48() & 0xffffff;
-- if (!my_dest.lid) {
-+ if (pp_get_port_info(ctx->context, ib_port, &ctx->portinfo)) {
-+ fprintf(stderr, "Couldn't get port info\n");
-+ return 1;
-+ }
-+
-+ my_dest.lid = ctx->portinfo.lid;
-+ if (ctx->portinfo.link_layer == IBV_LINK_LAYER_INFINIBAND && !my_dest.lid) {
- fprintf(stderr, "Couldn't get local LID\n");
- return 1;
- }
-
-- printf(" local address: LID 0x%04x, QPN 0x%06x, PSN 0x%06x\n",
-- my_dest.lid, my_dest.qpn, my_dest.psn);
-+ if (gidx >= 0) {
-+ if (ibv_query_gid(ctx->context, ib_port, gidx, &my_dest.gid)) {
-+ fprintf(stderr, "Could not get local gid for gid index %d\n", gidx);
-+ return 1;
-+ }
-+ } else
-+ memset(&my_dest.gid, 0, sizeof my_dest.gid);
-+
-+ my_dest.qpn = ctx->qp->qp_num;
-+ my_dest.psn = lrand48() & 0xffffff;
-+ inet_ntop(AF_INET6, &my_dest.gid, gid, sizeof gid);
-+ printf(" local address: LID 0x%04x, QPN 0x%06x, PSN 0x%06x, GID %s\n",
-+ my_dest.lid, my_dest.qpn, my_dest.psn, gid);
-
- if (servername)
- rem_dest = pp_client_exch_dest(servername, port, &my_dest);
- else
-- rem_dest = pp_server_exch_dest(ctx, ib_port, mtu, port, sl, &my_dest);
-+ rem_dest = pp_server_exch_dest(ctx, ib_port, mtu, port, sl, &my_dest, gidx);
-
- if (!rem_dest)
- return 1;
-
-- printf(" remote address: LID 0x%04x, QPN 0x%06x, PSN 0x%06x\n",
-- rem_dest->lid, rem_dest->qpn, rem_dest->psn);
-+ inet_ntop(AF_INET6, &rem_dest->gid, gid, sizeof gid);
-+ printf(" remote address: LID 0x%04x, QPN 0x%06x, PSN 0x%06x, GID %s\n",
-+ rem_dest->lid, rem_dest->qpn, rem_dest->psn, gid);
-
- if (servername)
-- if (pp_connect_ctx(ctx, ib_port, my_dest.psn, mtu, sl, rem_dest))
-+ if (pp_connect_ctx(ctx, ib_port, my_dest.psn, mtu, sl, rem_dest, gidx))
- return 1;
-
- ctx->pending = PINGPONG_RECV_WRID;
-Index: libibverbs/examples/ud_pingpong.c
-===================================================================
---- libibverbs.orig/examples/ud_pingpong.c 2010-02-08 15:04:24.389329000 +0200
-+++ libibverbs/examples/ud_pingpong.c 2010-03-17 14:08:48.502754000 +0200
-@@ -68,16 +68,18 @@ struct pingpong_context {
- int size;
- int rx_depth;
- int pending;
-+ struct ibv_port_attr portinfo;
- };
-
- struct pingpong_dest {
- int lid;
- int qpn;
- int psn;
-+ union ibv_gid gid;
- };
-
- static int pp_connect_ctx(struct pingpong_context *ctx, int port, int my_psn,
-- int sl, struct pingpong_dest *dest)
-+ int sl, struct pingpong_dest *dest, int sgid_idx)
- {
- struct ibv_ah_attr ah_attr = {
- .is_global = 0,
-@@ -105,6 +107,13 @@ static int pp_connect_ctx(struct pingpon
- return 1;
- }
-
-+ if (dest->gid.global.interface_id) {
-+ ah_attr.is_global = 1;
-+ ah_attr.grh.hop_limit = 1;
-+ ah_attr.grh.dgid = dest->gid;
-+ ah_attr.grh.sgid_index = sgid_idx;
-+ }
-+
- ctx->ah = ibv_create_ah(ctx->pd, &ah_attr);
- if (!ctx->ah) {
- fprintf(stderr, "Failed to create AH\n");
-@@ -123,10 +132,11 @@ static struct pingpong_dest *pp_client_e
- .ai_socktype = SOCK_STREAM
- };
- char *service;
-- char msg[sizeof "0000:000000:000000"];
-+ char msg[sizeof "0000:000000:000000:00000000000000000000000000000000"];
- int n;
- int sockfd = -1;
- struct pingpong_dest *rem_dest = NULL;
-+ char gid[33];
-
- if (asprintf(&service, "%d", port) < 0)
- return NULL;
-@@ -157,7 +167,8 @@ static struct pingpong_dest *pp_client_e
- return NULL;
- }
-
-- sprintf(msg, "%04x:%06x:%06x", my_dest->lid, my_dest->qpn, my_dest->psn);
-+ gid_to_wire_gid(&my_dest->gid, gid);
-+ sprintf(msg, "%04x:%06x:%06x:%s", my_dest->lid, my_dest->qpn, my_dest->psn, gid);
- if (write(sockfd, msg, sizeof msg) != sizeof msg) {
- fprintf(stderr, "Couldn't send local address\n");
- goto out;
-@@ -175,7 +186,8 @@ static struct pingpong_dest *pp_client_e
- if (!rem_dest)
- goto out;
-
-- sscanf(msg, "%x:%x:%x", &rem_dest->lid, &rem_dest->qpn, &rem_dest->psn);
-+ sscanf(msg, "%x:%x:%x:%s", &rem_dest->lid, &rem_dest->qpn, &rem_dest->psn, gid);
-+ wire_gid_to_gid(gid, &rem_dest->gid);
-
- out:
- close(sockfd);
-@@ -184,7 +196,8 @@ out:
-
- static struct pingpong_dest *pp_server_exch_dest(struct pingpong_context *ctx,
- int ib_port, int port, int sl,
-- const struct pingpong_dest *my_dest)
-+ const struct pingpong_dest *my_dest,
-+ int sgid_idx)
- {
- struct addrinfo *res, *t;
- struct addrinfo hints = {
-@@ -193,10 +206,11 @@ static struct pingpong_dest *pp_server_e
- .ai_socktype = SOCK_STREAM
- };
- char *service;
-- char msg[sizeof "0000:000000:000000"];
-+ char msg[sizeof "0000:000000:000000:00000000000000000000000000000000"];
- int n;
- int sockfd = -1, connfd;
- struct pingpong_dest *rem_dest = NULL;
-+ char gid[33];
-
- if (asprintf(&service, "%d", port) < 0)
- return NULL;
-@@ -250,16 +264,18 @@ static struct pingpong_dest *pp_server_e
- if (!rem_dest)
- goto out;
-
-- sscanf(msg, "%x:%x:%x", &rem_dest->lid, &rem_dest->qpn, &rem_dest->psn);
-+ sscanf(msg, "%x:%x:%x:%s", &rem_dest->lid, &rem_dest->qpn, &rem_dest->psn, gid);
-+ wire_gid_to_gid(gid, &rem_dest->gid);
-
-- if (pp_connect_ctx(ctx, ib_port, my_dest->psn, sl, rem_dest)) {
-+ if (pp_connect_ctx(ctx, ib_port, my_dest->psn, sl, rem_dest, sgid_idx)) {
- fprintf(stderr, "Couldn't connect to remote QP\n");
- free(rem_dest);
- rem_dest = NULL;
- goto out;
- }
-
-- sprintf(msg, "%04x:%06x:%06x", my_dest->lid, my_dest->qpn, my_dest->psn);
-+ gid_to_wire_gid(&my_dest->gid, gid);
-+ sprintf(msg, "%04x:%06x:%06x:%s", my_dest->lid, my_dest->qpn, my_dest->psn, gid);
- if (write(connfd, msg, sizeof msg) != sizeof msg) {
- fprintf(stderr, "Couldn't send local address\n");
- free(rem_dest);
-@@ -474,10 +490,11 @@ static void usage(const char *argv0)
- printf(" -p, --port=<port> listen on/connect to port <port> (default 18515)\n");
- printf(" -d, --ib-dev=<dev> use IB device <dev> (default first device found)\n");
- printf(" -i, --ib-port=<port> use port <port> of IB device (default 1)\n");
-- printf(" -s, --size=<size> size of message to exchange (default 2048)\n");
-+ printf(" -s, --size=<size> size of message to exchange (default 1024)\n");
- printf(" -r, --rx-depth=<dep> number of receives to post at a time (default 500)\n");
- printf(" -n, --iters=<iters> number of exchanges (default 1000)\n");
- printf(" -e, --events sleep on CQ events (default poll)\n");
-+ printf(" -g, --gid-idx=<gid index> local port gid index\n");
- }
-
- int main(int argc, char *argv[])
-@@ -492,7 +509,7 @@ int main(int argc, char *argv[])
- char *servername = NULL;
- int port = 18515;
- int ib_port = 1;
-- int size = 2048;
-+ int size = 1024;
- int rx_depth = 500;
- int iters = 1000;
- int use_event = 0;
-@@ -500,6 +517,8 @@ int main(int argc, char *argv[])
- int rcnt, scnt;
- int num_cq_events = 0;
- int sl = 0;
-+ int gidx = -1;
-+ char gid[33];
-
- srand48(getpid() * time(NULL));
-
-@@ -515,10 +534,11 @@ int main(int argc, char *argv[])
- { .name = "iters", .has_arg = 1, .val = 'n' },
- { .name = "sl", .has_arg = 1, .val = 'l' },
- { .name = "events", .has_arg = 0, .val = 'e' },
-+ { .name = "gid-idx", .has_arg = 1, .val = 'g' },
- { 0 }
- };
-
-- c = getopt_long(argc, argv, "p:d:i:s:r:n:l:e", long_options, NULL);
-+ c = getopt_long(argc, argv, "p:d:i:s:r:n:l:eg:", long_options, NULL);
- if (c == -1)
- break;
-
-@@ -563,6 +583,10 @@ int main(int argc, char *argv[])
- ++use_event;
- break;
-
-+ case 'g':
-+ gidx = strtol(optarg, NULL, 0);
-+ break;
-+
- default:
- usage(argv[0]);
- return 1;
-@@ -618,30 +642,41 @@ int main(int argc, char *argv[])
- return 1;
- }
-
-- my_dest.lid = pp_get_local_lid(ctx->context, ib_port);
-- my_dest.qpn = ctx->qp->qp_num;
-- my_dest.psn = lrand48() & 0xffffff;
-- if (!my_dest.lid) {
-- fprintf(stderr, "Couldn't get local LID\n");
-+ if (pp_get_port_info(ctx->context, ib_port, &ctx->portinfo)) {
-+ fprintf(stderr, "Couldn't get port info\n");
- return 1;
- }
-+ my_dest.lid = ctx->portinfo.lid;
-+
-+ my_dest.qpn = ctx->qp->qp_num;
-+ my_dest.psn = lrand48() & 0xffffff;
-+
-+ if (gidx >= 0) {
-+ if (ibv_query_gid(ctx->context, ib_port, gidx, &my_dest.gid)) {
-+ fprintf(stderr, "Could not get local gid for gid index %d\n", gidx);
-+ return 1;
-+ }
-+ } else
-+ memset(&my_dest.gid, 0, sizeof my_dest.gid);
-
-- printf(" local address: LID 0x%04x, QPN 0x%06x, PSN 0x%06x\n",
-- my_dest.lid, my_dest.qpn, my_dest.psn);
-+ inet_ntop(AF_INET6, &my_dest.gid, gid, sizeof gid);
-+ printf(" local address: LID 0x%04x, QPN 0x%06x, PSN 0x%06x: GID %s\n",
-+ my_dest.lid, my_dest.qpn, my_dest.psn, gid);
-
- if (servername)
- rem_dest = pp_client_exch_dest(servername, port, &my_dest);
- else
-- rem_dest = pp_server_exch_dest(ctx, ib_port, port, sl, &my_dest);
-+ rem_dest = pp_server_exch_dest(ctx, ib_port, port, sl, &my_dest, gidx);
-
- if (!rem_dest)
- return 1;
-
-- printf(" remote address: LID 0x%04x, QPN 0x%06x, PSN 0x%06x\n",
-- rem_dest->lid, rem_dest->qpn, rem_dest->psn);
-+ inet_ntop(AF_INET6, &rem_dest->gid, gid, sizeof gid);
-+ printf(" remote address: LID 0x%04x, QPN 0x%06x, PSN 0x%06x, GID %s\n",
-+ rem_dest->lid, rem_dest->qpn, rem_dest->psn, gid);
-
- if (servername)
-- if (pp_connect_ctx(ctx, ib_port, my_dest.psn, sl, rem_dest))
-+ if (pp_connect_ctx(ctx, ib_port, my_dest.psn, sl, rem_dest, gidx))
- return 1;
-
- ctx->pending = PINGPONG_RECV_WRID;
diff --git a/contrib/ofed/libibverbs/fixes/rocee_get_mac.patch b/contrib/ofed/libibverbs/fixes/rocee_get_mac.patch
deleted file mode 100644
index cd1198f..0000000
--- a/contrib/ofed/libibverbs/fixes/rocee_get_mac.patch
+++ /dev/null
@@ -1,112 +0,0 @@
-[PATCHv7 3/4] libibverbs: Add API to retrieve eth MAC
-
-Add a command to retrieve the MAC address of a port's GID. This is required by
-libraries to build work requests when the port's link layer is Ethernet.
-
-Signed-off-by: Eli Cohen <eli@mellanox.co.il>
----
- include/infiniband/driver.h | 1 +
- include/infiniband/kern-abi.h | 20 +++++++++++++++++++-
- src/cmd.c | 19 +++++++++++++++++++
- src/libibverbs.map | 1 +
- 4 files changed, 40 insertions(+), 1 deletions(-)
-
-Index: libibverbs/include/infiniband/driver.h
-===================================================================
---- libibverbs.orig/include/infiniband/driver.h 2010-02-18 13:48:37.000000000 +0200
-+++ libibverbs/include/infiniband/driver.h 2010-02-18 13:50:53.000000000 +0200
-@@ -136,6 +136,11 @@ int ibv_cmd_create_ah(struct ibv_pd *pd,
- int ibv_cmd_destroy_ah(struct ibv_ah *ah);
- int ibv_cmd_attach_mcast(struct ibv_qp *qp, const union ibv_gid *gid, uint16_t lid);
- int ibv_cmd_detach_mcast(struct ibv_qp *qp, const union ibv_gid *gid, uint16_t lid);
-+int ibv_cmd_get_eth_l2_addr(struct ibv_pd *pd, uint8_t port, const union ibv_gid *gid,
-+ int sgid_idx, uint8_t *mac, uint16_t *vlan_id);
-+
-+int ibv_cmd_get_eth_l2_addr(struct ibv_pd *pd, uint8_t port, const union ibv_gid *gid,
-+ int sgid_idx, uint8_t *mac, uint16_t *vlan_id);
-
- int ibv_dontfork_range(void *base, size_t size);
- int ibv_dofork_range(void *base, size_t size);
-Index: libibverbs/include/infiniband/kern-abi.h
-===================================================================
---- libibverbs.orig/include/infiniband/kern-abi.h 2010-02-18 13:48:46.000000000 +0200
-+++ libibverbs/include/infiniband/kern-abi.h 2010-02-18 13:50:53.000000000 +0200
-@@ -94,6 +94,7 @@ enum {
- IB_USER_VERBS_CMD_QUERY_XRC_RCV_QP,
- IB_USER_VERBS_CMD_REG_XRC_RCV_QP,
- IB_USER_VERBS_CMD_UNREG_XRC_RCV_QP,
-+ IB_USER_VERBS_CMD_GET_ETH_L2_ADDR,
- };
-
- /*
-@@ -946,6 +947,7 @@ enum {
- IB_USER_VERBS_CMD_QUERY_XRC_RCV_QP_V2 = -1,
- IB_USER_VERBS_CMD_REG_XRC_RCV_QP_V2 = -1,
- IB_USER_VERBS_CMD_UNREG_XRC_RCV_QP_V2 = -1,
-+ IB_USER_VERBS_CMD_GET_ETH_L2_ADDR_V2 = -1,
- };
-
- struct ibv_destroy_cq_v1 {
-@@ -1021,4 +1023,21 @@ struct ibv_create_srq_resp_v5 {
- __u32 srq_handle;
- };
-
-+struct ibv_get_eth_l2_addr {
-+ __u32 command;
-+ __u16 in_words;
-+ __u16 out_words;
-+ __u64 response;
-+ __u32 pd_handle;
-+ __u8 port;
-+ __u8 sgid_idx;
-+ __u8 reserved[2];
-+ __u8 dgid[16];
-+};
-+
-+struct ibv_get_eth_l2_addr_resp {
-+ __u8 mac[6];
-+ __u16 vlan_id;
-+};
-+
- #endif /* KERN_ABI_H */
-Index: libibverbs/src/cmd.c
-===================================================================
---- libibverbs.orig/src/cmd.c 2010-02-18 13:48:46.000000000 +0200
-+++ libibverbs/src/cmd.c 2010-02-18 13:50:53.000000000 +0200
-@@ -1407,4 +1407,24 @@ int ibv_cmd_unreg_xrc_rcv_qp(struct ibv_
- return 0;
- }
-
-+int ibv_cmd_get_eth_l2_addr(struct ibv_pd *pd, uint8_t port, const union ibv_gid *gid,
-+ int sgid_idx, uint8_t *mac, uint16_t *vlan_id)
-+{
-+ struct ibv_get_eth_l2_addr cmd;
-+ struct ibv_get_eth_l2_addr_resp resp;
-+
-+ IBV_INIT_CMD_RESP(&cmd, sizeof cmd, GET_ETH_L2_ADDR, &resp, sizeof resp);
-+ memcpy(cmd.dgid, gid, sizeof cmd.dgid);
-+ cmd.pd_handle = pd->handle;
-+ cmd.port = port;
-+ cmd.sgid_idx = sgid_idx;
-+
-+ if (write(pd->context->cmd_fd, &cmd, sizeof cmd) != sizeof cmd)
-+ return errno;
-+
-+ memcpy(mac, resp.mac, 6);
-+ *vlan_id = resp.vlan_id;
-+
-+ return 0;
-+}
-
-Index: libibverbs/src/libibverbs.map
-===================================================================
---- libibverbs.orig/src/libibverbs.map 2010-02-18 13:48:37.000000000 +0200
-+++ libibverbs/src/libibverbs.map 2010-02-18 13:50:53.000000000 +0200
-@@ -64,6 +64,7 @@ IBVERBS_1.0 {
- ibv_cmd_destroy_ah;
- ibv_cmd_attach_mcast;
- ibv_cmd_detach_mcast;
-+ ibv_cmd_get_eth_l2_addr;
- ibv_copy_qp_attr_from_kern;
- ibv_copy_path_rec_from_kern;
- ibv_copy_path_rec_to_kern;
diff --git a/contrib/ofed/libibverbs/fixes/rocee_kernel_accept_link_layer.patch b/contrib/ofed/libibverbs/fixes/rocee_kernel_accept_link_layer.patch
deleted file mode 100644
index 02981f4..0000000
--- a/contrib/ofed/libibverbs/fixes/rocee_kernel_accept_link_layer.patch
+++ /dev/null
@@ -1,50 +0,0 @@
-[PATCHv7 2/4] libibverbs: change kernel API to accept link layer
-
-Modify the code to allow passing the link layer of a port from kernel to user.
-Update ibv_query_port.3 man page with the change.
-
-Signed-off-by: Eli Cohen <eli@mellanox.co.il>
----
- include/infiniband/kern-abi.h | 3 ++-
- man/ibv_query_port.3 | 1 +
- src/cmd.c | 1 +
- 3 files changed, 4 insertions(+), 1 deletions(-)
-
-Index: libibverbs/include/infiniband/kern-abi.h
-===================================================================
---- libibverbs.orig/include/infiniband/kern-abi.h 2010-06-08 11:08:57.895171000 +0300
-+++ libibverbs/include/infiniband/kern-abi.h 2010-06-08 11:09:10.172540000 +0300
-@@ -231,7 +231,8 @@ struct ibv_query_port_resp {
- __u8 active_width;
- __u8 active_speed;
- __u8 phys_state;
-- __u8 reserved[3];
-+ __u8 link_layer;
-+ __u8 reserved[2];
- };
-
- struct ibv_alloc_pd {
-Index: libibverbs/man/ibv_query_port.3
-===================================================================
---- libibverbs.orig/man/ibv_query_port.3 2010-06-08 11:08:57.951172000 +0300
-+++ libibverbs/man/ibv_query_port.3 2010-06-08 11:09:10.177543000 +0300
-@@ -44,6 +44,7 @@ uint8_t init_type_reply;
- uint8_t active_width; /* Currently active link width */
- uint8_t active_speed; /* Currently active link speed */
- uint8_t phys_state; /* Physical port state */
-+uint8_t link_layer; /* link layer protocol of the port */
- .in -8
- };
- .sp
-Index: libibverbs/src/cmd.c
-===================================================================
---- libibverbs.orig/src/cmd.c 2010-06-08 11:08:57.999167000 +0300
-+++ libibverbs/src/cmd.c 2010-06-08 11:09:10.186539000 +0300
-@@ -196,6 +196,7 @@ int ibv_cmd_query_port(struct ibv_contex
- port_attr->active_width = resp.active_width;
- port_attr->active_speed = resp.active_speed;
- port_attr->phys_state = resp.phys_state;
-+ port_attr->link_layer = resp.link_layer;
-
- return 0;
- }
diff --git a/contrib/ofed/libibverbs/fixes/rocee_link_layer.patch b/contrib/ofed/libibverbs/fixes/rocee_link_layer.patch
deleted file mode 100644
index 226aaa3..0000000
--- a/contrib/ofed/libibverbs/fixes/rocee_link_layer.patch
+++ /dev/null
@@ -1,70 +0,0 @@
-[PATCHv7 1/4] libibverbs: Add link layer field to ibv_port_attr
-
-This field can have one of the values - IBV_LINK_LAYER_UNSPECIFIED,
-IBV_LINK_LAYER_INFINIBAND, IBV_LINK_LAYER_ETHERNET. It can be used by
-applications to know the link layer used by the port, which can be either
-Infiniband or Ethernet. The addition of the new field does not change the size
-of struct ibv_port_attr due to alignment of the preceding field. Binary
-compatibility is not compromised either since new apps with old libraries will
-determine the link layer as IB while old applications with new a new library do
-not read this field.
-
-Solution suggested by:
- Roland Dreier <rolandd@cisco.com>
- Jason Gunthorpe <jgunthorpe@obsidianresearch.com>
-Signed-off-by: Eli Cohen <eli@mellanox.co.il>
----
- include/infiniband/verbs.h | 21 +++++++++++++++++++++
- 1 files changed, 21 insertions(+), 0 deletions(-)
-
-Index: libibverbs/include/infiniband/verbs.h
-===================================================================
---- libibverbs.orig/include/infiniband/verbs.h 2010-06-08 11:00:05.575721000 +0300
-+++ libibverbs/include/infiniband/verbs.h 2010-06-08 11:00:39.442737000 +0300
-@@ -162,6 +162,12 @@ enum ibv_port_state {
- IBV_PORT_ACTIVE_DEFER = 5
- };
-
-+enum {
-+ IBV_LINK_LAYER_UNSPECIFIED,
-+ IBV_LINK_LAYER_INFINIBAND,
-+ IBV_LINK_LAYER_ETHERNET,
-+};
-+
- struct ibv_port_attr {
- enum ibv_port_state state;
- enum ibv_mtu max_mtu;
-@@ -182,6 +188,8 @@ struct ibv_port_attr {
- uint8_t active_width;
- uint8_t active_speed;
- uint8_t phys_state;
-+ uint8_t link_layer;
-+ uint8_t pad;
- };
-
- enum ibv_event_type {
-@@ -743,6 +751,16 @@ struct ibv_context {
- struct ibv_more_ops *more_ops;
- };
-
-+static inline int ___ibv_query_port(struct ibv_context *context,
-+ uint8_t port_num,
-+ struct ibv_port_attr *port_attr)
-+{
-+ port_attr->link_layer = IBV_LINK_LAYER_UNSPECIFIED;
-+ port_attr->pad = 0;
-+
-+ return context->ops.query_port(context, port_num, port_attr);
-+}
-+
- /**
- * ibv_get_device_list - Get list of IB devices currently available
- * @num_devices: optional. if non-NULL, set to the number of devices
-@@ -1304,4 +1322,7 @@ END_C_DECLS
-
- # undef __attribute_const
-
-+#define ibv_query_port(context, port_num, port_attr) \
-+ ___ibv_query_port(context, port_num, port_attr)
-+
- #endif /* INFINIBAND_VERBS_H */
diff --git a/contrib/ofed/libibverbs/fixes/rpm_spec_changelog_fix.patch b/contrib/ofed/libibverbs/fixes/rpm_spec_changelog_fix.patch
deleted file mode 100644
index 06eee72..0000000
--- a/contrib/ofed/libibverbs/fixes/rpm_spec_changelog_fix.patch
+++ /dev/null
@@ -1,13 +0,0 @@
-diff --git a/libibverbs.spec.in b/libibverbs.spec.in
-index d8cc4ee..daa3051 100644
---- a/libibverbs.spec.in
-+++ b/libibverbs.spec.in
-@@ -85,7 +85,7 @@ rm -rf $RPM_BUILD_ROOT
- %{_mandir}/man1/*
-
- %changelog
--* Thu Jun 3 Roland Dreier <rdreier@cisco.com> - 1.1.4-1
-+* Thu Jun 3 2010 Roland Dreier <rdreier@cisco.com> - 1.1.4-1
- - New upstream release
-
- * Thu Oct 29 2009 Roland Dreier <rdreier@cisco.com> - 1.1.3-1
diff --git a/contrib/ofed/libibverbs/fixes/series b/contrib/ofed/libibverbs/fixes/series
deleted file mode 100644
index e3fa53a..0000000
--- a/contrib/ofed/libibverbs/fixes/series
+++ /dev/null
@@ -1,14 +0,0 @@
-verbs_man_page.patch
-XRC_man_pages.patch
-XRC_base_implementation.patch
-XRC_RCV_QP.patch
-pthread_cond_t_fields.patch
-rocee_link_layer.patch
-rocee_kernel_accept_link_layer.patch
-rocee_get_mac.patch
-rocee_examples.patch
-qpt_raw_eth.patch
-configure_in-AC_PROG_LIBTOOL-for-automake.patch
-rpm_spec_changelog_fix.patch
-iboe_adapt_new_api.patch
-support_gid_change.patch
diff --git a/contrib/ofed/libibverbs/fixes/verbs_man_page.patch b/contrib/ofed/libibverbs/fixes/verbs_man_page.patch
deleted file mode 100644
index e2fa804..0000000
--- a/contrib/ofed/libibverbs/fixes/verbs_man_page.patch
+++ /dev/null
@@ -1,242 +0,0 @@
-commit ebc306b0ad2a8a873a195b26ebafe704da001981
-Author: Dotan Barak <dotanb@dev.mellanox.co.il>
-Date: Sun Feb 3 17:58:53 2008 +0200
-
- libibverbs: Added the man page verbs.7
-
- Added the man page verbs.7 which is an introduction to libibverbs man pages.
-
- Signed-off-by: Dotan Barak <dotanb@dev.mellanox.co.il>
- Signed-off-by: Or Gerlitz <ogerlitz@voltaire.com>
-
-Index: libibverbs/Makefile.am
-===================================================================
---- libibverbs.orig/Makefile.am 2010-06-07 18:38:19.088451000 +0300
-+++ libibverbs/Makefile.am 2010-06-08 10:58:10.061113000 +0300
-@@ -53,7 +53,7 @@ man_MANS = man/ibv_asyncwatch.1 man/ibv_
- man/ibv_post_srq_recv.3 man/ibv_query_device.3 man/ibv_query_gid.3 \
- man/ibv_query_pkey.3 man/ibv_query_port.3 man/ibv_query_qp.3 \
- man/ibv_query_srq.3 man/ibv_rate_to_mult.3 man/ibv_reg_mr.3 \
-- man/ibv_req_notify_cq.3 man/ibv_resize_cq.3
-+ man/ibv_req_notify_cq.3 man/ibv_resize_cq.3 man/verbs.7
-
- DEBIAN = debian/changelog debian/compat debian/control debian/copyright \
- debian/ibverbs-utils.install debian/libibverbs1.install \
-Index: libibverbs/libibverbs.spec.in
-===================================================================
---- libibverbs.orig/libibverbs.spec.in 2010-06-08 10:47:13.106792000 +0300
-+++ libibverbs/libibverbs.spec.in 2010-06-08 10:58:10.160119000 +0300
-@@ -74,6 +74,7 @@ rm -rf $RPM_BUILD_ROOT
- %{_libdir}/lib*.so
- %{_includedir}/*
- %{_mandir}/man3/*
-+%{_mandir}/man7/*
-
- %files devel-static
- %defattr(-,root,root,-)
-Index: libibverbs/man/verbs.7
-===================================================================
---- /dev/null 1970-01-01 00:00:00.000000000 +0000
-+++ libibverbs/man/verbs.7 2010-06-08 10:58:10.360115000 +0300
-@@ -0,0 +1,201 @@
-+.\" -*- nroff -*-
-+.\"
-+.TH VERBS 7 2008-01-17 libibverbs "Libibverbs Programmer's Manual"
-+.SH "NAME"
-+verbs \- Infiniband verbs library
-+.SH "SYNOPSIS"
-+.nf
-+.B #include <infiniband/verbs.h>
-+.fi
-+.SH "DESCRIPTION"
-+This library is an implementation of the verbs according to the Infiniband specification volume 1.2. It handles the control path of creating, modifying, querying and destroying resources such as Protection Domains (PD), Completion Queues (CQ), Queue-Pairs (QP), Shared Receive Queues (SRQ), Address Handles (AH), Memory Regions (MR). It also handles sending and receiving data posted to QPs and SRQs, getting completions from CQs using polling and completions events.
-+
-+The control path is implemented through system calls to the uverbs kernel module which further calls the low level HW driver. The data path is implemented through calls made to low level HW library which in most cases interacts directly with the HW providing kernel and network stack bypass (saving context/mode switches) along with zero copy and an asynchronous I/O model.
-+
-+
-+Typically, under network and RDMA programming, there are operations which involve interaction with remote peers (such as address resolution and connection establishment) and remote entities (such as route resolution and joining a multicast group under IB), where a resource managed through IB verbs such as QP or AH would be eventually created or effected from this interaction. In such cases, applications whose addressing semantics is based on IP can use librdmacm (see rdma_cm(7)) which works in conjunction with libibverbs.
-+
-+This library is thread safe library and verbs can be called from every thread in the process (the same resource can even be handled from different threads, for example: ibv_poll_cq can be called from more than one thread).
-+
-+However, it is up to the user to stop working with a resource after it was destroyed (by the same thread or by any other thread), this may result a segmentation fault.
-+
-+If fork (or any other system call that perform fork directly or indirectly) is being used, please see ibv_fork_init(3).
-+
-+.LP
-+The following shall be declared as functions and may also be defined
-+as macros. Function prototypes shall be provided.
-+.RS
-+.nf
-+
-+\fB
-+.B Library functions
-+
-+int ibv_fork_init(void);
-+
-+.B Device functions
-+
-+struct ibv_device **ibv_get_device_list(int *num_devices);
-+void ibv_free_device_list(struct ibv_device **list);
-+const char *ibv_get_device_name(struct ibv_device *device);
-+uint64_t ibv_get_device_guid(struct ibv_device *device);
-+
-+.B Context functions
-+
-+struct ibv_context *ibv_open_device(struct ibv_device *device);
-+int ibv_close_device(struct ibv_context *context);
-+
-+.B Queries
-+
-+int ibv_query_device(struct ibv_context *context,
-+ struct ibv_device_attr *device_attr);
-+int ibv_query_port(struct ibv_context *context, uint8_t port_num,
-+ struct ibv_port_attr *port_attr);
-+int ibv_query_pkey(struct ibv_context *context, uint8_t port_num,
-+ int index, uint16_t *pkey);
-+int ibv_query_gid(struct ibv_context *context, uint8_t port_num,
-+ int index, union ibv_gid *gid);
-+
-+.B Asynchronous events
-+
-+int ibv_get_async_event(struct ibv_context *context,
-+ struct ibv_async_event *event);
-+void ibv_ack_async_event(struct ibv_async_event *event);
-+
-+.B Protection Domains
-+
-+struct ibv_pd *ibv_alloc_pd(struct ibv_context *context);
-+int ibv_dealloc_pd(struct ibv_pd *pd);
-+
-+.B Memory Regions
-+
-+struct ibv_mr *ibv_reg_mr(struct ibv_pd *pd, void *addr,
-+ size_t length, enum ibv_access_flags access);
-+int ibv_dereg_mr(struct ibv_mr *mr);
-+
-+.B Address Handles
-+
-+struct ibv_ah *ibv_create_ah(struct ibv_pd *pd, struct ibv_ah_attr *attr);
-+int ibv_init_ah_from_wc(struct ibv_context *context, uint8_t port_num,
-+ struct ibv_wc *wc, struct ibv_grh *grh,
-+ struct ibv_ah_attr *ah_attr);
-+struct ibv_ah *ibv_create_ah_from_wc(struct ibv_pd *pd, struct ibv_wc *wc,
-+ struct ibv_grh *grh, uint8_t port_num);
-+int ibv_destroy_ah(struct ibv_ah *ah);
-+
-+.B Completion event channels
-+
-+struct ibv_comp_channel *ibv_create_comp_channel(struct ibv_context *context);
-+int ibv_destroy_comp_channel(struct ibv_comp_channel *channel);
-+
-+.B Completion Queues Control
-+
-+struct ibv_cq *ibv_create_cq(struct ibv_context *context, int cqe,
-+ void *cq_context,
-+ struct ibv_comp_channel *channel,
-+ int comp_vector);
-+int ibv_destroy_cq(struct ibv_cq *cq);
-+int ibv_resize_cq(struct ibv_cq *cq, int cqe);
-+
-+.B Reading Completions from CQ
-+
-+int ibv_poll_cq(struct ibv_cq *cq, int num_entries, struct ibv_wc *wc);
-+
-+.B Requesting / Managing CQ events
-+
-+int ibv_req_notify_cq(struct ibv_cq *cq, int solicited_only);
-+int ibv_get_cq_event(struct ibv_comp_channel *channel,
-+ struct ibv_cq **cq, void **cq_context);
-+void ibv_ack_cq_events(struct ibv_cq *cq, unsigned int nevents);
-+
-+.B Shared Receive Queue control
-+
-+struct ibv_srq *ibv_create_srq(struct ibv_pd *pd,
-+ struct ibv_srq_init_attr *srq_init_attr);
-+int ibv_destroy_srq(struct ibv_srq *srq);
-+int ibv_modify_srq(struct ibv_srq *srq,
-+ struct ibv_srq_attr *srq_attr,
-+ enum ibv_srq_attr_mask srq_attr_mask);
-+int ibv_query_srq(struct ibv_srq *srq, struct ibv_srq_attr *srq_attr);
-+
-+.B Queue Pair control
-+
-+struct ibv_qp *ibv_create_qp(struct ibv_pd *pd,
-+ struct ibv_qp_init_attr *qp_init_attr);
-+int ibv_destroy_qp(struct ibv_qp *qp);
-+int ibv_modify_qp(struct ibv_qp *qp, struct ibv_qp_attr *attr,
-+ enum ibv_qp_attr_mask attr_mask);
-+int ibv_query_qp(struct ibv_qp *qp, struct ibv_qp_attr *attr,
-+ enum ibv_qp_attr_mask attr_mask,
-+ struct ibv_qp_init_attr *init_attr);
-+
-+.B posting Work Requests to QPs/SRQs
-+int ibv_post_send(struct ibv_qp *qp, struct ibv_send_wr *wr,
-+ struct ibv_send_wr **bad_wr);
-+int ibv_post_recv(struct ibv_qp *qp, struct ibv_recv_wr *wr,
-+ struct ibv_recv_wr **bad_wr);
-+int ibv_post_srq_recv(struct ibv_srq *srq,
-+ struct ibv_recv_wr *recv_wr,
-+ struct ibv_recv_wr **bad_recv_wr);
-+
-+.B Multicast group
-+
-+int ibv_attach_mcast(struct ibv_qp *qp, union ibv_gid *gid, uint16_t lid);
-+int ibv_detach_mcast(struct ibv_qp *qp, union ibv_gid *gid, uint16_t lid);
-+
-+.B General functions
-+
-+int ibv_rate_to_mult(enum ibv_rate rate);
-+enum ibv_rate mult_to_ibv_rate(int mult);
-+\fP
-+.SH "SEE ALSO"
-+.LP
-+\fIibv_fork_init\fP(),
-+\fIibv_get_device_list\fP(),
-+\fIibv_free_device_list\fP(),
-+\fIibv_get_device_name\fP(),
-+\fIibv_get_device_guid\fP(),
-+\fIibv_open_device\fP(),
-+\fIibv_close_device\fP(),
-+\fIibv_query_device\fP(),
-+\fIibv_query_port\fP(),
-+\fIibv_query_pkey\fP(),
-+\fIibv_query_gid\fP(),
-+\fIibv_get_async_event\fP(),
-+\fIibv_ack_async_event\fP(),
-+\fIibv_alloc_pd\fP(),
-+\fIibv_dealloc_pd\fP(),
-+\fIibv_reg_mr\fP(),
-+\fIibv_dereg_mr\fP(),
-+\fIibv_create_ah\fP(),
-+\fIibv_init_ah_from_wc\fP(),
-+\fIibv_create_ah_from_wc\fP(),
-+\fIibv_destroy_ah\fP(),
-+\fIibv_create_comp_channel\fP(),
-+\fIibv_destroy_comp_channel\fP(),
-+\fIibv_create_cq\fP(),
-+\fIibv_destroy_cq\fP(),
-+\fIibv_resize_cq\fP(),
-+\fIibv_poll_cq\fP(),
-+\fIibv_req_notify_cq\fP(),
-+\fIibv_get_cq_event\fP(),
-+\fIibv_ack_cq_events\fP(),
-+\fIibv_create_srq\fP(),
-+\fIibv_destroy_srq\fP(),
-+\fIibv_modify_srq\fP(),
-+\fIibv_query_srq\fP(),
-+\fIibv_post_srq_recv\fP(),
-+\fIibv_create_qp\fP(),
-+\fIibv_destroy_qp\fP(),
-+\fIibv_modify_qp\fP(),
-+\fIibv_query_qp\fP(),
-+\fIibv_post_send\fP(),
-+\fIibv_post_recv\fP(),
-+\fIibv_attach_mcast\fP(),
-+\fIibv_detach_mcast\fP(),
-+\fIibv_rate_to_mult\fP(),
-+\fImult_to_ibv_rate\fP()
-+.SH "AUTHORS"
-+.TP
-+Dotan Barak <dotanb@mellanox.co.il>
-+.TP
-+Or Gerlitz <ogerlitz@voltaire.com>
diff --git a/contrib/ofed/libibverbs/ibverbs.h b/contrib/ofed/libibverbs/ibverbs.h
new file mode 100644
index 0000000..eb597fe
--- /dev/null
+++ b/contrib/ofed/libibverbs/ibverbs.h
@@ -0,0 +1,117 @@
+/*
+ * Copyright (c) 2004, 2005 Topspin Communications. All rights reserved.
+ * Copyright (c) 2007 Cisco Systems, Inc. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#ifndef IB_VERBS_H
+#define IB_VERBS_H
+
+#include <pthread.h>
+
+#include <infiniband/driver.h>
+
+#define INIT __attribute__((constructor))
+
+#define DEFAULT_ABI "IBVERBS_1.1"
+
+#define symver(name, api, ver) asm(".symver " #name "," #api "@" #ver)
+#define default_symver(name, api) \
+ asm(".symver " #name "," #api "@@" DEFAULT_ABI)
+#define private_symver(name, api) \
+ asm(".symver " #name "," #api "@@IBVERBS_PRIVATE_14")
+
+#define PFX "libibverbs: "
+
+struct ibv_abi_compat_v2 {
+ struct ibv_comp_channel channel;
+ pthread_mutex_t in_use;
+};
+
+extern int abi_ver;
+
+int ibverbs_init(struct ibv_device ***list);
+
+struct verbs_ex_private {
+ struct ibv_cq_ex *(*create_cq_ex)(struct ibv_context *context,
+ struct ibv_cq_init_attr_ex *init_attr);
+};
+
+#define IBV_INIT_CMD(cmd, size, opcode) \
+ do { \
+ if (abi_ver > 2) \
+ (cmd)->command = IB_USER_VERBS_CMD_##opcode; \
+ else \
+ (cmd)->command = IB_USER_VERBS_CMD_##opcode##_V2; \
+ (cmd)->in_words = (size) / 4; \
+ (cmd)->out_words = 0; \
+ } while (0)
+
+#define IBV_INIT_CMD_RESP(cmd, size, opcode, out, outsize) \
+ do { \
+ if (abi_ver > 2) \
+ (cmd)->command = IB_USER_VERBS_CMD_##opcode; \
+ else \
+ (cmd)->command = IB_USER_VERBS_CMD_##opcode##_V2; \
+ (cmd)->in_words = (size) / 4; \
+ (cmd)->out_words = (outsize) / 4; \
+ (cmd)->response = (uintptr_t) (out); \
+ } while (0)
+
+#define IBV_INIT_CMD_RESP_EX_V(cmd, cmd_size, size, opcode, out, resp_size,\
+ outsize) \
+ do { \
+ size_t c_size = cmd_size - sizeof(struct ex_hdr); \
+ if (abi_ver > 2) \
+ (cmd)->hdr.command = IB_USER_VERBS_CMD_##opcode; \
+ else \
+ (cmd)->hdr.command = \
+ IB_USER_VERBS_CMD_##opcode##_V2; \
+ (cmd)->hdr.in_words = ((c_size) / 8); \
+ (cmd)->hdr.out_words = ((resp_size) / 8); \
+ (cmd)->hdr.provider_in_words = (((size) - (cmd_size))/8);\
+ (cmd)->hdr.provider_out_words = \
+ (((outsize) - (resp_size)) / 8); \
+ (cmd)->hdr.response = (uintptr_t) (out); \
+ (cmd)->hdr.reserved = 0; \
+ } while (0)
+
+#define IBV_INIT_CMD_RESP_EX_VCMD(cmd, cmd_size, size, opcode, out, outsize) \
+ IBV_INIT_CMD_RESP_EX_V(cmd, cmd_size, size, opcode, out, \
+ sizeof(*(out)), outsize)
+
+#define IBV_INIT_CMD_RESP_EX(cmd, size, opcode, out, outsize) \
+ IBV_INIT_CMD_RESP_EX_V(cmd, sizeof(*(cmd)), size, opcode, out, \
+ sizeof(*(out)), outsize)
+
+#define IBV_INIT_CMD_EX(cmd, size, opcode) \
+ IBV_INIT_CMD_RESP_EX_V(cmd, sizeof(*(cmd)), size, opcode, NULL, 0, 0)
+
+#endif /* IB_VERBS_H */
diff --git a/contrib/ofed/libibverbs/include/infiniband/arch.h b/contrib/ofed/libibverbs/include/infiniband/arch.h
deleted file mode 100644
index ce77fd5..0000000
--- a/contrib/ofed/libibverbs/include/infiniband/arch.h
+++ /dev/null
@@ -1,129 +0,0 @@
-/*
- * Copyright (c) 2005 Topspin Communications. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-#ifndef INFINIBAND_ARCH_H
-#define INFINIBAND_ARCH_H
-
-#include <stdint.h>
-#include <infiniband/endian.h>
-#include <infiniband/byteswap.h>
-
-#if __BYTE_ORDER == __LITTLE_ENDIAN
-static inline uint64_t htonll(uint64_t x) { return bswap_64(x); }
-static inline uint64_t ntohll(uint64_t x) { return bswap_64(x); }
-#elif __BYTE_ORDER == __BIG_ENDIAN
-static inline uint64_t htonll(uint64_t x) { return x; }
-static inline uint64_t ntohll(uint64_t x) { return x; }
-#else
-#error __BYTE_ORDER is neither __LITTLE_ENDIAN nor __BIG_ENDIAN
-#endif
-
-/*
- * Architecture-specific defines. Currently, an architecture is
- * required to implement the following operations:
- *
- * mb() - memory barrier. No loads or stores may be reordered across
- * this macro by either the compiler or the CPU.
- * rmb() - read memory barrier. No loads may be reordered across this
- * macro by either the compiler or the CPU.
- * wmb() - write memory barrier. No stores may be reordered across
- * this macro by either the compiler or the CPU.
- * wc_wmb() - flush write combine buffers. No write-combined writes
- * will be reordered across this macro by either the compiler or
- * the CPU.
- */
-
-#if defined(__i386__)
-
-#define mb() asm volatile("lock; addl $0,0(%%esp) " ::: "memory")
-#define rmb() mb()
-#define wmb() asm volatile("" ::: "memory")
-#define wc_wmb() mb()
-
-#elif defined(__x86_64__)
-
-/*
- * Only use lfence for mb() and rmb() because we don't care about
- * ordering against non-temporal stores (for now at least).
- */
-#define mb() asm volatile("lfence" ::: "memory")
-#define rmb() mb()
-#define wmb() asm volatile("" ::: "memory")
-#define wc_wmb() asm volatile("sfence" ::: "memory")
-
-#elif defined(__PPC64__)
-
-#define mb() asm volatile("sync" ::: "memory")
-#define rmb() asm volatile("lwsync" ::: "memory")
-#define wmb() mb()
-#define wc_wmb() wmb()
-
-#elif defined(__ia64__)
-
-#define mb() asm volatile("mf" ::: "memory")
-#define rmb() mb()
-#define wmb() mb()
-#define wc_wmb() asm volatile("fwb" ::: "memory")
-
-#elif defined(__PPC__)
-
-#define mb() asm volatile("sync" ::: "memory")
-#define rmb() mb()
-#define wmb() mb()
-#define wc_wmb() wmb()
-
-#elif defined(__sparc_v9__)
-
-#define mb() asm volatile("membar #LoadLoad | #LoadStore | #StoreStore | #StoreLoad" ::: "memory")
-#define rmb() asm volatile("membar #LoadLoad" ::: "memory")
-#define wmb() asm volatile("membar #StoreStore" ::: "memory")
-#define wc_wmb() wmb()
-
-#elif defined(__sparc__)
-
-#define mb() asm volatile("" ::: "memory")
-#define rmb() mb()
-#define wmb() mb()
-#define wc_wmb() wmb()
-
-#else
-
-#warning No architecture specific defines found. Using generic implementation.
-
-#define mb() asm volatile("" ::: "memory")
-#define rmb() mb()
-#define wmb() mb()
-#define wc_wmb() wmb()
-
-#endif
-
-#endif /* INFINIBAND_ARCH_H */
diff --git a/contrib/ofed/libibverbs/include/infiniband/driver.h b/contrib/ofed/libibverbs/include/infiniband/driver.h
deleted file mode 100644
index 593ac3c..0000000
--- a/contrib/ofed/libibverbs/include/infiniband/driver.h
+++ /dev/null
@@ -1,172 +0,0 @@
-/*
- * Copyright (c) 2004, 2005 Topspin Communications. All rights reserved.
- * Copyright (c) 2005, 2006 Cisco Systems, Inc. All rights reserved.
- * Copyright (c) 2005 PathScale, Inc. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-#ifndef INFINIBAND_DRIVER_H
-#define INFINIBAND_DRIVER_H
-
-#include <infiniband/verbs.h>
-#include <infiniband/kern-abi.h>
-
-#ifdef __cplusplus
-# define BEGIN_C_DECLS extern "C" {
-# define END_C_DECLS }
-#else /* !__cplusplus */
-# define BEGIN_C_DECLS
-# define END_C_DECLS
-#endif /* __cplusplus */
-
-/*
- * Extension that low-level drivers should add to their .so filename
- * (probably via libtool "-release" option). For example a low-level
- * driver named "libfoo" should build a plug-in named "libfoo-rdmav2.so".
- */
-#define IBV_DEVICE_LIBRARY_EXTENSION rdmav2
-
-typedef struct ibv_device *(*ibv_driver_init_func)(const char *uverbs_sys_path,
- int abi_version);
-
-void ibv_register_driver(const char *name, ibv_driver_init_func init_func);
-int ibv_cmd_get_context(struct ibv_context *context, struct ibv_get_context *cmd,
- size_t cmd_size, struct ibv_get_context_resp *resp,
- size_t resp_size);
-int ibv_cmd_query_device(struct ibv_context *context,
- struct ibv_device_attr *device_attr,
- uint64_t *raw_fw_ver,
- struct ibv_query_device *cmd, size_t cmd_size);
-int ibv_cmd_query_port(struct ibv_context *context, uint8_t port_num,
- struct ibv_port_attr *port_attr,
- struct ibv_query_port *cmd, size_t cmd_size);
-int ibv_cmd_query_gid(struct ibv_context *context, uint8_t port_num,
- int index, union ibv_gid *gid);
-int ibv_cmd_query_pkey(struct ibv_context *context, uint8_t port_num,
- int index, uint16_t *pkey);
-int ibv_cmd_alloc_pd(struct ibv_context *context, struct ibv_pd *pd,
- struct ibv_alloc_pd *cmd, size_t cmd_size,
- struct ibv_alloc_pd_resp *resp, size_t resp_size);
-int ibv_cmd_dealloc_pd(struct ibv_pd *pd);
-#define IBV_CMD_REG_MR_HAS_RESP_PARAMS
-int ibv_cmd_reg_mr(struct ibv_pd *pd, void *addr, size_t length,
- uint64_t hca_va, int access,
- struct ibv_mr *mr, struct ibv_reg_mr *cmd,
- size_t cmd_size,
- struct ibv_reg_mr_resp *resp, size_t resp_size);
-int ibv_cmd_dereg_mr(struct ibv_mr *mr);
-int ibv_cmd_create_cq(struct ibv_context *context, int cqe,
- struct ibv_comp_channel *channel,
- int comp_vector, struct ibv_cq *cq,
- struct ibv_create_cq *cmd, size_t cmd_size,
- struct ibv_create_cq_resp *resp, size_t resp_size);
-int ibv_cmd_poll_cq(struct ibv_cq *cq, int ne, struct ibv_wc *wc);
-int ibv_cmd_req_notify_cq(struct ibv_cq *cq, int solicited_only);
-#define IBV_CMD_RESIZE_CQ_HAS_RESP_PARAMS
-int ibv_cmd_resize_cq(struct ibv_cq *cq, int cqe,
- struct ibv_resize_cq *cmd, size_t cmd_size,
- struct ibv_resize_cq_resp *resp, size_t resp_size);
-int ibv_cmd_destroy_cq(struct ibv_cq *cq);
-
-int ibv_cmd_create_srq(struct ibv_pd *pd,
- struct ibv_srq *srq, struct ibv_srq_init_attr *attr,
- struct ibv_create_srq *cmd, size_t cmd_size,
- struct ibv_create_srq_resp *resp, size_t resp_size);
-int ibv_cmd_create_xrc_srq(struct ibv_pd *pd,
- struct ibv_srq *srq, struct ibv_srq_init_attr *attr,
- uint32_t xrc_domain, uint32_t xrc_cq,
- struct ibv_create_xrc_srq *cmd, size_t cmd_size,
- struct ibv_create_srq_resp *resp, size_t resp_size);
-int ibv_cmd_modify_srq(struct ibv_srq *srq,
- struct ibv_srq_attr *srq_attr,
- int srq_attr_mask,
- struct ibv_modify_srq *cmd, size_t cmd_size);
-int ibv_cmd_query_srq(struct ibv_srq *srq,
- struct ibv_srq_attr *srq_attr,
- struct ibv_query_srq *cmd, size_t cmd_size);
-int ibv_cmd_destroy_srq(struct ibv_srq *srq);
-
-int ibv_cmd_create_qp(struct ibv_pd *pd,
- struct ibv_qp *qp, struct ibv_qp_init_attr *attr,
- struct ibv_create_qp *cmd, size_t cmd_size,
- struct ibv_create_qp_resp *resp, size_t resp_size);
-int ibv_cmd_query_qp(struct ibv_qp *qp, struct ibv_qp_attr *qp_attr,
- int attr_mask,
- struct ibv_qp_init_attr *qp_init_attr,
- struct ibv_query_qp *cmd, size_t cmd_size);
-int ibv_cmd_modify_qp(struct ibv_qp *qp, struct ibv_qp_attr *attr,
- int attr_mask,
- struct ibv_modify_qp *cmd, size_t cmd_size);
-int ibv_cmd_destroy_qp(struct ibv_qp *qp);
-int ibv_cmd_post_send(struct ibv_qp *ibqp, struct ibv_send_wr *wr,
- struct ibv_send_wr **bad_wr);
-int ibv_cmd_post_recv(struct ibv_qp *ibqp, struct ibv_recv_wr *wr,
- struct ibv_recv_wr **bad_wr);
-int ibv_cmd_post_srq_recv(struct ibv_srq *srq, struct ibv_recv_wr *wr,
- struct ibv_recv_wr **bad_wr);
-int ibv_cmd_create_ah(struct ibv_pd *pd, struct ibv_ah *ah,
- struct ibv_ah_attr *attr);
-int ibv_cmd_destroy_ah(struct ibv_ah *ah);
-int ibv_cmd_attach_mcast(struct ibv_qp *qp, const union ibv_gid *gid, uint16_t lid);
-int ibv_cmd_detach_mcast(struct ibv_qp *qp, const union ibv_gid *gid, uint16_t lid);
-
-int ibv_dontfork_range(void *base, size_t size);
-int ibv_dofork_range(void *base, size_t size);
-int ibv_cmd_open_xrc_domain(struct ibv_context *context, int fd, int oflag,
- struct ibv_xrc_domain *d,
- struct ibv_open_xrc_domain_resp *resp,
- size_t resp_size);
-int ibv_cmd_close_xrc_domain(struct ibv_xrc_domain *d);
-int ibv_cmd_create_xrc_rcv_qp(struct ibv_qp_init_attr *init_attr,
- uint32_t *xrc_rcv_qpn);
-int ibv_cmd_modify_xrc_rcv_qp(struct ibv_xrc_domain *d, uint32_t xrc_rcv_qpn,
- struct ibv_qp_attr *attr, int attr_mask);
-int ibv_cmd_query_xrc_rcv_qp(struct ibv_xrc_domain *d, uint32_t xrc_rcv_qpn,
- struct ibv_qp_attr *attr, int attr_mask,
- struct ibv_qp_init_attr *init_attr);
-int ibv_cmd_reg_xrc_rcv_qp(struct ibv_xrc_domain *xrc_domain,
- uint32_t xrc_qp_num);
-int ibv_cmd_unreg_xrc_rcv_qp(struct ibv_xrc_domain *xrc_domain,
- uint32_t xrc_qp_num);
-
-/*
- * sysfs helper functions
- */
-const char *ibv_get_sysfs_path(void);
-
-int ibv_read_sysfs_file(const char *dir, const char *file,
- char *buf, size_t size);
-
-int ibv_resolve_eth_gid(const struct ibv_pd *pd, uint8_t port_num,
- union ibv_gid *dgid, uint8_t sgid_index,
- uint8_t mac[], uint16_t *vlan, uint8_t *tagged,
- uint8_t *is_mcast);
-
-#endif /* INFINIBAND_DRIVER_H */
diff --git a/contrib/ofed/libibverbs/include/infiniband/kern-abi.h b/contrib/ofed/libibverbs/include/infiniband/kern-abi.h
deleted file mode 100644
index ee6f700..0000000
--- a/contrib/ofed/libibverbs/include/infiniband/kern-abi.h
+++ /dev/null
@@ -1,1024 +0,0 @@
-/*
- * Copyright (c) 2005 Topspin Communications. All rights reserved.
- * Copyright (c) 2005, 2006 Cisco Systems. All rights reserved.
- * Copyright (c) 2005 PathScale, Inc. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-#ifndef KERN_ABI_H
-#define KERN_ABI_H
-
-#include <infiniband/types.h>
-
-/*
- * This file must be kept in sync with the kernel's version of
- * drivers/infiniband/include/ib_user_verbs.h
- */
-
-/*
- * The minimum and maximum kernel ABI that we can handle.
- */
-#define IB_USER_VERBS_MIN_ABI_VERSION 1
-#define IB_USER_VERBS_MAX_ABI_VERSION 6
-
-enum {
- IB_USER_VERBS_CMD_GET_CONTEXT,
- IB_USER_VERBS_CMD_QUERY_DEVICE,
- IB_USER_VERBS_CMD_QUERY_PORT,
- IB_USER_VERBS_CMD_ALLOC_PD,
- IB_USER_VERBS_CMD_DEALLOC_PD,
- IB_USER_VERBS_CMD_CREATE_AH,
- IB_USER_VERBS_CMD_MODIFY_AH,
- IB_USER_VERBS_CMD_QUERY_AH,
- IB_USER_VERBS_CMD_DESTROY_AH,
- IB_USER_VERBS_CMD_REG_MR,
- IB_USER_VERBS_CMD_REG_SMR,
- IB_USER_VERBS_CMD_REREG_MR,
- IB_USER_VERBS_CMD_QUERY_MR,
- IB_USER_VERBS_CMD_DEREG_MR,
- IB_USER_VERBS_CMD_ALLOC_MW,
- IB_USER_VERBS_CMD_BIND_MW,
- IB_USER_VERBS_CMD_DEALLOC_MW,
- IB_USER_VERBS_CMD_CREATE_COMP_CHANNEL,
- IB_USER_VERBS_CMD_CREATE_CQ,
- IB_USER_VERBS_CMD_RESIZE_CQ,
- IB_USER_VERBS_CMD_DESTROY_CQ,
- IB_USER_VERBS_CMD_POLL_CQ,
- IB_USER_VERBS_CMD_PEEK_CQ,
- IB_USER_VERBS_CMD_REQ_NOTIFY_CQ,
- IB_USER_VERBS_CMD_CREATE_QP,
- IB_USER_VERBS_CMD_QUERY_QP,
- IB_USER_VERBS_CMD_MODIFY_QP,
- IB_USER_VERBS_CMD_DESTROY_QP,
- IB_USER_VERBS_CMD_POST_SEND,
- IB_USER_VERBS_CMD_POST_RECV,
- IB_USER_VERBS_CMD_ATTACH_MCAST,
- IB_USER_VERBS_CMD_DETACH_MCAST,
- IB_USER_VERBS_CMD_CREATE_SRQ,
- IB_USER_VERBS_CMD_MODIFY_SRQ,
- IB_USER_VERBS_CMD_QUERY_SRQ,
- IB_USER_VERBS_CMD_DESTROY_SRQ,
- IB_USER_VERBS_CMD_POST_SRQ_RECV,
- IB_USER_VERBS_CMD_CREATE_XRC_SRQ,
- IB_USER_VERBS_CMD_OPEN_XRC_DOMAIN,
- IB_USER_VERBS_CMD_CLOSE_XRC_DOMAIN,
- IB_USER_VERBS_CMD_CREATE_XRC_RCV_QP,
- IB_USER_VERBS_CMD_MODIFY_XRC_RCV_QP,
- IB_USER_VERBS_CMD_QUERY_XRC_RCV_QP,
- IB_USER_VERBS_CMD_REG_XRC_RCV_QP,
- IB_USER_VERBS_CMD_UNREG_XRC_RCV_QP,
-};
-
-/*
- * Make sure that all structs defined in this file remain laid out so
- * that they pack the same way on 32-bit and 64-bit architectures (to
- * avoid incompatibility between 32-bit userspace and 64-bit kernels).
- * Specifically:
- * - Do not use pointer types -- pass pointers in __u64 instead.
- * - Make sure that any structure larger than 4 bytes is padded to a
- * multiple of 8 bytes. Otherwise the structure size will be
- * different between 32-bit and 64-bit architectures.
- */
-
-struct ibv_kern_async_event {
- __u64 element;
- __u32 event_type;
- __u32 reserved;
-};
-
-struct ibv_comp_event {
- __u64 cq_handle;
-};
-
-/*
- * All commands from userspace should start with a __u32 command field
- * followed by __u16 in_words and out_words fields (which give the
- * length of the command block and response buffer if any in 32-bit
- * words). The kernel driver will read these fields first and read
- * the rest of the command struct based on these value.
- */
-
-struct ibv_query_params {
- __u32 command;
- __u16 in_words;
- __u16 out_words;
- __u64 response;
-};
-
-struct ibv_query_params_resp {
- __u32 num_cq_events;
-};
-
-struct ibv_get_context {
- __u32 command;
- __u16 in_words;
- __u16 out_words;
- __u64 response;
- __u64 driver_data[0];
-};
-
-struct ibv_get_context_resp {
- __u32 async_fd;
- __u32 num_comp_vectors;
-};
-
-struct ibv_query_device {
- __u32 command;
- __u16 in_words;
- __u16 out_words;
- __u64 response;
- __u64 driver_data[0];
-};
-
-struct ibv_query_device_resp {
- __u64 fw_ver;
- __u64 node_guid;
- __u64 sys_image_guid;
- __u64 max_mr_size;
- __u64 page_size_cap;
- __u32 vendor_id;
- __u32 vendor_part_id;
- __u32 hw_ver;
- __u32 max_qp;
- __u32 max_qp_wr;
- __u32 device_cap_flags;
- __u32 max_sge;
- __u32 max_sge_rd;
- __u32 max_cq;
- __u32 max_cqe;
- __u32 max_mr;
- __u32 max_pd;
- __u32 max_qp_rd_atom;
- __u32 max_ee_rd_atom;
- __u32 max_res_rd_atom;
- __u32 max_qp_init_rd_atom;
- __u32 max_ee_init_rd_atom;
- __u32 atomic_cap;
- __u32 max_ee;
- __u32 max_rdd;
- __u32 max_mw;
- __u32 max_raw_ipv6_qp;
- __u32 max_raw_ethy_qp;
- __u32 max_mcast_grp;
- __u32 max_mcast_qp_attach;
- __u32 max_total_mcast_qp_attach;
- __u32 max_ah;
- __u32 max_fmr;
- __u32 max_map_per_fmr;
- __u32 max_srq;
- __u32 max_srq_wr;
- __u32 max_srq_sge;
- __u16 max_pkeys;
- __u8 local_ca_ack_delay;
- __u8 phys_port_cnt;
- __u8 reserved[4];
-};
-
-struct ibv_query_port {
- __u32 command;
- __u16 in_words;
- __u16 out_words;
- __u64 response;
- __u8 port_num;
- __u8 reserved[7];
- __u64 driver_data[0];
-};
-
-struct ibv_query_port_resp {
- __u32 port_cap_flags;
- __u32 max_msg_sz;
- __u32 bad_pkey_cntr;
- __u32 qkey_viol_cntr;
- __u32 gid_tbl_len;
- __u16 pkey_tbl_len;
- __u16 lid;
- __u16 sm_lid;
- __u8 state;
- __u8 max_mtu;
- __u8 active_mtu;
- __u8 lmc;
- __u8 max_vl_num;
- __u8 sm_sl;
- __u8 subnet_timeout;
- __u8 init_type_reply;
- __u8 active_width;
- __u8 active_speed;
- __u8 phys_state;
- __u8 link_layer;
- __u8 reserved[2];
-};
-
-struct ibv_alloc_pd {
- __u32 command;
- __u16 in_words;
- __u16 out_words;
- __u64 response;
- __u64 driver_data[0];
-};
-
-struct ibv_alloc_pd_resp {
- __u32 pd_handle;
-};
-
-struct ibv_dealloc_pd {
- __u32 command;
- __u16 in_words;
- __u16 out_words;
- __u32 pd_handle;
-};
-
-struct ibv_reg_mr {
- __u32 command;
- __u16 in_words;
- __u16 out_words;
- __u64 response;
- __u64 start;
- __u64 length;
- __u64 hca_va;
- __u32 pd_handle;
- __u32 access_flags;
- __u64 driver_data[0];
-};
-
-struct ibv_reg_mr_resp {
- __u32 mr_handle;
- __u32 lkey;
- __u32 rkey;
-};
-
-struct ibv_dereg_mr {
- __u32 command;
- __u16 in_words;
- __u16 out_words;
- __u32 mr_handle;
-};
-
-struct ibv_create_comp_channel {
- __u32 command;
- __u16 in_words;
- __u16 out_words;
- __u64 response;
-};
-
-struct ibv_create_comp_channel_resp {
- __u32 fd;
-};
-
-struct ibv_create_cq {
- __u32 command;
- __u16 in_words;
- __u16 out_words;
- __u64 response;
- __u64 user_handle;
- __u32 cqe;
- __u32 comp_vector;
- __s32 comp_channel;
- __u32 reserved;
- __u64 driver_data[0];
-};
-
-struct ibv_create_cq_resp {
- __u32 cq_handle;
- __u32 cqe;
-};
-
-struct ibv_kern_wc {
- __u64 wr_id;
- __u32 status;
- __u32 opcode;
- __u32 vendor_err;
- __u32 byte_len;
- __u32 imm_data;
- __u32 qp_num;
- __u32 src_qp;
- __u32 wc_flags;
- __u16 pkey_index;
- __u16 slid;
- __u8 sl;
- __u8 dlid_path_bits;
- __u8 port_num;
- __u8 reserved;
-};
-
-struct ibv_poll_cq {
- __u32 command;
- __u16 in_words;
- __u16 out_words;
- __u64 response;
- __u32 cq_handle;
- __u32 ne;
-};
-
-struct ibv_poll_cq_resp {
- __u32 count;
- __u32 reserved;
- struct ibv_kern_wc wc[0];
-};
-
-struct ibv_req_notify_cq {
- __u32 command;
- __u16 in_words;
- __u16 out_words;
- __u32 cq_handle;
- __u32 solicited;
-};
-
-struct ibv_resize_cq {
- __u32 command;
- __u16 in_words;
- __u16 out_words;
- __u64 response;
- __u32 cq_handle;
- __u32 cqe;
- __u64 driver_data[0];
-};
-
-struct ibv_resize_cq_resp {
- __u32 cqe;
- __u32 reserved;
- __u64 driver_data[0];
-};
-
-struct ibv_destroy_cq {
- __u32 command;
- __u16 in_words;
- __u16 out_words;
- __u64 response;
- __u32 cq_handle;
- __u32 reserved;
-};
-
-struct ibv_destroy_cq_resp {
- __u32 comp_events_reported;
- __u32 async_events_reported;
-};
-
-struct ibv_kern_global_route {
- __u8 dgid[16];
- __u32 flow_label;
- __u8 sgid_index;
- __u8 hop_limit;
- __u8 traffic_class;
- __u8 reserved;
-};
-
-struct ibv_kern_ah_attr {
- struct ibv_kern_global_route grh;
- __u16 dlid;
- __u8 sl;
- __u8 src_path_bits;
- __u8 static_rate;
- __u8 is_global;
- __u8 port_num;
- __u8 reserved;
-};
-
-struct ibv_kern_qp_attr {
- __u32 qp_attr_mask;
- __u32 qp_state;
- __u32 cur_qp_state;
- __u32 path_mtu;
- __u32 path_mig_state;
- __u32 qkey;
- __u32 rq_psn;
- __u32 sq_psn;
- __u32 dest_qp_num;
- __u32 qp_access_flags;
-
- struct ibv_kern_ah_attr ah_attr;
- struct ibv_kern_ah_attr alt_ah_attr;
-
- /* ib_qp_cap */
- __u32 max_send_wr;
- __u32 max_recv_wr;
- __u32 max_send_sge;
- __u32 max_recv_sge;
- __u32 max_inline_data;
-
- __u16 pkey_index;
- __u16 alt_pkey_index;
- __u8 en_sqd_async_notify;
- __u8 sq_draining;
- __u8 max_rd_atomic;
- __u8 max_dest_rd_atomic;
- __u8 min_rnr_timer;
- __u8 port_num;
- __u8 timeout;
- __u8 retry_cnt;
- __u8 rnr_retry;
- __u8 alt_port_num;
- __u8 alt_timeout;
- __u8 reserved[5];
-};
-
-struct ibv_create_qp {
- __u32 command;
- __u16 in_words;
- __u16 out_words;
- __u64 response;
- __u64 user_handle;
- __u32 pd_handle;
- __u32 send_cq_handle;
- __u32 recv_cq_handle;
- __u32 srq_handle;
- __u32 max_send_wr;
- __u32 max_recv_wr;
- __u32 max_send_sge;
- __u32 max_recv_sge;
- __u32 max_inline_data;
- __u8 sq_sig_all;
- __u8 qp_type;
- __u8 is_srq;
- __u8 reserved;
- __u64 driver_data[0];
-};
-
-struct ibv_create_qp_resp {
- __u32 qp_handle;
- __u32 qpn;
- __u32 max_send_wr;
- __u32 max_recv_wr;
- __u32 max_send_sge;
- __u32 max_recv_sge;
- __u32 max_inline_data;
- __u32 reserved;
-};
-
-struct ibv_qp_dest {
- __u8 dgid[16];
- __u32 flow_label;
- __u16 dlid;
- __u16 reserved;
- __u8 sgid_index;
- __u8 hop_limit;
- __u8 traffic_class;
- __u8 sl;
- __u8 src_path_bits;
- __u8 static_rate;
- __u8 is_global;
- __u8 port_num;
-};
-
-struct ibv_query_qp {
- __u32 command;
- __u16 in_words;
- __u16 out_words;
- __u64 response;
- __u32 qp_handle;
- __u32 attr_mask;
- __u64 driver_data[0];
-};
-
-struct ibv_query_qp_resp {
- struct ibv_qp_dest dest;
- struct ibv_qp_dest alt_dest;
- __u32 max_send_wr;
- __u32 max_recv_wr;
- __u32 max_send_sge;
- __u32 max_recv_sge;
- __u32 max_inline_data;
- __u32 qkey;
- __u32 rq_psn;
- __u32 sq_psn;
- __u32 dest_qp_num;
- __u32 qp_access_flags;
- __u16 pkey_index;
- __u16 alt_pkey_index;
- __u8 qp_state;
- __u8 cur_qp_state;
- __u8 path_mtu;
- __u8 path_mig_state;
- __u8 sq_draining;
- __u8 max_rd_atomic;
- __u8 max_dest_rd_atomic;
- __u8 min_rnr_timer;
- __u8 port_num;
- __u8 timeout;
- __u8 retry_cnt;
- __u8 rnr_retry;
- __u8 alt_port_num;
- __u8 alt_timeout;
- __u8 sq_sig_all;
- __u8 reserved[5];
- __u64 driver_data[0];
-};
-
-struct ibv_modify_qp {
- __u32 command;
- __u16 in_words;
- __u16 out_words;
- struct ibv_qp_dest dest;
- struct ibv_qp_dest alt_dest;
- __u32 qp_handle;
- __u32 attr_mask;
- __u32 qkey;
- __u32 rq_psn;
- __u32 sq_psn;
- __u32 dest_qp_num;
- __u32 qp_access_flags;
- __u16 pkey_index;
- __u16 alt_pkey_index;
- __u8 qp_state;
- __u8 cur_qp_state;
- __u8 path_mtu;
- __u8 path_mig_state;
- __u8 en_sqd_async_notify;
- __u8 max_rd_atomic;
- __u8 max_dest_rd_atomic;
- __u8 min_rnr_timer;
- __u8 port_num;
- __u8 timeout;
- __u8 retry_cnt;
- __u8 rnr_retry;
- __u8 alt_port_num;
- __u8 alt_timeout;
- __u8 reserved[2];
- __u64 driver_data[0];
-};
-
-struct ibv_destroy_qp {
- __u32 command;
- __u16 in_words;
- __u16 out_words;
- __u64 response;
- __u32 qp_handle;
- __u32 reserved;
-};
-
-struct ibv_destroy_qp_resp {
- __u32 events_reported;
-};
-
-struct ibv_create_xrc_rcv_qp {
- __u32 command;
- __u16 in_words;
- __u16 out_words;
- __u64 response;
- __u64 user_handle;
- __u32 xrc_domain_handle;
- __u32 max_send_wr;
- __u32 max_recv_wr;
- __u32 max_send_sge;
- __u32 max_recv_sge;
- __u32 max_inline_data;
- __u8 sq_sig_all;
- __u8 qp_type;
- __u8 reserved[6];
- __u64 driver_data[0];
-};
-
-struct ibv_create_xrc_rcv_qp_resp {
- __u32 qpn;
- __u32 reserved;
-};
-
-struct ibv_modify_xrc_rcv_qp {
- __u32 command;
- __u16 in_words;
- __u16 out_words;
- __u32 xrc_domain_handle;
- __u32 qp_num;
- struct ibv_qp_dest dest;
- struct ibv_qp_dest alt_dest;
- __u32 attr_mask;
- __u32 qkey;
- __u32 rq_psn;
- __u32 sq_psn;
- __u32 dest_qp_num;
- __u32 qp_access_flags;
- __u16 pkey_index;
- __u16 alt_pkey_index;
- __u8 qp_state;
- __u8 cur_qp_state;
- __u8 path_mtu;
- __u8 path_mig_state;
- __u8 en_sqd_async_notify;
- __u8 max_rd_atomic;
- __u8 max_dest_rd_atomic;
- __u8 min_rnr_timer;
- __u8 port_num;
- __u8 timeout;
- __u8 retry_cnt;
- __u8 rnr_retry;
- __u8 alt_port_num;
- __u8 alt_timeout;
- __u8 reserved[6];
- __u64 driver_data[0];
-};
-
-struct ibv_query_xrc_rcv_qp {
- __u32 command;
- __u16 in_words;
- __u16 out_words;
- __u64 response;
- __u32 xrc_domain_handle;
- __u32 qp_num;
- __u32 attr_mask;
- __u32 reserved;
- __u64 driver_data[0];
-};
-
-struct ibv_reg_xrc_rcv_qp {
- __u32 command;
- __u16 in_words;
- __u16 out_words;
- __u32 xrc_domain_handle;
- __u32 qp_num;
- __u64 driver_data[0];
-};
-
-struct ibv_unreg_xrc_rcv_qp {
- __u32 command;
- __u16 in_words;
- __u16 out_words;
- __u32 xrc_domain_handle;
- __u32 qp_num;
- __u64 driver_data[0];
-};
-
-struct ibv_kern_send_wr {
- __u64 wr_id;
- __u32 num_sge;
- __u32 opcode;
- __u32 send_flags;
- __u32 imm_data;
- union {
- struct {
- __u64 remote_addr;
- __u32 rkey;
- __u32 reserved;
- } rdma;
- struct {
- __u64 remote_addr;
- __u64 compare_add;
- __u64 swap;
- __u32 rkey;
- __u32 reserved;
- } atomic;
- struct {
- __u32 ah;
- __u32 remote_qpn;
- __u32 remote_qkey;
- __u32 reserved;
- } ud;
- } wr;
-};
-
-struct ibv_post_send {
- __u32 command;
- __u16 in_words;
- __u16 out_words;
- __u64 response;
- __u32 qp_handle;
- __u32 wr_count;
- __u32 sge_count;
- __u32 wqe_size;
- struct ibv_kern_send_wr send_wr[0];
-};
-
-struct ibv_post_send_resp {
- __u32 bad_wr;
-};
-
-struct ibv_kern_recv_wr {
- __u64 wr_id;
- __u32 num_sge;
- __u32 reserved;
-};
-
-struct ibv_post_recv {
- __u32 command;
- __u16 in_words;
- __u16 out_words;
- __u64 response;
- __u32 qp_handle;
- __u32 wr_count;
- __u32 sge_count;
- __u32 wqe_size;
- struct ibv_kern_recv_wr recv_wr[0];
-};
-
-struct ibv_post_recv_resp {
- __u32 bad_wr;
-};
-
-struct ibv_post_srq_recv {
- __u32 command;
- __u16 in_words;
- __u16 out_words;
- __u64 response;
- __u32 srq_handle;
- __u32 wr_count;
- __u32 sge_count;
- __u32 wqe_size;
- struct ibv_kern_recv_wr recv_wr[0];
-};
-
-struct ibv_post_srq_recv_resp {
- __u32 bad_wr;
-};
-
-struct ibv_create_ah {
- __u32 command;
- __u16 in_words;
- __u16 out_words;
- __u64 response;
- __u64 user_handle;
- __u32 pd_handle;
- __u32 reserved;
- struct ibv_kern_ah_attr attr;
-};
-
-struct ibv_create_ah_resp {
- __u32 handle;
-};
-
-struct ibv_destroy_ah {
- __u32 command;
- __u16 in_words;
- __u16 out_words;
- __u32 ah_handle;
-};
-
-struct ibv_attach_mcast {
- __u32 command;
- __u16 in_words;
- __u16 out_words;
- __u8 gid[16];
- __u32 qp_handle;
- __u16 mlid;
- __u16 reserved;
- __u64 driver_data[0];
-};
-
-struct ibv_detach_mcast {
- __u32 command;
- __u16 in_words;
- __u16 out_words;
- __u8 gid[16];
- __u32 qp_handle;
- __u16 mlid;
- __u16 reserved;
- __u64 driver_data[0];
-};
-
-struct ibv_create_srq {
- __u32 command;
- __u16 in_words;
- __u16 out_words;
- __u64 response;
- __u64 user_handle;
- __u32 pd_handle;
- __u32 max_wr;
- __u32 max_sge;
- __u32 srq_limit;
- __u64 driver_data[0];
-};
-
-struct ibv_create_xrc_srq {
- __u32 command;
- __u16 in_words;
- __u16 out_words;
- __u64 response;
- __u64 user_handle;
- __u32 pd_handle;
- __u32 max_wr;
- __u32 max_sge;
- __u32 srq_limit;
- __u32 xrcd_handle;
- __u32 xrc_cq;
- __u64 driver_data[0];
-};
-
-struct ibv_create_srq_resp {
- __u32 srq_handle;
- __u32 max_wr;
- __u32 max_sge;
- __u32 reserved;
-};
-
-struct ibv_modify_srq {
- __u32 command;
- __u16 in_words;
- __u16 out_words;
- __u32 srq_handle;
- __u32 attr_mask;
- __u32 max_wr;
- __u32 srq_limit;
- __u64 driver_data[0];
-};
-
-struct ibv_query_srq {
- __u32 command;
- __u16 in_words;
- __u16 out_words;
- __u64 response;
- __u32 srq_handle;
- __u32 reserved;
- __u64 driver_data[0];
-};
-
-struct ibv_query_srq_resp {
- __u32 max_wr;
- __u32 max_sge;
- __u32 srq_limit;
- __u32 reserved;
-};
-
-struct ibv_destroy_srq {
- __u32 command;
- __u16 in_words;
- __u16 out_words;
- __u64 response;
- __u32 srq_handle;
- __u32 reserved;
-};
-
-struct ibv_destroy_srq_resp {
- __u32 events_reported;
-};
-
-struct ibv_open_xrc_domain {
- __u32 command;
- __u16 in_words;
- __u16 out_words;
- __u64 response;
- __u32 fd;
- __u32 oflags;
- __u64 driver_data[0];
-};
-
-struct ibv_open_xrc_domain_resp {
- __u32 xrcd_handle;
-};
-
-struct ibv_close_xrc_domain {
- __u32 command;
- __u16 in_words;
- __u16 out_words;
- __u64 response;
- __u32 xrcd_handle;
- __u32 reserved;
- __u64 driver_data[0];
-};
-
-/*
- * Compatibility with older ABI versions
- */
-
-enum {
- IB_USER_VERBS_CMD_QUERY_PARAMS_V2,
- IB_USER_VERBS_CMD_GET_CONTEXT_V2,
- IB_USER_VERBS_CMD_QUERY_DEVICE_V2,
- IB_USER_VERBS_CMD_QUERY_PORT_V2,
- IB_USER_VERBS_CMD_QUERY_GID_V2,
- IB_USER_VERBS_CMD_QUERY_PKEY_V2,
- IB_USER_VERBS_CMD_ALLOC_PD_V2,
- IB_USER_VERBS_CMD_DEALLOC_PD_V2,
- IB_USER_VERBS_CMD_CREATE_AH_V2,
- IB_USER_VERBS_CMD_MODIFY_AH_V2,
- IB_USER_VERBS_CMD_QUERY_AH_V2,
- IB_USER_VERBS_CMD_DESTROY_AH_V2,
- IB_USER_VERBS_CMD_REG_MR_V2,
- IB_USER_VERBS_CMD_REG_SMR_V2,
- IB_USER_VERBS_CMD_REREG_MR_V2,
- IB_USER_VERBS_CMD_QUERY_MR_V2,
- IB_USER_VERBS_CMD_DEREG_MR_V2,
- IB_USER_VERBS_CMD_ALLOC_MW_V2,
- IB_USER_VERBS_CMD_BIND_MW_V2,
- IB_USER_VERBS_CMD_DEALLOC_MW_V2,
- IB_USER_VERBS_CMD_CREATE_CQ_V2,
- IB_USER_VERBS_CMD_RESIZE_CQ_V2,
- IB_USER_VERBS_CMD_DESTROY_CQ_V2,
- IB_USER_VERBS_CMD_POLL_CQ_V2,
- IB_USER_VERBS_CMD_PEEK_CQ_V2,
- IB_USER_VERBS_CMD_REQ_NOTIFY_CQ_V2,
- IB_USER_VERBS_CMD_CREATE_QP_V2,
- IB_USER_VERBS_CMD_QUERY_QP_V2,
- IB_USER_VERBS_CMD_MODIFY_QP_V2,
- IB_USER_VERBS_CMD_DESTROY_QP_V2,
- IB_USER_VERBS_CMD_POST_SEND_V2,
- IB_USER_VERBS_CMD_POST_RECV_V2,
- IB_USER_VERBS_CMD_ATTACH_MCAST_V2,
- IB_USER_VERBS_CMD_DETACH_MCAST_V2,
- IB_USER_VERBS_CMD_CREATE_SRQ_V2,
- IB_USER_VERBS_CMD_MODIFY_SRQ_V2,
- IB_USER_VERBS_CMD_QUERY_SRQ_V2,
- IB_USER_VERBS_CMD_DESTROY_SRQ_V2,
- IB_USER_VERBS_CMD_POST_SRQ_RECV_V2,
- /*
- * Set commands that didn't exist to -1 so our compile-time
- * trick opcodes in IBV_INIT_CMD() doesn't break.
- */
- IB_USER_VERBS_CMD_CREATE_COMP_CHANNEL_V2 = -1,
- IB_USER_VERBS_CMD_CREATE_XRC_SRQ_V2 = -1,
- IB_USER_VERBS_CMD_OPEN_XRC_DOMAIN_V2 = -1,
- IB_USER_VERBS_CMD_CLOSE_XRC_DOMAIN_V2 = -1,
- IB_USER_VERBS_CMD_CREATE_XRC_RCV_QP_V2 = -1,
- IB_USER_VERBS_CMD_MODIFY_XRC_RCV_QP_V2 = -1,
- IB_USER_VERBS_CMD_QUERY_XRC_RCV_QP_V2 = -1,
- IB_USER_VERBS_CMD_REG_XRC_RCV_QP_V2 = -1,
- IB_USER_VERBS_CMD_UNREG_XRC_RCV_QP_V2 = -1,
-};
-
-struct ibv_destroy_cq_v1 {
- __u32 command;
- __u16 in_words;
- __u16 out_words;
- __u32 cq_handle;
-};
-
-struct ibv_destroy_qp_v1 {
- __u32 command;
- __u16 in_words;
- __u16 out_words;
- __u32 qp_handle;
-};
-
-struct ibv_destroy_srq_v1 {
- __u32 command;
- __u16 in_words;
- __u16 out_words;
- __u32 srq_handle;
-};
-
-struct ibv_get_context_v2 {
- __u32 command;
- __u16 in_words;
- __u16 out_words;
- __u64 response;
- __u64 cq_fd_tab;
- __u64 driver_data[0];
-};
-
-struct ibv_create_cq_v2 {
- __u32 command;
- __u16 in_words;
- __u16 out_words;
- __u64 response;
- __u64 user_handle;
- __u32 cqe;
- __u32 event_handler;
- __u64 driver_data[0];
-};
-
-struct ibv_modify_srq_v3 {
- __u32 command;
- __u16 in_words;
- __u16 out_words;
- __u32 srq_handle;
- __u32 attr_mask;
- __u32 max_wr;
- __u32 max_sge;
- __u32 srq_limit;
- __u32 reserved;
- __u64 driver_data[0];
-};
-
-struct ibv_create_qp_resp_v3 {
- __u32 qp_handle;
- __u32 qpn;
-};
-
-struct ibv_create_qp_resp_v4 {
- __u32 qp_handle;
- __u32 qpn;
- __u32 max_send_wr;
- __u32 max_recv_wr;
- __u32 max_send_sge;
- __u32 max_recv_sge;
- __u32 max_inline_data;
-};
-
-struct ibv_create_srq_resp_v5 {
- __u32 srq_handle;
-};
-
-#endif /* KERN_ABI_H */
diff --git a/contrib/ofed/libibverbs/include/infiniband/marshall.h b/contrib/ofed/libibverbs/include/infiniband/marshall.h
deleted file mode 100644
index 8be76c5..0000000
--- a/contrib/ofed/libibverbs/include/infiniband/marshall.h
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * Copyright (c) 2005 Intel Corporation. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-#ifndef INFINIBAND_MARSHALL_H
-#define INFINIBAND_MARSHALL_H
-
-#include <infiniband/verbs.h>
-#include <infiniband/sa.h>
-#include <infiniband/kern-abi.h>
-#include <infiniband/sa-kern-abi.h>
-
-#ifdef __cplusplus
-# define BEGIN_C_DECLS extern "C" {
-# define END_C_DECLS }
-#else /* !__cplusplus */
-# define BEGIN_C_DECLS
-# define END_C_DECLS
-#endif /* __cplusplus */
-
-BEGIN_C_DECLS
-
-void ibv_copy_qp_attr_from_kern(struct ibv_qp_attr *dst,
- struct ibv_kern_qp_attr *src);
-
-void ibv_copy_ah_attr_from_kern(struct ibv_ah_attr *dst,
- struct ibv_kern_ah_attr *src);
-
-void ibv_copy_path_rec_from_kern(struct ibv_sa_path_rec *dst,
- struct ibv_kern_path_rec *src);
-
-void ibv_copy_path_rec_to_kern(struct ibv_kern_path_rec *dst,
- struct ibv_sa_path_rec *src);
-
-END_C_DECLS
-
-#endif /* INFINIBAND_MARSHALL_H */
diff --git a/contrib/ofed/libibverbs/include/infiniband/sa-kern-abi.h b/contrib/ofed/libibverbs/include/infiniband/sa-kern-abi.h
deleted file mode 100644
index 3faa52a..0000000
--- a/contrib/ofed/libibverbs/include/infiniband/sa-kern-abi.h
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * Copyright (c) 2005 Intel Corporation. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-#ifndef INFINIBAND_SA_KERN_ABI_H
-#define INFINIBAND_SA_KERN_ABI_H
-
-#include <infiniband/types.h>
-
-/*
- * Obsolete, deprecated names. Will be removed in libibverbs 1.1.
- */
-#define ib_kern_path_rec ibv_kern_path_rec
-
-struct ibv_kern_path_rec {
- __u8 dgid[16];
- __u8 sgid[16];
- __u16 dlid;
- __u16 slid;
- __u32 raw_traffic;
- __u32 flow_label;
- __u32 reversible;
- __u32 mtu;
- __u16 pkey;
- __u8 hop_limit;
- __u8 traffic_class;
- __u8 numb_path;
- __u8 sl;
- __u8 mtu_selector;
- __u8 rate_selector;
- __u8 rate;
- __u8 packet_life_time_selector;
- __u8 packet_life_time;
- __u8 preference;
-};
-
-#endif /* INFINIBAND_SA_KERN_ABI_H */
diff --git a/contrib/ofed/libibverbs/include/infiniband/sa.h b/contrib/ofed/libibverbs/include/infiniband/sa.h
deleted file mode 100644
index 1153e94..0000000
--- a/contrib/ofed/libibverbs/include/infiniband/sa.h
+++ /dev/null
@@ -1,135 +0,0 @@
-/*
- * Copyright (c) 2004 Topspin Communications. All rights reserved.
- * Copyright (c) 2005 Voltaire, Inc. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-#ifndef INFINIBAND_SA_H
-#define INFINIBAND_SA_H
-
-#include <infiniband/verbs.h>
-
-struct ibv_sa_path_rec {
- /* reserved */
- /* reserved */
- union ibv_gid dgid;
- union ibv_gid sgid;
- uint16_t dlid;
- uint16_t slid;
- int raw_traffic;
- /* reserved */
- uint32_t flow_label;
- uint8_t hop_limit;
- uint8_t traffic_class;
- int reversible;
- uint8_t numb_path;
- uint16_t pkey;
- /* reserved */
- uint8_t sl;
- uint8_t mtu_selector;
- uint8_t mtu;
- uint8_t rate_selector;
- uint8_t rate;
- uint8_t packet_life_time_selector;
- uint8_t packet_life_time;
- uint8_t preference;
-};
-
-struct ibv_sa_mcmember_rec {
- union ibv_gid mgid;
- union ibv_gid port_gid;
- uint32_t qkey;
- uint16_t mlid;
- uint8_t mtu_selector;
- uint8_t mtu;
- uint8_t traffic_class;
- uint16_t pkey;
- uint8_t rate_selector;
- uint8_t rate;
- uint8_t packet_life_time_selector;
- uint8_t packet_life_time;
- uint8_t sl;
- uint32_t flow_label;
- uint8_t hop_limit;
- uint8_t scope;
- uint8_t join_state;
- int proxy_join;
-};
-
-struct ibv_sa_service_rec {
- uint64_t id;
- union ibv_gid gid;
- uint16_t pkey;
- /* uint16_t resv; */
- uint32_t lease;
- uint8_t key[16];
- uint8_t name[64];
- uint8_t data8[16];
- uint16_t data16[8];
- uint32_t data32[4];
- uint64_t data64[2];
-};
-
-#define IBV_PATH_RECORD_REVERSIBLE 0x80
-
-struct ibv_path_record {
- uint64_t service_id;
- union ibv_gid dgid;
- union ibv_gid sgid;
- uint16_t dlid;
- uint16_t slid;
- uint32_t flowlabel_hoplimit; /* resv-31:28 flow label-27:8 hop limit-7:0*/
- uint8_t tclass;
- uint8_t reversible_numpath; /* reversible-7:7 num path-6:0 */
- uint16_t pkey;
- uint16_t qosclass_sl; /* qos class-15:4 sl-3:0 */
- uint8_t mtu; /* mtu selector-7:6 mtu-5:0 */
- uint8_t rate; /* rate selector-7:6 rate-5:0 */
- uint8_t packetlifetime; /* lifetime selector-7:6 lifetime-5:0 */
- uint8_t preference;
- uint8_t reserved[6];
-};
-
-#define IBV_PATH_FLAG_GMP (1<<0)
-#define IBV_PATH_FLAG_PRIMARY (1<<1)
-#define IBV_PATH_FLAG_ALTERNATE (1<<2)
-#define IBV_PATH_FLAG_OUTBOUND (1<<3)
-#define IBV_PATH_FLAG_INBOUND (1<<4)
-#define IBV_PATH_FLAG_INBOUND_REVERSE (1<<5)
-#define IBV_PATH_FLAG_BIDIRECTIONAL (IBV_PATH_FLAG_OUTBOUND | \
- IBV_PATH_FLAG_INBOUND_REVERSE)
-
-struct ibv_path_data {
- uint32_t flags;
- uint32_t reserved;
- struct ibv_path_record path;
-};
-
-#endif /* INFINIBAND_SA_H */
diff --git a/contrib/ofed/libibverbs/include/infiniband/verbs.h b/contrib/ofed/libibverbs/include/infiniband/verbs.h
deleted file mode 100644
index 929e400..0000000
--- a/contrib/ofed/libibverbs/include/infiniband/verbs.h
+++ /dev/null
@@ -1,1330 +0,0 @@
-/*
- * Copyright (c) 2004, 2005 Topspin Communications. All rights reserved.
- * Copyright (c) 2004 Intel Corporation. All rights reserved.
- * Copyright (c) 2005, 2006, 2007 Cisco Systems, Inc. All rights reserved.
- * Copyright (c) 2005 PathScale, Inc. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-#ifndef INFINIBAND_VERBS_H
-#define INFINIBAND_VERBS_H
-
-#include <stdint.h>
-#include <pthread.h>
-
-#ifdef __cplusplus
-# define BEGIN_C_DECLS extern "C" {
-# define END_C_DECLS }
-#else /* !__cplusplus */
-# define BEGIN_C_DECLS
-# define END_C_DECLS
-#endif /* __cplusplus */
-
-#if __GNUC__ >= 3
-# define __attribute_const __attribute__((const))
-#else
-# define __attribute_const
-#endif
-
-BEGIN_C_DECLS
-
-union ibv_gid {
- uint8_t raw[16];
- struct {
- uint64_t subnet_prefix;
- uint64_t interface_id;
- } global;
-};
-
-enum ibv_node_type {
- IBV_NODE_UNKNOWN = -1,
- IBV_NODE_CA = 1,
- IBV_NODE_SWITCH,
- IBV_NODE_ROUTER,
- IBV_NODE_RNIC
-};
-
-enum ibv_transport_type {
- IBV_TRANSPORT_UNKNOWN = -1,
- IBV_TRANSPORT_IB = 0,
- IBV_TRANSPORT_IWARP
-};
-
-enum ibv_device_cap_flags {
- IBV_DEVICE_RESIZE_MAX_WR = 1,
- IBV_DEVICE_BAD_PKEY_CNTR = 1 << 1,
- IBV_DEVICE_BAD_QKEY_CNTR = 1 << 2,
- IBV_DEVICE_RAW_MULTI = 1 << 3,
- IBV_DEVICE_AUTO_PATH_MIG = 1 << 4,
- IBV_DEVICE_CHANGE_PHY_PORT = 1 << 5,
- IBV_DEVICE_UD_AV_PORT_ENFORCE = 1 << 6,
- IBV_DEVICE_CURR_QP_STATE_MOD = 1 << 7,
- IBV_DEVICE_SHUTDOWN_PORT = 1 << 8,
- IBV_DEVICE_INIT_TYPE = 1 << 9,
- IBV_DEVICE_PORT_ACTIVE_EVENT = 1 << 10,
- IBV_DEVICE_SYS_IMAGE_GUID = 1 << 11,
- IBV_DEVICE_RC_RNR_NAK_GEN = 1 << 12,
- IBV_DEVICE_SRQ_RESIZE = 1 << 13,
- IBV_DEVICE_N_NOTIFY_CQ = 1 << 14,
- IBV_DEVICE_XRC = 1 << 20
-};
-
-enum ibv_atomic_cap {
- IBV_ATOMIC_NONE,
- IBV_ATOMIC_HCA,
- IBV_ATOMIC_GLOB
-};
-
-struct ibv_device_attr {
- char fw_ver[64];
- uint64_t node_guid;
- uint64_t sys_image_guid;
- uint64_t max_mr_size;
- uint64_t page_size_cap;
- uint32_t vendor_id;
- uint32_t vendor_part_id;
- uint32_t hw_ver;
- int max_qp;
- int max_qp_wr;
- int device_cap_flags;
- int max_sge;
- int max_sge_rd;
- int max_cq;
- int max_cqe;
- int max_mr;
- int max_pd;
- int max_qp_rd_atom;
- int max_ee_rd_atom;
- int max_res_rd_atom;
- int max_qp_init_rd_atom;
- int max_ee_init_rd_atom;
- enum ibv_atomic_cap atomic_cap;
- int max_ee;
- int max_rdd;
- int max_mw;
- int max_raw_ipv6_qp;
- int max_raw_ethy_qp;
- int max_mcast_grp;
- int max_mcast_qp_attach;
- int max_total_mcast_qp_attach;
- int max_ah;
- int max_fmr;
- int max_map_per_fmr;
- int max_srq;
- int max_srq_wr;
- int max_srq_sge;
- uint16_t max_pkeys;
- uint8_t local_ca_ack_delay;
- uint8_t phys_port_cnt;
-};
-
-enum ibv_mtu {
- IBV_MTU_256 = 1,
- IBV_MTU_512 = 2,
- IBV_MTU_1024 = 3,
- IBV_MTU_2048 = 4,
- IBV_MTU_4096 = 5
-};
-
-enum ibv_port_state {
- IBV_PORT_NOP = 0,
- IBV_PORT_DOWN = 1,
- IBV_PORT_INIT = 2,
- IBV_PORT_ARMED = 3,
- IBV_PORT_ACTIVE = 4,
- IBV_PORT_ACTIVE_DEFER = 5
-};
-
-enum {
- IBV_LINK_LAYER_UNSPECIFIED,
- IBV_LINK_LAYER_INFINIBAND,
- IBV_LINK_LAYER_ETHERNET,
-};
-
-struct ibv_port_attr {
- enum ibv_port_state state;
- enum ibv_mtu max_mtu;
- enum ibv_mtu active_mtu;
- int gid_tbl_len;
- uint32_t port_cap_flags;
- uint32_t max_msg_sz;
- uint32_t bad_pkey_cntr;
- uint32_t qkey_viol_cntr;
- uint16_t pkey_tbl_len;
- uint16_t lid;
- uint16_t sm_lid;
- uint8_t lmc;
- uint8_t max_vl_num;
- uint8_t sm_sl;
- uint8_t subnet_timeout;
- uint8_t init_type_reply;
- uint8_t active_width;
- uint8_t active_speed;
- uint8_t phys_state;
- uint8_t link_layer;
- uint8_t pad;
-};
-
-enum ibv_event_type {
- IBV_EVENT_CQ_ERR,
- IBV_EVENT_QP_FATAL,
- IBV_EVENT_QP_REQ_ERR,
- IBV_EVENT_QP_ACCESS_ERR,
- IBV_EVENT_COMM_EST,
- IBV_EVENT_SQ_DRAINED,
- IBV_EVENT_PATH_MIG,
- IBV_EVENT_PATH_MIG_ERR,
- IBV_EVENT_DEVICE_FATAL,
- IBV_EVENT_PORT_ACTIVE,
- IBV_EVENT_PORT_ERR,
- IBV_EVENT_LID_CHANGE,
- IBV_EVENT_PKEY_CHANGE,
- IBV_EVENT_SM_CHANGE,
- IBV_EVENT_SRQ_ERR,
- IBV_EVENT_SRQ_LIMIT_REACHED,
- IBV_EVENT_QP_LAST_WQE_REACHED,
- IBV_EVENT_CLIENT_REREGISTER,
- IBV_EVENT_GID_CHANGE,
-};
-
-enum ibv_event_flags {
- IBV_XRC_QP_EVENT_FLAG = 0x80000000,
-};
-
-struct ibv_async_event {
- union {
- struct ibv_cq *cq;
- struct ibv_qp *qp;
- struct ibv_srq *srq;
- int port_num;
- uint32_t xrc_qp_num;
- } element;
- enum ibv_event_type event_type;
-};
-
-enum ibv_wc_status {
- IBV_WC_SUCCESS,
- IBV_WC_LOC_LEN_ERR,
- IBV_WC_LOC_QP_OP_ERR,
- IBV_WC_LOC_EEC_OP_ERR,
- IBV_WC_LOC_PROT_ERR,
- IBV_WC_WR_FLUSH_ERR,
- IBV_WC_MW_BIND_ERR,
- IBV_WC_BAD_RESP_ERR,
- IBV_WC_LOC_ACCESS_ERR,
- IBV_WC_REM_INV_REQ_ERR,
- IBV_WC_REM_ACCESS_ERR,
- IBV_WC_REM_OP_ERR,
- IBV_WC_RETRY_EXC_ERR,
- IBV_WC_RNR_RETRY_EXC_ERR,
- IBV_WC_LOC_RDD_VIOL_ERR,
- IBV_WC_REM_INV_RD_REQ_ERR,
- IBV_WC_REM_ABORT_ERR,
- IBV_WC_INV_EECN_ERR,
- IBV_WC_INV_EEC_STATE_ERR,
- IBV_WC_FATAL_ERR,
- IBV_WC_RESP_TIMEOUT_ERR,
- IBV_WC_GENERAL_ERR
-};
-const char *ibv_wc_status_str(enum ibv_wc_status status);
-
-enum ibv_wc_opcode {
- IBV_WC_SEND,
- IBV_WC_RDMA_WRITE,
- IBV_WC_RDMA_READ,
- IBV_WC_COMP_SWAP,
- IBV_WC_FETCH_ADD,
- IBV_WC_BIND_MW,
-/*
- * Set value of IBV_WC_RECV so consumers can test if a completion is a
- * receive by testing (opcode & IBV_WC_RECV).
- */
- IBV_WC_RECV = 1 << 7,
- IBV_WC_RECV_RDMA_WITH_IMM
-};
-
-enum ibv_wc_flags {
- IBV_WC_GRH = 1 << 0,
- IBV_WC_WITH_IMM = 1 << 1
-};
-
-struct ibv_wc {
- uint64_t wr_id;
- enum ibv_wc_status status;
- enum ibv_wc_opcode opcode;
- uint32_t vendor_err;
- uint32_t byte_len;
- uint32_t imm_data; /* in network byte order */
- uint32_t qp_num;
- uint32_t src_qp;
- int wc_flags;
- uint16_t pkey_index;
- uint16_t slid;
- uint8_t sl;
- uint8_t dlid_path_bits;
-};
-
-enum ibv_access_flags {
- IBV_ACCESS_LOCAL_WRITE = 1,
- IBV_ACCESS_REMOTE_WRITE = (1<<1),
- IBV_ACCESS_REMOTE_READ = (1<<2),
- IBV_ACCESS_REMOTE_ATOMIC = (1<<3),
- IBV_ACCESS_MW_BIND = (1<<4)
-};
-
-struct ibv_pd {
- struct ibv_context *context;
- uint32_t handle;
-};
-
-enum ibv_rereg_mr_flags {
- IBV_REREG_MR_CHANGE_TRANSLATION = (1 << 0),
- IBV_REREG_MR_CHANGE_PD = (1 << 1),
- IBV_REREG_MR_CHANGE_ACCESS = (1 << 2),
- IBV_REREG_MR_KEEP_VALID = (1 << 3)
-};
-
-struct ibv_mr {
- struct ibv_context *context;
- struct ibv_pd *pd;
- void *addr;
- size_t length;
- uint32_t handle;
- uint32_t lkey;
- uint32_t rkey;
-};
-
-enum ibv_mw_type {
- IBV_MW_TYPE_1 = 1,
- IBV_MW_TYPE_2 = 2
-};
-
-struct ibv_mw {
- struct ibv_context *context;
- struct ibv_pd *pd;
- uint32_t rkey;
-};
-
-struct ibv_global_route {
- union ibv_gid dgid;
- uint32_t flow_label;
- uint8_t sgid_index;
- uint8_t hop_limit;
- uint8_t traffic_class;
-};
-
-struct ibv_grh {
- uint32_t version_tclass_flow;
- uint16_t paylen;
- uint8_t next_hdr;
- uint8_t hop_limit;
- union ibv_gid sgid;
- union ibv_gid dgid;
-};
-
-enum ibv_rate {
- IBV_RATE_MAX = 0,
- IBV_RATE_2_5_GBPS = 2,
- IBV_RATE_5_GBPS = 5,
- IBV_RATE_10_GBPS = 3,
- IBV_RATE_20_GBPS = 6,
- IBV_RATE_30_GBPS = 4,
- IBV_RATE_40_GBPS = 7,
- IBV_RATE_60_GBPS = 8,
- IBV_RATE_80_GBPS = 9,
- IBV_RATE_120_GBPS = 10
-};
-
-/**
- * ibv_rate_to_mult - Convert the IB rate enum to a multiple of the
- * base rate of 2.5 Gbit/sec. For example, IBV_RATE_5_GBPS will be
- * converted to 2, since 5 Gbit/sec is 2 * 2.5 Gbit/sec.
- * @rate: rate to convert.
- */
-int ibv_rate_to_mult(enum ibv_rate rate) __attribute_const;
-
-/**
- * mult_to_ibv_rate - Convert a multiple of 2.5 Gbit/sec to an IB rate enum.
- * @mult: multiple to convert.
- */
-enum ibv_rate mult_to_ibv_rate(int mult) __attribute_const;
-
-struct ibv_ah_attr {
- struct ibv_global_route grh;
- uint16_t dlid;
- uint8_t sl;
- uint8_t src_path_bits;
- uint8_t static_rate;
- uint8_t is_global;
- uint8_t port_num;
-};
-
-struct ibv_xrc_domain {
- struct ibv_context *context;
- uint32_t handle;
-};
-
-enum ibv_srq_attr_mask {
- IBV_SRQ_MAX_WR = 1 << 0,
- IBV_SRQ_LIMIT = 1 << 1
-};
-
-struct ibv_srq_attr {
- uint32_t max_wr;
- uint32_t max_sge;
- uint32_t srq_limit;
-};
-
-struct ibv_srq_init_attr {
- void *srq_context;
- struct ibv_srq_attr attr;
-};
-
-enum ibv_qp_type {
- IBV_QPT_RC = 2,
- IBV_QPT_UC,
- IBV_QPT_UD,
- IBV_QPT_XRC,
- IBV_QPT_RAW_ETH = 8
-};
-
-struct ibv_qp_cap {
- uint32_t max_send_wr;
- uint32_t max_recv_wr;
- uint32_t max_send_sge;
- uint32_t max_recv_sge;
- uint32_t max_inline_data;
-};
-
-struct ibv_qp_init_attr {
- void *qp_context;
- struct ibv_cq *send_cq;
- struct ibv_cq *recv_cq;
- struct ibv_srq *srq;
- struct ibv_qp_cap cap;
- enum ibv_qp_type qp_type;
- int sq_sig_all;
- struct ibv_xrc_domain *xrc_domain;
-};
-
-enum ibv_qp_attr_mask {
- IBV_QP_STATE = 1 << 0,
- IBV_QP_CUR_STATE = 1 << 1,
- IBV_QP_EN_SQD_ASYNC_NOTIFY = 1 << 2,
- IBV_QP_ACCESS_FLAGS = 1 << 3,
- IBV_QP_PKEY_INDEX = 1 << 4,
- IBV_QP_PORT = 1 << 5,
- IBV_QP_QKEY = 1 << 6,
- IBV_QP_AV = 1 << 7,
- IBV_QP_PATH_MTU = 1 << 8,
- IBV_QP_TIMEOUT = 1 << 9,
- IBV_QP_RETRY_CNT = 1 << 10,
- IBV_QP_RNR_RETRY = 1 << 11,
- IBV_QP_RQ_PSN = 1 << 12,
- IBV_QP_MAX_QP_RD_ATOMIC = 1 << 13,
- IBV_QP_ALT_PATH = 1 << 14,
- IBV_QP_MIN_RNR_TIMER = 1 << 15,
- IBV_QP_SQ_PSN = 1 << 16,
- IBV_QP_MAX_DEST_RD_ATOMIC = 1 << 17,
- IBV_QP_PATH_MIG_STATE = 1 << 18,
- IBV_QP_CAP = 1 << 19,
- IBV_QP_DEST_QPN = 1 << 20
-};
-
-enum ibv_qp_state {
- IBV_QPS_RESET,
- IBV_QPS_INIT,
- IBV_QPS_RTR,
- IBV_QPS_RTS,
- IBV_QPS_SQD,
- IBV_QPS_SQE,
- IBV_QPS_ERR
-};
-
-enum ibv_mig_state {
- IBV_MIG_MIGRATED,
- IBV_MIG_REARM,
- IBV_MIG_ARMED
-};
-
-struct ibv_qp_attr {
- enum ibv_qp_state qp_state;
- enum ibv_qp_state cur_qp_state;
- enum ibv_mtu path_mtu;
- enum ibv_mig_state path_mig_state;
- uint32_t qkey;
- uint32_t rq_psn;
- uint32_t sq_psn;
- uint32_t dest_qp_num;
- int qp_access_flags;
- struct ibv_qp_cap cap;
- struct ibv_ah_attr ah_attr;
- struct ibv_ah_attr alt_ah_attr;
- uint16_t pkey_index;
- uint16_t alt_pkey_index;
- uint8_t en_sqd_async_notify;
- uint8_t sq_draining;
- uint8_t max_rd_atomic;
- uint8_t max_dest_rd_atomic;
- uint8_t min_rnr_timer;
- uint8_t port_num;
- uint8_t timeout;
- uint8_t retry_cnt;
- uint8_t rnr_retry;
- uint8_t alt_port_num;
- uint8_t alt_timeout;
-};
-
-enum ibv_wr_opcode {
- IBV_WR_RDMA_WRITE,
- IBV_WR_RDMA_WRITE_WITH_IMM,
- IBV_WR_SEND,
- IBV_WR_SEND_WITH_IMM,
- IBV_WR_RDMA_READ,
- IBV_WR_ATOMIC_CMP_AND_SWP,
- IBV_WR_ATOMIC_FETCH_AND_ADD
-};
-
-enum ibv_send_flags {
- IBV_SEND_FENCE = 1 << 0,
- IBV_SEND_SIGNALED = 1 << 1,
- IBV_SEND_SOLICITED = 1 << 2,
- IBV_SEND_INLINE = 1 << 3
-};
-
-struct ibv_sge {
- uint64_t addr;
- uint32_t length;
- uint32_t lkey;
-};
-
-struct ibv_send_wr {
- uint64_t wr_id;
- struct ibv_send_wr *next;
- struct ibv_sge *sg_list;
- int num_sge;
- enum ibv_wr_opcode opcode;
- int send_flags;
- uint32_t imm_data; /* in network byte order */
- union {
- struct {
- uint64_t remote_addr;
- uint32_t rkey;
- } rdma;
- struct {
- uint64_t remote_addr;
- uint64_t compare_add;
- uint64_t swap;
- uint32_t rkey;
- } atomic;
- struct {
- struct ibv_ah *ah;
- uint32_t remote_qpn;
- uint32_t remote_qkey;
- } ud;
- } wr;
- uint32_t xrc_remote_srq_num;
-};
-
-struct ibv_recv_wr {
- uint64_t wr_id;
- struct ibv_recv_wr *next;
- struct ibv_sge *sg_list;
- int num_sge;
-};
-
-struct ibv_mw_bind {
- uint64_t wr_id;
- struct ibv_mr *mr;
- void *addr;
- size_t length;
- int send_flags;
- int mw_access_flags;
-};
-
-struct ibv_srq {
- struct ibv_context *context;
- void *srq_context;
- struct ibv_pd *pd;
- uint32_t handle;
-
- uint32_t events_completed;
-
- uint32_t xrc_srq_num;
- struct ibv_xrc_domain *xrc_domain;
- struct ibv_cq *xrc_cq;
-
- pthread_mutex_t mutex;
- pthread_cond_t cond;
-};
-
-struct ibv_qp {
- struct ibv_context *context;
- void *qp_context;
- struct ibv_pd *pd;
- struct ibv_cq *send_cq;
- struct ibv_cq *recv_cq;
- struct ibv_srq *srq;
- uint32_t handle;
- uint32_t qp_num;
- enum ibv_qp_state state;
- enum ibv_qp_type qp_type;
-
- uint32_t events_completed;
-
- struct ibv_xrc_domain *xrc_domain;
-
- pthread_mutex_t mutex;
- pthread_cond_t cond;
-};
-
-struct ibv_comp_channel {
- struct ibv_context *context;
- int fd;
- int refcnt;
-};
-
-struct ibv_cq {
- struct ibv_context *context;
- struct ibv_comp_channel *channel;
- void *cq_context;
- uint32_t handle;
- int cqe;
-
- uint32_t comp_events_completed;
- uint32_t async_events_completed;
-
- pthread_mutex_t mutex;
- pthread_cond_t cond;
-};
-
-struct ibv_ah {
- struct ibv_context *context;
- struct ibv_pd *pd;
- uint32_t handle;
-};
-
-struct ibv_device;
-struct ibv_context;
-
-struct ibv_device_ops {
- struct ibv_context * (*alloc_context)(struct ibv_device *device, int cmd_fd);
- void (*free_context)(struct ibv_context *context);
-};
-
-enum {
- IBV_SYSFS_NAME_MAX = 64,
- IBV_SYSFS_PATH_MAX = 256
-};
-
-struct ibv_device {
- struct ibv_device_ops ops;
- enum ibv_node_type node_type;
- enum ibv_transport_type transport_type;
- /* Name of underlying kernel IB device, eg "mthca0" */
- char name[IBV_SYSFS_NAME_MAX];
- /* Name of uverbs device, eg "uverbs0" */
- char dev_name[IBV_SYSFS_NAME_MAX];
- /* Path to infiniband_verbs class device in sysfs */
- char dev_path[IBV_SYSFS_PATH_MAX];
- /* Path to infiniband class device in sysfs */
- char ibdev_path[IBV_SYSFS_PATH_MAX];
-};
-
-struct ibv_more_ops {
- struct ibv_srq * (*create_xrc_srq)(struct ibv_pd *pd,
- struct ibv_xrc_domain *xrc_domain,
- struct ibv_cq *xrc_cq,
- struct ibv_srq_init_attr *srq_init_attr);
- struct ibv_xrc_domain * (*open_xrc_domain)(struct ibv_context *context,
- int fd, int oflag);
- int (*close_xrc_domain)(struct ibv_xrc_domain *d);
- int (*create_xrc_rcv_qp)(struct ibv_qp_init_attr *init_attr,
- uint32_t *xrc_qp_num);
- int (*modify_xrc_rcv_qp)(struct ibv_xrc_domain *xrc_domain,
- uint32_t xrc_qp_num,
- struct ibv_qp_attr *attr,
- int attr_mask);
- int (*query_xrc_rcv_qp)(struct ibv_xrc_domain *xrc_domain,
- uint32_t xrc_qp_num,
- struct ibv_qp_attr *attr,
- int attr_mask,
- struct ibv_qp_init_attr *init_attr);
- int (*reg_xrc_rcv_qp)(struct ibv_xrc_domain *xrc_domain,
- uint32_t xrc_qp_num);
- int (*unreg_xrc_rcv_qp)(struct ibv_xrc_domain *xrc_domain,
- uint32_t xrc_qp_num);
-
-};
-
-struct ibv_context_ops {
- int (*query_device)(struct ibv_context *context,
- struct ibv_device_attr *device_attr);
- int (*query_port)(struct ibv_context *context, uint8_t port_num,
- struct ibv_port_attr *port_attr);
- struct ibv_pd * (*alloc_pd)(struct ibv_context *context);
- int (*dealloc_pd)(struct ibv_pd *pd);
- struct ibv_mr * (*reg_mr)(struct ibv_pd *pd, void *addr, size_t length,
- int access);
- struct ibv_mr * (*rereg_mr)(struct ibv_mr *mr,
- int flags,
- struct ibv_pd *pd, void *addr,
- size_t length,
- int access);
- int (*dereg_mr)(struct ibv_mr *mr);
- struct ibv_mw * (*alloc_mw)(struct ibv_pd *pd, enum ibv_mw_type type);
- int (*bind_mw)(struct ibv_qp *qp, struct ibv_mw *mw,
- struct ibv_mw_bind *mw_bind);
- int (*dealloc_mw)(struct ibv_mw *mw);
- struct ibv_cq * (*create_cq)(struct ibv_context *context, int cqe,
- struct ibv_comp_channel *channel,
- int comp_vector);
- int (*poll_cq)(struct ibv_cq *cq, int num_entries, struct ibv_wc *wc);
- int (*req_notify_cq)(struct ibv_cq *cq, int solicited_only);
- void (*cq_event)(struct ibv_cq *cq);
- int (*resize_cq)(struct ibv_cq *cq, int cqe);
- int (*destroy_cq)(struct ibv_cq *cq);
- struct ibv_srq * (*create_srq)(struct ibv_pd *pd,
- struct ibv_srq_init_attr *srq_init_attr);
- int (*modify_srq)(struct ibv_srq *srq,
- struct ibv_srq_attr *srq_attr,
- int srq_attr_mask);
- int (*query_srq)(struct ibv_srq *srq,
- struct ibv_srq_attr *srq_attr);
- int (*destroy_srq)(struct ibv_srq *srq);
- int (*post_srq_recv)(struct ibv_srq *srq,
- struct ibv_recv_wr *recv_wr,
- struct ibv_recv_wr **bad_recv_wr);
- struct ibv_qp * (*create_qp)(struct ibv_pd *pd, struct ibv_qp_init_attr *attr);
- int (*query_qp)(struct ibv_qp *qp, struct ibv_qp_attr *attr,
- int attr_mask,
- struct ibv_qp_init_attr *init_attr);
- int (*modify_qp)(struct ibv_qp *qp, struct ibv_qp_attr *attr,
- int attr_mask);
- int (*destroy_qp)(struct ibv_qp *qp);
- int (*post_send)(struct ibv_qp *qp, struct ibv_send_wr *wr,
- struct ibv_send_wr **bad_wr);
- int (*post_recv)(struct ibv_qp *qp, struct ibv_recv_wr *wr,
- struct ibv_recv_wr **bad_wr);
- struct ibv_ah * (*create_ah)(struct ibv_pd *pd, struct ibv_ah_attr *attr);
- int (*destroy_ah)(struct ibv_ah *ah);
- int (*attach_mcast)(struct ibv_qp *qp, const union ibv_gid *gid,
- uint16_t lid);
- int (*detach_mcast)(struct ibv_qp *qp, const union ibv_gid *gid,
- uint16_t lid);
- void (*async_event)(struct ibv_async_event *event);
-};
-
-struct ibv_context {
- struct ibv_device *device;
- struct ibv_context_ops ops;
- int cmd_fd;
- int async_fd;
- int num_comp_vectors;
- pthread_mutex_t mutex;
- void *abi_compat;
- struct ibv_more_ops *more_ops;
-};
-
-static inline int ___ibv_query_port(struct ibv_context *context,
- uint8_t port_num,
- struct ibv_port_attr *port_attr)
-{
- port_attr->link_layer = IBV_LINK_LAYER_UNSPECIFIED;
- port_attr->pad = 0;
-
- return context->ops.query_port(context, port_num, port_attr);
-}
-
-/**
- * ibv_get_device_list - Get list of IB devices currently available
- * @num_devices: optional. if non-NULL, set to the number of devices
- * returned in the array.
- *
- * Return a NULL-terminated array of IB devices. The array can be
- * released with ibv_free_device_list().
- */
-struct ibv_device **ibv_get_device_list(int *num_devices);
-
-/**
- * ibv_free_device_list - Free list from ibv_get_device_list()
- *
- * Free an array of devices returned from ibv_get_device_list(). Once
- * the array is freed, pointers to devices that were not opened with
- * ibv_open_device() are no longer valid. Client code must open all
- * devices it intends to use before calling ibv_free_device_list().
- */
-void ibv_free_device_list(struct ibv_device **list);
-
-/**
- * ibv_get_device_name - Return kernel device name
- */
-const char *ibv_get_device_name(struct ibv_device *device);
-
-/**
- * ibv_get_device_guid - Return device's node GUID
- */
-uint64_t ibv_get_device_guid(struct ibv_device *device);
-
-/**
- * ibv_open_device - Initialize device for use
- */
-struct ibv_context *ibv_open_device(struct ibv_device *device);
-
-/**
- * ibv_close_device - Release device
- */
-int ibv_close_device(struct ibv_context *context);
-
-/**
- * ibv_get_async_event - Get next async event
- * @event: Pointer to use to return async event
- *
- * All async events returned by ibv_get_async_event() must eventually
- * be acknowledged with ibv_ack_async_event().
- */
-int ibv_get_async_event(struct ibv_context *context,
- struct ibv_async_event *event);
-
-/**
- * ibv_ack_async_event - Acknowledge an async event
- * @event: Event to be acknowledged.
- *
- * All async events which are returned by ibv_get_async_event() must
- * be acknowledged. To avoid races, destroying an object (CQ, SRQ or
- * QP) will wait for all affiliated events to be acknowledged, so
- * there should be a one-to-one correspondence between acks and
- * successful gets.
- */
-void ibv_ack_async_event(struct ibv_async_event *event);
-
-/**
- * ibv_query_device - Get device properties
- */
-int ibv_query_device(struct ibv_context *context,
- struct ibv_device_attr *device_attr);
-
-/**
- * ibv_query_port - Get port properties
- */
-int ibv_query_port(struct ibv_context *context, uint8_t port_num,
- struct ibv_port_attr *port_attr);
-
-/**
- * ibv_query_gid - Get a GID table entry
- */
-int ibv_query_gid(struct ibv_context *context, uint8_t port_num,
- int index, union ibv_gid *gid);
-
-/**
- * ibv_query_pkey - Get a P_Key table entry
- */
-int ibv_query_pkey(struct ibv_context *context, uint8_t port_num,
- int index, uint16_t *pkey);
-
-/**
- * ibv_alloc_pd - Allocate a protection domain
- */
-struct ibv_pd *ibv_alloc_pd(struct ibv_context *context);
-
-/**
- * ibv_dealloc_pd - Free a protection domain
- */
-int ibv_dealloc_pd(struct ibv_pd *pd);
-
-/**
- * ibv_reg_mr - Register a memory region
- */
-struct ibv_mr *ibv_reg_mr(struct ibv_pd *pd, void *addr,
- size_t length, int access);
-
-/**
- * ibv_dereg_mr - Deregister a memory region
- */
-int ibv_dereg_mr(struct ibv_mr *mr);
-
-/**
- * ibv_create_comp_channel - Create a completion event channel
- */
-struct ibv_comp_channel *ibv_create_comp_channel(struct ibv_context *context);
-
-/**
- * ibv_destroy_comp_channel - Destroy a completion event channel
- */
-int ibv_destroy_comp_channel(struct ibv_comp_channel *channel);
-
-/**
- * ibv_create_cq - Create a completion queue
- * @context - Context CQ will be attached to
- * @cqe - Minimum number of entries required for CQ
- * @cq_context - Consumer-supplied context returned for completion events
- * @channel - Completion channel where completion events will be queued.
- * May be NULL if completion events will not be used.
- * @comp_vector - Completion vector used to signal completion events.
- * Must be >= 0 and < context->num_comp_vectors.
- */
-struct ibv_cq *ibv_create_cq(struct ibv_context *context, int cqe,
- void *cq_context,
- struct ibv_comp_channel *channel,
- int comp_vector);
-
-/**
- * ibv_resize_cq - Modifies the capacity of the CQ.
- * @cq: The CQ to resize.
- * @cqe: The minimum size of the CQ.
- *
- * Users can examine the cq structure to determine the actual CQ size.
- */
-int ibv_resize_cq(struct ibv_cq *cq, int cqe);
-
-/**
- * ibv_destroy_cq - Destroy a completion queue
- */
-int ibv_destroy_cq(struct ibv_cq *cq);
-
-/**
- * ibv_get_cq_event - Read next CQ event
- * @channel: Channel to get next event from.
- * @cq: Used to return pointer to CQ.
- * @cq_context: Used to return consumer-supplied CQ context.
- *
- * All completion events returned by ibv_get_cq_event() must
- * eventually be acknowledged with ibv_ack_cq_events().
- */
-int ibv_get_cq_event(struct ibv_comp_channel *channel,
- struct ibv_cq **cq, void **cq_context);
-
-/**
- * ibv_ack_cq_events - Acknowledge CQ completion events
- * @cq: CQ to acknowledge events for
- * @nevents: Number of events to acknowledge.
- *
- * All completion events which are returned by ibv_get_cq_event() must
- * be acknowledged. To avoid races, ibv_destroy_cq() will wait for
- * all completion events to be acknowledged, so there should be a
- * one-to-one correspondence between acks and successful gets. An
- * application may accumulate multiple completion events and
- * acknowledge them in a single call to ibv_ack_cq_events() by passing
- * the number of events to ack in @nevents.
- */
-void ibv_ack_cq_events(struct ibv_cq *cq, unsigned int nevents);
-
-/**
- * ibv_poll_cq - Poll a CQ for work completions
- * @cq:the CQ being polled
- * @num_entries:maximum number of completions to return
- * @wc:array of at least @num_entries of &struct ibv_wc where completions
- * will be returned
- *
- * Poll a CQ for (possibly multiple) completions. If the return value
- * is < 0, an error occurred. If the return value is >= 0, it is the
- * number of completions returned. If the return value is
- * non-negative and strictly less than num_entries, then the CQ was
- * emptied.
- */
-static inline int ibv_poll_cq(struct ibv_cq *cq, int num_entries, struct ibv_wc *wc)
-{
- return cq->context->ops.poll_cq(cq, num_entries, wc);
-}
-
-/**
- * ibv_req_notify_cq - Request completion notification on a CQ. An
- * event will be added to the completion channel associated with the
- * CQ when an entry is added to the CQ.
- * @cq: The completion queue to request notification for.
- * @solicited_only: If non-zero, an event will be generated only for
- * the next solicited CQ entry. If zero, any CQ entry, solicited or
- * not, will generate an event.
- */
-static inline int ibv_req_notify_cq(struct ibv_cq *cq, int solicited_only)
-{
- return cq->context->ops.req_notify_cq(cq, solicited_only);
-}
-
-/**
- * ibv_create_srq - Creates a SRQ associated with the specified protection
- * domain.
- * @pd: The protection domain associated with the SRQ.
- * @srq_init_attr: A list of initial attributes required to create the SRQ.
- *
- * srq_attr->max_wr and srq_attr->max_sge are read the determine the
- * requested size of the SRQ, and set to the actual values allocated
- * on return. If ibv_create_srq() succeeds, then max_wr and max_sge
- * will always be at least as large as the requested values.
- */
-struct ibv_srq *ibv_create_srq(struct ibv_pd *pd,
- struct ibv_srq_init_attr *srq_init_attr);
-
-/**
- * ibv_create_xrc_srq - Creates a SRQ associated with the specified protection
- * domain and xrc domain.
- * @pd: The protection domain associated with the SRQ.
- * @xrc_domain: The XRC domain associated with the SRQ.
- * @xrc_cq: CQ to report completions for XRC packets on.
- *
- * @srq_init_attr: A list of initial attributes required to create the SRQ.
- *
- * srq_attr->max_wr and srq_attr->max_sge are read the determine the
- * requested size of the SRQ, and set to the actual values allocated
- * on return. If ibv_create_srq() succeeds, then max_wr and max_sge
- * will always be at least as large as the requested values.
- */
-struct ibv_srq *ibv_create_xrc_srq(struct ibv_pd *pd,
- struct ibv_xrc_domain *xrc_domain,
- struct ibv_cq *xrc_cq,
- struct ibv_srq_init_attr *srq_init_attr);
-
-/**
- * ibv_modify_srq - Modifies the attributes for the specified SRQ.
- * @srq: The SRQ to modify.
- * @srq_attr: On input, specifies the SRQ attributes to modify. On output,
- * the current values of selected SRQ attributes are returned.
- * @srq_attr_mask: A bit-mask used to specify which attributes of the SRQ
- * are being modified.
- *
- * The mask may contain IBV_SRQ_MAX_WR to resize the SRQ and/or
- * IBV_SRQ_LIMIT to set the SRQ's limit and request notification when
- * the number of receives queued drops below the limit.
- */
-int ibv_modify_srq(struct ibv_srq *srq,
- struct ibv_srq_attr *srq_attr,
- int srq_attr_mask);
-
-/**
- * ibv_query_srq - Returns the attribute list and current values for the
- * specified SRQ.
- * @srq: The SRQ to query.
- * @srq_attr: The attributes of the specified SRQ.
- */
-int ibv_query_srq(struct ibv_srq *srq, struct ibv_srq_attr *srq_attr);
-
-/**
- * ibv_destroy_srq - Destroys the specified SRQ.
- * @srq: The SRQ to destroy.
- */
-int ibv_destroy_srq(struct ibv_srq *srq);
-
-/**
- * ibv_post_srq_recv - Posts a list of work requests to the specified SRQ.
- * @srq: The SRQ to post the work request on.
- * @recv_wr: A list of work requests to post on the receive queue.
- * @bad_recv_wr: On an immediate failure, this parameter will reference
- * the work request that failed to be posted on the QP.
- */
-static inline int ibv_post_srq_recv(struct ibv_srq *srq,
- struct ibv_recv_wr *recv_wr,
- struct ibv_recv_wr **bad_recv_wr)
-{
- return srq->context->ops.post_srq_recv(srq, recv_wr, bad_recv_wr);
-}
-
-/**
- * ibv_create_qp - Create a queue pair.
- */
-struct ibv_qp *ibv_create_qp(struct ibv_pd *pd,
- struct ibv_qp_init_attr *qp_init_attr);
-
-/**
- * ibv_modify_qp - Modify a queue pair.
- */
-int ibv_modify_qp(struct ibv_qp *qp, struct ibv_qp_attr *attr,
- int attr_mask);
-
-/**
- * ibv_query_qp - Returns the attribute list and current values for the
- * specified QP.
- * @qp: The QP to query.
- * @attr: The attributes of the specified QP.
- * @attr_mask: A bit-mask used to select specific attributes to query.
- * @init_attr: Additional attributes of the selected QP.
- *
- * The qp_attr_mask may be used to limit the query to gathering only the
- * selected attributes.
- */
-int ibv_query_qp(struct ibv_qp *qp, struct ibv_qp_attr *attr,
- int attr_mask,
- struct ibv_qp_init_attr *init_attr);
-
-/**
- * ibv_destroy_qp - Destroy a queue pair.
- */
-int ibv_destroy_qp(struct ibv_qp *qp);
-
-/**
- * ibv_post_send - Post a list of work requests to a send queue.
- *
- * If IBV_SEND_INLINE flag is set, the data buffers can be reused
- * immediately after the call returns.
- */
-static inline int ibv_post_send(struct ibv_qp *qp, struct ibv_send_wr *wr,
- struct ibv_send_wr **bad_wr)
-{
- return qp->context->ops.post_send(qp, wr, bad_wr);
-}
-
-/**
- * ibv_post_recv - Post a list of work requests to a receive queue.
- */
-static inline int ibv_post_recv(struct ibv_qp *qp, struct ibv_recv_wr *wr,
- struct ibv_recv_wr **bad_wr)
-{
- return qp->context->ops.post_recv(qp, wr, bad_wr);
-}
-
-/**
- * ibv_create_ah - Create an address handle.
- */
-struct ibv_ah *ibv_create_ah(struct ibv_pd *pd, struct ibv_ah_attr *attr);
-
-/**
- * ibv_init_ah_from_wc - Initializes address handle attributes from a
- * work completion.
- * @context: Device context on which the received message arrived.
- * @port_num: Port on which the received message arrived.
- * @wc: Work completion associated with the received message.
- * @grh: References the received global route header. This parameter is
- * ignored unless the work completion indicates that the GRH is valid.
- * @ah_attr: Returned attributes that can be used when creating an address
- * handle for replying to the message.
- */
-int ibv_init_ah_from_wc(struct ibv_context *context, uint8_t port_num,
- struct ibv_wc *wc, struct ibv_grh *grh,
- struct ibv_ah_attr *ah_attr);
-
-/**
- * ibv_create_ah_from_wc - Creates an address handle associated with the
- * sender of the specified work completion.
- * @pd: The protection domain associated with the address handle.
- * @wc: Work completion information associated with a received message.
- * @grh: References the received global route header. This parameter is
- * ignored unless the work completion indicates that the GRH is valid.
- * @port_num: The outbound port number to associate with the address.
- *
- * The address handle is used to reference a local or global destination
- * in all UD QP post sends.
- */
-struct ibv_ah *ibv_create_ah_from_wc(struct ibv_pd *pd, struct ibv_wc *wc,
- struct ibv_grh *grh, uint8_t port_num);
-
-/**
- * ibv_destroy_ah - Destroy an address handle.
- */
-int ibv_destroy_ah(struct ibv_ah *ah);
-
-/**
- * ibv_attach_mcast - Attaches the specified QP to a multicast group.
- * @qp: QP to attach to the multicast group. The QP must be a UD QP.
- * @gid: Multicast group GID.
- * @lid: Multicast group LID in host byte order.
- *
- * In order to route multicast packets correctly, subnet
- * administration must have created the multicast group and configured
- * the fabric appropriately. The port associated with the specified
- * QP must also be a member of the multicast group.
- */
-int ibv_attach_mcast(struct ibv_qp *qp, const union ibv_gid *gid, uint16_t lid);
-
-/**
- * ibv_detach_mcast - Detaches the specified QP from a multicast group.
- * @qp: QP to detach from the multicast group.
- * @gid: Multicast group GID.
- * @lid: Multicast group LID in host byte order.
- */
-int ibv_detach_mcast(struct ibv_qp *qp, const union ibv_gid *gid, uint16_t lid);
-
-/**
- * ibv_fork_init - Prepare data structures so that fork() may be used
- * safely. If this function is not called or returns a non-zero
- * status, then libibverbs data structures are not fork()-safe and the
- * effect of an application calling fork() is undefined.
- */
-int ibv_fork_init(void);
-
-/**
- * ibv_node_type_str - Return string describing node_type enum value
- */
-const char *ibv_node_type_str(enum ibv_node_type node_type);
-
-/**
- * ibv_port_state_str - Return string describing port_state enum value
- */
-const char *ibv_port_state_str(enum ibv_port_state port_state);
-
-/**
- * ibv_event_type_str - Return string describing event_type enum value
- */
-const char *ibv_event_type_str(enum ibv_event_type event);
-
-/**
- * ibv_open_xrc_domain - open an XRC domain
- * Returns a reference to an XRC domain.
- *
- * @context: Device context
- * @fd: descriptor for inode associated with the domain
- * If fd == -1, no inode is associated with the domain; in this ca= se,
- * the only legal value for oflag is O_CREAT
- *
- * @oflag: oflag values are constructed by OR-ing flags from the following list
- *
- * O_CREAT
- * If a domain belonging to device named by context is already associated
- * with the inode, this flag has no effect, except as noted under O_EXCL
- * below. Otherwise, a new XRC domain is created and is associated with
- * inode specified by fd.
- *
- * O_EXCL
- * If O_EXCL and O_CREAT are set, open will fail if a domain associated with
- * the inode exists. The check for the existence of the domain and creation
- * of the domain if it does not exist is atomic with respect to other
- * processes executing open with fd naming the same inode.
- */
-struct ibv_xrc_domain *ibv_open_xrc_domain(struct ibv_context *context,
- int fd, int oflag);
-
-/**
- * ibv_close_xrc_domain - close an XRC domain
- * If this is the last reference, destroys the domain.
- *
- * @d: reference to XRC domain to close
- *
- * close is implicitly performed at process exit.
- */
-int ibv_close_xrc_domain(struct ibv_xrc_domain *d);
-
-/**
- * ibv_create_xrc_rcv_qp - creates an XRC QP for serving as a receive-side-only QP,
- *
- * This QP is created in kernel space, and persists until the last process
- * registered for the QP calls ibv_unreg_xrc_rcv_qp() (at which time the QP
- * is destroyed).
- *
- * @init_attr: init attributes to use for QP. xrc domain MUST be included here.
- * All other fields are ignored.
- *
- * @xrc_rcv_qpn: qp_num of created QP (if success). To be passed to the
- * remote node (sender). The remote node will use xrc_rcv_qpn
- * in ibv_post_send when sending to XRC SRQ's on this host
- * in the same xrc domain.
- *
- * RETURNS: success (0), or a (negative) error value.
- *
- * NOTE: this verb also registers the calling user-process with the QP at its
- * creation time (implicit call to ibv_reg_xrc_rcv_qp), to avoid race
- * conditions. The creating process will need to call ibv_unreg_xrc_qp()
- * for the QP to release it from this process.
- */
-int ibv_create_xrc_rcv_qp(struct ibv_qp_init_attr *init_attr,
- uint32_t *xrc_rcv_qpn);
-
-/**
- * ibv_modify_xrc_rcv_qp - modifies an xrc_rcv qp.
- *
- * @xrc_domain: xrc domain the QP belongs to (for verification).
- * @xrc_qp_num: The (24 bit) number of the XRC QP.
- * @attr: modify-qp attributes. The following fields must be specified:
- * for RESET_2_INIT: qp_state, pkey_index , port, qp_access_flags
- * for INIT_2_RTR: qp_state, path_mtu, dest_qp_num, rq_psn,
- * max_dest_rd_atomic, min_rnr_timer, ah_attr
- * The QP need not be brought to RTS for the QP to operate as a
- * receive-only QP.
- * @attr_mask: bitmap indicating which attributes are provided in the attr
- * struct. Used for validity checking.
- * The following bits must be set:
- * for RESET_2_INIT: IBV_QP_PKEY_INDEX, IBV_QP_PORT,
- * IBV_QP_ACCESS_FLAGS, IBV_QP_STATE
- * for INIT_2_RTR: IBV_QP_AV, IBV_QP_PATH_MTU, IBV_QP_DEST_QPN,
- * IBV_QP_RQ_PSN, IBV_QP_MAX_DEST_RD_ATOMIC,
- * IBV_QP_MIN_RNR_TIMER, IBV_QP_STATE
- *
- * RETURNS: success (0), or a (positive) error value.
- *
- */
-int ibv_modify_xrc_rcv_qp(struct ibv_xrc_domain *xrc_domain,
- uint32_t xrc_qp_num,
- struct ibv_qp_attr *attr, int attr_mask);
-
-/**
- * ibv_query_xrc_rcv_qp - queries an xrc_rcv qp.
- *
- * @xrc_domain: xrc domain the QP belongs to (for verification).
- * @xrc_qp_num: The (24 bit) number of the XRC QP.
- * @attr: for returning qp attributes.
- * @attr_mask: bitmap indicating which attributes to return.
- * @init_attr: for returning the init attributes
- *
- * RETURNS: success (0), or a (positive) error value.
- *
- */
-int ibv_query_xrc_rcv_qp(struct ibv_xrc_domain *xrc_domain, uint32_t xrc_qp_num,
- struct ibv_qp_attr *attr, int attr_mask,
- struct ibv_qp_init_attr *init_attr);
-
-/**
- * ibv_reg_xrc_rcv_qp: registers a user process with an XRC QP which serves as
- * a receive-side only QP.
- *
- * @xrc_domain: xrc domain the QP belongs to (for verification).
- * @xrc_qp_num: The (24 bit) number of the XRC QP.
- *
- * RETURNS: success (0),
- * or error (EINVAL), if:
- * 1. There is no such QP_num allocated.
- * 2. The QP is allocated, but is not an receive XRC QP
- * 3. The XRC QP does not belong to the given domain.
- */
-int ibv_reg_xrc_rcv_qp(struct ibv_xrc_domain *xrc_domain, uint32_t xrc_qp_num);
-
-/**
- * ibv_unreg_xrc_rcv_qp: detaches a user process from an XRC QP serving as
- * a receive-side only QP. If as a result, there are no remaining
- * userspace processes registered for this XRC QP, it is destroyed.
- *
- * @xrc_domain: xrc domain the QP belongs to (for verification).
- * @xrc_qp_num: The (24 bit) number of the XRC QP.
- *
- * RETURNS: success (0),
- * or error (EINVAL), if:
- * 1. There is no such QP_num allocated.
- * 2. The QP is allocated, but is not an XRC QP
- * 3. The XRC QP does not belong to the given domain.
- * NOTE: There is no reason to return a special code if the QP is destroyed.
- * The unregister simply succeeds.
- */
-int ibv_unreg_xrc_rcv_qp(struct ibv_xrc_domain *xrc_domain,
- uint32_t xrc_qp_num);
-
-END_C_DECLS
-
-# undef __attribute_const
-
-#define ibv_query_port(context, port_num, port_attr) \
- ___ibv_query_port(context, port_num, port_attr)
-
-#endif /* INFINIBAND_VERBS_H */
diff --git a/contrib/ofed/libibverbs/init.c b/contrib/ofed/libibverbs/init.c
new file mode 100644
index 0000000..4f0f9f6
--- /dev/null
+++ b/contrib/ofed/libibverbs/init.c
@@ -0,0 +1,635 @@
+/*
+ * Copyright (c) 2004, 2005 Topspin Communications. All rights reserved.
+ * Copyright (c) 2006 Cisco Systems, Inc. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+#define _GNU_SOURCE
+#include <config.h>
+
+#include <stdlib.h>
+#include <string.h>
+#include <glob.h>
+#include <stdio.h>
+#include <dlfcn.h>
+#include <unistd.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <sys/time.h>
+#include <sys/resource.h>
+#include <dirent.h>
+#include <errno.h>
+#include <assert.h>
+
+#include "ibverbs.h"
+
+#pragma GCC diagnostic ignored "-Wmissing-prototypes"
+
+int abi_ver;
+
+struct ibv_sysfs_dev {
+ char sysfs_name[IBV_SYSFS_NAME_MAX];
+ char ibdev_name[IBV_SYSFS_NAME_MAX];
+ char sysfs_path[IBV_SYSFS_PATH_MAX];
+ char ibdev_path[IBV_SYSFS_PATH_MAX];
+ struct ibv_sysfs_dev *next;
+ int abi_ver;
+ int have_driver;
+};
+
+struct ibv_driver_name {
+ char *name;
+ struct ibv_driver_name *next;
+};
+
+struct ibv_driver {
+ const char *name;
+ verbs_driver_init_func verbs_init_func;
+ struct ibv_driver *next;
+};
+
+static struct ibv_sysfs_dev *sysfs_dev_list;
+static struct ibv_driver_name *driver_name_list;
+static struct ibv_driver *head_driver, *tail_driver;
+
+static int find_sysfs_devs(void)
+{
+#ifdef __linux__
+ char class_path[IBV_SYSFS_PATH_MAX];
+ DIR *class_dir;
+ struct dirent *dent;
+ struct ibv_sysfs_dev *sysfs_dev = NULL;
+ char value[8];
+ int ret = 0;
+
+ if (!check_snprintf(class_path, sizeof(class_path),
+ "%s/class/infiniband_verbs", ibv_get_sysfs_path()))
+ return ENOMEM;
+
+ class_dir = opendir(class_path);
+ if (!class_dir)
+ return ENOSYS;
+
+ while ((dent = readdir(class_dir))) {
+ struct stat buf;
+
+ if (dent->d_name[0] == '.')
+ continue;
+
+ if (!sysfs_dev)
+ sysfs_dev = malloc(sizeof *sysfs_dev);
+ if (!sysfs_dev) {
+ ret = ENOMEM;
+ goto out;
+ }
+
+ if (!check_snprintf(sysfs_dev->sysfs_path, sizeof sysfs_dev->sysfs_path,
+ "%s/%s", class_path, dent->d_name))
+ continue;
+
+ if (stat(sysfs_dev->sysfs_path, &buf)) {
+ fprintf(stderr, PFX "Warning: couldn't stat '%s'.\n",
+ sysfs_dev->sysfs_path);
+ continue;
+ }
+
+ if (!S_ISDIR(buf.st_mode))
+ continue;
+
+ if (!check_snprintf(sysfs_dev->sysfs_name, sizeof sysfs_dev->sysfs_name,
+ "%s", dent->d_name))
+ continue;
+
+ if (ibv_read_sysfs_file(sysfs_dev->sysfs_path, "ibdev",
+ sysfs_dev->ibdev_name,
+ sizeof sysfs_dev->ibdev_name) < 0) {
+ fprintf(stderr, PFX "Warning: no ibdev class attr for '%s'.\n",
+ dent->d_name);
+ continue;
+ }
+
+ if (!check_snprintf(
+ sysfs_dev->ibdev_path, sizeof(sysfs_dev->ibdev_path),
+ "%s/class/infiniband/%s", ibv_get_sysfs_path(),
+ sysfs_dev->ibdev_name))
+ continue;
+
+ sysfs_dev->next = sysfs_dev_list;
+ sysfs_dev->have_driver = 0;
+ if (ibv_read_sysfs_file(sysfs_dev->sysfs_path, "abi_version",
+ value, sizeof value) > 0)
+ sysfs_dev->abi_ver = strtol(value, NULL, 10);
+ else
+ sysfs_dev->abi_ver = 0;
+
+ sysfs_dev_list = sysfs_dev;
+ sysfs_dev = NULL;
+ }
+
+ out:
+ if (sysfs_dev)
+ free(sysfs_dev);
+
+ closedir(class_dir);
+ return ret;
+#else
+ char class_path[IBV_SYSFS_PATH_MAX];
+ struct ibv_sysfs_dev *sysfs_dev = NULL;
+ char value[8];
+ int ret = 0;
+ int i;
+
+ snprintf(class_path, sizeof class_path, "%s/class/infiniband_verbs",
+ ibv_get_sysfs_path());
+
+ for (i = 0; i < 256; i++) {
+ if (!sysfs_dev)
+ sysfs_dev = malloc(sizeof *sysfs_dev);
+ if (!sysfs_dev) {
+ ret = ENOMEM;
+ goto out;
+ }
+
+ snprintf(sysfs_dev->sysfs_path, sizeof sysfs_dev->sysfs_path,
+ "%s/uverbs%d", class_path, i);
+
+ snprintf(sysfs_dev->sysfs_name, sizeof sysfs_dev->sysfs_name,
+ "uverbs%d", i);
+
+ if (ibv_read_sysfs_file(sysfs_dev->sysfs_path, "ibdev",
+ sysfs_dev->ibdev_name,
+ sizeof sysfs_dev->ibdev_name) < 0)
+ continue;
+
+ snprintf(sysfs_dev->ibdev_path, sizeof sysfs_dev->ibdev_path,
+ "%s/class/infiniband/%s", ibv_get_sysfs_path(),
+ sysfs_dev->ibdev_name);
+
+ sysfs_dev->next = sysfs_dev_list;
+ sysfs_dev->have_driver = 0;
+ if (ibv_read_sysfs_file(sysfs_dev->sysfs_path, "abi_version",
+ value, sizeof value) > 0)
+ sysfs_dev->abi_ver = strtol(value, NULL, 10);
+ else
+ sysfs_dev->abi_ver = 0;
+
+ sysfs_dev_list = sysfs_dev;
+ sysfs_dev = NULL;
+ }
+
+ out:
+ if (sysfs_dev)
+ free(sysfs_dev);
+
+ return ret;
+#endif
+}
+
+void verbs_register_driver(const char *name,
+ verbs_driver_init_func verbs_init_func)
+{
+ struct ibv_driver *driver;
+
+ driver = malloc(sizeof *driver);
+ if (!driver) {
+ fprintf(stderr, PFX "Warning: couldn't allocate driver for %s\n", name);
+ return;
+ }
+
+ driver->name = name;
+ driver->verbs_init_func = verbs_init_func;
+ driver->next = NULL;
+
+ if (tail_driver)
+ tail_driver->next = driver;
+ else
+ head_driver = driver;
+ tail_driver = driver;
+}
+
+#define __IBV_QUOTE(x) #x
+#define IBV_QUOTE(x) __IBV_QUOTE(x)
+#define DLOPEN_TRAILER "-" IBV_QUOTE(IBV_DEVICE_LIBRARY_EXTENSION) ".so"
+
+static void load_driver(const char *name)
+{
+ char *so_name;
+ void *dlhandle;
+
+ /* If the name is an absolute path then open that path after appending
+ the trailer suffix */
+ if (name[0] == '/') {
+ if (asprintf(&so_name, "%s" DLOPEN_TRAILER, name) < 0)
+ goto out_asprintf;
+ dlhandle = dlopen(so_name, RTLD_NOW);
+ if (!dlhandle)
+ goto out_dlopen;
+ free(so_name);
+ return;
+ }
+
+ /* If configured with a provider plugin path then try that next */
+ if (sizeof(VERBS_PROVIDER_DIR) > 1) {
+ if (asprintf(&so_name, VERBS_PROVIDER_DIR "/lib%s" DLOPEN_TRAILER, name) <
+ 0)
+ goto out_asprintf;
+ dlhandle = dlopen(so_name, RTLD_NOW);
+ free(so_name);
+ if (dlhandle)
+ return;
+ }
+
+ /* Otherwise use the system libary search path. This is the historical
+ behavior of libibverbs */
+ if (asprintf(&so_name, "lib%s" DLOPEN_TRAILER, name) < 0)
+ goto out_asprintf;
+ dlhandle = dlopen(so_name, RTLD_NOW);
+ if (!dlhandle)
+ goto out_dlopen;
+ free(so_name);
+ return;
+
+out_asprintf:
+ fprintf(stderr, PFX "Warning: couldn't load driver '%s'.\n", name);
+ return;
+out_dlopen:
+ fprintf(stderr, PFX "Warning: couldn't load driver '%s': %s\n", so_name,
+ dlerror());
+ free(so_name);
+ return;
+}
+
+static void load_drivers(void)
+{
+ struct ibv_driver_name *name, *next_name;
+ const char *env;
+ char *list, *env_name;
+
+ /*
+ * Only use drivers passed in through the calling user's
+ * environment if we're not running setuid.
+ */
+ if (getuid() == geteuid()) {
+ if ((env = getenv("RDMAV_DRIVERS"))) {
+ list = strdupa(env);
+ while ((env_name = strsep(&list, ":;")))
+ load_driver(env_name);
+ } else if ((env = getenv("IBV_DRIVERS"))) {
+ list = strdupa(env);
+ while ((env_name = strsep(&list, ":;")))
+ load_driver(env_name);
+ }
+ }
+
+ for (name = driver_name_list, next_name = name ? name->next : NULL;
+ name;
+ name = next_name, next_name = name ? name->next : NULL) {
+ load_driver(name->name);
+ free(name->name);
+ free(name);
+ }
+}
+
+static void read_config_file(const char *path)
+{
+ FILE *conf;
+ char *line = NULL;
+ char *config;
+ char *field;
+ size_t buflen = 0;
+ ssize_t len;
+
+ conf = fopen(path, "r" STREAM_CLOEXEC);
+ if (!conf) {
+ fprintf(stderr, PFX "Warning: couldn't read config file %s.\n",
+ path);
+ return;
+ }
+
+ while ((len = getline(&line, &buflen, conf)) != -1) {
+ config = line + strspn(line, "\t ");
+ if (config[0] == '\n' || config[0] == '#')
+ continue;
+
+ field = strsep(&config, "\n\t ");
+
+ if (strcmp(field, "driver") == 0 && config != NULL) {
+ struct ibv_driver_name *driver_name;
+
+ config += strspn(config, "\t ");
+ field = strsep(&config, "\n\t ");
+
+ driver_name = malloc(sizeof *driver_name);
+ if (!driver_name) {
+ fprintf(stderr, PFX "Warning: couldn't allocate "
+ "driver name '%s'.\n", field);
+ continue;
+ }
+
+ driver_name->name = strdup(field);
+ if (!driver_name->name) {
+ fprintf(stderr, PFX "Warning: couldn't allocate "
+ "driver name '%s'.\n", field);
+ free(driver_name);
+ continue;
+ }
+
+ driver_name->next = driver_name_list;
+ driver_name_list = driver_name;
+ } else
+ fprintf(stderr, PFX "Warning: ignoring bad config directive "
+ "'%s' in file '%s'.\n", field, path);
+ }
+
+ if (line)
+ free(line);
+ fclose(conf);
+}
+
+static void read_config(void)
+{
+ DIR *conf_dir;
+ struct dirent *dent;
+ char *path;
+
+ conf_dir = opendir(IBV_CONFIG_DIR);
+ if (!conf_dir) {
+ fprintf(stderr, PFX "Warning: couldn't open config directory '%s'.\n",
+ IBV_CONFIG_DIR);
+ return;
+ }
+
+ while ((dent = readdir(conf_dir))) {
+ struct stat buf;
+
+ if (asprintf(&path, "%s/%s", IBV_CONFIG_DIR, dent->d_name) < 0) {
+ fprintf(stderr, PFX "Warning: couldn't read config file %s/%s.\n",
+ IBV_CONFIG_DIR, dent->d_name);
+ goto out;
+ }
+
+ if (stat(path, &buf)) {
+ fprintf(stderr, PFX "Warning: couldn't stat config file '%s'.\n",
+ path);
+ goto next;
+ }
+
+ if (!S_ISREG(buf.st_mode))
+ goto next;
+
+ read_config_file(path);
+next:
+ free(path);
+ }
+
+out:
+ closedir(conf_dir);
+}
+
+static struct ibv_device *try_driver(struct ibv_driver *driver,
+ struct ibv_sysfs_dev *sysfs_dev)
+{
+ struct verbs_device *vdev;
+ struct ibv_device *dev;
+ char value[16];
+
+ vdev = driver->verbs_init_func(sysfs_dev->sysfs_path, sysfs_dev->abi_ver);
+ if (!vdev)
+ return NULL;
+
+ dev = &vdev->device;
+ assert(dev->_ops._dummy1 == NULL);
+ assert(dev->_ops._dummy2 == NULL);
+
+ if (ibv_read_sysfs_file(sysfs_dev->ibdev_path, "node_type", value, sizeof value) < 0) {
+ fprintf(stderr, PFX "Warning: no node_type attr under %s.\n",
+ sysfs_dev->ibdev_path);
+ dev->node_type = IBV_NODE_UNKNOWN;
+ } else {
+ dev->node_type = strtol(value, NULL, 10);
+ if (dev->node_type < IBV_NODE_CA || dev->node_type > IBV_NODE_USNIC_UDP)
+ dev->node_type = IBV_NODE_UNKNOWN;
+ }
+
+ switch (dev->node_type) {
+ case IBV_NODE_CA:
+ case IBV_NODE_SWITCH:
+ case IBV_NODE_ROUTER:
+ dev->transport_type = IBV_TRANSPORT_IB;
+ break;
+ case IBV_NODE_RNIC:
+ dev->transport_type = IBV_TRANSPORT_IWARP;
+ break;
+ case IBV_NODE_USNIC:
+ dev->transport_type = IBV_TRANSPORT_USNIC;
+ break;
+ case IBV_NODE_USNIC_UDP:
+ dev->transport_type = IBV_TRANSPORT_USNIC_UDP;
+ break;
+ default:
+ dev->transport_type = IBV_TRANSPORT_UNKNOWN;
+ break;
+ }
+
+ strcpy(dev->dev_name, sysfs_dev->sysfs_name);
+ strcpy(dev->dev_path, sysfs_dev->sysfs_path);
+ strcpy(dev->name, sysfs_dev->ibdev_name);
+ strcpy(dev->ibdev_path, sysfs_dev->ibdev_path);
+
+ return dev;
+}
+
+static struct ibv_device *try_drivers(struct ibv_sysfs_dev *sysfs_dev)
+{
+ struct ibv_driver *driver;
+ struct ibv_device *dev;
+
+ for (driver = head_driver; driver; driver = driver->next) {
+ dev = try_driver(driver, sysfs_dev);
+ if (dev)
+ return dev;
+ }
+
+ return NULL;
+}
+
+static int check_abi_version(const char *path)
+{
+ char value[8];
+
+ if (ibv_read_sysfs_file(path, "class/infiniband_verbs/abi_version",
+ value, sizeof value) < 0) {
+ return ENOSYS;
+ }
+
+ abi_ver = strtol(value, NULL, 10);
+
+ if (abi_ver < IB_USER_VERBS_MIN_ABI_VERSION ||
+ abi_ver > IB_USER_VERBS_MAX_ABI_VERSION) {
+ fprintf(stderr, PFX "Fatal: kernel ABI version %d "
+ "doesn't match library version %d.\n",
+ abi_ver, IB_USER_VERBS_MAX_ABI_VERSION);
+ return ENOSYS;
+ }
+
+ return 0;
+}
+
+static void check_memlock_limit(void)
+{
+ struct rlimit rlim;
+
+ if (!geteuid())
+ return;
+
+ if (getrlimit(RLIMIT_MEMLOCK, &rlim)) {
+ fprintf(stderr, PFX "Warning: getrlimit(RLIMIT_MEMLOCK) failed.");
+ return;
+ }
+
+ if (rlim.rlim_cur <= 32768)
+ fprintf(stderr, PFX "Warning: RLIMIT_MEMLOCK is %lu bytes.\n"
+ " This will severely limit memory registrations.\n",
+ rlim.rlim_cur);
+}
+
+static void add_device(struct ibv_device *dev,
+ struct ibv_device ***dev_list,
+ int *num_devices,
+ int *list_size)
+{
+ struct ibv_device **new_list;
+
+ if (*list_size <= *num_devices) {
+ *list_size = *list_size ? *list_size * 2 : 1;
+ new_list = realloc(*dev_list, *list_size * sizeof (struct ibv_device *));
+ if (!new_list)
+ return;
+ *dev_list = new_list;
+ }
+
+ (*dev_list)[(*num_devices)++] = dev;
+}
+
+int ibverbs_init(struct ibv_device ***list)
+{
+ const char *sysfs_path;
+ struct ibv_sysfs_dev *sysfs_dev, *next_dev;
+ struct ibv_device *device;
+ int num_devices = 0;
+ int list_size = 0;
+ int statically_linked = 0;
+ int no_driver = 0;
+ int ret;
+
+ *list = NULL;
+
+ if (getenv("RDMAV_FORK_SAFE") || getenv("IBV_FORK_SAFE"))
+ if (ibv_fork_init())
+ fprintf(stderr, PFX "Warning: fork()-safety requested "
+ "but init failed\n");
+
+ sysfs_path = ibv_get_sysfs_path();
+ if (!sysfs_path)
+ return -ENOSYS;
+
+ ret = check_abi_version(sysfs_path);
+ if (ret)
+ return -ret;
+
+ check_memlock_limit();
+
+ read_config();
+
+ ret = find_sysfs_devs();
+ if (ret)
+ return -ret;
+
+ for (sysfs_dev = sysfs_dev_list; sysfs_dev; sysfs_dev = sysfs_dev->next) {
+ device = try_drivers(sysfs_dev);
+ if (device) {
+ add_device(device, list, &num_devices, &list_size);
+ sysfs_dev->have_driver = 1;
+ } else
+ no_driver = 1;
+ }
+
+ if (!no_driver)
+ goto out;
+
+ /*
+ * Check if we can dlopen() ourselves. If this fails,
+ * libibverbs is probably statically linked into the
+ * executable, and we should just give up, since trying to
+ * dlopen() a driver module will fail spectacularly (loading a
+ * driver .so will bring in dynamic copies of libibverbs and
+ * libdl to go along with the static copies the executable
+ * has, which quickly leads to a crash.
+ */
+ {
+ void *hand = dlopen(NULL, RTLD_NOW);
+ if (!hand) {
+ fprintf(stderr, PFX "Warning: dlopen(NULL) failed, "
+ "assuming static linking.\n");
+ statically_linked = 1;
+ goto out;
+ }
+ dlclose(hand);
+ }
+
+ load_drivers();
+
+ for (sysfs_dev = sysfs_dev_list; sysfs_dev; sysfs_dev = sysfs_dev->next) {
+ if (sysfs_dev->have_driver)
+ continue;
+
+ device = try_drivers(sysfs_dev);
+ if (device) {
+ add_device(device, list, &num_devices, &list_size);
+ sysfs_dev->have_driver = 1;
+ }
+ }
+
+out:
+ for (sysfs_dev = sysfs_dev_list,
+ next_dev = sysfs_dev ? sysfs_dev->next : NULL;
+ sysfs_dev;
+ sysfs_dev = next_dev, next_dev = sysfs_dev ? sysfs_dev->next : NULL) {
+ if (!sysfs_dev->have_driver && getenv("IBV_SHOW_WARNINGS")) {
+ fprintf(stderr, PFX "Warning: no userspace device-specific "
+ "driver found for %s\n", sysfs_dev->sysfs_path);
+ if (statically_linked)
+ fprintf(stderr, " When linking libibverbs statically, "
+ "driver must be statically linked too.\n");
+ }
+ free(sysfs_dev);
+ }
+
+ return num_devices;
+}
diff --git a/contrib/ofed/libibverbs/kern-abi.h b/contrib/ofed/libibverbs/kern-abi.h
new file mode 100644
index 0000000..75a1caa
--- /dev/null
+++ b/contrib/ofed/libibverbs/kern-abi.h
@@ -0,0 +1,1339 @@
+/*
+ * Copyright (c) 2005 Topspin Communications. All rights reserved.
+ * Copyright (c) 2005, 2006 Cisco Systems. All rights reserved.
+ * Copyright (c) 2005 PathScale, Inc. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#ifndef KERN_ABI_H
+#define KERN_ABI_H
+
+#include <infiniband/types.h>
+
+/*
+ * This file must be kept in sync with the kernel's version of
+ * drivers/infiniband/include/ib_user_verbs.h
+ */
+
+/*
+ * The minimum and maximum kernel ABI that we can handle.
+ */
+#define IB_USER_VERBS_MIN_ABI_VERSION 3
+#define IB_USER_VERBS_MAX_ABI_VERSION 6
+
+#define IB_USER_VERBS_CMD_THRESHOLD 50
+
+enum {
+ IB_USER_VERBS_CMD_GET_CONTEXT,
+ IB_USER_VERBS_CMD_QUERY_DEVICE,
+ IB_USER_VERBS_CMD_QUERY_PORT,
+ IB_USER_VERBS_CMD_ALLOC_PD,
+ IB_USER_VERBS_CMD_DEALLOC_PD,
+ IB_USER_VERBS_CMD_CREATE_AH,
+ IB_USER_VERBS_CMD_MODIFY_AH,
+ IB_USER_VERBS_CMD_QUERY_AH,
+ IB_USER_VERBS_CMD_DESTROY_AH,
+ IB_USER_VERBS_CMD_REG_MR,
+ IB_USER_VERBS_CMD_REG_SMR,
+ IB_USER_VERBS_CMD_REREG_MR,
+ IB_USER_VERBS_CMD_QUERY_MR,
+ IB_USER_VERBS_CMD_DEREG_MR,
+ IB_USER_VERBS_CMD_ALLOC_MW,
+ IB_USER_VERBS_CMD_BIND_MW,
+ IB_USER_VERBS_CMD_DEALLOC_MW,
+ IB_USER_VERBS_CMD_CREATE_COMP_CHANNEL,
+ IB_USER_VERBS_CMD_CREATE_CQ,
+ IB_USER_VERBS_CMD_RESIZE_CQ,
+ IB_USER_VERBS_CMD_DESTROY_CQ,
+ IB_USER_VERBS_CMD_POLL_CQ,
+ IB_USER_VERBS_CMD_PEEK_CQ,
+ IB_USER_VERBS_CMD_REQ_NOTIFY_CQ,
+ IB_USER_VERBS_CMD_CREATE_QP,
+ IB_USER_VERBS_CMD_QUERY_QP,
+ IB_USER_VERBS_CMD_MODIFY_QP,
+ IB_USER_VERBS_CMD_DESTROY_QP,
+ IB_USER_VERBS_CMD_POST_SEND,
+ IB_USER_VERBS_CMD_POST_RECV,
+ IB_USER_VERBS_CMD_ATTACH_MCAST,
+ IB_USER_VERBS_CMD_DETACH_MCAST,
+ IB_USER_VERBS_CMD_CREATE_SRQ,
+ IB_USER_VERBS_CMD_MODIFY_SRQ,
+ IB_USER_VERBS_CMD_QUERY_SRQ,
+ IB_USER_VERBS_CMD_DESTROY_SRQ,
+ IB_USER_VERBS_CMD_POST_SRQ_RECV,
+ IB_USER_VERBS_CMD_OPEN_XRCD,
+ IB_USER_VERBS_CMD_CLOSE_XRCD,
+ IB_USER_VERBS_CMD_CREATE_XSRQ,
+ IB_USER_VERBS_CMD_OPEN_QP
+};
+
+#define IB_USER_VERBS_CMD_COMMAND_MASK 0xff
+#define IB_USER_VERBS_CMD_FLAGS_MASK 0xff000000u
+#define IB_USER_VERBS_CMD_FLAGS_SHIFT 24
+
+
+#define IB_USER_VERBS_CMD_FLAG_EXTENDED 0x80ul
+
+/* use this mask for creating extended commands */
+#define IB_USER_VERBS_CMD_EXTENDED_MASK \
+ (IB_USER_VERBS_CMD_FLAG_EXTENDED << \
+ IB_USER_VERBS_CMD_FLAGS_SHIFT)
+
+
+enum {
+ IB_USER_VERBS_CMD_QUERY_DEVICE_EX = IB_USER_VERBS_CMD_EXTENDED_MASK |
+ IB_USER_VERBS_CMD_QUERY_DEVICE,
+ IB_USER_VERBS_CMD_CREATE_QP_EX = IB_USER_VERBS_CMD_EXTENDED_MASK |
+ IB_USER_VERBS_CMD_CREATE_QP,
+ IB_USER_VERBS_CMD_CREATE_CQ_EX = IB_USER_VERBS_CMD_EXTENDED_MASK |
+ IB_USER_VERBS_CMD_CREATE_CQ,
+ IB_USER_VERBS_CMD_MODIFY_QP_EX = IB_USER_VERBS_CMD_EXTENDED_MASK |
+ IB_USER_VERBS_CMD_MODIFY_QP,
+ IB_USER_VERBS_CMD_CREATE_FLOW = IB_USER_VERBS_CMD_EXTENDED_MASK +
+ IB_USER_VERBS_CMD_THRESHOLD,
+ IB_USER_VERBS_CMD_DESTROY_FLOW,
+ IB_USER_VERBS_CMD_CREATE_WQ,
+ IB_USER_VERBS_CMD_MODIFY_WQ,
+ IB_USER_VERBS_CMD_DESTROY_WQ,
+ IB_USER_VERBS_CMD_CREATE_RWQ_IND_TBL,
+ IB_USER_VERBS_CMD_DESTROY_RWQ_IND_TBL,
+};
+
+/*
+ * Make sure that all structs defined in this file remain laid out so
+ * that they pack the same way on 32-bit and 64-bit architectures (to
+ * avoid incompatibility between 32-bit userspace and 64-bit kernels).
+ * Specifically:
+ * - Do not use pointer types -- pass pointers in __u64 instead.
+ * - Make sure that any structure larger than 4 bytes is padded to a
+ * multiple of 8 bytes. Otherwise the structure size will be
+ * different between 32-bit and 64-bit architectures.
+ */
+
+struct hdr {
+ __u32 command;
+ __u16 in_words;
+ __u16 out_words;
+};
+
+struct response_hdr {
+ __u64 response;
+};
+
+struct ex_hdr {
+ struct {
+ __u32 command;
+ __u16 in_words;
+ __u16 out_words;
+ };
+ struct {
+ __u64 response;
+ };
+ struct {
+ __u16 provider_in_words;
+ __u16 provider_out_words;
+ __u32 reserved;
+ };
+};
+
+struct ibv_kern_async_event {
+ __u64 element;
+ __u32 event_type;
+ __u32 reserved;
+};
+
+struct ibv_comp_event {
+ __u64 cq_handle;
+};
+
+/*
+ * All commands from userspace should start with a __u32 command field
+ * followed by __u16 in_words and out_words fields (which give the
+ * length of the command block and response buffer if any in 32-bit
+ * words). The kernel driver will read these fields first and read
+ * the rest of the command struct based on these value.
+ */
+
+struct ibv_query_params {
+ __u32 command;
+ __u16 in_words;
+ __u16 out_words;
+ __u64 response;
+};
+
+struct ibv_query_params_resp {
+ __u32 num_cq_events;
+};
+
+struct ibv_get_context {
+ __u32 command;
+ __u16 in_words;
+ __u16 out_words;
+ __u64 response;
+ __u64 driver_data[0];
+};
+
+struct ibv_get_context_resp {
+ __u32 async_fd;
+ __u32 num_comp_vectors;
+};
+
+struct ibv_query_device {
+ __u32 command;
+ __u16 in_words;
+ __u16 out_words;
+ __u64 response;
+ __u64 driver_data[0];
+};
+
+struct ibv_query_device_resp {
+ __u64 fw_ver;
+ __be64 node_guid;
+ __be64 sys_image_guid;
+ __u64 max_mr_size;
+ __u64 page_size_cap;
+ __u32 vendor_id;
+ __u32 vendor_part_id;
+ __u32 hw_ver;
+ __u32 max_qp;
+ __u32 max_qp_wr;
+ __u32 device_cap_flags;
+ __u32 max_sge;
+ __u32 max_sge_rd;
+ __u32 max_cq;
+ __u32 max_cqe;
+ __u32 max_mr;
+ __u32 max_pd;
+ __u32 max_qp_rd_atom;
+ __u32 max_ee_rd_atom;
+ __u32 max_res_rd_atom;
+ __u32 max_qp_init_rd_atom;
+ __u32 max_ee_init_rd_atom;
+ __u32 atomic_cap;
+ __u32 max_ee;
+ __u32 max_rdd;
+ __u32 max_mw;
+ __u32 max_raw_ipv6_qp;
+ __u32 max_raw_ethy_qp;
+ __u32 max_mcast_grp;
+ __u32 max_mcast_qp_attach;
+ __u32 max_total_mcast_qp_attach;
+ __u32 max_ah;
+ __u32 max_fmr;
+ __u32 max_map_per_fmr;
+ __u32 max_srq;
+ __u32 max_srq_wr;
+ __u32 max_srq_sge;
+ __u16 max_pkeys;
+ __u8 local_ca_ack_delay;
+ __u8 phys_port_cnt;
+ __u8 reserved[4];
+};
+
+struct ibv_query_device_ex {
+ struct ex_hdr hdr;
+ __u32 comp_mask;
+ __u32 reserved;
+};
+
+struct ibv_odp_caps_resp {
+ __u64 general_caps;
+ struct {
+ __u32 rc_odp_caps;
+ __u32 uc_odp_caps;
+ __u32 ud_odp_caps;
+ } per_transport_caps;
+ __u32 reserved;
+};
+
+struct ibv_rss_caps_resp {
+ __u32 supported_qpts;
+ __u32 max_rwq_indirection_tables;
+ __u32 max_rwq_indirection_table_size;
+ __u32 reserved;
+};
+
+struct ibv_query_device_resp_ex {
+ struct ibv_query_device_resp base;
+ __u32 comp_mask;
+ __u32 response_length;
+ struct ibv_odp_caps_resp odp_caps;
+ __u64 timestamp_mask;
+ __u64 hca_core_clock;
+ __u64 device_cap_flags_ex;
+ struct ibv_rss_caps_resp rss_caps;
+ __u32 max_wq_type_rq;
+ __u32 raw_packet_caps;
+};
+
+struct ibv_query_port {
+ __u32 command;
+ __u16 in_words;
+ __u16 out_words;
+ __u64 response;
+ __u8 port_num;
+ __u8 reserved[7];
+ __u64 driver_data[0];
+};
+
+struct ibv_query_port_resp {
+ __u32 port_cap_flags;
+ __u32 max_msg_sz;
+ __u32 bad_pkey_cntr;
+ __u32 qkey_viol_cntr;
+ __u32 gid_tbl_len;
+ __u16 pkey_tbl_len;
+ __u16 lid;
+ __u16 sm_lid;
+ __u8 state;
+ __u8 max_mtu;
+ __u8 active_mtu;
+ __u8 lmc;
+ __u8 max_vl_num;
+ __u8 sm_sl;
+ __u8 subnet_timeout;
+ __u8 init_type_reply;
+ __u8 active_width;
+ __u8 active_speed;
+ __u8 phys_state;
+ __u8 link_layer;
+ __u8 reserved[2];
+};
+
+struct ibv_alloc_pd {
+ __u32 command;
+ __u16 in_words;
+ __u16 out_words;
+ __u64 response;
+ __u64 driver_data[0];
+};
+
+struct ibv_alloc_pd_resp {
+ __u32 pd_handle;
+};
+
+struct ibv_dealloc_pd {
+ __u32 command;
+ __u16 in_words;
+ __u16 out_words;
+ __u32 pd_handle;
+};
+
+struct ibv_open_xrcd {
+ __u32 command;
+ __u16 in_words;
+ __u16 out_words;
+ __u64 response;
+ __u32 fd;
+ __u32 oflags;
+ __u64 driver_data[0];
+};
+
+struct ibv_open_xrcd_resp {
+ __u32 xrcd_handle;
+};
+
+struct ibv_close_xrcd {
+ __u32 command;
+ __u16 in_words;
+ __u16 out_words;
+ __u32 xrcd_handle;
+};
+
+struct ibv_reg_mr {
+ __u32 command;
+ __u16 in_words;
+ __u16 out_words;
+ __u64 response;
+ __u64 start;
+ __u64 length;
+ __u64 hca_va;
+ __u32 pd_handle;
+ __u32 access_flags;
+ __u64 driver_data[0];
+};
+
+struct ibv_reg_mr_resp {
+ __u32 mr_handle;
+ __u32 lkey;
+ __u32 rkey;
+};
+
+struct ibv_rereg_mr {
+ __u32 command;
+ __u16 in_words;
+ __u16 out_words;
+ __u64 response;
+ __u32 mr_handle;
+ __u32 flags;
+ __u64 start;
+ __u64 length;
+ __u64 hca_va;
+ __u32 pd_handle;
+ __u32 access_flags;
+ __u64 driver_data[0];
+};
+
+struct ibv_rereg_mr_resp {
+ __u32 lkey;
+ __u32 rkey;
+};
+
+struct ibv_dereg_mr {
+ __u32 command;
+ __u16 in_words;
+ __u16 out_words;
+ __u32 mr_handle;
+};
+
+struct ibv_alloc_mw {
+ __u32 command;
+ __u16 in_words;
+ __u16 out_words;
+ __u64 response;
+ __u32 pd_handle;
+ __u8 mw_type;
+ __u8 reserved[3];
+};
+
+struct ibv_alloc_mw_resp {
+ __u32 mw_handle;
+ __u32 rkey;
+};
+
+struct ibv_dealloc_mw {
+ __u32 command;
+ __u16 in_words;
+ __u16 out_words;
+ __u32 mw_handle;
+ __u32 reserved;
+};
+
+struct ibv_create_comp_channel {
+ __u32 command;
+ __u16 in_words;
+ __u16 out_words;
+ __u64 response;
+};
+
+struct ibv_create_comp_channel_resp {
+ __u32 fd;
+};
+
+struct ibv_create_cq {
+ __u32 command;
+ __u16 in_words;
+ __u16 out_words;
+ __u64 response;
+ __u64 user_handle;
+ __u32 cqe;
+ __u32 comp_vector;
+ __s32 comp_channel;
+ __u32 reserved;
+ __u64 driver_data[0];
+};
+
+struct ibv_create_cq_resp {
+ __u32 cq_handle;
+ __u32 cqe;
+};
+
+enum ibv_create_cq_ex_kernel_flags {
+ IBV_CREATE_CQ_EX_KERNEL_FLAG_COMPLETION_TIMESTAMP = 1 << 0,
+};
+
+struct ibv_create_cq_ex {
+ struct ex_hdr hdr;
+ __u64 user_handle;
+ __u32 cqe;
+ __u32 comp_vector;
+ __s32 comp_channel;
+ __u32 comp_mask;
+ __u32 flags;
+ __u32 reserved;
+};
+
+struct ibv_create_cq_resp_ex {
+ struct ibv_create_cq_resp base;
+ __u32 comp_mask;
+ __u32 response_length;
+};
+
+struct ibv_kern_wc {
+ __u64 wr_id;
+ __u32 status;
+ __u32 opcode;
+ __u32 vendor_err;
+ __u32 byte_len;
+ __be32 imm_data;
+ __u32 qp_num;
+ __u32 src_qp;
+ __u32 wc_flags;
+ __u16 pkey_index;
+ __u16 slid;
+ __u8 sl;
+ __u8 dlid_path_bits;
+ __u8 port_num;
+ __u8 reserved;
+};
+
+struct ibv_poll_cq {
+ __u32 command;
+ __u16 in_words;
+ __u16 out_words;
+ __u64 response;
+ __u32 cq_handle;
+ __u32 ne;
+};
+
+struct ibv_poll_cq_resp {
+ __u32 count;
+ __u32 reserved;
+ struct ibv_kern_wc wc[0];
+};
+
+struct ibv_req_notify_cq {
+ __u32 command;
+ __u16 in_words;
+ __u16 out_words;
+ __u32 cq_handle;
+ __u32 solicited;
+};
+
+struct ibv_resize_cq {
+ __u32 command;
+ __u16 in_words;
+ __u16 out_words;
+ __u64 response;
+ __u32 cq_handle;
+ __u32 cqe;
+ __u64 driver_data[0];
+};
+
+struct ibv_resize_cq_resp {
+ __u32 cqe;
+ __u32 reserved;
+ __u64 driver_data[0];
+};
+
+struct ibv_destroy_cq {
+ __u32 command;
+ __u16 in_words;
+ __u16 out_words;
+ __u64 response;
+ __u32 cq_handle;
+ __u32 reserved;
+};
+
+struct ibv_destroy_cq_resp {
+ __u32 comp_events_reported;
+ __u32 async_events_reported;
+};
+
+struct ibv_kern_global_route {
+ __u8 dgid[16];
+ __u32 flow_label;
+ __u8 sgid_index;
+ __u8 hop_limit;
+ __u8 traffic_class;
+ __u8 reserved;
+};
+
+struct ibv_kern_ah_attr {
+ struct ibv_kern_global_route grh;
+ __u16 dlid;
+ __u8 sl;
+ __u8 src_path_bits;
+ __u8 static_rate;
+ __u8 is_global;
+ __u8 port_num;
+ __u8 reserved;
+};
+
+struct ibv_kern_qp_attr {
+ __u32 qp_attr_mask;
+ __u32 qp_state;
+ __u32 cur_qp_state;
+ __u32 path_mtu;
+ __u32 path_mig_state;
+ __u32 qkey;
+ __u32 rq_psn;
+ __u32 sq_psn;
+ __u32 dest_qp_num;
+ __u32 qp_access_flags;
+
+ struct ibv_kern_ah_attr ah_attr;
+ struct ibv_kern_ah_attr alt_ah_attr;
+
+ /* ib_qp_cap */
+ __u32 max_send_wr;
+ __u32 max_recv_wr;
+ __u32 max_send_sge;
+ __u32 max_recv_sge;
+ __u32 max_inline_data;
+
+ __u16 pkey_index;
+ __u16 alt_pkey_index;
+ __u8 en_sqd_async_notify;
+ __u8 sq_draining;
+ __u8 max_rd_atomic;
+ __u8 max_dest_rd_atomic;
+ __u8 min_rnr_timer;
+ __u8 port_num;
+ __u8 timeout;
+ __u8 retry_cnt;
+ __u8 rnr_retry;
+ __u8 alt_port_num;
+ __u8 alt_timeout;
+ __u8 reserved[5];
+};
+
+#define IBV_CREATE_QP_COMMON \
+ __u64 user_handle; \
+ __u32 pd_handle; \
+ __u32 send_cq_handle; \
+ __u32 recv_cq_handle; \
+ __u32 srq_handle; \
+ __u32 max_send_wr; \
+ __u32 max_recv_wr; \
+ __u32 max_send_sge; \
+ __u32 max_recv_sge; \
+ __u32 max_inline_data; \
+ __u8 sq_sig_all; \
+ __u8 qp_type; \
+ __u8 is_srq; \
+ __u8 reserved
+
+struct ibv_create_qp {
+ __u32 command;
+ __u16 in_words;
+ __u16 out_words;
+ __u64 response;
+ IBV_CREATE_QP_COMMON;
+ __u64 driver_data[0];
+};
+
+struct ibv_create_qp_common {
+ IBV_CREATE_QP_COMMON;
+};
+
+struct ibv_open_qp {
+ __u32 command;
+ __u16 in_words;
+ __u16 out_words;
+ __u64 response;
+ __u64 user_handle;
+ __u32 pd_handle;
+ __u32 qpn;
+ __u8 qp_type;
+ __u8 reserved[7];
+ __u64 driver_data[0];
+};
+
+/* also used for open response */
+struct ibv_create_qp_resp {
+ __u32 qp_handle;
+ __u32 qpn;
+ __u32 max_send_wr;
+ __u32 max_recv_wr;
+ __u32 max_send_sge;
+ __u32 max_recv_sge;
+ __u32 max_inline_data;
+ __u32 reserved;
+};
+
+enum ibv_create_qp_ex_kernel_mask {
+ IBV_CREATE_QP_EX_KERNEL_MASK_IND_TABLE = 1 << 0,
+};
+
+struct ibv_create_qp_ex {
+ struct ex_hdr hdr;
+ struct ibv_create_qp_common base;
+ __u32 comp_mask;
+ __u32 create_flags;
+ __u32 ind_tbl_handle;
+ __u32 reserved1;
+};
+
+struct ibv_create_qp_resp_ex {
+ struct ibv_create_qp_resp base;
+ __u32 comp_mask;
+ __u32 response_length;
+};
+
+struct ibv_qp_dest {
+ __u8 dgid[16];
+ __u32 flow_label;
+ __u16 dlid;
+ __u16 reserved;
+ __u8 sgid_index;
+ __u8 hop_limit;
+ __u8 traffic_class;
+ __u8 sl;
+ __u8 src_path_bits;
+ __u8 static_rate;
+ __u8 is_global;
+ __u8 port_num;
+};
+
+struct ibv_query_qp {
+ __u32 command;
+ __u16 in_words;
+ __u16 out_words;
+ __u64 response;
+ __u32 qp_handle;
+ __u32 attr_mask;
+ __u64 driver_data[0];
+};
+
+struct ibv_query_qp_resp {
+ struct ibv_qp_dest dest;
+ struct ibv_qp_dest alt_dest;
+ __u32 max_send_wr;
+ __u32 max_recv_wr;
+ __u32 max_send_sge;
+ __u32 max_recv_sge;
+ __u32 max_inline_data;
+ __u32 qkey;
+ __u32 rq_psn;
+ __u32 sq_psn;
+ __u32 dest_qp_num;
+ __u32 qp_access_flags;
+ __u16 pkey_index;
+ __u16 alt_pkey_index;
+ __u8 qp_state;
+ __u8 cur_qp_state;
+ __u8 path_mtu;
+ __u8 path_mig_state;
+ __u8 sq_draining;
+ __u8 max_rd_atomic;
+ __u8 max_dest_rd_atomic;
+ __u8 min_rnr_timer;
+ __u8 port_num;
+ __u8 timeout;
+ __u8 retry_cnt;
+ __u8 rnr_retry;
+ __u8 alt_port_num;
+ __u8 alt_timeout;
+ __u8 sq_sig_all;
+ __u8 reserved[5];
+ __u64 driver_data[0];
+};
+
+struct ibv_modify_qp_common {
+ struct ibv_qp_dest dest;
+ struct ibv_qp_dest alt_dest;
+ __u32 qp_handle;
+ __u32 attr_mask;
+ __u32 qkey;
+ __u32 rq_psn;
+ __u32 sq_psn;
+ __u32 dest_qp_num;
+ __u32 qp_access_flags;
+ __u16 pkey_index;
+ __u16 alt_pkey_index;
+ __u8 qp_state;
+ __u8 cur_qp_state;
+ __u8 path_mtu;
+ __u8 path_mig_state;
+ __u8 en_sqd_async_notify;
+ __u8 max_rd_atomic;
+ __u8 max_dest_rd_atomic;
+ __u8 min_rnr_timer;
+ __u8 port_num;
+ __u8 timeout;
+ __u8 retry_cnt;
+ __u8 rnr_retry;
+ __u8 alt_port_num;
+ __u8 alt_timeout;
+ __u8 reserved[2];
+};
+
+struct ibv_modify_qp {
+ __u32 command;
+ __u16 in_words;
+ __u16 out_words;
+ struct ibv_modify_qp_common base;
+ __u64 driver_data[0];
+};
+
+struct ibv_modify_qp_ex {
+ struct ex_hdr hdr;
+ struct ibv_modify_qp_common base;
+ __u32 rate_limit;
+ __u32 reserved;
+};
+
+struct ibv_modify_qp_resp_ex {
+ __u32 comp_mask;
+ __u32 response_length;
+};
+
+struct ibv_destroy_qp {
+ __u32 command;
+ __u16 in_words;
+ __u16 out_words;
+ __u64 response;
+ __u32 qp_handle;
+ __u32 reserved;
+};
+
+struct ibv_destroy_qp_resp {
+ __u32 events_reported;
+};
+
+struct ibv_kern_send_wr {
+ __u64 wr_id;
+ __u32 num_sge;
+ __u32 opcode;
+ __u32 send_flags;
+ __be32 imm_data;
+ union {
+ struct {
+ __u64 remote_addr;
+ __u32 rkey;
+ __u32 reserved;
+ } rdma;
+ struct {
+ __u64 remote_addr;
+ __u64 compare_add;
+ __u64 swap;
+ __u32 rkey;
+ __u32 reserved;
+ } atomic;
+ struct {
+ __u32 ah;
+ __u32 remote_qpn;
+ __u32 remote_qkey;
+ __u32 reserved;
+ } ud;
+ } wr;
+ union {
+ struct {
+ __u32 remote_srqn;
+ } xrc;
+ } qp_type;
+};
+
+struct ibv_kern_eth_filter {
+ __u8 dst_mac[6];
+ __u8 src_mac[6];
+ __u16 ether_type;
+ __u16 vlan_tag;
+};
+
+struct ibv_kern_spec_eth {
+ __u32 type;
+ __u16 size;
+ __u16 reserved;
+ struct ibv_kern_eth_filter val;
+ struct ibv_kern_eth_filter mask;
+};
+
+struct ibv_kern_ipv4_filter {
+ __u32 src_ip;
+ __u32 dst_ip;
+};
+
+struct ibv_kern_spec_ipv4 {
+ __u32 type;
+ __u16 size;
+ __u16 reserved;
+ struct ibv_kern_ipv4_filter val;
+ struct ibv_kern_ipv4_filter mask;
+};
+
+struct ibv_kern_ipv4_ext_filter {
+ __u32 src_ip;
+ __u32 dst_ip;
+ __u8 proto;
+ __u8 tos;
+ __u8 ttl;
+ __u8 flags;
+};
+
+struct ibv_kern_spec_ipv4_ext {
+ __u32 type;
+ __u16 size;
+ __u16 reserved;
+ struct ibv_kern_ipv4_ext_filter val;
+ struct ibv_kern_ipv4_ext_filter mask;
+};
+
+struct ibv_kern_ipv6_filter {
+ __u8 src_ip[16];
+ __u8 dst_ip[16];
+ __u32 flow_label;
+ __u8 next_hdr;
+ __u8 traffic_class;
+ __u8 hop_limit;
+ __u8 reserved;
+};
+
+struct ibv_kern_spec_ipv6 {
+ __u32 type;
+ __u16 size;
+ __u16 reserved;
+ struct ibv_kern_ipv6_filter val;
+ struct ibv_kern_ipv6_filter mask;
+};
+
+struct ibv_kern_tcp_udp_filter {
+ __u16 dst_port;
+ __u16 src_port;
+};
+
+struct ibv_kern_spec_tcp_udp {
+ __u32 type;
+ __u16 size;
+ __u16 reserved;
+ struct ibv_kern_tcp_udp_filter val;
+ struct ibv_kern_tcp_udp_filter mask;
+};
+
+struct ibv_kern_spec_action_tag {
+ __u32 type;
+ __u16 size;
+ __u16 reserved;
+ __u32 tag_id;
+ __u32 reserved1;
+};
+
+struct ibv_kern_tunnel_filter {
+ __u32 tunnel_id;
+};
+
+struct ibv_kern_spec_tunnel {
+ __u32 type;
+ __u16 size;
+ __u16 reserved;
+ struct ibv_kern_tunnel_filter val;
+ struct ibv_kern_tunnel_filter mask;
+};
+
+struct ibv_kern_spec_action_drop {
+ __u32 type;
+ __u16 size;
+ __u16 reserved;
+};
+
+struct ibv_kern_spec {
+ union {
+ struct {
+ __u32 type;
+ __u16 size;
+ __u16 reserved;
+ } hdr;
+ struct ibv_kern_spec_eth eth;
+ struct ibv_kern_spec_ipv4 ipv4;
+ struct ibv_kern_spec_ipv4_ext ipv4_ext;
+ struct ibv_kern_spec_tcp_udp tcp_udp;
+ struct ibv_kern_spec_ipv6 ipv6;
+ struct ibv_kern_spec_tunnel tunnel;
+ struct ibv_kern_spec_action_tag flow_tag;
+ struct ibv_kern_spec_action_drop drop;
+ };
+};
+
+struct ibv_kern_flow_attr {
+ __u32 type;
+ __u16 size;
+ __u16 priority;
+ __u8 num_of_specs;
+ __u8 reserved[2];
+ __u8 port;
+ __u32 flags;
+ /* Following are the optional layers according to user request
+ * struct ibv_kern_flow_spec_xxx
+ * struct ibv_kern_flow_spec_yyy
+ */
+};
+
+struct ibv_post_send {
+ __u32 command;
+ __u16 in_words;
+ __u16 out_words;
+ __u64 response;
+ __u32 qp_handle;
+ __u32 wr_count;
+ __u32 sge_count;
+ __u32 wqe_size;
+ struct ibv_kern_send_wr send_wr[0];
+};
+
+struct ibv_post_send_resp {
+ __u32 bad_wr;
+};
+
+struct ibv_kern_recv_wr {
+ __u64 wr_id;
+ __u32 num_sge;
+ __u32 reserved;
+};
+
+struct ibv_post_recv {
+ __u32 command;
+ __u16 in_words;
+ __u16 out_words;
+ __u64 response;
+ __u32 qp_handle;
+ __u32 wr_count;
+ __u32 sge_count;
+ __u32 wqe_size;
+ struct ibv_kern_recv_wr recv_wr[0];
+};
+
+struct ibv_post_recv_resp {
+ __u32 bad_wr;
+};
+
+struct ibv_post_srq_recv {
+ __u32 command;
+ __u16 in_words;
+ __u16 out_words;
+ __u64 response;
+ __u32 srq_handle;
+ __u32 wr_count;
+ __u32 sge_count;
+ __u32 wqe_size;
+ struct ibv_kern_recv_wr recv_wr[0];
+};
+
+struct ibv_post_srq_recv_resp {
+ __u32 bad_wr;
+};
+
+struct ibv_create_ah {
+ __u32 command;
+ __u16 in_words;
+ __u16 out_words;
+ __u64 response;
+ __u64 user_handle;
+ __u32 pd_handle;
+ __u32 reserved;
+ struct ibv_kern_ah_attr attr;
+};
+
+struct ibv_create_ah_resp {
+ __u32 handle;
+};
+
+struct ibv_destroy_ah {
+ __u32 command;
+ __u16 in_words;
+ __u16 out_words;
+ __u32 ah_handle;
+};
+
+struct ibv_attach_mcast {
+ __u32 command;
+ __u16 in_words;
+ __u16 out_words;
+ __u8 gid[16];
+ __u32 qp_handle;
+ __u16 mlid;
+ __u16 reserved;
+ __u64 driver_data[0];
+};
+
+struct ibv_create_flow {
+ struct ex_hdr hdr;
+ __u32 comp_mask;
+ __u32 qp_handle;
+ struct ibv_kern_flow_attr flow_attr;
+};
+
+struct ibv_create_flow_resp {
+ __u32 comp_mask;
+ __u32 flow_handle;
+};
+
+struct ibv_destroy_flow {
+ struct ex_hdr hdr;
+ __u32 comp_mask;
+ __u32 flow_handle;
+};
+
+struct ibv_detach_mcast {
+ __u32 command;
+ __u16 in_words;
+ __u16 out_words;
+ __u8 gid[16];
+ __u32 qp_handle;
+ __u16 mlid;
+ __u16 reserved;
+ __u64 driver_data[0];
+};
+
+struct ibv_create_srq {
+ __u32 command;
+ __u16 in_words;
+ __u16 out_words;
+ __u64 response;
+ __u64 user_handle;
+ __u32 pd_handle;
+ __u32 max_wr;
+ __u32 max_sge;
+ __u32 srq_limit;
+ __u64 driver_data[0];
+};
+
+struct ibv_create_xsrq {
+ __u32 command;
+ __u16 in_words;
+ __u16 out_words;
+ __u64 response;
+ __u64 user_handle;
+ __u32 srq_type;
+ __u32 pd_handle;
+ __u32 max_wr;
+ __u32 max_sge;
+ __u32 srq_limit;
+ __u32 reserved;
+ __u32 xrcd_handle;
+ __u32 cq_handle;
+ __u64 driver_data[0];
+};
+
+struct ibv_create_srq_resp {
+ __u32 srq_handle;
+ __u32 max_wr;
+ __u32 max_sge;
+ __u32 srqn;
+};
+
+struct ibv_modify_srq {
+ __u32 command;
+ __u16 in_words;
+ __u16 out_words;
+ __u32 srq_handle;
+ __u32 attr_mask;
+ __u32 max_wr;
+ __u32 srq_limit;
+ __u64 driver_data[0];
+};
+
+struct ibv_query_srq {
+ __u32 command;
+ __u16 in_words;
+ __u16 out_words;
+ __u64 response;
+ __u32 srq_handle;
+ __u32 reserved;
+ __u64 driver_data[0];
+};
+
+struct ibv_query_srq_resp {
+ __u32 max_wr;
+ __u32 max_sge;
+ __u32 srq_limit;
+ __u32 reserved;
+};
+
+struct ibv_destroy_srq {
+ __u32 command;
+ __u16 in_words;
+ __u16 out_words;
+ __u64 response;
+ __u32 srq_handle;
+ __u32 reserved;
+};
+
+struct ibv_destroy_srq_resp {
+ __u32 events_reported;
+};
+
+/*
+ * Compatibility with older ABI versions
+ */
+
+enum {
+ IB_USER_VERBS_CMD_QUERY_PARAMS_V2,
+ IB_USER_VERBS_CMD_GET_CONTEXT_V2,
+ IB_USER_VERBS_CMD_QUERY_DEVICE_V2,
+ IB_USER_VERBS_CMD_QUERY_PORT_V2,
+ IB_USER_VERBS_CMD_QUERY_GID_V2,
+ IB_USER_VERBS_CMD_QUERY_PKEY_V2,
+ IB_USER_VERBS_CMD_ALLOC_PD_V2,
+ IB_USER_VERBS_CMD_DEALLOC_PD_V2,
+ IB_USER_VERBS_CMD_CREATE_AH_V2,
+ IB_USER_VERBS_CMD_MODIFY_AH_V2,
+ IB_USER_VERBS_CMD_QUERY_AH_V2,
+ IB_USER_VERBS_CMD_DESTROY_AH_V2,
+ IB_USER_VERBS_CMD_REG_MR_V2,
+ IB_USER_VERBS_CMD_REG_SMR_V2,
+ IB_USER_VERBS_CMD_REREG_MR_V2,
+ IB_USER_VERBS_CMD_QUERY_MR_V2,
+ IB_USER_VERBS_CMD_DEREG_MR_V2,
+ IB_USER_VERBS_CMD_ALLOC_MW_V2,
+ IB_USER_VERBS_CMD_BIND_MW_V2,
+ IB_USER_VERBS_CMD_DEALLOC_MW_V2,
+ IB_USER_VERBS_CMD_CREATE_CQ_V2,
+ IB_USER_VERBS_CMD_RESIZE_CQ_V2,
+ IB_USER_VERBS_CMD_DESTROY_CQ_V2,
+ IB_USER_VERBS_CMD_POLL_CQ_V2,
+ IB_USER_VERBS_CMD_PEEK_CQ_V2,
+ IB_USER_VERBS_CMD_REQ_NOTIFY_CQ_V2,
+ IB_USER_VERBS_CMD_CREATE_QP_V2,
+ IB_USER_VERBS_CMD_QUERY_QP_V2,
+ IB_USER_VERBS_CMD_MODIFY_QP_V2,
+ IB_USER_VERBS_CMD_DESTROY_QP_V2,
+ IB_USER_VERBS_CMD_POST_SEND_V2,
+ IB_USER_VERBS_CMD_POST_RECV_V2,
+ IB_USER_VERBS_CMD_ATTACH_MCAST_V2,
+ IB_USER_VERBS_CMD_DETACH_MCAST_V2,
+ IB_USER_VERBS_CMD_CREATE_SRQ_V2,
+ IB_USER_VERBS_CMD_MODIFY_SRQ_V2,
+ IB_USER_VERBS_CMD_QUERY_SRQ_V2,
+ IB_USER_VERBS_CMD_DESTROY_SRQ_V2,
+ IB_USER_VERBS_CMD_POST_SRQ_RECV_V2,
+ /*
+ * Set commands that didn't exist to -1 so our compile-time
+ * trick opcodes in IBV_INIT_CMD() doesn't break.
+ */
+ IB_USER_VERBS_CMD_CREATE_COMP_CHANNEL_V2 = -1,
+ IB_USER_VERBS_CMD_OPEN_XRCD_V2 = -1,
+ IB_USER_VERBS_CMD_CLOSE_XRCD_V2 = -1,
+ IB_USER_VERBS_CMD_CREATE_XSRQ_V2 = -1,
+ IB_USER_VERBS_CMD_OPEN_QP_V2 = -1,
+ IB_USER_VERBS_CMD_CREATE_FLOW_V2 = -1,
+ IB_USER_VERBS_CMD_DESTROY_FLOW_V2 = -1,
+ IB_USER_VERBS_CMD_QUERY_DEVICE_EX_V2 = -1,
+ IB_USER_VERBS_CMD_CREATE_QP_EX_V2 = -1,
+ IB_USER_VERBS_CMD_CREATE_CQ_EX_V2 = -1,
+ IB_USER_VERBS_CMD_CREATE_WQ_V2 = -1,
+ IB_USER_VERBS_CMD_MODIFY_WQ_V2 = -1,
+ IB_USER_VERBS_CMD_DESTROY_WQ_V2 = -1,
+ IB_USER_VERBS_CMD_CREATE_RWQ_IND_TBL_V2 = -1,
+ IB_USER_VERBS_CMD_DESTROY_RWQ_IND_TBL_V2 = -1,
+ IB_USER_VERBS_CMD_MODIFY_QP_EX_V2 = -1,
+};
+
+struct ibv_modify_srq_v3 {
+ __u32 command;
+ __u16 in_words;
+ __u16 out_words;
+ __u32 srq_handle;
+ __u32 attr_mask;
+ __u32 max_wr;
+ __u32 max_sge;
+ __u32 srq_limit;
+ __u32 reserved;
+ __u64 driver_data[0];
+};
+
+struct ibv_create_qp_resp_v3 {
+ __u32 qp_handle;
+ __u32 qpn;
+};
+
+struct ibv_create_qp_resp_v4 {
+ __u32 qp_handle;
+ __u32 qpn;
+ __u32 max_send_wr;
+ __u32 max_recv_wr;
+ __u32 max_send_sge;
+ __u32 max_recv_sge;
+ __u32 max_inline_data;
+};
+
+struct ibv_create_srq_resp_v5 {
+ __u32 srq_handle;
+};
+
+struct ibv_create_wq {
+ struct ex_hdr hdr;
+ __u32 comp_mask;
+ __u32 wq_type;
+ __u64 user_handle;
+ __u32 pd_handle;
+ __u32 cq_handle;
+ __u32 max_wr;
+ __u32 max_sge;
+ __u32 create_flags;
+ __u32 reserved;
+};
+
+struct ibv_create_wq_resp {
+ __u32 comp_mask;
+ __u32 response_length;
+ __u32 wq_handle;
+ __u32 max_wr;
+ __u32 max_sge;
+ __u32 wqn;
+};
+
+struct ibv_destroy_wq {
+ struct ex_hdr hdr;
+ __u32 comp_mask;
+ __u32 wq_handle;
+};
+
+struct ibv_destroy_wq_resp {
+ __u32 comp_mask;
+ __u32 response_length;
+ __u32 events_reported;
+ __u32 reserved;
+};
+
+struct ibv_modify_wq {
+ struct ex_hdr hdr;
+ __u32 attr_mask;
+ __u32 wq_handle;
+ __u32 wq_state;
+ __u32 curr_wq_state;
+ __u32 flags;
+ __u32 flags_mask;
+};
+
+struct ibv_create_rwq_ind_table {
+ struct ex_hdr hdr;
+ __u32 comp_mask;
+ __u32 log_ind_tbl_size;
+ /* Following are wq handles based on log_ind_tbl_size, must be 64 bytes aligned.
+ * __u32 wq_handle1
+ * __u32 wq_handle2
+ */
+};
+
+struct ibv_create_rwq_ind_table_resp {
+ __u32 comp_mask;
+ __u32 response_length;
+ __u32 ind_tbl_handle;
+ __u32 ind_tbl_num;
+};
+
+struct ibv_destroy_rwq_ind_table {
+ struct ex_hdr hdr;
+ __u32 comp_mask;
+ __u32 ind_tbl_handle;
+};
+
+#endif /* KERN_ABI_H */
diff --git a/contrib/ofed/libibverbs/libibverbs.map b/contrib/ofed/libibverbs/libibverbs.map
new file mode 100644
index 0000000..5401241
--- /dev/null
+++ b/contrib/ofed/libibverbs/libibverbs.map
@@ -0,0 +1,142 @@
+/* Do not change this file without reading Documentation/versioning.md */
+IBVERBS_1.0 {
+ global:
+ ibv_get_device_list;
+ ibv_free_device_list;
+ ibv_get_device_name;
+ ibv_get_device_guid;
+ ibv_open_device;
+ ibv_close_device;
+ ibv_get_async_event;
+ ibv_ack_async_event;
+ ibv_query_device;
+ ibv_query_device_ex;
+ ibv_query_port;
+ ibv_query_gid;
+ ibv_query_pkey;
+ ibv_alloc_pd;
+ ibv_dealloc_pd;
+ ibv_reg_mr;
+ ibv_dereg_mr;
+ ibv_create_comp_channel;
+ ibv_destroy_comp_channel;
+ ibv_create_cq;
+ ibv_resize_cq;
+ ibv_destroy_cq;
+ ibv_get_cq_event;
+ ibv_ack_cq_events;
+ ibv_create_srq;
+ ibv_modify_srq;
+ ibv_query_srq;
+ ibv_destroy_srq;
+ ibv_create_qp;
+ ibv_query_qp;
+ ibv_modify_qp;
+ ibv_destroy_qp;
+ ibv_create_ah;
+ ibv_destroy_ah;
+ ibv_attach_mcast;
+ ibv_detach_mcast;
+ ibv_rate_to_mult;
+ mult_to_ibv_rate;
+
+ /* These historical symbols are now private to libibverbs, but used by
+ other rdma-core libraries. Do not change them. */
+ ibv_copy_path_rec_from_kern;
+ ibv_copy_path_rec_to_kern;
+ ibv_copy_qp_attr_from_kern;
+ ibv_get_sysfs_path;
+ ibv_read_sysfs_file;
+
+ local: *;
+};
+
+IBVERBS_1.1 {
+ global:
+ ibv_get_device_list;
+ ibv_free_device_list;
+ ibv_get_device_name;
+ ibv_get_device_guid;
+ ibv_open_device;
+ ibv_close_device;
+
+ ibv_init_ah_from_wc;
+ ibv_create_ah_from_wc;
+ ibv_fork_init;
+ ibv_dontfork_range;
+ ibv_dofork_range;
+ ibv_register_driver;
+
+ ibv_node_type_str;
+ ibv_port_state_str;
+ ibv_event_type_str;
+ ibv_wc_status_str;
+
+ ibv_rate_to_mbps;
+ mbps_to_ibv_rate;
+
+ ibv_resolve_eth_l2_from_gid;
+
+ /* These historical symbols are now private to libibverbs, but used by
+ other rdma-core libraries. Do not change them. */
+ ibv_copy_ah_attr_from_kern;
+} IBVERBS_1.0;
+
+/* NOTE: The next stanza for public symbols should be IBVERBS_1.4 due to release 12 */
+
+/* If any symbols in this stanza change ABI then the entire staza gets a new symbol
+ version. Also see the private_symver() macro */
+IBVERBS_PRIVATE_14 {
+ global:
+ /* These historical symbols are now private to libibverbs */
+ ibv_cmd_alloc_mw;
+ ibv_cmd_alloc_pd;
+ ibv_cmd_attach_mcast;
+ ibv_cmd_close_xrcd;
+ ibv_cmd_create_ah;
+ ibv_cmd_create_cq;
+ ibv_cmd_create_cq_ex;
+ ibv_cmd_create_flow;
+ ibv_cmd_create_qp;
+ ibv_cmd_create_qp_ex2;
+ ibv_cmd_create_qp_ex;
+ ibv_cmd_create_rwq_ind_table;
+ ibv_cmd_create_srq;
+ ibv_cmd_create_srq_ex;
+ ibv_cmd_create_wq;
+ ibv_cmd_dealloc_mw;
+ ibv_cmd_dealloc_pd;
+ ibv_cmd_dereg_mr;
+ ibv_cmd_destroy_ah;
+ ibv_cmd_destroy_cq;
+ ibv_cmd_destroy_flow;
+ ibv_cmd_destroy_qp;
+ ibv_cmd_destroy_rwq_ind_table;
+ ibv_cmd_destroy_srq;
+ ibv_cmd_destroy_wq;
+ ibv_cmd_detach_mcast;
+ ibv_cmd_get_context;
+ ibv_cmd_modify_qp;
+ ibv_cmd_modify_qp_ex;
+ ibv_cmd_modify_srq;
+ ibv_cmd_modify_wq;
+ ibv_cmd_open_qp;
+ ibv_cmd_open_xrcd;
+ ibv_cmd_poll_cq;
+ ibv_cmd_post_recv;
+ ibv_cmd_post_send;
+ ibv_cmd_post_srq_recv;
+ ibv_cmd_query_device;
+ ibv_cmd_query_device_ex;
+ ibv_cmd_query_port;
+ ibv_cmd_query_qp;
+ ibv_cmd_query_srq;
+ ibv_cmd_reg_mr;
+ ibv_cmd_req_notify_cq;
+ ibv_cmd_rereg_mr;
+ ibv_cmd_resize_cq;
+ ibv_query_gid_type;
+ ibv_register_driver;
+ verbs_register_driver;
+ verbs_init_cq;
+};
diff --git a/contrib/ofed/libibverbs/libibverbs.spec.in b/contrib/ofed/libibverbs/libibverbs.spec.in
deleted file mode 100644
index d122afa..0000000
--- a/contrib/ofed/libibverbs/libibverbs.spec.in
+++ /dev/null
@@ -1,146 +0,0 @@
-Name: libibverbs
-Version: 1.1.4
-Release: 1%{?dist}
-Summary: A library for direct userspace use of RDMA (InfiniBand/iWARP) hardware
-
-Group: System Environment/Libraries
-License: GPLv2 or BSD
-Url: http://openfabrics.org/
-Source: http://openfabrics.org/downloads/verbs/libibverbs-1.1.4.tar.gz
-BuildRoot: %(mktemp -ud %{_tmppath}/%{name}-%{version}-%{release}-XXXXXX)
-Requires(post): /sbin/ldconfig
-Requires(postun): /sbin/ldconfig
-
-%description
-libibverbs is a library that allows userspace processes to use RDMA
-"verbs" as described in the InfiniBand Architecture Specification and
-the RDMA Protocol Verbs Specification. This includes direct hardware
-access from userspace to InfiniBand/iWARP adapters (kernel bypass) for
-fast path operations.
-
-For this library to be useful, a device-specific plug-in module should
-also be installed.
-
-%package devel
-Summary: Development files for the libibverbs library
-Group: System Environment/Libraries
-Requires: %{name} = %{version}-%{release}
-
-%description devel
-Header files for the libibverbs library.
-
-%package devel-static
-Summary: Static development files for the libibverbs library
-Group: System Environment/Libraries
-
-%description devel-static
-Static libraries for the libibverbs library.
-
-%package utils
-Summary: Examples for the libibverbs library
-Group: System Environment/Libraries
-Requires: %{name} = %{version}-%{release}
-
-%description utils
-Useful libibverbs1 example programs such as ibv_devinfo, which
-displays information about RDMA devices.
-
-%prep
-%setup -q -n %{name}-@VERSION@
-
-%build
-%configure
-make %{?_smp_mflags}
-
-%install
-rm -rf $RPM_BUILD_ROOT
-make DESTDIR=%{buildroot} install
-# remove unpackaged files from the buildroot
-rm -f $RPM_BUILD_ROOT%{_libdir}/*.la
-
-%clean
-rm -rf $RPM_BUILD_ROOT
-
-%post -p /sbin/ldconfig
-%postun -p /sbin/ldconfig
-
-%files
-%defattr(-,root,root,-)
-%{_libdir}/libibverbs*.so.*
-%doc AUTHORS COPYING ChangeLog README
-
-%files devel
-%defattr(-,root,root,-)
-%{_libdir}/lib*.so
-%{_includedir}/*
-%{_mandir}/man3/*
-%{_mandir}/man7/*
-
-%files devel-static
-%defattr(-,root,root,-)
-%{_libdir}/*.a
-
-%files utils
-%defattr(-,root,root,-)
-%{_bindir}/*
-%{_mandir}/man1/*
-
-%changelog
-* Thu Jun 3 2010 Roland Dreier <rdreier@cisco.com> - 1.1.4-1
-- New upstream release
-
-* Thu Oct 29 2009 Roland Dreier <rdreier@cisco.com> - 1.1.3-1
-- New upstream release
-
-* Fri Jul 24 2009 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 1.1.2-3
-- Rebuilt for https://fedoraproject.org/wiki/Fedora_12_Mass_Rebuild
-
-* Wed Feb 25 2009 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 1.1.2-2
-- Rebuilt for https://fedoraproject.org/wiki/Fedora_11_Mass_Rebuild
-
-* Wed Apr 16 2008 Roland Dreier <rdreier@cisco.com> - 1.1.2-1
-- New upstream release
-- Update description to mention RDMA and iWARP, not just InfiniBand
-- Add "Requires" tag for libibverbs base package to -devel
-
-* Fri Jun 15 2007 Roland Dreier <rdreier@cisco.com> - 1.1.1-1
-- New upstream release
-
-* Wed Apr 11 2007 Roland Dreier <rdreier@cisco.com> - 1.1-1
-- New upstream release
-
-* Mon May 22 2006 Roland Dreier <rdreier@cisco.com> - 1.1-0.1.rc2
-- New upstream release
-- Remove dependency on libsysfs, since it is no longer used
-- Put section 3 manpages in devel package.
-- Spec file cleanups: remove unused ver macro, improve BuildRoot, add
- Requires for /sbin/ldconfig, split static libraries into
- devel-static package, and don't use makeinstall any more (all
- suggested by Doug Ledford <dledford@redhat.com>).
-
-* Thu May 4 2006 Roland Dreier <rdreier@cisco.com> - 1.0.4-1
-- New upstream release
-
-* Mon Mar 14 2006 Roland Dreier <rdreier@cisco.com> - 1.0.3-1
-- New upstream release
-
-* Mon Mar 13 2006 Roland Dreier <rdreier@cisco.com> - 1.0.1-1
-- New upstream release
-
-* Thu Feb 16 2006 Roland Dreier <rdreier@cisco.com> - 1.0-1
-- New upstream release
-
-* Wed Feb 15 2006 Roland Dreier <rolandd@cisco.com> - 1.0-0.5.rc7
-- New upstream release
-
-* Sun Jan 22 2006 Roland Dreier <rolandd@cisco.com> - 1.0-0.4.rc6
-- New upstream release
-
-* Tue Oct 25 2005 Roland Dreier <rolandd@cisco.com> - 1.0-0.3.rc5
-- New upstream release
-
-* Wed Oct 5 2005 Roland Dreier <rolandd@cisco.com> - 1.0-0.2.rc4
-- Update to upstream 1.0-rc4 release
-
-* Mon Sep 26 2005 Roland Dreier <rolandd@cisco.com> - 1.0-0.1.rc3
-- Initial attempt at Fedora Extras-compliant spec file
diff --git a/contrib/ofed/libibverbs/man/ibv_alloc_mw.3 b/contrib/ofed/libibverbs/man/ibv_alloc_mw.3
new file mode 100644
index 0000000..86acaca
--- /dev/null
+++ b/contrib/ofed/libibverbs/man/ibv_alloc_mw.3
@@ -0,0 +1,55 @@
+.\" -*- nroff -*-
+.\" Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md
+.\"
+.TH IBV_ALLOC_MW 3 2016-02-02 libibverbs "Libibverbs Programmer's Manual"
+.SH "NAME"
+ibv_alloc_mw, ibv_dealloc_mw \- allocate or deallocate a memory window (MW)
+.SH "SYNOPSIS"
+.nf
+.B #include <infiniband/verbs.h>
+.sp
+.BI "struct ibv_mw *ibv_alloc_mw(struct ibv_pd " "*pd" ,
+.BI " enum ibv_mw_type " "type");
+.sp
+.BI "int ibv_dealloc_mw(struct ibv_mw " "*mw" );
+.fi
+.SH "DESCRIPTION"
+.B ibv_alloc_mw()
+allocates a memory window (MW) associated with the protection domain
+.I pd\fR.
+The MW's type (1 or 2A/2B) is
+.I type\fR.
+.PP
+The MW is created not bound. For it to be useful, the MW must be bound, through either ibv_bind_mw (type 1) or a special WR (type 2).
+Once bound, the memory window allows RDMA (remote) access to a subset of the MR to which it was bound,
+until invalidated by: ibv_bind_mw verb with zero length for type 1,
+IBV_WR_LOCAL_INV/IBV_WR_SEND_WITH_INV WR opcode for type 2, deallocation.
+.PP
+.B ibv_dealloc_mw()
+Unbinds in case was previously bound and deallocates the MW
+.I mw\fR.
+.SH "RETURN VALUE"
+.B ibv_alloc_mw()
+returns a pointer to the allocated MW, or NULL if the request fails.
+The remote key (\fBR_Key\fR)
+field
+.B rkey
+is used by remote processes to perform Atomic and RDMA operations. This key will be changed during bind operations. The remote process places this
+.B rkey
+as the rkey field of struct ibv_send_wr passed to the ibv_post_send function.
+.PP
+.B ibv_dealloc_mw()
+returns 0 on success, or the value of errno on failure (which indicates the failure reason).
+.SH "NOTES"
+.B ibv_dereg_mr()
+fails if any memory window is still bound to this MR.
+.SH "SEE ALSO"
+.BR ibv_alloc_pd (3),
+.BR ibv_post_send (3),
+.BR ibv_bind_mw (3),
+.BR ibv_reg_mr (3),
+.SH "AUTHORS"
+.TP
+Majd Dibbiny <majd@mellanox.com>
+.TP
+Yishai Hadas <yishaih@mellanox.com>
diff --git a/contrib/ofed/libibverbs/man/ibv_alloc_pd.3 b/contrib/ofed/libibverbs/man/ibv_alloc_pd.3
index c3afd1a..cc475f4 100644
--- a/contrib/ofed/libibverbs/man/ibv_alloc_pd.3
+++ b/contrib/ofed/libibverbs/man/ibv_alloc_pd.3
@@ -1,4 +1,5 @@
.\" -*- nroff -*-
+.\" Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md
.\"
.TH IBV_ALLOC_PD 3 2006-10-31 libibverbs "Libibverbs Programmer's Manual"
.SH "NAME"
@@ -37,4 +38,4 @@ freed.
.BR ibv_create_ah_from_wc (3)
.SH "AUTHORS"
.TP
-Dotan Barak <dotanb@mellanox.co.il>
+Dotan Barak <dotanba@gmail.com>
diff --git a/contrib/ofed/libibverbs/man/ibv_asyncwatch.1 b/contrib/ofed/libibverbs/man/ibv_asyncwatch.1
index ece25f8..ae10117 100644
--- a/contrib/ofed/libibverbs/man/ibv_asyncwatch.1
+++ b/contrib/ofed/libibverbs/man/ibv_asyncwatch.1
@@ -1,3 +1,4 @@
+.\" Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md
.TH IBV_ASYNCWATCH 1 "August 30, 2005" "libibverbs" "USER COMMANDS"
.SH NAME
@@ -5,12 +6,26 @@ ibv_asyncwatch \- display asynchronous events
.SH SYNOPSIS
.B ibv_asyncwatch
+[\-d device] [-h]
.SH DESCRIPTION
.PP
Display asynchronous events forwarded to userspace for an RDMA device.
+.SH OPTIONS
+
+.PP
+.TP
+\fB\-d\fR, \fB\-\-ib\-dev\fR=\fIDEVICE\fR
+use IB device \fIDEVICE\fR (default first device found)
+.TP
+\fB\-h\fR, \fB\-\-help\fR=\fIDEVICE\fR
+Print a help text and exit.
+
.SH AUTHORS
.TP
Roland Dreier
.RI < rolandd@cisco.com >
+.TP
+Eran Ben Elisha
+.RI < eranbe@mellanox.com >
diff --git a/contrib/ofed/libibverbs/man/ibv_attach_mcast.3 b/contrib/ofed/libibverbs/man/ibv_attach_mcast.3
index 9f6213e..2ae1f5d 100644
--- a/contrib/ofed/libibverbs/man/ibv_attach_mcast.3
+++ b/contrib/ofed/libibverbs/man/ibv_attach_mcast.3
@@ -1,4 +1,5 @@
.\" -*- nroff -*-
+.\" Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md
.\"
.TH IBV_ATTACH_MCAST 3 2006-10-31 libibverbs "Libibverbs Programmer's Manual"
.SH "NAME"
@@ -50,4 +51,4 @@ the local port.
.BR ibv_create_qp (3)
.SH "AUTHORS"
.TP
-Dotan Barak <dotanb@mellanox.co.il>
+Dotan Barak <dotanba@gmail.com>
diff --git a/contrib/ofed/libibverbs/man/ibv_bind_mw.3 b/contrib/ofed/libibverbs/man/ibv_bind_mw.3
new file mode 100644
index 0000000..af309d0
--- /dev/null
+++ b/contrib/ofed/libibverbs/man/ibv_bind_mw.3
@@ -0,0 +1,93 @@
+.\" -*- nroff -*-
+.\" Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md
+.\"
+.TH IBV_BIND_MW 3 2016-02-02 libibverbs "Libibverbs Programmer's Manual"
+.SH "NAME"
+ibv_bind_mw \- post a request to bind a type 1 memory window to a memory region
+.SH "SYNOPSIS"
+.nf
+.B #include <infiniband/verbs.h>
+.sp
+.BI "int ibv_bind_mw(struct ibv_qp " "*qp" ", struct ibv_mw " "*mw" ",
+.BI " struct ibv_mw_bind " "*mw_bind" ");
+.fi
+.SH "DESCRIPTION"
+.B ibv_bind_mw()
+posts to the queue pair
+.I qp
+a request to bind the memory window
+.I mw
+according to the details in
+.I mw_bind\fR.
+.PP
+The argument
+.I mw_bind
+is an ibv_mw_bind struct, as defined in <infiniband/verbs.h>.
+.PP
+.nf
+struct ibv_mw_bind {
+.in +8
+uint64_t wr_id; /* User defined WR ID */
+int send_flags; /* Use ibv_send_flags */
+struct ibv_mw_bind_info bind_info; /* MW bind information */
+.in -8
+}
+.fi
+.PP
+.nf
+struct ibv_mw_bind_info {
+.in +8
+struct ibv_mr *mr; /* The MR to bind the MW to */
+uint64_t addr; /* The address the MW should start at */
+uint64_t length; /* The length (in bytes) the MW should span */
+int mw_access_flags; /* Access flags to the MW. Use ibv_access_flags */
+.in -8
+};
+.fi
+.PP
+The QP Transport Service Type must be either UC, RC or XRC_SEND for bind operations.
+.PP
+The attribute send_flags describes the properties of the \s-1WR\s0. It is either 0 or the bitwise \s-1OR\s0 of one or more of the following flags:
+.PP
+.TP
+.B IBV_SEND_FENCE \fR Set the fence indicator.
+.TP
+.B IBV_SEND_SIGNALED \fR Set the completion notification indicator. Relevant only if QP was created with sq_sig_all=0
+.PP
+The mw_access_flags define the allowed access to the MW after the bind
+completes successfully. It is either 0 or the bitwise \s-1OR\s0 of one
+or more of the following flags:
+.TP
+.B IBV_ACCESS_REMOTE_WRITE \fR Enable Remote Write Access. Requires local write access to the MR.
+.TP
+.B IBV_ACCESS_REMOTE_READ\fR Enable Remote Read Access
+.TP
+.B IBV_ACCESS_REMOTE_ATOMIC\fR Enable Remote Atomic Operation Access (if supported). Requires local write access to the MR.
+.TP
+.B IBV_ACCESS_ZERO_BASED\fR If set, the address set on the 'remote_addr' field on the WR will be an offset from the MW's start address.
+.SH "RETURN VALUE"
+.B ibv_bind_mw()
+returns 0 on success, or the value of errno on failure (which
+indicates the failure reason). In case of a success, the R_key of the
+memory window after the bind is returned in the mw_bind->mw->rkey field.
+.SH "NOTES"
+The bind does not complete when the function return - it is merely
+posted to the QP. The user should keep a copy of the old R_key, and
+fix the mw structure if the subsequent CQE for the bind operation
+indicates a failure. The user may safely send the R_key using a send
+request on the same QP, (based on QP ordering rules: a send after a bind
+request on the same QP are always ordered), but must not transfer it to the
+remote in any other manner before reading a successful CQE.
+.PP
+Note that for type 2 MW, one should directly post bind WR to the QP,
+using ibv_post_send.
+.SH "SEE ALSO"
+.BR ibv_alloc_mw (3),
+.BR ibv_post_send (3),
+.BR ibv_poll_cq (3)
+.BR ibv_reg_mr (3),
+.SH "AUTHORS"
+.TP
+Majd Dibbiny <majd@mellanox.com>
+.TP
+Yishai Hadas <yishaih@mellanox.com>
diff --git a/contrib/ofed/libibverbs/man/ibv_create_ah.3 b/contrib/ofed/libibverbs/man/ibv_create_ah.3
index 0260f0f..0ca2198 100644
--- a/contrib/ofed/libibverbs/man/ibv_create_ah.3
+++ b/contrib/ofed/libibverbs/man/ibv_create_ah.3
@@ -1,4 +1,5 @@
.\" -*- nroff -*-
+.\" Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md
.\"
.TH IBV_CREATE_AH 3 2006-10-31 libibverbs "Libibverbs Programmer's Manual"
.SH "NAME"
@@ -61,4 +62,4 @@ returns 0 on success, or the value of errno on failure (which indicates the fail
.BR ibv_create_ah_from_wc (3)
.SH "AUTHORS"
.TP
-Dotan Barak <dotanb@mellanox.co.il>
+Dotan Barak <dotanba@gmail.com>
diff --git a/contrib/ofed/libibverbs/man/ibv_create_ah_from_wc.3 b/contrib/ofed/libibverbs/man/ibv_create_ah_from_wc.3
index eb20dd3..ec7d29f 100644
--- a/contrib/ofed/libibverbs/man/ibv_create_ah_from_wc.3
+++ b/contrib/ofed/libibverbs/man/ibv_create_ah_from_wc.3
@@ -1,4 +1,5 @@
.\" -*- nroff -*-
+.\" Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md
.\"
.TH IBV_CREATE_AH_FROM_WC 3 2006-10-31 libibverbs "Libibverbs Programmer's Manual"
.SH "NAME"
@@ -60,4 +61,4 @@ can be used to create a new AH using
.BR ibv_poll_cq (3)
.SH "AUTHORS"
.TP
-Dotan Barak <dotanb@mellanox.co.il>
+Dotan Barak <dotanba@gmail.com>
diff --git a/contrib/ofed/libibverbs/man/ibv_create_comp_channel.3 b/contrib/ofed/libibverbs/man/ibv_create_comp_channel.3
index 285ee04..7460978 100644
--- a/contrib/ofed/libibverbs/man/ibv_create_comp_channel.3
+++ b/contrib/ofed/libibverbs/man/ibv_create_comp_channel.3
@@ -1,4 +1,5 @@
.\" -*- nroff -*-
+.\" Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md
.\"
.TH IBV_CREATE_COMP_CHANNEL 3 2006-10-31 libibverbs "Libibverbs Programmer's Manual"
.SH "NAME"
@@ -47,4 +48,4 @@ channel being destroyed.
.BR ibv_get_cq_event (3)
.SH "AUTHORS"
.TP
-Dotan Barak <dotanb@mellanox.co.il>
+Dotan Barak <dotanba@gmail.com>
diff --git a/contrib/ofed/libibverbs/man/ibv_create_cq.3 b/contrib/ofed/libibverbs/man/ibv_create_cq.3
index cfa5f3e..98ea4d2 100644
--- a/contrib/ofed/libibverbs/man/ibv_create_cq.3
+++ b/contrib/ofed/libibverbs/man/ibv_create_cq.3
@@ -1,4 +1,5 @@
.\" -*- nroff -*-
+.\" Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md
.\"
.TH IBV_CREATE_CQ 3 2006-10-31 libibverbs "Libibverbs Programmer's Manual"
.SH "NAME"
@@ -55,4 +56,4 @@ fails if any queue pair is still associated with this CQ.
.BR ibv_create_qp (3)
.SH "AUTHORS"
.TP
-Dotan Barak <dotanb@mellanox.co.il>
+Dotan Barak <dotanba@gmail.com>
diff --git a/contrib/ofed/libibverbs/man/ibv_create_cq_ex.3 b/contrib/ofed/libibverbs/man/ibv_create_cq_ex.3
new file mode 100644
index 0000000..7dfbef2
--- /dev/null
+++ b/contrib/ofed/libibverbs/man/ibv_create_cq_ex.3
@@ -0,0 +1,159 @@
+.\" -*- nroff -*-
+.\" Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md
+.\"
+.TH IBV_CREATE_CQ_EX 3 2016-05-08 libibverbs "Libibverbs Programmer's Manual"
+.SH "NAME"
+ibv_create_cq_ex \- create a completion queue (CQ)
+.SH "SYNOPSIS"
+.nf
+.B #include <infiniband/verbs.h>
+.sp
+.BI "struct ibv_cq_ex *ibv_create_cq_ex(struct ibv_context " "*context" ",
+.BI " struct ibv_create_cq_attr_ex " "*cq_attr" );
+.fi
+.SH "DESCRIPTION"
+.B ibv_create_cq_ex()
+creates a completion queue (CQ) for RDMA device context
+.I context\fR.
+The argument
+.I cq_attr
+is a pointer to struct ibv_cq_init_attr_ex as defined in <infiniband/verbs.h>.
+.PP
+.nf
+struct ibv_cq_init_attr_ex {
+.in +8
+int cqe; /* Minimum number of entries required for CQ */
+void *cq_context; /* Consumer-supplied context returned for completion events */
+struct ibv_comp_channel *channel; /* Completion channel where completion events will be queued. May be NULL if completion events will not be used. */
+int comp_vector; /* Completion vector used to signal completion events. Must be >= 0 and < context->num_comp_vectors. */
+uint64_t wc_flags; /* The wc_flags that should be returned in ibv_poll_cq_ex. Or'ed bit of enum ibv_wc_flags_ex. */
+uint32_t comp_mask; /* compatibility mask (extended verb). */
+uint32_t flags /* One or more flags from enum ibv_create_cq_attr_flags */
+.in -8
+};
+
+enum ibv_wc_flags_ex {
+ IBV_WC_EX_WITH_BYTE_LEN = 1 << 0, /* Require byte len in WC */
+ IBV_WC_EX_WITH_IMM = 1 << 1, /* Require immediate in WC */
+ IBV_WC_EX_WITH_QP_NUM = 1 << 2, /* Require QP number in WC */
+ IBV_WC_EX_WITH_SRC_QP = 1 << 3, /* Require source QP in WC */
+ IBV_WC_EX_WITH_SLID = 1 << 4, /* Require slid in WC */
+ IBV_WC_EX_WITH_SL = 1 << 5, /* Require sl in WC */
+ IBV_WC_EX_WITH_DLID_PATH_BITS = 1 << 6, /* Require dlid path bits in WC */
+ IBV_WC_EX_WITH_COMPLETION_TIMESTAMP = 1 << 7, /* Require completion timestamp in WC /*
+ IBV_WC_EX_WITH_CVLAN = 1 << 8, /* Require VLAN info in WC */
+ IBV_WC_EX_WITH_FLOW_TAG = 1 << 9, /* Require flow tag in WC */
+};
+
+enum ibv_cq_init_attr_mask {
+ IBV_CQ_INIT_ATTR_MASK_FLAGS = 1 << 0,
+};
+
+enum ibv_create_cq_attr_flags {
+ IBV_CREATE_CQ_ATTR_SINGLE_THREADED = 1 << 0, /* This CQ is used from a single threaded, thus no locking is required */
+};
+
+.SH "Polling an extended CQ"
+In order to poll an extended CQ efficiently, a user could use the following functions.
+
+.TP
+.B Completion iterator functions
+
+.BI "int ibv_start_poll(struct ibv_cq_ex " "*cq" ", struct ibv_poll_cq_attr " "*attr")
+.br
+Start polling a batch of work completions.
+.I attr
+is given in order to make this function
+easily extensible in the future. This function either returns 0 on success or an error code
+otherwise. When no completions are available on the CQ, ENOENT is returned, but the CQ remains
+in a valid state. On success, querying the completion's attribute could be done using the query
+functions described below. If an error code is given, end_poll shouldn't be called.
+
+.BI "int ibv_next_poll(struct ibv_cq_ex " "*cq")
+.br
+This function is called in order to get the next work completion. It has to be called after
+.I start_poll
+and before
+.I end_poll
+are called. This function either returns 0 on success or an error code
+otherwise. When no completions are available on the CQ, ENOENT is returned, but the CQ remains
+in a valid state. On success, querying the completion's attribute could be done using the query
+functions described below. If an error code is given, end_poll should still be called,
+indicating this is the end of the polled batch.
+
+.BI "void ibv_end_poll(struct ibv_cq_ex " "*cq")
+.br
+This function indicates the end of polling batch of work completions. After calling this function, the user should start a new batch
+by calling
+.I start_poll.
+
+.TP
+.B Polling fields in the completion
+Below members and functions are used in order to poll the current completion. The current completion is the completion which the iterator points to (start_poll and next_poll advances this iterator). Only fields that the user requested via wc_flags in ibv_create_cq_ex could be queried. In addition, some fields are only valid in certain opcodes and status codes.
+
+.BI "uint64_t wr_id - Can be accessed directly from struct ibv_cq_ex".
+
+.BI "enum ibv_wc_status - Can be accessed directly from struct ibv_cq_ex".
+
+.BI "enum ibv_wc_opcode ibv_wc_read_opcode(struct ibv_cq_ex " "*cq"); \c
+ Get the opcode from the current completion.
+
+.BI "uint32_t ibv_wc_read_vendor_err(struct ibv_cq_ex " "*cq"); \c
+ Get the vendor error from the current completion.
+
+.BI "uint32_t ibv_wc_read_byte_len(struct ibv_cq_ex " "*cq"); \c
+ Get the vendor error from the current completion.
+
+.BI "uint32_t ibv_wc_read_imm_data(struct ibv_cq_ex " "*cq"); \c
+ Get the immediate data field from the current completion.
+
+.BI "uint32_t ibv_wc_read_qp_num(struct ibv_cq_ex " "*cq"); \c
+ Get the QP number field from the current completion.
+
+.BI "uint32_t ibv_wc_read_src_qp(struct ibv_cq_ex " "*cq"); \c
+ Get the source QP number field from the current completion.
+
+.BI "int ibv_wc_read_wc_flags(struct ibv_cq_ex " "*cq"); \c
+ Get the QP flags field from the current completion.
+
+.BI "uint16_t ibv_wc_read_pkey_index(struct ibv_cq_ex " "*cq"); \c
+ Get the pkey index field from the current completion.
+
+.BI "uint32_t ibv_wc_read_slid(struct ibv_cq_ex " "*cq"); \c
+ Get the slid field from the current completion.
+
+.BI "uint8_t ibv_wc_read_sl(struct ibv_cq_ex " "*cq"); \c
+ Get the sl field from the current completion.
+
+.BI "uint8_t ibv_wc_read_dlid_path_bits(struct ibv_cq_ex " "*cq"); \c
+ Get the dlid_path_bits field from the current completion.
+
+.BI "uint64_t ibv_wc_read_completion_ts(struct ibv_cq_ex " "*cq"); \c
+ Get the completion timestamp from the current completion.
+
+.BI "uint16_t ibv_wc_read_cvlan(struct ibv_cq_ex " "*cq"); \c
+ Get the CVLAN field from the current completion.
+
+.BI "uint32_t ibv_wc_read_flow_tag(struct ibv_cq_ex " "*cq"); \c
+ Get flow tag from the current completion.
+
+.SH "RETURN VALUE"
+.B ibv_create_cq_ex()
+returns a pointer to the CQ, or NULL if the request fails.
+.SH "NOTES"
+.B ibv_create_cq_ex()
+may create a CQ with size greater than or equal to the requested
+size. Check the cqe attribute in the returned CQ for the actual size.
+.PP
+CQ should be destroyed with ibv_destroy_cq.
+.PP
+.SH "SEE ALSO"
+.BR ibv_create_cq (3),
+.BR ibv_destroy_cq (3),
+.BR ibv_resize_cq (3),
+.BR ibv_req_notify_cq (3),
+.BR ibv_ack_cq_events (3),
+.BR ibv_create_qp (3)
+.SH "AUTHORS"
+.TP
+Matan Barak <matanb@mellanox.com>
diff --git a/contrib/ofed/libibverbs/man/ibv_create_flow.3 b/contrib/ofed/libibverbs/man/ibv_create_flow.3
new file mode 100644
index 0000000..48bbb14
--- /dev/null
+++ b/contrib/ofed/libibverbs/man/ibv_create_flow.3
@@ -0,0 +1,216 @@
+.\" Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md
+.TH IBV_CREATE_FLOW 3 2016-03-15 libibverbs "Libibverbs Programmer's Manual"
+.SH "NAME"
+ibv_create_flow, ibv_destroy_flow \- create or destroy flow steering rules
+.SH "SYNOPSIS"
+.nf
+.B #include <infiniband/verbs.h>
+.sp
+.BI "struct ibv_flow *ibv_create_flow(struct ibv_qp " "*qp" ,
+.BI " struct ibv_flow_attr " "*flow_attr");
+.BI "int ibv_destroy_flow(struct ibv_flow " "*flow_id");
+.sp
+.fi
+.SH "DESCRIPTION"
+.SS ibv_create_flow()
+allows a user application QP
+.I qp
+to be attached into a specified flow
+.I flow
+which is defined in
+.I <infiniband/verbs.h>
+.PP
+.nf
+struct ibv_flow_attr {
+.in +8
+uint32_t comp_mask; /* Future extendibility */
+enum ibv_flow_attr_type type; /* Rule type - see below */
+uint16_t size; /* Size of command */
+uint16_t priority; /* Rule priority - see below */
+uint8_t num_of_specs; /* Number of ibv_flow_spec_xxx */
+uint8_t port; /* The uplink port number */
+uint32_t flags; /* Extra flags for rule - see below */
+/* Following are the optional layers according to user request
+ * struct ibv_flow_spec_xxx
+ * struct ibv_flow_spec_yyy
+ */
+.in -8
+};
+.sp
+.nf
+enum ibv_flow_attr_type {
+.in +8
+IBV_FLOW_ATTR_NORMAL = 0x0, /* Steering according to rule specifications */
+IBV_FLOW_ATTR_ALL_DEFAULT = 0x1, /* Default unicast and multicast rule - receive all Eth traffic which isn't steered to any QP */
+IBV_FLOW_ATTR_MC_DEFAULT = 0x2, /* Default multicast rule - receive all Eth multicast traffic which isn't steered to any QP */
+IBV_FLOW_ATTR_SNIFFER = 0x3, /* Sniffer rule - receive all port traffic */
+.in -8
+};
+.sp
+.nf
+enum ibv_flow_flags {
+.in +8
+IBV_FLOW_ATTR_FLAGS_ALLOW_LOOP_BACK = 1 << 0, /* Apply the rules on packets that were sent from the attached QP through loopback */
+IBV_FLOW_ATTR_FLAGS_DONT_TRAP = 1 << 1, /* Rule doesn't trap received packets, allowing them to match lower prioritized rules */
+.in -8
+};
+.fi
+.nf
+.br
+
+enum ibv_flow_spec_type {
+.in +8
+IBV_FLOW_SPEC_ETH = 0x20, /* Flow specification of L2 header */
+IBV_FLOW_SPEC_IPV4 = 0x30, /* Flow specification of IPv4 header */
+IBV_FLOW_SPEC_IPV6 = 0x31, /* Flow specification of IPv6 header */
+IBV_FLOW_SPEC_IPV4_EXT = 0x32, /* Extended flow specification of IPv4 */
+IBV_FLOW_SPEC_TCP = 0x40, /* Flow specification of TCP header */
+IBV_FLOW_SPEC_UDP = 0x41, /* Flow specification of UDP header */
+IBV_FLOW_SPEC_VXLAN_TUNNEL = 0x50, /* Flow specification of VXLAN header */
+IBV_FLOW_SPEC_INNER = 0x100, /* Flag making L2/L3/L4 specifications to be applied on the inner header */
+IBV_FLOW_SPEC_ACTION_TAG = 0x1000, /* Action tagging matched packet */
+IBV_FLOW_SPEC_ACTION_DROP = 0x1001, /* Action dropping matched packet */
+.in -8
+};
+.br
+
+Flow specification general structure:
+.BR
+struct ibv_flow_spec_xxx {
+.in +8
+enum ibv_flow_spec_type type;
+uint16_t size; /* Flow specification size = sizeof(struct ibv_flow_spec_xxx) */
+struct ibv_flow_xxx_filter val;
+struct ibv_flow_xxx_filter mask; /* Defines which bits from the filter value are applicable when looking for a match in the incoming packet */
+.in -8
+};
+.PP
+Each spec struct holds the relevant network layer parameters for matching. To enforce the match, the user sets a mask for each parameter.
+.br
+If the bit is set in the mask, the corresponding bit in the value should be matched.
+.br
+Note that most vendors support either full mask (all "1"s) or zero mask (all "0"s).
+.br
+.B Network parameters in the relevant network structs should be given in network order (big endian).
+
+.SS Flow domains and priority
+Flow steering defines the concept of domain and priority. Each domain represents an application that can attach a flow.
+Domains are prioritized. A higher priority domain will always supersede a lower priority domain when their flow specifications overlap.
+.br
+.B IB verbs have the higher priority domain.
+.br
+In addition to the domain, there is priority within each of the domains.
+A lower priority numeric value (higher priority) takes precedence over matching rules with higher numeric priority value (lower priority).
+It is important to note that the priority value of a flow spec is used not only to establish the precedence of conflicting flow matches
+but also as a way to abstract the order on which flow specs are tested for matches. Flows with higher priorities will be tested before flows with lower priorities.
+.PP
+.SS ibv_destroy_flow()
+destroys the flow
+.I flow_id\fR.
+.SH "RETURN VALUE"
+.B ibv_create_flow()
+returns a pointer to the flow, or NULL if the request fails. In case of an error, errno is updated.
+.PP
+.B ibv_destroy_flow()
+returns 0 on success, or the value of errno on failure (which indicates the failure reason).
+.SH "ERRORS"
+.SS EINVAL
+.B ibv_create_flow()
+flow specification, QP or priority are invalid
+.PP
+.B ibv_destroy_flow()
+flow_id is invalid
+.SS ENOMEM
+Couldn't create/destroy flow, not enough memory
+.SS ENXIO
+Device managed flow steering isn't currently supported
+.SS EPERM
+No permissions to add the flow steering rule
+.SH "NOTES"
+1. These verbs are available only for devices supporting
+.br
+ IBV_DEVICE_MANAGED_FLOW_STEERING and only for QPs of Transport Service Type
+.BR IBV_QPT_UD
+or
+.BR IBV_QPT_RAW_PACKET
+.br
+2. User must memset the spec struct with zeros before using it.
+.br
+3. ether_type field in ibv_flow_eth_filter is the ethertype following the last VLAN tag of the packet.
+.br
+4. Only rule type IBV_FLOW_ATTR_NORMAL supports IBV_FLOW_ATTR_FLAGS_DONT_TRAP flag.
+.br
+5. No specifications are needed for IBV_FLOW_ATTR_SNIFFER rule type.
+.br
+.PP
+.SH EXAMPLE
+.br
+Below flow_attr defines a rule in priority 0 to match a destination
+mac address and a source ipv4 address. For that, L2 and L3 specs are used.
+.br
+If there is a hit on this rule, means the
+received packet has destination mac: 66:11:22:33:44:55 and source ip: 0x0B86C806,
+the packet is steered to its attached qp.
+.sp
+.nf
+struct raw_eth_flow_attr {
+.in +8
+struct ibv_flow_attr attr;
+struct ibv_flow_spec_eth spec_eth;
+struct ibv_flow_spec_ipv4 spec_ipv4;
+.in -8
+} __attribute__((packed));
+.sp
+.nf
+struct raw_eth_flow_attr flow_attr = {
+.in +8
+ .attr = {
+ .comp_mask = 0,
+ .type = IBV_FLOW_ATTR_NORMAL,
+ .size = sizeof(flow_attr),
+ .priority = 0,
+ .num_of_specs = 2,
+ .port = 1,
+ .flags = 0,
+ },
+ .spec_eth = {
+ .type = IBV_FLOW_SPEC_ETH,
+ .size = sizeof(struct ibv_flow_spec_eth),
+ .val = {
+ .dst_mac = {0x66, 0x11, 0x22, 0x33, 0x44, 0x55},
+ .src_mac = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
+ .ether_type = 0,
+ .vlan_tag = 0,
+ },
+ .mask = {
+ .dst_mac = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF},
+ .src_mac = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF},
+ .ether_type = 0,
+ .vlan_tag = 0,
+ }
+ },
+ .spec_ipv4 = {
+ .type = IBV_FLOW_SPEC_IPV4,
+ .size = sizeof(struct ibv_flow_spec_ipv4),
+ .val = {
+ .src_ip = 0x0B86C806,
+ .dst_ip = 0,
+ },
+ .mask = {
+ .src_ip = 0xFFFFFFFF,
+ .dst_ip = 0,
+ }
+ }
+.in -8
+};
+.sp
+.nf
+.SH "AUTHORS"
+.TP
+Hadar Hen Zion <hadarh@mellanox.com>
+.TP
+Matan Barak <matanb@mellanox.com>
+.TP
+Yishai Hadas <yishaih@mellanox.com>
+.TP
+Maor Gottlieb <maorg@mellanox.com>
diff --git a/contrib/ofed/libibverbs/man/ibv_create_qp.3 b/contrib/ofed/libibverbs/man/ibv_create_qp.3
index 106b31c..78d7f43 100644
--- a/contrib/ofed/libibverbs/man/ibv_create_qp.3
+++ b/contrib/ofed/libibverbs/man/ibv_create_qp.3
@@ -1,4 +1,5 @@
.\" -*- nroff -*-
+.\" Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md
.\"
.TH IBV_CREATE_QP 3 2006-10-31 libibverbs "Libibverbs Programmer's Manual"
.SH "NAME"
@@ -28,9 +29,8 @@ struct ibv_cq *send_cq; /* CQ to be associated with the Send Que
struct ibv_cq *recv_cq; /* CQ to be associated with the Receive Queue (RQ) */
struct ibv_srq *srq; /* SRQ handle if QP is to be associated with an SRQ, otherwise NULL */
struct ibv_qp_cap cap; /* QP capabilities */
-enum ibv_qp_type qp_type; /* QP Transport Service Type: IBV_QPT_RC, IBV_QPT_UC, IBV_QPT_UD or IBV_QPT_XRC */
+enum ibv_qp_type qp_type; /* QP Transport Service Type: IBV_QPT_RC, IBV_QPT_UC, IBV_QPT_UD or IBV_QPT_RAW_PACKET */
int sq_sig_all; /* If set, each Work Request (WR) submitted to the SQ generates a completion entry */
-struct ibv_xrc_domain *xrc_domain; /* XRC domain the QP will be associated with (valid only for IBV_QPT_XRC QP), otherwise NULL */
.in -8
};
.sp
@@ -83,4 +83,4 @@ fails if the QP is attached to a multicast group.
.BR ibv_query_qp (3)
.SH "AUTHORS"
.TP
-Dotan Barak <dotanb@mellanox.co.il>
+Dotan Barak <dotanba@gmail.com>
diff --git a/contrib/ofed/libibverbs/man/ibv_create_qp_ex.3 b/contrib/ofed/libibverbs/man/ibv_create_qp_ex.3
new file mode 100644
index 0000000..99ae497
--- /dev/null
+++ b/contrib/ofed/libibverbs/man/ibv_create_qp_ex.3
@@ -0,0 +1,105 @@
+.\" -*- nroff -*-
+.\" Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md
+.\"
+.TH IBV_CREATE_QP_EX 3 2013-06-26 libibverbs "Libibverbs Programmer's Manual"
+.SH "NAME"
+ibv_create_qp_ex, ibv_destroy_qp \- create or destroy a queue pair (QP)
+.SH "SYNOPSIS"
+.nf
+.B #include <infiniband/verbs.h>
+.sp
+.BI "struct ibv_qp *ibv_create_qp_ex(struct ibv_context " "*context" ,
+.BI " struct ibv_qp_init_attr_ex " "*qp_init_attr" );
+.sp
+.BI "int ibv_destroy_qp(struct ibv_qp " "*qp" );
+.fi
+.SH "DESCRIPTION"
+.B ibv_create_qp_ex()
+creates a queue pair (QP) associated with the protection domain
+.I pd\fR.
+The argument
+.I qp_init_attr_ex
+is an ibv_qp_init_attr_ex struct, as defined in <infiniband/verbs.h>.
+.PP
+.nf
+struct ibv_qp_init_attr_ex {
+.in +8
+void *qp_context; /* Associated context of the QP */
+struct ibv_cq *send_cq; /* CQ to be associated with the Send Queue (SQ) */
+struct ibv_cq *recv_cq; /* CQ to be associated with the Receive Queue (RQ) */
+struct ibv_srq *srq; /* SRQ handle if QP is to be associated with an SRQ, otherwise NULL */
+struct ibv_qp_cap cap; /* QP capabilities */
+enum ibv_qp_type qp_type; /* QP Transport Service Type: IBV_QPT_RC, IBV_QPT_UC, IBV_QPT_UD or IBV_QPT_RAW_PACKET */
+int sq_sig_all; /* If set, each Work Request (WR) submitted to the SQ generates a completion entry */
+uint32_t comp_mask; /* Identifies valid fields */
+struct ibv_pd *pd; /* PD to be associated with the QP */
+struct ibv_xrcd *xrcd; /* XRC domain to be associated with the target QP */
+enum ibv_qp_create_flags create_flags; /* Creation flags for this QP */
+uint16_t max_tso_header; /* Maximum TSO header size */
+struct ibv_rwq_ind_table *rwq_ind_tbl; /* Indirection table to be associated with the QP */
+struct ibv_rx_hash_conf rx_hash_conf; /* RX hash configuration to be used */
+.in -8
+};
+.sp
+.nf
+struct ibv_qp_cap {
+.in +8
+uint32_t max_send_wr; /* Requested max number of outstanding WRs in the SQ */
+uint32_t max_recv_wr; /* Requested max number of outstanding WRs in the RQ */
+uint32_t max_send_sge; /* Requested max number of scatter/gather (s/g) elements in a WR in the SQ */
+uint32_t max_recv_sge; /* Requested max number of s/g elements in a WR in the SQ */
+uint32_t max_inline_data;/* Requested max number of data (bytes) that can be posted inline to the SQ, otherwise 0 */
+.in -8
+};
+.nf
+enum ibv_qp_create_flags {
+.in +8
+IBV_QP_CREATE_BLOCK_SELF_MCAST_LB = 1 << 1, /* Prevent self multicast loopback */
+IBV_QP_CREATE_SCATTER_FCS = 1 << 8, /* FCS field will be scattered to host memory */
+IBV_QP_CREATE_CVLAN_STRIPPING = 1 << 9, /* CVLAN field will be stripped from incoming packets */
+.in -8
+};
+.nf
+struct ibv_rx_hash_conf {
+.in +8
+uint8_t rx_hash_function; /* RX hash function, use enum ibv_rx_hash_function_flags */
+uint8_t rx_hash_key_len; /* RX hash key length */
+uint8_t *rx_hash_key; /* RX hash key data */
+uint64_t rx_hash_fields_mask; /* RX fields that should participate in the hashing, use enum ibv_rx_hash_fields */
+.in -8
+};
+.fi
+.PP
+The function
+.B ibv_create_qp_ex()
+will update the
+.I qp_init_attr_ex\fB\fR->cap
+struct with the actual \s-1QP\s0 values of the QP that was created;
+the values will be greater than or equal to the values requested.
+.PP
+.B ibv_destroy_qp()
+destroys the QP
+.I qp\fR.
+.SH "RETURN VALUE"
+.B ibv_create_qp_ex()
+returns a pointer to the created QP, or NULL if the request fails.
+Check the QP number (\fBqp_num\fR) in the returned QP.
+.PP
+.B ibv_destroy_qp()
+returns 0 on success, or the value of errno on failure (which indicates the failure reason).
+.SH "NOTES"
+.PP
+The attributes max_recv_wr and max_recv_sge are ignored by
+.B ibv_create_qp_ex()
+if the QP is to be associated with an SRQ.
+.PP
+.B ibv_destroy_qp()
+fails if the QP is attached to a multicast group.
+.SH "SEE ALSO"
+.BR ibv_alloc_pd (3),
+.BR ibv_modify_qp (3),
+.BR ibv_query_qp (3),
+.BR ibv_create_rwq_ind_table (3)
+.SH "AUTHORS"
+.TP
+Yishai Hadas <yishaih@mellanox.com>
diff --git a/contrib/ofed/libibverbs/man/ibv_create_rwq_ind_table.3 b/contrib/ofed/libibverbs/man/ibv_create_rwq_ind_table.3
new file mode 100644
index 0000000..176a5f1
--- /dev/null
+++ b/contrib/ofed/libibverbs/man/ibv_create_rwq_ind_table.3
@@ -0,0 +1,59 @@
+.\" -*- nroff -*-
+.\" Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md
+.\"
+.TH CREATE_RWQ_IND_TBL 3 2016-07-27 libibverbs "Libibverbs Programmer's Manual"
+.SH "NAME"
+ibv_create_rwq_ind_table, ibv_destroy_rwq_ind_table \- create or destroy a Receive Work Queue Indirection Table (RWQ IND TBL).
+.SH "SYNOPSIS"
+.nf
+.B #include <infiniband/verbs.h>
+.sp
+.BI "struct ibv_rwq_ind_table *ibv_create_rwq_ind_table(struct ibv_context " "*context,"
+.BI " struct ibv_rwq_ind_table_init_attr " "*init_attr" );
+.sp
+.BI "int ibv_destroy_rwq_ind_table(struct ibv_rwq_ind_table " "*rwq_ind_table" );
+.fi
+.SH "DESCRIPTION"
+.B ibv_create_rwq_ind_table()
+creates a RWQ IND TBL associated with the ibv_context
+.I context\fR.
+The argument
+.I init_attr
+is an ibv_rwq_ind_table_init_attr struct, as defined in <infiniband/verbs.h>.
+.PP
+.nf
+struct ibv_rwq_ind_table_init_attr {
+.in +8
+uint32_t log_ind_tbl_size; /* Log, base 2, of Indirection table size */
+struct ibv_wq **ind_tbl; /* Each entry is a pointer to Receive Work Queue */
+uint32_t comp_mask; /* Identifies valid fields. Use ibv_ind_table_init_attr_mask */
+.in -8
+};
+.fi
+.PP
+The function
+.B ibv_create_rwq_ind_table()
+will create a RWQ IND TBL that holds a table of Receive Work Queue.
+For further usage of the created object see below
+.I NOTES\fR.
+.PP
+.B ibv_destroy_rwq_ind_table()
+destroys the RWQ IND TBL
+.I rwq_ind_table\fR.
+.SH "RETURN VALUE"
+.B ibv_create_rwq_ind_table()
+returns a pointer to the created RWQ IND TBL, or NULL if the request fails.
+.PP
+.B ibv_destroy_rwq_ind_table()
+returns 0 on success, or the value of errno on failure (which indicates the failure reason).
+.SH "NOTES"
+The created object should be used as part of
+.I ibv_create_qp_ex()
+to enable dispatching of incoming packets based on some RX hash configuration.
+.SH "SEE ALSO"
+.BR ibv_create_wq (3),
+.BR ibv_modify_wq (3),
+.BR ibv_create_qp_ex (3),
+.SH "AUTHORS"
+.TP
+Yishai Hadas <yishaih@mellanox.com>
diff --git a/contrib/ofed/libibverbs/man/ibv_create_srq.3 b/contrib/ofed/libibverbs/man/ibv_create_srq.3
index fae9c0c..46ab8dd 100644
--- a/contrib/ofed/libibverbs/man/ibv_create_srq.3
+++ b/contrib/ofed/libibverbs/man/ibv_create_srq.3
@@ -1,4 +1,5 @@
.\" -*- nroff -*-
+.\" Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md
.\"
.TH IBV_CREATE_SRQ 3 2006-10-31 libibverbs "Libibverbs Programmer's Manual"
.SH "NAME"
@@ -10,26 +11,12 @@ ibv_create_srq, ibv_destroy_srq \- create or destroy a shared receive queue (SRQ
.BI "struct ibv_srq *ibv_create_srq(struct ibv_pd " "*pd" ", struct "
.BI " ibv_srq_init_attr " "*srq_init_attr" );
.sp
-.BI "struct ibv_srq *ibv_create_xrc_srq(struct ibv_pd " "*pd" ",
-.BI " struct ibv_xrc_domain " "*xrc_domain" ",
-.BI " struct ibv_cq " "*xrc_cq" ",
-.BI " struct ibv_srq_init_attr " "*srq_init_attr" );
-.sp
.BI "int ibv_destroy_srq(struct ibv_srq " "*srq" );
.fi
.SH "DESCRIPTION"
.B ibv_create_srq()
creates a shared receive queue (SRQ) associated with the protection domain
.I pd\fR.
-.PP
-.B ibv_create_xrc_srq()
-creates an XRC shared receive queue (SRQ) associated with the protection domain
-.I pd\fR,
-the XRC domain
-.I xrc_domain
-and the CQ which will hold the XRC completion
-.I xrc_cq\fR.
-.PP
The argument
.I srq_init_attr
is an ibv_srq_init_attr struct, as defined in <infiniband/verbs.h>.
@@ -78,4 +65,4 @@ fails if any queue pair is still associated with this SRQ.
.BR ibv_query_srq (3)
.SH "AUTHORS"
.TP
-Dotan Barak <dotanb@mellanox.co.il>
+Dotan Barak <dotanba@gmail.com>
diff --git a/contrib/ofed/libibverbs/man/ibv_create_srq_ex.3 b/contrib/ofed/libibverbs/man/ibv_create_srq_ex.3
new file mode 100644
index 0000000..c031906
--- /dev/null
+++ b/contrib/ofed/libibverbs/man/ibv_create_srq_ex.3
@@ -0,0 +1,72 @@
+.\" -*- nroff -*-
+.\" Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md
+.\"
+.TH IBV_CREATE_SRQ_EX 3 2013-06-26 libibverbs "Libibverbs Programmer's Manual"
+.SH "NAME"
+ibv_create_srq_ex, ibv_destroy_srq \- create or destroy a shared receive queue (SRQ)
+.SH "SYNOPSIS"
+.nf
+.B #include <infiniband/verbs.h>
+.sp
+.BI "struct ibv_srq *ibv_create_srq_ex(struct ibv_context " "*context" ", struct "
+.BI " ibv_srq_init_attr_ex " "*srq_init_attr_ex" );
+.sp
+.BI "int ibv_destroy_srq(struct ibv_srq " "*srq" );
+.fi
+.SH "DESCRIPTION"
+.B ibv_create_srq_ex()
+creates a shared receive queue (SRQ) supporting both basic and xrc modes.
+The argument
+.I srq_init_attr_ex
+is an ibv_srq_init_attr_ex struct, as defined in <infiniband/verbs.h>.
+.PP
+.nf
+struct ibv_srq_init_attr_ex {
+.in +8
+void *srq_context; /* Associated context of the SRQ */
+struct ibv_srq_attr attr; /* SRQ attributes */
+uint32_t comp_mask; /* Identifies valid fields */
+enum ibv_srq_type srq_type; /* Basic / XRC */
+struct ibv_pd *pd; /* PD associated with the SRQ */
+struct ibv_xrcd *xrcd; /* XRC domain to associate with the SRQ */
+struct ibv_cq *cq; /* CQ to associate with the SRQ for XRC mode */
+.in -8
+};
+.sp
+.nf
+struct ibv_srq_attr {
+.in +8
+uint32_t max_wr; /* Requested max number of outstanding work requests (WRs) in the SRQ */
+uint32_t max_sge; /* Requested max number of scatter elements per WR */
+uint32_t srq_limit; /* The limit value of the SRQ */
+.in -8
+};
+.fi
+.PP
+The function
+.B ibv_create_srq_ex()
+will update the
+.I srq_init_attr_ex
+struct with the original values of the SRQ that was created; the
+values of max_wr and max_sge will be greater than or equal to the
+values requested.
+.PP
+.B ibv_destroy_srq()
+destroys the SRQ
+.I srq\fR.
+.SH "RETURN VALUE"
+.B ibv_create_srq_ex()
+returns a pointer to the created SRQ, or NULL if the request fails.
+.PP
+.B ibv_destroy_srq()
+returns 0 on success, or the value of errno on failure (which indicates the failure reason).
+.SH "NOTES"
+.B ibv_destroy_srq()
+fails if any queue pair is still associated with this SRQ.
+.SH "SEE ALSO"
+.BR ibv_alloc_pd (3),
+.BR ibv_modify_srq (3),
+.BR ibv_query_srq (3)
+.SH "AUTHORS"
+.TP
+Yishai Hadas <yishaih@mellanox.com>
diff --git a/contrib/ofed/libibverbs/man/ibv_create_wq.3 b/contrib/ofed/libibverbs/man/ibv_create_wq.3
new file mode 100644
index 0000000..4a8b83c
--- /dev/null
+++ b/contrib/ofed/libibverbs/man/ibv_create_wq.3
@@ -0,0 +1,72 @@
+.\" -*- nroff -*-
+.\" Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md
+.\"
+.TH IBV_CREATE_WQ 3 2016-07-27 libibverbs "Libibverbs Programmer's Manual"
+.SH "NAME"
+ibv_create_wq, ibv_destroy_wq \- create or destroy a Work Queue (WQ).
+.SH "SYNOPSIS"
+.nf
+.B #include <infiniband/verbs_exp.h>
+.sp
+.BI "struct ibv_wq *ibv_create_wq(struct ibv_context " "*context,"
+.BI " struct ibv_wq_init_attr " "*wq_init_attr" );
+.sp
+.BI "int ibv_destroy_wq(struct ibv_wq " "*wq" );
+.fi
+.SH "DESCRIPTION"
+.B ibv_create_wq()
+creates a WQ associated with the ibv_context
+.I context\fR.
+The argument
+.I wq_init_attr
+is an ibv_wq_init_attr struct, as defined in <infiniband/verbs.h>.
+.PP
+.nf
+struct ibv_wq_init_attr {
+.in +8
+void *wq_context; /* Associated context of the WQ */
+enum ibv_wq_type wq_type; /* WQ type */
+uint32_t max_wr; /* Requested max number of outstanding WRs in the WQ */
+uint32_t max_sge; /* Requested max number of scatter/gather (s/g) elements per WR in the WQ */
+struct ibv_pd *pd; /* PD to be associated with the WQ */
+struct ibv_cq *cq; /* CQ to be associated with the WQ */
+uint32_t comp_mask; /* Identifies valid fields. Use ibv_wq_init_attr_mask */
+uint32_t create_flags /* Creation flags for this WQ, use enum ibv_wq_flags */
+.in -8
+};
+
+.sp
+.nf
+enum ibv_wq_flags {
+.in +8
+IBV_WQ_FLAGS_CVLAN_STRIPPING = 1 << 0, /* CVLAN field will be stripped from incoming packets */
+IBV_WQ_FLAGS_SCATTER_FCS = 1 << 1, /* FCS field will be scattered to host memory */
+IBV_WQ_FLAGS_RESERVED = 1 << 2,
+.in -8
+};
+.nf
+.fi
+.PP
+The function
+.B ibv_create_wq()
+will update the
+.I wq_init_attr\fB\fR->max_wr
+and
+.I wq_init_attr\fB\fR->max_sge
+fields with the actual \s-1WQ\s0 values of the WQ that was created;
+the values will be greater than or equal to the values requested.
+.PP
+.B ibv_destroy_wq()
+destroys the WQ
+.I wq\fR.
+.SH "RETURN VALUE"
+.B ibv_create_wq()
+returns a pointer to the created WQ, or NULL if the request fails.
+.PP
+.B ibv_destroy_wq()
+returns 0 on success, or the value of errno on failure (which indicates the failure reason).
+.SH "SEE ALSO"
+.BR ibv_modify_wq (3),
+.SH "AUTHORS"
+.TP
+Yishai Hadas <yishaih@mellanox.com>
diff --git a/contrib/ofed/libibverbs/man/ibv_create_xrc_rcv_qp.3 b/contrib/ofed/libibverbs/man/ibv_create_xrc_rcv_qp.3
deleted file mode 100644
index 2877c15..0000000
--- a/contrib/ofed/libibverbs/man/ibv_create_xrc_rcv_qp.3
+++ /dev/null
@@ -1,70 +0,0 @@
-.\" -*- nroff -*-
-.\"
-.TH IBV_CREATE_XRC_RCV_QP 3 2008-02-10 libibverbs "Libibverbs Programmer's Manual"
-.SH "NAME"
-ibv_create_xrc_rcv_qp \- create an XRC queue pair (QP) for serving as a receive-side only QP
-.SH "SYNOPSIS"
-.nf
-.B #include <infiniband/verbs.h>
-.sp
-.BI "int ibv_create_xrc_rcv_qp(struct ibv_qp_init_attr " "*init_attr" ,
-.BI " uint32_t " "*xrc_rcv_qpn" );
-.fi
-.SH "DESCRIPTION"
-.B ibv_create_xrc_rcv_qp()
-creates an XRC queue pair (QP) for serving as a receive-side only QP and returns its number through the pointer
-.I xrc_rcv_qpn\fR.
-This QP number should be passed to the remote node (sender).
-The remote node will use
-.I xrc_rcv_qpn
-in
-.B ibv_post_send()
-when sending to an XRC SRQ on this host in the same xrc domain as the XRC receive QP.
-This QP is created in kernel space, and persists until the last process registered for the QP
-calls
-.B ibv_unreg_xrc_rcv_qp()
-(at which time the QP is destroyed).
-.PP
-The process which creates this QP is automatically registered for it, and should also call
-.B ibv_unreg_xrc_rcv_qp()
-at some point, to unregister.
-
-Processes which wish to receive on an XRC SRQ via this QP should call
-.B ibv_reg_xrc_rcv_qp()
-for this QP, to guarantee that the QP will not be destroyed while they are still using it for receiving on the XRC SRQ.
-.PP
-The argument
-.I qp_init_attr
-is an ibv_qp_init_attr struct, as defined in <infiniband/verbs.h>.
-.PP
-.nf
-struct ibv_qp_init_attr {
-.in +8
-void *qp_context; /* value is being ignored */
-struct ibv_cq *send_cq; /* value is being ignored */
-struct ibv_cq *recv_cq; /* value is being ignored */
-struct ibv_srq *srq; /* value is being ignored */
-struct ibv_qp_cap cap; /* value is being ignored */
-enum ibv_qp_type qp_type; /* value is being ignored */
-int sq_sig_all; /* value is being ignored */
-struct ibv_xrc_domain *xrc_domain; /* XRC domain the QP will be associated with */
-.in -8
-};
-.fi
-.PP
-Most of the attributes in
-.I qp_init_attr
-are being ignored because this QP is a receive only QP and all RR are being posted to an SRQ.
-.SH "RETURN VALUE"
-.B ibv_create_xrc_rcv_qp()
-returns 0 on success, or the value of errno on failure (which indicates the failure reason).
-.SH "SEE ALSO"
-.BR ibv_open_xrc_domain (3),
-.BR ibv_modify_xrc_rcv_qp (3),
-.BR ibv_query_xrc_rcv_qp (3),
-.BR ibv_reg_xrc_rcv_qp (3),
-.BR ibv_unreg_xrc_rcv_qp (3),
-.BR ibv_post_send (3)
-.SH "AUTHORS"
-.TP
-Dotan Barak <dotanb@mellanox.co.il>
diff --git a/contrib/ofed/libibverbs/man/ibv_devices.1 b/contrib/ofed/libibverbs/man/ibv_devices.1
index 99b27e5..ffd57f8 100644
--- a/contrib/ofed/libibverbs/man/ibv_devices.1
+++ b/contrib/ofed/libibverbs/man/ibv_devices.1
@@ -1,3 +1,4 @@
+.\" Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md
.TH IBV_DEVICES 1 "August 30, 2005" "libibverbs" "USER COMMANDS"
.SH NAME
diff --git a/contrib/ofed/libibverbs/man/ibv_devinfo.1 b/contrib/ofed/libibverbs/man/ibv_devinfo.1
index 41878b2..b5e9a58 100644
--- a/contrib/ofed/libibverbs/man/ibv_devinfo.1
+++ b/contrib/ofed/libibverbs/man/ibv_devinfo.1
@@ -1,3 +1,4 @@
+.\" Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md
.TH IBV_DEVINFO 1 "August 30, 2005" "libibverbs" "USER COMMANDS"
.SH NAME
@@ -33,7 +34,7 @@ print all available information about RDMA devices
.SH AUTHORS
.TP
Dotan Barak
-.RI < dotanb@mellanox.co.il >
+.RI < dotanba@gmail.com >
.TP
Roland Dreier
.RI < rolandd@cisco.com >
diff --git a/contrib/ofed/libibverbs/man/ibv_event_type_str.3 b/contrib/ofed/libibverbs/man/ibv_event_type_str.3
index f9ebc35..2ae8b1c 100644
--- a/contrib/ofed/libibverbs/man/ibv_event_type_str.3
+++ b/contrib/ofed/libibverbs/man/ibv_event_type_str.3
@@ -1,4 +1,5 @@
.\" -*- nroff -*-
+.\" Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md
.\"
.TH IBV_EVENT_TYPE_STR 3 2006-10-31 libibverbs "Libibverbs Programmer's Manual"
.SH "NAME"
diff --git a/contrib/ofed/libibverbs/man/ibv_fork_init.3 b/contrib/ofed/libibverbs/man/ibv_fork_init.3
index b34f71f..012ea20 100644
--- a/contrib/ofed/libibverbs/man/ibv_fork_init.3
+++ b/contrib/ofed/libibverbs/man/ibv_fork_init.3
@@ -1,4 +1,5 @@
.\" -*- nroff -*-
+.\" Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md
.\"
.TH IBV_FORK_INIT 3 2006-10-31 libibverbs "Libibverbs Programmer's Manual"
.SH "NAME"
@@ -41,12 +42,22 @@ or
has the same effect as calling
.B ibv_fork_init()\fR.
.PP
+Setting the environment variable
+.BR RDMAV_HUGEPAGES_SAFE
+tells the library to check the underlying page size used by the kernel
+for memory regions. This is required if an application uses huge
+pages either directly or indirectly via a library such as libhugetlbfs.
+.PP
Calling
.B ibv_fork_init()
will reduce performance due to an extra system call for every memory
registration, and the additional memory allocated to track memory
regions. The precise performance impact depends on the workload and
usually will not be significant.
+.PP
+Setting
+.BR RDMAV_HUGEPAGES_SAFE
+adds further overhead to all memory registrations.
.SH "SEE ALSO"
.BR fork (2),
.BR wait (2),
@@ -55,4 +66,4 @@ usually will not be significant.
.BR ibv_get_device_list (3)
.SH "AUTHORS"
.TP
-Dotan Barak <dotanb@mellanox.co.il>
+Dotan Barak <dotanba@gmail.com>
diff --git a/contrib/ofed/libibverbs/man/ibv_get_async_event.3 b/contrib/ofed/libibverbs/man/ibv_get_async_event.3
index 7426f4d..85ce6e1 100644
--- a/contrib/ofed/libibverbs/man/ibv_get_async_event.3
+++ b/contrib/ofed/libibverbs/man/ibv_get_async_event.3
@@ -1,4 +1,5 @@
.\" -*- nroff -*-
+.\" Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md
.\"
.TH IBV_GET_ASYNC_EVENT 3 2006-10-31 libibverbs "Libibverbs Programmer's Manual"
.SH "NAME"
@@ -81,6 +82,8 @@ following events:
.B IBV_EVENT_SM_CHANGE \fR SM was changed on a port
.TP
.B IBV_EVENT_CLIENT_REREGISTER \fR SM sent a CLIENT_REREGISTER request to a port
+.TP
+.B IBV_EVENT_GID_CHANGE \fR GID table was changed on a port
.PP
.I CA events:
.TP
@@ -159,4 +162,4 @@ ibv_ack_async_event(&async_event);
.BR ibv_open_device (3)
.SH "AUTHORS"
.TP
-Dotan Barak <dotanb@mellanox.co.il>
+Dotan Barak <dotanba@gmail.com>
diff --git a/contrib/ofed/libibverbs/man/ibv_get_cq_event.3 b/contrib/ofed/libibverbs/man/ibv_get_cq_event.3
index 58c744a..a1a42e6 100644
--- a/contrib/ofed/libibverbs/man/ibv_get_cq_event.3
+++ b/contrib/ofed/libibverbs/man/ibv_get_cq_event.3
@@ -1,4 +1,5 @@
.\" -*- nroff -*-
+.\" Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md
.\"
.TH IBV_GET_CQ_EVENT 3 2006-10-31 libibverbs "Libibverbs Programmer's Manual"
.SH "NAME"
@@ -182,4 +183,4 @@ ibv_ack_cq_events(ev_cq, 1);
.SH "AUTHORS"
.TP
Dotan Barak
-.RI < dotanb@mellanox.co.il >
+.RI < dotanba@gmail.com >
diff --git a/contrib/ofed/libibverbs/man/ibv_get_device_guid.3 b/contrib/ofed/libibverbs/man/ibv_get_device_guid.3
index 98c0499..4652614 100644
--- a/contrib/ofed/libibverbs/man/ibv_get_device_guid.3
+++ b/contrib/ofed/libibverbs/man/ibv_get_device_guid.3
@@ -1,4 +1,5 @@
.\" -*- nroff -*-
+.\" Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md
.\"
.TH IBV_GET_DEVICE_GUID 3 2006-10-31 libibverbs "Libibverbs Programmer's Manual"
.SH "NAME"
@@ -22,4 +23,4 @@ returns the GUID of the device in network byte order.
.BR ibv_open_device (3)
.SH "AUTHORS"
.TP
-Dotan Barak <dotanb@mellanox.co.il>
+Dotan Barak <dotanba@gmail.com>
diff --git a/contrib/ofed/libibverbs/man/ibv_get_device_list.3 b/contrib/ofed/libibverbs/man/ibv_get_device_list.3
index 399beea..71c4a74 100644
--- a/contrib/ofed/libibverbs/man/ibv_get_device_list.3
+++ b/contrib/ofed/libibverbs/man/ibv_get_device_list.3
@@ -1,4 +1,5 @@
.\" -*- nroff -*-
+.\" Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md
.\"
.TH IBV_GET_DEVICE_LIST 3 2006-10-31 libibverbs "Libibverbs Programmer's Manual"
.SH "NAME"
@@ -50,6 +51,12 @@ Client code should open all the devices it intends to use with
Once it frees the array with
.B ibv_free_device_list()\fR,
it will be able to use only the open devices; pointers to unopened devices will no longer be valid.
+.P
+Setting the environment variable
+.BR IBV_SHOW_WARNINGS
+will cause warnings to be emitted to stderr if a kernel verbs device
+is discovered, but no corresponding userspace driver can be found for
+it.
.SH "SEE ALSO"
.BR ibv_fork_init (3),
.BR ibv_get_device_name (3),
@@ -57,4 +64,4 @@ it will be able to use only the open devices; pointers to unopened devices will
.BR ibv_open_device (3)
.SH "AUTHORS"
.TP
-Dotan Barak <dotanb@mellanox.co.il>
+Dotan Barak <dotanba@gmail.com>
diff --git a/contrib/ofed/libibverbs/man/ibv_get_device_name.3 b/contrib/ofed/libibverbs/man/ibv_get_device_name.3
index 284ea9f..ff9fa7f 100644
--- a/contrib/ofed/libibverbs/man/ibv_get_device_name.3
+++ b/contrib/ofed/libibverbs/man/ibv_get_device_name.3
@@ -1,4 +1,5 @@
.\" -*- nroff -*-
+.\" Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md
.\"
.TH IBV_GET_DEVICE_NAME 3 2006-10-31 libibverbs "Libibverbs Programmer's Manual"
.SH "NAME"
@@ -22,4 +23,4 @@ returns a pointer to the device name, or NULL if the request fails.
.BR ibv_open_device (3)
.SH "AUTHORS"
.TP
-Dotan Barak <dotanb@mellanox.co.il>
+Dotan Barak <dotanba@gmail.com>
diff --git a/contrib/ofed/libibverbs/man/ibv_get_srq_num.3 b/contrib/ofed/libibverbs/man/ibv_get_srq_num.3
new file mode 100644
index 0000000..4a1c92f
--- /dev/null
+++ b/contrib/ofed/libibverbs/man/ibv_get_srq_num.3
@@ -0,0 +1,33 @@
+.\" -*- nroff -*-
+.\" Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md
+.\"
+.TH IBV_GET_SRQ_NUM 3 2013-06-26 libibverbs "Libibverbs Programmer's Manual"
+.SH "NAME"
+ibv_get_srq_num \- return srq number associated with the given shared receive queue (SRQ)
+.SH "SYNOPSIS"
+.nf
+.B #include <infiniband/verbs.h>
+.sp
+.BI "int ibv_get_srq_num(struct ibv_srq " "*srq" ,
+.BI " uint32_t " "*srq_num" );
+.fi
+.SH "DESCRIPTION"
+.B ibv_get_srq_num()
+return srq number associated with the given shared receive queue
+The argument
+.I srq
+is an ibv_srq struct, as defined in <infiniband/verbs.h>.
+.I srq_num
+is an output parameter that holds the returned srq number.
+.PP
+.nf
+.SH "RETURN VALUE"
+.B ibv_get_srq_num()
+returns 0 on success, or the value of errno on failure (which indicates the failure reason).
+.SH "SEE ALSO"
+.BR ibv_alloc_pd (3),
+.BR ibv_modify_srq (3),
+.BR ibv_create_srq_ex (3)
+.SH "AUTHORS"
+.TP
+Yishai Hadas <yishaih@mellanox.com>
diff --git a/contrib/ofed/libibverbs/man/ibv_inc_rkey.3 b/contrib/ofed/libibverbs/man/ibv_inc_rkey.3
new file mode 100644
index 0000000..5c54a68
--- /dev/null
+++ b/contrib/ofed/libibverbs/man/ibv_inc_rkey.3
@@ -0,0 +1,33 @@
+.\" -*- nroff -*-
+.\" Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md
+.\"
+.TH IBV_INC_RKEY 3 2015-01-29 libibverbs "Libibverbs Programmer's Manual"
+.SH "NAME"
+.nf
+ibv_inc_rkey \- creates a new rkey from the given one
+.SH "SYNOPSIS"
+.nf
+.B #include <infiniband/verbs.h>
+.sp
+.BI "uint32_t ibv_inc_rkey(uint32_t " "rkey" ");
+.fi
+.SH "DESCRIPTION"
+.B ibv_inc_rkey()
+Increases the 8 LSB of
+.I rkey
+and returns the new value.
+.PP
+.SH "RETURN VALUE"
+.B ibv_inc_rkey()
+returns the new rkey.
+.SH "NOTES"
+.PP
+The verb generates a new rkey that is different from the previous one on its tag part
+but has the same index (bits 0xffffff00).
+A use case for this verb can be to create a new rkey from a Memory window's rkey
+when binding it to a Memory region.
+.SH "AUTHORS"
+.TP
+Majd Dibbiny <majd@mellanox.com>
+.TP
+Yishai Hadas <yishaih@mellanox.com>
diff --git a/contrib/ofed/libibverbs/man/ibv_modify_qp.3 b/contrib/ofed/libibverbs/man/ibv_modify_qp.3
index 864ffe6..487aa94 100644
--- a/contrib/ofed/libibverbs/man/ibv_modify_qp.3
+++ b/contrib/ofed/libibverbs/man/ibv_modify_qp.3
@@ -1,4 +1,5 @@
.\" -*- nroff -*-
+.\" Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md
.\"
.TH IBV_MODIFY_QP 3 2006-10-31 libibverbs "Libibverbs Programmer's Manual"
.SH "NAME"
@@ -48,6 +49,7 @@ uint8_t retry_cnt; /* Retry count (valid only for R
uint8_t rnr_retry; /* RNR retry (valid only for RC QPs) */
uint8_t alt_port_num; /* Alternate port number */
uint8_t alt_timeout; /* Local ack timeout for alternate path (valid only for RC QPs) */
+uint32_t rate_limit; /* Rate limit in kbps for packet pacing */
.in -8
};
.fi
@@ -104,6 +106,7 @@ The argument is either 0 or the bitwise OR of one or more of the following flags
.B IBV_QP_CAP \fR Set cap
.TP
.B IBV_QP_DEST_QPN \fR Set dest_qp_num
+.B IBV_QP_RATE_LIMIT \fR Set rate_limit
.SH "RETURN VALUE"
.B ibv_modify_qp()
returns 0 on success, or the value of errno on failure (which indicates the failure reason).
@@ -159,6 +162,16 @@ RTR \fB IBV_QP_STATE, IBV_QP_AV, IBV_QP_PATH_MTU, \fR
RTS \fB IBV_QP_STATE, IBV_QP_SQ_PSN, IBV_QP_MAX_QP_RD_ATOMIC, \fR
\fB IBV_QP_RETRY_CNT, IBV_QP_RNR_RETRY, IBV_QP_TIMEOUT \fR
.fi
+.PP
+.nf
+For QP Transport Service Type \fB IBV_QPT_RAW_PACKET\fR:
+.sp
+Next state Required attributes
+\-\-\-\-\-\-\-\-\-\- \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-
+Init \fB IBV_QP_STATE, IBV_QP_PORT\fR
+RTR \fB IBV_QP_STATE\fR
+RTS \fB IBV_QP_STATE\fR
+.fi
.SH "SEE ALSO"
.BR ibv_create_qp (3),
.BR ibv_destroy_qp (3),
@@ -166,4 +179,4 @@ RTS \fB IBV_QP_STATE, IBV_QP_SQ_PSN, IBV_QP_MAX_QP_RD_ATOMIC, \fR
.BR ibv_create_ah (3)
.SH "AUTHORS"
.TP
-Dotan Barak <dotanb@mellanox.co.il>
+Dotan Barak <dotanba@gmail.com>
diff --git a/contrib/ofed/libibverbs/man/ibv_modify_srq.3 b/contrib/ofed/libibverbs/man/ibv_modify_srq.3
index 184af5f..5233922 100644
--- a/contrib/ofed/libibverbs/man/ibv_modify_srq.3
+++ b/contrib/ofed/libibverbs/man/ibv_modify_srq.3
@@ -1,4 +1,5 @@
.\" -*- nroff -*-
+.\" Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md
.\"
.TH IBV_MODIFY_SRQ 3 2006-10-31 libibverbs "Libibverbs Programmer's Manual"
.SH "NAME"
@@ -60,4 +61,4 @@ Modifying the srq_limit arms the SRQ to produce an
.BR ibv_query_srq (3)
.SH "AUTHORS"
.TP
-Dotan Barak <dotanb@mellanox.co.il>
+Dotan Barak <dotanba@gmail.com>
diff --git a/contrib/ofed/libibverbs/man/ibv_modify_wq.3 b/contrib/ofed/libibverbs/man/ibv_modify_wq.3
new file mode 100644
index 0000000..1972ec2
--- /dev/null
+++ b/contrib/ofed/libibverbs/man/ibv_modify_wq.3
@@ -0,0 +1,46 @@
+.\" -*- nroff -*-
+.\" Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md
+.\"
+.TH IBV_MODIFY_WQ 3 2016-07-27 libibverbs "Libibverbs Programmer's Manual"
+.SH "NAME"
+ibv_modify_wq \- Modify a Work Queue (WQ).
+.SH "SYNOPSIS"
+.nf
+.B #include <infiniband/verbs.h>
+.sp
+.BI "struct int ibv_modify_wq(struct ibv_wq " "*wq,"
+.BI " struct ibv_wq_attr " "*wq_attr" );
+.sp
+.fi
+.SH "DESCRIPTION"
+.B ibv_modify_wq()
+modifys a WQ
+.I wq\fR.
+The argument
+.I wq_attr
+is an ibv_wq_attr struct, as defined in <infiniband/verbs.h>.
+.PP
+.nf
+struct ibv_wq_attr {
+.in +8
+uint32_t attr_mask; /* Use enum ibv_wq_attr_mask */
+enum ibv_wq_state wq_state; /* Move to this state */
+enum ibv_wq_state curr_wq_state; /* Assume this is the current state */
+uint32_t flags; /* Flags values to modify, use enum ibv_wq_flags */
+uint32_t flags_mask; /* Which flags to modify, use enum ibv_wq_flags */
+.in -8
+};
+.fi
+.PP
+The function
+.B ibv_modify_wq()
+will modify the WQ based on the given
+.I wq_attr\fB\fR->attr_mask
+.SH "RETURN VALUE"
+returns 0 on success, or the value of errno on failure (which indicates the failure reason).
+.SH "SEE ALSO"
+.BR ibv_create_wq (3),
+.BR ibv_destroy_wq (3),
+.SH "AUTHORS"
+.TP
+Yishai Hadas <yishaih@mellanox.com>
diff --git a/contrib/ofed/libibverbs/man/ibv_modify_xrc_rcv_qp.3 b/contrib/ofed/libibverbs/man/ibv_modify_xrc_rcv_qp.3
deleted file mode 100644
index cebe5b7..0000000
--- a/contrib/ofed/libibverbs/man/ibv_modify_xrc_rcv_qp.3
+++ /dev/null
@@ -1,141 +0,0 @@
-.\" -*- nroff -*-
-.\"
-.TH IBV_MODIFY_XRC_RCV_QP 3 2008-02-10 libibverbs "Libibverbs Programmer's Manual"
-.SH "NAME"
-ibv_modify_xrc_rcv_qp \- modify the attributes of an XRC receive queue pair (QP)
-.SH "SYNOPSIS"
-.nf
-.B #include <infiniband/verbs.h>
-.sp
-.BI "int ibv_modify_xrc_rcv_qp(struct ibv_xrc_domain " "*xrc_domain" ", uint32_t " "xrc_qp_num" ,
-.BI " struct ibv_qp_attr " "*attr" ", int " "attr_mask" );
-.fi
-.SH "DESCRIPTION"
-.B ibv_modify_qp()
-modifies the attributes of an XRC receive QP with the number
-.I xrc_qp_num
-which is associated with the XRC domain
-.I xrc_domain
-with the attributes in
-.I attr
-according to the mask
-.I attr_mask
-and move the QP state through the following transitions: Reset -> Init -> RTR.
-.I attr_mask
-should indicate all of the attributes which will be used in this QP transition and the following masks (at least) should be set:
-.PP
-.nf
-Next state Required attributes
-\-\-\-\-\-\-\-\-\-\- \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-
-Init \fB IBV_QP_STATE, IBV_QP_PKEY_INDEX, IBV_QP_PORT, \fR
- \fB IBV_QP_ACCESS_FLAGS \fR
-RTR \fB IBV_QP_STATE, IBV_QP_AV, IBV_QP_PATH_MTU, \fR
- \fB IBV_QP_DEST_QPN, IBV_QP_RQ_PSN, \fR
- \fB IBV_QP_MAX_DEST_RD_ATOMIC, IBV_QP_MIN_RNR_TIMER \fR
-.fi
-.PP
-The user can add optional attributes as well.
-.PP
-The argument \fIattr\fR is an ibv_qp_attr struct, as defined in <infiniband/verbs.h>.
-.PP
-.nf
-struct ibv_qp_attr {
-.in +8
-enum ibv_qp_state qp_state; /* Move the QP to this state */
-enum ibv_qp_state cur_qp_state; /* Assume this is the current QP state */
-enum ibv_mtu path_mtu; /* Path MTU (valid only for RC/UC QPs) */
-enum ibv_mig_state path_mig_state; /* Path migration state (valid if HCA supports APM) */
-uint32_t qkey; /* Q_Key for the QP (valid only for UD QPs) */
-uint32_t rq_psn; /* PSN for receive queue (valid only for RC/UC QPs) */
-uint32_t sq_psn; /* PSN for send queue (valid only for RC/UC QPs) */
-uint32_t dest_qp_num; /* Destination QP number (valid only for RC/UC QPs) */
-int qp_access_flags; /* Mask of enabled remote access operations (valid only for RC/UC QPs) */
-struct ibv_qp_cap cap; /* QP capabilities (valid if HCA supports QP resizing) */
-struct ibv_ah_attr ah_attr; /* Primary path address vector (valid only for RC/UC QPs) */
-struct ibv_ah_attr alt_ah_attr; /* Alternate path address vector (valid only for RC/UC QPs) */
-uint16_t pkey_index; /* Primary P_Key index */
-uint16_t alt_pkey_index; /* Alternate P_Key index */
-uint8_t en_sqd_async_notify; /* Enable SQD.drained async notification (Valid only if qp_state is SQD) */
-uint8_t sq_draining; /* Is the QP draining? Irrelevant for ibv_modify_qp() */
-uint8_t max_rd_atomic; /* Number of outstanding RDMA reads & atomic operations on the destination QP (valid only for RC QPs) */
-uint8_t max_dest_rd_atomic; /* Number of responder resources for handling incoming RDMA reads & atomic operations (valid only for RC QPs) */
-uint8_t min_rnr_timer; /* Minimum RNR NAK timer (valid only for RC QPs) */
-uint8_t port_num; /* Primary port number */
-uint8_t timeout; /* Local ack timeout for primary path (valid only for RC QPs) */
-uint8_t retry_cnt; /* Retry count (valid only for RC QPs) */
-uint8_t rnr_retry; /* RNR retry (valid only for RC QPs) */
-uint8_t alt_port_num; /* Alternate port number */
-uint8_t alt_timeout; /* Local ack timeout for alternate path (valid only for RC QPs) */
-.in -8
-};
-.fi
-.PP
-For details on struct ibv_qp_cap see the description of
-.B ibv_create_qp()\fR.
-For details on struct ibv_ah_attr see the description of
-.B ibv_create_ah()\fR.
-.PP
-The argument
-.I attr_mask
-specifies the QP attributes to be modified.
-The argument is either 0 or the bitwise OR of one or more of the following flags:
-.PP
-.TP
-.B IBV_QP_STATE \fR Modify qp_state
-.TP
-.B IBV_QP_CUR_STATE \fR Set cur_qp_state
-.TP
-.B IBV_QP_EN_SQD_ASYNC_NOTIFY \fR Set en_sqd_async_notify
-.TP
-.B IBV_QP_ACCESS_FLAGS \fR Set qp_access_flags
-.TP
-.B IBV_QP_PKEY_INDEX \fR Set pkey_index
-.TP
-.B IBV_QP_PORT \fR Set port_num
-.TP
-.B IBV_QP_QKEY \fR Set qkey
-.TP
-.B IBV_QP_AV \fR Set ah_attr
-.TP
-.B IBV_QP_PATH_MTU \fR Set path_mtu
-.TP
-.B IBV_QP_TIMEOUT \fR Set timeout
-.TP
-.B IBV_QP_RETRY_CNT \fR Set retry_cnt
-.TP
-.B IBV_QP_RNR_RETRY \fR Set rnr_retry
-.TP
-.B IBV_QP_RQ_PSN \fR Set rq_psn
-.TP
-.B IBV_QP_MAX_QP_RD_ATOMIC \fR Set max_rd_atomic
-.TP
-.B IBV_QP_ALT_PATH \fR Set the alternative path via: alt_ah_attr, alt_pkey_index, alt_port_num, alt_timeout
-.TP
-.B IBV_QP_MIN_RNR_TIMER \fR Set min_rnr_timer
-.TP
-.B IBV_QP_SQ_PSN \fR Set sq_psn
-.TP
-.B IBV_QP_MAX_DEST_RD_ATOMIC \fR Set max_dest_rd_atomic
-.TP
-.B IBV_QP_PATH_MIG_STATE \fR Set path_mig_state
-.TP
-.B IBV_QP_CAP \fR Set cap
-.TP
-.B IBV_QP_DEST_QPN \fR Set dest_qp_num
-.SH "RETURN VALUE"
-.B ibv_modify_xrc_rcv_qp()
-returns 0 on success, or the value of errno on failure (which indicates the failure reason).
-.SH "NOTES"
-If any of the modify attributes or the modify mask are invalid, none
-of the attributes will be modified (including the QP state).
-.PP
-Not all devices support alternate paths. To check if a device supports it, check if the
-.B IBV_DEVICE_AUTO_PATH_MIG
-bit is set in the device capabilities flags.
-.SH "SEE ALSO"
-.BR ibv_open_xrc_domain (3),
-.BR ibv_create_xrc_rcv_qp (3),
-.BR ibv_query_xrc_rcv_qp (3)
-.SH "AUTHORS"
-.TP
-Dotan Barak <dotanb@mellanox.co.il>
diff --git a/contrib/ofed/libibverbs/man/ibv_open_device.3 b/contrib/ofed/libibverbs/man/ibv_open_device.3
index d5149a5..cae2c4d 100644
--- a/contrib/ofed/libibverbs/man/ibv_open_device.3
+++ b/contrib/ofed/libibverbs/man/ibv_open_device.3
@@ -1,4 +1,5 @@
.\" -*- nroff -*-
+.\" Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md
.\"
.TH IBV_OPEN_DEVICE 3 2006-10-31 libibverbs "Libibverbs Programmer's Manual"
.SH "NAME"
@@ -40,4 +41,4 @@ resources before closing a context.
.BR ibv_query_pkey (3)
.SH "AUTHORS"
.TP
-Dotan Barak <dotanb@mellanox.co.il>
+Dotan Barak <dotanba@gmail.com>
diff --git a/contrib/ofed/libibverbs/man/ibv_open_qp.3 b/contrib/ofed/libibverbs/man/ibv_open_qp.3
new file mode 100644
index 0000000..e25e933
--- /dev/null
+++ b/contrib/ofed/libibverbs/man/ibv_open_qp.3
@@ -0,0 +1,52 @@
+.\" -*- nroff -*-
+.\" Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md
+.\"
+.TH IBV_OPEN_QP 3 2011-08-12 libibverbs "Libibverbs Programmer's Manual"
+.SH "NAME"
+ibv_open_qp \- open a shareable queue pair (QP)
+.SH "SYNOPSIS"
+.nf
+.B #include <infiniband/verbs.h>
+.sp
+.BI "struct ibv_qp *ibv_open_qp(struct ibv_context " "*context" ,
+.BI " struct ibv_qp_open_attr " "*qp_open_attr" );
+.fi
+.SH "DESCRIPTION"
+.B ibv_open_qp()
+opens an existing queue pair (QP) associated with the extended protection domain
+.I xrcd\fR.
+The argument
+.I qp_open_attr
+is an ibv_qp_open_attr struct, as defined in <infiniband/verbs.h>.
+.PP
+.nf
+struct ibv_qp_open_attr {
+.in +8
+uint32_t comp_mask; /* Identifies valid fields */
+uint32_t qp_num; /* QP number */
+struct *ibv_xrcd; /* XRC domain */
+void *qp_context; /* User defined opaque value */
+enum ibv_qp_type qp_type; /* QP transport service type */
+.fi
+.PP
+.B ibv_destroy_qp()
+closes the opened QP and destroys the underlying QP if it has no
+other references.
+.I qp\fR.
+.SH "RETURN VALUE"
+.B ibv_open_qp()
+returns a pointer to the opened QP, or NULL if the request fails.
+Check the QP number (\fBqp_num\fR) in the returned QP.
+.SH "NOTES"
+.B ibv_open_qp()
+will fail if a it is asked to open a QP that does not exist within
+the xrcd with the specified qp_num and qp_type.
+.SH "SEE ALSO"
+.BR ibv_alloc_pd (3),
+.BR ibv_create_qp (3),
+.BR ibv_create_qp_ex (3),
+.BR ibv_modify_qp (3),
+.BR ibv_query_qp (3)
+.SH "AUTHORS"
+.TP
+Sean Hefty <sean.hefty@intel.com>
diff --git a/contrib/ofed/libibverbs/man/ibv_open_xrc_domain.3 b/contrib/ofed/libibverbs/man/ibv_open_xrc_domain.3
deleted file mode 100644
index 874e582..0000000
--- a/contrib/ofed/libibverbs/man/ibv_open_xrc_domain.3
+++ /dev/null
@@ -1,80 +0,0 @@
-.\" -*- nroff -*-
-.\"
-.TH IBV_OPEN_XRC_DOMAIN 3 2008-02-10 libibverbs "Libibverbs Programmer's Manual"
-.SH "NAME"
-ibv_open_xrc_domain, ibv_close_xrc_domain \- open or close an eXtended Reliable Connection (XRC) domain
-.SH "SYNOPSIS"
-.nf
-.B #include <fcntl.h>
-.B #include <infiniband/verbs.h>
-.sp
-.BI "struct ibv_xrc_domain *ibv_open_xrc_domain(struct ibv_context " "*context" ","
-.BI " int " "fd" ", int " "oflag" );
-.nl
-.BI "int ibv_close_xrc_domain(struct ibv_xrc_domain " "*d" );
-.fi
-.SH "DESCRIPTION"
-.B ibv_open_xrc_domain()
-open an XRC domain for the InfiniBand device context
-.I context
-or return a reference to an opened one\fR.
-.I fd
-is the file descriptor to be associated with the XRC domain.
-The argument
-.I oflag
-describes the desired file creation attributes; it is either 0 or the bitwise OR of one or more of the following flags:
-.PP
-.TP
-.B O_CREAT
-If a domain belonging to device named by context is already associated with the inode, this flag has
-no effect, except as noted under
-.BR O_EXCL
-below. Otherwise, a new XRC domain is created and is associated with inode specified by
-.IR fd\fR.
-.TP
-.B O_EXCL
-If
-.BR O_EXCL
-and
-.BR O_CREAT
-are set, open will fail if a domain associated with the inode exists.
-The check for the existence of the domain and creation
-of the domain if it does not exist is atomic with respect to other
-processes executing open with
-.IR fd
-naming the same inode.
-.PP
-If
-.I fd
-equals -1, no inode is is associated with the domain, and the only valid value for
-.I oflag
-is
-.B O_CREAT\fR.
-.PP
-.B ibv_close_xrc_domain()
-closes the XRC domain
-.I d\fR.
-If this is the last reference, the XRC domain will be destroyed.
-.SH "RETURN VALUE"
-.B ibv_open_xrc_domain()
-returns a pointer to an opened XRC, or NULL if the request fails.
-.PP
-.B ibv_close_xrc_domain()
-returns 0 on success, or the value of errno on failure (which indicates the failure reason).
-.SH "NOTES"
-Not all devices support XRC. To check if a device supports it, check if the
-.B IBV_DEVICE_XRC
-bit is set in the device capabilities flags.
-.PP
-.B ibv_close_xrc_domain()
-may fail if any QP or SRQ are still associated with the XRC domain being closed.
-.SH "SEE ALSO"
-.BR ibv_create_xrc_srq (3),
-.BR ibv_create_qp (3),
-.BR ibv_create_xrc_rcv_qp (3),
-.BR ibv_modify_xrc_rcv_qp (3),
-.BR ibv_query_xrc_rcv_qp (3),
-.BR ibv_reg_xrc_rcv_qp (3)
-.SH "AUTHORS"
-.TP
-Dotan Barak <dotanb@mellanox.co.il>
diff --git a/contrib/ofed/libibverbs/man/ibv_open_xrcd.3 b/contrib/ofed/libibverbs/man/ibv_open_xrcd.3
new file mode 100644
index 0000000..239af2d
--- /dev/null
+++ b/contrib/ofed/libibverbs/man/ibv_open_xrcd.3
@@ -0,0 +1,77 @@
+.\" -*- nroff -*-
+.\" Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md
+.\"
+.TH IBV_OPEN_XRCD 3 2011-06-17 libibverbs "Libibverbs Programmer's Manual"
+.SH "NAME"
+ibv_open_xrcd, ibv_close_xrcd \- open or close an XRC protection domain (XRCDs)
+.SH "SYNOPSIS"
+.nf
+.B #include <infiniband/verbs.h>
+.sp
+.BI "struct ibv_xrcd *ibv_open_xrcd(struct ibv_context " "*context" ","
+.BI " struct ibv_xrcd_init_attr " "*xrcd_init_attr" );
+.sp
+.BI "int ibv_close_xrcd(struct ibv_xrcd " "*xrcd" );
+.fi
+.SH "DESCRIPTION"
+.B ibv_open_xrcd()
+open an XRC domain for the RDMA device context
+.I context
+.I xrcd_init_attr
+is an ibv_xrcd_init_attr struct, as defined in <infiniband/verbs.h>.
+.PP
+.nf
+struct ibv_xrcd_init_attr {
+.in +8
+uint32_t comp_mask; /* Identifies valid fields */
+int fd;
+int oflag;
+.fi
+.PP
+.I fd
+is the file descriptor to associate with the XRCD.
+.I oflag
+describes the desired creation attributes. It is a bitwise OR of zero or more
+of the following flags:
+.PP
+.TP
+.B O_CREAT
+Indicates that an XRCD should be created and associated with the inode referenced
+by the given fd. If the XRCD exists, this flag has no effect except as noted under
+.BR O_EXCL
+below.\fR
+.TP
+.B O_EXCL
+If
+.BR O_EXCL
+and
+.BR O_CREAT
+are set, open will fail if an XRCD associated with the inode exists.
+.PP
+If
+.I fd
+equals -1, no inode is associated with the XRCD. To indicate that XRCD should be created, use
+.I oflag
+=
+.B O_CREAT\fR.
+.PP
+.B ibv_close_xrcd()
+closes the XRCD
+.I xrcd\fR.
+If this is the last reference, the XRCD will be destroyed.
+.SH "RETURN VALUE"
+.B ibv_open_xrcd()
+returns a pointer to the opened XRCD, or NULL if the request fails.
+.PP
+.B ibv_close_xrcd()
+returns 0 on success, or the value of errno on failure (which indicates the
+failure reason).
+.SH "NOTES"
+.B ibv_close_xrcd()
+may fail if any other resource is still associated with the XRCD being closed.
+.SH "SEE ALSO"
+.BR ibv_create_srq_ex (3),
+.BR ibv_create_qp_ex (3),
+.SH "AUTHORS"
+.TP
+Sean Hefty <sean.hefty@intel.com>
diff --git a/contrib/ofed/libibverbs/man/ibv_poll_cq.3 b/contrib/ofed/libibverbs/man/ibv_poll_cq.3
index 6a66955..12d1a76 100644
--- a/contrib/ofed/libibverbs/man/ibv_poll_cq.3
+++ b/contrib/ofed/libibverbs/man/ibv_poll_cq.3
@@ -1,4 +1,5 @@
.\" -*- nroff -*-
+.\" Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md
.\"
.TH IBV_POLL_CQ 3 2006-10-31 libibverbs "Libibverbs Programmer's Manual"
.SH "NAME"
@@ -30,7 +31,12 @@ enum ibv_wc_status status; /* Status of the operation */
enum ibv_wc_opcode opcode; /* Operation type specified in the completed WR */
uint32_t vendor_err; /* Vendor error syndrome */
uint32_t byte_len; /* Number of bytes transferred */
-uint32_t imm_data; /* Immediate data (in network byte order) */
+union {
+.in +8
+__be32 imm_data; /* Immediate data (in network byte order) */
+uint32_t invalidated_rkey; /* Local RKey that was invalidated */
+.in -8
+};
uint32_t qp_num; /* Local QP number of completed WR */
uint32_t src_qp; /* Source QP number (remote QP number) of completed WR (valid only for UD QPs) */
int wc_flags; /* Flags of the completed WR */
@@ -50,6 +56,13 @@ It is either 0 or the bitwise OR of one or more of the following flags:
.B IBV_WC_GRH \fR GRH is present (valid only for UD QPs)
.TP
.B IBV_WC_WITH_IMM \fR Immediate data value is valid
+.TP
+.B IBV_WC_WITH_INV \fR Invalidated RKey data value is valid (cannot be combined with IBV_WC_WITH_IMM)
+.TP
+.B IBV_WC_IP_CSUM_OK \fR TCP/UDP checksum over IPv4 and IPv4 header checksum are
+verified.
+Valid only when \fBdevice_cap_flags\fR in device_attr indicates current QP is
+supported by checksum offload.
.PP
Not all
.I wc
@@ -74,4 +87,4 @@ will be triggered, and the CQ cannot be used.
.BR ibv_post_recv (3)
.SH "AUTHORS"
.TP
-Dotan Barak <dotanb@mellanox.co.il>
+Dotan Barak <dotanba@gmail.com>
diff --git a/contrib/ofed/libibverbs/man/ibv_post_recv.3 b/contrib/ofed/libibverbs/man/ibv_post_recv.3
index 46a630b..affca74 100644
--- a/contrib/ofed/libibverbs/man/ibv_post_recv.3
+++ b/contrib/ofed/libibverbs/man/ibv_post_recv.3
@@ -1,4 +1,5 @@
.\" -*- nroff -*-
+.\" Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md
.\"
.TH IBV_POST_RECV 3 2006-10-31 libibverbs "Libibverbs Programmer's Manual"
.SH "NAME"
@@ -73,4 +74,4 @@ offset of 40 bytes into the buffer(s) in the scatter list.
.BR ibv_poll_cq (3)
.SH "AUTHORS"
.TP
-Dotan Barak <dotanb@mellanox.co.il>
+Dotan Barak <dotanba@gmail.com>
diff --git a/contrib/ofed/libibverbs/man/ibv_post_send.3 b/contrib/ofed/libibverbs/man/ibv_post_send.3
index d2c6e07..ebbbb80 100644
--- a/contrib/ofed/libibverbs/man/ibv_post_send.3
+++ b/contrib/ofed/libibverbs/man/ibv_post_send.3
@@ -1,4 +1,5 @@
.\" -*- nroff -*-
+.\" Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md
.\"
.TH IBV_POST_SEND 3 2006-10-31 libibverbs "Libibverbs Programmer's Manual"
.SH "NAME"
@@ -60,9 +61,47 @@ uint32_t remote_qkey; /* Q_Key number of the destination QP */
} ud;
.in -8
} wr;
-uint32_t xrc_remote_srq_num; /* SRQ number of the destination XRC */
+union {
+.in +8
+struct {
+.in +8
+uint32_t remote_srqn; /* Number of the remote SRQ */
+.in -8
+} xrc;
+.in -8
+} qp_type;
+union {
+.in +8
+struct {
+.in +8
+struct ibv_mw *mw; /* Memory window (MW) of type 2 to bind */
+uint32_t rkey; /* The desired new rkey of the MW */
+struct ibv_mw_bind_info bind_info; /* MW additional bind information */
+.in -8
+} bind_mw;
+struct {
+.in +8
+void *hdr; /* Pointer address of inline header */
+uint16_t hdr_sz; /* Inline header size */
+uint16_t mss; /* Maximum segment size for each TSO fragment */
+.in -8
+} tso;
+.in -8
+};
.in -8
};
+.fi
+.sp
+.nf
+struct ibv_mw_bind_info {
+.in +8
+struct ibv_mr *mr; /* The Memory region (MR) to bind the MW to */
+uint64_t addr; /* The address the MW should start at */
+uint64_t length; /* The length (in bytes) the MW should span */
+int mw_access_flags; /* Access flags to the MW. Use ibv_access_flags */
+.in -8
+};
+.fi
.sp
.nf
struct ibv_sge {
@@ -77,15 +116,19 @@ uint32_t lkey; /* Key of the local Memory Regio
Each QP Transport Service Type supports a specific set of opcodes, as shown in the following table:
.PP
.nf
-OPCODE | IBV_QPT_UD | IBV_QPT_UC | IBV_QPT_RC | IBV_QPT_XRC
-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-+\-\-\-\-\-\-\-\-\-\-\-\-+\-\-\-\-\-\-\-\-\-\-\-\-+\-\-\-\-\-\-\-\-\-\-\-\-+\-\-\-\-\-\-\-\-\-\-\-\-
-IBV_WR_SEND | X | X | X | X
-IBV_WR_SEND_WITH_IMM | X | X | X | X
-IBV_WR_RDMA_WRITE | | X | X | X
-IBV_WR_RDMA_WRITE_WITH_IMM | | X | X | X
-IBV_WR_RDMA_READ | | | X | X
-IBV_WR_ATOMIC_CMP_AND_SWP | | | X | X
-IBV_WR_ATOMIC_FETCH_AND_ADD | | | X | X
+OPCODE | IBV_QPT_UD | IBV_QPT_UC | IBV_QPT_RC | IBV_QPT_XRC_SEND | IBV_QPT_RAW_PACKET
+\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-+\-\-\-\-\-\-\-\-\-\-\-\-+\-\-\-\-\-\-\-\-\-\-\-\-+\-\-\-\-\-\-\-\-\-\-\-\-+\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-+\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-
+IBV_WR_SEND | X | X | X | X | X
+IBV_WR_SEND_WITH_IMM | X | X | X | X |
+IBV_WR_RDMA_WRITE | | X | X | X |
+IBV_WR_RDMA_WRITE_WITH_IMM | | X | X | X |
+IBV_WR_RDMA_READ | | | X | X |
+IBV_WR_ATOMIC_CMP_AND_SWP | | | X | X |
+IBV_WR_ATOMIC_FETCH_AND_ADD | | | X | X |
+IBV_WR_LOCAL_INV | | X | X | X |
+IBV_WR_BIND_MW | | X | X | X |
+IBV_WR_SEND_WITH_INV | | X | X | X |
+IBV_WR_TSO | X | | | | X
.fi
.PP
The attribute send_flags describes the properties of the \s-1WR\s0. It is either 0 or the bitwise \s-1OR\s0 of one or more of the following flags:
@@ -99,6 +142,10 @@ The attribute send_flags describes the properties of the \s-1WR\s0. It is either
.TP
.B IBV_SEND_INLINE \fR Send data in given gather list as inline data
in a send WQE. Valid only for Send and RDMA Write. The L_Key will not be checked.
+.TP
+.B IBV_SEND_IP_CSUM \fR Offload the IPv4 and TCP/UDP checksum calculation.
+Valid only when \fBdevice_cap_flags\fR in device_attr indicates current QP is
+supported by checksum offload.
.SH "RETURN VALUE"
.B ibv_post_send()
returns 0 on success, or the value of errno on failure (which indicates the failure reason).
@@ -115,11 +162,14 @@ IBV_SEND_INLINE flag was set, the buffer can be reused immediately
after the call returns.
.SH "SEE ALSO"
.BR ibv_create_qp (3),
-.BR ibv_create_xrc_rcv_qp (3),
.BR ibv_create_ah (3),
.BR ibv_post_recv (3),
.BR ibv_post_srq_recv (3),
.BR ibv_poll_cq (3)
.SH "AUTHORS"
.TP
-Dotan Barak <dotanb@mellanox.co.il>
+Dotan Barak <dotanba@gmail.com>
+.TP
+Majd Dibbiny <majd@mellanox.com>
+.TP
+Yishai Hadas <yishaih@mellanox.com>
diff --git a/contrib/ofed/libibverbs/man/ibv_post_srq_recv.3 b/contrib/ofed/libibverbs/man/ibv_post_srq_recv.3
index 65877cd..51d1516 100644
--- a/contrib/ofed/libibverbs/man/ibv_post_srq_recv.3
+++ b/contrib/ofed/libibverbs/man/ibv_post_srq_recv.3
@@ -1,4 +1,5 @@
.\" -*- nroff -*-
+.\" Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md
.\"
.TH IBV_POST_SRQ_RECV 3 2006-10-31 libibverbs "Libibverbs Programmer's Manual"
.SH "NAME"
@@ -65,4 +66,4 @@ offset of 40 bytes into the buffer(s) in the scatter list.
.BR ibv_poll_cq (3)
.SH "AUTHORS"
.TP
-Dotan Barak <dotanb@mellanox.co.il>
+Dotan Barak <dotanba@gmail.com>
diff --git a/contrib/ofed/libibverbs/man/ibv_query_device.3 b/contrib/ofed/libibverbs/man/ibv_query_device.3
index 3bf7511..0e9d286 100644
--- a/contrib/ofed/libibverbs/man/ibv_query_device.3
+++ b/contrib/ofed/libibverbs/man/ibv_query_device.3
@@ -1,4 +1,5 @@
.\" -*- nroff -*-
+.\" Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md
.\"
.TH IBV_QUERY_DEVICE 3 2006-10-31 libibverbs "Libibverbs Programmer's Manual"
.SH "NAME"
@@ -32,8 +33,8 @@ uint32_t hw_ver; /* Hardware version */
int max_qp; /* Maximum number of supported QPs */
int max_qp_wr; /* Maximum number of outstanding WR on any work queue */
int device_cap_flags; /* HCA capabilities mask */
-int max_sge; /* Maximum number of s/g per WR for non-RD QPs */
-int max_sge_rd; /* Maximum number of s/g per WR for RD QPs */
+int max_sge; /* Maximum number of s/g per WR for SQ & RQ of QP for non RDMA Read operations */
+int max_sge_rd; /* Maximum number of s/g per WR for RDMA Read operations */
int max_cq; /* Maximum number of supported CQs */
int max_cqe; /* Maximum number of CQE capacity per CQ */
int max_mr; /* Maximum number of supported MRs */
@@ -81,4 +82,4 @@ in use by other users/processes.
.BR ibv_query_gid (3)
.SH "AUTHORS"
.TP
-Dotan Barak <dotanb@mellanox.co.il>
+Dotan Barak <dotanba@gmail.com>
diff --git a/contrib/ofed/libibverbs/man/ibv_query_device_ex.3 b/contrib/ofed/libibverbs/man/ibv_query_device_ex.3
new file mode 100644
index 0000000..fdfb708
--- /dev/null
+++ b/contrib/ofed/libibverbs/man/ibv_query_device_ex.3
@@ -0,0 +1,106 @@
+.\" -*- nroff -*-
+.\" Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md
+.\"
+.TH IBV_QUERY_DEVICE_EX 3 2014-12-17 libibverbs "Libibverbs Programmer's Manual"
+.SH "NAME"
+ibv_query_device_ex \- query an RDMA device's attributes
+.SH "SYNOPSIS"
+.nf
+.B #include <infiniband/verbs.h>
+.sp
+.BI "int ibv_query_device_ex(struct ibv_context " "*context",
+.BI " struct ibv_device_attr_ex " "*attr" );
+.fi
+.SH "DESCRIPTION"
+.B ibv_query_device_ex()
+returns the attributes of the device with context
+.I context\fR.
+The argument
+.I attr
+is a pointer to an ibv_device_attr_ex struct, as defined in <infiniband/verbs.h>.
+.PP
+.nf
+struct ibv_device_attr_ex {
+.in +8
+struct ibv_device_attr orig_attr;
+uint32_t comp_mask; /* Compatibility mask that defines which of the following variables are valid */
+struct ibv_odp_caps odp_caps; /* On-Demand Paging capabilities */
+uint64_t completion_timestamp_mask; /* Completion timestamp mask (0 = unsupported) */
+uint64_t hca_core_clock; /* The frequency (in kHZ) of the HCA (0 = unsupported) */
+uint64_t device_cap_flags_ex; /* Extended device capability flags */
+struct ibv_tso_caps tso_caps; /* TCP segmentation offload capabilities */
+struct ibv_rss_caps rss_caps; /* RSS capabilities */
+uint32_t max_wq_type_rq; /* Max Work Queue from type RQ */
+struct ibv_packet_pacing_caps packet_pacing_caps; /* Packet pacing capabilities */
+uint32_t raw_packet_caps; /* Raw packet capabilities, use enum ibv_raw_packet_caps */
+.in -8
+};
+
+struct ibv_odp_caps {
+ uint64_t general_odp_caps; /* Mask with enum ibv_odp_general_cap_bits */
+ struct {
+ uint32_t rc_odp_caps; /* Mask with enum ibv_odp_tranport_cap_bits to know which operations are supported. */
+ uint32_t uc_odp_caps; /* Mask with enum ibv_odp_tranport_cap_bits to know which operations are supported. */
+ uint32_t ud_odp_caps; /* Mask with enum ibv_odp_tranport_cap_bits to know which operations are supported. */
+ } per_transport_caps;
+};
+
+enum ibv_odp_general_cap_bits {
+ IBV_ODP_SUPPORT = 1 << 0, /* On demand paging is supported */
+};
+
+enum ibv_odp_transport_cap_bits {
+ IBV_ODP_SUPPORT_SEND = 1 << 0, /* Send operations support on-demand paging */
+ IBV_ODP_SUPPORT_RECV = 1 << 1, /* Receive operations support on-demand paging */
+ IBV_ODP_SUPPORT_WRITE = 1 << 2, /* RDMA-Write operations support on-demand paging */
+ IBV_ODP_SUPPORT_READ = 1 << 3, /* RDMA-Read operations support on-demand paging */
+ IBV_ODP_SUPPORT_ATOMIC = 1 << 4, /* RDMA-Atomic operations support on-demand paging */
+};
+
+struct ibv_tso_caps {
+ uint32_t max_tso; /* Maximum payload size in bytes supported for segmentation by TSO engine.*/
+ uint32_t supported_qpts; /* Bitmap showing which QP types are supported by TSO operation. */
+};
+
+struct ibv_rss_caps {
+ uint32_t supported_qpts; /* Bitmap showing which QP types are supported RSS */
+ uint32_t max_rwq_indirection_tables; /* Max receive work queue indirection tables */
+ uint32_t max_rwq_indirection_table_size; /* Max receive work queue indirection table size */
+ uint64_t rx_hash_fields_mask; /* Mask with enum ibv_rx_hash_fields to know which incoming packet's field can participates in the RX hash */
+ uint8_t rx_hash_function; /* Mask with enum ibv_rx_hash_function_flags to know which hash functions are supported */
+};
+
+struct ibv_packet_pacing_caps {
+ uint32_t qp_rate_limit_min; /* Minimum rate limit in kbps */
+ uint32_t qp_rate_limit_max; /* Maximum rate limit in kbps */
+ uint32_t supported_qpts; /* Bitmap showing which QP types are supported. */
+};
+
+enum ibv_raw_packet_caps {
+.in +8
+IBV_RAW_PACKET_CAP_CVLAN_STRIPPING = 1 << 0, /* CVLAN stripping is supported */
+IBV_RAW_PACKET_CAP_SCATTER_FCS = 1 << 1, /* FCS scattering is supported */
+IBV_RAW_PACKET_CAP_IP_CSUM = 1 << 2, /* IP CSUM offload is supported */
+.in -8
+};
+
+.fi
+.SH "RETURN VALUE"
+.B ibv_query_device_ex()
+returns 0 on success, or the value of errno on failure (which indicates the failure reason).
+.SH "NOTES"
+The maximum values returned by this function are the upper limits of
+supported resources by the device. However, it may not be possible to
+use these maximum values, since the actual number of any resource that
+can be created may be limited by the machine configuration, the amount
+of host memory, user permissions, and the amount of resources already
+in use by other users/processes.
+.SH "SEE ALSO"
+.BR ibv_query_device (3),
+.BR ibv_open_device (3),
+.BR ibv_query_port (3),
+.BR ibv_query_pkey (3),
+.BR ibv_query_gid (3)
+.SH "AUTHORS"
+.TP
+Majd Dibbiny <majd@mellanox.com>
diff --git a/contrib/ofed/libibverbs/man/ibv_query_gid.3 b/contrib/ofed/libibverbs/man/ibv_query_gid.3
index df3ac10..45e128b 100644
--- a/contrib/ofed/libibverbs/man/ibv_query_gid.3
+++ b/contrib/ofed/libibverbs/man/ibv_query_gid.3
@@ -1,4 +1,5 @@
.\" -*- nroff -*-
+.\" Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md
.\"
.TH IBV_QUERY_GID 3 2006-10-31 libibverbs "Libibverbs Programmer's Manual"
.SH "NAME"
@@ -30,4 +31,4 @@ returns 0 on success, and \-1 on error.
.BR ibv_query_pkey (3)
.SH "AUTHORS"
.TP
-Dotan Barak <dotanb@mellanox.co.il>
+Dotan Barak <dotanba@gmail.com>
diff --git a/contrib/ofed/libibverbs/man/ibv_query_pkey.3 b/contrib/ofed/libibverbs/man/ibv_query_pkey.3
index fcdfe6c..3af4044 100644
--- a/contrib/ofed/libibverbs/man/ibv_query_pkey.3
+++ b/contrib/ofed/libibverbs/man/ibv_query_pkey.3
@@ -1,4 +1,5 @@
.\" -*- nroff -*-
+.\" Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md
.\"
.TH IBV_QUERY_PKEY 3 2006-10-31 libibverbs "Libibverbs Programmer's Manual"
.SH "NAME"
@@ -30,4 +31,4 @@ returns 0 on success, and \-1 on error.
.BR ibv_query_gid (3)
.SH "AUTHORS"
.TP
-Dotan Barak <dotanb@mellanox.co.il>
+Dotan Barak <dotanba@gmail.com>
diff --git a/contrib/ofed/libibverbs/man/ibv_query_port.3 b/contrib/ofed/libibverbs/man/ibv_query_port.3
index f4bdf2f..6e480d6 100644
--- a/contrib/ofed/libibverbs/man/ibv_query_port.3
+++ b/contrib/ofed/libibverbs/man/ibv_query_port.3
@@ -1,4 +1,5 @@
.\" -*- nroff -*-
+.\" Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md
.\"
.TH IBV_QUERY_PORT 3 2006-10-31 libibverbs "Libibverbs Programmer's Manual"
.SH "NAME"
@@ -48,6 +49,9 @@ uint8_t link_layer; /* link layer protocol of the port */
.in -8
};
.sp
+possible values for the link layer field are IBV_LINK_LAYER_INFINIBAND,
+IBV_LINK_LAYER_ETHERNET, or IBV_LINK_LAYER_UNSPECIFIED.
+.sp
.fi
.SH "RETURN VALUE"
.B ibv_query_port()
@@ -59,4 +63,4 @@ returns 0 on success, or the value of errno on failure (which indicates the fail
.BR ibv_create_ah (3)
.SH "AUTHORS"
.TP
-Dotan Barak <dotanb@mellanox.co.il>
+Dotan Barak <dotanba@gmail.com>
diff --git a/contrib/ofed/libibverbs/man/ibv_query_qp.3 b/contrib/ofed/libibverbs/man/ibv_query_qp.3
index 2c4ceaf..907bc56 100644
--- a/contrib/ofed/libibverbs/man/ibv_query_qp.3
+++ b/contrib/ofed/libibverbs/man/ibv_query_qp.3
@@ -1,4 +1,5 @@
.\" -*- nroff -*-
+.\" Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md
.\"
.TH IBV_QUERY_QP 3 2006-10-31 libibverbs "Libibverbs Programmer's Manual"
.SH "NAME"
@@ -87,4 +88,4 @@ may yield some differences in the values returned for the following attributes:
.BR ibv_create_ah (3)
.SH "AUTHORS"
.TP
-Dotan Barak <dotanb@mellanox.co.il>
+Dotan Barak <dotanba@gmail.com>
diff --git a/contrib/ofed/libibverbs/man/ibv_query_rt_values_ex.3 b/contrib/ofed/libibverbs/man/ibv_query_rt_values_ex.3
new file mode 100644
index 0000000..8ff5b66
--- /dev/null
+++ b/contrib/ofed/libibverbs/man/ibv_query_rt_values_ex.3
@@ -0,0 +1,51 @@
+.\" -*- nroff -*-
+.\" Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md
+.\"
+.TH IBV_QUERY_RT_VALUES_EX 3 2016-2-20 libibverbs "Libibverbs Programmer's Manual"
+.SH "NAME"
+ibv_query_rt_values_ex \- query an RDMA device for some real time values
+.SH "SYNOPSIS"
+.nf
+.B #include <infiniband/verbs.h>
+.sp
+.BI "int ibv_query_rt_values_ex(struct ibv_context " "*context",
+.BI " struct ibv_values_ex " "*values" );
+.fi
+.SH "DESCRIPTION"
+.B ibv_query_rt_values_ex()
+returns certain real time values of a device
+.I context\fR.
+The argument
+.I attr
+is a pointer to an ibv_device_attr_ex struct, as defined in <infiniband/verbs.h>.
+.PP
+.nf
+struct ibv_values_ex {
+.in +8
+uint32_t comp_mask; /* Compatibility mask that defines the query/queried fields [in/out] */
+struct timespec raw_clock; /* HW raw clock */
+.in -8
+};
+
+enum ibv_values_mask {
+ IBV_VALUES_MASK_RAW_CLOCK = 1 << 0, /* HW raw clock */
+};
+
+.fi
+.SH "RETURN VALUE"
+.B ibv_query_rt_values_ex()
+returns 0 on success, or the value of errno on failure (which indicates the failure reason).
+.SH "NOTES"
+This extension verb only calls the provider, the provider has to query this value somehow and mark
+the queried values in the comp_mask field.
+.SH "SEE ALSO"
+.BR ibv_query_device (3),
+.BR ibv_open_device (3),
+.BR ibv_query_port (3),
+.BR ibv_query_pkey (3),
+.BR ibv_query_gid (3)
+.SH "AUTHORS"
+.TP
+Matan Barak <matanb@mellanox.com>
+.TP
+Yishai Hadas <yishaih@mellanox.com>
diff --git a/contrib/ofed/libibverbs/man/ibv_query_srq.3 b/contrib/ofed/libibverbs/man/ibv_query_srq.3
index 56db4fa..8a35ce0 100644
--- a/contrib/ofed/libibverbs/man/ibv_query_srq.3
+++ b/contrib/ofed/libibverbs/man/ibv_query_srq.3
@@ -1,4 +1,5 @@
.\" -*- nroff -*-
+.\" Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md
.\"
.TH IBV_QUERY_SRQ 3 2006-10-31 libibverbs "Libibverbs Programmer's Manual"
.SH "NAME"
@@ -41,4 +42,4 @@ asynchronous events will be generated until the event is rearmed.
.BR ibv_modify_srq (3)
.SH "AUTHORS"
.TP
-Dotan Barak <dotanb@mellanox.co.il>
+Dotan Barak <dotanba@gmail.com>
diff --git a/contrib/ofed/libibverbs/man/ibv_query_xrc_rcv_qp.3 b/contrib/ofed/libibverbs/man/ibv_query_xrc_rcv_qp.3
deleted file mode 100644
index d2429be..0000000
--- a/contrib/ofed/libibverbs/man/ibv_query_xrc_rcv_qp.3
+++ /dev/null
@@ -1,89 +0,0 @@
-.\" -*- nroff -*-
-.\"
-.TH IBV_QUERY_XRC_RCV_QP 3 2008-02-10 libibverbs "Libibverbs Programmer's Manual"
-.SH "NAME"
-ibv_query_xrc_rcv_qp \- get the attributes of an XRC receive queue pair (QP)
-.SH "SYNOPSIS"
-.nf
-.B #include <infiniband/verbs.h>
-.sp
-.BI "int ibv_query_xrc_rcv_qp(struct ibv_xrc_domain " "*xrc_domain" ", uint32_t " "xrc_qp_num" ,
-.BI " struct ibv_qp_attr " "*attr" ", int " "attr_mask" ,
-.BI " struct ibv_qp_init_attr " "*init_attr" );
-.fi
-.SH "DESCRIPTION"
-.B ibv_query_xrc_rcv_qp()
-gets the attributes specified in
-.I attr_mask
-for the XRC receive QP with the number
-.I xrc_qp_num
-which is associated with the XRC domain
-.I xrc_domain
-and returns them through the pointers
-.I attr
-and
-.I init_attr\fR.
-The argument
-.I attr
-is an ibv_qp_attr struct, as defined in <infiniband/verbs.h>.
-.PP
-.nf
-struct ibv_qp_attr {
-.in +8
-enum ibv_qp_state qp_state; /* Current QP state */
-enum ibv_qp_state cur_qp_state; /* Current QP state - irrelevant for ibv_query_qp */
-enum ibv_mtu path_mtu; /* Path MTU (valid only for RC/UC QPs) */
-enum ibv_mig_state path_mig_state; /* Path migration state (valid if HCA supports APM) */
-uint32_t qkey; /* Q_Key of the QP (valid only for UD QPs) */
-uint32_t rq_psn; /* PSN for receive queue (valid only for RC/UC QPs) */
-uint32_t sq_psn; /* PSN for send queue (valid only for RC/UC QPs) */
-uint32_t dest_qp_num; /* Destination QP number (valid only for RC/UC QPs) */
-int qp_access_flags; /* Mask of enabled remote access operations (valid only for RC/UC QPs) */
-struct ibv_qp_cap cap; /* QP capabilities */
-struct ibv_ah_attr ah_attr; /* Primary path address vector (valid only for RC/UC QPs) */
-struct ibv_ah_attr alt_ah_attr; /* Alternate path address vector (valid only for RC/UC QPs) */
-uint16_t pkey_index; /* Primary P_Key index */
-uint16_t alt_pkey_index; /* Alternate P_Key index */
-uint8_t en_sqd_async_notify; /* Enable SQD.drained async notification - irrelevant for ibv_query_qp */
-uint8_t sq_draining; /* Is the QP draining? (Valid only if qp_state is SQD) */
-uint8_t max_rd_atomic; /* Number of outstanding RDMA reads & atomic operations on the destination QP (valid only for RC QPs) */
-uint8_t max_dest_rd_atomic; /* Number of responder resources for handling incoming RDMA reads & atomic operations (valid only for RC QPs) */
-uint8_t min_rnr_timer; /* Minimum RNR NAK timer (valid only for RC QPs) */
-uint8_t port_num; /* Primary port number */
-uint8_t timeout; /* Local ack timeout for primary path (valid only for RC QPs) */
-uint8_t retry_cnt; /* Retry count (valid only for RC QPs) */
-uint8_t rnr_retry; /* RNR retry (valid only for RC QPs) */
-uint8_t alt_port_num; /* Alternate port number */
-uint8_t alt_timeout; /* Local ack timeout for alternate path (valid only for RC QPs) */
-.in -8
-};
-.fi
-.PP
-For details on struct ibv_qp_cap see the description of
-.B ibv_create_qp()\fR.
-For details on struct ibv_ah_attr see the description of
-.B ibv_create_ah()\fR.
-.SH "RETURN VALUE"
-.B ibv_query_xrc_rcv_qp()
-returns 0 on success, or the value of errno on failure (which indicates the failure reason).
-.SH "NOTES"
-The argument
-.I attr_mask
-is a hint that specifies the minimum list of attributes to retrieve.
-Some InfiniBand devices may return extra attributes not requested, for
-example if the value can be returned cheaply.
-.PP
-Attribute values are valid if they have been set using
-.B ibv_modify_xrc_rcv_qp()\fR.
-The exact list of valid attributes depends on the QP state.
-.PP
-Multiple calls to
-.B ibv_query_xrc_rcv_qp()
-may yield some differences in the values returned for the following attributes: qp_state, path_mig_state, sq_draining, ah_attr (if APM is enabled).
-.SH "SEE ALSO"
-.BR ibv_open_xrc_domain (3),
-.BR ibv_create_xrc_rcv_qp (3),
-.BR ibv_modify_xrc_rcv_qp (3)
-.SH "AUTHORS"
-.TP
-Dotan Barak <dotanb@mellanox.co.il>
diff --git a/contrib/ofed/libibverbs/man/ibv_rate_to_mbps.3 b/contrib/ofed/libibverbs/man/ibv_rate_to_mbps.3
new file mode 100644
index 0000000..27e8724
--- /dev/null
+++ b/contrib/ofed/libibverbs/man/ibv_rate_to_mbps.3
@@ -0,0 +1,46 @@
+.\" -*- nroff -*-
+.\" Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md
+.\"
+.TH IBV_RATE_TO_MBPS 3 2012-03-31 libibverbs "Libibverbs Programmer's Manual"
+.SH "NAME"
+.nf
+ibv_rate_to_mbps \- convert IB rate enumeration to Mbit/sec
+.sp
+mbps_to_ibv_rate \- convert Mbit/sec to an IB rate enumeration
+.SH "SYNOPSIS"
+.nf
+.B #include <infiniband/verbs.h>
+.sp
+.BI "int ibv_rate_to_mbps(enum ibv_rate " "rate" ");
+.sp
+.BI "enum ibv_rate mbps_to_ibv_rate(int " "mbps" ");
+.fi
+.SH "DESCRIPTION"
+.B ibv_rate_to_mbps()
+converts the IB transmission rate enumeration
+.I rate
+to a number of Mbit/sec. For example, if
+.I rate
+is
+.BR IBV_RATE_5_GBPS\fR,
+the value 5000 will be returned (5 Gbit/sec = 5000 Mbit/sec).
+.PP
+.B mbps_to_ibv_rate()
+converts the number of Mbit/sec
+.I mult
+to an IB transmission rate enumeration. For example, if
+.I mult
+is 5000, the rate enumeration
+.BR IBV_RATE_5_GBPS
+will be returned.
+.SH "RETURN VALUE"
+.B ibv_rate_to_mbps()
+returns the number of Mbit/sec.
+.PP
+.B mbps_to_ibv_rate()
+returns the enumeration representing the IB transmission rate.
+.SH "SEE ALSO"
+.BR ibv_query_port (3)
+.SH "AUTHORS"
+.TP
+Dotan Barak <dotanb@dev.mellanox.co.il>
diff --git a/contrib/ofed/libibverbs/man/ibv_rate_to_mult.3 b/contrib/ofed/libibverbs/man/ibv_rate_to_mult.3
index 1346d75..6e2a59d 100644
--- a/contrib/ofed/libibverbs/man/ibv_rate_to_mult.3
+++ b/contrib/ofed/libibverbs/man/ibv_rate_to_mult.3
@@ -1,4 +1,5 @@
.\" -*- nroff -*-
+.\" Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md
.\"
.TH IBV_RATE_TO_MULT 3 2006-10-31 libibverbs "Libibverbs Programmer's Manual"
.SH "NAME"
@@ -43,4 +44,4 @@ returns the enumeration representing the IB transmission rate.
.BR ibv_query_port (3)
.SH "AUTHORS"
.TP
-Dotan Barak <dotanb@mellanox.co.il>
+Dotan Barak <dotanba@gmail.com>
diff --git a/contrib/ofed/libibverbs/man/ibv_rc_pingpong.1 b/contrib/ofed/libibverbs/man/ibv_rc_pingpong.1
index d213c6f..84200b3 100644
--- a/contrib/ofed/libibverbs/man/ibv_rc_pingpong.1
+++ b/contrib/ofed/libibverbs/man/ibv_rc_pingpong.1
@@ -1,3 +1,4 @@
+.\" Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md
.TH IBV_RC_PINGPONG 1 "August 30, 2005" "libibverbs" "USER COMMANDS"
.SH NAME
@@ -5,12 +6,14 @@ ibv_rc_pingpong \- simple InfiniBand RC transport test
.SH SYNOPSIS
.B ibv_rc_pingpong
-[\-p port] [\-d device] [\-i ib port] [\-s size] [\-r rx depth]
-[\-n iters] [\-l sl] [\-e] \fBHOSTNAME\fR
+[\-p port] [\-d device] [\-i ib port] [\-s size] [\-m size]
+[\-r rx depth] [\-n iters] [\-l sl] [\-e] [\-g gid index]
+[\-o] [\-t] \fBHOSTNAME\fR
.B ibv_rc_pingpong
-[\-p port] [\-d device] [\-i ib port] [\-s size] [\-r rx depth]
-[\-n iters] [\-l sl] [\-e]
+[\-p port] [\-d device] [\-i ib port] [\-s size] [\-m size]
+[\-r rx depth] [\-n iters] [\-l sl] [\-e] [\-g gid index]
+[\-o] [\-t]
.SH DESCRIPTION
.PP
@@ -33,6 +36,9 @@ use IB port \fIPORT\fR (default port 1)
\fB\-s\fR, \fB\-\-size\fR=\fISIZE\fR
ping-pong messages of size \fISIZE\fR (default 4096)
.TP
+\fB\-m\fR, \fB\-\-mtu\fR=\fISIZE\fR
+path MTU \fISIZE\fR (default 1024)
+.TP
\fB\-r\fR, \fB\-\-rx\-depth\fR=\fIDEPTH\fR
post \fIDEPTH\fR receives at a time (default 1000)
.TP
@@ -45,11 +51,21 @@ use \fISL\fR as the service level value of the QP (default 0)
\fB\-e\fR, \fB\-\-events\fR
sleep while waiting for work completion events (default is to poll for
completions)
+.TP
+\fB\-g\fR, \fB\-\-gid-idx\fR=\fIGIDINDEX\fR
+local port \fIGIDINDEX\fR
+.TP
+\fB\-o\fR, \fB\-\-odp\fR
+use on demand paging
+.TP
+\fB\-t\fR, \fB\-\-ts\fR
+get CQE with timestamp
.SH SEE ALSO
.BR ibv_uc_pingpong (1),
.BR ibv_ud_pingpong (1),
-.BR ibv_srq_pingpong (1)
+.BR ibv_srq_pingpong (1),
+.BR ibv_xsrq_pingpong (1)
.SH AUTHORS
.TP
diff --git a/contrib/ofed/libibverbs/man/ibv_reg_mr.3 b/contrib/ofed/libibverbs/man/ibv_reg_mr.3
index 7bc6c01..d3f09c0 100644
--- a/contrib/ofed/libibverbs/man/ibv_reg_mr.3
+++ b/contrib/ofed/libibverbs/man/ibv_reg_mr.3
@@ -1,4 +1,5 @@
.\" -*- nroff -*-
+.\" Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md
.\"
.TH IBV_REG_MR 3 2006-10-31 libibverbs "Libibverbs Programmer's Manual"
.SH "NAME"
@@ -34,6 +35,8 @@ describes the desired memory protection attributes; it is either 0 or the bitwis
.B IBV_ACCESS_REMOTE_ATOMIC\fR Enable Remote Atomic Operation Access (if supported)
.TP
.B IBV_ACCESS_MW_BIND\fR Enable Memory Window Binding
+.TP
+.B IBV_ACCESS_ON_DEMAND\fR Create an on-demand paging MR
.PP
If
.B IBV_ACCESS_REMOTE_WRITE
@@ -73,4 +76,4 @@ fails if any memory window is still bound to this MR.
.BR ibv_post_srq_recv (3)
.SH "AUTHORS"
.TP
-Dotan Barak <dotanb@mellanox.co.il>
+Dotan Barak <dotanba@gmail.com>
diff --git a/contrib/ofed/libibverbs/man/ibv_reg_xrc_rcv_qp.3 b/contrib/ofed/libibverbs/man/ibv_reg_xrc_rcv_qp.3
deleted file mode 100644
index 7519ba7..0000000
--- a/contrib/ofed/libibverbs/man/ibv_reg_xrc_rcv_qp.3
+++ /dev/null
@@ -1,57 +0,0 @@
-.\" -*- nroff -*-
-.\"
-.TH IBV_REG_XRC_RCV_QP 3 2008-10-02 libibverbs "Libibverbs Programmer's Manual"
-.SH "NAME"
-ibv_reg_xrc_rcv_qp, ibv_unreg_xrc_rcv_qp \- register and unregister a user process with an XRC receive queue pair (QP)
-.SH "SYNOPSIS"
-.nf
-.B #include <infiniband/verbs.h>
-.sp
-.BI "int ibv_reg_xrc_rcv_qp(struct ibv_xrc_domain " "*xrc_domain" ", uint32_t " "xrc_qp_num" ");
-.nl
-.BI "int ibv_unreg_xrc_rcv_qp(struct ibv_xrc_domain " "*xrc_domain" ", uint32_t " "xrc_qp_num" ");
-.fi
-.SH "DESCRIPTION"
-.B ibv_reg_xrc_rcv_qp()
-registers a user process with the XRC receive QP (created via
-.B ibv_create_xrc_rcv_qp()
-) whose number is
-.I xrc_qp_num\fR,
-and which is associated with the XRC domain
-.I xrc_domain\fR.
-.PP
-.B ibv_unreg_xrc_rcv_qp()
-unregisters a user process from the XRC receive QP number
-.I xrc_qp_num\fR,
-which is associated with the XRC domain
-.I xrc_domain\fR.
-When the number of user processes registered with this XRC receive QP drops to zero, the QP is destroyed.
-.SH "RETURN VALUE"
-.B ibv_reg_xrc_rcv_qp()
-and
-.B ibv_unreg_xrc_rcv_qp()
-returns 0 on success, or the value of errno on failure (which indicates the failure reason).
-.SH "NOTES"
-.B ibv_reg_xrc_rcv_qp()
-and
-.B ibv_unreg_xrc_rcv_qp()
-may fail if the number
-.I xrc_qp_num
-is not a number of a valid XRC receive QP (the QP is not allocated or it is the number of a non-XRC QP), or
-the XRC receive QP was created with an XRC domain other than
-.I xrc_domain\fR.
-
-If a process is still registered with any XRC RCV QPs belonging to some domain,
-.B ibv_close_xrc_domain()
-will return failure if called for that domain in that process.
-
-.B ibv_create_xrc_rcv_qp()
-performs an implicit registration for the creating process; when that process is finished with the XRC RCV QP, it should call
-.B ibv_unreg_xrc_rcv_qp()
-for that QP. Note that if no other processes are registered with the QP at this time, its registration count will drop to zero and it will be destroyed.
-.SH "SEE ALSO"
-.BR ibv_open_xrc_domain (3),
-.BR ibv_create_xrc_rcv_qp (3)
-.SH "AUTHORS"
-.TP
-Dotan Barak <dotanb@mellanox.co.il>
diff --git a/contrib/ofed/libibverbs/man/ibv_req_notify_cq.3 b/contrib/ofed/libibverbs/man/ibv_req_notify_cq.3
index eda5801..1d1d621 100644
--- a/contrib/ofed/libibverbs/man/ibv_req_notify_cq.3
+++ b/contrib/ofed/libibverbs/man/ibv_req_notify_cq.3
@@ -1,4 +1,5 @@
.\" -*- nroff -*-
+.\" Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md
.\"
.TH IBV_REQ_NOTIFY_CQ 3 2006-10-31 libibverbs "Libibverbs Programmer's Manual"
.SH "NAME"
@@ -40,4 +41,4 @@ will be generated for each call to
.BR ibv_get_cq_event (3)
.SH "AUTHORS"
.TP
-Dotan Barak <dotanb@mellanox.co.il>
+Dotan Barak <dotanba@gmail.com>
diff --git a/contrib/ofed/libibverbs/man/ibv_rereg_mr.3 b/contrib/ofed/libibverbs/man/ibv_rereg_mr.3
new file mode 100644
index 0000000..9fa567c
--- /dev/null
+++ b/contrib/ofed/libibverbs/man/ibv_rereg_mr.3
@@ -0,0 +1,77 @@
+.\" -*- nroff -*-
+.\" Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md
+.\"
+.TH IBV_REREG_MR 3 2016-03-13 libibverbs "Libibverbs Programmer's Manual"
+.SH "NAME"
+ibv_rereg_mr \- re-register a memory region (MR)
+.SH "SYNOPSIS"
+.nf
+.B #include <infiniband/verbs.h>
+.sp
+.BI "int ibv_rereg_mr(struct ibv_mr " "*mr" ", int " " flags" ,
+.BI " struct ibv_pd * " "pd" ", void " " *addr",
+.BI " size_t " " length" ", int " " access");
+.fi
+.fi
+.SH "DESCRIPTION"
+.B ibv_rereg_mr()
+Modifies the attributes of an existing memory region (MR)
+.I mr\fR.
+Conceptually, this call performs the functions deregister memory region
+followed by register memory region. Where possible,
+resources are reused instead of deallocated and reallocated.
+.PP
+.I flags\fR
+is a bit-mask used to indicate which of the following properties of the memory region are being modified. Flags should be a combination (bit field) of:
+.PP
+.TP
+.B IBV_REREG_MR_CHANGE_TRANSLATION \fR Change translation (location and length)
+.TP
+.B IBV_REREG_MR_CHANGE_PD \fR Change protection domain
+.TP
+.B IBV_REREG_MR_CHANGE_ACCESS \fR Change access flags
+.PP
+When
+.B IBV_REREG_MR_CHANGE_PD
+is used,
+.I pd\fR
+represents the new PD this MR should be registered to.
+.br
+When
+.B IBV_REREG_MR_CHANGE_TRANSLATION
+is used,
+.I addr\fR.
+represents the virtual address (user-space pointer) of the new MR, while
+.I length\fR
+represents its length.
+.PP
+The access and other flags are represented in the field
+.I access\fR.
+This field describes the desired memory protection attributes; it is either 0 or the bitwise OR of one or more of ibv_access_flags.
+.TP
+.SH "RETURN VALUE"
+.B ibv_rereg_mr()
+returns 0 on success, otherwise an error has occurred,
+.I enum ibv_rereg_mr_err_code\fR
+represents the error as of below.
+.br
+IBV_REREG_MR_ERR_INPUT - Old MR is valid, an input error was detected by libibverbs.
+.br
+IBV_REREG_MR_ERR_DONT_FORK_NEW - Old MR is valid, failed via don't fork on new address range.
+.br
+IBV_REREG_MR_ERR_DO_FORK_OLD - New MR is valid, failed via do fork on old address range.
+.br
+IBV_REREG_MR_ERR_CMD - MR shouldn't be used, command error.
+.br
+IBV_REREG_MR_ERR_CMD_AND_DO_FORK_NEW - MR shouldn't be used, command error, invalid fork state on new address range.
+
+.SH "NOTES"
+Even on a failure, the user still needs to call ibv_dereg_mr on this MR.
+.SH "SEE ALSO"
+.BR ibv_reg_mr (3),
+.BR ibv_dereg_mr (3),
+.SH "AUTHORS"
+.TP
+Matan Barak <matanb@mellanox.com>
+.TP
+Yishai Hadas <yishaih@mellanox.com>
diff --git a/contrib/ofed/libibverbs/man/ibv_resize_cq.3 b/contrib/ofed/libibverbs/man/ibv_resize_cq.3
index 0563f56..b159501 100644
--- a/contrib/ofed/libibverbs/man/ibv_resize_cq.3
+++ b/contrib/ofed/libibverbs/man/ibv_resize_cq.3
@@ -1,4 +1,5 @@
.\" -*- nroff -*-
+.\" Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md
.\"
.TH IBV_RESIZE_CQ 3 2006-10-31 libibverbs "Libibverbs Programmer's Manual"
.SH "NAME"
@@ -39,4 +40,4 @@ will be updated to the actual size.
.BR ibv_destroy_cq (3)
.SH "AUTHORS"
.TP
-Dotan Barak <dotanb@mellanox.co.il>
+Dotan Barak <dotanba@gmail.com>
diff --git a/contrib/ofed/libibverbs/man/ibv_srq_pingpong.1 b/contrib/ofed/libibverbs/man/ibv_srq_pingpong.1
index d50f70e..b3fd00e 100644
--- a/contrib/ofed/libibverbs/man/ibv_srq_pingpong.1
+++ b/contrib/ofed/libibverbs/man/ibv_srq_pingpong.1
@@ -1,3 +1,4 @@
+.\" Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md
.TH IBV_SRQ_PINGPONG 1 "August 30, 2005" "libibverbs" "USER COMMANDS"
.SH NAME
@@ -5,12 +6,14 @@ ibv_srq_pingpong \- simple InfiniBand shared receive queue test
.SH SYNOPSIS
.B ibv_srq_pingpong
-[\-p port] [\-d device] [\-i ib port] [\-s size] [\-q num QPs] [\-r rx depth]
-[\-n iters] [\-l sl] [\-e] \fBHOSTNAME\fR
+[\-p port] [\-d device] [\-i ib port] [\-s size] [\-m size]
+[\-q num QPs] [\-r rx depth] [\-n iters] [\-l sl] [\-e]
+[\-g gid index] \fBHOSTNAME\fR
.B ibv_srq_pingpong
-[\-p port] [\-d device] [\-i ib port] [\-s size] [\-q num QPs] [\-r rx depth]
-[\-n iters] [\-l sl] [\-e]
+[\-p port] [\-d device] [\-i ib port] [\-s size] [\-m size]
+[\-q num QPs] [\-r rx depth] [\-n iters] [\-l sl] [\-e]
+[\-g gid index]
.SH DESCRIPTION
.PP
@@ -34,6 +37,9 @@ use IB port \fIPORT\fR (default port 1)
\fB\-s\fR, \fB\-\-size\fR=\fISIZE\fR
ping-pong messages of size \fISIZE\fR (default 4096)
.TP
+\fB\-m\fR, \fB\-\-mtu\fR=\fISIZE\fR
+path MTU \fISIZE\fR (default 1024)
+.TP
\fB\-q\fR, \fB\-\-num\-qp\fR=\fINUM\fR
use \fINUM\fR queue pairs for test (default 16)
.TP
@@ -49,11 +55,15 @@ use \fISL\fR as the service level value of the QPs (default 0)
\fB\-e\fR, \fB\-\-events\fR
sleep while waiting for work completion events (default is to poll for
completions)
+.TP
+\fB\-g\fR, \fB\-\-gid-idx\fR=\fIGIDINDEX\fR
+local port \fIGIDINDEX\fR
.SH SEE ALSO
.BR ibv_rc_pingpong (1),
.BR ibv_uc_pingpong (1),
-.BR ibv_ud_pingpong (1)
+.BR ibv_ud_pingpong (1),
+.BR ibv_xsrq_pingpong (1)
.SH AUTHORS
.TP
diff --git a/contrib/ofed/libibverbs/man/ibv_uc_pingpong.1 b/contrib/ofed/libibverbs/man/ibv_uc_pingpong.1
index ec97eb0..a90063f 100644
--- a/contrib/ofed/libibverbs/man/ibv_uc_pingpong.1
+++ b/contrib/ofed/libibverbs/man/ibv_uc_pingpong.1
@@ -1,3 +1,4 @@
+.\" Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md
.TH IBV_UC_PINGPONG 1 "August 30, 2005" "libibverbs" "USER COMMANDS"
.SH NAME
@@ -5,12 +6,13 @@ ibv_uc_pingpong \- simple InfiniBand UC transport test
.SH SYNOPSIS
.B ibv_uc_pingpong
-[\-p port] [\-d device] [\-i ib port] [\-s size] [\-r rx depth]
-[\-n iters] [\-l sl] [\-e] \fBHOSTNAME\fR
+[\-p port] [\-d device] [\-i ib port] [\-s size] [\-m size]
+[\-r rx depth] [\-n iters] [\-l sl] [\-e] [\-g gid index]
+\fBHOSTNAME\fR
.B ibv_uc_pingpong
-[\-p port] [\-d device] [\-i ib port] [\-s size] [\-r rx depth]
-[\-n iters] [\-l sl] [\-e]
+[\-p port] [\-d device] [\-i ib port] [\-s size] [\-m size]
+[\-r rx depth] [\-n iters] [\-l sl] [\-e] [\-g gid index]
.SH DESCRIPTION
.PP
@@ -33,6 +35,9 @@ use IB port \fIPORT\fR (default port 1)
\fB\-s\fR, \fB\-\-size\fR=\fISIZE\fR
ping-pong messages of size \fISIZE\fR (default 4096)
.TP
+\fB\-m\fR, \fB\-\-mtu\fR=\fISIZE\fR
+path MTU \fISIZE\fR (default 1024)
+.TP
\fB\-r\fR, \fB\-\-rx\-depth\fR=\fIDEPTH\fR
post \fIDEPTH\fR receives at a time (default 1000)
.TP
@@ -45,11 +50,15 @@ use \fISL\fR as the service level value of the QP (default 0)
\fB\-e\fR, \fB\-\-events\fR
sleep while waiting for work completion events (default is to poll for
completions)
+.TP
+\fB\-g\fR, \fB\-\-gid-idx\fR=\fIGIDINDEX\fR
+local port \fIGIDINDEX\fR
.SH SEE ALSO
.BR ibv_rc_pingpong (1),
.BR ibv_ud_pingpong (1),
-.BR ibv_srq_pingpong (1)
+.BR ibv_srq_pingpong (1),
+.BR ibv_xsrq_pingpong (1)
.SH AUTHORS
.TP
diff --git a/contrib/ofed/libibverbs/man/ibv_ud_pingpong.1 b/contrib/ofed/libibverbs/man/ibv_ud_pingpong.1
index a05af8d..fc71ee6 100644
--- a/contrib/ofed/libibverbs/man/ibv_ud_pingpong.1
+++ b/contrib/ofed/libibverbs/man/ibv_ud_pingpong.1
@@ -1,3 +1,4 @@
+.\" Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md
.TH IBV_UD_PINGPONG 1 "August 30, 2005" "libibverbs" "USER COMMANDS"
.SH NAME
@@ -6,11 +7,11 @@ ibv_ud_pingpong \- simple InfiniBand UD transport test
.SH SYNOPSIS
.B ibv_ud_pingpong
[\-p port] [\-d device] [\-i ib port] [\-s size] [\-r rx depth]
-[\-n iters] [\-l sl] [\-e] \fBHOSTNAME\fR
+[\-n iters] [\-l sl] [\-e] [\-g gid index] \fBHOSTNAME\fR
.B ibv_ud_pingpong
[\-p port] [\-d device] [\-i ib port] [\-s size] [\-r rx depth]
-[\-n iters] [\-l sl] [\-e]
+[\-n iters] [\-l sl] [\-e] [\-g gid index]
.SH DESCRIPTION
.PP
@@ -45,11 +46,15 @@ send messages with service level \fISL\fR (default 0)
\fB\-e\fR, \fB\-\-events\fR
sleep while waiting for work completion events (default is to poll for
completions)
+.TP
+\fB\-g\fR, \fB\-\-gid-idx\fR=\fIGIDINDEX\fR
+local port \fIGIDINDEX\fR
.SH SEE ALSO
.BR ibv_rc_pingpong (1),
.BR ibv_uc_pingpong (1),
-.BR ibv_srq_pingpong (1)
+.BR ibv_srq_pingpong (1),
+.BR ibv_xsrq_pingpong (1)
.SH AUTHORS
.TP
diff --git a/contrib/ofed/libibverbs/man/ibv_xsrq_pingpong.1 b/contrib/ofed/libibverbs/man/ibv_xsrq_pingpong.1
new file mode 100644
index 0000000..b225d9b
--- /dev/null
+++ b/contrib/ofed/libibverbs/man/ibv_xsrq_pingpong.1
@@ -0,0 +1,75 @@
+.\" Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md
+.TH IBV_XSRQ_PINGPONG 1 "May 24, 2016" "libibverbs" "USER COMMANDS"
+
+.SH NAME
+ibv_xsrq_pingpong \- simple InfiniBand shared receive queue test
+
+.SH SYNOPSIS
+.B ibv_xsrq_pingpong
+[\-p port] [\-d device] [\-i ib port] [\-s size] [\-m mtu] [\-c clients]
+[\-n num_tests] [\-l sl] [\-e] [\-g gid index] \fBHOSTNAME\fR
+
+.B ibv_xsrq_pingpong
+[\-p port] [\-d device] [\-i ib port] [\-s size] [\-m mtu] [\-c clients]
+[\-n num_tests] [\-l sl] [\-e] [\-g gid index]
+
+.SH DESCRIPTION
+.PP
+Run a simple ping-pong test over InfiniBand via the extended reliable
+connected (XRC) transport service, using a shared receive queue (SRQ).
+
+.SH OPTIONS
+
+.PP
+.TP
+\fB\-p\fR, \fB\-\-port\fR=\fIPORT\fR
+use TCP port \fIPORT\fR for initial synchronization (default 18515)
+.TP
+\fB\-d\fR, \fB\-\-ib\-dev\fR=\fIDEVICE\fR
+use IB device \fIDEVICE\fR (default first device found)
+.TP
+\fB\-i\fR, \fB\-\-ib\-port\fR=\fIPORT\fR
+use IB port \fIPORT\fR (default port 1)
+.TP
+\fB\-s\fR, \fB\-\-size\fR=\fISIZE\fR
+ping-pong messages of size \fISIZE\fR (default 4096)
+.TP
+\fB\-m\fR, \fB\-\-mtu\fR=\fIMTU\fR
+use path mtu of size \fIMTU\fR (default 2048)
+.TP
+\fB\-c\fR, \fB\-\-clients\fR=\fICLIENTS\fR
+number of clients \fICLIENTS\fR (on server only, default 1)
+.TP
+\fB\-n\fR, \fB\-\-num\-tests\fR=\fINUM_TESTS\fR
+perform \fINUM_TESTS\fR tests per client (default 5)
+.TP
+\fB\-l\fR, \fB\-\-sl\fR=\fISL\fR
+use \fISL\fR as the service level value (default 0)
+.TP
+\fB\-e\fR, \fB\-\-events\fR
+sleep while waiting for work completion events (default is to poll for
+completions)
+.TP
+\fB\-g\fR, \fB\-\-gid-idx\fR=\fIGIDINDEX\fR
+local port \fIGIDINDEX\fR
+
+.SH SEE ALSO
+.BR ibv_rc_pingpong (1),
+.BR ibv_uc_pingpong (1),
+.BR ibv_ud_pingpong (1)
+.BR ibv_srq_pingpong (1)
+
+.SH AUTHORS
+.TP
+Roland Dreier
+.RI < roland@purestorage.com >
+.TP
+Jarod Wilson
+.RI < jarod@redhat.com >
+
+.SH BUGS
+The network synchronization between client and server instances is
+weak, and does not prevent incompatible options from being used on the
+two instances. The method used for retrieving work completions is not
+strictly correct, and race conditions may cause failures on some
+systems.
diff --git a/contrib/ofed/libibverbs/man/verbs.7 b/contrib/ofed/libibverbs/man/verbs.7
deleted file mode 100644
index eab4463..0000000
--- a/contrib/ofed/libibverbs/man/verbs.7
+++ /dev/null
@@ -1,228 +0,0 @@
-.\" -*- nroff -*-
-.\"
-.TH VERBS 7 2008-02-25 libibverbs "Libibverbs Programmer's Manual"
-.SH "NAME"
-verbs \- Infiniband verbs library
-.SH "SYNOPSIS"
-.nf
-.B #include <infiniband/verbs.h>
-.fi
-.SH "DESCRIPTION"
-This library is an implementation of the verbs based on the Infiniband specification volume 1.2 chapter 11. It handles the control path of creating, modifying, querying and destroying resources such as Protection Domains (PD), Completion Queues (CQ), Queue-Pairs (QP), Shared Receive Queues (SRQ), Address Handles (AH), Memory Regions (MR). It also handles sending and receiving data posted to QPs and SRQs, getting completions from CQs using polling and completions events.
-
-The control path is implemented through system calls to the uverbs kernel module which further calls the low level HW driver. The data path is implemented through calls made to low level HW library which in most cases interacts directly with the HW providing kernel and network stack bypass (saving context/mode switches) along with zero copy and an asynchronous I/O model.
-
-
-Typically, under network and RDMA programming, there are operations which involve interaction with remote peers (such as address resolution and connection establishment) and remote entities (such as route resolution and joining a multicast group under IB), where a resource managed through IB verbs such as QP or AH would be eventually created or effected from this interaction. In such cases, applications whose addressing semantics is based on IP can use librdmacm (see rdma_cm(7)) which works in conjunction with libibverbs.
-
-This library is thread safe library and verbs can be called from every thread in the process (the same resource can even be handled from different threads, for example: ibv_poll_cq can be called from more than one thread).
-
-However, it is up to the user to stop working with a resource after it was destroyed (by the same thread or by any other thread), this may result a segmentation fault.
-
-If fork (or any other system call that perform fork directly or indirectly) is being used, please see ibv_fork_init(3).
-
-.LP
-The following shall be declared as functions and may also be defined
-as macros. Function prototypes shall be provided.
-.RS
-.nf
-
-\fB
-.B Library functions
-
-int ibv_fork_init(void);
-
-.B Device functions
-
-struct ibv_device **ibv_get_device_list(int *num_devices);
-void ibv_free_device_list(struct ibv_device **list);
-const char *ibv_get_device_name(struct ibv_device *device);
-uint64_t ibv_get_device_guid(struct ibv_device *device);
-
-.B Context functions
-
-struct ibv_context *ibv_open_device(struct ibv_device *device);
-int ibv_close_device(struct ibv_context *context);
-
-.B Queries
-
-int ibv_query_device(struct ibv_context *context,
- struct ibv_device_attr *device_attr);
-int ibv_query_port(struct ibv_context *context, uint8_t port_num,
- struct ibv_port_attr *port_attr);
-int ibv_query_pkey(struct ibv_context *context, uint8_t port_num,
- int index, uint16_t *pkey);
-int ibv_query_gid(struct ibv_context *context, uint8_t port_num,
- int index, union ibv_gid *gid);
-
-.B Asynchronous events
-
-int ibv_get_async_event(struct ibv_context *context,
- struct ibv_async_event *event);
-void ibv_ack_async_event(struct ibv_async_event *event);
-
-.B Protection Domains
-
-struct ibv_pd *ibv_alloc_pd(struct ibv_context *context);
-int ibv_dealloc_pd(struct ibv_pd *pd);
-
-.B Memory Regions
-
-struct ibv_mr *ibv_reg_mr(struct ibv_pd *pd, void *addr,
- size_t length, enum ibv_access_flags access);
-int ibv_dereg_mr(struct ibv_mr *mr);
-
-.B Address Handles
-
-struct ibv_ah *ibv_create_ah(struct ibv_pd *pd, struct ibv_ah_attr *attr);
-int ibv_init_ah_from_wc(struct ibv_context *context, uint8_t port_num,
- struct ibv_wc *wc, struct ibv_grh *grh,
- struct ibv_ah_attr *ah_attr);
-struct ibv_ah *ibv_create_ah_from_wc(struct ibv_pd *pd, struct ibv_wc *wc,
- struct ibv_grh *grh, uint8_t port_num);
-int ibv_destroy_ah(struct ibv_ah *ah);
-
-.B Completion event channels
-
-struct ibv_comp_channel *ibv_create_comp_channel(struct ibv_context *context);
-int ibv_destroy_comp_channel(struct ibv_comp_channel *channel);
-
-.B Completion Queues Control
-
-struct ibv_cq *ibv_create_cq(struct ibv_context *context, int cqe,
- void *cq_context,
- struct ibv_comp_channel *channel,
- int comp_vector);
-int ibv_destroy_cq(struct ibv_cq *cq);
-int ibv_resize_cq(struct ibv_cq *cq, int cqe);
-
-.B Reading Completions from CQ
-
-int ibv_poll_cq(struct ibv_cq *cq, int num_entries, struct ibv_wc *wc);
-
-.B Requesting / Managing CQ events
-
-int ibv_req_notify_cq(struct ibv_cq *cq, int solicited_only);
-int ibv_get_cq_event(struct ibv_comp_channel *channel,
- struct ibv_cq **cq, void **cq_context);
-void ibv_ack_cq_events(struct ibv_cq *cq, unsigned int nevents);
-
-.B Shared Receive Queue control
-
-struct ibv_srq *ibv_create_srq(struct ibv_pd *pd,
- struct ibv_srq_init_attr *srq_init_attr);
-int ibv_destroy_srq(struct ibv_srq *srq);
-int ibv_modify_srq(struct ibv_srq *srq,
- struct ibv_srq_attr *srq_attr,
- enum ibv_srq_attr_mask srq_attr_mask);
-int ibv_query_srq(struct ibv_srq *srq, struct ibv_srq_attr *srq_attr);
-
-.B eXtended Reliable Connection control
-
-struct ibv_xrc_domain *ibv_open_xrc_domain(struct ibv_context *context,
- int fd, int oflag);
-int ibv_close_xrc_domain(struct ibv_xrc_domain *d);
-struct ibv_srq *ibv_create_xrc_srq(struct ibv_pd *pd,
- struct ibv_xrc_domain *xrc_domain,
- struct ibv_cq *xrc_cq,
- struct ibv_srq_init_attr *srq_init_attr);
-int ibv_create_xrc_rcv_qp(struct ibv_qp_init_attr *init_attr,
- uint32_t *xrc_rcv_qpn);
-int ibv_modify_xrc_rcv_qp(struct ibv_xrc_domain *xrc_domain, uint32_t xrc_qp_num,
- struct ibv_qp_attr *attr, int attr_mask);
-int ibv_query_xrc_rcv_qp(struct ibv_xrc_domain *xrc_domain, uint32_t xrc_qp_num,
- struct ibv_qp_attr *attr, int attr_mask,
- struct ibv_qp_init_attr *init_attr);
-int ibv_reg_xrc_rcv_qp(struct ibv_xrc_domain *xrc_domain, uint32_t xrc_qp_num);
-int ibv_unreg_xrc_rcv_qp(struct ibv_xrc_domain *xrc_domain, uint32_t xrc_qp_num);
-
-.B Queue Pair control
-
-struct ibv_qp *ibv_create_qp(struct ibv_pd *pd,
- struct ibv_qp_init_attr *qp_init_attr);
-int ibv_destroy_qp(struct ibv_qp *qp);
-int ibv_modify_qp(struct ibv_qp *qp, struct ibv_qp_attr *attr,
- enum ibv_qp_attr_mask attr_mask);
-int ibv_query_qp(struct ibv_qp *qp, struct ibv_qp_attr *attr,
- enum ibv_qp_attr_mask attr_mask,
- struct ibv_qp_init_attr *init_attr);
-
-.B posting Work Requests to QPs/SRQs
-int ibv_post_send(struct ibv_qp *qp, struct ibv_send_wr *wr,
- struct ibv_send_wr **bad_wr);
-int ibv_post_recv(struct ibv_qp *qp, struct ibv_recv_wr *wr,
- struct ibv_recv_wr **bad_wr);
-int ibv_post_srq_recv(struct ibv_srq *srq,
- struct ibv_recv_wr *recv_wr,
- struct ibv_recv_wr **bad_recv_wr);
-
-.B Multicast group
-
-int ibv_attach_mcast(struct ibv_qp *qp, union ibv_gid *gid, uint16_t lid);
-int ibv_detach_mcast(struct ibv_qp *qp, union ibv_gid *gid, uint16_t lid);
-
-.B General functions
-
-int ibv_rate_to_mult(enum ibv_rate rate);
-enum ibv_rate mult_to_ibv_rate(int mult);
-\fP
-.SH "SEE ALSO"
-.LP
-\fIibv_fork_init\fP(),
-\fIibv_get_device_list\fP(),
-\fIibv_free_device_list\fP(),
-\fIibv_get_device_name\fP(),
-\fIibv_get_device_guid\fP(),
-\fIibv_open_device\fP(),
-\fIibv_close_device\fP(),
-\fIibv_query_device\fP(),
-\fIibv_query_port\fP(),
-\fIibv_query_pkey\fP(),
-\fIibv_query_gid\fP(),
-\fIibv_get_async_event\fP(),
-\fIibv_ack_async_event\fP(),
-\fIibv_alloc_pd\fP(),
-\fIibv_dealloc_pd\fP(),
-\fIibv_reg_mr\fP(),
-\fIibv_dereg_mr\fP(),
-\fIibv_create_ah\fP(),
-\fIibv_init_ah_from_wc\fP(),
-\fIibv_create_ah_from_wc\fP(),
-\fIibv_destroy_ah\fP(),
-\fIibv_create_comp_channel\fP(),
-\fIibv_destroy_comp_channel\fP(),
-\fIibv_create_cq\fP(),
-\fIibv_destroy_cq\fP(),
-\fIibv_resize_cq\fP(),
-\fIibv_poll_cq\fP(),
-\fIibv_req_notify_cq\fP(),
-\fIibv_get_cq_event\fP(),
-\fIibv_ack_cq_events\fP(),
-\fIibv_create_srq\fP(),
-\fIibv_destroy_srq\fP(),
-\fIibv_modify_srq\fP(),
-\fIibv_query_srq\fP(),
-\fIibv_open_xrc_domain\fP(),
-\fIibv_close_xrc_domain\fP(),
-\fIibv_create_xrc_srq\fP(),
-\fIibv_create_xrc_rcv_qp\fP(),
-\fIibv_modify_xrc_rcv_qp\fP(),
-\fIibv_query_xrc_rcv_qp\fP(),
-\fIibv_reg_xrc_rcv_qp\fP(),
-\fIibv_unreg_xrc_rcv_qp\fP(),
-\fIibv_post_srq_recv\fP(),
-\fIibv_create_qp\fP(),
-\fIibv_destroy_qp\fP(),
-\fIibv_modify_qp\fP(),
-\fIibv_query_qp\fP(),
-\fIibv_post_send\fP(),
-\fIibv_post_recv\fP(),
-\fIibv_attach_mcast\fP(),
-\fIibv_detach_mcast\fP(),
-\fIibv_rate_to_mult\fP(),
-\fImult_to_ibv_rate\fP()
-.SH "AUTHORS"
-.TP
-Dotan Barak <dotanb@mellanox.co.il>
-.TP
-Or Gerlitz <ogerlitz@voltaire.com>
diff --git a/contrib/ofed/libibverbs/marshall.c b/contrib/ofed/libibverbs/marshall.c
new file mode 100644
index 0000000..5b02608
--- /dev/null
+++ b/contrib/ofed/libibverbs/marshall.c
@@ -0,0 +1,140 @@
+/*
+ * Copyright (c) 2005 Intel Corporation. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#include <config.h>
+
+#include <string.h>
+
+#include <infiniband/marshall.h>
+
+void ibv_copy_ah_attr_from_kern(struct ibv_ah_attr *dst,
+ struct ibv_kern_ah_attr *src)
+{
+ memcpy(dst->grh.dgid.raw, src->grh.dgid, sizeof dst->grh.dgid);
+ dst->grh.flow_label = src->grh.flow_label;
+ dst->grh.sgid_index = src->grh.sgid_index;
+ dst->grh.hop_limit = src->grh.hop_limit;
+ dst->grh.traffic_class = src->grh.traffic_class;
+
+ dst->dlid = src->dlid;
+ dst->sl = src->sl;
+ dst->src_path_bits = src->src_path_bits;
+ dst->static_rate = src->static_rate;
+ dst->is_global = src->is_global;
+ dst->port_num = src->port_num;
+}
+
+void ibv_copy_qp_attr_from_kern(struct ibv_qp_attr *dst,
+ struct ibv_kern_qp_attr *src)
+{
+ dst->cur_qp_state = src->cur_qp_state;
+ dst->path_mtu = src->path_mtu;
+ dst->path_mig_state = src->path_mig_state;
+ dst->qkey = src->qkey;
+ dst->rq_psn = src->rq_psn;
+ dst->sq_psn = src->sq_psn;
+ dst->dest_qp_num = src->dest_qp_num;
+ dst->qp_access_flags = src->qp_access_flags;
+
+ dst->cap.max_send_wr = src->max_send_wr;
+ dst->cap.max_recv_wr = src->max_recv_wr;
+ dst->cap.max_send_sge = src->max_send_sge;
+ dst->cap.max_recv_sge = src->max_recv_sge;
+ dst->cap.max_inline_data = src->max_inline_data;
+
+ ibv_copy_ah_attr_from_kern(&dst->ah_attr, &src->ah_attr);
+ ibv_copy_ah_attr_from_kern(&dst->alt_ah_attr, &src->alt_ah_attr);
+
+ dst->pkey_index = src->pkey_index;
+ dst->alt_pkey_index = src->alt_pkey_index;
+ dst->en_sqd_async_notify = src->en_sqd_async_notify;
+ dst->sq_draining = src->sq_draining;
+ dst->max_rd_atomic = src->max_rd_atomic;
+ dst->max_dest_rd_atomic = src->max_dest_rd_atomic;
+ dst->min_rnr_timer = src->min_rnr_timer;
+ dst->port_num = src->port_num;
+ dst->timeout = src->timeout;
+ dst->retry_cnt = src->retry_cnt;
+ dst->rnr_retry = src->rnr_retry;
+ dst->alt_port_num = src->alt_port_num;
+ dst->alt_timeout = src->alt_timeout;
+}
+
+void ibv_copy_path_rec_from_kern(struct ibv_sa_path_rec *dst,
+ struct ib_user_path_rec *src)
+{
+ memcpy(dst->dgid.raw, src->dgid, sizeof dst->dgid);
+ memcpy(dst->sgid.raw, src->sgid, sizeof dst->sgid);
+
+ dst->dlid = src->dlid;
+ dst->slid = src->slid;
+ dst->raw_traffic = src->raw_traffic;
+ dst->flow_label = src->flow_label;
+ dst->hop_limit = src->hop_limit;
+ dst->traffic_class = src->traffic_class;
+ dst->reversible = src->reversible;
+ dst->numb_path = src->numb_path;
+ dst->pkey = src->pkey;
+ dst->sl = src->sl;
+ dst->mtu_selector = src->mtu_selector;
+ dst->mtu = src->mtu;
+ dst->rate_selector = src->rate_selector;
+ dst->rate = src->rate;
+ dst->packet_life_time = src->packet_life_time;
+ dst->preference = src->preference;
+ dst->packet_life_time_selector = src->packet_life_time_selector;
+}
+
+void ibv_copy_path_rec_to_kern(struct ib_user_path_rec *dst,
+ struct ibv_sa_path_rec *src)
+{
+ memcpy(dst->dgid, src->dgid.raw, sizeof src->dgid);
+ memcpy(dst->sgid, src->sgid.raw, sizeof src->sgid);
+
+ dst->dlid = src->dlid;
+ dst->slid = src->slid;
+ dst->raw_traffic = src->raw_traffic;
+ dst->flow_label = src->flow_label;
+ dst->hop_limit = src->hop_limit;
+ dst->traffic_class = src->traffic_class;
+ dst->reversible = src->reversible;
+ dst->numb_path = src->numb_path;
+ dst->pkey = src->pkey;
+ dst->sl = src->sl;
+ dst->mtu_selector = src->mtu_selector;
+ dst->mtu = src->mtu;
+ dst->rate_selector = src->rate_selector;
+ dst->rate = src->rate;
+ dst->packet_life_time = src->packet_life_time;
+ dst->preference = src->preference;
+ dst->packet_life_time_selector = src->packet_life_time_selector;
+}
diff --git a/contrib/ofed/libibverbs/marshall.h b/contrib/ofed/libibverbs/marshall.h
new file mode 100644
index 0000000..1dab1114
--- /dev/null
+++ b/contrib/ofed/libibverbs/marshall.h
@@ -0,0 +1,65 @@
+/*
+ * Copyright (c) 2005 Intel Corporation. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#ifndef INFINIBAND_MARSHALL_H
+#define INFINIBAND_MARSHALL_H
+
+#include <infiniband/verbs.h>
+#include <infiniband/sa.h>
+#include <infiniband/kern-abi.h>
+#include <rdma/ib_user_sa.h>
+
+#ifdef __cplusplus
+# define BEGIN_C_DECLS extern "C" {
+# define END_C_DECLS }
+#else /* !__cplusplus */
+# define BEGIN_C_DECLS
+# define END_C_DECLS
+#endif /* __cplusplus */
+
+BEGIN_C_DECLS
+
+void ibv_copy_qp_attr_from_kern(struct ibv_qp_attr *dst,
+ struct ibv_kern_qp_attr *src);
+
+void ibv_copy_ah_attr_from_kern(struct ibv_ah_attr *dst,
+ struct ibv_kern_ah_attr *src);
+
+void ibv_copy_path_rec_from_kern(struct ibv_sa_path_rec *dst,
+ struct ib_user_path_rec *src);
+
+void ibv_copy_path_rec_to_kern(struct ib_user_path_rec *dst,
+ struct ibv_sa_path_rec *src);
+
+END_C_DECLS
+
+#endif /* INFINIBAND_MARSHALL_H */
diff --git a/contrib/ofed/libibverbs/memory.c b/contrib/ofed/libibverbs/memory.c
new file mode 100644
index 0000000..5c8255d
--- /dev/null
+++ b/contrib/ofed/libibverbs/memory.c
@@ -0,0 +1,704 @@
+/*
+ * Copyright (c) 2004, 2005 Topspin Communications. All rights reserved.
+ * Copyright (c) 2006 Cisco Systems, Inc. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#include <config.h>
+
+#include <errno.h>
+#include <sys/mman.h>
+#include <unistd.h>
+#include <stdlib.h>
+#include <stdint.h>
+#include <stdio.h>
+#include <string.h>
+#include <dirent.h>
+#include <limits.h>
+#include <inttypes.h>
+
+#include "ibverbs.h"
+
+struct ibv_mem_node {
+ enum {
+ IBV_RED,
+ IBV_BLACK
+ } color;
+ struct ibv_mem_node *parent;
+ struct ibv_mem_node *left, *right;
+ uintptr_t start, end;
+ int refcnt;
+};
+
+static struct ibv_mem_node *mm_root;
+static pthread_mutex_t mm_mutex = PTHREAD_MUTEX_INITIALIZER;
+static int page_size;
+static int huge_page_enabled;
+static int too_late;
+
+static unsigned long smaps_page_size(FILE *file)
+{
+ int n;
+ unsigned long size = page_size;
+ char buf[1024];
+
+ while (fgets(buf, sizeof(buf), file) != NULL) {
+ if (!strstr(buf, "KernelPageSize:"))
+ continue;
+
+ n = sscanf(buf, "%*s %lu", &size);
+ if (n < 1)
+ continue;
+
+ /* page size is printed in Kb */
+ size = size * 1024;
+
+ break;
+ }
+
+ return size;
+}
+
+static unsigned long get_page_size(void *base)
+{
+ unsigned long ret = page_size;
+ pid_t pid;
+ FILE *file;
+ char buf[1024];
+
+ pid = getpid();
+ snprintf(buf, sizeof(buf), "/proc/%d/smaps", pid);
+
+ file = fopen(buf, "r" STREAM_CLOEXEC);
+ if (!file)
+ goto out;
+
+ while (fgets(buf, sizeof(buf), file) != NULL) {
+ int n;
+ uintptr_t range_start, range_end;
+
+ n = sscanf(buf, "%" SCNxPTR "-%" SCNxPTR, &range_start, &range_end);
+
+ if (n < 2)
+ continue;
+
+ if ((uintptr_t) base >= range_start && (uintptr_t) base < range_end) {
+ ret = smaps_page_size(file);
+ break;
+ }
+ }
+
+ fclose(file);
+
+out:
+ return ret;
+}
+
+int ibv_fork_init(void)
+{
+ void *tmp, *tmp_aligned;
+ int ret;
+ unsigned long size;
+
+ if (getenv("RDMAV_HUGEPAGES_SAFE"))
+ huge_page_enabled = 1;
+
+ if (mm_root)
+ return 0;
+
+ if (too_late)
+ return EINVAL;
+
+ page_size = sysconf(_SC_PAGESIZE);
+ if (page_size < 0)
+ return errno;
+
+ if (posix_memalign(&tmp, page_size, page_size))
+ return ENOMEM;
+
+ if (huge_page_enabled) {
+ size = get_page_size(tmp);
+ tmp_aligned = (void *) ((uintptr_t) tmp & ~(size - 1));
+ } else {
+ size = page_size;
+ tmp_aligned = tmp;
+ }
+
+ ret = madvise(tmp_aligned, size, MADV_DONTFORK) ||
+ madvise(tmp_aligned, size, MADV_DOFORK);
+
+ free(tmp);
+
+ if (ret)
+ return ENOSYS;
+
+ mm_root = malloc(sizeof *mm_root);
+ if (!mm_root)
+ return ENOMEM;
+
+ mm_root->parent = NULL;
+ mm_root->left = NULL;
+ mm_root->right = NULL;
+ mm_root->color = IBV_BLACK;
+ mm_root->start = 0;
+ mm_root->end = UINTPTR_MAX;
+ mm_root->refcnt = 0;
+
+ return 0;
+}
+
+static struct ibv_mem_node *__mm_prev(struct ibv_mem_node *node)
+{
+ if (node->left) {
+ node = node->left;
+ while (node->right)
+ node = node->right;
+ } else {
+ while (node->parent && node == node->parent->left)
+ node = node->parent;
+
+ node = node->parent;
+ }
+
+ return node;
+}
+
+static struct ibv_mem_node *__mm_next(struct ibv_mem_node *node)
+{
+ if (node->right) {
+ node = node->right;
+ while (node->left)
+ node = node->left;
+ } else {
+ while (node->parent && node == node->parent->right)
+ node = node->parent;
+
+ node = node->parent;
+ }
+
+ return node;
+}
+
+static void __mm_rotate_right(struct ibv_mem_node *node)
+{
+ struct ibv_mem_node *tmp;
+
+ tmp = node->left;
+
+ node->left = tmp->right;
+ if (node->left)
+ node->left->parent = node;
+
+ if (node->parent) {
+ if (node->parent->right == node)
+ node->parent->right = tmp;
+ else
+ node->parent->left = tmp;
+ } else
+ mm_root = tmp;
+
+ tmp->parent = node->parent;
+
+ tmp->right = node;
+ node->parent = tmp;
+}
+
+static void __mm_rotate_left(struct ibv_mem_node *node)
+{
+ struct ibv_mem_node *tmp;
+
+ tmp = node->right;
+
+ node->right = tmp->left;
+ if (node->right)
+ node->right->parent = node;
+
+ if (node->parent) {
+ if (node->parent->right == node)
+ node->parent->right = tmp;
+ else
+ node->parent->left = tmp;
+ } else
+ mm_root = tmp;
+
+ tmp->parent = node->parent;
+
+ tmp->left = node;
+ node->parent = tmp;
+}
+
+#if 0
+static int verify(struct ibv_mem_node *node)
+{
+ int hl, hr;
+
+ if (!node)
+ return 1;
+
+ hl = verify(node->left);
+ hr = verify(node->left);
+
+ if (!hl || !hr)
+ return 0;
+ if (hl != hr)
+ return 0;
+
+ if (node->color == IBV_RED) {
+ if (node->left && node->left->color != IBV_BLACK)
+ return 0;
+ if (node->right && node->right->color != IBV_BLACK)
+ return 0;
+ return hl;
+ }
+
+ return hl + 1;
+}
+#endif
+
+static void __mm_add_rebalance(struct ibv_mem_node *node)
+{
+ struct ibv_mem_node *parent, *gp, *uncle;
+
+ while (node->parent && node->parent->color == IBV_RED) {
+ parent = node->parent;
+ gp = node->parent->parent;
+
+ if (parent == gp->left) {
+ uncle = gp->right;
+
+ if (uncle && uncle->color == IBV_RED) {
+ parent->color = IBV_BLACK;
+ uncle->color = IBV_BLACK;
+ gp->color = IBV_RED;
+
+ node = gp;
+ } else {
+ if (node == parent->right) {
+ __mm_rotate_left(parent);
+ node = parent;
+ parent = node->parent;
+ }
+
+ parent->color = IBV_BLACK;
+ gp->color = IBV_RED;
+
+ __mm_rotate_right(gp);
+ }
+ } else {
+ uncle = gp->left;
+
+ if (uncle && uncle->color == IBV_RED) {
+ parent->color = IBV_BLACK;
+ uncle->color = IBV_BLACK;
+ gp->color = IBV_RED;
+
+ node = gp;
+ } else {
+ if (node == parent->left) {
+ __mm_rotate_right(parent);
+ node = parent;
+ parent = node->parent;
+ }
+
+ parent->color = IBV_BLACK;
+ gp->color = IBV_RED;
+
+ __mm_rotate_left(gp);
+ }
+ }
+ }
+
+ mm_root->color = IBV_BLACK;
+}
+
+static void __mm_add(struct ibv_mem_node *new)
+{
+ struct ibv_mem_node *node, *parent = NULL;
+
+ node = mm_root;
+ while (node) {
+ parent = node;
+ if (node->start < new->start)
+ node = node->right;
+ else
+ node = node->left;
+ }
+
+ if (parent->start < new->start)
+ parent->right = new;
+ else
+ parent->left = new;
+
+ new->parent = parent;
+ new->left = NULL;
+ new->right = NULL;
+
+ new->color = IBV_RED;
+ __mm_add_rebalance(new);
+}
+
+static void __mm_remove(struct ibv_mem_node *node)
+{
+ struct ibv_mem_node *child, *parent, *sib, *tmp;
+ int nodecol;
+
+ if (node->left && node->right) {
+ tmp = node->left;
+ while (tmp->right)
+ tmp = tmp->right;
+
+ nodecol = tmp->color;
+ child = tmp->left;
+ tmp->color = node->color;
+
+ if (tmp->parent != node) {
+ parent = tmp->parent;
+ parent->right = tmp->left;
+ if (tmp->left)
+ tmp->left->parent = parent;
+
+ tmp->left = node->left;
+ node->left->parent = tmp;
+ } else
+ parent = tmp;
+
+ tmp->right = node->right;
+ node->right->parent = tmp;
+
+ tmp->parent = node->parent;
+ if (node->parent) {
+ if (node->parent->left == node)
+ node->parent->left = tmp;
+ else
+ node->parent->right = tmp;
+ } else
+ mm_root = tmp;
+ } else {
+ nodecol = node->color;
+
+ child = node->left ? node->left : node->right;
+ parent = node->parent;
+
+ if (child)
+ child->parent = parent;
+ if (parent) {
+ if (parent->left == node)
+ parent->left = child;
+ else
+ parent->right = child;
+ } else
+ mm_root = child;
+ }
+
+ free(node);
+
+ if (nodecol == IBV_RED)
+ return;
+
+ while ((!child || child->color == IBV_BLACK) && child != mm_root) {
+ if (parent->left == child) {
+ sib = parent->right;
+
+ if (sib->color == IBV_RED) {
+ parent->color = IBV_RED;
+ sib->color = IBV_BLACK;
+ __mm_rotate_left(parent);
+ sib = parent->right;
+ }
+
+ if ((!sib->left || sib->left->color == IBV_BLACK) &&
+ (!sib->right || sib->right->color == IBV_BLACK)) {
+ sib->color = IBV_RED;
+ child = parent;
+ parent = child->parent;
+ } else {
+ if (!sib->right || sib->right->color == IBV_BLACK) {
+ if (sib->left)
+ sib->left->color = IBV_BLACK;
+ sib->color = IBV_RED;
+ __mm_rotate_right(sib);
+ sib = parent->right;
+ }
+
+ sib->color = parent->color;
+ parent->color = IBV_BLACK;
+ if (sib->right)
+ sib->right->color = IBV_BLACK;
+ __mm_rotate_left(parent);
+ child = mm_root;
+ break;
+ }
+ } else {
+ sib = parent->left;
+
+ if (sib->color == IBV_RED) {
+ parent->color = IBV_RED;
+ sib->color = IBV_BLACK;
+ __mm_rotate_right(parent);
+ sib = parent->left;
+ }
+
+ if ((!sib->left || sib->left->color == IBV_BLACK) &&
+ (!sib->right || sib->right->color == IBV_BLACK)) {
+ sib->color = IBV_RED;
+ child = parent;
+ parent = child->parent;
+ } else {
+ if (!sib->left || sib->left->color == IBV_BLACK) {
+ if (sib->right)
+ sib->right->color = IBV_BLACK;
+ sib->color = IBV_RED;
+ __mm_rotate_left(sib);
+ sib = parent->left;
+ }
+
+ sib->color = parent->color;
+ parent->color = IBV_BLACK;
+ if (sib->left)
+ sib->left->color = IBV_BLACK;
+ __mm_rotate_right(parent);
+ child = mm_root;
+ break;
+ }
+ }
+ }
+
+ if (child)
+ child->color = IBV_BLACK;
+}
+
+static struct ibv_mem_node *__mm_find_start(uintptr_t start, uintptr_t end)
+{
+ struct ibv_mem_node *node = mm_root;
+
+ while (node) {
+ if (node->start <= start && node->end >= start)
+ break;
+
+ if (node->start < start)
+ node = node->right;
+ else
+ node = node->left;
+ }
+
+ return node;
+}
+
+static struct ibv_mem_node *merge_ranges(struct ibv_mem_node *node,
+ struct ibv_mem_node *prev)
+{
+ prev->end = node->end;
+ prev->refcnt = node->refcnt;
+ __mm_remove(node);
+
+ return prev;
+}
+
+static struct ibv_mem_node *split_range(struct ibv_mem_node *node,
+ uintptr_t cut_line)
+{
+ struct ibv_mem_node *new_node = NULL;
+
+ new_node = malloc(sizeof *new_node);
+ if (!new_node)
+ return NULL;
+ new_node->start = cut_line;
+ new_node->end = node->end;
+ new_node->refcnt = node->refcnt;
+ node->end = cut_line - 1;
+ __mm_add(new_node);
+
+ return new_node;
+}
+
+static struct ibv_mem_node *get_start_node(uintptr_t start, uintptr_t end,
+ int inc)
+{
+ struct ibv_mem_node *node, *tmp = NULL;
+
+ node = __mm_find_start(start, end);
+ if (node->start < start)
+ node = split_range(node, start);
+ else {
+ tmp = __mm_prev(node);
+ if (tmp && tmp->refcnt == node->refcnt + inc)
+ node = merge_ranges(node, tmp);
+ }
+ return node;
+}
+
+/*
+ * This function is called if madvise() fails to undo merging/splitting
+ * operations performed on the node.
+ */
+static struct ibv_mem_node *undo_node(struct ibv_mem_node *node,
+ uintptr_t start, int inc)
+{
+ struct ibv_mem_node *tmp = NULL;
+
+ /*
+ * This condition can be true only if we merged this
+ * node with the previous one, so we need to split them.
+ */
+ if (start > node->start) {
+ tmp = split_range(node, start);
+ if (tmp) {
+ node->refcnt += inc;
+ node = tmp;
+ } else
+ return NULL;
+ }
+
+ tmp = __mm_prev(node);
+ if (tmp && tmp->refcnt == node->refcnt)
+ node = merge_ranges(node, tmp);
+
+ tmp = __mm_next(node);
+ if (tmp && tmp->refcnt == node->refcnt)
+ node = merge_ranges(tmp, node);
+
+ return node;
+}
+
+static int ibv_madvise_range(void *base, size_t size, int advice)
+{
+ uintptr_t start, end;
+ struct ibv_mem_node *node, *tmp;
+ int inc;
+ int rolling_back = 0;
+ int ret = 0;
+ unsigned long range_page_size;
+
+ if (!size)
+ return 0;
+
+ if (huge_page_enabled)
+ range_page_size = get_page_size(base);
+ else
+ range_page_size = page_size;
+
+ start = (uintptr_t) base & ~(range_page_size - 1);
+ end = ((uintptr_t) (base + size + range_page_size - 1) &
+ ~(range_page_size - 1)) - 1;
+
+ pthread_mutex_lock(&mm_mutex);
+again:
+ inc = advice == MADV_DONTFORK ? 1 : -1;
+
+ node = get_start_node(start, end, inc);
+ if (!node) {
+ ret = -1;
+ goto out;
+ }
+
+ while (node && node->start <= end) {
+ if (node->end > end) {
+ if (!split_range(node, end + 1)) {
+ ret = -1;
+ goto out;
+ }
+ }
+
+ if ((inc == -1 && node->refcnt == 1) ||
+ (inc == 1 && node->refcnt == 0)) {
+ /*
+ * If this is the first time through the loop,
+ * and we merged this node with the previous
+ * one, then we only want to do the madvise()
+ * on start ... node->end (rather than
+ * starting at node->start).
+ *
+ * Otherwise we end up doing madvise() on
+ * bigger region than we're being asked to,
+ * and that may lead to a spurious failure.
+ */
+ if (start > node->start)
+ ret = madvise((void *) start, node->end - start + 1,
+ advice);
+ else
+ ret = madvise((void *) node->start,
+ node->end - node->start + 1,
+ advice);
+ if (ret) {
+ node = undo_node(node, start, inc);
+
+ if (rolling_back || !node)
+ goto out;
+
+ /* madvise failed, roll back previous changes */
+ rolling_back = 1;
+ advice = advice == MADV_DONTFORK ?
+ MADV_DOFORK : MADV_DONTFORK;
+ tmp = __mm_prev(node);
+ if (!tmp || start > tmp->end)
+ goto out;
+ end = tmp->end;
+ goto again;
+ }
+ }
+
+ node->refcnt += inc;
+ node = __mm_next(node);
+ }
+
+ if (node) {
+ tmp = __mm_prev(node);
+ if (tmp && node->refcnt == tmp->refcnt)
+ node = merge_ranges(node, tmp);
+ }
+
+out:
+ if (rolling_back)
+ ret = -1;
+
+ pthread_mutex_unlock(&mm_mutex);
+
+ return ret;
+}
+
+int ibv_dontfork_range(void *base, size_t size)
+{
+ if (mm_root)
+ return ibv_madvise_range(base, size, MADV_DONTFORK);
+ else {
+ too_late = 1;
+ return 0;
+ }
+}
+
+int ibv_dofork_range(void *base, size_t size)
+{
+ if (mm_root)
+ return ibv_madvise_range(base, size, MADV_DOFORK);
+ else {
+ too_late = 1;
+ return 0;
+ }
+}
diff --git a/contrib/ofed/libibverbs/neigh.c b/contrib/ofed/libibverbs/neigh.c
new file mode 100644
index 0000000..2eba8e2
--- /dev/null
+++ b/contrib/ofed/libibverbs/neigh.c
@@ -0,0 +1,848 @@
+/* Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md
+ */
+
+#include "config.h"
+#include <net/if_packet.h>
+#include <linux/netlink.h>
+#include <linux/rtnetlink.h>
+#include <infiniband/endian.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <stdbool.h>
+
+#if HAVE_WORKING_IF_H
+#include <net/if.h>
+#endif
+
+#include <netlink/route/rtnl.h>
+#include <netlink/route/link.h>
+#include <netlink/route/route.h>
+#include <netlink/route/neighbour.h>
+
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <sys/timerfd.h>
+#include <errno.h>
+#include <unistd.h>
+#include <ifaddrs.h>
+#include <netdb.h>
+#include <assert.h>
+
+#if !HAVE_WORKING_IF_H
+/* We need this decl from net/if.h but old systems do not let use co-include
+ net/if.h and netlink/route/link.h */
+extern unsigned int if_nametoindex(__const char *__ifname) __THROW;
+#endif
+
+/* for PFX */
+#include "ibverbs.h"
+#include <sys/param.h>
+
+#include "neigh.h"
+
+#ifndef HAVE_LIBNL1
+#include <netlink/route/link/vlan.h>
+#endif
+
+static pthread_once_t device_neigh_alloc = PTHREAD_ONCE_INIT;
+static struct nl_sock *zero_socket;
+
+union sktaddr {
+ struct sockaddr s;
+ struct sockaddr_in s4;
+ struct sockaddr_in6 s6;
+};
+
+struct skt {
+ union sktaddr sktaddr;
+ socklen_t len;
+};
+
+static int set_link_port(union sktaddr *s, __be16 port, int oif)
+{
+ switch (s->s.sa_family) {
+ case AF_INET:
+ s->s4.sin_port = port;
+ break;
+ case AF_INET6:
+ s->s6.sin6_port = port;
+ s->s6.sin6_scope_id = oif;
+ break;
+ default:
+ return -EINVAL;
+ }
+
+ return 0;
+}
+
+static bool cmp_address(const struct sockaddr *s1,
+ const struct sockaddr *s2)
+{
+ if (s1->sa_family != s2->sa_family)
+ return false;
+
+ switch (s1->sa_family) {
+ case AF_INET:
+ return ((struct sockaddr_in *)s1)->sin_addr.s_addr ==
+ ((struct sockaddr_in *)s2)->sin_addr.s_addr;
+ case AF_INET6:
+ return !memcmp(
+ ((struct sockaddr_in6 *)s1)->sin6_addr.s6_addr,
+ ((struct sockaddr_in6 *)s2)->sin6_addr.s6_addr,
+ sizeof(((struct sockaddr_in6 *)s1)->sin6_addr.s6_addr));
+ default:
+ return false;
+ }
+}
+
+static int get_ifindex(const struct sockaddr *s)
+{
+ struct ifaddrs *ifaddr, *ifa;
+ int name2index = -ENODEV;
+
+ if (-1 == getifaddrs(&ifaddr))
+ return errno;
+
+ for (ifa = ifaddr; ifa != NULL; ifa = ifa->ifa_next) {
+ if (ifa->ifa_addr == NULL)
+ continue;
+
+ if (cmp_address(ifa->ifa_addr, s)) {
+ name2index = if_nametoindex(ifa->ifa_name);
+ break;
+ }
+ }
+
+ freeifaddrs(ifaddr);
+
+ return name2index;
+}
+
+static struct nl_addr *get_neigh_mac(struct get_neigh_handler *neigh_handler)
+{
+ struct rtnl_neigh *neigh;
+ struct nl_addr *ll_addr = NULL;
+
+ /* future optimization - if link local address - parse address and
+ * return mac now instead of doing so after the routing CB. This
+ * is of course referred to GIDs */
+ neigh = rtnl_neigh_get(neigh_handler->neigh_cache,
+ neigh_handler->oif,
+ neigh_handler->dst);
+ if (neigh == NULL)
+ return NULL;
+
+ ll_addr = rtnl_neigh_get_lladdr(neigh);
+ if (NULL != ll_addr)
+ ll_addr = nl_addr_clone(ll_addr);
+
+ rtnl_neigh_put(neigh);
+ return ll_addr;
+}
+
+static void get_neigh_cb_event(struct nl_object *obj, void *arg)
+{
+ struct get_neigh_handler *neigh_handler =
+ (struct get_neigh_handler *)arg;
+ /* assumed serilized callback (no parallel execution of function) */
+ if (nl_object_match_filter(
+ obj,
+ (struct nl_object *)neigh_handler->filter_neigh)) {
+ struct rtnl_neigh *neigh = (struct rtnl_neigh *)obj;
+ /* check that we didn't set it already */
+ if (neigh_handler->found_ll_addr == NULL) {
+ if (rtnl_neigh_get_lladdr(neigh) == NULL)
+ return;
+
+ neigh_handler->found_ll_addr =
+ nl_addr_clone(rtnl_neigh_get_lladdr(neigh));
+ }
+ }
+}
+
+static int get_neigh_cb(struct nl_msg *msg, void *arg)
+{
+ struct get_neigh_handler *neigh_handler =
+ (struct get_neigh_handler *)arg;
+
+ if (nl_msg_parse(msg, &get_neigh_cb_event, neigh_handler) < 0)
+ errno = ENOMSG;
+
+ return NL_OK;
+}
+
+static void set_neigh_filter(struct get_neigh_handler *neigh_handler,
+ struct rtnl_neigh *filter) {
+ neigh_handler->filter_neigh = filter;
+}
+
+static struct rtnl_neigh *create_filter_neigh_for_dst(struct nl_addr *dst_addr,
+ int oif)
+{
+ struct rtnl_neigh *filter_neigh;
+
+ filter_neigh = rtnl_neigh_alloc();
+ if (filter_neigh == NULL)
+ return NULL;
+
+ rtnl_neigh_set_ifindex(filter_neigh, oif);
+ rtnl_neigh_set_dst(filter_neigh, dst_addr);
+
+ return filter_neigh;
+}
+
+#define PORT_DISCARD htobe16(9)
+#define SEND_PAYLOAD "H"
+
+static int create_socket(struct get_neigh_handler *neigh_handler,
+ struct skt *addr_dst, int *psock_fd)
+{
+ int err;
+ struct skt addr_src;
+ int sock_fd;
+
+ memset(addr_dst, 0, sizeof(*addr_dst));
+ memset(&addr_src, 0, sizeof(addr_src));
+ addr_src.len = sizeof(addr_src.sktaddr);
+
+ err = nl_addr_fill_sockaddr(neigh_handler->src,
+ &addr_src.sktaddr.s,
+ &addr_src.len);
+ if (err) {
+ errno = EADDRNOTAVAIL;
+ return -1;
+ }
+
+ addr_dst->len = sizeof(addr_dst->sktaddr);
+ err = nl_addr_fill_sockaddr(neigh_handler->dst,
+ &addr_dst->sktaddr.s,
+ &addr_dst->len);
+ if (err) {
+ errno = EADDRNOTAVAIL;
+ return -1;
+ }
+
+ err = set_link_port(&addr_dst->sktaddr, PORT_DISCARD,
+ neigh_handler->oif);
+ if (err)
+ return -1;
+
+ sock_fd = socket(addr_dst->sktaddr.s.sa_family,
+ SOCK_DGRAM | SOCK_CLOEXEC, 0);
+ if (sock_fd == -1)
+ return -1;
+ err = bind(sock_fd, &addr_src.sktaddr.s, addr_src.len);
+ if (err) {
+ close(sock_fd);
+ return -1;
+ }
+
+ *psock_fd = sock_fd;
+
+ return 0;
+}
+
+#define NUM_OF_RETRIES 10
+#define NUM_OF_TRIES ((NUM_OF_RETRIES) + 1)
+#if NUM_OF_TRIES < 1
+#error "neigh: invalid value of NUM_OF_RETRIES"
+#endif
+static int create_timer(struct get_neigh_handler *neigh_handler)
+{
+ int user_timeout = neigh_handler->timeout/NUM_OF_TRIES;
+ struct timespec timeout = {
+ .tv_sec = user_timeout / 1000,
+ .tv_nsec = (user_timeout % 1000) * 1000000
+ };
+ struct itimerspec timer_time = {.it_value = timeout};
+ int timer_fd;
+
+ timer_fd = timerfd_create(CLOCK_MONOTONIC, TFD_NONBLOCK | TFD_CLOEXEC);
+ if (timer_fd == -1)
+ return timer_fd;
+
+ if (neigh_handler->timeout) {
+ if (NUM_OF_TRIES <= 1)
+ bzero(&timer_time.it_interval,
+ sizeof(timer_time.it_interval));
+ else
+ timer_time.it_interval = timeout;
+ if (timerfd_settime(timer_fd, 0, &timer_time, NULL)) {
+ close(timer_fd);
+ return -1;
+ }
+ }
+
+ return timer_fd;
+}
+
+#define UDP_SOCKET_MAX_SENDTO 100000ULL
+static int try_send_to(int sock_fd, void *buff, size_t buf_size,
+ struct skt *addr_dst)
+{
+ uint64_t max_count = UDP_SOCKET_MAX_SENDTO;
+ int err;
+
+ do {
+ err = sendto(sock_fd, buff, buf_size, 0,
+ &addr_dst->sktaddr.s,
+ addr_dst->len);
+ if (err > 0)
+ err = 0;
+ } while (-1 == err && EADDRNOTAVAIL == errno && --max_count);
+
+ return err;
+}
+
+static struct nl_addr *process_get_neigh_mac(
+ struct get_neigh_handler *neigh_handler)
+{
+ int err;
+ struct nl_addr *ll_addr = get_neigh_mac(neigh_handler);
+ struct rtnl_neigh *neigh_filter;
+ fd_set fdset;
+ int sock_fd;
+ int fd;
+ int nfds;
+ int timer_fd;
+ int ret;
+ struct skt addr_dst;
+ char buff[sizeof(SEND_PAYLOAD)] = SEND_PAYLOAD;
+ int retries = 0;
+
+ if (NULL != ll_addr)
+ return ll_addr;
+
+ err = nl_socket_add_membership(neigh_handler->sock,
+ RTNLGRP_NEIGH);
+ if (err < 0)
+ return NULL;
+
+ neigh_filter = create_filter_neigh_for_dst(neigh_handler->dst,
+ neigh_handler->oif);
+ if (neigh_filter == NULL)
+ return NULL;
+
+ set_neigh_filter(neigh_handler, neigh_filter);
+
+ nl_socket_disable_seq_check(neigh_handler->sock);
+ nl_socket_modify_cb(neigh_handler->sock, NL_CB_VALID, NL_CB_CUSTOM,
+ &get_neigh_cb, neigh_handler);
+
+ fd = nl_socket_get_fd(neigh_handler->sock);
+
+ err = create_socket(neigh_handler, &addr_dst, &sock_fd);
+
+ if (err)
+ return NULL;
+
+ err = try_send_to(sock_fd, buff, sizeof(buff), &addr_dst);
+ if (err)
+ goto close_socket;
+
+ timer_fd = create_timer(neigh_handler);
+ if (timer_fd < 0)
+ goto close_socket;
+
+ nfds = MAX(fd, timer_fd) + 1;
+
+ while (1) {
+ FD_ZERO(&fdset);
+ FD_SET(fd, &fdset);
+ FD_SET(timer_fd, &fdset);
+
+ /* wait for an incoming message on the netlink socket */
+ ret = select(nfds, &fdset, NULL, NULL, NULL);
+ if (ret == -1) {
+ goto select_err;
+ } else if (ret) {
+ if (FD_ISSET(fd, &fdset)) {
+ nl_recvmsgs_default(neigh_handler->sock);
+ if (neigh_handler->found_ll_addr)
+ break;
+ } else {
+ nl_cache_refill(neigh_handler->sock,
+ neigh_handler->neigh_cache);
+ ll_addr = get_neigh_mac(neigh_handler);
+ if (NULL != ll_addr) {
+ break;
+ } else if (FD_ISSET(timer_fd, &fdset) &&
+ retries < NUM_OF_RETRIES) {
+ try_send_to(sock_fd, buff, sizeof(buff),
+ &addr_dst);
+ }
+ }
+
+ if (FD_ISSET(timer_fd, &fdset)) {
+ uint64_t read_val;
+ ssize_t rc;
+
+ rc =
+ read(timer_fd, &read_val, sizeof(read_val));
+ assert(rc == sizeof(read_val));
+ if (++retries >= NUM_OF_TRIES) {
+ if (!errno)
+ errno = EDESTADDRREQ;
+ break;
+ }
+ }
+ }
+ }
+select_err:
+ close(timer_fd);
+close_socket:
+ close(sock_fd);
+ return ll_addr ? ll_addr : neigh_handler->found_ll_addr;
+}
+
+static int get_mcast_mac_ipv4(struct nl_addr *dst, struct nl_addr **ll_addr)
+{
+ uint8_t mac_addr[6] = {0x01, 0x00, 0x5E};
+ uint32_t addr = be32toh(*(__be32 *)nl_addr_get_binary_addr(dst));
+
+ mac_addr[5] = addr & 0xFF;
+ addr >>= 8;
+ mac_addr[4] = addr & 0xFF;
+ addr >>= 8;
+ mac_addr[3] = addr & 0x7F;
+
+ *ll_addr = nl_addr_build(AF_LLC, mac_addr, sizeof(mac_addr));
+
+ return *ll_addr == NULL ? -EINVAL : 0;
+}
+
+static int get_mcast_mac_ipv6(struct nl_addr *dst, struct nl_addr **ll_addr)
+{
+ uint8_t mac_addr[6] = {0x33, 0x33};
+
+ memcpy(mac_addr + 2, (uint8_t *)nl_addr_get_binary_addr(dst) + 12, 4);
+
+ *ll_addr = nl_addr_build(AF_LLC, mac_addr, sizeof(mac_addr));
+
+ return *ll_addr == NULL ? -EINVAL : 0;
+}
+
+static int get_link_local_mac_ipv6(struct nl_addr *dst,
+ struct nl_addr **ll_addr)
+{
+ uint8_t mac_addr[6];
+
+ memcpy(mac_addr + 3, (uint8_t *)nl_addr_get_binary_addr(dst) + 13, 3);
+ memcpy(mac_addr, (uint8_t *)nl_addr_get_binary_addr(dst) + 8, 3);
+ mac_addr[0] ^= 2;
+
+ *ll_addr = nl_addr_build(AF_LLC, mac_addr, sizeof(mac_addr));
+ return *ll_addr == NULL ? -EINVAL : 0;
+}
+
+static const struct encoded_l3_addr {
+ short family;
+ uint8_t prefix_bits;
+ const uint8_t data[16];
+ int (*getter)(struct nl_addr *dst, struct nl_addr **ll_addr);
+} encoded_prefixes[] = {
+ {.family = AF_INET,
+ .prefix_bits = 4,
+ .data = {0xe0},
+ .getter = &get_mcast_mac_ipv4},
+ {.family = AF_INET6,
+ .prefix_bits = 8,
+ .data = {0xff},
+ .getter = &get_mcast_mac_ipv6},
+ {.family = AF_INET6,
+ .prefix_bits = 64,
+ .data = {0xfe, 0x80},
+ .getter = get_link_local_mac_ipv6},
+};
+
+static int nl_addr_cmp_prefix_msb(void *addr1, int len1, void *addr2, int len2)
+{
+ int len = min(len1, len2);
+ int bytes = len / 8;
+ int d = memcmp(addr1, addr2, bytes);
+
+ if (d == 0) {
+ int mask = ((1UL << (len % 8)) - 1UL) << (8 - len);
+
+ d = (((uint8_t *)addr1)[bytes] & mask) -
+ (((uint8_t *)addr2)[bytes] & mask);
+ }
+
+ return d;
+}
+
+static int handle_encoded_mac(struct nl_addr *dst, struct nl_addr **ll_addr)
+{
+ uint32_t family = nl_addr_get_family(dst);
+ struct nl_addr *prefix = NULL;
+ int i;
+ int ret = 1;
+
+ for (i = 0;
+ i < sizeof(encoded_prefixes)/sizeof(encoded_prefixes[0]) &&
+ ret; prefix = NULL, i++) {
+ if (encoded_prefixes[i].family != family)
+ continue;
+
+ prefix = nl_addr_build(
+ family, (void *)encoded_prefixes[i].data,
+ min_t(size_t, encoded_prefixes[i].prefix_bits / 8 +
+ !!(encoded_prefixes[i].prefix_bits % 8),
+ sizeof(encoded_prefixes[i].data)));
+
+ if (prefix == NULL)
+ return -ENOMEM;
+ nl_addr_set_prefixlen(prefix,
+ encoded_prefixes[i].prefix_bits);
+
+ if (nl_addr_cmp_prefix_msb(nl_addr_get_binary_addr(dst),
+ nl_addr_get_prefixlen(dst),
+ nl_addr_get_binary_addr(prefix),
+ nl_addr_get_prefixlen(prefix)))
+ continue;
+
+ ret = encoded_prefixes[i].getter(dst, ll_addr);
+ nl_addr_put(prefix);
+ }
+
+ return ret;
+}
+
+static void get_route_cb_parser(struct nl_object *obj, void *arg)
+{
+ struct get_neigh_handler *neigh_handler =
+ (struct get_neigh_handler *)arg;
+
+ struct rtnl_route *route = (struct rtnl_route *)obj;
+ struct nl_addr *gateway = NULL;
+ struct nl_addr *src = rtnl_route_get_pref_src(route);
+ int oif;
+ int type = rtnl_route_get_type(route);
+ struct rtnl_link *link;
+
+ struct rtnl_nexthop *nh = rtnl_route_nexthop_n(route, 0);
+
+ if (nh != NULL)
+ gateway = rtnl_route_nh_get_gateway(nh);
+ oif = rtnl_route_nh_get_ifindex(nh);
+
+ if (gateway) {
+ nl_addr_put(neigh_handler->dst);
+ neigh_handler->dst = nl_addr_clone(gateway);
+ }
+
+ if (RTN_BLACKHOLE == type ||
+ RTN_UNREACHABLE == type ||
+ RTN_PROHIBIT == type ||
+ RTN_THROW == type) {
+ errno = ENETUNREACH;
+ goto err;
+ }
+
+ if (!neigh_handler->src && src)
+ neigh_handler->src = nl_addr_clone(src);
+
+ if (neigh_handler->oif < 0 && oif > 0)
+ neigh_handler->oif = oif;
+
+ /* Link Local */
+ if (RTN_LOCAL == type) {
+ struct nl_addr *lladdr;
+
+ link = rtnl_link_get(neigh_handler->link_cache,
+ neigh_handler->oif);
+
+ if (link == NULL)
+ goto err;
+
+ lladdr = rtnl_link_get_addr(link);
+
+ if (lladdr == NULL)
+ goto err_link;
+
+ neigh_handler->found_ll_addr = nl_addr_clone(lladdr);
+ rtnl_link_put(link);
+ } else {
+ handle_encoded_mac(
+ neigh_handler->dst,
+ &neigh_handler->found_ll_addr);
+ }
+
+ return;
+
+err_link:
+ rtnl_link_put(link);
+err:
+ if (neigh_handler->src) {
+ nl_addr_put(neigh_handler->src);
+ neigh_handler->src = NULL;
+ }
+}
+
+static int get_route_cb(struct nl_msg *msg, void *arg)
+{
+ struct get_neigh_handler *neigh_handler =
+ (struct get_neigh_handler *)arg;
+ int err;
+
+ err = nl_msg_parse(msg, &get_route_cb_parser, neigh_handler);
+ if (err < 0) {
+ errno = ENOMSG;
+ return err;
+ }
+
+ if (!neigh_handler->dst || !neigh_handler->src ||
+ neigh_handler->oif <= 0) {
+ errno = EINVAL;
+ return -1;
+ }
+
+ if (NULL != neigh_handler->found_ll_addr)
+ goto found;
+
+ neigh_handler->found_ll_addr =
+ process_get_neigh_mac(neigh_handler);
+
+found:
+ return neigh_handler->found_ll_addr ? 0 : -1;
+}
+
+int neigh_get_oif_from_src(struct get_neigh_handler *neigh_handler)
+{
+ int oif = -ENODEV;
+ struct addrinfo *src_info;
+ int err;
+
+ err = nl_addr_info(neigh_handler->src, &src_info);
+ if (err) {
+ if (!errno)
+ errno = ENXIO;
+ return oif;
+ }
+
+ oif = get_ifindex(src_info->ai_addr);
+ if (oif <= 0)
+ goto free;
+
+free:
+ freeaddrinfo(src_info);
+ return oif;
+}
+
+static void alloc_zero_based_socket(void)
+{
+ zero_socket = nl_socket_alloc();
+}
+
+int neigh_init_resources(struct get_neigh_handler *neigh_handler, int timeout)
+{
+ int err;
+
+ pthread_once(&device_neigh_alloc, &alloc_zero_based_socket);
+ neigh_handler->sock = nl_socket_alloc();
+ if (neigh_handler->sock == NULL) {
+ errno = ENOMEM;
+ return -1;
+ }
+
+ err = nl_connect(neigh_handler->sock, NETLINK_ROUTE);
+ if (err < 0)
+ goto free_socket;
+
+ err = rtnl_link_alloc_cache(neigh_handler->sock, AF_UNSPEC,
+ &neigh_handler->link_cache);
+ if (err) {
+ err = -1;
+ errno = ENOMEM;
+ goto close_connection;
+ }
+
+ nl_cache_mngt_provide(neigh_handler->link_cache);
+
+ err = rtnl_route_alloc_cache(neigh_handler->sock, AF_UNSPEC, 0,
+ &neigh_handler->route_cache);
+ if (err) {
+ err = -1;
+ errno = ENOMEM;
+ goto free_link_cache;
+ }
+
+ nl_cache_mngt_provide(neigh_handler->route_cache);
+
+ err = rtnl_neigh_alloc_cache(neigh_handler->sock,
+ &neigh_handler->neigh_cache);
+ if (err) {
+ err = -ENOMEM;
+ goto free_route_cache;
+ }
+
+ nl_cache_mngt_provide(neigh_handler->neigh_cache);
+
+ /* init structure */
+ neigh_handler->timeout = timeout;
+ neigh_handler->oif = -1;
+ neigh_handler->filter_neigh = NULL;
+ neigh_handler->found_ll_addr = NULL;
+ neigh_handler->dst = NULL;
+ neigh_handler->src = NULL;
+ neigh_handler->vid = -1;
+
+ return 0;
+
+free_route_cache:
+ nl_cache_mngt_unprovide(neigh_handler->route_cache);
+ nl_cache_free(neigh_handler->route_cache);
+ neigh_handler->route_cache = NULL;
+free_link_cache:
+ nl_cache_mngt_unprovide(neigh_handler->link_cache);
+ nl_cache_free(neigh_handler->link_cache);
+ neigh_handler->link_cache = NULL;
+close_connection:
+ nl_close(neigh_handler->sock);
+free_socket:
+ nl_socket_free(neigh_handler->sock);
+ neigh_handler->sock = NULL;
+ return err;
+}
+
+uint16_t neigh_get_vlan_id_from_dev(struct get_neigh_handler *neigh_handler)
+{
+ struct rtnl_link *link;
+ int vid = 0xffff;
+
+ link = rtnl_link_get(neigh_handler->link_cache, neigh_handler->oif);
+ if (link == NULL) {
+ errno = EINVAL;
+ return vid;
+ }
+
+ if (rtnl_link_is_vlan(link))
+ vid = rtnl_link_vlan_get_id(link);
+ rtnl_link_put(link);
+ return vid >= 0 && vid <= 0xfff ? vid : 0xffff;
+}
+
+void neigh_set_vlan_id(struct get_neigh_handler *neigh_handler, uint16_t vid)
+{
+ if (vid <= 0xfff)
+ neigh_handler->vid = vid;
+}
+
+int neigh_set_dst(struct get_neigh_handler *neigh_handler,
+ int family, void *buf, size_t size)
+{
+ neigh_handler->dst = nl_addr_build(family, buf, size);
+ return neigh_handler->dst == NULL;
+}
+
+int neigh_set_src(struct get_neigh_handler *neigh_handler,
+ int family, void *buf, size_t size)
+{
+ neigh_handler->src = nl_addr_build(family, buf, size);
+ return neigh_handler->src == NULL;
+}
+
+void neigh_set_oif(struct get_neigh_handler *neigh_handler, int oif)
+{
+ neigh_handler->oif = oif;
+}
+
+int neigh_get_ll(struct get_neigh_handler *neigh_handler, void *addr_buff,
+ int addr_size) {
+ int neigh_len;
+
+ if (neigh_handler->found_ll_addr == NULL)
+ return -EINVAL;
+
+ neigh_len = nl_addr_get_len(neigh_handler->found_ll_addr);
+
+ if (neigh_len > addr_size)
+ return -EINVAL;
+
+ memcpy(addr_buff, nl_addr_get_binary_addr(neigh_handler->found_ll_addr),
+ neigh_len);
+
+ return neigh_len;
+}
+
+void neigh_free_resources(struct get_neigh_handler *neigh_handler)
+{
+ /* Should be released first because it's holding a reference to dst */
+ if (neigh_handler->filter_neigh != NULL) {
+ rtnl_neigh_put(neigh_handler->filter_neigh);
+ neigh_handler->filter_neigh = NULL;
+ }
+
+ if (neigh_handler->src != NULL) {
+ nl_addr_put(neigh_handler->src);
+ neigh_handler->src = NULL;
+ }
+
+ if (neigh_handler->dst != NULL) {
+ nl_addr_put(neigh_handler->dst);
+ neigh_handler->dst = NULL;
+ }
+
+ if (neigh_handler->found_ll_addr != NULL) {
+ nl_addr_put(neigh_handler->found_ll_addr);
+ neigh_handler->found_ll_addr = NULL;
+ }
+
+ if (neigh_handler->neigh_cache != NULL) {
+ nl_cache_mngt_unprovide(neigh_handler->neigh_cache);
+ nl_cache_free(neigh_handler->neigh_cache);
+ neigh_handler->neigh_cache = NULL;
+ }
+
+ if (neigh_handler->route_cache != NULL) {
+ nl_cache_mngt_unprovide(neigh_handler->route_cache);
+ nl_cache_free(neigh_handler->route_cache);
+ neigh_handler->route_cache = NULL;
+ }
+
+ if (neigh_handler->link_cache != NULL) {
+ nl_cache_mngt_unprovide(neigh_handler->link_cache);
+ nl_cache_free(neigh_handler->link_cache);
+ neigh_handler->link_cache = NULL;
+ }
+
+ if (neigh_handler->sock != NULL) {
+ nl_close(neigh_handler->sock);
+ nl_socket_free(neigh_handler->sock);
+ neigh_handler->sock = NULL;
+ }
+}
+
+int process_get_neigh(struct get_neigh_handler *neigh_handler)
+{
+ struct nl_msg *m;
+ struct rtmsg rmsg = {
+ .rtm_family = nl_addr_get_family(neigh_handler->dst),
+ .rtm_dst_len = nl_addr_get_prefixlen(neigh_handler->dst),
+ };
+ int err;
+
+ m = nlmsg_alloc_simple(RTM_GETROUTE, 0);
+
+ if (m == NULL)
+ return -ENOMEM;
+
+ nlmsg_append(m, &rmsg, sizeof(rmsg), NLMSG_ALIGNTO);
+
+ nla_put_addr(m, RTA_DST, neigh_handler->dst);
+
+ if (neigh_handler->oif > 0)
+ nla_put_u32(m, RTA_OIF, neigh_handler->oif);
+
+ err = nl_send_auto_complete(neigh_handler->sock, m);
+ nlmsg_free(m);
+ if (err < 0)
+ return err;
+
+ nl_socket_modify_cb(neigh_handler->sock, NL_CB_VALID,
+ NL_CB_CUSTOM, &get_route_cb, neigh_handler);
+
+ err = nl_recvmsgs_default(neigh_handler->sock);
+
+ return err;
+}
diff --git a/contrib/ofed/libibverbs/neigh.h b/contrib/ofed/libibverbs/neigh.h
new file mode 100644
index 0000000..88211bf
--- /dev/null
+++ b/contrib/ofed/libibverbs/neigh.h
@@ -0,0 +1,50 @@
+/* Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md
+ */
+
+#ifndef _NEIGH_H_
+#define _NEIGH_H_
+
+#include <stddef.h>
+#include <stdint.h>
+#include "config.h"
+#ifdef HAVE_LIBNL1
+#include <netlink/object.h>
+#include "nl1_compat.h"
+#else
+#include <netlink/object-api.h>
+#endif
+
+struct get_neigh_handler {
+#ifdef HAVE_LIBNL1
+ struct nl_handle *sock;
+#else
+ struct nl_sock *sock;
+#endif
+ struct nl_cache *link_cache;
+ struct nl_cache *neigh_cache;
+ struct nl_cache *route_cache;
+ int32_t oif;
+ int vid;
+ struct rtnl_neigh *filter_neigh;
+ struct nl_addr *found_ll_addr;
+ struct nl_addr *dst;
+ struct nl_addr *src;
+ uint64_t timeout;
+};
+
+int process_get_neigh(struct get_neigh_handler *neigh_handler);
+void neigh_free_resources(struct get_neigh_handler *neigh_handler);
+void neigh_set_vlan_id(struct get_neigh_handler *neigh_handler, uint16_t vid);
+uint16_t neigh_get_vlan_id_from_dev(struct get_neigh_handler *neigh_handler);
+int neigh_init_resources(struct get_neigh_handler *neigh_handler, int timeout);
+
+int neigh_set_src(struct get_neigh_handler *neigh_handler,
+ int family, void *buf, size_t size);
+void neigh_set_oif(struct get_neigh_handler *neigh_handler, int oif);
+int neigh_set_dst(struct get_neigh_handler *neigh_handler,
+ int family, void *buf, size_t size);
+int neigh_get_oif_from_src(struct get_neigh_handler *neigh_handler);
+int neigh_get_ll(struct get_neigh_handler *neigh_handler, void *addr_buf,
+ int addr_size);
+
+#endif
diff --git a/contrib/ofed/libibverbs/nl1_compat.h b/contrib/ofed/libibverbs/nl1_compat.h
new file mode 100644
index 0000000..3210882
--- /dev/null
+++ b/contrib/ofed/libibverbs/nl1_compat.h
@@ -0,0 +1,78 @@
+/* Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md
+ */
+
+#ifndef _NL1_COMPAT_H_
+#define _NL1_COMPAT_H_
+
+#include <netlink/route/rtnl.h>
+#include <netlink/route/link.h>
+#include <netlink/route/route.h>
+#include <netlink/route/neighbour.h>
+
+struct nl_handle;
+
+/* Workaround - declaration missing */
+extern int rtnl_link_vlan_get_id(struct rtnl_link *);
+
+#define nl_geterror(x) nl_geterror()
+#define nl_sock nl_handle
+
+static inline void nl_socket_disable_seq_check(struct nl_sock *sock)
+{
+ nl_disable_sequence_check(sock);
+}
+
+struct rtnl_nexthop {};
+
+static inline struct rtnl_nexthop *rtnl_route_nexthop_n(
+ struct rtnl_route *r, int n)
+{
+ return (struct rtnl_nexthop *)r;
+}
+
+static inline struct nl_addr *rtnl_route_nh_get_gateway(struct rtnl_nexthop *nh)
+{
+ return rtnl_route_get_gateway((struct rtnl_route *)nh);
+}
+
+static inline int rtnl_route_nh_get_ifindex(struct rtnl_nexthop *nh)
+{
+ return rtnl_route_get_oif((struct rtnl_route *)nh);
+}
+
+#define nl_addr_info(addr, result) ( \
+ *(result) = nl_addr_info(addr), \
+ (*(result) == NULL) ? nl_get_errno() : 0 \
+)
+
+static inline void nl_socket_free(struct nl_sock *sock)
+{
+ nl_close(sock);
+}
+
+static inline struct nl_sock *nl_socket_alloc(void)
+{
+ return nl_handle_alloc();
+}
+
+#define rtnl_link_alloc_cache(sock, family, result) ( \
+ *result = rtnl_link_alloc_cache(sock), \
+ (*result == NULL) ? nl_get_errno() : 0 \
+)
+
+#define rtnl_route_alloc_cache(sock, family, flags, result) ( \
+ *result = rtnl_route_alloc_cache(sock), \
+ (*result == NULL) ? nl_get_errno() : 0 \
+)
+
+#define rtnl_neigh_alloc_cache(sock, result) ( \
+ *result = rtnl_neigh_alloc_cache(sock), \
+ (*result == NULL) ? nl_get_errno() : 0 \
+)
+
+static inline int rtnl_link_is_vlan(struct rtnl_link *link)
+{
+ return rtnl_link_vlan_get_id(link) <= 0;
+}
+
+#endif
diff --git a/contrib/ofed/libibverbs/include/infiniband/opcode.h b/contrib/ofed/libibverbs/opcode.h
index fd4bc96..fd4bc96 100644
--- a/contrib/ofed/libibverbs/include/infiniband/opcode.h
+++ b/contrib/ofed/libibverbs/opcode.h
diff --git a/contrib/ofed/libibverbs/sa-kern-abi.h b/contrib/ofed/libibverbs/sa-kern-abi.h
new file mode 100644
index 0000000..134aecc
--- /dev/null
+++ b/contrib/ofed/libibverbs/sa-kern-abi.h
@@ -0,0 +1,41 @@
+/*
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#ifndef INFINIBAND_SA_KERN_ABI_H
+#define INFINIBAND_SA_KERN_ABI_H
+
+#warning "This header is obsolete, use rdma/ib_user_sa.h instead"
+
+#include <rdma/ib_user_sa.h>
+
+#define ib_kern_path_rec ib_user_path_rec
+#define ibv_kern_path_rec ib_user_path_rec
+
+#endif
diff --git a/contrib/ofed/libibverbs/sa.h b/contrib/ofed/libibverbs/sa.h
new file mode 100644
index 0000000..bb82871
--- /dev/null
+++ b/contrib/ofed/libibverbs/sa.h
@@ -0,0 +1,136 @@
+/*
+ * Copyright (c) 2004 Topspin Communications. All rights reserved.
+ * Copyright (c) 2005 Voltaire, Inc. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#ifndef INFINIBAND_SA_H
+#define INFINIBAND_SA_H
+
+#include <infiniband/verbs.h>
+#include <infiniband/types.h>
+
+struct ibv_sa_path_rec {
+ /* reserved */
+ /* reserved */
+ union ibv_gid dgid;
+ union ibv_gid sgid;
+ __be16 dlid;
+ __be16 slid;
+ int raw_traffic;
+ /* reserved */
+ __be32 flow_label;
+ uint8_t hop_limit;
+ uint8_t traffic_class;
+ int reversible;
+ uint8_t numb_path;
+ __be16 pkey;
+ /* reserved */
+ uint8_t sl;
+ uint8_t mtu_selector;
+ uint8_t mtu;
+ uint8_t rate_selector;
+ uint8_t rate;
+ uint8_t packet_life_time_selector;
+ uint8_t packet_life_time;
+ uint8_t preference;
+};
+
+struct ibv_sa_mcmember_rec {
+ union ibv_gid mgid;
+ union ibv_gid port_gid;
+ uint32_t qkey;
+ uint16_t mlid;
+ uint8_t mtu_selector;
+ uint8_t mtu;
+ uint8_t traffic_class;
+ uint16_t pkey;
+ uint8_t rate_selector;
+ uint8_t rate;
+ uint8_t packet_life_time_selector;
+ uint8_t packet_life_time;
+ uint8_t sl;
+ uint32_t flow_label;
+ uint8_t hop_limit;
+ uint8_t scope;
+ uint8_t join_state;
+ int proxy_join;
+};
+
+struct ibv_sa_service_rec {
+ uint64_t id;
+ union ibv_gid gid;
+ uint16_t pkey;
+ /* uint16_t resv; */
+ uint32_t lease;
+ uint8_t key[16];
+ uint8_t name[64];
+ uint8_t data8[16];
+ uint16_t data16[8];
+ uint32_t data32[4];
+ uint64_t data64[2];
+};
+
+#define IBV_PATH_RECORD_REVERSIBLE 0x80
+
+struct ibv_path_record {
+ __be64 service_id;
+ union ibv_gid dgid;
+ union ibv_gid sgid;
+ __be16 dlid;
+ __be16 slid;
+ __be32 flowlabel_hoplimit; /* resv-31:28 flow label-27:8 hop limit-7:0*/
+ uint8_t tclass;
+ uint8_t reversible_numpath; /* reversible-7:7 num path-6:0 */
+ __be16 pkey;
+ __be16 qosclass_sl; /* qos class-15:4 sl-3:0 */
+ uint8_t mtu; /* mtu selector-7:6 mtu-5:0 */
+ uint8_t rate; /* rate selector-7:6 rate-5:0 */
+ uint8_t packetlifetime; /* lifetime selector-7:6 lifetime-5:0 */
+ uint8_t preference;
+ uint8_t reserved[6];
+};
+
+#define IBV_PATH_FLAG_GMP (1<<0)
+#define IBV_PATH_FLAG_PRIMARY (1<<1)
+#define IBV_PATH_FLAG_ALTERNATE (1<<2)
+#define IBV_PATH_FLAG_OUTBOUND (1<<3)
+#define IBV_PATH_FLAG_INBOUND (1<<4)
+#define IBV_PATH_FLAG_INBOUND_REVERSE (1<<5)
+#define IBV_PATH_FLAG_BIDIRECTIONAL (IBV_PATH_FLAG_OUTBOUND | \
+ IBV_PATH_FLAG_INBOUND_REVERSE)
+
+struct ibv_path_data {
+ uint32_t flags;
+ uint32_t reserved;
+ struct ibv_path_record path;
+};
+
+#endif /* INFINIBAND_SA_H */
diff --git a/contrib/ofed/libibverbs/src/cmd.c b/contrib/ofed/libibverbs/src/cmd.c
deleted file mode 100644
index fa67df2..0000000
--- a/contrib/ofed/libibverbs/src/cmd.c
+++ /dev/null
@@ -1,1409 +0,0 @@
-/*
- * Copyright (c) 2005 Topspin Communications. All rights reserved.
- * Copyright (c) 2005 PathScale, Inc. All rights reserved.
- * Copyright (c) 2006 Cisco Systems, Inc. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-#if HAVE_CONFIG_H
-# include <config.h>
-#endif /* HAVE_CONFIG_H */
-
-#include <stdio.h>
-#include <unistd.h>
-#include <stdlib.h>
-#include <errno.h>
-#include <alloca.h>
-#include <string.h>
-
-#include "ibverbs.h"
-
-static int ibv_cmd_get_context_v2(struct ibv_context *context,
- struct ibv_get_context *new_cmd,
- size_t new_cmd_size,
- struct ibv_get_context_resp *resp,
- size_t resp_size)
-{
- struct ibv_abi_compat_v2 *t;
- struct ibv_get_context_v2 *cmd;
- size_t cmd_size;
- uint32_t cq_fd;
-
- t = malloc(sizeof *t);
- if (!t)
- return ENOMEM;
- pthread_mutex_init(&t->in_use, NULL);
-
- cmd_size = sizeof *cmd + new_cmd_size - sizeof *new_cmd;
- cmd = alloca(cmd_size);
- memcpy(cmd->driver_data, new_cmd->driver_data, new_cmd_size - sizeof *new_cmd);
-
- IBV_INIT_CMD_RESP(cmd, cmd_size, GET_CONTEXT, resp, resp_size);
- cmd->cq_fd_tab = (uintptr_t) &cq_fd;
-
- if (write(context->cmd_fd, cmd, cmd_size) != cmd_size)
- return errno;
-
- VALGRIND_MAKE_MEM_DEFINED(resp, resp_size);
-
- context->async_fd = resp->async_fd;
- context->num_comp_vectors = 1;
- t->channel.context = context;
- t->channel.fd = cq_fd;
- t->channel.refcnt = 0;
- context->abi_compat = t;
-
- return 0;
-}
-
-int ibv_cmd_get_context(struct ibv_context *context, struct ibv_get_context *cmd,
- size_t cmd_size, struct ibv_get_context_resp *resp,
- size_t resp_size)
-{
- if (abi_ver <= 2)
- return ibv_cmd_get_context_v2(context, cmd, cmd_size, resp, resp_size);
-
- IBV_INIT_CMD_RESP(cmd, cmd_size, GET_CONTEXT, resp, resp_size);
-
- if (write(context->cmd_fd, cmd, cmd_size) != cmd_size)
- return errno;
-
- VALGRIND_MAKE_MEM_DEFINED(resp, resp_size);
-
- context->async_fd = resp->async_fd;
- context->num_comp_vectors = resp->num_comp_vectors;
-
- return 0;
-}
-
-int ibv_cmd_query_device(struct ibv_context *context,
- struct ibv_device_attr *device_attr,
- uint64_t *raw_fw_ver,
- struct ibv_query_device *cmd, size_t cmd_size)
-{
- struct ibv_query_device_resp resp;
-
- IBV_INIT_CMD_RESP(cmd, cmd_size, QUERY_DEVICE, &resp, sizeof resp);
-
- if (write(context->cmd_fd, cmd, cmd_size) != cmd_size)
- return errno;
-
- VALGRIND_MAKE_MEM_DEFINED(&resp, sizeof resp);
-
- memset(device_attr->fw_ver, 0, sizeof device_attr->fw_ver);
- *raw_fw_ver = resp.fw_ver;
- device_attr->node_guid = resp.node_guid;
- device_attr->sys_image_guid = resp.sys_image_guid;
- device_attr->max_mr_size = resp.max_mr_size;
- device_attr->page_size_cap = resp.page_size_cap;
- device_attr->vendor_id = resp.vendor_id;
- device_attr->vendor_part_id = resp.vendor_part_id;
- device_attr->hw_ver = resp.hw_ver;
- device_attr->max_qp = resp.max_qp;
- device_attr->max_qp_wr = resp.max_qp_wr;
- device_attr->device_cap_flags = resp.device_cap_flags;
- device_attr->max_sge = resp.max_sge;
- device_attr->max_sge_rd = resp.max_sge_rd;
- device_attr->max_cq = resp.max_cq;
- device_attr->max_cqe = resp.max_cqe;
- device_attr->max_mr = resp.max_mr;
- device_attr->max_pd = resp.max_pd;
- device_attr->max_qp_rd_atom = resp.max_qp_rd_atom;
- device_attr->max_ee_rd_atom = resp.max_ee_rd_atom;
- device_attr->max_res_rd_atom = resp.max_res_rd_atom;
- device_attr->max_qp_init_rd_atom = resp.max_qp_init_rd_atom;
- device_attr->max_ee_init_rd_atom = resp.max_ee_init_rd_atom;
- device_attr->atomic_cap = resp.atomic_cap;
- device_attr->max_ee = resp.max_ee;
- device_attr->max_rdd = resp.max_rdd;
- device_attr->max_mw = resp.max_mw;
- device_attr->max_raw_ipv6_qp = resp.max_raw_ipv6_qp;
- device_attr->max_raw_ethy_qp = resp.max_raw_ethy_qp;
- device_attr->max_mcast_grp = resp.max_mcast_grp;
- device_attr->max_mcast_qp_attach = resp.max_mcast_qp_attach;
- device_attr->max_total_mcast_qp_attach = resp.max_total_mcast_qp_attach;
- device_attr->max_ah = resp.max_ah;
- device_attr->max_fmr = resp.max_fmr;
- device_attr->max_map_per_fmr = resp.max_map_per_fmr;
- device_attr->max_srq = resp.max_srq;
- device_attr->max_srq_wr = resp.max_srq_wr;
- device_attr->max_srq_sge = resp.max_srq_sge;
- device_attr->max_pkeys = resp.max_pkeys;
- device_attr->local_ca_ack_delay = resp.local_ca_ack_delay;
- device_attr->phys_port_cnt = resp.phys_port_cnt;
-
- return 0;
-}
-
-int ibv_cmd_query_port(struct ibv_context *context, uint8_t port_num,
- struct ibv_port_attr *port_attr,
- struct ibv_query_port *cmd, size_t cmd_size)
-{
- struct ibv_query_port_resp resp;
-
- IBV_INIT_CMD_RESP(cmd, cmd_size, QUERY_PORT, &resp, sizeof resp);
- cmd->port_num = port_num;
- memset(cmd->reserved, 0, sizeof cmd->reserved);
-
- if (write(context->cmd_fd, cmd, cmd_size) != cmd_size)
- return errno;
-
- VALGRIND_MAKE_MEM_DEFINED(&resp, sizeof resp);
-
- port_attr->state = resp.state;
- port_attr->max_mtu = resp.max_mtu;
- port_attr->active_mtu = resp.active_mtu;
- port_attr->gid_tbl_len = resp.gid_tbl_len;
- port_attr->port_cap_flags = resp.port_cap_flags;
- port_attr->max_msg_sz = resp.max_msg_sz;
- port_attr->bad_pkey_cntr = resp.bad_pkey_cntr;
- port_attr->qkey_viol_cntr = resp.qkey_viol_cntr;
- port_attr->pkey_tbl_len = resp.pkey_tbl_len;
- port_attr->lid = resp.lid;
- port_attr->sm_lid = resp.sm_lid;
- port_attr->lmc = resp.lmc;
- port_attr->max_vl_num = resp.max_vl_num;
- port_attr->sm_sl = resp.sm_sl;
- port_attr->subnet_timeout = resp.subnet_timeout;
- port_attr->init_type_reply = resp.init_type_reply;
- port_attr->active_width = resp.active_width;
- port_attr->active_speed = resp.active_speed;
- port_attr->phys_state = resp.phys_state;
- port_attr->link_layer = resp.link_layer;
-
- return 0;
-}
-
-int ibv_cmd_alloc_pd(struct ibv_context *context, struct ibv_pd *pd,
- struct ibv_alloc_pd *cmd, size_t cmd_size,
- struct ibv_alloc_pd_resp *resp, size_t resp_size)
-{
- IBV_INIT_CMD_RESP(cmd, cmd_size, ALLOC_PD, resp, resp_size);
-
- if (write(context->cmd_fd, cmd, cmd_size) != cmd_size)
- return errno;
-
- VALGRIND_MAKE_MEM_DEFINED(resp, resp_size);
-
- pd->handle = resp->pd_handle;
- pd->context = context;
-
- return 0;
-}
-
-int ibv_cmd_dealloc_pd(struct ibv_pd *pd)
-{
- struct ibv_dealloc_pd cmd;
-
- IBV_INIT_CMD(&cmd, sizeof cmd, DEALLOC_PD);
- cmd.pd_handle = pd->handle;
-
- if (write(pd->context->cmd_fd, &cmd, sizeof cmd) != sizeof cmd)
- return errno;
-
- return 0;
-}
-
-int ibv_cmd_reg_mr(struct ibv_pd *pd, void *addr, size_t length,
- uint64_t hca_va, int access,
- struct ibv_mr *mr, struct ibv_reg_mr *cmd,
- size_t cmd_size,
- struct ibv_reg_mr_resp *resp, size_t resp_size)
-{
-
- IBV_INIT_CMD_RESP(cmd, cmd_size, REG_MR, resp, resp_size);
-
- cmd->start = (uintptr_t) addr;
- cmd->length = length;
- cmd->hca_va = hca_va;
- cmd->pd_handle = pd->handle;
- cmd->access_flags = access;
-
- if (write(pd->context->cmd_fd, cmd, cmd_size) != cmd_size)
- return errno;
-
- VALGRIND_MAKE_MEM_DEFINED(resp, resp_size);
-
- mr->handle = resp->mr_handle;
- mr->lkey = resp->lkey;
- mr->rkey = resp->rkey;
- mr->context = pd->context;
-
- return 0;
-}
-
-int ibv_cmd_dereg_mr(struct ibv_mr *mr)
-{
- struct ibv_dereg_mr cmd;
-
- IBV_INIT_CMD(&cmd, sizeof cmd, DEREG_MR);
- cmd.mr_handle = mr->handle;
-
- if (write(mr->context->cmd_fd, &cmd, sizeof cmd) != sizeof cmd)
- return errno;
-
- return 0;
-}
-
-static int ibv_cmd_create_cq_v2(struct ibv_context *context, int cqe,
- struct ibv_cq *cq,
- struct ibv_create_cq *new_cmd, size_t new_cmd_size,
- struct ibv_create_cq_resp *resp, size_t resp_size)
-{
- struct ibv_create_cq_v2 *cmd;
- size_t cmd_size;
-
- cmd_size = sizeof *cmd + new_cmd_size - sizeof *new_cmd;
- cmd = alloca(cmd_size);
- memcpy(cmd->driver_data, new_cmd->driver_data, new_cmd_size - sizeof *new_cmd);
-
- IBV_INIT_CMD_RESP(cmd, cmd_size, CREATE_CQ, resp, resp_size);
- cmd->user_handle = (uintptr_t) cq;
- cmd->cqe = cqe;
- cmd->event_handler = 0;
-
- if (write(context->cmd_fd, cmd, cmd_size) != cmd_size)
- return errno;
-
- VALGRIND_MAKE_MEM_DEFINED(resp, resp_size);
-
- cq->handle = resp->cq_handle;
- cq->cqe = resp->cqe;
- cq->context = context;
-
- return 0;
-}
-
-int ibv_cmd_create_cq(struct ibv_context *context, int cqe,
- struct ibv_comp_channel *channel,
- int comp_vector, struct ibv_cq *cq,
- struct ibv_create_cq *cmd, size_t cmd_size,
- struct ibv_create_cq_resp *resp, size_t resp_size)
-{
- if (abi_ver <= 2)
- return ibv_cmd_create_cq_v2(context, cqe, cq,
- cmd, cmd_size, resp, resp_size);
-
- IBV_INIT_CMD_RESP(cmd, cmd_size, CREATE_CQ, resp, resp_size);
- cmd->user_handle = (uintptr_t) cq;
- cmd->cqe = cqe;
- cmd->comp_vector = comp_vector;
- cmd->comp_channel = channel ? channel->fd : -1;
- cmd->reserved = 0;
-
- if (write(context->cmd_fd, cmd, cmd_size) != cmd_size)
- return errno;
-
- VALGRIND_MAKE_MEM_DEFINED(resp, resp_size);
-
- cq->handle = resp->cq_handle;
- cq->cqe = resp->cqe;
- cq->context = context;
-
- return 0;
-}
-
-int ibv_cmd_poll_cq(struct ibv_cq *ibcq, int ne, struct ibv_wc *wc)
-{
- struct ibv_poll_cq cmd;
- struct ibv_poll_cq_resp *resp;
- int i;
- int rsize;
- int ret;
-
- rsize = sizeof *resp + ne * sizeof(struct ibv_kern_wc);
- resp = malloc(rsize);
- if (!resp)
- return -1;
-
- IBV_INIT_CMD_RESP(&cmd, sizeof cmd, POLL_CQ, resp, rsize);
- cmd.cq_handle = ibcq->handle;
- cmd.ne = ne;
-
- if (write(ibcq->context->cmd_fd, &cmd, sizeof cmd) != sizeof cmd) {
- ret = -1;
- goto out;
- }
-
- VALGRIND_MAKE_MEM_DEFINED(resp, rsize);
-
- for (i = 0; i < resp->count; i++) {
- wc[i].wr_id = resp->wc[i].wr_id;
- wc[i].status = resp->wc[i].status;
- wc[i].opcode = resp->wc[i].opcode;
- wc[i].vendor_err = resp->wc[i].vendor_err;
- wc[i].byte_len = resp->wc[i].byte_len;
- wc[i].imm_data = resp->wc[i].imm_data;
- wc[i].qp_num = resp->wc[i].qp_num;
- wc[i].src_qp = resp->wc[i].src_qp;
- wc[i].wc_flags = resp->wc[i].wc_flags;
- wc[i].pkey_index = resp->wc[i].pkey_index;
- wc[i].slid = resp->wc[i].slid;
- wc[i].sl = resp->wc[i].sl;
- wc[i].dlid_path_bits = resp->wc[i].dlid_path_bits;
- }
-
- ret = resp->count;
-
-out:
- free(resp);
- return ret;
-}
-
-int ibv_cmd_req_notify_cq(struct ibv_cq *ibcq, int solicited_only)
-{
- struct ibv_req_notify_cq cmd;
-
- IBV_INIT_CMD(&cmd, sizeof cmd, REQ_NOTIFY_CQ);
- cmd.cq_handle = ibcq->handle;
- cmd.solicited = !!solicited_only;
-
- if (write(ibcq->context->cmd_fd, &cmd, sizeof cmd) != sizeof cmd)
- return errno;
-
- return 0;
-}
-
-int ibv_cmd_resize_cq(struct ibv_cq *cq, int cqe,
- struct ibv_resize_cq *cmd, size_t cmd_size,
- struct ibv_resize_cq_resp *resp, size_t resp_size)
-{
-
- IBV_INIT_CMD_RESP(cmd, cmd_size, RESIZE_CQ, resp, resp_size);
- cmd->cq_handle = cq->handle;
- cmd->cqe = cqe;
-
- if (write(cq->context->cmd_fd, cmd, cmd_size) != cmd_size)
- return errno;
-
- VALGRIND_MAKE_MEM_DEFINED(resp, resp_size);
-
- cq->cqe = resp->cqe;
-
- return 0;
-}
-
-static int ibv_cmd_destroy_cq_v1(struct ibv_cq *cq)
-{
- struct ibv_destroy_cq_v1 cmd;
-
- IBV_INIT_CMD(&cmd, sizeof cmd, DESTROY_CQ);
- cmd.cq_handle = cq->handle;
-
- if (write(cq->context->cmd_fd, &cmd, sizeof cmd) != sizeof cmd)
- return errno;
-
- return 0;
-}
-
-int ibv_cmd_destroy_cq(struct ibv_cq *cq)
-{
- struct ibv_destroy_cq cmd;
- struct ibv_destroy_cq_resp resp;
-
- if (abi_ver == 1)
- return ibv_cmd_destroy_cq_v1(cq);
-
- IBV_INIT_CMD_RESP(&cmd, sizeof cmd, DESTROY_CQ, &resp, sizeof resp);
- cmd.cq_handle = cq->handle;
- cmd.reserved = 0;
-
- if (write(cq->context->cmd_fd, &cmd, sizeof cmd) != sizeof cmd)
- return errno;
-
- VALGRIND_MAKE_MEM_DEFINED(&resp, sizeof resp);
-
- pthread_mutex_lock(&cq->mutex);
- while (cq->comp_events_completed != resp.comp_events_reported ||
- cq->async_events_completed != resp.async_events_reported)
- pthread_cond_wait(&cq->cond, &cq->mutex);
- pthread_mutex_unlock(&cq->mutex);
-
- return 0;
-}
-
-int ibv_cmd_create_srq(struct ibv_pd *pd,
- struct ibv_srq *srq, struct ibv_srq_init_attr *attr,
- struct ibv_create_srq *cmd, size_t cmd_size,
- struct ibv_create_srq_resp *resp, size_t resp_size)
-{
- IBV_INIT_CMD_RESP(cmd, cmd_size, CREATE_SRQ, resp, resp_size);
- cmd->user_handle = (uintptr_t) srq;
- cmd->pd_handle = pd->handle;
- cmd->max_wr = attr->attr.max_wr;
- cmd->max_sge = attr->attr.max_sge;
- cmd->srq_limit = attr->attr.srq_limit;
-
- if (write(pd->context->cmd_fd, cmd, cmd_size) != cmd_size)
- return errno;
-
- VALGRIND_MAKE_MEM_DEFINED(resp, resp_size);
-
- srq->handle = resp->srq_handle;
- srq->context = pd->context;
-
- if (abi_ver > 5) {
- attr->attr.max_wr = resp->max_wr;
- attr->attr.max_sge = resp->max_sge;
- } else {
- struct ibv_create_srq_resp_v5 *resp_v5 =
- (struct ibv_create_srq_resp_v5 *) resp;
-
- memmove((void *) resp + sizeof *resp,
- (void *) resp_v5 + sizeof *resp_v5,
- resp_size - sizeof *resp);
- }
-
- return 0;
-}
-
-int ibv_cmd_create_xrc_srq(struct ibv_pd *pd,
- struct ibv_srq *srq, struct ibv_srq_init_attr *attr,
- uint32_t xrcd_handle, uint32_t xrc_cq,
- struct ibv_create_xrc_srq *cmd, size_t cmd_size,
- struct ibv_create_srq_resp *resp, size_t resp_size)
-{
- IBV_INIT_CMD_RESP(cmd, cmd_size, CREATE_XRC_SRQ, resp, resp_size);
- cmd->user_handle = (uintptr_t) srq;
- cmd->pd_handle = pd->handle;
- cmd->max_wr = attr->attr.max_wr;
- cmd->max_sge = attr->attr.max_sge;
- cmd->srq_limit = attr->attr.srq_limit;
- cmd->xrcd_handle = xrcd_handle;
- cmd->xrc_cq = xrc_cq;
-
- if (write(pd->context->cmd_fd, cmd, cmd_size) != cmd_size)
- return errno;
-
- VALGRIND_MAKE_MEM_DEFINED(resp, resp_size);
-
- srq->handle = resp->srq_handle;
- srq->context = pd->context;
- attr->attr.max_wr = resp->max_wr;
- attr->attr.max_sge = resp->max_sge;
-
- return 0;
-}
-
-static int ibv_cmd_modify_srq_v3(struct ibv_srq *srq,
- struct ibv_srq_attr *srq_attr,
- int srq_attr_mask,
- struct ibv_modify_srq *new_cmd,
- size_t new_cmd_size)
-{
- struct ibv_modify_srq_v3 *cmd;
- size_t cmd_size;
-
- cmd_size = sizeof *cmd + new_cmd_size - sizeof *new_cmd;
- cmd = alloca(cmd_size);
- memcpy(cmd->driver_data, new_cmd->driver_data, new_cmd_size - sizeof *new_cmd);
-
- IBV_INIT_CMD(cmd, cmd_size, MODIFY_SRQ);
-
- cmd->srq_handle = srq->handle;
- cmd->attr_mask = srq_attr_mask;
- cmd->max_wr = srq_attr->max_wr;
- cmd->srq_limit = srq_attr->srq_limit;
- cmd->max_sge = 0;
- cmd->reserved = 0;
-
- if (write(srq->context->cmd_fd, cmd, cmd_size) != cmd_size)
- return errno;
-
- return 0;
-}
-
-int ibv_cmd_modify_srq(struct ibv_srq *srq,
- struct ibv_srq_attr *srq_attr,
- int srq_attr_mask,
- struct ibv_modify_srq *cmd, size_t cmd_size)
-{
- if (abi_ver == 3)
- return ibv_cmd_modify_srq_v3(srq, srq_attr, srq_attr_mask,
- cmd, cmd_size);
-
- IBV_INIT_CMD(cmd, cmd_size, MODIFY_SRQ);
-
- cmd->srq_handle = srq->handle;
- cmd->attr_mask = srq_attr_mask;
- cmd->max_wr = srq_attr->max_wr;
- cmd->srq_limit = srq_attr->srq_limit;
-
- if (write(srq->context->cmd_fd, cmd, cmd_size) != cmd_size)
- return errno;
-
- return 0;
-}
-
-int ibv_cmd_query_srq(struct ibv_srq *srq, struct ibv_srq_attr *srq_attr,
- struct ibv_query_srq *cmd, size_t cmd_size)
-{
- struct ibv_query_srq_resp resp;
-
- IBV_INIT_CMD_RESP(cmd, cmd_size, QUERY_SRQ, &resp, sizeof resp);
- cmd->srq_handle = srq->handle;
- cmd->reserved = 0;
-
- if (write(srq->context->cmd_fd, cmd, cmd_size) != cmd_size)
- return errno;
-
- VALGRIND_MAKE_MEM_DEFINED(&resp, sizeof resp);
-
- srq_attr->max_wr = resp.max_wr;
- srq_attr->max_sge = resp.max_sge;
- srq_attr->srq_limit = resp.srq_limit;
-
- return 0;
-}
-
-static int ibv_cmd_destroy_srq_v1(struct ibv_srq *srq)
-{
- struct ibv_destroy_srq_v1 cmd;
-
- IBV_INIT_CMD(&cmd, sizeof cmd, DESTROY_SRQ);
- cmd.srq_handle = srq->handle;
-
- if (write(srq->context->cmd_fd, &cmd, sizeof cmd) != sizeof cmd)
- return errno;
-
- return 0;
-}
-
-int ibv_cmd_destroy_srq(struct ibv_srq *srq)
-{
- struct ibv_destroy_srq cmd;
- struct ibv_destroy_srq_resp resp;
-
- if (abi_ver == 1)
- return ibv_cmd_destroy_srq_v1(srq);
-
- IBV_INIT_CMD_RESP(&cmd, sizeof cmd, DESTROY_SRQ, &resp, sizeof resp);
- cmd.srq_handle = srq->handle;
- cmd.reserved = 0;
-
- if (write(srq->context->cmd_fd, &cmd, sizeof cmd) != sizeof cmd)
- return errno;
-
- VALGRIND_MAKE_MEM_DEFINED(&resp, sizeof resp);
-
- pthread_mutex_lock(&srq->mutex);
- while (srq->events_completed != resp.events_reported)
- pthread_cond_wait(&srq->cond, &srq->mutex);
- pthread_mutex_unlock(&srq->mutex);
-
- return 0;
-}
-
-int ibv_cmd_create_qp(struct ibv_pd *pd,
- struct ibv_qp *qp, struct ibv_qp_init_attr *attr,
- struct ibv_create_qp *cmd, size_t cmd_size,
- struct ibv_create_qp_resp *resp, size_t resp_size)
-{
- IBV_INIT_CMD_RESP(cmd, cmd_size, CREATE_QP, resp, resp_size);
-
- cmd->user_handle = (uintptr_t) qp;
- cmd->pd_handle = pd->handle;
- cmd->send_cq_handle = attr->send_cq->handle;
- cmd->recv_cq_handle = attr->recv_cq->handle;
- cmd->max_send_wr = attr->cap.max_send_wr;
- cmd->max_recv_wr = attr->cap.max_recv_wr;
- cmd->max_send_sge = attr->cap.max_send_sge;
- cmd->max_recv_sge = attr->cap.max_recv_sge;
- cmd->max_inline_data = attr->cap.max_inline_data;
- cmd->sq_sig_all = attr->sq_sig_all;
- cmd->qp_type = attr->qp_type;
- cmd->is_srq = !!attr->srq;
- cmd->srq_handle = attr->qp_type == IBV_QPT_XRC ?
- (attr->xrc_domain ? attr->xrc_domain->handle : 0) :
- (attr->srq ? attr->srq->handle : 0);
- cmd->reserved = 0;
-
- if (write(pd->context->cmd_fd, cmd, cmd_size) != cmd_size)
- return errno;
-
- VALGRIND_MAKE_MEM_DEFINED(resp, resp_size);
-
- qp->handle = resp->qp_handle;
- qp->qp_num = resp->qpn;
- qp->context = pd->context;
-
- if (abi_ver > 3) {
- attr->cap.max_recv_sge = resp->max_recv_sge;
- attr->cap.max_send_sge = resp->max_send_sge;
- attr->cap.max_recv_wr = resp->max_recv_wr;
- attr->cap.max_send_wr = resp->max_send_wr;
- attr->cap.max_inline_data = resp->max_inline_data;
- }
-
- if (abi_ver == 4) {
- struct ibv_create_qp_resp_v4 *resp_v4 =
- (struct ibv_create_qp_resp_v4 *) resp;
-
- memmove((void *) resp + sizeof *resp,
- (void *) resp_v4 + sizeof *resp_v4,
- resp_size - sizeof *resp);
- } else if (abi_ver <= 3) {
- struct ibv_create_qp_resp_v3 *resp_v3 =
- (struct ibv_create_qp_resp_v3 *) resp;
-
- memmove((void *) resp + sizeof *resp,
- (void *) resp_v3 + sizeof *resp_v3,
- resp_size - sizeof *resp);
- }
-
- return 0;
-}
-
-int ibv_cmd_query_qp(struct ibv_qp *qp, struct ibv_qp_attr *attr,
- int attr_mask,
- struct ibv_qp_init_attr *init_attr,
- struct ibv_query_qp *cmd, size_t cmd_size)
-{
- struct ibv_query_qp_resp resp;
-
- IBV_INIT_CMD_RESP(cmd, cmd_size, QUERY_QP, &resp, sizeof resp);
- cmd->qp_handle = qp->handle;
- cmd->attr_mask = attr_mask;
-
- if (write(qp->context->cmd_fd, cmd, cmd_size) != cmd_size)
- return errno;
-
- VALGRIND_MAKE_MEM_DEFINED(&resp, sizeof resp);
-
- attr->qkey = resp.qkey;
- attr->rq_psn = resp.rq_psn;
- attr->sq_psn = resp.sq_psn;
- attr->dest_qp_num = resp.dest_qp_num;
- attr->qp_access_flags = resp.qp_access_flags;
- attr->pkey_index = resp.pkey_index;
- attr->alt_pkey_index = resp.alt_pkey_index;
- attr->qp_state = resp.qp_state;
- attr->cur_qp_state = resp.cur_qp_state;
- attr->path_mtu = resp.path_mtu;
- attr->path_mig_state = resp.path_mig_state;
- attr->sq_draining = resp.sq_draining;
- attr->max_rd_atomic = resp.max_rd_atomic;
- attr->max_dest_rd_atomic = resp.max_dest_rd_atomic;
- attr->min_rnr_timer = resp.min_rnr_timer;
- attr->port_num = resp.port_num;
- attr->timeout = resp.timeout;
- attr->retry_cnt = resp.retry_cnt;
- attr->rnr_retry = resp.rnr_retry;
- attr->alt_port_num = resp.alt_port_num;
- attr->alt_timeout = resp.alt_timeout;
- attr->cap.max_send_wr = resp.max_send_wr;
- attr->cap.max_recv_wr = resp.max_recv_wr;
- attr->cap.max_send_sge = resp.max_send_sge;
- attr->cap.max_recv_sge = resp.max_recv_sge;
- attr->cap.max_inline_data = resp.max_inline_data;
-
- memcpy(attr->ah_attr.grh.dgid.raw, resp.dest.dgid, 16);
- attr->ah_attr.grh.flow_label = resp.dest.flow_label;
- attr->ah_attr.dlid = resp.dest.dlid;
- attr->ah_attr.grh.sgid_index = resp.dest.sgid_index;
- attr->ah_attr.grh.hop_limit = resp.dest.hop_limit;
- attr->ah_attr.grh.traffic_class = resp.dest.traffic_class;
- attr->ah_attr.sl = resp.dest.sl;
- attr->ah_attr.src_path_bits = resp.dest.src_path_bits;
- attr->ah_attr.static_rate = resp.dest.static_rate;
- attr->ah_attr.is_global = resp.dest.is_global;
- attr->ah_attr.port_num = resp.dest.port_num;
-
- memcpy(attr->alt_ah_attr.grh.dgid.raw, resp.alt_dest.dgid, 16);
- attr->alt_ah_attr.grh.flow_label = resp.alt_dest.flow_label;
- attr->alt_ah_attr.dlid = resp.alt_dest.dlid;
- attr->alt_ah_attr.grh.sgid_index = resp.alt_dest.sgid_index;
- attr->alt_ah_attr.grh.hop_limit = resp.alt_dest.hop_limit;
- attr->alt_ah_attr.grh.traffic_class = resp.alt_dest.traffic_class;
- attr->alt_ah_attr.sl = resp.alt_dest.sl;
- attr->alt_ah_attr.src_path_bits = resp.alt_dest.src_path_bits;
- attr->alt_ah_attr.static_rate = resp.alt_dest.static_rate;
- attr->alt_ah_attr.is_global = resp.alt_dest.is_global;
- attr->alt_ah_attr.port_num = resp.alt_dest.port_num;
-
- init_attr->qp_context = qp->qp_context;
- init_attr->send_cq = qp->send_cq;
- init_attr->recv_cq = qp->recv_cq;
- init_attr->srq = qp->srq;
- init_attr->qp_type = qp->qp_type;
- if (qp->qp_type == IBV_QPT_XRC)
- init_attr->xrc_domain = qp->xrc_domain;
- init_attr->cap.max_send_wr = resp.max_send_wr;
- init_attr->cap.max_recv_wr = resp.max_recv_wr;
- init_attr->cap.max_send_sge = resp.max_send_sge;
- init_attr->cap.max_recv_sge = resp.max_recv_sge;
- init_attr->cap.max_inline_data = resp.max_inline_data;
- init_attr->sq_sig_all = resp.sq_sig_all;
-
- return 0;
-}
-
-int ibv_cmd_modify_qp(struct ibv_qp *qp, struct ibv_qp_attr *attr,
- int attr_mask,
- struct ibv_modify_qp *cmd, size_t cmd_size)
-{
- IBV_INIT_CMD(cmd, cmd_size, MODIFY_QP);
-
- cmd->qp_handle = qp->handle;
- cmd->attr_mask = attr_mask;
- cmd->qkey = attr->qkey;
- cmd->rq_psn = attr->rq_psn;
- cmd->sq_psn = attr->sq_psn;
- cmd->dest_qp_num = attr->dest_qp_num;
- cmd->qp_access_flags = attr->qp_access_flags;
- cmd->pkey_index = attr->pkey_index;
- cmd->alt_pkey_index = attr->alt_pkey_index;
- cmd->qp_state = attr->qp_state;
- cmd->cur_qp_state = attr->cur_qp_state;
- cmd->path_mtu = attr->path_mtu;
- cmd->path_mig_state = attr->path_mig_state;
- cmd->en_sqd_async_notify = attr->en_sqd_async_notify;
- cmd->max_rd_atomic = attr->max_rd_atomic;
- cmd->max_dest_rd_atomic = attr->max_dest_rd_atomic;
- cmd->min_rnr_timer = attr->min_rnr_timer;
- cmd->port_num = attr->port_num;
- cmd->timeout = attr->timeout;
- cmd->retry_cnt = attr->retry_cnt;
- cmd->rnr_retry = attr->rnr_retry;
- cmd->alt_port_num = attr->alt_port_num;
- cmd->alt_timeout = attr->alt_timeout;
-
- memcpy(cmd->dest.dgid, attr->ah_attr.grh.dgid.raw, 16);
- cmd->dest.flow_label = attr->ah_attr.grh.flow_label;
- cmd->dest.dlid = attr->ah_attr.dlid;
- cmd->dest.reserved = 0;
- cmd->dest.sgid_index = attr->ah_attr.grh.sgid_index;
- cmd->dest.hop_limit = attr->ah_attr.grh.hop_limit;
- cmd->dest.traffic_class = attr->ah_attr.grh.traffic_class;
- cmd->dest.sl = attr->ah_attr.sl;
- cmd->dest.src_path_bits = attr->ah_attr.src_path_bits;
- cmd->dest.static_rate = attr->ah_attr.static_rate;
- cmd->dest.is_global = attr->ah_attr.is_global;
- cmd->dest.port_num = attr->ah_attr.port_num;
-
- memcpy(cmd->alt_dest.dgid, attr->alt_ah_attr.grh.dgid.raw, 16);
- cmd->alt_dest.flow_label = attr->alt_ah_attr.grh.flow_label;
- cmd->alt_dest.dlid = attr->alt_ah_attr.dlid;
- cmd->alt_dest.reserved = 0;
- cmd->alt_dest.sgid_index = attr->alt_ah_attr.grh.sgid_index;
- cmd->alt_dest.hop_limit = attr->alt_ah_attr.grh.hop_limit;
- cmd->alt_dest.traffic_class = attr->alt_ah_attr.grh.traffic_class;
- cmd->alt_dest.sl = attr->alt_ah_attr.sl;
- cmd->alt_dest.src_path_bits = attr->alt_ah_attr.src_path_bits;
- cmd->alt_dest.static_rate = attr->alt_ah_attr.static_rate;
- cmd->alt_dest.is_global = attr->alt_ah_attr.is_global;
- cmd->alt_dest.port_num = attr->alt_ah_attr.port_num;
-
- cmd->reserved[0] = cmd->reserved[1] = 0;
-
- if (write(qp->context->cmd_fd, cmd, cmd_size) != cmd_size)
- return errno;
-
- return 0;
-}
-
-int ibv_cmd_create_xrc_rcv_qp(struct ibv_qp_init_attr *init_attr,
- uint32_t *xrc_rcv_qpn)
-{
- struct ibv_create_xrc_rcv_qp cmd;
- struct ibv_create_xrc_rcv_qp_resp resp;
-
- if (abi_ver < 6)
- return ENOSYS;
-
- IBV_INIT_CMD_RESP(&cmd, sizeof cmd, CREATE_XRC_RCV_QP, &resp,
- sizeof resp);
-
- cmd.xrc_domain_handle = init_attr->xrc_domain->handle;
- cmd.max_send_wr = init_attr->cap.max_send_wr;
- cmd.max_recv_wr = init_attr->cap.max_recv_wr;
- cmd.max_send_sge = init_attr->cap.max_send_sge;
- cmd.max_recv_sge = init_attr->cap.max_recv_sge;
- cmd.max_inline_data = init_attr->cap.max_inline_data;
- cmd.sq_sig_all = init_attr->sq_sig_all;
- cmd.qp_type = init_attr->qp_type;
- cmd.reserved[0] = cmd.reserved[1] = 0;
-
- if (write(init_attr->xrc_domain->context->cmd_fd, &cmd, sizeof cmd) !=
- sizeof cmd)
- return errno;
-
- *xrc_rcv_qpn = resp.qpn;
-
- return 0;
-}
-
-int ibv_cmd_modify_xrc_rcv_qp(struct ibv_xrc_domain *d, uint32_t xrc_qp_num,
- struct ibv_qp_attr *attr, int attr_mask)
-{
- struct ibv_modify_xrc_rcv_qp cmd;
-
- if (abi_ver < 6)
- return ENOSYS;
-
- IBV_INIT_CMD(&cmd, sizeof cmd, MODIFY_XRC_RCV_QP);
-
- cmd.xrc_domain_handle = d->handle;
- cmd.qp_num = xrc_qp_num;
- cmd.attr_mask = attr_mask;
- cmd.qkey = attr->qkey;
- cmd.rq_psn = attr->rq_psn;
- cmd.sq_psn = attr->sq_psn;
- cmd.dest_qp_num = attr->dest_qp_num;
- cmd.qp_access_flags = attr->qp_access_flags;
- cmd.pkey_index = attr->pkey_index;
- cmd.alt_pkey_index = attr->alt_pkey_index;
- cmd.qp_state = attr->qp_state;
- cmd.cur_qp_state = attr->cur_qp_state;
- cmd.path_mtu = attr->path_mtu;
- cmd.path_mig_state = attr->path_mig_state;
- cmd.en_sqd_async_notify = attr->en_sqd_async_notify;
- cmd.max_rd_atomic = attr->max_rd_atomic;
- cmd.max_dest_rd_atomic = attr->max_dest_rd_atomic;
- cmd.min_rnr_timer = attr->min_rnr_timer;
- cmd.port_num = attr->port_num;
- cmd.timeout = attr->timeout;
- cmd.retry_cnt = attr->retry_cnt;
- cmd.rnr_retry = attr->rnr_retry;
- cmd.alt_port_num = attr->alt_port_num;
- cmd.alt_timeout = attr->alt_timeout;
-
- memcpy(cmd.dest.dgid, attr->ah_attr.grh.dgid.raw, 16);
- cmd.dest.flow_label = attr->ah_attr.grh.flow_label;
- cmd.dest.dlid = attr->ah_attr.dlid;
- cmd.dest.reserved = 0;
- cmd.dest.sgid_index = attr->ah_attr.grh.sgid_index;
- cmd.dest.hop_limit = attr->ah_attr.grh.hop_limit;
- cmd.dest.traffic_class = attr->ah_attr.grh.traffic_class;
- cmd.dest.sl = attr->ah_attr.sl;
- cmd.dest.src_path_bits = attr->ah_attr.src_path_bits;
- cmd.dest.static_rate = attr->ah_attr.static_rate;
- cmd.dest.is_global = attr->ah_attr.is_global;
- cmd.dest.port_num = attr->ah_attr.port_num;
-
- memcpy(cmd.alt_dest.dgid, attr->alt_ah_attr.grh.dgid.raw, 16);
- cmd.alt_dest.flow_label = attr->alt_ah_attr.grh.flow_label;
- cmd.alt_dest.dlid = attr->alt_ah_attr.dlid;
- cmd.alt_dest.reserved = 0;
- cmd.alt_dest.sgid_index = attr->alt_ah_attr.grh.sgid_index;
- cmd.alt_dest.hop_limit = attr->alt_ah_attr.grh.hop_limit;
- cmd.alt_dest.traffic_class = attr->alt_ah_attr.grh.traffic_class;
- cmd.alt_dest.sl = attr->alt_ah_attr.sl;
- cmd.alt_dest.src_path_bits = attr->alt_ah_attr.src_path_bits;
- cmd.alt_dest.static_rate = attr->alt_ah_attr.static_rate;
- cmd.alt_dest.is_global = attr->alt_ah_attr.is_global;
- cmd.alt_dest.port_num = attr->alt_ah_attr.port_num;
-
- cmd.reserved[0] = cmd.reserved[1] = 0;
-
- if (write(d->context->cmd_fd, &cmd, sizeof cmd) != sizeof cmd)
- return errno;
-
- return 0;
-}
-
-int ibv_cmd_query_xrc_rcv_qp(struct ibv_xrc_domain *d, uint32_t xrc_qp_num,
- struct ibv_qp_attr *attr, int attr_mask,
- struct ibv_qp_init_attr *init_attr)
-{
- struct ibv_query_xrc_rcv_qp cmd;
- struct ibv_query_qp_resp resp;
-
- if (abi_ver < 6)
- return ENOSYS;
-
- IBV_INIT_CMD_RESP(&cmd, sizeof cmd, QUERY_XRC_RCV_QP, &resp,
- sizeof resp);
- cmd.xrc_domain_handle = d->handle;
- cmd.qp_num = xrc_qp_num;
- cmd.attr_mask = attr_mask;
-
- if (write(d->context->cmd_fd, &cmd, sizeof cmd) != sizeof cmd)
- return errno;
-
- VALGRIND_MAKE_MEM_DEFINED(&resp, sizeof resp);
-
- attr->qkey = resp.qkey;
- attr->rq_psn = resp.rq_psn;
- attr->sq_psn = resp.sq_psn;
- attr->dest_qp_num = resp.dest_qp_num;
- attr->qp_access_flags = resp.qp_access_flags;
- attr->pkey_index = resp.pkey_index;
- attr->alt_pkey_index = resp.alt_pkey_index;
- attr->qp_state = resp.qp_state;
- attr->cur_qp_state = resp.cur_qp_state;
- attr->path_mtu = resp.path_mtu;
- attr->path_mig_state = resp.path_mig_state;
- attr->sq_draining = resp.sq_draining;
- attr->max_rd_atomic = resp.max_rd_atomic;
- attr->max_dest_rd_atomic = resp.max_dest_rd_atomic;
- attr->min_rnr_timer = resp.min_rnr_timer;
- attr->port_num = resp.port_num;
- attr->timeout = resp.timeout;
- attr->retry_cnt = resp.retry_cnt;
- attr->rnr_retry = resp.rnr_retry;
- attr->alt_port_num = resp.alt_port_num;
- attr->alt_timeout = resp.alt_timeout;
- attr->cap.max_send_wr = resp.max_send_wr;
- attr->cap.max_recv_wr = resp.max_recv_wr;
- attr->cap.max_send_sge = resp.max_send_sge;
- attr->cap.max_recv_sge = resp.max_recv_sge;
- attr->cap.max_inline_data = resp.max_inline_data;
-
- memcpy(attr->ah_attr.grh.dgid.raw, resp.dest.dgid, 16);
- attr->ah_attr.grh.flow_label = resp.dest.flow_label;
- attr->ah_attr.dlid = resp.dest.dlid;
- attr->ah_attr.grh.sgid_index = resp.dest.sgid_index;
- attr->ah_attr.grh.hop_limit = resp.dest.hop_limit;
- attr->ah_attr.grh.traffic_class = resp.dest.traffic_class;
- attr->ah_attr.sl = resp.dest.sl;
- attr->ah_attr.src_path_bits = resp.dest.src_path_bits;
- attr->ah_attr.static_rate = resp.dest.static_rate;
- attr->ah_attr.is_global = resp.dest.is_global;
- attr->ah_attr.port_num = resp.dest.port_num;
-
- memcpy(attr->alt_ah_attr.grh.dgid.raw, resp.alt_dest.dgid, 16);
- attr->alt_ah_attr.grh.flow_label = resp.alt_dest.flow_label;
- attr->alt_ah_attr.dlid = resp.alt_dest.dlid;
- attr->alt_ah_attr.grh.sgid_index = resp.alt_dest.sgid_index;
- attr->alt_ah_attr.grh.hop_limit = resp.alt_dest.hop_limit;
- attr->alt_ah_attr.grh.traffic_class = resp.alt_dest.traffic_class;
- attr->alt_ah_attr.sl = resp.alt_dest.sl;
- attr->alt_ah_attr.src_path_bits = resp.alt_dest.src_path_bits;
- attr->alt_ah_attr.static_rate = resp.alt_dest.static_rate;
- attr->alt_ah_attr.is_global = resp.alt_dest.is_global;
- attr->alt_ah_attr.port_num = resp.alt_dest.port_num;
-
- init_attr->cap.max_send_wr = resp.max_send_wr;
- init_attr->cap.max_recv_wr = resp.max_recv_wr;
- init_attr->cap.max_send_sge = resp.max_send_sge;
- init_attr->cap.max_recv_sge = resp.max_recv_sge;
- init_attr->cap.max_inline_data = resp.max_inline_data;
- init_attr->sq_sig_all = resp.sq_sig_all;
-
- return 0;
-}
-
-static int ibv_cmd_destroy_qp_v1(struct ibv_qp *qp)
-{
- struct ibv_destroy_qp_v1 cmd;
-
- IBV_INIT_CMD(&cmd, sizeof cmd, DESTROY_QP);
- cmd.qp_handle = qp->handle;
-
- if (write(qp->context->cmd_fd, &cmd, sizeof cmd) != sizeof cmd)
- return errno;
-
- return 0;
-}
-
-int ibv_cmd_post_send(struct ibv_qp *ibqp, struct ibv_send_wr *wr,
- struct ibv_send_wr **bad_wr)
-{
- struct ibv_post_send *cmd;
- struct ibv_post_send_resp resp;
- struct ibv_send_wr *i;
- struct ibv_kern_send_wr *n, *tmp;
- struct ibv_sge *s;
- unsigned wr_count = 0;
- unsigned sge_count = 0;
- int cmd_size;
- int ret = 0;
-
- for (i = wr; i; i = i->next) {
- wr_count++;
- sge_count += i->num_sge;
- }
-
- cmd_size = sizeof *cmd + wr_count * sizeof *n + sge_count * sizeof *s;
- cmd = alloca(cmd_size);
-
- IBV_INIT_CMD_RESP(cmd, cmd_size, POST_SEND, &resp, sizeof resp);
- cmd->qp_handle = ibqp->handle;
- cmd->wr_count = wr_count;
- cmd->sge_count = sge_count;
- cmd->wqe_size = sizeof *n;
-
- n = (struct ibv_kern_send_wr *) ((void *) cmd + sizeof *cmd);
- s = (struct ibv_sge *) (n + wr_count);
-
- tmp = n;
- for (i = wr; i; i = i->next) {
- tmp->wr_id = i->wr_id;
- tmp->num_sge = i->num_sge;
- tmp->opcode = i->opcode;
- tmp->send_flags = i->send_flags;
- tmp->imm_data = i->imm_data;
- if (ibqp->qp_type == IBV_QPT_UD) {
- tmp->wr.ud.ah = i->wr.ud.ah->handle;
- tmp->wr.ud.remote_qpn = i->wr.ud.remote_qpn;
- tmp->wr.ud.remote_qkey = i->wr.ud.remote_qkey;
- } else {
- switch (i->opcode) {
- case IBV_WR_RDMA_WRITE:
- case IBV_WR_RDMA_WRITE_WITH_IMM:
- case IBV_WR_RDMA_READ:
- tmp->wr.rdma.remote_addr =
- i->wr.rdma.remote_addr;
- tmp->wr.rdma.rkey = i->wr.rdma.rkey;
- break;
- case IBV_WR_ATOMIC_CMP_AND_SWP:
- case IBV_WR_ATOMIC_FETCH_AND_ADD:
- tmp->wr.atomic.remote_addr =
- i->wr.atomic.remote_addr;
- tmp->wr.atomic.compare_add =
- i->wr.atomic.compare_add;
- tmp->wr.atomic.swap = i->wr.atomic.swap;
- tmp->wr.atomic.rkey = i->wr.atomic.rkey;
- break;
- default:
- break;
- }
- }
-
- if (tmp->num_sge) {
- memcpy(s, i->sg_list, tmp->num_sge * sizeof *s);
- s += tmp->num_sge;
- }
-
- tmp++;
- }
-
- resp.bad_wr = 0;
- if (write(ibqp->context->cmd_fd, cmd, cmd_size) != cmd_size)
- ret = errno;
-
- VALGRIND_MAKE_MEM_DEFINED(&resp, sizeof resp);
-
- wr_count = resp.bad_wr;
- if (wr_count) {
- i = wr;
- while (--wr_count)
- i = i->next;
- *bad_wr = i;
- } else if (ret)
- *bad_wr = wr;
-
- return ret;
-}
-
-int ibv_cmd_post_recv(struct ibv_qp *ibqp, struct ibv_recv_wr *wr,
- struct ibv_recv_wr **bad_wr)
-{
- struct ibv_post_recv *cmd;
- struct ibv_post_recv_resp resp;
- struct ibv_recv_wr *i;
- struct ibv_kern_recv_wr *n, *tmp;
- struct ibv_sge *s;
- unsigned wr_count = 0;
- unsigned sge_count = 0;
- int cmd_size;
- int ret = 0;
-
- for (i = wr; i; i = i->next) {
- wr_count++;
- sge_count += i->num_sge;
- }
-
- cmd_size = sizeof *cmd + wr_count * sizeof *n + sge_count * sizeof *s;
- cmd = alloca(cmd_size);
-
- IBV_INIT_CMD_RESP(cmd, cmd_size, POST_RECV, &resp, sizeof resp);
- cmd->qp_handle = ibqp->handle;
- cmd->wr_count = wr_count;
- cmd->sge_count = sge_count;
- cmd->wqe_size = sizeof *n;
-
- n = (struct ibv_kern_recv_wr *) ((void *) cmd + sizeof *cmd);
- s = (struct ibv_sge *) (n + wr_count);
-
- tmp = n;
- for (i = wr; i; i = i->next) {
- tmp->wr_id = i->wr_id;
- tmp->num_sge = i->num_sge;
-
- if (tmp->num_sge) {
- memcpy(s, i->sg_list, tmp->num_sge * sizeof *s);
- s += tmp->num_sge;
- }
-
- tmp++;
- }
-
- resp.bad_wr = 0;
- if (write(ibqp->context->cmd_fd, cmd, cmd_size) != cmd_size)
- ret = errno;
-
- VALGRIND_MAKE_MEM_DEFINED(&resp, sizeof resp);
-
- wr_count = resp.bad_wr;
- if (wr_count) {
- i = wr;
- while (--wr_count)
- i = i->next;
- *bad_wr = i;
- } else if (ret)
- *bad_wr = wr;
-
- return ret;
-}
-
-int ibv_cmd_post_srq_recv(struct ibv_srq *srq, struct ibv_recv_wr *wr,
- struct ibv_recv_wr **bad_wr)
-{
- struct ibv_post_srq_recv *cmd;
- struct ibv_post_srq_recv_resp resp;
- struct ibv_recv_wr *i;
- struct ibv_kern_recv_wr *n, *tmp;
- struct ibv_sge *s;
- unsigned wr_count = 0;
- unsigned sge_count = 0;
- int cmd_size;
- int ret = 0;
-
- for (i = wr; i; i = i->next) {
- wr_count++;
- sge_count += i->num_sge;
- }
-
- cmd_size = sizeof *cmd + wr_count * sizeof *n + sge_count * sizeof *s;
- cmd = alloca(cmd_size);
-
- IBV_INIT_CMD_RESP(cmd, cmd_size, POST_SRQ_RECV, &resp, sizeof resp);
- cmd->srq_handle = srq->handle;
- cmd->wr_count = wr_count;
- cmd->sge_count = sge_count;
- cmd->wqe_size = sizeof *n;
-
- n = (struct ibv_kern_recv_wr *) ((void *) cmd + sizeof *cmd);
- s = (struct ibv_sge *) (n + wr_count);
-
- tmp = n;
- for (i = wr; i; i = i->next) {
- tmp->wr_id = i->wr_id;
- tmp->num_sge = i->num_sge;
-
- if (tmp->num_sge) {
- memcpy(s, i->sg_list, tmp->num_sge * sizeof *s);
- s += tmp->num_sge;
- }
-
- tmp++;
- }
-
- resp.bad_wr = 0;
- if (write(srq->context->cmd_fd, cmd, cmd_size) != cmd_size)
- ret = errno;
-
- VALGRIND_MAKE_MEM_DEFINED(&resp, sizeof resp);
-
- wr_count = resp.bad_wr;
- if (wr_count) {
- i = wr;
- while (--wr_count)
- i = i->next;
- *bad_wr = i;
- } else if (ret)
- *bad_wr = wr;
-
- return ret;
-}
-
-int ibv_cmd_create_ah(struct ibv_pd *pd, struct ibv_ah *ah,
- struct ibv_ah_attr *attr)
-{
- struct ibv_create_ah cmd;
- struct ibv_create_ah_resp resp;
-
- IBV_INIT_CMD_RESP(&cmd, sizeof cmd, CREATE_AH, &resp, sizeof resp);
- cmd.user_handle = (uintptr_t) ah;
- cmd.pd_handle = pd->handle;
- cmd.attr.dlid = attr->dlid;
- cmd.attr.sl = attr->sl;
- cmd.attr.src_path_bits = attr->src_path_bits;
- cmd.attr.static_rate = attr->static_rate;
- cmd.attr.is_global = attr->is_global;
- cmd.attr.port_num = attr->port_num;
- cmd.attr.grh.flow_label = attr->grh.flow_label;
- cmd.attr.grh.sgid_index = attr->grh.sgid_index;
- cmd.attr.grh.hop_limit = attr->grh.hop_limit;
- cmd.attr.grh.traffic_class = attr->grh.traffic_class;
- memcpy(cmd.attr.grh.dgid, attr->grh.dgid.raw, 16);
-
- if (write(pd->context->cmd_fd, &cmd, sizeof cmd) != sizeof cmd)
- return errno;
-
- VALGRIND_MAKE_MEM_DEFINED(&resp, sizeof resp);
-
- ah->handle = resp.handle;
- ah->context = pd->context;
-
- return 0;
-}
-
-int ibv_cmd_destroy_ah(struct ibv_ah *ah)
-{
- struct ibv_destroy_ah cmd;
-
- IBV_INIT_CMD(&cmd, sizeof cmd, DESTROY_AH);
- cmd.ah_handle = ah->handle;
-
- if (write(ah->context->cmd_fd, &cmd, sizeof cmd) != sizeof cmd)
- return errno;
-
- return 0;
-}
-
-int ibv_cmd_destroy_qp(struct ibv_qp *qp)
-{
- struct ibv_destroy_qp cmd;
- struct ibv_destroy_qp_resp resp;
-
- if (abi_ver == 1)
- return ibv_cmd_destroy_qp_v1(qp);
-
- IBV_INIT_CMD_RESP(&cmd, sizeof cmd, DESTROY_QP, &resp, sizeof resp);
- cmd.qp_handle = qp->handle;
- cmd.reserved = 0;
-
- if (write(qp->context->cmd_fd, &cmd, sizeof cmd) != sizeof cmd)
- return errno;
-
- VALGRIND_MAKE_MEM_DEFINED(&resp, sizeof resp);
-
- pthread_mutex_lock(&qp->mutex);
- while (qp->events_completed != resp.events_reported)
- pthread_cond_wait(&qp->cond, &qp->mutex);
- pthread_mutex_unlock(&qp->mutex);
-
- return 0;
-}
-
-int ibv_cmd_attach_mcast(struct ibv_qp *qp, const union ibv_gid *gid, uint16_t lid)
-{
- struct ibv_attach_mcast cmd;
-
- IBV_INIT_CMD(&cmd, sizeof cmd, ATTACH_MCAST);
- memcpy(cmd.gid, gid->raw, sizeof cmd.gid);
- cmd.qp_handle = qp->handle;
- cmd.mlid = lid;
- cmd.reserved = 0;
-
- if (write(qp->context->cmd_fd, &cmd, sizeof cmd) != sizeof cmd)
- return errno;
-
- return 0;
-}
-
-int ibv_cmd_detach_mcast(struct ibv_qp *qp, const union ibv_gid *gid, uint16_t lid)
-{
- struct ibv_detach_mcast cmd;
-
- IBV_INIT_CMD(&cmd, sizeof cmd, DETACH_MCAST);
- memcpy(cmd.gid, gid->raw, sizeof cmd.gid);
- cmd.qp_handle = qp->handle;
- cmd.mlid = lid;
- cmd.reserved = 0;
-
- if (write(qp->context->cmd_fd, &cmd, sizeof cmd) != sizeof cmd)
- return errno;
-
- return 0;
-}
-
-int ibv_cmd_open_xrc_domain(struct ibv_context *context, int fd, int oflag,
- struct ibv_xrc_domain *d,
- struct ibv_open_xrc_domain_resp *resp,
- size_t resp_size)
-{
- struct ibv_open_xrc_domain cmd;
-
- if (abi_ver < 6)
- return ENOSYS;
-
- IBV_INIT_CMD_RESP(&cmd, sizeof cmd, OPEN_XRC_DOMAIN, resp, resp_size);
- cmd.fd = fd;
- cmd.oflags = oflag;
-
- if (write(context->cmd_fd, &cmd, sizeof cmd) != sizeof cmd)
- return errno;
-
- d->handle = resp->xrcd_handle;
-
- return 0;
-}
-
-int ibv_cmd_close_xrc_domain(struct ibv_xrc_domain *d)
-{
- struct ibv_close_xrc_domain cmd;
-
- if (abi_ver < 6)
- return ENOSYS;
-
- IBV_INIT_CMD(&cmd, sizeof cmd, CLOSE_XRC_DOMAIN);
- cmd.xrcd_handle = d->handle;
-
- if (write(d->context->cmd_fd, &cmd, sizeof cmd) != sizeof cmd)
- return errno;
- return 0;
-}
-
-int ibv_cmd_reg_xrc_rcv_qp(struct ibv_xrc_domain *d, uint32_t xrc_qp_num)
-{
- struct ibv_reg_xrc_rcv_qp cmd;
-
- if (abi_ver < 6)
- return ENOSYS;
-
- IBV_INIT_CMD(&cmd, sizeof cmd, REG_XRC_RCV_QP);
- cmd.xrc_domain_handle = d->handle;
- cmd.qp_num = xrc_qp_num;
-
- if (write(d->context->cmd_fd, &cmd, sizeof cmd) != sizeof cmd)
- return errno;
- return 0;
-}
-
-int ibv_cmd_unreg_xrc_rcv_qp(struct ibv_xrc_domain *d, uint32_t xrc_qp_num)
-{
- struct ibv_unreg_xrc_rcv_qp cmd;
-
- if (abi_ver < 6)
- return ENOSYS;
-
- IBV_INIT_CMD(&cmd, sizeof cmd, UNREG_XRC_RCV_QP);
- cmd.xrc_domain_handle = d->handle;
- cmd.qp_num = xrc_qp_num;
-
- if (write(d->context->cmd_fd, &cmd, sizeof cmd) != sizeof cmd)
- return errno;
- return 0;
-}
-
diff --git a/contrib/ofed/libibverbs/src/compat-1_0.c b/contrib/ofed/libibverbs/src/compat-1_0.c
deleted file mode 100644
index 3f5ff35..0000000
--- a/contrib/ofed/libibverbs/src/compat-1_0.c
+++ /dev/null
@@ -1,898 +0,0 @@
-/*
- * Copyright (c) 2007 Cisco Systems, Inc. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-#if HAVE_CONFIG_H
-# include <config.h>
-#endif /* HAVE_CONFIG_H */
-
-#include <string.h>
-#include <stddef.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <alloca.h>
-
-#include "ibverbs.h"
-
-struct ibv_pd_1_0 {
- struct ibv_context_1_0 *context;
- uint32_t handle;
-
- struct ibv_pd *real_pd;
-};
-
-struct ibv_mr_1_0 {
- struct ibv_context_1_0 *context;
- struct ibv_pd_1_0 *pd;
- uint32_t handle;
- uint32_t lkey;
- uint32_t rkey;
-
- struct ibv_mr *real_mr;
-};
-
-struct ibv_srq_1_0 {
- struct ibv_context_1_0 *context;
- void *srq_context;
- struct ibv_pd_1_0 *pd;
- uint32_t handle;
-
- pthread_mutex_t mutex;
- pthread_cond_t cond;
- uint32_t events_completed;
-
- struct ibv_srq *real_srq;
-};
-
-struct ibv_qp_init_attr_1_0 {
- void *qp_context;
- struct ibv_cq_1_0 *send_cq;
- struct ibv_cq_1_0 *recv_cq;
- struct ibv_srq_1_0 *srq;
- struct ibv_qp_cap cap;
- enum ibv_qp_type qp_type;
- int sq_sig_all;
-};
-
-struct ibv_send_wr_1_0 {
- struct ibv_send_wr_1_0 *next;
- uint64_t wr_id;
- struct ibv_sge *sg_list;
- int num_sge;
- enum ibv_wr_opcode opcode;
- int send_flags;
- uint32_t imm_data; /* in network byte order */
- union {
- struct {
- uint64_t remote_addr;
- uint32_t rkey;
- } rdma;
- struct {
- uint64_t remote_addr;
- uint64_t compare_add;
- uint64_t swap;
- uint32_t rkey;
- } atomic;
- struct {
- struct ibv_ah_1_0 *ah;
- uint32_t remote_qpn;
- uint32_t remote_qkey;
- } ud;
- } wr;
-};
-
-struct ibv_recv_wr_1_0 {
- struct ibv_recv_wr_1_0 *next;
- uint64_t wr_id;
- struct ibv_sge *sg_list;
- int num_sge;
-};
-
-struct ibv_qp_1_0 {
- struct ibv_context_1_0 *context;
- void *qp_context;
- struct ibv_pd_1_0 *pd;
- struct ibv_cq_1_0 *send_cq;
- struct ibv_cq_1_0 *recv_cq;
- struct ibv_srq_1_0 *srq;
- uint32_t handle;
- uint32_t qp_num;
- enum ibv_qp_state state;
- enum ibv_qp_type qp_type;
-
- pthread_mutex_t mutex;
- pthread_cond_t cond;
- uint32_t events_completed;
-
- struct ibv_qp *real_qp;
-};
-
-struct ibv_cq_1_0 {
- struct ibv_context_1_0 *context;
- void *cq_context;
- uint32_t handle;
- int cqe;
-
- pthread_mutex_t mutex;
- pthread_cond_t cond;
- uint32_t comp_events_completed;
- uint32_t async_events_completed;
-
- struct ibv_cq *real_cq;
-};
-
-struct ibv_ah_1_0 {
- struct ibv_context_1_0 *context;
- struct ibv_pd_1_0 *pd;
- uint32_t handle;
-
- struct ibv_ah *real_ah;
-};
-
-struct ibv_device_1_0 {
- void *obsolete_sysfs_dev;
- void *obsolete_sysfs_ibdev;
- struct ibv_device *real_device; /* was obsolete driver member */
- struct ibv_device_ops ops;
-};
-
-struct ibv_context_ops_1_0 {
- int (*query_device)(struct ibv_context *context,
- struct ibv_device_attr *device_attr);
- int (*query_port)(struct ibv_context *context, uint8_t port_num,
- struct ibv_port_attr *port_attr);
- struct ibv_pd * (*alloc_pd)(struct ibv_context *context);
- int (*dealloc_pd)(struct ibv_pd *pd);
- struct ibv_mr * (*reg_mr)(struct ibv_pd *pd, void *addr, size_t length,
- int access);
- int (*dereg_mr)(struct ibv_mr *mr);
- struct ibv_cq * (*create_cq)(struct ibv_context *context, int cqe,
- struct ibv_comp_channel *channel,
- int comp_vector);
- int (*poll_cq)(struct ibv_cq_1_0 *cq, int num_entries,
- struct ibv_wc *wc);
- int (*req_notify_cq)(struct ibv_cq_1_0 *cq,
- int solicited_only);
- void (*cq_event)(struct ibv_cq *cq);
- int (*resize_cq)(struct ibv_cq *cq, int cqe);
- int (*destroy_cq)(struct ibv_cq *cq);
- struct ibv_srq * (*create_srq)(struct ibv_pd *pd,
- struct ibv_srq_init_attr *srq_init_attr);
- int (*modify_srq)(struct ibv_srq *srq,
- struct ibv_srq_attr *srq_attr,
- int srq_attr_mask);
- int (*query_srq)(struct ibv_srq *srq,
- struct ibv_srq_attr *srq_attr);
- int (*destroy_srq)(struct ibv_srq *srq);
- int (*post_srq_recv)(struct ibv_srq_1_0 *srq,
- struct ibv_recv_wr_1_0 *recv_wr,
- struct ibv_recv_wr_1_0 **bad_recv_wr);
- struct ibv_qp * (*create_qp)(struct ibv_pd *pd, struct ibv_qp_init_attr *attr);
- int (*query_qp)(struct ibv_qp *qp, struct ibv_qp_attr *attr,
- int attr_mask,
- struct ibv_qp_init_attr *init_attr);
- int (*modify_qp)(struct ibv_qp *qp, struct ibv_qp_attr *attr,
- int attr_mask);
- int (*destroy_qp)(struct ibv_qp *qp);
- int (*post_send)(struct ibv_qp_1_0 *qp,
- struct ibv_send_wr_1_0 *wr,
- struct ibv_send_wr_1_0 **bad_wr);
- int (*post_recv)(struct ibv_qp_1_0 *qp,
- struct ibv_recv_wr_1_0 *wr,
- struct ibv_recv_wr_1_0 **bad_wr);
- struct ibv_ah * (*create_ah)(struct ibv_pd *pd, struct ibv_ah_attr *attr);
- int (*destroy_ah)(struct ibv_ah *ah);
- int (*attach_mcast)(struct ibv_qp *qp, union ibv_gid *gid,
- uint16_t lid);
- int (*detach_mcast)(struct ibv_qp *qp, union ibv_gid *gid,
- uint16_t lid);
-};
-
-struct ibv_context_1_0 {
- struct ibv_device_1_0 *device;
- struct ibv_context_ops_1_0 ops;
- int cmd_fd;
- int async_fd;
- int num_comp_vectors;
-
- struct ibv_context *real_context; /* was abi_compat member */
-};
-
-struct ibv_device_1_0 **__ibv_get_device_list_1_0(int *num)
-{
- struct ibv_device **real_list;
- struct ibv_device_1_0 **l;
- int i, n;
-
- real_list = ibv_get_device_list(&n);
- if (!real_list)
- return NULL;
-
- l = calloc(n + 2, sizeof (struct ibv_device_1_0 *));
- if (!l)
- return NULL;
-
- l[0] = (void *) real_list;
-
- for (i = 0; i < n; ++i) {
- l[i + 1] = calloc(1, sizeof (struct ibv_device_1_0));
- if (!l[i + 1])
- goto fail;
- l[i + 1]->real_device = real_list[i];
- }
-
- if (num)
- *num = n;
-
- return l + 1;
-
-fail:
- for (i = 1; i <= n; ++i)
- if (l[i])
- free(l[i]);
- ibv_free_device_list(real_list);
- return NULL;
-}
-symver(__ibv_get_device_list_1_0, ibv_get_device_list, IBVERBS_1.0);
-
-void __ibv_free_device_list_1_0(struct ibv_device_1_0 **list)
-{
- struct ibv_device_1_0 **l = list;
-
- while (*l) {
- free(*l);
- ++l;
- }
-
- ibv_free_device_list((void *) list[-1]);
- free(list - 1);
-}
-symver(__ibv_free_device_list_1_0, ibv_free_device_list, IBVERBS_1.0);
-
-const char *__ibv_get_device_name_1_0(struct ibv_device_1_0 *device)
-{
- return ibv_get_device_name(device->real_device);
-}
-symver(__ibv_get_device_name_1_0, ibv_get_device_name, IBVERBS_1.0);
-
-uint64_t __ibv_get_device_guid_1_0(struct ibv_device_1_0 *device)
-{
- return ibv_get_device_guid(device->real_device);
-}
-symver(__ibv_get_device_guid_1_0, ibv_get_device_guid, IBVERBS_1.0);
-
-static int poll_cq_wrapper_1_0(struct ibv_cq_1_0 *cq, int num_entries,
- struct ibv_wc *wc)
-{
- return cq->context->real_context->ops.poll_cq(cq->real_cq, num_entries, wc);
-}
-
-static int req_notify_cq_wrapper_1_0(struct ibv_cq_1_0 *cq, int sol_only)
-{
- return cq->context->real_context->ops.req_notify_cq(cq->real_cq, sol_only);
-}
-
-static int post_srq_recv_wrapper_1_0(struct ibv_srq_1_0 *srq, struct ibv_recv_wr_1_0 *wr,
- struct ibv_recv_wr_1_0 **bad_wr)
-{
- struct ibv_recv_wr_1_0 *w;
- struct ibv_recv_wr *real_wr, *head_wr = NULL, *tail_wr = NULL, *real_bad_wr;
- int ret;
-
- for (w = wr; w; w = w->next) {
- real_wr = alloca(sizeof *real_wr);
- real_wr->wr_id = w->wr_id;
- real_wr->sg_list = w->sg_list;
- real_wr->num_sge = w->num_sge;
- real_wr->next = NULL;
- if (tail_wr)
- tail_wr->next = real_wr;
- else
- head_wr = real_wr;
-
- tail_wr = real_wr;
- }
-
- ret = srq->context->real_context->ops.post_srq_recv(srq->real_srq, head_wr,
- &real_bad_wr);
-
- if (ret) {
- for (real_wr = head_wr, w = wr;
- real_wr;
- real_wr = real_wr->next, w = w->next)
- if (real_wr == real_bad_wr) {
- *bad_wr = w;
- break;
- }
- }
-
- return ret;
-}
-
-static int post_send_wrapper_1_0(struct ibv_qp_1_0 *qp, struct ibv_send_wr_1_0 *wr,
- struct ibv_send_wr_1_0 **bad_wr)
-{
- struct ibv_send_wr_1_0 *w;
- struct ibv_send_wr *real_wr, *head_wr = NULL, *tail_wr = NULL, *real_bad_wr;
- int is_ud = qp->qp_type == IBV_QPT_UD;
- int ret;
-
- for (w = wr; w; w = w->next) {
- real_wr = alloca(sizeof *real_wr);
- real_wr->wr_id = w->wr_id;
- real_wr->next = NULL;
-
- memcpy(&real_wr->sg_list, &w->sg_list,
- sizeof *w - offsetof(struct ibv_send_wr, sg_list));
-
- if (is_ud)
- real_wr->wr.ud.ah = w->wr.ud.ah->real_ah;
-
- if (tail_wr)
- tail_wr->next = real_wr;
- else
- head_wr = real_wr;
-
- tail_wr = real_wr;
- }
-
- ret = qp->context->real_context->ops.post_send(qp->real_qp, head_wr,
- &real_bad_wr);
-
- if (ret) {
- for (real_wr = head_wr, w = wr;
- real_wr;
- real_wr = real_wr->next, w = w->next)
- if (real_wr == real_bad_wr) {
- *bad_wr = w;
- break;
- }
- }
-
- return ret;
-}
-
-static int post_recv_wrapper_1_0(struct ibv_qp_1_0 *qp, struct ibv_recv_wr_1_0 *wr,
- struct ibv_recv_wr_1_0 **bad_wr)
-{
- struct ibv_recv_wr_1_0 *w;
- struct ibv_recv_wr *real_wr, *head_wr = NULL, *tail_wr = NULL, *real_bad_wr;
- int ret;
-
- for (w = wr; w; w = w->next) {
- real_wr = alloca(sizeof *real_wr);
- real_wr->wr_id = w->wr_id;
- real_wr->sg_list = w->sg_list;
- real_wr->num_sge = w->num_sge;
- real_wr->next = NULL;
- if (tail_wr)
- tail_wr->next = real_wr;
- else
- head_wr = real_wr;
-
- tail_wr = real_wr;
- }
-
- ret = qp->context->real_context->ops.post_recv(qp->real_qp, head_wr,
- &real_bad_wr);
-
- if (ret) {
- for (real_wr = head_wr, w = wr;
- real_wr;
- real_wr = real_wr->next, w = w->next)
- if (real_wr == real_bad_wr) {
- *bad_wr = w;
- break;
- }
- }
-
- return ret;
-}
-
-struct ibv_context_1_0 *__ibv_open_device_1_0(struct ibv_device_1_0 *device)
-{
- struct ibv_context *real_ctx;
- struct ibv_context_1_0 *ctx;
-
- ctx = malloc(sizeof *ctx);
- if (!ctx)
- return NULL;
-
- real_ctx = ibv_open_device(device->real_device);
- if (!real_ctx) {
- free(ctx);
- return NULL;
- }
-
- ctx->device = device;
- ctx->real_context = real_ctx;
-
- ctx->ops.poll_cq = poll_cq_wrapper_1_0;
- ctx->ops.req_notify_cq = req_notify_cq_wrapper_1_0;
- ctx->ops.post_send = post_send_wrapper_1_0;
- ctx->ops.post_recv = post_recv_wrapper_1_0;
- ctx->ops.post_srq_recv = post_srq_recv_wrapper_1_0;
-
- return ctx;
-}
-symver(__ibv_open_device_1_0, ibv_open_device, IBVERBS_1.0);
-
-int __ibv_close_device_1_0(struct ibv_context_1_0 *context)
-{
- int ret;
-
- ret = ibv_close_device(context->real_context);
- if (ret)
- return ret;
-
- free(context);
- return 0;
-}
-symver(__ibv_close_device_1_0, ibv_close_device, IBVERBS_1.0);
-
-int __ibv_get_async_event_1_0(struct ibv_context_1_0 *context,
- struct ibv_async_event *event)
-{
- int ret;
-
- ret = ibv_get_async_event(context->real_context, event);
- if (ret)
- return ret;
-
- switch (event->event_type) {
- case IBV_EVENT_CQ_ERR:
- event->element.cq = event->element.cq->cq_context;
- break;
-
- case IBV_EVENT_QP_FATAL:
- case IBV_EVENT_QP_REQ_ERR:
- case IBV_EVENT_QP_ACCESS_ERR:
- case IBV_EVENT_COMM_EST:
- case IBV_EVENT_SQ_DRAINED:
- case IBV_EVENT_PATH_MIG:
- case IBV_EVENT_PATH_MIG_ERR:
- case IBV_EVENT_QP_LAST_WQE_REACHED:
- event->element.qp = event->element.qp->qp_context;
- break;
-
- case IBV_EVENT_SRQ_ERR:
- case IBV_EVENT_SRQ_LIMIT_REACHED:
- event->element.srq = event->element.srq->srq_context;
- break;
-
- default:
- break;
- }
-
- return ret;
-}
-symver(__ibv_get_async_event_1_0, ibv_get_async_event, IBVERBS_1.0);
-
-void __ibv_ack_async_event_1_0(struct ibv_async_event *event)
-{
- struct ibv_async_event real_event = *event;
-
- switch (event->event_type) {
- case IBV_EVENT_CQ_ERR:
- real_event.element.cq =
- ((struct ibv_cq_1_0 *) event->element.cq)->real_cq;
- break;
-
- case IBV_EVENT_QP_FATAL:
- case IBV_EVENT_QP_REQ_ERR:
- case IBV_EVENT_QP_ACCESS_ERR:
- case IBV_EVENT_COMM_EST:
- case IBV_EVENT_SQ_DRAINED:
- case IBV_EVENT_PATH_MIG:
- case IBV_EVENT_PATH_MIG_ERR:
- case IBV_EVENT_QP_LAST_WQE_REACHED:
- real_event.element.qp =
- ((struct ibv_qp_1_0 *) event->element.qp)->real_qp;
- break;
-
- case IBV_EVENT_SRQ_ERR:
- case IBV_EVENT_SRQ_LIMIT_REACHED:
- real_event.element.srq =
- ((struct ibv_srq_1_0 *) event->element.srq)->real_srq;
- break;
-
- default:
- break;
- }
-
- ibv_ack_async_event(&real_event);
-}
-symver(__ibv_ack_async_event_1_0, ibv_ack_async_event, IBVERBS_1.0);
-
-int __ibv_query_device_1_0(struct ibv_context_1_0 *context,
- struct ibv_device_attr *device_attr)
-{
- return ibv_query_device(context->real_context, device_attr);
-}
-symver(__ibv_query_device_1_0, ibv_query_device, IBVERBS_1.0);
-
-int __ibv_query_port_1_0(struct ibv_context_1_0 *context, uint8_t port_num,
- struct ibv_port_attr *port_attr)
-{
- return ibv_query_port(context->real_context, port_num, port_attr);
-}
-symver(__ibv_query_port_1_0, ibv_query_port, IBVERBS_1.0);
-
-int __ibv_query_gid_1_0(struct ibv_context_1_0 *context, uint8_t port_num,
- int index, union ibv_gid *gid)
-{
- return ibv_query_gid(context->real_context, port_num, index, gid);
-}
-symver(__ibv_query_gid_1_0, ibv_query_gid, IBVERBS_1.0);
-
-int __ibv_query_pkey_1_0(struct ibv_context_1_0 *context, uint8_t port_num,
- int index, uint16_t *pkey)
-{
- return ibv_query_pkey(context->real_context, port_num, index, pkey);
-}
-symver(__ibv_query_pkey_1_0, ibv_query_pkey, IBVERBS_1.0);
-
-struct ibv_pd_1_0 *__ibv_alloc_pd_1_0(struct ibv_context_1_0 *context)
-{
- struct ibv_pd *real_pd;
- struct ibv_pd_1_0 *pd;
-
- pd = malloc(sizeof *pd);
- if (!pd)
- return NULL;
-
- real_pd = ibv_alloc_pd(context->real_context);
- if (!real_pd) {
- free(pd);
- return NULL;
- }
-
- pd->context = context;
- pd->real_pd = real_pd;
-
- return pd;
-}
-symver(__ibv_alloc_pd_1_0, ibv_alloc_pd, IBVERBS_1.0);
-
-int __ibv_dealloc_pd_1_0(struct ibv_pd_1_0 *pd)
-{
- int ret;
-
- ret = ibv_dealloc_pd(pd->real_pd);
- if (ret)
- return ret;
-
- free(pd);
- return 0;
-}
-symver(__ibv_dealloc_pd_1_0, ibv_dealloc_pd, IBVERBS_1.0);
-
-struct ibv_mr_1_0 *__ibv_reg_mr_1_0(struct ibv_pd_1_0 *pd, void *addr,
- size_t length, int access)
-{
- struct ibv_mr *real_mr;
- struct ibv_mr_1_0 *mr;
-
- mr = malloc(sizeof *mr);
- if (!mr)
- return NULL;
-
- real_mr = ibv_reg_mr(pd->real_pd, addr, length, access);
- if (!real_mr) {
- free(mr);
- return NULL;
- }
-
- mr->context = pd->context;
- mr->pd = pd;
- mr->lkey = real_mr->lkey;
- mr->rkey = real_mr->rkey;
- mr->real_mr = real_mr;
-
- return mr;
-}
-symver(__ibv_reg_mr_1_0, ibv_reg_mr, IBVERBS_1.0);
-
-int __ibv_dereg_mr_1_0(struct ibv_mr_1_0 *mr)
-{
- int ret;
-
- ret = ibv_dereg_mr(mr->real_mr);
- if (ret)
- return ret;
-
- free(mr);
- return 0;
-}
-symver(__ibv_dereg_mr_1_0, ibv_dereg_mr, IBVERBS_1.0);
-
-struct ibv_cq_1_0 *__ibv_create_cq_1_0(struct ibv_context_1_0 *context, int cqe,
- void *cq_context,
- struct ibv_comp_channel *channel,
- int comp_vector)
-{
- struct ibv_cq *real_cq;
- struct ibv_cq_1_0 *cq;
-
- cq = malloc(sizeof *cq);
- if (!cq)
- return NULL;
-
- real_cq = ibv_create_cq(context->real_context, cqe, cq_context,
- channel, comp_vector);
- if (!real_cq) {
- free(cq);
- return NULL;
- }
-
- cq->context = context;
- cq->cq_context = cq_context;
- cq->cqe = cqe;
- cq->real_cq = real_cq;
-
- real_cq->cq_context = cq;
-
- return cq;
-}
-symver(__ibv_create_cq_1_0, ibv_create_cq, IBVERBS_1.0);
-
-int __ibv_resize_cq_1_0(struct ibv_cq_1_0 *cq, int cqe)
-{
- return ibv_resize_cq(cq->real_cq, cqe);
-}
-symver(__ibv_resize_cq_1_0, ibv_resize_cq, IBVERBS_1.0);
-
-int __ibv_destroy_cq_1_0(struct ibv_cq_1_0 *cq)
-{
- int ret;
-
- ret = ibv_destroy_cq(cq->real_cq);
- if (ret)
- return ret;
-
- free(cq);
- return 0;
-}
-symver(__ibv_destroy_cq_1_0, ibv_destroy_cq, IBVERBS_1.0);
-
-int __ibv_get_cq_event_1_0(struct ibv_comp_channel *channel,
- struct ibv_cq_1_0 **cq, void **cq_context)
-{
- struct ibv_cq *real_cq;
- void *cq_ptr;
- int ret;
-
- ret = ibv_get_cq_event(channel, &real_cq, &cq_ptr);
- if (ret)
- return ret;
-
- *cq = cq_ptr;
- *cq_context = (*cq)->cq_context;
-
- return 0;
-}
-symver(__ibv_get_cq_event_1_0, ibv_get_cq_event, IBVERBS_1.0);
-
-void __ibv_ack_cq_events_1_0(struct ibv_cq_1_0 *cq, unsigned int nevents)
-{
- ibv_ack_cq_events(cq->real_cq, nevents);
-}
-symver(__ibv_ack_cq_events_1_0, ibv_ack_cq_events, IBVERBS_1.0);
-
-struct ibv_srq_1_0 *__ibv_create_srq_1_0(struct ibv_pd_1_0 *pd,
- struct ibv_srq_init_attr *srq_init_attr)
-{
- struct ibv_srq *real_srq;
- struct ibv_srq_1_0 *srq;
-
- srq = malloc(sizeof *srq);
- if (!srq)
- return NULL;
-
- real_srq = ibv_create_srq(pd->real_pd, srq_init_attr);
- if (!real_srq) {
- free(srq);
- return NULL;
- }
-
- srq->context = pd->context;
- srq->srq_context = srq_init_attr->srq_context;
- srq->pd = pd;
- srq->real_srq = real_srq;
-
- real_srq->srq_context = srq;
-
- return srq;
-}
-symver(__ibv_create_srq_1_0, ibv_create_srq, IBVERBS_1.0);
-
-int __ibv_modify_srq_1_0(struct ibv_srq_1_0 *srq,
- struct ibv_srq_attr *srq_attr,
- int srq_attr_mask)
-{
- return ibv_modify_srq(srq->real_srq, srq_attr, srq_attr_mask);
-}
-symver(__ibv_modify_srq_1_0, ibv_modify_srq, IBVERBS_1.0);
-
-int __ibv_query_srq_1_0(struct ibv_srq_1_0 *srq, struct ibv_srq_attr *srq_attr)
-{
- return ibv_query_srq(srq->real_srq, srq_attr);
-}
-symver(__ibv_query_srq_1_0, ibv_query_srq, IBVERBS_1.0);
-
-int __ibv_destroy_srq_1_0(struct ibv_srq_1_0 *srq)
-{
- int ret;
-
- ret = ibv_destroy_srq(srq->real_srq);
- if (ret)
- return ret;
-
- free(srq);
- return 0;
-}
-symver(__ibv_destroy_srq_1_0, ibv_destroy_srq, IBVERBS_1.0);
-
-struct ibv_qp_1_0 *__ibv_create_qp_1_0(struct ibv_pd_1_0 *pd,
- struct ibv_qp_init_attr_1_0 *qp_init_attr)
-{
- struct ibv_qp *real_qp;
- struct ibv_qp_1_0 *qp;
- struct ibv_qp_init_attr real_init_attr;
-
- qp = malloc(sizeof *qp);
- if (!qp)
- return NULL;
-
- real_init_attr.qp_context = qp_init_attr->qp_context;
- real_init_attr.send_cq = qp_init_attr->send_cq->real_cq;
- real_init_attr.recv_cq = qp_init_attr->recv_cq->real_cq;
- real_init_attr.srq = qp_init_attr->srq ?
- qp_init_attr->srq->real_srq : NULL;
- real_init_attr.cap = qp_init_attr->cap;
- real_init_attr.qp_type = qp_init_attr->qp_type;
- real_init_attr.sq_sig_all = qp_init_attr->sq_sig_all;
-
- real_qp = ibv_create_qp(pd->real_pd, &real_init_attr);
- if (!real_qp) {
- free(qp);
- return NULL;
- }
-
- qp->context = pd->context;
- qp->qp_context = qp_init_attr->qp_context;
- qp->pd = pd;
- qp->send_cq = qp_init_attr->send_cq;
- qp->recv_cq = qp_init_attr->recv_cq;
- qp->srq = qp_init_attr->srq;
- qp->qp_type = qp_init_attr->qp_type;
- qp->qp_num = real_qp->qp_num;
- qp->real_qp = real_qp;
-
- qp_init_attr->cap = real_init_attr.cap;
-
- real_qp->qp_context = qp;
-
- return qp;
-}
-symver(__ibv_create_qp_1_0, ibv_create_qp, IBVERBS_1.0);
-
-int __ibv_query_qp_1_0(struct ibv_qp_1_0 *qp, struct ibv_qp_attr *attr,
- int attr_mask,
- struct ibv_qp_init_attr_1_0 *init_attr)
-{
- struct ibv_qp_init_attr real_init_attr;
- int ret;
-
- ret = ibv_query_qp(qp->real_qp, attr, attr_mask, &real_init_attr);
- if (ret)
- return ret;
-
- init_attr->qp_context = qp->qp_context;
- init_attr->send_cq = real_init_attr.send_cq->cq_context;
- init_attr->recv_cq = real_init_attr.recv_cq->cq_context;
- init_attr->srq = real_init_attr.srq->srq_context;
- init_attr->qp_type = real_init_attr.qp_type;
- init_attr->cap = real_init_attr.cap;
- init_attr->sq_sig_all = real_init_attr.sq_sig_all;
-
- return 0;
-}
-symver(__ibv_query_qp_1_0, ibv_query_qp, IBVERBS_1.0);
-
-int __ibv_modify_qp_1_0(struct ibv_qp_1_0 *qp, struct ibv_qp_attr *attr,
- int attr_mask)
-{
- return ibv_modify_qp(qp->real_qp, attr, attr_mask);
-}
-symver(__ibv_modify_qp_1_0, ibv_modify_qp, IBVERBS_1.0);
-
-int __ibv_destroy_qp_1_0(struct ibv_qp_1_0 *qp)
-{
- int ret;
-
- ret = ibv_destroy_qp(qp->real_qp);
- if (ret)
- return ret;
-
- free(qp);
- return 0;
-}
-symver(__ibv_destroy_qp_1_0, ibv_destroy_qp, IBVERBS_1.0);
-
-struct ibv_ah_1_0 *__ibv_create_ah_1_0(struct ibv_pd_1_0 *pd,
- struct ibv_ah_attr *attr)
-{
- struct ibv_ah *real_ah;
- struct ibv_ah_1_0 *ah;
-
- ah = malloc(sizeof *ah);
- if (!ah)
- return NULL;
-
- real_ah = ibv_create_ah(pd->real_pd, attr);
- if (!real_ah) {
- free(ah);
- return NULL;
- }
-
- ah->context = pd->context;
- ah->pd = pd;
- ah->real_ah = real_ah;
-
- return ah;
-}
-symver(__ibv_create_ah_1_0, ibv_create_ah, IBVERBS_1.0);
-
-int __ibv_destroy_ah_1_0(struct ibv_ah_1_0 *ah)
-{
- int ret;
-
- ret = ibv_destroy_ah(ah->real_ah);
- if (ret)
- return ret;
-
- free(ah);
- return 0;
-}
-symver(__ibv_destroy_ah_1_0, ibv_destroy_ah, IBVERBS_1.0);
-
-int __ibv_attach_mcast_1_0(struct ibv_qp_1_0 *qp, union ibv_gid *gid, uint16_t lid)
-{
- return ibv_attach_mcast(qp->real_qp, gid, lid);
-}
-symver(__ibv_attach_mcast_1_0, ibv_attach_mcast, IBVERBS_1.0);
-
-int __ibv_detach_mcast_1_0(struct ibv_qp_1_0 *qp, union ibv_gid *gid, uint16_t lid)
-{
- return ibv_detach_mcast(qp->real_qp, gid, lid);
-}
-symver(__ibv_detach_mcast_1_0, ibv_detach_mcast, IBVERBS_1.0);
diff --git a/contrib/ofed/libibverbs/src/device.c b/contrib/ofed/libibverbs/src/device.c
deleted file mode 100644
index c2bca68..0000000
--- a/contrib/ofed/libibverbs/src/device.c
+++ /dev/null
@@ -1,280 +0,0 @@
-/*
- * Copyright (c) 2004, 2005 Topspin Communications. All rights reserved.
- * Copyright (c) 2006, 2007 Cisco Systems, Inc. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-#if HAVE_CONFIG_H
-# include <config.h>
-#endif /* HAVE_CONFIG_H */
-
-#include <stdio.h>
-#include <netinet/in.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <unistd.h>
-#include <stdlib.h>
-#include <alloca.h>
-#include <errno.h>
-
-#include <infiniband/arch.h>
-
-#include "ibverbs.h"
-
-static pthread_mutex_t device_list_lock = PTHREAD_MUTEX_INITIALIZER;
-static int num_devices;
-static struct ibv_device **device_list;
-
-struct ibv_device **__ibv_get_device_list(int *num)
-{
- struct ibv_device **l = 0;
- int i;
-
- if (num)
- *num = 0;
-
- pthread_mutex_lock(&device_list_lock);
-
- if (!num_devices)
- num_devices = ibverbs_init(&device_list);
-
- if (num_devices < 0) {
- errno = -num_devices;
- goto out;
- }
-
- l = calloc(num_devices + 1, sizeof (struct ibv_device *));
- if (!l) {
- errno = ENOMEM;
- goto out;
- }
-
- for (i = 0; i < num_devices; ++i)
- l[i] = device_list[i];
- if (num)
- *num = num_devices;
-
-out:
- pthread_mutex_unlock(&device_list_lock);
- return l;
-}
-default_symver(__ibv_get_device_list, ibv_get_device_list);
-
-void __ibv_free_device_list(struct ibv_device **list)
-{
- free(list);
-}
-default_symver(__ibv_free_device_list, ibv_free_device_list);
-
-const char *__ibv_get_device_name(struct ibv_device *device)
-{
- return device->name;
-}
-default_symver(__ibv_get_device_name, ibv_get_device_name);
-
-uint64_t __ibv_get_device_guid(struct ibv_device *device)
-{
- char attr[24];
- uint64_t guid = 0;
- uint16_t parts[4];
- int i;
-
- if (ibv_read_sysfs_file(device->ibdev_path, "node_guid",
- attr, sizeof attr) < 0)
- return 0;
-
- if (sscanf(attr, "%hx:%hx:%hx:%hx",
- parts, parts + 1, parts + 2, parts + 3) != 4)
- return 0;
-
- for (i = 0; i < 4; ++i)
- guid = (guid << 16) | parts[i];
-
- return htonll(guid);
-}
-default_symver(__ibv_get_device_guid, ibv_get_device_guid);
-
-struct ibv_context *__ibv_open_device(struct ibv_device *device)
-{
- char *devpath;
- int cmd_fd;
- struct ibv_context *context;
-
- if (asprintf(&devpath, "/dev/%s", device->dev_name) < 0)
- return NULL;
-
- /*
- * We'll only be doing writes, but we need O_RDWR in case the
- * provider needs to mmap() the file.
- */
- cmd_fd = open(devpath, O_RDWR);
- free(devpath);
-
- if (cmd_fd < 0)
- return NULL;
-
- context = device->ops.alloc_context(device, cmd_fd);
- if (!context)
- goto err;
-
- context->device = device;
- context->cmd_fd = cmd_fd;
- pthread_mutex_init(&context->mutex, NULL);
-
- return context;
-
-err:
- close(cmd_fd);
-
- return NULL;
-}
-default_symver(__ibv_open_device, ibv_open_device);
-
-int __ibv_close_device(struct ibv_context *context)
-{
- int async_fd = context->async_fd;
- int cmd_fd = context->cmd_fd;
- int cq_fd = -1;
-
- if (abi_ver <= 2) {
- struct ibv_abi_compat_v2 *t = context->abi_compat;
- cq_fd = t->channel.fd;
- free(context->abi_compat);
- }
-
- context->device->ops.free_context(context);
-
- close(async_fd);
- close(cmd_fd);
- if (abi_ver <= 2)
- close(cq_fd);
-
- return 0;
-}
-default_symver(__ibv_close_device, ibv_close_device);
-
-int __ibv_get_async_event(struct ibv_context *context,
- struct ibv_async_event *event)
-{
- struct ibv_kern_async_event ev;
-
- if (read(context->async_fd, &ev, sizeof ev) != sizeof ev)
- return -1;
-
- event->event_type = ev.event_type;
-
- if (event->event_type & IBV_XRC_QP_EVENT_FLAG) {
- event->element.xrc_qp_num = ev.element;
- } else
- switch (event->event_type) {
- case IBV_EVENT_CQ_ERR:
- event->element.cq = (void *) (uintptr_t) ev.element;
- break;
-
- case IBV_EVENT_QP_FATAL:
- case IBV_EVENT_QP_REQ_ERR:
- case IBV_EVENT_QP_ACCESS_ERR:
- case IBV_EVENT_COMM_EST:
- case IBV_EVENT_SQ_DRAINED:
- case IBV_EVENT_PATH_MIG:
- case IBV_EVENT_PATH_MIG_ERR:
- case IBV_EVENT_QP_LAST_WQE_REACHED:
- event->element.qp = (void *) (uintptr_t) ev.element;
- break;
-
- case IBV_EVENT_SRQ_ERR:
- case IBV_EVENT_SRQ_LIMIT_REACHED:
- event->element.srq = (void *) (uintptr_t) ev.element;
- break;
- default:
- event->element.port_num = ev.element;
- break;
- }
-
- if (context->ops.async_event)
- context->ops.async_event(event);
-
- return 0;
-}
-default_symver(__ibv_get_async_event, ibv_get_async_event);
-
-void __ibv_ack_async_event(struct ibv_async_event *event)
-{
- switch (event->event_type) {
- case IBV_EVENT_CQ_ERR:
- {
- struct ibv_cq *cq = event->element.cq;
-
- pthread_mutex_lock(&cq->mutex);
- ++cq->async_events_completed;
- pthread_cond_signal(&cq->cond);
- pthread_mutex_unlock(&cq->mutex);
-
- return;
- }
-
- case IBV_EVENT_QP_FATAL:
- case IBV_EVENT_QP_REQ_ERR:
- case IBV_EVENT_QP_ACCESS_ERR:
- case IBV_EVENT_COMM_EST:
- case IBV_EVENT_SQ_DRAINED:
- case IBV_EVENT_PATH_MIG:
- case IBV_EVENT_PATH_MIG_ERR:
- case IBV_EVENT_QP_LAST_WQE_REACHED:
- {
- struct ibv_qp *qp = event->element.qp;
-
- pthread_mutex_lock(&qp->mutex);
- ++qp->events_completed;
- pthread_cond_signal(&qp->cond);
- pthread_mutex_unlock(&qp->mutex);
-
- return;
- }
-
- case IBV_EVENT_SRQ_ERR:
- case IBV_EVENT_SRQ_LIMIT_REACHED:
- {
- struct ibv_srq *srq = event->element.srq;
-
- pthread_mutex_lock(&srq->mutex);
- ++srq->events_completed;
- pthread_cond_signal(&srq->cond);
- pthread_mutex_unlock(&srq->mutex);
-
- return;
- }
-
- default:
- return;
- }
-}
-default_symver(__ibv_ack_async_event, ibv_ack_async_event);
diff --git a/contrib/ofed/libibverbs/src/enum_strs.c b/contrib/ofed/libibverbs/src/enum_strs.c
deleted file mode 100644
index c57feaa..0000000
--- a/contrib/ofed/libibverbs/src/enum_strs.c
+++ /dev/null
@@ -1,127 +0,0 @@
-/*
- * Copyright (c) 2008 Lawrence Livermore National Laboratory
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-#include <infiniband/verbs.h>
-
-const char *ibv_node_type_str(enum ibv_node_type node_type)
-{
- static const char *const node_type_str[] = {
- [IBV_NODE_CA] = "InfiniBand channel adapter",
- [IBV_NODE_SWITCH] = "InfiniBand switch",
- [IBV_NODE_ROUTER] = "InfiniBand router",
- [IBV_NODE_RNIC] = "iWARP NIC"
- };
-
- if (node_type < IBV_NODE_CA || node_type > IBV_NODE_RNIC)
- return "unknown";
-
- return node_type_str[node_type];
-}
-
-const char *ibv_port_state_str(enum ibv_port_state port_state)
-{
- static const char *const port_state_str[] = {
- [IBV_PORT_NOP] = "no state change (NOP)",
- [IBV_PORT_DOWN] = "down",
- [IBV_PORT_INIT] = "init",
- [IBV_PORT_ARMED] = "armed",
- [IBV_PORT_ACTIVE] = "active",
- [IBV_PORT_ACTIVE_DEFER] = "active defer"
- };
-
- if (port_state < IBV_PORT_NOP || port_state > IBV_PORT_ACTIVE_DEFER)
- return "unknown";
-
- return port_state_str[port_state];
-}
-
-const char *ibv_event_type_str(enum ibv_event_type event)
-{
- static const char *const event_type_str[] = {
- [IBV_EVENT_CQ_ERR] = "CQ error",
- [IBV_EVENT_QP_FATAL] = "local work queue catastrophic error",
- [IBV_EVENT_QP_REQ_ERR] = "invalid request local work queue error",
- [IBV_EVENT_QP_ACCESS_ERR] = "local access violation work queue error",
- [IBV_EVENT_COMM_EST] = "communication established",
- [IBV_EVENT_SQ_DRAINED] = "send queue drained",
- [IBV_EVENT_PATH_MIG] = "path migrated",
- [IBV_EVENT_PATH_MIG_ERR] = "path migration request error",
- [IBV_EVENT_DEVICE_FATAL] = "local catastrophic error",
- [IBV_EVENT_PORT_ACTIVE] = "port active",
- [IBV_EVENT_PORT_ERR] = "port error",
- [IBV_EVENT_LID_CHANGE] = "LID change",
- [IBV_EVENT_PKEY_CHANGE] = "P_Key change",
- [IBV_EVENT_SM_CHANGE] = "SM change",
- [IBV_EVENT_SRQ_ERR] = "SRQ catastrophic error",
- [IBV_EVENT_SRQ_LIMIT_REACHED] = "SRQ limit reached",
- [IBV_EVENT_QP_LAST_WQE_REACHED] = "last WQE reached",
- [IBV_EVENT_CLIENT_REREGISTER] = "client reregistration",
- };
-
- if (event < IBV_EVENT_CQ_ERR || event > IBV_EVENT_CLIENT_REREGISTER)
- return "unknown";
-
- return event_type_str[event];
-}
-
-const char *ibv_wc_status_str(enum ibv_wc_status status)
-{
- static const char *const wc_status_str[] = {
- [IBV_WC_SUCCESS] = "success",
- [IBV_WC_LOC_LEN_ERR] = "local length error",
- [IBV_WC_LOC_QP_OP_ERR] = "local QP operation error",
- [IBV_WC_LOC_EEC_OP_ERR] = "local EE context operation error",
- [IBV_WC_LOC_PROT_ERR] = "local protection error",
- [IBV_WC_WR_FLUSH_ERR] = "Work Request Flushed Error",
- [IBV_WC_MW_BIND_ERR] = "memory management operation error",
- [IBV_WC_BAD_RESP_ERR] = "bad response error",
- [IBV_WC_LOC_ACCESS_ERR] = "local access error",
- [IBV_WC_REM_INV_REQ_ERR] = "remote invalid request error",
- [IBV_WC_REM_ACCESS_ERR] = "remote access error",
- [IBV_WC_REM_OP_ERR] = "remote operation error",
- [IBV_WC_RETRY_EXC_ERR] = "transport retry counter exceeded",
- [IBV_WC_RNR_RETRY_EXC_ERR] = "RNR retry counter exceeded",
- [IBV_WC_LOC_RDD_VIOL_ERR] = "local RDD violation error",
- [IBV_WC_REM_INV_RD_REQ_ERR] = "remote invalid RD request",
- [IBV_WC_REM_ABORT_ERR] = "aborted error",
- [IBV_WC_INV_EECN_ERR] = "invalid EE context number",
- [IBV_WC_INV_EEC_STATE_ERR] = "invalid EE context state",
- [IBV_WC_FATAL_ERR] = "fatal error",
- [IBV_WC_RESP_TIMEOUT_ERR] = "response timeout error",
- [IBV_WC_GENERAL_ERR] = "general error"
- };
-
- if (status < IBV_WC_SUCCESS || status > IBV_WC_GENERAL_ERR)
- return "unknown";
-
- return wc_status_str[status];
-}
diff --git a/contrib/ofed/libibverbs/src/ibverbs.h b/contrib/ofed/libibverbs/src/ibverbs.h
deleted file mode 100644
index 6a6e3c8..0000000
--- a/contrib/ofed/libibverbs/src/ibverbs.h
+++ /dev/null
@@ -1,105 +0,0 @@
-/*
- * Copyright (c) 2004, 2005 Topspin Communications. All rights reserved.
- * Copyright (c) 2007 Cisco Systems, Inc. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-#ifndef IB_VERBS_H
-#define IB_VERBS_H
-
-#include <pthread.h>
-
-#include <infiniband/driver.h>
-
-#ifdef HAVE_VALGRIND_MEMCHECK_H
-
-# include <valgrind/memcheck.h>
-
-# ifndef VALGRIND_MAKE_MEM_DEFINED
-# warning "Valgrind support requested, but VALGRIND_MAKE_MEM_DEFINED not available"
-# endif
-
-#endif /* HAVE_VALGRIND_MEMCHECK_H */
-
-#ifndef VALGRIND_MAKE_MEM_DEFINED
-# define VALGRIND_MAKE_MEM_DEFINED(addr, len)
-#endif
-
-#define HIDDEN __attribute__((visibility ("hidden")))
-
-#define INIT __attribute__((constructor))
-#define FINI __attribute__((destructor))
-
-#define DEFAULT_ABI "IBVERBS_1.1"
-
-#ifdef HAVE_SYMVER_SUPPORT
-# define symver(name, api, ver) \
- asm(".symver " #name "," #api "@" #ver)
-# define default_symver(name, api) \
- asm(".symver " #name "," #api "@@" DEFAULT_ABI)
-#else
-# define symver(name, api, ver)
-# define default_symver(name, api) \
- extern __typeof(name) api __attribute__((alias(#name)))
-#endif /* HAVE_SYMVER_SUPPORT */
-
-#define PFX "libibverbs: "
-
-struct ibv_abi_compat_v2 {
- struct ibv_comp_channel channel;
- pthread_mutex_t in_use;
-};
-
-extern HIDDEN int abi_ver;
-
-HIDDEN int ibverbs_init(struct ibv_device ***list);
-
-#define IBV_INIT_CMD(cmd, size, opcode) \
- do { \
- if (abi_ver > 2) \
- (cmd)->command = IB_USER_VERBS_CMD_##opcode; \
- else \
- (cmd)->command = IB_USER_VERBS_CMD_##opcode##_V2; \
- (cmd)->in_words = (size) / 4; \
- (cmd)->out_words = 0; \
- } while (0)
-
-#define IBV_INIT_CMD_RESP(cmd, size, opcode, out, outsize) \
- do { \
- if (abi_ver > 2) \
- (cmd)->command = IB_USER_VERBS_CMD_##opcode; \
- else \
- (cmd)->command = IB_USER_VERBS_CMD_##opcode##_V2; \
- (cmd)->in_words = (size) / 4; \
- (cmd)->out_words = (outsize) / 4; \
- (cmd)->response = (uintptr_t) (out); \
- } while (0)
-
-#endif /* IB_VERBS_H */
diff --git a/contrib/ofed/libibverbs/src/init.c b/contrib/ofed/libibverbs/src/init.c
deleted file mode 100644
index d48ad18..0000000
--- a/contrib/ofed/libibverbs/src/init.c
+++ /dev/null
@@ -1,595 +0,0 @@
-/*
- * Copyright (c) 2004, 2005 Topspin Communications. All rights reserved.
- * Copyright (c) 2006 Cisco Systems, Inc. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-#if HAVE_CONFIG_H
-# include <config.h>
-#endif /* HAVE_CONFIG_H */
-
-#include <stdlib.h>
-#include <string.h>
-#include <glob.h>
-#include <stdio.h>
-#include <dlfcn.h>
-#include <unistd.h>
-#include <sys/stat.h>
-#include <sys/types.h>
-#include <sys/time.h>
-#include <sys/resource.h>
-#include <dirent.h>
-#include <errno.h>
-
-#include "ibverbs.h"
-
-HIDDEN int abi_ver;
-
-struct ibv_sysfs_dev {
- char sysfs_name[IBV_SYSFS_NAME_MAX];
- char ibdev_name[IBV_SYSFS_NAME_MAX];
- char sysfs_path[IBV_SYSFS_PATH_MAX];
- char ibdev_path[IBV_SYSFS_PATH_MAX];
- struct ibv_sysfs_dev *next;
- int abi_ver;
- int have_driver;
-};
-
-struct ibv_driver_name {
- char *name;
- struct ibv_driver_name *next;
-};
-
-struct ibv_driver {
- const char *name;
- ibv_driver_init_func init_func;
- struct ibv_driver *next;
-};
-
-static struct ibv_sysfs_dev *sysfs_dev_list;
-static struct ibv_driver_name *driver_name_list;
-static struct ibv_driver *head_driver, *tail_driver;
-
-static int find_sysfs_devs(void)
-{
-#ifdef __linux__
- char class_path[IBV_SYSFS_PATH_MAX];
- DIR *class_dir;
- struct dirent *dent;
- struct ibv_sysfs_dev *sysfs_dev = NULL;
- char value[8];
- int ret = 0;
-
- snprintf(class_path, sizeof class_path, "%s/class/infiniband_verbs",
- ibv_get_sysfs_path());
-
- class_dir = opendir(class_path);
- if (!class_dir)
- return ENOSYS;
-
- while ((dent = readdir(class_dir))) {
- struct stat buf;
-
- if (dent->d_name[0] == '.')
- continue;
-
- if (!sysfs_dev)
- sysfs_dev = malloc(sizeof *sysfs_dev);
- if (!sysfs_dev) {
- ret = ENOMEM;
- goto out;
- }
-
- snprintf(sysfs_dev->sysfs_path, sizeof sysfs_dev->sysfs_path,
- "%s/%s", class_path, dent->d_name);
-
- if (stat(sysfs_dev->sysfs_path, &buf)) {
- fprintf(stderr, PFX "Warning: couldn't stat '%s'.\n",
- sysfs_dev->sysfs_path);
- continue;
- }
-
- if (!S_ISDIR(buf.st_mode))
- continue;
-
- snprintf(sysfs_dev->sysfs_name, sizeof sysfs_dev->sysfs_name,
- "%s", dent->d_name);
-
- if (ibv_read_sysfs_file(sysfs_dev->sysfs_path, "ibdev",
- sysfs_dev->ibdev_name,
- sizeof sysfs_dev->ibdev_name) < 0) {
- fprintf(stderr, PFX "Warning: no ibdev class attr for '%s'.\n",
- dent->d_name);
- continue;
- }
-
- snprintf(sysfs_dev->ibdev_path, sizeof sysfs_dev->ibdev_path,
- "%s/class/infiniband/%s", ibv_get_sysfs_path(),
- sysfs_dev->ibdev_name);
-
- sysfs_dev->next = sysfs_dev_list;
- sysfs_dev->have_driver = 0;
- if (ibv_read_sysfs_file(sysfs_dev->sysfs_path, "abi_version",
- value, sizeof value) > 0)
- sysfs_dev->abi_ver = strtol(value, NULL, 10);
- else
- sysfs_dev->abi_ver = 0;
-
- sysfs_dev_list = sysfs_dev;
- sysfs_dev = NULL;
- }
-
- out:
- if (sysfs_dev)
- free(sysfs_dev);
-
- closedir(class_dir);
- return ret;
-#else
- char class_path[IBV_SYSFS_PATH_MAX];
- struct ibv_sysfs_dev *sysfs_dev = NULL;
- char value[8];
- int ret = 0;
- int i;
-
- snprintf(class_path, sizeof class_path, "%s/class/infiniband_verbs",
- ibv_get_sysfs_path());
-
- for (i = 0; i < 256; i++) {
- if (!sysfs_dev)
- sysfs_dev = malloc(sizeof *sysfs_dev);
- if (!sysfs_dev) {
- ret = ENOMEM;
- goto out;
- }
-
- snprintf(sysfs_dev->sysfs_path, sizeof sysfs_dev->sysfs_path,
- "%s/uverbs%d", class_path, i);
-
- snprintf(sysfs_dev->sysfs_name, sizeof sysfs_dev->sysfs_name,
- "uverbs%d", i);
-
- if (ibv_read_sysfs_file(sysfs_dev->sysfs_path, "ibdev",
- sysfs_dev->ibdev_name,
- sizeof sysfs_dev->ibdev_name) < 0)
- continue;
-
- snprintf(sysfs_dev->ibdev_path, sizeof sysfs_dev->ibdev_path,
- "%s/class/infiniband/%s", ibv_get_sysfs_path(),
- sysfs_dev->ibdev_name);
-
- sysfs_dev->next = sysfs_dev_list;
- sysfs_dev->have_driver = 0;
- if (ibv_read_sysfs_file(sysfs_dev->sysfs_path, "abi_version",
- value, sizeof value) > 0)
- sysfs_dev->abi_ver = strtol(value, NULL, 10);
- else
- sysfs_dev->abi_ver = 0;
-
- sysfs_dev_list = sysfs_dev;
- sysfs_dev = NULL;
- }
-
- out:
- if (sysfs_dev)
- free(sysfs_dev);
-
- return ret;
-
-#endif
-}
-
-void ibv_register_driver(const char *name, ibv_driver_init_func init_func)
-{
- struct ibv_driver *driver;
-
- driver = malloc(sizeof *driver);
- if (!driver) {
- fprintf(stderr, PFX "Warning: couldn't allocate driver for %s\n", name);
- return;
- }
-
- driver->name = name;
- driver->init_func = init_func;
- driver->next = NULL;
-
- if (tail_driver)
- tail_driver->next = driver;
- else
- head_driver = driver;
- tail_driver = driver;
-}
-
-static void load_driver(const char *name)
-{
- char *so_name;
- void *dlhandle;
-
-#define __IBV_QUOTE(x) #x
-#define IBV_QUOTE(x) __IBV_QUOTE(x)
-
- if (asprintf(&so_name,
- name[0] == '/' ?
- "%s-" IBV_QUOTE(IBV_DEVICE_LIBRARY_EXTENSION) ".so" :
- "lib%s-" IBV_QUOTE(IBV_DEVICE_LIBRARY_EXTENSION) ".so",
- name) < 0) {
- fprintf(stderr, PFX "Warning: couldn't load driver '%s'.\n",
- name);
- return;
- }
-
- dlhandle = dlopen(so_name, RTLD_NOW);
- if (!dlhandle) {
- fprintf(stderr, PFX "Warning: couldn't load driver '%s': %s\n",
- name, dlerror());
- goto out;
- }
-
-out:
- free(so_name);
-}
-
-static void load_drivers(void)
-{
- struct ibv_driver_name *name, *next_name;
- const char *env;
- char *list, *env_name;
-
- /*
- * Only use drivers passed in through the calling user's
- * environment if we're not running setuid.
- */
- if (getuid() == geteuid()) {
- if ((env = getenv("RDMAV_DRIVERS"))) {
- list = strdupa(env);
- while ((env_name = strsep(&list, ":;")))
- load_driver(env_name);
- } else if ((env = getenv("IBV_DRIVERS"))) {
- list = strdupa(env);
- while ((env_name = strsep(&list, ":;")))
- load_driver(env_name);
- }
- }
-
- for (name = driver_name_list, next_name = name ? name->next : NULL;
- name;
- name = next_name, next_name = name ? name->next : NULL) {
- load_driver(name->name);
- free(name->name);
- free(name);
- }
-}
-
-static void read_config_file(const char *path)
-{
- FILE *conf;
- char *line = NULL;
- char *config;
- char *field;
- size_t buflen = 0;
- ssize_t len;
-
- conf = fopen(path, "r");
- if (!conf) {
- fprintf(stderr, PFX "Warning: couldn't read config file %s.\n",
- path);
- return;
- }
-
- while ((len = getline(&line, &buflen, conf)) != -1) {
- config = line + strspn(line, "\t ");
- if (config[0] == '\n' || config[0] == '#')
- continue;
-
- field = strsep(&config, "\n\t ");
-
- if (strcmp(field, "driver") == 0) {
- struct ibv_driver_name *driver_name;
-
- config += strspn(config, "\t ");
- field = strsep(&config, "\n\t ");
-
- driver_name = malloc(sizeof *driver_name);
- if (!driver_name) {
- fprintf(stderr, PFX "Warning: couldn't allocate "
- "driver name '%s'.\n", field);
- continue;
- }
-
- driver_name->name = strdup(field);
- if (!driver_name->name) {
- fprintf(stderr, PFX "Warning: couldn't allocate "
- "driver name '%s'.\n", field);
- free(driver_name);
- continue;
- }
-
- driver_name->next = driver_name_list;
- driver_name_list = driver_name;
- } else
- fprintf(stderr, PFX "Warning: ignoring bad config directive "
- "'%s' in file '%s'.\n", field, path);
- }
-
- if (line)
- free(line);
- fclose(conf);
-}
-
-static void read_config(void)
-{
- DIR *conf_dir;
- struct dirent *dent;
- char *path;
-
- conf_dir = opendir(IBV_CONFIG_DIR);
- if (!conf_dir) {
- fprintf(stderr, PFX "Warning: couldn't open config directory '%s'.\n",
- IBV_CONFIG_DIR);
- return;
- }
-
- while ((dent = readdir(conf_dir))) {
- struct stat buf;
-
- if (asprintf(&path, "%s/%s", IBV_CONFIG_DIR, dent->d_name) < 0) {
- fprintf(stderr, PFX "Warning: couldn't read config file %s/%s.\n",
- IBV_CONFIG_DIR, dent->d_name);
- return;
- }
-
- if (stat(path, &buf)) {
- fprintf(stderr, PFX "Warning: couldn't stat config file '%s'.\n",
- path);
- goto next;
- }
-
- if (!S_ISREG(buf.st_mode))
- goto next;
-
- read_config_file(path);
-next:
- free(path);
- }
-
- closedir(conf_dir);
-}
-
-static struct ibv_device *try_driver(struct ibv_driver *driver,
- struct ibv_sysfs_dev *sysfs_dev)
-{
- struct ibv_device *dev;
- char value[8];
-
- dev = driver->init_func(sysfs_dev->sysfs_path, sysfs_dev->abi_ver);
- if (!dev)
- return NULL;
-
- if (ibv_read_sysfs_file(sysfs_dev->ibdev_path, "node_type", value, sizeof value) < 0) {
- fprintf(stderr, PFX "Warning: no node_type attr under %s.\n",
- sysfs_dev->ibdev_path);
- dev->node_type = IBV_NODE_UNKNOWN;
- } else {
- dev->node_type = strtol(value, NULL, 10);
- if (dev->node_type < IBV_NODE_CA || dev->node_type > IBV_NODE_RNIC)
- dev->node_type = IBV_NODE_UNKNOWN;
- }
-out:
-
- switch (dev->node_type) {
- case IBV_NODE_CA:
- case IBV_NODE_SWITCH:
- case IBV_NODE_ROUTER:
- dev->transport_type = IBV_TRANSPORT_IB;
- break;
- case IBV_NODE_RNIC:
- dev->transport_type = IBV_TRANSPORT_IWARP;
- break;
- default:
- dev->transport_type = IBV_TRANSPORT_UNKNOWN;
- break;
- }
-
- strcpy(dev->dev_name, sysfs_dev->sysfs_name);
- strcpy(dev->dev_path, sysfs_dev->sysfs_path);
- strcpy(dev->name, sysfs_dev->ibdev_name);
- strcpy(dev->ibdev_path, sysfs_dev->ibdev_path);
-
- return dev;
-}
-
-static struct ibv_device *try_drivers(struct ibv_sysfs_dev *sysfs_dev)
-{
- struct ibv_driver *driver;
- struct ibv_device *dev;
-
- for (driver = head_driver; driver; driver = driver->next) {
- dev = try_driver(driver, sysfs_dev);
- if (dev)
- return dev;
- }
-
- return NULL;
-}
-
-static int check_abi_version(const char *path)
-{
- char value[8];
-
- if (ibv_read_sysfs_file(path, "class/infiniband_verbs/abi_version",
- value, sizeof value) < 0) {
- return ENOSYS;
- }
-
- abi_ver = strtol(value, NULL, 10);
-
- if (abi_ver < IB_USER_VERBS_MIN_ABI_VERSION ||
- abi_ver > IB_USER_VERBS_MAX_ABI_VERSION) {
- fprintf(stderr, PFX "Fatal: kernel ABI version %d "
- "doesn't match library version %d.\n",
- abi_ver, IB_USER_VERBS_MAX_ABI_VERSION);
- return ENOSYS;
- }
-
- return 0;
-}
-
-static void check_memlock_limit(void)
-{
- struct rlimit rlim;
-
- if (!geteuid())
- return;
-
- if (getrlimit(RLIMIT_MEMLOCK, &rlim)) {
- fprintf(stderr, PFX "Warning: getrlimit(RLIMIT_MEMLOCK) failed.");
- return;
- }
-
- if (rlim.rlim_cur <= 32768)
- fprintf(stderr, PFX "Warning: RLIMIT_MEMLOCK is %lu bytes.\n"
- " This will severely limit memory registrations.\n",
- rlim.rlim_cur);
-}
-
-static void add_device(struct ibv_device *dev,
- struct ibv_device ***dev_list,
- int *num_devices,
- int *list_size)
-{
- struct ibv_device **new_list;
-
- if (*list_size <= *num_devices) {
- *list_size = *list_size ? *list_size * 2 : 1;
- new_list = realloc(*dev_list, *list_size * sizeof (struct ibv_device *));
- if (!new_list)
- return;
- *dev_list = new_list;
- }
-
- (*dev_list)[(*num_devices)++] = dev;
-}
-
-HIDDEN int ibverbs_init(struct ibv_device ***list)
-{
- const char *sysfs_path;
- struct ibv_sysfs_dev *sysfs_dev, *next_dev;
- struct ibv_device *device;
- int num_devices = 0;
- int list_size = 0;
- int statically_linked = 0;
- int no_driver = 0;
- int ret;
-
- *list = NULL;
-
- if (getenv("RDMAV_FORK_SAFE") || getenv("IBV_FORK_SAFE"))
- if (ibv_fork_init())
- fprintf(stderr, PFX "Warning: fork()-safety requested "
- "but init failed\n");
-
- sysfs_path = ibv_get_sysfs_path();
- if (!sysfs_path)
- return -ENOSYS;
-
- ret = check_abi_version(sysfs_path);
- if (ret)
- return -ret;
-
- check_memlock_limit();
-
- read_config();
-
- ret = find_sysfs_devs();
- if (ret)
- return -ret;
-
- for (sysfs_dev = sysfs_dev_list; sysfs_dev; sysfs_dev = sysfs_dev->next) {
- device = try_drivers(sysfs_dev);
- if (device) {
- add_device(device, list, &num_devices, &list_size);
- sysfs_dev->have_driver = 1;
- } else
- no_driver = 1;
- }
-
- if (!no_driver)
- goto out;
-
- /*
- * Check if we can dlopen() ourselves. If this fails,
- * libibverbs is probably statically linked into the
- * executable, and we should just give up, since trying to
- * dlopen() a driver module will fail spectacularly (loading a
- * driver .so will bring in dynamic copies of libibverbs and
- * libdl to go along with the static copies the executable
- * has, which quickly leads to a crash.
- */
- {
- void *hand = dlopen(NULL, RTLD_NOW);
- if (!hand) {
- fprintf(stderr, PFX "Warning: dlopen(NULL) failed, "
- "assuming static linking.\n");
- statically_linked = 1;
- goto out;
- }
- dlclose(hand);
- }
-
- load_drivers();
-
- for (sysfs_dev = sysfs_dev_list; sysfs_dev; sysfs_dev = sysfs_dev->next) {
- if (sysfs_dev->have_driver)
- continue;
-
- device = try_drivers(sysfs_dev);
- if (device) {
- add_device(device, list, &num_devices, &list_size);
- sysfs_dev->have_driver = 1;
- }
- }
-
-out:
- for (sysfs_dev = sysfs_dev_list,
- next_dev = sysfs_dev ? sysfs_dev->next : NULL;
- sysfs_dev;
- sysfs_dev = next_dev, next_dev = sysfs_dev ? sysfs_dev->next : NULL) {
- if (!sysfs_dev->have_driver) {
- fprintf(stderr, PFX "Warning: no userspace device-specific "
- "driver found for %s\n", sysfs_dev->sysfs_path);
- if (statically_linked)
- fprintf(stderr, " When linking libibverbs statically, "
- "driver must be statically linked too.\n");
- }
- free(sysfs_dev);
- }
-
- return num_devices;
-}
diff --git a/contrib/ofed/libibverbs/src/kern_abi.h b/contrib/ofed/libibverbs/src/kern_abi.h
deleted file mode 100644
index e055e75..0000000
--- a/contrib/ofed/libibverbs/src/kern_abi.h
+++ /dev/null
@@ -1,101 +0,0 @@
-/*
- * Copyright (c) 2005 Topspin Communications. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-#ifndef KERN_ABI_H
-#define KERN_ABI_H
-
-#include <linux/types.h>
-
-/*
- * Increment this value if any changes that break userspace ABI
- * compatibility are made.
- */
-#define IB_USER_VERBS_ABI_VERSION 1
-
-enum {
- IB_USER_VERBS_CMD_GET_CONTEXT,
- IB_USER_VERBS_CMD_GET_EVENT_FDS,
- IB_USER_VERBS_CMD_ALLOC_PD,
- IB_USER_VERBS_CMD_DEALLOC_PD,
- IB_USER_VERBS_CMD_REG_MR,
- IB_USER_VERBS_CMD_DEREG_MR
-};
-
-/*
- * Make sure that all structs defined in this file remain laid out so
- * that they pack the same way on 32-bit and 64-bit architectures (to
- * avoid incompatibility between 32-bit userspace and 64-bit kernels).
- * In particular do not use pointer types -- pass pointers in __u64
- * instead.
- */
-
-struct ibv_kern_async_event {
- __u32 event_type;
- __u32 element;
-};
-
-struct ibv_comp_event {
- __u32 cq_handle;
-};
-
-/*
- * All commands from userspace should start with a __u32 command field
- * followed by __u16 in_words and out_words fields (which give the
- * length of the command block and response buffer if any in 32-bit
- * words). The kernel driver will read these fields first and read
- * the rest of the command struct based on these value.
- */
-
-struct ibv_get_context {
- __u32 command;
- __u16 in_words;
- __u16 out_words;
- __u64 response;
-};
-
-struct ibv_get_context_resp {
- __u32 num_cq_events;
-};
-
-struct ibv_get_event_fds {
- __u32 command;
- __u16 in_words;
- __u16 out_words;
- __u64 response;
-};
-
-struct ibv_get_event_fds_resp {
- __u32 async_fd;
- __u32 cq_fd[1];
-};
-
-#endif /* KERN_ABI_H */
diff --git a/contrib/ofed/libibverbs/src/libibverbs.map b/contrib/ofed/libibverbs/src/libibverbs.map
deleted file mode 100644
index 788b34b..0000000
--- a/contrib/ofed/libibverbs/src/libibverbs.map
+++ /dev/null
@@ -1,110 +0,0 @@
-IBVERBS_1.0 {
- global:
- ibv_get_device_list;
- ibv_free_device_list;
- ibv_get_device_name;
- ibv_get_device_guid;
- ibv_open_device;
- ibv_close_device;
- ibv_get_async_event;
- ibv_ack_async_event;
- ibv_query_device;
- ibv_query_port;
- ibv_query_gid;
- ibv_query_pkey;
- ibv_alloc_pd;
- ibv_dealloc_pd;
- ibv_reg_mr;
- ibv_dereg_mr;
- ibv_create_comp_channel;
- ibv_destroy_comp_channel;
- ibv_create_cq;
- ibv_resize_cq;
- ibv_destroy_cq;
- ibv_get_cq_event;
- ibv_ack_cq_events;
- ibv_create_srq;
- ibv_modify_srq;
- ibv_query_srq;
- ibv_destroy_srq;
- ibv_create_qp;
- ibv_query_qp;
- ibv_modify_qp;
- ibv_destroy_qp;
- ibv_create_ah;
- ibv_destroy_ah;
- ibv_attach_mcast;
- ibv_detach_mcast;
- ibv_cmd_get_context;
- ibv_cmd_query_device;
- ibv_cmd_query_port;
- ibv_cmd_query_gid;
- ibv_cmd_query_pkey;
- ibv_cmd_alloc_pd;
- ibv_cmd_dealloc_pd;
- ibv_cmd_reg_mr;
- ibv_cmd_dereg_mr;
- ibv_cmd_create_cq;
- ibv_cmd_poll_cq;
- ibv_cmd_req_notify_cq;
- ibv_cmd_resize_cq;
- ibv_cmd_destroy_cq;
- ibv_cmd_create_srq;
- ibv_cmd_modify_srq;
- ibv_cmd_query_srq;
- ibv_cmd_destroy_srq;
- ibv_cmd_create_qp;
- ibv_cmd_query_qp;
- ibv_cmd_modify_qp;
- ibv_cmd_destroy_qp;
- ibv_cmd_post_send;
- ibv_cmd_post_recv;
- ibv_cmd_post_srq_recv;
- ibv_cmd_create_ah;
- ibv_cmd_destroy_ah;
- ibv_cmd_attach_mcast;
- ibv_cmd_detach_mcast;
- ibv_copy_qp_attr_from_kern;
- ibv_copy_path_rec_from_kern;
- ibv_copy_path_rec_to_kern;
- ibv_rate_to_mult;
- mult_to_ibv_rate;
- ibv_get_sysfs_path;
- ibv_read_sysfs_file;
-
- local: *;
-};
-
-IBVERBS_1.1 {
- global:
- ibv_resolve_eth_gid;
-
- ibv_init_ah_from_wc;
- ibv_create_ah_from_wc;
- ibv_copy_ah_attr_from_kern;
- ibv_fork_init;
- ibv_dontfork_range;
- ibv_dofork_range;
- ibv_register_driver;
- ibv_create_xrc_srq;
- ibv_cmd_create_xrc_srq;
- ibv_open_xrc_domain;
- ibv_cmd_open_xrc_domain;
- ibv_close_xrc_domain;
- ibv_cmd_close_xrc_domain;
- ibv_create_xrc_rcv_qp;
- ibv_cmd_create_xrc_rcv_qp;
- ibv_modify_xrc_rcv_qp;
- ibv_cmd_modify_xrc_rcv_qp;
- ibv_query_xrc_rcv_qp;
- ibv_cmd_query_xrc_rcv_qp;
- ibv_reg_xrc_rcv_qp;
- ibv_cmd_reg_xrc_rcv_qp;
- ibv_unreg_xrc_rcv_qp;
- ibv_cmd_unreg_xrc_rcv_qp;
-
- ibv_node_type_str;
- ibv_port_state_str;
- ibv_event_type_str;
- ibv_wc_status_str;
-} IBVERBS_1.0;
diff --git a/contrib/ofed/libibverbs/src/marshall.c b/contrib/ofed/libibverbs/src/marshall.c
deleted file mode 100644
index 577b4b1..0000000
--- a/contrib/ofed/libibverbs/src/marshall.c
+++ /dev/null
@@ -1,142 +0,0 @@
-/*
- * Copyright (c) 2005 Intel Corporation. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-#if HAVE_CONFIG_H
-# include <config.h>
-#endif /* HAVE_CONFIG_H */
-
-#include <string.h>
-
-#include <infiniband/marshall.h>
-
-void ibv_copy_ah_attr_from_kern(struct ibv_ah_attr *dst,
- struct ibv_kern_ah_attr *src)
-{
- memcpy(dst->grh.dgid.raw, src->grh.dgid, sizeof dst->grh.dgid);
- dst->grh.flow_label = src->grh.flow_label;
- dst->grh.sgid_index = src->grh.sgid_index;
- dst->grh.hop_limit = src->grh.hop_limit;
- dst->grh.traffic_class = src->grh.traffic_class;
-
- dst->dlid = src->dlid;
- dst->sl = src->sl;
- dst->src_path_bits = src->src_path_bits;
- dst->static_rate = src->static_rate;
- dst->is_global = src->is_global;
- dst->port_num = src->port_num;
-}
-
-void ibv_copy_qp_attr_from_kern(struct ibv_qp_attr *dst,
- struct ibv_kern_qp_attr *src)
-{
- dst->cur_qp_state = src->cur_qp_state;
- dst->path_mtu = src->path_mtu;
- dst->path_mig_state = src->path_mig_state;
- dst->qkey = src->qkey;
- dst->rq_psn = src->rq_psn;
- dst->sq_psn = src->sq_psn;
- dst->dest_qp_num = src->dest_qp_num;
- dst->qp_access_flags = src->qp_access_flags;
-
- dst->cap.max_send_wr = src->max_send_wr;
- dst->cap.max_recv_wr = src->max_recv_wr;
- dst->cap.max_send_sge = src->max_send_sge;
- dst->cap.max_recv_sge = src->max_recv_sge;
- dst->cap.max_inline_data = src->max_inline_data;
-
- ibv_copy_ah_attr_from_kern(&dst->ah_attr, &src->ah_attr);
- ibv_copy_ah_attr_from_kern(&dst->alt_ah_attr, &src->alt_ah_attr);
-
- dst->pkey_index = src->pkey_index;
- dst->alt_pkey_index = src->alt_pkey_index;
- dst->en_sqd_async_notify = src->en_sqd_async_notify;
- dst->sq_draining = src->sq_draining;
- dst->max_rd_atomic = src->max_rd_atomic;
- dst->max_dest_rd_atomic = src->max_dest_rd_atomic;
- dst->min_rnr_timer = src->min_rnr_timer;
- dst->port_num = src->port_num;
- dst->timeout = src->timeout;
- dst->retry_cnt = src->retry_cnt;
- dst->rnr_retry = src->rnr_retry;
- dst->alt_port_num = src->alt_port_num;
- dst->alt_timeout = src->alt_timeout;
-}
-
-void ibv_copy_path_rec_from_kern(struct ibv_sa_path_rec *dst,
- struct ibv_kern_path_rec *src)
-{
- memcpy(dst->dgid.raw, src->dgid, sizeof dst->dgid);
- memcpy(dst->sgid.raw, src->sgid, sizeof dst->sgid);
-
- dst->dlid = src->dlid;
- dst->slid = src->slid;
- dst->raw_traffic = src->raw_traffic;
- dst->flow_label = src->flow_label;
- dst->hop_limit = src->hop_limit;
- dst->traffic_class = src->traffic_class;
- dst->reversible = src->reversible;
- dst->numb_path = src->numb_path;
- dst->pkey = src->pkey;
- dst->sl = src->sl;
- dst->mtu_selector = src->mtu_selector;
- dst->mtu = src->mtu;
- dst->rate_selector = src->rate_selector;
- dst->rate = src->rate;
- dst->packet_life_time = src->packet_life_time;
- dst->preference = src->preference;
- dst->packet_life_time_selector = src->packet_life_time_selector;
-}
-
-void ibv_copy_path_rec_to_kern(struct ibv_kern_path_rec *dst,
- struct ibv_sa_path_rec *src)
-{
- memcpy(dst->dgid, src->dgid.raw, sizeof src->dgid);
- memcpy(dst->sgid, src->sgid.raw, sizeof src->sgid);
-
- dst->dlid = src->dlid;
- dst->slid = src->slid;
- dst->raw_traffic = src->raw_traffic;
- dst->flow_label = src->flow_label;
- dst->hop_limit = src->hop_limit;
- dst->traffic_class = src->traffic_class;
- dst->reversible = src->reversible;
- dst->numb_path = src->numb_path;
- dst->pkey = src->pkey;
- dst->sl = src->sl;
- dst->mtu_selector = src->mtu_selector;
- dst->mtu = src->mtu;
- dst->rate_selector = src->rate_selector;
- dst->rate = src->rate;
- dst->packet_life_time = src->packet_life_time;
- dst->preference = src->preference;
- dst->packet_life_time_selector = src->packet_life_time_selector;
-}
diff --git a/contrib/ofed/libibverbs/src/memory.c b/contrib/ofed/libibverbs/src/memory.c
deleted file mode 100644
index 405dd5a..0000000
--- a/contrib/ofed/libibverbs/src/memory.c
+++ /dev/null
@@ -1,642 +0,0 @@
-/*
- * Copyright (c) 2004, 2005 Topspin Communications. All rights reserved.
- * Copyright (c) 2006 Cisco Systems, Inc. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-#if HAVE_CONFIG_H
-# include <config.h>
-#endif /* HAVE_CONFIG_H */
-
-#include <errno.h>
-#include <sys/mman.h>
-#include <unistd.h>
-#include <stdlib.h>
-#include <stdint.h>
-
-#include "ibverbs.h"
-
-/*
- * Most distro's headers don't have these yet.
- */
-#ifdef __linux__
-#ifndef MADV_DONTFORK
-#define MADV_DONTFORK 10
-#endif
-
-#ifndef MADV_DOFORK
-#define MADV_DOFORK 11
-#endif
-#else
-#define MADV_DONTFORK INHERIT_NONE
-#define MADV_DOFORK INHERIT_SHARE
-#endif
-
-struct ibv_mem_node {
- enum {
- IBV_RED,
- IBV_BLACK
- } color;
- struct ibv_mem_node *parent;
- struct ibv_mem_node *left, *right;
- uintptr_t start, end;
- int refcnt;
-};
-
-static struct ibv_mem_node *mm_root;
-static pthread_mutex_t mm_mutex = PTHREAD_MUTEX_INITIALIZER;
-static int page_size;
-static int too_late;
-
-int ibv_fork_init(void)
-{
-#ifdef __linux__
- void *tmp;
- int ret;
-#endif
-
- if (mm_root)
- return 0;
-
- if (too_late)
- return EINVAL;
-
- page_size = sysconf(_SC_PAGESIZE);
- if (page_size < 0)
- return errno;
-
-#ifdef __linux__
- if (posix_memalign(&tmp, page_size, page_size))
- return ENOMEM;
-
- ret = madvise(tmp, page_size, MADV_DONTFORK) ||
- madvise(tmp, page_size, MADV_DOFORK);
-
- free(tmp);
-
- if (ret)
- return ENOSYS;
-#endif
-
- mm_root = malloc(sizeof *mm_root);
- if (!mm_root)
- return ENOMEM;
-
- mm_root->parent = NULL;
- mm_root->left = NULL;
- mm_root->right = NULL;
- mm_root->color = IBV_BLACK;
- mm_root->start = 0;
- mm_root->end = UINTPTR_MAX;
- mm_root->refcnt = 0;
-
- return 0;
-}
-
-static struct ibv_mem_node *__mm_prev(struct ibv_mem_node *node)
-{
- if (node->left) {
- node = node->left;
- while (node->right)
- node = node->right;
- } else {
- while (node->parent && node == node->parent->left)
- node = node->parent;
-
- node = node->parent;
- }
-
- return node;
-}
-
-static struct ibv_mem_node *__mm_next(struct ibv_mem_node *node)
-{
- if (node->right) {
- node = node->right;
- while (node->left)
- node = node->left;
- } else {
- while (node->parent && node == node->parent->right)
- node = node->parent;
-
- node = node->parent;
- }
-
- return node;
-}
-
-static void __mm_rotate_right(struct ibv_mem_node *node)
-{
- struct ibv_mem_node *tmp;
-
- tmp = node->left;
-
- node->left = tmp->right;
- if (node->left)
- node->left->parent = node;
-
- if (node->parent) {
- if (node->parent->right == node)
- node->parent->right = tmp;
- else
- node->parent->left = tmp;
- } else
- mm_root = tmp;
-
- tmp->parent = node->parent;
-
- tmp->right = node;
- node->parent = tmp;
-}
-
-static void __mm_rotate_left(struct ibv_mem_node *node)
-{
- struct ibv_mem_node *tmp;
-
- tmp = node->right;
-
- node->right = tmp->left;
- if (node->right)
- node->right->parent = node;
-
- if (node->parent) {
- if (node->parent->right == node)
- node->parent->right = tmp;
- else
- node->parent->left = tmp;
- } else
- mm_root = tmp;
-
- tmp->parent = node->parent;
-
- tmp->left = node;
- node->parent = tmp;
-}
-
-static int verify(struct ibv_mem_node *node)
-{
- int hl, hr;
-
- if (!node)
- return 1;
-
- hl = verify(node->left);
- hr = verify(node->left);
-
- if (!hl || !hr)
- return 0;
- if (hl != hr)
- return 0;
-
- if (node->color == IBV_RED) {
- if (node->left && node->left->color != IBV_BLACK)
- return 0;
- if (node->right && node->right->color != IBV_BLACK)
- return 0;
- return hl;
- }
-
- return hl + 1;
-}
-
-static void __mm_add_rebalance(struct ibv_mem_node *node)
-{
- struct ibv_mem_node *parent, *gp, *uncle;
-
- while (node->parent && node->parent->color == IBV_RED) {
- parent = node->parent;
- gp = node->parent->parent;
-
- if (parent == gp->left) {
- uncle = gp->right;
-
- if (uncle && uncle->color == IBV_RED) {
- parent->color = IBV_BLACK;
- uncle->color = IBV_BLACK;
- gp->color = IBV_RED;
-
- node = gp;
- } else {
- if (node == parent->right) {
- __mm_rotate_left(parent);
- node = parent;
- parent = node->parent;
- }
-
- parent->color = IBV_BLACK;
- gp->color = IBV_RED;
-
- __mm_rotate_right(gp);
- }
- } else {
- uncle = gp->left;
-
- if (uncle && uncle->color == IBV_RED) {
- parent->color = IBV_BLACK;
- uncle->color = IBV_BLACK;
- gp->color = IBV_RED;
-
- node = gp;
- } else {
- if (node == parent->left) {
- __mm_rotate_right(parent);
- node = parent;
- parent = node->parent;
- }
-
- parent->color = IBV_BLACK;
- gp->color = IBV_RED;
-
- __mm_rotate_left(gp);
- }
- }
- }
-
- mm_root->color = IBV_BLACK;
-}
-
-static void __mm_add(struct ibv_mem_node *new)
-{
- struct ibv_mem_node *node, *parent = NULL;
-
- node = mm_root;
- while (node) {
- parent = node;
- if (node->start < new->start)
- node = node->right;
- else
- node = node->left;
- }
-
- if (parent->start < new->start)
- parent->right = new;
- else
- parent->left = new;
-
- new->parent = parent;
- new->left = NULL;
- new->right = NULL;
-
- new->color = IBV_RED;
- __mm_add_rebalance(new);
-}
-
-static void __mm_remove(struct ibv_mem_node *node)
-{
- struct ibv_mem_node *child, *parent, *sib, *tmp;
- int nodecol;
-
- if (node->left && node->right) {
- tmp = node->left;
- while (tmp->right)
- tmp = tmp->right;
-
- nodecol = tmp->color;
- child = tmp->left;
- tmp->color = node->color;
-
- if (tmp->parent != node) {
- parent = tmp->parent;
- parent->right = tmp->left;
- if (tmp->left)
- tmp->left->parent = parent;
-
- tmp->left = node->left;
- node->left->parent = tmp;
- } else
- parent = tmp;
-
- tmp->right = node->right;
- node->right->parent = tmp;
-
- tmp->parent = node->parent;
- if (node->parent) {
- if (node->parent->left == node)
- node->parent->left = tmp;
- else
- node->parent->right = tmp;
- } else
- mm_root = tmp;
- } else {
- nodecol = node->color;
-
- child = node->left ? node->left : node->right;
- parent = node->parent;
-
- if (child)
- child->parent = parent;
- if (parent) {
- if (parent->left == node)
- parent->left = child;
- else
- parent->right = child;
- } else
- mm_root = child;
- }
-
- free(node);
-
- if (nodecol == IBV_RED)
- return;
-
- while ((!child || child->color == IBV_BLACK) && child != mm_root) {
- if (parent->left == child) {
- sib = parent->right;
-
- if (sib->color == IBV_RED) {
- parent->color = IBV_RED;
- sib->color = IBV_BLACK;
- __mm_rotate_left(parent);
- sib = parent->right;
- }
-
- if ((!sib->left || sib->left->color == IBV_BLACK) &&
- (!sib->right || sib->right->color == IBV_BLACK)) {
- sib->color = IBV_RED;
- child = parent;
- parent = child->parent;
- } else {
- if (!sib->right || sib->right->color == IBV_BLACK) {
- if (sib->left)
- sib->left->color = IBV_BLACK;
- sib->color = IBV_RED;
- __mm_rotate_right(sib);
- sib = parent->right;
- }
-
- sib->color = parent->color;
- parent->color = IBV_BLACK;
- if (sib->right)
- sib->right->color = IBV_BLACK;
- __mm_rotate_left(parent);
- child = mm_root;
- break;
- }
- } else {
- sib = parent->left;
-
- if (sib->color == IBV_RED) {
- parent->color = IBV_RED;
- sib->color = IBV_BLACK;
- __mm_rotate_right(parent);
- sib = parent->left;
- }
-
- if ((!sib->left || sib->left->color == IBV_BLACK) &&
- (!sib->right || sib->right->color == IBV_BLACK)) {
- sib->color = IBV_RED;
- child = parent;
- parent = child->parent;
- } else {
- if (!sib->left || sib->left->color == IBV_BLACK) {
- if (sib->right)
- sib->right->color = IBV_BLACK;
- sib->color = IBV_RED;
- __mm_rotate_left(sib);
- sib = parent->left;
- }
-
- sib->color = parent->color;
- parent->color = IBV_BLACK;
- if (sib->left)
- sib->left->color = IBV_BLACK;
- __mm_rotate_right(parent);
- child = mm_root;
- break;
- }
- }
- }
-
- if (child)
- child->color = IBV_BLACK;
-}
-
-static struct ibv_mem_node *__mm_find_start(uintptr_t start, uintptr_t end)
-{
- struct ibv_mem_node *node = mm_root;
-
- while (node) {
- if (node->start <= start && node->end >= start)
- break;
-
- if (node->start < start)
- node = node->right;
- else
- node = node->left;
- }
-
- return node;
-}
-
-static struct ibv_mem_node *merge_ranges(struct ibv_mem_node *node,
- struct ibv_mem_node *prev)
-{
- prev->end = node->end;
- prev->refcnt = node->refcnt;
- __mm_remove(node);
-
- return prev;
-}
-
-static struct ibv_mem_node *split_range(struct ibv_mem_node *node,
- uintptr_t cut_line)
-{
- struct ibv_mem_node *new_node = NULL;
-
- new_node = malloc(sizeof *new_node);
- if (!new_node)
- return NULL;
- new_node->start = cut_line;
- new_node->end = node->end;
- new_node->refcnt = node->refcnt;
- node->end = cut_line - 1;
- __mm_add(new_node);
-
- return new_node;
-}
-
-static struct ibv_mem_node *get_start_node(uintptr_t start, uintptr_t end,
- int inc)
-{
- struct ibv_mem_node *node, *tmp = NULL;
-
- node = __mm_find_start(start, end);
- if (node->start < start)
- node = split_range(node, start);
- else {
- tmp = __mm_prev(node);
- if (tmp && tmp->refcnt == node->refcnt + inc)
- node = merge_ranges(node, tmp);
- }
- return node;
-}
-
-/*
- * This function is called if madvise() fails to undo merging/splitting
- * operations performed on the node.
- */
-static struct ibv_mem_node *undo_node(struct ibv_mem_node *node,
- uintptr_t start, int inc)
-{
- struct ibv_mem_node *tmp = NULL;
-
- /*
- * This condition can be true only if we merged this
- * node with the previous one, so we need to split them.
- */
- if (start > node->start) {
- tmp = split_range(node, start);
- if (tmp) {
- node->refcnt += inc;
- node = tmp;
- } else
- return NULL;
- }
-
- tmp = __mm_prev(node);
- if (tmp && tmp->refcnt == node->refcnt)
- node = merge_ranges(node, tmp);
-
- tmp = __mm_next(node);
- if (tmp && tmp->refcnt == node->refcnt)
- node = merge_ranges(tmp, node);
-
- return node;
-}
-
-static int ibv_madvise_range(void *base, size_t size, int advice)
-{
- uintptr_t start, end;
- struct ibv_mem_node *node, *tmp;
- int inc;
- int rolling_back = 0;
- int ret = 0;
-
- if (!size)
- return 0;
-
- start = (uintptr_t) base & ~(page_size - 1);
- end = ((uintptr_t) (base + size + page_size - 1) &
- ~(page_size - 1)) - 1;
-
- pthread_mutex_lock(&mm_mutex);
-again:
- inc = advice == MADV_DONTFORK ? 1 : -1;
-
- node = get_start_node(start, end, inc);
- if (!node) {
- ret = -1;
- goto out;
- }
-
- while (node && node->start <= end) {
- if (node->end > end) {
- if (!split_range(node, end + 1)) {
- ret = -1;
- goto out;
- }
- }
-
- if ((inc == -1 && node->refcnt == 1) ||
- (inc == 1 && node->refcnt == 0)) {
- /*
- * If this is the first time through the loop,
- * and we merged this node with the previous
- * one, then we only want to do the madvise()
- * on start ... node->end (rather than
- * starting at node->start).
- *
- * Otherwise we end up doing madvise() on
- * bigger region than we're being asked to,
- * and that may lead to a spurious failure.
- */
- if (start > node->start)
- ret = minherit((void *) start, node->end - start + 1,
- advice);
- else
- ret = minherit((void *) node->start,
- node->end - node->start + 1,
- advice);
- if (ret) {
- node = undo_node(node, start, inc);
-
- if (rolling_back || !node)
- goto out;
-
- /* madvise failed, roll back previous changes */
- rolling_back = 1;
- advice = advice == MADV_DONTFORK ?
- MADV_DOFORK : MADV_DONTFORK;
- tmp = __mm_prev(node);
- if (!tmp || start > tmp->end)
- goto out;
- end = tmp->end;
- goto again;
- }
- }
-
- node->refcnt += inc;
- node = __mm_next(node);
- }
-
- if (node) {
- tmp = __mm_prev(node);
- if (tmp && node->refcnt == tmp->refcnt)
- node = merge_ranges(node, tmp);
- }
-
-out:
- if (rolling_back)
- ret = -1;
-
- pthread_mutex_unlock(&mm_mutex);
-
- return ret;
-}
-
-int ibv_dontfork_range(void *base, size_t size)
-{
- if (mm_root)
- return ibv_madvise_range(base, size, MADV_DONTFORK);
- else {
- too_late = 1;
- return 0;
- }
-}
-
-int ibv_dofork_range(void *base, size_t size)
-{
- if (mm_root)
- return ibv_madvise_range(base, size, MADV_DOFORK);
- else {
- too_late = 1;
- return 0;
- }
-}
diff --git a/contrib/ofed/libibverbs/src/sysfs.c b/contrib/ofed/libibverbs/src/sysfs.c
deleted file mode 100644
index bbf05c5..0000000
--- a/contrib/ofed/libibverbs/src/sysfs.c
+++ /dev/null
@@ -1,104 +0,0 @@
-/*
- * Copyright (c) 2006 Cisco Systems, Inc. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-#if HAVE_CONFIG_H
-# include <config.h>
-#endif /* HAVE_CONFIG_H */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <string.h>
-
-#include <sys/sysctl.h>
-
-#include "ibverbs.h"
-
-static char *sysfs_path;
-
-const char *ibv_get_sysfs_path(void)
-{
- char *env = NULL;
-
- if (sysfs_path)
- return sysfs_path;
-
- /*
- * Only follow use path passed in through the calling user's
- * environment if we're not running SUID.
- */
- if (getuid() == geteuid())
- env = getenv("SYSFS_PATH");
-
- if (env) {
- int len;
-
- sysfs_path = strndup(env, IBV_SYSFS_PATH_MAX);
- len = strlen(sysfs_path);
- while (len > 0 && sysfs_path[len - 1] == '/') {
- --len;
- sysfs_path[len] = '\0';
- }
- } else
- sysfs_path = "/sys";
-
- return sysfs_path;
-}
-
-int ibv_read_sysfs_file(const char *dir, const char *file,
- char *buf, size_t size)
-{
- char *path, *s;
- int fd;
- size_t len;
-
- if (asprintf(&path, "%s/%s", dir, file) < 0)
- return -1;
-
- for (s = &path[0]; *s != '\0'; s++)
- if (*s == '/')
- *s = '.';
-
- len = size;
- if (sysctlbyname(&path[1], buf, &len, NULL, 0) == -1)
- return -1;
-
- free(path);
-
- if (len > 0 && buf[len - 1] == '\n')
- buf[--len] = '\0';
-
- return len;
-}
diff --git a/contrib/ofed/libibverbs/src/verbs.c b/contrib/ofed/libibverbs/src/verbs.c
deleted file mode 100644
index 9cbe73b..0000000
--- a/contrib/ofed/libibverbs/src/verbs.c
+++ /dev/null
@@ -1,754 +0,0 @@
-/*
- * Copyright (c) 2005 Topspin Communications. All rights reserved.
- * Copyright (c) 2006, 2007 Cisco Systems, Inc. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-#if HAVE_CONFIG_H
-# include <config.h>
-#endif /* HAVE_CONFIG_H */
-
-#include <stdio.h>
-#include <netinet/in.h>
-#include <unistd.h>
-#include <stdlib.h>
-#include <errno.h>
-#include <string.h>
-
-#include "ibverbs.h"
-
-int ibv_rate_to_mult(enum ibv_rate rate)
-{
- switch (rate) {
- case IBV_RATE_2_5_GBPS: return 1;
- case IBV_RATE_5_GBPS: return 2;
- case IBV_RATE_10_GBPS: return 4;
- case IBV_RATE_20_GBPS: return 8;
- case IBV_RATE_30_GBPS: return 12;
- case IBV_RATE_40_GBPS: return 16;
- case IBV_RATE_60_GBPS: return 24;
- case IBV_RATE_80_GBPS: return 32;
- case IBV_RATE_120_GBPS: return 48;
- default: return -1;
- }
-}
-
-enum ibv_rate mult_to_ibv_rate(int mult)
-{
- switch (mult) {
- case 1: return IBV_RATE_2_5_GBPS;
- case 2: return IBV_RATE_5_GBPS;
- case 4: return IBV_RATE_10_GBPS;
- case 8: return IBV_RATE_20_GBPS;
- case 12: return IBV_RATE_30_GBPS;
- case 16: return IBV_RATE_40_GBPS;
- case 24: return IBV_RATE_60_GBPS;
- case 32: return IBV_RATE_80_GBPS;
- case 48: return IBV_RATE_120_GBPS;
- default: return IBV_RATE_MAX;
- }
-}
-
-int __ibv_query_device(struct ibv_context *context,
- struct ibv_device_attr *device_attr)
-{
- return context->ops.query_device(context, device_attr);
-}
-default_symver(__ibv_query_device, ibv_query_device);
-
-int __ibv_query_port(struct ibv_context *context, uint8_t port_num,
- struct ibv_port_attr *port_attr)
-{
- return context->ops.query_port(context, port_num, port_attr);
-}
-default_symver(__ibv_query_port, ibv_query_port);
-
-int __ibv_query_gid(struct ibv_context *context, uint8_t port_num,
- int index, union ibv_gid *gid)
-{
- char name[24];
- char attr[41];
- uint16_t val;
- int i;
-
- snprintf(name, sizeof name, "ports/%d/gids/%d", port_num, index);
-
- if (ibv_read_sysfs_file(context->device->ibdev_path, name,
- attr, sizeof attr) < 0)
- return -1;
-
- for (i = 0; i < 8; ++i) {
- if (sscanf(attr + i * 5, "%hx", &val) != 1)
- return -1;
- gid->raw[i * 2 ] = val >> 8;
- gid->raw[i * 2 + 1] = val & 0xff;
- }
-
- return 0;
-}
-default_symver(__ibv_query_gid, ibv_query_gid);
-
-int __ibv_query_pkey(struct ibv_context *context, uint8_t port_num,
- int index, uint16_t *pkey)
-{
- char name[24];
- char attr[8];
- uint16_t val;
-
- snprintf(name, sizeof name, "ports/%d/pkeys/%d", port_num, index);
-
- if (ibv_read_sysfs_file(context->device->ibdev_path, name,
- attr, sizeof attr) < 0)
- return -1;
-
- if (sscanf(attr, "%hx", &val) != 1)
- return -1;
-
- *pkey = htons(val);
- return 0;
-}
-default_symver(__ibv_query_pkey, ibv_query_pkey);
-
-struct ibv_pd *__ibv_alloc_pd(struct ibv_context *context)
-{
- struct ibv_pd *pd;
-
- pd = context->ops.alloc_pd(context);
- if (pd)
- pd->context = context;
-
- return pd;
-}
-default_symver(__ibv_alloc_pd, ibv_alloc_pd);
-
-int __ibv_dealloc_pd(struct ibv_pd *pd)
-{
- return pd->context->ops.dealloc_pd(pd);
-}
-default_symver(__ibv_dealloc_pd, ibv_dealloc_pd);
-
-struct ibv_mr *__ibv_reg_mr(struct ibv_pd *pd, void *addr,
- size_t length, int access)
-{
- struct ibv_mr *mr;
-
- if (ibv_dontfork_range(addr, length))
- return NULL;
-
- mr = pd->context->ops.reg_mr(pd, addr, length, access);
- if (mr) {
- mr->context = pd->context;
- mr->pd = pd;
- mr->addr = addr;
- mr->length = length;
- } else
- ibv_dofork_range(addr, length);
-
- return mr;
-}
-default_symver(__ibv_reg_mr, ibv_reg_mr);
-
-int __ibv_dereg_mr(struct ibv_mr *mr)
-{
- int ret;
- void *addr = mr->addr;
- size_t length = mr->length;
-
- ret = mr->context->ops.dereg_mr(mr);
- if (!ret)
- ibv_dofork_range(addr, length);
-
- return ret;
-}
-default_symver(__ibv_dereg_mr, ibv_dereg_mr);
-
-static struct ibv_comp_channel *ibv_create_comp_channel_v2(struct ibv_context *context)
-{
- struct ibv_abi_compat_v2 *t = context->abi_compat;
- static int warned;
-
- if (!pthread_mutex_trylock(&t->in_use))
- return &t->channel;
-
- if (!warned) {
- fprintf(stderr, PFX "Warning: kernel's ABI version %d limits capacity.\n"
- " Only one completion channel can be created per context.\n",
- abi_ver);
- ++warned;
- }
-
- return NULL;
-}
-
-struct ibv_comp_channel *ibv_create_comp_channel(struct ibv_context *context)
-{
- struct ibv_comp_channel *channel;
- struct ibv_create_comp_channel cmd;
- struct ibv_create_comp_channel_resp resp;
-
- if (abi_ver <= 2)
- return ibv_create_comp_channel_v2(context);
-
- channel = malloc(sizeof *channel);
- if (!channel)
- return NULL;
-
- IBV_INIT_CMD_RESP(&cmd, sizeof cmd, CREATE_COMP_CHANNEL, &resp, sizeof resp);
- if (write(context->cmd_fd, &cmd, sizeof cmd) != sizeof cmd) {
- free(channel);
- return NULL;
- }
-
- VALGRIND_MAKE_MEM_DEFINED(&resp, sizeof resp);
-
- channel->context = context;
- channel->fd = resp.fd;
- channel->refcnt = 0;
-
- return channel;
-}
-
-static int ibv_destroy_comp_channel_v2(struct ibv_comp_channel *channel)
-{
- struct ibv_abi_compat_v2 *t = (struct ibv_abi_compat_v2 *) channel;
- pthread_mutex_unlock(&t->in_use);
- return 0;
-}
-
-int ibv_destroy_comp_channel(struct ibv_comp_channel *channel)
-{
- struct ibv_context *context;
- int ret;
-
- context = channel->context;
- pthread_mutex_lock(&context->mutex);
-
- if (channel->refcnt) {
- ret = EBUSY;
- goto out;
- }
-
- if (abi_ver <= 2) {
- ret = ibv_destroy_comp_channel_v2(channel);
- goto out;
- }
-
- close(channel->fd);
- free(channel);
- ret = 0;
-
-out:
- pthread_mutex_unlock(&context->mutex);
-
- return ret;
-}
-
-struct ibv_cq *__ibv_create_cq(struct ibv_context *context, int cqe, void *cq_context,
- struct ibv_comp_channel *channel, int comp_vector)
-{
- struct ibv_cq *cq;
-
- pthread_mutex_lock(&context->mutex);
-
- cq = context->ops.create_cq(context, cqe, channel, comp_vector);
-
- if (cq) {
- cq->context = context;
- cq->channel = channel;
- if (channel)
- ++channel->refcnt;
- cq->cq_context = cq_context;
- cq->comp_events_completed = 0;
- cq->async_events_completed = 0;
- pthread_mutex_init(&cq->mutex, NULL);
- pthread_cond_init(&cq->cond, NULL);
- }
-
- pthread_mutex_unlock(&context->mutex);
-
- return cq;
-}
-default_symver(__ibv_create_cq, ibv_create_cq);
-
-int __ibv_resize_cq(struct ibv_cq *cq, int cqe)
-{
- if (!cq->context->ops.resize_cq)
- return ENOSYS;
-
- return cq->context->ops.resize_cq(cq, cqe);
-}
-default_symver(__ibv_resize_cq, ibv_resize_cq);
-
-int __ibv_destroy_cq(struct ibv_cq *cq)
-{
- struct ibv_comp_channel *channel = cq->channel;
- int ret;
-
- if (channel)
- pthread_mutex_lock(&channel->context->mutex);
-
- ret = cq->context->ops.destroy_cq(cq);
-
- if (channel) {
- if (!ret)
- --channel->refcnt;
- pthread_mutex_unlock(&channel->context->mutex);
- }
-
- return ret;
-}
-default_symver(__ibv_destroy_cq, ibv_destroy_cq);
-
-int __ibv_get_cq_event(struct ibv_comp_channel *channel,
- struct ibv_cq **cq, void **cq_context)
-{
- struct ibv_comp_event ev;
-
- if (read(channel->fd, &ev, sizeof ev) != sizeof ev)
- return -1;
-
- *cq = (struct ibv_cq *) (uintptr_t) ev.cq_handle;
- *cq_context = (*cq)->cq_context;
-
- if ((*cq)->context->ops.cq_event)
- (*cq)->context->ops.cq_event(*cq);
-
- return 0;
-}
-default_symver(__ibv_get_cq_event, ibv_get_cq_event);
-
-void __ibv_ack_cq_events(struct ibv_cq *cq, unsigned int nevents)
-{
- pthread_mutex_lock(&cq->mutex);
- cq->comp_events_completed += nevents;
- pthread_cond_signal(&cq->cond);
- pthread_mutex_unlock(&cq->mutex);
-}
-default_symver(__ibv_ack_cq_events, ibv_ack_cq_events);
-
-struct ibv_srq *__ibv_create_srq(struct ibv_pd *pd,
- struct ibv_srq_init_attr *srq_init_attr)
-{
- struct ibv_srq *srq;
-
- if (!pd->context->ops.create_srq)
- return NULL;
-
- srq = pd->context->ops.create_srq(pd, srq_init_attr);
- if (srq) {
- srq->context = pd->context;
- srq->srq_context = srq_init_attr->srq_context;
- srq->pd = pd;
- srq->xrc_domain = NULL;
- srq->xrc_cq = NULL;
- srq->xrc_srq_num = 0;
- srq->events_completed = 0;
- pthread_mutex_init(&srq->mutex, NULL);
- pthread_cond_init(&srq->cond, NULL);
- }
-
- return srq;
-}
-default_symver(__ibv_create_srq, ibv_create_srq);
-
-struct ibv_srq *ibv_create_xrc_srq(struct ibv_pd *pd,
- struct ibv_xrc_domain *xrc_domain,
- struct ibv_cq *xrc_cq,
- struct ibv_srq_init_attr *srq_init_attr)
-{
- struct ibv_srq *srq;
-
- if (!pd->context->more_ops)
- return NULL;
-
- srq = pd->context->more_ops->create_xrc_srq(pd, xrc_domain,
- xrc_cq, srq_init_attr);
- if (srq) {
- srq->context = pd->context;
- srq->srq_context = srq_init_attr->srq_context;
- srq->pd = pd;
- srq->xrc_domain = xrc_domain;
- srq->xrc_cq = xrc_cq;
- srq->events_completed = 0;
- pthread_mutex_init(&srq->mutex, NULL);
- pthread_cond_init(&srq->cond, NULL);
- }
-
- return srq;
-}
-
-int __ibv_modify_srq(struct ibv_srq *srq,
- struct ibv_srq_attr *srq_attr,
- int srq_attr_mask)
-{
- return srq->context->ops.modify_srq(srq, srq_attr, srq_attr_mask);
-}
-default_symver(__ibv_modify_srq, ibv_modify_srq);
-
-int __ibv_query_srq(struct ibv_srq *srq, struct ibv_srq_attr *srq_attr)
-{
- return srq->context->ops.query_srq(srq, srq_attr);
-}
-default_symver(__ibv_query_srq, ibv_query_srq);
-
-int __ibv_destroy_srq(struct ibv_srq *srq)
-{
- return srq->context->ops.destroy_srq(srq);
-}
-default_symver(__ibv_destroy_srq, ibv_destroy_srq);
-
-struct ibv_qp *__ibv_create_qp(struct ibv_pd *pd,
- struct ibv_qp_init_attr *qp_init_attr)
-{
- struct ibv_qp *qp = pd->context->ops.create_qp(pd, qp_init_attr);
-
- if (qp) {
- qp->context = pd->context;
- qp->qp_context = qp_init_attr->qp_context;
- qp->pd = pd;
- qp->send_cq = qp_init_attr->send_cq;
- qp->recv_cq = qp_init_attr->recv_cq;
- qp->srq = qp_init_attr->srq;
- qp->qp_type = qp_init_attr->qp_type;
- qp->state = IBV_QPS_RESET;
- qp->events_completed = 0;
- qp->xrc_domain = qp_init_attr->qp_type == IBV_QPT_XRC ?
- qp_init_attr->xrc_domain : NULL;
- pthread_mutex_init(&qp->mutex, NULL);
- pthread_cond_init(&qp->cond, NULL);
- }
-
- return qp;
-}
-default_symver(__ibv_create_qp, ibv_create_qp);
-
-int __ibv_query_qp(struct ibv_qp *qp, struct ibv_qp_attr *attr,
- int attr_mask,
- struct ibv_qp_init_attr *init_attr)
-{
- int ret;
-
- ret = qp->context->ops.query_qp(qp, attr, attr_mask, init_attr);
- if (ret)
- return ret;
-
- if (attr_mask & IBV_QP_STATE)
- qp->state = attr->qp_state;
-
- return 0;
-}
-default_symver(__ibv_query_qp, ibv_query_qp);
-
-int __ibv_modify_qp(struct ibv_qp *qp, struct ibv_qp_attr *attr,
- int attr_mask)
-{
- int ret;
-
- ret = qp->context->ops.modify_qp(qp, attr, attr_mask);
- if (ret)
- return ret;
-
- if (attr_mask & IBV_QP_STATE)
- qp->state = attr->qp_state;
-
- return 0;
-}
-default_symver(__ibv_modify_qp, ibv_modify_qp);
-
-int __ibv_destroy_qp(struct ibv_qp *qp)
-{
- return qp->context->ops.destroy_qp(qp);
-}
-default_symver(__ibv_destroy_qp, ibv_destroy_qp);
-
-struct ibv_ah *__ibv_create_ah(struct ibv_pd *pd, struct ibv_ah_attr *attr)
-{
- struct ibv_ah *ah = pd->context->ops.create_ah(pd, attr);
-
- if (ah) {
- ah->context = pd->context;
- ah->pd = pd;
- }
-
- return ah;
-}
-default_symver(__ibv_create_ah, ibv_create_ah);
-
-static int ibv_find_gid_index(struct ibv_context *context, uint8_t port_num,
- union ibv_gid *gid)
-{
- union ibv_gid sgid;
- int i = 0, ret;
-
- do {
- ret = ibv_query_gid(context, port_num, i++, &sgid);
- } while (!ret && memcmp(&sgid, gid, sizeof *gid));
-
- return ret ? ret : i - 1;
-}
-
-int ibv_init_ah_from_wc(struct ibv_context *context, uint8_t port_num,
- struct ibv_wc *wc, struct ibv_grh *grh,
- struct ibv_ah_attr *ah_attr)
-{
- uint32_t flow_class;
- int ret;
-
- memset(ah_attr, 0, sizeof *ah_attr);
- ah_attr->dlid = wc->slid;
- ah_attr->sl = wc->sl;
- ah_attr->src_path_bits = wc->dlid_path_bits;
- ah_attr->port_num = port_num;
-
- if (wc->wc_flags & IBV_WC_GRH) {
- ah_attr->is_global = 1;
- ah_attr->grh.dgid = grh->sgid;
-
- ret = ibv_find_gid_index(context, port_num, &grh->dgid);
- if (ret < 0)
- return ret;
-
- ah_attr->grh.sgid_index = (uint8_t) ret;
- flow_class = ntohl(grh->version_tclass_flow);
- ah_attr->grh.flow_label = flow_class & 0xFFFFF;
- ah_attr->grh.hop_limit = grh->hop_limit;
- ah_attr->grh.traffic_class = (flow_class >> 20) & 0xFF;
- }
- return 0;
-}
-
-struct ibv_ah *ibv_create_ah_from_wc(struct ibv_pd *pd, struct ibv_wc *wc,
- struct ibv_grh *grh, uint8_t port_num)
-{
- struct ibv_ah_attr ah_attr;
- int ret;
-
- ret = ibv_init_ah_from_wc(pd->context, port_num, wc, grh, &ah_attr);
- if (ret)
- return NULL;
-
- return ibv_create_ah(pd, &ah_attr);
-}
-
-int __ibv_destroy_ah(struct ibv_ah *ah)
-{
- return ah->context->ops.destroy_ah(ah);
-}
-default_symver(__ibv_destroy_ah, ibv_destroy_ah);
-
-int __ibv_attach_mcast(struct ibv_qp *qp, const union ibv_gid *gid, uint16_t lid)
-{
- return qp->context->ops.attach_mcast(qp, gid, lid);
-}
-default_symver(__ibv_attach_mcast, ibv_attach_mcast);
-
-int __ibv_detach_mcast(struct ibv_qp *qp, const union ibv_gid *gid, uint16_t lid)
-{
- return qp->context->ops.detach_mcast(qp, gid, lid);
-}
-default_symver(__ibv_detach_mcast, ibv_detach_mcast);
-
-struct ibv_xrc_domain *ibv_open_xrc_domain(struct ibv_context *context,
- int fd, int oflag)
-{
- struct ibv_xrc_domain *d;
-
- if (!context->more_ops)
- return NULL;
-
- d = context->more_ops->open_xrc_domain(context, fd, oflag);
- if (d)
- d->context = context;
-
- return d;
-}
-
-int ibv_close_xrc_domain(struct ibv_xrc_domain *d)
-{
- if (!d->context->more_ops)
- return 0;
-
- return d->context->more_ops->close_xrc_domain(d);
-}
-
-int ibv_create_xrc_rcv_qp(struct ibv_qp_init_attr *init_attr,
- uint32_t *xrc_rcv_qpn)
-{
- struct ibv_context *c;
- if (!init_attr || !(init_attr->xrc_domain))
- return EINVAL;
-
- c = init_attr->xrc_domain->context;
- if (!c->more_ops)
- return ENOSYS;
-
- return c->more_ops->create_xrc_rcv_qp(init_attr,
- xrc_rcv_qpn);
-}
-
-int ibv_modify_xrc_rcv_qp(struct ibv_xrc_domain *d,
- uint32_t xrc_rcv_qpn,
- struct ibv_qp_attr *attr,
- int attr_mask)
-{
- if (!d || !attr)
- return EINVAL;
-
- if (!d->context->more_ops)
- return ENOSYS;
-
- return d->context->more_ops->modify_xrc_rcv_qp(d, xrc_rcv_qpn, attr,
- attr_mask);
-}
-
-int ibv_query_xrc_rcv_qp(struct ibv_xrc_domain *d,
- uint32_t xrc_rcv_qpn,
- struct ibv_qp_attr *attr,
- int attr_mask,
- struct ibv_qp_init_attr *init_attr)
-{
- if (!d)
- return EINVAL;
-
- if (!d->context->more_ops)
- return ENOSYS;
-
- return d->context->more_ops->query_xrc_rcv_qp(d, xrc_rcv_qpn, attr,
- attr_mask, init_attr);
-}
-
-int ibv_reg_xrc_rcv_qp(struct ibv_xrc_domain *d,
- uint32_t xrc_rcv_qpn)
-{
- return d->context->more_ops->reg_xrc_rcv_qp(d, xrc_rcv_qpn);
-}
-
-int ibv_unreg_xrc_rcv_qp(struct ibv_xrc_domain *d,
- uint32_t xrc_rcv_qpn)
-{
- return d->context->more_ops->unreg_xrc_rcv_qp(d, xrc_rcv_qpn);
-}
-
-
-static uint16_t get_vlan_id(const union ibv_gid *dgid)
-{
- return dgid->raw[11] << 8 | dgid->raw[12];
-}
-
-static void get_ll_mac(const union ibv_gid *gid, uint8_t *mac)
-{
- memcpy(mac, &gid->raw[8], 3);
- memcpy(mac + 3, &gid->raw[13], 3);
- mac[0] ^= 2;
-}
-
-static int is_multicast_gid(const union ibv_gid *gid)
-{
- return gid->raw[0] == 0xff;
-}
-
-static void get_mcast_mac(const union ibv_gid *gid, uint8_t *mac)
-{
- int i;
-
- mac[0] = 0x33;
- mac[1] = 0x33;
- for (i = 2; i < 6; ++i)
- mac[i] = gid->raw[i + 10];
-}
-
-static int is_link_local_gid(const union ibv_gid *gid)
-{
- uint32_t hi = *(uint32_t *)(gid->raw);
- uint32_t lo = *(uint32_t *)(gid->raw + 4);
- if (hi == htonl(0xfe800000) && lo == 0)
- return 1;
-
- return 0;
-}
-
-static int resolve_gid(const union ibv_gid *dgid, uint8_t *mac, uint8_t *is_mcast)
-{
- if (is_link_local_gid(dgid)) {
- get_ll_mac(dgid, mac);
- *is_mcast = 0;
- } else if (is_multicast_gid(dgid)) {
- get_mcast_mac(dgid, mac);
- *is_mcast = 1;
- } else
- return -EINVAL;
-
- return 0;
-}
-
-static int is_tagged_vlan(const union ibv_gid *gid)
-{
- uint16_t tag;
-
- tag = gid->raw[11] << 8 | gid->raw[12];
-
- return tag < 0x1000;
-}
-
-int __ibv_resolve_eth_gid(const struct ibv_pd *pd, uint8_t port_num,
- union ibv_gid *dgid, uint8_t sgid_index,
- uint8_t mac[], uint16_t *vlan, uint8_t *tagged,
- uint8_t *is_mcast)
-{
- int err;
- union ibv_gid sgid;
- int stagged, svlan;
-
- err = resolve_gid(dgid, mac, is_mcast);
- if (err)
- return err;
-
- err = ibv_query_gid(pd->context, port_num, sgid_index, &sgid);
- if (err)
- return err;
-
- stagged = is_tagged_vlan(&sgid);
- if (stagged) {
- if (!is_tagged_vlan(dgid) && !is_mcast)
- return -1;
-
- svlan = get_vlan_id(&sgid);
- if (svlan != get_vlan_id(dgid) && !is_mcast)
- return -1;
-
- *tagged = 1;
- *vlan = svlan;
- } else
- *tagged = 0;
-
- return 0;
-}
-default_symver(__ibv_resolve_eth_gid, ibv_resolve_eth_gid);
-
diff --git a/contrib/ofed/libibverbs/sysfs.c b/contrib/ofed/libibverbs/sysfs.c
new file mode 100644
index 0000000..0ea19fc
--- /dev/null
+++ b/contrib/ofed/libibverbs/sysfs.c
@@ -0,0 +1,102 @@
+/*
+ * Copyright (c) 2006 Cisco Systems, Inc. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+#define _GNU_SOURCE
+#include <config.h>
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <string.h>
+#include <sys/sysctl.h>
+
+#include "ibverbs.h"
+
+static const char *sysfs_path;
+
+const char *ibv_get_sysfs_path(void)
+{
+ const char *env = NULL;
+
+ if (sysfs_path)
+ return sysfs_path;
+
+ /*
+ * Only follow use path passed in through the calling user's
+ * environment if we're not running SUID.
+ */
+ if (getuid() == geteuid())
+ env = getenv("SYSFS_PATH");
+
+ if (env) {
+ int len;
+ char *dup;
+
+ sysfs_path = dup = strndup(env, IBV_SYSFS_PATH_MAX);
+ len = strlen(dup);
+ while (len > 0 && dup[len - 1] == '/') {
+ --len;
+ dup[len] = '\0';
+ }
+ } else
+ sysfs_path = "/sys";
+
+ return sysfs_path;
+}
+
+int ibv_read_sysfs_file(const char *dir, const char *file,
+ char *buf, size_t size)
+{
+ char *path, *s;
+ int fd;
+ size_t len;
+
+ if (asprintf(&path, "%s/%s", dir, file) < 0)
+ return -1;
+
+ for (s = &path[0]; *s != '\0'; s++)
+ if (*s == '/')
+ *s = '.';
+
+ len = size;
+ if (sysctlbyname(&path[1], buf, &len, NULL, 0) == -1)
+ return -1;
+
+ free(path);
+
+ if (len > 0 && buf[len - 1] == '\n')
+ buf[--len] = '\0';
+
+ return len;
+}
diff --git a/contrib/ofed/libibverbs/verbs.c b/contrib/ofed/libibverbs/verbs.c
new file mode 100644
index 0000000..f288261
--- /dev/null
+++ b/contrib/ofed/libibverbs/verbs.c
@@ -0,0 +1,1021 @@
+/*
+ * Copyright (c) 2005 Topspin Communications. All rights reserved.
+ * Copyright (c) 2006, 2007 Cisco Systems, Inc. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#define _GNU_SOURCE
+#include <config.h>
+
+#include <infiniband/endian.h>
+#include <stdio.h>
+#include <unistd.h>
+#include <stdlib.h>
+#include <errno.h>
+#include <string.h>
+#include <dirent.h>
+#include <netinet/in.h>
+#include <netinet/ip.h>
+#include <sys/socket.h>
+
+#include "ibverbs.h"
+#ifndef NRESOLVE_NEIGH
+#include <net/if.h>
+#include <net/if_arp.h>
+#include "neigh.h"
+#endif
+
+/* Hack to avoid GCC's -Wmissing-prototypes and the similar error from sparse
+ with these prototypes. Symbol versionining requires the goofy names, the
+ prototype must match the version in verbs.h.
+ */
+int __ibv_query_device(struct ibv_context *context,
+ struct ibv_device_attr *device_attr);
+int __ibv_query_port(struct ibv_context *context, uint8_t port_num,
+ struct ibv_port_attr *port_attr);
+int __ibv_query_gid(struct ibv_context *context, uint8_t port_num, int index,
+ union ibv_gid *gid);
+int __ibv_query_pkey(struct ibv_context *context, uint8_t port_num, int index,
+ __be16 *pkey);
+struct ibv_pd *__ibv_alloc_pd(struct ibv_context *context);
+int __ibv_dealloc_pd(struct ibv_pd *pd);
+struct ibv_mr *__ibv_reg_mr(struct ibv_pd *pd, void *addr, size_t length,
+ int access);
+int __ibv_rereg_mr(struct ibv_mr *mr, int flags, struct ibv_pd *pd, void *addr,
+ size_t length, int access);
+int __ibv_dereg_mr(struct ibv_mr *mr);
+struct ibv_cq *__ibv_create_cq(struct ibv_context *context, int cqe,
+ void *cq_context,
+ struct ibv_comp_channel *channel,
+ int comp_vector);
+int __ibv_resize_cq(struct ibv_cq *cq, int cqe);
+int __ibv_destroy_cq(struct ibv_cq *cq);
+int __ibv_get_cq_event(struct ibv_comp_channel *channel, struct ibv_cq **cq,
+ void **cq_context);
+void __ibv_ack_cq_events(struct ibv_cq *cq, unsigned int nevents);
+struct ibv_srq *__ibv_create_srq(struct ibv_pd *pd,
+ struct ibv_srq_init_attr *srq_init_attr);
+int __ibv_modify_srq(struct ibv_srq *srq, struct ibv_srq_attr *srq_attr,
+ int srq_attr_mask);
+int __ibv_query_srq(struct ibv_srq *srq, struct ibv_srq_attr *srq_attr);
+int __ibv_destroy_srq(struct ibv_srq *srq);
+struct ibv_qp *__ibv_create_qp(struct ibv_pd *pd,
+ struct ibv_qp_init_attr *qp_init_attr);
+int __ibv_query_qp(struct ibv_qp *qp, struct ibv_qp_attr *attr, int attr_mask,
+ struct ibv_qp_init_attr *init_attr);
+int __ibv_modify_qp(struct ibv_qp *qp, struct ibv_qp_attr *attr, int attr_mask);
+int __ibv_destroy_qp(struct ibv_qp *qp);
+struct ibv_ah *__ibv_create_ah(struct ibv_pd *pd, struct ibv_ah_attr *attr);
+int __ibv_destroy_ah(struct ibv_ah *ah);
+int __ibv_attach_mcast(struct ibv_qp *qp, const union ibv_gid *gid,
+ uint16_t lid);
+int __ibv_detach_mcast(struct ibv_qp *qp, const union ibv_gid *gid,
+ uint16_t lid);
+
+int __attribute__((const)) ibv_rate_to_mult(enum ibv_rate rate)
+{
+ switch (rate) {
+ case IBV_RATE_2_5_GBPS: return 1;
+ case IBV_RATE_5_GBPS: return 2;
+ case IBV_RATE_10_GBPS: return 4;
+ case IBV_RATE_20_GBPS: return 8;
+ case IBV_RATE_30_GBPS: return 12;
+ case IBV_RATE_40_GBPS: return 16;
+ case IBV_RATE_60_GBPS: return 24;
+ case IBV_RATE_80_GBPS: return 32;
+ case IBV_RATE_120_GBPS: return 48;
+ default: return -1;
+ }
+}
+
+enum ibv_rate __attribute__((const)) mult_to_ibv_rate(int mult)
+{
+ switch (mult) {
+ case 1: return IBV_RATE_2_5_GBPS;
+ case 2: return IBV_RATE_5_GBPS;
+ case 4: return IBV_RATE_10_GBPS;
+ case 8: return IBV_RATE_20_GBPS;
+ case 12: return IBV_RATE_30_GBPS;
+ case 16: return IBV_RATE_40_GBPS;
+ case 24: return IBV_RATE_60_GBPS;
+ case 32: return IBV_RATE_80_GBPS;
+ case 48: return IBV_RATE_120_GBPS;
+ default: return IBV_RATE_MAX;
+ }
+}
+
+int __attribute__((const)) ibv_rate_to_mbps(enum ibv_rate rate)
+{
+ switch (rate) {
+ case IBV_RATE_2_5_GBPS: return 2500;
+ case IBV_RATE_5_GBPS: return 5000;
+ case IBV_RATE_10_GBPS: return 10000;
+ case IBV_RATE_20_GBPS: return 20000;
+ case IBV_RATE_30_GBPS: return 30000;
+ case IBV_RATE_40_GBPS: return 40000;
+ case IBV_RATE_60_GBPS: return 60000;
+ case IBV_RATE_80_GBPS: return 80000;
+ case IBV_RATE_120_GBPS: return 120000;
+ case IBV_RATE_14_GBPS: return 14062;
+ case IBV_RATE_56_GBPS: return 56250;
+ case IBV_RATE_112_GBPS: return 112500;
+ case IBV_RATE_168_GBPS: return 168750;
+ case IBV_RATE_25_GBPS: return 25781;
+ case IBV_RATE_100_GBPS: return 103125;
+ case IBV_RATE_200_GBPS: return 206250;
+ case IBV_RATE_300_GBPS: return 309375;
+ default: return -1;
+ }
+}
+
+enum ibv_rate __attribute__((const)) mbps_to_ibv_rate(int mbps)
+{
+ switch (mbps) {
+ case 2500: return IBV_RATE_2_5_GBPS;
+ case 5000: return IBV_RATE_5_GBPS;
+ case 10000: return IBV_RATE_10_GBPS;
+ case 20000: return IBV_RATE_20_GBPS;
+ case 30000: return IBV_RATE_30_GBPS;
+ case 40000: return IBV_RATE_40_GBPS;
+ case 60000: return IBV_RATE_60_GBPS;
+ case 80000: return IBV_RATE_80_GBPS;
+ case 120000: return IBV_RATE_120_GBPS;
+ case 14062: return IBV_RATE_14_GBPS;
+ case 56250: return IBV_RATE_56_GBPS;
+ case 112500: return IBV_RATE_112_GBPS;
+ case 168750: return IBV_RATE_168_GBPS;
+ case 25781: return IBV_RATE_25_GBPS;
+ case 103125: return IBV_RATE_100_GBPS;
+ case 206250: return IBV_RATE_200_GBPS;
+ case 309375: return IBV_RATE_300_GBPS;
+ default: return IBV_RATE_MAX;
+ }
+}
+
+int __ibv_query_device(struct ibv_context *context,
+ struct ibv_device_attr *device_attr)
+{
+ return context->ops.query_device(context, device_attr);
+}
+default_symver(__ibv_query_device, ibv_query_device);
+
+int __ibv_query_port(struct ibv_context *context, uint8_t port_num,
+ struct ibv_port_attr *port_attr)
+{
+ return context->ops.query_port(context, port_num, port_attr);
+}
+default_symver(__ibv_query_port, ibv_query_port);
+
+int __ibv_query_gid(struct ibv_context *context, uint8_t port_num,
+ int index, union ibv_gid *gid)
+{
+ char name[24];
+ char attr[41];
+ uint16_t val;
+ int i;
+
+ snprintf(name, sizeof name, "ports/%d/gids/%d", port_num, index);
+
+ if (ibv_read_sysfs_file(context->device->ibdev_path, name,
+ attr, sizeof attr) < 0)
+ return -1;
+
+ for (i = 0; i < 8; ++i) {
+ if (sscanf(attr + i * 5, "%hx", &val) != 1)
+ return -1;
+ gid->raw[i * 2 ] = val >> 8;
+ gid->raw[i * 2 + 1] = val & 0xff;
+ }
+
+ return 0;
+}
+default_symver(__ibv_query_gid, ibv_query_gid);
+
+int __ibv_query_pkey(struct ibv_context *context, uint8_t port_num,
+ int index, __be16 *pkey)
+{
+ char name[24];
+ char attr[8];
+ uint16_t val;
+
+ snprintf(name, sizeof name, "ports/%d/pkeys/%d", port_num, index);
+
+ if (ibv_read_sysfs_file(context->device->ibdev_path, name,
+ attr, sizeof attr) < 0)
+ return -1;
+
+ if (sscanf(attr, "%hx", &val) != 1)
+ return -1;
+
+ *pkey = htobe16(val);
+ return 0;
+}
+default_symver(__ibv_query_pkey, ibv_query_pkey);
+
+struct ibv_pd *__ibv_alloc_pd(struct ibv_context *context)
+{
+ struct ibv_pd *pd;
+
+ pd = context->ops.alloc_pd(context);
+ if (pd)
+ pd->context = context;
+
+ return pd;
+}
+default_symver(__ibv_alloc_pd, ibv_alloc_pd);
+
+int __ibv_dealloc_pd(struct ibv_pd *pd)
+{
+ return pd->context->ops.dealloc_pd(pd);
+}
+default_symver(__ibv_dealloc_pd, ibv_dealloc_pd);
+
+struct ibv_mr *__ibv_reg_mr(struct ibv_pd *pd, void *addr,
+ size_t length, int access)
+{
+ struct ibv_mr *mr;
+
+ if (ibv_dontfork_range(addr, length))
+ return NULL;
+
+ mr = pd->context->ops.reg_mr(pd, addr, length, access);
+ if (mr) {
+ mr->context = pd->context;
+ mr->pd = pd;
+ mr->addr = addr;
+ mr->length = length;
+ } else
+ ibv_dofork_range(addr, length);
+
+ return mr;
+}
+default_symver(__ibv_reg_mr, ibv_reg_mr);
+
+int __ibv_rereg_mr(struct ibv_mr *mr, int flags,
+ struct ibv_pd *pd, void *addr,
+ size_t length, int access)
+{
+ int dofork_onfail = 0;
+ int err;
+ void *old_addr;
+ size_t old_len;
+
+ if (flags & ~IBV_REREG_MR_FLAGS_SUPPORTED) {
+ errno = EINVAL;
+ return IBV_REREG_MR_ERR_INPUT;
+ }
+
+ if ((flags & IBV_REREG_MR_CHANGE_TRANSLATION) &&
+ (!length || !addr)) {
+ errno = EINVAL;
+ return IBV_REREG_MR_ERR_INPUT;
+ }
+
+ if (access && !(flags & IBV_REREG_MR_CHANGE_ACCESS)) {
+ errno = EINVAL;
+ return IBV_REREG_MR_ERR_INPUT;
+ }
+
+ if (!mr->context->ops.rereg_mr) {
+ errno = ENOSYS;
+ return IBV_REREG_MR_ERR_INPUT;
+ }
+
+ if (flags & IBV_REREG_MR_CHANGE_TRANSLATION) {
+ err = ibv_dontfork_range(addr, length);
+ if (err)
+ return IBV_REREG_MR_ERR_DONT_FORK_NEW;
+ dofork_onfail = 1;
+ }
+
+ old_addr = mr->addr;
+ old_len = mr->length;
+ err = mr->context->ops.rereg_mr(mr, flags, pd, addr, length, access);
+ if (!err) {
+ if (flags & IBV_REREG_MR_CHANGE_PD)
+ mr->pd = pd;
+ if (flags & IBV_REREG_MR_CHANGE_TRANSLATION) {
+ mr->addr = addr;
+ mr->length = length;
+ err = ibv_dofork_range(old_addr, old_len);
+ if (err)
+ return IBV_REREG_MR_ERR_DO_FORK_OLD;
+ }
+ } else {
+ err = IBV_REREG_MR_ERR_CMD;
+ if (dofork_onfail) {
+ if (ibv_dofork_range(addr, length))
+ err = IBV_REREG_MR_ERR_CMD_AND_DO_FORK_NEW;
+ }
+ }
+
+ return err;
+}
+default_symver(__ibv_rereg_mr, ibv_rereg_mr);
+
+int __ibv_dereg_mr(struct ibv_mr *mr)
+{
+ int ret;
+ void *addr = mr->addr;
+ size_t length = mr->length;
+
+ ret = mr->context->ops.dereg_mr(mr);
+ if (!ret)
+ ibv_dofork_range(addr, length);
+
+ return ret;
+}
+default_symver(__ibv_dereg_mr, ibv_dereg_mr);
+
+static struct ibv_comp_channel *ibv_create_comp_channel_v2(struct ibv_context *context)
+{
+ struct ibv_abi_compat_v2 *t = context->abi_compat;
+ static int warned;
+
+ if (!pthread_mutex_trylock(&t->in_use))
+ return &t->channel;
+
+ if (!warned) {
+ fprintf(stderr, PFX "Warning: kernel's ABI version %d limits capacity.\n"
+ " Only one completion channel can be created per context.\n",
+ abi_ver);
+ ++warned;
+ }
+
+ return NULL;
+}
+
+struct ibv_comp_channel *ibv_create_comp_channel(struct ibv_context *context)
+{
+ struct ibv_comp_channel *channel;
+ struct ibv_create_comp_channel cmd;
+ struct ibv_create_comp_channel_resp resp;
+
+ if (abi_ver <= 2)
+ return ibv_create_comp_channel_v2(context);
+
+ channel = malloc(sizeof *channel);
+ if (!channel)
+ return NULL;
+
+ IBV_INIT_CMD_RESP(&cmd, sizeof cmd, CREATE_COMP_CHANNEL, &resp, sizeof resp);
+ if (write(context->cmd_fd, &cmd, sizeof cmd) != sizeof cmd) {
+ free(channel);
+ return NULL;
+ }
+
+ (void) VALGRIND_MAKE_MEM_DEFINED(&resp, sizeof resp);
+
+ channel->context = context;
+ channel->fd = resp.fd;
+ channel->refcnt = 0;
+
+ return channel;
+}
+
+static int ibv_destroy_comp_channel_v2(struct ibv_comp_channel *channel)
+{
+ struct ibv_abi_compat_v2 *t = (struct ibv_abi_compat_v2 *) channel;
+ pthread_mutex_unlock(&t->in_use);
+ return 0;
+}
+
+int ibv_destroy_comp_channel(struct ibv_comp_channel *channel)
+{
+ struct ibv_context *context;
+ int ret;
+
+ context = channel->context;
+ pthread_mutex_lock(&context->mutex);
+
+ if (channel->refcnt) {
+ ret = EBUSY;
+ goto out;
+ }
+
+ if (abi_ver <= 2) {
+ ret = ibv_destroy_comp_channel_v2(channel);
+ goto out;
+ }
+
+ close(channel->fd);
+ free(channel);
+ ret = 0;
+
+out:
+ pthread_mutex_unlock(&context->mutex);
+
+ return ret;
+}
+
+struct ibv_cq *__ibv_create_cq(struct ibv_context *context, int cqe, void *cq_context,
+ struct ibv_comp_channel *channel, int comp_vector)
+{
+ struct ibv_cq *cq;
+
+ cq = context->ops.create_cq(context, cqe, channel, comp_vector);
+
+ if (cq)
+ verbs_init_cq(cq, context, channel, cq_context);
+
+ return cq;
+}
+default_symver(__ibv_create_cq, ibv_create_cq);
+
+int __ibv_resize_cq(struct ibv_cq *cq, int cqe)
+{
+ if (!cq->context->ops.resize_cq)
+ return ENOSYS;
+
+ return cq->context->ops.resize_cq(cq, cqe);
+}
+default_symver(__ibv_resize_cq, ibv_resize_cq);
+
+int __ibv_destroy_cq(struct ibv_cq *cq)
+{
+ struct ibv_comp_channel *channel = cq->channel;
+ int ret;
+
+ ret = cq->context->ops.destroy_cq(cq);
+
+ if (channel) {
+ if (!ret) {
+ pthread_mutex_lock(&channel->context->mutex);
+ --channel->refcnt;
+ pthread_mutex_unlock(&channel->context->mutex);
+ }
+ }
+
+ return ret;
+}
+default_symver(__ibv_destroy_cq, ibv_destroy_cq);
+
+int __ibv_get_cq_event(struct ibv_comp_channel *channel,
+ struct ibv_cq **cq, void **cq_context)
+{
+ struct ibv_comp_event ev;
+
+ if (read(channel->fd, &ev, sizeof ev) != sizeof ev)
+ return -1;
+
+ *cq = (struct ibv_cq *) (uintptr_t) ev.cq_handle;
+ *cq_context = (*cq)->cq_context;
+
+ if ((*cq)->context->ops.cq_event)
+ (*cq)->context->ops.cq_event(*cq);
+
+ return 0;
+}
+default_symver(__ibv_get_cq_event, ibv_get_cq_event);
+
+void __ibv_ack_cq_events(struct ibv_cq *cq, unsigned int nevents)
+{
+ pthread_mutex_lock(&cq->mutex);
+ cq->comp_events_completed += nevents;
+ pthread_cond_signal(&cq->cond);
+ pthread_mutex_unlock(&cq->mutex);
+}
+default_symver(__ibv_ack_cq_events, ibv_ack_cq_events);
+
+struct ibv_srq *__ibv_create_srq(struct ibv_pd *pd,
+ struct ibv_srq_init_attr *srq_init_attr)
+{
+ struct ibv_srq *srq;
+
+ if (!pd->context->ops.create_srq)
+ return NULL;
+
+ srq = pd->context->ops.create_srq(pd, srq_init_attr);
+ if (srq) {
+ srq->context = pd->context;
+ srq->srq_context = srq_init_attr->srq_context;
+ srq->pd = pd;
+ srq->events_completed = 0;
+ pthread_mutex_init(&srq->mutex, NULL);
+ pthread_cond_init(&srq->cond, NULL);
+ }
+
+ return srq;
+}
+default_symver(__ibv_create_srq, ibv_create_srq);
+
+int __ibv_modify_srq(struct ibv_srq *srq,
+ struct ibv_srq_attr *srq_attr,
+ int srq_attr_mask)
+{
+ return srq->context->ops.modify_srq(srq, srq_attr, srq_attr_mask);
+}
+default_symver(__ibv_modify_srq, ibv_modify_srq);
+
+int __ibv_query_srq(struct ibv_srq *srq, struct ibv_srq_attr *srq_attr)
+{
+ return srq->context->ops.query_srq(srq, srq_attr);
+}
+default_symver(__ibv_query_srq, ibv_query_srq);
+
+int __ibv_destroy_srq(struct ibv_srq *srq)
+{
+ return srq->context->ops.destroy_srq(srq);
+}
+default_symver(__ibv_destroy_srq, ibv_destroy_srq);
+
+struct ibv_qp *__ibv_create_qp(struct ibv_pd *pd,
+ struct ibv_qp_init_attr *qp_init_attr)
+{
+ struct ibv_qp *qp = pd->context->ops.create_qp(pd, qp_init_attr);
+
+ if (qp) {
+ qp->context = pd->context;
+ qp->qp_context = qp_init_attr->qp_context;
+ qp->pd = pd;
+ qp->send_cq = qp_init_attr->send_cq;
+ qp->recv_cq = qp_init_attr->recv_cq;
+ qp->srq = qp_init_attr->srq;
+ qp->qp_type = qp_init_attr->qp_type;
+ qp->state = IBV_QPS_RESET;
+ qp->events_completed = 0;
+ pthread_mutex_init(&qp->mutex, NULL);
+ pthread_cond_init(&qp->cond, NULL);
+ }
+
+ return qp;
+}
+default_symver(__ibv_create_qp, ibv_create_qp);
+
+int __ibv_query_qp(struct ibv_qp *qp, struct ibv_qp_attr *attr,
+ int attr_mask,
+ struct ibv_qp_init_attr *init_attr)
+{
+ int ret;
+
+ ret = qp->context->ops.query_qp(qp, attr, attr_mask, init_attr);
+ if (ret)
+ return ret;
+
+ if (attr_mask & IBV_QP_STATE)
+ qp->state = attr->qp_state;
+
+ return 0;
+}
+default_symver(__ibv_query_qp, ibv_query_qp);
+
+int __ibv_modify_qp(struct ibv_qp *qp, struct ibv_qp_attr *attr,
+ int attr_mask)
+{
+ int ret;
+
+ ret = qp->context->ops.modify_qp(qp, attr, attr_mask);
+ if (ret)
+ return ret;
+
+ if (attr_mask & IBV_QP_STATE)
+ qp->state = attr->qp_state;
+
+ return 0;
+}
+default_symver(__ibv_modify_qp, ibv_modify_qp);
+
+int __ibv_destroy_qp(struct ibv_qp *qp)
+{
+ return qp->context->ops.destroy_qp(qp);
+}
+default_symver(__ibv_destroy_qp, ibv_destroy_qp);
+
+struct ibv_ah *__ibv_create_ah(struct ibv_pd *pd, struct ibv_ah_attr *attr)
+{
+ struct ibv_ah *ah = pd->context->ops.create_ah(pd, attr);
+
+ if (ah) {
+ ah->context = pd->context;
+ ah->pd = pd;
+ }
+
+ return ah;
+}
+default_symver(__ibv_create_ah, ibv_create_ah);
+
+/* GID types as appear in sysfs, no change is expected as of ABI
+ * compatibility.
+ */
+#define V1_TYPE "IB/RoCE v1"
+#define V2_TYPE "RoCE v2"
+int ibv_query_gid_type(struct ibv_context *context, uint8_t port_num,
+ unsigned int index, enum ibv_gid_type *type)
+{
+ char name[32];
+ char buff[11];
+
+ snprintf(name, sizeof(name), "ports/%d/gid_attrs/types/%d", port_num,
+ index);
+
+ /* Reset errno so that we can rely on its value upon any error flow in
+ * ibv_read_sysfs_file.
+ */
+ errno = 0;
+ if (ibv_read_sysfs_file(context->device->ibdev_path, name, buff,
+ sizeof(buff)) <= 0) {
+ char *dir_path;
+ DIR *dir;
+
+ if (errno == EINVAL) {
+ /* In IB, this file doesn't exist and the kernel sets
+ * errno to -EINVAL.
+ */
+ *type = IBV_GID_TYPE_IB_ROCE_V1;
+ return 0;
+ }
+ if (asprintf(&dir_path, "%s/%s/%d/%s/",
+ context->device->ibdev_path, "ports", port_num,
+ "gid_attrs") < 0)
+ return -1;
+ dir = opendir(dir_path);
+ free(dir_path);
+ if (!dir) {
+ if (errno == ENOENT)
+ /* Assuming that if gid_attrs doesn't exist,
+ * we have an old kernel and all GIDs are
+ * IB/RoCE v1
+ */
+ *type = IBV_GID_TYPE_IB_ROCE_V1;
+ else
+ return -1;
+ } else {
+ closedir(dir);
+ errno = EFAULT;
+ return -1;
+ }
+ } else {
+ if (!strcmp(buff, V1_TYPE)) {
+ *type = IBV_GID_TYPE_IB_ROCE_V1;
+ } else if (!strcmp(buff, V2_TYPE)) {
+ *type = IBV_GID_TYPE_ROCE_V2;
+ } else {
+ errno = ENOTSUP;
+ return -1;
+ }
+ }
+
+ return 0;
+}
+
+static int ibv_find_gid_index(struct ibv_context *context, uint8_t port_num,
+ union ibv_gid *gid, enum ibv_gid_type gid_type)
+{
+ enum ibv_gid_type sgid_type = 0;
+ union ibv_gid sgid;
+ int i = 0, ret;
+
+ do {
+ ret = ibv_query_gid(context, port_num, i, &sgid);
+ if (!ret) {
+ ret = ibv_query_gid_type(context, port_num, i,
+ &sgid_type);
+ }
+ i++;
+ } while (!ret && (memcmp(&sgid, gid, sizeof(*gid)) ||
+ (gid_type != sgid_type)));
+
+ return ret ? ret : i - 1;
+}
+
+static inline void map_ipv4_addr_to_ipv6(__be32 ipv4, struct in6_addr *ipv6)
+{
+ ipv6->s6_addr32[0] = 0;
+ ipv6->s6_addr32[1] = 0;
+ ipv6->s6_addr32[2] = htobe32(0x0000FFFF);
+ ipv6->s6_addr32[3] = ipv4;
+}
+
+static inline __sum16 ipv4_calc_hdr_csum(uint16_t *data, unsigned int num_hwords)
+{
+ unsigned int i = 0;
+ uint32_t sum = 0;
+
+ for (i = 0; i < num_hwords; i++)
+ sum += *(data++);
+
+ sum = (sum & 0xffff) + (sum >> 16);
+
+ return (__sum16)~sum;
+}
+
+static inline int get_grh_header_version(struct ibv_grh *grh)
+{
+ int ip6h_version = (be32toh(grh->version_tclass_flow) >> 28) & 0xf;
+ struct ip *ip4h = (struct ip *)((void *)grh + 20);
+ struct ip ip4h_checked;
+
+ if (ip6h_version != 6) {
+ if (ip4h->ip_v == 4)
+ return 4;
+ errno = EPROTONOSUPPORT;
+ return -1;
+ }
+ /* version may be 6 or 4 */
+ if (ip4h->ip_hl != 5) /* IPv4 header length must be 5 for RoCE v2. */
+ return 6;
+ /*
+ * Verify checksum.
+ * We can't write on scattered buffers so we have to copy to temp
+ * buffer.
+ */
+ memcpy(&ip4h_checked, ip4h, sizeof(ip4h_checked));
+ /* Need to set the checksum field (check) to 0 before re-calculating
+ * the checksum.
+ */
+ ip4h_checked.ip_sum = 0;
+ ip4h_checked.ip_sum = ipv4_calc_hdr_csum((uint16_t *)&ip4h_checked, 10);
+ /* if IPv4 header checksum is OK, believe it */
+ if (ip4h->ip_sum == ip4h_checked.ip_sum)
+ return 4;
+ return 6;
+}
+
+static inline void set_ah_attr_generic_fields(struct ibv_ah_attr *ah_attr,
+ struct ibv_wc *wc,
+ struct ibv_grh *grh,
+ uint8_t port_num)
+{
+ uint32_t flow_class;
+
+ flow_class = be32toh(grh->version_tclass_flow);
+ ah_attr->grh.flow_label = flow_class & 0xFFFFF;
+ ah_attr->dlid = wc->slid;
+ ah_attr->sl = wc->sl;
+ ah_attr->src_path_bits = wc->dlid_path_bits;
+ ah_attr->port_num = port_num;
+}
+
+static inline int set_ah_attr_by_ipv4(struct ibv_context *context,
+ struct ibv_ah_attr *ah_attr,
+ struct ip *ip4h, uint8_t port_num)
+{
+ union ibv_gid sgid;
+ int ret;
+
+ /* No point searching multicast GIDs in GID table */
+ if (IN_CLASSD(be32toh(ip4h->ip_dst.s_addr))) {
+ errno = EINVAL;
+ return -1;
+ }
+
+ map_ipv4_addr_to_ipv6(ip4h->ip_dst.s_addr, (struct in6_addr *)&sgid);
+ ret = ibv_find_gid_index(context, port_num, &sgid,
+ IBV_GID_TYPE_ROCE_V2);
+ if (ret < 0)
+ return ret;
+
+ map_ipv4_addr_to_ipv6(ip4h->ip_src.s_addr,
+ (struct in6_addr *)&ah_attr->grh.dgid);
+ ah_attr->grh.sgid_index = (uint8_t) ret;
+ ah_attr->grh.hop_limit = ip4h->ip_ttl;
+ ah_attr->grh.traffic_class = ip4h->ip_tos;
+
+ return 0;
+}
+
+#define IB_NEXT_HDR 0x1b
+static inline int set_ah_attr_by_ipv6(struct ibv_context *context,
+ struct ibv_ah_attr *ah_attr,
+ struct ibv_grh *grh, uint8_t port_num)
+{
+ uint32_t flow_class;
+ uint32_t sgid_type;
+ int ret;
+
+ /* No point searching multicast GIDs in GID table */
+ if (grh->dgid.raw[0] == 0xFF) {
+ errno = EINVAL;
+ return -1;
+ }
+
+ ah_attr->grh.dgid = grh->sgid;
+ if (grh->next_hdr == IPPROTO_UDP) {
+ sgid_type = IBV_GID_TYPE_ROCE_V2;
+ } else if (grh->next_hdr == IB_NEXT_HDR) {
+ sgid_type = IBV_GID_TYPE_IB_ROCE_V1;
+ } else {
+ errno = EPROTONOSUPPORT;
+ return -1;
+ }
+
+ ret = ibv_find_gid_index(context, port_num, &grh->dgid,
+ sgid_type);
+ if (ret < 0)
+ return ret;
+
+ ah_attr->grh.sgid_index = (uint8_t) ret;
+ flow_class = be32toh(grh->version_tclass_flow);
+ ah_attr->grh.hop_limit = grh->hop_limit;
+ ah_attr->grh.traffic_class = (flow_class >> 20) & 0xFF;
+
+ return 0;
+}
+
+int ibv_init_ah_from_wc(struct ibv_context *context, uint8_t port_num,
+ struct ibv_wc *wc, struct ibv_grh *grh,
+ struct ibv_ah_attr *ah_attr)
+{
+ int version;
+ int ret = 0;
+
+ memset(ah_attr, 0, sizeof *ah_attr);
+ set_ah_attr_generic_fields(ah_attr, wc, grh, port_num);
+
+ if (wc->wc_flags & IBV_WC_GRH) {
+ ah_attr->is_global = 1;
+ version = get_grh_header_version(grh);
+
+ if (version == 4)
+ ret = set_ah_attr_by_ipv4(context, ah_attr,
+ (struct ip *)((void *)grh + 20),
+ port_num);
+ else if (version == 6)
+ ret = set_ah_attr_by_ipv6(context, ah_attr, grh,
+ port_num);
+ else
+ ret = -1;
+ }
+
+ return ret;
+}
+
+struct ibv_ah *ibv_create_ah_from_wc(struct ibv_pd *pd, struct ibv_wc *wc,
+ struct ibv_grh *grh, uint8_t port_num)
+{
+ struct ibv_ah_attr ah_attr;
+ int ret;
+
+ ret = ibv_init_ah_from_wc(pd->context, port_num, wc, grh, &ah_attr);
+ if (ret)
+ return NULL;
+
+ return ibv_create_ah(pd, &ah_attr);
+}
+
+int __ibv_destroy_ah(struct ibv_ah *ah)
+{
+ return ah->context->ops.destroy_ah(ah);
+}
+default_symver(__ibv_destroy_ah, ibv_destroy_ah);
+
+int __ibv_attach_mcast(struct ibv_qp *qp, const union ibv_gid *gid, uint16_t lid)
+{
+ return qp->context->ops.attach_mcast(qp, gid, lid);
+}
+default_symver(__ibv_attach_mcast, ibv_attach_mcast);
+
+int __ibv_detach_mcast(struct ibv_qp *qp, const union ibv_gid *gid, uint16_t lid)
+{
+ return qp->context->ops.detach_mcast(qp, gid, lid);
+}
+default_symver(__ibv_detach_mcast, ibv_detach_mcast);
+
+static inline int ipv6_addr_v4mapped(const struct in6_addr *a)
+{
+ return IN6_IS_ADDR_V4MAPPED(a) ||
+ /* IPv4 encoded multicast addresses */
+ (a->s6_addr32[0] == htobe32(0xff0e0000) &&
+ ((a->s6_addr32[1] |
+ (a->s6_addr32[2] ^ htobe32(0x0000ffff))) == 0UL));
+}
+
+struct peer_address {
+ void *address;
+ uint32_t size;
+};
+
+static inline int create_peer_from_gid(int family, void *raw_gid,
+ struct peer_address *peer_address)
+{
+ switch (family) {
+ case AF_INET:
+ peer_address->address = raw_gid + 12;
+ peer_address->size = 4;
+ break;
+ case AF_INET6:
+ peer_address->address = raw_gid;
+ peer_address->size = 16;
+ break;
+ default:
+ return -1;
+ }
+
+ return 0;
+}
+
+#define NEIGH_GET_DEFAULT_TIMEOUT_MS 3000
+int ibv_resolve_eth_l2_from_gid(struct ibv_context *context,
+ struct ibv_ah_attr *attr,
+ uint8_t eth_mac[ETHERNET_LL_SIZE],
+ uint16_t *vid)
+{
+#ifndef NRESOLVE_NEIGH
+ int dst_family;
+ int src_family;
+ int oif;
+ struct get_neigh_handler neigh_handler;
+ union ibv_gid sgid;
+ int ether_len;
+ struct peer_address src;
+ struct peer_address dst;
+ uint16_t ret_vid;
+ int ret = -EINVAL;
+ int err;
+
+ err = ibv_query_gid(context, attr->port_num,
+ attr->grh.sgid_index, &sgid);
+
+ if (err)
+ return err;
+
+ err = neigh_init_resources(&neigh_handler,
+ NEIGH_GET_DEFAULT_TIMEOUT_MS);
+
+ if (err)
+ return err;
+
+ dst_family = ipv6_addr_v4mapped((struct in6_addr *)attr->grh.dgid.raw) ?
+ AF_INET : AF_INET6;
+ src_family = ipv6_addr_v4mapped((struct in6_addr *)sgid.raw) ?
+ AF_INET : AF_INET6;
+
+ if (create_peer_from_gid(dst_family, attr->grh.dgid.raw, &dst))
+ goto free_resources;
+
+ if (create_peer_from_gid(src_family, &sgid.raw, &src))
+ goto free_resources;
+
+ if (neigh_set_dst(&neigh_handler, dst_family, dst.address,
+ dst.size))
+ goto free_resources;
+
+ if (neigh_set_src(&neigh_handler, src_family, src.address,
+ src.size))
+ goto free_resources;
+
+ oif = neigh_get_oif_from_src(&neigh_handler);
+
+ if (oif > 0)
+ neigh_set_oif(&neigh_handler, oif);
+ else
+ goto free_resources;
+
+ ret = -EHOSTUNREACH;
+
+ /* blocking call */
+ if (process_get_neigh(&neigh_handler))
+ goto free_resources;
+
+ ret_vid = neigh_get_vlan_id_from_dev(&neigh_handler);
+
+ if (ret_vid <= 0xfff)
+ neigh_set_vlan_id(&neigh_handler, ret_vid);
+
+ /* We are using only Ethernet here */
+ ether_len = neigh_get_ll(&neigh_handler,
+ eth_mac,
+ sizeof(uint8_t) * ETHERNET_LL_SIZE);
+
+ if (ether_len <= 0)
+ goto free_resources;
+
+ *vid = ret_vid;
+
+ ret = 0;
+
+free_resources:
+ neigh_free_resources(&neigh_handler);
+
+ return ret;
+#else
+ return -ENOSYS;
+#endif
+}
diff --git a/contrib/ofed/libibverbs/verbs.h b/contrib/ofed/libibverbs/verbs.h
new file mode 100644
index 0000000..eff10f8
--- /dev/null
+++ b/contrib/ofed/libibverbs/verbs.h
@@ -0,0 +1,2376 @@
+/*
+ * Copyright (c) 2004, 2005 Topspin Communications. All rights reserved.
+ * Copyright (c) 2004, 2011-2012 Intel Corporation. All rights reserved.
+ * Copyright (c) 2005, 2006, 2007 Cisco Systems, Inc. All rights reserved.
+ * Copyright (c) 2005 PathScale, Inc. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#ifndef INFINIBAND_VERBS_H
+#define INFINIBAND_VERBS_H
+
+#include <stdint.h>
+#include <pthread.h>
+#include <stddef.h>
+#include <errno.h>
+#include <string.h>
+#include <infiniband/types.h>
+
+#ifdef __cplusplus
+# define BEGIN_C_DECLS extern "C" {
+# define END_C_DECLS }
+#else /* !__cplusplus */
+# define BEGIN_C_DECLS
+# define END_C_DECLS
+#endif /* __cplusplus */
+
+#if __GNUC__ >= 3
+# define __attribute_const __attribute__((const))
+#else
+# define __attribute_const
+#endif
+
+BEGIN_C_DECLS
+
+union ibv_gid {
+ uint8_t raw[16];
+ struct {
+ __be64 subnet_prefix;
+ __be64 interface_id;
+ } global;
+};
+
+#ifndef container_of
+/**
+ * container_of - cast a member of a structure out to the containing structure
+ * @ptr: the pointer to the member.
+ * @type: the type of the container struct this is embedded in.
+ * @member: the name of the member within the struct.
+ *
+ */
+#define container_of(ptr, type, member) \
+ ((type *) ((uint8_t *)(ptr) - offsetof(type, member)))
+#endif
+
+#define vext_field_avail(type, fld, sz) (offsetof(type, fld) < (sz))
+
+static void *__VERBS_ABI_IS_EXTENDED = ((uint8_t *) NULL) - 1;
+
+enum ibv_node_type {
+ IBV_NODE_UNKNOWN = -1,
+ IBV_NODE_CA = 1,
+ IBV_NODE_SWITCH,
+ IBV_NODE_ROUTER,
+ IBV_NODE_RNIC,
+ IBV_NODE_USNIC,
+ IBV_NODE_USNIC_UDP,
+};
+
+enum ibv_transport_type {
+ IBV_TRANSPORT_UNKNOWN = -1,
+ IBV_TRANSPORT_IB = 0,
+ IBV_TRANSPORT_IWARP,
+ IBV_TRANSPORT_USNIC,
+ IBV_TRANSPORT_USNIC_UDP,
+};
+
+enum ibv_device_cap_flags {
+ IBV_DEVICE_RESIZE_MAX_WR = 1,
+ IBV_DEVICE_BAD_PKEY_CNTR = 1 << 1,
+ IBV_DEVICE_BAD_QKEY_CNTR = 1 << 2,
+ IBV_DEVICE_RAW_MULTI = 1 << 3,
+ IBV_DEVICE_AUTO_PATH_MIG = 1 << 4,
+ IBV_DEVICE_CHANGE_PHY_PORT = 1 << 5,
+ IBV_DEVICE_UD_AV_PORT_ENFORCE = 1 << 6,
+ IBV_DEVICE_CURR_QP_STATE_MOD = 1 << 7,
+ IBV_DEVICE_SHUTDOWN_PORT = 1 << 8,
+ IBV_DEVICE_INIT_TYPE = 1 << 9,
+ IBV_DEVICE_PORT_ACTIVE_EVENT = 1 << 10,
+ IBV_DEVICE_SYS_IMAGE_GUID = 1 << 11,
+ IBV_DEVICE_RC_RNR_NAK_GEN = 1 << 12,
+ IBV_DEVICE_SRQ_RESIZE = 1 << 13,
+ IBV_DEVICE_N_NOTIFY_CQ = 1 << 14,
+ IBV_DEVICE_MEM_WINDOW = 1 << 17,
+ IBV_DEVICE_UD_IP_CSUM = 1 << 18,
+ IBV_DEVICE_XRC = 1 << 20,
+ IBV_DEVICE_MEM_MGT_EXTENSIONS = 1 << 21,
+ IBV_DEVICE_MEM_WINDOW_TYPE_2A = 1 << 23,
+ IBV_DEVICE_MEM_WINDOW_TYPE_2B = 1 << 24,
+ IBV_DEVICE_RC_IP_CSUM = 1 << 25,
+ IBV_DEVICE_RAW_IP_CSUM = 1 << 26,
+ IBV_DEVICE_MANAGED_FLOW_STEERING = 1 << 29
+};
+
+/*
+ * Can't extended above ibv_device_cap_flags enum as in some systems/compilers
+ * enum range is limited to 4 bytes.
+ */
+#define IBV_DEVICE_RAW_SCATTER_FCS (1ULL << 34)
+
+enum ibv_atomic_cap {
+ IBV_ATOMIC_NONE,
+ IBV_ATOMIC_HCA,
+ IBV_ATOMIC_GLOB
+};
+
+struct ibv_device_attr {
+ char fw_ver[64];
+ __be64 node_guid;
+ __be64 sys_image_guid;
+ uint64_t max_mr_size;
+ uint64_t page_size_cap;
+ uint32_t vendor_id;
+ uint32_t vendor_part_id;
+ uint32_t hw_ver;
+ int max_qp;
+ int max_qp_wr;
+ int device_cap_flags;
+ int max_sge;
+ int max_sge_rd;
+ int max_cq;
+ int max_cqe;
+ int max_mr;
+ int max_pd;
+ int max_qp_rd_atom;
+ int max_ee_rd_atom;
+ int max_res_rd_atom;
+ int max_qp_init_rd_atom;
+ int max_ee_init_rd_atom;
+ enum ibv_atomic_cap atomic_cap;
+ int max_ee;
+ int max_rdd;
+ int max_mw;
+ int max_raw_ipv6_qp;
+ int max_raw_ethy_qp;
+ int max_mcast_grp;
+ int max_mcast_qp_attach;
+ int max_total_mcast_qp_attach;
+ int max_ah;
+ int max_fmr;
+ int max_map_per_fmr;
+ int max_srq;
+ int max_srq_wr;
+ int max_srq_sge;
+ uint16_t max_pkeys;
+ uint8_t local_ca_ack_delay;
+ uint8_t phys_port_cnt;
+};
+
+/* An extensible input struct for possible future extensions of the
+ * ibv_query_device_ex verb. */
+struct ibv_query_device_ex_input {
+ uint32_t comp_mask;
+};
+
+enum ibv_odp_transport_cap_bits {
+ IBV_ODP_SUPPORT_SEND = 1 << 0,
+ IBV_ODP_SUPPORT_RECV = 1 << 1,
+ IBV_ODP_SUPPORT_WRITE = 1 << 2,
+ IBV_ODP_SUPPORT_READ = 1 << 3,
+ IBV_ODP_SUPPORT_ATOMIC = 1 << 4,
+};
+
+struct ibv_odp_caps {
+ uint64_t general_caps;
+ struct {
+ uint32_t rc_odp_caps;
+ uint32_t uc_odp_caps;
+ uint32_t ud_odp_caps;
+ } per_transport_caps;
+};
+
+enum ibv_odp_general_caps {
+ IBV_ODP_SUPPORT = 1 << 0,
+};
+
+struct ibv_tso_caps {
+ uint32_t max_tso;
+ uint32_t supported_qpts;
+};
+
+/* RX Hash function flags */
+enum ibv_rx_hash_function_flags {
+ IBV_RX_HASH_FUNC_TOEPLITZ = 1 << 0,
+};
+
+/*
+ * RX Hash fields enable to set which incoming packet's field should
+ * participates in RX Hash. Each flag represent certain packet's field,
+ * when the flag is set the field that is represented by the flag will
+ * participate in RX Hash calculation.
+ * Note: *IPV4 and *IPV6 flags can't be enabled together on the same QP
+ * and *TCP and *UDP flags can't be enabled together on the same QP.
+*/
+enum ibv_rx_hash_fields {
+ IBV_RX_HASH_SRC_IPV4 = 1 << 0,
+ IBV_RX_HASH_DST_IPV4 = 1 << 1,
+ IBV_RX_HASH_SRC_IPV6 = 1 << 2,
+ IBV_RX_HASH_DST_IPV6 = 1 << 3,
+ IBV_RX_HASH_SRC_PORT_TCP = 1 << 4,
+ IBV_RX_HASH_DST_PORT_TCP = 1 << 5,
+ IBV_RX_HASH_SRC_PORT_UDP = 1 << 6,
+ IBV_RX_HASH_DST_PORT_UDP = 1 << 7
+};
+
+struct ibv_rss_caps {
+ uint32_t supported_qpts;
+ uint32_t max_rwq_indirection_tables;
+ uint32_t max_rwq_indirection_table_size;
+ uint64_t rx_hash_fields_mask; /* enum ibv_rx_hash_fields */
+ uint8_t rx_hash_function; /* enum ibv_rx_hash_function_flags */
+};
+
+struct ibv_packet_pacing_caps {
+ uint32_t qp_rate_limit_min;
+ uint32_t qp_rate_limit_max; /* In kbps */
+ uint32_t supported_qpts;
+};
+
+enum ibv_raw_packet_caps {
+ IBV_RAW_PACKET_CAP_CVLAN_STRIPPING = 1 << 0,
+ IBV_RAW_PACKET_CAP_SCATTER_FCS = 1 << 1,
+ IBV_RAW_PACKET_CAP_IP_CSUM = 1 << 2,
+};
+
+struct ibv_device_attr_ex {
+ struct ibv_device_attr orig_attr;
+ uint32_t comp_mask;
+ struct ibv_odp_caps odp_caps;
+ uint64_t completion_timestamp_mask;
+ uint64_t hca_core_clock;
+ uint64_t device_cap_flags_ex;
+ struct ibv_tso_caps tso_caps;
+ struct ibv_rss_caps rss_caps;
+ uint32_t max_wq_type_rq;
+ struct ibv_packet_pacing_caps packet_pacing_caps;
+ uint32_t raw_packet_caps; /* Use ibv_raw_packet_caps */
+};
+
+enum ibv_mtu {
+ IBV_MTU_256 = 1,
+ IBV_MTU_512 = 2,
+ IBV_MTU_1024 = 3,
+ IBV_MTU_2048 = 4,
+ IBV_MTU_4096 = 5
+};
+
+enum ibv_port_state {
+ IBV_PORT_NOP = 0,
+ IBV_PORT_DOWN = 1,
+ IBV_PORT_INIT = 2,
+ IBV_PORT_ARMED = 3,
+ IBV_PORT_ACTIVE = 4,
+ IBV_PORT_ACTIVE_DEFER = 5
+};
+
+enum {
+ IBV_LINK_LAYER_UNSPECIFIED,
+ IBV_LINK_LAYER_INFINIBAND,
+ IBV_LINK_LAYER_ETHERNET,
+};
+
+enum ibv_port_cap_flags {
+ IBV_PORT_SM = 1 << 1,
+ IBV_PORT_NOTICE_SUP = 1 << 2,
+ IBV_PORT_TRAP_SUP = 1 << 3,
+ IBV_PORT_OPT_IPD_SUP = 1 << 4,
+ IBV_PORT_AUTO_MIGR_SUP = 1 << 5,
+ IBV_PORT_SL_MAP_SUP = 1 << 6,
+ IBV_PORT_MKEY_NVRAM = 1 << 7,
+ IBV_PORT_PKEY_NVRAM = 1 << 8,
+ IBV_PORT_LED_INFO_SUP = 1 << 9,
+ IBV_PORT_SYS_IMAGE_GUID_SUP = 1 << 11,
+ IBV_PORT_PKEY_SW_EXT_PORT_TRAP_SUP = 1 << 12,
+ IBV_PORT_EXTENDED_SPEEDS_SUP = 1 << 14,
+ IBV_PORT_CM_SUP = 1 << 16,
+ IBV_PORT_SNMP_TUNNEL_SUP = 1 << 17,
+ IBV_PORT_REINIT_SUP = 1 << 18,
+ IBV_PORT_DEVICE_MGMT_SUP = 1 << 19,
+ IBV_PORT_VENDOR_CLASS_SUP = 1 << 20,
+ IBV_PORT_DR_NOTICE_SUP = 1 << 21,
+ IBV_PORT_CAP_MASK_NOTICE_SUP = 1 << 22,
+ IBV_PORT_BOOT_MGMT_SUP = 1 << 23,
+ IBV_PORT_LINK_LATENCY_SUP = 1 << 24,
+ IBV_PORT_CLIENT_REG_SUP = 1 << 25,
+ IBV_PORT_IP_BASED_GIDS = 1 << 26
+};
+
+struct ibv_port_attr {
+ enum ibv_port_state state;
+ enum ibv_mtu max_mtu;
+ enum ibv_mtu active_mtu;
+ int gid_tbl_len;
+ uint32_t port_cap_flags;
+ uint32_t max_msg_sz;
+ uint32_t bad_pkey_cntr;
+ uint32_t qkey_viol_cntr;
+ uint16_t pkey_tbl_len;
+ uint16_t lid;
+ uint16_t sm_lid;
+ uint8_t lmc;
+ uint8_t max_vl_num;
+ uint8_t sm_sl;
+ uint8_t subnet_timeout;
+ uint8_t init_type_reply;
+ uint8_t active_width;
+ uint8_t active_speed;
+ uint8_t phys_state;
+ uint8_t link_layer;
+ uint8_t reserved;
+};
+
+enum ibv_event_type {
+ IBV_EVENT_CQ_ERR,
+ IBV_EVENT_QP_FATAL,
+ IBV_EVENT_QP_REQ_ERR,
+ IBV_EVENT_QP_ACCESS_ERR,
+ IBV_EVENT_COMM_EST,
+ IBV_EVENT_SQ_DRAINED,
+ IBV_EVENT_PATH_MIG,
+ IBV_EVENT_PATH_MIG_ERR,
+ IBV_EVENT_DEVICE_FATAL,
+ IBV_EVENT_PORT_ACTIVE,
+ IBV_EVENT_PORT_ERR,
+ IBV_EVENT_LID_CHANGE,
+ IBV_EVENT_PKEY_CHANGE,
+ IBV_EVENT_SM_CHANGE,
+ IBV_EVENT_SRQ_ERR,
+ IBV_EVENT_SRQ_LIMIT_REACHED,
+ IBV_EVENT_QP_LAST_WQE_REACHED,
+ IBV_EVENT_CLIENT_REREGISTER,
+ IBV_EVENT_GID_CHANGE,
+ IBV_EVENT_WQ_FATAL,
+};
+
+struct ibv_async_event {
+ union {
+ struct ibv_cq *cq;
+ struct ibv_qp *qp;
+ struct ibv_srq *srq;
+ struct ibv_wq *wq;
+ int port_num;
+ } element;
+ enum ibv_event_type event_type;
+};
+
+enum ibv_wc_status {
+ IBV_WC_SUCCESS,
+ IBV_WC_LOC_LEN_ERR,
+ IBV_WC_LOC_QP_OP_ERR,
+ IBV_WC_LOC_EEC_OP_ERR,
+ IBV_WC_LOC_PROT_ERR,
+ IBV_WC_WR_FLUSH_ERR,
+ IBV_WC_MW_BIND_ERR,
+ IBV_WC_BAD_RESP_ERR,
+ IBV_WC_LOC_ACCESS_ERR,
+ IBV_WC_REM_INV_REQ_ERR,
+ IBV_WC_REM_ACCESS_ERR,
+ IBV_WC_REM_OP_ERR,
+ IBV_WC_RETRY_EXC_ERR,
+ IBV_WC_RNR_RETRY_EXC_ERR,
+ IBV_WC_LOC_RDD_VIOL_ERR,
+ IBV_WC_REM_INV_RD_REQ_ERR,
+ IBV_WC_REM_ABORT_ERR,
+ IBV_WC_INV_EECN_ERR,
+ IBV_WC_INV_EEC_STATE_ERR,
+ IBV_WC_FATAL_ERR,
+ IBV_WC_RESP_TIMEOUT_ERR,
+ IBV_WC_GENERAL_ERR
+};
+const char *ibv_wc_status_str(enum ibv_wc_status status);
+
+enum ibv_wc_opcode {
+ IBV_WC_SEND,
+ IBV_WC_RDMA_WRITE,
+ IBV_WC_RDMA_READ,
+ IBV_WC_COMP_SWAP,
+ IBV_WC_FETCH_ADD,
+ IBV_WC_BIND_MW,
+ IBV_WC_LOCAL_INV,
+ IBV_WC_TSO,
+/*
+ * Set value of IBV_WC_RECV so consumers can test if a completion is a
+ * receive by testing (opcode & IBV_WC_RECV).
+ */
+ IBV_WC_RECV = 1 << 7,
+ IBV_WC_RECV_RDMA_WITH_IMM
+};
+
+enum {
+ IBV_WC_IP_CSUM_OK_SHIFT = 2
+};
+
+enum ibv_create_cq_wc_flags {
+ IBV_WC_EX_WITH_BYTE_LEN = 1 << 0,
+ IBV_WC_EX_WITH_IMM = 1 << 1,
+ IBV_WC_EX_WITH_QP_NUM = 1 << 2,
+ IBV_WC_EX_WITH_SRC_QP = 1 << 3,
+ IBV_WC_EX_WITH_SLID = 1 << 4,
+ IBV_WC_EX_WITH_SL = 1 << 5,
+ IBV_WC_EX_WITH_DLID_PATH_BITS = 1 << 6,
+ IBV_WC_EX_WITH_COMPLETION_TIMESTAMP = 1 << 7,
+ IBV_WC_EX_WITH_CVLAN = 1 << 8,
+ IBV_WC_EX_WITH_FLOW_TAG = 1 << 9,
+};
+
+enum {
+ IBV_WC_STANDARD_FLAGS = IBV_WC_EX_WITH_BYTE_LEN |
+ IBV_WC_EX_WITH_IMM |
+ IBV_WC_EX_WITH_QP_NUM |
+ IBV_WC_EX_WITH_SRC_QP |
+ IBV_WC_EX_WITH_SLID |
+ IBV_WC_EX_WITH_SL |
+ IBV_WC_EX_WITH_DLID_PATH_BITS
+};
+
+enum {
+ IBV_CREATE_CQ_SUP_WC_FLAGS = IBV_WC_STANDARD_FLAGS |
+ IBV_WC_EX_WITH_COMPLETION_TIMESTAMP |
+ IBV_WC_EX_WITH_CVLAN |
+ IBV_WC_EX_WITH_FLOW_TAG
+};
+
+enum ibv_wc_flags {
+ IBV_WC_GRH = 1 << 0,
+ IBV_WC_WITH_IMM = 1 << 1,
+ IBV_WC_IP_CSUM_OK = 1 << IBV_WC_IP_CSUM_OK_SHIFT,
+ IBV_WC_WITH_INV = 1 << 3
+};
+
+struct ibv_wc {
+ uint64_t wr_id;
+ enum ibv_wc_status status;
+ enum ibv_wc_opcode opcode;
+ uint32_t vendor_err;
+ uint32_t byte_len;
+ /* When (wc_flags & IBV_WC_WITH_IMM): Immediate data in network byte order.
+ * When (wc_flags & IBV_WC_WITH_INV): Stores the invalidated rkey.
+ */
+ union {
+ __be32 imm_data;
+ uint32_t invalidated_rkey;
+ };
+ uint32_t qp_num;
+ uint32_t src_qp;
+ int wc_flags;
+ uint16_t pkey_index;
+ uint16_t slid;
+ uint8_t sl;
+ uint8_t dlid_path_bits;
+};
+
+enum ibv_access_flags {
+ IBV_ACCESS_LOCAL_WRITE = 1,
+ IBV_ACCESS_REMOTE_WRITE = (1<<1),
+ IBV_ACCESS_REMOTE_READ = (1<<2),
+ IBV_ACCESS_REMOTE_ATOMIC = (1<<3),
+ IBV_ACCESS_MW_BIND = (1<<4),
+ IBV_ACCESS_ZERO_BASED = (1<<5),
+ IBV_ACCESS_ON_DEMAND = (1<<6),
+};
+
+struct ibv_mw_bind_info {
+ struct ibv_mr *mr;
+ uint64_t addr;
+ uint64_t length;
+ int mw_access_flags; /* use ibv_access_flags */
+};
+
+struct ibv_pd {
+ struct ibv_context *context;
+ uint32_t handle;
+};
+
+enum ibv_xrcd_init_attr_mask {
+ IBV_XRCD_INIT_ATTR_FD = 1 << 0,
+ IBV_XRCD_INIT_ATTR_OFLAGS = 1 << 1,
+ IBV_XRCD_INIT_ATTR_RESERVED = 1 << 2
+};
+
+struct ibv_xrcd_init_attr {
+ uint32_t comp_mask;
+ int fd;
+ int oflags;
+};
+
+struct ibv_xrcd {
+ struct ibv_context *context;
+};
+
+enum ibv_rereg_mr_flags {
+ IBV_REREG_MR_CHANGE_TRANSLATION = (1 << 0),
+ IBV_REREG_MR_CHANGE_PD = (1 << 1),
+ IBV_REREG_MR_CHANGE_ACCESS = (1 << 2),
+ IBV_REREG_MR_KEEP_VALID = (1 << 3),
+ IBV_REREG_MR_FLAGS_SUPPORTED = ((IBV_REREG_MR_KEEP_VALID << 1) - 1)
+};
+
+struct ibv_mr {
+ struct ibv_context *context;
+ struct ibv_pd *pd;
+ void *addr;
+ size_t length;
+ uint32_t handle;
+ uint32_t lkey;
+ uint32_t rkey;
+};
+
+enum ibv_mw_type {
+ IBV_MW_TYPE_1 = 1,
+ IBV_MW_TYPE_2 = 2
+};
+
+struct ibv_mw {
+ struct ibv_context *context;
+ struct ibv_pd *pd;
+ uint32_t rkey;
+ uint32_t handle;
+ enum ibv_mw_type type;
+};
+
+struct ibv_global_route {
+ union ibv_gid dgid;
+ uint32_t flow_label;
+ uint8_t sgid_index;
+ uint8_t hop_limit;
+ uint8_t traffic_class;
+};
+
+struct ibv_grh {
+ __be32 version_tclass_flow;
+ __be16 paylen;
+ uint8_t next_hdr;
+ uint8_t hop_limit;
+ union ibv_gid sgid;
+ union ibv_gid dgid;
+};
+
+enum ibv_rate {
+ IBV_RATE_MAX = 0,
+ IBV_RATE_2_5_GBPS = 2,
+ IBV_RATE_5_GBPS = 5,
+ IBV_RATE_10_GBPS = 3,
+ IBV_RATE_20_GBPS = 6,
+ IBV_RATE_30_GBPS = 4,
+ IBV_RATE_40_GBPS = 7,
+ IBV_RATE_60_GBPS = 8,
+ IBV_RATE_80_GBPS = 9,
+ IBV_RATE_120_GBPS = 10,
+ IBV_RATE_14_GBPS = 11,
+ IBV_RATE_56_GBPS = 12,
+ IBV_RATE_112_GBPS = 13,
+ IBV_RATE_168_GBPS = 14,
+ IBV_RATE_25_GBPS = 15,
+ IBV_RATE_100_GBPS = 16,
+ IBV_RATE_200_GBPS = 17,
+ IBV_RATE_300_GBPS = 18
+};
+
+/**
+ * ibv_rate_to_mult - Convert the IB rate enum to a multiple of the
+ * base rate of 2.5 Gbit/sec. For example, IBV_RATE_5_GBPS will be
+ * converted to 2, since 5 Gbit/sec is 2 * 2.5 Gbit/sec.
+ * @rate: rate to convert.
+ */
+int __attribute_const ibv_rate_to_mult(enum ibv_rate rate);
+
+/**
+ * mult_to_ibv_rate - Convert a multiple of 2.5 Gbit/sec to an IB rate enum.
+ * @mult: multiple to convert.
+ */
+enum ibv_rate __attribute_const mult_to_ibv_rate(int mult);
+
+/**
+ * ibv_rate_to_mbps - Convert the IB rate enum to Mbit/sec.
+ * For example, IBV_RATE_5_GBPS will return the value 5000.
+ * @rate: rate to convert.
+ */
+int __attribute_const ibv_rate_to_mbps(enum ibv_rate rate);
+
+/**
+ * mbps_to_ibv_rate - Convert a Mbit/sec value to an IB rate enum.
+ * @mbps: value to convert.
+ */
+enum ibv_rate __attribute_const mbps_to_ibv_rate(int mbps) __attribute_const;
+
+struct ibv_ah_attr {
+ struct ibv_global_route grh;
+ uint16_t dlid;
+ uint8_t sl;
+ uint8_t src_path_bits;
+ uint8_t static_rate;
+ uint8_t is_global;
+ uint8_t port_num;
+};
+
+enum ibv_srq_attr_mask {
+ IBV_SRQ_MAX_WR = 1 << 0,
+ IBV_SRQ_LIMIT = 1 << 1
+};
+
+struct ibv_srq_attr {
+ uint32_t max_wr;
+ uint32_t max_sge;
+ uint32_t srq_limit;
+};
+
+struct ibv_srq_init_attr {
+ void *srq_context;
+ struct ibv_srq_attr attr;
+};
+
+enum ibv_srq_type {
+ IBV_SRQT_BASIC,
+ IBV_SRQT_XRC
+};
+
+enum ibv_srq_init_attr_mask {
+ IBV_SRQ_INIT_ATTR_TYPE = 1 << 0,
+ IBV_SRQ_INIT_ATTR_PD = 1 << 1,
+ IBV_SRQ_INIT_ATTR_XRCD = 1 << 2,
+ IBV_SRQ_INIT_ATTR_CQ = 1 << 3,
+ IBV_SRQ_INIT_ATTR_RESERVED = 1 << 4
+};
+
+struct ibv_srq_init_attr_ex {
+ void *srq_context;
+ struct ibv_srq_attr attr;
+
+ uint32_t comp_mask;
+ enum ibv_srq_type srq_type;
+ struct ibv_pd *pd;
+ struct ibv_xrcd *xrcd;
+ struct ibv_cq *cq;
+};
+
+enum ibv_wq_type {
+ IBV_WQT_RQ
+};
+
+enum ibv_wq_init_attr_mask {
+ IBV_WQ_INIT_ATTR_FLAGS = 1 << 0,
+ IBV_WQ_INIT_ATTR_RESERVED = 1 << 1,
+};
+
+enum ibv_wq_flags {
+ IBV_WQ_FLAGS_CVLAN_STRIPPING = 1 << 0,
+ IBV_WQ_FLAGS_SCATTER_FCS = 1 << 1,
+ IBV_WQ_FLAGS_RESERVED = 1 << 2,
+};
+
+struct ibv_wq_init_attr {
+ void *wq_context;
+ enum ibv_wq_type wq_type;
+ uint32_t max_wr;
+ uint32_t max_sge;
+ struct ibv_pd *pd;
+ struct ibv_cq *cq;
+ uint32_t comp_mask; /* Use ibv_wq_init_attr_mask */
+ uint32_t create_flags; /* use ibv_wq_flags */
+};
+
+enum ibv_wq_state {
+ IBV_WQS_RESET,
+ IBV_WQS_RDY,
+ IBV_WQS_ERR,
+ IBV_WQS_UNKNOWN
+};
+
+enum ibv_wq_attr_mask {
+ IBV_WQ_ATTR_STATE = 1 << 0,
+ IBV_WQ_ATTR_CURR_STATE = 1 << 1,
+ IBV_WQ_ATTR_FLAGS = 1 << 2,
+ IBV_WQ_ATTR_RESERVED = 1 << 3,
+};
+
+struct ibv_wq_attr {
+ /* enum ibv_wq_attr_mask */
+ uint32_t attr_mask;
+ /* Move the WQ to this state */
+ enum ibv_wq_state wq_state;
+ /* Assume this is the current WQ state */
+ enum ibv_wq_state curr_wq_state;
+ uint32_t flags; /* Use ibv_wq_flags */
+ uint32_t flags_mask; /* Use ibv_wq_flags */
+};
+
+/*
+ * Receive Work Queue Indirection Table.
+ * It's used in order to distribute incoming packets between different
+ * Receive Work Queues. Associating Receive WQs with different CPU cores
+ * allows to workload the traffic between different CPU cores.
+ * The Indirection Table can contain only WQs of type IBV_WQT_RQ.
+*/
+struct ibv_rwq_ind_table {
+ struct ibv_context *context;
+ int ind_tbl_handle;
+ int ind_tbl_num;
+ uint32_t comp_mask;
+};
+
+enum ibv_ind_table_init_attr_mask {
+ IBV_CREATE_IND_TABLE_RESERVED = (1 << 0)
+};
+
+/*
+ * Receive Work Queue Indirection Table attributes
+ */
+struct ibv_rwq_ind_table_init_attr {
+ uint32_t log_ind_tbl_size;
+ /* Each entry is a pointer to a Receive Work Queue */
+ struct ibv_wq **ind_tbl;
+ uint32_t comp_mask;
+};
+
+enum ibv_qp_type {
+ IBV_QPT_RC = 2,
+ IBV_QPT_UC,
+ IBV_QPT_UD,
+ IBV_QPT_RAW_PACKET = 8,
+ IBV_QPT_XRC_SEND = 9,
+ IBV_QPT_XRC_RECV
+};
+
+struct ibv_qp_cap {
+ uint32_t max_send_wr;
+ uint32_t max_recv_wr;
+ uint32_t max_send_sge;
+ uint32_t max_recv_sge;
+ uint32_t max_inline_data;
+};
+
+struct ibv_qp_init_attr {
+ void *qp_context;
+ struct ibv_cq *send_cq;
+ struct ibv_cq *recv_cq;
+ struct ibv_srq *srq;
+ struct ibv_qp_cap cap;
+ enum ibv_qp_type qp_type;
+ int sq_sig_all;
+};
+
+enum ibv_qp_init_attr_mask {
+ IBV_QP_INIT_ATTR_PD = 1 << 0,
+ IBV_QP_INIT_ATTR_XRCD = 1 << 1,
+ IBV_QP_INIT_ATTR_CREATE_FLAGS = 1 << 2,
+ IBV_QP_INIT_ATTR_MAX_TSO_HEADER = 1 << 3,
+ IBV_QP_INIT_ATTR_IND_TABLE = 1 << 4,
+ IBV_QP_INIT_ATTR_RX_HASH = 1 << 5,
+ IBV_QP_INIT_ATTR_RESERVED = 1 << 6
+};
+
+enum ibv_qp_create_flags {
+ IBV_QP_CREATE_BLOCK_SELF_MCAST_LB = 1 << 1,
+ IBV_QP_CREATE_SCATTER_FCS = 1 << 8,
+ IBV_QP_CREATE_CVLAN_STRIPPING = 1 << 9,
+};
+
+struct ibv_rx_hash_conf {
+ /* enum ibv_rx_hash_function_flags */
+ uint8_t rx_hash_function;
+ uint8_t rx_hash_key_len;
+ uint8_t *rx_hash_key;
+ /* enum ibv_rx_hash_fields */
+ uint64_t rx_hash_fields_mask;
+};
+
+struct ibv_qp_init_attr_ex {
+ void *qp_context;
+ struct ibv_cq *send_cq;
+ struct ibv_cq *recv_cq;
+ struct ibv_srq *srq;
+ struct ibv_qp_cap cap;
+ enum ibv_qp_type qp_type;
+ int sq_sig_all;
+
+ uint32_t comp_mask;
+ struct ibv_pd *pd;
+ struct ibv_xrcd *xrcd;
+ uint32_t create_flags;
+ uint16_t max_tso_header;
+ struct ibv_rwq_ind_table *rwq_ind_tbl;
+ struct ibv_rx_hash_conf rx_hash_conf;
+};
+
+enum ibv_qp_open_attr_mask {
+ IBV_QP_OPEN_ATTR_NUM = 1 << 0,
+ IBV_QP_OPEN_ATTR_XRCD = 1 << 1,
+ IBV_QP_OPEN_ATTR_CONTEXT = 1 << 2,
+ IBV_QP_OPEN_ATTR_TYPE = 1 << 3,
+ IBV_QP_OPEN_ATTR_RESERVED = 1 << 4
+};
+
+struct ibv_qp_open_attr {
+ uint32_t comp_mask;
+ uint32_t qp_num;
+ struct ibv_xrcd *xrcd;
+ void *qp_context;
+ enum ibv_qp_type qp_type;
+};
+
+enum ibv_qp_attr_mask {
+ IBV_QP_STATE = 1 << 0,
+ IBV_QP_CUR_STATE = 1 << 1,
+ IBV_QP_EN_SQD_ASYNC_NOTIFY = 1 << 2,
+ IBV_QP_ACCESS_FLAGS = 1 << 3,
+ IBV_QP_PKEY_INDEX = 1 << 4,
+ IBV_QP_PORT = 1 << 5,
+ IBV_QP_QKEY = 1 << 6,
+ IBV_QP_AV = 1 << 7,
+ IBV_QP_PATH_MTU = 1 << 8,
+ IBV_QP_TIMEOUT = 1 << 9,
+ IBV_QP_RETRY_CNT = 1 << 10,
+ IBV_QP_RNR_RETRY = 1 << 11,
+ IBV_QP_RQ_PSN = 1 << 12,
+ IBV_QP_MAX_QP_RD_ATOMIC = 1 << 13,
+ IBV_QP_ALT_PATH = 1 << 14,
+ IBV_QP_MIN_RNR_TIMER = 1 << 15,
+ IBV_QP_SQ_PSN = 1 << 16,
+ IBV_QP_MAX_DEST_RD_ATOMIC = 1 << 17,
+ IBV_QP_PATH_MIG_STATE = 1 << 18,
+ IBV_QP_CAP = 1 << 19,
+ IBV_QP_DEST_QPN = 1 << 20,
+ IBV_QP_RATE_LIMIT = 1 << 25,
+};
+
+enum ibv_qp_state {
+ IBV_QPS_RESET,
+ IBV_QPS_INIT,
+ IBV_QPS_RTR,
+ IBV_QPS_RTS,
+ IBV_QPS_SQD,
+ IBV_QPS_SQE,
+ IBV_QPS_ERR,
+ IBV_QPS_UNKNOWN
+};
+
+enum ibv_mig_state {
+ IBV_MIG_MIGRATED,
+ IBV_MIG_REARM,
+ IBV_MIG_ARMED
+};
+
+struct ibv_qp_attr {
+ enum ibv_qp_state qp_state;
+ enum ibv_qp_state cur_qp_state;
+ enum ibv_mtu path_mtu;
+ enum ibv_mig_state path_mig_state;
+ uint32_t qkey;
+ uint32_t rq_psn;
+ uint32_t sq_psn;
+ uint32_t dest_qp_num;
+ int qp_access_flags;
+ struct ibv_qp_cap cap;
+ struct ibv_ah_attr ah_attr;
+ struct ibv_ah_attr alt_ah_attr;
+ uint16_t pkey_index;
+ uint16_t alt_pkey_index;
+ uint8_t en_sqd_async_notify;
+ uint8_t sq_draining;
+ uint8_t max_rd_atomic;
+ uint8_t max_dest_rd_atomic;
+ uint8_t min_rnr_timer;
+ uint8_t port_num;
+ uint8_t timeout;
+ uint8_t retry_cnt;
+ uint8_t rnr_retry;
+ uint8_t alt_port_num;
+ uint8_t alt_timeout;
+ uint32_t rate_limit;
+};
+
+enum ibv_wr_opcode {
+ IBV_WR_RDMA_WRITE,
+ IBV_WR_RDMA_WRITE_WITH_IMM,
+ IBV_WR_SEND,
+ IBV_WR_SEND_WITH_IMM,
+ IBV_WR_RDMA_READ,
+ IBV_WR_ATOMIC_CMP_AND_SWP,
+ IBV_WR_ATOMIC_FETCH_AND_ADD,
+ IBV_WR_LOCAL_INV,
+ IBV_WR_BIND_MW,
+ IBV_WR_SEND_WITH_INV,
+ IBV_WR_TSO,
+};
+
+enum ibv_send_flags {
+ IBV_SEND_FENCE = 1 << 0,
+ IBV_SEND_SIGNALED = 1 << 1,
+ IBV_SEND_SOLICITED = 1 << 2,
+ IBV_SEND_INLINE = 1 << 3,
+ IBV_SEND_IP_CSUM = 1 << 4
+};
+
+struct ibv_sge {
+ uint64_t addr;
+ uint32_t length;
+ uint32_t lkey;
+};
+
+struct ibv_send_wr {
+ uint64_t wr_id;
+ struct ibv_send_wr *next;
+ struct ibv_sge *sg_list;
+ int num_sge;
+ enum ibv_wr_opcode opcode;
+ int send_flags;
+ __be32 imm_data;
+ union {
+ struct {
+ uint64_t remote_addr;
+ uint32_t rkey;
+ } rdma;
+ struct {
+ uint64_t remote_addr;
+ uint64_t compare_add;
+ uint64_t swap;
+ uint32_t rkey;
+ } atomic;
+ struct {
+ struct ibv_ah *ah;
+ uint32_t remote_qpn;
+ uint32_t remote_qkey;
+ } ud;
+ } wr;
+ union {
+ struct {
+ uint32_t remote_srqn;
+ } xrc;
+ } qp_type;
+ union {
+ struct {
+ struct ibv_mw *mw;
+ uint32_t rkey;
+ struct ibv_mw_bind_info bind_info;
+ } bind_mw;
+ struct {
+ void *hdr;
+ uint16_t hdr_sz;
+ uint16_t mss;
+ } tso;
+ };
+};
+
+struct ibv_recv_wr {
+ uint64_t wr_id;
+ struct ibv_recv_wr *next;
+ struct ibv_sge *sg_list;
+ int num_sge;
+};
+
+struct ibv_mw_bind {
+ uint64_t wr_id;
+ int send_flags;
+ struct ibv_mw_bind_info bind_info;
+};
+
+struct ibv_srq {
+ struct ibv_context *context;
+ void *srq_context;
+ struct ibv_pd *pd;
+ uint32_t handle;
+
+ pthread_mutex_t mutex;
+ pthread_cond_t cond;
+ uint32_t events_completed;
+};
+
+/*
+ * Work Queue. QP can be created without internal WQs "packaged" inside it,
+ * this QP can be configured to use "external" WQ object as its
+ * receive/send queue.
+ * WQ associated (many to one) with Completion Queue it owns WQ properties
+ * (PD, WQ size etc).
+ * WQ of type IBV_WQT_RQ:
+ * - Contains receive WQEs, in this case its PD serves as scatter as well.
+ * - Exposes post receive function to be used to post a list of work
+ * requests (WRs) to its receive queue.
+ */
+struct ibv_wq {
+ struct ibv_context *context;
+ void *wq_context;
+ struct ibv_pd *pd;
+ struct ibv_cq *cq;
+ uint32_t wq_num;
+ uint32_t handle;
+ enum ibv_wq_state state;
+ enum ibv_wq_type wq_type;
+ int (*post_recv)(struct ibv_wq *current,
+ struct ibv_recv_wr *recv_wr,
+ struct ibv_recv_wr **bad_recv_wr);
+ pthread_mutex_t mutex;
+ pthread_cond_t cond;
+ uint32_t events_completed;
+ uint32_t comp_mask;
+};
+
+struct ibv_qp {
+ struct ibv_context *context;
+ void *qp_context;
+ struct ibv_pd *pd;
+ struct ibv_cq *send_cq;
+ struct ibv_cq *recv_cq;
+ struct ibv_srq *srq;
+ uint32_t handle;
+ uint32_t qp_num;
+ enum ibv_qp_state state;
+ enum ibv_qp_type qp_type;
+
+ pthread_mutex_t mutex;
+ pthread_cond_t cond;
+ uint32_t events_completed;
+};
+
+struct ibv_comp_channel {
+ struct ibv_context *context;
+ int fd;
+ int refcnt;
+};
+
+struct ibv_cq {
+ struct ibv_context *context;
+ struct ibv_comp_channel *channel;
+ void *cq_context;
+ uint32_t handle;
+ int cqe;
+
+ pthread_mutex_t mutex;
+ pthread_cond_t cond;
+ uint32_t comp_events_completed;
+ uint32_t async_events_completed;
+};
+
+struct ibv_poll_cq_attr {
+ uint32_t comp_mask;
+};
+
+struct ibv_cq_ex {
+ struct ibv_context *context;
+ struct ibv_comp_channel *channel;
+ void *cq_context;
+ uint32_t handle;
+ int cqe;
+
+ pthread_mutex_t mutex;
+ pthread_cond_t cond;
+ uint32_t comp_events_completed;
+ uint32_t async_events_completed;
+
+ uint32_t comp_mask;
+ enum ibv_wc_status status;
+ uint64_t wr_id;
+ int (*start_poll)(struct ibv_cq_ex *current,
+ struct ibv_poll_cq_attr *attr);
+ int (*next_poll)(struct ibv_cq_ex *current);
+ void (*end_poll)(struct ibv_cq_ex *current);
+ enum ibv_wc_opcode (*read_opcode)(struct ibv_cq_ex *current);
+ uint32_t (*read_vendor_err)(struct ibv_cq_ex *current);
+ uint32_t (*read_byte_len)(struct ibv_cq_ex *current);
+ uint32_t (*read_imm_data)(struct ibv_cq_ex *current);
+ uint32_t (*read_qp_num)(struct ibv_cq_ex *current);
+ uint32_t (*read_src_qp)(struct ibv_cq_ex *current);
+ int (*read_wc_flags)(struct ibv_cq_ex *current);
+ uint32_t (*read_slid)(struct ibv_cq_ex *current);
+ uint8_t (*read_sl)(struct ibv_cq_ex *current);
+ uint8_t (*read_dlid_path_bits)(struct ibv_cq_ex *current);
+ uint64_t (*read_completion_ts)(struct ibv_cq_ex *current);
+ uint16_t (*read_cvlan)(struct ibv_cq_ex *current);
+ uint32_t (*read_flow_tag)(struct ibv_cq_ex *current);
+};
+
+static inline struct ibv_cq *ibv_cq_ex_to_cq(struct ibv_cq_ex *cq)
+{
+ return (struct ibv_cq *)cq;
+}
+
+static inline int ibv_start_poll(struct ibv_cq_ex *cq,
+ struct ibv_poll_cq_attr *attr)
+{
+ return cq->start_poll(cq, attr);
+}
+
+static inline int ibv_next_poll(struct ibv_cq_ex *cq)
+{
+ return cq->next_poll(cq);
+}
+
+static inline void ibv_end_poll(struct ibv_cq_ex *cq)
+{
+ cq->end_poll(cq);
+}
+
+static inline enum ibv_wc_opcode ibv_wc_read_opcode(struct ibv_cq_ex *cq)
+{
+ return cq->read_opcode(cq);
+}
+
+static inline uint32_t ibv_wc_read_vendor_err(struct ibv_cq_ex *cq)
+{
+ return cq->read_vendor_err(cq);
+}
+
+static inline uint32_t ibv_wc_read_byte_len(struct ibv_cq_ex *cq)
+{
+ return cq->read_byte_len(cq);
+}
+
+static inline uint32_t ibv_wc_read_imm_data(struct ibv_cq_ex *cq)
+{
+ return cq->read_imm_data(cq);
+}
+
+static inline uint32_t ibv_wc_read_qp_num(struct ibv_cq_ex *cq)
+{
+ return cq->read_qp_num(cq);
+}
+
+static inline uint32_t ibv_wc_read_src_qp(struct ibv_cq_ex *cq)
+{
+ return cq->read_src_qp(cq);
+}
+
+static inline int ibv_wc_read_wc_flags(struct ibv_cq_ex *cq)
+{
+ return cq->read_wc_flags(cq);
+}
+
+static inline uint32_t ibv_wc_read_slid(struct ibv_cq_ex *cq)
+{
+ return cq->read_slid(cq);
+}
+
+static inline uint8_t ibv_wc_read_sl(struct ibv_cq_ex *cq)
+{
+ return cq->read_sl(cq);
+}
+
+static inline uint8_t ibv_wc_read_dlid_path_bits(struct ibv_cq_ex *cq)
+{
+ return cq->read_dlid_path_bits(cq);
+}
+
+static inline uint64_t ibv_wc_read_completion_ts(struct ibv_cq_ex *cq)
+{
+ return cq->read_completion_ts(cq);
+}
+
+static inline uint16_t ibv_wc_read_cvlan(struct ibv_cq_ex *cq)
+{
+ return cq->read_cvlan(cq);
+}
+
+static inline uint32_t ibv_wc_read_flow_tag(struct ibv_cq_ex *cq)
+{
+ return cq->read_flow_tag(cq);
+}
+
+static inline int ibv_post_wq_recv(struct ibv_wq *wq,
+ struct ibv_recv_wr *recv_wr,
+ struct ibv_recv_wr **bad_recv_wr)
+{
+ return wq->post_recv(wq, recv_wr, bad_recv_wr);
+}
+
+struct ibv_ah {
+ struct ibv_context *context;
+ struct ibv_pd *pd;
+ uint32_t handle;
+};
+
+enum ibv_flow_flags {
+ IBV_FLOW_ATTR_FLAGS_ALLOW_LOOP_BACK = 1 << 0,
+ IBV_FLOW_ATTR_FLAGS_DONT_TRAP = 1 << 1,
+};
+
+enum ibv_flow_attr_type {
+ /* steering according to rule specifications */
+ IBV_FLOW_ATTR_NORMAL = 0x0,
+ /* default unicast and multicast rule -
+ * receive all Eth traffic which isn't steered to any QP
+ */
+ IBV_FLOW_ATTR_ALL_DEFAULT = 0x1,
+ /* default multicast rule -
+ * receive all Eth multicast traffic which isn't steered to any QP
+ */
+ IBV_FLOW_ATTR_MC_DEFAULT = 0x2,
+ /* sniffer rule - receive all port traffic */
+ IBV_FLOW_ATTR_SNIFFER = 0x3,
+};
+
+enum ibv_flow_spec_type {
+ IBV_FLOW_SPEC_ETH = 0x20,
+ IBV_FLOW_SPEC_IPV4 = 0x30,
+ IBV_FLOW_SPEC_IPV6 = 0x31,
+ IBV_FLOW_SPEC_IPV4_EXT = 0x32,
+ IBV_FLOW_SPEC_TCP = 0x40,
+ IBV_FLOW_SPEC_UDP = 0x41,
+ IBV_FLOW_SPEC_VXLAN_TUNNEL = 0x50,
+ IBV_FLOW_SPEC_INNER = 0x100,
+ IBV_FLOW_SPEC_ACTION_TAG = 0x1000,
+ IBV_FLOW_SPEC_ACTION_DROP = 0x1001,
+};
+
+struct ibv_flow_eth_filter {
+ uint8_t dst_mac[6];
+ uint8_t src_mac[6];
+ uint16_t ether_type;
+ /*
+ * same layout as 802.1q: prio 3, cfi 1, vlan id 12
+ */
+ uint16_t vlan_tag;
+};
+
+struct ibv_flow_spec_eth {
+ enum ibv_flow_spec_type type;
+ uint16_t size;
+ struct ibv_flow_eth_filter val;
+ struct ibv_flow_eth_filter mask;
+};
+
+struct ibv_flow_ipv4_filter {
+ uint32_t src_ip;
+ uint32_t dst_ip;
+};
+
+struct ibv_flow_spec_ipv4 {
+ enum ibv_flow_spec_type type;
+ uint16_t size;
+ struct ibv_flow_ipv4_filter val;
+ struct ibv_flow_ipv4_filter mask;
+};
+
+struct ibv_flow_ipv4_ext_filter {
+ uint32_t src_ip;
+ uint32_t dst_ip;
+ uint8_t proto;
+ uint8_t tos;
+ uint8_t ttl;
+ uint8_t flags;
+};
+
+struct ibv_flow_spec_ipv4_ext {
+ enum ibv_flow_spec_type type;
+ uint16_t size;
+ struct ibv_flow_ipv4_ext_filter val;
+ struct ibv_flow_ipv4_ext_filter mask;
+};
+
+struct ibv_flow_ipv6_filter {
+ uint8_t src_ip[16];
+ uint8_t dst_ip[16];
+ uint32_t flow_label;
+ uint8_t next_hdr;
+ uint8_t traffic_class;
+ uint8_t hop_limit;
+};
+
+struct ibv_flow_spec_ipv6 {
+ enum ibv_flow_spec_type type;
+ uint16_t size;
+ struct ibv_flow_ipv6_filter val;
+ struct ibv_flow_ipv6_filter mask;
+};
+
+struct ibv_flow_tcp_udp_filter {
+ uint16_t dst_port;
+ uint16_t src_port;
+};
+
+struct ibv_flow_spec_tcp_udp {
+ enum ibv_flow_spec_type type;
+ uint16_t size;
+ struct ibv_flow_tcp_udp_filter val;
+ struct ibv_flow_tcp_udp_filter mask;
+};
+
+struct ibv_flow_tunnel_filter {
+ uint32_t tunnel_id;
+};
+
+struct ibv_flow_spec_tunnel {
+ enum ibv_flow_spec_type type;
+ uint16_t size;
+ struct ibv_flow_tunnel_filter val;
+ struct ibv_flow_tunnel_filter mask;
+};
+
+struct ibv_flow_spec_action_tag {
+ enum ibv_flow_spec_type type;
+ uint16_t size;
+ uint32_t tag_id;
+};
+
+struct ibv_flow_spec_action_drop {
+ enum ibv_flow_spec_type type;
+ uint16_t size;
+};
+
+struct ibv_flow_spec {
+ union {
+ struct {
+ enum ibv_flow_spec_type type;
+ uint16_t size;
+ } hdr;
+ struct ibv_flow_spec_eth eth;
+ struct ibv_flow_spec_ipv4 ipv4;
+ struct ibv_flow_spec_tcp_udp tcp_udp;
+ struct ibv_flow_spec_ipv4_ext ipv4_ext;
+ struct ibv_flow_spec_ipv6 ipv6;
+ struct ibv_flow_spec_tunnel tunnel;
+ struct ibv_flow_spec_action_tag flow_tag;
+ struct ibv_flow_spec_action_drop drop;
+ };
+};
+
+struct ibv_flow_attr {
+ uint32_t comp_mask;
+ enum ibv_flow_attr_type type;
+ uint16_t size;
+ uint16_t priority;
+ uint8_t num_of_specs;
+ uint8_t port;
+ uint32_t flags;
+ /* Following are the optional layers according to user request
+ * struct ibv_flow_spec_xxx [L2]
+ * struct ibv_flow_spec_yyy [L3/L4]
+ */
+};
+
+struct ibv_flow {
+ uint32_t comp_mask;
+ struct ibv_context *context;
+ uint32_t handle;
+};
+
+struct ibv_device;
+struct ibv_context;
+
+/* Obsolete, never used, do not touch */
+struct _ibv_device_ops {
+ struct ibv_context * (*_dummy1)(struct ibv_device *device, int cmd_fd);
+ void (*_dummy2)(struct ibv_context *context);
+};
+
+enum {
+ IBV_SYSFS_NAME_MAX = 64,
+ IBV_SYSFS_PATH_MAX = 256
+};
+
+struct ibv_device {
+ struct _ibv_device_ops _ops;
+ enum ibv_node_type node_type;
+ enum ibv_transport_type transport_type;
+ /* Name of underlying kernel IB device, eg "mthca0" */
+ char name[IBV_SYSFS_NAME_MAX];
+ /* Name of uverbs device, eg "uverbs0" */
+ char dev_name[IBV_SYSFS_NAME_MAX];
+ /* Path to infiniband_verbs class device in sysfs */
+ char dev_path[IBV_SYSFS_PATH_MAX];
+ /* Path to infiniband class device in sysfs */
+ char ibdev_path[IBV_SYSFS_PATH_MAX];
+};
+
+struct ibv_context_ops {
+ int (*query_device)(struct ibv_context *context,
+ struct ibv_device_attr *device_attr);
+ int (*query_port)(struct ibv_context *context, uint8_t port_num,
+ struct ibv_port_attr *port_attr);
+ struct ibv_pd * (*alloc_pd)(struct ibv_context *context);
+ int (*dealloc_pd)(struct ibv_pd *pd);
+ struct ibv_mr * (*reg_mr)(struct ibv_pd *pd, void *addr, size_t length,
+ int access);
+ int (*rereg_mr)(struct ibv_mr *mr,
+ int flags,
+ struct ibv_pd *pd, void *addr,
+ size_t length,
+ int access);
+ int (*dereg_mr)(struct ibv_mr *mr);
+ struct ibv_mw * (*alloc_mw)(struct ibv_pd *pd, enum ibv_mw_type type);
+ int (*bind_mw)(struct ibv_qp *qp, struct ibv_mw *mw,
+ struct ibv_mw_bind *mw_bind);
+ int (*dealloc_mw)(struct ibv_mw *mw);
+ struct ibv_cq * (*create_cq)(struct ibv_context *context, int cqe,
+ struct ibv_comp_channel *channel,
+ int comp_vector);
+ int (*poll_cq)(struct ibv_cq *cq, int num_entries, struct ibv_wc *wc);
+ int (*req_notify_cq)(struct ibv_cq *cq, int solicited_only);
+ void (*cq_event)(struct ibv_cq *cq);
+ int (*resize_cq)(struct ibv_cq *cq, int cqe);
+ int (*destroy_cq)(struct ibv_cq *cq);
+ struct ibv_srq * (*create_srq)(struct ibv_pd *pd,
+ struct ibv_srq_init_attr *srq_init_attr);
+ int (*modify_srq)(struct ibv_srq *srq,
+ struct ibv_srq_attr *srq_attr,
+ int srq_attr_mask);
+ int (*query_srq)(struct ibv_srq *srq,
+ struct ibv_srq_attr *srq_attr);
+ int (*destroy_srq)(struct ibv_srq *srq);
+ int (*post_srq_recv)(struct ibv_srq *srq,
+ struct ibv_recv_wr *recv_wr,
+ struct ibv_recv_wr **bad_recv_wr);
+ struct ibv_qp * (*create_qp)(struct ibv_pd *pd, struct ibv_qp_init_attr *attr);
+ int (*query_qp)(struct ibv_qp *qp, struct ibv_qp_attr *attr,
+ int attr_mask,
+ struct ibv_qp_init_attr *init_attr);
+ int (*modify_qp)(struct ibv_qp *qp, struct ibv_qp_attr *attr,
+ int attr_mask);
+ int (*destroy_qp)(struct ibv_qp *qp);
+ int (*post_send)(struct ibv_qp *qp, struct ibv_send_wr *wr,
+ struct ibv_send_wr **bad_wr);
+ int (*post_recv)(struct ibv_qp *qp, struct ibv_recv_wr *wr,
+ struct ibv_recv_wr **bad_wr);
+ struct ibv_ah * (*create_ah)(struct ibv_pd *pd, struct ibv_ah_attr *attr);
+ int (*destroy_ah)(struct ibv_ah *ah);
+ int (*attach_mcast)(struct ibv_qp *qp, const union ibv_gid *gid,
+ uint16_t lid);
+ int (*detach_mcast)(struct ibv_qp *qp, const union ibv_gid *gid,
+ uint16_t lid);
+ void (*async_event)(struct ibv_async_event *event);
+};
+
+struct ibv_context {
+ struct ibv_device *device;
+ struct ibv_context_ops ops;
+ int cmd_fd;
+ int async_fd;
+ int num_comp_vectors;
+ pthread_mutex_t mutex;
+ void *abi_compat;
+};
+
+enum ibv_cq_init_attr_mask {
+ IBV_CQ_INIT_ATTR_MASK_FLAGS = 1 << 0,
+ IBV_CQ_INIT_ATTR_MASK_RESERVED = 1 << 1
+};
+
+enum ibv_create_cq_attr_flags {
+ IBV_CREATE_CQ_ATTR_SINGLE_THREADED = 1 << 0,
+ IBV_CREATE_CQ_ATTR_RESERVED = 1 << 1,
+};
+
+struct ibv_cq_init_attr_ex {
+ /* Minimum number of entries required for CQ */
+ uint32_t cqe;
+ /* Consumer-supplied context returned for completion events */
+ void *cq_context;
+ /* Completion channel where completion events will be queued.
+ * May be NULL if completion events will not be used.
+ */
+ struct ibv_comp_channel *channel;
+ /* Completion vector used to signal completion events.
+ * Must be < context->num_comp_vectors.
+ */
+ uint32_t comp_vector;
+ /* Or'ed bit of enum ibv_create_cq_wc_flags. */
+ uint64_t wc_flags;
+ /* compatibility mask (extended verb). Or'd flags of
+ * enum ibv_cq_init_attr_mask
+ */
+ uint32_t comp_mask;
+ /* create cq attr flags - one or more flags from
+ * enum ibv_create_cq_attr_flags
+ */
+ uint32_t flags;
+};
+
+enum ibv_values_mask {
+ IBV_VALUES_MASK_RAW_CLOCK = 1 << 0,
+ IBV_VALUES_MASK_RESERVED = 1 << 1
+};
+
+struct ibv_values_ex {
+ uint32_t comp_mask;
+ struct timespec raw_clock;
+};
+
+enum verbs_context_mask {
+ VERBS_CONTEXT_XRCD = 1 << 0,
+ VERBS_CONTEXT_SRQ = 1 << 1,
+ VERBS_CONTEXT_QP = 1 << 2,
+ VERBS_CONTEXT_CREATE_FLOW = 1 << 3,
+ VERBS_CONTEXT_DESTROY_FLOW = 1 << 4,
+ VERBS_CONTEXT_RESERVED = 1 << 5
+};
+
+struct verbs_context {
+ /* "grows up" - new fields go here */
+ int (*destroy_rwq_ind_table)(struct ibv_rwq_ind_table *rwq_ind_table);
+ struct ibv_rwq_ind_table *(*create_rwq_ind_table)(struct ibv_context *context,
+ struct ibv_rwq_ind_table_init_attr *init_attr);
+ int (*destroy_wq)(struct ibv_wq *wq);
+ int (*modify_wq)(struct ibv_wq *wq, struct ibv_wq_attr *wq_attr);
+ struct ibv_wq * (*create_wq)(struct ibv_context *context,
+ struct ibv_wq_init_attr *wq_init_attr);
+ int (*query_rt_values)(struct ibv_context *context,
+ struct ibv_values_ex *values);
+ struct ibv_cq_ex *(*create_cq_ex)(struct ibv_context *context,
+ struct ibv_cq_init_attr_ex *init_attr);
+ struct verbs_ex_private *priv;
+ int (*query_device_ex)(struct ibv_context *context,
+ const struct ibv_query_device_ex_input *input,
+ struct ibv_device_attr_ex *attr,
+ size_t attr_size);
+ int (*ibv_destroy_flow) (struct ibv_flow *flow);
+ void (*ABI_placeholder2) (void); /* DO NOT COPY THIS GARBAGE */
+ struct ibv_flow * (*ibv_create_flow) (struct ibv_qp *qp,
+ struct ibv_flow_attr *flow_attr);
+ void (*ABI_placeholder1) (void); /* DO NOT COPY THIS GARBAGE */
+ struct ibv_qp *(*open_qp)(struct ibv_context *context,
+ struct ibv_qp_open_attr *attr);
+ struct ibv_qp *(*create_qp_ex)(struct ibv_context *context,
+ struct ibv_qp_init_attr_ex *qp_init_attr_ex);
+ int (*get_srq_num)(struct ibv_srq *srq, uint32_t *srq_num);
+ struct ibv_srq * (*create_srq_ex)(struct ibv_context *context,
+ struct ibv_srq_init_attr_ex *srq_init_attr_ex);
+ struct ibv_xrcd * (*open_xrcd)(struct ibv_context *context,
+ struct ibv_xrcd_init_attr *xrcd_init_attr);
+ int (*close_xrcd)(struct ibv_xrcd *xrcd);
+ uint64_t has_comp_mask;
+ size_t sz; /* Must be immediately before struct ibv_context */
+ struct ibv_context context; /* Must be last field in the struct */
+};
+
+static inline struct verbs_context *verbs_get_ctx(struct ibv_context *ctx)
+{
+ return (ctx->abi_compat != __VERBS_ABI_IS_EXTENDED) ?
+ NULL : container_of(ctx, struct verbs_context, context);
+}
+
+#define verbs_get_ctx_op(ctx, op) ({ \
+ struct verbs_context *__vctx = verbs_get_ctx(ctx); \
+ (!__vctx || (__vctx->sz < sizeof(*__vctx) - offsetof(struct verbs_context, op)) || \
+ !__vctx->op) ? NULL : __vctx; })
+
+#define verbs_set_ctx_op(_vctx, op, ptr) ({ \
+ struct verbs_context *vctx = _vctx; \
+ if (vctx && (vctx->sz >= sizeof(*vctx) - offsetof(struct verbs_context, op))) \
+ vctx->op = ptr; })
+
+/**
+ * ibv_get_device_list - Get list of IB devices currently available
+ * @num_devices: optional. if non-NULL, set to the number of devices
+ * returned in the array.
+ *
+ * Return a NULL-terminated array of IB devices. The array can be
+ * released with ibv_free_device_list().
+ */
+struct ibv_device **ibv_get_device_list(int *num_devices);
+
+/**
+ * ibv_free_device_list - Free list from ibv_get_device_list()
+ *
+ * Free an array of devices returned from ibv_get_device_list(). Once
+ * the array is freed, pointers to devices that were not opened with
+ * ibv_open_device() are no longer valid. Client code must open all
+ * devices it intends to use before calling ibv_free_device_list().
+ */
+void ibv_free_device_list(struct ibv_device **list);
+
+/**
+ * ibv_get_device_name - Return kernel device name
+ */
+const char *ibv_get_device_name(struct ibv_device *device);
+
+/**
+ * ibv_get_device_guid - Return device's node GUID
+ */
+__be64 ibv_get_device_guid(struct ibv_device *device);
+
+/**
+ * ibv_open_device - Initialize device for use
+ */
+struct ibv_context *ibv_open_device(struct ibv_device *device);
+
+/**
+ * ibv_close_device - Release device
+ */
+int ibv_close_device(struct ibv_context *context);
+
+/**
+ * ibv_get_async_event - Get next async event
+ * @event: Pointer to use to return async event
+ *
+ * All async events returned by ibv_get_async_event() must eventually
+ * be acknowledged with ibv_ack_async_event().
+ */
+int ibv_get_async_event(struct ibv_context *context,
+ struct ibv_async_event *event);
+
+/**
+ * ibv_ack_async_event - Acknowledge an async event
+ * @event: Event to be acknowledged.
+ *
+ * All async events which are returned by ibv_get_async_event() must
+ * be acknowledged. To avoid races, destroying an object (CQ, SRQ or
+ * QP) will wait for all affiliated events to be acknowledged, so
+ * there should be a one-to-one correspondence between acks and
+ * successful gets.
+ */
+void ibv_ack_async_event(struct ibv_async_event *event);
+
+/**
+ * ibv_query_device - Get device properties
+ */
+int ibv_query_device(struct ibv_context *context,
+ struct ibv_device_attr *device_attr);
+
+/**
+ * ibv_query_port - Get port properties
+ */
+int ibv_query_port(struct ibv_context *context, uint8_t port_num,
+ struct ibv_port_attr *port_attr);
+
+static inline int ___ibv_query_port(struct ibv_context *context,
+ uint8_t port_num,
+ struct ibv_port_attr *port_attr)
+{
+ /* For compatibility when running with old libibverbs */
+ port_attr->link_layer = IBV_LINK_LAYER_UNSPECIFIED;
+ port_attr->reserved = 0;
+
+ return ibv_query_port(context, port_num, port_attr);
+}
+
+#define ibv_query_port(context, port_num, port_attr) \
+ ___ibv_query_port(context, port_num, port_attr)
+
+/**
+ * ibv_query_gid - Get a GID table entry
+ */
+int ibv_query_gid(struct ibv_context *context, uint8_t port_num,
+ int index, union ibv_gid *gid);
+
+/**
+ * ibv_query_pkey - Get a P_Key table entry
+ */
+int ibv_query_pkey(struct ibv_context *context, uint8_t port_num,
+ int index, __be16 *pkey);
+
+/**
+ * ibv_alloc_pd - Allocate a protection domain
+ */
+struct ibv_pd *ibv_alloc_pd(struct ibv_context *context);
+
+/**
+ * ibv_dealloc_pd - Free a protection domain
+ */
+int ibv_dealloc_pd(struct ibv_pd *pd);
+
+static inline struct ibv_flow *ibv_create_flow(struct ibv_qp *qp,
+ struct ibv_flow_attr *flow)
+{
+ struct verbs_context *vctx = verbs_get_ctx_op(qp->context,
+ ibv_create_flow);
+ if (!vctx || !vctx->ibv_create_flow) {
+ errno = ENOSYS;
+ return NULL;
+ }
+
+ return vctx->ibv_create_flow(qp, flow);
+}
+
+static inline int ibv_destroy_flow(struct ibv_flow *flow_id)
+{
+ struct verbs_context *vctx = verbs_get_ctx_op(flow_id->context,
+ ibv_destroy_flow);
+ if (!vctx || !vctx->ibv_destroy_flow)
+ return -ENOSYS;
+ return vctx->ibv_destroy_flow(flow_id);
+}
+
+/**
+ * ibv_open_xrcd - Open an extended connection domain
+ */
+static inline struct ibv_xrcd *
+ibv_open_xrcd(struct ibv_context *context, struct ibv_xrcd_init_attr *xrcd_init_attr)
+{
+ struct verbs_context *vctx = verbs_get_ctx_op(context, open_xrcd);
+ if (!vctx) {
+ errno = ENOSYS;
+ return NULL;
+ }
+ return vctx->open_xrcd(context, xrcd_init_attr);
+}
+
+/**
+ * ibv_close_xrcd - Close an extended connection domain
+ */
+static inline int ibv_close_xrcd(struct ibv_xrcd *xrcd)
+{
+ struct verbs_context *vctx = verbs_get_ctx(xrcd->context);
+ return vctx->close_xrcd(xrcd);
+}
+
+/**
+ * ibv_reg_mr - Register a memory region
+ */
+struct ibv_mr *ibv_reg_mr(struct ibv_pd *pd, void *addr,
+ size_t length, int access);
+
+
+enum ibv_rereg_mr_err_code {
+ /* Old MR is valid, invalid input */
+ IBV_REREG_MR_ERR_INPUT = -1,
+ /* Old MR is valid, failed via don't fork on new address range */
+ IBV_REREG_MR_ERR_DONT_FORK_NEW = -2,
+ /* New MR is valid, failed via do fork on old address range */
+ IBV_REREG_MR_ERR_DO_FORK_OLD = -3,
+ /* MR shouldn't be used, command error */
+ IBV_REREG_MR_ERR_CMD = -4,
+ /* MR shouldn't be used, command error, invalid fork state on new address range */
+ IBV_REREG_MR_ERR_CMD_AND_DO_FORK_NEW = -5,
+};
+
+/**
+ * ibv_rereg_mr - Re-Register a memory region
+ */
+int ibv_rereg_mr(struct ibv_mr *mr, int flags,
+ struct ibv_pd *pd, void *addr,
+ size_t length, int access);
+/**
+ * ibv_dereg_mr - Deregister a memory region
+ */
+int ibv_dereg_mr(struct ibv_mr *mr);
+
+/**
+ * ibv_alloc_mw - Allocate a memory window
+ */
+static inline struct ibv_mw *ibv_alloc_mw(struct ibv_pd *pd,
+ enum ibv_mw_type type)
+{
+ struct ibv_mw *mw;
+
+ if (!pd->context->ops.alloc_mw) {
+ errno = ENOSYS;
+ return NULL;
+ }
+
+ mw = pd->context->ops.alloc_mw(pd, type);
+ return mw;
+}
+
+/**
+ * ibv_dealloc_mw - Free a memory window
+ */
+static inline int ibv_dealloc_mw(struct ibv_mw *mw)
+{
+ return mw->context->ops.dealloc_mw(mw);
+}
+
+/**
+ * ibv_inc_rkey - Increase the 8 lsb in the given rkey
+ */
+static inline uint32_t ibv_inc_rkey(uint32_t rkey)
+{
+ const uint32_t mask = 0x000000ff;
+ uint8_t newtag = (uint8_t)((rkey + 1) & mask);
+
+ return (rkey & ~mask) | newtag;
+}
+
+/**
+ * ibv_bind_mw - Bind a memory window to a region
+ */
+static inline int ibv_bind_mw(struct ibv_qp *qp, struct ibv_mw *mw,
+ struct ibv_mw_bind *mw_bind)
+{
+ if (mw->type != IBV_MW_TYPE_1)
+ return EINVAL;
+
+ return mw->context->ops.bind_mw(qp, mw, mw_bind);
+}
+
+/**
+ * ibv_create_comp_channel - Create a completion event channel
+ */
+struct ibv_comp_channel *ibv_create_comp_channel(struct ibv_context *context);
+
+/**
+ * ibv_destroy_comp_channel - Destroy a completion event channel
+ */
+int ibv_destroy_comp_channel(struct ibv_comp_channel *channel);
+
+/**
+ * ibv_create_cq - Create a completion queue
+ * @context - Context CQ will be attached to
+ * @cqe - Minimum number of entries required for CQ
+ * @cq_context - Consumer-supplied context returned for completion events
+ * @channel - Completion channel where completion events will be queued.
+ * May be NULL if completion events will not be used.
+ * @comp_vector - Completion vector used to signal completion events.
+ * Must be >= 0 and < context->num_comp_vectors.
+ */
+struct ibv_cq *ibv_create_cq(struct ibv_context *context, int cqe,
+ void *cq_context,
+ struct ibv_comp_channel *channel,
+ int comp_vector);
+
+/**
+ * ibv_create_cq_ex - Create a completion queue
+ * @context - Context CQ will be attached to
+ * @cq_attr - Attributes to create the CQ with
+ */
+static inline
+struct ibv_cq_ex *ibv_create_cq_ex(struct ibv_context *context,
+ struct ibv_cq_init_attr_ex *cq_attr)
+{
+ struct verbs_context *vctx = verbs_get_ctx_op(context, create_cq_ex);
+
+ if (!vctx) {
+ errno = ENOSYS;
+ return NULL;
+ }
+
+ if (cq_attr->comp_mask & ~(IBV_CQ_INIT_ATTR_MASK_RESERVED - 1)) {
+ errno = EINVAL;
+ return NULL;
+ }
+
+ return vctx->create_cq_ex(context, cq_attr);
+}
+
+/**
+ * ibv_resize_cq - Modifies the capacity of the CQ.
+ * @cq: The CQ to resize.
+ * @cqe: The minimum size of the CQ.
+ *
+ * Users can examine the cq structure to determine the actual CQ size.
+ */
+int ibv_resize_cq(struct ibv_cq *cq, int cqe);
+
+/**
+ * ibv_destroy_cq - Destroy a completion queue
+ */
+int ibv_destroy_cq(struct ibv_cq *cq);
+
+/**
+ * ibv_get_cq_event - Read next CQ event
+ * @channel: Channel to get next event from.
+ * @cq: Used to return pointer to CQ.
+ * @cq_context: Used to return consumer-supplied CQ context.
+ *
+ * All completion events returned by ibv_get_cq_event() must
+ * eventually be acknowledged with ibv_ack_cq_events().
+ */
+int ibv_get_cq_event(struct ibv_comp_channel *channel,
+ struct ibv_cq **cq, void **cq_context);
+
+/**
+ * ibv_ack_cq_events - Acknowledge CQ completion events
+ * @cq: CQ to acknowledge events for
+ * @nevents: Number of events to acknowledge.
+ *
+ * All completion events which are returned by ibv_get_cq_event() must
+ * be acknowledged. To avoid races, ibv_destroy_cq() will wait for
+ * all completion events to be acknowledged, so there should be a
+ * one-to-one correspondence between acks and successful gets. An
+ * application may accumulate multiple completion events and
+ * acknowledge them in a single call to ibv_ack_cq_events() by passing
+ * the number of events to ack in @nevents.
+ */
+void ibv_ack_cq_events(struct ibv_cq *cq, unsigned int nevents);
+
+/**
+ * ibv_poll_cq - Poll a CQ for work completions
+ * @cq:the CQ being polled
+ * @num_entries:maximum number of completions to return
+ * @wc:array of at least @num_entries of &struct ibv_wc where completions
+ * will be returned
+ *
+ * Poll a CQ for (possibly multiple) completions. If the return value
+ * is < 0, an error occurred. If the return value is >= 0, it is the
+ * number of completions returned. If the return value is
+ * non-negative and strictly less than num_entries, then the CQ was
+ * emptied.
+ */
+static inline int ibv_poll_cq(struct ibv_cq *cq, int num_entries, struct ibv_wc *wc)
+{
+ return cq->context->ops.poll_cq(cq, num_entries, wc);
+}
+
+/**
+ * ibv_req_notify_cq - Request completion notification on a CQ. An
+ * event will be added to the completion channel associated with the
+ * CQ when an entry is added to the CQ.
+ * @cq: The completion queue to request notification for.
+ * @solicited_only: If non-zero, an event will be generated only for
+ * the next solicited CQ entry. If zero, any CQ entry, solicited or
+ * not, will generate an event.
+ */
+static inline int ibv_req_notify_cq(struct ibv_cq *cq, int solicited_only)
+{
+ return cq->context->ops.req_notify_cq(cq, solicited_only);
+}
+
+/**
+ * ibv_create_srq - Creates a SRQ associated with the specified protection
+ * domain.
+ * @pd: The protection domain associated with the SRQ.
+ * @srq_init_attr: A list of initial attributes required to create the SRQ.
+ *
+ * srq_attr->max_wr and srq_attr->max_sge are read the determine the
+ * requested size of the SRQ, and set to the actual values allocated
+ * on return. If ibv_create_srq() succeeds, then max_wr and max_sge
+ * will always be at least as large as the requested values.
+ */
+struct ibv_srq *ibv_create_srq(struct ibv_pd *pd,
+ struct ibv_srq_init_attr *srq_init_attr);
+
+static inline struct ibv_srq *
+ibv_create_srq_ex(struct ibv_context *context,
+ struct ibv_srq_init_attr_ex *srq_init_attr_ex)
+{
+ struct verbs_context *vctx;
+ uint32_t mask = srq_init_attr_ex->comp_mask;
+
+ if (!(mask & ~(IBV_SRQ_INIT_ATTR_PD | IBV_SRQ_INIT_ATTR_TYPE)) &&
+ (mask & IBV_SRQ_INIT_ATTR_PD) &&
+ (!(mask & IBV_SRQ_INIT_ATTR_TYPE) ||
+ (srq_init_attr_ex->srq_type == IBV_SRQT_BASIC)))
+ return ibv_create_srq(srq_init_attr_ex->pd,
+ (struct ibv_srq_init_attr *)srq_init_attr_ex);
+
+ vctx = verbs_get_ctx_op(context, create_srq_ex);
+ if (!vctx) {
+ errno = ENOSYS;
+ return NULL;
+ }
+ return vctx->create_srq_ex(context, srq_init_attr_ex);
+}
+
+/**
+ * ibv_modify_srq - Modifies the attributes for the specified SRQ.
+ * @srq: The SRQ to modify.
+ * @srq_attr: On input, specifies the SRQ attributes to modify. On output,
+ * the current values of selected SRQ attributes are returned.
+ * @srq_attr_mask: A bit-mask used to specify which attributes of the SRQ
+ * are being modified.
+ *
+ * The mask may contain IBV_SRQ_MAX_WR to resize the SRQ and/or
+ * IBV_SRQ_LIMIT to set the SRQ's limit and request notification when
+ * the number of receives queued drops below the limit.
+ */
+int ibv_modify_srq(struct ibv_srq *srq,
+ struct ibv_srq_attr *srq_attr,
+ int srq_attr_mask);
+
+/**
+ * ibv_query_srq - Returns the attribute list and current values for the
+ * specified SRQ.
+ * @srq: The SRQ to query.
+ * @srq_attr: The attributes of the specified SRQ.
+ */
+int ibv_query_srq(struct ibv_srq *srq, struct ibv_srq_attr *srq_attr);
+
+static inline int ibv_get_srq_num(struct ibv_srq *srq, uint32_t *srq_num)
+{
+ struct verbs_context *vctx = verbs_get_ctx_op(srq->context, get_srq_num);
+
+ if (!vctx)
+ return ENOSYS;
+
+ return vctx->get_srq_num(srq, srq_num);
+}
+
+/**
+ * ibv_destroy_srq - Destroys the specified SRQ.
+ * @srq: The SRQ to destroy.
+ */
+int ibv_destroy_srq(struct ibv_srq *srq);
+
+/**
+ * ibv_post_srq_recv - Posts a list of work requests to the specified SRQ.
+ * @srq: The SRQ to post the work request on.
+ * @recv_wr: A list of work requests to post on the receive queue.
+ * @bad_recv_wr: On an immediate failure, this parameter will reference
+ * the work request that failed to be posted on the QP.
+ */
+static inline int ibv_post_srq_recv(struct ibv_srq *srq,
+ struct ibv_recv_wr *recv_wr,
+ struct ibv_recv_wr **bad_recv_wr)
+{
+ return srq->context->ops.post_srq_recv(srq, recv_wr, bad_recv_wr);
+}
+
+/**
+ * ibv_create_qp - Create a queue pair.
+ */
+struct ibv_qp *ibv_create_qp(struct ibv_pd *pd,
+ struct ibv_qp_init_attr *qp_init_attr);
+
+static inline struct ibv_qp *
+ibv_create_qp_ex(struct ibv_context *context, struct ibv_qp_init_attr_ex *qp_init_attr_ex)
+{
+ struct verbs_context *vctx;
+ uint32_t mask = qp_init_attr_ex->comp_mask;
+
+ if (mask == IBV_QP_INIT_ATTR_PD)
+ return ibv_create_qp(qp_init_attr_ex->pd,
+ (struct ibv_qp_init_attr *)qp_init_attr_ex);
+
+ vctx = verbs_get_ctx_op(context, create_qp_ex);
+ if (!vctx) {
+ errno = ENOSYS;
+ return NULL;
+ }
+ return vctx->create_qp_ex(context, qp_init_attr_ex);
+}
+
+/**
+ * ibv_query_rt_values_ex - Get current real time @values of a device.
+ * @values - in/out - defines the attributes we need to query/queried.
+ * (Or's bits of enum ibv_values_mask on values->comp_mask field)
+ */
+static inline int
+ibv_query_rt_values_ex(struct ibv_context *context,
+ struct ibv_values_ex *values)
+{
+ struct verbs_context *vctx;
+
+ vctx = verbs_get_ctx_op(context, query_rt_values);
+ if (!vctx)
+ return ENOSYS;
+
+ if (values->comp_mask & ~(IBV_VALUES_MASK_RESERVED - 1))
+ return EINVAL;
+
+ return vctx->query_rt_values(context, values);
+}
+
+/**
+ * ibv_query_device_ex - Get extended device properties
+ */
+static inline int
+ibv_query_device_ex(struct ibv_context *context,
+ const struct ibv_query_device_ex_input *input,
+ struct ibv_device_attr_ex *attr)
+{
+ struct verbs_context *vctx;
+ int ret;
+
+ vctx = verbs_get_ctx_op(context, query_device_ex);
+ if (!vctx)
+ goto legacy;
+
+ ret = vctx->query_device_ex(context, input, attr, sizeof(*attr));
+ if (ret == ENOSYS)
+ goto legacy;
+
+ return ret;
+
+legacy:
+ memset(attr, 0, sizeof(*attr));
+ ret = ibv_query_device(context, &attr->orig_attr);
+
+ return ret;
+}
+
+/**
+ * ibv_open_qp - Open a shareable queue pair.
+ */
+static inline struct ibv_qp *
+ibv_open_qp(struct ibv_context *context, struct ibv_qp_open_attr *qp_open_attr)
+{
+ struct verbs_context *vctx = verbs_get_ctx_op(context, open_qp);
+ if (!vctx) {
+ errno = ENOSYS;
+ return NULL;
+ }
+ return vctx->open_qp(context, qp_open_attr);
+}
+
+/**
+ * ibv_modify_qp - Modify a queue pair.
+ */
+int ibv_modify_qp(struct ibv_qp *qp, struct ibv_qp_attr *attr,
+ int attr_mask);
+
+/**
+ * ibv_query_qp - Returns the attribute list and current values for the
+ * specified QP.
+ * @qp: The QP to query.
+ * @attr: The attributes of the specified QP.
+ * @attr_mask: A bit-mask used to select specific attributes to query.
+ * @init_attr: Additional attributes of the selected QP.
+ *
+ * The qp_attr_mask may be used to limit the query to gathering only the
+ * selected attributes.
+ */
+int ibv_query_qp(struct ibv_qp *qp, struct ibv_qp_attr *attr,
+ int attr_mask,
+ struct ibv_qp_init_attr *init_attr);
+
+/**
+ * ibv_destroy_qp - Destroy a queue pair.
+ */
+int ibv_destroy_qp(struct ibv_qp *qp);
+
+/*
+ * ibv_create_wq - Creates a WQ associated with the specified protection
+ * domain.
+ * @context: ibv_context.
+ * @wq_init_attr: A list of initial attributes required to create the
+ * WQ. If WQ creation succeeds, then the attributes are updated to
+ * the actual capabilities of the created WQ.
+ *
+ * wq_init_attr->max_wr and wq_init_attr->max_sge determine
+ * the requested size of the WQ, and set to the actual values allocated
+ * on return.
+ * If ibv_create_wq() succeeds, then max_wr and max_sge will always be
+ * at least as large as the requested values.
+ *
+ * Return Value
+ * ibv_create_wq() returns a pointer to the created WQ, or NULL if the request
+ * fails.
+ */
+static inline struct ibv_wq *ibv_create_wq(struct ibv_context *context,
+ struct ibv_wq_init_attr *wq_init_attr)
+{
+ struct verbs_context *vctx = verbs_get_ctx_op(context, create_wq);
+ struct ibv_wq *wq;
+
+ if (!vctx) {
+ errno = ENOSYS;
+ return NULL;
+ }
+
+ wq = vctx->create_wq(context, wq_init_attr);
+ if (wq) {
+ wq->events_completed = 0;
+ pthread_mutex_init(&wq->mutex, NULL);
+ pthread_cond_init(&wq->cond, NULL);
+ }
+
+ return wq;
+}
+
+/*
+ * ibv_modify_wq - Modifies the attributes for the specified WQ.
+ * @wq: The WQ to modify.
+ * @wq_attr: On input, specifies the WQ attributes to modify.
+ * wq_attr->attr_mask: A bit-mask used to specify which attributes of the WQ
+ * are being modified.
+ * On output, the current values of selected WQ attributes are returned.
+ *
+ * Return Value
+ * ibv_modify_wq() returns 0 on success, or the value of errno
+ * on failure (which indicates the failure reason).
+ *
+*/
+static inline int ibv_modify_wq(struct ibv_wq *wq, struct ibv_wq_attr *wq_attr)
+{
+ struct verbs_context *vctx = verbs_get_ctx_op(wq->context, modify_wq);
+
+ if (!vctx)
+ return ENOSYS;
+
+ return vctx->modify_wq(wq, wq_attr);
+}
+
+/*
+ * ibv_destroy_wq - Destroys the specified WQ.
+ * @ibv_wq: The WQ to destroy.
+ * Return Value
+ * ibv_destroy_wq() returns 0 on success, or the value of errno
+ * on failure (which indicates the failure reason).
+*/
+static inline int ibv_destroy_wq(struct ibv_wq *wq)
+{
+ struct verbs_context *vctx;
+
+ vctx = verbs_get_ctx_op(wq->context, destroy_wq);
+ if (!vctx)
+ return ENOSYS;
+
+ return vctx->destroy_wq(wq);
+}
+
+/*
+ * ibv_create_rwq_ind_table - Creates a receive work queue Indirection Table
+ * @context: ibv_context.
+ * @init_attr: A list of initial attributes required to create the Indirection Table.
+ * Return Value
+ * ibv_create_rwq_ind_table returns a pointer to the created
+ * Indirection Table, or NULL if the request fails.
+ */
+static inline struct ibv_rwq_ind_table *ibv_create_rwq_ind_table(struct ibv_context *context,
+ struct ibv_rwq_ind_table_init_attr *init_attr)
+{
+ struct verbs_context *vctx;
+
+ vctx = verbs_get_ctx_op(context, create_rwq_ind_table);
+ if (!vctx) {
+ errno = ENOSYS;
+ return NULL;
+ }
+
+ return vctx->create_rwq_ind_table(context, init_attr);
+}
+
+/*
+ * ibv_destroy_rwq_ind_table - Destroys the specified Indirection Table.
+ * @rwq_ind_table: The Indirection Table to destroy.
+ * Return Value
+ * ibv_destroy_rwq_ind_table() returns 0 on success, or the value of errno
+ * on failure (which indicates the failure reason).
+*/
+static inline int ibv_destroy_rwq_ind_table(struct ibv_rwq_ind_table *rwq_ind_table)
+{
+ struct verbs_context *vctx;
+
+ vctx = verbs_get_ctx_op(rwq_ind_table->context, destroy_rwq_ind_table);
+ if (!vctx)
+ return ENOSYS;
+
+ return vctx->destroy_rwq_ind_table(rwq_ind_table);
+}
+
+/**
+ * ibv_post_send - Post a list of work requests to a send queue.
+ *
+ * If IBV_SEND_INLINE flag is set, the data buffers can be reused
+ * immediately after the call returns.
+ */
+static inline int ibv_post_send(struct ibv_qp *qp, struct ibv_send_wr *wr,
+ struct ibv_send_wr **bad_wr)
+{
+ return qp->context->ops.post_send(qp, wr, bad_wr);
+}
+
+/**
+ * ibv_post_recv - Post a list of work requests to a receive queue.
+ */
+static inline int ibv_post_recv(struct ibv_qp *qp, struct ibv_recv_wr *wr,
+ struct ibv_recv_wr **bad_wr)
+{
+ return qp->context->ops.post_recv(qp, wr, bad_wr);
+}
+
+/**
+ * ibv_create_ah - Create an address handle.
+ */
+struct ibv_ah *ibv_create_ah(struct ibv_pd *pd, struct ibv_ah_attr *attr);
+
+/**
+ * ibv_init_ah_from_wc - Initializes address handle attributes from a
+ * work completion.
+ * @context: Device context on which the received message arrived.
+ * @port_num: Port on which the received message arrived.
+ * @wc: Work completion associated with the received message.
+ * @grh: References the received global route header. This parameter is
+ * ignored unless the work completion indicates that the GRH is valid.
+ * @ah_attr: Returned attributes that can be used when creating an address
+ * handle for replying to the message.
+ */
+int ibv_init_ah_from_wc(struct ibv_context *context, uint8_t port_num,
+ struct ibv_wc *wc, struct ibv_grh *grh,
+ struct ibv_ah_attr *ah_attr);
+
+/**
+ * ibv_create_ah_from_wc - Creates an address handle associated with the
+ * sender of the specified work completion.
+ * @pd: The protection domain associated with the address handle.
+ * @wc: Work completion information associated with a received message.
+ * @grh: References the received global route header. This parameter is
+ * ignored unless the work completion indicates that the GRH is valid.
+ * @port_num: The outbound port number to associate with the address.
+ *
+ * The address handle is used to reference a local or global destination
+ * in all UD QP post sends.
+ */
+struct ibv_ah *ibv_create_ah_from_wc(struct ibv_pd *pd, struct ibv_wc *wc,
+ struct ibv_grh *grh, uint8_t port_num);
+
+/**
+ * ibv_destroy_ah - Destroy an address handle.
+ */
+int ibv_destroy_ah(struct ibv_ah *ah);
+
+/**
+ * ibv_attach_mcast - Attaches the specified QP to a multicast group.
+ * @qp: QP to attach to the multicast group. The QP must be a UD QP.
+ * @gid: Multicast group GID.
+ * @lid: Multicast group LID in host byte order.
+ *
+ * In order to route multicast packets correctly, subnet
+ * administration must have created the multicast group and configured
+ * the fabric appropriately. The port associated with the specified
+ * QP must also be a member of the multicast group.
+ */
+int ibv_attach_mcast(struct ibv_qp *qp, const union ibv_gid *gid, uint16_t lid);
+
+/**
+ * ibv_detach_mcast - Detaches the specified QP from a multicast group.
+ * @qp: QP to detach from the multicast group.
+ * @gid: Multicast group GID.
+ * @lid: Multicast group LID in host byte order.
+ */
+int ibv_detach_mcast(struct ibv_qp *qp, const union ibv_gid *gid, uint16_t lid);
+
+/**
+ * ibv_fork_init - Prepare data structures so that fork() may be used
+ * safely. If this function is not called or returns a non-zero
+ * status, then libibverbs data structures are not fork()-safe and the
+ * effect of an application calling fork() is undefined.
+ */
+int ibv_fork_init(void);
+
+/**
+ * ibv_node_type_str - Return string describing node_type enum value
+ */
+const char *ibv_node_type_str(enum ibv_node_type node_type);
+
+/**
+ * ibv_port_state_str - Return string describing port_state enum value
+ */
+const char *ibv_port_state_str(enum ibv_port_state port_state);
+
+/**
+ * ibv_event_type_str - Return string describing event_type enum value
+ */
+const char *ibv_event_type_str(enum ibv_event_type event);
+
+#define ETHERNET_LL_SIZE 6
+int ibv_resolve_eth_l2_from_gid(struct ibv_context *context,
+ struct ibv_ah_attr *attr,
+ uint8_t eth_mac[ETHERNET_LL_SIZE],
+ uint16_t *vid);
+
+static inline int ibv_is_qpt_supported(uint32_t caps, enum ibv_qp_type qpt)
+{
+ return !!(caps & (1 << qpt));
+}
+
+END_C_DECLS
+
+# undef __attribute_const
+
+
+#endif /* INFINIBAND_VERBS_H */
diff --git a/contrib/ofed/libmlx4/AUTHORS b/contrib/ofed/libmlx4/AUTHORS
deleted file mode 100644
index ffe1800..0000000
--- a/contrib/ofed/libmlx4/AUTHORS
+++ /dev/null
@@ -1 +0,0 @@
-Roland Dreier <rolandd@cisco.com>
diff --git a/contrib/ofed/libmlx4/COPYING b/contrib/ofed/libmlx4/COPYING
deleted file mode 100644
index add3d19..0000000
--- a/contrib/ofed/libmlx4/COPYING
+++ /dev/null
@@ -1,378 +0,0 @@
-This software is available to you under a choice of one of two
-licenses. You may choose to be licensed under the terms of the the
-OpenIB.org BSD license or the GNU General Public License (GPL) Version
-2, both included below.
-
-Copyright (c) 2007 Cisco, Inc. All rights reserved.
-
-==================================================================
-
- OpenIB.org BSD license
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions
-are met:
-
- * Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
-
- * Redistributions in binary form must reproduce the above
- copyright notice, this list of conditions and the following
- disclaimer in the documentation and/or other materials provided
- with the distribution.
-
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
-FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
-COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
-INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
-BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
-LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
-CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
-ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-POSSIBILITY OF SUCH DAMAGE.
-
-==================================================================
-
- GNU GENERAL PUBLIC LICENSE
- Version 2, June 1991
-
- Copyright (C) 1989, 1991 Free Software Foundation, Inc.
- 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- Everyone is permitted to copy and distribute verbatim copies
- of this license document, but changing it is not allowed.
-
- Preamble
-
- The licenses for most software are designed to take away your
-freedom to share and change it. By contrast, the GNU General Public
-License is intended to guarantee your freedom to share and change free
-software--to make sure the software is free for all its users. This
-General Public License applies to most of the Free Software
-Foundation's software and to any other program whose authors commit to
-using it. (Some other Free Software Foundation software is covered by
-the GNU Library General Public License instead.) You can apply it to
-your programs, too.
-
- When we speak of free software, we are referring to freedom, not
-price. Our General Public Licenses are designed to make sure that you
-have the freedom to distribute copies of free software (and charge for
-this service if you wish), that you receive source code or can get it
-if you want it, that you can change the software or use pieces of it
-in new free programs; and that you know you can do these things.
-
- To protect your rights, we need to make restrictions that forbid
-anyone to deny you these rights or to ask you to surrender the rights.
-These restrictions translate to certain responsibilities for you if you
-distribute copies of the software, or if you modify it.
-
- For example, if you distribute copies of such a program, whether
-gratis or for a fee, you must give the recipients all the rights that
-you have. You must make sure that they, too, receive or can get the
-source code. And you must show them these terms so they know their
-rights.
-
- We protect your rights with two steps: (1) copyright the software, and
-(2) offer you this license which gives you legal permission to copy,
-distribute and/or modify the software.
-
- Also, for each author's protection and ours, we want to make certain
-that everyone understands that there is no warranty for this free
-software. If the software is modified by someone else and passed on, we
-want its recipients to know that what they have is not the original, so
-that any problems introduced by others will not reflect on the original
-authors' reputations.
-
- Finally, any free program is threatened constantly by software
-patents. We wish to avoid the danger that redistributors of a free
-program will individually obtain patent licenses, in effect making the
-program proprietary. To prevent this, we have made it clear that any
-patent must be licensed for everyone's free use or not licensed at all.
-
- The precise terms and conditions for copying, distribution and
-modification follow.
-
- GNU GENERAL PUBLIC LICENSE
- TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
-
- 0. This License applies to any program or other work which contains
-a notice placed by the copyright holder saying it may be distributed
-under the terms of this General Public License. The "Program", below,
-refers to any such program or work, and a "work based on the Program"
-means either the Program or any derivative work under copyright law:
-that is to say, a work containing the Program or a portion of it,
-either verbatim or with modifications and/or translated into another
-language. (Hereinafter, translation is included without limitation in
-the term "modification".) Each licensee is addressed as "you".
-
-Activities other than copying, distribution and modification are not
-covered by this License; they are outside its scope. The act of
-running the Program is not restricted, and the output from the Program
-is covered only if its contents constitute a work based on the
-Program (independent of having been made by running the Program).
-Whether that is true depends on what the Program does.
-
- 1. You may copy and distribute verbatim copies of the Program's
-source code as you receive it, in any medium, provided that you
-conspicuously and appropriately publish on each copy an appropriate
-copyright notice and disclaimer of warranty; keep intact all the
-notices that refer to this License and to the absence of any warranty;
-and give any other recipients of the Program a copy of this License
-along with the Program.
-
-You may charge a fee for the physical act of transferring a copy, and
-you may at your option offer warranty protection in exchange for a fee.
-
- 2. You may modify your copy or copies of the Program or any portion
-of it, thus forming a work based on the Program, and copy and
-distribute such modifications or work under the terms of Section 1
-above, provided that you also meet all of these conditions:
-
- a) You must cause the modified files to carry prominent notices
- stating that you changed the files and the date of any change.
-
- b) You must cause any work that you distribute or publish, that in
- whole or in part contains or is derived from the Program or any
- part thereof, to be licensed as a whole at no charge to all third
- parties under the terms of this License.
-
- c) If the modified program normally reads commands interactively
- when run, you must cause it, when started running for such
- interactive use in the most ordinary way, to print or display an
- announcement including an appropriate copyright notice and a
- notice that there is no warranty (or else, saying that you provide
- a warranty) and that users may redistribute the program under
- these conditions, and telling the user how to view a copy of this
- License. (Exception: if the Program itself is interactive but
- does not normally print such an announcement, your work based on
- the Program is not required to print an announcement.)
-
-These requirements apply to the modified work as a whole. If
-identifiable sections of that work are not derived from the Program,
-and can be reasonably considered independent and separate works in
-themselves, then this License, and its terms, do not apply to those
-sections when you distribute them as separate works. But when you
-distribute the same sections as part of a whole which is a work based
-on the Program, the distribution of the whole must be on the terms of
-this License, whose permissions for other licensees extend to the
-entire whole, and thus to each and every part regardless of who wrote it.
-
-Thus, it is not the intent of this section to claim rights or contest
-your rights to work written entirely by you; rather, the intent is to
-exercise the right to control the distribution of derivative or
-collective works based on the Program.
-
-In addition, mere aggregation of another work not based on the Program
-with the Program (or with a work based on the Program) on a volume of
-a storage or distribution medium does not bring the other work under
-the scope of this License.
-
- 3. You may copy and distribute the Program (or a work based on it,
-under Section 2) in object code or executable form under the terms of
-Sections 1 and 2 above provided that you also do one of the following:
-
- a) Accompany it with the complete corresponding machine-readable
- source code, which must be distributed under the terms of Sections
- 1 and 2 above on a medium customarily used for software interchange; or,
-
- b) Accompany it with a written offer, valid for at least three
- years, to give any third party, for a charge no more than your
- cost of physically performing source distribution, a complete
- machine-readable copy of the corresponding source code, to be
- distributed under the terms of Sections 1 and 2 above on a medium
- customarily used for software interchange; or,
-
- c) Accompany it with the information you received as to the offer
- to distribute corresponding source code. (This alternative is
- allowed only for noncommercial distribution and only if you
- received the program in object code or executable form with such
- an offer, in accord with Subsection b above.)
-
-The source code for a work means the preferred form of the work for
-making modifications to it. For an executable work, complete source
-code means all the source code for all modules it contains, plus any
-associated interface definition files, plus the scripts used to
-control compilation and installation of the executable. However, as a
-special exception, the source code distributed need not include
-anything that is normally distributed (in either source or binary
-form) with the major components (compiler, kernel, and so on) of the
-operating system on which the executable runs, unless that component
-itself accompanies the executable.
-
-If distribution of executable or object code is made by offering
-access to copy from a designated place, then offering equivalent
-access to copy the source code from the same place counts as
-distribution of the source code, even though third parties are not
-compelled to copy the source along with the object code.
-
- 4. You may not copy, modify, sublicense, or distribute the Program
-except as expressly provided under this License. Any attempt
-otherwise to copy, modify, sublicense or distribute the Program is
-void, and will automatically terminate your rights under this License.
-However, parties who have received copies, or rights, from you under
-this License will not have their licenses terminated so long as such
-parties remain in full compliance.
-
- 5. You are not required to accept this License, since you have not
-signed it. However, nothing else grants you permission to modify or
-distribute the Program or its derivative works. These actions are
-prohibited by law if you do not accept this License. Therefore, by
-modifying or distributing the Program (or any work based on the
-Program), you indicate your acceptance of this License to do so, and
-all its terms and conditions for copying, distributing or modifying
-the Program or works based on it.
-
- 6. Each time you redistribute the Program (or any work based on the
-Program), the recipient automatically receives a license from the
-original licensor to copy, distribute or modify the Program subject to
-these terms and conditions. You may not impose any further
-restrictions on the recipients' exercise of the rights granted herein.
-You are not responsible for enforcing compliance by third parties to
-this License.
-
- 7. If, as a consequence of a court judgment or allegation of patent
-infringement or for any other reason (not limited to patent issues),
-conditions are imposed on you (whether by court order, agreement or
-otherwise) that contradict the conditions of this License, they do not
-excuse you from the conditions of this License. If you cannot
-distribute so as to satisfy simultaneously your obligations under this
-License and any other pertinent obligations, then as a consequence you
-may not distribute the Program at all. For example, if a patent
-license would not permit royalty-free redistribution of the Program by
-all those who receive copies directly or indirectly through you, then
-the only way you could satisfy both it and this License would be to
-refrain entirely from distribution of the Program.
-
-If any portion of this section is held invalid or unenforceable under
-any particular circumstance, the balance of the section is intended to
-apply and the section as a whole is intended to apply in other
-circumstances.
-
-It is not the purpose of this section to induce you to infringe any
-patents or other property right claims or to contest validity of any
-such claims; this section has the sole purpose of protecting the
-integrity of the free software distribution system, which is
-implemented by public license practices. Many people have made
-generous contributions to the wide range of software distributed
-through that system in reliance on consistent application of that
-system; it is up to the author/donor to decide if he or she is willing
-to distribute software through any other system and a licensee cannot
-impose that choice.
-
-This section is intended to make thoroughly clear what is believed to
-be a consequence of the rest of this License.
-
- 8. If the distribution and/or use of the Program is restricted in
-certain countries either by patents or by copyrighted interfaces, the
-original copyright holder who places the Program under this License
-may add an explicit geographical distribution limitation excluding
-those countries, so that distribution is permitted only in or among
-countries not thus excluded. In such case, this License incorporates
-the limitation as if written in the body of this License.
-
- 9. The Free Software Foundation may publish revised and/or new versions
-of the General Public License from time to time. Such new versions will
-be similar in spirit to the present version, but may differ in detail to
-address new problems or concerns.
-
-Each version is given a distinguishing version number. If the Program
-specifies a version number of this License which applies to it and "any
-later version", you have the option of following the terms and conditions
-either of that version or of any later version published by the Free
-Software Foundation. If the Program does not specify a version number of
-this License, you may choose any version ever published by the Free Software
-Foundation.
-
- 10. If you wish to incorporate parts of the Program into other free
-programs whose distribution conditions are different, write to the author
-to ask for permission. For software which is copyrighted by the Free
-Software Foundation, write to the Free Software Foundation; we sometimes
-make exceptions for this. Our decision will be guided by the two goals
-of preserving the free status of all derivatives of our free software and
-of promoting the sharing and reuse of software generally.
-
- NO WARRANTY
-
- 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
-FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
-OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
-PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
-OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
-MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
-TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
-PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
-REPAIR OR CORRECTION.
-
- 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
-WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
-REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
-INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
-OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
-TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
-YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
-PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
-POSSIBILITY OF SUCH DAMAGES.
-
- END OF TERMS AND CONDITIONS
-
- How to Apply These Terms to Your New Programs
-
- If you develop a new program, and you want it to be of the greatest
-possible use to the public, the best way to achieve this is to make it
-free software which everyone can redistribute and change under these terms.
-
- To do so, attach the following notices to the program. It is safest
-to attach them to the start of each source file to most effectively
-convey the exclusion of warranty; and each file should have at least
-the "copyright" line and a pointer to where the full notice is found.
-
- <one line to give the program's name and a brief idea of what it does.>
- Copyright (C) <year> <name of author>
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program 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 this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-
-Also add information on how to contact you by electronic and paper mail.
-
-If the program is interactive, make it output a short notice like this
-when it starts in an interactive mode:
-
- Gnomovision version 69, Copyright (C) year name of author
- Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
- This is free software, and you are welcome to redistribute it
- under certain conditions; type `show c' for details.
-
-The hypothetical commands `show w' and `show c' should show the appropriate
-parts of the General Public License. Of course, the commands you use may
-be called something other than `show w' and `show c'; they could even be
-mouse-clicks or menu items--whatever suits your program.
-
-You should also get your employer (if you work as a programmer) or your
-school, if any, to sign a "copyright disclaimer" for the program, if
-necessary. Here is a sample; alter the names:
-
- Yoyodyne, Inc., hereby disclaims all copyright interest in the program
- `Gnomovision' (which makes passes at compilers) written by James Hacker.
-
- <signature of Ty Coon>, 1 April 1989
- Ty Coon, President of Vice
-
-This General Public License does not permit incorporating your program into
-proprietary programs. If your program is a subroutine library, you may
-consider it more useful to permit linking proprietary applications with the
-library. If this is what you want to do, use the GNU Library General
-Public License instead of this License.
diff --git a/contrib/ofed/libmlx4/Makefile b/contrib/ofed/libmlx4/Makefile
new file mode 100644
index 0000000..d460cc2
--- /dev/null
+++ b/contrib/ofed/libmlx4/Makefile
@@ -0,0 +1,22 @@
+# $FreeBSD$
+
+.PATH: ${.CURDIR}
+
+SHLIBDIR?= /usr/lib
+LIB= mlx4
+SHLIB_MAJOR= 1
+MK_PROFILE= no
+
+SRCS= \
+buf.c \
+cq.c \
+dbrec.c \
+mlx4.c \
+qp.c \
+srq.c \
+verbs.c
+
+LIBADD= ibverbs pthread
+CFLAGS+= -I${.CURDIR}
+
+.include <bsd.lib.mk>
diff --git a/contrib/ofed/libmlx4/Makefile.am b/contrib/ofed/libmlx4/Makefile.am
deleted file mode 100644
index a7afb14..0000000
--- a/contrib/ofed/libmlx4/Makefile.am
+++ /dev/null
@@ -1,26 +0,0 @@
-AM_CFLAGS = -g -Wall -D_GNU_SOURCE
-
-mlx4_version_script = @MLX4_VERSION_SCRIPT@
-
-MLX4_SOURCES = src/buf.c src/cq.c src/dbrec.c src/mlx4.c src/qp.c \
- src/srq.c src/verbs.c
-
-if HAVE_IBV_DEVICE_LIBRARY_EXTENSION
- lib_LTLIBRARIES = src/libmlx4.la
- src_libmlx4_la_SOURCES = $(MLX4_SOURCES)
- src_libmlx4_la_LDFLAGS = -avoid-version -release @IBV_DEVICE_LIBRARY_EXTENSION@ \
- $(mlx4_version_script)
- mlx4confdir = $(sysconfdir)/libibverbs.d
- mlx4conf_DATA = mlx4.driver
-else
- mlx4libdir = $(libdir)/infiniband
- mlx4lib_LTLIBRARIES = src/mlx4.la
- src_mlx4_la_SOURCES = $(MLX4_SOURCES)
- src_mlx4_la_LDFLAGS = -avoid-version -module $(mlx4_version_script)
-endif
-
-EXTRA_DIST = src/doorbell.h src/mlx4.h src/mlx4-abi.h src/wqe.h \
- src/mlx4.map libmlx4.spec.in mlx4.driver
-
-dist-hook: libmlx4.spec
- cp libmlx4.spec $(distdir)
diff --git a/contrib/ofed/libmlx4/README b/contrib/ofed/libmlx4/README
deleted file mode 100644
index 5c027ef..0000000
--- a/contrib/ofed/libmlx4/README
+++ /dev/null
@@ -1,58 +0,0 @@
-Introduction
-============
-
-libmlx4 is a userspace driver for Mellanox ConnectX InfiniBand HCAs.
-It is a plug-in module for libibverbs that allows programs to use
-Mellanox hardware directly from userspace. See the libibverbs package
-for more information.
-
-Using libmlx4
-==============
-
-libmlx4 will be loaded and used automatically by programs linked with
-libibverbs. The mlx4_ib kernel module must be loaded for HCA devices
-to be detected and used.
-
-Supported Hardware
-==================
-
-libmlx4 currently supports HCAs based on the following Mellanox chip:
-
- MT25408 ConnectX (PCI Express)
-
-These HCAs use the mlx4_ib kernel driver. Support for other Mellanox
-HCAs, which use the ib_mthca kernel driver, is provided by the
-libmthca userspace driver.
-
-Valgrind Support
-================
-
-When running applications that use libibverbs under the Valgrind
-memory-checking debugger, Valgrind will falsely report "read from
-uninitialized" for memory that was initialized by the kernel drivers
-or HCA hardware. Specifically, Valgrind cannot see when kernel
-drivers or HCA hardware write to userspace memory, so when the process
-reads from that memory, Valgrind incorrectly assumes that the memory
-contents are uninitialized, and therefore raises a warning.
-
-libmlx4 can be built with specific support for the Valgrind
-memory-checking debugger by specifying the --with-valgrind command
-line argument to configure. This flag enables code in libibverbs to
-tell Valgrind "this memory may look uninitialized, but it's really
-OK," which therefore suppresses the incorrect "read from
-uninitialized" warnings. This code adds trivial overhead to the
-critical performance path, so it is disabled by default. The intent
-is that production users can use a "normal" build of libmlx4 and
-developers can use the "valgrind debug" build by simply switching
-their OPENIB_DRIVER_PATH environment variables.
-
-Libmlx4 needs some header files from Valgrind in order to compile this
-support; it is important to use the header files from the same version
-of Valgrind that will be used at run time. You may need to specify
-the directory where Valgrind's header files are installed as an
-argument to --with-valgrind. For example
-
- ./configure --with-valgrind=/opt/valgrind
-
-will make the libmlx4 build look for valgrind headers in
-/opt/valgrind/include
diff --git a/contrib/ofed/libmlx4/autogen.sh b/contrib/ofed/libmlx4/autogen.sh
deleted file mode 100755
index fd47839..0000000
--- a/contrib/ofed/libmlx4/autogen.sh
+++ /dev/null
@@ -1,8 +0,0 @@
-#! /bin/sh
-
-set -x
-aclocal -I config
-libtoolize --force --copy
-autoheader
-automake --foreign --add-missing --copy
-autoconf
diff --git a/contrib/ofed/libmlx4/buf.c b/contrib/ofed/libmlx4/buf.c
new file mode 100644
index 0000000..9b41e7f
--- /dev/null
+++ b/contrib/ofed/libmlx4/buf.c
@@ -0,0 +1,64 @@
+/*
+ * Copyright (c) 2006, 2007 Cisco, Inc. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#include <config.h>
+
+#include <stdlib.h>
+#include <errno.h>
+#include <sys/mman.h>
+
+#include "mlx4.h"
+
+int mlx4_alloc_buf(struct mlx4_buf *buf, size_t size, int page_size)
+{
+ int ret;
+
+ buf->length = align(size, page_size);
+ buf->buf = mmap(NULL, buf->length, PROT_READ | PROT_WRITE,
+ MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
+ if (buf->buf == MAP_FAILED)
+ return errno;
+
+ ret = ibv_dontfork_range(buf->buf, size);
+ if (ret)
+ munmap(buf->buf, buf->length);
+
+ return ret;
+}
+
+void mlx4_free_buf(struct mlx4_buf *buf)
+{
+ if (buf->length) {
+ ibv_dofork_range(buf->buf, buf->length);
+ munmap(buf->buf, buf->length);
+ }
+}
diff --git a/contrib/ofed/libmlx4/config.h b/contrib/ofed/libmlx4/config.h
new file mode 100644
index 0000000..af75292
--- /dev/null
+++ b/contrib/ofed/libmlx4/config.h
@@ -0,0 +1,13 @@
+/* $FreeBSD$ */
+
+#ifdef __LP64__
+#define SIZEOF_LONG 8
+#else
+#define SIZEOF_LONG 4
+#endif
+
+#define VALGRIND_MAKE_MEM_DEFINED(...) 0
+#define SWITCH_FALLTHROUGH (void)0
+#define ALWAYS_INLINE __attribute__ ((__always_inline__))
+#define likely(x) __predict_true(x)
+#define unlikely(x) __predict_false(x)
diff --git a/contrib/ofed/libmlx4/configure.in b/contrib/ofed/libmlx4/configure.in
deleted file mode 100644
index 46a3a64..0000000
--- a/contrib/ofed/libmlx4/configure.in
+++ /dev/null
@@ -1,84 +0,0 @@
-dnl Process this file with autoconf to produce a configure script.
-
-AC_PREREQ(2.57)
-AC_INIT(libmlx4, 1.0, general@lists.openfabrics.org)
-AC_CONFIG_SRCDIR([src/mlx4.h])
-AC_CONFIG_AUX_DIR(config)
-AM_CONFIG_HEADER(config.h)
-AM_INIT_AUTOMAKE(libmlx4, 1.0)
-AM_PROG_LIBTOOL
-
-AC_ARG_WITH([valgrind],
- AC_HELP_STRING([--with-valgrind],
- [Enable Valgrind annotations (small runtime overhead, default NO)]))
-if test x$with_valgrind = x || test x$with_valgrind = xno; then
- want_valgrind=no
- AC_DEFINE([NVALGRIND], 1, [Define to 1 to disable Valgrind annotations.])
-else
- want_valgrind=yes
- if test -d $with_valgrind; then
- CPPFLAGS="$CPPFLAGS -I$with_valgrind/include"
- fi
-fi
-
-dnl Checks for programs
-AC_PROG_CC
-
-dnl Checks for libraries
-AC_CHECK_LIB(ibverbs, ibv_get_device_list, [],
- AC_MSG_ERROR([ibv_get_device_list() not found. libmlx4 requires libibverbs.]))
-
-dnl Checks for header files.
-AC_CHECK_HEADER(infiniband/driver.h, [],
- AC_MSG_ERROR([<infiniband/driver.h> not found. libmlx4 requires libibverbs.]))
-AC_HEADER_STDC
-AC_CHECK_HEADER(valgrind/memcheck.h,
- [AC_DEFINE(HAVE_VALGRIND_MEMCHECK_H, 1,
- [Define to 1 if you have the <valgrind/memcheck.h> header file.])],
- [if test $want_valgrind = yes; then
- AC_MSG_ERROR([Valgrind memcheck support requested, but <valgrind/memcheck.h> not found.])
- fi])
-
-dnl Checks for typedefs, structures, and compiler characteristics.
-AC_C_CONST
-AC_CHECK_SIZEOF(long)
-AC_CHECK_MEMBER(struct ibv_context.more_ops,
- [AC_DEFINE([HAVE_IBV_MORE_OPS], 1, [Define to 1 if more_ops is a member of ibv_context])],,
- [#include <infiniband/verbs.h>])
-AC_CHECK_MEMBER(struct ibv_more_ops.create_xrc_srq,
- [AC_DEFINE([HAVE_IBV_XRC_OPS], 1, [Define to 1 if have xrc ops])],,
- [#include <infiniband/verbs.h>])
-
-dnl Checks for library functions
-AC_CHECK_FUNC(ibv_read_sysfs_file, [],
- AC_MSG_ERROR([ibv_read_sysfs_file() not found. libmlx4 requires libibverbs >= 1.0.3.]))
-AC_CHECK_FUNCS(ibv_dontfork_range ibv_dofork_range ibv_register_driver)
-
-dnl Now check if for libibverbs 1.0 vs 1.1
-dummy=if$$
-cat <<IBV_VERSION > $dummy.c
-#include <infiniband/driver.h>
-IBV_DEVICE_LIBRARY_EXTENSION
-IBV_VERSION
-IBV_DEVICE_LIBRARY_EXTENSION=`$CC $CPPFLAGS -E $dummy.c 2> /dev/null | tail -1`
-rm -f $dummy.c
-AM_CONDITIONAL(HAVE_IBV_DEVICE_LIBRARY_EXTENSION,
- test $IBV_DEVICE_LIBRARY_EXTENSION != IBV_DEVICE_LIBRARY_EXTENSION)
-AC_SUBST(IBV_DEVICE_LIBRARY_EXTENSION)
-
-AC_CACHE_CHECK(whether ld accepts --version-script, ac_cv_version_script,
- [if test -n "`$LD --help < /dev/null 2>/dev/null | grep version-script`"; then
- ac_cv_version_script=yes
- else
- ac_cv_version_script=no
- fi])
-
-if test $ac_cv_version_script = yes; then
- MLX4_VERSION_SCRIPT='-Wl,--version-script=$(srcdir)/src/mlx4.map'
-else
- MLX4_VERSION_SCRIPT=
-fi
-AC_SUBST(MLX4_VERSION_SCRIPT)
-
-AC_CONFIG_FILES([Makefile libmlx4.spec])
-AC_OUTPUT
diff --git a/contrib/ofed/libmlx4/cq.c b/contrib/ofed/libmlx4/cq.c
new file mode 100644
index 0000000..aa2ec1e
--- /dev/null
+++ b/contrib/ofed/libmlx4/cq.c
@@ -0,0 +1,819 @@
+/*
+ * Copyright (c) 2005 Topspin Communications. All rights reserved.
+ * Copyright (c) 2005 Mellanox Technologies Ltd. All rights reserved.
+ * Copyright (c) 2006, 2007 Cisco Systems. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#include <config.h>
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <pthread.h>
+#include <string.h>
+
+#include <infiniband/opcode.h>
+
+#include "mlx4.h"
+#include "doorbell.h"
+
+enum {
+ MLX4_CQ_DOORBELL = 0x20
+};
+
+enum {
+ CQ_OK = 0,
+ CQ_EMPTY = -1,
+ CQ_POLL_ERR = -2
+};
+
+#define MLX4_CQ_DB_REQ_NOT_SOL (1 << 24)
+#define MLX4_CQ_DB_REQ_NOT (2 << 24)
+
+enum {
+ MLX4_CQE_VLAN_PRESENT_MASK = 1 << 29,
+ MLX4_CQE_QPN_MASK = 0xffffff,
+};
+
+enum {
+ MLX4_CQE_OWNER_MASK = 0x80,
+ MLX4_CQE_IS_SEND_MASK = 0x40,
+ MLX4_CQE_OPCODE_MASK = 0x1f
+};
+
+enum {
+ MLX4_CQE_SYNDROME_LOCAL_LENGTH_ERR = 0x01,
+ MLX4_CQE_SYNDROME_LOCAL_QP_OP_ERR = 0x02,
+ MLX4_CQE_SYNDROME_LOCAL_PROT_ERR = 0x04,
+ MLX4_CQE_SYNDROME_WR_FLUSH_ERR = 0x05,
+ MLX4_CQE_SYNDROME_MW_BIND_ERR = 0x06,
+ MLX4_CQE_SYNDROME_BAD_RESP_ERR = 0x10,
+ MLX4_CQE_SYNDROME_LOCAL_ACCESS_ERR = 0x11,
+ MLX4_CQE_SYNDROME_REMOTE_INVAL_REQ_ERR = 0x12,
+ MLX4_CQE_SYNDROME_REMOTE_ACCESS_ERR = 0x13,
+ MLX4_CQE_SYNDROME_REMOTE_OP_ERR = 0x14,
+ MLX4_CQE_SYNDROME_TRANSPORT_RETRY_EXC_ERR = 0x15,
+ MLX4_CQE_SYNDROME_RNR_RETRY_EXC_ERR = 0x16,
+ MLX4_CQE_SYNDROME_REMOTE_ABORTED_ERR = 0x22,
+};
+
+struct mlx4_err_cqe {
+ uint32_t vlan_my_qpn;
+ uint32_t reserved1[5];
+ uint16_t wqe_index;
+ uint8_t vendor_err;
+ uint8_t syndrome;
+ uint8_t reserved2[3];
+ uint8_t owner_sr_opcode;
+};
+
+static struct mlx4_cqe *get_cqe(struct mlx4_cq *cq, int entry)
+{
+ return cq->buf.buf + entry * cq->cqe_size;
+}
+
+static void *get_sw_cqe(struct mlx4_cq *cq, int n)
+{
+ struct mlx4_cqe *cqe = get_cqe(cq, n & cq->ibv_cq.cqe);
+ struct mlx4_cqe *tcqe = cq->cqe_size == 64 ? cqe + 1 : cqe;
+
+ return (!!(tcqe->owner_sr_opcode & MLX4_CQE_OWNER_MASK) ^
+ !!(n & (cq->ibv_cq.cqe + 1))) ? NULL : cqe;
+}
+
+static struct mlx4_cqe *next_cqe_sw(struct mlx4_cq *cq)
+{
+ return get_sw_cqe(cq, cq->cons_index);
+}
+
+static enum ibv_wc_status mlx4_handle_error_cqe(struct mlx4_err_cqe *cqe)
+{
+ if (cqe->syndrome == MLX4_CQE_SYNDROME_LOCAL_QP_OP_ERR)
+ printf(PFX "local QP operation err "
+ "(QPN %06x, WQE index %x, vendor syndrome %02x, "
+ "opcode = %02x)\n",
+ htobe32(cqe->vlan_my_qpn), htobe32(cqe->wqe_index),
+ cqe->vendor_err,
+ cqe->owner_sr_opcode & ~MLX4_CQE_OWNER_MASK);
+
+ switch (cqe->syndrome) {
+ case MLX4_CQE_SYNDROME_LOCAL_LENGTH_ERR:
+ return IBV_WC_LOC_LEN_ERR;
+ case MLX4_CQE_SYNDROME_LOCAL_QP_OP_ERR:
+ return IBV_WC_LOC_QP_OP_ERR;
+ case MLX4_CQE_SYNDROME_LOCAL_PROT_ERR:
+ return IBV_WC_LOC_PROT_ERR;
+ case MLX4_CQE_SYNDROME_WR_FLUSH_ERR:
+ return IBV_WC_WR_FLUSH_ERR;
+ case MLX4_CQE_SYNDROME_MW_BIND_ERR:
+ return IBV_WC_MW_BIND_ERR;
+ case MLX4_CQE_SYNDROME_BAD_RESP_ERR:
+ return IBV_WC_BAD_RESP_ERR;
+ case MLX4_CQE_SYNDROME_LOCAL_ACCESS_ERR:
+ return IBV_WC_LOC_ACCESS_ERR;
+ case MLX4_CQE_SYNDROME_REMOTE_INVAL_REQ_ERR:
+ return IBV_WC_REM_INV_REQ_ERR;
+ case MLX4_CQE_SYNDROME_REMOTE_ACCESS_ERR:
+ return IBV_WC_REM_ACCESS_ERR;
+ case MLX4_CQE_SYNDROME_REMOTE_OP_ERR:
+ return IBV_WC_REM_OP_ERR;
+ case MLX4_CQE_SYNDROME_TRANSPORT_RETRY_EXC_ERR:
+ return IBV_WC_RETRY_EXC_ERR;
+ case MLX4_CQE_SYNDROME_RNR_RETRY_EXC_ERR:
+ return IBV_WC_RNR_RETRY_EXC_ERR;
+ case MLX4_CQE_SYNDROME_REMOTE_ABORTED_ERR:
+ return IBV_WC_REM_ABORT_ERR;
+ default:
+ return IBV_WC_GENERAL_ERR;
+ }
+}
+
+static inline void handle_good_req(struct ibv_wc *wc, struct mlx4_cqe *cqe)
+{
+ wc->wc_flags = 0;
+ switch (cqe->owner_sr_opcode & MLX4_CQE_OPCODE_MASK) {
+ case MLX4_OPCODE_RDMA_WRITE_IMM:
+ wc->wc_flags |= IBV_WC_WITH_IMM;
+ SWITCH_FALLTHROUGH;
+ case MLX4_OPCODE_RDMA_WRITE:
+ wc->opcode = IBV_WC_RDMA_WRITE;
+ break;
+ case MLX4_OPCODE_SEND_IMM:
+ wc->wc_flags |= IBV_WC_WITH_IMM;
+ SWITCH_FALLTHROUGH;
+ case MLX4_OPCODE_SEND:
+ case MLX4_OPCODE_SEND_INVAL:
+ wc->opcode = IBV_WC_SEND;
+ break;
+ case MLX4_OPCODE_RDMA_READ:
+ wc->opcode = IBV_WC_RDMA_READ;
+ wc->byte_len = be32toh(cqe->byte_cnt);
+ break;
+ case MLX4_OPCODE_ATOMIC_CS:
+ wc->opcode = IBV_WC_COMP_SWAP;
+ wc->byte_len = 8;
+ break;
+ case MLX4_OPCODE_ATOMIC_FA:
+ wc->opcode = IBV_WC_FETCH_ADD;
+ wc->byte_len = 8;
+ break;
+ case MLX4_OPCODE_LOCAL_INVAL:
+ wc->opcode = IBV_WC_LOCAL_INV;
+ break;
+ case MLX4_OPCODE_BIND_MW:
+ wc->opcode = IBV_WC_BIND_MW;
+ break;
+ default:
+ /* assume it's a send completion */
+ wc->opcode = IBV_WC_SEND;
+ break;
+ }
+}
+
+static inline int mlx4_get_next_cqe(struct mlx4_cq *cq,
+ struct mlx4_cqe **pcqe)
+ ALWAYS_INLINE;
+static inline int mlx4_get_next_cqe(struct mlx4_cq *cq,
+ struct mlx4_cqe **pcqe)
+{
+ struct mlx4_cqe *cqe;
+
+ cqe = next_cqe_sw(cq);
+ if (!cqe)
+ return CQ_EMPTY;
+
+ if (cq->cqe_size == 64)
+ ++cqe;
+
+ ++cq->cons_index;
+
+ VALGRIND_MAKE_MEM_DEFINED(cqe, sizeof *cqe);
+
+ /*
+ * Make sure we read CQ entry contents after we've checked the
+ * ownership bit.
+ */
+ udma_from_device_barrier();
+
+ *pcqe = cqe;
+
+ return CQ_OK;
+}
+
+static inline int mlx4_parse_cqe(struct mlx4_cq *cq,
+ struct mlx4_cqe *cqe,
+ struct mlx4_qp **cur_qp,
+ struct ibv_wc *wc, int lazy)
+ ALWAYS_INLINE;
+static inline int mlx4_parse_cqe(struct mlx4_cq *cq,
+ struct mlx4_cqe *cqe,
+ struct mlx4_qp **cur_qp,
+ struct ibv_wc *wc, int lazy)
+{
+ struct mlx4_wq *wq;
+ struct mlx4_srq *srq;
+ uint32_t qpn;
+ uint32_t g_mlpath_rqpn;
+ uint64_t *pwr_id;
+ uint16_t wqe_index;
+ struct mlx4_err_cqe *ecqe;
+ struct mlx4_context *mctx;
+ int is_error;
+ int is_send;
+ enum ibv_wc_status *pstatus;
+
+ mctx = to_mctx(cq->ibv_cq.context);
+ qpn = be32toh(cqe->vlan_my_qpn) & MLX4_CQE_QPN_MASK;
+ if (lazy) {
+ cq->cqe = cqe;
+ cq->flags &= (~MLX4_CQ_FLAGS_RX_CSUM_VALID);
+ } else
+ wc->qp_num = qpn;
+
+ is_send = cqe->owner_sr_opcode & MLX4_CQE_IS_SEND_MASK;
+ is_error = (cqe->owner_sr_opcode & MLX4_CQE_OPCODE_MASK) ==
+ MLX4_CQE_OPCODE_ERROR;
+
+ if ((qpn & MLX4_XRC_QPN_BIT) && !is_send) {
+ /*
+ * We do not have to take the XSRQ table lock here,
+ * because CQs will be locked while SRQs are removed
+ * from the table.
+ */
+ srq = mlx4_find_xsrq(&mctx->xsrq_table,
+ be32toh(cqe->g_mlpath_rqpn) & MLX4_CQE_QPN_MASK);
+ if (!srq)
+ return CQ_POLL_ERR;
+ } else {
+ if (!*cur_qp || (qpn != (*cur_qp)->verbs_qp.qp.qp_num)) {
+ /*
+ * We do not have to take the QP table lock here,
+ * because CQs will be locked while QPs are removed
+ * from the table.
+ */
+ *cur_qp = mlx4_find_qp(mctx, qpn);
+ if (!*cur_qp)
+ return CQ_POLL_ERR;
+ }
+ srq = ((*cur_qp)->verbs_qp.qp.srq) ? to_msrq((*cur_qp)->verbs_qp.qp.srq) : NULL;
+ }
+
+ pwr_id = lazy ? &cq->ibv_cq.wr_id : &wc->wr_id;
+ if (is_send) {
+ wq = &(*cur_qp)->sq;
+ wqe_index = be16toh(cqe->wqe_index);
+ wq->tail += (uint16_t) (wqe_index - (uint16_t) wq->tail);
+ *pwr_id = wq->wrid[wq->tail & (wq->wqe_cnt - 1)];
+ ++wq->tail;
+ } else if (srq) {
+ wqe_index = be16toh(cqe->wqe_index);
+ *pwr_id = srq->wrid[wqe_index];
+ mlx4_free_srq_wqe(srq, wqe_index);
+ } else {
+ wq = &(*cur_qp)->rq;
+ *pwr_id = wq->wrid[wq->tail & (wq->wqe_cnt - 1)];
+ ++wq->tail;
+ }
+
+ pstatus = lazy ? &cq->ibv_cq.status : &wc->status;
+ if (is_error) {
+ ecqe = (struct mlx4_err_cqe *)cqe;
+ *pstatus = mlx4_handle_error_cqe(ecqe);
+ if (!lazy)
+ wc->vendor_err = ecqe->vendor_err;
+ return CQ_OK;
+ }
+
+ *pstatus = IBV_WC_SUCCESS;
+ if (lazy) {
+ if (!is_send)
+ if ((*cur_qp) && ((*cur_qp)->qp_cap_cache & MLX4_RX_CSUM_VALID))
+ cq->flags |= MLX4_CQ_FLAGS_RX_CSUM_VALID;
+ } else if (is_send) {
+ handle_good_req(wc, cqe);
+ } else {
+ wc->byte_len = be32toh(cqe->byte_cnt);
+
+ switch (cqe->owner_sr_opcode & MLX4_CQE_OPCODE_MASK) {
+ case MLX4_RECV_OPCODE_RDMA_WRITE_IMM:
+ wc->opcode = IBV_WC_RECV_RDMA_WITH_IMM;
+ wc->wc_flags = IBV_WC_WITH_IMM;
+ wc->imm_data = cqe->immed_rss_invalid;
+ break;
+ case MLX4_RECV_OPCODE_SEND_INVAL:
+ wc->opcode = IBV_WC_RECV;
+ wc->wc_flags |= IBV_WC_WITH_INV;
+ wc->imm_data = be32toh(cqe->immed_rss_invalid);
+ break;
+ case MLX4_RECV_OPCODE_SEND:
+ wc->opcode = IBV_WC_RECV;
+ wc->wc_flags = 0;
+ break;
+ case MLX4_RECV_OPCODE_SEND_IMM:
+ wc->opcode = IBV_WC_RECV;
+ wc->wc_flags = IBV_WC_WITH_IMM;
+ wc->imm_data = cqe->immed_rss_invalid;
+ break;
+ }
+
+ wc->slid = be16toh(cqe->rlid);
+ g_mlpath_rqpn = be32toh(cqe->g_mlpath_rqpn);
+ wc->src_qp = g_mlpath_rqpn & 0xffffff;
+ wc->dlid_path_bits = (g_mlpath_rqpn >> 24) & 0x7f;
+ wc->wc_flags |= g_mlpath_rqpn & 0x80000000 ? IBV_WC_GRH : 0;
+ wc->pkey_index = be32toh(cqe->immed_rss_invalid) & 0x7f;
+ /* When working with xrc srqs, don't have qp to check link layer.
+ * Using IB SL, should consider Roce. (TBD)
+ */
+ if ((*cur_qp) && (*cur_qp)->link_layer == IBV_LINK_LAYER_ETHERNET)
+ wc->sl = be16toh(cqe->sl_vid) >> 13;
+ else
+ wc->sl = be16toh(cqe->sl_vid) >> 12;
+
+ if ((*cur_qp) && ((*cur_qp)->qp_cap_cache & MLX4_RX_CSUM_VALID)) {
+ wc->wc_flags |= ((cqe->status & htobe32(MLX4_CQE_STATUS_IPV4_CSUM_OK)) ==
+ htobe32(MLX4_CQE_STATUS_IPV4_CSUM_OK)) <<
+ IBV_WC_IP_CSUM_OK_SHIFT;
+ }
+ }
+
+ return CQ_OK;
+}
+
+static inline int mlx4_parse_lazy_cqe(struct mlx4_cq *cq,
+ struct mlx4_cqe *cqe)
+ ALWAYS_INLINE;
+static inline int mlx4_parse_lazy_cqe(struct mlx4_cq *cq,
+ struct mlx4_cqe *cqe)
+{
+ return mlx4_parse_cqe(cq, cqe, &cq->cur_qp, NULL, 1);
+}
+
+static inline int mlx4_poll_one(struct mlx4_cq *cq,
+ struct mlx4_qp **cur_qp,
+ struct ibv_wc *wc)
+ ALWAYS_INLINE;
+static inline int mlx4_poll_one(struct mlx4_cq *cq,
+ struct mlx4_qp **cur_qp,
+ struct ibv_wc *wc)
+{
+ struct mlx4_cqe *cqe;
+ int err;
+
+ err = mlx4_get_next_cqe(cq, &cqe);
+ if (err == CQ_EMPTY)
+ return err;
+
+ return mlx4_parse_cqe(cq, cqe, cur_qp, wc, 0);
+}
+
+int mlx4_poll_cq(struct ibv_cq *ibcq, int ne, struct ibv_wc *wc)
+{
+ struct mlx4_cq *cq = to_mcq(ibcq);
+ struct mlx4_qp *qp = NULL;
+ int npolled;
+ int err = CQ_OK;
+
+ pthread_spin_lock(&cq->lock);
+
+ for (npolled = 0; npolled < ne; ++npolled) {
+ err = mlx4_poll_one(cq, &qp, wc + npolled);
+ if (err != CQ_OK)
+ break;
+ }
+
+ if (npolled || err == CQ_POLL_ERR)
+ mlx4_update_cons_index(cq);
+
+ pthread_spin_unlock(&cq->lock);
+
+ return err == CQ_POLL_ERR ? err : npolled;
+}
+
+static inline void _mlx4_end_poll(struct ibv_cq_ex *ibcq, int lock)
+ ALWAYS_INLINE;
+static inline void _mlx4_end_poll(struct ibv_cq_ex *ibcq, int lock)
+{
+ struct mlx4_cq *cq = to_mcq(ibv_cq_ex_to_cq(ibcq));
+
+ mlx4_update_cons_index(cq);
+
+ if (lock)
+ pthread_spin_unlock(&cq->lock);
+}
+
+static inline int _mlx4_start_poll(struct ibv_cq_ex *ibcq,
+ struct ibv_poll_cq_attr *attr,
+ int lock)
+ ALWAYS_INLINE;
+static inline int _mlx4_start_poll(struct ibv_cq_ex *ibcq,
+ struct ibv_poll_cq_attr *attr,
+ int lock)
+{
+ struct mlx4_cq *cq = to_mcq(ibv_cq_ex_to_cq(ibcq));
+ struct mlx4_cqe *cqe;
+ int err;
+
+ if (unlikely(attr->comp_mask))
+ return EINVAL;
+
+ if (lock)
+ pthread_spin_lock(&cq->lock);
+
+ cq->cur_qp = NULL;
+
+ err = mlx4_get_next_cqe(cq, &cqe);
+ if (err == CQ_EMPTY) {
+ if (lock)
+ pthread_spin_unlock(&cq->lock);
+ return ENOENT;
+ }
+
+ err = mlx4_parse_lazy_cqe(cq, cqe);
+ if (lock && err)
+ pthread_spin_unlock(&cq->lock);
+
+ return err;
+}
+
+static int mlx4_next_poll(struct ibv_cq_ex *ibcq)
+{
+ struct mlx4_cq *cq = to_mcq(ibv_cq_ex_to_cq(ibcq));
+ struct mlx4_cqe *cqe;
+ int err;
+
+ err = mlx4_get_next_cqe(cq, &cqe);
+ if (err == CQ_EMPTY)
+ return ENOENT;
+
+ return mlx4_parse_lazy_cqe(cq, cqe);
+}
+
+static void mlx4_end_poll(struct ibv_cq_ex *ibcq)
+{
+ _mlx4_end_poll(ibcq, 0);
+}
+
+static void mlx4_end_poll_lock(struct ibv_cq_ex *ibcq)
+{
+ _mlx4_end_poll(ibcq, 1);
+}
+
+static int mlx4_start_poll(struct ibv_cq_ex *ibcq,
+ struct ibv_poll_cq_attr *attr)
+{
+ return _mlx4_start_poll(ibcq, attr, 0);
+}
+
+static int mlx4_start_poll_lock(struct ibv_cq_ex *ibcq,
+ struct ibv_poll_cq_attr *attr)
+{
+ return _mlx4_start_poll(ibcq, attr, 1);
+}
+
+static enum ibv_wc_opcode mlx4_cq_read_wc_opcode(struct ibv_cq_ex *ibcq)
+{
+ struct mlx4_cq *cq = to_mcq(ibv_cq_ex_to_cq(ibcq));
+
+ if (cq->cqe->owner_sr_opcode & MLX4_CQE_IS_SEND_MASK) {
+ switch (cq->cqe->owner_sr_opcode & MLX4_CQE_OPCODE_MASK) {
+ case MLX4_OPCODE_RDMA_WRITE_IMM:
+ case MLX4_OPCODE_RDMA_WRITE:
+ return IBV_WC_RDMA_WRITE;
+ case MLX4_OPCODE_SEND_INVAL:
+ case MLX4_OPCODE_SEND_IMM:
+ case MLX4_OPCODE_SEND:
+ return IBV_WC_SEND;
+ case MLX4_OPCODE_RDMA_READ:
+ return IBV_WC_RDMA_READ;
+ case MLX4_OPCODE_ATOMIC_CS:
+ return IBV_WC_COMP_SWAP;
+ case MLX4_OPCODE_ATOMIC_FA:
+ return IBV_WC_FETCH_ADD;
+ case MLX4_OPCODE_LOCAL_INVAL:
+ return IBV_WC_LOCAL_INV;
+ case MLX4_OPCODE_BIND_MW:
+ return IBV_WC_BIND_MW;
+ }
+ } else {
+ switch (cq->cqe->owner_sr_opcode & MLX4_CQE_OPCODE_MASK) {
+ case MLX4_RECV_OPCODE_RDMA_WRITE_IMM:
+ return IBV_WC_RECV_RDMA_WITH_IMM;
+ case MLX4_RECV_OPCODE_SEND_INVAL:
+ case MLX4_RECV_OPCODE_SEND_IMM:
+ case MLX4_RECV_OPCODE_SEND:
+ return IBV_WC_RECV;
+ }
+ }
+
+ return 0;
+}
+
+static uint32_t mlx4_cq_read_wc_qp_num(struct ibv_cq_ex *ibcq)
+{
+ struct mlx4_cq *cq = to_mcq(ibv_cq_ex_to_cq(ibcq));
+
+ return be32toh(cq->cqe->vlan_my_qpn) & MLX4_CQE_QPN_MASK;
+}
+
+static int mlx4_cq_read_wc_flags(struct ibv_cq_ex *ibcq)
+{
+ struct mlx4_cq *cq = to_mcq(ibv_cq_ex_to_cq(ibcq));
+ int is_send = cq->cqe->owner_sr_opcode & MLX4_CQE_IS_SEND_MASK;
+ int wc_flags = 0;
+
+ if (is_send) {
+ switch (cq->cqe->owner_sr_opcode & MLX4_CQE_OPCODE_MASK) {
+ case MLX4_OPCODE_RDMA_WRITE_IMM:
+ case MLX4_OPCODE_SEND_IMM:
+ wc_flags |= IBV_WC_WITH_IMM;
+ break;
+ }
+ } else {
+ if (cq->flags & MLX4_CQ_FLAGS_RX_CSUM_VALID)
+ wc_flags |= ((cq->cqe->status &
+ htobe32(MLX4_CQE_STATUS_IPV4_CSUM_OK)) ==
+ htobe32(MLX4_CQE_STATUS_IPV4_CSUM_OK)) <<
+ IBV_WC_IP_CSUM_OK_SHIFT;
+
+ switch (cq->cqe->owner_sr_opcode & MLX4_CQE_OPCODE_MASK) {
+ case MLX4_RECV_OPCODE_RDMA_WRITE_IMM:
+ case MLX4_RECV_OPCODE_SEND_IMM:
+ wc_flags |= IBV_WC_WITH_IMM;
+ break;
+ case MLX4_RECV_OPCODE_SEND_INVAL:
+ wc_flags |= IBV_WC_WITH_INV;
+ break;
+ }
+ wc_flags |= (be32toh(cq->cqe->g_mlpath_rqpn) & 0x80000000) ? IBV_WC_GRH : 0;
+ }
+
+ return wc_flags;
+}
+
+static uint32_t mlx4_cq_read_wc_byte_len(struct ibv_cq_ex *ibcq)
+{
+ struct mlx4_cq *cq = to_mcq(ibv_cq_ex_to_cq(ibcq));
+
+ return be32toh(cq->cqe->byte_cnt);
+}
+
+static uint32_t mlx4_cq_read_wc_vendor_err(struct ibv_cq_ex *ibcq)
+{
+ struct mlx4_cq *cq = to_mcq(ibv_cq_ex_to_cq(ibcq));
+ struct mlx4_err_cqe *ecqe = (struct mlx4_err_cqe *)cq->cqe;
+
+ return ecqe->vendor_err;
+}
+
+static uint32_t mlx4_cq_read_wc_imm_data(struct ibv_cq_ex *ibcq)
+{
+ struct mlx4_cq *cq = to_mcq(ibv_cq_ex_to_cq(ibcq));
+
+ switch (cq->cqe->owner_sr_opcode & MLX4_CQE_OPCODE_MASK) {
+ case MLX4_RECV_OPCODE_SEND_INVAL:
+ return be32toh(cq->cqe->immed_rss_invalid);
+ default:
+ return cq->cqe->immed_rss_invalid;
+ }
+}
+
+static uint32_t mlx4_cq_read_wc_slid(struct ibv_cq_ex *ibcq)
+{
+ struct mlx4_cq *cq = to_mcq(ibv_cq_ex_to_cq(ibcq));
+
+ return (uint32_t)be16toh(cq->cqe->rlid);
+}
+
+static uint8_t mlx4_cq_read_wc_sl(struct ibv_cq_ex *ibcq)
+{
+ struct mlx4_cq *cq = to_mcq(ibv_cq_ex_to_cq(ibcq));
+
+ if ((cq->cur_qp) && (cq->cur_qp->link_layer == IBV_LINK_LAYER_ETHERNET))
+ return be16toh(cq->cqe->sl_vid) >> 13;
+ else
+ return be16toh(cq->cqe->sl_vid) >> 12;
+}
+
+static uint32_t mlx4_cq_read_wc_src_qp(struct ibv_cq_ex *ibcq)
+{
+ struct mlx4_cq *cq = to_mcq(ibv_cq_ex_to_cq(ibcq));
+
+ return be32toh(cq->cqe->g_mlpath_rqpn) & 0xffffff;
+}
+
+static uint8_t mlx4_cq_read_wc_dlid_path_bits(struct ibv_cq_ex *ibcq)
+{
+ struct mlx4_cq *cq = to_mcq(ibv_cq_ex_to_cq(ibcq));
+
+ return (be32toh(cq->cqe->g_mlpath_rqpn) >> 24) & 0x7f;
+}
+
+static uint64_t mlx4_cq_read_wc_completion_ts(struct ibv_cq_ex *ibcq)
+{
+ struct mlx4_cq *cq = to_mcq(ibv_cq_ex_to_cq(ibcq));
+
+ return ((uint64_t)be32toh(cq->cqe->ts_47_16) << 16) |
+ (cq->cqe->ts_15_8 << 8) |
+ (cq->cqe->ts_7_0);
+}
+
+void mlx4_cq_fill_pfns(struct mlx4_cq *cq, const struct ibv_cq_init_attr_ex *cq_attr)
+{
+
+ if (cq->flags & MLX4_CQ_FLAGS_SINGLE_THREADED) {
+ cq->ibv_cq.start_poll = mlx4_start_poll;
+ cq->ibv_cq.end_poll = mlx4_end_poll;
+ } else {
+ cq->ibv_cq.start_poll = mlx4_start_poll_lock;
+ cq->ibv_cq.end_poll = mlx4_end_poll_lock;
+ }
+ cq->ibv_cq.next_poll = mlx4_next_poll;
+
+ cq->ibv_cq.read_opcode = mlx4_cq_read_wc_opcode;
+ cq->ibv_cq.read_vendor_err = mlx4_cq_read_wc_vendor_err;
+ cq->ibv_cq.read_wc_flags = mlx4_cq_read_wc_flags;
+ if (cq_attr->wc_flags & IBV_WC_EX_WITH_BYTE_LEN)
+ cq->ibv_cq.read_byte_len = mlx4_cq_read_wc_byte_len;
+ if (cq_attr->wc_flags & IBV_WC_EX_WITH_IMM)
+ cq->ibv_cq.read_imm_data = mlx4_cq_read_wc_imm_data;
+ if (cq_attr->wc_flags & IBV_WC_EX_WITH_QP_NUM)
+ cq->ibv_cq.read_qp_num = mlx4_cq_read_wc_qp_num;
+ if (cq_attr->wc_flags & IBV_WC_EX_WITH_SRC_QP)
+ cq->ibv_cq.read_src_qp = mlx4_cq_read_wc_src_qp;
+ if (cq_attr->wc_flags & IBV_WC_EX_WITH_SLID)
+ cq->ibv_cq.read_slid = mlx4_cq_read_wc_slid;
+ if (cq_attr->wc_flags & IBV_WC_EX_WITH_SL)
+ cq->ibv_cq.read_sl = mlx4_cq_read_wc_sl;
+ if (cq_attr->wc_flags & IBV_WC_EX_WITH_DLID_PATH_BITS)
+ cq->ibv_cq.read_dlid_path_bits = mlx4_cq_read_wc_dlid_path_bits;
+ if (cq_attr->wc_flags & IBV_WC_EX_WITH_COMPLETION_TIMESTAMP)
+ cq->ibv_cq.read_completion_ts = mlx4_cq_read_wc_completion_ts;
+}
+
+int mlx4_arm_cq(struct ibv_cq *ibvcq, int solicited)
+{
+ struct mlx4_cq *cq = to_mcq(ibvcq);
+ uint32_t doorbell[2];
+ uint32_t sn;
+ uint32_t ci;
+ uint32_t cmd;
+
+ sn = cq->arm_sn & 3;
+ ci = cq->cons_index & 0xffffff;
+ cmd = solicited ? MLX4_CQ_DB_REQ_NOT_SOL : MLX4_CQ_DB_REQ_NOT;
+
+ *cq->arm_db = htobe32(sn << 28 | cmd | ci);
+
+ /*
+ * Make sure that the doorbell record in host memory is
+ * written before ringing the doorbell via PCI MMIO.
+ */
+ udma_to_device_barrier();
+
+ doorbell[0] = htobe32(sn << 28 | cmd | cq->cqn);
+ doorbell[1] = htobe32(ci);
+
+ mlx4_write64(doorbell, to_mctx(ibvcq->context), MLX4_CQ_DOORBELL);
+
+ return 0;
+}
+
+void mlx4_cq_event(struct ibv_cq *cq)
+{
+ to_mcq(cq)->arm_sn++;
+}
+
+void __mlx4_cq_clean(struct mlx4_cq *cq, uint32_t qpn, struct mlx4_srq *srq)
+{
+ struct mlx4_cqe *cqe, *dest;
+ uint32_t prod_index;
+ uint8_t owner_bit;
+ int nfreed = 0;
+ int cqe_inc = cq->cqe_size == 64 ? 1 : 0;
+
+ /*
+ * First we need to find the current producer index, so we
+ * know where to start cleaning from. It doesn't matter if HW
+ * adds new entries after this loop -- the QP we're worried
+ * about is already in RESET, so the new entries won't come
+ * from our QP and therefore don't need to be checked.
+ */
+ for (prod_index = cq->cons_index; get_sw_cqe(cq, prod_index); ++prod_index)
+ if (prod_index == cq->cons_index + cq->ibv_cq.cqe)
+ break;
+
+ /*
+ * Now sweep backwards through the CQ, removing CQ entries
+ * that match our QP by copying older entries on top of them.
+ */
+ while ((int) --prod_index - (int) cq->cons_index >= 0) {
+ cqe = get_cqe(cq, prod_index & cq->ibv_cq.cqe);
+ cqe += cqe_inc;
+ if (srq && srq->ext_srq &&
+ (be32toh(cqe->g_mlpath_rqpn) & MLX4_CQE_QPN_MASK) == srq->verbs_srq.srq_num &&
+ !(cqe->owner_sr_opcode & MLX4_CQE_IS_SEND_MASK)) {
+ mlx4_free_srq_wqe(srq, be16toh(cqe->wqe_index));
+ ++nfreed;
+ } else if ((be32toh(cqe->vlan_my_qpn) & MLX4_CQE_QPN_MASK) == qpn) {
+ if (srq && !(cqe->owner_sr_opcode & MLX4_CQE_IS_SEND_MASK))
+ mlx4_free_srq_wqe(srq, be16toh(cqe->wqe_index));
+ ++nfreed;
+ } else if (nfreed) {
+ dest = get_cqe(cq, (prod_index + nfreed) & cq->ibv_cq.cqe);
+ dest += cqe_inc;
+ owner_bit = dest->owner_sr_opcode & MLX4_CQE_OWNER_MASK;
+ memcpy(dest, cqe, sizeof *cqe);
+ dest->owner_sr_opcode = owner_bit |
+ (dest->owner_sr_opcode & ~MLX4_CQE_OWNER_MASK);
+ }
+ }
+
+ if (nfreed) {
+ cq->cons_index += nfreed;
+ /*
+ * Make sure update of buffer contents is done before
+ * updating consumer index.
+ */
+ udma_to_device_barrier();
+ mlx4_update_cons_index(cq);
+ }
+}
+
+void mlx4_cq_clean(struct mlx4_cq *cq, uint32_t qpn, struct mlx4_srq *srq)
+{
+ pthread_spin_lock(&cq->lock);
+ __mlx4_cq_clean(cq, qpn, srq);
+ pthread_spin_unlock(&cq->lock);
+}
+
+int mlx4_get_outstanding_cqes(struct mlx4_cq *cq)
+{
+ uint32_t i;
+
+ for (i = cq->cons_index; get_sw_cqe(cq, i); ++i)
+ ;
+
+ return i - cq->cons_index;
+}
+
+void mlx4_cq_resize_copy_cqes(struct mlx4_cq *cq, void *buf, int old_cqe)
+{
+ struct mlx4_cqe *cqe;
+ int i;
+ int cqe_inc = cq->cqe_size == 64 ? 1 : 0;
+
+ i = cq->cons_index;
+ cqe = get_cqe(cq, (i & old_cqe));
+ cqe += cqe_inc;
+
+ while ((cqe->owner_sr_opcode & MLX4_CQE_OPCODE_MASK) != MLX4_CQE_OPCODE_RESIZE) {
+ cqe->owner_sr_opcode = (cqe->owner_sr_opcode & ~MLX4_CQE_OWNER_MASK) |
+ (((i + 1) & (cq->ibv_cq.cqe + 1)) ? MLX4_CQE_OWNER_MASK : 0);
+ memcpy(buf + ((i + 1) & cq->ibv_cq.cqe) * cq->cqe_size,
+ cqe - cqe_inc, cq->cqe_size);
+ ++i;
+ cqe = get_cqe(cq, (i & old_cqe));
+ cqe += cqe_inc;
+ }
+
+ ++cq->cons_index;
+}
+
+int mlx4_alloc_cq_buf(struct mlx4_device *dev, struct mlx4_buf *buf, int nent,
+ int entry_size)
+{
+ if (mlx4_alloc_buf(buf, align(nent * entry_size, dev->page_size),
+ dev->page_size))
+ return -1;
+ memset(buf->buf, 0, nent * entry_size);
+
+ return 0;
+}
diff --git a/contrib/ofed/libmlx4/dbrec.c b/contrib/ofed/libmlx4/dbrec.c
new file mode 100644
index 0000000..3e87573
--- /dev/null
+++ b/contrib/ofed/libmlx4/dbrec.c
@@ -0,0 +1,151 @@
+/*
+ * Copyright (c) 2005 Topspin Communications. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+#define _GNU_SOURCE
+#include <config.h>
+
+#include <stdlib.h>
+#include <pthread.h>
+#include <string.h>
+
+#include "mlx4.h"
+
+struct mlx4_db_page {
+ struct mlx4_db_page *prev, *next;
+ struct mlx4_buf buf;
+ int num_db;
+ int use_cnt;
+ unsigned long free[0];
+};
+
+static const int db_size[] = {
+ [MLX4_DB_TYPE_CQ] = 8,
+ [MLX4_DB_TYPE_RQ] = 4,
+};
+
+static struct mlx4_db_page *__add_page(struct mlx4_context *context,
+ enum mlx4_db_type type)
+{
+ struct mlx4_db_page *page;
+ int ps = to_mdev(context->ibv_ctx.device)->page_size;
+ int pp;
+ int i;
+
+ pp = ps / db_size[type];
+
+ page = malloc(sizeof *page + pp / 8);
+ if (!page)
+ return NULL;
+
+ if (mlx4_alloc_buf(&page->buf, ps, ps)) {
+ free(page);
+ return NULL;
+ }
+
+ page->num_db = pp;
+ page->use_cnt = 0;
+ for (i = 0; i < pp / (sizeof (long) * 8); ++i)
+ page->free[i] = ~0;
+
+ page->prev = NULL;
+ page->next = context->db_list[type];
+ context->db_list[type] = page;
+ if (page->next)
+ page->next->prev = page;
+
+ return page;
+}
+
+uint32_t *mlx4_alloc_db(struct mlx4_context *context, enum mlx4_db_type type)
+{
+ struct mlx4_db_page *page;
+ uint32_t *db = NULL;
+ int i, j;
+
+ pthread_mutex_lock(&context->db_list_mutex);
+
+ for (page = context->db_list[type]; page; page = page->next)
+ if (page->use_cnt < page->num_db)
+ goto found;
+
+ page = __add_page(context, type);
+ if (!page)
+ goto out;
+
+found:
+ ++page->use_cnt;
+
+ for (i = 0; !page->free[i]; ++i)
+ /* nothing */;
+
+ j = ffsl(page->free[i]);
+ page->free[i] &= ~(1UL << (j - 1));
+ db = page->buf.buf + (i * 8 * sizeof (long) + (j - 1)) * db_size[type];
+
+out:
+ pthread_mutex_unlock(&context->db_list_mutex);
+
+ return db;
+}
+
+void mlx4_free_db(struct mlx4_context *context, enum mlx4_db_type type, uint32_t *db)
+{
+ struct mlx4_db_page *page;
+ uintptr_t ps = to_mdev(context->ibv_ctx.device)->page_size;
+ int i;
+
+ pthread_mutex_lock(&context->db_list_mutex);
+
+ for (page = context->db_list[type]; page; page = page->next)
+ if (((uintptr_t) db & ~(ps - 1)) == (uintptr_t) page->buf.buf)
+ break;
+
+ if (!page)
+ goto out;
+
+ i = ((void *) db - page->buf.buf) / db_size[type];
+ page->free[i / (8 * sizeof (long))] |= 1UL << (i % (8 * sizeof (long)));
+
+ if (!--page->use_cnt) {
+ if (page->prev)
+ page->prev->next = page->next;
+ else
+ context->db_list[type] = page->next;
+ if (page->next)
+ page->next->prev = page->prev;
+
+ mlx4_free_buf(&page->buf);
+ free(page);
+ }
+
+out:
+ pthread_mutex_unlock(&context->db_list_mutex);
+}
diff --git a/contrib/ofed/libmlx4/debian/changelog b/contrib/ofed/libmlx4/debian/changelog
deleted file mode 100644
index 74cbef7..0000000
--- a/contrib/ofed/libmlx4/debian/changelog
+++ /dev/null
@@ -1,11 +0,0 @@
-libmlx4 (1.0-2) unstable; urgency=low
-
- * Add debian/watch file
-
- -- Roland Dreier <rolandd@cisco.com> Wed, 12 Mar 2008 10:40:19 -0700
-
-libmlx4 (1.0-1) unstable; urgency=low
-
- * Initial release. (Closes: #456355)
-
- -- Roland Dreier <rolandd@cisco.com> Fri, 14 Dec 2007 09:51:39 -0800
diff --git a/contrib/ofed/libmlx4/debian/compat b/contrib/ofed/libmlx4/debian/compat
deleted file mode 100644
index 7ed6ff8..0000000
--- a/contrib/ofed/libmlx4/debian/compat
+++ /dev/null
@@ -1 +0,0 @@
-5
diff --git a/contrib/ofed/libmlx4/debian/control.in b/contrib/ofed/libmlx4/debian/control.in
deleted file mode 100644
index 2cafc85..0000000
--- a/contrib/ofed/libmlx4/debian/control.in
+++ /dev/null
@@ -1,47 +0,0 @@
-Source: libmlx4
-Priority: extra
-Maintainer: Roland Dreier <rolandd@cisco.com>
-Build-Depends: @cdbs@, libibverbs-dev (>= 1.0)
-Standards-Version: 3.7.3
-Section: libs
-Homepage: http://www.openfabrics.org/
-
-Package: libmlx4-1
-Section: libs
-Architecture: any
-Depends: ${shlibs:Depends}, ${misc:Depends}
-Description: A userspace driver for Mellanox ConnectX InfiniBand HCAs
- libmlx4 is a device-specific driver for Mellanox ConnectX InfiniBand
- host channel adapters (HCAs) for the libibverbs library. This allows
- userspace processes to access Mellanox HCA hardware directly with
- low latency and low overhead.
- .
- This package contains the loadable plug-in.
-
-Package: libmlx4-dev
-Section: libdevel
-Architecture: any
-Depends: ${misc:Depends}, libmlx4-1 (= ${binary:Version})
-Description: Development files for the libmlx4 driver
- libmlx4 is a device-specific driver for Mellanox ConnectX InfiniBand
- host channel adapters (HCAs) for the libibverbs library. This allows
- userspace processes to access Mellanox HCA hardware directly with
- low latency and low overhead.
- .
- This package contains static versions of libmlx4 that may be linked
- directly to an application, which may be useful for debugging.
-
-Package: libmlx4-1-dbg
-Section: libdevel
-Priority: extra
-Architecture: any
-Depends: ${misc:Depends}, libmlx4-1 (= ${binary:Version})
-Description: Debugging symbols for the libmlx4 driver
- libmlx4 is a device-specific driver for Mellanox ConnectX InfiniBand
- host channel adapters (HCAs) for the libibverbs library. This allows
- userspace processes to access Mellanox HCA hardware directly with
- low latency and low overhead.
- .
- This package contains the debugging symbols associated with
- libmlx4-1. They will automatically be used by gdb for debugging
- libmlx4-related issues.
diff --git a/contrib/ofed/libmlx4/debian/copyright b/contrib/ofed/libmlx4/debian/copyright
deleted file mode 100644
index db07a25..0000000
--- a/contrib/ofed/libmlx4/debian/copyright
+++ /dev/null
@@ -1,43 +0,0 @@
-Initial Debianization:
-This package was debianized by Roland Dreier <rolandd@cisco.com> on
-Fri, 6 Apr 2007 10:04:57 -0700
-
-Source:
-It was downloaded from the OpenFabrics web site at
-<https://openfabrics.org/downloads/mlx4/>
-
-Authors:
- Roland Dreier <rolandd@cisco.com>
-
-Portions are copyrighted by:
- * Copyright (c) 2005, 2006, 2007 Cisco Systems. All rights reserved.
- * Copyright (c) 2004, 2005 Topspin Communications. All rights reserved.
- * Copyright (c) 2005 Mellanox Technologies Ltd. All rights reserved.
-
-libmlx4 is licensed under a choice of one of two licenses. You may
-choose to be licensed under the terms of the GNU General Public
-License (GPL) Version 2, available from the file
-/usr/share/common-licenses/GPL-2 on your Debian system, or the
-OpenIB.org BSD license below:
-
- Redistribution and use in source and binary forms, with or
- without modification, are permitted provided that the following
- conditions are met:
-
- - Redistributions of source code must retain the above
- copyright notice, this list of conditions and the following
- disclaimer.
-
- - Redistributions in binary form must reproduce the above
- copyright notice, this list of conditions and the following
- disclaimer in the documentation and/or other materials
- provided with the distribution.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
-BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
-ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
-CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-SOFTWARE.
diff --git a/contrib/ofed/libmlx4/debian/libmlx4-1.install b/contrib/ofed/libmlx4/debian/libmlx4-1.install
deleted file mode 100644
index a64e17d..0000000
--- a/contrib/ofed/libmlx4/debian/libmlx4-1.install
+++ /dev/null
@@ -1,2 +0,0 @@
-usr/lib/libmlx4-rdmav2.so
-etc/libibverbs.d/mlx4.driver
diff --git a/contrib/ofed/libmlx4/debian/libmlx4-dev.install b/contrib/ofed/libmlx4/debian/libmlx4-dev.install
deleted file mode 100644
index 4e1f3fe..0000000
--- a/contrib/ofed/libmlx4/debian/libmlx4-dev.install
+++ /dev/null
@@ -1 +0,0 @@
-usr/lib/libmlx4.{a,la}
diff --git a/contrib/ofed/libmlx4/debian/rules b/contrib/ofed/libmlx4/debian/rules
deleted file mode 100755
index 3e70bc3..0000000
--- a/contrib/ofed/libmlx4/debian/rules
+++ /dev/null
@@ -1,8 +0,0 @@
-#!/usr/bin/make -f
-# -*- mode: makefile; coding: utf-8 -*-
-
-DEB_DH_INSTALL_SOURCEDIR := debian/tmp
-DEB_AUTO_UPDATE_LIBTOOL := post
-
-include /usr/share/cdbs/1/rules/debhelper.mk
-include /usr/share/cdbs/1/class/autotools.mk
diff --git a/contrib/ofed/libmlx4/debian/watch b/contrib/ofed/libmlx4/debian/watch
deleted file mode 100644
index 06bae51..0000000
--- a/contrib/ofed/libmlx4/debian/watch
+++ /dev/null
@@ -1,3 +0,0 @@
-version=3
-opts="uversionmangle=s/-rc/~rc/" \
- http://www.openfabrics.org/downloads/mlx4/libmlx4-(.+)\.tar\.gz
diff --git a/contrib/ofed/libmlx4/doorbell.h b/contrib/ofed/libmlx4/doorbell.h
new file mode 100644
index 0000000..140a615
--- /dev/null
+++ b/contrib/ofed/libmlx4/doorbell.h
@@ -0,0 +1,70 @@
+/*
+ * Copyright (c) 2007 Cisco, Inc. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#ifndef DOORBELL_H
+#define DOORBELL_H
+
+#include <stdint.h>
+#include <pthread.h>
+#include "mlx4.h"
+#include "mmio.h"
+
+struct mlx4_context;
+
+#if SIZEOF_LONG == 8
+
+#if __BYTE_ORDER == __LITTLE_ENDIAN
+# define MLX4_PAIR_TO_64(val) ((uint64_t) val[1] << 32 | val[0])
+#elif __BYTE_ORDER == __BIG_ENDIAN
+# define MLX4_PAIR_TO_64(val) ((uint64_t) val[0] << 32 | val[1])
+#else
+# error __BYTE_ORDER not defined
+#endif
+
+static inline void mlx4_write64(uint32_t val[2], struct mlx4_context *ctx, int offset)
+{
+ mmio_writeq((unsigned long)(ctx->uar + offset), MLX4_PAIR_TO_64(val));
+}
+
+#else
+
+static inline void mlx4_write64(uint32_t val[2], struct mlx4_context *ctx, int offset)
+{
+ pthread_spin_lock(&ctx->uar_lock);
+ mmio_writel((unsigned long)(ctx->uar + offset), val[0]);
+ mmio_writel((unsigned long)(ctx->uar + offset + 4), val[1]);
+ pthread_spin_unlock(&ctx->uar_lock);
+}
+
+#endif
+
+#endif /* DOORBELL_H */
diff --git a/contrib/ofed/libmlx4/fixes/add_supported_devices.patch b/contrib/ofed/libmlx4/fixes/add_supported_devices.patch
deleted file mode 100644
index 85b4a66..0000000
--- a/contrib/ofed/libmlx4/fixes/add_supported_devices.patch
+++ /dev/null
@@ -1,35 +0,0 @@
-Index: libmlx4/src/mlx4.c
-===================================================================
---- libmlx4.orig/src/mlx4.c 2010-02-08 15:43:35.000000000 +0200
-+++ libmlx4/src/mlx4.c 2010-02-08 15:43:53.000000000 +0200
-@@ -66,6 +66,30 @@ struct {
- HCA(MELLANOX, 0x6354), /* MT25408 "Hermon" QDR */
- HCA(MELLANOX, 0x6732), /* MT25408 "Hermon" DDR PCIe gen2 */
- HCA(MELLANOX, 0x673c), /* MT25408 "Hermon" QDR PCIe gen2 */
-+ HCA(MELLANOX, 0x6368), /* MT25448 [ConnectX EN 10GigE, PCIe 2.0 2.5GT/s] */
-+ HCA(MELLANOX, 0x6750), /* MT26448 [ConnectX EN 10GigE, PCIe 2.0 5GT/s] */
-+ HCA(MELLANOX, 0x6372), /* MT25408 [ConnectX EN 10GigE 10GBaseT, PCIe 2.0 2.5GT/s] */
-+ HCA(MELLANOX, 0x675a), /* MT25408 [ConnectX EN 10GigE 10GBaseT, PCIe Gen2 5GT/s] */
-+ HCA(MELLANOX, 0x6764), /* MT26468 [ConnectX EN 10GigE, PCIe 2.0 5GT/s] */
-+ HCA(MELLANOX, 0x6746), /* MT26438 ConnectX VPI PCIe 2.0 5GT/s - IB QDR / 10GigE Virt+ */
-+ HCA(MELLANOX, 0x676e), /* MT26478 ConnectX EN 40GigE PCIe 2.0 5GT/s */
-+ HCA(MELLANOX, 0x6778), /* MT26488 ConnectX VPI PCIe 2.0 5GT/s - IB DDR / 10GigE Virt+ */
-+ HCA(MELLANOX, 0x1000),
-+ HCA(MELLANOX, 0x1001),
-+ HCA(MELLANOX, 0x1002),
-+ HCA(MELLANOX, 0x1003),
-+ HCA(MELLANOX, 0x1004),
-+ HCA(MELLANOX, 0x1005),
-+ HCA(MELLANOX, 0x1006),
-+ HCA(MELLANOX, 0x1007),
-+ HCA(MELLANOX, 0x1008),
-+ HCA(MELLANOX, 0x1009),
-+ HCA(MELLANOX, 0x100a),
-+ HCA(MELLANOX, 0x100b),
-+ HCA(MELLANOX, 0x100c),
-+ HCA(MELLANOX, 0x100d),
-+ HCA(MELLANOX, 0x100e),
-+ HCA(MELLANOX, 0x100f),
- };
-
- #ifdef HAVE_IBV_MORE_OPS
diff --git a/contrib/ofed/libmlx4/fixes/fix_inline_size.patch b/contrib/ofed/libmlx4/fixes/fix_inline_size.patch
deleted file mode 100644
index e01abb2..0000000
--- a/contrib/ofed/libmlx4/fixes/fix_inline_size.patch
+++ /dev/null
@@ -1,126 +0,0 @@
-From 6f9c7b5c83a832884b3e47a6ce52145991073586 Mon Sep 17 00:00:00 2001
-From: Eli Cohen <eli@mellanox.co.il>
-Date: Sun, 19 Sep 2010 11:28:40 +0200
-Subject: [PATCH] libmlx4: fix possible inline size
-
-The current driver checks required inline size by making sure it does not
-exceed 1024. This is wrong since the whole WQE is limited to 1008 bytes.
-Moreover, a more careful claculation is required to avoid cases where the
-application requests inline support in a certain size that when used later
-could cause connections to stall due to bad WQEs. This patch takes into account
-the size of the WQE, the segements used to create a WQE and the overhead
-incured by the inline segments themselves.
-
-Signed-off-by: Eli Cohen <eli@mellanox.co.il>
----
- src/verbs.c | 45 ++++++++++++++++++++++++++++++++++++++++-----
- 1 files changed, 40 insertions(+), 5 deletions(-)
-
-Index: libmlx4/src/verbs.c
-===================================================================
---- libmlx4.orig/src/verbs.c 2010-09-29 11:10:17.691587848 +0200
-+++ libmlx4/src/verbs.c 2010-09-29 11:16:11.031586721 +0200
-@@ -402,6 +402,44 @@ int mlx4_destroy_srq(struct ibv_srq *ibs
- return 0;
- }
-
-+static int verify_sizes(struct ibv_qp_init_attr *attr, struct mlx4_context *context)
-+{
-+ int size;
-+ int nsegs;
-+
-+ if (attr->cap.max_send_wr > context->max_qp_wr ||
-+ attr->cap.max_recv_wr > context->max_qp_wr ||
-+ attr->cap.max_send_sge > context->max_sge ||
-+ attr->cap.max_recv_sge > context->max_sge)
-+ return -1;
-+
-+ if (attr->cap.max_inline_data) {
-+ nsegs = num_inline_segs(attr->cap.max_inline_data, attr->qp_type);
-+ size = MLX4_MAX_WQE_SIZE - nsegs * sizeof (struct mlx4_wqe_inline_seg);
-+ switch (attr->qp_type) {
-+ case IBV_QPT_UD:
-+ size -= (sizeof (struct mlx4_wqe_ctrl_seg) +
-+ sizeof (struct mlx4_wqe_datagram_seg));
-+ break;
-+
-+ case IBV_QPT_RC:
-+ case IBV_QPT_UC:
-+ case IBV_QPT_XRC:
-+ size -= (sizeof (struct mlx4_wqe_ctrl_seg) +
-+ sizeof (struct mlx4_wqe_raddr_seg));
-+ break;
-+
-+ default:
-+ return 0;
-+ }
-+
-+ if (attr->cap.max_inline_data > size)
-+ return -1;
-+ }
-+
-+ return 0;
-+}
-+
- struct ibv_qp *mlx4_create_qp(struct ibv_pd *pd, struct ibv_qp_init_attr *attr)
- {
- struct mlx4_create_qp cmd;
-@@ -412,11 +450,7 @@ struct ibv_qp *mlx4_create_qp(struct ibv
-
-
- /* Sanity check QP size before proceeding */
-- if (attr->cap.max_send_wr > context->max_qp_wr ||
-- attr->cap.max_recv_wr > context->max_qp_wr ||
-- attr->cap.max_send_sge > context->max_sge ||
-- attr->cap.max_recv_sge > context->max_sge ||
-- attr->cap.max_inline_data > 1024)
-+ if (verify_sizes(attr, context))
- return NULL;
-
- qp = malloc(sizeof *qp);
-Index: libmlx4/src/mlx4.h
-===================================================================
---- libmlx4.orig/src/mlx4.h 2010-09-29 11:10:17.691587848 +0200
-+++ libmlx4/src/mlx4.h 2010-09-29 11:11:35.559586971 +0200
-@@ -159,6 +159,10 @@ enum {
- MLX4_CQE_OPCODE_RESIZE = 0x16,
- };
-
-+enum {
-+ MLX4_MAX_WQE_SIZE = 1008
-+};
-+
- struct mlx4_device {
- struct ibv_device ibv_dev;
- int page_size;
-@@ -410,6 +414,7 @@ int mlx4_post_recv(struct ibv_qp *ibqp,
- struct ibv_recv_wr **bad_wr);
- void mlx4_calc_sq_wqe_size(struct ibv_qp_cap *cap, enum ibv_qp_type type,
- struct mlx4_qp *qp);
-+int num_inline_segs(int data, enum ibv_qp_type type);
- int mlx4_alloc_qp_buf(struct ibv_pd *pd, struct ibv_qp_cap *cap,
- enum ibv_qp_type type, struct mlx4_qp *qp);
- void mlx4_set_sq_sizes(struct mlx4_qp *qp, struct ibv_qp_cap *cap,
-Index: libmlx4/src/qp.c
-===================================================================
---- libmlx4.orig/src/qp.c 2010-09-29 11:10:17.691587848 +0200
-+++ libmlx4/src/qp.c 2010-09-29 11:12:14.931587492 +0200
-@@ -505,7 +505,7 @@ out:
- return ret;
- }
-
--static int num_inline_segs(int data, enum ibv_qp_type type)
-+int num_inline_segs(int data, enum ibv_qp_type type)
- {
- /*
- * Inline data segments are not allowed to cross 64 byte
-@@ -634,7 +634,8 @@ void mlx4_set_sq_sizes(struct mlx4_qp *q
- int wqe_size;
- struct mlx4_context *ctx = to_mctx(qp->ibv_qp.context);
-
-- wqe_size = (1 << qp->sq.wqe_shift) - sizeof (struct mlx4_wqe_ctrl_seg);
-+ wqe_size = min((1 << qp->sq.wqe_shift), MLX4_MAX_WQE_SIZE) -
-+ sizeof (struct mlx4_wqe_ctrl_seg);
- switch (type) {
- case IBV_QPT_UD:
- wqe_size -= sizeof (struct mlx4_wqe_datagram_seg);
diff --git a/contrib/ofed/libmlx4/fixes/lim_qp_resources.patch b/contrib/ofed/libmlx4/fixes/lim_qp_resources.patch
deleted file mode 100644
index b9ce37e..0000000
--- a/contrib/ofed/libmlx4/fixes/lim_qp_resources.patch
+++ /dev/null
@@ -1,72 +0,0 @@
-Limit qp resources accepted for ibv_create_qp()
-
-to the limits reported in ib_query_device().
-Make sure that the limits returned to the caller following
-qp creation also lie within the reported device limits.
-(OFED 1.3 libmlx4 commit b612592e2c43472895ccc495183aa63980d8e7a5)
-
-Signed-off-by: Jack Morgenstein <jackm@dev.mellanox.co.il>
-
-Index: libmlx4/src/qp.c
-===================================================================
---- libmlx4.orig/src/qp.c 2008-06-04 08:24:45.000000000 +0300
-+++ libmlx4/src/qp.c 2008-06-04 08:24:49.000000000 +0300
-@@ -619,6 +619,7 @@ void mlx4_set_sq_sizes(struct mlx4_qp *q
- enum ibv_qp_type type)
- {
- int wqe_size;
-+ struct mlx4_context *ctx = to_mctx(qp->ibv_qp.context);
-
- wqe_size = (1 << qp->sq.wqe_shift) - sizeof (struct mlx4_wqe_ctrl_seg);
- switch (type) {
-@@ -636,8 +637,9 @@ void mlx4_set_sq_sizes(struct mlx4_qp *q
- }
-
- qp->sq.max_gs = wqe_size / sizeof (struct mlx4_wqe_data_seg);
-- cap->max_send_sge = qp->sq.max_gs;
-- qp->sq.max_post = qp->sq.wqe_cnt - qp->sq_spare_wqes;
-+ cap->max_send_sge = min(ctx->max_sge, qp->sq.max_gs);
-+ qp->sq.max_post = min(ctx->max_qp_wr,
-+ qp->sq.wqe_cnt - qp->sq_spare_wqes);
- cap->max_send_wr = qp->sq.max_post;
-
- /*
-Index: libmlx4/src/verbs.c
-===================================================================
---- libmlx4.orig/src/verbs.c 2008-06-04 08:24:45.000000000 +0300
-+++ libmlx4/src/verbs.c 2008-06-04 08:24:49.000000000 +0300
-@@ -390,12 +390,14 @@ struct ibv_qp *mlx4_create_qp(struct ibv
- struct ibv_create_qp_resp resp;
- struct mlx4_qp *qp;
- int ret;
-+ struct mlx4_context *context = to_mctx(pd->context);
-+
-
- /* Sanity check QP size before proceeding */
-- if (attr->cap.max_send_wr > 65536 ||
-- attr->cap.max_recv_wr > 65536 ||
-- attr->cap.max_send_sge > 64 ||
-- attr->cap.max_recv_sge > 64 ||
-+ if (attr->cap.max_send_wr > context->max_qp_wr ||
-+ attr->cap.max_recv_wr > context->max_qp_wr ||
-+ attr->cap.max_send_sge > context->max_sge ||
-+ attr->cap.max_recv_sge > context->max_sge ||
- attr->cap.max_inline_data > 1024)
- return NULL;
-
-@@ -461,8 +463,14 @@ struct ibv_qp *mlx4_create_qp(struct ibv
- goto err_destroy;
- pthread_mutex_unlock(&to_mctx(pd->context)->qp_table_mutex);
-
-- qp->rq.wqe_cnt = qp->rq.max_post = attr->cap.max_recv_wr;
-+ qp->rq.wqe_cnt = attr->cap.max_recv_wr;
- qp->rq.max_gs = attr->cap.max_recv_sge;
-+
-+ /* adjust rq maxima to not exceed reported device maxima */
-+ attr->cap.max_recv_wr = min(context->max_qp_wr, attr->cap.max_recv_wr);
-+ attr->cap.max_recv_sge = min(context->max_sge, attr->cap.max_recv_sge);
-+
-+ qp->rq.max_post = attr->cap.max_recv_wr;
- mlx4_set_sq_sizes(qp, &attr->cap, attr->qp_type);
-
- qp->doorbell_qpn = htonl(qp->ibv_qp.qp_num << 8);
diff --git a/contrib/ofed/libmlx4/fixes/post_rcv_end_of_sg.patch b/contrib/ofed/libmlx4/fixes/post_rcv_end_of_sg.patch
deleted file mode 100644
index aa11d9d..0000000
--- a/contrib/ofed/libmlx4/fixes/post_rcv_end_of_sg.patch
+++ /dev/null
@@ -1,29 +0,0 @@
-As in libmthca, need to initialize SRQ WQE scatter entries to the
-invalid lkey at work queue creation time.
-
-Signed-off-by: Jack Morgenstein <jackm@dev.mellanox.co.il>
-
-Index: libmlx4/src/srq.c
-===================================================================
---- libmlx4.orig/src/srq.c 2009-12-09 15:08:52.000000000 +0200
-+++ libmlx4/src/srq.c 2009-12-09 18:44:32.000000000 +0200
-@@ -128,6 +128,7 @@ int mlx4_alloc_srq_buf(struct ibv_pd *pd
- struct mlx4_srq *srq)
- {
- struct mlx4_wqe_srq_next_seg *next;
-+ struct mlx4_wqe_data_seg *scatter;
- int size;
- int buf_size;
- int i;
-@@ -160,6 +161,11 @@ int mlx4_alloc_srq_buf(struct ibv_pd *pd
- for (i = 0; i < srq->max; ++i) {
- next = get_wqe(srq, i);
- next->next_wqe_index = htons((i + 1) & (srq->max - 1));
-+
-+ for (scatter = (void *) (next + 1);
-+ (void *) scatter < (void *) next + (1 << srq->wqe_shift);
-+ ++scatter)
-+ scatter->lkey = htonl(MLX4_INVALID_LKEY);
- }
-
- srq->head = 0;
diff --git a/contrib/ofed/libmlx4/fixes/rocee_add_support.patch b/contrib/ofed/libmlx4/fixes/rocee_add_support.patch
deleted file mode 100644
index 017b075..0000000
--- a/contrib/ofed/libmlx4/fixes/rocee_add_support.patch
+++ /dev/null
@@ -1,145 +0,0 @@
-[PATCHv7 1/2] libmlx4: Add RoCEE support
-
-Modify libmlx4 to support RoCEE. The change involves retrieving the MAC address
-of a port based on its GID through a new system call, ibv_cmd_get_mac(), and
-embedding the MAC in the address vector representation of mlx4.
-
-Signed-off-by: Eli Cohen <eli@mellanox.co.il>
----
- src/mlx4.h | 3 +++
- src/qp.c | 2 ++
- src/verbs.c | 29 +++++++++++++++++++++++++++++
- src/wqe.h | 3 ++-
- 4 files changed, 36 insertions(+), 1 deletions(-)
-
-Index: libmlx4/src/mlx4.h
-===================================================================
---- libmlx4.orig/src/mlx4.h 2010-08-23 08:07:47.599964446 +0300
-+++ libmlx4/src/mlx4.h 2010-08-23 08:08:32.039462057 +0300
-@@ -277,11 +277,15 @@ struct mlx4_av {
- uint8_t hop_limit;
- uint32_t sl_tclass_flowlabel;
- uint8_t dgid[16];
-+ uint8_t mac[8];
- };
-
- struct mlx4_ah {
- struct ibv_ah ibv_ah;
- struct mlx4_av av;
-+ uint16_t vlan;
-+ uint8_t mac[6];
-+ uint8_t tagged;
- };
-
- struct mlx4_xrc_domain {
-Index: libmlx4/src/qp.c
-===================================================================
---- libmlx4.orig/src/qp.c 2010-08-23 08:07:46.283963844 +0300
-+++ libmlx4/src/qp.c 2010-08-23 08:08:32.039462057 +0300
-@@ -143,6 +143,8 @@ static void set_datagram_seg(struct mlx4
- memcpy(dseg->av, &to_mah(wr->wr.ud.ah)->av, sizeof (struct mlx4_av));
- dseg->dqpn = htonl(wr->wr.ud.remote_qpn);
- dseg->qkey = htonl(wr->wr.ud.remote_qkey);
-+ dseg->vlan = htons(to_mah(wr->wr.ud.ah)->vlan);
-+ memcpy(dseg->mac, to_mah(wr->wr.ud.ah)->mac, 6);
- }
-
- static void __set_data_seg(struct mlx4_wqe_data_seg *dseg, struct ibv_sge *sg)
-@@ -284,6 +286,11 @@ int mlx4_post_send(struct ibv_qp *ibqp,
- set_datagram_seg(wqe, wr);
- wqe += sizeof (struct mlx4_wqe_datagram_seg);
- size += sizeof (struct mlx4_wqe_datagram_seg) / 16;
-+ if (to_mah(wr->wr.ud.ah)->tagged) {
-+ ctrl->ins_vlan = 1 << 6;
-+ ctrl->vlan_tag = htons(to_mah(wr->wr.ud.ah)->vlan);
-+ }
-+
- break;
-
- default:
-@@ -396,7 +403,7 @@ out:
-
- if (nreq == 1 && inl && size > 1 && size < ctx->bf_buf_size / 16) {
- ctrl->owner_opcode |= htonl((qp->sq.head & 0xffff) << 8);
-- *(uint32_t *) ctrl->reserved |= qp->doorbell_qpn;
-+ *(uint32_t *) (&ctrl->vlan_tag) |= qp->doorbell_qpn;
- /*
- * Make sure that descriptor is written to memory
- * before writing to BlueFlame page.
-Index: libmlx4/src/verbs.c
-===================================================================
---- libmlx4.orig/src/verbs.c 2010-08-23 08:07:48.451964305 +0300
-+++ libmlx4/src/verbs.c 2010-08-23 08:08:32.039462057 +0300
-@@ -643,12 +643,14 @@ int mlx4_destroy_qp(struct ibv_qp *ibqp)
- struct ibv_ah *mlx4_create_ah(struct ibv_pd *pd, struct ibv_ah_attr *attr)
- {
- struct mlx4_ah *ah;
-+ struct ibv_port_attr port_attr;
-+ uint8_t is_mcast;
-
- ah = malloc(sizeof *ah);
- if (!ah)
- return NULL;
-
-- memset(&ah->av, 0, sizeof ah->av);
-+ memset(ah, 0, sizeof *ah);
-
- ah->av.port_pd = htonl(to_mpd(pd)->pdn | (attr->port_num << 24));
- ah->av.g_slid = attr->src_path_bits;
-@@ -668,7 +670,32 @@ struct ibv_ah *mlx4_create_ah(struct ibv
- memcpy(ah->av.dgid, attr->grh.dgid.raw, 16);
- }
-
-+ if (ibv_query_port(pd->context, attr->port_num, &port_attr))
-+ goto err;
-+
-+ if (port_attr.link_layer == IBV_LINK_LAYER_ETHERNET) {
-+ if (ibv_resolve_eth_gid(pd, attr->port_num,
-+ (union ibv_gid *)ah->av.dgid,
-+ attr->grh.sgid_index,
-+ ah->mac, &ah->vlan,
-+ &ah->tagged, &is_mcast))
-+ goto err;
-+
-+ if (is_mcast) {
-+ ah->av.dlid = htons(0xc000);
-+ ah->av.port_pd |= htonl(1 << 31);
-+ }
-+ if (ah->tagged) {
-+ ah->av.port_pd |= htonl(1 << 29);
-+ ah->vlan |= (attr->sl & 7) << 13;
-+ }
-+ }
-+
-+
- return &ah->ibv_ah;
-+err:
-+ free(ah);
-+ return NULL;
- }
-
- int mlx4_destroy_ah(struct ibv_ah *ah)
-Index: libmlx4/src/wqe.h
-===================================================================
---- libmlx4.orig/src/wqe.h 2010-08-23 08:07:46.287962570 +0300
-+++ libmlx4/src/wqe.h 2010-08-23 08:07:50.231963413 +0300
-@@ -54,7 +54,8 @@ enum {
-
- struct mlx4_wqe_ctrl_seg {
- uint32_t owner_opcode;
-- uint8_t reserved[3];
-+ uint16_t vlan_tag;
-+ uint8_t ins_vlan;
- uint8_t fence_size;
- /*
- * High 24 bits are SRC remote buffer; low 8 bits are flags:
-@@ -78,7 +79,8 @@ struct mlx4_wqe_datagram_seg {
- uint32_t av[8];
- uint32_t dqpn;
- uint32_t qkey;
-- uint32_t reserved[2];
-+ uint16_t vlan;
-+ uint8_t mac[6];
- };
-
- struct mlx4_wqe_data_seg {
diff --git a/contrib/ofed/libmlx4/fixes/series b/contrib/ofed/libmlx4/fixes/series
deleted file mode 100644
index 83516ec..0000000
--- a/contrib/ofed/libmlx4/fixes/series
+++ /dev/null
@@ -1,10 +0,0 @@
-userspace_dev_lims.patch
-lim_qp_resources.patch
-xrc_consolidated_v2.patch
-xrc_rcv_qp_v2.patch
-xrc_fix_close_domain.patch
-xrc_kernel_user_mismatch.patch
-rocee_add_support.patch
-add_supported_devices.patch
-post_rcv_end_of_sg.patch
-fix_inline_size.patch
diff --git a/contrib/ofed/libmlx4/fixes/userspace_dev_lims.patch b/contrib/ofed/libmlx4/fixes/userspace_dev_lims.patch
deleted file mode 100644
index 07cf638..0000000
--- a/contrib/ofed/libmlx4/fixes/userspace_dev_lims.patch
+++ /dev/null
@@ -1,79 +0,0 @@
-When creating a new user context, query device for
-
-various limits, for use in sanity checks and
-other resource limitation needs.
-
-Passing needed info back to userspace in this manner is
-preferable to breaking the ABI.
-(OFED 1.3 commit 43ca5e9225658b22ef8180bf0eff4faa7f5940cf)
-
-Signed-off-by: Jack Morgenstein <jackm@dev.mellanox.co.il>
-
-Index: libmlx4/src/mlx4.c
-===================================================================
---- libmlx4.orig/src/mlx4.c 2008-06-03 15:45:18.000000000 +0300
-+++ libmlx4/src/mlx4.c 2008-06-04 08:24:10.000000000 +0300
-@@ -104,6 +104,7 @@ static struct ibv_context *mlx4_alloc_co
- struct ibv_get_context cmd;
- struct mlx4_alloc_ucontext_resp resp;
- int i;
-+ struct ibv_device_attr dev_attrs;
-
- context = calloc(1, sizeof *context);
- if (!context)
-@@ -156,8 +157,20 @@ static struct ibv_context *mlx4_alloc_co
-
- context->ibv_ctx.ops = mlx4_ctx_ops;
-
-+ if (mlx4_query_device(&context->ibv_ctx, &dev_attrs))
-+ goto query_free;
-+
-+ context->max_qp_wr = dev_attrs.max_qp_wr;
-+ context->max_sge = dev_attrs.max_sge;
-+ context->max_cqe = dev_attrs.max_cqe;
-+
- return &context->ibv_ctx;
-
-+query_free:
-+ munmap(context->uar, to_mdev(ibdev)->page_size);
-+ if (context->bf_page)
-+ munmap(context->bf_page, to_mdev(ibdev)->page_size);
-+
- err_free:
- free(context);
- return NULL;
-Index: libmlx4/src/mlx4.h
-===================================================================
---- libmlx4.orig/src/mlx4.h 2008-06-03 15:45:18.000000000 +0300
-+++ libmlx4/src/mlx4.h 2008-06-04 08:24:10.000000000 +0300
-@@ -83,6 +83,20 @@
-
- #define PFX "mlx4: "
-
-+#ifndef max
-+#define max(a,b) \
-+ ({ typeof (a) _a = (a); \
-+ typeof (b) _b = (b); \
-+ _a > _b ? _a : _b; })
-+#endif
-+
-+#ifndef min
-+#define min(a,b) \
-+ ({ typeof (a) _a = (a); \
-+ typeof (b) _b = (b); \
-+ _a < _b ? _a : _b; })
-+#endif
-+
- enum {
- MLX4_CQ_ENTRY_SIZE = 0x20
- };
-@@ -156,6 +170,9 @@ struct mlx4_context {
- int num_qps;
- int qp_table_shift;
- int qp_table_mask;
-+ int max_qp_wr;
-+ int max_sge;
-+ int max_cqe;
-
- struct mlx4_db_page *db_list[MLX4_NUM_DB_TYPE];
- pthread_mutex_t db_list_mutex;
diff --git a/contrib/ofed/libmlx4/fixes/xrc_consolidated_v2.patch b/contrib/ofed/libmlx4/fixes/xrc_consolidated_v2.patch
deleted file mode 100644
index 9fe6c43..0000000
--- a/contrib/ofed/libmlx4/fixes/xrc_consolidated_v2.patch
+++ /dev/null
@@ -1,620 +0,0 @@
-XRC implementation, consolidated (version 2):
-
-xrc ops were moved to their own structure at the end of
-struct ibv_context (to preserve binary compatibility).
-
-Check for ibv_context.xrc_ops member via AC_CHECK_MEMBER
-
-XRC QPs have MSB set in qp number, for identification in
-completion handling.
-
-Various bug fixes.
-(OFED 1.3 commit 39fe7f47e8fc07f356098df048d00740ba585fc5)
-
-Signed-off-by: Jack Morgenstein <jackm@dev.mellanox.co.il>
----
-V2:
-1. checkpatch.pl cleanup
-2. Changed xrc_ops to more ops
-3. Check for xrc verbs in ibv_more_ops via AC_CHECK_MEMBER
-
-diff --git a/configure.in b/configure.in
-index 25f27f7..46a3a64 100644
---- a/configure.in
-+++ b/configure.in
-@@ -42,6 +42,12 @@ AC_CHECK_HEADER(valgrind/memcheck.h,
- dnl Checks for typedefs, structures, and compiler characteristics.
- AC_C_CONST
- AC_CHECK_SIZEOF(long)
-+AC_CHECK_MEMBER(struct ibv_context.more_ops,
-+ [AC_DEFINE([HAVE_IBV_MORE_OPS], 1, [Define to 1 if more_ops is a member of ibv_context])],,
-+ [#include <infiniband/verbs.h>])
-+AC_CHECK_MEMBER(struct ibv_more_ops.create_xrc_srq,
-+ [AC_DEFINE([HAVE_IBV_XRC_OPS], 1, [Define to 1 if have xrc ops])],,
-+ [#include <infiniband/verbs.h>])
-
- dnl Checks for library functions
- AC_CHECK_FUNC(ibv_read_sysfs_file, [],
-diff --git a/src/cq.c b/src/cq.c
-index 68e16e9..c598b87 100644
---- a/src/cq.c
-+++ b/src/cq.c
-@@ -194,8 +194,9 @@ static int mlx4_poll_one(struct mlx4_cq *cq,
- {
- struct mlx4_wq *wq;
- struct mlx4_cqe *cqe;
-- struct mlx4_srq *srq;
-+ struct mlx4_srq *srq = NULL;
- uint32_t qpn;
-+ uint32_t srqn;
- uint32_t g_mlpath_rqpn;
- uint16_t wqe_index;
- int is_error;
-@@ -221,20 +223,29 @@ static int mlx4_poll_one(struct mlx4_cq *cq,
- is_error = (cqe->owner_sr_opcode & MLX4_CQE_OPCODE_MASK) ==
- MLX4_CQE_OPCODE_ERROR;
-
-- if (!*cur_qp ||
-- (ntohl(cqe->my_qpn) & 0xffffff) != (*cur_qp)->ibv_qp.qp_num) {
-+ if (qpn & MLX4_XRC_QPN_BIT && !is_send) {
-+ srqn = ntohl(cqe->g_mlpath_rqpn) & 0xffffff;
-+ /*
-+ * We do not have to take the XRC SRQ table lock here,
-+ * because CQs will be locked while XRC SRQs are removed
-+ * from the table.
-+ */
-+ srq = mlx4_find_xrc_srq(to_mctx(cq->ibv_cq.context), srqn);
-+ if (!srq)
-+ return CQ_POLL_ERR;
-+ } else if (!*cur_qp || (qpn & 0xffffff) != (*cur_qp)->ibv_qp.qp_num) {
- /*
- * We do not have to take the QP table lock here,
- * because CQs will be locked while QPs are removed
- * from the table.
- */
- *cur_qp = mlx4_find_qp(to_mctx(cq->ibv_cq.context),
-- ntohl(cqe->my_qpn) & 0xffffff);
-+ qpn & 0xffffff);
- if (!*cur_qp)
- return CQ_POLL_ERR;
- }
-
-- wc->qp_num = (*cur_qp)->ibv_qp.qp_num;
-+ wc->qp_num = qpn & 0xffffff;
-
- if (is_send) {
- wq = &(*cur_qp)->sq;
-@@ -242,6 +254,10 @@ static int mlx4_poll_one(struct mlx4_cq *cq,
- wq->tail += (uint16_t) (wqe_index - (uint16_t) wq->tail);
- wc->wr_id = wq->wrid[wq->tail & (wq->wqe_cnt - 1)];
- ++wq->tail;
-+ } else if (srq) {
-+ wqe_index = htons(cqe->wqe_index);
-+ wc->wr_id = srq->wrid[wqe_index];
-+ mlx4_free_srq_wqe(srq, wqe_index);
- } else if ((*cur_qp)->ibv_qp.srq) {
- srq = to_msrq((*cur_qp)->ibv_qp.srq);
- wqe_index = htons(cqe->wqe_index);
-@@ -387,6 +403,10 @@ void __mlx4_cq_clean(struct mlx4_cq *cq, uint32_t qpn, struct mlx4_srq *srq)
- uint32_t prod_index;
- uint8_t owner_bit;
- int nfreed = 0;
-+ int is_xrc_srq = 0;
-+
-+ if (srq && srq->ibv_srq.xrc_cq)
-+ is_xrc_srq = 1;
-
- /*
- * First we need to find the current producer index, so we
-@@ -405,7 +425,12 @@ void __mlx4_cq_clean(struct mlx4_cq *cq, uint32_t qpn, struct mlx4_srq *srq)
- */
- while ((int) --prod_index - (int) cq->cons_index >= 0) {
- cqe = get_cqe(cq, prod_index & cq->ibv_cq.cqe);
-- if ((ntohl(cqe->my_qpn) & 0xffffff) == qpn) {
-+ if (is_xrc_srq &&
-+ (ntohl(cqe->g_mlpath_rqpn & 0xffffff) == srq->srqn) &&
-+ !(cqe->owner_sr_opcode & MLX4_CQE_IS_SEND_MASK)) {
-+ mlx4_free_srq_wqe(srq, ntohs(cqe->wqe_index));
-+ ++nfreed;
-+ } else if ((ntohl(cqe->my_qpn) & 0xffffff) == qpn) {
- if (srq && !(cqe->owner_sr_opcode & MLX4_CQE_IS_SEND_MASK))
- mlx4_free_srq_wqe(srq, ntohs(cqe->wqe_index));
- ++nfreed;
-diff --git a/src/mlx4-abi.h b/src/mlx4-abi.h
-index 20a40c9..1b1253c 100644
---- a/src/mlx4-abi.h
-+++ b/src/mlx4-abi.h
-@@ -68,6 +68,14 @@ struct mlx4_resize_cq {
- __u64 buf_addr;
- };
-
-+#ifdef HAVE_IBV_XRC_OPS
-+struct mlx4_create_xrc_srq {
-+ struct ibv_create_xrc_srq ibv_cmd;
-+ __u64 buf_addr;
-+ __u64 db_addr;
-+};
-+#endif
-+
- struct mlx4_create_srq {
- struct ibv_create_srq ibv_cmd;
- __u64 buf_addr;
-@@ -90,4 +98,12 @@ struct mlx4_create_qp {
- __u8 reserved[5];
- };
-
-+#ifdef HAVE_IBV_XRC_OPS
-+struct mlx4_open_xrc_domain_resp {
-+ struct ibv_open_xrc_domain_resp ibv_resp;
-+ __u32 xrcdn;
-+ __u32 reserved;
-+};
-+#endif
-+
- #endif /* MLX4_ABI_H */
-diff --git a/src/mlx4.c b/src/mlx4.c
-index 671e849..27ca75d 100644
---- a/src/mlx4.c
-+++ b/src/mlx4.c
-@@ -68,6 +68,16 @@ struct {
- HCA(MELLANOX, 0x673c), /* MT25408 "Hermon" QDR PCIe gen2 */
- };
-
-+#ifdef HAVE_IBV_MORE_OPS
-+static struct ibv_more_ops mlx4_more_ops = {
-+#ifdef HAVE_IBV_XRC_OPS
-+ .create_xrc_srq = mlx4_create_xrc_srq,
-+ .open_xrc_domain = mlx4_open_xrc_domain,
-+ .close_xrc_domain = mlx4_close_xrc_domain,
-+#endif
-+};
-+#endif
-+
- static struct ibv_context_ops mlx4_ctx_ops = {
- .query_device = mlx4_query_device,
- .query_port = mlx4_query_port,
-@@ -124,6 +134,15 @@ static struct ibv_context *mlx4_alloc_context(struct ibv_device *ibdev, int cmd_
- for (i = 0; i < MLX4_QP_TABLE_SIZE; ++i)
- context->qp_table[i].refcnt = 0;
-
-+ context->num_xrc_srqs = resp.qp_tab_size;
-+ context->xrc_srq_table_shift = ffs(context->num_xrc_srqs) - 1
-+ - MLX4_XRC_SRQ_TABLE_BITS;
-+ context->xrc_srq_table_mask = (1 << context->xrc_srq_table_shift) - 1;
-+
-+ pthread_mutex_init(&context->xrc_srq_table_mutex, NULL);
-+ for (i = 0; i < MLX4_XRC_SRQ_TABLE_SIZE; ++i)
-+ context->xrc_srq_table[i].refcnt = 0;
-+
- for (i = 0; i < MLX4_NUM_DB_TYPE; ++i)
- context->db_list[i] = NULL;
-
-@@ -156,6 +175,9 @@ static struct ibv_context *mlx4_alloc_context(struct ibv_device *ibdev, int cmd_
- pthread_spin_init(&context->uar_lock, PTHREAD_PROCESS_PRIVATE);
-
- context->ibv_ctx.ops = mlx4_ctx_ops;
-+#ifdef HAVE_IBV_XRC_OPS
-+ context->ibv_ctx.more_ops = &mlx4_more_ops;
-+#endif
-
- if (mlx4_query_device(&context->ibv_ctx, &dev_attrs))
- goto query_free;
-diff --git a/src/mlx4.h b/src/mlx4.h
-index 8643d8f..3eadb98 100644
---- a/src/mlx4.h
-+++ b/src/mlx4.h
-@@ -79,6 +79,11 @@
-
- #endif
-
-+#ifndef HAVE_IBV_MORE_OPS
-+#undef HAVE_IBV_XRC_OPS
-+#undef HAVE_IBV_CREATE_QP_EXP
-+#endif
-+
- #define HIDDEN __attribute__((visibility ("hidden")))
-
- #define PFX "mlx4: "
-@@ -111,6 +116,16 @@ enum {
- MLX4_QP_TABLE_MASK = MLX4_QP_TABLE_SIZE - 1
- };
-
-+enum {
-+ MLX4_XRC_SRQ_TABLE_BITS = 8,
-+ MLX4_XRC_SRQ_TABLE_SIZE = 1 << MLX4_XRC_SRQ_TABLE_BITS,
-+ MLX4_XRC_SRQ_TABLE_MASK = MLX4_XRC_SRQ_TABLE_SIZE - 1
-+};
-+
-+enum {
-+ MLX4_XRC_QPN_BIT = (1 << 23)
-+};
-+
- enum mlx4_db_type {
- MLX4_DB_TYPE_CQ,
- MLX4_DB_TYPE_RQ,
-@@ -174,6 +189,15 @@ struct mlx4_context {
- int max_sge;
- int max_cqe;
-
-+ struct {
-+ struct mlx4_srq **table;
-+ int refcnt;
-+ } xrc_srq_table[MLX4_XRC_SRQ_TABLE_SIZE];
-+ pthread_mutex_t xrc_srq_table_mutex;
-+ int num_xrc_srqs;
-+ int xrc_srq_table_shift;
-+ int xrc_srq_table_mask;
-+
- struct mlx4_db_page *db_list[MLX4_NUM_DB_TYPE];
- pthread_mutex_t db_list_mutex;
- };
-@@ -260,6 +284,11 @@ struct mlx4_ah {
- struct mlx4_av av;
- };
-
-+struct mlx4_xrc_domain {
-+ struct ibv_xrc_domain ibv_xrcd;
-+ uint32_t xrcdn;
-+};
-+
- static inline unsigned long align(unsigned long val, unsigned long align)
- {
- return (val + align - 1) & ~(align - 1);
-@@ -304,6 +333,13 @@ static inline struct mlx4_ah *to_mah(struct ibv_ah *ibah)
- return to_mxxx(ah, ah);
- }
-
-+#ifdef HAVE_IBV_XRC_OPS
-+static inline struct mlx4_xrc_domain *to_mxrcd(struct ibv_xrc_domain *ibxrcd)
-+{
-+ return to_mxxx(xrcd, xrc_domain);
-+}
-+#endif
-+
- int mlx4_alloc_buf(struct mlx4_buf *buf, size_t size, int page_size);
- void mlx4_free_buf(struct mlx4_buf *buf);
-
-@@ -350,6 +386,10 @@ void mlx4_free_srq_wqe(struct mlx4_srq *srq, int ind);
- int mlx4_post_srq_recv(struct ibv_srq *ibsrq,
- struct ibv_recv_wr *wr,
- struct ibv_recv_wr **bad_wr);
-+struct mlx4_srq *mlx4_find_xrc_srq(struct mlx4_context *ctx, uint32_t xrc_srqn);
-+int mlx4_store_xrc_srq(struct mlx4_context *ctx, uint32_t xrc_srqn,
-+ struct mlx4_srq *srq);
-+void mlx4_clear_xrc_srq(struct mlx4_context *ctx, uint32_t xrc_srqn);
-
- struct ibv_qp *mlx4_create_qp(struct ibv_pd *pd, struct ibv_qp_init_attr *attr);
- int mlx4_query_qp(struct ibv_qp *qp, struct ibv_qp_attr *attr,
-@@ -380,5 +420,16 @@ int mlx4_alloc_av(struct mlx4_pd *pd, struct ibv_ah_attr *attr,
- int mlx4_alloc_av(struct mlx4_pd *pd, struct ibv_ah_attr *attr,
- struct mlx4_ah *ah);
- void mlx4_free_av(struct mlx4_ah *ah);
-+#ifdef HAVE_IBV_XRC_OPS
-+struct ibv_srq *mlx4_create_xrc_srq(struct ibv_pd *pd,
-+ struct ibv_xrc_domain *xrc_domain,
-+ struct ibv_cq *xrc_cq,
-+ struct ibv_srq_init_attr *attr);
-+struct ibv_xrc_domain *mlx4_open_xrc_domain(struct ibv_context *context,
-+ int fd, int oflag);
-+
-+int mlx4_close_xrc_domain(struct ibv_xrc_domain *d);
-+#endif
-+
-
- #endif /* MLX4_H */
-diff --git a/src/qp.c b/src/qp.c
-index 01e8580..2f02430 100644
---- a/src/qp.c
-+++ b/src/qp.c
-@@ -226,7 +226,7 @@ int mlx4_post_send(struct ibv_qp *ibqp, struct ibv_send_wr *wr,
- ctrl = wqe = get_send_wqe(qp, ind & (qp->sq.wqe_cnt - 1));
- qp->sq.wrid[ind & (qp->sq.wqe_cnt - 1)] = wr->wr_id;
-
-- ctrl->srcrb_flags =
-+ ctrl->xrcrb_flags =
- (wr->send_flags & IBV_SEND_SIGNALED ?
- htonl(MLX4_WQE_CTRL_CQ_UPDATE) : 0) |
- (wr->send_flags & IBV_SEND_SOLICITED ?
-@@ -243,6 +243,9 @@ int mlx4_post_send(struct ibv_qp *ibqp, struct ibv_send_wr *wr,
- size = sizeof *ctrl / 16;
-
- switch (ibqp->qp_type) {
-+ case IBV_QPT_XRC:
-+ ctrl->xrcrb_flags |= htonl(wr->xrc_remote_srq_num << 8);
-+ /* fall thru */
- case IBV_QPT_RC:
- case IBV_QPT_UC:
- switch (wr->opcode) {
-@@ -543,6 +546,7 @@ void mlx4_calc_sq_wqe_size(struct ibv_qp_cap *cap, enum ibv_qp_type type,
- size += sizeof (struct mlx4_wqe_raddr_seg);
- break;
-
-+ case IBV_QPT_XRC:
- case IBV_QPT_RC:
- size += sizeof (struct mlx4_wqe_raddr_seg);
- /*
-@@ -631,6 +635,7 @@ void mlx4_set_sq_sizes(struct mlx4_qp *qp, struct ibv_qp_cap *cap,
-
- case IBV_QPT_UC:
- case IBV_QPT_RC:
-+ case IBV_QPT_XRC:
- wqe_size -= sizeof (struct mlx4_wqe_raddr_seg);
- break;
-
-diff --git a/src/srq.c b/src/srq.c
-index ba2ceb9..1350792 100644
---- a/src/srq.c
-+++ b/src/srq.c
-@@ -167,3 +167,53 @@ int mlx4_alloc_srq_buf(struct ibv_pd *pd, struct ibv_srq_attr *attr,
-
- return 0;
- }
-+
-+struct mlx4_srq *mlx4_find_xrc_srq(struct mlx4_context *ctx, uint32_t xrc_srqn)
-+{
-+ int tind = (xrc_srqn & (ctx->num_xrc_srqs - 1)) >> ctx->xrc_srq_table_shift;
-+
-+ if (ctx->xrc_srq_table[tind].refcnt)
-+ return ctx->xrc_srq_table[tind].table[xrc_srqn & ctx->xrc_srq_table_mask];
-+ else
-+ return NULL;
-+}
-+
-+int mlx4_store_xrc_srq(struct mlx4_context *ctx, uint32_t xrc_srqn,
-+ struct mlx4_srq *srq)
-+{
-+ int tind = (xrc_srqn & (ctx->num_xrc_srqs - 1)) >> ctx->xrc_srq_table_shift;
-+ int ret = 0;
-+
-+ pthread_mutex_lock(&ctx->xrc_srq_table_mutex);
-+
-+ if (!ctx->xrc_srq_table[tind].refcnt) {
-+ ctx->xrc_srq_table[tind].table = calloc(ctx->xrc_srq_table_mask + 1,
-+ sizeof(struct mlx4_srq *));
-+ if (!ctx->xrc_srq_table[tind].table) {
-+ ret = -1;
-+ goto out;
-+ }
-+ }
-+
-+ ++ctx->xrc_srq_table[tind].refcnt;
-+ ctx->xrc_srq_table[tind].table[xrc_srqn & ctx->xrc_srq_table_mask] = srq;
-+
-+out:
-+ pthread_mutex_unlock(&ctx->xrc_srq_table_mutex);
-+ return ret;
-+}
-+
-+void mlx4_clear_xrc_srq(struct mlx4_context *ctx, uint32_t xrc_srqn)
-+{
-+ int tind = (xrc_srqn & (ctx->num_xrc_srqs - 1)) >> ctx->xrc_srq_table_shift;
-+
-+ pthread_mutex_lock(&ctx->xrc_srq_table_mutex);
-+
-+ if (!--ctx->xrc_srq_table[tind].refcnt)
-+ free(ctx->xrc_srq_table[tind].table);
-+ else
-+ ctx->xrc_srq_table[tind].table[xrc_srqn & ctx->xrc_srq_table_mask] = NULL;
-+
-+ pthread_mutex_unlock(&ctx->xrc_srq_table_mutex);
-+}
-+
-diff --git a/src/verbs.c b/src/verbs.c
-index 400050c..b7c9c8e 100644
---- a/src/verbs.c
-+++ b/src/verbs.c
-@@ -368,18 +368,36 @@ int mlx4_query_srq(struct ibv_srq *srq,
- return ibv_cmd_query_srq(srq, attr, &cmd, sizeof cmd);
- }
-
--int mlx4_destroy_srq(struct ibv_srq *srq)
-+int mlx4_destroy_srq(struct ibv_srq *ibsrq)
- {
-+ struct mlx4_srq *srq = to_msrq(ibsrq);
-+ struct mlx4_cq *mcq = NULL;
- int ret;
-
-- ret = ibv_cmd_destroy_srq(srq);
-- if (ret)
-+ if (ibsrq->xrc_cq) {
-+ /* is an xrc_srq */
-+ mcq = to_mcq(ibsrq->xrc_cq);
-+ mlx4_cq_clean(mcq, 0, srq);
-+ pthread_spin_lock(&mcq->lock);
-+ mlx4_clear_xrc_srq(to_mctx(ibsrq->context), srq->srqn);
-+ pthread_spin_unlock(&mcq->lock);
-+ }
-+
-+ ret = ibv_cmd_destroy_srq(ibsrq);
-+ if (ret) {
-+ if (ibsrq->xrc_cq) {
-+ pthread_spin_lock(&mcq->lock);
-+ mlx4_store_xrc_srq(to_mctx(ibsrq->context),
-+ srq->srqn, srq);
-+ pthread_spin_unlock(&mcq->lock);
-+ }
- return ret;
-+ }
-
-- mlx4_free_db(to_mctx(srq->context), MLX4_DB_TYPE_RQ, to_msrq(srq)->db);
-- mlx4_free_buf(&to_msrq(srq)->buf);
-- free(to_msrq(srq)->wrid);
-- free(to_msrq(srq));
-+ mlx4_free_db(to_mctx(ibsrq->context), MLX4_DB_TYPE_RQ, srq->db);
-+ mlx4_free_buf(&srq->buf);
-+ free(srq->wrid);
-+ free(srq);
-
- return 0;
- }
-@@ -415,7 +433,7 @@ struct ibv_qp *mlx4_create_qp(struct ibv_pd *pd, struct ibv_qp_init_attr *attr)
- qp->sq.wqe_cnt = align_queue_size(attr->cap.max_send_wr + qp->sq_spare_wqes);
- qp->rq.wqe_cnt = align_queue_size(attr->cap.max_recv_wr);
-
-- if (attr->srq)
-+ if (attr->srq || attr->qp_type == IBV_QPT_XRC)
- attr->cap.max_recv_wr = qp->rq.wqe_cnt = 0;
- else {
- if (attr->cap.max_recv_sge < 1)
-@@ -433,7 +451,7 @@ struct ibv_qp *mlx4_create_qp(struct ibv_pd *pd, struct ibv_qp_init_attr *attr)
- pthread_spin_init(&qp->rq.lock, PTHREAD_PROCESS_PRIVATE))
- goto err_free;
-
-- if (!attr->srq) {
-+ if (!attr->srq && attr->qp_type != IBV_QPT_XRC) {
- qp->db = mlx4_alloc_db(to_mctx(pd->context), MLX4_DB_TYPE_RQ);
- if (!qp->db)
- goto err_free;
-@@ -442,7 +460,7 @@ struct ibv_qp *mlx4_create_qp(struct ibv_pd *pd, struct ibv_qp_init_attr *attr)
- }
-
- cmd.buf_addr = (uintptr_t) qp->buf.buf;
-- if (attr->srq)
-+ if (attr->srq || attr->qp_type == IBV_QPT_XRC)
- cmd.db_addr = 0;
- else
- cmd.db_addr = (uintptr_t) qp->db;
-@@ -485,7 +503,7 @@ err_destroy:
-
- err_rq_db:
- pthread_mutex_unlock(&to_mctx(pd->context)->qp_table_mutex);
-- if (!attr->srq)
-+ if (!attr->srq && attr->qp_type != IBV_QPT_XRC)
- mlx4_free_db(to_mctx(pd->context), MLX4_DB_TYPE_RQ, qp->db);
-
- err_free:
-@@ -544,7 +562,7 @@ int mlx4_modify_qp(struct ibv_qp *qp, struct ibv_qp_attr *attr,
- mlx4_cq_clean(to_mcq(qp->send_cq), qp->qp_num, NULL);
-
- mlx4_init_qp_indices(to_mqp(qp));
-- if (!qp->srq)
-+ if (!qp->srq && qp->qp_type != IBV_QPT_XRC)
- *to_mqp(qp)->db = 0;
- }
-
-@@ -603,7 +621,7 @@ int mlx4_destroy_qp(struct ibv_qp *ibqp)
- mlx4_unlock_cqs(ibqp);
- pthread_mutex_unlock(&to_mctx(ibqp->context)->qp_table_mutex);
-
-- if (!ibqp->srq)
-+ if (!ibqp->srq && ibqp->qp_type != IBV_QPT_XRC)
- mlx4_free_db(to_mctx(ibqp->context), MLX4_DB_TYPE_RQ, qp->db);
- free(qp->sq.wrid);
- if (qp->rq.wqe_cnt)
-@@ -661,3 +679,103 @@ int mlx4_detach_mcast(struct ibv_qp *qp, union ibv_gid *gid, uint16_t lid)
-
- return 0;
- }
-+
-+#ifdef HAVE_IBV_XRC_OPS
-+struct ibv_srq *mlx4_create_xrc_srq(struct ibv_pd *pd,
-+ struct ibv_xrc_domain *xrc_domain,
-+ struct ibv_cq *xrc_cq,
-+ struct ibv_srq_init_attr *attr)
-+{
-+ struct mlx4_create_xrc_srq cmd;
-+ struct mlx4_create_srq_resp resp;
-+ struct mlx4_srq *srq;
-+ int ret;
-+
-+ /* Sanity check SRQ size before proceeding */
-+ if (attr->attr.max_wr > 1 << 16 || attr->attr.max_sge > 64)
-+ return NULL;
-+
-+ srq = malloc(sizeof *srq);
-+ if (!srq)
-+ return NULL;
-+
-+ if (pthread_spin_init(&srq->lock, PTHREAD_PROCESS_PRIVATE))
-+ goto err;
-+
-+ srq->max = align_queue_size(attr->attr.max_wr + 1);
-+ srq->max_gs = attr->attr.max_sge;
-+ srq->counter = 0;
-+
-+ if (mlx4_alloc_srq_buf(pd, &attr->attr, srq))
-+ goto err;
-+
-+ srq->db = mlx4_alloc_db(to_mctx(pd->context), MLX4_DB_TYPE_RQ);
-+ if (!srq->db)
-+ goto err_free;
-+
-+ *srq->db = 0;
-+
-+ cmd.buf_addr = (uintptr_t) srq->buf.buf;
-+ cmd.db_addr = (uintptr_t) srq->db;
-+
-+ ret = ibv_cmd_create_xrc_srq(pd, &srq->ibv_srq, attr,
-+ xrc_domain->handle,
-+ xrc_cq->handle,
-+ &cmd.ibv_cmd, sizeof cmd,
-+ &resp.ibv_resp, sizeof resp);
-+ if (ret)
-+ goto err_db;
-+
-+ srq->ibv_srq.xrc_srq_num = srq->srqn = resp.srqn;
-+
-+ ret = mlx4_store_xrc_srq(to_mctx(pd->context), srq->ibv_srq.xrc_srq_num, srq);
-+ if (ret)
-+ goto err_destroy;
-+
-+ return &srq->ibv_srq;
-+
-+err_destroy:
-+ ibv_cmd_destroy_srq(&srq->ibv_srq);
-+
-+err_db:
-+ mlx4_free_db(to_mctx(pd->context), MLX4_DB_TYPE_RQ, srq->db);
-+
-+err_free:
-+ free(srq->wrid);
-+ mlx4_free_buf(&srq->buf);
-+
-+err:
-+ free(srq);
-+
-+ return NULL;
-+}
-+
-+struct ibv_xrc_domain *mlx4_open_xrc_domain(struct ibv_context *context,
-+ int fd, int oflag)
-+{
-+ int ret;
-+ struct mlx4_open_xrc_domain_resp resp;
-+ struct mlx4_xrc_domain *xrcd;
-+
-+ xrcd = malloc(sizeof *xrcd);
-+ if (!xrcd)
-+ return NULL;
-+
-+ ret = ibv_cmd_open_xrc_domain(context, fd, oflag, &xrcd->ibv_xrcd,
-+ &resp.ibv_resp, sizeof resp);
-+ if (ret) {
-+ free(xrcd);
-+ return NULL;
-+ }
-+
-+ xrcd->xrcdn = resp.xrcdn;
-+ return &xrcd->ibv_xrcd;
-+}
-+
-+int mlx4_close_xrc_domain(struct ibv_xrc_domain *d)
-+{
-+ ibv_cmd_close_xrc_domain(d);
-+ free(d);
-+ return 0;
-+}
-+#endif
-diff --git a/src/wqe.h b/src/wqe.h
-index 6f7f309..fa2f8ac 100644
---- a/src/wqe.h
-+++ b/src/wqe.h
-@@ -65,7 +65,7 @@ struct mlx4_wqe_ctrl_seg {
- * [1] SE (solicited event)
- * [0] FL (force loopback)
- */
-- uint32_t srcrb_flags;
-+ uint32_t xrcrb_flags;
- /*
- * imm is immediate data for send/RDMA write w/ immediate;
- * also invalidation key for send with invalidate; input
diff --git a/contrib/ofed/libmlx4/fixes/xrc_fix_close_domain.patch b/contrib/ofed/libmlx4/fixes/xrc_fix_close_domain.patch
deleted file mode 100644
index dfad7ac..0000000
--- a/contrib/ofed/libmlx4/fixes/xrc_fix_close_domain.patch
+++ /dev/null
@@ -1,27 +0,0 @@
-Pass return code to caller in mlx4_close_xrc_domain.
-
-ibv_cmd_close_xrc_domain() can return a busy or invalid error code.
-Need to pass this upward to caller.
-(Bugzilla 999)
-
-Signed-off-by: Jack Morgenstein <jackm@dev.mellanox.co.il>
-
-Index: libmlx4/src/verbs.c
-===================================================================
---- libmlx4.orig/src/verbs.c 2008-09-01 10:51:11.000000000 +0300
-+++ libmlx4/src/verbs.c 2008-09-01 10:52:40.000000000 +0300
-@@ -774,9 +774,11 @@
-
- int mlx4_close_xrc_domain(struct ibv_xrc_domain *d)
- {
-- ibv_cmd_close_xrc_domain(d);
-- free(d);
-- return 0;
-+ int ret;
-+ ret = ibv_cmd_close_xrc_domain(d);
-+ if (!ret)
-+ free(d);
-+ return ret;
- }
-
- int mlx4_create_xrc_rcv_qp(struct ibv_qp_init_attr *init_attr,
diff --git a/contrib/ofed/libmlx4/fixes/xrc_kernel_user_mismatch.patch b/contrib/ofed/libmlx4/fixes/xrc_kernel_user_mismatch.patch
deleted file mode 100644
index 41a0edb..0000000
--- a/contrib/ofed/libmlx4/fixes/xrc_kernel_user_mismatch.patch
+++ /dev/null
@@ -1,22 +0,0 @@
-When creating a new user context, exit if the kernel
-does not support XRC. (OFED libmlx4 has a compatibility problem).
-
-Signed-off-by: Jack Morgenstein <jackm@dev.mellanox.co.il>
-
-Index: libmlx4/src/mlx4.c
-===================================================================
---- libmlx4.orig/src/mlx4.c 2009-05-10 12:16:33.000000000 +0300
-+++ libmlx4/src/mlx4.c 2009-05-10 12:30:06.000000000 +0300
-@@ -190,6 +190,12 @@
- context->max_qp_wr = dev_attrs.max_qp_wr;
- context->max_sge = dev_attrs.max_sge;
- context->max_cqe = dev_attrs.max_cqe;
-+ if (!(dev_attrs.device_cap_flags & IBV_DEVICE_XRC)) {
-+ fprintf(stderr, PFX "There is a mismatch between "
-+ "the kernel and the userspace libraries: "
-+ "Kernel does not support XRC. Exiting.\n");
-+ goto query_free;
-+ }
-
- return &context->ibv_ctx;
-
diff --git a/contrib/ofed/libmlx4/fixes/xrc_rcv_qp_v2.patch b/contrib/ofed/libmlx4/fixes/xrc_rcv_qp_v2.patch
deleted file mode 100644
index 311c500..0000000
--- a/contrib/ofed/libmlx4/fixes/xrc_rcv_qp_v2.patch
+++ /dev/null
@@ -1,113 +0,0 @@
-Added support for XRC receive-only QPs (version 2).
-
-Signed-off-by: Jack Morgenstein <jackm@dev.mellanox.co.il>
----
-V2:
-1. xrc_ops changed to more_ops
-
-diff --git a/src/mlx4.c b/src/mlx4.c
-index 27ca75d..e5ded78 100644
---- a/src/mlx4.c
-+++ b/src/mlx4.c
-@@ -74,6 +74,11 @@ static struct ibv_more_ops mlx4_more_ops = {
- .create_xrc_srq = mlx4_create_xrc_srq,
- .open_xrc_domain = mlx4_open_xrc_domain,
- .close_xrc_domain = mlx4_close_xrc_domain,
-+ .create_xrc_rcv_qp = mlx4_create_xrc_rcv_qp,
-+ .modify_xrc_rcv_qp = mlx4_modify_xrc_rcv_qp,
-+ .query_xrc_rcv_qp = mlx4_query_xrc_rcv_qp,
-+ .reg_xrc_rcv_qp = mlx4_reg_xrc_rcv_qp,
-+ .unreg_xrc_rcv_qp = mlx4_unreg_xrc_rcv_qp,
- #endif
- };
- #endif
-diff --git a/src/mlx4.h b/src/mlx4.h
-index 3eadb98..6307a2d 100644
---- a/src/mlx4.h
-+++ b/src/mlx4.h
-@@ -429,6 +429,21 @@ struct ibv_xrc_domain *mlx4_open_xrc_domain(struct ibv_context *context,
- int fd, int oflag);
-
- int mlx4_close_xrc_domain(struct ibv_xrc_domain *d);
-+int mlx4_create_xrc_rcv_qp(struct ibv_qp_init_attr *init_attr,
-+ uint32_t *xrc_qp_num);
-+int mlx4_modify_xrc_rcv_qp(struct ibv_xrc_domain *xrc_domain,
-+ uint32_t xrc_qp_num,
-+ struct ibv_qp_attr *attr,
-+ int attr_mask);
-+int mlx4_query_xrc_rcv_qp(struct ibv_xrc_domain *xrc_domain,
-+ uint32_t xrc_qp_num,
-+ struct ibv_qp_attr *attr,
-+ int attr_mask,
-+ struct ibv_qp_init_attr *init_attr);
-+int mlx4_reg_xrc_rcv_qp(struct ibv_xrc_domain *xrc_domain,
-+ uint32_t xrc_qp_num);
-+int mlx4_unreg_xrc_rcv_qp(struct ibv_xrc_domain *xrc_domain,
-+ uint32_t xrc_qp_num);
- #endif
-
-
-diff --git a/src/verbs.c b/src/verbs.c
-index b7c9c8e..8261eae 100644
---- a/src/verbs.c
-+++ b/src/verbs.c
-@@ -778,4 +778,59 @@ int mlx4_close_xrc_domain(struct ibv_xrc_domain *d)
- free(d);
- return 0;
- }
-+
-+int mlx4_create_xrc_rcv_qp(struct ibv_qp_init_attr *init_attr,
-+ uint32_t *xrc_qp_num)
-+{
-+
-+ return ibv_cmd_create_xrc_rcv_qp(init_attr, xrc_qp_num);
-+}
-+
-+int mlx4_modify_xrc_rcv_qp(struct ibv_xrc_domain *xrc_domain,
-+ uint32_t xrc_qp_num,
-+ struct ibv_qp_attr *attr,
-+ int attr_mask)
-+{
-+ return ibv_cmd_modify_xrc_rcv_qp(xrc_domain, xrc_qp_num,
-+ attr, attr_mask);
-+}
-+
-+int mlx4_query_xrc_rcv_qp(struct ibv_xrc_domain *xrc_domain,
-+ uint32_t xrc_qp_num,
-+ struct ibv_qp_attr *attr,
-+ int attr_mask,
-+ struct ibv_qp_init_attr *init_attr)
-+{
-+ int ret;
-+
-+ ret = ibv_cmd_query_xrc_rcv_qp(xrc_domain, xrc_qp_num,
-+ attr, attr_mask, init_attr);
-+ if (ret)
-+ return ret;
-+
-+ init_attr->cap.max_send_wr = init_attr->cap.max_send_sge = 1;
-+ init_attr->cap.max_recv_sge = init_attr->cap.max_recv_wr = 0;
-+ init_attr->cap.max_inline_data = 0;
-+ init_attr->recv_cq = init_attr->send_cq = NULL;
-+ init_attr->srq = NULL;
-+ init_attr->xrc_domain = xrc_domain;
-+ init_attr->qp_type = IBV_QPT_XRC;
-+ init_attr->qp_context = NULL;
-+ attr->cap = init_attr->cap;
-+
-+ return 0;
-+}
-+
-+int mlx4_reg_xrc_rcv_qp(struct ibv_xrc_domain *xrc_domain,
-+ uint32_t xrc_qp_num)
-+{
-+ return ibv_cmd_reg_xrc_rcv_qp(xrc_domain, xrc_qp_num);
-+}
-+
-+int mlx4_unreg_xrc_rcv_qp(struct ibv_xrc_domain *xrc_domain,
-+ uint32_t xrc_qp_num)
-+{
-+ return ibv_cmd_unreg_xrc_rcv_qp(xrc_domain, xrc_qp_num);
-+}
-+
- #endif
diff --git a/contrib/ofed/libmlx4/libmlx4.spec.in b/contrib/ofed/libmlx4/libmlx4.spec.in
deleted file mode 100644
index 04c3625..0000000
--- a/contrib/ofed/libmlx4/libmlx4.spec.in
+++ /dev/null
@@ -1,65 +0,0 @@
-Name: libmlx4
-Version: 1.0
-Release: 2%{?dist}
-Summary: Mellanox ConnectX InfiniBand HCA Userspace Driver
-
-Group: System Environment/Libraries
-License: GPLv2 or BSD
-Url: http://openfabrics.org/
-Source: http://openfabrics.org/downloads/mlx4/libmlx4-1.0.tar.gz
-BuildRoot: %(mktemp -ud %{_tmppath}/%{name}-%{version}-%{release}-XXXXXX)
-
-BuildRequires: libibverbs-devel >= 1.1-0.1.rc2
-
-%description
-libmlx4 provides a device-specific userspace driver for Mellanox
-ConnectX HCAs for use with the libibverbs library.
-
-%package devel
-Summary: Development files for the libmlx4 driver
-Group: System Environment/Libraries
-Requires: %{name} = %{version}-%{release}
-Provides: libmlx4-static = %{version}-%{release}
-
-%description devel
-Static version of libmlx4 that may be linked directly to an
-application, which may be useful for debugging.
-
-%prep
-%setup -q -n %{name}-@VERSION@
-
-%build
-%configure
-make %{?_smp_mflags}
-
-%install
-rm -rf $RPM_BUILD_ROOT
-make DESTDIR=%{buildroot} install
-# remove unpackaged files from the buildroot
-rm -f $RPM_BUILD_ROOT%{_libdir}/*.la $RPM_BUILD_ROOT%{_libdir}/libmlx4.so
-
-%clean
-rm -rf $RPM_BUILD_ROOT
-
-%files
-%defattr(-,root,root,-)
-%{_libdir}/libmlx4-rdmav2.so
-%{_sysconfdir}/libibverbs.d/mlx4.driver
-%doc AUTHORS COPYING README
-
-%files devel
-%defattr(-,root,root,-)
-%{_libdir}/libmlx4.a
-
-%changelog
-* Sun Jan 27 2008 Roland Dreier <rdreier@cisco.com> - 1.0-2
-- Spec file cleanups, based on Fedora review: don't mark
- libmlx4.driver as a config file, since it is not user modifiable,
- and change the name of the -devel-static package to plain -devel,
- since it would be empty without the static library.
-
-* Sun Dec 9 2007 Roland Dreier <rdreier@cisco.com> - 1.0-1
-- New upstream release
-
-* Fri Apr 6 2007 Roland Dreier <rdreier@cisco.com> - 1.0-0.1.rc1
-- Initial Fedora spec file
diff --git a/contrib/ofed/libmlx4/mlx4-abi.h b/contrib/ofed/libmlx4/mlx4-abi.h
new file mode 100644
index 0000000..7d89505
--- /dev/null
+++ b/contrib/ofed/libmlx4/mlx4-abi.h
@@ -0,0 +1,159 @@
+/*
+ * Copyright (c) 2007 Cisco, Inc. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#ifndef MLX4_ABI_H
+#define MLX4_ABI_H
+
+#include <infiniband/kern-abi.h>
+
+#define MLX4_UVERBS_MIN_ABI_VERSION 2
+#define MLX4_UVERBS_MAX_ABI_VERSION 4
+
+#define MLX4_UVERBS_NO_DEV_CAPS_ABI_VERSION 3
+
+enum {
+ MLX4_USER_DEV_CAP_64B_CQE = 1L << 0
+};
+
+struct mlx4_alloc_ucontext_resp_v3 {
+ struct ibv_get_context_resp ibv_resp;
+ __u32 qp_tab_size;
+ __u16 bf_reg_size;
+ __u16 bf_regs_per_page;
+};
+
+enum mlx4_query_dev_ex_resp_mask {
+ MLX4_QUERY_DEV_RESP_MASK_CORE_CLOCK_OFFSET = 1UL << 0,
+};
+
+struct mlx4_alloc_ucontext_resp {
+ struct ibv_get_context_resp ibv_resp;
+ __u32 dev_caps;
+ __u32 qp_tab_size;
+ __u16 bf_reg_size;
+ __u16 bf_regs_per_page;
+ __u32 cqe_size;
+};
+
+struct mlx4_alloc_pd_resp {
+ struct ibv_alloc_pd_resp ibv_resp;
+ __u32 pdn;
+ __u32 reserved;
+};
+
+struct mlx4_create_cq {
+ struct ibv_create_cq ibv_cmd;
+ __u64 buf_addr;
+ __u64 db_addr;
+};
+
+struct mlx4_create_cq_resp {
+ struct ibv_create_cq_resp ibv_resp;
+ __u32 cqn;
+ __u32 reserved;
+};
+
+struct mlx4_create_cq_ex {
+ struct ibv_create_cq_ex ibv_cmd;
+ __u64 buf_addr;
+ __u64 db_addr;
+};
+
+struct mlx4_create_cq_resp_ex {
+ struct ibv_create_cq_resp_ex ibv_resp;
+ __u32 cqn;
+ __u32 reserved;
+};
+
+struct mlx4_resize_cq {
+ struct ibv_resize_cq ibv_cmd;
+ __u64 buf_addr;
+};
+
+struct mlx4_query_device_ex_resp {
+ struct ibv_query_device_resp_ex ibv_resp;
+ __u32 comp_mask;
+ __u32 response_length;
+ __u64 hca_core_clock_offset;
+};
+
+struct mlx4_query_device_ex {
+ struct ibv_query_device_ex ibv_cmd;
+};
+
+struct mlx4_create_srq {
+ struct ibv_create_srq ibv_cmd;
+ __u64 buf_addr;
+ __u64 db_addr;
+};
+
+struct mlx4_create_xsrq {
+ struct ibv_create_xsrq ibv_cmd;
+ __u64 buf_addr;
+ __u64 db_addr;
+};
+
+struct mlx4_create_srq_resp {
+ struct ibv_create_srq_resp ibv_resp;
+ __u32 srqn;
+ __u32 reserved;
+};
+
+struct mlx4_create_qp {
+ struct ibv_create_qp ibv_cmd;
+ __u64 buf_addr;
+ __u64 db_addr;
+ __u8 log_sq_bb_count;
+ __u8 log_sq_stride;
+ __u8 sq_no_prefetch; /* was reserved in ABI 2 */
+ __u8 reserved[5];
+};
+
+struct mlx4_create_qp_drv_ex {
+ __u64 buf_addr;
+ __u64 db_addr;
+ __u8 log_sq_bb_count;
+ __u8 log_sq_stride;
+ __u8 sq_no_prefetch; /* was reserved in ABI 2 */
+ __u8 reserved[5];
+};
+
+struct mlx4_create_qp_ex {
+ struct ibv_create_qp_ex ibv_cmd;
+ struct mlx4_create_qp_drv_ex drv_ex;
+};
+
+struct mlx4_create_qp_resp_ex {
+ struct ibv_create_qp_resp_ex ibv_resp;
+};
+
+#endif /* MLX4_ABI_H */
diff --git a/contrib/ofed/libmlx4/mlx4.c b/contrib/ofed/libmlx4/mlx4.c
new file mode 100644
index 0000000..229c267
--- /dev/null
+++ b/contrib/ofed/libmlx4/mlx4.c
@@ -0,0 +1,327 @@
+/*
+ * Copyright (c) 2007 Cisco, Inc. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#include <config.h>
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <errno.h>
+#include <sys/mman.h>
+#include <pthread.h>
+#include <string.h>
+
+#include "mlx4.h"
+#include "mlx4-abi.h"
+
+#ifndef PCI_VENDOR_ID_MELLANOX
+#define PCI_VENDOR_ID_MELLANOX 0x15b3
+#endif
+
+#define HCA(v, d) \
+ { .vendor = PCI_VENDOR_ID_##v, \
+ .device = d }
+
+static struct {
+ unsigned vendor;
+ unsigned device;
+} hca_table[] = {
+ HCA(MELLANOX, 0x6340), /* MT25408 "Hermon" SDR */
+ HCA(MELLANOX, 0x634a), /* MT25408 "Hermon" DDR */
+ HCA(MELLANOX, 0x6354), /* MT25408 "Hermon" QDR */
+ HCA(MELLANOX, 0x6732), /* MT25408 "Hermon" DDR PCIe gen2 */
+ HCA(MELLANOX, 0x673c), /* MT25408 "Hermon" QDR PCIe gen2 */
+ HCA(MELLANOX, 0x6368), /* MT25408 "Hermon" EN 10GigE */
+ HCA(MELLANOX, 0x6750), /* MT25408 "Hermon" EN 10GigE PCIe gen2 */
+ HCA(MELLANOX, 0x6372), /* MT25458 ConnectX EN 10GBASE-T 10GigE */
+ HCA(MELLANOX, 0x675a), /* MT25458 ConnectX EN 10GBASE-T+Gen2 10GigE */
+ HCA(MELLANOX, 0x6764), /* MT26468 ConnectX EN 10GigE PCIe gen2*/
+ HCA(MELLANOX, 0x6746), /* MT26438 ConnectX EN 40GigE PCIe gen2 5GT/s */
+ HCA(MELLANOX, 0x676e), /* MT26478 ConnectX2 40GigE PCIe gen2 */
+ HCA(MELLANOX, 0x1002), /* MT25400 Family [ConnectX-2 Virtual Function] */
+ HCA(MELLANOX, 0x1003), /* MT27500 Family [ConnectX-3] */
+ HCA(MELLANOX, 0x1004), /* MT27500 Family [ConnectX-3 Virtual Function] */
+ HCA(MELLANOX, 0x1005), /* MT27510 Family */
+ HCA(MELLANOX, 0x1006), /* MT27511 Family */
+ HCA(MELLANOX, 0x1007), /* MT27520 Family */
+ HCA(MELLANOX, 0x1008), /* MT27521 Family */
+ HCA(MELLANOX, 0x1009), /* MT27530 Family */
+ HCA(MELLANOX, 0x100a), /* MT27531 Family */
+ HCA(MELLANOX, 0x100b), /* MT27540 Family */
+ HCA(MELLANOX, 0x100c), /* MT27541 Family */
+ HCA(MELLANOX, 0x100d), /* MT27550 Family */
+ HCA(MELLANOX, 0x100e), /* MT27551 Family */
+ HCA(MELLANOX, 0x100f), /* MT27560 Family */
+ HCA(MELLANOX, 0x1010), /* MT27561 Family */
+};
+
+static struct ibv_context_ops mlx4_ctx_ops = {
+ .query_device = mlx4_query_device,
+ .query_port = mlx4_query_port,
+ .alloc_pd = mlx4_alloc_pd,
+ .dealloc_pd = mlx4_free_pd,
+ .reg_mr = mlx4_reg_mr,
+ .rereg_mr = mlx4_rereg_mr,
+ .dereg_mr = mlx4_dereg_mr,
+ .alloc_mw = mlx4_alloc_mw,
+ .dealloc_mw = mlx4_dealloc_mw,
+ .bind_mw = mlx4_bind_mw,
+ .create_cq = mlx4_create_cq,
+ .poll_cq = mlx4_poll_cq,
+ .req_notify_cq = mlx4_arm_cq,
+ .cq_event = mlx4_cq_event,
+ .resize_cq = mlx4_resize_cq,
+ .destroy_cq = mlx4_destroy_cq,
+ .create_srq = mlx4_create_srq,
+ .modify_srq = mlx4_modify_srq,
+ .query_srq = mlx4_query_srq,
+ .destroy_srq = mlx4_destroy_srq,
+ .post_srq_recv = mlx4_post_srq_recv,
+ .create_qp = mlx4_create_qp,
+ .query_qp = mlx4_query_qp,
+ .modify_qp = mlx4_modify_qp,
+ .destroy_qp = mlx4_destroy_qp,
+ .post_send = mlx4_post_send,
+ .post_recv = mlx4_post_recv,
+ .create_ah = mlx4_create_ah,
+ .destroy_ah = mlx4_destroy_ah,
+ .attach_mcast = ibv_cmd_attach_mcast,
+ .detach_mcast = ibv_cmd_detach_mcast
+};
+
+static int mlx4_map_internal_clock(struct mlx4_device *mdev,
+ struct ibv_context *ibv_ctx)
+{
+ struct mlx4_context *context = to_mctx(ibv_ctx);
+ void *hca_clock_page;
+
+ hca_clock_page = mmap(NULL, mdev->page_size,
+ PROT_READ, MAP_SHARED, ibv_ctx->cmd_fd,
+ mdev->page_size * 3);
+
+ if (hca_clock_page == MAP_FAILED) {
+ fprintf(stderr, PFX
+ "Warning: Timestamp available,\n"
+ "but failed to mmap() hca core clock page.\n");
+ return -1;
+ }
+
+ context->hca_core_clock = hca_clock_page +
+ (context->core_clock.offset & (mdev->page_size - 1));
+ return 0;
+}
+
+static int mlx4_init_context(struct verbs_device *v_device,
+ struct ibv_context *ibv_ctx, int cmd_fd)
+{
+ struct mlx4_context *context;
+ struct ibv_get_context cmd;
+ struct mlx4_alloc_ucontext_resp resp;
+ int i;
+ struct mlx4_alloc_ucontext_resp_v3 resp_v3;
+ __u16 bf_reg_size;
+ struct mlx4_device *dev = to_mdev(&v_device->device);
+ struct verbs_context *verbs_ctx = verbs_get_ctx(ibv_ctx);
+ struct ibv_device_attr_ex dev_attrs;
+
+ /* memory footprint of mlx4_context and verbs_context share
+ * struct ibv_context.
+ */
+ context = to_mctx(ibv_ctx);
+ ibv_ctx->cmd_fd = cmd_fd;
+
+ if (dev->abi_version <= MLX4_UVERBS_NO_DEV_CAPS_ABI_VERSION) {
+ if (ibv_cmd_get_context(ibv_ctx, &cmd, sizeof cmd,
+ &resp_v3.ibv_resp, sizeof resp_v3))
+ return errno;
+
+ context->num_qps = resp_v3.qp_tab_size;
+ bf_reg_size = resp_v3.bf_reg_size;
+ context->cqe_size = sizeof (struct mlx4_cqe);
+ } else {
+ if (ibv_cmd_get_context(ibv_ctx, &cmd, sizeof cmd,
+ &resp.ibv_resp, sizeof resp))
+ return errno;
+
+ context->num_qps = resp.qp_tab_size;
+ bf_reg_size = resp.bf_reg_size;
+ if (resp.dev_caps & MLX4_USER_DEV_CAP_64B_CQE)
+ context->cqe_size = resp.cqe_size;
+ else
+ context->cqe_size = sizeof (struct mlx4_cqe);
+ }
+
+ context->qp_table_shift = ffs(context->num_qps) - 1 - MLX4_QP_TABLE_BITS;
+ context->qp_table_mask = (1 << context->qp_table_shift) - 1;
+ for (i = 0; i < MLX4_PORTS_NUM; ++i)
+ context->port_query_cache[i].valid = 0;
+
+ pthread_mutex_init(&context->qp_table_mutex, NULL);
+ for (i = 0; i < MLX4_QP_TABLE_SIZE; ++i)
+ context->qp_table[i].refcnt = 0;
+
+ for (i = 0; i < MLX4_NUM_DB_TYPE; ++i)
+ context->db_list[i] = NULL;
+
+ mlx4_init_xsrq_table(&context->xsrq_table, context->num_qps);
+ pthread_mutex_init(&context->db_list_mutex, NULL);
+
+ context->uar = mmap(NULL, dev->page_size, PROT_WRITE,
+ MAP_SHARED, cmd_fd, 0);
+ if (context->uar == MAP_FAILED)
+ return errno;
+
+ if (bf_reg_size) {
+ context->bf_page = mmap(NULL, dev->page_size,
+ PROT_WRITE, MAP_SHARED, cmd_fd,
+ dev->page_size);
+ if (context->bf_page == MAP_FAILED) {
+ fprintf(stderr, PFX "Warning: BlueFlame available, "
+ "but failed to mmap() BlueFlame page.\n");
+ context->bf_page = NULL;
+ context->bf_buf_size = 0;
+ } else {
+ context->bf_buf_size = bf_reg_size / 2;
+ context->bf_offset = 0;
+ pthread_spin_init(&context->bf_lock, PTHREAD_PROCESS_PRIVATE);
+ }
+ } else {
+ context->bf_page = NULL;
+ context->bf_buf_size = 0;
+ }
+
+ pthread_spin_init(&context->uar_lock, PTHREAD_PROCESS_PRIVATE);
+ ibv_ctx->ops = mlx4_ctx_ops;
+
+ context->hca_core_clock = NULL;
+ memset(&dev_attrs, 0, sizeof(dev_attrs));
+ if (!mlx4_query_device_ex(ibv_ctx, NULL, &dev_attrs,
+ sizeof(struct ibv_device_attr_ex))) {
+ context->max_qp_wr = dev_attrs.orig_attr.max_qp_wr;
+ context->max_sge = dev_attrs.orig_attr.max_sge;
+ if (context->core_clock.offset_valid)
+ mlx4_map_internal_clock(dev, ibv_ctx);
+ }
+
+ verbs_ctx->has_comp_mask = VERBS_CONTEXT_XRCD | VERBS_CONTEXT_SRQ |
+ VERBS_CONTEXT_QP;
+ verbs_set_ctx_op(verbs_ctx, close_xrcd, mlx4_close_xrcd);
+ verbs_set_ctx_op(verbs_ctx, open_xrcd, mlx4_open_xrcd);
+ verbs_set_ctx_op(verbs_ctx, create_srq_ex, mlx4_create_srq_ex);
+ verbs_set_ctx_op(verbs_ctx, get_srq_num, verbs_get_srq_num);
+ verbs_set_ctx_op(verbs_ctx, create_qp_ex, mlx4_create_qp_ex);
+ verbs_set_ctx_op(verbs_ctx, open_qp, mlx4_open_qp);
+ verbs_set_ctx_op(verbs_ctx, ibv_create_flow, ibv_cmd_create_flow);
+ verbs_set_ctx_op(verbs_ctx, ibv_destroy_flow, ibv_cmd_destroy_flow);
+ verbs_set_ctx_op(verbs_ctx, create_cq_ex, mlx4_create_cq_ex);
+ verbs_set_ctx_op(verbs_ctx, query_device_ex, mlx4_query_device_ex);
+ verbs_set_ctx_op(verbs_ctx, query_rt_values, mlx4_query_rt_values);
+
+ return 0;
+
+}
+
+static void mlx4_uninit_context(struct verbs_device *v_device,
+ struct ibv_context *ibv_ctx)
+{
+ struct mlx4_context *context = to_mctx(ibv_ctx);
+
+ munmap(context->uar, to_mdev(&v_device->device)->page_size);
+ if (context->bf_page)
+ munmap(context->bf_page, to_mdev(&v_device->device)->page_size);
+ if (context->hca_core_clock)
+ munmap(context->hca_core_clock - context->core_clock.offset,
+ to_mdev(&v_device->device)->page_size);
+}
+
+static struct verbs_device_ops mlx4_dev_ops = {
+ .init_context = mlx4_init_context,
+ .uninit_context = mlx4_uninit_context,
+};
+
+static struct verbs_device *mlx4_driver_init(const char *uverbs_sys_path, int abi_version)
+{
+ char value[8];
+ struct mlx4_device *dev;
+ unsigned vendor, device;
+ int i;
+
+ if (ibv_read_sysfs_file(uverbs_sys_path, "device/vendor",
+ value, sizeof value) < 0)
+ return NULL;
+ vendor = strtol(value, NULL, 16);
+
+ if (ibv_read_sysfs_file(uverbs_sys_path, "device/device",
+ value, sizeof value) < 0)
+ return NULL;
+ device = strtol(value, NULL, 16);
+
+ for (i = 0; i < sizeof hca_table / sizeof hca_table[0]; ++i)
+ if (vendor == hca_table[i].vendor &&
+ device == hca_table[i].device)
+ goto found;
+
+ return NULL;
+
+found:
+ if (abi_version < MLX4_UVERBS_MIN_ABI_VERSION ||
+ abi_version > MLX4_UVERBS_MAX_ABI_VERSION) {
+ fprintf(stderr, PFX "Fatal: ABI version %d of %s is not supported "
+ "(min supported %d, max supported %d)\n",
+ abi_version, uverbs_sys_path,
+ MLX4_UVERBS_MIN_ABI_VERSION,
+ MLX4_UVERBS_MAX_ABI_VERSION);
+ return NULL;
+ }
+
+ dev = calloc(1, sizeof *dev);
+ if (!dev) {
+ fprintf(stderr, PFX "Fatal: couldn't allocate device for %s\n",
+ uverbs_sys_path);
+ return NULL;
+ }
+
+ dev->page_size = sysconf(_SC_PAGESIZE);
+ dev->abi_version = abi_version;
+
+ dev->verbs_dev.ops = &mlx4_dev_ops;
+ dev->verbs_dev.sz = sizeof(*dev);
+ dev->verbs_dev.size_of_context =
+ sizeof(struct mlx4_context) - sizeof(struct ibv_context);
+
+ return &dev->verbs_dev;
+}
+
+static __attribute__((constructor)) void mlx4_register_driver(void)
+{
+ verbs_register_driver("mlx4", mlx4_driver_init);
+}
diff --git a/contrib/ofed/libmlx4/mlx4.driver b/contrib/ofed/libmlx4/mlx4.driver
deleted file mode 100644
index 4d29fa8..0000000
--- a/contrib/ofed/libmlx4/mlx4.driver
+++ /dev/null
@@ -1 +0,0 @@
-driver mlx4
diff --git a/contrib/ofed/libmlx4/mlx4.h b/contrib/ofed/libmlx4/mlx4.h
new file mode 100644
index 0000000..864ef9e
--- /dev/null
+++ b/contrib/ofed/libmlx4/mlx4.h
@@ -0,0 +1,458 @@
+/*
+ * Copyright (c) 2004, 2005 Topspin Communications. All rights reserved.
+ * Copyright (c) 2005, 2006, 2007 Cisco Systems. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#ifndef MLX4_H
+#define MLX4_H
+
+#include <infiniband/endian.h>
+#include <stddef.h>
+
+#include <infiniband/driver.h>
+#include <infiniband/udma_barrier.h>
+#include <infiniband/verbs.h>
+
+#define MLX4_PORTS_NUM 2
+
+#define PFX "mlx4: "
+
+enum {
+ MLX4_STAT_RATE_OFFSET = 5
+};
+
+enum {
+ MLX4_QP_TABLE_BITS = 8,
+ MLX4_QP_TABLE_SIZE = 1 << MLX4_QP_TABLE_BITS,
+ MLX4_QP_TABLE_MASK = MLX4_QP_TABLE_SIZE - 1
+};
+
+#define MLX4_REMOTE_SRQN_FLAGS(wr) htobe32(wr->qp_type.xrc.remote_srqn << 8)
+
+enum {
+ MLX4_XSRQ_TABLE_BITS = 8,
+ MLX4_XSRQ_TABLE_SIZE = 1 << MLX4_XSRQ_TABLE_BITS,
+ MLX4_XSRQ_TABLE_MASK = MLX4_XSRQ_TABLE_SIZE - 1
+};
+
+struct mlx4_xsrq_table {
+ struct {
+ struct mlx4_srq **table;
+ int refcnt;
+ } xsrq_table[MLX4_XSRQ_TABLE_SIZE];
+
+ pthread_mutex_t mutex;
+ int num_xsrq;
+ int shift;
+ int mask;
+};
+
+enum {
+ MLX4_XRC_QPN_BIT = (1 << 23)
+};
+
+enum mlx4_db_type {
+ MLX4_DB_TYPE_CQ,
+ MLX4_DB_TYPE_RQ,
+ MLX4_NUM_DB_TYPE
+};
+
+enum {
+ MLX4_OPCODE_NOP = 0x00,
+ MLX4_OPCODE_SEND_INVAL = 0x01,
+ MLX4_OPCODE_RDMA_WRITE = 0x08,
+ MLX4_OPCODE_RDMA_WRITE_IMM = 0x09,
+ MLX4_OPCODE_SEND = 0x0a,
+ MLX4_OPCODE_SEND_IMM = 0x0b,
+ MLX4_OPCODE_LSO = 0x0e,
+ MLX4_OPCODE_RDMA_READ = 0x10,
+ MLX4_OPCODE_ATOMIC_CS = 0x11,
+ MLX4_OPCODE_ATOMIC_FA = 0x12,
+ MLX4_OPCODE_MASKED_ATOMIC_CS = 0x14,
+ MLX4_OPCODE_MASKED_ATOMIC_FA = 0x15,
+ MLX4_OPCODE_BIND_MW = 0x18,
+ MLX4_OPCODE_FMR = 0x19,
+ MLX4_OPCODE_LOCAL_INVAL = 0x1b,
+ MLX4_OPCODE_CONFIG_CMD = 0x1f,
+
+ MLX4_RECV_OPCODE_RDMA_WRITE_IMM = 0x00,
+ MLX4_RECV_OPCODE_SEND = 0x01,
+ MLX4_RECV_OPCODE_SEND_IMM = 0x02,
+ MLX4_RECV_OPCODE_SEND_INVAL = 0x03,
+
+ MLX4_CQE_OPCODE_ERROR = 0x1e,
+ MLX4_CQE_OPCODE_RESIZE = 0x16,
+};
+
+struct mlx4_device {
+ struct verbs_device verbs_dev;
+ int page_size;
+ int abi_version;
+};
+
+struct mlx4_db_page;
+
+struct mlx4_context {
+ struct ibv_context ibv_ctx;
+
+ void *uar;
+ pthread_spinlock_t uar_lock;
+
+ void *bf_page;
+ int bf_buf_size;
+ int bf_offset;
+ pthread_spinlock_t bf_lock;
+
+ struct {
+ struct mlx4_qp **table;
+ int refcnt;
+ } qp_table[MLX4_QP_TABLE_SIZE];
+ pthread_mutex_t qp_table_mutex;
+ int num_qps;
+ int qp_table_shift;
+ int qp_table_mask;
+ int max_qp_wr;
+ int max_sge;
+
+ struct mlx4_db_page *db_list[MLX4_NUM_DB_TYPE];
+ pthread_mutex_t db_list_mutex;
+ int cqe_size;
+ struct mlx4_xsrq_table xsrq_table;
+ struct {
+ uint8_t valid;
+ uint8_t link_layer;
+ enum ibv_port_cap_flags caps;
+ } port_query_cache[MLX4_PORTS_NUM];
+ struct {
+ uint64_t offset;
+ uint8_t offset_valid;
+ } core_clock;
+ void *hca_core_clock;
+};
+
+struct mlx4_buf {
+ void *buf;
+ size_t length;
+};
+
+struct mlx4_pd {
+ struct ibv_pd ibv_pd;
+ uint32_t pdn;
+};
+
+enum {
+ MLX4_CQ_FLAGS_RX_CSUM_VALID = 1 << 0,
+ MLX4_CQ_FLAGS_EXTENDED = 1 << 1,
+ MLX4_CQ_FLAGS_SINGLE_THREADED = 1 << 2,
+};
+
+struct mlx4_cq {
+ struct ibv_cq_ex ibv_cq;
+ struct mlx4_buf buf;
+ struct mlx4_buf resize_buf;
+ pthread_spinlock_t lock;
+ uint32_t cqn;
+ uint32_t cons_index;
+ uint32_t *set_ci_db;
+ uint32_t *arm_db;
+ int arm_sn;
+ int cqe_size;
+ struct mlx4_qp *cur_qp;
+ struct mlx4_cqe *cqe;
+ uint32_t flags;
+};
+
+struct mlx4_srq {
+ struct verbs_srq verbs_srq;
+ struct mlx4_buf buf;
+ pthread_spinlock_t lock;
+ uint64_t *wrid;
+ uint32_t srqn;
+ int max;
+ int max_gs;
+ int wqe_shift;
+ int head;
+ int tail;
+ uint32_t *db;
+ uint16_t counter;
+ uint8_t ext_srq;
+};
+
+struct mlx4_wq {
+ uint64_t *wrid;
+ pthread_spinlock_t lock;
+ int wqe_cnt;
+ int max_post;
+ unsigned head;
+ unsigned tail;
+ int max_gs;
+ int wqe_shift;
+ int offset;
+};
+
+struct mlx4_qp {
+ struct verbs_qp verbs_qp;
+ struct mlx4_buf buf;
+ int max_inline_data;
+ int buf_size;
+
+ uint32_t doorbell_qpn;
+ uint32_t sq_signal_bits;
+ int sq_spare_wqes;
+ struct mlx4_wq sq;
+
+ uint32_t *db;
+ struct mlx4_wq rq;
+
+ uint8_t link_layer;
+ uint32_t qp_cap_cache;
+};
+
+struct mlx4_av {
+ uint32_t port_pd;
+ uint8_t reserved1;
+ uint8_t g_slid;
+ uint16_t dlid;
+ uint8_t reserved2;
+ uint8_t gid_index;
+ uint8_t stat_rate;
+ uint8_t hop_limit;
+ uint32_t sl_tclass_flowlabel;
+ uint8_t dgid[16];
+};
+
+struct mlx4_ah {
+ struct ibv_ah ibv_ah;
+ struct mlx4_av av;
+ uint16_t vlan;
+ uint8_t mac[6];
+};
+
+enum {
+ MLX4_CSUM_SUPPORT_UD_OVER_IB = (1 << 0),
+ MLX4_CSUM_SUPPORT_RAW_OVER_ETH = (1 << 1),
+ /* Only report rx checksum when the validation is valid */
+ MLX4_RX_CSUM_VALID = (1 << 16),
+};
+
+enum mlx4_cqe_status {
+ MLX4_CQE_STATUS_TCP_UDP_CSUM_OK = (1 << 2),
+ MLX4_CQE_STATUS_IPV4_PKT = (1 << 22),
+ MLX4_CQE_STATUS_IP_HDR_CSUM_OK = (1 << 28),
+ MLX4_CQE_STATUS_IPV4_CSUM_OK = MLX4_CQE_STATUS_IPV4_PKT |
+ MLX4_CQE_STATUS_IP_HDR_CSUM_OK |
+ MLX4_CQE_STATUS_TCP_UDP_CSUM_OK
+};
+
+struct mlx4_cqe {
+ uint32_t vlan_my_qpn;
+ uint32_t immed_rss_invalid;
+ uint32_t g_mlpath_rqpn;
+ union {
+ struct {
+ uint16_t sl_vid;
+ uint16_t rlid;
+ };
+ uint32_t ts_47_16;
+ };
+ uint32_t status;
+ uint32_t byte_cnt;
+ uint16_t wqe_index;
+ uint16_t checksum;
+ uint8_t reserved3;
+ uint8_t ts_15_8;
+ uint8_t ts_7_0;
+ uint8_t owner_sr_opcode;
+};
+
+static inline unsigned long align(unsigned long val, unsigned long align)
+{
+ return (val + align - 1) & ~(align - 1);
+}
+int align_queue_size(int req);
+
+#define to_mxxx(xxx, type) \
+ ((struct mlx4_##type *) \
+ ((void *) ib##xxx - offsetof(struct mlx4_##type, ibv_##xxx)))
+
+static inline struct mlx4_device *to_mdev(struct ibv_device *ibdev)
+{
+ /* ibv_device is first field of verbs_device
+ * see try_driver() in libibverbs.
+ */
+ return container_of(ibdev, struct mlx4_device, verbs_dev);
+}
+
+static inline struct mlx4_context *to_mctx(struct ibv_context *ibctx)
+{
+ return to_mxxx(ctx, context);
+}
+
+static inline struct mlx4_pd *to_mpd(struct ibv_pd *ibpd)
+{
+ return to_mxxx(pd, pd);
+}
+
+static inline struct mlx4_cq *to_mcq(struct ibv_cq *ibcq)
+{
+ return to_mxxx(cq, cq);
+}
+
+static inline struct mlx4_srq *to_msrq(struct ibv_srq *ibsrq)
+{
+ return container_of(container_of(ibsrq, struct verbs_srq, srq),
+ struct mlx4_srq, verbs_srq);
+}
+
+static inline struct mlx4_qp *to_mqp(struct ibv_qp *ibqp)
+{
+ return container_of(container_of(ibqp, struct verbs_qp, qp),
+ struct mlx4_qp, verbs_qp);
+}
+
+static inline struct mlx4_ah *to_mah(struct ibv_ah *ibah)
+{
+ return to_mxxx(ah, ah);
+}
+
+static inline void mlx4_update_cons_index(struct mlx4_cq *cq)
+{
+ *cq->set_ci_db = htobe32(cq->cons_index & 0xffffff);
+}
+
+int mlx4_alloc_buf(struct mlx4_buf *buf, size_t size, int page_size);
+void mlx4_free_buf(struct mlx4_buf *buf);
+
+uint32_t *mlx4_alloc_db(struct mlx4_context *context, enum mlx4_db_type type);
+void mlx4_free_db(struct mlx4_context *context, enum mlx4_db_type type, uint32_t *db);
+
+int mlx4_query_device(struct ibv_context *context,
+ struct ibv_device_attr *attr);
+int mlx4_query_device_ex(struct ibv_context *context,
+ const struct ibv_query_device_ex_input *input,
+ struct ibv_device_attr_ex *attr,
+ size_t attr_size);
+int mlx4_query_port(struct ibv_context *context, uint8_t port,
+ struct ibv_port_attr *attr);
+int mlx4_query_rt_values(struct ibv_context *context,
+ struct ibv_values_ex *values);
+struct ibv_pd *mlx4_alloc_pd(struct ibv_context *context);
+int mlx4_free_pd(struct ibv_pd *pd);
+struct ibv_xrcd *mlx4_open_xrcd(struct ibv_context *context,
+ struct ibv_xrcd_init_attr *attr);
+int mlx4_close_xrcd(struct ibv_xrcd *xrcd);
+
+struct ibv_mr *mlx4_reg_mr(struct ibv_pd *pd, void *addr,
+ size_t length, int access);
+int mlx4_rereg_mr(struct ibv_mr *mr, int flags, struct ibv_pd *pd,
+ void *addr, size_t length, int access);
+int mlx4_dereg_mr(struct ibv_mr *mr);
+
+struct ibv_mw *mlx4_alloc_mw(struct ibv_pd *pd, enum ibv_mw_type type);
+int mlx4_dealloc_mw(struct ibv_mw *mw);
+int mlx4_bind_mw(struct ibv_qp *qp, struct ibv_mw *mw,
+ struct ibv_mw_bind *mw_bind);
+
+struct ibv_cq *mlx4_create_cq(struct ibv_context *context, int cqe,
+ struct ibv_comp_channel *channel,
+ int comp_vector);
+struct ibv_cq_ex *mlx4_create_cq_ex(struct ibv_context *context,
+ struct ibv_cq_init_attr_ex *cq_attr);
+void mlx4_cq_fill_pfns(struct mlx4_cq *cq, const struct ibv_cq_init_attr_ex *cq_attr);
+int mlx4_alloc_cq_buf(struct mlx4_device *dev, struct mlx4_buf *buf, int nent,
+ int entry_size);
+int mlx4_resize_cq(struct ibv_cq *cq, int cqe);
+int mlx4_destroy_cq(struct ibv_cq *cq);
+int mlx4_poll_cq(struct ibv_cq *cq, int ne, struct ibv_wc *wc);
+int mlx4_arm_cq(struct ibv_cq *cq, int solicited);
+void mlx4_cq_event(struct ibv_cq *cq);
+void __mlx4_cq_clean(struct mlx4_cq *cq, uint32_t qpn, struct mlx4_srq *srq);
+void mlx4_cq_clean(struct mlx4_cq *cq, uint32_t qpn, struct mlx4_srq *srq);
+int mlx4_get_outstanding_cqes(struct mlx4_cq *cq);
+void mlx4_cq_resize_copy_cqes(struct mlx4_cq *cq, void *buf, int new_cqe);
+
+struct ibv_srq *mlx4_create_srq(struct ibv_pd *pd,
+ struct ibv_srq_init_attr *attr);
+struct ibv_srq *mlx4_create_srq_ex(struct ibv_context *context,
+ struct ibv_srq_init_attr_ex *attr_ex);
+struct ibv_srq *mlx4_create_xrc_srq(struct ibv_context *context,
+ struct ibv_srq_init_attr_ex *attr_ex);
+int mlx4_modify_srq(struct ibv_srq *srq,
+ struct ibv_srq_attr *attr,
+ int mask);
+int mlx4_query_srq(struct ibv_srq *srq,
+ struct ibv_srq_attr *attr);
+int mlx4_destroy_srq(struct ibv_srq *srq);
+int mlx4_destroy_xrc_srq(struct ibv_srq *srq);
+int mlx4_alloc_srq_buf(struct ibv_pd *pd, struct ibv_srq_attr *attr,
+ struct mlx4_srq *srq);
+void mlx4_init_xsrq_table(struct mlx4_xsrq_table *xsrq_table, int size);
+struct mlx4_srq *mlx4_find_xsrq(struct mlx4_xsrq_table *xsrq_table, uint32_t srqn);
+int mlx4_store_xsrq(struct mlx4_xsrq_table *xsrq_table, uint32_t srqn,
+ struct mlx4_srq *srq);
+void mlx4_clear_xsrq(struct mlx4_xsrq_table *xsrq_table, uint32_t srqn);
+void mlx4_free_srq_wqe(struct mlx4_srq *srq, int ind);
+int mlx4_post_srq_recv(struct ibv_srq *ibsrq,
+ struct ibv_recv_wr *wr,
+ struct ibv_recv_wr **bad_wr);
+
+struct ibv_qp *mlx4_create_qp(struct ibv_pd *pd, struct ibv_qp_init_attr *attr);
+struct ibv_qp *mlx4_create_qp_ex(struct ibv_context *context,
+ struct ibv_qp_init_attr_ex *attr);
+struct ibv_qp *mlx4_open_qp(struct ibv_context *context, struct ibv_qp_open_attr *attr);
+int mlx4_query_qp(struct ibv_qp *qp, struct ibv_qp_attr *attr,
+ int attr_mask,
+ struct ibv_qp_init_attr *init_attr);
+int mlx4_modify_qp(struct ibv_qp *qp, struct ibv_qp_attr *attr,
+ int attr_mask);
+int mlx4_destroy_qp(struct ibv_qp *qp);
+void mlx4_init_qp_indices(struct mlx4_qp *qp);
+void mlx4_qp_init_sq_ownership(struct mlx4_qp *qp);
+int mlx4_post_send(struct ibv_qp *ibqp, struct ibv_send_wr *wr,
+ struct ibv_send_wr **bad_wr);
+int mlx4_post_recv(struct ibv_qp *ibqp, struct ibv_recv_wr *wr,
+ struct ibv_recv_wr **bad_wr);
+void mlx4_calc_sq_wqe_size(struct ibv_qp_cap *cap, enum ibv_qp_type type,
+ struct mlx4_qp *qp);
+int mlx4_alloc_qp_buf(struct ibv_context *context, struct ibv_qp_cap *cap,
+ enum ibv_qp_type type, struct mlx4_qp *qp);
+void mlx4_set_sq_sizes(struct mlx4_qp *qp, struct ibv_qp_cap *cap,
+ enum ibv_qp_type type);
+struct mlx4_qp *mlx4_find_qp(struct mlx4_context *ctx, uint32_t qpn);
+int mlx4_store_qp(struct mlx4_context *ctx, uint32_t qpn, struct mlx4_qp *qp);
+void mlx4_clear_qp(struct mlx4_context *ctx, uint32_t qpn);
+struct ibv_ah *mlx4_create_ah(struct ibv_pd *pd, struct ibv_ah_attr *attr);
+int mlx4_destroy_ah(struct ibv_ah *ah);
+int mlx4_alloc_av(struct mlx4_pd *pd, struct ibv_ah_attr *attr,
+ struct mlx4_ah *ah);
+void mlx4_free_av(struct mlx4_ah *ah);
+
+#endif /* MLX4_H */
diff --git a/contrib/ofed/libmlx4/mmio.h b/contrib/ofed/libmlx4/mmio.h
new file mode 100644
index 0000000..a1a2966
--- /dev/null
+++ b/contrib/ofed/libmlx4/mmio.h
@@ -0,0 +1,116 @@
+/* Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md
+ */
+#ifndef MMIO_H
+#define MMIO_H
+
+#include <unistd.h>
+#include <sys/syscall.h>
+#ifdef __s390x__
+
+static inline long mmio_writeb(const unsigned long mmio_addr,
+ const uint8_t val)
+{
+ return syscall(__NR_s390_pci_mmio_write, mmio_addr, &val, sizeof(val));
+}
+
+static inline long mmio_writew(const unsigned long mmio_addr,
+ const uint16_t val)
+{
+ return syscall(__NR_s390_pci_mmio_write, mmio_addr, &val, sizeof(val));
+}
+
+static inline long mmio_writel(const unsigned long mmio_addr,
+ const uint32_t val)
+{
+ return syscall(__NR_s390_pci_mmio_write, mmio_addr, &val, sizeof(val));
+}
+
+static inline long mmio_writeq(const unsigned long mmio_addr,
+ const uint64_t val)
+{
+ return syscall(__NR_s390_pci_mmio_write, mmio_addr, &val, sizeof(val));
+}
+
+static inline long mmio_write(const unsigned long mmio_addr,
+ const void *val,
+ const size_t length)
+{
+ return syscall(__NR_s390_pci_mmio_write, mmio_addr, val, length);
+}
+
+static inline long mmio_readb(const unsigned long mmio_addr, uint8_t *val)
+{
+ return syscall(__NR_s390_pci_mmio_read, mmio_addr, val, sizeof(*val));
+}
+
+static inline long mmio_readw(const unsigned long mmio_addr, uint16_t *val)
+{
+ return syscall(__NR_s390_pci_mmio_read, mmio_addr, val, sizeof(*val));
+}
+
+static inline long mmio_readl(const unsigned long mmio_addr, uint32_t *val)
+{
+ return syscall(__NR_s390_pci_mmio_read, mmio_addr, val, sizeof(*val));
+}
+
+static inline long mmio_readq(const unsigned long mmio_addr, uint64_t *val)
+{
+ return syscall(__NR_s390_pci_mmio_read, mmio_addr, val, sizeof(*val));
+}
+
+static inline long mmio_read(const unsigned long mmio_addr,
+ void *val,
+ const size_t length)
+{
+ return syscall(__NR_s390_pci_mmio_read, mmio_addr, val, length);
+}
+
+static inline void mlx4_bf_copy(unsigned long *dst,
+ unsigned long *src,
+ unsigned bytecnt)
+{
+ mmio_write((unsigned long)dst, src, bytecnt);
+}
+
+#else
+
+#define mmio_writeb(addr, value) \
+ (*((volatile uint8_t *)addr) = value)
+#define mmio_writew(addr, value) \
+ (*((volatile uint16_t *)addr) = value)
+#define mmio_writel(addr, value) \
+ (*((volatile uint32_t *)addr) = value)
+#define mmio_writeq(addr, value) \
+ (*((volatile uint64_t *)addr) = value)
+#define mmio_write(addr, value, length) \
+ memcpy(addr, value, length)
+
+#define mmio_readb(addr, value) \
+ (value = *((volatile uint8_t *)addr))
+#define mmio_readw(addr, value) \
+ (value = *((volatile uint16_t *)addr))
+#define mmio_readl(addr, value) \
+ (value = *((volatile uint32_t *)addr))
+#define mmio_readq(addr, value) \
+ (value = *((volatile uint64_t *)addr))
+#define mmio_read(addr, value, length) \
+ memcpy(value, addr, length)
+
+/*
+ * Avoid using memcpy() to copy to BlueFlame page, since memcpy()
+ * implementations may use move-string-buffer assembler instructions,
+ * which do not guarantee order of copying.
+ */
+static inline void mlx4_bf_copy(unsigned long *dst,
+ unsigned long *src,
+ unsigned bytecnt)
+{
+ while (bytecnt > 0) {
+ *dst++ = *src++;
+ *dst++ = *src++;
+ bytecnt -= 2 * sizeof(long);
+ }
+}
+#endif
+
+#endif
diff --git a/contrib/ofed/libmlx4/qp.c b/contrib/ofed/libmlx4/qp.c
new file mode 100644
index 0000000..577aab5
--- /dev/null
+++ b/contrib/ofed/libmlx4/qp.c
@@ -0,0 +1,776 @@
+/*
+ * Copyright (c) 2005 Topspin Communications. All rights reserved.
+ * Copyright (c) 2005 Mellanox Technologies Ltd. All rights reserved.
+ * Copyright (c) 2007 Cisco, Inc. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#include <config.h>
+
+#include <stdlib.h>
+#include <pthread.h>
+#include <string.h>
+#include <errno.h>
+
+#include "mlx4.h"
+#include "doorbell.h"
+#include "wqe.h"
+
+static const uint32_t mlx4_ib_opcode[] = {
+ [IBV_WR_SEND] = MLX4_OPCODE_SEND,
+ [IBV_WR_SEND_WITH_IMM] = MLX4_OPCODE_SEND_IMM,
+ [IBV_WR_RDMA_WRITE] = MLX4_OPCODE_RDMA_WRITE,
+ [IBV_WR_RDMA_WRITE_WITH_IMM] = MLX4_OPCODE_RDMA_WRITE_IMM,
+ [IBV_WR_RDMA_READ] = MLX4_OPCODE_RDMA_READ,
+ [IBV_WR_ATOMIC_CMP_AND_SWP] = MLX4_OPCODE_ATOMIC_CS,
+ [IBV_WR_ATOMIC_FETCH_AND_ADD] = MLX4_OPCODE_ATOMIC_FA,
+ [IBV_WR_LOCAL_INV] = MLX4_OPCODE_LOCAL_INVAL,
+ [IBV_WR_BIND_MW] = MLX4_OPCODE_BIND_MW,
+ [IBV_WR_SEND_WITH_INV] = MLX4_OPCODE_SEND_INVAL,
+};
+
+static void *get_recv_wqe(struct mlx4_qp *qp, int n)
+{
+ return qp->buf.buf + qp->rq.offset + (n << qp->rq.wqe_shift);
+}
+
+static void *get_send_wqe(struct mlx4_qp *qp, int n)
+{
+ return qp->buf.buf + qp->sq.offset + (n << qp->sq.wqe_shift);
+}
+
+/*
+ * Stamp a SQ WQE so that it is invalid if prefetched by marking the
+ * first four bytes of every 64 byte chunk with 0xffffffff, except for
+ * the very first chunk of the WQE.
+ */
+static void stamp_send_wqe(struct mlx4_qp *qp, int n)
+{
+ uint32_t *wqe = get_send_wqe(qp, n);
+ int i;
+ int ds = (((struct mlx4_wqe_ctrl_seg *)wqe)->fence_size & 0x3f) << 2;
+
+ for (i = 16; i < ds; i += 16)
+ wqe[i] = 0xffffffff;
+}
+
+void mlx4_init_qp_indices(struct mlx4_qp *qp)
+{
+ qp->sq.head = 0;
+ qp->sq.tail = 0;
+ qp->rq.head = 0;
+ qp->rq.tail = 0;
+}
+
+void mlx4_qp_init_sq_ownership(struct mlx4_qp *qp)
+{
+ struct mlx4_wqe_ctrl_seg *ctrl;
+ int i;
+
+ for (i = 0; i < qp->sq.wqe_cnt; ++i) {
+ ctrl = get_send_wqe(qp, i);
+ ctrl->owner_opcode = htobe32(1 << 31);
+ ctrl->fence_size = 1 << (qp->sq.wqe_shift - 4);
+
+ stamp_send_wqe(qp, i);
+ }
+}
+
+static int wq_overflow(struct mlx4_wq *wq, int nreq, struct mlx4_cq *cq)
+{
+ unsigned cur;
+
+ cur = wq->head - wq->tail;
+ if (cur + nreq < wq->max_post)
+ return 0;
+
+ pthread_spin_lock(&cq->lock);
+ cur = wq->head - wq->tail;
+ pthread_spin_unlock(&cq->lock);
+
+ return cur + nreq >= wq->max_post;
+}
+
+static void set_bind_seg(struct mlx4_wqe_bind_seg *bseg, struct ibv_send_wr *wr)
+{
+ int acc = wr->bind_mw.bind_info.mw_access_flags;
+ bseg->flags1 = 0;
+ if (acc & IBV_ACCESS_REMOTE_ATOMIC)
+ bseg->flags1 |= htobe32(MLX4_WQE_MW_ATOMIC);
+ if (acc & IBV_ACCESS_REMOTE_WRITE)
+ bseg->flags1 |= htobe32(MLX4_WQE_MW_REMOTE_WRITE);
+ if (acc & IBV_ACCESS_REMOTE_READ)
+ bseg->flags1 |= htobe32(MLX4_WQE_MW_REMOTE_READ);
+
+ bseg->flags2 = 0;
+ if (((struct ibv_mw *)(wr->bind_mw.mw))->type == IBV_MW_TYPE_2)
+ bseg->flags2 |= htobe32(MLX4_WQE_BIND_TYPE_2);
+ if (acc & IBV_ACCESS_ZERO_BASED)
+ bseg->flags2 |= htobe32(MLX4_WQE_BIND_ZERO_BASED);
+
+ bseg->new_rkey = htobe32(wr->bind_mw.rkey);
+ bseg->lkey = htobe32(wr->bind_mw.bind_info.mr->lkey);
+ bseg->addr = htobe64((uint64_t) wr->bind_mw.bind_info.addr);
+ bseg->length = htobe64(wr->bind_mw.bind_info.length);
+}
+
+static inline void set_local_inv_seg(struct mlx4_wqe_local_inval_seg *iseg,
+ uint32_t rkey)
+{
+ iseg->mem_key = htobe32(rkey);
+
+ iseg->reserved1 = 0;
+ iseg->reserved2 = 0;
+ iseg->reserved3[0] = 0;
+ iseg->reserved3[1] = 0;
+}
+
+static inline void set_raddr_seg(struct mlx4_wqe_raddr_seg *rseg,
+ uint64_t remote_addr, uint32_t rkey)
+{
+ rseg->raddr = htobe64(remote_addr);
+ rseg->rkey = htobe32(rkey);
+ rseg->reserved = 0;
+}
+
+static void set_atomic_seg(struct mlx4_wqe_atomic_seg *aseg, struct ibv_send_wr *wr)
+{
+ if (wr->opcode == IBV_WR_ATOMIC_CMP_AND_SWP) {
+ aseg->swap_add = htobe64(wr->wr.atomic.swap);
+ aseg->compare = htobe64(wr->wr.atomic.compare_add);
+ } else {
+ aseg->swap_add = htobe64(wr->wr.atomic.compare_add);
+ aseg->compare = 0;
+ }
+
+}
+
+static void set_datagram_seg(struct mlx4_wqe_datagram_seg *dseg,
+ struct ibv_send_wr *wr)
+{
+ memcpy(dseg->av, &to_mah(wr->wr.ud.ah)->av, sizeof (struct mlx4_av));
+ dseg->dqpn = htobe32(wr->wr.ud.remote_qpn);
+ dseg->qkey = htobe32(wr->wr.ud.remote_qkey);
+ dseg->vlan = htobe16(to_mah(wr->wr.ud.ah)->vlan);
+ memcpy(dseg->mac, to_mah(wr->wr.ud.ah)->mac, 6);
+}
+
+static void __set_data_seg(struct mlx4_wqe_data_seg *dseg, struct ibv_sge *sg)
+{
+ dseg->byte_count = htobe32(sg->length);
+ dseg->lkey = htobe32(sg->lkey);
+ dseg->addr = htobe64(sg->addr);
+}
+
+static void set_data_seg(struct mlx4_wqe_data_seg *dseg, struct ibv_sge *sg)
+{
+ dseg->lkey = htobe32(sg->lkey);
+ dseg->addr = htobe64(sg->addr);
+
+ /*
+ * Need a barrier here before writing the byte_count field to
+ * make sure that all the data is visible before the
+ * byte_count field is set. Otherwise, if the segment begins
+ * a new cacheline, the HCA prefetcher could grab the 64-byte
+ * chunk and get a valid (!= * 0xffffffff) byte count but
+ * stale data, and end up sending the wrong data.
+ */
+ udma_to_device_barrier();
+
+ if (likely(sg->length))
+ dseg->byte_count = htobe32(sg->length);
+ else
+ dseg->byte_count = htobe32(0x80000000);
+}
+
+int mlx4_post_send(struct ibv_qp *ibqp, struct ibv_send_wr *wr,
+ struct ibv_send_wr **bad_wr)
+{
+ struct mlx4_context *ctx;
+ struct mlx4_qp *qp = to_mqp(ibqp);
+ void *wqe;
+ struct mlx4_wqe_ctrl_seg *ctrl = NULL;
+ int ind;
+ int nreq;
+ int inl = 0;
+ int ret = 0;
+ int size = 0;
+ int i;
+
+ pthread_spin_lock(&qp->sq.lock);
+
+ /* XXX check that state is OK to post send */
+
+ ind = qp->sq.head;
+
+ for (nreq = 0; wr; ++nreq, wr = wr->next) {
+ if (wq_overflow(&qp->sq, nreq, to_mcq(ibqp->send_cq))) {
+ ret = ENOMEM;
+ *bad_wr = wr;
+ goto out;
+ }
+
+ if (wr->num_sge > qp->sq.max_gs) {
+ ret = ENOMEM;
+ *bad_wr = wr;
+ goto out;
+ }
+
+ if (wr->opcode >= sizeof mlx4_ib_opcode / sizeof mlx4_ib_opcode[0]) {
+ ret = EINVAL;
+ *bad_wr = wr;
+ goto out;
+ }
+
+ ctrl = wqe = get_send_wqe(qp, ind & (qp->sq.wqe_cnt - 1));
+ qp->sq.wrid[ind & (qp->sq.wqe_cnt - 1)] = wr->wr_id;
+
+ ctrl->srcrb_flags =
+ (wr->send_flags & IBV_SEND_SIGNALED ?
+ htobe32(MLX4_WQE_CTRL_CQ_UPDATE) : 0) |
+ (wr->send_flags & IBV_SEND_SOLICITED ?
+ htobe32(MLX4_WQE_CTRL_SOLICIT) : 0) |
+ qp->sq_signal_bits;
+
+ if (wr->opcode == IBV_WR_SEND_WITH_IMM ||
+ wr->opcode == IBV_WR_RDMA_WRITE_WITH_IMM)
+ ctrl->imm = wr->imm_data;
+ else
+ ctrl->imm = 0;
+
+ wqe += sizeof *ctrl;
+ size = sizeof *ctrl / 16;
+
+ switch (ibqp->qp_type) {
+ case IBV_QPT_XRC_SEND:
+ ctrl->srcrb_flags |= MLX4_REMOTE_SRQN_FLAGS(wr);
+ /* fall through */
+ case IBV_QPT_RC:
+ case IBV_QPT_UC:
+ switch (wr->opcode) {
+ case IBV_WR_ATOMIC_CMP_AND_SWP:
+ case IBV_WR_ATOMIC_FETCH_AND_ADD:
+ set_raddr_seg(wqe, wr->wr.atomic.remote_addr,
+ wr->wr.atomic.rkey);
+ wqe += sizeof (struct mlx4_wqe_raddr_seg);
+
+ set_atomic_seg(wqe, wr);
+ wqe += sizeof (struct mlx4_wqe_atomic_seg);
+ size += (sizeof (struct mlx4_wqe_raddr_seg) +
+ sizeof (struct mlx4_wqe_atomic_seg)) / 16;
+
+ break;
+
+ case IBV_WR_RDMA_READ:
+ inl = 1;
+ /* fall through */
+ case IBV_WR_RDMA_WRITE:
+ case IBV_WR_RDMA_WRITE_WITH_IMM:
+ if (!wr->num_sge)
+ inl = 1;
+ set_raddr_seg(wqe, wr->wr.rdma.remote_addr,
+ wr->wr.rdma.rkey);
+ wqe += sizeof (struct mlx4_wqe_raddr_seg);
+ size += sizeof (struct mlx4_wqe_raddr_seg) / 16;
+
+ break;
+ case IBV_WR_LOCAL_INV:
+ ctrl->srcrb_flags |=
+ htobe32(MLX4_WQE_CTRL_STRONG_ORDER);
+ set_local_inv_seg(wqe, wr->imm_data);
+ wqe += sizeof
+ (struct mlx4_wqe_local_inval_seg);
+ size += sizeof
+ (struct mlx4_wqe_local_inval_seg) / 16;
+ break;
+ case IBV_WR_BIND_MW:
+ ctrl->srcrb_flags |=
+ htobe32(MLX4_WQE_CTRL_STRONG_ORDER);
+ set_bind_seg(wqe, wr);
+ wqe += sizeof
+ (struct mlx4_wqe_bind_seg);
+ size += sizeof
+ (struct mlx4_wqe_bind_seg) / 16;
+ break;
+ case IBV_WR_SEND_WITH_INV:
+ ctrl->imm = htobe32(wr->imm_data);
+ break;
+
+ default:
+ /* No extra segments required for sends */
+ break;
+ }
+ break;
+
+ case IBV_QPT_UD:
+ set_datagram_seg(wqe, wr);
+ wqe += sizeof (struct mlx4_wqe_datagram_seg);
+ size += sizeof (struct mlx4_wqe_datagram_seg) / 16;
+
+ if (wr->send_flags & IBV_SEND_IP_CSUM) {
+ if (!(qp->qp_cap_cache & MLX4_CSUM_SUPPORT_UD_OVER_IB)) {
+ ret = EINVAL;
+ *bad_wr = wr;
+ goto out;
+ }
+ ctrl->srcrb_flags |= htobe32(MLX4_WQE_CTRL_IP_HDR_CSUM |
+ MLX4_WQE_CTRL_TCP_UDP_CSUM);
+ }
+ break;
+
+ case IBV_QPT_RAW_PACKET:
+ /* For raw eth, the MLX4_WQE_CTRL_SOLICIT flag is used
+ * to indicate that no icrc should be calculated */
+ ctrl->srcrb_flags |= htobe32(MLX4_WQE_CTRL_SOLICIT);
+ if (wr->send_flags & IBV_SEND_IP_CSUM) {
+ if (!(qp->qp_cap_cache & MLX4_CSUM_SUPPORT_RAW_OVER_ETH)) {
+ ret = EINVAL;
+ *bad_wr = wr;
+ goto out;
+ }
+ ctrl->srcrb_flags |= htobe32(MLX4_WQE_CTRL_IP_HDR_CSUM |
+ MLX4_WQE_CTRL_TCP_UDP_CSUM);
+ }
+ break;
+
+ default:
+ break;
+ }
+
+ if (wr->send_flags & IBV_SEND_INLINE && wr->num_sge) {
+ struct mlx4_wqe_inline_seg *seg;
+ void *addr;
+ int len, seg_len;
+ int num_seg;
+ int off, to_copy;
+
+ inl = 0;
+
+ seg = wqe;
+ wqe += sizeof *seg;
+ off = ((uintptr_t) wqe) & (MLX4_INLINE_ALIGN - 1);
+ num_seg = 0;
+ seg_len = 0;
+
+ for (i = 0; i < wr->num_sge; ++i) {
+ addr = (void *) (uintptr_t) wr->sg_list[i].addr;
+ len = wr->sg_list[i].length;
+ inl += len;
+
+ if (inl > qp->max_inline_data) {
+ inl = 0;
+ ret = ENOMEM;
+ *bad_wr = wr;
+ goto out;
+ }
+
+ while (len >= MLX4_INLINE_ALIGN - off) {
+ to_copy = MLX4_INLINE_ALIGN - off;
+ memcpy(wqe, addr, to_copy);
+ len -= to_copy;
+ wqe += to_copy;
+ addr += to_copy;
+ seg_len += to_copy;
+ udma_to_device_barrier(); /* see comment below */
+ seg->byte_count = htobe32(MLX4_INLINE_SEG | seg_len);
+ seg_len = 0;
+ seg = wqe;
+ wqe += sizeof *seg;
+ off = sizeof *seg;
+ ++num_seg;
+ }
+
+ memcpy(wqe, addr, len);
+ wqe += len;
+ seg_len += len;
+ off += len;
+ }
+
+ if (seg_len) {
+ ++num_seg;
+ /*
+ * Need a barrier here to make sure
+ * all the data is visible before the
+ * byte_count field is set. Otherwise
+ * the HCA prefetcher could grab the
+ * 64-byte chunk with this inline
+ * segment and get a valid (!=
+ * 0xffffffff) byte count but stale
+ * data, and end up sending the wrong
+ * data.
+ */
+ udma_to_device_barrier();
+ seg->byte_count = htobe32(MLX4_INLINE_SEG | seg_len);
+ }
+
+ size += (inl + num_seg * sizeof * seg + 15) / 16;
+ } else {
+ struct mlx4_wqe_data_seg *seg = wqe;
+
+ for (i = wr->num_sge - 1; i >= 0 ; --i)
+ set_data_seg(seg + i, wr->sg_list + i);
+
+ size += wr->num_sge * (sizeof *seg / 16);
+ }
+
+ ctrl->fence_size = (wr->send_flags & IBV_SEND_FENCE ?
+ MLX4_WQE_CTRL_FENCE : 0) | size;
+
+ /*
+ * Make sure descriptor is fully written before
+ * setting ownership bit (because HW can start
+ * executing as soon as we do).
+ */
+ udma_to_device_barrier();
+
+ ctrl->owner_opcode = htobe32(mlx4_ib_opcode[wr->opcode]) |
+ (ind & qp->sq.wqe_cnt ? htobe32(1 << 31) : 0);
+
+ /*
+ * We can improve latency by not stamping the last
+ * send queue WQE until after ringing the doorbell, so
+ * only stamp here if there are still more WQEs to post.
+ */
+ if (wr->next)
+ stamp_send_wqe(qp, (ind + qp->sq_spare_wqes) &
+ (qp->sq.wqe_cnt - 1));
+
+ ++ind;
+ }
+
+out:
+ ctx = to_mctx(ibqp->context);
+
+ if (nreq == 1 && inl && size > 1 && size <= ctx->bf_buf_size / 16) {
+ ctrl->owner_opcode |= htobe32((qp->sq.head & 0xffff) << 8);
+
+ ctrl->bf_qpn |= qp->doorbell_qpn;
+ ++qp->sq.head;
+ /*
+ * Make sure that descriptor is written to memory
+ * before writing to BlueFlame page.
+ */
+ mmio_wc_spinlock(&ctx->bf_lock);
+
+ mlx4_bf_copy(ctx->bf_page + ctx->bf_offset, (unsigned long *) ctrl,
+ align(size * 16, 64));
+ /* Flush before toggling bf_offset to be latency oriented */
+ mmio_flush_writes();
+
+ ctx->bf_offset ^= ctx->bf_buf_size;
+
+ pthread_spin_unlock(&ctx->bf_lock);
+ } else if (nreq) {
+ qp->sq.head += nreq;
+
+ /*
+ * Make sure that descriptors are written before
+ * doorbell record.
+ */
+ udma_to_device_barrier();
+
+ mmio_writel((unsigned long)(ctx->uar + MLX4_SEND_DOORBELL),
+ qp->doorbell_qpn);
+ }
+
+ if (nreq)
+ stamp_send_wqe(qp, (ind + qp->sq_spare_wqes - 1) &
+ (qp->sq.wqe_cnt - 1));
+
+ pthread_spin_unlock(&qp->sq.lock);
+
+ return ret;
+}
+
+int mlx4_post_recv(struct ibv_qp *ibqp, struct ibv_recv_wr *wr,
+ struct ibv_recv_wr **bad_wr)
+{
+ struct mlx4_qp *qp = to_mqp(ibqp);
+ struct mlx4_wqe_data_seg *scat;
+ int ret = 0;
+ int nreq;
+ int ind;
+ int i;
+
+ pthread_spin_lock(&qp->rq.lock);
+
+ /* XXX check that state is OK to post receive */
+
+ ind = qp->rq.head & (qp->rq.wqe_cnt - 1);
+
+ for (nreq = 0; wr; ++nreq, wr = wr->next) {
+ if (wq_overflow(&qp->rq, nreq, to_mcq(ibqp->recv_cq))) {
+ ret = ENOMEM;
+ *bad_wr = wr;
+ goto out;
+ }
+
+ if (wr->num_sge > qp->rq.max_gs) {
+ ret = ENOMEM;
+ *bad_wr = wr;
+ goto out;
+ }
+
+ scat = get_recv_wqe(qp, ind);
+
+ for (i = 0; i < wr->num_sge; ++i)
+ __set_data_seg(scat + i, wr->sg_list + i);
+
+ if (i < qp->rq.max_gs) {
+ scat[i].byte_count = 0;
+ scat[i].lkey = htobe32(MLX4_INVALID_LKEY);
+ scat[i].addr = 0;
+ }
+
+ qp->rq.wrid[ind] = wr->wr_id;
+
+ ind = (ind + 1) & (qp->rq.wqe_cnt - 1);
+ }
+
+out:
+ if (nreq) {
+ qp->rq.head += nreq;
+
+ /*
+ * Make sure that descriptors are written before
+ * doorbell record.
+ */
+ udma_to_device_barrier();
+
+ *qp->db = htobe32(qp->rq.head & 0xffff);
+ }
+
+ pthread_spin_unlock(&qp->rq.lock);
+
+ return ret;
+}
+
+static int num_inline_segs(int data, enum ibv_qp_type type)
+{
+ /*
+ * Inline data segments are not allowed to cross 64 byte
+ * boundaries. For UD QPs, the data segments always start
+ * aligned to 64 bytes (16 byte control segment + 48 byte
+ * datagram segment); for other QPs, there will be a 16 byte
+ * control segment and possibly a 16 byte remote address
+ * segment, so in the worst case there will be only 32 bytes
+ * available for the first data segment.
+ */
+ if (type == IBV_QPT_UD)
+ data += (sizeof (struct mlx4_wqe_ctrl_seg) +
+ sizeof (struct mlx4_wqe_datagram_seg)) %
+ MLX4_INLINE_ALIGN;
+ else
+ data += (sizeof (struct mlx4_wqe_ctrl_seg) +
+ sizeof (struct mlx4_wqe_raddr_seg)) %
+ MLX4_INLINE_ALIGN;
+
+ return (data + MLX4_INLINE_ALIGN - sizeof (struct mlx4_wqe_inline_seg) - 1) /
+ (MLX4_INLINE_ALIGN - sizeof (struct mlx4_wqe_inline_seg));
+}
+
+void mlx4_calc_sq_wqe_size(struct ibv_qp_cap *cap, enum ibv_qp_type type,
+ struct mlx4_qp *qp)
+{
+ int size;
+ int max_sq_sge;
+
+ max_sq_sge = align(cap->max_inline_data +
+ num_inline_segs(cap->max_inline_data, type) *
+ sizeof (struct mlx4_wqe_inline_seg),
+ sizeof (struct mlx4_wqe_data_seg)) /
+ sizeof (struct mlx4_wqe_data_seg);
+ if (max_sq_sge < cap->max_send_sge)
+ max_sq_sge = cap->max_send_sge;
+
+ size = max_sq_sge * sizeof (struct mlx4_wqe_data_seg);
+ switch (type) {
+ case IBV_QPT_UD:
+ size += sizeof (struct mlx4_wqe_datagram_seg);
+ break;
+
+ case IBV_QPT_UC:
+ size += sizeof (struct mlx4_wqe_raddr_seg);
+ break;
+
+ case IBV_QPT_XRC_SEND:
+ case IBV_QPT_RC:
+ size += sizeof (struct mlx4_wqe_raddr_seg);
+ /*
+ * An atomic op will require an atomic segment, a
+ * remote address segment and one scatter entry.
+ */
+ if (size < (sizeof (struct mlx4_wqe_atomic_seg) +
+ sizeof (struct mlx4_wqe_raddr_seg) +
+ sizeof (struct mlx4_wqe_data_seg)))
+ size = (sizeof (struct mlx4_wqe_atomic_seg) +
+ sizeof (struct mlx4_wqe_raddr_seg) +
+ sizeof (struct mlx4_wqe_data_seg));
+ break;
+
+ default:
+ break;
+ }
+
+ /* Make sure that we have enough space for a bind request */
+ if (size < sizeof (struct mlx4_wqe_bind_seg))
+ size = sizeof (struct mlx4_wqe_bind_seg);
+
+ size += sizeof (struct mlx4_wqe_ctrl_seg);
+
+ for (qp->sq.wqe_shift = 6; 1 << qp->sq.wqe_shift < size;
+ qp->sq.wqe_shift++)
+ ; /* nothing */
+}
+
+int mlx4_alloc_qp_buf(struct ibv_context *context, struct ibv_qp_cap *cap,
+ enum ibv_qp_type type, struct mlx4_qp *qp)
+{
+ qp->rq.max_gs = cap->max_recv_sge;
+
+ if (qp->sq.wqe_cnt) {
+ qp->sq.wrid = malloc(qp->sq.wqe_cnt * sizeof (uint64_t));
+ if (!qp->sq.wrid)
+ return -1;
+ }
+
+ if (qp->rq.wqe_cnt) {
+ qp->rq.wrid = malloc(qp->rq.wqe_cnt * sizeof (uint64_t));
+ if (!qp->rq.wrid) {
+ free(qp->sq.wrid);
+ return -1;
+ }
+ }
+
+ for (qp->rq.wqe_shift = 4;
+ 1 << qp->rq.wqe_shift < qp->rq.max_gs * sizeof (struct mlx4_wqe_data_seg);
+ qp->rq.wqe_shift++)
+ ; /* nothing */
+
+ qp->buf_size = (qp->rq.wqe_cnt << qp->rq.wqe_shift) +
+ (qp->sq.wqe_cnt << qp->sq.wqe_shift);
+ if (qp->rq.wqe_shift > qp->sq.wqe_shift) {
+ qp->rq.offset = 0;
+ qp->sq.offset = qp->rq.wqe_cnt << qp->rq.wqe_shift;
+ } else {
+ qp->rq.offset = qp->sq.wqe_cnt << qp->sq.wqe_shift;
+ qp->sq.offset = 0;
+ }
+
+ if (qp->buf_size) {
+ if (mlx4_alloc_buf(&qp->buf,
+ align(qp->buf_size, to_mdev(context->device)->page_size),
+ to_mdev(context->device)->page_size)) {
+ free(qp->sq.wrid);
+ free(qp->rq.wrid);
+ return -1;
+ }
+
+ memset(qp->buf.buf, 0, qp->buf_size);
+ } else {
+ qp->buf.buf = NULL;
+ }
+
+ return 0;
+}
+
+void mlx4_set_sq_sizes(struct mlx4_qp *qp, struct ibv_qp_cap *cap,
+ enum ibv_qp_type type)
+{
+ int wqe_size;
+
+ wqe_size = (1 << qp->sq.wqe_shift) - sizeof (struct mlx4_wqe_ctrl_seg);
+ switch (type) {
+ case IBV_QPT_UD:
+ wqe_size -= sizeof (struct mlx4_wqe_datagram_seg);
+ break;
+
+ case IBV_QPT_XRC_SEND:
+ case IBV_QPT_UC:
+ case IBV_QPT_RC:
+ wqe_size -= sizeof (struct mlx4_wqe_raddr_seg);
+ break;
+
+ default:
+ break;
+ }
+
+ qp->sq.max_gs = wqe_size / sizeof (struct mlx4_wqe_data_seg);
+ cap->max_send_sge = qp->sq.max_gs;
+ qp->sq.max_post = qp->sq.wqe_cnt - qp->sq_spare_wqes;
+ cap->max_send_wr = qp->sq.max_post;
+
+ /*
+ * Inline data segments can't cross a 64 byte boundary. So
+ * subtract off one segment header for each 64-byte chunk,
+ * taking into account the fact that wqe_size will be 32 mod
+ * 64 for non-UD QPs.
+ */
+ qp->max_inline_data = wqe_size -
+ sizeof (struct mlx4_wqe_inline_seg) *
+ (align(wqe_size, MLX4_INLINE_ALIGN) / MLX4_INLINE_ALIGN);
+ cap->max_inline_data = qp->max_inline_data;
+}
+
+struct mlx4_qp *mlx4_find_qp(struct mlx4_context *ctx, uint32_t qpn)
+{
+ int tind = (qpn & (ctx->num_qps - 1)) >> ctx->qp_table_shift;
+
+ if (ctx->qp_table[tind].refcnt)
+ return ctx->qp_table[tind].table[qpn & ctx->qp_table_mask];
+ else
+ return NULL;
+}
+
+int mlx4_store_qp(struct mlx4_context *ctx, uint32_t qpn, struct mlx4_qp *qp)
+{
+ int tind = (qpn & (ctx->num_qps - 1)) >> ctx->qp_table_shift;
+
+ if (!ctx->qp_table[tind].refcnt) {
+ ctx->qp_table[tind].table = calloc(ctx->qp_table_mask + 1,
+ sizeof (struct mlx4_qp *));
+ if (!ctx->qp_table[tind].table)
+ return -1;
+ }
+
+ ++ctx->qp_table[tind].refcnt;
+ ctx->qp_table[tind].table[qpn & ctx->qp_table_mask] = qp;
+ return 0;
+}
+
+void mlx4_clear_qp(struct mlx4_context *ctx, uint32_t qpn)
+{
+ int tind = (qpn & (ctx->num_qps - 1)) >> ctx->qp_table_shift;
+
+ if (!--ctx->qp_table[tind].refcnt)
+ free(ctx->qp_table[tind].table);
+ else
+ ctx->qp_table[tind].table[qpn & ctx->qp_table_mask] = NULL;
+}
diff --git a/contrib/ofed/libmlx4/src/buf.c b/contrib/ofed/libmlx4/src/buf.c
deleted file mode 100644
index 1ebc998..0000000
--- a/contrib/ofed/libmlx4/src/buf.c
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- * Copyright (c) 2006, 2007 Cisco, Inc. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-#if HAVE_CONFIG_H
-# include <config.h>
-#endif /* HAVE_CONFIG_H */
-
-#include <stdlib.h>
-#include <errno.h>
-#include <sys/mman.h>
-
-#include "mlx4.h"
-
-#if !(defined(HAVE_IBV_DONTFORK_RANGE) && defined(HAVE_IBV_DOFORK_RANGE))
-
-/*
- * If libibverbs isn't exporting these functions, then there's no
- * point in doing it here, because the rest of libibverbs isn't going
- * to be fork-safe anyway.
- */
-static int ibv_dontfork_range(void *base, size_t size)
-{
- return 0;
-}
-
-static int ibv_dofork_range(void *base, size_t size)
-{
- return 0;
-}
-
-#endif /* HAVE_IBV_DONTFORK_RANGE && HAVE_IBV_DOFORK_RANGE */
-
-int mlx4_alloc_buf(struct mlx4_buf *buf, size_t size, int page_size)
-{
- int ret;
-
- buf->length = align(size, page_size);
- buf->buf = mmap(NULL, buf->length, PROT_READ | PROT_WRITE,
- MAP_PRIVATE | MAP_ANON, -1, 0);
- if (buf->buf == MAP_FAILED)
- return errno;
-
- ret = ibv_dontfork_range(buf->buf, size);
- if (ret)
- munmap(buf->buf, buf->length);
-
- return ret;
-}
-
-void mlx4_free_buf(struct mlx4_buf *buf)
-{
- ibv_dofork_range(buf->buf, buf->length);
- munmap(buf->buf, buf->length);
-}
diff --git a/contrib/ofed/libmlx4/src/cq.c b/contrib/ofed/libmlx4/src/cq.c
deleted file mode 100644
index ef01fcf..0000000
--- a/contrib/ofed/libmlx4/src/cq.c
+++ /dev/null
@@ -1,508 +0,0 @@
-/*
- * Copyright (c) 2005 Topspin Communications. All rights reserved.
- * Copyright (c) 2005 Mellanox Technologies Ltd. All rights reserved.
- * Copyright (c) 2006, 2007 Cisco Systems. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-#if HAVE_CONFIG_H
-# include <config.h>
-#endif /* HAVE_CONFIG_H */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <pthread.h>
-#include <netinet/in.h>
-#include <string.h>
-
-#include <infiniband/opcode.h>
-
-#include "mlx4.h"
-#include "doorbell.h"
-
-enum {
- MLX4_CQ_DOORBELL = 0x20
-};
-
-enum {
- CQ_OK = 0,
- CQ_EMPTY = -1,
- CQ_POLL_ERR = -2
-};
-
-#define MLX4_CQ_DB_REQ_NOT_SOL (1 << 24)
-#define MLX4_CQ_DB_REQ_NOT (2 << 24)
-
-enum {
- MLX4_CQE_OWNER_MASK = 0x80,
- MLX4_CQE_IS_SEND_MASK = 0x40,
- MLX4_CQE_OPCODE_MASK = 0x1f
-};
-
-enum {
- MLX4_CQE_SYNDROME_LOCAL_LENGTH_ERR = 0x01,
- MLX4_CQE_SYNDROME_LOCAL_QP_OP_ERR = 0x02,
- MLX4_CQE_SYNDROME_LOCAL_PROT_ERR = 0x04,
- MLX4_CQE_SYNDROME_WR_FLUSH_ERR = 0x05,
- MLX4_CQE_SYNDROME_MW_BIND_ERR = 0x06,
- MLX4_CQE_SYNDROME_BAD_RESP_ERR = 0x10,
- MLX4_CQE_SYNDROME_LOCAL_ACCESS_ERR = 0x11,
- MLX4_CQE_SYNDROME_REMOTE_INVAL_REQ_ERR = 0x12,
- MLX4_CQE_SYNDROME_REMOTE_ACCESS_ERR = 0x13,
- MLX4_CQE_SYNDROME_REMOTE_OP_ERR = 0x14,
- MLX4_CQE_SYNDROME_TRANSPORT_RETRY_EXC_ERR = 0x15,
- MLX4_CQE_SYNDROME_RNR_RETRY_EXC_ERR = 0x16,
- MLX4_CQE_SYNDROME_REMOTE_ABORTED_ERR = 0x22,
-};
-
-struct mlx4_cqe {
- uint32_t my_qpn;
- uint32_t immed_rss_invalid;
- uint32_t g_mlpath_rqpn;
- uint8_t sl;
- uint8_t reserved1;
- uint16_t rlid;
- uint32_t reserved2;
- uint32_t byte_cnt;
- uint16_t wqe_index;
- uint16_t checksum;
- uint8_t reserved3[3];
- uint8_t owner_sr_opcode;
-};
-
-struct mlx4_err_cqe {
- uint32_t my_qpn;
- uint32_t reserved1[5];
- uint16_t wqe_index;
- uint8_t vendor_err;
- uint8_t syndrome;
- uint8_t reserved2[3];
- uint8_t owner_sr_opcode;
-};
-
-static struct mlx4_cqe *get_cqe(struct mlx4_cq *cq, int entry)
-{
- return cq->buf.buf + entry * cq->cqe_size;
-}
-
-static void *get_sw_cqe(struct mlx4_cq *cq, int n)
-{
- struct mlx4_cqe *cqe = get_cqe(cq, n & cq->ibv_cq.cqe);
- struct mlx4_cqe *tcqe = cq->cqe_size == 64 ? cqe + 1 : cqe;
-
- return (!!(tcqe->owner_sr_opcode & MLX4_CQE_OWNER_MASK) ^
- !!(n & (cq->ibv_cq.cqe + 1))) ? NULL : tcqe;
-}
-
-static struct mlx4_cqe *next_cqe_sw(struct mlx4_cq *cq)
-{
- return get_sw_cqe(cq, cq->cons_index);
-}
-
-static void update_cons_index(struct mlx4_cq *cq)
-{
- *cq->set_ci_db = htonl(cq->cons_index & 0xffffff);
-}
-
-static void mlx4_handle_error_cqe(struct mlx4_err_cqe *cqe, struct ibv_wc *wc)
-{
- if (cqe->syndrome == MLX4_CQE_SYNDROME_LOCAL_QP_OP_ERR)
- printf(PFX "local QP operation err "
- "(QPN %06x, WQE index %x, vendor syndrome %02x, "
- "opcode = %02x)\n",
- htonl(cqe->my_qpn), htonl(cqe->wqe_index),
- cqe->vendor_err,
- cqe->owner_sr_opcode & ~MLX4_CQE_OWNER_MASK);
-
- switch (cqe->syndrome) {
- case MLX4_CQE_SYNDROME_LOCAL_LENGTH_ERR:
- wc->status = IBV_WC_LOC_LEN_ERR;
- break;
- case MLX4_CQE_SYNDROME_LOCAL_QP_OP_ERR:
- wc->status = IBV_WC_LOC_QP_OP_ERR;
- break;
- case MLX4_CQE_SYNDROME_LOCAL_PROT_ERR:
- wc->status = IBV_WC_LOC_PROT_ERR;
- break;
- case MLX4_CQE_SYNDROME_WR_FLUSH_ERR:
- wc->status = IBV_WC_WR_FLUSH_ERR;
- break;
- case MLX4_CQE_SYNDROME_MW_BIND_ERR:
- wc->status = IBV_WC_MW_BIND_ERR;
- break;
- case MLX4_CQE_SYNDROME_BAD_RESP_ERR:
- wc->status = IBV_WC_BAD_RESP_ERR;
- break;
- case MLX4_CQE_SYNDROME_LOCAL_ACCESS_ERR:
- wc->status = IBV_WC_LOC_ACCESS_ERR;
- break;
- case MLX4_CQE_SYNDROME_REMOTE_INVAL_REQ_ERR:
- wc->status = IBV_WC_REM_INV_REQ_ERR;
- break;
- case MLX4_CQE_SYNDROME_REMOTE_ACCESS_ERR:
- wc->status = IBV_WC_REM_ACCESS_ERR;
- break;
- case MLX4_CQE_SYNDROME_REMOTE_OP_ERR:
- wc->status = IBV_WC_REM_OP_ERR;
- break;
- case MLX4_CQE_SYNDROME_TRANSPORT_RETRY_EXC_ERR:
- wc->status = IBV_WC_RETRY_EXC_ERR;
- break;
- case MLX4_CQE_SYNDROME_RNR_RETRY_EXC_ERR:
- wc->status = IBV_WC_RNR_RETRY_EXC_ERR;
- break;
- case MLX4_CQE_SYNDROME_REMOTE_ABORTED_ERR:
- wc->status = IBV_WC_REM_ABORT_ERR;
- break;
- default:
- wc->status = IBV_WC_GENERAL_ERR;
- break;
- }
-
- wc->vendor_err = cqe->vendor_err;
-}
-
-static int mlx4_poll_one(struct mlx4_cq *cq,
- struct mlx4_qp **cur_qp,
- struct ibv_wc *wc)
-{
- struct mlx4_wq *wq;
- struct mlx4_cqe *cqe;
- struct mlx4_srq *srq = NULL;
- uint32_t qpn;
- uint32_t srqn;
- uint32_t g_mlpath_rqpn;
- uint16_t wqe_index;
- int is_error;
- int is_send;
-
- cqe = next_cqe_sw(cq);
- if (!cqe)
- return CQ_EMPTY;
-
- ++cq->cons_index;
-
- VALGRIND_MAKE_MEM_DEFINED(cqe, sizeof *cqe);
-
- /*
- * Make sure we read CQ entry contents after we've checked the
- * ownership bit.
- */
- rmb();
-
- qpn = ntohl(cqe->my_qpn);
-
- is_send = cqe->owner_sr_opcode & MLX4_CQE_IS_SEND_MASK;
- is_error = (cqe->owner_sr_opcode & MLX4_CQE_OPCODE_MASK) ==
- MLX4_CQE_OPCODE_ERROR;
-
- if (qpn & MLX4_XRC_QPN_BIT && !is_send) {
- srqn = ntohl(cqe->g_mlpath_rqpn) & 0xffffff;
- /*
- * We do not have to take the XRC SRQ table lock here,
- * because CQs will be locked while XRC SRQs are removed
- * from the table.
- */
- srq = mlx4_find_xrc_srq(to_mctx(cq->ibv_cq.context), srqn);
- if (!srq)
- return CQ_POLL_ERR;
- } else if (!*cur_qp || (qpn & 0xffffff) != (*cur_qp)->ibv_qp.qp_num) {
- /*
- * We do not have to take the QP table lock here,
- * because CQs will be locked while QPs are removed
- * from the table.
- */
- *cur_qp = mlx4_find_qp(to_mctx(cq->ibv_cq.context),
- qpn & 0xffffff);
- if (!*cur_qp)
- return CQ_POLL_ERR;
- }
-
- wc->qp_num = qpn & 0xffffff;
-
- if (is_send) {
- wq = &(*cur_qp)->sq;
- wqe_index = ntohs(cqe->wqe_index);
- wq->tail += (uint16_t) (wqe_index - (uint16_t) wq->tail);
- wc->wr_id = wq->wrid[wq->tail & (wq->wqe_cnt - 1)];
- ++wq->tail;
- } else if (srq) {
- wqe_index = htons(cqe->wqe_index);
- wc->wr_id = srq->wrid[wqe_index];
- mlx4_free_srq_wqe(srq, wqe_index);
- } else if ((*cur_qp)->ibv_qp.srq) {
- srq = to_msrq((*cur_qp)->ibv_qp.srq);
- wqe_index = htons(cqe->wqe_index);
- wc->wr_id = srq->wrid[wqe_index];
- mlx4_free_srq_wqe(srq, wqe_index);
- } else {
- wq = &(*cur_qp)->rq;
- wc->wr_id = wq->wrid[wq->tail & (wq->wqe_cnt - 1)];
- ++wq->tail;
- }
-
- if (is_error) {
- mlx4_handle_error_cqe((struct mlx4_err_cqe *) cqe, wc);
- return CQ_OK;
- }
-
- wc->status = IBV_WC_SUCCESS;
-
- if (is_send) {
- wc->wc_flags = 0;
- switch (cqe->owner_sr_opcode & MLX4_CQE_OPCODE_MASK) {
- case MLX4_OPCODE_RDMA_WRITE_IMM:
- wc->wc_flags |= IBV_WC_WITH_IMM;
- case MLX4_OPCODE_RDMA_WRITE:
- wc->opcode = IBV_WC_RDMA_WRITE;
- break;
- case MLX4_OPCODE_SEND_IMM:
- wc->wc_flags |= IBV_WC_WITH_IMM;
- case MLX4_OPCODE_SEND:
- wc->opcode = IBV_WC_SEND;
- break;
- case MLX4_OPCODE_RDMA_READ:
- wc->opcode = IBV_WC_RDMA_READ;
- wc->byte_len = ntohl(cqe->byte_cnt);
- break;
- case MLX4_OPCODE_ATOMIC_CS:
- wc->opcode = IBV_WC_COMP_SWAP;
- wc->byte_len = 8;
- break;
- case MLX4_OPCODE_ATOMIC_FA:
- wc->opcode = IBV_WC_FETCH_ADD;
- wc->byte_len = 8;
- break;
- case MLX4_OPCODE_BIND_MW:
- wc->opcode = IBV_WC_BIND_MW;
- break;
- default:
- /* assume it's a send completion */
- wc->opcode = IBV_WC_SEND;
- break;
- }
- } else {
- wc->byte_len = ntohl(cqe->byte_cnt);
-
- switch (cqe->owner_sr_opcode & MLX4_CQE_OPCODE_MASK) {
- case MLX4_RECV_OPCODE_RDMA_WRITE_IMM:
- wc->opcode = IBV_WC_RECV_RDMA_WITH_IMM;
- wc->wc_flags = IBV_WC_WITH_IMM;
- wc->imm_data = cqe->immed_rss_invalid;
- break;
- case MLX4_RECV_OPCODE_SEND:
- wc->opcode = IBV_WC_RECV;
- wc->wc_flags = 0;
- break;
- case MLX4_RECV_OPCODE_SEND_IMM:
- wc->opcode = IBV_WC_RECV;
- wc->wc_flags = IBV_WC_WITH_IMM;
- wc->imm_data = cqe->immed_rss_invalid;
- break;
- }
-
- wc->slid = ntohs(cqe->rlid);
- wc->sl = cqe->sl >> 4;
- g_mlpath_rqpn = ntohl(cqe->g_mlpath_rqpn);
- wc->src_qp = g_mlpath_rqpn & 0xffffff;
- wc->dlid_path_bits = (g_mlpath_rqpn >> 24) & 0x7f;
- wc->wc_flags |= g_mlpath_rqpn & 0x80000000 ? IBV_WC_GRH : 0;
- wc->pkey_index = ntohl(cqe->immed_rss_invalid) & 0x7f;
- }
-
- return CQ_OK;
-}
-
-int mlx4_poll_cq(struct ibv_cq *ibcq, int ne, struct ibv_wc *wc)
-{
- struct mlx4_cq *cq = to_mcq(ibcq);
- struct mlx4_qp *qp = NULL;
- int npolled;
- int err = CQ_OK;
-
- pthread_spin_lock(&cq->lock);
-
- for (npolled = 0; npolled < ne; ++npolled) {
- err = mlx4_poll_one(cq, &qp, wc + npolled);
- if (err != CQ_OK)
- break;
- }
-
- if (npolled)
- update_cons_index(cq);
-
- pthread_spin_unlock(&cq->lock);
-
- return err == CQ_POLL_ERR ? err : npolled;
-}
-
-int mlx4_arm_cq(struct ibv_cq *ibvcq, int solicited)
-{
- struct mlx4_cq *cq = to_mcq(ibvcq);
- uint32_t doorbell[2];
- uint32_t sn;
- uint32_t ci;
- uint32_t cmd;
-
- sn = cq->arm_sn & 3;
- ci = cq->cons_index & 0xffffff;
- cmd = solicited ? MLX4_CQ_DB_REQ_NOT_SOL : MLX4_CQ_DB_REQ_NOT;
-
- *cq->arm_db = htonl(sn << 28 | cmd | ci);
-
- /*
- * Make sure that the doorbell record in host memory is
- * written before ringing the doorbell via PCI MMIO.
- */
- wmb();
-
- doorbell[0] = htonl(sn << 28 | cmd | cq->cqn);
- doorbell[1] = htonl(ci);
-
- mlx4_write64(doorbell, to_mctx(ibvcq->context), MLX4_CQ_DOORBELL);
-
- return 0;
-}
-
-void mlx4_cq_event(struct ibv_cq *cq)
-{
- to_mcq(cq)->arm_sn++;
-}
-
-void __mlx4_cq_clean(struct mlx4_cq *cq, uint32_t qpn, struct mlx4_srq *srq)
-{
- struct mlx4_cqe *cqe, *dest;
- uint32_t prod_index;
- uint8_t owner_bit;
- int nfreed = 0;
- int is_xrc_srq = 0;
- int cqe_inc = cq->cqe_size == 64 ? 1 : 0;
-
- if (srq && srq->ibv_srq.xrc_cq)
- is_xrc_srq = 1;
-
- /*
- * First we need to find the current producer index, so we
- * know where to start cleaning from. It doesn't matter if HW
- * adds new entries after this loop -- the QP we're worried
- * about is already in RESET, so the new entries won't come
- * from our QP and therefore don't need to be checked.
- */
- for (prod_index = cq->cons_index; get_sw_cqe(cq, prod_index); ++prod_index)
- if (prod_index == cq->cons_index + cq->ibv_cq.cqe)
- break;
-
- /*
- * Now sweep backwards through the CQ, removing CQ entries
- * that match our QP by copying older entries on top of them.
- */
- while ((int) --prod_index - (int) cq->cons_index >= 0) {
- cqe = get_cqe(cq, prod_index & cq->ibv_cq.cqe);
- cqe += cqe_inc;
- if (is_xrc_srq &&
- (ntohl(cqe->g_mlpath_rqpn & 0xffffff) == srq->srqn) &&
- !(cqe->owner_sr_opcode & MLX4_CQE_IS_SEND_MASK)) {
- mlx4_free_srq_wqe(srq, ntohs(cqe->wqe_index));
- ++nfreed;
- } else if ((ntohl(cqe->my_qpn) & 0xffffff) == qpn) {
- if (srq && !(cqe->owner_sr_opcode & MLX4_CQE_IS_SEND_MASK))
- mlx4_free_srq_wqe(srq, ntohs(cqe->wqe_index));
- ++nfreed;
- } else if (nfreed) {
- dest = get_cqe(cq, (prod_index + nfreed) & cq->ibv_cq.cqe);
- dest += cqe_inc;
- owner_bit = dest->owner_sr_opcode & MLX4_CQE_OWNER_MASK;
- memcpy(dest, cqe, sizeof *cqe);
- dest->owner_sr_opcode = owner_bit |
- (dest->owner_sr_opcode & ~MLX4_CQE_OWNER_MASK);
- }
- }
-
- if (nfreed) {
- cq->cons_index += nfreed;
- /*
- * Make sure update of buffer contents is done before
- * updating consumer index.
- */
- wmb();
- update_cons_index(cq);
- }
-}
-
-void mlx4_cq_clean(struct mlx4_cq *cq, uint32_t qpn, struct mlx4_srq *srq)
-{
- pthread_spin_lock(&cq->lock);
- __mlx4_cq_clean(cq, qpn, srq);
- pthread_spin_unlock(&cq->lock);
-}
-
-int mlx4_get_outstanding_cqes(struct mlx4_cq *cq)
-{
- uint32_t i;
-
- for (i = cq->cons_index; get_sw_cqe(cq, (i & cq->ibv_cq.cqe)); ++i)
- ;
-
- return i - cq->cons_index;
-}
-
-void mlx4_cq_resize_copy_cqes(struct mlx4_cq *cq, void *buf, int old_cqe)
-{
- struct mlx4_cqe *cqe;
- int i;
- int cqe_inc = cq->cqe_size == 64 ? 1 : 0;
-
- i = cq->cons_index;
- cqe = get_cqe(cq, (i & old_cqe));
- cqe += cqe_inc;
-
- while ((cqe->owner_sr_opcode & MLX4_CQE_OPCODE_MASK) != MLX4_CQE_OPCODE_RESIZE) {
- cqe->owner_sr_opcode = (cqe->owner_sr_opcode & ~MLX4_CQE_OWNER_MASK) |
- (((i + 1) & (cq->ibv_cq.cqe + 1)) ? MLX4_CQE_OWNER_MASK : 0);
- memcpy(buf + ((i + 1) & cq->ibv_cq.cqe) * cq->cqe_size,
- cqe - cqe_inc, cq->cqe_size);
- ++i;
- cqe = get_cqe(cq, (i & old_cqe));
- cqe += cqe_inc;
- }
-
- ++cq->cons_index;
-}
-
-int mlx4_alloc_cq_buf(struct mlx4_device *dev, struct mlx4_buf *buf, int nent,
- int entry_size)
-{
- if (mlx4_alloc_buf(buf, align(nent * entry_size, dev->page_size),
- dev->page_size))
- return -1;
- memset(buf->buf, 0, nent * entry_size);
-
- return 0;
-}
diff --git a/contrib/ofed/libmlx4/src/dbrec.c b/contrib/ofed/libmlx4/src/dbrec.c
deleted file mode 100644
index 02ef237..0000000
--- a/contrib/ofed/libmlx4/src/dbrec.c
+++ /dev/null
@@ -1,154 +0,0 @@
-/*
- * Copyright (c) 2005 Topspin Communications. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-#if HAVE_CONFIG_H
-# include <config.h>
-#endif /* HAVE_CONFIG_H */
-
-#include <stdlib.h>
-#include <netinet/in.h>
-#include <pthread.h>
-#include <string.h>
-
-#include "mlx4.h"
-
-struct mlx4_db_page {
- struct mlx4_db_page *prev, *next;
- struct mlx4_buf buf;
- int num_db;
- int use_cnt;
- unsigned long free[0];
-};
-
-static const int db_size[] = {
- [MLX4_DB_TYPE_CQ] = 8,
- [MLX4_DB_TYPE_RQ] = 4,
-};
-
-static struct mlx4_db_page *__add_page(struct mlx4_context *context,
- enum mlx4_db_type type)
-{
- struct mlx4_db_page *page;
- int ps = to_mdev(context->ibv_ctx.device)->page_size;
- int pp;
- int i;
-
- pp = ps / db_size[type];
-
- page = malloc(sizeof *page + pp / 8);
- if (!page)
- return NULL;
-
- if (mlx4_alloc_buf(&page->buf, ps, ps)) {
- free(page);
- return NULL;
- }
-
- page->num_db = pp;
- page->use_cnt = 0;
- for (i = 0; i < pp / (sizeof (long) * 8); ++i)
- page->free[i] = ~0;
-
- page->prev = NULL;
- page->next = context->db_list[type];
- context->db_list[type] = page;
- if (page->next)
- page->next->prev = page;
-
- return page;
-}
-
-uint32_t *mlx4_alloc_db(struct mlx4_context *context, enum mlx4_db_type type)
-{
- struct mlx4_db_page *page;
- uint32_t *db = NULL;
- int i, j;
-
- pthread_mutex_lock(&context->db_list_mutex);
-
- for (page = context->db_list[type]; page; page = page->next)
- if (page->use_cnt < page->num_db)
- goto found;
-
- page = __add_page(context, type);
- if (!page)
- goto out;
-
-found:
- ++page->use_cnt;
-
- for (i = 0; !page->free[i]; ++i)
- /* nothing */;
-
- j = ffsl(page->free[i]);
- page->free[i] &= ~(1UL << (j - 1));
- db = page->buf.buf + (i * 8 * sizeof (long) + (j - 1)) * db_size[type];
-
-out:
- pthread_mutex_unlock(&context->db_list_mutex);
-
- return db;
-}
-
-void mlx4_free_db(struct mlx4_context *context, enum mlx4_db_type type, uint32_t *db)
-{
- struct mlx4_db_page *page;
- uintptr_t ps = to_mdev(context->ibv_ctx.device)->page_size;
- int i;
-
- pthread_mutex_lock(&context->db_list_mutex);
-
- for (page = context->db_list[type]; page; page = page->next)
- if (((uintptr_t) db & ~(ps - 1)) == (uintptr_t) page->buf.buf)
- break;
-
- if (!page)
- goto out;
-
- i = ((void *) db - page->buf.buf) / db_size[type];
- page->free[i / (8 * sizeof (long))] |= 1UL << (i % (8 * sizeof (long)));
-
- if (!--page->use_cnt) {
- if (page->prev)
- page->prev->next = page->next;
- else
- context->db_list[type] = page->next;
- if (page->next)
- page->next->prev = page->prev;
-
- mlx4_free_buf(&page->buf);
- free(page);
- }
-
-out:
- pthread_mutex_unlock(&context->db_list_mutex);
-}
diff --git a/contrib/ofed/libmlx4/src/doorbell.h b/contrib/ofed/libmlx4/src/doorbell.h
deleted file mode 100644
index f0b30a9..0000000
--- a/contrib/ofed/libmlx4/src/doorbell.h
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * Copyright (c) 2007 Cisco, Inc. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-#ifndef DOORBELL_H
-#define DOORBELL_H
-
-#ifdef __LP64__
-#if __BYTE_ORDER == __LITTLE_ENDIAN
-# define MLX4_PAIR_TO_64(val) ((uint64_t) val[1] << 32 | val[0])
-#elif __BYTE_ORDER == __BIG_ENDIAN
-# define MLX4_PAIR_TO_64(val) ((uint64_t) val[0] << 32 | val[1])
-#else
-# error __BYTE_ORDER not defined
-#endif
-
-static inline void mlx4_write64(uint32_t val[2], struct mlx4_context *ctx, int offset)
-{
- *(volatile uint64_t *) (ctx->uar + offset) = MLX4_PAIR_TO_64(val);
-}
-
-#else
-
-static inline void mlx4_write64(uint32_t val[2], struct mlx4_context *ctx, int offset)
-{
- pthread_spin_lock(&ctx->uar_lock);
- *(volatile uint32_t *) (ctx->uar + offset) = val[0];
- *(volatile uint32_t *) (ctx->uar + offset + 4) = val[1];
- pthread_spin_unlock(&ctx->uar_lock);
-}
-
-#endif
-
-#endif /* DOORBELL_H */
diff --git a/contrib/ofed/libmlx4/src/mlx4-abi.h b/contrib/ofed/libmlx4/src/mlx4-abi.h
deleted file mode 100644
index f2d0010..0000000
--- a/contrib/ofed/libmlx4/src/mlx4-abi.h
+++ /dev/null
@@ -1,118 +0,0 @@
-/*
- * Copyright (c) 2007 Cisco, Inc. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-#ifndef MLX4_ABI_H
-#define MLX4_ABI_H
-
-#include <infiniband/kern-abi.h>
-
-#define MLX4_UVERBS_MIN_ABI_VERSION 2
-#define MLX4_UVERBS_MAX_ABI_VERSION 4
-
-struct mlx4_alloc_ucontext_resp_v3 {
- struct ibv_get_context_resp ibv_resp;
- __u32 qp_tab_size;
- __u16 bf_reg_size;
- __u16 bf_regs_per_page;
-};
-
-struct mlx4_alloc_ucontext_resp {
- struct ibv_get_context_resp ibv_resp;
- __u32 dev_caps;
- __u32 qp_tab_size;
- __u16 bf_reg_size;
- __u16 bf_regs_per_page;
- __u32 cqe_size;
-};
-
-struct mlx4_alloc_pd_resp {
- struct ibv_alloc_pd_resp ibv_resp;
- __u32 pdn;
- __u32 reserved;
-};
-
-struct mlx4_create_cq {
- struct ibv_create_cq ibv_cmd;
- __u64 buf_addr;
- __u64 db_addr;
-};
-
-struct mlx4_create_cq_resp {
- struct ibv_create_cq_resp ibv_resp;
- __u32 cqn;
- __u32 reserved;
-};
-
-struct mlx4_resize_cq {
- struct ibv_resize_cq ibv_cmd;
- __u64 buf_addr;
-};
-
-#ifdef HAVE_IBV_XRC_OPS
-struct mlx4_create_xrc_srq {
- struct ibv_create_xrc_srq ibv_cmd;
- __u64 buf_addr;
- __u64 db_addr;
-};
-#endif
-
-struct mlx4_create_srq {
- struct ibv_create_srq ibv_cmd;
- __u64 buf_addr;
- __u64 db_addr;
-};
-
-struct mlx4_create_srq_resp {
- struct ibv_create_srq_resp ibv_resp;
- __u32 srqn;
- __u32 reserved;
-};
-
-struct mlx4_create_qp {
- struct ibv_create_qp ibv_cmd;
- __u64 buf_addr;
- __u64 db_addr;
- __u8 log_sq_bb_count;
- __u8 log_sq_stride;
- __u8 sq_no_prefetch; /* was reserved in ABI 2 */
- __u8 reserved[5];
-};
-
-#ifdef HAVE_IBV_XRC_OPS
-struct mlx4_open_xrc_domain_resp {
- struct ibv_open_xrc_domain_resp ibv_resp;
- __u32 xrcdn;
- __u32 reserved;
-};
-#endif
-
-#endif /* MLX4_ABI_H */
diff --git a/contrib/ofed/libmlx4/src/mlx4.c b/contrib/ofed/libmlx4/src/mlx4.c
deleted file mode 100644
index a8ec332..0000000
--- a/contrib/ofed/libmlx4/src/mlx4.c
+++ /dev/null
@@ -1,338 +0,0 @@
-/*
- * Copyright (c) 2007 Cisco, Inc. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-#if HAVE_CONFIG_H
-# include <config.h>
-#endif /* HAVE_CONFIG_H */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <errno.h>
-#include <sys/mman.h>
-#include <pthread.h>
-#include <string.h>
-
-#ifndef HAVE_IBV_REGISTER_DRIVER
-#include <sysfs/libsysfs.h>
-#endif
-
-#include "mlx4.h"
-#include "mlx4-abi.h"
-
-#ifndef PCI_VENDOR_ID_MELLANOX
-#define PCI_VENDOR_ID_MELLANOX 0x15b3
-#endif
-
-#define HCA(v, d) \
- { .vendor = PCI_VENDOR_ID_##v, \
- .device = d }
-
-struct {
- unsigned vendor;
- unsigned device;
-} hca_table[] = {
- HCA(MELLANOX, 0x6340), /* MT25408 "Hermon" SDR */
- HCA(MELLANOX, 0x634a), /* MT25408 "Hermon" DDR */
- HCA(MELLANOX, 0x6354), /* MT25408 "Hermon" QDR */
- HCA(MELLANOX, 0x6732), /* MT25408 "Hermon" DDR PCIe gen2 */
- HCA(MELLANOX, 0x673c), /* MT25408 "Hermon" QDR PCIe gen2 */
- HCA(MELLANOX, 0x6368), /* MT25448 [ConnectX EN 10GigE, PCIe 2.0 2.5GT/s] */
- HCA(MELLANOX, 0x6750), /* MT26448 [ConnectX EN 10GigE, PCIe 2.0 5GT/s] */
- HCA(MELLANOX, 0x6372), /* MT25408 [ConnectX EN 10GigE 10GBaseT, PCIe 2.0 2.5GT/s] */
- HCA(MELLANOX, 0x675a), /* MT25408 [ConnectX EN 10GigE 10GBaseT, PCIe Gen2 5GT/s] */
- HCA(MELLANOX, 0x6764), /* MT26468 [ConnectX EN 10GigE, PCIe 2.0 5GT/s] */
- HCA(MELLANOX, 0x6746), /* MT26438 ConnectX VPI PCIe 2.0 5GT/s - IB QDR / 10GigE Virt+ */
- HCA(MELLANOX, 0x676e), /* MT26478 ConnectX EN 40GigE PCIe 2.0 5GT/s */
- HCA(MELLANOX, 0x6778), /* MT26488 ConnectX VPI PCIe 2.0 5GT/s - IB DDR / 10GigE Virt+ */
- HCA(MELLANOX, 0x1000),
- HCA(MELLANOX, 0x1001),
- HCA(MELLANOX, 0x1002),
- HCA(MELLANOX, 0x1003),
- HCA(MELLANOX, 0x1004),
- HCA(MELLANOX, 0x1005),
- HCA(MELLANOX, 0x1006),
- HCA(MELLANOX, 0x1007),
- HCA(MELLANOX, 0x1008),
- HCA(MELLANOX, 0x1009),
- HCA(MELLANOX, 0x100a),
- HCA(MELLANOX, 0x100b),
- HCA(MELLANOX, 0x100c),
- HCA(MELLANOX, 0x100d),
- HCA(MELLANOX, 0x100e),
- HCA(MELLANOX, 0x100f),
-};
-
-#ifdef HAVE_IBV_MORE_OPS
-static struct ibv_more_ops mlx4_more_ops = {
-#ifdef HAVE_IBV_XRC_OPS
- .create_xrc_srq = mlx4_create_xrc_srq,
- .open_xrc_domain = mlx4_open_xrc_domain,
- .close_xrc_domain = mlx4_close_xrc_domain,
- .create_xrc_rcv_qp = mlx4_create_xrc_rcv_qp,
- .modify_xrc_rcv_qp = mlx4_modify_xrc_rcv_qp,
- .query_xrc_rcv_qp = mlx4_query_xrc_rcv_qp,
- .reg_xrc_rcv_qp = mlx4_reg_xrc_rcv_qp,
- .unreg_xrc_rcv_qp = mlx4_unreg_xrc_rcv_qp,
-#endif
-};
-#endif
-
-static struct ibv_context_ops mlx4_ctx_ops = {
- .query_device = mlx4_query_device,
- .query_port = mlx4_query_port,
- .alloc_pd = mlx4_alloc_pd,
- .dealloc_pd = mlx4_free_pd,
- .reg_mr = mlx4_reg_mr,
- .dereg_mr = mlx4_dereg_mr,
- .create_cq = mlx4_create_cq,
- .poll_cq = mlx4_poll_cq,
- .req_notify_cq = mlx4_arm_cq,
- .cq_event = mlx4_cq_event,
- .resize_cq = mlx4_resize_cq,
- .destroy_cq = mlx4_destroy_cq,
- .create_srq = mlx4_create_srq,
- .modify_srq = mlx4_modify_srq,
- .query_srq = mlx4_query_srq,
- .destroy_srq = mlx4_destroy_srq,
- .post_srq_recv = mlx4_post_srq_recv,
- .create_qp = mlx4_create_qp,
- .query_qp = mlx4_query_qp,
- .modify_qp = mlx4_modify_qp,
- .destroy_qp = mlx4_destroy_qp,
- .post_send = mlx4_post_send,
- .post_recv = mlx4_post_recv,
- .create_ah = mlx4_create_ah,
- .destroy_ah = mlx4_destroy_ah,
- .attach_mcast = ibv_cmd_attach_mcast,
- .detach_mcast = ibv_cmd_detach_mcast
-};
-
-static struct ibv_context *mlx4_alloc_context(struct ibv_device *ibdev, int cmd_fd)
-{
- struct mlx4_context *context;
- struct ibv_get_context cmd;
- struct mlx4_alloc_ucontext_resp resp;
- struct mlx4_alloc_ucontext_resp_v3 resp_v3;
- int i;
- struct ibv_device_attr dev_attrs;
- unsigned int bf_reg_size;
-
- context = calloc(1, sizeof *context);
- if (!context)
- return NULL;
-
- context->ibv_ctx.cmd_fd = cmd_fd;
-
- if (to_mdev(ibdev)->driver_abi_ver > 3) {
- if (ibv_cmd_get_context(&context->ibv_ctx, &cmd, sizeof cmd,
- &resp.ibv_resp, sizeof resp))
- goto err_free;
-
- context->num_qps = resp.qp_tab_size;
- context->num_xrc_srqs = resp.qp_tab_size;
- bf_reg_size = resp.bf_reg_size;
- context->cqe_size = resp.cqe_size;
- } else {
- if (ibv_cmd_get_context(&context->ibv_ctx, &cmd, sizeof cmd,
- &resp_v3.ibv_resp, sizeof resp_v3))
- goto err_free;
-
- context->num_qps = resp_v3.qp_tab_size;
- context->num_xrc_srqs = resp_v3.qp_tab_size;
- bf_reg_size = resp_v3.bf_reg_size;
- context->cqe_size = 32;
- }
-
- context->qp_table_shift = ffs(context->num_qps) - 1 - MLX4_QP_TABLE_BITS;
- context->qp_table_mask = (1 << context->qp_table_shift) - 1;
-
- pthread_mutex_init(&context->qp_table_mutex, NULL);
- for (i = 0; i < MLX4_QP_TABLE_SIZE; ++i)
- context->qp_table[i].refcnt = 0;
-
- context->xrc_srq_table_shift = ffs(context->num_xrc_srqs) - 1
- - MLX4_XRC_SRQ_TABLE_BITS;
- context->xrc_srq_table_mask = (1 << context->xrc_srq_table_shift) - 1;
-
- pthread_mutex_init(&context->xrc_srq_table_mutex, NULL);
- for (i = 0; i < MLX4_XRC_SRQ_TABLE_SIZE; ++i)
- context->xrc_srq_table[i].refcnt = 0;
-
- for (i = 0; i < MLX4_NUM_DB_TYPE; ++i)
- context->db_list[i] = NULL;
-
- pthread_mutex_init(&context->db_list_mutex, NULL);
-
- context->uar = mmap(NULL, to_mdev(ibdev)->page_size, PROT_WRITE,
- MAP_SHARED, cmd_fd, 0);
- if (context->uar == MAP_FAILED)
- goto err_free;
-
- if (bf_reg_size) {
- context->bf_page = mmap(NULL, to_mdev(ibdev)->page_size,
- PROT_WRITE, MAP_SHARED, cmd_fd,
- to_mdev(ibdev)->page_size);
- if (context->bf_page == MAP_FAILED) {
- fprintf(stderr, PFX "Warning: BlueFlame available, "
- "but failed to mmap() BlueFlame page.\n");
- context->bf_page = NULL;
- context->bf_buf_size = 0;
- } else {
- context->bf_buf_size = bf_reg_size / 2;
- context->bf_offset = 0;
- pthread_spin_init(&context->bf_lock, PTHREAD_PROCESS_PRIVATE);
- }
- } else {
- context->bf_page = NULL;
- context->bf_buf_size = 0;
- }
-
- pthread_spin_init(&context->uar_lock, PTHREAD_PROCESS_PRIVATE);
-
- context->ibv_ctx.ops = mlx4_ctx_ops;
-#ifdef HAVE_IBV_XRC_OPS
- context->ibv_ctx.more_ops = &mlx4_more_ops;
-#endif
-
- if (mlx4_query_device(&context->ibv_ctx, &dev_attrs))
- goto query_free;
-
- context->max_qp_wr = dev_attrs.max_qp_wr;
- context->max_sge = dev_attrs.max_sge;
- context->max_cqe = dev_attrs.max_cqe;
- if (!(dev_attrs.device_cap_flags & IBV_DEVICE_XRC)) {
- fprintf(stderr, PFX "There is a mismatch between "
- "the kernel and the userspace libraries: "
- "Kernel does not support XRC. Exiting.\n");
- goto query_free;
- }
-
- return &context->ibv_ctx;
-
-query_free:
- munmap(context->uar, to_mdev(ibdev)->page_size);
- if (context->bf_page)
- munmap(context->bf_page, to_mdev(ibdev)->page_size);
-
-err_free:
- free(context);
- return NULL;
-}
-
-static void mlx4_free_context(struct ibv_context *ibctx)
-{
- struct mlx4_context *context = to_mctx(ibctx);
-
- munmap(context->uar, to_mdev(ibctx->device)->page_size);
- if (context->bf_page)
- munmap(context->bf_page, to_mdev(ibctx->device)->page_size);
- free(context);
-}
-
-static struct ibv_device_ops mlx4_dev_ops = {
- .alloc_context = mlx4_alloc_context,
- .free_context = mlx4_free_context
-};
-
-static struct ibv_device *mlx4_driver_init(const char *uverbs_sys_path,
- int abi_version)
-{
- char value[8];
- struct mlx4_device *dev;
- unsigned vendor, device;
- int i;
-
- if (ibv_read_sysfs_file(uverbs_sys_path, "device/vendor",
- value, sizeof value) < 0)
- return NULL;
- sscanf(value, "%i", &vendor);
-
- if (ibv_read_sysfs_file(uverbs_sys_path, "device/device",
- value, sizeof value) < 0)
- return NULL;
- sscanf(value, "%i", &device);
-
- for (i = 0; i < sizeof hca_table / sizeof hca_table[0]; ++i)
- if (vendor == hca_table[i].vendor &&
- device == hca_table[i].device)
- goto found;
-
- return NULL;
-
-found:
- if (abi_version < MLX4_UVERBS_MIN_ABI_VERSION ||
- abi_version > MLX4_UVERBS_MAX_ABI_VERSION) {
- fprintf(stderr, PFX "Fatal: ABI version %d of %s is not supported "
- "(min supported %d, max supported %d)\n",
- abi_version, uverbs_sys_path,
- MLX4_UVERBS_MIN_ABI_VERSION,
- MLX4_UVERBS_MAX_ABI_VERSION);
- return NULL;
- }
-
- dev = malloc(sizeof *dev);
- if (!dev) {
- fprintf(stderr, PFX "Fatal: couldn't allocate device for %s\n",
- uverbs_sys_path);
- return NULL;
- }
-
- dev->ibv_dev.ops = mlx4_dev_ops;
- dev->page_size = sysconf(_SC_PAGESIZE);
- dev->driver_abi_ver = abi_version;
-
- return &dev->ibv_dev;
-}
-
-#ifdef HAVE_IBV_REGISTER_DRIVER
-static __attribute__((constructor)) void mlx4_register_driver(void)
-{
- ibv_register_driver("mlx4", mlx4_driver_init);
-}
-#else
-/*
- * Export the old libsysfs sysfs_class_device-based driver entry point
- * if libibverbs does not export an ibv_register_driver() function.
- */
-struct ibv_device *openib_driver_init(struct sysfs_class_device *sysdev)
-{
- int abi_ver = 0;
- char value[8];
-
- if (ibv_read_sysfs_file(sysdev->path, "abi_version",
- value, sizeof value) > 0)
- abi_ver = strtol(value, NULL, 10);
-
- return mlx4_driver_init(sysdev->path, abi_ver);
-}
-#endif /* HAVE_IBV_REGISTER_DRIVER */
diff --git a/contrib/ofed/libmlx4/src/mlx4.h b/contrib/ofed/libmlx4/src/mlx4.h
deleted file mode 100644
index 208ebd0..0000000
--- a/contrib/ofed/libmlx4/src/mlx4.h
+++ /dev/null
@@ -1,457 +0,0 @@
-/*
- * Copyright (c) 2004, 2005 Topspin Communications. All rights reserved.
- * Copyright (c) 2005, 2006, 2007 Cisco Systems. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-#ifndef MLX4_H
-#define MLX4_H
-
-#include <stddef.h>
-
-#include <infiniband/driver.h>
-#include <infiniband/arch.h>
-
-#ifdef HAVE_VALGRIND_MEMCHECK_H
-
-# include <valgrind/memcheck.h>
-
-# if !defined(VALGRIND_MAKE_MEM_DEFINED) || !defined(VALGRIND_MAKE_MEM_UNDEFINED)
-# warning "Valgrind support requested, but VALGRIND_MAKE_MEM_(UN)DEFINED not available"
-# endif
-
-#endif /* HAVE_VALGRIND_MEMCHECK_H */
-
-#ifndef VALGRIND_MAKE_MEM_DEFINED
-# define VALGRIND_MAKE_MEM_DEFINED(addr,len)
-#endif
-
-#ifndef VALGRIND_MAKE_MEM_UNDEFINED
-# define VALGRIND_MAKE_MEM_UNDEFINED(addr,len)
-#endif
-
-#ifndef rmb
-# define rmb() mb()
-#endif
-
-#ifndef wmb
-# define wmb() mb()
-#endif
-
-#ifndef wc_wmb
-
-#if defined(__i386__)
-#define wc_wmb() asm volatile("lock; addl $0,0(%%esp) " ::: "memory")
-#elif defined(__x86_64__)
-#define wc_wmb() asm volatile("sfence" ::: "memory")
-#elif defined(__ia64__)
-#define wc_wmb() asm volatile("fwb" ::: "memory")
-#else
-#define wc_wmb() wmb()
-#endif
-
-#endif
-
-#ifndef HAVE_IBV_MORE_OPS
-#undef HAVE_IBV_XRC_OPS
-#undef HAVE_IBV_CREATE_QP_EXP
-#endif
-
-#define HIDDEN __attribute__((visibility ("hidden")))
-
-#define PFX "mlx4: "
-
-#ifndef max
-#define max(a,b) \
- ({ typeof (a) _a = (a); \
- typeof (b) _b = (b); \
- _a > _b ? _a : _b; })
-#endif
-
-#ifndef min
-#define min(a,b) \
- ({ typeof (a) _a = (a); \
- typeof (b) _b = (b); \
- _a < _b ? _a : _b; })
-#endif
-
-enum {
- MLX4_STAT_RATE_OFFSET = 5
-};
-
-enum {
- MLX4_QP_TABLE_BITS = 8,
- MLX4_QP_TABLE_SIZE = 1 << MLX4_QP_TABLE_BITS,
- MLX4_QP_TABLE_MASK = MLX4_QP_TABLE_SIZE - 1
-};
-
-enum {
- MLX4_XRC_SRQ_TABLE_BITS = 8,
- MLX4_XRC_SRQ_TABLE_SIZE = 1 << MLX4_XRC_SRQ_TABLE_BITS,
- MLX4_XRC_SRQ_TABLE_MASK = MLX4_XRC_SRQ_TABLE_SIZE - 1
-};
-
-enum {
- MLX4_XRC_QPN_BIT = (1 << 23)
-};
-
-enum mlx4_db_type {
- MLX4_DB_TYPE_CQ,
- MLX4_DB_TYPE_RQ,
- MLX4_NUM_DB_TYPE
-};
-
-enum {
- MLX4_OPCODE_NOP = 0x00,
- MLX4_OPCODE_SEND_INVAL = 0x01,
- MLX4_OPCODE_RDMA_WRITE = 0x08,
- MLX4_OPCODE_RDMA_WRITE_IMM = 0x09,
- MLX4_OPCODE_SEND = 0x0a,
- MLX4_OPCODE_SEND_IMM = 0x0b,
- MLX4_OPCODE_LSO = 0x0e,
- MLX4_OPCODE_RDMA_READ = 0x10,
- MLX4_OPCODE_ATOMIC_CS = 0x11,
- MLX4_OPCODE_ATOMIC_FA = 0x12,
- MLX4_OPCODE_ATOMIC_MASK_CS = 0x14,
- MLX4_OPCODE_ATOMIC_MASK_FA = 0x15,
- MLX4_OPCODE_BIND_MW = 0x18,
- MLX4_OPCODE_FMR = 0x19,
- MLX4_OPCODE_LOCAL_INVAL = 0x1b,
- MLX4_OPCODE_CONFIG_CMD = 0x1f,
-
- MLX4_RECV_OPCODE_RDMA_WRITE_IMM = 0x00,
- MLX4_RECV_OPCODE_SEND = 0x01,
- MLX4_RECV_OPCODE_SEND_IMM = 0x02,
- MLX4_RECV_OPCODE_SEND_INVAL = 0x03,
-
- MLX4_CQE_OPCODE_ERROR = 0x1e,
- MLX4_CQE_OPCODE_RESIZE = 0x16,
-};
-
-enum {
- MLX4_MAX_WQE_SIZE = 1008
-};
-
-struct mlx4_device {
- struct ibv_device ibv_dev;
- int page_size;
- int driver_abi_ver;
-};
-
-struct mlx4_db_page;
-
-struct mlx4_context {
- struct ibv_context ibv_ctx;
-
- void *uar;
- pthread_spinlock_t uar_lock;
-
- void *bf_page;
- int bf_buf_size;
- int bf_offset;
- pthread_spinlock_t bf_lock;
-
- struct {
- struct mlx4_qp **table;
- int refcnt;
- } qp_table[MLX4_QP_TABLE_SIZE];
- pthread_mutex_t qp_table_mutex;
- int num_qps;
- int qp_table_shift;
- int qp_table_mask;
- int max_qp_wr;
- int max_sge;
- int max_cqe;
- int cqe_size;
-
- struct {
- struct mlx4_srq **table;
- int refcnt;
- } xrc_srq_table[MLX4_XRC_SRQ_TABLE_SIZE];
- pthread_mutex_t xrc_srq_table_mutex;
- int num_xrc_srqs;
- int xrc_srq_table_shift;
- int xrc_srq_table_mask;
-
- struct mlx4_db_page *db_list[MLX4_NUM_DB_TYPE];
- pthread_mutex_t db_list_mutex;
-};
-
-struct mlx4_buf {
- void *buf;
- size_t length;
-};
-
-struct mlx4_pd {
- struct ibv_pd ibv_pd;
- uint32_t pdn;
-};
-
-struct mlx4_cq {
- struct ibv_cq ibv_cq;
- struct mlx4_buf buf;
- struct mlx4_buf resize_buf;
- pthread_spinlock_t lock;
- uint32_t cqn;
- uint32_t cons_index;
- uint32_t *set_ci_db;
- uint32_t *arm_db;
- int arm_sn;
- int cqe_size;
-};
-
-struct mlx4_srq {
- struct ibv_srq ibv_srq;
- struct mlx4_buf buf;
- pthread_spinlock_t lock;
- uint64_t *wrid;
- uint32_t srqn;
- int max;
- int max_gs;
- int wqe_shift;
- int head;
- int tail;
- uint32_t *db;
- uint16_t counter;
-};
-
-struct mlx4_wq {
- uint64_t *wrid;
- pthread_spinlock_t lock;
- int wqe_cnt;
- int max_post;
- unsigned head;
- unsigned tail;
- int max_gs;
- int wqe_shift;
- int offset;
-};
-
-struct mlx4_qp {
- struct ibv_qp ibv_qp;
- struct mlx4_buf buf;
- int max_inline_data;
- int buf_size;
-
- uint32_t doorbell_qpn;
- uint32_t sq_signal_bits;
- int sq_spare_wqes;
- struct mlx4_wq sq;
-
- uint32_t *db;
- struct mlx4_wq rq;
-};
-
-struct mlx4_av {
- uint32_t port_pd;
- uint8_t reserved1;
- uint8_t g_slid;
- uint16_t dlid;
- uint8_t reserved2;
- uint8_t gid_index;
- uint8_t stat_rate;
- uint8_t hop_limit;
- uint32_t sl_tclass_flowlabel;
- uint8_t dgid[16];
- uint8_t mac[8];
-};
-
-struct mlx4_ah {
- struct ibv_ah ibv_ah;
- struct mlx4_av av;
- uint16_t vlan;
- uint8_t mac[6];
- uint8_t tagged;
-};
-
-struct mlx4_xrc_domain {
- struct ibv_xrc_domain ibv_xrcd;
- uint32_t xrcdn;
-};
-
-static inline unsigned long align(unsigned long val, unsigned long align)
-{
- return (val + align - 1) & ~(align - 1);
-}
-
-#define to_mxxx(xxx, type) \
- ((struct mlx4_##type *) \
- ((void *) ib##xxx - offsetof(struct mlx4_##type, ibv_##xxx)))
-
-static inline struct mlx4_device *to_mdev(struct ibv_device *ibdev)
-{
- return to_mxxx(dev, device);
-}
-
-static inline struct mlx4_context *to_mctx(struct ibv_context *ibctx)
-{
- return to_mxxx(ctx, context);
-}
-
-static inline struct mlx4_pd *to_mpd(struct ibv_pd *ibpd)
-{
- return to_mxxx(pd, pd);
-}
-
-static inline struct mlx4_cq *to_mcq(struct ibv_cq *ibcq)
-{
- return to_mxxx(cq, cq);
-}
-
-static inline struct mlx4_srq *to_msrq(struct ibv_srq *ibsrq)
-{
- return to_mxxx(srq, srq);
-}
-
-static inline struct mlx4_qp *to_mqp(struct ibv_qp *ibqp)
-{
- return to_mxxx(qp, qp);
-}
-
-static inline struct mlx4_ah *to_mah(struct ibv_ah *ibah)
-{
- return to_mxxx(ah, ah);
-}
-
-#ifdef HAVE_IBV_XRC_OPS
-static inline struct mlx4_xrc_domain *to_mxrcd(struct ibv_xrc_domain *ibxrcd)
-{
- return to_mxxx(xrcd, xrc_domain);
-}
-#endif
-
-int mlx4_alloc_buf(struct mlx4_buf *buf, size_t size, int page_size);
-void mlx4_free_buf(struct mlx4_buf *buf);
-
-uint32_t *mlx4_alloc_db(struct mlx4_context *context, enum mlx4_db_type type);
-void mlx4_free_db(struct mlx4_context *context, enum mlx4_db_type type, uint32_t *db);
-
-int mlx4_query_device(struct ibv_context *context,
- struct ibv_device_attr *attr);
-int mlx4_query_port(struct ibv_context *context, uint8_t port,
- struct ibv_port_attr *attr);
-
-struct ibv_pd *mlx4_alloc_pd(struct ibv_context *context);
-int mlx4_free_pd(struct ibv_pd *pd);
-
-struct ibv_mr *mlx4_reg_mr(struct ibv_pd *pd, void *addr,
- size_t length, enum ibv_access_flags access);
-int mlx4_dereg_mr(struct ibv_mr *mr);
-
-struct ibv_cq *mlx4_create_cq(struct ibv_context *context, int cqe,
- struct ibv_comp_channel *channel,
- int comp_vector);
-int mlx4_alloc_cq_buf(struct mlx4_device *dev, struct mlx4_buf *buf, int nent,
- int entry_size);
-int mlx4_resize_cq(struct ibv_cq *cq, int cqe);
-int mlx4_destroy_cq(struct ibv_cq *cq);
-int mlx4_poll_cq(struct ibv_cq *cq, int ne, struct ibv_wc *wc);
-int mlx4_arm_cq(struct ibv_cq *cq, int solicited);
-void mlx4_cq_event(struct ibv_cq *cq);
-void __mlx4_cq_clean(struct mlx4_cq *cq, uint32_t qpn, struct mlx4_srq *srq);
-void mlx4_cq_clean(struct mlx4_cq *cq, uint32_t qpn, struct mlx4_srq *srq);
-int mlx4_get_outstanding_cqes(struct mlx4_cq *cq);
-void mlx4_cq_resize_copy_cqes(struct mlx4_cq *cq, void *buf, int new_cqe);
-
-struct ibv_srq *mlx4_create_srq(struct ibv_pd *pd,
- struct ibv_srq_init_attr *attr);
-int mlx4_modify_srq(struct ibv_srq *srq,
- struct ibv_srq_attr *attr,
- enum ibv_srq_attr_mask mask);
-int mlx4_query_srq(struct ibv_srq *srq,
- struct ibv_srq_attr *attr);
-int mlx4_destroy_srq(struct ibv_srq *srq);
-int mlx4_alloc_srq_buf(struct ibv_pd *pd, struct ibv_srq_attr *attr,
- struct mlx4_srq *srq);
-void mlx4_free_srq_wqe(struct mlx4_srq *srq, int ind);
-int mlx4_post_srq_recv(struct ibv_srq *ibsrq,
- struct ibv_recv_wr *wr,
- struct ibv_recv_wr **bad_wr);
-struct mlx4_srq *mlx4_find_xrc_srq(struct mlx4_context *ctx, uint32_t xrc_srqn);
-int mlx4_store_xrc_srq(struct mlx4_context *ctx, uint32_t xrc_srqn,
- struct mlx4_srq *srq);
-void mlx4_clear_xrc_srq(struct mlx4_context *ctx, uint32_t xrc_srqn);
-
-struct ibv_qp *mlx4_create_qp(struct ibv_pd *pd, struct ibv_qp_init_attr *attr);
-int mlx4_query_qp(struct ibv_qp *qp, struct ibv_qp_attr *attr,
- enum ibv_qp_attr_mask attr_mask,
- struct ibv_qp_init_attr *init_attr);
-int mlx4_modify_qp(struct ibv_qp *qp, struct ibv_qp_attr *attr,
- enum ibv_qp_attr_mask attr_mask);
-int mlx4_destroy_qp(struct ibv_qp *qp);
-void mlx4_init_qp_indices(struct mlx4_qp *qp);
-void mlx4_qp_init_sq_ownership(struct mlx4_qp *qp);
-int mlx4_post_send(struct ibv_qp *ibqp, struct ibv_send_wr *wr,
- struct ibv_send_wr **bad_wr);
-int mlx4_post_recv(struct ibv_qp *ibqp, struct ibv_recv_wr *wr,
- struct ibv_recv_wr **bad_wr);
-void mlx4_calc_sq_wqe_size(struct ibv_qp_cap *cap, enum ibv_qp_type type,
- struct mlx4_qp *qp);
-int num_inline_segs(int data, enum ibv_qp_type type);
-int mlx4_alloc_qp_buf(struct ibv_pd *pd, struct ibv_qp_cap *cap,
- enum ibv_qp_type type, struct mlx4_qp *qp);
-void mlx4_set_sq_sizes(struct mlx4_qp *qp, struct ibv_qp_cap *cap,
- enum ibv_qp_type type);
-struct mlx4_qp *mlx4_find_qp(struct mlx4_context *ctx, uint32_t qpn);
-int mlx4_store_qp(struct mlx4_context *ctx, uint32_t qpn, struct mlx4_qp *qp);
-void mlx4_clear_qp(struct mlx4_context *ctx, uint32_t qpn);
-struct ibv_ah *mlx4_create_ah(struct ibv_pd *pd, struct ibv_ah_attr *attr);
-int mlx4_destroy_ah(struct ibv_ah *ah);
-int mlx4_alloc_av(struct mlx4_pd *pd, struct ibv_ah_attr *attr,
- struct mlx4_ah *ah);
-void mlx4_free_av(struct mlx4_ah *ah);
-#ifdef HAVE_IBV_XRC_OPS
-struct ibv_srq *mlx4_create_xrc_srq(struct ibv_pd *pd,
- struct ibv_xrc_domain *xrc_domain,
- struct ibv_cq *xrc_cq,
- struct ibv_srq_init_attr *attr);
-struct ibv_xrc_domain *mlx4_open_xrc_domain(struct ibv_context *context,
- int fd, int oflag);
-
-int mlx4_close_xrc_domain(struct ibv_xrc_domain *d);
-int mlx4_create_xrc_rcv_qp(struct ibv_qp_init_attr *init_attr,
- uint32_t *xrc_qp_num);
-int mlx4_modify_xrc_rcv_qp(struct ibv_xrc_domain *xrc_domain,
- uint32_t xrc_qp_num,
- struct ibv_qp_attr *attr,
- int attr_mask);
-int mlx4_query_xrc_rcv_qp(struct ibv_xrc_domain *xrc_domain,
- uint32_t xrc_qp_num,
- struct ibv_qp_attr *attr,
- int attr_mask,
- struct ibv_qp_init_attr *init_attr);
-int mlx4_reg_xrc_rcv_qp(struct ibv_xrc_domain *xrc_domain,
- uint32_t xrc_qp_num);
-int mlx4_unreg_xrc_rcv_qp(struct ibv_xrc_domain *xrc_domain,
- uint32_t xrc_qp_num);
-#endif
-
-
-#endif /* MLX4_H */
diff --git a/contrib/ofed/libmlx4/src/mlx4.map b/contrib/ofed/libmlx4/src/mlx4.map
deleted file mode 100644
index ae8ed86..0000000
--- a/contrib/ofed/libmlx4/src/mlx4.map
+++ /dev/null
@@ -1,5 +0,0 @@
-{
- global:
- openib_driver_init;
- local: *;
-};
diff --git a/contrib/ofed/libmlx4/src/qp.c b/contrib/ofed/libmlx4/src/qp.c
deleted file mode 100644
index 4586ea7..0000000
--- a/contrib/ofed/libmlx4/src/qp.c
+++ /dev/null
@@ -1,706 +0,0 @@
-/*
- * Copyright (c) 2005 Topspin Communications. All rights reserved.
- * Copyright (c) 2005 Mellanox Technologies Ltd. All rights reserved.
- * Copyright (c) 2007 Cisco, Inc. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-#if HAVE_CONFIG_H
-# include <config.h>
-#endif /* HAVE_CONFIG_H */
-
-#include <stdlib.h>
-#include <netinet/in.h>
-#include <pthread.h>
-#include <string.h>
-
-#include "mlx4.h"
-#include "doorbell.h"
-#include "wqe.h"
-
-static const uint32_t mlx4_ib_opcode[] = {
- [IBV_WR_SEND] = MLX4_OPCODE_SEND,
- [IBV_WR_SEND_WITH_IMM] = MLX4_OPCODE_SEND_IMM,
- [IBV_WR_RDMA_WRITE] = MLX4_OPCODE_RDMA_WRITE,
- [IBV_WR_RDMA_WRITE_WITH_IMM] = MLX4_OPCODE_RDMA_WRITE_IMM,
- [IBV_WR_RDMA_READ] = MLX4_OPCODE_RDMA_READ,
- [IBV_WR_ATOMIC_CMP_AND_SWP] = MLX4_OPCODE_ATOMIC_CS,
- [IBV_WR_ATOMIC_FETCH_AND_ADD] = MLX4_OPCODE_ATOMIC_FA,
-};
-
-static void *get_recv_wqe(struct mlx4_qp *qp, int n)
-{
- return qp->buf.buf + qp->rq.offset + (n << qp->rq.wqe_shift);
-}
-
-static void *get_send_wqe(struct mlx4_qp *qp, int n)
-{
- return qp->buf.buf + qp->sq.offset + (n << qp->sq.wqe_shift);
-}
-
-/*
- * Stamp a SQ WQE so that it is invalid if prefetched by marking the
- * first four bytes of every 64 byte chunk with 0xffffffff, except for
- * the very first chunk of the WQE.
- */
-static void stamp_send_wqe(struct mlx4_qp *qp, int n)
-{
- uint32_t *wqe = get_send_wqe(qp, n);
- int i;
- int ds = (((struct mlx4_wqe_ctrl_seg *)wqe)->fence_size & 0x3f) << 2;
-
- for (i = 16; i < ds; i += 16)
- wqe[i] = 0xffffffff;
-}
-
-void mlx4_init_qp_indices(struct mlx4_qp *qp)
-{
- qp->sq.head = 0;
- qp->sq.tail = 0;
- qp->rq.head = 0;
- qp->rq.tail = 0;
-}
-
-void mlx4_qp_init_sq_ownership(struct mlx4_qp *qp)
-{
- struct mlx4_wqe_ctrl_seg *ctrl;
- int i;
-
- for (i = 0; i < qp->sq.wqe_cnt; ++i) {
- ctrl = get_send_wqe(qp, i);
- ctrl->owner_opcode = htonl(1 << 31);
- ctrl->fence_size = 1 << (qp->sq.wqe_shift - 4);
-
- stamp_send_wqe(qp, i);
- }
-}
-
-static int wq_overflow(struct mlx4_wq *wq, int nreq, struct mlx4_cq *cq)
-{
- unsigned cur;
-
- cur = wq->head - wq->tail;
- if (cur + nreq < wq->max_post)
- return 0;
-
- pthread_spin_lock(&cq->lock);
- cur = wq->head - wq->tail;
- pthread_spin_unlock(&cq->lock);
-
- return cur + nreq >= wq->max_post;
-}
-
-static inline void set_raddr_seg(struct mlx4_wqe_raddr_seg *rseg,
- uint64_t remote_addr, uint32_t rkey)
-{
- rseg->raddr = htonll(remote_addr);
- rseg->rkey = htonl(rkey);
- rseg->reserved = 0;
-}
-
-static void set_atomic_seg(struct mlx4_wqe_atomic_seg *aseg, struct ibv_send_wr *wr)
-{
- if (wr->opcode == IBV_WR_ATOMIC_CMP_AND_SWP) {
- aseg->swap_add = htonll(wr->wr.atomic.swap);
- aseg->compare = htonll(wr->wr.atomic.compare_add);
- } else {
- aseg->swap_add = htonll(wr->wr.atomic.compare_add);
- aseg->compare = 0;
- }
-
-}
-
-static void set_datagram_seg(struct mlx4_wqe_datagram_seg *dseg,
- struct ibv_send_wr *wr)
-{
- memcpy(dseg->av, &to_mah(wr->wr.ud.ah)->av, sizeof (struct mlx4_av));
- dseg->dqpn = htonl(wr->wr.ud.remote_qpn);
- dseg->qkey = htonl(wr->wr.ud.remote_qkey);
- dseg->vlan = htons(to_mah(wr->wr.ud.ah)->vlan);
- memcpy(dseg->mac, to_mah(wr->wr.ud.ah)->mac, 6);
-}
-
-static void __set_data_seg(struct mlx4_wqe_data_seg *dseg, struct ibv_sge *sg)
-{
- dseg->byte_count = htonl(sg->length);
- dseg->lkey = htonl(sg->lkey);
- dseg->addr = htonll(sg->addr);
-}
-
-static void set_data_seg(struct mlx4_wqe_data_seg *dseg, struct ibv_sge *sg)
-{
- dseg->lkey = htonl(sg->lkey);
- dseg->addr = htonll(sg->addr);
-
- /*
- * Need a barrier here before writing the byte_count field to
- * make sure that all the data is visible before the
- * byte_count field is set. Otherwise, if the segment begins
- * a new cacheline, the HCA prefetcher could grab the 64-byte
- * chunk and get a valid (!= * 0xffffffff) byte count but
- * stale data, and end up sending the wrong data.
- */
- wmb();
-
- dseg->byte_count = htonl(sg->length);
-}
-
-/*
- * Avoid using memcpy() to copy to BlueFlame page, since memcpy()
- * implementations may use move-string-buffer assembler instructions,
- * which do not guarantee order of copying.
- */
-static void mlx4_bf_copy(unsigned long *dst, unsigned long *src, unsigned bytecnt)
-{
- while (bytecnt > 0) {
- *dst++ = *src++;
- *dst++ = *src++;
- bytecnt -= 2 * sizeof (long);
- }
-}
-
-int mlx4_post_send(struct ibv_qp *ibqp, struct ibv_send_wr *wr,
- struct ibv_send_wr **bad_wr)
-{
- struct mlx4_context *ctx;
- struct mlx4_qp *qp = to_mqp(ibqp);
- void *wqe;
- struct mlx4_wqe_ctrl_seg *ctrl;
- int ind;
- int nreq;
- int inl = 0;
- int ret = 0;
- int size;
- int i;
-
- pthread_spin_lock(&qp->sq.lock);
-
- /* XXX check that state is OK to post send */
-
- ind = qp->sq.head;
-
- for (nreq = 0; wr; ++nreq, wr = wr->next) {
- if (wq_overflow(&qp->sq, nreq, to_mcq(qp->ibv_qp.send_cq))) {
- ret = -1;
- *bad_wr = wr;
- goto out;
- }
-
- if (wr->num_sge > qp->sq.max_gs) {
- ret = -1;
- *bad_wr = wr;
- goto out;
- }
-
- if (wr->opcode >= sizeof mlx4_ib_opcode / sizeof mlx4_ib_opcode[0]) {
- ret = -1;
- *bad_wr = wr;
- goto out;
- }
-
- ctrl = wqe = get_send_wqe(qp, ind & (qp->sq.wqe_cnt - 1));
- qp->sq.wrid[ind & (qp->sq.wqe_cnt - 1)] = wr->wr_id;
-
- ctrl->xrcrb_flags =
- (wr->send_flags & IBV_SEND_SIGNALED ?
- htonl(MLX4_WQE_CTRL_CQ_UPDATE) : 0) |
- (wr->send_flags & IBV_SEND_SOLICITED ?
- htonl(MLX4_WQE_CTRL_SOLICIT) : 0) |
- qp->sq_signal_bits;
-
- if (wr->opcode == IBV_WR_SEND_WITH_IMM ||
- wr->opcode == IBV_WR_RDMA_WRITE_WITH_IMM)
- ctrl->imm = wr->imm_data;
- else
- ctrl->imm = 0;
-
- wqe += sizeof *ctrl;
- size = sizeof *ctrl / 16;
-
- switch (ibqp->qp_type) {
- case IBV_QPT_XRC:
- ctrl->xrcrb_flags |= htonl(wr->xrc_remote_srq_num << 8);
- /* fall thru */
- case IBV_QPT_RC:
- case IBV_QPT_UC:
- switch (wr->opcode) {
- case IBV_WR_ATOMIC_CMP_AND_SWP:
- case IBV_WR_ATOMIC_FETCH_AND_ADD:
- set_raddr_seg(wqe, wr->wr.atomic.remote_addr,
- wr->wr.atomic.rkey);
- wqe += sizeof (struct mlx4_wqe_raddr_seg);
-
- set_atomic_seg(wqe, wr);
- wqe += sizeof (struct mlx4_wqe_atomic_seg);
- size += (sizeof (struct mlx4_wqe_raddr_seg) +
- sizeof (struct mlx4_wqe_atomic_seg)) / 16;
-
- break;
-
- case IBV_WR_RDMA_READ:
- inl = 1;
- /* fall through */
- case IBV_WR_RDMA_WRITE:
- case IBV_WR_RDMA_WRITE_WITH_IMM:
- set_raddr_seg(wqe, wr->wr.rdma.remote_addr,
- wr->wr.rdma.rkey);
- wqe += sizeof (struct mlx4_wqe_raddr_seg);
- size += sizeof (struct mlx4_wqe_raddr_seg) / 16;
-
- break;
-
- default:
- /* No extra segments required for sends */
- break;
- }
- break;
-
- case IBV_QPT_UD:
- set_datagram_seg(wqe, wr);
- wqe += sizeof (struct mlx4_wqe_datagram_seg);
- size += sizeof (struct mlx4_wqe_datagram_seg) / 16;
- if (to_mah(wr->wr.ud.ah)->tagged) {
- ctrl->ins_vlan = 1 << 6;
- ctrl->vlan_tag = htons(to_mah(wr->wr.ud.ah)->vlan);
- }
-
- break;
-
- default:
- break;
- }
-
- if (wr->send_flags & IBV_SEND_INLINE && wr->num_sge) {
- struct mlx4_wqe_inline_seg *seg;
- void *addr;
- int len, seg_len;
- int num_seg;
- int off, to_copy;
-
- inl = 0;
-
- seg = wqe;
- wqe += sizeof *seg;
- off = ((uintptr_t) wqe) & (MLX4_INLINE_ALIGN - 1);
- num_seg = 0;
- seg_len = 0;
-
- for (i = 0; i < wr->num_sge; ++i) {
- addr = (void *) (uintptr_t) wr->sg_list[i].addr;
- len = wr->sg_list[i].length;
- inl += len;
-
- if (inl > qp->max_inline_data) {
- inl = 0;
- ret = -1;
- *bad_wr = wr;
- goto out;
- }
-
- while (len >= MLX4_INLINE_ALIGN - off) {
- to_copy = MLX4_INLINE_ALIGN - off;
- memcpy(wqe, addr, to_copy);
- len -= to_copy;
- wqe += to_copy;
- addr += to_copy;
- seg_len += to_copy;
- wmb(); /* see comment below */
- seg->byte_count = htonl(MLX4_INLINE_SEG | seg_len);
- seg_len = 0;
- seg = wqe;
- wqe += sizeof *seg;
- off = sizeof *seg;
- ++num_seg;
- }
-
- memcpy(wqe, addr, len);
- wqe += len;
- seg_len += len;
- off += len;
- }
-
- if (seg_len) {
- ++num_seg;
- /*
- * Need a barrier here to make sure
- * all the data is visible before the
- * byte_count field is set. Otherwise
- * the HCA prefetcher could grab the
- * 64-byte chunk with this inline
- * segment and get a valid (!=
- * 0xffffffff) byte count but stale
- * data, and end up sending the wrong
- * data.
- */
- wmb();
- seg->byte_count = htonl(MLX4_INLINE_SEG | seg_len);
- }
-
- size += (inl + num_seg * sizeof * seg + 15) / 16;
- } else {
- struct mlx4_wqe_data_seg *seg = wqe;
-
- for (i = wr->num_sge - 1; i >= 0 ; --i)
- set_data_seg(seg + i, wr->sg_list + i);
-
- size += wr->num_sge * (sizeof *seg / 16);
- }
-
- ctrl->fence_size = (wr->send_flags & IBV_SEND_FENCE ?
- MLX4_WQE_CTRL_FENCE : 0) | size;
-
- /*
- * Make sure descriptor is fully written before
- * setting ownership bit (because HW can start
- * executing as soon as we do).
- */
- wmb();
-
- ctrl->owner_opcode = htonl(mlx4_ib_opcode[wr->opcode]) |
- (ind & qp->sq.wqe_cnt ? htonl(1 << 31) : 0);
-
- /*
- * We can improve latency by not stamping the last
- * send queue WQE until after ringing the doorbell, so
- * only stamp here if there are still more WQEs to post.
- */
- if (wr->next)
- stamp_send_wqe(qp, (ind + qp->sq_spare_wqes) &
- (qp->sq.wqe_cnt - 1));
-
- ++ind;
- }
-
-out:
- ctx = to_mctx(ibqp->context);
-
- if (nreq == 1 && inl && size > 1 && size < ctx->bf_buf_size / 16) {
- ctrl->owner_opcode |= htonl((qp->sq.head & 0xffff) << 8);
- *(uint32_t *) (&ctrl->vlan_tag) |= qp->doorbell_qpn;
- /*
- * Make sure that descriptor is written to memory
- * before writing to BlueFlame page.
- */
- wmb();
-
- ++qp->sq.head;
-
- pthread_spin_lock(&ctx->bf_lock);
-
- mlx4_bf_copy(ctx->bf_page + ctx->bf_offset, (unsigned long *) ctrl,
- align(size * 16, 64));
- wc_wmb();
-
- ctx->bf_offset ^= ctx->bf_buf_size;
-
- pthread_spin_unlock(&ctx->bf_lock);
- } else if (nreq) {
- qp->sq.head += nreq;
-
- /*
- * Make sure that descriptors are written before
- * doorbell record.
- */
- wmb();
-
- *(uint32_t *) (ctx->uar + MLX4_SEND_DOORBELL) = qp->doorbell_qpn;
- }
-
- if (nreq)
- stamp_send_wqe(qp, (ind + qp->sq_spare_wqes - 1) &
- (qp->sq.wqe_cnt - 1));
-
- pthread_spin_unlock(&qp->sq.lock);
-
- return ret;
-}
-
-int mlx4_post_recv(struct ibv_qp *ibqp, struct ibv_recv_wr *wr,
- struct ibv_recv_wr **bad_wr)
-{
- struct mlx4_qp *qp = to_mqp(ibqp);
- struct mlx4_wqe_data_seg *scat;
- int ret = 0;
- int nreq;
- int ind;
- int i;
-
- pthread_spin_lock(&qp->rq.lock);
-
- /* XXX check that state is OK to post receive */
-
- ind = qp->rq.head & (qp->rq.wqe_cnt - 1);
-
- for (nreq = 0; wr; ++nreq, wr = wr->next) {
- if (wq_overflow(&qp->rq, nreq, to_mcq(qp->ibv_qp.recv_cq))) {
- ret = -1;
- *bad_wr = wr;
- goto out;
- }
-
- if (wr->num_sge > qp->rq.max_gs) {
- ret = -1;
- *bad_wr = wr;
- goto out;
- }
-
- scat = get_recv_wqe(qp, ind);
-
- for (i = 0; i < wr->num_sge; ++i)
- __set_data_seg(scat + i, wr->sg_list + i);
-
- if (i < qp->rq.max_gs) {
- scat[i].byte_count = 0;
- scat[i].lkey = htonl(MLX4_INVALID_LKEY);
- scat[i].addr = 0;
- }
-
- qp->rq.wrid[ind] = wr->wr_id;
-
- ind = (ind + 1) & (qp->rq.wqe_cnt - 1);
- }
-
-out:
- if (nreq) {
- qp->rq.head += nreq;
-
- /*
- * Make sure that descriptors are written before
- * doorbell record.
- */
- wmb();
-
- *qp->db = htonl(qp->rq.head & 0xffff);
- }
-
- pthread_spin_unlock(&qp->rq.lock);
-
- return ret;
-}
-
-int num_inline_segs(int data, enum ibv_qp_type type)
-{
- /*
- * Inline data segments are not allowed to cross 64 byte
- * boundaries. For UD QPs, the data segments always start
- * aligned to 64 bytes (16 byte control segment + 48 byte
- * datagram segment); for other QPs, there will be a 16 byte
- * control segment and possibly a 16 byte remote address
- * segment, so in the worst case there will be only 32 bytes
- * available for the first data segment.
- */
- if (type == IBV_QPT_UD)
- data += (sizeof (struct mlx4_wqe_ctrl_seg) +
- sizeof (struct mlx4_wqe_datagram_seg)) %
- MLX4_INLINE_ALIGN;
- else
- data += (sizeof (struct mlx4_wqe_ctrl_seg) +
- sizeof (struct mlx4_wqe_raddr_seg)) %
- MLX4_INLINE_ALIGN;
-
- return (data + MLX4_INLINE_ALIGN - sizeof (struct mlx4_wqe_inline_seg) - 1) /
- (MLX4_INLINE_ALIGN - sizeof (struct mlx4_wqe_inline_seg));
-}
-
-void mlx4_calc_sq_wqe_size(struct ibv_qp_cap *cap, enum ibv_qp_type type,
- struct mlx4_qp *qp)
-{
- int size;
- int max_sq_sge;
-
- max_sq_sge = align(cap->max_inline_data +
- num_inline_segs(cap->max_inline_data, type) *
- sizeof (struct mlx4_wqe_inline_seg),
- sizeof (struct mlx4_wqe_data_seg)) /
- sizeof (struct mlx4_wqe_data_seg);
- if (max_sq_sge < cap->max_send_sge)
- max_sq_sge = cap->max_send_sge;
-
- size = max_sq_sge * sizeof (struct mlx4_wqe_data_seg);
- switch (type) {
- case IBV_QPT_UD:
- size += sizeof (struct mlx4_wqe_datagram_seg);
- break;
-
- case IBV_QPT_UC:
- size += sizeof (struct mlx4_wqe_raddr_seg);
- break;
-
- case IBV_QPT_XRC:
- case IBV_QPT_RC:
- size += sizeof (struct mlx4_wqe_raddr_seg);
- /*
- * An atomic op will require an atomic segment, a
- * remote address segment and one scatter entry.
- */
- if (size < (sizeof (struct mlx4_wqe_atomic_seg) +
- sizeof (struct mlx4_wqe_raddr_seg) +
- sizeof (struct mlx4_wqe_data_seg)))
- size = (sizeof (struct mlx4_wqe_atomic_seg) +
- sizeof (struct mlx4_wqe_raddr_seg) +
- sizeof (struct mlx4_wqe_data_seg));
- break;
-
- default:
- break;
- }
-
- /* Make sure that we have enough space for a bind request */
- if (size < sizeof (struct mlx4_wqe_bind_seg))
- size = sizeof (struct mlx4_wqe_bind_seg);
-
- size += sizeof (struct mlx4_wqe_ctrl_seg);
-
- for (qp->sq.wqe_shift = 6; 1 << qp->sq.wqe_shift < size;
- qp->sq.wqe_shift++)
- ; /* nothing */
-}
-
-int mlx4_alloc_qp_buf(struct ibv_pd *pd, struct ibv_qp_cap *cap,
- enum ibv_qp_type type, struct mlx4_qp *qp)
-{
- qp->rq.max_gs = cap->max_recv_sge;
-
- qp->sq.wrid = malloc(qp->sq.wqe_cnt * sizeof (uint64_t));
- if (!qp->sq.wrid)
- return -1;
-
- if (qp->rq.wqe_cnt) {
- qp->rq.wrid = malloc(qp->rq.wqe_cnt * sizeof (uint64_t));
- if (!qp->rq.wrid) {
- free(qp->sq.wrid);
- return -1;
- }
- }
-
- for (qp->rq.wqe_shift = 4;
- 1 << qp->rq.wqe_shift < qp->rq.max_gs * sizeof (struct mlx4_wqe_data_seg);
- qp->rq.wqe_shift++)
- ; /* nothing */
-
- qp->buf_size = (qp->rq.wqe_cnt << qp->rq.wqe_shift) +
- (qp->sq.wqe_cnt << qp->sq.wqe_shift);
- if (qp->rq.wqe_shift > qp->sq.wqe_shift) {
- qp->rq.offset = 0;
- qp->sq.offset = qp->rq.wqe_cnt << qp->rq.wqe_shift;
- } else {
- qp->rq.offset = qp->sq.wqe_cnt << qp->sq.wqe_shift;
- qp->sq.offset = 0;
- }
-
- if (mlx4_alloc_buf(&qp->buf,
- align(qp->buf_size, to_mdev(pd->context->device)->page_size),
- to_mdev(pd->context->device)->page_size)) {
- free(qp->sq.wrid);
- free(qp->rq.wrid);
- return -1;
- }
-
- memset(qp->buf.buf, 0, qp->buf_size);
-
- return 0;
-}
-
-void mlx4_set_sq_sizes(struct mlx4_qp *qp, struct ibv_qp_cap *cap,
- enum ibv_qp_type type)
-{
- int wqe_size;
- struct mlx4_context *ctx = to_mctx(qp->ibv_qp.context);
-
- wqe_size = min((1 << qp->sq.wqe_shift), MLX4_MAX_WQE_SIZE) -
- sizeof (struct mlx4_wqe_ctrl_seg);
- switch (type) {
- case IBV_QPT_UD:
- wqe_size -= sizeof (struct mlx4_wqe_datagram_seg);
- break;
-
- case IBV_QPT_UC:
- case IBV_QPT_RC:
- case IBV_QPT_XRC:
- wqe_size -= sizeof (struct mlx4_wqe_raddr_seg);
- break;
-
- default:
- break;
- }
-
- qp->sq.max_gs = wqe_size / sizeof (struct mlx4_wqe_data_seg);
- cap->max_send_sge = min(ctx->max_sge, qp->sq.max_gs);
- qp->sq.max_post = min(ctx->max_qp_wr,
- qp->sq.wqe_cnt - qp->sq_spare_wqes);
- cap->max_send_wr = qp->sq.max_post;
-
- /*
- * Inline data segments can't cross a 64 byte boundary. So
- * subtract off one segment header for each 64-byte chunk,
- * taking into account the fact that wqe_size will be 32 mod
- * 64 for non-UD QPs.
- */
- qp->max_inline_data = wqe_size -
- sizeof (struct mlx4_wqe_inline_seg) *
- (align(wqe_size, MLX4_INLINE_ALIGN) / MLX4_INLINE_ALIGN);
- cap->max_inline_data = qp->max_inline_data;
-}
-
-struct mlx4_qp *mlx4_find_qp(struct mlx4_context *ctx, uint32_t qpn)
-{
- int tind = (qpn & (ctx->num_qps - 1)) >> ctx->qp_table_shift;
-
- if (ctx->qp_table[tind].refcnt)
- return ctx->qp_table[tind].table[qpn & ctx->qp_table_mask];
- else
- return NULL;
-}
-
-int mlx4_store_qp(struct mlx4_context *ctx, uint32_t qpn, struct mlx4_qp *qp)
-{
- int tind = (qpn & (ctx->num_qps - 1)) >> ctx->qp_table_shift;
-
- if (!ctx->qp_table[tind].refcnt) {
- ctx->qp_table[tind].table = calloc(ctx->qp_table_mask + 1,
- sizeof (struct mlx4_qp *));
- if (!ctx->qp_table[tind].table)
- return -1;
- }
-
- ++ctx->qp_table[tind].refcnt;
- ctx->qp_table[tind].table[qpn & ctx->qp_table_mask] = qp;
- return 0;
-}
-
-void mlx4_clear_qp(struct mlx4_context *ctx, uint32_t qpn)
-{
- int tind = (qpn & (ctx->num_qps - 1)) >> ctx->qp_table_shift;
-
- if (!--ctx->qp_table[tind].refcnt)
- free(ctx->qp_table[tind].table);
- else
- ctx->qp_table[tind].table[qpn & ctx->qp_table_mask] = NULL;
-}
diff --git a/contrib/ofed/libmlx4/src/srq.c b/contrib/ofed/libmlx4/src/srq.c
deleted file mode 100644
index 6dfbe1b..0000000
--- a/contrib/ofed/libmlx4/src/srq.c
+++ /dev/null
@@ -1,225 +0,0 @@
-/*
- * Copyright (c) 2007 Cisco, Inc. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-#if HAVE_CONFIG_H
-# include <config.h>
-#endif /* HAVE_CONFIG_H */
-
-#include <stdlib.h>
-#include <netinet/in.h>
-#include <pthread.h>
-#include <string.h>
-
-#include "mlx4.h"
-#include "doorbell.h"
-#include "wqe.h"
-
-static void *get_wqe(struct mlx4_srq *srq, int n)
-{
- return srq->buf.buf + (n << srq->wqe_shift);
-}
-
-void mlx4_free_srq_wqe(struct mlx4_srq *srq, int ind)
-{
- struct mlx4_wqe_srq_next_seg *next;
-
- pthread_spin_lock(&srq->lock);
-
- next = get_wqe(srq, srq->tail);
- next->next_wqe_index = htons(ind);
- srq->tail = ind;
-
- pthread_spin_unlock(&srq->lock);
-}
-
-int mlx4_post_srq_recv(struct ibv_srq *ibsrq,
- struct ibv_recv_wr *wr,
- struct ibv_recv_wr **bad_wr)
-{
- struct mlx4_srq *srq = to_msrq(ibsrq);
- struct mlx4_wqe_srq_next_seg *next;
- struct mlx4_wqe_data_seg *scat;
- int err = 0;
- int nreq;
- int i;
-
- pthread_spin_lock(&srq->lock);
-
- for (nreq = 0; wr; ++nreq, wr = wr->next) {
- if (wr->num_sge > srq->max_gs) {
- err = -1;
- *bad_wr = wr;
- break;
- }
-
- if (srq->head == srq->tail) {
- /* SRQ is full*/
- err = -1;
- *bad_wr = wr;
- break;
- }
-
- srq->wrid[srq->head] = wr->wr_id;
-
- next = get_wqe(srq, srq->head);
- srq->head = ntohs(next->next_wqe_index);
- scat = (struct mlx4_wqe_data_seg *) (next + 1);
-
- for (i = 0; i < wr->num_sge; ++i) {
- scat[i].byte_count = htonl(wr->sg_list[i].length);
- scat[i].lkey = htonl(wr->sg_list[i].lkey);
- scat[i].addr = htonll(wr->sg_list[i].addr);
- }
-
- if (i < srq->max_gs) {
- scat[i].byte_count = 0;
- scat[i].lkey = htonl(MLX4_INVALID_LKEY);
- scat[i].addr = 0;
- }
- }
-
- if (nreq) {
- srq->counter += nreq;
-
- /*
- * Make sure that descriptors are written before
- * we write doorbell record.
- */
- wmb();
-
- *srq->db = htonl(srq->counter);
- }
-
- pthread_spin_unlock(&srq->lock);
-
- return err;
-}
-
-int mlx4_alloc_srq_buf(struct ibv_pd *pd, struct ibv_srq_attr *attr,
- struct mlx4_srq *srq)
-{
- struct mlx4_wqe_srq_next_seg *next;
- struct mlx4_wqe_data_seg *scatter;
- int size;
- int buf_size;
- int i;
-
- srq->wrid = malloc(srq->max * sizeof (uint64_t));
- if (!srq->wrid)
- return -1;
-
- size = sizeof (struct mlx4_wqe_srq_next_seg) +
- srq->max_gs * sizeof (struct mlx4_wqe_data_seg);
-
- for (srq->wqe_shift = 5; 1 << srq->wqe_shift < size; ++srq->wqe_shift)
- ; /* nothing */
-
- buf_size = srq->max << srq->wqe_shift;
-
- if (mlx4_alloc_buf(&srq->buf, buf_size,
- to_mdev(pd->context->device)->page_size)) {
- free(srq->wrid);
- return -1;
- }
-
- memset(srq->buf.buf, 0, buf_size);
-
- /*
- * Now initialize the SRQ buffer so that all of the WQEs are
- * linked into the list of free WQEs.
- */
-
- for (i = 0; i < srq->max; ++i) {
- next = get_wqe(srq, i);
- next->next_wqe_index = htons((i + 1) & (srq->max - 1));
-
- for (scatter = (void *) (next + 1);
- (void *) scatter < (void *) next + (1 << srq->wqe_shift);
- ++scatter)
- scatter->lkey = htonl(MLX4_INVALID_LKEY);
- }
-
- srq->head = 0;
- srq->tail = srq->max - 1;
-
- return 0;
-}
-
-struct mlx4_srq *mlx4_find_xrc_srq(struct mlx4_context *ctx, uint32_t xrc_srqn)
-{
- int tind = (xrc_srqn & (ctx->num_xrc_srqs - 1)) >> ctx->xrc_srq_table_shift;
-
- if (ctx->xrc_srq_table[tind].refcnt)
- return ctx->xrc_srq_table[tind].table[xrc_srqn & ctx->xrc_srq_table_mask];
- else
- return NULL;
-}
-
-int mlx4_store_xrc_srq(struct mlx4_context *ctx, uint32_t xrc_srqn,
- struct mlx4_srq *srq)
-{
- int tind = (xrc_srqn & (ctx->num_xrc_srqs - 1)) >> ctx->xrc_srq_table_shift;
- int ret = 0;
-
- pthread_mutex_lock(&ctx->xrc_srq_table_mutex);
-
- if (!ctx->xrc_srq_table[tind].refcnt) {
- ctx->xrc_srq_table[tind].table = calloc(ctx->xrc_srq_table_mask + 1,
- sizeof(struct mlx4_srq *));
- if (!ctx->xrc_srq_table[tind].table) {
- ret = -1;
- goto out;
- }
- }
-
- ++ctx->xrc_srq_table[tind].refcnt;
- ctx->xrc_srq_table[tind].table[xrc_srqn & ctx->xrc_srq_table_mask] = srq;
-
-out:
- pthread_mutex_unlock(&ctx->xrc_srq_table_mutex);
- return ret;
-}
-
-void mlx4_clear_xrc_srq(struct mlx4_context *ctx, uint32_t xrc_srqn)
-{
- int tind = (xrc_srqn & (ctx->num_xrc_srqs - 1)) >> ctx->xrc_srq_table_shift;
-
- pthread_mutex_lock(&ctx->xrc_srq_table_mutex);
-
- if (!--ctx->xrc_srq_table[tind].refcnt)
- free(ctx->xrc_srq_table[tind].table);
- else
- ctx->xrc_srq_table[tind].table[xrc_srqn & ctx->xrc_srq_table_mask] = NULL;
-
- pthread_mutex_unlock(&ctx->xrc_srq_table_mutex);
-}
-
diff --git a/contrib/ofed/libmlx4/src/verbs.c b/contrib/ofed/libmlx4/src/verbs.c
deleted file mode 100644
index 1a80698..0000000
--- a/contrib/ofed/libmlx4/src/verbs.c
+++ /dev/null
@@ -1,901 +0,0 @@
-/*
- * Copyright (c) 2007 Cisco, Inc. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-#if HAVE_CONFIG_H
-# include <config.h>
-#endif /* HAVE_CONFIG_H */
-
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-#include <pthread.h>
-#include <errno.h>
-#include <netinet/in.h>
-
-#include "mlx4.h"
-#include "mlx4-abi.h"
-#include "wqe.h"
-
-int mlx4_query_device(struct ibv_context *context, struct ibv_device_attr *attr)
-{
- struct ibv_query_device cmd;
- uint64_t raw_fw_ver;
- unsigned major, minor, sub_minor;
- int ret;
-
- ret = ibv_cmd_query_device(context, attr, &raw_fw_ver, &cmd, sizeof cmd);
- if (ret)
- return ret;
-
- major = (raw_fw_ver >> 32) & 0xffff;
- minor = (raw_fw_ver >> 16) & 0xffff;
- sub_minor = raw_fw_ver & 0xffff;
-
- snprintf(attr->fw_ver, sizeof attr->fw_ver,
- "%d.%d.%03d", major, minor, sub_minor);
-
- return 0;
-}
-
-int mlx4_query_port(struct ibv_context *context, uint8_t port,
- struct ibv_port_attr *attr)
-{
- struct ibv_query_port cmd;
-
- return ibv_cmd_query_port(context, port, attr, &cmd, sizeof cmd);
-}
-
-struct ibv_pd *mlx4_alloc_pd(struct ibv_context *context)
-{
- struct ibv_alloc_pd cmd;
- struct mlx4_alloc_pd_resp resp;
- struct mlx4_pd *pd;
-
- pd = malloc(sizeof *pd);
- if (!pd)
- return NULL;
-
- if (ibv_cmd_alloc_pd(context, &pd->ibv_pd, &cmd, sizeof cmd,
- &resp.ibv_resp, sizeof resp)) {
- free(pd);
- return NULL;
- }
-
- pd->pdn = resp.pdn;
-
- return &pd->ibv_pd;
-}
-
-int mlx4_free_pd(struct ibv_pd *pd)
-{
- int ret;
-
- ret = ibv_cmd_dealloc_pd(pd);
- if (ret)
- return ret;
-
- free(to_mpd(pd));
- return 0;
-}
-
-struct ibv_mr *mlx4_reg_mr(struct ibv_pd *pd, void *addr, size_t length,
- enum ibv_access_flags access)
-{
- struct ibv_mr *mr;
- struct ibv_reg_mr cmd;
- int ret;
-
- mr = malloc(sizeof *mr);
- if (!mr)
- return NULL;
-
-#ifdef IBV_CMD_REG_MR_HAS_RESP_PARAMS
- {
- struct ibv_reg_mr_resp resp;
-
- ret = ibv_cmd_reg_mr(pd, addr, length, (uintptr_t) addr,
- access, mr, &cmd, sizeof cmd,
- &resp, sizeof resp);
- }
-#else
- ret = ibv_cmd_reg_mr(pd, addr, length, (uintptr_t) addr, access, mr,
- &cmd, sizeof cmd);
-#endif
- if (ret) {
- free(mr);
- return NULL;
- }
-
- return mr;
-}
-
-int mlx4_dereg_mr(struct ibv_mr *mr)
-{
- int ret;
-
- ret = ibv_cmd_dereg_mr(mr);
- if (ret)
- return ret;
-
- free(mr);
- return 0;
-}
-
-static int align_queue_size(int req)
-{
- int nent;
-
- for (nent = 1; nent < req; nent <<= 1)
- ; /* nothing */
-
- return nent;
-}
-
-struct ibv_cq *mlx4_create_cq(struct ibv_context *context, int cqe,
- struct ibv_comp_channel *channel,
- int comp_vector)
-{
- struct mlx4_create_cq cmd;
- struct mlx4_create_cq_resp resp;
- struct mlx4_cq *cq;
- int ret;
- struct mlx4_context *mctx = to_mctx(context);
-
- /* Sanity check CQ size before proceeding */
- if (cqe > 0x3fffff)
- return NULL;
-
- cq = malloc(sizeof *cq);
- if (!cq)
- return NULL;
-
- cq->cons_index = 0;
-
- if (pthread_spin_init(&cq->lock, PTHREAD_PROCESS_PRIVATE))
- goto err;
-
- cqe = align_queue_size(cqe + 1);
-
- if (mlx4_alloc_cq_buf(to_mdev(context->device), &cq->buf, cqe, mctx->cqe_size))
- goto err;
-
- cq->cqe_size = mctx->cqe_size;
-
- cq->set_ci_db = mlx4_alloc_db(to_mctx(context), MLX4_DB_TYPE_CQ);
- if (!cq->set_ci_db)
- goto err_buf;
-
- cq->arm_db = cq->set_ci_db + 1;
- *cq->arm_db = 0;
- cq->arm_sn = 1;
- *cq->set_ci_db = 0;
-
- cmd.buf_addr = (uintptr_t) cq->buf.buf;
- cmd.db_addr = (uintptr_t) cq->set_ci_db;
-
- ret = ibv_cmd_create_cq(context, cqe - 1, channel, comp_vector,
- &cq->ibv_cq, &cmd.ibv_cmd, sizeof cmd,
- &resp.ibv_resp, sizeof resp);
- if (ret)
- goto err_db;
-
- cq->cqn = resp.cqn;
-
- return &cq->ibv_cq;
-
-err_db:
- mlx4_free_db(to_mctx(context), MLX4_DB_TYPE_CQ, cq->set_ci_db);
-
-err_buf:
- mlx4_free_buf(&cq->buf);
-
-err:
- free(cq);
-
- return NULL;
-}
-
-int mlx4_resize_cq(struct ibv_cq *ibcq, int cqe)
-{
- struct mlx4_cq *cq = to_mcq(ibcq);
- struct mlx4_resize_cq cmd;
- struct mlx4_buf buf;
- int old_cqe, outst_cqe, ret;
-
- /* Sanity check CQ size before proceeding */
- if (cqe > 0x3fffff)
- return EINVAL;
-
- pthread_spin_lock(&cq->lock);
-
- cqe = align_queue_size(cqe + 1);
- if (cqe == ibcq->cqe + 1) {
- ret = 0;
- goto out;
- }
-
- /* Can't be smaller then the number of outstanding CQEs */
- outst_cqe = mlx4_get_outstanding_cqes(cq);
- if (cqe < outst_cqe + 1) {
- ret = 0;
- goto out;
- }
-
- ret = mlx4_alloc_cq_buf(to_mdev(ibcq->context->device), &buf, cqe,
- cq->cqe_size);
- if (ret)
- goto out;
-
- old_cqe = ibcq->cqe;
- cmd.buf_addr = (uintptr_t) buf.buf;
-
-#ifdef IBV_CMD_RESIZE_CQ_HAS_RESP_PARAMS
- {
- struct ibv_resize_cq_resp resp;
- ret = ibv_cmd_resize_cq(ibcq, cqe - 1, &cmd.ibv_cmd, sizeof cmd,
- &resp, sizeof resp);
- }
-#else
- ret = ibv_cmd_resize_cq(ibcq, cqe - 1, &cmd.ibv_cmd, sizeof cmd);
-#endif
- if (ret) {
- mlx4_free_buf(&buf);
- goto out;
- }
-
- mlx4_cq_resize_copy_cqes(cq, buf.buf, old_cqe);
-
- mlx4_free_buf(&cq->buf);
- cq->buf = buf;
-
-out:
- pthread_spin_unlock(&cq->lock);
- return ret;
-}
-
-int mlx4_destroy_cq(struct ibv_cq *cq)
-{
- int ret;
-
- ret = ibv_cmd_destroy_cq(cq);
- if (ret)
- return ret;
-
- mlx4_free_db(to_mctx(cq->context), MLX4_DB_TYPE_CQ, to_mcq(cq)->set_ci_db);
- mlx4_free_buf(&to_mcq(cq)->buf);
- free(to_mcq(cq));
-
- return 0;
-}
-
-struct ibv_srq *mlx4_create_srq(struct ibv_pd *pd,
- struct ibv_srq_init_attr *attr)
-{
- struct mlx4_create_srq cmd;
- struct mlx4_create_srq_resp resp;
- struct mlx4_srq *srq;
- int ret;
-
- /* Sanity check SRQ size before proceeding */
- if (attr->attr.max_wr > 1 << 16 || attr->attr.max_sge > 64)
- return NULL;
-
- srq = malloc(sizeof *srq);
- if (!srq)
- return NULL;
-
- if (pthread_spin_init(&srq->lock, PTHREAD_PROCESS_PRIVATE))
- goto err;
-
- srq->max = align_queue_size(attr->attr.max_wr + 1);
- srq->max_gs = attr->attr.max_sge;
- srq->counter = 0;
-
- if (mlx4_alloc_srq_buf(pd, &attr->attr, srq))
- goto err;
-
- srq->db = mlx4_alloc_db(to_mctx(pd->context), MLX4_DB_TYPE_RQ);
- if (!srq->db)
- goto err_free;
-
- *srq->db = 0;
-
- cmd.buf_addr = (uintptr_t) srq->buf.buf;
- cmd.db_addr = (uintptr_t) srq->db;
-
- ret = ibv_cmd_create_srq(pd, &srq->ibv_srq, attr,
- &cmd.ibv_cmd, sizeof cmd,
- &resp.ibv_resp, sizeof resp);
- if (ret)
- goto err_db;
-
- srq->srqn = resp.srqn;
-
- return &srq->ibv_srq;
-
-err_db:
- mlx4_free_db(to_mctx(pd->context), MLX4_DB_TYPE_RQ, srq->db);
-
-err_free:
- free(srq->wrid);
- mlx4_free_buf(&srq->buf);
-
-err:
- free(srq);
-
- return NULL;
-}
-
-int mlx4_modify_srq(struct ibv_srq *srq,
- struct ibv_srq_attr *attr,
- enum ibv_srq_attr_mask attr_mask)
-{
- struct ibv_modify_srq cmd;
-
- return ibv_cmd_modify_srq(srq, attr, attr_mask, &cmd, sizeof cmd);
-}
-
-int mlx4_query_srq(struct ibv_srq *srq,
- struct ibv_srq_attr *attr)
-{
- struct ibv_query_srq cmd;
-
- return ibv_cmd_query_srq(srq, attr, &cmd, sizeof cmd);
-}
-
-int mlx4_destroy_srq(struct ibv_srq *ibsrq)
-{
- struct mlx4_srq *srq = to_msrq(ibsrq);
- struct mlx4_cq *mcq = NULL;
- int ret;
-
- if (ibsrq->xrc_cq) {
- /* is an xrc_srq */
- mcq = to_mcq(ibsrq->xrc_cq);
- mlx4_cq_clean(mcq, 0, srq);
- pthread_spin_lock(&mcq->lock);
- mlx4_clear_xrc_srq(to_mctx(ibsrq->context), srq->srqn);
- pthread_spin_unlock(&mcq->lock);
- }
-
- ret = ibv_cmd_destroy_srq(ibsrq);
- if (ret) {
- if (ibsrq->xrc_cq) {
- pthread_spin_lock(&mcq->lock);
- mlx4_store_xrc_srq(to_mctx(ibsrq->context),
- srq->srqn, srq);
- pthread_spin_unlock(&mcq->lock);
- }
- return ret;
- }
-
- mlx4_free_db(to_mctx(ibsrq->context), MLX4_DB_TYPE_RQ, srq->db);
- mlx4_free_buf(&srq->buf);
- free(srq->wrid);
- free(srq);
-
- return 0;
-}
-
-static int verify_sizes(struct ibv_qp_init_attr *attr, struct mlx4_context *context)
-{
- int size;
- int nsegs;
-
- if (attr->cap.max_send_wr > context->max_qp_wr ||
- attr->cap.max_recv_wr > context->max_qp_wr ||
- attr->cap.max_send_sge > context->max_sge ||
- attr->cap.max_recv_sge > context->max_sge)
- return -1;
-
- if (attr->cap.max_inline_data) {
- nsegs = num_inline_segs(attr->cap.max_inline_data, attr->qp_type);
- size = MLX4_MAX_WQE_SIZE - nsegs * sizeof (struct mlx4_wqe_inline_seg);
- switch (attr->qp_type) {
- case IBV_QPT_UD:
- size -= (sizeof (struct mlx4_wqe_ctrl_seg) +
- sizeof (struct mlx4_wqe_datagram_seg));
- break;
-
- case IBV_QPT_RC:
- case IBV_QPT_UC:
- case IBV_QPT_XRC:
- size -= (sizeof (struct mlx4_wqe_ctrl_seg) +
- sizeof (struct mlx4_wqe_raddr_seg));
- break;
-
- default:
- return 0;
- }
-
- if (attr->cap.max_inline_data > size)
- return -1;
- }
-
- return 0;
-}
-
-struct ibv_qp *mlx4_create_qp(struct ibv_pd *pd, struct ibv_qp_init_attr *attr)
-{
- struct mlx4_create_qp cmd;
- struct ibv_create_qp_resp resp;
- struct mlx4_qp *qp;
- int ret;
- struct mlx4_context *context = to_mctx(pd->context);
-
-
- /* Sanity check QP size before proceeding */
- if (verify_sizes(attr, context))
- return NULL;
-
- qp = malloc(sizeof *qp);
- if (!qp)
- return NULL;
-
- mlx4_calc_sq_wqe_size(&attr->cap, attr->qp_type, qp);
-
- /*
- * We need to leave 2 KB + 1 WQE of headroom in the SQ to
- * allow HW to prefetch.
- */
- qp->sq_spare_wqes = (2048 >> qp->sq.wqe_shift) + 1;
- qp->sq.wqe_cnt = align_queue_size(attr->cap.max_send_wr + qp->sq_spare_wqes);
- qp->rq.wqe_cnt = align_queue_size(attr->cap.max_recv_wr);
-
- if (attr->srq || attr->qp_type == IBV_QPT_XRC)
- attr->cap.max_recv_wr = qp->rq.wqe_cnt = 0;
- else {
- if (attr->cap.max_recv_sge < 1)
- attr->cap.max_recv_sge = 1;
- if (attr->cap.max_recv_wr < 1)
- attr->cap.max_recv_wr = 1;
- }
-
- if (mlx4_alloc_qp_buf(pd, &attr->cap, attr->qp_type, qp))
- goto err;
-
- mlx4_init_qp_indices(qp);
-
- if (pthread_spin_init(&qp->sq.lock, PTHREAD_PROCESS_PRIVATE) ||
- pthread_spin_init(&qp->rq.lock, PTHREAD_PROCESS_PRIVATE))
- goto err_free;
-
- if (!attr->srq && attr->qp_type != IBV_QPT_XRC) {
- qp->db = mlx4_alloc_db(to_mctx(pd->context), MLX4_DB_TYPE_RQ);
- if (!qp->db)
- goto err_free;
-
- *qp->db = 0;
- }
-
- cmd.buf_addr = (uintptr_t) qp->buf.buf;
- if (attr->srq || attr->qp_type == IBV_QPT_XRC)
- cmd.db_addr = 0;
- else
- cmd.db_addr = (uintptr_t) qp->db;
- cmd.log_sq_stride = qp->sq.wqe_shift;
- for (cmd.log_sq_bb_count = 0;
- qp->sq.wqe_cnt > 1 << cmd.log_sq_bb_count;
- ++cmd.log_sq_bb_count)
- ; /* nothing */
- cmd.sq_no_prefetch = 0; /* OK for ABI 2: just a reserved field */
- memset(cmd.reserved, 0, sizeof cmd.reserved);
-
- pthread_mutex_lock(&to_mctx(pd->context)->qp_table_mutex);
-
- ret = ibv_cmd_create_qp(pd, &qp->ibv_qp, attr, &cmd.ibv_cmd, sizeof cmd,
- &resp, sizeof resp);
- if (ret)
- goto err_rq_db;
-
- ret = mlx4_store_qp(to_mctx(pd->context), qp->ibv_qp.qp_num, qp);
- if (ret)
- goto err_destroy;
- pthread_mutex_unlock(&to_mctx(pd->context)->qp_table_mutex);
-
- qp->rq.wqe_cnt = attr->cap.max_recv_wr;
- qp->rq.max_gs = attr->cap.max_recv_sge;
-
- /* adjust rq maxima to not exceed reported device maxima */
- attr->cap.max_recv_wr = min(context->max_qp_wr, attr->cap.max_recv_wr);
- attr->cap.max_recv_sge = min(context->max_sge, attr->cap.max_recv_sge);
-
- qp->rq.max_post = attr->cap.max_recv_wr;
- mlx4_set_sq_sizes(qp, &attr->cap, attr->qp_type);
-
- qp->doorbell_qpn = htonl(qp->ibv_qp.qp_num << 8);
- if (attr->sq_sig_all)
- qp->sq_signal_bits = htonl(MLX4_WQE_CTRL_CQ_UPDATE);
- else
- qp->sq_signal_bits = 0;
-
- return &qp->ibv_qp;
-
-err_destroy:
- ibv_cmd_destroy_qp(&qp->ibv_qp);
-
-err_rq_db:
- pthread_mutex_unlock(&to_mctx(pd->context)->qp_table_mutex);
- if (!attr->srq && attr->qp_type != IBV_QPT_XRC)
- mlx4_free_db(to_mctx(pd->context), MLX4_DB_TYPE_RQ, qp->db);
-
-err_free:
- free(qp->sq.wrid);
- if (qp->rq.wqe_cnt)
- free(qp->rq.wrid);
- mlx4_free_buf(&qp->buf);
-
-err:
- free(qp);
-
- return NULL;
-}
-
-int mlx4_query_qp(struct ibv_qp *ibqp, struct ibv_qp_attr *attr,
- enum ibv_qp_attr_mask attr_mask,
- struct ibv_qp_init_attr *init_attr)
-{
- struct ibv_query_qp cmd;
- struct mlx4_qp *qp = to_mqp(ibqp);
- int ret;
-
- ret = ibv_cmd_query_qp(ibqp, attr, attr_mask, init_attr, &cmd, sizeof cmd);
- if (ret)
- return ret;
-
- init_attr->cap.max_send_wr = qp->sq.max_post;
- init_attr->cap.max_send_sge = qp->sq.max_gs;
- init_attr->cap.max_inline_data = qp->max_inline_data;
-
- attr->cap = init_attr->cap;
-
- return 0;
-}
-
-int mlx4_modify_qp(struct ibv_qp *qp, struct ibv_qp_attr *attr,
- enum ibv_qp_attr_mask attr_mask)
-{
- struct ibv_modify_qp cmd;
- int ret;
-
- if (qp->state == IBV_QPS_RESET &&
- attr_mask & IBV_QP_STATE &&
- attr->qp_state == IBV_QPS_INIT) {
- mlx4_qp_init_sq_ownership(to_mqp(qp));
- }
-
- ret = ibv_cmd_modify_qp(qp, attr, attr_mask, &cmd, sizeof cmd);
-
- if (!ret &&
- (attr_mask & IBV_QP_STATE) &&
- attr->qp_state == IBV_QPS_RESET) {
- mlx4_cq_clean(to_mcq(qp->recv_cq), qp->qp_num,
- qp->srq ? to_msrq(qp->srq) : NULL);
- if (qp->send_cq != qp->recv_cq)
- mlx4_cq_clean(to_mcq(qp->send_cq), qp->qp_num, NULL);
-
- mlx4_init_qp_indices(to_mqp(qp));
- if (!qp->srq && qp->qp_type != IBV_QPT_XRC)
- *to_mqp(qp)->db = 0;
- }
-
- return ret;
-}
-
-static void mlx4_lock_cqs(struct ibv_qp *qp)
-{
- struct mlx4_cq *send_cq = to_mcq(qp->send_cq);
- struct mlx4_cq *recv_cq = to_mcq(qp->recv_cq);
-
- if (send_cq == recv_cq)
- pthread_spin_lock(&send_cq->lock);
- else if (send_cq->cqn < recv_cq->cqn) {
- pthread_spin_lock(&send_cq->lock);
- pthread_spin_lock(&recv_cq->lock);
- } else {
- pthread_spin_lock(&recv_cq->lock);
- pthread_spin_lock(&send_cq->lock);
- }
-}
-
-static void mlx4_unlock_cqs(struct ibv_qp *qp)
-{
- struct mlx4_cq *send_cq = to_mcq(qp->send_cq);
- struct mlx4_cq *recv_cq = to_mcq(qp->recv_cq);
-
- if (send_cq == recv_cq)
- pthread_spin_unlock(&send_cq->lock);
- else if (send_cq->cqn < recv_cq->cqn) {
- pthread_spin_unlock(&recv_cq->lock);
- pthread_spin_unlock(&send_cq->lock);
- } else {
- pthread_spin_unlock(&send_cq->lock);
- pthread_spin_unlock(&recv_cq->lock);
- }
-}
-
-int mlx4_destroy_qp(struct ibv_qp *ibqp)
-{
- struct mlx4_qp *qp = to_mqp(ibqp);
- int ret;
-
- pthread_mutex_lock(&to_mctx(ibqp->context)->qp_table_mutex);
- ret = ibv_cmd_destroy_qp(ibqp);
- if (ret) {
- pthread_mutex_unlock(&to_mctx(ibqp->context)->qp_table_mutex);
- return ret;
- }
-
- mlx4_lock_cqs(ibqp);
-
- __mlx4_cq_clean(to_mcq(ibqp->recv_cq), ibqp->qp_num,
- ibqp->srq ? to_msrq(ibqp->srq) : NULL);
- if (ibqp->send_cq != ibqp->recv_cq)
- __mlx4_cq_clean(to_mcq(ibqp->send_cq), ibqp->qp_num, NULL);
-
- mlx4_clear_qp(to_mctx(ibqp->context), ibqp->qp_num);
-
- mlx4_unlock_cqs(ibqp);
- pthread_mutex_unlock(&to_mctx(ibqp->context)->qp_table_mutex);
-
- if (!ibqp->srq && ibqp->qp_type != IBV_QPT_XRC)
- mlx4_free_db(to_mctx(ibqp->context), MLX4_DB_TYPE_RQ, qp->db);
- free(qp->sq.wrid);
- if (qp->rq.wqe_cnt)
- free(qp->rq.wrid);
- mlx4_free_buf(&qp->buf);
- free(qp);
-
- return 0;
-}
-
-struct ibv_ah *mlx4_create_ah(struct ibv_pd *pd, struct ibv_ah_attr *attr)
-{
- struct mlx4_ah *ah;
- struct ibv_port_attr port_attr;
- uint8_t is_mcast;
-
- ah = malloc(sizeof *ah);
- if (!ah)
- return NULL;
-
- memset(ah, 0, sizeof *ah);
-
- ah->av.port_pd = htonl(to_mpd(pd)->pdn | (attr->port_num << 24));
- ah->av.g_slid = attr->src_path_bits;
- ah->av.dlid = htons(attr->dlid);
- if (attr->static_rate) {
- ah->av.stat_rate = attr->static_rate + MLX4_STAT_RATE_OFFSET;
- /* XXX check rate cap? */
- }
- ah->av.sl_tclass_flowlabel = htonl(attr->sl << 28);
- if (attr->is_global) {
- ah->av.g_slid |= 0x80;
- ah->av.gid_index = attr->grh.sgid_index;
- ah->av.hop_limit = attr->grh.hop_limit;
- ah->av.sl_tclass_flowlabel |=
- htonl((attr->grh.traffic_class << 20) |
- attr->grh.flow_label);
- memcpy(ah->av.dgid, attr->grh.dgid.raw, 16);
- }
-
- if (ibv_query_port(pd->context, attr->port_num, &port_attr))
- goto err;
-
- if (port_attr.link_layer == IBV_LINK_LAYER_ETHERNET) {
- if (ibv_resolve_eth_gid(pd, attr->port_num,
- (union ibv_gid *)ah->av.dgid,
- attr->grh.sgid_index,
- ah->mac, &ah->vlan,
- &ah->tagged, &is_mcast))
- goto err;
-
- if (is_mcast) {
- ah->av.dlid = htons(0xc000);
- ah->av.port_pd |= htonl(1 << 31);
- }
- if (ah->tagged) {
- ah->av.port_pd |= htonl(1 << 29);
- ah->vlan |= (attr->sl & 7) << 13;
- }
- }
-
-
- return &ah->ibv_ah;
-err:
- free(ah);
- return NULL;
-}
-
-int mlx4_destroy_ah(struct ibv_ah *ah)
-{
- free(to_mah(ah));
-
- return 0;
-}
-
-#ifdef HAVE_IBV_XRC_OPS
-struct ibv_srq *mlx4_create_xrc_srq(struct ibv_pd *pd,
- struct ibv_xrc_domain *xrc_domain,
- struct ibv_cq *xrc_cq,
- struct ibv_srq_init_attr *attr)
-{
- struct mlx4_create_xrc_srq cmd;
- struct mlx4_create_srq_resp resp;
- struct mlx4_srq *srq;
- int ret;
-
- /* Sanity check SRQ size before proceeding */
- if (attr->attr.max_wr > 1 << 16 || attr->attr.max_sge > 64)
- return NULL;
-
- srq = malloc(sizeof *srq);
- if (!srq)
- return NULL;
-
- if (pthread_spin_init(&srq->lock, PTHREAD_PROCESS_PRIVATE))
- goto err;
-
- srq->max = align_queue_size(attr->attr.max_wr + 1);
- srq->max_gs = attr->attr.max_sge;
- srq->counter = 0;
-
- if (mlx4_alloc_srq_buf(pd, &attr->attr, srq))
- goto err;
-
- srq->db = mlx4_alloc_db(to_mctx(pd->context), MLX4_DB_TYPE_RQ);
- if (!srq->db)
- goto err_free;
-
- *srq->db = 0;
-
- cmd.buf_addr = (uintptr_t) srq->buf.buf;
- cmd.db_addr = (uintptr_t) srq->db;
-
- ret = ibv_cmd_create_xrc_srq(pd, &srq->ibv_srq, attr,
- xrc_domain->handle,
- xrc_cq->handle,
- &cmd.ibv_cmd, sizeof cmd,
- &resp.ibv_resp, sizeof resp);
- if (ret)
- goto err_db;
-
- srq->ibv_srq.xrc_srq_num = srq->srqn = resp.srqn;
-
- ret = mlx4_store_xrc_srq(to_mctx(pd->context), srq->ibv_srq.xrc_srq_num, srq);
- if (ret)
- goto err_destroy;
-
- return &srq->ibv_srq;
-
-err_destroy:
- ibv_cmd_destroy_srq(&srq->ibv_srq);
-
-err_db:
- mlx4_free_db(to_mctx(pd->context), MLX4_DB_TYPE_RQ, srq->db);
-
-err_free:
- free(srq->wrid);
- mlx4_free_buf(&srq->buf);
-
-err:
- free(srq);
-
- return NULL;
-}
-
-struct ibv_xrc_domain *mlx4_open_xrc_domain(struct ibv_context *context,
- int fd, int oflag)
-{
- int ret;
- struct mlx4_open_xrc_domain_resp resp;
- struct mlx4_xrc_domain *xrcd;
-
- xrcd = malloc(sizeof *xrcd);
- if (!xrcd)
- return NULL;
-
- ret = ibv_cmd_open_xrc_domain(context, fd, oflag, &xrcd->ibv_xrcd,
- &resp.ibv_resp, sizeof resp);
- if (ret) {
- free(xrcd);
- return NULL;
- }
-
- xrcd->xrcdn = resp.xrcdn;
- return &xrcd->ibv_xrcd;
-}
-
-int mlx4_close_xrc_domain(struct ibv_xrc_domain *d)
-{
- int ret;
- ret = ibv_cmd_close_xrc_domain(d);
- if (!ret)
- free(d);
- return ret;
-}
-
-int mlx4_create_xrc_rcv_qp(struct ibv_qp_init_attr *init_attr,
- uint32_t *xrc_qp_num)
-{
-
- return ibv_cmd_create_xrc_rcv_qp(init_attr, xrc_qp_num);
-}
-
-int mlx4_modify_xrc_rcv_qp(struct ibv_xrc_domain *xrc_domain,
- uint32_t xrc_qp_num,
- struct ibv_qp_attr *attr,
- int attr_mask)
-{
- return ibv_cmd_modify_xrc_rcv_qp(xrc_domain, xrc_qp_num,
- attr, attr_mask);
-}
-
-int mlx4_query_xrc_rcv_qp(struct ibv_xrc_domain *xrc_domain,
- uint32_t xrc_qp_num,
- struct ibv_qp_attr *attr,
- int attr_mask,
- struct ibv_qp_init_attr *init_attr)
-{
- int ret;
-
- ret = ibv_cmd_query_xrc_rcv_qp(xrc_domain, xrc_qp_num,
- attr, attr_mask, init_attr);
- if (ret)
- return ret;
-
- init_attr->cap.max_send_wr = init_attr->cap.max_send_sge = 1;
- init_attr->cap.max_recv_sge = init_attr->cap.max_recv_wr = 0;
- init_attr->cap.max_inline_data = 0;
- init_attr->recv_cq = init_attr->send_cq = NULL;
- init_attr->srq = NULL;
- init_attr->xrc_domain = xrc_domain;
- init_attr->qp_type = IBV_QPT_XRC;
- init_attr->qp_context = NULL;
- attr->cap = init_attr->cap;
-
- return 0;
-}
-
-int mlx4_reg_xrc_rcv_qp(struct ibv_xrc_domain *xrc_domain,
- uint32_t xrc_qp_num)
-{
- return ibv_cmd_reg_xrc_rcv_qp(xrc_domain, xrc_qp_num);
-}
-
-int mlx4_unreg_xrc_rcv_qp(struct ibv_xrc_domain *xrc_domain,
- uint32_t xrc_qp_num)
-{
- return ibv_cmd_unreg_xrc_rcv_qp(xrc_domain, xrc_qp_num);
-}
-
-#endif
diff --git a/contrib/ofed/libmlx4/src/wqe.h b/contrib/ofed/libmlx4/src/wqe.h
deleted file mode 100644
index 92f88dd..0000000
--- a/contrib/ofed/libmlx4/src/wqe.h
+++ /dev/null
@@ -1,122 +0,0 @@
-/*
- * Copyright (c) 2007 Cisco, Inc. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-#ifndef WQE_H
-#define WQE_H
-
-enum {
- MLX4_SEND_DOORBELL = 0x14,
-};
-
-enum {
- MLX4_WQE_CTRL_FENCE = 1 << 6,
- MLX4_WQE_CTRL_CQ_UPDATE = 3 << 2,
- MLX4_WQE_CTRL_SOLICIT = 1 << 1,
-};
-
-enum {
- MLX4_INLINE_SEG = 1 << 31,
- MLX4_INLINE_ALIGN = 64,
-};
-
-enum {
- MLX4_INVALID_LKEY = 0x100,
-};
-
-struct mlx4_wqe_ctrl_seg {
- uint32_t owner_opcode;
- uint16_t vlan_tag;
- uint8_t ins_vlan;
- uint8_t fence_size;
- /*
- * High 24 bits are SRC remote buffer; low 8 bits are flags:
- * [7] SO (strong ordering)
- * [5] TCP/UDP checksum
- * [4] IP checksum
- * [3:2] C (generate completion queue entry)
- * [1] SE (solicited event)
- * [0] FL (force loopback)
- */
- uint32_t xrcrb_flags;
- /*
- * imm is immediate data for send/RDMA write w/ immediate;
- * also invalidation key for send with invalidate; input
- * modifier for WQEs on CCQs.
- */
- uint32_t imm;
-};
-
-struct mlx4_wqe_datagram_seg {
- uint32_t av[8];
- uint32_t dqpn;
- uint32_t qkey;
- uint16_t vlan;
- uint8_t mac[6];
-};
-
-struct mlx4_wqe_data_seg {
- uint32_t byte_count;
- uint32_t lkey;
- uint64_t addr;
-};
-
-struct mlx4_wqe_inline_seg {
- uint32_t byte_count;
-};
-
-struct mlx4_wqe_srq_next_seg {
- uint16_t reserved1;
- uint16_t next_wqe_index;
- uint32_t reserved2[3];
-};
-
-struct mlx4_wqe_raddr_seg {
- uint64_t raddr;
- uint32_t rkey;
- uint32_t reserved;
-};
-
-struct mlx4_wqe_atomic_seg {
- uint64_t swap_add;
- uint64_t compare;
-};
-
-struct mlx4_wqe_bind_seg {
- uint32_t flags1;
- uint32_t flags2;
- uint32_t new_rkey;
- uint32_t lkey;
- uint64_t addr;
- uint64_t length;
-};
-
-#endif /* WQE_H */
diff --git a/contrib/ofed/libmlx4/srq.c b/contrib/ofed/libmlx4/srq.c
new file mode 100644
index 0000000..b8d25bb
--- /dev/null
+++ b/contrib/ofed/libmlx4/srq.c
@@ -0,0 +1,325 @@
+/*
+ * Copyright (c) 2007 Cisco, Inc. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#include <config.h>
+
+#include <stdlib.h>
+#include <pthread.h>
+#include <string.h>
+
+#include "mlx4.h"
+#include "doorbell.h"
+#include "wqe.h"
+#include "mlx4-abi.h"
+
+static void *get_wqe(struct mlx4_srq *srq, int n)
+{
+ return srq->buf.buf + (n << srq->wqe_shift);
+}
+
+void mlx4_free_srq_wqe(struct mlx4_srq *srq, int ind)
+{
+ struct mlx4_wqe_srq_next_seg *next;
+
+ pthread_spin_lock(&srq->lock);
+
+ next = get_wqe(srq, srq->tail);
+ next->next_wqe_index = htobe16(ind);
+ srq->tail = ind;
+
+ pthread_spin_unlock(&srq->lock);
+}
+
+int mlx4_post_srq_recv(struct ibv_srq *ibsrq,
+ struct ibv_recv_wr *wr,
+ struct ibv_recv_wr **bad_wr)
+{
+ struct mlx4_srq *srq = to_msrq(ibsrq);
+ struct mlx4_wqe_srq_next_seg *next;
+ struct mlx4_wqe_data_seg *scat;
+ int err = 0;
+ int nreq;
+ int i;
+
+ pthread_spin_lock(&srq->lock);
+
+ for (nreq = 0; wr; ++nreq, wr = wr->next) {
+ if (wr->num_sge > srq->max_gs) {
+ err = -1;
+ *bad_wr = wr;
+ break;
+ }
+
+ if (srq->head == srq->tail) {
+ /* SRQ is full*/
+ err = -1;
+ *bad_wr = wr;
+ break;
+ }
+
+ srq->wrid[srq->head] = wr->wr_id;
+
+ next = get_wqe(srq, srq->head);
+ srq->head = be16toh(next->next_wqe_index);
+ scat = (struct mlx4_wqe_data_seg *) (next + 1);
+
+ for (i = 0; i < wr->num_sge; ++i) {
+ scat[i].byte_count = htobe32(wr->sg_list[i].length);
+ scat[i].lkey = htobe32(wr->sg_list[i].lkey);
+ scat[i].addr = htobe64(wr->sg_list[i].addr);
+ }
+
+ if (i < srq->max_gs) {
+ scat[i].byte_count = 0;
+ scat[i].lkey = htobe32(MLX4_INVALID_LKEY);
+ scat[i].addr = 0;
+ }
+ }
+
+ if (nreq) {
+ srq->counter += nreq;
+
+ /*
+ * Make sure that descriptors are written before
+ * we write doorbell record.
+ */
+ udma_to_device_barrier();
+
+ *srq->db = htobe32(srq->counter);
+ }
+
+ pthread_spin_unlock(&srq->lock);
+
+ return err;
+}
+
+int mlx4_alloc_srq_buf(struct ibv_pd *pd, struct ibv_srq_attr *attr,
+ struct mlx4_srq *srq)
+{
+ struct mlx4_wqe_srq_next_seg *next;
+ struct mlx4_wqe_data_seg *scatter;
+ int size;
+ int buf_size;
+ int i;
+
+ srq->wrid = malloc(srq->max * sizeof (uint64_t));
+ if (!srq->wrid)
+ return -1;
+
+ size = sizeof (struct mlx4_wqe_srq_next_seg) +
+ srq->max_gs * sizeof (struct mlx4_wqe_data_seg);
+
+ for (srq->wqe_shift = 5; 1 << srq->wqe_shift < size; ++srq->wqe_shift)
+ ; /* nothing */
+
+ buf_size = srq->max << srq->wqe_shift;
+
+ if (mlx4_alloc_buf(&srq->buf, buf_size,
+ to_mdev(pd->context->device)->page_size)) {
+ free(srq->wrid);
+ return -1;
+ }
+
+ memset(srq->buf.buf, 0, buf_size);
+
+ /*
+ * Now initialize the SRQ buffer so that all of the WQEs are
+ * linked into the list of free WQEs.
+ */
+
+ for (i = 0; i < srq->max; ++i) {
+ next = get_wqe(srq, i);
+ next->next_wqe_index = htobe16((i + 1) & (srq->max - 1));
+
+ for (scatter = (void *) (next + 1);
+ (void *) scatter < (void *) next + (1 << srq->wqe_shift);
+ ++scatter)
+ scatter->lkey = htobe32(MLX4_INVALID_LKEY);
+ }
+
+ srq->head = 0;
+ srq->tail = srq->max - 1;
+
+ return 0;
+}
+
+void mlx4_init_xsrq_table(struct mlx4_xsrq_table *xsrq_table, int size)
+{
+ memset(xsrq_table, 0, sizeof *xsrq_table);
+ xsrq_table->num_xsrq = size;
+ xsrq_table->shift = ffs(size) - 1 - MLX4_XSRQ_TABLE_BITS;
+ xsrq_table->mask = (1 << xsrq_table->shift) - 1;
+
+ pthread_mutex_init(&xsrq_table->mutex, NULL);
+}
+
+struct mlx4_srq *mlx4_find_xsrq(struct mlx4_xsrq_table *xsrq_table, uint32_t srqn)
+{
+ int index;
+
+ index = (srqn & (xsrq_table->num_xsrq - 1)) >> xsrq_table->shift;
+ if (xsrq_table->xsrq_table[index].refcnt)
+ return xsrq_table->xsrq_table[index].table[srqn & xsrq_table->mask];
+
+ return NULL;
+}
+
+int mlx4_store_xsrq(struct mlx4_xsrq_table *xsrq_table, uint32_t srqn,
+ struct mlx4_srq *srq)
+{
+ int index, ret = 0;
+
+ index = (srqn & (xsrq_table->num_xsrq - 1)) >> xsrq_table->shift;
+ pthread_mutex_lock(&xsrq_table->mutex);
+ if (!xsrq_table->xsrq_table[index].refcnt) {
+ xsrq_table->xsrq_table[index].table = calloc(xsrq_table->mask + 1,
+ sizeof(struct mlx4_srq *));
+ if (!xsrq_table->xsrq_table[index].table) {
+ ret = -1;
+ goto out;
+ }
+ }
+
+ xsrq_table->xsrq_table[index].refcnt++;
+ xsrq_table->xsrq_table[index].table[srqn & xsrq_table->mask] = srq;
+
+out:
+ pthread_mutex_unlock(&xsrq_table->mutex);
+ return ret;
+}
+
+void mlx4_clear_xsrq(struct mlx4_xsrq_table *xsrq_table, uint32_t srqn)
+{
+ int index;
+
+ index = (srqn & (xsrq_table->num_xsrq - 1)) >> xsrq_table->shift;
+ pthread_mutex_lock(&xsrq_table->mutex);
+
+ if (--xsrq_table->xsrq_table[index].refcnt)
+ xsrq_table->xsrq_table[index].table[srqn & xsrq_table->mask] = NULL;
+ else
+ free(xsrq_table->xsrq_table[index].table);
+
+ pthread_mutex_unlock(&xsrq_table->mutex);
+}
+
+struct ibv_srq *mlx4_create_xrc_srq(struct ibv_context *context,
+ struct ibv_srq_init_attr_ex *attr_ex)
+{
+ struct mlx4_create_xsrq cmd;
+ struct mlx4_create_srq_resp resp;
+ struct mlx4_srq *srq;
+ int ret;
+
+ /* Sanity check SRQ size before proceeding */
+ if (attr_ex->attr.max_wr > 1 << 16 || attr_ex->attr.max_sge > 64)
+ return NULL;
+
+ srq = calloc(1, sizeof *srq);
+ if (!srq)
+ return NULL;
+
+ if (pthread_spin_init(&srq->lock, PTHREAD_PROCESS_PRIVATE))
+ goto err;
+
+ srq->max = align_queue_size(attr_ex->attr.max_wr + 1);
+ srq->max_gs = attr_ex->attr.max_sge;
+ srq->counter = 0;
+ srq->ext_srq = 1;
+
+ if (mlx4_alloc_srq_buf(attr_ex->pd, &attr_ex->attr, srq))
+ goto err;
+
+ srq->db = mlx4_alloc_db(to_mctx(context), MLX4_DB_TYPE_RQ);
+ if (!srq->db)
+ goto err_free;
+
+ *srq->db = 0;
+
+ cmd.buf_addr = (uintptr_t) srq->buf.buf;
+ cmd.db_addr = (uintptr_t) srq->db;
+
+ ret = ibv_cmd_create_srq_ex(context, &srq->verbs_srq,
+ sizeof(srq->verbs_srq),
+ attr_ex,
+ &cmd.ibv_cmd, sizeof cmd,
+ &resp.ibv_resp, sizeof resp);
+ if (ret)
+ goto err_db;
+
+ ret = mlx4_store_xsrq(&to_mctx(context)->xsrq_table,
+ srq->verbs_srq.srq_num, srq);
+ if (ret)
+ goto err_destroy;
+
+ return &srq->verbs_srq.srq;
+
+err_destroy:
+ ibv_cmd_destroy_srq(&srq->verbs_srq.srq);
+err_db:
+ mlx4_free_db(to_mctx(context), MLX4_DB_TYPE_RQ, srq->db);
+err_free:
+ free(srq->wrid);
+ mlx4_free_buf(&srq->buf);
+err:
+ free(srq);
+ return NULL;
+}
+
+int mlx4_destroy_xrc_srq(struct ibv_srq *srq)
+{
+ struct mlx4_context *mctx = to_mctx(srq->context);
+ struct mlx4_srq *msrq = to_msrq(srq);
+ struct mlx4_cq *mcq;
+ int ret;
+
+ mcq = to_mcq(msrq->verbs_srq.cq);
+ mlx4_cq_clean(mcq, 0, msrq);
+ pthread_spin_lock(&mcq->lock);
+ mlx4_clear_xsrq(&mctx->xsrq_table, msrq->verbs_srq.srq_num);
+ pthread_spin_unlock(&mcq->lock);
+
+ ret = ibv_cmd_destroy_srq(srq);
+ if (ret) {
+ pthread_spin_lock(&mcq->lock);
+ mlx4_store_xsrq(&mctx->xsrq_table, msrq->verbs_srq.srq_num, msrq);
+ pthread_spin_unlock(&mcq->lock);
+ return ret;
+ }
+
+ mlx4_free_db(mctx, MLX4_DB_TYPE_RQ, msrq->db);
+ mlx4_free_buf(&msrq->buf);
+ free(msrq->wrid);
+ free(msrq);
+
+ return 0;
+}
diff --git a/contrib/ofed/libmlx4/verbs.c b/contrib/ofed/libmlx4/verbs.c
new file mode 100644
index 0000000..f6f43f9
--- /dev/null
+++ b/contrib/ofed/libmlx4/verbs.c
@@ -0,0 +1,1255 @@
+/*
+ * Copyright (c) 2007 Cisco, Inc. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#include <config.h>
+
+#include <infiniband/endian.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <pthread.h>
+#include <errno.h>
+
+#include "mlx4.h"
+#include "mlx4-abi.h"
+#include "wqe.h"
+
+int mlx4_query_device(struct ibv_context *context, struct ibv_device_attr *attr)
+{
+ struct ibv_query_device cmd;
+ uint64_t raw_fw_ver;
+ unsigned major, minor, sub_minor;
+ int ret;
+
+ ret = ibv_cmd_query_device(context, attr, &raw_fw_ver, &cmd, sizeof cmd);
+ if (ret)
+ return ret;
+
+ major = (raw_fw_ver >> 32) & 0xffff;
+ minor = (raw_fw_ver >> 16) & 0xffff;
+ sub_minor = raw_fw_ver & 0xffff;
+
+ snprintf(attr->fw_ver, sizeof attr->fw_ver,
+ "%d.%d.%03d", major, minor, sub_minor);
+
+ return 0;
+}
+
+int mlx4_query_device_ex(struct ibv_context *context,
+ const struct ibv_query_device_ex_input *input,
+ struct ibv_device_attr_ex *attr,
+ size_t attr_size)
+{
+ struct mlx4_context *mctx = to_mctx(context);
+ struct mlx4_query_device_ex_resp resp = {};
+ struct mlx4_query_device_ex cmd = {};
+ uint64_t raw_fw_ver;
+ unsigned sub_minor;
+ unsigned major;
+ unsigned minor;
+ int err;
+
+ err = ibv_cmd_query_device_ex(context, input, attr, attr_size,
+ &raw_fw_ver,
+ &cmd.ibv_cmd, sizeof(cmd.ibv_cmd), sizeof(cmd),
+ &resp.ibv_resp, sizeof(resp.ibv_resp),
+ sizeof(resp));
+ if (err)
+ return err;
+
+ if (resp.comp_mask & MLX4_QUERY_DEV_RESP_MASK_CORE_CLOCK_OFFSET) {
+ mctx->core_clock.offset = resp.hca_core_clock_offset;
+ mctx->core_clock.offset_valid = 1;
+ }
+
+ major = (raw_fw_ver >> 32) & 0xffff;
+ minor = (raw_fw_ver >> 16) & 0xffff;
+ sub_minor = raw_fw_ver & 0xffff;
+
+ snprintf(attr->orig_attr.fw_ver, sizeof attr->orig_attr.fw_ver,
+ "%d.%d.%03d", major, minor, sub_minor);
+
+ return 0;
+}
+
+#define READL(ptr) (*((uint32_t *)(ptr)))
+static int mlx4_read_clock(struct ibv_context *context, uint64_t *cycles)
+{
+ unsigned int clockhi, clocklo, clockhi1;
+ int i;
+ struct mlx4_context *ctx = to_mctx(context);
+
+ if (!ctx->hca_core_clock)
+ return -EOPNOTSUPP;
+
+ /* Handle wraparound */
+ for (i = 0; i < 2; i++) {
+ clockhi = be32toh(READL(ctx->hca_core_clock));
+ clocklo = be32toh(READL(ctx->hca_core_clock + 4));
+ clockhi1 = be32toh(READL(ctx->hca_core_clock));
+ if (clockhi == clockhi1)
+ break;
+ }
+
+ *cycles = (uint64_t)clockhi << 32 | (uint64_t)clocklo;
+
+ return 0;
+}
+
+int mlx4_query_rt_values(struct ibv_context *context,
+ struct ibv_values_ex *values)
+{
+ uint32_t comp_mask = 0;
+ int err = 0;
+
+ if (values->comp_mask & IBV_VALUES_MASK_RAW_CLOCK) {
+ uint64_t cycles;
+
+ err = mlx4_read_clock(context, &cycles);
+ if (!err) {
+ values->raw_clock.tv_sec = 0;
+ values->raw_clock.tv_nsec = cycles;
+ comp_mask |= IBV_VALUES_MASK_RAW_CLOCK;
+ }
+ }
+
+ values->comp_mask = comp_mask;
+
+ return err;
+}
+
+int mlx4_query_port(struct ibv_context *context, uint8_t port,
+ struct ibv_port_attr *attr)
+{
+ struct ibv_query_port cmd;
+ int err;
+
+ err = ibv_cmd_query_port(context, port, attr, &cmd, sizeof(cmd));
+ if (!err && port <= MLX4_PORTS_NUM && port > 0) {
+ struct mlx4_context *mctx = to_mctx(context);
+ if (!mctx->port_query_cache[port - 1].valid) {
+ mctx->port_query_cache[port - 1].link_layer =
+ attr->link_layer;
+ mctx->port_query_cache[port - 1].caps =
+ attr->port_cap_flags;
+ mctx->port_query_cache[port - 1].valid = 1;
+ }
+ }
+
+ return err;
+}
+
+/* Only the fields in the port cache will be valid */
+static int query_port_cache(struct ibv_context *context, uint8_t port_num,
+ struct ibv_port_attr *port_attr)
+{
+ struct mlx4_context *mctx = to_mctx(context);
+ if (port_num <= 0 || port_num > MLX4_PORTS_NUM)
+ return -EINVAL;
+ if (mctx->port_query_cache[port_num - 1].valid) {
+ port_attr->link_layer =
+ mctx->
+ port_query_cache[port_num - 1].
+ link_layer;
+ port_attr->port_cap_flags =
+ mctx->
+ port_query_cache[port_num - 1].
+ caps;
+ return 0;
+ }
+ return mlx4_query_port(context, port_num,
+ (struct ibv_port_attr *)port_attr);
+
+}
+
+struct ibv_pd *mlx4_alloc_pd(struct ibv_context *context)
+{
+ struct ibv_alloc_pd cmd;
+ struct mlx4_alloc_pd_resp resp;
+ struct mlx4_pd *pd;
+
+ pd = malloc(sizeof *pd);
+ if (!pd)
+ return NULL;
+
+ if (ibv_cmd_alloc_pd(context, &pd->ibv_pd, &cmd, sizeof cmd,
+ &resp.ibv_resp, sizeof resp)) {
+ free(pd);
+ return NULL;
+ }
+
+ pd->pdn = resp.pdn;
+
+ return &pd->ibv_pd;
+}
+
+int mlx4_free_pd(struct ibv_pd *pd)
+{
+ int ret;
+
+ ret = ibv_cmd_dealloc_pd(pd);
+ if (ret)
+ return ret;
+
+ free(to_mpd(pd));
+ return 0;
+}
+
+struct ibv_xrcd *mlx4_open_xrcd(struct ibv_context *context,
+ struct ibv_xrcd_init_attr *attr)
+{
+ struct ibv_open_xrcd cmd;
+ struct ibv_open_xrcd_resp resp;
+ struct verbs_xrcd *xrcd;
+ int ret;
+
+ xrcd = calloc(1, sizeof *xrcd);
+ if (!xrcd)
+ return NULL;
+
+ ret = ibv_cmd_open_xrcd(context, xrcd, sizeof(*xrcd), attr,
+ &cmd, sizeof cmd, &resp, sizeof resp);
+ if (ret)
+ goto err;
+
+ return &xrcd->xrcd;
+
+err:
+ free(xrcd);
+ return NULL;
+}
+
+int mlx4_close_xrcd(struct ibv_xrcd *ib_xrcd)
+{
+ struct verbs_xrcd *xrcd = container_of(ib_xrcd, struct verbs_xrcd, xrcd);
+ int ret;
+
+ ret = ibv_cmd_close_xrcd(xrcd);
+ if (!ret)
+ free(xrcd);
+
+ return ret;
+}
+
+struct ibv_mr *mlx4_reg_mr(struct ibv_pd *pd, void *addr, size_t length,
+ int access)
+{
+ struct ibv_mr *mr;
+ struct ibv_reg_mr cmd;
+ struct ibv_reg_mr_resp resp;
+ int ret;
+
+ mr = malloc(sizeof *mr);
+ if (!mr)
+ return NULL;
+
+ ret = ibv_cmd_reg_mr(pd, addr, length, (uintptr_t) addr,
+ access, mr, &cmd, sizeof cmd,
+ &resp, sizeof resp);
+ if (ret) {
+ free(mr);
+ return NULL;
+ }
+
+ return mr;
+}
+
+int mlx4_rereg_mr(struct ibv_mr *mr,
+ int flags,
+ struct ibv_pd *pd, void *addr,
+ size_t length, int access)
+{
+ struct ibv_rereg_mr cmd;
+ struct ibv_rereg_mr_resp resp;
+
+ if (flags & IBV_REREG_MR_KEEP_VALID)
+ return ENOTSUP;
+
+ return ibv_cmd_rereg_mr(mr, flags, addr, length,
+ (uintptr_t)addr,
+ access, pd,
+ &cmd, sizeof(cmd),
+ &resp, sizeof(resp));
+}
+
+int mlx4_dereg_mr(struct ibv_mr *mr)
+{
+ int ret;
+
+ ret = ibv_cmd_dereg_mr(mr);
+ if (ret)
+ return ret;
+
+ free(mr);
+ return 0;
+}
+
+struct ibv_mw *mlx4_alloc_mw(struct ibv_pd *pd, enum ibv_mw_type type)
+{
+ struct ibv_mw *mw;
+ struct ibv_alloc_mw cmd;
+ struct ibv_alloc_mw_resp resp;
+ int ret;
+
+ mw = calloc(1, sizeof(*mw));
+ if (!mw)
+ return NULL;
+
+ ret = ibv_cmd_alloc_mw(pd, type, mw, &cmd, sizeof(cmd),
+ &resp, sizeof(resp));
+
+ if (ret) {
+ free(mw);
+ return NULL;
+ }
+
+ return mw;
+}
+
+int mlx4_dealloc_mw(struct ibv_mw *mw)
+{
+ int ret;
+ struct ibv_dealloc_mw cmd;
+
+ ret = ibv_cmd_dealloc_mw(mw, &cmd, sizeof(cmd));
+ if (ret)
+ return ret;
+
+ free(mw);
+ return 0;
+}
+
+int mlx4_bind_mw(struct ibv_qp *qp, struct ibv_mw *mw,
+ struct ibv_mw_bind *mw_bind)
+{
+ struct ibv_send_wr *bad_wr = NULL;
+ struct ibv_send_wr wr = { };
+ int ret;
+
+
+ wr.opcode = IBV_WR_BIND_MW;
+ wr.next = NULL;
+
+ wr.wr_id = mw_bind->wr_id;
+ wr.send_flags = mw_bind->send_flags;
+
+ wr.bind_mw.mw = mw;
+ wr.bind_mw.rkey = ibv_inc_rkey(mw->rkey);
+ wr.bind_mw.bind_info = mw_bind->bind_info;
+
+ ret = mlx4_post_send(qp, &wr, &bad_wr);
+
+ if (ret)
+ return ret;
+
+ /* updating the mw with the latest rkey. */
+ mw->rkey = wr.bind_mw.rkey;
+
+ return 0;
+}
+
+int align_queue_size(int req)
+{
+ int nent;
+
+ for (nent = 1; nent < req; nent <<= 1)
+ ; /* nothing */
+
+ return nent;
+}
+
+enum {
+ CREATE_CQ_SUPPORTED_WC_FLAGS = IBV_WC_STANDARD_FLAGS |
+ IBV_WC_EX_WITH_COMPLETION_TIMESTAMP
+};
+
+enum {
+ CREATE_CQ_SUPPORTED_COMP_MASK = IBV_CQ_INIT_ATTR_MASK_FLAGS
+};
+
+enum {
+ CREATE_CQ_SUPPORTED_FLAGS = IBV_CREATE_CQ_ATTR_SINGLE_THREADED
+};
+
+
+static int mlx4_cmd_create_cq(struct ibv_context *context,
+ struct ibv_cq_init_attr_ex *cq_attr,
+ struct mlx4_cq *cq)
+{
+ struct mlx4_create_cq cmd = {};
+ struct mlx4_create_cq_resp resp = {};
+ int ret;
+
+ cmd.buf_addr = (uintptr_t) cq->buf.buf;
+ cmd.db_addr = (uintptr_t) cq->set_ci_db;
+
+ ret = ibv_cmd_create_cq(context, cq_attr->cqe, cq_attr->channel,
+ cq_attr->comp_vector,
+ ibv_cq_ex_to_cq(&cq->ibv_cq),
+ &cmd.ibv_cmd, sizeof(cmd),
+ &resp.ibv_resp, sizeof(resp));
+ if (!ret)
+ cq->cqn = resp.cqn;
+
+ return ret;
+
+}
+
+static int mlx4_cmd_create_cq_ex(struct ibv_context *context,
+ struct ibv_cq_init_attr_ex *cq_attr,
+ struct mlx4_cq *cq)
+{
+ struct mlx4_create_cq_ex cmd = {};
+ struct mlx4_create_cq_resp_ex resp = {};
+ int ret;
+
+ cmd.buf_addr = (uintptr_t) cq->buf.buf;
+ cmd.db_addr = (uintptr_t) cq->set_ci_db;
+
+ ret = ibv_cmd_create_cq_ex(context, cq_attr,
+ &cq->ibv_cq, &cmd.ibv_cmd,
+ sizeof(cmd.ibv_cmd),
+ sizeof(cmd),
+ &resp.ibv_resp,
+ sizeof(resp.ibv_resp),
+ sizeof(resp));
+ if (!ret)
+ cq->cqn = resp.cqn;
+
+ return ret;
+}
+
+static struct ibv_cq_ex *create_cq(struct ibv_context *context,
+ struct ibv_cq_init_attr_ex *cq_attr,
+ int cq_alloc_flags)
+{
+ struct mlx4_cq *cq;
+ int ret;
+ struct mlx4_context *mctx = to_mctx(context);
+
+ /* Sanity check CQ size before proceeding */
+ if (cq_attr->cqe > 0x3fffff) {
+ errno = EINVAL;
+ return NULL;
+ }
+
+ if (cq_attr->comp_mask & ~CREATE_CQ_SUPPORTED_COMP_MASK) {
+ errno = ENOTSUP;
+ return NULL;
+ }
+
+ if (cq_attr->comp_mask & IBV_CQ_INIT_ATTR_MASK_FLAGS &&
+ cq_attr->flags & ~CREATE_CQ_SUPPORTED_FLAGS) {
+ errno = ENOTSUP;
+ return NULL;
+ }
+
+ if (cq_attr->wc_flags & ~CREATE_CQ_SUPPORTED_WC_FLAGS)
+ return NULL;
+
+ /* mlx4 devices don't support slid and sl in cqe when completion
+ * timestamp is enabled in the CQ
+ */
+ if ((cq_attr->wc_flags & (IBV_WC_EX_WITH_SLID | IBV_WC_EX_WITH_SL)) &&
+ (cq_attr->wc_flags & IBV_WC_EX_WITH_COMPLETION_TIMESTAMP)) {
+ errno = ENOTSUP;
+ return NULL;
+ }
+
+ cq = malloc(sizeof *cq);
+ if (!cq)
+ return NULL;
+
+ cq->cons_index = 0;
+
+ if (pthread_spin_init(&cq->lock, PTHREAD_PROCESS_PRIVATE))
+ goto err;
+
+ cq_attr->cqe = align_queue_size(cq_attr->cqe + 1);
+
+ if (mlx4_alloc_cq_buf(to_mdev(context->device), &cq->buf, cq_attr->cqe, mctx->cqe_size))
+ goto err;
+
+ cq->cqe_size = mctx->cqe_size;
+ cq->set_ci_db = mlx4_alloc_db(to_mctx(context), MLX4_DB_TYPE_CQ);
+ if (!cq->set_ci_db)
+ goto err_buf;
+
+ cq->arm_db = cq->set_ci_db + 1;
+ *cq->arm_db = 0;
+ cq->arm_sn = 1;
+ *cq->set_ci_db = 0;
+ cq->flags = cq_alloc_flags;
+
+ if (cq_attr->comp_mask & IBV_CQ_INIT_ATTR_MASK_FLAGS &&
+ cq_attr->flags & IBV_CREATE_CQ_ATTR_SINGLE_THREADED)
+ cq->flags |= MLX4_CQ_FLAGS_SINGLE_THREADED;
+
+ --cq_attr->cqe;
+ if (cq_alloc_flags & MLX4_CQ_FLAGS_EXTENDED)
+ ret = mlx4_cmd_create_cq_ex(context, cq_attr, cq);
+ else
+ ret = mlx4_cmd_create_cq(context, cq_attr, cq);
+
+ if (ret)
+ goto err_db;
+
+
+ if (cq_alloc_flags & MLX4_CQ_FLAGS_EXTENDED)
+ mlx4_cq_fill_pfns(cq, cq_attr);
+
+ return &cq->ibv_cq;
+
+err_db:
+ mlx4_free_db(to_mctx(context), MLX4_DB_TYPE_CQ, cq->set_ci_db);
+
+err_buf:
+ mlx4_free_buf(&cq->buf);
+
+err:
+ free(cq);
+
+ return NULL;
+}
+
+struct ibv_cq *mlx4_create_cq(struct ibv_context *context, int cqe,
+ struct ibv_comp_channel *channel,
+ int comp_vector)
+{
+ struct ibv_cq_ex *cq;
+ struct ibv_cq_init_attr_ex cq_attr = {.cqe = cqe, .channel = channel,
+ .comp_vector = comp_vector,
+ .wc_flags = IBV_WC_STANDARD_FLAGS};
+
+ cq = create_cq(context, &cq_attr, 0);
+ return cq ? ibv_cq_ex_to_cq(cq) : NULL;
+}
+
+struct ibv_cq_ex *mlx4_create_cq_ex(struct ibv_context *context,
+ struct ibv_cq_init_attr_ex *cq_attr)
+{
+ /*
+ * Make local copy since some attributes might be adjusted
+ * for internal use.
+ */
+ struct ibv_cq_init_attr_ex cq_attr_c = {.cqe = cq_attr->cqe,
+ .channel = cq_attr->channel,
+ .comp_vector = cq_attr->comp_vector,
+ .wc_flags = cq_attr->wc_flags,
+ .comp_mask = cq_attr->comp_mask,
+ .flags = cq_attr->flags};
+
+ return create_cq(context, &cq_attr_c, MLX4_CQ_FLAGS_EXTENDED);
+}
+
+int mlx4_resize_cq(struct ibv_cq *ibcq, int cqe)
+{
+ struct mlx4_cq *cq = to_mcq(ibcq);
+ struct mlx4_resize_cq cmd;
+ struct ibv_resize_cq_resp resp;
+ struct mlx4_buf buf;
+ int old_cqe, outst_cqe, ret;
+
+ /* Sanity check CQ size before proceeding */
+ if (cqe > 0x3fffff)
+ return EINVAL;
+
+ pthread_spin_lock(&cq->lock);
+
+ cqe = align_queue_size(cqe + 1);
+ if (cqe == ibcq->cqe + 1) {
+ ret = 0;
+ goto out;
+ }
+
+ /* Can't be smaller then the number of outstanding CQEs */
+ outst_cqe = mlx4_get_outstanding_cqes(cq);
+ if (cqe < outst_cqe + 1) {
+ ret = EINVAL;
+ goto out;
+ }
+
+ ret = mlx4_alloc_cq_buf(to_mdev(ibcq->context->device), &buf, cqe, cq->cqe_size);
+ if (ret)
+ goto out;
+
+ old_cqe = ibcq->cqe;
+ cmd.buf_addr = (uintptr_t) buf.buf;
+
+ ret = ibv_cmd_resize_cq(ibcq, cqe - 1, &cmd.ibv_cmd, sizeof cmd,
+ &resp, sizeof resp);
+ if (ret) {
+ mlx4_free_buf(&buf);
+ goto out;
+ }
+
+ mlx4_cq_resize_copy_cqes(cq, buf.buf, old_cqe);
+
+ mlx4_free_buf(&cq->buf);
+ cq->buf = buf;
+ mlx4_update_cons_index(cq);
+
+out:
+ pthread_spin_unlock(&cq->lock);
+ return ret;
+}
+
+int mlx4_destroy_cq(struct ibv_cq *cq)
+{
+ int ret;
+
+ ret = ibv_cmd_destroy_cq(cq);
+ if (ret)
+ return ret;
+
+ mlx4_free_db(to_mctx(cq->context), MLX4_DB_TYPE_CQ, to_mcq(cq)->set_ci_db);
+ mlx4_free_buf(&to_mcq(cq)->buf);
+ free(to_mcq(cq));
+
+ return 0;
+}
+
+struct ibv_srq *mlx4_create_srq(struct ibv_pd *pd,
+ struct ibv_srq_init_attr *attr)
+{
+ struct mlx4_create_srq cmd;
+ struct mlx4_create_srq_resp resp;
+ struct mlx4_srq *srq;
+ int ret;
+
+ /* Sanity check SRQ size before proceeding */
+ if (attr->attr.max_wr > 1 << 16 || attr->attr.max_sge > 64)
+ return NULL;
+
+ srq = malloc(sizeof *srq);
+ if (!srq)
+ return NULL;
+
+ if (pthread_spin_init(&srq->lock, PTHREAD_PROCESS_PRIVATE))
+ goto err;
+
+ srq->max = align_queue_size(attr->attr.max_wr + 1);
+ srq->max_gs = attr->attr.max_sge;
+ srq->counter = 0;
+ srq->ext_srq = 0;
+
+ if (mlx4_alloc_srq_buf(pd, &attr->attr, srq))
+ goto err;
+
+ srq->db = mlx4_alloc_db(to_mctx(pd->context), MLX4_DB_TYPE_RQ);
+ if (!srq->db)
+ goto err_free;
+
+ *srq->db = 0;
+
+ cmd.buf_addr = (uintptr_t) srq->buf.buf;
+ cmd.db_addr = (uintptr_t) srq->db;
+
+ ret = ibv_cmd_create_srq(pd, &srq->verbs_srq.srq, attr,
+ &cmd.ibv_cmd, sizeof cmd,
+ &resp.ibv_resp, sizeof resp);
+ if (ret)
+ goto err_db;
+
+ return &srq->verbs_srq.srq;
+
+err_db:
+ mlx4_free_db(to_mctx(pd->context), MLX4_DB_TYPE_RQ, srq->db);
+
+err_free:
+ free(srq->wrid);
+ mlx4_free_buf(&srq->buf);
+
+err:
+ free(srq);
+
+ return NULL;
+}
+
+struct ibv_srq *mlx4_create_srq_ex(struct ibv_context *context,
+ struct ibv_srq_init_attr_ex *attr_ex)
+{
+ if (!(attr_ex->comp_mask & IBV_SRQ_INIT_ATTR_TYPE) ||
+ (attr_ex->srq_type == IBV_SRQT_BASIC))
+ return mlx4_create_srq(attr_ex->pd, (struct ibv_srq_init_attr *) attr_ex);
+ else if (attr_ex->srq_type == IBV_SRQT_XRC)
+ return mlx4_create_xrc_srq(context, attr_ex);
+
+ return NULL;
+}
+
+int mlx4_modify_srq(struct ibv_srq *srq,
+ struct ibv_srq_attr *attr,
+ int attr_mask)
+{
+ struct ibv_modify_srq cmd;
+
+ return ibv_cmd_modify_srq(srq, attr, attr_mask, &cmd, sizeof cmd);
+}
+
+int mlx4_query_srq(struct ibv_srq *srq,
+ struct ibv_srq_attr *attr)
+{
+ struct ibv_query_srq cmd;
+
+ return ibv_cmd_query_srq(srq, attr, &cmd, sizeof cmd);
+}
+
+int mlx4_destroy_srq(struct ibv_srq *srq)
+{
+ int ret;
+
+ if (to_msrq(srq)->ext_srq)
+ return mlx4_destroy_xrc_srq(srq);
+
+ ret = ibv_cmd_destroy_srq(srq);
+ if (ret)
+ return ret;
+
+ mlx4_free_db(to_mctx(srq->context), MLX4_DB_TYPE_RQ, to_msrq(srq)->db);
+ mlx4_free_buf(&to_msrq(srq)->buf);
+ free(to_msrq(srq)->wrid);
+ free(to_msrq(srq));
+
+ return 0;
+}
+
+static int mlx4_cmd_create_qp_ex(struct ibv_context *context,
+ struct ibv_qp_init_attr_ex *attr,
+ struct mlx4_create_qp *cmd,
+ struct mlx4_qp *qp)
+{
+ struct mlx4_create_qp_ex cmd_ex;
+ struct mlx4_create_qp_resp_ex resp;
+ int ret;
+
+ memset(&cmd_ex, 0, sizeof(cmd_ex));
+ memcpy(&cmd_ex.ibv_cmd.base, &cmd->ibv_cmd.user_handle,
+ offsetof(typeof(cmd->ibv_cmd), is_srq) +
+ sizeof(cmd->ibv_cmd.is_srq) -
+ offsetof(typeof(cmd->ibv_cmd), user_handle));
+
+ memcpy(&cmd_ex.drv_ex, &cmd->buf_addr,
+ offsetof(typeof(*cmd), sq_no_prefetch) +
+ sizeof(cmd->sq_no_prefetch) - sizeof(cmd->ibv_cmd));
+
+ ret = ibv_cmd_create_qp_ex2(context, &qp->verbs_qp,
+ sizeof(qp->verbs_qp), attr,
+ &cmd_ex.ibv_cmd, sizeof(cmd_ex.ibv_cmd),
+ sizeof(cmd_ex), &resp.ibv_resp,
+ sizeof(resp.ibv_resp), sizeof(resp));
+ return ret;
+}
+
+enum {
+ MLX4_CREATE_QP_SUP_COMP_MASK = (IBV_QP_INIT_ATTR_PD |
+ IBV_QP_INIT_ATTR_XRCD |
+ IBV_QP_INIT_ATTR_CREATE_FLAGS),
+};
+
+enum {
+ MLX4_CREATE_QP_EX2_COMP_MASK = (IBV_QP_INIT_ATTR_CREATE_FLAGS),
+};
+
+struct ibv_qp *mlx4_create_qp_ex(struct ibv_context *context,
+ struct ibv_qp_init_attr_ex *attr)
+{
+ struct mlx4_context *ctx = to_mctx(context);
+ struct mlx4_create_qp cmd;
+ struct ibv_create_qp_resp resp;
+ struct mlx4_qp *qp;
+ int ret;
+
+ /* Sanity check QP size before proceeding */
+ if (ctx->max_qp_wr) { /* mlx4_query_device succeeded */
+ if (attr->cap.max_send_wr > ctx->max_qp_wr ||
+ attr->cap.max_recv_wr > ctx->max_qp_wr ||
+ attr->cap.max_send_sge > ctx->max_sge ||
+ attr->cap.max_recv_sge > ctx->max_sge)
+ return NULL;
+ } else {
+ if (attr->cap.max_send_wr > 65536 ||
+ attr->cap.max_recv_wr > 65536 ||
+ attr->cap.max_send_sge > 64 ||
+ attr->cap.max_recv_sge > 64)
+ return NULL;
+ }
+ if (attr->cap.max_inline_data > 1024)
+ return NULL;
+
+ if (attr->comp_mask & ~MLX4_CREATE_QP_SUP_COMP_MASK)
+ return NULL;
+
+ qp = calloc(1, sizeof *qp);
+ if (!qp)
+ return NULL;
+
+ if (attr->qp_type == IBV_QPT_XRC_RECV) {
+ attr->cap.max_send_wr = qp->sq.wqe_cnt = 0;
+ } else {
+ mlx4_calc_sq_wqe_size(&attr->cap, attr->qp_type, qp);
+ /*
+ * We need to leave 2 KB + 1 WQE of headroom in the SQ to
+ * allow HW to prefetch.
+ */
+ qp->sq_spare_wqes = (2048 >> qp->sq.wqe_shift) + 1;
+ qp->sq.wqe_cnt = align_queue_size(attr->cap.max_send_wr + qp->sq_spare_wqes);
+ }
+
+ if (attr->srq || attr->qp_type == IBV_QPT_XRC_SEND ||
+ attr->qp_type == IBV_QPT_XRC_RECV) {
+ attr->cap.max_recv_wr = qp->rq.wqe_cnt = attr->cap.max_recv_sge = 0;
+ } else {
+ qp->rq.wqe_cnt = align_queue_size(attr->cap.max_recv_wr);
+ if (attr->cap.max_recv_sge < 1)
+ attr->cap.max_recv_sge = 1;
+ if (attr->cap.max_recv_wr < 1)
+ attr->cap.max_recv_wr = 1;
+ }
+
+ if (mlx4_alloc_qp_buf(context, &attr->cap, attr->qp_type, qp))
+ goto err;
+
+ mlx4_init_qp_indices(qp);
+
+ if (pthread_spin_init(&qp->sq.lock, PTHREAD_PROCESS_PRIVATE) ||
+ pthread_spin_init(&qp->rq.lock, PTHREAD_PROCESS_PRIVATE))
+ goto err_free;
+
+ if (attr->cap.max_recv_sge) {
+ qp->db = mlx4_alloc_db(to_mctx(context), MLX4_DB_TYPE_RQ);
+ if (!qp->db)
+ goto err_free;
+
+ *qp->db = 0;
+ cmd.db_addr = (uintptr_t) qp->db;
+ } else {
+ cmd.db_addr = 0;
+ }
+
+ cmd.buf_addr = (uintptr_t) qp->buf.buf;
+ cmd.log_sq_stride = qp->sq.wqe_shift;
+ for (cmd.log_sq_bb_count = 0;
+ qp->sq.wqe_cnt > 1 << cmd.log_sq_bb_count;
+ ++cmd.log_sq_bb_count)
+ ; /* nothing */
+ cmd.sq_no_prefetch = 0; /* OK for ABI 2: just a reserved field */
+ memset(cmd.reserved, 0, sizeof cmd.reserved);
+ pthread_mutex_lock(&to_mctx(context)->qp_table_mutex);
+
+ if (attr->comp_mask & MLX4_CREATE_QP_EX2_COMP_MASK)
+ ret = mlx4_cmd_create_qp_ex(context, attr, &cmd, qp);
+ else
+ ret = ibv_cmd_create_qp_ex(context, &qp->verbs_qp,
+ sizeof(qp->verbs_qp), attr,
+ &cmd.ibv_cmd, sizeof(cmd), &resp,
+ sizeof(resp));
+ if (ret)
+ goto err_rq_db;
+
+ if (qp->sq.wqe_cnt || qp->rq.wqe_cnt) {
+ ret = mlx4_store_qp(to_mctx(context), qp->verbs_qp.qp.qp_num, qp);
+ if (ret)
+ goto err_destroy;
+ }
+ pthread_mutex_unlock(&to_mctx(context)->qp_table_mutex);
+
+ qp->rq.wqe_cnt = qp->rq.max_post = attr->cap.max_recv_wr;
+ qp->rq.max_gs = attr->cap.max_recv_sge;
+ if (attr->qp_type != IBV_QPT_XRC_RECV)
+ mlx4_set_sq_sizes(qp, &attr->cap, attr->qp_type);
+
+ qp->doorbell_qpn = htobe32(qp->verbs_qp.qp.qp_num << 8);
+ if (attr->sq_sig_all)
+ qp->sq_signal_bits = htobe32(MLX4_WQE_CTRL_CQ_UPDATE);
+ else
+ qp->sq_signal_bits = 0;
+
+ return &qp->verbs_qp.qp;
+
+err_destroy:
+ ibv_cmd_destroy_qp(&qp->verbs_qp.qp);
+
+err_rq_db:
+ pthread_mutex_unlock(&to_mctx(context)->qp_table_mutex);
+ if (attr->cap.max_recv_sge)
+ mlx4_free_db(to_mctx(context), MLX4_DB_TYPE_RQ, qp->db);
+
+err_free:
+ free(qp->sq.wrid);
+ if (qp->rq.wqe_cnt)
+ free(qp->rq.wrid);
+ mlx4_free_buf(&qp->buf);
+
+err:
+ free(qp);
+
+ return NULL;
+}
+
+struct ibv_qp *mlx4_create_qp(struct ibv_pd *pd, struct ibv_qp_init_attr *attr)
+{
+ struct ibv_qp_init_attr_ex attr_ex;
+ struct ibv_qp *qp;
+
+ memcpy(&attr_ex, attr, sizeof *attr);
+ attr_ex.comp_mask = IBV_QP_INIT_ATTR_PD;
+ attr_ex.pd = pd;
+ qp = mlx4_create_qp_ex(pd->context, &attr_ex);
+ if (qp)
+ memcpy(attr, &attr_ex, sizeof *attr);
+ return qp;
+}
+
+struct ibv_qp *mlx4_open_qp(struct ibv_context *context, struct ibv_qp_open_attr *attr)
+{
+ struct ibv_open_qp cmd;
+ struct ibv_create_qp_resp resp;
+ struct mlx4_qp *qp;
+ int ret;
+
+ qp = calloc(1, sizeof *qp);
+ if (!qp)
+ return NULL;
+
+ ret = ibv_cmd_open_qp(context, &qp->verbs_qp, sizeof(qp->verbs_qp), attr,
+ &cmd, sizeof cmd, &resp, sizeof resp);
+ if (ret)
+ goto err;
+
+ return &qp->verbs_qp.qp;
+
+err:
+ free(qp);
+ return NULL;
+}
+
+int mlx4_query_qp(struct ibv_qp *ibqp, struct ibv_qp_attr *attr,
+ int attr_mask,
+ struct ibv_qp_init_attr *init_attr)
+{
+ struct ibv_query_qp cmd;
+ struct mlx4_qp *qp = to_mqp(ibqp);
+ int ret;
+
+ ret = ibv_cmd_query_qp(ibqp, attr, attr_mask, init_attr, &cmd, sizeof cmd);
+ if (ret)
+ return ret;
+
+ init_attr->cap.max_send_wr = qp->sq.max_post;
+ init_attr->cap.max_send_sge = qp->sq.max_gs;
+ init_attr->cap.max_inline_data = qp->max_inline_data;
+
+ attr->cap = init_attr->cap;
+
+ return 0;
+}
+
+int mlx4_modify_qp(struct ibv_qp *qp, struct ibv_qp_attr *attr,
+ int attr_mask)
+{
+ struct ibv_modify_qp cmd = {};
+ struct ibv_port_attr port_attr;
+ struct mlx4_qp *mqp = to_mqp(qp);
+ struct ibv_device_attr device_attr;
+ int ret;
+
+ memset(&device_attr, 0, sizeof(device_attr));
+ if (attr_mask & IBV_QP_PORT) {
+ ret = ibv_query_port(qp->context, attr->port_num,
+ &port_attr);
+ if (ret)
+ return ret;
+ mqp->link_layer = port_attr.link_layer;
+
+ ret = ibv_query_device(qp->context, &device_attr);
+ if (ret)
+ return ret;
+
+ switch(qp->qp_type) {
+ case IBV_QPT_UD:
+ if ((mqp->link_layer == IBV_LINK_LAYER_INFINIBAND) &&
+ (device_attr.device_cap_flags & IBV_DEVICE_UD_IP_CSUM))
+ mqp->qp_cap_cache |= MLX4_CSUM_SUPPORT_UD_OVER_IB |
+ MLX4_RX_CSUM_VALID;
+ break;
+ case IBV_QPT_RAW_PACKET:
+ if ((mqp->link_layer == IBV_LINK_LAYER_ETHERNET) &&
+ (device_attr.device_cap_flags & IBV_DEVICE_RAW_IP_CSUM))
+ mqp->qp_cap_cache |= MLX4_CSUM_SUPPORT_RAW_OVER_ETH |
+ MLX4_RX_CSUM_VALID;
+ break;
+ default:
+ break;
+ }
+
+ }
+
+ if (qp->state == IBV_QPS_RESET &&
+ attr_mask & IBV_QP_STATE &&
+ attr->qp_state == IBV_QPS_INIT) {
+ mlx4_qp_init_sq_ownership(to_mqp(qp));
+ }
+
+ ret = ibv_cmd_modify_qp(qp, attr, attr_mask, &cmd, sizeof cmd);
+
+ if (!ret &&
+ (attr_mask & IBV_QP_STATE) &&
+ attr->qp_state == IBV_QPS_RESET) {
+ if (qp->recv_cq)
+ mlx4_cq_clean(to_mcq(qp->recv_cq), qp->qp_num,
+ qp->srq ? to_msrq(qp->srq) : NULL);
+ if (qp->send_cq && qp->send_cq != qp->recv_cq)
+ mlx4_cq_clean(to_mcq(qp->send_cq), qp->qp_num, NULL);
+
+ mlx4_init_qp_indices(to_mqp(qp));
+ if (to_mqp(qp)->rq.wqe_cnt)
+ *to_mqp(qp)->db = 0;
+ }
+
+ return ret;
+}
+
+static void mlx4_lock_cqs(struct ibv_qp *qp)
+{
+ struct mlx4_cq *send_cq = to_mcq(qp->send_cq);
+ struct mlx4_cq *recv_cq = to_mcq(qp->recv_cq);
+
+ if (!qp->send_cq || !qp->recv_cq) {
+ if (qp->send_cq)
+ pthread_spin_lock(&send_cq->lock);
+ else if (qp->recv_cq)
+ pthread_spin_lock(&recv_cq->lock);
+ } else if (send_cq == recv_cq) {
+ pthread_spin_lock(&send_cq->lock);
+ } else if (send_cq->cqn < recv_cq->cqn) {
+ pthread_spin_lock(&send_cq->lock);
+ pthread_spin_lock(&recv_cq->lock);
+ } else {
+ pthread_spin_lock(&recv_cq->lock);
+ pthread_spin_lock(&send_cq->lock);
+ }
+}
+
+static void mlx4_unlock_cqs(struct ibv_qp *qp)
+{
+ struct mlx4_cq *send_cq = to_mcq(qp->send_cq);
+ struct mlx4_cq *recv_cq = to_mcq(qp->recv_cq);
+
+
+ if (!qp->send_cq || !qp->recv_cq) {
+ if (qp->send_cq)
+ pthread_spin_unlock(&send_cq->lock);
+ else if (qp->recv_cq)
+ pthread_spin_unlock(&recv_cq->lock);
+ } else if (send_cq == recv_cq) {
+ pthread_spin_unlock(&send_cq->lock);
+ } else if (send_cq->cqn < recv_cq->cqn) {
+ pthread_spin_unlock(&recv_cq->lock);
+ pthread_spin_unlock(&send_cq->lock);
+ } else {
+ pthread_spin_unlock(&send_cq->lock);
+ pthread_spin_unlock(&recv_cq->lock);
+ }
+}
+
+int mlx4_destroy_qp(struct ibv_qp *ibqp)
+{
+ struct mlx4_qp *qp = to_mqp(ibqp);
+ int ret;
+
+ pthread_mutex_lock(&to_mctx(ibqp->context)->qp_table_mutex);
+ ret = ibv_cmd_destroy_qp(ibqp);
+ if (ret) {
+ pthread_mutex_unlock(&to_mctx(ibqp->context)->qp_table_mutex);
+ return ret;
+ }
+
+ mlx4_lock_cqs(ibqp);
+
+ if (ibqp->recv_cq)
+ __mlx4_cq_clean(to_mcq(ibqp->recv_cq), ibqp->qp_num,
+ ibqp->srq ? to_msrq(ibqp->srq) : NULL);
+ if (ibqp->send_cq && ibqp->send_cq != ibqp->recv_cq)
+ __mlx4_cq_clean(to_mcq(ibqp->send_cq), ibqp->qp_num, NULL);
+
+ if (qp->sq.wqe_cnt || qp->rq.wqe_cnt)
+ mlx4_clear_qp(to_mctx(ibqp->context), ibqp->qp_num);
+
+ mlx4_unlock_cqs(ibqp);
+ pthread_mutex_unlock(&to_mctx(ibqp->context)->qp_table_mutex);
+
+ if (qp->rq.wqe_cnt) {
+ mlx4_free_db(to_mctx(ibqp->context), MLX4_DB_TYPE_RQ, qp->db);
+ free(qp->rq.wrid);
+ }
+ if (qp->sq.wqe_cnt)
+ free(qp->sq.wrid);
+ mlx4_free_buf(&qp->buf);
+ free(qp);
+
+ return 0;
+}
+
+static int link_local_gid(const union ibv_gid *gid)
+{
+ uint32_t *tmp = (uint32_t *)gid->raw;
+ uint32_t hi = tmp[0];
+ uint32_t lo = tmp[1];
+
+ if (hi == htobe32(0xfe800000) && lo == 0)
+ return 1;
+
+ return 0;
+}
+
+static int is_multicast_gid(const union ibv_gid *gid)
+{
+ return gid->raw[0] == 0xff;
+}
+
+static uint16_t get_vlan_id(union ibv_gid *gid)
+{
+ uint16_t vid;
+ vid = gid->raw[11] << 8 | gid->raw[12];
+ return vid < 0x1000 ? vid : 0xffff;
+}
+
+static int mlx4_resolve_grh_to_l2(struct ibv_pd *pd, struct mlx4_ah *ah,
+ struct ibv_ah_attr *attr)
+{
+ int err, i;
+ uint16_t vid;
+ union ibv_gid sgid;
+
+ if (link_local_gid(&attr->grh.dgid)) {
+ memcpy(ah->mac, &attr->grh.dgid.raw[8], 3);
+ memcpy(ah->mac + 3, &attr->grh.dgid.raw[13], 3);
+ ah->mac[0] ^= 2;
+
+ vid = get_vlan_id(&attr->grh.dgid);
+ } else if (is_multicast_gid(&attr->grh.dgid)) {
+ ah->mac[0] = 0x33;
+ ah->mac[1] = 0x33;
+ for (i = 2; i < 6; ++i)
+ ah->mac[i] = attr->grh.dgid.raw[i + 10];
+
+ err = ibv_query_gid(pd->context, attr->port_num,
+ attr->grh.sgid_index, &sgid);
+ if (err)
+ return err;
+
+ ah->av.dlid = htobe16(0xc000);
+ ah->av.port_pd |= htobe32(1 << 31);
+
+ vid = get_vlan_id(&sgid);
+ } else
+ return 1;
+
+ if (vid != 0xffff) {
+ ah->av.port_pd |= htobe32(1 << 29);
+ ah->vlan = vid | ((attr->sl & 7) << 13);
+ }
+
+ return 0;
+}
+
+struct ibv_ah *mlx4_create_ah(struct ibv_pd *pd, struct ibv_ah_attr *attr)
+{
+ struct mlx4_ah *ah;
+ struct ibv_port_attr port_attr;
+
+ if (query_port_cache(pd->context, attr->port_num, &port_attr))
+ return NULL;
+
+ ah = malloc(sizeof *ah);
+ if (!ah)
+ return NULL;
+
+ memset(&ah->av, 0, sizeof ah->av);
+
+ ah->av.port_pd = htobe32(to_mpd(pd)->pdn | (attr->port_num << 24));
+
+ if (port_attr.link_layer != IBV_LINK_LAYER_ETHERNET) {
+ ah->av.g_slid = attr->src_path_bits;
+ ah->av.dlid = htobe16(attr->dlid);
+ ah->av.sl_tclass_flowlabel = htobe32(attr->sl << 28);
+ } else
+ ah->av.sl_tclass_flowlabel = htobe32(attr->sl << 29);
+
+ if (attr->static_rate) {
+ ah->av.stat_rate = attr->static_rate + MLX4_STAT_RATE_OFFSET;
+ /* XXX check rate cap? */
+ }
+ if (attr->is_global) {
+ ah->av.g_slid |= 0x80;
+ ah->av.gid_index = attr->grh.sgid_index;
+ ah->av.hop_limit = attr->grh.hop_limit;
+ ah->av.sl_tclass_flowlabel |=
+ htobe32((attr->grh.traffic_class << 20) |
+ attr->grh.flow_label);
+ memcpy(ah->av.dgid, attr->grh.dgid.raw, 16);
+ }
+
+ if (port_attr.link_layer == IBV_LINK_LAYER_ETHERNET) {
+ if (port_attr.port_cap_flags & IBV_PORT_IP_BASED_GIDS) {
+ uint16_t vid;
+
+ if (ibv_resolve_eth_l2_from_gid(pd->context, attr,
+ ah->mac, &vid)) {
+ free(ah);
+ return NULL;
+ }
+
+ if (vid <= 0xfff) {
+ ah->av.port_pd |= htobe32(1 << 29);
+ ah->vlan = vid |
+ ((attr->sl & 7) << 13);
+ }
+
+ } else {
+ if (mlx4_resolve_grh_to_l2(pd, ah, attr)) {
+ free(ah);
+ return NULL;
+ }
+ }
+ }
+
+ return &ah->ibv_ah;
+}
+
+int mlx4_destroy_ah(struct ibv_ah *ah)
+{
+ free(to_mah(ah));
+
+ return 0;
+}
diff --git a/contrib/ofed/libmlx4/wqe.h b/contrib/ofed/libmlx4/wqe.h
new file mode 100644
index 0000000..6f833d9
--- /dev/null
+++ b/contrib/ofed/libmlx4/wqe.h
@@ -0,0 +1,149 @@
+/*
+ * Copyright (c) 2007 Cisco, Inc. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#ifndef WQE_H
+#define WQE_H
+
+#include <stdint.h>
+
+enum {
+ MLX4_SEND_DOORBELL = 0x14,
+};
+
+enum {
+ MLX4_WQE_CTRL_SOLICIT = 1 << 1,
+ MLX4_WQE_CTRL_CQ_UPDATE = 3 << 2,
+ MLX4_WQE_CTRL_IP_HDR_CSUM = 1 << 4,
+ MLX4_WQE_CTRL_TCP_UDP_CSUM = 1 << 5,
+ MLX4_WQE_CTRL_FENCE = 1 << 6,
+ MLX4_WQE_CTRL_STRONG_ORDER = 1 << 7
+};
+
+enum {
+ MLX4_WQE_BIND_TYPE_2 = (1<<31),
+ MLX4_WQE_BIND_ZERO_BASED = (1<<30),
+};
+
+enum {
+ MLX4_INLINE_SEG = 1 << 31,
+ MLX4_INLINE_ALIGN = 64,
+};
+
+enum {
+ MLX4_INVALID_LKEY = 0x100,
+};
+
+struct mlx4_wqe_ctrl_seg {
+ uint32_t owner_opcode;
+ union {
+ struct {
+ uint8_t reserved[3];
+ uint8_t fence_size;
+ };
+ uint32_t bf_qpn;
+ };
+ /*
+ * High 24 bits are SRC remote buffer; low 8 bits are flags:
+ * [7] SO (strong ordering)
+ * [5] TCP/UDP checksum
+ * [4] IP checksum
+ * [3:2] C (generate completion queue entry)
+ * [1] SE (solicited event)
+ * [0] FL (force loopback)
+ */
+ uint32_t srcrb_flags;
+ /*
+ * imm is immediate data for send/RDMA write w/ immediate;
+ * also invalidation key for send with invalidate; input
+ * modifier for WQEs on CCQs.
+ */
+ uint32_t imm;
+};
+
+struct mlx4_wqe_datagram_seg {
+ uint32_t av[8];
+ uint32_t dqpn;
+ uint32_t qkey;
+ uint16_t vlan;
+ uint8_t mac[6];
+};
+
+struct mlx4_wqe_data_seg {
+ uint32_t byte_count;
+ uint32_t lkey;
+ uint64_t addr;
+};
+
+struct mlx4_wqe_inline_seg {
+ uint32_t byte_count;
+};
+
+struct mlx4_wqe_srq_next_seg {
+ uint16_t reserved1;
+ uint16_t next_wqe_index;
+ uint32_t reserved2[3];
+};
+
+struct mlx4_wqe_local_inval_seg {
+ uint64_t reserved1;
+ uint32_t mem_key;
+ uint32_t reserved2;
+ uint64_t reserved3[2];
+};
+
+enum {
+ MLX4_WQE_MW_REMOTE_READ = 1 << 29,
+ MLX4_WQE_MW_REMOTE_WRITE = 1 << 30,
+ MLX4_WQE_MW_ATOMIC = 1 << 31
+};
+
+struct mlx4_wqe_raddr_seg {
+ uint64_t raddr;
+ uint32_t rkey;
+ uint32_t reserved;
+};
+
+struct mlx4_wqe_atomic_seg {
+ uint64_t swap_add;
+ uint64_t compare;
+};
+
+struct mlx4_wqe_bind_seg {
+ uint32_t flags1;
+ uint32_t flags2;
+ uint32_t new_rkey;
+ uint32_t lkey;
+ uint64_t addr;
+ uint64_t length;
+};
+
+#endif /* WQE_H */
diff --git a/contrib/ofed/libmlx5/Makefile b/contrib/ofed/libmlx5/Makefile
new file mode 100644
index 0000000..5e54172
--- /dev/null
+++ b/contrib/ofed/libmlx5/Makefile
@@ -0,0 +1,24 @@
+# $FreeBSD$
+
+.PATH: ${.CURDIR}
+
+SHLIBDIR?= /usr/lib
+LIB= mlx5
+SHLIB_MAJOR= 1
+MK_PROFILE= no
+
+SRCS= \
+buf.c \
+cq.c \
+dbrec.c \
+mlx5.c \
+qp.c \
+srq.c \
+verbs.c
+
+LIBADD= ibverbs pthread
+CFLAGS+= -I${.CURDIR}
+VERSION_MAP= ${.CURDIR}/libmlx5.map
+
+.include <bsd.lib.mk>
+
diff --git a/contrib/ofed/libmlx5/bitmap.h b/contrib/ofed/libmlx5/bitmap.h
new file mode 100644
index 0000000..4b18690
--- /dev/null
+++ b/contrib/ofed/libmlx5/bitmap.h
@@ -0,0 +1,111 @@
+/*
+ * Copyright (c) 2000, 2011 Mellanox Technology Inc. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#ifndef BITMAP_H
+#define BITMAP_H
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <pthread.h>
+#include <string.h>
+#include <sys/types.h>
+#include <sys/ipc.h>
+#include <sys/shm.h>
+#include <sys/mman.h>
+#include <errno.h>
+#include "mlx5.h"
+
+/* Only ia64 requires this */
+#ifdef __ia64__
+#define MLX5_SHM_ADDR ((void *)0x8000000000000000UL)
+#define MLX5_SHMAT_FLAGS (SHM_RND)
+#else
+#define MLX5_SHM_ADDR NULL
+#define MLX5_SHMAT_FLAGS 0
+#endif
+
+#define BITS_PER_LONG (8 * sizeof(long))
+#define BITS_TO_LONGS(nr) DIV_ROUND_UP(nr, BITS_PER_LONG)
+
+#ifndef HPAGE_SIZE
+#define HPAGE_SIZE (2UL * 1024 * 1024)
+#endif
+
+#define MLX5_SHM_LENGTH HPAGE_SIZE
+#define MLX5_Q_CHUNK_SIZE 32768
+#define MLX5_SHM_NUM_REGION 64
+
+static inline unsigned long mlx5_ffz(uint32_t word)
+{
+ return __builtin_ffs(~word) - 1;
+}
+
+static inline uint32_t mlx5_find_first_zero_bit(const unsigned long *addr,
+ uint32_t size)
+{
+ const unsigned long *p = addr;
+ uint32_t result = 0;
+ unsigned long tmp;
+
+ while (size & ~(BITS_PER_LONG - 1)) {
+ tmp = *(p++);
+ if (~tmp)
+ goto found;
+ result += BITS_PER_LONG;
+ size -= BITS_PER_LONG;
+ }
+ if (!size)
+ return result;
+
+ tmp = (*p) | (~0UL << size);
+ if (tmp == (uint32_t)~0UL) /* Are any bits zero? */
+ return result + size; /* Nope. */
+found:
+ return result + mlx5_ffz(tmp);
+}
+
+static inline void mlx5_set_bit(unsigned int nr, unsigned long *addr)
+{
+ addr[(nr / BITS_PER_LONG)] |= (1 << (nr % BITS_PER_LONG));
+}
+
+static inline void mlx5_clear_bit(unsigned int nr, unsigned long *addr)
+{
+ addr[(nr / BITS_PER_LONG)] &= ~(1 << (nr % BITS_PER_LONG));
+}
+
+static inline int mlx5_test_bit(unsigned int nr, const unsigned long *addr)
+{
+ return !!(addr[(nr / BITS_PER_LONG)] & (1 << (nr % BITS_PER_LONG)));
+}
+
+#endif
diff --git a/contrib/ofed/libmlx5/buf.c b/contrib/ofed/libmlx5/buf.c
new file mode 100644
index 0000000..df0f653
--- /dev/null
+++ b/contrib/ofed/libmlx5/buf.c
@@ -0,0 +1,571 @@
+/*
+ * Copyright (c) 2012 Mellanox Technologies, Inc. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#include <config.h>
+
+#include <signal.h>
+#include <sys/ipc.h>
+#include <sys/shm.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <errno.h>
+
+#include "mlx5.h"
+#include "bitmap.h"
+
+static int mlx5_bitmap_init(struct mlx5_bitmap *bitmap, uint32_t num,
+ uint32_t mask)
+{
+ bitmap->last = 0;
+ bitmap->top = 0;
+ bitmap->max = num;
+ bitmap->avail = num;
+ bitmap->mask = mask;
+ bitmap->avail = bitmap->max;
+ bitmap->table = calloc(BITS_TO_LONGS(bitmap->max), sizeof(uint32_t));
+ if (!bitmap->table)
+ return -ENOMEM;
+
+ return 0;
+}
+
+static void bitmap_free_range(struct mlx5_bitmap *bitmap, uint32_t obj,
+ int cnt)
+{
+ int i;
+
+ obj &= bitmap->max - 1;
+
+ for (i = 0; i < cnt; i++)
+ mlx5_clear_bit(obj + i, bitmap->table);
+ bitmap->last = min(bitmap->last, obj);
+ bitmap->top = (bitmap->top + bitmap->max) & bitmap->mask;
+ bitmap->avail += cnt;
+}
+
+static int bitmap_empty(struct mlx5_bitmap *bitmap)
+{
+ return (bitmap->avail == bitmap->max) ? 1 : 0;
+}
+
+static int bitmap_avail(struct mlx5_bitmap *bitmap)
+{
+ return bitmap->avail;
+}
+
+static void mlx5_bitmap_cleanup(struct mlx5_bitmap *bitmap)
+{
+ if (bitmap->table)
+ free(bitmap->table);
+}
+
+static void free_huge_mem(struct mlx5_hugetlb_mem *hmem)
+{
+ mlx5_bitmap_cleanup(&hmem->bitmap);
+ if (shmdt(hmem->shmaddr) == -1)
+ mlx5_dbg(stderr, MLX5_DBG_CONTIG, "%s\n", strerror(errno));
+ shmctl(hmem->shmid, IPC_RMID, NULL);
+ free(hmem);
+}
+
+static int mlx5_bitmap_alloc(struct mlx5_bitmap *bitmap)
+{
+ uint32_t obj;
+ int ret;
+
+ obj = mlx5_find_first_zero_bit(bitmap->table, bitmap->max);
+ if (obj < bitmap->max) {
+ mlx5_set_bit(obj, bitmap->table);
+ bitmap->last = (obj + 1);
+ if (bitmap->last == bitmap->max)
+ bitmap->last = 0;
+ obj |= bitmap->top;
+ ret = obj;
+ } else
+ ret = -1;
+
+ if (ret != -1)
+ --bitmap->avail;
+
+ return ret;
+}
+
+static uint32_t find_aligned_range(unsigned long *bitmap,
+ uint32_t start, uint32_t nbits,
+ int len, int alignment)
+{
+ uint32_t end, i;
+
+again:
+ start = align(start, alignment);
+
+ while ((start < nbits) && mlx5_test_bit(start, bitmap))
+ start += alignment;
+
+ if (start >= nbits)
+ return -1;
+
+ end = start + len;
+ if (end > nbits)
+ return -1;
+
+ for (i = start + 1; i < end; i++) {
+ if (mlx5_test_bit(i, bitmap)) {
+ start = i + 1;
+ goto again;
+ }
+ }
+
+ return start;
+}
+
+static int bitmap_alloc_range(struct mlx5_bitmap *bitmap, int cnt,
+ int align)
+{
+ uint32_t obj;
+ int ret, i;
+
+ if (cnt == 1 && align == 1)
+ return mlx5_bitmap_alloc(bitmap);
+
+ if (cnt > bitmap->max)
+ return -1;
+
+ obj = find_aligned_range(bitmap->table, bitmap->last,
+ bitmap->max, cnt, align);
+ if (obj >= bitmap->max) {
+ bitmap->top = (bitmap->top + bitmap->max) & bitmap->mask;
+ obj = find_aligned_range(bitmap->table, 0, bitmap->max,
+ cnt, align);
+ }
+
+ if (obj < bitmap->max) {
+ for (i = 0; i < cnt; i++)
+ mlx5_set_bit(obj + i, bitmap->table);
+ if (obj == bitmap->last) {
+ bitmap->last = (obj + cnt);
+ if (bitmap->last >= bitmap->max)
+ bitmap->last = 0;
+ }
+ obj |= bitmap->top;
+ ret = obj;
+ } else
+ ret = -1;
+
+ if (ret != -1)
+ bitmap->avail -= cnt;
+
+ return obj;
+}
+
+static struct mlx5_hugetlb_mem *alloc_huge_mem(size_t size)
+{
+ struct mlx5_hugetlb_mem *hmem;
+ size_t shm_len;
+
+ hmem = malloc(sizeof(*hmem));
+ if (!hmem)
+ return NULL;
+
+ shm_len = align(size, MLX5_SHM_LENGTH);
+ hmem->shmid = shmget(IPC_PRIVATE, shm_len, SHM_HUGETLB | SHM_R | SHM_W);
+ if (hmem->shmid == -1) {
+ mlx5_dbg(stderr, MLX5_DBG_CONTIG, "%s\n", strerror(errno));
+ goto out_free;
+ }
+
+ hmem->shmaddr = shmat(hmem->shmid, MLX5_SHM_ADDR, MLX5_SHMAT_FLAGS);
+ if (hmem->shmaddr == (void *)-1) {
+ mlx5_dbg(stderr, MLX5_DBG_CONTIG, "%s\n", strerror(errno));
+ goto out_rmid;
+ }
+
+ if (mlx5_bitmap_init(&hmem->bitmap, shm_len / MLX5_Q_CHUNK_SIZE,
+ shm_len / MLX5_Q_CHUNK_SIZE - 1)) {
+ mlx5_dbg(stderr, MLX5_DBG_CONTIG, "%s\n", strerror(errno));
+ goto out_shmdt;
+ }
+
+ /*
+ * Marked to be destroyed when process detaches from shmget segment
+ */
+ shmctl(hmem->shmid, IPC_RMID, NULL);
+
+ return hmem;
+
+out_shmdt:
+ if (shmdt(hmem->shmaddr) == -1)
+ mlx5_dbg(stderr, MLX5_DBG_CONTIG, "%s\n", strerror(errno));
+
+out_rmid:
+ shmctl(hmem->shmid, IPC_RMID, NULL);
+
+out_free:
+ free(hmem);
+ return NULL;
+}
+
+static int alloc_huge_buf(struct mlx5_context *mctx, struct mlx5_buf *buf,
+ size_t size, int page_size)
+{
+ int found = 0;
+ int nchunk;
+ struct mlx5_hugetlb_mem *hmem;
+ int ret;
+
+ buf->length = align(size, MLX5_Q_CHUNK_SIZE);
+ nchunk = buf->length / MLX5_Q_CHUNK_SIZE;
+
+ mlx5_spin_lock(&mctx->hugetlb_lock);
+ TAILQ_FOREACH(hmem, &mctx->hugetlb_list, entry) {
+ if (bitmap_avail(&hmem->bitmap)) {
+ buf->base = bitmap_alloc_range(&hmem->bitmap, nchunk, 1);
+ if (buf->base != -1) {
+ buf->hmem = hmem;
+ found = 1;
+ break;
+ }
+ }
+ }
+ mlx5_spin_unlock(&mctx->hugetlb_lock);
+
+ if (!found) {
+ hmem = alloc_huge_mem(buf->length);
+ if (!hmem)
+ return -1;
+
+ buf->base = bitmap_alloc_range(&hmem->bitmap, nchunk, 1);
+ if (buf->base == -1) {
+ free_huge_mem(hmem);
+ /* TBD: remove after proven stability */
+ fprintf(stderr, "BUG: huge allocation\n");
+ return -1;
+ }
+
+ buf->hmem = hmem;
+
+ mlx5_spin_lock(&mctx->hugetlb_lock);
+ if (bitmap_avail(&hmem->bitmap))
+ TAILQ_INSERT_HEAD(&mctx->hugetlb_list, hmem, entry);
+ else
+ TAILQ_INSERT_TAIL(&mctx->hugetlb_list, hmem, entry);
+ mlx5_spin_unlock(&mctx->hugetlb_lock);
+ }
+
+ buf->buf = hmem->shmaddr + buf->base * MLX5_Q_CHUNK_SIZE;
+
+ ret = ibv_dontfork_range(buf->buf, buf->length);
+ if (ret) {
+ mlx5_dbg(stderr, MLX5_DBG_CONTIG, "\n");
+ goto out_fork;
+ }
+ buf->type = MLX5_ALLOC_TYPE_HUGE;
+
+ return 0;
+
+out_fork:
+ mlx5_spin_lock(&mctx->hugetlb_lock);
+ bitmap_free_range(&hmem->bitmap, buf->base, nchunk);
+ if (bitmap_empty(&hmem->bitmap)) {
+ TAILQ_REMOVE(&mctx->hugetlb_list, hmem, entry);
+ mlx5_spin_unlock(&mctx->hugetlb_lock);
+ free_huge_mem(hmem);
+ } else
+ mlx5_spin_unlock(&mctx->hugetlb_lock);
+
+ return -1;
+}
+
+static void free_huge_buf(struct mlx5_context *ctx, struct mlx5_buf *buf)
+{
+ int nchunk;
+
+ nchunk = buf->length / MLX5_Q_CHUNK_SIZE;
+ mlx5_spin_lock(&ctx->hugetlb_lock);
+ bitmap_free_range(&buf->hmem->bitmap, buf->base, nchunk);
+ if (bitmap_empty(&buf->hmem->bitmap)) {
+ TAILQ_REMOVE(&ctx->hugetlb_list, buf->hmem, entry);
+ mlx5_spin_unlock(&ctx->hugetlb_lock);
+ free_huge_mem(buf->hmem);
+ } else
+ mlx5_spin_unlock(&ctx->hugetlb_lock);
+}
+
+int mlx5_alloc_prefered_buf(struct mlx5_context *mctx,
+ struct mlx5_buf *buf,
+ size_t size, int page_size,
+ enum mlx5_alloc_type type,
+ const char *component)
+{
+ int ret;
+
+ /*
+ * Fallback mechanism priority:
+ * huge pages
+ * contig pages
+ * default
+ */
+ if (type == MLX5_ALLOC_TYPE_HUGE ||
+ type == MLX5_ALLOC_TYPE_PREFER_HUGE ||
+ type == MLX5_ALLOC_TYPE_ALL) {
+ ret = alloc_huge_buf(mctx, buf, size, page_size);
+ if (!ret)
+ return 0;
+
+ if (type == MLX5_ALLOC_TYPE_HUGE)
+ return -1;
+
+ mlx5_dbg(stderr, MLX5_DBG_CONTIG,
+ "Huge mode allocation failed, fallback to %s mode\n",
+ MLX5_ALLOC_TYPE_ALL ? "contig" : "default");
+ }
+
+ if (type == MLX5_ALLOC_TYPE_CONTIG ||
+ type == MLX5_ALLOC_TYPE_PREFER_CONTIG ||
+ type == MLX5_ALLOC_TYPE_ALL) {
+ ret = mlx5_alloc_buf_contig(mctx, buf, size, page_size, component);
+ if (!ret)
+ return 0;
+
+ if (type == MLX5_ALLOC_TYPE_CONTIG)
+ return -1;
+ mlx5_dbg(stderr, MLX5_DBG_CONTIG,
+ "Contig allocation failed, fallback to default mode\n");
+ }
+
+ return mlx5_alloc_buf(buf, size, page_size);
+
+}
+
+int mlx5_free_actual_buf(struct mlx5_context *ctx, struct mlx5_buf *buf)
+{
+ int err = 0;
+
+ switch (buf->type) {
+ case MLX5_ALLOC_TYPE_ANON:
+ mlx5_free_buf(buf);
+ break;
+
+ case MLX5_ALLOC_TYPE_HUGE:
+ free_huge_buf(ctx, buf);
+ break;
+
+ case MLX5_ALLOC_TYPE_CONTIG:
+ mlx5_free_buf_contig(ctx, buf);
+ break;
+ default:
+ fprintf(stderr, "Bad allocation type\n");
+ }
+
+ return err;
+}
+
+/* This function computes log2(v) rounded up.
+ We don't want to have a dependency to libm which exposes ceil & log2 APIs.
+ Code was written based on public domain code:
+ URL: http://graphics.stanford.edu/~seander/bithacks.html#IntegerLog.
+*/
+static uint32_t mlx5_get_block_order(uint32_t v)
+{
+ static const uint32_t bits_arr[] = {0x2, 0xC, 0xF0, 0xFF00, 0xFFFF0000};
+ static const uint32_t shift_arr[] = {1, 2, 4, 8, 16};
+ int i;
+ uint32_t input_val = v;
+
+ register uint32_t r = 0;/* result of log2(v) will go here */
+ for (i = 4; i >= 0; i--) {
+ if (v & bits_arr[i]) {
+ v >>= shift_arr[i];
+ r |= shift_arr[i];
+ }
+ }
+ /* Rounding up if required */
+ r += !!(input_val & ((1 << r) - 1));
+
+ return r;
+}
+
+void mlx5_get_alloc_type(const char *component,
+ enum mlx5_alloc_type *alloc_type,
+ enum mlx5_alloc_type default_type)
+
+{
+ char *env_value;
+ char name[128];
+
+ snprintf(name, sizeof(name), "%s_ALLOC_TYPE", component);
+
+ *alloc_type = default_type;
+
+ env_value = getenv(name);
+ if (env_value) {
+ if (!strcasecmp(env_value, "ANON"))
+ *alloc_type = MLX5_ALLOC_TYPE_ANON;
+ else if (!strcasecmp(env_value, "HUGE"))
+ *alloc_type = MLX5_ALLOC_TYPE_HUGE;
+ else if (!strcasecmp(env_value, "CONTIG"))
+ *alloc_type = MLX5_ALLOC_TYPE_CONTIG;
+ else if (!strcasecmp(env_value, "PREFER_CONTIG"))
+ *alloc_type = MLX5_ALLOC_TYPE_PREFER_CONTIG;
+ else if (!strcasecmp(env_value, "PREFER_HUGE"))
+ *alloc_type = MLX5_ALLOC_TYPE_PREFER_HUGE;
+ else if (!strcasecmp(env_value, "ALL"))
+ *alloc_type = MLX5_ALLOC_TYPE_ALL;
+ }
+}
+
+static void mlx5_alloc_get_env_info(int *max_block_log,
+ int *min_block_log,
+ const char *component)
+
+{
+ char *env;
+ int value;
+ char name[128];
+
+ /* First set defaults */
+ *max_block_log = MLX5_MAX_LOG2_CONTIG_BLOCK_SIZE;
+ *min_block_log = MLX5_MIN_LOG2_CONTIG_BLOCK_SIZE;
+
+ snprintf(name, sizeof(name), "%s_MAX_LOG2_CONTIG_BSIZE", component);
+ env = getenv(name);
+ if (env) {
+ value = atoi(env);
+ if (value <= MLX5_MAX_LOG2_CONTIG_BLOCK_SIZE &&
+ value >= MLX5_MIN_LOG2_CONTIG_BLOCK_SIZE)
+ *max_block_log = value;
+ else
+ fprintf(stderr, "Invalid value %d for %s\n",
+ value, name);
+ }
+ sprintf(name, "%s_MIN_LOG2_CONTIG_BSIZE", component);
+ env = getenv(name);
+ if (env) {
+ value = atoi(env);
+ if (value >= MLX5_MIN_LOG2_CONTIG_BLOCK_SIZE &&
+ value <= *max_block_log)
+ *min_block_log = value;
+ else
+ fprintf(stderr, "Invalid value %d for %s\n",
+ value, name);
+ }
+}
+
+int mlx5_alloc_buf_contig(struct mlx5_context *mctx,
+ struct mlx5_buf *buf, size_t size,
+ int page_size,
+ const char *component)
+{
+ void *addr = MAP_FAILED;
+ int block_size_exp;
+ int max_block_log;
+ int min_block_log;
+ struct ibv_context *context = &mctx->ibv_ctx;
+ off_t offset;
+
+ mlx5_alloc_get_env_info(&max_block_log,
+ &min_block_log,
+ component);
+
+ block_size_exp = mlx5_get_block_order(size);
+
+ if (block_size_exp > max_block_log)
+ block_size_exp = max_block_log;
+
+ do {
+ offset = 0;
+ set_command(MLX5_MMAP_GET_CONTIGUOUS_PAGES_CMD, &offset);
+ set_order(block_size_exp, &offset);
+ addr = mmap(NULL , size, PROT_WRITE | PROT_READ, MAP_SHARED,
+ context->cmd_fd, page_size * offset);
+ if (addr != MAP_FAILED)
+ break;
+
+ /*
+ * The kernel returns EINVAL if not supported
+ */
+ if (errno == EINVAL)
+ return -1;
+
+ block_size_exp -= 1;
+ } while (block_size_exp >= min_block_log);
+ mlx5_dbg(mctx->dbg_fp, MLX5_DBG_CONTIG, "block order %d, addr %p\n",
+ block_size_exp, addr);
+
+ if (addr == MAP_FAILED)
+ return -1;
+
+ if (ibv_dontfork_range(addr, size)) {
+ munmap(addr, size);
+ return -1;
+ }
+
+ buf->buf = addr;
+ buf->length = size;
+ buf->type = MLX5_ALLOC_TYPE_CONTIG;
+
+ return 0;
+}
+
+void mlx5_free_buf_contig(struct mlx5_context *mctx, struct mlx5_buf *buf)
+{
+ ibv_dofork_range(buf->buf, buf->length);
+ munmap(buf->buf, buf->length);
+}
+
+int mlx5_alloc_buf(struct mlx5_buf *buf, size_t size, int page_size)
+{
+ int ret;
+ int al_size;
+
+ al_size = align(size, page_size);
+ ret = posix_memalign(&buf->buf, page_size, al_size);
+ if (ret)
+ return ret;
+
+ ret = ibv_dontfork_range(buf->buf, al_size);
+ if (ret)
+ free(buf->buf);
+
+ if (!ret) {
+ buf->length = al_size;
+ buf->type = MLX5_ALLOC_TYPE_ANON;
+ }
+
+ return ret;
+}
+
+void mlx5_free_buf(struct mlx5_buf *buf)
+{
+ ibv_dofork_range(buf->buf, buf->length);
+ free(buf->buf);
+}
diff --git a/contrib/ofed/libmlx5/config.h b/contrib/ofed/libmlx5/config.h
new file mode 100644
index 0000000..dede0ab
--- /dev/null
+++ b/contrib/ofed/libmlx5/config.h
@@ -0,0 +1,20 @@
+/* $FreeBSD$ */
+
+#define min_t(type, x, y) ({ \
+ type __min1 = (x); \
+ type __min2 = (y); \
+ __min1 < __min2 ? __min1 : __min2; })
+
+#define max_t(type, x, y) ({ \
+ type __max1 = (x); \
+ type __max2 = (y); \
+ __max1 > __max2 ? __max1 : __max2; })
+
+#define min(a, b) ((a) > (b) ? (b) : (a))
+#define max(a, b) ((a) < (b) ? (b) : (a))
+#define SWITCH_FALLTHROUGH (void)0
+#define ALWAYS_INLINE __attribute__ ((__always_inline__))
+#define VALGRIND_MAKE_MEM_DEFINED(...) 0
+#define likely(x) __predict_true(x)
+#define unlikely(x) __predict_false(x)
+#define SHM_HUGETLB 0
diff --git a/contrib/ofed/libmlx5/cq.c b/contrib/ofed/libmlx5/cq.c
new file mode 100644
index 0000000..d9fe5c0
--- /dev/null
+++ b/contrib/ofed/libmlx5/cq.c
@@ -0,0 +1,1519 @@
+/*
+ * Copyright (c) 2012 Mellanox Technologies, Inc. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#include <config.h>
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <pthread.h>
+#include <string.h>
+#include <errno.h>
+#include <unistd.h>
+
+#include <infiniband/opcode.h>
+
+#include "mlx5.h"
+#include "wqe.h"
+#include "doorbell.h"
+
+enum {
+ CQ_OK = 0,
+ CQ_EMPTY = -1,
+ CQ_POLL_ERR = -2
+};
+
+enum {
+ MLX5_CQ_MODIFY_RESEIZE = 0,
+ MLX5_CQ_MODIFY_MODER = 1,
+ MLX5_CQ_MODIFY_MAPPING = 2,
+};
+
+int mlx5_stall_num_loop = 60;
+int mlx5_stall_cq_poll_min = 60;
+int mlx5_stall_cq_poll_max = 100000;
+int mlx5_stall_cq_inc_step = 100;
+int mlx5_stall_cq_dec_step = 10;
+
+static inline uint8_t get_cqe_l3_hdr_type(struct mlx5_cqe64 *cqe)
+{
+ return (cqe->l4_hdr_type_etc >> 2) & 0x3;
+}
+
+static void *get_buf_cqe(struct mlx5_buf *buf, int n, int cqe_sz)
+{
+ return buf->buf + n * cqe_sz;
+}
+
+static void *get_cqe(struct mlx5_cq *cq, int n)
+{
+ return cq->active_buf->buf + n * cq->cqe_sz;
+}
+
+static void *get_sw_cqe(struct mlx5_cq *cq, int n)
+{
+ void *cqe = get_cqe(cq, n & cq->ibv_cq.cqe);
+ struct mlx5_cqe64 *cqe64;
+
+ cqe64 = (cq->cqe_sz == 64) ? cqe : cqe + 64;
+
+ if (likely(mlx5dv_get_cqe_opcode(cqe64) != MLX5_CQE_INVALID) &&
+ !((cqe64->op_own & MLX5_CQE_OWNER_MASK) ^ !!(n & (cq->ibv_cq.cqe + 1)))) {
+ return cqe;
+ } else {
+ return NULL;
+ }
+}
+
+static void *next_cqe_sw(struct mlx5_cq *cq)
+{
+ return get_sw_cqe(cq, cq->cons_index);
+}
+
+static void update_cons_index(struct mlx5_cq *cq)
+{
+ cq->dbrec[MLX5_CQ_SET_CI] = htobe32(cq->cons_index & 0xffffff);
+}
+
+static inline void handle_good_req(struct ibv_wc *wc, struct mlx5_cqe64 *cqe, struct mlx5_wq *wq, int idx)
+{
+ switch (be32toh(cqe->sop_drop_qpn) >> 24) {
+ case MLX5_OPCODE_RDMA_WRITE_IMM:
+ wc->wc_flags |= IBV_WC_WITH_IMM;
+ SWITCH_FALLTHROUGH;
+ case MLX5_OPCODE_RDMA_WRITE:
+ wc->opcode = IBV_WC_RDMA_WRITE;
+ break;
+ case MLX5_OPCODE_SEND_IMM:
+ wc->wc_flags |= IBV_WC_WITH_IMM;
+ SWITCH_FALLTHROUGH;
+ case MLX5_OPCODE_SEND:
+ case MLX5_OPCODE_SEND_INVAL:
+ wc->opcode = IBV_WC_SEND;
+ break;
+ case MLX5_OPCODE_RDMA_READ:
+ wc->opcode = IBV_WC_RDMA_READ;
+ wc->byte_len = be32toh(cqe->byte_cnt);
+ break;
+ case MLX5_OPCODE_ATOMIC_CS:
+ wc->opcode = IBV_WC_COMP_SWAP;
+ wc->byte_len = 8;
+ break;
+ case MLX5_OPCODE_ATOMIC_FA:
+ wc->opcode = IBV_WC_FETCH_ADD;
+ wc->byte_len = 8;
+ break;
+ case MLX5_OPCODE_UMR:
+ wc->opcode = wq->wr_data[idx];
+ break;
+ case MLX5_OPCODE_TSO:
+ wc->opcode = IBV_WC_TSO;
+ break;
+ }
+}
+
+static inline int handle_responder_lazy(struct mlx5_cq *cq, struct mlx5_cqe64 *cqe,
+ struct mlx5_resource *cur_rsc, struct mlx5_srq *srq)
+{
+ uint16_t wqe_ctr;
+ struct mlx5_wq *wq;
+ struct mlx5_qp *qp = rsc_to_mqp(cur_rsc);
+ int err = IBV_WC_SUCCESS;
+
+ if (srq) {
+ wqe_ctr = be16toh(cqe->wqe_counter);
+ cq->ibv_cq.wr_id = srq->wrid[wqe_ctr];
+ mlx5_free_srq_wqe(srq, wqe_ctr);
+ if (cqe->op_own & MLX5_INLINE_SCATTER_32)
+ err = mlx5_copy_to_recv_srq(srq, wqe_ctr, cqe,
+ be32toh(cqe->byte_cnt));
+ else if (cqe->op_own & MLX5_INLINE_SCATTER_64)
+ err = mlx5_copy_to_recv_srq(srq, wqe_ctr, cqe - 1,
+ be32toh(cqe->byte_cnt));
+ } else {
+ if (likely(cur_rsc->type == MLX5_RSC_TYPE_QP)) {
+ wq = &qp->rq;
+ if (qp->qp_cap_cache & MLX5_RX_CSUM_VALID)
+ cq->flags |= MLX5_CQ_FLAGS_RX_CSUM_VALID;
+ } else {
+ wq = &(rsc_to_mrwq(cur_rsc)->rq);
+ }
+
+ wqe_ctr = wq->tail & (wq->wqe_cnt - 1);
+ cq->ibv_cq.wr_id = wq->wrid[wqe_ctr];
+ ++wq->tail;
+ if (cqe->op_own & MLX5_INLINE_SCATTER_32)
+ err = mlx5_copy_to_recv_wqe(qp, wqe_ctr, cqe,
+ be32toh(cqe->byte_cnt));
+ else if (cqe->op_own & MLX5_INLINE_SCATTER_64)
+ err = mlx5_copy_to_recv_wqe(qp, wqe_ctr, cqe - 1,
+ be32toh(cqe->byte_cnt));
+ }
+
+ return err;
+}
+
+static inline int handle_responder(struct ibv_wc *wc, struct mlx5_cqe64 *cqe,
+ struct mlx5_resource *cur_rsc, struct mlx5_srq *srq)
+{
+ uint16_t wqe_ctr;
+ struct mlx5_wq *wq;
+ struct mlx5_qp *qp = rsc_to_mqp(cur_rsc);
+ uint8_t g;
+ int err = 0;
+
+ wc->byte_len = be32toh(cqe->byte_cnt);
+ if (srq) {
+ wqe_ctr = be16toh(cqe->wqe_counter);
+ wc->wr_id = srq->wrid[wqe_ctr];
+ mlx5_free_srq_wqe(srq, wqe_ctr);
+ if (cqe->op_own & MLX5_INLINE_SCATTER_32)
+ err = mlx5_copy_to_recv_srq(srq, wqe_ctr, cqe,
+ wc->byte_len);
+ else if (cqe->op_own & MLX5_INLINE_SCATTER_64)
+ err = mlx5_copy_to_recv_srq(srq, wqe_ctr, cqe - 1,
+ wc->byte_len);
+ } else {
+ if (likely(cur_rsc->type == MLX5_RSC_TYPE_QP)) {
+ wq = &qp->rq;
+ if (qp->qp_cap_cache & MLX5_RX_CSUM_VALID)
+ wc->wc_flags |= (!!(cqe->hds_ip_ext & MLX5_CQE_L4_OK) &
+ !!(cqe->hds_ip_ext & MLX5_CQE_L3_OK) &
+ (get_cqe_l3_hdr_type(cqe) ==
+ MLX5_CQE_L3_HDR_TYPE_IPV4)) <<
+ IBV_WC_IP_CSUM_OK_SHIFT;
+ } else {
+ wq = &(rsc_to_mrwq(cur_rsc)->rq);
+ }
+
+ wqe_ctr = wq->tail & (wq->wqe_cnt - 1);
+ wc->wr_id = wq->wrid[wqe_ctr];
+ ++wq->tail;
+ if (cqe->op_own & MLX5_INLINE_SCATTER_32)
+ err = mlx5_copy_to_recv_wqe(qp, wqe_ctr, cqe,
+ wc->byte_len);
+ else if (cqe->op_own & MLX5_INLINE_SCATTER_64)
+ err = mlx5_copy_to_recv_wqe(qp, wqe_ctr, cqe - 1,
+ wc->byte_len);
+ }
+ if (err)
+ return err;
+
+ switch (cqe->op_own >> 4) {
+ case MLX5_CQE_RESP_WR_IMM:
+ wc->opcode = IBV_WC_RECV_RDMA_WITH_IMM;
+ wc->wc_flags |= IBV_WC_WITH_IMM;
+ wc->imm_data = cqe->imm_inval_pkey;
+ break;
+ case MLX5_CQE_RESP_SEND:
+ wc->opcode = IBV_WC_RECV;
+ break;
+ case MLX5_CQE_RESP_SEND_IMM:
+ wc->opcode = IBV_WC_RECV;
+ wc->wc_flags |= IBV_WC_WITH_IMM;
+ wc->imm_data = cqe->imm_inval_pkey;
+ break;
+ case MLX5_CQE_RESP_SEND_INV:
+ wc->opcode = IBV_WC_RECV;
+ wc->wc_flags |= IBV_WC_WITH_INV;
+ wc->imm_data = be32toh(cqe->imm_inval_pkey);
+ break;
+ }
+ wc->slid = be16toh(cqe->slid);
+ wc->sl = (be32toh(cqe->flags_rqpn) >> 24) & 0xf;
+ wc->src_qp = be32toh(cqe->flags_rqpn) & 0xffffff;
+ wc->dlid_path_bits = cqe->ml_path & 0x7f;
+ g = (be32toh(cqe->flags_rqpn) >> 28) & 3;
+ wc->wc_flags |= g ? IBV_WC_GRH : 0;
+ wc->pkey_index = be32toh(cqe->imm_inval_pkey) & 0xffff;
+
+ return IBV_WC_SUCCESS;
+}
+
+static void dump_cqe(FILE *fp, void *buf)
+{
+ uint32_t *p = buf;
+ int i;
+
+ for (i = 0; i < 16; i += 4)
+ fprintf(fp, "%08x %08x %08x %08x\n", be32toh(p[i]), be32toh(p[i + 1]),
+ be32toh(p[i + 2]), be32toh(p[i + 3]));
+}
+
+static enum ibv_wc_status mlx5_handle_error_cqe(struct mlx5_err_cqe *cqe)
+{
+ switch (cqe->syndrome) {
+ case MLX5_CQE_SYNDROME_LOCAL_LENGTH_ERR:
+ return IBV_WC_LOC_LEN_ERR;
+ case MLX5_CQE_SYNDROME_LOCAL_QP_OP_ERR:
+ return IBV_WC_LOC_QP_OP_ERR;
+ case MLX5_CQE_SYNDROME_LOCAL_PROT_ERR:
+ return IBV_WC_LOC_PROT_ERR;
+ case MLX5_CQE_SYNDROME_WR_FLUSH_ERR:
+ return IBV_WC_WR_FLUSH_ERR;
+ case MLX5_CQE_SYNDROME_MW_BIND_ERR:
+ return IBV_WC_MW_BIND_ERR;
+ case MLX5_CQE_SYNDROME_BAD_RESP_ERR:
+ return IBV_WC_BAD_RESP_ERR;
+ case MLX5_CQE_SYNDROME_LOCAL_ACCESS_ERR:
+ return IBV_WC_LOC_ACCESS_ERR;
+ case MLX5_CQE_SYNDROME_REMOTE_INVAL_REQ_ERR:
+ return IBV_WC_REM_INV_REQ_ERR;
+ case MLX5_CQE_SYNDROME_REMOTE_ACCESS_ERR:
+ return IBV_WC_REM_ACCESS_ERR;
+ case MLX5_CQE_SYNDROME_REMOTE_OP_ERR:
+ return IBV_WC_REM_OP_ERR;
+ case MLX5_CQE_SYNDROME_TRANSPORT_RETRY_EXC_ERR:
+ return IBV_WC_RETRY_EXC_ERR;
+ case MLX5_CQE_SYNDROME_RNR_RETRY_EXC_ERR:
+ return IBV_WC_RNR_RETRY_EXC_ERR;
+ case MLX5_CQE_SYNDROME_REMOTE_ABORTED_ERR:
+ return IBV_WC_REM_ABORT_ERR;
+ default:
+ return IBV_WC_GENERAL_ERR;
+ }
+}
+
+#if defined(__x86_64__) || defined (__i386__)
+static inline unsigned long get_cycles(void)
+{
+ uint32_t low, high;
+ uint64_t val;
+ asm volatile ("rdtsc" : "=a" (low), "=d" (high));
+ val = high;
+ val = (val << 32) | low;
+ return val;
+}
+
+static void mlx5_stall_poll_cq(void)
+{
+ int i;
+
+ for (i = 0; i < mlx5_stall_num_loop; i++)
+ (void)get_cycles();
+}
+static void mlx5_stall_cycles_poll_cq(uint64_t cycles)
+{
+ while (get_cycles() < cycles)
+ ; /* Nothing */
+}
+static void mlx5_get_cycles(uint64_t *cycles)
+{
+ *cycles = get_cycles();
+}
+#else
+static void mlx5_stall_poll_cq(void)
+{
+}
+static void mlx5_stall_cycles_poll_cq(uint64_t cycles)
+{
+}
+static void mlx5_get_cycles(uint64_t *cycles)
+{
+}
+#endif
+
+static inline struct mlx5_qp *get_req_context(struct mlx5_context *mctx,
+ struct mlx5_resource **cur_rsc,
+ uint32_t rsn, int cqe_ver)
+ ALWAYS_INLINE;
+static inline struct mlx5_qp *get_req_context(struct mlx5_context *mctx,
+ struct mlx5_resource **cur_rsc,
+ uint32_t rsn, int cqe_ver)
+{
+ if (!*cur_rsc || (rsn != (*cur_rsc)->rsn))
+ *cur_rsc = cqe_ver ? mlx5_find_uidx(mctx, rsn) :
+ (struct mlx5_resource *)mlx5_find_qp(mctx, rsn);
+
+ return rsc_to_mqp(*cur_rsc);
+}
+
+static inline int get_resp_ctx_v1(struct mlx5_context *mctx,
+ struct mlx5_resource **cur_rsc,
+ struct mlx5_srq **cur_srq,
+ uint32_t uidx, uint8_t *is_srq)
+ ALWAYS_INLINE;
+static inline int get_resp_ctx_v1(struct mlx5_context *mctx,
+ struct mlx5_resource **cur_rsc,
+ struct mlx5_srq **cur_srq,
+ uint32_t uidx, uint8_t *is_srq)
+{
+ struct mlx5_qp *mqp;
+
+ if (!*cur_rsc || (uidx != (*cur_rsc)->rsn)) {
+ *cur_rsc = mlx5_find_uidx(mctx, uidx);
+ if (unlikely(!*cur_rsc))
+ return CQ_POLL_ERR;
+ }
+
+ switch ((*cur_rsc)->type) {
+ case MLX5_RSC_TYPE_QP:
+ mqp = rsc_to_mqp(*cur_rsc);
+ if (mqp->verbs_qp.qp.srq) {
+ *cur_srq = to_msrq(mqp->verbs_qp.qp.srq);
+ *is_srq = 1;
+ }
+ break;
+ case MLX5_RSC_TYPE_XSRQ:
+ *cur_srq = rsc_to_msrq(*cur_rsc);
+ *is_srq = 1;
+ break;
+ case MLX5_RSC_TYPE_RWQ:
+ break;
+ default:
+ return CQ_POLL_ERR;
+ }
+
+ return CQ_OK;
+}
+
+static inline int get_qp_ctx(struct mlx5_context *mctx,
+ struct mlx5_resource **cur_rsc,
+ uint32_t qpn)
+ ALWAYS_INLINE;
+static inline int get_qp_ctx(struct mlx5_context *mctx,
+ struct mlx5_resource **cur_rsc,
+ uint32_t qpn)
+{
+ if (!*cur_rsc || (qpn != (*cur_rsc)->rsn)) {
+ /*
+ * We do not have to take the QP table lock here,
+ * because CQs will be locked while QPs are removed
+ * from the table.
+ */
+ *cur_rsc = (struct mlx5_resource *)mlx5_find_qp(mctx, qpn);
+ if (unlikely(!*cur_rsc))
+ return CQ_POLL_ERR;
+ }
+
+ return CQ_OK;
+}
+
+static inline int get_srq_ctx(struct mlx5_context *mctx,
+ struct mlx5_srq **cur_srq,
+ uint32_t srqn_uidx)
+ ALWAYS_INLINE;
+static inline int get_srq_ctx(struct mlx5_context *mctx,
+ struct mlx5_srq **cur_srq,
+ uint32_t srqn)
+{
+ if (!*cur_srq || (srqn != (*cur_srq)->srqn)) {
+ *cur_srq = mlx5_find_srq(mctx, srqn);
+ if (unlikely(!*cur_srq))
+ return CQ_POLL_ERR;
+ }
+
+ return CQ_OK;
+}
+
+static inline int get_cur_rsc(struct mlx5_context *mctx,
+ int cqe_ver,
+ uint32_t qpn,
+ uint32_t srqn_uidx,
+ struct mlx5_resource **cur_rsc,
+ struct mlx5_srq **cur_srq,
+ uint8_t *is_srq)
+{
+ int err;
+
+ if (cqe_ver) {
+ err = get_resp_ctx_v1(mctx, cur_rsc, cur_srq, srqn_uidx,
+ is_srq);
+ } else {
+ if (srqn_uidx) {
+ *is_srq = 1;
+ err = get_srq_ctx(mctx, cur_srq, srqn_uidx);
+ } else {
+ err = get_qp_ctx(mctx, cur_rsc, qpn);
+ }
+ }
+
+ return err;
+
+}
+
+static inline int mlx5_get_next_cqe(struct mlx5_cq *cq,
+ struct mlx5_cqe64 **pcqe64,
+ void **pcqe)
+ ALWAYS_INLINE;
+static inline int mlx5_get_next_cqe(struct mlx5_cq *cq,
+ struct mlx5_cqe64 **pcqe64,
+ void **pcqe)
+{
+ void *cqe;
+ struct mlx5_cqe64 *cqe64;
+
+ cqe = next_cqe_sw(cq);
+ if (!cqe)
+ return CQ_EMPTY;
+
+ cqe64 = (cq->cqe_sz == 64) ? cqe : cqe + 64;
+
+ ++cq->cons_index;
+
+ VALGRIND_MAKE_MEM_DEFINED(cqe64, sizeof *cqe64);
+
+ /*
+ * Make sure we read CQ entry contents after we've checked the
+ * ownership bit.
+ */
+ udma_from_device_barrier();
+
+#ifdef MLX5_DEBUG
+ {
+ struct mlx5_context *mctx = to_mctx(cq->ibv_cq.context);
+
+ if (mlx5_debug_mask & MLX5_DBG_CQ_CQE) {
+ FILE *fp = mctx->dbg_fp;
+
+ mlx5_dbg(fp, MLX5_DBG_CQ_CQE, "dump cqe for cqn 0x%x:\n", cq->cqn);
+ dump_cqe(fp, cqe64);
+ }
+ }
+#endif
+ *pcqe64 = cqe64;
+ *pcqe = cqe;
+
+ return CQ_OK;
+}
+
+static inline int mlx5_parse_cqe(struct mlx5_cq *cq,
+ struct mlx5_cqe64 *cqe64,
+ void *cqe,
+ struct mlx5_resource **cur_rsc,
+ struct mlx5_srq **cur_srq,
+ struct ibv_wc *wc,
+ int cqe_ver, int lazy)
+ ALWAYS_INLINE;
+static inline int mlx5_parse_cqe(struct mlx5_cq *cq,
+ struct mlx5_cqe64 *cqe64,
+ void *cqe,
+ struct mlx5_resource **cur_rsc,
+ struct mlx5_srq **cur_srq,
+ struct ibv_wc *wc,
+ int cqe_ver, int lazy)
+{
+ struct mlx5_wq *wq;
+ uint16_t wqe_ctr;
+ uint32_t qpn;
+ uint32_t srqn_uidx;
+ int idx;
+ uint8_t opcode;
+ struct mlx5_err_cqe *ecqe;
+ int err = 0;
+ struct mlx5_qp *mqp;
+ struct mlx5_context *mctx;
+ uint8_t is_srq = 0;
+
+ mctx = to_mctx(ibv_cq_ex_to_cq(&cq->ibv_cq)->context);
+ qpn = be32toh(cqe64->sop_drop_qpn) & 0xffffff;
+ if (lazy) {
+ cq->cqe64 = cqe64;
+ cq->flags &= (~MLX5_CQ_FLAGS_RX_CSUM_VALID);
+ } else {
+ wc->wc_flags = 0;
+ wc->qp_num = qpn;
+ }
+
+ opcode = mlx5dv_get_cqe_opcode(cqe64);
+ switch (opcode) {
+ case MLX5_CQE_REQ:
+ {
+ mqp = get_req_context(mctx, cur_rsc,
+ (cqe_ver ? (be32toh(cqe64->srqn_uidx) & 0xffffff) : qpn),
+ cqe_ver);
+ if (unlikely(!mqp))
+ return CQ_POLL_ERR;
+ wq = &mqp->sq;
+ wqe_ctr = be16toh(cqe64->wqe_counter);
+ idx = wqe_ctr & (wq->wqe_cnt - 1);
+ if (lazy) {
+ uint32_t wc_byte_len;
+
+ switch (be32toh(cqe64->sop_drop_qpn) >> 24) {
+ case MLX5_OPCODE_UMR:
+ cq->umr_opcode = wq->wr_data[idx];
+ break;
+
+ case MLX5_OPCODE_RDMA_READ:
+ wc_byte_len = be32toh(cqe64->byte_cnt);
+ goto scatter_out;
+ case MLX5_OPCODE_ATOMIC_CS:
+ case MLX5_OPCODE_ATOMIC_FA:
+ wc_byte_len = 8;
+
+ scatter_out:
+ if (cqe64->op_own & MLX5_INLINE_SCATTER_32)
+ err = mlx5_copy_to_send_wqe(
+ mqp, wqe_ctr, cqe, wc_byte_len);
+ else if (cqe64->op_own & MLX5_INLINE_SCATTER_64)
+ err = mlx5_copy_to_send_wqe(
+ mqp, wqe_ctr, cqe - 1, wc_byte_len);
+ break;
+ }
+
+ cq->ibv_cq.wr_id = wq->wrid[idx];
+ cq->ibv_cq.status = err;
+ } else {
+ handle_good_req(wc, cqe64, wq, idx);
+
+ if (cqe64->op_own & MLX5_INLINE_SCATTER_32)
+ err = mlx5_copy_to_send_wqe(mqp, wqe_ctr, cqe,
+ wc->byte_len);
+ else if (cqe64->op_own & MLX5_INLINE_SCATTER_64)
+ err = mlx5_copy_to_send_wqe(
+ mqp, wqe_ctr, cqe - 1, wc->byte_len);
+
+ wc->wr_id = wq->wrid[idx];
+ wc->status = err;
+ }
+
+ wq->tail = wq->wqe_head[idx] + 1;
+ break;
+ }
+ case MLX5_CQE_RESP_WR_IMM:
+ case MLX5_CQE_RESP_SEND:
+ case MLX5_CQE_RESP_SEND_IMM:
+ case MLX5_CQE_RESP_SEND_INV:
+ srqn_uidx = be32toh(cqe64->srqn_uidx) & 0xffffff;
+ err = get_cur_rsc(mctx, cqe_ver, qpn, srqn_uidx, cur_rsc,
+ cur_srq, &is_srq);
+ if (unlikely(err))
+ return CQ_POLL_ERR;
+
+ if (lazy)
+ cq->ibv_cq.status = handle_responder_lazy(cq, cqe64,
+ *cur_rsc,
+ is_srq ? *cur_srq : NULL);
+ else
+ wc->status = handle_responder(wc, cqe64, *cur_rsc,
+ is_srq ? *cur_srq : NULL);
+ break;
+ case MLX5_CQE_RESIZE_CQ:
+ break;
+ case MLX5_CQE_REQ_ERR:
+ case MLX5_CQE_RESP_ERR:
+ srqn_uidx = be32toh(cqe64->srqn_uidx) & 0xffffff;
+ ecqe = (struct mlx5_err_cqe *)cqe64;
+ {
+ enum ibv_wc_status *pstatus = lazy ? &cq->ibv_cq.status : &wc->status;
+
+ *pstatus = mlx5_handle_error_cqe(ecqe);
+ }
+
+ if (!lazy)
+ wc->vendor_err = ecqe->vendor_err_synd;
+
+ if (unlikely(ecqe->syndrome != MLX5_CQE_SYNDROME_WR_FLUSH_ERR &&
+ ecqe->syndrome != MLX5_CQE_SYNDROME_TRANSPORT_RETRY_EXC_ERR)) {
+ FILE *fp = mctx->dbg_fp;
+ fprintf(fp, PFX "%s: got completion with error:\n",
+ mctx->hostname);
+ dump_cqe(fp, ecqe);
+ if (mlx5_freeze_on_error_cqe) {
+ fprintf(fp, PFX "freezing at poll cq...");
+ while (1)
+ sleep(10);
+ }
+ }
+
+ if (opcode == MLX5_CQE_REQ_ERR) {
+ mqp = get_req_context(mctx, cur_rsc,
+ (cqe_ver ? srqn_uidx : qpn), cqe_ver);
+ if (unlikely(!mqp))
+ return CQ_POLL_ERR;
+ wq = &mqp->sq;
+ wqe_ctr = be16toh(cqe64->wqe_counter);
+ idx = wqe_ctr & (wq->wqe_cnt - 1);
+ if (lazy)
+ cq->ibv_cq.wr_id = wq->wrid[idx];
+ else
+ wc->wr_id = wq->wrid[idx];
+ wq->tail = wq->wqe_head[idx] + 1;
+ } else {
+ err = get_cur_rsc(mctx, cqe_ver, qpn, srqn_uidx,
+ cur_rsc, cur_srq, &is_srq);
+ if (unlikely(err))
+ return CQ_POLL_ERR;
+
+ if (is_srq) {
+ wqe_ctr = be16toh(cqe64->wqe_counter);
+ if (lazy)
+ cq->ibv_cq.wr_id = (*cur_srq)->wrid[wqe_ctr];
+ else
+ wc->wr_id = (*cur_srq)->wrid[wqe_ctr];
+ mlx5_free_srq_wqe(*cur_srq, wqe_ctr);
+ } else {
+ switch ((*cur_rsc)->type) {
+ case MLX5_RSC_TYPE_RWQ:
+ wq = &(rsc_to_mrwq(*cur_rsc)->rq);
+ break;
+ default:
+ wq = &(rsc_to_mqp(*cur_rsc)->rq);
+ break;
+ }
+
+ if (lazy)
+ cq->ibv_cq.wr_id = wq->wrid[wq->tail & (wq->wqe_cnt - 1)];
+ else
+ wc->wr_id = wq->wrid[wq->tail & (wq->wqe_cnt - 1)];
+ ++wq->tail;
+ }
+ }
+ break;
+ }
+
+ return CQ_OK;
+}
+
+static inline int mlx5_parse_lazy_cqe(struct mlx5_cq *cq,
+ struct mlx5_cqe64 *cqe64,
+ void *cqe, int cqe_ver)
+ ALWAYS_INLINE;
+static inline int mlx5_parse_lazy_cqe(struct mlx5_cq *cq,
+ struct mlx5_cqe64 *cqe64,
+ void *cqe, int cqe_ver)
+{
+ return mlx5_parse_cqe(cq, cqe64, cqe, &cq->cur_rsc, &cq->cur_srq, NULL, cqe_ver, 1);
+}
+
+static inline int mlx5_poll_one(struct mlx5_cq *cq,
+ struct mlx5_resource **cur_rsc,
+ struct mlx5_srq **cur_srq,
+ struct ibv_wc *wc, int cqe_ver)
+ ALWAYS_INLINE;
+static inline int mlx5_poll_one(struct mlx5_cq *cq,
+ struct mlx5_resource **cur_rsc,
+ struct mlx5_srq **cur_srq,
+ struct ibv_wc *wc, int cqe_ver)
+{
+ struct mlx5_cqe64 *cqe64;
+ void *cqe;
+ int err;
+
+ err = mlx5_get_next_cqe(cq, &cqe64, &cqe);
+ if (err == CQ_EMPTY)
+ return err;
+
+ return mlx5_parse_cqe(cq, cqe64, cqe, cur_rsc, cur_srq, wc, cqe_ver, 0);
+}
+
+static inline int poll_cq(struct ibv_cq *ibcq, int ne,
+ struct ibv_wc *wc, int cqe_ver)
+ ALWAYS_INLINE;
+static inline int poll_cq(struct ibv_cq *ibcq, int ne,
+ struct ibv_wc *wc, int cqe_ver)
+{
+ struct mlx5_cq *cq = to_mcq(ibcq);
+ struct mlx5_resource *rsc = NULL;
+ struct mlx5_srq *srq = NULL;
+ int npolled;
+ int err = CQ_OK;
+
+ if (cq->stall_enable) {
+ if (cq->stall_adaptive_enable) {
+ if (cq->stall_last_count)
+ mlx5_stall_cycles_poll_cq(cq->stall_last_count + cq->stall_cycles);
+ } else if (cq->stall_next_poll) {
+ cq->stall_next_poll = 0;
+ mlx5_stall_poll_cq();
+ }
+ }
+
+ mlx5_spin_lock(&cq->lock);
+
+ for (npolled = 0; npolled < ne; ++npolled) {
+ err = mlx5_poll_one(cq, &rsc, &srq, wc + npolled, cqe_ver);
+ if (err != CQ_OK)
+ break;
+ }
+
+ update_cons_index(cq);
+
+ mlx5_spin_unlock(&cq->lock);
+
+ if (cq->stall_enable) {
+ if (cq->stall_adaptive_enable) {
+ if (npolled == 0) {
+ cq->stall_cycles = max(cq->stall_cycles-mlx5_stall_cq_dec_step,
+ mlx5_stall_cq_poll_min);
+ mlx5_get_cycles(&cq->stall_last_count);
+ } else if (npolled < ne) {
+ cq->stall_cycles = min(cq->stall_cycles+mlx5_stall_cq_inc_step,
+ mlx5_stall_cq_poll_max);
+ mlx5_get_cycles(&cq->stall_last_count);
+ } else {
+ cq->stall_cycles = max(cq->stall_cycles-mlx5_stall_cq_dec_step,
+ mlx5_stall_cq_poll_min);
+ cq->stall_last_count = 0;
+ }
+ } else if (err == CQ_EMPTY) {
+ cq->stall_next_poll = 1;
+ }
+ }
+
+ return err == CQ_POLL_ERR ? err : npolled;
+}
+
+enum polling_mode {
+ POLLING_MODE_NO_STALL,
+ POLLING_MODE_STALL,
+ POLLING_MODE_STALL_ADAPTIVE
+};
+
+static inline void _mlx5_end_poll(struct ibv_cq_ex *ibcq,
+ int lock, enum polling_mode stall)
+ ALWAYS_INLINE;
+static inline void _mlx5_end_poll(struct ibv_cq_ex *ibcq,
+ int lock, enum polling_mode stall)
+{
+ struct mlx5_cq *cq = to_mcq(ibv_cq_ex_to_cq(ibcq));
+
+ update_cons_index(cq);
+
+ if (lock)
+ mlx5_spin_unlock(&cq->lock);
+
+ if (stall) {
+ if (stall == POLLING_MODE_STALL_ADAPTIVE) {
+ if (!(cq->flags & MLX5_CQ_FLAGS_FOUND_CQES)) {
+ cq->stall_cycles = max(cq->stall_cycles - mlx5_stall_cq_dec_step,
+ mlx5_stall_cq_poll_min);
+ mlx5_get_cycles(&cq->stall_last_count);
+ } else if (cq->flags & MLX5_CQ_FLAGS_EMPTY_DURING_POLL) {
+ cq->stall_cycles = min(cq->stall_cycles + mlx5_stall_cq_inc_step,
+ mlx5_stall_cq_poll_max);
+ mlx5_get_cycles(&cq->stall_last_count);
+ } else {
+ cq->stall_cycles = max(cq->stall_cycles - mlx5_stall_cq_dec_step,
+ mlx5_stall_cq_poll_min);
+ cq->stall_last_count = 0;
+ }
+ } else if (!(cq->flags & MLX5_CQ_FLAGS_FOUND_CQES)) {
+ cq->stall_next_poll = 1;
+ }
+
+ cq->flags &= ~(MLX5_CQ_FLAGS_FOUND_CQES | MLX5_CQ_FLAGS_EMPTY_DURING_POLL);
+ }
+}
+
+static inline int mlx5_start_poll(struct ibv_cq_ex *ibcq, struct ibv_poll_cq_attr *attr,
+ int lock, enum polling_mode stall, int cqe_version)
+ ALWAYS_INLINE;
+static inline int mlx5_start_poll(struct ibv_cq_ex *ibcq, struct ibv_poll_cq_attr *attr,
+ int lock, enum polling_mode stall, int cqe_version)
+{
+ struct mlx5_cq *cq = to_mcq(ibv_cq_ex_to_cq(ibcq));
+ struct mlx5_cqe64 *cqe64;
+ void *cqe;
+ int err;
+
+ if (unlikely(attr->comp_mask))
+ return EINVAL;
+
+ if (stall) {
+ if (stall == POLLING_MODE_STALL_ADAPTIVE) {
+ if (cq->stall_last_count)
+ mlx5_stall_cycles_poll_cq(cq->stall_last_count + cq->stall_cycles);
+ } else if (cq->stall_next_poll) {
+ cq->stall_next_poll = 0;
+ mlx5_stall_poll_cq();
+ }
+ }
+
+ if (lock)
+ mlx5_spin_lock(&cq->lock);
+
+ cq->cur_rsc = NULL;
+ cq->cur_srq = NULL;
+
+ err = mlx5_get_next_cqe(cq, &cqe64, &cqe);
+ if (err == CQ_EMPTY) {
+ if (lock)
+ mlx5_spin_unlock(&cq->lock);
+
+ if (stall) {
+ if (stall == POLLING_MODE_STALL_ADAPTIVE) {
+ cq->stall_cycles = max(cq->stall_cycles - mlx5_stall_cq_dec_step,
+ mlx5_stall_cq_poll_min);
+ mlx5_get_cycles(&cq->stall_last_count);
+ } else {
+ cq->stall_next_poll = 1;
+ }
+ }
+
+ return ENOENT;
+ }
+
+ if (stall)
+ cq->flags |= MLX5_CQ_FLAGS_FOUND_CQES;
+
+ err = mlx5_parse_lazy_cqe(cq, cqe64, cqe, cqe_version);
+ if (lock && err)
+ mlx5_spin_unlock(&cq->lock);
+
+ if (stall && err) {
+ if (stall == POLLING_MODE_STALL_ADAPTIVE) {
+ cq->stall_cycles = max(cq->stall_cycles - mlx5_stall_cq_dec_step,
+ mlx5_stall_cq_poll_min);
+ cq->stall_last_count = 0;
+ }
+
+ cq->flags &= ~(MLX5_CQ_FLAGS_FOUND_CQES);
+ }
+
+ return err;
+}
+
+static inline int mlx5_next_poll(struct ibv_cq_ex *ibcq,
+ enum polling_mode stall, int cqe_version)
+ ALWAYS_INLINE;
+static inline int mlx5_next_poll(struct ibv_cq_ex *ibcq,
+ enum polling_mode stall,
+ int cqe_version)
+{
+ struct mlx5_cq *cq = to_mcq(ibv_cq_ex_to_cq(ibcq));
+ struct mlx5_cqe64 *cqe64;
+ void *cqe;
+ int err;
+
+ err = mlx5_get_next_cqe(cq, &cqe64, &cqe);
+ if (err == CQ_EMPTY) {
+ if (stall == POLLING_MODE_STALL_ADAPTIVE)
+ cq->flags |= MLX5_CQ_FLAGS_EMPTY_DURING_POLL;
+
+ return ENOENT;
+ }
+
+ return mlx5_parse_lazy_cqe(cq, cqe64, cqe, cqe_version);
+}
+
+static inline int mlx5_next_poll_adaptive_v0(struct ibv_cq_ex *ibcq)
+{
+ return mlx5_next_poll(ibcq, POLLING_MODE_STALL_ADAPTIVE, 0);
+}
+
+static inline int mlx5_next_poll_adaptive_v1(struct ibv_cq_ex *ibcq)
+{
+ return mlx5_next_poll(ibcq, POLLING_MODE_STALL_ADAPTIVE, 1);
+}
+
+static inline int mlx5_next_poll_v0(struct ibv_cq_ex *ibcq)
+{
+ return mlx5_next_poll(ibcq, 0, 0);
+}
+
+static inline int mlx5_next_poll_v1(struct ibv_cq_ex *ibcq)
+{
+ return mlx5_next_poll(ibcq, 0, 1);
+}
+
+static inline int mlx5_start_poll_v0(struct ibv_cq_ex *ibcq,
+ struct ibv_poll_cq_attr *attr)
+{
+ return mlx5_start_poll(ibcq, attr, 0, 0, 0);
+}
+
+static inline int mlx5_start_poll_v1(struct ibv_cq_ex *ibcq,
+ struct ibv_poll_cq_attr *attr)
+{
+ return mlx5_start_poll(ibcq, attr, 0, 0, 1);
+}
+
+static inline int mlx5_start_poll_v0_lock(struct ibv_cq_ex *ibcq,
+ struct ibv_poll_cq_attr *attr)
+{
+ return mlx5_start_poll(ibcq, attr, 1, 0, 0);
+}
+
+static inline int mlx5_start_poll_v1_lock(struct ibv_cq_ex *ibcq,
+ struct ibv_poll_cq_attr *attr)
+{
+ return mlx5_start_poll(ibcq, attr, 1, 0, 1);
+}
+
+static inline int mlx5_start_poll_adaptive_stall_v0_lock(struct ibv_cq_ex *ibcq,
+ struct ibv_poll_cq_attr *attr)
+{
+ return mlx5_start_poll(ibcq, attr, 1, POLLING_MODE_STALL_ADAPTIVE, 0);
+}
+
+static inline int mlx5_start_poll_stall_v0_lock(struct ibv_cq_ex *ibcq,
+ struct ibv_poll_cq_attr *attr)
+{
+ return mlx5_start_poll(ibcq, attr, 1, POLLING_MODE_STALL, 0);
+}
+
+static inline int mlx5_start_poll_adaptive_stall_v1_lock(struct ibv_cq_ex *ibcq,
+ struct ibv_poll_cq_attr *attr)
+{
+ return mlx5_start_poll(ibcq, attr, 1, POLLING_MODE_STALL_ADAPTIVE, 1);
+}
+
+static inline int mlx5_start_poll_stall_v1_lock(struct ibv_cq_ex *ibcq,
+ struct ibv_poll_cq_attr *attr)
+{
+ return mlx5_start_poll(ibcq, attr, 1, POLLING_MODE_STALL, 1);
+}
+
+static inline int mlx5_start_poll_stall_v0(struct ibv_cq_ex *ibcq,
+ struct ibv_poll_cq_attr *attr)
+{
+ return mlx5_start_poll(ibcq, attr, 0, POLLING_MODE_STALL, 0);
+}
+
+static inline int mlx5_start_poll_adaptive_stall_v0(struct ibv_cq_ex *ibcq,
+ struct ibv_poll_cq_attr *attr)
+{
+ return mlx5_start_poll(ibcq, attr, 0, POLLING_MODE_STALL_ADAPTIVE, 0);
+}
+
+static inline int mlx5_start_poll_adaptive_stall_v1(struct ibv_cq_ex *ibcq,
+ struct ibv_poll_cq_attr *attr)
+{
+ return mlx5_start_poll(ibcq, attr, 0, POLLING_MODE_STALL_ADAPTIVE, 1);
+}
+
+static inline int mlx5_start_poll_stall_v1(struct ibv_cq_ex *ibcq,
+ struct ibv_poll_cq_attr *attr)
+{
+ return mlx5_start_poll(ibcq, attr, 0, POLLING_MODE_STALL, 1);
+}
+
+static inline void mlx5_end_poll_adaptive_stall_lock(struct ibv_cq_ex *ibcq)
+{
+ _mlx5_end_poll(ibcq, 1, POLLING_MODE_STALL_ADAPTIVE);
+}
+
+static inline void mlx5_end_poll_stall_lock(struct ibv_cq_ex *ibcq)
+{
+ _mlx5_end_poll(ibcq, 1, POLLING_MODE_STALL);
+}
+
+static inline void mlx5_end_poll_adaptive_stall(struct ibv_cq_ex *ibcq)
+{
+ _mlx5_end_poll(ibcq, 0, POLLING_MODE_STALL_ADAPTIVE);
+}
+
+static inline void mlx5_end_poll_stall(struct ibv_cq_ex *ibcq)
+{
+ _mlx5_end_poll(ibcq, 0, POLLING_MODE_STALL);
+}
+
+static inline void mlx5_end_poll(struct ibv_cq_ex *ibcq)
+{
+ _mlx5_end_poll(ibcq, 0, 0);
+}
+
+static inline void mlx5_end_poll_lock(struct ibv_cq_ex *ibcq)
+{
+ _mlx5_end_poll(ibcq, 1, 0);
+}
+
+int mlx5_poll_cq(struct ibv_cq *ibcq, int ne, struct ibv_wc *wc)
+{
+ return poll_cq(ibcq, ne, wc, 0);
+}
+
+int mlx5_poll_cq_v1(struct ibv_cq *ibcq, int ne, struct ibv_wc *wc)
+{
+ return poll_cq(ibcq, ne, wc, 1);
+}
+
+static inline enum ibv_wc_opcode mlx5_cq_read_wc_opcode(struct ibv_cq_ex *ibcq)
+{
+ struct mlx5_cq *cq = to_mcq(ibv_cq_ex_to_cq(ibcq));
+
+ switch (mlx5dv_get_cqe_opcode(cq->cqe64)) {
+ case MLX5_CQE_RESP_WR_IMM:
+ return IBV_WC_RECV_RDMA_WITH_IMM;
+ case MLX5_CQE_RESP_SEND:
+ case MLX5_CQE_RESP_SEND_IMM:
+ case MLX5_CQE_RESP_SEND_INV:
+ return IBV_WC_RECV;
+ case MLX5_CQE_REQ:
+ switch (be32toh(cq->cqe64->sop_drop_qpn) >> 24) {
+ case MLX5_OPCODE_RDMA_WRITE_IMM:
+ case MLX5_OPCODE_RDMA_WRITE:
+ return IBV_WC_RDMA_WRITE;
+ case MLX5_OPCODE_SEND_IMM:
+ case MLX5_OPCODE_SEND:
+ case MLX5_OPCODE_SEND_INVAL:
+ return IBV_WC_SEND;
+ case MLX5_OPCODE_RDMA_READ:
+ return IBV_WC_RDMA_READ;
+ case MLX5_OPCODE_ATOMIC_CS:
+ return IBV_WC_COMP_SWAP;
+ case MLX5_OPCODE_ATOMIC_FA:
+ return IBV_WC_FETCH_ADD;
+ case MLX5_OPCODE_UMR:
+ return cq->umr_opcode;
+ case MLX5_OPCODE_TSO:
+ return IBV_WC_TSO;
+ }
+ }
+
+#ifdef MLX5_DEBUG
+{
+ struct mlx5_context *ctx = to_mctx(ibcq->context);
+
+ mlx5_dbg(ctx->dbg_fp, MLX5_DBG_CQ_CQE, "un-expected opcode in cqe\n");
+}
+#endif
+ return 0;
+}
+
+static inline uint32_t mlx5_cq_read_wc_qp_num(struct ibv_cq_ex *ibcq)
+{
+ struct mlx5_cq *cq = to_mcq(ibv_cq_ex_to_cq(ibcq));
+
+ return be32toh(cq->cqe64->sop_drop_qpn) & 0xffffff;
+}
+
+static inline int mlx5_cq_read_wc_flags(struct ibv_cq_ex *ibcq)
+{
+ struct mlx5_cq *cq = to_mcq(ibv_cq_ex_to_cq(ibcq));
+ int wc_flags = 0;
+
+ if (cq->flags & MLX5_CQ_FLAGS_RX_CSUM_VALID)
+ wc_flags = (!!(cq->cqe64->hds_ip_ext & MLX5_CQE_L4_OK) &
+ !!(cq->cqe64->hds_ip_ext & MLX5_CQE_L3_OK) &
+ (get_cqe_l3_hdr_type(cq->cqe64) ==
+ MLX5_CQE_L3_HDR_TYPE_IPV4)) <<
+ IBV_WC_IP_CSUM_OK_SHIFT;
+
+ switch (mlx5dv_get_cqe_opcode(cq->cqe64)) {
+ case MLX5_CQE_RESP_WR_IMM:
+ case MLX5_CQE_RESP_SEND_IMM:
+ wc_flags |= IBV_WC_WITH_IMM;
+ break;
+ case MLX5_CQE_RESP_SEND_INV:
+ wc_flags |= IBV_WC_WITH_INV;
+ break;
+ }
+
+ wc_flags |= ((be32toh(cq->cqe64->flags_rqpn) >> 28) & 3) ? IBV_WC_GRH : 0;
+ return wc_flags;
+}
+
+static inline uint32_t mlx5_cq_read_wc_byte_len(struct ibv_cq_ex *ibcq)
+{
+ struct mlx5_cq *cq = to_mcq(ibv_cq_ex_to_cq(ibcq));
+
+ return be32toh(cq->cqe64->byte_cnt);
+}
+
+static inline uint32_t mlx5_cq_read_wc_vendor_err(struct ibv_cq_ex *ibcq)
+{
+ struct mlx5_cq *cq = to_mcq(ibv_cq_ex_to_cq(ibcq));
+ struct mlx5_err_cqe *ecqe = (struct mlx5_err_cqe *)cq->cqe64;
+
+ return ecqe->vendor_err_synd;
+}
+
+static inline uint32_t mlx5_cq_read_wc_imm_data(struct ibv_cq_ex *ibcq)
+{
+ struct mlx5_cq *cq = to_mcq(ibv_cq_ex_to_cq(ibcq));
+
+ switch (mlx5dv_get_cqe_opcode(cq->cqe64)) {
+ case MLX5_CQE_RESP_SEND_INV:
+ return be32toh(cq->cqe64->imm_inval_pkey);
+ default:
+ return cq->cqe64->imm_inval_pkey;
+ }
+}
+
+static inline uint32_t mlx5_cq_read_wc_slid(struct ibv_cq_ex *ibcq)
+{
+ struct mlx5_cq *cq = to_mcq(ibv_cq_ex_to_cq(ibcq));
+
+ return (uint32_t)be16toh(cq->cqe64->slid);
+}
+
+static inline uint8_t mlx5_cq_read_wc_sl(struct ibv_cq_ex *ibcq)
+{
+ struct mlx5_cq *cq = to_mcq(ibv_cq_ex_to_cq(ibcq));
+
+ return (be32toh(cq->cqe64->flags_rqpn) >> 24) & 0xf;
+}
+
+static inline uint32_t mlx5_cq_read_wc_src_qp(struct ibv_cq_ex *ibcq)
+{
+ struct mlx5_cq *cq = to_mcq(ibv_cq_ex_to_cq(ibcq));
+
+ return be32toh(cq->cqe64->flags_rqpn) & 0xffffff;
+}
+
+static inline uint8_t mlx5_cq_read_wc_dlid_path_bits(struct ibv_cq_ex *ibcq)
+{
+ struct mlx5_cq *cq = to_mcq(ibv_cq_ex_to_cq(ibcq));
+
+ return cq->cqe64->ml_path & 0x7f;
+}
+
+static inline uint64_t mlx5_cq_read_wc_completion_ts(struct ibv_cq_ex *ibcq)
+{
+ struct mlx5_cq *cq = to_mcq(ibv_cq_ex_to_cq(ibcq));
+
+ return be64toh(cq->cqe64->timestamp);
+}
+
+static inline uint16_t mlx5_cq_read_wc_cvlan(struct ibv_cq_ex *ibcq)
+{
+ struct mlx5_cq *cq = to_mcq(ibv_cq_ex_to_cq(ibcq));
+
+ return be16toh(cq->cqe64->vlan_info);
+}
+
+static inline uint32_t mlx5_cq_read_flow_tag(struct ibv_cq_ex *ibcq)
+{
+ struct mlx5_cq *cq = to_mcq(ibv_cq_ex_to_cq(ibcq));
+
+ return be32toh(cq->cqe64->sop_drop_qpn) & MLX5_FLOW_TAG_MASK;
+}
+
+#define BIT(i) (1UL << (i))
+
+#define SINGLE_THREADED BIT(0)
+#define STALL BIT(1)
+#define V1 BIT(2)
+#define ADAPTIVE BIT(3)
+
+#define mlx5_start_poll_name(cqe_ver, lock, stall, adaptive) \
+ mlx5_start_poll##adaptive##stall##cqe_ver##lock
+#define mlx5_next_poll_name(cqe_ver, adaptive) \
+ mlx5_next_poll##adaptive##cqe_ver
+#define mlx5_end_poll_name(lock, stall, adaptive) \
+ mlx5_end_poll##adaptive##stall##lock
+
+#define POLL_FN_ENTRY(cqe_ver, lock, stall, adaptive) { \
+ .start_poll = &mlx5_start_poll_name(cqe_ver, lock, stall, adaptive), \
+ .next_poll = &mlx5_next_poll_name(cqe_ver, adaptive), \
+ .end_poll = &mlx5_end_poll_name(lock, stall, adaptive), \
+ }
+
+static const struct op
+{
+ int (*start_poll)(struct ibv_cq_ex *ibcq, struct ibv_poll_cq_attr *attr);
+ int (*next_poll)(struct ibv_cq_ex *ibcq);
+ void (*end_poll)(struct ibv_cq_ex *ibcq);
+} ops[ADAPTIVE + V1 + STALL + SINGLE_THREADED + 1] = {
+ [V1] = POLL_FN_ENTRY(_v1, _lock, , ),
+ [0] = POLL_FN_ENTRY(_v0, _lock, , ),
+ [V1 | SINGLE_THREADED] = POLL_FN_ENTRY(_v1, , , ),
+ [SINGLE_THREADED] = POLL_FN_ENTRY(_v0, , , ),
+ [V1 | STALL] = POLL_FN_ENTRY(_v1, _lock, _stall, ),
+ [STALL] = POLL_FN_ENTRY(_v0, _lock, _stall, ),
+ [V1 | SINGLE_THREADED | STALL] = POLL_FN_ENTRY(_v1, , _stall, ),
+ [SINGLE_THREADED | STALL] = POLL_FN_ENTRY(_v0, , _stall, ),
+ [V1 | STALL | ADAPTIVE] = POLL_FN_ENTRY(_v1, _lock, _stall, _adaptive),
+ [STALL | ADAPTIVE] = POLL_FN_ENTRY(_v0, _lock, _stall, _adaptive),
+ [V1 | SINGLE_THREADED | STALL | ADAPTIVE] = POLL_FN_ENTRY(_v1, , _stall, _adaptive),
+ [SINGLE_THREADED | STALL | ADAPTIVE] = POLL_FN_ENTRY(_v0, , _stall, _adaptive),
+};
+
+void mlx5_cq_fill_pfns(struct mlx5_cq *cq, const struct ibv_cq_init_attr_ex *cq_attr)
+{
+ struct mlx5_context *mctx = to_mctx(ibv_cq_ex_to_cq(&cq->ibv_cq)->context);
+ const struct op *poll_ops = &ops[((cq->stall_enable && cq->stall_adaptive_enable) ? ADAPTIVE : 0) |
+ (mctx->cqe_version ? V1 : 0) |
+ (cq->flags & MLX5_CQ_FLAGS_SINGLE_THREADED ?
+ SINGLE_THREADED : 0) |
+ (cq->stall_enable ? STALL : 0)];
+
+ cq->ibv_cq.start_poll = poll_ops->start_poll;
+ cq->ibv_cq.next_poll = poll_ops->next_poll;
+ cq->ibv_cq.end_poll = poll_ops->end_poll;
+
+ cq->ibv_cq.read_opcode = mlx5_cq_read_wc_opcode;
+ cq->ibv_cq.read_vendor_err = mlx5_cq_read_wc_vendor_err;
+ cq->ibv_cq.read_wc_flags = mlx5_cq_read_wc_flags;
+ if (cq_attr->wc_flags & IBV_WC_EX_WITH_BYTE_LEN)
+ cq->ibv_cq.read_byte_len = mlx5_cq_read_wc_byte_len;
+ if (cq_attr->wc_flags & IBV_WC_EX_WITH_IMM)
+ cq->ibv_cq.read_imm_data = mlx5_cq_read_wc_imm_data;
+ if (cq_attr->wc_flags & IBV_WC_EX_WITH_QP_NUM)
+ cq->ibv_cq.read_qp_num = mlx5_cq_read_wc_qp_num;
+ if (cq_attr->wc_flags & IBV_WC_EX_WITH_SRC_QP)
+ cq->ibv_cq.read_src_qp = mlx5_cq_read_wc_src_qp;
+ if (cq_attr->wc_flags & IBV_WC_EX_WITH_SLID)
+ cq->ibv_cq.read_slid = mlx5_cq_read_wc_slid;
+ if (cq_attr->wc_flags & IBV_WC_EX_WITH_SL)
+ cq->ibv_cq.read_sl = mlx5_cq_read_wc_sl;
+ if (cq_attr->wc_flags & IBV_WC_EX_WITH_DLID_PATH_BITS)
+ cq->ibv_cq.read_dlid_path_bits = mlx5_cq_read_wc_dlid_path_bits;
+ if (cq_attr->wc_flags & IBV_WC_EX_WITH_COMPLETION_TIMESTAMP)
+ cq->ibv_cq.read_completion_ts = mlx5_cq_read_wc_completion_ts;
+ if (cq_attr->wc_flags & IBV_WC_EX_WITH_CVLAN)
+ cq->ibv_cq.read_cvlan = mlx5_cq_read_wc_cvlan;
+ if (cq_attr->wc_flags & IBV_WC_EX_WITH_FLOW_TAG)
+ cq->ibv_cq.read_flow_tag = mlx5_cq_read_flow_tag;
+}
+
+int mlx5_arm_cq(struct ibv_cq *ibvcq, int solicited)
+{
+ struct mlx5_cq *cq = to_mcq(ibvcq);
+ struct mlx5_context *ctx = to_mctx(ibvcq->context);
+ uint32_t doorbell[2];
+ uint32_t sn;
+ uint32_t ci;
+ uint32_t cmd;
+
+ sn = cq->arm_sn & 3;
+ ci = cq->cons_index & 0xffffff;
+ cmd = solicited ? MLX5_CQ_DB_REQ_NOT_SOL : MLX5_CQ_DB_REQ_NOT;
+
+ cq->dbrec[MLX5_CQ_ARM_DB] = htobe32(sn << 28 | cmd | ci);
+
+ /*
+ * Make sure that the doorbell record in host memory is
+ * written before ringing the doorbell via PCI WC MMIO.
+ */
+ mmio_wc_start();
+
+ doorbell[0] = htobe32(sn << 28 | cmd | ci);
+ doorbell[1] = htobe32(cq->cqn);
+
+ mlx5_write64(doorbell, ctx->uar[0] + MLX5_CQ_DOORBELL, &ctx->lock32);
+
+ mmio_flush_writes();
+
+ return 0;
+}
+
+void mlx5_cq_event(struct ibv_cq *cq)
+{
+ to_mcq(cq)->arm_sn++;
+}
+
+static int is_equal_rsn(struct mlx5_cqe64 *cqe64, uint32_t rsn)
+{
+ return rsn == (be32toh(cqe64->sop_drop_qpn) & 0xffffff);
+}
+
+static inline int is_equal_uidx(struct mlx5_cqe64 *cqe64, uint32_t uidx)
+{
+ return uidx == (be32toh(cqe64->srqn_uidx) & 0xffffff);
+}
+
+static inline int is_responder(uint8_t opcode)
+{
+ switch (opcode) {
+ case MLX5_CQE_RESP_WR_IMM:
+ case MLX5_CQE_RESP_SEND:
+ case MLX5_CQE_RESP_SEND_IMM:
+ case MLX5_CQE_RESP_SEND_INV:
+ case MLX5_CQE_RESP_ERR:
+ return 1;
+ }
+
+ return 0;
+}
+
+static inline int free_res_cqe(struct mlx5_cqe64 *cqe64, uint32_t rsn,
+ struct mlx5_srq *srq, int cqe_version)
+{
+ if (cqe_version) {
+ if (is_equal_uidx(cqe64, rsn)) {
+ if (srq && is_responder(mlx5dv_get_cqe_opcode(cqe64)))
+ mlx5_free_srq_wqe(srq,
+ be16toh(cqe64->wqe_counter));
+ return 1;
+ }
+ } else {
+ if (is_equal_rsn(cqe64, rsn)) {
+ if (srq && (be32toh(cqe64->srqn_uidx) & 0xffffff))
+ mlx5_free_srq_wqe(srq,
+ be16toh(cqe64->wqe_counter));
+ return 1;
+ }
+ }
+
+ return 0;
+}
+
+void __mlx5_cq_clean(struct mlx5_cq *cq, uint32_t rsn, struct mlx5_srq *srq)
+{
+ uint32_t prod_index;
+ int nfreed = 0;
+ struct mlx5_cqe64 *cqe64, *dest64;
+ void *cqe, *dest;
+ uint8_t owner_bit;
+ int cqe_version;
+
+ if (!cq || cq->flags & MLX5_CQ_FLAGS_DV_OWNED)
+ return;
+
+ /*
+ * First we need to find the current producer index, so we
+ * know where to start cleaning from. It doesn't matter if HW
+ * adds new entries after this loop -- the QP we're worried
+ * about is already in RESET, so the new entries won't come
+ * from our QP and therefore don't need to be checked.
+ */
+ for (prod_index = cq->cons_index; get_sw_cqe(cq, prod_index); ++prod_index)
+ if (prod_index == cq->cons_index + cq->ibv_cq.cqe)
+ break;
+
+ /*
+ * Now sweep backwards through the CQ, removing CQ entries
+ * that match our QP by copying older entries on top of them.
+ */
+ cqe_version = (to_mctx(cq->ibv_cq.context))->cqe_version;
+ while ((int) --prod_index - (int) cq->cons_index >= 0) {
+ cqe = get_cqe(cq, prod_index & cq->ibv_cq.cqe);
+ cqe64 = (cq->cqe_sz == 64) ? cqe : cqe + 64;
+ if (free_res_cqe(cqe64, rsn, srq, cqe_version)) {
+ ++nfreed;
+ } else if (nfreed) {
+ dest = get_cqe(cq, (prod_index + nfreed) & cq->ibv_cq.cqe);
+ dest64 = (cq->cqe_sz == 64) ? dest : dest + 64;
+ owner_bit = dest64->op_own & MLX5_CQE_OWNER_MASK;
+ memcpy(dest, cqe, cq->cqe_sz);
+ dest64->op_own = owner_bit |
+ (dest64->op_own & ~MLX5_CQE_OWNER_MASK);
+ }
+ }
+
+ if (nfreed) {
+ cq->cons_index += nfreed;
+ /*
+ * Make sure update of buffer contents is done before
+ * updating consumer index.
+ */
+ udma_to_device_barrier();
+ update_cons_index(cq);
+ }
+}
+
+void mlx5_cq_clean(struct mlx5_cq *cq, uint32_t qpn, struct mlx5_srq *srq)
+{
+ mlx5_spin_lock(&cq->lock);
+ __mlx5_cq_clean(cq, qpn, srq);
+ mlx5_spin_unlock(&cq->lock);
+}
+
+static uint8_t sw_ownership_bit(int n, int nent)
+{
+ return (n & nent) ? 1 : 0;
+}
+
+static int is_hw(uint8_t own, int n, int mask)
+{
+ return (own & MLX5_CQE_OWNER_MASK) ^ !!(n & (mask + 1));
+}
+
+void mlx5_cq_resize_copy_cqes(struct mlx5_cq *cq)
+{
+ struct mlx5_cqe64 *scqe64;
+ struct mlx5_cqe64 *dcqe64;
+ void *start_cqe;
+ void *scqe;
+ void *dcqe;
+ int ssize;
+ int dsize;
+ int i;
+ uint8_t sw_own;
+
+ ssize = cq->cqe_sz;
+ dsize = cq->resize_cqe_sz;
+
+ i = cq->cons_index;
+ scqe = get_buf_cqe(cq->active_buf, i & cq->active_cqes, ssize);
+ scqe64 = ssize == 64 ? scqe : scqe + 64;
+ start_cqe = scqe;
+ if (is_hw(scqe64->op_own, i, cq->active_cqes)) {
+ fprintf(stderr, "expected cqe in sw ownership\n");
+ return;
+ }
+
+ while ((scqe64->op_own >> 4) != MLX5_CQE_RESIZE_CQ) {
+ dcqe = get_buf_cqe(cq->resize_buf, (i + 1) & (cq->resize_cqes - 1), dsize);
+ dcqe64 = dsize == 64 ? dcqe : dcqe + 64;
+ sw_own = sw_ownership_bit(i + 1, cq->resize_cqes);
+ memcpy(dcqe, scqe, ssize);
+ dcqe64->op_own = (dcqe64->op_own & ~MLX5_CQE_OWNER_MASK) | sw_own;
+
+ ++i;
+ scqe = get_buf_cqe(cq->active_buf, i & cq->active_cqes, ssize);
+ scqe64 = ssize == 64 ? scqe : scqe + 64;
+ if (is_hw(scqe64->op_own, i, cq->active_cqes)) {
+ fprintf(stderr, "expected cqe in sw ownership\n");
+ return;
+ }
+
+ if (scqe == start_cqe) {
+ fprintf(stderr, "resize CQ failed to get resize CQE\n");
+ return;
+ }
+ }
+ ++cq->cons_index;
+}
+
+int mlx5_alloc_cq_buf(struct mlx5_context *mctx, struct mlx5_cq *cq,
+ struct mlx5_buf *buf, int nent, int cqe_sz)
+{
+ struct mlx5_cqe64 *cqe;
+ int i;
+ struct mlx5_device *dev = to_mdev(mctx->ibv_ctx.device);
+ int ret;
+ enum mlx5_alloc_type type;
+ enum mlx5_alloc_type default_type = MLX5_ALLOC_TYPE_ANON;
+
+ if (mlx5_use_huge("HUGE_CQ"))
+ default_type = MLX5_ALLOC_TYPE_HUGE;
+
+ mlx5_get_alloc_type(MLX5_CQ_PREFIX, &type, default_type);
+
+ ret = mlx5_alloc_prefered_buf(mctx, buf,
+ align(nent * cqe_sz, dev->page_size),
+ dev->page_size,
+ type,
+ MLX5_CQ_PREFIX);
+
+ if (ret)
+ return -1;
+
+ memset(buf->buf, 0, nent * cqe_sz);
+
+ for (i = 0; i < nent; ++i) {
+ cqe = buf->buf + i * cqe_sz;
+ cqe += cqe_sz == 128 ? 1 : 0;
+ cqe->op_own = MLX5_CQE_INVALID << 4;
+ }
+
+ return 0;
+}
+
+int mlx5_free_cq_buf(struct mlx5_context *ctx, struct mlx5_buf *buf)
+{
+ return mlx5_free_actual_buf(ctx, buf);
+}
diff --git a/contrib/ofed/libmlx5/dbrec.c b/contrib/ofed/libmlx5/dbrec.c
new file mode 100644
index 0000000..f346939
--- /dev/null
+++ b/contrib/ofed/libmlx5/dbrec.c
@@ -0,0 +1,148 @@
+/*
+ * Copyright (c) 2012 Mellanox Technologies, Inc. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+#define _GNU_SOURCE
+#include <config.h>
+
+#include <stdlib.h>
+#include <pthread.h>
+#include <string.h>
+
+#include "mlx5.h"
+
+struct mlx5_db_page {
+ struct mlx5_db_page *prev, *next;
+ struct mlx5_buf buf;
+ int num_db;
+ int use_cnt;
+ unsigned long free[0];
+};
+
+static struct mlx5_db_page *__add_page(struct mlx5_context *context)
+{
+ struct mlx5_db_page *page;
+ int ps = to_mdev(context->ibv_ctx.device)->page_size;
+ int pp;
+ int i;
+ int nlong;
+
+ pp = ps / context->cache_line_size;
+ nlong = (pp + 8 * sizeof(long) - 1) / (8 * sizeof(long));
+
+ page = malloc(sizeof *page + nlong * sizeof(long));
+ if (!page)
+ return NULL;
+
+ if (mlx5_alloc_buf(&page->buf, ps, ps)) {
+ free(page);
+ return NULL;
+ }
+
+ page->num_db = pp;
+ page->use_cnt = 0;
+ for (i = 0; i < nlong; ++i)
+ page->free[i] = ~0;
+
+ page->prev = NULL;
+ page->next = context->db_list;
+ context->db_list = page;
+ if (page->next)
+ page->next->prev = page;
+
+ return page;
+}
+
+uint32_t *mlx5_alloc_dbrec(struct mlx5_context *context)
+{
+ struct mlx5_db_page *page;
+ uint32_t *db = NULL;
+ int i, j;
+
+ pthread_mutex_lock(&context->db_list_mutex);
+
+ for (page = context->db_list; page; page = page->next)
+ if (page->use_cnt < page->num_db)
+ goto found;
+
+ page = __add_page(context);
+ if (!page)
+ goto out;
+
+found:
+ ++page->use_cnt;
+
+ for (i = 0; !page->free[i]; ++i)
+ /* nothing */;
+
+ j = ffsl(page->free[i]);
+ --j;
+ page->free[i] &= ~(1UL << j);
+ db = page->buf.buf + (i * 8 * sizeof(long) + j) * context->cache_line_size;
+
+out:
+ pthread_mutex_unlock(&context->db_list_mutex);
+
+ return db;
+}
+
+void mlx5_free_db(struct mlx5_context *context, uint32_t *db)
+{
+ struct mlx5_db_page *page;
+ uintptr_t ps = to_mdev(context->ibv_ctx.device)->page_size;
+ int i;
+
+ pthread_mutex_lock(&context->db_list_mutex);
+
+ for (page = context->db_list; page; page = page->next)
+ if (((uintptr_t) db & ~(ps - 1)) == (uintptr_t) page->buf.buf)
+ break;
+
+ if (!page)
+ goto out;
+
+ i = ((void *) db - page->buf.buf) / context->cache_line_size;
+ page->free[i / (8 * sizeof(long))] |= 1UL << (i % (8 * sizeof(long)));
+
+ if (!--page->use_cnt) {
+ if (page->prev)
+ page->prev->next = page->next;
+ else
+ context->db_list = page->next;
+ if (page->next)
+ page->next->prev = page->prev;
+
+ mlx5_free_buf(&page->buf);
+ free(page);
+ }
+
+out:
+ pthread_mutex_unlock(&context->db_list_mutex);
+}
diff --git a/contrib/ofed/libmlx5/doorbell.h b/contrib/ofed/libmlx5/doorbell.h
new file mode 100644
index 0000000..2d5ede4
--- /dev/null
+++ b/contrib/ofed/libmlx5/doorbell.h
@@ -0,0 +1,67 @@
+/*
+ * Copyright (c) 2012 Mellanox Technologies, Inc. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+
+#ifndef DOORBELL_H
+#define DOORBELL_H
+
+#include <stdint.h>
+#include "mlx5.h"
+
+#if SIZEOF_LONG == 8
+
+#if __BYTE_ORDER == __LITTLE_ENDIAN
+# define MLX5_PAIR_TO_64(val) ((uint64_t) val[1] << 32 | val[0])
+#elif __BYTE_ORDER == __BIG_ENDIAN
+# define MLX5_PAIR_TO_64(val) ((uint64_t) val[0] << 32 | val[1])
+#else
+# error __BYTE_ORDER not defined
+#endif
+
+static inline void mlx5_write64(uint32_t val[2], void *dest, struct mlx5_spinlock *lock)
+{
+ *(volatile uint64_t *)dest = MLX5_PAIR_TO_64(val);
+}
+
+#else
+
+static inline void mlx5_write64(uint32_t val[2], void *dest, struct mlx5_spinlock *lock)
+{
+ mlx5_spin_lock(lock);
+ *(volatile uint32_t *)dest = val[0];
+ *(volatile uint32_t *)(dest + 4) = val[1];
+ mlx5_spin_unlock(lock);
+}
+
+#endif
+
+#endif /* DOORBELL_H */
diff --git a/contrib/ofed/libmlx5/libmlx5.map b/contrib/ofed/libmlx5/libmlx5.map
new file mode 100644
index 0000000..6d9fb25
--- /dev/null
+++ b/contrib/ofed/libmlx5/libmlx5.map
@@ -0,0 +1,13 @@
+/* Export symbols should be added below according to
+ Documentation/versioning.md document. */
+MLX5_1.0 {
+ global:
+ mlx5dv_query_device;
+ mlx5dv_init_obj;
+ local: *;
+};
+
+MLX5_1.1 {
+ global:
+ mlx5dv_create_cq;
+} MLX5_1.0;
diff --git a/contrib/ofed/libmlx5/mlx5-abi.h b/contrib/ofed/libmlx5/mlx5-abi.h
new file mode 100644
index 0000000..d05cb40
--- /dev/null
+++ b/contrib/ofed/libmlx5/mlx5-abi.h
@@ -0,0 +1,288 @@
+/*
+ * Copyright (c) 2012 Mellanox Technologies, Inc. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#ifndef MLX5_ABI_H
+#define MLX5_ABI_H
+
+#include <infiniband/kern-abi.h>
+#include <infiniband/verbs.h>
+#include "mlx5dv.h"
+
+#define MLX5_UVERBS_MIN_ABI_VERSION 1
+#define MLX5_UVERBS_MAX_ABI_VERSION 1
+
+enum {
+ MLX5_QP_FLAG_SIGNATURE = 1 << 0,
+ MLX5_QP_FLAG_SCATTER_CQE = 1 << 1,
+};
+
+enum {
+ MLX5_RWQ_FLAG_SIGNATURE = 1 << 0,
+};
+
+enum {
+ MLX5_NUM_NON_FP_BFREGS_PER_UAR = 2,
+ NUM_BFREGS_PER_UAR = 4,
+ MLX5_MAX_UARS = 1 << 8,
+ MLX5_MAX_BFREGS = MLX5_MAX_UARS * MLX5_NUM_NON_FP_BFREGS_PER_UAR,
+ MLX5_DEF_TOT_UUARS = 8 * MLX5_NUM_NON_FP_BFREGS_PER_UAR,
+ MLX5_MED_BFREGS_TSHOLD = 12,
+};
+
+enum mlx5_lib_caps {
+ MLX5_LIB_CAP_4K_UAR = 1 << 0,
+};
+
+struct mlx5_alloc_ucontext {
+ struct ibv_get_context ibv_req;
+ __u32 total_num_uuars;
+ __u32 num_low_latency_uuars;
+ __u32 flags;
+ __u32 comp_mask;
+ __u8 cqe_version;
+ __u8 reserved0;
+ __u16 reserved1;
+ __u32 reserved2;
+ __u64 lib_caps;
+};
+
+enum mlx5_ib_alloc_ucontext_resp_mask {
+ MLX5_IB_ALLOC_UCONTEXT_RESP_MASK_CORE_CLOCK_OFFSET = 1UL << 0,
+};
+
+struct mlx5_alloc_ucontext_resp {
+ struct ibv_get_context_resp ibv_resp;
+ __u32 qp_tab_size;
+ __u32 bf_reg_size;
+ __u32 tot_uuars;
+ __u32 cache_line_size;
+ __u16 max_sq_desc_sz;
+ __u16 max_rq_desc_sz;
+ __u32 max_send_wqebb;
+ __u32 max_recv_wr;
+ __u32 max_srq_recv_wr;
+ __u16 num_ports;
+ __u16 reserved1;
+ __u32 comp_mask;
+ __u32 response_length;
+ __u8 cqe_version;
+ __u8 cmds_supp_uhw;
+ __u16 reserved2;
+ __u64 hca_core_clock_offset;
+ __u32 log_uar_size;
+ __u32 num_uars_per_page;
+};
+
+struct mlx5_create_ah_resp {
+ struct ibv_create_ah_resp ibv_resp;
+ __u32 response_length;
+ __u8 dmac[ETHERNET_LL_SIZE];
+ __u8 reserved[6];
+};
+
+struct mlx5_alloc_pd_resp {
+ struct ibv_alloc_pd_resp ibv_resp;
+ __u32 pdn;
+};
+
+struct mlx5_create_cq {
+ struct ibv_create_cq ibv_cmd;
+ __u64 buf_addr;
+ __u64 db_addr;
+ __u32 cqe_size;
+ __u8 cqe_comp_en;
+ __u8 cqe_comp_res_format;
+ __u16 reserved;
+};
+
+struct mlx5_create_cq_resp {
+ struct ibv_create_cq_resp ibv_resp;
+ __u32 cqn;
+};
+
+struct mlx5_create_srq {
+ struct ibv_create_srq ibv_cmd;
+ __u64 buf_addr;
+ __u64 db_addr;
+ __u32 flags;
+};
+
+struct mlx5_create_srq_resp {
+ struct ibv_create_srq_resp ibv_resp;
+ __u32 srqn;
+ __u32 reserved;
+};
+
+struct mlx5_create_srq_ex {
+ struct ibv_create_xsrq ibv_cmd;
+ __u64 buf_addr;
+ __u64 db_addr;
+ __u32 flags;
+ __u32 reserved;
+ __u32 uidx;
+ __u32 reserved1;
+};
+
+struct mlx5_create_qp_drv_ex {
+ __u64 buf_addr;
+ __u64 db_addr;
+ __u32 sq_wqe_count;
+ __u32 rq_wqe_count;
+ __u32 rq_wqe_shift;
+ __u32 flags;
+ __u32 uidx;
+ __u32 reserved;
+ /* SQ buffer address - used for Raw Packet QP */
+ __u64 sq_buf_addr;
+};
+
+struct mlx5_create_qp_ex {
+ struct ibv_create_qp_ex ibv_cmd;
+ struct mlx5_create_qp_drv_ex drv_ex;
+};
+
+struct mlx5_create_qp_ex_rss {
+ struct ibv_create_qp_ex ibv_cmd;
+ __u64 rx_hash_fields_mask; /* enum ibv_rx_hash_fields */
+ __u8 rx_hash_function; /* enum ibv_rx_hash_function_flags */
+ __u8 rx_key_len;
+ __u8 reserved[6];
+ __u8 rx_hash_key[128];
+ __u32 comp_mask;
+ __u32 reserved1;
+};
+
+struct mlx5_create_qp_resp_ex {
+ struct ibv_create_qp_resp_ex ibv_resp;
+ __u32 uuar_index;
+ __u32 reserved;
+};
+
+struct mlx5_create_qp {
+ struct ibv_create_qp ibv_cmd;
+ __u64 buf_addr;
+ __u64 db_addr;
+ __u32 sq_wqe_count;
+ __u32 rq_wqe_count;
+ __u32 rq_wqe_shift;
+ __u32 flags;
+ __u32 uidx;
+ __u32 reserved;
+ /* SQ buffer address - used for Raw Packet QP */
+ __u64 sq_buf_addr;
+};
+
+struct mlx5_create_qp_resp {
+ struct ibv_create_qp_resp ibv_resp;
+ __u32 uuar_index;
+};
+
+struct mlx5_drv_create_wq {
+ __u64 buf_addr;
+ __u64 db_addr;
+ __u32 rq_wqe_count;
+ __u32 rq_wqe_shift;
+ __u32 user_index;
+ __u32 flags;
+ __u32 comp_mask;
+ __u32 reserved;
+};
+
+struct mlx5_create_wq {
+ struct ibv_create_wq ibv_cmd;
+ struct mlx5_drv_create_wq drv;
+};
+
+struct mlx5_create_wq_resp {
+ struct ibv_create_wq_resp ibv_resp;
+ __u32 response_length;
+ __u32 reserved;
+};
+
+struct mlx5_modify_wq {
+ struct ibv_modify_wq ibv_cmd;
+ __u32 comp_mask;
+ __u32 reserved;
+};
+
+struct mlx5_create_rwq_ind_table_resp {
+ struct ibv_create_rwq_ind_table_resp ibv_resp;
+};
+
+struct mlx5_destroy_rwq_ind_table {
+ struct ibv_destroy_rwq_ind_table ibv_cmd;
+};
+
+struct mlx5_resize_cq {
+ struct ibv_resize_cq ibv_cmd;
+ __u64 buf_addr;
+ __u16 cqe_size;
+ __u16 reserved0;
+ __u32 reserved1;
+};
+
+struct mlx5_resize_cq_resp {
+ struct ibv_resize_cq_resp ibv_resp;
+};
+
+struct mlx5_query_device_ex {
+ struct ibv_query_device_ex ibv_cmd;
+};
+
+struct mlx5_reserved_tso_caps {
+ __u64 reserved;
+};
+
+struct mlx5_rss_caps {
+ __u64 rx_hash_fields_mask; /* enum ibv_rx_hash_fields */
+ __u8 rx_hash_function; /* enum ibv_rx_hash_function_flags */
+ __u8 reserved[7];
+};
+
+struct mlx5_packet_pacing_caps {
+ struct ibv_packet_pacing_caps caps;
+ __u32 reserved;
+};
+
+struct mlx5_query_device_ex_resp {
+ struct ibv_query_device_resp_ex ibv_resp;
+ __u32 comp_mask;
+ __u32 response_length;
+ struct ibv_tso_caps tso_caps;
+ struct mlx5_rss_caps rss_caps; /* vendor data channel */
+ struct mlx5dv_cqe_comp_caps cqe_comp_caps;
+ struct mlx5_packet_pacing_caps packet_pacing_caps;
+ __u32 support_multi_pkt_send_wqe;
+ __u32 reserved;
+};
+
+#endif /* MLX5_ABI_H */
diff --git a/contrib/ofed/libmlx5/mlx5.c b/contrib/ofed/libmlx5/mlx5.c
new file mode 100644
index 0000000..491979b
--- /dev/null
+++ b/contrib/ofed/libmlx5/mlx5.c
@@ -0,0 +1,1027 @@
+/*
+ * Copyright (c) 2012 Mellanox Technologies, Inc. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+#define _GNU_SOURCE
+#include <config.h>
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <errno.h>
+#include <sys/mman.h>
+#include <pthread.h>
+#include <string.h>
+#include <sched.h>
+#include <sys/param.h>
+#include <sys/cpuset.h>
+
+#include "mlx5.h"
+#include "mlx5-abi.h"
+
+#ifndef PCI_VENDOR_ID_MELLANOX
+#define PCI_VENDOR_ID_MELLANOX 0x15b3
+#endif
+
+#ifndef CPU_OR
+#define CPU_OR(x, y, z) do {} while (0)
+#endif
+
+#ifndef CPU_EQUAL
+#define CPU_EQUAL(x, y) 1
+#endif
+
+
+#define HCA(v, d) \
+ { .vendor = PCI_VENDOR_ID_##v, \
+ .device = d }
+
+static struct {
+ unsigned vendor;
+ unsigned device;
+} hca_table[] = {
+ HCA(MELLANOX, 4113), /* MT4113 Connect-IB */
+ HCA(MELLANOX, 4114), /* Connect-IB Virtual Function */
+ HCA(MELLANOX, 4115), /* ConnectX-4 */
+ HCA(MELLANOX, 4116), /* ConnectX-4 Virtual Function */
+ HCA(MELLANOX, 4117), /* ConnectX-4LX */
+ HCA(MELLANOX, 4118), /* ConnectX-4LX Virtual Function */
+ HCA(MELLANOX, 4119), /* ConnectX-5, PCIe 3.0 */
+ HCA(MELLANOX, 4120), /* ConnectX-5 Virtual Function */
+ HCA(MELLANOX, 4121), /* ConnectX-5 Ex */
+ HCA(MELLANOX, 4122), /* ConnectX-5 Ex VF */
+ HCA(MELLANOX, 4123), /* ConnectX-6 */
+ HCA(MELLANOX, 4124), /* ConnectX-6 VF */
+ HCA(MELLANOX, 41682), /* BlueField integrated ConnectX-5 network controller */
+ HCA(MELLANOX, 41683), /* BlueField integrated ConnectX-5 network controller VF */
+};
+
+uint32_t mlx5_debug_mask = 0;
+int mlx5_freeze_on_error_cqe;
+
+static struct ibv_context_ops mlx5_ctx_ops = {
+ .query_device = mlx5_query_device,
+ .query_port = mlx5_query_port,
+ .alloc_pd = mlx5_alloc_pd,
+ .dealloc_pd = mlx5_free_pd,
+ .reg_mr = mlx5_reg_mr,
+ .rereg_mr = mlx5_rereg_mr,
+ .dereg_mr = mlx5_dereg_mr,
+ .alloc_mw = mlx5_alloc_mw,
+ .dealloc_mw = mlx5_dealloc_mw,
+ .bind_mw = mlx5_bind_mw,
+ .create_cq = mlx5_create_cq,
+ .poll_cq = mlx5_poll_cq,
+ .req_notify_cq = mlx5_arm_cq,
+ .cq_event = mlx5_cq_event,
+ .resize_cq = mlx5_resize_cq,
+ .destroy_cq = mlx5_destroy_cq,
+ .create_srq = mlx5_create_srq,
+ .modify_srq = mlx5_modify_srq,
+ .query_srq = mlx5_query_srq,
+ .destroy_srq = mlx5_destroy_srq,
+ .post_srq_recv = mlx5_post_srq_recv,
+ .create_qp = mlx5_create_qp,
+ .query_qp = mlx5_query_qp,
+ .modify_qp = mlx5_modify_qp,
+ .destroy_qp = mlx5_destroy_qp,
+ .post_send = mlx5_post_send,
+ .post_recv = mlx5_post_recv,
+ .create_ah = mlx5_create_ah,
+ .destroy_ah = mlx5_destroy_ah,
+ .attach_mcast = mlx5_attach_mcast,
+ .detach_mcast = mlx5_detach_mcast
+};
+
+static int read_number_from_line(const char *line, int *value)
+{
+ const char *ptr;
+
+ ptr = strchr(line, ':');
+ if (!ptr)
+ return 1;
+
+ ++ptr;
+
+ *value = atoi(ptr);
+ return 0;
+}
+/**
+ * The function looks for the first free user-index in all the
+ * user-index tables. If all are used, returns -1, otherwise
+ * a valid user-index.
+ * In case the reference count of the table is zero, it means the
+ * table is not in use and wasn't allocated yet, therefore the
+ * mlx5_store_uidx allocates the table, and increment the reference
+ * count on the table.
+ */
+static int32_t get_free_uidx(struct mlx5_context *ctx)
+{
+ int32_t tind;
+ int32_t i;
+
+ for (tind = 0; tind < MLX5_UIDX_TABLE_SIZE; tind++) {
+ if (ctx->uidx_table[tind].refcnt < MLX5_UIDX_TABLE_MASK)
+ break;
+ }
+
+ if (tind == MLX5_UIDX_TABLE_SIZE)
+ return -1;
+
+ if (!ctx->uidx_table[tind].refcnt)
+ return tind << MLX5_UIDX_TABLE_SHIFT;
+
+ for (i = 0; i < MLX5_UIDX_TABLE_MASK + 1; i++) {
+ if (!ctx->uidx_table[tind].table[i])
+ break;
+ }
+
+ return (tind << MLX5_UIDX_TABLE_SHIFT) | i;
+}
+
+int32_t mlx5_store_uidx(struct mlx5_context *ctx, void *rsc)
+{
+ int32_t tind;
+ int32_t ret = -1;
+ int32_t uidx;
+
+ pthread_mutex_lock(&ctx->uidx_table_mutex);
+ uidx = get_free_uidx(ctx);
+ if (uidx < 0)
+ goto out;
+
+ tind = uidx >> MLX5_UIDX_TABLE_SHIFT;
+
+ if (!ctx->uidx_table[tind].refcnt) {
+ ctx->uidx_table[tind].table = calloc(MLX5_UIDX_TABLE_MASK + 1,
+ sizeof(struct mlx5_resource *));
+ if (!ctx->uidx_table[tind].table)
+ goto out;
+ }
+
+ ++ctx->uidx_table[tind].refcnt;
+ ctx->uidx_table[tind].table[uidx & MLX5_UIDX_TABLE_MASK] = rsc;
+ ret = uidx;
+
+out:
+ pthread_mutex_unlock(&ctx->uidx_table_mutex);
+ return ret;
+}
+
+void mlx5_clear_uidx(struct mlx5_context *ctx, uint32_t uidx)
+{
+ int tind = uidx >> MLX5_UIDX_TABLE_SHIFT;
+
+ pthread_mutex_lock(&ctx->uidx_table_mutex);
+
+ if (!--ctx->uidx_table[tind].refcnt)
+ free(ctx->uidx_table[tind].table);
+ else
+ ctx->uidx_table[tind].table[uidx & MLX5_UIDX_TABLE_MASK] = NULL;
+
+ pthread_mutex_unlock(&ctx->uidx_table_mutex);
+}
+
+static int mlx5_is_sandy_bridge(int *num_cores)
+{
+ char line[128];
+ FILE *fd;
+ int rc = 0;
+ int cur_cpu_family = -1;
+ int cur_cpu_model = -1;
+
+ fd = fopen("/proc/cpuinfo", "r");
+ if (!fd)
+ return 0;
+
+ *num_cores = 0;
+
+ while (fgets(line, 128, fd)) {
+ int value;
+
+ /* if this is information on new processor */
+ if (!strncmp(line, "processor", 9)) {
+ ++*num_cores;
+
+ cur_cpu_family = -1;
+ cur_cpu_model = -1;
+ } else if (!strncmp(line, "cpu family", 10)) {
+ if ((cur_cpu_family < 0) && (!read_number_from_line(line, &value)))
+ cur_cpu_family = value;
+ } else if (!strncmp(line, "model", 5)) {
+ if ((cur_cpu_model < 0) && (!read_number_from_line(line, &value)))
+ cur_cpu_model = value;
+ }
+
+ /* if this is a Sandy Bridge CPU */
+ if ((cur_cpu_family == 6) &&
+ (cur_cpu_model == 0x2A || (cur_cpu_model == 0x2D) ))
+ rc = 1;
+ }
+
+ fclose(fd);
+ return rc;
+}
+
+/*
+man cpuset
+
+ This format displays each 32-bit word in hexadecimal (using ASCII characters "0" - "9" and "a" - "f"); words
+ are filled with leading zeros, if required. For masks longer than one word, a comma separator is used between
+ words. Words are displayed in big-endian order, which has the most significant bit first. The hex digits
+ within a word are also in big-endian order.
+
+ The number of 32-bit words displayed is the minimum number needed to display all bits of the bitmask, based on
+ the size of the bitmask.
+
+ Examples of the Mask Format:
+
+ 00000001 # just bit 0 set
+ 40000000,00000000,00000000 # just bit 94 set
+ 000000ff,00000000 # bits 32-39 set
+ 00000000,000E3862 # 1,5,6,11-13,17-19 set
+
+ A mask with bits 0, 1, 2, 4, 8, 16, 32, and 64 set displays as:
+
+ 00000001,00000001,00010117
+
+ The first "1" is for bit 64, the second for bit 32, the third for bit 16, the fourth for bit 8, the fifth for
+ bit 4, and the "7" is for bits 2, 1, and 0.
+*/
+static void mlx5_local_cpu_set(struct ibv_device *ibdev, cpuset_t *cpu_set)
+{
+ char *p, buf[1024];
+ char *env_value;
+ uint32_t word;
+ int i, k;
+
+ env_value = getenv("MLX5_LOCAL_CPUS");
+ if (env_value)
+ strncpy(buf, env_value, sizeof(buf));
+ else {
+ char fname[MAXPATHLEN];
+
+ snprintf(fname, MAXPATHLEN, "/sys/class/infiniband/%s",
+ ibv_get_device_name(ibdev));
+
+ if (ibv_read_sysfs_file(fname, "device/local_cpus", buf, sizeof(buf))) {
+ fprintf(stderr, PFX "Warning: can not get local cpu set: failed to open %s\n", fname);
+ return;
+ }
+ }
+
+ p = strrchr(buf, ',');
+ if (!p)
+ p = buf;
+
+ i = 0;
+ do {
+ if (*p == ',') {
+ *p = 0;
+ p ++;
+ }
+
+ word = strtoul(p, NULL, 16);
+
+ for (k = 0; word; ++k, word >>= 1)
+ if (word & 1)
+ CPU_SET(k+i, cpu_set);
+
+ if (p == buf)
+ break;
+
+ p = strrchr(buf, ',');
+ if (!p)
+ p = buf;
+
+ i += 32;
+ } while (i < CPU_SETSIZE);
+}
+
+static int mlx5_enable_sandy_bridge_fix(struct ibv_device *ibdev)
+{
+ cpuset_t my_cpus, dev_local_cpus, result_set;
+ int stall_enable;
+ int ret;
+ int num_cores;
+
+ if (!mlx5_is_sandy_bridge(&num_cores))
+ return 0;
+
+ /* by default enable stall on sandy bridge arch */
+ stall_enable = 1;
+
+ /*
+ * check if app is bound to cpu set that is inside
+ * of device local cpu set. Disable stalling if true
+ */
+
+ /* use static cpu set - up to CPU_SETSIZE (1024) cpus/node */
+ CPU_ZERO(&my_cpus);
+ CPU_ZERO(&dev_local_cpus);
+ CPU_ZERO(&result_set);
+ ret = cpuset_getaffinity(CPU_LEVEL_WHICH, CPU_WHICH_PID, -1,
+ sizeof(my_cpus), &my_cpus);
+ if (ret == -1) {
+ if (errno == EINVAL)
+ fprintf(stderr, PFX "Warning: my cpu set is too small\n");
+ else
+ fprintf(stderr, PFX "Warning: failed to get my cpu set\n");
+ goto out;
+ }
+
+ /* get device local cpu set */
+ mlx5_local_cpu_set(ibdev, &dev_local_cpus);
+
+ /* check if my cpu set is in dev cpu */
+ CPU_OR(&result_set, &my_cpus);
+ CPU_OR(&result_set, &dev_local_cpus);
+ stall_enable = CPU_EQUAL(&result_set, &dev_local_cpus) ? 0 : 1;
+
+out:
+ return stall_enable;
+}
+
+static void mlx5_read_env(struct ibv_device *ibdev, struct mlx5_context *ctx)
+{
+ char *env_value;
+
+ env_value = getenv("MLX5_STALL_CQ_POLL");
+ if (env_value)
+ /* check if cq stall is enforced by user */
+ ctx->stall_enable = (strcmp(env_value, "0")) ? 1 : 0;
+ else
+ /* autodetect if we need to do cq polling */
+ ctx->stall_enable = mlx5_enable_sandy_bridge_fix(ibdev);
+
+ env_value = getenv("MLX5_STALL_NUM_LOOP");
+ if (env_value)
+ mlx5_stall_num_loop = atoi(env_value);
+
+ env_value = getenv("MLX5_STALL_CQ_POLL_MIN");
+ if (env_value)
+ mlx5_stall_cq_poll_min = atoi(env_value);
+
+ env_value = getenv("MLX5_STALL_CQ_POLL_MAX");
+ if (env_value)
+ mlx5_stall_cq_poll_max = atoi(env_value);
+
+ env_value = getenv("MLX5_STALL_CQ_INC_STEP");
+ if (env_value)
+ mlx5_stall_cq_inc_step = atoi(env_value);
+
+ env_value = getenv("MLX5_STALL_CQ_DEC_STEP");
+ if (env_value)
+ mlx5_stall_cq_dec_step = atoi(env_value);
+
+ ctx->stall_adaptive_enable = 0;
+ ctx->stall_cycles = 0;
+
+ if (mlx5_stall_num_loop < 0) {
+ ctx->stall_adaptive_enable = 1;
+ ctx->stall_cycles = mlx5_stall_cq_poll_min;
+ }
+
+}
+
+static int get_total_uuars(int page_size)
+{
+ int size = MLX5_DEF_TOT_UUARS;
+ int uuars_in_page;
+ char *env;
+
+ env = getenv("MLX5_TOTAL_UUARS");
+ if (env)
+ size = atoi(env);
+
+ if (size < 1)
+ return -EINVAL;
+
+ uuars_in_page = page_size / MLX5_ADAPTER_PAGE_SIZE * MLX5_NUM_NON_FP_BFREGS_PER_UAR;
+ size = max(uuars_in_page, size);
+ size = align(size, MLX5_NUM_NON_FP_BFREGS_PER_UAR);
+ if (size > MLX5_MAX_BFREGS)
+ return -ENOMEM;
+
+ return size;
+}
+
+static void open_debug_file(struct mlx5_context *ctx)
+{
+ char *env;
+
+ env = getenv("MLX5_DEBUG_FILE");
+ if (!env) {
+ ctx->dbg_fp = stderr;
+ return;
+ }
+
+ ctx->dbg_fp = fopen(env, "aw+");
+ if (!ctx->dbg_fp) {
+ fprintf(stderr, "Failed opening debug file %s, using stderr\n", env);
+ ctx->dbg_fp = stderr;
+ return;
+ }
+}
+
+static void close_debug_file(struct mlx5_context *ctx)
+{
+ if (ctx->dbg_fp && ctx->dbg_fp != stderr)
+ fclose(ctx->dbg_fp);
+}
+
+static void set_debug_mask(void)
+{
+ char *env;
+
+ env = getenv("MLX5_DEBUG_MASK");
+ if (env)
+ mlx5_debug_mask = strtol(env, NULL, 0);
+}
+
+static void set_freeze_on_error(void)
+{
+ char *env;
+
+ env = getenv("MLX5_FREEZE_ON_ERROR_CQE");
+ if (env)
+ mlx5_freeze_on_error_cqe = strtol(env, NULL, 0);
+}
+
+static int get_always_bf(void)
+{
+ char *env;
+
+ env = getenv("MLX5_POST_SEND_PREFER_BF");
+ if (!env)
+ return 1;
+
+ return strcmp(env, "0") ? 1 : 0;
+}
+
+static int get_shut_up_bf(void)
+{
+ char *env;
+
+ env = getenv("MLX5_SHUT_UP_BF");
+ if (!env)
+ return 0;
+
+ return strcmp(env, "0") ? 1 : 0;
+}
+
+static int get_num_low_lat_uuars(int tot_uuars)
+{
+ char *env;
+ int num = 4;
+
+ env = getenv("MLX5_NUM_LOW_LAT_UUARS");
+ if (env)
+ num = atoi(env);
+
+ if (num < 0)
+ return -EINVAL;
+
+ num = max(num, tot_uuars - MLX5_MED_BFREGS_TSHOLD);
+ return num;
+}
+
+/* The library allocates an array of uuar contexts. The one in index zero does
+ * not to execersize odd/even policy so it can avoid a lock but it may not use
+ * blue flame. The upper ones, low_lat_uuars can use blue flame with no lock
+ * since they are assigned to one QP only. The rest can use blue flame but since
+ * they are shared they need a lock
+ */
+static int need_uuar_lock(struct mlx5_context *ctx, int uuarn)
+{
+ if (uuarn == 0 || mlx5_single_threaded)
+ return 0;
+
+ if (uuarn >= (ctx->tot_uuars - ctx->low_lat_uuars) * 2)
+ return 0;
+
+ return 1;
+}
+
+static int single_threaded_app(void)
+{
+
+ char *env;
+
+ env = getenv("MLX5_SINGLE_THREADED");
+ if (env)
+ return strcmp(env, "1") ? 0 : 1;
+
+ return 0;
+}
+
+static int mlx5_cmd_get_context(struct mlx5_context *context,
+ struct mlx5_alloc_ucontext *req,
+ size_t req_len,
+ struct mlx5_alloc_ucontext_resp *resp,
+ size_t resp_len)
+{
+ if (!ibv_cmd_get_context(&context->ibv_ctx, &req->ibv_req,
+ req_len, &resp->ibv_resp, resp_len))
+ return 0;
+
+ /* The ibv_cmd_get_context fails in older kernels when passing
+ * a request length that the kernel doesn't know.
+ * To avoid breaking compatibility of new libmlx5 and older
+ * kernels, when ibv_cmd_get_context fails with the full
+ * request length, we try once again with the legacy length.
+ * We repeat this process while reducing requested size based
+ * on the feature input size. To avoid this in the future, we
+ * will remove the check in kernel that requires fields unknown
+ * to the kernel to be cleared. This will require that any new
+ * feature that involves extending struct mlx5_alloc_ucontext
+ * will be accompanied by an indication in the form of one or
+ * more fields in struct mlx5_alloc_ucontext_resp. If the
+ * response value can be interpreted as feature not supported
+ * when the returned value is zero, this will suffice to
+ * indicate to the library that the request was ignored by the
+ * kernel, either because it is unaware or because it decided
+ * to do so. If zero is a valid response, we will add a new
+ * field that indicates whether the request was handled.
+ */
+ if (!ibv_cmd_get_context(&context->ibv_ctx, &req->ibv_req,
+ offsetof(struct mlx5_alloc_ucontext, lib_caps),
+ &resp->ibv_resp, resp_len))
+ return 0;
+
+ return ibv_cmd_get_context(&context->ibv_ctx, &req->ibv_req,
+ offsetof(struct mlx5_alloc_ucontext,
+ cqe_version),
+ &resp->ibv_resp, resp_len);
+}
+
+static int mlx5_map_internal_clock(struct mlx5_device *mdev,
+ struct ibv_context *ibv_ctx)
+{
+ struct mlx5_context *context = to_mctx(ibv_ctx);
+ void *hca_clock_page;
+ off_t offset = 0;
+
+ set_command(MLX5_MMAP_GET_CORE_CLOCK_CMD, &offset);
+ hca_clock_page = mmap(NULL, mdev->page_size,
+ PROT_READ, MAP_SHARED, ibv_ctx->cmd_fd,
+ mdev->page_size * offset);
+
+ if (hca_clock_page == MAP_FAILED) {
+ fprintf(stderr, PFX
+ "Warning: Timestamp available,\n"
+ "but failed to mmap() hca core clock page.\n");
+ return -1;
+ }
+
+ context->hca_core_clock = hca_clock_page +
+ (context->core_clock.offset & (mdev->page_size - 1));
+ return 0;
+}
+
+int mlx5dv_query_device(struct ibv_context *ctx_in,
+ struct mlx5dv_context *attrs_out)
+{
+ struct mlx5_context *mctx = to_mctx(ctx_in);
+ uint64_t comp_mask_out = 0;
+
+ attrs_out->version = 0;
+ attrs_out->flags = 0;
+
+ if (mctx->cqe_version == MLX5_CQE_VERSION_V1)
+ attrs_out->flags |= MLX5DV_CONTEXT_FLAGS_CQE_V1;
+
+ if (mctx->vendor_cap_flags & MLX5_VENDOR_CAP_FLAGS_MPW)
+ attrs_out->flags |= MLX5DV_CONTEXT_FLAGS_MPW;
+
+ if (attrs_out->comp_mask & MLX5DV_CONTEXT_MASK_CQE_COMPRESION) {
+ attrs_out->cqe_comp_caps = mctx->cqe_comp_caps;
+ comp_mask_out |= MLX5DV_CONTEXT_MASK_CQE_COMPRESION;
+ }
+
+ attrs_out->comp_mask = comp_mask_out;
+
+ return 0;
+}
+
+static int mlx5dv_get_qp(struct ibv_qp *qp_in,
+ struct mlx5dv_qp *qp_out)
+{
+ struct mlx5_qp *mqp = to_mqp(qp_in);
+
+ qp_out->comp_mask = 0;
+ qp_out->dbrec = mqp->db;
+
+ if (mqp->sq_buf_size)
+ /* IBV_QPT_RAW_PACKET */
+ qp_out->sq.buf = (void *)((uintptr_t)mqp->sq_buf.buf);
+ else
+ qp_out->sq.buf = (void *)((uintptr_t)mqp->buf.buf + mqp->sq.offset);
+ qp_out->sq.wqe_cnt = mqp->sq.wqe_cnt;
+ qp_out->sq.stride = 1 << mqp->sq.wqe_shift;
+
+ qp_out->rq.buf = (void *)((uintptr_t)mqp->buf.buf + mqp->rq.offset);
+ qp_out->rq.wqe_cnt = mqp->rq.wqe_cnt;
+ qp_out->rq.stride = 1 << mqp->rq.wqe_shift;
+
+ qp_out->bf.reg = mqp->bf->reg;
+
+ if (mqp->bf->uuarn > 0)
+ qp_out->bf.size = mqp->bf->buf_size;
+ else
+ qp_out->bf.size = 0;
+
+ return 0;
+}
+
+static int mlx5dv_get_cq(struct ibv_cq *cq_in,
+ struct mlx5dv_cq *cq_out)
+{
+ struct mlx5_cq *mcq = to_mcq(cq_in);
+ struct mlx5_context *mctx = to_mctx(cq_in->context);
+
+ cq_out->comp_mask = 0;
+ cq_out->cqn = mcq->cqn;
+ cq_out->cqe_cnt = mcq->ibv_cq.cqe + 1;
+ cq_out->cqe_size = mcq->cqe_sz;
+ cq_out->buf = mcq->active_buf->buf;
+ cq_out->dbrec = mcq->dbrec;
+ cq_out->uar = mctx->uar;
+
+ mcq->flags |= MLX5_CQ_FLAGS_DV_OWNED;
+
+ return 0;
+}
+
+static int mlx5dv_get_rwq(struct ibv_wq *wq_in,
+ struct mlx5dv_rwq *rwq_out)
+{
+ struct mlx5_rwq *mrwq = to_mrwq(wq_in);
+
+ rwq_out->comp_mask = 0;
+ rwq_out->buf = mrwq->pbuff;
+ rwq_out->dbrec = mrwq->recv_db;
+ rwq_out->wqe_cnt = mrwq->rq.wqe_cnt;
+ rwq_out->stride = 1 << mrwq->rq.wqe_shift;
+
+ return 0;
+}
+
+static int mlx5dv_get_srq(struct ibv_srq *srq_in,
+ struct mlx5dv_srq *srq_out)
+{
+ struct mlx5_srq *msrq;
+
+ msrq = container_of(srq_in, struct mlx5_srq, vsrq.srq);
+
+ srq_out->comp_mask = 0;
+ srq_out->buf = msrq->buf.buf;
+ srq_out->dbrec = msrq->db;
+ srq_out->stride = 1 << msrq->wqe_shift;
+ srq_out->head = msrq->head;
+ srq_out->tail = msrq->tail;
+
+ return 0;
+}
+
+int mlx5dv_init_obj(struct mlx5dv_obj *obj, uint64_t obj_type)
+{
+ int ret = 0;
+
+ if (obj_type & MLX5DV_OBJ_QP)
+ ret = mlx5dv_get_qp(obj->qp.in, obj->qp.out);
+ if (!ret && (obj_type & MLX5DV_OBJ_CQ))
+ ret = mlx5dv_get_cq(obj->cq.in, obj->cq.out);
+ if (!ret && (obj_type & MLX5DV_OBJ_SRQ))
+ ret = mlx5dv_get_srq(obj->srq.in, obj->srq.out);
+ if (!ret && (obj_type & MLX5DV_OBJ_RWQ))
+ ret = mlx5dv_get_rwq(obj->rwq.in, obj->rwq.out);
+
+ return ret;
+}
+
+static void adjust_uar_info(struct mlx5_device *mdev,
+ struct mlx5_context *context,
+ struct mlx5_alloc_ucontext_resp resp)
+{
+ if (!resp.log_uar_size && !resp.num_uars_per_page) {
+ /* old kernel */
+ context->uar_size = mdev->page_size;
+ context->num_uars_per_page = 1;
+ return;
+ }
+
+ context->uar_size = 1 << resp.log_uar_size;
+ context->num_uars_per_page = resp.num_uars_per_page;
+}
+
+static int mlx5_init_context(struct verbs_device *vdev,
+ struct ibv_context *ctx, int cmd_fd)
+{
+ struct mlx5_context *context;
+ struct mlx5_alloc_ucontext req;
+ struct mlx5_alloc_ucontext_resp resp;
+ int i;
+ int page_size;
+ int tot_uuars;
+ int low_lat_uuars;
+ int gross_uuars;
+ int j;
+ off_t offset;
+ struct mlx5_device *mdev;
+ struct verbs_context *v_ctx;
+ struct ibv_port_attr port_attr;
+ struct ibv_device_attr_ex device_attr;
+ int k;
+ int bfi;
+ int num_sys_page_map;
+
+ mdev = to_mdev(&vdev->device);
+ v_ctx = verbs_get_ctx(ctx);
+ page_size = mdev->page_size;
+ mlx5_single_threaded = single_threaded_app();
+
+ context = to_mctx(ctx);
+ context->ibv_ctx.cmd_fd = cmd_fd;
+
+ open_debug_file(context);
+ set_debug_mask();
+ set_freeze_on_error();
+ if (gethostname(context->hostname, sizeof(context->hostname)))
+ strcpy(context->hostname, "host_unknown");
+
+ tot_uuars = get_total_uuars(page_size);
+ if (tot_uuars < 0) {
+ errno = -tot_uuars;
+ goto err_free;
+ }
+
+ low_lat_uuars = get_num_low_lat_uuars(tot_uuars);
+ if (low_lat_uuars < 0) {
+ errno = -low_lat_uuars;
+ goto err_free;
+ }
+
+ if (low_lat_uuars > tot_uuars - 1) {
+ errno = ENOMEM;
+ goto err_free;
+ }
+
+ memset(&req, 0, sizeof(req));
+ memset(&resp, 0, sizeof(resp));
+
+ req.total_num_uuars = tot_uuars;
+ req.num_low_latency_uuars = low_lat_uuars;
+ req.cqe_version = MLX5_CQE_VERSION_V1;
+ req.lib_caps |= MLX5_LIB_CAP_4K_UAR;
+
+ if (mlx5_cmd_get_context(context, &req, sizeof(req), &resp,
+ sizeof(resp)))
+ goto err_free;
+
+ context->max_num_qps = resp.qp_tab_size;
+ context->bf_reg_size = resp.bf_reg_size;
+ context->tot_uuars = resp.tot_uuars;
+ context->low_lat_uuars = low_lat_uuars;
+ context->cache_line_size = resp.cache_line_size;
+ context->max_sq_desc_sz = resp.max_sq_desc_sz;
+ context->max_rq_desc_sz = resp.max_rq_desc_sz;
+ context->max_send_wqebb = resp.max_send_wqebb;
+ context->num_ports = resp.num_ports;
+ context->max_recv_wr = resp.max_recv_wr;
+ context->max_srq_recv_wr = resp.max_srq_recv_wr;
+
+ context->cqe_version = resp.cqe_version;
+ if (context->cqe_version) {
+ if (context->cqe_version == MLX5_CQE_VERSION_V1)
+ mlx5_ctx_ops.poll_cq = mlx5_poll_cq_v1;
+ else
+ goto err_free;
+ }
+
+ adjust_uar_info(mdev, context, resp);
+
+ gross_uuars = context->tot_uuars / MLX5_NUM_NON_FP_BFREGS_PER_UAR * NUM_BFREGS_PER_UAR;
+ context->bfs = calloc(gross_uuars, sizeof(*context->bfs));
+ if (!context->bfs) {
+ errno = ENOMEM;
+ goto err_free;
+ }
+
+ context->cmds_supp_uhw = resp.cmds_supp_uhw;
+ context->vendor_cap_flags = 0;
+
+ pthread_mutex_init(&context->qp_table_mutex, NULL);
+ pthread_mutex_init(&context->srq_table_mutex, NULL);
+ pthread_mutex_init(&context->uidx_table_mutex, NULL);
+ for (i = 0; i < MLX5_QP_TABLE_SIZE; ++i)
+ context->qp_table[i].refcnt = 0;
+
+ for (i = 0; i < MLX5_QP_TABLE_SIZE; ++i)
+ context->uidx_table[i].refcnt = 0;
+
+ context->db_list = NULL;
+
+ pthread_mutex_init(&context->db_list_mutex, NULL);
+
+ num_sys_page_map = context->tot_uuars / (context->num_uars_per_page * MLX5_NUM_NON_FP_BFREGS_PER_UAR);
+ for (i = 0; i < num_sys_page_map; ++i) {
+ offset = 0;
+ set_command(MLX5_MMAP_GET_REGULAR_PAGES_CMD, &offset);
+ set_index(i, &offset);
+ context->uar[i] = mmap(NULL, page_size, PROT_WRITE, MAP_SHARED,
+ cmd_fd, page_size * offset);
+ if (context->uar[i] == MAP_FAILED) {
+ context->uar[i] = NULL;
+ goto err_free_bf;
+ }
+ }
+
+ for (i = 0; i < num_sys_page_map; i++) {
+ for (j = 0; j < context->num_uars_per_page; j++) {
+ for (k = 0; k < NUM_BFREGS_PER_UAR; k++) {
+ bfi = (i * context->num_uars_per_page + j) * NUM_BFREGS_PER_UAR + k;
+ context->bfs[bfi].reg = context->uar[i] + MLX5_ADAPTER_PAGE_SIZE * j +
+ MLX5_BF_OFFSET + k * context->bf_reg_size;
+ context->bfs[bfi].need_lock = need_uuar_lock(context, bfi);
+ mlx5_spinlock_init(&context->bfs[bfi].lock);
+ context->bfs[bfi].offset = 0;
+ if (bfi)
+ context->bfs[bfi].buf_size = context->bf_reg_size / 2;
+ context->bfs[bfi].uuarn = bfi;
+ }
+ }
+ }
+ context->hca_core_clock = NULL;
+ if (resp.response_length + sizeof(resp.ibv_resp) >=
+ offsetof(struct mlx5_alloc_ucontext_resp, hca_core_clock_offset) +
+ sizeof(resp.hca_core_clock_offset) &&
+ resp.comp_mask & MLX5_IB_ALLOC_UCONTEXT_RESP_MASK_CORE_CLOCK_OFFSET) {
+ context->core_clock.offset = resp.hca_core_clock_offset;
+ mlx5_map_internal_clock(mdev, ctx);
+ }
+
+ mlx5_spinlock_init(&context->lock32);
+
+ context->prefer_bf = get_always_bf();
+ context->shut_up_bf = get_shut_up_bf();
+ mlx5_read_env(&vdev->device, context);
+
+ mlx5_spinlock_init(&context->hugetlb_lock);
+ TAILQ_INIT(&context->hugetlb_list);
+
+ context->ibv_ctx.ops = mlx5_ctx_ops;
+
+ verbs_set_ctx_op(v_ctx, create_qp_ex, mlx5_create_qp_ex);
+ verbs_set_ctx_op(v_ctx, open_xrcd, mlx5_open_xrcd);
+ verbs_set_ctx_op(v_ctx, close_xrcd, mlx5_close_xrcd);
+ verbs_set_ctx_op(v_ctx, create_srq_ex, mlx5_create_srq_ex);
+ verbs_set_ctx_op(v_ctx, get_srq_num, mlx5_get_srq_num);
+ verbs_set_ctx_op(v_ctx, query_device_ex, mlx5_query_device_ex);
+ verbs_set_ctx_op(v_ctx, query_rt_values, mlx5_query_rt_values);
+ verbs_set_ctx_op(v_ctx, ibv_create_flow, ibv_cmd_create_flow);
+ verbs_set_ctx_op(v_ctx, ibv_destroy_flow, ibv_cmd_destroy_flow);
+ verbs_set_ctx_op(v_ctx, create_cq_ex, mlx5_create_cq_ex);
+ verbs_set_ctx_op(v_ctx, create_wq, mlx5_create_wq);
+ verbs_set_ctx_op(v_ctx, modify_wq, mlx5_modify_wq);
+ verbs_set_ctx_op(v_ctx, destroy_wq, mlx5_destroy_wq);
+ verbs_set_ctx_op(v_ctx, create_rwq_ind_table, mlx5_create_rwq_ind_table);
+ verbs_set_ctx_op(v_ctx, destroy_rwq_ind_table, mlx5_destroy_rwq_ind_table);
+
+ memset(&device_attr, 0, sizeof(device_attr));
+ if (!mlx5_query_device_ex(ctx, NULL, &device_attr,
+ sizeof(struct ibv_device_attr_ex))) {
+ context->cached_device_cap_flags =
+ device_attr.orig_attr.device_cap_flags;
+ context->atomic_cap = device_attr.orig_attr.atomic_cap;
+ context->cached_tso_caps = device_attr.tso_caps;
+ }
+
+ for (j = 0; j < min(MLX5_MAX_PORTS_NUM, context->num_ports); ++j) {
+ memset(&port_attr, 0, sizeof(port_attr));
+ if (!mlx5_query_port(ctx, j + 1, &port_attr))
+ context->cached_link_layer[j] = port_attr.link_layer;
+ }
+
+ return 0;
+
+err_free_bf:
+ free(context->bfs);
+
+err_free:
+ for (i = 0; i < MLX5_MAX_UARS; ++i) {
+ if (context->uar[i])
+ munmap(context->uar[i], page_size);
+ }
+ close_debug_file(context);
+ return errno;
+}
+
+static void mlx5_cleanup_context(struct verbs_device *device,
+ struct ibv_context *ibctx)
+{
+ struct mlx5_context *context = to_mctx(ibctx);
+ int page_size = to_mdev(ibctx->device)->page_size;
+ int i;
+
+ free(context->bfs);
+ for (i = 0; i < MLX5_MAX_UARS; ++i) {
+ if (context->uar[i])
+ munmap(context->uar[i], page_size);
+ }
+ if (context->hca_core_clock)
+ munmap(context->hca_core_clock - context->core_clock.offset,
+ page_size);
+ close_debug_file(context);
+}
+
+static struct verbs_device_ops mlx5_dev_ops = {
+ .init_context = mlx5_init_context,
+ .uninit_context = mlx5_cleanup_context,
+};
+
+static struct verbs_device *mlx5_driver_init(const char *uverbs_sys_path,
+ int abi_version)
+{
+ char value[8];
+ struct mlx5_device *dev;
+ unsigned vendor, device;
+ int i;
+
+ if (ibv_read_sysfs_file(uverbs_sys_path, "device/vendor",
+ value, sizeof value) < 0)
+ return NULL;
+ sscanf(value, "%i", &vendor);
+
+ if (ibv_read_sysfs_file(uverbs_sys_path, "device/device",
+ value, sizeof value) < 0)
+ return NULL;
+ sscanf(value, "%i", &device);
+
+ for (i = 0; i < sizeof hca_table / sizeof hca_table[0]; ++i)
+ if (vendor == hca_table[i].vendor &&
+ device == hca_table[i].device)
+ goto found;
+
+ return NULL;
+
+found:
+ if (abi_version < MLX5_UVERBS_MIN_ABI_VERSION ||
+ abi_version > MLX5_UVERBS_MAX_ABI_VERSION) {
+ fprintf(stderr, PFX "Fatal: ABI version %d of %s is not supported "
+ "(min supported %d, max supported %d)\n",
+ abi_version, uverbs_sys_path,
+ MLX5_UVERBS_MIN_ABI_VERSION,
+ MLX5_UVERBS_MAX_ABI_VERSION);
+ return NULL;
+ }
+
+ dev = calloc(1, sizeof *dev);
+ if (!dev) {
+ fprintf(stderr, PFX "Fatal: couldn't allocate device for %s\n",
+ uverbs_sys_path);
+ return NULL;
+ }
+
+ dev->page_size = sysconf(_SC_PAGESIZE);
+ dev->driver_abi_ver = abi_version;
+
+ dev->verbs_dev.ops = &mlx5_dev_ops;
+ dev->verbs_dev.sz = sizeof(*dev);
+ dev->verbs_dev.size_of_context = sizeof(struct mlx5_context) -
+ sizeof(struct ibv_context);
+
+ return &dev->verbs_dev;
+}
+
+static __attribute__((constructor)) void mlx5_register_driver(void)
+{
+ verbs_register_driver("mlx5", mlx5_driver_init);
+}
diff --git a/contrib/ofed/libmlx5/mlx5.h b/contrib/ofed/libmlx5/mlx5.h
new file mode 100644
index 0000000..456b9ba
--- /dev/null
+++ b/contrib/ofed/libmlx5/mlx5.h
@@ -0,0 +1,766 @@
+/*
+ * Copyright (c) 2012 Mellanox Technologies, Inc. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#ifndef MLX5_H
+#define MLX5_H
+
+#include <stddef.h>
+#include <stdio.h>
+#include <stdatomic.h>
+#include <stdbool.h>
+
+#include <sys/queue.h>
+
+#include <infiniband/driver.h>
+#include <infiniband/udma_barrier.h>
+#include "mlx5-abi.h"
+#include "bitmap.h"
+#include "mlx5dv.h"
+
+#define PFX "mlx5: "
+
+
+enum {
+ MLX5_IB_MMAP_CMD_SHIFT = 8,
+ MLX5_IB_MMAP_CMD_MASK = 0xff,
+};
+
+enum {
+ MLX5_MMAP_GET_REGULAR_PAGES_CMD = 0,
+ MLX5_MMAP_GET_CONTIGUOUS_PAGES_CMD = 1,
+ MLX5_MMAP_GET_CORE_CLOCK_CMD = 5
+};
+
+enum {
+ MLX5_CQE_VERSION_V0 = 0,
+ MLX5_CQE_VERSION_V1 = 1,
+};
+
+enum {
+ MLX5_ADAPTER_PAGE_SIZE = 4096,
+};
+
+#define MLX5_CQ_PREFIX "MLX_CQ"
+#define MLX5_QP_PREFIX "MLX_QP"
+#define MLX5_MR_PREFIX "MLX_MR"
+#define MLX5_RWQ_PREFIX "MLX_RWQ"
+#define MLX5_MAX_LOG2_CONTIG_BLOCK_SIZE 23
+#define MLX5_MIN_LOG2_CONTIG_BLOCK_SIZE 12
+
+enum {
+ MLX5_DBG_QP = 1 << 0,
+ MLX5_DBG_CQ = 1 << 1,
+ MLX5_DBG_QP_SEND = 1 << 2,
+ MLX5_DBG_QP_SEND_ERR = 1 << 3,
+ MLX5_DBG_CQ_CQE = 1 << 4,
+ MLX5_DBG_CONTIG = 1 << 5,
+};
+
+extern uint32_t mlx5_debug_mask;
+extern int mlx5_freeze_on_error_cqe;
+
+#ifdef MLX5_DEBUG
+#define mlx5_dbg(fp, mask, format, arg...) \
+do { \
+ if (mask & mlx5_debug_mask) \
+ fprintf(fp, "%s:%d: " format, __func__, __LINE__, ##arg); \
+} while (0)
+
+#else
+static inline void mlx5_dbg(FILE *fp, uint32_t mask, const char *fmt, ...)
+ __attribute__((format(printf, 3, 4)));
+static inline void mlx5_dbg(FILE *fp, uint32_t mask, const char *fmt, ...)
+{
+}
+#endif
+
+enum {
+ MLX5_STAT_RATE_OFFSET = 5
+};
+
+enum {
+ MLX5_QP_TABLE_SHIFT = 12,
+ MLX5_QP_TABLE_MASK = (1 << MLX5_QP_TABLE_SHIFT) - 1,
+ MLX5_QP_TABLE_SIZE = 1 << (24 - MLX5_QP_TABLE_SHIFT),
+};
+
+enum {
+ MLX5_UIDX_TABLE_SHIFT = 12,
+ MLX5_UIDX_TABLE_MASK = (1 << MLX5_UIDX_TABLE_SHIFT) - 1,
+ MLX5_UIDX_TABLE_SIZE = 1 << (24 - MLX5_UIDX_TABLE_SHIFT),
+};
+
+enum {
+ MLX5_SRQ_TABLE_SHIFT = 12,
+ MLX5_SRQ_TABLE_MASK = (1 << MLX5_SRQ_TABLE_SHIFT) - 1,
+ MLX5_SRQ_TABLE_SIZE = 1 << (24 - MLX5_SRQ_TABLE_SHIFT),
+};
+
+enum {
+ MLX5_BF_OFFSET = 0x800
+};
+
+enum {
+ MLX5_RECV_OPCODE_RDMA_WRITE_IMM = 0x00,
+ MLX5_RECV_OPCODE_SEND = 0x01,
+ MLX5_RECV_OPCODE_SEND_IMM = 0x02,
+ MLX5_RECV_OPCODE_SEND_INVAL = 0x03,
+
+ MLX5_CQE_OPCODE_ERROR = 0x1e,
+ MLX5_CQE_OPCODE_RESIZE = 0x16,
+};
+
+enum {
+ MLX5_SRQ_FLAG_SIGNATURE = 1 << 0,
+};
+
+enum {
+ MLX5_MAX_PORTS_NUM = 2,
+};
+
+enum {
+ MLX5_CSUM_SUPPORT_RAW_OVER_ETH = (1 << 0),
+ /*
+ * Only report rx checksum when the validation
+ * is valid.
+ */
+ MLX5_RX_CSUM_VALID = (1 << 16),
+};
+
+enum mlx5_alloc_type {
+ MLX5_ALLOC_TYPE_ANON,
+ MLX5_ALLOC_TYPE_HUGE,
+ MLX5_ALLOC_TYPE_CONTIG,
+ MLX5_ALLOC_TYPE_PREFER_HUGE,
+ MLX5_ALLOC_TYPE_PREFER_CONTIG,
+ MLX5_ALLOC_TYPE_ALL
+};
+
+enum mlx5_rsc_type {
+ MLX5_RSC_TYPE_QP,
+ MLX5_RSC_TYPE_XSRQ,
+ MLX5_RSC_TYPE_SRQ,
+ MLX5_RSC_TYPE_RWQ,
+ MLX5_RSC_TYPE_INVAL,
+};
+
+enum {
+ MLX5_USER_CMDS_SUPP_UHW_QUERY_DEVICE = 1 << 0,
+ MLX5_USER_CMDS_SUPP_UHW_CREATE_AH = 1 << 1,
+};
+
+enum mlx5_vendor_cap_flags {
+ MLX5_VENDOR_CAP_FLAGS_MPW = 1 << 0,
+};
+
+enum {
+ MLX5_FLOW_TAG_MASK = 0x000fffff,
+};
+
+struct mlx5_resource {
+ enum mlx5_rsc_type type;
+ uint32_t rsn;
+};
+
+struct mlx5_device {
+ struct verbs_device verbs_dev;
+ int page_size;
+ int driver_abi_ver;
+};
+
+struct mlx5_db_page;
+
+struct mlx5_spinlock {
+ pthread_spinlock_t lock;
+ int in_use;
+};
+
+struct mlx5_hugetlb_mem;
+
+struct mlx5_context {
+ struct ibv_context ibv_ctx;
+ int max_num_qps;
+ int bf_reg_size;
+ int tot_uuars;
+ int low_lat_uuars;
+ int num_uars_per_page;
+ int bf_regs_per_page;
+ int num_bf_regs;
+ int prefer_bf;
+ int shut_up_bf;
+ struct {
+ struct mlx5_qp **table;
+ int refcnt;
+ } qp_table[MLX5_QP_TABLE_SIZE];
+ pthread_mutex_t qp_table_mutex;
+
+ struct {
+ struct mlx5_srq **table;
+ int refcnt;
+ } srq_table[MLX5_SRQ_TABLE_SIZE];
+ pthread_mutex_t srq_table_mutex;
+
+ struct {
+ struct mlx5_resource **table;
+ int refcnt;
+ } uidx_table[MLX5_UIDX_TABLE_SIZE];
+ pthread_mutex_t uidx_table_mutex;
+
+ void *uar[MLX5_MAX_UARS];
+ struct mlx5_spinlock lock32;
+ struct mlx5_db_page *db_list;
+ pthread_mutex_t db_list_mutex;
+ int cache_line_size;
+ int max_sq_desc_sz;
+ int max_rq_desc_sz;
+ int max_send_wqebb;
+ int max_recv_wr;
+ unsigned max_srq_recv_wr;
+ int num_ports;
+ int stall_enable;
+ int stall_adaptive_enable;
+ int stall_cycles;
+ struct mlx5_bf *bfs;
+ FILE *dbg_fp;
+ char hostname[40];
+ struct mlx5_spinlock hugetlb_lock;
+ TAILQ_HEAD(,mlx5_hugetlb_mem) hugetlb_list;
+ int cqe_version;
+ uint8_t cached_link_layer[MLX5_MAX_PORTS_NUM];
+ int cached_device_cap_flags;
+ enum ibv_atomic_cap atomic_cap;
+ struct {
+ uint64_t offset;
+ uint64_t mask;
+ } core_clock;
+ void *hca_core_clock;
+ struct ibv_tso_caps cached_tso_caps;
+ int cmds_supp_uhw;
+ uint32_t uar_size;
+ uint64_t vendor_cap_flags; /* Use enum mlx5_vendor_cap_flags */
+ struct mlx5dv_cqe_comp_caps cqe_comp_caps;
+};
+
+struct mlx5_bitmap {
+ uint32_t last;
+ uint32_t top;
+ uint32_t max;
+ uint32_t avail;
+ uint32_t mask;
+ unsigned long *table;
+};
+
+struct mlx5_hugetlb_mem {
+ int shmid;
+ void *shmaddr;
+ struct mlx5_bitmap bitmap;
+ TAILQ_ENTRY(mlx5_hugetlb_mem) entry;
+};
+
+struct mlx5_buf {
+ void *buf;
+ size_t length;
+ int base;
+ struct mlx5_hugetlb_mem *hmem;
+ enum mlx5_alloc_type type;
+};
+
+struct mlx5_pd {
+ struct ibv_pd ibv_pd;
+ uint32_t pdn;
+};
+
+enum {
+ MLX5_CQ_SET_CI = 0,
+ MLX5_CQ_ARM_DB = 1,
+};
+
+enum {
+ MLX5_CQ_FLAGS_RX_CSUM_VALID = 1 << 0,
+ MLX5_CQ_FLAGS_EMPTY_DURING_POLL = 1 << 1,
+ MLX5_CQ_FLAGS_FOUND_CQES = 1 << 2,
+ MLX5_CQ_FLAGS_EXTENDED = 1 << 3,
+ MLX5_CQ_FLAGS_SINGLE_THREADED = 1 << 4,
+ MLX5_CQ_FLAGS_DV_OWNED = 1 << 5,
+};
+
+struct mlx5_cq {
+ /* ibv_cq should always be subset of ibv_cq_ex */
+ struct ibv_cq_ex ibv_cq;
+ struct mlx5_buf buf_a;
+ struct mlx5_buf buf_b;
+ struct mlx5_buf *active_buf;
+ struct mlx5_buf *resize_buf;
+ int resize_cqes;
+ int active_cqes;
+ struct mlx5_spinlock lock;
+ uint32_t cqn;
+ uint32_t cons_index;
+ uint32_t *dbrec;
+ int arm_sn;
+ int cqe_sz;
+ int resize_cqe_sz;
+ int stall_next_poll;
+ int stall_enable;
+ uint64_t stall_last_count;
+ int stall_adaptive_enable;
+ int stall_cycles;
+ struct mlx5_resource *cur_rsc;
+ struct mlx5_srq *cur_srq;
+ struct mlx5_cqe64 *cqe64;
+ uint32_t flags;
+ int umr_opcode;
+};
+
+struct mlx5_srq {
+ struct mlx5_resource rsc; /* This struct must be first */
+ struct verbs_srq vsrq;
+ struct mlx5_buf buf;
+ struct mlx5_spinlock lock;
+ uint64_t *wrid;
+ uint32_t srqn;
+ int max;
+ int max_gs;
+ int wqe_shift;
+ int head;
+ int tail;
+ uint32_t *db;
+ uint16_t counter;
+ int wq_sig;
+};
+
+struct wr_list {
+ uint16_t opcode;
+ uint16_t next;
+};
+
+struct mlx5_wq {
+ uint64_t *wrid;
+ unsigned *wqe_head;
+ struct mlx5_spinlock lock;
+ unsigned wqe_cnt;
+ unsigned max_post;
+ unsigned head;
+ unsigned tail;
+ unsigned cur_post;
+ int max_gs;
+ int wqe_shift;
+ int offset;
+ void *qend;
+ uint32_t *wr_data;
+};
+
+struct mlx5_bf {
+ void *reg;
+ int need_lock;
+ struct mlx5_spinlock lock;
+ unsigned offset;
+ unsigned buf_size;
+ unsigned uuarn;
+};
+
+struct mlx5_mr {
+ struct ibv_mr ibv_mr;
+ struct mlx5_buf buf;
+ uint32_t alloc_flags;
+};
+
+struct mlx5_qp {
+ struct mlx5_resource rsc; /* This struct must be first */
+ struct verbs_qp verbs_qp;
+ struct ibv_qp *ibv_qp;
+ struct mlx5_buf buf;
+ void *sq_start;
+ int max_inline_data;
+ int buf_size;
+ /* For Raw Packet QP, use different buffers for the SQ and RQ */
+ struct mlx5_buf sq_buf;
+ int sq_buf_size;
+ struct mlx5_bf *bf;
+
+ uint8_t fm_cache;
+ uint8_t sq_signal_bits;
+ struct mlx5_wq sq;
+
+ uint32_t *db;
+ struct mlx5_wq rq;
+ int wq_sig;
+ uint32_t qp_cap_cache;
+ int atomics_enabled;
+ uint32_t max_tso;
+ uint16_t max_tso_header;
+ int rss_qp;
+};
+
+struct mlx5_ah {
+ struct ibv_ah ibv_ah;
+ struct mlx5_wqe_av av;
+ bool kern_ah;
+};
+
+struct mlx5_rwq {
+ struct mlx5_resource rsc;
+ struct ibv_wq wq;
+ struct mlx5_buf buf;
+ int buf_size;
+ struct mlx5_wq rq;
+ uint32_t *db;
+ void *pbuff;
+ uint32_t *recv_db;
+ int wq_sig;
+};
+
+static inline int mlx5_ilog2(int n)
+{
+ int t;
+
+ if (n <= 0)
+ return -1;
+
+ t = 0;
+ while ((1 << t) < n)
+ ++t;
+
+ return t;
+}
+
+extern int mlx5_stall_num_loop;
+extern int mlx5_stall_cq_poll_min;
+extern int mlx5_stall_cq_poll_max;
+extern int mlx5_stall_cq_inc_step;
+extern int mlx5_stall_cq_dec_step;
+extern int mlx5_single_threaded;
+
+static inline unsigned DIV_ROUND_UP(unsigned n, unsigned d)
+{
+ return (n + d - 1u) / d;
+}
+
+static inline unsigned long align(unsigned long val, unsigned long align)
+{
+ return (val + align - 1) & ~(align - 1);
+}
+
+#define to_mxxx(xxx, type) \
+ ((struct mlx5_##type *) \
+ ((void *) ib##xxx - offsetof(struct mlx5_##type, ibv_##xxx)))
+
+static inline struct mlx5_device *to_mdev(struct ibv_device *ibdev)
+{
+ struct mlx5_device *ret;
+
+ ret = (void *)ibdev - offsetof(struct mlx5_device, verbs_dev);
+ return ret;
+}
+
+static inline struct mlx5_context *to_mctx(struct ibv_context *ibctx)
+{
+ return to_mxxx(ctx, context);
+}
+
+static inline struct mlx5_pd *to_mpd(struct ibv_pd *ibpd)
+{
+ return to_mxxx(pd, pd);
+}
+
+static inline struct mlx5_cq *to_mcq(struct ibv_cq *ibcq)
+{
+ return to_mxxx(cq, cq);
+}
+
+static inline struct mlx5_srq *to_msrq(struct ibv_srq *ibsrq)
+{
+ struct verbs_srq *vsrq = (struct verbs_srq *)ibsrq;
+
+ return container_of(vsrq, struct mlx5_srq, vsrq);
+}
+
+static inline struct mlx5_qp *to_mqp(struct ibv_qp *ibqp)
+{
+ struct verbs_qp *vqp = (struct verbs_qp *)ibqp;
+
+ return container_of(vqp, struct mlx5_qp, verbs_qp);
+}
+
+static inline struct mlx5_rwq *to_mrwq(struct ibv_wq *ibwq)
+{
+ return container_of(ibwq, struct mlx5_rwq, wq);
+}
+
+static inline struct mlx5_mr *to_mmr(struct ibv_mr *ibmr)
+{
+ return to_mxxx(mr, mr);
+}
+
+static inline struct mlx5_ah *to_mah(struct ibv_ah *ibah)
+{
+ return to_mxxx(ah, ah);
+}
+
+static inline int max_int(int a, int b)
+{
+ return a > b ? a : b;
+}
+
+static inline struct mlx5_qp *rsc_to_mqp(struct mlx5_resource *rsc)
+{
+ return (struct mlx5_qp *)rsc;
+}
+
+static inline struct mlx5_srq *rsc_to_msrq(struct mlx5_resource *rsc)
+{
+ return (struct mlx5_srq *)rsc;
+}
+
+static inline struct mlx5_rwq *rsc_to_mrwq(struct mlx5_resource *rsc)
+{
+ return (struct mlx5_rwq *)rsc;
+}
+
+int mlx5_alloc_buf(struct mlx5_buf *buf, size_t size, int page_size);
+void mlx5_free_buf(struct mlx5_buf *buf);
+int mlx5_alloc_buf_contig(struct mlx5_context *mctx, struct mlx5_buf *buf,
+ size_t size, int page_size, const char *component);
+void mlx5_free_buf_contig(struct mlx5_context *mctx, struct mlx5_buf *buf);
+int mlx5_alloc_prefered_buf(struct mlx5_context *mctx,
+ struct mlx5_buf *buf,
+ size_t size, int page_size,
+ enum mlx5_alloc_type alloc_type,
+ const char *component);
+int mlx5_free_actual_buf(struct mlx5_context *ctx, struct mlx5_buf *buf);
+void mlx5_get_alloc_type(const char *component,
+ enum mlx5_alloc_type *alloc_type,
+ enum mlx5_alloc_type default_alloc_type);
+int mlx5_use_huge(const char *key);
+
+uint32_t *mlx5_alloc_dbrec(struct mlx5_context *context);
+void mlx5_free_db(struct mlx5_context *context, uint32_t *db);
+
+int mlx5_query_device(struct ibv_context *context,
+ struct ibv_device_attr *attr);
+int mlx5_query_device_ex(struct ibv_context *context,
+ const struct ibv_query_device_ex_input *input,
+ struct ibv_device_attr_ex *attr,
+ size_t attr_size);
+int mlx5_query_rt_values(struct ibv_context *context,
+ struct ibv_values_ex *values);
+struct ibv_qp *mlx5_create_qp_ex(struct ibv_context *context,
+ struct ibv_qp_init_attr_ex *attr);
+int mlx5_query_port(struct ibv_context *context, uint8_t port,
+ struct ibv_port_attr *attr);
+
+struct ibv_pd *mlx5_alloc_pd(struct ibv_context *context);
+int mlx5_free_pd(struct ibv_pd *pd);
+
+struct ibv_mr *mlx5_reg_mr(struct ibv_pd *pd, void *addr,
+ size_t length, int access);
+int mlx5_rereg_mr(struct ibv_mr *mr, int flags, struct ibv_pd *pd, void *addr,
+ size_t length, int access);
+int mlx5_dereg_mr(struct ibv_mr *mr);
+struct ibv_mw *mlx5_alloc_mw(struct ibv_pd *pd, enum ibv_mw_type);
+int mlx5_dealloc_mw(struct ibv_mw *mw);
+int mlx5_bind_mw(struct ibv_qp *qp, struct ibv_mw *mw,
+ struct ibv_mw_bind *mw_bind);
+
+struct ibv_cq *mlx5_create_cq(struct ibv_context *context, int cqe,
+ struct ibv_comp_channel *channel,
+ int comp_vector);
+struct ibv_cq_ex *mlx5_create_cq_ex(struct ibv_context *context,
+ struct ibv_cq_init_attr_ex *cq_attr);
+void mlx5_cq_fill_pfns(struct mlx5_cq *cq, const struct ibv_cq_init_attr_ex *cq_attr);
+int mlx5_alloc_cq_buf(struct mlx5_context *mctx, struct mlx5_cq *cq,
+ struct mlx5_buf *buf, int nent, int cqe_sz);
+int mlx5_free_cq_buf(struct mlx5_context *ctx, struct mlx5_buf *buf);
+int mlx5_resize_cq(struct ibv_cq *cq, int cqe);
+int mlx5_destroy_cq(struct ibv_cq *cq);
+int mlx5_poll_cq(struct ibv_cq *cq, int ne, struct ibv_wc *wc);
+int mlx5_poll_cq_v1(struct ibv_cq *cq, int ne, struct ibv_wc *wc);
+int mlx5_arm_cq(struct ibv_cq *cq, int solicited);
+void mlx5_cq_event(struct ibv_cq *cq);
+void __mlx5_cq_clean(struct mlx5_cq *cq, uint32_t qpn, struct mlx5_srq *srq);
+void mlx5_cq_clean(struct mlx5_cq *cq, uint32_t qpn, struct mlx5_srq *srq);
+void mlx5_cq_resize_copy_cqes(struct mlx5_cq *cq);
+
+struct ibv_srq *mlx5_create_srq(struct ibv_pd *pd,
+ struct ibv_srq_init_attr *attr);
+int mlx5_modify_srq(struct ibv_srq *srq, struct ibv_srq_attr *attr,
+ int mask);
+int mlx5_query_srq(struct ibv_srq *srq,
+ struct ibv_srq_attr *attr);
+int mlx5_destroy_srq(struct ibv_srq *srq);
+int mlx5_alloc_srq_buf(struct ibv_context *context, struct mlx5_srq *srq);
+void mlx5_free_srq_wqe(struct mlx5_srq *srq, int ind);
+int mlx5_post_srq_recv(struct ibv_srq *ibsrq,
+ struct ibv_recv_wr *wr,
+ struct ibv_recv_wr **bad_wr);
+
+struct ibv_qp *mlx5_create_qp(struct ibv_pd *pd, struct ibv_qp_init_attr *attr);
+int mlx5_query_qp(struct ibv_qp *qp, struct ibv_qp_attr *attr,
+ int attr_mask,
+ struct ibv_qp_init_attr *init_attr);
+int mlx5_modify_qp(struct ibv_qp *qp, struct ibv_qp_attr *attr,
+ int attr_mask);
+int mlx5_destroy_qp(struct ibv_qp *qp);
+void mlx5_init_qp_indices(struct mlx5_qp *qp);
+void mlx5_init_rwq_indices(struct mlx5_rwq *rwq);
+int mlx5_post_send(struct ibv_qp *ibqp, struct ibv_send_wr *wr,
+ struct ibv_send_wr **bad_wr);
+int mlx5_post_recv(struct ibv_qp *ibqp, struct ibv_recv_wr *wr,
+ struct ibv_recv_wr **bad_wr);
+int mlx5_post_wq_recv(struct ibv_wq *ibwq, struct ibv_recv_wr *wr,
+ struct ibv_recv_wr **bad_wr);
+void mlx5_calc_sq_wqe_size(struct ibv_qp_cap *cap, enum ibv_qp_type type,
+ struct mlx5_qp *qp);
+void mlx5_set_sq_sizes(struct mlx5_qp *qp, struct ibv_qp_cap *cap,
+ enum ibv_qp_type type);
+struct mlx5_qp *mlx5_find_qp(struct mlx5_context *ctx, uint32_t qpn);
+int mlx5_store_qp(struct mlx5_context *ctx, uint32_t qpn, struct mlx5_qp *qp);
+void mlx5_clear_qp(struct mlx5_context *ctx, uint32_t qpn);
+int32_t mlx5_store_uidx(struct mlx5_context *ctx, void *rsc);
+void mlx5_clear_uidx(struct mlx5_context *ctx, uint32_t uidx);
+struct mlx5_srq *mlx5_find_srq(struct mlx5_context *ctx, uint32_t srqn);
+int mlx5_store_srq(struct mlx5_context *ctx, uint32_t srqn,
+ struct mlx5_srq *srq);
+void mlx5_clear_srq(struct mlx5_context *ctx, uint32_t srqn);
+struct ibv_ah *mlx5_create_ah(struct ibv_pd *pd, struct ibv_ah_attr *attr);
+int mlx5_destroy_ah(struct ibv_ah *ah);
+int mlx5_alloc_av(struct mlx5_pd *pd, struct ibv_ah_attr *attr,
+ struct mlx5_ah *ah);
+void mlx5_free_av(struct mlx5_ah *ah);
+int mlx5_attach_mcast(struct ibv_qp *qp, const union ibv_gid *gid, uint16_t lid);
+int mlx5_detach_mcast(struct ibv_qp *qp, const union ibv_gid *gid, uint16_t lid);
+int mlx5_round_up_power_of_two(long long sz);
+void *mlx5_get_atomic_laddr(struct mlx5_qp *qp, uint16_t idx, int *byte_count);
+void *mlx5_get_send_wqe(struct mlx5_qp *qp, int n);
+int mlx5_copy_to_recv_wqe(struct mlx5_qp *qp, int idx, void *buf, int size);
+int mlx5_copy_to_send_wqe(struct mlx5_qp *qp, int idx, void *buf, int size);
+int mlx5_copy_to_recv_srq(struct mlx5_srq *srq, int idx, void *buf, int size);
+struct ibv_xrcd *mlx5_open_xrcd(struct ibv_context *context,
+ struct ibv_xrcd_init_attr *xrcd_init_attr);
+int mlx5_get_srq_num(struct ibv_srq *srq, uint32_t *srq_num);
+int mlx5_close_xrcd(struct ibv_xrcd *ib_xrcd);
+struct ibv_wq *mlx5_create_wq(struct ibv_context *context,
+ struct ibv_wq_init_attr *attr);
+int mlx5_modify_wq(struct ibv_wq *wq, struct ibv_wq_attr *attr);
+int mlx5_destroy_wq(struct ibv_wq *wq);
+struct ibv_rwq_ind_table *mlx5_create_rwq_ind_table(struct ibv_context *context,
+ struct ibv_rwq_ind_table_init_attr *init_attr);
+int mlx5_destroy_rwq_ind_table(struct ibv_rwq_ind_table *rwq_ind_table);
+struct ibv_srq *mlx5_create_srq_ex(struct ibv_context *context,
+ struct ibv_srq_init_attr_ex *attr);
+
+static inline void *mlx5_find_uidx(struct mlx5_context *ctx, uint32_t uidx)
+{
+ int tind = uidx >> MLX5_UIDX_TABLE_SHIFT;
+
+ if (likely(ctx->uidx_table[tind].refcnt))
+ return ctx->uidx_table[tind].table[uidx & MLX5_UIDX_TABLE_MASK];
+
+ return NULL;
+}
+
+static inline int mlx5_spin_lock(struct mlx5_spinlock *lock)
+{
+ if (!mlx5_single_threaded)
+ return pthread_spin_lock(&lock->lock);
+
+ if (unlikely(lock->in_use)) {
+ fprintf(stderr, "*** ERROR: multithreading vilation ***\n"
+ "You are running a multithreaded application but\n"
+ "you set MLX5_SINGLE_THREADED=1. Please unset it.\n");
+ abort();
+ } else {
+ lock->in_use = 1;
+ /*
+ * This fence is not at all correct, but it increases the
+ * chance that in_use is detected by another thread without
+ * much runtime cost. */
+ atomic_thread_fence(memory_order_acq_rel);
+ }
+
+ return 0;
+}
+
+static inline int mlx5_spin_unlock(struct mlx5_spinlock *lock)
+{
+ if (!mlx5_single_threaded)
+ return pthread_spin_unlock(&lock->lock);
+
+ lock->in_use = 0;
+
+ return 0;
+}
+
+static inline int mlx5_spinlock_init(struct mlx5_spinlock *lock)
+{
+ lock->in_use = 0;
+ return pthread_spin_init(&lock->lock, PTHREAD_PROCESS_PRIVATE);
+}
+
+static inline int mlx5_spinlock_destroy(struct mlx5_spinlock *lock)
+{
+ return pthread_spin_destroy(&lock->lock);
+}
+
+static inline void set_command(int command, off_t *offset)
+{
+ *offset |= (command << MLX5_IB_MMAP_CMD_SHIFT);
+}
+
+static inline void set_arg(int arg, off_t *offset)
+{
+ *offset |= arg;
+}
+
+static inline void set_order(int order, off_t *offset)
+{
+ set_arg(order, offset);
+}
+
+static inline void set_index(int index, off_t *offset)
+{
+ set_arg(index, offset);
+}
+
+static inline uint8_t calc_sig(void *wqe, int size)
+{
+ int i;
+ uint8_t *p = wqe;
+ uint8_t res = 0;
+
+ for (i = 0; i < size; ++i)
+ res ^= p[i];
+
+ return ~res;
+}
+
+#endif /* MLX5_H */
diff --git a/contrib/ofed/libmlx5/mlx5dv.7 b/contrib/ofed/libmlx5/mlx5dv.7
new file mode 100644
index 0000000..c02c967
--- /dev/null
+++ b/contrib/ofed/libmlx5/mlx5dv.7
@@ -0,0 +1,44 @@
+.\" -*- nroff -*-
+.\" Licensed under the OpenIB.org (MIT) - See COPYING.md
+.\"
+.TH MLX5DV 7 2017-02-02 1.0.0
+.SH "NAME"
+mlx5dv \- Direct verbs for mlx5 devices
+.br
+This is low level access to mlx5 devices to perform data path operations,
+without general branching performed by \fBibv_post_send\fR(3).
+
+.SH "DESCRIPTION"
+The libibverbs API is an abstract one. It is agnostic to any underlying
+provider specific implementation. While this abstraction has the advantage
+of user applications portability it has a performance penalty. For some
+applications optimizing performance is more important than portability.
+
+The mlx5 direct verbs API is intended for such applications.
+It exposes mlx5 specific low level data path (send/receive/completion)
+operations, allowing the application to bypass the libibverbs data path API.
+
+This interface consists from one hardware specific header file
+with relevant inline functions and conversion logic from ibverbs structures
+to mlx5 specific structures.
+
+The direct include of mlx5dv.h together with linkage to mlx5 library will
+allow usage of this new interface.
+
+Once an application uses the direct flow the locking scheme is fully managed
+by itself. There is an expectation that no mixed flows in the data path for both
+direct/non-direct access will be by same application.
+
+.SH "NOTES"
+All Mellanox NIC devices starting from Connect-IB (Connect-IB,
+ConnectX-4, ConnectX-4Lx, ConnectX-5, ...) implement the mlx5 API,
+thus using the mlx5 direct verbs does not limit the applications
+to a single NIC HW device thus keeping some level of portability.
+
+.SH "SEE ALSO"
+.BR ibv_post_send (3),
+.BR verbs (7)
+
+.SH "AUTHORS"
+.TP
+Leon Romanovsky <leonro@mellanox.com>
diff --git a/contrib/ofed/libmlx5/mlx5dv.h b/contrib/ofed/libmlx5/mlx5dv.h
new file mode 100644
index 0000000..5cd0b0d
--- /dev/null
+++ b/contrib/ofed/libmlx5/mlx5dv.h
@@ -0,0 +1,618 @@
+/*
+ * Copyright (c) 2017 Mellanox Technologies, Inc. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#ifndef _MLX5DV_H_
+#define _MLX5DV_H_
+
+#include <infiniband/types.h> /* For the __be64 type */
+#include <infiniband/endian.h>
+
+#if defined(__SSE3__)
+#include <emmintrin.h>
+#include <tmmintrin.h>
+#endif /* defined(__SSE3__) */
+
+#include <infiniband/verbs.h>
+
+/* Always inline the functions */
+#ifdef __GNUC__
+#define MLX5DV_ALWAYS_INLINE inline __attribute__((always_inline))
+#else
+#define MLX5DV_ALWAYS_INLINE inline
+#endif
+
+enum {
+ MLX5_RCV_DBR = 0,
+ MLX5_SND_DBR = 1,
+};
+
+enum mlx5dv_context_comp_mask {
+ MLX5DV_CONTEXT_MASK_CQE_COMPRESION = 1 << 0,
+ MLX5DV_CONTEXT_MASK_RESERVED = 1 << 1,
+};
+
+struct mlx5dv_cqe_comp_caps {
+ uint32_t max_num;
+ uint32_t supported_format; /* enum mlx5dv_cqe_comp_res_format */
+};
+
+/*
+ * Direct verbs device-specific attributes
+ */
+struct mlx5dv_context {
+ uint8_t version;
+ uint64_t flags;
+ uint64_t comp_mask;
+ struct mlx5dv_cqe_comp_caps cqe_comp_caps;
+};
+
+enum mlx5dv_context_flags {
+ /*
+ * This flag indicates if CQE version 0 or 1 is needed.
+ */
+ MLX5DV_CONTEXT_FLAGS_CQE_V1 = (1 << 0),
+ MLX5DV_CONTEXT_FLAGS_MPW = (1 << 1),
+};
+
+enum mlx5dv_cq_init_attr_mask {
+ MLX5DV_CQ_INIT_ATTR_MASK_COMPRESSED_CQE = 1 << 0,
+ MLX5DV_CQ_INIT_ATTR_MASK_RESERVED = 1 << 1,
+};
+
+struct mlx5dv_cq_init_attr {
+ uint64_t comp_mask; /* Use enum mlx5dv_cq_init_attr_mask */
+ uint8_t cqe_comp_res_format; /* Use enum mlx5dv_cqe_comp_res_format */
+};
+
+struct ibv_cq_ex *mlx5dv_create_cq(struct ibv_context *context,
+ struct ibv_cq_init_attr_ex *cq_attr,
+ struct mlx5dv_cq_init_attr *mlx5_cq_attr);
+/*
+ * Most device capabilities are exported by ibv_query_device(...),
+ * but there is HW device-specific information which is important
+ * for data-path, but isn't provided.
+ *
+ * Return 0 on success.
+ */
+int mlx5dv_query_device(struct ibv_context *ctx_in,
+ struct mlx5dv_context *attrs_out);
+
+struct mlx5dv_qp {
+ uint32_t *dbrec;
+ struct {
+ void *buf;
+ uint32_t wqe_cnt;
+ uint32_t stride;
+ } sq;
+ struct {
+ void *buf;
+ uint32_t wqe_cnt;
+ uint32_t stride;
+ } rq;
+ struct {
+ void *reg;
+ uint32_t size;
+ } bf;
+ uint64_t comp_mask;
+};
+
+struct mlx5dv_cq {
+ void *buf;
+ uint32_t *dbrec;
+ uint32_t cqe_cnt;
+ uint32_t cqe_size;
+ void *uar;
+ uint32_t cqn;
+ uint64_t comp_mask;
+};
+
+struct mlx5dv_srq {
+ void *buf;
+ uint32_t *dbrec;
+ uint32_t stride;
+ uint32_t head;
+ uint32_t tail;
+ uint64_t comp_mask;
+};
+
+struct mlx5dv_rwq {
+ void *buf;
+ uint32_t *dbrec;
+ uint32_t wqe_cnt;
+ uint32_t stride;
+ uint64_t comp_mask;
+};
+
+struct mlx5dv_obj {
+ struct {
+ struct ibv_qp *in;
+ struct mlx5dv_qp *out;
+ } qp;
+ struct {
+ struct ibv_cq *in;
+ struct mlx5dv_cq *out;
+ } cq;
+ struct {
+ struct ibv_srq *in;
+ struct mlx5dv_srq *out;
+ } srq;
+ struct {
+ struct ibv_wq *in;
+ struct mlx5dv_rwq *out;
+ } rwq;
+};
+
+enum mlx5dv_obj_type {
+ MLX5DV_OBJ_QP = 1 << 0,
+ MLX5DV_OBJ_CQ = 1 << 1,
+ MLX5DV_OBJ_SRQ = 1 << 2,
+ MLX5DV_OBJ_RWQ = 1 << 3,
+};
+
+/*
+ * This function will initialize mlx5dv_xxx structs based on supplied type.
+ * The information for initialization is taken from ibv_xx structs supplied
+ * as part of input.
+ *
+ * Request information of CQ marks its owned by DV for all consumer index
+ * related actions.
+ *
+ * The initialization type can be combination of several types together.
+ *
+ * Return: 0 in case of success.
+ */
+int mlx5dv_init_obj(struct mlx5dv_obj *obj, uint64_t obj_type);
+
+enum {
+ MLX5_OPCODE_NOP = 0x00,
+ MLX5_OPCODE_SEND_INVAL = 0x01,
+ MLX5_OPCODE_RDMA_WRITE = 0x08,
+ MLX5_OPCODE_RDMA_WRITE_IMM = 0x09,
+ MLX5_OPCODE_SEND = 0x0a,
+ MLX5_OPCODE_SEND_IMM = 0x0b,
+ MLX5_OPCODE_TSO = 0x0e,
+ MLX5_OPCODE_RDMA_READ = 0x10,
+ MLX5_OPCODE_ATOMIC_CS = 0x11,
+ MLX5_OPCODE_ATOMIC_FA = 0x12,
+ MLX5_OPCODE_ATOMIC_MASKED_CS = 0x14,
+ MLX5_OPCODE_ATOMIC_MASKED_FA = 0x15,
+ MLX5_OPCODE_FMR = 0x19,
+ MLX5_OPCODE_LOCAL_INVAL = 0x1b,
+ MLX5_OPCODE_CONFIG_CMD = 0x1f,
+ MLX5_OPCODE_UMR = 0x25,
+};
+
+/*
+ * CQE related part
+ */
+
+enum {
+ MLX5_INLINE_SCATTER_32 = 0x4,
+ MLX5_INLINE_SCATTER_64 = 0x8,
+};
+
+enum {
+ MLX5_CQE_SYNDROME_LOCAL_LENGTH_ERR = 0x01,
+ MLX5_CQE_SYNDROME_LOCAL_QP_OP_ERR = 0x02,
+ MLX5_CQE_SYNDROME_LOCAL_PROT_ERR = 0x04,
+ MLX5_CQE_SYNDROME_WR_FLUSH_ERR = 0x05,
+ MLX5_CQE_SYNDROME_MW_BIND_ERR = 0x06,
+ MLX5_CQE_SYNDROME_BAD_RESP_ERR = 0x10,
+ MLX5_CQE_SYNDROME_LOCAL_ACCESS_ERR = 0x11,
+ MLX5_CQE_SYNDROME_REMOTE_INVAL_REQ_ERR = 0x12,
+ MLX5_CQE_SYNDROME_REMOTE_ACCESS_ERR = 0x13,
+ MLX5_CQE_SYNDROME_REMOTE_OP_ERR = 0x14,
+ MLX5_CQE_SYNDROME_TRANSPORT_RETRY_EXC_ERR = 0x15,
+ MLX5_CQE_SYNDROME_RNR_RETRY_EXC_ERR = 0x16,
+ MLX5_CQE_SYNDROME_REMOTE_ABORTED_ERR = 0x22,
+};
+
+enum {
+ MLX5_CQE_L2_OK = 1 << 0,
+ MLX5_CQE_L3_OK = 1 << 1,
+ MLX5_CQE_L4_OK = 1 << 2,
+};
+
+enum {
+ MLX5_CQE_L3_HDR_TYPE_NONE = 0x0,
+ MLX5_CQE_L3_HDR_TYPE_IPV6 = 0x1,
+ MLX5_CQE_L3_HDR_TYPE_IPV4 = 0x2,
+};
+
+enum {
+ MLX5_CQE_OWNER_MASK = 1,
+ MLX5_CQE_REQ = 0,
+ MLX5_CQE_RESP_WR_IMM = 1,
+ MLX5_CQE_RESP_SEND = 2,
+ MLX5_CQE_RESP_SEND_IMM = 3,
+ MLX5_CQE_RESP_SEND_INV = 4,
+ MLX5_CQE_RESIZE_CQ = 5,
+ MLX5_CQE_REQ_ERR = 13,
+ MLX5_CQE_RESP_ERR = 14,
+ MLX5_CQE_INVALID = 15,
+};
+
+enum {
+ MLX5_CQ_DOORBELL = 0x20
+};
+
+enum {
+ MLX5_CQ_DB_REQ_NOT_SOL = 1 << 24,
+ MLX5_CQ_DB_REQ_NOT = 0 << 24,
+};
+
+struct mlx5_err_cqe {
+ uint8_t rsvd0[32];
+ uint32_t srqn;
+ uint8_t rsvd1[18];
+ uint8_t vendor_err_synd;
+ uint8_t syndrome;
+ uint32_t s_wqe_opcode_qpn;
+ uint16_t wqe_counter;
+ uint8_t signature;
+ uint8_t op_own;
+};
+
+struct mlx5_cqe64 {
+ uint8_t rsvd0[17];
+ uint8_t ml_path;
+ uint8_t rsvd20[4];
+ uint16_t slid;
+ uint32_t flags_rqpn;
+ uint8_t hds_ip_ext;
+ uint8_t l4_hdr_type_etc;
+ uint16_t vlan_info;
+ uint32_t srqn_uidx;
+ uint32_t imm_inval_pkey;
+ uint8_t rsvd40[4];
+ uint32_t byte_cnt;
+ __be64 timestamp;
+ uint32_t sop_drop_qpn;
+ uint16_t wqe_counter;
+ uint8_t signature;
+ uint8_t op_own;
+};
+
+enum mlx5dv_cqe_comp_res_format {
+ MLX5DV_CQE_RES_FORMAT_HASH = 1 << 0,
+ MLX5DV_CQE_RES_FORMAT_CSUM = 1 << 1,
+ MLX5DV_CQE_RES_FORMAT_RESERVED = 1 << 2,
+};
+
+static MLX5DV_ALWAYS_INLINE
+uint8_t mlx5dv_get_cqe_owner(struct mlx5_cqe64 *cqe)
+{
+ return cqe->op_own & 0x1;
+}
+
+static MLX5DV_ALWAYS_INLINE
+void mlx5dv_set_cqe_owner(struct mlx5_cqe64 *cqe, uint8_t val)
+{
+ cqe->op_own = (val & 0x1) | (cqe->op_own & ~0x1);
+}
+
+/* Solicited event */
+static MLX5DV_ALWAYS_INLINE
+uint8_t mlx5dv_get_cqe_se(struct mlx5_cqe64 *cqe)
+{
+ return (cqe->op_own >> 1) & 0x1;
+}
+
+static MLX5DV_ALWAYS_INLINE
+uint8_t mlx5dv_get_cqe_format(struct mlx5_cqe64 *cqe)
+{
+ return (cqe->op_own >> 2) & 0x3;
+}
+
+static MLX5DV_ALWAYS_INLINE
+uint8_t mlx5dv_get_cqe_opcode(struct mlx5_cqe64 *cqe)
+{
+ return cqe->op_own >> 4;
+}
+
+/*
+ * WQE related part
+ */
+enum {
+ MLX5_INVALID_LKEY = 0x100,
+};
+
+enum {
+ MLX5_EXTENDED_UD_AV = 0x80000000,
+};
+
+enum {
+ MLX5_WQE_CTRL_CQ_UPDATE = 2 << 2,
+ MLX5_WQE_CTRL_SOLICITED = 1 << 1,
+ MLX5_WQE_CTRL_FENCE = 4 << 5,
+ MLX5_WQE_CTRL_INITIATOR_SMALL_FENCE = 1 << 5,
+};
+
+enum {
+ MLX5_SEND_WQE_BB = 64,
+ MLX5_SEND_WQE_SHIFT = 6,
+};
+
+enum {
+ MLX5_INLINE_SEG = 0x80000000,
+};
+
+enum {
+ MLX5_ETH_WQE_L3_CSUM = (1 << 6),
+ MLX5_ETH_WQE_L4_CSUM = (1 << 7),
+};
+
+struct mlx5_wqe_srq_next_seg {
+ uint8_t rsvd0[2];
+ uint16_t next_wqe_index;
+ uint8_t signature;
+ uint8_t rsvd1[11];
+};
+
+struct mlx5_wqe_data_seg {
+ uint32_t byte_count;
+ uint32_t lkey;
+ uint64_t addr;
+};
+
+struct mlx5_wqe_ctrl_seg {
+ uint32_t opmod_idx_opcode;
+ uint32_t qpn_ds;
+ uint8_t signature;
+ uint8_t rsvd[2];
+ uint8_t fm_ce_se;
+ uint32_t imm;
+};
+
+struct mlx5_wqe_av {
+ union {
+ struct {
+ uint32_t qkey;
+ uint32_t reserved;
+ } qkey;
+ uint64_t dc_key;
+ } key;
+ uint32_t dqp_dct;
+ uint8_t stat_rate_sl;
+ uint8_t fl_mlid;
+ uint16_t rlid;
+ uint8_t reserved0[4];
+ uint8_t rmac[6];
+ uint8_t tclass;
+ uint8_t hop_limit;
+ uint32_t grh_gid_fl;
+ uint8_t rgid[16];
+};
+
+struct mlx5_wqe_datagram_seg {
+ struct mlx5_wqe_av av;
+};
+
+struct mlx5_wqe_raddr_seg {
+ uint64_t raddr;
+ uint32_t rkey;
+ uint32_t reserved;
+};
+
+struct mlx5_wqe_atomic_seg {
+ uint64_t swap_add;
+ uint64_t compare;
+};
+
+struct mlx5_wqe_inl_data_seg {
+ uint32_t byte_count;
+};
+
+struct mlx5_wqe_eth_seg {
+ uint32_t rsvd0;
+ uint8_t cs_flags;
+ uint8_t rsvd1;
+ uint16_t mss;
+ uint32_t rsvd2;
+ uint16_t inline_hdr_sz;
+ uint8_t inline_hdr_start[2];
+ uint8_t inline_hdr[16];
+};
+
+/*
+ * Control segment - contains some control information for the current WQE.
+ *
+ * Output:
+ * seg - control segment to be filled
+ * Input:
+ * pi - WQEBB number of the first block of this WQE.
+ * This number should wrap at 0xffff, regardless of
+ * size of the WQ.
+ * opcode - Opcode of this WQE. Encodes the type of operation
+ * to be executed on the QP.
+ * opmod - Opcode modifier.
+ * qp_num - QP/SQ number this WQE is posted to.
+ * fm_ce_se - FM (fence mode), CE (completion and event mode)
+ * and SE (solicited event).
+ * ds - WQE size in octowords (16-byte units). DS accounts for all
+ * the segments in the WQE as summarized in WQE construction.
+ * signature - WQE signature.
+ * imm - Immediate data/Invalidation key/UMR mkey.
+ */
+static MLX5DV_ALWAYS_INLINE
+void mlx5dv_set_ctrl_seg(struct mlx5_wqe_ctrl_seg *seg, uint16_t pi,
+ uint8_t opcode, uint8_t opmod, uint32_t qp_num,
+ uint8_t fm_ce_se, uint8_t ds,
+ uint8_t signature, uint32_t imm)
+{
+ seg->opmod_idx_opcode = htobe32(((uint32_t)opmod << 24) | ((uint32_t)pi << 8) | opcode);
+ seg->qpn_ds = htobe32((qp_num << 8) | ds);
+ seg->fm_ce_se = fm_ce_se;
+ seg->signature = signature;
+ /*
+ * The caller should prepare "imm" in advance based on WR opcode.
+ * For IBV_WR_SEND_WITH_IMM and IBV_WR_RDMA_WRITE_WITH_IMM,
+ * the "imm" should be assigned as is.
+ * For the IBV_WR_SEND_WITH_INV, it should be htobe32(imm).
+ */
+ seg->imm = imm;
+}
+
+/* x86 optimized version of mlx5dv_set_ctrl_seg()
+ *
+ * This is useful when doing calculations on large data sets
+ * for parallel calculations.
+ *
+ * It doesn't suit for serialized algorithms.
+ */
+#if defined(__SSE3__)
+static MLX5DV_ALWAYS_INLINE
+void mlx5dv_x86_set_ctrl_seg(struct mlx5_wqe_ctrl_seg *seg, uint16_t pi,
+ uint8_t opcode, uint8_t opmod, uint32_t qp_num,
+ uint8_t fm_ce_se, uint8_t ds,
+ uint8_t signature, uint32_t imm)
+{
+ __m128i val = _mm_set_epi32(imm, qp_num, (ds << 16) | pi,
+ (signature << 24) | (opcode << 16) | (opmod << 8) | fm_ce_se);
+ __m128i mask = _mm_set_epi8(15, 14, 13, 12, /* immediate */
+ 0, /* signal/fence_mode */
+ 0x80, 0x80, /* reserved */
+ 3, /* signature */
+ 6, /* data size */
+ 8, 9, 10, /* QP num */
+ 2, /* opcode */
+ 4, 5, /* sw_pi in BE */
+ 1 /* opmod */
+ );
+ *(__m128i *) seg = _mm_shuffle_epi8(val, mask);
+}
+#endif /* defined(__SSE3__) */
+
+/*
+ * Datagram Segment - contains address information required in order
+ * to form a datagram message.
+ *
+ * Output:
+ * seg - datagram segment to be filled.
+ * Input:
+ * key - Q_key/access key.
+ * dqp_dct - Destination QP number for UD and DCT for DC.
+ * ext - Address vector extension.
+ * stat_rate_sl - Maximum static rate control, SL/ethernet priority.
+ * fl_mlid - Force loopback and source LID for IB.
+ * rlid - Remote LID
+ * rmac - Remote MAC
+ * tclass - GRH tclass/IPv6 tclass/IPv4 ToS
+ * hop_limit - GRH hop limit/IPv6 hop limit/IPv4 TTL
+ * grh_gid_fi - GRH, source GID address and IPv6 flow label.
+ * rgid - Remote GID/IP address.
+ */
+static MLX5DV_ALWAYS_INLINE
+void mlx5dv_set_dgram_seg(struct mlx5_wqe_datagram_seg *seg,
+ uint64_t key, uint32_t dqp_dct,
+ uint8_t ext, uint8_t stat_rate_sl,
+ uint8_t fl_mlid, uint16_t rlid,
+ uint8_t *rmac, uint8_t tclass,
+ uint8_t hop_limit, uint32_t grh_gid_fi,
+ uint8_t *rgid)
+{
+
+ /* Always put 64 bits, in q_key, the reserved part will be 0 */
+ seg->av.key.dc_key = htobe64(key);
+ seg->av.dqp_dct = htobe32(((uint32_t)ext << 31) | dqp_dct);
+ seg->av.stat_rate_sl = stat_rate_sl;
+ seg->av.fl_mlid = fl_mlid;
+ seg->av.rlid = htobe16(rlid);
+ memcpy(seg->av.rmac, rmac, 6);
+ seg->av.tclass = tclass;
+ seg->av.hop_limit = hop_limit;
+ seg->av.grh_gid_fl = htobe32(grh_gid_fi);
+ memcpy(seg->av.rgid, rgid, 16);
+}
+
+/*
+ * Data Segments - contain pointers and a byte count for the scatter/gather list.
+ * They can optionally contain data, which will save a memory read access for
+ * gather Work Requests.
+ */
+static MLX5DV_ALWAYS_INLINE
+void mlx5dv_set_data_seg(struct mlx5_wqe_data_seg *seg,
+ uint32_t length, uint32_t lkey,
+ uintptr_t address)
+{
+ seg->byte_count = htobe32(length);
+ seg->lkey = htobe32(lkey);
+ seg->addr = htobe64(address);
+}
+/*
+ * x86 optimized version of mlx5dv_set_data_seg()
+ *
+ * This is useful when doing calculations on large data sets
+ * for parallel calculations.
+ *
+ * It doesn't suit for serialized algorithms.
+ */
+#if defined(__SSE3__)
+static MLX5DV_ALWAYS_INLINE
+void mlx5dv_x86_set_data_seg(struct mlx5_wqe_data_seg *seg,
+ uint32_t length, uint32_t lkey,
+ uintptr_t address)
+{
+ __m128i val = _mm_set_epi32((uint32_t)address, (uint32_t)(address >> 32), lkey, length);
+ __m128i mask = _mm_set_epi8(12, 13, 14, 15, /* local address low */
+ 8, 9, 10, 11, /* local address high */
+ 4, 5, 6, 7, /* l_key */
+ 0, 1, 2, 3 /* byte count */
+ );
+ *(__m128i *) seg = _mm_shuffle_epi8(val, mask);
+}
+#endif /* defined(__SSE3__) */
+
+/*
+ * Eth Segment - contains packet headers and information for stateless L2, L3, L4 offloading.
+ *
+ * Output:
+ * seg - Eth segment to be filled.
+ * Input:
+ * cs_flags - l3cs/l3cs_inner/l4cs/l4cs_inner.
+ * mss - Maximum segment size. For TSO WQEs, the number of bytes
+ * in the TCP payload to be transmitted in each packet. Must
+ * be 0 on non TSO WQEs.
+ * inline_hdr_sz - Length of the inlined packet headers.
+ * inline_hdr_start - Inlined packet header.
+ */
+static MLX5DV_ALWAYS_INLINE
+void mlx5dv_set_eth_seg(struct mlx5_wqe_eth_seg *seg, uint8_t cs_flags,
+ uint16_t mss, uint16_t inline_hdr_sz,
+ uint8_t *inline_hdr_start)
+{
+ seg->cs_flags = cs_flags;
+ seg->mss = htobe16(mss);
+ seg->inline_hdr_sz = htobe16(inline_hdr_sz);
+ memcpy(seg->inline_hdr_start, inline_hdr_start, inline_hdr_sz);
+}
+#endif /* _MLX5DV_H_ */
diff --git a/contrib/ofed/libmlx5/mlx5dv_init_obj.3 b/contrib/ofed/libmlx5/mlx5dv_init_obj.3
new file mode 100644
index 0000000..2468407
--- /dev/null
+++ b/contrib/ofed/libmlx5/mlx5dv_init_obj.3
@@ -0,0 +1,130 @@
+.\" -*- nroff -*-
+.\" Licensed under the OpenIB.org (MIT) - See COPYING.md
+.\"
+.TH MLX5DV_INIT_OBJ 3 2017-02-02 1.0.0
+.SH "NAME"
+mlx5dv_init_obj \- Initialize mlx5 direct verbs object from ibv_xxx structures
+.SH "SYNOPSIS"
+.nf
+.B #include <infiniband/mlx5dv.h>
+.sp
+.BI "int mlx5dv_init_obj(struct mlx5dv_obj *obj, uint64_t obj_type);
+.fi
+.SH "DESCRIPTION"
+.B mlx5dv_init_obj()
+This function will initialize mlx5dv_xxx structs based on supplied type. The information
+for initialization is taken from ibv_xx structs supplied as part of input.
+
+Request information of CQ marks its owned by direct verbs for all consumer index
+related actions. The initialization type can be combination of several types together.
+.PP
+.nf
+struct mlx5dv_qp {
+.in +8
+uint32_t *dbrec;
+struct {
+.in +8
+void *buf;
+uint32_t wqe_cnt;
+uint32_t stride;
+.in -8
+} sq;
+struct {
+.in +8
+void *buf;
+uint32_t wqe_cnt;
+uint32_t stride;
+.in -8
+} rq;
+struct {
+.in +8
+void *reg;
+uint32_t size;
+.in -8
+} bf;
+uint64_t comp_mask;
+.in -8
+};
+
+struct mlx5dv_cq {
+.in +8
+void *buf;
+uint32_t *dbrec;
+uint32_t cqe_cnt;
+uint32_t cqe_size;
+void *uar;
+uint32_t cqn;
+uint64_t comp_mask;
+.in -8
+};
+
+struct mlx5dv_srq {
+.in +8
+void *buf;
+uint32_t *dbrec;
+uint32_t stride;
+uint32_t head;
+uint32_t tail;
+uint64_t comp_mask;
+.in -8
+};
+
+struct mlx5dv_rwq {
+.in +8
+void *buf;
+uint32_t *dbrec;
+uint32_t wqe_cnt;
+uint32_t stride;
+uint64_t comp_mask;
+.in -8
+};
+
+struct mlx5dv_obj {
+.in +8
+struct {
+.in +8
+struct ibv_qp *in;
+struct mlx5dv_qp *out;
+.in -8
+} qp;
+struct {
+.in +8
+struct ibv_cq *in;
+struct mlx5dv_cq *out;
+.in -8
+} cq;
+struct {
+.in +8
+struct ibv_srq *in;
+struct mlx5dv_srq *out;
+.in -8
+} srq;
+struct {
+.in +8
+struct ibv_wq *in;
+struct mlx5dv_rwq *out;
+.in -8
+} rwq;
+.in -8
+};
+
+enum mlx5dv_obj_type {
+.in +8
+MLX5DV_OBJ_QP = 1 << 0,
+MLX5DV_OBJ_CQ = 1 << 1,
+MLX5DV_OBJ_SRQ = 1 << 2,
+MLX5DV_OBJ_RWQ = 1 << 3,
+.in -8
+};
+.fi
+.SH "RETURN VALUE"
+0 on success or the value of errno on failure (which indicates the failure reason).
+.SH "NOTES"
+ * The information if doorbell is blueflame is based on mlx5dv_qp->bf->size,
+in case of 0 it's not a BF.
+ * Compatibility masks (comp_mask) are in/out fields.
+.SH "SEE ALSO"
+.BR mlx5dv (7)
+.SH "AUTHORS"
+.TP
+Leon Romanovsky <leonro@mellanox.com>
diff --git a/contrib/ofed/libmlx5/mlx5dv_query_device.3 b/contrib/ofed/libmlx5/mlx5dv_query_device.3
new file mode 100644
index 0000000..b33a75b4
--- /dev/null
+++ b/contrib/ofed/libmlx5/mlx5dv_query_device.3
@@ -0,0 +1,51 @@
+.\" -*- nroff -*-
+.\" Licensed under the OpenIB.org (MIT) - See COPYING.md
+.\"
+.TH MLX5DV_QUERY_DEVICE 3 2017-02-02 1.0.0
+.SH "NAME"
+mlx5dv_query_device \- Query device capabilities specific to mlx5
+.SH "SYNOPSIS"
+.nf
+.B #include <infiniband/mlx5dv.h>
+.sp
+.BI "int mlx5dv_query_device(struct ibv_context *ctx_in,
+.BI " struct mlx5dv_context *attrs_out);
+.fi
+.SH "DESCRIPTION"
+.B mlx5dv_query_device()
+Query HW device-specific information which is important for data-path, but isn't provided by
+\fBibv_query_device\fR(3).
+.PP
+This function returns version, flags and compatibility mask. The version represents the format
+of the internal hardware structures that mlx5dv.h represents. Additions of new fields to the existed
+structures are handled by comp_mask field.
+.PP
+.nf
+struct mlx5dv_context {
+.in +8
+uint8_t version;
+uint64_t flags;
+uint64_t comp_mask;
+.in -8
+};
+
+enum mlx5dv_context_flags {
+.in +8
+/*
+ * This flag indicates if CQE version 0 or 1 is needed.
+ */
+ MLX5DV_CONTEXT_FLAGS_CQE_V1 = (1 << 0),
+ MLX5DV_CONTEXT_FLAGS_MPW = (1 << 1), /* Multi packet WQE is supported or not */
+.in -8
+};
+.fi
+.SH "RETURN VALUE"
+0 on success or the value of errno on failure (which indicates the failure reason).
+.SH "NOTES"
+ * Compatibility mask (comp_mask) is in/out field.
+.SH "SEE ALSO"
+.BR mlx5dv (7),
+.BR ibv_query_device (3)
+.SH "AUTHORS"
+.TP
+Leon Romanovsky <leonro@mellanox.com>
diff --git a/contrib/ofed/libmlx5/qp.c b/contrib/ofed/libmlx5/qp.c
new file mode 100644
index 0000000..8c4ab95
--- /dev/null
+++ b/contrib/ofed/libmlx5/qp.c
@@ -0,0 +1,1262 @@
+/*
+ * Copyright (c) 2012 Mellanox Technologies, Inc. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#include <config.h>
+
+#include <stdlib.h>
+#include <pthread.h>
+#include <string.h>
+#include <errno.h>
+#include <stdio.h>
+
+#include "mlx5.h"
+#include "doorbell.h"
+#include "wqe.h"
+
+#define MLX5_ATOMIC_SIZE 8
+
+static const uint32_t mlx5_ib_opcode[] = {
+ [IBV_WR_SEND] = MLX5_OPCODE_SEND,
+ [IBV_WR_SEND_WITH_INV] = MLX5_OPCODE_SEND_INVAL,
+ [IBV_WR_SEND_WITH_IMM] = MLX5_OPCODE_SEND_IMM,
+ [IBV_WR_RDMA_WRITE] = MLX5_OPCODE_RDMA_WRITE,
+ [IBV_WR_RDMA_WRITE_WITH_IMM] = MLX5_OPCODE_RDMA_WRITE_IMM,
+ [IBV_WR_RDMA_READ] = MLX5_OPCODE_RDMA_READ,
+ [IBV_WR_ATOMIC_CMP_AND_SWP] = MLX5_OPCODE_ATOMIC_CS,
+ [IBV_WR_ATOMIC_FETCH_AND_ADD] = MLX5_OPCODE_ATOMIC_FA,
+ [IBV_WR_BIND_MW] = MLX5_OPCODE_UMR,
+ [IBV_WR_LOCAL_INV] = MLX5_OPCODE_UMR,
+ [IBV_WR_TSO] = MLX5_OPCODE_TSO,
+};
+
+static void *get_recv_wqe(struct mlx5_qp *qp, int n)
+{
+ return qp->buf.buf + qp->rq.offset + (n << qp->rq.wqe_shift);
+}
+
+static void *get_wq_recv_wqe(struct mlx5_rwq *rwq, int n)
+{
+ return rwq->pbuff + (n << rwq->rq.wqe_shift);
+}
+
+static int copy_to_scat(struct mlx5_wqe_data_seg *scat, void *buf, int *size,
+ int max)
+{
+ int copy;
+ int i;
+
+ if (unlikely(!(*size)))
+ return IBV_WC_SUCCESS;
+
+ for (i = 0; i < max; ++i) {
+ copy = min_t(long, *size, be32toh(scat->byte_count));
+ memcpy((void *)(unsigned long)be64toh(scat->addr), buf, copy);
+ *size -= copy;
+ if (*size == 0)
+ return IBV_WC_SUCCESS;
+
+ buf += copy;
+ ++scat;
+ }
+ return IBV_WC_LOC_LEN_ERR;
+}
+
+int mlx5_copy_to_recv_wqe(struct mlx5_qp *qp, int idx, void *buf, int size)
+{
+ struct mlx5_wqe_data_seg *scat;
+ int max = 1 << (qp->rq.wqe_shift - 4);
+
+ scat = get_recv_wqe(qp, idx);
+ if (unlikely(qp->wq_sig))
+ ++scat;
+
+ return copy_to_scat(scat, buf, &size, max);
+}
+
+int mlx5_copy_to_send_wqe(struct mlx5_qp *qp, int idx, void *buf, int size)
+{
+ struct mlx5_wqe_ctrl_seg *ctrl;
+ struct mlx5_wqe_data_seg *scat;
+ void *p;
+ int max;
+
+ idx &= (qp->sq.wqe_cnt - 1);
+ ctrl = mlx5_get_send_wqe(qp, idx);
+ if (qp->ibv_qp->qp_type != IBV_QPT_RC) {
+ fprintf(stderr, "scatter to CQE is supported only for RC QPs\n");
+ return IBV_WC_GENERAL_ERR;
+ }
+ p = ctrl + 1;
+
+ switch (be32toh(ctrl->opmod_idx_opcode) & 0xff) {
+ case MLX5_OPCODE_RDMA_READ:
+ p = p + sizeof(struct mlx5_wqe_raddr_seg);
+ break;
+
+ case MLX5_OPCODE_ATOMIC_CS:
+ case MLX5_OPCODE_ATOMIC_FA:
+ p = p + sizeof(struct mlx5_wqe_raddr_seg) +
+ sizeof(struct mlx5_wqe_atomic_seg);
+ break;
+
+ default:
+ fprintf(stderr, "scatter to CQE for opcode %d\n",
+ be32toh(ctrl->opmod_idx_opcode) & 0xff);
+ return IBV_WC_REM_INV_REQ_ERR;
+ }
+
+ scat = p;
+ max = (be32toh(ctrl->qpn_ds) & 0x3F) - (((void *)scat - (void *)ctrl) >> 4);
+ if (unlikely((void *)(scat + max) > qp->sq.qend)) {
+ int tmp = ((void *)qp->sq.qend - (void *)scat) >> 4;
+ int orig_size = size;
+
+ if (copy_to_scat(scat, buf, &size, tmp) == IBV_WC_SUCCESS)
+ return IBV_WC_SUCCESS;
+ max = max - tmp;
+ buf += orig_size - size;
+ scat = mlx5_get_send_wqe(qp, 0);
+ }
+
+ return copy_to_scat(scat, buf, &size, max);
+}
+
+void *mlx5_get_send_wqe(struct mlx5_qp *qp, int n)
+{
+ return qp->sq_start + (n << MLX5_SEND_WQE_SHIFT);
+}
+
+void mlx5_init_rwq_indices(struct mlx5_rwq *rwq)
+{
+ rwq->rq.head = 0;
+ rwq->rq.tail = 0;
+}
+
+void mlx5_init_qp_indices(struct mlx5_qp *qp)
+{
+ qp->sq.head = 0;
+ qp->sq.tail = 0;
+ qp->rq.head = 0;
+ qp->rq.tail = 0;
+ qp->sq.cur_post = 0;
+}
+
+static int mlx5_wq_overflow(struct mlx5_wq *wq, int nreq, struct mlx5_cq *cq)
+{
+ unsigned cur;
+
+ cur = wq->head - wq->tail;
+ if (cur + nreq < wq->max_post)
+ return 0;
+
+ mlx5_spin_lock(&cq->lock);
+ cur = wq->head - wq->tail;
+ mlx5_spin_unlock(&cq->lock);
+
+ return cur + nreq >= wq->max_post;
+}
+
+static inline void set_raddr_seg(struct mlx5_wqe_raddr_seg *rseg,
+ uint64_t remote_addr, uint32_t rkey)
+{
+ rseg->raddr = htobe64(remote_addr);
+ rseg->rkey = htobe32(rkey);
+ rseg->reserved = 0;
+}
+
+static void set_atomic_seg(struct mlx5_wqe_atomic_seg *aseg,
+ enum ibv_wr_opcode opcode,
+ uint64_t swap,
+ uint64_t compare_add)
+{
+ if (opcode == IBV_WR_ATOMIC_CMP_AND_SWP) {
+ aseg->swap_add = htobe64(swap);
+ aseg->compare = htobe64(compare_add);
+ } else {
+ aseg->swap_add = htobe64(compare_add);
+ }
+}
+
+static void set_datagram_seg(struct mlx5_wqe_datagram_seg *dseg,
+ struct ibv_send_wr *wr)
+{
+ memcpy(&dseg->av, &to_mah(wr->wr.ud.ah)->av, sizeof dseg->av);
+ dseg->av.dqp_dct = htobe32(wr->wr.ud.remote_qpn | MLX5_EXTENDED_UD_AV);
+ dseg->av.key.qkey.qkey = htobe32(wr->wr.ud.remote_qkey);
+}
+
+static void set_data_ptr_seg(struct mlx5_wqe_data_seg *dseg, struct ibv_sge *sg,
+ int offset)
+{
+ dseg->byte_count = htobe32(sg->length - offset);
+ dseg->lkey = htobe32(sg->lkey);
+ dseg->addr = htobe64(sg->addr + offset);
+}
+
+static void set_data_ptr_seg_atomic(struct mlx5_wqe_data_seg *dseg,
+ struct ibv_sge *sg)
+{
+ dseg->byte_count = htobe32(MLX5_ATOMIC_SIZE);
+ dseg->lkey = htobe32(sg->lkey);
+ dseg->addr = htobe64(sg->addr);
+}
+
+/*
+ * Avoid using memcpy() to copy to BlueFlame page, since memcpy()
+ * implementations may use move-string-buffer assembler instructions,
+ * which do not guarantee order of copying.
+ */
+static void mlx5_bf_copy(unsigned long long *dst, unsigned long long *src,
+ unsigned bytecnt, struct mlx5_qp *qp)
+{
+ while (bytecnt > 0) {
+ *dst++ = *src++;
+ *dst++ = *src++;
+ *dst++ = *src++;
+ *dst++ = *src++;
+ *dst++ = *src++;
+ *dst++ = *src++;
+ *dst++ = *src++;
+ *dst++ = *src++;
+ bytecnt -= 8 * sizeof(unsigned long long);
+ if (unlikely(src == qp->sq.qend))
+ src = qp->sq_start;
+ }
+}
+
+static uint32_t send_ieth(struct ibv_send_wr *wr)
+{
+ switch (wr->opcode) {
+ case IBV_WR_SEND_WITH_IMM:
+ case IBV_WR_RDMA_WRITE_WITH_IMM:
+ return wr->imm_data;
+ case IBV_WR_SEND_WITH_INV:
+ return htobe32(wr->imm_data);
+ default:
+ return 0;
+ }
+}
+
+static int set_data_inl_seg(struct mlx5_qp *qp, struct ibv_send_wr *wr,
+ void *wqe, int *sz,
+ struct mlx5_sg_copy_ptr *sg_copy_ptr)
+{
+ struct mlx5_wqe_inline_seg *seg;
+ void *addr;
+ int len;
+ int i;
+ int inl = 0;
+ void *qend = qp->sq.qend;
+ int copy;
+ int offset = sg_copy_ptr->offset;
+
+ seg = wqe;
+ wqe += sizeof *seg;
+ for (i = sg_copy_ptr->index; i < wr->num_sge; ++i) {
+ addr = (void *) (unsigned long)(wr->sg_list[i].addr + offset);
+ len = wr->sg_list[i].length - offset;
+ inl += len;
+ offset = 0;
+
+ if (unlikely(inl > qp->max_inline_data))
+ return ENOMEM;
+
+ if (unlikely(wqe + len > qend)) {
+ copy = qend - wqe;
+ memcpy(wqe, addr, copy);
+ addr += copy;
+ len -= copy;
+ wqe = mlx5_get_send_wqe(qp, 0);
+ }
+ memcpy(wqe, addr, len);
+ wqe += len;
+ }
+
+ if (likely(inl)) {
+ seg->byte_count = htobe32(inl | MLX5_INLINE_SEG);
+ *sz = align(inl + sizeof seg->byte_count, 16) / 16;
+ } else
+ *sz = 0;
+
+ return 0;
+}
+
+static uint8_t wq_sig(struct mlx5_wqe_ctrl_seg *ctrl)
+{
+ return calc_sig(ctrl, be32toh(ctrl->qpn_ds));
+}
+
+#ifdef MLX5_DEBUG
+static void dump_wqe(FILE *fp, int idx, int size_16, struct mlx5_qp *qp)
+{
+ uint32_t *p = NULL;
+ int i, j;
+ int tidx = idx;
+
+ fprintf(fp, "dump wqe at %p\n", mlx5_get_send_wqe(qp, tidx));
+ for (i = 0, j = 0; i < size_16 * 4; i += 4, j += 4) {
+ if ((i & 0xf) == 0) {
+ void *buf = mlx5_get_send_wqe(qp, tidx);
+ tidx = (tidx + 1) & (qp->sq.wqe_cnt - 1);
+ p = buf;
+ j = 0;
+ }
+ fprintf(fp, "%08x %08x %08x %08x\n", be32toh(p[j]), be32toh(p[j + 1]),
+ be32toh(p[j + 2]), be32toh(p[j + 3]));
+ }
+}
+#endif /* MLX5_DEBUG */
+
+
+void *mlx5_get_atomic_laddr(struct mlx5_qp *qp, uint16_t idx, int *byte_count)
+{
+ struct mlx5_wqe_data_seg *dpseg;
+ void *addr;
+
+ dpseg = mlx5_get_send_wqe(qp, idx) + sizeof(struct mlx5_wqe_ctrl_seg) +
+ sizeof(struct mlx5_wqe_raddr_seg) +
+ sizeof(struct mlx5_wqe_atomic_seg);
+ addr = (void *)(unsigned long)be64toh(dpseg->addr);
+
+ /*
+ * Currently byte count is always 8 bytes. Fix this when
+ * we support variable size of atomics
+ */
+ *byte_count = 8;
+ return addr;
+}
+
+static inline int copy_eth_inline_headers(struct ibv_qp *ibqp,
+ struct ibv_send_wr *wr,
+ struct mlx5_wqe_eth_seg *eseg,
+ struct mlx5_sg_copy_ptr *sg_copy_ptr)
+{
+ uint32_t inl_hdr_size = MLX5_ETH_L2_INLINE_HEADER_SIZE;
+ int inl_hdr_copy_size = 0;
+ int j = 0;
+ FILE *fp = to_mctx(ibqp->context)->dbg_fp;
+
+ if (unlikely(wr->num_sge < 1)) {
+ mlx5_dbg(fp, MLX5_DBG_QP_SEND, "illegal num_sge: %d, minimum is 1\n",
+ wr->num_sge);
+ return EINVAL;
+ }
+
+ if (likely(wr->sg_list[0].length >= MLX5_ETH_L2_INLINE_HEADER_SIZE)) {
+ inl_hdr_copy_size = MLX5_ETH_L2_INLINE_HEADER_SIZE;
+ memcpy(eseg->inline_hdr_start,
+ (void *)(uintptr_t)wr->sg_list[0].addr,
+ inl_hdr_copy_size);
+ } else {
+ for (j = 0; j < wr->num_sge && inl_hdr_size > 0; ++j) {
+ inl_hdr_copy_size = min(wr->sg_list[j].length,
+ inl_hdr_size);
+ memcpy(eseg->inline_hdr_start +
+ (MLX5_ETH_L2_INLINE_HEADER_SIZE - inl_hdr_size),
+ (void *)(uintptr_t)wr->sg_list[j].addr,
+ inl_hdr_copy_size);
+ inl_hdr_size -= inl_hdr_copy_size;
+ }
+ if (unlikely(inl_hdr_size)) {
+ mlx5_dbg(fp, MLX5_DBG_QP_SEND, "Ethernet headers < 16 bytes\n");
+ return EINVAL;
+ }
+ --j;
+ }
+
+
+ eseg->inline_hdr_sz = htobe16(MLX5_ETH_L2_INLINE_HEADER_SIZE);
+
+ /* If we copied all the sge into the inline-headers, then we need to
+ * start copying from the next sge into the data-segment.
+ */
+ if (unlikely(wr->sg_list[j].length == inl_hdr_copy_size)) {
+ ++j;
+ inl_hdr_copy_size = 0;
+ }
+
+ sg_copy_ptr->index = j;
+ sg_copy_ptr->offset = inl_hdr_copy_size;
+
+ return 0;
+}
+
+#undef ALIGN
+#define ALIGN(x, log_a) ((((x) + (1 << (log_a)) - 1)) & ~((1 << (log_a)) - 1))
+
+static inline uint16_t get_klm_octo(int nentries)
+{
+ return htobe16(ALIGN(nentries, 3) / 2);
+}
+
+static void set_umr_data_seg(struct mlx5_qp *qp, enum ibv_mw_type type,
+ int32_t rkey, struct ibv_mw_bind_info *bind_info,
+ uint32_t qpn, void **seg, int *size)
+{
+ union {
+ struct mlx5_wqe_umr_klm_seg klm;
+ uint8_t reserved[64];
+ } *data = *seg;
+
+ data->klm.byte_count = htobe32(bind_info->length);
+ data->klm.mkey = htobe32(bind_info->mr->lkey);
+ data->klm.address = htobe64(bind_info->addr);
+
+ memset(&data->klm + 1, 0, sizeof(data->reserved) -
+ sizeof(data->klm));
+
+ *seg += sizeof(*data);
+ *size += (sizeof(*data) / 16);
+}
+
+static void set_umr_mkey_seg(struct mlx5_qp *qp, enum ibv_mw_type type,
+ int32_t rkey, struct ibv_mw_bind_info *bind_info,
+ uint32_t qpn, void **seg, int *size)
+{
+ struct mlx5_wqe_mkey_context_seg *mkey = *seg;
+
+ mkey->qpn_mkey = htobe32((rkey & 0xFF) |
+ ((type == IBV_MW_TYPE_1 || !bind_info->length) ?
+ 0xFFFFFF00 : qpn << 8));
+ if (bind_info->length) {
+ /* Local read is set in kernel */
+ mkey->access_flags = 0;
+ mkey->free = 0;
+ if (bind_info->mw_access_flags & IBV_ACCESS_LOCAL_WRITE)
+ mkey->access_flags |=
+ MLX5_WQE_MKEY_CONTEXT_ACCESS_FLAGS_LOCAL_WRITE;
+ if (bind_info->mw_access_flags & IBV_ACCESS_REMOTE_WRITE)
+ mkey->access_flags |=
+ MLX5_WQE_MKEY_CONTEXT_ACCESS_FLAGS_REMOTE_WRITE;
+ if (bind_info->mw_access_flags & IBV_ACCESS_REMOTE_READ)
+ mkey->access_flags |=
+ MLX5_WQE_MKEY_CONTEXT_ACCESS_FLAGS_REMOTE_READ;
+ if (bind_info->mw_access_flags & IBV_ACCESS_REMOTE_ATOMIC)
+ mkey->access_flags |=
+ MLX5_WQE_MKEY_CONTEXT_ACCESS_FLAGS_ATOMIC;
+ if (bind_info->mw_access_flags & IBV_ACCESS_ZERO_BASED)
+ mkey->start_addr = 0;
+ else
+ mkey->start_addr = htobe64(bind_info->addr);
+ mkey->len = htobe64(bind_info->length);
+ } else {
+ mkey->free = MLX5_WQE_MKEY_CONTEXT_FREE;
+ }
+
+ *seg += sizeof(struct mlx5_wqe_mkey_context_seg);
+ *size += (sizeof(struct mlx5_wqe_mkey_context_seg) / 16);
+}
+
+static inline void set_umr_control_seg(struct mlx5_qp *qp, enum ibv_mw_type type,
+ int32_t rkey, struct ibv_mw_bind_info *bind_info,
+ uint32_t qpn, void **seg, int *size)
+{
+ struct mlx5_wqe_umr_ctrl_seg *ctrl = *seg;
+
+ ctrl->flags = MLX5_WQE_UMR_CTRL_FLAG_TRNSLATION_OFFSET |
+ MLX5_WQE_UMR_CTRL_FLAG_INLINE;
+ ctrl->mkey_mask = htobe64(MLX5_WQE_UMR_CTRL_MKEY_MASK_FREE |
+ MLX5_WQE_UMR_CTRL_MKEY_MASK_MKEY);
+ ctrl->translation_offset = 0;
+ memset(ctrl->rsvd0, 0, sizeof(ctrl->rsvd0));
+ memset(ctrl->rsvd1, 0, sizeof(ctrl->rsvd1));
+
+ if (type == IBV_MW_TYPE_2)
+ ctrl->mkey_mask |= htobe64(MLX5_WQE_UMR_CTRL_MKEY_MASK_QPN);
+
+ if (bind_info->length) {
+ ctrl->klm_octowords = get_klm_octo(1);
+ if (type == IBV_MW_TYPE_2)
+ ctrl->flags |= MLX5_WQE_UMR_CTRL_FLAG_CHECK_FREE;
+ ctrl->mkey_mask |= htobe64(MLX5_WQE_UMR_CTRL_MKEY_MASK_LEN |
+ MLX5_WQE_UMR_CTRL_MKEY_MASK_START_ADDR |
+ MLX5_WQE_UMR_CTRL_MKEY_MASK_ACCESS_LOCAL_WRITE |
+ MLX5_WQE_UMR_CTRL_MKEY_MASK_ACCESS_REMOTE_READ |
+ MLX5_WQE_UMR_CTRL_MKEY_MASK_ACCESS_REMOTE_WRITE |
+ MLX5_WQE_UMR_CTRL_MKEY_MASK_ACCESS_ATOMIC);
+ } else {
+ ctrl->klm_octowords = get_klm_octo(0);
+ if (type == IBV_MW_TYPE_2)
+ ctrl->flags |= MLX5_WQE_UMR_CTRL_FLAG_CHECK_QPN;
+ }
+
+ *seg += sizeof(struct mlx5_wqe_umr_ctrl_seg);
+ *size += sizeof(struct mlx5_wqe_umr_ctrl_seg) / 16;
+}
+
+static inline int set_bind_wr(struct mlx5_qp *qp, enum ibv_mw_type type,
+ int32_t rkey, struct ibv_mw_bind_info *bind_info,
+ uint32_t qpn, void **seg, int *size)
+{
+ void *qend = qp->sq.qend;
+
+#ifdef MW_DEBUG
+ if (bind_info->mw_access_flags &
+ ~(IBV_ACCESS_REMOTE_ATOMIC | IBV_ACCESS_REMOTE_READ |
+ IBV_ACCESS_REMOTE_WRITE))
+ return EINVAL;
+
+ if (bind_info->mr &&
+ (bind_info->mr->addr > (void *)bind_info->addr ||
+ bind_info->mr->addr + bind_info->mr->length <
+ (void *)bind_info->addr + bind_info->length ||
+ !(to_mmr(bind_info->mr)->alloc_flags & IBV_ACCESS_MW_BIND) ||
+ (bind_info->mw_access_flags &
+ (IBV_ACCESS_REMOTE_ATOMIC | IBV_ACCESS_REMOTE_WRITE) &&
+ !(to_mmr(bind_info->mr)->alloc_flags & IBV_ACCESS_LOCAL_WRITE))))
+ return EINVAL;
+
+#endif
+
+ /* check that len > 2GB because KLM support only 2GB */
+ if (bind_info->length > 1UL << 31)
+ return EOPNOTSUPP;
+
+ set_umr_control_seg(qp, type, rkey, bind_info, qpn, seg, size);
+ if (unlikely((*seg == qend)))
+ *seg = mlx5_get_send_wqe(qp, 0);
+
+ set_umr_mkey_seg(qp, type, rkey, bind_info, qpn, seg, size);
+ if (!bind_info->length)
+ return 0;
+
+ if (unlikely((seg == qend)))
+ *seg = mlx5_get_send_wqe(qp, 0);
+
+ set_umr_data_seg(qp, type, rkey, bind_info, qpn, seg, size);
+ return 0;
+}
+
+/* Copy tso header to eth segment with considering padding and WQE
+ * wrap around in WQ buffer.
+ */
+static inline int set_tso_eth_seg(void **seg, struct ibv_send_wr *wr,
+ void *qend, struct mlx5_qp *qp, int *size)
+{
+ struct mlx5_wqe_eth_seg *eseg = *seg;
+ int size_of_inl_hdr_start = sizeof(eseg->inline_hdr_start);
+ uint64_t left, left_len, copy_sz;
+ void *pdata = wr->tso.hdr;
+ FILE *fp = to_mctx(qp->ibv_qp->context)->dbg_fp;
+
+ if (unlikely(wr->tso.hdr_sz < MLX5_ETH_L2_MIN_HEADER_SIZE ||
+ wr->tso.hdr_sz > qp->max_tso_header)) {
+ mlx5_dbg(fp, MLX5_DBG_QP_SEND,
+ "TSO header size should be at least %d and at most %d\n",
+ MLX5_ETH_L2_MIN_HEADER_SIZE,
+ qp->max_tso_header);
+ return EINVAL;
+ }
+
+ left = wr->tso.hdr_sz;
+ eseg->mss = htobe16(wr->tso.mss);
+ eseg->inline_hdr_sz = htobe16(wr->tso.hdr_sz);
+
+ /* Check if there is space till the end of queue, if yes,
+ * copy all in one shot, otherwise copy till the end of queue,
+ * rollback and then copy the left
+ */
+ left_len = qend - (void *)eseg->inline_hdr_start;
+ copy_sz = min(left_len, left);
+
+ memcpy(eseg->inline_hdr_start, pdata, copy_sz);
+
+ /* The -1 is because there are already 16 bytes included in
+ * eseg->inline_hdr[16]
+ */
+ *seg += align(copy_sz - size_of_inl_hdr_start, 16) - 16;
+ *size += align(copy_sz - size_of_inl_hdr_start, 16) / 16 - 1;
+
+ /* The last wqe in the queue */
+ if (unlikely(copy_sz < left)) {
+ *seg = mlx5_get_send_wqe(qp, 0);
+ left -= copy_sz;
+ pdata += copy_sz;
+ memcpy(*seg, pdata, left);
+ *seg += align(left, 16);
+ *size += align(left, 16) / 16;
+ }
+
+ return 0;
+}
+
+static inline int _mlx5_post_send(struct ibv_qp *ibqp, struct ibv_send_wr *wr,
+ struct ibv_send_wr **bad_wr)
+{
+ struct mlx5_context *ctx;
+ struct mlx5_qp *qp = to_mqp(ibqp);
+ void *seg;
+ struct mlx5_wqe_eth_seg *eseg;
+ struct mlx5_wqe_ctrl_seg *ctrl = NULL;
+ struct mlx5_wqe_data_seg *dpseg;
+ struct mlx5_sg_copy_ptr sg_copy_ptr = {.index = 0, .offset = 0};
+ int nreq;
+ int inl = 0;
+ int err = 0;
+ int size = 0;
+ int i;
+ unsigned idx;
+ uint8_t opmod = 0;
+ struct mlx5_bf *bf = qp->bf;
+ void *qend = qp->sq.qend;
+ uint32_t mlx5_opcode;
+ struct mlx5_wqe_xrc_seg *xrc;
+ uint8_t fence;
+ uint8_t next_fence;
+ uint32_t max_tso = 0;
+ FILE *fp = to_mctx(ibqp->context)->dbg_fp; /* The compiler ignores in non-debug mode */
+
+ mlx5_spin_lock(&qp->sq.lock);
+
+ next_fence = qp->fm_cache;
+
+ for (nreq = 0; wr; ++nreq, wr = wr->next) {
+ if (unlikely(wr->opcode < 0 ||
+ wr->opcode >= sizeof mlx5_ib_opcode / sizeof mlx5_ib_opcode[0])) {
+ mlx5_dbg(fp, MLX5_DBG_QP_SEND, "bad opcode %d\n", wr->opcode);
+ err = EINVAL;
+ *bad_wr = wr;
+ goto out;
+ }
+
+ if (unlikely(mlx5_wq_overflow(&qp->sq, nreq,
+ to_mcq(qp->ibv_qp->send_cq)))) {
+ mlx5_dbg(fp, MLX5_DBG_QP_SEND, "work queue overflow\n");
+ err = ENOMEM;
+ *bad_wr = wr;
+ goto out;
+ }
+
+ if (unlikely(wr->num_sge > qp->sq.max_gs)) {
+ mlx5_dbg(fp, MLX5_DBG_QP_SEND, "max gs exceeded %d (max = %d)\n",
+ wr->num_sge, qp->sq.max_gs);
+ err = ENOMEM;
+ *bad_wr = wr;
+ goto out;
+ }
+
+ if (wr->send_flags & IBV_SEND_FENCE)
+ fence = MLX5_WQE_CTRL_FENCE;
+ else
+ fence = next_fence;
+ next_fence = 0;
+ idx = qp->sq.cur_post & (qp->sq.wqe_cnt - 1);
+ ctrl = seg = mlx5_get_send_wqe(qp, idx);
+ *(uint32_t *)(seg + 8) = 0;
+ ctrl->imm = send_ieth(wr);
+ ctrl->fm_ce_se = qp->sq_signal_bits | fence |
+ (wr->send_flags & IBV_SEND_SIGNALED ?
+ MLX5_WQE_CTRL_CQ_UPDATE : 0) |
+ (wr->send_flags & IBV_SEND_SOLICITED ?
+ MLX5_WQE_CTRL_SOLICITED : 0);
+
+ seg += sizeof *ctrl;
+ size = sizeof *ctrl / 16;
+
+ switch (ibqp->qp_type) {
+ case IBV_QPT_XRC_SEND:
+ if (unlikely(wr->opcode != IBV_WR_BIND_MW &&
+ wr->opcode != IBV_WR_LOCAL_INV)) {
+ xrc = seg;
+ xrc->xrc_srqn = htobe32(wr->qp_type.xrc.remote_srqn);
+ seg += sizeof(*xrc);
+ size += sizeof(*xrc) / 16;
+ }
+ /* fall through */
+ case IBV_QPT_RC:
+ switch (wr->opcode) {
+ case IBV_WR_RDMA_READ:
+ case IBV_WR_RDMA_WRITE:
+ case IBV_WR_RDMA_WRITE_WITH_IMM:
+ set_raddr_seg(seg, wr->wr.rdma.remote_addr,
+ wr->wr.rdma.rkey);
+ seg += sizeof(struct mlx5_wqe_raddr_seg);
+ size += sizeof(struct mlx5_wqe_raddr_seg) / 16;
+ break;
+
+ case IBV_WR_ATOMIC_CMP_AND_SWP:
+ case IBV_WR_ATOMIC_FETCH_AND_ADD:
+ if (unlikely(!qp->atomics_enabled)) {
+ mlx5_dbg(fp, MLX5_DBG_QP_SEND, "atomic operations are not supported\n");
+ err = ENOSYS;
+ *bad_wr = wr;
+ goto out;
+ }
+ set_raddr_seg(seg, wr->wr.atomic.remote_addr,
+ wr->wr.atomic.rkey);
+ seg += sizeof(struct mlx5_wqe_raddr_seg);
+
+ set_atomic_seg(seg, wr->opcode,
+ wr->wr.atomic.swap,
+ wr->wr.atomic.compare_add);
+ seg += sizeof(struct mlx5_wqe_atomic_seg);
+
+ size += (sizeof(struct mlx5_wqe_raddr_seg) +
+ sizeof(struct mlx5_wqe_atomic_seg)) / 16;
+ break;
+
+ case IBV_WR_BIND_MW:
+ next_fence = MLX5_WQE_CTRL_INITIATOR_SMALL_FENCE;
+ ctrl->imm = htobe32(wr->bind_mw.mw->rkey);
+ err = set_bind_wr(qp, wr->bind_mw.mw->type,
+ wr->bind_mw.rkey,
+ &wr->bind_mw.bind_info,
+ ibqp->qp_num, &seg, &size);
+ if (err) {
+ *bad_wr = wr;
+ goto out;
+ }
+
+ qp->sq.wr_data[idx] = IBV_WC_BIND_MW;
+ break;
+ case IBV_WR_LOCAL_INV: {
+ struct ibv_mw_bind_info bind_info = {};
+
+ next_fence = MLX5_WQE_CTRL_INITIATOR_SMALL_FENCE;
+ ctrl->imm = htobe32(wr->imm_data);
+ err = set_bind_wr(qp, IBV_MW_TYPE_2, 0,
+ &bind_info, ibqp->qp_num,
+ &seg, &size);
+ if (err) {
+ *bad_wr = wr;
+ goto out;
+ }
+
+ qp->sq.wr_data[idx] = IBV_WC_LOCAL_INV;
+ break;
+ }
+
+ default:
+ break;
+ }
+ break;
+
+ case IBV_QPT_UC:
+ switch (wr->opcode) {
+ case IBV_WR_RDMA_WRITE:
+ case IBV_WR_RDMA_WRITE_WITH_IMM:
+ set_raddr_seg(seg, wr->wr.rdma.remote_addr,
+ wr->wr.rdma.rkey);
+ seg += sizeof(struct mlx5_wqe_raddr_seg);
+ size += sizeof(struct mlx5_wqe_raddr_seg) / 16;
+ break;
+ case IBV_WR_BIND_MW:
+ next_fence = MLX5_WQE_CTRL_INITIATOR_SMALL_FENCE;
+ ctrl->imm = htobe32(wr->bind_mw.mw->rkey);
+ err = set_bind_wr(qp, wr->bind_mw.mw->type,
+ wr->bind_mw.rkey,
+ &wr->bind_mw.bind_info,
+ ibqp->qp_num, &seg, &size);
+ if (err) {
+ *bad_wr = wr;
+ goto out;
+ }
+
+ qp->sq.wr_data[idx] = IBV_WC_BIND_MW;
+ break;
+ case IBV_WR_LOCAL_INV: {
+ struct ibv_mw_bind_info bind_info = {};
+
+ next_fence = MLX5_WQE_CTRL_INITIATOR_SMALL_FENCE;
+ ctrl->imm = htobe32(wr->imm_data);
+ err = set_bind_wr(qp, IBV_MW_TYPE_2, 0,
+ &bind_info, ibqp->qp_num,
+ &seg, &size);
+ if (err) {
+ *bad_wr = wr;
+ goto out;
+ }
+
+ qp->sq.wr_data[idx] = IBV_WC_LOCAL_INV;
+ break;
+ }
+
+ default:
+ break;
+ }
+ break;
+
+ case IBV_QPT_UD:
+ set_datagram_seg(seg, wr);
+ seg += sizeof(struct mlx5_wqe_datagram_seg);
+ size += sizeof(struct mlx5_wqe_datagram_seg) / 16;
+ if (unlikely((seg == qend)))
+ seg = mlx5_get_send_wqe(qp, 0);
+ break;
+
+ case IBV_QPT_RAW_PACKET:
+ memset(seg, 0, sizeof(struct mlx5_wqe_eth_seg));
+ eseg = seg;
+
+ if (wr->send_flags & IBV_SEND_IP_CSUM) {
+ if (!(qp->qp_cap_cache & MLX5_CSUM_SUPPORT_RAW_OVER_ETH)) {
+ err = EINVAL;
+ *bad_wr = wr;
+ goto out;
+ }
+
+ eseg->cs_flags |= MLX5_ETH_WQE_L3_CSUM | MLX5_ETH_WQE_L4_CSUM;
+ }
+
+ if (wr->opcode == IBV_WR_TSO) {
+ max_tso = qp->max_tso;
+ err = set_tso_eth_seg(&seg, wr, qend, qp, &size);
+ if (unlikely(err)) {
+ *bad_wr = wr;
+ goto out;
+ }
+ } else {
+ err = copy_eth_inline_headers(ibqp, wr, seg, &sg_copy_ptr);
+ if (unlikely(err)) {
+ *bad_wr = wr;
+ mlx5_dbg(fp, MLX5_DBG_QP_SEND,
+ "copy_eth_inline_headers failed, err: %d\n",
+ err);
+ goto out;
+ }
+ }
+
+ seg += sizeof(struct mlx5_wqe_eth_seg);
+ size += sizeof(struct mlx5_wqe_eth_seg) / 16;
+ break;
+
+ default:
+ break;
+ }
+
+ if (wr->send_flags & IBV_SEND_INLINE && wr->num_sge) {
+ int sz = 0;
+
+ err = set_data_inl_seg(qp, wr, seg, &sz, &sg_copy_ptr);
+ if (unlikely(err)) {
+ *bad_wr = wr;
+ mlx5_dbg(fp, MLX5_DBG_QP_SEND,
+ "inline layout failed, err %d\n", err);
+ goto out;
+ }
+ inl = 1;
+ size += sz;
+ } else {
+ dpseg = seg;
+ for (i = sg_copy_ptr.index; i < wr->num_sge; ++i) {
+ if (unlikely(dpseg == qend)) {
+ seg = mlx5_get_send_wqe(qp, 0);
+ dpseg = seg;
+ }
+ if (likely(wr->sg_list[i].length)) {
+ if (unlikely(wr->opcode ==
+ IBV_WR_ATOMIC_CMP_AND_SWP ||
+ wr->opcode ==
+ IBV_WR_ATOMIC_FETCH_AND_ADD))
+ set_data_ptr_seg_atomic(dpseg, wr->sg_list + i);
+ else {
+ if (unlikely(wr->opcode == IBV_WR_TSO)) {
+ if (max_tso < wr->sg_list[i].length) {
+ err = EINVAL;
+ *bad_wr = wr;
+ goto out;
+ }
+ max_tso -= wr->sg_list[i].length;
+ }
+ set_data_ptr_seg(dpseg, wr->sg_list + i,
+ sg_copy_ptr.offset);
+ }
+ sg_copy_ptr.offset = 0;
+ ++dpseg;
+ size += sizeof(struct mlx5_wqe_data_seg) / 16;
+ }
+ }
+ }
+
+ mlx5_opcode = mlx5_ib_opcode[wr->opcode];
+ ctrl->opmod_idx_opcode = htobe32(((qp->sq.cur_post & 0xffff) << 8) |
+ mlx5_opcode |
+ (opmod << 24));
+ ctrl->qpn_ds = htobe32(size | (ibqp->qp_num << 8));
+
+ if (unlikely(qp->wq_sig))
+ ctrl->signature = wq_sig(ctrl);
+
+ qp->sq.wrid[idx] = wr->wr_id;
+ qp->sq.wqe_head[idx] = qp->sq.head + nreq;
+ qp->sq.cur_post += DIV_ROUND_UP(size * 16, MLX5_SEND_WQE_BB);
+
+#ifdef MLX5_DEBUG
+ if (mlx5_debug_mask & MLX5_DBG_QP_SEND)
+ dump_wqe(to_mctx(ibqp->context)->dbg_fp, idx, size, qp);
+#endif
+ }
+
+out:
+ if (likely(nreq)) {
+ qp->sq.head += nreq;
+ qp->fm_cache = next_fence;
+
+ /*
+ * Make sure that descriptors are written before
+ * updating doorbell record and ringing the doorbell
+ */
+ udma_to_device_barrier();
+ qp->db[MLX5_SND_DBR] = htobe32(qp->sq.cur_post & 0xffff);
+
+ /* Make sure that the doorbell write happens before the memcpy
+ * to WC memory below */
+ ctx = to_mctx(ibqp->context);
+ if (bf->need_lock)
+ mmio_wc_spinlock(&bf->lock.lock);
+ else
+ mmio_wc_start();
+
+ if (!ctx->shut_up_bf && nreq == 1 && bf->uuarn &&
+ (inl || ctx->prefer_bf) && size > 1 &&
+ size <= bf->buf_size / 16)
+ mlx5_bf_copy(bf->reg + bf->offset, (unsigned long long *)ctrl,
+ align(size * 16, 64), qp);
+ else
+ mlx5_write64((__be32 *)ctrl, bf->reg + bf->offset,
+ &ctx->lock32);
+
+ /*
+ * use mmio_flush_writes() to ensure write combining buffers are flushed out
+ * of the running CPU. This must be carried inside the spinlock.
+ * Otherwise, there is a potential race. In the race, CPU A
+ * writes doorbell 1, which is waiting in the WC buffer. CPU B
+ * writes doorbell 2, and it's write is flushed earlier. Since
+ * the mmio_flush_writes is CPU local, this will result in the HCA seeing
+ * doorbell 2, followed by doorbell 1.
+ * Flush before toggling bf_offset to be latency oriented.
+ */
+ mmio_flush_writes();
+ bf->offset ^= bf->buf_size;
+ if (bf->need_lock)
+ mlx5_spin_unlock(&bf->lock);
+ }
+
+ mlx5_spin_unlock(&qp->sq.lock);
+
+ return err;
+}
+
+int mlx5_post_send(struct ibv_qp *ibqp, struct ibv_send_wr *wr,
+ struct ibv_send_wr **bad_wr)
+{
+#ifdef MW_DEBUG
+ if (wr->opcode == IBV_WR_BIND_MW) {
+ if (wr->bind_mw.mw->type == IBV_MW_TYPE_1)
+ return EINVAL;
+
+ if (!wr->bind_mw.bind_info.mr ||
+ !wr->bind_mw.bind_info.addr ||
+ !wr->bind_mw.bind_info.length)
+ return EINVAL;
+
+ if (wr->bind_mw.bind_info.mr->pd != wr->bind_mw.mw->pd)
+ return EINVAL;
+ }
+#endif
+
+ return _mlx5_post_send(ibqp, wr, bad_wr);
+}
+
+int mlx5_bind_mw(struct ibv_qp *qp, struct ibv_mw *mw,
+ struct ibv_mw_bind *mw_bind)
+{
+ struct ibv_mw_bind_info *bind_info = &mw_bind->bind_info;
+ struct ibv_send_wr wr = {};
+ struct ibv_send_wr *bad_wr = NULL;
+ int ret;
+
+ if (!bind_info->mr && (bind_info->addr || bind_info->length)) {
+ errno = EINVAL;
+ return errno;
+ }
+
+ if (bind_info->mw_access_flags & IBV_ACCESS_ZERO_BASED) {
+ errno = EINVAL;
+ return errno;
+ }
+
+ if (bind_info->mr) {
+ if (to_mmr(bind_info->mr)->alloc_flags & IBV_ACCESS_ZERO_BASED) {
+ errno = EINVAL;
+ return errno;
+ }
+
+ if (mw->pd != bind_info->mr->pd) {
+ errno = EPERM;
+ return errno;
+ }
+ }
+
+ wr.opcode = IBV_WR_BIND_MW;
+ wr.next = NULL;
+ wr.wr_id = mw_bind->wr_id;
+ wr.send_flags = mw_bind->send_flags;
+ wr.bind_mw.bind_info = mw_bind->bind_info;
+ wr.bind_mw.mw = mw;
+ wr.bind_mw.rkey = ibv_inc_rkey(mw->rkey);
+
+ ret = _mlx5_post_send(qp, &wr, &bad_wr);
+ if (ret)
+ return ret;
+
+ mw->rkey = wr.bind_mw.rkey;
+
+ return 0;
+}
+
+static void set_sig_seg(struct mlx5_qp *qp, struct mlx5_rwqe_sig *sig,
+ int size, uint16_t idx)
+{
+ uint8_t sign;
+ uint32_t qpn = qp->ibv_qp->qp_num;
+
+ sign = calc_sig(sig, size);
+ sign ^= calc_sig(&qpn, 4);
+ sign ^= calc_sig(&idx, 2);
+ sig->signature = sign;
+}
+
+static void set_wq_sig_seg(struct mlx5_rwq *rwq, struct mlx5_rwqe_sig *sig,
+ int size, uint16_t idx)
+{
+ uint8_t sign;
+ uint32_t qpn = rwq->wq.wq_num;
+
+ sign = calc_sig(sig, size);
+ sign ^= calc_sig(&qpn, 4);
+ sign ^= calc_sig(&idx, 2);
+ sig->signature = sign;
+}
+
+int mlx5_post_wq_recv(struct ibv_wq *ibwq, struct ibv_recv_wr *wr,
+ struct ibv_recv_wr **bad_wr)
+{
+ struct mlx5_rwq *rwq = to_mrwq(ibwq);
+ struct mlx5_wqe_data_seg *scat;
+ int err = 0;
+ int nreq;
+ int ind;
+ int i, j;
+ struct mlx5_rwqe_sig *sig;
+
+ mlx5_spin_lock(&rwq->rq.lock);
+
+ ind = rwq->rq.head & (rwq->rq.wqe_cnt - 1);
+
+ for (nreq = 0; wr; ++nreq, wr = wr->next) {
+ if (unlikely(mlx5_wq_overflow(&rwq->rq, nreq,
+ to_mcq(rwq->wq.cq)))) {
+ err = ENOMEM;
+ *bad_wr = wr;
+ goto out;
+ }
+
+ if (unlikely(wr->num_sge > rwq->rq.max_gs)) {
+ err = EINVAL;
+ *bad_wr = wr;
+ goto out;
+ }
+
+ scat = get_wq_recv_wqe(rwq, ind);
+ sig = (struct mlx5_rwqe_sig *)scat;
+ if (unlikely(rwq->wq_sig)) {
+ memset(sig, 0, 1 << rwq->rq.wqe_shift);
+ ++scat;
+ }
+
+ for (i = 0, j = 0; i < wr->num_sge; ++i) {
+ if (unlikely(!wr->sg_list[i].length))
+ continue;
+ set_data_ptr_seg(scat + j++, wr->sg_list + i, 0);
+ }
+
+ if (j < rwq->rq.max_gs) {
+ scat[j].byte_count = 0;
+ scat[j].lkey = htobe32(MLX5_INVALID_LKEY);
+ scat[j].addr = 0;
+ }
+
+ if (unlikely(rwq->wq_sig))
+ set_wq_sig_seg(rwq, sig, (wr->num_sge + 1) << 4,
+ rwq->rq.head & 0xffff);
+
+ rwq->rq.wrid[ind] = wr->wr_id;
+
+ ind = (ind + 1) & (rwq->rq.wqe_cnt - 1);
+ }
+
+out:
+ if (likely(nreq)) {
+ rwq->rq.head += nreq;
+ /*
+ * Make sure that descriptors are written before
+ * doorbell record.
+ */
+ udma_to_device_barrier();
+ *(rwq->recv_db) = htobe32(rwq->rq.head & 0xffff);
+ }
+
+ mlx5_spin_unlock(&rwq->rq.lock);
+
+ return err;
+}
+
+int mlx5_post_recv(struct ibv_qp *ibqp, struct ibv_recv_wr *wr,
+ struct ibv_recv_wr **bad_wr)
+{
+ struct mlx5_qp *qp = to_mqp(ibqp);
+ struct mlx5_wqe_data_seg *scat;
+ int err = 0;
+ int nreq;
+ int ind;
+ int i, j;
+ struct mlx5_rwqe_sig *sig;
+
+ mlx5_spin_lock(&qp->rq.lock);
+
+ ind = qp->rq.head & (qp->rq.wqe_cnt - 1);
+
+ for (nreq = 0; wr; ++nreq, wr = wr->next) {
+ if (unlikely(mlx5_wq_overflow(&qp->rq, nreq,
+ to_mcq(qp->ibv_qp->recv_cq)))) {
+ err = ENOMEM;
+ *bad_wr = wr;
+ goto out;
+ }
+
+ if (unlikely(wr->num_sge > qp->rq.max_gs)) {
+ err = EINVAL;
+ *bad_wr = wr;
+ goto out;
+ }
+
+ scat = get_recv_wqe(qp, ind);
+ sig = (struct mlx5_rwqe_sig *)scat;
+ if (unlikely(qp->wq_sig)) {
+ memset(sig, 0, 1 << qp->rq.wqe_shift);
+ ++scat;
+ }
+
+ for (i = 0, j = 0; i < wr->num_sge; ++i) {
+ if (unlikely(!wr->sg_list[i].length))
+ continue;
+ set_data_ptr_seg(scat + j++, wr->sg_list + i, 0);
+ }
+
+ if (j < qp->rq.max_gs) {
+ scat[j].byte_count = 0;
+ scat[j].lkey = htobe32(MLX5_INVALID_LKEY);
+ scat[j].addr = 0;
+ }
+
+ if (unlikely(qp->wq_sig))
+ set_sig_seg(qp, sig, (wr->num_sge + 1) << 4,
+ qp->rq.head & 0xffff);
+
+ qp->rq.wrid[ind] = wr->wr_id;
+
+ ind = (ind + 1) & (qp->rq.wqe_cnt - 1);
+ }
+
+out:
+ if (likely(nreq)) {
+ qp->rq.head += nreq;
+
+ /*
+ * Make sure that descriptors are written before
+ * doorbell record.
+ */
+ udma_to_device_barrier();
+
+ /*
+ * For Raw Packet QP, avoid updating the doorbell record
+ * as long as the QP isn't in RTR state, to avoid receiving
+ * packets in illegal states.
+ * This is only for Raw Packet QPs since they are represented
+ * differently in the hardware.
+ */
+ if (likely(!(ibqp->qp_type == IBV_QPT_RAW_PACKET &&
+ ibqp->state < IBV_QPS_RTR)))
+ qp->db[MLX5_RCV_DBR] = htobe32(qp->rq.head & 0xffff);
+ }
+
+ mlx5_spin_unlock(&qp->rq.lock);
+
+ return err;
+}
+
+int mlx5_use_huge(const char *key)
+{
+ char *e;
+ e = getenv(key);
+ if (e && !strcmp(e, "y"))
+ return 1;
+
+ return 0;
+}
+
+struct mlx5_qp *mlx5_find_qp(struct mlx5_context *ctx, uint32_t qpn)
+{
+ int tind = qpn >> MLX5_QP_TABLE_SHIFT;
+
+ if (ctx->qp_table[tind].refcnt)
+ return ctx->qp_table[tind].table[qpn & MLX5_QP_TABLE_MASK];
+ else
+ return NULL;
+}
+
+int mlx5_store_qp(struct mlx5_context *ctx, uint32_t qpn, struct mlx5_qp *qp)
+{
+ int tind = qpn >> MLX5_QP_TABLE_SHIFT;
+
+ if (!ctx->qp_table[tind].refcnt) {
+ ctx->qp_table[tind].table = calloc(MLX5_QP_TABLE_MASK + 1,
+ sizeof(struct mlx5_qp *));
+ if (!ctx->qp_table[tind].table)
+ return -1;
+ }
+
+ ++ctx->qp_table[tind].refcnt;
+ ctx->qp_table[tind].table[qpn & MLX5_QP_TABLE_MASK] = qp;
+ return 0;
+}
+
+void mlx5_clear_qp(struct mlx5_context *ctx, uint32_t qpn)
+{
+ int tind = qpn >> MLX5_QP_TABLE_SHIFT;
+
+ if (!--ctx->qp_table[tind].refcnt)
+ free(ctx->qp_table[tind].table);
+ else
+ ctx->qp_table[tind].table[qpn & MLX5_QP_TABLE_MASK] = NULL;
+}
diff --git a/contrib/ofed/libmlx5/srq.c b/contrib/ofed/libmlx5/srq.c
new file mode 100644
index 0000000..202fa87
--- /dev/null
+++ b/contrib/ofed/libmlx5/srq.c
@@ -0,0 +1,244 @@
+/*
+ * Copyright (c) 2012 Mellanox Technologies, Inc. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#include <config.h>
+
+#include <stdlib.h>
+#include <pthread.h>
+#include <string.h>
+#include <errno.h>
+
+#include "mlx5.h"
+#include "doorbell.h"
+#include "wqe.h"
+
+static void *get_wqe(struct mlx5_srq *srq, int n)
+{
+ return srq->buf.buf + (n << srq->wqe_shift);
+}
+
+int mlx5_copy_to_recv_srq(struct mlx5_srq *srq, int idx, void *buf, int size)
+{
+ struct mlx5_wqe_srq_next_seg *next;
+ struct mlx5_wqe_data_seg *scat;
+ int copy;
+ int i;
+ int max = 1 << (srq->wqe_shift - 4);
+
+ next = get_wqe(srq, idx);
+ scat = (struct mlx5_wqe_data_seg *) (next + 1);
+
+ for (i = 0; i < max; ++i) {
+ copy = min_t(long, size, be32toh(scat->byte_count));
+ memcpy((void *)(unsigned long)be64toh(scat->addr), buf, copy);
+ size -= copy;
+ if (size <= 0)
+ return IBV_WC_SUCCESS;
+
+ buf += copy;
+ ++scat;
+ }
+ return IBV_WC_LOC_LEN_ERR;
+}
+
+void mlx5_free_srq_wqe(struct mlx5_srq *srq, int ind)
+{
+ struct mlx5_wqe_srq_next_seg *next;
+
+ mlx5_spin_lock(&srq->lock);
+
+ next = get_wqe(srq, srq->tail);
+ next->next_wqe_index = htobe16(ind);
+ srq->tail = ind;
+
+ mlx5_spin_unlock(&srq->lock);
+}
+
+int mlx5_post_srq_recv(struct ibv_srq *ibsrq,
+ struct ibv_recv_wr *wr,
+ struct ibv_recv_wr **bad_wr)
+{
+ struct mlx5_srq *srq = to_msrq(ibsrq);
+ struct mlx5_wqe_srq_next_seg *next;
+ struct mlx5_wqe_data_seg *scat;
+ int err = 0;
+ int nreq;
+ int i;
+
+ mlx5_spin_lock(&srq->lock);
+
+ for (nreq = 0; wr; ++nreq, wr = wr->next) {
+ if (wr->num_sge > srq->max_gs) {
+ err = EINVAL;
+ *bad_wr = wr;
+ break;
+ }
+
+ if (srq->head == srq->tail) {
+ /* SRQ is full*/
+ err = ENOMEM;
+ *bad_wr = wr;
+ break;
+ }
+
+ srq->wrid[srq->head] = wr->wr_id;
+
+ next = get_wqe(srq, srq->head);
+ srq->head = be16toh(next->next_wqe_index);
+ scat = (struct mlx5_wqe_data_seg *) (next + 1);
+
+ for (i = 0; i < wr->num_sge; ++i) {
+ scat[i].byte_count = htobe32(wr->sg_list[i].length);
+ scat[i].lkey = htobe32(wr->sg_list[i].lkey);
+ scat[i].addr = htobe64(wr->sg_list[i].addr);
+ }
+
+ if (i < srq->max_gs) {
+ scat[i].byte_count = 0;
+ scat[i].lkey = htobe32(MLX5_INVALID_LKEY);
+ scat[i].addr = 0;
+ }
+ }
+
+ if (nreq) {
+ srq->counter += nreq;
+
+ /*
+ * Make sure that descriptors are written before
+ * we write doorbell record.
+ */
+ udma_to_device_barrier();
+
+ *srq->db = htobe32(srq->counter);
+ }
+
+ mlx5_spin_unlock(&srq->lock);
+
+ return err;
+}
+
+int mlx5_alloc_srq_buf(struct ibv_context *context, struct mlx5_srq *srq)
+{
+ struct mlx5_wqe_srq_next_seg *next;
+ int size;
+ int buf_size;
+ int i;
+ struct mlx5_context *ctx;
+
+ ctx = to_mctx(context);
+
+ if (srq->max_gs < 0) {
+ errno = EINVAL;
+ return -1;
+ }
+
+ srq->wrid = malloc(srq->max * sizeof *srq->wrid);
+ if (!srq->wrid)
+ return -1;
+
+ size = sizeof(struct mlx5_wqe_srq_next_seg) +
+ srq->max_gs * sizeof(struct mlx5_wqe_data_seg);
+ size = max(32, size);
+
+ size = mlx5_round_up_power_of_two(size);
+
+ if (size > ctx->max_recv_wr) {
+ errno = EINVAL;
+ return -1;
+ }
+ srq->max_gs = (size - sizeof(struct mlx5_wqe_srq_next_seg)) /
+ sizeof(struct mlx5_wqe_data_seg);
+
+ srq->wqe_shift = mlx5_ilog2(size);
+
+ buf_size = srq->max * size;
+
+ if (mlx5_alloc_buf(&srq->buf, buf_size,
+ to_mdev(context->device)->page_size)) {
+ free(srq->wrid);
+ return -1;
+ }
+
+ memset(srq->buf.buf, 0, buf_size);
+
+ /*
+ * Now initialize the SRQ buffer so that all of the WQEs are
+ * linked into the list of free WQEs.
+ */
+
+ for (i = 0; i < srq->max; ++i) {
+ next = get_wqe(srq, i);
+ next->next_wqe_index = htobe16((i + 1) & (srq->max - 1));
+ }
+
+ srq->head = 0;
+ srq->tail = srq->max - 1;
+
+ return 0;
+}
+
+struct mlx5_srq *mlx5_find_srq(struct mlx5_context *ctx, uint32_t srqn)
+{
+ int tind = srqn >> MLX5_SRQ_TABLE_SHIFT;
+
+ if (ctx->srq_table[tind].refcnt)
+ return ctx->srq_table[tind].table[srqn & MLX5_SRQ_TABLE_MASK];
+ else
+ return NULL;
+}
+
+int mlx5_store_srq(struct mlx5_context *ctx, uint32_t srqn,
+ struct mlx5_srq *srq)
+{
+ int tind = srqn >> MLX5_SRQ_TABLE_SHIFT;
+
+ if (!ctx->srq_table[tind].refcnt) {
+ ctx->srq_table[tind].table = calloc(MLX5_QP_TABLE_MASK + 1,
+ sizeof(struct mlx5_qp *));
+ if (!ctx->srq_table[tind].table)
+ return -1;
+ }
+
+ ++ctx->srq_table[tind].refcnt;
+ ctx->srq_table[tind].table[srqn & MLX5_QP_TABLE_MASK] = srq;
+ return 0;
+}
+
+void mlx5_clear_srq(struct mlx5_context *ctx, uint32_t srqn)
+{
+ int tind = srqn >> MLX5_QP_TABLE_SHIFT;
+
+ if (!--ctx->srq_table[tind].refcnt)
+ free(ctx->srq_table[tind].table);
+ else
+ ctx->srq_table[tind].table[srqn & MLX5_SRQ_TABLE_MASK] = NULL;
+}
diff --git a/contrib/ofed/libmlx5/verbs.c b/contrib/ofed/libmlx5/verbs.c
new file mode 100644
index 0000000..2e2f74f
--- /dev/null
+++ b/contrib/ofed/libmlx5/verbs.c
@@ -0,0 +1,2212 @@
+/*
+ * Copyright (c) 2012 Mellanox Technologies, Inc. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#include <config.h>
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <pthread.h>
+#include <errno.h>
+#include <limits.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <sys/mman.h>
+
+#include "mlx5.h"
+#include "mlx5-abi.h"
+#include "wqe.h"
+
+int mlx5_single_threaded = 0;
+
+static inline int is_xrc_tgt(int type)
+{
+ return type == IBV_QPT_XRC_RECV;
+}
+
+int mlx5_query_device(struct ibv_context *context, struct ibv_device_attr *attr)
+{
+ struct ibv_query_device cmd;
+ uint64_t raw_fw_ver;
+ unsigned major, minor, sub_minor;
+ int ret;
+
+ ret = ibv_cmd_query_device(context, attr, &raw_fw_ver, &cmd, sizeof cmd);
+ if (ret)
+ return ret;
+
+ major = (raw_fw_ver >> 32) & 0xffff;
+ minor = (raw_fw_ver >> 16) & 0xffff;
+ sub_minor = raw_fw_ver & 0xffff;
+
+ snprintf(attr->fw_ver, sizeof attr->fw_ver,
+ "%d.%d.%04d", major, minor, sub_minor);
+
+ return 0;
+}
+
+#define READL(ptr) (*((uint32_t *)(ptr)))
+static int mlx5_read_clock(struct ibv_context *context, uint64_t *cycles)
+{
+ unsigned int clockhi, clocklo, clockhi1;
+ int i;
+ struct mlx5_context *ctx = to_mctx(context);
+
+ if (!ctx->hca_core_clock)
+ return -EOPNOTSUPP;
+
+ /* Handle wraparound */
+ for (i = 0; i < 2; i++) {
+ clockhi = be32toh(READL(ctx->hca_core_clock));
+ clocklo = be32toh(READL(ctx->hca_core_clock + 4));
+ clockhi1 = be32toh(READL(ctx->hca_core_clock));
+ if (clockhi == clockhi1)
+ break;
+ }
+
+ *cycles = (uint64_t)clockhi << 32 | (uint64_t)clocklo;
+
+ return 0;
+}
+
+int mlx5_query_rt_values(struct ibv_context *context,
+ struct ibv_values_ex *values)
+{
+ uint32_t comp_mask = 0;
+ int err = 0;
+
+ if (values->comp_mask & IBV_VALUES_MASK_RAW_CLOCK) {
+ uint64_t cycles;
+
+ err = mlx5_read_clock(context, &cycles);
+ if (!err) {
+ values->raw_clock.tv_sec = 0;
+ values->raw_clock.tv_nsec = cycles;
+ comp_mask |= IBV_VALUES_MASK_RAW_CLOCK;
+ }
+ }
+
+ values->comp_mask = comp_mask;
+
+ return err;
+}
+
+int mlx5_query_port(struct ibv_context *context, uint8_t port,
+ struct ibv_port_attr *attr)
+{
+ struct ibv_query_port cmd;
+
+ return ibv_cmd_query_port(context, port, attr, &cmd, sizeof cmd);
+}
+
+struct ibv_pd *mlx5_alloc_pd(struct ibv_context *context)
+{
+ struct ibv_alloc_pd cmd;
+ struct mlx5_alloc_pd_resp resp;
+ struct mlx5_pd *pd;
+
+ pd = calloc(1, sizeof *pd);
+ if (!pd)
+ return NULL;
+
+ if (ibv_cmd_alloc_pd(context, &pd->ibv_pd, &cmd, sizeof cmd,
+ &resp.ibv_resp, sizeof resp)) {
+ free(pd);
+ return NULL;
+ }
+
+ pd->pdn = resp.pdn;
+
+ return &pd->ibv_pd;
+}
+
+int mlx5_free_pd(struct ibv_pd *pd)
+{
+ int ret;
+
+ ret = ibv_cmd_dealloc_pd(pd);
+ if (ret)
+ return ret;
+
+ free(to_mpd(pd));
+ return 0;
+}
+
+struct ibv_mr *mlx5_reg_mr(struct ibv_pd *pd, void *addr, size_t length,
+ int acc)
+{
+ struct mlx5_mr *mr;
+ struct ibv_reg_mr cmd;
+ int ret;
+ enum ibv_access_flags access = (enum ibv_access_flags)acc;
+ struct ibv_reg_mr_resp resp;
+
+ mr = calloc(1, sizeof(*mr));
+ if (!mr)
+ return NULL;
+
+ ret = ibv_cmd_reg_mr(pd, addr, length, (uintptr_t)addr, access,
+ &(mr->ibv_mr), &cmd, sizeof(cmd), &resp,
+ sizeof resp);
+ if (ret) {
+ mlx5_free_buf(&(mr->buf));
+ free(mr);
+ return NULL;
+ }
+ mr->alloc_flags = acc;
+
+ return &mr->ibv_mr;
+}
+
+int mlx5_rereg_mr(struct ibv_mr *ibmr, int flags, struct ibv_pd *pd, void *addr,
+ size_t length, int access)
+{
+ struct ibv_rereg_mr cmd;
+ struct ibv_rereg_mr_resp resp;
+
+ if (flags & IBV_REREG_MR_KEEP_VALID)
+ return ENOTSUP;
+
+ return ibv_cmd_rereg_mr(ibmr, flags, addr, length, (uintptr_t)addr,
+ access, pd, &cmd, sizeof(cmd), &resp,
+ sizeof(resp));
+}
+
+int mlx5_dereg_mr(struct ibv_mr *ibmr)
+{
+ int ret;
+ struct mlx5_mr *mr = to_mmr(ibmr);
+
+ ret = ibv_cmd_dereg_mr(ibmr);
+ if (ret)
+ return ret;
+
+ free(mr);
+ return 0;
+}
+
+struct ibv_mw *mlx5_alloc_mw(struct ibv_pd *pd, enum ibv_mw_type type)
+{
+ struct ibv_mw *mw;
+ struct ibv_alloc_mw cmd;
+ struct ibv_alloc_mw_resp resp;
+ int ret;
+
+ mw = malloc(sizeof(*mw));
+ if (!mw)
+ return NULL;
+
+ memset(mw, 0, sizeof(*mw));
+
+ ret = ibv_cmd_alloc_mw(pd, type, mw, &cmd, sizeof(cmd), &resp,
+ sizeof(resp));
+ if (ret) {
+ free(mw);
+ return NULL;
+ }
+
+ return mw;
+}
+
+int mlx5_dealloc_mw(struct ibv_mw *mw)
+{
+ int ret;
+ struct ibv_dealloc_mw cmd;
+
+ ret = ibv_cmd_dealloc_mw(mw, &cmd, sizeof(cmd));
+ if (ret)
+ return ret;
+
+ free(mw);
+ return 0;
+}
+
+int mlx5_round_up_power_of_two(long long sz)
+{
+ long long ret;
+
+ for (ret = 1; ret < sz; ret <<= 1)
+ ; /* nothing */
+
+ if (ret > INT_MAX) {
+ fprintf(stderr, "%s: roundup overflow\n", __func__);
+ return -ENOMEM;
+ }
+
+ return (int)ret;
+}
+
+static int align_queue_size(long long req)
+{
+ return mlx5_round_up_power_of_two(req);
+}
+
+static int get_cqe_size(void)
+{
+ char *env;
+ int size = 64;
+
+ env = getenv("MLX5_CQE_SIZE");
+ if (env)
+ size = atoi(env);
+
+ switch (size) {
+ case 64:
+ case 128:
+ return size;
+
+ default:
+ return -EINVAL;
+ }
+}
+
+static int use_scatter_to_cqe(void)
+{
+ char *env;
+
+ env = getenv("MLX5_SCATTER_TO_CQE");
+ if (env && !strcmp(env, "0"))
+ return 0;
+
+ return 1;
+}
+
+static int srq_sig_enabled(void)
+{
+ char *env;
+
+ env = getenv("MLX5_SRQ_SIGNATURE");
+ if (env)
+ return 1;
+
+ return 0;
+}
+
+static int qp_sig_enabled(void)
+{
+ char *env;
+
+ env = getenv("MLX5_QP_SIGNATURE");
+ if (env)
+ return 1;
+
+ return 0;
+}
+
+enum {
+ CREATE_CQ_SUPPORTED_WC_FLAGS = IBV_WC_STANDARD_FLAGS |
+ IBV_WC_EX_WITH_COMPLETION_TIMESTAMP |
+ IBV_WC_EX_WITH_CVLAN |
+ IBV_WC_EX_WITH_FLOW_TAG
+};
+
+enum {
+ CREATE_CQ_SUPPORTED_COMP_MASK = IBV_CQ_INIT_ATTR_MASK_FLAGS
+};
+
+enum {
+ CREATE_CQ_SUPPORTED_FLAGS = IBV_CREATE_CQ_ATTR_SINGLE_THREADED
+};
+
+static struct ibv_cq_ex *create_cq(struct ibv_context *context,
+ const struct ibv_cq_init_attr_ex *cq_attr,
+ int cq_alloc_flags,
+ struct mlx5dv_cq_init_attr *mlx5cq_attr)
+{
+ struct mlx5_create_cq cmd;
+ struct mlx5_create_cq_resp resp;
+ struct mlx5_cq *cq;
+ int cqe_sz;
+ int ret;
+ int ncqe;
+ struct mlx5_context *mctx = to_mctx(context);
+ FILE *fp = to_mctx(context)->dbg_fp;
+
+ if (!cq_attr->cqe) {
+ mlx5_dbg(fp, MLX5_DBG_CQ, "CQE invalid\n");
+ errno = EINVAL;
+ return NULL;
+ }
+
+ if (cq_attr->comp_mask & ~CREATE_CQ_SUPPORTED_COMP_MASK) {
+ mlx5_dbg(fp, MLX5_DBG_CQ,
+ "Unsupported comp_mask for create_cq\n");
+ errno = EINVAL;
+ return NULL;
+ }
+
+ if (cq_attr->comp_mask & IBV_CQ_INIT_ATTR_MASK_FLAGS &&
+ cq_attr->flags & ~CREATE_CQ_SUPPORTED_FLAGS) {
+ mlx5_dbg(fp, MLX5_DBG_CQ,
+ "Unsupported creation flags requested for create_cq\n");
+ errno = EINVAL;
+ return NULL;
+ }
+
+ if (cq_attr->wc_flags & ~CREATE_CQ_SUPPORTED_WC_FLAGS) {
+ mlx5_dbg(fp, MLX5_DBG_CQ, "\n");
+ errno = ENOTSUP;
+ return NULL;
+ }
+
+ cq = calloc(1, sizeof *cq);
+ if (!cq) {
+ mlx5_dbg(fp, MLX5_DBG_CQ, "\n");
+ return NULL;
+ }
+
+ memset(&cmd, 0, sizeof cmd);
+ cq->cons_index = 0;
+
+ if (mlx5_spinlock_init(&cq->lock))
+ goto err;
+
+ ncqe = align_queue_size(cq_attr->cqe + 1);
+ if ((ncqe > (1 << 24)) || (ncqe < (cq_attr->cqe + 1))) {
+ mlx5_dbg(fp, MLX5_DBG_CQ, "ncqe %d\n", ncqe);
+ errno = EINVAL;
+ goto err_spl;
+ }
+
+ cqe_sz = get_cqe_size();
+ if (cqe_sz < 0) {
+ mlx5_dbg(fp, MLX5_DBG_CQ, "\n");
+ errno = -cqe_sz;
+ goto err_spl;
+ }
+
+ if (mlx5_alloc_cq_buf(to_mctx(context), cq, &cq->buf_a, ncqe, cqe_sz)) {
+ mlx5_dbg(fp, MLX5_DBG_CQ, "\n");
+ goto err_spl;
+ }
+
+ cq->dbrec = mlx5_alloc_dbrec(to_mctx(context));
+ if (!cq->dbrec) {
+ mlx5_dbg(fp, MLX5_DBG_CQ, "\n");
+ goto err_buf;
+ }
+
+ cq->dbrec[MLX5_CQ_SET_CI] = 0;
+ cq->dbrec[MLX5_CQ_ARM_DB] = 0;
+ cq->arm_sn = 0;
+ cq->cqe_sz = cqe_sz;
+ cq->flags = cq_alloc_flags;
+
+ if (cq_attr->comp_mask & IBV_CQ_INIT_ATTR_MASK_FLAGS &&
+ cq_attr->flags & IBV_CREATE_CQ_ATTR_SINGLE_THREADED)
+ cq->flags |= MLX5_CQ_FLAGS_SINGLE_THREADED;
+ cmd.buf_addr = (uintptr_t) cq->buf_a.buf;
+ cmd.db_addr = (uintptr_t) cq->dbrec;
+ cmd.cqe_size = cqe_sz;
+
+ if (mlx5cq_attr) {
+ if (mlx5cq_attr->comp_mask & ~(MLX5DV_CQ_INIT_ATTR_MASK_RESERVED - 1)) {
+ mlx5_dbg(fp, MLX5_DBG_CQ,
+ "Unsupported vendor comp_mask for create_cq\n");
+ errno = EINVAL;
+ goto err_db;
+ }
+
+ if (mlx5cq_attr->comp_mask & MLX5DV_CQ_INIT_ATTR_MASK_COMPRESSED_CQE) {
+ if (mctx->cqe_comp_caps.max_num &&
+ (mlx5cq_attr->cqe_comp_res_format &
+ mctx->cqe_comp_caps.supported_format)) {
+ cmd.cqe_comp_en = 1;
+ cmd.cqe_comp_res_format = mlx5cq_attr->cqe_comp_res_format;
+ } else {
+ mlx5_dbg(fp, MLX5_DBG_CQ, "CQE Compression is not supported\n");
+ errno = EINVAL;
+ goto err_db;
+ }
+ }
+ }
+
+ ret = ibv_cmd_create_cq(context, ncqe - 1, cq_attr->channel,
+ cq_attr->comp_vector,
+ ibv_cq_ex_to_cq(&cq->ibv_cq), &cmd.ibv_cmd,
+ sizeof(cmd), &resp.ibv_resp, sizeof(resp));
+ if (ret) {
+ mlx5_dbg(fp, MLX5_DBG_CQ, "ret %d\n", ret);
+ goto err_db;
+ }
+
+ cq->active_buf = &cq->buf_a;
+ cq->resize_buf = NULL;
+ cq->cqn = resp.cqn;
+ cq->stall_enable = to_mctx(context)->stall_enable;
+ cq->stall_adaptive_enable = to_mctx(context)->stall_adaptive_enable;
+ cq->stall_cycles = to_mctx(context)->stall_cycles;
+
+ if (cq_alloc_flags & MLX5_CQ_FLAGS_EXTENDED)
+ mlx5_cq_fill_pfns(cq, cq_attr);
+
+ return &cq->ibv_cq;
+
+err_db:
+ mlx5_free_db(to_mctx(context), cq->dbrec);
+
+err_buf:
+ mlx5_free_cq_buf(to_mctx(context), &cq->buf_a);
+
+err_spl:
+ mlx5_spinlock_destroy(&cq->lock);
+
+err:
+ free(cq);
+
+ return NULL;
+}
+
+struct ibv_cq *mlx5_create_cq(struct ibv_context *context, int cqe,
+ struct ibv_comp_channel *channel,
+ int comp_vector)
+{
+ struct ibv_cq_ex *cq;
+ struct ibv_cq_init_attr_ex cq_attr = {.cqe = cqe, .channel = channel,
+ .comp_vector = comp_vector,
+ .wc_flags = IBV_WC_STANDARD_FLAGS};
+
+ if (cqe <= 0) {
+ errno = EINVAL;
+ return NULL;
+ }
+
+ cq = create_cq(context, &cq_attr, 0, NULL);
+ return cq ? ibv_cq_ex_to_cq(cq) : NULL;
+}
+
+struct ibv_cq_ex *mlx5_create_cq_ex(struct ibv_context *context,
+ struct ibv_cq_init_attr_ex *cq_attr)
+{
+ return create_cq(context, cq_attr, MLX5_CQ_FLAGS_EXTENDED, NULL);
+}
+
+struct ibv_cq_ex *mlx5dv_create_cq(struct ibv_context *context,
+ struct ibv_cq_init_attr_ex *cq_attr,
+ struct mlx5dv_cq_init_attr *mlx5_cq_attr)
+{
+ struct ibv_cq_ex *cq;
+
+ cq = create_cq(context, cq_attr, MLX5_CQ_FLAGS_EXTENDED, mlx5_cq_attr);
+ if (!cq)
+ return NULL;
+
+ verbs_init_cq(ibv_cq_ex_to_cq(cq), context,
+ cq_attr->channel, cq_attr->cq_context);
+ return cq;
+}
+
+int mlx5_resize_cq(struct ibv_cq *ibcq, int cqe)
+{
+ struct mlx5_cq *cq = to_mcq(ibcq);
+ struct mlx5_resize_cq_resp resp;
+ struct mlx5_resize_cq cmd;
+ struct mlx5_context *mctx = to_mctx(ibcq->context);
+ int err;
+
+ if (cqe < 0) {
+ errno = EINVAL;
+ return errno;
+ }
+
+ memset(&cmd, 0, sizeof(cmd));
+ memset(&resp, 0, sizeof(resp));
+
+ if (((long long)cqe * 64) > INT_MAX)
+ return EINVAL;
+
+ mlx5_spin_lock(&cq->lock);
+ cq->active_cqes = cq->ibv_cq.cqe;
+ if (cq->active_buf == &cq->buf_a)
+ cq->resize_buf = &cq->buf_b;
+ else
+ cq->resize_buf = &cq->buf_a;
+
+ cqe = align_queue_size(cqe + 1);
+ if (cqe == ibcq->cqe + 1) {
+ cq->resize_buf = NULL;
+ err = 0;
+ goto out;
+ }
+
+ /* currently we don't change cqe size */
+ cq->resize_cqe_sz = cq->cqe_sz;
+ cq->resize_cqes = cqe;
+ err = mlx5_alloc_cq_buf(mctx, cq, cq->resize_buf, cq->resize_cqes, cq->resize_cqe_sz);
+ if (err) {
+ cq->resize_buf = NULL;
+ errno = ENOMEM;
+ goto out;
+ }
+
+ cmd.buf_addr = (uintptr_t)cq->resize_buf->buf;
+ cmd.cqe_size = cq->resize_cqe_sz;
+
+ err = ibv_cmd_resize_cq(ibcq, cqe - 1, &cmd.ibv_cmd, sizeof(cmd),
+ &resp.ibv_resp, sizeof(resp));
+ if (err)
+ goto out_buf;
+
+ mlx5_cq_resize_copy_cqes(cq);
+ mlx5_free_cq_buf(mctx, cq->active_buf);
+ cq->active_buf = cq->resize_buf;
+ cq->ibv_cq.cqe = cqe - 1;
+ mlx5_spin_unlock(&cq->lock);
+ cq->resize_buf = NULL;
+ return 0;
+
+out_buf:
+ mlx5_free_cq_buf(mctx, cq->resize_buf);
+ cq->resize_buf = NULL;
+
+out:
+ mlx5_spin_unlock(&cq->lock);
+ return err;
+}
+
+int mlx5_destroy_cq(struct ibv_cq *cq)
+{
+ int ret;
+
+ ret = ibv_cmd_destroy_cq(cq);
+ if (ret)
+ return ret;
+
+ mlx5_free_db(to_mctx(cq->context), to_mcq(cq)->dbrec);
+ mlx5_free_cq_buf(to_mctx(cq->context), to_mcq(cq)->active_buf);
+ free(to_mcq(cq));
+
+ return 0;
+}
+
+struct ibv_srq *mlx5_create_srq(struct ibv_pd *pd,
+ struct ibv_srq_init_attr *attr)
+{
+ struct mlx5_create_srq cmd;
+ struct mlx5_create_srq_resp resp;
+ struct mlx5_srq *srq;
+ int ret;
+ struct mlx5_context *ctx;
+ int max_sge;
+ struct ibv_srq *ibsrq;
+
+ ctx = to_mctx(pd->context);
+ srq = calloc(1, sizeof *srq);
+ if (!srq) {
+ fprintf(stderr, "%s-%d:\n", __func__, __LINE__);
+ return NULL;
+ }
+ ibsrq = &srq->vsrq.srq;
+
+ memset(&cmd, 0, sizeof cmd);
+ if (mlx5_spinlock_init(&srq->lock)) {
+ fprintf(stderr, "%s-%d:\n", __func__, __LINE__);
+ goto err;
+ }
+
+ if (attr->attr.max_wr > ctx->max_srq_recv_wr) {
+ fprintf(stderr, "%s-%d:max_wr %d, max_srq_recv_wr %d\n", __func__, __LINE__,
+ attr->attr.max_wr, ctx->max_srq_recv_wr);
+ errno = EINVAL;
+ goto err;
+ }
+
+ /*
+ * this calculation does not consider required control segments. The
+ * final calculation is done again later. This is done so to avoid
+ * overflows of variables
+ */
+ max_sge = ctx->max_rq_desc_sz / sizeof(struct mlx5_wqe_data_seg);
+ if (attr->attr.max_sge > max_sge) {
+ fprintf(stderr, "%s-%d:max_wr %d, max_srq_recv_wr %d\n", __func__, __LINE__,
+ attr->attr.max_wr, ctx->max_srq_recv_wr);
+ errno = EINVAL;
+ goto err;
+ }
+
+ srq->max = align_queue_size(attr->attr.max_wr + 1);
+ srq->max_gs = attr->attr.max_sge;
+ srq->counter = 0;
+
+ if (mlx5_alloc_srq_buf(pd->context, srq)) {
+ fprintf(stderr, "%s-%d:\n", __func__, __LINE__);
+ goto err;
+ }
+
+ srq->db = mlx5_alloc_dbrec(to_mctx(pd->context));
+ if (!srq->db) {
+ fprintf(stderr, "%s-%d:\n", __func__, __LINE__);
+ goto err_free;
+ }
+
+ *srq->db = 0;
+
+ cmd.buf_addr = (uintptr_t) srq->buf.buf;
+ cmd.db_addr = (uintptr_t) srq->db;
+ srq->wq_sig = srq_sig_enabled();
+ if (srq->wq_sig)
+ cmd.flags = MLX5_SRQ_FLAG_SIGNATURE;
+
+ attr->attr.max_sge = srq->max_gs;
+ pthread_mutex_lock(&ctx->srq_table_mutex);
+ ret = ibv_cmd_create_srq(pd, ibsrq, attr, &cmd.ibv_cmd, sizeof(cmd),
+ &resp.ibv_resp, sizeof(resp));
+ if (ret)
+ goto err_db;
+
+ ret = mlx5_store_srq(ctx, resp.srqn, srq);
+ if (ret)
+ goto err_destroy;
+
+ pthread_mutex_unlock(&ctx->srq_table_mutex);
+
+ srq->srqn = resp.srqn;
+ srq->rsc.rsn = resp.srqn;
+ srq->rsc.type = MLX5_RSC_TYPE_SRQ;
+
+ return ibsrq;
+
+err_destroy:
+ ibv_cmd_destroy_srq(ibsrq);
+
+err_db:
+ pthread_mutex_unlock(&ctx->srq_table_mutex);
+ mlx5_free_db(to_mctx(pd->context), srq->db);
+
+err_free:
+ free(srq->wrid);
+ mlx5_free_buf(&srq->buf);
+
+err:
+ free(srq);
+
+ return NULL;
+}
+
+int mlx5_modify_srq(struct ibv_srq *srq,
+ struct ibv_srq_attr *attr,
+ int attr_mask)
+{
+ struct ibv_modify_srq cmd;
+
+ return ibv_cmd_modify_srq(srq, attr, attr_mask, &cmd, sizeof cmd);
+}
+
+int mlx5_query_srq(struct ibv_srq *srq,
+ struct ibv_srq_attr *attr)
+{
+ struct ibv_query_srq cmd;
+
+ return ibv_cmd_query_srq(srq, attr, &cmd, sizeof cmd);
+}
+
+int mlx5_destroy_srq(struct ibv_srq *srq)
+{
+ int ret;
+ struct mlx5_srq *msrq = to_msrq(srq);
+ struct mlx5_context *ctx = to_mctx(srq->context);
+
+ ret = ibv_cmd_destroy_srq(srq);
+ if (ret)
+ return ret;
+
+ if (ctx->cqe_version && msrq->rsc.type == MLX5_RSC_TYPE_XSRQ)
+ mlx5_clear_uidx(ctx, msrq->rsc.rsn);
+ else
+ mlx5_clear_srq(ctx, msrq->srqn);
+
+ mlx5_free_db(ctx, msrq->db);
+ mlx5_free_buf(&msrq->buf);
+ free(msrq->wrid);
+ free(msrq);
+
+ return 0;
+}
+
+static int sq_overhead(enum ibv_qp_type qp_type)
+{
+ size_t size = 0;
+ size_t mw_bind_size =
+ sizeof(struct mlx5_wqe_umr_ctrl_seg) +
+ sizeof(struct mlx5_wqe_mkey_context_seg) +
+ max_t(size_t, sizeof(struct mlx5_wqe_umr_klm_seg), 64);
+
+ switch (qp_type) {
+ case IBV_QPT_RC:
+ size += sizeof(struct mlx5_wqe_ctrl_seg) +
+ max(sizeof(struct mlx5_wqe_atomic_seg) +
+ sizeof(struct mlx5_wqe_raddr_seg),
+ mw_bind_size);
+ break;
+
+ case IBV_QPT_UC:
+ size = sizeof(struct mlx5_wqe_ctrl_seg) +
+ max(sizeof(struct mlx5_wqe_raddr_seg),
+ mw_bind_size);
+ break;
+
+ case IBV_QPT_UD:
+ size = sizeof(struct mlx5_wqe_ctrl_seg) +
+ sizeof(struct mlx5_wqe_datagram_seg);
+ break;
+
+ case IBV_QPT_XRC_SEND:
+ size = sizeof(struct mlx5_wqe_ctrl_seg) + mw_bind_size;
+ SWITCH_FALLTHROUGH;
+
+ case IBV_QPT_XRC_RECV:
+ size = max(size, sizeof(struct mlx5_wqe_ctrl_seg) +
+ sizeof(struct mlx5_wqe_xrc_seg) +
+ sizeof(struct mlx5_wqe_raddr_seg));
+ break;
+
+ case IBV_QPT_RAW_PACKET:
+ size = sizeof(struct mlx5_wqe_ctrl_seg) +
+ sizeof(struct mlx5_wqe_eth_seg);
+ break;
+
+ default:
+ return -EINVAL;
+ }
+
+ return size;
+}
+
+static int mlx5_calc_send_wqe(struct mlx5_context *ctx,
+ struct ibv_qp_init_attr_ex *attr,
+ struct mlx5_qp *qp)
+{
+ int size;
+ int inl_size = 0;
+ int max_gather;
+ int tot_size;
+
+ size = sq_overhead(attr->qp_type);
+ if (size < 0)
+ return size;
+
+ if (attr->cap.max_inline_data) {
+ inl_size = size + align(sizeof(struct mlx5_wqe_inl_data_seg) +
+ attr->cap.max_inline_data, 16);
+ }
+
+ if (attr->comp_mask & IBV_QP_INIT_ATTR_MAX_TSO_HEADER) {
+ size += align(attr->max_tso_header, 16);
+ qp->max_tso_header = attr->max_tso_header;
+ }
+
+ max_gather = (ctx->max_sq_desc_sz - size) /
+ sizeof(struct mlx5_wqe_data_seg);
+ if (attr->cap.max_send_sge > max_gather)
+ return -EINVAL;
+
+ size += attr->cap.max_send_sge * sizeof(struct mlx5_wqe_data_seg);
+ tot_size = max_int(size, inl_size);
+
+ if (tot_size > ctx->max_sq_desc_sz)
+ return -EINVAL;
+
+ return align(tot_size, MLX5_SEND_WQE_BB);
+}
+
+static int mlx5_calc_rcv_wqe(struct mlx5_context *ctx,
+ struct ibv_qp_init_attr_ex *attr,
+ struct mlx5_qp *qp)
+{
+ uint32_t size;
+ int num_scatter;
+
+ if (attr->srq)
+ return 0;
+
+ num_scatter = max_t(uint32_t, attr->cap.max_recv_sge, 1);
+ size = sizeof(struct mlx5_wqe_data_seg) * num_scatter;
+ if (qp->wq_sig)
+ size += sizeof(struct mlx5_rwqe_sig);
+
+ if (size > ctx->max_rq_desc_sz)
+ return -EINVAL;
+
+ size = mlx5_round_up_power_of_two(size);
+
+ return size;
+}
+
+static int mlx5_calc_sq_size(struct mlx5_context *ctx,
+ struct ibv_qp_init_attr_ex *attr,
+ struct mlx5_qp *qp)
+{
+ int wqe_size;
+ int wq_size;
+ FILE *fp = ctx->dbg_fp;
+
+ if (!attr->cap.max_send_wr)
+ return 0;
+
+ wqe_size = mlx5_calc_send_wqe(ctx, attr, qp);
+ if (wqe_size < 0) {
+ mlx5_dbg(fp, MLX5_DBG_QP, "\n");
+ return wqe_size;
+ }
+
+ if (wqe_size > ctx->max_sq_desc_sz) {
+ mlx5_dbg(fp, MLX5_DBG_QP, "\n");
+ return -EINVAL;
+ }
+
+ qp->max_inline_data = wqe_size - sq_overhead(attr->qp_type) -
+ sizeof(struct mlx5_wqe_inl_data_seg);
+ attr->cap.max_inline_data = qp->max_inline_data;
+
+ /*
+ * to avoid overflow, we limit max_send_wr so
+ * that the multiplication will fit in int
+ */
+ if (attr->cap.max_send_wr > 0x7fffffff / ctx->max_sq_desc_sz) {
+ mlx5_dbg(fp, MLX5_DBG_QP, "\n");
+ return -EINVAL;
+ }
+
+ wq_size = mlx5_round_up_power_of_two(attr->cap.max_send_wr * wqe_size);
+ qp->sq.wqe_cnt = wq_size / MLX5_SEND_WQE_BB;
+ if (qp->sq.wqe_cnt > ctx->max_send_wqebb) {
+ mlx5_dbg(fp, MLX5_DBG_QP, "\n");
+ return -EINVAL;
+ }
+
+ qp->sq.wqe_shift = mlx5_ilog2(MLX5_SEND_WQE_BB);
+ qp->sq.max_gs = attr->cap.max_send_sge;
+ qp->sq.max_post = wq_size / wqe_size;
+
+ return wq_size;
+}
+
+static int mlx5_calc_rwq_size(struct mlx5_context *ctx,
+ struct mlx5_rwq *rwq,
+ struct ibv_wq_init_attr *attr)
+{
+ size_t wqe_size;
+ int wq_size;
+ uint32_t num_scatter;
+ int scat_spc;
+
+ if (!attr->max_wr)
+ return -EINVAL;
+
+ /* TBD: check caps for RQ */
+ num_scatter = max_t(uint32_t, attr->max_sge, 1);
+ wqe_size = sizeof(struct mlx5_wqe_data_seg) * num_scatter;
+
+ if (rwq->wq_sig)
+ wqe_size += sizeof(struct mlx5_rwqe_sig);
+
+ if (wqe_size <= 0 || wqe_size > ctx->max_rq_desc_sz)
+ return -EINVAL;
+
+ wqe_size = mlx5_round_up_power_of_two(wqe_size);
+ wq_size = mlx5_round_up_power_of_two(attr->max_wr) * wqe_size;
+ wq_size = max(wq_size, MLX5_SEND_WQE_BB);
+ rwq->rq.wqe_cnt = wq_size / wqe_size;
+ rwq->rq.wqe_shift = mlx5_ilog2(wqe_size);
+ rwq->rq.max_post = 1 << mlx5_ilog2(wq_size / wqe_size);
+ scat_spc = wqe_size -
+ ((rwq->wq_sig) ? sizeof(struct mlx5_rwqe_sig) : 0);
+ rwq->rq.max_gs = scat_spc / sizeof(struct mlx5_wqe_data_seg);
+ return wq_size;
+}
+
+static int mlx5_calc_rq_size(struct mlx5_context *ctx,
+ struct ibv_qp_init_attr_ex *attr,
+ struct mlx5_qp *qp)
+{
+ int wqe_size;
+ int wq_size;
+ int scat_spc;
+ FILE *fp = ctx->dbg_fp;
+
+ if (!attr->cap.max_recv_wr)
+ return 0;
+
+ if (attr->cap.max_recv_wr > ctx->max_recv_wr) {
+ mlx5_dbg(fp, MLX5_DBG_QP, "\n");
+ return -EINVAL;
+ }
+
+ wqe_size = mlx5_calc_rcv_wqe(ctx, attr, qp);
+ if (wqe_size < 0 || wqe_size > ctx->max_rq_desc_sz) {
+ mlx5_dbg(fp, MLX5_DBG_QP, "\n");
+ return -EINVAL;
+ }
+
+ wq_size = mlx5_round_up_power_of_two(attr->cap.max_recv_wr) * wqe_size;
+ if (wqe_size) {
+ wq_size = max(wq_size, MLX5_SEND_WQE_BB);
+ qp->rq.wqe_cnt = wq_size / wqe_size;
+ qp->rq.wqe_shift = mlx5_ilog2(wqe_size);
+ qp->rq.max_post = 1 << mlx5_ilog2(wq_size / wqe_size);
+ scat_spc = wqe_size -
+ (qp->wq_sig ? sizeof(struct mlx5_rwqe_sig) : 0);
+ qp->rq.max_gs = scat_spc / sizeof(struct mlx5_wqe_data_seg);
+ } else {
+ qp->rq.wqe_cnt = 0;
+ qp->rq.wqe_shift = 0;
+ qp->rq.max_post = 0;
+ qp->rq.max_gs = 0;
+ }
+ return wq_size;
+}
+
+static int mlx5_calc_wq_size(struct mlx5_context *ctx,
+ struct ibv_qp_init_attr_ex *attr,
+ struct mlx5_qp *qp)
+{
+ int ret;
+ int result;
+
+ ret = mlx5_calc_sq_size(ctx, attr, qp);
+ if (ret < 0)
+ return ret;
+
+ result = ret;
+ ret = mlx5_calc_rq_size(ctx, attr, qp);
+ if (ret < 0)
+ return ret;
+
+ result += ret;
+
+ qp->sq.offset = ret;
+ qp->rq.offset = 0;
+
+ return result;
+}
+
+static void map_uuar(struct ibv_context *context, struct mlx5_qp *qp,
+ int uuar_index)
+{
+ struct mlx5_context *ctx = to_mctx(context);
+
+ qp->bf = &ctx->bfs[uuar_index];
+}
+
+static const char *qptype2key(enum ibv_qp_type type)
+{
+ switch (type) {
+ case IBV_QPT_RC: return "HUGE_RC";
+ case IBV_QPT_UC: return "HUGE_UC";
+ case IBV_QPT_UD: return "HUGE_UD";
+ case IBV_QPT_RAW_PACKET: return "HUGE_RAW_ETH";
+ default: return "HUGE_NA";
+ }
+}
+
+static int mlx5_alloc_qp_buf(struct ibv_context *context,
+ struct ibv_qp_init_attr_ex *attr,
+ struct mlx5_qp *qp,
+ int size)
+{
+ int err;
+ enum mlx5_alloc_type alloc_type;
+ enum mlx5_alloc_type default_alloc_type = MLX5_ALLOC_TYPE_ANON;
+ const char *qp_huge_key;
+
+ if (qp->sq.wqe_cnt) {
+ qp->sq.wrid = malloc(qp->sq.wqe_cnt * sizeof(*qp->sq.wrid));
+ if (!qp->sq.wrid) {
+ errno = ENOMEM;
+ err = -1;
+ return err;
+ }
+
+ qp->sq.wr_data = malloc(qp->sq.wqe_cnt * sizeof(*qp->sq.wr_data));
+ if (!qp->sq.wr_data) {
+ errno = ENOMEM;
+ err = -1;
+ goto ex_wrid;
+ }
+ }
+
+ qp->sq.wqe_head = malloc(qp->sq.wqe_cnt * sizeof(*qp->sq.wqe_head));
+ if (!qp->sq.wqe_head) {
+ errno = ENOMEM;
+ err = -1;
+ goto ex_wrid;
+ }
+
+ if (qp->rq.wqe_cnt) {
+ qp->rq.wrid = malloc(qp->rq.wqe_cnt * sizeof(uint64_t));
+ if (!qp->rq.wrid) {
+ errno = ENOMEM;
+ err = -1;
+ goto ex_wrid;
+ }
+ }
+
+ /* compatibility support */
+ qp_huge_key = qptype2key(qp->ibv_qp->qp_type);
+ if (mlx5_use_huge(qp_huge_key))
+ default_alloc_type = MLX5_ALLOC_TYPE_HUGE;
+
+ mlx5_get_alloc_type(MLX5_QP_PREFIX, &alloc_type,
+ default_alloc_type);
+
+ err = mlx5_alloc_prefered_buf(to_mctx(context), &qp->buf,
+ align(qp->buf_size, to_mdev
+ (context->device)->page_size),
+ to_mdev(context->device)->page_size,
+ alloc_type,
+ MLX5_QP_PREFIX);
+
+ if (err) {
+ err = -ENOMEM;
+ goto ex_wrid;
+ }
+
+ memset(qp->buf.buf, 0, qp->buf_size);
+
+ if (attr->qp_type == IBV_QPT_RAW_PACKET) {
+ size_t aligned_sq_buf_size = align(qp->sq_buf_size,
+ to_mdev(context->device)->page_size);
+ /* For Raw Packet QP, allocate a separate buffer for the SQ */
+ err = mlx5_alloc_prefered_buf(to_mctx(context), &qp->sq_buf,
+ aligned_sq_buf_size,
+ to_mdev(context->device)->page_size,
+ alloc_type,
+ MLX5_QP_PREFIX);
+ if (err) {
+ err = -ENOMEM;
+ goto rq_buf;
+ }
+
+ memset(qp->sq_buf.buf, 0, aligned_sq_buf_size);
+ }
+
+ return 0;
+rq_buf:
+ mlx5_free_actual_buf(to_mctx(qp->verbs_qp.qp.context), &qp->buf);
+ex_wrid:
+ if (qp->rq.wrid)
+ free(qp->rq.wrid);
+
+ if (qp->sq.wqe_head)
+ free(qp->sq.wqe_head);
+
+ if (qp->sq.wr_data)
+ free(qp->sq.wr_data);
+ if (qp->sq.wrid)
+ free(qp->sq.wrid);
+
+ return err;
+}
+
+static void mlx5_free_qp_buf(struct mlx5_qp *qp)
+{
+ struct mlx5_context *ctx = to_mctx(qp->ibv_qp->context);
+
+ mlx5_free_actual_buf(ctx, &qp->buf);
+
+ if (qp->sq_buf.buf)
+ mlx5_free_actual_buf(ctx, &qp->sq_buf);
+
+ if (qp->rq.wrid)
+ free(qp->rq.wrid);
+
+ if (qp->sq.wqe_head)
+ free(qp->sq.wqe_head);
+
+ if (qp->sq.wrid)
+ free(qp->sq.wrid);
+
+ if (qp->sq.wr_data)
+ free(qp->sq.wr_data);
+}
+
+static int mlx5_cmd_create_rss_qp(struct ibv_context *context,
+ struct ibv_qp_init_attr_ex *attr,
+ struct mlx5_qp *qp)
+{
+ struct mlx5_create_qp_ex_rss cmd_ex_rss = {};
+ struct mlx5_create_qp_resp_ex resp = {};
+ int ret;
+
+ if (attr->rx_hash_conf.rx_hash_key_len > sizeof(cmd_ex_rss.rx_hash_key)) {
+ errno = EINVAL;
+ return errno;
+ }
+
+ cmd_ex_rss.rx_hash_fields_mask = attr->rx_hash_conf.rx_hash_fields_mask;
+ cmd_ex_rss.rx_hash_function = attr->rx_hash_conf.rx_hash_function;
+ cmd_ex_rss.rx_key_len = attr->rx_hash_conf.rx_hash_key_len;
+ memcpy(cmd_ex_rss.rx_hash_key, attr->rx_hash_conf.rx_hash_key,
+ attr->rx_hash_conf.rx_hash_key_len);
+
+ ret = ibv_cmd_create_qp_ex2(context, &qp->verbs_qp,
+ sizeof(qp->verbs_qp), attr,
+ &cmd_ex_rss.ibv_cmd, sizeof(cmd_ex_rss.ibv_cmd),
+ sizeof(cmd_ex_rss), &resp.ibv_resp,
+ sizeof(resp.ibv_resp), sizeof(resp));
+ if (ret)
+ return ret;
+
+ qp->rss_qp = 1;
+ return 0;
+}
+
+static int mlx5_cmd_create_qp_ex(struct ibv_context *context,
+ struct ibv_qp_init_attr_ex *attr,
+ struct mlx5_create_qp *cmd,
+ struct mlx5_qp *qp,
+ struct mlx5_create_qp_resp_ex *resp)
+{
+ struct mlx5_create_qp_ex cmd_ex;
+ int ret;
+
+ memset(&cmd_ex, 0, sizeof(cmd_ex));
+ memcpy(&cmd_ex.ibv_cmd.base, &cmd->ibv_cmd.user_handle,
+ offsetof(typeof(cmd->ibv_cmd), is_srq) +
+ sizeof(cmd->ibv_cmd.is_srq) -
+ offsetof(typeof(cmd->ibv_cmd), user_handle));
+
+ memcpy(&cmd_ex.drv_ex, &cmd->buf_addr,
+ offsetof(typeof(*cmd), sq_buf_addr) +
+ sizeof(cmd->sq_buf_addr) - sizeof(cmd->ibv_cmd));
+
+ ret = ibv_cmd_create_qp_ex2(context, &qp->verbs_qp,
+ sizeof(qp->verbs_qp), attr,
+ &cmd_ex.ibv_cmd, sizeof(cmd_ex.ibv_cmd),
+ sizeof(cmd_ex), &resp->ibv_resp,
+ sizeof(resp->ibv_resp), sizeof(*resp));
+
+ return ret;
+}
+
+enum {
+ MLX5_CREATE_QP_SUP_COMP_MASK = (IBV_QP_INIT_ATTR_PD |
+ IBV_QP_INIT_ATTR_XRCD |
+ IBV_QP_INIT_ATTR_CREATE_FLAGS |
+ IBV_QP_INIT_ATTR_MAX_TSO_HEADER |
+ IBV_QP_INIT_ATTR_IND_TABLE |
+ IBV_QP_INIT_ATTR_RX_HASH),
+};
+
+enum {
+ MLX5_CREATE_QP_EX2_COMP_MASK = (IBV_QP_INIT_ATTR_CREATE_FLAGS |
+ IBV_QP_INIT_ATTR_MAX_TSO_HEADER |
+ IBV_QP_INIT_ATTR_IND_TABLE |
+ IBV_QP_INIT_ATTR_RX_HASH),
+};
+
+static struct ibv_qp *create_qp(struct ibv_context *context,
+ struct ibv_qp_init_attr_ex *attr)
+{
+ struct mlx5_create_qp cmd;
+ struct mlx5_create_qp_resp resp;
+ struct mlx5_create_qp_resp_ex resp_ex;
+ struct mlx5_qp *qp;
+ int ret;
+ struct mlx5_context *ctx = to_mctx(context);
+ struct ibv_qp *ibqp;
+ int32_t usr_idx = 0;
+ uint32_t uuar_index;
+ FILE *fp = ctx->dbg_fp;
+
+ if (attr->comp_mask & ~MLX5_CREATE_QP_SUP_COMP_MASK)
+ return NULL;
+
+ if ((attr->comp_mask & IBV_QP_INIT_ATTR_MAX_TSO_HEADER) &&
+ (attr->qp_type != IBV_QPT_RAW_PACKET))
+ return NULL;
+
+ qp = calloc(1, sizeof(*qp));
+ if (!qp) {
+ mlx5_dbg(fp, MLX5_DBG_QP, "\n");
+ return NULL;
+ }
+ ibqp = (struct ibv_qp *)&qp->verbs_qp;
+ qp->ibv_qp = ibqp;
+
+ memset(&cmd, 0, sizeof(cmd));
+ memset(&resp, 0, sizeof(resp));
+ memset(&resp_ex, 0, sizeof(resp_ex));
+
+ if (attr->comp_mask & IBV_QP_INIT_ATTR_RX_HASH) {
+ ret = mlx5_cmd_create_rss_qp(context, attr, qp);
+ if (ret)
+ goto err;
+
+ return ibqp;
+ }
+
+ qp->wq_sig = qp_sig_enabled();
+ if (qp->wq_sig)
+ cmd.flags |= MLX5_QP_FLAG_SIGNATURE;
+
+ if (use_scatter_to_cqe())
+ cmd.flags |= MLX5_QP_FLAG_SCATTER_CQE;
+
+ ret = mlx5_calc_wq_size(ctx, attr, qp);
+ if (ret < 0) {
+ errno = -ret;
+ goto err;
+ }
+
+ if (attr->qp_type == IBV_QPT_RAW_PACKET) {
+ qp->buf_size = qp->sq.offset;
+ qp->sq_buf_size = ret - qp->buf_size;
+ qp->sq.offset = 0;
+ } else {
+ qp->buf_size = ret;
+ qp->sq_buf_size = 0;
+ }
+
+ if (mlx5_alloc_qp_buf(context, attr, qp, ret)) {
+ mlx5_dbg(fp, MLX5_DBG_QP, "\n");
+ goto err;
+ }
+
+ if (attr->qp_type == IBV_QPT_RAW_PACKET) {
+ qp->sq_start = qp->sq_buf.buf;
+ qp->sq.qend = qp->sq_buf.buf +
+ (qp->sq.wqe_cnt << qp->sq.wqe_shift);
+ } else {
+ qp->sq_start = qp->buf.buf + qp->sq.offset;
+ qp->sq.qend = qp->buf.buf + qp->sq.offset +
+ (qp->sq.wqe_cnt << qp->sq.wqe_shift);
+ }
+
+ mlx5_init_qp_indices(qp);
+
+ if (mlx5_spinlock_init(&qp->sq.lock) ||
+ mlx5_spinlock_init(&qp->rq.lock))
+ goto err_free_qp_buf;
+
+ qp->db = mlx5_alloc_dbrec(ctx);
+ if (!qp->db) {
+ mlx5_dbg(fp, MLX5_DBG_QP, "\n");
+ goto err_free_qp_buf;
+ }
+
+ qp->db[MLX5_RCV_DBR] = 0;
+ qp->db[MLX5_SND_DBR] = 0;
+
+ cmd.buf_addr = (uintptr_t) qp->buf.buf;
+ cmd.sq_buf_addr = (attr->qp_type == IBV_QPT_RAW_PACKET) ?
+ (uintptr_t) qp->sq_buf.buf : 0;
+ cmd.db_addr = (uintptr_t) qp->db;
+ cmd.sq_wqe_count = qp->sq.wqe_cnt;
+ cmd.rq_wqe_count = qp->rq.wqe_cnt;
+ cmd.rq_wqe_shift = qp->rq.wqe_shift;
+
+ if (ctx->atomic_cap == IBV_ATOMIC_HCA)
+ qp->atomics_enabled = 1;
+
+ if (!ctx->cqe_version) {
+ cmd.uidx = 0xffffff;
+ pthread_mutex_lock(&ctx->qp_table_mutex);
+ } else if (!is_xrc_tgt(attr->qp_type)) {
+ usr_idx = mlx5_store_uidx(ctx, qp);
+ if (usr_idx < 0) {
+ mlx5_dbg(fp, MLX5_DBG_QP, "Couldn't find free user index\n");
+ goto err_rq_db;
+ }
+
+ cmd.uidx = usr_idx;
+ }
+
+ if (attr->comp_mask & MLX5_CREATE_QP_EX2_COMP_MASK)
+ ret = mlx5_cmd_create_qp_ex(context, attr, &cmd, qp, &resp_ex);
+ else
+ ret = ibv_cmd_create_qp_ex(context, &qp->verbs_qp, sizeof(qp->verbs_qp),
+ attr, &cmd.ibv_cmd, sizeof(cmd),
+ &resp.ibv_resp, sizeof(resp));
+ if (ret) {
+ mlx5_dbg(fp, MLX5_DBG_QP, "ret %d\n", ret);
+ goto err_free_uidx;
+ }
+
+ uuar_index = (attr->comp_mask & MLX5_CREATE_QP_EX2_COMP_MASK) ?
+ resp_ex.uuar_index : resp.uuar_index;
+ if (!ctx->cqe_version) {
+ if (qp->sq.wqe_cnt || qp->rq.wqe_cnt) {
+ ret = mlx5_store_qp(ctx, ibqp->qp_num, qp);
+ if (ret) {
+ mlx5_dbg(fp, MLX5_DBG_QP, "ret %d\n", ret);
+ goto err_destroy;
+ }
+ }
+
+ pthread_mutex_unlock(&ctx->qp_table_mutex);
+ }
+
+ map_uuar(context, qp, uuar_index);
+
+ qp->rq.max_post = qp->rq.wqe_cnt;
+ if (attr->sq_sig_all)
+ qp->sq_signal_bits = MLX5_WQE_CTRL_CQ_UPDATE;
+ else
+ qp->sq_signal_bits = 0;
+
+ attr->cap.max_send_wr = qp->sq.max_post;
+ attr->cap.max_recv_wr = qp->rq.max_post;
+ attr->cap.max_recv_sge = qp->rq.max_gs;
+
+ qp->rsc.type = MLX5_RSC_TYPE_QP;
+ qp->rsc.rsn = (ctx->cqe_version && !is_xrc_tgt(attr->qp_type)) ?
+ usr_idx : ibqp->qp_num;
+
+ return ibqp;
+
+err_destroy:
+ ibv_cmd_destroy_qp(ibqp);
+
+err_free_uidx:
+ if (!ctx->cqe_version)
+ pthread_mutex_unlock(&to_mctx(context)->qp_table_mutex);
+ else if (!is_xrc_tgt(attr->qp_type))
+ mlx5_clear_uidx(ctx, usr_idx);
+
+err_rq_db:
+ mlx5_free_db(to_mctx(context), qp->db);
+
+err_free_qp_buf:
+ mlx5_free_qp_buf(qp);
+
+err:
+ free(qp);
+
+ return NULL;
+}
+
+struct ibv_qp *mlx5_create_qp(struct ibv_pd *pd,
+ struct ibv_qp_init_attr *attr)
+{
+ struct ibv_qp *qp;
+ struct ibv_qp_init_attr_ex attrx;
+
+ memset(&attrx, 0, sizeof(attrx));
+ memcpy(&attrx, attr, sizeof(*attr));
+ attrx.comp_mask = IBV_QP_INIT_ATTR_PD;
+ attrx.pd = pd;
+ qp = create_qp(pd->context, &attrx);
+ if (qp)
+ memcpy(attr, &attrx, sizeof(*attr));
+
+ return qp;
+}
+
+static void mlx5_lock_cqs(struct ibv_qp *qp)
+{
+ struct mlx5_cq *send_cq = to_mcq(qp->send_cq);
+ struct mlx5_cq *recv_cq = to_mcq(qp->recv_cq);
+
+ if (send_cq && recv_cq) {
+ if (send_cq == recv_cq) {
+ mlx5_spin_lock(&send_cq->lock);
+ } else if (send_cq->cqn < recv_cq->cqn) {
+ mlx5_spin_lock(&send_cq->lock);
+ mlx5_spin_lock(&recv_cq->lock);
+ } else {
+ mlx5_spin_lock(&recv_cq->lock);
+ mlx5_spin_lock(&send_cq->lock);
+ }
+ } else if (send_cq) {
+ mlx5_spin_lock(&send_cq->lock);
+ } else if (recv_cq) {
+ mlx5_spin_lock(&recv_cq->lock);
+ }
+}
+
+static void mlx5_unlock_cqs(struct ibv_qp *qp)
+{
+ struct mlx5_cq *send_cq = to_mcq(qp->send_cq);
+ struct mlx5_cq *recv_cq = to_mcq(qp->recv_cq);
+
+ if (send_cq && recv_cq) {
+ if (send_cq == recv_cq) {
+ mlx5_spin_unlock(&send_cq->lock);
+ } else if (send_cq->cqn < recv_cq->cqn) {
+ mlx5_spin_unlock(&recv_cq->lock);
+ mlx5_spin_unlock(&send_cq->lock);
+ } else {
+ mlx5_spin_unlock(&send_cq->lock);
+ mlx5_spin_unlock(&recv_cq->lock);
+ }
+ } else if (send_cq) {
+ mlx5_spin_unlock(&send_cq->lock);
+ } else if (recv_cq) {
+ mlx5_spin_unlock(&recv_cq->lock);
+ }
+}
+
+int mlx5_destroy_qp(struct ibv_qp *ibqp)
+{
+ struct mlx5_qp *qp = to_mqp(ibqp);
+ struct mlx5_context *ctx = to_mctx(ibqp->context);
+ int ret;
+
+ if (qp->rss_qp) {
+ ret = ibv_cmd_destroy_qp(ibqp);
+ if (ret)
+ return ret;
+ goto free;
+ }
+
+ if (!ctx->cqe_version)
+ pthread_mutex_lock(&ctx->qp_table_mutex);
+
+ ret = ibv_cmd_destroy_qp(ibqp);
+ if (ret) {
+ if (!ctx->cqe_version)
+ pthread_mutex_unlock(&ctx->qp_table_mutex);
+ return ret;
+ }
+
+ mlx5_lock_cqs(ibqp);
+
+ __mlx5_cq_clean(to_mcq(ibqp->recv_cq), qp->rsc.rsn,
+ ibqp->srq ? to_msrq(ibqp->srq) : NULL);
+ if (ibqp->send_cq != ibqp->recv_cq)
+ __mlx5_cq_clean(to_mcq(ibqp->send_cq), qp->rsc.rsn, NULL);
+
+ if (!ctx->cqe_version) {
+ if (qp->sq.wqe_cnt || qp->rq.wqe_cnt)
+ mlx5_clear_qp(ctx, ibqp->qp_num);
+ }
+
+ mlx5_unlock_cqs(ibqp);
+ if (!ctx->cqe_version)
+ pthread_mutex_unlock(&ctx->qp_table_mutex);
+ else if (!is_xrc_tgt(ibqp->qp_type))
+ mlx5_clear_uidx(ctx, qp->rsc.rsn);
+
+ mlx5_free_db(ctx, qp->db);
+ mlx5_free_qp_buf(qp);
+free:
+ free(qp);
+
+ return 0;
+}
+
+int mlx5_query_qp(struct ibv_qp *ibqp, struct ibv_qp_attr *attr,
+ int attr_mask, struct ibv_qp_init_attr *init_attr)
+{
+ struct ibv_query_qp cmd;
+ struct mlx5_qp *qp = to_mqp(ibqp);
+ int ret;
+
+ if (qp->rss_qp)
+ return ENOSYS;
+
+ ret = ibv_cmd_query_qp(ibqp, attr, attr_mask, init_attr, &cmd, sizeof(cmd));
+ if (ret)
+ return ret;
+
+ init_attr->cap.max_send_wr = qp->sq.max_post;
+ init_attr->cap.max_send_sge = qp->sq.max_gs;
+ init_attr->cap.max_inline_data = qp->max_inline_data;
+
+ attr->cap = init_attr->cap;
+
+ return 0;
+}
+
+enum {
+ MLX5_MODIFY_QP_EX_ATTR_MASK = IBV_QP_RATE_LIMIT,
+};
+
+int mlx5_modify_qp(struct ibv_qp *qp, struct ibv_qp_attr *attr,
+ int attr_mask)
+{
+ struct ibv_modify_qp cmd = {};
+ struct ibv_modify_qp_ex cmd_ex = {};
+ struct ibv_modify_qp_resp_ex resp = {};
+ struct mlx5_qp *mqp = to_mqp(qp);
+ struct mlx5_context *context = to_mctx(qp->context);
+ int ret;
+ uint32_t *db;
+
+ if (mqp->rss_qp)
+ return ENOSYS;
+
+ if (attr_mask & IBV_QP_PORT) {
+ switch (qp->qp_type) {
+ case IBV_QPT_RAW_PACKET:
+ if (context->cached_link_layer[attr->port_num - 1] ==
+ IBV_LINK_LAYER_ETHERNET) {
+ if (context->cached_device_cap_flags &
+ IBV_DEVICE_RAW_IP_CSUM)
+ mqp->qp_cap_cache |=
+ MLX5_CSUM_SUPPORT_RAW_OVER_ETH |
+ MLX5_RX_CSUM_VALID;
+
+ if (ibv_is_qpt_supported(
+ context->cached_tso_caps.supported_qpts,
+ IBV_QPT_RAW_PACKET))
+ mqp->max_tso =
+ context->cached_tso_caps.max_tso;
+ }
+ break;
+ default:
+ break;
+ }
+ }
+
+ if (attr_mask & MLX5_MODIFY_QP_EX_ATTR_MASK)
+ ret = ibv_cmd_modify_qp_ex(qp, attr, attr_mask,
+ &cmd_ex,
+ sizeof(cmd_ex), sizeof(cmd_ex),
+ &resp,
+ sizeof(resp), sizeof(resp));
+ else
+ ret = ibv_cmd_modify_qp(qp, attr, attr_mask,
+ &cmd, sizeof(cmd));
+
+ if (!ret &&
+ (attr_mask & IBV_QP_STATE) &&
+ attr->qp_state == IBV_QPS_RESET) {
+ if (qp->recv_cq) {
+ mlx5_cq_clean(to_mcq(qp->recv_cq), mqp->rsc.rsn,
+ qp->srq ? to_msrq(qp->srq) : NULL);
+ }
+ if (qp->send_cq != qp->recv_cq && qp->send_cq)
+ mlx5_cq_clean(to_mcq(qp->send_cq),
+ to_mqp(qp)->rsc.rsn, NULL);
+
+ mlx5_init_qp_indices(mqp);
+ db = mqp->db;
+ db[MLX5_RCV_DBR] = 0;
+ db[MLX5_SND_DBR] = 0;
+ }
+
+ /*
+ * When the Raw Packet QP is in INIT state, its RQ
+ * underneath is already in RDY, which means it can
+ * receive packets. According to the IB spec, a QP can't
+ * receive packets until moved to RTR state. To achieve this,
+ * for Raw Packet QPs, we update the doorbell record
+ * once the QP is moved to RTR.
+ */
+ if (!ret &&
+ (attr_mask & IBV_QP_STATE) &&
+ attr->qp_state == IBV_QPS_RTR &&
+ qp->qp_type == IBV_QPT_RAW_PACKET) {
+ mlx5_spin_lock(&mqp->rq.lock);
+ mqp->db[MLX5_RCV_DBR] = htobe32(mqp->rq.head & 0xffff);
+ mlx5_spin_unlock(&mqp->rq.lock);
+ }
+
+ return ret;
+}
+
+#define RROCE_UDP_SPORT_MIN 0xC000
+#define RROCE_UDP_SPORT_MAX 0xFFFF
+struct ibv_ah *mlx5_create_ah(struct ibv_pd *pd, struct ibv_ah_attr *attr)
+{
+ struct mlx5_context *ctx = to_mctx(pd->context);
+ struct ibv_port_attr port_attr;
+ struct mlx5_ah *ah;
+ uint32_t gid_type;
+ uint32_t tmp;
+ uint8_t grh;
+ int is_eth;
+
+ if (attr->port_num < 1 || attr->port_num > ctx->num_ports)
+ return NULL;
+
+ if (ctx->cached_link_layer[attr->port_num - 1]) {
+ is_eth = ctx->cached_link_layer[attr->port_num - 1] ==
+ IBV_LINK_LAYER_ETHERNET;
+ } else {
+ if (ibv_query_port(pd->context, attr->port_num, &port_attr))
+ return NULL;
+
+ is_eth = (port_attr.link_layer == IBV_LINK_LAYER_ETHERNET);
+ }
+
+ if (unlikely((!attr->is_global) && is_eth)) {
+ errno = EINVAL;
+ return NULL;
+ }
+
+ ah = calloc(1, sizeof *ah);
+ if (!ah)
+ return NULL;
+
+ if (is_eth) {
+ if (ibv_query_gid_type(pd->context, attr->port_num,
+ attr->grh.sgid_index, &gid_type))
+ goto err;
+
+ if (gid_type == IBV_GID_TYPE_ROCE_V2)
+ ah->av.rlid = htobe16(rand() % (RROCE_UDP_SPORT_MAX + 1
+ - RROCE_UDP_SPORT_MIN)
+ + RROCE_UDP_SPORT_MIN);
+ /* Since RoCE packets must contain GRH, this bit is reserved
+ * for RoCE and shouldn't be set.
+ */
+ grh = 0;
+ } else {
+ ah->av.fl_mlid = attr->src_path_bits & 0x7f;
+ ah->av.rlid = htobe16(attr->dlid);
+ grh = 1;
+ }
+ ah->av.stat_rate_sl = (attr->static_rate << 4) | attr->sl;
+ if (attr->is_global) {
+ ah->av.tclass = attr->grh.traffic_class;
+ ah->av.hop_limit = attr->grh.hop_limit;
+ tmp = htobe32((grh << 30) |
+ ((attr->grh.sgid_index & 0xff) << 20) |
+ (attr->grh.flow_label & 0xfffff));
+ ah->av.grh_gid_fl = tmp;
+ memcpy(ah->av.rgid, attr->grh.dgid.raw, 16);
+ }
+
+ if (is_eth) {
+ if (ctx->cmds_supp_uhw & MLX5_USER_CMDS_SUPP_UHW_CREATE_AH) {
+ struct mlx5_create_ah_resp resp = {};
+
+ if (ibv_cmd_create_ah(pd, &ah->ibv_ah, attr, &resp.ibv_resp, sizeof(resp)))
+ goto err;
+
+ ah->kern_ah = true;
+ memcpy(ah->av.rmac, resp.dmac, ETHERNET_LL_SIZE);
+ } else {
+ uint16_t vid;
+
+ if (ibv_resolve_eth_l2_from_gid(pd->context, attr,
+ ah->av.rmac, &vid))
+ goto err;
+ }
+ }
+
+ return &ah->ibv_ah;
+err:
+ free(ah);
+ return NULL;
+}
+
+int mlx5_destroy_ah(struct ibv_ah *ah)
+{
+ struct mlx5_ah *mah = to_mah(ah);
+ int err;
+
+ if (mah->kern_ah) {
+ err = ibv_cmd_destroy_ah(ah);
+ if (err)
+ return err;
+ }
+
+ free(mah);
+ return 0;
+}
+
+int mlx5_attach_mcast(struct ibv_qp *qp, const union ibv_gid *gid, uint16_t lid)
+{
+ return ibv_cmd_attach_mcast(qp, gid, lid);
+}
+
+int mlx5_detach_mcast(struct ibv_qp *qp, const union ibv_gid *gid, uint16_t lid)
+{
+ return ibv_cmd_detach_mcast(qp, gid, lid);
+}
+
+struct ibv_qp *mlx5_create_qp_ex(struct ibv_context *context,
+ struct ibv_qp_init_attr_ex *attr)
+{
+ return create_qp(context, attr);
+}
+
+int mlx5_get_srq_num(struct ibv_srq *srq, uint32_t *srq_num)
+{
+ struct mlx5_srq *msrq = to_msrq(srq);
+
+ *srq_num = msrq->srqn;
+
+ return 0;
+}
+
+struct ibv_xrcd *
+mlx5_open_xrcd(struct ibv_context *context,
+ struct ibv_xrcd_init_attr *xrcd_init_attr)
+{
+ int err;
+ struct verbs_xrcd *xrcd;
+ struct ibv_open_xrcd cmd = {};
+ struct ibv_open_xrcd_resp resp = {};
+
+ xrcd = calloc(1, sizeof(*xrcd));
+ if (!xrcd)
+ return NULL;
+
+ err = ibv_cmd_open_xrcd(context, xrcd, sizeof(*xrcd), xrcd_init_attr,
+ &cmd, sizeof(cmd), &resp, sizeof(resp));
+ if (err) {
+ free(xrcd);
+ return NULL;
+ }
+
+ return &xrcd->xrcd;
+}
+
+int mlx5_close_xrcd(struct ibv_xrcd *ib_xrcd)
+{
+ struct verbs_xrcd *xrcd = container_of(ib_xrcd, struct verbs_xrcd, xrcd);
+ int ret;
+
+ ret = ibv_cmd_close_xrcd(xrcd);
+ if (!ret)
+ free(xrcd);
+
+ return ret;
+}
+
+static struct ibv_srq *
+mlx5_create_xrc_srq(struct ibv_context *context,
+ struct ibv_srq_init_attr_ex *attr)
+{
+ int err;
+ struct mlx5_create_srq_ex cmd;
+ struct mlx5_create_srq_resp resp;
+ struct mlx5_srq *msrq;
+ struct mlx5_context *ctx = to_mctx(context);
+ int max_sge;
+ struct ibv_srq *ibsrq;
+ int uidx;
+ FILE *fp = ctx->dbg_fp;
+
+ msrq = calloc(1, sizeof(*msrq));
+ if (!msrq)
+ return NULL;
+
+ ibsrq = (struct ibv_srq *)&msrq->vsrq;
+
+ memset(&cmd, 0, sizeof(cmd));
+ memset(&resp, 0, sizeof(resp));
+
+ if (mlx5_spinlock_init(&msrq->lock)) {
+ fprintf(stderr, "%s-%d:\n", __func__, __LINE__);
+ goto err;
+ }
+
+ if (attr->attr.max_wr > ctx->max_srq_recv_wr) {
+ fprintf(stderr, "%s-%d:max_wr %d, max_srq_recv_wr %d\n",
+ __func__, __LINE__, attr->attr.max_wr,
+ ctx->max_srq_recv_wr);
+ errno = EINVAL;
+ goto err;
+ }
+
+ /*
+ * this calculation does not consider required control segments. The
+ * final calculation is done again later. This is done so to avoid
+ * overflows of variables
+ */
+ max_sge = ctx->max_recv_wr / sizeof(struct mlx5_wqe_data_seg);
+ if (attr->attr.max_sge > max_sge) {
+ fprintf(stderr, "%s-%d:max_wr %d, max_srq_recv_wr %d\n",
+ __func__, __LINE__, attr->attr.max_wr,
+ ctx->max_srq_recv_wr);
+ errno = EINVAL;
+ goto err;
+ }
+
+ msrq->max = align_queue_size(attr->attr.max_wr + 1);
+ msrq->max_gs = attr->attr.max_sge;
+ msrq->counter = 0;
+
+ if (mlx5_alloc_srq_buf(context, msrq)) {
+ fprintf(stderr, "%s-%d:\n", __func__, __LINE__);
+ goto err;
+ }
+
+ msrq->db = mlx5_alloc_dbrec(ctx);
+ if (!msrq->db) {
+ fprintf(stderr, "%s-%d:\n", __func__, __LINE__);
+ goto err_free;
+ }
+
+ *msrq->db = 0;
+
+ cmd.buf_addr = (uintptr_t)msrq->buf.buf;
+ cmd.db_addr = (uintptr_t)msrq->db;
+ msrq->wq_sig = srq_sig_enabled();
+ if (msrq->wq_sig)
+ cmd.flags = MLX5_SRQ_FLAG_SIGNATURE;
+
+ attr->attr.max_sge = msrq->max_gs;
+ if (ctx->cqe_version) {
+ uidx = mlx5_store_uidx(ctx, msrq);
+ if (uidx < 0) {
+ mlx5_dbg(fp, MLX5_DBG_QP, "Couldn't find free user index\n");
+ goto err_free_db;
+ }
+ cmd.uidx = uidx;
+ } else {
+ cmd.uidx = 0xffffff;
+ pthread_mutex_lock(&ctx->srq_table_mutex);
+ }
+
+ err = ibv_cmd_create_srq_ex(context, &msrq->vsrq, sizeof(msrq->vsrq),
+ attr, &cmd.ibv_cmd, sizeof(cmd),
+ &resp.ibv_resp, sizeof(resp));
+ if (err)
+ goto err_free_uidx;
+
+ if (!ctx->cqe_version) {
+ err = mlx5_store_srq(to_mctx(context), resp.srqn, msrq);
+ if (err)
+ goto err_destroy;
+
+ pthread_mutex_unlock(&ctx->srq_table_mutex);
+ }
+
+ msrq->srqn = resp.srqn;
+ msrq->rsc.type = MLX5_RSC_TYPE_XSRQ;
+ msrq->rsc.rsn = ctx->cqe_version ? cmd.uidx : resp.srqn;
+
+ return ibsrq;
+
+err_destroy:
+ ibv_cmd_destroy_srq(ibsrq);
+
+err_free_uidx:
+ if (ctx->cqe_version)
+ mlx5_clear_uidx(ctx, cmd.uidx);
+ else
+ pthread_mutex_unlock(&ctx->srq_table_mutex);
+
+err_free_db:
+ mlx5_free_db(ctx, msrq->db);
+
+err_free:
+ free(msrq->wrid);
+ mlx5_free_buf(&msrq->buf);
+
+err:
+ free(msrq);
+
+ return NULL;
+}
+
+struct ibv_srq *mlx5_create_srq_ex(struct ibv_context *context,
+ struct ibv_srq_init_attr_ex *attr)
+{
+ if (!(attr->comp_mask & IBV_SRQ_INIT_ATTR_TYPE) ||
+ (attr->srq_type == IBV_SRQT_BASIC))
+ return mlx5_create_srq(attr->pd,
+ (struct ibv_srq_init_attr *)attr);
+ else if (attr->srq_type == IBV_SRQT_XRC)
+ return mlx5_create_xrc_srq(context, attr);
+
+ return NULL;
+}
+
+int mlx5_query_device_ex(struct ibv_context *context,
+ const struct ibv_query_device_ex_input *input,
+ struct ibv_device_attr_ex *attr,
+ size_t attr_size)
+{
+ struct mlx5_context *mctx = to_mctx(context);
+ struct mlx5_query_device_ex_resp resp;
+ struct mlx5_query_device_ex cmd;
+ struct ibv_device_attr *a;
+ uint64_t raw_fw_ver;
+ unsigned sub_minor;
+ unsigned major;
+ unsigned minor;
+ int err;
+ int cmd_supp_uhw = mctx->cmds_supp_uhw &
+ MLX5_USER_CMDS_SUPP_UHW_QUERY_DEVICE;
+
+ memset(&cmd, 0, sizeof(cmd));
+ memset(&resp, 0, sizeof(resp));
+ err = ibv_cmd_query_device_ex(context, input, attr, attr_size,
+ &raw_fw_ver,
+ &cmd.ibv_cmd, sizeof(cmd.ibv_cmd), sizeof(cmd),
+ &resp.ibv_resp, sizeof(resp.ibv_resp),
+ cmd_supp_uhw ? sizeof(resp) : sizeof(resp.ibv_resp));
+ if (err)
+ return err;
+
+ attr->tso_caps = resp.tso_caps;
+ attr->rss_caps.rx_hash_fields_mask = resp.rss_caps.rx_hash_fields_mask;
+ attr->rss_caps.rx_hash_function = resp.rss_caps.rx_hash_function;
+ attr->packet_pacing_caps = resp.packet_pacing_caps.caps;
+
+ if (resp.support_multi_pkt_send_wqe)
+ mctx->vendor_cap_flags |= MLX5_VENDOR_CAP_FLAGS_MPW;
+
+ mctx->cqe_comp_caps = resp.cqe_comp_caps;
+
+ major = (raw_fw_ver >> 32) & 0xffff;
+ minor = (raw_fw_ver >> 16) & 0xffff;
+ sub_minor = raw_fw_ver & 0xffff;
+ a = &attr->orig_attr;
+ snprintf(a->fw_ver, sizeof(a->fw_ver), "%d.%d.%04d",
+ major, minor, sub_minor);
+
+ return 0;
+}
+
+static int rwq_sig_enabled(struct ibv_context *context)
+{
+ char *env;
+
+ env = getenv("MLX5_RWQ_SIGNATURE");
+ if (env)
+ return 1;
+
+ return 0;
+}
+
+static void mlx5_free_rwq_buf(struct mlx5_rwq *rwq, struct ibv_context *context)
+{
+ struct mlx5_context *ctx = to_mctx(context);
+
+ mlx5_free_actual_buf(ctx, &rwq->buf);
+ free(rwq->rq.wrid);
+}
+
+static int mlx5_alloc_rwq_buf(struct ibv_context *context,
+ struct mlx5_rwq *rwq,
+ int size)
+{
+ int err;
+ enum mlx5_alloc_type default_alloc_type = MLX5_ALLOC_TYPE_PREFER_CONTIG;
+
+ rwq->rq.wrid = malloc(rwq->rq.wqe_cnt * sizeof(uint64_t));
+ if (!rwq->rq.wrid) {
+ errno = ENOMEM;
+ return -1;
+ }
+
+ err = mlx5_alloc_prefered_buf(to_mctx(context), &rwq->buf,
+ align(rwq->buf_size, to_mdev
+ (context->device)->page_size),
+ to_mdev(context->device)->page_size,
+ default_alloc_type,
+ MLX5_RWQ_PREFIX);
+
+ if (err) {
+ free(rwq->rq.wrid);
+ errno = ENOMEM;
+ return -1;
+ }
+
+ return 0;
+}
+
+struct ibv_wq *mlx5_create_wq(struct ibv_context *context,
+ struct ibv_wq_init_attr *attr)
+{
+ struct mlx5_create_wq cmd;
+ struct mlx5_create_wq_resp resp;
+ int err;
+ struct mlx5_rwq *rwq;
+ struct mlx5_context *ctx = to_mctx(context);
+ int ret;
+ int32_t usr_idx = 0;
+ FILE *fp = ctx->dbg_fp;
+
+ if (attr->wq_type != IBV_WQT_RQ)
+ return NULL;
+
+ memset(&cmd, 0, sizeof(cmd));
+ memset(&resp, 0, sizeof(resp));
+
+ rwq = calloc(1, sizeof(*rwq));
+ if (!rwq)
+ return NULL;
+
+ rwq->wq_sig = rwq_sig_enabled(context);
+ if (rwq->wq_sig)
+ cmd.drv.flags = MLX5_RWQ_FLAG_SIGNATURE;
+
+ ret = mlx5_calc_rwq_size(ctx, rwq, attr);
+ if (ret < 0) {
+ errno = -ret;
+ goto err;
+ }
+
+ rwq->buf_size = ret;
+ if (mlx5_alloc_rwq_buf(context, rwq, ret))
+ goto err;
+
+ mlx5_init_rwq_indices(rwq);
+
+ if (mlx5_spinlock_init(&rwq->rq.lock))
+ goto err_free_rwq_buf;
+
+ rwq->db = mlx5_alloc_dbrec(ctx);
+ if (!rwq->db)
+ goto err_free_rwq_buf;
+
+ rwq->db[MLX5_RCV_DBR] = 0;
+ rwq->db[MLX5_SND_DBR] = 0;
+ rwq->pbuff = rwq->buf.buf + rwq->rq.offset;
+ rwq->recv_db = &rwq->db[MLX5_RCV_DBR];
+ cmd.drv.buf_addr = (uintptr_t)rwq->buf.buf;
+ cmd.drv.db_addr = (uintptr_t)rwq->db;
+ cmd.drv.rq_wqe_count = rwq->rq.wqe_cnt;
+ cmd.drv.rq_wqe_shift = rwq->rq.wqe_shift;
+ usr_idx = mlx5_store_uidx(ctx, rwq);
+ if (usr_idx < 0) {
+ mlx5_dbg(fp, MLX5_DBG_QP, "Couldn't find free user index\n");
+ goto err_free_db_rec;
+ }
+
+ cmd.drv.user_index = usr_idx;
+ err = ibv_cmd_create_wq(context, attr, &rwq->wq, &cmd.ibv_cmd,
+ sizeof(cmd.ibv_cmd),
+ sizeof(cmd),
+ &resp.ibv_resp, sizeof(resp.ibv_resp),
+ sizeof(resp));
+ if (err)
+ goto err_create;
+
+ rwq->rsc.type = MLX5_RSC_TYPE_RWQ;
+ rwq->rsc.rsn = cmd.drv.user_index;
+
+ rwq->wq.post_recv = mlx5_post_wq_recv;
+ return &rwq->wq;
+
+err_create:
+ mlx5_clear_uidx(ctx, cmd.drv.user_index);
+err_free_db_rec:
+ mlx5_free_db(to_mctx(context), rwq->db);
+err_free_rwq_buf:
+ mlx5_free_rwq_buf(rwq, context);
+err:
+ free(rwq);
+ return NULL;
+}
+
+int mlx5_modify_wq(struct ibv_wq *wq, struct ibv_wq_attr *attr)
+{
+ struct mlx5_modify_wq cmd = {};
+ struct mlx5_rwq *rwq = to_mrwq(wq);
+
+ if ((attr->attr_mask & IBV_WQ_ATTR_STATE) &&
+ attr->wq_state == IBV_WQS_RDY) {
+ if ((attr->attr_mask & IBV_WQ_ATTR_CURR_STATE) &&
+ attr->curr_wq_state != wq->state)
+ return -EINVAL;
+
+ if (wq->state == IBV_WQS_RESET) {
+ mlx5_spin_lock(&to_mcq(wq->cq)->lock);
+ __mlx5_cq_clean(to_mcq(wq->cq),
+ rwq->rsc.rsn, NULL);
+ mlx5_spin_unlock(&to_mcq(wq->cq)->lock);
+ mlx5_init_rwq_indices(rwq);
+ rwq->db[MLX5_RCV_DBR] = 0;
+ rwq->db[MLX5_SND_DBR] = 0;
+ }
+ }
+
+ return ibv_cmd_modify_wq(wq, attr, &cmd.ibv_cmd, sizeof(cmd.ibv_cmd), sizeof(cmd));
+}
+
+int mlx5_destroy_wq(struct ibv_wq *wq)
+{
+ struct mlx5_rwq *rwq = to_mrwq(wq);
+ int ret;
+
+ ret = ibv_cmd_destroy_wq(wq);
+ if (ret)
+ return ret;
+
+ mlx5_spin_lock(&to_mcq(wq->cq)->lock);
+ __mlx5_cq_clean(to_mcq(wq->cq), rwq->rsc.rsn, NULL);
+ mlx5_spin_unlock(&to_mcq(wq->cq)->lock);
+ mlx5_clear_uidx(to_mctx(wq->context), rwq->rsc.rsn);
+ mlx5_free_db(to_mctx(wq->context), rwq->db);
+ mlx5_free_rwq_buf(rwq, wq->context);
+ free(rwq);
+
+ return 0;
+}
+
+struct ibv_rwq_ind_table *mlx5_create_rwq_ind_table(struct ibv_context *context,
+ struct ibv_rwq_ind_table_init_attr *init_attr)
+{
+ struct ibv_create_rwq_ind_table *cmd;
+ struct mlx5_create_rwq_ind_table_resp resp;
+ struct ibv_rwq_ind_table *ind_table;
+ uint32_t required_tbl_size;
+ int num_tbl_entries;
+ int cmd_size;
+ int err;
+
+ num_tbl_entries = 1 << init_attr->log_ind_tbl_size;
+ /* Data must be u64 aligned */
+ required_tbl_size = (num_tbl_entries * sizeof(uint32_t)) < sizeof(uint64_t) ?
+ sizeof(uint64_t) : (num_tbl_entries * sizeof(uint32_t));
+
+ cmd_size = required_tbl_size + sizeof(*cmd);
+ cmd = calloc(1, cmd_size);
+ if (!cmd)
+ return NULL;
+
+ memset(&resp, 0, sizeof(resp));
+ ind_table = calloc(1, sizeof(*ind_table));
+ if (!ind_table)
+ goto free_cmd;
+
+ err = ibv_cmd_create_rwq_ind_table(context, init_attr, ind_table, cmd,
+ cmd_size, cmd_size, &resp.ibv_resp, sizeof(resp.ibv_resp),
+ sizeof(resp));
+ if (err)
+ goto err;
+
+ free(cmd);
+ return ind_table;
+
+err:
+ free(ind_table);
+free_cmd:
+ free(cmd);
+ return NULL;
+}
+
+int mlx5_destroy_rwq_ind_table(struct ibv_rwq_ind_table *rwq_ind_table)
+{
+ int ret;
+
+ ret = ibv_cmd_destroy_rwq_ind_table(rwq_ind_table);
+
+ if (ret)
+ return ret;
+
+ free(rwq_ind_table);
+ return 0;
+}
diff --git a/contrib/ofed/libmlx5/wqe.h b/contrib/ofed/libmlx5/wqe.h
new file mode 100644
index 0000000..cbe05d3
--- /dev/null
+++ b/contrib/ofed/libmlx5/wqe.h
@@ -0,0 +1,190 @@
+/*
+ * Copyright (c) 2012 Mellanox Technologies, Inc. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#ifndef WQE_H
+#define WQE_H
+
+#include <stdint.h>
+
+struct mlx5_sg_copy_ptr {
+ int index;
+ int offset;
+};
+
+struct mlx5_eqe_comp {
+ uint32_t reserved[6];
+ uint32_t cqn;
+};
+
+struct mlx5_eqe_qp_srq {
+ uint32_t reserved[6];
+ uint32_t qp_srq_n;
+};
+
+struct mlx5_wqe_xrc_seg {
+ uint32_t xrc_srqn;
+ uint8_t rsvd[12];
+};
+
+struct mlx5_wqe_masked_atomic_seg {
+ uint64_t swap_add;
+ uint64_t compare;
+ uint64_t swap_add_mask;
+ uint64_t compare_mask;
+};
+
+enum {
+ MLX5_ETH_L2_INLINE_HEADER_SIZE = 18,
+ MLX5_ETH_L2_MIN_HEADER_SIZE = 14,
+};
+
+enum {
+ MLX5_WQE_UMR_CTRL_FLAG_INLINE = 1 << 7,
+ MLX5_WQE_UMR_CTRL_FLAG_CHECK_FREE = 1 << 5,
+ MLX5_WQE_UMR_CTRL_FLAG_TRNSLATION_OFFSET = 1 << 4,
+ MLX5_WQE_UMR_CTRL_FLAG_CHECK_QPN = 1 << 3,
+};
+
+enum {
+ MLX5_WQE_UMR_CTRL_MKEY_MASK_LEN = 1 << 0,
+ MLX5_WQE_UMR_CTRL_MKEY_MASK_START_ADDR = 1 << 6,
+ MLX5_WQE_UMR_CTRL_MKEY_MASK_MKEY = 1 << 13,
+ MLX5_WQE_UMR_CTRL_MKEY_MASK_QPN = 1 << 14,
+ MLX5_WQE_UMR_CTRL_MKEY_MASK_ACCESS_LOCAL_WRITE = 1 << 18,
+ MLX5_WQE_UMR_CTRL_MKEY_MASK_ACCESS_REMOTE_READ = 1 << 19,
+ MLX5_WQE_UMR_CTRL_MKEY_MASK_ACCESS_REMOTE_WRITE = 1 << 20,
+ MLX5_WQE_UMR_CTRL_MKEY_MASK_ACCESS_ATOMIC = 1 << 21,
+ MLX5_WQE_UMR_CTRL_MKEY_MASK_FREE = 1 << 29,
+};
+
+struct mlx5_wqe_umr_ctrl_seg {
+ uint8_t flags;
+ uint8_t rsvd0[3];
+ uint16_t klm_octowords;
+ uint16_t translation_offset;
+ uint64_t mkey_mask;
+ uint8_t rsvd1[32];
+};
+
+struct mlx5_wqe_umr_klm_seg {
+ /* up to 2GB */
+ uint32_t byte_count;
+ uint32_t mkey;
+ uint64_t address;
+};
+
+union mlx5_wqe_umr_inline_seg {
+ struct mlx5_wqe_umr_klm_seg klm;
+};
+
+enum {
+ MLX5_WQE_MKEY_CONTEXT_FREE = 1 << 6
+};
+
+enum {
+ MLX5_WQE_MKEY_CONTEXT_ACCESS_FLAGS_ATOMIC = 1 << 6,
+ MLX5_WQE_MKEY_CONTEXT_ACCESS_FLAGS_REMOTE_WRITE = 1 << 5,
+ MLX5_WQE_MKEY_CONTEXT_ACCESS_FLAGS_REMOTE_READ = 1 << 4,
+ MLX5_WQE_MKEY_CONTEXT_ACCESS_FLAGS_LOCAL_WRITE = 1 << 3,
+ MLX5_WQE_MKEY_CONTEXT_ACCESS_FLAGS_LOCAL_READ = 1 << 2
+};
+
+struct mlx5_wqe_mkey_context_seg {
+ uint8_t free;
+ uint8_t reserved1;
+ uint8_t access_flags;
+ uint8_t sf;
+ uint32_t qpn_mkey;
+ uint32_t reserved2;
+ uint32_t flags_pd;
+ uint64_t start_addr;
+ uint64_t len;
+ uint32_t bsf_octword_size;
+ uint32_t reserved3[4];
+ uint32_t translations_octword_size;
+ uint8_t reserved4[3];
+ uint8_t log_page_size;
+ uint32_t reserved;
+ union mlx5_wqe_umr_inline_seg inseg[0];
+};
+
+struct mlx5_seg_set_psv {
+ uint8_t rsvd[4];
+ uint16_t syndrome;
+ uint16_t status;
+ uint16_t block_guard;
+ uint16_t app_tag;
+ uint32_t ref_tag;
+ uint32_t mkey;
+ uint64_t va;
+};
+
+struct mlx5_seg_get_psv {
+ uint8_t rsvd[19];
+ uint8_t num_psv;
+ uint32_t l_key;
+ uint64_t va;
+ uint32_t psv_index[4];
+};
+
+struct mlx5_seg_check_psv {
+ uint8_t rsvd0[2];
+ uint16_t err_coalescing_op;
+ uint8_t rsvd1[2];
+ uint16_t xport_err_op;
+ uint8_t rsvd2[2];
+ uint16_t xport_err_mask;
+ uint8_t rsvd3[7];
+ uint8_t num_psv;
+ uint32_t l_key;
+ uint64_t va;
+ uint32_t psv_index[4];
+};
+
+struct mlx5_rwqe_sig {
+ uint8_t rsvd0[4];
+ uint8_t signature;
+ uint8_t rsvd1[11];
+};
+
+struct mlx5_wqe_signature_seg {
+ uint8_t rsvd0[4];
+ uint8_t signature;
+ uint8_t rsvd1[11];
+};
+
+struct mlx5_wqe_inline_seg {
+ uint32_t byte_count;
+};
+
+
+#endif /* WQE_H */
diff --git a/contrib/ofed/libmthca/AUTHORS b/contrib/ofed/libmthca/AUTHORS
deleted file mode 100644
index 165aea7..0000000
--- a/contrib/ofed/libmthca/AUTHORS
+++ /dev/null
@@ -1,2 +0,0 @@
-Roland Dreier <roland@topspin.com>
-Michael S. Tsirkin <mst@mellanox.co.il>
diff --git a/contrib/ofed/libmthca/COPYING b/contrib/ofed/libmthca/COPYING
deleted file mode 100644
index ee1a79ff..0000000
--- a/contrib/ofed/libmthca/COPYING
+++ /dev/null
@@ -1,378 +0,0 @@
-This software is available to you under a choice of one of two
-licenses. You may choose to be licensed under the terms of the the
-OpenIB.org BSD license or the GNU General Public License (GPL) Version
-2, both included below.
-
-Copyright (c) 2004 Topspin Communications. All rights reserved.
-
-==================================================================
-
- OpenIB.org BSD license
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions
-are met:
-
- * Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
-
- * Redistributions in binary form must reproduce the above
- copyright notice, this list of conditions and the following
- disclaimer in the documentation and/or other materials provided
- with the distribution.
-
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
-FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
-COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
-INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
-BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
-LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
-CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
-ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-POSSIBILITY OF SUCH DAMAGE.
-
-==================================================================
-
- GNU GENERAL PUBLIC LICENSE
- Version 2, June 1991
-
- Copyright (C) 1989, 1991 Free Software Foundation, Inc.
- 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- Everyone is permitted to copy and distribute verbatim copies
- of this license document, but changing it is not allowed.
-
- Preamble
-
- The licenses for most software are designed to take away your
-freedom to share and change it. By contrast, the GNU General Public
-License is intended to guarantee your freedom to share and change free
-software--to make sure the software is free for all its users. This
-General Public License applies to most of the Free Software
-Foundation's software and to any other program whose authors commit to
-using it. (Some other Free Software Foundation software is covered by
-the GNU Library General Public License instead.) You can apply it to
-your programs, too.
-
- When we speak of free software, we are referring to freedom, not
-price. Our General Public Licenses are designed to make sure that you
-have the freedom to distribute copies of free software (and charge for
-this service if you wish), that you receive source code or can get it
-if you want it, that you can change the software or use pieces of it
-in new free programs; and that you know you can do these things.
-
- To protect your rights, we need to make restrictions that forbid
-anyone to deny you these rights or to ask you to surrender the rights.
-These restrictions translate to certain responsibilities for you if you
-distribute copies of the software, or if you modify it.
-
- For example, if you distribute copies of such a program, whether
-gratis or for a fee, you must give the recipients all the rights that
-you have. You must make sure that they, too, receive or can get the
-source code. And you must show them these terms so they know their
-rights.
-
- We protect your rights with two steps: (1) copyright the software, and
-(2) offer you this license which gives you legal permission to copy,
-distribute and/or modify the software.
-
- Also, for each author's protection and ours, we want to make certain
-that everyone understands that there is no warranty for this free
-software. If the software is modified by someone else and passed on, we
-want its recipients to know that what they have is not the original, so
-that any problems introduced by others will not reflect on the original
-authors' reputations.
-
- Finally, any free program is threatened constantly by software
-patents. We wish to avoid the danger that redistributors of a free
-program will individually obtain patent licenses, in effect making the
-program proprietary. To prevent this, we have made it clear that any
-patent must be licensed for everyone's free use or not licensed at all.
-
- The precise terms and conditions for copying, distribution and
-modification follow.
-
- GNU GENERAL PUBLIC LICENSE
- TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
-
- 0. This License applies to any program or other work which contains
-a notice placed by the copyright holder saying it may be distributed
-under the terms of this General Public License. The "Program", below,
-refers to any such program or work, and a "work based on the Program"
-means either the Program or any derivative work under copyright law:
-that is to say, a work containing the Program or a portion of it,
-either verbatim or with modifications and/or translated into another
-language. (Hereinafter, translation is included without limitation in
-the term "modification".) Each licensee is addressed as "you".
-
-Activities other than copying, distribution and modification are not
-covered by this License; they are outside its scope. The act of
-running the Program is not restricted, and the output from the Program
-is covered only if its contents constitute a work based on the
-Program (independent of having been made by running the Program).
-Whether that is true depends on what the Program does.
-
- 1. You may copy and distribute verbatim copies of the Program's
-source code as you receive it, in any medium, provided that you
-conspicuously and appropriately publish on each copy an appropriate
-copyright notice and disclaimer of warranty; keep intact all the
-notices that refer to this License and to the absence of any warranty;
-and give any other recipients of the Program a copy of this License
-along with the Program.
-
-You may charge a fee for the physical act of transferring a copy, and
-you may at your option offer warranty protection in exchange for a fee.
-
- 2. You may modify your copy or copies of the Program or any portion
-of it, thus forming a work based on the Program, and copy and
-distribute such modifications or work under the terms of Section 1
-above, provided that you also meet all of these conditions:
-
- a) You must cause the modified files to carry prominent notices
- stating that you changed the files and the date of any change.
-
- b) You must cause any work that you distribute or publish, that in
- whole or in part contains or is derived from the Program or any
- part thereof, to be licensed as a whole at no charge to all third
- parties under the terms of this License.
-
- c) If the modified program normally reads commands interactively
- when run, you must cause it, when started running for such
- interactive use in the most ordinary way, to print or display an
- announcement including an appropriate copyright notice and a
- notice that there is no warranty (or else, saying that you provide
- a warranty) and that users may redistribute the program under
- these conditions, and telling the user how to view a copy of this
- License. (Exception: if the Program itself is interactive but
- does not normally print such an announcement, your work based on
- the Program is not required to print an announcement.)
-
-These requirements apply to the modified work as a whole. If
-identifiable sections of that work are not derived from the Program,
-and can be reasonably considered independent and separate works in
-themselves, then this License, and its terms, do not apply to those
-sections when you distribute them as separate works. But when you
-distribute the same sections as part of a whole which is a work based
-on the Program, the distribution of the whole must be on the terms of
-this License, whose permissions for other licensees extend to the
-entire whole, and thus to each and every part regardless of who wrote it.
-
-Thus, it is not the intent of this section to claim rights or contest
-your rights to work written entirely by you; rather, the intent is to
-exercise the right to control the distribution of derivative or
-collective works based on the Program.
-
-In addition, mere aggregation of another work not based on the Program
-with the Program (or with a work based on the Program) on a volume of
-a storage or distribution medium does not bring the other work under
-the scope of this License.
-
- 3. You may copy and distribute the Program (or a work based on it,
-under Section 2) in object code or executable form under the terms of
-Sections 1 and 2 above provided that you also do one of the following:
-
- a) Accompany it with the complete corresponding machine-readable
- source code, which must be distributed under the terms of Sections
- 1 and 2 above on a medium customarily used for software interchange; or,
-
- b) Accompany it with a written offer, valid for at least three
- years, to give any third party, for a charge no more than your
- cost of physically performing source distribution, a complete
- machine-readable copy of the corresponding source code, to be
- distributed under the terms of Sections 1 and 2 above on a medium
- customarily used for software interchange; or,
-
- c) Accompany it with the information you received as to the offer
- to distribute corresponding source code. (This alternative is
- allowed only for noncommercial distribution and only if you
- received the program in object code or executable form with such
- an offer, in accord with Subsection b above.)
-
-The source code for a work means the preferred form of the work for
-making modifications to it. For an executable work, complete source
-code means all the source code for all modules it contains, plus any
-associated interface definition files, plus the scripts used to
-control compilation and installation of the executable. However, as a
-special exception, the source code distributed need not include
-anything that is normally distributed (in either source or binary
-form) with the major components (compiler, kernel, and so on) of the
-operating system on which the executable runs, unless that component
-itself accompanies the executable.
-
-If distribution of executable or object code is made by offering
-access to copy from a designated place, then offering equivalent
-access to copy the source code from the same place counts as
-distribution of the source code, even though third parties are not
-compelled to copy the source along with the object code.
-
- 4. You may not copy, modify, sublicense, or distribute the Program
-except as expressly provided under this License. Any attempt
-otherwise to copy, modify, sublicense or distribute the Program is
-void, and will automatically terminate your rights under this License.
-However, parties who have received copies, or rights, from you under
-this License will not have their licenses terminated so long as such
-parties remain in full compliance.
-
- 5. You are not required to accept this License, since you have not
-signed it. However, nothing else grants you permission to modify or
-distribute the Program or its derivative works. These actions are
-prohibited by law if you do not accept this License. Therefore, by
-modifying or distributing the Program (or any work based on the
-Program), you indicate your acceptance of this License to do so, and
-all its terms and conditions for copying, distributing or modifying
-the Program or works based on it.
-
- 6. Each time you redistribute the Program (or any work based on the
-Program), the recipient automatically receives a license from the
-original licensor to copy, distribute or modify the Program subject to
-these terms and conditions. You may not impose any further
-restrictions on the recipients' exercise of the rights granted herein.
-You are not responsible for enforcing compliance by third parties to
-this License.
-
- 7. If, as a consequence of a court judgment or allegation of patent
-infringement or for any other reason (not limited to patent issues),
-conditions are imposed on you (whether by court order, agreement or
-otherwise) that contradict the conditions of this License, they do not
-excuse you from the conditions of this License. If you cannot
-distribute so as to satisfy simultaneously your obligations under this
-License and any other pertinent obligations, then as a consequence you
-may not distribute the Program at all. For example, if a patent
-license would not permit royalty-free redistribution of the Program by
-all those who receive copies directly or indirectly through you, then
-the only way you could satisfy both it and this License would be to
-refrain entirely from distribution of the Program.
-
-If any portion of this section is held invalid or unenforceable under
-any particular circumstance, the balance of the section is intended to
-apply and the section as a whole is intended to apply in other
-circumstances.
-
-It is not the purpose of this section to induce you to infringe any
-patents or other property right claims or to contest validity of any
-such claims; this section has the sole purpose of protecting the
-integrity of the free software distribution system, which is
-implemented by public license practices. Many people have made
-generous contributions to the wide range of software distributed
-through that system in reliance on consistent application of that
-system; it is up to the author/donor to decide if he or she is willing
-to distribute software through any other system and a licensee cannot
-impose that choice.
-
-This section is intended to make thoroughly clear what is believed to
-be a consequence of the rest of this License.
-
- 8. If the distribution and/or use of the Program is restricted in
-certain countries either by patents or by copyrighted interfaces, the
-original copyright holder who places the Program under this License
-may add an explicit geographical distribution limitation excluding
-those countries, so that distribution is permitted only in or among
-countries not thus excluded. In such case, this License incorporates
-the limitation as if written in the body of this License.
-
- 9. The Free Software Foundation may publish revised and/or new versions
-of the General Public License from time to time. Such new versions will
-be similar in spirit to the present version, but may differ in detail to
-address new problems or concerns.
-
-Each version is given a distinguishing version number. If the Program
-specifies a version number of this License which applies to it and "any
-later version", you have the option of following the terms and conditions
-either of that version or of any later version published by the Free
-Software Foundation. If the Program does not specify a version number of
-this License, you may choose any version ever published by the Free Software
-Foundation.
-
- 10. If you wish to incorporate parts of the Program into other free
-programs whose distribution conditions are different, write to the author
-to ask for permission. For software which is copyrighted by the Free
-Software Foundation, write to the Free Software Foundation; we sometimes
-make exceptions for this. Our decision will be guided by the two goals
-of preserving the free status of all derivatives of our free software and
-of promoting the sharing and reuse of software generally.
-
- NO WARRANTY
-
- 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
-FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
-OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
-PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
-OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
-MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
-TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
-PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
-REPAIR OR CORRECTION.
-
- 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
-WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
-REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
-INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
-OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
-TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
-YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
-PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
-POSSIBILITY OF SUCH DAMAGES.
-
- END OF TERMS AND CONDITIONS
-
- How to Apply These Terms to Your New Programs
-
- If you develop a new program, and you want it to be of the greatest
-possible use to the public, the best way to achieve this is to make it
-free software which everyone can redistribute and change under these terms.
-
- To do so, attach the following notices to the program. It is safest
-to attach them to the start of each source file to most effectively
-convey the exclusion of warranty; and each file should have at least
-the "copyright" line and a pointer to where the full notice is found.
-
- <one line to give the program's name and a brief idea of what it does.>
- Copyright (C) <year> <name of author>
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program 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 this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-
-Also add information on how to contact you by electronic and paper mail.
-
-If the program is interactive, make it output a short notice like this
-when it starts in an interactive mode:
-
- Gnomovision version 69, Copyright (C) year name of author
- Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
- This is free software, and you are welcome to redistribute it
- under certain conditions; type `show c' for details.
-
-The hypothetical commands `show w' and `show c' should show the appropriate
-parts of the General Public License. Of course, the commands you use may
-be called something other than `show w' and `show c'; they could even be
-mouse-clicks or menu items--whatever suits your program.
-
-You should also get your employer (if you work as a programmer) or your
-school, if any, to sign a "copyright disclaimer" for the program, if
-necessary. Here is a sample; alter the names:
-
- Yoyodyne, Inc., hereby disclaims all copyright interest in the program
- `Gnomovision' (which makes passes at compilers) written by James Hacker.
-
- <signature of Ty Coon>, 1 April 1989
- Ty Coon, President of Vice
-
-This General Public License does not permit incorporating your program into
-proprietary programs. If your program is a subroutine library, you may
-consider it more useful to permit linking proprietary applications with the
-library. If this is what you want to do, use the GNU Library General
-Public License instead of this License.
diff --git a/contrib/ofed/libmthca/ChangeLog b/contrib/ofed/libmthca/ChangeLog
deleted file mode 100644
index 015ed38..0000000
--- a/contrib/ofed/libmthca/ChangeLog
+++ /dev/null
@@ -1,378 +0,0 @@
-2006-11-09 Roland Dreier <rdreier@cisco.com>
-
- * Release version 1.0.3.
-
-2006-10-17 Roland Dreier <rdreier@cisco.com>
-
- * src/cq.c, src/qp.c, src/srq.c: Convert existing uses of mb() to
- rmb() or wmb() as appropriate. In fact all memory barriers were
- really just wmb(), except for the barrier between reading a CQE's
- ownership bit and contents, which should be rmb().
-
- * src/mthca.h: Add compatibility defines of rmb()/wmb() so that
- libmthca continues to build against old libibverbs releases.
-
-2006-10-03 Roland Dreier <rdreier@cisco.com>
-
- * src/cq.c (mthca_poll_one): Annotate so that Valgrind knows
- contents of CQ entry are all valid after they are written by HCA.
- (set_cqe_hw): Annotate so that CQ entries owned by hardware are
- not defined.
-
- * src/mthca.h: Add wrapper for VALGRIND_MAKE_MEM_DEFINED so that
- it can be used in .c files without worrying about whether Valgrind
- is installed or enabled.
-
- * configure.in: Add support for Valgrind annotation (enabled with
- --with-valgrind option to configure).
-
- * src/verbs.c (mthca_create_qp): Set reserved fields to 0 to avoid
- future problems and also to make Valgrind a little quieter.
-
-2006-09-04 Roland Dreier <rdreier@cisco.com>
-
- * src/verbs.c (mthca_destroy_qp): Avoid potential AB-BA deadlock
- when destroying QPs by always taking CQ locks in a consistent
- order (lowest CQN first). The old code always took the send_cq
- lock first, which is prone to deadlock if the send_cq of one QP is
- the recv_cq of another QP destroyed at the same time. This bug
- was pointed out by Dotan Barak and Jack Morgenstein.
-
-2006-08-23 Roland Dreier <rdreier@cisco.com>
-
- * src/verbs.c (mthca_resize_cq): Add a test for
- IBV_CMD_RESIZE_CQ_HAS_RESP_PARAMS to make libmthca work with newer
- libibverbs libraries that add two parameters to ibv_cmd_resize_cq().
-
-2006-08-09 Michael S. Tsirkin <mst@mellanox.co.il>
-
- * src/qp.c (mthca_tavor_post_send, mthca_arbel_post_send): Fence
- bit must be set in both doorbell and WQE.
-
-2006-08-03 Jack Morgenstein <jackm@mellanox.co.il>
-
- * src/mthca.h: Include <stddef.h> to get definition of offsetof().
-
-2006-08-03 Michael S. Tsirkin <mst@mellanox.co.il>
-
- * src/verbs.c (mthca_create_srq): Limit SRQ max_wr to avoid
- integer overflow.
-
-2006-07-26 Roland Dreier <rdreier@cisco.com>
-
- * src/mthca.h, src/ah.c, src/cq.c, src/memfree.c, src/qp.c,
- src/srq.c, src/verbs.c: Convert internal allocations for AH pages
- (for non-memfree HCAs), CQ buffers, doorbell pages (for memfree
- HCAs), QP buffers and SRQ buffers to use the new buffer
- allocator. This makes libmthca fork()-clean when built against
- libibverbs 1.1.
-
- * src/buf.c (mthca_alloc_buf, mthca_free_buf): Add new functions
- to wrap up allocating page-aligned buffers. The new functions
- will call ibv_dontfork_range()/ibv_dofork_range() to do proper
- madvise()ing to handle fork(), if applicable.
-
- * configure.in: Check for ibv_dontfork_range() and ibv_dontfork_range().
-
-2006-07-04 Dotan Barak <dotanb@mellanox.co.il>
-
- * src/verbs.c (mthca_create_cq, mthca_resize_cq): Passing huge
- size values to create_cq/resize_cq causes a hang in
- align_cq_size(). Fix this by validating input, similiar to what
- we do for mthca_create_qp() and mthca_create_srq().
-
-2006-06-13 Roland Dreier <rdreier@cisco.com>
-
- * Release version 1.0.2.
-
-2006-06-13 Michael S. Tsirkin <mst@mellanox.co.il>
-
- * src/cq.c (mthca_poll_one): Add workaround for MemFree FW bug
- that causes wrong WQE addr to be reported.
-
-2006-05-24 Roland Dreier <rdreier@cisco.com>
-
- * src/mthca.c: If <sysfs/libsysfs.h> is detected, include it
- explicitly. This lets things build when sysfs headers are
- installed on the build system even when building against
- libibverbs 1.1 (which does not include sysfs headers implicitly).
-
- * src/ah.c, src/cq.c, src/memfree.c, src/mthca.c, src/qp.c,
- src/srq.c: Add include of <string.h>, since it may no long be
- implicitly included from libsysfs headers when building with
- libibverbs 1.1.
-
-2006-05-24 Michael S. Tsirkin <mst@mellanox.co.il>
-
- * src/srq.c (mthca_tavor_post_srq_recv): Fix posting of lists of
- receives that have exactly a multiple of 256 entries (same as QP
- bug fixed below).
-
-2006-05-22 Roland Dreier <rdreier@cisco.com>
-
- * configure.in, src/mthca.c (openib_driver_init): Check for the
- presence of <sysfs/libsysfs.h>, and if it is not installed, don't
- export the old openib_driver_init() entry point.
-
-2006-05-18 Michael S. Tsirkin <mst@mellanox.co.il>
-
- * src/qp.c (mthca_tavor_post_recv): Fix posting of lists of
- receives that have exactly a multiple of 256 entries.
-
-2006-05-08 Jack Morgenstein <jackm@mellanox.co.il>
-
- * src/mthca.c: Add include files needed for open() if
- HAVE_IBV_READ_SYSFS_FILE is not defined (so libmthca includes a
- private local definition of ibv_read_sysfs_file()).
-
-2006-04-11 Roland Dreier <rdreier@cisco.com>
-
- * src/mthca.c (ibv_driver_init, openib_driver_init): Add new
- forward-compatible driver entry point. Make old entry point a
- simple wrapper for the new one.
-
-2006-03-14 Roland Dreier <rdreier@cisco.com>
-
- * Release version 1.0.1.
-
- * Makefile.am (EXTRA_DIST): Remove debian/ directory from
- tarballs, since Debian policy is that upstream tarballs should not
- include it.
-
-2006-03-13 Roland Dreier <rdreier@cisco.com>
-
- * Release version 1.0.
-
-2006-02-27 Dotan Barak <dotanb@mellanox.co.il>
-
- * src/qp.c (mthca_tavor_post_send, mthca_arbel_post_send): Add
- support for IBV_SEND_FENCE flag.
-
-2006-02-16 Roland Dreier <rdreier@cisco.com>
-
- * src/memfree.c (mthca_alloc_db): Introduce a temporary variable
- to pass to posix_memalign() to avoid "warning: dereferencing
- type-punned pointer will break strict-aliasing rules."
-
- * Release version 1.0-rc7.
-
-2006-02-15 Roland Dreier <rdreier@cisco.com>
-
- * src/verbs.c (mthca_create_qp): Update to add new response and
- response size parameters for libibverbs ibv_cmd_create_qp().
-
-2006-02-14 Roland Dreier <rdreier@cisco.com>
-
- * Release version 1.0-rc6.
-
-2006-02-13 Dotan Barak <dotanb@mellanox.co.il>
-
- * src/verbs.c (mthca_query_qp, mthca_query_srq): Add query QP and
- query SRQ verbs.
-
-2006-01-31 Roland Dreier <rdreier@cisco.com>
-
- * src/mthca.h: Remove useless "extern" from function declarations.
-
-2006-01-30 Michael S. Tsirkin <mst@mellanox.co.il>
-
- * src/qp.c (mthca_tavor_post_recv, mthca_arbel_post_recv): Pass
- recv_cq to wq_overflow() so we lock the correct CQ. Noticed by
- Yossi Leybovich.
-
-2006-01-26 Roland Dreier <rdreier@cisco.com>
-
- * src/mthca.h, src/verbs.c, src/cq.c, src/mthca.c: Add
- implementation of resize CQ operation.
-
- * src/mthca-abi.h: Add mthca-specific resize CQ ABI.
-
-2006-01-22 Roland Dreier <rdreier@cisco.com>
-
- * Release version 1.0-rc5.
-
-2006-01-11 Jack Morgenstein <jackm@mellanox.co.il>
-
- * src/verbs.c (mthca_free_pd): Free pointer to correct structure
- (we get lucky now, but don't rely on this).
- * src/mthca.c (mthca_free_context): Free context's PD so we don't
- leak it.
-
-2006-01-06 Michael S. Tsirkin <mst@mellanox.co.il>
-
- * src/verbs.c (mthca_destroy_qp): Jack Morgenstein has discovered
- the following race condition in libmthca:
-
- Thread A destroys QP A at the kernel side by calling
- ibv_cmd_destroy_qp, but its time-slice is over before removing it
- from the user-space qp_table removal.
-
- Thread B allocates QP B, receiving a QP number that matches the
- just-destroyed QP A in the low 16 bits. Thread B will now
- over-write the slot in qp_table which was used for QP A.
-
- Thread A wakes up and clears qp_table slot, in effect removing QP
- B from qp_table.
-
- As a solution, remove the QP from qp_table before calling
- ibv_cmd_destroy_qp. This also makes sense since operations are
- performed in the reverse order in create_qp.
-
- * src/cq.c (handle_error_cqe): Fill in vendor_err field for
- completions with error.
-
-2006-01-05 Jack Morgenstein <jackm@mellanox.co.il>
-
- * src/verbs.c (mthca_destroy_qp, mthca_destroy_srq): Free QP/SRQ
- object to avoid memory leak.
-
-2005-12-15 Jack Morgenstein <jackm@mellanox.co.il>
-
- * src/cq.c (mthca_cq_clean): When cleaning up a CQ, we should free
- an SRQ WQE if and only if the CQE is a receive.
-
-2005-12-15 Michael S. Tsirkin <mst@mellanox.co.il>
-
- * src/qp.c (mthca_store_qp): Don't increment qp_table ref count if
- allocation fails.
-
-2005-11-29 Michael S. Tsirkin <mst@mellanox.co.il>
-
- * src/qp.c (mthca_arbel_post_send): Add handling for posting long
- send lists for mem-free HCAs.
- * src/qp.c (mthca_tavor_post_recv): Fix posting long receive
- lists: nreq is set to zero early on, so we need to use
- MTHCA_TAVOR_MAX_WQES_PER_RECV_DB as the increment to rq.head.
-
-2005-11-28 Roland Dreier <roland@cisco.com>
-
- * src/qp.c (mthca_init_qp_indices): Set qp->sq.last and
- qp->rq.last so that QP is fully reset when the indices are
- reinited on transition to RESET state.
- (mthca_tavor_post_send, mthca_arbel_post_send): Don't create an
- inline send segment when a work request is posted that has the
- inline flag set but no gather entries included.
-
-2005-11-09 Roland Dreier <roland@cisco.com>
-
- * src/srq.c (mthca_tavor_post_srq_recv), src/qp.c
- (mthca_tavor_post_recv): Fix bugs in long receive list handling;
- need to set nreq to 0 and not put 256 credits into the second
- doorbell word.
-
- * src/cq.c (mthca_cq_clean): Handle case where CQ indices wrap
- around by treating signed comparisons of prod_index and
- cq->cons_index carefully.
-
-2005-11-09 Michael S. Tsirkin <mst@mellanox.co.il>
-
- * src/srq.c (mthca_tavor_post_srq_recv), src/qp.c
- (mthca_tavor_post_recv): Tavor requires that a doorbell be rung
- at least every 256 receives, so add code to ring doorbells in the
- middle of posting a huge list of receives.
-
- * src/qp.c (mthca_tavor_post_send, mthca_tavor_post_send): When
- posting atomic operations, could wqe size in "octowords" correctly.
-
- * src/ah.c (mthca_alloc_av): Don't free ah if page allocation
- fails. It will be freed where it's allocated, in the caller.
-
-2005-11-08 Roland Dreier <roland@cisco.com>
-
- * src/qp.c, src/verbs.c, src/mthca.h: Delegate setting of QP
- capabilities (max_sge, max_inline_data, etc) to kernel.
-
-2005-11-04 Roland Dreier <roland@cisco.com>
-
- * src/verbs.c (mthca_destroy_qp): Clean CQEs when we destroy a QP.
- (mthca_modify_qp): Clean CQEs when we move a QP to RESET state,
- and reset QP index pointers.
-
- * src/cq.c (mthca_cq_clean): Add function to clean out CQEs for
- QPs that are being destroyed or reset.
-
-2005-10-30 Roland Dreier <roland@cisco.com>
-
- * src/srq.c (wqe_to_link): Change to use an offset of 12 (the imm
- field), because posting an SRQ WQE may actually change the ee_nds
- field and still cause free list corruption. A receive WQE will
- never have immediate data, so using imm is definitely safe.
-
-2005-10-25 Roland Dreier <roland@cisco.com>
-
- * Release version 1.0-rc4.
-
-2005-10-23 Roland Dreier <roland@cisco.com>
-
- * src/qp.c (mthca_return_cap, mthca_alloc_qp_buf), src/verbs.c
- (mthca_create_qp): Explicitly pass QP type to functions used while
- creating QP, since we can't rely on ibv_qp.qp_type to be set until
- after we return. This fixes breakage with UD QPs introduced in
- the last change below.
-
-2005-10-19 Roland Dreier <roland@cisco.com>
-
- * src/mthca.h, src/verbs.c (mthca_create_qp), src/qp.c
- (mthca_tavor_post_send, mthca_arbel_post_send, mthca_alloc_qp_buf,
- mthca_return_cap): Eliminate struct mthca_qp.qpt field and use
- struct ibv_qp.qp_type instead (now that that field has been added
- in libibverbs).
-
-2005-10-18 Roland Dreier <roland@cisco.com>
-
- * src/cq.c (handle_error_cqe, mthca_poll_one): Dump CQEs for local
- QP operation errors instead of all error statuses.
-
-2005-10-06 Roland Dreier <roland@cisco.com>
-
- * src/srq.c (mthca_free_srq_wqe): Pass index instead of WQE
- address. The only caller already has the index handy, so there's
- no need to recalculate it here.
-
- * src/srq.c (mthca_tavor_post_srq_recv,
- mthca_arbel_post_srq_recv): Add an extra check so that we report
- the SRQ as full before using the one extra WQE we need internally.
-
-2005-10-05 Roland Dreier <roland@cisco.com>
-
- * src/verbs.c (mthca_modify_srq): Fill in mthca_modify_srq().
-
-2005-09-29 Roland Dreier <roland@cisco.com>
-
- * src/verbs.c (mthca_query_device): Update to match new libibverbs
- API that requires device-specific libraries to format firmware version.
-
-2005-09-25 Roland Dreier <roland@cisco.com>
-
- * src/cq.c, src/mthca.c, src/mthca.h, src/verbs.c: Update to match
- new libibverbs API introduced with completion channel implementation.
-
-2005-09-13 Roland Dreier <roland@cisco.com>
-
- * src/qp.c (mthca_tavor_post_send, mthca_tavor_post_recv,
- mthca_arbel_post_send), src/srq.c (mthca_tavor_post_srq_recv):
- Apply Michael S. Tsirkin's patch to fix linking of WQEs on
- mem-free HCAs. While we're at it, simplify the Tavor WQE posting
- code as well -- there's no need for a conditional, just always lik
- the previous WQE.
-
-2005-09-07 Roland Dreier <roland@cisco.com>
-
- * src/mthca.h: Get rid of ntohll() and htonll() now that
- libibverbs defines them in <infiniband/arch.h>.
-
-2005-08-31 Roland Dreier <roland@cisco.com>
-
- * src/memfree.c (mthca_free_db): When we free a doorbell record,
- really mark it as free in the free bitmap. This we we don't
- eventually run out of doorbells if a consumer creates and frees a
- lot of objects.
-
- * src/memfree.c (mthca_alloc_db): Introduce MTHCA_FREE_MAP_SIZE so
- that we iterate over the correct number of entries in the mem-free
- doorbell record free maps. This fixes some off-by-a-factor-of-8
- bugs that could lead to crashes.
-
- * src/verbs.c (mthca_create_cq): In the mem-free case, when
- creating a CQ fails to allocate an arm doorbell, make sure we free
- the set CI doorbell instead of the (non-existent) arm doorbell.
diff --git a/contrib/ofed/libmthca/Makefile.am b/contrib/ofed/libmthca/Makefile.am
deleted file mode 100644
index e9be461..0000000
--- a/contrib/ofed/libmthca/Makefile.am
+++ /dev/null
@@ -1,29 +0,0 @@
-AM_CFLAGS = -g -Wall -D_GNU_SOURCE
-
-mthca_version_script = @MTHCA_VERSION_SCRIPT@
-
-MTHCA_SOURCES = src/ah.c src/buf.c src/cq.c src/memfree.c src/mthca.c \
- src/qp.c src/srq.c src/verbs.c
-
-if HAVE_IBV_DEVICE_LIBRARY_EXTENSION
- lib_LTLIBRARIES = src/libmthca.la
- src_libmthca_la_SOURCES = $(MTHCA_SOURCES)
- src_libmthca_la_LDFLAGS = -avoid-version -release @IBV_DEVICE_LIBRARY_EXTENSION@ \
- $(mthca_version_script)
- mthcaconfdir = $(sysconfdir)/libibverbs.d
- mthcaconf_DATA = mthca.driver
-else
- mthcalibdir = $(libdir)/infiniband
- mthcalib_LTLIBRARIES = src/mthca.la
- src_mthca_la_SOURCES = $(MTHCA_SOURCES)
- src_mthca_la_LDFLAGS = -avoid-version -module $(mthca_version_script)
-endif
-
-DEBIAN = debian/changelog debian/compat debian/control debian/copyright \
- debian/libmthca1.install debian/libmthca-dev.install debian/rules
-
-EXTRA_DIST = src/doorbell.h src/mthca.h src/mthca-abi.h src/wqe.h \
- src/mthca.map libmthca.spec.in mthca.driver
-
-dist-hook: libmthca.spec
- cp libmthca.spec $(distdir)
diff --git a/contrib/ofed/libmthca/README b/contrib/ofed/libmthca/README
deleted file mode 100644
index 88636f8..0000000
--- a/contrib/ofed/libmthca/README
+++ /dev/null
@@ -1,59 +0,0 @@
-Introduction
-============
-
-libmthca is a userspace driver for Mellanox InfiniBand HCAs. It works
-as a plug-in module for libibverbs that allows programs to use
-Mellanox hardware directly from userspace. See the libibverbs package
-for more information.
-
-Using libmthca
-==============
-
-libmthca will be loaded and used automatically by programs linked with
-libibverbs. The ib_mthca kernel module must be loaded for HCA devices
-to be detected and used.
-
-Supported Hardware
-==================
-
-libmthca currently supports HCAs based on the following Mellanox chips:
-
- MT23108 InfiniHost (PCI-X)
- MT25208 InfiniHost III Ex (PCI Express)
- MT25204 InfiniHost III Lx (PCI Express)
-
-Both non-DDR and DDR HCAs are supported, and the MT25208 is supported
-with both MT23108-compatible and native MemFree firmware.
-
-Valgrind Support
-================
-
-When running applications that use libibverbs under the Valgrind
-memory-checking debugger, Valgrind will falsely report "read from
-uninitialized" for memory that was initialized by the kernel drivers
-or HCA hardware. Specifically, Valgrind cannot see when kernel
-drivers or HCA hardware write to userspace memory, so when the process
-reads from that memory, Valgrind incorrectly assumes that the memory
-contents are uninitialized, and therefore raises a warning.
-
-libmthca can be built with specific support for the Valgrind
-memory-checking debugger by specifying the --with-valgrind command
-line argument to configure. This flag enables code in libibverbs to
-tell Valgrind "this memory may look uninitialized, but it's really
-OK," which therefore suppresses the incorrect "read from
-uninitialized" warnings. This code adds trivial overhead to the
-critical performance path, so it is disabled by default. The intent
-is that production users can use a "normal" build of libmthca and
-developers can use the "valgrind debug" build by simply switching
-their OPENIB_DRIVER_PATH environment variables.
-
-Libmthca needs some header files from Valgrind in order to compile
-this support; it is important to use the header files from the same
-version of Valgrind that will be used at run time. You may need to
-specify the directory where Valgrind's header files are installed as
-an argument to --with-valgrind. For example
-
- ./configure --with-valgrind=/opt/valgrind
-
-will make the libmthca build look for valgrind headers in
-/opt/valgrind/include
diff --git a/contrib/ofed/libmthca/autogen.sh b/contrib/ofed/libmthca/autogen.sh
deleted file mode 100755
index fd47839..0000000
--- a/contrib/ofed/libmthca/autogen.sh
+++ /dev/null
@@ -1,8 +0,0 @@
-#! /bin/sh
-
-set -x
-aclocal -I config
-libtoolize --force --copy
-autoheader
-automake --foreign --add-missing --copy
-autoconf
diff --git a/contrib/ofed/libmthca/configure.in b/contrib/ofed/libmthca/configure.in
deleted file mode 100644
index e3b38dd..0000000
--- a/contrib/ofed/libmthca/configure.in
+++ /dev/null
@@ -1,77 +0,0 @@
-dnl Process this file with autoconf to produce a configure script.
-
-AC_PREREQ(2.57)
-AC_INIT(libmthca, 1.0.5, openib-general@openib.org)
-AC_CONFIG_SRCDIR([src/mthca.h])
-AC_CONFIG_AUX_DIR(config)
-AM_CONFIG_HEADER(config.h)
-AM_INIT_AUTOMAKE(libmthca, 1.0.5)
-AM_PROG_LIBTOOL
-
-AC_ARG_WITH([valgrind],
- AC_HELP_STRING([--with-valgrind],
- [Enable Valgrind annotations (small runtime overhead, default NO)]))
-if test x$with_valgrind = x || test x$with_valgrind = xno; then
- want_valgrind=no
- AC_DEFINE([NVALGRIND], 1, [Define to 1 to disable Valgrind annotations.])
-else
- want_valgrind=yes
- if test -d $with_valgrind; then
- CPPFLAGS="$CPPFLAGS -I$with_valgrind/include"
- fi
-fi
-
-dnl Checks for programs
-AC_PROG_CC
-
-dnl Checks for libraries
-AC_CHECK_LIB(ibverbs, ibv_get_device_list, [],
- AC_MSG_ERROR([ibv_get_device_list() not found. libmthca requires libibverbs.]))
-
-dnl Checks for header files.
-AC_CHECK_HEADER(infiniband/driver.h, [],
- AC_MSG_ERROR([<infiniband/driver.h> not found. libmthca requires libibverbs.]))
-AC_HEADER_STDC
-AC_CHECK_HEADER(valgrind/memcheck.h,
- [AC_DEFINE(HAVE_VALGRIND_MEMCHECK_H, 1,
- [Define to 1 if you have the <valgrind/memcheck.h> header file.])],
- [if test $want_valgrind = yes; then
- AC_MSG_ERROR([Valgrind memcheck support requested, but <valgrind/memcheck.h> not found.])
- fi])
-
-dnl Checks for typedefs, structures, and compiler characteristics.
-AC_C_CONST
-AC_CHECK_SIZEOF(long)
-
-dnl Checks for library functions
-AC_CHECK_FUNCS(ibv_read_sysfs_file ibv_dontfork_range ibv_dofork_range \
- ibv_register_driver)
-
-dnl Now check if for libibverbs 1.0 vs 1.1
-dummy=if$$
-cat <<IBV_VERSION > $dummy.c
-#include <infiniband/driver.h>
-IBV_DEVICE_LIBRARY_EXTENSION
-IBV_VERSION
-IBV_DEVICE_LIBRARY_EXTENSION=`$CC $CPPFLAGS -E $dummy.c 2> /dev/null | tail -1`
-rm -f $dummy.c
-AM_CONDITIONAL(HAVE_IBV_DEVICE_LIBRARY_EXTENSION,
- test $IBV_DEVICE_LIBRARY_EXTENSION != IBV_DEVICE_LIBRARY_EXTENSION)
-AC_SUBST(IBV_DEVICE_LIBRARY_EXTENSION)
-
-AC_CACHE_CHECK(whether ld accepts --version-script, ac_cv_version_script,
- [if test -n "`$LD --help < /dev/null 2>/dev/null | grep version-script`"; then
- ac_cv_version_script=yes
- else
- ac_cv_version_script=no
- fi])
-
-if test $ac_cv_version_script = yes; then
- MTHCA_VERSION_SCRIPT='-Wl,--version-script=$(srcdir)/src/mthca.map'
-else
- MTHCA_VERSION_SCRIPT=
-fi
-AC_SUBST(MTHCA_VERSION_SCRIPT)
-
-AC_CONFIG_FILES([Makefile libmthca.spec])
-AC_OUTPUT
diff --git a/contrib/ofed/libmthca/debian/changelog b/contrib/ofed/libmthca/debian/changelog
deleted file mode 100644
index 1e0c3f6..0000000
--- a/contrib/ofed/libmthca/debian/changelog
+++ /dev/null
@@ -1,45 +0,0 @@
-libmthca (1.0.5-1) unstable; urgency=low
-
- * New upstream release.
- - Fix issues on non-mem-free HCAs.
- - Fix problems with completion entry cleanup.
- * Replace deprecated ${Source-Version} with ${binary:Version}
- * Add debian/watch file.
- * Update libtool during build to avoid setting RPATH in binaries on amd64.
-
- -- Roland Dreier <rolandd@cisco.com> Tue, 27 May 2008 14:19:55 -0700
-
-libmthca (1.0.4-1) unstable; urgency=low
-
- * New upstream release.
- * Rebuild against libibverbs 1.1.
-
- -- Roland Dreier <rolandd@cisco.com> Mon, 30 Apr 2007 17:11:51 -0700
-
-libmthca (1.0.3-1) unstable; urgency=low
-
- * New upstream release.
- - Fix various integer overflows.
- - Fix potential AB-BA deadlock when destroying QPs.
- - Add more forward compat against future libibverbs releases.
- * Build against libibverbs 1.0.4, with fixed sparc mb() definition.
- (Closes: #365559)
- * Improve package description.
-
- -- Roland Dreier <rolandd@cisco.com> Thu, 9 Nov 2006 11:07:58 -0800
-
-libmthca (1.0.2-1) unstable; urgency=low
-
- * New upstream release:
- - Work around MemFree firmware bug in receive completions with error.
- - Fix posting receive lists with exactly a multiple of 256 entries.
- - Add forward compatibility for future libibverbs releases.
- * Update to Standards-Version: 3.7.2.
-
- -- Roland Dreier <rolandd@cisco.com> Tue, 13 Jun 2006 11:33:32 -0700
-
-libmthca (1.0.1-1) unstable; urgency=low
-
- * Initial Release. (Closes: #325753)
-
- -- Roland Dreier <rolandd@cisco.com> Wed, 15 Feb 2006 11:22:18 -0700
diff --git a/contrib/ofed/libmthca/debian/compat b/contrib/ofed/libmthca/debian/compat
deleted file mode 100644
index 7ed6ff8..0000000
--- a/contrib/ofed/libmthca/debian/compat
+++ /dev/null
@@ -1 +0,0 @@
-5
diff --git a/contrib/ofed/libmthca/debian/control.in b/contrib/ofed/libmthca/debian/control.in
deleted file mode 100644
index e58114d..0000000
--- a/contrib/ofed/libmthca/debian/control.in
+++ /dev/null
@@ -1,47 +0,0 @@
-Source: libmthca
-Priority: extra
-Maintainer: Roland Dreier <rolandd@cisco.com>
-Build-Depends: @cdbs@, dpkg-dev (>= 1.13.19), libibverbs-dev (>= 1.1)
-Standards-Version: 3.7.3
-Section: libs
-Homepage: http://www.openfabrics.org/
-
-Package: libmthca1
-Section: libs
-Architecture: any
-Depends: ${shlibs:Depends}, ${misc:Depends}
-Description: A userspace driver for Mellanox InfiniBand HCAs
- libmthca is a device-specific driver for Mellanox InfiniBand host
- channel adapters (HCAs) for the libibverbs library. This allows
- userspace processes to access Mellanox HCA hardware directly with
- low latency and low overhead.
- .
- This package contains the loadable plug-in.
-
-Package: libmthca-dev
-Section: libdevel
-Architecture: any
-Depends: ${misc:Depends}, libmthca1 (= ${binary:Version})
-Description: Development files for the libmthca driver
- libmthca is a device-specific driver for Mellanox InfiniBand host
- channel adapters (HCAs) for the libibverbs library. This allows
- userspace processes to access Mellanox HCA hardware directly with
- low latency and low overhead.
- .
- This package contains static versions of libmthca that may be linked
- directly to an application, which may be useful for debugging.
-
-Package: libmthca1-dbg
-Section: libdevel
-Priority: extra
-Architecture: any
-Depends: ${misc:Depends}, libmthca1 (= ${binary:Version})
-Description: Debugging symbols for the libmthca driver
- libmthca is a device-specific driver for Mellanox InfiniBand host
- channel adapters (HCAs) for the libibverbs library. This allows
- userspace processes to access Mellanox HCA hardware directly with
- low latency and low overhead.
- .
- This package contains the debugging symbols associated with
- libmthca1. They will automatically be used by gdb for debugging
- libmthca-related issues.
diff --git a/contrib/ofed/libmthca/debian/copyright b/contrib/ofed/libmthca/debian/copyright
deleted file mode 100644
index 04abee0..0000000
--- a/contrib/ofed/libmthca/debian/copyright
+++ /dev/null
@@ -1,44 +0,0 @@
-Initial Debianization:
-This package was debianized by Roland Dreier <rolandd@cisco.com> on
-Thu, 28 Apr 2005 13:16:56 -0700.
-
-Source:
-It was downloaded from the OpenIB web site at
-<https://openib.org/downloads.html>
-
-Authors:
- Roland Dreier <roland@topspin.com>
- Michael S. Tsirkin <mst@mellanox.co.il>
-
-Portions are copyrighted by:
- * Copyright (c) 2005, 2006 Cisco Systems. All rights reserved.
- * Copyright (c) 2004, 2005 Topspin Communications. All rights reserved.
- * Copyright (c) 2005 Mellanox Technologies Ltd. All rights reserved.
-
-libmthca is licensed under a choice of one of two licenses. You may
-choose to be licensed under the terms of the GNU General Public
-License (GPL) Version 2, available from the file
-/usr/share/common-licenses/GPL-2 on your Debian system, or the
-OpenIB.org BSD license below:
-
- Redistribution and use in source and binary forms, with or
- without modification, are permitted provided that the following
- conditions are met:
-
- - Redistributions of source code must retain the above
- copyright notice, this list of conditions and the following
- disclaimer.
-
- - Redistributions in binary form must reproduce the above
- copyright notice, this list of conditions and the following
- disclaimer in the documentation and/or other materials
- provided with the distribution.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
-BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
-ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
-CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-SOFTWARE.
diff --git a/contrib/ofed/libmthca/debian/libmthca-dev.install b/contrib/ofed/libmthca/debian/libmthca-dev.install
deleted file mode 100644
index 5b815a3..0000000
--- a/contrib/ofed/libmthca/debian/libmthca-dev.install
+++ /dev/null
@@ -1 +0,0 @@
-usr/lib/libmthca.{a,la}
diff --git a/contrib/ofed/libmthca/debian/libmthca1.install b/contrib/ofed/libmthca/debian/libmthca1.install
deleted file mode 100644
index 090fcc7..0000000
--- a/contrib/ofed/libmthca/debian/libmthca1.install
+++ /dev/null
@@ -1,2 +0,0 @@
-usr/lib/libmthca-rdmav2.so
-etc/libibverbs.d/mthca.driver
diff --git a/contrib/ofed/libmthca/debian/rules b/contrib/ofed/libmthca/debian/rules
deleted file mode 100755
index 3e70bc3..0000000
--- a/contrib/ofed/libmthca/debian/rules
+++ /dev/null
@@ -1,8 +0,0 @@
-#!/usr/bin/make -f
-# -*- mode: makefile; coding: utf-8 -*-
-
-DEB_DH_INSTALL_SOURCEDIR := debian/tmp
-DEB_AUTO_UPDATE_LIBTOOL := post
-
-include /usr/share/cdbs/1/rules/debhelper.mk
-include /usr/share/cdbs/1/class/autotools.mk
diff --git a/contrib/ofed/libmthca/debian/watch b/contrib/ofed/libmthca/debian/watch
deleted file mode 100644
index 8010f86..0000000
--- a/contrib/ofed/libmthca/debian/watch
+++ /dev/null
@@ -1,3 +0,0 @@
-version=3
-opts="uversionmangle=s/-rc/~rc/" \
- http://www.openfabrics.org/downloads/mthca/libmthca-(.+)\.tar\.gz
diff --git a/contrib/ofed/libmthca/libmthca.spec.in b/contrib/ofed/libmthca/libmthca.spec.in
deleted file mode 100644
index 163b481..0000000
--- a/contrib/ofed/libmthca/libmthca.spec.in
+++ /dev/null
@@ -1,94 +0,0 @@
-Name: libmthca
-Version: 1.0.5
-Release: 1%{?dist}
-Summary: Mellanox InfiniBand HCA Userspace Driver
-
-Group: System Environment/Libraries
-License: GPLv2 or BSD
-Url: http://openfabrics.org/
-Source: http://openfabrics.org/downloads/mthca/libmthca-1.0.5.tar.gz
-BuildRoot: %(mktemp -ud %{_tmppath}/%{name}-%{version}-%{release}-XXXXXX)
-
-BuildRequires: libibverbs-devel >= 1.1-0.1.rc2
-
-%description
-libmthca provides a device-specific userspace driver for Mellanox HCAs
-(MT23108 InfiniHost and MT25208 InfiniHost III Ex) for use with the
-libibverbs library.
-
-%package devel-static
-Summary: Development files for the libmthca driver
-Group: System Environment/Libraries
-Requires: %{name} = %{version}-%{release}
-
-%description devel-static
-Static version of libmthca that may be linked directly to an
-application, which may be useful for debugging.
-
-%prep
-%setup -q -n %{name}-@VERSION@
-
-%build
-%configure
-make %{?_smp_mflags}
-
-%install
-rm -rf $RPM_BUILD_ROOT
-make DESTDIR=%{buildroot} install
-# remove unpackaged files from the buildroot
-rm -f $RPM_BUILD_ROOT%{_libdir}/*.la $RPM_BUILD_ROOT%{_libdir}/libmthca.so
-
-%clean
-rm -rf $RPM_BUILD_ROOT
-
-%files
-%defattr(-,root,root,-)
-%{_libdir}/libmthca-rdmav2.so
-%{_sysconfdir}/libibverbs.d/mthca.driver
-%doc AUTHORS COPYING ChangeLog README
-
-%files devel-static
-%defattr(-,root,root,-)
-%{_libdir}/libmthca.a
-
-%changelog
-* Tue May 27 2008 Roland Dreier <rolandd@cisco.com> - 1.0.5-1
-- New upstream release
-- Change openib.org URLs to openfabrics.org URLs
-
-* Thu May 22 2008 Todd Zullinger <tmz@pobox.com> - 1.0.4-3
-- fix license tag
-
-* Mon Feb 18 2008 Fedora Release Engineering <rel-eng@fedoraproject.org> - 1.0.4-2
-- Autorebuild for GCC 4.3
-
-* Thu Nov 9 2006 Roland Dreier <rdreier@cisco.com> - 1.0.4-1
-- New upstream release
-- Depend on libibverbs 1.1, and package new library file names.
-- Spec file cleanups: remove unused ver macro, improve BuildRoot, move
- static libraries into devel-static package, and don't use makeinstall
- any more (all suggested by Doug Ledford <dledford@redhat.com>).
-
-* Wed Jul 26 2006 Roland Dreier <rdreier@cisco.com> - 1.0.3-1
-- New upstream release
-
-* Mon Mar 14 2006 Roland Dreier <rdreier@cisco.com> - 1.0.2-1
-- New upstream release
-
-* Thu Feb 16 2006 Roland Dreier <rdreier@cisco.com> - 1.0-1
-- New upstream release
-
-* Sun Feb 15 2006 Roland Dreier <rolandd@cisco.com> - 1.0-0.5.rc7
-- New upstream release
-
-* Sun Jan 22 2006 Roland Dreier <rolandd@cisco.com> - 1.0-0.4.rc6
-- New upstream release
-
-* Tue Oct 25 2005 Roland Dreier <rolandd@cisco.com> - 1.0-0.3.rc5
-- New upstream release
-
-* Wed Oct 5 2005 Roland Dreier <rolandd@cisco.com> - 1.0-0.2.rc4
-- Update to upstream 1.0-rc4 release
-
-* Mon Sep 26 2005 Roland Dreier <rolandd@cisco.com> - 1.0-0.1.rc3
-- Initial attempt at Fedora Extras-compliant spec file
diff --git a/contrib/ofed/libmthca/mthca.driver b/contrib/ofed/libmthca/mthca.driver
deleted file mode 100644
index 5880a47..0000000
--- a/contrib/ofed/libmthca/mthca.driver
+++ /dev/null
@@ -1 +0,0 @@
-driver mthca
diff --git a/contrib/ofed/libmthca/src/ah.c b/contrib/ofed/libmthca/src/ah.c
deleted file mode 100644
index d7494d5..0000000
--- a/contrib/ofed/libmthca/src/ah.c
+++ /dev/null
@@ -1,191 +0,0 @@
-/*
- * Copyright (c) 2005 Topspin Communications. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-#if HAVE_CONFIG_H
-# include <config.h>
-#endif /* HAVE_CONFIG_H */
-
-#include <stdlib.h>
-#include <netinet/in.h>
-#include <pthread.h>
-#include <string.h>
-
-#include "mthca.h"
-
-struct mthca_ah_page {
- struct mthca_ah_page *prev, *next;
- struct mthca_buf buf;
- struct ibv_mr *mr;
- int use_cnt;
- unsigned free[0];
-};
-
-static struct mthca_ah_page *__add_page(struct mthca_pd *pd, int page_size, int per_page)
-{
- struct mthca_ah_page *page;
- int i;
-
- page = malloc(sizeof *page + per_page * sizeof (int));
- if (!page)
- return NULL;
-
- if (mthca_alloc_buf(&page->buf, page_size, page_size)) {
- free(page);
- return NULL;
- }
-
- page->mr = mthca_reg_mr(&pd->ibv_pd, page->buf.buf, page_size, 0);
- if (!page->mr) {
- mthca_free_buf(&page->buf);
- free(page);
- return NULL;
- }
-
- page->mr->context = pd->ibv_pd.context;
-
- page->use_cnt = 0;
- for (i = 0; i < per_page; ++i)
- page->free[i] = ~0;
-
- page->prev = NULL;
- page->next = pd->ah_list;
- pd->ah_list = page;
- if (page->next)
- page->next->prev = page;
-
- return page;
-}
-
-int mthca_alloc_av(struct mthca_pd *pd, struct ibv_ah_attr *attr,
- struct mthca_ah *ah)
-{
- if (mthca_is_memfree(pd->ibv_pd.context)) {
- ah->av = malloc(sizeof *ah->av);
- if (!ah->av)
- return -1;
- } else {
- struct mthca_ah_page *page;
- int ps;
- int pp;
- int i, j;
-
- ps = to_mdev(pd->ibv_pd.context->device)->page_size;
- pp = ps / (sizeof *ah->av * 8 * sizeof (int));
-
- pthread_mutex_lock(&pd->ah_mutex);
- for (page = pd->ah_list; page; page = page->next)
- if (page->use_cnt < ps / sizeof *ah->av)
- for (i = 0; i < pp; ++i)
- if (page->free[i])
- goto found;
-
- page = __add_page(pd, ps, pp);
- if (!page) {
- pthread_mutex_unlock(&pd->ah_mutex);
- return -1;
- }
-
- found:
- ++page->use_cnt;
-
- for (i = 0, j = -1; i < pp; ++i)
- if (page->free[i]) {
- j = ffs(page->free[i]);
- page->free[i] &= ~(1 << (j - 1));
- ah->av = page->buf.buf +
- (i * 8 * sizeof (int) + (j - 1)) * sizeof *ah->av;
- break;
- }
-
- ah->key = page->mr->lkey;
- ah->page = page;
-
- pthread_mutex_unlock(&pd->ah_mutex);
- }
-
- memset(ah->av, 0, sizeof *ah->av);
-
- ah->av->port_pd = htonl(pd->pdn | (attr->port_num << 24));
- ah->av->g_slid = attr->src_path_bits;
- ah->av->dlid = htons(attr->dlid);
- ah->av->msg_sr = (3 << 4) | /* 2K message */
- attr->static_rate;
- ah->av->sl_tclass_flowlabel = htonl(attr->sl << 28);
- if (attr->is_global) {
- ah->av->g_slid |= 0x80;
- /* XXX get gid_table length */
- ah->av->gid_index = (attr->port_num - 1) * 32 +
- attr->grh.sgid_index;
- ah->av->hop_limit = attr->grh.hop_limit;
- ah->av->sl_tclass_flowlabel |=
- htonl((attr->grh.traffic_class << 20) |
- attr->grh.flow_label);
- memcpy(ah->av->dgid, attr->grh.dgid.raw, 16);
- } else {
- /* Arbel workaround -- low byte of GID must be 2 */
- ah->av->dgid[3] = htonl(2);
- }
-
- return 0;
-}
-
-void mthca_free_av(struct mthca_ah *ah)
-{
- if (mthca_is_memfree(ah->ibv_ah.context)) {
- free(ah->av);
- } else {
- struct mthca_pd *pd = to_mpd(ah->ibv_ah.pd);
- struct mthca_ah_page *page;
- int i;
-
- pthread_mutex_lock(&pd->ah_mutex);
-
- page = ah->page;
- i = ((void *) ah->av - page->buf.buf) / sizeof *ah->av;
- page->free[i / (8 * sizeof (int))] |= 1 << (i % (8 * sizeof (int)));
-
- if (!--page->use_cnt) {
- if (page->prev)
- page->prev->next = page->next;
- else
- pd->ah_list = page->next;
- if (page->next)
- page->next->prev = page->prev;
-
- mthca_dereg_mr(page->mr);
- mthca_free_buf(&page->buf);
- free(page);
- }
-
- pthread_mutex_unlock(&pd->ah_mutex);
- }
-}
diff --git a/contrib/ofed/libmthca/src/buf.c b/contrib/ofed/libmthca/src/buf.c
deleted file mode 100644
index 6c1be4f..0000000
--- a/contrib/ofed/libmthca/src/buf.c
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- * Copyright (c) 2006 Cisco Systems, Inc. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-#if HAVE_CONFIG_H
-# include <config.h>
-#endif /* HAVE_CONFIG_H */
-
-#include <stdlib.h>
-
-#include "mthca.h"
-
-#if !(defined(HAVE_IBV_DONTFORK_RANGE) && defined(HAVE_IBV_DOFORK_RANGE))
-
-/*
- * If libibverbs isn't exporting these functions, then there's no
- * point in doing it here, because the rest of libibverbs isn't going
- * to be fork-safe anyway.
- */
-static int ibv_dontfork_range(void *base, size_t size)
-{
- return 0;
-}
-
-static int ibv_dofork_range(void *base, size_t size)
-{
- return 0;
-}
-
-#endif /* HAVE_IBV_DONTFORK_RANGE && HAVE_IBV_DOFORK_RANGE */
-
-int mthca_alloc_buf(struct mthca_buf *buf, size_t size, int page_size)
-{
- int ret;
-
- ret = posix_memalign(&buf->buf, page_size, align(size, page_size));
- if (ret)
- return ret;
-
- ret = ibv_dontfork_range(buf->buf, size);
- if (ret)
- free(buf->buf);
-
- if (!ret)
- buf->length = size;
-
- return ret;
-}
-
-void mthca_free_buf(struct mthca_buf *buf)
-{
- ibv_dofork_range(buf->buf, buf->length);
- free(buf->buf);
-}
diff --git a/contrib/ofed/libmthca/src/cq.c b/contrib/ofed/libmthca/src/cq.c
deleted file mode 100644
index 24ff0aa..0000000
--- a/contrib/ofed/libmthca/src/cq.c
+++ /dev/null
@@ -1,633 +0,0 @@
-/*
- * Copyright (c) 2005 Topspin Communications. All rights reserved.
- * Copyright (c) 2005 Mellanox Technologies Ltd. All rights reserved.
- * Copyright (c) 2006 Cisco Systems. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-#if HAVE_CONFIG_H
-# include <config.h>
-#endif /* HAVE_CONFIG_H */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <pthread.h>
-#include <netinet/in.h>
-#include <string.h>
-
-#include <infiniband/opcode.h>
-
-#include "mthca.h"
-#include "doorbell.h"
-
-enum {
- MTHCA_CQ_DOORBELL = 0x20
-};
-
-enum {
- CQ_OK = 0,
- CQ_EMPTY = -1,
- CQ_POLL_ERR = -2
-};
-
-#define MTHCA_TAVOR_CQ_DB_INC_CI (1 << 24)
-#define MTHCA_TAVOR_CQ_DB_REQ_NOT (2 << 24)
-#define MTHCA_TAVOR_CQ_DB_REQ_NOT_SOL (3 << 24)
-#define MTHCA_TAVOR_CQ_DB_SET_CI (4 << 24)
-#define MTHCA_TAVOR_CQ_DB_REQ_NOT_MULT (5 << 24)
-
-#define MTHCA_ARBEL_CQ_DB_REQ_NOT_SOL (1 << 24)
-#define MTHCA_ARBEL_CQ_DB_REQ_NOT (2 << 24)
-#define MTHCA_ARBEL_CQ_DB_REQ_NOT_MULT (3 << 24)
-
-enum {
- MTHCA_CQ_ENTRY_OWNER_SW = 0x00,
- MTHCA_CQ_ENTRY_OWNER_HW = 0x80,
- MTHCA_ERROR_CQE_OPCODE_MASK = 0xfe
-};
-
-enum {
- SYNDROME_LOCAL_LENGTH_ERR = 0x01,
- SYNDROME_LOCAL_QP_OP_ERR = 0x02,
- SYNDROME_LOCAL_EEC_OP_ERR = 0x03,
- SYNDROME_LOCAL_PROT_ERR = 0x04,
- SYNDROME_WR_FLUSH_ERR = 0x05,
- SYNDROME_MW_BIND_ERR = 0x06,
- SYNDROME_BAD_RESP_ERR = 0x10,
- SYNDROME_LOCAL_ACCESS_ERR = 0x11,
- SYNDROME_REMOTE_INVAL_REQ_ERR = 0x12,
- SYNDROME_REMOTE_ACCESS_ERR = 0x13,
- SYNDROME_REMOTE_OP_ERR = 0x14,
- SYNDROME_RETRY_EXC_ERR = 0x15,
- SYNDROME_RNR_RETRY_EXC_ERR = 0x16,
- SYNDROME_LOCAL_RDD_VIOL_ERR = 0x20,
- SYNDROME_REMOTE_INVAL_RD_REQ_ERR = 0x21,
- SYNDROME_REMOTE_ABORTED_ERR = 0x22,
- SYNDROME_INVAL_EECN_ERR = 0x23,
- SYNDROME_INVAL_EEC_STATE_ERR = 0x24
-};
-
-struct mthca_cqe {
- uint32_t my_qpn;
- uint32_t my_ee;
- uint32_t rqpn;
- uint16_t sl_g_mlpath;
- uint16_t rlid;
- uint32_t imm_etype_pkey_eec;
- uint32_t byte_cnt;
- uint32_t wqe;
- uint8_t opcode;
- uint8_t is_send;
- uint8_t reserved;
- uint8_t owner;
-};
-
-struct mthca_err_cqe {
- uint32_t my_qpn;
- uint32_t reserved1[3];
- uint8_t syndrome;
- uint8_t vendor_err;
- uint16_t db_cnt;
- uint32_t reserved2;
- uint32_t wqe;
- uint8_t opcode;
- uint8_t reserved3[2];
- uint8_t owner;
-};
-
-static inline struct mthca_cqe *get_cqe(struct mthca_cq *cq, int entry)
-{
- return cq->buf.buf + entry * MTHCA_CQ_ENTRY_SIZE;
-}
-
-static inline struct mthca_cqe *cqe_sw(struct mthca_cq *cq, int i)
-{
- struct mthca_cqe *cqe = get_cqe(cq, i);
- return MTHCA_CQ_ENTRY_OWNER_HW & cqe->owner ? NULL : cqe;
-}
-
-static inline struct mthca_cqe *next_cqe_sw(struct mthca_cq *cq)
-{
- return cqe_sw(cq, cq->cons_index & cq->ibv_cq.cqe);
-}
-
-static inline void set_cqe_hw(struct mthca_cqe *cqe)
-{
- VALGRIND_MAKE_MEM_UNDEFINED(cqe, sizeof *cqe);
- cqe->owner = MTHCA_CQ_ENTRY_OWNER_HW;
-}
-
-/*
- * incr is ignored in native Arbel (mem-free) mode, so cq->cons_index
- * should be correct before calling update_cons_index().
- */
-static inline void update_cons_index(struct mthca_cq *cq, int incr)
-{
- uint32_t doorbell[2];
-
- if (mthca_is_memfree(cq->ibv_cq.context)) {
- *cq->set_ci_db = htonl(cq->cons_index);
- wmb();
- } else {
- doorbell[0] = htonl(MTHCA_TAVOR_CQ_DB_INC_CI | cq->cqn);
- doorbell[1] = htonl(incr - 1);
-
- mthca_write64(doorbell, to_mctx(cq->ibv_cq.context), MTHCA_CQ_DOORBELL);
- }
-}
-
-static void dump_cqe(void *cqe_ptr)
-{
- uint32_t *cqe = cqe_ptr;
- int i;
-
- for (i = 0; i < 8; ++i)
- printf(" [%2x] %08x\n", i * 4, ntohl(((uint32_t *) cqe)[i]));
-}
-
-static int handle_error_cqe(struct mthca_cq *cq,
- struct mthca_qp *qp, int wqe_index, int is_send,
- struct mthca_err_cqe *cqe,
- struct ibv_wc *wc, int *free_cqe)
-{
- int err;
- int dbd;
- uint32_t new_wqe;
-
- if (cqe->syndrome == SYNDROME_LOCAL_QP_OP_ERR) {
- printf("local QP operation err "
- "(QPN %06x, WQE @ %08x, CQN %06x, index %d)\n",
- ntohl(cqe->my_qpn), ntohl(cqe->wqe),
- cq->cqn, cq->cons_index);
- dump_cqe(cqe);
- }
-
- /*
- * For completions in error, only work request ID, status, vendor error
- * (and freed resource count for RD) have to be set.
- */
- switch (cqe->syndrome) {
- case SYNDROME_LOCAL_LENGTH_ERR:
- wc->status = IBV_WC_LOC_LEN_ERR;
- break;
- case SYNDROME_LOCAL_QP_OP_ERR:
- wc->status = IBV_WC_LOC_QP_OP_ERR;
- break;
- case SYNDROME_LOCAL_EEC_OP_ERR:
- wc->status = IBV_WC_LOC_EEC_OP_ERR;
- break;
- case SYNDROME_LOCAL_PROT_ERR:
- wc->status = IBV_WC_LOC_PROT_ERR;
- break;
- case SYNDROME_WR_FLUSH_ERR:
- wc->status = IBV_WC_WR_FLUSH_ERR;
- break;
- case SYNDROME_MW_BIND_ERR:
- wc->status = IBV_WC_MW_BIND_ERR;
- break;
- case SYNDROME_BAD_RESP_ERR:
- wc->status = IBV_WC_BAD_RESP_ERR;
- break;
- case SYNDROME_LOCAL_ACCESS_ERR:
- wc->status = IBV_WC_LOC_ACCESS_ERR;
- break;
- case SYNDROME_REMOTE_INVAL_REQ_ERR:
- wc->status = IBV_WC_REM_INV_REQ_ERR;
- break;
- case SYNDROME_REMOTE_ACCESS_ERR:
- wc->status = IBV_WC_REM_ACCESS_ERR;
- break;
- case SYNDROME_REMOTE_OP_ERR:
- wc->status = IBV_WC_REM_OP_ERR;
- break;
- case SYNDROME_RETRY_EXC_ERR:
- wc->status = IBV_WC_RETRY_EXC_ERR;
- break;
- case SYNDROME_RNR_RETRY_EXC_ERR:
- wc->status = IBV_WC_RNR_RETRY_EXC_ERR;
- break;
- case SYNDROME_LOCAL_RDD_VIOL_ERR:
- wc->status = IBV_WC_LOC_RDD_VIOL_ERR;
- break;
- case SYNDROME_REMOTE_INVAL_RD_REQ_ERR:
- wc->status = IBV_WC_REM_INV_RD_REQ_ERR;
- break;
- case SYNDROME_REMOTE_ABORTED_ERR:
- wc->status = IBV_WC_REM_ABORT_ERR;
- break;
- case SYNDROME_INVAL_EECN_ERR:
- wc->status = IBV_WC_INV_EECN_ERR;
- break;
- case SYNDROME_INVAL_EEC_STATE_ERR:
- wc->status = IBV_WC_INV_EEC_STATE_ERR;
- break;
- default:
- wc->status = IBV_WC_GENERAL_ERR;
- break;
- }
-
- wc->vendor_err = cqe->vendor_err;
-
- /*
- * Mem-free HCAs always generate one CQE per WQE, even in the
- * error case, so we don't have to check the doorbell count, etc.
- */
- if (mthca_is_memfree(cq->ibv_cq.context))
- return 0;
-
- err = mthca_free_err_wqe(qp, is_send, wqe_index, &dbd, &new_wqe);
- if (err)
- return err;
-
- /*
- * If we're at the end of the WQE chain, or we've used up our
- * doorbell count, free the CQE. Otherwise just update it for
- * the next poll operation.
- *
- * This doesn't apply to mem-free HCAs, which never use the
- * doorbell count field. In that case we always free the CQE.
- */
- if (mthca_is_memfree(cq->ibv_cq.context) ||
- !(new_wqe & htonl(0x3f)) || (!cqe->db_cnt && dbd))
- return 0;
-
- cqe->db_cnt = htons(ntohs(cqe->db_cnt) - dbd);
- cqe->wqe = new_wqe;
- cqe->syndrome = SYNDROME_WR_FLUSH_ERR;
-
- *free_cqe = 0;
-
- return 0;
-}
-
-static inline int mthca_poll_one(struct mthca_cq *cq,
- struct mthca_qp **cur_qp,
- int *freed,
- struct ibv_wc *wc)
-{
- struct mthca_wq *wq;
- struct mthca_cqe *cqe;
- struct mthca_srq *srq;
- uint32_t qpn;
- uint32_t wqe;
- int wqe_index;
- int is_error;
- int is_send;
- int free_cqe = 1;
- int err = 0;
-
- cqe = next_cqe_sw(cq);
- if (!cqe)
- return CQ_EMPTY;
-
- VALGRIND_MAKE_MEM_DEFINED(cqe, sizeof *cqe);
-
- /*
- * Make sure we read CQ entry contents after we've checked the
- * ownership bit.
- */
- rmb();
-
- qpn = ntohl(cqe->my_qpn);
-
- is_error = (cqe->opcode & MTHCA_ERROR_CQE_OPCODE_MASK) ==
- MTHCA_ERROR_CQE_OPCODE_MASK;
- is_send = is_error ? cqe->opcode & 0x01 : cqe->is_send & 0x80;
-
- if (!*cur_qp || ntohl(cqe->my_qpn) != (*cur_qp)->ibv_qp.qp_num) {
- /*
- * We do not have to take the QP table lock here,
- * because CQs will be locked while QPs are removed
- * from the table.
- */
- *cur_qp = mthca_find_qp(to_mctx(cq->ibv_cq.context), ntohl(cqe->my_qpn));
- if (!*cur_qp) {
- err = CQ_POLL_ERR;
- goto out;
- }
- }
-
- wc->qp_num = (*cur_qp)->ibv_qp.qp_num;
-
- if (is_send) {
- wq = &(*cur_qp)->sq;
- wqe_index = ((ntohl(cqe->wqe) - (*cur_qp)->send_wqe_offset) >> wq->wqe_shift);
- wc->wr_id = (*cur_qp)->wrid[wqe_index + (*cur_qp)->rq.max];
- } else if ((*cur_qp)->ibv_qp.srq) {
- srq = to_msrq((*cur_qp)->ibv_qp.srq);
- wqe = htonl(cqe->wqe);
- wq = NULL;
- wqe_index = wqe >> srq->wqe_shift;
- wc->wr_id = srq->wrid[wqe_index];
- mthca_free_srq_wqe(srq, wqe_index);
- } else {
- int32_t wqe;
- wq = &(*cur_qp)->rq;
- wqe = ntohl(cqe->wqe);
- wqe_index = wqe >> wq->wqe_shift;
- /*
- * WQE addr == base - 1 might be reported by Sinai FW
- * 1.0.800 and Arbel FW 5.1.400 in receive completion
- * with error instead of (rq size - 1). This bug
- * should be fixed in later FW revisions.
- */
- if (wqe_index < 0)
- wqe_index = wq->max - 1;
- wc->wr_id = (*cur_qp)->wrid[wqe_index];
- }
-
- if (wq) {
- if (wq->last_comp < wqe_index)
- wq->tail += wqe_index - wq->last_comp;
- else
- wq->tail += wqe_index + wq->max - wq->last_comp;
-
- wq->last_comp = wqe_index;
- }
-
- if (is_error) {
- err = handle_error_cqe(cq, *cur_qp, wqe_index, is_send,
- (struct mthca_err_cqe *) cqe,
- wc, &free_cqe);
- goto out;
- }
-
- if (is_send) {
- wc->wc_flags = 0;
- switch (cqe->opcode) {
- case MTHCA_OPCODE_RDMA_WRITE:
- wc->opcode = IBV_WC_RDMA_WRITE;
- break;
- case MTHCA_OPCODE_RDMA_WRITE_IMM:
- wc->opcode = IBV_WC_RDMA_WRITE;
- wc->wc_flags |= IBV_WC_WITH_IMM;
- break;
- case MTHCA_OPCODE_SEND:
- wc->opcode = IBV_WC_SEND;
- break;
- case MTHCA_OPCODE_SEND_IMM:
- wc->opcode = IBV_WC_SEND;
- wc->wc_flags |= IBV_WC_WITH_IMM;
- break;
- case MTHCA_OPCODE_RDMA_READ:
- wc->opcode = IBV_WC_RDMA_READ;
- wc->byte_len = ntohl(cqe->byte_cnt);
- break;
- case MTHCA_OPCODE_ATOMIC_CS:
- wc->opcode = IBV_WC_COMP_SWAP;
- wc->byte_len = ntohl(cqe->byte_cnt);
- break;
- case MTHCA_OPCODE_ATOMIC_FA:
- wc->opcode = IBV_WC_FETCH_ADD;
- wc->byte_len = ntohl(cqe->byte_cnt);
- break;
- case MTHCA_OPCODE_BIND_MW:
- wc->opcode = IBV_WC_BIND_MW;
- break;
- default:
- /* assume it's a send completion */
- wc->opcode = IBV_WC_SEND;
- break;
- }
- } else {
- wc->byte_len = ntohl(cqe->byte_cnt);
- switch (cqe->opcode & 0x1f) {
- case IBV_OPCODE_SEND_LAST_WITH_IMMEDIATE:
- case IBV_OPCODE_SEND_ONLY_WITH_IMMEDIATE:
- wc->wc_flags = IBV_WC_WITH_IMM;
- wc->imm_data = cqe->imm_etype_pkey_eec;
- wc->opcode = IBV_WC_RECV;
- break;
- case IBV_OPCODE_RDMA_WRITE_LAST_WITH_IMMEDIATE:
- case IBV_OPCODE_RDMA_WRITE_ONLY_WITH_IMMEDIATE:
- wc->wc_flags = IBV_WC_WITH_IMM;
- wc->imm_data = cqe->imm_etype_pkey_eec;
- wc->opcode = IBV_WC_RECV_RDMA_WITH_IMM;
- break;
- default:
- wc->wc_flags = 0;
- wc->opcode = IBV_WC_RECV;
- break;
- }
- wc->slid = ntohs(cqe->rlid);
- wc->sl = ntohs(cqe->sl_g_mlpath) >> 12;
- wc->src_qp = ntohl(cqe->rqpn) & 0xffffff;
- wc->dlid_path_bits = ntohs(cqe->sl_g_mlpath) & 0x7f;
- wc->pkey_index = ntohl(cqe->imm_etype_pkey_eec) >> 16;
- wc->wc_flags |= ntohs(cqe->sl_g_mlpath) & 0x80 ?
- IBV_WC_GRH : 0;
- }
-
- wc->status = IBV_WC_SUCCESS;
-
-out:
- if (free_cqe) {
- set_cqe_hw(cqe);
- ++(*freed);
- ++cq->cons_index;
- }
-
- return err;
-}
-
-int mthca_poll_cq(struct ibv_cq *ibcq, int ne, struct ibv_wc *wc)
-{
- struct mthca_cq *cq = to_mcq(ibcq);
- struct mthca_qp *qp = NULL;
- int npolled;
- int err = CQ_OK;
- int freed = 0;
-
- pthread_spin_lock(&cq->lock);
-
- for (npolled = 0; npolled < ne; ++npolled) {
- err = mthca_poll_one(cq, &qp, &freed, wc + npolled);
- if (err != CQ_OK)
- break;
- }
-
- if (freed) {
- wmb();
- update_cons_index(cq, freed);
- }
-
- pthread_spin_unlock(&cq->lock);
-
- return err == CQ_POLL_ERR ? err : npolled;
-}
-
-int mthca_tavor_arm_cq(struct ibv_cq *cq, int solicited)
-{
- uint32_t doorbell[2];
-
- doorbell[0] = htonl((solicited ?
- MTHCA_TAVOR_CQ_DB_REQ_NOT_SOL :
- MTHCA_TAVOR_CQ_DB_REQ_NOT) |
- to_mcq(cq)->cqn);
- doorbell[1] = 0xffffffff;
-
- mthca_write64(doorbell, to_mctx(cq->context), MTHCA_CQ_DOORBELL);
-
- return 0;
-}
-
-int mthca_arbel_arm_cq(struct ibv_cq *ibvcq, int solicited)
-{
- struct mthca_cq *cq = to_mcq(ibvcq);
- uint32_t doorbell[2];
- uint32_t sn;
- uint32_t ci;
-
- sn = cq->arm_sn & 3;
- ci = htonl(cq->cons_index);
-
- doorbell[0] = ci;
- doorbell[1] = htonl((cq->cqn << 8) | (2 << 5) | (sn << 3) |
- (solicited ? 1 : 2));
-
- mthca_write_db_rec(doorbell, cq->arm_db);
-
- /*
- * Make sure that the doorbell record in host memory is
- * written before ringing the doorbell via PCI MMIO.
- */
- wmb();
-
- doorbell[0] = htonl((sn << 28) |
- (solicited ?
- MTHCA_ARBEL_CQ_DB_REQ_NOT_SOL :
- MTHCA_ARBEL_CQ_DB_REQ_NOT) |
- cq->cqn);
- doorbell[1] = ci;
-
- mthca_write64(doorbell, to_mctx(ibvcq->context), MTHCA_CQ_DOORBELL);
-
- return 0;
-}
-
-void mthca_arbel_cq_event(struct ibv_cq *cq)
-{
- to_mcq(cq)->arm_sn++;
-}
-
-static inline int is_recv_cqe(struct mthca_cqe *cqe)
-{
- if ((cqe->opcode & MTHCA_ERROR_CQE_OPCODE_MASK) ==
- MTHCA_ERROR_CQE_OPCODE_MASK)
- return !(cqe->opcode & 0x01);
- else
- return !(cqe->is_send & 0x80);
-}
-
-void __mthca_cq_clean(struct mthca_cq *cq, uint32_t qpn, struct mthca_srq *srq)
-{
- struct mthca_cqe *cqe;
- uint32_t prod_index;
- int i, nfreed = 0;
-
- /*
- * First we need to find the current producer index, so we
- * know where to start cleaning from. It doesn't matter if HW
- * adds new entries after this loop -- the QP we're worried
- * about is already in RESET, so the new entries won't come
- * from our QP and therefore don't need to be checked.
- */
- for (prod_index = cq->cons_index;
- cqe_sw(cq, prod_index & cq->ibv_cq.cqe);
- ++prod_index)
- if (prod_index == cq->cons_index + cq->ibv_cq.cqe)
- break;
-
- /*
- * Now sweep backwards through the CQ, removing CQ entries
- * that match our QP by copying older entries on top of them.
- */
- while ((int) --prod_index - (int) cq->cons_index >= 0) {
- cqe = get_cqe(cq, prod_index & cq->ibv_cq.cqe);
- if (cqe->my_qpn == htonl(qpn)) {
- if (srq && is_recv_cqe(cqe))
- mthca_free_srq_wqe(srq,
- ntohl(cqe->wqe) >> srq->wqe_shift);
- ++nfreed;
- } else if (nfreed)
- memcpy(get_cqe(cq, (prod_index + nfreed) & cq->ibv_cq.cqe),
- cqe, MTHCA_CQ_ENTRY_SIZE);
- }
-
- if (nfreed) {
- for (i = 0; i < nfreed; ++i)
- set_cqe_hw(get_cqe(cq, (cq->cons_index + i) & cq->ibv_cq.cqe));
- wmb();
- cq->cons_index += nfreed;
- update_cons_index(cq, nfreed);
- }
-}
-
-void mthca_cq_clean(struct mthca_cq *cq, uint32_t qpn, struct mthca_srq *srq)
-{
- pthread_spin_lock(&cq->lock);
- __mthca_cq_clean(cq, qpn, srq);
- pthread_spin_unlock(&cq->lock);
-}
-
-void mthca_cq_resize_copy_cqes(struct mthca_cq *cq, void *buf, int old_cqe)
-{
- int i;
-
- /*
- * In Tavor mode, the hardware keeps the consumer and producer
- * indices mod the CQ size. Since we might be making the CQ
- * bigger, we need to deal with the case where the producer
- * index wrapped around before the CQ was resized.
- */
- if (!mthca_is_memfree(cq->ibv_cq.context) && old_cqe < cq->ibv_cq.cqe) {
- cq->cons_index &= old_cqe;
- if (cqe_sw(cq, old_cqe))
- cq->cons_index -= old_cqe + 1;
- }
-
- for (i = cq->cons_index; cqe_sw(cq, i & old_cqe); ++i)
- memcpy(buf + (i & cq->ibv_cq.cqe) * MTHCA_CQ_ENTRY_SIZE,
- get_cqe(cq, i & old_cqe), MTHCA_CQ_ENTRY_SIZE);
-}
-
-int mthca_alloc_cq_buf(struct mthca_device *dev, struct mthca_buf *buf, int nent)
-{
- int i;
-
- if (mthca_alloc_buf(buf, align(nent * MTHCA_CQ_ENTRY_SIZE, dev->page_size),
- dev->page_size))
- return -1;
-
- for (i = 0; i < nent; ++i)
- ((struct mthca_cqe *) buf->buf)[i].owner = MTHCA_CQ_ENTRY_OWNER_HW;
-
- return 0;
-}
diff --git a/contrib/ofed/libmthca/src/doorbell.h b/contrib/ofed/libmthca/src/doorbell.h
deleted file mode 100644
index a3aa42a..0000000
--- a/contrib/ofed/libmthca/src/doorbell.h
+++ /dev/null
@@ -1,107 +0,0 @@
-/*
- * Copyright (c) 2004, 2005 Topspin Communications. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-#ifndef DOORBELL_H
-#define DOORBELL_H
-
-#ifdef __i386__
-
-static inline void mthca_write64(uint32_t val[2], struct mthca_context *ctx, int offset)
-{
- /* i386 stack is aligned to 8 bytes, so this should be OK: */
- uint8_t xmmsave[8] __attribute__((aligned(8)));
-
- asm volatile (
- "movlps %%xmm0,(%0); \n\t"
- "movlps (%1),%%xmm0; \n\t"
- "movlps %%xmm0,(%2); \n\t"
- "movlps (%0),%%xmm0; \n\t"
- :
- : "r" (xmmsave), "r" (val), "r" (ctx->uar + offset)
- : "memory" );
-}
-
-static inline void mthca_write_db_rec(uint32_t val[2], uint32_t *db)
-{
- /* i386 stack is aligned to 8 bytes, so this should be OK: */
- uint8_t xmmsave[8] __attribute__((aligned(8)));
-
- asm volatile (
- "movlps %%xmm0,(%0); \n\t"
- "movlps (%1),%%xmm0; \n\t"
- "movlps %%xmm0,(%2); \n\t"
- "movlps (%0),%%xmm0; \n\t"
- :
- : "r" (xmmsave), "r" (val), "r" (db)
- : "memory" );
-}
-
-#elif SIZEOF_LONG == 8
-
-#if __BYTE_ORDER == __LITTLE_ENDIAN
-# define MTHCA_PAIR_TO_64(val) ((uint64_t) val[1] << 32 | val[0])
-#elif __BYTE_ORDER == __BIG_ENDIAN
-# define MTHCA_PAIR_TO_64(val) ((uint64_t) val[0] << 32 | val[1])
-#else
-# error __BYTE_ORDER not defined
-#endif
-
-static inline void mthca_write64(uint32_t val[2], struct mthca_context *ctx, int offset)
-{
- *(volatile uint64_t *) (ctx->uar + offset) = MTHCA_PAIR_TO_64(val);
-}
-
-static inline void mthca_write_db_rec(uint32_t val[2], uint32_t *db)
-{
- *(volatile uint64_t *) db = MTHCA_PAIR_TO_64(val);
-}
-
-#else
-
-static inline void mthca_write64(uint32_t val[2], struct mthca_context *ctx, int offset)
-{
- pthread_spin_lock(&ctx->uar_lock);
- *(volatile uint32_t *) (ctx->uar + offset) = val[0];
- *(volatile uint32_t *) (ctx->uar + offset + 4) = val[1];
- pthread_spin_unlock(&ctx->uar_lock);
-}
-
-static inline void mthca_write_db_rec(uint32_t val[2], uint32_t *db)
-{
- *(volatile uint32_t *) db = val[0];
- mb();
- *(volatile uint32_t *) (db + 1) = val[1];
-}
-
-#endif
-
-#endif /* MTHCA_H */
diff --git a/contrib/ofed/libmthca/src/memfree.c b/contrib/ofed/libmthca/src/memfree.c
deleted file mode 100644
index 987e149..0000000
--- a/contrib/ofed/libmthca/src/memfree.c
+++ /dev/null
@@ -1,204 +0,0 @@
-/*
- * Copyright (c) 2005 Topspin Communications. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-#if HAVE_CONFIG_H
-# include <config.h>
-#endif /* HAVE_CONFIG_H */
-
-#include <stdlib.h>
-#include <netinet/in.h>
-#include <pthread.h>
-#include <string.h>
-
-#include "mthca.h"
-
-#define MTHCA_FREE_MAP_SIZE (MTHCA_DB_REC_PER_PAGE / (SIZEOF_LONG * 8))
-
-struct mthca_db_page {
- unsigned long free[MTHCA_FREE_MAP_SIZE];
- struct mthca_buf db_rec;
-};
-
-struct mthca_db_table {
- int npages;
- int max_group1;
- int min_group2;
- pthread_mutex_t mutex;
- struct mthca_db_page page[];
-};
-
-int mthca_alloc_db(struct mthca_db_table *db_tab, enum mthca_db_type type,
- uint32_t **db)
-{
- int i, j, k;
- int group, start, end, dir;
- int ret = 0;
-
- pthread_mutex_lock(&db_tab->mutex);
-
- switch (type) {
- case MTHCA_DB_TYPE_CQ_ARM:
- case MTHCA_DB_TYPE_SQ:
- group = 0;
- start = 0;
- end = db_tab->max_group1;
- dir = 1;
- break;
-
- case MTHCA_DB_TYPE_CQ_SET_CI:
- case MTHCA_DB_TYPE_RQ:
- case MTHCA_DB_TYPE_SRQ:
- group = 1;
- start = db_tab->npages - 1;
- end = db_tab->min_group2;
- dir = -1;
- break;
-
- default:
- ret = -1;
- goto out;
- }
-
- for (i = start; i != end; i += dir)
- if (db_tab->page[i].db_rec.buf)
- for (j = 0; j < MTHCA_FREE_MAP_SIZE; ++j)
- if (db_tab->page[i].free[j])
- goto found;
-
- if (db_tab->max_group1 >= db_tab->min_group2 - 1) {
- ret = -1;
- goto out;
- }
-
- if (mthca_alloc_buf(&db_tab->page[i].db_rec,
- MTHCA_DB_REC_PAGE_SIZE,
- MTHCA_DB_REC_PAGE_SIZE)) {
- ret = -1;
- goto out;
- }
-
- memset(db_tab->page[i].db_rec.buf, 0, MTHCA_DB_REC_PAGE_SIZE);
- memset(db_tab->page[i].free, 0xff, sizeof db_tab->page[i].free);
-
- if (group == 0)
- ++db_tab->max_group1;
- else
- --db_tab->min_group2;
-
-found:
- for (j = 0; j < MTHCA_FREE_MAP_SIZE; ++j) {
- k = ffsl(db_tab->page[i].free[j]);
- if (k)
- break;
- }
-
- if (!k) {
- ret = -1;
- goto out;
- }
-
- --k;
- db_tab->page[i].free[j] &= ~(1UL << k);
-
- j = j * SIZEOF_LONG * 8 + k;
- if (group == 1)
- j = MTHCA_DB_REC_PER_PAGE - 1 - j;
-
- ret = i * MTHCA_DB_REC_PER_PAGE + j;
- *db = db_tab->page[i].db_rec.buf + j * 8;
-
-out:
- pthread_mutex_unlock(&db_tab->mutex);
- return ret;
-}
-
-void mthca_set_db_qn(uint32_t *db, enum mthca_db_type type, uint32_t qn)
-{
- db[1] = htonl((qn << 8) | (type << 5));
-}
-
-void mthca_free_db(struct mthca_db_table *db_tab, enum mthca_db_type type, int db_index)
-{
- int i, j;
- struct mthca_db_page *page;
-
- i = db_index / MTHCA_DB_REC_PER_PAGE;
- j = db_index % MTHCA_DB_REC_PER_PAGE;
-
- page = db_tab->page + i;
-
- pthread_mutex_lock(&db_tab->mutex);
- *(uint64_t *) (page->db_rec.buf + j * 8) = 0;
-
- if (i >= db_tab->min_group2)
- j = MTHCA_DB_REC_PER_PAGE - 1 - j;
-
- page->free[j / (SIZEOF_LONG * 8)] |= 1UL << (j % (SIZEOF_LONG * 8));
-
- pthread_mutex_unlock(&db_tab->mutex);
-}
-
-struct mthca_db_table *mthca_alloc_db_tab(int uarc_size)
-{
- struct mthca_db_table *db_tab;
- int npages;
- int i;
-
- npages = uarc_size / MTHCA_DB_REC_PAGE_SIZE;
- db_tab = malloc(sizeof (struct mthca_db_table) +
- npages * sizeof (struct mthca_db_page));
-
- pthread_mutex_init(&db_tab->mutex, NULL);
-
- db_tab->npages = npages;
- db_tab->max_group1 = 0;
- db_tab->min_group2 = npages - 1;
-
- for (i = 0; i < npages; ++i)
- db_tab->page[i].db_rec.buf = NULL;
-
- return db_tab;
-}
-
-void mthca_free_db_tab(struct mthca_db_table *db_tab)
-{
- int i;
-
- if (!db_tab)
- return;
-
- for (i = 0; i < db_tab->npages; ++i)
- if (db_tab->page[i].db_rec.buf)
- mthca_free_buf(&db_tab->page[i].db_rec);
-
- free(db_tab);
-}
diff --git a/contrib/ofed/libmthca/src/mthca-abi.h b/contrib/ofed/libmthca/src/mthca-abi.h
deleted file mode 100644
index 4fbd98b..0000000
--- a/contrib/ofed/libmthca/src/mthca-abi.h
+++ /dev/null
@@ -1,109 +0,0 @@
-/*
- * Copyright (c) 2004, 2005 Topspin Communications. All rights reserved.
- * Copyright (c) 2006 Cisco Systems. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-#ifndef MTHCA_ABI_H
-#define MTHCA_ABI_H
-
-#include <infiniband/kern-abi.h>
-
-#define MTHCA_UVERBS_ABI_VERSION 1
-
-struct mthca_alloc_ucontext_resp {
- struct ibv_get_context_resp ibv_resp;
- __u32 qp_tab_size;
- __u32 uarc_size;
-};
-
-struct mthca_alloc_pd_resp {
- struct ibv_alloc_pd_resp ibv_resp;
- __u32 pdn;
- __u32 reserved;
-};
-
-struct mthca_reg_mr {
- struct ibv_reg_mr ibv_cmd;
-/*
- * Mark the memory region with a DMA attribute that causes
- * in-flight DMA to be flushed when the region is written to:
- */
-#define MTHCA_MR_DMASYNC 0x1
- __u32 mr_attrs;
- __u32 reserved;
-};
-
-struct mthca_create_cq {
- struct ibv_create_cq ibv_cmd;
- __u32 lkey;
- __u32 pdn;
- __u64 arm_db_page;
- __u64 set_db_page;
- __u32 arm_db_index;
- __u32 set_db_index;
-};
-
-struct mthca_create_cq_resp {
- struct ibv_create_cq_resp ibv_resp;
- __u32 cqn;
- __u32 reserved;
-};
-
-struct mthca_resize_cq {
- struct ibv_resize_cq ibv_cmd;
- __u32 lkey;
- __u32 reserved;
-};
-
-struct mthca_create_srq {
- struct ibv_create_srq ibv_cmd;
- __u32 lkey;
- __u32 db_index;
- __u64 db_page;
-};
-
-struct mthca_create_srq_resp {
- struct ibv_create_srq_resp ibv_resp;
- __u32 srqn;
- __u32 reserved;
-};
-
-struct mthca_create_qp {
- struct ibv_create_qp ibv_cmd;
- __u32 lkey;
- __u32 reserved;
- __u64 sq_db_page;
- __u64 rq_db_page;
- __u32 sq_db_index;
- __u32 rq_db_index;
-};
-
-#endif /* MTHCA_ABI_H */
diff --git a/contrib/ofed/libmthca/src/mthca.c b/contrib/ofed/libmthca/src/mthca.c
deleted file mode 100644
index e00c4ee..0000000
--- a/contrib/ofed/libmthca/src/mthca.c
+++ /dev/null
@@ -1,326 +0,0 @@
-/*
- * Copyright (c) 2004, 2005 Topspin Communications. All rights reserved.
- * Copyright (c) 2006 Cisco Systems. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-#if HAVE_CONFIG_H
-# include <config.h>
-#endif /* HAVE_CONFIG_H */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <errno.h>
-#include <sys/mman.h>
-#include <pthread.h>
-#include <string.h>
-
-#ifndef HAVE_IBV_REGISTER_DRIVER
-#include <sysfs/libsysfs.h>
-#endif
-
-#ifndef HAVE_IBV_READ_SYSFS_FILE
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#endif
-
-#include "mthca.h"
-#include "mthca-abi.h"
-
-#ifndef PCI_VENDOR_ID_MELLANOX
-#define PCI_VENDOR_ID_MELLANOX 0x15b3
-#endif
-
-#ifndef PCI_DEVICE_ID_MELLANOX_TAVOR
-#define PCI_DEVICE_ID_MELLANOX_TAVOR 0x5a44
-#endif
-
-#ifndef PCI_DEVICE_ID_MELLANOX_ARBEL_COMPAT
-#define PCI_DEVICE_ID_MELLANOX_ARBEL_COMPAT 0x6278
-#endif
-
-#ifndef PCI_DEVICE_ID_MELLANOX_ARBEL
-#define PCI_DEVICE_ID_MELLANOX_ARBEL 0x6282
-#endif
-
-#ifndef PCI_DEVICE_ID_MELLANOX_SINAI_OLD
-#define PCI_DEVICE_ID_MELLANOX_SINAI_OLD 0x5e8c
-#endif
-
-#ifndef PCI_DEVICE_ID_MELLANOX_SINAI
-#define PCI_DEVICE_ID_MELLANOX_SINAI 0x6274
-#endif
-
-#ifndef PCI_VENDOR_ID_TOPSPIN
-#define PCI_VENDOR_ID_TOPSPIN 0x1867
-#endif
-
-#define HCA(v, d, t) \
- { .vendor = PCI_VENDOR_ID_##v, \
- .device = PCI_DEVICE_ID_MELLANOX_##d, \
- .type = MTHCA_##t }
-
-struct {
- unsigned vendor;
- unsigned device;
- enum mthca_hca_type type;
-} hca_table[] = {
- HCA(MELLANOX, TAVOR, TAVOR),
- HCA(MELLANOX, ARBEL_COMPAT, TAVOR),
- HCA(MELLANOX, ARBEL, ARBEL),
- HCA(MELLANOX, SINAI_OLD, ARBEL),
- HCA(MELLANOX, SINAI, ARBEL),
- HCA(TOPSPIN, TAVOR, TAVOR),
- HCA(TOPSPIN, ARBEL_COMPAT, TAVOR),
- HCA(TOPSPIN, ARBEL, ARBEL),
- HCA(TOPSPIN, SINAI_OLD, ARBEL),
- HCA(TOPSPIN, SINAI, ARBEL),
-};
-
-static struct ibv_context_ops mthca_ctx_ops = {
- .query_device = mthca_query_device,
- .query_port = mthca_query_port,
- .alloc_pd = mthca_alloc_pd,
- .dealloc_pd = mthca_free_pd,
- .reg_mr = mthca_reg_mr,
- .dereg_mr = mthca_dereg_mr,
- .create_cq = mthca_create_cq,
- .poll_cq = mthca_poll_cq,
- .resize_cq = mthca_resize_cq,
- .destroy_cq = mthca_destroy_cq,
- .create_srq = mthca_create_srq,
- .modify_srq = mthca_modify_srq,
- .query_srq = mthca_query_srq,
- .destroy_srq = mthca_destroy_srq,
- .create_qp = mthca_create_qp,
- .query_qp = mthca_query_qp,
- .modify_qp = mthca_modify_qp,
- .destroy_qp = mthca_destroy_qp,
- .create_ah = mthca_create_ah,
- .destroy_ah = mthca_destroy_ah,
- .attach_mcast = mthca_attach_mcast,
- .detach_mcast = mthca_detach_mcast
-};
-
-static struct ibv_context *mthca_alloc_context(struct ibv_device *ibdev, int cmd_fd)
-{
- struct mthca_context *context;
- struct ibv_get_context cmd;
- struct mthca_alloc_ucontext_resp resp;
- int i;
-
- context = calloc(1, sizeof *context);
- if (!context)
- return NULL;
-
- context->ibv_ctx.cmd_fd = cmd_fd;
-
- if (ibv_cmd_get_context(&context->ibv_ctx, &cmd, sizeof cmd,
- &resp.ibv_resp, sizeof resp))
- goto err_free;
-
- context->num_qps = resp.qp_tab_size;
- context->qp_table_shift = ffs(context->num_qps) - 1 - MTHCA_QP_TABLE_BITS;
- context->qp_table_mask = (1 << context->qp_table_shift) - 1;
-
- /*
- * Need to set ibv_ctx.device because mthca_is_memfree() will
- * look at it to figure out the HCA type.
- */
- context->ibv_ctx.device = ibdev;
-
- if (mthca_is_memfree(&context->ibv_ctx)) {
- context->db_tab = mthca_alloc_db_tab(resp.uarc_size);
- if (!context->db_tab)
- goto err_free;
- } else
- context->db_tab = NULL;
-
- pthread_mutex_init(&context->qp_table_mutex, NULL);
- for (i = 0; i < MTHCA_QP_TABLE_SIZE; ++i)
- context->qp_table[i].refcnt = 0;
-
- context->uar = mmap(NULL, to_mdev(ibdev)->page_size, PROT_WRITE,
- MAP_SHARED, cmd_fd, 0);
- if (context->uar == MAP_FAILED)
- goto err_db_tab;
-
- pthread_spin_init(&context->uar_lock, PTHREAD_PROCESS_PRIVATE);
-
- context->pd = mthca_alloc_pd(&context->ibv_ctx);
- if (!context->pd)
- goto err_unmap;
-
- context->pd->context = &context->ibv_ctx;
-
- context->ibv_ctx.ops = mthca_ctx_ops;
-
- if (mthca_is_memfree(&context->ibv_ctx)) {
- context->ibv_ctx.ops.req_notify_cq = mthca_arbel_arm_cq;
- context->ibv_ctx.ops.cq_event = mthca_arbel_cq_event;
- context->ibv_ctx.ops.post_send = mthca_arbel_post_send;
- context->ibv_ctx.ops.post_recv = mthca_arbel_post_recv;
- context->ibv_ctx.ops.post_srq_recv = mthca_arbel_post_srq_recv;
- } else {
- context->ibv_ctx.ops.req_notify_cq = mthca_tavor_arm_cq;
- context->ibv_ctx.ops.cq_event = NULL;
- context->ibv_ctx.ops.post_send = mthca_tavor_post_send;
- context->ibv_ctx.ops.post_recv = mthca_tavor_post_recv;
- context->ibv_ctx.ops.post_srq_recv = mthca_tavor_post_srq_recv;
- }
-
- return &context->ibv_ctx;
-
-err_unmap:
- munmap(context->uar, to_mdev(ibdev)->page_size);
-
-err_db_tab:
- mthca_free_db_tab(context->db_tab);
-
-err_free:
- free(context);
- return NULL;
-}
-
-static void mthca_free_context(struct ibv_context *ibctx)
-{
- struct mthca_context *context = to_mctx(ibctx);
-
- mthca_free_pd(context->pd);
- munmap(context->uar, to_mdev(ibctx->device)->page_size);
- mthca_free_db_tab(context->db_tab);
- free(context);
-}
-
-static struct ibv_device_ops mthca_dev_ops = {
- .alloc_context = mthca_alloc_context,
- .free_context = mthca_free_context
-};
-
-/*
- * Keep a private implementation of HAVE_IBV_READ_SYSFS_FILE to handle
- * old versions of libibverbs that didn't implement it. This can be
- * removed when libibverbs 1.0.3 or newer is available "everywhere."
- */
-#ifndef HAVE_IBV_READ_SYSFS_FILE
-static int ibv_read_sysfs_file(const char *dir, const char *file,
- char *buf, size_t size)
-{
- char path[256];
- int fd;
- int len;
-
- snprintf(path, sizeof path, "%s/%s", dir, file);
-
- fd = open(path, O_RDONLY);
- if (fd < 0)
- return -1;
-
- len = read(fd, buf, size);
-
- close(fd);
-
- if (len > 0 && buf[len - 1] == '\n')
- buf[--len] = '\0';
-
- return len;
-}
-#endif /* HAVE_IBV_READ_SYSFS_FILE */
-
-static struct ibv_device *mthca_driver_init(const char *uverbs_sys_path,
- int abi_version)
-{
- char value[8];
- struct mthca_device *dev;
- unsigned vendor, device;
- int i;
-
- if (ibv_read_sysfs_file(uverbs_sys_path, "device/vendor",
- value, sizeof value) < 0)
- return NULL;
- sscanf(value, "%i", &vendor);
-
- if (ibv_read_sysfs_file(uverbs_sys_path, "device/device",
- value, sizeof value) < 0)
- return NULL;
- sscanf(value, "%i", &device);
-
- for (i = 0; i < sizeof hca_table / sizeof hca_table[0]; ++i)
- if (vendor == hca_table[i].vendor &&
- device == hca_table[i].device)
- goto found;
-
- return NULL;
-
-found:
- if (abi_version > MTHCA_UVERBS_ABI_VERSION) {
- fprintf(stderr, PFX "Fatal: ABI version %d of %s is too new (expected %d)\n",
- abi_version, uverbs_sys_path, MTHCA_UVERBS_ABI_VERSION);
- return NULL;
- }
-
- dev = malloc(sizeof *dev);
- if (!dev) {
- fprintf(stderr, PFX "Fatal: couldn't allocate device for %s\n",
- uverbs_sys_path);
- return NULL;
- }
-
- dev->ibv_dev.ops = mthca_dev_ops;
- dev->hca_type = hca_table[i].type;
- dev->page_size = sysconf(_SC_PAGESIZE);
-
- return &dev->ibv_dev;
-}
-
-#ifdef HAVE_IBV_REGISTER_DRIVER
-static __attribute__((constructor)) void mthca_register_driver(void)
-{
- ibv_register_driver("mthca", mthca_driver_init);
-}
-#else
-/*
- * Export the old libsysfs sysfs_class_device-based driver entry point
- * if libibverbs does not export an ibv_register_driver() function.
- */
-struct ibv_device *openib_driver_init(struct sysfs_class_device *sysdev)
-{
- int abi_ver = 0;
- char value[8];
-
- if (ibv_read_sysfs_file(sysdev->path, "abi_version",
- value, sizeof value) > 0)
- abi_ver = strtol(value, NULL, 10);
-
- return mthca_driver_init(sysdev->path, abi_ver);
-}
-#endif /* HAVE_IBV_REGISTER_DRIVER */
diff --git a/contrib/ofed/libmthca/src/mthca.h b/contrib/ofed/libmthca/src/mthca.h
deleted file mode 100644
index 66751f3..0000000
--- a/contrib/ofed/libmthca/src/mthca.h
+++ /dev/null
@@ -1,378 +0,0 @@
-/*
- * Copyright (c) 2004, 2005 Topspin Communications. All rights reserved.
- * Copyright (c) 2005, 2006 Cisco Systems. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-#ifndef MTHCA_H
-#define MTHCA_H
-
-#include <stddef.h>
-
-#include <infiniband/driver.h>
-#include <infiniband/arch.h>
-
-#ifdef HAVE_VALGRIND_MEMCHECK_H
-
-# include <valgrind/memcheck.h>
-
-# if !defined(VALGRIND_MAKE_MEM_DEFINED) || !defined(VALGRIND_MAKE_MEM_UNDEFINED)
-# warning "Valgrind support requested, but VALGRIND_MAKE_MEM_(UN)DEFINED not available"
-# endif
-
-#endif /* HAVE_VALGRIND_MEMCHECK_H */
-
-#ifndef VALGRIND_MAKE_MEM_DEFINED
-# define VALGRIND_MAKE_MEM_DEFINED(addr,len)
-#endif
-
-#ifndef VALGRIND_MAKE_MEM_UNDEFINED
-# define VALGRIND_MAKE_MEM_UNDEFINED(addr,len)
-#endif
-
-#ifndef rmb
-# define rmb() mb()
-#endif
-
-#ifndef wmb
-# define wmb() mb()
-#endif
-
-#define HIDDEN __attribute__((visibility ("hidden")))
-
-#define PFX "mthca: "
-
-enum mthca_hca_type {
- MTHCA_TAVOR,
- MTHCA_ARBEL
-};
-
-enum {
- MTHCA_CQ_ENTRY_SIZE = 0x20
-};
-
-enum {
- MTHCA_QP_TABLE_BITS = 8,
- MTHCA_QP_TABLE_SIZE = 1 << MTHCA_QP_TABLE_BITS,
- MTHCA_QP_TABLE_MASK = MTHCA_QP_TABLE_SIZE - 1
-};
-
-enum {
- MTHCA_DB_REC_PAGE_SIZE = 4096,
- MTHCA_DB_REC_PER_PAGE = MTHCA_DB_REC_PAGE_SIZE / 8
-};
-
-enum mthca_db_type {
- MTHCA_DB_TYPE_INVALID = 0x0,
- MTHCA_DB_TYPE_CQ_SET_CI = 0x1,
- MTHCA_DB_TYPE_CQ_ARM = 0x2,
- MTHCA_DB_TYPE_SQ = 0x3,
- MTHCA_DB_TYPE_RQ = 0x4,
- MTHCA_DB_TYPE_SRQ = 0x5,
- MTHCA_DB_TYPE_GROUP_SEP = 0x7
-};
-
-enum {
- MTHCA_OPCODE_NOP = 0x00,
- MTHCA_OPCODE_RDMA_WRITE = 0x08,
- MTHCA_OPCODE_RDMA_WRITE_IMM = 0x09,
- MTHCA_OPCODE_SEND = 0x0a,
- MTHCA_OPCODE_SEND_IMM = 0x0b,
- MTHCA_OPCODE_RDMA_READ = 0x10,
- MTHCA_OPCODE_ATOMIC_CS = 0x11,
- MTHCA_OPCODE_ATOMIC_FA = 0x12,
- MTHCA_OPCODE_BIND_MW = 0x18,
- MTHCA_OPCODE_INVALID = 0xff
-};
-
-struct mthca_ah_page;
-
-struct mthca_device {
- struct ibv_device ibv_dev;
- enum mthca_hca_type hca_type;
- int page_size;
-};
-
-struct mthca_db_table;
-
-struct mthca_context {
- struct ibv_context ibv_ctx;
- void *uar;
- pthread_spinlock_t uar_lock;
- struct mthca_db_table *db_tab;
- struct ibv_pd *pd;
- struct {
- struct mthca_qp **table;
- int refcnt;
- } qp_table[MTHCA_QP_TABLE_SIZE];
- pthread_mutex_t qp_table_mutex;
- int num_qps;
- int qp_table_shift;
- int qp_table_mask;
-};
-
-struct mthca_buf {
- void *buf;
- size_t length;
-};
-
-struct mthca_pd {
- struct ibv_pd ibv_pd;
- struct mthca_ah_page *ah_list;
- pthread_mutex_t ah_mutex;
- uint32_t pdn;
-};
-
-struct mthca_cq {
- struct ibv_cq ibv_cq;
- struct mthca_buf buf;
- pthread_spinlock_t lock;
- struct ibv_mr *mr;
- uint32_t cqn;
- uint32_t cons_index;
-
- /* Next fields are mem-free only */
- int set_ci_db_index;
- uint32_t *set_ci_db;
- int arm_db_index;
- uint32_t *arm_db;
- int arm_sn;
-};
-
-struct mthca_srq {
- struct ibv_srq ibv_srq;
- struct mthca_buf buf;
- void *last;
- pthread_spinlock_t lock;
- struct ibv_mr *mr;
- uint64_t *wrid;
- uint32_t srqn;
- int max;
- int max_gs;
- int wqe_shift;
- int first_free;
- int last_free;
- int buf_size;
-
- /* Next fields are mem-free only */
- int db_index;
- uint32_t *db;
- uint16_t counter;
-};
-
-struct mthca_wq {
- pthread_spinlock_t lock;
- int max;
- unsigned next_ind;
- unsigned last_comp;
- unsigned head;
- unsigned tail;
- void *last;
- int max_gs;
- int wqe_shift;
-
- /* Next fields are mem-free only */
- int db_index;
- uint32_t *db;
-};
-
-struct mthca_qp {
- struct ibv_qp ibv_qp;
- struct mthca_buf buf;
- uint64_t *wrid;
- int send_wqe_offset;
- int max_inline_data;
- int buf_size;
- struct mthca_wq sq;
- struct mthca_wq rq;
- struct ibv_mr *mr;
- int sq_sig_all;
-};
-
-struct mthca_av {
- uint32_t port_pd;
- uint8_t reserved1;
- uint8_t g_slid;
- uint16_t dlid;
- uint8_t reserved2;
- uint8_t gid_index;
- uint8_t msg_sr;
- uint8_t hop_limit;
- uint32_t sl_tclass_flowlabel;
- uint32_t dgid[4];
-};
-
-struct mthca_ah {
- struct ibv_ah ibv_ah;
- struct mthca_av *av;
- struct mthca_ah_page *page;
- uint32_t key;
-};
-
-static inline unsigned long align(unsigned long val, unsigned long align)
-{
- return (val + align - 1) & ~(align - 1);
-}
-
-static inline uintptr_t db_align(uint32_t *db)
-{
- return (uintptr_t) db & ~((uintptr_t) MTHCA_DB_REC_PAGE_SIZE - 1);
-}
-
-#define to_mxxx(xxx, type) \
- ((struct mthca_##type *) \
- ((void *) ib##xxx - offsetof(struct mthca_##type, ibv_##xxx)))
-
-static inline struct mthca_device *to_mdev(struct ibv_device *ibdev)
-{
- return to_mxxx(dev, device);
-}
-
-static inline struct mthca_context *to_mctx(struct ibv_context *ibctx)
-{
- return to_mxxx(ctx, context);
-}
-
-static inline struct mthca_pd *to_mpd(struct ibv_pd *ibpd)
-{
- return to_mxxx(pd, pd);
-}
-
-static inline struct mthca_cq *to_mcq(struct ibv_cq *ibcq)
-{
- return to_mxxx(cq, cq);
-}
-
-static inline struct mthca_srq *to_msrq(struct ibv_srq *ibsrq)
-{
- return to_mxxx(srq, srq);
-}
-
-static inline struct mthca_qp *to_mqp(struct ibv_qp *ibqp)
-{
- return to_mxxx(qp, qp);
-}
-
-static inline struct mthca_ah *to_mah(struct ibv_ah *ibah)
-{
- return to_mxxx(ah, ah);
-}
-
-static inline int mthca_is_memfree(struct ibv_context *ibctx)
-{
- return to_mdev(ibctx->device)->hca_type == MTHCA_ARBEL;
-}
-
-int mthca_alloc_buf(struct mthca_buf *buf, size_t size, int page_size);
-void mthca_free_buf(struct mthca_buf *buf);
-
-int mthca_alloc_db(struct mthca_db_table *db_tab, enum mthca_db_type type,
- uint32_t **db);
-void mthca_set_db_qn(uint32_t *db, enum mthca_db_type type, uint32_t qn);
-void mthca_free_db(struct mthca_db_table *db_tab, enum mthca_db_type type, int db_index);
-struct mthca_db_table *mthca_alloc_db_tab(int uarc_size);
-void mthca_free_db_tab(struct mthca_db_table *db_tab);
-
-int mthca_query_device(struct ibv_context *context,
- struct ibv_device_attr *attr);
-int mthca_query_port(struct ibv_context *context, uint8_t port,
- struct ibv_port_attr *attr);
-
-struct ibv_pd *mthca_alloc_pd(struct ibv_context *context);
-int mthca_free_pd(struct ibv_pd *pd);
-
-struct ibv_mr *mthca_reg_mr(struct ibv_pd *pd, void *addr,
- size_t length, enum ibv_access_flags access);
-int mthca_dereg_mr(struct ibv_mr *mr);
-
-struct ibv_cq *mthca_create_cq(struct ibv_context *context, int cqe,
- struct ibv_comp_channel *channel,
- int comp_vector);
-int mthca_resize_cq(struct ibv_cq *cq, int cqe);
-int mthca_destroy_cq(struct ibv_cq *cq);
-int mthca_poll_cq(struct ibv_cq *cq, int ne, struct ibv_wc *wc);
-int mthca_tavor_arm_cq(struct ibv_cq *cq, int solicited);
-int mthca_arbel_arm_cq(struct ibv_cq *cq, int solicited);
-void mthca_arbel_cq_event(struct ibv_cq *cq);
-void __mthca_cq_clean(struct mthca_cq *cq, uint32_t qpn, struct mthca_srq *srq);
-void mthca_cq_clean(struct mthca_cq *cq, uint32_t qpn, struct mthca_srq *srq);
-void mthca_cq_resize_copy_cqes(struct mthca_cq *cq, void *buf, int new_cqe);
-int mthca_alloc_cq_buf(struct mthca_device *dev, struct mthca_buf *buf, int nent);
-
-struct ibv_srq *mthca_create_srq(struct ibv_pd *pd,
- struct ibv_srq_init_attr *attr);
-int mthca_modify_srq(struct ibv_srq *srq,
- struct ibv_srq_attr *attr,
- enum ibv_srq_attr_mask mask);
-int mthca_query_srq(struct ibv_srq *srq,
- struct ibv_srq_attr *attr);
-int mthca_destroy_srq(struct ibv_srq *srq);
-int mthca_alloc_srq_buf(struct ibv_pd *pd, struct ibv_srq_attr *attr,
- struct mthca_srq *srq);
-void mthca_free_srq_wqe(struct mthca_srq *srq, int ind);
-int mthca_tavor_post_srq_recv(struct ibv_srq *ibsrq,
- struct ibv_recv_wr *wr,
- struct ibv_recv_wr **bad_wr);
-int mthca_arbel_post_srq_recv(struct ibv_srq *ibsrq,
- struct ibv_recv_wr *wr,
- struct ibv_recv_wr **bad_wr);
-
-struct ibv_qp *mthca_create_qp(struct ibv_pd *pd, struct ibv_qp_init_attr *attr);
-int mthca_query_qp(struct ibv_qp *qp, struct ibv_qp_attr *attr,
- enum ibv_qp_attr_mask attr_mask,
- struct ibv_qp_init_attr *init_attr);
-int mthca_modify_qp(struct ibv_qp *qp, struct ibv_qp_attr *attr,
- enum ibv_qp_attr_mask attr_mask);
-int mthca_destroy_qp(struct ibv_qp *qp);
-void mthca_init_qp_indices(struct mthca_qp *qp);
-int mthca_tavor_post_send(struct ibv_qp *ibqp, struct ibv_send_wr *wr,
- struct ibv_send_wr **bad_wr);
-int mthca_tavor_post_recv(struct ibv_qp *ibqp, struct ibv_recv_wr *wr,
- struct ibv_recv_wr **bad_wr);
-int mthca_arbel_post_send(struct ibv_qp *ibqp, struct ibv_send_wr *wr,
- struct ibv_send_wr **bad_wr);
-int mthca_arbel_post_recv(struct ibv_qp *ibqp, struct ibv_recv_wr *wr,
- struct ibv_recv_wr **bad_wr);
-int mthca_alloc_qp_buf(struct ibv_pd *pd, struct ibv_qp_cap *cap,
- enum ibv_qp_type type, struct mthca_qp *qp);
-struct mthca_qp *mthca_find_qp(struct mthca_context *ctx, uint32_t qpn);
-int mthca_store_qp(struct mthca_context *ctx, uint32_t qpn, struct mthca_qp *qp);
-void mthca_clear_qp(struct mthca_context *ctx, uint32_t qpn);
-int mthca_free_err_wqe(struct mthca_qp *qp, int is_send,
- int index, int *dbd, uint32_t *new_wqe);
-struct ibv_ah *mthca_create_ah(struct ibv_pd *pd, struct ibv_ah_attr *attr);
-int mthca_destroy_ah(struct ibv_ah *ah);
-int mthca_alloc_av(struct mthca_pd *pd, struct ibv_ah_attr *attr,
- struct mthca_ah *ah);
-void mthca_free_av(struct mthca_ah *ah);
-int mthca_attach_mcast(struct ibv_qp *qp, union ibv_gid *gid, uint16_t lid);
-int mthca_detach_mcast(struct ibv_qp *qp, union ibv_gid *gid, uint16_t lid);
-
-#endif /* MTHCA_H */
diff --git a/contrib/ofed/libmthca/src/mthca.map b/contrib/ofed/libmthca/src/mthca.map
deleted file mode 100644
index ae8ed86..0000000
--- a/contrib/ofed/libmthca/src/mthca.map
+++ /dev/null
@@ -1,5 +0,0 @@
-{
- global:
- openib_driver_init;
- local: *;
-};
diff --git a/contrib/ofed/libmthca/src/qp.c b/contrib/ofed/libmthca/src/qp.c
deleted file mode 100644
index 84dd206..0000000
--- a/contrib/ofed/libmthca/src/qp.c
+++ /dev/null
@@ -1,963 +0,0 @@
-/*
- * Copyright (c) 2005 Topspin Communications. All rights reserved.
- * Copyright (c) 2005 Mellanox Technologies Ltd. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-#if HAVE_CONFIG_H
-# include <config.h>
-#endif /* HAVE_CONFIG_H */
-
-#include <stdlib.h>
-#include <netinet/in.h>
-#include <pthread.h>
-#include <string.h>
-
-#include "mthca.h"
-#include "doorbell.h"
-#include "wqe.h"
-
-enum {
- MTHCA_SEND_DOORBELL_FENCE = 1 << 5
-};
-
-static const uint8_t mthca_opcode[] = {
- [IBV_WR_SEND] = MTHCA_OPCODE_SEND,
- [IBV_WR_SEND_WITH_IMM] = MTHCA_OPCODE_SEND_IMM,
- [IBV_WR_RDMA_WRITE] = MTHCA_OPCODE_RDMA_WRITE,
- [IBV_WR_RDMA_WRITE_WITH_IMM] = MTHCA_OPCODE_RDMA_WRITE_IMM,
- [IBV_WR_RDMA_READ] = MTHCA_OPCODE_RDMA_READ,
- [IBV_WR_ATOMIC_CMP_AND_SWP] = MTHCA_OPCODE_ATOMIC_CS,
- [IBV_WR_ATOMIC_FETCH_AND_ADD] = MTHCA_OPCODE_ATOMIC_FA,
-};
-
-static void *get_recv_wqe(struct mthca_qp *qp, int n)
-{
- return qp->buf.buf + (n << qp->rq.wqe_shift);
-}
-
-static void *get_send_wqe(struct mthca_qp *qp, int n)
-{
- return qp->buf.buf + qp->send_wqe_offset + (n << qp->sq.wqe_shift);
-}
-
-void mthca_init_qp_indices(struct mthca_qp *qp)
-{
- qp->sq.next_ind = 0;
- qp->sq.last_comp = qp->sq.max - 1;
- qp->sq.head = 0;
- qp->sq.tail = 0;
- qp->sq.last = get_send_wqe(qp, qp->sq.max - 1);
-
- qp->rq.next_ind = 0;
- qp->rq.last_comp = qp->rq.max - 1;
- qp->rq.head = 0;
- qp->rq.tail = 0;
- qp->rq.last = get_recv_wqe(qp, qp->rq.max - 1);
-}
-
-static inline int wq_overflow(struct mthca_wq *wq, int nreq, struct mthca_cq *cq)
-{
- unsigned cur;
-
- cur = wq->head - wq->tail;
- if (cur + nreq < wq->max)
- return 0;
-
- pthread_spin_lock(&cq->lock);
- cur = wq->head - wq->tail;
- pthread_spin_unlock(&cq->lock);
-
- return cur + nreq >= wq->max;
-}
-
-int mthca_tavor_post_send(struct ibv_qp *ibqp, struct ibv_send_wr *wr,
- struct ibv_send_wr **bad_wr)
-{
- struct mthca_qp *qp = to_mqp(ibqp);
- void *wqe, *prev_wqe;
- int ind;
- int nreq;
- int ret = 0;
- int size;
- int size0 = 0;
- int i;
- /*
- * f0 and op0 cannot be used unless nreq > 0, which means this
- * function makes it through the loop at least once. So the
- * code inside the if (!size0) will be executed, and f0 and
- * op0 will be initialized. So any gcc warning about "may be
- * used unitialized" is bogus.
- */
- uint32_t f0;
- uint32_t op0;
-
- pthread_spin_lock(&qp->sq.lock);
-
- ind = qp->sq.next_ind;
-
- for (nreq = 0; wr; ++nreq, wr = wr->next) {
- if (wq_overflow(&qp->sq, nreq, to_mcq(qp->ibv_qp.send_cq))) {
- ret = -1;
- *bad_wr = wr;
- goto out;
- }
-
- wqe = get_send_wqe(qp, ind);
- prev_wqe = qp->sq.last;
- qp->sq.last = wqe;
-
- ((struct mthca_next_seg *) wqe)->nda_op = 0;
- ((struct mthca_next_seg *) wqe)->ee_nds = 0;
- ((struct mthca_next_seg *) wqe)->flags =
- ((wr->send_flags & IBV_SEND_SIGNALED) ?
- htonl(MTHCA_NEXT_CQ_UPDATE) : 0) |
- ((wr->send_flags & IBV_SEND_SOLICITED) ?
- htonl(MTHCA_NEXT_SOLICIT) : 0) |
- htonl(1);
- if (wr->opcode == IBV_WR_SEND_WITH_IMM ||
- wr->opcode == IBV_WR_RDMA_WRITE_WITH_IMM)
- ((struct mthca_next_seg *) wqe)->imm = wr->imm_data;
-
- wqe += sizeof (struct mthca_next_seg);
- size = sizeof (struct mthca_next_seg) / 16;
-
- switch (ibqp->qp_type) {
- case IBV_QPT_RC:
- switch (wr->opcode) {
- case IBV_WR_ATOMIC_CMP_AND_SWP:
- case IBV_WR_ATOMIC_FETCH_AND_ADD:
- ((struct mthca_raddr_seg *) wqe)->raddr =
- htonll(wr->wr.atomic.remote_addr);
- ((struct mthca_raddr_seg *) wqe)->rkey =
- htonl(wr->wr.atomic.rkey);
- ((struct mthca_raddr_seg *) wqe)->reserved = 0;
-
- wqe += sizeof (struct mthca_raddr_seg);
-
- if (wr->opcode == IBV_WR_ATOMIC_CMP_AND_SWP) {
- ((struct mthca_atomic_seg *) wqe)->swap_add =
- htonll(wr->wr.atomic.swap);
- ((struct mthca_atomic_seg *) wqe)->compare =
- htonll(wr->wr.atomic.compare_add);
- } else {
- ((struct mthca_atomic_seg *) wqe)->swap_add =
- htonll(wr->wr.atomic.compare_add);
- ((struct mthca_atomic_seg *) wqe)->compare = 0;
- }
-
- wqe += sizeof (struct mthca_atomic_seg);
- size += (sizeof (struct mthca_raddr_seg) +
- sizeof (struct mthca_atomic_seg)) / 16;
- break;
-
- case IBV_WR_RDMA_WRITE:
- case IBV_WR_RDMA_WRITE_WITH_IMM:
- case IBV_WR_RDMA_READ:
- ((struct mthca_raddr_seg *) wqe)->raddr =
- htonll(wr->wr.rdma.remote_addr);
- ((struct mthca_raddr_seg *) wqe)->rkey =
- htonl(wr->wr.rdma.rkey);
- ((struct mthca_raddr_seg *) wqe)->reserved = 0;
- wqe += sizeof (struct mthca_raddr_seg);
- size += sizeof (struct mthca_raddr_seg) / 16;
- break;
-
- default:
- /* No extra segments required for sends */
- break;
- }
-
- break;
-
- case IBV_QPT_UC:
- switch (wr->opcode) {
- case IBV_WR_RDMA_WRITE:
- case IBV_WR_RDMA_WRITE_WITH_IMM:
- ((struct mthca_raddr_seg *) wqe)->raddr =
- htonll(wr->wr.rdma.remote_addr);
- ((struct mthca_raddr_seg *) wqe)->rkey =
- htonl(wr->wr.rdma.rkey);
- ((struct mthca_raddr_seg *) wqe)->reserved = 0;
- wqe += sizeof (struct mthca_raddr_seg);
- size += sizeof (struct mthca_raddr_seg) / 16;
- break;
-
- default:
- /* No extra segments required for sends */
- break;
- }
-
- break;
-
- case IBV_QPT_UD:
- ((struct mthca_tavor_ud_seg *) wqe)->lkey =
- htonl(to_mah(wr->wr.ud.ah)->key);
- ((struct mthca_tavor_ud_seg *) wqe)->av_addr =
- htonll((uintptr_t) to_mah(wr->wr.ud.ah)->av);
- ((struct mthca_tavor_ud_seg *) wqe)->dqpn =
- htonl(wr->wr.ud.remote_qpn);
- ((struct mthca_tavor_ud_seg *) wqe)->qkey =
- htonl(wr->wr.ud.remote_qkey);
-
- wqe += sizeof (struct mthca_tavor_ud_seg);
- size += sizeof (struct mthca_tavor_ud_seg) / 16;
- break;
-
- default:
- break;
- }
-
- if (wr->num_sge > qp->sq.max_gs) {
- ret = -1;
- *bad_wr = wr;
- goto out;
- }
-
- if (wr->send_flags & IBV_SEND_INLINE) {
- if (wr->num_sge) {
- struct mthca_inline_seg *seg = wqe;
- int s = 0;
-
- wqe += sizeof *seg;
- for (i = 0; i < wr->num_sge; ++i) {
- struct ibv_sge *sge = &wr->sg_list[i];
-
- s += sge->length;
-
- if (s > qp->max_inline_data) {
- ret = -1;
- *bad_wr = wr;
- goto out;
- }
-
- memcpy(wqe, (void *) (intptr_t) sge->addr,
- sge->length);
- wqe += sge->length;
- }
-
- seg->byte_count = htonl(MTHCA_INLINE_SEG | s);
- size += align(s + sizeof *seg, 16) / 16;
- }
- } else {
- struct mthca_data_seg *seg;
-
- for (i = 0; i < wr->num_sge; ++i) {
- seg = wqe;
- seg->byte_count = htonl(wr->sg_list[i].length);
- seg->lkey = htonl(wr->sg_list[i].lkey);
- seg->addr = htonll(wr->sg_list[i].addr);
- wqe += sizeof *seg;
- }
-
- size += wr->num_sge * (sizeof *seg / 16);
- }
-
- qp->wrid[ind + qp->rq.max] = wr->wr_id;
-
- if (wr->opcode >= sizeof mthca_opcode / sizeof mthca_opcode[0]) {
- ret = -1;
- *bad_wr = wr;
- goto out;
- }
-
- ((struct mthca_next_seg *) prev_wqe)->nda_op =
- htonl(((ind << qp->sq.wqe_shift) +
- qp->send_wqe_offset) |
- mthca_opcode[wr->opcode]);
- /*
- * Make sure that nda_op is written before setting ee_nds.
- */
- wmb();
- ((struct mthca_next_seg *) prev_wqe)->ee_nds =
- htonl((size0 ? 0 : MTHCA_NEXT_DBD) | size |
- ((wr->send_flags & IBV_SEND_FENCE) ?
- MTHCA_NEXT_FENCE : 0));
-
- if (!size0) {
- size0 = size;
- op0 = mthca_opcode[wr->opcode];
- f0 = wr->send_flags & IBV_SEND_FENCE ?
- MTHCA_SEND_DOORBELL_FENCE : 0;
- }
-
- ++ind;
- if (ind >= qp->sq.max)
- ind -= qp->sq.max;
- }
-
-out:
- if (nreq) {
- uint32_t doorbell[2];
-
- doorbell[0] = htonl(((qp->sq.next_ind << qp->sq.wqe_shift) +
- qp->send_wqe_offset) | f0 | op0);
- doorbell[1] = htonl((ibqp->qp_num << 8) | size0);
-
- mthca_write64(doorbell, to_mctx(ibqp->context), MTHCA_SEND_DOORBELL);
- }
-
- qp->sq.next_ind = ind;
- qp->sq.head += nreq;
-
- pthread_spin_unlock(&qp->sq.lock);
- return ret;
-}
-
-int mthca_tavor_post_recv(struct ibv_qp *ibqp, struct ibv_recv_wr *wr,
- struct ibv_recv_wr **bad_wr)
-{
- struct mthca_qp *qp = to_mqp(ibqp);
- uint32_t doorbell[2];
- int ret = 0;
- int nreq;
- int i;
- int size;
- int size0 = 0;
- int ind;
- void *wqe;
- void *prev_wqe;
-
- pthread_spin_lock(&qp->rq.lock);
-
- ind = qp->rq.next_ind;
-
- for (nreq = 0; wr; wr = wr->next) {
- if (wq_overflow(&qp->rq, nreq, to_mcq(qp->ibv_qp.recv_cq))) {
- ret = -1;
- *bad_wr = wr;
- goto out;
- }
-
- wqe = get_recv_wqe(qp, ind);
- prev_wqe = qp->rq.last;
- qp->rq.last = wqe;
-
- ((struct mthca_next_seg *) wqe)->ee_nds =
- htonl(MTHCA_NEXT_DBD);
- ((struct mthca_next_seg *) wqe)->flags =
- htonl(MTHCA_NEXT_CQ_UPDATE);
-
- wqe += sizeof (struct mthca_next_seg);
- size = sizeof (struct mthca_next_seg) / 16;
-
- if (wr->num_sge > qp->rq.max_gs) {
- ret = -1;
- *bad_wr = wr;
- goto out;
- }
-
- for (i = 0; i < wr->num_sge; ++i) {
- ((struct mthca_data_seg *) wqe)->byte_count =
- htonl(wr->sg_list[i].length);
- ((struct mthca_data_seg *) wqe)->lkey =
- htonl(wr->sg_list[i].lkey);
- ((struct mthca_data_seg *) wqe)->addr =
- htonll(wr->sg_list[i].addr);
- wqe += sizeof (struct mthca_data_seg);
- size += sizeof (struct mthca_data_seg) / 16;
- }
-
- qp->wrid[ind] = wr->wr_id;
-
- ((struct mthca_next_seg *) prev_wqe)->ee_nds =
- htonl(MTHCA_NEXT_DBD | size);
-
- if (!size0)
- size0 = size;
-
- ++ind;
- if (ind >= qp->rq.max)
- ind -= qp->rq.max;
-
- ++nreq;
- if (nreq == MTHCA_TAVOR_MAX_WQES_PER_RECV_DB) {
- nreq = 0;
-
- doorbell[0] = htonl((qp->rq.next_ind << qp->rq.wqe_shift) | size0);
- doorbell[1] = htonl(ibqp->qp_num << 8);
-
- /*
- * Make sure that descriptors are written
- * before doorbell is rung.
- */
- wmb();
-
- mthca_write64(doorbell, to_mctx(ibqp->context), MTHCA_RECV_DOORBELL);
-
- qp->rq.next_ind = ind;
- qp->rq.head += MTHCA_TAVOR_MAX_WQES_PER_RECV_DB;
- size0 = 0;
- }
- }
-
-out:
- if (nreq) {
- doorbell[0] = htonl((qp->rq.next_ind << qp->rq.wqe_shift) | size0);
- doorbell[1] = htonl((ibqp->qp_num << 8) | nreq);
-
- /*
- * Make sure that descriptors are written before
- * doorbell is rung.
- */
- wmb();
-
- mthca_write64(doorbell, to_mctx(ibqp->context), MTHCA_RECV_DOORBELL);
- }
-
- qp->rq.next_ind = ind;
- qp->rq.head += nreq;
-
- pthread_spin_unlock(&qp->rq.lock);
- return ret;
-}
-
-int mthca_arbel_post_send(struct ibv_qp *ibqp, struct ibv_send_wr *wr,
- struct ibv_send_wr **bad_wr)
-{
- struct mthca_qp *qp = to_mqp(ibqp);
- uint32_t doorbell[2];
- void *wqe, *prev_wqe;
- int ind;
- int nreq;
- int ret = 0;
- int size;
- int size0 = 0;
- int i;
- /*
- * f0 and op0 cannot be used unless nreq > 0, which means this
- * function makes it through the loop at least once. So the
- * code inside the if (!size0) will be executed, and f0 and
- * op0 will be initialized. So any gcc warning about "may be
- * used unitialized" is bogus.
- */
- uint32_t f0;
- uint32_t op0;
-
- pthread_spin_lock(&qp->sq.lock);
-
- /* XXX check that state is OK to post send */
-
- ind = qp->sq.head & (qp->sq.max - 1);
-
- for (nreq = 0; wr; ++nreq, wr = wr->next) {
- if (nreq == MTHCA_ARBEL_MAX_WQES_PER_SEND_DB) {
- nreq = 0;
-
- doorbell[0] = htonl((MTHCA_ARBEL_MAX_WQES_PER_SEND_DB << 24) |
- ((qp->sq.head & 0xffff) << 8) | f0 | op0);
- doorbell[1] = htonl((ibqp->qp_num << 8) | size0);
-
- qp->sq.head += MTHCA_ARBEL_MAX_WQES_PER_SEND_DB;
-
- /*
- * Make sure that descriptors are written before
- * doorbell record.
- */
- wmb();
- *qp->sq.db = htonl(qp->sq.head & 0xffff);
-
- /*
- * Make sure doorbell record is written before we
- * write MMIO send doorbell.
- */
- wmb();
- mthca_write64(doorbell, to_mctx(ibqp->context), MTHCA_SEND_DOORBELL);
-
- size0 = 0;
- }
-
- if (wq_overflow(&qp->sq, nreq, to_mcq(qp->ibv_qp.send_cq))) {
- ret = -1;
- *bad_wr = wr;
- goto out;
- }
-
- wqe = get_send_wqe(qp, ind);
- prev_wqe = qp->sq.last;
- qp->sq.last = wqe;
-
- ((struct mthca_next_seg *) wqe)->flags =
- ((wr->send_flags & IBV_SEND_SIGNALED) ?
- htonl(MTHCA_NEXT_CQ_UPDATE) : 0) |
- ((wr->send_flags & IBV_SEND_SOLICITED) ?
- htonl(MTHCA_NEXT_SOLICIT) : 0) |
- htonl(1);
- if (wr->opcode == IBV_WR_SEND_WITH_IMM ||
- wr->opcode == IBV_WR_RDMA_WRITE_WITH_IMM)
- ((struct mthca_next_seg *) wqe)->imm = wr->imm_data;
-
- wqe += sizeof (struct mthca_next_seg);
- size = sizeof (struct mthca_next_seg) / 16;
-
- switch (ibqp->qp_type) {
- case IBV_QPT_RC:
- switch (wr->opcode) {
- case IBV_WR_ATOMIC_CMP_AND_SWP:
- case IBV_WR_ATOMIC_FETCH_AND_ADD:
- ((struct mthca_raddr_seg *) wqe)->raddr =
- htonll(wr->wr.atomic.remote_addr);
- ((struct mthca_raddr_seg *) wqe)->rkey =
- htonl(wr->wr.atomic.rkey);
- ((struct mthca_raddr_seg *) wqe)->reserved = 0;
-
- wqe += sizeof (struct mthca_raddr_seg);
-
- if (wr->opcode == IBV_WR_ATOMIC_CMP_AND_SWP) {
- ((struct mthca_atomic_seg *) wqe)->swap_add =
- htonll(wr->wr.atomic.swap);
- ((struct mthca_atomic_seg *) wqe)->compare =
- htonll(wr->wr.atomic.compare_add);
- } else {
- ((struct mthca_atomic_seg *) wqe)->swap_add =
- htonll(wr->wr.atomic.compare_add);
- ((struct mthca_atomic_seg *) wqe)->compare = 0;
- }
-
- wqe += sizeof (struct mthca_atomic_seg);
- size += (sizeof (struct mthca_raddr_seg) +
- sizeof (struct mthca_atomic_seg)) / 16;
- break;
-
- case IBV_WR_RDMA_WRITE:
- case IBV_WR_RDMA_WRITE_WITH_IMM:
- case IBV_WR_RDMA_READ:
- ((struct mthca_raddr_seg *) wqe)->raddr =
- htonll(wr->wr.rdma.remote_addr);
- ((struct mthca_raddr_seg *) wqe)->rkey =
- htonl(wr->wr.rdma.rkey);
- ((struct mthca_raddr_seg *) wqe)->reserved = 0;
- wqe += sizeof (struct mthca_raddr_seg);
- size += sizeof (struct mthca_raddr_seg) / 16;
- break;
-
- default:
- /* No extra segments required for sends */
- break;
- }
-
- break;
-
- case IBV_QPT_UC:
- switch (wr->opcode) {
- case IBV_WR_RDMA_WRITE:
- case IBV_WR_RDMA_WRITE_WITH_IMM:
- ((struct mthca_raddr_seg *) wqe)->raddr =
- htonll(wr->wr.rdma.remote_addr);
- ((struct mthca_raddr_seg *) wqe)->rkey =
- htonl(wr->wr.rdma.rkey);
- ((struct mthca_raddr_seg *) wqe)->reserved = 0;
- wqe += sizeof (struct mthca_raddr_seg);
- size += sizeof (struct mthca_raddr_seg) / 16;
- break;
-
- default:
- /* No extra segments required for sends */
- break;
- }
-
- break;
-
- case IBV_QPT_UD:
- memcpy(((struct mthca_arbel_ud_seg *) wqe)->av,
- to_mah(wr->wr.ud.ah)->av, sizeof (struct mthca_av));
- ((struct mthca_arbel_ud_seg *) wqe)->dqpn =
- htonl(wr->wr.ud.remote_qpn);
- ((struct mthca_arbel_ud_seg *) wqe)->qkey =
- htonl(wr->wr.ud.remote_qkey);
-
- wqe += sizeof (struct mthca_arbel_ud_seg);
- size += sizeof (struct mthca_arbel_ud_seg) / 16;
- break;
-
- default:
- break;
- }
-
- if (wr->num_sge > qp->sq.max_gs) {
- ret = -1;
- *bad_wr = wr;
- goto out;
- }
-
- if (wr->send_flags & IBV_SEND_INLINE) {
- if (wr->num_sge) {
- struct mthca_inline_seg *seg = wqe;
- int s = 0;
-
- wqe += sizeof *seg;
- for (i = 0; i < wr->num_sge; ++i) {
- struct ibv_sge *sge = &wr->sg_list[i];
-
- s += sge->length;
-
- if (s > qp->max_inline_data) {
- ret = -1;
- *bad_wr = wr;
- goto out;
- }
-
- memcpy(wqe, (void *) (uintptr_t) sge->addr,
- sge->length);
- wqe += sge->length;
- }
-
- seg->byte_count = htonl(MTHCA_INLINE_SEG | s);
- size += align(s + sizeof *seg, 16) / 16;
- }
- } else {
- struct mthca_data_seg *seg;
-
- for (i = 0; i < wr->num_sge; ++i) {
- seg = wqe;
- seg->byte_count = htonl(wr->sg_list[i].length);
- seg->lkey = htonl(wr->sg_list[i].lkey);
- seg->addr = htonll(wr->sg_list[i].addr);
- wqe += sizeof *seg;
- }
-
- size += wr->num_sge * (sizeof *seg / 16);
- }
-
- qp->wrid[ind + qp->rq.max] = wr->wr_id;
-
- if (wr->opcode >= sizeof mthca_opcode / sizeof mthca_opcode[0]) {
- ret = -1;
- *bad_wr = wr;
- goto out;
- }
-
- ((struct mthca_next_seg *) prev_wqe)->nda_op =
- htonl(((ind << qp->sq.wqe_shift) +
- qp->send_wqe_offset) |
- mthca_opcode[wr->opcode]);
- wmb();
- ((struct mthca_next_seg *) prev_wqe)->ee_nds =
- htonl(MTHCA_NEXT_DBD | size |
- ((wr->send_flags & IBV_SEND_FENCE) ?
- MTHCA_NEXT_FENCE : 0));
-
- if (!size0) {
- size0 = size;
- op0 = mthca_opcode[wr->opcode];
- f0 = wr->send_flags & IBV_SEND_FENCE ?
- MTHCA_SEND_DOORBELL_FENCE : 0;
- }
-
- ++ind;
- if (ind >= qp->sq.max)
- ind -= qp->sq.max;
- }
-
-out:
- if (nreq) {
- doorbell[0] = htonl((nreq << 24) |
- ((qp->sq.head & 0xffff) << 8) |
- f0 | op0);
- doorbell[1] = htonl((ibqp->qp_num << 8) | size0);
-
- qp->sq.head += nreq;
-
- /*
- * Make sure that descriptors are written before
- * doorbell record.
- */
- wmb();
- *qp->sq.db = htonl(qp->sq.head & 0xffff);
-
- /*
- * Make sure doorbell record is written before we
- * write MMIO send doorbell.
- */
- wmb();
- mthca_write64(doorbell, to_mctx(ibqp->context), MTHCA_SEND_DOORBELL);
- }
-
- pthread_spin_unlock(&qp->sq.lock);
- return ret;
-}
-
-int mthca_arbel_post_recv(struct ibv_qp *ibqp, struct ibv_recv_wr *wr,
- struct ibv_recv_wr **bad_wr)
-{
- struct mthca_qp *qp = to_mqp(ibqp);
- int ret = 0;
- int nreq;
- int ind;
- int i;
- void *wqe;
-
- pthread_spin_lock(&qp->rq.lock);
-
- /* XXX check that state is OK to post receive */
-
- ind = qp->rq.head & (qp->rq.max - 1);
-
- for (nreq = 0; wr; ++nreq, wr = wr->next) {
- if (wq_overflow(&qp->rq, nreq, to_mcq(qp->ibv_qp.recv_cq))) {
- ret = -1;
- *bad_wr = wr;
- goto out;
- }
-
- wqe = get_recv_wqe(qp, ind);
-
- ((struct mthca_next_seg *) wqe)->flags = 0;
-
- wqe += sizeof (struct mthca_next_seg);
-
- if (wr->num_sge > qp->rq.max_gs) {
- ret = -1;
- *bad_wr = wr;
- goto out;
- }
-
- for (i = 0; i < wr->num_sge; ++i) {
- ((struct mthca_data_seg *) wqe)->byte_count =
- htonl(wr->sg_list[i].length);
- ((struct mthca_data_seg *) wqe)->lkey =
- htonl(wr->sg_list[i].lkey);
- ((struct mthca_data_seg *) wqe)->addr =
- htonll(wr->sg_list[i].addr);
- wqe += sizeof (struct mthca_data_seg);
- }
-
- if (i < qp->rq.max_gs) {
- ((struct mthca_data_seg *) wqe)->byte_count = 0;
- ((struct mthca_data_seg *) wqe)->lkey = htonl(MTHCA_INVAL_LKEY);
- ((struct mthca_data_seg *) wqe)->addr = 0;
- }
-
- qp->wrid[ind] = wr->wr_id;
-
- ++ind;
- if (ind >= qp->rq.max)
- ind -= qp->rq.max;
- }
-out:
- if (nreq) {
- qp->rq.head += nreq;
-
- /*
- * Make sure that descriptors are written before
- * doorbell record.
- */
- wmb();
- *qp->rq.db = htonl(qp->rq.head & 0xffff);
- }
-
- pthread_spin_unlock(&qp->rq.lock);
- return ret;
-}
-
-int mthca_alloc_qp_buf(struct ibv_pd *pd, struct ibv_qp_cap *cap,
- enum ibv_qp_type type, struct mthca_qp *qp)
-{
- int size;
- int max_sq_sge;
- struct mthca_next_seg *next;
- int i;
-
- qp->rq.max_gs = cap->max_recv_sge;
- qp->sq.max_gs = cap->max_send_sge;
- max_sq_sge = align(cap->max_inline_data + sizeof (struct mthca_inline_seg),
- sizeof (struct mthca_data_seg)) / sizeof (struct mthca_data_seg);
- if (max_sq_sge < cap->max_send_sge)
- max_sq_sge = cap->max_send_sge;
-
- qp->wrid = malloc((qp->rq.max + qp->sq.max) * sizeof (uint64_t));
- if (!qp->wrid)
- return -1;
-
- size = sizeof (struct mthca_next_seg) +
- qp->rq.max_gs * sizeof (struct mthca_data_seg);
-
- for (qp->rq.wqe_shift = 6; 1 << qp->rq.wqe_shift < size;
- qp->rq.wqe_shift++)
- ; /* nothing */
-
- size = max_sq_sge * sizeof (struct mthca_data_seg);
- switch (type) {
- case IBV_QPT_UD:
- size += mthca_is_memfree(pd->context) ?
- sizeof (struct mthca_arbel_ud_seg) :
- sizeof (struct mthca_tavor_ud_seg);
- break;
-
- case IBV_QPT_UC:
- size += sizeof (struct mthca_raddr_seg);
- break;
-
- case IBV_QPT_RC:
- size += sizeof (struct mthca_raddr_seg);
- /*
- * An atomic op will require an atomic segment, a
- * remote address segment and one scatter entry.
- */
- if (size < (sizeof (struct mthca_atomic_seg) +
- sizeof (struct mthca_raddr_seg) +
- sizeof (struct mthca_data_seg)))
- size = (sizeof (struct mthca_atomic_seg) +
- sizeof (struct mthca_raddr_seg) +
- sizeof (struct mthca_data_seg));
- break;
-
- default:
- break;
- }
-
- /* Make sure that we have enough space for a bind request */
- if (size < sizeof (struct mthca_bind_seg))
- size = sizeof (struct mthca_bind_seg);
-
- size += sizeof (struct mthca_next_seg);
-
- for (qp->sq.wqe_shift = 6; 1 << qp->sq.wqe_shift < size;
- qp->sq.wqe_shift++)
- ; /* nothing */
-
- qp->send_wqe_offset = align(qp->rq.max << qp->rq.wqe_shift,
- 1 << qp->sq.wqe_shift);
-
- qp->buf_size = qp->send_wqe_offset + (qp->sq.max << qp->sq.wqe_shift);
-
- if (mthca_alloc_buf(&qp->buf,
- align(qp->buf_size, to_mdev(pd->context->device)->page_size),
- to_mdev(pd->context->device)->page_size)) {
- free(qp->wrid);
- return -1;
- }
-
- memset(qp->buf.buf, 0, qp->buf_size);
-
- if (mthca_is_memfree(pd->context)) {
- struct mthca_data_seg *scatter;
- uint32_t sz;
-
- sz = htonl((sizeof (struct mthca_next_seg) +
- qp->rq.max_gs * sizeof (struct mthca_data_seg)) / 16);
-
- for (i = 0; i < qp->rq.max; ++i) {
- next = get_recv_wqe(qp, i);
- next->nda_op = htonl(((i + 1) & (qp->rq.max - 1)) <<
- qp->rq.wqe_shift);
- next->ee_nds = sz;
-
- for (scatter = (void *) (next + 1);
- (void *) scatter < (void *) next + (1 << qp->rq.wqe_shift);
- ++scatter)
- scatter->lkey = htonl(MTHCA_INVAL_LKEY);
- }
-
- for (i = 0; i < qp->sq.max; ++i) {
- next = get_send_wqe(qp, i);
- next->nda_op = htonl((((i + 1) & (qp->sq.max - 1)) <<
- qp->sq.wqe_shift) +
- qp->send_wqe_offset);
- }
- } else {
- for (i = 0; i < qp->rq.max; ++i) {
- next = get_recv_wqe(qp, i);
- next->nda_op = htonl((((i + 1) % qp->rq.max) <<
- qp->rq.wqe_shift) | 1);
- }
- }
-
- qp->sq.last = get_send_wqe(qp, qp->sq.max - 1);
- qp->rq.last = get_recv_wqe(qp, qp->rq.max - 1);
-
- return 0;
-}
-
-struct mthca_qp *mthca_find_qp(struct mthca_context *ctx, uint32_t qpn)
-{
- int tind = (qpn & (ctx->num_qps - 1)) >> ctx->qp_table_shift;
-
- if (ctx->qp_table[tind].refcnt)
- return ctx->qp_table[tind].table[qpn & ctx->qp_table_mask];
- else
- return NULL;
-}
-
-int mthca_store_qp(struct mthca_context *ctx, uint32_t qpn, struct mthca_qp *qp)
-{
- int tind = (qpn & (ctx->num_qps - 1)) >> ctx->qp_table_shift;
-
- if (!ctx->qp_table[tind].refcnt) {
- ctx->qp_table[tind].table = calloc(ctx->qp_table_mask + 1,
- sizeof (struct mthca_qp *));
- if (!ctx->qp_table[tind].table)
- return -1;
- }
-
- ++ctx->qp_table[tind].refcnt;
- ctx->qp_table[tind].table[qpn & ctx->qp_table_mask] = qp;
- return 0;
-}
-
-void mthca_clear_qp(struct mthca_context *ctx, uint32_t qpn)
-{
- int tind = (qpn & (ctx->num_qps - 1)) >> ctx->qp_table_shift;
-
- if (!--ctx->qp_table[tind].refcnt)
- free(ctx->qp_table[tind].table);
- else
- ctx->qp_table[tind].table[qpn & ctx->qp_table_mask] = NULL;
-}
-
-int mthca_free_err_wqe(struct mthca_qp *qp, int is_send,
- int index, int *dbd, uint32_t *new_wqe)
-{
- struct mthca_next_seg *next;
-
- /*
- * For SRQs, all receive WQEs generate a CQE, so we're always
- * at the end of the doorbell chain.
- */
- if (qp->ibv_qp.srq && !is_send) {
- *new_wqe = 0;
- return 0;
- }
-
- if (is_send)
- next = get_send_wqe(qp, index);
- else
- next = get_recv_wqe(qp, index);
-
- *dbd = !!(next->ee_nds & htonl(MTHCA_NEXT_DBD));
- if (next->ee_nds & htonl(0x3f))
- *new_wqe = (next->nda_op & htonl(~0x3f)) |
- (next->ee_nds & htonl(0x3f));
- else
- *new_wqe = 0;
-
- return 0;
-}
-
diff --git a/contrib/ofed/libmthca/src/srq.c b/contrib/ofed/libmthca/src/srq.c
deleted file mode 100644
index 97a0c74..0000000
--- a/contrib/ofed/libmthca/src/srq.c
+++ /dev/null
@@ -1,312 +0,0 @@
-/*
- * Copyright (c) 2005 Cisco Systems. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-#if HAVE_CONFIG_H
-# include <config.h>
-#endif /* HAVE_CONFIG_H */
-
-#include <stdlib.h>
-#include <netinet/in.h>
-#include <pthread.h>
-#include <string.h>
-
-#include "mthca.h"
-#include "doorbell.h"
-#include "wqe.h"
-
-static void *get_wqe(struct mthca_srq *srq, int n)
-{
- return srq->buf.buf + (n << srq->wqe_shift);
-}
-
-/*
- * Return a pointer to the location within a WQE that we're using as a
- * link when the WQE is in the free list. We use the imm field at an
- * offset of 12 bytes because in the Tavor case, posting a WQE may
- * overwrite the next segment of the previous WQE, but a receive WQE
- * will never touch the imm field. This avoids corrupting our free
- * list if the previous WQE has already completed and been put on the
- * free list when we post the next WQE.
- */
-static inline int *wqe_to_link(void *wqe)
-{
- return (int *) (wqe + 12);
-}
-
-void mthca_free_srq_wqe(struct mthca_srq *srq, int ind)
-{
- struct mthca_next_seg *last_free;
-
- pthread_spin_lock(&srq->lock);
-
- last_free = get_wqe(srq, srq->last_free);
- *wqe_to_link(last_free) = ind;
- last_free->nda_op = htonl((ind << srq->wqe_shift) | 1);
- *wqe_to_link(get_wqe(srq, ind)) = -1;
- srq->last_free = ind;
-
- pthread_spin_unlock(&srq->lock);
-}
-
-int mthca_tavor_post_srq_recv(struct ibv_srq *ibsrq,
- struct ibv_recv_wr *wr,
- struct ibv_recv_wr **bad_wr)
-{
- struct mthca_srq *srq = to_msrq(ibsrq);
- uint32_t doorbell[2];
- int err = 0;
- int first_ind;
- int ind;
- int next_ind;
- int nreq;
- int i;
- void *wqe;
- void *prev_wqe;
-
- pthread_spin_lock(&srq->lock);
-
- first_ind = srq->first_free;
-
- for (nreq = 0; wr; wr = wr->next) {
- ind = srq->first_free;
- wqe = get_wqe(srq, ind);
- next_ind = *wqe_to_link(wqe);
-
- if (next_ind < 0) {
- err = -1;
- *bad_wr = wr;
- break;
- }
-
- prev_wqe = srq->last;
- srq->last = wqe;
-
- ((struct mthca_next_seg *) wqe)->ee_nds = 0;
- /* flags field will always remain 0 */
-
- wqe += sizeof (struct mthca_next_seg);
-
- if (wr->num_sge > srq->max_gs) {
- err = -1;
- *bad_wr = wr;
- srq->last = prev_wqe;
- break;
- }
-
- for (i = 0; i < wr->num_sge; ++i) {
- ((struct mthca_data_seg *) wqe)->byte_count =
- htonl(wr->sg_list[i].length);
- ((struct mthca_data_seg *) wqe)->lkey =
- htonl(wr->sg_list[i].lkey);
- ((struct mthca_data_seg *) wqe)->addr =
- htonll(wr->sg_list[i].addr);
- wqe += sizeof (struct mthca_data_seg);
- }
-
- if (i < srq->max_gs) {
- ((struct mthca_data_seg *) wqe)->byte_count = 0;
- ((struct mthca_data_seg *) wqe)->lkey = htonl(MTHCA_INVAL_LKEY);
- ((struct mthca_data_seg *) wqe)->addr = 0;
- }
-
- ((struct mthca_next_seg *) prev_wqe)->ee_nds =
- htonl(MTHCA_NEXT_DBD);
-
- srq->wrid[ind] = wr->wr_id;
- srq->first_free = next_ind;
-
- if (++nreq == MTHCA_TAVOR_MAX_WQES_PER_RECV_DB) {
- nreq = 0;
-
- doorbell[0] = htonl(first_ind << srq->wqe_shift);
- doorbell[1] = htonl(srq->srqn << 8);
-
- /*
- * Make sure that descriptors are written
- * before doorbell is rung.
- */
- wmb();
-
- mthca_write64(doorbell, to_mctx(ibsrq->context), MTHCA_RECV_DOORBELL);
-
- first_ind = srq->first_free;
- }
- }
-
- if (nreq) {
- doorbell[0] = htonl(first_ind << srq->wqe_shift);
- doorbell[1] = htonl((srq->srqn << 8) | nreq);
-
- /*
- * Make sure that descriptors are written before
- * doorbell is rung.
- */
- wmb();
-
- mthca_write64(doorbell, to_mctx(ibsrq->context), MTHCA_RECV_DOORBELL);
- }
-
- pthread_spin_unlock(&srq->lock);
- return err;
-}
-
-int mthca_arbel_post_srq_recv(struct ibv_srq *ibsrq,
- struct ibv_recv_wr *wr,
- struct ibv_recv_wr **bad_wr)
-{
- struct mthca_srq *srq = to_msrq(ibsrq);
- int err = 0;
- int ind;
- int next_ind;
- int nreq;
- int i;
- void *wqe;
-
- pthread_spin_lock(&srq->lock);
-
- for (nreq = 0; wr; ++nreq, wr = wr->next) {
- ind = srq->first_free;
- wqe = get_wqe(srq, ind);
- next_ind = *wqe_to_link(wqe);
-
- if (next_ind < 0) {
- err = -1;
- *bad_wr = wr;
- break;
- }
-
- ((struct mthca_next_seg *) wqe)->ee_nds = 0;
- /* flags field will always remain 0 */
-
- wqe += sizeof (struct mthca_next_seg);
-
- if (wr->num_sge > srq->max_gs) {
- err = -1;
- *bad_wr = wr;
- break;
- }
-
- for (i = 0; i < wr->num_sge; ++i) {
- ((struct mthca_data_seg *) wqe)->byte_count =
- htonl(wr->sg_list[i].length);
- ((struct mthca_data_seg *) wqe)->lkey =
- htonl(wr->sg_list[i].lkey);
- ((struct mthca_data_seg *) wqe)->addr =
- htonll(wr->sg_list[i].addr);
- wqe += sizeof (struct mthca_data_seg);
- }
-
- if (i < srq->max_gs) {
- ((struct mthca_data_seg *) wqe)->byte_count = 0;
- ((struct mthca_data_seg *) wqe)->lkey = htonl(MTHCA_INVAL_LKEY);
- ((struct mthca_data_seg *) wqe)->addr = 0;
- }
-
- srq->wrid[ind] = wr->wr_id;
- srq->first_free = next_ind;
- }
-
- if (nreq) {
- srq->counter += nreq;
-
- /*
- * Make sure that descriptors are written before
- * we write doorbell record.
- */
- wmb();
- *srq->db = htonl(srq->counter);
- }
-
- pthread_spin_unlock(&srq->lock);
- return err;
-}
-
-int mthca_alloc_srq_buf(struct ibv_pd *pd, struct ibv_srq_attr *attr,
- struct mthca_srq *srq)
-{
- struct mthca_data_seg *scatter;
- void *wqe;
- int size;
- int i;
-
- srq->wrid = malloc(srq->max * sizeof (uint64_t));
- if (!srq->wrid)
- return -1;
-
- size = sizeof (struct mthca_next_seg) +
- srq->max_gs * sizeof (struct mthca_data_seg);
-
- for (srq->wqe_shift = 6; 1 << srq->wqe_shift < size; ++srq->wqe_shift)
- ; /* nothing */
-
- srq->buf_size = srq->max << srq->wqe_shift;
-
- if (mthca_alloc_buf(&srq->buf,
- align(srq->buf_size, to_mdev(pd->context->device)->page_size),
- to_mdev(pd->context->device)->page_size)) {
- free(srq->wrid);
- return -1;
- }
-
- memset(srq->buf.buf, 0, srq->buf_size);
-
- /*
- * Now initialize the SRQ buffer so that all of the WQEs are
- * linked into the list of free WQEs. In addition, set the
- * scatter list L_Keys to the sentry value of 0x100.
- */
-
- for (i = 0; i < srq->max; ++i) {
- struct mthca_next_seg *next;
-
- next = wqe = get_wqe(srq, i);
-
- if (i < srq->max - 1) {
- *wqe_to_link(wqe) = i + 1;
- next->nda_op = htonl(((i + 1) << srq->wqe_shift) | 1);
- } else {
- *wqe_to_link(wqe) = -1;
- next->nda_op = 0;
- }
-
- for (scatter = wqe + sizeof (struct mthca_next_seg);
- (void *) scatter < wqe + (1 << srq->wqe_shift);
- ++scatter)
- scatter->lkey = htonl(MTHCA_INVAL_LKEY);
- }
-
- srq->first_free = 0;
- srq->last_free = srq->max - 1;
- srq->last = get_wqe(srq, srq->max - 1);
-
- return 0;
-}
diff --git a/contrib/ofed/libmthca/src/verbs.c b/contrib/ofed/libmthca/src/verbs.c
deleted file mode 100644
index b2ef3ec..0000000
--- a/contrib/ofed/libmthca/src/verbs.c
+++ /dev/null
@@ -1,758 +0,0 @@
-/*
- * Copyright (c) 2005 Topspin Communications. All rights reserved.
- * Copyright (c) 2005, 2006 Cisco Systems. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-#if HAVE_CONFIG_H
-# include <config.h>
-#endif /* HAVE_CONFIG_H */
-
-#include <stdlib.h>
-#include <stdio.h>
-#include <strings.h>
-#include <pthread.h>
-#include <errno.h>
-#include <netinet/in.h>
-
-#include "mthca.h"
-#include "mthca-abi.h"
-
-int mthca_query_device(struct ibv_context *context, struct ibv_device_attr *attr)
-{
- struct ibv_query_device cmd;
- uint64_t raw_fw_ver;
- unsigned major, minor, sub_minor;
- int ret;
-
- ret = ibv_cmd_query_device(context, attr, &raw_fw_ver, &cmd, sizeof cmd);
- if (ret)
- return ret;
-
- major = (raw_fw_ver >> 32) & 0xffff;
- minor = (raw_fw_ver >> 16) & 0xffff;
- sub_minor = raw_fw_ver & 0xffff;
-
- snprintf(attr->fw_ver, sizeof attr->fw_ver,
- "%d.%d.%d", major, minor, sub_minor);
-
- return 0;
-}
-
-int mthca_query_port(struct ibv_context *context, uint8_t port,
- struct ibv_port_attr *attr)
-{
- struct ibv_query_port cmd;
-
- return ibv_cmd_query_port(context, port, attr, &cmd, sizeof cmd);
-}
-
-struct ibv_pd *mthca_alloc_pd(struct ibv_context *context)
-{
- struct ibv_alloc_pd cmd;
- struct mthca_alloc_pd_resp resp;
- struct mthca_pd *pd;
-
- pd = malloc(sizeof *pd);
- if (!pd)
- return NULL;
-
- if (!mthca_is_memfree(context)) {
- pd->ah_list = NULL;
- if (pthread_mutex_init(&pd->ah_mutex, NULL)) {
- free(pd);
- return NULL;
- }
- }
-
- if (ibv_cmd_alloc_pd(context, &pd->ibv_pd, &cmd, sizeof cmd,
- &resp.ibv_resp, sizeof resp)) {
- free(pd);
- return NULL;
- }
-
- pd->pdn = resp.pdn;
-
- return &pd->ibv_pd;
-}
-
-int mthca_free_pd(struct ibv_pd *pd)
-{
- int ret;
-
- ret = ibv_cmd_dealloc_pd(pd);
- if (ret)
- return ret;
-
- free(to_mpd(pd));
- return 0;
-}
-
-static struct ibv_mr *__mthca_reg_mr(struct ibv_pd *pd, void *addr,
- size_t length, uint64_t hca_va,
- enum ibv_access_flags access,
- int dma_sync)
-{
- struct ibv_mr *mr;
- struct mthca_reg_mr cmd;
- int ret;
-
- /*
- * Old kernels just ignore the extra data we pass in with the
- * reg_mr command structure, so there's no need to add an ABI
- * version check here (and indeed the kernel ABI was not
- * incremented due to this change).
- */
- cmd.mr_attrs = dma_sync ? MTHCA_MR_DMASYNC : 0;
- cmd.reserved = 0;
-
- mr = malloc(sizeof *mr);
- if (!mr)
- return NULL;
-
-#ifdef IBV_CMD_REG_MR_HAS_RESP_PARAMS
- {
- struct ibv_reg_mr_resp resp;
-
- ret = ibv_cmd_reg_mr(pd, addr, length, hca_va, access, mr,
- &cmd.ibv_cmd, sizeof cmd, &resp, sizeof resp);
- }
-#else
- ret = ibv_cmd_reg_mr(pd, addr, length, hca_va, access, mr,
- &cmd.ibv_cmd, sizeof cmd);
-#endif
- if (ret) {
- free(mr);
- return NULL;
- }
-
- return mr;
-}
-
-struct ibv_mr *mthca_reg_mr(struct ibv_pd *pd, void *addr,
- size_t length, enum ibv_access_flags access)
-{
- return __mthca_reg_mr(pd, addr, length, (uintptr_t) addr, access, 0);
-}
-
-int mthca_dereg_mr(struct ibv_mr *mr)
-{
- int ret;
-
- ret = ibv_cmd_dereg_mr(mr);
- if (ret)
- return ret;
-
- free(mr);
- return 0;
-}
-
-static int align_cq_size(int cqe)
-{
- int nent;
-
- for (nent = 1; nent <= cqe; nent <<= 1)
- ; /* nothing */
-
- return nent;
-}
-
-struct ibv_cq *mthca_create_cq(struct ibv_context *context, int cqe,
- struct ibv_comp_channel *channel,
- int comp_vector)
-{
- struct mthca_create_cq cmd;
- struct mthca_create_cq_resp resp;
- struct mthca_cq *cq;
- int ret;
-
- /* Sanity check CQ size before proceeding */
- if (cqe > 131072)
- return NULL;
-
- cq = malloc(sizeof *cq);
- if (!cq)
- return NULL;
-
- cq->cons_index = 0;
-
- if (pthread_spin_init(&cq->lock, PTHREAD_PROCESS_PRIVATE))
- goto err;
-
- cqe = align_cq_size(cqe);
- if (mthca_alloc_cq_buf(to_mdev(context->device), &cq->buf, cqe))
- goto err;
-
- cq->mr = __mthca_reg_mr(to_mctx(context)->pd, cq->buf.buf,
- cqe * MTHCA_CQ_ENTRY_SIZE,
- 0, IBV_ACCESS_LOCAL_WRITE, 1);
- if (!cq->mr)
- goto err_buf;
-
- cq->mr->context = context;
-
- if (mthca_is_memfree(context)) {
- cq->arm_sn = 1;
- cq->set_ci_db_index = mthca_alloc_db(to_mctx(context)->db_tab,
- MTHCA_DB_TYPE_CQ_SET_CI,
- &cq->set_ci_db);
- if (cq->set_ci_db_index < 0)
- goto err_unreg;
-
- cq->arm_db_index = mthca_alloc_db(to_mctx(context)->db_tab,
- MTHCA_DB_TYPE_CQ_ARM,
- &cq->arm_db);
- if (cq->arm_db_index < 0)
- goto err_set_db;
-
- cmd.arm_db_page = db_align(cq->arm_db);
- cmd.set_db_page = db_align(cq->set_ci_db);
- cmd.arm_db_index = cq->arm_db_index;
- cmd.set_db_index = cq->set_ci_db_index;
- } else {
- cmd.arm_db_page = cmd.set_db_page =
- cmd.arm_db_index = cmd.set_db_index = 0;
- }
-
- cmd.lkey = cq->mr->lkey;
- cmd.pdn = to_mpd(to_mctx(context)->pd)->pdn;
- ret = ibv_cmd_create_cq(context, cqe - 1, channel, comp_vector,
- &cq->ibv_cq, &cmd.ibv_cmd, sizeof cmd,
- &resp.ibv_resp, sizeof resp);
- if (ret)
- goto err_arm_db;
-
- cq->cqn = resp.cqn;
-
- if (mthca_is_memfree(context)) {
- mthca_set_db_qn(cq->set_ci_db, MTHCA_DB_TYPE_CQ_SET_CI, cq->cqn);
- mthca_set_db_qn(cq->arm_db, MTHCA_DB_TYPE_CQ_ARM, cq->cqn);
- }
-
- return &cq->ibv_cq;
-
-err_arm_db:
- if (mthca_is_memfree(context))
- mthca_free_db(to_mctx(context)->db_tab, MTHCA_DB_TYPE_CQ_ARM,
- cq->arm_db_index);
-
-err_set_db:
- if (mthca_is_memfree(context))
- mthca_free_db(to_mctx(context)->db_tab, MTHCA_DB_TYPE_CQ_SET_CI,
- cq->set_ci_db_index);
-
-err_unreg:
- mthca_dereg_mr(cq->mr);
-
-err_buf:
- mthca_free_buf(&cq->buf);
-
-err:
- free(cq);
-
- return NULL;
-}
-
-int mthca_resize_cq(struct ibv_cq *ibcq, int cqe)
-{
- struct mthca_cq *cq = to_mcq(ibcq);
- struct mthca_resize_cq cmd;
- struct ibv_mr *mr;
- struct mthca_buf buf;
- int old_cqe;
- int ret;
-
- /* Sanity check CQ size before proceeding */
- if (cqe > 131072)
- return EINVAL;
-
- pthread_spin_lock(&cq->lock);
-
- cqe = align_cq_size(cqe);
- if (cqe == ibcq->cqe + 1) {
- ret = 0;
- goto out;
- }
-
- ret = mthca_alloc_cq_buf(to_mdev(ibcq->context->device), &buf, cqe);
- if (ret)
- goto out;
-
- mr = __mthca_reg_mr(to_mctx(ibcq->context)->pd, buf.buf,
- cqe * MTHCA_CQ_ENTRY_SIZE,
- 0, IBV_ACCESS_LOCAL_WRITE, 1);
- if (!mr) {
- mthca_free_buf(&buf);
- ret = ENOMEM;
- goto out;
- }
-
- mr->context = ibcq->context;
-
- old_cqe = ibcq->cqe;
-
- cmd.lkey = mr->lkey;
-#ifdef IBV_CMD_RESIZE_CQ_HAS_RESP_PARAMS
- {
- struct ibv_resize_cq_resp resp;
- ret = ibv_cmd_resize_cq(ibcq, cqe - 1, &cmd.ibv_cmd, sizeof cmd,
- &resp, sizeof resp);
- }
-#else
- ret = ibv_cmd_resize_cq(ibcq, cqe - 1, &cmd.ibv_cmd, sizeof cmd);
-#endif
- if (ret) {
- mthca_dereg_mr(mr);
- mthca_free_buf(&buf);
- goto out;
- }
-
- mthca_cq_resize_copy_cqes(cq, buf.buf, old_cqe);
-
- mthca_dereg_mr(cq->mr);
- mthca_free_buf(&cq->buf);
-
- cq->buf = buf;
- cq->mr = mr;
-
-out:
- pthread_spin_unlock(&cq->lock);
- return ret;
-}
-
-int mthca_destroy_cq(struct ibv_cq *cq)
-{
- int ret;
-
- ret = ibv_cmd_destroy_cq(cq);
- if (ret)
- return ret;
-
- if (mthca_is_memfree(cq->context)) {
- mthca_free_db(to_mctx(cq->context)->db_tab, MTHCA_DB_TYPE_CQ_SET_CI,
- to_mcq(cq)->set_ci_db_index);
- mthca_free_db(to_mctx(cq->context)->db_tab, MTHCA_DB_TYPE_CQ_ARM,
- to_mcq(cq)->arm_db_index);
- }
-
- mthca_dereg_mr(to_mcq(cq)->mr);
- mthca_free_buf(&to_mcq(cq)->buf);
- free(to_mcq(cq));
-
- return 0;
-}
-
-static int align_queue_size(struct ibv_context *context, int size, int spare)
-{
- int ret;
-
- /*
- * If someone asks for a 0-sized queue, presumably they're not
- * going to use it. So don't mess with their size.
- */
- if (!size)
- return 0;
-
- if (mthca_is_memfree(context)) {
- for (ret = 1; ret < size + spare; ret <<= 1)
- ; /* nothing */
-
- return ret;
- } else
- return size + spare;
-}
-
-struct ibv_srq *mthca_create_srq(struct ibv_pd *pd,
- struct ibv_srq_init_attr *attr)
-{
- struct mthca_create_srq cmd;
- struct mthca_create_srq_resp resp;
- struct mthca_srq *srq;
- int ret;
-
- /* Sanity check SRQ size before proceeding */
- if (attr->attr.max_wr > 1 << 16 || attr->attr.max_sge > 64)
- return NULL;
-
- srq = malloc(sizeof *srq);
- if (!srq)
- return NULL;
-
- if (pthread_spin_init(&srq->lock, PTHREAD_PROCESS_PRIVATE))
- goto err;
-
- srq->max = align_queue_size(pd->context, attr->attr.max_wr, 1);
- srq->max_gs = attr->attr.max_sge;
- srq->counter = 0;
-
- if (mthca_alloc_srq_buf(pd, &attr->attr, srq))
- goto err;
-
- srq->mr = __mthca_reg_mr(pd, srq->buf.buf, srq->buf_size, 0, 0, 0);
- if (!srq->mr)
- goto err_free;
-
- srq->mr->context = pd->context;
-
- if (mthca_is_memfree(pd->context)) {
- srq->db_index = mthca_alloc_db(to_mctx(pd->context)->db_tab,
- MTHCA_DB_TYPE_SRQ, &srq->db);
- if (srq->db_index < 0)
- goto err_unreg;
-
- cmd.db_page = db_align(srq->db);
- cmd.db_index = srq->db_index;
- } else {
- cmd.db_page = cmd.db_index = 0;
- }
-
- cmd.lkey = srq->mr->lkey;
-
- ret = ibv_cmd_create_srq(pd, &srq->ibv_srq, attr,
- &cmd.ibv_cmd, sizeof cmd,
- &resp.ibv_resp, sizeof resp);
- if (ret)
- goto err_db;
-
- srq->srqn = resp.srqn;
-
- if (mthca_is_memfree(pd->context))
- mthca_set_db_qn(srq->db, MTHCA_DB_TYPE_SRQ, srq->srqn);
-
- return &srq->ibv_srq;
-
-err_db:
- if (mthca_is_memfree(pd->context))
- mthca_free_db(to_mctx(pd->context)->db_tab, MTHCA_DB_TYPE_SRQ,
- srq->db_index);
-
-err_unreg:
- mthca_dereg_mr(srq->mr);
-
-err_free:
- free(srq->wrid);
- mthca_free_buf(&srq->buf);
-
-err:
- free(srq);
-
- return NULL;
-}
-
-int mthca_modify_srq(struct ibv_srq *srq,
- struct ibv_srq_attr *attr,
- enum ibv_srq_attr_mask attr_mask)
-{
- struct ibv_modify_srq cmd;
-
- return ibv_cmd_modify_srq(srq, attr, attr_mask, &cmd, sizeof cmd);
-}
-
-int mthca_query_srq(struct ibv_srq *srq,
- struct ibv_srq_attr *attr)
-{
- struct ibv_query_srq cmd;
-
- return ibv_cmd_query_srq(srq, attr, &cmd, sizeof cmd);
-}
-
-int mthca_destroy_srq(struct ibv_srq *srq)
-{
- int ret;
-
- ret = ibv_cmd_destroy_srq(srq);
- if (ret)
- return ret;
-
- if (mthca_is_memfree(srq->context))
- mthca_free_db(to_mctx(srq->context)->db_tab, MTHCA_DB_TYPE_SRQ,
- to_msrq(srq)->db_index);
-
- mthca_dereg_mr(to_msrq(srq)->mr);
-
- mthca_free_buf(&to_msrq(srq)->buf);
- free(to_msrq(srq)->wrid);
- free(to_msrq(srq));
-
- return 0;
-}
-
-struct ibv_qp *mthca_create_qp(struct ibv_pd *pd, struct ibv_qp_init_attr *attr)
-{
- struct mthca_create_qp cmd;
- struct ibv_create_qp_resp resp;
- struct mthca_qp *qp;
- int ret;
-
- /* Sanity check QP size before proceeding */
- if (attr->cap.max_send_wr > 65536 ||
- attr->cap.max_recv_wr > 65536 ||
- attr->cap.max_send_sge > 64 ||
- attr->cap.max_recv_sge > 64 ||
- attr->cap.max_inline_data > 1024)
- return NULL;
-
- qp = malloc(sizeof *qp);
- if (!qp)
- return NULL;
-
- qp->sq.max = align_queue_size(pd->context, attr->cap.max_send_wr, 0);
- qp->rq.max = align_queue_size(pd->context, attr->cap.max_recv_wr, 0);
-
- if (mthca_alloc_qp_buf(pd, &attr->cap, attr->qp_type, qp))
- goto err;
-
- mthca_init_qp_indices(qp);
-
- if (pthread_spin_init(&qp->sq.lock, PTHREAD_PROCESS_PRIVATE) ||
- pthread_spin_init(&qp->rq.lock, PTHREAD_PROCESS_PRIVATE))
- goto err_free;
-
- qp->mr = __mthca_reg_mr(pd, qp->buf.buf, qp->buf_size, 0, 0, 0);
- if (!qp->mr)
- goto err_free;
-
- qp->mr->context = pd->context;
-
- cmd.lkey = qp->mr->lkey;
- cmd.reserved = 0;
-
- if (mthca_is_memfree(pd->context)) {
- qp->sq.db_index = mthca_alloc_db(to_mctx(pd->context)->db_tab,
- MTHCA_DB_TYPE_SQ,
- &qp->sq.db);
- if (qp->sq.db_index < 0)
- goto err_unreg;
-
- qp->rq.db_index = mthca_alloc_db(to_mctx(pd->context)->db_tab,
- MTHCA_DB_TYPE_RQ,
- &qp->rq.db);
- if (qp->rq.db_index < 0)
- goto err_sq_db;
-
- cmd.sq_db_page = db_align(qp->sq.db);
- cmd.rq_db_page = db_align(qp->rq.db);
- cmd.sq_db_index = qp->sq.db_index;
- cmd.rq_db_index = qp->rq.db_index;
- } else {
- cmd.sq_db_page = cmd.rq_db_page =
- cmd.sq_db_index = cmd.rq_db_index = 0;
- }
-
- pthread_mutex_lock(&to_mctx(pd->context)->qp_table_mutex);
- ret = ibv_cmd_create_qp(pd, &qp->ibv_qp, attr, &cmd.ibv_cmd, sizeof cmd,
- &resp, sizeof resp);
- if (ret)
- goto err_rq_db;
-
- if (mthca_is_memfree(pd->context)) {
- mthca_set_db_qn(qp->sq.db, MTHCA_DB_TYPE_SQ, qp->ibv_qp.qp_num);
- mthca_set_db_qn(qp->rq.db, MTHCA_DB_TYPE_RQ, qp->ibv_qp.qp_num);
- }
-
- ret = mthca_store_qp(to_mctx(pd->context), qp->ibv_qp.qp_num, qp);
- if (ret)
- goto err_destroy;
- pthread_mutex_unlock(&to_mctx(pd->context)->qp_table_mutex);
-
- qp->sq.max = attr->cap.max_send_wr;
- qp->rq.max = attr->cap.max_recv_wr;
- qp->sq.max_gs = attr->cap.max_send_sge;
- qp->rq.max_gs = attr->cap.max_recv_sge;
- qp->max_inline_data = attr->cap.max_inline_data;
-
- return &qp->ibv_qp;
-
-err_destroy:
- ibv_cmd_destroy_qp(&qp->ibv_qp);
-
-err_rq_db:
- pthread_mutex_unlock(&to_mctx(pd->context)->qp_table_mutex);
- if (mthca_is_memfree(pd->context))
- mthca_free_db(to_mctx(pd->context)->db_tab, MTHCA_DB_TYPE_RQ,
- qp->rq.db_index);
-
-err_sq_db:
- if (mthca_is_memfree(pd->context))
- mthca_free_db(to_mctx(pd->context)->db_tab, MTHCA_DB_TYPE_SQ,
- qp->sq.db_index);
-
-err_unreg:
- mthca_dereg_mr(qp->mr);
-
-err_free:
- free(qp->wrid);
- mthca_free_buf(&qp->buf);
-
-err:
- free(qp);
-
- return NULL;
-}
-
-int mthca_query_qp(struct ibv_qp *qp, struct ibv_qp_attr *attr,
- enum ibv_qp_attr_mask attr_mask,
- struct ibv_qp_init_attr *init_attr)
-{
- struct ibv_query_qp cmd;
-
- return ibv_cmd_query_qp(qp, attr, attr_mask, init_attr, &cmd, sizeof cmd);
-}
-
-int mthca_modify_qp(struct ibv_qp *qp, struct ibv_qp_attr *attr,
- enum ibv_qp_attr_mask attr_mask)
-{
- struct ibv_modify_qp cmd;
- int ret;
-
- ret = ibv_cmd_modify_qp(qp, attr, attr_mask, &cmd, sizeof cmd);
-
- if (!ret &&
- (attr_mask & IBV_QP_STATE) &&
- attr->qp_state == IBV_QPS_RESET) {
- mthca_cq_clean(to_mcq(qp->recv_cq), qp->qp_num,
- qp->srq ? to_msrq(qp->srq) : NULL);
- if (qp->send_cq != qp->recv_cq)
- mthca_cq_clean(to_mcq(qp->send_cq), qp->qp_num, NULL);
-
- mthca_init_qp_indices(to_mqp(qp));
-
- if (mthca_is_memfree(qp->context)) {
- *to_mqp(qp)->sq.db = 0;
- *to_mqp(qp)->rq.db = 0;
- }
- }
-
- return ret;
-}
-
-static void mthca_lock_cqs(struct ibv_qp *qp)
-{
- struct mthca_cq *send_cq = to_mcq(qp->send_cq);
- struct mthca_cq *recv_cq = to_mcq(qp->recv_cq);
-
- if (send_cq == recv_cq)
- pthread_spin_lock(&send_cq->lock);
- else if (send_cq->cqn < recv_cq->cqn) {
- pthread_spin_lock(&send_cq->lock);
- pthread_spin_lock(&recv_cq->lock);
- } else {
- pthread_spin_lock(&recv_cq->lock);
- pthread_spin_lock(&send_cq->lock);
- }
-}
-
-static void mthca_unlock_cqs(struct ibv_qp *qp)
-{
- struct mthca_cq *send_cq = to_mcq(qp->send_cq);
- struct mthca_cq *recv_cq = to_mcq(qp->recv_cq);
-
- if (send_cq == recv_cq)
- pthread_spin_unlock(&send_cq->lock);
- else if (send_cq->cqn < recv_cq->cqn) {
- pthread_spin_unlock(&recv_cq->lock);
- pthread_spin_unlock(&send_cq->lock);
- } else {
- pthread_spin_unlock(&send_cq->lock);
- pthread_spin_unlock(&recv_cq->lock);
- }
-}
-
-int mthca_destroy_qp(struct ibv_qp *qp)
-{
- int ret;
-
- pthread_mutex_lock(&to_mctx(qp->context)->qp_table_mutex);
- ret = ibv_cmd_destroy_qp(qp);
- if (ret) {
- pthread_mutex_unlock(&to_mctx(qp->context)->qp_table_mutex);
- return ret;
- }
-
- mthca_lock_cqs(qp);
-
- __mthca_cq_clean(to_mcq(qp->recv_cq), qp->qp_num,
- qp->srq ? to_msrq(qp->srq) : NULL);
- if (qp->send_cq != qp->recv_cq)
- __mthca_cq_clean(to_mcq(qp->send_cq), qp->qp_num, NULL);
-
- mthca_clear_qp(to_mctx(qp->context), qp->qp_num);
-
- mthca_unlock_cqs(qp);
- pthread_mutex_unlock(&to_mctx(qp->context)->qp_table_mutex);
-
- if (mthca_is_memfree(qp->context)) {
- mthca_free_db(to_mctx(qp->context)->db_tab, MTHCA_DB_TYPE_RQ,
- to_mqp(qp)->rq.db_index);
- mthca_free_db(to_mctx(qp->context)->db_tab, MTHCA_DB_TYPE_SQ,
- to_mqp(qp)->sq.db_index);
- }
-
- mthca_dereg_mr(to_mqp(qp)->mr);
- mthca_free_buf(&to_mqp(qp)->buf);
- free(to_mqp(qp)->wrid);
- free(to_mqp(qp));
-
- return 0;
-}
-
-struct ibv_ah *mthca_create_ah(struct ibv_pd *pd, struct ibv_ah_attr *attr)
-{
- struct mthca_ah *ah;
-
- ah = malloc(sizeof *ah);
- if (!ah)
- return NULL;
-
- if (mthca_alloc_av(to_mpd(pd), attr, ah)) {
- free(ah);
- return NULL;
- }
-
- return &ah->ibv_ah;
-}
-
-int mthca_destroy_ah(struct ibv_ah *ah)
-{
- mthca_free_av(to_mah(ah));
- free(to_mah(ah));
-
- return 0;
-}
-
-int mthca_attach_mcast(struct ibv_qp *qp, union ibv_gid *gid, uint16_t lid)
-{
- return ibv_cmd_attach_mcast(qp, gid, lid);
-}
-
-int mthca_detach_mcast(struct ibv_qp *qp, union ibv_gid *gid, uint16_t lid)
-{
- return ibv_cmd_detach_mcast(qp, gid, lid);
-}
diff --git a/contrib/ofed/libmthca/src/wqe.h b/contrib/ofed/libmthca/src/wqe.h
deleted file mode 100644
index 602f512..0000000
--- a/contrib/ofed/libmthca/src/wqe.h
+++ /dev/null
@@ -1,114 +0,0 @@
-/*
- * Copyright (c) 2004, 2005 Topspin Communications. All rights reserved.
- * Copyright (c) 2005 Cisco Systems. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-#ifndef WQE_H
-#define WQE_H
-
-enum {
- MTHCA_SEND_DOORBELL = 0x10,
- MTHCA_RECV_DOORBELL = 0x18
-};
-
-enum {
- MTHCA_NEXT_DBD = 1 << 7,
- MTHCA_NEXT_FENCE = 1 << 6,
- MTHCA_NEXT_CQ_UPDATE = 1 << 3,
- MTHCA_NEXT_EVENT_GEN = 1 << 2,
- MTHCA_NEXT_SOLICIT = 1 << 1,
-};
-
-enum {
- MTHCA_INLINE_SEG = 1 << 31
-};
-
-enum {
- MTHCA_INVAL_LKEY = 0x100,
- MTHCA_TAVOR_MAX_WQES_PER_RECV_DB = 256,
- MTHCA_ARBEL_MAX_WQES_PER_SEND_DB = 255
-};
-
-struct mthca_next_seg {
- uint32_t nda_op; /* [31:6] next WQE [4:0] next opcode */
- uint32_t ee_nds; /* [31:8] next EE [7] DBD [6] F [5:0] next WQE size */
- uint32_t flags; /* [3] CQ [2] Event [1] Solicit */
- uint32_t imm; /* immediate data */
-};
-
-struct mthca_tavor_ud_seg {
- uint32_t reserved1;
- uint32_t lkey;
- uint64_t av_addr;
- uint32_t reserved2[4];
- uint32_t dqpn;
- uint32_t qkey;
- uint32_t reserved3[2];
-};
-
-struct mthca_arbel_ud_seg {
- uint32_t av[8];
- uint32_t dqpn;
- uint32_t qkey;
- uint32_t reserved[2];
-};
-
-struct mthca_bind_seg {
- uint32_t flags; /* [31] Atomic [30] rem write [29] rem read */
- uint32_t reserved;
- uint32_t new_rkey;
- uint32_t lkey;
- uint64_t addr;
- uint64_t length;
-};
-
-struct mthca_raddr_seg {
- uint64_t raddr;
- uint32_t rkey;
- uint32_t reserved;
-};
-
-struct mthca_atomic_seg {
- uint64_t swap_add;
- uint64_t compare;
-};
-
-struct mthca_data_seg {
- uint32_t byte_count;
- uint32_t lkey;
- uint64_t addr;
-};
-
-struct mthca_inline_seg {
- uint32_t byte_count;
-};
-
-#endif /* WQE_H */
diff --git a/contrib/ofed/librdmacm/AUTHORS b/contrib/ofed/librdmacm/AUTHORS
deleted file mode 100644
index f76b870..0000000
--- a/contrib/ofed/librdmacm/AUTHORS
+++ /dev/null
@@ -1 +0,0 @@
-Sean Hefty <sean.hefty@intel.com>
diff --git a/contrib/ofed/librdmacm/COPYING b/contrib/ofed/librdmacm/COPYING
deleted file mode 100644
index 39f3831..0000000
--- a/contrib/ofed/librdmacm/COPYING
+++ /dev/null
@@ -1,378 +0,0 @@
-This software is available to you under a choice of one of two
-licenses. You may choose to be licensed under the terms of the the
-OpenIB.org BSD license or the GNU General Public License (GPL) Version
-2, both included below.
-
-Copyright (c) 2005 Intel Corporation. All rights reserved.
-
-==================================================================
-
- OpenIB.org BSD license
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions
-are met:
-
- * Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
-
- * Redistributions in binary form must reproduce the above
- copyright notice, this list of conditions and the following
- disclaimer in the documentation and/or other materials provided
- with the distribution.
-
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
-FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
-COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
-INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
-BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
-LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
-CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
-ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-POSSIBILITY OF SUCH DAMAGE.
-
-==================================================================
-
- GNU GENERAL PUBLIC LICENSE
- Version 2, June 1991
-
- Copyright (C) 1989, 1991 Free Software Foundation, Inc.
- 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- Everyone is permitted to copy and distribute verbatim copies
- of this license document, but changing it is not allowed.
-
- Preamble
-
- The licenses for most software are designed to take away your
-freedom to share and change it. By contrast, the GNU General Public
-License is intended to guarantee your freedom to share and change free
-software--to make sure the software is free for all its users. This
-General Public License applies to most of the Free Software
-Foundation's software and to any other program whose authors commit to
-using it. (Some other Free Software Foundation software is covered by
-the GNU Library General Public License instead.) You can apply it to
-your programs, too.
-
- When we speak of free software, we are referring to freedom, not
-price. Our General Public Licenses are designed to make sure that you
-have the freedom to distribute copies of free software (and charge for
-this service if you wish), that you receive source code or can get it
-if you want it, that you can change the software or use pieces of it
-in new free programs; and that you know you can do these things.
-
- To protect your rights, we need to make restrictions that forbid
-anyone to deny you these rights or to ask you to surrender the rights.
-These restrictions translate to certain responsibilities for you if you
-distribute copies of the software, or if you modify it.
-
- For example, if you distribute copies of such a program, whether
-gratis or for a fee, you must give the recipients all the rights that
-you have. You must make sure that they, too, receive or can get the
-source code. And you must show them these terms so they know their
-rights.
-
- We protect your rights with two steps: (1) copyright the software, and
-(2) offer you this license which gives you legal permission to copy,
-distribute and/or modify the software.
-
- Also, for each author's protection and ours, we want to make certain
-that everyone understands that there is no warranty for this free
-software. If the software is modified by someone else and passed on, we
-want its recipients to know that what they have is not the original, so
-that any problems introduced by others will not reflect on the original
-authors' reputations.
-
- Finally, any free program is threatened constantly by software
-patents. We wish to avoid the danger that redistributors of a free
-program will individually obtain patent licenses, in effect making the
-program proprietary. To prevent this, we have made it clear that any
-patent must be licensed for everyone's free use or not licensed at all.
-
- The precise terms and conditions for copying, distribution and
-modification follow.
-
- GNU GENERAL PUBLIC LICENSE
- TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
-
- 0. This License applies to any program or other work which contains
-a notice placed by the copyright holder saying it may be distributed
-under the terms of this General Public License. The "Program", below,
-refers to any such program or work, and a "work based on the Program"
-means either the Program or any derivative work under copyright law:
-that is to say, a work containing the Program or a portion of it,
-either verbatim or with modifications and/or translated into another
-language. (Hereinafter, translation is included without limitation in
-the term "modification".) Each licensee is addressed as "you".
-
-Activities other than copying, distribution and modification are not
-covered by this License; they are outside its scope. The act of
-running the Program is not restricted, and the output from the Program
-is covered only if its contents constitute a work based on the
-Program (independent of having been made by running the Program).
-Whether that is true depends on what the Program does.
-
- 1. You may copy and distribute verbatim copies of the Program's
-source code as you receive it, in any medium, provided that you
-conspicuously and appropriately publish on each copy an appropriate
-copyright notice and disclaimer of warranty; keep intact all the
-notices that refer to this License and to the absence of any warranty;
-and give any other recipients of the Program a copy of this License
-along with the Program.
-
-You may charge a fee for the physical act of transferring a copy, and
-you may at your option offer warranty protection in exchange for a fee.
-
- 2. You may modify your copy or copies of the Program or any portion
-of it, thus forming a work based on the Program, and copy and
-distribute such modifications or work under the terms of Section 1
-above, provided that you also meet all of these conditions:
-
- a) You must cause the modified files to carry prominent notices
- stating that you changed the files and the date of any change.
-
- b) You must cause any work that you distribute or publish, that in
- whole or in part contains or is derived from the Program or any
- part thereof, to be licensed as a whole at no charge to all third
- parties under the terms of this License.
-
- c) If the modified program normally reads commands interactively
- when run, you must cause it, when started running for such
- interactive use in the most ordinary way, to print or display an
- announcement including an appropriate copyright notice and a
- notice that there is no warranty (or else, saying that you provide
- a warranty) and that users may redistribute the program under
- these conditions, and telling the user how to view a copy of this
- License. (Exception: if the Program itself is interactive but
- does not normally print such an announcement, your work based on
- the Program is not required to print an announcement.)
-
-These requirements apply to the modified work as a whole. If
-identifiable sections of that work are not derived from the Program,
-and can be reasonably considered independent and separate works in
-themselves, then this License, and its terms, do not apply to those
-sections when you distribute them as separate works. But when you
-distribute the same sections as part of a whole which is a work based
-on the Program, the distribution of the whole must be on the terms of
-this License, whose permissions for other licensees extend to the
-entire whole, and thus to each and every part regardless of who wrote it.
-
-Thus, it is not the intent of this section to claim rights or contest
-your rights to work written entirely by you; rather, the intent is to
-exercise the right to control the distribution of derivative or
-collective works based on the Program.
-
-In addition, mere aggregation of another work not based on the Program
-with the Program (or with a work based on the Program) on a volume of
-a storage or distribution medium does not bring the other work under
-the scope of this License.
-
- 3. You may copy and distribute the Program (or a work based on it,
-under Section 2) in object code or executable form under the terms of
-Sections 1 and 2 above provided that you also do one of the following:
-
- a) Accompany it with the complete corresponding machine-readable
- source code, which must be distributed under the terms of Sections
- 1 and 2 above on a medium customarily used for software interchange; or,
-
- b) Accompany it with a written offer, valid for at least three
- years, to give any third party, for a charge no more than your
- cost of physically performing source distribution, a complete
- machine-readable copy of the corresponding source code, to be
- distributed under the terms of Sections 1 and 2 above on a medium
- customarily used for software interchange; or,
-
- c) Accompany it with the information you received as to the offer
- to distribute corresponding source code. (This alternative is
- allowed only for noncommercial distribution and only if you
- received the program in object code or executable form with such
- an offer, in accord with Subsection b above.)
-
-The source code for a work means the preferred form of the work for
-making modifications to it. For an executable work, complete source
-code means all the source code for all modules it contains, plus any
-associated interface definition files, plus the scripts used to
-control compilation and installation of the executable. However, as a
-special exception, the source code distributed need not include
-anything that is normally distributed (in either source or binary
-form) with the major components (compiler, kernel, and so on) of the
-operating system on which the executable runs, unless that component
-itself accompanies the executable.
-
-If distribution of executable or object code is made by offering
-access to copy from a designated place, then offering equivalent
-access to copy the source code from the same place counts as
-distribution of the source code, even though third parties are not
-compelled to copy the source along with the object code.
-
- 4. You may not copy, modify, sublicense, or distribute the Program
-except as expressly provided under this License. Any attempt
-otherwise to copy, modify, sublicense or distribute the Program is
-void, and will automatically terminate your rights under this License.
-However, parties who have received copies, or rights, from you under
-this License will not have their licenses terminated so long as such
-parties remain in full compliance.
-
- 5. You are not required to accept this License, since you have not
-signed it. However, nothing else grants you permission to modify or
-distribute the Program or its derivative works. These actions are
-prohibited by law if you do not accept this License. Therefore, by
-modifying or distributing the Program (or any work based on the
-Program), you indicate your acceptance of this License to do so, and
-all its terms and conditions for copying, distributing or modifying
-the Program or works based on it.
-
- 6. Each time you redistribute the Program (or any work based on the
-Program), the recipient automatically receives a license from the
-original licensor to copy, distribute or modify the Program subject to
-these terms and conditions. You may not impose any further
-restrictions on the recipients' exercise of the rights granted herein.
-You are not responsible for enforcing compliance by third parties to
-this License.
-
- 7. If, as a consequence of a court judgment or allegation of patent
-infringement or for any other reason (not limited to patent issues),
-conditions are imposed on you (whether by court order, agreement or
-otherwise) that contradict the conditions of this License, they do not
-excuse you from the conditions of this License. If you cannot
-distribute so as to satisfy simultaneously your obligations under this
-License and any other pertinent obligations, then as a consequence you
-may not distribute the Program at all. For example, if a patent
-license would not permit royalty-free redistribution of the Program by
-all those who receive copies directly or indirectly through you, then
-the only way you could satisfy both it and this License would be to
-refrain entirely from distribution of the Program.
-
-If any portion of this section is held invalid or unenforceable under
-any particular circumstance, the balance of the section is intended to
-apply and the section as a whole is intended to apply in other
-circumstances.
-
-It is not the purpose of this section to induce you to infringe any
-patents or other property right claims or to contest validity of any
-such claims; this section has the sole purpose of protecting the
-integrity of the free software distribution system, which is
-implemented by public license practices. Many people have made
-generous contributions to the wide range of software distributed
-through that system in reliance on consistent application of that
-system; it is up to the author/donor to decide if he or she is willing
-to distribute software through any other system and a licensee cannot
-impose that choice.
-
-This section is intended to make thoroughly clear what is believed to
-be a consequence of the rest of this License.
-
- 8. If the distribution and/or use of the Program is restricted in
-certain countries either by patents or by copyrighted interfaces, the
-original copyright holder who places the Program under this License
-may add an explicit geographical distribution limitation excluding
-those countries, so that distribution is permitted only in or among
-countries not thus excluded. In such case, this License incorporates
-the limitation as if written in the body of this License.
-
- 9. The Free Software Foundation may publish revised and/or new versions
-of the General Public License from time to time. Such new versions will
-be similar in spirit to the present version, but may differ in detail to
-address new problems or concerns.
-
-Each version is given a distinguishing version number. If the Program
-specifies a version number of this License which applies to it and "any
-later version", you have the option of following the terms and conditions
-either of that version or of any later version published by the Free
-Software Foundation. If the Program does not specify a version number of
-this License, you may choose any version ever published by the Free Software
-Foundation.
-
- 10. If you wish to incorporate parts of the Program into other free
-programs whose distribution conditions are different, write to the author
-to ask for permission. For software which is copyrighted by the Free
-Software Foundation, write to the Free Software Foundation; we sometimes
-make exceptions for this. Our decision will be guided by the two goals
-of preserving the free status of all derivatives of our free software and
-of promoting the sharing and reuse of software generally.
-
- NO WARRANTY
-
- 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
-FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
-OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
-PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
-OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
-MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
-TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
-PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
-REPAIR OR CORRECTION.
-
- 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
-WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
-REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
-INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
-OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
-TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
-YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
-PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
-POSSIBILITY OF SUCH DAMAGES.
-
- END OF TERMS AND CONDITIONS
-
- How to Apply These Terms to Your New Programs
-
- If you develop a new program, and you want it to be of the greatest
-possible use to the public, the best way to achieve this is to make it
-free software which everyone can redistribute and change under these terms.
-
- To do so, attach the following notices to the program. It is safest
-to attach them to the start of each source file to most effectively
-convey the exclusion of warranty; and each file should have at least
-the "copyright" line and a pointer to where the full notice is found.
-
- <one line to give the program's name and a brief idea of what it does.>
- Copyright (C) <year> <name of author>
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program 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 this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-
-Also add information on how to contact you by electronic and paper mail.
-
-If the program is interactive, make it output a short notice like this
-when it starts in an interactive mode:
-
- Gnomovision version 69, Copyright (C) year name of author
- Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
- This is free software, and you are welcome to redistribute it
- under certain conditions; type `show c' for details.
-
-The hypothetical commands `show w' and `show c' should show the appropriate
-parts of the General Public License. Of course, the commands you use may
-be called something other than `show w' and `show c'; they could even be
-mouse-clicks or menu items--whatever suits your program.
-
-You should also get your employer (if you work as a programmer) or your
-school, if any, to sign a "copyright disclaimer" for the program, if
-necessary. Here is a sample; alter the names:
-
- Yoyodyne, Inc., hereby disclaims all copyright interest in the program
- `Gnomovision' (which makes passes at compilers) written by James Hacker.
-
- <signature of Ty Coon>, 1 April 1989
- Ty Coon, President of Vice
-
-This General Public License does not permit incorporating your program into
-proprietary programs. If your program is a subroutine library, you may
-consider it more useful to permit linking proprietary applications with the
-library. If this is what you want to do, use the GNU Library General
-Public License instead of this License.
diff --git a/contrib/ofed/librdmacm/ChangeLog b/contrib/ofed/librdmacm/ChangeLog
deleted file mode 100644
index e69de29..0000000
--- a/contrib/ofed/librdmacm/ChangeLog
+++ /dev/null
diff --git a/contrib/ofed/librdmacm/INSTALL b/contrib/ofed/librdmacm/INSTALL
deleted file mode 100644
index e69de29..0000000
--- a/contrib/ofed/librdmacm/INSTALL
+++ /dev/null
diff --git a/contrib/ofed/librdmacm/Makefile b/contrib/ofed/librdmacm/Makefile
new file mode 100644
index 0000000..593315dd
--- /dev/null
+++ b/contrib/ofed/librdmacm/Makefile
@@ -0,0 +1,71 @@
+# $FreeBSD$
+
+.PATH: ${.CURDIR} ${.CURDIR}/man
+
+SHLIBDIR?= /usr/lib
+LIB= rdmacm
+SHLIB_MAJOR= 1
+MK_PROFILE= no
+CFLAGS+= -I${.CURDIR}
+
+SRCS= \
+acm.c \
+addrinfo.c \
+cma.c \
+indexer.c
+
+MAN= \
+rdma_accept.3 \
+rdma_ack_cm_event.3 \
+rdma_bind_addr.3 \
+rdma_connect.3 \
+rdma_create_ep.3 \
+rdma_create_event_channel.3 \
+rdma_create_id.3 \
+rdma_create_qp.3 \
+rdma_create_srq.3 \
+rdma_dereg_mr.3 \
+rdma_destroy_ep.3 \
+rdma_destroy_event_channel.3 \
+rdma_destroy_id.3 \
+rdma_destroy_qp.3 \
+rdma_destroy_srq.3 \
+rdma_disconnect.3 \
+rdma_event_str.3 \
+rdma_free_devices.3 \
+rdma_get_cm_event.3 \
+rdma_get_devices.3 \
+rdma_get_dst_port.3 \
+rdma_get_local_addr.3 \
+rdma_get_peer_addr.3 \
+rdma_get_recv_comp.3 \
+rdma_get_request.3 \
+rdma_get_send_comp.3 \
+rdma_get_src_port.3 \
+rdma_getaddrinfo.3 \
+rdma_join_multicast.3 \
+rdma_leave_multicast.3 \
+rdma_listen.3 \
+rdma_migrate_id.3 \
+rdma_notify.3 \
+rdma_post_read.3 \
+rdma_post_readv.3 \
+rdma_post_recv.3 \
+rdma_post_recvv.3 \
+rdma_post_send.3 \
+rdma_post_sendv.3 \
+rdma_post_ud_send.3 \
+rdma_post_write.3 \
+rdma_post_writev.3 \
+rdma_reg_msgs.3 \
+rdma_reg_read.3 \
+rdma_reg_write.3 \
+rdma_reject.3 \
+rdma_resolve_addr.3 \
+rdma_resolve_route.3 \
+rdma_set_option.3
+
+LIBADD= ibverbs
+VERSION_MAP= ${.CURDIR}/librdmacm.map
+
+.include <bsd.lib.mk>
diff --git a/contrib/ofed/librdmacm/Makefile.am b/contrib/ofed/librdmacm/Makefile.am
deleted file mode 100644
index 290cbc3..0000000
--- a/contrib/ofed/librdmacm/Makefile.am
+++ /dev/null
@@ -1,74 +0,0 @@
-INCLUDES = -I$(srcdir)/include
-
-lib_LTLIBRARIES = src/librdmacm.la
-
-AM_CFLAGS = -g -Wall -D_GNU_SOURCE
-
-src_librdmacm_la_CFLAGS = $(AM_CFLAGS)
-
-if HAVE_LD_VERSION_SCRIPT
- librdmacm_version_script = -Wl,--version-script=$(srcdir)/src/librdmacm.map
-else
- librdmacm_version_script =
-endif
-
-src_librdmacm_la_SOURCES = src/cma.c
-src_librdmacm_la_LDFLAGS = -version-info 1 -export-dynamic \
- $(librdmacm_version_script)
-src_librdmacm_la_DEPENDENCIES = $(srcdir)/src/librdmacm.map
-
-bin_PROGRAMS = examples/ucmatose examples/rping examples/udaddy examples/mckey
-examples_ucmatose_SOURCES = examples/cmatose.c
-examples_ucmatose_LDADD = $(top_builddir)/src/librdmacm.la
-examples_rping_SOURCES = examples/rping.c
-examples_rping_LDADD = $(top_builddir)/src/librdmacm.la
-examples_udaddy_SOURCES = examples/udaddy.c
-examples_udaddy_LDADD = $(top_builddir)/src/librdmacm.la
-examples_mckey_SOURCES = examples/mckey.c
-examples_mckey_LDADD = $(top_builddir)/src/librdmacm.la
-
-librdmacmincludedir = $(includedir)/rdma
-
-librdmacminclude_HEADERS = include/rdma/rdma_cma_abi.h \
- include/rdma/rdma_cma.h
-
-man_MANS = \
- man/rdma_accept.3 \
- man/rdma_ack_cm_event.3 \
- man/rdma_bind_addr.3 \
- man/rdma_connect.3 \
- man/rdma_create_event_channel.3 \
- man/rdma_create_id.3 \
- man/rdma_create_qp.3 \
- man/rdma_destroy_event_channel.3 \
- man/rdma_destroy_id.3 \
- man/rdma_destroy_qp.3 \
- man/rdma_disconnect.3 \
- man/rdma_free_devices.3 \
- man/rdma_get_cm_event.3 \
- man/rdma_get_devices.3 \
- man/rdma_get_src_port.3 \
- man/rdma_get_dst_port.3 \
- man/rdma_get_local_addr.3 \
- man/rdma_get_peer_addr.3 \
- man/rdma_join_multicast.3 \
- man/rdma_leave_multicast.3 \
- man/rdma_listen.3 \
- man/rdma_migrate_id.3 \
- man/rdma_notify.3 \
- man/rdma_reject.3 \
- man/rdma_resolve_addr.3 \
- man/rdma_resolve_route.3 \
- man/rdma_event_str.3 \
- man/rdma_set_option.3 \
- man/ucmatose.1 \
- man/udaddy.1 \
- man/mckey.1 \
- man/rping.1 \
- man/rdma_cm.7
-
-EXTRA_DIST = include/rdma/rdma_cma_abi.h include/rdma/rdma_cma.h \
- src/librdmacm.map librdmacm.spec.in $(man_MANS)
-
-dist-hook: librdmacm.spec
- cp librdmacm.spec $(distdir)
diff --git a/contrib/ofed/librdmacm/Makefile.in b/contrib/ofed/librdmacm/Makefile.in
deleted file mode 100644
index 21cb41d..0000000
--- a/contrib/ofed/librdmacm/Makefile.in
+++ /dev/null
@@ -1,974 +0,0 @@
-# Makefile.in generated by automake 1.9.6 from Makefile.am.
-# @configure_input@
-
-# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
-# 2003, 2004, 2005 Free Software Foundation, Inc.
-# This Makefile.in is free software; the Free Software Foundation
-# gives unlimited permission to copy and/or distribute it,
-# with or without modifications, as long as this notice is preserved.
-
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
-# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
-# PARTICULAR PURPOSE.
-
-@SET_MAKE@
-
-
-
-srcdir = @srcdir@
-top_srcdir = @top_srcdir@
-VPATH = @srcdir@
-pkgdatadir = $(datadir)/@PACKAGE@
-pkglibdir = $(libdir)/@PACKAGE@
-pkgincludedir = $(includedir)/@PACKAGE@
-top_builddir = .
-am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
-INSTALL = @INSTALL@
-install_sh_DATA = $(install_sh) -c -m 644
-install_sh_PROGRAM = $(install_sh) -c
-install_sh_SCRIPT = $(install_sh) -c
-INSTALL_HEADER = $(INSTALL_DATA)
-transform = $(program_transform_name)
-NORMAL_INSTALL = :
-PRE_INSTALL = :
-POST_INSTALL = :
-NORMAL_UNINSTALL = :
-PRE_UNINSTALL = :
-POST_UNINSTALL = :
-build_triplet = @build@
-host_triplet = @host@
-bin_PROGRAMS = examples/ucmatose$(EXEEXT) examples/rping$(EXEEXT) \
- examples/udaddy$(EXEEXT) examples/mckey$(EXEEXT)
-DIST_COMMON = README $(am__configure_deps) $(librdmacminclude_HEADERS) \
- $(srcdir)/Makefile.am $(srcdir)/Makefile.in \
- $(srcdir)/config.h.in $(srcdir)/librdmacm.spec.in \
- $(top_srcdir)/configure AUTHORS COPYING ChangeLog INSTALL NEWS \
- config/compile config/config.guess config/config.sub \
- config/depcomp config/install-sh config/ltmain.sh \
- config/missing
-subdir = .
-ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
-am__aclocal_m4_deps = $(top_srcdir)/configure.in
-am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
- $(ACLOCAL_M4)
-am__CONFIG_DISTCLEAN_FILES = config.status config.cache config.log \
- configure.lineno configure.status.lineno
-mkinstalldirs = $(install_sh) -d
-CONFIG_HEADER = config.h
-CONFIG_CLEAN_FILES = librdmacm.spec
-am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
-am__vpath_adj = case $$p in \
- $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \
- *) f=$$p;; \
- esac;
-am__strip_dir = `echo $$p | sed -e 's|^.*/||'`;
-am__installdirs = "$(DESTDIR)$(libdir)" "$(DESTDIR)$(bindir)" \
- "$(DESTDIR)$(man1dir)" "$(DESTDIR)$(man3dir)" \
- "$(DESTDIR)$(man7dir)" "$(DESTDIR)$(librdmacmincludedir)"
-libLTLIBRARIES_INSTALL = $(INSTALL)
-LTLIBRARIES = $(lib_LTLIBRARIES)
-src_librdmacm_la_LIBADD =
-am_src_librdmacm_la_OBJECTS = src_librdmacm_la-cma.lo
-src_librdmacm_la_OBJECTS = $(am_src_librdmacm_la_OBJECTS)
-am__dirstamp = $(am__leading_dot)dirstamp
-binPROGRAMS_INSTALL = $(INSTALL_PROGRAM)
-PROGRAMS = $(bin_PROGRAMS)
-am_examples_mckey_OBJECTS = mckey.$(OBJEXT)
-examples_mckey_OBJECTS = $(am_examples_mckey_OBJECTS)
-examples_mckey_DEPENDENCIES = $(top_builddir)/src/librdmacm.la
-am_examples_rping_OBJECTS = rping.$(OBJEXT)
-examples_rping_OBJECTS = $(am_examples_rping_OBJECTS)
-examples_rping_DEPENDENCIES = $(top_builddir)/src/librdmacm.la
-am_examples_ucmatose_OBJECTS = cmatose.$(OBJEXT)
-examples_ucmatose_OBJECTS = $(am_examples_ucmatose_OBJECTS)
-examples_ucmatose_DEPENDENCIES = $(top_builddir)/src/librdmacm.la
-am_examples_udaddy_OBJECTS = udaddy.$(OBJEXT)
-examples_udaddy_OBJECTS = $(am_examples_udaddy_OBJECTS)
-examples_udaddy_DEPENDENCIES = $(top_builddir)/src/librdmacm.la
-DEFAULT_INCLUDES = -I. -I$(srcdir) -I.
-depcomp = $(SHELL) $(top_srcdir)/config/depcomp
-am__depfiles_maybe = depfiles
-COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
- $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
-LTCOMPILE = $(LIBTOOL) --tag=CC --mode=compile $(CC) $(DEFS) \
- $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
- $(AM_CFLAGS) $(CFLAGS)
-CCLD = $(CC)
-LINK = $(LIBTOOL) --tag=CC --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
- $(AM_LDFLAGS) $(LDFLAGS) -o $@
-SOURCES = $(src_librdmacm_la_SOURCES) $(examples_mckey_SOURCES) \
- $(examples_rping_SOURCES) $(examples_ucmatose_SOURCES) \
- $(examples_udaddy_SOURCES)
-DIST_SOURCES = $(src_librdmacm_la_SOURCES) $(examples_mckey_SOURCES) \
- $(examples_rping_SOURCES) $(examples_ucmatose_SOURCES) \
- $(examples_udaddy_SOURCES)
-man1dir = $(mandir)/man1
-man3dir = $(mandir)/man3
-man7dir = $(mandir)/man7
-NROFF = nroff
-MANS = $(man_MANS)
-librdmacmincludeHEADERS_INSTALL = $(INSTALL_HEADER)
-HEADERS = $(librdmacminclude_HEADERS)
-ETAGS = etags
-CTAGS = ctags
-DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
-distdir = $(PACKAGE)-$(VERSION)
-top_distdir = $(distdir)
-am__remove_distdir = \
- { test ! -d $(distdir) \
- || { find $(distdir) -type d ! -perm -200 -exec chmod u+w {} ';' \
- && rm -fr $(distdir); }; }
-DIST_ARCHIVES = $(distdir).tar.gz
-GZIP_ENV = --best
-distuninstallcheck_listfiles = find . -type f -print
-distcleancheck_listfiles = find . -type f -print
-ACLOCAL = @ACLOCAL@
-AMDEP_FALSE = @AMDEP_FALSE@
-AMDEP_TRUE = @AMDEP_TRUE@
-AMTAR = @AMTAR@
-AR = @AR@
-AUTOCONF = @AUTOCONF@
-AUTOHEADER = @AUTOHEADER@
-AUTOMAKE = @AUTOMAKE@
-AWK = @AWK@
-CC = @CC@
-CCDEPMODE = @CCDEPMODE@
-CFLAGS = @CFLAGS@
-CPP = @CPP@
-CPPFLAGS = @CPPFLAGS@
-CXX = @CXX@
-CXXCPP = @CXXCPP@
-CXXDEPMODE = @CXXDEPMODE@
-CXXFLAGS = @CXXFLAGS@
-CYGPATH_W = @CYGPATH_W@
-DEFS = @DEFS@
-DEPDIR = @DEPDIR@
-ECHO = @ECHO@
-ECHO_C = @ECHO_C@
-ECHO_N = @ECHO_N@
-ECHO_T = @ECHO_T@
-EGREP = @EGREP@
-EXEEXT = @EXEEXT@
-F77 = @F77@
-FFLAGS = @FFLAGS@
-HAVE_LD_VERSION_SCRIPT_FALSE = @HAVE_LD_VERSION_SCRIPT_FALSE@
-HAVE_LD_VERSION_SCRIPT_TRUE = @HAVE_LD_VERSION_SCRIPT_TRUE@
-INSTALL_DATA = @INSTALL_DATA@
-INSTALL_PROGRAM = @INSTALL_PROGRAM@
-INSTALL_SCRIPT = @INSTALL_SCRIPT@
-INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
-LDFLAGS = @LDFLAGS@
-LIBOBJS = @LIBOBJS@
-LIBS = @LIBS@
-LIBTOOL = @LIBTOOL@
-LN_S = @LN_S@
-LTLIBOBJS = @LTLIBOBJS@
-MAKEINFO = @MAKEINFO@
-OBJEXT = @OBJEXT@
-PACKAGE = @PACKAGE@
-PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
-PACKAGE_NAME = @PACKAGE_NAME@
-PACKAGE_STRING = @PACKAGE_STRING@
-PACKAGE_TARNAME = @PACKAGE_TARNAME@
-PACKAGE_VERSION = @PACKAGE_VERSION@
-PATH_SEPARATOR = @PATH_SEPARATOR@
-RANLIB = @RANLIB@
-SET_MAKE = @SET_MAKE@
-SHELL = @SHELL@
-STRIP = @STRIP@
-VERSION = @VERSION@
-ac_ct_AR = @ac_ct_AR@
-ac_ct_CC = @ac_ct_CC@
-ac_ct_CXX = @ac_ct_CXX@
-ac_ct_F77 = @ac_ct_F77@
-ac_ct_RANLIB = @ac_ct_RANLIB@
-ac_ct_STRIP = @ac_ct_STRIP@
-am__fastdepCC_FALSE = @am__fastdepCC_FALSE@
-am__fastdepCC_TRUE = @am__fastdepCC_TRUE@
-am__fastdepCXX_FALSE = @am__fastdepCXX_FALSE@
-am__fastdepCXX_TRUE = @am__fastdepCXX_TRUE@
-am__include = @am__include@
-am__leading_dot = @am__leading_dot@
-am__quote = @am__quote@
-am__tar = @am__tar@
-am__untar = @am__untar@
-bindir = @bindir@
-build = @build@
-build_alias = @build_alias@
-build_cpu = @build_cpu@
-build_os = @build_os@
-build_vendor = @build_vendor@
-datadir = @datadir@
-exec_prefix = @exec_prefix@
-host = @host@
-host_alias = @host_alias@
-host_cpu = @host_cpu@
-host_os = @host_os@
-host_vendor = @host_vendor@
-includedir = @includedir@
-infodir = @infodir@
-install_sh = @install_sh@
-libdir = @libdir@
-libexecdir = @libexecdir@
-localstatedir = @localstatedir@
-mandir = @mandir@
-mkdir_p = @mkdir_p@
-oldincludedir = @oldincludedir@
-prefix = @prefix@
-program_transform_name = @program_transform_name@
-sbindir = @sbindir@
-sharedstatedir = @sharedstatedir@
-sysconfdir = @sysconfdir@
-target_alias = @target_alias@
-INCLUDES = -I$(srcdir)/include
-lib_LTLIBRARIES = src/librdmacm.la
-AM_CFLAGS = -g -Wall -D_GNU_SOURCE
-src_librdmacm_la_CFLAGS = $(AM_CFLAGS)
-@HAVE_LD_VERSION_SCRIPT_FALSE@librdmacm_version_script =
-@HAVE_LD_VERSION_SCRIPT_TRUE@librdmacm_version_script = -Wl,--version-script=$(srcdir)/src/librdmacm.map
-src_librdmacm_la_SOURCES = src/cma.c
-src_librdmacm_la_LDFLAGS = -version-info 1 -export-dynamic \
- $(librdmacm_version_script)
-
-src_librdmacm_la_DEPENDENCIES = $(srcdir)/src/librdmacm.map
-examples_ucmatose_SOURCES = examples/cmatose.c
-examples_ucmatose_LDADD = $(top_builddir)/src/librdmacm.la
-examples_rping_SOURCES = examples/rping.c
-examples_rping_LDADD = $(top_builddir)/src/librdmacm.la
-examples_udaddy_SOURCES = examples/udaddy.c
-examples_udaddy_LDADD = $(top_builddir)/src/librdmacm.la
-examples_mckey_SOURCES = examples/mckey.c
-examples_mckey_LDADD = $(top_builddir)/src/librdmacm.la
-librdmacmincludedir = $(includedir)/rdma
-librdmacminclude_HEADERS = include/rdma/rdma_cma_abi.h \
- include/rdma/rdma_cma.h
-
-man_MANS = \
- man/rdma_accept.3 \
- man/rdma_ack_cm_event.3 \
- man/rdma_bind_addr.3 \
- man/rdma_connect.3 \
- man/rdma_create_event_channel.3 \
- man/rdma_create_id.3 \
- man/rdma_create_qp.3 \
- man/rdma_destroy_event_channel.3 \
- man/rdma_destroy_id.3 \
- man/rdma_destroy_qp.3 \
- man/rdma_disconnect.3 \
- man/rdma_free_devices.3 \
- man/rdma_get_cm_event.3 \
- man/rdma_get_devices.3 \
- man/rdma_get_src_port.3 \
- man/rdma_get_dst_port.3 \
- man/rdma_get_local_addr.3 \
- man/rdma_get_peer_addr.3 \
- man/rdma_join_multicast.3 \
- man/rdma_leave_multicast.3 \
- man/rdma_listen.3 \
- man/rdma_migrate_id.3 \
- man/rdma_notify.3 \
- man/rdma_reject.3 \
- man/rdma_resolve_addr.3 \
- man/rdma_resolve_route.3 \
- man/rdma_event_str.3 \
- man/rdma_set_option.3 \
- man/ucmatose.1 \
- man/udaddy.1 \
- man/mckey.1 \
- man/rping.1 \
- man/rdma_cm.7
-
-EXTRA_DIST = include/rdma/rdma_cma_abi.h include/rdma/rdma_cma.h \
- src/librdmacm.map librdmacm.spec.in $(man_MANS)
-
-all: config.h
- $(MAKE) $(AM_MAKEFLAGS) all-am
-
-.SUFFIXES:
-.SUFFIXES: .c .lo .o .obj
-am--refresh:
- @:
-$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps)
- @for dep in $?; do \
- case '$(am__configure_deps)' in \
- *$$dep*) \
- echo ' cd $(srcdir) && $(AUTOMAKE) --foreign '; \
- cd $(srcdir) && $(AUTOMAKE) --foreign \
- && exit 0; \
- exit 1;; \
- esac; \
- done; \
- echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign Makefile'; \
- cd $(top_srcdir) && \
- $(AUTOMAKE) --foreign Makefile
-.PRECIOUS: Makefile
-Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
- @case '$?' in \
- *config.status*) \
- echo ' $(SHELL) ./config.status'; \
- $(SHELL) ./config.status;; \
- *) \
- echo ' cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe)'; \
- cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe);; \
- esac;
-
-$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
- $(SHELL) ./config.status --recheck
-
-$(top_srcdir)/configure: $(am__configure_deps)
- cd $(srcdir) && $(AUTOCONF)
-$(ACLOCAL_M4): $(am__aclocal_m4_deps)
- cd $(srcdir) && $(ACLOCAL) $(ACLOCAL_AMFLAGS)
-
-config.h: stamp-h1
- @if test ! -f $@; then \
- rm -f stamp-h1; \
- $(MAKE) stamp-h1; \
- else :; fi
-
-stamp-h1: $(srcdir)/config.h.in $(top_builddir)/config.status
- @rm -f stamp-h1
- cd $(top_builddir) && $(SHELL) ./config.status config.h
-$(srcdir)/config.h.in: $(am__configure_deps)
- cd $(top_srcdir) && $(AUTOHEADER)
- rm -f stamp-h1
- touch $@
-
-distclean-hdr:
- -rm -f config.h stamp-h1
-librdmacm.spec: $(top_builddir)/config.status $(srcdir)/librdmacm.spec.in
- cd $(top_builddir) && $(SHELL) ./config.status $@
-install-libLTLIBRARIES: $(lib_LTLIBRARIES)
- @$(NORMAL_INSTALL)
- test -z "$(libdir)" || $(mkdir_p) "$(DESTDIR)$(libdir)"
- @list='$(lib_LTLIBRARIES)'; for p in $$list; do \
- if test -f $$p; then \
- f=$(am__strip_dir) \
- echo " $(LIBTOOL) --mode=install $(libLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) '$$p' '$(DESTDIR)$(libdir)/$$f'"; \
- $(LIBTOOL) --mode=install $(libLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) "$$p" "$(DESTDIR)$(libdir)/$$f"; \
- else :; fi; \
- done
-
-uninstall-libLTLIBRARIES:
- @$(NORMAL_UNINSTALL)
- @set -x; list='$(lib_LTLIBRARIES)'; for p in $$list; do \
- p=$(am__strip_dir) \
- echo " $(LIBTOOL) --mode=uninstall rm -f '$(DESTDIR)$(libdir)/$$p'"; \
- $(LIBTOOL) --mode=uninstall rm -f "$(DESTDIR)$(libdir)/$$p"; \
- done
-
-clean-libLTLIBRARIES:
- -test -z "$(lib_LTLIBRARIES)" || rm -f $(lib_LTLIBRARIES)
- @list='$(lib_LTLIBRARIES)'; for p in $$list; do \
- dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \
- test "$$dir" != "$$p" || dir=.; \
- echo "rm -f \"$${dir}/so_locations\""; \
- rm -f "$${dir}/so_locations"; \
- done
-src/$(am__dirstamp):
- @$(mkdir_p) src
- @: > src/$(am__dirstamp)
-src/librdmacm.la: $(src_librdmacm_la_OBJECTS) $(src_librdmacm_la_DEPENDENCIES) src/$(am__dirstamp)
- $(LINK) -rpath $(libdir) $(src_librdmacm_la_LDFLAGS) $(src_librdmacm_la_OBJECTS) $(src_librdmacm_la_LIBADD) $(LIBS)
-install-binPROGRAMS: $(bin_PROGRAMS)
- @$(NORMAL_INSTALL)
- test -z "$(bindir)" || $(mkdir_p) "$(DESTDIR)$(bindir)"
- @list='$(bin_PROGRAMS)'; for p in $$list; do \
- p1=`echo $$p|sed 's/$(EXEEXT)$$//'`; \
- if test -f $$p \
- || test -f $$p1 \
- ; then \
- f=`echo "$$p1" | sed 's,^.*/,,;$(transform);s/$$/$(EXEEXT)/'`; \
- echo " $(INSTALL_PROGRAM_ENV) $(LIBTOOL) --mode=install $(binPROGRAMS_INSTALL) '$$p' '$(DESTDIR)$(bindir)/$$f'"; \
- $(INSTALL_PROGRAM_ENV) $(LIBTOOL) --mode=install $(binPROGRAMS_INSTALL) "$$p" "$(DESTDIR)$(bindir)/$$f" || exit 1; \
- else :; fi; \
- done
-
-uninstall-binPROGRAMS:
- @$(NORMAL_UNINSTALL)
- @list='$(bin_PROGRAMS)'; for p in $$list; do \
- f=`echo "$$p" | sed 's,^.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/'`; \
- echo " rm -f '$(DESTDIR)$(bindir)/$$f'"; \
- rm -f "$(DESTDIR)$(bindir)/$$f"; \
- done
-
-clean-binPROGRAMS:
- @list='$(bin_PROGRAMS)'; for p in $$list; do \
- f=`echo $$p|sed 's/$(EXEEXT)$$//'`; \
- echo " rm -f $$p $$f"; \
- rm -f $$p $$f ; \
- done
-examples/$(am__dirstamp):
- @$(mkdir_p) examples
- @: > examples/$(am__dirstamp)
-examples/mckey$(EXEEXT): $(examples_mckey_OBJECTS) $(examples_mckey_DEPENDENCIES) examples/$(am__dirstamp)
- @rm -f examples/mckey$(EXEEXT)
- $(LINK) $(examples_mckey_LDFLAGS) $(examples_mckey_OBJECTS) $(examples_mckey_LDADD) $(LIBS)
-examples/rping$(EXEEXT): $(examples_rping_OBJECTS) $(examples_rping_DEPENDENCIES) examples/$(am__dirstamp)
- @rm -f examples/rping$(EXEEXT)
- $(LINK) $(examples_rping_LDFLAGS) $(examples_rping_OBJECTS) $(examples_rping_LDADD) $(LIBS)
-examples/ucmatose$(EXEEXT): $(examples_ucmatose_OBJECTS) $(examples_ucmatose_DEPENDENCIES) examples/$(am__dirstamp)
- @rm -f examples/ucmatose$(EXEEXT)
- $(LINK) $(examples_ucmatose_LDFLAGS) $(examples_ucmatose_OBJECTS) $(examples_ucmatose_LDADD) $(LIBS)
-examples/udaddy$(EXEEXT): $(examples_udaddy_OBJECTS) $(examples_udaddy_DEPENDENCIES) examples/$(am__dirstamp)
- @rm -f examples/udaddy$(EXEEXT)
- $(LINK) $(examples_udaddy_LDFLAGS) $(examples_udaddy_OBJECTS) $(examples_udaddy_LDADD) $(LIBS)
-
-mostlyclean-compile:
- -rm -f *.$(OBJEXT)
-
-distclean-compile:
- -rm -f *.tab.c
-
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cmatose.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mckey.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/rping.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/src_librdmacm_la-cma.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/udaddy.Po@am__quote@
-
-.c.o:
-@am__fastdepCC_TRUE@ if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ $<; \
-@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi
-@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
-@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@ $(COMPILE) -c $<
-
-.c.obj:
-@am__fastdepCC_TRUE@ if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ `$(CYGPATH_W) '$<'`; \
-@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi
-@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
-@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'`
-
-.c.lo:
-@am__fastdepCC_TRUE@ if $(LTCOMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ $<; \
-@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Plo"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi
-@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
-@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $<
-
-src_librdmacm_la-cma.lo: src/cma.c
-@am__fastdepCC_TRUE@ if $(LIBTOOL) --tag=CC --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(src_librdmacm_la_CFLAGS) $(CFLAGS) -MT src_librdmacm_la-cma.lo -MD -MP -MF "$(DEPDIR)/src_librdmacm_la-cma.Tpo" -c -o src_librdmacm_la-cma.lo `test -f 'src/cma.c' || echo '$(srcdir)/'`src/cma.c; \
-@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/src_librdmacm_la-cma.Tpo" "$(DEPDIR)/src_librdmacm_la-cma.Plo"; else rm -f "$(DEPDIR)/src_librdmacm_la-cma.Tpo"; exit 1; fi
-@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='src/cma.c' object='src_librdmacm_la-cma.lo' libtool=yes @AMDEPBACKSLASH@
-@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(src_librdmacm_la_CFLAGS) $(CFLAGS) -c -o src_librdmacm_la-cma.lo `test -f 'src/cma.c' || echo '$(srcdir)/'`src/cma.c
-
-mckey.o: examples/mckey.c
-@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT mckey.o -MD -MP -MF "$(DEPDIR)/mckey.Tpo" -c -o mckey.o `test -f 'examples/mckey.c' || echo '$(srcdir)/'`examples/mckey.c; \
-@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/mckey.Tpo" "$(DEPDIR)/mckey.Po"; else rm -f "$(DEPDIR)/mckey.Tpo"; exit 1; fi
-@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='examples/mckey.c' object='mckey.o' libtool=no @AMDEPBACKSLASH@
-@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o mckey.o `test -f 'examples/mckey.c' || echo '$(srcdir)/'`examples/mckey.c
-
-mckey.obj: examples/mckey.c
-@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT mckey.obj -MD -MP -MF "$(DEPDIR)/mckey.Tpo" -c -o mckey.obj `if test -f 'examples/mckey.c'; then $(CYGPATH_W) 'examples/mckey.c'; else $(CYGPATH_W) '$(srcdir)/examples/mckey.c'; fi`; \
-@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/mckey.Tpo" "$(DEPDIR)/mckey.Po"; else rm -f "$(DEPDIR)/mckey.Tpo"; exit 1; fi
-@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='examples/mckey.c' object='mckey.obj' libtool=no @AMDEPBACKSLASH@
-@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o mckey.obj `if test -f 'examples/mckey.c'; then $(CYGPATH_W) 'examples/mckey.c'; else $(CYGPATH_W) '$(srcdir)/examples/mckey.c'; fi`
-
-rping.o: examples/rping.c
-@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT rping.o -MD -MP -MF "$(DEPDIR)/rping.Tpo" -c -o rping.o `test -f 'examples/rping.c' || echo '$(srcdir)/'`examples/rping.c; \
-@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/rping.Tpo" "$(DEPDIR)/rping.Po"; else rm -f "$(DEPDIR)/rping.Tpo"; exit 1; fi
-@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='examples/rping.c' object='rping.o' libtool=no @AMDEPBACKSLASH@
-@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o rping.o `test -f 'examples/rping.c' || echo '$(srcdir)/'`examples/rping.c
-
-rping.obj: examples/rping.c
-@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT rping.obj -MD -MP -MF "$(DEPDIR)/rping.Tpo" -c -o rping.obj `if test -f 'examples/rping.c'; then $(CYGPATH_W) 'examples/rping.c'; else $(CYGPATH_W) '$(srcdir)/examples/rping.c'; fi`; \
-@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/rping.Tpo" "$(DEPDIR)/rping.Po"; else rm -f "$(DEPDIR)/rping.Tpo"; exit 1; fi
-@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='examples/rping.c' object='rping.obj' libtool=no @AMDEPBACKSLASH@
-@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o rping.obj `if test -f 'examples/rping.c'; then $(CYGPATH_W) 'examples/rping.c'; else $(CYGPATH_W) '$(srcdir)/examples/rping.c'; fi`
-
-cmatose.o: examples/cmatose.c
-@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT cmatose.o -MD -MP -MF "$(DEPDIR)/cmatose.Tpo" -c -o cmatose.o `test -f 'examples/cmatose.c' || echo '$(srcdir)/'`examples/cmatose.c; \
-@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/cmatose.Tpo" "$(DEPDIR)/cmatose.Po"; else rm -f "$(DEPDIR)/cmatose.Tpo"; exit 1; fi
-@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='examples/cmatose.c' object='cmatose.o' libtool=no @AMDEPBACKSLASH@
-@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o cmatose.o `test -f 'examples/cmatose.c' || echo '$(srcdir)/'`examples/cmatose.c
-
-cmatose.obj: examples/cmatose.c
-@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT cmatose.obj -MD -MP -MF "$(DEPDIR)/cmatose.Tpo" -c -o cmatose.obj `if test -f 'examples/cmatose.c'; then $(CYGPATH_W) 'examples/cmatose.c'; else $(CYGPATH_W) '$(srcdir)/examples/cmatose.c'; fi`; \
-@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/cmatose.Tpo" "$(DEPDIR)/cmatose.Po"; else rm -f "$(DEPDIR)/cmatose.Tpo"; exit 1; fi
-@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='examples/cmatose.c' object='cmatose.obj' libtool=no @AMDEPBACKSLASH@
-@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o cmatose.obj `if test -f 'examples/cmatose.c'; then $(CYGPATH_W) 'examples/cmatose.c'; else $(CYGPATH_W) '$(srcdir)/examples/cmatose.c'; fi`
-
-udaddy.o: examples/udaddy.c
-@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT udaddy.o -MD -MP -MF "$(DEPDIR)/udaddy.Tpo" -c -o udaddy.o `test -f 'examples/udaddy.c' || echo '$(srcdir)/'`examples/udaddy.c; \
-@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/udaddy.Tpo" "$(DEPDIR)/udaddy.Po"; else rm -f "$(DEPDIR)/udaddy.Tpo"; exit 1; fi
-@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='examples/udaddy.c' object='udaddy.o' libtool=no @AMDEPBACKSLASH@
-@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o udaddy.o `test -f 'examples/udaddy.c' || echo '$(srcdir)/'`examples/udaddy.c
-
-udaddy.obj: examples/udaddy.c
-@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT udaddy.obj -MD -MP -MF "$(DEPDIR)/udaddy.Tpo" -c -o udaddy.obj `if test -f 'examples/udaddy.c'; then $(CYGPATH_W) 'examples/udaddy.c'; else $(CYGPATH_W) '$(srcdir)/examples/udaddy.c'; fi`; \
-@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/udaddy.Tpo" "$(DEPDIR)/udaddy.Po"; else rm -f "$(DEPDIR)/udaddy.Tpo"; exit 1; fi
-@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='examples/udaddy.c' object='udaddy.obj' libtool=no @AMDEPBACKSLASH@
-@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o udaddy.obj `if test -f 'examples/udaddy.c'; then $(CYGPATH_W) 'examples/udaddy.c'; else $(CYGPATH_W) '$(srcdir)/examples/udaddy.c'; fi`
-
-mostlyclean-libtool:
- -rm -f *.lo
-
-clean-libtool:
- -rm -rf .libs _libs
- -rm -rf src/.libs src/_libs
-
-distclean-libtool:
- -rm -f libtool
-uninstall-info-am:
-install-man1: $(man1_MANS) $(man_MANS)
- @$(NORMAL_INSTALL)
- test -z "$(man1dir)" || $(mkdir_p) "$(DESTDIR)$(man1dir)"
- @list='$(man1_MANS) $(dist_man1_MANS) $(nodist_man1_MANS)'; \
- l2='$(man_MANS) $(dist_man_MANS) $(nodist_man_MANS)'; \
- for i in $$l2; do \
- case "$$i" in \
- *.1*) list="$$list $$i" ;; \
- esac; \
- done; \
- for i in $$list; do \
- if test -f $(srcdir)/$$i; then file=$(srcdir)/$$i; \
- else file=$$i; fi; \
- ext=`echo $$i | sed -e 's/^.*\\.//'`; \
- case "$$ext" in \
- 1*) ;; \
- *) ext='1' ;; \
- esac; \
- inst=`echo $$i | sed -e 's/\\.[0-9a-z]*$$//'`; \
- inst=`echo $$inst | sed -e 's/^.*\///'`; \
- inst=`echo $$inst | sed '$(transform)'`.$$ext; \
- echo " $(INSTALL_DATA) '$$file' '$(DESTDIR)$(man1dir)/$$inst'"; \
- $(INSTALL_DATA) "$$file" "$(DESTDIR)$(man1dir)/$$inst"; \
- done
-uninstall-man1:
- @$(NORMAL_UNINSTALL)
- @list='$(man1_MANS) $(dist_man1_MANS) $(nodist_man1_MANS)'; \
- l2='$(man_MANS) $(dist_man_MANS) $(nodist_man_MANS)'; \
- for i in $$l2; do \
- case "$$i" in \
- *.1*) list="$$list $$i" ;; \
- esac; \
- done; \
- for i in $$list; do \
- ext=`echo $$i | sed -e 's/^.*\\.//'`; \
- case "$$ext" in \
- 1*) ;; \
- *) ext='1' ;; \
- esac; \
- inst=`echo $$i | sed -e 's/\\.[0-9a-z]*$$//'`; \
- inst=`echo $$inst | sed -e 's/^.*\///'`; \
- inst=`echo $$inst | sed '$(transform)'`.$$ext; \
- echo " rm -f '$(DESTDIR)$(man1dir)/$$inst'"; \
- rm -f "$(DESTDIR)$(man1dir)/$$inst"; \
- done
-install-man3: $(man3_MANS) $(man_MANS)
- @$(NORMAL_INSTALL)
- test -z "$(man3dir)" || $(mkdir_p) "$(DESTDIR)$(man3dir)"
- @list='$(man3_MANS) $(dist_man3_MANS) $(nodist_man3_MANS)'; \
- l2='$(man_MANS) $(dist_man_MANS) $(nodist_man_MANS)'; \
- for i in $$l2; do \
- case "$$i" in \
- *.3*) list="$$list $$i" ;; \
- esac; \
- done; \
- for i in $$list; do \
- if test -f $(srcdir)/$$i; then file=$(srcdir)/$$i; \
- else file=$$i; fi; \
- ext=`echo $$i | sed -e 's/^.*\\.//'`; \
- case "$$ext" in \
- 3*) ;; \
- *) ext='3' ;; \
- esac; \
- inst=`echo $$i | sed -e 's/\\.[0-9a-z]*$$//'`; \
- inst=`echo $$inst | sed -e 's/^.*\///'`; \
- inst=`echo $$inst | sed '$(transform)'`.$$ext; \
- echo " $(INSTALL_DATA) '$$file' '$(DESTDIR)$(man3dir)/$$inst'"; \
- $(INSTALL_DATA) "$$file" "$(DESTDIR)$(man3dir)/$$inst"; \
- done
-uninstall-man3:
- @$(NORMAL_UNINSTALL)
- @list='$(man3_MANS) $(dist_man3_MANS) $(nodist_man3_MANS)'; \
- l2='$(man_MANS) $(dist_man_MANS) $(nodist_man_MANS)'; \
- for i in $$l2; do \
- case "$$i" in \
- *.3*) list="$$list $$i" ;; \
- esac; \
- done; \
- for i in $$list; do \
- ext=`echo $$i | sed -e 's/^.*\\.//'`; \
- case "$$ext" in \
- 3*) ;; \
- *) ext='3' ;; \
- esac; \
- inst=`echo $$i | sed -e 's/\\.[0-9a-z]*$$//'`; \
- inst=`echo $$inst | sed -e 's/^.*\///'`; \
- inst=`echo $$inst | sed '$(transform)'`.$$ext; \
- echo " rm -f '$(DESTDIR)$(man3dir)/$$inst'"; \
- rm -f "$(DESTDIR)$(man3dir)/$$inst"; \
- done
-install-man7: $(man7_MANS) $(man_MANS)
- @$(NORMAL_INSTALL)
- test -z "$(man7dir)" || $(mkdir_p) "$(DESTDIR)$(man7dir)"
- @list='$(man7_MANS) $(dist_man7_MANS) $(nodist_man7_MANS)'; \
- l2='$(man_MANS) $(dist_man_MANS) $(nodist_man_MANS)'; \
- for i in $$l2; do \
- case "$$i" in \
- *.7*) list="$$list $$i" ;; \
- esac; \
- done; \
- for i in $$list; do \
- if test -f $(srcdir)/$$i; then file=$(srcdir)/$$i; \
- else file=$$i; fi; \
- ext=`echo $$i | sed -e 's/^.*\\.//'`; \
- case "$$ext" in \
- 7*) ;; \
- *) ext='7' ;; \
- esac; \
- inst=`echo $$i | sed -e 's/\\.[0-9a-z]*$$//'`; \
- inst=`echo $$inst | sed -e 's/^.*\///'`; \
- inst=`echo $$inst | sed '$(transform)'`.$$ext; \
- echo " $(INSTALL_DATA) '$$file' '$(DESTDIR)$(man7dir)/$$inst'"; \
- $(INSTALL_DATA) "$$file" "$(DESTDIR)$(man7dir)/$$inst"; \
- done
-uninstall-man7:
- @$(NORMAL_UNINSTALL)
- @list='$(man7_MANS) $(dist_man7_MANS) $(nodist_man7_MANS)'; \
- l2='$(man_MANS) $(dist_man_MANS) $(nodist_man_MANS)'; \
- for i in $$l2; do \
- case "$$i" in \
- *.7*) list="$$list $$i" ;; \
- esac; \
- done; \
- for i in $$list; do \
- ext=`echo $$i | sed -e 's/^.*\\.//'`; \
- case "$$ext" in \
- 7*) ;; \
- *) ext='7' ;; \
- esac; \
- inst=`echo $$i | sed -e 's/\\.[0-9a-z]*$$//'`; \
- inst=`echo $$inst | sed -e 's/^.*\///'`; \
- inst=`echo $$inst | sed '$(transform)'`.$$ext; \
- echo " rm -f '$(DESTDIR)$(man7dir)/$$inst'"; \
- rm -f "$(DESTDIR)$(man7dir)/$$inst"; \
- done
-install-librdmacmincludeHEADERS: $(librdmacminclude_HEADERS)
- @$(NORMAL_INSTALL)
- test -z "$(librdmacmincludedir)" || $(mkdir_p) "$(DESTDIR)$(librdmacmincludedir)"
- @list='$(librdmacminclude_HEADERS)'; for p in $$list; do \
- if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
- f=$(am__strip_dir) \
- echo " $(librdmacmincludeHEADERS_INSTALL) '$$d$$p' '$(DESTDIR)$(librdmacmincludedir)/$$f'"; \
- $(librdmacmincludeHEADERS_INSTALL) "$$d$$p" "$(DESTDIR)$(librdmacmincludedir)/$$f"; \
- done
-
-uninstall-librdmacmincludeHEADERS:
- @$(NORMAL_UNINSTALL)
- @list='$(librdmacminclude_HEADERS)'; for p in $$list; do \
- f=$(am__strip_dir) \
- echo " rm -f '$(DESTDIR)$(librdmacmincludedir)/$$f'"; \
- rm -f "$(DESTDIR)$(librdmacmincludedir)/$$f"; \
- done
-
-ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
- list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
- unique=`for i in $$list; do \
- if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
- done | \
- $(AWK) ' { files[$$0] = 1; } \
- END { for (i in files) print i; }'`; \
- mkid -fID $$unique
-tags: TAGS
-
-TAGS: $(HEADERS) $(SOURCES) config.h.in $(TAGS_DEPENDENCIES) \
- $(TAGS_FILES) $(LISP)
- tags=; \
- here=`pwd`; \
- list='$(SOURCES) $(HEADERS) config.h.in $(LISP) $(TAGS_FILES)'; \
- unique=`for i in $$list; do \
- if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
- done | \
- $(AWK) ' { files[$$0] = 1; } \
- END { for (i in files) print i; }'`; \
- if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
- test -n "$$unique" || unique=$$empty_fix; \
- $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
- $$tags $$unique; \
- fi
-ctags: CTAGS
-CTAGS: $(HEADERS) $(SOURCES) config.h.in $(TAGS_DEPENDENCIES) \
- $(TAGS_FILES) $(LISP)
- tags=; \
- here=`pwd`; \
- list='$(SOURCES) $(HEADERS) config.h.in $(LISP) $(TAGS_FILES)'; \
- unique=`for i in $$list; do \
- if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
- done | \
- $(AWK) ' { files[$$0] = 1; } \
- END { for (i in files) print i; }'`; \
- test -z "$(CTAGS_ARGS)$$tags$$unique" \
- || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
- $$tags $$unique
-
-GTAGS:
- here=`$(am__cd) $(top_builddir) && pwd` \
- && cd $(top_srcdir) \
- && gtags -i $(GTAGS_ARGS) $$here
-
-distclean-tags:
- -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
-
-distdir: $(DISTFILES)
- $(am__remove_distdir)
- mkdir $(distdir)
- $(mkdir_p) $(distdir)/. $(distdir)/config $(distdir)/include/rdma $(distdir)/man $(distdir)/src
- @srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \
- topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \
- list='$(DISTFILES)'; for file in $$list; do \
- case $$file in \
- $(srcdir)/*) file=`echo "$$file" | sed "s|^$$srcdirstrip/||"`;; \
- $(top_srcdir)/*) file=`echo "$$file" | sed "s|^$$topsrcdirstrip/|$(top_builddir)/|"`;; \
- esac; \
- if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
- dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \
- if test "$$dir" != "$$file" && test "$$dir" != "."; then \
- dir="/$$dir"; \
- $(mkdir_p) "$(distdir)$$dir"; \
- else \
- dir=''; \
- fi; \
- if test -d $$d/$$file; then \
- if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
- cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
- fi; \
- cp -pR $$d/$$file $(distdir)$$dir || exit 1; \
- else \
- test -f $(distdir)/$$file \
- || cp -p $$d/$$file $(distdir)/$$file \
- || exit 1; \
- fi; \
- done
- $(MAKE) $(AM_MAKEFLAGS) \
- top_distdir="$(top_distdir)" distdir="$(distdir)" \
- dist-hook
- -find $(distdir) -type d ! -perm -777 -exec chmod a+rwx {} \; -o \
- ! -type d ! -perm -444 -links 1 -exec chmod a+r {} \; -o \
- ! -type d ! -perm -400 -exec chmod a+r {} \; -o \
- ! -type d ! -perm -444 -exec $(SHELL) $(install_sh) -c -m a+r {} {} \; \
- || chmod -R a+r $(distdir)
-dist-gzip: distdir
- tardir=$(distdir) && $(am__tar) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz
- $(am__remove_distdir)
-
-dist-bzip2: distdir
- tardir=$(distdir) && $(am__tar) | bzip2 -9 -c >$(distdir).tar.bz2
- $(am__remove_distdir)
-
-dist-tarZ: distdir
- tardir=$(distdir) && $(am__tar) | compress -c >$(distdir).tar.Z
- $(am__remove_distdir)
-
-dist-shar: distdir
- shar $(distdir) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).shar.gz
- $(am__remove_distdir)
-
-dist-zip: distdir
- -rm -f $(distdir).zip
- zip -rq $(distdir).zip $(distdir)
- $(am__remove_distdir)
-
-dist dist-all: distdir
- tardir=$(distdir) && $(am__tar) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz
- $(am__remove_distdir)
-
-# This target untars the dist file and tries a VPATH configuration. Then
-# it guarantees that the distribution is self-contained by making another
-# tarfile.
-distcheck: dist
- case '$(DIST_ARCHIVES)' in \
- *.tar.gz*) \
- GZIP=$(GZIP_ENV) gunzip -c $(distdir).tar.gz | $(am__untar) ;;\
- *.tar.bz2*) \
- bunzip2 -c $(distdir).tar.bz2 | $(am__untar) ;;\
- *.tar.Z*) \
- uncompress -c $(distdir).tar.Z | $(am__untar) ;;\
- *.shar.gz*) \
- GZIP=$(GZIP_ENV) gunzip -c $(distdir).shar.gz | unshar ;;\
- *.zip*) \
- unzip $(distdir).zip ;;\
- esac
- chmod -R a-w $(distdir); chmod a+w $(distdir)
- mkdir $(distdir)/_build
- mkdir $(distdir)/_inst
- chmod a-w $(distdir)
- dc_install_base=`$(am__cd) $(distdir)/_inst && pwd | sed -e 's,^[^:\\/]:[\\/],/,'` \
- && dc_destdir="$${TMPDIR-/tmp}/am-dc-$$$$/" \
- && cd $(distdir)/_build \
- && ../configure --srcdir=.. --prefix="$$dc_install_base" \
- $(DISTCHECK_CONFIGURE_FLAGS) \
- && $(MAKE) $(AM_MAKEFLAGS) \
- && $(MAKE) $(AM_MAKEFLAGS) dvi \
- && $(MAKE) $(AM_MAKEFLAGS) check \
- && $(MAKE) $(AM_MAKEFLAGS) install \
- && $(MAKE) $(AM_MAKEFLAGS) installcheck \
- && $(MAKE) $(AM_MAKEFLAGS) uninstall \
- && $(MAKE) $(AM_MAKEFLAGS) distuninstallcheck_dir="$$dc_install_base" \
- distuninstallcheck \
- && chmod -R a-w "$$dc_install_base" \
- && ({ \
- (cd ../.. && umask 077 && mkdir "$$dc_destdir") \
- && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" install \
- && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" uninstall \
- && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" \
- distuninstallcheck_dir="$$dc_destdir" distuninstallcheck; \
- } || { rm -rf "$$dc_destdir"; exit 1; }) \
- && rm -rf "$$dc_destdir" \
- && $(MAKE) $(AM_MAKEFLAGS) dist \
- && rm -rf $(DIST_ARCHIVES) \
- && $(MAKE) $(AM_MAKEFLAGS) distcleancheck
- $(am__remove_distdir)
- @(echo "$(distdir) archives ready for distribution: "; \
- list='$(DIST_ARCHIVES)'; for i in $$list; do echo $$i; done) | \
- sed -e '1{h;s/./=/g;p;x;}' -e '$${p;x;}'
-distuninstallcheck:
- @cd $(distuninstallcheck_dir) \
- && test `$(distuninstallcheck_listfiles) | wc -l` -le 1 \
- || { echo "ERROR: files left after uninstall:" ; \
- if test -n "$(DESTDIR)"; then \
- echo " (check DESTDIR support)"; \
- fi ; \
- $(distuninstallcheck_listfiles) ; \
- exit 1; } >&2
-distcleancheck: distclean
- @if test '$(srcdir)' = . ; then \
- echo "ERROR: distcleancheck can only run from a VPATH build" ; \
- exit 1 ; \
- fi
- @test `$(distcleancheck_listfiles) | wc -l` -eq 0 \
- || { echo "ERROR: files left in build directory after distclean:" ; \
- $(distcleancheck_listfiles) ; \
- exit 1; } >&2
-check-am: all-am
-check: check-am
-all-am: Makefile $(LTLIBRARIES) $(PROGRAMS) $(MANS) $(HEADERS) \
- config.h
-install-binPROGRAMS: install-libLTLIBRARIES
-
-installdirs:
- for dir in "$(DESTDIR)$(libdir)" "$(DESTDIR)$(bindir)" "$(DESTDIR)$(man1dir)" "$(DESTDIR)$(man3dir)" "$(DESTDIR)$(man7dir)" "$(DESTDIR)$(librdmacmincludedir)"; do \
- test -z "$$dir" || $(mkdir_p) "$$dir"; \
- done
-install: install-am
-install-exec: install-exec-am
-install-data: install-data-am
-uninstall: uninstall-am
-
-install-am: all-am
- @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
-
-installcheck: installcheck-am
-install-strip:
- $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
- install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
- `test -z '$(STRIP)' || \
- echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
-mostlyclean-generic:
-
-clean-generic:
-
-distclean-generic:
- -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
- -rm -f examples/$(am__dirstamp)
- -rm -f src/$(am__dirstamp)
-
-maintainer-clean-generic:
- @echo "This command is intended for maintainers to use"
- @echo "it deletes files that may require special tools to rebuild."
-clean: clean-am
-
-clean-am: clean-binPROGRAMS clean-generic clean-libLTLIBRARIES \
- clean-libtool mostlyclean-am
-
-distclean: distclean-am
- -rm -f $(am__CONFIG_DISTCLEAN_FILES)
- -rm -rf ./$(DEPDIR)
- -rm -f Makefile
-distclean-am: clean-am distclean-compile distclean-generic \
- distclean-hdr distclean-libtool distclean-tags
-
-dvi: dvi-am
-
-dvi-am:
-
-html: html-am
-
-info: info-am
-
-info-am:
-
-install-data-am: install-librdmacmincludeHEADERS install-man
-
-install-exec-am: install-binPROGRAMS install-libLTLIBRARIES
-
-install-info: install-info-am
-
-install-man: install-man1 install-man3 install-man7
-
-installcheck-am:
-
-maintainer-clean: maintainer-clean-am
- -rm -f $(am__CONFIG_DISTCLEAN_FILES)
- -rm -rf $(top_srcdir)/autom4te.cache
- -rm -rf ./$(DEPDIR)
- -rm -f Makefile
-maintainer-clean-am: distclean-am maintainer-clean-generic
-
-mostlyclean: mostlyclean-am
-
-mostlyclean-am: mostlyclean-compile mostlyclean-generic \
- mostlyclean-libtool
-
-pdf: pdf-am
-
-pdf-am:
-
-ps: ps-am
-
-ps-am:
-
-uninstall-am: uninstall-binPROGRAMS uninstall-info-am \
- uninstall-libLTLIBRARIES uninstall-librdmacmincludeHEADERS \
- uninstall-man
-
-uninstall-man: uninstall-man1 uninstall-man3 uninstall-man7
-
-.PHONY: CTAGS GTAGS all all-am am--refresh check check-am clean \
- clean-binPROGRAMS clean-generic clean-libLTLIBRARIES \
- clean-libtool ctags dist dist-all dist-bzip2 dist-gzip \
- dist-hook dist-shar dist-tarZ dist-zip distcheck distclean \
- distclean-compile distclean-generic distclean-hdr \
- distclean-libtool distclean-tags distcleancheck distdir \
- distuninstallcheck dvi dvi-am html html-am info info-am \
- install install-am install-binPROGRAMS install-data \
- install-data-am install-exec install-exec-am install-info \
- install-info-am install-libLTLIBRARIES \
- install-librdmacmincludeHEADERS install-man install-man1 \
- install-man3 install-man7 install-strip installcheck \
- installcheck-am installdirs maintainer-clean \
- maintainer-clean-generic mostlyclean mostlyclean-compile \
- mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
- tags uninstall uninstall-am uninstall-binPROGRAMS \
- uninstall-info-am uninstall-libLTLIBRARIES \
- uninstall-librdmacmincludeHEADERS uninstall-man uninstall-man1 \
- uninstall-man3 uninstall-man7
-
-
-dist-hook: librdmacm.spec
- cp librdmacm.spec $(distdir)
-# Tell versions [3.59,3.63) of GNU make to not export all variables.
-# Otherwise a system limit (for SysV at least) may be exceeded.
-.NOEXPORT:
diff --git a/contrib/ofed/librdmacm/NEWS b/contrib/ofed/librdmacm/NEWS
deleted file mode 100644
index e69de29..0000000
--- a/contrib/ofed/librdmacm/NEWS
+++ /dev/null
diff --git a/contrib/ofed/librdmacm/README b/contrib/ofed/librdmacm/README
deleted file mode 100644
index 4d104cd..0000000
--- a/contrib/ofed/librdmacm/README
+++ /dev/null
@@ -1,50 +0,0 @@
-This README is for userspace RDMA cm library.
-
-
-Building
-========
-To make this directory, run:
-./autogen.sh && ./configure && make && make install
-
-Typically the autogen and configure steps only need be done the first
-time unless configure.in or Makefile.am changes.
-
-Libraries are installed by default at /usr/local/lib.
-
-
-Device files
-============
-The userspace CMA uses a single device file regardless of the number
-of adapters or ports present.
-
-To create the appropriate character device file automatically with
-udev, a rule like
-
- KERNEL="rdma_cm", NAME="infiniband/%k", MODE="0666"
-
-can be used. This will create the device node named
-
- /dev/infiniband/rdma_cm
-
-or you can create it manually
-
- mknod /dev/infiniband/rdma_cm c 231 255
-
-
-Common issues
-=============
-
-Using multiple interfaces
- The librdmacm does support multiple interfaces. To make use
- of multiple interfaces, however, you need to instruct linux
- to only send ARP reples on the interface targetted in the ARP
- request. This can be done using a command similar to the
- following:
-
- sysctl -w net.ipv4.conf.all.arp_ignore=2
-
- Without this change, it's possible for linux to resopnd to ARP
- requests on a different interface (IP address) than the IP
- address carried in the ARP request. This causes the RDMA stack
- to incorrectly map the remote IP address to the wrong RDMA
- device.
diff --git a/contrib/ofed/librdmacm/aclocal.m4 b/contrib/ofed/librdmacm/aclocal.m4
deleted file mode 100644
index 5baa59e..0000000
--- a/contrib/ofed/librdmacm/aclocal.m4
+++ /dev/null
@@ -1,7267 +0,0 @@
-# generated automatically by aclocal 1.9.6 -*- Autoconf -*-
-
-# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
-# 2005 Free Software Foundation, Inc.
-# This file is free software; the Free Software Foundation
-# gives unlimited permission to copy and/or distribute it,
-# with or without modifications, as long as this notice is preserved.
-
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
-# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
-# PARTICULAR PURPOSE.
-
-# libtool.m4 - Configure libtool for the host system. -*-Autoconf-*-
-
-# serial 48 Debian 1.5.22-2 AC_PROG_LIBTOOL
-
-
-# AC_PROVIDE_IFELSE(MACRO-NAME, IF-PROVIDED, IF-NOT-PROVIDED)
-# -----------------------------------------------------------
-# If this macro is not defined by Autoconf, define it here.
-m4_ifdef([AC_PROVIDE_IFELSE],
- [],
- [m4_define([AC_PROVIDE_IFELSE],
- [m4_ifdef([AC_PROVIDE_$1],
- [$2], [$3])])])
-
-
-# AC_PROG_LIBTOOL
-# ---------------
-AC_DEFUN([AC_PROG_LIBTOOL],
-[AC_REQUIRE([_AC_PROG_LIBTOOL])dnl
-dnl If AC_PROG_CXX has already been expanded, run AC_LIBTOOL_CXX
-dnl immediately, otherwise, hook it in at the end of AC_PROG_CXX.
- AC_PROVIDE_IFELSE([AC_PROG_CXX],
- [AC_LIBTOOL_CXX],
- [define([AC_PROG_CXX], defn([AC_PROG_CXX])[AC_LIBTOOL_CXX
- ])])
-dnl And a similar setup for Fortran 77 support
- AC_PROVIDE_IFELSE([AC_PROG_F77],
- [AC_LIBTOOL_F77],
- [define([AC_PROG_F77], defn([AC_PROG_F77])[AC_LIBTOOL_F77
-])])
-
-dnl Quote A][M_PROG_GCJ so that aclocal doesn't bring it in needlessly.
-dnl If either AC_PROG_GCJ or A][M_PROG_GCJ have already been expanded, run
-dnl AC_LIBTOOL_GCJ immediately, otherwise, hook it in at the end of both.
- AC_PROVIDE_IFELSE([AC_PROG_GCJ],
- [AC_LIBTOOL_GCJ],
- [AC_PROVIDE_IFELSE([A][M_PROG_GCJ],
- [AC_LIBTOOL_GCJ],
- [AC_PROVIDE_IFELSE([LT_AC_PROG_GCJ],
- [AC_LIBTOOL_GCJ],
- [ifdef([AC_PROG_GCJ],
- [define([AC_PROG_GCJ], defn([AC_PROG_GCJ])[AC_LIBTOOL_GCJ])])
- ifdef([A][M_PROG_GCJ],
- [define([A][M_PROG_GCJ], defn([A][M_PROG_GCJ])[AC_LIBTOOL_GCJ])])
- ifdef([LT_AC_PROG_GCJ],
- [define([LT_AC_PROG_GCJ],
- defn([LT_AC_PROG_GCJ])[AC_LIBTOOL_GCJ])])])])
-])])# AC_PROG_LIBTOOL
-
-
-# _AC_PROG_LIBTOOL
-# ----------------
-AC_DEFUN([_AC_PROG_LIBTOOL],
-[AC_REQUIRE([AC_LIBTOOL_SETUP])dnl
-AC_BEFORE([$0],[AC_LIBTOOL_CXX])dnl
-AC_BEFORE([$0],[AC_LIBTOOL_F77])dnl
-AC_BEFORE([$0],[AC_LIBTOOL_GCJ])dnl
-
-# This can be used to rebuild libtool when needed
-LIBTOOL_DEPS="$ac_aux_dir/ltmain.sh"
-
-# Always use our own libtool.
-LIBTOOL='$(SHELL) $(top_builddir)/libtool'
-AC_SUBST(LIBTOOL)dnl
-
-# Prevent multiple expansion
-define([AC_PROG_LIBTOOL], [])
-])# _AC_PROG_LIBTOOL
-
-
-# AC_LIBTOOL_SETUP
-# ----------------
-AC_DEFUN([AC_LIBTOOL_SETUP],
-[AC_PREREQ(2.50)dnl
-AC_REQUIRE([AC_ENABLE_SHARED])dnl
-AC_REQUIRE([AC_ENABLE_STATIC])dnl
-AC_REQUIRE([AC_ENABLE_FAST_INSTALL])dnl
-AC_REQUIRE([AC_CANONICAL_HOST])dnl
-AC_REQUIRE([AC_CANONICAL_BUILD])dnl
-AC_REQUIRE([AC_PROG_CC])dnl
-AC_REQUIRE([AC_PROG_LD])dnl
-AC_REQUIRE([AC_PROG_LD_RELOAD_FLAG])dnl
-AC_REQUIRE([AC_PROG_NM])dnl
-
-AC_REQUIRE([AC_PROG_LN_S])dnl
-AC_REQUIRE([AC_DEPLIBS_CHECK_METHOD])dnl
-# Autoconf 2.13's AC_OBJEXT and AC_EXEEXT macros only works for C compilers!
-AC_REQUIRE([AC_OBJEXT])dnl
-AC_REQUIRE([AC_EXEEXT])dnl
-dnl
-
-AC_LIBTOOL_SYS_MAX_CMD_LEN
-AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE
-AC_LIBTOOL_OBJDIR
-
-AC_REQUIRE([_LT_AC_SYS_COMPILER])dnl
-_LT_AC_PROG_ECHO_BACKSLASH
-
-case $host_os in
-aix3*)
- # AIX sometimes has problems with the GCC collect2 program. For some
- # reason, if we set the COLLECT_NAMES environment variable, the problems
- # vanish in a puff of smoke.
- if test "X${COLLECT_NAMES+set}" != Xset; then
- COLLECT_NAMES=
- export COLLECT_NAMES
- fi
- ;;
-esac
-
-# Sed substitution that helps us do robust quoting. It backslashifies
-# metacharacters that are still active within double-quoted strings.
-Xsed='sed -e 1s/^X//'
-[sed_quote_subst='s/\([\\"\\`$\\\\]\)/\\\1/g']
-
-# Same as above, but do not quote variable references.
-[double_quote_subst='s/\([\\"\\`\\\\]\)/\\\1/g']
-
-# Sed substitution to delay expansion of an escaped shell variable in a
-# double_quote_subst'ed string.
-delay_variable_subst='s/\\\\\\\\\\\$/\\\\\\$/g'
-
-# Sed substitution to avoid accidental globbing in evaled expressions
-no_glob_subst='s/\*/\\\*/g'
-
-# Constants:
-rm="rm -f"
-
-# Global variables:
-default_ofile=libtool
-can_build_shared=yes
-
-# All known linkers require a `.a' archive for static linking (except MSVC,
-# which needs '.lib').
-libext=a
-ltmain="$ac_aux_dir/ltmain.sh"
-ofile="$default_ofile"
-with_gnu_ld="$lt_cv_prog_gnu_ld"
-
-AC_CHECK_TOOL(AR, ar, false)
-AC_CHECK_TOOL(RANLIB, ranlib, :)
-AC_CHECK_TOOL(STRIP, strip, :)
-
-old_CC="$CC"
-old_CFLAGS="$CFLAGS"
-
-# Set sane defaults for various variables
-test -z "$AR" && AR=ar
-test -z "$AR_FLAGS" && AR_FLAGS=cru
-test -z "$AS" && AS=as
-test -z "$CC" && CC=cc
-test -z "$LTCC" && LTCC=$CC
-test -z "$LTCFLAGS" && LTCFLAGS=$CFLAGS
-test -z "$DLLTOOL" && DLLTOOL=dlltool
-test -z "$LD" && LD=ld
-test -z "$LN_S" && LN_S="ln -s"
-test -z "$MAGIC_CMD" && MAGIC_CMD=file
-test -z "$NM" && NM=nm
-test -z "$SED" && SED=sed
-test -z "$OBJDUMP" && OBJDUMP=objdump
-test -z "$RANLIB" && RANLIB=:
-test -z "$STRIP" && STRIP=:
-test -z "$ac_objext" && ac_objext=o
-
-# Determine commands to create old-style static archives.
-old_archive_cmds='$AR $AR_FLAGS $oldlib$oldobjs$old_deplibs'
-old_postinstall_cmds='chmod 644 $oldlib'
-old_postuninstall_cmds=
-
-if test -n "$RANLIB"; then
- case $host_os in
- openbsd*)
- old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB -t \$oldlib"
- ;;
- *)
- old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB \$oldlib"
- ;;
- esac
- old_archive_cmds="$old_archive_cmds~\$RANLIB \$oldlib"
-fi
-
-_LT_CC_BASENAME([$compiler])
-
-# Only perform the check for file, if the check method requires it
-case $deplibs_check_method in
-file_magic*)
- if test "$file_magic_cmd" = '$MAGIC_CMD'; then
- AC_PATH_MAGIC
- fi
- ;;
-esac
-
-AC_PROVIDE_IFELSE([AC_LIBTOOL_DLOPEN], enable_dlopen=yes, enable_dlopen=no)
-AC_PROVIDE_IFELSE([AC_LIBTOOL_WIN32_DLL],
-enable_win32_dll=yes, enable_win32_dll=no)
-
-AC_ARG_ENABLE([libtool-lock],
- [AC_HELP_STRING([--disable-libtool-lock],
- [avoid locking (might break parallel builds)])])
-test "x$enable_libtool_lock" != xno && enable_libtool_lock=yes
-
-AC_ARG_WITH([pic],
- [AC_HELP_STRING([--with-pic],
- [try to use only PIC/non-PIC objects @<:@default=use both@:>@])],
- [pic_mode="$withval"],
- [pic_mode=default])
-test -z "$pic_mode" && pic_mode=default
-
-# Use C for the default configuration in the libtool script
-tagname=
-AC_LIBTOOL_LANG_C_CONFIG
-_LT_AC_TAGCONFIG
-])# AC_LIBTOOL_SETUP
-
-
-# _LT_AC_SYS_COMPILER
-# -------------------
-AC_DEFUN([_LT_AC_SYS_COMPILER],
-[AC_REQUIRE([AC_PROG_CC])dnl
-
-# If no C compiler was specified, use CC.
-LTCC=${LTCC-"$CC"}
-
-# If no C compiler flags were specified, use CFLAGS.
-LTCFLAGS=${LTCFLAGS-"$CFLAGS"}
-
-# Allow CC to be a program name with arguments.
-compiler=$CC
-])# _LT_AC_SYS_COMPILER
-
-
-# _LT_CC_BASENAME(CC)
-# -------------------
-# Calculate cc_basename. Skip known compiler wrappers and cross-prefix.
-AC_DEFUN([_LT_CC_BASENAME],
-[for cc_temp in $1""; do
- case $cc_temp in
- compile | *[[\\/]]compile | ccache | *[[\\/]]ccache ) ;;
- distcc | *[[\\/]]distcc | purify | *[[\\/]]purify ) ;;
- \-*) ;;
- *) break;;
- esac
-done
-cc_basename=`$echo "X$cc_temp" | $Xsed -e 's%.*/%%' -e "s%^$host_alias-%%"`
-])
-
-
-# _LT_COMPILER_BOILERPLATE
-# ------------------------
-# Check for compiler boilerplate output or warnings with
-# the simple compiler test code.
-AC_DEFUN([_LT_COMPILER_BOILERPLATE],
-[ac_outfile=conftest.$ac_objext
-printf "$lt_simple_compile_test_code" >conftest.$ac_ext
-eval "$ac_compile" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err
-_lt_compiler_boilerplate=`cat conftest.err`
-$rm conftest*
-])# _LT_COMPILER_BOILERPLATE
-
-
-# _LT_LINKER_BOILERPLATE
-# ----------------------
-# Check for linker boilerplate output or warnings with
-# the simple link test code.
-AC_DEFUN([_LT_LINKER_BOILERPLATE],
-[ac_outfile=conftest.$ac_objext
-printf "$lt_simple_link_test_code" >conftest.$ac_ext
-eval "$ac_link" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err
-_lt_linker_boilerplate=`cat conftest.err`
-$rm conftest*
-])# _LT_LINKER_BOILERPLATE
-
-
-# _LT_AC_SYS_LIBPATH_AIX
-# ----------------------
-# Links a minimal program and checks the executable
-# for the system default hardcoded library path. In most cases,
-# this is /usr/lib:/lib, but when the MPI compilers are used
-# the location of the communication and MPI libs are included too.
-# If we don't find anything, use the default library path according
-# to the aix ld manual.
-AC_DEFUN([_LT_AC_SYS_LIBPATH_AIX],
-[AC_LINK_IFELSE(AC_LANG_PROGRAM,[
-aix_libpath=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; }
-}'`
-# Check for a 64-bit object if we didn't find anything.
-if test -z "$aix_libpath"; then aix_libpath=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; }
-}'`; fi],[])
-if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
-])# _LT_AC_SYS_LIBPATH_AIX
-
-
-# _LT_AC_SHELL_INIT(ARG)
-# ----------------------
-AC_DEFUN([_LT_AC_SHELL_INIT],
-[ifdef([AC_DIVERSION_NOTICE],
- [AC_DIVERT_PUSH(AC_DIVERSION_NOTICE)],
- [AC_DIVERT_PUSH(NOTICE)])
-$1
-AC_DIVERT_POP
-])# _LT_AC_SHELL_INIT
-
-
-# _LT_AC_PROG_ECHO_BACKSLASH
-# --------------------------
-# Add some code to the start of the generated configure script which
-# will find an echo command which doesn't interpret backslashes.
-AC_DEFUN([_LT_AC_PROG_ECHO_BACKSLASH],
-[_LT_AC_SHELL_INIT([
-# Check that we are running under the correct shell.
-SHELL=${CONFIG_SHELL-/bin/sh}
-
-case X$ECHO in
-X*--fallback-echo)
- # Remove one level of quotation (which was required for Make).
- ECHO=`echo "$ECHO" | sed 's,\\\\\[$]\\[$]0,'[$]0','`
- ;;
-esac
-
-echo=${ECHO-echo}
-if test "X[$]1" = X--no-reexec; then
- # Discard the --no-reexec flag, and continue.
- shift
-elif test "X[$]1" = X--fallback-echo; then
- # Avoid inline document here, it may be left over
- :
-elif test "X`($echo '\t') 2>/dev/null`" = 'X\t' ; then
- # Yippee, $echo works!
- :
-else
- # Restart under the correct shell.
- exec $SHELL "[$]0" --no-reexec ${1+"[$]@"}
-fi
-
-if test "X[$]1" = X--fallback-echo; then
- # used as fallback echo
- shift
- cat <<EOF
-[$]*
-EOF
- exit 0
-fi
-
-# The HP-UX ksh and POSIX shell print the target directory to stdout
-# if CDPATH is set.
-(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
-
-if test -z "$ECHO"; then
-if test "X${echo_test_string+set}" != Xset; then
-# find a string as large as possible, as long as the shell can cope with it
- for cmd in 'sed 50q "[$]0"' 'sed 20q "[$]0"' 'sed 10q "[$]0"' 'sed 2q "[$]0"' 'echo test'; do
- # expected sizes: less than 2Kb, 1Kb, 512 bytes, 16 bytes, ...
- if (echo_test_string=`eval $cmd`) 2>/dev/null &&
- echo_test_string=`eval $cmd` &&
- (test "X$echo_test_string" = "X$echo_test_string") 2>/dev/null
- then
- break
- fi
- done
-fi
-
-if test "X`($echo '\t') 2>/dev/null`" = 'X\t' &&
- echo_testing_string=`($echo "$echo_test_string") 2>/dev/null` &&
- test "X$echo_testing_string" = "X$echo_test_string"; then
- :
-else
- # The Solaris, AIX, and Digital Unix default echo programs unquote
- # backslashes. This makes it impossible to quote backslashes using
- # echo "$something" | sed 's/\\/\\\\/g'
- #
- # So, first we look for a working echo in the user's PATH.
-
- lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
- for dir in $PATH /usr/ucb; do
- IFS="$lt_save_ifs"
- if (test -f $dir/echo || test -f $dir/echo$ac_exeext) &&
- test "X`($dir/echo '\t') 2>/dev/null`" = 'X\t' &&
- echo_testing_string=`($dir/echo "$echo_test_string") 2>/dev/null` &&
- test "X$echo_testing_string" = "X$echo_test_string"; then
- echo="$dir/echo"
- break
- fi
- done
- IFS="$lt_save_ifs"
-
- if test "X$echo" = Xecho; then
- # We didn't find a better echo, so look for alternatives.
- if test "X`(print -r '\t') 2>/dev/null`" = 'X\t' &&
- echo_testing_string=`(print -r "$echo_test_string") 2>/dev/null` &&
- test "X$echo_testing_string" = "X$echo_test_string"; then
- # This shell has a builtin print -r that does the trick.
- echo='print -r'
- elif (test -f /bin/ksh || test -f /bin/ksh$ac_exeext) &&
- test "X$CONFIG_SHELL" != X/bin/ksh; then
- # If we have ksh, try running configure again with it.
- ORIGINAL_CONFIG_SHELL=${CONFIG_SHELL-/bin/sh}
- export ORIGINAL_CONFIG_SHELL
- CONFIG_SHELL=/bin/ksh
- export CONFIG_SHELL
- exec $CONFIG_SHELL "[$]0" --no-reexec ${1+"[$]@"}
- else
- # Try using printf.
- echo='printf %s\n'
- if test "X`($echo '\t') 2>/dev/null`" = 'X\t' &&
- echo_testing_string=`($echo "$echo_test_string") 2>/dev/null` &&
- test "X$echo_testing_string" = "X$echo_test_string"; then
- # Cool, printf works
- :
- elif echo_testing_string=`($ORIGINAL_CONFIG_SHELL "[$]0" --fallback-echo '\t') 2>/dev/null` &&
- test "X$echo_testing_string" = 'X\t' &&
- echo_testing_string=`($ORIGINAL_CONFIG_SHELL "[$]0" --fallback-echo "$echo_test_string") 2>/dev/null` &&
- test "X$echo_testing_string" = "X$echo_test_string"; then
- CONFIG_SHELL=$ORIGINAL_CONFIG_SHELL
- export CONFIG_SHELL
- SHELL="$CONFIG_SHELL"
- export SHELL
- echo="$CONFIG_SHELL [$]0 --fallback-echo"
- elif echo_testing_string=`($CONFIG_SHELL "[$]0" --fallback-echo '\t') 2>/dev/null` &&
- test "X$echo_testing_string" = 'X\t' &&
- echo_testing_string=`($CONFIG_SHELL "[$]0" --fallback-echo "$echo_test_string") 2>/dev/null` &&
- test "X$echo_testing_string" = "X$echo_test_string"; then
- echo="$CONFIG_SHELL [$]0 --fallback-echo"
- else
- # maybe with a smaller string...
- prev=:
-
- for cmd in 'echo test' 'sed 2q "[$]0"' 'sed 10q "[$]0"' 'sed 20q "[$]0"' 'sed 50q "[$]0"'; do
- if (test "X$echo_test_string" = "X`eval $cmd`") 2>/dev/null
- then
- break
- fi
- prev="$cmd"
- done
-
- if test "$prev" != 'sed 50q "[$]0"'; then
- echo_test_string=`eval $prev`
- export echo_test_string
- exec ${ORIGINAL_CONFIG_SHELL-${CONFIG_SHELL-/bin/sh}} "[$]0" ${1+"[$]@"}
- else
- # Oops. We lost completely, so just stick with echo.
- echo=echo
- fi
- fi
- fi
- fi
-fi
-fi
-
-# Copy echo and quote the copy suitably for passing to libtool from
-# the Makefile, instead of quoting the original, which is used later.
-ECHO=$echo
-if test "X$ECHO" = "X$CONFIG_SHELL [$]0 --fallback-echo"; then
- ECHO="$CONFIG_SHELL \\\$\[$]0 --fallback-echo"
-fi
-
-AC_SUBST(ECHO)
-])])# _LT_AC_PROG_ECHO_BACKSLASH
-
-
-# _LT_AC_LOCK
-# -----------
-AC_DEFUN([_LT_AC_LOCK],
-[AC_ARG_ENABLE([libtool-lock],
- [AC_HELP_STRING([--disable-libtool-lock],
- [avoid locking (might break parallel builds)])])
-test "x$enable_libtool_lock" != xno && enable_libtool_lock=yes
-
-# Some flags need to be propagated to the compiler or linker for good
-# libtool support.
-case $host in
-ia64-*-hpux*)
- # Find out which ABI we are using.
- echo 'int i;' > conftest.$ac_ext
- if AC_TRY_EVAL(ac_compile); then
- case `/usr/bin/file conftest.$ac_objext` in
- *ELF-32*)
- HPUX_IA64_MODE="32"
- ;;
- *ELF-64*)
- HPUX_IA64_MODE="64"
- ;;
- esac
- fi
- rm -rf conftest*
- ;;
-*-*-irix6*)
- # Find out which ABI we are using.
- echo '[#]line __oline__ "configure"' > conftest.$ac_ext
- if AC_TRY_EVAL(ac_compile); then
- if test "$lt_cv_prog_gnu_ld" = yes; then
- case `/usr/bin/file conftest.$ac_objext` in
- *32-bit*)
- LD="${LD-ld} -melf32bsmip"
- ;;
- *N32*)
- LD="${LD-ld} -melf32bmipn32"
- ;;
- *64-bit*)
- LD="${LD-ld} -melf64bmip"
- ;;
- esac
- else
- case `/usr/bin/file conftest.$ac_objext` in
- *32-bit*)
- LD="${LD-ld} -32"
- ;;
- *N32*)
- LD="${LD-ld} -n32"
- ;;
- *64-bit*)
- LD="${LD-ld} -64"
- ;;
- esac
- fi
- fi
- rm -rf conftest*
- ;;
-
-x86_64-*linux*|ppc*-*linux*|powerpc*-*linux*|s390*-*linux*|sparc*-*linux*)
- # Find out which ABI we are using.
- echo 'int i;' > conftest.$ac_ext
- if AC_TRY_EVAL(ac_compile); then
- case `/usr/bin/file conftest.o` in
- *32-bit*)
- case $host in
- x86_64-*linux*)
- LD="${LD-ld} -m elf_i386"
- ;;
- ppc64-*linux*|powerpc64-*linux*)
- LD="${LD-ld} -m elf32ppclinux"
- ;;
- s390x-*linux*)
- LD="${LD-ld} -m elf_s390"
- ;;
- sparc64-*linux*)
- LD="${LD-ld} -m elf32_sparc"
- ;;
- esac
- ;;
- *64-bit*)
- case $host in
- x86_64-*linux*)
- LD="${LD-ld} -m elf_x86_64"
- ;;
- ppc*-*linux*|powerpc*-*linux*)
- LD="${LD-ld} -m elf64ppc"
- ;;
- s390*-*linux*)
- LD="${LD-ld} -m elf64_s390"
- ;;
- sparc*-*linux*)
- LD="${LD-ld} -m elf64_sparc"
- ;;
- esac
- ;;
- esac
- fi
- rm -rf conftest*
- ;;
-
-*-*-sco3.2v5*)
- # On SCO OpenServer 5, we need -belf to get full-featured binaries.
- SAVE_CFLAGS="$CFLAGS"
- CFLAGS="$CFLAGS -belf"
- AC_CACHE_CHECK([whether the C compiler needs -belf], lt_cv_cc_needs_belf,
- [AC_LANG_PUSH(C)
- AC_TRY_LINK([],[],[lt_cv_cc_needs_belf=yes],[lt_cv_cc_needs_belf=no])
- AC_LANG_POP])
- if test x"$lt_cv_cc_needs_belf" != x"yes"; then
- # this is probably gcc 2.8.0, egcs 1.0 or newer; no need for -belf
- CFLAGS="$SAVE_CFLAGS"
- fi
- ;;
-sparc*-*solaris*)
- # Find out which ABI we are using.
- echo 'int i;' > conftest.$ac_ext
- if AC_TRY_EVAL(ac_compile); then
- case `/usr/bin/file conftest.o` in
- *64-bit*)
- case $lt_cv_prog_gnu_ld in
- yes*) LD="${LD-ld} -m elf64_sparc" ;;
- *) LD="${LD-ld} -64" ;;
- esac
- ;;
- esac
- fi
- rm -rf conftest*
- ;;
-
-AC_PROVIDE_IFELSE([AC_LIBTOOL_WIN32_DLL],
-[*-*-cygwin* | *-*-mingw* | *-*-pw32*)
- AC_CHECK_TOOL(DLLTOOL, dlltool, false)
- AC_CHECK_TOOL(AS, as, false)
- AC_CHECK_TOOL(OBJDUMP, objdump, false)
- ;;
- ])
-esac
-
-need_locks="$enable_libtool_lock"
-
-])# _LT_AC_LOCK
-
-
-# AC_LIBTOOL_COMPILER_OPTION(MESSAGE, VARIABLE-NAME, FLAGS,
-# [OUTPUT-FILE], [ACTION-SUCCESS], [ACTION-FAILURE])
-# ----------------------------------------------------------------
-# Check whether the given compiler option works
-AC_DEFUN([AC_LIBTOOL_COMPILER_OPTION],
-[AC_REQUIRE([LT_AC_PROG_SED])
-AC_CACHE_CHECK([$1], [$2],
- [$2=no
- ifelse([$4], , [ac_outfile=conftest.$ac_objext], [ac_outfile=$4])
- printf "$lt_simple_compile_test_code" > conftest.$ac_ext
- lt_compiler_flag="$3"
- # Insert the option either (1) after the last *FLAGS variable, or
- # (2) before a word containing "conftest.", or (3) at the end.
- # Note that $ac_compile itself does not contain backslashes and begins
- # with a dollar sign (not a hyphen), so the echo should work correctly.
- # The option is referenced via a variable to avoid confusing sed.
- lt_compile=`echo "$ac_compile" | $SED \
- -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
- -e 's: [[^ ]]*conftest\.: $lt_compiler_flag&:; t' \
- -e 's:$: $lt_compiler_flag:'`
- (eval echo "\"\$as_me:__oline__: $lt_compile\"" >&AS_MESSAGE_LOG_FD)
- (eval "$lt_compile" 2>conftest.err)
- ac_status=$?
- cat conftest.err >&AS_MESSAGE_LOG_FD
- echo "$as_me:__oline__: \$? = $ac_status" >&AS_MESSAGE_LOG_FD
- if (exit $ac_status) && test -s "$ac_outfile"; then
- # The compiler can only warn and ignore the option if not recognized
- # So say no if there are warnings other than the usual output.
- $echo "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' >conftest.exp
- $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2
- if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then
- $2=yes
- fi
- fi
- $rm conftest*
-])
-
-if test x"[$]$2" = xyes; then
- ifelse([$5], , :, [$5])
-else
- ifelse([$6], , :, [$6])
-fi
-])# AC_LIBTOOL_COMPILER_OPTION
-
-
-# AC_LIBTOOL_LINKER_OPTION(MESSAGE, VARIABLE-NAME, FLAGS,
-# [ACTION-SUCCESS], [ACTION-FAILURE])
-# ------------------------------------------------------------
-# Check whether the given compiler option works
-AC_DEFUN([AC_LIBTOOL_LINKER_OPTION],
-[AC_CACHE_CHECK([$1], [$2],
- [$2=no
- save_LDFLAGS="$LDFLAGS"
- LDFLAGS="$LDFLAGS $3"
- printf "$lt_simple_link_test_code" > conftest.$ac_ext
- if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then
- # The linker can only warn and ignore the option if not recognized
- # So say no if there are warnings
- if test -s conftest.err; then
- # Append any errors to the config.log.
- cat conftest.err 1>&AS_MESSAGE_LOG_FD
- $echo "X$_lt_linker_boilerplate" | $Xsed -e '/^$/d' > conftest.exp
- $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2
- if diff conftest.exp conftest.er2 >/dev/null; then
- $2=yes
- fi
- else
- $2=yes
- fi
- fi
- $rm conftest*
- LDFLAGS="$save_LDFLAGS"
-])
-
-if test x"[$]$2" = xyes; then
- ifelse([$4], , :, [$4])
-else
- ifelse([$5], , :, [$5])
-fi
-])# AC_LIBTOOL_LINKER_OPTION
-
-
-# AC_LIBTOOL_SYS_MAX_CMD_LEN
-# --------------------------
-AC_DEFUN([AC_LIBTOOL_SYS_MAX_CMD_LEN],
-[# find the maximum length of command line arguments
-AC_MSG_CHECKING([the maximum length of command line arguments])
-AC_CACHE_VAL([lt_cv_sys_max_cmd_len], [dnl
- i=0
- teststring="ABCD"
-
- case $build_os in
- msdosdjgpp*)
- # On DJGPP, this test can blow up pretty badly due to problems in libc
- # (any single argument exceeding 2000 bytes causes a buffer overrun
- # during glob expansion). Even if it were fixed, the result of this
- # check would be larger than it should be.
- lt_cv_sys_max_cmd_len=12288; # 12K is about right
- ;;
-
- gnu*)
- # Under GNU Hurd, this test is not required because there is
- # no limit to the length of command line arguments.
- # Libtool will interpret -1 as no limit whatsoever
- lt_cv_sys_max_cmd_len=-1;
- ;;
-
- cygwin* | mingw*)
- # On Win9x/ME, this test blows up -- it succeeds, but takes
- # about 5 minutes as the teststring grows exponentially.
- # Worse, since 9x/ME are not pre-emptively multitasking,
- # you end up with a "frozen" computer, even though with patience
- # the test eventually succeeds (with a max line length of 256k).
- # Instead, let's just punt: use the minimum linelength reported by
- # all of the supported platforms: 8192 (on NT/2K/XP).
- lt_cv_sys_max_cmd_len=8192;
- ;;
-
- amigaos*)
- # On AmigaOS with pdksh, this test takes hours, literally.
- # So we just punt and use a minimum line length of 8192.
- lt_cv_sys_max_cmd_len=8192;
- ;;
-
- netbsd* | freebsd* | openbsd* | darwin* | dragonfly*)
- # This has been around since 386BSD, at least. Likely further.
- if test -x /sbin/sysctl; then
- lt_cv_sys_max_cmd_len=`/sbin/sysctl -n kern.argmax`
- elif test -x /usr/sbin/sysctl; then
- lt_cv_sys_max_cmd_len=`/usr/sbin/sysctl -n kern.argmax`
- else
- lt_cv_sys_max_cmd_len=65536 # usable default for all BSDs
- fi
- # And add a safety zone
- lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4`
- lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3`
- ;;
-
- interix*)
- # We know the value 262144 and hardcode it with a safety zone (like BSD)
- lt_cv_sys_max_cmd_len=196608
- ;;
-
- osf*)
- # Dr. Hans Ekkehard Plesser reports seeing a kernel panic running configure
- # due to this test when exec_disable_arg_limit is 1 on Tru64. It is not
- # nice to cause kernel panics so lets avoid the loop below.
- # First set a reasonable default.
- lt_cv_sys_max_cmd_len=16384
- #
- if test -x /sbin/sysconfig; then
- case `/sbin/sysconfig -q proc exec_disable_arg_limit` in
- *1*) lt_cv_sys_max_cmd_len=-1 ;;
- esac
- fi
- ;;
- sco3.2v5*)
- lt_cv_sys_max_cmd_len=102400
- ;;
- sysv5* | sco5v6* | sysv4.2uw2*)
- kargmax=`grep ARG_MAX /etc/conf/cf.d/stune 2>/dev/null`
- if test -n "$kargmax"; then
- lt_cv_sys_max_cmd_len=`echo $kargmax | sed 's/.*[[ ]]//'`
- else
- lt_cv_sys_max_cmd_len=32768
- fi
- ;;
- *)
- # If test is not a shell built-in, we'll probably end up computing a
- # maximum length that is only half of the actual maximum length, but
- # we can't tell.
- SHELL=${SHELL-${CONFIG_SHELL-/bin/sh}}
- while (test "X"`$SHELL [$]0 --fallback-echo "X$teststring" 2>/dev/null` \
- = "XX$teststring") >/dev/null 2>&1 &&
- new_result=`expr "X$teststring" : ".*" 2>&1` &&
- lt_cv_sys_max_cmd_len=$new_result &&
- test $i != 17 # 1/2 MB should be enough
- do
- i=`expr $i + 1`
- teststring=$teststring$teststring
- done
- teststring=
- # Add a significant safety factor because C++ compilers can tack on massive
- # amounts of additional arguments before passing them to the linker.
- # It appears as though 1/2 is a usable value.
- lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 2`
- ;;
- esac
-])
-if test -n $lt_cv_sys_max_cmd_len ; then
- AC_MSG_RESULT($lt_cv_sys_max_cmd_len)
-else
- AC_MSG_RESULT(none)
-fi
-])# AC_LIBTOOL_SYS_MAX_CMD_LEN
-
-
-# _LT_AC_CHECK_DLFCN
-# ------------------
-AC_DEFUN([_LT_AC_CHECK_DLFCN],
-[AC_CHECK_HEADERS(dlfcn.h)dnl
-])# _LT_AC_CHECK_DLFCN
-
-
-# _LT_AC_TRY_DLOPEN_SELF (ACTION-IF-TRUE, ACTION-IF-TRUE-W-USCORE,
-# ACTION-IF-FALSE, ACTION-IF-CROSS-COMPILING)
-# ---------------------------------------------------------------------
-AC_DEFUN([_LT_AC_TRY_DLOPEN_SELF],
-[AC_REQUIRE([_LT_AC_CHECK_DLFCN])dnl
-if test "$cross_compiling" = yes; then :
- [$4]
-else
- lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
- lt_status=$lt_dlunknown
- cat > conftest.$ac_ext <<EOF
-[#line __oline__ "configure"
-#include "confdefs.h"
-
-#if HAVE_DLFCN_H
-#include <dlfcn.h>
-#endif
-
-#include <stdio.h>
-
-#ifdef RTLD_GLOBAL
-# define LT_DLGLOBAL RTLD_GLOBAL
-#else
-# ifdef DL_GLOBAL
-# define LT_DLGLOBAL DL_GLOBAL
-# else
-# define LT_DLGLOBAL 0
-# endif
-#endif
-
-/* We may have to define LT_DLLAZY_OR_NOW in the command line if we
- find out it does not work in some platform. */
-#ifndef LT_DLLAZY_OR_NOW
-# ifdef RTLD_LAZY
-# define LT_DLLAZY_OR_NOW RTLD_LAZY
-# else
-# ifdef DL_LAZY
-# define LT_DLLAZY_OR_NOW DL_LAZY
-# else
-# ifdef RTLD_NOW
-# define LT_DLLAZY_OR_NOW RTLD_NOW
-# else
-# ifdef DL_NOW
-# define LT_DLLAZY_OR_NOW DL_NOW
-# else
-# define LT_DLLAZY_OR_NOW 0
-# endif
-# endif
-# endif
-# endif
-#endif
-
-#ifdef __cplusplus
-extern "C" void exit (int);
-#endif
-
-void fnord() { int i=42;}
-int main ()
-{
- void *self = dlopen (0, LT_DLGLOBAL|LT_DLLAZY_OR_NOW);
- int status = $lt_dlunknown;
-
- if (self)
- {
- if (dlsym (self,"fnord")) status = $lt_dlno_uscore;
- else if (dlsym( self,"_fnord")) status = $lt_dlneed_uscore;
- /* dlclose (self); */
- }
- else
- puts (dlerror ());
-
- exit (status);
-}]
-EOF
- if AC_TRY_EVAL(ac_link) && test -s conftest${ac_exeext} 2>/dev/null; then
- (./conftest; exit; ) >&AS_MESSAGE_LOG_FD 2>/dev/null
- lt_status=$?
- case x$lt_status in
- x$lt_dlno_uscore) $1 ;;
- x$lt_dlneed_uscore) $2 ;;
- x$lt_dlunknown|x*) $3 ;;
- esac
- else :
- # compilation failed
- $3
- fi
-fi
-rm -fr conftest*
-])# _LT_AC_TRY_DLOPEN_SELF
-
-
-# AC_LIBTOOL_DLOPEN_SELF
-# ----------------------
-AC_DEFUN([AC_LIBTOOL_DLOPEN_SELF],
-[AC_REQUIRE([_LT_AC_CHECK_DLFCN])dnl
-if test "x$enable_dlopen" != xyes; then
- enable_dlopen=unknown
- enable_dlopen_self=unknown
- enable_dlopen_self_static=unknown
-else
- lt_cv_dlopen=no
- lt_cv_dlopen_libs=
-
- case $host_os in
- beos*)
- lt_cv_dlopen="load_add_on"
- lt_cv_dlopen_libs=
- lt_cv_dlopen_self=yes
- ;;
-
- mingw* | pw32*)
- lt_cv_dlopen="LoadLibrary"
- lt_cv_dlopen_libs=
- ;;
-
- cygwin*)
- lt_cv_dlopen="dlopen"
- lt_cv_dlopen_libs=
- ;;
-
- darwin*)
- # if libdl is installed we need to link against it
- AC_CHECK_LIB([dl], [dlopen],
- [lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl"],[
- lt_cv_dlopen="dyld"
- lt_cv_dlopen_libs=
- lt_cv_dlopen_self=yes
- ])
- ;;
-
- *)
- AC_CHECK_FUNC([shl_load],
- [lt_cv_dlopen="shl_load"],
- [AC_CHECK_LIB([dld], [shl_load],
- [lt_cv_dlopen="shl_load" lt_cv_dlopen_libs="-dld"],
- [AC_CHECK_FUNC([dlopen],
- [lt_cv_dlopen="dlopen"],
- [AC_CHECK_LIB([dl], [dlopen],
- [lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl"],
- [AC_CHECK_LIB([svld], [dlopen],
- [lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-lsvld"],
- [AC_CHECK_LIB([dld], [dld_link],
- [lt_cv_dlopen="dld_link" lt_cv_dlopen_libs="-dld"])
- ])
- ])
- ])
- ])
- ])
- ;;
- esac
-
- if test "x$lt_cv_dlopen" != xno; then
- enable_dlopen=yes
- else
- enable_dlopen=no
- fi
-
- case $lt_cv_dlopen in
- dlopen)
- save_CPPFLAGS="$CPPFLAGS"
- test "x$ac_cv_header_dlfcn_h" = xyes && CPPFLAGS="$CPPFLAGS -DHAVE_DLFCN_H"
-
- save_LDFLAGS="$LDFLAGS"
- wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $export_dynamic_flag_spec\"
-
- save_LIBS="$LIBS"
- LIBS="$lt_cv_dlopen_libs $LIBS"
-
- AC_CACHE_CHECK([whether a program can dlopen itself],
- lt_cv_dlopen_self, [dnl
- _LT_AC_TRY_DLOPEN_SELF(
- lt_cv_dlopen_self=yes, lt_cv_dlopen_self=yes,
- lt_cv_dlopen_self=no, lt_cv_dlopen_self=cross)
- ])
-
- if test "x$lt_cv_dlopen_self" = xyes; then
- wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $lt_prog_compiler_static\"
- AC_CACHE_CHECK([whether a statically linked program can dlopen itself],
- lt_cv_dlopen_self_static, [dnl
- _LT_AC_TRY_DLOPEN_SELF(
- lt_cv_dlopen_self_static=yes, lt_cv_dlopen_self_static=yes,
- lt_cv_dlopen_self_static=no, lt_cv_dlopen_self_static=cross)
- ])
- fi
-
- CPPFLAGS="$save_CPPFLAGS"
- LDFLAGS="$save_LDFLAGS"
- LIBS="$save_LIBS"
- ;;
- esac
-
- case $lt_cv_dlopen_self in
- yes|no) enable_dlopen_self=$lt_cv_dlopen_self ;;
- *) enable_dlopen_self=unknown ;;
- esac
-
- case $lt_cv_dlopen_self_static in
- yes|no) enable_dlopen_self_static=$lt_cv_dlopen_self_static ;;
- *) enable_dlopen_self_static=unknown ;;
- esac
-fi
-])# AC_LIBTOOL_DLOPEN_SELF
-
-
-# AC_LIBTOOL_PROG_CC_C_O([TAGNAME])
-# ---------------------------------
-# Check to see if options -c and -o are simultaneously supported by compiler
-AC_DEFUN([AC_LIBTOOL_PROG_CC_C_O],
-[AC_REQUIRE([_LT_AC_SYS_COMPILER])dnl
-AC_CACHE_CHECK([if $compiler supports -c -o file.$ac_objext],
- [_LT_AC_TAGVAR(lt_cv_prog_compiler_c_o, $1)],
- [_LT_AC_TAGVAR(lt_cv_prog_compiler_c_o, $1)=no
- $rm -r conftest 2>/dev/null
- mkdir conftest
- cd conftest
- mkdir out
- printf "$lt_simple_compile_test_code" > conftest.$ac_ext
-
- lt_compiler_flag="-o out/conftest2.$ac_objext"
- # Insert the option either (1) after the last *FLAGS variable, or
- # (2) before a word containing "conftest.", or (3) at the end.
- # Note that $ac_compile itself does not contain backslashes and begins
- # with a dollar sign (not a hyphen), so the echo should work correctly.
- lt_compile=`echo "$ac_compile" | $SED \
- -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
- -e 's: [[^ ]]*conftest\.: $lt_compiler_flag&:; t' \
- -e 's:$: $lt_compiler_flag:'`
- (eval echo "\"\$as_me:__oline__: $lt_compile\"" >&AS_MESSAGE_LOG_FD)
- (eval "$lt_compile" 2>out/conftest.err)
- ac_status=$?
- cat out/conftest.err >&AS_MESSAGE_LOG_FD
- echo "$as_me:__oline__: \$? = $ac_status" >&AS_MESSAGE_LOG_FD
- if (exit $ac_status) && test -s out/conftest2.$ac_objext
- then
- # The compiler can only warn and ignore the option if not recognized
- # So say no if there are warnings
- $echo "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' > out/conftest.exp
- $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2
- if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then
- _LT_AC_TAGVAR(lt_cv_prog_compiler_c_o, $1)=yes
- fi
- fi
- chmod u+w . 2>&AS_MESSAGE_LOG_FD
- $rm conftest*
- # SGI C++ compiler will create directory out/ii_files/ for
- # template instantiation
- test -d out/ii_files && $rm out/ii_files/* && rmdir out/ii_files
- $rm out/* && rmdir out
- cd ..
- rmdir conftest
- $rm conftest*
-])
-])# AC_LIBTOOL_PROG_CC_C_O
-
-
-# AC_LIBTOOL_SYS_HARD_LINK_LOCKS([TAGNAME])
-# -----------------------------------------
-# Check to see if we can do hard links to lock some files if needed
-AC_DEFUN([AC_LIBTOOL_SYS_HARD_LINK_LOCKS],
-[AC_REQUIRE([_LT_AC_LOCK])dnl
-
-hard_links="nottested"
-if test "$_LT_AC_TAGVAR(lt_cv_prog_compiler_c_o, $1)" = no && test "$need_locks" != no; then
- # do not overwrite the value of need_locks provided by the user
- AC_MSG_CHECKING([if we can lock with hard links])
- hard_links=yes
- $rm conftest*
- ln conftest.a conftest.b 2>/dev/null && hard_links=no
- touch conftest.a
- ln conftest.a conftest.b 2>&5 || hard_links=no
- ln conftest.a conftest.b 2>/dev/null && hard_links=no
- AC_MSG_RESULT([$hard_links])
- if test "$hard_links" = no; then
- AC_MSG_WARN([`$CC' does not support `-c -o', so `make -j' may be unsafe])
- need_locks=warn
- fi
-else
- need_locks=no
-fi
-])# AC_LIBTOOL_SYS_HARD_LINK_LOCKS
-
-
-# AC_LIBTOOL_OBJDIR
-# -----------------
-AC_DEFUN([AC_LIBTOOL_OBJDIR],
-[AC_CACHE_CHECK([for objdir], [lt_cv_objdir],
-[rm -f .libs 2>/dev/null
-mkdir .libs 2>/dev/null
-if test -d .libs; then
- lt_cv_objdir=.libs
-else
- # MS-DOS does not allow filenames that begin with a dot.
- lt_cv_objdir=_libs
-fi
-rmdir .libs 2>/dev/null])
-objdir=$lt_cv_objdir
-])# AC_LIBTOOL_OBJDIR
-
-
-# AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH([TAGNAME])
-# ----------------------------------------------
-# Check hardcoding attributes.
-AC_DEFUN([AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH],
-[AC_MSG_CHECKING([how to hardcode library paths into programs])
-_LT_AC_TAGVAR(hardcode_action, $1)=
-if test -n "$_LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)" || \
- test -n "$_LT_AC_TAGVAR(runpath_var, $1)" || \
- test "X$_LT_AC_TAGVAR(hardcode_automatic, $1)" = "Xyes" ; then
-
- # We can hardcode non-existant directories.
- if test "$_LT_AC_TAGVAR(hardcode_direct, $1)" != no &&
- # If the only mechanism to avoid hardcoding is shlibpath_var, we
- # have to relink, otherwise we might link with an installed library
- # when we should be linking with a yet-to-be-installed one
- ## test "$_LT_AC_TAGVAR(hardcode_shlibpath_var, $1)" != no &&
- test "$_LT_AC_TAGVAR(hardcode_minus_L, $1)" != no; then
- # Linking always hardcodes the temporary library directory.
- _LT_AC_TAGVAR(hardcode_action, $1)=relink
- else
- # We can link without hardcoding, and we can hardcode nonexisting dirs.
- _LT_AC_TAGVAR(hardcode_action, $1)=immediate
- fi
-else
- # We cannot hardcode anything, or else we can only hardcode existing
- # directories.
- _LT_AC_TAGVAR(hardcode_action, $1)=unsupported
-fi
-AC_MSG_RESULT([$_LT_AC_TAGVAR(hardcode_action, $1)])
-
-if test "$_LT_AC_TAGVAR(hardcode_action, $1)" = relink; then
- # Fast installation is not supported
- enable_fast_install=no
-elif test "$shlibpath_overrides_runpath" = yes ||
- test "$enable_shared" = no; then
- # Fast installation is not necessary
- enable_fast_install=needless
-fi
-])# AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH
-
-
-# AC_LIBTOOL_SYS_LIB_STRIP
-# ------------------------
-AC_DEFUN([AC_LIBTOOL_SYS_LIB_STRIP],
-[striplib=
-old_striplib=
-AC_MSG_CHECKING([whether stripping libraries is possible])
-if test -n "$STRIP" && $STRIP -V 2>&1 | grep "GNU strip" >/dev/null; then
- test -z "$old_striplib" && old_striplib="$STRIP --strip-debug"
- test -z "$striplib" && striplib="$STRIP --strip-unneeded"
- AC_MSG_RESULT([yes])
-else
-# FIXME - insert some real tests, host_os isn't really good enough
- case $host_os in
- darwin*)
- if test -n "$STRIP" ; then
- striplib="$STRIP -x"
- AC_MSG_RESULT([yes])
- else
- AC_MSG_RESULT([no])
-fi
- ;;
- *)
- AC_MSG_RESULT([no])
- ;;
- esac
-fi
-])# AC_LIBTOOL_SYS_LIB_STRIP
-
-
-# AC_LIBTOOL_SYS_DYNAMIC_LINKER
-# -----------------------------
-# PORTME Fill in your ld.so characteristics
-AC_DEFUN([AC_LIBTOOL_SYS_DYNAMIC_LINKER],
-[AC_MSG_CHECKING([dynamic linker characteristics])
-library_names_spec=
-libname_spec='lib$name'
-soname_spec=
-shrext_cmds=".so"
-postinstall_cmds=
-postuninstall_cmds=
-finish_cmds=
-finish_eval=
-shlibpath_var=
-shlibpath_overrides_runpath=unknown
-version_type=none
-dynamic_linker="$host_os ld.so"
-sys_lib_dlsearch_path_spec="/lib /usr/lib"
-if test "$GCC" = yes; then
- sys_lib_search_path_spec=`$CC -print-search-dirs | grep "^libraries:" | $SED -e "s/^libraries://" -e "s,=/,/,g"`
- if echo "$sys_lib_search_path_spec" | grep ';' >/dev/null ; then
- # if the path contains ";" then we assume it to be the separator
- # otherwise default to the standard path separator (i.e. ":") - it is
- # assumed that no part of a normal pathname contains ";" but that should
- # okay in the real world where ";" in dirpaths is itself problematic.
- sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'`
- else
- sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"`
- fi
-else
- sys_lib_search_path_spec="/lib /usr/lib /usr/local/lib"
-fi
-need_lib_prefix=unknown
-hardcode_into_libs=no
-
-# when you set need_version to no, make sure it does not cause -set_version
-# flags to be left without arguments
-need_version=unknown
-
-case $host_os in
-aix3*)
- version_type=linux
- library_names_spec='${libname}${release}${shared_ext}$versuffix $libname.a'
- shlibpath_var=LIBPATH
-
- # AIX 3 has no versioning support, so we append a major version to the name.
- soname_spec='${libname}${release}${shared_ext}$major'
- ;;
-
-aix4* | aix5*)
- version_type=linux
- need_lib_prefix=no
- need_version=no
- hardcode_into_libs=yes
- if test "$host_cpu" = ia64; then
- # AIX 5 supports IA64
- library_names_spec='${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext}$versuffix $libname${shared_ext}'
- shlibpath_var=LD_LIBRARY_PATH
- else
- # With GCC up to 2.95.x, collect2 would create an import file
- # for dependence libraries. The import file would start with
- # the line `#! .'. This would cause the generated library to
- # depend on `.', always an invalid library. This was fixed in
- # development snapshots of GCC prior to 3.0.
- case $host_os in
- aix4 | aix4.[[01]] | aix4.[[01]].*)
- if { echo '#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 97)'
- echo ' yes '
- echo '#endif'; } | ${CC} -E - | grep yes > /dev/null; then
- :
- else
- can_build_shared=no
- fi
- ;;
- esac
- # AIX (on Power*) has no versioning support, so currently we can not hardcode correct
- # soname into executable. Probably we can add versioning support to
- # collect2, so additional links can be useful in future.
- if test "$aix_use_runtimelinking" = yes; then
- # If using run time linking (on AIX 4.2 or later) use lib<name>.so
- # instead of lib<name>.a to let people know that these are not
- # typical AIX shared libraries.
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
- else
- # We preserve .a as extension for shared libraries through AIX4.2
- # and later when we are not doing run time linking.
- library_names_spec='${libname}${release}.a $libname.a'
- soname_spec='${libname}${release}${shared_ext}$major'
- fi
- shlibpath_var=LIBPATH
- fi
- ;;
-
-amigaos*)
- library_names_spec='$libname.ixlibrary $libname.a'
- # Create ${libname}_ixlibrary.a entries in /sys/libs.
- finish_eval='for lib in `ls $libdir/*.ixlibrary 2>/dev/null`; do libname=`$echo "X$lib" | $Xsed -e '\''s%^.*/\([[^/]]*\)\.ixlibrary$%\1%'\''`; test $rm /sys/libs/${libname}_ixlibrary.a; $show "cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a"; cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a || exit 1; done'
- ;;
-
-beos*)
- library_names_spec='${libname}${shared_ext}'
- dynamic_linker="$host_os ld.so"
- shlibpath_var=LIBRARY_PATH
- ;;
-
-bsdi[[45]]*)
- version_type=linux
- need_version=no
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
- soname_spec='${libname}${release}${shared_ext}$major'
- finish_cmds='PATH="\$PATH:/sbin" ldconfig $libdir'
- shlibpath_var=LD_LIBRARY_PATH
- sys_lib_search_path_spec="/shlib /usr/lib /usr/X11/lib /usr/contrib/lib /lib /usr/local/lib"
- sys_lib_dlsearch_path_spec="/shlib /usr/lib /usr/local/lib"
- # the default ld.so.conf also contains /usr/contrib/lib and
- # /usr/X11R6/lib (/usr/X11 is a link to /usr/X11R6), but let us allow
- # libtool to hard-code these into programs
- ;;
-
-cygwin* | mingw* | pw32*)
- version_type=windows
- shrext_cmds=".dll"
- need_version=no
- need_lib_prefix=no
-
- case $GCC,$host_os in
- yes,cygwin* | yes,mingw* | yes,pw32*)
- library_names_spec='$libname.dll.a'
- # DLL is installed to $(libdir)/../bin by postinstall_cmds
- postinstall_cmds='base_file=`basename \${file}`~
- dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i;echo \$dlname'\''`~
- dldir=$destdir/`dirname \$dlpath`~
- test -d \$dldir || mkdir -p \$dldir~
- $install_prog $dir/$dlname \$dldir/$dlname~
- chmod a+x \$dldir/$dlname'
- postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~
- dlpath=$dir/\$dldll~
- $rm \$dlpath'
- shlibpath_overrides_runpath=yes
-
- case $host_os in
- cygwin*)
- # Cygwin DLLs use 'cyg' prefix rather than 'lib'
- soname_spec='`echo ${libname} | sed -e 's/^lib/cyg/'``echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}'
- sys_lib_search_path_spec="/usr/lib /lib/w32api /lib /usr/local/lib"
- ;;
- mingw*)
- # MinGW DLLs use traditional 'lib' prefix
- soname_spec='${libname}`echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}'
- sys_lib_search_path_spec=`$CC -print-search-dirs | grep "^libraries:" | $SED -e "s/^libraries://" -e "s,=/,/,g"`
- if echo "$sys_lib_search_path_spec" | [grep ';[c-zC-Z]:/' >/dev/null]; then
- # It is most probably a Windows format PATH printed by
- # mingw gcc, but we are running on Cygwin. Gcc prints its search
- # path with ; separators, and with drive letters. We can handle the
- # drive letters (cygwin fileutils understands them), so leave them,
- # especially as we might pass files found there to a mingw objdump,
- # which wouldn't understand a cygwinified path. Ahh.
- sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'`
- else
- sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"`
- fi
- ;;
- pw32*)
- # pw32 DLLs use 'pw' prefix rather than 'lib'
- library_names_spec='`echo ${libname} | sed -e 's/^lib/pw/'``echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}'
- ;;
- esac
- ;;
-
- *)
- library_names_spec='${libname}`echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext} $libname.lib'
- ;;
- esac
- dynamic_linker='Win32 ld.exe'
- # FIXME: first we should search . and the directory the executable is in
- shlibpath_var=PATH
- ;;
-
-darwin* | rhapsody*)
- dynamic_linker="$host_os dyld"
- version_type=darwin
- need_lib_prefix=no
- need_version=no
- library_names_spec='${libname}${release}${versuffix}$shared_ext ${libname}${release}${major}$shared_ext ${libname}$shared_ext'
- soname_spec='${libname}${release}${major}$shared_ext'
- shlibpath_overrides_runpath=yes
- shlibpath_var=DYLD_LIBRARY_PATH
- shrext_cmds='`test .$module = .yes && echo .so || echo .dylib`'
- # Apple's gcc prints 'gcc -print-search-dirs' doesn't operate the same.
- if test "$GCC" = yes; then
- sys_lib_search_path_spec=`$CC -print-search-dirs | tr "\n" "$PATH_SEPARATOR" | sed -e 's/libraries:/@libraries:/' | tr "@" "\n" | grep "^libraries:" | sed -e "s/^libraries://" -e "s,=/,/,g" -e "s,$PATH_SEPARATOR, ,g" -e "s,.*,& /lib /usr/lib /usr/local/lib,g"`
- else
- sys_lib_search_path_spec='/lib /usr/lib /usr/local/lib'
- fi
- sys_lib_dlsearch_path_spec='/usr/local/lib /lib /usr/lib'
- ;;
-
-dgux*)
- version_type=linux
- need_lib_prefix=no
- need_version=no
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname$shared_ext'
- soname_spec='${libname}${release}${shared_ext}$major'
- shlibpath_var=LD_LIBRARY_PATH
- ;;
-
-freebsd1*)
- dynamic_linker=no
- ;;
-
-kfreebsd*-gnu)
- version_type=linux
- need_lib_prefix=no
- need_version=no
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
- soname_spec='${libname}${release}${shared_ext}$major'
- shlibpath_var=LD_LIBRARY_PATH
- shlibpath_overrides_runpath=no
- hardcode_into_libs=yes
- dynamic_linker='GNU ld.so'
- ;;
-
-freebsd* | dragonfly*)
- # DragonFly does not have aout. When/if they implement a new
- # versioning mechanism, adjust this.
- if test -x /usr/bin/objformat; then
- objformat=`/usr/bin/objformat`
- else
- case $host_os in
- freebsd[[123]]*) objformat=aout ;;
- *) objformat=elf ;;
- esac
- fi
- version_type=freebsd-$objformat
- case $version_type in
- freebsd-elf*)
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}'
- need_version=no
- need_lib_prefix=no
- ;;
- freebsd-*)
- library_names_spec='${libname}${release}${shared_ext}$versuffix $libname${shared_ext}$versuffix'
- need_version=yes
- ;;
- esac
- shlibpath_var=LD_LIBRARY_PATH
- case $host_os in
- freebsd2*)
- shlibpath_overrides_runpath=yes
- ;;
- freebsd3.[[01]]* | freebsdelf3.[[01]]*)
- shlibpath_overrides_runpath=yes
- hardcode_into_libs=yes
- ;;
- freebsd3.[[2-9]]* | freebsdelf3.[[2-9]]* | \
- freebsd4.[[0-5]] | freebsdelf4.[[0-5]] | freebsd4.1.1 | freebsdelf4.1.1)
- shlibpath_overrides_runpath=no
- hardcode_into_libs=yes
- ;;
- freebsd*) # from 4.6 on
- shlibpath_overrides_runpath=yes
- hardcode_into_libs=yes
- ;;
- esac
- ;;
-
-gnu*)
- version_type=linux
- need_lib_prefix=no
- need_version=no
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}'
- soname_spec='${libname}${release}${shared_ext}$major'
- shlibpath_var=LD_LIBRARY_PATH
- hardcode_into_libs=yes
- ;;
-
-hpux9* | hpux10* | hpux11*)
- # Give a soname corresponding to the major version so that dld.sl refuses to
- # link against other versions.
- version_type=sunos
- need_lib_prefix=no
- need_version=no
- case $host_cpu in
- ia64*)
- shrext_cmds='.so'
- hardcode_into_libs=yes
- dynamic_linker="$host_os dld.so"
- shlibpath_var=LD_LIBRARY_PATH
- shlibpath_overrides_runpath=yes # Unless +noenvvar is specified.
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
- soname_spec='${libname}${release}${shared_ext}$major'
- if test "X$HPUX_IA64_MODE" = X32; then
- sys_lib_search_path_spec="/usr/lib/hpux32 /usr/local/lib/hpux32 /usr/local/lib"
- else
- sys_lib_search_path_spec="/usr/lib/hpux64 /usr/local/lib/hpux64"
- fi
- sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec
- ;;
- hppa*64*)
- shrext_cmds='.sl'
- hardcode_into_libs=yes
- dynamic_linker="$host_os dld.sl"
- shlibpath_var=LD_LIBRARY_PATH # How should we handle SHLIB_PATH
- shlibpath_overrides_runpath=yes # Unless +noenvvar is specified.
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
- soname_spec='${libname}${release}${shared_ext}$major'
- sys_lib_search_path_spec="/usr/lib/pa20_64 /usr/ccs/lib/pa20_64"
- sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec
- ;;
- *)
- shrext_cmds='.sl'
- dynamic_linker="$host_os dld.sl"
- shlibpath_var=SHLIB_PATH
- shlibpath_overrides_runpath=no # +s is required to enable SHLIB_PATH
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
- soname_spec='${libname}${release}${shared_ext}$major'
- ;;
- esac
- # HP-UX runs *really* slowly unless shared libraries are mode 555.
- postinstall_cmds='chmod 555 $lib'
- ;;
-
-interix3*)
- version_type=linux
- need_lib_prefix=no
- need_version=no
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
- soname_spec='${libname}${release}${shared_ext}$major'
- dynamic_linker='Interix 3.x ld.so.1 (PE, like ELF)'
- shlibpath_var=LD_LIBRARY_PATH
- shlibpath_overrides_runpath=no
- hardcode_into_libs=yes
- ;;
-
-irix5* | irix6* | nonstopux*)
- case $host_os in
- nonstopux*) version_type=nonstopux ;;
- *)
- if test "$lt_cv_prog_gnu_ld" = yes; then
- version_type=linux
- else
- version_type=irix
- fi ;;
- esac
- need_lib_prefix=no
- need_version=no
- soname_spec='${libname}${release}${shared_ext}$major'
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext} $libname${shared_ext}'
- case $host_os in
- irix5* | nonstopux*)
- libsuff= shlibsuff=
- ;;
- *)
- case $LD in # libtool.m4 will add one of these switches to LD
- *-32|*"-32 "|*-melf32bsmip|*"-melf32bsmip ")
- libsuff= shlibsuff= libmagic=32-bit;;
- *-n32|*"-n32 "|*-melf32bmipn32|*"-melf32bmipn32 ")
- libsuff=32 shlibsuff=N32 libmagic=N32;;
- *-64|*"-64 "|*-melf64bmip|*"-melf64bmip ")
- libsuff=64 shlibsuff=64 libmagic=64-bit;;
- *) libsuff= shlibsuff= libmagic=never-match;;
- esac
- ;;
- esac
- shlibpath_var=LD_LIBRARY${shlibsuff}_PATH
- shlibpath_overrides_runpath=no
- sys_lib_search_path_spec="/usr/lib${libsuff} /lib${libsuff} /usr/local/lib${libsuff}"
- sys_lib_dlsearch_path_spec="/usr/lib${libsuff} /lib${libsuff}"
- hardcode_into_libs=yes
- ;;
-
-# No shared lib support for Linux oldld, aout, or coff.
-linux*oldld* | linux*aout* | linux*coff*)
- dynamic_linker=no
- ;;
-
-# This must be Linux ELF.
-linux*)
- version_type=linux
- need_lib_prefix=no
- need_version=no
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
- soname_spec='${libname}${release}${shared_ext}$major'
- finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir'
- shlibpath_var=LD_LIBRARY_PATH
- shlibpath_overrides_runpath=no
- # This implies no fast_install, which is unacceptable.
- # Some rework will be needed to allow for fast_install
- # before this can be enabled.
- hardcode_into_libs=yes
-
- # Append ld.so.conf contents to the search path
- if test -f /etc/ld.so.conf; then
- lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s", \[$]2)); skip = 1; } { if (!skip) print \[$]0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;s/[:, ]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;/^$/d' | tr '\n' ' '`
- sys_lib_dlsearch_path_spec="/lib /usr/lib $lt_ld_extra"
- fi
-
- # We used to test for /lib/ld.so.1 and disable shared libraries on
- # powerpc, because MkLinux only supported shared libraries with the
- # GNU dynamic linker. Since this was broken with cross compilers,
- # most powerpc-linux boxes support dynamic linking these days and
- # people can always --disable-shared, the test was removed, and we
- # assume the GNU/Linux dynamic linker is in use.
- dynamic_linker='GNU/Linux ld.so'
- ;;
-
-netbsdelf*-gnu)
- version_type=linux
- need_lib_prefix=no
- need_version=no
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
- soname_spec='${libname}${release}${shared_ext}$major'
- shlibpath_var=LD_LIBRARY_PATH
- shlibpath_overrides_runpath=no
- hardcode_into_libs=yes
- dynamic_linker='NetBSD ld.elf_so'
- ;;
-
-knetbsd*-gnu)
- version_type=linux
- need_lib_prefix=no
- need_version=no
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
- soname_spec='${libname}${release}${shared_ext}$major'
- shlibpath_var=LD_LIBRARY_PATH
- shlibpath_overrides_runpath=no
- hardcode_into_libs=yes
- dynamic_linker='GNU ld.so'
- ;;
-
-netbsd*)
- version_type=sunos
- need_lib_prefix=no
- need_version=no
- if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
- finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir'
- dynamic_linker='NetBSD (a.out) ld.so'
- else
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
- soname_spec='${libname}${release}${shared_ext}$major'
- dynamic_linker='NetBSD ld.elf_so'
- fi
- shlibpath_var=LD_LIBRARY_PATH
- shlibpath_overrides_runpath=yes
- hardcode_into_libs=yes
- ;;
-
-newsos6)
- version_type=linux
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
- shlibpath_var=LD_LIBRARY_PATH
- shlibpath_overrides_runpath=yes
- ;;
-
-nto-qnx*)
- version_type=linux
- need_lib_prefix=no
- need_version=no
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
- soname_spec='${libname}${release}${shared_ext}$major'
- shlibpath_var=LD_LIBRARY_PATH
- shlibpath_overrides_runpath=yes
- ;;
-
-openbsd*)
- version_type=sunos
- sys_lib_dlsearch_path_spec="/usr/lib"
- need_lib_prefix=no
- # Some older versions of OpenBSD (3.3 at least) *do* need versioned libs.
- case $host_os in
- openbsd3.3 | openbsd3.3.*) need_version=yes ;;
- *) need_version=no ;;
- esac
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
- finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir'
- shlibpath_var=LD_LIBRARY_PATH
- if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
- case $host_os in
- openbsd2.[[89]] | openbsd2.[[89]].*)
- shlibpath_overrides_runpath=no
- ;;
- *)
- shlibpath_overrides_runpath=yes
- ;;
- esac
- else
- shlibpath_overrides_runpath=yes
- fi
- ;;
-
-os2*)
- libname_spec='$name'
- shrext_cmds=".dll"
- need_lib_prefix=no
- library_names_spec='$libname${shared_ext} $libname.a'
- dynamic_linker='OS/2 ld.exe'
- shlibpath_var=LIBPATH
- ;;
-
-osf3* | osf4* | osf5*)
- version_type=osf
- need_lib_prefix=no
- need_version=no
- soname_spec='${libname}${release}${shared_ext}$major'
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
- shlibpath_var=LD_LIBRARY_PATH
- sys_lib_search_path_spec="/usr/shlib /usr/ccs/lib /usr/lib/cmplrs/cc /usr/lib /usr/local/lib /var/shlib"
- sys_lib_dlsearch_path_spec="$sys_lib_search_path_spec"
- ;;
-
-solaris*)
- version_type=linux
- need_lib_prefix=no
- need_version=no
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
- soname_spec='${libname}${release}${shared_ext}$major'
- shlibpath_var=LD_LIBRARY_PATH
- shlibpath_overrides_runpath=yes
- hardcode_into_libs=yes
- # ldd complains unless libraries are executable
- postinstall_cmds='chmod +x $lib'
- ;;
-
-sunos4*)
- version_type=sunos
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
- finish_cmds='PATH="\$PATH:/usr/etc" ldconfig $libdir'
- shlibpath_var=LD_LIBRARY_PATH
- shlibpath_overrides_runpath=yes
- if test "$with_gnu_ld" = yes; then
- need_lib_prefix=no
- fi
- need_version=yes
- ;;
-
-sysv4 | sysv4.3*)
- version_type=linux
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
- soname_spec='${libname}${release}${shared_ext}$major'
- shlibpath_var=LD_LIBRARY_PATH
- case $host_vendor in
- sni)
- shlibpath_overrides_runpath=no
- need_lib_prefix=no
- export_dynamic_flag_spec='${wl}-Blargedynsym'
- runpath_var=LD_RUN_PATH
- ;;
- siemens)
- need_lib_prefix=no
- ;;
- motorola)
- need_lib_prefix=no
- need_version=no
- shlibpath_overrides_runpath=no
- sys_lib_search_path_spec='/lib /usr/lib /usr/ccs/lib'
- ;;
- esac
- ;;
-
-sysv4*MP*)
- if test -d /usr/nec ;then
- version_type=linux
- library_names_spec='$libname${shared_ext}.$versuffix $libname${shared_ext}.$major $libname${shared_ext}'
- soname_spec='$libname${shared_ext}.$major'
- shlibpath_var=LD_LIBRARY_PATH
- fi
- ;;
-
-sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*)
- version_type=freebsd-elf
- need_lib_prefix=no
- need_version=no
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}'
- soname_spec='${libname}${release}${shared_ext}$major'
- shlibpath_var=LD_LIBRARY_PATH
- hardcode_into_libs=yes
- if test "$with_gnu_ld" = yes; then
- sys_lib_search_path_spec='/usr/local/lib /usr/gnu/lib /usr/ccs/lib /usr/lib /lib'
- shlibpath_overrides_runpath=no
- else
- sys_lib_search_path_spec='/usr/ccs/lib /usr/lib'
- shlibpath_overrides_runpath=yes
- case $host_os in
- sco3.2v5*)
- sys_lib_search_path_spec="$sys_lib_search_path_spec /lib"
- ;;
- esac
- fi
- sys_lib_dlsearch_path_spec='/usr/lib'
- ;;
-
-uts4*)
- version_type=linux
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
- soname_spec='${libname}${release}${shared_ext}$major'
- shlibpath_var=LD_LIBRARY_PATH
- ;;
-
-*)
- dynamic_linker=no
- ;;
-esac
-AC_MSG_RESULT([$dynamic_linker])
-test "$dynamic_linker" = no && can_build_shared=no
-
-variables_saved_for_relink="PATH $shlibpath_var $runpath_var"
-if test "$GCC" = yes; then
- variables_saved_for_relink="$variables_saved_for_relink GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH"
-fi
-])# AC_LIBTOOL_SYS_DYNAMIC_LINKER
-
-
-# _LT_AC_TAGCONFIG
-# ----------------
-AC_DEFUN([_LT_AC_TAGCONFIG],
-[AC_ARG_WITH([tags],
- [AC_HELP_STRING([--with-tags@<:@=TAGS@:>@],
- [include additional configurations @<:@automatic@:>@])],
- [tagnames="$withval"])
-
-if test -f "$ltmain" && test -n "$tagnames"; then
- if test ! -f "${ofile}"; then
- AC_MSG_WARN([output file `$ofile' does not exist])
- fi
-
- if test -z "$LTCC"; then
- eval "`$SHELL ${ofile} --config | grep '^LTCC='`"
- if test -z "$LTCC"; then
- AC_MSG_WARN([output file `$ofile' does not look like a libtool script])
- else
- AC_MSG_WARN([using `LTCC=$LTCC', extracted from `$ofile'])
- fi
- fi
- if test -z "$LTCFLAGS"; then
- eval "`$SHELL ${ofile} --config | grep '^LTCFLAGS='`"
- fi
-
- # Extract list of available tagged configurations in $ofile.
- # Note that this assumes the entire list is on one line.
- available_tags=`grep "^available_tags=" "${ofile}" | $SED -e 's/available_tags=\(.*$\)/\1/' -e 's/\"//g'`
-
- lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR,"
- for tagname in $tagnames; do
- IFS="$lt_save_ifs"
- # Check whether tagname contains only valid characters
- case `$echo "X$tagname" | $Xsed -e 's:[[-_ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890,/]]::g'` in
- "") ;;
- *) AC_MSG_ERROR([invalid tag name: $tagname])
- ;;
- esac
-
- if grep "^# ### BEGIN LIBTOOL TAG CONFIG: $tagname$" < "${ofile}" > /dev/null
- then
- AC_MSG_ERROR([tag name \"$tagname\" already exists])
- fi
-
- # Update the list of available tags.
- if test -n "$tagname"; then
- echo appending configuration tag \"$tagname\" to $ofile
-
- case $tagname in
- CXX)
- if test -n "$CXX" && ( test "X$CXX" != "Xno" &&
- ( (test "X$CXX" = "Xg++" && `g++ -v >/dev/null 2>&1` ) ||
- (test "X$CXX" != "Xg++"))) ; then
- AC_LIBTOOL_LANG_CXX_CONFIG
- else
- tagname=""
- fi
- ;;
-
- F77)
- if test -n "$F77" && test "X$F77" != "Xno"; then
- AC_LIBTOOL_LANG_F77_CONFIG
- else
- tagname=""
- fi
- ;;
-
- GCJ)
- if test -n "$GCJ" && test "X$GCJ" != "Xno"; then
- AC_LIBTOOL_LANG_GCJ_CONFIG
- else
- tagname=""
- fi
- ;;
-
- RC)
- AC_LIBTOOL_LANG_RC_CONFIG
- ;;
-
- *)
- AC_MSG_ERROR([Unsupported tag name: $tagname])
- ;;
- esac
-
- # Append the new tag name to the list of available tags.
- if test -n "$tagname" ; then
- available_tags="$available_tags $tagname"
- fi
- fi
- done
- IFS="$lt_save_ifs"
-
- # Now substitute the updated list of available tags.
- if eval "sed -e 's/^available_tags=.*\$/available_tags=\"$available_tags\"/' \"$ofile\" > \"${ofile}T\""; then
- mv "${ofile}T" "$ofile"
- chmod +x "$ofile"
- else
- rm -f "${ofile}T"
- AC_MSG_ERROR([unable to update list of available tagged configurations.])
- fi
-fi
-])# _LT_AC_TAGCONFIG
-
-
-# AC_LIBTOOL_DLOPEN
-# -----------------
-# enable checks for dlopen support
-AC_DEFUN([AC_LIBTOOL_DLOPEN],
- [AC_BEFORE([$0],[AC_LIBTOOL_SETUP])
-])# AC_LIBTOOL_DLOPEN
-
-
-# AC_LIBTOOL_WIN32_DLL
-# --------------------
-# declare package support for building win32 DLLs
-AC_DEFUN([AC_LIBTOOL_WIN32_DLL],
-[AC_BEFORE([$0], [AC_LIBTOOL_SETUP])
-])# AC_LIBTOOL_WIN32_DLL
-
-
-# AC_ENABLE_SHARED([DEFAULT])
-# ---------------------------
-# implement the --enable-shared flag
-# DEFAULT is either `yes' or `no'. If omitted, it defaults to `yes'.
-AC_DEFUN([AC_ENABLE_SHARED],
-[define([AC_ENABLE_SHARED_DEFAULT], ifelse($1, no, no, yes))dnl
-AC_ARG_ENABLE([shared],
- [AC_HELP_STRING([--enable-shared@<:@=PKGS@:>@],
- [build shared libraries @<:@default=]AC_ENABLE_SHARED_DEFAULT[@:>@])],
- [p=${PACKAGE-default}
- case $enableval in
- yes) enable_shared=yes ;;
- no) enable_shared=no ;;
- *)
- enable_shared=no
- # Look at the argument we got. We use all the common list separators.
- lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR,"
- for pkg in $enableval; do
- IFS="$lt_save_ifs"
- if test "X$pkg" = "X$p"; then
- enable_shared=yes
- fi
- done
- IFS="$lt_save_ifs"
- ;;
- esac],
- [enable_shared=]AC_ENABLE_SHARED_DEFAULT)
-])# AC_ENABLE_SHARED
-
-
-# AC_DISABLE_SHARED
-# -----------------
-# set the default shared flag to --disable-shared
-AC_DEFUN([AC_DISABLE_SHARED],
-[AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl
-AC_ENABLE_SHARED(no)
-])# AC_DISABLE_SHARED
-
-
-# AC_ENABLE_STATIC([DEFAULT])
-# ---------------------------
-# implement the --enable-static flag
-# DEFAULT is either `yes' or `no'. If omitted, it defaults to `yes'.
-AC_DEFUN([AC_ENABLE_STATIC],
-[define([AC_ENABLE_STATIC_DEFAULT], ifelse($1, no, no, yes))dnl
-AC_ARG_ENABLE([static],
- [AC_HELP_STRING([--enable-static@<:@=PKGS@:>@],
- [build static libraries @<:@default=]AC_ENABLE_STATIC_DEFAULT[@:>@])],
- [p=${PACKAGE-default}
- case $enableval in
- yes) enable_static=yes ;;
- no) enable_static=no ;;
- *)
- enable_static=no
- # Look at the argument we got. We use all the common list separators.
- lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR,"
- for pkg in $enableval; do
- IFS="$lt_save_ifs"
- if test "X$pkg" = "X$p"; then
- enable_static=yes
- fi
- done
- IFS="$lt_save_ifs"
- ;;
- esac],
- [enable_static=]AC_ENABLE_STATIC_DEFAULT)
-])# AC_ENABLE_STATIC
-
-
-# AC_DISABLE_STATIC
-# -----------------
-# set the default static flag to --disable-static
-AC_DEFUN([AC_DISABLE_STATIC],
-[AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl
-AC_ENABLE_STATIC(no)
-])# AC_DISABLE_STATIC
-
-
-# AC_ENABLE_FAST_INSTALL([DEFAULT])
-# ---------------------------------
-# implement the --enable-fast-install flag
-# DEFAULT is either `yes' or `no'. If omitted, it defaults to `yes'.
-AC_DEFUN([AC_ENABLE_FAST_INSTALL],
-[define([AC_ENABLE_FAST_INSTALL_DEFAULT], ifelse($1, no, no, yes))dnl
-AC_ARG_ENABLE([fast-install],
- [AC_HELP_STRING([--enable-fast-install@<:@=PKGS@:>@],
- [optimize for fast installation @<:@default=]AC_ENABLE_FAST_INSTALL_DEFAULT[@:>@])],
- [p=${PACKAGE-default}
- case $enableval in
- yes) enable_fast_install=yes ;;
- no) enable_fast_install=no ;;
- *)
- enable_fast_install=no
- # Look at the argument we got. We use all the common list separators.
- lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR,"
- for pkg in $enableval; do
- IFS="$lt_save_ifs"
- if test "X$pkg" = "X$p"; then
- enable_fast_install=yes
- fi
- done
- IFS="$lt_save_ifs"
- ;;
- esac],
- [enable_fast_install=]AC_ENABLE_FAST_INSTALL_DEFAULT)
-])# AC_ENABLE_FAST_INSTALL
-
-
-# AC_DISABLE_FAST_INSTALL
-# -----------------------
-# set the default to --disable-fast-install
-AC_DEFUN([AC_DISABLE_FAST_INSTALL],
-[AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl
-AC_ENABLE_FAST_INSTALL(no)
-])# AC_DISABLE_FAST_INSTALL
-
-
-# AC_LIBTOOL_PICMODE([MODE])
-# --------------------------
-# implement the --with-pic flag
-# MODE is either `yes' or `no'. If omitted, it defaults to `both'.
-AC_DEFUN([AC_LIBTOOL_PICMODE],
-[AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl
-pic_mode=ifelse($#,1,$1,default)
-])# AC_LIBTOOL_PICMODE
-
-
-# AC_PROG_EGREP
-# -------------
-# This is predefined starting with Autoconf 2.54, so this conditional
-# definition can be removed once we require Autoconf 2.54 or later.
-m4_ifndef([AC_PROG_EGREP], [AC_DEFUN([AC_PROG_EGREP],
-[AC_CACHE_CHECK([for egrep], [ac_cv_prog_egrep],
- [if echo a | (grep -E '(a|b)') >/dev/null 2>&1
- then ac_cv_prog_egrep='grep -E'
- else ac_cv_prog_egrep='egrep'
- fi])
- EGREP=$ac_cv_prog_egrep
- AC_SUBST([EGREP])
-])])
-
-
-# AC_PATH_TOOL_PREFIX
-# -------------------
-# find a file program which can recognise shared library
-AC_DEFUN([AC_PATH_TOOL_PREFIX],
-[AC_REQUIRE([AC_PROG_EGREP])dnl
-AC_MSG_CHECKING([for $1])
-AC_CACHE_VAL(lt_cv_path_MAGIC_CMD,
-[case $MAGIC_CMD in
-[[\\/*] | ?:[\\/]*])
- lt_cv_path_MAGIC_CMD="$MAGIC_CMD" # Let the user override the test with a path.
- ;;
-*)
- lt_save_MAGIC_CMD="$MAGIC_CMD"
- lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
-dnl $ac_dummy forces splitting on constant user-supplied paths.
-dnl POSIX.2 word splitting is done only on the output of word expansions,
-dnl not every word. This closes a longstanding sh security hole.
- ac_dummy="ifelse([$2], , $PATH, [$2])"
- for ac_dir in $ac_dummy; do
- IFS="$lt_save_ifs"
- test -z "$ac_dir" && ac_dir=.
- if test -f $ac_dir/$1; then
- lt_cv_path_MAGIC_CMD="$ac_dir/$1"
- if test -n "$file_magic_test_file"; then
- case $deplibs_check_method in
- "file_magic "*)
- file_magic_regex=`expr "$deplibs_check_method" : "file_magic \(.*\)"`
- MAGIC_CMD="$lt_cv_path_MAGIC_CMD"
- if eval $file_magic_cmd \$file_magic_test_file 2> /dev/null |
- $EGREP "$file_magic_regex" > /dev/null; then
- :
- else
- cat <<EOF 1>&2
-
-*** Warning: the command libtool uses to detect shared libraries,
-*** $file_magic_cmd, produces output that libtool cannot recognize.
-*** The result is that libtool may fail to recognize shared libraries
-*** as such. This will affect the creation of libtool libraries that
-*** depend on shared libraries, but programs linked with such libtool
-*** libraries will work regardless of this problem. Nevertheless, you
-*** may want to report the problem to your system manager and/or to
-*** bug-libtool@gnu.org
-
-EOF
- fi ;;
- esac
- fi
- break
- fi
- done
- IFS="$lt_save_ifs"
- MAGIC_CMD="$lt_save_MAGIC_CMD"
- ;;
-esac])
-MAGIC_CMD="$lt_cv_path_MAGIC_CMD"
-if test -n "$MAGIC_CMD"; then
- AC_MSG_RESULT($MAGIC_CMD)
-else
- AC_MSG_RESULT(no)
-fi
-])# AC_PATH_TOOL_PREFIX
-
-
-# AC_PATH_MAGIC
-# -------------
-# find a file program which can recognise a shared library
-AC_DEFUN([AC_PATH_MAGIC],
-[AC_PATH_TOOL_PREFIX(${ac_tool_prefix}file, /usr/bin$PATH_SEPARATOR$PATH)
-if test -z "$lt_cv_path_MAGIC_CMD"; then
- if test -n "$ac_tool_prefix"; then
- AC_PATH_TOOL_PREFIX(file, /usr/bin$PATH_SEPARATOR$PATH)
- else
- MAGIC_CMD=:
- fi
-fi
-])# AC_PATH_MAGIC
-
-
-# AC_PROG_LD
-# ----------
-# find the pathname to the GNU or non-GNU linker
-AC_DEFUN([AC_PROG_LD],
-[AC_ARG_WITH([gnu-ld],
- [AC_HELP_STRING([--with-gnu-ld],
- [assume the C compiler uses GNU ld @<:@default=no@:>@])],
- [test "$withval" = no || with_gnu_ld=yes],
- [with_gnu_ld=no])
-AC_REQUIRE([LT_AC_PROG_SED])dnl
-AC_REQUIRE([AC_PROG_CC])dnl
-AC_REQUIRE([AC_CANONICAL_HOST])dnl
-AC_REQUIRE([AC_CANONICAL_BUILD])dnl
-ac_prog=ld
-if test "$GCC" = yes; then
- # Check if gcc -print-prog-name=ld gives a path.
- AC_MSG_CHECKING([for ld used by $CC])
- case $host in
- *-*-mingw*)
- # gcc leaves a trailing carriage return which upsets mingw
- ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;;
- *)
- ac_prog=`($CC -print-prog-name=ld) 2>&5` ;;
- esac
- case $ac_prog in
- # Accept absolute paths.
- [[\\/]]* | ?:[[\\/]]*)
- re_direlt='/[[^/]][[^/]]*/\.\./'
- # Canonicalize the pathname of ld
- ac_prog=`echo $ac_prog| $SED 's%\\\\%/%g'`
- while echo $ac_prog | grep "$re_direlt" > /dev/null 2>&1; do
- ac_prog=`echo $ac_prog| $SED "s%$re_direlt%/%"`
- done
- test -z "$LD" && LD="$ac_prog"
- ;;
- "")
- # If it fails, then pretend we aren't using GCC.
- ac_prog=ld
- ;;
- *)
- # If it is relative, then search for the first ld in PATH.
- with_gnu_ld=unknown
- ;;
- esac
-elif test "$with_gnu_ld" = yes; then
- AC_MSG_CHECKING([for GNU ld])
-else
- AC_MSG_CHECKING([for non-GNU ld])
-fi
-AC_CACHE_VAL(lt_cv_path_LD,
-[if test -z "$LD"; then
- lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
- for ac_dir in $PATH; do
- IFS="$lt_save_ifs"
- test -z "$ac_dir" && ac_dir=.
- if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then
- lt_cv_path_LD="$ac_dir/$ac_prog"
- # Check to see if the program is GNU ld. I'd rather use --version,
- # but apparently some variants of GNU ld only accept -v.
- # Break only if it was the GNU/non-GNU ld that we prefer.
- case `"$lt_cv_path_LD" -v 2>&1 </dev/null` in
- *GNU* | *'with BFD'*)
- test "$with_gnu_ld" != no && break
- ;;
- *)
- test "$with_gnu_ld" != yes && break
- ;;
- esac
- fi
- done
- IFS="$lt_save_ifs"
-else
- lt_cv_path_LD="$LD" # Let the user override the test with a path.
-fi])
-LD="$lt_cv_path_LD"
-if test -n "$LD"; then
- AC_MSG_RESULT($LD)
-else
- AC_MSG_RESULT(no)
-fi
-test -z "$LD" && AC_MSG_ERROR([no acceptable ld found in \$PATH])
-AC_PROG_LD_GNU
-])# AC_PROG_LD
-
-
-# AC_PROG_LD_GNU
-# --------------
-AC_DEFUN([AC_PROG_LD_GNU],
-[AC_REQUIRE([AC_PROG_EGREP])dnl
-AC_CACHE_CHECK([if the linker ($LD) is GNU ld], lt_cv_prog_gnu_ld,
-[# I'd rather use --version here, but apparently some GNU lds only accept -v.
-case `$LD -v 2>&1 </dev/null` in
-*GNU* | *'with BFD'*)
- lt_cv_prog_gnu_ld=yes
- ;;
-*)
- lt_cv_prog_gnu_ld=no
- ;;
-esac])
-with_gnu_ld=$lt_cv_prog_gnu_ld
-])# AC_PROG_LD_GNU
-
-
-# AC_PROG_LD_RELOAD_FLAG
-# ----------------------
-# find reload flag for linker
-# -- PORTME Some linkers may need a different reload flag.
-AC_DEFUN([AC_PROG_LD_RELOAD_FLAG],
-[AC_CACHE_CHECK([for $LD option to reload object files],
- lt_cv_ld_reload_flag,
- [lt_cv_ld_reload_flag='-r'])
-reload_flag=$lt_cv_ld_reload_flag
-case $reload_flag in
-"" | " "*) ;;
-*) reload_flag=" $reload_flag" ;;
-esac
-reload_cmds='$LD$reload_flag -o $output$reload_objs'
-case $host_os in
- darwin*)
- if test "$GCC" = yes; then
- reload_cmds='$LTCC $LTCFLAGS -nostdlib ${wl}-r -o $output$reload_objs'
- else
- reload_cmds='$LD$reload_flag -o $output$reload_objs'
- fi
- ;;
-esac
-])# AC_PROG_LD_RELOAD_FLAG
-
-
-# AC_DEPLIBS_CHECK_METHOD
-# -----------------------
-# how to check for library dependencies
-# -- PORTME fill in with the dynamic library characteristics
-AC_DEFUN([AC_DEPLIBS_CHECK_METHOD],
-[AC_CACHE_CHECK([how to recognise dependent libraries],
-lt_cv_deplibs_check_method,
-[lt_cv_file_magic_cmd='$MAGIC_CMD'
-lt_cv_file_magic_test_file=
-lt_cv_deplibs_check_method='unknown'
-# Need to set the preceding variable on all platforms that support
-# interlibrary dependencies.
-# 'none' -- dependencies not supported.
-# `unknown' -- same as none, but documents that we really don't know.
-# 'pass_all' -- all dependencies passed with no checks.
-# 'test_compile' -- check by making test program.
-# 'file_magic [[regex]]' -- check by looking for files in library path
-# which responds to the $file_magic_cmd with a given extended regex.
-# If you have `file' or equivalent on your system and you're not sure
-# whether `pass_all' will *always* work, you probably want this one.
-
-case $host_os in
-aix4* | aix5*)
- lt_cv_deplibs_check_method=pass_all
- ;;
-
-beos*)
- lt_cv_deplibs_check_method=pass_all
- ;;
-
-bsdi[[45]]*)
- lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[ML]]SB (shared object|dynamic lib)'
- lt_cv_file_magic_cmd='/usr/bin/file -L'
- lt_cv_file_magic_test_file=/shlib/libc.so
- ;;
-
-cygwin*)
- # func_win32_libid is a shell function defined in ltmain.sh
- lt_cv_deplibs_check_method='file_magic ^x86 archive import|^x86 DLL'
- lt_cv_file_magic_cmd='func_win32_libid'
- ;;
-
-mingw* | pw32*)
- # Base MSYS/MinGW do not provide the 'file' command needed by
- # func_win32_libid shell function, so use a weaker test based on 'objdump'.
- lt_cv_deplibs_check_method='file_magic file format pei*-i386(.*architecture: i386)?'
- lt_cv_file_magic_cmd='$OBJDUMP -f'
- ;;
-
-darwin* | rhapsody*)
- lt_cv_deplibs_check_method=pass_all
- ;;
-
-freebsd* | kfreebsd*-gnu | dragonfly*)
- if echo __ELF__ | $CC -E - | grep __ELF__ > /dev/null; then
- case $host_cpu in
- i*86 )
- # Not sure whether the presence of OpenBSD here was a mistake.
- # Let's accept both of them until this is cleared up.
- lt_cv_deplibs_check_method='file_magic (FreeBSD|OpenBSD|DragonFly)/i[[3-9]]86 (compact )?demand paged shared library'
- lt_cv_file_magic_cmd=/usr/bin/file
- lt_cv_file_magic_test_file=`echo /usr/lib/libc.so.*`
- ;;
- esac
- else
- lt_cv_deplibs_check_method=pass_all
- fi
- ;;
-
-gnu*)
- lt_cv_deplibs_check_method=pass_all
- ;;
-
-hpux10.20* | hpux11*)
- lt_cv_file_magic_cmd=/usr/bin/file
- case $host_cpu in
- ia64*)
- lt_cv_deplibs_check_method='file_magic (s[[0-9]][[0-9]][[0-9]]|ELF-[[0-9]][[0-9]]) shared object file - IA64'
- lt_cv_file_magic_test_file=/usr/lib/hpux32/libc.so
- ;;
- hppa*64*)
- [lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|ELF-[0-9][0-9]) shared object file - PA-RISC [0-9].[0-9]']
- lt_cv_file_magic_test_file=/usr/lib/pa20_64/libc.sl
- ;;
- *)
- lt_cv_deplibs_check_method='file_magic (s[[0-9]][[0-9]][[0-9]]|PA-RISC[[0-9]].[[0-9]]) shared library'
- lt_cv_file_magic_test_file=/usr/lib/libc.sl
- ;;
- esac
- ;;
-
-interix3*)
- # PIC code is broken on Interix 3.x, that's why |\.a not |_pic\.a here
- lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so|\.a)$'
- ;;
-
-irix5* | irix6* | nonstopux*)
- case $LD in
- *-32|*"-32 ") libmagic=32-bit;;
- *-n32|*"-n32 ") libmagic=N32;;
- *-64|*"-64 ") libmagic=64-bit;;
- *) libmagic=never-match;;
- esac
- lt_cv_deplibs_check_method=pass_all
- ;;
-
-# This must be Linux ELF.
-linux*)
- lt_cv_deplibs_check_method=pass_all
- ;;
-
-netbsd* | netbsdelf*-gnu | knetbsd*-gnu)
- if echo __ELF__ | $CC -E - | grep __ELF__ > /dev/null; then
- lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so\.[[0-9]]+\.[[0-9]]+|_pic\.a)$'
- else
- lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so|_pic\.a)$'
- fi
- ;;
-
-newos6*)
- lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[ML]]SB (executable|dynamic lib)'
- lt_cv_file_magic_cmd=/usr/bin/file
- lt_cv_file_magic_test_file=/usr/lib/libnls.so
- ;;
-
-nto-qnx*)
- lt_cv_deplibs_check_method=unknown
- ;;
-
-openbsd*)
- if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
- lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so\.[[0-9]]+\.[[0-9]]+|\.so|_pic\.a)$'
- else
- lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so\.[[0-9]]+\.[[0-9]]+|_pic\.a)$'
- fi
- ;;
-
-osf3* | osf4* | osf5*)
- lt_cv_deplibs_check_method=pass_all
- ;;
-
-solaris*)
- lt_cv_deplibs_check_method=pass_all
- ;;
-
-sysv4 | sysv4.3*)
- case $host_vendor in
- motorola)
- lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[ML]]SB (shared object|dynamic lib) M[[0-9]][[0-9]]* Version [[0-9]]'
- lt_cv_file_magic_test_file=`echo /usr/lib/libc.so*`
- ;;
- ncr)
- lt_cv_deplibs_check_method=pass_all
- ;;
- sequent)
- lt_cv_file_magic_cmd='/bin/file'
- lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[LM]]SB (shared object|dynamic lib )'
- ;;
- sni)
- lt_cv_file_magic_cmd='/bin/file'
- lt_cv_deplibs_check_method="file_magic ELF [[0-9]][[0-9]]*-bit [[LM]]SB dynamic lib"
- lt_cv_file_magic_test_file=/lib/libc.so
- ;;
- siemens)
- lt_cv_deplibs_check_method=pass_all
- ;;
- pc)
- lt_cv_deplibs_check_method=pass_all
- ;;
- esac
- ;;
-
-sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*)
- lt_cv_deplibs_check_method=pass_all
- ;;
-esac
-])
-file_magic_cmd=$lt_cv_file_magic_cmd
-deplibs_check_method=$lt_cv_deplibs_check_method
-test -z "$deplibs_check_method" && deplibs_check_method=unknown
-])# AC_DEPLIBS_CHECK_METHOD
-
-
-# AC_PROG_NM
-# ----------
-# find the pathname to a BSD-compatible name lister
-AC_DEFUN([AC_PROG_NM],
-[AC_CACHE_CHECK([for BSD-compatible nm], lt_cv_path_NM,
-[if test -n "$NM"; then
- # Let the user override the test.
- lt_cv_path_NM="$NM"
-else
- lt_nm_to_check="${ac_tool_prefix}nm"
- if test -n "$ac_tool_prefix" && test "$build" = "$host"; then
- lt_nm_to_check="$lt_nm_to_check nm"
- fi
- for lt_tmp_nm in $lt_nm_to_check; do
- lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
- for ac_dir in $PATH /usr/ccs/bin/elf /usr/ccs/bin /usr/ucb /bin; do
- IFS="$lt_save_ifs"
- test -z "$ac_dir" && ac_dir=.
- tmp_nm="$ac_dir/$lt_tmp_nm"
- if test -f "$tmp_nm" || test -f "$tmp_nm$ac_exeext" ; then
- # Check to see if the nm accepts a BSD-compat flag.
- # Adding the `sed 1q' prevents false positives on HP-UX, which says:
- # nm: unknown option "B" ignored
- # Tru64's nm complains that /dev/null is an invalid object file
- case `"$tmp_nm" -B /dev/null 2>&1 | sed '1q'` in
- */dev/null* | *'Invalid file or object type'*)
- lt_cv_path_NM="$tmp_nm -B"
- break
- ;;
- *)
- case `"$tmp_nm" -p /dev/null 2>&1 | sed '1q'` in
- */dev/null*)
- lt_cv_path_NM="$tmp_nm -p"
- break
- ;;
- *)
- lt_cv_path_NM=${lt_cv_path_NM="$tmp_nm"} # keep the first match, but
- continue # so that we can try to find one that supports BSD flags
- ;;
- esac
- ;;
- esac
- fi
- done
- IFS="$lt_save_ifs"
- done
- test -z "$lt_cv_path_NM" && lt_cv_path_NM=nm
-fi])
-NM="$lt_cv_path_NM"
-])# AC_PROG_NM
-
-
-# AC_CHECK_LIBM
-# -------------
-# check for math library
-AC_DEFUN([AC_CHECK_LIBM],
-[AC_REQUIRE([AC_CANONICAL_HOST])dnl
-LIBM=
-case $host in
-*-*-beos* | *-*-cygwin* | *-*-pw32* | *-*-darwin*)
- # These system don't have libm, or don't need it
- ;;
-*-ncr-sysv4.3*)
- AC_CHECK_LIB(mw, _mwvalidcheckl, LIBM="-lmw")
- AC_CHECK_LIB(m, cos, LIBM="$LIBM -lm")
- ;;
-*)
- AC_CHECK_LIB(m, cos, LIBM="-lm")
- ;;
-esac
-])# AC_CHECK_LIBM
-
-
-# AC_LIBLTDL_CONVENIENCE([DIRECTORY])
-# -----------------------------------
-# sets LIBLTDL to the link flags for the libltdl convenience library and
-# LTDLINCL to the include flags for the libltdl header and adds
-# --enable-ltdl-convenience to the configure arguments. Note that
-# AC_CONFIG_SUBDIRS is not called here. If DIRECTORY is not provided,
-# it is assumed to be `libltdl'. LIBLTDL will be prefixed with
-# '${top_builddir}/' and LTDLINCL will be prefixed with '${top_srcdir}/'
-# (note the single quotes!). If your package is not flat and you're not
-# using automake, define top_builddir and top_srcdir appropriately in
-# the Makefiles.
-AC_DEFUN([AC_LIBLTDL_CONVENIENCE],
-[AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl
- case $enable_ltdl_convenience in
- no) AC_MSG_ERROR([this package needs a convenience libltdl]) ;;
- "") enable_ltdl_convenience=yes
- ac_configure_args="$ac_configure_args --enable-ltdl-convenience" ;;
- esac
- LIBLTDL='${top_builddir}/'ifelse($#,1,[$1],['libltdl'])/libltdlc.la
- LTDLINCL='-I${top_srcdir}/'ifelse($#,1,[$1],['libltdl'])
- # For backwards non-gettext consistent compatibility...
- INCLTDL="$LTDLINCL"
-])# AC_LIBLTDL_CONVENIENCE
-
-
-# AC_LIBLTDL_INSTALLABLE([DIRECTORY])
-# -----------------------------------
-# sets LIBLTDL to the link flags for the libltdl installable library and
-# LTDLINCL to the include flags for the libltdl header and adds
-# --enable-ltdl-install to the configure arguments. Note that
-# AC_CONFIG_SUBDIRS is not called here. If DIRECTORY is not provided,
-# and an installed libltdl is not found, it is assumed to be `libltdl'.
-# LIBLTDL will be prefixed with '${top_builddir}/'# and LTDLINCL with
-# '${top_srcdir}/' (note the single quotes!). If your package is not
-# flat and you're not using automake, define top_builddir and top_srcdir
-# appropriately in the Makefiles.
-# In the future, this macro may have to be called after AC_PROG_LIBTOOL.
-AC_DEFUN([AC_LIBLTDL_INSTALLABLE],
-[AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl
- AC_CHECK_LIB(ltdl, lt_dlinit,
- [test x"$enable_ltdl_install" != xyes && enable_ltdl_install=no],
- [if test x"$enable_ltdl_install" = xno; then
- AC_MSG_WARN([libltdl not installed, but installation disabled])
- else
- enable_ltdl_install=yes
- fi
- ])
- if test x"$enable_ltdl_install" = x"yes"; then
- ac_configure_args="$ac_configure_args --enable-ltdl-install"
- LIBLTDL='${top_builddir}/'ifelse($#,1,[$1],['libltdl'])/libltdl.la
- LTDLINCL='-I${top_srcdir}/'ifelse($#,1,[$1],['libltdl'])
- else
- ac_configure_args="$ac_configure_args --enable-ltdl-install=no"
- LIBLTDL="-lltdl"
- LTDLINCL=
- fi
- # For backwards non-gettext consistent compatibility...
- INCLTDL="$LTDLINCL"
-])# AC_LIBLTDL_INSTALLABLE
-
-
-# AC_LIBTOOL_CXX
-# --------------
-# enable support for C++ libraries
-AC_DEFUN([AC_LIBTOOL_CXX],
-[AC_REQUIRE([_LT_AC_LANG_CXX])
-])# AC_LIBTOOL_CXX
-
-
-# _LT_AC_LANG_CXX
-# ---------------
-AC_DEFUN([_LT_AC_LANG_CXX],
-[AC_REQUIRE([AC_PROG_CXX])
-AC_REQUIRE([_LT_AC_PROG_CXXCPP])
-_LT_AC_SHELL_INIT([tagnames=${tagnames+${tagnames},}CXX])
-])# _LT_AC_LANG_CXX
-
-# _LT_AC_PROG_CXXCPP
-# ------------------
-AC_DEFUN([_LT_AC_PROG_CXXCPP],
-[
-AC_REQUIRE([AC_PROG_CXX])
-if test -n "$CXX" && ( test "X$CXX" != "Xno" &&
- ( (test "X$CXX" = "Xg++" && `g++ -v >/dev/null 2>&1` ) ||
- (test "X$CXX" != "Xg++"))) ; then
- AC_PROG_CXXCPP
-fi
-])# _LT_AC_PROG_CXXCPP
-
-# AC_LIBTOOL_F77
-# --------------
-# enable support for Fortran 77 libraries
-AC_DEFUN([AC_LIBTOOL_F77],
-[AC_REQUIRE([_LT_AC_LANG_F77])
-])# AC_LIBTOOL_F77
-
-
-# _LT_AC_LANG_F77
-# ---------------
-AC_DEFUN([_LT_AC_LANG_F77],
-[AC_REQUIRE([AC_PROG_F77])
-_LT_AC_SHELL_INIT([tagnames=${tagnames+${tagnames},}F77])
-])# _LT_AC_LANG_F77
-
-
-# AC_LIBTOOL_GCJ
-# --------------
-# enable support for GCJ libraries
-AC_DEFUN([AC_LIBTOOL_GCJ],
-[AC_REQUIRE([_LT_AC_LANG_GCJ])
-])# AC_LIBTOOL_GCJ
-
-
-# _LT_AC_LANG_GCJ
-# ---------------
-AC_DEFUN([_LT_AC_LANG_GCJ],
-[AC_PROVIDE_IFELSE([AC_PROG_GCJ],[],
- [AC_PROVIDE_IFELSE([A][M_PROG_GCJ],[],
- [AC_PROVIDE_IFELSE([LT_AC_PROG_GCJ],[],
- [ifdef([AC_PROG_GCJ],[AC_REQUIRE([AC_PROG_GCJ])],
- [ifdef([A][M_PROG_GCJ],[AC_REQUIRE([A][M_PROG_GCJ])],
- [AC_REQUIRE([A][C_PROG_GCJ_OR_A][M_PROG_GCJ])])])])])])
-_LT_AC_SHELL_INIT([tagnames=${tagnames+${tagnames},}GCJ])
-])# _LT_AC_LANG_GCJ
-
-
-# AC_LIBTOOL_RC
-# -------------
-# enable support for Windows resource files
-AC_DEFUN([AC_LIBTOOL_RC],
-[AC_REQUIRE([LT_AC_PROG_RC])
-_LT_AC_SHELL_INIT([tagnames=${tagnames+${tagnames},}RC])
-])# AC_LIBTOOL_RC
-
-
-# AC_LIBTOOL_LANG_C_CONFIG
-# ------------------------
-# Ensure that the configuration vars for the C compiler are
-# suitably defined. Those variables are subsequently used by
-# AC_LIBTOOL_CONFIG to write the compiler configuration to `libtool'.
-AC_DEFUN([AC_LIBTOOL_LANG_C_CONFIG], [_LT_AC_LANG_C_CONFIG])
-AC_DEFUN([_LT_AC_LANG_C_CONFIG],
-[lt_save_CC="$CC"
-AC_LANG_PUSH(C)
-
-# Source file extension for C test sources.
-ac_ext=c
-
-# Object file extension for compiled C test sources.
-objext=o
-_LT_AC_TAGVAR(objext, $1)=$objext
-
-# Code to be used in simple compile tests
-lt_simple_compile_test_code="int some_variable = 0;\n"
-
-# Code to be used in simple link tests
-lt_simple_link_test_code='int main(){return(0);}\n'
-
-_LT_AC_SYS_COMPILER
-
-# save warnings/boilerplate of simple test code
-_LT_COMPILER_BOILERPLATE
-_LT_LINKER_BOILERPLATE
-
-AC_LIBTOOL_PROG_COMPILER_NO_RTTI($1)
-AC_LIBTOOL_PROG_COMPILER_PIC($1)
-AC_LIBTOOL_PROG_CC_C_O($1)
-AC_LIBTOOL_SYS_HARD_LINK_LOCKS($1)
-AC_LIBTOOL_PROG_LD_SHLIBS($1)
-AC_LIBTOOL_SYS_DYNAMIC_LINKER($1)
-AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH($1)
-AC_LIBTOOL_SYS_LIB_STRIP
-AC_LIBTOOL_DLOPEN_SELF
-
-# Report which library types will actually be built
-AC_MSG_CHECKING([if libtool supports shared libraries])
-AC_MSG_RESULT([$can_build_shared])
-
-AC_MSG_CHECKING([whether to build shared libraries])
-test "$can_build_shared" = "no" && enable_shared=no
-
-# On AIX, shared libraries and static libraries use the same namespace, and
-# are all built from PIC.
-case $host_os in
-aix3*)
- test "$enable_shared" = yes && enable_static=no
- if test -n "$RANLIB"; then
- archive_cmds="$archive_cmds~\$RANLIB \$lib"
- postinstall_cmds='$RANLIB $lib'
- fi
- ;;
-
-aix4* | aix5*)
- if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then
- test "$enable_shared" = yes && enable_static=no
- fi
- ;;
-esac
-AC_MSG_RESULT([$enable_shared])
-
-AC_MSG_CHECKING([whether to build static libraries])
-# Make sure either enable_shared or enable_static is yes.
-test "$enable_shared" = yes || enable_static=yes
-AC_MSG_RESULT([$enable_static])
-
-AC_LIBTOOL_CONFIG($1)
-
-AC_LANG_POP
-CC="$lt_save_CC"
-])# AC_LIBTOOL_LANG_C_CONFIG
-
-
-# AC_LIBTOOL_LANG_CXX_CONFIG
-# --------------------------
-# Ensure that the configuration vars for the C compiler are
-# suitably defined. Those variables are subsequently used by
-# AC_LIBTOOL_CONFIG to write the compiler configuration to `libtool'.
-AC_DEFUN([AC_LIBTOOL_LANG_CXX_CONFIG], [_LT_AC_LANG_CXX_CONFIG(CXX)])
-AC_DEFUN([_LT_AC_LANG_CXX_CONFIG],
-[AC_LANG_PUSH(C++)
-AC_REQUIRE([AC_PROG_CXX])
-AC_REQUIRE([_LT_AC_PROG_CXXCPP])
-
-_LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no
-_LT_AC_TAGVAR(allow_undefined_flag, $1)=
-_LT_AC_TAGVAR(always_export_symbols, $1)=no
-_LT_AC_TAGVAR(archive_expsym_cmds, $1)=
-_LT_AC_TAGVAR(export_dynamic_flag_spec, $1)=
-_LT_AC_TAGVAR(hardcode_direct, $1)=no
-_LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)=
-_LT_AC_TAGVAR(hardcode_libdir_flag_spec_ld, $1)=
-_LT_AC_TAGVAR(hardcode_libdir_separator, $1)=
-_LT_AC_TAGVAR(hardcode_minus_L, $1)=no
-_LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=unsupported
-_LT_AC_TAGVAR(hardcode_automatic, $1)=no
-_LT_AC_TAGVAR(module_cmds, $1)=
-_LT_AC_TAGVAR(module_expsym_cmds, $1)=
-_LT_AC_TAGVAR(link_all_deplibs, $1)=unknown
-_LT_AC_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds
-_LT_AC_TAGVAR(no_undefined_flag, $1)=
-_LT_AC_TAGVAR(whole_archive_flag_spec, $1)=
-_LT_AC_TAGVAR(enable_shared_with_static_runtimes, $1)=no
-
-# Dependencies to place before and after the object being linked:
-_LT_AC_TAGVAR(predep_objects, $1)=
-_LT_AC_TAGVAR(postdep_objects, $1)=
-_LT_AC_TAGVAR(predeps, $1)=
-_LT_AC_TAGVAR(postdeps, $1)=
-_LT_AC_TAGVAR(compiler_lib_search_path, $1)=
-
-# Source file extension for C++ test sources.
-ac_ext=cpp
-
-# Object file extension for compiled C++ test sources.
-objext=o
-_LT_AC_TAGVAR(objext, $1)=$objext
-
-# Code to be used in simple compile tests
-lt_simple_compile_test_code="int some_variable = 0;\n"
-
-# Code to be used in simple link tests
-lt_simple_link_test_code='int main(int, char *[[]]) { return(0); }\n'
-
-# ltmain only uses $CC for tagged configurations so make sure $CC is set.
-_LT_AC_SYS_COMPILER
-
-# save warnings/boilerplate of simple test code
-_LT_COMPILER_BOILERPLATE
-_LT_LINKER_BOILERPLATE
-
-# Allow CC to be a program name with arguments.
-lt_save_CC=$CC
-lt_save_LD=$LD
-lt_save_GCC=$GCC
-GCC=$GXX
-lt_save_with_gnu_ld=$with_gnu_ld
-lt_save_path_LD=$lt_cv_path_LD
-if test -n "${lt_cv_prog_gnu_ldcxx+set}"; then
- lt_cv_prog_gnu_ld=$lt_cv_prog_gnu_ldcxx
-else
- $as_unset lt_cv_prog_gnu_ld
-fi
-if test -n "${lt_cv_path_LDCXX+set}"; then
- lt_cv_path_LD=$lt_cv_path_LDCXX
-else
- $as_unset lt_cv_path_LD
-fi
-test -z "${LDCXX+set}" || LD=$LDCXX
-CC=${CXX-"c++"}
-compiler=$CC
-_LT_AC_TAGVAR(compiler, $1)=$CC
-_LT_CC_BASENAME([$compiler])
-
-# We don't want -fno-exception wen compiling C++ code, so set the
-# no_builtin_flag separately
-if test "$GXX" = yes; then
- _LT_AC_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=' -fno-builtin'
-else
- _LT_AC_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=
-fi
-
-if test "$GXX" = yes; then
- # Set up default GNU C++ configuration
-
- AC_PROG_LD
-
- # Check if GNU C++ uses GNU ld as the underlying linker, since the
- # archiving commands below assume that GNU ld is being used.
- if test "$with_gnu_ld" = yes; then
- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib'
- _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
-
- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}--rpath ${wl}$libdir'
- _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic'
-
- # If archive_cmds runs LD, not CC, wlarc should be empty
- # XXX I think wlarc can be eliminated in ltcf-cxx, but I need to
- # investigate it a little bit more. (MM)
- wlarc='${wl}'
-
- # ancient GNU ld didn't support --whole-archive et. al.
- if eval "`$CC -print-prog-name=ld` --help 2>&1" | \
- grep 'no-whole-archive' > /dev/null; then
- _LT_AC_TAGVAR(whole_archive_flag_spec, $1)="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive'
- else
- _LT_AC_TAGVAR(whole_archive_flag_spec, $1)=
- fi
- else
- with_gnu_ld=no
- wlarc=
-
- # A generic and very simple default shared library creation
- # command for GNU C++ for the case where it uses the native
- # linker, instead of GNU ld. If possible, this setting should
- # overridden to take advantage of the native linker features on
- # the platform it is being used on.
- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $lib'
- fi
-
- # Commands to make compiler produce verbose output that lists
- # what "hidden" libraries, object files and flags are used when
- # linking a shared library.
- output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep "\-L"'
-
-else
- GXX=no
- with_gnu_ld=no
- wlarc=
-fi
-
-# PORTME: fill in a description of your system's C++ link characteristics
-AC_MSG_CHECKING([whether the $compiler linker ($LD) supports shared libraries])
-_LT_AC_TAGVAR(ld_shlibs, $1)=yes
-case $host_os in
- aix3*)
- # FIXME: insert proper C++ library support
- _LT_AC_TAGVAR(ld_shlibs, $1)=no
- ;;
- aix4* | aix5*)
- if test "$host_cpu" = ia64; then
- # On IA64, the linker does run time linking by default, so we don't
- # have to do anything special.
- aix_use_runtimelinking=no
- exp_sym_flag='-Bexport'
- no_entry_flag=""
- else
- aix_use_runtimelinking=no
-
- # Test if we are trying to use run time linking or normal
- # AIX style linking. If -brtl is somewhere in LDFLAGS, we
- # need to do runtime linking.
- case $host_os in aix4.[[23]]|aix4.[[23]].*|aix5*)
- for ld_flag in $LDFLAGS; do
- case $ld_flag in
- *-brtl*)
- aix_use_runtimelinking=yes
- break
- ;;
- esac
- done
- ;;
- esac
-
- exp_sym_flag='-bexport'
- no_entry_flag='-bnoentry'
- fi
-
- # When large executables or shared objects are built, AIX ld can
- # have problems creating the table of contents. If linking a library
- # or program results in "error TOC overflow" add -mminimal-toc to
- # CXXFLAGS/CFLAGS for g++/gcc. In the cases where that is not
- # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS.
-
- _LT_AC_TAGVAR(archive_cmds, $1)=''
- _LT_AC_TAGVAR(hardcode_direct, $1)=yes
- _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=':'
- _LT_AC_TAGVAR(link_all_deplibs, $1)=yes
-
- if test "$GXX" = yes; then
- case $host_os in aix4.[[012]]|aix4.[[012]].*)
- # We only want to do this on AIX 4.2 and lower, the check
- # below for broken collect2 doesn't work under 4.3+
- collect2name=`${CC} -print-prog-name=collect2`
- if test -f "$collect2name" && \
- strings "$collect2name" | grep resolve_lib_name >/dev/null
- then
- # We have reworked collect2
- _LT_AC_TAGVAR(hardcode_direct, $1)=yes
- else
- # We have old collect2
- _LT_AC_TAGVAR(hardcode_direct, $1)=unsupported
- # It fails to find uninstalled libraries when the uninstalled
- # path is not listed in the libpath. Setting hardcode_minus_L
- # to unsupported forces relinking
- _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes
- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
- _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=
- fi
- ;;
- esac
- shared_flag='-shared'
- if test "$aix_use_runtimelinking" = yes; then
- shared_flag="$shared_flag "'${wl}-G'
- fi
- else
- # not using gcc
- if test "$host_cpu" = ia64; then
- # VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release
- # chokes on -Wl,-G. The following line is correct:
- shared_flag='-G'
- else
- if test "$aix_use_runtimelinking" = yes; then
- shared_flag='${wl}-G'
- else
- shared_flag='${wl}-bM:SRE'
- fi
- fi
- fi
-
- # It seems that -bexpall does not export symbols beginning with
- # underscore (_), so it is better to generate a list of symbols to export.
- _LT_AC_TAGVAR(always_export_symbols, $1)=yes
- if test "$aix_use_runtimelinking" = yes; then
- # Warning - without using the other runtime loading flags (-brtl),
- # -berok will link without error, but may produce a broken library.
- _LT_AC_TAGVAR(allow_undefined_flag, $1)='-berok'
- # Determine the default libpath from the value encoded in an empty executable.
- _LT_AC_SYS_LIBPATH_AIX
- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath"
-
- _LT_AC_TAGVAR(archive_expsym_cmds, $1)="\$CC"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then echo "${wl}${allow_undefined_flag}"; else :; fi` '"\${wl}$exp_sym_flag:\$export_symbols $shared_flag"
- else
- if test "$host_cpu" = ia64; then
- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R $libdir:/usr/lib:/lib'
- _LT_AC_TAGVAR(allow_undefined_flag, $1)="-z nodefs"
- _LT_AC_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$exp_sym_flag:\$export_symbols"
- else
- # Determine the default libpath from the value encoded in an empty executable.
- _LT_AC_SYS_LIBPATH_AIX
- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath"
- # Warning - without using the other run time loading flags,
- # -berok will link without error, but may produce a broken library.
- _LT_AC_TAGVAR(no_undefined_flag, $1)=' ${wl}-bernotok'
- _LT_AC_TAGVAR(allow_undefined_flag, $1)=' ${wl}-berok'
- # Exported symbols can be pulled into shared objects from archives
- _LT_AC_TAGVAR(whole_archive_flag_spec, $1)='$convenience'
- _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=yes
- # This is similar to how AIX traditionally builds its shared libraries.
- _LT_AC_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs ${wl}-bnoentry $compiler_flags ${wl}-bE:$export_symbols${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname'
- fi
- fi
- ;;
-
- beos*)
- if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
- _LT_AC_TAGVAR(allow_undefined_flag, $1)=unsupported
- # Joseph Beckenbach <jrb3@best.com> says some releases of gcc
- # support --undefined. This deserves some investigation. FIXME
- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
- else
- _LT_AC_TAGVAR(ld_shlibs, $1)=no
- fi
- ;;
-
- chorus*)
- case $cc_basename in
- *)
- # FIXME: insert proper C++ library support
- _LT_AC_TAGVAR(ld_shlibs, $1)=no
- ;;
- esac
- ;;
-
- cygwin* | mingw* | pw32*)
- # _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1) is actually meaningless,
- # as there is no search path for DLLs.
- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
- _LT_AC_TAGVAR(allow_undefined_flag, $1)=unsupported
- _LT_AC_TAGVAR(always_export_symbols, $1)=no
- _LT_AC_TAGVAR(enable_shared_with_static_runtimes, $1)=yes
-
- if $LD --help 2>&1 | grep 'auto-import' > /dev/null; then
- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
- # If the export-symbols file already is a .def file (1st line
- # is EXPORTS), use it as is; otherwise, prepend...
- _LT_AC_TAGVAR(archive_expsym_cmds, $1)='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then
- cp $export_symbols $output_objdir/$soname.def;
- else
- echo EXPORTS > $output_objdir/$soname.def;
- cat $export_symbols >> $output_objdir/$soname.def;
- fi~
- $CC -shared -nostdlib $output_objdir/$soname.def $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
- else
- _LT_AC_TAGVAR(ld_shlibs, $1)=no
- fi
- ;;
- darwin* | rhapsody*)
- case $host_os in
- rhapsody* | darwin1.[[012]])
- _LT_AC_TAGVAR(allow_undefined_flag, $1)='${wl}-undefined ${wl}suppress'
- ;;
- *) # Darwin 1.3 on
- if test -z ${MACOSX_DEPLOYMENT_TARGET} ; then
- _LT_AC_TAGVAR(allow_undefined_flag, $1)='${wl}-flat_namespace ${wl}-undefined ${wl}suppress'
- else
- case ${MACOSX_DEPLOYMENT_TARGET} in
- 10.[[012]])
- _LT_AC_TAGVAR(allow_undefined_flag, $1)='${wl}-flat_namespace ${wl}-undefined ${wl}suppress'
- ;;
- 10.*)
- _LT_AC_TAGVAR(allow_undefined_flag, $1)='${wl}-undefined ${wl}dynamic_lookup'
- ;;
- esac
- fi
- ;;
- esac
- _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no
- _LT_AC_TAGVAR(hardcode_direct, $1)=no
- _LT_AC_TAGVAR(hardcode_automatic, $1)=yes
- _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=unsupported
- _LT_AC_TAGVAR(whole_archive_flag_spec, $1)=''
- _LT_AC_TAGVAR(link_all_deplibs, $1)=yes
-
- if test "$GXX" = yes ; then
- lt_int_apple_cc_single_mod=no
- output_verbose_link_cmd='echo'
- if $CC -dumpspecs 2>&1 | $EGREP 'single_module' >/dev/null ; then
- lt_int_apple_cc_single_mod=yes
- fi
- if test "X$lt_int_apple_cc_single_mod" = Xyes ; then
- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -dynamiclib -single_module $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring'
- else
- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -r -keep_private_externs -nostdlib -o ${lib}-master.o $libobjs~$CC -dynamiclib $allow_undefined_flag -o $lib ${lib}-master.o $deplibs $compiler_flags -install_name $rpath/$soname $verstring'
- fi
- _LT_AC_TAGVAR(module_cmds, $1)='$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags'
- # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin lds
- if test "X$lt_int_apple_cc_single_mod" = Xyes ; then
- _LT_AC_TAGVAR(archive_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -dynamiclib -single_module $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
- else
- _LT_AC_TAGVAR(archive_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -r -keep_private_externs -nostdlib -o ${lib}-master.o $libobjs~$CC -dynamiclib $allow_undefined_flag -o $lib ${lib}-master.o $deplibs $compiler_flags -install_name $rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
- fi
- _LT_AC_TAGVAR(module_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
- else
- case $cc_basename in
- xlc*)
- output_verbose_link_cmd='echo'
- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -qmkshrobj ${wl}-single_module $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-install_name ${wl}`echo $rpath/$soname` $verstring'
- _LT_AC_TAGVAR(module_cmds, $1)='$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags'
- # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin lds
- _LT_AC_TAGVAR(archive_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -qmkshrobj ${wl}-single_module $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-install_name ${wl}$rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
- _LT_AC_TAGVAR(module_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
- ;;
- *)
- _LT_AC_TAGVAR(ld_shlibs, $1)=no
- ;;
- esac
- fi
- ;;
-
- dgux*)
- case $cc_basename in
- ec++*)
- # FIXME: insert proper C++ library support
- _LT_AC_TAGVAR(ld_shlibs, $1)=no
- ;;
- ghcx*)
- # Green Hills C++ Compiler
- # FIXME: insert proper C++ library support
- _LT_AC_TAGVAR(ld_shlibs, $1)=no
- ;;
- *)
- # FIXME: insert proper C++ library support
- _LT_AC_TAGVAR(ld_shlibs, $1)=no
- ;;
- esac
- ;;
- freebsd[[12]]*)
- # C++ shared libraries reported to be fairly broken before switch to ELF
- _LT_AC_TAGVAR(ld_shlibs, $1)=no
- ;;
- freebsd-elf*)
- _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no
- ;;
- freebsd* | kfreebsd*-gnu | dragonfly*)
- # FreeBSD 3 and later use GNU C++ and GNU ld with standard ELF
- # conventions
- _LT_AC_TAGVAR(ld_shlibs, $1)=yes
- ;;
- gnu*)
- ;;
- hpux9*)
- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir'
- _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=:
- _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
- _LT_AC_TAGVAR(hardcode_direct, $1)=yes
- _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes # Not in the search PATH,
- # but as the default
- # location of the library.
-
- case $cc_basename in
- CC*)
- # FIXME: insert proper C++ library support
- _LT_AC_TAGVAR(ld_shlibs, $1)=no
- ;;
- aCC*)
- _LT_AC_TAGVAR(archive_cmds, $1)='$rm $output_objdir/$soname~$CC -b ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
- # Commands to make compiler produce verbose output that lists
- # what "hidden" libraries, object files and flags are used when
- # linking a shared library.
- #
- # There doesn't appear to be a way to prevent this compiler from
- # explicitly linking system object files so we need to strip them
- # from the output so that they don't get included in the library
- # dependencies.
- output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | grep "[[-]]L"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; echo $list'
- ;;
- *)
- if test "$GXX" = yes; then
- _LT_AC_TAGVAR(archive_cmds, $1)='$rm $output_objdir/$soname~$CC -shared -nostdlib -fPIC ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
- else
- # FIXME: insert proper C++ library support
- _LT_AC_TAGVAR(ld_shlibs, $1)=no
- fi
- ;;
- esac
- ;;
- hpux10*|hpux11*)
- if test $with_gnu_ld = no; then
- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir'
- _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=:
-
- case $host_cpu in
- hppa*64*|ia64*)
- _LT_AC_TAGVAR(hardcode_libdir_flag_spec_ld, $1)='+b $libdir'
- ;;
- *)
- _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
- ;;
- esac
- fi
- case $host_cpu in
- hppa*64*|ia64*)
- _LT_AC_TAGVAR(hardcode_direct, $1)=no
- _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
- ;;
- *)
- _LT_AC_TAGVAR(hardcode_direct, $1)=yes
- _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes # Not in the search PATH,
- # but as the default
- # location of the library.
- ;;
- esac
-
- case $cc_basename in
- CC*)
- # FIXME: insert proper C++ library support
- _LT_AC_TAGVAR(ld_shlibs, $1)=no
- ;;
- aCC*)
- case $host_cpu in
- hppa*64*)
- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
- ;;
- ia64*)
- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
- ;;
- *)
- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
- ;;
- esac
- # Commands to make compiler produce verbose output that lists
- # what "hidden" libraries, object files and flags are used when
- # linking a shared library.
- #
- # There doesn't appear to be a way to prevent this compiler from
- # explicitly linking system object files so we need to strip them
- # from the output so that they don't get included in the library
- # dependencies.
- output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | grep "\-L"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; echo $list'
- ;;
- *)
- if test "$GXX" = yes; then
- if test $with_gnu_ld = no; then
- case $host_cpu in
- hppa*64*)
- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib -fPIC ${wl}+h ${wl}$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
- ;;
- ia64*)
- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib -fPIC ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
- ;;
- *)
- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
- ;;
- esac
- fi
- else
- # FIXME: insert proper C++ library support
- _LT_AC_TAGVAR(ld_shlibs, $1)=no
- fi
- ;;
- esac
- ;;
- interix3*)
- _LT_AC_TAGVAR(hardcode_direct, $1)=no
- _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
- _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
- # Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc.
- # Instead, shared libraries are loaded at an image base (0x10000000 by
- # default) and relocated if they conflict, which is a slow very memory
- # consuming and fragmenting process. To avoid this, we pick a random,
- # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link
- # time. Moving up from 0x10000000 also allows more sbrk(2) space.
- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
- _LT_AC_TAGVAR(archive_expsym_cmds, $1)='sed "s,^,_," $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--retain-symbols-file,$output_objdir/$soname.expsym ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
- ;;
- irix5* | irix6*)
- case $cc_basename in
- CC*)
- # SGI C++
- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -all -multigot $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib'
-
- # Archives containing C++ object files must be created using
- # "CC -ar", where "CC" is the IRIX C++ compiler. This is
- # necessary to make sure instantiated templates are included
- # in the archive.
- _LT_AC_TAGVAR(old_archive_cmds, $1)='$CC -ar -WR,-u -o $oldlib $oldobjs'
- ;;
- *)
- if test "$GXX" = yes; then
- if test "$with_gnu_ld" = no; then
- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
- else
- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` -o $lib'
- fi
- fi
- _LT_AC_TAGVAR(link_all_deplibs, $1)=yes
- ;;
- esac
- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
- _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=:
- ;;
- linux*)
- case $cc_basename in
- KCC*)
- # Kuck and Associates, Inc. (KAI) C++ Compiler
-
- # KCC will only create a shared library if the output file
- # ends with ".so" (or ".sl" for HP-UX), so rename the library
- # to its proper name (with version) after linking.
- _LT_AC_TAGVAR(archive_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib'
- _LT_AC_TAGVAR(archive_expsym_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib ${wl}-retain-symbols-file,$export_symbols; mv \$templib $lib'
- # Commands to make compiler produce verbose output that lists
- # what "hidden" libraries, object files and flags are used when
- # linking a shared library.
- #
- # There doesn't appear to be a way to prevent this compiler from
- # explicitly linking system object files so we need to strip them
- # from the output so that they don't get included in the library
- # dependencies.
- output_verbose_link_cmd='templist=`$CC $CFLAGS -v conftest.$objext -o libconftest$shared_ext 2>&1 | grep "ld"`; rm -f libconftest$shared_ext; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; echo $list'
-
- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}--rpath,$libdir'
- _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic'
-
- # Archives containing C++ object files must be created using
- # "CC -Bstatic", where "CC" is the KAI C++ compiler.
- _LT_AC_TAGVAR(old_archive_cmds, $1)='$CC -Bstatic -o $oldlib $oldobjs'
- ;;
- icpc*)
- # Intel C++
- with_gnu_ld=yes
- # version 8.0 and above of icpc choke on multiply defined symbols
- # if we add $predep_objects and $postdep_objects, however 7.1 and
- # earlier do not add the objects themselves.
- case `$CC -V 2>&1` in
- *"Version 7."*)
- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib'
- _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
- ;;
- *) # Version 8.0 or newer
- tmp_idyn=
- case $host_cpu in
- ia64*) tmp_idyn=' -i_dynamic';;
- esac
- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared'"$tmp_idyn"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
- _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared'"$tmp_idyn"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
- ;;
- esac
- _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no
- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
- _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic'
- _LT_AC_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive$convenience ${wl}--no-whole-archive'
- ;;
- pgCC*)
- # Portland Group C++ compiler
- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname -o $lib'
- _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname ${wl}-retain-symbols-file ${wl}$export_symbols -o $lib'
-
- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}--rpath ${wl}$libdir'
- _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic'
- _LT_AC_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}--no-whole-archive'
- ;;
- cxx*)
- # Compaq C++
- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib'
- _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib ${wl}-retain-symbols-file $wl$export_symbols'
-
- runpath_var=LD_RUN_PATH
- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-rpath $libdir'
- _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=:
-
- # Commands to make compiler produce verbose output that lists
- # what "hidden" libraries, object files and flags are used when
- # linking a shared library.
- #
- # There doesn't appear to be a way to prevent this compiler from
- # explicitly linking system object files so we need to strip them
- # from the output so that they don't get included in the library
- # dependencies.
- output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep "ld"`; templist=`echo $templist | $SED "s/\(^.*ld.*\)\( .*ld .*$\)/\1/"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; echo $list'
- ;;
- esac
- ;;
- lynxos*)
- # FIXME: insert proper C++ library support
- _LT_AC_TAGVAR(ld_shlibs, $1)=no
- ;;
- m88k*)
- # FIXME: insert proper C++ library support
- _LT_AC_TAGVAR(ld_shlibs, $1)=no
- ;;
- mvs*)
- case $cc_basename in
- cxx*)
- # FIXME: insert proper C++ library support
- _LT_AC_TAGVAR(ld_shlibs, $1)=no
- ;;
- *)
- # FIXME: insert proper C++ library support
- _LT_AC_TAGVAR(ld_shlibs, $1)=no
- ;;
- esac
- ;;
- netbsd* | netbsdelf*-gnu | knetbsd*-gnu)
- if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then
- _LT_AC_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $predep_objects $libobjs $deplibs $postdep_objects $linker_flags'
- wlarc=
- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
- _LT_AC_TAGVAR(hardcode_direct, $1)=yes
- _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
- fi
- # Workaround some broken pre-1.5 toolchains
- output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep conftest.$objext | $SED -e "s:-lgcc -lc -lgcc::"'
- ;;
- openbsd2*)
- # C++ shared libraries are fairly broken
- _LT_AC_TAGVAR(ld_shlibs, $1)=no
- ;;
- openbsd*)
- _LT_AC_TAGVAR(hardcode_direct, $1)=yes
- _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $lib'
- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
- if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
- _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-retain-symbols-file,$export_symbols -o $lib'
- _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
- _LT_AC_TAGVAR(whole_archive_flag_spec, $1)="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive'
- fi
- output_verbose_link_cmd='echo'
- ;;
- osf3*)
- case $cc_basename in
- KCC*)
- # Kuck and Associates, Inc. (KAI) C++ Compiler
-
- # KCC will only create a shared library if the output file
- # ends with ".so" (or ".sl" for HP-UX), so rename the library
- # to its proper name (with version) after linking.
- _LT_AC_TAGVAR(archive_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib'
-
- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
- _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=:
-
- # Archives containing C++ object files must be created using
- # "CC -Bstatic", where "CC" is the KAI C++ compiler.
- _LT_AC_TAGVAR(old_archive_cmds, $1)='$CC -Bstatic -o $oldlib $oldobjs'
-
- ;;
- RCC*)
- # Rational C++ 2.4.1
- # FIXME: insert proper C++ library support
- _LT_AC_TAGVAR(ld_shlibs, $1)=no
- ;;
- cxx*)
- _LT_AC_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*'
- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $soname `test -n "$verstring" && echo ${wl}-set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib'
-
- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
- _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=:
-
- # Commands to make compiler produce verbose output that lists
- # what "hidden" libraries, object files and flags are used when
- # linking a shared library.
- #
- # There doesn't appear to be a way to prevent this compiler from
- # explicitly linking system object files so we need to strip them
- # from the output so that they don't get included in the library
- # dependencies.
- output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep "ld" | grep -v "ld:"`; templist=`echo $templist | $SED "s/\(^.*ld.*\)\( .*ld.*$\)/\1/"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; echo $list'
- ;;
- *)
- if test "$GXX" = yes && test "$with_gnu_ld" = no; then
- _LT_AC_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*'
- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib ${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
-
- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
- _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=:
-
- # Commands to make compiler produce verbose output that lists
- # what "hidden" libraries, object files and flags are used when
- # linking a shared library.
- output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep "\-L"'
-
- else
- # FIXME: insert proper C++ library support
- _LT_AC_TAGVAR(ld_shlibs, $1)=no
- fi
- ;;
- esac
- ;;
- osf4* | osf5*)
- case $cc_basename in
- KCC*)
- # Kuck and Associates, Inc. (KAI) C++ Compiler
-
- # KCC will only create a shared library if the output file
- # ends with ".so" (or ".sl" for HP-UX), so rename the library
- # to its proper name (with version) after linking.
- _LT_AC_TAGVAR(archive_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib'
-
- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
- _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=:
-
- # Archives containing C++ object files must be created using
- # the KAI C++ compiler.
- _LT_AC_TAGVAR(old_archive_cmds, $1)='$CC -o $oldlib $oldobjs'
- ;;
- RCC*)
- # Rational C++ 2.4.1
- # FIXME: insert proper C++ library support
- _LT_AC_TAGVAR(ld_shlibs, $1)=no
- ;;
- cxx*)
- _LT_AC_TAGVAR(allow_undefined_flag, $1)=' -expect_unresolved \*'
- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib'
- _LT_AC_TAGVAR(archive_expsym_cmds, $1)='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done~
- echo "-hidden">> $lib.exp~
- $CC -shared$allow_undefined_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname -Wl,-input -Wl,$lib.exp `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib~
- $rm $lib.exp'
-
- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-rpath $libdir'
- _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=:
-
- # Commands to make compiler produce verbose output that lists
- # what "hidden" libraries, object files and flags are used when
- # linking a shared library.
- #
- # There doesn't appear to be a way to prevent this compiler from
- # explicitly linking system object files so we need to strip them
- # from the output so that they don't get included in the library
- # dependencies.
- output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep "ld" | grep -v "ld:"`; templist=`echo $templist | $SED "s/\(^.*ld.*\)\( .*ld.*$\)/\1/"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; echo $list'
- ;;
- *)
- if test "$GXX" = yes && test "$with_gnu_ld" = no; then
- _LT_AC_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*'
- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib ${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
-
- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
- _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=:
-
- # Commands to make compiler produce verbose output that lists
- # what "hidden" libraries, object files and flags are used when
- # linking a shared library.
- output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep "\-L"'
-
- else
- # FIXME: insert proper C++ library support
- _LT_AC_TAGVAR(ld_shlibs, $1)=no
- fi
- ;;
- esac
- ;;
- psos*)
- # FIXME: insert proper C++ library support
- _LT_AC_TAGVAR(ld_shlibs, $1)=no
- ;;
- sunos4*)
- case $cc_basename in
- CC*)
- # Sun C++ 4.x
- # FIXME: insert proper C++ library support
- _LT_AC_TAGVAR(ld_shlibs, $1)=no
- ;;
- lcc*)
- # Lucid
- # FIXME: insert proper C++ library support
- _LT_AC_TAGVAR(ld_shlibs, $1)=no
- ;;
- *)
- # FIXME: insert proper C++ library support
- _LT_AC_TAGVAR(ld_shlibs, $1)=no
- ;;
- esac
- ;;
- solaris*)
- case $cc_basename in
- CC*)
- # Sun C++ 4.2, 5.x and Centerline C++
- _LT_AC_TAGVAR(archive_cmds_need_lc,$1)=yes
- _LT_AC_TAGVAR(no_undefined_flag, $1)=' -zdefs'
- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -G${allow_undefined_flag} -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
- _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~
- $CC -G${allow_undefined_flag} ${wl}-M ${wl}$lib.exp -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$rm $lib.exp'
-
- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
- _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
- case $host_os in
- solaris2.[[0-5]] | solaris2.[[0-5]].*) ;;
- *)
- # The C++ compiler is used as linker so we must use $wl
- # flag to pass the commands to the underlying system
- # linker. We must also pass each convience library through
- # to the system linker between allextract/defaultextract.
- # The C++ compiler will combine linker options so we
- # cannot just pass the convience library names through
- # without $wl.
- # Supported since Solaris 2.6 (maybe 2.5.1?)
- _LT_AC_TAGVAR(whole_archive_flag_spec, $1)='${wl}-z ${wl}allextract`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}-z ${wl}defaultextract'
- ;;
- esac
- _LT_AC_TAGVAR(link_all_deplibs, $1)=yes
-
- output_verbose_link_cmd='echo'
-
- # Archives containing C++ object files must be created using
- # "CC -xar", where "CC" is the Sun C++ compiler. This is
- # necessary to make sure instantiated templates are included
- # in the archive.
- _LT_AC_TAGVAR(old_archive_cmds, $1)='$CC -xar -o $oldlib $oldobjs'
- ;;
- gcx*)
- # Green Hills C++ Compiler
- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib'
-
- # The C++ compiler must be used to create the archive.
- _LT_AC_TAGVAR(old_archive_cmds, $1)='$CC $LDFLAGS -archive -o $oldlib $oldobjs'
- ;;
- *)
- # GNU C++ compiler with Solaris linker
- if test "$GXX" = yes && test "$with_gnu_ld" = no; then
- _LT_AC_TAGVAR(no_undefined_flag, $1)=' ${wl}-z ${wl}defs'
- if $CC --version | grep -v '^2\.7' > /dev/null; then
- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $LDFLAGS $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib'
- _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~
- $CC -shared -nostdlib ${wl}-M $wl$lib.exp -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$rm $lib.exp'
-
- # Commands to make compiler produce verbose output that lists
- # what "hidden" libraries, object files and flags are used when
- # linking a shared library.
- output_verbose_link_cmd="$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep \"\-L\""
- else
- # g++ 2.7 appears to require `-G' NOT `-shared' on this
- # platform.
- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -G -nostdlib $LDFLAGS $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib'
- _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~
- $CC -G -nostdlib ${wl}-M $wl$lib.exp -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$rm $lib.exp'
-
- # Commands to make compiler produce verbose output that lists
- # what "hidden" libraries, object files and flags are used when
- # linking a shared library.
- output_verbose_link_cmd="$CC -G $CFLAGS -v conftest.$objext 2>&1 | grep \"\-L\""
- fi
-
- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R $wl$libdir'
- fi
- ;;
- esac
- ;;
- sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[[01]].[[10]]* | unixware7* | sco3.2v5.0.[[024]]*)
- _LT_AC_TAGVAR(no_undefined_flag, $1)='${wl}-z,text'
- _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no
- _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
- runpath_var='LD_RUN_PATH'
-
- case $cc_basename in
- CC*)
- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
- _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
- ;;
- *)
- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
- _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
- ;;
- esac
- ;;
- sysv5* | sco3.2v5* | sco5v6*)
- # Note: We can NOT use -z defs as we might desire, because we do not
- # link with -lc, and that would cause any symbols used from libc to
- # always be unresolved, which means just about no library would
- # ever link correctly. If we're not using GNU ld we use -z text
- # though, which does catch some bad symbols but isn't as heavy-handed
- # as -z defs.
- # For security reasons, it is highly recommended that you always
- # use absolute paths for naming shared libraries, and exclude the
- # DT_RUNPATH tag from executables and libraries. But doing so
- # requires that you compile everything twice, which is a pain.
- # So that behaviour is only enabled if SCOABSPATH is set to a
- # non-empty value in the environment. Most likely only useful for
- # creating official distributions of packages.
- # This is a hack until libtool officially supports absolute path
- # names for shared libraries.
- _LT_AC_TAGVAR(no_undefined_flag, $1)='${wl}-z,text'
- _LT_AC_TAGVAR(allow_undefined_flag, $1)='${wl}-z,nodefs'
- _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no
- _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='`test -z "$SCOABSPATH" && echo ${wl}-R,$libdir`'
- _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=':'
- _LT_AC_TAGVAR(link_all_deplibs, $1)=yes
- _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-Bexport'
- runpath_var='LD_RUN_PATH'
-
- case $cc_basename in
- CC*)
- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags'
- _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags'
- ;;
- *)
- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags'
- _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags'
- ;;
- esac
- ;;
- tandem*)
- case $cc_basename in
- NCC*)
- # NonStop-UX NCC 3.20
- # FIXME: insert proper C++ library support
- _LT_AC_TAGVAR(ld_shlibs, $1)=no
- ;;
- *)
- # FIXME: insert proper C++ library support
- _LT_AC_TAGVAR(ld_shlibs, $1)=no
- ;;
- esac
- ;;
- vxworks*)
- # FIXME: insert proper C++ library support
- _LT_AC_TAGVAR(ld_shlibs, $1)=no
- ;;
- *)
- # FIXME: insert proper C++ library support
- _LT_AC_TAGVAR(ld_shlibs, $1)=no
- ;;
-esac
-AC_MSG_RESULT([$_LT_AC_TAGVAR(ld_shlibs, $1)])
-test "$_LT_AC_TAGVAR(ld_shlibs, $1)" = no && can_build_shared=no
-
-_LT_AC_TAGVAR(GCC, $1)="$GXX"
-_LT_AC_TAGVAR(LD, $1)="$LD"
-
-AC_LIBTOOL_POSTDEP_PREDEP($1)
-AC_LIBTOOL_PROG_COMPILER_PIC($1)
-AC_LIBTOOL_PROG_CC_C_O($1)
-AC_LIBTOOL_SYS_HARD_LINK_LOCKS($1)
-AC_LIBTOOL_PROG_LD_SHLIBS($1)
-AC_LIBTOOL_SYS_DYNAMIC_LINKER($1)
-AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH($1)
-
-AC_LIBTOOL_CONFIG($1)
-
-AC_LANG_POP
-CC=$lt_save_CC
-LDCXX=$LD
-LD=$lt_save_LD
-GCC=$lt_save_GCC
-with_gnu_ldcxx=$with_gnu_ld
-with_gnu_ld=$lt_save_with_gnu_ld
-lt_cv_path_LDCXX=$lt_cv_path_LD
-lt_cv_path_LD=$lt_save_path_LD
-lt_cv_prog_gnu_ldcxx=$lt_cv_prog_gnu_ld
-lt_cv_prog_gnu_ld=$lt_save_with_gnu_ld
-])# AC_LIBTOOL_LANG_CXX_CONFIG
-
-# AC_LIBTOOL_POSTDEP_PREDEP([TAGNAME])
-# ------------------------------------
-# Figure out "hidden" library dependencies from verbose
-# compiler output when linking a shared library.
-# Parse the compiler output and extract the necessary
-# objects, libraries and library flags.
-AC_DEFUN([AC_LIBTOOL_POSTDEP_PREDEP],[
-dnl we can't use the lt_simple_compile_test_code here,
-dnl because it contains code intended for an executable,
-dnl not a library. It's possible we should let each
-dnl tag define a new lt_????_link_test_code variable,
-dnl but it's only used here...
-ifelse([$1],[],[cat > conftest.$ac_ext <<EOF
-int a;
-void foo (void) { a = 0; }
-EOF
-],[$1],[CXX],[cat > conftest.$ac_ext <<EOF
-class Foo
-{
-public:
- Foo (void) { a = 0; }
-private:
- int a;
-};
-EOF
-],[$1],[F77],[cat > conftest.$ac_ext <<EOF
- subroutine foo
- implicit none
- integer*4 a
- a=0
- return
- end
-EOF
-],[$1],[GCJ],[cat > conftest.$ac_ext <<EOF
-public class foo {
- private int a;
- public void bar (void) {
- a = 0;
- }
-};
-EOF
-])
-dnl Parse the compiler output and extract the necessary
-dnl objects, libraries and library flags.
-if AC_TRY_EVAL(ac_compile); then
- # Parse the compiler output and extract the necessary
- # objects, libraries and library flags.
-
- # Sentinel used to keep track of whether or not we are before
- # the conftest object file.
- pre_test_object_deps_done=no
-
- # The `*' in the case matches for architectures that use `case' in
- # $output_verbose_cmd can trigger glob expansion during the loop
- # eval without this substitution.
- output_verbose_link_cmd=`$echo "X$output_verbose_link_cmd" | $Xsed -e "$no_glob_subst"`
-
- for p in `eval $output_verbose_link_cmd`; do
- case $p in
-
- -L* | -R* | -l*)
- # Some compilers place space between "-{L,R}" and the path.
- # Remove the space.
- if test $p = "-L" \
- || test $p = "-R"; then
- prev=$p
- continue
- else
- prev=
- fi
-
- if test "$pre_test_object_deps_done" = no; then
- case $p in
- -L* | -R*)
- # Internal compiler library paths should come after those
- # provided the user. The postdeps already come after the
- # user supplied libs so there is no need to process them.
- if test -z "$_LT_AC_TAGVAR(compiler_lib_search_path, $1)"; then
- _LT_AC_TAGVAR(compiler_lib_search_path, $1)="${prev}${p}"
- else
- _LT_AC_TAGVAR(compiler_lib_search_path, $1)="${_LT_AC_TAGVAR(compiler_lib_search_path, $1)} ${prev}${p}"
- fi
- ;;
- # The "-l" case would never come before the object being
- # linked, so don't bother handling this case.
- esac
- else
- if test -z "$_LT_AC_TAGVAR(postdeps, $1)"; then
- _LT_AC_TAGVAR(postdeps, $1)="${prev}${p}"
- else
- _LT_AC_TAGVAR(postdeps, $1)="${_LT_AC_TAGVAR(postdeps, $1)} ${prev}${p}"
- fi
- fi
- ;;
-
- *.$objext)
- # This assumes that the test object file only shows up
- # once in the compiler output.
- if test "$p" = "conftest.$objext"; then
- pre_test_object_deps_done=yes
- continue
- fi
-
- if test "$pre_test_object_deps_done" = no; then
- if test -z "$_LT_AC_TAGVAR(predep_objects, $1)"; then
- _LT_AC_TAGVAR(predep_objects, $1)="$p"
- else
- _LT_AC_TAGVAR(predep_objects, $1)="$_LT_AC_TAGVAR(predep_objects, $1) $p"
- fi
- else
- if test -z "$_LT_AC_TAGVAR(postdep_objects, $1)"; then
- _LT_AC_TAGVAR(postdep_objects, $1)="$p"
- else
- _LT_AC_TAGVAR(postdep_objects, $1)="$_LT_AC_TAGVAR(postdep_objects, $1) $p"
- fi
- fi
- ;;
-
- *) ;; # Ignore the rest.
-
- esac
- done
-
- # Clean up.
- rm -f a.out a.exe
-else
- echo "libtool.m4: error: problem compiling $1 test program"
-fi
-
-$rm -f confest.$objext
-
-# PORTME: override above test on systems where it is broken
-ifelse([$1],[CXX],
-[case $host_os in
-interix3*)
- # Interix 3.5 installs completely hosed .la files for C++, so rather than
- # hack all around it, let's just trust "g++" to DTRT.
- _LT_AC_TAGVAR(predep_objects,$1)=
- _LT_AC_TAGVAR(postdep_objects,$1)=
- _LT_AC_TAGVAR(postdeps,$1)=
- ;;
-
-solaris*)
- case $cc_basename in
- CC*)
- # Adding this requires a known-good setup of shared libraries for
- # Sun compiler versions before 5.6, else PIC objects from an old
- # archive will be linked into the output, leading to subtle bugs.
- _LT_AC_TAGVAR(postdeps,$1)='-lCstd -lCrun'
- ;;
- esac
- ;;
-esac
-])
-
-case " $_LT_AC_TAGVAR(postdeps, $1) " in
-*" -lc "*) _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no ;;
-esac
-])# AC_LIBTOOL_POSTDEP_PREDEP
-
-# AC_LIBTOOL_LANG_F77_CONFIG
-# --------------------------
-# Ensure that the configuration vars for the C compiler are
-# suitably defined. Those variables are subsequently used by
-# AC_LIBTOOL_CONFIG to write the compiler configuration to `libtool'.
-AC_DEFUN([AC_LIBTOOL_LANG_F77_CONFIG], [_LT_AC_LANG_F77_CONFIG(F77)])
-AC_DEFUN([_LT_AC_LANG_F77_CONFIG],
-[AC_REQUIRE([AC_PROG_F77])
-AC_LANG_PUSH(Fortran 77)
-
-_LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no
-_LT_AC_TAGVAR(allow_undefined_flag, $1)=
-_LT_AC_TAGVAR(always_export_symbols, $1)=no
-_LT_AC_TAGVAR(archive_expsym_cmds, $1)=
-_LT_AC_TAGVAR(export_dynamic_flag_spec, $1)=
-_LT_AC_TAGVAR(hardcode_direct, $1)=no
-_LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)=
-_LT_AC_TAGVAR(hardcode_libdir_flag_spec_ld, $1)=
-_LT_AC_TAGVAR(hardcode_libdir_separator, $1)=
-_LT_AC_TAGVAR(hardcode_minus_L, $1)=no
-_LT_AC_TAGVAR(hardcode_automatic, $1)=no
-_LT_AC_TAGVAR(module_cmds, $1)=
-_LT_AC_TAGVAR(module_expsym_cmds, $1)=
-_LT_AC_TAGVAR(link_all_deplibs, $1)=unknown
-_LT_AC_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds
-_LT_AC_TAGVAR(no_undefined_flag, $1)=
-_LT_AC_TAGVAR(whole_archive_flag_spec, $1)=
-_LT_AC_TAGVAR(enable_shared_with_static_runtimes, $1)=no
-
-# Source file extension for f77 test sources.
-ac_ext=f
-
-# Object file extension for compiled f77 test sources.
-objext=o
-_LT_AC_TAGVAR(objext, $1)=$objext
-
-# Code to be used in simple compile tests
-lt_simple_compile_test_code=" subroutine t\n return\n end\n"
-
-# Code to be used in simple link tests
-lt_simple_link_test_code=" program t\n end\n"
-
-# ltmain only uses $CC for tagged configurations so make sure $CC is set.
-_LT_AC_SYS_COMPILER
-
-# save warnings/boilerplate of simple test code
-_LT_COMPILER_BOILERPLATE
-_LT_LINKER_BOILERPLATE
-
-# Allow CC to be a program name with arguments.
-lt_save_CC="$CC"
-CC=${F77-"f77"}
-compiler=$CC
-_LT_AC_TAGVAR(compiler, $1)=$CC
-_LT_CC_BASENAME([$compiler])
-
-AC_MSG_CHECKING([if libtool supports shared libraries])
-AC_MSG_RESULT([$can_build_shared])
-
-AC_MSG_CHECKING([whether to build shared libraries])
-test "$can_build_shared" = "no" && enable_shared=no
-
-# On AIX, shared libraries and static libraries use the same namespace, and
-# are all built from PIC.
-case $host_os in
-aix3*)
- test "$enable_shared" = yes && enable_static=no
- if test -n "$RANLIB"; then
- archive_cmds="$archive_cmds~\$RANLIB \$lib"
- postinstall_cmds='$RANLIB $lib'
- fi
- ;;
-aix4* | aix5*)
- if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then
- test "$enable_shared" = yes && enable_static=no
- fi
- ;;
-esac
-AC_MSG_RESULT([$enable_shared])
-
-AC_MSG_CHECKING([whether to build static libraries])
-# Make sure either enable_shared or enable_static is yes.
-test "$enable_shared" = yes || enable_static=yes
-AC_MSG_RESULT([$enable_static])
-
-_LT_AC_TAGVAR(GCC, $1)="$G77"
-_LT_AC_TAGVAR(LD, $1)="$LD"
-
-AC_LIBTOOL_PROG_COMPILER_PIC($1)
-AC_LIBTOOL_PROG_CC_C_O($1)
-AC_LIBTOOL_SYS_HARD_LINK_LOCKS($1)
-AC_LIBTOOL_PROG_LD_SHLIBS($1)
-AC_LIBTOOL_SYS_DYNAMIC_LINKER($1)
-AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH($1)
-
-AC_LIBTOOL_CONFIG($1)
-
-AC_LANG_POP
-CC="$lt_save_CC"
-])# AC_LIBTOOL_LANG_F77_CONFIG
-
-
-# AC_LIBTOOL_LANG_GCJ_CONFIG
-# --------------------------
-# Ensure that the configuration vars for the C compiler are
-# suitably defined. Those variables are subsequently used by
-# AC_LIBTOOL_CONFIG to write the compiler configuration to `libtool'.
-AC_DEFUN([AC_LIBTOOL_LANG_GCJ_CONFIG], [_LT_AC_LANG_GCJ_CONFIG(GCJ)])
-AC_DEFUN([_LT_AC_LANG_GCJ_CONFIG],
-[AC_LANG_SAVE
-
-# Source file extension for Java test sources.
-ac_ext=java
-
-# Object file extension for compiled Java test sources.
-objext=o
-_LT_AC_TAGVAR(objext, $1)=$objext
-
-# Code to be used in simple compile tests
-lt_simple_compile_test_code="class foo {}\n"
-
-# Code to be used in simple link tests
-lt_simple_link_test_code='public class conftest { public static void main(String[[]] argv) {}; }\n'
-
-# ltmain only uses $CC for tagged configurations so make sure $CC is set.
-_LT_AC_SYS_COMPILER
-
-# save warnings/boilerplate of simple test code
-_LT_COMPILER_BOILERPLATE
-_LT_LINKER_BOILERPLATE
-
-# Allow CC to be a program name with arguments.
-lt_save_CC="$CC"
-CC=${GCJ-"gcj"}
-compiler=$CC
-_LT_AC_TAGVAR(compiler, $1)=$CC
-_LT_CC_BASENAME([$compiler])
-
-# GCJ did not exist at the time GCC didn't implicitly link libc in.
-_LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no
-
-_LT_AC_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds
-
-AC_LIBTOOL_PROG_COMPILER_NO_RTTI($1)
-AC_LIBTOOL_PROG_COMPILER_PIC($1)
-AC_LIBTOOL_PROG_CC_C_O($1)
-AC_LIBTOOL_SYS_HARD_LINK_LOCKS($1)
-AC_LIBTOOL_PROG_LD_SHLIBS($1)
-AC_LIBTOOL_SYS_DYNAMIC_LINKER($1)
-AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH($1)
-
-AC_LIBTOOL_CONFIG($1)
-
-AC_LANG_RESTORE
-CC="$lt_save_CC"
-])# AC_LIBTOOL_LANG_GCJ_CONFIG
-
-
-# AC_LIBTOOL_LANG_RC_CONFIG
-# -------------------------
-# Ensure that the configuration vars for the Windows resource compiler are
-# suitably defined. Those variables are subsequently used by
-# AC_LIBTOOL_CONFIG to write the compiler configuration to `libtool'.
-AC_DEFUN([AC_LIBTOOL_LANG_RC_CONFIG], [_LT_AC_LANG_RC_CONFIG(RC)])
-AC_DEFUN([_LT_AC_LANG_RC_CONFIG],
-[AC_LANG_SAVE
-
-# Source file extension for RC test sources.
-ac_ext=rc
-
-# Object file extension for compiled RC test sources.
-objext=o
-_LT_AC_TAGVAR(objext, $1)=$objext
-
-# Code to be used in simple compile tests
-lt_simple_compile_test_code='sample MENU { MENUITEM "&Soup", 100, CHECKED }\n'
-
-# Code to be used in simple link tests
-lt_simple_link_test_code="$lt_simple_compile_test_code"
-
-# ltmain only uses $CC for tagged configurations so make sure $CC is set.
-_LT_AC_SYS_COMPILER
-
-# save warnings/boilerplate of simple test code
-_LT_COMPILER_BOILERPLATE
-_LT_LINKER_BOILERPLATE
-
-# Allow CC to be a program name with arguments.
-lt_save_CC="$CC"
-CC=${RC-"windres"}
-compiler=$CC
-_LT_AC_TAGVAR(compiler, $1)=$CC
-_LT_CC_BASENAME([$compiler])
-_LT_AC_TAGVAR(lt_cv_prog_compiler_c_o, $1)=yes
-
-AC_LIBTOOL_CONFIG($1)
-
-AC_LANG_RESTORE
-CC="$lt_save_CC"
-])# AC_LIBTOOL_LANG_RC_CONFIG
-
-
-# AC_LIBTOOL_CONFIG([TAGNAME])
-# ----------------------------
-# If TAGNAME is not passed, then create an initial libtool script
-# with a default configuration from the untagged config vars. Otherwise
-# add code to config.status for appending the configuration named by
-# TAGNAME from the matching tagged config vars.
-AC_DEFUN([AC_LIBTOOL_CONFIG],
-[# The else clause should only fire when bootstrapping the
-# libtool distribution, otherwise you forgot to ship ltmain.sh
-# with your package, and you will get complaints that there are
-# no rules to generate ltmain.sh.
-if test -f "$ltmain"; then
- # See if we are running on zsh, and set the options which allow our commands through
- # without removal of \ escapes.
- if test -n "${ZSH_VERSION+set}" ; then
- setopt NO_GLOB_SUBST
- fi
- # Now quote all the things that may contain metacharacters while being
- # careful not to overquote the AC_SUBSTed values. We take copies of the
- # variables and quote the copies for generation of the libtool script.
- for var in echo old_CC old_CFLAGS AR AR_FLAGS EGREP RANLIB LN_S LTCC LTCFLAGS NM \
- SED SHELL STRIP \
- libname_spec library_names_spec soname_spec extract_expsyms_cmds \
- old_striplib striplib file_magic_cmd finish_cmds finish_eval \
- deplibs_check_method reload_flag reload_cmds need_locks \
- lt_cv_sys_global_symbol_pipe lt_cv_sys_global_symbol_to_cdecl \
- lt_cv_sys_global_symbol_to_c_name_address \
- sys_lib_search_path_spec sys_lib_dlsearch_path_spec \
- old_postinstall_cmds old_postuninstall_cmds \
- _LT_AC_TAGVAR(compiler, $1) \
- _LT_AC_TAGVAR(CC, $1) \
- _LT_AC_TAGVAR(LD, $1) \
- _LT_AC_TAGVAR(lt_prog_compiler_wl, $1) \
- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1) \
- _LT_AC_TAGVAR(lt_prog_compiler_static, $1) \
- _LT_AC_TAGVAR(lt_prog_compiler_no_builtin_flag, $1) \
- _LT_AC_TAGVAR(export_dynamic_flag_spec, $1) \
- _LT_AC_TAGVAR(thread_safe_flag_spec, $1) \
- _LT_AC_TAGVAR(whole_archive_flag_spec, $1) \
- _LT_AC_TAGVAR(enable_shared_with_static_runtimes, $1) \
- _LT_AC_TAGVAR(old_archive_cmds, $1) \
- _LT_AC_TAGVAR(old_archive_from_new_cmds, $1) \
- _LT_AC_TAGVAR(predep_objects, $1) \
- _LT_AC_TAGVAR(postdep_objects, $1) \
- _LT_AC_TAGVAR(predeps, $1) \
- _LT_AC_TAGVAR(postdeps, $1) \
- _LT_AC_TAGVAR(compiler_lib_search_path, $1) \
- _LT_AC_TAGVAR(archive_cmds, $1) \
- _LT_AC_TAGVAR(archive_expsym_cmds, $1) \
- _LT_AC_TAGVAR(postinstall_cmds, $1) \
- _LT_AC_TAGVAR(postuninstall_cmds, $1) \
- _LT_AC_TAGVAR(old_archive_from_expsyms_cmds, $1) \
- _LT_AC_TAGVAR(allow_undefined_flag, $1) \
- _LT_AC_TAGVAR(no_undefined_flag, $1) \
- _LT_AC_TAGVAR(export_symbols_cmds, $1) \
- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1) \
- _LT_AC_TAGVAR(hardcode_libdir_flag_spec_ld, $1) \
- _LT_AC_TAGVAR(hardcode_libdir_separator, $1) \
- _LT_AC_TAGVAR(hardcode_automatic, $1) \
- _LT_AC_TAGVAR(module_cmds, $1) \
- _LT_AC_TAGVAR(module_expsym_cmds, $1) \
- _LT_AC_TAGVAR(lt_cv_prog_compiler_c_o, $1) \
- _LT_AC_TAGVAR(exclude_expsyms, $1) \
- _LT_AC_TAGVAR(include_expsyms, $1); do
-
- case $var in
- _LT_AC_TAGVAR(old_archive_cmds, $1) | \
- _LT_AC_TAGVAR(old_archive_from_new_cmds, $1) | \
- _LT_AC_TAGVAR(archive_cmds, $1) | \
- _LT_AC_TAGVAR(archive_expsym_cmds, $1) | \
- _LT_AC_TAGVAR(module_cmds, $1) | \
- _LT_AC_TAGVAR(module_expsym_cmds, $1) | \
- _LT_AC_TAGVAR(old_archive_from_expsyms_cmds, $1) | \
- _LT_AC_TAGVAR(export_symbols_cmds, $1) | \
- extract_expsyms_cmds | reload_cmds | finish_cmds | \
- postinstall_cmds | postuninstall_cmds | \
- old_postinstall_cmds | old_postuninstall_cmds | \
- sys_lib_search_path_spec | sys_lib_dlsearch_path_spec)
- # Double-quote double-evaled strings.
- eval "lt_$var=\\\"\`\$echo \"X\$$var\" | \$Xsed -e \"\$double_quote_subst\" -e \"\$sed_quote_subst\" -e \"\$delay_variable_subst\"\`\\\""
- ;;
- *)
- eval "lt_$var=\\\"\`\$echo \"X\$$var\" | \$Xsed -e \"\$sed_quote_subst\"\`\\\""
- ;;
- esac
- done
-
- case $lt_echo in
- *'\[$]0 --fallback-echo"')
- lt_echo=`$echo "X$lt_echo" | $Xsed -e 's/\\\\\\\[$]0 --fallback-echo"[$]/[$]0 --fallback-echo"/'`
- ;;
- esac
-
-ifelse([$1], [],
- [cfgfile="${ofile}T"
- trap "$rm \"$cfgfile\"; exit 1" 1 2 15
- $rm -f "$cfgfile"
- AC_MSG_NOTICE([creating $ofile])],
- [cfgfile="$ofile"])
-
- cat <<__EOF__ >> "$cfgfile"
-ifelse([$1], [],
-[#! $SHELL
-
-# `$echo "$cfgfile" | sed 's%^.*/%%'` - Provide generalized library-building support services.
-# Generated automatically by $PROGRAM (GNU $PACKAGE $VERSION$TIMESTAMP)
-# NOTE: Changes made to this file will be lost: look at ltmain.sh.
-#
-# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001
-# Free Software Foundation, Inc.
-#
-# This file is part of GNU Libtool:
-# Originally by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-#
-# This program 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 this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-#
-# As a special exception to the GNU General Public License, if you
-# distribute this file as part of a program that contains a
-# configuration script generated by Autoconf, you may include it under
-# the same distribution terms that you use for the rest of that program.
-
-# A sed program that does not truncate output.
-SED=$lt_SED
-
-# Sed that helps us avoid accidentally triggering echo(1) options like -n.
-Xsed="$SED -e 1s/^X//"
-
-# The HP-UX ksh and POSIX shell print the target directory to stdout
-# if CDPATH is set.
-(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
-
-# The names of the tagged configurations supported by this script.
-available_tags=
-
-# ### BEGIN LIBTOOL CONFIG],
-[# ### BEGIN LIBTOOL TAG CONFIG: $tagname])
-
-# Libtool was configured on host `(hostname || uname -n) 2>/dev/null | sed 1q`:
-
-# Shell to use when invoking shell scripts.
-SHELL=$lt_SHELL
-
-# Whether or not to build shared libraries.
-build_libtool_libs=$enable_shared
-
-# Whether or not to build static libraries.
-build_old_libs=$enable_static
-
-# Whether or not to add -lc for building shared libraries.
-build_libtool_need_lc=$_LT_AC_TAGVAR(archive_cmds_need_lc, $1)
-
-# Whether or not to disallow shared libs when runtime libs are static
-allow_libtool_libs_with_static_runtimes=$_LT_AC_TAGVAR(enable_shared_with_static_runtimes, $1)
-
-# Whether or not to optimize for fast installation.
-fast_install=$enable_fast_install
-
-# The host system.
-host_alias=$host_alias
-host=$host
-host_os=$host_os
-
-# The build system.
-build_alias=$build_alias
-build=$build
-build_os=$build_os
-
-# An echo program that does not interpret backslashes.
-echo=$lt_echo
-
-# The archiver.
-AR=$lt_AR
-AR_FLAGS=$lt_AR_FLAGS
-
-# A C compiler.
-LTCC=$lt_LTCC
-
-# LTCC compiler flags.
-LTCFLAGS=$lt_LTCFLAGS
-
-# A language-specific compiler.
-CC=$lt_[]_LT_AC_TAGVAR(compiler, $1)
-
-# Is the compiler the GNU C compiler?
-with_gcc=$_LT_AC_TAGVAR(GCC, $1)
-
-# An ERE matcher.
-EGREP=$lt_EGREP
-
-# The linker used to build libraries.
-LD=$lt_[]_LT_AC_TAGVAR(LD, $1)
-
-# Whether we need hard or soft links.
-LN_S=$lt_LN_S
-
-# A BSD-compatible nm program.
-NM=$lt_NM
-
-# A symbol stripping program
-STRIP=$lt_STRIP
-
-# Used to examine libraries when file_magic_cmd begins "file"
-MAGIC_CMD=$MAGIC_CMD
-
-# Used on cygwin: DLL creation program.
-DLLTOOL="$DLLTOOL"
-
-# Used on cygwin: object dumper.
-OBJDUMP="$OBJDUMP"
-
-# Used on cygwin: assembler.
-AS="$AS"
-
-# The name of the directory that contains temporary libtool files.
-objdir=$objdir
-
-# How to create reloadable object files.
-reload_flag=$lt_reload_flag
-reload_cmds=$lt_reload_cmds
-
-# How to pass a linker flag through the compiler.
-wl=$lt_[]_LT_AC_TAGVAR(lt_prog_compiler_wl, $1)
-
-# Object file suffix (normally "o").
-objext="$ac_objext"
-
-# Old archive suffix (normally "a").
-libext="$libext"
-
-# Shared library suffix (normally ".so").
-shrext_cmds='$shrext_cmds'
-
-# Executable file suffix (normally "").
-exeext="$exeext"
-
-# Additional compiler flags for building library objects.
-pic_flag=$lt_[]_LT_AC_TAGVAR(lt_prog_compiler_pic, $1)
-pic_mode=$pic_mode
-
-# What is the maximum length of a command?
-max_cmd_len=$lt_cv_sys_max_cmd_len
-
-# Does compiler simultaneously support -c and -o options?
-compiler_c_o=$lt_[]_LT_AC_TAGVAR(lt_cv_prog_compiler_c_o, $1)
-
-# Must we lock files when doing compilation?
-need_locks=$lt_need_locks
-
-# Do we need the lib prefix for modules?
-need_lib_prefix=$need_lib_prefix
-
-# Do we need a version for libraries?
-need_version=$need_version
-
-# Whether dlopen is supported.
-dlopen_support=$enable_dlopen
-
-# Whether dlopen of programs is supported.
-dlopen_self=$enable_dlopen_self
-
-# Whether dlopen of statically linked programs is supported.
-dlopen_self_static=$enable_dlopen_self_static
-
-# Compiler flag to prevent dynamic linking.
-link_static_flag=$lt_[]_LT_AC_TAGVAR(lt_prog_compiler_static, $1)
-
-# Compiler flag to turn off builtin functions.
-no_builtin_flag=$lt_[]_LT_AC_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)
-
-# Compiler flag to allow reflexive dlopens.
-export_dynamic_flag_spec=$lt_[]_LT_AC_TAGVAR(export_dynamic_flag_spec, $1)
-
-# Compiler flag to generate shared objects directly from archives.
-whole_archive_flag_spec=$lt_[]_LT_AC_TAGVAR(whole_archive_flag_spec, $1)
-
-# Compiler flag to generate thread-safe objects.
-thread_safe_flag_spec=$lt_[]_LT_AC_TAGVAR(thread_safe_flag_spec, $1)
-
-# Library versioning type.
-version_type=$version_type
-
-# Format of library name prefix.
-libname_spec=$lt_libname_spec
-
-# List of archive names. First name is the real one, the rest are links.
-# The last name is the one that the linker finds with -lNAME.
-library_names_spec=$lt_library_names_spec
-
-# The coded name of the library, if different from the real name.
-soname_spec=$lt_soname_spec
-
-# Commands used to build and install an old-style archive.
-RANLIB=$lt_RANLIB
-old_archive_cmds=$lt_[]_LT_AC_TAGVAR(old_archive_cmds, $1)
-old_postinstall_cmds=$lt_old_postinstall_cmds
-old_postuninstall_cmds=$lt_old_postuninstall_cmds
-
-# Create an old-style archive from a shared archive.
-old_archive_from_new_cmds=$lt_[]_LT_AC_TAGVAR(old_archive_from_new_cmds, $1)
-
-# Create a temporary old-style archive to link instead of a shared archive.
-old_archive_from_expsyms_cmds=$lt_[]_LT_AC_TAGVAR(old_archive_from_expsyms_cmds, $1)
-
-# Commands used to build and install a shared archive.
-archive_cmds=$lt_[]_LT_AC_TAGVAR(archive_cmds, $1)
-archive_expsym_cmds=$lt_[]_LT_AC_TAGVAR(archive_expsym_cmds, $1)
-postinstall_cmds=$lt_postinstall_cmds
-postuninstall_cmds=$lt_postuninstall_cmds
-
-# Commands used to build a loadable module (assumed same as above if empty)
-module_cmds=$lt_[]_LT_AC_TAGVAR(module_cmds, $1)
-module_expsym_cmds=$lt_[]_LT_AC_TAGVAR(module_expsym_cmds, $1)
-
-# Commands to strip libraries.
-old_striplib=$lt_old_striplib
-striplib=$lt_striplib
-
-# Dependencies to place before the objects being linked to create a
-# shared library.
-predep_objects=$lt_[]_LT_AC_TAGVAR(predep_objects, $1)
-
-# Dependencies to place after the objects being linked to create a
-# shared library.
-postdep_objects=$lt_[]_LT_AC_TAGVAR(postdep_objects, $1)
-
-# Dependencies to place before the objects being linked to create a
-# shared library.
-predeps=$lt_[]_LT_AC_TAGVAR(predeps, $1)
-
-# Dependencies to place after the objects being linked to create a
-# shared library.
-postdeps=$lt_[]_LT_AC_TAGVAR(postdeps, $1)
-
-# The library search path used internally by the compiler when linking
-# a shared library.
-compiler_lib_search_path=$lt_[]_LT_AC_TAGVAR(compiler_lib_search_path, $1)
-
-# Method to check whether dependent libraries are shared objects.
-deplibs_check_method=$lt_deplibs_check_method
-
-# Command to use when deplibs_check_method == file_magic.
-file_magic_cmd=$lt_file_magic_cmd
-
-# Flag that allows shared libraries with undefined symbols to be built.
-allow_undefined_flag=$lt_[]_LT_AC_TAGVAR(allow_undefined_flag, $1)
-
-# Flag that forces no undefined symbols.
-no_undefined_flag=$lt_[]_LT_AC_TAGVAR(no_undefined_flag, $1)
-
-# Commands used to finish a libtool library installation in a directory.
-finish_cmds=$lt_finish_cmds
-
-# Same as above, but a single script fragment to be evaled but not shown.
-finish_eval=$lt_finish_eval
-
-# Take the output of nm and produce a listing of raw symbols and C names.
-global_symbol_pipe=$lt_lt_cv_sys_global_symbol_pipe
-
-# Transform the output of nm in a proper C declaration
-global_symbol_to_cdecl=$lt_lt_cv_sys_global_symbol_to_cdecl
-
-# Transform the output of nm in a C name address pair
-global_symbol_to_c_name_address=$lt_lt_cv_sys_global_symbol_to_c_name_address
-
-# This is the shared library runtime path variable.
-runpath_var=$runpath_var
-
-# This is the shared library path variable.
-shlibpath_var=$shlibpath_var
-
-# Is shlibpath searched before the hard-coded library search path?
-shlibpath_overrides_runpath=$shlibpath_overrides_runpath
-
-# How to hardcode a shared library path into an executable.
-hardcode_action=$_LT_AC_TAGVAR(hardcode_action, $1)
-
-# Whether we should hardcode library paths into libraries.
-hardcode_into_libs=$hardcode_into_libs
-
-# Flag to hardcode \$libdir into a binary during linking.
-# This must work even if \$libdir does not exist.
-hardcode_libdir_flag_spec=$lt_[]_LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)
-
-# If ld is used when linking, flag to hardcode \$libdir into
-# a binary during linking. This must work even if \$libdir does
-# not exist.
-hardcode_libdir_flag_spec_ld=$lt_[]_LT_AC_TAGVAR(hardcode_libdir_flag_spec_ld, $1)
-
-# Whether we need a single -rpath flag with a separated argument.
-hardcode_libdir_separator=$lt_[]_LT_AC_TAGVAR(hardcode_libdir_separator, $1)
-
-# Set to yes if using DIR/libNAME${shared_ext} during linking hardcodes DIR into the
-# resulting binary.
-hardcode_direct=$_LT_AC_TAGVAR(hardcode_direct, $1)
-
-# Set to yes if using the -LDIR flag during linking hardcodes DIR into the
-# resulting binary.
-hardcode_minus_L=$_LT_AC_TAGVAR(hardcode_minus_L, $1)
-
-# Set to yes if using SHLIBPATH_VAR=DIR during linking hardcodes DIR into
-# the resulting binary.
-hardcode_shlibpath_var=$_LT_AC_TAGVAR(hardcode_shlibpath_var, $1)
-
-# Set to yes if building a shared library automatically hardcodes DIR into the library
-# and all subsequent libraries and executables linked against it.
-hardcode_automatic=$_LT_AC_TAGVAR(hardcode_automatic, $1)
-
-# Variables whose values should be saved in libtool wrapper scripts and
-# restored at relink time.
-variables_saved_for_relink="$variables_saved_for_relink"
-
-# Whether libtool must link a program against all its dependency libraries.
-link_all_deplibs=$_LT_AC_TAGVAR(link_all_deplibs, $1)
-
-# Compile-time system search path for libraries
-sys_lib_search_path_spec=$lt_sys_lib_search_path_spec
-
-# Run-time system search path for libraries
-sys_lib_dlsearch_path_spec=$lt_sys_lib_dlsearch_path_spec
-
-# Fix the shell variable \$srcfile for the compiler.
-fix_srcfile_path="$_LT_AC_TAGVAR(fix_srcfile_path, $1)"
-
-# Set to yes if exported symbols are required.
-always_export_symbols=$_LT_AC_TAGVAR(always_export_symbols, $1)
-
-# The commands to list exported symbols.
-export_symbols_cmds=$lt_[]_LT_AC_TAGVAR(export_symbols_cmds, $1)
-
-# The commands to extract the exported symbol list from a shared archive.
-extract_expsyms_cmds=$lt_extract_expsyms_cmds
-
-# Symbols that should not be listed in the preloaded symbols.
-exclude_expsyms=$lt_[]_LT_AC_TAGVAR(exclude_expsyms, $1)
-
-# Symbols that must always be exported.
-include_expsyms=$lt_[]_LT_AC_TAGVAR(include_expsyms, $1)
-
-ifelse([$1],[],
-[# ### END LIBTOOL CONFIG],
-[# ### END LIBTOOL TAG CONFIG: $tagname])
-
-__EOF__
-
-ifelse([$1],[], [
- case $host_os in
- aix3*)
- cat <<\EOF >> "$cfgfile"
-
-# AIX sometimes has problems with the GCC collect2 program. For some
-# reason, if we set the COLLECT_NAMES environment variable, the problems
-# vanish in a puff of smoke.
-if test "X${COLLECT_NAMES+set}" != Xset; then
- COLLECT_NAMES=
- export COLLECT_NAMES
-fi
-EOF
- ;;
- esac
-
- # We use sed instead of cat because bash on DJGPP gets confused if
- # if finds mixed CR/LF and LF-only lines. Since sed operates in
- # text mode, it properly converts lines to CR/LF. This bash problem
- # is reportedly fixed, but why not run on old versions too?
- sed '$q' "$ltmain" >> "$cfgfile" || (rm -f "$cfgfile"; exit 1)
-
- mv -f "$cfgfile" "$ofile" || \
- (rm -f "$ofile" && cp "$cfgfile" "$ofile" && rm -f "$cfgfile")
- chmod +x "$ofile"
-])
-else
- # If there is no Makefile yet, we rely on a make rule to execute
- # `config.status --recheck' to rerun these tests and create the
- # libtool script then.
- ltmain_in=`echo $ltmain | sed -e 's/\.sh$/.in/'`
- if test -f "$ltmain_in"; then
- test -f Makefile && make "$ltmain"
- fi
-fi
-])# AC_LIBTOOL_CONFIG
-
-
-# AC_LIBTOOL_PROG_COMPILER_NO_RTTI([TAGNAME])
-# -------------------------------------------
-AC_DEFUN([AC_LIBTOOL_PROG_COMPILER_NO_RTTI],
-[AC_REQUIRE([_LT_AC_SYS_COMPILER])dnl
-
-_LT_AC_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=
-
-if test "$GCC" = yes; then
- _LT_AC_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=' -fno-builtin'
-
- AC_LIBTOOL_COMPILER_OPTION([if $compiler supports -fno-rtti -fno-exceptions],
- lt_cv_prog_compiler_rtti_exceptions,
- [-fno-rtti -fno-exceptions], [],
- [_LT_AC_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)="$_LT_AC_TAGVAR(lt_prog_compiler_no_builtin_flag, $1) -fno-rtti -fno-exceptions"])
-fi
-])# AC_LIBTOOL_PROG_COMPILER_NO_RTTI
-
-
-# AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE
-# ---------------------------------
-AC_DEFUN([AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE],
-[AC_REQUIRE([AC_CANONICAL_HOST])
-AC_REQUIRE([AC_PROG_NM])
-AC_REQUIRE([AC_OBJEXT])
-# Check for command to grab the raw symbol name followed by C symbol from nm.
-AC_MSG_CHECKING([command to parse $NM output from $compiler object])
-AC_CACHE_VAL([lt_cv_sys_global_symbol_pipe],
-[
-# These are sane defaults that work on at least a few old systems.
-# [They come from Ultrix. What could be older than Ultrix?!! ;)]
-
-# Character class describing NM global symbol codes.
-symcode='[[BCDEGRST]]'
-
-# Regexp to match symbols that can be accessed directly from C.
-sympat='\([[_A-Za-z]][[_A-Za-z0-9]]*\)'
-
-# Transform an extracted symbol line into a proper C declaration
-lt_cv_sys_global_symbol_to_cdecl="sed -n -e 's/^. .* \(.*\)$/extern int \1;/p'"
-
-# Transform an extracted symbol line into symbol name and symbol address
-lt_cv_sys_global_symbol_to_c_name_address="sed -n -e 's/^: \([[^ ]]*\) $/ {\\\"\1\\\", (lt_ptr) 0},/p' -e 's/^$symcode \([[^ ]]*\) \([[^ ]]*\)$/ {\"\2\", (lt_ptr) \&\2},/p'"
-
-# Define system-specific variables.
-case $host_os in
-aix*)
- symcode='[[BCDT]]'
- ;;
-cygwin* | mingw* | pw32*)
- symcode='[[ABCDGISTW]]'
- ;;
-hpux*) # Its linker distinguishes data from code symbols
- if test "$host_cpu" = ia64; then
- symcode='[[ABCDEGRST]]'
- fi
- lt_cv_sys_global_symbol_to_cdecl="sed -n -e 's/^T .* \(.*\)$/extern int \1();/p' -e 's/^$symcode* .* \(.*\)$/extern char \1;/p'"
- lt_cv_sys_global_symbol_to_c_name_address="sed -n -e 's/^: \([[^ ]]*\) $/ {\\\"\1\\\", (lt_ptr) 0},/p' -e 's/^$symcode* \([[^ ]]*\) \([[^ ]]*\)$/ {\"\2\", (lt_ptr) \&\2},/p'"
- ;;
-linux*)
- if test "$host_cpu" = ia64; then
- symcode='[[ABCDGIRSTW]]'
- lt_cv_sys_global_symbol_to_cdecl="sed -n -e 's/^T .* \(.*\)$/extern int \1();/p' -e 's/^$symcode* .* \(.*\)$/extern char \1;/p'"
- lt_cv_sys_global_symbol_to_c_name_address="sed -n -e 's/^: \([[^ ]]*\) $/ {\\\"\1\\\", (lt_ptr) 0},/p' -e 's/^$symcode* \([[^ ]]*\) \([[^ ]]*\)$/ {\"\2\", (lt_ptr) \&\2},/p'"
- fi
- ;;
-irix* | nonstopux*)
- symcode='[[BCDEGRST]]'
- ;;
-osf*)
- symcode='[[BCDEGQRST]]'
- ;;
-solaris*)
- symcode='[[BDRT]]'
- ;;
-sco3.2v5*)
- symcode='[[DT]]'
- ;;
-sysv4.2uw2*)
- symcode='[[DT]]'
- ;;
-sysv5* | sco5v6* | unixware* | OpenUNIX*)
- symcode='[[ABDT]]'
- ;;
-sysv4)
- symcode='[[DFNSTU]]'
- ;;
-esac
-
-# Handle CRLF in mingw tool chain
-opt_cr=
-case $build_os in
-mingw*)
- opt_cr=`echo 'x\{0,1\}' | tr x '\015'` # option cr in regexp
- ;;
-esac
-
-# If we're using GNU nm, then use its standard symbol codes.
-case `$NM -V 2>&1` in
-*GNU* | *'with BFD'*)
- symcode='[[ABCDGIRSTW]]' ;;
-esac
-
-# Try without a prefix undercore, then with it.
-for ac_symprfx in "" "_"; do
-
- # Transform symcode, sympat, and symprfx into a raw symbol and a C symbol.
- symxfrm="\\1 $ac_symprfx\\2 \\2"
-
- # Write the raw and C identifiers.
- lt_cv_sys_global_symbol_pipe="sed -n -e 's/^.*[[ ]]\($symcode$symcode*\)[[ ]][[ ]]*$ac_symprfx$sympat$opt_cr$/$symxfrm/p'"
-
- # Check to see that the pipe works correctly.
- pipe_works=no
-
- rm -f conftest*
- cat > conftest.$ac_ext <<EOF
-#ifdef __cplusplus
-extern "C" {
-#endif
-char nm_test_var;
-void nm_test_func(){}
-#ifdef __cplusplus
-}
-#endif
-int main(){nm_test_var='a';nm_test_func();return(0);}
-EOF
-
- if AC_TRY_EVAL(ac_compile); then
- # Now try to grab the symbols.
- nlist=conftest.nm
- if AC_TRY_EVAL(NM conftest.$ac_objext \| $lt_cv_sys_global_symbol_pipe \> $nlist) && test -s "$nlist"; then
- # Try sorting and uniquifying the output.
- if sort "$nlist" | uniq > "$nlist"T; then
- mv -f "$nlist"T "$nlist"
- else
- rm -f "$nlist"T
- fi
-
- # Make sure that we snagged all the symbols we need.
- if grep ' nm_test_var$' "$nlist" >/dev/null; then
- if grep ' nm_test_func$' "$nlist" >/dev/null; then
- cat <<EOF > conftest.$ac_ext
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-EOF
- # Now generate the symbol file.
- eval "$lt_cv_sys_global_symbol_to_cdecl"' < "$nlist" | grep -v main >> conftest.$ac_ext'
-
- cat <<EOF >> conftest.$ac_ext
-#if defined (__STDC__) && __STDC__
-# define lt_ptr_t void *
-#else
-# define lt_ptr_t char *
-# define const
-#endif
-
-/* The mapping between symbol names and symbols. */
-const struct {
- const char *name;
- lt_ptr_t address;
-}
-lt_preloaded_symbols[[]] =
-{
-EOF
- $SED "s/^$symcode$symcode* \(.*\) \(.*\)$/ {\"\2\", (lt_ptr_t) \&\2},/" < "$nlist" | grep -v main >> conftest.$ac_ext
- cat <<\EOF >> conftest.$ac_ext
- {0, (lt_ptr_t) 0}
-};
-
-#ifdef __cplusplus
-}
-#endif
-EOF
- # Now try linking the two files.
- mv conftest.$ac_objext conftstm.$ac_objext
- lt_save_LIBS="$LIBS"
- lt_save_CFLAGS="$CFLAGS"
- LIBS="conftstm.$ac_objext"
- CFLAGS="$CFLAGS$_LT_AC_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)"
- if AC_TRY_EVAL(ac_link) && test -s conftest${ac_exeext}; then
- pipe_works=yes
- fi
- LIBS="$lt_save_LIBS"
- CFLAGS="$lt_save_CFLAGS"
- else
- echo "cannot find nm_test_func in $nlist" >&AS_MESSAGE_LOG_FD
- fi
- else
- echo "cannot find nm_test_var in $nlist" >&AS_MESSAGE_LOG_FD
- fi
- else
- echo "cannot run $lt_cv_sys_global_symbol_pipe" >&AS_MESSAGE_LOG_FD
- fi
- else
- echo "$progname: failed program was:" >&AS_MESSAGE_LOG_FD
- cat conftest.$ac_ext >&5
- fi
- rm -f conftest* conftst*
-
- # Do not use the global_symbol_pipe unless it works.
- if test "$pipe_works" = yes; then
- break
- else
- lt_cv_sys_global_symbol_pipe=
- fi
-done
-])
-if test -z "$lt_cv_sys_global_symbol_pipe"; then
- lt_cv_sys_global_symbol_to_cdecl=
-fi
-if test -z "$lt_cv_sys_global_symbol_pipe$lt_cv_sys_global_symbol_to_cdecl"; then
- AC_MSG_RESULT(failed)
-else
- AC_MSG_RESULT(ok)
-fi
-]) # AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE
-
-
-# AC_LIBTOOL_PROG_COMPILER_PIC([TAGNAME])
-# ---------------------------------------
-AC_DEFUN([AC_LIBTOOL_PROG_COMPILER_PIC],
-[_LT_AC_TAGVAR(lt_prog_compiler_wl, $1)=
-_LT_AC_TAGVAR(lt_prog_compiler_pic, $1)=
-_LT_AC_TAGVAR(lt_prog_compiler_static, $1)=
-
-AC_MSG_CHECKING([for $compiler option to produce PIC])
- ifelse([$1],[CXX],[
- # C++ specific cases for pic, static, wl, etc.
- if test "$GXX" = yes; then
- _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
- _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-static'
-
- case $host_os in
- aix*)
- # All AIX code is PIC.
- if test "$host_cpu" = ia64; then
- # AIX 5 now supports IA64 processor
- _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
- fi
- ;;
- amigaos*)
- # FIXME: we need at least 68020 code to build shared libraries, but
- # adding the `-m68020' flag to GCC prevents building anything better,
- # like `-m68040'.
- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-m68020 -resident32 -malways-restore-a4'
- ;;
- beos* | cygwin* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*)
- # PIC is the default for these OSes.
- ;;
- mingw* | os2* | pw32*)
- # This hack is so that the source file can tell whether it is being
- # built for inclusion in a dll (and should export symbols for example).
- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT'
- ;;
- darwin* | rhapsody*)
- # PIC is the default on this platform
- # Common symbols not allowed in MH_DYLIB files
- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-fno-common'
- ;;
- *djgpp*)
- # DJGPP does not support shared libraries at all
- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)=
- ;;
- interix3*)
- # Interix 3.x gcc -fpic/-fPIC options generate broken code.
- # Instead, we relocate shared libraries at runtime.
- ;;
- sysv4*MP*)
- if test -d /usr/nec; then
- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)=-Kconform_pic
- fi
- ;;
- hpux*)
- # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but
- # not for PA HP-UX.
- case $host_cpu in
- hppa*64*|ia64*)
- ;;
- *)
- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
- ;;
- esac
- ;;
- *)
- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
- ;;
- esac
- else
- case $host_os in
- aix4* | aix5*)
- # All AIX code is PIC.
- if test "$host_cpu" = ia64; then
- # AIX 5 now supports IA64 processor
- _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
- else
- _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-bnso -bI:/lib/syscalls.exp'
- fi
- ;;
- chorus*)
- case $cc_basename in
- cxch68*)
- # Green Hills C++ Compiler
- # _LT_AC_TAGVAR(lt_prog_compiler_static, $1)="--no_auto_instantiation -u __main -u __premain -u _abort -r $COOL_DIR/lib/libOrb.a $MVME_DIR/lib/CC/libC.a $MVME_DIR/lib/classix/libcx.s.a"
- ;;
- esac
- ;;
- darwin*)
- # PIC is the default on this platform
- # Common symbols not allowed in MH_DYLIB files
- case $cc_basename in
- xlc*)
- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-qnocommon'
- _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
- ;;
- esac
- ;;
- dgux*)
- case $cc_basename in
- ec++*)
- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
- ;;
- ghcx*)
- # Green Hills C++ Compiler
- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-pic'
- ;;
- *)
- ;;
- esac
- ;;
- freebsd* | kfreebsd*-gnu | dragonfly*)
- # FreeBSD uses GNU C++
- ;;
- hpux9* | hpux10* | hpux11*)
- case $cc_basename in
- CC*)
- _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
- _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='${wl}-a ${wl}archive'
- if test "$host_cpu" != ia64; then
- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='+Z'
- fi
- ;;
- aCC*)
- _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
- _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='${wl}-a ${wl}archive'
- case $host_cpu in
- hppa*64*|ia64*)
- # +Z the default
- ;;
- *)
- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='+Z'
- ;;
- esac
- ;;
- *)
- ;;
- esac
- ;;
- interix*)
- # This is c89, which is MS Visual C++ (no shared libs)
- # Anyone wants to do a port?
- ;;
- irix5* | irix6* | nonstopux*)
- case $cc_basename in
- CC*)
- _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
- _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-non_shared'
- # CC pic flag -KPIC is the default.
- ;;
- *)
- ;;
- esac
- ;;
- linux*)
- case $cc_basename in
- KCC*)
- # KAI C++ Compiler
- _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='--backend -Wl,'
- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
- ;;
- icpc* | ecpc*)
- # Intel C++
- _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
- _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-static'
- ;;
- pgCC*)
- # Portland Group C++ compiler.
- _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-fpic'
- _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
- ;;
- cxx*)
- # Compaq C++
- # Make sure the PIC flag is empty. It appears that all Alpha
- # Linux and Compaq Tru64 Unix objects are PIC.
- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)=
- _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-non_shared'
- ;;
- *)
- ;;
- esac
- ;;
- lynxos*)
- ;;
- m88k*)
- ;;
- mvs*)
- case $cc_basename in
- cxx*)
- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-W c,exportall'
- ;;
- *)
- ;;
- esac
- ;;
- netbsd* | netbsdelf*-gnu | knetbsd*-gnu)
- ;;
- osf3* | osf4* | osf5*)
- case $cc_basename in
- KCC*)
- _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='--backend -Wl,'
- ;;
- RCC*)
- # Rational C++ 2.4.1
- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-pic'
- ;;
- cxx*)
- # Digital/Compaq C++
- _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
- # Make sure the PIC flag is empty. It appears that all Alpha
- # Linux and Compaq Tru64 Unix objects are PIC.
- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)=
- _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-non_shared'
- ;;
- *)
- ;;
- esac
- ;;
- psos*)
- ;;
- solaris*)
- case $cc_basename in
- CC*)
- # Sun C++ 4.2, 5.x and Centerline C++
- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
- _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
- _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld '
- ;;
- gcx*)
- # Green Hills C++ Compiler
- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-PIC'
- ;;
- *)
- ;;
- esac
- ;;
- sunos4*)
- case $cc_basename in
- CC*)
- # Sun C++ 4.x
- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-pic'
- _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
- ;;
- lcc*)
- # Lucid
- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-pic'
- ;;
- *)
- ;;
- esac
- ;;
- tandem*)
- case $cc_basename in
- NCC*)
- # NonStop-UX NCC 3.20
- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
- ;;
- *)
- ;;
- esac
- ;;
- sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*)
- case $cc_basename in
- CC*)
- _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
- _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
- ;;
- esac
- ;;
- vxworks*)
- ;;
- *)
- _LT_AC_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no
- ;;
- esac
- fi
-],
-[
- if test "$GCC" = yes; then
- _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
- _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-static'
-
- case $host_os in
- aix*)
- # All AIX code is PIC.
- if test "$host_cpu" = ia64; then
- # AIX 5 now supports IA64 processor
- _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
- fi
- ;;
-
- amigaos*)
- # FIXME: we need at least 68020 code to build shared libraries, but
- # adding the `-m68020' flag to GCC prevents building anything better,
- # like `-m68040'.
- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-m68020 -resident32 -malways-restore-a4'
- ;;
-
- beos* | cygwin* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*)
- # PIC is the default for these OSes.
- ;;
-
- mingw* | pw32* | os2*)
- # This hack is so that the source file can tell whether it is being
- # built for inclusion in a dll (and should export symbols for example).
- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT'
- ;;
-
- darwin* | rhapsody*)
- # PIC is the default on this platform
- # Common symbols not allowed in MH_DYLIB files
- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-fno-common'
- ;;
-
- interix3*)
- # Interix 3.x gcc -fpic/-fPIC options generate broken code.
- # Instead, we relocate shared libraries at runtime.
- ;;
-
- msdosdjgpp*)
- # Just because we use GCC doesn't mean we suddenly get shared libraries
- # on systems that don't support them.
- _LT_AC_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no
- enable_shared=no
- ;;
-
- sysv4*MP*)
- if test -d /usr/nec; then
- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)=-Kconform_pic
- fi
- ;;
-
- hpux*)
- # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but
- # not for PA HP-UX.
- case $host_cpu in
- hppa*64*|ia64*)
- # +Z the default
- ;;
- *)
- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
- ;;
- esac
- ;;
-
- *)
- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
- ;;
- esac
- else
- # PORTME Check for flag to pass linker flags through the system compiler.
- case $host_os in
- aix*)
- _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
- if test "$host_cpu" = ia64; then
- # AIX 5 now supports IA64 processor
- _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
- else
- _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-bnso -bI:/lib/syscalls.exp'
- fi
- ;;
- darwin*)
- # PIC is the default on this platform
- # Common symbols not allowed in MH_DYLIB files
- case $cc_basename in
- xlc*)
- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-qnocommon'
- _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
- ;;
- esac
- ;;
-
- mingw* | pw32* | os2*)
- # This hack is so that the source file can tell whether it is being
- # built for inclusion in a dll (and should export symbols for example).
- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT'
- ;;
-
- hpux9* | hpux10* | hpux11*)
- _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
- # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but
- # not for PA HP-UX.
- case $host_cpu in
- hppa*64*|ia64*)
- # +Z the default
- ;;
- *)
- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='+Z'
- ;;
- esac
- # Is there a better lt_prog_compiler_static that works with the bundled CC?
- _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='${wl}-a ${wl}archive'
- ;;
-
- irix5* | irix6* | nonstopux*)
- _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
- # PIC (with -KPIC) is the default.
- _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-non_shared'
- ;;
-
- newsos6)
- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
- _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
- ;;
-
- linux*)
- case $cc_basename in
- icc* | ecc*)
- _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
- _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-static'
- ;;
- pgcc* | pgf77* | pgf90* | pgf95*)
- # Portland Group compilers (*not* the Pentium gcc compiler,
- # which looks to be a dead project)
- _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-fpic'
- _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
- ;;
- ccc*)
- _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
- # All Alpha code is PIC.
- _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-non_shared'
- ;;
- esac
- ;;
-
- osf3* | osf4* | osf5*)
- _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
- # All OSF/1 code is PIC.
- _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-non_shared'
- ;;
-
- solaris*)
- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
- _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
- case $cc_basename in
- f77* | f90* | f95*)
- _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld ';;
- *)
- _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,';;
- esac
- ;;
-
- sunos4*)
- _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld '
- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-PIC'
- _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
- ;;
-
- sysv4 | sysv4.2uw2* | sysv4.3*)
- _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
- _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
- ;;
-
- sysv4*MP*)
- if test -d /usr/nec ;then
- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-Kconform_pic'
- _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
- fi
- ;;
-
- sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*)
- _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
- _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
- ;;
-
- unicos*)
- _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
- _LT_AC_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no
- ;;
-
- uts4*)
- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-pic'
- _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
- ;;
-
- *)
- _LT_AC_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no
- ;;
- esac
- fi
-])
-AC_MSG_RESULT([$_LT_AC_TAGVAR(lt_prog_compiler_pic, $1)])
-
-#
-# Check to make sure the PIC flag actually works.
-#
-if test -n "$_LT_AC_TAGVAR(lt_prog_compiler_pic, $1)"; then
- AC_LIBTOOL_COMPILER_OPTION([if $compiler PIC flag $_LT_AC_TAGVAR(lt_prog_compiler_pic, $1) works],
- _LT_AC_TAGVAR(lt_prog_compiler_pic_works, $1),
- [$_LT_AC_TAGVAR(lt_prog_compiler_pic, $1)ifelse([$1],[],[ -DPIC],[ifelse([$1],[CXX],[ -DPIC],[])])], [],
- [case $_LT_AC_TAGVAR(lt_prog_compiler_pic, $1) in
- "" | " "*) ;;
- *) _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)=" $_LT_AC_TAGVAR(lt_prog_compiler_pic, $1)" ;;
- esac],
- [_LT_AC_TAGVAR(lt_prog_compiler_pic, $1)=
- _LT_AC_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no])
-fi
-case $host_os in
- # For platforms which do not support PIC, -DPIC is meaningless:
- *djgpp*)
- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)=
- ;;
- *)
- _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)="$_LT_AC_TAGVAR(lt_prog_compiler_pic, $1)ifelse([$1],[],[ -DPIC],[ifelse([$1],[CXX],[ -DPIC],[])])"
- ;;
-esac
-
-#
-# Check to make sure the static flag actually works.
-#
-wl=$_LT_AC_TAGVAR(lt_prog_compiler_wl, $1) eval lt_tmp_static_flag=\"$_LT_AC_TAGVAR(lt_prog_compiler_static, $1)\"
-AC_LIBTOOL_LINKER_OPTION([if $compiler static flag $lt_tmp_static_flag works],
- _LT_AC_TAGVAR(lt_prog_compiler_static_works, $1),
- $lt_tmp_static_flag,
- [],
- [_LT_AC_TAGVAR(lt_prog_compiler_static, $1)=])
-])
-
-
-# AC_LIBTOOL_PROG_LD_SHLIBS([TAGNAME])
-# ------------------------------------
-# See if the linker supports building shared libraries.
-AC_DEFUN([AC_LIBTOOL_PROG_LD_SHLIBS],
-[AC_MSG_CHECKING([whether the $compiler linker ($LD) supports shared libraries])
-ifelse([$1],[CXX],[
- _LT_AC_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols'
- case $host_os in
- aix4* | aix5*)
- # If we're using GNU nm, then we don't want the "-C" option.
- # -C means demangle to AIX nm, but means don't demangle with GNU nm
- if $NM -V 2>&1 | grep 'GNU' > /dev/null; then
- _LT_AC_TAGVAR(export_symbols_cmds, $1)='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\[$]2 == "T") || (\[$]2 == "D") || (\[$]2 == "B")) && ([substr](\[$]3,1,1) != ".")) { print \[$]3 } }'\'' | sort -u > $export_symbols'
- else
- _LT_AC_TAGVAR(export_symbols_cmds, $1)='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\[$]2 == "T") || (\[$]2 == "D") || (\[$]2 == "B")) && ([substr](\[$]3,1,1) != ".")) { print \[$]3 } }'\'' | sort -u > $export_symbols'
- fi
- ;;
- pw32*)
- _LT_AC_TAGVAR(export_symbols_cmds, $1)="$ltdll_cmds"
- ;;
- cygwin* | mingw*)
- _LT_AC_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[[BCDGRS]] /s/.* \([[^ ]]*\)/\1 DATA/;/^.* __nm__/s/^.* __nm__\([[^ ]]*\) [[^ ]]*/\1 DATA/;/^I /d;/^[[AITW]] /s/.* //'\'' | sort | uniq > $export_symbols'
- ;;
- kfreebsd*-gnu)
- _LT_AC_TAGVAR(link_all_deplibs, $1)=no
- ;;
- linux*)
- _LT_AC_TAGVAR(link_all_deplibs, $1)=no
- ;;
- *)
- _LT_AC_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols'
- ;;
- esac
-],[
- runpath_var=
- _LT_AC_TAGVAR(allow_undefined_flag, $1)=
- _LT_AC_TAGVAR(enable_shared_with_static_runtimes, $1)=no
- _LT_AC_TAGVAR(archive_cmds, $1)=
- _LT_AC_TAGVAR(archive_expsym_cmds, $1)=
- _LT_AC_TAGVAR(old_archive_From_new_cmds, $1)=
- _LT_AC_TAGVAR(old_archive_from_expsyms_cmds, $1)=
- _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)=
- _LT_AC_TAGVAR(whole_archive_flag_spec, $1)=
- _LT_AC_TAGVAR(thread_safe_flag_spec, $1)=
- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)=
- _LT_AC_TAGVAR(hardcode_libdir_flag_spec_ld, $1)=
- _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=
- _LT_AC_TAGVAR(hardcode_direct, $1)=no
- _LT_AC_TAGVAR(hardcode_minus_L, $1)=no
- _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=unsupported
- _LT_AC_TAGVAR(link_all_deplibs, $1)=unknown
- _LT_AC_TAGVAR(hardcode_automatic, $1)=no
- _LT_AC_TAGVAR(module_cmds, $1)=
- _LT_AC_TAGVAR(module_expsym_cmds, $1)=
- _LT_AC_TAGVAR(always_export_symbols, $1)=no
- _LT_AC_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols'
- # include_expsyms should be a list of space-separated symbols to be *always*
- # included in the symbol list
- _LT_AC_TAGVAR(include_expsyms, $1)=
- # exclude_expsyms can be an extended regexp of symbols to exclude
- # it will be wrapped by ` (' and `)$', so one must not match beginning or
- # end of line. Example: `a|bc|.*d.*' will exclude the symbols `a' and `bc',
- # as well as any symbol that contains `d'.
- _LT_AC_TAGVAR(exclude_expsyms, $1)="_GLOBAL_OFFSET_TABLE_"
- # Although _GLOBAL_OFFSET_TABLE_ is a valid symbol C name, most a.out
- # platforms (ab)use it in PIC code, but their linkers get confused if
- # the symbol is explicitly referenced. Since portable code cannot
- # rely on this symbol name, it's probably fine to never include it in
- # preloaded symbol tables.
- extract_expsyms_cmds=
- # Just being paranoid about ensuring that cc_basename is set.
- _LT_CC_BASENAME([$compiler])
- case $host_os in
- cygwin* | mingw* | pw32*)
- # FIXME: the MSVC++ port hasn't been tested in a loooong time
- # When not using gcc, we currently assume that we are using
- # Microsoft Visual C++.
- if test "$GCC" != yes; then
- with_gnu_ld=no
- fi
- ;;
- interix*)
- # we just hope/assume this is gcc and not c89 (= MSVC++)
- with_gnu_ld=yes
- ;;
- openbsd*)
- with_gnu_ld=no
- ;;
- esac
-
- _LT_AC_TAGVAR(ld_shlibs, $1)=yes
- if test "$with_gnu_ld" = yes; then
- # If archive_cmds runs LD, not CC, wlarc should be empty
- wlarc='${wl}'
-
- # Set some defaults for GNU ld with shared library support. These
- # are reset later if shared libraries are not supported. Putting them
- # here allows them to be overridden if necessary.
- runpath_var=LD_RUN_PATH
- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}--rpath ${wl}$libdir'
- _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic'
- # ancient GNU ld didn't support --whole-archive et. al.
- if $LD --help 2>&1 | grep 'no-whole-archive' > /dev/null; then
- _LT_AC_TAGVAR(whole_archive_flag_spec, $1)="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive'
- else
- _LT_AC_TAGVAR(whole_archive_flag_spec, $1)=
- fi
- supports_anon_versioning=no
- case `$LD -v 2>/dev/null` in
- *\ [[01]].* | *\ 2.[[0-9]].* | *\ 2.10.*) ;; # catch versions < 2.11
- *\ 2.11.93.0.2\ *) supports_anon_versioning=yes ;; # RH7.3 ...
- *\ 2.11.92.0.12\ *) supports_anon_versioning=yes ;; # Mandrake 8.2 ...
- *\ 2.11.*) ;; # other 2.11 versions
- *) supports_anon_versioning=yes ;;
- esac
-
- # See if GNU ld supports shared libraries.
- case $host_os in
- aix3* | aix4* | aix5*)
- # On AIX/PPC, the GNU linker is very broken
- if test "$host_cpu" != ia64; then
- _LT_AC_TAGVAR(ld_shlibs, $1)=no
- cat <<EOF 1>&2
-
-*** Warning: the GNU linker, at least up to release 2.9.1, is reported
-*** to be unable to reliably create shared libraries on AIX.
-*** Therefore, libtool is disabling shared libraries support. If you
-*** really care for shared libraries, you may want to modify your PATH
-*** so that a non-GNU linker is found, and then restart.
-
-EOF
- fi
- ;;
-
- amigaos*)
- _LT_AC_TAGVAR(archive_cmds, $1)='$rm $output_objdir/a2ixlibrary.data~$echo "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$echo "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$echo "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$echo "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)'
- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
- _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes
-
- # Samuel A. Falvo II <kc5tja@dolphin.openprojects.net> reports
- # that the semantics of dynamic libraries on AmigaOS, at least up
- # to version 4, is to share data among multiple programs linked
- # with the same dynamic library. Since this doesn't match the
- # behavior of shared libraries on other platforms, we can't use
- # them.
- _LT_AC_TAGVAR(ld_shlibs, $1)=no
- ;;
-
- beos*)
- if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
- _LT_AC_TAGVAR(allow_undefined_flag, $1)=unsupported
- # Joseph Beckenbach <jrb3@best.com> says some releases of gcc
- # support --undefined. This deserves some investigation. FIXME
- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
- else
- _LT_AC_TAGVAR(ld_shlibs, $1)=no
- fi
- ;;
-
- cygwin* | mingw* | pw32*)
- # _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1) is actually meaningless,
- # as there is no search path for DLLs.
- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
- _LT_AC_TAGVAR(allow_undefined_flag, $1)=unsupported
- _LT_AC_TAGVAR(always_export_symbols, $1)=no
- _LT_AC_TAGVAR(enable_shared_with_static_runtimes, $1)=yes
- _LT_AC_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[[BCDGRS]] /s/.* \([[^ ]]*\)/\1 DATA/'\'' | $SED -e '\''/^[[AITW]] /s/.* //'\'' | sort | uniq > $export_symbols'
-
- if $LD --help 2>&1 | grep 'auto-import' > /dev/null; then
- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
- # If the export-symbols file already is a .def file (1st line
- # is EXPORTS), use it as is; otherwise, prepend...
- _LT_AC_TAGVAR(archive_expsym_cmds, $1)='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then
- cp $export_symbols $output_objdir/$soname.def;
- else
- echo EXPORTS > $output_objdir/$soname.def;
- cat $export_symbols >> $output_objdir/$soname.def;
- fi~
- $CC -shared $output_objdir/$soname.def $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
- else
- _LT_AC_TAGVAR(ld_shlibs, $1)=no
- fi
- ;;
-
- interix3*)
- _LT_AC_TAGVAR(hardcode_direct, $1)=no
- _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
- _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
- # Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc.
- # Instead, shared libraries are loaded at an image base (0x10000000 by
- # default) and relocated if they conflict, which is a slow very memory
- # consuming and fragmenting process. To avoid this, we pick a random,
- # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link
- # time. Moving up from 0x10000000 also allows more sbrk(2) space.
- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
- _LT_AC_TAGVAR(archive_expsym_cmds, $1)='sed "s,^,_," $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--retain-symbols-file,$output_objdir/$soname.expsym ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
- ;;
-
- linux*)
- if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
- tmp_addflag=
- case $cc_basename,$host_cpu in
- pgcc*) # Portland Group C compiler
- _LT_AC_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}--no-whole-archive'
- tmp_addflag=' $pic_flag'
- ;;
- pgf77* | pgf90* | pgf95*) # Portland Group f77 and f90 compilers
- _LT_AC_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}--no-whole-archive'
- tmp_addflag=' $pic_flag -Mnomain' ;;
- ecc*,ia64* | icc*,ia64*) # Intel C compiler on ia64
- tmp_addflag=' -i_dynamic' ;;
- efc*,ia64* | ifort*,ia64*) # Intel Fortran compiler on ia64
- tmp_addflag=' -i_dynamic -nofor_main' ;;
- ifc* | ifort*) # Intel Fortran compiler
- tmp_addflag=' -nofor_main' ;;
- esac
- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared'"$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
-
- if test $supports_anon_versioning = yes; then
- _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$echo "{ global:" > $output_objdir/$libname.ver~
- cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~
- $echo "local: *; };" >> $output_objdir/$libname.ver~
- $CC -shared'"$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib'
- fi
- _LT_AC_TAGVAR(link_all_deplibs, $1)=no
- else
- _LT_AC_TAGVAR(ld_shlibs, $1)=no
- fi
- ;;
-
- netbsd* | netbsdelf*-gnu | knetbsd*-gnu)
- if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then
- _LT_AC_TAGVAR(archive_cmds, $1)='$LD -Bshareable $libobjs $deplibs $linker_flags -o $lib'
- wlarc=
- else
- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
- _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
- fi
- ;;
-
- solaris*)
- if $LD -v 2>&1 | grep 'BFD 2\.8' > /dev/null; then
- _LT_AC_TAGVAR(ld_shlibs, $1)=no
- cat <<EOF 1>&2
-
-*** Warning: The releases 2.8.* of the GNU linker cannot reliably
-*** create shared libraries on Solaris systems. Therefore, libtool
-*** is disabling shared libraries support. We urge you to upgrade GNU
-*** binutils to release 2.9.1 or newer. Another option is to modify
-*** your PATH or compiler configuration so that the native linker is
-*** used, and then restart.
-
-EOF
- elif $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
- _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
- else
- _LT_AC_TAGVAR(ld_shlibs, $1)=no
- fi
- ;;
-
- sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX*)
- case `$LD -v 2>&1` in
- *\ [[01]].* | *\ 2.[[0-9]].* | *\ 2.1[[0-5]].*)
- _LT_AC_TAGVAR(ld_shlibs, $1)=no
- cat <<_LT_EOF 1>&2
-
-*** Warning: Releases of the GNU linker prior to 2.16.91.0.3 can not
-*** reliably create shared libraries on SCO systems. Therefore, libtool
-*** is disabling shared libraries support. We urge you to upgrade GNU
-*** binutils to release 2.16.91.0.3 or newer. Another option is to modify
-*** your PATH or compiler configuration so that the native linker is
-*** used, and then restart.
-
-_LT_EOF
- ;;
- *)
- if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='`test -z "$SCOABSPATH" && echo ${wl}-rpath,$libdir`'
- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib'
- _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname,\${SCOABSPATH:+${install_libdir}/}$soname,-retain-symbols-file,$export_symbols -o $lib'
- else
- _LT_AC_TAGVAR(ld_shlibs, $1)=no
- fi
- ;;
- esac
- ;;
-
- sunos4*)
- _LT_AC_TAGVAR(archive_cmds, $1)='$LD -assert pure-text -Bshareable -o $lib $libobjs $deplibs $linker_flags'
- wlarc=
- _LT_AC_TAGVAR(hardcode_direct, $1)=yes
- _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
- ;;
-
- *)
- if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
- _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
- else
- _LT_AC_TAGVAR(ld_shlibs, $1)=no
- fi
- ;;
- esac
-
- if test "$_LT_AC_TAGVAR(ld_shlibs, $1)" = no; then
- runpath_var=
- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)=
- _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)=
- _LT_AC_TAGVAR(whole_archive_flag_spec, $1)=
- fi
- else
- # PORTME fill in a description of your system's linker (not GNU ld)
- case $host_os in
- aix3*)
- _LT_AC_TAGVAR(allow_undefined_flag, $1)=unsupported
- _LT_AC_TAGVAR(always_export_symbols, $1)=yes
- _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$LD -o $output_objdir/$soname $libobjs $deplibs $linker_flags -bE:$export_symbols -T512 -H512 -bM:SRE~$AR $AR_FLAGS $lib $output_objdir/$soname'
- # Note: this linker hardcodes the directories in LIBPATH if there
- # are no directories specified by -L.
- _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes
- if test "$GCC" = yes && test -z "$lt_prog_compiler_static"; then
- # Neither direct hardcoding nor static linking is supported with a
- # broken collect2.
- _LT_AC_TAGVAR(hardcode_direct, $1)=unsupported
- fi
- ;;
-
- aix4* | aix5*)
- if test "$host_cpu" = ia64; then
- # On IA64, the linker does run time linking by default, so we don't
- # have to do anything special.
- aix_use_runtimelinking=no
- exp_sym_flag='-Bexport'
- no_entry_flag=""
- else
- # If we're using GNU nm, then we don't want the "-C" option.
- # -C means demangle to AIX nm, but means don't demangle with GNU nm
- if $NM -V 2>&1 | grep 'GNU' > /dev/null; then
- _LT_AC_TAGVAR(export_symbols_cmds, $1)='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\[$]2 == "T") || (\[$]2 == "D") || (\[$]2 == "B")) && ([substr](\[$]3,1,1) != ".")) { print \[$]3 } }'\'' | sort -u > $export_symbols'
- else
- _LT_AC_TAGVAR(export_symbols_cmds, $1)='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\[$]2 == "T") || (\[$]2 == "D") || (\[$]2 == "B")) && ([substr](\[$]3,1,1) != ".")) { print \[$]3 } }'\'' | sort -u > $export_symbols'
- fi
- aix_use_runtimelinking=no
-
- # Test if we are trying to use run time linking or normal
- # AIX style linking. If -brtl is somewhere in LDFLAGS, we
- # need to do runtime linking.
- case $host_os in aix4.[[23]]|aix4.[[23]].*|aix5*)
- for ld_flag in $LDFLAGS; do
- if (test $ld_flag = "-brtl" || test $ld_flag = "-Wl,-brtl"); then
- aix_use_runtimelinking=yes
- break
- fi
- done
- ;;
- esac
-
- exp_sym_flag='-bexport'
- no_entry_flag='-bnoentry'
- fi
-
- # When large executables or shared objects are built, AIX ld can
- # have problems creating the table of contents. If linking a library
- # or program results in "error TOC overflow" add -mminimal-toc to
- # CXXFLAGS/CFLAGS for g++/gcc. In the cases where that is not
- # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS.
-
- _LT_AC_TAGVAR(archive_cmds, $1)=''
- _LT_AC_TAGVAR(hardcode_direct, $1)=yes
- _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=':'
- _LT_AC_TAGVAR(link_all_deplibs, $1)=yes
-
- if test "$GCC" = yes; then
- case $host_os in aix4.[[012]]|aix4.[[012]].*)
- # We only want to do this on AIX 4.2 and lower, the check
- # below for broken collect2 doesn't work under 4.3+
- collect2name=`${CC} -print-prog-name=collect2`
- if test -f "$collect2name" && \
- strings "$collect2name" | grep resolve_lib_name >/dev/null
- then
- # We have reworked collect2
- _LT_AC_TAGVAR(hardcode_direct, $1)=yes
- else
- # We have old collect2
- _LT_AC_TAGVAR(hardcode_direct, $1)=unsupported
- # It fails to find uninstalled libraries when the uninstalled
- # path is not listed in the libpath. Setting hardcode_minus_L
- # to unsupported forces relinking
- _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes
- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
- _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=
- fi
- ;;
- esac
- shared_flag='-shared'
- if test "$aix_use_runtimelinking" = yes; then
- shared_flag="$shared_flag "'${wl}-G'
- fi
- else
- # not using gcc
- if test "$host_cpu" = ia64; then
- # VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release
- # chokes on -Wl,-G. The following line is correct:
- shared_flag='-G'
- else
- if test "$aix_use_runtimelinking" = yes; then
- shared_flag='${wl}-G'
- else
- shared_flag='${wl}-bM:SRE'
- fi
- fi
- fi
-
- # It seems that -bexpall does not export symbols beginning with
- # underscore (_), so it is better to generate a list of symbols to export.
- _LT_AC_TAGVAR(always_export_symbols, $1)=yes
- if test "$aix_use_runtimelinking" = yes; then
- # Warning - without using the other runtime loading flags (-brtl),
- # -berok will link without error, but may produce a broken library.
- _LT_AC_TAGVAR(allow_undefined_flag, $1)='-berok'
- # Determine the default libpath from the value encoded in an empty executable.
- _LT_AC_SYS_LIBPATH_AIX
- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath"
- _LT_AC_TAGVAR(archive_expsym_cmds, $1)="\$CC"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then echo "${wl}${allow_undefined_flag}"; else :; fi` '"\${wl}$exp_sym_flag:\$export_symbols $shared_flag"
- else
- if test "$host_cpu" = ia64; then
- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R $libdir:/usr/lib:/lib'
- _LT_AC_TAGVAR(allow_undefined_flag, $1)="-z nodefs"
- _LT_AC_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$exp_sym_flag:\$export_symbols"
- else
- # Determine the default libpath from the value encoded in an empty executable.
- _LT_AC_SYS_LIBPATH_AIX
- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath"
- # Warning - without using the other run time loading flags,
- # -berok will link without error, but may produce a broken library.
- _LT_AC_TAGVAR(no_undefined_flag, $1)=' ${wl}-bernotok'
- _LT_AC_TAGVAR(allow_undefined_flag, $1)=' ${wl}-berok'
- # Exported symbols can be pulled into shared objects from archives
- _LT_AC_TAGVAR(whole_archive_flag_spec, $1)='$convenience'
- _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=yes
- # This is similar to how AIX traditionally builds its shared libraries.
- _LT_AC_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs ${wl}-bnoentry $compiler_flags ${wl}-bE:$export_symbols${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname'
- fi
- fi
- ;;
-
- amigaos*)
- _LT_AC_TAGVAR(archive_cmds, $1)='$rm $output_objdir/a2ixlibrary.data~$echo "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$echo "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$echo "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$echo "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)'
- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
- _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes
- # see comment about different semantics on the GNU ld section
- _LT_AC_TAGVAR(ld_shlibs, $1)=no
- ;;
-
- bsdi[[45]]*)
- _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)=-rdynamic
- ;;
-
- cygwin* | mingw* | pw32*)
- # When not using gcc, we currently assume that we are using
- # Microsoft Visual C++.
- # hardcode_libdir_flag_spec is actually meaningless, as there is
- # no search path for DLLs.
- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)=' '
- _LT_AC_TAGVAR(allow_undefined_flag, $1)=unsupported
- # Tell ltmain to make .lib files, not .a files.
- libext=lib
- # Tell ltmain to make .dll files, not .so files.
- shrext_cmds=".dll"
- # FIXME: Setting linknames here is a bad hack.
- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -o $lib $libobjs $compiler_flags `echo "$deplibs" | $SED -e '\''s/ -lc$//'\''` -link -dll~linknames='
- # The linker will automatically build a .lib file if we build a DLL.
- _LT_AC_TAGVAR(old_archive_From_new_cmds, $1)='true'
- # FIXME: Should let the user specify the lib program.
- _LT_AC_TAGVAR(old_archive_cmds, $1)='lib /OUT:$oldlib$oldobjs$old_deplibs'
- _LT_AC_TAGVAR(fix_srcfile_path, $1)='`cygpath -w "$srcfile"`'
- _LT_AC_TAGVAR(enable_shared_with_static_runtimes, $1)=yes
- ;;
-
- darwin* | rhapsody*)
- case $host_os in
- rhapsody* | darwin1.[[012]])
- _LT_AC_TAGVAR(allow_undefined_flag, $1)='${wl}-undefined ${wl}suppress'
- ;;
- *) # Darwin 1.3 on
- if test -z ${MACOSX_DEPLOYMENT_TARGET} ; then
- _LT_AC_TAGVAR(allow_undefined_flag, $1)='${wl}-flat_namespace ${wl}-undefined ${wl}suppress'
- else
- case ${MACOSX_DEPLOYMENT_TARGET} in
- 10.[[012]])
- _LT_AC_TAGVAR(allow_undefined_flag, $1)='${wl}-flat_namespace ${wl}-undefined ${wl}suppress'
- ;;
- 10.*)
- _LT_AC_TAGVAR(allow_undefined_flag, $1)='${wl}-undefined ${wl}dynamic_lookup'
- ;;
- esac
- fi
- ;;
- esac
- _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no
- _LT_AC_TAGVAR(hardcode_direct, $1)=no
- _LT_AC_TAGVAR(hardcode_automatic, $1)=yes
- _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=unsupported
- _LT_AC_TAGVAR(whole_archive_flag_spec, $1)=''
- _LT_AC_TAGVAR(link_all_deplibs, $1)=yes
- if test "$GCC" = yes ; then
- output_verbose_link_cmd='echo'
- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -dynamiclib $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring'
- _LT_AC_TAGVAR(module_cmds, $1)='$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags'
- # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin lds
- _LT_AC_TAGVAR(archive_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -dynamiclib $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
- _LT_AC_TAGVAR(module_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
- else
- case $cc_basename in
- xlc*)
- output_verbose_link_cmd='echo'
- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -qmkshrobj $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-install_name ${wl}`echo $rpath/$soname` $verstring'
- _LT_AC_TAGVAR(module_cmds, $1)='$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags'
- # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin lds
- _LT_AC_TAGVAR(archive_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -qmkshrobj $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-install_name ${wl}$rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
- _LT_AC_TAGVAR(module_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
- ;;
- *)
- _LT_AC_TAGVAR(ld_shlibs, $1)=no
- ;;
- esac
- fi
- ;;
-
- dgux*)
- _LT_AC_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
- _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
- ;;
-
- freebsd1*)
- _LT_AC_TAGVAR(ld_shlibs, $1)=no
- ;;
-
- # FreeBSD 2.2.[012] allows us to include c++rt0.o to get C++ constructor
- # support. Future versions do this automatically, but an explicit c++rt0.o
- # does not break anything, and helps significantly (at the cost of a little
- # extra space).
- freebsd2.2*)
- _LT_AC_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags /usr/lib/c++rt0.o'
- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
- _LT_AC_TAGVAR(hardcode_direct, $1)=yes
- _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
- ;;
-
- # Unfortunately, older versions of FreeBSD 2 do not have this feature.
- freebsd2*)
- _LT_AC_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags'
- _LT_AC_TAGVAR(hardcode_direct, $1)=yes
- _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes
- _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
- ;;
-
- # FreeBSD 3 and greater uses gcc -shared to do shared libraries.
- freebsd* | dragonfly*)
- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -o $lib $libobjs $deplibs $compiler_flags'
- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
- _LT_AC_TAGVAR(hardcode_direct, $1)=yes
- _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
- ;;
-
- # GNU/kFreeBSD uses gcc -shared to do shared libraries.
- kfreebsd*-gnu)
- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -o $lib $libobjs $deplibs $compiler_flags'
- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
- _LT_AC_TAGVAR(hardcode_direct, $1)=yes
- _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
- _LT_AC_TAGVAR(link_all_deplibs, $1)=no
- ;;
-
- hpux9*)
- if test "$GCC" = yes; then
- _LT_AC_TAGVAR(archive_cmds, $1)='$rm $output_objdir/$soname~$CC -shared -fPIC ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $libobjs $deplibs $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
- else
- _LT_AC_TAGVAR(archive_cmds, $1)='$rm $output_objdir/$soname~$LD -b +b $install_libdir -o $output_objdir/$soname $libobjs $deplibs $linker_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
- fi
- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir'
- _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=:
- _LT_AC_TAGVAR(hardcode_direct, $1)=yes
-
- # hardcode_minus_L: Not really in the search PATH,
- # but as the default location of the library.
- _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes
- _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
- ;;
-
- hpux10*)
- if test "$GCC" = yes -a "$with_gnu_ld" = no; then
- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
- else
- _LT_AC_TAGVAR(archive_cmds, $1)='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags'
- fi
- if test "$with_gnu_ld" = no; then
- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir'
- _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=:
-
- _LT_AC_TAGVAR(hardcode_direct, $1)=yes
- _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
-
- # hardcode_minus_L: Not really in the search PATH,
- # but as the default location of the library.
- _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes
- fi
- ;;
-
- hpux11*)
- if test "$GCC" = yes -a "$with_gnu_ld" = no; then
- case $host_cpu in
- hppa*64*)
- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
- ;;
- ia64*)
- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags'
- ;;
- *)
- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
- ;;
- esac
- else
- case $host_cpu in
- hppa*64*)
- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
- ;;
- ia64*)
- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags'
- ;;
- *)
- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
- ;;
- esac
- fi
- if test "$with_gnu_ld" = no; then
- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir'
- _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=:
-
- case $host_cpu in
- hppa*64*|ia64*)
- _LT_AC_TAGVAR(hardcode_libdir_flag_spec_ld, $1)='+b $libdir'
- _LT_AC_TAGVAR(hardcode_direct, $1)=no
- _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
- ;;
- *)
- _LT_AC_TAGVAR(hardcode_direct, $1)=yes
- _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
-
- # hardcode_minus_L: Not really in the search PATH,
- # but as the default location of the library.
- _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes
- ;;
- esac
- fi
- ;;
-
- irix5* | irix6* | nonstopux*)
- if test "$GCC" = yes; then
- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
- else
- _LT_AC_TAGVAR(archive_cmds, $1)='$LD -shared $libobjs $deplibs $linker_flags -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib'
- _LT_AC_TAGVAR(hardcode_libdir_flag_spec_ld, $1)='-rpath $libdir'
- fi
- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
- _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=:
- _LT_AC_TAGVAR(link_all_deplibs, $1)=yes
- ;;
-
- netbsd* | netbsdelf*-gnu | knetbsd*-gnu)
- if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then
- _LT_AC_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' # a.out
- else
- _LT_AC_TAGVAR(archive_cmds, $1)='$LD -shared -o $lib $libobjs $deplibs $linker_flags' # ELF
- fi
- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
- _LT_AC_TAGVAR(hardcode_direct, $1)=yes
- _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
- ;;
-
- newsos6)
- _LT_AC_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
- _LT_AC_TAGVAR(hardcode_direct, $1)=yes
- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
- _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=:
- _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
- ;;
-
- openbsd*)
- _LT_AC_TAGVAR(hardcode_direct, $1)=yes
- _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
- if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags'
- _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-retain-symbols-file,$export_symbols'
- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
- _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
- else
- case $host_os in
- openbsd[[01]].* | openbsd2.[[0-7]] | openbsd2.[[0-7]].*)
- _LT_AC_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags'
- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
- ;;
- *)
- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags'
- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
- ;;
- esac
- fi
- ;;
-
- os2*)
- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
- _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes
- _LT_AC_TAGVAR(allow_undefined_flag, $1)=unsupported
- _LT_AC_TAGVAR(archive_cmds, $1)='$echo "LIBRARY $libname INITINSTANCE" > $output_objdir/$libname.def~$echo "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~$echo DATA >> $output_objdir/$libname.def~$echo " SINGLE NONSHARED" >> $output_objdir/$libname.def~$echo EXPORTS >> $output_objdir/$libname.def~emxexp $libobjs >> $output_objdir/$libname.def~$CC -Zdll -Zcrtdll -o $lib $libobjs $deplibs $compiler_flags $output_objdir/$libname.def'
- _LT_AC_TAGVAR(old_archive_From_new_cmds, $1)='emximp -o $output_objdir/$libname.a $output_objdir/$libname.def'
- ;;
-
- osf3*)
- if test "$GCC" = yes; then
- _LT_AC_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*'
- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
- else
- _LT_AC_TAGVAR(allow_undefined_flag, $1)=' -expect_unresolved \*'
- _LT_AC_TAGVAR(archive_cmds, $1)='$LD -shared${allow_undefined_flag} $libobjs $deplibs $linker_flags -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib'
- fi
- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
- _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=:
- ;;
-
- osf4* | osf5*) # as osf3* with the addition of -msym flag
- if test "$GCC" = yes; then
- _LT_AC_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*'
- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
- else
- _LT_AC_TAGVAR(allow_undefined_flag, $1)=' -expect_unresolved \*'
- _LT_AC_TAGVAR(archive_cmds, $1)='$LD -shared${allow_undefined_flag} $libobjs $deplibs $linker_flags -msym -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib'
- _LT_AC_TAGVAR(archive_expsym_cmds, $1)='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done; echo "-hidden">> $lib.exp~
- $LD -shared${allow_undefined_flag} -input $lib.exp $linker_flags $libobjs $deplibs -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib~$rm $lib.exp'
-
- # Both c and cxx compiler support -rpath directly
- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-rpath $libdir'
- fi
- _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=:
- ;;
-
- solaris*)
- _LT_AC_TAGVAR(no_undefined_flag, $1)=' -z text'
- if test "$GCC" = yes; then
- wlarc='${wl}'
- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
- _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~
- $CC -shared ${wl}-M ${wl}$lib.exp ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags~$rm $lib.exp'
- else
- wlarc=''
- _LT_AC_TAGVAR(archive_cmds, $1)='$LD -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $linker_flags'
- _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~
- $LD -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linker_flags~$rm $lib.exp'
- fi
- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
- _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
- case $host_os in
- solaris2.[[0-5]] | solaris2.[[0-5]].*) ;;
- *)
- # The compiler driver will combine linker options so we
- # cannot just pass the convience library names through
- # without $wl, iff we do not link with $LD.
- # Luckily, gcc supports the same syntax we need for Sun Studio.
- # Supported since Solaris 2.6 (maybe 2.5.1?)
- case $wlarc in
- '')
- _LT_AC_TAGVAR(whole_archive_flag_spec, $1)='-z allextract$convenience -z defaultextract' ;;
- *)
- _LT_AC_TAGVAR(whole_archive_flag_spec, $1)='${wl}-z ${wl}allextract`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}-z ${wl}defaultextract' ;;
- esac ;;
- esac
- _LT_AC_TAGVAR(link_all_deplibs, $1)=yes
- ;;
-
- sunos4*)
- if test "x$host_vendor" = xsequent; then
- # Use $CC to link under sequent, because it throws in some extra .o
- # files that make .init and .fini sections work.
- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h $soname -o $lib $libobjs $deplibs $compiler_flags'
- else
- _LT_AC_TAGVAR(archive_cmds, $1)='$LD -assert pure-text -Bstatic -o $lib $libobjs $deplibs $linker_flags'
- fi
- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
- _LT_AC_TAGVAR(hardcode_direct, $1)=yes
- _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes
- _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
- ;;
-
- sysv4)
- case $host_vendor in
- sni)
- _LT_AC_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
- _LT_AC_TAGVAR(hardcode_direct, $1)=yes # is this really true???
- ;;
- siemens)
- ## LD is ld it makes a PLAMLIB
- ## CC just makes a GrossModule.
- _LT_AC_TAGVAR(archive_cmds, $1)='$LD -G -o $lib $libobjs $deplibs $linker_flags'
- _LT_AC_TAGVAR(reload_cmds, $1)='$CC -r -o $output$reload_objs'
- _LT_AC_TAGVAR(hardcode_direct, $1)=no
- ;;
- motorola)
- _LT_AC_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
- _LT_AC_TAGVAR(hardcode_direct, $1)=no #Motorola manual says yes, but my tests say they lie
- ;;
- esac
- runpath_var='LD_RUN_PATH'
- _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
- ;;
-
- sysv4.3*)
- _LT_AC_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
- _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
- _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='-Bexport'
- ;;
-
- sysv4*MP*)
- if test -d /usr/nec; then
- _LT_AC_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
- _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
- runpath_var=LD_RUN_PATH
- hardcode_runpath_var=yes
- _LT_AC_TAGVAR(ld_shlibs, $1)=yes
- fi
- ;;
-
- sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[[01]].[[10]]* | unixware7*)
- _LT_AC_TAGVAR(no_undefined_flag, $1)='${wl}-z,text'
- _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no
- _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
- runpath_var='LD_RUN_PATH'
-
- if test "$GCC" = yes; then
- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
- _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
- else
- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
- _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
- fi
- ;;
-
- sysv5* | sco3.2v5* | sco5v6*)
- # Note: We can NOT use -z defs as we might desire, because we do not
- # link with -lc, and that would cause any symbols used from libc to
- # always be unresolved, which means just about no library would
- # ever link correctly. If we're not using GNU ld we use -z text
- # though, which does catch some bad symbols but isn't as heavy-handed
- # as -z defs.
- _LT_AC_TAGVAR(no_undefined_flag, $1)='${wl}-z,text'
- _LT_AC_TAGVAR(allow_undefined_flag, $1)='${wl}-z,nodefs'
- _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no
- _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='`test -z "$SCOABSPATH" && echo ${wl}-R,$libdir`'
- _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=':'
- _LT_AC_TAGVAR(link_all_deplibs, $1)=yes
- _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-Bexport'
- runpath_var='LD_RUN_PATH'
-
- if test "$GCC" = yes; then
- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags'
- _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags'
- else
- _LT_AC_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags'
- _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags'
- fi
- ;;
-
- uts4*)
- _LT_AC_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
- _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
- _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
- ;;
-
- *)
- _LT_AC_TAGVAR(ld_shlibs, $1)=no
- ;;
- esac
- fi
-])
-AC_MSG_RESULT([$_LT_AC_TAGVAR(ld_shlibs, $1)])
-test "$_LT_AC_TAGVAR(ld_shlibs, $1)" = no && can_build_shared=no
-
-#
-# Do we need to explicitly link libc?
-#
-case "x$_LT_AC_TAGVAR(archive_cmds_need_lc, $1)" in
-x|xyes)
- # Assume -lc should be added
- _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=yes
-
- if test "$enable_shared" = yes && test "$GCC" = yes; then
- case $_LT_AC_TAGVAR(archive_cmds, $1) in
- *'~'*)
- # FIXME: we may have to deal with multi-command sequences.
- ;;
- '$CC '*)
- # Test whether the compiler implicitly links with -lc since on some
- # systems, -lgcc has to come before -lc. If gcc already passes -lc
- # to ld, don't add -lc before -lgcc.
- AC_MSG_CHECKING([whether -lc should be explicitly linked in])
- $rm conftest*
- printf "$lt_simple_compile_test_code" > conftest.$ac_ext
-
- if AC_TRY_EVAL(ac_compile) 2>conftest.err; then
- soname=conftest
- lib=conftest
- libobjs=conftest.$ac_objext
- deplibs=
- wl=$_LT_AC_TAGVAR(lt_prog_compiler_wl, $1)
- pic_flag=$_LT_AC_TAGVAR(lt_prog_compiler_pic, $1)
- compiler_flags=-v
- linker_flags=-v
- verstring=
- output_objdir=.
- libname=conftest
- lt_save_allow_undefined_flag=$_LT_AC_TAGVAR(allow_undefined_flag, $1)
- _LT_AC_TAGVAR(allow_undefined_flag, $1)=
- if AC_TRY_EVAL(_LT_AC_TAGVAR(archive_cmds, $1) 2\>\&1 \| grep \" -lc \" \>/dev/null 2\>\&1)
- then
- _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no
- else
- _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=yes
- fi
- _LT_AC_TAGVAR(allow_undefined_flag, $1)=$lt_save_allow_undefined_flag
- else
- cat conftest.err 1>&5
- fi
- $rm conftest*
- AC_MSG_RESULT([$_LT_AC_TAGVAR(archive_cmds_need_lc, $1)])
- ;;
- esac
- fi
- ;;
-esac
-])# AC_LIBTOOL_PROG_LD_SHLIBS
-
-
-# _LT_AC_FILE_LTDLL_C
-# -------------------
-# Be careful that the start marker always follows a newline.
-AC_DEFUN([_LT_AC_FILE_LTDLL_C], [
-# /* ltdll.c starts here */
-# #define WIN32_LEAN_AND_MEAN
-# #include <windows.h>
-# #undef WIN32_LEAN_AND_MEAN
-# #include <stdio.h>
-#
-# #ifndef __CYGWIN__
-# # ifdef __CYGWIN32__
-# # define __CYGWIN__ __CYGWIN32__
-# # endif
-# #endif
-#
-# #ifdef __cplusplus
-# extern "C" {
-# #endif
-# BOOL APIENTRY DllMain (HINSTANCE hInst, DWORD reason, LPVOID reserved);
-# #ifdef __cplusplus
-# }
-# #endif
-#
-# #ifdef __CYGWIN__
-# #include <cygwin/cygwin_dll.h>
-# DECLARE_CYGWIN_DLL( DllMain );
-# #endif
-# HINSTANCE __hDllInstance_base;
-#
-# BOOL APIENTRY
-# DllMain (HINSTANCE hInst, DWORD reason, LPVOID reserved)
-# {
-# __hDllInstance_base = hInst;
-# return TRUE;
-# }
-# /* ltdll.c ends here */
-])# _LT_AC_FILE_LTDLL_C
-
-
-# _LT_AC_TAGVAR(VARNAME, [TAGNAME])
-# ---------------------------------
-AC_DEFUN([_LT_AC_TAGVAR], [ifelse([$2], [], [$1], [$1_$2])])
-
-
-# old names
-AC_DEFUN([AM_PROG_LIBTOOL], [AC_PROG_LIBTOOL])
-AC_DEFUN([AM_ENABLE_SHARED], [AC_ENABLE_SHARED($@)])
-AC_DEFUN([AM_ENABLE_STATIC], [AC_ENABLE_STATIC($@)])
-AC_DEFUN([AM_DISABLE_SHARED], [AC_DISABLE_SHARED($@)])
-AC_DEFUN([AM_DISABLE_STATIC], [AC_DISABLE_STATIC($@)])
-AC_DEFUN([AM_PROG_LD], [AC_PROG_LD])
-AC_DEFUN([AM_PROG_NM], [AC_PROG_NM])
-
-# This is just to silence aclocal about the macro not being used
-ifelse([AC_DISABLE_FAST_INSTALL])
-
-AC_DEFUN([LT_AC_PROG_GCJ],
-[AC_CHECK_TOOL(GCJ, gcj, no)
- test "x${GCJFLAGS+set}" = xset || GCJFLAGS="-g -O2"
- AC_SUBST(GCJFLAGS)
-])
-
-AC_DEFUN([LT_AC_PROG_RC],
-[AC_CHECK_TOOL(RC, windres, no)
-])
-
-# NOTE: This macro has been submitted for inclusion into #
-# GNU Autoconf as AC_PROG_SED. When it is available in #
-# a released version of Autoconf we should remove this #
-# macro and use it instead. #
-# LT_AC_PROG_SED
-# --------------
-# Check for a fully-functional sed program, that truncates
-# as few characters as possible. Prefer GNU sed if found.
-AC_DEFUN([LT_AC_PROG_SED],
-[AC_MSG_CHECKING([for a sed that does not truncate output])
-AC_CACHE_VAL(lt_cv_path_SED,
-[# Loop through the user's path and test for sed and gsed.
-# Then use that list of sed's as ones to test for truncation.
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
- IFS=$as_save_IFS
- test -z "$as_dir" && as_dir=.
- for lt_ac_prog in sed gsed; do
- for ac_exec_ext in '' $ac_executable_extensions; do
- if $as_executable_p "$as_dir/$lt_ac_prog$ac_exec_ext"; then
- lt_ac_sed_list="$lt_ac_sed_list $as_dir/$lt_ac_prog$ac_exec_ext"
- fi
- done
- done
-done
-lt_ac_max=0
-lt_ac_count=0
-# Add /usr/xpg4/bin/sed as it is typically found on Solaris
-# along with /bin/sed that truncates output.
-for lt_ac_sed in $lt_ac_sed_list /usr/xpg4/bin/sed; do
- test ! -f $lt_ac_sed && continue
- cat /dev/null > conftest.in
- lt_ac_count=0
- echo $ECHO_N "0123456789$ECHO_C" >conftest.in
- # Check for GNU sed and select it if it is found.
- if "$lt_ac_sed" --version 2>&1 < /dev/null | grep 'GNU' > /dev/null; then
- lt_cv_path_SED=$lt_ac_sed
- break
- fi
- while true; do
- cat conftest.in conftest.in >conftest.tmp
- mv conftest.tmp conftest.in
- cp conftest.in conftest.nl
- echo >>conftest.nl
- $lt_ac_sed -e 's/a$//' < conftest.nl >conftest.out || break
- cmp -s conftest.out conftest.nl || break
- # 10000 chars as input seems more than enough
- test $lt_ac_count -gt 10 && break
- lt_ac_count=`expr $lt_ac_count + 1`
- if test $lt_ac_count -gt $lt_ac_max; then
- lt_ac_max=$lt_ac_count
- lt_cv_path_SED=$lt_ac_sed
- fi
- done
-done
-])
-SED=$lt_cv_path_SED
-AC_MSG_RESULT([$SED])
-])
-
-# Copyright (C) 2002, 2003, 2005 Free Software Foundation, Inc.
-#
-# This file is free software; the Free Software Foundation
-# gives unlimited permission to copy and/or distribute it,
-# with or without modifications, as long as this notice is preserved.
-
-# AM_AUTOMAKE_VERSION(VERSION)
-# ----------------------------
-# Automake X.Y traces this macro to ensure aclocal.m4 has been
-# generated from the m4 files accompanying Automake X.Y.
-AC_DEFUN([AM_AUTOMAKE_VERSION], [am__api_version="1.9"])
-
-# AM_SET_CURRENT_AUTOMAKE_VERSION
-# -------------------------------
-# Call AM_AUTOMAKE_VERSION so it can be traced.
-# This function is AC_REQUIREd by AC_INIT_AUTOMAKE.
-AC_DEFUN([AM_SET_CURRENT_AUTOMAKE_VERSION],
- [AM_AUTOMAKE_VERSION([1.9.6])])
-
-# AM_AUX_DIR_EXPAND -*- Autoconf -*-
-
-# Copyright (C) 2001, 2003, 2005 Free Software Foundation, Inc.
-#
-# This file is free software; the Free Software Foundation
-# gives unlimited permission to copy and/or distribute it,
-# with or without modifications, as long as this notice is preserved.
-
-# For projects using AC_CONFIG_AUX_DIR([foo]), Autoconf sets
-# $ac_aux_dir to `$srcdir/foo'. In other projects, it is set to
-# `$srcdir', `$srcdir/..', or `$srcdir/../..'.
-#
-# Of course, Automake must honor this variable whenever it calls a
-# tool from the auxiliary directory. The problem is that $srcdir (and
-# therefore $ac_aux_dir as well) can be either absolute or relative,
-# depending on how configure is run. This is pretty annoying, since
-# it makes $ac_aux_dir quite unusable in subdirectories: in the top
-# source directory, any form will work fine, but in subdirectories a
-# relative path needs to be adjusted first.
-#
-# $ac_aux_dir/missing
-# fails when called from a subdirectory if $ac_aux_dir is relative
-# $top_srcdir/$ac_aux_dir/missing
-# fails if $ac_aux_dir is absolute,
-# fails when called from a subdirectory in a VPATH build with
-# a relative $ac_aux_dir
-#
-# The reason of the latter failure is that $top_srcdir and $ac_aux_dir
-# are both prefixed by $srcdir. In an in-source build this is usually
-# harmless because $srcdir is `.', but things will broke when you
-# start a VPATH build or use an absolute $srcdir.
-#
-# So we could use something similar to $top_srcdir/$ac_aux_dir/missing,
-# iff we strip the leading $srcdir from $ac_aux_dir. That would be:
-# am_aux_dir='\$(top_srcdir)/'`expr "$ac_aux_dir" : "$srcdir//*\(.*\)"`
-# and then we would define $MISSING as
-# MISSING="\${SHELL} $am_aux_dir/missing"
-# This will work as long as MISSING is not called from configure, because
-# unfortunately $(top_srcdir) has no meaning in configure.
-# However there are other variables, like CC, which are often used in
-# configure, and could therefore not use this "fixed" $ac_aux_dir.
-#
-# Another solution, used here, is to always expand $ac_aux_dir to an
-# absolute PATH. The drawback is that using absolute paths prevent a
-# configured tree to be moved without reconfiguration.
-
-AC_DEFUN([AM_AUX_DIR_EXPAND],
-[dnl Rely on autoconf to set up CDPATH properly.
-AC_PREREQ([2.50])dnl
-# expand $ac_aux_dir to an absolute path
-am_aux_dir=`cd $ac_aux_dir && pwd`
-])
-
-# AM_CONDITIONAL -*- Autoconf -*-
-
-# Copyright (C) 1997, 2000, 2001, 2003, 2004, 2005
-# Free Software Foundation, Inc.
-#
-# This file is free software; the Free Software Foundation
-# gives unlimited permission to copy and/or distribute it,
-# with or without modifications, as long as this notice is preserved.
-
-# serial 7
-
-# AM_CONDITIONAL(NAME, SHELL-CONDITION)
-# -------------------------------------
-# Define a conditional.
-AC_DEFUN([AM_CONDITIONAL],
-[AC_PREREQ(2.52)dnl
- ifelse([$1], [TRUE], [AC_FATAL([$0: invalid condition: $1])],
- [$1], [FALSE], [AC_FATAL([$0: invalid condition: $1])])dnl
-AC_SUBST([$1_TRUE])
-AC_SUBST([$1_FALSE])
-if $2; then
- $1_TRUE=
- $1_FALSE='#'
-else
- $1_TRUE='#'
- $1_FALSE=
-fi
-AC_CONFIG_COMMANDS_PRE(
-[if test -z "${$1_TRUE}" && test -z "${$1_FALSE}"; then
- AC_MSG_ERROR([[conditional "$1" was never defined.
-Usually this means the macro was only invoked conditionally.]])
-fi])])
-
-
-# Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005
-# Free Software Foundation, Inc.
-#
-# This file is free software; the Free Software Foundation
-# gives unlimited permission to copy and/or distribute it,
-# with or without modifications, as long as this notice is preserved.
-
-# serial 8
-
-# There are a few dirty hacks below to avoid letting `AC_PROG_CC' be
-# written in clear, in which case automake, when reading aclocal.m4,
-# will think it sees a *use*, and therefore will trigger all it's
-# C support machinery. Also note that it means that autoscan, seeing
-# CC etc. in the Makefile, will ask for an AC_PROG_CC use...
-
-
-# _AM_DEPENDENCIES(NAME)
-# ----------------------
-# See how the compiler implements dependency checking.
-# NAME is "CC", "CXX", "GCJ", or "OBJC".
-# We try a few techniques and use that to set a single cache variable.
-#
-# We don't AC_REQUIRE the corresponding AC_PROG_CC since the latter was
-# modified to invoke _AM_DEPENDENCIES(CC); we would have a circular
-# dependency, and given that the user is not expected to run this macro,
-# just rely on AC_PROG_CC.
-AC_DEFUN([_AM_DEPENDENCIES],
-[AC_REQUIRE([AM_SET_DEPDIR])dnl
-AC_REQUIRE([AM_OUTPUT_DEPENDENCY_COMMANDS])dnl
-AC_REQUIRE([AM_MAKE_INCLUDE])dnl
-AC_REQUIRE([AM_DEP_TRACK])dnl
-
-ifelse([$1], CC, [depcc="$CC" am_compiler_list=],
- [$1], CXX, [depcc="$CXX" am_compiler_list=],
- [$1], OBJC, [depcc="$OBJC" am_compiler_list='gcc3 gcc'],
- [$1], GCJ, [depcc="$GCJ" am_compiler_list='gcc3 gcc'],
- [depcc="$$1" am_compiler_list=])
-
-AC_CACHE_CHECK([dependency style of $depcc],
- [am_cv_$1_dependencies_compiler_type],
-[if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then
- # We make a subdir and do the tests there. Otherwise we can end up
- # making bogus files that we don't know about and never remove. For
- # instance it was reported that on HP-UX the gcc test will end up
- # making a dummy file named `D' -- because `-MD' means `put the output
- # in D'.
- mkdir conftest.dir
- # Copy depcomp to subdir because otherwise we won't find it if we're
- # using a relative directory.
- cp "$am_depcomp" conftest.dir
- cd conftest.dir
- # We will build objects and dependencies in a subdirectory because
- # it helps to detect inapplicable dependency modes. For instance
- # both Tru64's cc and ICC support -MD to output dependencies as a
- # side effect of compilation, but ICC will put the dependencies in
- # the current directory while Tru64 will put them in the object
- # directory.
- mkdir sub
-
- am_cv_$1_dependencies_compiler_type=none
- if test "$am_compiler_list" = ""; then
- am_compiler_list=`sed -n ['s/^#*\([a-zA-Z0-9]*\))$/\1/p'] < ./depcomp`
- fi
- for depmode in $am_compiler_list; do
- # Setup a source with many dependencies, because some compilers
- # like to wrap large dependency lists on column 80 (with \), and
- # we should not choose a depcomp mode which is confused by this.
- #
- # We need to recreate these files for each test, as the compiler may
- # overwrite some of them when testing with obscure command lines.
- # This happens at least with the AIX C compiler.
- : > sub/conftest.c
- for i in 1 2 3 4 5 6; do
- echo '#include "conftst'$i'.h"' >> sub/conftest.c
- # Using `: > sub/conftst$i.h' creates only sub/conftst1.h with
- # Solaris 8's {/usr,}/bin/sh.
- touch sub/conftst$i.h
- done
- echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf
-
- case $depmode in
- nosideeffect)
- # after this tag, mechanisms are not by side-effect, so they'll
- # only be used when explicitly requested
- if test "x$enable_dependency_tracking" = xyes; then
- continue
- else
- break
- fi
- ;;
- none) break ;;
- esac
- # We check with `-c' and `-o' for the sake of the "dashmstdout"
- # mode. It turns out that the SunPro C++ compiler does not properly
- # handle `-M -o', and we need to detect this.
- if depmode=$depmode \
- source=sub/conftest.c object=sub/conftest.${OBJEXT-o} \
- depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \
- $SHELL ./depcomp $depcc -c -o sub/conftest.${OBJEXT-o} sub/conftest.c \
- >/dev/null 2>conftest.err &&
- grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 &&
- grep sub/conftest.${OBJEXT-o} sub/conftest.Po > /dev/null 2>&1 &&
- ${MAKE-make} -s -f confmf > /dev/null 2>&1; then
- # icc doesn't choke on unknown options, it will just issue warnings
- # or remarks (even with -Werror). So we grep stderr for any message
- # that says an option was ignored or not supported.
- # When given -MP, icc 7.0 and 7.1 complain thusly:
- # icc: Command line warning: ignoring option '-M'; no argument required
- # The diagnosis changed in icc 8.0:
- # icc: Command line remark: option '-MP' not supported
- if (grep 'ignoring option' conftest.err ||
- grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else
- am_cv_$1_dependencies_compiler_type=$depmode
- break
- fi
- fi
- done
-
- cd ..
- rm -rf conftest.dir
-else
- am_cv_$1_dependencies_compiler_type=none
-fi
-])
-AC_SUBST([$1DEPMODE], [depmode=$am_cv_$1_dependencies_compiler_type])
-AM_CONDITIONAL([am__fastdep$1], [
- test "x$enable_dependency_tracking" != xno \
- && test "$am_cv_$1_dependencies_compiler_type" = gcc3])
-])
-
-
-# AM_SET_DEPDIR
-# -------------
-# Choose a directory name for dependency files.
-# This macro is AC_REQUIREd in _AM_DEPENDENCIES
-AC_DEFUN([AM_SET_DEPDIR],
-[AC_REQUIRE([AM_SET_LEADING_DOT])dnl
-AC_SUBST([DEPDIR], ["${am__leading_dot}deps"])dnl
-])
-
-
-# AM_DEP_TRACK
-# ------------
-AC_DEFUN([AM_DEP_TRACK],
-[AC_ARG_ENABLE(dependency-tracking,
-[ --disable-dependency-tracking speeds up one-time build
- --enable-dependency-tracking do not reject slow dependency extractors])
-if test "x$enable_dependency_tracking" != xno; then
- am_depcomp="$ac_aux_dir/depcomp"
- AMDEPBACKSLASH='\'
-fi
-AM_CONDITIONAL([AMDEP], [test "x$enable_dependency_tracking" != xno])
-AC_SUBST([AMDEPBACKSLASH])
-])
-
-# Generate code to set up dependency tracking. -*- Autoconf -*-
-
-# Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005
-# Free Software Foundation, Inc.
-#
-# This file is free software; the Free Software Foundation
-# gives unlimited permission to copy and/or distribute it,
-# with or without modifications, as long as this notice is preserved.
-
-#serial 3
-
-# _AM_OUTPUT_DEPENDENCY_COMMANDS
-# ------------------------------
-AC_DEFUN([_AM_OUTPUT_DEPENDENCY_COMMANDS],
-[for mf in $CONFIG_FILES; do
- # Strip MF so we end up with the name of the file.
- mf=`echo "$mf" | sed -e 's/:.*$//'`
- # Check whether this is an Automake generated Makefile or not.
- # We used to match only the files named `Makefile.in', but
- # some people rename them; so instead we look at the file content.
- # Grep'ing the first line is not enough: some people post-process
- # each Makefile.in and add a new line on top of each file to say so.
- # So let's grep whole file.
- if grep '^#.*generated by automake' $mf > /dev/null 2>&1; then
- dirpart=`AS_DIRNAME("$mf")`
- else
- continue
- fi
- # Extract the definition of DEPDIR, am__include, and am__quote
- # from the Makefile without running `make'.
- DEPDIR=`sed -n 's/^DEPDIR = //p' < "$mf"`
- test -z "$DEPDIR" && continue
- am__include=`sed -n 's/^am__include = //p' < "$mf"`
- test -z "am__include" && continue
- am__quote=`sed -n 's/^am__quote = //p' < "$mf"`
- # When using ansi2knr, U may be empty or an underscore; expand it
- U=`sed -n 's/^U = //p' < "$mf"`
- # Find all dependency output files, they are included files with
- # $(DEPDIR) in their names. We invoke sed twice because it is the
- # simplest approach to changing $(DEPDIR) to its actual value in the
- # expansion.
- for file in `sed -n "
- s/^$am__include $am__quote\(.*(DEPDIR).*\)$am__quote"'$/\1/p' <"$mf" | \
- sed -e 's/\$(DEPDIR)/'"$DEPDIR"'/g' -e 's/\$U/'"$U"'/g'`; do
- # Make sure the directory exists.
- test -f "$dirpart/$file" && continue
- fdir=`AS_DIRNAME(["$file"])`
- AS_MKDIR_P([$dirpart/$fdir])
- # echo "creating $dirpart/$file"
- echo '# dummy' > "$dirpart/$file"
- done
-done
-])# _AM_OUTPUT_DEPENDENCY_COMMANDS
-
-
-# AM_OUTPUT_DEPENDENCY_COMMANDS
-# -----------------------------
-# This macro should only be invoked once -- use via AC_REQUIRE.
-#
-# This code is only required when automatic dependency tracking
-# is enabled. FIXME. This creates each `.P' file that we will
-# need in order to bootstrap the dependency handling code.
-AC_DEFUN([AM_OUTPUT_DEPENDENCY_COMMANDS],
-[AC_CONFIG_COMMANDS([depfiles],
- [test x"$AMDEP_TRUE" != x"" || _AM_OUTPUT_DEPENDENCY_COMMANDS],
- [AMDEP_TRUE="$AMDEP_TRUE" ac_aux_dir="$ac_aux_dir"])
-])
-
-# Copyright (C) 1996, 1997, 2000, 2001, 2003, 2005
-# Free Software Foundation, Inc.
-#
-# This file is free software; the Free Software Foundation
-# gives unlimited permission to copy and/or distribute it,
-# with or without modifications, as long as this notice is preserved.
-
-# serial 8
-
-# AM_CONFIG_HEADER is obsolete. It has been replaced by AC_CONFIG_HEADERS.
-AU_DEFUN([AM_CONFIG_HEADER], [AC_CONFIG_HEADERS($@)])
-
-# Do all the work for Automake. -*- Autoconf -*-
-
-# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005
-# Free Software Foundation, Inc.
-#
-# This file is free software; the Free Software Foundation
-# gives unlimited permission to copy and/or distribute it,
-# with or without modifications, as long as this notice is preserved.
-
-# serial 12
-
-# This macro actually does too much. Some checks are only needed if
-# your package does certain things. But this isn't really a big deal.
-
-# AM_INIT_AUTOMAKE(PACKAGE, VERSION, [NO-DEFINE])
-# AM_INIT_AUTOMAKE([OPTIONS])
-# -----------------------------------------------
-# The call with PACKAGE and VERSION arguments is the old style
-# call (pre autoconf-2.50), which is being phased out. PACKAGE
-# and VERSION should now be passed to AC_INIT and removed from
-# the call to AM_INIT_AUTOMAKE.
-# We support both call styles for the transition. After
-# the next Automake release, Autoconf can make the AC_INIT
-# arguments mandatory, and then we can depend on a new Autoconf
-# release and drop the old call support.
-AC_DEFUN([AM_INIT_AUTOMAKE],
-[AC_PREREQ([2.58])dnl
-dnl Autoconf wants to disallow AM_ names. We explicitly allow
-dnl the ones we care about.
-m4_pattern_allow([^AM_[A-Z]+FLAGS$])dnl
-AC_REQUIRE([AM_SET_CURRENT_AUTOMAKE_VERSION])dnl
-AC_REQUIRE([AC_PROG_INSTALL])dnl
-# test to see if srcdir already configured
-if test "`cd $srcdir && pwd`" != "`pwd`" &&
- test -f $srcdir/config.status; then
- AC_MSG_ERROR([source directory already configured; run "make distclean" there first])
-fi
-
-# test whether we have cygpath
-if test -z "$CYGPATH_W"; then
- if (cygpath --version) >/dev/null 2>/dev/null; then
- CYGPATH_W='cygpath -w'
- else
- CYGPATH_W=echo
- fi
-fi
-AC_SUBST([CYGPATH_W])
-
-# Define the identity of the package.
-dnl Distinguish between old-style and new-style calls.
-m4_ifval([$2],
-[m4_ifval([$3], [_AM_SET_OPTION([no-define])])dnl
- AC_SUBST([PACKAGE], [$1])dnl
- AC_SUBST([VERSION], [$2])],
-[_AM_SET_OPTIONS([$1])dnl
- AC_SUBST([PACKAGE], ['AC_PACKAGE_TARNAME'])dnl
- AC_SUBST([VERSION], ['AC_PACKAGE_VERSION'])])dnl
-
-_AM_IF_OPTION([no-define],,
-[AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE", [Name of package])
- AC_DEFINE_UNQUOTED(VERSION, "$VERSION", [Version number of package])])dnl
-
-# Some tools Automake needs.
-AC_REQUIRE([AM_SANITY_CHECK])dnl
-AC_REQUIRE([AC_ARG_PROGRAM])dnl
-AM_MISSING_PROG(ACLOCAL, aclocal-${am__api_version})
-AM_MISSING_PROG(AUTOCONF, autoconf)
-AM_MISSING_PROG(AUTOMAKE, automake-${am__api_version})
-AM_MISSING_PROG(AUTOHEADER, autoheader)
-AM_MISSING_PROG(MAKEINFO, makeinfo)
-AM_PROG_INSTALL_SH
-AM_PROG_INSTALL_STRIP
-AC_REQUIRE([AM_PROG_MKDIR_P])dnl
-# We need awk for the "check" target. The system "awk" is bad on
-# some platforms.
-AC_REQUIRE([AC_PROG_AWK])dnl
-AC_REQUIRE([AC_PROG_MAKE_SET])dnl
-AC_REQUIRE([AM_SET_LEADING_DOT])dnl
-_AM_IF_OPTION([tar-ustar], [_AM_PROG_TAR([ustar])],
- [_AM_IF_OPTION([tar-pax], [_AM_PROG_TAR([pax])],
- [_AM_PROG_TAR([v7])])])
-_AM_IF_OPTION([no-dependencies],,
-[AC_PROVIDE_IFELSE([AC_PROG_CC],
- [_AM_DEPENDENCIES(CC)],
- [define([AC_PROG_CC],
- defn([AC_PROG_CC])[_AM_DEPENDENCIES(CC)])])dnl
-AC_PROVIDE_IFELSE([AC_PROG_CXX],
- [_AM_DEPENDENCIES(CXX)],
- [define([AC_PROG_CXX],
- defn([AC_PROG_CXX])[_AM_DEPENDENCIES(CXX)])])dnl
-])
-])
-
-
-# When config.status generates a header, we must update the stamp-h file.
-# This file resides in the same directory as the config header
-# that is generated. The stamp files are numbered to have different names.
-
-# Autoconf calls _AC_AM_CONFIG_HEADER_HOOK (when defined) in the
-# loop where config.status creates the headers, so we can generate
-# our stamp files there.
-AC_DEFUN([_AC_AM_CONFIG_HEADER_HOOK],
-[# Compute $1's index in $config_headers.
-_am_stamp_count=1
-for _am_header in $config_headers :; do
- case $_am_header in
- $1 | $1:* )
- break ;;
- * )
- _am_stamp_count=`expr $_am_stamp_count + 1` ;;
- esac
-done
-echo "timestamp for $1" >`AS_DIRNAME([$1])`/stamp-h[]$_am_stamp_count])
-
-# Copyright (C) 2001, 2003, 2005 Free Software Foundation, Inc.
-#
-# This file is free software; the Free Software Foundation
-# gives unlimited permission to copy and/or distribute it,
-# with or without modifications, as long as this notice is preserved.
-
-# AM_PROG_INSTALL_SH
-# ------------------
-# Define $install_sh.
-AC_DEFUN([AM_PROG_INSTALL_SH],
-[AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl
-install_sh=${install_sh-"$am_aux_dir/install-sh"}
-AC_SUBST(install_sh)])
-
-# Copyright (C) 2003, 2005 Free Software Foundation, Inc.
-#
-# This file is free software; the Free Software Foundation
-# gives unlimited permission to copy and/or distribute it,
-# with or without modifications, as long as this notice is preserved.
-
-# serial 2
-
-# Check whether the underlying file-system supports filenames
-# with a leading dot. For instance MS-DOS doesn't.
-AC_DEFUN([AM_SET_LEADING_DOT],
-[rm -rf .tst 2>/dev/null
-mkdir .tst 2>/dev/null
-if test -d .tst; then
- am__leading_dot=.
-else
- am__leading_dot=_
-fi
-rmdir .tst 2>/dev/null
-AC_SUBST([am__leading_dot])])
-
-# Check to see how 'make' treats includes. -*- Autoconf -*-
-
-# Copyright (C) 2001, 2002, 2003, 2005 Free Software Foundation, Inc.
-#
-# This file is free software; the Free Software Foundation
-# gives unlimited permission to copy and/or distribute it,
-# with or without modifications, as long as this notice is preserved.
-
-# serial 3
-
-# AM_MAKE_INCLUDE()
-# -----------------
-# Check to see how make treats includes.
-AC_DEFUN([AM_MAKE_INCLUDE],
-[am_make=${MAKE-make}
-cat > confinc << 'END'
-am__doit:
- @echo done
-.PHONY: am__doit
-END
-# If we don't find an include directive, just comment out the code.
-AC_MSG_CHECKING([for style of include used by $am_make])
-am__include="#"
-am__quote=
-_am_result=none
-# First try GNU make style include.
-echo "include confinc" > confmf
-# We grep out `Entering directory' and `Leaving directory'
-# messages which can occur if `w' ends up in MAKEFLAGS.
-# In particular we don't look at `^make:' because GNU make might
-# be invoked under some other name (usually "gmake"), in which
-# case it prints its new name instead of `make'.
-if test "`$am_make -s -f confmf 2> /dev/null | grep -v 'ing directory'`" = "done"; then
- am__include=include
- am__quote=
- _am_result=GNU
-fi
-# Now try BSD make style include.
-if test "$am__include" = "#"; then
- echo '.include "confinc"' > confmf
- if test "`$am_make -s -f confmf 2> /dev/null`" = "done"; then
- am__include=.include
- am__quote="\""
- _am_result=BSD
- fi
-fi
-AC_SUBST([am__include])
-AC_SUBST([am__quote])
-AC_MSG_RESULT([$_am_result])
-rm -f confinc confmf
-])
-
-# Fake the existence of programs that GNU maintainers use. -*- Autoconf -*-
-
-# Copyright (C) 1997, 1999, 2000, 2001, 2003, 2005
-# Free Software Foundation, Inc.
-#
-# This file is free software; the Free Software Foundation
-# gives unlimited permission to copy and/or distribute it,
-# with or without modifications, as long as this notice is preserved.
-
-# serial 4
-
-# AM_MISSING_PROG(NAME, PROGRAM)
-# ------------------------------
-AC_DEFUN([AM_MISSING_PROG],
-[AC_REQUIRE([AM_MISSING_HAS_RUN])
-$1=${$1-"${am_missing_run}$2"}
-AC_SUBST($1)])
-
-
-# AM_MISSING_HAS_RUN
-# ------------------
-# Define MISSING if not defined so far and test if it supports --run.
-# If it does, set am_missing_run to use it, otherwise, to nothing.
-AC_DEFUN([AM_MISSING_HAS_RUN],
-[AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl
-test x"${MISSING+set}" = xset || MISSING="\${SHELL} $am_aux_dir/missing"
-# Use eval to expand $SHELL
-if eval "$MISSING --run true"; then
- am_missing_run="$MISSING --run "
-else
- am_missing_run=
- AC_MSG_WARN([`missing' script is too old or missing])
-fi
-])
-
-# Copyright (C) 2003, 2004, 2005 Free Software Foundation, Inc.
-#
-# This file is free software; the Free Software Foundation
-# gives unlimited permission to copy and/or distribute it,
-# with or without modifications, as long as this notice is preserved.
-
-# AM_PROG_MKDIR_P
-# ---------------
-# Check whether `mkdir -p' is supported, fallback to mkinstalldirs otherwise.
-#
-# Automake 1.8 used `mkdir -m 0755 -p --' to ensure that directories
-# created by `make install' are always world readable, even if the
-# installer happens to have an overly restrictive umask (e.g. 077).
-# This was a mistake. There are at least two reasons why we must not
-# use `-m 0755':
-# - it causes special bits like SGID to be ignored,
-# - it may be too restrictive (some setups expect 775 directories).
-#
-# Do not use -m 0755 and let people choose whatever they expect by
-# setting umask.
-#
-# We cannot accept any implementation of `mkdir' that recognizes `-p'.
-# Some implementations (such as Solaris 8's) are not thread-safe: if a
-# parallel make tries to run `mkdir -p a/b' and `mkdir -p a/c'
-# concurrently, both version can detect that a/ is missing, but only
-# one can create it and the other will error out. Consequently we
-# restrict ourselves to GNU make (using the --version option ensures
-# this.)
-AC_DEFUN([AM_PROG_MKDIR_P],
-[if mkdir -p --version . >/dev/null 2>&1 && test ! -d ./--version; then
- # We used to keeping the `.' as first argument, in order to
- # allow $(mkdir_p) to be used without argument. As in
- # $(mkdir_p) $(somedir)
- # where $(somedir) is conditionally defined. However this is wrong
- # for two reasons:
- # 1. if the package is installed by a user who cannot write `.'
- # make install will fail,
- # 2. the above comment should most certainly read
- # $(mkdir_p) $(DESTDIR)$(somedir)
- # so it does not work when $(somedir) is undefined and
- # $(DESTDIR) is not.
- # To support the latter case, we have to write
- # test -z "$(somedir)" || $(mkdir_p) $(DESTDIR)$(somedir),
- # so the `.' trick is pointless.
- mkdir_p='mkdir -p --'
-else
- # On NextStep and OpenStep, the `mkdir' command does not
- # recognize any option. It will interpret all options as
- # directories to create, and then abort because `.' already
- # exists.
- for d in ./-p ./--version;
- do
- test -d $d && rmdir $d
- done
- # $(mkinstalldirs) is defined by Automake if mkinstalldirs exists.
- if test -f "$ac_aux_dir/mkinstalldirs"; then
- mkdir_p='$(mkinstalldirs)'
- else
- mkdir_p='$(install_sh) -d'
- fi
-fi
-AC_SUBST([mkdir_p])])
-
-# Helper functions for option handling. -*- Autoconf -*-
-
-# Copyright (C) 2001, 2002, 2003, 2005 Free Software Foundation, Inc.
-#
-# This file is free software; the Free Software Foundation
-# gives unlimited permission to copy and/or distribute it,
-# with or without modifications, as long as this notice is preserved.
-
-# serial 3
-
-# _AM_MANGLE_OPTION(NAME)
-# -----------------------
-AC_DEFUN([_AM_MANGLE_OPTION],
-[[_AM_OPTION_]m4_bpatsubst($1, [[^a-zA-Z0-9_]], [_])])
-
-# _AM_SET_OPTION(NAME)
-# ------------------------------
-# Set option NAME. Presently that only means defining a flag for this option.
-AC_DEFUN([_AM_SET_OPTION],
-[m4_define(_AM_MANGLE_OPTION([$1]), 1)])
-
-# _AM_SET_OPTIONS(OPTIONS)
-# ----------------------------------
-# OPTIONS is a space-separated list of Automake options.
-AC_DEFUN([_AM_SET_OPTIONS],
-[AC_FOREACH([_AM_Option], [$1], [_AM_SET_OPTION(_AM_Option)])])
-
-# _AM_IF_OPTION(OPTION, IF-SET, [IF-NOT-SET])
-# -------------------------------------------
-# Execute IF-SET if OPTION is set, IF-NOT-SET otherwise.
-AC_DEFUN([_AM_IF_OPTION],
-[m4_ifset(_AM_MANGLE_OPTION([$1]), [$2], [$3])])
-
-# Check to make sure that the build environment is sane. -*- Autoconf -*-
-
-# Copyright (C) 1996, 1997, 2000, 2001, 2003, 2005
-# Free Software Foundation, Inc.
-#
-# This file is free software; the Free Software Foundation
-# gives unlimited permission to copy and/or distribute it,
-# with or without modifications, as long as this notice is preserved.
-
-# serial 4
-
-# AM_SANITY_CHECK
-# ---------------
-AC_DEFUN([AM_SANITY_CHECK],
-[AC_MSG_CHECKING([whether build environment is sane])
-# Just in case
-sleep 1
-echo timestamp > conftest.file
-# Do `set' in a subshell so we don't clobber the current shell's
-# arguments. Must try -L first in case configure is actually a
-# symlink; some systems play weird games with the mod time of symlinks
-# (eg FreeBSD returns the mod time of the symlink's containing
-# directory).
-if (
- set X `ls -Lt $srcdir/configure conftest.file 2> /dev/null`
- if test "$[*]" = "X"; then
- # -L didn't work.
- set X `ls -t $srcdir/configure conftest.file`
- fi
- rm -f conftest.file
- if test "$[*]" != "X $srcdir/configure conftest.file" \
- && test "$[*]" != "X conftest.file $srcdir/configure"; then
-
- # If neither matched, then we have a broken ls. This can happen
- # if, for instance, CONFIG_SHELL is bash and it inherits a
- # broken ls alias from the environment. This has actually
- # happened. Such a system could not be considered "sane".
- AC_MSG_ERROR([ls -t appears to fail. Make sure there is not a broken
-alias in your environment])
- fi
-
- test "$[2]" = conftest.file
- )
-then
- # Ok.
- :
-else
- AC_MSG_ERROR([newly created file is older than distributed files!
-Check your system clock])
-fi
-AC_MSG_RESULT(yes)])
-
-# Copyright (C) 2001, 2003, 2005 Free Software Foundation, Inc.
-#
-# This file is free software; the Free Software Foundation
-# gives unlimited permission to copy and/or distribute it,
-# with or without modifications, as long as this notice is preserved.
-
-# AM_PROG_INSTALL_STRIP
-# ---------------------
-# One issue with vendor `install' (even GNU) is that you can't
-# specify the program used to strip binaries. This is especially
-# annoying in cross-compiling environments, where the build's strip
-# is unlikely to handle the host's binaries.
-# Fortunately install-sh will honor a STRIPPROG variable, so we
-# always use install-sh in `make install-strip', and initialize
-# STRIPPROG with the value of the STRIP variable (set by the user).
-AC_DEFUN([AM_PROG_INSTALL_STRIP],
-[AC_REQUIRE([AM_PROG_INSTALL_SH])dnl
-# Installed binaries are usually stripped using `strip' when the user
-# run `make install-strip'. However `strip' might not be the right
-# tool to use in cross-compilation environments, therefore Automake
-# will honor the `STRIP' environment variable to overrule this program.
-dnl Don't test for $cross_compiling = yes, because it might be `maybe'.
-if test "$cross_compiling" != no; then
- AC_CHECK_TOOL([STRIP], [strip], :)
-fi
-INSTALL_STRIP_PROGRAM="\${SHELL} \$(install_sh) -c -s"
-AC_SUBST([INSTALL_STRIP_PROGRAM])])
-
-# Check how to create a tarball. -*- Autoconf -*-
-
-# Copyright (C) 2004, 2005 Free Software Foundation, Inc.
-#
-# This file is free software; the Free Software Foundation
-# gives unlimited permission to copy and/or distribute it,
-# with or without modifications, as long as this notice is preserved.
-
-# serial 2
-
-# _AM_PROG_TAR(FORMAT)
-# --------------------
-# Check how to create a tarball in format FORMAT.
-# FORMAT should be one of `v7', `ustar', or `pax'.
-#
-# Substitute a variable $(am__tar) that is a command
-# writing to stdout a FORMAT-tarball containing the directory
-# $tardir.
-# tardir=directory && $(am__tar) > result.tar
-#
-# Substitute a variable $(am__untar) that extract such
-# a tarball read from stdin.
-# $(am__untar) < result.tar
-AC_DEFUN([_AM_PROG_TAR],
-[# Always define AMTAR for backward compatibility.
-AM_MISSING_PROG([AMTAR], [tar])
-m4_if([$1], [v7],
- [am__tar='${AMTAR} chof - "$$tardir"'; am__untar='${AMTAR} xf -'],
- [m4_case([$1], [ustar],, [pax],,
- [m4_fatal([Unknown tar format])])
-AC_MSG_CHECKING([how to create a $1 tar archive])
-# Loop over all known methods to create a tar archive until one works.
-_am_tools='gnutar m4_if([$1], [ustar], [plaintar]) pax cpio none'
-_am_tools=${am_cv_prog_tar_$1-$_am_tools}
-# Do not fold the above two line into one, because Tru64 sh and
-# Solaris sh will not grok spaces in the rhs of `-'.
-for _am_tool in $_am_tools
-do
- case $_am_tool in
- gnutar)
- for _am_tar in tar gnutar gtar;
- do
- AM_RUN_LOG([$_am_tar --version]) && break
- done
- am__tar="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$$tardir"'
- am__tar_="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$tardir"'
- am__untar="$_am_tar -xf -"
- ;;
- plaintar)
- # Must skip GNU tar: if it does not support --format= it doesn't create
- # ustar tarball either.
- (tar --version) >/dev/null 2>&1 && continue
- am__tar='tar chf - "$$tardir"'
- am__tar_='tar chf - "$tardir"'
- am__untar='tar xf -'
- ;;
- pax)
- am__tar='pax -L -x $1 -w "$$tardir"'
- am__tar_='pax -L -x $1 -w "$tardir"'
- am__untar='pax -r'
- ;;
- cpio)
- am__tar='find "$$tardir" -print | cpio -o -H $1 -L'
- am__tar_='find "$tardir" -print | cpio -o -H $1 -L'
- am__untar='cpio -i -H $1 -d'
- ;;
- none)
- am__tar=false
- am__tar_=false
- am__untar=false
- ;;
- esac
-
- # If the value was cached, stop now. We just wanted to have am__tar
- # and am__untar set.
- test -n "${am_cv_prog_tar_$1}" && break
-
- # tar/untar a dummy directory, and stop if the command works
- rm -rf conftest.dir
- mkdir conftest.dir
- echo GrepMe > conftest.dir/file
- AM_RUN_LOG([tardir=conftest.dir && eval $am__tar_ >conftest.tar])
- rm -rf conftest.dir
- if test -s conftest.tar; then
- AM_RUN_LOG([$am__untar <conftest.tar])
- grep GrepMe conftest.dir/file >/dev/null 2>&1 && break
- fi
-done
-rm -rf conftest.dir
-
-AC_CACHE_VAL([am_cv_prog_tar_$1], [am_cv_prog_tar_$1=$_am_tool])
-AC_MSG_RESULT([$am_cv_prog_tar_$1])])
-AC_SUBST([am__tar])
-AC_SUBST([am__untar])
-]) # _AM_PROG_TAR
-
diff --git a/contrib/ofed/librdmacm/acm.c b/contrib/ofed/librdmacm/acm.c
new file mode 100644
index 0000000..b533e29
--- /dev/null
+++ b/contrib/ofed/librdmacm/acm.c
@@ -0,0 +1,443 @@
+/*
+ * Copyright (c) 2010-2012 Intel Corporation. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#include <config.h>
+
+#include <stdio.h>
+#include <inttypes.h>
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <netdb.h>
+#include <unistd.h>
+
+#include "cma.h"
+#include <rdma/rdma_cma.h>
+#include <infiniband/ib.h>
+#include <infiniband/sa.h>
+
+#define ACM_VERSION 1
+
+#define ACM_OP_RESOLVE 0x01
+#define ACM_OP_ACK 0x80
+
+#define ACM_STATUS_SUCCESS 0
+#define ACM_STATUS_ENOMEM 1
+#define ACM_STATUS_EINVAL 2
+#define ACM_STATUS_ENODATA 3
+#define ACM_STATUS_ENOTCONN 5
+#define ACM_STATUS_ETIMEDOUT 6
+#define ACM_STATUS_ESRCADDR 7
+#define ACM_STATUS_ESRCTYPE 8
+#define ACM_STATUS_EDESTADDR 9
+#define ACM_STATUS_EDESTTYPE 10
+
+#define ACM_FLAGS_NODELAY (1<<30)
+
+#define ACM_MSG_HDR_LENGTH 16
+#define ACM_MAX_ADDRESS 64
+#define ACM_MSG_EP_LENGTH 72
+#define ACM_MSG_DATA_LENGTH (ACM_MSG_EP_LENGTH * 8)
+
+struct acm_hdr {
+ uint8_t version;
+ uint8_t opcode;
+ uint8_t status;
+ uint8_t data[3];
+ uint16_t length;
+ uint64_t tid;
+};
+
+#define ACM_EP_INFO_NAME 0x0001
+#define ACM_EP_INFO_ADDRESS_IP 0x0002
+#define ACM_EP_INFO_ADDRESS_IP6 0x0003
+#define ACM_EP_INFO_PATH 0x0010
+
+union acm_ep_info {
+ uint8_t addr[ACM_MAX_ADDRESS];
+ uint8_t name[ACM_MAX_ADDRESS];
+ struct ibv_path_record path;
+};
+
+#define ACM_EP_FLAG_SOURCE (1<<0)
+#define ACM_EP_FLAG_DEST (1<<1)
+
+struct acm_ep_addr_data {
+ uint32_t flags;
+ uint16_t type;
+ uint16_t reserved;
+ union acm_ep_info info;
+};
+
+struct acm_resolve_msg {
+ struct acm_hdr hdr;
+ struct acm_ep_addr_data data[0];
+};
+
+struct acm_msg {
+ struct acm_hdr hdr;
+ union{
+ uint8_t data[ACM_MSG_DATA_LENGTH];
+ struct acm_ep_addr_data resolve_data[0];
+ };
+};
+
+static pthread_mutex_t acm_lock = PTHREAD_MUTEX_INITIALIZER;
+static int sock = -1;
+static uint16_t server_port;
+
+static int ucma_set_server_port(void)
+{
+ FILE *f;
+
+ if ((f = fopen(IBACM_PORT_FILE, "r" STREAM_CLOEXEC))) {
+ if (fscanf(f, "%" SCNu16, &server_port) != 1)
+ server_port = 0;
+ fclose(f);
+ }
+ return server_port;
+}
+
+void ucma_ib_init(void)
+{
+ struct sockaddr_in addr;
+ static int init;
+ int ret;
+
+ if (init)
+ return;
+
+ pthread_mutex_lock(&acm_lock);
+ if (init)
+ goto unlock;
+
+ if (!ucma_set_server_port())
+ goto out;
+
+ sock = socket(AF_INET, SOCK_STREAM | SOCK_CLOEXEC, IPPROTO_TCP);
+ if (sock < 0)
+ goto out;
+
+ memset(&addr, 0, sizeof addr);
+ addr.sin_family = AF_INET;
+ addr.sin_addr.s_addr = htobe32(INADDR_LOOPBACK);
+ addr.sin_port = htobe16(server_port);
+ ret = connect(sock, (struct sockaddr *) &addr, sizeof(addr));
+ if (ret) {
+ close(sock);
+ sock = -1;
+ }
+out:
+ init = 1;
+unlock:
+ pthread_mutex_unlock(&acm_lock);
+}
+
+void ucma_ib_cleanup(void)
+{
+ if (sock >= 0) {
+ shutdown(sock, SHUT_RDWR);
+ close(sock);
+ }
+}
+
+static int ucma_ib_set_addr(struct rdma_addrinfo *ib_rai,
+ struct rdma_addrinfo *rai)
+{
+ struct sockaddr_ib *src, *dst;
+ struct ibv_path_record *path;
+
+ src = calloc(1, sizeof(*src));
+ if (!src)
+ return ERR(ENOMEM);
+
+ dst = calloc(1, sizeof(*dst));
+ if (!dst) {
+ free(src);
+ return ERR(ENOMEM);
+ }
+
+ path = &((struct ibv_path_data *) ib_rai->ai_route)->path;
+
+ src->sib_family = AF_IB;
+ src->sib_pkey = path->pkey;
+ src->sib_flowinfo = htobe32(be32toh(path->flowlabel_hoplimit) >> 8);
+ memcpy(&src->sib_addr, &path->sgid, 16);
+ ucma_set_sid(ib_rai->ai_port_space, rai->ai_src_addr, src);
+
+ dst->sib_family = AF_IB;
+ dst->sib_pkey = path->pkey;
+ dst->sib_flowinfo = htobe32(be32toh(path->flowlabel_hoplimit) >> 8);
+ memcpy(&dst->sib_addr, &path->dgid, 16);
+ ucma_set_sid(ib_rai->ai_port_space, rai->ai_dst_addr, dst);
+
+ ib_rai->ai_src_addr = (struct sockaddr *) src;
+ ib_rai->ai_src_len = sizeof(*src);
+
+ ib_rai->ai_dst_addr = (struct sockaddr *) dst;
+ ib_rai->ai_dst_len = sizeof(*dst);
+
+ return 0;
+}
+
+static int ucma_ib_set_connect(struct rdma_addrinfo *ib_rai,
+ struct rdma_addrinfo *rai)
+{
+ struct ib_connect_hdr *hdr;
+
+ if (rai->ai_family == AF_IB)
+ return 0;
+
+ hdr = calloc(1, sizeof(*hdr));
+ if (!hdr)
+ return ERR(ENOMEM);
+
+ if (rai->ai_family == AF_INET) {
+ hdr->ip_version = 4 << 4;
+ memcpy(&hdr->cma_src_ip4,
+ &((struct sockaddr_in *) rai->ai_src_addr)->sin_addr, 4);
+ memcpy(&hdr->cma_dst_ip4,
+ &((struct sockaddr_in *) rai->ai_dst_addr)->sin_addr, 4);
+ } else {
+ hdr->ip_version = 6 << 4;
+ memcpy(&hdr->cma_src_ip6,
+ &((struct sockaddr_in6 *) rai->ai_src_addr)->sin6_addr, 16);
+ memcpy(&hdr->cma_dst_ip6,
+ &((struct sockaddr_in6 *) rai->ai_dst_addr)->sin6_addr, 16);
+ }
+
+ ib_rai->ai_connect = hdr;
+ ib_rai->ai_connect_len = sizeof(*hdr);
+ return 0;
+}
+
+static void ucma_resolve_af_ib(struct rdma_addrinfo **rai)
+{
+ struct rdma_addrinfo *ib_rai;
+
+ ib_rai = calloc(1, sizeof(*ib_rai));
+ if (!ib_rai)
+ return;
+
+ ib_rai->ai_flags = (*rai)->ai_flags;
+ ib_rai->ai_family = AF_IB;
+ ib_rai->ai_qp_type = (*rai)->ai_qp_type;
+ ib_rai->ai_port_space = (*rai)->ai_port_space;
+
+ ib_rai->ai_route = calloc(1, (*rai)->ai_route_len);
+ if (!ib_rai->ai_route)
+ goto err;
+
+ memcpy(ib_rai->ai_route, (*rai)->ai_route, (*rai)->ai_route_len);
+ ib_rai->ai_route_len = (*rai)->ai_route_len;
+
+ if ((*rai)->ai_src_canonname) {
+ ib_rai->ai_src_canonname = strdup((*rai)->ai_src_canonname);
+ if (!ib_rai->ai_src_canonname)
+ goto err;
+ }
+
+ if ((*rai)->ai_dst_canonname) {
+ ib_rai->ai_dst_canonname = strdup((*rai)->ai_dst_canonname);
+ if (!ib_rai->ai_dst_canonname)
+ goto err;
+ }
+
+ if (ucma_ib_set_connect(ib_rai, *rai))
+ goto err;
+
+ if (ucma_ib_set_addr(ib_rai, *rai))
+ goto err;
+
+ ib_rai->ai_next = *rai;
+ *rai = ib_rai;
+ return;
+
+err:
+ rdma_freeaddrinfo(ib_rai);
+}
+
+static void ucma_ib_save_resp(struct rdma_addrinfo *rai, struct acm_msg *msg)
+{
+ struct acm_ep_addr_data *ep_data;
+ struct ibv_path_data *path_data = NULL;
+ struct sockaddr_in *sin;
+ struct sockaddr_in6 *sin6;
+ int i, cnt, path_cnt = 0;
+
+ cnt = (msg->hdr.length - ACM_MSG_HDR_LENGTH) / ACM_MSG_EP_LENGTH;
+ for (i = 0; i < cnt; i++) {
+ ep_data = &msg->resolve_data[i];
+ switch (ep_data->type) {
+ case ACM_EP_INFO_PATH:
+ ep_data->type = 0;
+ if (!path_data)
+ path_data = (struct ibv_path_data *) ep_data;
+ path_cnt++;
+ break;
+ case ACM_EP_INFO_ADDRESS_IP:
+ if (!(ep_data->flags & ACM_EP_FLAG_SOURCE) || rai->ai_src_len)
+ break;
+
+ sin = calloc(1, sizeof(*sin));
+ if (!sin)
+ break;
+
+ sin->sin_family = AF_INET;
+ memcpy(&sin->sin_addr, &ep_data->info.addr, 4);
+ rai->ai_src_len = sizeof(*sin);
+ rai->ai_src_addr = (struct sockaddr *) sin;
+ break;
+ case ACM_EP_INFO_ADDRESS_IP6:
+ if (!(ep_data->flags & ACM_EP_FLAG_SOURCE) || rai->ai_src_len)
+ break;
+
+ sin6 = calloc(1, sizeof(*sin6));
+ if (!sin6)
+ break;
+
+ sin6->sin6_family = AF_INET6;
+ memcpy(&sin6->sin6_addr, &ep_data->info.addr, 16);
+ rai->ai_src_len = sizeof(*sin6);
+ rai->ai_src_addr = (struct sockaddr *) sin6;
+ break;
+ default:
+ break;
+ }
+ }
+
+ rai->ai_route = calloc(path_cnt, sizeof(*path_data));
+ if (rai->ai_route) {
+ memcpy(rai->ai_route, path_data, path_cnt * sizeof(*path_data));
+ rai->ai_route_len = path_cnt * sizeof(*path_data);
+ }
+}
+
+static void ucma_set_ep_addr(struct acm_ep_addr_data *data, struct sockaddr *addr)
+{
+ if (addr->sa_family == AF_INET) {
+ data->type = ACM_EP_INFO_ADDRESS_IP;
+ memcpy(data->info.addr, &((struct sockaddr_in *) addr)->sin_addr, 4);
+ } else {
+ data->type = ACM_EP_INFO_ADDRESS_IP6;
+ memcpy(data->info.addr, &((struct sockaddr_in6 *) addr)->sin6_addr, 16);
+ }
+}
+
+static int ucma_inet_addr(struct sockaddr *addr, socklen_t len)
+{
+ return len && addr && (addr->sa_family == AF_INET ||
+ addr->sa_family == AF_INET6);
+}
+
+static int ucma_ib_addr(struct sockaddr *addr, socklen_t len)
+{
+ return len && addr && (addr->sa_family == AF_IB);
+}
+
+void ucma_ib_resolve(struct rdma_addrinfo **rai,
+ const struct rdma_addrinfo *hints)
+{
+ struct acm_msg msg;
+ struct acm_ep_addr_data *data;
+ int ret;
+
+ ucma_ib_init();
+ if (sock < 0)
+ return;
+
+ memset(&msg, 0, sizeof msg);
+ msg.hdr.version = ACM_VERSION;
+ msg.hdr.opcode = ACM_OP_RESOLVE;
+ msg.hdr.length = ACM_MSG_HDR_LENGTH;
+
+ data = &msg.resolve_data[0];
+ if (ucma_inet_addr((*rai)->ai_src_addr, (*rai)->ai_src_len)) {
+ data->flags = ACM_EP_FLAG_SOURCE;
+ ucma_set_ep_addr(data, (*rai)->ai_src_addr);
+ data++;
+ msg.hdr.length += ACM_MSG_EP_LENGTH;
+ }
+
+ if (ucma_inet_addr((*rai)->ai_dst_addr, (*rai)->ai_dst_len)) {
+ data->flags = ACM_EP_FLAG_DEST;
+ if (hints->ai_flags & (RAI_NUMERICHOST | RAI_NOROUTE))
+ data->flags |= ACM_FLAGS_NODELAY;
+ ucma_set_ep_addr(data, (*rai)->ai_dst_addr);
+ data++;
+ msg.hdr.length += ACM_MSG_EP_LENGTH;
+ }
+
+ if (hints->ai_route_len ||
+ ucma_ib_addr((*rai)->ai_src_addr, (*rai)->ai_src_len) ||
+ ucma_ib_addr((*rai)->ai_dst_addr, (*rai)->ai_dst_len)) {
+ struct ibv_path_record *path;
+
+ if (hints->ai_route_len == sizeof(struct ibv_path_record))
+ path = (struct ibv_path_record *) hints->ai_route;
+ else if (hints->ai_route_len == sizeof(struct ibv_path_data))
+ path = &((struct ibv_path_data *) hints->ai_route)->path;
+ else
+ path = NULL;
+
+ if (path)
+ memcpy(&data->info.path, path, sizeof(*path));
+
+ if (ucma_ib_addr((*rai)->ai_src_addr, (*rai)->ai_src_len)) {
+ memcpy(&data->info.path.sgid,
+ &((struct sockaddr_ib *) (*rai)->ai_src_addr)->sib_addr, 16);
+ }
+ if (ucma_ib_addr((*rai)->ai_dst_addr, (*rai)->ai_dst_len)) {
+ memcpy(&data->info.path.dgid,
+ &((struct sockaddr_ib *) (*rai)->ai_dst_addr)->sib_addr, 16);
+ }
+ data->type = ACM_EP_INFO_PATH;
+ data++;
+ msg.hdr.length += ACM_MSG_EP_LENGTH;
+ }
+
+ pthread_mutex_lock(&acm_lock);
+ ret = send(sock, (char *) &msg, msg.hdr.length, 0);
+ if (ret != msg.hdr.length) {
+ pthread_mutex_unlock(&acm_lock);
+ return;
+ }
+
+ ret = recv(sock, (char *) &msg, sizeof msg, 0);
+ pthread_mutex_unlock(&acm_lock);
+ if (ret < ACM_MSG_HDR_LENGTH || ret != msg.hdr.length || msg.hdr.status)
+ return;
+
+ ucma_ib_save_resp(*rai, &msg);
+
+ if (af_ib_support && !(hints->ai_flags & RAI_ROUTEONLY) && (*rai)->ai_route_len)
+ ucma_resolve_af_ib(rai);
+}
diff --git a/contrib/ofed/librdmacm/addrinfo.c b/contrib/ofed/librdmacm/addrinfo.c
new file mode 100644
index 0000000..7e66065
--- /dev/null
+++ b/contrib/ofed/librdmacm/addrinfo.c
@@ -0,0 +1,319 @@
+/*
+ * Copyright (c) 2010-2014 Intel Corporation. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ * $Id: cm.c 3453 2005-09-15 21:43:21Z sean.hefty $
+ */
+
+#include <config.h>
+
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <netdb.h>
+#include <unistd.h>
+
+#include "cma.h"
+#include <rdma/rdma_cma.h>
+#include <infiniband/ib.h>
+
+static struct rdma_addrinfo nohints;
+
+static void ucma_convert_to_ai(struct addrinfo *ai,
+ const struct rdma_addrinfo *rai)
+{
+ memset(ai, 0, sizeof(*ai));
+ if (rai->ai_flags & RAI_PASSIVE)
+ ai->ai_flags = AI_PASSIVE;
+ if (rai->ai_flags & RAI_NUMERICHOST)
+ ai->ai_flags |= AI_NUMERICHOST;
+ if (rai->ai_family != AF_IB)
+ ai->ai_family = rai->ai_family;
+
+ switch (rai->ai_qp_type) {
+ case IBV_QPT_RC:
+ case IBV_QPT_UC:
+ case IBV_QPT_XRC_SEND:
+ case IBV_QPT_XRC_RECV:
+ ai->ai_socktype = SOCK_STREAM;
+ break;
+ case IBV_QPT_UD:
+ ai->ai_socktype = SOCK_DGRAM;
+ break;
+ }
+
+ switch (rai->ai_port_space) {
+ case RDMA_PS_TCP:
+ ai->ai_protocol = IPPROTO_TCP;
+ break;
+ case RDMA_PS_IPOIB:
+ case RDMA_PS_UDP:
+ ai->ai_protocol = IPPROTO_UDP;
+ break;
+ case RDMA_PS_IB:
+ if (ai->ai_socktype == SOCK_STREAM)
+ ai->ai_protocol = IPPROTO_TCP;
+ else if (ai->ai_socktype == SOCK_DGRAM)
+ ai->ai_protocol = IPPROTO_UDP;
+ break;
+ }
+
+ if (rai->ai_flags & RAI_PASSIVE) {
+ ai->ai_addrlen = rai->ai_src_len;
+ ai->ai_addr = rai->ai_src_addr;
+ } else {
+ ai->ai_addrlen = rai->ai_dst_len;
+ ai->ai_addr = rai->ai_dst_addr;
+ }
+ ai->ai_canonname = rai->ai_dst_canonname;
+ ai->ai_next = NULL;
+}
+
+static int ucma_copy_addr(struct sockaddr **dst, socklen_t *dst_len,
+ struct sockaddr *src, socklen_t src_len)
+{
+ *dst = malloc(src_len);
+ if (!(*dst))
+ return ERR(ENOMEM);
+
+ memcpy(*dst, src, src_len);
+ *dst_len = src_len;
+ return 0;
+}
+
+void ucma_set_sid(enum rdma_port_space ps, struct sockaddr *addr,
+ struct sockaddr_ib *sib)
+{
+ __be16 port;
+
+ port = addr ? ucma_get_port(addr) : 0;
+ sib->sib_sid = htobe64(((uint64_t) ps << 16) + be16toh(port));
+
+ if (ps)
+ sib->sib_sid_mask = htobe64(RDMA_IB_IP_PS_MASK);
+ if (port)
+ sib->sib_sid_mask |= htobe64(RDMA_IB_IP_PORT_MASK);
+}
+
+static int ucma_convert_in6(int ps, struct sockaddr_ib **dst, socklen_t *dst_len,
+ struct sockaddr_in6 *src, socklen_t src_len)
+{
+ *dst = calloc(1, sizeof(struct sockaddr_ib));
+ if (!(*dst))
+ return ERR(ENOMEM);
+
+ (*dst)->sib_family = AF_IB;
+ (*dst)->sib_pkey = htobe16(0xFFFF);
+ (*dst)->sib_flowinfo = src->sin6_flowinfo;
+ ib_addr_set(&(*dst)->sib_addr, src->sin6_addr.s6_addr32[0],
+ src->sin6_addr.s6_addr32[1], src->sin6_addr.s6_addr32[2],
+ src->sin6_addr.s6_addr32[3]);
+ ucma_set_sid(ps, (struct sockaddr *) src, *dst);
+ (*dst)->sib_scope_id = src->sin6_scope_id;
+
+ *dst_len = sizeof(struct sockaddr_ib);
+ return 0;
+}
+
+static int ucma_convert_to_rai(struct rdma_addrinfo *rai,
+ const struct rdma_addrinfo *hints,
+ const struct addrinfo *ai)
+{
+ int ret;
+
+ if (hints->ai_qp_type) {
+ rai->ai_qp_type = hints->ai_qp_type;
+ } else {
+ switch (ai->ai_socktype) {
+ case SOCK_STREAM:
+ rai->ai_qp_type = IBV_QPT_RC;
+ break;
+ case SOCK_DGRAM:
+ rai->ai_qp_type = IBV_QPT_UD;
+ break;
+ }
+ }
+
+ if (hints->ai_port_space) {
+ rai->ai_port_space = hints->ai_port_space;
+ } else {
+ switch (ai->ai_protocol) {
+ case IPPROTO_TCP:
+ rai->ai_port_space = RDMA_PS_TCP;
+ break;
+ case IPPROTO_UDP:
+ rai->ai_port_space = RDMA_PS_UDP;
+ break;
+ }
+ }
+
+ if (ai->ai_flags & AI_PASSIVE) {
+ rai->ai_flags = RAI_PASSIVE;
+ if (ai->ai_canonname)
+ rai->ai_src_canonname = strdup(ai->ai_canonname);
+
+ if ((hints->ai_flags & RAI_FAMILY) && (hints->ai_family == AF_IB) &&
+ (hints->ai_flags & RAI_NUMERICHOST)) {
+ rai->ai_family = AF_IB;
+ ret = ucma_convert_in6(rai->ai_port_space,
+ (struct sockaddr_ib **) &rai->ai_src_addr,
+ &rai->ai_src_len,
+ (struct sockaddr_in6 *) ai->ai_addr,
+ ai->ai_addrlen);
+ } else {
+ rai->ai_family = ai->ai_family;
+ ret = ucma_copy_addr(&rai->ai_src_addr, &rai->ai_src_len,
+ ai->ai_addr, ai->ai_addrlen);
+ }
+ } else {
+ if (ai->ai_canonname)
+ rai->ai_dst_canonname = strdup(ai->ai_canonname);
+
+ if ((hints->ai_flags & RAI_FAMILY) && (hints->ai_family == AF_IB) &&
+ (hints->ai_flags & RAI_NUMERICHOST)) {
+ rai->ai_family = AF_IB;
+ ret = ucma_convert_in6(rai->ai_port_space,
+ (struct sockaddr_ib **) &rai->ai_dst_addr,
+ &rai->ai_dst_len,
+ (struct sockaddr_in6 *) ai->ai_addr,
+ ai->ai_addrlen);
+ } else {
+ rai->ai_family = ai->ai_family;
+ ret = ucma_copy_addr(&rai->ai_dst_addr, &rai->ai_dst_len,
+ ai->ai_addr, ai->ai_addrlen);
+ }
+ }
+ return ret;
+}
+
+static int ucma_getaddrinfo(const char *node, const char *service,
+ const struct rdma_addrinfo *hints,
+ struct rdma_addrinfo *rai)
+{
+ struct addrinfo ai_hints;
+ struct addrinfo *ai;
+ int ret;
+
+ if (hints != &nohints) {
+ ucma_convert_to_ai(&ai_hints, hints);
+ ret = getaddrinfo(node, service, &ai_hints, &ai);
+ } else {
+ ret = getaddrinfo(node, service, NULL, &ai);
+ }
+ if (ret)
+ return ret;
+
+ ret = ucma_convert_to_rai(rai, hints, ai);
+ freeaddrinfo(ai);
+ return ret;
+}
+
+int rdma_getaddrinfo(const char *node, const char *service,
+ const struct rdma_addrinfo *hints,
+ struct rdma_addrinfo **res)
+{
+ struct rdma_addrinfo *rai;
+ int ret;
+
+ if (!service && !node && !hints)
+ return ERR(EINVAL);
+
+ ret = ucma_init();
+ if (ret)
+ return ret;
+
+ rai = calloc(1, sizeof(*rai));
+ if (!rai)
+ return ERR(ENOMEM);
+
+ if (!hints)
+ hints = &nohints;
+
+ if (node || service) {
+ ret = ucma_getaddrinfo(node, service, hints, rai);
+ } else {
+ rai->ai_flags = hints->ai_flags;
+ rai->ai_family = hints->ai_family;
+ rai->ai_qp_type = hints->ai_qp_type;
+ rai->ai_port_space = hints->ai_port_space;
+ if (hints->ai_dst_len) {
+ ret = ucma_copy_addr(&rai->ai_dst_addr, &rai->ai_dst_len,
+ hints->ai_dst_addr, hints->ai_dst_len);
+ }
+ }
+ if (ret)
+ goto err;
+
+ if (!rai->ai_src_len && hints->ai_src_len) {
+ ret = ucma_copy_addr(&rai->ai_src_addr, &rai->ai_src_len,
+ hints->ai_src_addr, hints->ai_src_len);
+ if (ret)
+ goto err;
+ }
+
+ if (!(rai->ai_flags & RAI_PASSIVE))
+ ucma_ib_resolve(&rai, hints);
+
+ *res = rai;
+ return 0;
+
+err:
+ rdma_freeaddrinfo(rai);
+ return ret;
+}
+
+void rdma_freeaddrinfo(struct rdma_addrinfo *res)
+{
+ struct rdma_addrinfo *rai;
+
+ while (res) {
+ rai = res;
+ res = res->ai_next;
+
+ if (rai->ai_connect)
+ free(rai->ai_connect);
+
+ if (rai->ai_route)
+ free(rai->ai_route);
+
+ if (rai->ai_src_canonname)
+ free(rai->ai_src_canonname);
+
+ if (rai->ai_dst_canonname)
+ free(rai->ai_dst_canonname);
+
+ if (rai->ai_src_addr)
+ free(rai->ai_src_addr);
+
+ if (rai->ai_dst_addr)
+ free(rai->ai_dst_addr);
+
+ free(rai);
+ }
+}
diff --git a/contrib/ofed/librdmacm/cma.c b/contrib/ofed/librdmacm/cma.c
new file mode 100644
index 0000000..8338887
--- /dev/null
+++ b/contrib/ofed/librdmacm/cma.c
@@ -0,0 +1,2460 @@
+/*
+ * Copyright (c) 2005-2014 Intel Corporation. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#include <config.h>
+
+#include <stdlib.h>
+#include <string.h>
+#include <glob.h>
+#include <stdio.h>
+#include <fcntl.h>
+#include <errno.h>
+#include <stdint.h>
+#include <poll.h>
+#include <unistd.h>
+#include <pthread.h>
+#include <infiniband/endian.h>
+#include <stddef.h>
+#include <netdb.h>
+#include <syslog.h>
+#include <limits.h>
+
+#include "cma.h"
+#include "indexer.h"
+#include <infiniband/driver.h>
+#include <infiniband/marshall.h>
+#include <rdma/rdma_cma.h>
+#include <rdma/rdma_cma_abi.h>
+#include <rdma/rdma_verbs.h>
+#include <infiniband/ib.h>
+
+#define CMA_INIT_CMD(req, req_size, op) \
+do { \
+ memset(req, 0, req_size); \
+ (req)->cmd = UCMA_CMD_##op; \
+ (req)->in = req_size - sizeof(struct ucma_abi_cmd_hdr); \
+} while (0)
+
+#define CMA_INIT_CMD_RESP(req, req_size, op, resp, resp_size) \
+do { \
+ CMA_INIT_CMD(req, req_size, op); \
+ (req)->out = resp_size; \
+ (req)->response = (uintptr_t) (resp); \
+} while (0)
+
+struct cma_port {
+ uint8_t link_layer;
+};
+
+struct cma_device {
+ struct ibv_context *verbs;
+ struct ibv_pd *pd;
+ struct ibv_xrcd *xrcd;
+ struct cma_port *port;
+ __be64 guid;
+ int port_cnt;
+ int refcnt;
+ int max_qpsize;
+ uint8_t max_initiator_depth;
+ uint8_t max_responder_resources;
+};
+
+struct cma_id_private {
+ struct rdma_cm_id id;
+ struct cma_device *cma_dev;
+ void *connect;
+ size_t connect_len;
+ int events_completed;
+ int connect_error;
+ int sync;
+ pthread_cond_t cond;
+ pthread_mutex_t mut;
+ uint32_t handle;
+ struct cma_multicast *mc_list;
+ struct ibv_qp_init_attr *qp_init_attr;
+ uint8_t initiator_depth;
+ uint8_t responder_resources;
+};
+
+struct cma_multicast {
+ struct cma_multicast *next;
+ struct cma_id_private *id_priv;
+ void *context;
+ int events_completed;
+ pthread_cond_t cond;
+ uint32_t handle;
+ union ibv_gid mgid;
+ uint16_t mlid;
+ struct sockaddr_storage addr;
+};
+
+struct cma_event {
+ struct rdma_cm_event event;
+ uint8_t private_data[RDMA_MAX_PRIVATE_DATA];
+ struct cma_id_private *id_priv;
+ struct cma_multicast *mc;
+};
+
+static struct cma_device *cma_dev_array;
+static int cma_dev_cnt;
+static int cma_init_cnt;
+static pthread_mutex_t mut = PTHREAD_MUTEX_INITIALIZER;
+static int abi_ver = RDMA_USER_CM_MAX_ABI_VERSION;
+int af_ib_support;
+static struct index_map ucma_idm;
+static fastlock_t idm_lock;
+
+static int check_abi_version(void)
+{
+ char value[8];
+
+ if ((ibv_read_sysfs_file(ibv_get_sysfs_path(),
+ "class/misc/rdma_cm/abi_version",
+ value, sizeof value) < 0) &&
+ (ibv_read_sysfs_file(ibv_get_sysfs_path(),
+ "class/infiniband_ucma/abi_version",
+ value, sizeof value) < 0)) {
+ /*
+ * Older version of Linux do not have class/misc. To support
+ * backports, assume the most recent version of the ABI. If
+ * we're wrong, we'll simply fail later when calling the ABI.
+ */
+ return 0;
+ }
+
+ abi_ver = strtol(value, NULL, 10);
+ if (abi_ver < RDMA_USER_CM_MIN_ABI_VERSION ||
+ abi_ver > RDMA_USER_CM_MAX_ABI_VERSION) {
+ return -1;
+ }
+ return 0;
+}
+
+/*
+ * This function is called holding the mutex lock
+ * cma_dev_cnt must be set before calling this function to
+ * ensure that the lock is not acquired recursively.
+ */
+static void ucma_set_af_ib_support(void)
+{
+ struct rdma_cm_id *id;
+ struct sockaddr_ib sib;
+ int ret;
+
+ ret = rdma_create_id(NULL, &id, NULL, RDMA_PS_IB);
+ if (ret)
+ return;
+
+ memset(&sib, 0, sizeof sib);
+ sib.sib_family = AF_IB;
+ sib.sib_sid = htobe64(RDMA_IB_IP_PS_TCP);
+ sib.sib_sid_mask = htobe64(RDMA_IB_IP_PS_MASK);
+ af_ib_support = 1;
+ ret = rdma_bind_addr(id, (struct sockaddr *) &sib);
+ af_ib_support = !ret;
+
+ rdma_destroy_id(id);
+}
+
+int ucma_init(void)
+{
+ struct ibv_device **dev_list = NULL;
+ int i, ret, dev_cnt;
+
+ /* Quick check without lock to see if we're already initialized */
+ if (cma_dev_cnt)
+ return 0;
+
+ pthread_mutex_lock(&mut);
+ if (cma_dev_cnt) {
+ pthread_mutex_unlock(&mut);
+ return 0;
+ }
+
+ fastlock_init(&idm_lock);
+ ret = check_abi_version();
+ if (ret)
+ goto err1;
+
+ dev_list = ibv_get_device_list(&dev_cnt);
+ if (!dev_list) {
+ ret = ERR(ENODEV);
+ goto err1;
+ }
+
+ if (!dev_cnt) {
+ ret = ERR(ENODEV);
+ goto err2;
+ }
+
+ cma_dev_array = calloc(dev_cnt, sizeof(*cma_dev_array));
+ if (!cma_dev_array) {
+ ret = ERR(ENOMEM);
+ goto err2;
+ }
+
+ for (i = 0; dev_list[i]; i++)
+ cma_dev_array[i].guid = ibv_get_device_guid(dev_list[i]);
+
+ cma_dev_cnt = dev_cnt;
+ ucma_set_af_ib_support();
+ pthread_mutex_unlock(&mut);
+ ibv_free_device_list(dev_list);
+ return 0;
+
+err2:
+ ibv_free_device_list(dev_list);
+err1:
+ fastlock_destroy(&idm_lock);
+ pthread_mutex_unlock(&mut);
+ return ret;
+}
+
+static struct ibv_context *ucma_open_device(__be64 guid)
+{
+ struct ibv_device **dev_list;
+ struct ibv_context *verbs = NULL;
+ int i;
+
+ dev_list = ibv_get_device_list(NULL);
+ if (!dev_list) {
+ return NULL;
+ }
+
+ for (i = 0; dev_list[i]; i++) {
+ if (ibv_get_device_guid(dev_list[i]) == guid) {
+ verbs = ibv_open_device(dev_list[i]);
+ break;
+ }
+ }
+
+ ibv_free_device_list(dev_list);
+ return verbs;
+}
+
+static int ucma_init_device(struct cma_device *cma_dev)
+{
+ struct ibv_port_attr port_attr;
+ struct ibv_device_attr attr;
+ int i, ret;
+
+ if (cma_dev->verbs)
+ return 0;
+
+ cma_dev->verbs = ucma_open_device(cma_dev->guid);
+ if (!cma_dev->verbs)
+ return ERR(ENODEV);
+
+ ret = ibv_query_device(cma_dev->verbs, &attr);
+ if (ret) {
+ ret = ERR(ret);
+ goto err;
+ }
+
+ cma_dev->port = malloc(sizeof(*cma_dev->port) * attr.phys_port_cnt);
+ if (!cma_dev->port) {
+ ret = ERR(ENOMEM);
+ goto err;
+ }
+
+ for (i = 1; i <= attr.phys_port_cnt; i++) {
+ if (ibv_query_port(cma_dev->verbs, i, &port_attr))
+ cma_dev->port[i - 1].link_layer = IBV_LINK_LAYER_UNSPECIFIED;
+ else
+ cma_dev->port[i - 1].link_layer = port_attr.link_layer;
+ }
+
+ cma_dev->port_cnt = attr.phys_port_cnt;
+ cma_dev->max_qpsize = attr.max_qp_wr;
+ cma_dev->max_initiator_depth = (uint8_t) attr.max_qp_init_rd_atom;
+ cma_dev->max_responder_resources = (uint8_t) attr.max_qp_rd_atom;
+ cma_init_cnt++;
+ return 0;
+
+err:
+ ibv_close_device(cma_dev->verbs);
+ cma_dev->verbs = NULL;
+ return ret;
+}
+
+static int ucma_init_all(void)
+{
+ int i, ret = 0;
+
+ if (!cma_dev_cnt) {
+ ret = ucma_init();
+ if (ret)
+ return ret;
+ }
+
+ if (cma_init_cnt == cma_dev_cnt)
+ return 0;
+
+ pthread_mutex_lock(&mut);
+ for (i = 0; i < cma_dev_cnt; i++) {
+ ret = ucma_init_device(&cma_dev_array[i]);
+ if (ret)
+ break;
+ }
+ pthread_mutex_unlock(&mut);
+ return ret;
+}
+
+struct ibv_context **rdma_get_devices(int *num_devices)
+{
+ struct ibv_context **devs = NULL;
+ int i;
+
+ if (ucma_init_all())
+ goto out;
+
+ devs = malloc(sizeof(*devs) * (cma_dev_cnt + 1));
+ if (!devs)
+ goto out;
+
+ for (i = 0; i < cma_dev_cnt; i++)
+ devs[i] = cma_dev_array[i].verbs;
+ devs[i] = NULL;
+out:
+ if (num_devices)
+ *num_devices = devs ? cma_dev_cnt : 0;
+ return devs;
+}
+
+void rdma_free_devices(struct ibv_context **list)
+{
+ free(list);
+}
+
+struct rdma_event_channel *rdma_create_event_channel(void)
+{
+ struct rdma_event_channel *channel;
+
+ if (ucma_init())
+ return NULL;
+
+ channel = malloc(sizeof(*channel));
+ if (!channel)
+ return NULL;
+
+ channel->fd = open("/dev/rdma_cm", O_RDWR | O_CLOEXEC);
+ if (channel->fd < 0) {
+ goto err;
+ }
+ return channel;
+err:
+ free(channel);
+ return NULL;
+}
+
+void rdma_destroy_event_channel(struct rdma_event_channel *channel)
+{
+ close(channel->fd);
+ free(channel);
+}
+
+static int ucma_get_device(struct cma_id_private *id_priv, __be64 guid)
+{
+ struct cma_device *cma_dev;
+ int i, ret;
+
+ for (i = 0; i < cma_dev_cnt; i++) {
+ cma_dev = &cma_dev_array[i];
+ if (cma_dev->guid == guid)
+ goto match;
+ }
+
+ return ERR(ENODEV);
+match:
+ pthread_mutex_lock(&mut);
+ if ((ret = ucma_init_device(cma_dev)))
+ goto out;
+
+ if (!cma_dev->refcnt++) {
+ cma_dev->pd = ibv_alloc_pd(cma_dev->verbs);
+ if (!cma_dev->pd) {
+ cma_dev->refcnt--;
+ ret = ERR(ENOMEM);
+ goto out;
+ }
+ }
+ id_priv->cma_dev = cma_dev;
+ id_priv->id.verbs = cma_dev->verbs;
+ id_priv->id.pd = cma_dev->pd;
+out:
+ pthread_mutex_unlock(&mut);
+ return ret;
+}
+
+static void ucma_put_device(struct cma_device *cma_dev)
+{
+ pthread_mutex_lock(&mut);
+ if (!--cma_dev->refcnt) {
+ ibv_dealloc_pd(cma_dev->pd);
+ if (cma_dev->xrcd)
+ ibv_close_xrcd(cma_dev->xrcd);
+ }
+ pthread_mutex_unlock(&mut);
+}
+
+static struct ibv_xrcd *ucma_get_xrcd(struct cma_device *cma_dev)
+{
+ struct ibv_xrcd_init_attr attr;
+
+ pthread_mutex_lock(&mut);
+ if (!cma_dev->xrcd) {
+ memset(&attr, 0, sizeof attr);
+ attr.comp_mask = IBV_XRCD_INIT_ATTR_FD | IBV_XRCD_INIT_ATTR_OFLAGS;
+ attr.fd = -1;
+ attr.oflags = O_CREAT;
+ cma_dev->xrcd = ibv_open_xrcd(cma_dev->verbs, &attr);
+ }
+ pthread_mutex_unlock(&mut);
+ return cma_dev->xrcd;
+}
+
+static void ucma_insert_id(struct cma_id_private *id_priv)
+{
+ fastlock_acquire(&idm_lock);
+ idm_set(&ucma_idm, id_priv->handle, id_priv);
+ fastlock_release(&idm_lock);
+}
+
+static void ucma_remove_id(struct cma_id_private *id_priv)
+{
+ if (id_priv->handle <= IDX_MAX_INDEX)
+ idm_clear(&ucma_idm, id_priv->handle);
+}
+
+static struct cma_id_private *ucma_lookup_id(int handle)
+{
+ return idm_lookup(&ucma_idm, handle);
+}
+
+static void ucma_free_id(struct cma_id_private *id_priv)
+{
+ ucma_remove_id(id_priv);
+ if (id_priv->cma_dev)
+ ucma_put_device(id_priv->cma_dev);
+ pthread_cond_destroy(&id_priv->cond);
+ pthread_mutex_destroy(&id_priv->mut);
+ if (id_priv->id.route.path_rec)
+ free(id_priv->id.route.path_rec);
+
+ if (id_priv->sync)
+ rdma_destroy_event_channel(id_priv->id.channel);
+ if (id_priv->connect_len)
+ free(id_priv->connect);
+ free(id_priv);
+}
+
+static struct cma_id_private *ucma_alloc_id(struct rdma_event_channel *channel,
+ void *context,
+ enum rdma_port_space ps,
+ enum ibv_qp_type qp_type)
+{
+ struct cma_id_private *id_priv;
+
+ id_priv = calloc(1, sizeof(*id_priv));
+ if (!id_priv)
+ return NULL;
+
+ id_priv->id.context = context;
+ id_priv->id.ps = ps;
+ id_priv->id.qp_type = qp_type;
+ id_priv->handle = 0xFFFFFFFF;
+
+ if (!channel) {
+ id_priv->id.channel = rdma_create_event_channel();
+ if (!id_priv->id.channel)
+ goto err;
+ id_priv->sync = 1;
+ } else {
+ id_priv->id.channel = channel;
+ }
+
+ pthread_mutex_init(&id_priv->mut, NULL);
+ if (pthread_cond_init(&id_priv->cond, NULL))
+ goto err;
+
+ return id_priv;
+
+err: ucma_free_id(id_priv);
+ return NULL;
+}
+
+static int rdma_create_id2(struct rdma_event_channel *channel,
+ struct rdma_cm_id **id, void *context,
+ enum rdma_port_space ps, enum ibv_qp_type qp_type)
+{
+ struct ucma_abi_create_id_resp resp;
+ struct ucma_abi_create_id cmd;
+ struct cma_id_private *id_priv;
+ int ret;
+
+ ret = ucma_init();
+ if (ret)
+ return ret;
+
+ id_priv = ucma_alloc_id(channel, context, ps, qp_type);
+ if (!id_priv)
+ return ERR(ENOMEM);
+
+ CMA_INIT_CMD_RESP(&cmd, sizeof cmd, CREATE_ID, &resp, sizeof resp);
+ cmd.uid = (uintptr_t) id_priv;
+ cmd.ps = ps;
+ cmd.qp_type = qp_type;
+
+ ret = write(id_priv->id.channel->fd, &cmd, sizeof cmd);
+ if (ret != sizeof cmd)
+ goto err;
+
+ VALGRIND_MAKE_MEM_DEFINED(&resp, sizeof resp);
+
+ id_priv->handle = resp.id;
+ ucma_insert_id(id_priv);
+ *id = &id_priv->id;
+ return 0;
+
+err: ucma_free_id(id_priv);
+ return ret;
+}
+
+int rdma_create_id(struct rdma_event_channel *channel,
+ struct rdma_cm_id **id, void *context,
+ enum rdma_port_space ps)
+{
+ enum ibv_qp_type qp_type;
+
+ qp_type = (ps == RDMA_PS_IPOIB || ps == RDMA_PS_UDP) ?
+ IBV_QPT_UD : IBV_QPT_RC;
+ return rdma_create_id2(channel, id, context, ps, qp_type);
+}
+
+static int ucma_destroy_kern_id(int fd, uint32_t handle)
+{
+ struct ucma_abi_destroy_id_resp resp;
+ struct ucma_abi_destroy_id cmd;
+ int ret;
+
+ CMA_INIT_CMD_RESP(&cmd, sizeof cmd, DESTROY_ID, &resp, sizeof resp);
+ cmd.id = handle;
+
+ ret = write(fd, &cmd, sizeof cmd);
+ if (ret != sizeof cmd)
+ return (ret >= 0) ? ERR(ENODATA) : -1;
+
+ VALGRIND_MAKE_MEM_DEFINED(&resp, sizeof resp);
+
+ return resp.events_reported;
+}
+
+int rdma_destroy_id(struct rdma_cm_id *id)
+{
+ struct cma_id_private *id_priv;
+ int ret;
+
+ id_priv = container_of(id, struct cma_id_private, id);
+ ret = ucma_destroy_kern_id(id->channel->fd, id_priv->handle);
+ if (ret < 0)
+ return ret;
+
+ if (id_priv->id.event)
+ rdma_ack_cm_event(id_priv->id.event);
+
+ pthread_mutex_lock(&id_priv->mut);
+ while (id_priv->events_completed < ret)
+ pthread_cond_wait(&id_priv->cond, &id_priv->mut);
+ pthread_mutex_unlock(&id_priv->mut);
+
+ ucma_free_id(id_priv);
+ return 0;
+}
+
+int ucma_addrlen(struct sockaddr *addr)
+{
+ if (!addr)
+ return 0;
+
+ switch (addr->sa_family) {
+ case PF_INET:
+ return sizeof(struct sockaddr_in);
+ case PF_INET6:
+ return sizeof(struct sockaddr_in6);
+ case PF_IB:
+ return af_ib_support ? sizeof(struct sockaddr_ib) : 0;
+ default:
+ return 0;
+ }
+}
+
+static int ucma_query_addr(struct rdma_cm_id *id)
+{
+ struct ucma_abi_query_addr_resp resp;
+ struct ucma_abi_query cmd;
+ struct cma_id_private *id_priv;
+ int ret;
+
+ CMA_INIT_CMD_RESP(&cmd, sizeof cmd, QUERY, &resp, sizeof resp);
+ id_priv = container_of(id, struct cma_id_private, id);
+ cmd.id = id_priv->handle;
+ cmd.option = UCMA_QUERY_ADDR;
+
+ ret = write(id->channel->fd, &cmd, sizeof cmd);
+ if (ret != sizeof cmd)
+ return (ret >= 0) ? ERR(ENODATA) : -1;
+
+ VALGRIND_MAKE_MEM_DEFINED(&resp, sizeof resp);
+
+ memcpy(&id->route.addr.src_addr, &resp.src_addr, resp.src_size);
+ memcpy(&id->route.addr.dst_addr, &resp.dst_addr, resp.dst_size);
+
+ if (!id_priv->cma_dev && resp.node_guid) {
+ ret = ucma_get_device(id_priv, resp.node_guid);
+ if (ret)
+ return ret;
+ id->port_num = resp.port_num;
+ id->route.addr.addr.ibaddr.pkey = resp.pkey;
+ }
+
+ return 0;
+}
+
+static int ucma_query_gid(struct rdma_cm_id *id)
+{
+ struct ucma_abi_query_addr_resp resp;
+ struct ucma_abi_query cmd;
+ struct cma_id_private *id_priv;
+ struct sockaddr_ib *sib;
+ int ret;
+
+ CMA_INIT_CMD_RESP(&cmd, sizeof cmd, QUERY, &resp, sizeof resp);
+ id_priv = container_of(id, struct cma_id_private, id);
+ cmd.id = id_priv->handle;
+ cmd.option = UCMA_QUERY_GID;
+
+ ret = write(id->channel->fd, &cmd, sizeof cmd);
+ if (ret != sizeof cmd)
+ return (ret >= 0) ? ERR(ENODATA) : -1;
+
+ VALGRIND_MAKE_MEM_DEFINED(&resp, sizeof resp);
+
+ sib = (struct sockaddr_ib *) &resp.src_addr;
+ memcpy(id->route.addr.addr.ibaddr.sgid.raw, sib->sib_addr.sib_raw,
+ sizeof id->route.addr.addr.ibaddr.sgid);
+
+ sib = (struct sockaddr_ib *) &resp.dst_addr;
+ memcpy(id->route.addr.addr.ibaddr.dgid.raw, sib->sib_addr.sib_raw,
+ sizeof id->route.addr.addr.ibaddr.dgid);
+
+ return 0;
+}
+
+static void ucma_convert_path(struct ibv_path_data *path_data,
+ struct ibv_sa_path_rec *sa_path)
+{
+ uint32_t fl_hop;
+
+ sa_path->dgid = path_data->path.dgid;
+ sa_path->sgid = path_data->path.sgid;
+ sa_path->dlid = path_data->path.dlid;
+ sa_path->slid = path_data->path.slid;
+ sa_path->raw_traffic = 0;
+
+ fl_hop = be32toh(path_data->path.flowlabel_hoplimit);
+ sa_path->flow_label = htobe32(fl_hop >> 8);
+ sa_path->hop_limit = (uint8_t) fl_hop;
+
+ sa_path->traffic_class = path_data->path.tclass;
+ sa_path->reversible = path_data->path.reversible_numpath >> 7;
+ sa_path->numb_path = 1;
+ sa_path->pkey = path_data->path.pkey;
+ sa_path->sl = be16toh(path_data->path.qosclass_sl) & 0xF;
+ sa_path->mtu_selector = 2; /* exactly */
+ sa_path->mtu = path_data->path.mtu & 0x1F;
+ sa_path->rate_selector = 2;
+ sa_path->rate = path_data->path.rate & 0x1F;
+ sa_path->packet_life_time_selector = 2;
+ sa_path->packet_life_time = path_data->path.packetlifetime & 0x1F;
+
+ sa_path->preference = (uint8_t) path_data->flags;
+}
+
+static int ucma_query_path(struct rdma_cm_id *id)
+{
+ struct ucma_abi_query_path_resp *resp;
+ struct ucma_abi_query cmd;
+ struct cma_id_private *id_priv;
+ int ret, i, size;
+
+ size = sizeof(*resp) + sizeof(struct ibv_path_data) * 6;
+ resp = alloca(size);
+ CMA_INIT_CMD_RESP(&cmd, sizeof cmd, QUERY, resp, size);
+ id_priv = container_of(id, struct cma_id_private, id);
+ cmd.id = id_priv->handle;
+ cmd.option = UCMA_QUERY_PATH;
+
+ ret = write(id->channel->fd, &cmd, sizeof cmd);
+ if (ret != sizeof cmd)
+ return (ret >= 0) ? ERR(ENODATA) : -1;
+
+ VALGRIND_MAKE_MEM_DEFINED(resp, size);
+
+ if (resp->num_paths) {
+ id->route.path_rec = malloc(sizeof(*id->route.path_rec) *
+ resp->num_paths);
+ if (!id->route.path_rec)
+ return ERR(ENOMEM);
+
+ id->route.num_paths = resp->num_paths;
+ for (i = 0; i < resp->num_paths; i++)
+ ucma_convert_path(&resp->path_data[i], &id->route.path_rec[i]);
+ }
+
+ return 0;
+}
+
+static int ucma_query_route(struct rdma_cm_id *id)
+{
+ struct ucma_abi_query_route_resp resp;
+ struct ucma_abi_query cmd;
+ struct cma_id_private *id_priv;
+ int ret, i;
+
+ CMA_INIT_CMD_RESP(&cmd, sizeof cmd, QUERY_ROUTE, &resp, sizeof resp);
+ id_priv = container_of(id, struct cma_id_private, id);
+ cmd.id = id_priv->handle;
+
+ ret = write(id->channel->fd, &cmd, sizeof cmd);
+ if (ret != sizeof cmd)
+ return (ret >= 0) ? ERR(ENODATA) : -1;
+
+ VALGRIND_MAKE_MEM_DEFINED(&resp, sizeof resp);
+
+ if (resp.num_paths) {
+ id->route.path_rec = malloc(sizeof(*id->route.path_rec) *
+ resp.num_paths);
+ if (!id->route.path_rec)
+ return ERR(ENOMEM);
+
+ id->route.num_paths = resp.num_paths;
+ for (i = 0; i < resp.num_paths; i++)
+ ibv_copy_path_rec_from_kern(&id->route.path_rec[i],
+ &resp.ib_route[i]);
+ }
+
+ memcpy(id->route.addr.addr.ibaddr.sgid.raw, resp.ib_route[0].sgid,
+ sizeof id->route.addr.addr.ibaddr.sgid);
+ memcpy(id->route.addr.addr.ibaddr.dgid.raw, resp.ib_route[0].dgid,
+ sizeof id->route.addr.addr.ibaddr.dgid);
+ id->route.addr.addr.ibaddr.pkey = resp.ib_route[0].pkey;
+ memcpy(&id->route.addr.src_addr, &resp.src_addr,
+ sizeof resp.src_addr);
+ memcpy(&id->route.addr.dst_addr, &resp.dst_addr,
+ sizeof resp.dst_addr);
+
+ if (!id_priv->cma_dev && resp.node_guid) {
+ ret = ucma_get_device(id_priv, resp.node_guid);
+ if (ret)
+ return ret;
+ id_priv->id.port_num = resp.port_num;
+ }
+
+ return 0;
+}
+
+static int rdma_bind_addr2(struct rdma_cm_id *id, struct sockaddr *addr,
+ socklen_t addrlen)
+{
+ struct ucma_abi_bind cmd;
+ struct cma_id_private *id_priv;
+ int ret;
+
+ CMA_INIT_CMD(&cmd, sizeof cmd, BIND);
+ id_priv = container_of(id, struct cma_id_private, id);
+ cmd.id = id_priv->handle;
+ cmd.addr_size = addrlen;
+ memcpy(&cmd.addr, addr, addrlen);
+
+ ret = write(id->channel->fd, &cmd, sizeof cmd);
+ if (ret != sizeof cmd)
+ return (ret >= 0) ? ERR(ENODATA) : -1;
+
+ ret = ucma_query_addr(id);
+ if (!ret)
+ ret = ucma_query_gid(id);
+ return ret;
+}
+
+int rdma_bind_addr(struct rdma_cm_id *id, struct sockaddr *addr)
+{
+ struct ucma_abi_bind_ip cmd;
+ struct cma_id_private *id_priv;
+ int ret, addrlen;
+
+ addrlen = ucma_addrlen(addr);
+ if (!addrlen)
+ return ERR(EINVAL);
+
+ if (af_ib_support)
+ return rdma_bind_addr2(id, addr, addrlen);
+
+ CMA_INIT_CMD(&cmd, sizeof cmd, BIND_IP);
+ id_priv = container_of(id, struct cma_id_private, id);
+ cmd.id = id_priv->handle;
+ memcpy(&cmd.addr, addr, addrlen);
+
+ ret = write(id->channel->fd, &cmd, sizeof cmd);
+ if (ret != sizeof cmd)
+ return (ret >= 0) ? ERR(ENODATA) : -1;
+
+ return ucma_query_route(id);
+}
+
+int ucma_complete(struct rdma_cm_id *id)
+{
+ struct cma_id_private *id_priv;
+ int ret;
+
+ id_priv = container_of(id, struct cma_id_private, id);
+ if (!id_priv->sync)
+ return 0;
+
+ if (id_priv->id.event) {
+ rdma_ack_cm_event(id_priv->id.event);
+ id_priv->id.event = NULL;
+ }
+
+ ret = rdma_get_cm_event(id_priv->id.channel, &id_priv->id.event);
+ if (ret)
+ return ret;
+
+ if (id_priv->id.event->status) {
+ if (id_priv->id.event->event == RDMA_CM_EVENT_REJECTED)
+ ret = ERR(ECONNREFUSED);
+ else if (id_priv->id.event->status < 0)
+ ret = ERR(-id_priv->id.event->status);
+ else
+ ret = ERR(-id_priv->id.event->status);
+ }
+ return ret;
+}
+
+static int rdma_resolve_addr2(struct rdma_cm_id *id, struct sockaddr *src_addr,
+ socklen_t src_len, struct sockaddr *dst_addr,
+ socklen_t dst_len, int timeout_ms)
+{
+ struct ucma_abi_resolve_addr cmd;
+ struct cma_id_private *id_priv;
+ int ret;
+
+ CMA_INIT_CMD(&cmd, sizeof cmd, RESOLVE_ADDR);
+ id_priv = container_of(id, struct cma_id_private, id);
+ cmd.id = id_priv->handle;
+ if ((cmd.src_size = src_len))
+ memcpy(&cmd.src_addr, src_addr, src_len);
+ memcpy(&cmd.dst_addr, dst_addr, dst_len);
+ cmd.dst_size = dst_len;
+ cmd.timeout_ms = timeout_ms;
+
+ ret = write(id->channel->fd, &cmd, sizeof cmd);
+ if (ret != sizeof cmd)
+ return (ret >= 0) ? ERR(ENODATA) : -1;
+
+ memcpy(&id->route.addr.dst_addr, dst_addr, dst_len);
+ return ucma_complete(id);
+}
+
+int rdma_resolve_addr(struct rdma_cm_id *id, struct sockaddr *src_addr,
+ struct sockaddr *dst_addr, int timeout_ms)
+{
+ struct ucma_abi_resolve_ip cmd;
+ struct cma_id_private *id_priv;
+ int ret, dst_len, src_len;
+
+ dst_len = ucma_addrlen(dst_addr);
+ if (!dst_len)
+ return ERR(EINVAL);
+
+ src_len = ucma_addrlen(src_addr);
+ if (src_addr && !src_len)
+ return ERR(EINVAL);
+
+ if (af_ib_support)
+ return rdma_resolve_addr2(id, src_addr, src_len, dst_addr,
+ dst_len, timeout_ms);
+
+ CMA_INIT_CMD(&cmd, sizeof cmd, RESOLVE_IP);
+ id_priv = container_of(id, struct cma_id_private, id);
+ cmd.id = id_priv->handle;
+ if (src_addr)
+ memcpy(&cmd.src_addr, src_addr, src_len);
+ memcpy(&cmd.dst_addr, dst_addr, dst_len);
+ cmd.timeout_ms = timeout_ms;
+
+ ret = write(id->channel->fd, &cmd, sizeof cmd);
+ if (ret != sizeof cmd)
+ return (ret >= 0) ? ERR(ENODATA) : -1;
+
+ memcpy(&id->route.addr.dst_addr, dst_addr, dst_len);
+ return ucma_complete(id);
+}
+
+static int ucma_set_ib_route(struct rdma_cm_id *id)
+{
+ struct rdma_addrinfo hint, *rai;
+ int ret;
+
+ memset(&hint, 0, sizeof hint);
+ hint.ai_flags = RAI_ROUTEONLY;
+ hint.ai_family = id->route.addr.src_addr.sa_family;
+ hint.ai_src_len = ucma_addrlen((struct sockaddr *) &id->route.addr.src_addr);
+ hint.ai_src_addr = &id->route.addr.src_addr;
+ hint.ai_dst_len = ucma_addrlen((struct sockaddr *) &id->route.addr.dst_addr);
+ hint.ai_dst_addr = &id->route.addr.dst_addr;
+
+ ret = rdma_getaddrinfo(NULL, NULL, &hint, &rai);
+ if (ret)
+ return ret;
+
+ if (rai->ai_route_len)
+ ret = rdma_set_option(id, RDMA_OPTION_IB, RDMA_OPTION_IB_PATH,
+ rai->ai_route, rai->ai_route_len);
+ else
+ ret = -1;
+
+ rdma_freeaddrinfo(rai);
+ return ret;
+}
+
+int rdma_resolve_route(struct rdma_cm_id *id, int timeout_ms)
+{
+ struct ucma_abi_resolve_route cmd;
+ struct cma_id_private *id_priv;
+ int ret;
+
+ id_priv = container_of(id, struct cma_id_private, id);
+ if (id->verbs->device->transport_type == IBV_TRANSPORT_IB) {
+ ret = ucma_set_ib_route(id);
+ if (!ret)
+ goto out;
+ }
+
+ CMA_INIT_CMD(&cmd, sizeof cmd, RESOLVE_ROUTE);
+ cmd.id = id_priv->handle;
+ cmd.timeout_ms = timeout_ms;
+
+ ret = write(id->channel->fd, &cmd, sizeof cmd);
+ if (ret != sizeof cmd)
+ return (ret >= 0) ? ERR(ENODATA) : -1;
+
+out:
+ return ucma_complete(id);
+}
+
+static int ucma_is_ud_qp(enum ibv_qp_type qp_type)
+{
+ return (qp_type == IBV_QPT_UD);
+}
+
+static int rdma_init_qp_attr(struct rdma_cm_id *id, struct ibv_qp_attr *qp_attr,
+ int *qp_attr_mask)
+{
+ struct ucma_abi_init_qp_attr cmd;
+ struct ibv_kern_qp_attr resp;
+ struct cma_id_private *id_priv;
+ int ret;
+
+ CMA_INIT_CMD_RESP(&cmd, sizeof cmd, INIT_QP_ATTR, &resp, sizeof resp);
+ id_priv = container_of(id, struct cma_id_private, id);
+ cmd.id = id_priv->handle;
+ cmd.qp_state = qp_attr->qp_state;
+
+ ret = write(id->channel->fd, &cmd, sizeof cmd);
+ if (ret != sizeof cmd)
+ return (ret >= 0) ? ERR(ENODATA) : -1;
+
+ VALGRIND_MAKE_MEM_DEFINED(&resp, sizeof resp);
+
+ ibv_copy_qp_attr_from_kern(qp_attr, &resp);
+ *qp_attr_mask = resp.qp_attr_mask;
+ return 0;
+}
+
+static int ucma_modify_qp_rtr(struct rdma_cm_id *id, uint8_t resp_res)
+{
+ struct cma_id_private *id_priv;
+ struct ibv_qp_attr qp_attr;
+ int qp_attr_mask, ret;
+ uint8_t link_layer;
+
+ if (!id->qp)
+ return ERR(EINVAL);
+
+ /* Need to update QP attributes from default values. */
+ qp_attr.qp_state = IBV_QPS_INIT;
+ ret = rdma_init_qp_attr(id, &qp_attr, &qp_attr_mask);
+ if (ret)
+ return ret;
+
+ ret = ibv_modify_qp(id->qp, &qp_attr, qp_attr_mask);
+ if (ret)
+ return ERR(ret);
+
+ qp_attr.qp_state = IBV_QPS_RTR;
+ ret = rdma_init_qp_attr(id, &qp_attr, &qp_attr_mask);
+ if (ret)
+ return ret;
+
+ /*
+ * Workaround for rdma_ucm kernel bug:
+ * mask off qp_attr_mask bits 21-24 which are used for RoCE
+ */
+ id_priv = container_of(id, struct cma_id_private, id);
+ link_layer = id_priv->cma_dev->port[id->port_num - 1].link_layer;
+
+ if (link_layer == IBV_LINK_LAYER_INFINIBAND)
+ qp_attr_mask &= UINT_MAX ^ 0xe00000;
+
+ if (resp_res != RDMA_MAX_RESP_RES)
+ qp_attr.max_dest_rd_atomic = resp_res;
+ return rdma_seterrno(ibv_modify_qp(id->qp, &qp_attr, qp_attr_mask));
+}
+
+static int ucma_modify_qp_rts(struct rdma_cm_id *id, uint8_t init_depth)
+{
+ struct ibv_qp_attr qp_attr;
+ int qp_attr_mask, ret;
+
+ qp_attr.qp_state = IBV_QPS_RTS;
+ ret = rdma_init_qp_attr(id, &qp_attr, &qp_attr_mask);
+ if (ret)
+ return ret;
+
+ if (init_depth != RDMA_MAX_INIT_DEPTH)
+ qp_attr.max_rd_atomic = init_depth;
+ return rdma_seterrno(ibv_modify_qp(id->qp, &qp_attr, qp_attr_mask));
+}
+
+static int ucma_modify_qp_sqd(struct rdma_cm_id *id)
+{
+ struct ibv_qp_attr qp_attr;
+
+ if (!id->qp)
+ return 0;
+
+ qp_attr.qp_state = IBV_QPS_SQD;
+ return rdma_seterrno(ibv_modify_qp(id->qp, &qp_attr, IBV_QP_STATE));
+}
+
+static int ucma_modify_qp_err(struct rdma_cm_id *id)
+{
+ struct ibv_qp_attr qp_attr;
+
+ if (!id->qp)
+ return 0;
+
+ qp_attr.qp_state = IBV_QPS_ERR;
+ return rdma_seterrno(ibv_modify_qp(id->qp, &qp_attr, IBV_QP_STATE));
+}
+
+static int ucma_find_pkey(struct cma_device *cma_dev, uint8_t port_num,
+ __be16 pkey, uint16_t *pkey_index)
+{
+ int ret, i;
+ __be16 chk_pkey;
+
+ for (i = 0, ret = 0; !ret; i++) {
+ ret = ibv_query_pkey(cma_dev->verbs, port_num, i, &chk_pkey);
+ if (!ret && pkey == chk_pkey) {
+ *pkey_index = (uint16_t) i;
+ return 0;
+ }
+ }
+ return ERR(EINVAL);
+}
+
+static int ucma_init_conn_qp3(struct cma_id_private *id_priv, struct ibv_qp *qp)
+{
+ struct ibv_qp_attr qp_attr;
+ int ret;
+
+ ret = ucma_find_pkey(id_priv->cma_dev, id_priv->id.port_num,
+ id_priv->id.route.addr.addr.ibaddr.pkey,
+ &qp_attr.pkey_index);
+ if (ret)
+ return ret;
+
+ qp_attr.port_num = id_priv->id.port_num;
+ qp_attr.qp_state = IBV_QPS_INIT;
+ qp_attr.qp_access_flags = 0;
+
+ ret = ibv_modify_qp(qp, &qp_attr, IBV_QP_STATE | IBV_QP_ACCESS_FLAGS |
+ IBV_QP_PKEY_INDEX | IBV_QP_PORT);
+ return rdma_seterrno(ret);
+}
+
+static int ucma_init_conn_qp(struct cma_id_private *id_priv, struct ibv_qp *qp)
+{
+ struct ibv_qp_attr qp_attr;
+ int qp_attr_mask, ret;
+
+ if (abi_ver == 3)
+ return ucma_init_conn_qp3(id_priv, qp);
+
+ qp_attr.qp_state = IBV_QPS_INIT;
+ ret = rdma_init_qp_attr(&id_priv->id, &qp_attr, &qp_attr_mask);
+ if (ret)
+ return ret;
+
+ return rdma_seterrno(ibv_modify_qp(qp, &qp_attr, qp_attr_mask));
+}
+
+static int ucma_init_ud_qp3(struct cma_id_private *id_priv, struct ibv_qp *qp)
+{
+ struct ibv_qp_attr qp_attr;
+ int ret;
+
+ ret = ucma_find_pkey(id_priv->cma_dev, id_priv->id.port_num,
+ id_priv->id.route.addr.addr.ibaddr.pkey,
+ &qp_attr.pkey_index);
+ if (ret)
+ return ret;
+
+ qp_attr.port_num = id_priv->id.port_num;
+ qp_attr.qp_state = IBV_QPS_INIT;
+ qp_attr.qkey = RDMA_UDP_QKEY;
+
+ ret = ibv_modify_qp(qp, &qp_attr, IBV_QP_STATE | IBV_QP_QKEY |
+ IBV_QP_PKEY_INDEX | IBV_QP_PORT);
+ if (ret)
+ return ERR(ret);
+
+ qp_attr.qp_state = IBV_QPS_RTR;
+ ret = ibv_modify_qp(qp, &qp_attr, IBV_QP_STATE);
+ if (ret)
+ return ERR(ret);
+
+ qp_attr.qp_state = IBV_QPS_RTS;
+ qp_attr.sq_psn = 0;
+ ret = ibv_modify_qp(qp, &qp_attr, IBV_QP_STATE | IBV_QP_SQ_PSN);
+ return rdma_seterrno(ret);
+}
+
+static int ucma_init_ud_qp(struct cma_id_private *id_priv, struct ibv_qp *qp)
+{
+ struct ibv_qp_attr qp_attr;
+ int qp_attr_mask, ret;
+
+ if (abi_ver == 3)
+ return ucma_init_ud_qp3(id_priv, qp);
+
+ qp_attr.qp_state = IBV_QPS_INIT;
+ ret = rdma_init_qp_attr(&id_priv->id, &qp_attr, &qp_attr_mask);
+ if (ret)
+ return ret;
+
+ ret = ibv_modify_qp(qp, &qp_attr, qp_attr_mask);
+ if (ret)
+ return ERR(ret);
+
+ qp_attr.qp_state = IBV_QPS_RTR;
+ ret = ibv_modify_qp(qp, &qp_attr, IBV_QP_STATE);
+ if (ret)
+ return ERR(ret);
+
+ qp_attr.qp_state = IBV_QPS_RTS;
+ qp_attr.sq_psn = 0;
+ ret = ibv_modify_qp(qp, &qp_attr, IBV_QP_STATE | IBV_QP_SQ_PSN);
+ return rdma_seterrno(ret);
+}
+
+static void ucma_destroy_cqs(struct rdma_cm_id *id)
+{
+ if (id->qp_type == IBV_QPT_XRC_RECV && id->srq)
+ return;
+
+ if (id->recv_cq) {
+ ibv_destroy_cq(id->recv_cq);
+ if (id->send_cq && (id->send_cq != id->recv_cq)) {
+ ibv_destroy_cq(id->send_cq);
+ id->send_cq = NULL;
+ }
+ id->recv_cq = NULL;
+ }
+
+ if (id->recv_cq_channel) {
+ ibv_destroy_comp_channel(id->recv_cq_channel);
+ if (id->send_cq_channel && (id->send_cq_channel != id->recv_cq_channel)) {
+ ibv_destroy_comp_channel(id->send_cq_channel);
+ id->send_cq_channel = NULL;
+ }
+ id->recv_cq_channel = NULL;
+ }
+}
+
+static int ucma_create_cqs(struct rdma_cm_id *id, uint32_t send_size, uint32_t recv_size)
+{
+ if (recv_size) {
+ id->recv_cq_channel = ibv_create_comp_channel(id->verbs);
+ if (!id->recv_cq_channel)
+ goto err;
+
+ id->recv_cq = ibv_create_cq(id->verbs, recv_size,
+ id, id->recv_cq_channel, 0);
+ if (!id->recv_cq)
+ goto err;
+ }
+
+ if (send_size) {
+ id->send_cq_channel = ibv_create_comp_channel(id->verbs);
+ if (!id->send_cq_channel)
+ goto err;
+
+ id->send_cq = ibv_create_cq(id->verbs, send_size,
+ id, id->send_cq_channel, 0);
+ if (!id->send_cq)
+ goto err;
+ }
+
+ return 0;
+err:
+ ucma_destroy_cqs(id);
+ return ERR(ENOMEM);
+}
+
+int rdma_create_srq_ex(struct rdma_cm_id *id, struct ibv_srq_init_attr_ex *attr)
+{
+ struct cma_id_private *id_priv;
+ struct ibv_srq *srq;
+ int ret;
+
+ id_priv = container_of(id, struct cma_id_private, id);
+ if (!(attr->comp_mask & IBV_SRQ_INIT_ATTR_TYPE))
+ return ERR(EINVAL);
+
+ if (!(attr->comp_mask & IBV_SRQ_INIT_ATTR_PD) || !attr->pd) {
+ attr->pd = id->pd;
+ attr->comp_mask |= IBV_SRQ_INIT_ATTR_PD;
+ }
+
+ if (attr->srq_type == IBV_SRQT_XRC) {
+ if (!(attr->comp_mask & IBV_SRQ_INIT_ATTR_XRCD) || !attr->xrcd) {
+ attr->xrcd = ucma_get_xrcd(id_priv->cma_dev);
+ if (!attr->xrcd)
+ return -1;
+ }
+ if (!(attr->comp_mask & IBV_SRQ_INIT_ATTR_CQ) || !attr->cq) {
+ ret = ucma_create_cqs(id, 0, attr->attr.max_wr);
+ if (ret)
+ return ret;
+ attr->cq = id->recv_cq;
+ }
+ attr->comp_mask |= IBV_SRQ_INIT_ATTR_XRCD | IBV_SRQ_INIT_ATTR_CQ;
+ }
+
+ srq = ibv_create_srq_ex(id->verbs, attr);
+ if (!srq) {
+ ret = -1;
+ goto err;
+ }
+
+ if (!id->pd)
+ id->pd = attr->pd;
+ id->srq = srq;
+ return 0;
+err:
+ ucma_destroy_cqs(id);
+ return ret;
+}
+
+int rdma_create_srq(struct rdma_cm_id *id, struct ibv_pd *pd,
+ struct ibv_srq_init_attr *attr)
+{
+ struct ibv_srq_init_attr_ex attr_ex;
+ int ret;
+
+ memcpy(&attr_ex, attr, sizeof(*attr));
+ attr_ex.comp_mask = IBV_SRQ_INIT_ATTR_TYPE | IBV_SRQ_INIT_ATTR_PD;
+ if (id->qp_type == IBV_QPT_XRC_RECV) {
+ attr_ex.srq_type = IBV_SRQT_XRC;
+ } else {
+ attr_ex.srq_type = IBV_SRQT_BASIC;
+ }
+ attr_ex.pd = pd;
+ ret = rdma_create_srq_ex(id, &attr_ex);
+ memcpy(attr, &attr_ex, sizeof(*attr));
+ return ret;
+}
+
+void rdma_destroy_srq(struct rdma_cm_id *id)
+{
+ ibv_destroy_srq(id->srq);
+ id->srq = NULL;
+ ucma_destroy_cqs(id);
+}
+
+int rdma_create_qp_ex(struct rdma_cm_id *id,
+ struct ibv_qp_init_attr_ex *attr)
+{
+ struct cma_id_private *id_priv;
+ struct ibv_qp *qp;
+ int ret;
+
+ if (id->qp)
+ return ERR(EINVAL);
+
+ id_priv = container_of(id, struct cma_id_private, id);
+ if (!(attr->comp_mask & IBV_QP_INIT_ATTR_PD) || !attr->pd) {
+ attr->comp_mask |= IBV_QP_INIT_ATTR_PD;
+ attr->pd = id->pd;
+ } else if (id->verbs != attr->pd->context)
+ return ERR(EINVAL);
+
+ if ((id->recv_cq && attr->recv_cq && id->recv_cq != attr->recv_cq) ||
+ (id->send_cq && attr->send_cq && id->send_cq != attr->send_cq))
+ return ERR(EINVAL);
+
+ if (id->qp_type == IBV_QPT_XRC_RECV) {
+ if (!(attr->comp_mask & IBV_QP_INIT_ATTR_XRCD) || !attr->xrcd) {
+ attr->xrcd = ucma_get_xrcd(id_priv->cma_dev);
+ if (!attr->xrcd)
+ return -1;
+ attr->comp_mask |= IBV_QP_INIT_ATTR_XRCD;
+ }
+ }
+
+ ret = ucma_create_cqs(id, attr->send_cq || id->send_cq ? 0 : attr->cap.max_send_wr,
+ attr->recv_cq || id->recv_cq ? 0 : attr->cap.max_recv_wr);
+ if (ret)
+ return ret;
+
+ if (!attr->send_cq)
+ attr->send_cq = id->send_cq;
+ if (!attr->recv_cq)
+ attr->recv_cq = id->recv_cq;
+ if (id->srq && !attr->srq)
+ attr->srq = id->srq;
+ qp = ibv_create_qp_ex(id->verbs, attr);
+ if (!qp) {
+ ret = ERR(ENOMEM);
+ goto err1;
+ }
+
+ if (ucma_is_ud_qp(id->qp_type))
+ ret = ucma_init_ud_qp(id_priv, qp);
+ else
+ ret = ucma_init_conn_qp(id_priv, qp);
+ if (ret)
+ goto err2;
+
+ id->pd = qp->pd;
+ id->qp = qp;
+ return 0;
+err2:
+ ibv_destroy_qp(qp);
+err1:
+ ucma_destroy_cqs(id);
+ return ret;
+}
+
+int rdma_create_qp(struct rdma_cm_id *id, struct ibv_pd *pd,
+ struct ibv_qp_init_attr *qp_init_attr)
+{
+ struct ibv_qp_init_attr_ex attr_ex;
+ int ret;
+
+ memcpy(&attr_ex, qp_init_attr, sizeof(*qp_init_attr));
+ attr_ex.comp_mask = IBV_QP_INIT_ATTR_PD;
+ attr_ex.pd = pd ? pd : id->pd;
+ ret = rdma_create_qp_ex(id, &attr_ex);
+ memcpy(qp_init_attr, &attr_ex, sizeof(*qp_init_attr));
+ return ret;
+}
+
+void rdma_destroy_qp(struct rdma_cm_id *id)
+{
+ ibv_destroy_qp(id->qp);
+ id->qp = NULL;
+ ucma_destroy_cqs(id);
+}
+
+static int ucma_valid_param(struct cma_id_private *id_priv,
+ struct rdma_conn_param *param)
+{
+ if (id_priv->id.ps != RDMA_PS_TCP)
+ return 0;
+
+ if (!id_priv->id.qp && !param)
+ goto err;
+
+ if (!param)
+ return 0;
+
+ if ((param->responder_resources != RDMA_MAX_RESP_RES) &&
+ (param->responder_resources > id_priv->cma_dev->max_responder_resources))
+ goto err;
+
+ if ((param->initiator_depth != RDMA_MAX_INIT_DEPTH) &&
+ (param->initiator_depth > id_priv->cma_dev->max_initiator_depth))
+ goto err;
+
+ return 0;
+err:
+ return ERR(EINVAL);
+}
+
+static void ucma_copy_conn_param_to_kern(struct cma_id_private *id_priv,
+ struct ucma_abi_conn_param *dst,
+ struct rdma_conn_param *src,
+ uint32_t qp_num, uint8_t srq)
+{
+ dst->qp_num = qp_num;
+ dst->srq = srq;
+ dst->responder_resources = id_priv->responder_resources;
+ dst->initiator_depth = id_priv->initiator_depth;
+ dst->valid = 1;
+
+ if (id_priv->connect_len) {
+ memcpy(dst->private_data, id_priv->connect, id_priv->connect_len);
+ dst->private_data_len = id_priv->connect_len;
+ }
+
+ if (src) {
+ dst->flow_control = src->flow_control;
+ dst->retry_count = src->retry_count;
+ dst->rnr_retry_count = src->rnr_retry_count;
+
+ if (src->private_data && src->private_data_len) {
+ memcpy(dst->private_data + dst->private_data_len,
+ src->private_data, src->private_data_len);
+ dst->private_data_len += src->private_data_len;
+ }
+ } else {
+ dst->retry_count = 7;
+ dst->rnr_retry_count = 7;
+ }
+}
+
+int rdma_connect(struct rdma_cm_id *id, struct rdma_conn_param *conn_param)
+{
+ struct ucma_abi_connect cmd;
+ struct cma_id_private *id_priv;
+ int ret;
+
+ id_priv = container_of(id, struct cma_id_private, id);
+ ret = ucma_valid_param(id_priv, conn_param);
+ if (ret)
+ return ret;
+
+ if (conn_param && conn_param->initiator_depth != RDMA_MAX_INIT_DEPTH)
+ id_priv->initiator_depth = conn_param->initiator_depth;
+ else
+ id_priv->initiator_depth = id_priv->cma_dev->max_initiator_depth;
+ if (conn_param && conn_param->responder_resources != RDMA_MAX_RESP_RES)
+ id_priv->responder_resources = conn_param->responder_resources;
+ else
+ id_priv->responder_resources = id_priv->cma_dev->max_responder_resources;
+
+ CMA_INIT_CMD(&cmd, sizeof cmd, CONNECT);
+ cmd.id = id_priv->handle;
+ if (id->qp) {
+ ucma_copy_conn_param_to_kern(id_priv, &cmd.conn_param,
+ conn_param, id->qp->qp_num,
+ (id->qp->srq != NULL));
+ } else if (conn_param) {
+ ucma_copy_conn_param_to_kern(id_priv, &cmd.conn_param,
+ conn_param, conn_param->qp_num,
+ conn_param->srq);
+ } else {
+ ucma_copy_conn_param_to_kern(id_priv, &cmd.conn_param,
+ conn_param, 0, 0);
+ }
+
+ ret = write(id->channel->fd, &cmd, sizeof cmd);
+ if (ret != sizeof cmd)
+ return (ret >= 0) ? ERR(ENODATA) : -1;
+
+ if (id_priv->connect_len) {
+ free(id_priv->connect);
+ id_priv->connect_len = 0;
+ }
+
+ return ucma_complete(id);
+}
+
+int rdma_listen(struct rdma_cm_id *id, int backlog)
+{
+ struct ucma_abi_listen cmd;
+ struct cma_id_private *id_priv;
+ int ret;
+
+ CMA_INIT_CMD(&cmd, sizeof cmd, LISTEN);
+ id_priv = container_of(id, struct cma_id_private, id);
+ cmd.id = id_priv->handle;
+ cmd.backlog = backlog;
+
+ ret = write(id->channel->fd, &cmd, sizeof cmd);
+ if (ret != sizeof cmd)
+ return (ret >= 0) ? ERR(ENODATA) : -1;
+
+ if (af_ib_support)
+ return ucma_query_addr(id);
+ else
+ return ucma_query_route(id);
+}
+
+int rdma_get_request(struct rdma_cm_id *listen, struct rdma_cm_id **id)
+{
+ struct cma_id_private *id_priv;
+ struct rdma_cm_event *event;
+ int ret;
+
+ id_priv = container_of(listen, struct cma_id_private, id);
+ if (!id_priv->sync)
+ return ERR(EINVAL);
+
+ if (listen->event) {
+ rdma_ack_cm_event(listen->event);
+ listen->event = NULL;
+ }
+
+ ret = rdma_get_cm_event(listen->channel, &event);
+ if (ret)
+ return ret;
+
+ if (event->status) {
+ ret = ERR(event->status);
+ goto err;
+ }
+
+ if (event->event != RDMA_CM_EVENT_CONNECT_REQUEST) {
+ ret = ERR(EINVAL);
+ goto err;
+ }
+
+ if (id_priv->qp_init_attr) {
+ struct ibv_qp_init_attr attr;
+
+ attr = *id_priv->qp_init_attr;
+ ret = rdma_create_qp(event->id, listen->pd, &attr);
+ if (ret)
+ goto err;
+ }
+
+ *id = event->id;
+ (*id)->event = event;
+ return 0;
+
+err:
+ listen->event = event;
+ return ret;
+}
+
+int rdma_accept(struct rdma_cm_id *id, struct rdma_conn_param *conn_param)
+{
+ struct ucma_abi_accept cmd;
+ struct cma_id_private *id_priv;
+ int ret;
+
+ id_priv = container_of(id, struct cma_id_private, id);
+ ret = ucma_valid_param(id_priv, conn_param);
+ if (ret)
+ return ret;
+
+ if (!conn_param || conn_param->initiator_depth == RDMA_MAX_INIT_DEPTH) {
+ id_priv->initiator_depth = min(id_priv->initiator_depth,
+ id_priv->cma_dev->max_initiator_depth);
+ } else {
+ id_priv->initiator_depth = conn_param->initiator_depth;
+ }
+ if (!conn_param || conn_param->responder_resources == RDMA_MAX_RESP_RES) {
+ id_priv->responder_resources = min(id_priv->responder_resources,
+ id_priv->cma_dev->max_responder_resources);
+ } else {
+ id_priv->responder_resources = conn_param->responder_resources;
+ }
+
+ if (!ucma_is_ud_qp(id->qp_type)) {
+ ret = ucma_modify_qp_rtr(id, id_priv->responder_resources);
+ if (ret)
+ return ret;
+
+ ret = ucma_modify_qp_rts(id, id_priv->initiator_depth);
+ if (ret)
+ return ret;
+ }
+
+ CMA_INIT_CMD(&cmd, sizeof cmd, ACCEPT);
+ cmd.id = id_priv->handle;
+ cmd.uid = (uintptr_t) id_priv;
+ if (id->qp)
+ ucma_copy_conn_param_to_kern(id_priv, &cmd.conn_param,
+ conn_param, id->qp->qp_num,
+ (id->qp->srq != NULL));
+ else
+ ucma_copy_conn_param_to_kern(id_priv, &cmd.conn_param,
+ conn_param, conn_param->qp_num,
+ conn_param->srq);
+
+ ret = write(id->channel->fd, &cmd, sizeof cmd);
+ if (ret != sizeof cmd) {
+ ucma_modify_qp_err(id);
+ return (ret >= 0) ? ERR(ENODATA) : -1;
+ }
+
+ if (ucma_is_ud_qp(id->qp_type))
+ return 0;
+
+ return ucma_complete(id);
+}
+
+int rdma_reject(struct rdma_cm_id *id, const void *private_data,
+ uint8_t private_data_len)
+{
+ struct ucma_abi_reject cmd;
+ struct cma_id_private *id_priv;
+ int ret;
+
+ CMA_INIT_CMD(&cmd, sizeof cmd, REJECT);
+
+ id_priv = container_of(id, struct cma_id_private, id);
+ cmd.id = id_priv->handle;
+ if (private_data && private_data_len) {
+ memcpy(cmd.private_data, private_data, private_data_len);
+ cmd.private_data_len = private_data_len;
+ }
+
+ ret = write(id->channel->fd, &cmd, sizeof cmd);
+ if (ret != sizeof cmd)
+ return (ret >= 0) ? ERR(ENODATA) : -1;
+
+ return 0;
+}
+
+int rdma_notify(struct rdma_cm_id *id, enum ibv_event_type event)
+{
+ struct ucma_abi_notify cmd;
+ struct cma_id_private *id_priv;
+ int ret;
+
+ CMA_INIT_CMD(&cmd, sizeof cmd, NOTIFY);
+
+ id_priv = container_of(id, struct cma_id_private, id);
+ cmd.id = id_priv->handle;
+ cmd.event = event;
+ ret = write(id->channel->fd, &cmd, sizeof cmd);
+ if (ret != sizeof cmd)
+ return (ret >= 0) ? ERR(ENODATA) : -1;
+
+ return 0;
+}
+
+int ucma_shutdown(struct rdma_cm_id *id)
+{
+ switch (id->verbs->device->transport_type) {
+ case IBV_TRANSPORT_IB:
+ return ucma_modify_qp_err(id);
+ case IBV_TRANSPORT_IWARP:
+ return ucma_modify_qp_sqd(id);
+ default:
+ return ERR(EINVAL);
+ }
+}
+
+int rdma_disconnect(struct rdma_cm_id *id)
+{
+ struct ucma_abi_disconnect cmd;
+ struct cma_id_private *id_priv;
+ int ret;
+
+ ret = ucma_shutdown(id);
+ if (ret)
+ return ret;
+
+ CMA_INIT_CMD(&cmd, sizeof cmd, DISCONNECT);
+ id_priv = container_of(id, struct cma_id_private, id);
+ cmd.id = id_priv->handle;
+
+ ret = write(id->channel->fd, &cmd, sizeof cmd);
+ if (ret != sizeof cmd)
+ return (ret >= 0) ? ERR(ENODATA) : -1;
+
+ return ucma_complete(id);
+}
+
+static int rdma_join_multicast2(struct rdma_cm_id *id, struct sockaddr *addr,
+ socklen_t addrlen, void *context)
+{
+ struct ucma_abi_create_id_resp resp;
+ struct cma_id_private *id_priv;
+ struct cma_multicast *mc, **pos;
+ int ret;
+
+ id_priv = container_of(id, struct cma_id_private, id);
+ mc = calloc(1, sizeof(*mc));
+ if (!mc)
+ return ERR(ENOMEM);
+
+ mc->context = context;
+ mc->id_priv = id_priv;
+ memcpy(&mc->addr, addr, addrlen);
+ if (pthread_cond_init(&mc->cond, NULL)) {
+ ret = -1;
+ goto err1;
+ }
+
+ pthread_mutex_lock(&id_priv->mut);
+ mc->next = id_priv->mc_list;
+ id_priv->mc_list = mc;
+ pthread_mutex_unlock(&id_priv->mut);
+
+ if (af_ib_support) {
+ struct ucma_abi_join_mcast cmd;
+
+ CMA_INIT_CMD_RESP(&cmd, sizeof cmd, JOIN_MCAST, &resp, sizeof resp);
+ cmd.id = id_priv->handle;
+ memcpy(&cmd.addr, addr, addrlen);
+ cmd.addr_size = addrlen;
+ cmd.uid = (uintptr_t) mc;
+ cmd.reserved = 0;
+
+ ret = write(id->channel->fd, &cmd, sizeof cmd);
+ if (ret != sizeof cmd) {
+ ret = (ret >= 0) ? ERR(ENODATA) : -1;
+ goto err2;
+ }
+ } else {
+ struct ucma_abi_join_ip_mcast cmd;
+
+ CMA_INIT_CMD_RESP(&cmd, sizeof cmd, JOIN_IP_MCAST, &resp, sizeof resp);
+ cmd.id = id_priv->handle;
+ memcpy(&cmd.addr, addr, addrlen);
+ cmd.uid = (uintptr_t) mc;
+
+ ret = write(id->channel->fd, &cmd, sizeof cmd);
+ if (ret != sizeof cmd) {
+ ret = (ret >= 0) ? ERR(ENODATA) : -1;
+ goto err2;
+ }
+ }
+
+ VALGRIND_MAKE_MEM_DEFINED(&resp, sizeof resp);
+
+ mc->handle = resp.id;
+ return ucma_complete(id);
+
+err2:
+ pthread_mutex_lock(&id_priv->mut);
+ for (pos = &id_priv->mc_list; *pos != mc; pos = &(*pos)->next)
+ ;
+ *pos = mc->next;
+ pthread_mutex_unlock(&id_priv->mut);
+err1:
+ free(mc);
+ return ret;
+}
+
+int rdma_join_multicast(struct rdma_cm_id *id, struct sockaddr *addr,
+ void *context)
+{
+ int addrlen;
+
+ addrlen = ucma_addrlen(addr);
+ if (!addrlen)
+ return ERR(EINVAL);
+
+ return rdma_join_multicast2(id, addr, addrlen, context);
+}
+
+int rdma_leave_multicast(struct rdma_cm_id *id, struct sockaddr *addr)
+{
+ struct ucma_abi_destroy_id cmd;
+ struct ucma_abi_destroy_id_resp resp;
+ struct cma_id_private *id_priv;
+ struct cma_multicast *mc, **pos;
+ int ret, addrlen;
+
+ addrlen = ucma_addrlen(addr);
+ if (!addrlen)
+ return ERR(EINVAL);
+
+ id_priv = container_of(id, struct cma_id_private, id);
+ pthread_mutex_lock(&id_priv->mut);
+ for (pos = &id_priv->mc_list; *pos; pos = &(*pos)->next)
+ if (!memcmp(&(*pos)->addr, addr, addrlen))
+ break;
+
+ mc = *pos;
+ if (*pos)
+ *pos = mc->next;
+ pthread_mutex_unlock(&id_priv->mut);
+ if (!mc)
+ return ERR(EADDRNOTAVAIL);
+
+ if (id->qp)
+ ibv_detach_mcast(id->qp, &mc->mgid, mc->mlid);
+
+ CMA_INIT_CMD_RESP(&cmd, sizeof cmd, LEAVE_MCAST, &resp, sizeof resp);
+ cmd.id = mc->handle;
+
+ ret = write(id->channel->fd, &cmd, sizeof cmd);
+ if (ret != sizeof cmd) {
+ ret = (ret >= 0) ? ERR(ENODATA) : -1;
+ goto free;
+ }
+
+ VALGRIND_MAKE_MEM_DEFINED(&resp, sizeof resp);
+
+ pthread_mutex_lock(&id_priv->mut);
+ while (mc->events_completed < resp.events_reported)
+ pthread_cond_wait(&mc->cond, &id_priv->mut);
+ pthread_mutex_unlock(&id_priv->mut);
+
+ ret = 0;
+free:
+ free(mc);
+ return ret;
+}
+
+static void ucma_complete_event(struct cma_id_private *id_priv)
+{
+ pthread_mutex_lock(&id_priv->mut);
+ id_priv->events_completed++;
+ pthread_cond_signal(&id_priv->cond);
+ pthread_mutex_unlock(&id_priv->mut);
+}
+
+static void ucma_complete_mc_event(struct cma_multicast *mc)
+{
+ pthread_mutex_lock(&mc->id_priv->mut);
+ mc->events_completed++;
+ pthread_cond_signal(&mc->cond);
+ mc->id_priv->events_completed++;
+ pthread_cond_signal(&mc->id_priv->cond);
+ pthread_mutex_unlock(&mc->id_priv->mut);
+}
+
+int rdma_ack_cm_event(struct rdma_cm_event *event)
+{
+ struct cma_event *evt;
+
+ if (!event)
+ return ERR(EINVAL);
+
+ evt = container_of(event, struct cma_event, event);
+
+ if (evt->mc)
+ ucma_complete_mc_event(evt->mc);
+ else
+ ucma_complete_event(evt->id_priv);
+ free(evt);
+ return 0;
+}
+
+static void ucma_process_addr_resolved(struct cma_event *evt)
+{
+ if (af_ib_support) {
+ evt->event.status = ucma_query_addr(&evt->id_priv->id);
+ if (!evt->event.status &&
+ evt->id_priv->id.verbs->device->transport_type == IBV_TRANSPORT_IB)
+ evt->event.status = ucma_query_gid(&evt->id_priv->id);
+ } else {
+ evt->event.status = ucma_query_route(&evt->id_priv->id);
+ }
+
+ if (evt->event.status)
+ evt->event.event = RDMA_CM_EVENT_ADDR_ERROR;
+}
+
+static void ucma_process_route_resolved(struct cma_event *evt)
+{
+ if (evt->id_priv->id.verbs->device->transport_type != IBV_TRANSPORT_IB)
+ return;
+
+ if (af_ib_support)
+ evt->event.status = ucma_query_path(&evt->id_priv->id);
+ else
+ evt->event.status = ucma_query_route(&evt->id_priv->id);
+
+ if (evt->event.status)
+ evt->event.event = RDMA_CM_EVENT_ROUTE_ERROR;
+}
+
+static int ucma_query_req_info(struct rdma_cm_id *id)
+{
+ int ret;
+
+ if (!af_ib_support)
+ return ucma_query_route(id);
+
+ ret = ucma_query_addr(id);
+ if (ret)
+ return ret;
+
+ ret = ucma_query_gid(id);
+ if (ret)
+ return ret;
+
+ ret = ucma_query_path(id);
+ if (ret)
+ return ret;
+
+ return 0;
+}
+
+static int ucma_process_conn_req(struct cma_event *evt,
+ uint32_t handle)
+{
+ struct cma_id_private *id_priv;
+ int ret;
+
+ id_priv = ucma_alloc_id(evt->id_priv->id.channel,
+ evt->id_priv->id.context, evt->id_priv->id.ps,
+ evt->id_priv->id.qp_type);
+ if (!id_priv) {
+ ucma_destroy_kern_id(evt->id_priv->id.channel->fd, handle);
+ ret = ERR(ENOMEM);
+ goto err1;
+ }
+
+ evt->event.listen_id = &evt->id_priv->id;
+ evt->event.id = &id_priv->id;
+ id_priv->handle = handle;
+ ucma_insert_id(id_priv);
+ id_priv->initiator_depth = evt->event.param.conn.initiator_depth;
+ id_priv->responder_resources = evt->event.param.conn.responder_resources;
+
+ if (evt->id_priv->sync) {
+ ret = rdma_migrate_id(&id_priv->id, NULL);
+ if (ret)
+ goto err2;
+ }
+
+ ret = ucma_query_req_info(&id_priv->id);
+ if (ret)
+ goto err2;
+
+ return 0;
+
+err2:
+ rdma_destroy_id(&id_priv->id);
+err1:
+ ucma_complete_event(evt->id_priv);
+ return ret;
+}
+
+static int ucma_process_conn_resp(struct cma_id_private *id_priv)
+{
+ struct ucma_abi_accept cmd;
+ int ret;
+
+ ret = ucma_modify_qp_rtr(&id_priv->id, RDMA_MAX_RESP_RES);
+ if (ret)
+ goto err;
+
+ ret = ucma_modify_qp_rts(&id_priv->id, RDMA_MAX_INIT_DEPTH);
+ if (ret)
+ goto err;
+
+ CMA_INIT_CMD(&cmd, sizeof cmd, ACCEPT);
+ cmd.id = id_priv->handle;
+
+ ret = write(id_priv->id.channel->fd, &cmd, sizeof cmd);
+ if (ret != sizeof cmd) {
+ ret = (ret >= 0) ? ERR(ENODATA) : -1;
+ goto err;
+ }
+
+ return 0;
+err:
+ ucma_modify_qp_err(&id_priv->id);
+ return ret;
+}
+
+static int ucma_process_join(struct cma_event *evt)
+{
+ evt->mc->mgid = evt->event.param.ud.ah_attr.grh.dgid;
+ evt->mc->mlid = evt->event.param.ud.ah_attr.dlid;
+
+ if (!evt->id_priv->id.qp)
+ return 0;
+
+ return rdma_seterrno(ibv_attach_mcast(evt->id_priv->id.qp,
+ &evt->mc->mgid, evt->mc->mlid));
+}
+
+static void ucma_copy_conn_event(struct cma_event *event,
+ struct ucma_abi_conn_param *src)
+{
+ struct rdma_conn_param *dst = &event->event.param.conn;
+
+ dst->private_data_len = src->private_data_len;
+ if (src->private_data_len) {
+ dst->private_data = &event->private_data;
+ memcpy(&event->private_data, src->private_data,
+ src->private_data_len);
+ }
+
+ dst->responder_resources = src->responder_resources;
+ dst->initiator_depth = src->initiator_depth;
+ dst->flow_control = src->flow_control;
+ dst->retry_count = src->retry_count;
+ dst->rnr_retry_count = src->rnr_retry_count;
+ dst->srq = src->srq;
+ dst->qp_num = src->qp_num;
+}
+
+static void ucma_copy_ud_event(struct cma_event *event,
+ struct ucma_abi_ud_param *src)
+{
+ struct rdma_ud_param *dst = &event->event.param.ud;
+
+ dst->private_data_len = src->private_data_len;
+ if (src->private_data_len) {
+ dst->private_data = &event->private_data;
+ memcpy(&event->private_data, src->private_data,
+ src->private_data_len);
+ }
+
+ ibv_copy_ah_attr_from_kern(&dst->ah_attr, &src->ah_attr);
+ dst->qp_num = src->qp_num;
+ dst->qkey = src->qkey;
+}
+
+int rdma_get_cm_event(struct rdma_event_channel *channel,
+ struct rdma_cm_event **event)
+{
+ struct ucma_abi_event_resp resp;
+ struct ucma_abi_get_event cmd;
+ struct cma_event *evt;
+ int ret;
+
+ ret = ucma_init();
+ if (ret)
+ return ret;
+
+ if (!event)
+ return ERR(EINVAL);
+
+ evt = malloc(sizeof(*evt));
+ if (!evt)
+ return ERR(ENOMEM);
+
+retry:
+ memset(evt, 0, sizeof(*evt));
+ CMA_INIT_CMD_RESP(&cmd, sizeof cmd, GET_EVENT, &resp, sizeof resp);
+ ret = write(channel->fd, &cmd, sizeof cmd);
+ if (ret != sizeof cmd) {
+ free(evt);
+ return (ret >= 0) ? ERR(ENODATA) : -1;
+ }
+
+ VALGRIND_MAKE_MEM_DEFINED(&resp, sizeof resp);
+
+ evt->event.event = resp.event;
+ /*
+ * We should have a non-zero uid, except for connection requests.
+ * But a bug in older kernels can report a uid 0. Work-around this
+ * issue by looking up the cma_id based on the kernel's id when the
+ * uid is 0 and we're processing a connection established event.
+ * In all other cases, if the uid is 0, we discard the event, like
+ * the kernel should have done.
+ */
+ if (resp.uid) {
+ evt->id_priv = (void *) (uintptr_t) resp.uid;
+ } else {
+ evt->id_priv = ucma_lookup_id(resp.id);
+ if (!evt->id_priv) {
+ syslog(LOG_WARNING, PFX "Warning: discarding unmatched "
+ "event - rdma_destroy_id may hang.\n");
+ goto retry;
+ }
+ if (resp.event != RDMA_CM_EVENT_ESTABLISHED) {
+ ucma_complete_event(evt->id_priv);
+ goto retry;
+ }
+ }
+ evt->event.id = &evt->id_priv->id;
+ evt->event.status = resp.status;
+
+ switch (resp.event) {
+ case RDMA_CM_EVENT_ADDR_RESOLVED:
+ ucma_process_addr_resolved(evt);
+ break;
+ case RDMA_CM_EVENT_ROUTE_RESOLVED:
+ ucma_process_route_resolved(evt);
+ break;
+ case RDMA_CM_EVENT_CONNECT_REQUEST:
+ evt->id_priv = (void *) (uintptr_t) resp.uid;
+ if (ucma_is_ud_qp(evt->id_priv->id.qp_type))
+ ucma_copy_ud_event(evt, &resp.param.ud);
+ else
+ ucma_copy_conn_event(evt, &resp.param.conn);
+
+ ret = ucma_process_conn_req(evt, resp.id);
+ if (ret)
+ goto retry;
+ break;
+ case RDMA_CM_EVENT_CONNECT_RESPONSE:
+ ucma_copy_conn_event(evt, &resp.param.conn);
+ evt->event.status = ucma_process_conn_resp(evt->id_priv);
+ if (!evt->event.status)
+ evt->event.event = RDMA_CM_EVENT_ESTABLISHED;
+ else {
+ evt->event.event = RDMA_CM_EVENT_CONNECT_ERROR;
+ evt->id_priv->connect_error = 1;
+ }
+ break;
+ case RDMA_CM_EVENT_ESTABLISHED:
+ if (ucma_is_ud_qp(evt->id_priv->id.qp_type)) {
+ ucma_copy_ud_event(evt, &resp.param.ud);
+ break;
+ }
+
+ ucma_copy_conn_event(evt, &resp.param.conn);
+ break;
+ case RDMA_CM_EVENT_REJECTED:
+ if (evt->id_priv->connect_error) {
+ ucma_complete_event(evt->id_priv);
+ goto retry;
+ }
+ ucma_copy_conn_event(evt, &resp.param.conn);
+ ucma_modify_qp_err(evt->event.id);
+ break;
+ case RDMA_CM_EVENT_DISCONNECTED:
+ if (evt->id_priv->connect_error) {
+ ucma_complete_event(evt->id_priv);
+ goto retry;
+ }
+ ucma_copy_conn_event(evt, &resp.param.conn);
+ break;
+ case RDMA_CM_EVENT_MULTICAST_JOIN:
+ evt->mc = (void *) (uintptr_t) resp.uid;
+ evt->id_priv = evt->mc->id_priv;
+ evt->event.id = &evt->id_priv->id;
+ ucma_copy_ud_event(evt, &resp.param.ud);
+ evt->event.param.ud.private_data = evt->mc->context;
+ evt->event.status = ucma_process_join(evt);
+ if (evt->event.status)
+ evt->event.event = RDMA_CM_EVENT_MULTICAST_ERROR;
+ break;
+ case RDMA_CM_EVENT_MULTICAST_ERROR:
+ evt->mc = (void *) (uintptr_t) resp.uid;
+ evt->id_priv = evt->mc->id_priv;
+ evt->event.id = &evt->id_priv->id;
+ evt->event.param.ud.private_data = evt->mc->context;
+ break;
+ default:
+ evt->id_priv = (void *) (uintptr_t) resp.uid;
+ evt->event.id = &evt->id_priv->id;
+ evt->event.status = resp.status;
+ if (ucma_is_ud_qp(evt->id_priv->id.qp_type))
+ ucma_copy_ud_event(evt, &resp.param.ud);
+ else
+ ucma_copy_conn_event(evt, &resp.param.conn);
+ break;
+ }
+
+ *event = &evt->event;
+ return 0;
+}
+
+const char *rdma_event_str(enum rdma_cm_event_type event)
+{
+ switch (event) {
+ case RDMA_CM_EVENT_ADDR_RESOLVED:
+ return "RDMA_CM_EVENT_ADDR_RESOLVED";
+ case RDMA_CM_EVENT_ADDR_ERROR:
+ return "RDMA_CM_EVENT_ADDR_ERROR";
+ case RDMA_CM_EVENT_ROUTE_RESOLVED:
+ return "RDMA_CM_EVENT_ROUTE_RESOLVED";
+ case RDMA_CM_EVENT_ROUTE_ERROR:
+ return "RDMA_CM_EVENT_ROUTE_ERROR";
+ case RDMA_CM_EVENT_CONNECT_REQUEST:
+ return "RDMA_CM_EVENT_CONNECT_REQUEST";
+ case RDMA_CM_EVENT_CONNECT_RESPONSE:
+ return "RDMA_CM_EVENT_CONNECT_RESPONSE";
+ case RDMA_CM_EVENT_CONNECT_ERROR:
+ return "RDMA_CM_EVENT_CONNECT_ERROR";
+ case RDMA_CM_EVENT_UNREACHABLE:
+ return "RDMA_CM_EVENT_UNREACHABLE";
+ case RDMA_CM_EVENT_REJECTED:
+ return "RDMA_CM_EVENT_REJECTED";
+ case RDMA_CM_EVENT_ESTABLISHED:
+ return "RDMA_CM_EVENT_ESTABLISHED";
+ case RDMA_CM_EVENT_DISCONNECTED:
+ return "RDMA_CM_EVENT_DISCONNECTED";
+ case RDMA_CM_EVENT_DEVICE_REMOVAL:
+ return "RDMA_CM_EVENT_DEVICE_REMOVAL";
+ case RDMA_CM_EVENT_MULTICAST_JOIN:
+ return "RDMA_CM_EVENT_MULTICAST_JOIN";
+ case RDMA_CM_EVENT_MULTICAST_ERROR:
+ return "RDMA_CM_EVENT_MULTICAST_ERROR";
+ case RDMA_CM_EVENT_ADDR_CHANGE:
+ return "RDMA_CM_EVENT_ADDR_CHANGE";
+ case RDMA_CM_EVENT_TIMEWAIT_EXIT:
+ return "RDMA_CM_EVENT_TIMEWAIT_EXIT";
+ default:
+ return "UNKNOWN EVENT";
+ }
+}
+
+int rdma_set_option(struct rdma_cm_id *id, int level, int optname,
+ void *optval, size_t optlen)
+{
+ struct ucma_abi_set_option cmd;
+ struct cma_id_private *id_priv;
+ int ret;
+
+ CMA_INIT_CMD(&cmd, sizeof cmd, SET_OPTION);
+ id_priv = container_of(id, struct cma_id_private, id);
+ cmd.id = id_priv->handle;
+ cmd.optval = (uintptr_t) optval;
+ cmd.level = level;
+ cmd.optname = optname;
+ cmd.optlen = optlen;
+
+ ret = write(id->channel->fd, &cmd, sizeof cmd);
+ if (ret != sizeof cmd)
+ return (ret >= 0) ? ERR(ENODATA) : -1;
+
+ return 0;
+}
+
+int rdma_migrate_id(struct rdma_cm_id *id, struct rdma_event_channel *channel)
+{
+ struct ucma_abi_migrate_resp resp;
+ struct ucma_abi_migrate_id cmd;
+ struct cma_id_private *id_priv;
+ int ret, sync;
+
+ id_priv = container_of(id, struct cma_id_private, id);
+ if (id_priv->sync && !channel)
+ return ERR(EINVAL);
+
+ if ((sync = (channel == NULL))) {
+ channel = rdma_create_event_channel();
+ if (!channel)
+ return -1;
+ }
+
+ CMA_INIT_CMD_RESP(&cmd, sizeof cmd, MIGRATE_ID, &resp, sizeof resp);
+ cmd.id = id_priv->handle;
+ cmd.fd = id->channel->fd;
+
+ ret = write(channel->fd, &cmd, sizeof cmd);
+ if (ret != sizeof cmd) {
+ if (sync)
+ rdma_destroy_event_channel(channel);
+ return (ret >= 0) ? ERR(ENODATA) : -1;
+ }
+
+ VALGRIND_MAKE_MEM_DEFINED(&resp, sizeof resp);
+
+ if (id_priv->sync) {
+ if (id->event) {
+ rdma_ack_cm_event(id->event);
+ id->event = NULL;
+ }
+ rdma_destroy_event_channel(id->channel);
+ }
+
+ /*
+ * Eventually if we want to support migrating channels while events are
+ * being processed on the current channel, we need to block here while
+ * there are any outstanding events on the current channel for this id
+ * to prevent the user from processing events for this id on the old
+ * channel after this call returns.
+ */
+ pthread_mutex_lock(&id_priv->mut);
+ id_priv->sync = sync;
+ id->channel = channel;
+ while (id_priv->events_completed < resp.events_reported)
+ pthread_cond_wait(&id_priv->cond, &id_priv->mut);
+ pthread_mutex_unlock(&id_priv->mut);
+
+ return 0;
+}
+
+static int ucma_passive_ep(struct rdma_cm_id *id, struct rdma_addrinfo *res,
+ struct ibv_pd *pd, struct ibv_qp_init_attr *qp_init_attr)
+{
+ struct cma_id_private *id_priv;
+ int ret;
+
+ if (af_ib_support)
+ ret = rdma_bind_addr2(id, res->ai_src_addr, res->ai_src_len);
+ else
+ ret = rdma_bind_addr(id, res->ai_src_addr);
+ if (ret)
+ return ret;
+
+ id_priv = container_of(id, struct cma_id_private, id);
+ if (pd)
+ id->pd = pd;
+
+ if (qp_init_attr) {
+ id_priv->qp_init_attr = malloc(sizeof(*qp_init_attr));
+ if (!id_priv->qp_init_attr)
+ return ERR(ENOMEM);
+
+ *id_priv->qp_init_attr = *qp_init_attr;
+ id_priv->qp_init_attr->qp_type = res->ai_qp_type;
+ }
+
+ return 0;
+}
+
+int rdma_create_ep(struct rdma_cm_id **id, struct rdma_addrinfo *res,
+ struct ibv_pd *pd, struct ibv_qp_init_attr *qp_init_attr)
+{
+ struct rdma_cm_id *cm_id;
+ struct cma_id_private *id_priv;
+ int ret;
+
+ ret = rdma_create_id2(NULL, &cm_id, NULL, res->ai_port_space, res->ai_qp_type);
+ if (ret)
+ return ret;
+
+ if (res->ai_flags & RAI_PASSIVE) {
+ ret = ucma_passive_ep(cm_id, res, pd, qp_init_attr);
+ if (ret)
+ goto err;
+ goto out;
+ }
+
+ if (af_ib_support)
+ ret = rdma_resolve_addr2(cm_id, res->ai_src_addr, res->ai_src_len,
+ res->ai_dst_addr, res->ai_dst_len, 2000);
+ else
+ ret = rdma_resolve_addr(cm_id, res->ai_src_addr, res->ai_dst_addr, 2000);
+ if (ret)
+ goto err;
+
+ if (res->ai_route_len) {
+ ret = rdma_set_option(cm_id, RDMA_OPTION_IB, RDMA_OPTION_IB_PATH,
+ res->ai_route, res->ai_route_len);
+ if (!ret)
+ ret = ucma_complete(cm_id);
+ } else {
+ ret = rdma_resolve_route(cm_id, 2000);
+ }
+ if (ret)
+ goto err;
+
+ if (qp_init_attr) {
+ qp_init_attr->qp_type = res->ai_qp_type;
+ ret = rdma_create_qp(cm_id, pd, qp_init_attr);
+ if (ret)
+ goto err;
+ }
+
+ if (res->ai_connect_len) {
+ id_priv = container_of(cm_id, struct cma_id_private, id);
+ id_priv->connect = malloc(res->ai_connect_len);
+ if (!id_priv->connect) {
+ ret = ERR(ENOMEM);
+ goto err;
+ }
+ memcpy(id_priv->connect, res->ai_connect, res->ai_connect_len);
+ id_priv->connect_len = res->ai_connect_len;
+ }
+
+out:
+ *id = cm_id;
+ return 0;
+
+err:
+ rdma_destroy_ep(cm_id);
+ return ret;
+}
+
+void rdma_destroy_ep(struct rdma_cm_id *id)
+{
+ struct cma_id_private *id_priv;
+
+ if (id->qp)
+ rdma_destroy_qp(id);
+
+ if (id->srq)
+ rdma_destroy_srq(id);
+
+ id_priv = container_of(id, struct cma_id_private, id);
+ if (id_priv->qp_init_attr)
+ free(id_priv->qp_init_attr);
+
+ rdma_destroy_id(id);
+}
+
+int ucma_max_qpsize(struct rdma_cm_id *id)
+{
+ struct cma_id_private *id_priv;
+ int i, max_size = 0;
+
+ id_priv = container_of(id, struct cma_id_private, id);
+ if (id && id_priv->cma_dev) {
+ max_size = id_priv->cma_dev->max_qpsize;
+ } else {
+ ucma_init_all();
+ for (i = 0; i < cma_dev_cnt; i++) {
+ if (!max_size || max_size > cma_dev_array[i].max_qpsize)
+ max_size = cma_dev_array[i].max_qpsize;
+ }
+ }
+ return max_size;
+}
+
+__be16 ucma_get_port(struct sockaddr *addr)
+{
+ switch (addr->sa_family) {
+ case AF_INET:
+ return ((struct sockaddr_in *) addr)->sin_port;
+ case AF_INET6:
+ return ((struct sockaddr_in6 *) addr)->sin6_port;
+ case AF_IB:
+ return htobe16((uint16_t) be64toh(((struct sockaddr_ib *) addr)->sib_sid));
+ default:
+ return 0;
+ }
+}
+
+__be16 rdma_get_src_port(struct rdma_cm_id *id)
+{
+ return ucma_get_port(&id->route.addr.src_addr);
+}
+
+__be16 rdma_get_dst_port(struct rdma_cm_id *id)
+{
+ return ucma_get_port(&id->route.addr.dst_addr);
+}
+
diff --git a/contrib/ofed/librdmacm/cma.h b/contrib/ofed/librdmacm/cma.h
new file mode 100644
index 0000000..a3f1f33
--- /dev/null
+++ b/contrib/ofed/librdmacm/cma.h
@@ -0,0 +1,113 @@
+/*
+ * Copyright (c) 2005-2014 Intel Corporation. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+#if !defined(CMA_H)
+#define CMA_H
+
+#include <config.h>
+
+#include <stdlib.h>
+#include <errno.h>
+#include <infiniband/endian.h>
+#include <semaphore.h>
+#include <stdatomic.h>
+
+#include <rdma/rdma_cma.h>
+#include <infiniband/ib.h>
+
+#define PFX "librdmacm: "
+
+/*
+ * Fast synchronization for low contention locking.
+ */
+typedef struct {
+ sem_t sem;
+ _Atomic(int) cnt;
+} fastlock_t;
+static inline void fastlock_init(fastlock_t *lock)
+{
+ sem_init(&lock->sem, 0, 0);
+ atomic_store(&lock->cnt, 0);
+}
+static inline void fastlock_destroy(fastlock_t *lock)
+{
+ sem_destroy(&lock->sem);
+}
+static inline void fastlock_acquire(fastlock_t *lock)
+{
+ if (atomic_fetch_add(&lock->cnt, 1) > 0)
+ sem_wait(&lock->sem);
+}
+static inline void fastlock_release(fastlock_t *lock)
+{
+ if (atomic_fetch_sub(&lock->cnt, 1) > 1)
+ sem_post(&lock->sem);
+}
+
+__be16 ucma_get_port(struct sockaddr *addr);
+int ucma_addrlen(struct sockaddr *addr);
+void ucma_set_sid(enum rdma_port_space ps, struct sockaddr *addr,
+ struct sockaddr_ib *sib);
+int ucma_max_qpsize(struct rdma_cm_id *id);
+int ucma_complete(struct rdma_cm_id *id);
+int ucma_shutdown(struct rdma_cm_id *id);
+
+static inline int ERR(int err)
+{
+ errno = err;
+ return -1;
+}
+
+int ucma_init(void);
+extern int af_ib_support;
+
+#define RAI_ROUTEONLY 0x01000000
+
+void ucma_ib_init(void);
+void ucma_ib_cleanup(void);
+void ucma_ib_resolve(struct rdma_addrinfo **rai,
+ const struct rdma_addrinfo *hints);
+
+struct ib_connect_hdr {
+ uint8_t cma_version;
+ uint8_t ip_version; /* IP version: 7:4 */
+ uint16_t port;
+ uint32_t src_addr[4];
+ uint32_t dst_addr[4];
+#define cma_src_ip4 src_addr[3]
+#define cma_src_ip6 src_addr[0]
+#define cma_dst_ip4 dst_addr[3]
+#define cma_dst_ip6 dst_addr[0]
+};
+
+#endif /* CMA_H */
diff --git a/contrib/ofed/librdmacm/config.h b/contrib/ofed/librdmacm/config.h
new file mode 100644
index 0000000..3742629
--- /dev/null
+++ b/contrib/ofed/librdmacm/config.h
@@ -0,0 +1,9 @@
+/* $FreeBSD$ */
+
+#define min(a, b) ((a) > (b) ? (b) : (a))
+#define VALGRIND_MAKE_MEM_DEFINED(...) 0
+#define s6_addr32 __u6_addr.__u6_addr32
+#define STREAM_CLOEXEC "e"
+#define ENODATA ECONNREFUSED
+#define IBACM_PORT_FILE "/var/run/ibacm.port"
+
diff --git a/contrib/ofed/librdmacm/config.h.in b/contrib/ofed/librdmacm/config.h.in
deleted file mode 100644
index 48a9db8..0000000
--- a/contrib/ofed/librdmacm/config.h.in
+++ /dev/null
@@ -1,67 +0,0 @@
-/* config.h.in. Generated from configure.in by autoheader. */
-
-/* Define to 1 if you have the <dlfcn.h> header file. */
-#undef HAVE_DLFCN_H
-
-/* Define to 1 if you have the <inttypes.h> header file. */
-#undef HAVE_INTTYPES_H
-
-/* Define to 1 if you have the `ibverbs' library (-libverbs). */
-#undef HAVE_LIBIBVERBS
-
-/* Define to 1 if you have the <memory.h> header file. */
-#undef HAVE_MEMORY_H
-
-/* Define to 1 if you have the <stdint.h> header file. */
-#undef HAVE_STDINT_H
-
-/* Define to 1 if you have the <stdlib.h> header file. */
-#undef HAVE_STDLIB_H
-
-/* Define to 1 if you have the <strings.h> header file. */
-#undef HAVE_STRINGS_H
-
-/* Define to 1 if you have the <string.h> header file. */
-#undef HAVE_STRING_H
-
-/* Define to 1 if you have the <sys/stat.h> header file. */
-#undef HAVE_SYS_STAT_H
-
-/* Define to 1 if you have the <sys/types.h> header file. */
-#undef HAVE_SYS_TYPES_H
-
-/* Define to 1 if you have the <unistd.h> header file. */
-#undef HAVE_UNISTD_H
-
-/* Define to 1 to enable valgrind annotations */
-#undef INCLUDE_VALGRIND
-
-/* Name of package */
-#undef PACKAGE
-
-/* Define to the address where bug reports for this package should be sent. */
-#undef PACKAGE_BUGREPORT
-
-/* Define to the full name of this package. */
-#undef PACKAGE_NAME
-
-/* Define to the full name and version of this package. */
-#undef PACKAGE_STRING
-
-/* Define to the one symbol short name of this package. */
-#undef PACKAGE_TARNAME
-
-/* Define to the version of this package. */
-#undef PACKAGE_VERSION
-
-/* The size of a `long', as computed by sizeof. */
-#undef SIZEOF_LONG
-
-/* Define to 1 if you have the ANSI C header files. */
-#undef STDC_HEADERS
-
-/* Version number of package */
-#undef VERSION
-
-/* Define to empty if `const' does not conform to ANSI C. */
-#undef const
diff --git a/contrib/ofed/librdmacm/config/compile b/contrib/ofed/librdmacm/config/compile
deleted file mode 100755
index 1b1d232..0000000
--- a/contrib/ofed/librdmacm/config/compile
+++ /dev/null
@@ -1,142 +0,0 @@
-#! /bin/sh
-# Wrapper for compilers which do not understand `-c -o'.
-
-scriptversion=2005-05-14.22
-
-# Copyright (C) 1999, 2000, 2003, 2004, 2005 Free Software Foundation, Inc.
-# Written by Tom Tromey <tromey@cygnus.com>.
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2, or (at your option)
-# any later version.
-#
-# This program 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 this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-
-# As a special exception to the GNU General Public License, if you
-# distribute this file as part of a program that contains a
-# configuration script generated by Autoconf, you may include it under
-# the same distribution terms that you use for the rest of that program.
-
-# This file is maintained in Automake, please report
-# bugs to <bug-automake@gnu.org> or send patches to
-# <automake-patches@gnu.org>.
-
-case $1 in
- '')
- echo "$0: No command. Try \`$0 --help' for more information." 1>&2
- exit 1;
- ;;
- -h | --h*)
- cat <<\EOF
-Usage: compile [--help] [--version] PROGRAM [ARGS]
-
-Wrapper for compilers which do not understand `-c -o'.
-Remove `-o dest.o' from ARGS, run PROGRAM with the remaining
-arguments, and rename the output as expected.
-
-If you are trying to build a whole package this is not the
-right script to run: please start by reading the file `INSTALL'.
-
-Report bugs to <bug-automake@gnu.org>.
-EOF
- exit $?
- ;;
- -v | --v*)
- echo "compile $scriptversion"
- exit $?
- ;;
-esac
-
-ofile=
-cfile=
-eat=
-
-for arg
-do
- if test -n "$eat"; then
- eat=
- else
- case $1 in
- -o)
- # configure might choose to run compile as `compile cc -o foo foo.c'.
- # So we strip `-o arg' only if arg is an object.
- eat=1
- case $2 in
- *.o | *.obj)
- ofile=$2
- ;;
- *)
- set x "$@" -o "$2"
- shift
- ;;
- esac
- ;;
- *.c)
- cfile=$1
- set x "$@" "$1"
- shift
- ;;
- *)
- set x "$@" "$1"
- shift
- ;;
- esac
- fi
- shift
-done
-
-if test -z "$ofile" || test -z "$cfile"; then
- # If no `-o' option was seen then we might have been invoked from a
- # pattern rule where we don't need one. That is ok -- this is a
- # normal compilation that the losing compiler can handle. If no
- # `.c' file was seen then we are probably linking. That is also
- # ok.
- exec "$@"
-fi
-
-# Name of file we expect compiler to create.
-cofile=`echo "$cfile" | sed -e 's|^.*/||' -e 's/\.c$/.o/'`
-
-# Create the lock directory.
-# Note: use `[/.-]' here to ensure that we don't use the same name
-# that we are using for the .o file. Also, base the name on the expected
-# object file name, since that is what matters with a parallel build.
-lockdir=`echo "$cofile" | sed -e 's|[/.-]|_|g'`.d
-while true; do
- if mkdir "$lockdir" >/dev/null 2>&1; then
- break
- fi
- sleep 1
-done
-# FIXME: race condition here if user kills between mkdir and trap.
-trap "rmdir '$lockdir'; exit 1" 1 2 15
-
-# Run the compile.
-"$@"
-ret=$?
-
-if test -f "$cofile"; then
- mv "$cofile" "$ofile"
-elif test -f "${cofile}bj"; then
- mv "${cofile}bj" "$ofile"
-fi
-
-rmdir "$lockdir"
-exit $ret
-
-# Local Variables:
-# mode: shell-script
-# sh-indentation: 2
-# eval: (add-hook 'write-file-hooks 'time-stamp)
-# time-stamp-start: "scriptversion="
-# time-stamp-format: "%:y-%02m-%02d.%02H"
-# time-stamp-end: "$"
-# End:
diff --git a/contrib/ofed/librdmacm/config/config.guess b/contrib/ofed/librdmacm/config/config.guess
deleted file mode 100755
index ad5281e..0000000
--- a/contrib/ofed/librdmacm/config/config.guess
+++ /dev/null
@@ -1,1466 +0,0 @@
-#! /bin/sh
-# Attempt to guess a canonical system name.
-# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
-# 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
-
-timestamp='2005-08-03'
-
-# This file is free software; you can redistribute it and/or modify it
-# under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-#
-# This program 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 this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA
-# 02110-1301, USA.
-#
-# As a special exception to the GNU General Public License, if you
-# distribute this file as part of a program that contains a
-# configuration script generated by Autoconf, you may include it under
-# the same distribution terms that you use for the rest of that program.
-
-
-# Originally written by Per Bothner <per@bothner.com>.
-# Please send patches to <config-patches@gnu.org>. Submit a context
-# diff and a properly formatted ChangeLog entry.
-#
-# This script attempts to guess a canonical system name similar to
-# config.sub. If it succeeds, it prints the system name on stdout, and
-# exits with 0. Otherwise, it exits with 1.
-#
-# The plan is that this can be called by configure scripts if you
-# don't specify an explicit build system type.
-
-me=`echo "$0" | sed -e 's,.*/,,'`
-
-usage="\
-Usage: $0 [OPTION]
-
-Output the configuration name of the system \`$me' is run on.
-
-Operation modes:
- -h, --help print this help, then exit
- -t, --time-stamp print date of last modification, then exit
- -v, --version print version number, then exit
-
-Report bugs and patches to <config-patches@gnu.org>."
-
-version="\
-GNU config.guess ($timestamp)
-
-Originally written by Per Bothner.
-Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005
-Free Software Foundation, Inc.
-
-This is free software; see the source for copying conditions. There is NO
-warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
-
-help="
-Try \`$me --help' for more information."
-
-# Parse command line
-while test $# -gt 0 ; do
- case $1 in
- --time-stamp | --time* | -t )
- echo "$timestamp" ; exit ;;
- --version | -v )
- echo "$version" ; exit ;;
- --help | --h* | -h )
- echo "$usage"; exit ;;
- -- ) # Stop option processing
- shift; break ;;
- - ) # Use stdin as input.
- break ;;
- -* )
- echo "$me: invalid option $1$help" >&2
- exit 1 ;;
- * )
- break ;;
- esac
-done
-
-if test $# != 0; then
- echo "$me: too many arguments$help" >&2
- exit 1
-fi
-
-trap 'exit 1' 1 2 15
-
-# CC_FOR_BUILD -- compiler used by this script. Note that the use of a
-# compiler to aid in system detection is discouraged as it requires
-# temporary files to be created and, as you can see below, it is a
-# headache to deal with in a portable fashion.
-
-# Historically, `CC_FOR_BUILD' used to be named `HOST_CC'. We still
-# use `HOST_CC' if defined, but it is deprecated.
-
-# Portable tmp directory creation inspired by the Autoconf team.
-
-set_cc_for_build='
-trap "exitcode=\$?; (rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null) && exit \$exitcode" 0 ;
-trap "rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null; exit 1" 1 2 13 15 ;
-: ${TMPDIR=/tmp} ;
- { tmp=`(umask 077 && mktemp -d -q "$TMPDIR/cgXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" ; } ||
- { test -n "$RANDOM" && tmp=$TMPDIR/cg$$-$RANDOM && (umask 077 && mkdir $tmp) ; } ||
- { tmp=$TMPDIR/cg-$$ && (umask 077 && mkdir $tmp) && echo "Warning: creating insecure temp directory" >&2 ; } ||
- { echo "$me: cannot create a temporary directory in $TMPDIR" >&2 ; exit 1 ; } ;
-dummy=$tmp/dummy ;
-tmpfiles="$dummy.c $dummy.o $dummy.rel $dummy" ;
-case $CC_FOR_BUILD,$HOST_CC,$CC in
- ,,) echo "int x;" > $dummy.c ;
- for c in cc gcc c89 c99 ; do
- if ($c -c -o $dummy.o $dummy.c) >/dev/null 2>&1 ; then
- CC_FOR_BUILD="$c"; break ;
- fi ;
- done ;
- if test x"$CC_FOR_BUILD" = x ; then
- CC_FOR_BUILD=no_compiler_found ;
- fi
- ;;
- ,,*) CC_FOR_BUILD=$CC ;;
- ,*,*) CC_FOR_BUILD=$HOST_CC ;;
-esac ; set_cc_for_build= ;'
-
-# This is needed to find uname on a Pyramid OSx when run in the BSD universe.
-# (ghazi@noc.rutgers.edu 1994-08-24)
-if (test -f /.attbin/uname) >/dev/null 2>&1 ; then
- PATH=$PATH:/.attbin ; export PATH
-fi
-
-UNAME_MACHINE=`(uname -m) 2>/dev/null` || UNAME_MACHINE=unknown
-UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown
-UNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown
-UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown
-
-# Note: order is significant - the case branches are not exclusive.
-
-case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
- *:NetBSD:*:*)
- # NetBSD (nbsd) targets should (where applicable) match one or
- # more of the tupples: *-*-netbsdelf*, *-*-netbsdaout*,
- # *-*-netbsdecoff* and *-*-netbsd*. For targets that recently
- # switched to ELF, *-*-netbsd* would select the old
- # object file format. This provides both forward
- # compatibility and a consistent mechanism for selecting the
- # object file format.
- #
- # Note: NetBSD doesn't particularly care about the vendor
- # portion of the name. We always set it to "unknown".
- sysctl="sysctl -n hw.machine_arch"
- UNAME_MACHINE_ARCH=`(/sbin/$sysctl 2>/dev/null || \
- /usr/sbin/$sysctl 2>/dev/null || echo unknown)`
- case "${UNAME_MACHINE_ARCH}" in
- armeb) machine=armeb-unknown ;;
- arm*) machine=arm-unknown ;;
- sh3el) machine=shl-unknown ;;
- sh3eb) machine=sh-unknown ;;
- *) machine=${UNAME_MACHINE_ARCH}-unknown ;;
- esac
- # The Operating System including object format, if it has switched
- # to ELF recently, or will in the future.
- case "${UNAME_MACHINE_ARCH}" in
- arm*|i386|m68k|ns32k|sh3*|sparc|vax)
- eval $set_cc_for_build
- if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \
- | grep __ELF__ >/dev/null
- then
- # Once all utilities can be ECOFF (netbsdecoff) or a.out (netbsdaout).
- # Return netbsd for either. FIX?
- os=netbsd
- else
- os=netbsdelf
- fi
- ;;
- *)
- os=netbsd
- ;;
- esac
- # The OS release
- # Debian GNU/NetBSD machines have a different userland, and
- # thus, need a distinct triplet. However, they do not need
- # kernel version information, so it can be replaced with a
- # suitable tag, in the style of linux-gnu.
- case "${UNAME_VERSION}" in
- Debian*)
- release='-gnu'
- ;;
- *)
- release=`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'`
- ;;
- esac
- # Since CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM:
- # contains redundant information, the shorter form:
- # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used.
- echo "${machine}-${os}${release}"
- exit ;;
- *:OpenBSD:*:*)
- UNAME_MACHINE_ARCH=`arch | sed 's/OpenBSD.//'`
- echo ${UNAME_MACHINE_ARCH}-unknown-openbsd${UNAME_RELEASE}
- exit ;;
- *:ekkoBSD:*:*)
- echo ${UNAME_MACHINE}-unknown-ekkobsd${UNAME_RELEASE}
- exit ;;
- macppc:MirBSD:*:*)
- echo powerppc-unknown-mirbsd${UNAME_RELEASE}
- exit ;;
- *:MirBSD:*:*)
- echo ${UNAME_MACHINE}-unknown-mirbsd${UNAME_RELEASE}
- exit ;;
- alpha:OSF1:*:*)
- case $UNAME_RELEASE in
- *4.0)
- UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'`
- ;;
- *5.*)
- UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $4}'`
- ;;
- esac
- # According to Compaq, /usr/sbin/psrinfo has been available on
- # OSF/1 and Tru64 systems produced since 1995. I hope that
- # covers most systems running today. This code pipes the CPU
- # types through head -n 1, so we only detect the type of CPU 0.
- ALPHA_CPU_TYPE=`/usr/sbin/psrinfo -v | sed -n -e 's/^ The alpha \(.*\) processor.*$/\1/p' | head -n 1`
- case "$ALPHA_CPU_TYPE" in
- "EV4 (21064)")
- UNAME_MACHINE="alpha" ;;
- "EV4.5 (21064)")
- UNAME_MACHINE="alpha" ;;
- "LCA4 (21066/21068)")
- UNAME_MACHINE="alpha" ;;
- "EV5 (21164)")
- UNAME_MACHINE="alphaev5" ;;
- "EV5.6 (21164A)")
- UNAME_MACHINE="alphaev56" ;;
- "EV5.6 (21164PC)")
- UNAME_MACHINE="alphapca56" ;;
- "EV5.7 (21164PC)")
- UNAME_MACHINE="alphapca57" ;;
- "EV6 (21264)")
- UNAME_MACHINE="alphaev6" ;;
- "EV6.7 (21264A)")
- UNAME_MACHINE="alphaev67" ;;
- "EV6.8CB (21264C)")
- UNAME_MACHINE="alphaev68" ;;
- "EV6.8AL (21264B)")
- UNAME_MACHINE="alphaev68" ;;
- "EV6.8CX (21264D)")
- UNAME_MACHINE="alphaev68" ;;
- "EV6.9A (21264/EV69A)")
- UNAME_MACHINE="alphaev69" ;;
- "EV7 (21364)")
- UNAME_MACHINE="alphaev7" ;;
- "EV7.9 (21364A)")
- UNAME_MACHINE="alphaev79" ;;
- esac
- # A Pn.n version is a patched version.
- # A Vn.n version is a released version.
- # A Tn.n version is a released field test version.
- # A Xn.n version is an unreleased experimental baselevel.
- # 1.2 uses "1.2" for uname -r.
- echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[PVTX]//' | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'`
- exit ;;
- Alpha\ *:Windows_NT*:*)
- # How do we know it's Interix rather than the generic POSIX subsystem?
- # Should we change UNAME_MACHINE based on the output of uname instead
- # of the specific Alpha model?
- echo alpha-pc-interix
- exit ;;
- 21064:Windows_NT:50:3)
- echo alpha-dec-winnt3.5
- exit ;;
- Amiga*:UNIX_System_V:4.0:*)
- echo m68k-unknown-sysv4
- exit ;;
- *:[Aa]miga[Oo][Ss]:*:*)
- echo ${UNAME_MACHINE}-unknown-amigaos
- exit ;;
- *:[Mm]orph[Oo][Ss]:*:*)
- echo ${UNAME_MACHINE}-unknown-morphos
- exit ;;
- *:OS/390:*:*)
- echo i370-ibm-openedition
- exit ;;
- *:z/VM:*:*)
- echo s390-ibm-zvmoe
- exit ;;
- *:OS400:*:*)
- echo powerpc-ibm-os400
- exit ;;
- arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*)
- echo arm-acorn-riscix${UNAME_RELEASE}
- exit ;;
- arm:riscos:*:*|arm:RISCOS:*:*)
- echo arm-unknown-riscos
- exit ;;
- SR2?01:HI-UX/MPP:*:* | SR8000:HI-UX/MPP:*:*)
- echo hppa1.1-hitachi-hiuxmpp
- exit ;;
- Pyramid*:OSx*:*:* | MIS*:OSx*:*:* | MIS*:SMP_DC-OSx*:*:*)
- # akee@wpdis03.wpafb.af.mil (Earle F. Ake) contributed MIS and NILE.
- if test "`(/bin/universe) 2>/dev/null`" = att ; then
- echo pyramid-pyramid-sysv3
- else
- echo pyramid-pyramid-bsd
- fi
- exit ;;
- NILE*:*:*:dcosx)
- echo pyramid-pyramid-svr4
- exit ;;
- DRS?6000:unix:4.0:6*)
- echo sparc-icl-nx6
- exit ;;
- DRS?6000:UNIX_SV:4.2*:7* | DRS?6000:isis:4.2*:7*)
- case `/usr/bin/uname -p` in
- sparc) echo sparc-icl-nx7; exit ;;
- esac ;;
- sun4H:SunOS:5.*:*)
- echo sparc-hal-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
- exit ;;
- sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*)
- echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
- exit ;;
- i86pc:SunOS:5.*:*)
- echo i386-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
- exit ;;
- sun4*:SunOS:6*:*)
- # According to config.sub, this is the proper way to canonicalize
- # SunOS6. Hard to guess exactly what SunOS6 will be like, but
- # it's likely to be more like Solaris than SunOS4.
- echo sparc-sun-solaris3`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
- exit ;;
- sun4*:SunOS:*:*)
- case "`/usr/bin/arch -k`" in
- Series*|S4*)
- UNAME_RELEASE=`uname -v`
- ;;
- esac
- # Japanese Language versions have a version number like `4.1.3-JL'.
- echo sparc-sun-sunos`echo ${UNAME_RELEASE}|sed -e 's/-/_/'`
- exit ;;
- sun3*:SunOS:*:*)
- echo m68k-sun-sunos${UNAME_RELEASE}
- exit ;;
- sun*:*:4.2BSD:*)
- UNAME_RELEASE=`(sed 1q /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null`
- test "x${UNAME_RELEASE}" = "x" && UNAME_RELEASE=3
- case "`/bin/arch`" in
- sun3)
- echo m68k-sun-sunos${UNAME_RELEASE}
- ;;
- sun4)
- echo sparc-sun-sunos${UNAME_RELEASE}
- ;;
- esac
- exit ;;
- aushp:SunOS:*:*)
- echo sparc-auspex-sunos${UNAME_RELEASE}
- exit ;;
- # The situation for MiNT is a little confusing. The machine name
- # can be virtually everything (everything which is not
- # "atarist" or "atariste" at least should have a processor
- # > m68000). The system name ranges from "MiNT" over "FreeMiNT"
- # to the lowercase version "mint" (or "freemint"). Finally
- # the system name "TOS" denotes a system which is actually not
- # MiNT. But MiNT is downward compatible to TOS, so this should
- # be no problem.
- atarist[e]:*MiNT:*:* | atarist[e]:*mint:*:* | atarist[e]:*TOS:*:*)
- echo m68k-atari-mint${UNAME_RELEASE}
- exit ;;
- atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*)
- echo m68k-atari-mint${UNAME_RELEASE}
- exit ;;
- *falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*)
- echo m68k-atari-mint${UNAME_RELEASE}
- exit ;;
- milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*)
- echo m68k-milan-mint${UNAME_RELEASE}
- exit ;;
- hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*)
- echo m68k-hades-mint${UNAME_RELEASE}
- exit ;;
- *:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*)
- echo m68k-unknown-mint${UNAME_RELEASE}
- exit ;;
- m68k:machten:*:*)
- echo m68k-apple-machten${UNAME_RELEASE}
- exit ;;
- powerpc:machten:*:*)
- echo powerpc-apple-machten${UNAME_RELEASE}
- exit ;;
- RISC*:Mach:*:*)
- echo mips-dec-mach_bsd4.3
- exit ;;
- RISC*:ULTRIX:*:*)
- echo mips-dec-ultrix${UNAME_RELEASE}
- exit ;;
- VAX*:ULTRIX*:*:*)
- echo vax-dec-ultrix${UNAME_RELEASE}
- exit ;;
- 2020:CLIX:*:* | 2430:CLIX:*:*)
- echo clipper-intergraph-clix${UNAME_RELEASE}
- exit ;;
- mips:*:*:UMIPS | mips:*:*:RISCos)
- eval $set_cc_for_build
- sed 's/^ //' << EOF >$dummy.c
-#ifdef __cplusplus
-#include <stdio.h> /* for printf() prototype */
- int main (int argc, char *argv[]) {
-#else
- int main (argc, argv) int argc; char *argv[]; {
-#endif
- #if defined (host_mips) && defined (MIPSEB)
- #if defined (SYSTYPE_SYSV)
- printf ("mips-mips-riscos%ssysv\n", argv[1]); exit (0);
- #endif
- #if defined (SYSTYPE_SVR4)
- printf ("mips-mips-riscos%ssvr4\n", argv[1]); exit (0);
- #endif
- #if defined (SYSTYPE_BSD43) || defined(SYSTYPE_BSD)
- printf ("mips-mips-riscos%sbsd\n", argv[1]); exit (0);
- #endif
- #endif
- exit (-1);
- }
-EOF
- $CC_FOR_BUILD -o $dummy $dummy.c &&
- dummyarg=`echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` &&
- SYSTEM_NAME=`$dummy $dummyarg` &&
- { echo "$SYSTEM_NAME"; exit; }
- echo mips-mips-riscos${UNAME_RELEASE}
- exit ;;
- Motorola:PowerMAX_OS:*:*)
- echo powerpc-motorola-powermax
- exit ;;
- Motorola:*:4.3:PL8-*)
- echo powerpc-harris-powermax
- exit ;;
- Night_Hawk:*:*:PowerMAX_OS | Synergy:PowerMAX_OS:*:*)
- echo powerpc-harris-powermax
- exit ;;
- Night_Hawk:Power_UNIX:*:*)
- echo powerpc-harris-powerunix
- exit ;;
- m88k:CX/UX:7*:*)
- echo m88k-harris-cxux7
- exit ;;
- m88k:*:4*:R4*)
- echo m88k-motorola-sysv4
- exit ;;
- m88k:*:3*:R3*)
- echo m88k-motorola-sysv3
- exit ;;
- AViiON:dgux:*:*)
- # DG/UX returns AViiON for all architectures
- UNAME_PROCESSOR=`/usr/bin/uname -p`
- if [ $UNAME_PROCESSOR = mc88100 ] || [ $UNAME_PROCESSOR = mc88110 ]
- then
- if [ ${TARGET_BINARY_INTERFACE}x = m88kdguxelfx ] || \
- [ ${TARGET_BINARY_INTERFACE}x = x ]
- then
- echo m88k-dg-dgux${UNAME_RELEASE}
- else
- echo m88k-dg-dguxbcs${UNAME_RELEASE}
- fi
- else
- echo i586-dg-dgux${UNAME_RELEASE}
- fi
- exit ;;
- M88*:DolphinOS:*:*) # DolphinOS (SVR3)
- echo m88k-dolphin-sysv3
- exit ;;
- M88*:*:R3*:*)
- # Delta 88k system running SVR3
- echo m88k-motorola-sysv3
- exit ;;
- XD88*:*:*:*) # Tektronix XD88 system running UTekV (SVR3)
- echo m88k-tektronix-sysv3
- exit ;;
- Tek43[0-9][0-9]:UTek:*:*) # Tektronix 4300 system running UTek (BSD)
- echo m68k-tektronix-bsd
- exit ;;
- *:IRIX*:*:*)
- echo mips-sgi-irix`echo ${UNAME_RELEASE}|sed -e 's/-/_/g'`
- exit ;;
- ????????:AIX?:[12].1:2) # AIX 2.2.1 or AIX 2.1.1 is RT/PC AIX.
- echo romp-ibm-aix # uname -m gives an 8 hex-code CPU id
- exit ;; # Note that: echo "'`uname -s`'" gives 'AIX '
- i*86:AIX:*:*)
- echo i386-ibm-aix
- exit ;;
- ia64:AIX:*:*)
- if [ -x /usr/bin/oslevel ] ; then
- IBM_REV=`/usr/bin/oslevel`
- else
- IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE}
- fi
- echo ${UNAME_MACHINE}-ibm-aix${IBM_REV}
- exit ;;
- *:AIX:2:3)
- if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then
- eval $set_cc_for_build
- sed 's/^ //' << EOF >$dummy.c
- #include <sys/systemcfg.h>
-
- main()
- {
- if (!__power_pc())
- exit(1);
- puts("powerpc-ibm-aix3.2.5");
- exit(0);
- }
-EOF
- if $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy`
- then
- echo "$SYSTEM_NAME"
- else
- echo rs6000-ibm-aix3.2.5
- fi
- elif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then
- echo rs6000-ibm-aix3.2.4
- else
- echo rs6000-ibm-aix3.2
- fi
- exit ;;
- *:AIX:*:[45])
- IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | sed 1q | awk '{ print $1 }'`
- if /usr/sbin/lsattr -El ${IBM_CPU_ID} | grep ' POWER' >/dev/null 2>&1; then
- IBM_ARCH=rs6000
- else
- IBM_ARCH=powerpc
- fi
- if [ -x /usr/bin/oslevel ] ; then
- IBM_REV=`/usr/bin/oslevel`
- else
- IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE}
- fi
- echo ${IBM_ARCH}-ibm-aix${IBM_REV}
- exit ;;
- *:AIX:*:*)
- echo rs6000-ibm-aix
- exit ;;
- ibmrt:4.4BSD:*|romp-ibm:BSD:*)
- echo romp-ibm-bsd4.4
- exit ;;
- ibmrt:*BSD:*|romp-ibm:BSD:*) # covers RT/PC BSD and
- echo romp-ibm-bsd${UNAME_RELEASE} # 4.3 with uname added to
- exit ;; # report: romp-ibm BSD 4.3
- *:BOSX:*:*)
- echo rs6000-bull-bosx
- exit ;;
- DPX/2?00:B.O.S.:*:*)
- echo m68k-bull-sysv3
- exit ;;
- 9000/[34]??:4.3bsd:1.*:*)
- echo m68k-hp-bsd
- exit ;;
- hp300:4.4BSD:*:* | 9000/[34]??:4.3bsd:2.*:*)
- echo m68k-hp-bsd4.4
- exit ;;
- 9000/[34678]??:HP-UX:*:*)
- HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'`
- case "${UNAME_MACHINE}" in
- 9000/31? ) HP_ARCH=m68000 ;;
- 9000/[34]?? ) HP_ARCH=m68k ;;
- 9000/[678][0-9][0-9])
- if [ -x /usr/bin/getconf ]; then
- sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null`
- sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null`
- case "${sc_cpu_version}" in
- 523) HP_ARCH="hppa1.0" ;; # CPU_PA_RISC1_0
- 528) HP_ARCH="hppa1.1" ;; # CPU_PA_RISC1_1
- 532) # CPU_PA_RISC2_0
- case "${sc_kernel_bits}" in
- 32) HP_ARCH="hppa2.0n" ;;
- 64) HP_ARCH="hppa2.0w" ;;
- '') HP_ARCH="hppa2.0" ;; # HP-UX 10.20
- esac ;;
- esac
- fi
- if [ "${HP_ARCH}" = "" ]; then
- eval $set_cc_for_build
- sed 's/^ //' << EOF >$dummy.c
-
- #define _HPUX_SOURCE
- #include <stdlib.h>
- #include <unistd.h>
-
- int main ()
- {
- #if defined(_SC_KERNEL_BITS)
- long bits = sysconf(_SC_KERNEL_BITS);
- #endif
- long cpu = sysconf (_SC_CPU_VERSION);
-
- switch (cpu)
- {
- case CPU_PA_RISC1_0: puts ("hppa1.0"); break;
- case CPU_PA_RISC1_1: puts ("hppa1.1"); break;
- case CPU_PA_RISC2_0:
- #if defined(_SC_KERNEL_BITS)
- switch (bits)
- {
- case 64: puts ("hppa2.0w"); break;
- case 32: puts ("hppa2.0n"); break;
- default: puts ("hppa2.0"); break;
- } break;
- #else /* !defined(_SC_KERNEL_BITS) */
- puts ("hppa2.0"); break;
- #endif
- default: puts ("hppa1.0"); break;
- }
- exit (0);
- }
-EOF
- (CCOPTS= $CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null) && HP_ARCH=`$dummy`
- test -z "$HP_ARCH" && HP_ARCH=hppa
- fi ;;
- esac
- if [ ${HP_ARCH} = "hppa2.0w" ]
- then
- eval $set_cc_for_build
-
- # hppa2.0w-hp-hpux* has a 64-bit kernel and a compiler generating
- # 32-bit code. hppa64-hp-hpux* has the same kernel and a compiler
- # generating 64-bit code. GNU and HP use different nomenclature:
- #
- # $ CC_FOR_BUILD=cc ./config.guess
- # => hppa2.0w-hp-hpux11.23
- # $ CC_FOR_BUILD="cc +DA2.0w" ./config.guess
- # => hppa64-hp-hpux11.23
-
- if echo __LP64__ | (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) |
- grep __LP64__ >/dev/null
- then
- HP_ARCH="hppa2.0w"
- else
- HP_ARCH="hppa64"
- fi
- fi
- echo ${HP_ARCH}-hp-hpux${HPUX_REV}
- exit ;;
- ia64:HP-UX:*:*)
- HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'`
- echo ia64-hp-hpux${HPUX_REV}
- exit ;;
- 3050*:HI-UX:*:*)
- eval $set_cc_for_build
- sed 's/^ //' << EOF >$dummy.c
- #include <unistd.h>
- int
- main ()
- {
- long cpu = sysconf (_SC_CPU_VERSION);
- /* The order matters, because CPU_IS_HP_MC68K erroneously returns
- true for CPU_PA_RISC1_0. CPU_IS_PA_RISC returns correct
- results, however. */
- if (CPU_IS_PA_RISC (cpu))
- {
- switch (cpu)
- {
- case CPU_PA_RISC1_0: puts ("hppa1.0-hitachi-hiuxwe2"); break;
- case CPU_PA_RISC1_1: puts ("hppa1.1-hitachi-hiuxwe2"); break;
- case CPU_PA_RISC2_0: puts ("hppa2.0-hitachi-hiuxwe2"); break;
- default: puts ("hppa-hitachi-hiuxwe2"); break;
- }
- }
- else if (CPU_IS_HP_MC68K (cpu))
- puts ("m68k-hitachi-hiuxwe2");
- else puts ("unknown-hitachi-hiuxwe2");
- exit (0);
- }
-EOF
- $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy` &&
- { echo "$SYSTEM_NAME"; exit; }
- echo unknown-hitachi-hiuxwe2
- exit ;;
- 9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:* )
- echo hppa1.1-hp-bsd
- exit ;;
- 9000/8??:4.3bsd:*:*)
- echo hppa1.0-hp-bsd
- exit ;;
- *9??*:MPE/iX:*:* | *3000*:MPE/iX:*:*)
- echo hppa1.0-hp-mpeix
- exit ;;
- hp7??:OSF1:*:* | hp8?[79]:OSF1:*:* )
- echo hppa1.1-hp-osf
- exit ;;
- hp8??:OSF1:*:*)
- echo hppa1.0-hp-osf
- exit ;;
- i*86:OSF1:*:*)
- if [ -x /usr/sbin/sysversion ] ; then
- echo ${UNAME_MACHINE}-unknown-osf1mk
- else
- echo ${UNAME_MACHINE}-unknown-osf1
- fi
- exit ;;
- parisc*:Lites*:*:*)
- echo hppa1.1-hp-lites
- exit ;;
- C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*)
- echo c1-convex-bsd
- exit ;;
- C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*)
- if getsysinfo -f scalar_acc
- then echo c32-convex-bsd
- else echo c2-convex-bsd
- fi
- exit ;;
- C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*)
- echo c34-convex-bsd
- exit ;;
- C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*)
- echo c38-convex-bsd
- exit ;;
- C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*)
- echo c4-convex-bsd
- exit ;;
- CRAY*Y-MP:*:*:*)
- echo ymp-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
- exit ;;
- CRAY*[A-Z]90:*:*:*)
- echo ${UNAME_MACHINE}-cray-unicos${UNAME_RELEASE} \
- | sed -e 's/CRAY.*\([A-Z]90\)/\1/' \
- -e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/ \
- -e 's/\.[^.]*$/.X/'
- exit ;;
- CRAY*TS:*:*:*)
- echo t90-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
- exit ;;
- CRAY*T3E:*:*:*)
- echo alphaev5-cray-unicosmk${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
- exit ;;
- CRAY*SV1:*:*:*)
- echo sv1-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
- exit ;;
- *:UNICOS/mp:*:*)
- echo craynv-cray-unicosmp${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
- exit ;;
- F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*)
- FUJITSU_PROC=`uname -m | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'`
- FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'`
- FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'`
- echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}"
- exit ;;
- 5000:UNIX_System_V:4.*:*)
- FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'`
- FUJITSU_REL=`echo ${UNAME_RELEASE} | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/ /_/'`
- echo "sparc-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}"
- exit ;;
- i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*)
- echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE}
- exit ;;
- sparc*:BSD/OS:*:*)
- echo sparc-unknown-bsdi${UNAME_RELEASE}
- exit ;;
- *:BSD/OS:*:*)
- echo ${UNAME_MACHINE}-unknown-bsdi${UNAME_RELEASE}
- exit ;;
- *:FreeBSD:*:*)
- echo ${UNAME_MACHINE}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`
- exit ;;
- i*:CYGWIN*:*)
- echo ${UNAME_MACHINE}-pc-cygwin
- exit ;;
- i*:MINGW*:*)
- echo ${UNAME_MACHINE}-pc-mingw32
- exit ;;
- i*:windows32*:*)
- # uname -m includes "-pc" on this system.
- echo ${UNAME_MACHINE}-mingw32
- exit ;;
- i*:PW*:*)
- echo ${UNAME_MACHINE}-pc-pw32
- exit ;;
- x86:Interix*:[34]*)
- echo i586-pc-interix${UNAME_RELEASE}|sed -e 's/\..*//'
- exit ;;
- [345]86:Windows_95:* | [345]86:Windows_98:* | [345]86:Windows_NT:*)
- echo i${UNAME_MACHINE}-pc-mks
- exit ;;
- i*:Windows_NT*:* | Pentium*:Windows_NT*:*)
- # How do we know it's Interix rather than the generic POSIX subsystem?
- # It also conflicts with pre-2.0 versions of AT&T UWIN. Should we
- # UNAME_MACHINE based on the output of uname instead of i386?
- echo i586-pc-interix
- exit ;;
- i*:UWIN*:*)
- echo ${UNAME_MACHINE}-pc-uwin
- exit ;;
- amd64:CYGWIN*:*:* | x86_64:CYGWIN*:*:*)
- echo x86_64-unknown-cygwin
- exit ;;
- p*:CYGWIN*:*)
- echo powerpcle-unknown-cygwin
- exit ;;
- prep*:SunOS:5.*:*)
- echo powerpcle-unknown-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
- exit ;;
- *:GNU:*:*)
- # the GNU system
- echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-gnu`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'`
- exit ;;
- *:GNU/*:*:*)
- # other systems with GNU libc and userland
- echo ${UNAME_MACHINE}-unknown-`echo ${UNAME_SYSTEM} | sed 's,^[^/]*/,,' | tr '[A-Z]' '[a-z]'``echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`-gnu
- exit ;;
- i*86:Minix:*:*)
- echo ${UNAME_MACHINE}-pc-minix
- exit ;;
- arm*:Linux:*:*)
- echo ${UNAME_MACHINE}-unknown-linux-gnu
- exit ;;
- cris:Linux:*:*)
- echo cris-axis-linux-gnu
- exit ;;
- crisv32:Linux:*:*)
- echo crisv32-axis-linux-gnu
- exit ;;
- frv:Linux:*:*)
- echo frv-unknown-linux-gnu
- exit ;;
- ia64:Linux:*:*)
- echo ${UNAME_MACHINE}-unknown-linux-gnu
- exit ;;
- m32r*:Linux:*:*)
- echo ${UNAME_MACHINE}-unknown-linux-gnu
- exit ;;
- m68*:Linux:*:*)
- echo ${UNAME_MACHINE}-unknown-linux-gnu
- exit ;;
- mips:Linux:*:*)
- eval $set_cc_for_build
- sed 's/^ //' << EOF >$dummy.c
- #undef CPU
- #undef mips
- #undef mipsel
- #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL)
- CPU=mipsel
- #else
- #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB)
- CPU=mips
- #else
- CPU=
- #endif
- #endif
-EOF
- eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep ^CPU=`
- test x"${CPU}" != x && { echo "${CPU}-unknown-linux-gnu"; exit; }
- ;;
- mips64:Linux:*:*)
- eval $set_cc_for_build
- sed 's/^ //' << EOF >$dummy.c
- #undef CPU
- #undef mips64
- #undef mips64el
- #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL)
- CPU=mips64el
- #else
- #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB)
- CPU=mips64
- #else
- CPU=
- #endif
- #endif
-EOF
- eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep ^CPU=`
- test x"${CPU}" != x && { echo "${CPU}-unknown-linux-gnu"; exit; }
- ;;
- or32:Linux:*:*)
- echo or32-unknown-linux-gnu
- exit ;;
- ppc:Linux:*:*)
- echo powerpc-unknown-linux-gnu
- exit ;;
- ppc64:Linux:*:*)
- echo powerpc64-unknown-linux-gnu
- exit ;;
- alpha:Linux:*:*)
- case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in
- EV5) UNAME_MACHINE=alphaev5 ;;
- EV56) UNAME_MACHINE=alphaev56 ;;
- PCA56) UNAME_MACHINE=alphapca56 ;;
- PCA57) UNAME_MACHINE=alphapca56 ;;
- EV6) UNAME_MACHINE=alphaev6 ;;
- EV67) UNAME_MACHINE=alphaev67 ;;
- EV68*) UNAME_MACHINE=alphaev68 ;;
- esac
- objdump --private-headers /bin/sh | grep ld.so.1 >/dev/null
- if test "$?" = 0 ; then LIBC="libc1" ; else LIBC="" ; fi
- echo ${UNAME_MACHINE}-unknown-linux-gnu${LIBC}
- exit ;;
- parisc:Linux:*:* | hppa:Linux:*:*)
- # Look for CPU level
- case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in
- PA7*) echo hppa1.1-unknown-linux-gnu ;;
- PA8*) echo hppa2.0-unknown-linux-gnu ;;
- *) echo hppa-unknown-linux-gnu ;;
- esac
- exit ;;
- parisc64:Linux:*:* | hppa64:Linux:*:*)
- echo hppa64-unknown-linux-gnu
- exit ;;
- s390:Linux:*:* | s390x:Linux:*:*)
- echo ${UNAME_MACHINE}-ibm-linux
- exit ;;
- sh64*:Linux:*:*)
- echo ${UNAME_MACHINE}-unknown-linux-gnu
- exit ;;
- sh*:Linux:*:*)
- echo ${UNAME_MACHINE}-unknown-linux-gnu
- exit ;;
- sparc:Linux:*:* | sparc64:Linux:*:*)
- echo ${UNAME_MACHINE}-unknown-linux-gnu
- exit ;;
- x86_64:Linux:*:*)
- echo x86_64-unknown-linux-gnu
- exit ;;
- i*86:Linux:*:*)
- # The BFD linker knows what the default object file format is, so
- # first see if it will tell us. cd to the root directory to prevent
- # problems with other programs or directories called `ld' in the path.
- # Set LC_ALL=C to ensure ld outputs messages in English.
- ld_supported_targets=`cd /; LC_ALL=C ld --help 2>&1 \
- | sed -ne '/supported targets:/!d
- s/[ ][ ]*/ /g
- s/.*supported targets: *//
- s/ .*//
- p'`
- case "$ld_supported_targets" in
- elf32-i386)
- TENTATIVE="${UNAME_MACHINE}-pc-linux-gnu"
- ;;
- a.out-i386-linux)
- echo "${UNAME_MACHINE}-pc-linux-gnuaout"
- exit ;;
- coff-i386)
- echo "${UNAME_MACHINE}-pc-linux-gnucoff"
- exit ;;
- "")
- # Either a pre-BFD a.out linker (linux-gnuoldld) or
- # one that does not give us useful --help.
- echo "${UNAME_MACHINE}-pc-linux-gnuoldld"
- exit ;;
- esac
- # Determine whether the default compiler is a.out or elf
- eval $set_cc_for_build
- sed 's/^ //' << EOF >$dummy.c
- #include <features.h>
- #ifdef __ELF__
- # ifdef __GLIBC__
- # if __GLIBC__ >= 2
- LIBC=gnu
- # else
- LIBC=gnulibc1
- # endif
- # else
- LIBC=gnulibc1
- # endif
- #else
- #ifdef __INTEL_COMPILER
- LIBC=gnu
- #else
- LIBC=gnuaout
- #endif
- #endif
- #ifdef __dietlibc__
- LIBC=dietlibc
- #endif
-EOF
- eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep ^LIBC=`
- test x"${LIBC}" != x && {
- echo "${UNAME_MACHINE}-pc-linux-${LIBC}"
- exit
- }
- test x"${TENTATIVE}" != x && { echo "${TENTATIVE}"; exit; }
- ;;
- i*86:DYNIX/ptx:4*:*)
- # ptx 4.0 does uname -s correctly, with DYNIX/ptx in there.
- # earlier versions are messed up and put the nodename in both
- # sysname and nodename.
- echo i386-sequent-sysv4
- exit ;;
- i*86:UNIX_SV:4.2MP:2.*)
- # Unixware is an offshoot of SVR4, but it has its own version
- # number series starting with 2...
- # I am not positive that other SVR4 systems won't match this,
- # I just have to hope. -- rms.
- # Use sysv4.2uw... so that sysv4* matches it.
- echo ${UNAME_MACHINE}-pc-sysv4.2uw${UNAME_VERSION}
- exit ;;
- i*86:OS/2:*:*)
- # If we were able to find `uname', then EMX Unix compatibility
- # is probably installed.
- echo ${UNAME_MACHINE}-pc-os2-emx
- exit ;;
- i*86:XTS-300:*:STOP)
- echo ${UNAME_MACHINE}-unknown-stop
- exit ;;
- i*86:atheos:*:*)
- echo ${UNAME_MACHINE}-unknown-atheos
- exit ;;
- i*86:syllable:*:*)
- echo ${UNAME_MACHINE}-pc-syllable
- exit ;;
- i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.0*:*)
- echo i386-unknown-lynxos${UNAME_RELEASE}
- exit ;;
- i*86:*DOS:*:*)
- echo ${UNAME_MACHINE}-pc-msdosdjgpp
- exit ;;
- i*86:*:4.*:* | i*86:SYSTEM_V:4.*:*)
- UNAME_REL=`echo ${UNAME_RELEASE} | sed 's/\/MP$//'`
- if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then
- echo ${UNAME_MACHINE}-univel-sysv${UNAME_REL}
- else
- echo ${UNAME_MACHINE}-pc-sysv${UNAME_REL}
- fi
- exit ;;
- i*86:*:5:[678]*)
- # UnixWare 7.x, OpenUNIX and OpenServer 6.
- case `/bin/uname -X | grep "^Machine"` in
- *486*) UNAME_MACHINE=i486 ;;
- *Pentium) UNAME_MACHINE=i586 ;;
- *Pent*|*Celeron) UNAME_MACHINE=i686 ;;
- esac
- echo ${UNAME_MACHINE}-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}${UNAME_VERSION}
- exit ;;
- i*86:*:3.2:*)
- if test -f /usr/options/cb.name; then
- UNAME_REL=`sed -n 's/.*Version //p' </usr/options/cb.name`
- echo ${UNAME_MACHINE}-pc-isc$UNAME_REL
- elif /bin/uname -X 2>/dev/null >/dev/null ; then
- UNAME_REL=`(/bin/uname -X|grep Release|sed -e 's/.*= //')`
- (/bin/uname -X|grep i80486 >/dev/null) && UNAME_MACHINE=i486
- (/bin/uname -X|grep '^Machine.*Pentium' >/dev/null) \
- && UNAME_MACHINE=i586
- (/bin/uname -X|grep '^Machine.*Pent *II' >/dev/null) \
- && UNAME_MACHINE=i686
- (/bin/uname -X|grep '^Machine.*Pentium Pro' >/dev/null) \
- && UNAME_MACHINE=i686
- echo ${UNAME_MACHINE}-pc-sco$UNAME_REL
- else
- echo ${UNAME_MACHINE}-pc-sysv32
- fi
- exit ;;
- pc:*:*:*)
- # Left here for compatibility:
- # uname -m prints for DJGPP always 'pc', but it prints nothing about
- # the processor, so we play safe by assuming i386.
- echo i386-pc-msdosdjgpp
- exit ;;
- Intel:Mach:3*:*)
- echo i386-pc-mach3
- exit ;;
- paragon:*:*:*)
- echo i860-intel-osf1
- exit ;;
- i860:*:4.*:*) # i860-SVR4
- if grep Stardent /usr/include/sys/uadmin.h >/dev/null 2>&1 ; then
- echo i860-stardent-sysv${UNAME_RELEASE} # Stardent Vistra i860-SVR4
- else # Add other i860-SVR4 vendors below as they are discovered.
- echo i860-unknown-sysv${UNAME_RELEASE} # Unknown i860-SVR4
- fi
- exit ;;
- mini*:CTIX:SYS*5:*)
- # "miniframe"
- echo m68010-convergent-sysv
- exit ;;
- mc68k:UNIX:SYSTEM5:3.51m)
- echo m68k-convergent-sysv
- exit ;;
- M680?0:D-NIX:5.3:*)
- echo m68k-diab-dnix
- exit ;;
- M68*:*:R3V[5678]*:*)
- test -r /sysV68 && { echo 'm68k-motorola-sysv'; exit; } ;;
- 3[345]??:*:4.0:3.0 | 3[34]??A:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 3[34]??/*:*:4.0:3.0 | 4400:*:4.0:3.0 | 4850:*:4.0:3.0 | SKA40:*:4.0:3.0 | SDS2:*:4.0:3.0 | SHG2:*:4.0:3.0 | S7501*:*:4.0:3.0)
- OS_REL=''
- test -r /etc/.relid \
- && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid`
- /bin/uname -p 2>/dev/null | grep 86 >/dev/null \
- && { echo i486-ncr-sysv4.3${OS_REL}; exit; }
- /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \
- && { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;;
- 3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*)
- /bin/uname -p 2>/dev/null | grep 86 >/dev/null \
- && { echo i486-ncr-sysv4; exit; } ;;
- m68*:LynxOS:2.*:* | m68*:LynxOS:3.0*:*)
- echo m68k-unknown-lynxos${UNAME_RELEASE}
- exit ;;
- mc68030:UNIX_System_V:4.*:*)
- echo m68k-atari-sysv4
- exit ;;
- TSUNAMI:LynxOS:2.*:*)
- echo sparc-unknown-lynxos${UNAME_RELEASE}
- exit ;;
- rs6000:LynxOS:2.*:*)
- echo rs6000-unknown-lynxos${UNAME_RELEASE}
- exit ;;
- PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.0*:*)
- echo powerpc-unknown-lynxos${UNAME_RELEASE}
- exit ;;
- SM[BE]S:UNIX_SV:*:*)
- echo mips-dde-sysv${UNAME_RELEASE}
- exit ;;
- RM*:ReliantUNIX-*:*:*)
- echo mips-sni-sysv4
- exit ;;
- RM*:SINIX-*:*:*)
- echo mips-sni-sysv4
- exit ;;
- *:SINIX-*:*:*)
- if uname -p 2>/dev/null >/dev/null ; then
- UNAME_MACHINE=`(uname -p) 2>/dev/null`
- echo ${UNAME_MACHINE}-sni-sysv4
- else
- echo ns32k-sni-sysv
- fi
- exit ;;
- PENTIUM:*:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort
- # says <Richard.M.Bartel@ccMail.Census.GOV>
- echo i586-unisys-sysv4
- exit ;;
- *:UNIX_System_V:4*:FTX*)
- # From Gerald Hewes <hewes@openmarket.com>.
- # How about differentiating between stratus architectures? -djm
- echo hppa1.1-stratus-sysv4
- exit ;;
- *:*:*:FTX*)
- # From seanf@swdc.stratus.com.
- echo i860-stratus-sysv4
- exit ;;
- i*86:VOS:*:*)
- # From Paul.Green@stratus.com.
- echo ${UNAME_MACHINE}-stratus-vos
- exit ;;
- *:VOS:*:*)
- # From Paul.Green@stratus.com.
- echo hppa1.1-stratus-vos
- exit ;;
- mc68*:A/UX:*:*)
- echo m68k-apple-aux${UNAME_RELEASE}
- exit ;;
- news*:NEWS-OS:6*:*)
- echo mips-sony-newsos6
- exit ;;
- R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*)
- if [ -d /usr/nec ]; then
- echo mips-nec-sysv${UNAME_RELEASE}
- else
- echo mips-unknown-sysv${UNAME_RELEASE}
- fi
- exit ;;
- BeBox:BeOS:*:*) # BeOS running on hardware made by Be, PPC only.
- echo powerpc-be-beos
- exit ;;
- BeMac:BeOS:*:*) # BeOS running on Mac or Mac clone, PPC only.
- echo powerpc-apple-beos
- exit ;;
- BePC:BeOS:*:*) # BeOS running on Intel PC compatible.
- echo i586-pc-beos
- exit ;;
- SX-4:SUPER-UX:*:*)
- echo sx4-nec-superux${UNAME_RELEASE}
- exit ;;
- SX-5:SUPER-UX:*:*)
- echo sx5-nec-superux${UNAME_RELEASE}
- exit ;;
- SX-6:SUPER-UX:*:*)
- echo sx6-nec-superux${UNAME_RELEASE}
- exit ;;
- Power*:Rhapsody:*:*)
- echo powerpc-apple-rhapsody${UNAME_RELEASE}
- exit ;;
- *:Rhapsody:*:*)
- echo ${UNAME_MACHINE}-apple-rhapsody${UNAME_RELEASE}
- exit ;;
- *:Darwin:*:*)
- UNAME_PROCESSOR=`uname -p` || UNAME_PROCESSOR=unknown
- case $UNAME_PROCESSOR in
- *86) UNAME_PROCESSOR=i686 ;;
- unknown) UNAME_PROCESSOR=powerpc ;;
- esac
- echo ${UNAME_PROCESSOR}-apple-darwin${UNAME_RELEASE}
- exit ;;
- *:procnto*:*:* | *:QNX:[0123456789]*:*)
- UNAME_PROCESSOR=`uname -p`
- if test "$UNAME_PROCESSOR" = "x86"; then
- UNAME_PROCESSOR=i386
- UNAME_MACHINE=pc
- fi
- echo ${UNAME_PROCESSOR}-${UNAME_MACHINE}-nto-qnx${UNAME_RELEASE}
- exit ;;
- *:QNX:*:4*)
- echo i386-pc-qnx
- exit ;;
- NSE-?:NONSTOP_KERNEL:*:*)
- echo nse-tandem-nsk${UNAME_RELEASE}
- exit ;;
- NSR-?:NONSTOP_KERNEL:*:*)
- echo nsr-tandem-nsk${UNAME_RELEASE}
- exit ;;
- *:NonStop-UX:*:*)
- echo mips-compaq-nonstopux
- exit ;;
- BS2000:POSIX*:*:*)
- echo bs2000-siemens-sysv
- exit ;;
- DS/*:UNIX_System_V:*:*)
- echo ${UNAME_MACHINE}-${UNAME_SYSTEM}-${UNAME_RELEASE}
- exit ;;
- *:Plan9:*:*)
- # "uname -m" is not consistent, so use $cputype instead. 386
- # is converted to i386 for consistency with other x86
- # operating systems.
- if test "$cputype" = "386"; then
- UNAME_MACHINE=i386
- else
- UNAME_MACHINE="$cputype"
- fi
- echo ${UNAME_MACHINE}-unknown-plan9
- exit ;;
- *:TOPS-10:*:*)
- echo pdp10-unknown-tops10
- exit ;;
- *:TENEX:*:*)
- echo pdp10-unknown-tenex
- exit ;;
- KS10:TOPS-20:*:* | KL10:TOPS-20:*:* | TYPE4:TOPS-20:*:*)
- echo pdp10-dec-tops20
- exit ;;
- XKL-1:TOPS-20:*:* | TYPE5:TOPS-20:*:*)
- echo pdp10-xkl-tops20
- exit ;;
- *:TOPS-20:*:*)
- echo pdp10-unknown-tops20
- exit ;;
- *:ITS:*:*)
- echo pdp10-unknown-its
- exit ;;
- SEI:*:*:SEIUX)
- echo mips-sei-seiux${UNAME_RELEASE}
- exit ;;
- *:DragonFly:*:*)
- echo ${UNAME_MACHINE}-unknown-dragonfly`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`
- exit ;;
- *:*VMS:*:*)
- UNAME_MACHINE=`(uname -p) 2>/dev/null`
- case "${UNAME_MACHINE}" in
- A*) echo alpha-dec-vms ; exit ;;
- I*) echo ia64-dec-vms ; exit ;;
- V*) echo vax-dec-vms ; exit ;;
- esac ;;
- *:XENIX:*:SysV)
- echo i386-pc-xenix
- exit ;;
- i*86:skyos:*:*)
- echo ${UNAME_MACHINE}-pc-skyos`echo ${UNAME_RELEASE}` | sed -e 's/ .*$//'
- exit ;;
-esac
-
-#echo '(No uname command or uname output not recognized.)' 1>&2
-#echo "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" 1>&2
-
-eval $set_cc_for_build
-cat >$dummy.c <<EOF
-#ifdef _SEQUENT_
-# include <sys/types.h>
-# include <sys/utsname.h>
-#endif
-main ()
-{
-#if defined (sony)
-#if defined (MIPSEB)
- /* BFD wants "bsd" instead of "newsos". Perhaps BFD should be changed,
- I don't know.... */
- printf ("mips-sony-bsd\n"); exit (0);
-#else
-#include <sys/param.h>
- printf ("m68k-sony-newsos%s\n",
-#ifdef NEWSOS4
- "4"
-#else
- ""
-#endif
- ); exit (0);
-#endif
-#endif
-
-#if defined (__arm) && defined (__acorn) && defined (__unix)
- printf ("arm-acorn-riscix\n"); exit (0);
-#endif
-
-#if defined (hp300) && !defined (hpux)
- printf ("m68k-hp-bsd\n"); exit (0);
-#endif
-
-#if defined (NeXT)
-#if !defined (__ARCHITECTURE__)
-#define __ARCHITECTURE__ "m68k"
-#endif
- int version;
- version=`(hostinfo | sed -n 's/.*NeXT Mach \([0-9]*\).*/\1/p') 2>/dev/null`;
- if (version < 4)
- printf ("%s-next-nextstep%d\n", __ARCHITECTURE__, version);
- else
- printf ("%s-next-openstep%d\n", __ARCHITECTURE__, version);
- exit (0);
-#endif
-
-#if defined (MULTIMAX) || defined (n16)
-#if defined (UMAXV)
- printf ("ns32k-encore-sysv\n"); exit (0);
-#else
-#if defined (CMU)
- printf ("ns32k-encore-mach\n"); exit (0);
-#else
- printf ("ns32k-encore-bsd\n"); exit (0);
-#endif
-#endif
-#endif
-
-#if defined (__386BSD__)
- printf ("i386-pc-bsd\n"); exit (0);
-#endif
-
-#if defined (sequent)
-#if defined (i386)
- printf ("i386-sequent-dynix\n"); exit (0);
-#endif
-#if defined (ns32000)
- printf ("ns32k-sequent-dynix\n"); exit (0);
-#endif
-#endif
-
-#if defined (_SEQUENT_)
- struct utsname un;
-
- uname(&un);
-
- if (strncmp(un.version, "V2", 2) == 0) {
- printf ("i386-sequent-ptx2\n"); exit (0);
- }
- if (strncmp(un.version, "V1", 2) == 0) { /* XXX is V1 correct? */
- printf ("i386-sequent-ptx1\n"); exit (0);
- }
- printf ("i386-sequent-ptx\n"); exit (0);
-
-#endif
-
-#if defined (vax)
-# if !defined (ultrix)
-# include <sys/param.h>
-# if defined (BSD)
-# if BSD == 43
- printf ("vax-dec-bsd4.3\n"); exit (0);
-# else
-# if BSD == 199006
- printf ("vax-dec-bsd4.3reno\n"); exit (0);
-# else
- printf ("vax-dec-bsd\n"); exit (0);
-# endif
-# endif
-# else
- printf ("vax-dec-bsd\n"); exit (0);
-# endif
-# else
- printf ("vax-dec-ultrix\n"); exit (0);
-# endif
-#endif
-
-#if defined (alliant) && defined (i860)
- printf ("i860-alliant-bsd\n"); exit (0);
-#endif
-
- exit (1);
-}
-EOF
-
-$CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null && SYSTEM_NAME=`$dummy` &&
- { echo "$SYSTEM_NAME"; exit; }
-
-# Apollos put the system type in the environment.
-
-test -d /usr/apollo && { echo ${ISP}-apollo-${SYSTYPE}; exit; }
-
-# Convex versions that predate uname can use getsysinfo(1)
-
-if [ -x /usr/convex/getsysinfo ]
-then
- case `getsysinfo -f cpu_type` in
- c1*)
- echo c1-convex-bsd
- exit ;;
- c2*)
- if getsysinfo -f scalar_acc
- then echo c32-convex-bsd
- else echo c2-convex-bsd
- fi
- exit ;;
- c34*)
- echo c34-convex-bsd
- exit ;;
- c38*)
- echo c38-convex-bsd
- exit ;;
- c4*)
- echo c4-convex-bsd
- exit ;;
- esac
-fi
-
-cat >&2 <<EOF
-$0: unable to guess system type
-
-This script, last modified $timestamp, has failed to recognize
-the operating system you are using. It is advised that you
-download the most up to date version of the config scripts from
-
- http://savannah.gnu.org/cgi-bin/viewcvs/*checkout*/config/config/config.guess
-and
- http://savannah.gnu.org/cgi-bin/viewcvs/*checkout*/config/config/config.sub
-
-If the version you run ($0) is already up to date, please
-send the following data and any information you think might be
-pertinent to <config-patches@gnu.org> in order to provide the needed
-information to handle your system.
-
-config.guess timestamp = $timestamp
-
-uname -m = `(uname -m) 2>/dev/null || echo unknown`
-uname -r = `(uname -r) 2>/dev/null || echo unknown`
-uname -s = `(uname -s) 2>/dev/null || echo unknown`
-uname -v = `(uname -v) 2>/dev/null || echo unknown`
-
-/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null`
-/bin/uname -X = `(/bin/uname -X) 2>/dev/null`
-
-hostinfo = `(hostinfo) 2>/dev/null`
-/bin/universe = `(/bin/universe) 2>/dev/null`
-/usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null`
-/bin/arch = `(/bin/arch) 2>/dev/null`
-/usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null`
-/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null`
-
-UNAME_MACHINE = ${UNAME_MACHINE}
-UNAME_RELEASE = ${UNAME_RELEASE}
-UNAME_SYSTEM = ${UNAME_SYSTEM}
-UNAME_VERSION = ${UNAME_VERSION}
-EOF
-
-exit 1
-
-# Local variables:
-# eval: (add-hook 'write-file-hooks 'time-stamp)
-# time-stamp-start: "timestamp='"
-# time-stamp-format: "%:y-%02m-%02d"
-# time-stamp-end: "'"
-# End:
diff --git a/contrib/ofed/librdmacm/config/config.sub b/contrib/ofed/librdmacm/config/config.sub
deleted file mode 100755
index 1c366df..0000000
--- a/contrib/ofed/librdmacm/config/config.sub
+++ /dev/null
@@ -1,1579 +0,0 @@
-#! /bin/sh
-# Configuration validation subroutine script.
-# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
-# 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
-
-timestamp='2005-07-08'
-
-# This file is (in principle) common to ALL GNU software.
-# The presence of a machine in this file suggests that SOME GNU software
-# can handle that machine. It does not imply ALL GNU software can.
-#
-# This file is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-#
-# This program 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 this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA
-# 02110-1301, USA.
-#
-# As a special exception to the GNU General Public License, if you
-# distribute this file as part of a program that contains a
-# configuration script generated by Autoconf, you may include it under
-# the same distribution terms that you use for the rest of that program.
-
-
-# Please send patches to <config-patches@gnu.org>. Submit a context
-# diff and a properly formatted ChangeLog entry.
-#
-# Configuration subroutine to validate and canonicalize a configuration type.
-# Supply the specified configuration type as an argument.
-# If it is invalid, we print an error message on stderr and exit with code 1.
-# Otherwise, we print the canonical config type on stdout and succeed.
-
-# This file is supposed to be the same for all GNU packages
-# and recognize all the CPU types, system types and aliases
-# that are meaningful with *any* GNU software.
-# Each package is responsible for reporting which valid configurations
-# it does not support. The user should be able to distinguish
-# a failure to support a valid configuration from a meaningless
-# configuration.
-
-# The goal of this file is to map all the various variations of a given
-# machine specification into a single specification in the form:
-# CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM
-# or in some cases, the newer four-part form:
-# CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM
-# It is wrong to echo any other type of specification.
-
-me=`echo "$0" | sed -e 's,.*/,,'`
-
-usage="\
-Usage: $0 [OPTION] CPU-MFR-OPSYS
- $0 [OPTION] ALIAS
-
-Canonicalize a configuration name.
-
-Operation modes:
- -h, --help print this help, then exit
- -t, --time-stamp print date of last modification, then exit
- -v, --version print version number, then exit
-
-Report bugs and patches to <config-patches@gnu.org>."
-
-version="\
-GNU config.sub ($timestamp)
-
-Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005
-Free Software Foundation, Inc.
-
-This is free software; see the source for copying conditions. There is NO
-warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
-
-help="
-Try \`$me --help' for more information."
-
-# Parse command line
-while test $# -gt 0 ; do
- case $1 in
- --time-stamp | --time* | -t )
- echo "$timestamp" ; exit ;;
- --version | -v )
- echo "$version" ; exit ;;
- --help | --h* | -h )
- echo "$usage"; exit ;;
- -- ) # Stop option processing
- shift; break ;;
- - ) # Use stdin as input.
- break ;;
- -* )
- echo "$me: invalid option $1$help"
- exit 1 ;;
-
- *local*)
- # First pass through any local machine types.
- echo $1
- exit ;;
-
- * )
- break ;;
- esac
-done
-
-case $# in
- 0) echo "$me: missing argument$help" >&2
- exit 1;;
- 1) ;;
- *) echo "$me: too many arguments$help" >&2
- exit 1;;
-esac
-
-# Separate what the user gave into CPU-COMPANY and OS or KERNEL-OS (if any).
-# Here we must recognize all the valid KERNEL-OS combinations.
-maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'`
-case $maybe_os in
- nto-qnx* | linux-gnu* | linux-dietlibc | linux-uclibc* | uclinux-uclibc* | uclinux-gnu* | \
- kfreebsd*-gnu* | knetbsd*-gnu* | netbsd*-gnu* | storm-chaos* | os2-emx* | rtmk-nova*)
- os=-$maybe_os
- basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`
- ;;
- *)
- basic_machine=`echo $1 | sed 's/-[^-]*$//'`
- if [ $basic_machine != $1 ]
- then os=`echo $1 | sed 's/.*-/-/'`
- else os=; fi
- ;;
-esac
-
-### Let's recognize common machines as not being operating systems so
-### that things like config.sub decstation-3100 work. We also
-### recognize some manufacturers as not being operating systems, so we
-### can provide default operating systems below.
-case $os in
- -sun*os*)
- # Prevent following clause from handling this invalid input.
- ;;
- -dec* | -mips* | -sequent* | -encore* | -pc532* | -sgi* | -sony* | \
- -att* | -7300* | -3300* | -delta* | -motorola* | -sun[234]* | \
- -unicom* | -ibm* | -next | -hp | -isi* | -apollo | -altos* | \
- -convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\
- -c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \
- -harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \
- -apple | -axis | -knuth | -cray)
- os=
- basic_machine=$1
- ;;
- -sim | -cisco | -oki | -wec | -winbond)
- os=
- basic_machine=$1
- ;;
- -scout)
- ;;
- -wrs)
- os=-vxworks
- basic_machine=$1
- ;;
- -chorusos*)
- os=-chorusos
- basic_machine=$1
- ;;
- -chorusrdb)
- os=-chorusrdb
- basic_machine=$1
- ;;
- -hiux*)
- os=-hiuxwe2
- ;;
- -sco5)
- os=-sco3.2v5
- basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
- ;;
- -sco4)
- os=-sco3.2v4
- basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
- ;;
- -sco3.2.[4-9]*)
- os=`echo $os | sed -e 's/sco3.2./sco3.2v/'`
- basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
- ;;
- -sco3.2v[4-9]*)
- # Don't forget version if it is 3.2v4 or newer.
- basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
- ;;
- -sco*)
- os=-sco3.2v2
- basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
- ;;
- -udk*)
- basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
- ;;
- -isc)
- os=-isc2.2
- basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
- ;;
- -clix*)
- basic_machine=clipper-intergraph
- ;;
- -isc*)
- basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
- ;;
- -lynx*)
- os=-lynxos
- ;;
- -ptx*)
- basic_machine=`echo $1 | sed -e 's/86-.*/86-sequent/'`
- ;;
- -windowsnt*)
- os=`echo $os | sed -e 's/windowsnt/winnt/'`
- ;;
- -psos*)
- os=-psos
- ;;
- -mint | -mint[0-9]*)
- basic_machine=m68k-atari
- os=-mint
- ;;
-esac
-
-# Decode aliases for certain CPU-COMPANY combinations.
-case $basic_machine in
- # Recognize the basic CPU types without company name.
- # Some are omitted here because they have special meanings below.
- 1750a | 580 \
- | a29k \
- | alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \
- | alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | alpha64pca5[67] \
- | am33_2.0 \
- | arc | arm | arm[bl]e | arme[lb] | armv[2345] | armv[345][lb] | avr \
- | bfin \
- | c4x | clipper \
- | d10v | d30v | dlx | dsp16xx \
- | fr30 | frv \
- | h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \
- | i370 | i860 | i960 | ia64 \
- | ip2k | iq2000 \
- | m32r | m32rle | m68000 | m68k | m88k | maxq | mcore \
- | mips | mipsbe | mipseb | mipsel | mipsle \
- | mips16 \
- | mips64 | mips64el \
- | mips64vr | mips64vrel \
- | mips64orion | mips64orionel \
- | mips64vr4100 | mips64vr4100el \
- | mips64vr4300 | mips64vr4300el \
- | mips64vr5000 | mips64vr5000el \
- | mips64vr5900 | mips64vr5900el \
- | mipsisa32 | mipsisa32el \
- | mipsisa32r2 | mipsisa32r2el \
- | mipsisa64 | mipsisa64el \
- | mipsisa64r2 | mipsisa64r2el \
- | mipsisa64sb1 | mipsisa64sb1el \
- | mipsisa64sr71k | mipsisa64sr71kel \
- | mipstx39 | mipstx39el \
- | mn10200 | mn10300 \
- | ms1 \
- | msp430 \
- | ns16k | ns32k \
- | or32 \
- | pdp10 | pdp11 | pj | pjl \
- | powerpc | powerpc64 | powerpc64le | powerpcle | ppcbe \
- | pyramid \
- | sh | sh[1234] | sh[24]a | sh[23]e | sh[34]eb | shbe | shle | sh[1234]le | sh3ele \
- | sh64 | sh64le \
- | sparc | sparc64 | sparc64b | sparc86x | sparclet | sparclite \
- | sparcv8 | sparcv9 | sparcv9b \
- | strongarm \
- | tahoe | thumb | tic4x | tic80 | tron \
- | v850 | v850e \
- | we32k \
- | x86 | xscale | xscalee[bl] | xstormy16 | xtensa \
- | z8k)
- basic_machine=$basic_machine-unknown
- ;;
- m32c)
- basic_machine=$basic_machine-unknown
- ;;
- m6811 | m68hc11 | m6812 | m68hc12)
- # Motorola 68HC11/12.
- basic_machine=$basic_machine-unknown
- os=-none
- ;;
- m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | v70 | w65 | z8k)
- ;;
-
- # We use `pc' rather than `unknown'
- # because (1) that's what they normally are, and
- # (2) the word "unknown" tends to confuse beginning users.
- i*86 | x86_64)
- basic_machine=$basic_machine-pc
- ;;
- # Object if more than one company name word.
- *-*-*)
- echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2
- exit 1
- ;;
- # Recognize the basic CPU types with company name.
- 580-* \
- | a29k-* \
- | alpha-* | alphaev[4-8]-* | alphaev56-* | alphaev6[78]-* \
- | alpha64-* | alpha64ev[4-8]-* | alpha64ev56-* | alpha64ev6[78]-* \
- | alphapca5[67]-* | alpha64pca5[67]-* | arc-* \
- | arm-* | armbe-* | armle-* | armeb-* | armv*-* \
- | avr-* \
- | bfin-* | bs2000-* \
- | c[123]* | c30-* | [cjt]90-* | c4x-* | c54x-* | c55x-* | c6x-* \
- | clipper-* | craynv-* | cydra-* \
- | d10v-* | d30v-* | dlx-* \
- | elxsi-* \
- | f30[01]-* | f700-* | fr30-* | frv-* | fx80-* \
- | h8300-* | h8500-* \
- | hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \
- | i*86-* | i860-* | i960-* | ia64-* \
- | ip2k-* | iq2000-* \
- | m32r-* | m32rle-* \
- | m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \
- | m88110-* | m88k-* | maxq-* | mcore-* \
- | mips-* | mipsbe-* | mipseb-* | mipsel-* | mipsle-* \
- | mips16-* \
- | mips64-* | mips64el-* \
- | mips64vr-* | mips64vrel-* \
- | mips64orion-* | mips64orionel-* \
- | mips64vr4100-* | mips64vr4100el-* \
- | mips64vr4300-* | mips64vr4300el-* \
- | mips64vr5000-* | mips64vr5000el-* \
- | mips64vr5900-* | mips64vr5900el-* \
- | mipsisa32-* | mipsisa32el-* \
- | mipsisa32r2-* | mipsisa32r2el-* \
- | mipsisa64-* | mipsisa64el-* \
- | mipsisa64r2-* | mipsisa64r2el-* \
- | mipsisa64sb1-* | mipsisa64sb1el-* \
- | mipsisa64sr71k-* | mipsisa64sr71kel-* \
- | mipstx39-* | mipstx39el-* \
- | mmix-* \
- | ms1-* \
- | msp430-* \
- | none-* | np1-* | ns16k-* | ns32k-* \
- | orion-* \
- | pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \
- | powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* | ppcbe-* \
- | pyramid-* \
- | romp-* | rs6000-* \
- | sh-* | sh[1234]-* | sh[24]a-* | sh[23]e-* | sh[34]eb-* | shbe-* \
- | shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \
- | sparc-* | sparc64-* | sparc64b-* | sparc86x-* | sparclet-* \
- | sparclite-* \
- | sparcv8-* | sparcv9-* | sparcv9b-* | strongarm-* | sv1-* | sx?-* \
- | tahoe-* | thumb-* \
- | tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* \
- | tron-* \
- | v850-* | v850e-* | vax-* \
- | we32k-* \
- | x86-* | x86_64-* | xps100-* | xscale-* | xscalee[bl]-* \
- | xstormy16-* | xtensa-* \
- | ymp-* \
- | z8k-*)
- ;;
- m32c-*)
- ;;
- # Recognize the various machine names and aliases which stand
- # for a CPU type and a company and sometimes even an OS.
- 386bsd)
- basic_machine=i386-unknown
- os=-bsd
- ;;
- 3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc)
- basic_machine=m68000-att
- ;;
- 3b*)
- basic_machine=we32k-att
- ;;
- a29khif)
- basic_machine=a29k-amd
- os=-udi
- ;;
- abacus)
- basic_machine=abacus-unknown
- ;;
- adobe68k)
- basic_machine=m68010-adobe
- os=-scout
- ;;
- alliant | fx80)
- basic_machine=fx80-alliant
- ;;
- altos | altos3068)
- basic_machine=m68k-altos
- ;;
- am29k)
- basic_machine=a29k-none
- os=-bsd
- ;;
- amd64)
- basic_machine=x86_64-pc
- ;;
- amd64-*)
- basic_machine=x86_64-`echo $basic_machine | sed 's/^[^-]*-//'`
- ;;
- amdahl)
- basic_machine=580-amdahl
- os=-sysv
- ;;
- amiga | amiga-*)
- basic_machine=m68k-unknown
- ;;
- amigaos | amigados)
- basic_machine=m68k-unknown
- os=-amigaos
- ;;
- amigaunix | amix)
- basic_machine=m68k-unknown
- os=-sysv4
- ;;
- apollo68)
- basic_machine=m68k-apollo
- os=-sysv
- ;;
- apollo68bsd)
- basic_machine=m68k-apollo
- os=-bsd
- ;;
- aux)
- basic_machine=m68k-apple
- os=-aux
- ;;
- balance)
- basic_machine=ns32k-sequent
- os=-dynix
- ;;
- c90)
- basic_machine=c90-cray
- os=-unicos
- ;;
- convex-c1)
- basic_machine=c1-convex
- os=-bsd
- ;;
- convex-c2)
- basic_machine=c2-convex
- os=-bsd
- ;;
- convex-c32)
- basic_machine=c32-convex
- os=-bsd
- ;;
- convex-c34)
- basic_machine=c34-convex
- os=-bsd
- ;;
- convex-c38)
- basic_machine=c38-convex
- os=-bsd
- ;;
- cray | j90)
- basic_machine=j90-cray
- os=-unicos
- ;;
- craynv)
- basic_machine=craynv-cray
- os=-unicosmp
- ;;
- cr16c)
- basic_machine=cr16c-unknown
- os=-elf
- ;;
- crds | unos)
- basic_machine=m68k-crds
- ;;
- crisv32 | crisv32-* | etraxfs*)
- basic_machine=crisv32-axis
- ;;
- cris | cris-* | etrax*)
- basic_machine=cris-axis
- ;;
- crx)
- basic_machine=crx-unknown
- os=-elf
- ;;
- da30 | da30-*)
- basic_machine=m68k-da30
- ;;
- decstation | decstation-3100 | pmax | pmax-* | pmin | dec3100 | decstatn)
- basic_machine=mips-dec
- ;;
- decsystem10* | dec10*)
- basic_machine=pdp10-dec
- os=-tops10
- ;;
- decsystem20* | dec20*)
- basic_machine=pdp10-dec
- os=-tops20
- ;;
- delta | 3300 | motorola-3300 | motorola-delta \
- | 3300-motorola | delta-motorola)
- basic_machine=m68k-motorola
- ;;
- delta88)
- basic_machine=m88k-motorola
- os=-sysv3
- ;;
- djgpp)
- basic_machine=i586-pc
- os=-msdosdjgpp
- ;;
- dpx20 | dpx20-*)
- basic_machine=rs6000-bull
- os=-bosx
- ;;
- dpx2* | dpx2*-bull)
- basic_machine=m68k-bull
- os=-sysv3
- ;;
- ebmon29k)
- basic_machine=a29k-amd
- os=-ebmon
- ;;
- elxsi)
- basic_machine=elxsi-elxsi
- os=-bsd
- ;;
- encore | umax | mmax)
- basic_machine=ns32k-encore
- ;;
- es1800 | OSE68k | ose68k | ose | OSE)
- basic_machine=m68k-ericsson
- os=-ose
- ;;
- fx2800)
- basic_machine=i860-alliant
- ;;
- genix)
- basic_machine=ns32k-ns
- ;;
- gmicro)
- basic_machine=tron-gmicro
- os=-sysv
- ;;
- go32)
- basic_machine=i386-pc
- os=-go32
- ;;
- h3050r* | hiux*)
- basic_machine=hppa1.1-hitachi
- os=-hiuxwe2
- ;;
- h8300hms)
- basic_machine=h8300-hitachi
- os=-hms
- ;;
- h8300xray)
- basic_machine=h8300-hitachi
- os=-xray
- ;;
- h8500hms)
- basic_machine=h8500-hitachi
- os=-hms
- ;;
- harris)
- basic_machine=m88k-harris
- os=-sysv3
- ;;
- hp300-*)
- basic_machine=m68k-hp
- ;;
- hp300bsd)
- basic_machine=m68k-hp
- os=-bsd
- ;;
- hp300hpux)
- basic_machine=m68k-hp
- os=-hpux
- ;;
- hp3k9[0-9][0-9] | hp9[0-9][0-9])
- basic_machine=hppa1.0-hp
- ;;
- hp9k2[0-9][0-9] | hp9k31[0-9])
- basic_machine=m68000-hp
- ;;
- hp9k3[2-9][0-9])
- basic_machine=m68k-hp
- ;;
- hp9k6[0-9][0-9] | hp6[0-9][0-9])
- basic_machine=hppa1.0-hp
- ;;
- hp9k7[0-79][0-9] | hp7[0-79][0-9])
- basic_machine=hppa1.1-hp
- ;;
- hp9k78[0-9] | hp78[0-9])
- # FIXME: really hppa2.0-hp
- basic_machine=hppa1.1-hp
- ;;
- hp9k8[67]1 | hp8[67]1 | hp9k80[24] | hp80[24] | hp9k8[78]9 | hp8[78]9 | hp9k893 | hp893)
- # FIXME: really hppa2.0-hp
- basic_machine=hppa1.1-hp
- ;;
- hp9k8[0-9][13679] | hp8[0-9][13679])
- basic_machine=hppa1.1-hp
- ;;
- hp9k8[0-9][0-9] | hp8[0-9][0-9])
- basic_machine=hppa1.0-hp
- ;;
- hppa-next)
- os=-nextstep3
- ;;
- hppaosf)
- basic_machine=hppa1.1-hp
- os=-osf
- ;;
- hppro)
- basic_machine=hppa1.1-hp
- os=-proelf
- ;;
- i370-ibm* | ibm*)
- basic_machine=i370-ibm
- ;;
-# I'm not sure what "Sysv32" means. Should this be sysv3.2?
- i*86v32)
- basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
- os=-sysv32
- ;;
- i*86v4*)
- basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
- os=-sysv4
- ;;
- i*86v)
- basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
- os=-sysv
- ;;
- i*86sol2)
- basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
- os=-solaris2
- ;;
- i386mach)
- basic_machine=i386-mach
- os=-mach
- ;;
- i386-vsta | vsta)
- basic_machine=i386-unknown
- os=-vsta
- ;;
- iris | iris4d)
- basic_machine=mips-sgi
- case $os in
- -irix*)
- ;;
- *)
- os=-irix4
- ;;
- esac
- ;;
- isi68 | isi)
- basic_machine=m68k-isi
- os=-sysv
- ;;
- m88k-omron*)
- basic_machine=m88k-omron
- ;;
- magnum | m3230)
- basic_machine=mips-mips
- os=-sysv
- ;;
- merlin)
- basic_machine=ns32k-utek
- os=-sysv
- ;;
- mingw32)
- basic_machine=i386-pc
- os=-mingw32
- ;;
- miniframe)
- basic_machine=m68000-convergent
- ;;
- *mint | -mint[0-9]* | *MiNT | *MiNT[0-9]*)
- basic_machine=m68k-atari
- os=-mint
- ;;
- mips3*-*)
- basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`
- ;;
- mips3*)
- basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`-unknown
- ;;
- monitor)
- basic_machine=m68k-rom68k
- os=-coff
- ;;
- morphos)
- basic_machine=powerpc-unknown
- os=-morphos
- ;;
- msdos)
- basic_machine=i386-pc
- os=-msdos
- ;;
- mvs)
- basic_machine=i370-ibm
- os=-mvs
- ;;
- ncr3000)
- basic_machine=i486-ncr
- os=-sysv4
- ;;
- netbsd386)
- basic_machine=i386-unknown
- os=-netbsd
- ;;
- netwinder)
- basic_machine=armv4l-rebel
- os=-linux
- ;;
- news | news700 | news800 | news900)
- basic_machine=m68k-sony
- os=-newsos
- ;;
- news1000)
- basic_machine=m68030-sony
- os=-newsos
- ;;
- news-3600 | risc-news)
- basic_machine=mips-sony
- os=-newsos
- ;;
- necv70)
- basic_machine=v70-nec
- os=-sysv
- ;;
- next | m*-next )
- basic_machine=m68k-next
- case $os in
- -nextstep* )
- ;;
- -ns2*)
- os=-nextstep2
- ;;
- *)
- os=-nextstep3
- ;;
- esac
- ;;
- nh3000)
- basic_machine=m68k-harris
- os=-cxux
- ;;
- nh[45]000)
- basic_machine=m88k-harris
- os=-cxux
- ;;
- nindy960)
- basic_machine=i960-intel
- os=-nindy
- ;;
- mon960)
- basic_machine=i960-intel
- os=-mon960
- ;;
- nonstopux)
- basic_machine=mips-compaq
- os=-nonstopux
- ;;
- np1)
- basic_machine=np1-gould
- ;;
- nsr-tandem)
- basic_machine=nsr-tandem
- ;;
- op50n-* | op60c-*)
- basic_machine=hppa1.1-oki
- os=-proelf
- ;;
- openrisc | openrisc-*)
- basic_machine=or32-unknown
- ;;
- os400)
- basic_machine=powerpc-ibm
- os=-os400
- ;;
- OSE68000 | ose68000)
- basic_machine=m68000-ericsson
- os=-ose
- ;;
- os68k)
- basic_machine=m68k-none
- os=-os68k
- ;;
- pa-hitachi)
- basic_machine=hppa1.1-hitachi
- os=-hiuxwe2
- ;;
- paragon)
- basic_machine=i860-intel
- os=-osf
- ;;
- pbd)
- basic_machine=sparc-tti
- ;;
- pbb)
- basic_machine=m68k-tti
- ;;
- pc532 | pc532-*)
- basic_machine=ns32k-pc532
- ;;
- pentium | p5 | k5 | k6 | nexgen | viac3)
- basic_machine=i586-pc
- ;;
- pentiumpro | p6 | 6x86 | athlon | athlon_*)
- basic_machine=i686-pc
- ;;
- pentiumii | pentium2 | pentiumiii | pentium3)
- basic_machine=i686-pc
- ;;
- pentium4)
- basic_machine=i786-pc
- ;;
- pentium-* | p5-* | k5-* | k6-* | nexgen-* | viac3-*)
- basic_machine=i586-`echo $basic_machine | sed 's/^[^-]*-//'`
- ;;
- pentiumpro-* | p6-* | 6x86-* | athlon-*)
- basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'`
- ;;
- pentiumii-* | pentium2-* | pentiumiii-* | pentium3-*)
- basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'`
- ;;
- pentium4-*)
- basic_machine=i786-`echo $basic_machine | sed 's/^[^-]*-//'`
- ;;
- pn)
- basic_machine=pn-gould
- ;;
- power) basic_machine=power-ibm
- ;;
- ppc) basic_machine=powerpc-unknown
- ;;
- ppc-*) basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'`
- ;;
- ppcle | powerpclittle | ppc-le | powerpc-little)
- basic_machine=powerpcle-unknown
- ;;
- ppcle-* | powerpclittle-*)
- basic_machine=powerpcle-`echo $basic_machine | sed 's/^[^-]*-//'`
- ;;
- ppc64) basic_machine=powerpc64-unknown
- ;;
- ppc64-*) basic_machine=powerpc64-`echo $basic_machine | sed 's/^[^-]*-//'`
- ;;
- ppc64le | powerpc64little | ppc64-le | powerpc64-little)
- basic_machine=powerpc64le-unknown
- ;;
- ppc64le-* | powerpc64little-*)
- basic_machine=powerpc64le-`echo $basic_machine | sed 's/^[^-]*-//'`
- ;;
- ps2)
- basic_machine=i386-ibm
- ;;
- pw32)
- basic_machine=i586-unknown
- os=-pw32
- ;;
- rom68k)
- basic_machine=m68k-rom68k
- os=-coff
- ;;
- rm[46]00)
- basic_machine=mips-siemens
- ;;
- rtpc | rtpc-*)
- basic_machine=romp-ibm
- ;;
- s390 | s390-*)
- basic_machine=s390-ibm
- ;;
- s390x | s390x-*)
- basic_machine=s390x-ibm
- ;;
- sa29200)
- basic_machine=a29k-amd
- os=-udi
- ;;
- sb1)
- basic_machine=mipsisa64sb1-unknown
- ;;
- sb1el)
- basic_machine=mipsisa64sb1el-unknown
- ;;
- sei)
- basic_machine=mips-sei
- os=-seiux
- ;;
- sequent)
- basic_machine=i386-sequent
- ;;
- sh)
- basic_machine=sh-hitachi
- os=-hms
- ;;
- sh64)
- basic_machine=sh64-unknown
- ;;
- sparclite-wrs | simso-wrs)
- basic_machine=sparclite-wrs
- os=-vxworks
- ;;
- sps7)
- basic_machine=m68k-bull
- os=-sysv2
- ;;
- spur)
- basic_machine=spur-unknown
- ;;
- st2000)
- basic_machine=m68k-tandem
- ;;
- stratus)
- basic_machine=i860-stratus
- os=-sysv4
- ;;
- sun2)
- basic_machine=m68000-sun
- ;;
- sun2os3)
- basic_machine=m68000-sun
- os=-sunos3
- ;;
- sun2os4)
- basic_machine=m68000-sun
- os=-sunos4
- ;;
- sun3os3)
- basic_machine=m68k-sun
- os=-sunos3
- ;;
- sun3os4)
- basic_machine=m68k-sun
- os=-sunos4
- ;;
- sun4os3)
- basic_machine=sparc-sun
- os=-sunos3
- ;;
- sun4os4)
- basic_machine=sparc-sun
- os=-sunos4
- ;;
- sun4sol2)
- basic_machine=sparc-sun
- os=-solaris2
- ;;
- sun3 | sun3-*)
- basic_machine=m68k-sun
- ;;
- sun4)
- basic_machine=sparc-sun
- ;;
- sun386 | sun386i | roadrunner)
- basic_machine=i386-sun
- ;;
- sv1)
- basic_machine=sv1-cray
- os=-unicos
- ;;
- symmetry)
- basic_machine=i386-sequent
- os=-dynix
- ;;
- t3e)
- basic_machine=alphaev5-cray
- os=-unicos
- ;;
- t90)
- basic_machine=t90-cray
- os=-unicos
- ;;
- tic54x | c54x*)
- basic_machine=tic54x-unknown
- os=-coff
- ;;
- tic55x | c55x*)
- basic_machine=tic55x-unknown
- os=-coff
- ;;
- tic6x | c6x*)
- basic_machine=tic6x-unknown
- os=-coff
- ;;
- tx39)
- basic_machine=mipstx39-unknown
- ;;
- tx39el)
- basic_machine=mipstx39el-unknown
- ;;
- toad1)
- basic_machine=pdp10-xkl
- os=-tops20
- ;;
- tower | tower-32)
- basic_machine=m68k-ncr
- ;;
- tpf)
- basic_machine=s390x-ibm
- os=-tpf
- ;;
- udi29k)
- basic_machine=a29k-amd
- os=-udi
- ;;
- ultra3)
- basic_machine=a29k-nyu
- os=-sym1
- ;;
- v810 | necv810)
- basic_machine=v810-nec
- os=-none
- ;;
- vaxv)
- basic_machine=vax-dec
- os=-sysv
- ;;
- vms)
- basic_machine=vax-dec
- os=-vms
- ;;
- vpp*|vx|vx-*)
- basic_machine=f301-fujitsu
- ;;
- vxworks960)
- basic_machine=i960-wrs
- os=-vxworks
- ;;
- vxworks68)
- basic_machine=m68k-wrs
- os=-vxworks
- ;;
- vxworks29k)
- basic_machine=a29k-wrs
- os=-vxworks
- ;;
- w65*)
- basic_machine=w65-wdc
- os=-none
- ;;
- w89k-*)
- basic_machine=hppa1.1-winbond
- os=-proelf
- ;;
- xbox)
- basic_machine=i686-pc
- os=-mingw32
- ;;
- xps | xps100)
- basic_machine=xps100-honeywell
- ;;
- ymp)
- basic_machine=ymp-cray
- os=-unicos
- ;;
- z8k-*-coff)
- basic_machine=z8k-unknown
- os=-sim
- ;;
- none)
- basic_machine=none-none
- os=-none
- ;;
-
-# Here we handle the default manufacturer of certain CPU types. It is in
-# some cases the only manufacturer, in others, it is the most popular.
- w89k)
- basic_machine=hppa1.1-winbond
- ;;
- op50n)
- basic_machine=hppa1.1-oki
- ;;
- op60c)
- basic_machine=hppa1.1-oki
- ;;
- romp)
- basic_machine=romp-ibm
- ;;
- mmix)
- basic_machine=mmix-knuth
- ;;
- rs6000)
- basic_machine=rs6000-ibm
- ;;
- vax)
- basic_machine=vax-dec
- ;;
- pdp10)
- # there are many clones, so DEC is not a safe bet
- basic_machine=pdp10-unknown
- ;;
- pdp11)
- basic_machine=pdp11-dec
- ;;
- we32k)
- basic_machine=we32k-att
- ;;
- sh[1234] | sh[24]a | sh[34]eb | sh[1234]le | sh[23]ele)
- basic_machine=sh-unknown
- ;;
- sparc | sparcv8 | sparcv9 | sparcv9b)
- basic_machine=sparc-sun
- ;;
- cydra)
- basic_machine=cydra-cydrome
- ;;
- orion)
- basic_machine=orion-highlevel
- ;;
- orion105)
- basic_machine=clipper-highlevel
- ;;
- mac | mpw | mac-mpw)
- basic_machine=m68k-apple
- ;;
- pmac | pmac-mpw)
- basic_machine=powerpc-apple
- ;;
- *-unknown)
- # Make sure to match an already-canonicalized machine name.
- ;;
- *)
- echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2
- exit 1
- ;;
-esac
-
-# Here we canonicalize certain aliases for manufacturers.
-case $basic_machine in
- *-digital*)
- basic_machine=`echo $basic_machine | sed 's/digital.*/dec/'`
- ;;
- *-commodore*)
- basic_machine=`echo $basic_machine | sed 's/commodore.*/cbm/'`
- ;;
- *)
- ;;
-esac
-
-# Decode manufacturer-specific aliases for certain operating systems.
-
-if [ x"$os" != x"" ]
-then
-case $os in
- # First match some system type aliases
- # that might get confused with valid system types.
- # -solaris* is a basic system type, with this one exception.
- -solaris1 | -solaris1.*)
- os=`echo $os | sed -e 's|solaris1|sunos4|'`
- ;;
- -solaris)
- os=-solaris2
- ;;
- -svr4*)
- os=-sysv4
- ;;
- -unixware*)
- os=-sysv4.2uw
- ;;
- -gnu/linux*)
- os=`echo $os | sed -e 's|gnu/linux|linux-gnu|'`
- ;;
- # First accept the basic system types.
- # The portable systems comes first.
- # Each alternative MUST END IN A *, to match a version number.
- # -sysv* is not here because it comes later, after sysvr4.
- -gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \
- | -*vms* | -sco* | -esix* | -isc* | -aix* | -sunos | -sunos[34]*\
- | -hpux* | -unos* | -osf* | -luna* | -dgux* | -solaris* | -sym* \
- | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \
- | -aos* \
- | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \
- | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \
- | -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* | -openbsd* \
- | -ekkobsd* | -kfreebsd* | -freebsd* | -riscix* | -lynxos* \
- | -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \
- | -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \
- | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \
- | -chorusos* | -chorusrdb* \
- | -cygwin* | -pe* | -psos* | -moss* | -proelf* | -rtems* \
- | -mingw32* | -linux-gnu* | -linux-uclibc* | -uxpv* | -beos* | -mpeix* | -udk* \
- | -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \
- | -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \
- | -storm-chaos* | -tops10* | -tenex* | -tops20* | -its* \
- | -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \
- | -morphos* | -superux* | -rtmk* | -rtmk-nova* | -windiss* \
- | -powermax* | -dnix* | -nx6 | -nx7 | -sei* | -dragonfly* \
- | -skyos* | -haiku*)
- # Remember, each alternative MUST END IN *, to match a version number.
- ;;
- -qnx*)
- case $basic_machine in
- x86-* | i*86-*)
- ;;
- *)
- os=-nto$os
- ;;
- esac
- ;;
- -nto-qnx*)
- ;;
- -nto*)
- os=`echo $os | sed -e 's|nto|nto-qnx|'`
- ;;
- -sim | -es1800* | -hms* | -xray | -os68k* | -none* | -v88r* \
- | -windows* | -osx | -abug | -netware* | -os9* | -beos* | -haiku* \
- | -macos* | -mpw* | -magic* | -mmixware* | -mon960* | -lnews*)
- ;;
- -mac*)
- os=`echo $os | sed -e 's|mac|macos|'`
- ;;
- -linux-dietlibc)
- os=-linux-dietlibc
- ;;
- -linux*)
- os=`echo $os | sed -e 's|linux|linux-gnu|'`
- ;;
- -sunos5*)
- os=`echo $os | sed -e 's|sunos5|solaris2|'`
- ;;
- -sunos6*)
- os=`echo $os | sed -e 's|sunos6|solaris3|'`
- ;;
- -opened*)
- os=-openedition
- ;;
- -os400*)
- os=-os400
- ;;
- -wince*)
- os=-wince
- ;;
- -osfrose*)
- os=-osfrose
- ;;
- -osf*)
- os=-osf
- ;;
- -utek*)
- os=-bsd
- ;;
- -dynix*)
- os=-bsd
- ;;
- -acis*)
- os=-aos
- ;;
- -atheos*)
- os=-atheos
- ;;
- -syllable*)
- os=-syllable
- ;;
- -386bsd)
- os=-bsd
- ;;
- -ctix* | -uts*)
- os=-sysv
- ;;
- -nova*)
- os=-rtmk-nova
- ;;
- -ns2 )
- os=-nextstep2
- ;;
- -nsk*)
- os=-nsk
- ;;
- # Preserve the version number of sinix5.
- -sinix5.*)
- os=`echo $os | sed -e 's|sinix|sysv|'`
- ;;
- -sinix*)
- os=-sysv4
- ;;
- -tpf*)
- os=-tpf
- ;;
- -triton*)
- os=-sysv3
- ;;
- -oss*)
- os=-sysv3
- ;;
- -svr4)
- os=-sysv4
- ;;
- -svr3)
- os=-sysv3
- ;;
- -sysvr4)
- os=-sysv4
- ;;
- # This must come after -sysvr4.
- -sysv*)
- ;;
- -ose*)
- os=-ose
- ;;
- -es1800*)
- os=-ose
- ;;
- -xenix)
- os=-xenix
- ;;
- -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*)
- os=-mint
- ;;
- -aros*)
- os=-aros
- ;;
- -kaos*)
- os=-kaos
- ;;
- -zvmoe)
- os=-zvmoe
- ;;
- -none)
- ;;
- *)
- # Get rid of the `-' at the beginning of $os.
- os=`echo $os | sed 's/[^-]*-//'`
- echo Invalid configuration \`$1\': system \`$os\' not recognized 1>&2
- exit 1
- ;;
-esac
-else
-
-# Here we handle the default operating systems that come with various machines.
-# The value should be what the vendor currently ships out the door with their
-# machine or put another way, the most popular os provided with the machine.
-
-# Note that if you're going to try to match "-MANUFACTURER" here (say,
-# "-sun"), then you have to tell the case statement up towards the top
-# that MANUFACTURER isn't an operating system. Otherwise, code above
-# will signal an error saying that MANUFACTURER isn't an operating
-# system, and we'll never get to this point.
-
-case $basic_machine in
- *-acorn)
- os=-riscix1.2
- ;;
- arm*-rebel)
- os=-linux
- ;;
- arm*-semi)
- os=-aout
- ;;
- c4x-* | tic4x-*)
- os=-coff
- ;;
- # This must come before the *-dec entry.
- pdp10-*)
- os=-tops20
- ;;
- pdp11-*)
- os=-none
- ;;
- *-dec | vax-*)
- os=-ultrix4.2
- ;;
- m68*-apollo)
- os=-domain
- ;;
- i386-sun)
- os=-sunos4.0.2
- ;;
- m68000-sun)
- os=-sunos3
- # This also exists in the configure program, but was not the
- # default.
- # os=-sunos4
- ;;
- m68*-cisco)
- os=-aout
- ;;
- mips*-cisco)
- os=-elf
- ;;
- mips*-*)
- os=-elf
- ;;
- or32-*)
- os=-coff
- ;;
- *-tti) # must be before sparc entry or we get the wrong os.
- os=-sysv3
- ;;
- sparc-* | *-sun)
- os=-sunos4.1.1
- ;;
- *-be)
- os=-beos
- ;;
- *-haiku)
- os=-haiku
- ;;
- *-ibm)
- os=-aix
- ;;
- *-knuth)
- os=-mmixware
- ;;
- *-wec)
- os=-proelf
- ;;
- *-winbond)
- os=-proelf
- ;;
- *-oki)
- os=-proelf
- ;;
- *-hp)
- os=-hpux
- ;;
- *-hitachi)
- os=-hiux
- ;;
- i860-* | *-att | *-ncr | *-altos | *-motorola | *-convergent)
- os=-sysv
- ;;
- *-cbm)
- os=-amigaos
- ;;
- *-dg)
- os=-dgux
- ;;
- *-dolphin)
- os=-sysv3
- ;;
- m68k-ccur)
- os=-rtu
- ;;
- m88k-omron*)
- os=-luna
- ;;
- *-next )
- os=-nextstep
- ;;
- *-sequent)
- os=-ptx
- ;;
- *-crds)
- os=-unos
- ;;
- *-ns)
- os=-genix
- ;;
- i370-*)
- os=-mvs
- ;;
- *-next)
- os=-nextstep3
- ;;
- *-gould)
- os=-sysv
- ;;
- *-highlevel)
- os=-bsd
- ;;
- *-encore)
- os=-bsd
- ;;
- *-sgi)
- os=-irix
- ;;
- *-siemens)
- os=-sysv4
- ;;
- *-masscomp)
- os=-rtu
- ;;
- f30[01]-fujitsu | f700-fujitsu)
- os=-uxpv
- ;;
- *-rom68k)
- os=-coff
- ;;
- *-*bug)
- os=-coff
- ;;
- *-apple)
- os=-macos
- ;;
- *-atari*)
- os=-mint
- ;;
- *)
- os=-none
- ;;
-esac
-fi
-
-# Here we handle the case where we know the os, and the CPU type, but not the
-# manufacturer. We pick the logical manufacturer.
-vendor=unknown
-case $basic_machine in
- *-unknown)
- case $os in
- -riscix*)
- vendor=acorn
- ;;
- -sunos*)
- vendor=sun
- ;;
- -aix*)
- vendor=ibm
- ;;
- -beos*)
- vendor=be
- ;;
- -hpux*)
- vendor=hp
- ;;
- -mpeix*)
- vendor=hp
- ;;
- -hiux*)
- vendor=hitachi
- ;;
- -unos*)
- vendor=crds
- ;;
- -dgux*)
- vendor=dg
- ;;
- -luna*)
- vendor=omron
- ;;
- -genix*)
- vendor=ns
- ;;
- -mvs* | -opened*)
- vendor=ibm
- ;;
- -os400*)
- vendor=ibm
- ;;
- -ptx*)
- vendor=sequent
- ;;
- -tpf*)
- vendor=ibm
- ;;
- -vxsim* | -vxworks* | -windiss*)
- vendor=wrs
- ;;
- -aux*)
- vendor=apple
- ;;
- -hms*)
- vendor=hitachi
- ;;
- -mpw* | -macos*)
- vendor=apple
- ;;
- -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*)
- vendor=atari
- ;;
- -vos*)
- vendor=stratus
- ;;
- esac
- basic_machine=`echo $basic_machine | sed "s/unknown/$vendor/"`
- ;;
-esac
-
-echo $basic_machine$os
-exit
-
-# Local variables:
-# eval: (add-hook 'write-file-hooks 'time-stamp)
-# time-stamp-start: "timestamp='"
-# time-stamp-format: "%:y-%02m-%02d"
-# time-stamp-end: "'"
-# End:
diff --git a/contrib/ofed/librdmacm/config/depcomp b/contrib/ofed/librdmacm/config/depcomp
deleted file mode 100755
index 04701da..0000000
--- a/contrib/ofed/librdmacm/config/depcomp
+++ /dev/null
@@ -1,530 +0,0 @@
-#! /bin/sh
-# depcomp - compile a program generating dependencies as side-effects
-
-scriptversion=2005-07-09.11
-
-# Copyright (C) 1999, 2000, 2003, 2004, 2005 Free Software Foundation, Inc.
-
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2, or (at your option)
-# any later version.
-
-# This program 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 this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
-# 02110-1301, USA.
-
-# As a special exception to the GNU General Public License, if you
-# distribute this file as part of a program that contains a
-# configuration script generated by Autoconf, you may include it under
-# the same distribution terms that you use for the rest of that program.
-
-# Originally written by Alexandre Oliva <oliva@dcc.unicamp.br>.
-
-case $1 in
- '')
- echo "$0: No command. Try \`$0 --help' for more information." 1>&2
- exit 1;
- ;;
- -h | --h*)
- cat <<\EOF
-Usage: depcomp [--help] [--version] PROGRAM [ARGS]
-
-Run PROGRAMS ARGS to compile a file, generating dependencies
-as side-effects.
-
-Environment variables:
- depmode Dependency tracking mode.
- source Source file read by `PROGRAMS ARGS'.
- object Object file output by `PROGRAMS ARGS'.
- DEPDIR directory where to store dependencies.
- depfile Dependency file to output.
- tmpdepfile Temporary file to use when outputing dependencies.
- libtool Whether libtool is used (yes/no).
-
-Report bugs to <bug-automake@gnu.org>.
-EOF
- exit $?
- ;;
- -v | --v*)
- echo "depcomp $scriptversion"
- exit $?
- ;;
-esac
-
-if test -z "$depmode" || test -z "$source" || test -z "$object"; then
- echo "depcomp: Variables source, object and depmode must be set" 1>&2
- exit 1
-fi
-
-# Dependencies for sub/bar.o or sub/bar.obj go into sub/.deps/bar.Po.
-depfile=${depfile-`echo "$object" |
- sed 's|[^\\/]*$|'${DEPDIR-.deps}'/&|;s|\.\([^.]*\)$|.P\1|;s|Pobj$|Po|'`}
-tmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`}
-
-rm -f "$tmpdepfile"
-
-# Some modes work just like other modes, but use different flags. We
-# parameterize here, but still list the modes in the big case below,
-# to make depend.m4 easier to write. Note that we *cannot* use a case
-# here, because this file can only contain one case statement.
-if test "$depmode" = hp; then
- # HP compiler uses -M and no extra arg.
- gccflag=-M
- depmode=gcc
-fi
-
-if test "$depmode" = dashXmstdout; then
- # This is just like dashmstdout with a different argument.
- dashmflag=-xM
- depmode=dashmstdout
-fi
-
-case "$depmode" in
-gcc3)
-## gcc 3 implements dependency tracking that does exactly what
-## we want. Yay! Note: for some reason libtool 1.4 doesn't like
-## it if -MD -MP comes after the -MF stuff. Hmm.
- "$@" -MT "$object" -MD -MP -MF "$tmpdepfile"
- stat=$?
- if test $stat -eq 0; then :
- else
- rm -f "$tmpdepfile"
- exit $stat
- fi
- mv "$tmpdepfile" "$depfile"
- ;;
-
-gcc)
-## There are various ways to get dependency output from gcc. Here's
-## why we pick this rather obscure method:
-## - Don't want to use -MD because we'd like the dependencies to end
-## up in a subdir. Having to rename by hand is ugly.
-## (We might end up doing this anyway to support other compilers.)
-## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like
-## -MM, not -M (despite what the docs say).
-## - Using -M directly means running the compiler twice (even worse
-## than renaming).
- if test -z "$gccflag"; then
- gccflag=-MD,
- fi
- "$@" -Wp,"$gccflag$tmpdepfile"
- stat=$?
- if test $stat -eq 0; then :
- else
- rm -f "$tmpdepfile"
- exit $stat
- fi
- rm -f "$depfile"
- echo "$object : \\" > "$depfile"
- alpha=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz
-## The second -e expression handles DOS-style file names with drive letters.
- sed -e 's/^[^:]*: / /' \
- -e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile"
-## This next piece of magic avoids the `deleted header file' problem.
-## The problem is that when a header file which appears in a .P file
-## is deleted, the dependency causes make to die (because there is
-## typically no way to rebuild the header). We avoid this by adding
-## dummy dependencies for each header file. Too bad gcc doesn't do
-## this for us directly.
- tr ' ' '
-' < "$tmpdepfile" |
-## Some versions of gcc put a space before the `:'. On the theory
-## that the space means something, we add a space to the output as
-## well.
-## Some versions of the HPUX 10.20 sed can't process this invocation
-## correctly. Breaking it into two sed invocations is a workaround.
- sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
- rm -f "$tmpdepfile"
- ;;
-
-hp)
- # This case exists only to let depend.m4 do its work. It works by
- # looking at the text of this script. This case will never be run,
- # since it is checked for above.
- exit 1
- ;;
-
-sgi)
- if test "$libtool" = yes; then
- "$@" "-Wp,-MDupdate,$tmpdepfile"
- else
- "$@" -MDupdate "$tmpdepfile"
- fi
- stat=$?
- if test $stat -eq 0; then :
- else
- rm -f "$tmpdepfile"
- exit $stat
- fi
- rm -f "$depfile"
-
- if test -f "$tmpdepfile"; then # yes, the sourcefile depend on other files
- echo "$object : \\" > "$depfile"
-
- # Clip off the initial element (the dependent). Don't try to be
- # clever and replace this with sed code, as IRIX sed won't handle
- # lines with more than a fixed number of characters (4096 in
- # IRIX 6.2 sed, 8192 in IRIX 6.5). We also remove comment lines;
- # the IRIX cc adds comments like `#:fec' to the end of the
- # dependency line.
- tr ' ' '
-' < "$tmpdepfile" \
- | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' | \
- tr '
-' ' ' >> $depfile
- echo >> $depfile
-
- # The second pass generates a dummy entry for each header file.
- tr ' ' '
-' < "$tmpdepfile" \
- | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \
- >> $depfile
- else
- # The sourcefile does not contain any dependencies, so just
- # store a dummy comment line, to avoid errors with the Makefile
- # "include basename.Plo" scheme.
- echo "#dummy" > "$depfile"
- fi
- rm -f "$tmpdepfile"
- ;;
-
-aix)
- # The C for AIX Compiler uses -M and outputs the dependencies
- # in a .u file. In older versions, this file always lives in the
- # current directory. Also, the AIX compiler puts `$object:' at the
- # start of each line; $object doesn't have directory information.
- # Version 6 uses the directory in both cases.
- stripped=`echo "$object" | sed 's/\(.*\)\..*$/\1/'`
- tmpdepfile="$stripped.u"
- if test "$libtool" = yes; then
- "$@" -Wc,-M
- else
- "$@" -M
- fi
- stat=$?
-
- if test -f "$tmpdepfile"; then :
- else
- stripped=`echo "$stripped" | sed 's,^.*/,,'`
- tmpdepfile="$stripped.u"
- fi
-
- if test $stat -eq 0; then :
- else
- rm -f "$tmpdepfile"
- exit $stat
- fi
-
- if test -f "$tmpdepfile"; then
- outname="$stripped.o"
- # Each line is of the form `foo.o: dependent.h'.
- # Do two passes, one to just change these to
- # `$object: dependent.h' and one to simply `dependent.h:'.
- sed -e "s,^$outname:,$object :," < "$tmpdepfile" > "$depfile"
- sed -e "s,^$outname: \(.*\)$,\1:," < "$tmpdepfile" >> "$depfile"
- else
- # The sourcefile does not contain any dependencies, so just
- # store a dummy comment line, to avoid errors with the Makefile
- # "include basename.Plo" scheme.
- echo "#dummy" > "$depfile"
- fi
- rm -f "$tmpdepfile"
- ;;
-
-icc)
- # Intel's C compiler understands `-MD -MF file'. However on
- # icc -MD -MF foo.d -c -o sub/foo.o sub/foo.c
- # ICC 7.0 will fill foo.d with something like
- # foo.o: sub/foo.c
- # foo.o: sub/foo.h
- # which is wrong. We want:
- # sub/foo.o: sub/foo.c
- # sub/foo.o: sub/foo.h
- # sub/foo.c:
- # sub/foo.h:
- # ICC 7.1 will output
- # foo.o: sub/foo.c sub/foo.h
- # and will wrap long lines using \ :
- # foo.o: sub/foo.c ... \
- # sub/foo.h ... \
- # ...
-
- "$@" -MD -MF "$tmpdepfile"
- stat=$?
- if test $stat -eq 0; then :
- else
- rm -f "$tmpdepfile"
- exit $stat
- fi
- rm -f "$depfile"
- # Each line is of the form `foo.o: dependent.h',
- # or `foo.o: dep1.h dep2.h \', or ` dep3.h dep4.h \'.
- # Do two passes, one to just change these to
- # `$object: dependent.h' and one to simply `dependent.h:'.
- sed "s,^[^:]*:,$object :," < "$tmpdepfile" > "$depfile"
- # Some versions of the HPUX 10.20 sed can't process this invocation
- # correctly. Breaking it into two sed invocations is a workaround.
- sed 's,^[^:]*: \(.*\)$,\1,;s/^\\$//;/^$/d;/:$/d' < "$tmpdepfile" |
- sed -e 's/$/ :/' >> "$depfile"
- rm -f "$tmpdepfile"
- ;;
-
-tru64)
- # The Tru64 compiler uses -MD to generate dependencies as a side
- # effect. `cc -MD -o foo.o ...' puts the dependencies into `foo.o.d'.
- # At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put
- # dependencies in `foo.d' instead, so we check for that too.
- # Subdirectories are respected.
- dir=`echo "$object" | sed -e 's|/[^/]*$|/|'`
- test "x$dir" = "x$object" && dir=
- base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'`
-
- if test "$libtool" = yes; then
- # With Tru64 cc, shared objects can also be used to make a
- # static library. This mecanism is used in libtool 1.4 series to
- # handle both shared and static libraries in a single compilation.
- # With libtool 1.4, dependencies were output in $dir.libs/$base.lo.d.
- #
- # With libtool 1.5 this exception was removed, and libtool now
- # generates 2 separate objects for the 2 libraries. These two
- # compilations output dependencies in in $dir.libs/$base.o.d and
- # in $dir$base.o.d. We have to check for both files, because
- # one of the two compilations can be disabled. We should prefer
- # $dir$base.o.d over $dir.libs/$base.o.d because the latter is
- # automatically cleaned when .libs/ is deleted, while ignoring
- # the former would cause a distcleancheck panic.
- tmpdepfile1=$dir.libs/$base.lo.d # libtool 1.4
- tmpdepfile2=$dir$base.o.d # libtool 1.5
- tmpdepfile3=$dir.libs/$base.o.d # libtool 1.5
- tmpdepfile4=$dir.libs/$base.d # Compaq CCC V6.2-504
- "$@" -Wc,-MD
- else
- tmpdepfile1=$dir$base.o.d
- tmpdepfile2=$dir$base.d
- tmpdepfile3=$dir$base.d
- tmpdepfile4=$dir$base.d
- "$@" -MD
- fi
-
- stat=$?
- if test $stat -eq 0; then :
- else
- rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4"
- exit $stat
- fi
-
- for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4"
- do
- test -f "$tmpdepfile" && break
- done
- if test -f "$tmpdepfile"; then
- sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile"
- # That's a tab and a space in the [].
- sed -e 's,^.*\.[a-z]*:[ ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile"
- else
- echo "#dummy" > "$depfile"
- fi
- rm -f "$tmpdepfile"
- ;;
-
-#nosideeffect)
- # This comment above is used by automake to tell side-effect
- # dependency tracking mechanisms from slower ones.
-
-dashmstdout)
- # Important note: in order to support this mode, a compiler *must*
- # always write the preprocessed file to stdout, regardless of -o.
- "$@" || exit $?
-
- # Remove the call to Libtool.
- if test "$libtool" = yes; then
- while test $1 != '--mode=compile'; do
- shift
- done
- shift
- fi
-
- # Remove `-o $object'.
- IFS=" "
- for arg
- do
- case $arg in
- -o)
- shift
- ;;
- $object)
- shift
- ;;
- *)
- set fnord "$@" "$arg"
- shift # fnord
- shift # $arg
- ;;
- esac
- done
-
- test -z "$dashmflag" && dashmflag=-M
- # Require at least two characters before searching for `:'
- # in the target name. This is to cope with DOS-style filenames:
- # a dependency such as `c:/foo/bar' could be seen as target `c' otherwise.
- "$@" $dashmflag |
- sed 's:^[ ]*[^: ][^:][^:]*\:[ ]*:'"$object"'\: :' > "$tmpdepfile"
- rm -f "$depfile"
- cat < "$tmpdepfile" > "$depfile"
- tr ' ' '
-' < "$tmpdepfile" | \
-## Some versions of the HPUX 10.20 sed can't process this invocation
-## correctly. Breaking it into two sed invocations is a workaround.
- sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
- rm -f "$tmpdepfile"
- ;;
-
-dashXmstdout)
- # This case only exists to satisfy depend.m4. It is never actually
- # run, as this mode is specially recognized in the preamble.
- exit 1
- ;;
-
-makedepend)
- "$@" || exit $?
- # Remove any Libtool call
- if test "$libtool" = yes; then
- while test $1 != '--mode=compile'; do
- shift
- done
- shift
- fi
- # X makedepend
- shift
- cleared=no
- for arg in "$@"; do
- case $cleared in
- no)
- set ""; shift
- cleared=yes ;;
- esac
- case "$arg" in
- -D*|-I*)
- set fnord "$@" "$arg"; shift ;;
- # Strip any option that makedepend may not understand. Remove
- # the object too, otherwise makedepend will parse it as a source file.
- -*|$object)
- ;;
- *)
- set fnord "$@" "$arg"; shift ;;
- esac
- done
- obj_suffix="`echo $object | sed 's/^.*\././'`"
- touch "$tmpdepfile"
- ${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@"
- rm -f "$depfile"
- cat < "$tmpdepfile" > "$depfile"
- sed '1,2d' "$tmpdepfile" | tr ' ' '
-' | \
-## Some versions of the HPUX 10.20 sed can't process this invocation
-## correctly. Breaking it into two sed invocations is a workaround.
- sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
- rm -f "$tmpdepfile" "$tmpdepfile".bak
- ;;
-
-cpp)
- # Important note: in order to support this mode, a compiler *must*
- # always write the preprocessed file to stdout.
- "$@" || exit $?
-
- # Remove the call to Libtool.
- if test "$libtool" = yes; then
- while test $1 != '--mode=compile'; do
- shift
- done
- shift
- fi
-
- # Remove `-o $object'.
- IFS=" "
- for arg
- do
- case $arg in
- -o)
- shift
- ;;
- $object)
- shift
- ;;
- *)
- set fnord "$@" "$arg"
- shift # fnord
- shift # $arg
- ;;
- esac
- done
-
- "$@" -E |
- sed -n -e '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \
- -e '/^#line [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' |
- sed '$ s: \\$::' > "$tmpdepfile"
- rm -f "$depfile"
- echo "$object : \\" > "$depfile"
- cat < "$tmpdepfile" >> "$depfile"
- sed < "$tmpdepfile" '/^$/d;s/^ //;s/ \\$//;s/$/ :/' >> "$depfile"
- rm -f "$tmpdepfile"
- ;;
-
-msvisualcpp)
- # Important note: in order to support this mode, a compiler *must*
- # always write the preprocessed file to stdout, regardless of -o,
- # because we must use -o when running libtool.
- "$@" || exit $?
- IFS=" "
- for arg
- do
- case "$arg" in
- "-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI")
- set fnord "$@"
- shift
- shift
- ;;
- *)
- set fnord "$@" "$arg"
- shift
- shift
- ;;
- esac
- done
- "$@" -E |
- sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::echo "`cygpath -u \\"\1\\"`":p' | sort | uniq > "$tmpdepfile"
- rm -f "$depfile"
- echo "$object : \\" > "$depfile"
- . "$tmpdepfile" | sed 's% %\\ %g' | sed -n '/^\(.*\)$/ s:: \1 \\:p' >> "$depfile"
- echo " " >> "$depfile"
- . "$tmpdepfile" | sed 's% %\\ %g' | sed -n '/^\(.*\)$/ s::\1\::p' >> "$depfile"
- rm -f "$tmpdepfile"
- ;;
-
-none)
- exec "$@"
- ;;
-
-*)
- echo "Unknown depmode $depmode" 1>&2
- exit 1
- ;;
-esac
-
-exit 0
-
-# Local Variables:
-# mode: shell-script
-# sh-indentation: 2
-# eval: (add-hook 'write-file-hooks 'time-stamp)
-# time-stamp-start: "scriptversion="
-# time-stamp-format: "%:y-%02m-%02d.%02H"
-# time-stamp-end: "$"
-# End:
diff --git a/contrib/ofed/librdmacm/config/install-sh b/contrib/ofed/librdmacm/config/install-sh
deleted file mode 100755
index 4d4a951..0000000
--- a/contrib/ofed/librdmacm/config/install-sh
+++ /dev/null
@@ -1,323 +0,0 @@
-#!/bin/sh
-# install - install a program, script, or datafile
-
-scriptversion=2005-05-14.22
-
-# This originates from X11R5 (mit/util/scripts/install.sh), which was
-# later released in X11R6 (xc/config/util/install.sh) with the
-# following copyright and license.
-#
-# Copyright (C) 1994 X Consortium
-#
-# Permission is hereby granted, free of charge, to any person obtaining a copy
-# of this software and associated documentation files (the "Software"), to
-# deal in the Software without restriction, including without limitation the
-# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
-# sell copies of the Software, and to permit persons to whom the Software is
-# furnished to do so, subject to the following conditions:
-#
-# The above copyright notice and this permission notice shall be included in
-# all copies or substantial portions of the Software.
-#
-# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-# X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
-# AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNEC-
-# TION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-#
-# Except as contained in this notice, the name of the X Consortium shall not
-# be used in advertising or otherwise to promote the sale, use or other deal-
-# ings in this Software without prior written authorization from the X Consor-
-# tium.
-#
-#
-# FSF changes to this file are in the public domain.
-#
-# Calling this script install-sh is preferred over install.sh, to prevent
-# `make' implicit rules from creating a file called install from it
-# when there is no Makefile.
-#
-# This script is compatible with the BSD install script, but was written
-# from scratch. It can only install one file at a time, a restriction
-# shared with many OS's install programs.
-
-# set DOITPROG to echo to test this script
-
-# Don't use :- since 4.3BSD and earlier shells don't like it.
-doit="${DOITPROG-}"
-
-# put in absolute paths if you don't have them in your path; or use env. vars.
-
-mvprog="${MVPROG-mv}"
-cpprog="${CPPROG-cp}"
-chmodprog="${CHMODPROG-chmod}"
-chownprog="${CHOWNPROG-chown}"
-chgrpprog="${CHGRPPROG-chgrp}"
-stripprog="${STRIPPROG-strip}"
-rmprog="${RMPROG-rm}"
-mkdirprog="${MKDIRPROG-mkdir}"
-
-chmodcmd="$chmodprog 0755"
-chowncmd=
-chgrpcmd=
-stripcmd=
-rmcmd="$rmprog -f"
-mvcmd="$mvprog"
-src=
-dst=
-dir_arg=
-dstarg=
-no_target_directory=
-
-usage="Usage: $0 [OPTION]... [-T] SRCFILE DSTFILE
- or: $0 [OPTION]... SRCFILES... DIRECTORY
- or: $0 [OPTION]... -t DIRECTORY SRCFILES...
- or: $0 [OPTION]... -d DIRECTORIES...
-
-In the 1st form, copy SRCFILE to DSTFILE.
-In the 2nd and 3rd, copy all SRCFILES to DIRECTORY.
-In the 4th, create DIRECTORIES.
-
-Options:
--c (ignored)
--d create directories instead of installing files.
--g GROUP $chgrpprog installed files to GROUP.
--m MODE $chmodprog installed files to MODE.
--o USER $chownprog installed files to USER.
--s $stripprog installed files.
--t DIRECTORY install into DIRECTORY.
--T report an error if DSTFILE is a directory.
---help display this help and exit.
---version display version info and exit.
-
-Environment variables override the default commands:
- CHGRPPROG CHMODPROG CHOWNPROG CPPROG MKDIRPROG MVPROG RMPROG STRIPPROG
-"
-
-while test -n "$1"; do
- case $1 in
- -c) shift
- continue;;
-
- -d) dir_arg=true
- shift
- continue;;
-
- -g) chgrpcmd="$chgrpprog $2"
- shift
- shift
- continue;;
-
- --help) echo "$usage"; exit $?;;
-
- -m) chmodcmd="$chmodprog $2"
- shift
- shift
- continue;;
-
- -o) chowncmd="$chownprog $2"
- shift
- shift
- continue;;
-
- -s) stripcmd=$stripprog
- shift
- continue;;
-
- -t) dstarg=$2
- shift
- shift
- continue;;
-
- -T) no_target_directory=true
- shift
- continue;;
-
- --version) echo "$0 $scriptversion"; exit $?;;
-
- *) # When -d is used, all remaining arguments are directories to create.
- # When -t is used, the destination is already specified.
- test -n "$dir_arg$dstarg" && break
- # Otherwise, the last argument is the destination. Remove it from $@.
- for arg
- do
- if test -n "$dstarg"; then
- # $@ is not empty: it contains at least $arg.
- set fnord "$@" "$dstarg"
- shift # fnord
- fi
- shift # arg
- dstarg=$arg
- done
- break;;
- esac
-done
-
-if test -z "$1"; then
- if test -z "$dir_arg"; then
- echo "$0: no input file specified." >&2
- exit 1
- fi
- # It's OK to call `install-sh -d' without argument.
- # This can happen when creating conditional directories.
- exit 0
-fi
-
-for src
-do
- # Protect names starting with `-'.
- case $src in
- -*) src=./$src ;;
- esac
-
- if test -n "$dir_arg"; then
- dst=$src
- src=
-
- if test -d "$dst"; then
- mkdircmd=:
- chmodcmd=
- else
- mkdircmd=$mkdirprog
- fi
- else
- # Waiting for this to be detected by the "$cpprog $src $dsttmp" command
- # might cause directories to be created, which would be especially bad
- # if $src (and thus $dsttmp) contains '*'.
- if test ! -f "$src" && test ! -d "$src"; then
- echo "$0: $src does not exist." >&2
- exit 1
- fi
-
- if test -z "$dstarg"; then
- echo "$0: no destination specified." >&2
- exit 1
- fi
-
- dst=$dstarg
- # Protect names starting with `-'.
- case $dst in
- -*) dst=./$dst ;;
- esac
-
- # If destination is a directory, append the input filename; won't work
- # if double slashes aren't ignored.
- if test -d "$dst"; then
- if test -n "$no_target_directory"; then
- echo "$0: $dstarg: Is a directory" >&2
- exit 1
- fi
- dst=$dst/`basename "$src"`
- fi
- fi
-
- # This sed command emulates the dirname command.
- dstdir=`echo "$dst" | sed -e 's,/*$,,;s,[^/]*$,,;s,/*$,,;s,^$,.,'`
-
- # Make sure that the destination directory exists.
-
- # Skip lots of stat calls in the usual case.
- if test ! -d "$dstdir"; then
- defaultIFS='
- '
- IFS="${IFS-$defaultIFS}"
-
- oIFS=$IFS
- # Some sh's can't handle IFS=/ for some reason.
- IFS='%'
- set x `echo "$dstdir" | sed -e 's@/@%@g' -e 's@^%@/@'`
- shift
- IFS=$oIFS
-
- pathcomp=
-
- while test $# -ne 0 ; do
- pathcomp=$pathcomp$1
- shift
- if test ! -d "$pathcomp"; then
- $mkdirprog "$pathcomp"
- # mkdir can fail with a `File exist' error in case several
- # install-sh are creating the directory concurrently. This
- # is OK.
- test -d "$pathcomp" || exit
- fi
- pathcomp=$pathcomp/
- done
- fi
-
- if test -n "$dir_arg"; then
- $doit $mkdircmd "$dst" \
- && { test -z "$chowncmd" || $doit $chowncmd "$dst"; } \
- && { test -z "$chgrpcmd" || $doit $chgrpcmd "$dst"; } \
- && { test -z "$stripcmd" || $doit $stripcmd "$dst"; } \
- && { test -z "$chmodcmd" || $doit $chmodcmd "$dst"; }
-
- else
- dstfile=`basename "$dst"`
-
- # Make a couple of temp file names in the proper directory.
- dsttmp=$dstdir/_inst.$$_
- rmtmp=$dstdir/_rm.$$_
-
- # Trap to clean up those temp files at exit.
- trap 'ret=$?; rm -f "$dsttmp" "$rmtmp" && exit $ret' 0
- trap '(exit $?); exit' 1 2 13 15
-
- # Copy the file name to the temp name.
- $doit $cpprog "$src" "$dsttmp" &&
-
- # and set any options; do chmod last to preserve setuid bits.
- #
- # If any of these fail, we abort the whole thing. If we want to
- # ignore errors from any of these, just make sure not to ignore
- # errors from the above "$doit $cpprog $src $dsttmp" command.
- #
- { test -z "$chowncmd" || $doit $chowncmd "$dsttmp"; } \
- && { test -z "$chgrpcmd" || $doit $chgrpcmd "$dsttmp"; } \
- && { test -z "$stripcmd" || $doit $stripcmd "$dsttmp"; } \
- && { test -z "$chmodcmd" || $doit $chmodcmd "$dsttmp"; } &&
-
- # Now rename the file to the real destination.
- { $doit $mvcmd -f "$dsttmp" "$dstdir/$dstfile" 2>/dev/null \
- || {
- # The rename failed, perhaps because mv can't rename something else
- # to itself, or perhaps because mv is so ancient that it does not
- # support -f.
-
- # Now remove or move aside any old file at destination location.
- # We try this two ways since rm can't unlink itself on some
- # systems and the destination file might be busy for other
- # reasons. In this case, the final cleanup might fail but the new
- # file should still install successfully.
- {
- if test -f "$dstdir/$dstfile"; then
- $doit $rmcmd -f "$dstdir/$dstfile" 2>/dev/null \
- || $doit $mvcmd -f "$dstdir/$dstfile" "$rmtmp" 2>/dev/null \
- || {
- echo "$0: cannot unlink or rename $dstdir/$dstfile" >&2
- (exit 1); exit 1
- }
- else
- :
- fi
- } &&
-
- # Now rename the file to the real destination.
- $doit $mvcmd "$dsttmp" "$dstdir/$dstfile"
- }
- }
- fi || { (exit 1); exit 1; }
-done
-
-# The final little trick to "correctly" pass the exit status to the exit trap.
-{
- (exit 0); exit 0
-}
-
-# Local variables:
-# eval: (add-hook 'write-file-hooks 'time-stamp)
-# time-stamp-start: "scriptversion="
-# time-stamp-format: "%:y-%02m-%02d.%02H"
-# time-stamp-end: "$"
-# End:
diff --git a/contrib/ofed/librdmacm/config/ltmain.sh b/contrib/ofed/librdmacm/config/ltmain.sh
deleted file mode 100644
index 8fc56db..0000000
--- a/contrib/ofed/librdmacm/config/ltmain.sh
+++ /dev/null
@@ -1,6871 +0,0 @@
-# ltmain.sh - Provide generalized library-building support services.
-# NOTE: Changing this file will not affect anything until you rerun configure.
-#
-# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005
-# Free Software Foundation, Inc.
-# Originally by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-#
-# This program 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 this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-#
-# As a special exception to the GNU General Public License, if you
-# distribute this file as part of a program that contains a
-# configuration script generated by Autoconf, you may include it under
-# the same distribution terms that you use for the rest of that program.
-
-basename="s,^.*/,,g"
-
-# Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh
-# is ksh but when the shell is invoked as "sh" and the current value of
-# the _XPG environment variable is not equal to 1 (one), the special
-# positional parameter $0, within a function call, is the name of the
-# function.
-progpath="$0"
-
-# The name of this program:
-progname=`echo "$progpath" | $SED $basename`
-modename="$progname"
-
-# Global variables:
-EXIT_SUCCESS=0
-EXIT_FAILURE=1
-
-PROGRAM=ltmain.sh
-PACKAGE=libtool
-VERSION="1.5.22 Debian 1.5.22-2"
-TIMESTAMP=" (1.1220.2.365 2005/12/18 22:14:06)"
-
-# See if we are running on zsh, and set the options which allow our
-# commands through without removal of \ escapes.
-if test -n "${ZSH_VERSION+set}" ; then
- setopt NO_GLOB_SUBST
-fi
-
-# Check that we have a working $echo.
-if test "X$1" = X--no-reexec; then
- # Discard the --no-reexec flag, and continue.
- shift
-elif test "X$1" = X--fallback-echo; then
- # Avoid inline document here, it may be left over
- :
-elif test "X`($echo '\t') 2>/dev/null`" = 'X\t'; then
- # Yippee, $echo works!
- :
-else
- # Restart under the correct shell, and then maybe $echo will work.
- exec $SHELL "$progpath" --no-reexec ${1+"$@"}
-fi
-
-if test "X$1" = X--fallback-echo; then
- # used as fallback echo
- shift
- cat <<EOF
-$*
-EOF
- exit $EXIT_SUCCESS
-fi
-
-default_mode=
-help="Try \`$progname --help' for more information."
-magic="%%%MAGIC variable%%%"
-mkdir="mkdir"
-mv="mv -f"
-rm="rm -f"
-
-# Sed substitution that helps us do robust quoting. It backslashifies
-# metacharacters that are still active within double-quoted strings.
-Xsed="${SED}"' -e 1s/^X//'
-sed_quote_subst='s/\([\\`\\"$\\\\]\)/\\\1/g'
-# test EBCDIC or ASCII
-case `echo X|tr X '\101'` in
- A) # ASCII based system
- # \n is not interpreted correctly by Solaris 8 /usr/ucb/tr
- SP2NL='tr \040 \012'
- NL2SP='tr \015\012 \040\040'
- ;;
- *) # EBCDIC based system
- SP2NL='tr \100 \n'
- NL2SP='tr \r\n \100\100'
- ;;
-esac
-
-# NLS nuisances.
-# Only set LANG and LC_ALL to C if already set.
-# These must not be set unconditionally because not all systems understand
-# e.g. LANG=C (notably SCO).
-# We save the old values to restore during execute mode.
-if test "${LC_ALL+set}" = set; then
- save_LC_ALL="$LC_ALL"; LC_ALL=C; export LC_ALL
-fi
-if test "${LANG+set}" = set; then
- save_LANG="$LANG"; LANG=C; export LANG
-fi
-
-# Make sure IFS has a sensible default
-lt_nl='
-'
-IFS=" $lt_nl"
-
-if test "$build_libtool_libs" != yes && test "$build_old_libs" != yes; then
- $echo "$modename: not configured to build any kind of library" 1>&2
- $echo "Fatal configuration error. See the $PACKAGE docs for more information." 1>&2
- exit $EXIT_FAILURE
-fi
-
-# Global variables.
-mode=$default_mode
-nonopt=
-prev=
-prevopt=
-run=
-show="$echo"
-show_help=
-execute_dlfiles=
-duplicate_deps=no
-preserve_args=
-lo2o="s/\\.lo\$/.${objext}/"
-o2lo="s/\\.${objext}\$/.lo/"
-
-#####################################
-# Shell function definitions:
-# This seems to be the best place for them
-
-# func_mktempdir [string]
-# Make a temporary directory that won't clash with other running
-# libtool processes, and avoids race conditions if possible. If
-# given, STRING is the basename for that directory.
-func_mktempdir ()
-{
- my_template="${TMPDIR-/tmp}/${1-$progname}"
-
- if test "$run" = ":"; then
- # Return a directory name, but don't create it in dry-run mode
- my_tmpdir="${my_template}-$$"
- else
-
- # If mktemp works, use that first and foremost
- my_tmpdir=`mktemp -d "${my_template}-XXXXXXXX" 2>/dev/null`
-
- if test ! -d "$my_tmpdir"; then
- # Failing that, at least try and use $RANDOM to avoid a race
- my_tmpdir="${my_template}-${RANDOM-0}$$"
-
- save_mktempdir_umask=`umask`
- umask 0077
- $mkdir "$my_tmpdir"
- umask $save_mktempdir_umask
- fi
-
- # If we're not in dry-run mode, bomb out on failure
- test -d "$my_tmpdir" || {
- $echo "cannot create temporary directory \`$my_tmpdir'" 1>&2
- exit $EXIT_FAILURE
- }
- fi
-
- $echo "X$my_tmpdir" | $Xsed
-}
-
-
-# func_win32_libid arg
-# return the library type of file 'arg'
-#
-# Need a lot of goo to handle *both* DLLs and import libs
-# Has to be a shell function in order to 'eat' the argument
-# that is supplied when $file_magic_command is called.
-func_win32_libid ()
-{
- win32_libid_type="unknown"
- win32_fileres=`file -L $1 2>/dev/null`
- case $win32_fileres in
- *ar\ archive\ import\ library*) # definitely import
- win32_libid_type="x86 archive import"
- ;;
- *ar\ archive*) # could be an import, or static
- if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null | \
- $EGREP -e 'file format pe-i386(.*architecture: i386)?' >/dev/null ; then
- win32_nmres=`eval $NM -f posix -A $1 | \
- $SED -n -e '1,100{/ I /{s,.*,import,;p;q;};}'`
- case $win32_nmres in
- import*) win32_libid_type="x86 archive import";;
- *) win32_libid_type="x86 archive static";;
- esac
- fi
- ;;
- *DLL*)
- win32_libid_type="x86 DLL"
- ;;
- *executable*) # but shell scripts are "executable" too...
- case $win32_fileres in
- *MS\ Windows\ PE\ Intel*)
- win32_libid_type="x86 DLL"
- ;;
- esac
- ;;
- esac
- $echo $win32_libid_type
-}
-
-
-# func_infer_tag arg
-# Infer tagged configuration to use if any are available and
-# if one wasn't chosen via the "--tag" command line option.
-# Only attempt this if the compiler in the base compile
-# command doesn't match the default compiler.
-# arg is usually of the form 'gcc ...'
-func_infer_tag ()
-{
- if test -n "$available_tags" && test -z "$tagname"; then
- CC_quoted=
- for arg in $CC; do
- case $arg in
- *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"")
- arg="\"$arg\""
- ;;
- esac
- CC_quoted="$CC_quoted $arg"
- done
- case $@ in
- # Blanks in the command may have been stripped by the calling shell,
- # but not from the CC environment variable when configure was run.
- " $CC "* | "$CC "* | " `$echo $CC` "* | "`$echo $CC` "* | " $CC_quoted"* | "$CC_quoted "* | " `$echo $CC_quoted` "* | "`$echo $CC_quoted` "*) ;;
- # Blanks at the start of $base_compile will cause this to fail
- # if we don't check for them as well.
- *)
- for z in $available_tags; do
- if grep "^# ### BEGIN LIBTOOL TAG CONFIG: $z$" < "$progpath" > /dev/null; then
- # Evaluate the configuration.
- eval "`${SED} -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $progpath`"
- CC_quoted=
- for arg in $CC; do
- # Double-quote args containing other shell metacharacters.
- case $arg in
- *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"")
- arg="\"$arg\""
- ;;
- esac
- CC_quoted="$CC_quoted $arg"
- done
- case "$@ " in
- " $CC "* | "$CC "* | " `$echo $CC` "* | "`$echo $CC` "* | " $CC_quoted"* | "$CC_quoted "* | " `$echo $CC_quoted` "* | "`$echo $CC_quoted` "*)
- # The compiler in the base compile command matches
- # the one in the tagged configuration.
- # Assume this is the tagged configuration we want.
- tagname=$z
- break
- ;;
- esac
- fi
- done
- # If $tagname still isn't set, then no tagged configuration
- # was found and let the user know that the "--tag" command
- # line option must be used.
- if test -z "$tagname"; then
- $echo "$modename: unable to infer tagged configuration"
- $echo "$modename: specify a tag with \`--tag'" 1>&2
- exit $EXIT_FAILURE
-# else
-# $echo "$modename: using $tagname tagged configuration"
- fi
- ;;
- esac
- fi
-}
-
-
-# func_extract_an_archive dir oldlib
-func_extract_an_archive ()
-{
- f_ex_an_ar_dir="$1"; shift
- f_ex_an_ar_oldlib="$1"
-
- $show "(cd $f_ex_an_ar_dir && $AR x $f_ex_an_ar_oldlib)"
- $run eval "(cd \$f_ex_an_ar_dir && $AR x \$f_ex_an_ar_oldlib)" || exit $?
- if ($AR t "$f_ex_an_ar_oldlib" | sort | sort -uc >/dev/null 2>&1); then
- :
- else
- $echo "$modename: ERROR: object name conflicts: $f_ex_an_ar_dir/$f_ex_an_ar_oldlib" 1>&2
- exit $EXIT_FAILURE
- fi
-}
-
-# func_extract_archives gentop oldlib ...
-func_extract_archives ()
-{
- my_gentop="$1"; shift
- my_oldlibs=${1+"$@"}
- my_oldobjs=""
- my_xlib=""
- my_xabs=""
- my_xdir=""
- my_status=""
-
- $show "${rm}r $my_gentop"
- $run ${rm}r "$my_gentop"
- $show "$mkdir $my_gentop"
- $run $mkdir "$my_gentop"
- my_status=$?
- if test "$my_status" -ne 0 && test ! -d "$my_gentop"; then
- exit $my_status
- fi
-
- for my_xlib in $my_oldlibs; do
- # Extract the objects.
- case $my_xlib in
- [\\/]* | [A-Za-z]:[\\/]*) my_xabs="$my_xlib" ;;
- *) my_xabs=`pwd`"/$my_xlib" ;;
- esac
- my_xlib=`$echo "X$my_xlib" | $Xsed -e 's%^.*/%%'`
- my_xdir="$my_gentop/$my_xlib"
-
- $show "${rm}r $my_xdir"
- $run ${rm}r "$my_xdir"
- $show "$mkdir $my_xdir"
- $run $mkdir "$my_xdir"
- exit_status=$?
- if test "$exit_status" -ne 0 && test ! -d "$my_xdir"; then
- exit $exit_status
- fi
- case $host in
- *-darwin*)
- $show "Extracting $my_xabs"
- # Do not bother doing anything if just a dry run
- if test -z "$run"; then
- darwin_orig_dir=`pwd`
- cd $my_xdir || exit $?
- darwin_archive=$my_xabs
- darwin_curdir=`pwd`
- darwin_base_archive=`$echo "X$darwin_archive" | $Xsed -e 's%^.*/%%'`
- darwin_arches=`lipo -info "$darwin_archive" 2>/dev/null | $EGREP Architectures 2>/dev/null`
- if test -n "$darwin_arches"; then
- darwin_arches=`echo "$darwin_arches" | $SED -e 's/.*are://'`
- darwin_arch=
- $show "$darwin_base_archive has multiple architectures $darwin_arches"
- for darwin_arch in $darwin_arches ; do
- mkdir -p "unfat-$$/${darwin_base_archive}-${darwin_arch}"
- lipo -thin $darwin_arch -output "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}" "${darwin_archive}"
- cd "unfat-$$/${darwin_base_archive}-${darwin_arch}"
- func_extract_an_archive "`pwd`" "${darwin_base_archive}"
- cd "$darwin_curdir"
- $rm "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}"
- done # $darwin_arches
- ## Okay now we have a bunch of thin objects, gotta fatten them up :)
- darwin_filelist=`find unfat-$$ -type f -name \*.o -print -o -name \*.lo -print| xargs basename | sort -u | $NL2SP`
- darwin_file=
- darwin_files=
- for darwin_file in $darwin_filelist; do
- darwin_files=`find unfat-$$ -name $darwin_file -print | $NL2SP`
- lipo -create -output "$darwin_file" $darwin_files
- done # $darwin_filelist
- ${rm}r unfat-$$
- cd "$darwin_orig_dir"
- else
- cd "$darwin_orig_dir"
- func_extract_an_archive "$my_xdir" "$my_xabs"
- fi # $darwin_arches
- fi # $run
- ;;
- *)
- func_extract_an_archive "$my_xdir" "$my_xabs"
- ;;
- esac
- my_oldobjs="$my_oldobjs "`find $my_xdir -name \*.$objext -print -o -name \*.lo -print | $NL2SP`
- done
- func_extract_archives_result="$my_oldobjs"
-}
-# End of Shell function definitions
-#####################################
-
-# Darwin sucks
-eval std_shrext=\"$shrext_cmds\"
-
-disable_libs=no
-
-# Parse our command line options once, thoroughly.
-while test "$#" -gt 0
-do
- arg="$1"
- shift
-
- case $arg in
- -*=*) optarg=`$echo "X$arg" | $Xsed -e 's/[-_a-zA-Z0-9]*=//'` ;;
- *) optarg= ;;
- esac
-
- # If the previous option needs an argument, assign it.
- if test -n "$prev"; then
- case $prev in
- execute_dlfiles)
- execute_dlfiles="$execute_dlfiles $arg"
- ;;
- tag)
- tagname="$arg"
- preserve_args="${preserve_args}=$arg"
-
- # Check whether tagname contains only valid characters
- case $tagname in
- *[!-_A-Za-z0-9,/]*)
- $echo "$progname: invalid tag name: $tagname" 1>&2
- exit $EXIT_FAILURE
- ;;
- esac
-
- case $tagname in
- CC)
- # Don't test for the "default" C tag, as we know, it's there, but
- # not specially marked.
- ;;
- *)
- if grep "^# ### BEGIN LIBTOOL TAG CONFIG: $tagname$" < "$progpath" > /dev/null; then
- taglist="$taglist $tagname"
- # Evaluate the configuration.
- eval "`${SED} -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$tagname'$/,/^# ### END LIBTOOL TAG CONFIG: '$tagname'$/p' < $progpath`"
- else
- $echo "$progname: ignoring unknown tag $tagname" 1>&2
- fi
- ;;
- esac
- ;;
- *)
- eval "$prev=\$arg"
- ;;
- esac
-
- prev=
- prevopt=
- continue
- fi
-
- # Have we seen a non-optional argument yet?
- case $arg in
- --help)
- show_help=yes
- ;;
-
- --version)
- $echo "$PROGRAM (GNU $PACKAGE) $VERSION$TIMESTAMP"
- $echo
- $echo "Copyright (C) 2005 Free Software Foundation, Inc."
- $echo "This is free software; see the source for copying conditions. There is NO"
- $echo "warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
- exit $?
- ;;
-
- --config)
- ${SED} -e '1,/^# ### BEGIN LIBTOOL CONFIG/d' -e '/^# ### END LIBTOOL CONFIG/,$d' $progpath
- # Now print the configurations for the tags.
- for tagname in $taglist; do
- ${SED} -n -e "/^# ### BEGIN LIBTOOL TAG CONFIG: $tagname$/,/^# ### END LIBTOOL TAG CONFIG: $tagname$/p" < "$progpath"
- done
- exit $?
- ;;
-
- --debug)
- $echo "$progname: enabling shell trace mode"
- set -x
- preserve_args="$preserve_args $arg"
- ;;
-
- --dry-run | -n)
- run=:
- ;;
-
- --features)
- $echo "host: $host"
- if test "$build_libtool_libs" = yes; then
- $echo "enable shared libraries"
- else
- $echo "disable shared libraries"
- fi
- if test "$build_old_libs" = yes; then
- $echo "enable static libraries"
- else
- $echo "disable static libraries"
- fi
- exit $?
- ;;
-
- --finish) mode="finish" ;;
-
- --mode) prevopt="--mode" prev=mode ;;
- --mode=*) mode="$optarg" ;;
-
- --preserve-dup-deps) duplicate_deps="yes" ;;
-
- --quiet | --silent)
- show=:
- preserve_args="$preserve_args $arg"
- ;;
-
- --tag)
- prevopt="--tag"
- prev=tag
- preserve_args="$preserve_args --tag"
- ;;
- --tag=*)
- set tag "$optarg" ${1+"$@"}
- shift
- prev=tag
- preserve_args="$preserve_args --tag"
- ;;
-
- -dlopen)
- prevopt="-dlopen"
- prev=execute_dlfiles
- ;;
-
- -*)
- $echo "$modename: unrecognized option \`$arg'" 1>&2
- $echo "$help" 1>&2
- exit $EXIT_FAILURE
- ;;
-
- *)
- nonopt="$arg"
- break
- ;;
- esac
-done
-
-if test -n "$prevopt"; then
- $echo "$modename: option \`$prevopt' requires an argument" 1>&2
- $echo "$help" 1>&2
- exit $EXIT_FAILURE
-fi
-
-case $disable_libs in
-no)
- ;;
-shared)
- build_libtool_libs=no
- build_old_libs=yes
- ;;
-static)
- build_old_libs=`case $build_libtool_libs in yes) echo no;; *) echo yes;; esac`
- ;;
-esac
-
-# If this variable is set in any of the actions, the command in it
-# will be execed at the end. This prevents here-documents from being
-# left over by shells.
-exec_cmd=
-
-if test -z "$show_help"; then
-
- # Infer the operation mode.
- if test -z "$mode"; then
- $echo "*** Warning: inferring the mode of operation is deprecated." 1>&2
- $echo "*** Future versions of Libtool will require --mode=MODE be specified." 1>&2
- case $nonopt in
- *cc | cc* | *++ | gcc* | *-gcc* | g++* | xlc*)
- mode=link
- for arg
- do
- case $arg in
- -c)
- mode=compile
- break
- ;;
- esac
- done
- ;;
- *db | *dbx | *strace | *truss)
- mode=execute
- ;;
- *install*|cp|mv)
- mode=install
- ;;
- *rm)
- mode=uninstall
- ;;
- *)
- # If we have no mode, but dlfiles were specified, then do execute mode.
- test -n "$execute_dlfiles" && mode=execute
-
- # Just use the default operation mode.
- if test -z "$mode"; then
- if test -n "$nonopt"; then
- $echo "$modename: warning: cannot infer operation mode from \`$nonopt'" 1>&2
- else
- $echo "$modename: warning: cannot infer operation mode without MODE-ARGS" 1>&2
- fi
- fi
- ;;
- esac
- fi
-
- # Only execute mode is allowed to have -dlopen flags.
- if test -n "$execute_dlfiles" && test "$mode" != execute; then
- $echo "$modename: unrecognized option \`-dlopen'" 1>&2
- $echo "$help" 1>&2
- exit $EXIT_FAILURE
- fi
-
- # Change the help message to a mode-specific one.
- generic_help="$help"
- help="Try \`$modename --help --mode=$mode' for more information."
-
- # These modes are in order of execution frequency so that they run quickly.
- case $mode in
- # libtool compile mode
- compile)
- modename="$modename: compile"
- # Get the compilation command and the source file.
- base_compile=
- srcfile="$nonopt" # always keep a non-empty value in "srcfile"
- suppress_opt=yes
- suppress_output=
- arg_mode=normal
- libobj=
- later=
-
- for arg
- do
- case $arg_mode in
- arg )
- # do not "continue". Instead, add this to base_compile
- lastarg="$arg"
- arg_mode=normal
- ;;
-
- target )
- libobj="$arg"
- arg_mode=normal
- continue
- ;;
-
- normal )
- # Accept any command-line options.
- case $arg in
- -o)
- if test -n "$libobj" ; then
- $echo "$modename: you cannot specify \`-o' more than once" 1>&2
- exit $EXIT_FAILURE
- fi
- arg_mode=target
- continue
- ;;
-
- -static | -prefer-pic | -prefer-non-pic)
- later="$later $arg"
- continue
- ;;
-
- -no-suppress)
- suppress_opt=no
- continue
- ;;
-
- -Xcompiler)
- arg_mode=arg # the next one goes into the "base_compile" arg list
- continue # The current "srcfile" will either be retained or
- ;; # replaced later. I would guess that would be a bug.
-
- -Wc,*)
- args=`$echo "X$arg" | $Xsed -e "s/^-Wc,//"`
- lastarg=
- save_ifs="$IFS"; IFS=','
- for arg in $args; do
- IFS="$save_ifs"
-
- # Double-quote args containing other shell metacharacters.
- # Many Bourne shells cannot handle close brackets correctly
- # in scan sets, so we specify it separately.
- case $arg in
- *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"")
- arg="\"$arg\""
- ;;
- esac
- lastarg="$lastarg $arg"
- done
- IFS="$save_ifs"
- lastarg=`$echo "X$lastarg" | $Xsed -e "s/^ //"`
-
- # Add the arguments to base_compile.
- base_compile="$base_compile $lastarg"
- continue
- ;;
-
- * )
- # Accept the current argument as the source file.
- # The previous "srcfile" becomes the current argument.
- #
- lastarg="$srcfile"
- srcfile="$arg"
- ;;
- esac # case $arg
- ;;
- esac # case $arg_mode
-
- # Aesthetically quote the previous argument.
- lastarg=`$echo "X$lastarg" | $Xsed -e "$sed_quote_subst"`
-
- case $lastarg in
- # Double-quote args containing other shell metacharacters.
- # Many Bourne shells cannot handle close brackets correctly
- # in scan sets, and some SunOS ksh mistreat backslash-escaping
- # in scan sets (worked around with variable expansion),
- # and furthermore cannot handle '|' '&' '(' ')' in scan sets
- # at all, so we specify them separately.
- *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"")
- lastarg="\"$lastarg\""
- ;;
- esac
-
- base_compile="$base_compile $lastarg"
- done # for arg
-
- case $arg_mode in
- arg)
- $echo "$modename: you must specify an argument for -Xcompile"
- exit $EXIT_FAILURE
- ;;
- target)
- $echo "$modename: you must specify a target with \`-o'" 1>&2
- exit $EXIT_FAILURE
- ;;
- *)
- # Get the name of the library object.
- [ -z "$libobj" ] && libobj=`$echo "X$srcfile" | $Xsed -e 's%^.*/%%'`
- ;;
- esac
-
- # Recognize several different file suffixes.
- # If the user specifies -o file.o, it is replaced with file.lo
- xform='[cCFSifmso]'
- case $libobj in
- *.ada) xform=ada ;;
- *.adb) xform=adb ;;
- *.ads) xform=ads ;;
- *.asm) xform=asm ;;
- *.c++) xform=c++ ;;
- *.cc) xform=cc ;;
- *.ii) xform=ii ;;
- *.class) xform=class ;;
- *.cpp) xform=cpp ;;
- *.cxx) xform=cxx ;;
- *.f90) xform=f90 ;;
- *.for) xform=for ;;
- *.java) xform=java ;;
- esac
-
- libobj=`$echo "X$libobj" | $Xsed -e "s/\.$xform$/.lo/"`
-
- case $libobj in
- *.lo) obj=`$echo "X$libobj" | $Xsed -e "$lo2o"` ;;
- *)
- $echo "$modename: cannot determine name of library object from \`$libobj'" 1>&2
- exit $EXIT_FAILURE
- ;;
- esac
-
- func_infer_tag $base_compile
-
- for arg in $later; do
- case $arg in
- -static)
- build_old_libs=yes
- continue
- ;;
-
- -prefer-pic)
- pic_mode=yes
- continue
- ;;
-
- -prefer-non-pic)
- pic_mode=no
- continue
- ;;
- esac
- done
-
- qlibobj=`$echo "X$libobj" | $Xsed -e "$sed_quote_subst"`
- case $qlibobj in
- *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"")
- qlibobj="\"$qlibobj\"" ;;
- esac
- test "X$libobj" != "X$qlibobj" \
- && $echo "X$libobj" | grep '[]~#^*{};<>?"'"'"' &()|`$[]' \
- && $echo "$modename: libobj name \`$libobj' may not contain shell special characters."
- objname=`$echo "X$obj" | $Xsed -e 's%^.*/%%'`
- xdir=`$echo "X$obj" | $Xsed -e 's%/[^/]*$%%'`
- if test "X$xdir" = "X$obj"; then
- xdir=
- else
- xdir=$xdir/
- fi
- lobj=${xdir}$objdir/$objname
-
- if test -z "$base_compile"; then
- $echo "$modename: you must specify a compilation command" 1>&2
- $echo "$help" 1>&2
- exit $EXIT_FAILURE
- fi
-
- # Delete any leftover library objects.
- if test "$build_old_libs" = yes; then
- removelist="$obj $lobj $libobj ${libobj}T"
- else
- removelist="$lobj $libobj ${libobj}T"
- fi
-
- $run $rm $removelist
- trap "$run $rm $removelist; exit $EXIT_FAILURE" 1 2 15
-
- # On Cygwin there's no "real" PIC flag so we must build both object types
- case $host_os in
- cygwin* | mingw* | pw32* | os2*)
- pic_mode=default
- ;;
- esac
- if test "$pic_mode" = no && test "$deplibs_check_method" != pass_all; then
- # non-PIC code in shared libraries is not supported
- pic_mode=default
- fi
-
- # Calculate the filename of the output object if compiler does
- # not support -o with -c
- if test "$compiler_c_o" = no; then
- output_obj=`$echo "X$srcfile" | $Xsed -e 's%^.*/%%' -e 's%\.[^.]*$%%'`.${objext}
- lockfile="$output_obj.lock"
- removelist="$removelist $output_obj $lockfile"
- trap "$run $rm $removelist; exit $EXIT_FAILURE" 1 2 15
- else
- output_obj=
- need_locks=no
- lockfile=
- fi
-
- # Lock this critical section if it is needed
- # We use this script file to make the link, it avoids creating a new file
- if test "$need_locks" = yes; then
- until $run ln "$progpath" "$lockfile" 2>/dev/null; do
- $show "Waiting for $lockfile to be removed"
- sleep 2
- done
- elif test "$need_locks" = warn; then
- if test -f "$lockfile"; then
- $echo "\
-*** ERROR, $lockfile exists and contains:
-`cat $lockfile 2>/dev/null`
-
-This indicates that another process is trying to use the same
-temporary object file, and libtool could not work around it because
-your compiler does not support \`-c' and \`-o' together. If you
-repeat this compilation, it may succeed, by chance, but you had better
-avoid parallel builds (make -j) in this platform, or get a better
-compiler."
-
- $run $rm $removelist
- exit $EXIT_FAILURE
- fi
- $echo "$srcfile" > "$lockfile"
- fi
-
- if test -n "$fix_srcfile_path"; then
- eval srcfile=\"$fix_srcfile_path\"
- fi
- qsrcfile=`$echo "X$srcfile" | $Xsed -e "$sed_quote_subst"`
- case $qsrcfile in
- *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"")
- qsrcfile="\"$qsrcfile\"" ;;
- esac
-
- $run $rm "$libobj" "${libobj}T"
-
- # Create a libtool object file (analogous to a ".la" file),
- # but don't create it if we're doing a dry run.
- test -z "$run" && cat > ${libobj}T <<EOF
-# $libobj - a libtool object file
-# Generated by $PROGRAM - GNU $PACKAGE $VERSION$TIMESTAMP
-#
-# Please DO NOT delete this file!
-# It is necessary for linking the library.
-
-# Name of the PIC object.
-EOF
-
- # Only build a PIC object if we are building libtool libraries.
- if test "$build_libtool_libs" = yes; then
- # Without this assignment, base_compile gets emptied.
- fbsd_hideous_sh_bug=$base_compile
-
- if test "$pic_mode" != no; then
- command="$base_compile $qsrcfile $pic_flag"
- else
- # Don't build PIC code
- command="$base_compile $qsrcfile"
- fi
-
- if test ! -d "${xdir}$objdir"; then
- $show "$mkdir ${xdir}$objdir"
- $run $mkdir ${xdir}$objdir
- exit_status=$?
- if test "$exit_status" -ne 0 && test ! -d "${xdir}$objdir"; then
- exit $exit_status
- fi
- fi
-
- if test -z "$output_obj"; then
- # Place PIC objects in $objdir
- command="$command -o $lobj"
- fi
-
- $run $rm "$lobj" "$output_obj"
-
- $show "$command"
- if $run eval "$command"; then :
- else
- test -n "$output_obj" && $run $rm $removelist
- exit $EXIT_FAILURE
- fi
-
- if test "$need_locks" = warn &&
- test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then
- $echo "\
-*** ERROR, $lockfile contains:
-`cat $lockfile 2>/dev/null`
-
-but it should contain:
-$srcfile
-
-This indicates that another process is trying to use the same
-temporary object file, and libtool could not work around it because
-your compiler does not support \`-c' and \`-o' together. If you
-repeat this compilation, it may succeed, by chance, but you had better
-avoid parallel builds (make -j) in this platform, or get a better
-compiler."
-
- $run $rm $removelist
- exit $EXIT_FAILURE
- fi
-
- # Just move the object if needed, then go on to compile the next one
- if test -n "$output_obj" && test "X$output_obj" != "X$lobj"; then
- $show "$mv $output_obj $lobj"
- if $run $mv $output_obj $lobj; then :
- else
- error=$?
- $run $rm $removelist
- exit $error
- fi
- fi
-
- # Append the name of the PIC object to the libtool object file.
- test -z "$run" && cat >> ${libobj}T <<EOF
-pic_object='$objdir/$objname'
-
-EOF
-
- # Allow error messages only from the first compilation.
- if test "$suppress_opt" = yes; then
- suppress_output=' >/dev/null 2>&1'
- fi
- else
- # No PIC object so indicate it doesn't exist in the libtool
- # object file.
- test -z "$run" && cat >> ${libobj}T <<EOF
-pic_object=none
-
-EOF
- fi
-
- # Only build a position-dependent object if we build old libraries.
- if test "$build_old_libs" = yes; then
- if test "$pic_mode" != yes; then
- # Don't build PIC code
- command="$base_compile $qsrcfile"
- else
- command="$base_compile $qsrcfile $pic_flag"
- fi
- if test "$compiler_c_o" = yes; then
- command="$command -o $obj"
- fi
-
- # Suppress compiler output if we already did a PIC compilation.
- command="$command$suppress_output"
- $run $rm "$obj" "$output_obj"
- $show "$command"
- if $run eval "$command"; then :
- else
- $run $rm $removelist
- exit $EXIT_FAILURE
- fi
-
- if test "$need_locks" = warn &&
- test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then
- $echo "\
-*** ERROR, $lockfile contains:
-`cat $lockfile 2>/dev/null`
-
-but it should contain:
-$srcfile
-
-This indicates that another process is trying to use the same
-temporary object file, and libtool could not work around it because
-your compiler does not support \`-c' and \`-o' together. If you
-repeat this compilation, it may succeed, by chance, but you had better
-avoid parallel builds (make -j) in this platform, or get a better
-compiler."
-
- $run $rm $removelist
- exit $EXIT_FAILURE
- fi
-
- # Just move the object if needed
- if test -n "$output_obj" && test "X$output_obj" != "X$obj"; then
- $show "$mv $output_obj $obj"
- if $run $mv $output_obj $obj; then :
- else
- error=$?
- $run $rm $removelist
- exit $error
- fi
- fi
-
- # Append the name of the non-PIC object the libtool object file.
- # Only append if the libtool object file exists.
- test -z "$run" && cat >> ${libobj}T <<EOF
-# Name of the non-PIC object.
-non_pic_object='$objname'
-
-EOF
- else
- # Append the name of the non-PIC object the libtool object file.
- # Only append if the libtool object file exists.
- test -z "$run" && cat >> ${libobj}T <<EOF
-# Name of the non-PIC object.
-non_pic_object=none
-
-EOF
- fi
-
- $run $mv "${libobj}T" "${libobj}"
-
- # Unlock the critical section if it was locked
- if test "$need_locks" != no; then
- $run $rm "$lockfile"
- fi
-
- exit $EXIT_SUCCESS
- ;;
-
- # libtool link mode
- link | relink)
- modename="$modename: link"
- case $host in
- *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2*)
- # It is impossible to link a dll without this setting, and
- # we shouldn't force the makefile maintainer to figure out
- # which system we are compiling for in order to pass an extra
- # flag for every libtool invocation.
- # allow_undefined=no
-
- # FIXME: Unfortunately, there are problems with the above when trying
- # to make a dll which has undefined symbols, in which case not
- # even a static library is built. For now, we need to specify
- # -no-undefined on the libtool link line when we can be certain
- # that all symbols are satisfied, otherwise we get a static library.
- allow_undefined=yes
- ;;
- *)
- allow_undefined=yes
- ;;
- esac
- libtool_args="$nonopt"
- base_compile="$nonopt $@"
- compile_command="$nonopt"
- finalize_command="$nonopt"
-
- compile_rpath=
- finalize_rpath=
- compile_shlibpath=
- finalize_shlibpath=
- convenience=
- old_convenience=
- deplibs=
- old_deplibs=
- compiler_flags=
- linker_flags=
- dllsearchpath=
- lib_search_path=`pwd`
- inst_prefix_dir=
-
- avoid_version=no
- dlfiles=
- dlprefiles=
- dlself=no
- export_dynamic=no
- export_symbols=
- export_symbols_regex=
- generated=
- libobjs=
- ltlibs=
- module=no
- no_install=no
- objs=
- non_pic_objects=
- notinst_path= # paths that contain not-installed libtool libraries
- precious_files_regex=
- prefer_static_libs=no
- preload=no
- prev=
- prevarg=
- release=
- rpath=
- xrpath=
- perm_rpath=
- temp_rpath=
- thread_safe=no
- vinfo=
- vinfo_number=no
-
- func_infer_tag $base_compile
-
- # We need to know -static, to get the right output filenames.
- for arg
- do
- case $arg in
- -all-static | -static)
- if test "X$arg" = "X-all-static"; then
- if test "$build_libtool_libs" = yes && test -z "$link_static_flag"; then
- $echo "$modename: warning: complete static linking is impossible in this configuration" 1>&2
- fi
- if test -n "$link_static_flag"; then
- dlopen_self=$dlopen_self_static
- fi
- prefer_static_libs=yes
- else
- if test -z "$pic_flag" && test -n "$link_static_flag"; then
- dlopen_self=$dlopen_self_static
- fi
- prefer_static_libs=built
- fi
- build_libtool_libs=no
- build_old_libs=yes
- break
- ;;
- esac
- done
-
- # See if our shared archives depend on static archives.
- test -n "$old_archive_from_new_cmds" && build_old_libs=yes
-
- # Go through the arguments, transforming them on the way.
- while test "$#" -gt 0; do
- arg="$1"
- shift
- case $arg in
- *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"")
- qarg=\"`$echo "X$arg" | $Xsed -e "$sed_quote_subst"`\" ### testsuite: skip nested quoting test
- ;;
- *) qarg=$arg ;;
- esac
- libtool_args="$libtool_args $qarg"
-
- # If the previous option needs an argument, assign it.
- if test -n "$prev"; then
- case $prev in
- output)
- compile_command="$compile_command @OUTPUT@"
- finalize_command="$finalize_command @OUTPUT@"
- ;;
- esac
-
- case $prev in
- dlfiles|dlprefiles)
- if test "$preload" = no; then
- # Add the symbol object into the linking commands.
- compile_command="$compile_command @SYMFILE@"
- finalize_command="$finalize_command @SYMFILE@"
- preload=yes
- fi
- case $arg in
- *.la | *.lo) ;; # We handle these cases below.
- force)
- if test "$dlself" = no; then
- dlself=needless
- export_dynamic=yes
- fi
- prev=
- continue
- ;;
- self)
- if test "$prev" = dlprefiles; then
- dlself=yes
- elif test "$prev" = dlfiles && test "$dlopen_self" != yes; then
- dlself=yes
- else
- dlself=needless
- export_dynamic=yes
- fi
- prev=
- continue
- ;;
- *)
- if test "$prev" = dlfiles; then
- dlfiles="$dlfiles $arg"
- else
- dlprefiles="$dlprefiles $arg"
- fi
- prev=
- continue
- ;;
- esac
- ;;
- expsyms)
- export_symbols="$arg"
- if test ! -f "$arg"; then
- $echo "$modename: symbol file \`$arg' does not exist"
- exit $EXIT_FAILURE
- fi
- prev=
- continue
- ;;
- expsyms_regex)
- export_symbols_regex="$arg"
- prev=
- continue
- ;;
- inst_prefix)
- inst_prefix_dir="$arg"
- prev=
- continue
- ;;
- precious_regex)
- precious_files_regex="$arg"
- prev=
- continue
- ;;
- release)
- release="-$arg"
- prev=
- continue
- ;;
- objectlist)
- if test -f "$arg"; then
- save_arg=$arg
- moreargs=
- for fil in `cat $save_arg`
- do
-# moreargs="$moreargs $fil"
- arg=$fil
- # A libtool-controlled object.
-
- # Check to see that this really is a libtool object.
- if (${SED} -e '2q' $arg | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then
- pic_object=
- non_pic_object=
-
- # Read the .lo file
- # If there is no directory component, then add one.
- case $arg in
- */* | *\\*) . $arg ;;
- *) . ./$arg ;;
- esac
-
- if test -z "$pic_object" || \
- test -z "$non_pic_object" ||
- test "$pic_object" = none && \
- test "$non_pic_object" = none; then
- $echo "$modename: cannot find name of object for \`$arg'" 1>&2
- exit $EXIT_FAILURE
- fi
-
- # Extract subdirectory from the argument.
- xdir=`$echo "X$arg" | $Xsed -e 's%/[^/]*$%%'`
- if test "X$xdir" = "X$arg"; then
- xdir=
- else
- xdir="$xdir/"
- fi
-
- if test "$pic_object" != none; then
- # Prepend the subdirectory the object is found in.
- pic_object="$xdir$pic_object"
-
- if test "$prev" = dlfiles; then
- if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then
- dlfiles="$dlfiles $pic_object"
- prev=
- continue
- else
- # If libtool objects are unsupported, then we need to preload.
- prev=dlprefiles
- fi
- fi
-
- # CHECK ME: I think I busted this. -Ossama
- if test "$prev" = dlprefiles; then
- # Preload the old-style object.
- dlprefiles="$dlprefiles $pic_object"
- prev=
- fi
-
- # A PIC object.
- libobjs="$libobjs $pic_object"
- arg="$pic_object"
- fi
-
- # Non-PIC object.
- if test "$non_pic_object" != none; then
- # Prepend the subdirectory the object is found in.
- non_pic_object="$xdir$non_pic_object"
-
- # A standard non-PIC object
- non_pic_objects="$non_pic_objects $non_pic_object"
- if test -z "$pic_object" || test "$pic_object" = none ; then
- arg="$non_pic_object"
- fi
- else
- # If the PIC object exists, use it instead.
- # $xdir was prepended to $pic_object above.
- non_pic_object="$pic_object"
- non_pic_objects="$non_pic_objects $non_pic_object"
- fi
- else
- # Only an error if not doing a dry-run.
- if test -z "$run"; then
- $echo "$modename: \`$arg' is not a valid libtool object" 1>&2
- exit $EXIT_FAILURE
- else
- # Dry-run case.
-
- # Extract subdirectory from the argument.
- xdir=`$echo "X$arg" | $Xsed -e 's%/[^/]*$%%'`
- if test "X$xdir" = "X$arg"; then
- xdir=
- else
- xdir="$xdir/"
- fi
-
- pic_object=`$echo "X${xdir}${objdir}/${arg}" | $Xsed -e "$lo2o"`
- non_pic_object=`$echo "X${xdir}${arg}" | $Xsed -e "$lo2o"`
- libobjs="$libobjs $pic_object"
- non_pic_objects="$non_pic_objects $non_pic_object"
- fi
- fi
- done
- else
- $echo "$modename: link input file \`$save_arg' does not exist"
- exit $EXIT_FAILURE
- fi
- arg=$save_arg
- prev=
- continue
- ;;
- rpath | xrpath)
- # We need an absolute path.
- case $arg in
- [\\/]* | [A-Za-z]:[\\/]*) ;;
- *)
- $echo "$modename: only absolute run-paths are allowed" 1>&2
- exit $EXIT_FAILURE
- ;;
- esac
- if test "$prev" = rpath; then
- case "$rpath " in
- *" $arg "*) ;;
- *) rpath="$rpath $arg" ;;
- esac
- else
- case "$xrpath " in
- *" $arg "*) ;;
- *) xrpath="$xrpath $arg" ;;
- esac
- fi
- prev=
- continue
- ;;
- xcompiler)
- compiler_flags="$compiler_flags $qarg"
- prev=
- compile_command="$compile_command $qarg"
- finalize_command="$finalize_command $qarg"
- continue
- ;;
- xlinker)
- linker_flags="$linker_flags $qarg"
- compiler_flags="$compiler_flags $wl$qarg"
- prev=
- compile_command="$compile_command $wl$qarg"
- finalize_command="$finalize_command $wl$qarg"
- continue
- ;;
- xcclinker)
- linker_flags="$linker_flags $qarg"
- compiler_flags="$compiler_flags $qarg"
- prev=
- compile_command="$compile_command $qarg"
- finalize_command="$finalize_command $qarg"
- continue
- ;;
- shrext)
- shrext_cmds="$arg"
- prev=
- continue
- ;;
- darwin_framework|darwin_framework_skip)
- test "$prev" = "darwin_framework" && compiler_flags="$compiler_flags $arg"
- compile_command="$compile_command $arg"
- finalize_command="$finalize_command $arg"
- prev=
- continue
- ;;
- *)
- eval "$prev=\"\$arg\""
- prev=
- continue
- ;;
- esac
- fi # test -n "$prev"
-
- prevarg="$arg"
-
- case $arg in
- -all-static)
- if test -n "$link_static_flag"; then
- compile_command="$compile_command $link_static_flag"
- finalize_command="$finalize_command $link_static_flag"
- fi
- continue
- ;;
-
- -allow-undefined)
- # FIXME: remove this flag sometime in the future.
- $echo "$modename: \`-allow-undefined' is deprecated because it is the default" 1>&2
- continue
- ;;
-
- -avoid-version)
- avoid_version=yes
- continue
- ;;
-
- -dlopen)
- prev=dlfiles
- continue
- ;;
-
- -dlpreopen)
- prev=dlprefiles
- continue
- ;;
-
- -export-dynamic)
- export_dynamic=yes
- continue
- ;;
-
- -export-symbols | -export-symbols-regex)
- if test -n "$export_symbols" || test -n "$export_symbols_regex"; then
- $echo "$modename: more than one -exported-symbols argument is not allowed"
- exit $EXIT_FAILURE
- fi
- if test "X$arg" = "X-export-symbols"; then
- prev=expsyms
- else
- prev=expsyms_regex
- fi
- continue
- ;;
-
- -framework|-arch|-isysroot)
- case " $CC " in
- *" ${arg} ${1} "* | *" ${arg} ${1} "*)
- prev=darwin_framework_skip ;;
- *) compiler_flags="$compiler_flags $arg"
- prev=darwin_framework ;;
- esac
- compile_command="$compile_command $arg"
- finalize_command="$finalize_command $arg"
- continue
- ;;
-
- -inst-prefix-dir)
- prev=inst_prefix
- continue
- ;;
-
- # The native IRIX linker understands -LANG:*, -LIST:* and -LNO:*
- # so, if we see these flags be careful not to treat them like -L
- -L[A-Z][A-Z]*:*)
- case $with_gcc/$host in
- no/*-*-irix* | /*-*-irix*)
- compile_command="$compile_command $arg"
- finalize_command="$finalize_command $arg"
- ;;
- esac
- continue
- ;;
-
- -L*)
- dir=`$echo "X$arg" | $Xsed -e 's/^-L//'`
- # We need an absolute path.
- case $dir in
- [\\/]* | [A-Za-z]:[\\/]*) ;;
- *)
- absdir=`cd "$dir" && pwd`
- if test -z "$absdir"; then
- $echo "$modename: cannot determine absolute directory name of \`$dir'" 1>&2
- absdir="$dir"
- notinst_path="$notinst_path $dir"
- fi
- dir="$absdir"
- ;;
- esac
- case "$deplibs " in
- *" -L$dir "*) ;;
- *)
- deplibs="$deplibs -L$dir"
- lib_search_path="$lib_search_path $dir"
- ;;
- esac
- case $host in
- *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2*)
- testbindir=`$echo "X$dir" | $Xsed -e 's*/lib$*/bin*'`
- case :$dllsearchpath: in
- *":$dir:"*) ;;
- *) dllsearchpath="$dllsearchpath:$dir";;
- esac
- case :$dllsearchpath: in
- *":$testbindir:"*) ;;
- *) dllsearchpath="$dllsearchpath:$testbindir";;
- esac
- ;;
- esac
- continue
- ;;
-
- -l*)
- if test "X$arg" = "X-lc" || test "X$arg" = "X-lm"; then
- case $host in
- *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-beos*)
- # These systems don't actually have a C or math library (as such)
- continue
- ;;
- *-*-os2*)
- # These systems don't actually have a C library (as such)
- test "X$arg" = "X-lc" && continue
- ;;
- *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
- # Do not include libc due to us having libc/libc_r.
- test "X$arg" = "X-lc" && continue
- ;;
- *-*-rhapsody* | *-*-darwin1.[012])
- # Rhapsody C and math libraries are in the System framework
- deplibs="$deplibs -framework System"
- continue
- ;;
- *-*-sco3.2v5* | *-*-sco5v6*)
- # Causes problems with __ctype
- test "X$arg" = "X-lc" && continue
- ;;
- *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*)
- # Compiler inserts libc in the correct place for threads to work
- test "X$arg" = "X-lc" && continue
- ;;
- esac
- elif test "X$arg" = "X-lc_r"; then
- case $host in
- *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
- # Do not include libc_r directly, use -pthread flag.
- continue
- ;;
- esac
- fi
- deplibs="$deplibs $arg"
- continue
- ;;
-
- # Tru64 UNIX uses -model [arg] to determine the layout of C++
- # classes, name mangling, and exception handling.
- -model)
- compile_command="$compile_command $arg"
- compiler_flags="$compiler_flags $arg"
- finalize_command="$finalize_command $arg"
- prev=xcompiler
- continue
- ;;
-
- -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe)
- compiler_flags="$compiler_flags $arg"
- compile_command="$compile_command $arg"
- finalize_command="$finalize_command $arg"
- continue
- ;;
-
- -module)
- module=yes
- continue
- ;;
-
- # -64, -mips[0-9] enable 64-bit mode on the SGI compiler
- # -r[0-9][0-9]* specifies the processor on the SGI compiler
- # -xarch=*, -xtarget=* enable 64-bit mode on the Sun compiler
- # +DA*, +DD* enable 64-bit mode on the HP compiler
- # -q* pass through compiler args for the IBM compiler
- # -m* pass through architecture-specific compiler args for GCC
- # -m*, -t[45]*, -txscale* pass through architecture-specific
- # compiler args for GCC
- # -pg pass through profiling flag for GCC
- # @file GCC response files
- -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*|-pg| \
- -t[45]*|-txscale*|@*)
-
- # Unknown arguments in both finalize_command and compile_command need
- # to be aesthetically quoted because they are evaled later.
- arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"`
- case $arg in
- *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"")
- arg="\"$arg\""
- ;;
- esac
- compile_command="$compile_command $arg"
- finalize_command="$finalize_command $arg"
- compiler_flags="$compiler_flags $arg"
- continue
- ;;
-
- -shrext)
- prev=shrext
- continue
- ;;
-
- -no-fast-install)
- fast_install=no
- continue
- ;;
-
- -no-install)
- case $host in
- *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2*)
- # The PATH hackery in wrapper scripts is required on Windows
- # in order for the loader to find any dlls it needs.
- $echo "$modename: warning: \`-no-install' is ignored for $host" 1>&2
- $echo "$modename: warning: assuming \`-no-fast-install' instead" 1>&2
- fast_install=no
- ;;
- *) no_install=yes ;;
- esac
- continue
- ;;
-
- -no-undefined)
- allow_undefined=no
- continue
- ;;
-
- -objectlist)
- prev=objectlist
- continue
- ;;
-
- -o) prev=output ;;
-
- -precious-files-regex)
- prev=precious_regex
- continue
- ;;
-
- -release)
- prev=release
- continue
- ;;
-
- -rpath)
- prev=rpath
- continue
- ;;
-
- -R)
- prev=xrpath
- continue
- ;;
-
- -R*)
- dir=`$echo "X$arg" | $Xsed -e 's/^-R//'`
- # We need an absolute path.
- case $dir in
- [\\/]* | [A-Za-z]:[\\/]*) ;;
- *)
- $echo "$modename: only absolute run-paths are allowed" 1>&2
- exit $EXIT_FAILURE
- ;;
- esac
- case "$xrpath " in
- *" $dir "*) ;;
- *) xrpath="$xrpath $dir" ;;
- esac
- continue
- ;;
-
- -static)
- # The effects of -static are defined in a previous loop.
- # We used to do the same as -all-static on platforms that
- # didn't have a PIC flag, but the assumption that the effects
- # would be equivalent was wrong. It would break on at least
- # Digital Unix and AIX.
- continue
- ;;
-
- -thread-safe)
- thread_safe=yes
- continue
- ;;
-
- -version-info)
- prev=vinfo
- continue
- ;;
- -version-number)
- prev=vinfo
- vinfo_number=yes
- continue
- ;;
-
- -Wc,*)
- args=`$echo "X$arg" | $Xsed -e "$sed_quote_subst" -e 's/^-Wc,//'`
- arg=
- save_ifs="$IFS"; IFS=','
- for flag in $args; do
- IFS="$save_ifs"
- case $flag in
- *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"")
- flag="\"$flag\""
- ;;
- esac
- arg="$arg $wl$flag"
- compiler_flags="$compiler_flags $flag"
- done
- IFS="$save_ifs"
- arg=`$echo "X$arg" | $Xsed -e "s/^ //"`
- ;;
-
- -Wl,*)
- args=`$echo "X$arg" | $Xsed -e "$sed_quote_subst" -e 's/^-Wl,//'`
- arg=
- save_ifs="$IFS"; IFS=','
- for flag in $args; do
- IFS="$save_ifs"
- case $flag in
- *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"")
- flag="\"$flag\""
- ;;
- esac
- arg="$arg $wl$flag"
- compiler_flags="$compiler_flags $wl$flag"
- linker_flags="$linker_flags $flag"
- done
- IFS="$save_ifs"
- arg=`$echo "X$arg" | $Xsed -e "s/^ //"`
- ;;
-
- -Xcompiler)
- prev=xcompiler
- continue
- ;;
-
- -Xlinker)
- prev=xlinker
- continue
- ;;
-
- -XCClinker)
- prev=xcclinker
- continue
- ;;
-
- # Some other compiler flag.
- -* | +*)
- # Unknown arguments in both finalize_command and compile_command need
- # to be aesthetically quoted because they are evaled later.
- arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"`
- case $arg in
- *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"")
- arg="\"$arg\""
- ;;
- esac
- ;;
-
- *.$objext)
- # A standard object.
- objs="$objs $arg"
- ;;
-
- *.lo)
- # A libtool-controlled object.
-
- # Check to see that this really is a libtool object.
- if (${SED} -e '2q' $arg | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then
- pic_object=
- non_pic_object=
-
- # Read the .lo file
- # If there is no directory component, then add one.
- case $arg in
- */* | *\\*) . $arg ;;
- *) . ./$arg ;;
- esac
-
- if test -z "$pic_object" || \
- test -z "$non_pic_object" ||
- test "$pic_object" = none && \
- test "$non_pic_object" = none; then
- $echo "$modename: cannot find name of object for \`$arg'" 1>&2
- exit $EXIT_FAILURE
- fi
-
- # Extract subdirectory from the argument.
- xdir=`$echo "X$arg" | $Xsed -e 's%/[^/]*$%%'`
- if test "X$xdir" = "X$arg"; then
- xdir=
- else
- xdir="$xdir/"
- fi
-
- if test "$pic_object" != none; then
- # Prepend the subdirectory the object is found in.
- pic_object="$xdir$pic_object"
-
- if test "$prev" = dlfiles; then
- if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then
- dlfiles="$dlfiles $pic_object"
- prev=
- continue
- else
- # If libtool objects are unsupported, then we need to preload.
- prev=dlprefiles
- fi
- fi
-
- # CHECK ME: I think I busted this. -Ossama
- if test "$prev" = dlprefiles; then
- # Preload the old-style object.
- dlprefiles="$dlprefiles $pic_object"
- prev=
- fi
-
- # A PIC object.
- libobjs="$libobjs $pic_object"
- arg="$pic_object"
- fi
-
- # Non-PIC object.
- if test "$non_pic_object" != none; then
- # Prepend the subdirectory the object is found in.
- non_pic_object="$xdir$non_pic_object"
-
- # A standard non-PIC object
- non_pic_objects="$non_pic_objects $non_pic_object"
- if test -z "$pic_object" || test "$pic_object" = none ; then
- arg="$non_pic_object"
- fi
- else
- # If the PIC object exists, use it instead.
- # $xdir was prepended to $pic_object above.
- non_pic_object="$pic_object"
- non_pic_objects="$non_pic_objects $non_pic_object"
- fi
- else
- # Only an error if not doing a dry-run.
- if test -z "$run"; then
- $echo "$modename: \`$arg' is not a valid libtool object" 1>&2
- exit $EXIT_FAILURE
- else
- # Dry-run case.
-
- # Extract subdirectory from the argument.
- xdir=`$echo "X$arg" | $Xsed -e 's%/[^/]*$%%'`
- if test "X$xdir" = "X$arg"; then
- xdir=
- else
- xdir="$xdir/"
- fi
-
- pic_object=`$echo "X${xdir}${objdir}/${arg}" | $Xsed -e "$lo2o"`
- non_pic_object=`$echo "X${xdir}${arg}" | $Xsed -e "$lo2o"`
- libobjs="$libobjs $pic_object"
- non_pic_objects="$non_pic_objects $non_pic_object"
- fi
- fi
- ;;
-
- *.$libext)
- # An archive.
- deplibs="$deplibs $arg"
- old_deplibs="$old_deplibs $arg"
- continue
- ;;
-
- *.la)
- # A libtool-controlled library.
-
- if test "$prev" = dlfiles; then
- # This library was specified with -dlopen.
- dlfiles="$dlfiles $arg"
- prev=
- elif test "$prev" = dlprefiles; then
- # The library was specified with -dlpreopen.
- dlprefiles="$dlprefiles $arg"
- prev=
- else
- deplibs="$deplibs $arg"
- fi
- continue
- ;;
-
- # Some other compiler argument.
- *)
- # Unknown arguments in both finalize_command and compile_command need
- # to be aesthetically quoted because they are evaled later.
- arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"`
- case $arg in
- *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"")
- arg="\"$arg\""
- ;;
- esac
- ;;
- esac # arg
-
- # Now actually substitute the argument into the commands.
- if test -n "$arg"; then
- compile_command="$compile_command $arg"
- finalize_command="$finalize_command $arg"
- fi
- done # argument parsing loop
-
- if test -n "$prev"; then
- $echo "$modename: the \`$prevarg' option requires an argument" 1>&2
- $echo "$help" 1>&2
- exit $EXIT_FAILURE
- fi
-
- if test "$export_dynamic" = yes && test -n "$export_dynamic_flag_spec"; then
- eval arg=\"$export_dynamic_flag_spec\"
- compile_command="$compile_command $arg"
- finalize_command="$finalize_command $arg"
- fi
-
- oldlibs=
- # calculate the name of the file, without its directory
- outputname=`$echo "X$output" | $Xsed -e 's%^.*/%%'`
- libobjs_save="$libobjs"
-
- if test -n "$shlibpath_var"; then
- # get the directories listed in $shlibpath_var
- eval shlib_search_path=\`\$echo \"X\${$shlibpath_var}\" \| \$Xsed -e \'s/:/ /g\'\`
- else
- shlib_search_path=
- fi
- eval sys_lib_search_path=\"$sys_lib_search_path_spec\"
- eval sys_lib_dlsearch_path=\"$sys_lib_dlsearch_path_spec\"
-
- output_objdir=`$echo "X$output" | $Xsed -e 's%/[^/]*$%%'`
- if test "X$output_objdir" = "X$output"; then
- output_objdir="$objdir"
- else
- output_objdir="$output_objdir/$objdir"
- fi
- # Create the object directory.
- if test ! -d "$output_objdir"; then
- $show "$mkdir $output_objdir"
- $run $mkdir $output_objdir
- exit_status=$?
- if test "$exit_status" -ne 0 && test ! -d "$output_objdir"; then
- exit $exit_status
- fi
- fi
-
- # Determine the type of output
- case $output in
- "")
- $echo "$modename: you must specify an output file" 1>&2
- $echo "$help" 1>&2
- exit $EXIT_FAILURE
- ;;
- *.$libext) linkmode=oldlib ;;
- *.lo | *.$objext) linkmode=obj ;;
- *.la) linkmode=lib ;;
- *) linkmode=prog ;; # Anything else should be a program.
- esac
-
- case $host in
- *cygwin* | *mingw* | *pw32*)
- # don't eliminate duplications in $postdeps and $predeps
- duplicate_compiler_generated_deps=yes
- ;;
- *)
- duplicate_compiler_generated_deps=$duplicate_deps
- ;;
- esac
- specialdeplibs=
-
- libs=
- # Find all interdependent deplibs by searching for libraries
- # that are linked more than once (e.g. -la -lb -la)
- for deplib in $deplibs; do
- if test "X$duplicate_deps" = "Xyes" ; then
- case "$libs " in
- *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;;
- esac
- fi
- libs="$libs $deplib"
- done
-
- if test "$linkmode" = lib; then
- libs="$predeps $libs $compiler_lib_search_path $postdeps"
-
- # Compute libraries that are listed more than once in $predeps
- # $postdeps and mark them as special (i.e., whose duplicates are
- # not to be eliminated).
- pre_post_deps=
- if test "X$duplicate_compiler_generated_deps" = "Xyes" ; then
- for pre_post_dep in $predeps $postdeps; do
- case "$pre_post_deps " in
- *" $pre_post_dep "*) specialdeplibs="$specialdeplibs $pre_post_deps" ;;
- esac
- pre_post_deps="$pre_post_deps $pre_post_dep"
- done
- fi
- pre_post_deps=
- fi
-
- deplibs=
- newdependency_libs=
- newlib_search_path=
- need_relink=no # whether we're linking any uninstalled libtool libraries
- notinst_deplibs= # not-installed libtool libraries
- case $linkmode in
- lib)
- passes="conv link"
- for file in $dlfiles $dlprefiles; do
- case $file in
- *.la) ;;
- *)
- $echo "$modename: libraries can \`-dlopen' only libtool libraries: $file" 1>&2
- exit $EXIT_FAILURE
- ;;
- esac
- done
- ;;
- prog)
- compile_deplibs=
- finalize_deplibs=
- alldeplibs=no
- newdlfiles=
- newdlprefiles=
- passes="conv scan dlopen dlpreopen link"
- ;;
- *) passes="conv"
- ;;
- esac
- for pass in $passes; do
- if test "$linkmode,$pass" = "lib,link" ||
- test "$linkmode,$pass" = "prog,scan"; then
- libs="$deplibs"
- deplibs=
- fi
- if test "$linkmode" = prog; then
- case $pass in
- dlopen) libs="$dlfiles" ;;
- dlpreopen) libs="$dlprefiles" ;;
- link)
- libs="$deplibs %DEPLIBS%"
- test "X$link_all_deplibs" != Xno && libs="$libs $dependency_libs"
- ;;
- esac
- fi
- if test "$pass" = dlopen; then
- # Collect dlpreopened libraries
- save_deplibs="$deplibs"
- deplibs=
- fi
- for deplib in $libs; do
- lib=
- found=no
- case $deplib in
- -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe)
- if test "$linkmode,$pass" = "prog,link"; then
- compile_deplibs="$deplib $compile_deplibs"
- finalize_deplibs="$deplib $finalize_deplibs"
- else
- compiler_flags="$compiler_flags $deplib"
- fi
- continue
- ;;
- -l*)
- if test "$linkmode" != lib && test "$linkmode" != prog; then
- $echo "$modename: warning: \`-l' is ignored for archives/objects" 1>&2
- continue
- fi
- name=`$echo "X$deplib" | $Xsed -e 's/^-l//'`
- for searchdir in $newlib_search_path $lib_search_path $sys_lib_search_path $shlib_search_path; do
- for search_ext in .la $std_shrext .so .a; do
- # Search the libtool library
- lib="$searchdir/lib${name}${search_ext}"
- if test -f "$lib"; then
- if test "$search_ext" = ".la"; then
- found=yes
- else
- found=no
- fi
- break 2
- fi
- done
- done
- if test "$found" != yes; then
- # deplib doesn't seem to be a libtool library
- if test "$linkmode,$pass" = "prog,link"; then
- compile_deplibs="$deplib $compile_deplibs"
- finalize_deplibs="$deplib $finalize_deplibs"
- else
- deplibs="$deplib $deplibs"
- test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs"
- fi
- continue
- else # deplib is a libtool library
- # If $allow_libtool_libs_with_static_runtimes && $deplib is a stdlib,
- # We need to do some special things here, and not later.
- if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
- case " $predeps $postdeps " in
- *" $deplib "*)
- if (${SED} -e '2q' $lib |
- grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then
- library_names=
- old_library=
- case $lib in
- */* | *\\*) . $lib ;;
- *) . ./$lib ;;
- esac
- for l in $old_library $library_names; do
- ll="$l"
- done
- if test "X$ll" = "X$old_library" ; then # only static version available
- found=no
- ladir=`$echo "X$lib" | $Xsed -e 's%/[^/]*$%%'`
- test "X$ladir" = "X$lib" && ladir="."
- lib=$ladir/$old_library
- if test "$linkmode,$pass" = "prog,link"; then
- compile_deplibs="$deplib $compile_deplibs"
- finalize_deplibs="$deplib $finalize_deplibs"
- else
- deplibs="$deplib $deplibs"
- test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs"
- fi
- continue
- fi
- fi
- ;;
- *) ;;
- esac
- fi
- fi
- ;; # -l
- -L*)
- case $linkmode in
- lib)
- deplibs="$deplib $deplibs"
- test "$pass" = conv && continue
- newdependency_libs="$deplib $newdependency_libs"
- newlib_search_path="$newlib_search_path "`$echo "X$deplib" | $Xsed -e 's/^-L//'`
- ;;
- prog)
- if test "$pass" = conv; then
- deplibs="$deplib $deplibs"
- continue
- fi
- if test "$pass" = scan; then
- deplibs="$deplib $deplibs"
- else
- compile_deplibs="$deplib $compile_deplibs"
- finalize_deplibs="$deplib $finalize_deplibs"
- fi
- newlib_search_path="$newlib_search_path "`$echo "X$deplib" | $Xsed -e 's/^-L//'`
- ;;
- *)
- $echo "$modename: warning: \`-L' is ignored for archives/objects" 1>&2
- ;;
- esac # linkmode
- continue
- ;; # -L
- -R*)
- if test "$pass" = link; then
- dir=`$echo "X$deplib" | $Xsed -e 's/^-R//'`
- # Make sure the xrpath contains only unique directories.
- case "$xrpath " in
- *" $dir "*) ;;
- *) xrpath="$xrpath $dir" ;;
- esac
- fi
- deplibs="$deplib $deplibs"
- continue
- ;;
- *.la) lib="$deplib" ;;
- *.$libext)
- if test "$pass" = conv; then
- deplibs="$deplib $deplibs"
- continue
- fi
- case $linkmode in
- lib)
- valid_a_lib=no
- case $deplibs_check_method in
- match_pattern*)
- set dummy $deplibs_check_method
- match_pattern_regex=`expr "$deplibs_check_method" : "$2 \(.*\)"`
- if eval $echo \"$deplib\" 2>/dev/null \
- | $SED 10q \
- | $EGREP "$match_pattern_regex" > /dev/null; then
- valid_a_lib=yes
- fi
- ;;
- pass_all)
- valid_a_lib=yes
- ;;
- esac
- if test "$valid_a_lib" != yes; then
- $echo
- $echo "*** Warning: Trying to link with static lib archive $deplib."
- $echo "*** I have the capability to make that library automatically link in when"
- $echo "*** you link to this library. But I can only do this if you have a"
- $echo "*** shared version of the library, which you do not appear to have"
- $echo "*** because the file extensions .$libext of this argument makes me believe"
- $echo "*** that it is just a static archive that I should not used here."
- else
- $echo
- $echo "*** Warning: Linking the shared library $output against the"
- $echo "*** static library $deplib is not portable!"
- deplibs="$deplib $deplibs"
- fi
- continue
- ;;
- prog)
- if test "$pass" != link; then
- deplibs="$deplib $deplibs"
- else
- compile_deplibs="$deplib $compile_deplibs"
- finalize_deplibs="$deplib $finalize_deplibs"
- fi
- continue
- ;;
- esac # linkmode
- ;; # *.$libext
- *.lo | *.$objext)
- if test "$pass" = conv; then
- deplibs="$deplib $deplibs"
- elif test "$linkmode" = prog; then
- if test "$pass" = dlpreopen || test "$dlopen_support" != yes || test "$build_libtool_libs" = no; then
- # If there is no dlopen support or we're linking statically,
- # we need to preload.
- newdlprefiles="$newdlprefiles $deplib"
- compile_deplibs="$deplib $compile_deplibs"
- finalize_deplibs="$deplib $finalize_deplibs"
- else
- newdlfiles="$newdlfiles $deplib"
- fi
- fi
- continue
- ;;
- %DEPLIBS%)
- alldeplibs=yes
- continue
- ;;
- esac # case $deplib
- if test "$found" = yes || test -f "$lib"; then :
- else
- $echo "$modename: cannot find the library \`$lib' or unhandled argument \`$deplib'" 1>&2
- exit $EXIT_FAILURE
- fi
-
- # Check to see that this really is a libtool archive.
- if (${SED} -e '2q' $lib | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then :
- else
- $echo "$modename: \`$lib' is not a valid libtool archive" 1>&2
- exit $EXIT_FAILURE
- fi
-
- ladir=`$echo "X$lib" | $Xsed -e 's%/[^/]*$%%'`
- test "X$ladir" = "X$lib" && ladir="."
-
- dlname=
- dlopen=
- dlpreopen=
- libdir=
- library_names=
- old_library=
- # If the library was installed with an old release of libtool,
- # it will not redefine variables installed, or shouldnotlink
- installed=yes
- shouldnotlink=no
- avoidtemprpath=
-
-
- # Read the .la file
- case $lib in
- */* | *\\*) . $lib ;;
- *) . ./$lib ;;
- esac
-
- if test "$linkmode,$pass" = "lib,link" ||
- test "$linkmode,$pass" = "prog,scan" ||
- { test "$linkmode" != prog && test "$linkmode" != lib; }; then
- test -n "$dlopen" && dlfiles="$dlfiles $dlopen"
- test -n "$dlpreopen" && dlprefiles="$dlprefiles $dlpreopen"
- fi
-
- if test "$pass" = conv; then
- # Only check for convenience libraries
- deplibs="$lib $deplibs"
- if test -z "$libdir"; then
- if test -z "$old_library"; then
- $echo "$modename: cannot find name of link library for \`$lib'" 1>&2
- exit $EXIT_FAILURE
- fi
- # It is a libtool convenience library, so add in its objects.
- convenience="$convenience $ladir/$objdir/$old_library"
- old_convenience="$old_convenience $ladir/$objdir/$old_library"
- tmp_libs=
- for deplib in $dependency_libs; do
- deplibs="$deplib $deplibs"
- if test "X$duplicate_deps" = "Xyes" ; then
- case "$tmp_libs " in
- *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;;
- esac
- fi
- tmp_libs="$tmp_libs $deplib"
- done
- elif test "$linkmode" != prog && test "$linkmode" != lib; then
- $echo "$modename: \`$lib' is not a convenience library" 1>&2
- exit $EXIT_FAILURE
- fi
- continue
- fi # $pass = conv
-
-
- # Get the name of the library we link against.
- linklib=
- for l in $old_library $library_names; do
- linklib="$l"
- done
- if test -z "$linklib"; then
- $echo "$modename: cannot find name of link library for \`$lib'" 1>&2
- exit $EXIT_FAILURE
- fi
-
- # This library was specified with -dlopen.
- if test "$pass" = dlopen; then
- if test -z "$libdir"; then
- $echo "$modename: cannot -dlopen a convenience library: \`$lib'" 1>&2
- exit $EXIT_FAILURE
- fi
- if test -z "$dlname" ||
- test "$dlopen_support" != yes ||
- test "$build_libtool_libs" = no; then
- # If there is no dlname, no dlopen support or we're linking
- # statically, we need to preload. We also need to preload any
- # dependent libraries so libltdl's deplib preloader doesn't
- # bomb out in the load deplibs phase.
- dlprefiles="$dlprefiles $lib $dependency_libs"
- else
- newdlfiles="$newdlfiles $lib"
- fi
- continue
- fi # $pass = dlopen
-
- # We need an absolute path.
- case $ladir in
- [\\/]* | [A-Za-z]:[\\/]*) abs_ladir="$ladir" ;;
- *)
- abs_ladir=`cd "$ladir" && pwd`
- if test -z "$abs_ladir"; then
- $echo "$modename: warning: cannot determine absolute directory name of \`$ladir'" 1>&2
- $echo "$modename: passing it literally to the linker, although it might fail" 1>&2
- abs_ladir="$ladir"
- fi
- ;;
- esac
- laname=`$echo "X$lib" | $Xsed -e 's%^.*/%%'`
-
- # Find the relevant object directory and library name.
- if test "X$installed" = Xyes; then
- if test ! -f "$libdir/$linklib" && test -f "$abs_ladir/$linklib"; then
- $echo "$modename: warning: library \`$lib' was moved." 1>&2
- dir="$ladir"
- absdir="$abs_ladir"
- libdir="$abs_ladir"
- else
- dir="$libdir"
- absdir="$libdir"
- fi
- test "X$hardcode_automatic" = Xyes && avoidtemprpath=yes
- else
- if test ! -f "$ladir/$objdir/$linklib" && test -f "$abs_ladir/$linklib"; then
- dir="$ladir"
- absdir="$abs_ladir"
- # Remove this search path later
- notinst_path="$notinst_path $abs_ladir"
- else
- dir="$ladir/$objdir"
- absdir="$abs_ladir/$objdir"
- # Remove this search path later
- notinst_path="$notinst_path $abs_ladir"
- fi
- fi # $installed = yes
- name=`$echo "X$laname" | $Xsed -e 's/\.la$//' -e 's/^lib//'`
-
- # This library was specified with -dlpreopen.
- if test "$pass" = dlpreopen; then
- if test -z "$libdir"; then
- $echo "$modename: cannot -dlpreopen a convenience library: \`$lib'" 1>&2
- exit $EXIT_FAILURE
- fi
- # Prefer using a static library (so that no silly _DYNAMIC symbols
- # are required to link).
- if test -n "$old_library"; then
- newdlprefiles="$newdlprefiles $dir/$old_library"
- # Otherwise, use the dlname, so that lt_dlopen finds it.
- elif test -n "$dlname"; then
- newdlprefiles="$newdlprefiles $dir/$dlname"
- else
- newdlprefiles="$newdlprefiles $dir/$linklib"
- fi
- fi # $pass = dlpreopen
-
- if test -z "$libdir"; then
- # Link the convenience library
- if test "$linkmode" = lib; then
- deplibs="$dir/$old_library $deplibs"
- elif test "$linkmode,$pass" = "prog,link"; then
- compile_deplibs="$dir/$old_library $compile_deplibs"
- finalize_deplibs="$dir/$old_library $finalize_deplibs"
- else
- deplibs="$lib $deplibs" # used for prog,scan pass
- fi
- continue
- fi
-
-
- if test "$linkmode" = prog && test "$pass" != link; then
- newlib_search_path="$newlib_search_path $ladir"
- deplibs="$lib $deplibs"
-
- linkalldeplibs=no
- if test "$link_all_deplibs" != no || test -z "$library_names" ||
- test "$build_libtool_libs" = no; then
- linkalldeplibs=yes
- fi
-
- tmp_libs=
- for deplib in $dependency_libs; do
- case $deplib in
- -L*) newlib_search_path="$newlib_search_path "`$echo "X$deplib" | $Xsed -e 's/^-L//'`;; ### testsuite: skip nested quoting test
- esac
- # Need to link against all dependency_libs?
- if test "$linkalldeplibs" = yes; then
- deplibs="$deplib $deplibs"
- else
- # Need to hardcode shared library paths
- # or/and link against static libraries
- newdependency_libs="$deplib $newdependency_libs"
- fi
- if test "X$duplicate_deps" = "Xyes" ; then
- case "$tmp_libs " in
- *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;;
- esac
- fi
- tmp_libs="$tmp_libs $deplib"
- done # for deplib
- continue
- fi # $linkmode = prog...
-
- if test "$linkmode,$pass" = "prog,link"; then
- if test -n "$library_names" &&
- { test "$prefer_static_libs" = no || test -z "$old_library"; }; then
- # We need to hardcode the library path
- if test -n "$shlibpath_var" && test -z "$avoidtemprpath" ; then
- # Make sure the rpath contains only unique directories.
- case "$temp_rpath " in
- *" $dir "*) ;;
- *" $absdir "*) ;;
- *) temp_rpath="$temp_rpath $absdir" ;;
- esac
- fi
-
- # Hardcode the library path.
- # Skip directories that are in the system default run-time
- # search path.
- case " $sys_lib_dlsearch_path " in
- *" $absdir "*) ;;
- *)
- case "$compile_rpath " in
- *" $absdir "*) ;;
- *) compile_rpath="$compile_rpath $absdir"
- esac
- ;;
- esac
- case " $sys_lib_dlsearch_path " in
- *" $libdir "*) ;;
- *)
- case "$finalize_rpath " in
- *" $libdir "*) ;;
- *) finalize_rpath="$finalize_rpath $libdir"
- esac
- ;;
- esac
- fi # $linkmode,$pass = prog,link...
-
- if test "$alldeplibs" = yes &&
- { test "$deplibs_check_method" = pass_all ||
- { test "$build_libtool_libs" = yes &&
- test -n "$library_names"; }; }; then
- # We only need to search for static libraries
- continue
- fi
- fi
-
- link_static=no # Whether the deplib will be linked statically
- use_static_libs=$prefer_static_libs
- if test "$use_static_libs" = built && test "$installed" = yes ; then
- use_static_libs=no
- fi
- if test -n "$library_names" &&
- { test "$use_static_libs" = no || test -z "$old_library"; }; then
- if test "$installed" = no; then
- notinst_deplibs="$notinst_deplibs $lib"
- need_relink=yes
- fi
- # This is a shared library
-
- # Warn about portability, can't link against -module's on
- # some systems (darwin)
- if test "$shouldnotlink" = yes && test "$pass" = link ; then
- $echo
- if test "$linkmode" = prog; then
- $echo "*** Warning: Linking the executable $output against the loadable module"
- else
- $echo "*** Warning: Linking the shared library $output against the loadable module"
- fi
- $echo "*** $linklib is not portable!"
- fi
- if test "$linkmode" = lib &&
- test "$hardcode_into_libs" = yes; then
- # Hardcode the library path.
- # Skip directories that are in the system default run-time
- # search path.
- case " $sys_lib_dlsearch_path " in
- *" $absdir "*) ;;
- *)
- case "$compile_rpath " in
- *" $absdir "*) ;;
- *) compile_rpath="$compile_rpath $absdir"
- esac
- ;;
- esac
- case " $sys_lib_dlsearch_path " in
- *" $libdir "*) ;;
- *)
- case "$finalize_rpath " in
- *" $libdir "*) ;;
- *) finalize_rpath="$finalize_rpath $libdir"
- esac
- ;;
- esac
- fi
-
- if test -n "$old_archive_from_expsyms_cmds"; then
- # figure out the soname
- set dummy $library_names
- realname="$2"
- shift; shift
- libname=`eval \\$echo \"$libname_spec\"`
- # use dlname if we got it. it's perfectly good, no?
- if test -n "$dlname"; then
- soname="$dlname"
- elif test -n "$soname_spec"; then
- # bleh windows
- case $host in
- *cygwin* | mingw*)
- major=`expr $current - $age`
- versuffix="-$major"
- ;;
- esac
- eval soname=\"$soname_spec\"
- else
- soname="$realname"
- fi
-
- # Make a new name for the extract_expsyms_cmds to use
- soroot="$soname"
- soname=`$echo $soroot | ${SED} -e 's/^.*\///'`
- newlib="libimp-`$echo $soname | ${SED} 's/^lib//;s/\.dll$//'`.a"
-
- # If the library has no export list, then create one now
- if test -f "$output_objdir/$soname-def"; then :
- else
- $show "extracting exported symbol list from \`$soname'"
- save_ifs="$IFS"; IFS='~'
- cmds=$extract_expsyms_cmds
- for cmd in $cmds; do
- IFS="$save_ifs"
- eval cmd=\"$cmd\"
- $show "$cmd"
- $run eval "$cmd" || exit $?
- done
- IFS="$save_ifs"
- fi
-
- # Create $newlib
- if test -f "$output_objdir/$newlib"; then :; else
- $show "generating import library for \`$soname'"
- save_ifs="$IFS"; IFS='~'
- cmds=$old_archive_from_expsyms_cmds
- for cmd in $cmds; do
- IFS="$save_ifs"
- eval cmd=\"$cmd\"
- $show "$cmd"
- $run eval "$cmd" || exit $?
- done
- IFS="$save_ifs"
- fi
- # make sure the library variables are pointing to the new library
- dir=$output_objdir
- linklib=$newlib
- fi # test -n "$old_archive_from_expsyms_cmds"
-
- if test "$linkmode" = prog || test "$mode" != relink; then
- add_shlibpath=
- add_dir=
- add=
- lib_linked=yes
- case $hardcode_action in
- immediate | unsupported)
- if test "$hardcode_direct" = no; then
- add="$dir/$linklib"
- case $host in
- *-*-sco3.2v5.0.[024]*) add_dir="-L$dir" ;;
- *-*-sysv4*uw2*) add_dir="-L$dir" ;;
- *-*-sysv5OpenUNIX* | *-*-sysv5UnixWare7.[01].[10]* | \
- *-*-unixware7*) add_dir="-L$dir" ;;
- *-*-darwin* )
- # if the lib is a module then we can not link against
- # it, someone is ignoring the new warnings I added
- if /usr/bin/file -L $add 2> /dev/null |
- $EGREP ": [^:]* bundle" >/dev/null ; then
- $echo "** Warning, lib $linklib is a module, not a shared library"
- if test -z "$old_library" ; then
- $echo
- $echo "** And there doesn't seem to be a static archive available"
- $echo "** The link will probably fail, sorry"
- else
- add="$dir/$old_library"
- fi
- fi
- esac
- elif test "$hardcode_minus_L" = no; then
- case $host in
- *-*-sunos*) add_shlibpath="$dir" ;;
- esac
- add_dir="-L$dir"
- add="-l$name"
- elif test "$hardcode_shlibpath_var" = no; then
- add_shlibpath="$dir"
- add="-l$name"
- else
- lib_linked=no
- fi
- ;;
- relink)
- if test "$hardcode_direct" = yes; then
- add="$dir/$linklib"
- elif test "$hardcode_minus_L" = yes; then
- add_dir="-L$dir"
- # Try looking first in the location we're being installed to.
- if test -n "$inst_prefix_dir"; then
- case $libdir in
- [\\/]*)
- add_dir="$add_dir -L$inst_prefix_dir$libdir"
- ;;
- esac
- fi
- add="-l$name"
- elif test "$hardcode_shlibpath_var" = yes; then
- add_shlibpath="$dir"
- add="-l$name"
- else
- lib_linked=no
- fi
- ;;
- *) lib_linked=no ;;
- esac
-
- if test "$lib_linked" != yes; then
- $echo "$modename: configuration error: unsupported hardcode properties"
- exit $EXIT_FAILURE
- fi
-
- if test -n "$add_shlibpath"; then
- case :$compile_shlibpath: in
- *":$add_shlibpath:"*) ;;
- *) compile_shlibpath="$compile_shlibpath$add_shlibpath:" ;;
- esac
- fi
- if test "$linkmode" = prog; then
- test -n "$add_dir" && compile_deplibs="$add_dir $compile_deplibs"
- test -n "$add" && compile_deplibs="$add $compile_deplibs"
- else
- test -n "$add_dir" && deplibs="$add_dir $deplibs"
- test -n "$add" && deplibs="$add $deplibs"
- if test "$hardcode_direct" != yes && \
- test "$hardcode_minus_L" != yes && \
- test "$hardcode_shlibpath_var" = yes; then
- case :$finalize_shlibpath: in
- *":$libdir:"*) ;;
- *) finalize_shlibpath="$finalize_shlibpath$libdir:" ;;
- esac
- fi
- fi
- fi
-
- if test "$linkmode" = prog || test "$mode" = relink; then
- add_shlibpath=
- add_dir=
- add=
- # Finalize command for both is simple: just hardcode it.
- if test "$hardcode_direct" = yes; then
- add="$libdir/$linklib"
- elif test "$hardcode_minus_L" = yes; then
- add_dir="-L$libdir"
- add="-l$name"
- elif test "$hardcode_shlibpath_var" = yes; then
- case :$finalize_shlibpath: in
- *":$libdir:"*) ;;
- *) finalize_shlibpath="$finalize_shlibpath$libdir:" ;;
- esac
- add="-l$name"
- elif test "$hardcode_automatic" = yes; then
- if test -n "$inst_prefix_dir" &&
- test -f "$inst_prefix_dir$libdir/$linklib" ; then
- add="$inst_prefix_dir$libdir/$linklib"
- else
- add="$libdir/$linklib"
- fi
- else
- # We cannot seem to hardcode it, guess we'll fake it.
- add_dir="-L$libdir"
- # Try looking first in the location we're being installed to.
- if test -n "$inst_prefix_dir"; then
- case $libdir in
- [\\/]*)
- add_dir="$add_dir -L$inst_prefix_dir$libdir"
- ;;
- esac
- fi
- add="-l$name"
- fi
-
- if test "$linkmode" = prog; then
- test -n "$add_dir" && finalize_deplibs="$add_dir $finalize_deplibs"
- test -n "$add" && finalize_deplibs="$add $finalize_deplibs"
- else
- test -n "$add_dir" && deplibs="$add_dir $deplibs"
- test -n "$add" && deplibs="$add $deplibs"
- fi
- fi
- elif test "$linkmode" = prog; then
- # Here we assume that one of hardcode_direct or hardcode_minus_L
- # is not unsupported. This is valid on all known static and
- # shared platforms.
- if test "$hardcode_direct" != unsupported; then
- test -n "$old_library" && linklib="$old_library"
- compile_deplibs="$dir/$linklib $compile_deplibs"
- finalize_deplibs="$dir/$linklib $finalize_deplibs"
- else
- compile_deplibs="-l$name -L$dir $compile_deplibs"
- finalize_deplibs="-l$name -L$dir $finalize_deplibs"
- fi
- elif test "$build_libtool_libs" = yes; then
- # Not a shared library
- if test "$deplibs_check_method" != pass_all; then
- # We're trying link a shared library against a static one
- # but the system doesn't support it.
-
- # Just print a warning and add the library to dependency_libs so
- # that the program can be linked against the static library.
- $echo
- $echo "*** Warning: This system can not link to static lib archive $lib."
- $echo "*** I have the capability to make that library automatically link in when"
- $echo "*** you link to this library. But I can only do this if you have a"
- $echo "*** shared version of the library, which you do not appear to have."
- if test "$module" = yes; then
- $echo "*** But as you try to build a module library, libtool will still create "
- $echo "*** a static module, that should work as long as the dlopening application"
- $echo "*** is linked with the -dlopen flag to resolve symbols at runtime."
- if test -z "$global_symbol_pipe"; then
- $echo
- $echo "*** However, this would only work if libtool was able to extract symbol"
- $echo "*** lists from a program, using \`nm' or equivalent, but libtool could"
- $echo "*** not find such a program. So, this module is probably useless."
- $echo "*** \`nm' from GNU binutils and a full rebuild may help."
- fi
- if test "$build_old_libs" = no; then
- build_libtool_libs=module
- build_old_libs=yes
- else
- build_libtool_libs=no
- fi
- fi
- else
- deplibs="$dir/$old_library $deplibs"
- link_static=yes
- fi
- fi # link shared/static library?
-
- if test "$linkmode" = lib; then
- if test -n "$dependency_libs" &&
- { test "$hardcode_into_libs" != yes ||
- test "$build_old_libs" = yes ||
- test "$link_static" = yes; }; then
- # Extract -R from dependency_libs
- temp_deplibs=
- for libdir in $dependency_libs; do
- case $libdir in
- -R*) temp_xrpath=`$echo "X$libdir" | $Xsed -e 's/^-R//'`
- case " $xrpath " in
- *" $temp_xrpath "*) ;;
- *) xrpath="$xrpath $temp_xrpath";;
- esac;;
- *) temp_deplibs="$temp_deplibs $libdir";;
- esac
- done
- dependency_libs="$temp_deplibs"
- fi
-
- newlib_search_path="$newlib_search_path $absdir"
- # Link against this library
- test "$link_static" = no && newdependency_libs="$abs_ladir/$laname $newdependency_libs"
- # ... and its dependency_libs
- tmp_libs=
- for deplib in $dependency_libs; do
- newdependency_libs="$deplib $newdependency_libs"
- if test "X$duplicate_deps" = "Xyes" ; then
- case "$tmp_libs " in
- *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;;
- esac
- fi
- tmp_libs="$tmp_libs $deplib"
- done
-
- if test "$link_all_deplibs" != no; then
- # Add the search paths of all dependency libraries
- for deplib in $dependency_libs; do
- case $deplib in
- -L*) path="$deplib" ;;
- *.la)
- dir=`$echo "X$deplib" | $Xsed -e 's%/[^/]*$%%'`
- test "X$dir" = "X$deplib" && dir="."
- # We need an absolute path.
- case $dir in
- [\\/]* | [A-Za-z]:[\\/]*) absdir="$dir" ;;
- *)
- absdir=`cd "$dir" && pwd`
- if test -z "$absdir"; then
- $echo "$modename: warning: cannot determine absolute directory name of \`$dir'" 1>&2
- absdir="$dir"
- fi
- ;;
- esac
- if grep "^installed=no" $deplib > /dev/null; then
- path="$absdir/$objdir"
- else
- eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib`
- if test -z "$libdir"; then
- $echo "$modename: \`$deplib' is not a valid libtool archive" 1>&2
- exit $EXIT_FAILURE
- fi
- if test "$absdir" != "$libdir"; then
- $echo "$modename: warning: \`$deplib' seems to be moved" 1>&2
- fi
- path="$absdir"
- fi
- depdepl=
- case $host in
- *-*-darwin*)
- # we do not want to link against static libs,
- # but need to link against shared
- eval deplibrary_names=`${SED} -n -e 's/^library_names=\(.*\)$/\1/p' $deplib`
- if test -n "$deplibrary_names" ; then
- for tmp in $deplibrary_names ; do
- depdepl=$tmp
- done
- if test -f "$path/$depdepl" ; then
- depdepl="$path/$depdepl"
- fi
- # do not add paths which are already there
- case " $newlib_search_path " in
- *" $path "*) ;;
- *) newlib_search_path="$newlib_search_path $path";;
- esac
- fi
- path=""
- ;;
- *)
- path="-L$path"
- ;;
- esac
- ;;
- -l*)
- case $host in
- *-*-darwin*)
- # Again, we only want to link against shared libraries
- eval tmp_libs=`$echo "X$deplib" | $Xsed -e "s,^\-l,,"`
- for tmp in $newlib_search_path ; do
- if test -f "$tmp/lib$tmp_libs.dylib" ; then
- eval depdepl="$tmp/lib$tmp_libs.dylib"
- break
- fi
- done
- path=""
- ;;
- *) continue ;;
- esac
- ;;
- *) continue ;;
- esac
- case " $deplibs " in
- *" $path "*) ;;
- *) deplibs="$path $deplibs" ;;
- esac
- case " $deplibs " in
- *" $depdepl "*) ;;
- *) deplibs="$depdepl $deplibs" ;;
- esac
- done
- fi # link_all_deplibs != no
- fi # linkmode = lib
- done # for deplib in $libs
- dependency_libs="$newdependency_libs"
- if test "$pass" = dlpreopen; then
- # Link the dlpreopened libraries before other libraries
- for deplib in $save_deplibs; do
- deplibs="$deplib $deplibs"
- done
- fi
- if test "$pass" != dlopen; then
- if test "$pass" != conv; then
- # Make sure lib_search_path contains only unique directories.
- lib_search_path=
- for dir in $newlib_search_path; do
- case "$lib_search_path " in
- *" $dir "*) ;;
- *) lib_search_path="$lib_search_path $dir" ;;
- esac
- done
- newlib_search_path=
- fi
-
- if test "$linkmode,$pass" != "prog,link"; then
- vars="deplibs"
- else
- vars="compile_deplibs finalize_deplibs"
- fi
- for var in $vars dependency_libs; do
- # Add libraries to $var in reverse order
- eval tmp_libs=\"\$$var\"
- new_libs=
- for deplib in $tmp_libs; do
- # FIXME: Pedantically, this is the right thing to do, so
- # that some nasty dependency loop isn't accidentally
- # broken:
- #new_libs="$deplib $new_libs"
- # Pragmatically, this seems to cause very few problems in
- # practice:
- case $deplib in
- -L*) new_libs="$deplib $new_libs" ;;
- -R*) ;;
- *)
- # And here is the reason: when a library appears more
- # than once as an explicit dependence of a library, or
- # is implicitly linked in more than once by the
- # compiler, it is considered special, and multiple
- # occurrences thereof are not removed. Compare this
- # with having the same library being listed as a
- # dependency of multiple other libraries: in this case,
- # we know (pedantically, we assume) the library does not
- # need to be listed more than once, so we keep only the
- # last copy. This is not always right, but it is rare
- # enough that we require users that really mean to play
- # such unportable linking tricks to link the library
- # using -Wl,-lname, so that libtool does not consider it
- # for duplicate removal.
- case " $specialdeplibs " in
- *" $deplib "*) new_libs="$deplib $new_libs" ;;
- *)
- case " $new_libs " in
- *" $deplib "*) ;;
- *) new_libs="$deplib $new_libs" ;;
- esac
- ;;
- esac
- ;;
- esac
- done
- tmp_libs=
- for deplib in $new_libs; do
- case $deplib in
- -L*)
- case " $tmp_libs " in
- *" $deplib "*) ;;
- *) tmp_libs="$tmp_libs $deplib" ;;
- esac
- ;;
- *) tmp_libs="$tmp_libs $deplib" ;;
- esac
- done
- eval $var=\"$tmp_libs\"
- done # for var
- fi
- # Last step: remove runtime libs from dependency_libs
- # (they stay in deplibs)
- tmp_libs=
- for i in $dependency_libs ; do
- case " $predeps $postdeps $compiler_lib_search_path " in
- *" $i "*)
- i=""
- ;;
- esac
- if test -n "$i" ; then
- tmp_libs="$tmp_libs $i"
- fi
- done
- dependency_libs=$tmp_libs
- done # for pass
- if test "$linkmode" = prog; then
- dlfiles="$newdlfiles"
- dlprefiles="$newdlprefiles"
- fi
-
- case $linkmode in
- oldlib)
- if test -n "$deplibs"; then
- $echo "$modename: warning: \`-l' and \`-L' are ignored for archives" 1>&2
- fi
-
- if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
- $echo "$modename: warning: \`-dlopen' is ignored for archives" 1>&2
- fi
-
- if test -n "$rpath"; then
- $echo "$modename: warning: \`-rpath' is ignored for archives" 1>&2
- fi
-
- if test -n "$xrpath"; then
- $echo "$modename: warning: \`-R' is ignored for archives" 1>&2
- fi
-
- if test -n "$vinfo"; then
- $echo "$modename: warning: \`-version-info/-version-number' is ignored for archives" 1>&2
- fi
-
- if test -n "$release"; then
- $echo "$modename: warning: \`-release' is ignored for archives" 1>&2
- fi
-
- if test -n "$export_symbols" || test -n "$export_symbols_regex"; then
- $echo "$modename: warning: \`-export-symbols' is ignored for archives" 1>&2
- fi
-
- # Now set the variables for building old libraries.
- build_libtool_libs=no
- oldlibs="$output"
- objs="$objs$old_deplibs"
- ;;
-
- lib)
- # Make sure we only generate libraries of the form `libNAME.la'.
- case $outputname in
- lib*)
- name=`$echo "X$outputname" | $Xsed -e 's/\.la$//' -e 's/^lib//'`
- eval shared_ext=\"$shrext_cmds\"
- eval libname=\"$libname_spec\"
- ;;
- *)
- if test "$module" = no; then
- $echo "$modename: libtool library \`$output' must begin with \`lib'" 1>&2
- $echo "$help" 1>&2
- exit $EXIT_FAILURE
- fi
- if test "$need_lib_prefix" != no; then
- # Add the "lib" prefix for modules if required
- name=`$echo "X$outputname" | $Xsed -e 's/\.la$//'`
- eval shared_ext=\"$shrext_cmds\"
- eval libname=\"$libname_spec\"
- else
- libname=`$echo "X$outputname" | $Xsed -e 's/\.la$//'`
- fi
- ;;
- esac
-
- if test -n "$objs"; then
- if test "$deplibs_check_method" != pass_all; then
- $echo "$modename: cannot build libtool library \`$output' from non-libtool objects on this host:$objs" 2>&1
- exit $EXIT_FAILURE
- else
- $echo
- $echo "*** Warning: Linking the shared library $output against the non-libtool"
- $echo "*** objects $objs is not portable!"
- libobjs="$libobjs $objs"
- fi
- fi
-
- if test "$dlself" != no; then
- $echo "$modename: warning: \`-dlopen self' is ignored for libtool libraries" 1>&2
- fi
-
- set dummy $rpath
- if test "$#" -gt 2; then
- $echo "$modename: warning: ignoring multiple \`-rpath's for a libtool library" 1>&2
- fi
- install_libdir="$2"
-
- oldlibs=
- if test -z "$rpath"; then
- if test "$build_libtool_libs" = yes; then
- # Building a libtool convenience library.
- # Some compilers have problems with a `.al' extension so
- # convenience libraries should have the same extension an
- # archive normally would.
- oldlibs="$output_objdir/$libname.$libext $oldlibs"
- build_libtool_libs=convenience
- build_old_libs=yes
- fi
-
- if test -n "$vinfo"; then
- $echo "$modename: warning: \`-version-info/-version-number' is ignored for convenience libraries" 1>&2
- fi
-
- if test -n "$release"; then
- $echo "$modename: warning: \`-release' is ignored for convenience libraries" 1>&2
- fi
- else
-
- # Parse the version information argument.
- save_ifs="$IFS"; IFS=':'
- set dummy $vinfo 0 0 0
- IFS="$save_ifs"
-
- if test -n "$8"; then
- $echo "$modename: too many parameters to \`-version-info'" 1>&2
- $echo "$help" 1>&2
- exit $EXIT_FAILURE
- fi
-
- # convert absolute version numbers to libtool ages
- # this retains compatibility with .la files and attempts
- # to make the code below a bit more comprehensible
-
- case $vinfo_number in
- yes)
- number_major="$2"
- number_minor="$3"
- number_revision="$4"
- #
- # There are really only two kinds -- those that
- # use the current revision as the major version
- # and those that subtract age and use age as
- # a minor version. But, then there is irix
- # which has an extra 1 added just for fun
- #
- case $version_type in
- darwin|linux|osf|windows)
- current=`expr $number_major + $number_minor`
- age="$number_minor"
- revision="$number_revision"
- ;;
- freebsd-aout|freebsd-elf|sunos)
- current="$number_major"
- revision="$number_minor"
- age="0"
- ;;
- irix|nonstopux)
- current=`expr $number_major + $number_minor - 1`
- age="$number_minor"
- revision="$number_minor"
- ;;
- *)
- $echo "$modename: unknown library version type \`$version_type'" 1>&2
- $echo "Fatal configuration error. See the $PACKAGE docs for more information." 1>&2
- exit $EXIT_FAILURE
- ;;
- esac
- ;;
- no)
- current="$2"
- revision="$3"
- age="$4"
- ;;
- esac
-
- # Check that each of the things are valid numbers.
- case $current in
- 0|[1-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|[1-9][0-9][0-9][0-9][0-9]) ;;
- *)
- $echo "$modename: CURRENT \`$current' must be a nonnegative integer" 1>&2
- $echo "$modename: \`$vinfo' is not valid version information" 1>&2
- exit $EXIT_FAILURE
- ;;
- esac
-
- case $revision in
- 0|[1-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|[1-9][0-9][0-9][0-9][0-9]) ;;
- *)
- $echo "$modename: REVISION \`$revision' must be a nonnegative integer" 1>&2
- $echo "$modename: \`$vinfo' is not valid version information" 1>&2
- exit $EXIT_FAILURE
- ;;
- esac
-
- case $age in
- 0|[1-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|[1-9][0-9][0-9][0-9][0-9]) ;;
- *)
- $echo "$modename: AGE \`$age' must be a nonnegative integer" 1>&2
- $echo "$modename: \`$vinfo' is not valid version information" 1>&2
- exit $EXIT_FAILURE
- ;;
- esac
-
- if test "$age" -gt "$current"; then
- $echo "$modename: AGE \`$age' is greater than the current interface number \`$current'" 1>&2
- $echo "$modename: \`$vinfo' is not valid version information" 1>&2
- exit $EXIT_FAILURE
- fi
-
- # Calculate the version variables.
- major=
- versuffix=
- verstring=
- case $version_type in
- none) ;;
-
- darwin)
- # Like Linux, but with the current version available in
- # verstring for coding it into the library header
- major=.`expr $current - $age`
- versuffix="$major.$age.$revision"
- # Darwin ld doesn't like 0 for these options...
- minor_current=`expr $current + 1`
- verstring="${wl}-compatibility_version ${wl}$minor_current ${wl}-current_version ${wl}$minor_current.$revision"
- ;;
-
- freebsd-aout)
- major=".$current"
- versuffix=".$current.$revision";
- ;;
-
- freebsd-elf)
- major=".$current"
- versuffix=".$current";
- ;;
-
- irix | nonstopux)
- major=`expr $current - $age + 1`
-
- case $version_type in
- nonstopux) verstring_prefix=nonstopux ;;
- *) verstring_prefix=sgi ;;
- esac
- verstring="$verstring_prefix$major.$revision"
-
- # Add in all the interfaces that we are compatible with.
- loop=$revision
- while test "$loop" -ne 0; do
- iface=`expr $revision - $loop`
- loop=`expr $loop - 1`
- verstring="$verstring_prefix$major.$iface:$verstring"
- done
-
- # Before this point, $major must not contain `.'.
- major=.$major
- versuffix="$major.$revision"
- ;;
-
- linux)
- major=.`expr $current - $age`
- versuffix="$major.$age.$revision"
- ;;
-
- osf)
- major=.`expr $current - $age`
- versuffix=".$current.$age.$revision"
- verstring="$current.$age.$revision"
-
- # Add in all the interfaces that we are compatible with.
- loop=$age
- while test "$loop" -ne 0; do
- iface=`expr $current - $loop`
- loop=`expr $loop - 1`
- verstring="$verstring:${iface}.0"
- done
-
- # Make executables depend on our current version.
- verstring="$verstring:${current}.0"
- ;;
-
- sunos)
- major=".$current"
- versuffix=".$current.$revision"
- ;;
-
- windows)
- # Use '-' rather than '.', since we only want one
- # extension on DOS 8.3 filesystems.
- major=`expr $current - $age`
- versuffix="-$major"
- ;;
-
- *)
- $echo "$modename: unknown library version type \`$version_type'" 1>&2
- $echo "Fatal configuration error. See the $PACKAGE docs for more information." 1>&2
- exit $EXIT_FAILURE
- ;;
- esac
-
- # Clear the version info if we defaulted, and they specified a release.
- if test -z "$vinfo" && test -n "$release"; then
- major=
- case $version_type in
- darwin)
- # we can't check for "0.0" in archive_cmds due to quoting
- # problems, so we reset it completely
- verstring=
- ;;
- *)
- verstring="0.0"
- ;;
- esac
- if test "$need_version" = no; then
- versuffix=
- else
- versuffix=".0.0"
- fi
- fi
-
- # Remove version info from name if versioning should be avoided
- if test "$avoid_version" = yes && test "$need_version" = no; then
- major=
- versuffix=
- verstring=""
- fi
-
- # Check to see if the archive will have undefined symbols.
- if test "$allow_undefined" = yes; then
- if test "$allow_undefined_flag" = unsupported; then
- $echo "$modename: warning: undefined symbols not allowed in $host shared libraries" 1>&2
- build_libtool_libs=no
- build_old_libs=yes
- fi
- else
- # Don't allow undefined symbols.
- allow_undefined_flag="$no_undefined_flag"
- fi
- fi
-
- if test "$mode" != relink; then
- # Remove our outputs, but don't remove object files since they
- # may have been created when compiling PIC objects.
- removelist=
- tempremovelist=`$echo "$output_objdir/*"`
- for p in $tempremovelist; do
- case $p in
- *.$objext)
- ;;
- $output_objdir/$outputname | $output_objdir/$libname.* | $output_objdir/${libname}${release}.*)
- if test "X$precious_files_regex" != "X"; then
- if echo $p | $EGREP -e "$precious_files_regex" >/dev/null 2>&1
- then
- continue
- fi
- fi
- removelist="$removelist $p"
- ;;
- *) ;;
- esac
- done
- if test -n "$removelist"; then
- $show "${rm}r $removelist"
- $run ${rm}r $removelist
- fi
- fi
-
- # Now set the variables for building old libraries.
- if test "$build_old_libs" = yes && test "$build_libtool_libs" != convenience ; then
- oldlibs="$oldlibs $output_objdir/$libname.$libext"
-
- # Transform .lo files to .o files.
- oldobjs="$objs "`$echo "X$libobjs" | $SP2NL | $Xsed -e '/\.'${libext}'$/d' -e "$lo2o" | $NL2SP`
- fi
-
- # Eliminate all temporary directories.
- for path in $notinst_path; do
- lib_search_path=`$echo "$lib_search_path " | ${SED} -e "s% $path % %g"`
- deplibs=`$echo "$deplibs " | ${SED} -e "s% -L$path % %g"`
- dependency_libs=`$echo "$dependency_libs " | ${SED} -e "s% -L$path % %g"`
- done
-
- if test -n "$xrpath"; then
- # If the user specified any rpath flags, then add them.
- temp_xrpath=
- for libdir in $xrpath; do
- temp_xrpath="$temp_xrpath -R$libdir"
- case "$finalize_rpath " in
- *" $libdir "*) ;;
- *) finalize_rpath="$finalize_rpath $libdir" ;;
- esac
- done
- if test "$hardcode_into_libs" != yes || test "$build_old_libs" = yes; then
- dependency_libs="$temp_xrpath $dependency_libs"
- fi
- fi
-
- # Make sure dlfiles contains only unique files that won't be dlpreopened
- old_dlfiles="$dlfiles"
- dlfiles=
- for lib in $old_dlfiles; do
- case " $dlprefiles $dlfiles " in
- *" $lib "*) ;;
- *) dlfiles="$dlfiles $lib" ;;
- esac
- done
-
- # Make sure dlprefiles contains only unique files
- old_dlprefiles="$dlprefiles"
- dlprefiles=
- for lib in $old_dlprefiles; do
- case "$dlprefiles " in
- *" $lib "*) ;;
- *) dlprefiles="$dlprefiles $lib" ;;
- esac
- done
-
- if test "$build_libtool_libs" = yes; then
- if test -n "$rpath"; then
- case $host in
- *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-beos*)
- # these systems don't actually have a c library (as such)!
- ;;
- *-*-rhapsody* | *-*-darwin1.[012])
- # Rhapsody C library is in the System framework
- deplibs="$deplibs -framework System"
- ;;
- *-*-netbsd*)
- # Don't link with libc until the a.out ld.so is fixed.
- ;;
- *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
- # Do not include libc due to us having libc/libc_r.
- ;;
- *-*-sco3.2v5* | *-*-sco5v6*)
- # Causes problems with __ctype
- ;;
- *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*)
- # Compiler inserts libc in the correct place for threads to work
- ;;
- *)
- # Add libc to deplibs on all other systems if necessary.
- if test "$build_libtool_need_lc" = "yes"; then
- deplibs="$deplibs -lc"
- fi
- ;;
- esac
- fi
-
- # Transform deplibs into only deplibs that can be linked in shared.
- name_save=$name
- libname_save=$libname
- release_save=$release
- versuffix_save=$versuffix
- major_save=$major
- # I'm not sure if I'm treating the release correctly. I think
- # release should show up in the -l (ie -lgmp5) so we don't want to
- # add it in twice. Is that correct?
- release=""
- versuffix=""
- major=""
- newdeplibs=
- droppeddeps=no
- case $deplibs_check_method in
- pass_all)
- # Don't check for shared/static. Everything works.
- # This might be a little naive. We might want to check
- # whether the library exists or not. But this is on
- # osf3 & osf4 and I'm not really sure... Just
- # implementing what was already the behavior.
- newdeplibs=$deplibs
- ;;
- test_compile)
- # This code stresses the "libraries are programs" paradigm to its
- # limits. Maybe even breaks it. We compile a program, linking it
- # against the deplibs as a proxy for the library. Then we can check
- # whether they linked in statically or dynamically with ldd.
- $rm conftest.c
- cat > conftest.c <<EOF
- int main() { return 0; }
-EOF
- $rm conftest
- $LTCC $LTCFLAGS -o conftest conftest.c $deplibs
- if test "$?" -eq 0 ; then
- ldd_output=`ldd conftest`
- for i in $deplibs; do
- name=`expr $i : '-l\(.*\)'`
- # If $name is empty we are operating on a -L argument.
- if test "$name" != "" && test "$name" -ne "0"; then
- if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
- case " $predeps $postdeps " in
- *" $i "*)
- newdeplibs="$newdeplibs $i"
- i=""
- ;;
- esac
- fi
- if test -n "$i" ; then
- libname=`eval \\$echo \"$libname_spec\"`
- deplib_matches=`eval \\$echo \"$library_names_spec\"`
- set dummy $deplib_matches
- deplib_match=$2
- if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then
- newdeplibs="$newdeplibs $i"
- else
- droppeddeps=yes
- $echo
- $echo "*** Warning: dynamic linker does not accept needed library $i."
- $echo "*** I have the capability to make that library automatically link in when"
- $echo "*** you link to this library. But I can only do this if you have a"
- $echo "*** shared version of the library, which I believe you do not have"
- $echo "*** because a test_compile did reveal that the linker did not use it for"
- $echo "*** its dynamic dependency list that programs get resolved with at runtime."
- fi
- fi
- else
- newdeplibs="$newdeplibs $i"
- fi
- done
- else
- # Error occurred in the first compile. Let's try to salvage
- # the situation: Compile a separate program for each library.
- for i in $deplibs; do
- name=`expr $i : '-l\(.*\)'`
- # If $name is empty we are operating on a -L argument.
- if test "$name" != "" && test "$name" != "0"; then
- $rm conftest
- $LTCC $LTCFLAGS -o conftest conftest.c $i
- # Did it work?
- if test "$?" -eq 0 ; then
- ldd_output=`ldd conftest`
- if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
- case " $predeps $postdeps " in
- *" $i "*)
- newdeplibs="$newdeplibs $i"
- i=""
- ;;
- esac
- fi
- if test -n "$i" ; then
- libname=`eval \\$echo \"$libname_spec\"`
- deplib_matches=`eval \\$echo \"$library_names_spec\"`
- set dummy $deplib_matches
- deplib_match=$2
- if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then
- newdeplibs="$newdeplibs $i"
- else
- droppeddeps=yes
- $echo
- $echo "*** Warning: dynamic linker does not accept needed library $i."
- $echo "*** I have the capability to make that library automatically link in when"
- $echo "*** you link to this library. But I can only do this if you have a"
- $echo "*** shared version of the library, which you do not appear to have"
- $echo "*** because a test_compile did reveal that the linker did not use this one"
- $echo "*** as a dynamic dependency that programs can get resolved with at runtime."
- fi
- fi
- else
- droppeddeps=yes
- $echo
- $echo "*** Warning! Library $i is needed by this library but I was not able to"
- $echo "*** make it link in! You will probably need to install it or some"
- $echo "*** library that it depends on before this library will be fully"
- $echo "*** functional. Installing it before continuing would be even better."
- fi
- else
- newdeplibs="$newdeplibs $i"
- fi
- done
- fi
- ;;
- file_magic*)
- set dummy $deplibs_check_method
- file_magic_regex=`expr "$deplibs_check_method" : "$2 \(.*\)"`
- for a_deplib in $deplibs; do
- name=`expr $a_deplib : '-l\(.*\)'`
- # If $name is empty we are operating on a -L argument.
- if test "$name" != "" && test "$name" != "0"; then
- if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
- case " $predeps $postdeps " in
- *" $a_deplib "*)
- newdeplibs="$newdeplibs $a_deplib"
- a_deplib=""
- ;;
- esac
- fi
- if test -n "$a_deplib" ; then
- libname=`eval \\$echo \"$libname_spec\"`
- for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do
- potential_libs=`ls $i/$libname[.-]* 2>/dev/null`
- for potent_lib in $potential_libs; do
- # Follow soft links.
- if ls -lLd "$potent_lib" 2>/dev/null \
- | grep " -> " >/dev/null; then
- continue
- fi
- # The statement above tries to avoid entering an
- # endless loop below, in case of cyclic links.
- # We might still enter an endless loop, since a link
- # loop can be closed while we follow links,
- # but so what?
- potlib="$potent_lib"
- while test -h "$potlib" 2>/dev/null; do
- potliblink=`ls -ld $potlib | ${SED} 's/.* -> //'`
- case $potliblink in
- [\\/]* | [A-Za-z]:[\\/]*) potlib="$potliblink";;
- *) potlib=`$echo "X$potlib" | $Xsed -e 's,[^/]*$,,'`"$potliblink";;
- esac
- done
- if eval $file_magic_cmd \"\$potlib\" 2>/dev/null \
- | ${SED} 10q \
- | $EGREP "$file_magic_regex" > /dev/null; then
- newdeplibs="$newdeplibs $a_deplib"
- a_deplib=""
- break 2
- fi
- done
- done
- fi
- if test -n "$a_deplib" ; then
- droppeddeps=yes
- $echo
- $echo "*** Warning: linker path does not have real file for library $a_deplib."
- $echo "*** I have the capability to make that library automatically link in when"
- $echo "*** you link to this library. But I can only do this if you have a"
- $echo "*** shared version of the library, which you do not appear to have"
- $echo "*** because I did check the linker path looking for a file starting"
- if test -z "$potlib" ; then
- $echo "*** with $libname but no candidates were found. (...for file magic test)"
- else
- $echo "*** with $libname and none of the candidates passed a file format test"
- $echo "*** using a file magic. Last file checked: $potlib"
- fi
- fi
- else
- # Add a -L argument.
- newdeplibs="$newdeplibs $a_deplib"
- fi
- done # Gone through all deplibs.
- ;;
- match_pattern*)
- set dummy $deplibs_check_method
- match_pattern_regex=`expr "$deplibs_check_method" : "$2 \(.*\)"`
- for a_deplib in $deplibs; do
- name=`expr $a_deplib : '-l\(.*\)'`
- # If $name is empty we are operating on a -L argument.
- if test -n "$name" && test "$name" != "0"; then
- if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
- case " $predeps $postdeps " in
- *" $a_deplib "*)
- newdeplibs="$newdeplibs $a_deplib"
- a_deplib=""
- ;;
- esac
- fi
- if test -n "$a_deplib" ; then
- libname=`eval \\$echo \"$libname_spec\"`
- for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do
- potential_libs=`ls $i/$libname[.-]* 2>/dev/null`
- for potent_lib in $potential_libs; do
- potlib="$potent_lib" # see symlink-check above in file_magic test
- if eval $echo \"$potent_lib\" 2>/dev/null \
- | ${SED} 10q \
- | $EGREP "$match_pattern_regex" > /dev/null; then
- newdeplibs="$newdeplibs $a_deplib"
- a_deplib=""
- break 2
- fi
- done
- done
- fi
- if test -n "$a_deplib" ; then
- droppeddeps=yes
- $echo
- $echo "*** Warning: linker path does not have real file for library $a_deplib."
- $echo "*** I have the capability to make that library automatically link in when"
- $echo "*** you link to this library. But I can only do this if you have a"
- $echo "*** shared version of the library, which you do not appear to have"
- $echo "*** because I did check the linker path looking for a file starting"
- if test -z "$potlib" ; then
- $echo "*** with $libname but no candidates were found. (...for regex pattern test)"
- else
- $echo "*** with $libname and none of the candidates passed a file format test"
- $echo "*** using a regex pattern. Last file checked: $potlib"
- fi
- fi
- else
- # Add a -L argument.
- newdeplibs="$newdeplibs $a_deplib"
- fi
- done # Gone through all deplibs.
- ;;
- none | unknown | *)
- newdeplibs=""
- tmp_deplibs=`$echo "X $deplibs" | $Xsed -e 's/ -lc$//' \
- -e 's/ -[LR][^ ]*//g'`
- if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
- for i in $predeps $postdeps ; do
- # can't use Xsed below, because $i might contain '/'
- tmp_deplibs=`$echo "X $tmp_deplibs" | ${SED} -e "1s,^X,," -e "s,$i,,"`
- done
- fi
- if $echo "X $tmp_deplibs" | $Xsed -e 's/[ ]//g' \
- | grep . >/dev/null; then
- $echo
- if test "X$deplibs_check_method" = "Xnone"; then
- $echo "*** Warning: inter-library dependencies are not supported in this platform."
- else
- $echo "*** Warning: inter-library dependencies are not known to be supported."
- fi
- $echo "*** All declared inter-library dependencies are being dropped."
- droppeddeps=yes
- fi
- ;;
- esac
- versuffix=$versuffix_save
- major=$major_save
- release=$release_save
- libname=$libname_save
- name=$name_save
-
- case $host in
- *-*-rhapsody* | *-*-darwin1.[012])
- # On Rhapsody replace the C library is the System framework
- newdeplibs=`$echo "X $newdeplibs" | $Xsed -e 's/ -lc / -framework System /'`
- ;;
- esac
-
- if test "$droppeddeps" = yes; then
- if test "$module" = yes; then
- $echo
- $echo "*** Warning: libtool could not satisfy all declared inter-library"
- $echo "*** dependencies of module $libname. Therefore, libtool will create"
- $echo "*** a static module, that should work as long as the dlopening"
- $echo "*** application is linked with the -dlopen flag."
- if test -z "$global_symbol_pipe"; then
- $echo
- $echo "*** However, this would only work if libtool was able to extract symbol"
- $echo "*** lists from a program, using \`nm' or equivalent, but libtool could"
- $echo "*** not find such a program. So, this module is probably useless."
- $echo "*** \`nm' from GNU binutils and a full rebuild may help."
- fi
- if test "$build_old_libs" = no; then
- oldlibs="$output_objdir/$libname.$libext"
- build_libtool_libs=module
- build_old_libs=yes
- else
- build_libtool_libs=no
- fi
- else
- $echo "*** The inter-library dependencies that have been dropped here will be"
- $echo "*** automatically added whenever a program is linked with this library"
- $echo "*** or is declared to -dlopen it."
-
- if test "$allow_undefined" = no; then
- $echo
- $echo "*** Since this library must not contain undefined symbols,"
- $echo "*** because either the platform does not support them or"
- $echo "*** it was explicitly requested with -no-undefined,"
- $echo "*** libtool will only create a static version of it."
- if test "$build_old_libs" = no; then
- oldlibs="$output_objdir/$libname.$libext"
- build_libtool_libs=module
- build_old_libs=yes
- else
- build_libtool_libs=no
- fi
- fi
- fi
- fi
- # Done checking deplibs!
- deplibs=$newdeplibs
- fi
-
-
- # move library search paths that coincide with paths to not yet
- # installed libraries to the beginning of the library search list
- new_libs=
- for path in $notinst_path; do
- case " $new_libs " in
- *" -L$path/$objdir "*) ;;
- *)
- case " $deplibs " in
- *" -L$path/$objdir "*)
- new_libs="$new_libs -L$path/$objdir" ;;
- esac
- ;;
- esac
- done
- for deplib in $deplibs; do
- case $deplib in
- -L*)
- case " $new_libs " in
- *" $deplib "*) ;;
- *) new_libs="$new_libs $deplib" ;;
- esac
- ;;
- *) new_libs="$new_libs $deplib" ;;
- esac
- done
- deplibs="$new_libs"
-
-
- # All the library-specific variables (install_libdir is set above).
- library_names=
- old_library=
- dlname=
-
- # Test again, we may have decided not to build it any more
- if test "$build_libtool_libs" = yes; then
- if test "$hardcode_into_libs" = yes; then
- # Hardcode the library paths
- hardcode_libdirs=
- dep_rpath=
- rpath="$finalize_rpath"
- test "$mode" != relink && rpath="$compile_rpath$rpath"
- for libdir in $rpath; do
- if test -n "$hardcode_libdir_flag_spec"; then
- if test -n "$hardcode_libdir_separator"; then
- if test -z "$hardcode_libdirs"; then
- hardcode_libdirs="$libdir"
- else
- # Just accumulate the unique libdirs.
- case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
- *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
- ;;
- *)
- hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir"
- ;;
- esac
- fi
- else
- eval flag=\"$hardcode_libdir_flag_spec\"
- dep_rpath="$dep_rpath $flag"
- fi
- elif test -n "$runpath_var"; then
- case "$perm_rpath " in
- *" $libdir "*) ;;
- *) perm_rpath="$perm_rpath $libdir" ;;
- esac
- fi
- done
- # Substitute the hardcoded libdirs into the rpath.
- if test -n "$hardcode_libdir_separator" &&
- test -n "$hardcode_libdirs"; then
- libdir="$hardcode_libdirs"
- if test -n "$hardcode_libdir_flag_spec_ld"; then
- eval dep_rpath=\"$hardcode_libdir_flag_spec_ld\"
- else
- eval dep_rpath=\"$hardcode_libdir_flag_spec\"
- fi
- fi
- if test -n "$runpath_var" && test -n "$perm_rpath"; then
- # We should set the runpath_var.
- rpath=
- for dir in $perm_rpath; do
- rpath="$rpath$dir:"
- done
- eval "$runpath_var='$rpath\$$runpath_var'; export $runpath_var"
- fi
- test -n "$dep_rpath" && deplibs="$dep_rpath $deplibs"
- fi
-
- shlibpath="$finalize_shlibpath"
- test "$mode" != relink && shlibpath="$compile_shlibpath$shlibpath"
- if test -n "$shlibpath"; then
- eval "$shlibpath_var='$shlibpath\$$shlibpath_var'; export $shlibpath_var"
- fi
-
- # Get the real and link names of the library.
- eval shared_ext=\"$shrext_cmds\"
- eval library_names=\"$library_names_spec\"
- set dummy $library_names
- realname="$2"
- shift; shift
-
- if test -n "$soname_spec"; then
- eval soname=\"$soname_spec\"
- else
- soname="$realname"
- fi
- if test -z "$dlname"; then
- dlname=$soname
- fi
-
- lib="$output_objdir/$realname"
- linknames=
- for link
- do
- linknames="$linknames $link"
- done
-
- # Use standard objects if they are pic
- test -z "$pic_flag" && libobjs=`$echo "X$libobjs" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP`
-
- # Prepare the list of exported symbols
- if test -z "$export_symbols"; then
- if test "$always_export_symbols" = yes || test -n "$export_symbols_regex"; then
- $show "generating symbol list for \`$libname.la'"
- export_symbols="$output_objdir/$libname.exp"
- $run $rm $export_symbols
- cmds=$export_symbols_cmds
- save_ifs="$IFS"; IFS='~'
- for cmd in $cmds; do
- IFS="$save_ifs"
- eval cmd=\"$cmd\"
- if len=`expr "X$cmd" : ".*"` &&
- test "$len" -le "$max_cmd_len" || test "$max_cmd_len" -le -1; then
- $show "$cmd"
- $run eval "$cmd" || exit $?
- skipped_export=false
- else
- # The command line is too long to execute in one step.
- $show "using reloadable object file for export list..."
- skipped_export=:
- # Break out early, otherwise skipped_export may be
- # set to false by a later but shorter cmd.
- break
- fi
- done
- IFS="$save_ifs"
- if test -n "$export_symbols_regex"; then
- $show "$EGREP -e \"$export_symbols_regex\" \"$export_symbols\" > \"${export_symbols}T\""
- $run eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"'
- $show "$mv \"${export_symbols}T\" \"$export_symbols\""
- $run eval '$mv "${export_symbols}T" "$export_symbols"'
- fi
- fi
- fi
-
- if test -n "$export_symbols" && test -n "$include_expsyms"; then
- $run eval '$echo "X$include_expsyms" | $SP2NL >> "$export_symbols"'
- fi
-
- tmp_deplibs=
- for test_deplib in $deplibs; do
- case " $convenience " in
- *" $test_deplib "*) ;;
- *)
- tmp_deplibs="$tmp_deplibs $test_deplib"
- ;;
- esac
- done
- deplibs="$tmp_deplibs"
-
- if test -n "$convenience"; then
- if test -n "$whole_archive_flag_spec"; then
- save_libobjs=$libobjs
- eval libobjs=\"\$libobjs $whole_archive_flag_spec\"
- else
- gentop="$output_objdir/${outputname}x"
- generated="$generated $gentop"
-
- func_extract_archives $gentop $convenience
- libobjs="$libobjs $func_extract_archives_result"
- fi
- fi
-
- if test "$thread_safe" = yes && test -n "$thread_safe_flag_spec"; then
- eval flag=\"$thread_safe_flag_spec\"
- linker_flags="$linker_flags $flag"
- fi
-
- # Make a backup of the uninstalled library when relinking
- if test "$mode" = relink; then
- $run eval '(cd $output_objdir && $rm ${realname}U && $mv $realname ${realname}U)' || exit $?
- fi
-
- # Do each of the archive commands.
- if test "$module" = yes && test -n "$module_cmds" ; then
- if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then
- eval test_cmds=\"$module_expsym_cmds\"
- cmds=$module_expsym_cmds
- else
- eval test_cmds=\"$module_cmds\"
- cmds=$module_cmds
- fi
- else
- if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then
- eval test_cmds=\"$archive_expsym_cmds\"
- cmds=$archive_expsym_cmds
- else
- eval test_cmds=\"$archive_cmds\"
- cmds=$archive_cmds
- fi
- fi
-
- if test "X$skipped_export" != "X:" &&
- len=`expr "X$test_cmds" : ".*" 2>/dev/null` &&
- test "$len" -le "$max_cmd_len" || test "$max_cmd_len" -le -1; then
- :
- else
- # The command line is too long to link in one step, link piecewise.
- $echo "creating reloadable object files..."
-
- # Save the value of $output and $libobjs because we want to
- # use them later. If we have whole_archive_flag_spec, we
- # want to use save_libobjs as it was before
- # whole_archive_flag_spec was expanded, because we can't
- # assume the linker understands whole_archive_flag_spec.
- # This may have to be revisited, in case too many
- # convenience libraries get linked in and end up exceeding
- # the spec.
- if test -z "$convenience" || test -z "$whole_archive_flag_spec"; then
- save_libobjs=$libobjs
- fi
- save_output=$output
- output_la=`$echo "X$output" | $Xsed -e "$basename"`
-
- # Clear the reloadable object creation command queue and
- # initialize k to one.
- test_cmds=
- concat_cmds=
- objlist=
- delfiles=
- last_robj=
- k=1
- output=$output_objdir/$output_la-${k}.$objext
- # Loop over the list of objects to be linked.
- for obj in $save_libobjs
- do
- eval test_cmds=\"$reload_cmds $objlist $last_robj\"
- if test "X$objlist" = X ||
- { len=`expr "X$test_cmds" : ".*" 2>/dev/null` &&
- test "$len" -le "$max_cmd_len"; }; then
- objlist="$objlist $obj"
- else
- # The command $test_cmds is almost too long, add a
- # command to the queue.
- if test "$k" -eq 1 ; then
- # The first file doesn't have a previous command to add.
- eval concat_cmds=\"$reload_cmds $objlist $last_robj\"
- else
- # All subsequent reloadable object files will link in
- # the last one created.
- eval concat_cmds=\"\$concat_cmds~$reload_cmds $objlist $last_robj\"
- fi
- last_robj=$output_objdir/$output_la-${k}.$objext
- k=`expr $k + 1`
- output=$output_objdir/$output_la-${k}.$objext
- objlist=$obj
- len=1
- fi
- done
- # Handle the remaining objects by creating one last
- # reloadable object file. All subsequent reloadable object
- # files will link in the last one created.
- test -z "$concat_cmds" || concat_cmds=$concat_cmds~
- eval concat_cmds=\"\${concat_cmds}$reload_cmds $objlist $last_robj\"
-
- if ${skipped_export-false}; then
- $show "generating symbol list for \`$libname.la'"
- export_symbols="$output_objdir/$libname.exp"
- $run $rm $export_symbols
- libobjs=$output
- # Append the command to create the export file.
- eval concat_cmds=\"\$concat_cmds~$export_symbols_cmds\"
- fi
-
- # Set up a command to remove the reloadable object files
- # after they are used.
- i=0
- while test "$i" -lt "$k"
- do
- i=`expr $i + 1`
- delfiles="$delfiles $output_objdir/$output_la-${i}.$objext"
- done
-
- $echo "creating a temporary reloadable object file: $output"
-
- # Loop through the commands generated above and execute them.
- save_ifs="$IFS"; IFS='~'
- for cmd in $concat_cmds; do
- IFS="$save_ifs"
- $show "$cmd"
- $run eval "$cmd" || exit $?
- done
- IFS="$save_ifs"
-
- libobjs=$output
- # Restore the value of output.
- output=$save_output
-
- if test -n "$convenience" && test -n "$whole_archive_flag_spec"; then
- eval libobjs=\"\$libobjs $whole_archive_flag_spec\"
- fi
- # Expand the library linking commands again to reset the
- # value of $libobjs for piecewise linking.
-
- # Do each of the archive commands.
- if test "$module" = yes && test -n "$module_cmds" ; then
- if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then
- cmds=$module_expsym_cmds
- else
- cmds=$module_cmds
- fi
- else
- if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then
- cmds=$archive_expsym_cmds
- else
- cmds=$archive_cmds
- fi
- fi
-
- # Append the command to remove the reloadable object files
- # to the just-reset $cmds.
- eval cmds=\"\$cmds~\$rm $delfiles\"
- fi
- save_ifs="$IFS"; IFS='~'
- for cmd in $cmds; do
- IFS="$save_ifs"
- eval cmd=\"$cmd\"
- $show "$cmd"
- $run eval "$cmd" || {
- lt_exit=$?
-
- # Restore the uninstalled library and exit
- if test "$mode" = relink; then
- $run eval '(cd $output_objdir && $rm ${realname}T && $mv ${realname}U $realname)'
- fi
-
- exit $lt_exit
- }
- done
- IFS="$save_ifs"
-
- # Restore the uninstalled library and exit
- if test "$mode" = relink; then
- $run eval '(cd $output_objdir && $rm ${realname}T && $mv $realname ${realname}T && $mv "$realname"U $realname)' || exit $?
-
- if test -n "$convenience"; then
- if test -z "$whole_archive_flag_spec"; then
- $show "${rm}r $gentop"
- $run ${rm}r "$gentop"
- fi
- fi
-
- exit $EXIT_SUCCESS
- fi
-
- # Create links to the real library.
- for linkname in $linknames; do
- if test "$realname" != "$linkname"; then
- $show "(cd $output_objdir && $rm $linkname && $LN_S $realname $linkname)"
- $run eval '(cd $output_objdir && $rm $linkname && $LN_S $realname $linkname)' || exit $?
- fi
- done
-
- # If -module or -export-dynamic was specified, set the dlname.
- if test "$module" = yes || test "$export_dynamic" = yes; then
- # On all known operating systems, these are identical.
- dlname="$soname"
- fi
- fi
- ;;
-
- obj)
- if test -n "$deplibs"; then
- $echo "$modename: warning: \`-l' and \`-L' are ignored for objects" 1>&2
- fi
-
- if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
- $echo "$modename: warning: \`-dlopen' is ignored for objects" 1>&2
- fi
-
- if test -n "$rpath"; then
- $echo "$modename: warning: \`-rpath' is ignored for objects" 1>&2
- fi
-
- if test -n "$xrpath"; then
- $echo "$modename: warning: \`-R' is ignored for objects" 1>&2
- fi
-
- if test -n "$vinfo"; then
- $echo "$modename: warning: \`-version-info' is ignored for objects" 1>&2
- fi
-
- if test -n "$release"; then
- $echo "$modename: warning: \`-release' is ignored for objects" 1>&2
- fi
-
- case $output in
- *.lo)
- if test -n "$objs$old_deplibs"; then
- $echo "$modename: cannot build library object \`$output' from non-libtool objects" 1>&2
- exit $EXIT_FAILURE
- fi
- libobj="$output"
- obj=`$echo "X$output" | $Xsed -e "$lo2o"`
- ;;
- *)
- libobj=
- obj="$output"
- ;;
- esac
-
- # Delete the old objects.
- $run $rm $obj $libobj
-
- # Objects from convenience libraries. This assumes
- # single-version convenience libraries. Whenever we create
- # different ones for PIC/non-PIC, this we'll have to duplicate
- # the extraction.
- reload_conv_objs=
- gentop=
- # reload_cmds runs $LD directly, so let us get rid of
- # -Wl from whole_archive_flag_spec
- wl=
-
- if test -n "$convenience"; then
- if test -n "$whole_archive_flag_spec"; then
- eval reload_conv_objs=\"\$reload_objs $whole_archive_flag_spec\"
- else
- gentop="$output_objdir/${obj}x"
- generated="$generated $gentop"
-
- func_extract_archives $gentop $convenience
- reload_conv_objs="$reload_objs $func_extract_archives_result"
- fi
- fi
-
- # Create the old-style object.
- reload_objs="$objs$old_deplibs "`$echo "X$libobjs" | $SP2NL | $Xsed -e '/\.'${libext}$'/d' -e '/\.lib$/d' -e "$lo2o" | $NL2SP`" $reload_conv_objs" ### testsuite: skip nested quoting test
-
- output="$obj"
- cmds=$reload_cmds
- save_ifs="$IFS"; IFS='~'
- for cmd in $cmds; do
- IFS="$save_ifs"
- eval cmd=\"$cmd\"
- $show "$cmd"
- $run eval "$cmd" || exit $?
- done
- IFS="$save_ifs"
-
- # Exit if we aren't doing a library object file.
- if test -z "$libobj"; then
- if test -n "$gentop"; then
- $show "${rm}r $gentop"
- $run ${rm}r $gentop
- fi
-
- exit $EXIT_SUCCESS
- fi
-
- if test "$build_libtool_libs" != yes; then
- if test -n "$gentop"; then
- $show "${rm}r $gentop"
- $run ${rm}r $gentop
- fi
-
- # Create an invalid libtool object if no PIC, so that we don't
- # accidentally link it into a program.
- # $show "echo timestamp > $libobj"
- # $run eval "echo timestamp > $libobj" || exit $?
- exit $EXIT_SUCCESS
- fi
-
- if test -n "$pic_flag" || test "$pic_mode" != default; then
- # Only do commands if we really have different PIC objects.
- reload_objs="$libobjs $reload_conv_objs"
- output="$libobj"
- cmds=$reload_cmds
- save_ifs="$IFS"; IFS='~'
- for cmd in $cmds; do
- IFS="$save_ifs"
- eval cmd=\"$cmd\"
- $show "$cmd"
- $run eval "$cmd" || exit $?
- done
- IFS="$save_ifs"
- fi
-
- if test -n "$gentop"; then
- $show "${rm}r $gentop"
- $run ${rm}r $gentop
- fi
-
- exit $EXIT_SUCCESS
- ;;
-
- prog)
- case $host in
- *cygwin*) output=`$echo $output | ${SED} -e 's,.exe$,,;s,$,.exe,'` ;;
- esac
- if test -n "$vinfo"; then
- $echo "$modename: warning: \`-version-info' is ignored for programs" 1>&2
- fi
-
- if test -n "$release"; then
- $echo "$modename: warning: \`-release' is ignored for programs" 1>&2
- fi
-
- if test "$preload" = yes; then
- if test "$dlopen_support" = unknown && test "$dlopen_self" = unknown &&
- test "$dlopen_self_static" = unknown; then
- $echo "$modename: warning: \`AC_LIBTOOL_DLOPEN' not used. Assuming no dlopen support."
- fi
- fi
-
- case $host in
- *-*-rhapsody* | *-*-darwin1.[012])
- # On Rhapsody replace the C library is the System framework
- compile_deplibs=`$echo "X $compile_deplibs" | $Xsed -e 's/ -lc / -framework System /'`
- finalize_deplibs=`$echo "X $finalize_deplibs" | $Xsed -e 's/ -lc / -framework System /'`
- ;;
- esac
-
- case $host in
- *darwin*)
- # Don't allow lazy linking, it breaks C++ global constructors
- if test "$tagname" = CXX ; then
- compile_command="$compile_command ${wl}-bind_at_load"
- finalize_command="$finalize_command ${wl}-bind_at_load"
- fi
- ;;
- esac
-
-
- # move library search paths that coincide with paths to not yet
- # installed libraries to the beginning of the library search list
- new_libs=
- for path in $notinst_path; do
- case " $new_libs " in
- *" -L$path/$objdir "*) ;;
- *)
- case " $compile_deplibs " in
- *" -L$path/$objdir "*)
- new_libs="$new_libs -L$path/$objdir" ;;
- esac
- ;;
- esac
- done
- for deplib in $compile_deplibs; do
- case $deplib in
- -L*)
- case " $new_libs " in
- *" $deplib "*) ;;
- *) new_libs="$new_libs $deplib" ;;
- esac
- ;;
- *) new_libs="$new_libs $deplib" ;;
- esac
- done
- compile_deplibs="$new_libs"
-
-
- compile_command="$compile_command $compile_deplibs"
- finalize_command="$finalize_command $finalize_deplibs"
-
- if test -n "$rpath$xrpath"; then
- # If the user specified any rpath flags, then add them.
- for libdir in $rpath $xrpath; do
- # This is the magic to use -rpath.
- case "$finalize_rpath " in
- *" $libdir "*) ;;
- *) finalize_rpath="$finalize_rpath $libdir" ;;
- esac
- done
- fi
-
- # Now hardcode the library paths
- rpath=
- hardcode_libdirs=
- for libdir in $compile_rpath $finalize_rpath; do
- if test -n "$hardcode_libdir_flag_spec"; then
- if test -n "$hardcode_libdir_separator"; then
- if test -z "$hardcode_libdirs"; then
- hardcode_libdirs="$libdir"
- else
- # Just accumulate the unique libdirs.
- case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
- *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
- ;;
- *)
- hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir"
- ;;
- esac
- fi
- else
- eval flag=\"$hardcode_libdir_flag_spec\"
- rpath="$rpath $flag"
- fi
- elif test -n "$runpath_var"; then
- case "$perm_rpath " in
- *" $libdir "*) ;;
- *) perm_rpath="$perm_rpath $libdir" ;;
- esac
- fi
- case $host in
- *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2*)
- testbindir=`$echo "X$libdir" | $Xsed -e 's*/lib$*/bin*'`
- case :$dllsearchpath: in
- *":$libdir:"*) ;;
- *) dllsearchpath="$dllsearchpath:$libdir";;
- esac
- case :$dllsearchpath: in
- *":$testbindir:"*) ;;
- *) dllsearchpath="$dllsearchpath:$testbindir";;
- esac
- ;;
- esac
- done
- # Substitute the hardcoded libdirs into the rpath.
- if test -n "$hardcode_libdir_separator" &&
- test -n "$hardcode_libdirs"; then
- libdir="$hardcode_libdirs"
- eval rpath=\" $hardcode_libdir_flag_spec\"
- fi
- compile_rpath="$rpath"
-
- rpath=
- hardcode_libdirs=
- for libdir in $finalize_rpath; do
- if test -n "$hardcode_libdir_flag_spec"; then
- if test -n "$hardcode_libdir_separator"; then
- if test -z "$hardcode_libdirs"; then
- hardcode_libdirs="$libdir"
- else
- # Just accumulate the unique libdirs.
- case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
- *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
- ;;
- *)
- hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir"
- ;;
- esac
- fi
- else
- eval flag=\"$hardcode_libdir_flag_spec\"
- rpath="$rpath $flag"
- fi
- elif test -n "$runpath_var"; then
- case "$finalize_perm_rpath " in
- *" $libdir "*) ;;
- *) finalize_perm_rpath="$finalize_perm_rpath $libdir" ;;
- esac
- fi
- done
- # Substitute the hardcoded libdirs into the rpath.
- if test -n "$hardcode_libdir_separator" &&
- test -n "$hardcode_libdirs"; then
- libdir="$hardcode_libdirs"
- eval rpath=\" $hardcode_libdir_flag_spec\"
- fi
- finalize_rpath="$rpath"
-
- if test -n "$libobjs" && test "$build_old_libs" = yes; then
- # Transform all the library objects into standard objects.
- compile_command=`$echo "X$compile_command" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP`
- finalize_command=`$echo "X$finalize_command" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP`
- fi
-
- dlsyms=
- if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
- if test -n "$NM" && test -n "$global_symbol_pipe"; then
- dlsyms="${outputname}S.c"
- else
- $echo "$modename: not configured to extract global symbols from dlpreopened files" 1>&2
- fi
- fi
-
- if test -n "$dlsyms"; then
- case $dlsyms in
- "") ;;
- *.c)
- # Discover the nlist of each of the dlfiles.
- nlist="$output_objdir/${outputname}.nm"
-
- $show "$rm $nlist ${nlist}S ${nlist}T"
- $run $rm "$nlist" "${nlist}S" "${nlist}T"
-
- # Parse the name list into a source file.
- $show "creating $output_objdir/$dlsyms"
-
- test -z "$run" && $echo > "$output_objdir/$dlsyms" "\
-/* $dlsyms - symbol resolution table for \`$outputname' dlsym emulation. */
-/* Generated by $PROGRAM - GNU $PACKAGE $VERSION$TIMESTAMP */
-
-#ifdef __cplusplus
-extern \"C\" {
-#endif
-
-/* Prevent the only kind of declaration conflicts we can make. */
-#define lt_preloaded_symbols some_other_symbol
-
-/* External symbol declarations for the compiler. */\
-"
-
- if test "$dlself" = yes; then
- $show "generating symbol list for \`$output'"
-
- test -z "$run" && $echo ': @PROGRAM@ ' > "$nlist"
-
- # Add our own program objects to the symbol list.
- progfiles=`$echo "X$objs$old_deplibs" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP`
- for arg in $progfiles; do
- $show "extracting global C symbols from \`$arg'"
- $run eval "$NM $arg | $global_symbol_pipe >> '$nlist'"
- done
-
- if test -n "$exclude_expsyms"; then
- $run eval '$EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T'
- $run eval '$mv "$nlist"T "$nlist"'
- fi
-
- if test -n "$export_symbols_regex"; then
- $run eval '$EGREP -e "$export_symbols_regex" "$nlist" > "$nlist"T'
- $run eval '$mv "$nlist"T "$nlist"'
- fi
-
- # Prepare the list of exported symbols
- if test -z "$export_symbols"; then
- export_symbols="$output_objdir/$outputname.exp"
- $run $rm $export_symbols
- $run eval "${SED} -n -e '/^: @PROGRAM@ $/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"'
- case $host in
- *cygwin* | *mingw* )
- $run eval "echo EXPORTS "'> "$output_objdir/$outputname.def"'
- $run eval 'cat "$export_symbols" >> "$output_objdir/$outputname.def"'
- ;;
- esac
- else
- $run eval "${SED} -e 's/\([].[*^$]\)/\\\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$outputname.exp"'
- $run eval 'grep -f "$output_objdir/$outputname.exp" < "$nlist" > "$nlist"T'
- $run eval 'mv "$nlist"T "$nlist"'
- case $host in
- *cygwin* | *mingw* )
- $run eval "echo EXPORTS "'> "$output_objdir/$outputname.def"'
- $run eval 'cat "$nlist" >> "$output_objdir/$outputname.def"'
- ;;
- esac
- fi
- fi
-
- for arg in $dlprefiles; do
- $show "extracting global C symbols from \`$arg'"
- name=`$echo "$arg" | ${SED} -e 's%^.*/%%'`
- $run eval '$echo ": $name " >> "$nlist"'
- $run eval "$NM $arg | $global_symbol_pipe >> '$nlist'"
- done
-
- if test -z "$run"; then
- # Make sure we have at least an empty file.
- test -f "$nlist" || : > "$nlist"
-
- if test -n "$exclude_expsyms"; then
- $EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T
- $mv "$nlist"T "$nlist"
- fi
-
- # Try sorting and uniquifying the output.
- if grep -v "^: " < "$nlist" |
- if sort -k 3 </dev/null >/dev/null 2>&1; then
- sort -k 3
- else
- sort +2
- fi |
- uniq > "$nlist"S; then
- :
- else
- grep -v "^: " < "$nlist" > "$nlist"S
- fi
-
- if test -f "$nlist"S; then
- eval "$global_symbol_to_cdecl"' < "$nlist"S >> "$output_objdir/$dlsyms"'
- else
- $echo '/* NONE */' >> "$output_objdir/$dlsyms"
- fi
-
- $echo >> "$output_objdir/$dlsyms" "\
-
-#undef lt_preloaded_symbols
-
-#if defined (__STDC__) && __STDC__
-# define lt_ptr void *
-#else
-# define lt_ptr char *
-# define const
-#endif
-
-/* The mapping between symbol names and symbols. */
-"
-
- case $host in
- *cygwin* | *mingw* )
- $echo >> "$output_objdir/$dlsyms" "\
-/* DATA imports from DLLs on WIN32 can't be const, because
- runtime relocations are performed -- see ld's documentation
- on pseudo-relocs */
-struct {
-"
- ;;
- * )
- $echo >> "$output_objdir/$dlsyms" "\
-const struct {
-"
- ;;
- esac
-
-
- $echo >> "$output_objdir/$dlsyms" "\
- const char *name;
- lt_ptr address;
-}
-lt_preloaded_symbols[] =
-{\
-"
-
- eval "$global_symbol_to_c_name_address" < "$nlist" >> "$output_objdir/$dlsyms"
-
- $echo >> "$output_objdir/$dlsyms" "\
- {0, (lt_ptr) 0}
-};
-
-/* This works around a problem in FreeBSD linker */
-#ifdef FREEBSD_WORKAROUND
-static const void *lt_preloaded_setup() {
- return lt_preloaded_symbols;
-}
-#endif
-
-#ifdef __cplusplus
-}
-#endif\
-"
- fi
-
- pic_flag_for_symtable=
- case $host in
- # compiling the symbol table file with pic_flag works around
- # a FreeBSD bug that causes programs to crash when -lm is
- # linked before any other PIC object. But we must not use
- # pic_flag when linking with -static. The problem exists in
- # FreeBSD 2.2.6 and is fixed in FreeBSD 3.1.
- *-*-freebsd2*|*-*-freebsd3.0*|*-*-freebsdelf3.0*)
- case "$compile_command " in
- *" -static "*) ;;
- *) pic_flag_for_symtable=" $pic_flag -DFREEBSD_WORKAROUND";;
- esac;;
- *-*-hpux*)
- case "$compile_command " in
- *" -static "*) ;;
- *) pic_flag_for_symtable=" $pic_flag";;
- esac
- esac
-
- # Now compile the dynamic symbol file.
- $show "(cd $output_objdir && $LTCC $LTCFLAGS -c$no_builtin_flag$pic_flag_for_symtable \"$dlsyms\")"
- $run eval '(cd $output_objdir && $LTCC $LTCFLAGS -c$no_builtin_flag$pic_flag_for_symtable "$dlsyms")' || exit $?
-
- # Clean up the generated files.
- $show "$rm $output_objdir/$dlsyms $nlist ${nlist}S ${nlist}T"
- $run $rm "$output_objdir/$dlsyms" "$nlist" "${nlist}S" "${nlist}T"
-
- # Transform the symbol file into the correct name.
- case $host in
- *cygwin* | *mingw* )
- if test -f "$output_objdir/${outputname}.def" ; then
- compile_command=`$echo "X$compile_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}.def $output_objdir/${outputname}S.${objext}%"`
- finalize_command=`$echo "X$finalize_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}.def $output_objdir/${outputname}S.${objext}%"`
- else
- compile_command=`$echo "X$compile_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}S.${objext}%"`
- finalize_command=`$echo "X$finalize_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}S.${objext}%"`
- fi
- ;;
- * )
- compile_command=`$echo "X$compile_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}S.${objext}%"`
- finalize_command=`$echo "X$finalize_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}S.${objext}%"`
- ;;
- esac
- ;;
- *)
- $echo "$modename: unknown suffix for \`$dlsyms'" 1>&2
- exit $EXIT_FAILURE
- ;;
- esac
- else
- # We keep going just in case the user didn't refer to
- # lt_preloaded_symbols. The linker will fail if global_symbol_pipe
- # really was required.
-
- # Nullify the symbol file.
- compile_command=`$echo "X$compile_command" | $Xsed -e "s% @SYMFILE@%%"`
- finalize_command=`$echo "X$finalize_command" | $Xsed -e "s% @SYMFILE@%%"`
- fi
-
- if test "$need_relink" = no || test "$build_libtool_libs" != yes; then
- # Replace the output file specification.
- compile_command=`$echo "X$compile_command" | $Xsed -e 's%@OUTPUT@%'"$output"'%g'`
- link_command="$compile_command$compile_rpath"
-
- # We have no uninstalled library dependencies, so finalize right now.
- $show "$link_command"
- $run eval "$link_command"
- exit_status=$?
-
- # Delete the generated files.
- if test -n "$dlsyms"; then
- $show "$rm $output_objdir/${outputname}S.${objext}"
- $run $rm "$output_objdir/${outputname}S.${objext}"
- fi
-
- exit $exit_status
- fi
-
- if test -n "$shlibpath_var"; then
- # We should set the shlibpath_var
- rpath=
- for dir in $temp_rpath; do
- case $dir in
- [\\/]* | [A-Za-z]:[\\/]*)
- # Absolute path.
- rpath="$rpath$dir:"
- ;;
- *)
- # Relative path: add a thisdir entry.
- rpath="$rpath\$thisdir/$dir:"
- ;;
- esac
- done
- temp_rpath="$rpath"
- fi
-
- if test -n "$compile_shlibpath$finalize_shlibpath"; then
- compile_command="$shlibpath_var=\"$compile_shlibpath$finalize_shlibpath\$$shlibpath_var\" $compile_command"
- fi
- if test -n "$finalize_shlibpath"; then
- finalize_command="$shlibpath_var=\"$finalize_shlibpath\$$shlibpath_var\" $finalize_command"
- fi
-
- compile_var=
- finalize_var=
- if test -n "$runpath_var"; then
- if test -n "$perm_rpath"; then
- # We should set the runpath_var.
- rpath=
- for dir in $perm_rpath; do
- rpath="$rpath$dir:"
- done
- compile_var="$runpath_var=\"$rpath\$$runpath_var\" "
- fi
- if test -n "$finalize_perm_rpath"; then
- # We should set the runpath_var.
- rpath=
- for dir in $finalize_perm_rpath; do
- rpath="$rpath$dir:"
- done
- finalize_var="$runpath_var=\"$rpath\$$runpath_var\" "
- fi
- fi
-
- if test "$no_install" = yes; then
- # We don't need to create a wrapper script.
- link_command="$compile_var$compile_command$compile_rpath"
- # Replace the output file specification.
- link_command=`$echo "X$link_command" | $Xsed -e 's%@OUTPUT@%'"$output"'%g'`
- # Delete the old output file.
- $run $rm $output
- # Link the executable and exit
- $show "$link_command"
- $run eval "$link_command" || exit $?
- exit $EXIT_SUCCESS
- fi
-
- if test "$hardcode_action" = relink; then
- # Fast installation is not supported
- link_command="$compile_var$compile_command$compile_rpath"
- relink_command="$finalize_var$finalize_command$finalize_rpath"
-
- $echo "$modename: warning: this platform does not like uninstalled shared libraries" 1>&2
- $echo "$modename: \`$output' will be relinked during installation" 1>&2
- else
- if test "$fast_install" != no; then
- link_command="$finalize_var$compile_command$finalize_rpath"
- if test "$fast_install" = yes; then
- relink_command=`$echo "X$compile_var$compile_command$compile_rpath" | $Xsed -e 's%@OUTPUT@%\$progdir/\$file%g'`
- else
- # fast_install is set to needless
- relink_command=
- fi
- else
- link_command="$compile_var$compile_command$compile_rpath"
- relink_command="$finalize_var$finalize_command$finalize_rpath"
- fi
- fi
-
- # Replace the output file specification.
- link_command=`$echo "X$link_command" | $Xsed -e 's%@OUTPUT@%'"$output_objdir/$outputname"'%g'`
-
- # Delete the old output files.
- $run $rm $output $output_objdir/$outputname $output_objdir/lt-$outputname
-
- $show "$link_command"
- $run eval "$link_command" || exit $?
-
- # Now create the wrapper script.
- $show "creating $output"
-
- # Quote the relink command for shipping.
- if test -n "$relink_command"; then
- # Preserve any variables that may affect compiler behavior
- for var in $variables_saved_for_relink; do
- if eval test -z \"\${$var+set}\"; then
- relink_command="{ test -z \"\${$var+set}\" || unset $var || { $var=; export $var; }; }; $relink_command"
- elif eval var_value=\$$var; test -z "$var_value"; then
- relink_command="$var=; export $var; $relink_command"
- else
- var_value=`$echo "X$var_value" | $Xsed -e "$sed_quote_subst"`
- relink_command="$var=\"$var_value\"; export $var; $relink_command"
- fi
- done
- relink_command="(cd `pwd`; $relink_command)"
- relink_command=`$echo "X$relink_command" | $Xsed -e "$sed_quote_subst"`
- fi
-
- # Quote $echo for shipping.
- if test "X$echo" = "X$SHELL $progpath --fallback-echo"; then
- case $progpath in
- [\\/]* | [A-Za-z]:[\\/]*) qecho="$SHELL $progpath --fallback-echo";;
- *) qecho="$SHELL `pwd`/$progpath --fallback-echo";;
- esac
- qecho=`$echo "X$qecho" | $Xsed -e "$sed_quote_subst"`
- else
- qecho=`$echo "X$echo" | $Xsed -e "$sed_quote_subst"`
- fi
-
- # Only actually do things if our run command is non-null.
- if test -z "$run"; then
- # win32 will think the script is a binary if it has
- # a .exe suffix, so we strip it off here.
- case $output in
- *.exe) output=`$echo $output|${SED} 's,.exe$,,'` ;;
- esac
- # test for cygwin because mv fails w/o .exe extensions
- case $host in
- *cygwin*)
- exeext=.exe
- outputname=`$echo $outputname|${SED} 's,.exe$,,'` ;;
- *) exeext= ;;
- esac
- case $host in
- *cygwin* | *mingw* )
- output_name=`basename $output`
- output_path=`dirname $output`
- cwrappersource="$output_path/$objdir/lt-$output_name.c"
- cwrapper="$output_path/$output_name.exe"
- $rm $cwrappersource $cwrapper
- trap "$rm $cwrappersource $cwrapper; exit $EXIT_FAILURE" 1 2 15
-
- cat > $cwrappersource <<EOF
-
-/* $cwrappersource - temporary wrapper executable for $objdir/$outputname
- Generated by $PROGRAM - GNU $PACKAGE $VERSION$TIMESTAMP
-
- The $output program cannot be directly executed until all the libtool
- libraries that it depends on are installed.
-
- This wrapper executable should never be moved out of the build directory.
- If it is, it will not operate correctly.
-
- Currently, it simply execs the wrapper *script* "/bin/sh $output",
- but could eventually absorb all of the scripts functionality and
- exec $objdir/$outputname directly.
-*/
-EOF
- cat >> $cwrappersource<<"EOF"
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <malloc.h>
-#include <stdarg.h>
-#include <assert.h>
-#include <string.h>
-#include <ctype.h>
-#include <sys/stat.h>
-
-#if defined(PATH_MAX)
-# define LT_PATHMAX PATH_MAX
-#elif defined(MAXPATHLEN)
-# define LT_PATHMAX MAXPATHLEN
-#else
-# define LT_PATHMAX 1024
-#endif
-
-#ifndef DIR_SEPARATOR
-# define DIR_SEPARATOR '/'
-# define PATH_SEPARATOR ':'
-#endif
-
-#if defined (_WIN32) || defined (__MSDOS__) || defined (__DJGPP__) || \
- defined (__OS2__)
-# define HAVE_DOS_BASED_FILE_SYSTEM
-# ifndef DIR_SEPARATOR_2
-# define DIR_SEPARATOR_2 '\\'
-# endif
-# ifndef PATH_SEPARATOR_2
-# define PATH_SEPARATOR_2 ';'
-# endif
-#endif
-
-#ifndef DIR_SEPARATOR_2
-# define IS_DIR_SEPARATOR(ch) ((ch) == DIR_SEPARATOR)
-#else /* DIR_SEPARATOR_2 */
-# define IS_DIR_SEPARATOR(ch) \
- (((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2))
-#endif /* DIR_SEPARATOR_2 */
-
-#ifndef PATH_SEPARATOR_2
-# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR)
-#else /* PATH_SEPARATOR_2 */
-# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR_2)
-#endif /* PATH_SEPARATOR_2 */
-
-#define XMALLOC(type, num) ((type *) xmalloc ((num) * sizeof(type)))
-#define XFREE(stale) do { \
- if (stale) { free ((void *) stale); stale = 0; } \
-} while (0)
-
-/* -DDEBUG is fairly common in CFLAGS. */
-#undef DEBUG
-#if defined DEBUGWRAPPER
-# define DEBUG(format, ...) fprintf(stderr, format, __VA_ARGS__)
-#else
-# define DEBUG(format, ...)
-#endif
-
-const char *program_name = NULL;
-
-void * xmalloc (size_t num);
-char * xstrdup (const char *string);
-const char * base_name (const char *name);
-char * find_executable(const char *wrapper);
-int check_executable(const char *path);
-char * strendzap(char *str, const char *pat);
-void lt_fatal (const char *message, ...);
-
-int
-main (int argc, char *argv[])
-{
- char **newargz;
- int i;
-
- program_name = (char *) xstrdup (base_name (argv[0]));
- DEBUG("(main) argv[0] : %s\n",argv[0]);
- DEBUG("(main) program_name : %s\n",program_name);
- newargz = XMALLOC(char *, argc+2);
-EOF
-
- cat >> $cwrappersource <<EOF
- newargz[0] = (char *) xstrdup("$SHELL");
-EOF
-
- cat >> $cwrappersource <<"EOF"
- newargz[1] = find_executable(argv[0]);
- if (newargz[1] == NULL)
- lt_fatal("Couldn't find %s", argv[0]);
- DEBUG("(main) found exe at : %s\n",newargz[1]);
- /* we know the script has the same name, without the .exe */
- /* so make sure newargz[1] doesn't end in .exe */
- strendzap(newargz[1],".exe");
- for (i = 1; i < argc; i++)
- newargz[i+1] = xstrdup(argv[i]);
- newargz[argc+1] = NULL;
-
- for (i=0; i<argc+1; i++)
- {
- DEBUG("(main) newargz[%d] : %s\n",i,newargz[i]);
- ;
- }
-
-EOF
-
- case $host_os in
- mingw*)
- cat >> $cwrappersource <<EOF
- execv("$SHELL",(char const **)newargz);
-EOF
- ;;
- *)
- cat >> $cwrappersource <<EOF
- execv("$SHELL",newargz);
-EOF
- ;;
- esac
-
- cat >> $cwrappersource <<"EOF"
- return 127;
-}
-
-void *
-xmalloc (size_t num)
-{
- void * p = (void *) malloc (num);
- if (!p)
- lt_fatal ("Memory exhausted");
-
- return p;
-}
-
-char *
-xstrdup (const char *string)
-{
- return string ? strcpy ((char *) xmalloc (strlen (string) + 1), string) : NULL
-;
-}
-
-const char *
-base_name (const char *name)
-{
- const char *base;
-
-#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
- /* Skip over the disk name in MSDOS pathnames. */
- if (isalpha ((unsigned char)name[0]) && name[1] == ':')
- name += 2;
-#endif
-
- for (base = name; *name; name++)
- if (IS_DIR_SEPARATOR (*name))
- base = name + 1;
- return base;
-}
-
-int
-check_executable(const char * path)
-{
- struct stat st;
-
- DEBUG("(check_executable) : %s\n", path ? (*path ? path : "EMPTY!") : "NULL!");
- if ((!path) || (!*path))
- return 0;
-
- if ((stat (path, &st) >= 0) &&
- (
- /* MinGW & native WIN32 do not support S_IXOTH or S_IXGRP */
-#if defined (S_IXOTH)
- ((st.st_mode & S_IXOTH) == S_IXOTH) ||
-#endif
-#if defined (S_IXGRP)
- ((st.st_mode & S_IXGRP) == S_IXGRP) ||
-#endif
- ((st.st_mode & S_IXUSR) == S_IXUSR))
- )
- return 1;
- else
- return 0;
-}
-
-/* Searches for the full path of the wrapper. Returns
- newly allocated full path name if found, NULL otherwise */
-char *
-find_executable (const char* wrapper)
-{
- int has_slash = 0;
- const char* p;
- const char* p_next;
- /* static buffer for getcwd */
- char tmp[LT_PATHMAX + 1];
- int tmp_len;
- char* concat_name;
-
- DEBUG("(find_executable) : %s\n", wrapper ? (*wrapper ? wrapper : "EMPTY!") : "NULL!");
-
- if ((wrapper == NULL) || (*wrapper == '\0'))
- return NULL;
-
- /* Absolute path? */
-#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
- if (isalpha ((unsigned char)wrapper[0]) && wrapper[1] == ':')
- {
- concat_name = xstrdup (wrapper);
- if (check_executable(concat_name))
- return concat_name;
- XFREE(concat_name);
- }
- else
- {
-#endif
- if (IS_DIR_SEPARATOR (wrapper[0]))
- {
- concat_name = xstrdup (wrapper);
- if (check_executable(concat_name))
- return concat_name;
- XFREE(concat_name);
- }
-#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
- }
-#endif
-
- for (p = wrapper; *p; p++)
- if (*p == '/')
- {
- has_slash = 1;
- break;
- }
- if (!has_slash)
- {
- /* no slashes; search PATH */
- const char* path = getenv ("PATH");
- if (path != NULL)
- {
- for (p = path; *p; p = p_next)
- {
- const char* q;
- size_t p_len;
- for (q = p; *q; q++)
- if (IS_PATH_SEPARATOR(*q))
- break;
- p_len = q - p;
- p_next = (*q == '\0' ? q : q + 1);
- if (p_len == 0)
- {
- /* empty path: current directory */
- if (getcwd (tmp, LT_PATHMAX) == NULL)
- lt_fatal ("getcwd failed");
- tmp_len = strlen(tmp);
- concat_name = XMALLOC(char, tmp_len + 1 + strlen(wrapper) + 1);
- memcpy (concat_name, tmp, tmp_len);
- concat_name[tmp_len] = '/';
- strcpy (concat_name + tmp_len + 1, wrapper);
- }
- else
- {
- concat_name = XMALLOC(char, p_len + 1 + strlen(wrapper) + 1);
- memcpy (concat_name, p, p_len);
- concat_name[p_len] = '/';
- strcpy (concat_name + p_len + 1, wrapper);
- }
- if (check_executable(concat_name))
- return concat_name;
- XFREE(concat_name);
- }
- }
- /* not found in PATH; assume curdir */
- }
- /* Relative path | not found in path: prepend cwd */
- if (getcwd (tmp, LT_PATHMAX) == NULL)
- lt_fatal ("getcwd failed");
- tmp_len = strlen(tmp);
- concat_name = XMALLOC(char, tmp_len + 1 + strlen(wrapper) + 1);
- memcpy (concat_name, tmp, tmp_len);
- concat_name[tmp_len] = '/';
- strcpy (concat_name + tmp_len + 1, wrapper);
-
- if (check_executable(concat_name))
- return concat_name;
- XFREE(concat_name);
- return NULL;
-}
-
-char *
-strendzap(char *str, const char *pat)
-{
- size_t len, patlen;
-
- assert(str != NULL);
- assert(pat != NULL);
-
- len = strlen(str);
- patlen = strlen(pat);
-
- if (patlen <= len)
- {
- str += len - patlen;
- if (strcmp(str, pat) == 0)
- *str = '\0';
- }
- return str;
-}
-
-static void
-lt_error_core (int exit_status, const char * mode,
- const char * message, va_list ap)
-{
- fprintf (stderr, "%s: %s: ", program_name, mode);
- vfprintf (stderr, message, ap);
- fprintf (stderr, ".\n");
-
- if (exit_status >= 0)
- exit (exit_status);
-}
-
-void
-lt_fatal (const char *message, ...)
-{
- va_list ap;
- va_start (ap, message);
- lt_error_core (EXIT_FAILURE, "FATAL", message, ap);
- va_end (ap);
-}
-EOF
- # we should really use a build-platform specific compiler
- # here, but OTOH, the wrappers (shell script and this C one)
- # are only useful if you want to execute the "real" binary.
- # Since the "real" binary is built for $host, then this
- # wrapper might as well be built for $host, too.
- $run $LTCC $LTCFLAGS -s -o $cwrapper $cwrappersource
- ;;
- esac
- $rm $output
- trap "$rm $output; exit $EXIT_FAILURE" 1 2 15
-
- $echo > $output "\
-#! $SHELL
-
-# $output - temporary wrapper script for $objdir/$outputname
-# Generated by $PROGRAM - GNU $PACKAGE $VERSION$TIMESTAMP
-#
-# The $output program cannot be directly executed until all the libtool
-# libraries that it depends on are installed.
-#
-# This wrapper script should never be moved out of the build directory.
-# If it is, it will not operate correctly.
-
-# Sed substitution that helps us do robust quoting. It backslashifies
-# metacharacters that are still active within double-quoted strings.
-Xsed='${SED} -e 1s/^X//'
-sed_quote_subst='$sed_quote_subst'
-
-# The HP-UX ksh and POSIX shell print the target directory to stdout
-# if CDPATH is set.
-(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
-
-relink_command=\"$relink_command\"
-
-# This environment variable determines our operation mode.
-if test \"\$libtool_install_magic\" = \"$magic\"; then
- # install mode needs the following variable:
- notinst_deplibs='$notinst_deplibs'
-else
- # When we are sourced in execute mode, \$file and \$echo are already set.
- if test \"\$libtool_execute_magic\" != \"$magic\"; then
- echo=\"$qecho\"
- file=\"\$0\"
- # Make sure echo works.
- if test \"X\$1\" = X--no-reexec; then
- # Discard the --no-reexec flag, and continue.
- shift
- elif test \"X\`(\$echo '\t') 2>/dev/null\`\" = 'X\t'; then
- # Yippee, \$echo works!
- :
- else
- # Restart under the correct shell, and then maybe \$echo will work.
- exec $SHELL \"\$0\" --no-reexec \${1+\"\$@\"}
- fi
- fi\
-"
- $echo >> $output "\
-
- # Find the directory that this script lives in.
- thisdir=\`\$echo \"X\$file\" | \$Xsed -e 's%/[^/]*$%%'\`
- test \"x\$thisdir\" = \"x\$file\" && thisdir=.
-
- # Follow symbolic links until we get to the real thisdir.
- file=\`ls -ld \"\$file\" | ${SED} -n 's/.*-> //p'\`
- while test -n \"\$file\"; do
- destdir=\`\$echo \"X\$file\" | \$Xsed -e 's%/[^/]*\$%%'\`
-
- # If there was a directory component, then change thisdir.
- if test \"x\$destdir\" != \"x\$file\"; then
- case \"\$destdir\" in
- [\\\\/]* | [A-Za-z]:[\\\\/]*) thisdir=\"\$destdir\" ;;
- *) thisdir=\"\$thisdir/\$destdir\" ;;
- esac
- fi
-
- file=\`\$echo \"X\$file\" | \$Xsed -e 's%^.*/%%'\`
- file=\`ls -ld \"\$thisdir/\$file\" | ${SED} -n 's/.*-> //p'\`
- done
-
- # Try to get the absolute directory name.
- absdir=\`cd \"\$thisdir\" && pwd\`
- test -n \"\$absdir\" && thisdir=\"\$absdir\"
-"
-
- if test "$fast_install" = yes; then
- $echo >> $output "\
- program=lt-'$outputname'$exeext
- progdir=\"\$thisdir/$objdir\"
-
- if test ! -f \"\$progdir/\$program\" || \\
- { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | ${SED} 1q\`; \\
- test \"X\$file\" != \"X\$progdir/\$program\"; }; then
-
- file=\"\$\$-\$program\"
-
- if test ! -d \"\$progdir\"; then
- $mkdir \"\$progdir\"
- else
- $rm \"\$progdir/\$file\"
- fi"
-
- $echo >> $output "\
-
- # relink executable if necessary
- if test -n \"\$relink_command\"; then
- if relink_command_output=\`eval \$relink_command 2>&1\`; then :
- else
- $echo \"\$relink_command_output\" >&2
- $rm \"\$progdir/\$file\"
- exit $EXIT_FAILURE
- fi
- fi
-
- $mv \"\$progdir/\$file\" \"\$progdir/\$program\" 2>/dev/null ||
- { $rm \"\$progdir/\$program\";
- $mv \"\$progdir/\$file\" \"\$progdir/\$program\"; }
- $rm \"\$progdir/\$file\"
- fi"
- else
- $echo >> $output "\
- program='$outputname'
- progdir=\"\$thisdir/$objdir\"
-"
- fi
-
- $echo >> $output "\
-
- if test -f \"\$progdir/\$program\"; then"
-
- # Export our shlibpath_var if we have one.
- if test "$shlibpath_overrides_runpath" = yes && test -n "$shlibpath_var" && test -n "$temp_rpath"; then
- $echo >> $output "\
- # Add our own library path to $shlibpath_var
- $shlibpath_var=\"$temp_rpath\$$shlibpath_var\"
-
- # Some systems cannot cope with colon-terminated $shlibpath_var
- # The second colon is a workaround for a bug in BeOS R4 sed
- $shlibpath_var=\`\$echo \"X\$$shlibpath_var\" | \$Xsed -e 's/::*\$//'\`
-
- export $shlibpath_var
-"
- fi
-
- # fixup the dll searchpath if we need to.
- if test -n "$dllsearchpath"; then
- $echo >> $output "\
- # Add the dll search path components to the executable PATH
- PATH=$dllsearchpath:\$PATH
-"
- fi
-
- $echo >> $output "\
- if test \"\$libtool_execute_magic\" != \"$magic\"; then
- # Run the actual program with our arguments.
-"
- case $host in
- # Backslashes separate directories on plain windows
- *-*-mingw | *-*-os2*)
- $echo >> $output "\
- exec \"\$progdir\\\\\$program\" \${1+\"\$@\"}
-"
- ;;
-
- *)
- $echo >> $output "\
- exec \"\$progdir/\$program\" \${1+\"\$@\"}
-"
- ;;
- esac
- $echo >> $output "\
- \$echo \"\$0: cannot exec \$program \${1+\"\$@\"}\"
- exit $EXIT_FAILURE
- fi
- else
- # The program doesn't exist.
- \$echo \"\$0: error: \\\`\$progdir/\$program' does not exist\" 1>&2
- \$echo \"This script is just a wrapper for \$program.\" 1>&2
- $echo \"See the $PACKAGE documentation for more information.\" 1>&2
- exit $EXIT_FAILURE
- fi
-fi\
-"
- chmod +x $output
- fi
- exit $EXIT_SUCCESS
- ;;
- esac
-
- # See if we need to build an old-fashioned archive.
- for oldlib in $oldlibs; do
-
- if test "$build_libtool_libs" = convenience; then
- oldobjs="$libobjs_save"
- addlibs="$convenience"
- build_libtool_libs=no
- else
- if test "$build_libtool_libs" = module; then
- oldobjs="$libobjs_save"
- build_libtool_libs=no
- else
- oldobjs="$old_deplibs $non_pic_objects"
- fi
- addlibs="$old_convenience"
- fi
-
- if test -n "$addlibs"; then
- gentop="$output_objdir/${outputname}x"
- generated="$generated $gentop"
-
- func_extract_archives $gentop $addlibs
- oldobjs="$oldobjs $func_extract_archives_result"
- fi
-
- # Do each command in the archive commands.
- if test -n "$old_archive_from_new_cmds" && test "$build_libtool_libs" = yes; then
- cmds=$old_archive_from_new_cmds
- else
- # POSIX demands no paths to be encoded in archives. We have
- # to avoid creating archives with duplicate basenames if we
- # might have to extract them afterwards, e.g., when creating a
- # static archive out of a convenience library, or when linking
- # the entirety of a libtool archive into another (currently
- # not supported by libtool).
- if (for obj in $oldobjs
- do
- $echo "X$obj" | $Xsed -e 's%^.*/%%'
- done | sort | sort -uc >/dev/null 2>&1); then
- :
- else
- $echo "copying selected object files to avoid basename conflicts..."
-
- if test -z "$gentop"; then
- gentop="$output_objdir/${outputname}x"
- generated="$generated $gentop"
-
- $show "${rm}r $gentop"
- $run ${rm}r "$gentop"
- $show "$mkdir $gentop"
- $run $mkdir "$gentop"
- exit_status=$?
- if test "$exit_status" -ne 0 && test ! -d "$gentop"; then
- exit $exit_status
- fi
- fi
-
- save_oldobjs=$oldobjs
- oldobjs=
- counter=1
- for obj in $save_oldobjs
- do
- objbase=`$echo "X$obj" | $Xsed -e 's%^.*/%%'`
- case " $oldobjs " in
- " ") oldobjs=$obj ;;
- *[\ /]"$objbase "*)
- while :; do
- # Make sure we don't pick an alternate name that also
- # overlaps.
- newobj=lt$counter-$objbase
- counter=`expr $counter + 1`
- case " $oldobjs " in
- *[\ /]"$newobj "*) ;;
- *) if test ! -f "$gentop/$newobj"; then break; fi ;;
- esac
- done
- $show "ln $obj $gentop/$newobj || cp $obj $gentop/$newobj"
- $run ln "$obj" "$gentop/$newobj" ||
- $run cp "$obj" "$gentop/$newobj"
- oldobjs="$oldobjs $gentop/$newobj"
- ;;
- *) oldobjs="$oldobjs $obj" ;;
- esac
- done
- fi
-
- eval cmds=\"$old_archive_cmds\"
-
- if len=`expr "X$cmds" : ".*"` &&
- test "$len" -le "$max_cmd_len" || test "$max_cmd_len" -le -1; then
- cmds=$old_archive_cmds
- else
- # the command line is too long to link in one step, link in parts
- $echo "using piecewise archive linking..."
- save_RANLIB=$RANLIB
- RANLIB=:
- objlist=
- concat_cmds=
- save_oldobjs=$oldobjs
-
- # Is there a better way of finding the last object in the list?
- for obj in $save_oldobjs
- do
- last_oldobj=$obj
- done
- for obj in $save_oldobjs
- do
- oldobjs="$objlist $obj"
- objlist="$objlist $obj"
- eval test_cmds=\"$old_archive_cmds\"
- if len=`expr "X$test_cmds" : ".*" 2>/dev/null` &&
- test "$len" -le "$max_cmd_len"; then
- :
- else
- # the above command should be used before it gets too long
- oldobjs=$objlist
- if test "$obj" = "$last_oldobj" ; then
- RANLIB=$save_RANLIB
- fi
- test -z "$concat_cmds" || concat_cmds=$concat_cmds~
- eval concat_cmds=\"\${concat_cmds}$old_archive_cmds\"
- objlist=
- fi
- done
- RANLIB=$save_RANLIB
- oldobjs=$objlist
- if test "X$oldobjs" = "X" ; then
- eval cmds=\"\$concat_cmds\"
- else
- eval cmds=\"\$concat_cmds~\$old_archive_cmds\"
- fi
- fi
- fi
- save_ifs="$IFS"; IFS='~'
- for cmd in $cmds; do
- eval cmd=\"$cmd\"
- IFS="$save_ifs"
- $show "$cmd"
- $run eval "$cmd" || exit $?
- done
- IFS="$save_ifs"
- done
-
- if test -n "$generated"; then
- $show "${rm}r$generated"
- $run ${rm}r$generated
- fi
-
- # Now create the libtool archive.
- case $output in
- *.la)
- old_library=
- test "$build_old_libs" = yes && old_library="$libname.$libext"
- $show "creating $output"
-
- # Preserve any variables that may affect compiler behavior
- for var in $variables_saved_for_relink; do
- if eval test -z \"\${$var+set}\"; then
- relink_command="{ test -z \"\${$var+set}\" || unset $var || { $var=; export $var; }; }; $relink_command"
- elif eval var_value=\$$var; test -z "$var_value"; then
- relink_command="$var=; export $var; $relink_command"
- else
- var_value=`$echo "X$var_value" | $Xsed -e "$sed_quote_subst"`
- relink_command="$var=\"$var_value\"; export $var; $relink_command"
- fi
- done
- # Quote the link command for shipping.
- relink_command="(cd `pwd`; $SHELL $progpath $preserve_args --mode=relink $libtool_args @inst_prefix_dir@)"
- relink_command=`$echo "X$relink_command" | $Xsed -e "$sed_quote_subst"`
- if test "$hardcode_automatic" = yes ; then
- relink_command=
- fi
-
-
- # Only create the output if not a dry run.
- if test -z "$run"; then
- for installed in no yes; do
- if test "$installed" = yes; then
- if test -z "$install_libdir"; then
- break
- fi
- output="$output_objdir/$outputname"i
- # Replace all uninstalled libtool libraries with the installed ones
- newdependency_libs=
- for deplib in $dependency_libs; do
- case $deplib in
- *.la)
- name=`$echo "X$deplib" | $Xsed -e 's%^.*/%%'`
- eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib`
- if test -z "$libdir"; then
- $echo "$modename: \`$deplib' is not a valid libtool archive" 1>&2
- exit $EXIT_FAILURE
- fi
- newdependency_libs="$newdependency_libs $libdir/$name"
- ;;
- *) newdependency_libs="$newdependency_libs $deplib" ;;
- esac
- done
- dependency_libs="$newdependency_libs"
- newdlfiles=
- for lib in $dlfiles; do
- name=`$echo "X$lib" | $Xsed -e 's%^.*/%%'`
- eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib`
- if test -z "$libdir"; then
- $echo "$modename: \`$lib' is not a valid libtool archive" 1>&2
- exit $EXIT_FAILURE
- fi
- newdlfiles="$newdlfiles $libdir/$name"
- done
- dlfiles="$newdlfiles"
- newdlprefiles=
- for lib in $dlprefiles; do
- name=`$echo "X$lib" | $Xsed -e 's%^.*/%%'`
- eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib`
- if test -z "$libdir"; then
- $echo "$modename: \`$lib' is not a valid libtool archive" 1>&2
- exit $EXIT_FAILURE
- fi
- newdlprefiles="$newdlprefiles $libdir/$name"
- done
- dlprefiles="$newdlprefiles"
- else
- newdlfiles=
- for lib in $dlfiles; do
- case $lib in
- [\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;;
- *) abs=`pwd`"/$lib" ;;
- esac
- newdlfiles="$newdlfiles $abs"
- done
- dlfiles="$newdlfiles"
- newdlprefiles=
- for lib in $dlprefiles; do
- case $lib in
- [\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;;
- *) abs=`pwd`"/$lib" ;;
- esac
- newdlprefiles="$newdlprefiles $abs"
- done
- dlprefiles="$newdlprefiles"
- fi
- $rm $output
- # place dlname in correct position for cygwin
- tdlname=$dlname
- case $host,$output,$installed,$module,$dlname in
- *cygwin*,*lai,yes,no,*.dll | *mingw*,*lai,yes,no,*.dll) tdlname=../bin/$dlname ;;
- esac
- $echo > $output "\
-# $outputname - a libtool library file
-# Generated by $PROGRAM - GNU $PACKAGE $VERSION$TIMESTAMP
-#
-# Please DO NOT delete this file!
-# It is necessary for linking the library.
-
-# The name that we can dlopen(3).
-dlname='$tdlname'
-
-# Names of this library.
-library_names='$library_names'
-
-# The name of the static archive.
-old_library='$old_library'
-
-# Libraries that this one depends upon.
-dependency_libs='$dependency_libs'
-
-# Version information for $libname.
-current=$current
-age=$age
-revision=$revision
-
-# Is this an already installed library?
-installed=$installed
-
-# Should we warn about portability when linking against -modules?
-shouldnotlink=$module
-
-# Files to dlopen/dlpreopen
-dlopen='$dlfiles'
-dlpreopen='$dlprefiles'
-
-# Directory that this library needs to be installed in:
-libdir='$install_libdir'"
- if test "$installed" = no && test "$need_relink" = yes; then
- $echo >> $output "\
-relink_command=\"$relink_command\""
- fi
- done
- fi
-
- # Do a symbolic link so that the libtool archive can be found in
- # LD_LIBRARY_PATH before the program is installed.
- $show "(cd $output_objdir && $rm $outputname && $LN_S ../$outputname $outputname)"
- $run eval '(cd $output_objdir && $rm $outputname && $LN_S ../$outputname $outputname)' || exit $?
- ;;
- esac
- exit $EXIT_SUCCESS
- ;;
-
- # libtool install mode
- install)
- modename="$modename: install"
-
- # There may be an optional sh(1) argument at the beginning of
- # install_prog (especially on Windows NT).
- if test "$nonopt" = "$SHELL" || test "$nonopt" = /bin/sh ||
- # Allow the use of GNU shtool's install command.
- $echo "X$nonopt" | grep shtool > /dev/null; then
- # Aesthetically quote it.
- arg=`$echo "X$nonopt" | $Xsed -e "$sed_quote_subst"`
- case $arg in
- *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"")
- arg="\"$arg\""
- ;;
- esac
- install_prog="$arg "
- arg="$1"
- shift
- else
- install_prog=
- arg=$nonopt
- fi
-
- # The real first argument should be the name of the installation program.
- # Aesthetically quote it.
- arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"`
- case $arg in
- *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"")
- arg="\"$arg\""
- ;;
- esac
- install_prog="$install_prog$arg"
-
- # We need to accept at least all the BSD install flags.
- dest=
- files=
- opts=
- prev=
- install_type=
- isdir=no
- stripme=
- for arg
- do
- if test -n "$dest"; then
- files="$files $dest"
- dest=$arg
- continue
- fi
-
- case $arg in
- -d) isdir=yes ;;
- -f)
- case " $install_prog " in
- *[\\\ /]cp\ *) ;;
- *) prev=$arg ;;
- esac
- ;;
- -g | -m | -o) prev=$arg ;;
- -s)
- stripme=" -s"
- continue
- ;;
- -*)
- ;;
- *)
- # If the previous option needed an argument, then skip it.
- if test -n "$prev"; then
- prev=
- else
- dest=$arg
- continue
- fi
- ;;
- esac
-
- # Aesthetically quote the argument.
- arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"`
- case $arg in
- *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"")
- arg="\"$arg\""
- ;;
- esac
- install_prog="$install_prog $arg"
- done
-
- if test -z "$install_prog"; then
- $echo "$modename: you must specify an install program" 1>&2
- $echo "$help" 1>&2
- exit $EXIT_FAILURE
- fi
-
- if test -n "$prev"; then
- $echo "$modename: the \`$prev' option requires an argument" 1>&2
- $echo "$help" 1>&2
- exit $EXIT_FAILURE
- fi
-
- if test -z "$files"; then
- if test -z "$dest"; then
- $echo "$modename: no file or destination specified" 1>&2
- else
- $echo "$modename: you must specify a destination" 1>&2
- fi
- $echo "$help" 1>&2
- exit $EXIT_FAILURE
- fi
-
- # Strip any trailing slash from the destination.
- dest=`$echo "X$dest" | $Xsed -e 's%/$%%'`
-
- # Check to see that the destination is a directory.
- test -d "$dest" && isdir=yes
- if test "$isdir" = yes; then
- destdir="$dest"
- destname=
- else
- destdir=`$echo "X$dest" | $Xsed -e 's%/[^/]*$%%'`
- test "X$destdir" = "X$dest" && destdir=.
- destname=`$echo "X$dest" | $Xsed -e 's%^.*/%%'`
-
- # Not a directory, so check to see that there is only one file specified.
- set dummy $files
- if test "$#" -gt 2; then
- $echo "$modename: \`$dest' is not a directory" 1>&2
- $echo "$help" 1>&2
- exit $EXIT_FAILURE
- fi
- fi
- case $destdir in
- [\\/]* | [A-Za-z]:[\\/]*) ;;
- *)
- for file in $files; do
- case $file in
- *.lo) ;;
- *)
- $echo "$modename: \`$destdir' must be an absolute directory name" 1>&2
- $echo "$help" 1>&2
- exit $EXIT_FAILURE
- ;;
- esac
- done
- ;;
- esac
-
- # This variable tells wrapper scripts just to set variables rather
- # than running their programs.
- libtool_install_magic="$magic"
-
- staticlibs=
- future_libdirs=
- current_libdirs=
- for file in $files; do
-
- # Do each installation.
- case $file in
- *.$libext)
- # Do the static libraries later.
- staticlibs="$staticlibs $file"
- ;;
-
- *.la)
- # Check to see that this really is a libtool archive.
- if (${SED} -e '2q' $file | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then :
- else
- $echo "$modename: \`$file' is not a valid libtool archive" 1>&2
- $echo "$help" 1>&2
- exit $EXIT_FAILURE
- fi
-
- library_names=
- old_library=
- relink_command=
- # If there is no directory component, then add one.
- case $file in
- */* | *\\*) . $file ;;
- *) . ./$file ;;
- esac
-
- # Add the libdir to current_libdirs if it is the destination.
- if test "X$destdir" = "X$libdir"; then
- case "$current_libdirs " in
- *" $libdir "*) ;;
- *) current_libdirs="$current_libdirs $libdir" ;;
- esac
- else
- # Note the libdir as a future libdir.
- case "$future_libdirs " in
- *" $libdir "*) ;;
- *) future_libdirs="$future_libdirs $libdir" ;;
- esac
- fi
-
- dir=`$echo "X$file" | $Xsed -e 's%/[^/]*$%%'`/
- test "X$dir" = "X$file/" && dir=
- dir="$dir$objdir"
-
- if test -n "$relink_command"; then
- # Determine the prefix the user has applied to our future dir.
- inst_prefix_dir=`$echo "$destdir" | $SED "s%$libdir\$%%"`
-
- # Don't allow the user to place us outside of our expected
- # location b/c this prevents finding dependent libraries that
- # are installed to the same prefix.
- # At present, this check doesn't affect windows .dll's that
- # are installed into $libdir/../bin (currently, that works fine)
- # but it's something to keep an eye on.
- if test "$inst_prefix_dir" = "$destdir"; then
- $echo "$modename: error: cannot install \`$file' to a directory not ending in $libdir" 1>&2
- exit $EXIT_FAILURE
- fi
-
- if test -n "$inst_prefix_dir"; then
- # Stick the inst_prefix_dir data into the link command.
- relink_command=`$echo "$relink_command" | $SED "s%@inst_prefix_dir@%-inst-prefix-dir $inst_prefix_dir%"`
- else
- relink_command=`$echo "$relink_command" | $SED "s%@inst_prefix_dir@%%"`
- fi
-
- $echo "$modename: warning: relinking \`$file'" 1>&2
- $show "$relink_command"
- if $run eval "$relink_command"; then :
- else
- $echo "$modename: error: relink \`$file' with the above command before installing it" 1>&2
- exit $EXIT_FAILURE
- fi
- fi
-
- # See the names of the shared library.
- set dummy $library_names
- if test -n "$2"; then
- realname="$2"
- shift
- shift
-
- srcname="$realname"
- test -n "$relink_command" && srcname="$realname"T
-
- # Install the shared library and build the symlinks.
- $show "$install_prog $dir/$srcname $destdir/$realname"
- $run eval "$install_prog $dir/$srcname $destdir/$realname" || exit $?
- if test -n "$stripme" && test -n "$striplib"; then
- $show "$striplib $destdir/$realname"
- $run eval "$striplib $destdir/$realname" || exit $?
- fi
-
- if test "$#" -gt 0; then
- # Delete the old symlinks, and create new ones.
- # Try `ln -sf' first, because the `ln' binary might depend on
- # the symlink we replace! Solaris /bin/ln does not understand -f,
- # so we also need to try rm && ln -s.
- for linkname
- do
- if test "$linkname" != "$realname"; then
- $show "(cd $destdir && { $LN_S -f $realname $linkname || { $rm $linkname && $LN_S $realname $linkname; }; })"
- $run eval "(cd $destdir && { $LN_S -f $realname $linkname || { $rm $linkname && $LN_S $realname $linkname; }; })"
- fi
- done
- fi
-
- # Do each command in the postinstall commands.
- lib="$destdir/$realname"
- cmds=$postinstall_cmds
- save_ifs="$IFS"; IFS='~'
- for cmd in $cmds; do
- IFS="$save_ifs"
- eval cmd=\"$cmd\"
- $show "$cmd"
- $run eval "$cmd" || {
- lt_exit=$?
-
- # Restore the uninstalled library and exit
- if test "$mode" = relink; then
- $run eval '(cd $output_objdir && $rm ${realname}T && $mv ${realname}U $realname)'
- fi
-
- exit $lt_exit
- }
- done
- IFS="$save_ifs"
- fi
-
- # Install the pseudo-library for information purposes.
- name=`$echo "X$file" | $Xsed -e 's%^.*/%%'`
- instname="$dir/$name"i
- $show "$install_prog $instname $destdir/$name"
- $run eval "$install_prog $instname $destdir/$name" || exit $?
-
- # Maybe install the static library, too.
- test -n "$old_library" && staticlibs="$staticlibs $dir/$old_library"
- ;;
-
- *.lo)
- # Install (i.e. copy) a libtool object.
-
- # Figure out destination file name, if it wasn't already specified.
- if test -n "$destname"; then
- destfile="$destdir/$destname"
- else
- destfile=`$echo "X$file" | $Xsed -e 's%^.*/%%'`
- destfile="$destdir/$destfile"
- fi
-
- # Deduce the name of the destination old-style object file.
- case $destfile in
- *.lo)
- staticdest=`$echo "X$destfile" | $Xsed -e "$lo2o"`
- ;;
- *.$objext)
- staticdest="$destfile"
- destfile=
- ;;
- *)
- $echo "$modename: cannot copy a libtool object to \`$destfile'" 1>&2
- $echo "$help" 1>&2
- exit $EXIT_FAILURE
- ;;
- esac
-
- # Install the libtool object if requested.
- if test -n "$destfile"; then
- $show "$install_prog $file $destfile"
- $run eval "$install_prog $file $destfile" || exit $?
- fi
-
- # Install the old object if enabled.
- if test "$build_old_libs" = yes; then
- # Deduce the name of the old-style object file.
- staticobj=`$echo "X$file" | $Xsed -e "$lo2o"`
-
- $show "$install_prog $staticobj $staticdest"
- $run eval "$install_prog \$staticobj \$staticdest" || exit $?
- fi
- exit $EXIT_SUCCESS
- ;;
-
- *)
- # Figure out destination file name, if it wasn't already specified.
- if test -n "$destname"; then
- destfile="$destdir/$destname"
- else
- destfile=`$echo "X$file" | $Xsed -e 's%^.*/%%'`
- destfile="$destdir/$destfile"
- fi
-
- # If the file is missing, and there is a .exe on the end, strip it
- # because it is most likely a libtool script we actually want to
- # install
- stripped_ext=""
- case $file in
- *.exe)
- if test ! -f "$file"; then
- file=`$echo $file|${SED} 's,.exe$,,'`
- stripped_ext=".exe"
- fi
- ;;
- esac
-
- # Do a test to see if this is really a libtool program.
- case $host in
- *cygwin*|*mingw*)
- wrapper=`$echo $file | ${SED} -e 's,.exe$,,'`
- ;;
- *)
- wrapper=$file
- ;;
- esac
- if (${SED} -e '4q' $wrapper | grep "^# Generated by .*$PACKAGE")>/dev/null 2>&1; then
- notinst_deplibs=
- relink_command=
-
- # Note that it is not necessary on cygwin/mingw to append a dot to
- # foo even if both foo and FILE.exe exist: automatic-append-.exe
- # behavior happens only for exec(3), not for open(2)! Also, sourcing
- # `FILE.' does not work on cygwin managed mounts.
- #
- # If there is no directory component, then add one.
- case $wrapper in
- */* | *\\*) . ${wrapper} ;;
- *) . ./${wrapper} ;;
- esac
-
- # Check the variables that should have been set.
- if test -z "$notinst_deplibs"; then
- $echo "$modename: invalid libtool wrapper script \`$wrapper'" 1>&2
- exit $EXIT_FAILURE
- fi
-
- finalize=yes
- for lib in $notinst_deplibs; do
- # Check to see that each library is installed.
- libdir=
- if test -f "$lib"; then
- # If there is no directory component, then add one.
- case $lib in
- */* | *\\*) . $lib ;;
- *) . ./$lib ;;
- esac
- fi
- libfile="$libdir/"`$echo "X$lib" | $Xsed -e 's%^.*/%%g'` ### testsuite: skip nested quoting test
- if test -n "$libdir" && test ! -f "$libfile"; then
- $echo "$modename: warning: \`$lib' has not been installed in \`$libdir'" 1>&2
- finalize=no
- fi
- done
-
- relink_command=
- # Note that it is not necessary on cygwin/mingw to append a dot to
- # foo even if both foo and FILE.exe exist: automatic-append-.exe
- # behavior happens only for exec(3), not for open(2)! Also, sourcing
- # `FILE.' does not work on cygwin managed mounts.
- #
- # If there is no directory component, then add one.
- case $wrapper in
- */* | *\\*) . ${wrapper} ;;
- *) . ./${wrapper} ;;
- esac
-
- outputname=
- if test "$fast_install" = no && test -n "$relink_command"; then
- if test "$finalize" = yes && test -z "$run"; then
- tmpdir=`func_mktempdir`
- file=`$echo "X$file$stripped_ext" | $Xsed -e 's%^.*/%%'`
- outputname="$tmpdir/$file"
- # Replace the output file specification.
- relink_command=`$echo "X$relink_command" | $Xsed -e 's%@OUTPUT@%'"$outputname"'%g'`
-
- $show "$relink_command"
- if $run eval "$relink_command"; then :
- else
- $echo "$modename: error: relink \`$file' with the above command before installing it" 1>&2
- ${rm}r "$tmpdir"
- continue
- fi
- file="$outputname"
- else
- $echo "$modename: warning: cannot relink \`$file'" 1>&2
- fi
- else
- # Install the binary that we compiled earlier.
- file=`$echo "X$file$stripped_ext" | $Xsed -e "s%\([^/]*\)$%$objdir/\1%"`
- fi
- fi
-
- # remove .exe since cygwin /usr/bin/install will append another
- # one anyway
- case $install_prog,$host in
- */usr/bin/install*,*cygwin*)
- case $file:$destfile in
- *.exe:*.exe)
- # this is ok
- ;;
- *.exe:*)
- destfile=$destfile.exe
- ;;
- *:*.exe)
- destfile=`$echo $destfile | ${SED} -e 's,.exe$,,'`
- ;;
- esac
- ;;
- esac
- $show "$install_prog$stripme $file $destfile"
- $run eval "$install_prog\$stripme \$file \$destfile" || exit $?
- test -n "$outputname" && ${rm}r "$tmpdir"
- ;;
- esac
- done
-
- for file in $staticlibs; do
- name=`$echo "X$file" | $Xsed -e 's%^.*/%%'`
-
- # Set up the ranlib parameters.
- oldlib="$destdir/$name"
-
- $show "$install_prog $file $oldlib"
- $run eval "$install_prog \$file \$oldlib" || exit $?
-
- if test -n "$stripme" && test -n "$old_striplib"; then
- $show "$old_striplib $oldlib"
- $run eval "$old_striplib $oldlib" || exit $?
- fi
-
- # Do each command in the postinstall commands.
- cmds=$old_postinstall_cmds
- save_ifs="$IFS"; IFS='~'
- for cmd in $cmds; do
- IFS="$save_ifs"
- eval cmd=\"$cmd\"
- $show "$cmd"
- $run eval "$cmd" || exit $?
- done
- IFS="$save_ifs"
- done
-
- if test -n "$future_libdirs"; then
- $echo "$modename: warning: remember to run \`$progname --finish$future_libdirs'" 1>&2
- fi
-
- if test -n "$current_libdirs"; then
- # Maybe just do a dry run.
- test -n "$run" && current_libdirs=" -n$current_libdirs"
- exec_cmd='$SHELL $progpath $preserve_args --finish$current_libdirs'
- else
- exit $EXIT_SUCCESS
- fi
- ;;
-
- # libtool finish mode
- finish)
- modename="$modename: finish"
- libdirs="$nonopt"
- admincmds=
-
- if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then
- for dir
- do
- libdirs="$libdirs $dir"
- done
-
- for libdir in $libdirs; do
- if test -n "$finish_cmds"; then
- # Do each command in the finish commands.
- cmds=$finish_cmds
- save_ifs="$IFS"; IFS='~'
- for cmd in $cmds; do
- IFS="$save_ifs"
- eval cmd=\"$cmd\"
- $show "$cmd"
- $run eval "$cmd" || admincmds="$admincmds
- $cmd"
- done
- IFS="$save_ifs"
- fi
- if test -n "$finish_eval"; then
- # Do the single finish_eval.
- eval cmds=\"$finish_eval\"
- $run eval "$cmds" || admincmds="$admincmds
- $cmds"
- fi
- done
- fi
-
- # Exit here if they wanted silent mode.
- test "$show" = : && exit $EXIT_SUCCESS
-
- $echo "X----------------------------------------------------------------------" | $Xsed
- $echo "Libraries have been installed in:"
- for libdir in $libdirs; do
- $echo " $libdir"
- done
- $echo
- $echo "If you ever happen to want to link against installed libraries"
- $echo "in a given directory, LIBDIR, you must either use libtool, and"
- $echo "specify the full pathname of the library, or use the \`-LLIBDIR'"
- $echo "flag during linking and do at least one of the following:"
- if test -n "$shlibpath_var"; then
- $echo " - add LIBDIR to the \`$shlibpath_var' environment variable"
- $echo " during execution"
- fi
- if test -n "$runpath_var"; then
- $echo " - add LIBDIR to the \`$runpath_var' environment variable"
- $echo " during linking"
- fi
- if test -n "$hardcode_libdir_flag_spec"; then
- libdir=LIBDIR
- eval flag=\"$hardcode_libdir_flag_spec\"
-
- $echo " - use the \`$flag' linker flag"
- fi
- if test -n "$admincmds"; then
- $echo " - have your system administrator run these commands:$admincmds"
- fi
- if test -f /etc/ld.so.conf; then
- $echo " - have your system administrator add LIBDIR to \`/etc/ld.so.conf'"
- fi
- $echo
- $echo "See any operating system documentation about shared libraries for"
- $echo "more information, such as the ld(1) and ld.so(8) manual pages."
- $echo "X----------------------------------------------------------------------" | $Xsed
- exit $EXIT_SUCCESS
- ;;
-
- # libtool execute mode
- execute)
- modename="$modename: execute"
-
- # The first argument is the command name.
- cmd="$nonopt"
- if test -z "$cmd"; then
- $echo "$modename: you must specify a COMMAND" 1>&2
- $echo "$help"
- exit $EXIT_FAILURE
- fi
-
- # Handle -dlopen flags immediately.
- for file in $execute_dlfiles; do
- if test ! -f "$file"; then
- $echo "$modename: \`$file' is not a file" 1>&2
- $echo "$help" 1>&2
- exit $EXIT_FAILURE
- fi
-
- dir=
- case $file in
- *.la)
- # Check to see that this really is a libtool archive.
- if (${SED} -e '2q' $file | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then :
- else
- $echo "$modename: \`$lib' is not a valid libtool archive" 1>&2
- $echo "$help" 1>&2
- exit $EXIT_FAILURE
- fi
-
- # Read the libtool library.
- dlname=
- library_names=
-
- # If there is no directory component, then add one.
- case $file in
- */* | *\\*) . $file ;;
- *) . ./$file ;;
- esac
-
- # Skip this library if it cannot be dlopened.
- if test -z "$dlname"; then
- # Warn if it was a shared library.
- test -n "$library_names" && $echo "$modename: warning: \`$file' was not linked with \`-export-dynamic'"
- continue
- fi
-
- dir=`$echo "X$file" | $Xsed -e 's%/[^/]*$%%'`
- test "X$dir" = "X$file" && dir=.
-
- if test -f "$dir/$objdir/$dlname"; then
- dir="$dir/$objdir"
- else
- $echo "$modename: cannot find \`$dlname' in \`$dir' or \`$dir/$objdir'" 1>&2
- exit $EXIT_FAILURE
- fi
- ;;
-
- *.lo)
- # Just add the directory containing the .lo file.
- dir=`$echo "X$file" | $Xsed -e 's%/[^/]*$%%'`
- test "X$dir" = "X$file" && dir=.
- ;;
-
- *)
- $echo "$modename: warning \`-dlopen' is ignored for non-libtool libraries and objects" 1>&2
- continue
- ;;
- esac
-
- # Get the absolute pathname.
- absdir=`cd "$dir" && pwd`
- test -n "$absdir" && dir="$absdir"
-
- # Now add the directory to shlibpath_var.
- if eval "test -z \"\$$shlibpath_var\""; then
- eval "$shlibpath_var=\"\$dir\""
- else
- eval "$shlibpath_var=\"\$dir:\$$shlibpath_var\""
- fi
- done
-
- # This variable tells wrapper scripts just to set shlibpath_var
- # rather than running their programs.
- libtool_execute_magic="$magic"
-
- # Check if any of the arguments is a wrapper script.
- args=
- for file
- do
- case $file in
- -*) ;;
- *)
- # Do a test to see if this is really a libtool program.
- if (${SED} -e '4q' $file | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then
- # If there is no directory component, then add one.
- case $file in
- */* | *\\*) . $file ;;
- *) . ./$file ;;
- esac
-
- # Transform arg to wrapped name.
- file="$progdir/$program"
- fi
- ;;
- esac
- # Quote arguments (to preserve shell metacharacters).
- file=`$echo "X$file" | $Xsed -e "$sed_quote_subst"`
- args="$args \"$file\""
- done
-
- if test -z "$run"; then
- if test -n "$shlibpath_var"; then
- # Export the shlibpath_var.
- eval "export $shlibpath_var"
- fi
-
- # Restore saved environment variables
- if test "${save_LC_ALL+set}" = set; then
- LC_ALL="$save_LC_ALL"; export LC_ALL
- fi
- if test "${save_LANG+set}" = set; then
- LANG="$save_LANG"; export LANG
- fi
-
- # Now prepare to actually exec the command.
- exec_cmd="\$cmd$args"
- else
- # Display what would be done.
- if test -n "$shlibpath_var"; then
- eval "\$echo \"\$shlibpath_var=\$$shlibpath_var\""
- $echo "export $shlibpath_var"
- fi
- $echo "$cmd$args"
- exit $EXIT_SUCCESS
- fi
- ;;
-
- # libtool clean and uninstall mode
- clean | uninstall)
- modename="$modename: $mode"
- rm="$nonopt"
- files=
- rmforce=
- exit_status=0
-
- # This variable tells wrapper scripts just to set variables rather
- # than running their programs.
- libtool_install_magic="$magic"
-
- for arg
- do
- case $arg in
- -f) rm="$rm $arg"; rmforce=yes ;;
- -*) rm="$rm $arg" ;;
- *) files="$files $arg" ;;
- esac
- done
-
- if test -z "$rm"; then
- $echo "$modename: you must specify an RM program" 1>&2
- $echo "$help" 1>&2
- exit $EXIT_FAILURE
- fi
-
- rmdirs=
-
- origobjdir="$objdir"
- for file in $files; do
- dir=`$echo "X$file" | $Xsed -e 's%/[^/]*$%%'`
- if test "X$dir" = "X$file"; then
- dir=.
- objdir="$origobjdir"
- else
- objdir="$dir/$origobjdir"
- fi
- name=`$echo "X$file" | $Xsed -e 's%^.*/%%'`
- test "$mode" = uninstall && objdir="$dir"
-
- # Remember objdir for removal later, being careful to avoid duplicates
- if test "$mode" = clean; then
- case " $rmdirs " in
- *" $objdir "*) ;;
- *) rmdirs="$rmdirs $objdir" ;;
- esac
- fi
-
- # Don't error if the file doesn't exist and rm -f was used.
- if (test -L "$file") >/dev/null 2>&1 \
- || (test -h "$file") >/dev/null 2>&1 \
- || test -f "$file"; then
- :
- elif test -d "$file"; then
- exit_status=1
- continue
- elif test "$rmforce" = yes; then
- continue
- fi
-
- rmfiles="$file"
-
- case $name in
- *.la)
- # Possibly a libtool archive, so verify it.
- if (${SED} -e '2q' $file | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then
- . $dir/$name
-
- # Delete the libtool libraries and symlinks.
- for n in $library_names; do
- rmfiles="$rmfiles $objdir/$n"
- done
- test -n "$old_library" && rmfiles="$rmfiles $objdir/$old_library"
-
- case "$mode" in
- clean)
- case " $library_names " in
- # " " in the beginning catches empty $dlname
- *" $dlname "*) ;;
- *) rmfiles="$rmfiles $objdir/$dlname" ;;
- esac
- test -n "$libdir" && rmfiles="$rmfiles $objdir/$name $objdir/${name}i"
- ;;
- uninstall)
- if test -n "$library_names"; then
- # Do each command in the postuninstall commands.
- cmds=$postuninstall_cmds
- save_ifs="$IFS"; IFS='~'
- for cmd in $cmds; do
- IFS="$save_ifs"
- eval cmd=\"$cmd\"
- $show "$cmd"
- $run eval "$cmd"
- if test "$?" -ne 0 && test "$rmforce" != yes; then
- exit_status=1
- fi
- done
- IFS="$save_ifs"
- fi
-
- if test -n "$old_library"; then
- # Do each command in the old_postuninstall commands.
- cmds=$old_postuninstall_cmds
- save_ifs="$IFS"; IFS='~'
- for cmd in $cmds; do
- IFS="$save_ifs"
- eval cmd=\"$cmd\"
- $show "$cmd"
- $run eval "$cmd"
- if test "$?" -ne 0 && test "$rmforce" != yes; then
- exit_status=1
- fi
- done
- IFS="$save_ifs"
- fi
- # FIXME: should reinstall the best remaining shared library.
- ;;
- esac
- fi
- ;;
-
- *.lo)
- # Possibly a libtool object, so verify it.
- if (${SED} -e '2q' $file | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then
-
- # Read the .lo file
- . $dir/$name
-
- # Add PIC object to the list of files to remove.
- if test -n "$pic_object" \
- && test "$pic_object" != none; then
- rmfiles="$rmfiles $dir/$pic_object"
- fi
-
- # Add non-PIC object to the list of files to remove.
- if test -n "$non_pic_object" \
- && test "$non_pic_object" != none; then
- rmfiles="$rmfiles $dir/$non_pic_object"
- fi
- fi
- ;;
-
- *)
- if test "$mode" = clean ; then
- noexename=$name
- case $file in
- *.exe)
- file=`$echo $file|${SED} 's,.exe$,,'`
- noexename=`$echo $name|${SED} 's,.exe$,,'`
- # $file with .exe has already been added to rmfiles,
- # add $file without .exe
- rmfiles="$rmfiles $file"
- ;;
- esac
- # Do a test to see if this is a libtool program.
- if (${SED} -e '4q' $file | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then
- relink_command=
- . $dir/$noexename
-
- # note $name still contains .exe if it was in $file originally
- # as does the version of $file that was added into $rmfiles
- rmfiles="$rmfiles $objdir/$name $objdir/${name}S.${objext}"
- if test "$fast_install" = yes && test -n "$relink_command"; then
- rmfiles="$rmfiles $objdir/lt-$name"
- fi
- if test "X$noexename" != "X$name" ; then
- rmfiles="$rmfiles $objdir/lt-${noexename}.c"
- fi
- fi
- fi
- ;;
- esac
- $show "$rm $rmfiles"
- $run $rm $rmfiles || exit_status=1
- done
- objdir="$origobjdir"
-
- # Try to remove the ${objdir}s in the directories where we deleted files
- for dir in $rmdirs; do
- if test -d "$dir"; then
- $show "rmdir $dir"
- $run rmdir $dir >/dev/null 2>&1
- fi
- done
-
- exit $exit_status
- ;;
-
- "")
- $echo "$modename: you must specify a MODE" 1>&2
- $echo "$generic_help" 1>&2
- exit $EXIT_FAILURE
- ;;
- esac
-
- if test -z "$exec_cmd"; then
- $echo "$modename: invalid operation mode \`$mode'" 1>&2
- $echo "$generic_help" 1>&2
- exit $EXIT_FAILURE
- fi
-fi # test -z "$show_help"
-
-if test -n "$exec_cmd"; then
- eval exec $exec_cmd
- exit $EXIT_FAILURE
-fi
-
-# We need to display help for each of the modes.
-case $mode in
-"") $echo \
-"Usage: $modename [OPTION]... [MODE-ARG]...
-
-Provide generalized library-building support services.
-
- --config show all configuration variables
- --debug enable verbose shell tracing
--n, --dry-run display commands without modifying any files
- --features display basic configuration information and exit
- --finish same as \`--mode=finish'
- --help display this help message and exit
- --mode=MODE use operation mode MODE [default=inferred from MODE-ARGS]
- --quiet same as \`--silent'
- --silent don't print informational messages
- --tag=TAG use configuration variables from tag TAG
- --version print version information
-
-MODE must be one of the following:
-
- clean remove files from the build directory
- compile compile a source file into a libtool object
- execute automatically set library path, then run a program
- finish complete the installation of libtool libraries
- install install libraries or executables
- link create a library or an executable
- uninstall remove libraries from an installed directory
-
-MODE-ARGS vary depending on the MODE. Try \`$modename --help --mode=MODE' for
-a more detailed description of MODE.
-
-Report bugs to <bug-libtool@gnu.org>."
- exit $EXIT_SUCCESS
- ;;
-
-clean)
- $echo \
-"Usage: $modename [OPTION]... --mode=clean RM [RM-OPTION]... FILE...
-
-Remove files from the build directory.
-
-RM is the name of the program to use to delete files associated with each FILE
-(typically \`/bin/rm'). RM-OPTIONS are options (such as \`-f') to be passed
-to RM.
-
-If FILE is a libtool library, object or program, all the files associated
-with it are deleted. Otherwise, only FILE itself is deleted using RM."
- ;;
-
-compile)
- $echo \
-"Usage: $modename [OPTION]... --mode=compile COMPILE-COMMAND... SOURCEFILE
-
-Compile a source file into a libtool library object.
-
-This mode accepts the following additional options:
-
- -o OUTPUT-FILE set the output file name to OUTPUT-FILE
- -prefer-pic try to building PIC objects only
- -prefer-non-pic try to building non-PIC objects only
- -static always build a \`.o' file suitable for static linking
-
-COMPILE-COMMAND is a command to be used in creating a \`standard' object file
-from the given SOURCEFILE.
-
-The output file name is determined by removing the directory component from
-SOURCEFILE, then substituting the C source code suffix \`.c' with the
-library object suffix, \`.lo'."
- ;;
-
-execute)
- $echo \
-"Usage: $modename [OPTION]... --mode=execute COMMAND [ARGS]...
-
-Automatically set library path, then run a program.
-
-This mode accepts the following additional options:
-
- -dlopen FILE add the directory containing FILE to the library path
-
-This mode sets the library path environment variable according to \`-dlopen'
-flags.
-
-If any of the ARGS are libtool executable wrappers, then they are translated
-into their corresponding uninstalled binary, and any of their required library
-directories are added to the library path.
-
-Then, COMMAND is executed, with ARGS as arguments."
- ;;
-
-finish)
- $echo \
-"Usage: $modename [OPTION]... --mode=finish [LIBDIR]...
-
-Complete the installation of libtool libraries.
-
-Each LIBDIR is a directory that contains libtool libraries.
-
-The commands that this mode executes may require superuser privileges. Use
-the \`--dry-run' option if you just want to see what would be executed."
- ;;
-
-install)
- $echo \
-"Usage: $modename [OPTION]... --mode=install INSTALL-COMMAND...
-
-Install executables or libraries.
-
-INSTALL-COMMAND is the installation command. The first component should be
-either the \`install' or \`cp' program.
-
-The rest of the components are interpreted as arguments to that command (only
-BSD-compatible install options are recognized)."
- ;;
-
-link)
- $echo \
-"Usage: $modename [OPTION]... --mode=link LINK-COMMAND...
-
-Link object files or libraries together to form another library, or to
-create an executable program.
-
-LINK-COMMAND is a command using the C compiler that you would use to create
-a program from several object files.
-
-The following components of LINK-COMMAND are treated specially:
-
- -all-static do not do any dynamic linking at all
- -avoid-version do not add a version suffix if possible
- -dlopen FILE \`-dlpreopen' FILE if it cannot be dlopened at runtime
- -dlpreopen FILE link in FILE and add its symbols to lt_preloaded_symbols
- -export-dynamic allow symbols from OUTPUT-FILE to be resolved with dlsym(3)
- -export-symbols SYMFILE
- try to export only the symbols listed in SYMFILE
- -export-symbols-regex REGEX
- try to export only the symbols matching REGEX
- -LLIBDIR search LIBDIR for required installed libraries
- -lNAME OUTPUT-FILE requires the installed library libNAME
- -module build a library that can dlopened
- -no-fast-install disable the fast-install mode
- -no-install link a not-installable executable
- -no-undefined declare that a library does not refer to external symbols
- -o OUTPUT-FILE create OUTPUT-FILE from the specified objects
- -objectlist FILE Use a list of object files found in FILE to specify objects
- -precious-files-regex REGEX
- don't remove output files matching REGEX
- -release RELEASE specify package release information
- -rpath LIBDIR the created library will eventually be installed in LIBDIR
- -R[ ]LIBDIR add LIBDIR to the runtime path of programs and libraries
- -static do not do any dynamic linking of libtool libraries
- -version-info CURRENT[:REVISION[:AGE]]
- specify library version info [each variable defaults to 0]
-
-All other options (arguments beginning with \`-') are ignored.
-
-Every other argument is treated as a filename. Files ending in \`.la' are
-treated as uninstalled libtool libraries, other files are standard or library
-object files.
-
-If the OUTPUT-FILE ends in \`.la', then a libtool library is created,
-only library objects (\`.lo' files) may be specified, and \`-rpath' is
-required, except when creating a convenience library.
-
-If OUTPUT-FILE ends in \`.a' or \`.lib', then a standard library is created
-using \`ar' and \`ranlib', or on Windows using \`lib'.
-
-If OUTPUT-FILE ends in \`.lo' or \`.${objext}', then a reloadable object file
-is created, otherwise an executable program is created."
- ;;
-
-uninstall)
- $echo \
-"Usage: $modename [OPTION]... --mode=uninstall RM [RM-OPTION]... FILE...
-
-Remove libraries from an installation directory.
-
-RM is the name of the program to use to delete files associated with each FILE
-(typically \`/bin/rm'). RM-OPTIONS are options (such as \`-f') to be passed
-to RM.
-
-If FILE is a libtool library, all the files associated with it are deleted.
-Otherwise, only FILE itself is deleted using RM."
- ;;
-
-*)
- $echo "$modename: invalid operation mode \`$mode'" 1>&2
- $echo "$help" 1>&2
- exit $EXIT_FAILURE
- ;;
-esac
-
-$echo
-$echo "Try \`$modename --help' for more information about other modes."
-
-exit $?
-
-# The TAGs below are defined such that we never get into a situation
-# in which we disable both kinds of libraries. Given conflicting
-# choices, we go for a static library, that is the most portable,
-# since we can't tell whether shared libraries were disabled because
-# the user asked for that or because the platform doesn't support
-# them. This is particularly important on AIX, because we don't
-# support having both static and shared libraries enabled at the same
-# time on that platform, so we default to a shared-only configuration.
-# If a disable-shared tag is given, we'll fallback to a static-only
-# configuration. But we'll never go from static-only to shared-only.
-
-# ### BEGIN LIBTOOL TAG CONFIG: disable-shared
-disable_libs=shared
-# ### END LIBTOOL TAG CONFIG: disable-shared
-
-# ### BEGIN LIBTOOL TAG CONFIG: disable-static
-disable_libs=static
-# ### END LIBTOOL TAG CONFIG: disable-static
-
-# Local Variables:
-# mode:shell-script
-# sh-indentation:2
-# End:
diff --git a/contrib/ofed/librdmacm/config/missing b/contrib/ofed/librdmacm/config/missing
deleted file mode 100755
index 894e786..0000000
--- a/contrib/ofed/librdmacm/config/missing
+++ /dev/null
@@ -1,360 +0,0 @@
-#! /bin/sh
-# Common stub for a few missing GNU programs while installing.
-
-scriptversion=2005-06-08.21
-
-# Copyright (C) 1996, 1997, 1999, 2000, 2002, 2003, 2004, 2005
-# Free Software Foundation, Inc.
-# Originally by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996.
-
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2, or (at your option)
-# any later version.
-
-# This program 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 this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
-# 02110-1301, USA.
-
-# As a special exception to the GNU General Public License, if you
-# distribute this file as part of a program that contains a
-# configuration script generated by Autoconf, you may include it under
-# the same distribution terms that you use for the rest of that program.
-
-if test $# -eq 0; then
- echo 1>&2 "Try \`$0 --help' for more information"
- exit 1
-fi
-
-run=:
-
-# In the cases where this matters, `missing' is being run in the
-# srcdir already.
-if test -f configure.ac; then
- configure_ac=configure.ac
-else
- configure_ac=configure.in
-fi
-
-msg="missing on your system"
-
-case "$1" in
---run)
- # Try to run requested program, and just exit if it succeeds.
- run=
- shift
- "$@" && exit 0
- # Exit code 63 means version mismatch. This often happens
- # when the user try to use an ancient version of a tool on
- # a file that requires a minimum version. In this case we
- # we should proceed has if the program had been absent, or
- # if --run hadn't been passed.
- if test $? = 63; then
- run=:
- msg="probably too old"
- fi
- ;;
-
- -h|--h|--he|--hel|--help)
- echo "\
-$0 [OPTION]... PROGRAM [ARGUMENT]...
-
-Handle \`PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an
-error status if there is no known handling for PROGRAM.
-
-Options:
- -h, --help display this help and exit
- -v, --version output version information and exit
- --run try to run the given command, and emulate it if it fails
-
-Supported PROGRAM values:
- aclocal touch file \`aclocal.m4'
- autoconf touch file \`configure'
- autoheader touch file \`config.h.in'
- automake touch all \`Makefile.in' files
- bison create \`y.tab.[ch]', if possible, from existing .[ch]
- flex create \`lex.yy.c', if possible, from existing .c
- help2man touch the output file
- lex create \`lex.yy.c', if possible, from existing .c
- makeinfo touch the output file
- tar try tar, gnutar, gtar, then tar without non-portable flags
- yacc create \`y.tab.[ch]', if possible, from existing .[ch]
-
-Send bug reports to <bug-automake@gnu.org>."
- exit $?
- ;;
-
- -v|--v|--ve|--ver|--vers|--versi|--versio|--version)
- echo "missing $scriptversion (GNU Automake)"
- exit $?
- ;;
-
- -*)
- echo 1>&2 "$0: Unknown \`$1' option"
- echo 1>&2 "Try \`$0 --help' for more information"
- exit 1
- ;;
-
-esac
-
-# Now exit if we have it, but it failed. Also exit now if we
-# don't have it and --version was passed (most likely to detect
-# the program).
-case "$1" in
- lex|yacc)
- # Not GNU programs, they don't have --version.
- ;;
-
- tar)
- if test -n "$run"; then
- echo 1>&2 "ERROR: \`tar' requires --run"
- exit 1
- elif test "x$2" = "x--version" || test "x$2" = "x--help"; then
- exit 1
- fi
- ;;
-
- *)
- if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
- # We have it, but it failed.
- exit 1
- elif test "x$2" = "x--version" || test "x$2" = "x--help"; then
- # Could not run --version or --help. This is probably someone
- # running `$TOOL --version' or `$TOOL --help' to check whether
- # $TOOL exists and not knowing $TOOL uses missing.
- exit 1
- fi
- ;;
-esac
-
-# If it does not exist, or fails to run (possibly an outdated version),
-# try to emulate it.
-case "$1" in
- aclocal*)
- echo 1>&2 "\
-WARNING: \`$1' is $msg. You should only need it if
- you modified \`acinclude.m4' or \`${configure_ac}'. You might want
- to install the \`Automake' and \`Perl' packages. Grab them from
- any GNU archive site."
- touch aclocal.m4
- ;;
-
- autoconf)
- echo 1>&2 "\
-WARNING: \`$1' is $msg. You should only need it if
- you modified \`${configure_ac}'. You might want to install the
- \`Autoconf' and \`GNU m4' packages. Grab them from any GNU
- archive site."
- touch configure
- ;;
-
- autoheader)
- echo 1>&2 "\
-WARNING: \`$1' is $msg. You should only need it if
- you modified \`acconfig.h' or \`${configure_ac}'. You might want
- to install the \`Autoconf' and \`GNU m4' packages. Grab them
- from any GNU archive site."
- files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' ${configure_ac}`
- test -z "$files" && files="config.h"
- touch_files=
- for f in $files; do
- case "$f" in
- *:*) touch_files="$touch_files "`echo "$f" |
- sed -e 's/^[^:]*://' -e 's/:.*//'`;;
- *) touch_files="$touch_files $f.in";;
- esac
- done
- touch $touch_files
- ;;
-
- automake*)
- echo 1>&2 "\
-WARNING: \`$1' is $msg. You should only need it if
- you modified \`Makefile.am', \`acinclude.m4' or \`${configure_ac}'.
- You might want to install the \`Automake' and \`Perl' packages.
- Grab them from any GNU archive site."
- find . -type f -name Makefile.am -print |
- sed 's/\.am$/.in/' |
- while read f; do touch "$f"; done
- ;;
-
- autom4te)
- echo 1>&2 "\
-WARNING: \`$1' is needed, but is $msg.
- You might have modified some files without having the
- proper tools for further handling them.
- You can get \`$1' as part of \`Autoconf' from any GNU
- archive site."
-
- file=`echo "$*" | sed -n 's/.*--output[ =]*\([^ ]*\).*/\1/p'`
- test -z "$file" && file=`echo "$*" | sed -n 's/.*-o[ ]*\([^ ]*\).*/\1/p'`
- if test -f "$file"; then
- touch $file
- else
- test -z "$file" || exec >$file
- echo "#! /bin/sh"
- echo "# Created by GNU Automake missing as a replacement of"
- echo "# $ $@"
- echo "exit 0"
- chmod +x $file
- exit 1
- fi
- ;;
-
- bison|yacc)
- echo 1>&2 "\
-WARNING: \`$1' $msg. You should only need it if
- you modified a \`.y' file. You may need the \`Bison' package
- in order for those modifications to take effect. You can get
- \`Bison' from any GNU archive site."
- rm -f y.tab.c y.tab.h
- if [ $# -ne 1 ]; then
- eval LASTARG="\${$#}"
- case "$LASTARG" in
- *.y)
- SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'`
- if [ -f "$SRCFILE" ]; then
- cp "$SRCFILE" y.tab.c
- fi
- SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'`
- if [ -f "$SRCFILE" ]; then
- cp "$SRCFILE" y.tab.h
- fi
- ;;
- esac
- fi
- if [ ! -f y.tab.h ]; then
- echo >y.tab.h
- fi
- if [ ! -f y.tab.c ]; then
- echo 'main() { return 0; }' >y.tab.c
- fi
- ;;
-
- lex|flex)
- echo 1>&2 "\
-WARNING: \`$1' is $msg. You should only need it if
- you modified a \`.l' file. You may need the \`Flex' package
- in order for those modifications to take effect. You can get
- \`Flex' from any GNU archive site."
- rm -f lex.yy.c
- if [ $# -ne 1 ]; then
- eval LASTARG="\${$#}"
- case "$LASTARG" in
- *.l)
- SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'`
- if [ -f "$SRCFILE" ]; then
- cp "$SRCFILE" lex.yy.c
- fi
- ;;
- esac
- fi
- if [ ! -f lex.yy.c ]; then
- echo 'main() { return 0; }' >lex.yy.c
- fi
- ;;
-
- help2man)
- echo 1>&2 "\
-WARNING: \`$1' is $msg. You should only need it if
- you modified a dependency of a manual page. You may need the
- \`Help2man' package in order for those modifications to take
- effect. You can get \`Help2man' from any GNU archive site."
-
- file=`echo "$*" | sed -n 's/.*-o \([^ ]*\).*/\1/p'`
- if test -z "$file"; then
- file=`echo "$*" | sed -n 's/.*--output=\([^ ]*\).*/\1/p'`
- fi
- if [ -f "$file" ]; then
- touch $file
- else
- test -z "$file" || exec >$file
- echo ".ab help2man is required to generate this page"
- exit 1
- fi
- ;;
-
- makeinfo)
- echo 1>&2 "\
-WARNING: \`$1' is $msg. You should only need it if
- you modified a \`.texi' or \`.texinfo' file, or any other file
- indirectly affecting the aspect of the manual. The spurious
- call might also be the consequence of using a buggy \`make' (AIX,
- DU, IRIX). You might want to install the \`Texinfo' package or
- the \`GNU make' package. Grab either from any GNU archive site."
- # The file to touch is that specified with -o ...
- file=`echo "$*" | sed -n 's/.*-o \([^ ]*\).*/\1/p'`
- if test -z "$file"; then
- # ... or it is the one specified with @setfilename ...
- infile=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'`
- file=`sed -n '/^@setfilename/ { s/.* \([^ ]*\) *$/\1/; p; q; }' $infile`
- # ... or it is derived from the source name (dir/f.texi becomes f.info)
- test -z "$file" && file=`echo "$infile" | sed 's,.*/,,;s,.[^.]*$,,'`.info
- fi
- # If the file does not exist, the user really needs makeinfo;
- # let's fail without touching anything.
- test -f $file || exit 1
- touch $file
- ;;
-
- tar)
- shift
-
- # We have already tried tar in the generic part.
- # Look for gnutar/gtar before invocation to avoid ugly error
- # messages.
- if (gnutar --version > /dev/null 2>&1); then
- gnutar "$@" && exit 0
- fi
- if (gtar --version > /dev/null 2>&1); then
- gtar "$@" && exit 0
- fi
- firstarg="$1"
- if shift; then
- case "$firstarg" in
- *o*)
- firstarg=`echo "$firstarg" | sed s/o//`
- tar "$firstarg" "$@" && exit 0
- ;;
- esac
- case "$firstarg" in
- *h*)
- firstarg=`echo "$firstarg" | sed s/h//`
- tar "$firstarg" "$@" && exit 0
- ;;
- esac
- fi
-
- echo 1>&2 "\
-WARNING: I can't seem to be able to run \`tar' with the given arguments.
- You may want to install GNU tar or Free paxutils, or check the
- command line arguments."
- exit 1
- ;;
-
- *)
- echo 1>&2 "\
-WARNING: \`$1' is needed, and is $msg.
- You might have modified some files without having the
- proper tools for further handling them. Check the \`README' file,
- it often tells you about the needed prerequisites for installing
- this package. You may also peek at any GNU archive site, in case
- some other package would contain this missing \`$1' program."
- exit 1
- ;;
-esac
-
-exit 0
-
-# Local variables:
-# eval: (add-hook 'write-file-hooks 'time-stamp)
-# time-stamp-start: "scriptversion="
-# time-stamp-format: "%:y-%02m-%02d.%02H"
-# time-stamp-end: "$"
-# End:
diff --git a/contrib/ofed/librdmacm/configure b/contrib/ofed/librdmacm/configure
deleted file mode 100755
index 3c6ac08..0000000
--- a/contrib/ofed/librdmacm/configure
+++ /dev/null
@@ -1,21957 +0,0 @@
-#! /bin/sh
-# Guess values for system-dependent variables and create Makefiles.
-# Generated by GNU Autoconf 2.59 for librdmacm 1.0.11.
-#
-# Report bugs to <general@lists.openfabrics.org>.
-#
-# Copyright (C) 2003 Free Software Foundation, Inc.
-# This configure script is free software; the Free Software Foundation
-# gives unlimited permission to copy, distribute and modify it.
-## --------------------- ##
-## M4sh Initialization. ##
-## --------------------- ##
-
-# Be Bourne compatible
-if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then
- emulate sh
- NULLCMD=:
- # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which
- # is contrary to our usage. Disable this feature.
- alias -g '${1+"$@"}'='"$@"'
-elif test -n "${BASH_VERSION+set}" && (set -o posix) >/dev/null 2>&1; then
- set -o posix
-fi
-DUALCASE=1; export DUALCASE # for MKS sh
-
-# Support unset when possible.
-if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then
- as_unset=unset
-else
- as_unset=false
-fi
-
-
-# Work around bugs in pre-3.0 UWIN ksh.
-$as_unset ENV MAIL MAILPATH
-PS1='$ '
-PS2='> '
-PS4='+ '
-
-# NLS nuisances.
-for as_var in \
- LANG LANGUAGE LC_ADDRESS LC_ALL LC_COLLATE LC_CTYPE LC_IDENTIFICATION \
- LC_MEASUREMENT LC_MESSAGES LC_MONETARY LC_NAME LC_NUMERIC LC_PAPER \
- LC_TELEPHONE LC_TIME
-do
- if (set +x; test -z "`(eval $as_var=C; export $as_var) 2>&1`"); then
- eval $as_var=C; export $as_var
- else
- $as_unset $as_var
- fi
-done
-
-# Required to use basename.
-if expr a : '\(a\)' >/dev/null 2>&1; then
- as_expr=expr
-else
- as_expr=false
-fi
-
-if (basename /) >/dev/null 2>&1 && test "X`basename / 2>&1`" = "X/"; then
- as_basename=basename
-else
- as_basename=false
-fi
-
-
-# Name of the executable.
-as_me=`$as_basename "$0" ||
-$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \
- X"$0" : 'X\(//\)$' \| \
- X"$0" : 'X\(/\)$' \| \
- . : '\(.\)' 2>/dev/null ||
-echo X/"$0" |
- sed '/^.*\/\([^/][^/]*\)\/*$/{ s//\1/; q; }
- /^X\/\(\/\/\)$/{ s//\1/; q; }
- /^X\/\(\/\).*/{ s//\1/; q; }
- s/.*/./; q'`
-
-
-# PATH needs CR, and LINENO needs CR and PATH.
-# Avoid depending upon Character Ranges.
-as_cr_letters='abcdefghijklmnopqrstuvwxyz'
-as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ'
-as_cr_Letters=$as_cr_letters$as_cr_LETTERS
-as_cr_digits='0123456789'
-as_cr_alnum=$as_cr_Letters$as_cr_digits
-
-# The user is always right.
-if test "${PATH_SEPARATOR+set}" != set; then
- echo "#! /bin/sh" >conf$$.sh
- echo "exit 0" >>conf$$.sh
- chmod +x conf$$.sh
- if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then
- PATH_SEPARATOR=';'
- else
- PATH_SEPARATOR=:
- fi
- rm -f conf$$.sh
-fi
-
-
- as_lineno_1=$LINENO
- as_lineno_2=$LINENO
- as_lineno_3=`(expr $as_lineno_1 + 1) 2>/dev/null`
- test "x$as_lineno_1" != "x$as_lineno_2" &&
- test "x$as_lineno_3" = "x$as_lineno_2" || {
- # Find who we are. Look in the path if we contain no path at all
- # relative or not.
- case $0 in
- *[\\/]* ) as_myself=$0 ;;
- *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
- IFS=$as_save_IFS
- test -z "$as_dir" && as_dir=.
- test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break
-done
-
- ;;
- esac
- # We did not find ourselves, most probably we were run as `sh COMMAND'
- # in which case we are not to be found in the path.
- if test "x$as_myself" = x; then
- as_myself=$0
- fi
- if test ! -f "$as_myself"; then
- { echo "$as_me: error: cannot find myself; rerun with an absolute path" >&2
- { (exit 1); exit 1; }; }
- fi
- case $CONFIG_SHELL in
- '')
- as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH
-do
- IFS=$as_save_IFS
- test -z "$as_dir" && as_dir=.
- for as_base in sh bash ksh sh5; do
- case $as_dir in
- /*)
- if ("$as_dir/$as_base" -c '
- as_lineno_1=$LINENO
- as_lineno_2=$LINENO
- as_lineno_3=`(expr $as_lineno_1 + 1) 2>/dev/null`
- test "x$as_lineno_1" != "x$as_lineno_2" &&
- test "x$as_lineno_3" = "x$as_lineno_2" ') 2>/dev/null; then
- $as_unset BASH_ENV || test "${BASH_ENV+set}" != set || { BASH_ENV=; export BASH_ENV; }
- $as_unset ENV || test "${ENV+set}" != set || { ENV=; export ENV; }
- CONFIG_SHELL=$as_dir/$as_base
- export CONFIG_SHELL
- exec "$CONFIG_SHELL" "$0" ${1+"$@"}
- fi;;
- esac
- done
-done
-;;
- esac
-
- # Create $as_me.lineno as a copy of $as_myself, but with $LINENO
- # uniformly replaced by the line number. The first 'sed' inserts a
- # line-number line before each line; the second 'sed' does the real
- # work. The second script uses 'N' to pair each line-number line
- # with the numbered line, and appends trailing '-' during
- # substitution so that $LINENO is not a special case at line end.
- # (Raja R Harinath suggested sed '=', and Paul Eggert wrote the
- # second 'sed' script. Blame Lee E. McMahon for sed's syntax. :-)
- sed '=' <$as_myself |
- sed '
- N
- s,$,-,
- : loop
- s,^\(['$as_cr_digits']*\)\(.*\)[$]LINENO\([^'$as_cr_alnum'_]\),\1\2\1\3,
- t loop
- s,-$,,
- s,^['$as_cr_digits']*\n,,
- ' >$as_me.lineno &&
- chmod +x $as_me.lineno ||
- { echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2
- { (exit 1); exit 1; }; }
-
- # Don't try to exec as it changes $[0], causing all sort of problems
- # (the dirname of $[0] is not the place where we might find the
- # original and so on. Autoconf is especially sensible to this).
- . ./$as_me.lineno
- # Exit status is that of the last command.
- exit
-}
-
-
-case `echo "testing\c"; echo 1,2,3`,`echo -n testing; echo 1,2,3` in
- *c*,-n*) ECHO_N= ECHO_C='
-' ECHO_T=' ' ;;
- *c*,* ) ECHO_N=-n ECHO_C= ECHO_T= ;;
- *) ECHO_N= ECHO_C='\c' ECHO_T= ;;
-esac
-
-if expr a : '\(a\)' >/dev/null 2>&1; then
- as_expr=expr
-else
- as_expr=false
-fi
-
-rm -f conf$$ conf$$.exe conf$$.file
-echo >conf$$.file
-if ln -s conf$$.file conf$$ 2>/dev/null; then
- # We could just check for DJGPP; but this test a) works b) is more generic
- # and c) will remain valid once DJGPP supports symlinks (DJGPP 2.04).
- if test -f conf$$.exe; then
- # Don't use ln at all; we don't have any links
- as_ln_s='cp -p'
- else
- as_ln_s='ln -s'
- fi
-elif ln conf$$.file conf$$ 2>/dev/null; then
- as_ln_s=ln
-else
- as_ln_s='cp -p'
-fi
-rm -f conf$$ conf$$.exe conf$$.file
-
-if mkdir -p . 2>/dev/null; then
- as_mkdir_p=:
-else
- test -d ./-p && rmdir ./-p
- as_mkdir_p=false
-fi
-
-as_executable_p="test -f"
-
-# Sed expression to map a string onto a valid CPP name.
-as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'"
-
-# Sed expression to map a string onto a valid variable name.
-as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'"
-
-
-# IFS
-# We need space, tab and new line, in precisely that order.
-as_nl='
-'
-IFS=" $as_nl"
-
-# CDPATH.
-$as_unset CDPATH
-
-
-
-# Check that we are running under the correct shell.
-SHELL=${CONFIG_SHELL-/bin/sh}
-
-case X$ECHO in
-X*--fallback-echo)
- # Remove one level of quotation (which was required for Make).
- ECHO=`echo "$ECHO" | sed 's,\\\\\$\\$0,'$0','`
- ;;
-esac
-
-echo=${ECHO-echo}
-if test "X$1" = X--no-reexec; then
- # Discard the --no-reexec flag, and continue.
- shift
-elif test "X$1" = X--fallback-echo; then
- # Avoid inline document here, it may be left over
- :
-elif test "X`($echo '\t') 2>/dev/null`" = 'X\t' ; then
- # Yippee, $echo works!
- :
-else
- # Restart under the correct shell.
- exec $SHELL "$0" --no-reexec ${1+"$@"}
-fi
-
-if test "X$1" = X--fallback-echo; then
- # used as fallback echo
- shift
- cat <<EOF
-$*
-EOF
- exit 0
-fi
-
-# The HP-UX ksh and POSIX shell print the target directory to stdout
-# if CDPATH is set.
-(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
-
-if test -z "$ECHO"; then
-if test "X${echo_test_string+set}" != Xset; then
-# find a string as large as possible, as long as the shell can cope with it
- for cmd in 'sed 50q "$0"' 'sed 20q "$0"' 'sed 10q "$0"' 'sed 2q "$0"' 'echo test'; do
- # expected sizes: less than 2Kb, 1Kb, 512 bytes, 16 bytes, ...
- if (echo_test_string=`eval $cmd`) 2>/dev/null &&
- echo_test_string=`eval $cmd` &&
- (test "X$echo_test_string" = "X$echo_test_string") 2>/dev/null
- then
- break
- fi
- done
-fi
-
-if test "X`($echo '\t') 2>/dev/null`" = 'X\t' &&
- echo_testing_string=`($echo "$echo_test_string") 2>/dev/null` &&
- test "X$echo_testing_string" = "X$echo_test_string"; then
- :
-else
- # The Solaris, AIX, and Digital Unix default echo programs unquote
- # backslashes. This makes it impossible to quote backslashes using
- # echo "$something" | sed 's/\\/\\\\/g'
- #
- # So, first we look for a working echo in the user's PATH.
-
- lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
- for dir in $PATH /usr/ucb; do
- IFS="$lt_save_ifs"
- if (test -f $dir/echo || test -f $dir/echo$ac_exeext) &&
- test "X`($dir/echo '\t') 2>/dev/null`" = 'X\t' &&
- echo_testing_string=`($dir/echo "$echo_test_string") 2>/dev/null` &&
- test "X$echo_testing_string" = "X$echo_test_string"; then
- echo="$dir/echo"
- break
- fi
- done
- IFS="$lt_save_ifs"
-
- if test "X$echo" = Xecho; then
- # We didn't find a better echo, so look for alternatives.
- if test "X`(print -r '\t') 2>/dev/null`" = 'X\t' &&
- echo_testing_string=`(print -r "$echo_test_string") 2>/dev/null` &&
- test "X$echo_testing_string" = "X$echo_test_string"; then
- # This shell has a builtin print -r that does the trick.
- echo='print -r'
- elif (test -f /bin/ksh || test -f /bin/ksh$ac_exeext) &&
- test "X$CONFIG_SHELL" != X/bin/ksh; then
- # If we have ksh, try running configure again with it.
- ORIGINAL_CONFIG_SHELL=${CONFIG_SHELL-/bin/sh}
- export ORIGINAL_CONFIG_SHELL
- CONFIG_SHELL=/bin/ksh
- export CONFIG_SHELL
- exec $CONFIG_SHELL "$0" --no-reexec ${1+"$@"}
- else
- # Try using printf.
- echo='printf %s\n'
- if test "X`($echo '\t') 2>/dev/null`" = 'X\t' &&
- echo_testing_string=`($echo "$echo_test_string") 2>/dev/null` &&
- test "X$echo_testing_string" = "X$echo_test_string"; then
- # Cool, printf works
- :
- elif echo_testing_string=`($ORIGINAL_CONFIG_SHELL "$0" --fallback-echo '\t') 2>/dev/null` &&
- test "X$echo_testing_string" = 'X\t' &&
- echo_testing_string=`($ORIGINAL_CONFIG_SHELL "$0" --fallback-echo "$echo_test_string") 2>/dev/null` &&
- test "X$echo_testing_string" = "X$echo_test_string"; then
- CONFIG_SHELL=$ORIGINAL_CONFIG_SHELL
- export CONFIG_SHELL
- SHELL="$CONFIG_SHELL"
- export SHELL
- echo="$CONFIG_SHELL $0 --fallback-echo"
- elif echo_testing_string=`($CONFIG_SHELL "$0" --fallback-echo '\t') 2>/dev/null` &&
- test "X$echo_testing_string" = 'X\t' &&
- echo_testing_string=`($CONFIG_SHELL "$0" --fallback-echo "$echo_test_string") 2>/dev/null` &&
- test "X$echo_testing_string" = "X$echo_test_string"; then
- echo="$CONFIG_SHELL $0 --fallback-echo"
- else
- # maybe with a smaller string...
- prev=:
-
- for cmd in 'echo test' 'sed 2q "$0"' 'sed 10q "$0"' 'sed 20q "$0"' 'sed 50q "$0"'; do
- if (test "X$echo_test_string" = "X`eval $cmd`") 2>/dev/null
- then
- break
- fi
- prev="$cmd"
- done
-
- if test "$prev" != 'sed 50q "$0"'; then
- echo_test_string=`eval $prev`
- export echo_test_string
- exec ${ORIGINAL_CONFIG_SHELL-${CONFIG_SHELL-/bin/sh}} "$0" ${1+"$@"}
- else
- # Oops. We lost completely, so just stick with echo.
- echo=echo
- fi
- fi
- fi
- fi
-fi
-fi
-
-# Copy echo and quote the copy suitably for passing to libtool from
-# the Makefile, instead of quoting the original, which is used later.
-ECHO=$echo
-if test "X$ECHO" = "X$CONFIG_SHELL $0 --fallback-echo"; then
- ECHO="$CONFIG_SHELL \\\$\$0 --fallback-echo"
-fi
-
-
-
-
-tagnames=${tagnames+${tagnames},}CXX
-
-tagnames=${tagnames+${tagnames},}F77
-
-# Name of the host.
-# hostname on some systems (SVR3.2, Linux) returns a bogus exit status,
-# so uname gets run too.
-ac_hostname=`(hostname || uname -n) 2>/dev/null | sed 1q`
-
-exec 6>&1
-
-#
-# Initializations.
-#
-ac_default_prefix=/usr/local
-ac_config_libobj_dir=.
-cross_compiling=no
-subdirs=
-MFLAGS=
-MAKEFLAGS=
-SHELL=${CONFIG_SHELL-/bin/sh}
-
-# Maximum number of lines to put in a shell here document.
-# This variable seems obsolete. It should probably be removed, and
-# only ac_max_sed_lines should be used.
-: ${ac_max_here_lines=38}
-
-# Identity of this package.
-PACKAGE_NAME='librdmacm'
-PACKAGE_TARNAME='librdmacm'
-PACKAGE_VERSION='1.0.11'
-PACKAGE_STRING='librdmacm 1.0.11'
-PACKAGE_BUGREPORT='general@lists.openfabrics.org'
-
-ac_unique_file="src/cma.c"
-# Factoring default headers for most tests.
-ac_includes_default="\
-#include <stdio.h>
-#if HAVE_SYS_TYPES_H
-# include <sys/types.h>
-#endif
-#if HAVE_SYS_STAT_H
-# include <sys/stat.h>
-#endif
-#if STDC_HEADERS
-# include <stdlib.h>
-# include <stddef.h>
-#else
-# if HAVE_STDLIB_H
-# include <stdlib.h>
-# endif
-#endif
-#if HAVE_STRING_H
-# if !STDC_HEADERS && HAVE_MEMORY_H
-# include <memory.h>
-# endif
-# include <string.h>
-#endif
-#if HAVE_STRINGS_H
-# include <strings.h>
-#endif
-#if HAVE_INTTYPES_H
-# include <inttypes.h>
-#else
-# if HAVE_STDINT_H
-# include <stdint.h>
-# endif
-#endif
-#if HAVE_UNISTD_H
-# include <unistd.h>
-#endif"
-
-ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS INSTALL_PROGRAM INSTALL_SCRIPT INSTALL_DATA CYGPATH_W PACKAGE VERSION ACLOCAL AUTOCONF AUTOMAKE AUTOHEADER MAKEINFO install_sh STRIP ac_ct_STRIP INSTALL_STRIP_PROGRAM mkdir_p AWK SET_MAKE am__leading_dot AMTAR am__tar am__untar build build_cpu build_vendor build_os host host_cpu host_vendor host_os CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC EXEEXT OBJEXT DEPDIR am__include am__quote AMDEP_TRUE AMDEP_FALSE AMDEPBACKSLASH CCDEPMODE am__fastdepCC_TRUE am__fastdepCC_FALSE EGREP LN_S ECHO AR ac_ct_AR RANLIB ac_ct_RANLIB CPP CXX CXXFLAGS ac_ct_CXX CXXDEPMODE am__fastdepCXX_TRUE am__fastdepCXX_FALSE CXXCPP F77 FFLAGS ac_ct_F77 LIBTOOL HAVE_LD_VERSION_SCRIPT_TRUE HAVE_LD_VERSION_SCRIPT_FALSE LIBOBJS LTLIBOBJS'
-ac_subst_files=''
-
-# Initialize some variables set by options.
-ac_init_help=
-ac_init_version=false
-# The variables have the same names as the options, with
-# dashes changed to underlines.
-cache_file=/dev/null
-exec_prefix=NONE
-no_create=
-no_recursion=
-prefix=NONE
-program_prefix=NONE
-program_suffix=NONE
-program_transform_name=s,x,x,
-silent=
-site=
-srcdir=
-verbose=
-x_includes=NONE
-x_libraries=NONE
-
-# Installation directory options.
-# These are left unexpanded so users can "make install exec_prefix=/foo"
-# and all the variables that are supposed to be based on exec_prefix
-# by default will actually change.
-# Use braces instead of parens because sh, perl, etc. also accept them.
-bindir='${exec_prefix}/bin'
-sbindir='${exec_prefix}/sbin'
-libexecdir='${exec_prefix}/libexec'
-datadir='${prefix}/share'
-sysconfdir='${prefix}/etc'
-sharedstatedir='${prefix}/com'
-localstatedir='${prefix}/var'
-libdir='${exec_prefix}/lib'
-includedir='${prefix}/include'
-oldincludedir='/usr/include'
-infodir='${prefix}/info'
-mandir='${prefix}/man'
-
-ac_prev=
-for ac_option
-do
- # If the previous option needs an argument, assign it.
- if test -n "$ac_prev"; then
- eval "$ac_prev=\$ac_option"
- ac_prev=
- continue
- fi
-
- ac_optarg=`expr "x$ac_option" : 'x[^=]*=\(.*\)'`
-
- # Accept the important Cygnus configure options, so we can diagnose typos.
-
- case $ac_option in
-
- -bindir | --bindir | --bindi | --bind | --bin | --bi)
- ac_prev=bindir ;;
- -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*)
- bindir=$ac_optarg ;;
-
- -build | --build | --buil | --bui | --bu)
- ac_prev=build_alias ;;
- -build=* | --build=* | --buil=* | --bui=* | --bu=*)
- build_alias=$ac_optarg ;;
-
- -cache-file | --cache-file | --cache-fil | --cache-fi \
- | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c)
- ac_prev=cache_file ;;
- -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \
- | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*)
- cache_file=$ac_optarg ;;
-
- --config-cache | -C)
- cache_file=config.cache ;;
-
- -datadir | --datadir | --datadi | --datad | --data | --dat | --da)
- ac_prev=datadir ;;
- -datadir=* | --datadir=* | --datadi=* | --datad=* | --data=* | --dat=* \
- | --da=*)
- datadir=$ac_optarg ;;
-
- -disable-* | --disable-*)
- ac_feature=`expr "x$ac_option" : 'x-*disable-\(.*\)'`
- # Reject names that are not valid shell variable names.
- expr "x$ac_feature" : ".*[^-_$as_cr_alnum]" >/dev/null &&
- { echo "$as_me: error: invalid feature name: $ac_feature" >&2
- { (exit 1); exit 1; }; }
- ac_feature=`echo $ac_feature | sed 's/-/_/g'`
- eval "enable_$ac_feature=no" ;;
-
- -enable-* | --enable-*)
- ac_feature=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'`
- # Reject names that are not valid shell variable names.
- expr "x$ac_feature" : ".*[^-_$as_cr_alnum]" >/dev/null &&
- { echo "$as_me: error: invalid feature name: $ac_feature" >&2
- { (exit 1); exit 1; }; }
- ac_feature=`echo $ac_feature | sed 's/-/_/g'`
- case $ac_option in
- *=*) ac_optarg=`echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"`;;
- *) ac_optarg=yes ;;
- esac
- eval "enable_$ac_feature='$ac_optarg'" ;;
-
- -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \
- | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \
- | --exec | --exe | --ex)
- ac_prev=exec_prefix ;;
- -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \
- | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \
- | --exec=* | --exe=* | --ex=*)
- exec_prefix=$ac_optarg ;;
-
- -gas | --gas | --ga | --g)
- # Obsolete; use --with-gas.
- with_gas=yes ;;
-
- -help | --help | --hel | --he | -h)
- ac_init_help=long ;;
- -help=r* | --help=r* | --hel=r* | --he=r* | -hr*)
- ac_init_help=recursive ;;
- -help=s* | --help=s* | --hel=s* | --he=s* | -hs*)
- ac_init_help=short ;;
-
- -host | --host | --hos | --ho)
- ac_prev=host_alias ;;
- -host=* | --host=* | --hos=* | --ho=*)
- host_alias=$ac_optarg ;;
-
- -includedir | --includedir | --includedi | --included | --include \
- | --includ | --inclu | --incl | --inc)
- ac_prev=includedir ;;
- -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \
- | --includ=* | --inclu=* | --incl=* | --inc=*)
- includedir=$ac_optarg ;;
-
- -infodir | --infodir | --infodi | --infod | --info | --inf)
- ac_prev=infodir ;;
- -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*)
- infodir=$ac_optarg ;;
-
- -libdir | --libdir | --libdi | --libd)
- ac_prev=libdir ;;
- -libdir=* | --libdir=* | --libdi=* | --libd=*)
- libdir=$ac_optarg ;;
-
- -libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \
- | --libexe | --libex | --libe)
- ac_prev=libexecdir ;;
- -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \
- | --libexe=* | --libex=* | --libe=*)
- libexecdir=$ac_optarg ;;
-
- -localstatedir | --localstatedir | --localstatedi | --localstated \
- | --localstate | --localstat | --localsta | --localst \
- | --locals | --local | --loca | --loc | --lo)
- ac_prev=localstatedir ;;
- -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \
- | --localstate=* | --localstat=* | --localsta=* | --localst=* \
- | --locals=* | --local=* | --loca=* | --loc=* | --lo=*)
- localstatedir=$ac_optarg ;;
-
- -mandir | --mandir | --mandi | --mand | --man | --ma | --m)
- ac_prev=mandir ;;
- -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*)
- mandir=$ac_optarg ;;
-
- -nfp | --nfp | --nf)
- # Obsolete; use --without-fp.
- with_fp=no ;;
-
- -no-create | --no-create | --no-creat | --no-crea | --no-cre \
- | --no-cr | --no-c | -n)
- no_create=yes ;;
-
- -no-recursion | --no-recursion | --no-recursio | --no-recursi \
- | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r)
- no_recursion=yes ;;
-
- -oldincludedir | --oldincludedir | --oldincludedi | --oldincluded \
- | --oldinclude | --oldinclud | --oldinclu | --oldincl | --oldinc \
- | --oldin | --oldi | --old | --ol | --o)
- ac_prev=oldincludedir ;;
- -oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \
- | --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \
- | --oldin=* | --oldi=* | --old=* | --ol=* | --o=*)
- oldincludedir=$ac_optarg ;;
-
- -prefix | --prefix | --prefi | --pref | --pre | --pr | --p)
- ac_prev=prefix ;;
- -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*)
- prefix=$ac_optarg ;;
-
- -program-prefix | --program-prefix | --program-prefi | --program-pref \
- | --program-pre | --program-pr | --program-p)
- ac_prev=program_prefix ;;
- -program-prefix=* | --program-prefix=* | --program-prefi=* \
- | --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*)
- program_prefix=$ac_optarg ;;
-
- -program-suffix | --program-suffix | --program-suffi | --program-suff \
- | --program-suf | --program-su | --program-s)
- ac_prev=program_suffix ;;
- -program-suffix=* | --program-suffix=* | --program-suffi=* \
- | --program-suff=* | --program-suf=* | --program-su=* | --program-s=*)
- program_suffix=$ac_optarg ;;
-
- -program-transform-name | --program-transform-name \
- | --program-transform-nam | --program-transform-na \
- | --program-transform-n | --program-transform- \
- | --program-transform | --program-transfor \
- | --program-transfo | --program-transf \
- | --program-trans | --program-tran \
- | --progr-tra | --program-tr | --program-t)
- ac_prev=program_transform_name ;;
- -program-transform-name=* | --program-transform-name=* \
- | --program-transform-nam=* | --program-transform-na=* \
- | --program-transform-n=* | --program-transform-=* \
- | --program-transform=* | --program-transfor=* \
- | --program-transfo=* | --program-transf=* \
- | --program-trans=* | --program-tran=* \
- | --progr-tra=* | --program-tr=* | --program-t=*)
- program_transform_name=$ac_optarg ;;
-
- -q | -quiet | --quiet | --quie | --qui | --qu | --q \
- | -silent | --silent | --silen | --sile | --sil)
- silent=yes ;;
-
- -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb)
- ac_prev=sbindir ;;
- -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \
- | --sbi=* | --sb=*)
- sbindir=$ac_optarg ;;
-
- -sharedstatedir | --sharedstatedir | --sharedstatedi \
- | --sharedstated | --sharedstate | --sharedstat | --sharedsta \
- | --sharedst | --shareds | --shared | --share | --shar \
- | --sha | --sh)
- ac_prev=sharedstatedir ;;
- -sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \
- | --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \
- | --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \
- | --sha=* | --sh=*)
- sharedstatedir=$ac_optarg ;;
-
- -site | --site | --sit)
- ac_prev=site ;;
- -site=* | --site=* | --sit=*)
- site=$ac_optarg ;;
-
- -srcdir | --srcdir | --srcdi | --srcd | --src | --sr)
- ac_prev=srcdir ;;
- -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*)
- srcdir=$ac_optarg ;;
-
- -sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \
- | --syscon | --sysco | --sysc | --sys | --sy)
- ac_prev=sysconfdir ;;
- -sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \
- | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*)
- sysconfdir=$ac_optarg ;;
-
- -target | --target | --targe | --targ | --tar | --ta | --t)
- ac_prev=target_alias ;;
- -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*)
- target_alias=$ac_optarg ;;
-
- -v | -verbose | --verbose | --verbos | --verbo | --verb)
- verbose=yes ;;
-
- -version | --version | --versio | --versi | --vers | -V)
- ac_init_version=: ;;
-
- -with-* | --with-*)
- ac_package=`expr "x$ac_option" : 'x-*with-\([^=]*\)'`
- # Reject names that are not valid shell variable names.
- expr "x$ac_package" : ".*[^-_$as_cr_alnum]" >/dev/null &&
- { echo "$as_me: error: invalid package name: $ac_package" >&2
- { (exit 1); exit 1; }; }
- ac_package=`echo $ac_package| sed 's/-/_/g'`
- case $ac_option in
- *=*) ac_optarg=`echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"`;;
- *) ac_optarg=yes ;;
- esac
- eval "with_$ac_package='$ac_optarg'" ;;
-
- -without-* | --without-*)
- ac_package=`expr "x$ac_option" : 'x-*without-\(.*\)'`
- # Reject names that are not valid shell variable names.
- expr "x$ac_package" : ".*[^-_$as_cr_alnum]" >/dev/null &&
- { echo "$as_me: error: invalid package name: $ac_package" >&2
- { (exit 1); exit 1; }; }
- ac_package=`echo $ac_package | sed 's/-/_/g'`
- eval "with_$ac_package=no" ;;
-
- --x)
- # Obsolete; use --with-x.
- with_x=yes ;;
-
- -x-includes | --x-includes | --x-include | --x-includ | --x-inclu \
- | --x-incl | --x-inc | --x-in | --x-i)
- ac_prev=x_includes ;;
- -x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \
- | --x-incl=* | --x-inc=* | --x-in=* | --x-i=*)
- x_includes=$ac_optarg ;;
-
- -x-libraries | --x-libraries | --x-librarie | --x-librari \
- | --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l)
- ac_prev=x_libraries ;;
- -x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \
- | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*)
- x_libraries=$ac_optarg ;;
-
- -*) { echo "$as_me: error: unrecognized option: $ac_option
-Try \`$0 --help' for more information." >&2
- { (exit 1); exit 1; }; }
- ;;
-
- *=*)
- ac_envvar=`expr "x$ac_option" : 'x\([^=]*\)='`
- # Reject names that are not valid shell variable names.
- expr "x$ac_envvar" : ".*[^_$as_cr_alnum]" >/dev/null &&
- { echo "$as_me: error: invalid variable name: $ac_envvar" >&2
- { (exit 1); exit 1; }; }
- ac_optarg=`echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"`
- eval "$ac_envvar='$ac_optarg'"
- export $ac_envvar ;;
-
- *)
- # FIXME: should be removed in autoconf 3.0.
- echo "$as_me: WARNING: you should use --build, --host, --target" >&2
- expr "x$ac_option" : ".*[^-._$as_cr_alnum]" >/dev/null &&
- echo "$as_me: WARNING: invalid host type: $ac_option" >&2
- : ${build_alias=$ac_option} ${host_alias=$ac_option} ${target_alias=$ac_option}
- ;;
-
- esac
-done
-
-if test -n "$ac_prev"; then
- ac_option=--`echo $ac_prev | sed 's/_/-/g'`
- { echo "$as_me: error: missing argument to $ac_option" >&2
- { (exit 1); exit 1; }; }
-fi
-
-# Be sure to have absolute paths.
-for ac_var in exec_prefix prefix
-do
- eval ac_val=$`echo $ac_var`
- case $ac_val in
- [\\/$]* | ?:[\\/]* | NONE | '' ) ;;
- *) { echo "$as_me: error: expected an absolute directory name for --$ac_var: $ac_val" >&2
- { (exit 1); exit 1; }; };;
- esac
-done
-
-# Be sure to have absolute paths.
-for ac_var in bindir sbindir libexecdir datadir sysconfdir sharedstatedir \
- localstatedir libdir includedir oldincludedir infodir mandir
-do
- eval ac_val=$`echo $ac_var`
- case $ac_val in
- [\\/$]* | ?:[\\/]* ) ;;
- *) { echo "$as_me: error: expected an absolute directory name for --$ac_var: $ac_val" >&2
- { (exit 1); exit 1; }; };;
- esac
-done
-
-# There might be people who depend on the old broken behavior: `$host'
-# used to hold the argument of --host etc.
-# FIXME: To remove some day.
-build=$build_alias
-host=$host_alias
-target=$target_alias
-
-# FIXME: To remove some day.
-if test "x$host_alias" != x; then
- if test "x$build_alias" = x; then
- cross_compiling=maybe
- echo "$as_me: WARNING: If you wanted to set the --build type, don't use --host.
- If a cross compiler is detected then cross compile mode will be used." >&2
- elif test "x$build_alias" != "x$host_alias"; then
- cross_compiling=yes
- fi
-fi
-
-ac_tool_prefix=
-test -n "$host_alias" && ac_tool_prefix=$host_alias-
-
-test "$silent" = yes && exec 6>/dev/null
-
-
-# Find the source files, if location was not specified.
-if test -z "$srcdir"; then
- ac_srcdir_defaulted=yes
- # Try the directory containing this script, then its parent.
- ac_confdir=`(dirname "$0") 2>/dev/null ||
-$as_expr X"$0" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
- X"$0" : 'X\(//\)[^/]' \| \
- X"$0" : 'X\(//\)$' \| \
- X"$0" : 'X\(/\)' \| \
- . : '\(.\)' 2>/dev/null ||
-echo X"$0" |
- sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; }
- /^X\(\/\/\)[^/].*/{ s//\1/; q; }
- /^X\(\/\/\)$/{ s//\1/; q; }
- /^X\(\/\).*/{ s//\1/; q; }
- s/.*/./; q'`
- srcdir=$ac_confdir
- if test ! -r $srcdir/$ac_unique_file; then
- srcdir=..
- fi
-else
- ac_srcdir_defaulted=no
-fi
-if test ! -r $srcdir/$ac_unique_file; then
- if test "$ac_srcdir_defaulted" = yes; then
- { echo "$as_me: error: cannot find sources ($ac_unique_file) in $ac_confdir or .." >&2
- { (exit 1); exit 1; }; }
- else
- { echo "$as_me: error: cannot find sources ($ac_unique_file) in $srcdir" >&2
- { (exit 1); exit 1; }; }
- fi
-fi
-(cd $srcdir && test -r ./$ac_unique_file) 2>/dev/null ||
- { echo "$as_me: error: sources are in $srcdir, but \`cd $srcdir' does not work" >&2
- { (exit 1); exit 1; }; }
-srcdir=`echo "$srcdir" | sed 's%\([^\\/]\)[\\/]*$%\1%'`
-ac_env_build_alias_set=${build_alias+set}
-ac_env_build_alias_value=$build_alias
-ac_cv_env_build_alias_set=${build_alias+set}
-ac_cv_env_build_alias_value=$build_alias
-ac_env_host_alias_set=${host_alias+set}
-ac_env_host_alias_value=$host_alias
-ac_cv_env_host_alias_set=${host_alias+set}
-ac_cv_env_host_alias_value=$host_alias
-ac_env_target_alias_set=${target_alias+set}
-ac_env_target_alias_value=$target_alias
-ac_cv_env_target_alias_set=${target_alias+set}
-ac_cv_env_target_alias_value=$target_alias
-ac_env_CC_set=${CC+set}
-ac_env_CC_value=$CC
-ac_cv_env_CC_set=${CC+set}
-ac_cv_env_CC_value=$CC
-ac_env_CFLAGS_set=${CFLAGS+set}
-ac_env_CFLAGS_value=$CFLAGS
-ac_cv_env_CFLAGS_set=${CFLAGS+set}
-ac_cv_env_CFLAGS_value=$CFLAGS
-ac_env_LDFLAGS_set=${LDFLAGS+set}
-ac_env_LDFLAGS_value=$LDFLAGS
-ac_cv_env_LDFLAGS_set=${LDFLAGS+set}
-ac_cv_env_LDFLAGS_value=$LDFLAGS
-ac_env_CPPFLAGS_set=${CPPFLAGS+set}
-ac_env_CPPFLAGS_value=$CPPFLAGS
-ac_cv_env_CPPFLAGS_set=${CPPFLAGS+set}
-ac_cv_env_CPPFLAGS_value=$CPPFLAGS
-ac_env_CPP_set=${CPP+set}
-ac_env_CPP_value=$CPP
-ac_cv_env_CPP_set=${CPP+set}
-ac_cv_env_CPP_value=$CPP
-ac_env_CXX_set=${CXX+set}
-ac_env_CXX_value=$CXX
-ac_cv_env_CXX_set=${CXX+set}
-ac_cv_env_CXX_value=$CXX
-ac_env_CXXFLAGS_set=${CXXFLAGS+set}
-ac_env_CXXFLAGS_value=$CXXFLAGS
-ac_cv_env_CXXFLAGS_set=${CXXFLAGS+set}
-ac_cv_env_CXXFLAGS_value=$CXXFLAGS
-ac_env_CXXCPP_set=${CXXCPP+set}
-ac_env_CXXCPP_value=$CXXCPP
-ac_cv_env_CXXCPP_set=${CXXCPP+set}
-ac_cv_env_CXXCPP_value=$CXXCPP
-ac_env_F77_set=${F77+set}
-ac_env_F77_value=$F77
-ac_cv_env_F77_set=${F77+set}
-ac_cv_env_F77_value=$F77
-ac_env_FFLAGS_set=${FFLAGS+set}
-ac_env_FFLAGS_value=$FFLAGS
-ac_cv_env_FFLAGS_set=${FFLAGS+set}
-ac_cv_env_FFLAGS_value=$FFLAGS
-
-#
-# Report the --help message.
-#
-if test "$ac_init_help" = "long"; then
- # Omit some internal or obsolete options to make the list less imposing.
- # This message is too long to be a string in the A/UX 3.1 sh.
- cat <<_ACEOF
-\`configure' configures librdmacm 1.0.11 to adapt to many kinds of systems.
-
-Usage: $0 [OPTION]... [VAR=VALUE]...
-
-To assign environment variables (e.g., CC, CFLAGS...), specify them as
-VAR=VALUE. See below for descriptions of some of the useful variables.
-
-Defaults for the options are specified in brackets.
-
-Configuration:
- -h, --help display this help and exit
- --help=short display options specific to this package
- --help=recursive display the short help of all the included packages
- -V, --version display version information and exit
- -q, --quiet, --silent do not print \`checking...' messages
- --cache-file=FILE cache test results in FILE [disabled]
- -C, --config-cache alias for \`--cache-file=config.cache'
- -n, --no-create do not create output files
- --srcdir=DIR find the sources in DIR [configure dir or \`..']
-
-_ACEOF
-
- cat <<_ACEOF
-Installation directories:
- --prefix=PREFIX install architecture-independent files in PREFIX
- [$ac_default_prefix]
- --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX
- [PREFIX]
-
-By default, \`make install' will install all the files in
-\`$ac_default_prefix/bin', \`$ac_default_prefix/lib' etc. You can specify
-an installation prefix other than \`$ac_default_prefix' using \`--prefix',
-for instance \`--prefix=\$HOME'.
-
-For better control, use the options below.
-
-Fine tuning of the installation directories:
- --bindir=DIR user executables [EPREFIX/bin]
- --sbindir=DIR system admin executables [EPREFIX/sbin]
- --libexecdir=DIR program executables [EPREFIX/libexec]
- --datadir=DIR read-only architecture-independent data [PREFIX/share]
- --sysconfdir=DIR read-only single-machine data [PREFIX/etc]
- --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com]
- --localstatedir=DIR modifiable single-machine data [PREFIX/var]
- --libdir=DIR object code libraries [EPREFIX/lib]
- --includedir=DIR C header files [PREFIX/include]
- --oldincludedir=DIR C header files for non-gcc [/usr/include]
- --infodir=DIR info documentation [PREFIX/info]
- --mandir=DIR man documentation [PREFIX/man]
-_ACEOF
-
- cat <<\_ACEOF
-
-Program names:
- --program-prefix=PREFIX prepend PREFIX to installed program names
- --program-suffix=SUFFIX append SUFFIX to installed program names
- --program-transform-name=PROGRAM run sed PROGRAM on installed program names
-
-System types:
- --build=BUILD configure for building on BUILD [guessed]
- --host=HOST cross-compile to build programs to run on HOST [BUILD]
-_ACEOF
-fi
-
-if test -n "$ac_init_help"; then
- case $ac_init_help in
- short | recursive ) echo "Configuration of librdmacm 1.0.11:";;
- esac
- cat <<\_ACEOF
-
-Optional Features:
- --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no)
- --enable-FEATURE[=ARG] include FEATURE [ARG=yes]
- --enable-shared[=PKGS]
- build shared libraries [default=yes]
- --enable-static[=PKGS]
- build static libraries [default=yes]
- --enable-fast-install[=PKGS]
- optimize for fast installation [default=yes]
- --disable-dependency-tracking speeds up one-time build
- --enable-dependency-tracking do not reject slow dependency extractors
- --disable-libtool-lock avoid locking (might break parallel builds)
- --disable-libcheck do not test for presence of ib libraries
-
-Optional Packages:
- --with-PACKAGE[=ARG] use PACKAGE [ARG=yes]
- --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no)
- --with-gnu-ld assume the C compiler uses GNU ld [default=no]
- --with-pic try to use only PIC/non-PIC objects [default=use
- both]
- --with-tags[=TAGS]
- include additional configurations [automatic]
- --with-valgrind Enable valgrind annotations - default NO
-
-Some influential environment variables:
- CC C compiler command
- CFLAGS C compiler flags
- LDFLAGS linker flags, e.g. -L<lib dir> if you have libraries in a
- nonstandard directory <lib dir>
- CPPFLAGS C/C++ preprocessor flags, e.g. -I<include dir> if you have
- headers in a nonstandard directory <include dir>
- CPP C preprocessor
- CXX C++ compiler command
- CXXFLAGS C++ compiler flags
- CXXCPP C++ preprocessor
- F77 Fortran 77 compiler command
- FFLAGS Fortran 77 compiler flags
-
-Use these variables to override the choices made by `configure' or to help
-it to find libraries and programs with nonstandard names/locations.
-
-Report bugs to <general@lists.openfabrics.org>.
-_ACEOF
-fi
-
-if test "$ac_init_help" = "recursive"; then
- # If there are subdirs, report their specific --help.
- ac_popdir=`pwd`
- for ac_dir in : $ac_subdirs_all; do test "x$ac_dir" = x: && continue
- test -d $ac_dir || continue
- ac_builddir=.
-
-if test "$ac_dir" != .; then
- ac_dir_suffix=/`echo "$ac_dir" | sed 's,^\.[\\/],,'`
- # A "../" for each directory in $ac_dir_suffix.
- ac_top_builddir=`echo "$ac_dir_suffix" | sed 's,/[^\\/]*,../,g'`
-else
- ac_dir_suffix= ac_top_builddir=
-fi
-
-case $srcdir in
- .) # No --srcdir option. We are building in place.
- ac_srcdir=.
- if test -z "$ac_top_builddir"; then
- ac_top_srcdir=.
- else
- ac_top_srcdir=`echo $ac_top_builddir | sed 's,/$,,'`
- fi ;;
- [\\/]* | ?:[\\/]* ) # Absolute path.
- ac_srcdir=$srcdir$ac_dir_suffix;
- ac_top_srcdir=$srcdir ;;
- *) # Relative path.
- ac_srcdir=$ac_top_builddir$srcdir$ac_dir_suffix
- ac_top_srcdir=$ac_top_builddir$srcdir ;;
-esac
-
-# Do not use `cd foo && pwd` to compute absolute paths, because
-# the directories may not exist.
-case `pwd` in
-.) ac_abs_builddir="$ac_dir";;
-*)
- case "$ac_dir" in
- .) ac_abs_builddir=`pwd`;;
- [\\/]* | ?:[\\/]* ) ac_abs_builddir="$ac_dir";;
- *) ac_abs_builddir=`pwd`/"$ac_dir";;
- esac;;
-esac
-case $ac_abs_builddir in
-.) ac_abs_top_builddir=${ac_top_builddir}.;;
-*)
- case ${ac_top_builddir}. in
- .) ac_abs_top_builddir=$ac_abs_builddir;;
- [\\/]* | ?:[\\/]* ) ac_abs_top_builddir=${ac_top_builddir}.;;
- *) ac_abs_top_builddir=$ac_abs_builddir/${ac_top_builddir}.;;
- esac;;
-esac
-case $ac_abs_builddir in
-.) ac_abs_srcdir=$ac_srcdir;;
-*)
- case $ac_srcdir in
- .) ac_abs_srcdir=$ac_abs_builddir;;
- [\\/]* | ?:[\\/]* ) ac_abs_srcdir=$ac_srcdir;;
- *) ac_abs_srcdir=$ac_abs_builddir/$ac_srcdir;;
- esac;;
-esac
-case $ac_abs_builddir in
-.) ac_abs_top_srcdir=$ac_top_srcdir;;
-*)
- case $ac_top_srcdir in
- .) ac_abs_top_srcdir=$ac_abs_builddir;;
- [\\/]* | ?:[\\/]* ) ac_abs_top_srcdir=$ac_top_srcdir;;
- *) ac_abs_top_srcdir=$ac_abs_builddir/$ac_top_srcdir;;
- esac;;
-esac
-
- cd $ac_dir
- # Check for guested configure; otherwise get Cygnus style configure.
- if test -f $ac_srcdir/configure.gnu; then
- echo
- $SHELL $ac_srcdir/configure.gnu --help=recursive
- elif test -f $ac_srcdir/configure; then
- echo
- $SHELL $ac_srcdir/configure --help=recursive
- elif test -f $ac_srcdir/configure.ac ||
- test -f $ac_srcdir/configure.in; then
- echo
- $ac_configure --help
- else
- echo "$as_me: WARNING: no configuration information is in $ac_dir" >&2
- fi
- cd "$ac_popdir"
- done
-fi
-
-test -n "$ac_init_help" && exit 0
-if $ac_init_version; then
- cat <<\_ACEOF
-librdmacm configure 1.0.11
-generated by GNU Autoconf 2.59
-
-Copyright (C) 2003 Free Software Foundation, Inc.
-This configure script is free software; the Free Software Foundation
-gives unlimited permission to copy, distribute and modify it.
-_ACEOF
- exit 0
-fi
-exec 5>config.log
-cat >&5 <<_ACEOF
-This file contains any messages produced by compilers while
-running configure, to aid debugging if configure makes a mistake.
-
-It was created by librdmacm $as_me 1.0.11, which was
-generated by GNU Autoconf 2.59. Invocation command line was
-
- $ $0 $@
-
-_ACEOF
-{
-cat <<_ASUNAME
-## --------- ##
-## Platform. ##
-## --------- ##
-
-hostname = `(hostname || uname -n) 2>/dev/null | sed 1q`
-uname -m = `(uname -m) 2>/dev/null || echo unknown`
-uname -r = `(uname -r) 2>/dev/null || echo unknown`
-uname -s = `(uname -s) 2>/dev/null || echo unknown`
-uname -v = `(uname -v) 2>/dev/null || echo unknown`
-
-/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null || echo unknown`
-/bin/uname -X = `(/bin/uname -X) 2>/dev/null || echo unknown`
-
-/bin/arch = `(/bin/arch) 2>/dev/null || echo unknown`
-/usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null || echo unknown`
-/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null || echo unknown`
-hostinfo = `(hostinfo) 2>/dev/null || echo unknown`
-/bin/machine = `(/bin/machine) 2>/dev/null || echo unknown`
-/usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null || echo unknown`
-/bin/universe = `(/bin/universe) 2>/dev/null || echo unknown`
-
-_ASUNAME
-
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
- IFS=$as_save_IFS
- test -z "$as_dir" && as_dir=.
- echo "PATH: $as_dir"
-done
-
-} >&5
-
-cat >&5 <<_ACEOF
-
-
-## ----------- ##
-## Core tests. ##
-## ----------- ##
-
-_ACEOF
-
-
-# Keep a trace of the command line.
-# Strip out --no-create and --no-recursion so they do not pile up.
-# Strip out --silent because we don't want to record it for future runs.
-# Also quote any args containing shell meta-characters.
-# Make two passes to allow for proper duplicate-argument suppression.
-ac_configure_args=
-ac_configure_args0=
-ac_configure_args1=
-ac_sep=
-ac_must_keep_next=false
-for ac_pass in 1 2
-do
- for ac_arg
- do
- case $ac_arg in
- -no-create | --no-c* | -n | -no-recursion | --no-r*) continue ;;
- -q | -quiet | --quiet | --quie | --qui | --qu | --q \
- | -silent | --silent | --silen | --sile | --sil)
- continue ;;
- *" "*|*" "*|*[\[\]\~\#\$\^\&\*\(\)\{\}\\\|\;\<\>\?\"\']*)
- ac_arg=`echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;;
- esac
- case $ac_pass in
- 1) ac_configure_args0="$ac_configure_args0 '$ac_arg'" ;;
- 2)
- ac_configure_args1="$ac_configure_args1 '$ac_arg'"
- if test $ac_must_keep_next = true; then
- ac_must_keep_next=false # Got value, back to normal.
- else
- case $ac_arg in
- *=* | --config-cache | -C | -disable-* | --disable-* \
- | -enable-* | --enable-* | -gas | --g* | -nfp | --nf* \
- | -q | -quiet | --q* | -silent | --sil* | -v | -verb* \
- | -with-* | --with-* | -without-* | --without-* | --x)
- case "$ac_configure_args0 " in
- "$ac_configure_args1"*" '$ac_arg' "* ) continue ;;
- esac
- ;;
- -* ) ac_must_keep_next=true ;;
- esac
- fi
- ac_configure_args="$ac_configure_args$ac_sep'$ac_arg'"
- # Get rid of the leading space.
- ac_sep=" "
- ;;
- esac
- done
-done
-$as_unset ac_configure_args0 || test "${ac_configure_args0+set}" != set || { ac_configure_args0=; export ac_configure_args0; }
-$as_unset ac_configure_args1 || test "${ac_configure_args1+set}" != set || { ac_configure_args1=; export ac_configure_args1; }
-
-# When interrupted or exit'd, cleanup temporary files, and complete
-# config.log. We remove comments because anyway the quotes in there
-# would cause problems or look ugly.
-# WARNING: Be sure not to use single quotes in there, as some shells,
-# such as our DU 5.0 friend, will then `close' the trap.
-trap 'exit_status=$?
- # Save into config.log some information that might help in debugging.
- {
- echo
-
- cat <<\_ASBOX
-## ---------------- ##
-## Cache variables. ##
-## ---------------- ##
-_ASBOX
- echo
- # The following way of writing the cache mishandles newlines in values,
-{
- (set) 2>&1 |
- case `(ac_space='"'"' '"'"'; set | grep ac_space) 2>&1` in
- *ac_space=\ *)
- sed -n \
- "s/'"'"'/'"'"'\\\\'"'"''"'"'/g;
- s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='"'"'\\2'"'"'/p"
- ;;
- *)
- sed -n \
- "s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1=\\2/p"
- ;;
- esac;
-}
- echo
-
- cat <<\_ASBOX
-## ----------------- ##
-## Output variables. ##
-## ----------------- ##
-_ASBOX
- echo
- for ac_var in $ac_subst_vars
- do
- eval ac_val=$`echo $ac_var`
- echo "$ac_var='"'"'$ac_val'"'"'"
- done | sort
- echo
-
- if test -n "$ac_subst_files"; then
- cat <<\_ASBOX
-## ------------- ##
-## Output files. ##
-## ------------- ##
-_ASBOX
- echo
- for ac_var in $ac_subst_files
- do
- eval ac_val=$`echo $ac_var`
- echo "$ac_var='"'"'$ac_val'"'"'"
- done | sort
- echo
- fi
-
- if test -s confdefs.h; then
- cat <<\_ASBOX
-## ----------- ##
-## confdefs.h. ##
-## ----------- ##
-_ASBOX
- echo
- sed "/^$/d" confdefs.h | sort
- echo
- fi
- test "$ac_signal" != 0 &&
- echo "$as_me: caught signal $ac_signal"
- echo "$as_me: exit $exit_status"
- } >&5
- rm -f core *.core &&
- rm -rf conftest* confdefs* conf$$* $ac_clean_files &&
- exit $exit_status
- ' 0
-for ac_signal in 1 2 13 15; do
- trap 'ac_signal='$ac_signal'; { (exit 1); exit 1; }' $ac_signal
-done
-ac_signal=0
-
-# confdefs.h avoids OS command line length limits that DEFS can exceed.
-rm -rf conftest* confdefs.h
-# AIX cpp loses on an empty file, so make sure it contains at least a newline.
-echo >confdefs.h
-
-# Predefined preprocessor variables.
-
-cat >>confdefs.h <<_ACEOF
-#define PACKAGE_NAME "$PACKAGE_NAME"
-_ACEOF
-
-
-cat >>confdefs.h <<_ACEOF
-#define PACKAGE_TARNAME "$PACKAGE_TARNAME"
-_ACEOF
-
-
-cat >>confdefs.h <<_ACEOF
-#define PACKAGE_VERSION "$PACKAGE_VERSION"
-_ACEOF
-
-
-cat >>confdefs.h <<_ACEOF
-#define PACKAGE_STRING "$PACKAGE_STRING"
-_ACEOF
-
-
-cat >>confdefs.h <<_ACEOF
-#define PACKAGE_BUGREPORT "$PACKAGE_BUGREPORT"
-_ACEOF
-
-
-# Let the site file select an alternate cache file if it wants to.
-# Prefer explicitly selected file to automatically selected ones.
-if test -z "$CONFIG_SITE"; then
- if test "x$prefix" != xNONE; then
- CONFIG_SITE="$prefix/share/config.site $prefix/etc/config.site"
- else
- CONFIG_SITE="$ac_default_prefix/share/config.site $ac_default_prefix/etc/config.site"
- fi
-fi
-for ac_site_file in $CONFIG_SITE; do
- if test -r "$ac_site_file"; then
- { echo "$as_me:$LINENO: loading site script $ac_site_file" >&5
-echo "$as_me: loading site script $ac_site_file" >&6;}
- sed 's/^/| /' "$ac_site_file" >&5
- . "$ac_site_file"
- fi
-done
-
-if test -r "$cache_file"; then
- # Some versions of bash will fail to source /dev/null (special
- # files actually), so we avoid doing that.
- if test -f "$cache_file"; then
- { echo "$as_me:$LINENO: loading cache $cache_file" >&5
-echo "$as_me: loading cache $cache_file" >&6;}
- case $cache_file in
- [\\/]* | ?:[\\/]* ) . $cache_file;;
- *) . ./$cache_file;;
- esac
- fi
-else
- { echo "$as_me:$LINENO: creating cache $cache_file" >&5
-echo "$as_me: creating cache $cache_file" >&6;}
- >$cache_file
-fi
-
-# Check that the precious variables saved in the cache have kept the same
-# value.
-ac_cache_corrupted=false
-for ac_var in `(set) 2>&1 |
- sed -n 's/^ac_env_\([a-zA-Z_0-9]*\)_set=.*/\1/p'`; do
- eval ac_old_set=\$ac_cv_env_${ac_var}_set
- eval ac_new_set=\$ac_env_${ac_var}_set
- eval ac_old_val="\$ac_cv_env_${ac_var}_value"
- eval ac_new_val="\$ac_env_${ac_var}_value"
- case $ac_old_set,$ac_new_set in
- set,)
- { echo "$as_me:$LINENO: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5
-echo "$as_me: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&2;}
- ac_cache_corrupted=: ;;
- ,set)
- { echo "$as_me:$LINENO: error: \`$ac_var' was not set in the previous run" >&5
-echo "$as_me: error: \`$ac_var' was not set in the previous run" >&2;}
- ac_cache_corrupted=: ;;
- ,);;
- *)
- if test "x$ac_old_val" != "x$ac_new_val"; then
- { echo "$as_me:$LINENO: error: \`$ac_var' has changed since the previous run:" >&5
-echo "$as_me: error: \`$ac_var' has changed since the previous run:" >&2;}
- { echo "$as_me:$LINENO: former value: $ac_old_val" >&5
-echo "$as_me: former value: $ac_old_val" >&2;}
- { echo "$as_me:$LINENO: current value: $ac_new_val" >&5
-echo "$as_me: current value: $ac_new_val" >&2;}
- ac_cache_corrupted=:
- fi;;
- esac
- # Pass precious variables to config.status.
- if test "$ac_new_set" = set; then
- case $ac_new_val in
- *" "*|*" "*|*[\[\]\~\#\$\^\&\*\(\)\{\}\\\|\;\<\>\?\"\']*)
- ac_arg=$ac_var=`echo "$ac_new_val" | sed "s/'/'\\\\\\\\''/g"` ;;
- *) ac_arg=$ac_var=$ac_new_val ;;
- esac
- case " $ac_configure_args " in
- *" '$ac_arg' "*) ;; # Avoid dups. Use of quotes ensures accuracy.
- *) ac_configure_args="$ac_configure_args '$ac_arg'" ;;
- esac
- fi
-done
-if $ac_cache_corrupted; then
- { echo "$as_me:$LINENO: error: changes in the environment can compromise the build" >&5
-echo "$as_me: error: changes in the environment can compromise the build" >&2;}
- { { echo "$as_me:$LINENO: error: run \`make distclean' and/or \`rm $cache_file' and start over" >&5
-echo "$as_me: error: run \`make distclean' and/or \`rm $cache_file' and start over" >&2;}
- { (exit 1); exit 1; }; }
-fi
-
-ac_ext=c
-ac_cpp='$CPP $CPPFLAGS'
-ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
-ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
-ac_compiler_gnu=$ac_cv_c_compiler_gnu
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-ac_aux_dir=
-for ac_dir in config $srcdir/config; do
- if test -f $ac_dir/install-sh; then
- ac_aux_dir=$ac_dir
- ac_install_sh="$ac_aux_dir/install-sh -c"
- break
- elif test -f $ac_dir/install.sh; then
- ac_aux_dir=$ac_dir
- ac_install_sh="$ac_aux_dir/install.sh -c"
- break
- elif test -f $ac_dir/shtool; then
- ac_aux_dir=$ac_dir
- ac_install_sh="$ac_aux_dir/shtool install -c"
- break
- fi
-done
-if test -z "$ac_aux_dir"; then
- { { echo "$as_me:$LINENO: error: cannot find install-sh or install.sh in config $srcdir/config" >&5
-echo "$as_me: error: cannot find install-sh or install.sh in config $srcdir/config" >&2;}
- { (exit 1); exit 1; }; }
-fi
-ac_config_guess="$SHELL $ac_aux_dir/config.guess"
-ac_config_sub="$SHELL $ac_aux_dir/config.sub"
-ac_configure="$SHELL $ac_aux_dir/configure" # This should be Cygnus configure.
-
- ac_config_headers="$ac_config_headers config.h"
-
-am__api_version="1.9"
-# Find a good install program. We prefer a C program (faster),
-# so one script is as good as another. But avoid the broken or
-# incompatible versions:
-# SysV /etc/install, /usr/sbin/install
-# SunOS /usr/etc/install
-# IRIX /sbin/install
-# AIX /bin/install
-# AmigaOS /C/install, which installs bootblocks on floppy discs
-# AIX 4 /usr/bin/installbsd, which doesn't work without a -g flag
-# AFS /usr/afsws/bin/install, which mishandles nonexistent args
-# SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff"
-# OS/2's system install, which has a completely different semantic
-# ./install, which can be erroneously created by make from ./install.sh.
-echo "$as_me:$LINENO: checking for a BSD-compatible install" >&5
-echo $ECHO_N "checking for a BSD-compatible install... $ECHO_C" >&6
-if test -z "$INSTALL"; then
-if test "${ac_cv_path_install+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
- IFS=$as_save_IFS
- test -z "$as_dir" && as_dir=.
- # Account for people who put trailing slashes in PATH elements.
-case $as_dir/ in
- ./ | .// | /cC/* | \
- /etc/* | /usr/sbin/* | /usr/etc/* | /sbin/* | /usr/afsws/bin/* | \
- ?:\\/os2\\/install\\/* | ?:\\/OS2\\/INSTALL\\/* | \
- /usr/ucb/* ) ;;
- *)
- # OSF1 and SCO ODT 3.0 have their own names for install.
- # Don't use installbsd from OSF since it installs stuff as root
- # by default.
- for ac_prog in ginstall scoinst install; do
- for ac_exec_ext in '' $ac_executable_extensions; do
- if $as_executable_p "$as_dir/$ac_prog$ac_exec_ext"; then
- if test $ac_prog = install &&
- grep dspmsg "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then
- # AIX install. It has an incompatible calling convention.
- :
- elif test $ac_prog = install &&
- grep pwplus "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then
- # program-specific install script used by HP pwplus--don't use.
- :
- else
- ac_cv_path_install="$as_dir/$ac_prog$ac_exec_ext -c"
- break 3
- fi
- fi
- done
- done
- ;;
-esac
-done
-
-
-fi
- if test "${ac_cv_path_install+set}" = set; then
- INSTALL=$ac_cv_path_install
- else
- # As a last resort, use the slow shell script. We don't cache a
- # path for INSTALL within a source directory, because that will
- # break other packages using the cache if that directory is
- # removed, or if the path is relative.
- INSTALL=$ac_install_sh
- fi
-fi
-echo "$as_me:$LINENO: result: $INSTALL" >&5
-echo "${ECHO_T}$INSTALL" >&6
-
-# Use test -z because SunOS4 sh mishandles braces in ${var-val}.
-# It thinks the first close brace ends the variable substitution.
-test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}'
-
-test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL}'
-
-test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644'
-
-echo "$as_me:$LINENO: checking whether build environment is sane" >&5
-echo $ECHO_N "checking whether build environment is sane... $ECHO_C" >&6
-# Just in case
-sleep 1
-echo timestamp > conftest.file
-# Do `set' in a subshell so we don't clobber the current shell's
-# arguments. Must try -L first in case configure is actually a
-# symlink; some systems play weird games with the mod time of symlinks
-# (eg FreeBSD returns the mod time of the symlink's containing
-# directory).
-if (
- set X `ls -Lt $srcdir/configure conftest.file 2> /dev/null`
- if test "$*" = "X"; then
- # -L didn't work.
- set X `ls -t $srcdir/configure conftest.file`
- fi
- rm -f conftest.file
- if test "$*" != "X $srcdir/configure conftest.file" \
- && test "$*" != "X conftest.file $srcdir/configure"; then
-
- # If neither matched, then we have a broken ls. This can happen
- # if, for instance, CONFIG_SHELL is bash and it inherits a
- # broken ls alias from the environment. This has actually
- # happened. Such a system could not be considered "sane".
- { { echo "$as_me:$LINENO: error: ls -t appears to fail. Make sure there is not a broken
-alias in your environment" >&5
-echo "$as_me: error: ls -t appears to fail. Make sure there is not a broken
-alias in your environment" >&2;}
- { (exit 1); exit 1; }; }
- fi
-
- test "$2" = conftest.file
- )
-then
- # Ok.
- :
-else
- { { echo "$as_me:$LINENO: error: newly created file is older than distributed files!
-Check your system clock" >&5
-echo "$as_me: error: newly created file is older than distributed files!
-Check your system clock" >&2;}
- { (exit 1); exit 1; }; }
-fi
-echo "$as_me:$LINENO: result: yes" >&5
-echo "${ECHO_T}yes" >&6
-test "$program_prefix" != NONE &&
- program_transform_name="s,^,$program_prefix,;$program_transform_name"
-# Use a double $ so make ignores it.
-test "$program_suffix" != NONE &&
- program_transform_name="s,\$,$program_suffix,;$program_transform_name"
-# Double any \ or $. echo might interpret backslashes.
-# By default was `s,x,x', remove it if useless.
-cat <<\_ACEOF >conftest.sed
-s/[\\$]/&&/g;s/;s,x,x,$//
-_ACEOF
-program_transform_name=`echo $program_transform_name | sed -f conftest.sed`
-rm conftest.sed
-
-# expand $ac_aux_dir to an absolute path
-am_aux_dir=`cd $ac_aux_dir && pwd`
-
-test x"${MISSING+set}" = xset || MISSING="\${SHELL} $am_aux_dir/missing"
-# Use eval to expand $SHELL
-if eval "$MISSING --run true"; then
- am_missing_run="$MISSING --run "
-else
- am_missing_run=
- { echo "$as_me:$LINENO: WARNING: \`missing' script is too old or missing" >&5
-echo "$as_me: WARNING: \`missing' script is too old or missing" >&2;}
-fi
-
-if mkdir -p --version . >/dev/null 2>&1 && test ! -d ./--version; then
- # We used to keeping the `.' as first argument, in order to
- # allow $(mkdir_p) to be used without argument. As in
- # $(mkdir_p) $(somedir)
- # where $(somedir) is conditionally defined. However this is wrong
- # for two reasons:
- # 1. if the package is installed by a user who cannot write `.'
- # make install will fail,
- # 2. the above comment should most certainly read
- # $(mkdir_p) $(DESTDIR)$(somedir)
- # so it does not work when $(somedir) is undefined and
- # $(DESTDIR) is not.
- # To support the latter case, we have to write
- # test -z "$(somedir)" || $(mkdir_p) $(DESTDIR)$(somedir),
- # so the `.' trick is pointless.
- mkdir_p='mkdir -p --'
-else
- # On NextStep and OpenStep, the `mkdir' command does not
- # recognize any option. It will interpret all options as
- # directories to create, and then abort because `.' already
- # exists.
- for d in ./-p ./--version;
- do
- test -d $d && rmdir $d
- done
- # $(mkinstalldirs) is defined by Automake if mkinstalldirs exists.
- if test -f "$ac_aux_dir/mkinstalldirs"; then
- mkdir_p='$(mkinstalldirs)'
- else
- mkdir_p='$(install_sh) -d'
- fi
-fi
-
-for ac_prog in gawk mawk nawk awk
-do
- # Extract the first word of "$ac_prog", so it can be a program name with args.
-set dummy $ac_prog; ac_word=$2
-echo "$as_me:$LINENO: checking for $ac_word" >&5
-echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
-if test "${ac_cv_prog_AWK+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- if test -n "$AWK"; then
- ac_cv_prog_AWK="$AWK" # Let the user override the test.
-else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
- IFS=$as_save_IFS
- test -z "$as_dir" && as_dir=.
- for ac_exec_ext in '' $ac_executable_extensions; do
- if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
- ac_cv_prog_AWK="$ac_prog"
- echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
- break 2
- fi
-done
-done
-
-fi
-fi
-AWK=$ac_cv_prog_AWK
-if test -n "$AWK"; then
- echo "$as_me:$LINENO: result: $AWK" >&5
-echo "${ECHO_T}$AWK" >&6
-else
- echo "$as_me:$LINENO: result: no" >&5
-echo "${ECHO_T}no" >&6
-fi
-
- test -n "$AWK" && break
-done
-
-echo "$as_me:$LINENO: checking whether ${MAKE-make} sets \$(MAKE)" >&5
-echo $ECHO_N "checking whether ${MAKE-make} sets \$(MAKE)... $ECHO_C" >&6
-set dummy ${MAKE-make}; ac_make=`echo "$2" | sed 'y,:./+-,___p_,'`
-if eval "test \"\${ac_cv_prog_make_${ac_make}_set+set}\" = set"; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- cat >conftest.make <<\_ACEOF
-all:
- @echo 'ac_maketemp="$(MAKE)"'
-_ACEOF
-# GNU make sometimes prints "make[1]: Entering...", which would confuse us.
-eval `${MAKE-make} -f conftest.make 2>/dev/null | grep temp=`
-if test -n "$ac_maketemp"; then
- eval ac_cv_prog_make_${ac_make}_set=yes
-else
- eval ac_cv_prog_make_${ac_make}_set=no
-fi
-rm -f conftest.make
-fi
-if eval "test \"`echo '$ac_cv_prog_make_'${ac_make}_set`\" = yes"; then
- echo "$as_me:$LINENO: result: yes" >&5
-echo "${ECHO_T}yes" >&6
- SET_MAKE=
-else
- echo "$as_me:$LINENO: result: no" >&5
-echo "${ECHO_T}no" >&6
- SET_MAKE="MAKE=${MAKE-make}"
-fi
-
-rm -rf .tst 2>/dev/null
-mkdir .tst 2>/dev/null
-if test -d .tst; then
- am__leading_dot=.
-else
- am__leading_dot=_
-fi
-rmdir .tst 2>/dev/null
-
-# test to see if srcdir already configured
-if test "`cd $srcdir && pwd`" != "`pwd`" &&
- test -f $srcdir/config.status; then
- { { echo "$as_me:$LINENO: error: source directory already configured; run \"make distclean\" there first" >&5
-echo "$as_me: error: source directory already configured; run \"make distclean\" there first" >&2;}
- { (exit 1); exit 1; }; }
-fi
-
-# test whether we have cygpath
-if test -z "$CYGPATH_W"; then
- if (cygpath --version) >/dev/null 2>/dev/null; then
- CYGPATH_W='cygpath -w'
- else
- CYGPATH_W=echo
- fi
-fi
-
-
-# Define the identity of the package.
- PACKAGE=librdmacm
- VERSION=1.0.11
-
-
-cat >>confdefs.h <<_ACEOF
-#define PACKAGE "$PACKAGE"
-_ACEOF
-
-
-cat >>confdefs.h <<_ACEOF
-#define VERSION "$VERSION"
-_ACEOF
-
-# Some tools Automake needs.
-
-ACLOCAL=${ACLOCAL-"${am_missing_run}aclocal-${am__api_version}"}
-
-
-AUTOCONF=${AUTOCONF-"${am_missing_run}autoconf"}
-
-
-AUTOMAKE=${AUTOMAKE-"${am_missing_run}automake-${am__api_version}"}
-
-
-AUTOHEADER=${AUTOHEADER-"${am_missing_run}autoheader"}
-
-
-MAKEINFO=${MAKEINFO-"${am_missing_run}makeinfo"}
-
-install_sh=${install_sh-"$am_aux_dir/install-sh"}
-
-# Installed binaries are usually stripped using `strip' when the user
-# run `make install-strip'. However `strip' might not be the right
-# tool to use in cross-compilation environments, therefore Automake
-# will honor the `STRIP' environment variable to overrule this program.
-if test "$cross_compiling" != no; then
- if test -n "$ac_tool_prefix"; then
- # Extract the first word of "${ac_tool_prefix}strip", so it can be a program name with args.
-set dummy ${ac_tool_prefix}strip; ac_word=$2
-echo "$as_me:$LINENO: checking for $ac_word" >&5
-echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
-if test "${ac_cv_prog_STRIP+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- if test -n "$STRIP"; then
- ac_cv_prog_STRIP="$STRIP" # Let the user override the test.
-else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
- IFS=$as_save_IFS
- test -z "$as_dir" && as_dir=.
- for ac_exec_ext in '' $ac_executable_extensions; do
- if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
- ac_cv_prog_STRIP="${ac_tool_prefix}strip"
- echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
- break 2
- fi
-done
-done
-
-fi
-fi
-STRIP=$ac_cv_prog_STRIP
-if test -n "$STRIP"; then
- echo "$as_me:$LINENO: result: $STRIP" >&5
-echo "${ECHO_T}$STRIP" >&6
-else
- echo "$as_me:$LINENO: result: no" >&5
-echo "${ECHO_T}no" >&6
-fi
-
-fi
-if test -z "$ac_cv_prog_STRIP"; then
- ac_ct_STRIP=$STRIP
- # Extract the first word of "strip", so it can be a program name with args.
-set dummy strip; ac_word=$2
-echo "$as_me:$LINENO: checking for $ac_word" >&5
-echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
-if test "${ac_cv_prog_ac_ct_STRIP+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- if test -n "$ac_ct_STRIP"; then
- ac_cv_prog_ac_ct_STRIP="$ac_ct_STRIP" # Let the user override the test.
-else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
- IFS=$as_save_IFS
- test -z "$as_dir" && as_dir=.
- for ac_exec_ext in '' $ac_executable_extensions; do
- if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
- ac_cv_prog_ac_ct_STRIP="strip"
- echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
- break 2
- fi
-done
-done
-
- test -z "$ac_cv_prog_ac_ct_STRIP" && ac_cv_prog_ac_ct_STRIP=":"
-fi
-fi
-ac_ct_STRIP=$ac_cv_prog_ac_ct_STRIP
-if test -n "$ac_ct_STRIP"; then
- echo "$as_me:$LINENO: result: $ac_ct_STRIP" >&5
-echo "${ECHO_T}$ac_ct_STRIP" >&6
-else
- echo "$as_me:$LINENO: result: no" >&5
-echo "${ECHO_T}no" >&6
-fi
-
- STRIP=$ac_ct_STRIP
-else
- STRIP="$ac_cv_prog_STRIP"
-fi
-
-fi
-INSTALL_STRIP_PROGRAM="\${SHELL} \$(install_sh) -c -s"
-
-# We need awk for the "check" target. The system "awk" is bad on
-# some platforms.
-# Always define AMTAR for backward compatibility.
-
-AMTAR=${AMTAR-"${am_missing_run}tar"}
-
-am__tar='${AMTAR} chof - "$$tardir"'; am__untar='${AMTAR} xf -'
-
-
-
-
-
-
-# Check whether --enable-shared or --disable-shared was given.
-if test "${enable_shared+set}" = set; then
- enableval="$enable_shared"
- p=${PACKAGE-default}
- case $enableval in
- yes) enable_shared=yes ;;
- no) enable_shared=no ;;
- *)
- enable_shared=no
- # Look at the argument we got. We use all the common list separators.
- lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR,"
- for pkg in $enableval; do
- IFS="$lt_save_ifs"
- if test "X$pkg" = "X$p"; then
- enable_shared=yes
- fi
- done
- IFS="$lt_save_ifs"
- ;;
- esac
-else
- enable_shared=yes
-fi;
-
-# Check whether --enable-static or --disable-static was given.
-if test "${enable_static+set}" = set; then
- enableval="$enable_static"
- p=${PACKAGE-default}
- case $enableval in
- yes) enable_static=yes ;;
- no) enable_static=no ;;
- *)
- enable_static=no
- # Look at the argument we got. We use all the common list separators.
- lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR,"
- for pkg in $enableval; do
- IFS="$lt_save_ifs"
- if test "X$pkg" = "X$p"; then
- enable_static=yes
- fi
- done
- IFS="$lt_save_ifs"
- ;;
- esac
-else
- enable_static=yes
-fi;
-
-# Check whether --enable-fast-install or --disable-fast-install was given.
-if test "${enable_fast_install+set}" = set; then
- enableval="$enable_fast_install"
- p=${PACKAGE-default}
- case $enableval in
- yes) enable_fast_install=yes ;;
- no) enable_fast_install=no ;;
- *)
- enable_fast_install=no
- # Look at the argument we got. We use all the common list separators.
- lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR,"
- for pkg in $enableval; do
- IFS="$lt_save_ifs"
- if test "X$pkg" = "X$p"; then
- enable_fast_install=yes
- fi
- done
- IFS="$lt_save_ifs"
- ;;
- esac
-else
- enable_fast_install=yes
-fi;
-
-# Make sure we can run config.sub.
-$ac_config_sub sun4 >/dev/null 2>&1 ||
- { { echo "$as_me:$LINENO: error: cannot run $ac_config_sub" >&5
-echo "$as_me: error: cannot run $ac_config_sub" >&2;}
- { (exit 1); exit 1; }; }
-
-echo "$as_me:$LINENO: checking build system type" >&5
-echo $ECHO_N "checking build system type... $ECHO_C" >&6
-if test "${ac_cv_build+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- ac_cv_build_alias=$build_alias
-test -z "$ac_cv_build_alias" &&
- ac_cv_build_alias=`$ac_config_guess`
-test -z "$ac_cv_build_alias" &&
- { { echo "$as_me:$LINENO: error: cannot guess build type; you must specify one" >&5
-echo "$as_me: error: cannot guess build type; you must specify one" >&2;}
- { (exit 1); exit 1; }; }
-ac_cv_build=`$ac_config_sub $ac_cv_build_alias` ||
- { { echo "$as_me:$LINENO: error: $ac_config_sub $ac_cv_build_alias failed" >&5
-echo "$as_me: error: $ac_config_sub $ac_cv_build_alias failed" >&2;}
- { (exit 1); exit 1; }; }
-
-fi
-echo "$as_me:$LINENO: result: $ac_cv_build" >&5
-echo "${ECHO_T}$ac_cv_build" >&6
-build=$ac_cv_build
-build_cpu=`echo $ac_cv_build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'`
-build_vendor=`echo $ac_cv_build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'`
-build_os=`echo $ac_cv_build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'`
-
-
-echo "$as_me:$LINENO: checking host system type" >&5
-echo $ECHO_N "checking host system type... $ECHO_C" >&6
-if test "${ac_cv_host+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- ac_cv_host_alias=$host_alias
-test -z "$ac_cv_host_alias" &&
- ac_cv_host_alias=$ac_cv_build_alias
-ac_cv_host=`$ac_config_sub $ac_cv_host_alias` ||
- { { echo "$as_me:$LINENO: error: $ac_config_sub $ac_cv_host_alias failed" >&5
-echo "$as_me: error: $ac_config_sub $ac_cv_host_alias failed" >&2;}
- { (exit 1); exit 1; }; }
-
-fi
-echo "$as_me:$LINENO: result: $ac_cv_host" >&5
-echo "${ECHO_T}$ac_cv_host" >&6
-host=$ac_cv_host
-host_cpu=`echo $ac_cv_host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'`
-host_vendor=`echo $ac_cv_host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'`
-host_os=`echo $ac_cv_host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'`
-
-
-DEPDIR="${am__leading_dot}deps"
-
- ac_config_commands="$ac_config_commands depfiles"
-
-
-am_make=${MAKE-make}
-cat > confinc << 'END'
-am__doit:
- @echo done
-.PHONY: am__doit
-END
-# If we don't find an include directive, just comment out the code.
-echo "$as_me:$LINENO: checking for style of include used by $am_make" >&5
-echo $ECHO_N "checking for style of include used by $am_make... $ECHO_C" >&6
-am__include="#"
-am__quote=
-_am_result=none
-# First try GNU make style include.
-echo "include confinc" > confmf
-# We grep out `Entering directory' and `Leaving directory'
-# messages which can occur if `w' ends up in MAKEFLAGS.
-# In particular we don't look at `^make:' because GNU make might
-# be invoked under some other name (usually "gmake"), in which
-# case it prints its new name instead of `make'.
-if test "`$am_make -s -f confmf 2> /dev/null | grep -v 'ing directory'`" = "done"; then
- am__include=include
- am__quote=
- _am_result=GNU
-fi
-# Now try BSD make style include.
-if test "$am__include" = "#"; then
- echo '.include "confinc"' > confmf
- if test "`$am_make -s -f confmf 2> /dev/null`" = "done"; then
- am__include=.include
- am__quote="\""
- _am_result=BSD
- fi
-fi
-
-
-echo "$as_me:$LINENO: result: $_am_result" >&5
-echo "${ECHO_T}$_am_result" >&6
-rm -f confinc confmf
-
-# Check whether --enable-dependency-tracking or --disable-dependency-tracking was given.
-if test "${enable_dependency_tracking+set}" = set; then
- enableval="$enable_dependency_tracking"
-
-fi;
-if test "x$enable_dependency_tracking" != xno; then
- am_depcomp="$ac_aux_dir/depcomp"
- AMDEPBACKSLASH='\'
-fi
-
-
-if test "x$enable_dependency_tracking" != xno; then
- AMDEP_TRUE=
- AMDEP_FALSE='#'
-else
- AMDEP_TRUE='#'
- AMDEP_FALSE=
-fi
-
-
-
-ac_ext=c
-ac_cpp='$CPP $CPPFLAGS'
-ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
-ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
-ac_compiler_gnu=$ac_cv_c_compiler_gnu
-if test -n "$ac_tool_prefix"; then
- # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args.
-set dummy ${ac_tool_prefix}gcc; ac_word=$2
-echo "$as_me:$LINENO: checking for $ac_word" >&5
-echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
-if test "${ac_cv_prog_CC+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- if test -n "$CC"; then
- ac_cv_prog_CC="$CC" # Let the user override the test.
-else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
- IFS=$as_save_IFS
- test -z "$as_dir" && as_dir=.
- for ac_exec_ext in '' $ac_executable_extensions; do
- if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
- ac_cv_prog_CC="${ac_tool_prefix}gcc"
- echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
- break 2
- fi
-done
-done
-
-fi
-fi
-CC=$ac_cv_prog_CC
-if test -n "$CC"; then
- echo "$as_me:$LINENO: result: $CC" >&5
-echo "${ECHO_T}$CC" >&6
-else
- echo "$as_me:$LINENO: result: no" >&5
-echo "${ECHO_T}no" >&6
-fi
-
-fi
-if test -z "$ac_cv_prog_CC"; then
- ac_ct_CC=$CC
- # Extract the first word of "gcc", so it can be a program name with args.
-set dummy gcc; ac_word=$2
-echo "$as_me:$LINENO: checking for $ac_word" >&5
-echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
-if test "${ac_cv_prog_ac_ct_CC+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- if test -n "$ac_ct_CC"; then
- ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test.
-else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
- IFS=$as_save_IFS
- test -z "$as_dir" && as_dir=.
- for ac_exec_ext in '' $ac_executable_extensions; do
- if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
- ac_cv_prog_ac_ct_CC="gcc"
- echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
- break 2
- fi
-done
-done
-
-fi
-fi
-ac_ct_CC=$ac_cv_prog_ac_ct_CC
-if test -n "$ac_ct_CC"; then
- echo "$as_me:$LINENO: result: $ac_ct_CC" >&5
-echo "${ECHO_T}$ac_ct_CC" >&6
-else
- echo "$as_me:$LINENO: result: no" >&5
-echo "${ECHO_T}no" >&6
-fi
-
- CC=$ac_ct_CC
-else
- CC="$ac_cv_prog_CC"
-fi
-
-if test -z "$CC"; then
- if test -n "$ac_tool_prefix"; then
- # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args.
-set dummy ${ac_tool_prefix}cc; ac_word=$2
-echo "$as_me:$LINENO: checking for $ac_word" >&5
-echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
-if test "${ac_cv_prog_CC+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- if test -n "$CC"; then
- ac_cv_prog_CC="$CC" # Let the user override the test.
-else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
- IFS=$as_save_IFS
- test -z "$as_dir" && as_dir=.
- for ac_exec_ext in '' $ac_executable_extensions; do
- if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
- ac_cv_prog_CC="${ac_tool_prefix}cc"
- echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
- break 2
- fi
-done
-done
-
-fi
-fi
-CC=$ac_cv_prog_CC
-if test -n "$CC"; then
- echo "$as_me:$LINENO: result: $CC" >&5
-echo "${ECHO_T}$CC" >&6
-else
- echo "$as_me:$LINENO: result: no" >&5
-echo "${ECHO_T}no" >&6
-fi
-
-fi
-if test -z "$ac_cv_prog_CC"; then
- ac_ct_CC=$CC
- # Extract the first word of "cc", so it can be a program name with args.
-set dummy cc; ac_word=$2
-echo "$as_me:$LINENO: checking for $ac_word" >&5
-echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
-if test "${ac_cv_prog_ac_ct_CC+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- if test -n "$ac_ct_CC"; then
- ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test.
-else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
- IFS=$as_save_IFS
- test -z "$as_dir" && as_dir=.
- for ac_exec_ext in '' $ac_executable_extensions; do
- if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
- ac_cv_prog_ac_ct_CC="cc"
- echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
- break 2
- fi
-done
-done
-
-fi
-fi
-ac_ct_CC=$ac_cv_prog_ac_ct_CC
-if test -n "$ac_ct_CC"; then
- echo "$as_me:$LINENO: result: $ac_ct_CC" >&5
-echo "${ECHO_T}$ac_ct_CC" >&6
-else
- echo "$as_me:$LINENO: result: no" >&5
-echo "${ECHO_T}no" >&6
-fi
-
- CC=$ac_ct_CC
-else
- CC="$ac_cv_prog_CC"
-fi
-
-fi
-if test -z "$CC"; then
- # Extract the first word of "cc", so it can be a program name with args.
-set dummy cc; ac_word=$2
-echo "$as_me:$LINENO: checking for $ac_word" >&5
-echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
-if test "${ac_cv_prog_CC+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- if test -n "$CC"; then
- ac_cv_prog_CC="$CC" # Let the user override the test.
-else
- ac_prog_rejected=no
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
- IFS=$as_save_IFS
- test -z "$as_dir" && as_dir=.
- for ac_exec_ext in '' $ac_executable_extensions; do
- if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
- if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then
- ac_prog_rejected=yes
- continue
- fi
- ac_cv_prog_CC="cc"
- echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
- break 2
- fi
-done
-done
-
-if test $ac_prog_rejected = yes; then
- # We found a bogon in the path, so make sure we never use it.
- set dummy $ac_cv_prog_CC
- shift
- if test $# != 0; then
- # We chose a different compiler from the bogus one.
- # However, it has the same basename, so the bogon will be chosen
- # first if we set CC to just the basename; use the full file name.
- shift
- ac_cv_prog_CC="$as_dir/$ac_word${1+' '}$@"
- fi
-fi
-fi
-fi
-CC=$ac_cv_prog_CC
-if test -n "$CC"; then
- echo "$as_me:$LINENO: result: $CC" >&5
-echo "${ECHO_T}$CC" >&6
-else
- echo "$as_me:$LINENO: result: no" >&5
-echo "${ECHO_T}no" >&6
-fi
-
-fi
-if test -z "$CC"; then
- if test -n "$ac_tool_prefix"; then
- for ac_prog in cl
- do
- # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args.
-set dummy $ac_tool_prefix$ac_prog; ac_word=$2
-echo "$as_me:$LINENO: checking for $ac_word" >&5
-echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
-if test "${ac_cv_prog_CC+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- if test -n "$CC"; then
- ac_cv_prog_CC="$CC" # Let the user override the test.
-else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
- IFS=$as_save_IFS
- test -z "$as_dir" && as_dir=.
- for ac_exec_ext in '' $ac_executable_extensions; do
- if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
- ac_cv_prog_CC="$ac_tool_prefix$ac_prog"
- echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
- break 2
- fi
-done
-done
-
-fi
-fi
-CC=$ac_cv_prog_CC
-if test -n "$CC"; then
- echo "$as_me:$LINENO: result: $CC" >&5
-echo "${ECHO_T}$CC" >&6
-else
- echo "$as_me:$LINENO: result: no" >&5
-echo "${ECHO_T}no" >&6
-fi
-
- test -n "$CC" && break
- done
-fi
-if test -z "$CC"; then
- ac_ct_CC=$CC
- for ac_prog in cl
-do
- # Extract the first word of "$ac_prog", so it can be a program name with args.
-set dummy $ac_prog; ac_word=$2
-echo "$as_me:$LINENO: checking for $ac_word" >&5
-echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
-if test "${ac_cv_prog_ac_ct_CC+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- if test -n "$ac_ct_CC"; then
- ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test.
-else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
- IFS=$as_save_IFS
- test -z "$as_dir" && as_dir=.
- for ac_exec_ext in '' $ac_executable_extensions; do
- if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
- ac_cv_prog_ac_ct_CC="$ac_prog"
- echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
- break 2
- fi
-done
-done
-
-fi
-fi
-ac_ct_CC=$ac_cv_prog_ac_ct_CC
-if test -n "$ac_ct_CC"; then
- echo "$as_me:$LINENO: result: $ac_ct_CC" >&5
-echo "${ECHO_T}$ac_ct_CC" >&6
-else
- echo "$as_me:$LINENO: result: no" >&5
-echo "${ECHO_T}no" >&6
-fi
-
- test -n "$ac_ct_CC" && break
-done
-
- CC=$ac_ct_CC
-fi
-
-fi
-
-
-test -z "$CC" && { { echo "$as_me:$LINENO: error: no acceptable C compiler found in \$PATH
-See \`config.log' for more details." >&5
-echo "$as_me: error: no acceptable C compiler found in \$PATH
-See \`config.log' for more details." >&2;}
- { (exit 1); exit 1; }; }
-
-# Provide some information about the compiler.
-echo "$as_me:$LINENO:" \
- "checking for C compiler version" >&5
-ac_compiler=`set X $ac_compile; echo $2`
-{ (eval echo "$as_me:$LINENO: \"$ac_compiler --version </dev/null >&5\"") >&5
- (eval $ac_compiler --version </dev/null >&5) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }
-{ (eval echo "$as_me:$LINENO: \"$ac_compiler -v </dev/null >&5\"") >&5
- (eval $ac_compiler -v </dev/null >&5) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }
-{ (eval echo "$as_me:$LINENO: \"$ac_compiler -V </dev/null >&5\"") >&5
- (eval $ac_compiler -V </dev/null >&5) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }
-
-cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-
-int
-main ()
-{
-
- ;
- return 0;
-}
-_ACEOF
-ac_clean_files_save=$ac_clean_files
-ac_clean_files="$ac_clean_files a.out a.exe b.out"
-# Try to create an executable without -o first, disregard a.out.
-# It will help us diagnose broken compilers, and finding out an intuition
-# of exeext.
-echo "$as_me:$LINENO: checking for C compiler default output file name" >&5
-echo $ECHO_N "checking for C compiler default output file name... $ECHO_C" >&6
-ac_link_default=`echo "$ac_link" | sed 's/ -o *conftest[^ ]*//'`
-if { (eval echo "$as_me:$LINENO: \"$ac_link_default\"") >&5
- (eval $ac_link_default) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; then
- # Find the output, starting from the most likely. This scheme is
-# not robust to junk in `.', hence go to wildcards (a.*) only as a last
-# resort.
-
-# Be careful to initialize this variable, since it used to be cached.
-# Otherwise an old cache value of `no' led to `EXEEXT = no' in a Makefile.
-ac_cv_exeext=
-# b.out is created by i960 compilers.
-for ac_file in a_out.exe a.exe conftest.exe a.out conftest a.* conftest.* b.out
-do
- test -f "$ac_file" || continue
- case $ac_file in
- *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.o | *.obj )
- ;;
- conftest.$ac_ext )
- # This is the source file.
- ;;
- [ab].out )
- # We found the default executable, but exeext='' is most
- # certainly right.
- break;;
- *.* )
- ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'`
- # FIXME: I believe we export ac_cv_exeext for Libtool,
- # but it would be cool to find out if it's true. Does anybody
- # maintain Libtool? --akim.
- export ac_cv_exeext
- break;;
- * )
- break;;
- esac
-done
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-{ { echo "$as_me:$LINENO: error: C compiler cannot create executables
-See \`config.log' for more details." >&5
-echo "$as_me: error: C compiler cannot create executables
-See \`config.log' for more details." >&2;}
- { (exit 77); exit 77; }; }
-fi
-
-ac_exeext=$ac_cv_exeext
-echo "$as_me:$LINENO: result: $ac_file" >&5
-echo "${ECHO_T}$ac_file" >&6
-
-# Check the compiler produces executables we can run. If not, either
-# the compiler is broken, or we cross compile.
-echo "$as_me:$LINENO: checking whether the C compiler works" >&5
-echo $ECHO_N "checking whether the C compiler works... $ECHO_C" >&6
-# FIXME: These cross compiler hacks should be removed for Autoconf 3.0
-# If not cross compiling, check that we can run a simple program.
-if test "$cross_compiling" != yes; then
- if { ac_try='./$ac_file'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
- cross_compiling=no
- else
- if test "$cross_compiling" = maybe; then
- cross_compiling=yes
- else
- { { echo "$as_me:$LINENO: error: cannot run C compiled programs.
-If you meant to cross compile, use \`--host'.
-See \`config.log' for more details." >&5
-echo "$as_me: error: cannot run C compiled programs.
-If you meant to cross compile, use \`--host'.
-See \`config.log' for more details." >&2;}
- { (exit 1); exit 1; }; }
- fi
- fi
-fi
-echo "$as_me:$LINENO: result: yes" >&5
-echo "${ECHO_T}yes" >&6
-
-rm -f a.out a.exe conftest$ac_cv_exeext b.out
-ac_clean_files=$ac_clean_files_save
-# Check the compiler produces executables we can run. If not, either
-# the compiler is broken, or we cross compile.
-echo "$as_me:$LINENO: checking whether we are cross compiling" >&5
-echo $ECHO_N "checking whether we are cross compiling... $ECHO_C" >&6
-echo "$as_me:$LINENO: result: $cross_compiling" >&5
-echo "${ECHO_T}$cross_compiling" >&6
-
-echo "$as_me:$LINENO: checking for suffix of executables" >&5
-echo $ECHO_N "checking for suffix of executables... $ECHO_C" >&6
-if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
- (eval $ac_link) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; then
- # If both `conftest.exe' and `conftest' are `present' (well, observable)
-# catch `conftest.exe'. For instance with Cygwin, `ls conftest' will
-# work properly (i.e., refer to `conftest.exe'), while it won't with
-# `rm'.
-for ac_file in conftest.exe conftest conftest.*; do
- test -f "$ac_file" || continue
- case $ac_file in
- *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.o | *.obj ) ;;
- *.* ) ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'`
- export ac_cv_exeext
- break;;
- * ) break;;
- esac
-done
-else
- { { echo "$as_me:$LINENO: error: cannot compute suffix of executables: cannot compile and link
-See \`config.log' for more details." >&5
-echo "$as_me: error: cannot compute suffix of executables: cannot compile and link
-See \`config.log' for more details." >&2;}
- { (exit 1); exit 1; }; }
-fi
-
-rm -f conftest$ac_cv_exeext
-echo "$as_me:$LINENO: result: $ac_cv_exeext" >&5
-echo "${ECHO_T}$ac_cv_exeext" >&6
-
-rm -f conftest.$ac_ext
-EXEEXT=$ac_cv_exeext
-ac_exeext=$EXEEXT
-echo "$as_me:$LINENO: checking for suffix of object files" >&5
-echo $ECHO_N "checking for suffix of object files... $ECHO_C" >&6
-if test "${ac_cv_objext+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-
-int
-main ()
-{
-
- ;
- return 0;
-}
-_ACEOF
-rm -f conftest.o conftest.obj
-if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
- (eval $ac_compile) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; then
- for ac_file in `(ls conftest.o conftest.obj; ls conftest.*) 2>/dev/null`; do
- case $ac_file in
- *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg ) ;;
- *) ac_cv_objext=`expr "$ac_file" : '.*\.\(.*\)'`
- break;;
- esac
-done
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-{ { echo "$as_me:$LINENO: error: cannot compute suffix of object files: cannot compile
-See \`config.log' for more details." >&5
-echo "$as_me: error: cannot compute suffix of object files: cannot compile
-See \`config.log' for more details." >&2;}
- { (exit 1); exit 1; }; }
-fi
-
-rm -f conftest.$ac_cv_objext conftest.$ac_ext
-fi
-echo "$as_me:$LINENO: result: $ac_cv_objext" >&5
-echo "${ECHO_T}$ac_cv_objext" >&6
-OBJEXT=$ac_cv_objext
-ac_objext=$OBJEXT
-echo "$as_me:$LINENO: checking whether we are using the GNU C compiler" >&5
-echo $ECHO_N "checking whether we are using the GNU C compiler... $ECHO_C" >&6
-if test "${ac_cv_c_compiler_gnu+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-
-int
-main ()
-{
-#ifndef __GNUC__
- choke me
-#endif
-
- ;
- return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
- (eval $ac_compile) 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } &&
- { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; } &&
- { ac_try='test -s conftest.$ac_objext'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
- ac_compiler_gnu=yes
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-ac_compiler_gnu=no
-fi
-rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
-ac_cv_c_compiler_gnu=$ac_compiler_gnu
-
-fi
-echo "$as_me:$LINENO: result: $ac_cv_c_compiler_gnu" >&5
-echo "${ECHO_T}$ac_cv_c_compiler_gnu" >&6
-GCC=`test $ac_compiler_gnu = yes && echo yes`
-ac_test_CFLAGS=${CFLAGS+set}
-ac_save_CFLAGS=$CFLAGS
-CFLAGS="-g"
-echo "$as_me:$LINENO: checking whether $CC accepts -g" >&5
-echo $ECHO_N "checking whether $CC accepts -g... $ECHO_C" >&6
-if test "${ac_cv_prog_cc_g+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-
-int
-main ()
-{
-
- ;
- return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
- (eval $ac_compile) 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } &&
- { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; } &&
- { ac_try='test -s conftest.$ac_objext'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
- ac_cv_prog_cc_g=yes
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-ac_cv_prog_cc_g=no
-fi
-rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
-fi
-echo "$as_me:$LINENO: result: $ac_cv_prog_cc_g" >&5
-echo "${ECHO_T}$ac_cv_prog_cc_g" >&6
-if test "$ac_test_CFLAGS" = set; then
- CFLAGS=$ac_save_CFLAGS
-elif test $ac_cv_prog_cc_g = yes; then
- if test "$GCC" = yes; then
- CFLAGS="-g -O2"
- else
- CFLAGS="-g"
- fi
-else
- if test "$GCC" = yes; then
- CFLAGS="-O2"
- else
- CFLAGS=
- fi
-fi
-echo "$as_me:$LINENO: checking for $CC option to accept ANSI C" >&5
-echo $ECHO_N "checking for $CC option to accept ANSI C... $ECHO_C" >&6
-if test "${ac_cv_prog_cc_stdc+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- ac_cv_prog_cc_stdc=no
-ac_save_CC=$CC
-cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-#include <stdarg.h>
-#include <stdio.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-/* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */
-struct buf { int x; };
-FILE * (*rcsopen) (struct buf *, struct stat *, int);
-static char *e (p, i)
- char **p;
- int i;
-{
- return p[i];
-}
-static char *f (char * (*g) (char **, int), char **p, ...)
-{
- char *s;
- va_list v;
- va_start (v,p);
- s = g (p, va_arg (v,int));
- va_end (v);
- return s;
-}
-
-/* OSF 4.0 Compaq cc is some sort of almost-ANSI by default. It has
- function prototypes and stuff, but not '\xHH' hex character constants.
- These don't provoke an error unfortunately, instead are silently treated
- as 'x'. The following induces an error, until -std1 is added to get
- proper ANSI mode. Curiously '\x00'!='x' always comes out true, for an
- array size at least. It's necessary to write '\x00'==0 to get something
- that's true only with -std1. */
-int osf4_cc_array ['\x00' == 0 ? 1 : -1];
-
-int test (int i, double x);
-struct s1 {int (*f) (int a);};
-struct s2 {int (*f) (double a);};
-int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int);
-int argc;
-char **argv;
-int
-main ()
-{
-return f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1];
- ;
- return 0;
-}
-_ACEOF
-# Don't try gcc -ansi; that turns off useful extensions and
-# breaks some systems' header files.
-# AIX -qlanglvl=ansi
-# Ultrix and OSF/1 -std1
-# HP-UX 10.20 and later -Ae
-# HP-UX older versions -Aa -D_HPUX_SOURCE
-# SVR4 -Xc -D__EXTENSIONS__
-for ac_arg in "" -qlanglvl=ansi -std1 -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__"
-do
- CC="$ac_save_CC $ac_arg"
- rm -f conftest.$ac_objext
-if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
- (eval $ac_compile) 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } &&
- { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; } &&
- { ac_try='test -s conftest.$ac_objext'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
- ac_cv_prog_cc_stdc=$ac_arg
-break
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-fi
-rm -f conftest.err conftest.$ac_objext
-done
-rm -f conftest.$ac_ext conftest.$ac_objext
-CC=$ac_save_CC
-
-fi
-
-case "x$ac_cv_prog_cc_stdc" in
- x|xno)
- echo "$as_me:$LINENO: result: none needed" >&5
-echo "${ECHO_T}none needed" >&6 ;;
- *)
- echo "$as_me:$LINENO: result: $ac_cv_prog_cc_stdc" >&5
-echo "${ECHO_T}$ac_cv_prog_cc_stdc" >&6
- CC="$CC $ac_cv_prog_cc_stdc" ;;
-esac
-
-# Some people use a C++ compiler to compile C. Since we use `exit',
-# in C++ we need to declare it. In case someone uses the same compiler
-# for both compiling C and C++ we need to have the C++ compiler decide
-# the declaration of exit, since it's the most demanding environment.
-cat >conftest.$ac_ext <<_ACEOF
-#ifndef __cplusplus
- choke me
-#endif
-_ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
- (eval $ac_compile) 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } &&
- { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; } &&
- { ac_try='test -s conftest.$ac_objext'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
- for ac_declaration in \
- '' \
- 'extern "C" void std::exit (int) throw (); using std::exit;' \
- 'extern "C" void std::exit (int); using std::exit;' \
- 'extern "C" void exit (int) throw ();' \
- 'extern "C" void exit (int);' \
- 'void exit (int);'
-do
- cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-$ac_declaration
-#include <stdlib.h>
-int
-main ()
-{
-exit (42);
- ;
- return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
- (eval $ac_compile) 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } &&
- { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; } &&
- { ac_try='test -s conftest.$ac_objext'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
- :
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-continue
-fi
-rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
- cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-$ac_declaration
-int
-main ()
-{
-exit (42);
- ;
- return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
- (eval $ac_compile) 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } &&
- { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; } &&
- { ac_try='test -s conftest.$ac_objext'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
- break
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-fi
-rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
-done
-rm -f conftest*
-if test -n "$ac_declaration"; then
- echo '#ifdef __cplusplus' >>confdefs.h
- echo $ac_declaration >>confdefs.h
- echo '#endif' >>confdefs.h
-fi
-
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-fi
-rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
-ac_ext=c
-ac_cpp='$CPP $CPPFLAGS'
-ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
-ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
-ac_compiler_gnu=$ac_cv_c_compiler_gnu
-
-depcc="$CC" am_compiler_list=
-
-echo "$as_me:$LINENO: checking dependency style of $depcc" >&5
-echo $ECHO_N "checking dependency style of $depcc... $ECHO_C" >&6
-if test "${am_cv_CC_dependencies_compiler_type+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then
- # We make a subdir and do the tests there. Otherwise we can end up
- # making bogus files that we don't know about and never remove. For
- # instance it was reported that on HP-UX the gcc test will end up
- # making a dummy file named `D' -- because `-MD' means `put the output
- # in D'.
- mkdir conftest.dir
- # Copy depcomp to subdir because otherwise we won't find it if we're
- # using a relative directory.
- cp "$am_depcomp" conftest.dir
- cd conftest.dir
- # We will build objects and dependencies in a subdirectory because
- # it helps to detect inapplicable dependency modes. For instance
- # both Tru64's cc and ICC support -MD to output dependencies as a
- # side effect of compilation, but ICC will put the dependencies in
- # the current directory while Tru64 will put them in the object
- # directory.
- mkdir sub
-
- am_cv_CC_dependencies_compiler_type=none
- if test "$am_compiler_list" = ""; then
- am_compiler_list=`sed -n 's/^#*\([a-zA-Z0-9]*\))$/\1/p' < ./depcomp`
- fi
- for depmode in $am_compiler_list; do
- # Setup a source with many dependencies, because some compilers
- # like to wrap large dependency lists on column 80 (with \), and
- # we should not choose a depcomp mode which is confused by this.
- #
- # We need to recreate these files for each test, as the compiler may
- # overwrite some of them when testing with obscure command lines.
- # This happens at least with the AIX C compiler.
- : > sub/conftest.c
- for i in 1 2 3 4 5 6; do
- echo '#include "conftst'$i'.h"' >> sub/conftest.c
- # Using `: > sub/conftst$i.h' creates only sub/conftst1.h with
- # Solaris 8's {/usr,}/bin/sh.
- touch sub/conftst$i.h
- done
- echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf
-
- case $depmode in
- nosideeffect)
- # after this tag, mechanisms are not by side-effect, so they'll
- # only be used when explicitly requested
- if test "x$enable_dependency_tracking" = xyes; then
- continue
- else
- break
- fi
- ;;
- none) break ;;
- esac
- # We check with `-c' and `-o' for the sake of the "dashmstdout"
- # mode. It turns out that the SunPro C++ compiler does not properly
- # handle `-M -o', and we need to detect this.
- if depmode=$depmode \
- source=sub/conftest.c object=sub/conftest.${OBJEXT-o} \
- depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \
- $SHELL ./depcomp $depcc -c -o sub/conftest.${OBJEXT-o} sub/conftest.c \
- >/dev/null 2>conftest.err &&
- grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 &&
- grep sub/conftest.${OBJEXT-o} sub/conftest.Po > /dev/null 2>&1 &&
- ${MAKE-make} -s -f confmf > /dev/null 2>&1; then
- # icc doesn't choke on unknown options, it will just issue warnings
- # or remarks (even with -Werror). So we grep stderr for any message
- # that says an option was ignored or not supported.
- # When given -MP, icc 7.0 and 7.1 complain thusly:
- # icc: Command line warning: ignoring option '-M'; no argument required
- # The diagnosis changed in icc 8.0:
- # icc: Command line remark: option '-MP' not supported
- if (grep 'ignoring option' conftest.err ||
- grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else
- am_cv_CC_dependencies_compiler_type=$depmode
- break
- fi
- fi
- done
-
- cd ..
- rm -rf conftest.dir
-else
- am_cv_CC_dependencies_compiler_type=none
-fi
-
-fi
-echo "$as_me:$LINENO: result: $am_cv_CC_dependencies_compiler_type" >&5
-echo "${ECHO_T}$am_cv_CC_dependencies_compiler_type" >&6
-CCDEPMODE=depmode=$am_cv_CC_dependencies_compiler_type
-
-
-
-if
- test "x$enable_dependency_tracking" != xno \
- && test "$am_cv_CC_dependencies_compiler_type" = gcc3; then
- am__fastdepCC_TRUE=
- am__fastdepCC_FALSE='#'
-else
- am__fastdepCC_TRUE='#'
- am__fastdepCC_FALSE=
-fi
-
-
-echo "$as_me:$LINENO: checking for a sed that does not truncate output" >&5
-echo $ECHO_N "checking for a sed that does not truncate output... $ECHO_C" >&6
-if test "${lt_cv_path_SED+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- # Loop through the user's path and test for sed and gsed.
-# Then use that list of sed's as ones to test for truncation.
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
- IFS=$as_save_IFS
- test -z "$as_dir" && as_dir=.
- for lt_ac_prog in sed gsed; do
- for ac_exec_ext in '' $ac_executable_extensions; do
- if $as_executable_p "$as_dir/$lt_ac_prog$ac_exec_ext"; then
- lt_ac_sed_list="$lt_ac_sed_list $as_dir/$lt_ac_prog$ac_exec_ext"
- fi
- done
- done
-done
-lt_ac_max=0
-lt_ac_count=0
-# Add /usr/xpg4/bin/sed as it is typically found on Solaris
-# along with /bin/sed that truncates output.
-for lt_ac_sed in $lt_ac_sed_list /usr/xpg4/bin/sed; do
- test ! -f $lt_ac_sed && continue
- cat /dev/null > conftest.in
- lt_ac_count=0
- echo $ECHO_N "0123456789$ECHO_C" >conftest.in
- # Check for GNU sed and select it if it is found.
- if "$lt_ac_sed" --version 2>&1 < /dev/null | grep 'GNU' > /dev/null; then
- lt_cv_path_SED=$lt_ac_sed
- break
- fi
- while true; do
- cat conftest.in conftest.in >conftest.tmp
- mv conftest.tmp conftest.in
- cp conftest.in conftest.nl
- echo >>conftest.nl
- $lt_ac_sed -e 's/a$//' < conftest.nl >conftest.out || break
- cmp -s conftest.out conftest.nl || break
- # 10000 chars as input seems more than enough
- test $lt_ac_count -gt 10 && break
- lt_ac_count=`expr $lt_ac_count + 1`
- if test $lt_ac_count -gt $lt_ac_max; then
- lt_ac_max=$lt_ac_count
- lt_cv_path_SED=$lt_ac_sed
- fi
- done
-done
-
-fi
-
-SED=$lt_cv_path_SED
-echo "$as_me:$LINENO: result: $SED" >&5
-echo "${ECHO_T}$SED" >&6
-
-echo "$as_me:$LINENO: checking for egrep" >&5
-echo $ECHO_N "checking for egrep... $ECHO_C" >&6
-if test "${ac_cv_prog_egrep+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- if echo a | (grep -E '(a|b)') >/dev/null 2>&1
- then ac_cv_prog_egrep='grep -E'
- else ac_cv_prog_egrep='egrep'
- fi
-fi
-echo "$as_me:$LINENO: result: $ac_cv_prog_egrep" >&5
-echo "${ECHO_T}$ac_cv_prog_egrep" >&6
- EGREP=$ac_cv_prog_egrep
-
-
-
-# Check whether --with-gnu-ld or --without-gnu-ld was given.
-if test "${with_gnu_ld+set}" = set; then
- withval="$with_gnu_ld"
- test "$withval" = no || with_gnu_ld=yes
-else
- with_gnu_ld=no
-fi;
-ac_prog=ld
-if test "$GCC" = yes; then
- # Check if gcc -print-prog-name=ld gives a path.
- echo "$as_me:$LINENO: checking for ld used by $CC" >&5
-echo $ECHO_N "checking for ld used by $CC... $ECHO_C" >&6
- case $host in
- *-*-mingw*)
- # gcc leaves a trailing carriage return which upsets mingw
- ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;;
- *)
- ac_prog=`($CC -print-prog-name=ld) 2>&5` ;;
- esac
- case $ac_prog in
- # Accept absolute paths.
- [\\/]* | ?:[\\/]*)
- re_direlt='/[^/][^/]*/\.\./'
- # Canonicalize the pathname of ld
- ac_prog=`echo $ac_prog| $SED 's%\\\\%/%g'`
- while echo $ac_prog | grep "$re_direlt" > /dev/null 2>&1; do
- ac_prog=`echo $ac_prog| $SED "s%$re_direlt%/%"`
- done
- test -z "$LD" && LD="$ac_prog"
- ;;
- "")
- # If it fails, then pretend we aren't using GCC.
- ac_prog=ld
- ;;
- *)
- # If it is relative, then search for the first ld in PATH.
- with_gnu_ld=unknown
- ;;
- esac
-elif test "$with_gnu_ld" = yes; then
- echo "$as_me:$LINENO: checking for GNU ld" >&5
-echo $ECHO_N "checking for GNU ld... $ECHO_C" >&6
-else
- echo "$as_me:$LINENO: checking for non-GNU ld" >&5
-echo $ECHO_N "checking for non-GNU ld... $ECHO_C" >&6
-fi
-if test "${lt_cv_path_LD+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- if test -z "$LD"; then
- lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
- for ac_dir in $PATH; do
- IFS="$lt_save_ifs"
- test -z "$ac_dir" && ac_dir=.
- if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then
- lt_cv_path_LD="$ac_dir/$ac_prog"
- # Check to see if the program is GNU ld. I'd rather use --version,
- # but apparently some variants of GNU ld only accept -v.
- # Break only if it was the GNU/non-GNU ld that we prefer.
- case `"$lt_cv_path_LD" -v 2>&1 </dev/null` in
- *GNU* | *'with BFD'*)
- test "$with_gnu_ld" != no && break
- ;;
- *)
- test "$with_gnu_ld" != yes && break
- ;;
- esac
- fi
- done
- IFS="$lt_save_ifs"
-else
- lt_cv_path_LD="$LD" # Let the user override the test with a path.
-fi
-fi
-
-LD="$lt_cv_path_LD"
-if test -n "$LD"; then
- echo "$as_me:$LINENO: result: $LD" >&5
-echo "${ECHO_T}$LD" >&6
-else
- echo "$as_me:$LINENO: result: no" >&5
-echo "${ECHO_T}no" >&6
-fi
-test -z "$LD" && { { echo "$as_me:$LINENO: error: no acceptable ld found in \$PATH" >&5
-echo "$as_me: error: no acceptable ld found in \$PATH" >&2;}
- { (exit 1); exit 1; }; }
-echo "$as_me:$LINENO: checking if the linker ($LD) is GNU ld" >&5
-echo $ECHO_N "checking if the linker ($LD) is GNU ld... $ECHO_C" >&6
-if test "${lt_cv_prog_gnu_ld+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- # I'd rather use --version here, but apparently some GNU lds only accept -v.
-case `$LD -v 2>&1 </dev/null` in
-*GNU* | *'with BFD'*)
- lt_cv_prog_gnu_ld=yes
- ;;
-*)
- lt_cv_prog_gnu_ld=no
- ;;
-esac
-fi
-echo "$as_me:$LINENO: result: $lt_cv_prog_gnu_ld" >&5
-echo "${ECHO_T}$lt_cv_prog_gnu_ld" >&6
-with_gnu_ld=$lt_cv_prog_gnu_ld
-
-
-echo "$as_me:$LINENO: checking for $LD option to reload object files" >&5
-echo $ECHO_N "checking for $LD option to reload object files... $ECHO_C" >&6
-if test "${lt_cv_ld_reload_flag+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- lt_cv_ld_reload_flag='-r'
-fi
-echo "$as_me:$LINENO: result: $lt_cv_ld_reload_flag" >&5
-echo "${ECHO_T}$lt_cv_ld_reload_flag" >&6
-reload_flag=$lt_cv_ld_reload_flag
-case $reload_flag in
-"" | " "*) ;;
-*) reload_flag=" $reload_flag" ;;
-esac
-reload_cmds='$LD$reload_flag -o $output$reload_objs'
-case $host_os in
- darwin*)
- if test "$GCC" = yes; then
- reload_cmds='$LTCC $LTCFLAGS -nostdlib ${wl}-r -o $output$reload_objs'
- else
- reload_cmds='$LD$reload_flag -o $output$reload_objs'
- fi
- ;;
-esac
-
-echo "$as_me:$LINENO: checking for BSD-compatible nm" >&5
-echo $ECHO_N "checking for BSD-compatible nm... $ECHO_C" >&6
-if test "${lt_cv_path_NM+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- if test -n "$NM"; then
- # Let the user override the test.
- lt_cv_path_NM="$NM"
-else
- lt_nm_to_check="${ac_tool_prefix}nm"
- if test -n "$ac_tool_prefix" && test "$build" = "$host"; then
- lt_nm_to_check="$lt_nm_to_check nm"
- fi
- for lt_tmp_nm in $lt_nm_to_check; do
- lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
- for ac_dir in $PATH /usr/ccs/bin/elf /usr/ccs/bin /usr/ucb /bin; do
- IFS="$lt_save_ifs"
- test -z "$ac_dir" && ac_dir=.
- tmp_nm="$ac_dir/$lt_tmp_nm"
- if test -f "$tmp_nm" || test -f "$tmp_nm$ac_exeext" ; then
- # Check to see if the nm accepts a BSD-compat flag.
- # Adding the `sed 1q' prevents false positives on HP-UX, which says:
- # nm: unknown option "B" ignored
- # Tru64's nm complains that /dev/null is an invalid object file
- case `"$tmp_nm" -B /dev/null 2>&1 | sed '1q'` in
- */dev/null* | *'Invalid file or object type'*)
- lt_cv_path_NM="$tmp_nm -B"
- break
- ;;
- *)
- case `"$tmp_nm" -p /dev/null 2>&1 | sed '1q'` in
- */dev/null*)
- lt_cv_path_NM="$tmp_nm -p"
- break
- ;;
- *)
- lt_cv_path_NM=${lt_cv_path_NM="$tmp_nm"} # keep the first match, but
- continue # so that we can try to find one that supports BSD flags
- ;;
- esac
- ;;
- esac
- fi
- done
- IFS="$lt_save_ifs"
- done
- test -z "$lt_cv_path_NM" && lt_cv_path_NM=nm
-fi
-fi
-echo "$as_me:$LINENO: result: $lt_cv_path_NM" >&5
-echo "${ECHO_T}$lt_cv_path_NM" >&6
-NM="$lt_cv_path_NM"
-
-echo "$as_me:$LINENO: checking whether ln -s works" >&5
-echo $ECHO_N "checking whether ln -s works... $ECHO_C" >&6
-LN_S=$as_ln_s
-if test "$LN_S" = "ln -s"; then
- echo "$as_me:$LINENO: result: yes" >&5
-echo "${ECHO_T}yes" >&6
-else
- echo "$as_me:$LINENO: result: no, using $LN_S" >&5
-echo "${ECHO_T}no, using $LN_S" >&6
-fi
-
-echo "$as_me:$LINENO: checking how to recognise dependent libraries" >&5
-echo $ECHO_N "checking how to recognise dependent libraries... $ECHO_C" >&6
-if test "${lt_cv_deplibs_check_method+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- lt_cv_file_magic_cmd='$MAGIC_CMD'
-lt_cv_file_magic_test_file=
-lt_cv_deplibs_check_method='unknown'
-# Need to set the preceding variable on all platforms that support
-# interlibrary dependencies.
-# 'none' -- dependencies not supported.
-# `unknown' -- same as none, but documents that we really don't know.
-# 'pass_all' -- all dependencies passed with no checks.
-# 'test_compile' -- check by making test program.
-# 'file_magic [[regex]]' -- check by looking for files in library path
-# which responds to the $file_magic_cmd with a given extended regex.
-# If you have `file' or equivalent on your system and you're not sure
-# whether `pass_all' will *always* work, you probably want this one.
-
-case $host_os in
-aix4* | aix5*)
- lt_cv_deplibs_check_method=pass_all
- ;;
-
-beos*)
- lt_cv_deplibs_check_method=pass_all
- ;;
-
-bsdi[45]*)
- lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [ML]SB (shared object|dynamic lib)'
- lt_cv_file_magic_cmd='/usr/bin/file -L'
- lt_cv_file_magic_test_file=/shlib/libc.so
- ;;
-
-cygwin*)
- # func_win32_libid is a shell function defined in ltmain.sh
- lt_cv_deplibs_check_method='file_magic ^x86 archive import|^x86 DLL'
- lt_cv_file_magic_cmd='func_win32_libid'
- ;;
-
-mingw* | pw32*)
- # Base MSYS/MinGW do not provide the 'file' command needed by
- # func_win32_libid shell function, so use a weaker test based on 'objdump'.
- lt_cv_deplibs_check_method='file_magic file format pei*-i386(.*architecture: i386)?'
- lt_cv_file_magic_cmd='$OBJDUMP -f'
- ;;
-
-darwin* | rhapsody*)
- lt_cv_deplibs_check_method=pass_all
- ;;
-
-freebsd* | kfreebsd*-gnu | dragonfly*)
- if echo __ELF__ | $CC -E - | grep __ELF__ > /dev/null; then
- case $host_cpu in
- i*86 )
- # Not sure whether the presence of OpenBSD here was a mistake.
- # Let's accept both of them until this is cleared up.
- lt_cv_deplibs_check_method='file_magic (FreeBSD|OpenBSD|DragonFly)/i[3-9]86 (compact )?demand paged shared library'
- lt_cv_file_magic_cmd=/usr/bin/file
- lt_cv_file_magic_test_file=`echo /usr/lib/libc.so.*`
- ;;
- esac
- else
- lt_cv_deplibs_check_method=pass_all
- fi
- ;;
-
-gnu*)
- lt_cv_deplibs_check_method=pass_all
- ;;
-
-hpux10.20* | hpux11*)
- lt_cv_file_magic_cmd=/usr/bin/file
- case $host_cpu in
- ia64*)
- lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|ELF-[0-9][0-9]) shared object file - IA64'
- lt_cv_file_magic_test_file=/usr/lib/hpux32/libc.so
- ;;
- hppa*64*)
- lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|ELF-[0-9][0-9]) shared object file - PA-RISC [0-9].[0-9]'
- lt_cv_file_magic_test_file=/usr/lib/pa20_64/libc.sl
- ;;
- *)
- lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|PA-RISC[0-9].[0-9]) shared library'
- lt_cv_file_magic_test_file=/usr/lib/libc.sl
- ;;
- esac
- ;;
-
-interix3*)
- # PIC code is broken on Interix 3.x, that's why |\.a not |_pic\.a here
- lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so|\.a)$'
- ;;
-
-irix5* | irix6* | nonstopux*)
- case $LD in
- *-32|*"-32 ") libmagic=32-bit;;
- *-n32|*"-n32 ") libmagic=N32;;
- *-64|*"-64 ") libmagic=64-bit;;
- *) libmagic=never-match;;
- esac
- lt_cv_deplibs_check_method=pass_all
- ;;
-
-# This must be Linux ELF.
-linux*)
- lt_cv_deplibs_check_method=pass_all
- ;;
-
-netbsd* | netbsdelf*-gnu | knetbsd*-gnu)
- if echo __ELF__ | $CC -E - | grep __ELF__ > /dev/null; then
- lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so\.[0-9]+\.[0-9]+|_pic\.a)$'
- else
- lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so|_pic\.a)$'
- fi
- ;;
-
-newos6*)
- lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [ML]SB (executable|dynamic lib)'
- lt_cv_file_magic_cmd=/usr/bin/file
- lt_cv_file_magic_test_file=/usr/lib/libnls.so
- ;;
-
-nto-qnx*)
- lt_cv_deplibs_check_method=unknown
- ;;
-
-openbsd*)
- if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
- lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so\.[0-9]+\.[0-9]+|\.so|_pic\.a)$'
- else
- lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so\.[0-9]+\.[0-9]+|_pic\.a)$'
- fi
- ;;
-
-osf3* | osf4* | osf5*)
- lt_cv_deplibs_check_method=pass_all
- ;;
-
-solaris*)
- lt_cv_deplibs_check_method=pass_all
- ;;
-
-sysv4 | sysv4.3*)
- case $host_vendor in
- motorola)
- lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [ML]SB (shared object|dynamic lib) M[0-9][0-9]* Version [0-9]'
- lt_cv_file_magic_test_file=`echo /usr/lib/libc.so*`
- ;;
- ncr)
- lt_cv_deplibs_check_method=pass_all
- ;;
- sequent)
- lt_cv_file_magic_cmd='/bin/file'
- lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [LM]SB (shared object|dynamic lib )'
- ;;
- sni)
- lt_cv_file_magic_cmd='/bin/file'
- lt_cv_deplibs_check_method="file_magic ELF [0-9][0-9]*-bit [LM]SB dynamic lib"
- lt_cv_file_magic_test_file=/lib/libc.so
- ;;
- siemens)
- lt_cv_deplibs_check_method=pass_all
- ;;
- pc)
- lt_cv_deplibs_check_method=pass_all
- ;;
- esac
- ;;
-
-sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*)
- lt_cv_deplibs_check_method=pass_all
- ;;
-esac
-
-fi
-echo "$as_me:$LINENO: result: $lt_cv_deplibs_check_method" >&5
-echo "${ECHO_T}$lt_cv_deplibs_check_method" >&6
-file_magic_cmd=$lt_cv_file_magic_cmd
-deplibs_check_method=$lt_cv_deplibs_check_method
-test -z "$deplibs_check_method" && deplibs_check_method=unknown
-
-
-
-
-# If no C compiler was specified, use CC.
-LTCC=${LTCC-"$CC"}
-
-# If no C compiler flags were specified, use CFLAGS.
-LTCFLAGS=${LTCFLAGS-"$CFLAGS"}
-
-# Allow CC to be a program name with arguments.
-compiler=$CC
-
-
-# Check whether --enable-libtool-lock or --disable-libtool-lock was given.
-if test "${enable_libtool_lock+set}" = set; then
- enableval="$enable_libtool_lock"
-
-fi;
-test "x$enable_libtool_lock" != xno && enable_libtool_lock=yes
-
-# Some flags need to be propagated to the compiler or linker for good
-# libtool support.
-case $host in
-ia64-*-hpux*)
- # Find out which ABI we are using.
- echo 'int i;' > conftest.$ac_ext
- if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
- (eval $ac_compile) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; then
- case `/usr/bin/file conftest.$ac_objext` in
- *ELF-32*)
- HPUX_IA64_MODE="32"
- ;;
- *ELF-64*)
- HPUX_IA64_MODE="64"
- ;;
- esac
- fi
- rm -rf conftest*
- ;;
-*-*-irix6*)
- # Find out which ABI we are using.
- echo '#line 3673 "configure"' > conftest.$ac_ext
- if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
- (eval $ac_compile) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; then
- if test "$lt_cv_prog_gnu_ld" = yes; then
- case `/usr/bin/file conftest.$ac_objext` in
- *32-bit*)
- LD="${LD-ld} -melf32bsmip"
- ;;
- *N32*)
- LD="${LD-ld} -melf32bmipn32"
- ;;
- *64-bit*)
- LD="${LD-ld} -melf64bmip"
- ;;
- esac
- else
- case `/usr/bin/file conftest.$ac_objext` in
- *32-bit*)
- LD="${LD-ld} -32"
- ;;
- *N32*)
- LD="${LD-ld} -n32"
- ;;
- *64-bit*)
- LD="${LD-ld} -64"
- ;;
- esac
- fi
- fi
- rm -rf conftest*
- ;;
-
-x86_64-*linux*|ppc*-*linux*|powerpc*-*linux*|s390*-*linux*|sparc*-*linux*)
- # Find out which ABI we are using.
- echo 'int i;' > conftest.$ac_ext
- if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
- (eval $ac_compile) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; then
- case `/usr/bin/file conftest.o` in
- *32-bit*)
- case $host in
- x86_64-*linux*)
- LD="${LD-ld} -m elf_i386"
- ;;
- ppc64-*linux*|powerpc64-*linux*)
- LD="${LD-ld} -m elf32ppclinux"
- ;;
- s390x-*linux*)
- LD="${LD-ld} -m elf_s390"
- ;;
- sparc64-*linux*)
- LD="${LD-ld} -m elf32_sparc"
- ;;
- esac
- ;;
- *64-bit*)
- case $host in
- x86_64-*linux*)
- LD="${LD-ld} -m elf_x86_64"
- ;;
- ppc*-*linux*|powerpc*-*linux*)
- LD="${LD-ld} -m elf64ppc"
- ;;
- s390*-*linux*)
- LD="${LD-ld} -m elf64_s390"
- ;;
- sparc*-*linux*)
- LD="${LD-ld} -m elf64_sparc"
- ;;
- esac
- ;;
- esac
- fi
- rm -rf conftest*
- ;;
-
-*-*-sco3.2v5*)
- # On SCO OpenServer 5, we need -belf to get full-featured binaries.
- SAVE_CFLAGS="$CFLAGS"
- CFLAGS="$CFLAGS -belf"
- echo "$as_me:$LINENO: checking whether the C compiler needs -belf" >&5
-echo $ECHO_N "checking whether the C compiler needs -belf... $ECHO_C" >&6
-if test "${lt_cv_cc_needs_belf+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- ac_ext=c
-ac_cpp='$CPP $CPPFLAGS'
-ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
-ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
-ac_compiler_gnu=$ac_cv_c_compiler_gnu
-
- cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-
-int
-main ()
-{
-
- ;
- return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
- (eval $ac_link) 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } &&
- { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; } &&
- { ac_try='test -s conftest$ac_exeext'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
- lt_cv_cc_needs_belf=yes
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-lt_cv_cc_needs_belf=no
-fi
-rm -f conftest.err conftest.$ac_objext \
- conftest$ac_exeext conftest.$ac_ext
- ac_ext=c
-ac_cpp='$CPP $CPPFLAGS'
-ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
-ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
-ac_compiler_gnu=$ac_cv_c_compiler_gnu
-
-fi
-echo "$as_me:$LINENO: result: $lt_cv_cc_needs_belf" >&5
-echo "${ECHO_T}$lt_cv_cc_needs_belf" >&6
- if test x"$lt_cv_cc_needs_belf" != x"yes"; then
- # this is probably gcc 2.8.0, egcs 1.0 or newer; no need for -belf
- CFLAGS="$SAVE_CFLAGS"
- fi
- ;;
-sparc*-*solaris*)
- # Find out which ABI we are using.
- echo 'int i;' > conftest.$ac_ext
- if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
- (eval $ac_compile) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; then
- case `/usr/bin/file conftest.o` in
- *64-bit*)
- case $lt_cv_prog_gnu_ld in
- yes*) LD="${LD-ld} -m elf64_sparc" ;;
- *) LD="${LD-ld} -64" ;;
- esac
- ;;
- esac
- fi
- rm -rf conftest*
- ;;
-
-
-esac
-
-need_locks="$enable_libtool_lock"
-
-
-ac_ext=c
-ac_cpp='$CPP $CPPFLAGS'
-ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
-ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
-ac_compiler_gnu=$ac_cv_c_compiler_gnu
-echo "$as_me:$LINENO: checking how to run the C preprocessor" >&5
-echo $ECHO_N "checking how to run the C preprocessor... $ECHO_C" >&6
-# On Suns, sometimes $CPP names a directory.
-if test -n "$CPP" && test -d "$CPP"; then
- CPP=
-fi
-if test -z "$CPP"; then
- if test "${ac_cv_prog_CPP+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- # Double quotes because CPP needs to be expanded
- for CPP in "$CC -E" "$CC -E -traditional-cpp" "/lib/cpp"
- do
- ac_preproc_ok=false
-for ac_c_preproc_warn_flag in '' yes
-do
- # Use a header file that comes with gcc, so configuring glibc
- # with a fresh cross-compiler works.
- # Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
- # <limits.h> exists even on freestanding compilers.
- # On the NeXT, cc -E runs the code through the compiler's parser,
- # not just through cpp. "Syntax error" is here to catch this case.
- cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-#ifdef __STDC__
-# include <limits.h>
-#else
-# include <assert.h>
-#endif
- Syntax error
-_ACEOF
-if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5
- (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } >/dev/null; then
- if test -s conftest.err; then
- ac_cpp_err=$ac_c_preproc_warn_flag
- ac_cpp_err=$ac_cpp_err$ac_c_werror_flag
- else
- ac_cpp_err=
- fi
-else
- ac_cpp_err=yes
-fi
-if test -z "$ac_cpp_err"; then
- :
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
- # Broken: fails on valid input.
-continue
-fi
-rm -f conftest.err conftest.$ac_ext
-
- # OK, works on sane cases. Now check whether non-existent headers
- # can be detected and how.
- cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-#include <ac_nonexistent.h>
-_ACEOF
-if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5
- (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } >/dev/null; then
- if test -s conftest.err; then
- ac_cpp_err=$ac_c_preproc_warn_flag
- ac_cpp_err=$ac_cpp_err$ac_c_werror_flag
- else
- ac_cpp_err=
- fi
-else
- ac_cpp_err=yes
-fi
-if test -z "$ac_cpp_err"; then
- # Broken: success on invalid input.
-continue
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
- # Passes both tests.
-ac_preproc_ok=:
-break
-fi
-rm -f conftest.err conftest.$ac_ext
-
-done
-# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped.
-rm -f conftest.err conftest.$ac_ext
-if $ac_preproc_ok; then
- break
-fi
-
- done
- ac_cv_prog_CPP=$CPP
-
-fi
- CPP=$ac_cv_prog_CPP
-else
- ac_cv_prog_CPP=$CPP
-fi
-echo "$as_me:$LINENO: result: $CPP" >&5
-echo "${ECHO_T}$CPP" >&6
-ac_preproc_ok=false
-for ac_c_preproc_warn_flag in '' yes
-do
- # Use a header file that comes with gcc, so configuring glibc
- # with a fresh cross-compiler works.
- # Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
- # <limits.h> exists even on freestanding compilers.
- # On the NeXT, cc -E runs the code through the compiler's parser,
- # not just through cpp. "Syntax error" is here to catch this case.
- cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-#ifdef __STDC__
-# include <limits.h>
-#else
-# include <assert.h>
-#endif
- Syntax error
-_ACEOF
-if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5
- (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } >/dev/null; then
- if test -s conftest.err; then
- ac_cpp_err=$ac_c_preproc_warn_flag
- ac_cpp_err=$ac_cpp_err$ac_c_werror_flag
- else
- ac_cpp_err=
- fi
-else
- ac_cpp_err=yes
-fi
-if test -z "$ac_cpp_err"; then
- :
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
- # Broken: fails on valid input.
-continue
-fi
-rm -f conftest.err conftest.$ac_ext
-
- # OK, works on sane cases. Now check whether non-existent headers
- # can be detected and how.
- cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-#include <ac_nonexistent.h>
-_ACEOF
-if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5
- (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } >/dev/null; then
- if test -s conftest.err; then
- ac_cpp_err=$ac_c_preproc_warn_flag
- ac_cpp_err=$ac_cpp_err$ac_c_werror_flag
- else
- ac_cpp_err=
- fi
-else
- ac_cpp_err=yes
-fi
-if test -z "$ac_cpp_err"; then
- # Broken: success on invalid input.
-continue
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
- # Passes both tests.
-ac_preproc_ok=:
-break
-fi
-rm -f conftest.err conftest.$ac_ext
-
-done
-# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped.
-rm -f conftest.err conftest.$ac_ext
-if $ac_preproc_ok; then
- :
-else
- { { echo "$as_me:$LINENO: error: C preprocessor \"$CPP\" fails sanity check
-See \`config.log' for more details." >&5
-echo "$as_me: error: C preprocessor \"$CPP\" fails sanity check
-See \`config.log' for more details." >&2;}
- { (exit 1); exit 1; }; }
-fi
-
-ac_ext=c
-ac_cpp='$CPP $CPPFLAGS'
-ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
-ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
-ac_compiler_gnu=$ac_cv_c_compiler_gnu
-
-
-echo "$as_me:$LINENO: checking for ANSI C header files" >&5
-echo $ECHO_N "checking for ANSI C header files... $ECHO_C" >&6
-if test "${ac_cv_header_stdc+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-#include <stdlib.h>
-#include <stdarg.h>
-#include <string.h>
-#include <float.h>
-
-int
-main ()
-{
-
- ;
- return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
- (eval $ac_compile) 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } &&
- { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; } &&
- { ac_try='test -s conftest.$ac_objext'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
- ac_cv_header_stdc=yes
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-ac_cv_header_stdc=no
-fi
-rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
-
-if test $ac_cv_header_stdc = yes; then
- # SunOS 4.x string.h does not declare mem*, contrary to ANSI.
- cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-#include <string.h>
-
-_ACEOF
-if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
- $EGREP "memchr" >/dev/null 2>&1; then
- :
-else
- ac_cv_header_stdc=no
-fi
-rm -f conftest*
-
-fi
-
-if test $ac_cv_header_stdc = yes; then
- # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI.
- cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-#include <stdlib.h>
-
-_ACEOF
-if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
- $EGREP "free" >/dev/null 2>&1; then
- :
-else
- ac_cv_header_stdc=no
-fi
-rm -f conftest*
-
-fi
-
-if test $ac_cv_header_stdc = yes; then
- # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi.
- if test "$cross_compiling" = yes; then
- :
-else
- cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-#include <ctype.h>
-#if ((' ' & 0x0FF) == 0x020)
-# define ISLOWER(c) ('a' <= (c) && (c) <= 'z')
-# define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c))
-#else
-# define ISLOWER(c) \
- (('a' <= (c) && (c) <= 'i') \
- || ('j' <= (c) && (c) <= 'r') \
- || ('s' <= (c) && (c) <= 'z'))
-# define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c))
-#endif
-
-#define XOR(e, f) (((e) && !(f)) || (!(e) && (f)))
-int
-main ()
-{
- int i;
- for (i = 0; i < 256; i++)
- if (XOR (islower (i), ISLOWER (i))
- || toupper (i) != TOUPPER (i))
- exit(2);
- exit (0);
-}
-_ACEOF
-rm -f conftest$ac_exeext
-if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
- (eval $ac_link) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
- :
-else
- echo "$as_me: program exited with status $ac_status" >&5
-echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-( exit $ac_status )
-ac_cv_header_stdc=no
-fi
-rm -f core *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
-fi
-fi
-fi
-echo "$as_me:$LINENO: result: $ac_cv_header_stdc" >&5
-echo "${ECHO_T}$ac_cv_header_stdc" >&6
-if test $ac_cv_header_stdc = yes; then
-
-cat >>confdefs.h <<\_ACEOF
-#define STDC_HEADERS 1
-_ACEOF
-
-fi
-
-# On IRIX 5.3, sys/types and inttypes.h are conflicting.
-
-
-
-
-
-
-
-
-
-for ac_header in sys/types.h sys/stat.h stdlib.h string.h memory.h strings.h \
- inttypes.h stdint.h unistd.h
-do
-as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
-echo "$as_me:$LINENO: checking for $ac_header" >&5
-echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
-if eval "test \"\${$as_ac_Header+set}\" = set"; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-$ac_includes_default
-
-#include <$ac_header>
-_ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
- (eval $ac_compile) 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } &&
- { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; } &&
- { ac_try='test -s conftest.$ac_objext'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
- eval "$as_ac_Header=yes"
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-eval "$as_ac_Header=no"
-fi
-rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
-fi
-echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5
-echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6
-if test `eval echo '${'$as_ac_Header'}'` = yes; then
- cat >>confdefs.h <<_ACEOF
-#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1
-_ACEOF
-
-fi
-
-done
-
-
-
-for ac_header in dlfcn.h
-do
-as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
-if eval "test \"\${$as_ac_Header+set}\" = set"; then
- echo "$as_me:$LINENO: checking for $ac_header" >&5
-echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
-if eval "test \"\${$as_ac_Header+set}\" = set"; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-fi
-echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5
-echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6
-else
- # Is the header compilable?
-echo "$as_me:$LINENO: checking $ac_header usability" >&5
-echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6
-cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-$ac_includes_default
-#include <$ac_header>
-_ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
- (eval $ac_compile) 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } &&
- { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; } &&
- { ac_try='test -s conftest.$ac_objext'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
- ac_header_compiler=yes
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-ac_header_compiler=no
-fi
-rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
-echo "$as_me:$LINENO: result: $ac_header_compiler" >&5
-echo "${ECHO_T}$ac_header_compiler" >&6
-
-# Is the header present?
-echo "$as_me:$LINENO: checking $ac_header presence" >&5
-echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6
-cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-#include <$ac_header>
-_ACEOF
-if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5
- (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } >/dev/null; then
- if test -s conftest.err; then
- ac_cpp_err=$ac_c_preproc_warn_flag
- ac_cpp_err=$ac_cpp_err$ac_c_werror_flag
- else
- ac_cpp_err=
- fi
-else
- ac_cpp_err=yes
-fi
-if test -z "$ac_cpp_err"; then
- ac_header_preproc=yes
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
- ac_header_preproc=no
-fi
-rm -f conftest.err conftest.$ac_ext
-echo "$as_me:$LINENO: result: $ac_header_preproc" >&5
-echo "${ECHO_T}$ac_header_preproc" >&6
-
-# So? What about this header?
-case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in
- yes:no: )
- { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5
-echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;}
- { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5
-echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;}
- ac_header_preproc=yes
- ;;
- no:yes:* )
- { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5
-echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;}
- { echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5
-echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;}
- { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5
-echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;}
- { echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5
-echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;}
- { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5
-echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;}
- { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5
-echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;}
- (
- cat <<\_ASBOX
-## -------------------------------------------- ##
-## Report this to general@lists.openfabrics.org ##
-## -------------------------------------------- ##
-_ASBOX
- ) |
- sed "s/^/$as_me: WARNING: /" >&2
- ;;
-esac
-echo "$as_me:$LINENO: checking for $ac_header" >&5
-echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
-if eval "test \"\${$as_ac_Header+set}\" = set"; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- eval "$as_ac_Header=\$ac_header_preproc"
-fi
-echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5
-echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6
-
-fi
-if test `eval echo '${'$as_ac_Header'}'` = yes; then
- cat >>confdefs.h <<_ACEOF
-#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1
-_ACEOF
-
-fi
-
-done
-
-ac_ext=cc
-ac_cpp='$CXXCPP $CPPFLAGS'
-ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
-ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
-ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
-if test -n "$ac_tool_prefix"; then
- for ac_prog in $CCC g++ c++ gpp aCC CC cxx cc++ cl FCC KCC RCC xlC_r xlC
- do
- # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args.
-set dummy $ac_tool_prefix$ac_prog; ac_word=$2
-echo "$as_me:$LINENO: checking for $ac_word" >&5
-echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
-if test "${ac_cv_prog_CXX+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- if test -n "$CXX"; then
- ac_cv_prog_CXX="$CXX" # Let the user override the test.
-else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
- IFS=$as_save_IFS
- test -z "$as_dir" && as_dir=.
- for ac_exec_ext in '' $ac_executable_extensions; do
- if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
- ac_cv_prog_CXX="$ac_tool_prefix$ac_prog"
- echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
- break 2
- fi
-done
-done
-
-fi
-fi
-CXX=$ac_cv_prog_CXX
-if test -n "$CXX"; then
- echo "$as_me:$LINENO: result: $CXX" >&5
-echo "${ECHO_T}$CXX" >&6
-else
- echo "$as_me:$LINENO: result: no" >&5
-echo "${ECHO_T}no" >&6
-fi
-
- test -n "$CXX" && break
- done
-fi
-if test -z "$CXX"; then
- ac_ct_CXX=$CXX
- for ac_prog in $CCC g++ c++ gpp aCC CC cxx cc++ cl FCC KCC RCC xlC_r xlC
-do
- # Extract the first word of "$ac_prog", so it can be a program name with args.
-set dummy $ac_prog; ac_word=$2
-echo "$as_me:$LINENO: checking for $ac_word" >&5
-echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
-if test "${ac_cv_prog_ac_ct_CXX+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- if test -n "$ac_ct_CXX"; then
- ac_cv_prog_ac_ct_CXX="$ac_ct_CXX" # Let the user override the test.
-else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
- IFS=$as_save_IFS
- test -z "$as_dir" && as_dir=.
- for ac_exec_ext in '' $ac_executable_extensions; do
- if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
- ac_cv_prog_ac_ct_CXX="$ac_prog"
- echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
- break 2
- fi
-done
-done
-
-fi
-fi
-ac_ct_CXX=$ac_cv_prog_ac_ct_CXX
-if test -n "$ac_ct_CXX"; then
- echo "$as_me:$LINENO: result: $ac_ct_CXX" >&5
-echo "${ECHO_T}$ac_ct_CXX" >&6
-else
- echo "$as_me:$LINENO: result: no" >&5
-echo "${ECHO_T}no" >&6
-fi
-
- test -n "$ac_ct_CXX" && break
-done
-test -n "$ac_ct_CXX" || ac_ct_CXX="g++"
-
- CXX=$ac_ct_CXX
-fi
-
-
-# Provide some information about the compiler.
-echo "$as_me:$LINENO:" \
- "checking for C++ compiler version" >&5
-ac_compiler=`set X $ac_compile; echo $2`
-{ (eval echo "$as_me:$LINENO: \"$ac_compiler --version </dev/null >&5\"") >&5
- (eval $ac_compiler --version </dev/null >&5) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }
-{ (eval echo "$as_me:$LINENO: \"$ac_compiler -v </dev/null >&5\"") >&5
- (eval $ac_compiler -v </dev/null >&5) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }
-{ (eval echo "$as_me:$LINENO: \"$ac_compiler -V </dev/null >&5\"") >&5
- (eval $ac_compiler -V </dev/null >&5) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }
-
-echo "$as_me:$LINENO: checking whether we are using the GNU C++ compiler" >&5
-echo $ECHO_N "checking whether we are using the GNU C++ compiler... $ECHO_C" >&6
-if test "${ac_cv_cxx_compiler_gnu+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-
-int
-main ()
-{
-#ifndef __GNUC__
- choke me
-#endif
-
- ;
- return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
- (eval $ac_compile) 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } &&
- { ac_try='test -z "$ac_cxx_werror_flag" || test ! -s conftest.err'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; } &&
- { ac_try='test -s conftest.$ac_objext'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
- ac_compiler_gnu=yes
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-ac_compiler_gnu=no
-fi
-rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
-ac_cv_cxx_compiler_gnu=$ac_compiler_gnu
-
-fi
-echo "$as_me:$LINENO: result: $ac_cv_cxx_compiler_gnu" >&5
-echo "${ECHO_T}$ac_cv_cxx_compiler_gnu" >&6
-GXX=`test $ac_compiler_gnu = yes && echo yes`
-ac_test_CXXFLAGS=${CXXFLAGS+set}
-ac_save_CXXFLAGS=$CXXFLAGS
-CXXFLAGS="-g"
-echo "$as_me:$LINENO: checking whether $CXX accepts -g" >&5
-echo $ECHO_N "checking whether $CXX accepts -g... $ECHO_C" >&6
-if test "${ac_cv_prog_cxx_g+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-
-int
-main ()
-{
-
- ;
- return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
- (eval $ac_compile) 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } &&
- { ac_try='test -z "$ac_cxx_werror_flag" || test ! -s conftest.err'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; } &&
- { ac_try='test -s conftest.$ac_objext'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
- ac_cv_prog_cxx_g=yes
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-ac_cv_prog_cxx_g=no
-fi
-rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
-fi
-echo "$as_me:$LINENO: result: $ac_cv_prog_cxx_g" >&5
-echo "${ECHO_T}$ac_cv_prog_cxx_g" >&6
-if test "$ac_test_CXXFLAGS" = set; then
- CXXFLAGS=$ac_save_CXXFLAGS
-elif test $ac_cv_prog_cxx_g = yes; then
- if test "$GXX" = yes; then
- CXXFLAGS="-g -O2"
- else
- CXXFLAGS="-g"
- fi
-else
- if test "$GXX" = yes; then
- CXXFLAGS="-O2"
- else
- CXXFLAGS=
- fi
-fi
-for ac_declaration in \
- '' \
- 'extern "C" void std::exit (int) throw (); using std::exit;' \
- 'extern "C" void std::exit (int); using std::exit;' \
- 'extern "C" void exit (int) throw ();' \
- 'extern "C" void exit (int);' \
- 'void exit (int);'
-do
- cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-$ac_declaration
-#include <stdlib.h>
-int
-main ()
-{
-exit (42);
- ;
- return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
- (eval $ac_compile) 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } &&
- { ac_try='test -z "$ac_cxx_werror_flag" || test ! -s conftest.err'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; } &&
- { ac_try='test -s conftest.$ac_objext'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
- :
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-continue
-fi
-rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
- cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-$ac_declaration
-int
-main ()
-{
-exit (42);
- ;
- return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
- (eval $ac_compile) 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } &&
- { ac_try='test -z "$ac_cxx_werror_flag" || test ! -s conftest.err'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; } &&
- { ac_try='test -s conftest.$ac_objext'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
- break
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-fi
-rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
-done
-rm -f conftest*
-if test -n "$ac_declaration"; then
- echo '#ifdef __cplusplus' >>confdefs.h
- echo $ac_declaration >>confdefs.h
- echo '#endif' >>confdefs.h
-fi
-
-ac_ext=cc
-ac_cpp='$CXXCPP $CPPFLAGS'
-ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
-ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
-ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
-
-depcc="$CXX" am_compiler_list=
-
-echo "$as_me:$LINENO: checking dependency style of $depcc" >&5
-echo $ECHO_N "checking dependency style of $depcc... $ECHO_C" >&6
-if test "${am_cv_CXX_dependencies_compiler_type+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then
- # We make a subdir and do the tests there. Otherwise we can end up
- # making bogus files that we don't know about and never remove. For
- # instance it was reported that on HP-UX the gcc test will end up
- # making a dummy file named `D' -- because `-MD' means `put the output
- # in D'.
- mkdir conftest.dir
- # Copy depcomp to subdir because otherwise we won't find it if we're
- # using a relative directory.
- cp "$am_depcomp" conftest.dir
- cd conftest.dir
- # We will build objects and dependencies in a subdirectory because
- # it helps to detect inapplicable dependency modes. For instance
- # both Tru64's cc and ICC support -MD to output dependencies as a
- # side effect of compilation, but ICC will put the dependencies in
- # the current directory while Tru64 will put them in the object
- # directory.
- mkdir sub
-
- am_cv_CXX_dependencies_compiler_type=none
- if test "$am_compiler_list" = ""; then
- am_compiler_list=`sed -n 's/^#*\([a-zA-Z0-9]*\))$/\1/p' < ./depcomp`
- fi
- for depmode in $am_compiler_list; do
- # Setup a source with many dependencies, because some compilers
- # like to wrap large dependency lists on column 80 (with \), and
- # we should not choose a depcomp mode which is confused by this.
- #
- # We need to recreate these files for each test, as the compiler may
- # overwrite some of them when testing with obscure command lines.
- # This happens at least with the AIX C compiler.
- : > sub/conftest.c
- for i in 1 2 3 4 5 6; do
- echo '#include "conftst'$i'.h"' >> sub/conftest.c
- # Using `: > sub/conftst$i.h' creates only sub/conftst1.h with
- # Solaris 8's {/usr,}/bin/sh.
- touch sub/conftst$i.h
- done
- echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf
-
- case $depmode in
- nosideeffect)
- # after this tag, mechanisms are not by side-effect, so they'll
- # only be used when explicitly requested
- if test "x$enable_dependency_tracking" = xyes; then
- continue
- else
- break
- fi
- ;;
- none) break ;;
- esac
- # We check with `-c' and `-o' for the sake of the "dashmstdout"
- # mode. It turns out that the SunPro C++ compiler does not properly
- # handle `-M -o', and we need to detect this.
- if depmode=$depmode \
- source=sub/conftest.c object=sub/conftest.${OBJEXT-o} \
- depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \
- $SHELL ./depcomp $depcc -c -o sub/conftest.${OBJEXT-o} sub/conftest.c \
- >/dev/null 2>conftest.err &&
- grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 &&
- grep sub/conftest.${OBJEXT-o} sub/conftest.Po > /dev/null 2>&1 &&
- ${MAKE-make} -s -f confmf > /dev/null 2>&1; then
- # icc doesn't choke on unknown options, it will just issue warnings
- # or remarks (even with -Werror). So we grep stderr for any message
- # that says an option was ignored or not supported.
- # When given -MP, icc 7.0 and 7.1 complain thusly:
- # icc: Command line warning: ignoring option '-M'; no argument required
- # The diagnosis changed in icc 8.0:
- # icc: Command line remark: option '-MP' not supported
- if (grep 'ignoring option' conftest.err ||
- grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else
- am_cv_CXX_dependencies_compiler_type=$depmode
- break
- fi
- fi
- done
-
- cd ..
- rm -rf conftest.dir
-else
- am_cv_CXX_dependencies_compiler_type=none
-fi
-
-fi
-echo "$as_me:$LINENO: result: $am_cv_CXX_dependencies_compiler_type" >&5
-echo "${ECHO_T}$am_cv_CXX_dependencies_compiler_type" >&6
-CXXDEPMODE=depmode=$am_cv_CXX_dependencies_compiler_type
-
-
-
-if
- test "x$enable_dependency_tracking" != xno \
- && test "$am_cv_CXX_dependencies_compiler_type" = gcc3; then
- am__fastdepCXX_TRUE=
- am__fastdepCXX_FALSE='#'
-else
- am__fastdepCXX_TRUE='#'
- am__fastdepCXX_FALSE=
-fi
-
-
-
-
-if test -n "$CXX" && ( test "X$CXX" != "Xno" &&
- ( (test "X$CXX" = "Xg++" && `g++ -v >/dev/null 2>&1` ) ||
- (test "X$CXX" != "Xg++"))) ; then
- ac_ext=cc
-ac_cpp='$CXXCPP $CPPFLAGS'
-ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
-ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
-ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
-echo "$as_me:$LINENO: checking how to run the C++ preprocessor" >&5
-echo $ECHO_N "checking how to run the C++ preprocessor... $ECHO_C" >&6
-if test -z "$CXXCPP"; then
- if test "${ac_cv_prog_CXXCPP+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- # Double quotes because CXXCPP needs to be expanded
- for CXXCPP in "$CXX -E" "/lib/cpp"
- do
- ac_preproc_ok=false
-for ac_cxx_preproc_warn_flag in '' yes
-do
- # Use a header file that comes with gcc, so configuring glibc
- # with a fresh cross-compiler works.
- # Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
- # <limits.h> exists even on freestanding compilers.
- # On the NeXT, cc -E runs the code through the compiler's parser,
- # not just through cpp. "Syntax error" is here to catch this case.
- cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-#ifdef __STDC__
-# include <limits.h>
-#else
-# include <assert.h>
-#endif
- Syntax error
-_ACEOF
-if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5
- (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } >/dev/null; then
- if test -s conftest.err; then
- ac_cpp_err=$ac_cxx_preproc_warn_flag
- ac_cpp_err=$ac_cpp_err$ac_cxx_werror_flag
- else
- ac_cpp_err=
- fi
-else
- ac_cpp_err=yes
-fi
-if test -z "$ac_cpp_err"; then
- :
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
- # Broken: fails on valid input.
-continue
-fi
-rm -f conftest.err conftest.$ac_ext
-
- # OK, works on sane cases. Now check whether non-existent headers
- # can be detected and how.
- cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-#include <ac_nonexistent.h>
-_ACEOF
-if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5
- (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } >/dev/null; then
- if test -s conftest.err; then
- ac_cpp_err=$ac_cxx_preproc_warn_flag
- ac_cpp_err=$ac_cpp_err$ac_cxx_werror_flag
- else
- ac_cpp_err=
- fi
-else
- ac_cpp_err=yes
-fi
-if test -z "$ac_cpp_err"; then
- # Broken: success on invalid input.
-continue
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
- # Passes both tests.
-ac_preproc_ok=:
-break
-fi
-rm -f conftest.err conftest.$ac_ext
-
-done
-# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped.
-rm -f conftest.err conftest.$ac_ext
-if $ac_preproc_ok; then
- break
-fi
-
- done
- ac_cv_prog_CXXCPP=$CXXCPP
-
-fi
- CXXCPP=$ac_cv_prog_CXXCPP
-else
- ac_cv_prog_CXXCPP=$CXXCPP
-fi
-echo "$as_me:$LINENO: result: $CXXCPP" >&5
-echo "${ECHO_T}$CXXCPP" >&6
-ac_preproc_ok=false
-for ac_cxx_preproc_warn_flag in '' yes
-do
- # Use a header file that comes with gcc, so configuring glibc
- # with a fresh cross-compiler works.
- # Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
- # <limits.h> exists even on freestanding compilers.
- # On the NeXT, cc -E runs the code through the compiler's parser,
- # not just through cpp. "Syntax error" is here to catch this case.
- cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-#ifdef __STDC__
-# include <limits.h>
-#else
-# include <assert.h>
-#endif
- Syntax error
-_ACEOF
-if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5
- (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } >/dev/null; then
- if test -s conftest.err; then
- ac_cpp_err=$ac_cxx_preproc_warn_flag
- ac_cpp_err=$ac_cpp_err$ac_cxx_werror_flag
- else
- ac_cpp_err=
- fi
-else
- ac_cpp_err=yes
-fi
-if test -z "$ac_cpp_err"; then
- :
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
- # Broken: fails on valid input.
-continue
-fi
-rm -f conftest.err conftest.$ac_ext
-
- # OK, works on sane cases. Now check whether non-existent headers
- # can be detected and how.
- cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-#include <ac_nonexistent.h>
-_ACEOF
-if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5
- (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } >/dev/null; then
- if test -s conftest.err; then
- ac_cpp_err=$ac_cxx_preproc_warn_flag
- ac_cpp_err=$ac_cpp_err$ac_cxx_werror_flag
- else
- ac_cpp_err=
- fi
-else
- ac_cpp_err=yes
-fi
-if test -z "$ac_cpp_err"; then
- # Broken: success on invalid input.
-continue
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
- # Passes both tests.
-ac_preproc_ok=:
-break
-fi
-rm -f conftest.err conftest.$ac_ext
-
-done
-# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped.
-rm -f conftest.err conftest.$ac_ext
-if $ac_preproc_ok; then
- :
-else
- { { echo "$as_me:$LINENO: error: C++ preprocessor \"$CXXCPP\" fails sanity check
-See \`config.log' for more details." >&5
-echo "$as_me: error: C++ preprocessor \"$CXXCPP\" fails sanity check
-See \`config.log' for more details." >&2;}
- { (exit 1); exit 1; }; }
-fi
-
-ac_ext=cc
-ac_cpp='$CXXCPP $CPPFLAGS'
-ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
-ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
-ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
-
-fi
-
-
-ac_ext=f
-ac_compile='$F77 -c $FFLAGS conftest.$ac_ext >&5'
-ac_link='$F77 -o conftest$ac_exeext $FFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
-ac_compiler_gnu=$ac_cv_f77_compiler_gnu
-if test -n "$ac_tool_prefix"; then
- for ac_prog in g77 f77 xlf frt pgf77 fort77 fl32 af77 f90 xlf90 pgf90 epcf90 f95 fort xlf95 ifc efc pgf95 lf95 gfortran
- do
- # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args.
-set dummy $ac_tool_prefix$ac_prog; ac_word=$2
-echo "$as_me:$LINENO: checking for $ac_word" >&5
-echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
-if test "${ac_cv_prog_F77+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- if test -n "$F77"; then
- ac_cv_prog_F77="$F77" # Let the user override the test.
-else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
- IFS=$as_save_IFS
- test -z "$as_dir" && as_dir=.
- for ac_exec_ext in '' $ac_executable_extensions; do
- if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
- ac_cv_prog_F77="$ac_tool_prefix$ac_prog"
- echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
- break 2
- fi
-done
-done
-
-fi
-fi
-F77=$ac_cv_prog_F77
-if test -n "$F77"; then
- echo "$as_me:$LINENO: result: $F77" >&5
-echo "${ECHO_T}$F77" >&6
-else
- echo "$as_me:$LINENO: result: no" >&5
-echo "${ECHO_T}no" >&6
-fi
-
- test -n "$F77" && break
- done
-fi
-if test -z "$F77"; then
- ac_ct_F77=$F77
- for ac_prog in g77 f77 xlf frt pgf77 fort77 fl32 af77 f90 xlf90 pgf90 epcf90 f95 fort xlf95 ifc efc pgf95 lf95 gfortran
-do
- # Extract the first word of "$ac_prog", so it can be a program name with args.
-set dummy $ac_prog; ac_word=$2
-echo "$as_me:$LINENO: checking for $ac_word" >&5
-echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
-if test "${ac_cv_prog_ac_ct_F77+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- if test -n "$ac_ct_F77"; then
- ac_cv_prog_ac_ct_F77="$ac_ct_F77" # Let the user override the test.
-else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
- IFS=$as_save_IFS
- test -z "$as_dir" && as_dir=.
- for ac_exec_ext in '' $ac_executable_extensions; do
- if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
- ac_cv_prog_ac_ct_F77="$ac_prog"
- echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
- break 2
- fi
-done
-done
-
-fi
-fi
-ac_ct_F77=$ac_cv_prog_ac_ct_F77
-if test -n "$ac_ct_F77"; then
- echo "$as_me:$LINENO: result: $ac_ct_F77" >&5
-echo "${ECHO_T}$ac_ct_F77" >&6
-else
- echo "$as_me:$LINENO: result: no" >&5
-echo "${ECHO_T}no" >&6
-fi
-
- test -n "$ac_ct_F77" && break
-done
-
- F77=$ac_ct_F77
-fi
-
-
-# Provide some information about the compiler.
-echo "$as_me:5264:" \
- "checking for Fortran 77 compiler version" >&5
-ac_compiler=`set X $ac_compile; echo $2`
-{ (eval echo "$as_me:$LINENO: \"$ac_compiler --version </dev/null >&5\"") >&5
- (eval $ac_compiler --version </dev/null >&5) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }
-{ (eval echo "$as_me:$LINENO: \"$ac_compiler -v </dev/null >&5\"") >&5
- (eval $ac_compiler -v </dev/null >&5) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }
-{ (eval echo "$as_me:$LINENO: \"$ac_compiler -V </dev/null >&5\"") >&5
- (eval $ac_compiler -V </dev/null >&5) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }
-rm -f a.out
-
-# If we don't use `.F' as extension, the preprocessor is not run on the
-# input file. (Note that this only needs to work for GNU compilers.)
-ac_save_ext=$ac_ext
-ac_ext=F
-echo "$as_me:$LINENO: checking whether we are using the GNU Fortran 77 compiler" >&5
-echo $ECHO_N "checking whether we are using the GNU Fortran 77 compiler... $ECHO_C" >&6
-if test "${ac_cv_f77_compiler_gnu+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- cat >conftest.$ac_ext <<_ACEOF
- program main
-#ifndef __GNUC__
- choke me
-#endif
-
- end
-_ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
- (eval $ac_compile) 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } &&
- { ac_try='test -z "$ac_f77_werror_flag" || test ! -s conftest.err'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; } &&
- { ac_try='test -s conftest.$ac_objext'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
- ac_compiler_gnu=yes
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-ac_compiler_gnu=no
-fi
-rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
-ac_cv_f77_compiler_gnu=$ac_compiler_gnu
-
-fi
-echo "$as_me:$LINENO: result: $ac_cv_f77_compiler_gnu" >&5
-echo "${ECHO_T}$ac_cv_f77_compiler_gnu" >&6
-ac_ext=$ac_save_ext
-ac_test_FFLAGS=${FFLAGS+set}
-ac_save_FFLAGS=$FFLAGS
-FFLAGS=
-echo "$as_me:$LINENO: checking whether $F77 accepts -g" >&5
-echo $ECHO_N "checking whether $F77 accepts -g... $ECHO_C" >&6
-if test "${ac_cv_prog_f77_g+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- FFLAGS=-g
-cat >conftest.$ac_ext <<_ACEOF
- program main
-
- end
-_ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
- (eval $ac_compile) 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } &&
- { ac_try='test -z "$ac_f77_werror_flag" || test ! -s conftest.err'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; } &&
- { ac_try='test -s conftest.$ac_objext'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
- ac_cv_prog_f77_g=yes
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-ac_cv_prog_f77_g=no
-fi
-rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
-
-fi
-echo "$as_me:$LINENO: result: $ac_cv_prog_f77_g" >&5
-echo "${ECHO_T}$ac_cv_prog_f77_g" >&6
-if test "$ac_test_FFLAGS" = set; then
- FFLAGS=$ac_save_FFLAGS
-elif test $ac_cv_prog_f77_g = yes; then
- if test "x$ac_cv_f77_compiler_gnu" = xyes; then
- FFLAGS="-g -O2"
- else
- FFLAGS="-g"
- fi
-else
- if test "x$ac_cv_f77_compiler_gnu" = xyes; then
- FFLAGS="-O2"
- else
- FFLAGS=
- fi
-fi
-
-G77=`test $ac_compiler_gnu = yes && echo yes`
-ac_ext=c
-ac_cpp='$CPP $CPPFLAGS'
-ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
-ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
-ac_compiler_gnu=$ac_cv_c_compiler_gnu
-
-
-
-# Autoconf 2.13's AC_OBJEXT and AC_EXEEXT macros only works for C compilers!
-
-# find the maximum length of command line arguments
-echo "$as_me:$LINENO: checking the maximum length of command line arguments" >&5
-echo $ECHO_N "checking the maximum length of command line arguments... $ECHO_C" >&6
-if test "${lt_cv_sys_max_cmd_len+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- i=0
- teststring="ABCD"
-
- case $build_os in
- msdosdjgpp*)
- # On DJGPP, this test can blow up pretty badly due to problems in libc
- # (any single argument exceeding 2000 bytes causes a buffer overrun
- # during glob expansion). Even if it were fixed, the result of this
- # check would be larger than it should be.
- lt_cv_sys_max_cmd_len=12288; # 12K is about right
- ;;
-
- gnu*)
- # Under GNU Hurd, this test is not required because there is
- # no limit to the length of command line arguments.
- # Libtool will interpret -1 as no limit whatsoever
- lt_cv_sys_max_cmd_len=-1;
- ;;
-
- cygwin* | mingw*)
- # On Win9x/ME, this test blows up -- it succeeds, but takes
- # about 5 minutes as the teststring grows exponentially.
- # Worse, since 9x/ME are not pre-emptively multitasking,
- # you end up with a "frozen" computer, even though with patience
- # the test eventually succeeds (with a max line length of 256k).
- # Instead, let's just punt: use the minimum linelength reported by
- # all of the supported platforms: 8192 (on NT/2K/XP).
- lt_cv_sys_max_cmd_len=8192;
- ;;
-
- amigaos*)
- # On AmigaOS with pdksh, this test takes hours, literally.
- # So we just punt and use a minimum line length of 8192.
- lt_cv_sys_max_cmd_len=8192;
- ;;
-
- netbsd* | freebsd* | openbsd* | darwin* | dragonfly*)
- # This has been around since 386BSD, at least. Likely further.
- if test -x /sbin/sysctl; then
- lt_cv_sys_max_cmd_len=`/sbin/sysctl -n kern.argmax`
- elif test -x /usr/sbin/sysctl; then
- lt_cv_sys_max_cmd_len=`/usr/sbin/sysctl -n kern.argmax`
- else
- lt_cv_sys_max_cmd_len=65536 # usable default for all BSDs
- fi
- # And add a safety zone
- lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4`
- lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3`
- ;;
-
- interix*)
- # We know the value 262144 and hardcode it with a safety zone (like BSD)
- lt_cv_sys_max_cmd_len=196608
- ;;
-
- osf*)
- # Dr. Hans Ekkehard Plesser reports seeing a kernel panic running configure
- # due to this test when exec_disable_arg_limit is 1 on Tru64. It is not
- # nice to cause kernel panics so lets avoid the loop below.
- # First set a reasonable default.
- lt_cv_sys_max_cmd_len=16384
- #
- if test -x /sbin/sysconfig; then
- case `/sbin/sysconfig -q proc exec_disable_arg_limit` in
- *1*) lt_cv_sys_max_cmd_len=-1 ;;
- esac
- fi
- ;;
- sco3.2v5*)
- lt_cv_sys_max_cmd_len=102400
- ;;
- sysv5* | sco5v6* | sysv4.2uw2*)
- kargmax=`grep ARG_MAX /etc/conf/cf.d/stune 2>/dev/null`
- if test -n "$kargmax"; then
- lt_cv_sys_max_cmd_len=`echo $kargmax | sed 's/.*[ ]//'`
- else
- lt_cv_sys_max_cmd_len=32768
- fi
- ;;
- *)
- # If test is not a shell built-in, we'll probably end up computing a
- # maximum length that is only half of the actual maximum length, but
- # we can't tell.
- SHELL=${SHELL-${CONFIG_SHELL-/bin/sh}}
- while (test "X"`$SHELL $0 --fallback-echo "X$teststring" 2>/dev/null` \
- = "XX$teststring") >/dev/null 2>&1 &&
- new_result=`expr "X$teststring" : ".*" 2>&1` &&
- lt_cv_sys_max_cmd_len=$new_result &&
- test $i != 17 # 1/2 MB should be enough
- do
- i=`expr $i + 1`
- teststring=$teststring$teststring
- done
- teststring=
- # Add a significant safety factor because C++ compilers can tack on massive
- # amounts of additional arguments before passing them to the linker.
- # It appears as though 1/2 is a usable value.
- lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 2`
- ;;
- esac
-
-fi
-
-if test -n $lt_cv_sys_max_cmd_len ; then
- echo "$as_me:$LINENO: result: $lt_cv_sys_max_cmd_len" >&5
-echo "${ECHO_T}$lt_cv_sys_max_cmd_len" >&6
-else
- echo "$as_me:$LINENO: result: none" >&5
-echo "${ECHO_T}none" >&6
-fi
-
-
-
-
-# Check for command to grab the raw symbol name followed by C symbol from nm.
-echo "$as_me:$LINENO: checking command to parse $NM output from $compiler object" >&5
-echo $ECHO_N "checking command to parse $NM output from $compiler object... $ECHO_C" >&6
-if test "${lt_cv_sys_global_symbol_pipe+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-
-# These are sane defaults that work on at least a few old systems.
-# [They come from Ultrix. What could be older than Ultrix?!! ;)]
-
-# Character class describing NM global symbol codes.
-symcode='[BCDEGRST]'
-
-# Regexp to match symbols that can be accessed directly from C.
-sympat='\([_A-Za-z][_A-Za-z0-9]*\)'
-
-# Transform an extracted symbol line into a proper C declaration
-lt_cv_sys_global_symbol_to_cdecl="sed -n -e 's/^. .* \(.*\)$/extern int \1;/p'"
-
-# Transform an extracted symbol line into symbol name and symbol address
-lt_cv_sys_global_symbol_to_c_name_address="sed -n -e 's/^: \([^ ]*\) $/ {\\\"\1\\\", (lt_ptr) 0},/p' -e 's/^$symcode \([^ ]*\) \([^ ]*\)$/ {\"\2\", (lt_ptr) \&\2},/p'"
-
-# Define system-specific variables.
-case $host_os in
-aix*)
- symcode='[BCDT]'
- ;;
-cygwin* | mingw* | pw32*)
- symcode='[ABCDGISTW]'
- ;;
-hpux*) # Its linker distinguishes data from code symbols
- if test "$host_cpu" = ia64; then
- symcode='[ABCDEGRST]'
- fi
- lt_cv_sys_global_symbol_to_cdecl="sed -n -e 's/^T .* \(.*\)$/extern int \1();/p' -e 's/^$symcode* .* \(.*\)$/extern char \1;/p'"
- lt_cv_sys_global_symbol_to_c_name_address="sed -n -e 's/^: \([^ ]*\) $/ {\\\"\1\\\", (lt_ptr) 0},/p' -e 's/^$symcode* \([^ ]*\) \([^ ]*\)$/ {\"\2\", (lt_ptr) \&\2},/p'"
- ;;
-linux*)
- if test "$host_cpu" = ia64; then
- symcode='[ABCDGIRSTW]'
- lt_cv_sys_global_symbol_to_cdecl="sed -n -e 's/^T .* \(.*\)$/extern int \1();/p' -e 's/^$symcode* .* \(.*\)$/extern char \1;/p'"
- lt_cv_sys_global_symbol_to_c_name_address="sed -n -e 's/^: \([^ ]*\) $/ {\\\"\1\\\", (lt_ptr) 0},/p' -e 's/^$symcode* \([^ ]*\) \([^ ]*\)$/ {\"\2\", (lt_ptr) \&\2},/p'"
- fi
- ;;
-irix* | nonstopux*)
- symcode='[BCDEGRST]'
- ;;
-osf*)
- symcode='[BCDEGQRST]'
- ;;
-solaris*)
- symcode='[BDRT]'
- ;;
-sco3.2v5*)
- symcode='[DT]'
- ;;
-sysv4.2uw2*)
- symcode='[DT]'
- ;;
-sysv5* | sco5v6* | unixware* | OpenUNIX*)
- symcode='[ABDT]'
- ;;
-sysv4)
- symcode='[DFNSTU]'
- ;;
-esac
-
-# Handle CRLF in mingw tool chain
-opt_cr=
-case $build_os in
-mingw*)
- opt_cr=`echo 'x\{0,1\}' | tr x '\015'` # option cr in regexp
- ;;
-esac
-
-# If we're using GNU nm, then use its standard symbol codes.
-case `$NM -V 2>&1` in
-*GNU* | *'with BFD'*)
- symcode='[ABCDGIRSTW]' ;;
-esac
-
-# Try without a prefix undercore, then with it.
-for ac_symprfx in "" "_"; do
-
- # Transform symcode, sympat, and symprfx into a raw symbol and a C symbol.
- symxfrm="\\1 $ac_symprfx\\2 \\2"
-
- # Write the raw and C identifiers.
- lt_cv_sys_global_symbol_pipe="sed -n -e 's/^.*[ ]\($symcode$symcode*\)[ ][ ]*$ac_symprfx$sympat$opt_cr$/$symxfrm/p'"
-
- # Check to see that the pipe works correctly.
- pipe_works=no
-
- rm -f conftest*
- cat > conftest.$ac_ext <<EOF
-#ifdef __cplusplus
-extern "C" {
-#endif
-char nm_test_var;
-void nm_test_func(){}
-#ifdef __cplusplus
-}
-#endif
-int main(){nm_test_var='a';nm_test_func();return(0);}
-EOF
-
- if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
- (eval $ac_compile) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; then
- # Now try to grab the symbols.
- nlist=conftest.nm
- if { (eval echo "$as_me:$LINENO: \"$NM conftest.$ac_objext \| $lt_cv_sys_global_symbol_pipe \> $nlist\"") >&5
- (eval $NM conftest.$ac_objext \| $lt_cv_sys_global_symbol_pipe \> $nlist) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } && test -s "$nlist"; then
- # Try sorting and uniquifying the output.
- if sort "$nlist" | uniq > "$nlist"T; then
- mv -f "$nlist"T "$nlist"
- else
- rm -f "$nlist"T
- fi
-
- # Make sure that we snagged all the symbols we need.
- if grep ' nm_test_var$' "$nlist" >/dev/null; then
- if grep ' nm_test_func$' "$nlist" >/dev/null; then
- cat <<EOF > conftest.$ac_ext
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-EOF
- # Now generate the symbol file.
- eval "$lt_cv_sys_global_symbol_to_cdecl"' < "$nlist" | grep -v main >> conftest.$ac_ext'
-
- cat <<EOF >> conftest.$ac_ext
-#if defined (__STDC__) && __STDC__
-# define lt_ptr_t void *
-#else
-# define lt_ptr_t char *
-# define const
-#endif
-
-/* The mapping between symbol names and symbols. */
-const struct {
- const char *name;
- lt_ptr_t address;
-}
-lt_preloaded_symbols[] =
-{
-EOF
- $SED "s/^$symcode$symcode* \(.*\) \(.*\)$/ {\"\2\", (lt_ptr_t) \&\2},/" < "$nlist" | grep -v main >> conftest.$ac_ext
- cat <<\EOF >> conftest.$ac_ext
- {0, (lt_ptr_t) 0}
-};
-
-#ifdef __cplusplus
-}
-#endif
-EOF
- # Now try linking the two files.
- mv conftest.$ac_objext conftstm.$ac_objext
- lt_save_LIBS="$LIBS"
- lt_save_CFLAGS="$CFLAGS"
- LIBS="conftstm.$ac_objext"
- CFLAGS="$CFLAGS$lt_prog_compiler_no_builtin_flag"
- if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
- (eval $ac_link) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } && test -s conftest${ac_exeext}; then
- pipe_works=yes
- fi
- LIBS="$lt_save_LIBS"
- CFLAGS="$lt_save_CFLAGS"
- else
- echo "cannot find nm_test_func in $nlist" >&5
- fi
- else
- echo "cannot find nm_test_var in $nlist" >&5
- fi
- else
- echo "cannot run $lt_cv_sys_global_symbol_pipe" >&5
- fi
- else
- echo "$progname: failed program was:" >&5
- cat conftest.$ac_ext >&5
- fi
- rm -f conftest* conftst*
-
- # Do not use the global_symbol_pipe unless it works.
- if test "$pipe_works" = yes; then
- break
- else
- lt_cv_sys_global_symbol_pipe=
- fi
-done
-
-fi
-
-if test -z "$lt_cv_sys_global_symbol_pipe"; then
- lt_cv_sys_global_symbol_to_cdecl=
-fi
-if test -z "$lt_cv_sys_global_symbol_pipe$lt_cv_sys_global_symbol_to_cdecl"; then
- echo "$as_me:$LINENO: result: failed" >&5
-echo "${ECHO_T}failed" >&6
-else
- echo "$as_me:$LINENO: result: ok" >&5
-echo "${ECHO_T}ok" >&6
-fi
-
-echo "$as_me:$LINENO: checking for objdir" >&5
-echo $ECHO_N "checking for objdir... $ECHO_C" >&6
-if test "${lt_cv_objdir+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- rm -f .libs 2>/dev/null
-mkdir .libs 2>/dev/null
-if test -d .libs; then
- lt_cv_objdir=.libs
-else
- # MS-DOS does not allow filenames that begin with a dot.
- lt_cv_objdir=_libs
-fi
-rmdir .libs 2>/dev/null
-fi
-echo "$as_me:$LINENO: result: $lt_cv_objdir" >&5
-echo "${ECHO_T}$lt_cv_objdir" >&6
-objdir=$lt_cv_objdir
-
-
-
-
-
-case $host_os in
-aix3*)
- # AIX sometimes has problems with the GCC collect2 program. For some
- # reason, if we set the COLLECT_NAMES environment variable, the problems
- # vanish in a puff of smoke.
- if test "X${COLLECT_NAMES+set}" != Xset; then
- COLLECT_NAMES=
- export COLLECT_NAMES
- fi
- ;;
-esac
-
-# Sed substitution that helps us do robust quoting. It backslashifies
-# metacharacters that are still active within double-quoted strings.
-Xsed='sed -e 1s/^X//'
-sed_quote_subst='s/\([\\"\\`$\\\\]\)/\\\1/g'
-
-# Same as above, but do not quote variable references.
-double_quote_subst='s/\([\\"\\`\\\\]\)/\\\1/g'
-
-# Sed substitution to delay expansion of an escaped shell variable in a
-# double_quote_subst'ed string.
-delay_variable_subst='s/\\\\\\\\\\\$/\\\\\\$/g'
-
-# Sed substitution to avoid accidental globbing in evaled expressions
-no_glob_subst='s/\*/\\\*/g'
-
-# Constants:
-rm="rm -f"
-
-# Global variables:
-default_ofile=libtool
-can_build_shared=yes
-
-# All known linkers require a `.a' archive for static linking (except MSVC,
-# which needs '.lib').
-libext=a
-ltmain="$ac_aux_dir/ltmain.sh"
-ofile="$default_ofile"
-with_gnu_ld="$lt_cv_prog_gnu_ld"
-
-if test -n "$ac_tool_prefix"; then
- # Extract the first word of "${ac_tool_prefix}ar", so it can be a program name with args.
-set dummy ${ac_tool_prefix}ar; ac_word=$2
-echo "$as_me:$LINENO: checking for $ac_word" >&5
-echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
-if test "${ac_cv_prog_AR+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- if test -n "$AR"; then
- ac_cv_prog_AR="$AR" # Let the user override the test.
-else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
- IFS=$as_save_IFS
- test -z "$as_dir" && as_dir=.
- for ac_exec_ext in '' $ac_executable_extensions; do
- if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
- ac_cv_prog_AR="${ac_tool_prefix}ar"
- echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
- break 2
- fi
-done
-done
-
-fi
-fi
-AR=$ac_cv_prog_AR
-if test -n "$AR"; then
- echo "$as_me:$LINENO: result: $AR" >&5
-echo "${ECHO_T}$AR" >&6
-else
- echo "$as_me:$LINENO: result: no" >&5
-echo "${ECHO_T}no" >&6
-fi
-
-fi
-if test -z "$ac_cv_prog_AR"; then
- ac_ct_AR=$AR
- # Extract the first word of "ar", so it can be a program name with args.
-set dummy ar; ac_word=$2
-echo "$as_me:$LINENO: checking for $ac_word" >&5
-echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
-if test "${ac_cv_prog_ac_ct_AR+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- if test -n "$ac_ct_AR"; then
- ac_cv_prog_ac_ct_AR="$ac_ct_AR" # Let the user override the test.
-else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
- IFS=$as_save_IFS
- test -z "$as_dir" && as_dir=.
- for ac_exec_ext in '' $ac_executable_extensions; do
- if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
- ac_cv_prog_ac_ct_AR="ar"
- echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
- break 2
- fi
-done
-done
-
- test -z "$ac_cv_prog_ac_ct_AR" && ac_cv_prog_ac_ct_AR="false"
-fi
-fi
-ac_ct_AR=$ac_cv_prog_ac_ct_AR
-if test -n "$ac_ct_AR"; then
- echo "$as_me:$LINENO: result: $ac_ct_AR" >&5
-echo "${ECHO_T}$ac_ct_AR" >&6
-else
- echo "$as_me:$LINENO: result: no" >&5
-echo "${ECHO_T}no" >&6
-fi
-
- AR=$ac_ct_AR
-else
- AR="$ac_cv_prog_AR"
-fi
-
-if test -n "$ac_tool_prefix"; then
- # Extract the first word of "${ac_tool_prefix}ranlib", so it can be a program name with args.
-set dummy ${ac_tool_prefix}ranlib; ac_word=$2
-echo "$as_me:$LINENO: checking for $ac_word" >&5
-echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
-if test "${ac_cv_prog_RANLIB+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- if test -n "$RANLIB"; then
- ac_cv_prog_RANLIB="$RANLIB" # Let the user override the test.
-else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
- IFS=$as_save_IFS
- test -z "$as_dir" && as_dir=.
- for ac_exec_ext in '' $ac_executable_extensions; do
- if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
- ac_cv_prog_RANLIB="${ac_tool_prefix}ranlib"
- echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
- break 2
- fi
-done
-done
-
-fi
-fi
-RANLIB=$ac_cv_prog_RANLIB
-if test -n "$RANLIB"; then
- echo "$as_me:$LINENO: result: $RANLIB" >&5
-echo "${ECHO_T}$RANLIB" >&6
-else
- echo "$as_me:$LINENO: result: no" >&5
-echo "${ECHO_T}no" >&6
-fi
-
-fi
-if test -z "$ac_cv_prog_RANLIB"; then
- ac_ct_RANLIB=$RANLIB
- # Extract the first word of "ranlib", so it can be a program name with args.
-set dummy ranlib; ac_word=$2
-echo "$as_me:$LINENO: checking for $ac_word" >&5
-echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
-if test "${ac_cv_prog_ac_ct_RANLIB+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- if test -n "$ac_ct_RANLIB"; then
- ac_cv_prog_ac_ct_RANLIB="$ac_ct_RANLIB" # Let the user override the test.
-else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
- IFS=$as_save_IFS
- test -z "$as_dir" && as_dir=.
- for ac_exec_ext in '' $ac_executable_extensions; do
- if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
- ac_cv_prog_ac_ct_RANLIB="ranlib"
- echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
- break 2
- fi
-done
-done
-
- test -z "$ac_cv_prog_ac_ct_RANLIB" && ac_cv_prog_ac_ct_RANLIB=":"
-fi
-fi
-ac_ct_RANLIB=$ac_cv_prog_ac_ct_RANLIB
-if test -n "$ac_ct_RANLIB"; then
- echo "$as_me:$LINENO: result: $ac_ct_RANLIB" >&5
-echo "${ECHO_T}$ac_ct_RANLIB" >&6
-else
- echo "$as_me:$LINENO: result: no" >&5
-echo "${ECHO_T}no" >&6
-fi
-
- RANLIB=$ac_ct_RANLIB
-else
- RANLIB="$ac_cv_prog_RANLIB"
-fi
-
-if test -n "$ac_tool_prefix"; then
- # Extract the first word of "${ac_tool_prefix}strip", so it can be a program name with args.
-set dummy ${ac_tool_prefix}strip; ac_word=$2
-echo "$as_me:$LINENO: checking for $ac_word" >&5
-echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
-if test "${ac_cv_prog_STRIP+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- if test -n "$STRIP"; then
- ac_cv_prog_STRIP="$STRIP" # Let the user override the test.
-else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
- IFS=$as_save_IFS
- test -z "$as_dir" && as_dir=.
- for ac_exec_ext in '' $ac_executable_extensions; do
- if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
- ac_cv_prog_STRIP="${ac_tool_prefix}strip"
- echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
- break 2
- fi
-done
-done
-
-fi
-fi
-STRIP=$ac_cv_prog_STRIP
-if test -n "$STRIP"; then
- echo "$as_me:$LINENO: result: $STRIP" >&5
-echo "${ECHO_T}$STRIP" >&6
-else
- echo "$as_me:$LINENO: result: no" >&5
-echo "${ECHO_T}no" >&6
-fi
-
-fi
-if test -z "$ac_cv_prog_STRIP"; then
- ac_ct_STRIP=$STRIP
- # Extract the first word of "strip", so it can be a program name with args.
-set dummy strip; ac_word=$2
-echo "$as_me:$LINENO: checking for $ac_word" >&5
-echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
-if test "${ac_cv_prog_ac_ct_STRIP+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- if test -n "$ac_ct_STRIP"; then
- ac_cv_prog_ac_ct_STRIP="$ac_ct_STRIP" # Let the user override the test.
-else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
- IFS=$as_save_IFS
- test -z "$as_dir" && as_dir=.
- for ac_exec_ext in '' $ac_executable_extensions; do
- if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
- ac_cv_prog_ac_ct_STRIP="strip"
- echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
- break 2
- fi
-done
-done
-
- test -z "$ac_cv_prog_ac_ct_STRIP" && ac_cv_prog_ac_ct_STRIP=":"
-fi
-fi
-ac_ct_STRIP=$ac_cv_prog_ac_ct_STRIP
-if test -n "$ac_ct_STRIP"; then
- echo "$as_me:$LINENO: result: $ac_ct_STRIP" >&5
-echo "${ECHO_T}$ac_ct_STRIP" >&6
-else
- echo "$as_me:$LINENO: result: no" >&5
-echo "${ECHO_T}no" >&6
-fi
-
- STRIP=$ac_ct_STRIP
-else
- STRIP="$ac_cv_prog_STRIP"
-fi
-
-
-old_CC="$CC"
-old_CFLAGS="$CFLAGS"
-
-# Set sane defaults for various variables
-test -z "$AR" && AR=ar
-test -z "$AR_FLAGS" && AR_FLAGS=cru
-test -z "$AS" && AS=as
-test -z "$CC" && CC=cc
-test -z "$LTCC" && LTCC=$CC
-test -z "$LTCFLAGS" && LTCFLAGS=$CFLAGS
-test -z "$DLLTOOL" && DLLTOOL=dlltool
-test -z "$LD" && LD=ld
-test -z "$LN_S" && LN_S="ln -s"
-test -z "$MAGIC_CMD" && MAGIC_CMD=file
-test -z "$NM" && NM=nm
-test -z "$SED" && SED=sed
-test -z "$OBJDUMP" && OBJDUMP=objdump
-test -z "$RANLIB" && RANLIB=:
-test -z "$STRIP" && STRIP=:
-test -z "$ac_objext" && ac_objext=o
-
-# Determine commands to create old-style static archives.
-old_archive_cmds='$AR $AR_FLAGS $oldlib$oldobjs$old_deplibs'
-old_postinstall_cmds='chmod 644 $oldlib'
-old_postuninstall_cmds=
-
-if test -n "$RANLIB"; then
- case $host_os in
- openbsd*)
- old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB -t \$oldlib"
- ;;
- *)
- old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB \$oldlib"
- ;;
- esac
- old_archive_cmds="$old_archive_cmds~\$RANLIB \$oldlib"
-fi
-
-for cc_temp in $compiler""; do
- case $cc_temp in
- compile | *[\\/]compile | ccache | *[\\/]ccache ) ;;
- distcc | *[\\/]distcc | purify | *[\\/]purify ) ;;
- \-*) ;;
- *) break;;
- esac
-done
-cc_basename=`$echo "X$cc_temp" | $Xsed -e 's%.*/%%' -e "s%^$host_alias-%%"`
-
-
-# Only perform the check for file, if the check method requires it
-case $deplibs_check_method in
-file_magic*)
- if test "$file_magic_cmd" = '$MAGIC_CMD'; then
- echo "$as_me:$LINENO: checking for ${ac_tool_prefix}file" >&5
-echo $ECHO_N "checking for ${ac_tool_prefix}file... $ECHO_C" >&6
-if test "${lt_cv_path_MAGIC_CMD+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- case $MAGIC_CMD in
-[\\/*] | ?:[\\/]*)
- lt_cv_path_MAGIC_CMD="$MAGIC_CMD" # Let the user override the test with a path.
- ;;
-*)
- lt_save_MAGIC_CMD="$MAGIC_CMD"
- lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
- ac_dummy="/usr/bin$PATH_SEPARATOR$PATH"
- for ac_dir in $ac_dummy; do
- IFS="$lt_save_ifs"
- test -z "$ac_dir" && ac_dir=.
- if test -f $ac_dir/${ac_tool_prefix}file; then
- lt_cv_path_MAGIC_CMD="$ac_dir/${ac_tool_prefix}file"
- if test -n "$file_magic_test_file"; then
- case $deplibs_check_method in
- "file_magic "*)
- file_magic_regex=`expr "$deplibs_check_method" : "file_magic \(.*\)"`
- MAGIC_CMD="$lt_cv_path_MAGIC_CMD"
- if eval $file_magic_cmd \$file_magic_test_file 2> /dev/null |
- $EGREP "$file_magic_regex" > /dev/null; then
- :
- else
- cat <<EOF 1>&2
-
-*** Warning: the command libtool uses to detect shared libraries,
-*** $file_magic_cmd, produces output that libtool cannot recognize.
-*** The result is that libtool may fail to recognize shared libraries
-*** as such. This will affect the creation of libtool libraries that
-*** depend on shared libraries, but programs linked with such libtool
-*** libraries will work regardless of this problem. Nevertheless, you
-*** may want to report the problem to your system manager and/or to
-*** bug-libtool@gnu.org
-
-EOF
- fi ;;
- esac
- fi
- break
- fi
- done
- IFS="$lt_save_ifs"
- MAGIC_CMD="$lt_save_MAGIC_CMD"
- ;;
-esac
-fi
-
-MAGIC_CMD="$lt_cv_path_MAGIC_CMD"
-if test -n "$MAGIC_CMD"; then
- echo "$as_me:$LINENO: result: $MAGIC_CMD" >&5
-echo "${ECHO_T}$MAGIC_CMD" >&6
-else
- echo "$as_me:$LINENO: result: no" >&5
-echo "${ECHO_T}no" >&6
-fi
-
-if test -z "$lt_cv_path_MAGIC_CMD"; then
- if test -n "$ac_tool_prefix"; then
- echo "$as_me:$LINENO: checking for file" >&5
-echo $ECHO_N "checking for file... $ECHO_C" >&6
-if test "${lt_cv_path_MAGIC_CMD+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- case $MAGIC_CMD in
-[\\/*] | ?:[\\/]*)
- lt_cv_path_MAGIC_CMD="$MAGIC_CMD" # Let the user override the test with a path.
- ;;
-*)
- lt_save_MAGIC_CMD="$MAGIC_CMD"
- lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
- ac_dummy="/usr/bin$PATH_SEPARATOR$PATH"
- for ac_dir in $ac_dummy; do
- IFS="$lt_save_ifs"
- test -z "$ac_dir" && ac_dir=.
- if test -f $ac_dir/file; then
- lt_cv_path_MAGIC_CMD="$ac_dir/file"
- if test -n "$file_magic_test_file"; then
- case $deplibs_check_method in
- "file_magic "*)
- file_magic_regex=`expr "$deplibs_check_method" : "file_magic \(.*\)"`
- MAGIC_CMD="$lt_cv_path_MAGIC_CMD"
- if eval $file_magic_cmd \$file_magic_test_file 2> /dev/null |
- $EGREP "$file_magic_regex" > /dev/null; then
- :
- else
- cat <<EOF 1>&2
-
-*** Warning: the command libtool uses to detect shared libraries,
-*** $file_magic_cmd, produces output that libtool cannot recognize.
-*** The result is that libtool may fail to recognize shared libraries
-*** as such. This will affect the creation of libtool libraries that
-*** depend on shared libraries, but programs linked with such libtool
-*** libraries will work regardless of this problem. Nevertheless, you
-*** may want to report the problem to your system manager and/or to
-*** bug-libtool@gnu.org
-
-EOF
- fi ;;
- esac
- fi
- break
- fi
- done
- IFS="$lt_save_ifs"
- MAGIC_CMD="$lt_save_MAGIC_CMD"
- ;;
-esac
-fi
-
-MAGIC_CMD="$lt_cv_path_MAGIC_CMD"
-if test -n "$MAGIC_CMD"; then
- echo "$as_me:$LINENO: result: $MAGIC_CMD" >&5
-echo "${ECHO_T}$MAGIC_CMD" >&6
-else
- echo "$as_me:$LINENO: result: no" >&5
-echo "${ECHO_T}no" >&6
-fi
-
- else
- MAGIC_CMD=:
- fi
-fi
-
- fi
- ;;
-esac
-
-enable_dlopen=no
-enable_win32_dll=no
-
-# Check whether --enable-libtool-lock or --disable-libtool-lock was given.
-if test "${enable_libtool_lock+set}" = set; then
- enableval="$enable_libtool_lock"
-
-fi;
-test "x$enable_libtool_lock" != xno && enable_libtool_lock=yes
-
-
-# Check whether --with-pic or --without-pic was given.
-if test "${with_pic+set}" = set; then
- withval="$with_pic"
- pic_mode="$withval"
-else
- pic_mode=default
-fi;
-test -z "$pic_mode" && pic_mode=default
-
-# Use C for the default configuration in the libtool script
-tagname=
-lt_save_CC="$CC"
-ac_ext=c
-ac_cpp='$CPP $CPPFLAGS'
-ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
-ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
-ac_compiler_gnu=$ac_cv_c_compiler_gnu
-
-
-# Source file extension for C test sources.
-ac_ext=c
-
-# Object file extension for compiled C test sources.
-objext=o
-objext=$objext
-
-# Code to be used in simple compile tests
-lt_simple_compile_test_code="int some_variable = 0;\n"
-
-# Code to be used in simple link tests
-lt_simple_link_test_code='int main(){return(0);}\n'
-
-
-# If no C compiler was specified, use CC.
-LTCC=${LTCC-"$CC"}
-
-# If no C compiler flags were specified, use CFLAGS.
-LTCFLAGS=${LTCFLAGS-"$CFLAGS"}
-
-# Allow CC to be a program name with arguments.
-compiler=$CC
-
-
-# save warnings/boilerplate of simple test code
-ac_outfile=conftest.$ac_objext
-printf "$lt_simple_compile_test_code" >conftest.$ac_ext
-eval "$ac_compile" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err
-_lt_compiler_boilerplate=`cat conftest.err`
-$rm conftest*
-
-ac_outfile=conftest.$ac_objext
-printf "$lt_simple_link_test_code" >conftest.$ac_ext
-eval "$ac_link" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err
-_lt_linker_boilerplate=`cat conftest.err`
-$rm conftest*
-
-
-
-lt_prog_compiler_no_builtin_flag=
-
-if test "$GCC" = yes; then
- lt_prog_compiler_no_builtin_flag=' -fno-builtin'
-
-
-echo "$as_me:$LINENO: checking if $compiler supports -fno-rtti -fno-exceptions" >&5
-echo $ECHO_N "checking if $compiler supports -fno-rtti -fno-exceptions... $ECHO_C" >&6
-if test "${lt_cv_prog_compiler_rtti_exceptions+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- lt_cv_prog_compiler_rtti_exceptions=no
- ac_outfile=conftest.$ac_objext
- printf "$lt_simple_compile_test_code" > conftest.$ac_ext
- lt_compiler_flag="-fno-rtti -fno-exceptions"
- # Insert the option either (1) after the last *FLAGS variable, or
- # (2) before a word containing "conftest.", or (3) at the end.
- # Note that $ac_compile itself does not contain backslashes and begins
- # with a dollar sign (not a hyphen), so the echo should work correctly.
- # The option is referenced via a variable to avoid confusing sed.
- lt_compile=`echo "$ac_compile" | $SED \
- -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
- -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
- -e 's:$: $lt_compiler_flag:'`
- (eval echo "\"\$as_me:6325: $lt_compile\"" >&5)
- (eval "$lt_compile" 2>conftest.err)
- ac_status=$?
- cat conftest.err >&5
- echo "$as_me:6329: \$? = $ac_status" >&5
- if (exit $ac_status) && test -s "$ac_outfile"; then
- # The compiler can only warn and ignore the option if not recognized
- # So say no if there are warnings other than the usual output.
- $echo "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' >conftest.exp
- $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2
- if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then
- lt_cv_prog_compiler_rtti_exceptions=yes
- fi
- fi
- $rm conftest*
-
-fi
-echo "$as_me:$LINENO: result: $lt_cv_prog_compiler_rtti_exceptions" >&5
-echo "${ECHO_T}$lt_cv_prog_compiler_rtti_exceptions" >&6
-
-if test x"$lt_cv_prog_compiler_rtti_exceptions" = xyes; then
- lt_prog_compiler_no_builtin_flag="$lt_prog_compiler_no_builtin_flag -fno-rtti -fno-exceptions"
-else
- :
-fi
-
-fi
-
-lt_prog_compiler_wl=
-lt_prog_compiler_pic=
-lt_prog_compiler_static=
-
-echo "$as_me:$LINENO: checking for $compiler option to produce PIC" >&5
-echo $ECHO_N "checking for $compiler option to produce PIC... $ECHO_C" >&6
-
- if test "$GCC" = yes; then
- lt_prog_compiler_wl='-Wl,'
- lt_prog_compiler_static='-static'
-
- case $host_os in
- aix*)
- # All AIX code is PIC.
- if test "$host_cpu" = ia64; then
- # AIX 5 now supports IA64 processor
- lt_prog_compiler_static='-Bstatic'
- fi
- ;;
-
- amigaos*)
- # FIXME: we need at least 68020 code to build shared libraries, but
- # adding the `-m68020' flag to GCC prevents building anything better,
- # like `-m68040'.
- lt_prog_compiler_pic='-m68020 -resident32 -malways-restore-a4'
- ;;
-
- beos* | cygwin* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*)
- # PIC is the default for these OSes.
- ;;
-
- mingw* | pw32* | os2*)
- # This hack is so that the source file can tell whether it is being
- # built for inclusion in a dll (and should export symbols for example).
- lt_prog_compiler_pic='-DDLL_EXPORT'
- ;;
-
- darwin* | rhapsody*)
- # PIC is the default on this platform
- # Common symbols not allowed in MH_DYLIB files
- lt_prog_compiler_pic='-fno-common'
- ;;
-
- interix3*)
- # Interix 3.x gcc -fpic/-fPIC options generate broken code.
- # Instead, we relocate shared libraries at runtime.
- ;;
-
- msdosdjgpp*)
- # Just because we use GCC doesn't mean we suddenly get shared libraries
- # on systems that don't support them.
- lt_prog_compiler_can_build_shared=no
- enable_shared=no
- ;;
-
- sysv4*MP*)
- if test -d /usr/nec; then
- lt_prog_compiler_pic=-Kconform_pic
- fi
- ;;
-
- hpux*)
- # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but
- # not for PA HP-UX.
- case $host_cpu in
- hppa*64*|ia64*)
- # +Z the default
- ;;
- *)
- lt_prog_compiler_pic='-fPIC'
- ;;
- esac
- ;;
-
- *)
- lt_prog_compiler_pic='-fPIC'
- ;;
- esac
- else
- # PORTME Check for flag to pass linker flags through the system compiler.
- case $host_os in
- aix*)
- lt_prog_compiler_wl='-Wl,'
- if test "$host_cpu" = ia64; then
- # AIX 5 now supports IA64 processor
- lt_prog_compiler_static='-Bstatic'
- else
- lt_prog_compiler_static='-bnso -bI:/lib/syscalls.exp'
- fi
- ;;
- darwin*)
- # PIC is the default on this platform
- # Common symbols not allowed in MH_DYLIB files
- case $cc_basename in
- xlc*)
- lt_prog_compiler_pic='-qnocommon'
- lt_prog_compiler_wl='-Wl,'
- ;;
- esac
- ;;
-
- mingw* | pw32* | os2*)
- # This hack is so that the source file can tell whether it is being
- # built for inclusion in a dll (and should export symbols for example).
- lt_prog_compiler_pic='-DDLL_EXPORT'
- ;;
-
- hpux9* | hpux10* | hpux11*)
- lt_prog_compiler_wl='-Wl,'
- # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but
- # not for PA HP-UX.
- case $host_cpu in
- hppa*64*|ia64*)
- # +Z the default
- ;;
- *)
- lt_prog_compiler_pic='+Z'
- ;;
- esac
- # Is there a better lt_prog_compiler_static that works with the bundled CC?
- lt_prog_compiler_static='${wl}-a ${wl}archive'
- ;;
-
- irix5* | irix6* | nonstopux*)
- lt_prog_compiler_wl='-Wl,'
- # PIC (with -KPIC) is the default.
- lt_prog_compiler_static='-non_shared'
- ;;
-
- newsos6)
- lt_prog_compiler_pic='-KPIC'
- lt_prog_compiler_static='-Bstatic'
- ;;
-
- linux*)
- case $cc_basename in
- icc* | ecc*)
- lt_prog_compiler_wl='-Wl,'
- lt_prog_compiler_pic='-KPIC'
- lt_prog_compiler_static='-static'
- ;;
- pgcc* | pgf77* | pgf90* | pgf95*)
- # Portland Group compilers (*not* the Pentium gcc compiler,
- # which looks to be a dead project)
- lt_prog_compiler_wl='-Wl,'
- lt_prog_compiler_pic='-fpic'
- lt_prog_compiler_static='-Bstatic'
- ;;
- ccc*)
- lt_prog_compiler_wl='-Wl,'
- # All Alpha code is PIC.
- lt_prog_compiler_static='-non_shared'
- ;;
- esac
- ;;
-
- osf3* | osf4* | osf5*)
- lt_prog_compiler_wl='-Wl,'
- # All OSF/1 code is PIC.
- lt_prog_compiler_static='-non_shared'
- ;;
-
- solaris*)
- lt_prog_compiler_pic='-KPIC'
- lt_prog_compiler_static='-Bstatic'
- case $cc_basename in
- f77* | f90* | f95*)
- lt_prog_compiler_wl='-Qoption ld ';;
- *)
- lt_prog_compiler_wl='-Wl,';;
- esac
- ;;
-
- sunos4*)
- lt_prog_compiler_wl='-Qoption ld '
- lt_prog_compiler_pic='-PIC'
- lt_prog_compiler_static='-Bstatic'
- ;;
-
- sysv4 | sysv4.2uw2* | sysv4.3*)
- lt_prog_compiler_wl='-Wl,'
- lt_prog_compiler_pic='-KPIC'
- lt_prog_compiler_static='-Bstatic'
- ;;
-
- sysv4*MP*)
- if test -d /usr/nec ;then
- lt_prog_compiler_pic='-Kconform_pic'
- lt_prog_compiler_static='-Bstatic'
- fi
- ;;
-
- sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*)
- lt_prog_compiler_wl='-Wl,'
- lt_prog_compiler_pic='-KPIC'
- lt_prog_compiler_static='-Bstatic'
- ;;
-
- unicos*)
- lt_prog_compiler_wl='-Wl,'
- lt_prog_compiler_can_build_shared=no
- ;;
-
- uts4*)
- lt_prog_compiler_pic='-pic'
- lt_prog_compiler_static='-Bstatic'
- ;;
-
- *)
- lt_prog_compiler_can_build_shared=no
- ;;
- esac
- fi
-
-echo "$as_me:$LINENO: result: $lt_prog_compiler_pic" >&5
-echo "${ECHO_T}$lt_prog_compiler_pic" >&6
-
-#
-# Check to make sure the PIC flag actually works.
-#
-if test -n "$lt_prog_compiler_pic"; then
-
-echo "$as_me:$LINENO: checking if $compiler PIC flag $lt_prog_compiler_pic works" >&5
-echo $ECHO_N "checking if $compiler PIC flag $lt_prog_compiler_pic works... $ECHO_C" >&6
-if test "${lt_prog_compiler_pic_works+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- lt_prog_compiler_pic_works=no
- ac_outfile=conftest.$ac_objext
- printf "$lt_simple_compile_test_code" > conftest.$ac_ext
- lt_compiler_flag="$lt_prog_compiler_pic -DPIC"
- # Insert the option either (1) after the last *FLAGS variable, or
- # (2) before a word containing "conftest.", or (3) at the end.
- # Note that $ac_compile itself does not contain backslashes and begins
- # with a dollar sign (not a hyphen), so the echo should work correctly.
- # The option is referenced via a variable to avoid confusing sed.
- lt_compile=`echo "$ac_compile" | $SED \
- -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
- -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
- -e 's:$: $lt_compiler_flag:'`
- (eval echo "\"\$as_me:6593: $lt_compile\"" >&5)
- (eval "$lt_compile" 2>conftest.err)
- ac_status=$?
- cat conftest.err >&5
- echo "$as_me:6597: \$? = $ac_status" >&5
- if (exit $ac_status) && test -s "$ac_outfile"; then
- # The compiler can only warn and ignore the option if not recognized
- # So say no if there are warnings other than the usual output.
- $echo "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' >conftest.exp
- $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2
- if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then
- lt_prog_compiler_pic_works=yes
- fi
- fi
- $rm conftest*
-
-fi
-echo "$as_me:$LINENO: result: $lt_prog_compiler_pic_works" >&5
-echo "${ECHO_T}$lt_prog_compiler_pic_works" >&6
-
-if test x"$lt_prog_compiler_pic_works" = xyes; then
- case $lt_prog_compiler_pic in
- "" | " "*) ;;
- *) lt_prog_compiler_pic=" $lt_prog_compiler_pic" ;;
- esac
-else
- lt_prog_compiler_pic=
- lt_prog_compiler_can_build_shared=no
-fi
-
-fi
-case $host_os in
- # For platforms which do not support PIC, -DPIC is meaningless:
- *djgpp*)
- lt_prog_compiler_pic=
- ;;
- *)
- lt_prog_compiler_pic="$lt_prog_compiler_pic -DPIC"
- ;;
-esac
-
-#
-# Check to make sure the static flag actually works.
-#
-wl=$lt_prog_compiler_wl eval lt_tmp_static_flag=\"$lt_prog_compiler_static\"
-echo "$as_me:$LINENO: checking if $compiler static flag $lt_tmp_static_flag works" >&5
-echo $ECHO_N "checking if $compiler static flag $lt_tmp_static_flag works... $ECHO_C" >&6
-if test "${lt_prog_compiler_static_works+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- lt_prog_compiler_static_works=no
- save_LDFLAGS="$LDFLAGS"
- LDFLAGS="$LDFLAGS $lt_tmp_static_flag"
- printf "$lt_simple_link_test_code" > conftest.$ac_ext
- if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then
- # The linker can only warn and ignore the option if not recognized
- # So say no if there are warnings
- if test -s conftest.err; then
- # Append any errors to the config.log.
- cat conftest.err 1>&5
- $echo "X$_lt_linker_boilerplate" | $Xsed -e '/^$/d' > conftest.exp
- $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2
- if diff conftest.exp conftest.er2 >/dev/null; then
- lt_prog_compiler_static_works=yes
- fi
- else
- lt_prog_compiler_static_works=yes
- fi
- fi
- $rm conftest*
- LDFLAGS="$save_LDFLAGS"
-
-fi
-echo "$as_me:$LINENO: result: $lt_prog_compiler_static_works" >&5
-echo "${ECHO_T}$lt_prog_compiler_static_works" >&6
-
-if test x"$lt_prog_compiler_static_works" = xyes; then
- :
-else
- lt_prog_compiler_static=
-fi
-
-
-echo "$as_me:$LINENO: checking if $compiler supports -c -o file.$ac_objext" >&5
-echo $ECHO_N "checking if $compiler supports -c -o file.$ac_objext... $ECHO_C" >&6
-if test "${lt_cv_prog_compiler_c_o+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- lt_cv_prog_compiler_c_o=no
- $rm -r conftest 2>/dev/null
- mkdir conftest
- cd conftest
- mkdir out
- printf "$lt_simple_compile_test_code" > conftest.$ac_ext
-
- lt_compiler_flag="-o out/conftest2.$ac_objext"
- # Insert the option either (1) after the last *FLAGS variable, or
- # (2) before a word containing "conftest.", or (3) at the end.
- # Note that $ac_compile itself does not contain backslashes and begins
- # with a dollar sign (not a hyphen), so the echo should work correctly.
- lt_compile=`echo "$ac_compile" | $SED \
- -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
- -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
- -e 's:$: $lt_compiler_flag:'`
- (eval echo "\"\$as_me:6697: $lt_compile\"" >&5)
- (eval "$lt_compile" 2>out/conftest.err)
- ac_status=$?
- cat out/conftest.err >&5
- echo "$as_me:6701: \$? = $ac_status" >&5
- if (exit $ac_status) && test -s out/conftest2.$ac_objext
- then
- # The compiler can only warn and ignore the option if not recognized
- # So say no if there are warnings
- $echo "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' > out/conftest.exp
- $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2
- if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then
- lt_cv_prog_compiler_c_o=yes
- fi
- fi
- chmod u+w . 2>&5
- $rm conftest*
- # SGI C++ compiler will create directory out/ii_files/ for
- # template instantiation
- test -d out/ii_files && $rm out/ii_files/* && rmdir out/ii_files
- $rm out/* && rmdir out
- cd ..
- rmdir conftest
- $rm conftest*
-
-fi
-echo "$as_me:$LINENO: result: $lt_cv_prog_compiler_c_o" >&5
-echo "${ECHO_T}$lt_cv_prog_compiler_c_o" >&6
-
-
-hard_links="nottested"
-if test "$lt_cv_prog_compiler_c_o" = no && test "$need_locks" != no; then
- # do not overwrite the value of need_locks provided by the user
- echo "$as_me:$LINENO: checking if we can lock with hard links" >&5
-echo $ECHO_N "checking if we can lock with hard links... $ECHO_C" >&6
- hard_links=yes
- $rm conftest*
- ln conftest.a conftest.b 2>/dev/null && hard_links=no
- touch conftest.a
- ln conftest.a conftest.b 2>&5 || hard_links=no
- ln conftest.a conftest.b 2>/dev/null && hard_links=no
- echo "$as_me:$LINENO: result: $hard_links" >&5
-echo "${ECHO_T}$hard_links" >&6
- if test "$hard_links" = no; then
- { echo "$as_me:$LINENO: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&5
-echo "$as_me: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&2;}
- need_locks=warn
- fi
-else
- need_locks=no
-fi
-
-echo "$as_me:$LINENO: checking whether the $compiler linker ($LD) supports shared libraries" >&5
-echo $ECHO_N "checking whether the $compiler linker ($LD) supports shared libraries... $ECHO_C" >&6
-
- runpath_var=
- allow_undefined_flag=
- enable_shared_with_static_runtimes=no
- archive_cmds=
- archive_expsym_cmds=
- old_archive_From_new_cmds=
- old_archive_from_expsyms_cmds=
- export_dynamic_flag_spec=
- whole_archive_flag_spec=
- thread_safe_flag_spec=
- hardcode_libdir_flag_spec=
- hardcode_libdir_flag_spec_ld=
- hardcode_libdir_separator=
- hardcode_direct=no
- hardcode_minus_L=no
- hardcode_shlibpath_var=unsupported
- link_all_deplibs=unknown
- hardcode_automatic=no
- module_cmds=
- module_expsym_cmds=
- always_export_symbols=no
- export_symbols_cmds='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols'
- # include_expsyms should be a list of space-separated symbols to be *always*
- # included in the symbol list
- include_expsyms=
- # exclude_expsyms can be an extended regexp of symbols to exclude
- # it will be wrapped by ` (' and `)$', so one must not match beginning or
- # end of line. Example: `a|bc|.*d.*' will exclude the symbols `a' and `bc',
- # as well as any symbol that contains `d'.
- exclude_expsyms="_GLOBAL_OFFSET_TABLE_"
- # Although _GLOBAL_OFFSET_TABLE_ is a valid symbol C name, most a.out
- # platforms (ab)use it in PIC code, but their linkers get confused if
- # the symbol is explicitly referenced. Since portable code cannot
- # rely on this symbol name, it's probably fine to never include it in
- # preloaded symbol tables.
- extract_expsyms_cmds=
- # Just being paranoid about ensuring that cc_basename is set.
- for cc_temp in $compiler""; do
- case $cc_temp in
- compile | *[\\/]compile | ccache | *[\\/]ccache ) ;;
- distcc | *[\\/]distcc | purify | *[\\/]purify ) ;;
- \-*) ;;
- *) break;;
- esac
-done
-cc_basename=`$echo "X$cc_temp" | $Xsed -e 's%.*/%%' -e "s%^$host_alias-%%"`
-
- case $host_os in
- cygwin* | mingw* | pw32*)
- # FIXME: the MSVC++ port hasn't been tested in a loooong time
- # When not using gcc, we currently assume that we are using
- # Microsoft Visual C++.
- if test "$GCC" != yes; then
- with_gnu_ld=no
- fi
- ;;
- interix*)
- # we just hope/assume this is gcc and not c89 (= MSVC++)
- with_gnu_ld=yes
- ;;
- openbsd*)
- with_gnu_ld=no
- ;;
- esac
-
- ld_shlibs=yes
- if test "$with_gnu_ld" = yes; then
- # If archive_cmds runs LD, not CC, wlarc should be empty
- wlarc='${wl}'
-
- # Set some defaults for GNU ld with shared library support. These
- # are reset later if shared libraries are not supported. Putting them
- # here allows them to be overridden if necessary.
- runpath_var=LD_RUN_PATH
- hardcode_libdir_flag_spec='${wl}--rpath ${wl}$libdir'
- export_dynamic_flag_spec='${wl}--export-dynamic'
- # ancient GNU ld didn't support --whole-archive et. al.
- if $LD --help 2>&1 | grep 'no-whole-archive' > /dev/null; then
- whole_archive_flag_spec="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive'
- else
- whole_archive_flag_spec=
- fi
- supports_anon_versioning=no
- case `$LD -v 2>/dev/null` in
- *\ [01].* | *\ 2.[0-9].* | *\ 2.10.*) ;; # catch versions < 2.11
- *\ 2.11.93.0.2\ *) supports_anon_versioning=yes ;; # RH7.3 ...
- *\ 2.11.92.0.12\ *) supports_anon_versioning=yes ;; # Mandrake 8.2 ...
- *\ 2.11.*) ;; # other 2.11 versions
- *) supports_anon_versioning=yes ;;
- esac
-
- # See if GNU ld supports shared libraries.
- case $host_os in
- aix3* | aix4* | aix5*)
- # On AIX/PPC, the GNU linker is very broken
- if test "$host_cpu" != ia64; then
- ld_shlibs=no
- cat <<EOF 1>&2
-
-*** Warning: the GNU linker, at least up to release 2.9.1, is reported
-*** to be unable to reliably create shared libraries on AIX.
-*** Therefore, libtool is disabling shared libraries support. If you
-*** really care for shared libraries, you may want to modify your PATH
-*** so that a non-GNU linker is found, and then restart.
-
-EOF
- fi
- ;;
-
- amigaos*)
- archive_cmds='$rm $output_objdir/a2ixlibrary.data~$echo "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$echo "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$echo "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$echo "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)'
- hardcode_libdir_flag_spec='-L$libdir'
- hardcode_minus_L=yes
-
- # Samuel A. Falvo II <kc5tja@dolphin.openprojects.net> reports
- # that the semantics of dynamic libraries on AmigaOS, at least up
- # to version 4, is to share data among multiple programs linked
- # with the same dynamic library. Since this doesn't match the
- # behavior of shared libraries on other platforms, we can't use
- # them.
- ld_shlibs=no
- ;;
-
- beos*)
- if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
- allow_undefined_flag=unsupported
- # Joseph Beckenbach <jrb3@best.com> says some releases of gcc
- # support --undefined. This deserves some investigation. FIXME
- archive_cmds='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
- else
- ld_shlibs=no
- fi
- ;;
-
- cygwin* | mingw* | pw32*)
- # _LT_AC_TAGVAR(hardcode_libdir_flag_spec, ) is actually meaningless,
- # as there is no search path for DLLs.
- hardcode_libdir_flag_spec='-L$libdir'
- allow_undefined_flag=unsupported
- always_export_symbols=no
- enable_shared_with_static_runtimes=yes
- export_symbols_cmds='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[BCDGRS] /s/.* \([^ ]*\)/\1 DATA/'\'' | $SED -e '\''/^[AITW] /s/.* //'\'' | sort | uniq > $export_symbols'
-
- if $LD --help 2>&1 | grep 'auto-import' > /dev/null; then
- archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
- # If the export-symbols file already is a .def file (1st line
- # is EXPORTS), use it as is; otherwise, prepend...
- archive_expsym_cmds='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then
- cp $export_symbols $output_objdir/$soname.def;
- else
- echo EXPORTS > $output_objdir/$soname.def;
- cat $export_symbols >> $output_objdir/$soname.def;
- fi~
- $CC -shared $output_objdir/$soname.def $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
- else
- ld_shlibs=no
- fi
- ;;
-
- interix3*)
- hardcode_direct=no
- hardcode_shlibpath_var=no
- hardcode_libdir_flag_spec='${wl}-rpath,$libdir'
- export_dynamic_flag_spec='${wl}-E'
- # Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc.
- # Instead, shared libraries are loaded at an image base (0x10000000 by
- # default) and relocated if they conflict, which is a slow very memory
- # consuming and fragmenting process. To avoid this, we pick a random,
- # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link
- # time. Moving up from 0x10000000 also allows more sbrk(2) space.
- archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
- archive_expsym_cmds='sed "s,^,_," $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--retain-symbols-file,$output_objdir/$soname.expsym ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
- ;;
-
- linux*)
- if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
- tmp_addflag=
- case $cc_basename,$host_cpu in
- pgcc*) # Portland Group C compiler
- whole_archive_flag_spec='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}--no-whole-archive'
- tmp_addflag=' $pic_flag'
- ;;
- pgf77* | pgf90* | pgf95*) # Portland Group f77 and f90 compilers
- whole_archive_flag_spec='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}--no-whole-archive'
- tmp_addflag=' $pic_flag -Mnomain' ;;
- ecc*,ia64* | icc*,ia64*) # Intel C compiler on ia64
- tmp_addflag=' -i_dynamic' ;;
- efc*,ia64* | ifort*,ia64*) # Intel Fortran compiler on ia64
- tmp_addflag=' -i_dynamic -nofor_main' ;;
- ifc* | ifort*) # Intel Fortran compiler
- tmp_addflag=' -nofor_main' ;;
- esac
- archive_cmds='$CC -shared'"$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
-
- if test $supports_anon_versioning = yes; then
- archive_expsym_cmds='$echo "{ global:" > $output_objdir/$libname.ver~
- cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~
- $echo "local: *; };" >> $output_objdir/$libname.ver~
- $CC -shared'"$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib'
- fi
- link_all_deplibs=no
- else
- ld_shlibs=no
- fi
- ;;
-
- netbsd* | netbsdelf*-gnu | knetbsd*-gnu)
- if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then
- archive_cmds='$LD -Bshareable $libobjs $deplibs $linker_flags -o $lib'
- wlarc=
- else
- archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
- archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
- fi
- ;;
-
- solaris*)
- if $LD -v 2>&1 | grep 'BFD 2\.8' > /dev/null; then
- ld_shlibs=no
- cat <<EOF 1>&2
-
-*** Warning: The releases 2.8.* of the GNU linker cannot reliably
-*** create shared libraries on Solaris systems. Therefore, libtool
-*** is disabling shared libraries support. We urge you to upgrade GNU
-*** binutils to release 2.9.1 or newer. Another option is to modify
-*** your PATH or compiler configuration so that the native linker is
-*** used, and then restart.
-
-EOF
- elif $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
- archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
- archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
- else
- ld_shlibs=no
- fi
- ;;
-
- sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX*)
- case `$LD -v 2>&1` in
- *\ [01].* | *\ 2.[0-9].* | *\ 2.1[0-5].*)
- ld_shlibs=no
- cat <<_LT_EOF 1>&2
-
-*** Warning: Releases of the GNU linker prior to 2.16.91.0.3 can not
-*** reliably create shared libraries on SCO systems. Therefore, libtool
-*** is disabling shared libraries support. We urge you to upgrade GNU
-*** binutils to release 2.16.91.0.3 or newer. Another option is to modify
-*** your PATH or compiler configuration so that the native linker is
-*** used, and then restart.
-
-_LT_EOF
- ;;
- *)
- if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
- hardcode_libdir_flag_spec='`test -z "$SCOABSPATH" && echo ${wl}-rpath,$libdir`'
- archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib'
- archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname,\${SCOABSPATH:+${install_libdir}/}$soname,-retain-symbols-file,$export_symbols -o $lib'
- else
- ld_shlibs=no
- fi
- ;;
- esac
- ;;
-
- sunos4*)
- archive_cmds='$LD -assert pure-text -Bshareable -o $lib $libobjs $deplibs $linker_flags'
- wlarc=
- hardcode_direct=yes
- hardcode_shlibpath_var=no
- ;;
-
- *)
- if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
- archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
- archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
- else
- ld_shlibs=no
- fi
- ;;
- esac
-
- if test "$ld_shlibs" = no; then
- runpath_var=
- hardcode_libdir_flag_spec=
- export_dynamic_flag_spec=
- whole_archive_flag_spec=
- fi
- else
- # PORTME fill in a description of your system's linker (not GNU ld)
- case $host_os in
- aix3*)
- allow_undefined_flag=unsupported
- always_export_symbols=yes
- archive_expsym_cmds='$LD -o $output_objdir/$soname $libobjs $deplibs $linker_flags -bE:$export_symbols -T512 -H512 -bM:SRE~$AR $AR_FLAGS $lib $output_objdir/$soname'
- # Note: this linker hardcodes the directories in LIBPATH if there
- # are no directories specified by -L.
- hardcode_minus_L=yes
- if test "$GCC" = yes && test -z "$lt_prog_compiler_static"; then
- # Neither direct hardcoding nor static linking is supported with a
- # broken collect2.
- hardcode_direct=unsupported
- fi
- ;;
-
- aix4* | aix5*)
- if test "$host_cpu" = ia64; then
- # On IA64, the linker does run time linking by default, so we don't
- # have to do anything special.
- aix_use_runtimelinking=no
- exp_sym_flag='-Bexport'
- no_entry_flag=""
- else
- # If we're using GNU nm, then we don't want the "-C" option.
- # -C means demangle to AIX nm, but means don't demangle with GNU nm
- if $NM -V 2>&1 | grep 'GNU' > /dev/null; then
- export_symbols_cmds='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$2 == "T") || (\$2 == "D") || (\$2 == "B")) && (substr(\$3,1,1) != ".")) { print \$3 } }'\'' | sort -u > $export_symbols'
- else
- export_symbols_cmds='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\$2 == "T") || (\$2 == "D") || (\$2 == "B")) && (substr(\$3,1,1) != ".")) { print \$3 } }'\'' | sort -u > $export_symbols'
- fi
- aix_use_runtimelinking=no
-
- # Test if we are trying to use run time linking or normal
- # AIX style linking. If -brtl is somewhere in LDFLAGS, we
- # need to do runtime linking.
- case $host_os in aix4.[23]|aix4.[23].*|aix5*)
- for ld_flag in $LDFLAGS; do
- if (test $ld_flag = "-brtl" || test $ld_flag = "-Wl,-brtl"); then
- aix_use_runtimelinking=yes
- break
- fi
- done
- ;;
- esac
-
- exp_sym_flag='-bexport'
- no_entry_flag='-bnoentry'
- fi
-
- # When large executables or shared objects are built, AIX ld can
- # have problems creating the table of contents. If linking a library
- # or program results in "error TOC overflow" add -mminimal-toc to
- # CXXFLAGS/CFLAGS for g++/gcc. In the cases where that is not
- # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS.
-
- archive_cmds=''
- hardcode_direct=yes
- hardcode_libdir_separator=':'
- link_all_deplibs=yes
-
- if test "$GCC" = yes; then
- case $host_os in aix4.[012]|aix4.[012].*)
- # We only want to do this on AIX 4.2 and lower, the check
- # below for broken collect2 doesn't work under 4.3+
- collect2name=`${CC} -print-prog-name=collect2`
- if test -f "$collect2name" && \
- strings "$collect2name" | grep resolve_lib_name >/dev/null
- then
- # We have reworked collect2
- hardcode_direct=yes
- else
- # We have old collect2
- hardcode_direct=unsupported
- # It fails to find uninstalled libraries when the uninstalled
- # path is not listed in the libpath. Setting hardcode_minus_L
- # to unsupported forces relinking
- hardcode_minus_L=yes
- hardcode_libdir_flag_spec='-L$libdir'
- hardcode_libdir_separator=
- fi
- ;;
- esac
- shared_flag='-shared'
- if test "$aix_use_runtimelinking" = yes; then
- shared_flag="$shared_flag "'${wl}-G'
- fi
- else
- # not using gcc
- if test "$host_cpu" = ia64; then
- # VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release
- # chokes on -Wl,-G. The following line is correct:
- shared_flag='-G'
- else
- if test "$aix_use_runtimelinking" = yes; then
- shared_flag='${wl}-G'
- else
- shared_flag='${wl}-bM:SRE'
- fi
- fi
- fi
-
- # It seems that -bexpall does not export symbols beginning with
- # underscore (_), so it is better to generate a list of symbols to export.
- always_export_symbols=yes
- if test "$aix_use_runtimelinking" = yes; then
- # Warning - without using the other runtime loading flags (-brtl),
- # -berok will link without error, but may produce a broken library.
- allow_undefined_flag='-berok'
- # Determine the default libpath from the value encoded in an empty executable.
- cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-
-int
-main ()
-{
-
- ;
- return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
- (eval $ac_link) 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } &&
- { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; } &&
- { ac_try='test -s conftest$ac_exeext'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
-
-aix_libpath=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; }
-}'`
-# Check for a 64-bit object if we didn't find anything.
-if test -z "$aix_libpath"; then aix_libpath=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; }
-}'`; fi
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-fi
-rm -f conftest.err conftest.$ac_objext \
- conftest$ac_exeext conftest.$ac_ext
-if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
-
- hardcode_libdir_flag_spec='${wl}-blibpath:$libdir:'"$aix_libpath"
- archive_expsym_cmds="\$CC"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then echo "${wl}${allow_undefined_flag}"; else :; fi` '"\${wl}$exp_sym_flag:\$export_symbols $shared_flag"
- else
- if test "$host_cpu" = ia64; then
- hardcode_libdir_flag_spec='${wl}-R $libdir:/usr/lib:/lib'
- allow_undefined_flag="-z nodefs"
- archive_expsym_cmds="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$exp_sym_flag:\$export_symbols"
- else
- # Determine the default libpath from the value encoded in an empty executable.
- cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-
-int
-main ()
-{
-
- ;
- return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
- (eval $ac_link) 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } &&
- { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; } &&
- { ac_try='test -s conftest$ac_exeext'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
-
-aix_libpath=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; }
-}'`
-# Check for a 64-bit object if we didn't find anything.
-if test -z "$aix_libpath"; then aix_libpath=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; }
-}'`; fi
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-fi
-rm -f conftest.err conftest.$ac_objext \
- conftest$ac_exeext conftest.$ac_ext
-if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
-
- hardcode_libdir_flag_spec='${wl}-blibpath:$libdir:'"$aix_libpath"
- # Warning - without using the other run time loading flags,
- # -berok will link without error, but may produce a broken library.
- no_undefined_flag=' ${wl}-bernotok'
- allow_undefined_flag=' ${wl}-berok'
- # Exported symbols can be pulled into shared objects from archives
- whole_archive_flag_spec='$convenience'
- archive_cmds_need_lc=yes
- # This is similar to how AIX traditionally builds its shared libraries.
- archive_expsym_cmds="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs ${wl}-bnoentry $compiler_flags ${wl}-bE:$export_symbols${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname'
- fi
- fi
- ;;
-
- amigaos*)
- archive_cmds='$rm $output_objdir/a2ixlibrary.data~$echo "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$echo "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$echo "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$echo "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)'
- hardcode_libdir_flag_spec='-L$libdir'
- hardcode_minus_L=yes
- # see comment about different semantics on the GNU ld section
- ld_shlibs=no
- ;;
-
- bsdi[45]*)
- export_dynamic_flag_spec=-rdynamic
- ;;
-
- cygwin* | mingw* | pw32*)
- # When not using gcc, we currently assume that we are using
- # Microsoft Visual C++.
- # hardcode_libdir_flag_spec is actually meaningless, as there is
- # no search path for DLLs.
- hardcode_libdir_flag_spec=' '
- allow_undefined_flag=unsupported
- # Tell ltmain to make .lib files, not .a files.
- libext=lib
- # Tell ltmain to make .dll files, not .so files.
- shrext_cmds=".dll"
- # FIXME: Setting linknames here is a bad hack.
- archive_cmds='$CC -o $lib $libobjs $compiler_flags `echo "$deplibs" | $SED -e '\''s/ -lc$//'\''` -link -dll~linknames='
- # The linker will automatically build a .lib file if we build a DLL.
- old_archive_From_new_cmds='true'
- # FIXME: Should let the user specify the lib program.
- old_archive_cmds='lib /OUT:$oldlib$oldobjs$old_deplibs'
- fix_srcfile_path='`cygpath -w "$srcfile"`'
- enable_shared_with_static_runtimes=yes
- ;;
-
- darwin* | rhapsody*)
- case $host_os in
- rhapsody* | darwin1.[012])
- allow_undefined_flag='${wl}-undefined ${wl}suppress'
- ;;
- *) # Darwin 1.3 on
- if test -z ${MACOSX_DEPLOYMENT_TARGET} ; then
- allow_undefined_flag='${wl}-flat_namespace ${wl}-undefined ${wl}suppress'
- else
- case ${MACOSX_DEPLOYMENT_TARGET} in
- 10.[012])
- allow_undefined_flag='${wl}-flat_namespace ${wl}-undefined ${wl}suppress'
- ;;
- 10.*)
- allow_undefined_flag='${wl}-undefined ${wl}dynamic_lookup'
- ;;
- esac
- fi
- ;;
- esac
- archive_cmds_need_lc=no
- hardcode_direct=no
- hardcode_automatic=yes
- hardcode_shlibpath_var=unsupported
- whole_archive_flag_spec=''
- link_all_deplibs=yes
- if test "$GCC" = yes ; then
- output_verbose_link_cmd='echo'
- archive_cmds='$CC -dynamiclib $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring'
- module_cmds='$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags'
- # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin lds
- archive_expsym_cmds='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -dynamiclib $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
- module_expsym_cmds='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
- else
- case $cc_basename in
- xlc*)
- output_verbose_link_cmd='echo'
- archive_cmds='$CC -qmkshrobj $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-install_name ${wl}`echo $rpath/$soname` $verstring'
- module_cmds='$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags'
- # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin lds
- archive_expsym_cmds='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -qmkshrobj $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-install_name ${wl}$rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
- module_expsym_cmds='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
- ;;
- *)
- ld_shlibs=no
- ;;
- esac
- fi
- ;;
-
- dgux*)
- archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
- hardcode_libdir_flag_spec='-L$libdir'
- hardcode_shlibpath_var=no
- ;;
-
- freebsd1*)
- ld_shlibs=no
- ;;
-
- # FreeBSD 2.2.[012] allows us to include c++rt0.o to get C++ constructor
- # support. Future versions do this automatically, but an explicit c++rt0.o
- # does not break anything, and helps significantly (at the cost of a little
- # extra space).
- freebsd2.2*)
- archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags /usr/lib/c++rt0.o'
- hardcode_libdir_flag_spec='-R$libdir'
- hardcode_direct=yes
- hardcode_shlibpath_var=no
- ;;
-
- # Unfortunately, older versions of FreeBSD 2 do not have this feature.
- freebsd2*)
- archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags'
- hardcode_direct=yes
- hardcode_minus_L=yes
- hardcode_shlibpath_var=no
- ;;
-
- # FreeBSD 3 and greater uses gcc -shared to do shared libraries.
- freebsd* | dragonfly*)
- archive_cmds='$CC -shared -o $lib $libobjs $deplibs $compiler_flags'
- hardcode_libdir_flag_spec='-R$libdir'
- hardcode_direct=yes
- hardcode_shlibpath_var=no
- ;;
-
- # GNU/kFreeBSD uses gcc -shared to do shared libraries.
- kfreebsd*-gnu)
- archive_cmds='$CC -shared -o $lib $libobjs $deplibs $compiler_flags'
- hardcode_libdir_flag_spec='-R$libdir'
- hardcode_direct=yes
- hardcode_shlibpath_var=no
- link_all_deplibs=no
- ;;
-
- hpux9*)
- if test "$GCC" = yes; then
- archive_cmds='$rm $output_objdir/$soname~$CC -shared -fPIC ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $libobjs $deplibs $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
- else
- archive_cmds='$rm $output_objdir/$soname~$LD -b +b $install_libdir -o $output_objdir/$soname $libobjs $deplibs $linker_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
- fi
- hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir'
- hardcode_libdir_separator=:
- hardcode_direct=yes
-
- # hardcode_minus_L: Not really in the search PATH,
- # but as the default location of the library.
- hardcode_minus_L=yes
- export_dynamic_flag_spec='${wl}-E'
- ;;
-
- hpux10*)
- if test "$GCC" = yes -a "$with_gnu_ld" = no; then
- archive_cmds='$CC -shared -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
- else
- archive_cmds='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags'
- fi
- if test "$with_gnu_ld" = no; then
- hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir'
- hardcode_libdir_separator=:
-
- hardcode_direct=yes
- export_dynamic_flag_spec='${wl}-E'
-
- # hardcode_minus_L: Not really in the search PATH,
- # but as the default location of the library.
- hardcode_minus_L=yes
- fi
- ;;
-
- hpux11*)
- if test "$GCC" = yes -a "$with_gnu_ld" = no; then
- case $host_cpu in
- hppa*64*)
- archive_cmds='$CC -shared ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
- ;;
- ia64*)
- archive_cmds='$CC -shared ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags'
- ;;
- *)
- archive_cmds='$CC -shared -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
- ;;
- esac
- else
- case $host_cpu in
- hppa*64*)
- archive_cmds='$CC -b ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
- ;;
- ia64*)
- archive_cmds='$CC -b ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags'
- ;;
- *)
- archive_cmds='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
- ;;
- esac
- fi
- if test "$with_gnu_ld" = no; then
- hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir'
- hardcode_libdir_separator=:
-
- case $host_cpu in
- hppa*64*|ia64*)
- hardcode_libdir_flag_spec_ld='+b $libdir'
- hardcode_direct=no
- hardcode_shlibpath_var=no
- ;;
- *)
- hardcode_direct=yes
- export_dynamic_flag_spec='${wl}-E'
-
- # hardcode_minus_L: Not really in the search PATH,
- # but as the default location of the library.
- hardcode_minus_L=yes
- ;;
- esac
- fi
- ;;
-
- irix5* | irix6* | nonstopux*)
- if test "$GCC" = yes; then
- archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
- else
- archive_cmds='$LD -shared $libobjs $deplibs $linker_flags -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib'
- hardcode_libdir_flag_spec_ld='-rpath $libdir'
- fi
- hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
- hardcode_libdir_separator=:
- link_all_deplibs=yes
- ;;
-
- netbsd* | netbsdelf*-gnu | knetbsd*-gnu)
- if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then
- archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' # a.out
- else
- archive_cmds='$LD -shared -o $lib $libobjs $deplibs $linker_flags' # ELF
- fi
- hardcode_libdir_flag_spec='-R$libdir'
- hardcode_direct=yes
- hardcode_shlibpath_var=no
- ;;
-
- newsos6)
- archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
- hardcode_direct=yes
- hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
- hardcode_libdir_separator=:
- hardcode_shlibpath_var=no
- ;;
-
- openbsd*)
- hardcode_direct=yes
- hardcode_shlibpath_var=no
- if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
- archive_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags'
- archive_expsym_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-retain-symbols-file,$export_symbols'
- hardcode_libdir_flag_spec='${wl}-rpath,$libdir'
- export_dynamic_flag_spec='${wl}-E'
- else
- case $host_os in
- openbsd[01].* | openbsd2.[0-7] | openbsd2.[0-7].*)
- archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags'
- hardcode_libdir_flag_spec='-R$libdir'
- ;;
- *)
- archive_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags'
- hardcode_libdir_flag_spec='${wl}-rpath,$libdir'
- ;;
- esac
- fi
- ;;
-
- os2*)
- hardcode_libdir_flag_spec='-L$libdir'
- hardcode_minus_L=yes
- allow_undefined_flag=unsupported
- archive_cmds='$echo "LIBRARY $libname INITINSTANCE" > $output_objdir/$libname.def~$echo "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~$echo DATA >> $output_objdir/$libname.def~$echo " SINGLE NONSHARED" >> $output_objdir/$libname.def~$echo EXPORTS >> $output_objdir/$libname.def~emxexp $libobjs >> $output_objdir/$libname.def~$CC -Zdll -Zcrtdll -o $lib $libobjs $deplibs $compiler_flags $output_objdir/$libname.def'
- old_archive_From_new_cmds='emximp -o $output_objdir/$libname.a $output_objdir/$libname.def'
- ;;
-
- osf3*)
- if test "$GCC" = yes; then
- allow_undefined_flag=' ${wl}-expect_unresolved ${wl}\*'
- archive_cmds='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
- else
- allow_undefined_flag=' -expect_unresolved \*'
- archive_cmds='$LD -shared${allow_undefined_flag} $libobjs $deplibs $linker_flags -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib'
- fi
- hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
- hardcode_libdir_separator=:
- ;;
-
- osf4* | osf5*) # as osf3* with the addition of -msym flag
- if test "$GCC" = yes; then
- allow_undefined_flag=' ${wl}-expect_unresolved ${wl}\*'
- archive_cmds='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
- hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
- else
- allow_undefined_flag=' -expect_unresolved \*'
- archive_cmds='$LD -shared${allow_undefined_flag} $libobjs $deplibs $linker_flags -msym -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib'
- archive_expsym_cmds='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done; echo "-hidden">> $lib.exp~
- $LD -shared${allow_undefined_flag} -input $lib.exp $linker_flags $libobjs $deplibs -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib~$rm $lib.exp'
-
- # Both c and cxx compiler support -rpath directly
- hardcode_libdir_flag_spec='-rpath $libdir'
- fi
- hardcode_libdir_separator=:
- ;;
-
- solaris*)
- no_undefined_flag=' -z text'
- if test "$GCC" = yes; then
- wlarc='${wl}'
- archive_cmds='$CC -shared ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
- archive_expsym_cmds='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~
- $CC -shared ${wl}-M ${wl}$lib.exp ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags~$rm $lib.exp'
- else
- wlarc=''
- archive_cmds='$LD -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $linker_flags'
- archive_expsym_cmds='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~
- $LD -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linker_flags~$rm $lib.exp'
- fi
- hardcode_libdir_flag_spec='-R$libdir'
- hardcode_shlibpath_var=no
- case $host_os in
- solaris2.[0-5] | solaris2.[0-5].*) ;;
- *)
- # The compiler driver will combine linker options so we
- # cannot just pass the convience library names through
- # without $wl, iff we do not link with $LD.
- # Luckily, gcc supports the same syntax we need for Sun Studio.
- # Supported since Solaris 2.6 (maybe 2.5.1?)
- case $wlarc in
- '')
- whole_archive_flag_spec='-z allextract$convenience -z defaultextract' ;;
- *)
- whole_archive_flag_spec='${wl}-z ${wl}allextract`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}-z ${wl}defaultextract' ;;
- esac ;;
- esac
- link_all_deplibs=yes
- ;;
-
- sunos4*)
- if test "x$host_vendor" = xsequent; then
- # Use $CC to link under sequent, because it throws in some extra .o
- # files that make .init and .fini sections work.
- archive_cmds='$CC -G ${wl}-h $soname -o $lib $libobjs $deplibs $compiler_flags'
- else
- archive_cmds='$LD -assert pure-text -Bstatic -o $lib $libobjs $deplibs $linker_flags'
- fi
- hardcode_libdir_flag_spec='-L$libdir'
- hardcode_direct=yes
- hardcode_minus_L=yes
- hardcode_shlibpath_var=no
- ;;
-
- sysv4)
- case $host_vendor in
- sni)
- archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
- hardcode_direct=yes # is this really true???
- ;;
- siemens)
- ## LD is ld it makes a PLAMLIB
- ## CC just makes a GrossModule.
- archive_cmds='$LD -G -o $lib $libobjs $deplibs $linker_flags'
- reload_cmds='$CC -r -o $output$reload_objs'
- hardcode_direct=no
- ;;
- motorola)
- archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
- hardcode_direct=no #Motorola manual says yes, but my tests say they lie
- ;;
- esac
- runpath_var='LD_RUN_PATH'
- hardcode_shlibpath_var=no
- ;;
-
- sysv4.3*)
- archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
- hardcode_shlibpath_var=no
- export_dynamic_flag_spec='-Bexport'
- ;;
-
- sysv4*MP*)
- if test -d /usr/nec; then
- archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
- hardcode_shlibpath_var=no
- runpath_var=LD_RUN_PATH
- hardcode_runpath_var=yes
- ld_shlibs=yes
- fi
- ;;
-
- sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[01].[10]* | unixware7*)
- no_undefined_flag='${wl}-z,text'
- archive_cmds_need_lc=no
- hardcode_shlibpath_var=no
- runpath_var='LD_RUN_PATH'
-
- if test "$GCC" = yes; then
- archive_cmds='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
- archive_expsym_cmds='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
- else
- archive_cmds='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
- archive_expsym_cmds='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
- fi
- ;;
-
- sysv5* | sco3.2v5* | sco5v6*)
- # Note: We can NOT use -z defs as we might desire, because we do not
- # link with -lc, and that would cause any symbols used from libc to
- # always be unresolved, which means just about no library would
- # ever link correctly. If we're not using GNU ld we use -z text
- # though, which does catch some bad symbols but isn't as heavy-handed
- # as -z defs.
- no_undefined_flag='${wl}-z,text'
- allow_undefined_flag='${wl}-z,nodefs'
- archive_cmds_need_lc=no
- hardcode_shlibpath_var=no
- hardcode_libdir_flag_spec='`test -z "$SCOABSPATH" && echo ${wl}-R,$libdir`'
- hardcode_libdir_separator=':'
- link_all_deplibs=yes
- export_dynamic_flag_spec='${wl}-Bexport'
- runpath_var='LD_RUN_PATH'
-
- if test "$GCC" = yes; then
- archive_cmds='$CC -shared ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags'
- archive_expsym_cmds='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags'
- else
- archive_cmds='$CC -G ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags'
- archive_expsym_cmds='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags'
- fi
- ;;
-
- uts4*)
- archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
- hardcode_libdir_flag_spec='-L$libdir'
- hardcode_shlibpath_var=no
- ;;
-
- *)
- ld_shlibs=no
- ;;
- esac
- fi
-
-echo "$as_me:$LINENO: result: $ld_shlibs" >&5
-echo "${ECHO_T}$ld_shlibs" >&6
-test "$ld_shlibs" = no && can_build_shared=no
-
-#
-# Do we need to explicitly link libc?
-#
-case "x$archive_cmds_need_lc" in
-x|xyes)
- # Assume -lc should be added
- archive_cmds_need_lc=yes
-
- if test "$enable_shared" = yes && test "$GCC" = yes; then
- case $archive_cmds in
- *'~'*)
- # FIXME: we may have to deal with multi-command sequences.
- ;;
- '$CC '*)
- # Test whether the compiler implicitly links with -lc since on some
- # systems, -lgcc has to come before -lc. If gcc already passes -lc
- # to ld, don't add -lc before -lgcc.
- echo "$as_me:$LINENO: checking whether -lc should be explicitly linked in" >&5
-echo $ECHO_N "checking whether -lc should be explicitly linked in... $ECHO_C" >&6
- $rm conftest*
- printf "$lt_simple_compile_test_code" > conftest.$ac_ext
-
- if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
- (eval $ac_compile) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } 2>conftest.err; then
- soname=conftest
- lib=conftest
- libobjs=conftest.$ac_objext
- deplibs=
- wl=$lt_prog_compiler_wl
- pic_flag=$lt_prog_compiler_pic
- compiler_flags=-v
- linker_flags=-v
- verstring=
- output_objdir=.
- libname=conftest
- lt_save_allow_undefined_flag=$allow_undefined_flag
- allow_undefined_flag=
- if { (eval echo "$as_me:$LINENO: \"$archive_cmds 2\>\&1 \| grep \" -lc \" \>/dev/null 2\>\&1\"") >&5
- (eval $archive_cmds 2\>\&1 \| grep \" -lc \" \>/dev/null 2\>\&1) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }
- then
- archive_cmds_need_lc=no
- else
- archive_cmds_need_lc=yes
- fi
- allow_undefined_flag=$lt_save_allow_undefined_flag
- else
- cat conftest.err 1>&5
- fi
- $rm conftest*
- echo "$as_me:$LINENO: result: $archive_cmds_need_lc" >&5
-echo "${ECHO_T}$archive_cmds_need_lc" >&6
- ;;
- esac
- fi
- ;;
-esac
-
-echo "$as_me:$LINENO: checking dynamic linker characteristics" >&5
-echo $ECHO_N "checking dynamic linker characteristics... $ECHO_C" >&6
-library_names_spec=
-libname_spec='lib$name'
-soname_spec=
-shrext_cmds=".so"
-postinstall_cmds=
-postuninstall_cmds=
-finish_cmds=
-finish_eval=
-shlibpath_var=
-shlibpath_overrides_runpath=unknown
-version_type=none
-dynamic_linker="$host_os ld.so"
-sys_lib_dlsearch_path_spec="/lib /usr/lib"
-if test "$GCC" = yes; then
- sys_lib_search_path_spec=`$CC -print-search-dirs | grep "^libraries:" | $SED -e "s/^libraries://" -e "s,=/,/,g"`
- if echo "$sys_lib_search_path_spec" | grep ';' >/dev/null ; then
- # if the path contains ";" then we assume it to be the separator
- # otherwise default to the standard path separator (i.e. ":") - it is
- # assumed that no part of a normal pathname contains ";" but that should
- # okay in the real world where ";" in dirpaths is itself problematic.
- sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'`
- else
- sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"`
- fi
-else
- sys_lib_search_path_spec="/lib /usr/lib /usr/local/lib"
-fi
-need_lib_prefix=unknown
-hardcode_into_libs=no
-
-# when you set need_version to no, make sure it does not cause -set_version
-# flags to be left without arguments
-need_version=unknown
-
-case $host_os in
-aix3*)
- version_type=linux
- library_names_spec='${libname}${release}${shared_ext}$versuffix $libname.a'
- shlibpath_var=LIBPATH
-
- # AIX 3 has no versioning support, so we append a major version to the name.
- soname_spec='${libname}${release}${shared_ext}$major'
- ;;
-
-aix4* | aix5*)
- version_type=linux
- need_lib_prefix=no
- need_version=no
- hardcode_into_libs=yes
- if test "$host_cpu" = ia64; then
- # AIX 5 supports IA64
- library_names_spec='${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext}$versuffix $libname${shared_ext}'
- shlibpath_var=LD_LIBRARY_PATH
- else
- # With GCC up to 2.95.x, collect2 would create an import file
- # for dependence libraries. The import file would start with
- # the line `#! .'. This would cause the generated library to
- # depend on `.', always an invalid library. This was fixed in
- # development snapshots of GCC prior to 3.0.
- case $host_os in
- aix4 | aix4.[01] | aix4.[01].*)
- if { echo '#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 97)'
- echo ' yes '
- echo '#endif'; } | ${CC} -E - | grep yes > /dev/null; then
- :
- else
- can_build_shared=no
- fi
- ;;
- esac
- # AIX (on Power*) has no versioning support, so currently we can not hardcode correct
- # soname into executable. Probably we can add versioning support to
- # collect2, so additional links can be useful in future.
- if test "$aix_use_runtimelinking" = yes; then
- # If using run time linking (on AIX 4.2 or later) use lib<name>.so
- # instead of lib<name>.a to let people know that these are not
- # typical AIX shared libraries.
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
- else
- # We preserve .a as extension for shared libraries through AIX4.2
- # and later when we are not doing run time linking.
- library_names_spec='${libname}${release}.a $libname.a'
- soname_spec='${libname}${release}${shared_ext}$major'
- fi
- shlibpath_var=LIBPATH
- fi
- ;;
-
-amigaos*)
- library_names_spec='$libname.ixlibrary $libname.a'
- # Create ${libname}_ixlibrary.a entries in /sys/libs.
- finish_eval='for lib in `ls $libdir/*.ixlibrary 2>/dev/null`; do libname=`$echo "X$lib" | $Xsed -e '\''s%^.*/\([^/]*\)\.ixlibrary$%\1%'\''`; test $rm /sys/libs/${libname}_ixlibrary.a; $show "cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a"; cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a || exit 1; done'
- ;;
-
-beos*)
- library_names_spec='${libname}${shared_ext}'
- dynamic_linker="$host_os ld.so"
- shlibpath_var=LIBRARY_PATH
- ;;
-
-bsdi[45]*)
- version_type=linux
- need_version=no
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
- soname_spec='${libname}${release}${shared_ext}$major'
- finish_cmds='PATH="\$PATH:/sbin" ldconfig $libdir'
- shlibpath_var=LD_LIBRARY_PATH
- sys_lib_search_path_spec="/shlib /usr/lib /usr/X11/lib /usr/contrib/lib /lib /usr/local/lib"
- sys_lib_dlsearch_path_spec="/shlib /usr/lib /usr/local/lib"
- # the default ld.so.conf also contains /usr/contrib/lib and
- # /usr/X11R6/lib (/usr/X11 is a link to /usr/X11R6), but let us allow
- # libtool to hard-code these into programs
- ;;
-
-cygwin* | mingw* | pw32*)
- version_type=windows
- shrext_cmds=".dll"
- need_version=no
- need_lib_prefix=no
-
- case $GCC,$host_os in
- yes,cygwin* | yes,mingw* | yes,pw32*)
- library_names_spec='$libname.dll.a'
- # DLL is installed to $(libdir)/../bin by postinstall_cmds
- postinstall_cmds='base_file=`basename \${file}`~
- dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i;echo \$dlname'\''`~
- dldir=$destdir/`dirname \$dlpath`~
- test -d \$dldir || mkdir -p \$dldir~
- $install_prog $dir/$dlname \$dldir/$dlname~
- chmod a+x \$dldir/$dlname'
- postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~
- dlpath=$dir/\$dldll~
- $rm \$dlpath'
- shlibpath_overrides_runpath=yes
-
- case $host_os in
- cygwin*)
- # Cygwin DLLs use 'cyg' prefix rather than 'lib'
- soname_spec='`echo ${libname} | sed -e 's/^lib/cyg/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}'
- sys_lib_search_path_spec="/usr/lib /lib/w32api /lib /usr/local/lib"
- ;;
- mingw*)
- # MinGW DLLs use traditional 'lib' prefix
- soname_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}'
- sys_lib_search_path_spec=`$CC -print-search-dirs | grep "^libraries:" | $SED -e "s/^libraries://" -e "s,=/,/,g"`
- if echo "$sys_lib_search_path_spec" | grep ';[c-zC-Z]:/' >/dev/null; then
- # It is most probably a Windows format PATH printed by
- # mingw gcc, but we are running on Cygwin. Gcc prints its search
- # path with ; separators, and with drive letters. We can handle the
- # drive letters (cygwin fileutils understands them), so leave them,
- # especially as we might pass files found there to a mingw objdump,
- # which wouldn't understand a cygwinified path. Ahh.
- sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'`
- else
- sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"`
- fi
- ;;
- pw32*)
- # pw32 DLLs use 'pw' prefix rather than 'lib'
- library_names_spec='`echo ${libname} | sed -e 's/^lib/pw/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}'
- ;;
- esac
- ;;
-
- *)
- library_names_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext} $libname.lib'
- ;;
- esac
- dynamic_linker='Win32 ld.exe'
- # FIXME: first we should search . and the directory the executable is in
- shlibpath_var=PATH
- ;;
-
-darwin* | rhapsody*)
- dynamic_linker="$host_os dyld"
- version_type=darwin
- need_lib_prefix=no
- need_version=no
- library_names_spec='${libname}${release}${versuffix}$shared_ext ${libname}${release}${major}$shared_ext ${libname}$shared_ext'
- soname_spec='${libname}${release}${major}$shared_ext'
- shlibpath_overrides_runpath=yes
- shlibpath_var=DYLD_LIBRARY_PATH
- shrext_cmds='`test .$module = .yes && echo .so || echo .dylib`'
- # Apple's gcc prints 'gcc -print-search-dirs' doesn't operate the same.
- if test "$GCC" = yes; then
- sys_lib_search_path_spec=`$CC -print-search-dirs | tr "\n" "$PATH_SEPARATOR" | sed -e 's/libraries:/@libraries:/' | tr "@" "\n" | grep "^libraries:" | sed -e "s/^libraries://" -e "s,=/,/,g" -e "s,$PATH_SEPARATOR, ,g" -e "s,.*,& /lib /usr/lib /usr/local/lib,g"`
- else
- sys_lib_search_path_spec='/lib /usr/lib /usr/local/lib'
- fi
- sys_lib_dlsearch_path_spec='/usr/local/lib /lib /usr/lib'
- ;;
-
-dgux*)
- version_type=linux
- need_lib_prefix=no
- need_version=no
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname$shared_ext'
- soname_spec='${libname}${release}${shared_ext}$major'
- shlibpath_var=LD_LIBRARY_PATH
- ;;
-
-freebsd1*)
- dynamic_linker=no
- ;;
-
-kfreebsd*-gnu)
- version_type=linux
- need_lib_prefix=no
- need_version=no
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
- soname_spec='${libname}${release}${shared_ext}$major'
- shlibpath_var=LD_LIBRARY_PATH
- shlibpath_overrides_runpath=no
- hardcode_into_libs=yes
- dynamic_linker='GNU ld.so'
- ;;
-
-freebsd* | dragonfly*)
- # DragonFly does not have aout. When/if they implement a new
- # versioning mechanism, adjust this.
- if test -x /usr/bin/objformat; then
- objformat=`/usr/bin/objformat`
- else
- case $host_os in
- freebsd[123]*) objformat=aout ;;
- *) objformat=elf ;;
- esac
- fi
- version_type=freebsd-$objformat
- case $version_type in
- freebsd-elf*)
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}'
- need_version=no
- need_lib_prefix=no
- ;;
- freebsd-*)
- library_names_spec='${libname}${release}${shared_ext}$versuffix $libname${shared_ext}$versuffix'
- need_version=yes
- ;;
- esac
- shlibpath_var=LD_LIBRARY_PATH
- case $host_os in
- freebsd2*)
- shlibpath_overrides_runpath=yes
- ;;
- freebsd3.[01]* | freebsdelf3.[01]*)
- shlibpath_overrides_runpath=yes
- hardcode_into_libs=yes
- ;;
- freebsd3.[2-9]* | freebsdelf3.[2-9]* | \
- freebsd4.[0-5] | freebsdelf4.[0-5] | freebsd4.1.1 | freebsdelf4.1.1)
- shlibpath_overrides_runpath=no
- hardcode_into_libs=yes
- ;;
- freebsd*) # from 4.6 on
- shlibpath_overrides_runpath=yes
- hardcode_into_libs=yes
- ;;
- esac
- ;;
-
-gnu*)
- version_type=linux
- need_lib_prefix=no
- need_version=no
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}'
- soname_spec='${libname}${release}${shared_ext}$major'
- shlibpath_var=LD_LIBRARY_PATH
- hardcode_into_libs=yes
- ;;
-
-hpux9* | hpux10* | hpux11*)
- # Give a soname corresponding to the major version so that dld.sl refuses to
- # link against other versions.
- version_type=sunos
- need_lib_prefix=no
- need_version=no
- case $host_cpu in
- ia64*)
- shrext_cmds='.so'
- hardcode_into_libs=yes
- dynamic_linker="$host_os dld.so"
- shlibpath_var=LD_LIBRARY_PATH
- shlibpath_overrides_runpath=yes # Unless +noenvvar is specified.
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
- soname_spec='${libname}${release}${shared_ext}$major'
- if test "X$HPUX_IA64_MODE" = X32; then
- sys_lib_search_path_spec="/usr/lib/hpux32 /usr/local/lib/hpux32 /usr/local/lib"
- else
- sys_lib_search_path_spec="/usr/lib/hpux64 /usr/local/lib/hpux64"
- fi
- sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec
- ;;
- hppa*64*)
- shrext_cmds='.sl'
- hardcode_into_libs=yes
- dynamic_linker="$host_os dld.sl"
- shlibpath_var=LD_LIBRARY_PATH # How should we handle SHLIB_PATH
- shlibpath_overrides_runpath=yes # Unless +noenvvar is specified.
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
- soname_spec='${libname}${release}${shared_ext}$major'
- sys_lib_search_path_spec="/usr/lib/pa20_64 /usr/ccs/lib/pa20_64"
- sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec
- ;;
- *)
- shrext_cmds='.sl'
- dynamic_linker="$host_os dld.sl"
- shlibpath_var=SHLIB_PATH
- shlibpath_overrides_runpath=no # +s is required to enable SHLIB_PATH
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
- soname_spec='${libname}${release}${shared_ext}$major'
- ;;
- esac
- # HP-UX runs *really* slowly unless shared libraries are mode 555.
- postinstall_cmds='chmod 555 $lib'
- ;;
-
-interix3*)
- version_type=linux
- need_lib_prefix=no
- need_version=no
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
- soname_spec='${libname}${release}${shared_ext}$major'
- dynamic_linker='Interix 3.x ld.so.1 (PE, like ELF)'
- shlibpath_var=LD_LIBRARY_PATH
- shlibpath_overrides_runpath=no
- hardcode_into_libs=yes
- ;;
-
-irix5* | irix6* | nonstopux*)
- case $host_os in
- nonstopux*) version_type=nonstopux ;;
- *)
- if test "$lt_cv_prog_gnu_ld" = yes; then
- version_type=linux
- else
- version_type=irix
- fi ;;
- esac
- need_lib_prefix=no
- need_version=no
- soname_spec='${libname}${release}${shared_ext}$major'
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext} $libname${shared_ext}'
- case $host_os in
- irix5* | nonstopux*)
- libsuff= shlibsuff=
- ;;
- *)
- case $LD in # libtool.m4 will add one of these switches to LD
- *-32|*"-32 "|*-melf32bsmip|*"-melf32bsmip ")
- libsuff= shlibsuff= libmagic=32-bit;;
- *-n32|*"-n32 "|*-melf32bmipn32|*"-melf32bmipn32 ")
- libsuff=32 shlibsuff=N32 libmagic=N32;;
- *-64|*"-64 "|*-melf64bmip|*"-melf64bmip ")
- libsuff=64 shlibsuff=64 libmagic=64-bit;;
- *) libsuff= shlibsuff= libmagic=never-match;;
- esac
- ;;
- esac
- shlibpath_var=LD_LIBRARY${shlibsuff}_PATH
- shlibpath_overrides_runpath=no
- sys_lib_search_path_spec="/usr/lib${libsuff} /lib${libsuff} /usr/local/lib${libsuff}"
- sys_lib_dlsearch_path_spec="/usr/lib${libsuff} /lib${libsuff}"
- hardcode_into_libs=yes
- ;;
-
-# No shared lib support for Linux oldld, aout, or coff.
-linux*oldld* | linux*aout* | linux*coff*)
- dynamic_linker=no
- ;;
-
-# This must be Linux ELF.
-linux*)
- version_type=linux
- need_lib_prefix=no
- need_version=no
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
- soname_spec='${libname}${release}${shared_ext}$major'
- finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir'
- shlibpath_var=LD_LIBRARY_PATH
- shlibpath_overrides_runpath=no
- # This implies no fast_install, which is unacceptable.
- # Some rework will be needed to allow for fast_install
- # before this can be enabled.
- hardcode_into_libs=yes
-
- # Append ld.so.conf contents to the search path
- if test -f /etc/ld.so.conf; then
- lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s", \$2)); skip = 1; } { if (!skip) print \$0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;s/[:, ]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;/^$/d' | tr '\n' ' '`
- sys_lib_dlsearch_path_spec="/lib /usr/lib $lt_ld_extra"
- fi
-
- # We used to test for /lib/ld.so.1 and disable shared libraries on
- # powerpc, because MkLinux only supported shared libraries with the
- # GNU dynamic linker. Since this was broken with cross compilers,
- # most powerpc-linux boxes support dynamic linking these days and
- # people can always --disable-shared, the test was removed, and we
- # assume the GNU/Linux dynamic linker is in use.
- dynamic_linker='GNU/Linux ld.so'
- ;;
-
-netbsdelf*-gnu)
- version_type=linux
- need_lib_prefix=no
- need_version=no
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
- soname_spec='${libname}${release}${shared_ext}$major'
- shlibpath_var=LD_LIBRARY_PATH
- shlibpath_overrides_runpath=no
- hardcode_into_libs=yes
- dynamic_linker='NetBSD ld.elf_so'
- ;;
-
-knetbsd*-gnu)
- version_type=linux
- need_lib_prefix=no
- need_version=no
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
- soname_spec='${libname}${release}${shared_ext}$major'
- shlibpath_var=LD_LIBRARY_PATH
- shlibpath_overrides_runpath=no
- hardcode_into_libs=yes
- dynamic_linker='GNU ld.so'
- ;;
-
-netbsd*)
- version_type=sunos
- need_lib_prefix=no
- need_version=no
- if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
- finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir'
- dynamic_linker='NetBSD (a.out) ld.so'
- else
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
- soname_spec='${libname}${release}${shared_ext}$major'
- dynamic_linker='NetBSD ld.elf_so'
- fi
- shlibpath_var=LD_LIBRARY_PATH
- shlibpath_overrides_runpath=yes
- hardcode_into_libs=yes
- ;;
-
-newsos6)
- version_type=linux
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
- shlibpath_var=LD_LIBRARY_PATH
- shlibpath_overrides_runpath=yes
- ;;
-
-nto-qnx*)
- version_type=linux
- need_lib_prefix=no
- need_version=no
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
- soname_spec='${libname}${release}${shared_ext}$major'
- shlibpath_var=LD_LIBRARY_PATH
- shlibpath_overrides_runpath=yes
- ;;
-
-openbsd*)
- version_type=sunos
- sys_lib_dlsearch_path_spec="/usr/lib"
- need_lib_prefix=no
- # Some older versions of OpenBSD (3.3 at least) *do* need versioned libs.
- case $host_os in
- openbsd3.3 | openbsd3.3.*) need_version=yes ;;
- *) need_version=no ;;
- esac
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
- finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir'
- shlibpath_var=LD_LIBRARY_PATH
- if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
- case $host_os in
- openbsd2.[89] | openbsd2.[89].*)
- shlibpath_overrides_runpath=no
- ;;
- *)
- shlibpath_overrides_runpath=yes
- ;;
- esac
- else
- shlibpath_overrides_runpath=yes
- fi
- ;;
-
-os2*)
- libname_spec='$name'
- shrext_cmds=".dll"
- need_lib_prefix=no
- library_names_spec='$libname${shared_ext} $libname.a'
- dynamic_linker='OS/2 ld.exe'
- shlibpath_var=LIBPATH
- ;;
-
-osf3* | osf4* | osf5*)
- version_type=osf
- need_lib_prefix=no
- need_version=no
- soname_spec='${libname}${release}${shared_ext}$major'
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
- shlibpath_var=LD_LIBRARY_PATH
- sys_lib_search_path_spec="/usr/shlib /usr/ccs/lib /usr/lib/cmplrs/cc /usr/lib /usr/local/lib /var/shlib"
- sys_lib_dlsearch_path_spec="$sys_lib_search_path_spec"
- ;;
-
-solaris*)
- version_type=linux
- need_lib_prefix=no
- need_version=no
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
- soname_spec='${libname}${release}${shared_ext}$major'
- shlibpath_var=LD_LIBRARY_PATH
- shlibpath_overrides_runpath=yes
- hardcode_into_libs=yes
- # ldd complains unless libraries are executable
- postinstall_cmds='chmod +x $lib'
- ;;
-
-sunos4*)
- version_type=sunos
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
- finish_cmds='PATH="\$PATH:/usr/etc" ldconfig $libdir'
- shlibpath_var=LD_LIBRARY_PATH
- shlibpath_overrides_runpath=yes
- if test "$with_gnu_ld" = yes; then
- need_lib_prefix=no
- fi
- need_version=yes
- ;;
-
-sysv4 | sysv4.3*)
- version_type=linux
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
- soname_spec='${libname}${release}${shared_ext}$major'
- shlibpath_var=LD_LIBRARY_PATH
- case $host_vendor in
- sni)
- shlibpath_overrides_runpath=no
- need_lib_prefix=no
- export_dynamic_flag_spec='${wl}-Blargedynsym'
- runpath_var=LD_RUN_PATH
- ;;
- siemens)
- need_lib_prefix=no
- ;;
- motorola)
- need_lib_prefix=no
- need_version=no
- shlibpath_overrides_runpath=no
- sys_lib_search_path_spec='/lib /usr/lib /usr/ccs/lib'
- ;;
- esac
- ;;
-
-sysv4*MP*)
- if test -d /usr/nec ;then
- version_type=linux
- library_names_spec='$libname${shared_ext}.$versuffix $libname${shared_ext}.$major $libname${shared_ext}'
- soname_spec='$libname${shared_ext}.$major'
- shlibpath_var=LD_LIBRARY_PATH
- fi
- ;;
-
-sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*)
- version_type=freebsd-elf
- need_lib_prefix=no
- need_version=no
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}'
- soname_spec='${libname}${release}${shared_ext}$major'
- shlibpath_var=LD_LIBRARY_PATH
- hardcode_into_libs=yes
- if test "$with_gnu_ld" = yes; then
- sys_lib_search_path_spec='/usr/local/lib /usr/gnu/lib /usr/ccs/lib /usr/lib /lib'
- shlibpath_overrides_runpath=no
- else
- sys_lib_search_path_spec='/usr/ccs/lib /usr/lib'
- shlibpath_overrides_runpath=yes
- case $host_os in
- sco3.2v5*)
- sys_lib_search_path_spec="$sys_lib_search_path_spec /lib"
- ;;
- esac
- fi
- sys_lib_dlsearch_path_spec='/usr/lib'
- ;;
-
-uts4*)
- version_type=linux
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
- soname_spec='${libname}${release}${shared_ext}$major'
- shlibpath_var=LD_LIBRARY_PATH
- ;;
-
-*)
- dynamic_linker=no
- ;;
-esac
-echo "$as_me:$LINENO: result: $dynamic_linker" >&5
-echo "${ECHO_T}$dynamic_linker" >&6
-test "$dynamic_linker" = no && can_build_shared=no
-
-variables_saved_for_relink="PATH $shlibpath_var $runpath_var"
-if test "$GCC" = yes; then
- variables_saved_for_relink="$variables_saved_for_relink GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH"
-fi
-
-echo "$as_me:$LINENO: checking how to hardcode library paths into programs" >&5
-echo $ECHO_N "checking how to hardcode library paths into programs... $ECHO_C" >&6
-hardcode_action=
-if test -n "$hardcode_libdir_flag_spec" || \
- test -n "$runpath_var" || \
- test "X$hardcode_automatic" = "Xyes" ; then
-
- # We can hardcode non-existant directories.
- if test "$hardcode_direct" != no &&
- # If the only mechanism to avoid hardcoding is shlibpath_var, we
- # have to relink, otherwise we might link with an installed library
- # when we should be linking with a yet-to-be-installed one
- ## test "$_LT_AC_TAGVAR(hardcode_shlibpath_var, )" != no &&
- test "$hardcode_minus_L" != no; then
- # Linking always hardcodes the temporary library directory.
- hardcode_action=relink
- else
- # We can link without hardcoding, and we can hardcode nonexisting dirs.
- hardcode_action=immediate
- fi
-else
- # We cannot hardcode anything, or else we can only hardcode existing
- # directories.
- hardcode_action=unsupported
-fi
-echo "$as_me:$LINENO: result: $hardcode_action" >&5
-echo "${ECHO_T}$hardcode_action" >&6
-
-if test "$hardcode_action" = relink; then
- # Fast installation is not supported
- enable_fast_install=no
-elif test "$shlibpath_overrides_runpath" = yes ||
- test "$enable_shared" = no; then
- # Fast installation is not necessary
- enable_fast_install=needless
-fi
-
-striplib=
-old_striplib=
-echo "$as_me:$LINENO: checking whether stripping libraries is possible" >&5
-echo $ECHO_N "checking whether stripping libraries is possible... $ECHO_C" >&6
-if test -n "$STRIP" && $STRIP -V 2>&1 | grep "GNU strip" >/dev/null; then
- test -z "$old_striplib" && old_striplib="$STRIP --strip-debug"
- test -z "$striplib" && striplib="$STRIP --strip-unneeded"
- echo "$as_me:$LINENO: result: yes" >&5
-echo "${ECHO_T}yes" >&6
-else
-# FIXME - insert some real tests, host_os isn't really good enough
- case $host_os in
- darwin*)
- if test -n "$STRIP" ; then
- striplib="$STRIP -x"
- echo "$as_me:$LINENO: result: yes" >&5
-echo "${ECHO_T}yes" >&6
- else
- echo "$as_me:$LINENO: result: no" >&5
-echo "${ECHO_T}no" >&6
-fi
- ;;
- *)
- echo "$as_me:$LINENO: result: no" >&5
-echo "${ECHO_T}no" >&6
- ;;
- esac
-fi
-
-if test "x$enable_dlopen" != xyes; then
- enable_dlopen=unknown
- enable_dlopen_self=unknown
- enable_dlopen_self_static=unknown
-else
- lt_cv_dlopen=no
- lt_cv_dlopen_libs=
-
- case $host_os in
- beos*)
- lt_cv_dlopen="load_add_on"
- lt_cv_dlopen_libs=
- lt_cv_dlopen_self=yes
- ;;
-
- mingw* | pw32*)
- lt_cv_dlopen="LoadLibrary"
- lt_cv_dlopen_libs=
- ;;
-
- cygwin*)
- lt_cv_dlopen="dlopen"
- lt_cv_dlopen_libs=
- ;;
-
- darwin*)
- # if libdl is installed we need to link against it
- echo "$as_me:$LINENO: checking for dlopen in -ldl" >&5
-echo $ECHO_N "checking for dlopen in -ldl... $ECHO_C" >&6
-if test "${ac_cv_lib_dl_dlopen+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- ac_check_lib_save_LIBS=$LIBS
-LIBS="-ldl $LIBS"
-cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-
-/* Override any gcc2 internal prototype to avoid an error. */
-#ifdef __cplusplus
-extern "C"
-#endif
-/* We use char because int might match the return type of a gcc2
- builtin and then its argument prototype would still apply. */
-char dlopen ();
-int
-main ()
-{
-dlopen ();
- ;
- return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
- (eval $ac_link) 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } &&
- { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; } &&
- { ac_try='test -s conftest$ac_exeext'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
- ac_cv_lib_dl_dlopen=yes
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-ac_cv_lib_dl_dlopen=no
-fi
-rm -f conftest.err conftest.$ac_objext \
- conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
-fi
-echo "$as_me:$LINENO: result: $ac_cv_lib_dl_dlopen" >&5
-echo "${ECHO_T}$ac_cv_lib_dl_dlopen" >&6
-if test $ac_cv_lib_dl_dlopen = yes; then
- lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl"
-else
-
- lt_cv_dlopen="dyld"
- lt_cv_dlopen_libs=
- lt_cv_dlopen_self=yes
-
-fi
-
- ;;
-
- *)
- echo "$as_me:$LINENO: checking for shl_load" >&5
-echo $ECHO_N "checking for shl_load... $ECHO_C" >&6
-if test "${ac_cv_func_shl_load+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-/* Define shl_load to an innocuous variant, in case <limits.h> declares shl_load.
- For example, HP-UX 11i <limits.h> declares gettimeofday. */
-#define shl_load innocuous_shl_load
-
-/* System header to define __stub macros and hopefully few prototypes,
- which can conflict with char shl_load (); below.
- Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
- <limits.h> exists even on freestanding compilers. */
-
-#ifdef __STDC__
-# include <limits.h>
-#else
-# include <assert.h>
-#endif
-
-#undef shl_load
-
-/* Override any gcc2 internal prototype to avoid an error. */
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-/* We use char because int might match the return type of a gcc2
- builtin and then its argument prototype would still apply. */
-char shl_load ();
-/* The GNU C library defines this for functions which it implements
- to always fail with ENOSYS. Some functions are actually named
- something starting with __ and the normal name is an alias. */
-#if defined (__stub_shl_load) || defined (__stub___shl_load)
-choke me
-#else
-char (*f) () = shl_load;
-#endif
-#ifdef __cplusplus
-}
-#endif
-
-int
-main ()
-{
-return f != shl_load;
- ;
- return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
- (eval $ac_link) 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } &&
- { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; } &&
- { ac_try='test -s conftest$ac_exeext'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
- ac_cv_func_shl_load=yes
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-ac_cv_func_shl_load=no
-fi
-rm -f conftest.err conftest.$ac_objext \
- conftest$ac_exeext conftest.$ac_ext
-fi
-echo "$as_me:$LINENO: result: $ac_cv_func_shl_load" >&5
-echo "${ECHO_T}$ac_cv_func_shl_load" >&6
-if test $ac_cv_func_shl_load = yes; then
- lt_cv_dlopen="shl_load"
-else
- echo "$as_me:$LINENO: checking for shl_load in -ldld" >&5
-echo $ECHO_N "checking for shl_load in -ldld... $ECHO_C" >&6
-if test "${ac_cv_lib_dld_shl_load+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- ac_check_lib_save_LIBS=$LIBS
-LIBS="-ldld $LIBS"
-cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-
-/* Override any gcc2 internal prototype to avoid an error. */
-#ifdef __cplusplus
-extern "C"
-#endif
-/* We use char because int might match the return type of a gcc2
- builtin and then its argument prototype would still apply. */
-char shl_load ();
-int
-main ()
-{
-shl_load ();
- ;
- return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
- (eval $ac_link) 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } &&
- { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; } &&
- { ac_try='test -s conftest$ac_exeext'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
- ac_cv_lib_dld_shl_load=yes
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-ac_cv_lib_dld_shl_load=no
-fi
-rm -f conftest.err conftest.$ac_objext \
- conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
-fi
-echo "$as_me:$LINENO: result: $ac_cv_lib_dld_shl_load" >&5
-echo "${ECHO_T}$ac_cv_lib_dld_shl_load" >&6
-if test $ac_cv_lib_dld_shl_load = yes; then
- lt_cv_dlopen="shl_load" lt_cv_dlopen_libs="-dld"
-else
- echo "$as_me:$LINENO: checking for dlopen" >&5
-echo $ECHO_N "checking for dlopen... $ECHO_C" >&6
-if test "${ac_cv_func_dlopen+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-/* Define dlopen to an innocuous variant, in case <limits.h> declares dlopen.
- For example, HP-UX 11i <limits.h> declares gettimeofday. */
-#define dlopen innocuous_dlopen
-
-/* System header to define __stub macros and hopefully few prototypes,
- which can conflict with char dlopen (); below.
- Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
- <limits.h> exists even on freestanding compilers. */
-
-#ifdef __STDC__
-# include <limits.h>
-#else
-# include <assert.h>
-#endif
-
-#undef dlopen
-
-/* Override any gcc2 internal prototype to avoid an error. */
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-/* We use char because int might match the return type of a gcc2
- builtin and then its argument prototype would still apply. */
-char dlopen ();
-/* The GNU C library defines this for functions which it implements
- to always fail with ENOSYS. Some functions are actually named
- something starting with __ and the normal name is an alias. */
-#if defined (__stub_dlopen) || defined (__stub___dlopen)
-choke me
-#else
-char (*f) () = dlopen;
-#endif
-#ifdef __cplusplus
-}
-#endif
-
-int
-main ()
-{
-return f != dlopen;
- ;
- return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
- (eval $ac_link) 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } &&
- { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; } &&
- { ac_try='test -s conftest$ac_exeext'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
- ac_cv_func_dlopen=yes
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-ac_cv_func_dlopen=no
-fi
-rm -f conftest.err conftest.$ac_objext \
- conftest$ac_exeext conftest.$ac_ext
-fi
-echo "$as_me:$LINENO: result: $ac_cv_func_dlopen" >&5
-echo "${ECHO_T}$ac_cv_func_dlopen" >&6
-if test $ac_cv_func_dlopen = yes; then
- lt_cv_dlopen="dlopen"
-else
- echo "$as_me:$LINENO: checking for dlopen in -ldl" >&5
-echo $ECHO_N "checking for dlopen in -ldl... $ECHO_C" >&6
-if test "${ac_cv_lib_dl_dlopen+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- ac_check_lib_save_LIBS=$LIBS
-LIBS="-ldl $LIBS"
-cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-
-/* Override any gcc2 internal prototype to avoid an error. */
-#ifdef __cplusplus
-extern "C"
-#endif
-/* We use char because int might match the return type of a gcc2
- builtin and then its argument prototype would still apply. */
-char dlopen ();
-int
-main ()
-{
-dlopen ();
- ;
- return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
- (eval $ac_link) 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } &&
- { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; } &&
- { ac_try='test -s conftest$ac_exeext'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
- ac_cv_lib_dl_dlopen=yes
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-ac_cv_lib_dl_dlopen=no
-fi
-rm -f conftest.err conftest.$ac_objext \
- conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
-fi
-echo "$as_me:$LINENO: result: $ac_cv_lib_dl_dlopen" >&5
-echo "${ECHO_T}$ac_cv_lib_dl_dlopen" >&6
-if test $ac_cv_lib_dl_dlopen = yes; then
- lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl"
-else
- echo "$as_me:$LINENO: checking for dlopen in -lsvld" >&5
-echo $ECHO_N "checking for dlopen in -lsvld... $ECHO_C" >&6
-if test "${ac_cv_lib_svld_dlopen+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- ac_check_lib_save_LIBS=$LIBS
-LIBS="-lsvld $LIBS"
-cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-
-/* Override any gcc2 internal prototype to avoid an error. */
-#ifdef __cplusplus
-extern "C"
-#endif
-/* We use char because int might match the return type of a gcc2
- builtin and then its argument prototype would still apply. */
-char dlopen ();
-int
-main ()
-{
-dlopen ();
- ;
- return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
- (eval $ac_link) 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } &&
- { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; } &&
- { ac_try='test -s conftest$ac_exeext'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
- ac_cv_lib_svld_dlopen=yes
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-ac_cv_lib_svld_dlopen=no
-fi
-rm -f conftest.err conftest.$ac_objext \
- conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
-fi
-echo "$as_me:$LINENO: result: $ac_cv_lib_svld_dlopen" >&5
-echo "${ECHO_T}$ac_cv_lib_svld_dlopen" >&6
-if test $ac_cv_lib_svld_dlopen = yes; then
- lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-lsvld"
-else
- echo "$as_me:$LINENO: checking for dld_link in -ldld" >&5
-echo $ECHO_N "checking for dld_link in -ldld... $ECHO_C" >&6
-if test "${ac_cv_lib_dld_dld_link+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- ac_check_lib_save_LIBS=$LIBS
-LIBS="-ldld $LIBS"
-cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-
-/* Override any gcc2 internal prototype to avoid an error. */
-#ifdef __cplusplus
-extern "C"
-#endif
-/* We use char because int might match the return type of a gcc2
- builtin and then its argument prototype would still apply. */
-char dld_link ();
-int
-main ()
-{
-dld_link ();
- ;
- return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
- (eval $ac_link) 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } &&
- { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; } &&
- { ac_try='test -s conftest$ac_exeext'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
- ac_cv_lib_dld_dld_link=yes
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-ac_cv_lib_dld_dld_link=no
-fi
-rm -f conftest.err conftest.$ac_objext \
- conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
-fi
-echo "$as_me:$LINENO: result: $ac_cv_lib_dld_dld_link" >&5
-echo "${ECHO_T}$ac_cv_lib_dld_dld_link" >&6
-if test $ac_cv_lib_dld_dld_link = yes; then
- lt_cv_dlopen="dld_link" lt_cv_dlopen_libs="-dld"
-fi
-
-
-fi
-
-
-fi
-
-
-fi
-
-
-fi
-
-
-fi
-
- ;;
- esac
-
- if test "x$lt_cv_dlopen" != xno; then
- enable_dlopen=yes
- else
- enable_dlopen=no
- fi
-
- case $lt_cv_dlopen in
- dlopen)
- save_CPPFLAGS="$CPPFLAGS"
- test "x$ac_cv_header_dlfcn_h" = xyes && CPPFLAGS="$CPPFLAGS -DHAVE_DLFCN_H"
-
- save_LDFLAGS="$LDFLAGS"
- wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $export_dynamic_flag_spec\"
-
- save_LIBS="$LIBS"
- LIBS="$lt_cv_dlopen_libs $LIBS"
-
- echo "$as_me:$LINENO: checking whether a program can dlopen itself" >&5
-echo $ECHO_N "checking whether a program can dlopen itself... $ECHO_C" >&6
-if test "${lt_cv_dlopen_self+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- if test "$cross_compiling" = yes; then :
- lt_cv_dlopen_self=cross
-else
- lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
- lt_status=$lt_dlunknown
- cat > conftest.$ac_ext <<EOF
-#line 9055 "configure"
-#include "confdefs.h"
-
-#if HAVE_DLFCN_H
-#include <dlfcn.h>
-#endif
-
-#include <stdio.h>
-
-#ifdef RTLD_GLOBAL
-# define LT_DLGLOBAL RTLD_GLOBAL
-#else
-# ifdef DL_GLOBAL
-# define LT_DLGLOBAL DL_GLOBAL
-# else
-# define LT_DLGLOBAL 0
-# endif
-#endif
-
-/* We may have to define LT_DLLAZY_OR_NOW in the command line if we
- find out it does not work in some platform. */
-#ifndef LT_DLLAZY_OR_NOW
-# ifdef RTLD_LAZY
-# define LT_DLLAZY_OR_NOW RTLD_LAZY
-# else
-# ifdef DL_LAZY
-# define LT_DLLAZY_OR_NOW DL_LAZY
-# else
-# ifdef RTLD_NOW
-# define LT_DLLAZY_OR_NOW RTLD_NOW
-# else
-# ifdef DL_NOW
-# define LT_DLLAZY_OR_NOW DL_NOW
-# else
-# define LT_DLLAZY_OR_NOW 0
-# endif
-# endif
-# endif
-# endif
-#endif
-
-#ifdef __cplusplus
-extern "C" void exit (int);
-#endif
-
-void fnord() { int i=42;}
-int main ()
-{
- void *self = dlopen (0, LT_DLGLOBAL|LT_DLLAZY_OR_NOW);
- int status = $lt_dlunknown;
-
- if (self)
- {
- if (dlsym (self,"fnord")) status = $lt_dlno_uscore;
- else if (dlsym( self,"_fnord")) status = $lt_dlneed_uscore;
- /* dlclose (self); */
- }
- else
- puts (dlerror ());
-
- exit (status);
-}
-EOF
- if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
- (eval $ac_link) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } && test -s conftest${ac_exeext} 2>/dev/null; then
- (./conftest; exit; ) >&5 2>/dev/null
- lt_status=$?
- case x$lt_status in
- x$lt_dlno_uscore) lt_cv_dlopen_self=yes ;;
- x$lt_dlneed_uscore) lt_cv_dlopen_self=yes ;;
- x$lt_dlunknown|x*) lt_cv_dlopen_self=no ;;
- esac
- else :
- # compilation failed
- lt_cv_dlopen_self=no
- fi
-fi
-rm -fr conftest*
-
-
-fi
-echo "$as_me:$LINENO: result: $lt_cv_dlopen_self" >&5
-echo "${ECHO_T}$lt_cv_dlopen_self" >&6
-
- if test "x$lt_cv_dlopen_self" = xyes; then
- wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $lt_prog_compiler_static\"
- echo "$as_me:$LINENO: checking whether a statically linked program can dlopen itself" >&5
-echo $ECHO_N "checking whether a statically linked program can dlopen itself... $ECHO_C" >&6
-if test "${lt_cv_dlopen_self_static+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- if test "$cross_compiling" = yes; then :
- lt_cv_dlopen_self_static=cross
-else
- lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
- lt_status=$lt_dlunknown
- cat > conftest.$ac_ext <<EOF
-#line 9155 "configure"
-#include "confdefs.h"
-
-#if HAVE_DLFCN_H
-#include <dlfcn.h>
-#endif
-
-#include <stdio.h>
-
-#ifdef RTLD_GLOBAL
-# define LT_DLGLOBAL RTLD_GLOBAL
-#else
-# ifdef DL_GLOBAL
-# define LT_DLGLOBAL DL_GLOBAL
-# else
-# define LT_DLGLOBAL 0
-# endif
-#endif
-
-/* We may have to define LT_DLLAZY_OR_NOW in the command line if we
- find out it does not work in some platform. */
-#ifndef LT_DLLAZY_OR_NOW
-# ifdef RTLD_LAZY
-# define LT_DLLAZY_OR_NOW RTLD_LAZY
-# else
-# ifdef DL_LAZY
-# define LT_DLLAZY_OR_NOW DL_LAZY
-# else
-# ifdef RTLD_NOW
-# define LT_DLLAZY_OR_NOW RTLD_NOW
-# else
-# ifdef DL_NOW
-# define LT_DLLAZY_OR_NOW DL_NOW
-# else
-# define LT_DLLAZY_OR_NOW 0
-# endif
-# endif
-# endif
-# endif
-#endif
-
-#ifdef __cplusplus
-extern "C" void exit (int);
-#endif
-
-void fnord() { int i=42;}
-int main ()
-{
- void *self = dlopen (0, LT_DLGLOBAL|LT_DLLAZY_OR_NOW);
- int status = $lt_dlunknown;
-
- if (self)
- {
- if (dlsym (self,"fnord")) status = $lt_dlno_uscore;
- else if (dlsym( self,"_fnord")) status = $lt_dlneed_uscore;
- /* dlclose (self); */
- }
- else
- puts (dlerror ());
-
- exit (status);
-}
-EOF
- if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
- (eval $ac_link) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } && test -s conftest${ac_exeext} 2>/dev/null; then
- (./conftest; exit; ) >&5 2>/dev/null
- lt_status=$?
- case x$lt_status in
- x$lt_dlno_uscore) lt_cv_dlopen_self_static=yes ;;
- x$lt_dlneed_uscore) lt_cv_dlopen_self_static=yes ;;
- x$lt_dlunknown|x*) lt_cv_dlopen_self_static=no ;;
- esac
- else :
- # compilation failed
- lt_cv_dlopen_self_static=no
- fi
-fi
-rm -fr conftest*
-
-
-fi
-echo "$as_me:$LINENO: result: $lt_cv_dlopen_self_static" >&5
-echo "${ECHO_T}$lt_cv_dlopen_self_static" >&6
- fi
-
- CPPFLAGS="$save_CPPFLAGS"
- LDFLAGS="$save_LDFLAGS"
- LIBS="$save_LIBS"
- ;;
- esac
-
- case $lt_cv_dlopen_self in
- yes|no) enable_dlopen_self=$lt_cv_dlopen_self ;;
- *) enable_dlopen_self=unknown ;;
- esac
-
- case $lt_cv_dlopen_self_static in
- yes|no) enable_dlopen_self_static=$lt_cv_dlopen_self_static ;;
- *) enable_dlopen_self_static=unknown ;;
- esac
-fi
-
-
-# Report which library types will actually be built
-echo "$as_me:$LINENO: checking if libtool supports shared libraries" >&5
-echo $ECHO_N "checking if libtool supports shared libraries... $ECHO_C" >&6
-echo "$as_me:$LINENO: result: $can_build_shared" >&5
-echo "${ECHO_T}$can_build_shared" >&6
-
-echo "$as_me:$LINENO: checking whether to build shared libraries" >&5
-echo $ECHO_N "checking whether to build shared libraries... $ECHO_C" >&6
-test "$can_build_shared" = "no" && enable_shared=no
-
-# On AIX, shared libraries and static libraries use the same namespace, and
-# are all built from PIC.
-case $host_os in
-aix3*)
- test "$enable_shared" = yes && enable_static=no
- if test -n "$RANLIB"; then
- archive_cmds="$archive_cmds~\$RANLIB \$lib"
- postinstall_cmds='$RANLIB $lib'
- fi
- ;;
-
-aix4* | aix5*)
- if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then
- test "$enable_shared" = yes && enable_static=no
- fi
- ;;
-esac
-echo "$as_me:$LINENO: result: $enable_shared" >&5
-echo "${ECHO_T}$enable_shared" >&6
-
-echo "$as_me:$LINENO: checking whether to build static libraries" >&5
-echo $ECHO_N "checking whether to build static libraries... $ECHO_C" >&6
-# Make sure either enable_shared or enable_static is yes.
-test "$enable_shared" = yes || enable_static=yes
-echo "$as_me:$LINENO: result: $enable_static" >&5
-echo "${ECHO_T}$enable_static" >&6
-
-# The else clause should only fire when bootstrapping the
-# libtool distribution, otherwise you forgot to ship ltmain.sh
-# with your package, and you will get complaints that there are
-# no rules to generate ltmain.sh.
-if test -f "$ltmain"; then
- # See if we are running on zsh, and set the options which allow our commands through
- # without removal of \ escapes.
- if test -n "${ZSH_VERSION+set}" ; then
- setopt NO_GLOB_SUBST
- fi
- # Now quote all the things that may contain metacharacters while being
- # careful not to overquote the AC_SUBSTed values. We take copies of the
- # variables and quote the copies for generation of the libtool script.
- for var in echo old_CC old_CFLAGS AR AR_FLAGS EGREP RANLIB LN_S LTCC LTCFLAGS NM \
- SED SHELL STRIP \
- libname_spec library_names_spec soname_spec extract_expsyms_cmds \
- old_striplib striplib file_magic_cmd finish_cmds finish_eval \
- deplibs_check_method reload_flag reload_cmds need_locks \
- lt_cv_sys_global_symbol_pipe lt_cv_sys_global_symbol_to_cdecl \
- lt_cv_sys_global_symbol_to_c_name_address \
- sys_lib_search_path_spec sys_lib_dlsearch_path_spec \
- old_postinstall_cmds old_postuninstall_cmds \
- compiler \
- CC \
- LD \
- lt_prog_compiler_wl \
- lt_prog_compiler_pic \
- lt_prog_compiler_static \
- lt_prog_compiler_no_builtin_flag \
- export_dynamic_flag_spec \
- thread_safe_flag_spec \
- whole_archive_flag_spec \
- enable_shared_with_static_runtimes \
- old_archive_cmds \
- old_archive_from_new_cmds \
- predep_objects \
- postdep_objects \
- predeps \
- postdeps \
- compiler_lib_search_path \
- archive_cmds \
- archive_expsym_cmds \
- postinstall_cmds \
- postuninstall_cmds \
- old_archive_from_expsyms_cmds \
- allow_undefined_flag \
- no_undefined_flag \
- export_symbols_cmds \
- hardcode_libdir_flag_spec \
- hardcode_libdir_flag_spec_ld \
- hardcode_libdir_separator \
- hardcode_automatic \
- module_cmds \
- module_expsym_cmds \
- lt_cv_prog_compiler_c_o \
- exclude_expsyms \
- include_expsyms; do
-
- case $var in
- old_archive_cmds | \
- old_archive_from_new_cmds | \
- archive_cmds | \
- archive_expsym_cmds | \
- module_cmds | \
- module_expsym_cmds | \
- old_archive_from_expsyms_cmds | \
- export_symbols_cmds | \
- extract_expsyms_cmds | reload_cmds | finish_cmds | \
- postinstall_cmds | postuninstall_cmds | \
- old_postinstall_cmds | old_postuninstall_cmds | \
- sys_lib_search_path_spec | sys_lib_dlsearch_path_spec)
- # Double-quote double-evaled strings.
- eval "lt_$var=\\\"\`\$echo \"X\$$var\" | \$Xsed -e \"\$double_quote_subst\" -e \"\$sed_quote_subst\" -e \"\$delay_variable_subst\"\`\\\""
- ;;
- *)
- eval "lt_$var=\\\"\`\$echo \"X\$$var\" | \$Xsed -e \"\$sed_quote_subst\"\`\\\""
- ;;
- esac
- done
-
- case $lt_echo in
- *'\$0 --fallback-echo"')
- lt_echo=`$echo "X$lt_echo" | $Xsed -e 's/\\\\\\\$0 --fallback-echo"$/$0 --fallback-echo"/'`
- ;;
- esac
-
-cfgfile="${ofile}T"
- trap "$rm \"$cfgfile\"; exit 1" 1 2 15
- $rm -f "$cfgfile"
- { echo "$as_me:$LINENO: creating $ofile" >&5
-echo "$as_me: creating $ofile" >&6;}
-
- cat <<__EOF__ >> "$cfgfile"
-#! $SHELL
-
-# `$echo "$cfgfile" | sed 's%^.*/%%'` - Provide generalized library-building support services.
-# Generated automatically by $PROGRAM (GNU $PACKAGE $VERSION$TIMESTAMP)
-# NOTE: Changes made to this file will be lost: look at ltmain.sh.
-#
-# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001
-# Free Software Foundation, Inc.
-#
-# This file is part of GNU Libtool:
-# Originally by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-#
-# This program 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 this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-#
-# As a special exception to the GNU General Public License, if you
-# distribute this file as part of a program that contains a
-# configuration script generated by Autoconf, you may include it under
-# the same distribution terms that you use for the rest of that program.
-
-# A sed program that does not truncate output.
-SED=$lt_SED
-
-# Sed that helps us avoid accidentally triggering echo(1) options like -n.
-Xsed="$SED -e 1s/^X//"
-
-# The HP-UX ksh and POSIX shell print the target directory to stdout
-# if CDPATH is set.
-(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
-
-# The names of the tagged configurations supported by this script.
-available_tags=
-
-# ### BEGIN LIBTOOL CONFIG
-
-# Libtool was configured on host `(hostname || uname -n) 2>/dev/null | sed 1q`:
-
-# Shell to use when invoking shell scripts.
-SHELL=$lt_SHELL
-
-# Whether or not to build shared libraries.
-build_libtool_libs=$enable_shared
-
-# Whether or not to build static libraries.
-build_old_libs=$enable_static
-
-# Whether or not to add -lc for building shared libraries.
-build_libtool_need_lc=$archive_cmds_need_lc
-
-# Whether or not to disallow shared libs when runtime libs are static
-allow_libtool_libs_with_static_runtimes=$enable_shared_with_static_runtimes
-
-# Whether or not to optimize for fast installation.
-fast_install=$enable_fast_install
-
-# The host system.
-host_alias=$host_alias
-host=$host
-host_os=$host_os
-
-# The build system.
-build_alias=$build_alias
-build=$build
-build_os=$build_os
-
-# An echo program that does not interpret backslashes.
-echo=$lt_echo
-
-# The archiver.
-AR=$lt_AR
-AR_FLAGS=$lt_AR_FLAGS
-
-# A C compiler.
-LTCC=$lt_LTCC
-
-# LTCC compiler flags.
-LTCFLAGS=$lt_LTCFLAGS
-
-# A language-specific compiler.
-CC=$lt_compiler
-
-# Is the compiler the GNU C compiler?
-with_gcc=$GCC
-
-# An ERE matcher.
-EGREP=$lt_EGREP
-
-# The linker used to build libraries.
-LD=$lt_LD
-
-# Whether we need hard or soft links.
-LN_S=$lt_LN_S
-
-# A BSD-compatible nm program.
-NM=$lt_NM
-
-# A symbol stripping program
-STRIP=$lt_STRIP
-
-# Used to examine libraries when file_magic_cmd begins "file"
-MAGIC_CMD=$MAGIC_CMD
-
-# Used on cygwin: DLL creation program.
-DLLTOOL="$DLLTOOL"
-
-# Used on cygwin: object dumper.
-OBJDUMP="$OBJDUMP"
-
-# Used on cygwin: assembler.
-AS="$AS"
-
-# The name of the directory that contains temporary libtool files.
-objdir=$objdir
-
-# How to create reloadable object files.
-reload_flag=$lt_reload_flag
-reload_cmds=$lt_reload_cmds
-
-# How to pass a linker flag through the compiler.
-wl=$lt_lt_prog_compiler_wl
-
-# Object file suffix (normally "o").
-objext="$ac_objext"
-
-# Old archive suffix (normally "a").
-libext="$libext"
-
-# Shared library suffix (normally ".so").
-shrext_cmds='$shrext_cmds'
-
-# Executable file suffix (normally "").
-exeext="$exeext"
-
-# Additional compiler flags for building library objects.
-pic_flag=$lt_lt_prog_compiler_pic
-pic_mode=$pic_mode
-
-# What is the maximum length of a command?
-max_cmd_len=$lt_cv_sys_max_cmd_len
-
-# Does compiler simultaneously support -c and -o options?
-compiler_c_o=$lt_lt_cv_prog_compiler_c_o
-
-# Must we lock files when doing compilation?
-need_locks=$lt_need_locks
-
-# Do we need the lib prefix for modules?
-need_lib_prefix=$need_lib_prefix
-
-# Do we need a version for libraries?
-need_version=$need_version
-
-# Whether dlopen is supported.
-dlopen_support=$enable_dlopen
-
-# Whether dlopen of programs is supported.
-dlopen_self=$enable_dlopen_self
-
-# Whether dlopen of statically linked programs is supported.
-dlopen_self_static=$enable_dlopen_self_static
-
-# Compiler flag to prevent dynamic linking.
-link_static_flag=$lt_lt_prog_compiler_static
-
-# Compiler flag to turn off builtin functions.
-no_builtin_flag=$lt_lt_prog_compiler_no_builtin_flag
-
-# Compiler flag to allow reflexive dlopens.
-export_dynamic_flag_spec=$lt_export_dynamic_flag_spec
-
-# Compiler flag to generate shared objects directly from archives.
-whole_archive_flag_spec=$lt_whole_archive_flag_spec
-
-# Compiler flag to generate thread-safe objects.
-thread_safe_flag_spec=$lt_thread_safe_flag_spec
-
-# Library versioning type.
-version_type=$version_type
-
-# Format of library name prefix.
-libname_spec=$lt_libname_spec
-
-# List of archive names. First name is the real one, the rest are links.
-# The last name is the one that the linker finds with -lNAME.
-library_names_spec=$lt_library_names_spec
-
-# The coded name of the library, if different from the real name.
-soname_spec=$lt_soname_spec
-
-# Commands used to build and install an old-style archive.
-RANLIB=$lt_RANLIB
-old_archive_cmds=$lt_old_archive_cmds
-old_postinstall_cmds=$lt_old_postinstall_cmds
-old_postuninstall_cmds=$lt_old_postuninstall_cmds
-
-# Create an old-style archive from a shared archive.
-old_archive_from_new_cmds=$lt_old_archive_from_new_cmds
-
-# Create a temporary old-style archive to link instead of a shared archive.
-old_archive_from_expsyms_cmds=$lt_old_archive_from_expsyms_cmds
-
-# Commands used to build and install a shared archive.
-archive_cmds=$lt_archive_cmds
-archive_expsym_cmds=$lt_archive_expsym_cmds
-postinstall_cmds=$lt_postinstall_cmds
-postuninstall_cmds=$lt_postuninstall_cmds
-
-# Commands used to build a loadable module (assumed same as above if empty)
-module_cmds=$lt_module_cmds
-module_expsym_cmds=$lt_module_expsym_cmds
-
-# Commands to strip libraries.
-old_striplib=$lt_old_striplib
-striplib=$lt_striplib
-
-# Dependencies to place before the objects being linked to create a
-# shared library.
-predep_objects=$lt_predep_objects
-
-# Dependencies to place after the objects being linked to create a
-# shared library.
-postdep_objects=$lt_postdep_objects
-
-# Dependencies to place before the objects being linked to create a
-# shared library.
-predeps=$lt_predeps
-
-# Dependencies to place after the objects being linked to create a
-# shared library.
-postdeps=$lt_postdeps
-
-# The library search path used internally by the compiler when linking
-# a shared library.
-compiler_lib_search_path=$lt_compiler_lib_search_path
-
-# Method to check whether dependent libraries are shared objects.
-deplibs_check_method=$lt_deplibs_check_method
-
-# Command to use when deplibs_check_method == file_magic.
-file_magic_cmd=$lt_file_magic_cmd
-
-# Flag that allows shared libraries with undefined symbols to be built.
-allow_undefined_flag=$lt_allow_undefined_flag
-
-# Flag that forces no undefined symbols.
-no_undefined_flag=$lt_no_undefined_flag
-
-# Commands used to finish a libtool library installation in a directory.
-finish_cmds=$lt_finish_cmds
-
-# Same as above, but a single script fragment to be evaled but not shown.
-finish_eval=$lt_finish_eval
-
-# Take the output of nm and produce a listing of raw symbols and C names.
-global_symbol_pipe=$lt_lt_cv_sys_global_symbol_pipe
-
-# Transform the output of nm in a proper C declaration
-global_symbol_to_cdecl=$lt_lt_cv_sys_global_symbol_to_cdecl
-
-# Transform the output of nm in a C name address pair
-global_symbol_to_c_name_address=$lt_lt_cv_sys_global_symbol_to_c_name_address
-
-# This is the shared library runtime path variable.
-runpath_var=$runpath_var
-
-# This is the shared library path variable.
-shlibpath_var=$shlibpath_var
-
-# Is shlibpath searched before the hard-coded library search path?
-shlibpath_overrides_runpath=$shlibpath_overrides_runpath
-
-# How to hardcode a shared library path into an executable.
-hardcode_action=$hardcode_action
-
-# Whether we should hardcode library paths into libraries.
-hardcode_into_libs=$hardcode_into_libs
-
-# Flag to hardcode \$libdir into a binary during linking.
-# This must work even if \$libdir does not exist.
-hardcode_libdir_flag_spec=$lt_hardcode_libdir_flag_spec
-
-# If ld is used when linking, flag to hardcode \$libdir into
-# a binary during linking. This must work even if \$libdir does
-# not exist.
-hardcode_libdir_flag_spec_ld=$lt_hardcode_libdir_flag_spec_ld
-
-# Whether we need a single -rpath flag with a separated argument.
-hardcode_libdir_separator=$lt_hardcode_libdir_separator
-
-# Set to yes if using DIR/libNAME${shared_ext} during linking hardcodes DIR into the
-# resulting binary.
-hardcode_direct=$hardcode_direct
-
-# Set to yes if using the -LDIR flag during linking hardcodes DIR into the
-# resulting binary.
-hardcode_minus_L=$hardcode_minus_L
-
-# Set to yes if using SHLIBPATH_VAR=DIR during linking hardcodes DIR into
-# the resulting binary.
-hardcode_shlibpath_var=$hardcode_shlibpath_var
-
-# Set to yes if building a shared library automatically hardcodes DIR into the library
-# and all subsequent libraries and executables linked against it.
-hardcode_automatic=$hardcode_automatic
-
-# Variables whose values should be saved in libtool wrapper scripts and
-# restored at relink time.
-variables_saved_for_relink="$variables_saved_for_relink"
-
-# Whether libtool must link a program against all its dependency libraries.
-link_all_deplibs=$link_all_deplibs
-
-# Compile-time system search path for libraries
-sys_lib_search_path_spec=$lt_sys_lib_search_path_spec
-
-# Run-time system search path for libraries
-sys_lib_dlsearch_path_spec=$lt_sys_lib_dlsearch_path_spec
-
-# Fix the shell variable \$srcfile for the compiler.
-fix_srcfile_path="$fix_srcfile_path"
-
-# Set to yes if exported symbols are required.
-always_export_symbols=$always_export_symbols
-
-# The commands to list exported symbols.
-export_symbols_cmds=$lt_export_symbols_cmds
-
-# The commands to extract the exported symbol list from a shared archive.
-extract_expsyms_cmds=$lt_extract_expsyms_cmds
-
-# Symbols that should not be listed in the preloaded symbols.
-exclude_expsyms=$lt_exclude_expsyms
-
-# Symbols that must always be exported.
-include_expsyms=$lt_include_expsyms
-
-# ### END LIBTOOL CONFIG
-
-__EOF__
-
-
- case $host_os in
- aix3*)
- cat <<\EOF >> "$cfgfile"
-
-# AIX sometimes has problems with the GCC collect2 program. For some
-# reason, if we set the COLLECT_NAMES environment variable, the problems
-# vanish in a puff of smoke.
-if test "X${COLLECT_NAMES+set}" != Xset; then
- COLLECT_NAMES=
- export COLLECT_NAMES
-fi
-EOF
- ;;
- esac
-
- # We use sed instead of cat because bash on DJGPP gets confused if
- # if finds mixed CR/LF and LF-only lines. Since sed operates in
- # text mode, it properly converts lines to CR/LF. This bash problem
- # is reportedly fixed, but why not run on old versions too?
- sed '$q' "$ltmain" >> "$cfgfile" || (rm -f "$cfgfile"; exit 1)
-
- mv -f "$cfgfile" "$ofile" || \
- (rm -f "$ofile" && cp "$cfgfile" "$ofile" && rm -f "$cfgfile")
- chmod +x "$ofile"
-
-else
- # If there is no Makefile yet, we rely on a make rule to execute
- # `config.status --recheck' to rerun these tests and create the
- # libtool script then.
- ltmain_in=`echo $ltmain | sed -e 's/\.sh$/.in/'`
- if test -f "$ltmain_in"; then
- test -f Makefile && make "$ltmain"
- fi
-fi
-
-
-ac_ext=c
-ac_cpp='$CPP $CPPFLAGS'
-ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
-ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
-ac_compiler_gnu=$ac_cv_c_compiler_gnu
-
-CC="$lt_save_CC"
-
-
-# Check whether --with-tags or --without-tags was given.
-if test "${with_tags+set}" = set; then
- withval="$with_tags"
- tagnames="$withval"
-fi;
-
-if test -f "$ltmain" && test -n "$tagnames"; then
- if test ! -f "${ofile}"; then
- { echo "$as_me:$LINENO: WARNING: output file \`$ofile' does not exist" >&5
-echo "$as_me: WARNING: output file \`$ofile' does not exist" >&2;}
- fi
-
- if test -z "$LTCC"; then
- eval "`$SHELL ${ofile} --config | grep '^LTCC='`"
- if test -z "$LTCC"; then
- { echo "$as_me:$LINENO: WARNING: output file \`$ofile' does not look like a libtool script" >&5
-echo "$as_me: WARNING: output file \`$ofile' does not look like a libtool script" >&2;}
- else
- { echo "$as_me:$LINENO: WARNING: using \`LTCC=$LTCC', extracted from \`$ofile'" >&5
-echo "$as_me: WARNING: using \`LTCC=$LTCC', extracted from \`$ofile'" >&2;}
- fi
- fi
- if test -z "$LTCFLAGS"; then
- eval "`$SHELL ${ofile} --config | grep '^LTCFLAGS='`"
- fi
-
- # Extract list of available tagged configurations in $ofile.
- # Note that this assumes the entire list is on one line.
- available_tags=`grep "^available_tags=" "${ofile}" | $SED -e 's/available_tags=\(.*$\)/\1/' -e 's/\"//g'`
-
- lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR,"
- for tagname in $tagnames; do
- IFS="$lt_save_ifs"
- # Check whether tagname contains only valid characters
- case `$echo "X$tagname" | $Xsed -e 's:[-_ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890,/]::g'` in
- "") ;;
- *) { { echo "$as_me:$LINENO: error: invalid tag name: $tagname" >&5
-echo "$as_me: error: invalid tag name: $tagname" >&2;}
- { (exit 1); exit 1; }; }
- ;;
- esac
-
- if grep "^# ### BEGIN LIBTOOL TAG CONFIG: $tagname$" < "${ofile}" > /dev/null
- then
- { { echo "$as_me:$LINENO: error: tag name \"$tagname\" already exists" >&5
-echo "$as_me: error: tag name \"$tagname\" already exists" >&2;}
- { (exit 1); exit 1; }; }
- fi
-
- # Update the list of available tags.
- if test -n "$tagname"; then
- echo appending configuration tag \"$tagname\" to $ofile
-
- case $tagname in
- CXX)
- if test -n "$CXX" && ( test "X$CXX" != "Xno" &&
- ( (test "X$CXX" = "Xg++" && `g++ -v >/dev/null 2>&1` ) ||
- (test "X$CXX" != "Xg++"))) ; then
- ac_ext=cc
-ac_cpp='$CXXCPP $CPPFLAGS'
-ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
-ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
-ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
-
-
-
-
-archive_cmds_need_lc_CXX=no
-allow_undefined_flag_CXX=
-always_export_symbols_CXX=no
-archive_expsym_cmds_CXX=
-export_dynamic_flag_spec_CXX=
-hardcode_direct_CXX=no
-hardcode_libdir_flag_spec_CXX=
-hardcode_libdir_flag_spec_ld_CXX=
-hardcode_libdir_separator_CXX=
-hardcode_minus_L_CXX=no
-hardcode_shlibpath_var_CXX=unsupported
-hardcode_automatic_CXX=no
-module_cmds_CXX=
-module_expsym_cmds_CXX=
-link_all_deplibs_CXX=unknown
-old_archive_cmds_CXX=$old_archive_cmds
-no_undefined_flag_CXX=
-whole_archive_flag_spec_CXX=
-enable_shared_with_static_runtimes_CXX=no
-
-# Dependencies to place before and after the object being linked:
-predep_objects_CXX=
-postdep_objects_CXX=
-predeps_CXX=
-postdeps_CXX=
-compiler_lib_search_path_CXX=
-
-# Source file extension for C++ test sources.
-ac_ext=cpp
-
-# Object file extension for compiled C++ test sources.
-objext=o
-objext_CXX=$objext
-
-# Code to be used in simple compile tests
-lt_simple_compile_test_code="int some_variable = 0;\n"
-
-# Code to be used in simple link tests
-lt_simple_link_test_code='int main(int, char *[]) { return(0); }\n'
-
-# ltmain only uses $CC for tagged configurations so make sure $CC is set.
-
-# If no C compiler was specified, use CC.
-LTCC=${LTCC-"$CC"}
-
-# If no C compiler flags were specified, use CFLAGS.
-LTCFLAGS=${LTCFLAGS-"$CFLAGS"}
-
-# Allow CC to be a program name with arguments.
-compiler=$CC
-
-
-# save warnings/boilerplate of simple test code
-ac_outfile=conftest.$ac_objext
-printf "$lt_simple_compile_test_code" >conftest.$ac_ext
-eval "$ac_compile" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err
-_lt_compiler_boilerplate=`cat conftest.err`
-$rm conftest*
-
-ac_outfile=conftest.$ac_objext
-printf "$lt_simple_link_test_code" >conftest.$ac_ext
-eval "$ac_link" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err
-_lt_linker_boilerplate=`cat conftest.err`
-$rm conftest*
-
-
-# Allow CC to be a program name with arguments.
-lt_save_CC=$CC
-lt_save_LD=$LD
-lt_save_GCC=$GCC
-GCC=$GXX
-lt_save_with_gnu_ld=$with_gnu_ld
-lt_save_path_LD=$lt_cv_path_LD
-if test -n "${lt_cv_prog_gnu_ldcxx+set}"; then
- lt_cv_prog_gnu_ld=$lt_cv_prog_gnu_ldcxx
-else
- $as_unset lt_cv_prog_gnu_ld
-fi
-if test -n "${lt_cv_path_LDCXX+set}"; then
- lt_cv_path_LD=$lt_cv_path_LDCXX
-else
- $as_unset lt_cv_path_LD
-fi
-test -z "${LDCXX+set}" || LD=$LDCXX
-CC=${CXX-"c++"}
-compiler=$CC
-compiler_CXX=$CC
-for cc_temp in $compiler""; do
- case $cc_temp in
- compile | *[\\/]compile | ccache | *[\\/]ccache ) ;;
- distcc | *[\\/]distcc | purify | *[\\/]purify ) ;;
- \-*) ;;
- *) break;;
- esac
-done
-cc_basename=`$echo "X$cc_temp" | $Xsed -e 's%.*/%%' -e "s%^$host_alias-%%"`
-
-
-# We don't want -fno-exception wen compiling C++ code, so set the
-# no_builtin_flag separately
-if test "$GXX" = yes; then
- lt_prog_compiler_no_builtin_flag_CXX=' -fno-builtin'
-else
- lt_prog_compiler_no_builtin_flag_CXX=
-fi
-
-if test "$GXX" = yes; then
- # Set up default GNU C++ configuration
-
-
-# Check whether --with-gnu-ld or --without-gnu-ld was given.
-if test "${with_gnu_ld+set}" = set; then
- withval="$with_gnu_ld"
- test "$withval" = no || with_gnu_ld=yes
-else
- with_gnu_ld=no
-fi;
-ac_prog=ld
-if test "$GCC" = yes; then
- # Check if gcc -print-prog-name=ld gives a path.
- echo "$as_me:$LINENO: checking for ld used by $CC" >&5
-echo $ECHO_N "checking for ld used by $CC... $ECHO_C" >&6
- case $host in
- *-*-mingw*)
- # gcc leaves a trailing carriage return which upsets mingw
- ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;;
- *)
- ac_prog=`($CC -print-prog-name=ld) 2>&5` ;;
- esac
- case $ac_prog in
- # Accept absolute paths.
- [\\/]* | ?:[\\/]*)
- re_direlt='/[^/][^/]*/\.\./'
- # Canonicalize the pathname of ld
- ac_prog=`echo $ac_prog| $SED 's%\\\\%/%g'`
- while echo $ac_prog | grep "$re_direlt" > /dev/null 2>&1; do
- ac_prog=`echo $ac_prog| $SED "s%$re_direlt%/%"`
- done
- test -z "$LD" && LD="$ac_prog"
- ;;
- "")
- # If it fails, then pretend we aren't using GCC.
- ac_prog=ld
- ;;
- *)
- # If it is relative, then search for the first ld in PATH.
- with_gnu_ld=unknown
- ;;
- esac
-elif test "$with_gnu_ld" = yes; then
- echo "$as_me:$LINENO: checking for GNU ld" >&5
-echo $ECHO_N "checking for GNU ld... $ECHO_C" >&6
-else
- echo "$as_me:$LINENO: checking for non-GNU ld" >&5
-echo $ECHO_N "checking for non-GNU ld... $ECHO_C" >&6
-fi
-if test "${lt_cv_path_LD+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- if test -z "$LD"; then
- lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
- for ac_dir in $PATH; do
- IFS="$lt_save_ifs"
- test -z "$ac_dir" && ac_dir=.
- if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then
- lt_cv_path_LD="$ac_dir/$ac_prog"
- # Check to see if the program is GNU ld. I'd rather use --version,
- # but apparently some variants of GNU ld only accept -v.
- # Break only if it was the GNU/non-GNU ld that we prefer.
- case `"$lt_cv_path_LD" -v 2>&1 </dev/null` in
- *GNU* | *'with BFD'*)
- test "$with_gnu_ld" != no && break
- ;;
- *)
- test "$with_gnu_ld" != yes && break
- ;;
- esac
- fi
- done
- IFS="$lt_save_ifs"
-else
- lt_cv_path_LD="$LD" # Let the user override the test with a path.
-fi
-fi
-
-LD="$lt_cv_path_LD"
-if test -n "$LD"; then
- echo "$as_me:$LINENO: result: $LD" >&5
-echo "${ECHO_T}$LD" >&6
-else
- echo "$as_me:$LINENO: result: no" >&5
-echo "${ECHO_T}no" >&6
-fi
-test -z "$LD" && { { echo "$as_me:$LINENO: error: no acceptable ld found in \$PATH" >&5
-echo "$as_me: error: no acceptable ld found in \$PATH" >&2;}
- { (exit 1); exit 1; }; }
-echo "$as_me:$LINENO: checking if the linker ($LD) is GNU ld" >&5
-echo $ECHO_N "checking if the linker ($LD) is GNU ld... $ECHO_C" >&6
-if test "${lt_cv_prog_gnu_ld+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- # I'd rather use --version here, but apparently some GNU lds only accept -v.
-case `$LD -v 2>&1 </dev/null` in
-*GNU* | *'with BFD'*)
- lt_cv_prog_gnu_ld=yes
- ;;
-*)
- lt_cv_prog_gnu_ld=no
- ;;
-esac
-fi
-echo "$as_me:$LINENO: result: $lt_cv_prog_gnu_ld" >&5
-echo "${ECHO_T}$lt_cv_prog_gnu_ld" >&6
-with_gnu_ld=$lt_cv_prog_gnu_ld
-
-
-
- # Check if GNU C++ uses GNU ld as the underlying linker, since the
- # archiving commands below assume that GNU ld is being used.
- if test "$with_gnu_ld" = yes; then
- archive_cmds_CXX='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib'
- archive_expsym_cmds_CXX='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
-
- hardcode_libdir_flag_spec_CXX='${wl}--rpath ${wl}$libdir'
- export_dynamic_flag_spec_CXX='${wl}--export-dynamic'
-
- # If archive_cmds runs LD, not CC, wlarc should be empty
- # XXX I think wlarc can be eliminated in ltcf-cxx, but I need to
- # investigate it a little bit more. (MM)
- wlarc='${wl}'
-
- # ancient GNU ld didn't support --whole-archive et. al.
- if eval "`$CC -print-prog-name=ld` --help 2>&1" | \
- grep 'no-whole-archive' > /dev/null; then
- whole_archive_flag_spec_CXX="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive'
- else
- whole_archive_flag_spec_CXX=
- fi
- else
- with_gnu_ld=no
- wlarc=
-
- # A generic and very simple default shared library creation
- # command for GNU C++ for the case where it uses the native
- # linker, instead of GNU ld. If possible, this setting should
- # overridden to take advantage of the native linker features on
- # the platform it is being used on.
- archive_cmds_CXX='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $lib'
- fi
-
- # Commands to make compiler produce verbose output that lists
- # what "hidden" libraries, object files and flags are used when
- # linking a shared library.
- output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep "\-L"'
-
-else
- GXX=no
- with_gnu_ld=no
- wlarc=
-fi
-
-# PORTME: fill in a description of your system's C++ link characteristics
-echo "$as_me:$LINENO: checking whether the $compiler linker ($LD) supports shared libraries" >&5
-echo $ECHO_N "checking whether the $compiler linker ($LD) supports shared libraries... $ECHO_C" >&6
-ld_shlibs_CXX=yes
-case $host_os in
- aix3*)
- # FIXME: insert proper C++ library support
- ld_shlibs_CXX=no
- ;;
- aix4* | aix5*)
- if test "$host_cpu" = ia64; then
- # On IA64, the linker does run time linking by default, so we don't
- # have to do anything special.
- aix_use_runtimelinking=no
- exp_sym_flag='-Bexport'
- no_entry_flag=""
- else
- aix_use_runtimelinking=no
-
- # Test if we are trying to use run time linking or normal
- # AIX style linking. If -brtl is somewhere in LDFLAGS, we
- # need to do runtime linking.
- case $host_os in aix4.[23]|aix4.[23].*|aix5*)
- for ld_flag in $LDFLAGS; do
- case $ld_flag in
- *-brtl*)
- aix_use_runtimelinking=yes
- break
- ;;
- esac
- done
- ;;
- esac
-
- exp_sym_flag='-bexport'
- no_entry_flag='-bnoentry'
- fi
-
- # When large executables or shared objects are built, AIX ld can
- # have problems creating the table of contents. If linking a library
- # or program results in "error TOC overflow" add -mminimal-toc to
- # CXXFLAGS/CFLAGS for g++/gcc. In the cases where that is not
- # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS.
-
- archive_cmds_CXX=''
- hardcode_direct_CXX=yes
- hardcode_libdir_separator_CXX=':'
- link_all_deplibs_CXX=yes
-
- if test "$GXX" = yes; then
- case $host_os in aix4.[012]|aix4.[012].*)
- # We only want to do this on AIX 4.2 and lower, the check
- # below for broken collect2 doesn't work under 4.3+
- collect2name=`${CC} -print-prog-name=collect2`
- if test -f "$collect2name" && \
- strings "$collect2name" | grep resolve_lib_name >/dev/null
- then
- # We have reworked collect2
- hardcode_direct_CXX=yes
- else
- # We have old collect2
- hardcode_direct_CXX=unsupported
- # It fails to find uninstalled libraries when the uninstalled
- # path is not listed in the libpath. Setting hardcode_minus_L
- # to unsupported forces relinking
- hardcode_minus_L_CXX=yes
- hardcode_libdir_flag_spec_CXX='-L$libdir'
- hardcode_libdir_separator_CXX=
- fi
- ;;
- esac
- shared_flag='-shared'
- if test "$aix_use_runtimelinking" = yes; then
- shared_flag="$shared_flag "'${wl}-G'
- fi
- else
- # not using gcc
- if test "$host_cpu" = ia64; then
- # VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release
- # chokes on -Wl,-G. The following line is correct:
- shared_flag='-G'
- else
- if test "$aix_use_runtimelinking" = yes; then
- shared_flag='${wl}-G'
- else
- shared_flag='${wl}-bM:SRE'
- fi
- fi
- fi
-
- # It seems that -bexpall does not export symbols beginning with
- # underscore (_), so it is better to generate a list of symbols to export.
- always_export_symbols_CXX=yes
- if test "$aix_use_runtimelinking" = yes; then
- # Warning - without using the other runtime loading flags (-brtl),
- # -berok will link without error, but may produce a broken library.
- allow_undefined_flag_CXX='-berok'
- # Determine the default libpath from the value encoded in an empty executable.
- cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-
-int
-main ()
-{
-
- ;
- return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
- (eval $ac_link) 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } &&
- { ac_try='test -z "$ac_cxx_werror_flag" || test ! -s conftest.err'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; } &&
- { ac_try='test -s conftest$ac_exeext'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
-
-aix_libpath=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; }
-}'`
-# Check for a 64-bit object if we didn't find anything.
-if test -z "$aix_libpath"; then aix_libpath=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; }
-}'`; fi
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-fi
-rm -f conftest.err conftest.$ac_objext \
- conftest$ac_exeext conftest.$ac_ext
-if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
-
- hardcode_libdir_flag_spec_CXX='${wl}-blibpath:$libdir:'"$aix_libpath"
-
- archive_expsym_cmds_CXX="\$CC"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then echo "${wl}${allow_undefined_flag}"; else :; fi` '"\${wl}$exp_sym_flag:\$export_symbols $shared_flag"
- else
- if test "$host_cpu" = ia64; then
- hardcode_libdir_flag_spec_CXX='${wl}-R $libdir:/usr/lib:/lib'
- allow_undefined_flag_CXX="-z nodefs"
- archive_expsym_cmds_CXX="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$exp_sym_flag:\$export_symbols"
- else
- # Determine the default libpath from the value encoded in an empty executable.
- cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-
-int
-main ()
-{
-
- ;
- return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
- (eval $ac_link) 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } &&
- { ac_try='test -z "$ac_cxx_werror_flag" || test ! -s conftest.err'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; } &&
- { ac_try='test -s conftest$ac_exeext'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
-
-aix_libpath=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; }
-}'`
-# Check for a 64-bit object if we didn't find anything.
-if test -z "$aix_libpath"; then aix_libpath=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; }
-}'`; fi
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-fi
-rm -f conftest.err conftest.$ac_objext \
- conftest$ac_exeext conftest.$ac_ext
-if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
-
- hardcode_libdir_flag_spec_CXX='${wl}-blibpath:$libdir:'"$aix_libpath"
- # Warning - without using the other run time loading flags,
- # -berok will link without error, but may produce a broken library.
- no_undefined_flag_CXX=' ${wl}-bernotok'
- allow_undefined_flag_CXX=' ${wl}-berok'
- # Exported symbols can be pulled into shared objects from archives
- whole_archive_flag_spec_CXX='$convenience'
- archive_cmds_need_lc_CXX=yes
- # This is similar to how AIX traditionally builds its shared libraries.
- archive_expsym_cmds_CXX="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs ${wl}-bnoentry $compiler_flags ${wl}-bE:$export_symbols${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname'
- fi
- fi
- ;;
-
- beos*)
- if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
- allow_undefined_flag_CXX=unsupported
- # Joseph Beckenbach <jrb3@best.com> says some releases of gcc
- # support --undefined. This deserves some investigation. FIXME
- archive_cmds_CXX='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
- else
- ld_shlibs_CXX=no
- fi
- ;;
-
- chorus*)
- case $cc_basename in
- *)
- # FIXME: insert proper C++ library support
- ld_shlibs_CXX=no
- ;;
- esac
- ;;
-
- cygwin* | mingw* | pw32*)
- # _LT_AC_TAGVAR(hardcode_libdir_flag_spec, CXX) is actually meaningless,
- # as there is no search path for DLLs.
- hardcode_libdir_flag_spec_CXX='-L$libdir'
- allow_undefined_flag_CXX=unsupported
- always_export_symbols_CXX=no
- enable_shared_with_static_runtimes_CXX=yes
-
- if $LD --help 2>&1 | grep 'auto-import' > /dev/null; then
- archive_cmds_CXX='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
- # If the export-symbols file already is a .def file (1st line
- # is EXPORTS), use it as is; otherwise, prepend...
- archive_expsym_cmds_CXX='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then
- cp $export_symbols $output_objdir/$soname.def;
- else
- echo EXPORTS > $output_objdir/$soname.def;
- cat $export_symbols >> $output_objdir/$soname.def;
- fi~
- $CC -shared -nostdlib $output_objdir/$soname.def $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
- else
- ld_shlibs_CXX=no
- fi
- ;;
- darwin* | rhapsody*)
- case $host_os in
- rhapsody* | darwin1.[012])
- allow_undefined_flag_CXX='${wl}-undefined ${wl}suppress'
- ;;
- *) # Darwin 1.3 on
- if test -z ${MACOSX_DEPLOYMENT_TARGET} ; then
- allow_undefined_flag_CXX='${wl}-flat_namespace ${wl}-undefined ${wl}suppress'
- else
- case ${MACOSX_DEPLOYMENT_TARGET} in
- 10.[012])
- allow_undefined_flag_CXX='${wl}-flat_namespace ${wl}-undefined ${wl}suppress'
- ;;
- 10.*)
- allow_undefined_flag_CXX='${wl}-undefined ${wl}dynamic_lookup'
- ;;
- esac
- fi
- ;;
- esac
- archive_cmds_need_lc_CXX=no
- hardcode_direct_CXX=no
- hardcode_automatic_CXX=yes
- hardcode_shlibpath_var_CXX=unsupported
- whole_archive_flag_spec_CXX=''
- link_all_deplibs_CXX=yes
-
- if test "$GXX" = yes ; then
- lt_int_apple_cc_single_mod=no
- output_verbose_link_cmd='echo'
- if $CC -dumpspecs 2>&1 | $EGREP 'single_module' >/dev/null ; then
- lt_int_apple_cc_single_mod=yes
- fi
- if test "X$lt_int_apple_cc_single_mod" = Xyes ; then
- archive_cmds_CXX='$CC -dynamiclib -single_module $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring'
- else
- archive_cmds_CXX='$CC -r -keep_private_externs -nostdlib -o ${lib}-master.o $libobjs~$CC -dynamiclib $allow_undefined_flag -o $lib ${lib}-master.o $deplibs $compiler_flags -install_name $rpath/$soname $verstring'
- fi
- module_cmds_CXX='$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags'
- # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin lds
- if test "X$lt_int_apple_cc_single_mod" = Xyes ; then
- archive_expsym_cmds_CXX='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -dynamiclib -single_module $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
- else
- archive_expsym_cmds_CXX='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -r -keep_private_externs -nostdlib -o ${lib}-master.o $libobjs~$CC -dynamiclib $allow_undefined_flag -o $lib ${lib}-master.o $deplibs $compiler_flags -install_name $rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
- fi
- module_expsym_cmds_CXX='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
- else
- case $cc_basename in
- xlc*)
- output_verbose_link_cmd='echo'
- archive_cmds_CXX='$CC -qmkshrobj ${wl}-single_module $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-install_name ${wl}`echo $rpath/$soname` $verstring'
- module_cmds_CXX='$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags'
- # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin lds
- archive_expsym_cmds_CXX='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -qmkshrobj ${wl}-single_module $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-install_name ${wl}$rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
- module_expsym_cmds_CXX='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
- ;;
- *)
- ld_shlibs_CXX=no
- ;;
- esac
- fi
- ;;
-
- dgux*)
- case $cc_basename in
- ec++*)
- # FIXME: insert proper C++ library support
- ld_shlibs_CXX=no
- ;;
- ghcx*)
- # Green Hills C++ Compiler
- # FIXME: insert proper C++ library support
- ld_shlibs_CXX=no
- ;;
- *)
- # FIXME: insert proper C++ library support
- ld_shlibs_CXX=no
- ;;
- esac
- ;;
- freebsd[12]*)
- # C++ shared libraries reported to be fairly broken before switch to ELF
- ld_shlibs_CXX=no
- ;;
- freebsd-elf*)
- archive_cmds_need_lc_CXX=no
- ;;
- freebsd* | kfreebsd*-gnu | dragonfly*)
- # FreeBSD 3 and later use GNU C++ and GNU ld with standard ELF
- # conventions
- ld_shlibs_CXX=yes
- ;;
- gnu*)
- ;;
- hpux9*)
- hardcode_libdir_flag_spec_CXX='${wl}+b ${wl}$libdir'
- hardcode_libdir_separator_CXX=:
- export_dynamic_flag_spec_CXX='${wl}-E'
- hardcode_direct_CXX=yes
- hardcode_minus_L_CXX=yes # Not in the search PATH,
- # but as the default
- # location of the library.
-
- case $cc_basename in
- CC*)
- # FIXME: insert proper C++ library support
- ld_shlibs_CXX=no
- ;;
- aCC*)
- archive_cmds_CXX='$rm $output_objdir/$soname~$CC -b ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
- # Commands to make compiler produce verbose output that lists
- # what "hidden" libraries, object files and flags are used when
- # linking a shared library.
- #
- # There doesn't appear to be a way to prevent this compiler from
- # explicitly linking system object files so we need to strip them
- # from the output so that they don't get included in the library
- # dependencies.
- output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | grep "[-]L"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; echo $list'
- ;;
- *)
- if test "$GXX" = yes; then
- archive_cmds_CXX='$rm $output_objdir/$soname~$CC -shared -nostdlib -fPIC ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
- else
- # FIXME: insert proper C++ library support
- ld_shlibs_CXX=no
- fi
- ;;
- esac
- ;;
- hpux10*|hpux11*)
- if test $with_gnu_ld = no; then
- hardcode_libdir_flag_spec_CXX='${wl}+b ${wl}$libdir'
- hardcode_libdir_separator_CXX=:
-
- case $host_cpu in
- hppa*64*|ia64*)
- hardcode_libdir_flag_spec_ld_CXX='+b $libdir'
- ;;
- *)
- export_dynamic_flag_spec_CXX='${wl}-E'
- ;;
- esac
- fi
- case $host_cpu in
- hppa*64*|ia64*)
- hardcode_direct_CXX=no
- hardcode_shlibpath_var_CXX=no
- ;;
- *)
- hardcode_direct_CXX=yes
- hardcode_minus_L_CXX=yes # Not in the search PATH,
- # but as the default
- # location of the library.
- ;;
- esac
-
- case $cc_basename in
- CC*)
- # FIXME: insert proper C++ library support
- ld_shlibs_CXX=no
- ;;
- aCC*)
- case $host_cpu in
- hppa*64*)
- archive_cmds_CXX='$CC -b ${wl}+h ${wl}$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
- ;;
- ia64*)
- archive_cmds_CXX='$CC -b ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
- ;;
- *)
- archive_cmds_CXX='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
- ;;
- esac
- # Commands to make compiler produce verbose output that lists
- # what "hidden" libraries, object files and flags are used when
- # linking a shared library.
- #
- # There doesn't appear to be a way to prevent this compiler from
- # explicitly linking system object files so we need to strip them
- # from the output so that they don't get included in the library
- # dependencies.
- output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | grep "\-L"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; echo $list'
- ;;
- *)
- if test "$GXX" = yes; then
- if test $with_gnu_ld = no; then
- case $host_cpu in
- hppa*64*)
- archive_cmds_CXX='$CC -shared -nostdlib -fPIC ${wl}+h ${wl}$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
- ;;
- ia64*)
- archive_cmds_CXX='$CC -shared -nostdlib -fPIC ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
- ;;
- *)
- archive_cmds_CXX='$CC -shared -nostdlib -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
- ;;
- esac
- fi
- else
- # FIXME: insert proper C++ library support
- ld_shlibs_CXX=no
- fi
- ;;
- esac
- ;;
- interix3*)
- hardcode_direct_CXX=no
- hardcode_shlibpath_var_CXX=no
- hardcode_libdir_flag_spec_CXX='${wl}-rpath,$libdir'
- export_dynamic_flag_spec_CXX='${wl}-E'
- # Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc.
- # Instead, shared libraries are loaded at an image base (0x10000000 by
- # default) and relocated if they conflict, which is a slow very memory
- # consuming and fragmenting process. To avoid this, we pick a random,
- # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link
- # time. Moving up from 0x10000000 also allows more sbrk(2) space.
- archive_cmds_CXX='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
- archive_expsym_cmds_CXX='sed "s,^,_," $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--retain-symbols-file,$output_objdir/$soname.expsym ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
- ;;
- irix5* | irix6*)
- case $cc_basename in
- CC*)
- # SGI C++
- archive_cmds_CXX='$CC -shared -all -multigot $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib'
-
- # Archives containing C++ object files must be created using
- # "CC -ar", where "CC" is the IRIX C++ compiler. This is
- # necessary to make sure instantiated templates are included
- # in the archive.
- old_archive_cmds_CXX='$CC -ar -WR,-u -o $oldlib $oldobjs'
- ;;
- *)
- if test "$GXX" = yes; then
- if test "$with_gnu_ld" = no; then
- archive_cmds_CXX='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
- else
- archive_cmds_CXX='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` -o $lib'
- fi
- fi
- link_all_deplibs_CXX=yes
- ;;
- esac
- hardcode_libdir_flag_spec_CXX='${wl}-rpath ${wl}$libdir'
- hardcode_libdir_separator_CXX=:
- ;;
- linux*)
- case $cc_basename in
- KCC*)
- # Kuck and Associates, Inc. (KAI) C++ Compiler
-
- # KCC will only create a shared library if the output file
- # ends with ".so" (or ".sl" for HP-UX), so rename the library
- # to its proper name (with version) after linking.
- archive_cmds_CXX='tempext=`echo $shared_ext | $SED -e '\''s/\([^()0-9A-Za-z{}]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib'
- archive_expsym_cmds_CXX='tempext=`echo $shared_ext | $SED -e '\''s/\([^()0-9A-Za-z{}]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib ${wl}-retain-symbols-file,$export_symbols; mv \$templib $lib'
- # Commands to make compiler produce verbose output that lists
- # what "hidden" libraries, object files and flags are used when
- # linking a shared library.
- #
- # There doesn't appear to be a way to prevent this compiler from
- # explicitly linking system object files so we need to strip them
- # from the output so that they don't get included in the library
- # dependencies.
- output_verbose_link_cmd='templist=`$CC $CFLAGS -v conftest.$objext -o libconftest$shared_ext 2>&1 | grep "ld"`; rm -f libconftest$shared_ext; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; echo $list'
-
- hardcode_libdir_flag_spec_CXX='${wl}--rpath,$libdir'
- export_dynamic_flag_spec_CXX='${wl}--export-dynamic'
-
- # Archives containing C++ object files must be created using
- # "CC -Bstatic", where "CC" is the KAI C++ compiler.
- old_archive_cmds_CXX='$CC -Bstatic -o $oldlib $oldobjs'
- ;;
- icpc*)
- # Intel C++
- with_gnu_ld=yes
- # version 8.0 and above of icpc choke on multiply defined symbols
- # if we add $predep_objects and $postdep_objects, however 7.1 and
- # earlier do not add the objects themselves.
- case `$CC -V 2>&1` in
- *"Version 7."*)
- archive_cmds_CXX='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib'
- archive_expsym_cmds_CXX='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
- ;;
- *) # Version 8.0 or newer
- tmp_idyn=
- case $host_cpu in
- ia64*) tmp_idyn=' -i_dynamic';;
- esac
- archive_cmds_CXX='$CC -shared'"$tmp_idyn"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
- archive_expsym_cmds_CXX='$CC -shared'"$tmp_idyn"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
- ;;
- esac
- archive_cmds_need_lc_CXX=no
- hardcode_libdir_flag_spec_CXX='${wl}-rpath,$libdir'
- export_dynamic_flag_spec_CXX='${wl}--export-dynamic'
- whole_archive_flag_spec_CXX='${wl}--whole-archive$convenience ${wl}--no-whole-archive'
- ;;
- pgCC*)
- # Portland Group C++ compiler
- archive_cmds_CXX='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname -o $lib'
- archive_expsym_cmds_CXX='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname ${wl}-retain-symbols-file ${wl}$export_symbols -o $lib'
-
- hardcode_libdir_flag_spec_CXX='${wl}--rpath ${wl}$libdir'
- export_dynamic_flag_spec_CXX='${wl}--export-dynamic'
- whole_archive_flag_spec_CXX='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}--no-whole-archive'
- ;;
- cxx*)
- # Compaq C++
- archive_cmds_CXX='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib'
- archive_expsym_cmds_CXX='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib ${wl}-retain-symbols-file $wl$export_symbols'
-
- runpath_var=LD_RUN_PATH
- hardcode_libdir_flag_spec_CXX='-rpath $libdir'
- hardcode_libdir_separator_CXX=:
-
- # Commands to make compiler produce verbose output that lists
- # what "hidden" libraries, object files and flags are used when
- # linking a shared library.
- #
- # There doesn't appear to be a way to prevent this compiler from
- # explicitly linking system object files so we need to strip them
- # from the output so that they don't get included in the library
- # dependencies.
- output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep "ld"`; templist=`echo $templist | $SED "s/\(^.*ld.*\)\( .*ld .*$\)/\1/"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; echo $list'
- ;;
- esac
- ;;
- lynxos*)
- # FIXME: insert proper C++ library support
- ld_shlibs_CXX=no
- ;;
- m88k*)
- # FIXME: insert proper C++ library support
- ld_shlibs_CXX=no
- ;;
- mvs*)
- case $cc_basename in
- cxx*)
- # FIXME: insert proper C++ library support
- ld_shlibs_CXX=no
- ;;
- *)
- # FIXME: insert proper C++ library support
- ld_shlibs_CXX=no
- ;;
- esac
- ;;
- netbsd* | netbsdelf*-gnu | knetbsd*-gnu)
- if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then
- archive_cmds_CXX='$LD -Bshareable -o $lib $predep_objects $libobjs $deplibs $postdep_objects $linker_flags'
- wlarc=
- hardcode_libdir_flag_spec_CXX='-R$libdir'
- hardcode_direct_CXX=yes
- hardcode_shlibpath_var_CXX=no
- fi
- # Workaround some broken pre-1.5 toolchains
- output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep conftest.$objext | $SED -e "s:-lgcc -lc -lgcc::"'
- ;;
- openbsd2*)
- # C++ shared libraries are fairly broken
- ld_shlibs_CXX=no
- ;;
- openbsd*)
- hardcode_direct_CXX=yes
- hardcode_shlibpath_var_CXX=no
- archive_cmds_CXX='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $lib'
- hardcode_libdir_flag_spec_CXX='${wl}-rpath,$libdir'
- if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
- archive_expsym_cmds_CXX='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-retain-symbols-file,$export_symbols -o $lib'
- export_dynamic_flag_spec_CXX='${wl}-E'
- whole_archive_flag_spec_CXX="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive'
- fi
- output_verbose_link_cmd='echo'
- ;;
- osf3*)
- case $cc_basename in
- KCC*)
- # Kuck and Associates, Inc. (KAI) C++ Compiler
-
- # KCC will only create a shared library if the output file
- # ends with ".so" (or ".sl" for HP-UX), so rename the library
- # to its proper name (with version) after linking.
- archive_cmds_CXX='tempext=`echo $shared_ext | $SED -e '\''s/\([^()0-9A-Za-z{}]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib'
-
- hardcode_libdir_flag_spec_CXX='${wl}-rpath,$libdir'
- hardcode_libdir_separator_CXX=:
-
- # Archives containing C++ object files must be created using
- # "CC -Bstatic", where "CC" is the KAI C++ compiler.
- old_archive_cmds_CXX='$CC -Bstatic -o $oldlib $oldobjs'
-
- ;;
- RCC*)
- # Rational C++ 2.4.1
- # FIXME: insert proper C++ library support
- ld_shlibs_CXX=no
- ;;
- cxx*)
- allow_undefined_flag_CXX=' ${wl}-expect_unresolved ${wl}\*'
- archive_cmds_CXX='$CC -shared${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $soname `test -n "$verstring" && echo ${wl}-set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib'
-
- hardcode_libdir_flag_spec_CXX='${wl}-rpath ${wl}$libdir'
- hardcode_libdir_separator_CXX=:
-
- # Commands to make compiler produce verbose output that lists
- # what "hidden" libraries, object files and flags are used when
- # linking a shared library.
- #
- # There doesn't appear to be a way to prevent this compiler from
- # explicitly linking system object files so we need to strip them
- # from the output so that they don't get included in the library
- # dependencies.
- output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep "ld" | grep -v "ld:"`; templist=`echo $templist | $SED "s/\(^.*ld.*\)\( .*ld.*$\)/\1/"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; echo $list'
- ;;
- *)
- if test "$GXX" = yes && test "$with_gnu_ld" = no; then
- allow_undefined_flag_CXX=' ${wl}-expect_unresolved ${wl}\*'
- archive_cmds_CXX='$CC -shared -nostdlib ${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
-
- hardcode_libdir_flag_spec_CXX='${wl}-rpath ${wl}$libdir'
- hardcode_libdir_separator_CXX=:
-
- # Commands to make compiler produce verbose output that lists
- # what "hidden" libraries, object files and flags are used when
- # linking a shared library.
- output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep "\-L"'
-
- else
- # FIXME: insert proper C++ library support
- ld_shlibs_CXX=no
- fi
- ;;
- esac
- ;;
- osf4* | osf5*)
- case $cc_basename in
- KCC*)
- # Kuck and Associates, Inc. (KAI) C++ Compiler
-
- # KCC will only create a shared library if the output file
- # ends with ".so" (or ".sl" for HP-UX), so rename the library
- # to its proper name (with version) after linking.
- archive_cmds_CXX='tempext=`echo $shared_ext | $SED -e '\''s/\([^()0-9A-Za-z{}]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib'
-
- hardcode_libdir_flag_spec_CXX='${wl}-rpath,$libdir'
- hardcode_libdir_separator_CXX=:
-
- # Archives containing C++ object files must be created using
- # the KAI C++ compiler.
- old_archive_cmds_CXX='$CC -o $oldlib $oldobjs'
- ;;
- RCC*)
- # Rational C++ 2.4.1
- # FIXME: insert proper C++ library support
- ld_shlibs_CXX=no
- ;;
- cxx*)
- allow_undefined_flag_CXX=' -expect_unresolved \*'
- archive_cmds_CXX='$CC -shared${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib'
- archive_expsym_cmds_CXX='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done~
- echo "-hidden">> $lib.exp~
- $CC -shared$allow_undefined_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname -Wl,-input -Wl,$lib.exp `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib~
- $rm $lib.exp'
-
- hardcode_libdir_flag_spec_CXX='-rpath $libdir'
- hardcode_libdir_separator_CXX=:
-
- # Commands to make compiler produce verbose output that lists
- # what "hidden" libraries, object files and flags are used when
- # linking a shared library.
- #
- # There doesn't appear to be a way to prevent this compiler from
- # explicitly linking system object files so we need to strip them
- # from the output so that they don't get included in the library
- # dependencies.
- output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep "ld" | grep -v "ld:"`; templist=`echo $templist | $SED "s/\(^.*ld.*\)\( .*ld.*$\)/\1/"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; echo $list'
- ;;
- *)
- if test "$GXX" = yes && test "$with_gnu_ld" = no; then
- allow_undefined_flag_CXX=' ${wl}-expect_unresolved ${wl}\*'
- archive_cmds_CXX='$CC -shared -nostdlib ${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
-
- hardcode_libdir_flag_spec_CXX='${wl}-rpath ${wl}$libdir'
- hardcode_libdir_separator_CXX=:
-
- # Commands to make compiler produce verbose output that lists
- # what "hidden" libraries, object files and flags are used when
- # linking a shared library.
- output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep "\-L"'
-
- else
- # FIXME: insert proper C++ library support
- ld_shlibs_CXX=no
- fi
- ;;
- esac
- ;;
- psos*)
- # FIXME: insert proper C++ library support
- ld_shlibs_CXX=no
- ;;
- sunos4*)
- case $cc_basename in
- CC*)
- # Sun C++ 4.x
- # FIXME: insert proper C++ library support
- ld_shlibs_CXX=no
- ;;
- lcc*)
- # Lucid
- # FIXME: insert proper C++ library support
- ld_shlibs_CXX=no
- ;;
- *)
- # FIXME: insert proper C++ library support
- ld_shlibs_CXX=no
- ;;
- esac
- ;;
- solaris*)
- case $cc_basename in
- CC*)
- # Sun C++ 4.2, 5.x and Centerline C++
- archive_cmds_need_lc_CXX=yes
- no_undefined_flag_CXX=' -zdefs'
- archive_cmds_CXX='$CC -G${allow_undefined_flag} -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
- archive_expsym_cmds_CXX='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~
- $CC -G${allow_undefined_flag} ${wl}-M ${wl}$lib.exp -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$rm $lib.exp'
-
- hardcode_libdir_flag_spec_CXX='-R$libdir'
- hardcode_shlibpath_var_CXX=no
- case $host_os in
- solaris2.[0-5] | solaris2.[0-5].*) ;;
- *)
- # The C++ compiler is used as linker so we must use $wl
- # flag to pass the commands to the underlying system
- # linker. We must also pass each convience library through
- # to the system linker between allextract/defaultextract.
- # The C++ compiler will combine linker options so we
- # cannot just pass the convience library names through
- # without $wl.
- # Supported since Solaris 2.6 (maybe 2.5.1?)
- whole_archive_flag_spec_CXX='${wl}-z ${wl}allextract`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}-z ${wl}defaultextract'
- ;;
- esac
- link_all_deplibs_CXX=yes
-
- output_verbose_link_cmd='echo'
-
- # Archives containing C++ object files must be created using
- # "CC -xar", where "CC" is the Sun C++ compiler. This is
- # necessary to make sure instantiated templates are included
- # in the archive.
- old_archive_cmds_CXX='$CC -xar -o $oldlib $oldobjs'
- ;;
- gcx*)
- # Green Hills C++ Compiler
- archive_cmds_CXX='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib'
-
- # The C++ compiler must be used to create the archive.
- old_archive_cmds_CXX='$CC $LDFLAGS -archive -o $oldlib $oldobjs'
- ;;
- *)
- # GNU C++ compiler with Solaris linker
- if test "$GXX" = yes && test "$with_gnu_ld" = no; then
- no_undefined_flag_CXX=' ${wl}-z ${wl}defs'
- if $CC --version | grep -v '^2\.7' > /dev/null; then
- archive_cmds_CXX='$CC -shared -nostdlib $LDFLAGS $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib'
- archive_expsym_cmds_CXX='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~
- $CC -shared -nostdlib ${wl}-M $wl$lib.exp -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$rm $lib.exp'
-
- # Commands to make compiler produce verbose output that lists
- # what "hidden" libraries, object files and flags are used when
- # linking a shared library.
- output_verbose_link_cmd="$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep \"\-L\""
- else
- # g++ 2.7 appears to require `-G' NOT `-shared' on this
- # platform.
- archive_cmds_CXX='$CC -G -nostdlib $LDFLAGS $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib'
- archive_expsym_cmds_CXX='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~
- $CC -G -nostdlib ${wl}-M $wl$lib.exp -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$rm $lib.exp'
-
- # Commands to make compiler produce verbose output that lists
- # what "hidden" libraries, object files and flags are used when
- # linking a shared library.
- output_verbose_link_cmd="$CC -G $CFLAGS -v conftest.$objext 2>&1 | grep \"\-L\""
- fi
-
- hardcode_libdir_flag_spec_CXX='${wl}-R $wl$libdir'
- fi
- ;;
- esac
- ;;
- sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[01].[10]* | unixware7* | sco3.2v5.0.[024]*)
- no_undefined_flag_CXX='${wl}-z,text'
- archive_cmds_need_lc_CXX=no
- hardcode_shlibpath_var_CXX=no
- runpath_var='LD_RUN_PATH'
-
- case $cc_basename in
- CC*)
- archive_cmds_CXX='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
- archive_expsym_cmds_CXX='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
- ;;
- *)
- archive_cmds_CXX='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
- archive_expsym_cmds_CXX='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
- ;;
- esac
- ;;
- sysv5* | sco3.2v5* | sco5v6*)
- # Note: We can NOT use -z defs as we might desire, because we do not
- # link with -lc, and that would cause any symbols used from libc to
- # always be unresolved, which means just about no library would
- # ever link correctly. If we're not using GNU ld we use -z text
- # though, which does catch some bad symbols but isn't as heavy-handed
- # as -z defs.
- # For security reasons, it is highly recommended that you always
- # use absolute paths for naming shared libraries, and exclude the
- # DT_RUNPATH tag from executables and libraries. But doing so
- # requires that you compile everything twice, which is a pain.
- # So that behaviour is only enabled if SCOABSPATH is set to a
- # non-empty value in the environment. Most likely only useful for
- # creating official distributions of packages.
- # This is a hack until libtool officially supports absolute path
- # names for shared libraries.
- no_undefined_flag_CXX='${wl}-z,text'
- allow_undefined_flag_CXX='${wl}-z,nodefs'
- archive_cmds_need_lc_CXX=no
- hardcode_shlibpath_var_CXX=no
- hardcode_libdir_flag_spec_CXX='`test -z "$SCOABSPATH" && echo ${wl}-R,$libdir`'
- hardcode_libdir_separator_CXX=':'
- link_all_deplibs_CXX=yes
- export_dynamic_flag_spec_CXX='${wl}-Bexport'
- runpath_var='LD_RUN_PATH'
-
- case $cc_basename in
- CC*)
- archive_cmds_CXX='$CC -G ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags'
- archive_expsym_cmds_CXX='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags'
- ;;
- *)
- archive_cmds_CXX='$CC -shared ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags'
- archive_expsym_cmds_CXX='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags'
- ;;
- esac
- ;;
- tandem*)
- case $cc_basename in
- NCC*)
- # NonStop-UX NCC 3.20
- # FIXME: insert proper C++ library support
- ld_shlibs_CXX=no
- ;;
- *)
- # FIXME: insert proper C++ library support
- ld_shlibs_CXX=no
- ;;
- esac
- ;;
- vxworks*)
- # FIXME: insert proper C++ library support
- ld_shlibs_CXX=no
- ;;
- *)
- # FIXME: insert proper C++ library support
- ld_shlibs_CXX=no
- ;;
-esac
-echo "$as_me:$LINENO: result: $ld_shlibs_CXX" >&5
-echo "${ECHO_T}$ld_shlibs_CXX" >&6
-test "$ld_shlibs_CXX" = no && can_build_shared=no
-
-GCC_CXX="$GXX"
-LD_CXX="$LD"
-
-
-cat > conftest.$ac_ext <<EOF
-class Foo
-{
-public:
- Foo (void) { a = 0; }
-private:
- int a;
-};
-EOF
-
-if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
- (eval $ac_compile) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; then
- # Parse the compiler output and extract the necessary
- # objects, libraries and library flags.
-
- # Sentinel used to keep track of whether or not we are before
- # the conftest object file.
- pre_test_object_deps_done=no
-
- # The `*' in the case matches for architectures that use `case' in
- # $output_verbose_cmd can trigger glob expansion during the loop
- # eval without this substitution.
- output_verbose_link_cmd=`$echo "X$output_verbose_link_cmd" | $Xsed -e "$no_glob_subst"`
-
- for p in `eval $output_verbose_link_cmd`; do
- case $p in
-
- -L* | -R* | -l*)
- # Some compilers place space between "-{L,R}" and the path.
- # Remove the space.
- if test $p = "-L" \
- || test $p = "-R"; then
- prev=$p
- continue
- else
- prev=
- fi
-
- if test "$pre_test_object_deps_done" = no; then
- case $p in
- -L* | -R*)
- # Internal compiler library paths should come after those
- # provided the user. The postdeps already come after the
- # user supplied libs so there is no need to process them.
- if test -z "$compiler_lib_search_path_CXX"; then
- compiler_lib_search_path_CXX="${prev}${p}"
- else
- compiler_lib_search_path_CXX="${compiler_lib_search_path_CXX} ${prev}${p}"
- fi
- ;;
- # The "-l" case would never come before the object being
- # linked, so don't bother handling this case.
- esac
- else
- if test -z "$postdeps_CXX"; then
- postdeps_CXX="${prev}${p}"
- else
- postdeps_CXX="${postdeps_CXX} ${prev}${p}"
- fi
- fi
- ;;
-
- *.$objext)
- # This assumes that the test object file only shows up
- # once in the compiler output.
- if test "$p" = "conftest.$objext"; then
- pre_test_object_deps_done=yes
- continue
- fi
-
- if test "$pre_test_object_deps_done" = no; then
- if test -z "$predep_objects_CXX"; then
- predep_objects_CXX="$p"
- else
- predep_objects_CXX="$predep_objects_CXX $p"
- fi
- else
- if test -z "$postdep_objects_CXX"; then
- postdep_objects_CXX="$p"
- else
- postdep_objects_CXX="$postdep_objects_CXX $p"
- fi
- fi
- ;;
-
- *) ;; # Ignore the rest.
-
- esac
- done
-
- # Clean up.
- rm -f a.out a.exe
-else
- echo "libtool.m4: error: problem compiling CXX test program"
-fi
-
-$rm -f confest.$objext
-
-# PORTME: override above test on systems where it is broken
-case $host_os in
-interix3*)
- # Interix 3.5 installs completely hosed .la files for C++, so rather than
- # hack all around it, let's just trust "g++" to DTRT.
- predep_objects_CXX=
- postdep_objects_CXX=
- postdeps_CXX=
- ;;
-
-solaris*)
- case $cc_basename in
- CC*)
- # Adding this requires a known-good setup of shared libraries for
- # Sun compiler versions before 5.6, else PIC objects from an old
- # archive will be linked into the output, leading to subtle bugs.
- postdeps_CXX='-lCstd -lCrun'
- ;;
- esac
- ;;
-esac
-
-
-case " $postdeps_CXX " in
-*" -lc "*) archive_cmds_need_lc_CXX=no ;;
-esac
-
-lt_prog_compiler_wl_CXX=
-lt_prog_compiler_pic_CXX=
-lt_prog_compiler_static_CXX=
-
-echo "$as_me:$LINENO: checking for $compiler option to produce PIC" >&5
-echo $ECHO_N "checking for $compiler option to produce PIC... $ECHO_C" >&6
-
- # C++ specific cases for pic, static, wl, etc.
- if test "$GXX" = yes; then
- lt_prog_compiler_wl_CXX='-Wl,'
- lt_prog_compiler_static_CXX='-static'
-
- case $host_os in
- aix*)
- # All AIX code is PIC.
- if test "$host_cpu" = ia64; then
- # AIX 5 now supports IA64 processor
- lt_prog_compiler_static_CXX='-Bstatic'
- fi
- ;;
- amigaos*)
- # FIXME: we need at least 68020 code to build shared libraries, but
- # adding the `-m68020' flag to GCC prevents building anything better,
- # like `-m68040'.
- lt_prog_compiler_pic_CXX='-m68020 -resident32 -malways-restore-a4'
- ;;
- beos* | cygwin* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*)
- # PIC is the default for these OSes.
- ;;
- mingw* | os2* | pw32*)
- # This hack is so that the source file can tell whether it is being
- # built for inclusion in a dll (and should export symbols for example).
- lt_prog_compiler_pic_CXX='-DDLL_EXPORT'
- ;;
- darwin* | rhapsody*)
- # PIC is the default on this platform
- # Common symbols not allowed in MH_DYLIB files
- lt_prog_compiler_pic_CXX='-fno-common'
- ;;
- *djgpp*)
- # DJGPP does not support shared libraries at all
- lt_prog_compiler_pic_CXX=
- ;;
- interix3*)
- # Interix 3.x gcc -fpic/-fPIC options generate broken code.
- # Instead, we relocate shared libraries at runtime.
- ;;
- sysv4*MP*)
- if test -d /usr/nec; then
- lt_prog_compiler_pic_CXX=-Kconform_pic
- fi
- ;;
- hpux*)
- # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but
- # not for PA HP-UX.
- case $host_cpu in
- hppa*64*|ia64*)
- ;;
- *)
- lt_prog_compiler_pic_CXX='-fPIC'
- ;;
- esac
- ;;
- *)
- lt_prog_compiler_pic_CXX='-fPIC'
- ;;
- esac
- else
- case $host_os in
- aix4* | aix5*)
- # All AIX code is PIC.
- if test "$host_cpu" = ia64; then
- # AIX 5 now supports IA64 processor
- lt_prog_compiler_static_CXX='-Bstatic'
- else
- lt_prog_compiler_static_CXX='-bnso -bI:/lib/syscalls.exp'
- fi
- ;;
- chorus*)
- case $cc_basename in
- cxch68*)
- # Green Hills C++ Compiler
- # _LT_AC_TAGVAR(lt_prog_compiler_static, CXX)="--no_auto_instantiation -u __main -u __premain -u _abort -r $COOL_DIR/lib/libOrb.a $MVME_DIR/lib/CC/libC.a $MVME_DIR/lib/classix/libcx.s.a"
- ;;
- esac
- ;;
- darwin*)
- # PIC is the default on this platform
- # Common symbols not allowed in MH_DYLIB files
- case $cc_basename in
- xlc*)
- lt_prog_compiler_pic_CXX='-qnocommon'
- lt_prog_compiler_wl_CXX='-Wl,'
- ;;
- esac
- ;;
- dgux*)
- case $cc_basename in
- ec++*)
- lt_prog_compiler_pic_CXX='-KPIC'
- ;;
- ghcx*)
- # Green Hills C++ Compiler
- lt_prog_compiler_pic_CXX='-pic'
- ;;
- *)
- ;;
- esac
- ;;
- freebsd* | kfreebsd*-gnu | dragonfly*)
- # FreeBSD uses GNU C++
- ;;
- hpux9* | hpux10* | hpux11*)
- case $cc_basename in
- CC*)
- lt_prog_compiler_wl_CXX='-Wl,'
- lt_prog_compiler_static_CXX='${wl}-a ${wl}archive'
- if test "$host_cpu" != ia64; then
- lt_prog_compiler_pic_CXX='+Z'
- fi
- ;;
- aCC*)
- lt_prog_compiler_wl_CXX='-Wl,'
- lt_prog_compiler_static_CXX='${wl}-a ${wl}archive'
- case $host_cpu in
- hppa*64*|ia64*)
- # +Z the default
- ;;
- *)
- lt_prog_compiler_pic_CXX='+Z'
- ;;
- esac
- ;;
- *)
- ;;
- esac
- ;;
- interix*)
- # This is c89, which is MS Visual C++ (no shared libs)
- # Anyone wants to do a port?
- ;;
- irix5* | irix6* | nonstopux*)
- case $cc_basename in
- CC*)
- lt_prog_compiler_wl_CXX='-Wl,'
- lt_prog_compiler_static_CXX='-non_shared'
- # CC pic flag -KPIC is the default.
- ;;
- *)
- ;;
- esac
- ;;
- linux*)
- case $cc_basename in
- KCC*)
- # KAI C++ Compiler
- lt_prog_compiler_wl_CXX='--backend -Wl,'
- lt_prog_compiler_pic_CXX='-fPIC'
- ;;
- icpc* | ecpc*)
- # Intel C++
- lt_prog_compiler_wl_CXX='-Wl,'
- lt_prog_compiler_pic_CXX='-KPIC'
- lt_prog_compiler_static_CXX='-static'
- ;;
- pgCC*)
- # Portland Group C++ compiler.
- lt_prog_compiler_wl_CXX='-Wl,'
- lt_prog_compiler_pic_CXX='-fpic'
- lt_prog_compiler_static_CXX='-Bstatic'
- ;;
- cxx*)
- # Compaq C++
- # Make sure the PIC flag is empty. It appears that all Alpha
- # Linux and Compaq Tru64 Unix objects are PIC.
- lt_prog_compiler_pic_CXX=
- lt_prog_compiler_static_CXX='-non_shared'
- ;;
- *)
- ;;
- esac
- ;;
- lynxos*)
- ;;
- m88k*)
- ;;
- mvs*)
- case $cc_basename in
- cxx*)
- lt_prog_compiler_pic_CXX='-W c,exportall'
- ;;
- *)
- ;;
- esac
- ;;
- netbsd* | netbsdelf*-gnu | knetbsd*-gnu)
- ;;
- osf3* | osf4* | osf5*)
- case $cc_basename in
- KCC*)
- lt_prog_compiler_wl_CXX='--backend -Wl,'
- ;;
- RCC*)
- # Rational C++ 2.4.1
- lt_prog_compiler_pic_CXX='-pic'
- ;;
- cxx*)
- # Digital/Compaq C++
- lt_prog_compiler_wl_CXX='-Wl,'
- # Make sure the PIC flag is empty. It appears that all Alpha
- # Linux and Compaq Tru64 Unix objects are PIC.
- lt_prog_compiler_pic_CXX=
- lt_prog_compiler_static_CXX='-non_shared'
- ;;
- *)
- ;;
- esac
- ;;
- psos*)
- ;;
- solaris*)
- case $cc_basename in
- CC*)
- # Sun C++ 4.2, 5.x and Centerline C++
- lt_prog_compiler_pic_CXX='-KPIC'
- lt_prog_compiler_static_CXX='-Bstatic'
- lt_prog_compiler_wl_CXX='-Qoption ld '
- ;;
- gcx*)
- # Green Hills C++ Compiler
- lt_prog_compiler_pic_CXX='-PIC'
- ;;
- *)
- ;;
- esac
- ;;
- sunos4*)
- case $cc_basename in
- CC*)
- # Sun C++ 4.x
- lt_prog_compiler_pic_CXX='-pic'
- lt_prog_compiler_static_CXX='-Bstatic'
- ;;
- lcc*)
- # Lucid
- lt_prog_compiler_pic_CXX='-pic'
- ;;
- *)
- ;;
- esac
- ;;
- tandem*)
- case $cc_basename in
- NCC*)
- # NonStop-UX NCC 3.20
- lt_prog_compiler_pic_CXX='-KPIC'
- ;;
- *)
- ;;
- esac
- ;;
- sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*)
- case $cc_basename in
- CC*)
- lt_prog_compiler_wl_CXX='-Wl,'
- lt_prog_compiler_pic_CXX='-KPIC'
- lt_prog_compiler_static_CXX='-Bstatic'
- ;;
- esac
- ;;
- vxworks*)
- ;;
- *)
- lt_prog_compiler_can_build_shared_CXX=no
- ;;
- esac
- fi
-
-echo "$as_me:$LINENO: result: $lt_prog_compiler_pic_CXX" >&5
-echo "${ECHO_T}$lt_prog_compiler_pic_CXX" >&6
-
-#
-# Check to make sure the PIC flag actually works.
-#
-if test -n "$lt_prog_compiler_pic_CXX"; then
-
-echo "$as_me:$LINENO: checking if $compiler PIC flag $lt_prog_compiler_pic_CXX works" >&5
-echo $ECHO_N "checking if $compiler PIC flag $lt_prog_compiler_pic_CXX works... $ECHO_C" >&6
-if test "${lt_prog_compiler_pic_works_CXX+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- lt_prog_compiler_pic_works_CXX=no
- ac_outfile=conftest.$ac_objext
- printf "$lt_simple_compile_test_code" > conftest.$ac_ext
- lt_compiler_flag="$lt_prog_compiler_pic_CXX -DPIC"
- # Insert the option either (1) after the last *FLAGS variable, or
- # (2) before a word containing "conftest.", or (3) at the end.
- # Note that $ac_compile itself does not contain backslashes and begins
- # with a dollar sign (not a hyphen), so the echo should work correctly.
- # The option is referenced via a variable to avoid confusing sed.
- lt_compile=`echo "$ac_compile" | $SED \
- -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
- -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
- -e 's:$: $lt_compiler_flag:'`
- (eval echo "\"\$as_me:11493: $lt_compile\"" >&5)
- (eval "$lt_compile" 2>conftest.err)
- ac_status=$?
- cat conftest.err >&5
- echo "$as_me:11497: \$? = $ac_status" >&5
- if (exit $ac_status) && test -s "$ac_outfile"; then
- # The compiler can only warn and ignore the option if not recognized
- # So say no if there are warnings other than the usual output.
- $echo "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' >conftest.exp
- $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2
- if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then
- lt_prog_compiler_pic_works_CXX=yes
- fi
- fi
- $rm conftest*
-
-fi
-echo "$as_me:$LINENO: result: $lt_prog_compiler_pic_works_CXX" >&5
-echo "${ECHO_T}$lt_prog_compiler_pic_works_CXX" >&6
-
-if test x"$lt_prog_compiler_pic_works_CXX" = xyes; then
- case $lt_prog_compiler_pic_CXX in
- "" | " "*) ;;
- *) lt_prog_compiler_pic_CXX=" $lt_prog_compiler_pic_CXX" ;;
- esac
-else
- lt_prog_compiler_pic_CXX=
- lt_prog_compiler_can_build_shared_CXX=no
-fi
-
-fi
-case $host_os in
- # For platforms which do not support PIC, -DPIC is meaningless:
- *djgpp*)
- lt_prog_compiler_pic_CXX=
- ;;
- *)
- lt_prog_compiler_pic_CXX="$lt_prog_compiler_pic_CXX -DPIC"
- ;;
-esac
-
-#
-# Check to make sure the static flag actually works.
-#
-wl=$lt_prog_compiler_wl_CXX eval lt_tmp_static_flag=\"$lt_prog_compiler_static_CXX\"
-echo "$as_me:$LINENO: checking if $compiler static flag $lt_tmp_static_flag works" >&5
-echo $ECHO_N "checking if $compiler static flag $lt_tmp_static_flag works... $ECHO_C" >&6
-if test "${lt_prog_compiler_static_works_CXX+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- lt_prog_compiler_static_works_CXX=no
- save_LDFLAGS="$LDFLAGS"
- LDFLAGS="$LDFLAGS $lt_tmp_static_flag"
- printf "$lt_simple_link_test_code" > conftest.$ac_ext
- if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then
- # The linker can only warn and ignore the option if not recognized
- # So say no if there are warnings
- if test -s conftest.err; then
- # Append any errors to the config.log.
- cat conftest.err 1>&5
- $echo "X$_lt_linker_boilerplate" | $Xsed -e '/^$/d' > conftest.exp
- $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2
- if diff conftest.exp conftest.er2 >/dev/null; then
- lt_prog_compiler_static_works_CXX=yes
- fi
- else
- lt_prog_compiler_static_works_CXX=yes
- fi
- fi
- $rm conftest*
- LDFLAGS="$save_LDFLAGS"
-
-fi
-echo "$as_me:$LINENO: result: $lt_prog_compiler_static_works_CXX" >&5
-echo "${ECHO_T}$lt_prog_compiler_static_works_CXX" >&6
-
-if test x"$lt_prog_compiler_static_works_CXX" = xyes; then
- :
-else
- lt_prog_compiler_static_CXX=
-fi
-
-
-echo "$as_me:$LINENO: checking if $compiler supports -c -o file.$ac_objext" >&5
-echo $ECHO_N "checking if $compiler supports -c -o file.$ac_objext... $ECHO_C" >&6
-if test "${lt_cv_prog_compiler_c_o_CXX+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- lt_cv_prog_compiler_c_o_CXX=no
- $rm -r conftest 2>/dev/null
- mkdir conftest
- cd conftest
- mkdir out
- printf "$lt_simple_compile_test_code" > conftest.$ac_ext
-
- lt_compiler_flag="-o out/conftest2.$ac_objext"
- # Insert the option either (1) after the last *FLAGS variable, or
- # (2) before a word containing "conftest.", or (3) at the end.
- # Note that $ac_compile itself does not contain backslashes and begins
- # with a dollar sign (not a hyphen), so the echo should work correctly.
- lt_compile=`echo "$ac_compile" | $SED \
- -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
- -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
- -e 's:$: $lt_compiler_flag:'`
- (eval echo "\"\$as_me:11597: $lt_compile\"" >&5)
- (eval "$lt_compile" 2>out/conftest.err)
- ac_status=$?
- cat out/conftest.err >&5
- echo "$as_me:11601: \$? = $ac_status" >&5
- if (exit $ac_status) && test -s out/conftest2.$ac_objext
- then
- # The compiler can only warn and ignore the option if not recognized
- # So say no if there are warnings
- $echo "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' > out/conftest.exp
- $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2
- if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then
- lt_cv_prog_compiler_c_o_CXX=yes
- fi
- fi
- chmod u+w . 2>&5
- $rm conftest*
- # SGI C++ compiler will create directory out/ii_files/ for
- # template instantiation
- test -d out/ii_files && $rm out/ii_files/* && rmdir out/ii_files
- $rm out/* && rmdir out
- cd ..
- rmdir conftest
- $rm conftest*
-
-fi
-echo "$as_me:$LINENO: result: $lt_cv_prog_compiler_c_o_CXX" >&5
-echo "${ECHO_T}$lt_cv_prog_compiler_c_o_CXX" >&6
-
-
-hard_links="nottested"
-if test "$lt_cv_prog_compiler_c_o_CXX" = no && test "$need_locks" != no; then
- # do not overwrite the value of need_locks provided by the user
- echo "$as_me:$LINENO: checking if we can lock with hard links" >&5
-echo $ECHO_N "checking if we can lock with hard links... $ECHO_C" >&6
- hard_links=yes
- $rm conftest*
- ln conftest.a conftest.b 2>/dev/null && hard_links=no
- touch conftest.a
- ln conftest.a conftest.b 2>&5 || hard_links=no
- ln conftest.a conftest.b 2>/dev/null && hard_links=no
- echo "$as_me:$LINENO: result: $hard_links" >&5
-echo "${ECHO_T}$hard_links" >&6
- if test "$hard_links" = no; then
- { echo "$as_me:$LINENO: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&5
-echo "$as_me: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&2;}
- need_locks=warn
- fi
-else
- need_locks=no
-fi
-
-echo "$as_me:$LINENO: checking whether the $compiler linker ($LD) supports shared libraries" >&5
-echo $ECHO_N "checking whether the $compiler linker ($LD) supports shared libraries... $ECHO_C" >&6
-
- export_symbols_cmds_CXX='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols'
- case $host_os in
- aix4* | aix5*)
- # If we're using GNU nm, then we don't want the "-C" option.
- # -C means demangle to AIX nm, but means don't demangle with GNU nm
- if $NM -V 2>&1 | grep 'GNU' > /dev/null; then
- export_symbols_cmds_CXX='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$2 == "T") || (\$2 == "D") || (\$2 == "B")) && (substr(\$3,1,1) != ".")) { print \$3 } }'\'' | sort -u > $export_symbols'
- else
- export_symbols_cmds_CXX='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\$2 == "T") || (\$2 == "D") || (\$2 == "B")) && (substr(\$3,1,1) != ".")) { print \$3 } }'\'' | sort -u > $export_symbols'
- fi
- ;;
- pw32*)
- export_symbols_cmds_CXX="$ltdll_cmds"
- ;;
- cygwin* | mingw*)
- export_symbols_cmds_CXX='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[BCDGRS] /s/.* \([^ ]*\)/\1 DATA/;/^.* __nm__/s/^.* __nm__\([^ ]*\) [^ ]*/\1 DATA/;/^I /d;/^[AITW] /s/.* //'\'' | sort | uniq > $export_symbols'
- ;;
- kfreebsd*-gnu)
- link_all_deplibs_CXX=no
- ;;
- linux*)
- link_all_deplibs_CXX=no
- ;;
- *)
- export_symbols_cmds_CXX='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols'
- ;;
- esac
-
-echo "$as_me:$LINENO: result: $ld_shlibs_CXX" >&5
-echo "${ECHO_T}$ld_shlibs_CXX" >&6
-test "$ld_shlibs_CXX" = no && can_build_shared=no
-
-#
-# Do we need to explicitly link libc?
-#
-case "x$archive_cmds_need_lc_CXX" in
-x|xyes)
- # Assume -lc should be added
- archive_cmds_need_lc_CXX=yes
-
- if test "$enable_shared" = yes && test "$GCC" = yes; then
- case $archive_cmds_CXX in
- *'~'*)
- # FIXME: we may have to deal with multi-command sequences.
- ;;
- '$CC '*)
- # Test whether the compiler implicitly links with -lc since on some
- # systems, -lgcc has to come before -lc. If gcc already passes -lc
- # to ld, don't add -lc before -lgcc.
- echo "$as_me:$LINENO: checking whether -lc should be explicitly linked in" >&5
-echo $ECHO_N "checking whether -lc should be explicitly linked in... $ECHO_C" >&6
- $rm conftest*
- printf "$lt_simple_compile_test_code" > conftest.$ac_ext
-
- if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
- (eval $ac_compile) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } 2>conftest.err; then
- soname=conftest
- lib=conftest
- libobjs=conftest.$ac_objext
- deplibs=
- wl=$lt_prog_compiler_wl_CXX
- pic_flag=$lt_prog_compiler_pic_CXX
- compiler_flags=-v
- linker_flags=-v
- verstring=
- output_objdir=.
- libname=conftest
- lt_save_allow_undefined_flag=$allow_undefined_flag_CXX
- allow_undefined_flag_CXX=
- if { (eval echo "$as_me:$LINENO: \"$archive_cmds_CXX 2\>\&1 \| grep \" -lc \" \>/dev/null 2\>\&1\"") >&5
- (eval $archive_cmds_CXX 2\>\&1 \| grep \" -lc \" \>/dev/null 2\>\&1) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }
- then
- archive_cmds_need_lc_CXX=no
- else
- archive_cmds_need_lc_CXX=yes
- fi
- allow_undefined_flag_CXX=$lt_save_allow_undefined_flag
- else
- cat conftest.err 1>&5
- fi
- $rm conftest*
- echo "$as_me:$LINENO: result: $archive_cmds_need_lc_CXX" >&5
-echo "${ECHO_T}$archive_cmds_need_lc_CXX" >&6
- ;;
- esac
- fi
- ;;
-esac
-
-echo "$as_me:$LINENO: checking dynamic linker characteristics" >&5
-echo $ECHO_N "checking dynamic linker characteristics... $ECHO_C" >&6
-library_names_spec=
-libname_spec='lib$name'
-soname_spec=
-shrext_cmds=".so"
-postinstall_cmds=
-postuninstall_cmds=
-finish_cmds=
-finish_eval=
-shlibpath_var=
-shlibpath_overrides_runpath=unknown
-version_type=none
-dynamic_linker="$host_os ld.so"
-sys_lib_dlsearch_path_spec="/lib /usr/lib"
-if test "$GCC" = yes; then
- sys_lib_search_path_spec=`$CC -print-search-dirs | grep "^libraries:" | $SED -e "s/^libraries://" -e "s,=/,/,g"`
- if echo "$sys_lib_search_path_spec" | grep ';' >/dev/null ; then
- # if the path contains ";" then we assume it to be the separator
- # otherwise default to the standard path separator (i.e. ":") - it is
- # assumed that no part of a normal pathname contains ";" but that should
- # okay in the real world where ";" in dirpaths is itself problematic.
- sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'`
- else
- sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"`
- fi
-else
- sys_lib_search_path_spec="/lib /usr/lib /usr/local/lib"
-fi
-need_lib_prefix=unknown
-hardcode_into_libs=no
-
-# when you set need_version to no, make sure it does not cause -set_version
-# flags to be left without arguments
-need_version=unknown
-
-case $host_os in
-aix3*)
- version_type=linux
- library_names_spec='${libname}${release}${shared_ext}$versuffix $libname.a'
- shlibpath_var=LIBPATH
-
- # AIX 3 has no versioning support, so we append a major version to the name.
- soname_spec='${libname}${release}${shared_ext}$major'
- ;;
-
-aix4* | aix5*)
- version_type=linux
- need_lib_prefix=no
- need_version=no
- hardcode_into_libs=yes
- if test "$host_cpu" = ia64; then
- # AIX 5 supports IA64
- library_names_spec='${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext}$versuffix $libname${shared_ext}'
- shlibpath_var=LD_LIBRARY_PATH
- else
- # With GCC up to 2.95.x, collect2 would create an import file
- # for dependence libraries. The import file would start with
- # the line `#! .'. This would cause the generated library to
- # depend on `.', always an invalid library. This was fixed in
- # development snapshots of GCC prior to 3.0.
- case $host_os in
- aix4 | aix4.[01] | aix4.[01].*)
- if { echo '#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 97)'
- echo ' yes '
- echo '#endif'; } | ${CC} -E - | grep yes > /dev/null; then
- :
- else
- can_build_shared=no
- fi
- ;;
- esac
- # AIX (on Power*) has no versioning support, so currently we can not hardcode correct
- # soname into executable. Probably we can add versioning support to
- # collect2, so additional links can be useful in future.
- if test "$aix_use_runtimelinking" = yes; then
- # If using run time linking (on AIX 4.2 or later) use lib<name>.so
- # instead of lib<name>.a to let people know that these are not
- # typical AIX shared libraries.
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
- else
- # We preserve .a as extension for shared libraries through AIX4.2
- # and later when we are not doing run time linking.
- library_names_spec='${libname}${release}.a $libname.a'
- soname_spec='${libname}${release}${shared_ext}$major'
- fi
- shlibpath_var=LIBPATH
- fi
- ;;
-
-amigaos*)
- library_names_spec='$libname.ixlibrary $libname.a'
- # Create ${libname}_ixlibrary.a entries in /sys/libs.
- finish_eval='for lib in `ls $libdir/*.ixlibrary 2>/dev/null`; do libname=`$echo "X$lib" | $Xsed -e '\''s%^.*/\([^/]*\)\.ixlibrary$%\1%'\''`; test $rm /sys/libs/${libname}_ixlibrary.a; $show "cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a"; cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a || exit 1; done'
- ;;
-
-beos*)
- library_names_spec='${libname}${shared_ext}'
- dynamic_linker="$host_os ld.so"
- shlibpath_var=LIBRARY_PATH
- ;;
-
-bsdi[45]*)
- version_type=linux
- need_version=no
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
- soname_spec='${libname}${release}${shared_ext}$major'
- finish_cmds='PATH="\$PATH:/sbin" ldconfig $libdir'
- shlibpath_var=LD_LIBRARY_PATH
- sys_lib_search_path_spec="/shlib /usr/lib /usr/X11/lib /usr/contrib/lib /lib /usr/local/lib"
- sys_lib_dlsearch_path_spec="/shlib /usr/lib /usr/local/lib"
- # the default ld.so.conf also contains /usr/contrib/lib and
- # /usr/X11R6/lib (/usr/X11 is a link to /usr/X11R6), but let us allow
- # libtool to hard-code these into programs
- ;;
-
-cygwin* | mingw* | pw32*)
- version_type=windows
- shrext_cmds=".dll"
- need_version=no
- need_lib_prefix=no
-
- case $GCC,$host_os in
- yes,cygwin* | yes,mingw* | yes,pw32*)
- library_names_spec='$libname.dll.a'
- # DLL is installed to $(libdir)/../bin by postinstall_cmds
- postinstall_cmds='base_file=`basename \${file}`~
- dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i;echo \$dlname'\''`~
- dldir=$destdir/`dirname \$dlpath`~
- test -d \$dldir || mkdir -p \$dldir~
- $install_prog $dir/$dlname \$dldir/$dlname~
- chmod a+x \$dldir/$dlname'
- postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~
- dlpath=$dir/\$dldll~
- $rm \$dlpath'
- shlibpath_overrides_runpath=yes
-
- case $host_os in
- cygwin*)
- # Cygwin DLLs use 'cyg' prefix rather than 'lib'
- soname_spec='`echo ${libname} | sed -e 's/^lib/cyg/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}'
- sys_lib_search_path_spec="/usr/lib /lib/w32api /lib /usr/local/lib"
- ;;
- mingw*)
- # MinGW DLLs use traditional 'lib' prefix
- soname_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}'
- sys_lib_search_path_spec=`$CC -print-search-dirs | grep "^libraries:" | $SED -e "s/^libraries://" -e "s,=/,/,g"`
- if echo "$sys_lib_search_path_spec" | grep ';[c-zC-Z]:/' >/dev/null; then
- # It is most probably a Windows format PATH printed by
- # mingw gcc, but we are running on Cygwin. Gcc prints its search
- # path with ; separators, and with drive letters. We can handle the
- # drive letters (cygwin fileutils understands them), so leave them,
- # especially as we might pass files found there to a mingw objdump,
- # which wouldn't understand a cygwinified path. Ahh.
- sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'`
- else
- sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"`
- fi
- ;;
- pw32*)
- # pw32 DLLs use 'pw' prefix rather than 'lib'
- library_names_spec='`echo ${libname} | sed -e 's/^lib/pw/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}'
- ;;
- esac
- ;;
-
- *)
- library_names_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext} $libname.lib'
- ;;
- esac
- dynamic_linker='Win32 ld.exe'
- # FIXME: first we should search . and the directory the executable is in
- shlibpath_var=PATH
- ;;
-
-darwin* | rhapsody*)
- dynamic_linker="$host_os dyld"
- version_type=darwin
- need_lib_prefix=no
- need_version=no
- library_names_spec='${libname}${release}${versuffix}$shared_ext ${libname}${release}${major}$shared_ext ${libname}$shared_ext'
- soname_spec='${libname}${release}${major}$shared_ext'
- shlibpath_overrides_runpath=yes
- shlibpath_var=DYLD_LIBRARY_PATH
- shrext_cmds='`test .$module = .yes && echo .so || echo .dylib`'
- # Apple's gcc prints 'gcc -print-search-dirs' doesn't operate the same.
- if test "$GCC" = yes; then
- sys_lib_search_path_spec=`$CC -print-search-dirs | tr "\n" "$PATH_SEPARATOR" | sed -e 's/libraries:/@libraries:/' | tr "@" "\n" | grep "^libraries:" | sed -e "s/^libraries://" -e "s,=/,/,g" -e "s,$PATH_SEPARATOR, ,g" -e "s,.*,& /lib /usr/lib /usr/local/lib,g"`
- else
- sys_lib_search_path_spec='/lib /usr/lib /usr/local/lib'
- fi
- sys_lib_dlsearch_path_spec='/usr/local/lib /lib /usr/lib'
- ;;
-
-dgux*)
- version_type=linux
- need_lib_prefix=no
- need_version=no
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname$shared_ext'
- soname_spec='${libname}${release}${shared_ext}$major'
- shlibpath_var=LD_LIBRARY_PATH
- ;;
-
-freebsd1*)
- dynamic_linker=no
- ;;
-
-kfreebsd*-gnu)
- version_type=linux
- need_lib_prefix=no
- need_version=no
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
- soname_spec='${libname}${release}${shared_ext}$major'
- shlibpath_var=LD_LIBRARY_PATH
- shlibpath_overrides_runpath=no
- hardcode_into_libs=yes
- dynamic_linker='GNU ld.so'
- ;;
-
-freebsd* | dragonfly*)
- # DragonFly does not have aout. When/if they implement a new
- # versioning mechanism, adjust this.
- if test -x /usr/bin/objformat; then
- objformat=`/usr/bin/objformat`
- else
- case $host_os in
- freebsd[123]*) objformat=aout ;;
- *) objformat=elf ;;
- esac
- fi
- version_type=freebsd-$objformat
- case $version_type in
- freebsd-elf*)
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}'
- need_version=no
- need_lib_prefix=no
- ;;
- freebsd-*)
- library_names_spec='${libname}${release}${shared_ext}$versuffix $libname${shared_ext}$versuffix'
- need_version=yes
- ;;
- esac
- shlibpath_var=LD_LIBRARY_PATH
- case $host_os in
- freebsd2*)
- shlibpath_overrides_runpath=yes
- ;;
- freebsd3.[01]* | freebsdelf3.[01]*)
- shlibpath_overrides_runpath=yes
- hardcode_into_libs=yes
- ;;
- freebsd3.[2-9]* | freebsdelf3.[2-9]* | \
- freebsd4.[0-5] | freebsdelf4.[0-5] | freebsd4.1.1 | freebsdelf4.1.1)
- shlibpath_overrides_runpath=no
- hardcode_into_libs=yes
- ;;
- freebsd*) # from 4.6 on
- shlibpath_overrides_runpath=yes
- hardcode_into_libs=yes
- ;;
- esac
- ;;
-
-gnu*)
- version_type=linux
- need_lib_prefix=no
- need_version=no
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}'
- soname_spec='${libname}${release}${shared_ext}$major'
- shlibpath_var=LD_LIBRARY_PATH
- hardcode_into_libs=yes
- ;;
-
-hpux9* | hpux10* | hpux11*)
- # Give a soname corresponding to the major version so that dld.sl refuses to
- # link against other versions.
- version_type=sunos
- need_lib_prefix=no
- need_version=no
- case $host_cpu in
- ia64*)
- shrext_cmds='.so'
- hardcode_into_libs=yes
- dynamic_linker="$host_os dld.so"
- shlibpath_var=LD_LIBRARY_PATH
- shlibpath_overrides_runpath=yes # Unless +noenvvar is specified.
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
- soname_spec='${libname}${release}${shared_ext}$major'
- if test "X$HPUX_IA64_MODE" = X32; then
- sys_lib_search_path_spec="/usr/lib/hpux32 /usr/local/lib/hpux32 /usr/local/lib"
- else
- sys_lib_search_path_spec="/usr/lib/hpux64 /usr/local/lib/hpux64"
- fi
- sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec
- ;;
- hppa*64*)
- shrext_cmds='.sl'
- hardcode_into_libs=yes
- dynamic_linker="$host_os dld.sl"
- shlibpath_var=LD_LIBRARY_PATH # How should we handle SHLIB_PATH
- shlibpath_overrides_runpath=yes # Unless +noenvvar is specified.
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
- soname_spec='${libname}${release}${shared_ext}$major'
- sys_lib_search_path_spec="/usr/lib/pa20_64 /usr/ccs/lib/pa20_64"
- sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec
- ;;
- *)
- shrext_cmds='.sl'
- dynamic_linker="$host_os dld.sl"
- shlibpath_var=SHLIB_PATH
- shlibpath_overrides_runpath=no # +s is required to enable SHLIB_PATH
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
- soname_spec='${libname}${release}${shared_ext}$major'
- ;;
- esac
- # HP-UX runs *really* slowly unless shared libraries are mode 555.
- postinstall_cmds='chmod 555 $lib'
- ;;
-
-interix3*)
- version_type=linux
- need_lib_prefix=no
- need_version=no
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
- soname_spec='${libname}${release}${shared_ext}$major'
- dynamic_linker='Interix 3.x ld.so.1 (PE, like ELF)'
- shlibpath_var=LD_LIBRARY_PATH
- shlibpath_overrides_runpath=no
- hardcode_into_libs=yes
- ;;
-
-irix5* | irix6* | nonstopux*)
- case $host_os in
- nonstopux*) version_type=nonstopux ;;
- *)
- if test "$lt_cv_prog_gnu_ld" = yes; then
- version_type=linux
- else
- version_type=irix
- fi ;;
- esac
- need_lib_prefix=no
- need_version=no
- soname_spec='${libname}${release}${shared_ext}$major'
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext} $libname${shared_ext}'
- case $host_os in
- irix5* | nonstopux*)
- libsuff= shlibsuff=
- ;;
- *)
- case $LD in # libtool.m4 will add one of these switches to LD
- *-32|*"-32 "|*-melf32bsmip|*"-melf32bsmip ")
- libsuff= shlibsuff= libmagic=32-bit;;
- *-n32|*"-n32 "|*-melf32bmipn32|*"-melf32bmipn32 ")
- libsuff=32 shlibsuff=N32 libmagic=N32;;
- *-64|*"-64 "|*-melf64bmip|*"-melf64bmip ")
- libsuff=64 shlibsuff=64 libmagic=64-bit;;
- *) libsuff= shlibsuff= libmagic=never-match;;
- esac
- ;;
- esac
- shlibpath_var=LD_LIBRARY${shlibsuff}_PATH
- shlibpath_overrides_runpath=no
- sys_lib_search_path_spec="/usr/lib${libsuff} /lib${libsuff} /usr/local/lib${libsuff}"
- sys_lib_dlsearch_path_spec="/usr/lib${libsuff} /lib${libsuff}"
- hardcode_into_libs=yes
- ;;
-
-# No shared lib support for Linux oldld, aout, or coff.
-linux*oldld* | linux*aout* | linux*coff*)
- dynamic_linker=no
- ;;
-
-# This must be Linux ELF.
-linux*)
- version_type=linux
- need_lib_prefix=no
- need_version=no
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
- soname_spec='${libname}${release}${shared_ext}$major'
- finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir'
- shlibpath_var=LD_LIBRARY_PATH
- shlibpath_overrides_runpath=no
- # This implies no fast_install, which is unacceptable.
- # Some rework will be needed to allow for fast_install
- # before this can be enabled.
- hardcode_into_libs=yes
-
- # Append ld.so.conf contents to the search path
- if test -f /etc/ld.so.conf; then
- lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s", \$2)); skip = 1; } { if (!skip) print \$0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;s/[:, ]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;/^$/d' | tr '\n' ' '`
- sys_lib_dlsearch_path_spec="/lib /usr/lib $lt_ld_extra"
- fi
-
- # We used to test for /lib/ld.so.1 and disable shared libraries on
- # powerpc, because MkLinux only supported shared libraries with the
- # GNU dynamic linker. Since this was broken with cross compilers,
- # most powerpc-linux boxes support dynamic linking these days and
- # people can always --disable-shared, the test was removed, and we
- # assume the GNU/Linux dynamic linker is in use.
- dynamic_linker='GNU/Linux ld.so'
- ;;
-
-netbsdelf*-gnu)
- version_type=linux
- need_lib_prefix=no
- need_version=no
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
- soname_spec='${libname}${release}${shared_ext}$major'
- shlibpath_var=LD_LIBRARY_PATH
- shlibpath_overrides_runpath=no
- hardcode_into_libs=yes
- dynamic_linker='NetBSD ld.elf_so'
- ;;
-
-knetbsd*-gnu)
- version_type=linux
- need_lib_prefix=no
- need_version=no
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
- soname_spec='${libname}${release}${shared_ext}$major'
- shlibpath_var=LD_LIBRARY_PATH
- shlibpath_overrides_runpath=no
- hardcode_into_libs=yes
- dynamic_linker='GNU ld.so'
- ;;
-
-netbsd*)
- version_type=sunos
- need_lib_prefix=no
- need_version=no
- if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
- finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir'
- dynamic_linker='NetBSD (a.out) ld.so'
- else
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
- soname_spec='${libname}${release}${shared_ext}$major'
- dynamic_linker='NetBSD ld.elf_so'
- fi
- shlibpath_var=LD_LIBRARY_PATH
- shlibpath_overrides_runpath=yes
- hardcode_into_libs=yes
- ;;
-
-newsos6)
- version_type=linux
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
- shlibpath_var=LD_LIBRARY_PATH
- shlibpath_overrides_runpath=yes
- ;;
-
-nto-qnx*)
- version_type=linux
- need_lib_prefix=no
- need_version=no
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
- soname_spec='${libname}${release}${shared_ext}$major'
- shlibpath_var=LD_LIBRARY_PATH
- shlibpath_overrides_runpath=yes
- ;;
-
-openbsd*)
- version_type=sunos
- sys_lib_dlsearch_path_spec="/usr/lib"
- need_lib_prefix=no
- # Some older versions of OpenBSD (3.3 at least) *do* need versioned libs.
- case $host_os in
- openbsd3.3 | openbsd3.3.*) need_version=yes ;;
- *) need_version=no ;;
- esac
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
- finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir'
- shlibpath_var=LD_LIBRARY_PATH
- if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
- case $host_os in
- openbsd2.[89] | openbsd2.[89].*)
- shlibpath_overrides_runpath=no
- ;;
- *)
- shlibpath_overrides_runpath=yes
- ;;
- esac
- else
- shlibpath_overrides_runpath=yes
- fi
- ;;
-
-os2*)
- libname_spec='$name'
- shrext_cmds=".dll"
- need_lib_prefix=no
- library_names_spec='$libname${shared_ext} $libname.a'
- dynamic_linker='OS/2 ld.exe'
- shlibpath_var=LIBPATH
- ;;
-
-osf3* | osf4* | osf5*)
- version_type=osf
- need_lib_prefix=no
- need_version=no
- soname_spec='${libname}${release}${shared_ext}$major'
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
- shlibpath_var=LD_LIBRARY_PATH
- sys_lib_search_path_spec="/usr/shlib /usr/ccs/lib /usr/lib/cmplrs/cc /usr/lib /usr/local/lib /var/shlib"
- sys_lib_dlsearch_path_spec="$sys_lib_search_path_spec"
- ;;
-
-solaris*)
- version_type=linux
- need_lib_prefix=no
- need_version=no
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
- soname_spec='${libname}${release}${shared_ext}$major'
- shlibpath_var=LD_LIBRARY_PATH
- shlibpath_overrides_runpath=yes
- hardcode_into_libs=yes
- # ldd complains unless libraries are executable
- postinstall_cmds='chmod +x $lib'
- ;;
-
-sunos4*)
- version_type=sunos
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
- finish_cmds='PATH="\$PATH:/usr/etc" ldconfig $libdir'
- shlibpath_var=LD_LIBRARY_PATH
- shlibpath_overrides_runpath=yes
- if test "$with_gnu_ld" = yes; then
- need_lib_prefix=no
- fi
- need_version=yes
- ;;
-
-sysv4 | sysv4.3*)
- version_type=linux
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
- soname_spec='${libname}${release}${shared_ext}$major'
- shlibpath_var=LD_LIBRARY_PATH
- case $host_vendor in
- sni)
- shlibpath_overrides_runpath=no
- need_lib_prefix=no
- export_dynamic_flag_spec='${wl}-Blargedynsym'
- runpath_var=LD_RUN_PATH
- ;;
- siemens)
- need_lib_prefix=no
- ;;
- motorola)
- need_lib_prefix=no
- need_version=no
- shlibpath_overrides_runpath=no
- sys_lib_search_path_spec='/lib /usr/lib /usr/ccs/lib'
- ;;
- esac
- ;;
-
-sysv4*MP*)
- if test -d /usr/nec ;then
- version_type=linux
- library_names_spec='$libname${shared_ext}.$versuffix $libname${shared_ext}.$major $libname${shared_ext}'
- soname_spec='$libname${shared_ext}.$major'
- shlibpath_var=LD_LIBRARY_PATH
- fi
- ;;
-
-sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*)
- version_type=freebsd-elf
- need_lib_prefix=no
- need_version=no
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}'
- soname_spec='${libname}${release}${shared_ext}$major'
- shlibpath_var=LD_LIBRARY_PATH
- hardcode_into_libs=yes
- if test "$with_gnu_ld" = yes; then
- sys_lib_search_path_spec='/usr/local/lib /usr/gnu/lib /usr/ccs/lib /usr/lib /lib'
- shlibpath_overrides_runpath=no
- else
- sys_lib_search_path_spec='/usr/ccs/lib /usr/lib'
- shlibpath_overrides_runpath=yes
- case $host_os in
- sco3.2v5*)
- sys_lib_search_path_spec="$sys_lib_search_path_spec /lib"
- ;;
- esac
- fi
- sys_lib_dlsearch_path_spec='/usr/lib'
- ;;
-
-uts4*)
- version_type=linux
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
- soname_spec='${libname}${release}${shared_ext}$major'
- shlibpath_var=LD_LIBRARY_PATH
- ;;
-
-*)
- dynamic_linker=no
- ;;
-esac
-echo "$as_me:$LINENO: result: $dynamic_linker" >&5
-echo "${ECHO_T}$dynamic_linker" >&6
-test "$dynamic_linker" = no && can_build_shared=no
-
-variables_saved_for_relink="PATH $shlibpath_var $runpath_var"
-if test "$GCC" = yes; then
- variables_saved_for_relink="$variables_saved_for_relink GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH"
-fi
-
-echo "$as_me:$LINENO: checking how to hardcode library paths into programs" >&5
-echo $ECHO_N "checking how to hardcode library paths into programs... $ECHO_C" >&6
-hardcode_action_CXX=
-if test -n "$hardcode_libdir_flag_spec_CXX" || \
- test -n "$runpath_var_CXX" || \
- test "X$hardcode_automatic_CXX" = "Xyes" ; then
-
- # We can hardcode non-existant directories.
- if test "$hardcode_direct_CXX" != no &&
- # If the only mechanism to avoid hardcoding is shlibpath_var, we
- # have to relink, otherwise we might link with an installed library
- # when we should be linking with a yet-to-be-installed one
- ## test "$_LT_AC_TAGVAR(hardcode_shlibpath_var, CXX)" != no &&
- test "$hardcode_minus_L_CXX" != no; then
- # Linking always hardcodes the temporary library directory.
- hardcode_action_CXX=relink
- else
- # We can link without hardcoding, and we can hardcode nonexisting dirs.
- hardcode_action_CXX=immediate
- fi
-else
- # We cannot hardcode anything, or else we can only hardcode existing
- # directories.
- hardcode_action_CXX=unsupported
-fi
-echo "$as_me:$LINENO: result: $hardcode_action_CXX" >&5
-echo "${ECHO_T}$hardcode_action_CXX" >&6
-
-if test "$hardcode_action_CXX" = relink; then
- # Fast installation is not supported
- enable_fast_install=no
-elif test "$shlibpath_overrides_runpath" = yes ||
- test "$enable_shared" = no; then
- # Fast installation is not necessary
- enable_fast_install=needless
-fi
-
-
-# The else clause should only fire when bootstrapping the
-# libtool distribution, otherwise you forgot to ship ltmain.sh
-# with your package, and you will get complaints that there are
-# no rules to generate ltmain.sh.
-if test -f "$ltmain"; then
- # See if we are running on zsh, and set the options which allow our commands through
- # without removal of \ escapes.
- if test -n "${ZSH_VERSION+set}" ; then
- setopt NO_GLOB_SUBST
- fi
- # Now quote all the things that may contain metacharacters while being
- # careful not to overquote the AC_SUBSTed values. We take copies of the
- # variables and quote the copies for generation of the libtool script.
- for var in echo old_CC old_CFLAGS AR AR_FLAGS EGREP RANLIB LN_S LTCC LTCFLAGS NM \
- SED SHELL STRIP \
- libname_spec library_names_spec soname_spec extract_expsyms_cmds \
- old_striplib striplib file_magic_cmd finish_cmds finish_eval \
- deplibs_check_method reload_flag reload_cmds need_locks \
- lt_cv_sys_global_symbol_pipe lt_cv_sys_global_symbol_to_cdecl \
- lt_cv_sys_global_symbol_to_c_name_address \
- sys_lib_search_path_spec sys_lib_dlsearch_path_spec \
- old_postinstall_cmds old_postuninstall_cmds \
- compiler_CXX \
- CC_CXX \
- LD_CXX \
- lt_prog_compiler_wl_CXX \
- lt_prog_compiler_pic_CXX \
- lt_prog_compiler_static_CXX \
- lt_prog_compiler_no_builtin_flag_CXX \
- export_dynamic_flag_spec_CXX \
- thread_safe_flag_spec_CXX \
- whole_archive_flag_spec_CXX \
- enable_shared_with_static_runtimes_CXX \
- old_archive_cmds_CXX \
- old_archive_from_new_cmds_CXX \
- predep_objects_CXX \
- postdep_objects_CXX \
- predeps_CXX \
- postdeps_CXX \
- compiler_lib_search_path_CXX \
- archive_cmds_CXX \
- archive_expsym_cmds_CXX \
- postinstall_cmds_CXX \
- postuninstall_cmds_CXX \
- old_archive_from_expsyms_cmds_CXX \
- allow_undefined_flag_CXX \
- no_undefined_flag_CXX \
- export_symbols_cmds_CXX \
- hardcode_libdir_flag_spec_CXX \
- hardcode_libdir_flag_spec_ld_CXX \
- hardcode_libdir_separator_CXX \
- hardcode_automatic_CXX \
- module_cmds_CXX \
- module_expsym_cmds_CXX \
- lt_cv_prog_compiler_c_o_CXX \
- exclude_expsyms_CXX \
- include_expsyms_CXX; do
-
- case $var in
- old_archive_cmds_CXX | \
- old_archive_from_new_cmds_CXX | \
- archive_cmds_CXX | \
- archive_expsym_cmds_CXX | \
- module_cmds_CXX | \
- module_expsym_cmds_CXX | \
- old_archive_from_expsyms_cmds_CXX | \
- export_symbols_cmds_CXX | \
- extract_expsyms_cmds | reload_cmds | finish_cmds | \
- postinstall_cmds | postuninstall_cmds | \
- old_postinstall_cmds | old_postuninstall_cmds | \
- sys_lib_search_path_spec | sys_lib_dlsearch_path_spec)
- # Double-quote double-evaled strings.
- eval "lt_$var=\\\"\`\$echo \"X\$$var\" | \$Xsed -e \"\$double_quote_subst\" -e \"\$sed_quote_subst\" -e \"\$delay_variable_subst\"\`\\\""
- ;;
- *)
- eval "lt_$var=\\\"\`\$echo \"X\$$var\" | \$Xsed -e \"\$sed_quote_subst\"\`\\\""
- ;;
- esac
- done
-
- case $lt_echo in
- *'\$0 --fallback-echo"')
- lt_echo=`$echo "X$lt_echo" | $Xsed -e 's/\\\\\\\$0 --fallback-echo"$/$0 --fallback-echo"/'`
- ;;
- esac
-
-cfgfile="$ofile"
-
- cat <<__EOF__ >> "$cfgfile"
-# ### BEGIN LIBTOOL TAG CONFIG: $tagname
-
-# Libtool was configured on host `(hostname || uname -n) 2>/dev/null | sed 1q`:
-
-# Shell to use when invoking shell scripts.
-SHELL=$lt_SHELL
-
-# Whether or not to build shared libraries.
-build_libtool_libs=$enable_shared
-
-# Whether or not to build static libraries.
-build_old_libs=$enable_static
-
-# Whether or not to add -lc for building shared libraries.
-build_libtool_need_lc=$archive_cmds_need_lc_CXX
-
-# Whether or not to disallow shared libs when runtime libs are static
-allow_libtool_libs_with_static_runtimes=$enable_shared_with_static_runtimes_CXX
-
-# Whether or not to optimize for fast installation.
-fast_install=$enable_fast_install
-
-# The host system.
-host_alias=$host_alias
-host=$host
-host_os=$host_os
-
-# The build system.
-build_alias=$build_alias
-build=$build
-build_os=$build_os
-
-# An echo program that does not interpret backslashes.
-echo=$lt_echo
-
-# The archiver.
-AR=$lt_AR
-AR_FLAGS=$lt_AR_FLAGS
-
-# A C compiler.
-LTCC=$lt_LTCC
-
-# LTCC compiler flags.
-LTCFLAGS=$lt_LTCFLAGS
-
-# A language-specific compiler.
-CC=$lt_compiler_CXX
-
-# Is the compiler the GNU C compiler?
-with_gcc=$GCC_CXX
-
-# An ERE matcher.
-EGREP=$lt_EGREP
-
-# The linker used to build libraries.
-LD=$lt_LD_CXX
-
-# Whether we need hard or soft links.
-LN_S=$lt_LN_S
-
-# A BSD-compatible nm program.
-NM=$lt_NM
-
-# A symbol stripping program
-STRIP=$lt_STRIP
-
-# Used to examine libraries when file_magic_cmd begins "file"
-MAGIC_CMD=$MAGIC_CMD
-
-# Used on cygwin: DLL creation program.
-DLLTOOL="$DLLTOOL"
-
-# Used on cygwin: object dumper.
-OBJDUMP="$OBJDUMP"
-
-# Used on cygwin: assembler.
-AS="$AS"
-
-# The name of the directory that contains temporary libtool files.
-objdir=$objdir
-
-# How to create reloadable object files.
-reload_flag=$lt_reload_flag
-reload_cmds=$lt_reload_cmds
-
-# How to pass a linker flag through the compiler.
-wl=$lt_lt_prog_compiler_wl_CXX
-
-# Object file suffix (normally "o").
-objext="$ac_objext"
-
-# Old archive suffix (normally "a").
-libext="$libext"
-
-# Shared library suffix (normally ".so").
-shrext_cmds='$shrext_cmds'
-
-# Executable file suffix (normally "").
-exeext="$exeext"
-
-# Additional compiler flags for building library objects.
-pic_flag=$lt_lt_prog_compiler_pic_CXX
-pic_mode=$pic_mode
-
-# What is the maximum length of a command?
-max_cmd_len=$lt_cv_sys_max_cmd_len
-
-# Does compiler simultaneously support -c and -o options?
-compiler_c_o=$lt_lt_cv_prog_compiler_c_o_CXX
-
-# Must we lock files when doing compilation?
-need_locks=$lt_need_locks
-
-# Do we need the lib prefix for modules?
-need_lib_prefix=$need_lib_prefix
-
-# Do we need a version for libraries?
-need_version=$need_version
-
-# Whether dlopen is supported.
-dlopen_support=$enable_dlopen
-
-# Whether dlopen of programs is supported.
-dlopen_self=$enable_dlopen_self
-
-# Whether dlopen of statically linked programs is supported.
-dlopen_self_static=$enable_dlopen_self_static
-
-# Compiler flag to prevent dynamic linking.
-link_static_flag=$lt_lt_prog_compiler_static_CXX
-
-# Compiler flag to turn off builtin functions.
-no_builtin_flag=$lt_lt_prog_compiler_no_builtin_flag_CXX
-
-# Compiler flag to allow reflexive dlopens.
-export_dynamic_flag_spec=$lt_export_dynamic_flag_spec_CXX
-
-# Compiler flag to generate shared objects directly from archives.
-whole_archive_flag_spec=$lt_whole_archive_flag_spec_CXX
-
-# Compiler flag to generate thread-safe objects.
-thread_safe_flag_spec=$lt_thread_safe_flag_spec_CXX
-
-# Library versioning type.
-version_type=$version_type
-
-# Format of library name prefix.
-libname_spec=$lt_libname_spec
-
-# List of archive names. First name is the real one, the rest are links.
-# The last name is the one that the linker finds with -lNAME.
-library_names_spec=$lt_library_names_spec
-
-# The coded name of the library, if different from the real name.
-soname_spec=$lt_soname_spec
-
-# Commands used to build and install an old-style archive.
-RANLIB=$lt_RANLIB
-old_archive_cmds=$lt_old_archive_cmds_CXX
-old_postinstall_cmds=$lt_old_postinstall_cmds
-old_postuninstall_cmds=$lt_old_postuninstall_cmds
-
-# Create an old-style archive from a shared archive.
-old_archive_from_new_cmds=$lt_old_archive_from_new_cmds_CXX
-
-# Create a temporary old-style archive to link instead of a shared archive.
-old_archive_from_expsyms_cmds=$lt_old_archive_from_expsyms_cmds_CXX
-
-# Commands used to build and install a shared archive.
-archive_cmds=$lt_archive_cmds_CXX
-archive_expsym_cmds=$lt_archive_expsym_cmds_CXX
-postinstall_cmds=$lt_postinstall_cmds
-postuninstall_cmds=$lt_postuninstall_cmds
-
-# Commands used to build a loadable module (assumed same as above if empty)
-module_cmds=$lt_module_cmds_CXX
-module_expsym_cmds=$lt_module_expsym_cmds_CXX
-
-# Commands to strip libraries.
-old_striplib=$lt_old_striplib
-striplib=$lt_striplib
-
-# Dependencies to place before the objects being linked to create a
-# shared library.
-predep_objects=$lt_predep_objects_CXX
-
-# Dependencies to place after the objects being linked to create a
-# shared library.
-postdep_objects=$lt_postdep_objects_CXX
-
-# Dependencies to place before the objects being linked to create a
-# shared library.
-predeps=$lt_predeps_CXX
-
-# Dependencies to place after the objects being linked to create a
-# shared library.
-postdeps=$lt_postdeps_CXX
-
-# The library search path used internally by the compiler when linking
-# a shared library.
-compiler_lib_search_path=$lt_compiler_lib_search_path_CXX
-
-# Method to check whether dependent libraries are shared objects.
-deplibs_check_method=$lt_deplibs_check_method
-
-# Command to use when deplibs_check_method == file_magic.
-file_magic_cmd=$lt_file_magic_cmd
-
-# Flag that allows shared libraries with undefined symbols to be built.
-allow_undefined_flag=$lt_allow_undefined_flag_CXX
-
-# Flag that forces no undefined symbols.
-no_undefined_flag=$lt_no_undefined_flag_CXX
-
-# Commands used to finish a libtool library installation in a directory.
-finish_cmds=$lt_finish_cmds
-
-# Same as above, but a single script fragment to be evaled but not shown.
-finish_eval=$lt_finish_eval
-
-# Take the output of nm and produce a listing of raw symbols and C names.
-global_symbol_pipe=$lt_lt_cv_sys_global_symbol_pipe
-
-# Transform the output of nm in a proper C declaration
-global_symbol_to_cdecl=$lt_lt_cv_sys_global_symbol_to_cdecl
-
-# Transform the output of nm in a C name address pair
-global_symbol_to_c_name_address=$lt_lt_cv_sys_global_symbol_to_c_name_address
-
-# This is the shared library runtime path variable.
-runpath_var=$runpath_var
-
-# This is the shared library path variable.
-shlibpath_var=$shlibpath_var
-
-# Is shlibpath searched before the hard-coded library search path?
-shlibpath_overrides_runpath=$shlibpath_overrides_runpath
-
-# How to hardcode a shared library path into an executable.
-hardcode_action=$hardcode_action_CXX
-
-# Whether we should hardcode library paths into libraries.
-hardcode_into_libs=$hardcode_into_libs
-
-# Flag to hardcode \$libdir into a binary during linking.
-# This must work even if \$libdir does not exist.
-hardcode_libdir_flag_spec=$lt_hardcode_libdir_flag_spec_CXX
-
-# If ld is used when linking, flag to hardcode \$libdir into
-# a binary during linking. This must work even if \$libdir does
-# not exist.
-hardcode_libdir_flag_spec_ld=$lt_hardcode_libdir_flag_spec_ld_CXX
-
-# Whether we need a single -rpath flag with a separated argument.
-hardcode_libdir_separator=$lt_hardcode_libdir_separator_CXX
-
-# Set to yes if using DIR/libNAME${shared_ext} during linking hardcodes DIR into the
-# resulting binary.
-hardcode_direct=$hardcode_direct_CXX
-
-# Set to yes if using the -LDIR flag during linking hardcodes DIR into the
-# resulting binary.
-hardcode_minus_L=$hardcode_minus_L_CXX
-
-# Set to yes if using SHLIBPATH_VAR=DIR during linking hardcodes DIR into
-# the resulting binary.
-hardcode_shlibpath_var=$hardcode_shlibpath_var_CXX
-
-# Set to yes if building a shared library automatically hardcodes DIR into the library
-# and all subsequent libraries and executables linked against it.
-hardcode_automatic=$hardcode_automatic_CXX
-
-# Variables whose values should be saved in libtool wrapper scripts and
-# restored at relink time.
-variables_saved_for_relink="$variables_saved_for_relink"
-
-# Whether libtool must link a program against all its dependency libraries.
-link_all_deplibs=$link_all_deplibs_CXX
-
-# Compile-time system search path for libraries
-sys_lib_search_path_spec=$lt_sys_lib_search_path_spec
-
-# Run-time system search path for libraries
-sys_lib_dlsearch_path_spec=$lt_sys_lib_dlsearch_path_spec
-
-# Fix the shell variable \$srcfile for the compiler.
-fix_srcfile_path="$fix_srcfile_path_CXX"
-
-# Set to yes if exported symbols are required.
-always_export_symbols=$always_export_symbols_CXX
-
-# The commands to list exported symbols.
-export_symbols_cmds=$lt_export_symbols_cmds_CXX
-
-# The commands to extract the exported symbol list from a shared archive.
-extract_expsyms_cmds=$lt_extract_expsyms_cmds
-
-# Symbols that should not be listed in the preloaded symbols.
-exclude_expsyms=$lt_exclude_expsyms_CXX
-
-# Symbols that must always be exported.
-include_expsyms=$lt_include_expsyms_CXX
-
-# ### END LIBTOOL TAG CONFIG: $tagname
-
-__EOF__
-
-
-else
- # If there is no Makefile yet, we rely on a make rule to execute
- # `config.status --recheck' to rerun these tests and create the
- # libtool script then.
- ltmain_in=`echo $ltmain | sed -e 's/\.sh$/.in/'`
- if test -f "$ltmain_in"; then
- test -f Makefile && make "$ltmain"
- fi
-fi
-
-
-ac_ext=c
-ac_cpp='$CPP $CPPFLAGS'
-ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
-ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
-ac_compiler_gnu=$ac_cv_c_compiler_gnu
-
-CC=$lt_save_CC
-LDCXX=$LD
-LD=$lt_save_LD
-GCC=$lt_save_GCC
-with_gnu_ldcxx=$with_gnu_ld
-with_gnu_ld=$lt_save_with_gnu_ld
-lt_cv_path_LDCXX=$lt_cv_path_LD
-lt_cv_path_LD=$lt_save_path_LD
-lt_cv_prog_gnu_ldcxx=$lt_cv_prog_gnu_ld
-lt_cv_prog_gnu_ld=$lt_save_with_gnu_ld
-
- else
- tagname=""
- fi
- ;;
-
- F77)
- if test -n "$F77" && test "X$F77" != "Xno"; then
-
-ac_ext=f
-ac_compile='$F77 -c $FFLAGS conftest.$ac_ext >&5'
-ac_link='$F77 -o conftest$ac_exeext $FFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
-ac_compiler_gnu=$ac_cv_f77_compiler_gnu
-
-
-archive_cmds_need_lc_F77=no
-allow_undefined_flag_F77=
-always_export_symbols_F77=no
-archive_expsym_cmds_F77=
-export_dynamic_flag_spec_F77=
-hardcode_direct_F77=no
-hardcode_libdir_flag_spec_F77=
-hardcode_libdir_flag_spec_ld_F77=
-hardcode_libdir_separator_F77=
-hardcode_minus_L_F77=no
-hardcode_automatic_F77=no
-module_cmds_F77=
-module_expsym_cmds_F77=
-link_all_deplibs_F77=unknown
-old_archive_cmds_F77=$old_archive_cmds
-no_undefined_flag_F77=
-whole_archive_flag_spec_F77=
-enable_shared_with_static_runtimes_F77=no
-
-# Source file extension for f77 test sources.
-ac_ext=f
-
-# Object file extension for compiled f77 test sources.
-objext=o
-objext_F77=$objext
-
-# Code to be used in simple compile tests
-lt_simple_compile_test_code=" subroutine t\n return\n end\n"
-
-# Code to be used in simple link tests
-lt_simple_link_test_code=" program t\n end\n"
-
-# ltmain only uses $CC for tagged configurations so make sure $CC is set.
-
-# If no C compiler was specified, use CC.
-LTCC=${LTCC-"$CC"}
-
-# If no C compiler flags were specified, use CFLAGS.
-LTCFLAGS=${LTCFLAGS-"$CFLAGS"}
-
-# Allow CC to be a program name with arguments.
-compiler=$CC
-
-
-# save warnings/boilerplate of simple test code
-ac_outfile=conftest.$ac_objext
-printf "$lt_simple_compile_test_code" >conftest.$ac_ext
-eval "$ac_compile" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err
-_lt_compiler_boilerplate=`cat conftest.err`
-$rm conftest*
-
-ac_outfile=conftest.$ac_objext
-printf "$lt_simple_link_test_code" >conftest.$ac_ext
-eval "$ac_link" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err
-_lt_linker_boilerplate=`cat conftest.err`
-$rm conftest*
-
-
-# Allow CC to be a program name with arguments.
-lt_save_CC="$CC"
-CC=${F77-"f77"}
-compiler=$CC
-compiler_F77=$CC
-for cc_temp in $compiler""; do
- case $cc_temp in
- compile | *[\\/]compile | ccache | *[\\/]ccache ) ;;
- distcc | *[\\/]distcc | purify | *[\\/]purify ) ;;
- \-*) ;;
- *) break;;
- esac
-done
-cc_basename=`$echo "X$cc_temp" | $Xsed -e 's%.*/%%' -e "s%^$host_alias-%%"`
-
-
-echo "$as_me:$LINENO: checking if libtool supports shared libraries" >&5
-echo $ECHO_N "checking if libtool supports shared libraries... $ECHO_C" >&6
-echo "$as_me:$LINENO: result: $can_build_shared" >&5
-echo "${ECHO_T}$can_build_shared" >&6
-
-echo "$as_me:$LINENO: checking whether to build shared libraries" >&5
-echo $ECHO_N "checking whether to build shared libraries... $ECHO_C" >&6
-test "$can_build_shared" = "no" && enable_shared=no
-
-# On AIX, shared libraries and static libraries use the same namespace, and
-# are all built from PIC.
-case $host_os in
-aix3*)
- test "$enable_shared" = yes && enable_static=no
- if test -n "$RANLIB"; then
- archive_cmds="$archive_cmds~\$RANLIB \$lib"
- postinstall_cmds='$RANLIB $lib'
- fi
- ;;
-aix4* | aix5*)
- if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then
- test "$enable_shared" = yes && enable_static=no
- fi
- ;;
-esac
-echo "$as_me:$LINENO: result: $enable_shared" >&5
-echo "${ECHO_T}$enable_shared" >&6
-
-echo "$as_me:$LINENO: checking whether to build static libraries" >&5
-echo $ECHO_N "checking whether to build static libraries... $ECHO_C" >&6
-# Make sure either enable_shared or enable_static is yes.
-test "$enable_shared" = yes || enable_static=yes
-echo "$as_me:$LINENO: result: $enable_static" >&5
-echo "${ECHO_T}$enable_static" >&6
-
-GCC_F77="$G77"
-LD_F77="$LD"
-
-lt_prog_compiler_wl_F77=
-lt_prog_compiler_pic_F77=
-lt_prog_compiler_static_F77=
-
-echo "$as_me:$LINENO: checking for $compiler option to produce PIC" >&5
-echo $ECHO_N "checking for $compiler option to produce PIC... $ECHO_C" >&6
-
- if test "$GCC" = yes; then
- lt_prog_compiler_wl_F77='-Wl,'
- lt_prog_compiler_static_F77='-static'
-
- case $host_os in
- aix*)
- # All AIX code is PIC.
- if test "$host_cpu" = ia64; then
- # AIX 5 now supports IA64 processor
- lt_prog_compiler_static_F77='-Bstatic'
- fi
- ;;
-
- amigaos*)
- # FIXME: we need at least 68020 code to build shared libraries, but
- # adding the `-m68020' flag to GCC prevents building anything better,
- # like `-m68040'.
- lt_prog_compiler_pic_F77='-m68020 -resident32 -malways-restore-a4'
- ;;
-
- beos* | cygwin* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*)
- # PIC is the default for these OSes.
- ;;
-
- mingw* | pw32* | os2*)
- # This hack is so that the source file can tell whether it is being
- # built for inclusion in a dll (and should export symbols for example).
- lt_prog_compiler_pic_F77='-DDLL_EXPORT'
- ;;
-
- darwin* | rhapsody*)
- # PIC is the default on this platform
- # Common symbols not allowed in MH_DYLIB files
- lt_prog_compiler_pic_F77='-fno-common'
- ;;
-
- interix3*)
- # Interix 3.x gcc -fpic/-fPIC options generate broken code.
- # Instead, we relocate shared libraries at runtime.
- ;;
-
- msdosdjgpp*)
- # Just because we use GCC doesn't mean we suddenly get shared libraries
- # on systems that don't support them.
- lt_prog_compiler_can_build_shared_F77=no
- enable_shared=no
- ;;
-
- sysv4*MP*)
- if test -d /usr/nec; then
- lt_prog_compiler_pic_F77=-Kconform_pic
- fi
- ;;
-
- hpux*)
- # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but
- # not for PA HP-UX.
- case $host_cpu in
- hppa*64*|ia64*)
- # +Z the default
- ;;
- *)
- lt_prog_compiler_pic_F77='-fPIC'
- ;;
- esac
- ;;
-
- *)
- lt_prog_compiler_pic_F77='-fPIC'
- ;;
- esac
- else
- # PORTME Check for flag to pass linker flags through the system compiler.
- case $host_os in
- aix*)
- lt_prog_compiler_wl_F77='-Wl,'
- if test "$host_cpu" = ia64; then
- # AIX 5 now supports IA64 processor
- lt_prog_compiler_static_F77='-Bstatic'
- else
- lt_prog_compiler_static_F77='-bnso -bI:/lib/syscalls.exp'
- fi
- ;;
- darwin*)
- # PIC is the default on this platform
- # Common symbols not allowed in MH_DYLIB files
- case $cc_basename in
- xlc*)
- lt_prog_compiler_pic_F77='-qnocommon'
- lt_prog_compiler_wl_F77='-Wl,'
- ;;
- esac
- ;;
-
- mingw* | pw32* | os2*)
- # This hack is so that the source file can tell whether it is being
- # built for inclusion in a dll (and should export symbols for example).
- lt_prog_compiler_pic_F77='-DDLL_EXPORT'
- ;;
-
- hpux9* | hpux10* | hpux11*)
- lt_prog_compiler_wl_F77='-Wl,'
- # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but
- # not for PA HP-UX.
- case $host_cpu in
- hppa*64*|ia64*)
- # +Z the default
- ;;
- *)
- lt_prog_compiler_pic_F77='+Z'
- ;;
- esac
- # Is there a better lt_prog_compiler_static that works with the bundled CC?
- lt_prog_compiler_static_F77='${wl}-a ${wl}archive'
- ;;
-
- irix5* | irix6* | nonstopux*)
- lt_prog_compiler_wl_F77='-Wl,'
- # PIC (with -KPIC) is the default.
- lt_prog_compiler_static_F77='-non_shared'
- ;;
-
- newsos6)
- lt_prog_compiler_pic_F77='-KPIC'
- lt_prog_compiler_static_F77='-Bstatic'
- ;;
-
- linux*)
- case $cc_basename in
- icc* | ecc*)
- lt_prog_compiler_wl_F77='-Wl,'
- lt_prog_compiler_pic_F77='-KPIC'
- lt_prog_compiler_static_F77='-static'
- ;;
- pgcc* | pgf77* | pgf90* | pgf95*)
- # Portland Group compilers (*not* the Pentium gcc compiler,
- # which looks to be a dead project)
- lt_prog_compiler_wl_F77='-Wl,'
- lt_prog_compiler_pic_F77='-fpic'
- lt_prog_compiler_static_F77='-Bstatic'
- ;;
- ccc*)
- lt_prog_compiler_wl_F77='-Wl,'
- # All Alpha code is PIC.
- lt_prog_compiler_static_F77='-non_shared'
- ;;
- esac
- ;;
-
- osf3* | osf4* | osf5*)
- lt_prog_compiler_wl_F77='-Wl,'
- # All OSF/1 code is PIC.
- lt_prog_compiler_static_F77='-non_shared'
- ;;
-
- solaris*)
- lt_prog_compiler_pic_F77='-KPIC'
- lt_prog_compiler_static_F77='-Bstatic'
- case $cc_basename in
- f77* | f90* | f95*)
- lt_prog_compiler_wl_F77='-Qoption ld ';;
- *)
- lt_prog_compiler_wl_F77='-Wl,';;
- esac
- ;;
-
- sunos4*)
- lt_prog_compiler_wl_F77='-Qoption ld '
- lt_prog_compiler_pic_F77='-PIC'
- lt_prog_compiler_static_F77='-Bstatic'
- ;;
-
- sysv4 | sysv4.2uw2* | sysv4.3*)
- lt_prog_compiler_wl_F77='-Wl,'
- lt_prog_compiler_pic_F77='-KPIC'
- lt_prog_compiler_static_F77='-Bstatic'
- ;;
-
- sysv4*MP*)
- if test -d /usr/nec ;then
- lt_prog_compiler_pic_F77='-Kconform_pic'
- lt_prog_compiler_static_F77='-Bstatic'
- fi
- ;;
-
- sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*)
- lt_prog_compiler_wl_F77='-Wl,'
- lt_prog_compiler_pic_F77='-KPIC'
- lt_prog_compiler_static_F77='-Bstatic'
- ;;
-
- unicos*)
- lt_prog_compiler_wl_F77='-Wl,'
- lt_prog_compiler_can_build_shared_F77=no
- ;;
-
- uts4*)
- lt_prog_compiler_pic_F77='-pic'
- lt_prog_compiler_static_F77='-Bstatic'
- ;;
-
- *)
- lt_prog_compiler_can_build_shared_F77=no
- ;;
- esac
- fi
-
-echo "$as_me:$LINENO: result: $lt_prog_compiler_pic_F77" >&5
-echo "${ECHO_T}$lt_prog_compiler_pic_F77" >&6
-
-#
-# Check to make sure the PIC flag actually works.
-#
-if test -n "$lt_prog_compiler_pic_F77"; then
-
-echo "$as_me:$LINENO: checking if $compiler PIC flag $lt_prog_compiler_pic_F77 works" >&5
-echo $ECHO_N "checking if $compiler PIC flag $lt_prog_compiler_pic_F77 works... $ECHO_C" >&6
-if test "${lt_prog_compiler_pic_works_F77+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- lt_prog_compiler_pic_works_F77=no
- ac_outfile=conftest.$ac_objext
- printf "$lt_simple_compile_test_code" > conftest.$ac_ext
- lt_compiler_flag="$lt_prog_compiler_pic_F77"
- # Insert the option either (1) after the last *FLAGS variable, or
- # (2) before a word containing "conftest.", or (3) at the end.
- # Note that $ac_compile itself does not contain backslashes and begins
- # with a dollar sign (not a hyphen), so the echo should work correctly.
- # The option is referenced via a variable to avoid confusing sed.
- lt_compile=`echo "$ac_compile" | $SED \
- -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
- -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
- -e 's:$: $lt_compiler_flag:'`
- (eval echo "\"\$as_me:13185: $lt_compile\"" >&5)
- (eval "$lt_compile" 2>conftest.err)
- ac_status=$?
- cat conftest.err >&5
- echo "$as_me:13189: \$? = $ac_status" >&5
- if (exit $ac_status) && test -s "$ac_outfile"; then
- # The compiler can only warn and ignore the option if not recognized
- # So say no if there are warnings other than the usual output.
- $echo "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' >conftest.exp
- $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2
- if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then
- lt_prog_compiler_pic_works_F77=yes
- fi
- fi
- $rm conftest*
-
-fi
-echo "$as_me:$LINENO: result: $lt_prog_compiler_pic_works_F77" >&5
-echo "${ECHO_T}$lt_prog_compiler_pic_works_F77" >&6
-
-if test x"$lt_prog_compiler_pic_works_F77" = xyes; then
- case $lt_prog_compiler_pic_F77 in
- "" | " "*) ;;
- *) lt_prog_compiler_pic_F77=" $lt_prog_compiler_pic_F77" ;;
- esac
-else
- lt_prog_compiler_pic_F77=
- lt_prog_compiler_can_build_shared_F77=no
-fi
-
-fi
-case $host_os in
- # For platforms which do not support PIC, -DPIC is meaningless:
- *djgpp*)
- lt_prog_compiler_pic_F77=
- ;;
- *)
- lt_prog_compiler_pic_F77="$lt_prog_compiler_pic_F77"
- ;;
-esac
-
-#
-# Check to make sure the static flag actually works.
-#
-wl=$lt_prog_compiler_wl_F77 eval lt_tmp_static_flag=\"$lt_prog_compiler_static_F77\"
-echo "$as_me:$LINENO: checking if $compiler static flag $lt_tmp_static_flag works" >&5
-echo $ECHO_N "checking if $compiler static flag $lt_tmp_static_flag works... $ECHO_C" >&6
-if test "${lt_prog_compiler_static_works_F77+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- lt_prog_compiler_static_works_F77=no
- save_LDFLAGS="$LDFLAGS"
- LDFLAGS="$LDFLAGS $lt_tmp_static_flag"
- printf "$lt_simple_link_test_code" > conftest.$ac_ext
- if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then
- # The linker can only warn and ignore the option if not recognized
- # So say no if there are warnings
- if test -s conftest.err; then
- # Append any errors to the config.log.
- cat conftest.err 1>&5
- $echo "X$_lt_linker_boilerplate" | $Xsed -e '/^$/d' > conftest.exp
- $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2
- if diff conftest.exp conftest.er2 >/dev/null; then
- lt_prog_compiler_static_works_F77=yes
- fi
- else
- lt_prog_compiler_static_works_F77=yes
- fi
- fi
- $rm conftest*
- LDFLAGS="$save_LDFLAGS"
-
-fi
-echo "$as_me:$LINENO: result: $lt_prog_compiler_static_works_F77" >&5
-echo "${ECHO_T}$lt_prog_compiler_static_works_F77" >&6
-
-if test x"$lt_prog_compiler_static_works_F77" = xyes; then
- :
-else
- lt_prog_compiler_static_F77=
-fi
-
-
-echo "$as_me:$LINENO: checking if $compiler supports -c -o file.$ac_objext" >&5
-echo $ECHO_N "checking if $compiler supports -c -o file.$ac_objext... $ECHO_C" >&6
-if test "${lt_cv_prog_compiler_c_o_F77+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- lt_cv_prog_compiler_c_o_F77=no
- $rm -r conftest 2>/dev/null
- mkdir conftest
- cd conftest
- mkdir out
- printf "$lt_simple_compile_test_code" > conftest.$ac_ext
-
- lt_compiler_flag="-o out/conftest2.$ac_objext"
- # Insert the option either (1) after the last *FLAGS variable, or
- # (2) before a word containing "conftest.", or (3) at the end.
- # Note that $ac_compile itself does not contain backslashes and begins
- # with a dollar sign (not a hyphen), so the echo should work correctly.
- lt_compile=`echo "$ac_compile" | $SED \
- -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
- -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
- -e 's:$: $lt_compiler_flag:'`
- (eval echo "\"\$as_me:13289: $lt_compile\"" >&5)
- (eval "$lt_compile" 2>out/conftest.err)
- ac_status=$?
- cat out/conftest.err >&5
- echo "$as_me:13293: \$? = $ac_status" >&5
- if (exit $ac_status) && test -s out/conftest2.$ac_objext
- then
- # The compiler can only warn and ignore the option if not recognized
- # So say no if there are warnings
- $echo "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' > out/conftest.exp
- $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2
- if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then
- lt_cv_prog_compiler_c_o_F77=yes
- fi
- fi
- chmod u+w . 2>&5
- $rm conftest*
- # SGI C++ compiler will create directory out/ii_files/ for
- # template instantiation
- test -d out/ii_files && $rm out/ii_files/* && rmdir out/ii_files
- $rm out/* && rmdir out
- cd ..
- rmdir conftest
- $rm conftest*
-
-fi
-echo "$as_me:$LINENO: result: $lt_cv_prog_compiler_c_o_F77" >&5
-echo "${ECHO_T}$lt_cv_prog_compiler_c_o_F77" >&6
-
-
-hard_links="nottested"
-if test "$lt_cv_prog_compiler_c_o_F77" = no && test "$need_locks" != no; then
- # do not overwrite the value of need_locks provided by the user
- echo "$as_me:$LINENO: checking if we can lock with hard links" >&5
-echo $ECHO_N "checking if we can lock with hard links... $ECHO_C" >&6
- hard_links=yes
- $rm conftest*
- ln conftest.a conftest.b 2>/dev/null && hard_links=no
- touch conftest.a
- ln conftest.a conftest.b 2>&5 || hard_links=no
- ln conftest.a conftest.b 2>/dev/null && hard_links=no
- echo "$as_me:$LINENO: result: $hard_links" >&5
-echo "${ECHO_T}$hard_links" >&6
- if test "$hard_links" = no; then
- { echo "$as_me:$LINENO: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&5
-echo "$as_me: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&2;}
- need_locks=warn
- fi
-else
- need_locks=no
-fi
-
-echo "$as_me:$LINENO: checking whether the $compiler linker ($LD) supports shared libraries" >&5
-echo $ECHO_N "checking whether the $compiler linker ($LD) supports shared libraries... $ECHO_C" >&6
-
- runpath_var=
- allow_undefined_flag_F77=
- enable_shared_with_static_runtimes_F77=no
- archive_cmds_F77=
- archive_expsym_cmds_F77=
- old_archive_From_new_cmds_F77=
- old_archive_from_expsyms_cmds_F77=
- export_dynamic_flag_spec_F77=
- whole_archive_flag_spec_F77=
- thread_safe_flag_spec_F77=
- hardcode_libdir_flag_spec_F77=
- hardcode_libdir_flag_spec_ld_F77=
- hardcode_libdir_separator_F77=
- hardcode_direct_F77=no
- hardcode_minus_L_F77=no
- hardcode_shlibpath_var_F77=unsupported
- link_all_deplibs_F77=unknown
- hardcode_automatic_F77=no
- module_cmds_F77=
- module_expsym_cmds_F77=
- always_export_symbols_F77=no
- export_symbols_cmds_F77='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols'
- # include_expsyms should be a list of space-separated symbols to be *always*
- # included in the symbol list
- include_expsyms_F77=
- # exclude_expsyms can be an extended regexp of symbols to exclude
- # it will be wrapped by ` (' and `)$', so one must not match beginning or
- # end of line. Example: `a|bc|.*d.*' will exclude the symbols `a' and `bc',
- # as well as any symbol that contains `d'.
- exclude_expsyms_F77="_GLOBAL_OFFSET_TABLE_"
- # Although _GLOBAL_OFFSET_TABLE_ is a valid symbol C name, most a.out
- # platforms (ab)use it in PIC code, but their linkers get confused if
- # the symbol is explicitly referenced. Since portable code cannot
- # rely on this symbol name, it's probably fine to never include it in
- # preloaded symbol tables.
- extract_expsyms_cmds=
- # Just being paranoid about ensuring that cc_basename is set.
- for cc_temp in $compiler""; do
- case $cc_temp in
- compile | *[\\/]compile | ccache | *[\\/]ccache ) ;;
- distcc | *[\\/]distcc | purify | *[\\/]purify ) ;;
- \-*) ;;
- *) break;;
- esac
-done
-cc_basename=`$echo "X$cc_temp" | $Xsed -e 's%.*/%%' -e "s%^$host_alias-%%"`
-
- case $host_os in
- cygwin* | mingw* | pw32*)
- # FIXME: the MSVC++ port hasn't been tested in a loooong time
- # When not using gcc, we currently assume that we are using
- # Microsoft Visual C++.
- if test "$GCC" != yes; then
- with_gnu_ld=no
- fi
- ;;
- interix*)
- # we just hope/assume this is gcc and not c89 (= MSVC++)
- with_gnu_ld=yes
- ;;
- openbsd*)
- with_gnu_ld=no
- ;;
- esac
-
- ld_shlibs_F77=yes
- if test "$with_gnu_ld" = yes; then
- # If archive_cmds runs LD, not CC, wlarc should be empty
- wlarc='${wl}'
-
- # Set some defaults for GNU ld with shared library support. These
- # are reset later if shared libraries are not supported. Putting them
- # here allows them to be overridden if necessary.
- runpath_var=LD_RUN_PATH
- hardcode_libdir_flag_spec_F77='${wl}--rpath ${wl}$libdir'
- export_dynamic_flag_spec_F77='${wl}--export-dynamic'
- # ancient GNU ld didn't support --whole-archive et. al.
- if $LD --help 2>&1 | grep 'no-whole-archive' > /dev/null; then
- whole_archive_flag_spec_F77="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive'
- else
- whole_archive_flag_spec_F77=
- fi
- supports_anon_versioning=no
- case `$LD -v 2>/dev/null` in
- *\ [01].* | *\ 2.[0-9].* | *\ 2.10.*) ;; # catch versions < 2.11
- *\ 2.11.93.0.2\ *) supports_anon_versioning=yes ;; # RH7.3 ...
- *\ 2.11.92.0.12\ *) supports_anon_versioning=yes ;; # Mandrake 8.2 ...
- *\ 2.11.*) ;; # other 2.11 versions
- *) supports_anon_versioning=yes ;;
- esac
-
- # See if GNU ld supports shared libraries.
- case $host_os in
- aix3* | aix4* | aix5*)
- # On AIX/PPC, the GNU linker is very broken
- if test "$host_cpu" != ia64; then
- ld_shlibs_F77=no
- cat <<EOF 1>&2
-
-*** Warning: the GNU linker, at least up to release 2.9.1, is reported
-*** to be unable to reliably create shared libraries on AIX.
-*** Therefore, libtool is disabling shared libraries support. If you
-*** really care for shared libraries, you may want to modify your PATH
-*** so that a non-GNU linker is found, and then restart.
-
-EOF
- fi
- ;;
-
- amigaos*)
- archive_cmds_F77='$rm $output_objdir/a2ixlibrary.data~$echo "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$echo "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$echo "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$echo "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)'
- hardcode_libdir_flag_spec_F77='-L$libdir'
- hardcode_minus_L_F77=yes
-
- # Samuel A. Falvo II <kc5tja@dolphin.openprojects.net> reports
- # that the semantics of dynamic libraries on AmigaOS, at least up
- # to version 4, is to share data among multiple programs linked
- # with the same dynamic library. Since this doesn't match the
- # behavior of shared libraries on other platforms, we can't use
- # them.
- ld_shlibs_F77=no
- ;;
-
- beos*)
- if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
- allow_undefined_flag_F77=unsupported
- # Joseph Beckenbach <jrb3@best.com> says some releases of gcc
- # support --undefined. This deserves some investigation. FIXME
- archive_cmds_F77='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
- else
- ld_shlibs_F77=no
- fi
- ;;
-
- cygwin* | mingw* | pw32*)
- # _LT_AC_TAGVAR(hardcode_libdir_flag_spec, F77) is actually meaningless,
- # as there is no search path for DLLs.
- hardcode_libdir_flag_spec_F77='-L$libdir'
- allow_undefined_flag_F77=unsupported
- always_export_symbols_F77=no
- enable_shared_with_static_runtimes_F77=yes
- export_symbols_cmds_F77='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[BCDGRS] /s/.* \([^ ]*\)/\1 DATA/'\'' | $SED -e '\''/^[AITW] /s/.* //'\'' | sort | uniq > $export_symbols'
-
- if $LD --help 2>&1 | grep 'auto-import' > /dev/null; then
- archive_cmds_F77='$CC -shared $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
- # If the export-symbols file already is a .def file (1st line
- # is EXPORTS), use it as is; otherwise, prepend...
- archive_expsym_cmds_F77='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then
- cp $export_symbols $output_objdir/$soname.def;
- else
- echo EXPORTS > $output_objdir/$soname.def;
- cat $export_symbols >> $output_objdir/$soname.def;
- fi~
- $CC -shared $output_objdir/$soname.def $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
- else
- ld_shlibs_F77=no
- fi
- ;;
-
- interix3*)
- hardcode_direct_F77=no
- hardcode_shlibpath_var_F77=no
- hardcode_libdir_flag_spec_F77='${wl}-rpath,$libdir'
- export_dynamic_flag_spec_F77='${wl}-E'
- # Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc.
- # Instead, shared libraries are loaded at an image base (0x10000000 by
- # default) and relocated if they conflict, which is a slow very memory
- # consuming and fragmenting process. To avoid this, we pick a random,
- # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link
- # time. Moving up from 0x10000000 also allows more sbrk(2) space.
- archive_cmds_F77='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
- archive_expsym_cmds_F77='sed "s,^,_," $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--retain-symbols-file,$output_objdir/$soname.expsym ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
- ;;
-
- linux*)
- if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
- tmp_addflag=
- case $cc_basename,$host_cpu in
- pgcc*) # Portland Group C compiler
- whole_archive_flag_spec_F77='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}--no-whole-archive'
- tmp_addflag=' $pic_flag'
- ;;
- pgf77* | pgf90* | pgf95*) # Portland Group f77 and f90 compilers
- whole_archive_flag_spec_F77='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}--no-whole-archive'
- tmp_addflag=' $pic_flag -Mnomain' ;;
- ecc*,ia64* | icc*,ia64*) # Intel C compiler on ia64
- tmp_addflag=' -i_dynamic' ;;
- efc*,ia64* | ifort*,ia64*) # Intel Fortran compiler on ia64
- tmp_addflag=' -i_dynamic -nofor_main' ;;
- ifc* | ifort*) # Intel Fortran compiler
- tmp_addflag=' -nofor_main' ;;
- esac
- archive_cmds_F77='$CC -shared'"$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
-
- if test $supports_anon_versioning = yes; then
- archive_expsym_cmds_F77='$echo "{ global:" > $output_objdir/$libname.ver~
- cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~
- $echo "local: *; };" >> $output_objdir/$libname.ver~
- $CC -shared'"$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib'
- fi
- link_all_deplibs_F77=no
- else
- ld_shlibs_F77=no
- fi
- ;;
-
- netbsd* | netbsdelf*-gnu | knetbsd*-gnu)
- if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then
- archive_cmds_F77='$LD -Bshareable $libobjs $deplibs $linker_flags -o $lib'
- wlarc=
- else
- archive_cmds_F77='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
- archive_expsym_cmds_F77='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
- fi
- ;;
-
- solaris*)
- if $LD -v 2>&1 | grep 'BFD 2\.8' > /dev/null; then
- ld_shlibs_F77=no
- cat <<EOF 1>&2
-
-*** Warning: The releases 2.8.* of the GNU linker cannot reliably
-*** create shared libraries on Solaris systems. Therefore, libtool
-*** is disabling shared libraries support. We urge you to upgrade GNU
-*** binutils to release 2.9.1 or newer. Another option is to modify
-*** your PATH or compiler configuration so that the native linker is
-*** used, and then restart.
-
-EOF
- elif $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
- archive_cmds_F77='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
- archive_expsym_cmds_F77='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
- else
- ld_shlibs_F77=no
- fi
- ;;
-
- sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX*)
- case `$LD -v 2>&1` in
- *\ [01].* | *\ 2.[0-9].* | *\ 2.1[0-5].*)
- ld_shlibs_F77=no
- cat <<_LT_EOF 1>&2
-
-*** Warning: Releases of the GNU linker prior to 2.16.91.0.3 can not
-*** reliably create shared libraries on SCO systems. Therefore, libtool
-*** is disabling shared libraries support. We urge you to upgrade GNU
-*** binutils to release 2.16.91.0.3 or newer. Another option is to modify
-*** your PATH or compiler configuration so that the native linker is
-*** used, and then restart.
-
-_LT_EOF
- ;;
- *)
- if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
- hardcode_libdir_flag_spec_F77='`test -z "$SCOABSPATH" && echo ${wl}-rpath,$libdir`'
- archive_cmds_F77='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib'
- archive_expsym_cmds_F77='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname,\${SCOABSPATH:+${install_libdir}/}$soname,-retain-symbols-file,$export_symbols -o $lib'
- else
- ld_shlibs_F77=no
- fi
- ;;
- esac
- ;;
-
- sunos4*)
- archive_cmds_F77='$LD -assert pure-text -Bshareable -o $lib $libobjs $deplibs $linker_flags'
- wlarc=
- hardcode_direct_F77=yes
- hardcode_shlibpath_var_F77=no
- ;;
-
- *)
- if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
- archive_cmds_F77='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
- archive_expsym_cmds_F77='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
- else
- ld_shlibs_F77=no
- fi
- ;;
- esac
-
- if test "$ld_shlibs_F77" = no; then
- runpath_var=
- hardcode_libdir_flag_spec_F77=
- export_dynamic_flag_spec_F77=
- whole_archive_flag_spec_F77=
- fi
- else
- # PORTME fill in a description of your system's linker (not GNU ld)
- case $host_os in
- aix3*)
- allow_undefined_flag_F77=unsupported
- always_export_symbols_F77=yes
- archive_expsym_cmds_F77='$LD -o $output_objdir/$soname $libobjs $deplibs $linker_flags -bE:$export_symbols -T512 -H512 -bM:SRE~$AR $AR_FLAGS $lib $output_objdir/$soname'
- # Note: this linker hardcodes the directories in LIBPATH if there
- # are no directories specified by -L.
- hardcode_minus_L_F77=yes
- if test "$GCC" = yes && test -z "$lt_prog_compiler_static"; then
- # Neither direct hardcoding nor static linking is supported with a
- # broken collect2.
- hardcode_direct_F77=unsupported
- fi
- ;;
-
- aix4* | aix5*)
- if test "$host_cpu" = ia64; then
- # On IA64, the linker does run time linking by default, so we don't
- # have to do anything special.
- aix_use_runtimelinking=no
- exp_sym_flag='-Bexport'
- no_entry_flag=""
- else
- # If we're using GNU nm, then we don't want the "-C" option.
- # -C means demangle to AIX nm, but means don't demangle with GNU nm
- if $NM -V 2>&1 | grep 'GNU' > /dev/null; then
- export_symbols_cmds_F77='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$2 == "T") || (\$2 == "D") || (\$2 == "B")) && (substr(\$3,1,1) != ".")) { print \$3 } }'\'' | sort -u > $export_symbols'
- else
- export_symbols_cmds_F77='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\$2 == "T") || (\$2 == "D") || (\$2 == "B")) && (substr(\$3,1,1) != ".")) { print \$3 } }'\'' | sort -u > $export_symbols'
- fi
- aix_use_runtimelinking=no
-
- # Test if we are trying to use run time linking or normal
- # AIX style linking. If -brtl is somewhere in LDFLAGS, we
- # need to do runtime linking.
- case $host_os in aix4.[23]|aix4.[23].*|aix5*)
- for ld_flag in $LDFLAGS; do
- if (test $ld_flag = "-brtl" || test $ld_flag = "-Wl,-brtl"); then
- aix_use_runtimelinking=yes
- break
- fi
- done
- ;;
- esac
-
- exp_sym_flag='-bexport'
- no_entry_flag='-bnoentry'
- fi
-
- # When large executables or shared objects are built, AIX ld can
- # have problems creating the table of contents. If linking a library
- # or program results in "error TOC overflow" add -mminimal-toc to
- # CXXFLAGS/CFLAGS for g++/gcc. In the cases where that is not
- # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS.
-
- archive_cmds_F77=''
- hardcode_direct_F77=yes
- hardcode_libdir_separator_F77=':'
- link_all_deplibs_F77=yes
-
- if test "$GCC" = yes; then
- case $host_os in aix4.[012]|aix4.[012].*)
- # We only want to do this on AIX 4.2 and lower, the check
- # below for broken collect2 doesn't work under 4.3+
- collect2name=`${CC} -print-prog-name=collect2`
- if test -f "$collect2name" && \
- strings "$collect2name" | grep resolve_lib_name >/dev/null
- then
- # We have reworked collect2
- hardcode_direct_F77=yes
- else
- # We have old collect2
- hardcode_direct_F77=unsupported
- # It fails to find uninstalled libraries when the uninstalled
- # path is not listed in the libpath. Setting hardcode_minus_L
- # to unsupported forces relinking
- hardcode_minus_L_F77=yes
- hardcode_libdir_flag_spec_F77='-L$libdir'
- hardcode_libdir_separator_F77=
- fi
- ;;
- esac
- shared_flag='-shared'
- if test "$aix_use_runtimelinking" = yes; then
- shared_flag="$shared_flag "'${wl}-G'
- fi
- else
- # not using gcc
- if test "$host_cpu" = ia64; then
- # VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release
- # chokes on -Wl,-G. The following line is correct:
- shared_flag='-G'
- else
- if test "$aix_use_runtimelinking" = yes; then
- shared_flag='${wl}-G'
- else
- shared_flag='${wl}-bM:SRE'
- fi
- fi
- fi
-
- # It seems that -bexpall does not export symbols beginning with
- # underscore (_), so it is better to generate a list of symbols to export.
- always_export_symbols_F77=yes
- if test "$aix_use_runtimelinking" = yes; then
- # Warning - without using the other runtime loading flags (-brtl),
- # -berok will link without error, but may produce a broken library.
- allow_undefined_flag_F77='-berok'
- # Determine the default libpath from the value encoded in an empty executable.
- cat >conftest.$ac_ext <<_ACEOF
- program main
-
- end
-_ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
- (eval $ac_link) 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } &&
- { ac_try='test -z "$ac_f77_werror_flag" || test ! -s conftest.err'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; } &&
- { ac_try='test -s conftest$ac_exeext'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
-
-aix_libpath=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; }
-}'`
-# Check for a 64-bit object if we didn't find anything.
-if test -z "$aix_libpath"; then aix_libpath=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; }
-}'`; fi
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-fi
-rm -f conftest.err conftest.$ac_objext \
- conftest$ac_exeext conftest.$ac_ext
-if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
-
- hardcode_libdir_flag_spec_F77='${wl}-blibpath:$libdir:'"$aix_libpath"
- archive_expsym_cmds_F77="\$CC"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then echo "${wl}${allow_undefined_flag}"; else :; fi` '"\${wl}$exp_sym_flag:\$export_symbols $shared_flag"
- else
- if test "$host_cpu" = ia64; then
- hardcode_libdir_flag_spec_F77='${wl}-R $libdir:/usr/lib:/lib'
- allow_undefined_flag_F77="-z nodefs"
- archive_expsym_cmds_F77="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$exp_sym_flag:\$export_symbols"
- else
- # Determine the default libpath from the value encoded in an empty executable.
- cat >conftest.$ac_ext <<_ACEOF
- program main
-
- end
-_ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
- (eval $ac_link) 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } &&
- { ac_try='test -z "$ac_f77_werror_flag" || test ! -s conftest.err'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; } &&
- { ac_try='test -s conftest$ac_exeext'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
-
-aix_libpath=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; }
-}'`
-# Check for a 64-bit object if we didn't find anything.
-if test -z "$aix_libpath"; then aix_libpath=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; }
-}'`; fi
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-fi
-rm -f conftest.err conftest.$ac_objext \
- conftest$ac_exeext conftest.$ac_ext
-if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
-
- hardcode_libdir_flag_spec_F77='${wl}-blibpath:$libdir:'"$aix_libpath"
- # Warning - without using the other run time loading flags,
- # -berok will link without error, but may produce a broken library.
- no_undefined_flag_F77=' ${wl}-bernotok'
- allow_undefined_flag_F77=' ${wl}-berok'
- # Exported symbols can be pulled into shared objects from archives
- whole_archive_flag_spec_F77='$convenience'
- archive_cmds_need_lc_F77=yes
- # This is similar to how AIX traditionally builds its shared libraries.
- archive_expsym_cmds_F77="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs ${wl}-bnoentry $compiler_flags ${wl}-bE:$export_symbols${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname'
- fi
- fi
- ;;
-
- amigaos*)
- archive_cmds_F77='$rm $output_objdir/a2ixlibrary.data~$echo "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$echo "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$echo "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$echo "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)'
- hardcode_libdir_flag_spec_F77='-L$libdir'
- hardcode_minus_L_F77=yes
- # see comment about different semantics on the GNU ld section
- ld_shlibs_F77=no
- ;;
-
- bsdi[45]*)
- export_dynamic_flag_spec_F77=-rdynamic
- ;;
-
- cygwin* | mingw* | pw32*)
- # When not using gcc, we currently assume that we are using
- # Microsoft Visual C++.
- # hardcode_libdir_flag_spec is actually meaningless, as there is
- # no search path for DLLs.
- hardcode_libdir_flag_spec_F77=' '
- allow_undefined_flag_F77=unsupported
- # Tell ltmain to make .lib files, not .a files.
- libext=lib
- # Tell ltmain to make .dll files, not .so files.
- shrext_cmds=".dll"
- # FIXME: Setting linknames here is a bad hack.
- archive_cmds_F77='$CC -o $lib $libobjs $compiler_flags `echo "$deplibs" | $SED -e '\''s/ -lc$//'\''` -link -dll~linknames='
- # The linker will automatically build a .lib file if we build a DLL.
- old_archive_From_new_cmds_F77='true'
- # FIXME: Should let the user specify the lib program.
- old_archive_cmds_F77='lib /OUT:$oldlib$oldobjs$old_deplibs'
- fix_srcfile_path_F77='`cygpath -w "$srcfile"`'
- enable_shared_with_static_runtimes_F77=yes
- ;;
-
- darwin* | rhapsody*)
- case $host_os in
- rhapsody* | darwin1.[012])
- allow_undefined_flag_F77='${wl}-undefined ${wl}suppress'
- ;;
- *) # Darwin 1.3 on
- if test -z ${MACOSX_DEPLOYMENT_TARGET} ; then
- allow_undefined_flag_F77='${wl}-flat_namespace ${wl}-undefined ${wl}suppress'
- else
- case ${MACOSX_DEPLOYMENT_TARGET} in
- 10.[012])
- allow_undefined_flag_F77='${wl}-flat_namespace ${wl}-undefined ${wl}suppress'
- ;;
- 10.*)
- allow_undefined_flag_F77='${wl}-undefined ${wl}dynamic_lookup'
- ;;
- esac
- fi
- ;;
- esac
- archive_cmds_need_lc_F77=no
- hardcode_direct_F77=no
- hardcode_automatic_F77=yes
- hardcode_shlibpath_var_F77=unsupported
- whole_archive_flag_spec_F77=''
- link_all_deplibs_F77=yes
- if test "$GCC" = yes ; then
- output_verbose_link_cmd='echo'
- archive_cmds_F77='$CC -dynamiclib $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring'
- module_cmds_F77='$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags'
- # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin lds
- archive_expsym_cmds_F77='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -dynamiclib $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
- module_expsym_cmds_F77='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
- else
- case $cc_basename in
- xlc*)
- output_verbose_link_cmd='echo'
- archive_cmds_F77='$CC -qmkshrobj $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-install_name ${wl}`echo $rpath/$soname` $verstring'
- module_cmds_F77='$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags'
- # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin lds
- archive_expsym_cmds_F77='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -qmkshrobj $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-install_name ${wl}$rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
- module_expsym_cmds_F77='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
- ;;
- *)
- ld_shlibs_F77=no
- ;;
- esac
- fi
- ;;
-
- dgux*)
- archive_cmds_F77='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
- hardcode_libdir_flag_spec_F77='-L$libdir'
- hardcode_shlibpath_var_F77=no
- ;;
-
- freebsd1*)
- ld_shlibs_F77=no
- ;;
-
- # FreeBSD 2.2.[012] allows us to include c++rt0.o to get C++ constructor
- # support. Future versions do this automatically, but an explicit c++rt0.o
- # does not break anything, and helps significantly (at the cost of a little
- # extra space).
- freebsd2.2*)
- archive_cmds_F77='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags /usr/lib/c++rt0.o'
- hardcode_libdir_flag_spec_F77='-R$libdir'
- hardcode_direct_F77=yes
- hardcode_shlibpath_var_F77=no
- ;;
-
- # Unfortunately, older versions of FreeBSD 2 do not have this feature.
- freebsd2*)
- archive_cmds_F77='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags'
- hardcode_direct_F77=yes
- hardcode_minus_L_F77=yes
- hardcode_shlibpath_var_F77=no
- ;;
-
- # FreeBSD 3 and greater uses gcc -shared to do shared libraries.
- freebsd* | dragonfly*)
- archive_cmds_F77='$CC -shared -o $lib $libobjs $deplibs $compiler_flags'
- hardcode_libdir_flag_spec_F77='-R$libdir'
- hardcode_direct_F77=yes
- hardcode_shlibpath_var_F77=no
- ;;
-
- # GNU/kFreeBSD uses gcc -shared to do shared libraries.
- kfreebsd*-gnu)
- archive_cmds_F77='$CC -shared -o $lib $libobjs $deplibs $compiler_flags'
- hardcode_libdir_flag_spec_F77='-R$libdir'
- hardcode_direct_F77=yes
- hardcode_shlibpath_var_F77=no
- link_all_deplibs_F77=no
- ;;
-
- hpux9*)
- if test "$GCC" = yes; then
- archive_cmds_F77='$rm $output_objdir/$soname~$CC -shared -fPIC ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $libobjs $deplibs $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
- else
- archive_cmds_F77='$rm $output_objdir/$soname~$LD -b +b $install_libdir -o $output_objdir/$soname $libobjs $deplibs $linker_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
- fi
- hardcode_libdir_flag_spec_F77='${wl}+b ${wl}$libdir'
- hardcode_libdir_separator_F77=:
- hardcode_direct_F77=yes
-
- # hardcode_minus_L: Not really in the search PATH,
- # but as the default location of the library.
- hardcode_minus_L_F77=yes
- export_dynamic_flag_spec_F77='${wl}-E'
- ;;
-
- hpux10*)
- if test "$GCC" = yes -a "$with_gnu_ld" = no; then
- archive_cmds_F77='$CC -shared -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
- else
- archive_cmds_F77='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags'
- fi
- if test "$with_gnu_ld" = no; then
- hardcode_libdir_flag_spec_F77='${wl}+b ${wl}$libdir'
- hardcode_libdir_separator_F77=:
-
- hardcode_direct_F77=yes
- export_dynamic_flag_spec_F77='${wl}-E'
-
- # hardcode_minus_L: Not really in the search PATH,
- # but as the default location of the library.
- hardcode_minus_L_F77=yes
- fi
- ;;
-
- hpux11*)
- if test "$GCC" = yes -a "$with_gnu_ld" = no; then
- case $host_cpu in
- hppa*64*)
- archive_cmds_F77='$CC -shared ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
- ;;
- ia64*)
- archive_cmds_F77='$CC -shared ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags'
- ;;
- *)
- archive_cmds_F77='$CC -shared -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
- ;;
- esac
- else
- case $host_cpu in
- hppa*64*)
- archive_cmds_F77='$CC -b ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
- ;;
- ia64*)
- archive_cmds_F77='$CC -b ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags'
- ;;
- *)
- archive_cmds_F77='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
- ;;
- esac
- fi
- if test "$with_gnu_ld" = no; then
- hardcode_libdir_flag_spec_F77='${wl}+b ${wl}$libdir'
- hardcode_libdir_separator_F77=:
-
- case $host_cpu in
- hppa*64*|ia64*)
- hardcode_libdir_flag_spec_ld_F77='+b $libdir'
- hardcode_direct_F77=no
- hardcode_shlibpath_var_F77=no
- ;;
- *)
- hardcode_direct_F77=yes
- export_dynamic_flag_spec_F77='${wl}-E'
-
- # hardcode_minus_L: Not really in the search PATH,
- # but as the default location of the library.
- hardcode_minus_L_F77=yes
- ;;
- esac
- fi
- ;;
-
- irix5* | irix6* | nonstopux*)
- if test "$GCC" = yes; then
- archive_cmds_F77='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
- else
- archive_cmds_F77='$LD -shared $libobjs $deplibs $linker_flags -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib'
- hardcode_libdir_flag_spec_ld_F77='-rpath $libdir'
- fi
- hardcode_libdir_flag_spec_F77='${wl}-rpath ${wl}$libdir'
- hardcode_libdir_separator_F77=:
- link_all_deplibs_F77=yes
- ;;
-
- netbsd* | netbsdelf*-gnu | knetbsd*-gnu)
- if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then
- archive_cmds_F77='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' # a.out
- else
- archive_cmds_F77='$LD -shared -o $lib $libobjs $deplibs $linker_flags' # ELF
- fi
- hardcode_libdir_flag_spec_F77='-R$libdir'
- hardcode_direct_F77=yes
- hardcode_shlibpath_var_F77=no
- ;;
-
- newsos6)
- archive_cmds_F77='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
- hardcode_direct_F77=yes
- hardcode_libdir_flag_spec_F77='${wl}-rpath ${wl}$libdir'
- hardcode_libdir_separator_F77=:
- hardcode_shlibpath_var_F77=no
- ;;
-
- openbsd*)
- hardcode_direct_F77=yes
- hardcode_shlibpath_var_F77=no
- if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
- archive_cmds_F77='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags'
- archive_expsym_cmds_F77='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-retain-symbols-file,$export_symbols'
- hardcode_libdir_flag_spec_F77='${wl}-rpath,$libdir'
- export_dynamic_flag_spec_F77='${wl}-E'
- else
- case $host_os in
- openbsd[01].* | openbsd2.[0-7] | openbsd2.[0-7].*)
- archive_cmds_F77='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags'
- hardcode_libdir_flag_spec_F77='-R$libdir'
- ;;
- *)
- archive_cmds_F77='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags'
- hardcode_libdir_flag_spec_F77='${wl}-rpath,$libdir'
- ;;
- esac
- fi
- ;;
-
- os2*)
- hardcode_libdir_flag_spec_F77='-L$libdir'
- hardcode_minus_L_F77=yes
- allow_undefined_flag_F77=unsupported
- archive_cmds_F77='$echo "LIBRARY $libname INITINSTANCE" > $output_objdir/$libname.def~$echo "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~$echo DATA >> $output_objdir/$libname.def~$echo " SINGLE NONSHARED" >> $output_objdir/$libname.def~$echo EXPORTS >> $output_objdir/$libname.def~emxexp $libobjs >> $output_objdir/$libname.def~$CC -Zdll -Zcrtdll -o $lib $libobjs $deplibs $compiler_flags $output_objdir/$libname.def'
- old_archive_From_new_cmds_F77='emximp -o $output_objdir/$libname.a $output_objdir/$libname.def'
- ;;
-
- osf3*)
- if test "$GCC" = yes; then
- allow_undefined_flag_F77=' ${wl}-expect_unresolved ${wl}\*'
- archive_cmds_F77='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
- else
- allow_undefined_flag_F77=' -expect_unresolved \*'
- archive_cmds_F77='$LD -shared${allow_undefined_flag} $libobjs $deplibs $linker_flags -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib'
- fi
- hardcode_libdir_flag_spec_F77='${wl}-rpath ${wl}$libdir'
- hardcode_libdir_separator_F77=:
- ;;
-
- osf4* | osf5*) # as osf3* with the addition of -msym flag
- if test "$GCC" = yes; then
- allow_undefined_flag_F77=' ${wl}-expect_unresolved ${wl}\*'
- archive_cmds_F77='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
- hardcode_libdir_flag_spec_F77='${wl}-rpath ${wl}$libdir'
- else
- allow_undefined_flag_F77=' -expect_unresolved \*'
- archive_cmds_F77='$LD -shared${allow_undefined_flag} $libobjs $deplibs $linker_flags -msym -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib'
- archive_expsym_cmds_F77='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done; echo "-hidden">> $lib.exp~
- $LD -shared${allow_undefined_flag} -input $lib.exp $linker_flags $libobjs $deplibs -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib~$rm $lib.exp'
-
- # Both c and cxx compiler support -rpath directly
- hardcode_libdir_flag_spec_F77='-rpath $libdir'
- fi
- hardcode_libdir_separator_F77=:
- ;;
-
- solaris*)
- no_undefined_flag_F77=' -z text'
- if test "$GCC" = yes; then
- wlarc='${wl}'
- archive_cmds_F77='$CC -shared ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
- archive_expsym_cmds_F77='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~
- $CC -shared ${wl}-M ${wl}$lib.exp ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags~$rm $lib.exp'
- else
- wlarc=''
- archive_cmds_F77='$LD -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $linker_flags'
- archive_expsym_cmds_F77='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~
- $LD -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linker_flags~$rm $lib.exp'
- fi
- hardcode_libdir_flag_spec_F77='-R$libdir'
- hardcode_shlibpath_var_F77=no
- case $host_os in
- solaris2.[0-5] | solaris2.[0-5].*) ;;
- *)
- # The compiler driver will combine linker options so we
- # cannot just pass the convience library names through
- # without $wl, iff we do not link with $LD.
- # Luckily, gcc supports the same syntax we need for Sun Studio.
- # Supported since Solaris 2.6 (maybe 2.5.1?)
- case $wlarc in
- '')
- whole_archive_flag_spec_F77='-z allextract$convenience -z defaultextract' ;;
- *)
- whole_archive_flag_spec_F77='${wl}-z ${wl}allextract`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}-z ${wl}defaultextract' ;;
- esac ;;
- esac
- link_all_deplibs_F77=yes
- ;;
-
- sunos4*)
- if test "x$host_vendor" = xsequent; then
- # Use $CC to link under sequent, because it throws in some extra .o
- # files that make .init and .fini sections work.
- archive_cmds_F77='$CC -G ${wl}-h $soname -o $lib $libobjs $deplibs $compiler_flags'
- else
- archive_cmds_F77='$LD -assert pure-text -Bstatic -o $lib $libobjs $deplibs $linker_flags'
- fi
- hardcode_libdir_flag_spec_F77='-L$libdir'
- hardcode_direct_F77=yes
- hardcode_minus_L_F77=yes
- hardcode_shlibpath_var_F77=no
- ;;
-
- sysv4)
- case $host_vendor in
- sni)
- archive_cmds_F77='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
- hardcode_direct_F77=yes # is this really true???
- ;;
- siemens)
- ## LD is ld it makes a PLAMLIB
- ## CC just makes a GrossModule.
- archive_cmds_F77='$LD -G -o $lib $libobjs $deplibs $linker_flags'
- reload_cmds_F77='$CC -r -o $output$reload_objs'
- hardcode_direct_F77=no
- ;;
- motorola)
- archive_cmds_F77='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
- hardcode_direct_F77=no #Motorola manual says yes, but my tests say they lie
- ;;
- esac
- runpath_var='LD_RUN_PATH'
- hardcode_shlibpath_var_F77=no
- ;;
-
- sysv4.3*)
- archive_cmds_F77='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
- hardcode_shlibpath_var_F77=no
- export_dynamic_flag_spec_F77='-Bexport'
- ;;
-
- sysv4*MP*)
- if test -d /usr/nec; then
- archive_cmds_F77='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
- hardcode_shlibpath_var_F77=no
- runpath_var=LD_RUN_PATH
- hardcode_runpath_var=yes
- ld_shlibs_F77=yes
- fi
- ;;
-
- sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[01].[10]* | unixware7*)
- no_undefined_flag_F77='${wl}-z,text'
- archive_cmds_need_lc_F77=no
- hardcode_shlibpath_var_F77=no
- runpath_var='LD_RUN_PATH'
-
- if test "$GCC" = yes; then
- archive_cmds_F77='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
- archive_expsym_cmds_F77='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
- else
- archive_cmds_F77='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
- archive_expsym_cmds_F77='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
- fi
- ;;
-
- sysv5* | sco3.2v5* | sco5v6*)
- # Note: We can NOT use -z defs as we might desire, because we do not
- # link with -lc, and that would cause any symbols used from libc to
- # always be unresolved, which means just about no library would
- # ever link correctly. If we're not using GNU ld we use -z text
- # though, which does catch some bad symbols but isn't as heavy-handed
- # as -z defs.
- no_undefined_flag_F77='${wl}-z,text'
- allow_undefined_flag_F77='${wl}-z,nodefs'
- archive_cmds_need_lc_F77=no
- hardcode_shlibpath_var_F77=no
- hardcode_libdir_flag_spec_F77='`test -z "$SCOABSPATH" && echo ${wl}-R,$libdir`'
- hardcode_libdir_separator_F77=':'
- link_all_deplibs_F77=yes
- export_dynamic_flag_spec_F77='${wl}-Bexport'
- runpath_var='LD_RUN_PATH'
-
- if test "$GCC" = yes; then
- archive_cmds_F77='$CC -shared ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags'
- archive_expsym_cmds_F77='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags'
- else
- archive_cmds_F77='$CC -G ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags'
- archive_expsym_cmds_F77='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags'
- fi
- ;;
-
- uts4*)
- archive_cmds_F77='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
- hardcode_libdir_flag_spec_F77='-L$libdir'
- hardcode_shlibpath_var_F77=no
- ;;
-
- *)
- ld_shlibs_F77=no
- ;;
- esac
- fi
-
-echo "$as_me:$LINENO: result: $ld_shlibs_F77" >&5
-echo "${ECHO_T}$ld_shlibs_F77" >&6
-test "$ld_shlibs_F77" = no && can_build_shared=no
-
-#
-# Do we need to explicitly link libc?
-#
-case "x$archive_cmds_need_lc_F77" in
-x|xyes)
- # Assume -lc should be added
- archive_cmds_need_lc_F77=yes
-
- if test "$enable_shared" = yes && test "$GCC" = yes; then
- case $archive_cmds_F77 in
- *'~'*)
- # FIXME: we may have to deal with multi-command sequences.
- ;;
- '$CC '*)
- # Test whether the compiler implicitly links with -lc since on some
- # systems, -lgcc has to come before -lc. If gcc already passes -lc
- # to ld, don't add -lc before -lgcc.
- echo "$as_me:$LINENO: checking whether -lc should be explicitly linked in" >&5
-echo $ECHO_N "checking whether -lc should be explicitly linked in... $ECHO_C" >&6
- $rm conftest*
- printf "$lt_simple_compile_test_code" > conftest.$ac_ext
-
- if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
- (eval $ac_compile) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } 2>conftest.err; then
- soname=conftest
- lib=conftest
- libobjs=conftest.$ac_objext
- deplibs=
- wl=$lt_prog_compiler_wl_F77
- pic_flag=$lt_prog_compiler_pic_F77
- compiler_flags=-v
- linker_flags=-v
- verstring=
- output_objdir=.
- libname=conftest
- lt_save_allow_undefined_flag=$allow_undefined_flag_F77
- allow_undefined_flag_F77=
- if { (eval echo "$as_me:$LINENO: \"$archive_cmds_F77 2\>\&1 \| grep \" -lc \" \>/dev/null 2\>\&1\"") >&5
- (eval $archive_cmds_F77 2\>\&1 \| grep \" -lc \" \>/dev/null 2\>\&1) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }
- then
- archive_cmds_need_lc_F77=no
- else
- archive_cmds_need_lc_F77=yes
- fi
- allow_undefined_flag_F77=$lt_save_allow_undefined_flag
- else
- cat conftest.err 1>&5
- fi
- $rm conftest*
- echo "$as_me:$LINENO: result: $archive_cmds_need_lc_F77" >&5
-echo "${ECHO_T}$archive_cmds_need_lc_F77" >&6
- ;;
- esac
- fi
- ;;
-esac
-
-echo "$as_me:$LINENO: checking dynamic linker characteristics" >&5
-echo $ECHO_N "checking dynamic linker characteristics... $ECHO_C" >&6
-library_names_spec=
-libname_spec='lib$name'
-soname_spec=
-shrext_cmds=".so"
-postinstall_cmds=
-postuninstall_cmds=
-finish_cmds=
-finish_eval=
-shlibpath_var=
-shlibpath_overrides_runpath=unknown
-version_type=none
-dynamic_linker="$host_os ld.so"
-sys_lib_dlsearch_path_spec="/lib /usr/lib"
-if test "$GCC" = yes; then
- sys_lib_search_path_spec=`$CC -print-search-dirs | grep "^libraries:" | $SED -e "s/^libraries://" -e "s,=/,/,g"`
- if echo "$sys_lib_search_path_spec" | grep ';' >/dev/null ; then
- # if the path contains ";" then we assume it to be the separator
- # otherwise default to the standard path separator (i.e. ":") - it is
- # assumed that no part of a normal pathname contains ";" but that should
- # okay in the real world where ";" in dirpaths is itself problematic.
- sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'`
- else
- sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"`
- fi
-else
- sys_lib_search_path_spec="/lib /usr/lib /usr/local/lib"
-fi
-need_lib_prefix=unknown
-hardcode_into_libs=no
-
-# when you set need_version to no, make sure it does not cause -set_version
-# flags to be left without arguments
-need_version=unknown
-
-case $host_os in
-aix3*)
- version_type=linux
- library_names_spec='${libname}${release}${shared_ext}$versuffix $libname.a'
- shlibpath_var=LIBPATH
-
- # AIX 3 has no versioning support, so we append a major version to the name.
- soname_spec='${libname}${release}${shared_ext}$major'
- ;;
-
-aix4* | aix5*)
- version_type=linux
- need_lib_prefix=no
- need_version=no
- hardcode_into_libs=yes
- if test "$host_cpu" = ia64; then
- # AIX 5 supports IA64
- library_names_spec='${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext}$versuffix $libname${shared_ext}'
- shlibpath_var=LD_LIBRARY_PATH
- else
- # With GCC up to 2.95.x, collect2 would create an import file
- # for dependence libraries. The import file would start with
- # the line `#! .'. This would cause the generated library to
- # depend on `.', always an invalid library. This was fixed in
- # development snapshots of GCC prior to 3.0.
- case $host_os in
- aix4 | aix4.[01] | aix4.[01].*)
- if { echo '#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 97)'
- echo ' yes '
- echo '#endif'; } | ${CC} -E - | grep yes > /dev/null; then
- :
- else
- can_build_shared=no
- fi
- ;;
- esac
- # AIX (on Power*) has no versioning support, so currently we can not hardcode correct
- # soname into executable. Probably we can add versioning support to
- # collect2, so additional links can be useful in future.
- if test "$aix_use_runtimelinking" = yes; then
- # If using run time linking (on AIX 4.2 or later) use lib<name>.so
- # instead of lib<name>.a to let people know that these are not
- # typical AIX shared libraries.
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
- else
- # We preserve .a as extension for shared libraries through AIX4.2
- # and later when we are not doing run time linking.
- library_names_spec='${libname}${release}.a $libname.a'
- soname_spec='${libname}${release}${shared_ext}$major'
- fi
- shlibpath_var=LIBPATH
- fi
- ;;
-
-amigaos*)
- library_names_spec='$libname.ixlibrary $libname.a'
- # Create ${libname}_ixlibrary.a entries in /sys/libs.
- finish_eval='for lib in `ls $libdir/*.ixlibrary 2>/dev/null`; do libname=`$echo "X$lib" | $Xsed -e '\''s%^.*/\([^/]*\)\.ixlibrary$%\1%'\''`; test $rm /sys/libs/${libname}_ixlibrary.a; $show "cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a"; cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a || exit 1; done'
- ;;
-
-beos*)
- library_names_spec='${libname}${shared_ext}'
- dynamic_linker="$host_os ld.so"
- shlibpath_var=LIBRARY_PATH
- ;;
-
-bsdi[45]*)
- version_type=linux
- need_version=no
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
- soname_spec='${libname}${release}${shared_ext}$major'
- finish_cmds='PATH="\$PATH:/sbin" ldconfig $libdir'
- shlibpath_var=LD_LIBRARY_PATH
- sys_lib_search_path_spec="/shlib /usr/lib /usr/X11/lib /usr/contrib/lib /lib /usr/local/lib"
- sys_lib_dlsearch_path_spec="/shlib /usr/lib /usr/local/lib"
- # the default ld.so.conf also contains /usr/contrib/lib and
- # /usr/X11R6/lib (/usr/X11 is a link to /usr/X11R6), but let us allow
- # libtool to hard-code these into programs
- ;;
-
-cygwin* | mingw* | pw32*)
- version_type=windows
- shrext_cmds=".dll"
- need_version=no
- need_lib_prefix=no
-
- case $GCC,$host_os in
- yes,cygwin* | yes,mingw* | yes,pw32*)
- library_names_spec='$libname.dll.a'
- # DLL is installed to $(libdir)/../bin by postinstall_cmds
- postinstall_cmds='base_file=`basename \${file}`~
- dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i;echo \$dlname'\''`~
- dldir=$destdir/`dirname \$dlpath`~
- test -d \$dldir || mkdir -p \$dldir~
- $install_prog $dir/$dlname \$dldir/$dlname~
- chmod a+x \$dldir/$dlname'
- postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~
- dlpath=$dir/\$dldll~
- $rm \$dlpath'
- shlibpath_overrides_runpath=yes
-
- case $host_os in
- cygwin*)
- # Cygwin DLLs use 'cyg' prefix rather than 'lib'
- soname_spec='`echo ${libname} | sed -e 's/^lib/cyg/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}'
- sys_lib_search_path_spec="/usr/lib /lib/w32api /lib /usr/local/lib"
- ;;
- mingw*)
- # MinGW DLLs use traditional 'lib' prefix
- soname_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}'
- sys_lib_search_path_spec=`$CC -print-search-dirs | grep "^libraries:" | $SED -e "s/^libraries://" -e "s,=/,/,g"`
- if echo "$sys_lib_search_path_spec" | grep ';[c-zC-Z]:/' >/dev/null; then
- # It is most probably a Windows format PATH printed by
- # mingw gcc, but we are running on Cygwin. Gcc prints its search
- # path with ; separators, and with drive letters. We can handle the
- # drive letters (cygwin fileutils understands them), so leave them,
- # especially as we might pass files found there to a mingw objdump,
- # which wouldn't understand a cygwinified path. Ahh.
- sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'`
- else
- sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"`
- fi
- ;;
- pw32*)
- # pw32 DLLs use 'pw' prefix rather than 'lib'
- library_names_spec='`echo ${libname} | sed -e 's/^lib/pw/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}'
- ;;
- esac
- ;;
-
- *)
- library_names_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext} $libname.lib'
- ;;
- esac
- dynamic_linker='Win32 ld.exe'
- # FIXME: first we should search . and the directory the executable is in
- shlibpath_var=PATH
- ;;
-
-darwin* | rhapsody*)
- dynamic_linker="$host_os dyld"
- version_type=darwin
- need_lib_prefix=no
- need_version=no
- library_names_spec='${libname}${release}${versuffix}$shared_ext ${libname}${release}${major}$shared_ext ${libname}$shared_ext'
- soname_spec='${libname}${release}${major}$shared_ext'
- shlibpath_overrides_runpath=yes
- shlibpath_var=DYLD_LIBRARY_PATH
- shrext_cmds='`test .$module = .yes && echo .so || echo .dylib`'
- # Apple's gcc prints 'gcc -print-search-dirs' doesn't operate the same.
- if test "$GCC" = yes; then
- sys_lib_search_path_spec=`$CC -print-search-dirs | tr "\n" "$PATH_SEPARATOR" | sed -e 's/libraries:/@libraries:/' | tr "@" "\n" | grep "^libraries:" | sed -e "s/^libraries://" -e "s,=/,/,g" -e "s,$PATH_SEPARATOR, ,g" -e "s,.*,& /lib /usr/lib /usr/local/lib,g"`
- else
- sys_lib_search_path_spec='/lib /usr/lib /usr/local/lib'
- fi
- sys_lib_dlsearch_path_spec='/usr/local/lib /lib /usr/lib'
- ;;
-
-dgux*)
- version_type=linux
- need_lib_prefix=no
- need_version=no
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname$shared_ext'
- soname_spec='${libname}${release}${shared_ext}$major'
- shlibpath_var=LD_LIBRARY_PATH
- ;;
-
-freebsd1*)
- dynamic_linker=no
- ;;
-
-kfreebsd*-gnu)
- version_type=linux
- need_lib_prefix=no
- need_version=no
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
- soname_spec='${libname}${release}${shared_ext}$major'
- shlibpath_var=LD_LIBRARY_PATH
- shlibpath_overrides_runpath=no
- hardcode_into_libs=yes
- dynamic_linker='GNU ld.so'
- ;;
-
-freebsd* | dragonfly*)
- # DragonFly does not have aout. When/if they implement a new
- # versioning mechanism, adjust this.
- if test -x /usr/bin/objformat; then
- objformat=`/usr/bin/objformat`
- else
- case $host_os in
- freebsd[123]*) objformat=aout ;;
- *) objformat=elf ;;
- esac
- fi
- version_type=freebsd-$objformat
- case $version_type in
- freebsd-elf*)
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}'
- need_version=no
- need_lib_prefix=no
- ;;
- freebsd-*)
- library_names_spec='${libname}${release}${shared_ext}$versuffix $libname${shared_ext}$versuffix'
- need_version=yes
- ;;
- esac
- shlibpath_var=LD_LIBRARY_PATH
- case $host_os in
- freebsd2*)
- shlibpath_overrides_runpath=yes
- ;;
- freebsd3.[01]* | freebsdelf3.[01]*)
- shlibpath_overrides_runpath=yes
- hardcode_into_libs=yes
- ;;
- freebsd3.[2-9]* | freebsdelf3.[2-9]* | \
- freebsd4.[0-5] | freebsdelf4.[0-5] | freebsd4.1.1 | freebsdelf4.1.1)
- shlibpath_overrides_runpath=no
- hardcode_into_libs=yes
- ;;
- freebsd*) # from 4.6 on
- shlibpath_overrides_runpath=yes
- hardcode_into_libs=yes
- ;;
- esac
- ;;
-
-gnu*)
- version_type=linux
- need_lib_prefix=no
- need_version=no
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}'
- soname_spec='${libname}${release}${shared_ext}$major'
- shlibpath_var=LD_LIBRARY_PATH
- hardcode_into_libs=yes
- ;;
-
-hpux9* | hpux10* | hpux11*)
- # Give a soname corresponding to the major version so that dld.sl refuses to
- # link against other versions.
- version_type=sunos
- need_lib_prefix=no
- need_version=no
- case $host_cpu in
- ia64*)
- shrext_cmds='.so'
- hardcode_into_libs=yes
- dynamic_linker="$host_os dld.so"
- shlibpath_var=LD_LIBRARY_PATH
- shlibpath_overrides_runpath=yes # Unless +noenvvar is specified.
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
- soname_spec='${libname}${release}${shared_ext}$major'
- if test "X$HPUX_IA64_MODE" = X32; then
- sys_lib_search_path_spec="/usr/lib/hpux32 /usr/local/lib/hpux32 /usr/local/lib"
- else
- sys_lib_search_path_spec="/usr/lib/hpux64 /usr/local/lib/hpux64"
- fi
- sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec
- ;;
- hppa*64*)
- shrext_cmds='.sl'
- hardcode_into_libs=yes
- dynamic_linker="$host_os dld.sl"
- shlibpath_var=LD_LIBRARY_PATH # How should we handle SHLIB_PATH
- shlibpath_overrides_runpath=yes # Unless +noenvvar is specified.
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
- soname_spec='${libname}${release}${shared_ext}$major'
- sys_lib_search_path_spec="/usr/lib/pa20_64 /usr/ccs/lib/pa20_64"
- sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec
- ;;
- *)
- shrext_cmds='.sl'
- dynamic_linker="$host_os dld.sl"
- shlibpath_var=SHLIB_PATH
- shlibpath_overrides_runpath=no # +s is required to enable SHLIB_PATH
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
- soname_spec='${libname}${release}${shared_ext}$major'
- ;;
- esac
- # HP-UX runs *really* slowly unless shared libraries are mode 555.
- postinstall_cmds='chmod 555 $lib'
- ;;
-
-interix3*)
- version_type=linux
- need_lib_prefix=no
- need_version=no
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
- soname_spec='${libname}${release}${shared_ext}$major'
- dynamic_linker='Interix 3.x ld.so.1 (PE, like ELF)'
- shlibpath_var=LD_LIBRARY_PATH
- shlibpath_overrides_runpath=no
- hardcode_into_libs=yes
- ;;
-
-irix5* | irix6* | nonstopux*)
- case $host_os in
- nonstopux*) version_type=nonstopux ;;
- *)
- if test "$lt_cv_prog_gnu_ld" = yes; then
- version_type=linux
- else
- version_type=irix
- fi ;;
- esac
- need_lib_prefix=no
- need_version=no
- soname_spec='${libname}${release}${shared_ext}$major'
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext} $libname${shared_ext}'
- case $host_os in
- irix5* | nonstopux*)
- libsuff= shlibsuff=
- ;;
- *)
- case $LD in # libtool.m4 will add one of these switches to LD
- *-32|*"-32 "|*-melf32bsmip|*"-melf32bsmip ")
- libsuff= shlibsuff= libmagic=32-bit;;
- *-n32|*"-n32 "|*-melf32bmipn32|*"-melf32bmipn32 ")
- libsuff=32 shlibsuff=N32 libmagic=N32;;
- *-64|*"-64 "|*-melf64bmip|*"-melf64bmip ")
- libsuff=64 shlibsuff=64 libmagic=64-bit;;
- *) libsuff= shlibsuff= libmagic=never-match;;
- esac
- ;;
- esac
- shlibpath_var=LD_LIBRARY${shlibsuff}_PATH
- shlibpath_overrides_runpath=no
- sys_lib_search_path_spec="/usr/lib${libsuff} /lib${libsuff} /usr/local/lib${libsuff}"
- sys_lib_dlsearch_path_spec="/usr/lib${libsuff} /lib${libsuff}"
- hardcode_into_libs=yes
- ;;
-
-# No shared lib support for Linux oldld, aout, or coff.
-linux*oldld* | linux*aout* | linux*coff*)
- dynamic_linker=no
- ;;
-
-# This must be Linux ELF.
-linux*)
- version_type=linux
- need_lib_prefix=no
- need_version=no
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
- soname_spec='${libname}${release}${shared_ext}$major'
- finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir'
- shlibpath_var=LD_LIBRARY_PATH
- shlibpath_overrides_runpath=no
- # This implies no fast_install, which is unacceptable.
- # Some rework will be needed to allow for fast_install
- # before this can be enabled.
- hardcode_into_libs=yes
-
- # Append ld.so.conf contents to the search path
- if test -f /etc/ld.so.conf; then
- lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s", \$2)); skip = 1; } { if (!skip) print \$0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;s/[:, ]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;/^$/d' | tr '\n' ' '`
- sys_lib_dlsearch_path_spec="/lib /usr/lib $lt_ld_extra"
- fi
-
- # We used to test for /lib/ld.so.1 and disable shared libraries on
- # powerpc, because MkLinux only supported shared libraries with the
- # GNU dynamic linker. Since this was broken with cross compilers,
- # most powerpc-linux boxes support dynamic linking these days and
- # people can always --disable-shared, the test was removed, and we
- # assume the GNU/Linux dynamic linker is in use.
- dynamic_linker='GNU/Linux ld.so'
- ;;
-
-netbsdelf*-gnu)
- version_type=linux
- need_lib_prefix=no
- need_version=no
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
- soname_spec='${libname}${release}${shared_ext}$major'
- shlibpath_var=LD_LIBRARY_PATH
- shlibpath_overrides_runpath=no
- hardcode_into_libs=yes
- dynamic_linker='NetBSD ld.elf_so'
- ;;
-
-knetbsd*-gnu)
- version_type=linux
- need_lib_prefix=no
- need_version=no
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
- soname_spec='${libname}${release}${shared_ext}$major'
- shlibpath_var=LD_LIBRARY_PATH
- shlibpath_overrides_runpath=no
- hardcode_into_libs=yes
- dynamic_linker='GNU ld.so'
- ;;
-
-netbsd*)
- version_type=sunos
- need_lib_prefix=no
- need_version=no
- if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
- finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir'
- dynamic_linker='NetBSD (a.out) ld.so'
- else
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
- soname_spec='${libname}${release}${shared_ext}$major'
- dynamic_linker='NetBSD ld.elf_so'
- fi
- shlibpath_var=LD_LIBRARY_PATH
- shlibpath_overrides_runpath=yes
- hardcode_into_libs=yes
- ;;
-
-newsos6)
- version_type=linux
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
- shlibpath_var=LD_LIBRARY_PATH
- shlibpath_overrides_runpath=yes
- ;;
-
-nto-qnx*)
- version_type=linux
- need_lib_prefix=no
- need_version=no
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
- soname_spec='${libname}${release}${shared_ext}$major'
- shlibpath_var=LD_LIBRARY_PATH
- shlibpath_overrides_runpath=yes
- ;;
-
-openbsd*)
- version_type=sunos
- sys_lib_dlsearch_path_spec="/usr/lib"
- need_lib_prefix=no
- # Some older versions of OpenBSD (3.3 at least) *do* need versioned libs.
- case $host_os in
- openbsd3.3 | openbsd3.3.*) need_version=yes ;;
- *) need_version=no ;;
- esac
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
- finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir'
- shlibpath_var=LD_LIBRARY_PATH
- if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
- case $host_os in
- openbsd2.[89] | openbsd2.[89].*)
- shlibpath_overrides_runpath=no
- ;;
- *)
- shlibpath_overrides_runpath=yes
- ;;
- esac
- else
- shlibpath_overrides_runpath=yes
- fi
- ;;
-
-os2*)
- libname_spec='$name'
- shrext_cmds=".dll"
- need_lib_prefix=no
- library_names_spec='$libname${shared_ext} $libname.a'
- dynamic_linker='OS/2 ld.exe'
- shlibpath_var=LIBPATH
- ;;
-
-osf3* | osf4* | osf5*)
- version_type=osf
- need_lib_prefix=no
- need_version=no
- soname_spec='${libname}${release}${shared_ext}$major'
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
- shlibpath_var=LD_LIBRARY_PATH
- sys_lib_search_path_spec="/usr/shlib /usr/ccs/lib /usr/lib/cmplrs/cc /usr/lib /usr/local/lib /var/shlib"
- sys_lib_dlsearch_path_spec="$sys_lib_search_path_spec"
- ;;
-
-solaris*)
- version_type=linux
- need_lib_prefix=no
- need_version=no
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
- soname_spec='${libname}${release}${shared_ext}$major'
- shlibpath_var=LD_LIBRARY_PATH
- shlibpath_overrides_runpath=yes
- hardcode_into_libs=yes
- # ldd complains unless libraries are executable
- postinstall_cmds='chmod +x $lib'
- ;;
-
-sunos4*)
- version_type=sunos
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
- finish_cmds='PATH="\$PATH:/usr/etc" ldconfig $libdir'
- shlibpath_var=LD_LIBRARY_PATH
- shlibpath_overrides_runpath=yes
- if test "$with_gnu_ld" = yes; then
- need_lib_prefix=no
- fi
- need_version=yes
- ;;
-
-sysv4 | sysv4.3*)
- version_type=linux
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
- soname_spec='${libname}${release}${shared_ext}$major'
- shlibpath_var=LD_LIBRARY_PATH
- case $host_vendor in
- sni)
- shlibpath_overrides_runpath=no
- need_lib_prefix=no
- export_dynamic_flag_spec='${wl}-Blargedynsym'
- runpath_var=LD_RUN_PATH
- ;;
- siemens)
- need_lib_prefix=no
- ;;
- motorola)
- need_lib_prefix=no
- need_version=no
- shlibpath_overrides_runpath=no
- sys_lib_search_path_spec='/lib /usr/lib /usr/ccs/lib'
- ;;
- esac
- ;;
-
-sysv4*MP*)
- if test -d /usr/nec ;then
- version_type=linux
- library_names_spec='$libname${shared_ext}.$versuffix $libname${shared_ext}.$major $libname${shared_ext}'
- soname_spec='$libname${shared_ext}.$major'
- shlibpath_var=LD_LIBRARY_PATH
- fi
- ;;
-
-sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*)
- version_type=freebsd-elf
- need_lib_prefix=no
- need_version=no
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}'
- soname_spec='${libname}${release}${shared_ext}$major'
- shlibpath_var=LD_LIBRARY_PATH
- hardcode_into_libs=yes
- if test "$with_gnu_ld" = yes; then
- sys_lib_search_path_spec='/usr/local/lib /usr/gnu/lib /usr/ccs/lib /usr/lib /lib'
- shlibpath_overrides_runpath=no
- else
- sys_lib_search_path_spec='/usr/ccs/lib /usr/lib'
- shlibpath_overrides_runpath=yes
- case $host_os in
- sco3.2v5*)
- sys_lib_search_path_spec="$sys_lib_search_path_spec /lib"
- ;;
- esac
- fi
- sys_lib_dlsearch_path_spec='/usr/lib'
- ;;
-
-uts4*)
- version_type=linux
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
- soname_spec='${libname}${release}${shared_ext}$major'
- shlibpath_var=LD_LIBRARY_PATH
- ;;
-
-*)
- dynamic_linker=no
- ;;
-esac
-echo "$as_me:$LINENO: result: $dynamic_linker" >&5
-echo "${ECHO_T}$dynamic_linker" >&6
-test "$dynamic_linker" = no && can_build_shared=no
-
-variables_saved_for_relink="PATH $shlibpath_var $runpath_var"
-if test "$GCC" = yes; then
- variables_saved_for_relink="$variables_saved_for_relink GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH"
-fi
-
-echo "$as_me:$LINENO: checking how to hardcode library paths into programs" >&5
-echo $ECHO_N "checking how to hardcode library paths into programs... $ECHO_C" >&6
-hardcode_action_F77=
-if test -n "$hardcode_libdir_flag_spec_F77" || \
- test -n "$runpath_var_F77" || \
- test "X$hardcode_automatic_F77" = "Xyes" ; then
-
- # We can hardcode non-existant directories.
- if test "$hardcode_direct_F77" != no &&
- # If the only mechanism to avoid hardcoding is shlibpath_var, we
- # have to relink, otherwise we might link with an installed library
- # when we should be linking with a yet-to-be-installed one
- ## test "$_LT_AC_TAGVAR(hardcode_shlibpath_var, F77)" != no &&
- test "$hardcode_minus_L_F77" != no; then
- # Linking always hardcodes the temporary library directory.
- hardcode_action_F77=relink
- else
- # We can link without hardcoding, and we can hardcode nonexisting dirs.
- hardcode_action_F77=immediate
- fi
-else
- # We cannot hardcode anything, or else we can only hardcode existing
- # directories.
- hardcode_action_F77=unsupported
-fi
-echo "$as_me:$LINENO: result: $hardcode_action_F77" >&5
-echo "${ECHO_T}$hardcode_action_F77" >&6
-
-if test "$hardcode_action_F77" = relink; then
- # Fast installation is not supported
- enable_fast_install=no
-elif test "$shlibpath_overrides_runpath" = yes ||
- test "$enable_shared" = no; then
- # Fast installation is not necessary
- enable_fast_install=needless
-fi
-
-
-# The else clause should only fire when bootstrapping the
-# libtool distribution, otherwise you forgot to ship ltmain.sh
-# with your package, and you will get complaints that there are
-# no rules to generate ltmain.sh.
-if test -f "$ltmain"; then
- # See if we are running on zsh, and set the options which allow our commands through
- # without removal of \ escapes.
- if test -n "${ZSH_VERSION+set}" ; then
- setopt NO_GLOB_SUBST
- fi
- # Now quote all the things that may contain metacharacters while being
- # careful not to overquote the AC_SUBSTed values. We take copies of the
- # variables and quote the copies for generation of the libtool script.
- for var in echo old_CC old_CFLAGS AR AR_FLAGS EGREP RANLIB LN_S LTCC LTCFLAGS NM \
- SED SHELL STRIP \
- libname_spec library_names_spec soname_spec extract_expsyms_cmds \
- old_striplib striplib file_magic_cmd finish_cmds finish_eval \
- deplibs_check_method reload_flag reload_cmds need_locks \
- lt_cv_sys_global_symbol_pipe lt_cv_sys_global_symbol_to_cdecl \
- lt_cv_sys_global_symbol_to_c_name_address \
- sys_lib_search_path_spec sys_lib_dlsearch_path_spec \
- old_postinstall_cmds old_postuninstall_cmds \
- compiler_F77 \
- CC_F77 \
- LD_F77 \
- lt_prog_compiler_wl_F77 \
- lt_prog_compiler_pic_F77 \
- lt_prog_compiler_static_F77 \
- lt_prog_compiler_no_builtin_flag_F77 \
- export_dynamic_flag_spec_F77 \
- thread_safe_flag_spec_F77 \
- whole_archive_flag_spec_F77 \
- enable_shared_with_static_runtimes_F77 \
- old_archive_cmds_F77 \
- old_archive_from_new_cmds_F77 \
- predep_objects_F77 \
- postdep_objects_F77 \
- predeps_F77 \
- postdeps_F77 \
- compiler_lib_search_path_F77 \
- archive_cmds_F77 \
- archive_expsym_cmds_F77 \
- postinstall_cmds_F77 \
- postuninstall_cmds_F77 \
- old_archive_from_expsyms_cmds_F77 \
- allow_undefined_flag_F77 \
- no_undefined_flag_F77 \
- export_symbols_cmds_F77 \
- hardcode_libdir_flag_spec_F77 \
- hardcode_libdir_flag_spec_ld_F77 \
- hardcode_libdir_separator_F77 \
- hardcode_automatic_F77 \
- module_cmds_F77 \
- module_expsym_cmds_F77 \
- lt_cv_prog_compiler_c_o_F77 \
- exclude_expsyms_F77 \
- include_expsyms_F77; do
-
- case $var in
- old_archive_cmds_F77 | \
- old_archive_from_new_cmds_F77 | \
- archive_cmds_F77 | \
- archive_expsym_cmds_F77 | \
- module_cmds_F77 | \
- module_expsym_cmds_F77 | \
- old_archive_from_expsyms_cmds_F77 | \
- export_symbols_cmds_F77 | \
- extract_expsyms_cmds | reload_cmds | finish_cmds | \
- postinstall_cmds | postuninstall_cmds | \
- old_postinstall_cmds | old_postuninstall_cmds | \
- sys_lib_search_path_spec | sys_lib_dlsearch_path_spec)
- # Double-quote double-evaled strings.
- eval "lt_$var=\\\"\`\$echo \"X\$$var\" | \$Xsed -e \"\$double_quote_subst\" -e \"\$sed_quote_subst\" -e \"\$delay_variable_subst\"\`\\\""
- ;;
- *)
- eval "lt_$var=\\\"\`\$echo \"X\$$var\" | \$Xsed -e \"\$sed_quote_subst\"\`\\\""
- ;;
- esac
- done
-
- case $lt_echo in
- *'\$0 --fallback-echo"')
- lt_echo=`$echo "X$lt_echo" | $Xsed -e 's/\\\\\\\$0 --fallback-echo"$/$0 --fallback-echo"/'`
- ;;
- esac
-
-cfgfile="$ofile"
-
- cat <<__EOF__ >> "$cfgfile"
-# ### BEGIN LIBTOOL TAG CONFIG: $tagname
-
-# Libtool was configured on host `(hostname || uname -n) 2>/dev/null | sed 1q`:
-
-# Shell to use when invoking shell scripts.
-SHELL=$lt_SHELL
-
-# Whether or not to build shared libraries.
-build_libtool_libs=$enable_shared
-
-# Whether or not to build static libraries.
-build_old_libs=$enable_static
-
-# Whether or not to add -lc for building shared libraries.
-build_libtool_need_lc=$archive_cmds_need_lc_F77
-
-# Whether or not to disallow shared libs when runtime libs are static
-allow_libtool_libs_with_static_runtimes=$enable_shared_with_static_runtimes_F77
-
-# Whether or not to optimize for fast installation.
-fast_install=$enable_fast_install
-
-# The host system.
-host_alias=$host_alias
-host=$host
-host_os=$host_os
-
-# The build system.
-build_alias=$build_alias
-build=$build
-build_os=$build_os
-
-# An echo program that does not interpret backslashes.
-echo=$lt_echo
-
-# The archiver.
-AR=$lt_AR
-AR_FLAGS=$lt_AR_FLAGS
-
-# A C compiler.
-LTCC=$lt_LTCC
-
-# LTCC compiler flags.
-LTCFLAGS=$lt_LTCFLAGS
-
-# A language-specific compiler.
-CC=$lt_compiler_F77
-
-# Is the compiler the GNU C compiler?
-with_gcc=$GCC_F77
-
-# An ERE matcher.
-EGREP=$lt_EGREP
-
-# The linker used to build libraries.
-LD=$lt_LD_F77
-
-# Whether we need hard or soft links.
-LN_S=$lt_LN_S
-
-# A BSD-compatible nm program.
-NM=$lt_NM
-
-# A symbol stripping program
-STRIP=$lt_STRIP
-
-# Used to examine libraries when file_magic_cmd begins "file"
-MAGIC_CMD=$MAGIC_CMD
-
-# Used on cygwin: DLL creation program.
-DLLTOOL="$DLLTOOL"
-
-# Used on cygwin: object dumper.
-OBJDUMP="$OBJDUMP"
-
-# Used on cygwin: assembler.
-AS="$AS"
-
-# The name of the directory that contains temporary libtool files.
-objdir=$objdir
-
-# How to create reloadable object files.
-reload_flag=$lt_reload_flag
-reload_cmds=$lt_reload_cmds
-
-# How to pass a linker flag through the compiler.
-wl=$lt_lt_prog_compiler_wl_F77
-
-# Object file suffix (normally "o").
-objext="$ac_objext"
-
-# Old archive suffix (normally "a").
-libext="$libext"
-
-# Shared library suffix (normally ".so").
-shrext_cmds='$shrext_cmds'
-
-# Executable file suffix (normally "").
-exeext="$exeext"
-
-# Additional compiler flags for building library objects.
-pic_flag=$lt_lt_prog_compiler_pic_F77
-pic_mode=$pic_mode
-
-# What is the maximum length of a command?
-max_cmd_len=$lt_cv_sys_max_cmd_len
-
-# Does compiler simultaneously support -c and -o options?
-compiler_c_o=$lt_lt_cv_prog_compiler_c_o_F77
-
-# Must we lock files when doing compilation?
-need_locks=$lt_need_locks
-
-# Do we need the lib prefix for modules?
-need_lib_prefix=$need_lib_prefix
-
-# Do we need a version for libraries?
-need_version=$need_version
-
-# Whether dlopen is supported.
-dlopen_support=$enable_dlopen
-
-# Whether dlopen of programs is supported.
-dlopen_self=$enable_dlopen_self
-
-# Whether dlopen of statically linked programs is supported.
-dlopen_self_static=$enable_dlopen_self_static
-
-# Compiler flag to prevent dynamic linking.
-link_static_flag=$lt_lt_prog_compiler_static_F77
-
-# Compiler flag to turn off builtin functions.
-no_builtin_flag=$lt_lt_prog_compiler_no_builtin_flag_F77
-
-# Compiler flag to allow reflexive dlopens.
-export_dynamic_flag_spec=$lt_export_dynamic_flag_spec_F77
-
-# Compiler flag to generate shared objects directly from archives.
-whole_archive_flag_spec=$lt_whole_archive_flag_spec_F77
-
-# Compiler flag to generate thread-safe objects.
-thread_safe_flag_spec=$lt_thread_safe_flag_spec_F77
-
-# Library versioning type.
-version_type=$version_type
-
-# Format of library name prefix.
-libname_spec=$lt_libname_spec
-
-# List of archive names. First name is the real one, the rest are links.
-# The last name is the one that the linker finds with -lNAME.
-library_names_spec=$lt_library_names_spec
-
-# The coded name of the library, if different from the real name.
-soname_spec=$lt_soname_spec
-
-# Commands used to build and install an old-style archive.
-RANLIB=$lt_RANLIB
-old_archive_cmds=$lt_old_archive_cmds_F77
-old_postinstall_cmds=$lt_old_postinstall_cmds
-old_postuninstall_cmds=$lt_old_postuninstall_cmds
-
-# Create an old-style archive from a shared archive.
-old_archive_from_new_cmds=$lt_old_archive_from_new_cmds_F77
-
-# Create a temporary old-style archive to link instead of a shared archive.
-old_archive_from_expsyms_cmds=$lt_old_archive_from_expsyms_cmds_F77
-
-# Commands used to build and install a shared archive.
-archive_cmds=$lt_archive_cmds_F77
-archive_expsym_cmds=$lt_archive_expsym_cmds_F77
-postinstall_cmds=$lt_postinstall_cmds
-postuninstall_cmds=$lt_postuninstall_cmds
-
-# Commands used to build a loadable module (assumed same as above if empty)
-module_cmds=$lt_module_cmds_F77
-module_expsym_cmds=$lt_module_expsym_cmds_F77
-
-# Commands to strip libraries.
-old_striplib=$lt_old_striplib
-striplib=$lt_striplib
-
-# Dependencies to place before the objects being linked to create a
-# shared library.
-predep_objects=$lt_predep_objects_F77
-
-# Dependencies to place after the objects being linked to create a
-# shared library.
-postdep_objects=$lt_postdep_objects_F77
-
-# Dependencies to place before the objects being linked to create a
-# shared library.
-predeps=$lt_predeps_F77
-
-# Dependencies to place after the objects being linked to create a
-# shared library.
-postdeps=$lt_postdeps_F77
-
-# The library search path used internally by the compiler when linking
-# a shared library.
-compiler_lib_search_path=$lt_compiler_lib_search_path_F77
-
-# Method to check whether dependent libraries are shared objects.
-deplibs_check_method=$lt_deplibs_check_method
-
-# Command to use when deplibs_check_method == file_magic.
-file_magic_cmd=$lt_file_magic_cmd
-
-# Flag that allows shared libraries with undefined symbols to be built.
-allow_undefined_flag=$lt_allow_undefined_flag_F77
-
-# Flag that forces no undefined symbols.
-no_undefined_flag=$lt_no_undefined_flag_F77
-
-# Commands used to finish a libtool library installation in a directory.
-finish_cmds=$lt_finish_cmds
-
-# Same as above, but a single script fragment to be evaled but not shown.
-finish_eval=$lt_finish_eval
-
-# Take the output of nm and produce a listing of raw symbols and C names.
-global_symbol_pipe=$lt_lt_cv_sys_global_symbol_pipe
-
-# Transform the output of nm in a proper C declaration
-global_symbol_to_cdecl=$lt_lt_cv_sys_global_symbol_to_cdecl
-
-# Transform the output of nm in a C name address pair
-global_symbol_to_c_name_address=$lt_lt_cv_sys_global_symbol_to_c_name_address
-
-# This is the shared library runtime path variable.
-runpath_var=$runpath_var
-
-# This is the shared library path variable.
-shlibpath_var=$shlibpath_var
-
-# Is shlibpath searched before the hard-coded library search path?
-shlibpath_overrides_runpath=$shlibpath_overrides_runpath
-
-# How to hardcode a shared library path into an executable.
-hardcode_action=$hardcode_action_F77
-
-# Whether we should hardcode library paths into libraries.
-hardcode_into_libs=$hardcode_into_libs
-
-# Flag to hardcode \$libdir into a binary during linking.
-# This must work even if \$libdir does not exist.
-hardcode_libdir_flag_spec=$lt_hardcode_libdir_flag_spec_F77
-
-# If ld is used when linking, flag to hardcode \$libdir into
-# a binary during linking. This must work even if \$libdir does
-# not exist.
-hardcode_libdir_flag_spec_ld=$lt_hardcode_libdir_flag_spec_ld_F77
-
-# Whether we need a single -rpath flag with a separated argument.
-hardcode_libdir_separator=$lt_hardcode_libdir_separator_F77
-
-# Set to yes if using DIR/libNAME${shared_ext} during linking hardcodes DIR into the
-# resulting binary.
-hardcode_direct=$hardcode_direct_F77
-
-# Set to yes if using the -LDIR flag during linking hardcodes DIR into the
-# resulting binary.
-hardcode_minus_L=$hardcode_minus_L_F77
-
-# Set to yes if using SHLIBPATH_VAR=DIR during linking hardcodes DIR into
-# the resulting binary.
-hardcode_shlibpath_var=$hardcode_shlibpath_var_F77
-
-# Set to yes if building a shared library automatically hardcodes DIR into the library
-# and all subsequent libraries and executables linked against it.
-hardcode_automatic=$hardcode_automatic_F77
-
-# Variables whose values should be saved in libtool wrapper scripts and
-# restored at relink time.
-variables_saved_for_relink="$variables_saved_for_relink"
-
-# Whether libtool must link a program against all its dependency libraries.
-link_all_deplibs=$link_all_deplibs_F77
-
-# Compile-time system search path for libraries
-sys_lib_search_path_spec=$lt_sys_lib_search_path_spec
-
-# Run-time system search path for libraries
-sys_lib_dlsearch_path_spec=$lt_sys_lib_dlsearch_path_spec
-
-# Fix the shell variable \$srcfile for the compiler.
-fix_srcfile_path="$fix_srcfile_path_F77"
-
-# Set to yes if exported symbols are required.
-always_export_symbols=$always_export_symbols_F77
-
-# The commands to list exported symbols.
-export_symbols_cmds=$lt_export_symbols_cmds_F77
-
-# The commands to extract the exported symbol list from a shared archive.
-extract_expsyms_cmds=$lt_extract_expsyms_cmds
-
-# Symbols that should not be listed in the preloaded symbols.
-exclude_expsyms=$lt_exclude_expsyms_F77
-
-# Symbols that must always be exported.
-include_expsyms=$lt_include_expsyms_F77
-
-# ### END LIBTOOL TAG CONFIG: $tagname
-
-__EOF__
-
-
-else
- # If there is no Makefile yet, we rely on a make rule to execute
- # `config.status --recheck' to rerun these tests and create the
- # libtool script then.
- ltmain_in=`echo $ltmain | sed -e 's/\.sh$/.in/'`
- if test -f "$ltmain_in"; then
- test -f Makefile && make "$ltmain"
- fi
-fi
-
-
-ac_ext=c
-ac_cpp='$CPP $CPPFLAGS'
-ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
-ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
-ac_compiler_gnu=$ac_cv_c_compiler_gnu
-
-CC="$lt_save_CC"
-
- else
- tagname=""
- fi
- ;;
-
- GCJ)
- if test -n "$GCJ" && test "X$GCJ" != "Xno"; then
-
-
-
-# Source file extension for Java test sources.
-ac_ext=java
-
-# Object file extension for compiled Java test sources.
-objext=o
-objext_GCJ=$objext
-
-# Code to be used in simple compile tests
-lt_simple_compile_test_code="class foo {}\n"
-
-# Code to be used in simple link tests
-lt_simple_link_test_code='public class conftest { public static void main(String[] argv) {}; }\n'
-
-# ltmain only uses $CC for tagged configurations so make sure $CC is set.
-
-# If no C compiler was specified, use CC.
-LTCC=${LTCC-"$CC"}
-
-# If no C compiler flags were specified, use CFLAGS.
-LTCFLAGS=${LTCFLAGS-"$CFLAGS"}
-
-# Allow CC to be a program name with arguments.
-compiler=$CC
-
-
-# save warnings/boilerplate of simple test code
-ac_outfile=conftest.$ac_objext
-printf "$lt_simple_compile_test_code" >conftest.$ac_ext
-eval "$ac_compile" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err
-_lt_compiler_boilerplate=`cat conftest.err`
-$rm conftest*
-
-ac_outfile=conftest.$ac_objext
-printf "$lt_simple_link_test_code" >conftest.$ac_ext
-eval "$ac_link" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err
-_lt_linker_boilerplate=`cat conftest.err`
-$rm conftest*
-
-
-# Allow CC to be a program name with arguments.
-lt_save_CC="$CC"
-CC=${GCJ-"gcj"}
-compiler=$CC
-compiler_GCJ=$CC
-for cc_temp in $compiler""; do
- case $cc_temp in
- compile | *[\\/]compile | ccache | *[\\/]ccache ) ;;
- distcc | *[\\/]distcc | purify | *[\\/]purify ) ;;
- \-*) ;;
- *) break;;
- esac
-done
-cc_basename=`$echo "X$cc_temp" | $Xsed -e 's%.*/%%' -e "s%^$host_alias-%%"`
-
-
-# GCJ did not exist at the time GCC didn't implicitly link libc in.
-archive_cmds_need_lc_GCJ=no
-
-old_archive_cmds_GCJ=$old_archive_cmds
-
-
-lt_prog_compiler_no_builtin_flag_GCJ=
-
-if test "$GCC" = yes; then
- lt_prog_compiler_no_builtin_flag_GCJ=' -fno-builtin'
-
-
-echo "$as_me:$LINENO: checking if $compiler supports -fno-rtti -fno-exceptions" >&5
-echo $ECHO_N "checking if $compiler supports -fno-rtti -fno-exceptions... $ECHO_C" >&6
-if test "${lt_cv_prog_compiler_rtti_exceptions+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- lt_cv_prog_compiler_rtti_exceptions=no
- ac_outfile=conftest.$ac_objext
- printf "$lt_simple_compile_test_code" > conftest.$ac_ext
- lt_compiler_flag="-fno-rtti -fno-exceptions"
- # Insert the option either (1) after the last *FLAGS variable, or
- # (2) before a word containing "conftest.", or (3) at the end.
- # Note that $ac_compile itself does not contain backslashes and begins
- # with a dollar sign (not a hyphen), so the echo should work correctly.
- # The option is referenced via a variable to avoid confusing sed.
- lt_compile=`echo "$ac_compile" | $SED \
- -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
- -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
- -e 's:$: $lt_compiler_flag:'`
- (eval echo "\"\$as_me:15512: $lt_compile\"" >&5)
- (eval "$lt_compile" 2>conftest.err)
- ac_status=$?
- cat conftest.err >&5
- echo "$as_me:15516: \$? = $ac_status" >&5
- if (exit $ac_status) && test -s "$ac_outfile"; then
- # The compiler can only warn and ignore the option if not recognized
- # So say no if there are warnings other than the usual output.
- $echo "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' >conftest.exp
- $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2
- if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then
- lt_cv_prog_compiler_rtti_exceptions=yes
- fi
- fi
- $rm conftest*
-
-fi
-echo "$as_me:$LINENO: result: $lt_cv_prog_compiler_rtti_exceptions" >&5
-echo "${ECHO_T}$lt_cv_prog_compiler_rtti_exceptions" >&6
-
-if test x"$lt_cv_prog_compiler_rtti_exceptions" = xyes; then
- lt_prog_compiler_no_builtin_flag_GCJ="$lt_prog_compiler_no_builtin_flag_GCJ -fno-rtti -fno-exceptions"
-else
- :
-fi
-
-fi
-
-lt_prog_compiler_wl_GCJ=
-lt_prog_compiler_pic_GCJ=
-lt_prog_compiler_static_GCJ=
-
-echo "$as_me:$LINENO: checking for $compiler option to produce PIC" >&5
-echo $ECHO_N "checking for $compiler option to produce PIC... $ECHO_C" >&6
-
- if test "$GCC" = yes; then
- lt_prog_compiler_wl_GCJ='-Wl,'
- lt_prog_compiler_static_GCJ='-static'
-
- case $host_os in
- aix*)
- # All AIX code is PIC.
- if test "$host_cpu" = ia64; then
- # AIX 5 now supports IA64 processor
- lt_prog_compiler_static_GCJ='-Bstatic'
- fi
- ;;
-
- amigaos*)
- # FIXME: we need at least 68020 code to build shared libraries, but
- # adding the `-m68020' flag to GCC prevents building anything better,
- # like `-m68040'.
- lt_prog_compiler_pic_GCJ='-m68020 -resident32 -malways-restore-a4'
- ;;
-
- beos* | cygwin* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*)
- # PIC is the default for these OSes.
- ;;
-
- mingw* | pw32* | os2*)
- # This hack is so that the source file can tell whether it is being
- # built for inclusion in a dll (and should export symbols for example).
- lt_prog_compiler_pic_GCJ='-DDLL_EXPORT'
- ;;
-
- darwin* | rhapsody*)
- # PIC is the default on this platform
- # Common symbols not allowed in MH_DYLIB files
- lt_prog_compiler_pic_GCJ='-fno-common'
- ;;
-
- interix3*)
- # Interix 3.x gcc -fpic/-fPIC options generate broken code.
- # Instead, we relocate shared libraries at runtime.
- ;;
-
- msdosdjgpp*)
- # Just because we use GCC doesn't mean we suddenly get shared libraries
- # on systems that don't support them.
- lt_prog_compiler_can_build_shared_GCJ=no
- enable_shared=no
- ;;
-
- sysv4*MP*)
- if test -d /usr/nec; then
- lt_prog_compiler_pic_GCJ=-Kconform_pic
- fi
- ;;
-
- hpux*)
- # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but
- # not for PA HP-UX.
- case $host_cpu in
- hppa*64*|ia64*)
- # +Z the default
- ;;
- *)
- lt_prog_compiler_pic_GCJ='-fPIC'
- ;;
- esac
- ;;
-
- *)
- lt_prog_compiler_pic_GCJ='-fPIC'
- ;;
- esac
- else
- # PORTME Check for flag to pass linker flags through the system compiler.
- case $host_os in
- aix*)
- lt_prog_compiler_wl_GCJ='-Wl,'
- if test "$host_cpu" = ia64; then
- # AIX 5 now supports IA64 processor
- lt_prog_compiler_static_GCJ='-Bstatic'
- else
- lt_prog_compiler_static_GCJ='-bnso -bI:/lib/syscalls.exp'
- fi
- ;;
- darwin*)
- # PIC is the default on this platform
- # Common symbols not allowed in MH_DYLIB files
- case $cc_basename in
- xlc*)
- lt_prog_compiler_pic_GCJ='-qnocommon'
- lt_prog_compiler_wl_GCJ='-Wl,'
- ;;
- esac
- ;;
-
- mingw* | pw32* | os2*)
- # This hack is so that the source file can tell whether it is being
- # built for inclusion in a dll (and should export symbols for example).
- lt_prog_compiler_pic_GCJ='-DDLL_EXPORT'
- ;;
-
- hpux9* | hpux10* | hpux11*)
- lt_prog_compiler_wl_GCJ='-Wl,'
- # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but
- # not for PA HP-UX.
- case $host_cpu in
- hppa*64*|ia64*)
- # +Z the default
- ;;
- *)
- lt_prog_compiler_pic_GCJ='+Z'
- ;;
- esac
- # Is there a better lt_prog_compiler_static that works with the bundled CC?
- lt_prog_compiler_static_GCJ='${wl}-a ${wl}archive'
- ;;
-
- irix5* | irix6* | nonstopux*)
- lt_prog_compiler_wl_GCJ='-Wl,'
- # PIC (with -KPIC) is the default.
- lt_prog_compiler_static_GCJ='-non_shared'
- ;;
-
- newsos6)
- lt_prog_compiler_pic_GCJ='-KPIC'
- lt_prog_compiler_static_GCJ='-Bstatic'
- ;;
-
- linux*)
- case $cc_basename in
- icc* | ecc*)
- lt_prog_compiler_wl_GCJ='-Wl,'
- lt_prog_compiler_pic_GCJ='-KPIC'
- lt_prog_compiler_static_GCJ='-static'
- ;;
- pgcc* | pgf77* | pgf90* | pgf95*)
- # Portland Group compilers (*not* the Pentium gcc compiler,
- # which looks to be a dead project)
- lt_prog_compiler_wl_GCJ='-Wl,'
- lt_prog_compiler_pic_GCJ='-fpic'
- lt_prog_compiler_static_GCJ='-Bstatic'
- ;;
- ccc*)
- lt_prog_compiler_wl_GCJ='-Wl,'
- # All Alpha code is PIC.
- lt_prog_compiler_static_GCJ='-non_shared'
- ;;
- esac
- ;;
-
- osf3* | osf4* | osf5*)
- lt_prog_compiler_wl_GCJ='-Wl,'
- # All OSF/1 code is PIC.
- lt_prog_compiler_static_GCJ='-non_shared'
- ;;
-
- solaris*)
- lt_prog_compiler_pic_GCJ='-KPIC'
- lt_prog_compiler_static_GCJ='-Bstatic'
- case $cc_basename in
- f77* | f90* | f95*)
- lt_prog_compiler_wl_GCJ='-Qoption ld ';;
- *)
- lt_prog_compiler_wl_GCJ='-Wl,';;
- esac
- ;;
-
- sunos4*)
- lt_prog_compiler_wl_GCJ='-Qoption ld '
- lt_prog_compiler_pic_GCJ='-PIC'
- lt_prog_compiler_static_GCJ='-Bstatic'
- ;;
-
- sysv4 | sysv4.2uw2* | sysv4.3*)
- lt_prog_compiler_wl_GCJ='-Wl,'
- lt_prog_compiler_pic_GCJ='-KPIC'
- lt_prog_compiler_static_GCJ='-Bstatic'
- ;;
-
- sysv4*MP*)
- if test -d /usr/nec ;then
- lt_prog_compiler_pic_GCJ='-Kconform_pic'
- lt_prog_compiler_static_GCJ='-Bstatic'
- fi
- ;;
-
- sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*)
- lt_prog_compiler_wl_GCJ='-Wl,'
- lt_prog_compiler_pic_GCJ='-KPIC'
- lt_prog_compiler_static_GCJ='-Bstatic'
- ;;
-
- unicos*)
- lt_prog_compiler_wl_GCJ='-Wl,'
- lt_prog_compiler_can_build_shared_GCJ=no
- ;;
-
- uts4*)
- lt_prog_compiler_pic_GCJ='-pic'
- lt_prog_compiler_static_GCJ='-Bstatic'
- ;;
-
- *)
- lt_prog_compiler_can_build_shared_GCJ=no
- ;;
- esac
- fi
-
-echo "$as_me:$LINENO: result: $lt_prog_compiler_pic_GCJ" >&5
-echo "${ECHO_T}$lt_prog_compiler_pic_GCJ" >&6
-
-#
-# Check to make sure the PIC flag actually works.
-#
-if test -n "$lt_prog_compiler_pic_GCJ"; then
-
-echo "$as_me:$LINENO: checking if $compiler PIC flag $lt_prog_compiler_pic_GCJ works" >&5
-echo $ECHO_N "checking if $compiler PIC flag $lt_prog_compiler_pic_GCJ works... $ECHO_C" >&6
-if test "${lt_prog_compiler_pic_works_GCJ+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- lt_prog_compiler_pic_works_GCJ=no
- ac_outfile=conftest.$ac_objext
- printf "$lt_simple_compile_test_code" > conftest.$ac_ext
- lt_compiler_flag="$lt_prog_compiler_pic_GCJ"
- # Insert the option either (1) after the last *FLAGS variable, or
- # (2) before a word containing "conftest.", or (3) at the end.
- # Note that $ac_compile itself does not contain backslashes and begins
- # with a dollar sign (not a hyphen), so the echo should work correctly.
- # The option is referenced via a variable to avoid confusing sed.
- lt_compile=`echo "$ac_compile" | $SED \
- -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
- -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
- -e 's:$: $lt_compiler_flag:'`
- (eval echo "\"\$as_me:15780: $lt_compile\"" >&5)
- (eval "$lt_compile" 2>conftest.err)
- ac_status=$?
- cat conftest.err >&5
- echo "$as_me:15784: \$? = $ac_status" >&5
- if (exit $ac_status) && test -s "$ac_outfile"; then
- # The compiler can only warn and ignore the option if not recognized
- # So say no if there are warnings other than the usual output.
- $echo "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' >conftest.exp
- $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2
- if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then
- lt_prog_compiler_pic_works_GCJ=yes
- fi
- fi
- $rm conftest*
-
-fi
-echo "$as_me:$LINENO: result: $lt_prog_compiler_pic_works_GCJ" >&5
-echo "${ECHO_T}$lt_prog_compiler_pic_works_GCJ" >&6
-
-if test x"$lt_prog_compiler_pic_works_GCJ" = xyes; then
- case $lt_prog_compiler_pic_GCJ in
- "" | " "*) ;;
- *) lt_prog_compiler_pic_GCJ=" $lt_prog_compiler_pic_GCJ" ;;
- esac
-else
- lt_prog_compiler_pic_GCJ=
- lt_prog_compiler_can_build_shared_GCJ=no
-fi
-
-fi
-case $host_os in
- # For platforms which do not support PIC, -DPIC is meaningless:
- *djgpp*)
- lt_prog_compiler_pic_GCJ=
- ;;
- *)
- lt_prog_compiler_pic_GCJ="$lt_prog_compiler_pic_GCJ"
- ;;
-esac
-
-#
-# Check to make sure the static flag actually works.
-#
-wl=$lt_prog_compiler_wl_GCJ eval lt_tmp_static_flag=\"$lt_prog_compiler_static_GCJ\"
-echo "$as_me:$LINENO: checking if $compiler static flag $lt_tmp_static_flag works" >&5
-echo $ECHO_N "checking if $compiler static flag $lt_tmp_static_flag works... $ECHO_C" >&6
-if test "${lt_prog_compiler_static_works_GCJ+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- lt_prog_compiler_static_works_GCJ=no
- save_LDFLAGS="$LDFLAGS"
- LDFLAGS="$LDFLAGS $lt_tmp_static_flag"
- printf "$lt_simple_link_test_code" > conftest.$ac_ext
- if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then
- # The linker can only warn and ignore the option if not recognized
- # So say no if there are warnings
- if test -s conftest.err; then
- # Append any errors to the config.log.
- cat conftest.err 1>&5
- $echo "X$_lt_linker_boilerplate" | $Xsed -e '/^$/d' > conftest.exp
- $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2
- if diff conftest.exp conftest.er2 >/dev/null; then
- lt_prog_compiler_static_works_GCJ=yes
- fi
- else
- lt_prog_compiler_static_works_GCJ=yes
- fi
- fi
- $rm conftest*
- LDFLAGS="$save_LDFLAGS"
-
-fi
-echo "$as_me:$LINENO: result: $lt_prog_compiler_static_works_GCJ" >&5
-echo "${ECHO_T}$lt_prog_compiler_static_works_GCJ" >&6
-
-if test x"$lt_prog_compiler_static_works_GCJ" = xyes; then
- :
-else
- lt_prog_compiler_static_GCJ=
-fi
-
-
-echo "$as_me:$LINENO: checking if $compiler supports -c -o file.$ac_objext" >&5
-echo $ECHO_N "checking if $compiler supports -c -o file.$ac_objext... $ECHO_C" >&6
-if test "${lt_cv_prog_compiler_c_o_GCJ+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- lt_cv_prog_compiler_c_o_GCJ=no
- $rm -r conftest 2>/dev/null
- mkdir conftest
- cd conftest
- mkdir out
- printf "$lt_simple_compile_test_code" > conftest.$ac_ext
-
- lt_compiler_flag="-o out/conftest2.$ac_objext"
- # Insert the option either (1) after the last *FLAGS variable, or
- # (2) before a word containing "conftest.", or (3) at the end.
- # Note that $ac_compile itself does not contain backslashes and begins
- # with a dollar sign (not a hyphen), so the echo should work correctly.
- lt_compile=`echo "$ac_compile" | $SED \
- -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
- -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
- -e 's:$: $lt_compiler_flag:'`
- (eval echo "\"\$as_me:15884: $lt_compile\"" >&5)
- (eval "$lt_compile" 2>out/conftest.err)
- ac_status=$?
- cat out/conftest.err >&5
- echo "$as_me:15888: \$? = $ac_status" >&5
- if (exit $ac_status) && test -s out/conftest2.$ac_objext
- then
- # The compiler can only warn and ignore the option if not recognized
- # So say no if there are warnings
- $echo "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' > out/conftest.exp
- $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2
- if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then
- lt_cv_prog_compiler_c_o_GCJ=yes
- fi
- fi
- chmod u+w . 2>&5
- $rm conftest*
- # SGI C++ compiler will create directory out/ii_files/ for
- # template instantiation
- test -d out/ii_files && $rm out/ii_files/* && rmdir out/ii_files
- $rm out/* && rmdir out
- cd ..
- rmdir conftest
- $rm conftest*
-
-fi
-echo "$as_me:$LINENO: result: $lt_cv_prog_compiler_c_o_GCJ" >&5
-echo "${ECHO_T}$lt_cv_prog_compiler_c_o_GCJ" >&6
-
-
-hard_links="nottested"
-if test "$lt_cv_prog_compiler_c_o_GCJ" = no && test "$need_locks" != no; then
- # do not overwrite the value of need_locks provided by the user
- echo "$as_me:$LINENO: checking if we can lock with hard links" >&5
-echo $ECHO_N "checking if we can lock with hard links... $ECHO_C" >&6
- hard_links=yes
- $rm conftest*
- ln conftest.a conftest.b 2>/dev/null && hard_links=no
- touch conftest.a
- ln conftest.a conftest.b 2>&5 || hard_links=no
- ln conftest.a conftest.b 2>/dev/null && hard_links=no
- echo "$as_me:$LINENO: result: $hard_links" >&5
-echo "${ECHO_T}$hard_links" >&6
- if test "$hard_links" = no; then
- { echo "$as_me:$LINENO: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&5
-echo "$as_me: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&2;}
- need_locks=warn
- fi
-else
- need_locks=no
-fi
-
-echo "$as_me:$LINENO: checking whether the $compiler linker ($LD) supports shared libraries" >&5
-echo $ECHO_N "checking whether the $compiler linker ($LD) supports shared libraries... $ECHO_C" >&6
-
- runpath_var=
- allow_undefined_flag_GCJ=
- enable_shared_with_static_runtimes_GCJ=no
- archive_cmds_GCJ=
- archive_expsym_cmds_GCJ=
- old_archive_From_new_cmds_GCJ=
- old_archive_from_expsyms_cmds_GCJ=
- export_dynamic_flag_spec_GCJ=
- whole_archive_flag_spec_GCJ=
- thread_safe_flag_spec_GCJ=
- hardcode_libdir_flag_spec_GCJ=
- hardcode_libdir_flag_spec_ld_GCJ=
- hardcode_libdir_separator_GCJ=
- hardcode_direct_GCJ=no
- hardcode_minus_L_GCJ=no
- hardcode_shlibpath_var_GCJ=unsupported
- link_all_deplibs_GCJ=unknown
- hardcode_automatic_GCJ=no
- module_cmds_GCJ=
- module_expsym_cmds_GCJ=
- always_export_symbols_GCJ=no
- export_symbols_cmds_GCJ='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols'
- # include_expsyms should be a list of space-separated symbols to be *always*
- # included in the symbol list
- include_expsyms_GCJ=
- # exclude_expsyms can be an extended regexp of symbols to exclude
- # it will be wrapped by ` (' and `)$', so one must not match beginning or
- # end of line. Example: `a|bc|.*d.*' will exclude the symbols `a' and `bc',
- # as well as any symbol that contains `d'.
- exclude_expsyms_GCJ="_GLOBAL_OFFSET_TABLE_"
- # Although _GLOBAL_OFFSET_TABLE_ is a valid symbol C name, most a.out
- # platforms (ab)use it in PIC code, but their linkers get confused if
- # the symbol is explicitly referenced. Since portable code cannot
- # rely on this symbol name, it's probably fine to never include it in
- # preloaded symbol tables.
- extract_expsyms_cmds=
- # Just being paranoid about ensuring that cc_basename is set.
- for cc_temp in $compiler""; do
- case $cc_temp in
- compile | *[\\/]compile | ccache | *[\\/]ccache ) ;;
- distcc | *[\\/]distcc | purify | *[\\/]purify ) ;;
- \-*) ;;
- *) break;;
- esac
-done
-cc_basename=`$echo "X$cc_temp" | $Xsed -e 's%.*/%%' -e "s%^$host_alias-%%"`
-
- case $host_os in
- cygwin* | mingw* | pw32*)
- # FIXME: the MSVC++ port hasn't been tested in a loooong time
- # When not using gcc, we currently assume that we are using
- # Microsoft Visual C++.
- if test "$GCC" != yes; then
- with_gnu_ld=no
- fi
- ;;
- interix*)
- # we just hope/assume this is gcc and not c89 (= MSVC++)
- with_gnu_ld=yes
- ;;
- openbsd*)
- with_gnu_ld=no
- ;;
- esac
-
- ld_shlibs_GCJ=yes
- if test "$with_gnu_ld" = yes; then
- # If archive_cmds runs LD, not CC, wlarc should be empty
- wlarc='${wl}'
-
- # Set some defaults for GNU ld with shared library support. These
- # are reset later if shared libraries are not supported. Putting them
- # here allows them to be overridden if necessary.
- runpath_var=LD_RUN_PATH
- hardcode_libdir_flag_spec_GCJ='${wl}--rpath ${wl}$libdir'
- export_dynamic_flag_spec_GCJ='${wl}--export-dynamic'
- # ancient GNU ld didn't support --whole-archive et. al.
- if $LD --help 2>&1 | grep 'no-whole-archive' > /dev/null; then
- whole_archive_flag_spec_GCJ="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive'
- else
- whole_archive_flag_spec_GCJ=
- fi
- supports_anon_versioning=no
- case `$LD -v 2>/dev/null` in
- *\ [01].* | *\ 2.[0-9].* | *\ 2.10.*) ;; # catch versions < 2.11
- *\ 2.11.93.0.2\ *) supports_anon_versioning=yes ;; # RH7.3 ...
- *\ 2.11.92.0.12\ *) supports_anon_versioning=yes ;; # Mandrake 8.2 ...
- *\ 2.11.*) ;; # other 2.11 versions
- *) supports_anon_versioning=yes ;;
- esac
-
- # See if GNU ld supports shared libraries.
- case $host_os in
- aix3* | aix4* | aix5*)
- # On AIX/PPC, the GNU linker is very broken
- if test "$host_cpu" != ia64; then
- ld_shlibs_GCJ=no
- cat <<EOF 1>&2
-
-*** Warning: the GNU linker, at least up to release 2.9.1, is reported
-*** to be unable to reliably create shared libraries on AIX.
-*** Therefore, libtool is disabling shared libraries support. If you
-*** really care for shared libraries, you may want to modify your PATH
-*** so that a non-GNU linker is found, and then restart.
-
-EOF
- fi
- ;;
-
- amigaos*)
- archive_cmds_GCJ='$rm $output_objdir/a2ixlibrary.data~$echo "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$echo "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$echo "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$echo "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)'
- hardcode_libdir_flag_spec_GCJ='-L$libdir'
- hardcode_minus_L_GCJ=yes
-
- # Samuel A. Falvo II <kc5tja@dolphin.openprojects.net> reports
- # that the semantics of dynamic libraries on AmigaOS, at least up
- # to version 4, is to share data among multiple programs linked
- # with the same dynamic library. Since this doesn't match the
- # behavior of shared libraries on other platforms, we can't use
- # them.
- ld_shlibs_GCJ=no
- ;;
-
- beos*)
- if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
- allow_undefined_flag_GCJ=unsupported
- # Joseph Beckenbach <jrb3@best.com> says some releases of gcc
- # support --undefined. This deserves some investigation. FIXME
- archive_cmds_GCJ='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
- else
- ld_shlibs_GCJ=no
- fi
- ;;
-
- cygwin* | mingw* | pw32*)
- # _LT_AC_TAGVAR(hardcode_libdir_flag_spec, GCJ) is actually meaningless,
- # as there is no search path for DLLs.
- hardcode_libdir_flag_spec_GCJ='-L$libdir'
- allow_undefined_flag_GCJ=unsupported
- always_export_symbols_GCJ=no
- enable_shared_with_static_runtimes_GCJ=yes
- export_symbols_cmds_GCJ='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[BCDGRS] /s/.* \([^ ]*\)/\1 DATA/'\'' | $SED -e '\''/^[AITW] /s/.* //'\'' | sort | uniq > $export_symbols'
-
- if $LD --help 2>&1 | grep 'auto-import' > /dev/null; then
- archive_cmds_GCJ='$CC -shared $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
- # If the export-symbols file already is a .def file (1st line
- # is EXPORTS), use it as is; otherwise, prepend...
- archive_expsym_cmds_GCJ='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then
- cp $export_symbols $output_objdir/$soname.def;
- else
- echo EXPORTS > $output_objdir/$soname.def;
- cat $export_symbols >> $output_objdir/$soname.def;
- fi~
- $CC -shared $output_objdir/$soname.def $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
- else
- ld_shlibs_GCJ=no
- fi
- ;;
-
- interix3*)
- hardcode_direct_GCJ=no
- hardcode_shlibpath_var_GCJ=no
- hardcode_libdir_flag_spec_GCJ='${wl}-rpath,$libdir'
- export_dynamic_flag_spec_GCJ='${wl}-E'
- # Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc.
- # Instead, shared libraries are loaded at an image base (0x10000000 by
- # default) and relocated if they conflict, which is a slow very memory
- # consuming and fragmenting process. To avoid this, we pick a random,
- # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link
- # time. Moving up from 0x10000000 also allows more sbrk(2) space.
- archive_cmds_GCJ='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
- archive_expsym_cmds_GCJ='sed "s,^,_," $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--retain-symbols-file,$output_objdir/$soname.expsym ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
- ;;
-
- linux*)
- if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
- tmp_addflag=
- case $cc_basename,$host_cpu in
- pgcc*) # Portland Group C compiler
- whole_archive_flag_spec_GCJ='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}--no-whole-archive'
- tmp_addflag=' $pic_flag'
- ;;
- pgf77* | pgf90* | pgf95*) # Portland Group f77 and f90 compilers
- whole_archive_flag_spec_GCJ='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}--no-whole-archive'
- tmp_addflag=' $pic_flag -Mnomain' ;;
- ecc*,ia64* | icc*,ia64*) # Intel C compiler on ia64
- tmp_addflag=' -i_dynamic' ;;
- efc*,ia64* | ifort*,ia64*) # Intel Fortran compiler on ia64
- tmp_addflag=' -i_dynamic -nofor_main' ;;
- ifc* | ifort*) # Intel Fortran compiler
- tmp_addflag=' -nofor_main' ;;
- esac
- archive_cmds_GCJ='$CC -shared'"$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
-
- if test $supports_anon_versioning = yes; then
- archive_expsym_cmds_GCJ='$echo "{ global:" > $output_objdir/$libname.ver~
- cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~
- $echo "local: *; };" >> $output_objdir/$libname.ver~
- $CC -shared'"$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib'
- fi
- link_all_deplibs_GCJ=no
- else
- ld_shlibs_GCJ=no
- fi
- ;;
-
- netbsd* | netbsdelf*-gnu | knetbsd*-gnu)
- if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then
- archive_cmds_GCJ='$LD -Bshareable $libobjs $deplibs $linker_flags -o $lib'
- wlarc=
- else
- archive_cmds_GCJ='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
- archive_expsym_cmds_GCJ='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
- fi
- ;;
-
- solaris*)
- if $LD -v 2>&1 | grep 'BFD 2\.8' > /dev/null; then
- ld_shlibs_GCJ=no
- cat <<EOF 1>&2
-
-*** Warning: The releases 2.8.* of the GNU linker cannot reliably
-*** create shared libraries on Solaris systems. Therefore, libtool
-*** is disabling shared libraries support. We urge you to upgrade GNU
-*** binutils to release 2.9.1 or newer. Another option is to modify
-*** your PATH or compiler configuration so that the native linker is
-*** used, and then restart.
-
-EOF
- elif $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
- archive_cmds_GCJ='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
- archive_expsym_cmds_GCJ='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
- else
- ld_shlibs_GCJ=no
- fi
- ;;
-
- sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX*)
- case `$LD -v 2>&1` in
- *\ [01].* | *\ 2.[0-9].* | *\ 2.1[0-5].*)
- ld_shlibs_GCJ=no
- cat <<_LT_EOF 1>&2
-
-*** Warning: Releases of the GNU linker prior to 2.16.91.0.3 can not
-*** reliably create shared libraries on SCO systems. Therefore, libtool
-*** is disabling shared libraries support. We urge you to upgrade GNU
-*** binutils to release 2.16.91.0.3 or newer. Another option is to modify
-*** your PATH or compiler configuration so that the native linker is
-*** used, and then restart.
-
-_LT_EOF
- ;;
- *)
- if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
- hardcode_libdir_flag_spec_GCJ='`test -z "$SCOABSPATH" && echo ${wl}-rpath,$libdir`'
- archive_cmds_GCJ='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib'
- archive_expsym_cmds_GCJ='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname,\${SCOABSPATH:+${install_libdir}/}$soname,-retain-symbols-file,$export_symbols -o $lib'
- else
- ld_shlibs_GCJ=no
- fi
- ;;
- esac
- ;;
-
- sunos4*)
- archive_cmds_GCJ='$LD -assert pure-text -Bshareable -o $lib $libobjs $deplibs $linker_flags'
- wlarc=
- hardcode_direct_GCJ=yes
- hardcode_shlibpath_var_GCJ=no
- ;;
-
- *)
- if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
- archive_cmds_GCJ='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
- archive_expsym_cmds_GCJ='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
- else
- ld_shlibs_GCJ=no
- fi
- ;;
- esac
-
- if test "$ld_shlibs_GCJ" = no; then
- runpath_var=
- hardcode_libdir_flag_spec_GCJ=
- export_dynamic_flag_spec_GCJ=
- whole_archive_flag_spec_GCJ=
- fi
- else
- # PORTME fill in a description of your system's linker (not GNU ld)
- case $host_os in
- aix3*)
- allow_undefined_flag_GCJ=unsupported
- always_export_symbols_GCJ=yes
- archive_expsym_cmds_GCJ='$LD -o $output_objdir/$soname $libobjs $deplibs $linker_flags -bE:$export_symbols -T512 -H512 -bM:SRE~$AR $AR_FLAGS $lib $output_objdir/$soname'
- # Note: this linker hardcodes the directories in LIBPATH if there
- # are no directories specified by -L.
- hardcode_minus_L_GCJ=yes
- if test "$GCC" = yes && test -z "$lt_prog_compiler_static"; then
- # Neither direct hardcoding nor static linking is supported with a
- # broken collect2.
- hardcode_direct_GCJ=unsupported
- fi
- ;;
-
- aix4* | aix5*)
- if test "$host_cpu" = ia64; then
- # On IA64, the linker does run time linking by default, so we don't
- # have to do anything special.
- aix_use_runtimelinking=no
- exp_sym_flag='-Bexport'
- no_entry_flag=""
- else
- # If we're using GNU nm, then we don't want the "-C" option.
- # -C means demangle to AIX nm, but means don't demangle with GNU nm
- if $NM -V 2>&1 | grep 'GNU' > /dev/null; then
- export_symbols_cmds_GCJ='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$2 == "T") || (\$2 == "D") || (\$2 == "B")) && (substr(\$3,1,1) != ".")) { print \$3 } }'\'' | sort -u > $export_symbols'
- else
- export_symbols_cmds_GCJ='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\$2 == "T") || (\$2 == "D") || (\$2 == "B")) && (substr(\$3,1,1) != ".")) { print \$3 } }'\'' | sort -u > $export_symbols'
- fi
- aix_use_runtimelinking=no
-
- # Test if we are trying to use run time linking or normal
- # AIX style linking. If -brtl is somewhere in LDFLAGS, we
- # need to do runtime linking.
- case $host_os in aix4.[23]|aix4.[23].*|aix5*)
- for ld_flag in $LDFLAGS; do
- if (test $ld_flag = "-brtl" || test $ld_flag = "-Wl,-brtl"); then
- aix_use_runtimelinking=yes
- break
- fi
- done
- ;;
- esac
-
- exp_sym_flag='-bexport'
- no_entry_flag='-bnoentry'
- fi
-
- # When large executables or shared objects are built, AIX ld can
- # have problems creating the table of contents. If linking a library
- # or program results in "error TOC overflow" add -mminimal-toc to
- # CXXFLAGS/CFLAGS for g++/gcc. In the cases where that is not
- # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS.
-
- archive_cmds_GCJ=''
- hardcode_direct_GCJ=yes
- hardcode_libdir_separator_GCJ=':'
- link_all_deplibs_GCJ=yes
-
- if test "$GCC" = yes; then
- case $host_os in aix4.[012]|aix4.[012].*)
- # We only want to do this on AIX 4.2 and lower, the check
- # below for broken collect2 doesn't work under 4.3+
- collect2name=`${CC} -print-prog-name=collect2`
- if test -f "$collect2name" && \
- strings "$collect2name" | grep resolve_lib_name >/dev/null
- then
- # We have reworked collect2
- hardcode_direct_GCJ=yes
- else
- # We have old collect2
- hardcode_direct_GCJ=unsupported
- # It fails to find uninstalled libraries when the uninstalled
- # path is not listed in the libpath. Setting hardcode_minus_L
- # to unsupported forces relinking
- hardcode_minus_L_GCJ=yes
- hardcode_libdir_flag_spec_GCJ='-L$libdir'
- hardcode_libdir_separator_GCJ=
- fi
- ;;
- esac
- shared_flag='-shared'
- if test "$aix_use_runtimelinking" = yes; then
- shared_flag="$shared_flag "'${wl}-G'
- fi
- else
- # not using gcc
- if test "$host_cpu" = ia64; then
- # VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release
- # chokes on -Wl,-G. The following line is correct:
- shared_flag='-G'
- else
- if test "$aix_use_runtimelinking" = yes; then
- shared_flag='${wl}-G'
- else
- shared_flag='${wl}-bM:SRE'
- fi
- fi
- fi
-
- # It seems that -bexpall does not export symbols beginning with
- # underscore (_), so it is better to generate a list of symbols to export.
- always_export_symbols_GCJ=yes
- if test "$aix_use_runtimelinking" = yes; then
- # Warning - without using the other runtime loading flags (-brtl),
- # -berok will link without error, but may produce a broken library.
- allow_undefined_flag_GCJ='-berok'
- # Determine the default libpath from the value encoded in an empty executable.
- cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-
-int
-main ()
-{
-
- ;
- return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
- (eval $ac_link) 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } &&
- { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; } &&
- { ac_try='test -s conftest$ac_exeext'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
-
-aix_libpath=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; }
-}'`
-# Check for a 64-bit object if we didn't find anything.
-if test -z "$aix_libpath"; then aix_libpath=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; }
-}'`; fi
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-fi
-rm -f conftest.err conftest.$ac_objext \
- conftest$ac_exeext conftest.$ac_ext
-if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
-
- hardcode_libdir_flag_spec_GCJ='${wl}-blibpath:$libdir:'"$aix_libpath"
- archive_expsym_cmds_GCJ="\$CC"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then echo "${wl}${allow_undefined_flag}"; else :; fi` '"\${wl}$exp_sym_flag:\$export_symbols $shared_flag"
- else
- if test "$host_cpu" = ia64; then
- hardcode_libdir_flag_spec_GCJ='${wl}-R $libdir:/usr/lib:/lib'
- allow_undefined_flag_GCJ="-z nodefs"
- archive_expsym_cmds_GCJ="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$exp_sym_flag:\$export_symbols"
- else
- # Determine the default libpath from the value encoded in an empty executable.
- cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-
-int
-main ()
-{
-
- ;
- return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
- (eval $ac_link) 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } &&
- { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; } &&
- { ac_try='test -s conftest$ac_exeext'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
-
-aix_libpath=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; }
-}'`
-# Check for a 64-bit object if we didn't find anything.
-if test -z "$aix_libpath"; then aix_libpath=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; }
-}'`; fi
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-fi
-rm -f conftest.err conftest.$ac_objext \
- conftest$ac_exeext conftest.$ac_ext
-if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
-
- hardcode_libdir_flag_spec_GCJ='${wl}-blibpath:$libdir:'"$aix_libpath"
- # Warning - without using the other run time loading flags,
- # -berok will link without error, but may produce a broken library.
- no_undefined_flag_GCJ=' ${wl}-bernotok'
- allow_undefined_flag_GCJ=' ${wl}-berok'
- # Exported symbols can be pulled into shared objects from archives
- whole_archive_flag_spec_GCJ='$convenience'
- archive_cmds_need_lc_GCJ=yes
- # This is similar to how AIX traditionally builds its shared libraries.
- archive_expsym_cmds_GCJ="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs ${wl}-bnoentry $compiler_flags ${wl}-bE:$export_symbols${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname'
- fi
- fi
- ;;
-
- amigaos*)
- archive_cmds_GCJ='$rm $output_objdir/a2ixlibrary.data~$echo "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$echo "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$echo "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$echo "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)'
- hardcode_libdir_flag_spec_GCJ='-L$libdir'
- hardcode_minus_L_GCJ=yes
- # see comment about different semantics on the GNU ld section
- ld_shlibs_GCJ=no
- ;;
-
- bsdi[45]*)
- export_dynamic_flag_spec_GCJ=-rdynamic
- ;;
-
- cygwin* | mingw* | pw32*)
- # When not using gcc, we currently assume that we are using
- # Microsoft Visual C++.
- # hardcode_libdir_flag_spec is actually meaningless, as there is
- # no search path for DLLs.
- hardcode_libdir_flag_spec_GCJ=' '
- allow_undefined_flag_GCJ=unsupported
- # Tell ltmain to make .lib files, not .a files.
- libext=lib
- # Tell ltmain to make .dll files, not .so files.
- shrext_cmds=".dll"
- # FIXME: Setting linknames here is a bad hack.
- archive_cmds_GCJ='$CC -o $lib $libobjs $compiler_flags `echo "$deplibs" | $SED -e '\''s/ -lc$//'\''` -link -dll~linknames='
- # The linker will automatically build a .lib file if we build a DLL.
- old_archive_From_new_cmds_GCJ='true'
- # FIXME: Should let the user specify the lib program.
- old_archive_cmds_GCJ='lib /OUT:$oldlib$oldobjs$old_deplibs'
- fix_srcfile_path_GCJ='`cygpath -w "$srcfile"`'
- enable_shared_with_static_runtimes_GCJ=yes
- ;;
-
- darwin* | rhapsody*)
- case $host_os in
- rhapsody* | darwin1.[012])
- allow_undefined_flag_GCJ='${wl}-undefined ${wl}suppress'
- ;;
- *) # Darwin 1.3 on
- if test -z ${MACOSX_DEPLOYMENT_TARGET} ; then
- allow_undefined_flag_GCJ='${wl}-flat_namespace ${wl}-undefined ${wl}suppress'
- else
- case ${MACOSX_DEPLOYMENT_TARGET} in
- 10.[012])
- allow_undefined_flag_GCJ='${wl}-flat_namespace ${wl}-undefined ${wl}suppress'
- ;;
- 10.*)
- allow_undefined_flag_GCJ='${wl}-undefined ${wl}dynamic_lookup'
- ;;
- esac
- fi
- ;;
- esac
- archive_cmds_need_lc_GCJ=no
- hardcode_direct_GCJ=no
- hardcode_automatic_GCJ=yes
- hardcode_shlibpath_var_GCJ=unsupported
- whole_archive_flag_spec_GCJ=''
- link_all_deplibs_GCJ=yes
- if test "$GCC" = yes ; then
- output_verbose_link_cmd='echo'
- archive_cmds_GCJ='$CC -dynamiclib $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring'
- module_cmds_GCJ='$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags'
- # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin lds
- archive_expsym_cmds_GCJ='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -dynamiclib $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
- module_expsym_cmds_GCJ='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
- else
- case $cc_basename in
- xlc*)
- output_verbose_link_cmd='echo'
- archive_cmds_GCJ='$CC -qmkshrobj $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-install_name ${wl}`echo $rpath/$soname` $verstring'
- module_cmds_GCJ='$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags'
- # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin lds
- archive_expsym_cmds_GCJ='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -qmkshrobj $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-install_name ${wl}$rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
- module_expsym_cmds_GCJ='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
- ;;
- *)
- ld_shlibs_GCJ=no
- ;;
- esac
- fi
- ;;
-
- dgux*)
- archive_cmds_GCJ='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
- hardcode_libdir_flag_spec_GCJ='-L$libdir'
- hardcode_shlibpath_var_GCJ=no
- ;;
-
- freebsd1*)
- ld_shlibs_GCJ=no
- ;;
-
- # FreeBSD 2.2.[012] allows us to include c++rt0.o to get C++ constructor
- # support. Future versions do this automatically, but an explicit c++rt0.o
- # does not break anything, and helps significantly (at the cost of a little
- # extra space).
- freebsd2.2*)
- archive_cmds_GCJ='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags /usr/lib/c++rt0.o'
- hardcode_libdir_flag_spec_GCJ='-R$libdir'
- hardcode_direct_GCJ=yes
- hardcode_shlibpath_var_GCJ=no
- ;;
-
- # Unfortunately, older versions of FreeBSD 2 do not have this feature.
- freebsd2*)
- archive_cmds_GCJ='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags'
- hardcode_direct_GCJ=yes
- hardcode_minus_L_GCJ=yes
- hardcode_shlibpath_var_GCJ=no
- ;;
-
- # FreeBSD 3 and greater uses gcc -shared to do shared libraries.
- freebsd* | dragonfly*)
- archive_cmds_GCJ='$CC -shared -o $lib $libobjs $deplibs $compiler_flags'
- hardcode_libdir_flag_spec_GCJ='-R$libdir'
- hardcode_direct_GCJ=yes
- hardcode_shlibpath_var_GCJ=no
- ;;
-
- # GNU/kFreeBSD uses gcc -shared to do shared libraries.
- kfreebsd*-gnu)
- archive_cmds_GCJ='$CC -shared -o $lib $libobjs $deplibs $compiler_flags'
- hardcode_libdir_flag_spec_GCJ='-R$libdir'
- hardcode_direct_GCJ=yes
- hardcode_shlibpath_var_GCJ=no
- link_all_deplibs_GCJ=no
- ;;
-
- hpux9*)
- if test "$GCC" = yes; then
- archive_cmds_GCJ='$rm $output_objdir/$soname~$CC -shared -fPIC ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $libobjs $deplibs $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
- else
- archive_cmds_GCJ='$rm $output_objdir/$soname~$LD -b +b $install_libdir -o $output_objdir/$soname $libobjs $deplibs $linker_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
- fi
- hardcode_libdir_flag_spec_GCJ='${wl}+b ${wl}$libdir'
- hardcode_libdir_separator_GCJ=:
- hardcode_direct_GCJ=yes
-
- # hardcode_minus_L: Not really in the search PATH,
- # but as the default location of the library.
- hardcode_minus_L_GCJ=yes
- export_dynamic_flag_spec_GCJ='${wl}-E'
- ;;
-
- hpux10*)
- if test "$GCC" = yes -a "$with_gnu_ld" = no; then
- archive_cmds_GCJ='$CC -shared -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
- else
- archive_cmds_GCJ='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags'
- fi
- if test "$with_gnu_ld" = no; then
- hardcode_libdir_flag_spec_GCJ='${wl}+b ${wl}$libdir'
- hardcode_libdir_separator_GCJ=:
-
- hardcode_direct_GCJ=yes
- export_dynamic_flag_spec_GCJ='${wl}-E'
-
- # hardcode_minus_L: Not really in the search PATH,
- # but as the default location of the library.
- hardcode_minus_L_GCJ=yes
- fi
- ;;
-
- hpux11*)
- if test "$GCC" = yes -a "$with_gnu_ld" = no; then
- case $host_cpu in
- hppa*64*)
- archive_cmds_GCJ='$CC -shared ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
- ;;
- ia64*)
- archive_cmds_GCJ='$CC -shared ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags'
- ;;
- *)
- archive_cmds_GCJ='$CC -shared -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
- ;;
- esac
- else
- case $host_cpu in
- hppa*64*)
- archive_cmds_GCJ='$CC -b ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
- ;;
- ia64*)
- archive_cmds_GCJ='$CC -b ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags'
- ;;
- *)
- archive_cmds_GCJ='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
- ;;
- esac
- fi
- if test "$with_gnu_ld" = no; then
- hardcode_libdir_flag_spec_GCJ='${wl}+b ${wl}$libdir'
- hardcode_libdir_separator_GCJ=:
-
- case $host_cpu in
- hppa*64*|ia64*)
- hardcode_libdir_flag_spec_ld_GCJ='+b $libdir'
- hardcode_direct_GCJ=no
- hardcode_shlibpath_var_GCJ=no
- ;;
- *)
- hardcode_direct_GCJ=yes
- export_dynamic_flag_spec_GCJ='${wl}-E'
-
- # hardcode_minus_L: Not really in the search PATH,
- # but as the default location of the library.
- hardcode_minus_L_GCJ=yes
- ;;
- esac
- fi
- ;;
-
- irix5* | irix6* | nonstopux*)
- if test "$GCC" = yes; then
- archive_cmds_GCJ='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
- else
- archive_cmds_GCJ='$LD -shared $libobjs $deplibs $linker_flags -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib'
- hardcode_libdir_flag_spec_ld_GCJ='-rpath $libdir'
- fi
- hardcode_libdir_flag_spec_GCJ='${wl}-rpath ${wl}$libdir'
- hardcode_libdir_separator_GCJ=:
- link_all_deplibs_GCJ=yes
- ;;
-
- netbsd* | netbsdelf*-gnu | knetbsd*-gnu)
- if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then
- archive_cmds_GCJ='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' # a.out
- else
- archive_cmds_GCJ='$LD -shared -o $lib $libobjs $deplibs $linker_flags' # ELF
- fi
- hardcode_libdir_flag_spec_GCJ='-R$libdir'
- hardcode_direct_GCJ=yes
- hardcode_shlibpath_var_GCJ=no
- ;;
-
- newsos6)
- archive_cmds_GCJ='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
- hardcode_direct_GCJ=yes
- hardcode_libdir_flag_spec_GCJ='${wl}-rpath ${wl}$libdir'
- hardcode_libdir_separator_GCJ=:
- hardcode_shlibpath_var_GCJ=no
- ;;
-
- openbsd*)
- hardcode_direct_GCJ=yes
- hardcode_shlibpath_var_GCJ=no
- if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
- archive_cmds_GCJ='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags'
- archive_expsym_cmds_GCJ='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-retain-symbols-file,$export_symbols'
- hardcode_libdir_flag_spec_GCJ='${wl}-rpath,$libdir'
- export_dynamic_flag_spec_GCJ='${wl}-E'
- else
- case $host_os in
- openbsd[01].* | openbsd2.[0-7] | openbsd2.[0-7].*)
- archive_cmds_GCJ='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags'
- hardcode_libdir_flag_spec_GCJ='-R$libdir'
- ;;
- *)
- archive_cmds_GCJ='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags'
- hardcode_libdir_flag_spec_GCJ='${wl}-rpath,$libdir'
- ;;
- esac
- fi
- ;;
-
- os2*)
- hardcode_libdir_flag_spec_GCJ='-L$libdir'
- hardcode_minus_L_GCJ=yes
- allow_undefined_flag_GCJ=unsupported
- archive_cmds_GCJ='$echo "LIBRARY $libname INITINSTANCE" > $output_objdir/$libname.def~$echo "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~$echo DATA >> $output_objdir/$libname.def~$echo " SINGLE NONSHARED" >> $output_objdir/$libname.def~$echo EXPORTS >> $output_objdir/$libname.def~emxexp $libobjs >> $output_objdir/$libname.def~$CC -Zdll -Zcrtdll -o $lib $libobjs $deplibs $compiler_flags $output_objdir/$libname.def'
- old_archive_From_new_cmds_GCJ='emximp -o $output_objdir/$libname.a $output_objdir/$libname.def'
- ;;
-
- osf3*)
- if test "$GCC" = yes; then
- allow_undefined_flag_GCJ=' ${wl}-expect_unresolved ${wl}\*'
- archive_cmds_GCJ='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
- else
- allow_undefined_flag_GCJ=' -expect_unresolved \*'
- archive_cmds_GCJ='$LD -shared${allow_undefined_flag} $libobjs $deplibs $linker_flags -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib'
- fi
- hardcode_libdir_flag_spec_GCJ='${wl}-rpath ${wl}$libdir'
- hardcode_libdir_separator_GCJ=:
- ;;
-
- osf4* | osf5*) # as osf3* with the addition of -msym flag
- if test "$GCC" = yes; then
- allow_undefined_flag_GCJ=' ${wl}-expect_unresolved ${wl}\*'
- archive_cmds_GCJ='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
- hardcode_libdir_flag_spec_GCJ='${wl}-rpath ${wl}$libdir'
- else
- allow_undefined_flag_GCJ=' -expect_unresolved \*'
- archive_cmds_GCJ='$LD -shared${allow_undefined_flag} $libobjs $deplibs $linker_flags -msym -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib'
- archive_expsym_cmds_GCJ='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done; echo "-hidden">> $lib.exp~
- $LD -shared${allow_undefined_flag} -input $lib.exp $linker_flags $libobjs $deplibs -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib~$rm $lib.exp'
-
- # Both c and cxx compiler support -rpath directly
- hardcode_libdir_flag_spec_GCJ='-rpath $libdir'
- fi
- hardcode_libdir_separator_GCJ=:
- ;;
-
- solaris*)
- no_undefined_flag_GCJ=' -z text'
- if test "$GCC" = yes; then
- wlarc='${wl}'
- archive_cmds_GCJ='$CC -shared ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
- archive_expsym_cmds_GCJ='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~
- $CC -shared ${wl}-M ${wl}$lib.exp ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags~$rm $lib.exp'
- else
- wlarc=''
- archive_cmds_GCJ='$LD -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $linker_flags'
- archive_expsym_cmds_GCJ='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~
- $LD -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linker_flags~$rm $lib.exp'
- fi
- hardcode_libdir_flag_spec_GCJ='-R$libdir'
- hardcode_shlibpath_var_GCJ=no
- case $host_os in
- solaris2.[0-5] | solaris2.[0-5].*) ;;
- *)
- # The compiler driver will combine linker options so we
- # cannot just pass the convience library names through
- # without $wl, iff we do not link with $LD.
- # Luckily, gcc supports the same syntax we need for Sun Studio.
- # Supported since Solaris 2.6 (maybe 2.5.1?)
- case $wlarc in
- '')
- whole_archive_flag_spec_GCJ='-z allextract$convenience -z defaultextract' ;;
- *)
- whole_archive_flag_spec_GCJ='${wl}-z ${wl}allextract`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}-z ${wl}defaultextract' ;;
- esac ;;
- esac
- link_all_deplibs_GCJ=yes
- ;;
-
- sunos4*)
- if test "x$host_vendor" = xsequent; then
- # Use $CC to link under sequent, because it throws in some extra .o
- # files that make .init and .fini sections work.
- archive_cmds_GCJ='$CC -G ${wl}-h $soname -o $lib $libobjs $deplibs $compiler_flags'
- else
- archive_cmds_GCJ='$LD -assert pure-text -Bstatic -o $lib $libobjs $deplibs $linker_flags'
- fi
- hardcode_libdir_flag_spec_GCJ='-L$libdir'
- hardcode_direct_GCJ=yes
- hardcode_minus_L_GCJ=yes
- hardcode_shlibpath_var_GCJ=no
- ;;
-
- sysv4)
- case $host_vendor in
- sni)
- archive_cmds_GCJ='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
- hardcode_direct_GCJ=yes # is this really true???
- ;;
- siemens)
- ## LD is ld it makes a PLAMLIB
- ## CC just makes a GrossModule.
- archive_cmds_GCJ='$LD -G -o $lib $libobjs $deplibs $linker_flags'
- reload_cmds_GCJ='$CC -r -o $output$reload_objs'
- hardcode_direct_GCJ=no
- ;;
- motorola)
- archive_cmds_GCJ='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
- hardcode_direct_GCJ=no #Motorola manual says yes, but my tests say they lie
- ;;
- esac
- runpath_var='LD_RUN_PATH'
- hardcode_shlibpath_var_GCJ=no
- ;;
-
- sysv4.3*)
- archive_cmds_GCJ='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
- hardcode_shlibpath_var_GCJ=no
- export_dynamic_flag_spec_GCJ='-Bexport'
- ;;
-
- sysv4*MP*)
- if test -d /usr/nec; then
- archive_cmds_GCJ='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
- hardcode_shlibpath_var_GCJ=no
- runpath_var=LD_RUN_PATH
- hardcode_runpath_var=yes
- ld_shlibs_GCJ=yes
- fi
- ;;
-
- sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[01].[10]* | unixware7*)
- no_undefined_flag_GCJ='${wl}-z,text'
- archive_cmds_need_lc_GCJ=no
- hardcode_shlibpath_var_GCJ=no
- runpath_var='LD_RUN_PATH'
-
- if test "$GCC" = yes; then
- archive_cmds_GCJ='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
- archive_expsym_cmds_GCJ='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
- else
- archive_cmds_GCJ='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
- archive_expsym_cmds_GCJ='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
- fi
- ;;
-
- sysv5* | sco3.2v5* | sco5v6*)
- # Note: We can NOT use -z defs as we might desire, because we do not
- # link with -lc, and that would cause any symbols used from libc to
- # always be unresolved, which means just about no library would
- # ever link correctly. If we're not using GNU ld we use -z text
- # though, which does catch some bad symbols but isn't as heavy-handed
- # as -z defs.
- no_undefined_flag_GCJ='${wl}-z,text'
- allow_undefined_flag_GCJ='${wl}-z,nodefs'
- archive_cmds_need_lc_GCJ=no
- hardcode_shlibpath_var_GCJ=no
- hardcode_libdir_flag_spec_GCJ='`test -z "$SCOABSPATH" && echo ${wl}-R,$libdir`'
- hardcode_libdir_separator_GCJ=':'
- link_all_deplibs_GCJ=yes
- export_dynamic_flag_spec_GCJ='${wl}-Bexport'
- runpath_var='LD_RUN_PATH'
-
- if test "$GCC" = yes; then
- archive_cmds_GCJ='$CC -shared ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags'
- archive_expsym_cmds_GCJ='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags'
- else
- archive_cmds_GCJ='$CC -G ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags'
- archive_expsym_cmds_GCJ='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,\${SCOABSPATH:+${install_libdir}/}$soname -o $lib $libobjs $deplibs $compiler_flags'
- fi
- ;;
-
- uts4*)
- archive_cmds_GCJ='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
- hardcode_libdir_flag_spec_GCJ='-L$libdir'
- hardcode_shlibpath_var_GCJ=no
- ;;
-
- *)
- ld_shlibs_GCJ=no
- ;;
- esac
- fi
-
-echo "$as_me:$LINENO: result: $ld_shlibs_GCJ" >&5
-echo "${ECHO_T}$ld_shlibs_GCJ" >&6
-test "$ld_shlibs_GCJ" = no && can_build_shared=no
-
-#
-# Do we need to explicitly link libc?
-#
-case "x$archive_cmds_need_lc_GCJ" in
-x|xyes)
- # Assume -lc should be added
- archive_cmds_need_lc_GCJ=yes
-
- if test "$enable_shared" = yes && test "$GCC" = yes; then
- case $archive_cmds_GCJ in
- *'~'*)
- # FIXME: we may have to deal with multi-command sequences.
- ;;
- '$CC '*)
- # Test whether the compiler implicitly links with -lc since on some
- # systems, -lgcc has to come before -lc. If gcc already passes -lc
- # to ld, don't add -lc before -lgcc.
- echo "$as_me:$LINENO: checking whether -lc should be explicitly linked in" >&5
-echo $ECHO_N "checking whether -lc should be explicitly linked in... $ECHO_C" >&6
- $rm conftest*
- printf "$lt_simple_compile_test_code" > conftest.$ac_ext
-
- if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
- (eval $ac_compile) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } 2>conftest.err; then
- soname=conftest
- lib=conftest
- libobjs=conftest.$ac_objext
- deplibs=
- wl=$lt_prog_compiler_wl_GCJ
- pic_flag=$lt_prog_compiler_pic_GCJ
- compiler_flags=-v
- linker_flags=-v
- verstring=
- output_objdir=.
- libname=conftest
- lt_save_allow_undefined_flag=$allow_undefined_flag_GCJ
- allow_undefined_flag_GCJ=
- if { (eval echo "$as_me:$LINENO: \"$archive_cmds_GCJ 2\>\&1 \| grep \" -lc \" \>/dev/null 2\>\&1\"") >&5
- (eval $archive_cmds_GCJ 2\>\&1 \| grep \" -lc \" \>/dev/null 2\>\&1) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }
- then
- archive_cmds_need_lc_GCJ=no
- else
- archive_cmds_need_lc_GCJ=yes
- fi
- allow_undefined_flag_GCJ=$lt_save_allow_undefined_flag
- else
- cat conftest.err 1>&5
- fi
- $rm conftest*
- echo "$as_me:$LINENO: result: $archive_cmds_need_lc_GCJ" >&5
-echo "${ECHO_T}$archive_cmds_need_lc_GCJ" >&6
- ;;
- esac
- fi
- ;;
-esac
-
-echo "$as_me:$LINENO: checking dynamic linker characteristics" >&5
-echo $ECHO_N "checking dynamic linker characteristics... $ECHO_C" >&6
-library_names_spec=
-libname_spec='lib$name'
-soname_spec=
-shrext_cmds=".so"
-postinstall_cmds=
-postuninstall_cmds=
-finish_cmds=
-finish_eval=
-shlibpath_var=
-shlibpath_overrides_runpath=unknown
-version_type=none
-dynamic_linker="$host_os ld.so"
-sys_lib_dlsearch_path_spec="/lib /usr/lib"
-if test "$GCC" = yes; then
- sys_lib_search_path_spec=`$CC -print-search-dirs | grep "^libraries:" | $SED -e "s/^libraries://" -e "s,=/,/,g"`
- if echo "$sys_lib_search_path_spec" | grep ';' >/dev/null ; then
- # if the path contains ";" then we assume it to be the separator
- # otherwise default to the standard path separator (i.e. ":") - it is
- # assumed that no part of a normal pathname contains ";" but that should
- # okay in the real world where ";" in dirpaths is itself problematic.
- sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'`
- else
- sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"`
- fi
-else
- sys_lib_search_path_spec="/lib /usr/lib /usr/local/lib"
-fi
-need_lib_prefix=unknown
-hardcode_into_libs=no
-
-# when you set need_version to no, make sure it does not cause -set_version
-# flags to be left without arguments
-need_version=unknown
-
-case $host_os in
-aix3*)
- version_type=linux
- library_names_spec='${libname}${release}${shared_ext}$versuffix $libname.a'
- shlibpath_var=LIBPATH
-
- # AIX 3 has no versioning support, so we append a major version to the name.
- soname_spec='${libname}${release}${shared_ext}$major'
- ;;
-
-aix4* | aix5*)
- version_type=linux
- need_lib_prefix=no
- need_version=no
- hardcode_into_libs=yes
- if test "$host_cpu" = ia64; then
- # AIX 5 supports IA64
- library_names_spec='${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext}$versuffix $libname${shared_ext}'
- shlibpath_var=LD_LIBRARY_PATH
- else
- # With GCC up to 2.95.x, collect2 would create an import file
- # for dependence libraries. The import file would start with
- # the line `#! .'. This would cause the generated library to
- # depend on `.', always an invalid library. This was fixed in
- # development snapshots of GCC prior to 3.0.
- case $host_os in
- aix4 | aix4.[01] | aix4.[01].*)
- if { echo '#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 97)'
- echo ' yes '
- echo '#endif'; } | ${CC} -E - | grep yes > /dev/null; then
- :
- else
- can_build_shared=no
- fi
- ;;
- esac
- # AIX (on Power*) has no versioning support, so currently we can not hardcode correct
- # soname into executable. Probably we can add versioning support to
- # collect2, so additional links can be useful in future.
- if test "$aix_use_runtimelinking" = yes; then
- # If using run time linking (on AIX 4.2 or later) use lib<name>.so
- # instead of lib<name>.a to let people know that these are not
- # typical AIX shared libraries.
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
- else
- # We preserve .a as extension for shared libraries through AIX4.2
- # and later when we are not doing run time linking.
- library_names_spec='${libname}${release}.a $libname.a'
- soname_spec='${libname}${release}${shared_ext}$major'
- fi
- shlibpath_var=LIBPATH
- fi
- ;;
-
-amigaos*)
- library_names_spec='$libname.ixlibrary $libname.a'
- # Create ${libname}_ixlibrary.a entries in /sys/libs.
- finish_eval='for lib in `ls $libdir/*.ixlibrary 2>/dev/null`; do libname=`$echo "X$lib" | $Xsed -e '\''s%^.*/\([^/]*\)\.ixlibrary$%\1%'\''`; test $rm /sys/libs/${libname}_ixlibrary.a; $show "cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a"; cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a || exit 1; done'
- ;;
-
-beos*)
- library_names_spec='${libname}${shared_ext}'
- dynamic_linker="$host_os ld.so"
- shlibpath_var=LIBRARY_PATH
- ;;
-
-bsdi[45]*)
- version_type=linux
- need_version=no
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
- soname_spec='${libname}${release}${shared_ext}$major'
- finish_cmds='PATH="\$PATH:/sbin" ldconfig $libdir'
- shlibpath_var=LD_LIBRARY_PATH
- sys_lib_search_path_spec="/shlib /usr/lib /usr/X11/lib /usr/contrib/lib /lib /usr/local/lib"
- sys_lib_dlsearch_path_spec="/shlib /usr/lib /usr/local/lib"
- # the default ld.so.conf also contains /usr/contrib/lib and
- # /usr/X11R6/lib (/usr/X11 is a link to /usr/X11R6), but let us allow
- # libtool to hard-code these into programs
- ;;
-
-cygwin* | mingw* | pw32*)
- version_type=windows
- shrext_cmds=".dll"
- need_version=no
- need_lib_prefix=no
-
- case $GCC,$host_os in
- yes,cygwin* | yes,mingw* | yes,pw32*)
- library_names_spec='$libname.dll.a'
- # DLL is installed to $(libdir)/../bin by postinstall_cmds
- postinstall_cmds='base_file=`basename \${file}`~
- dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i;echo \$dlname'\''`~
- dldir=$destdir/`dirname \$dlpath`~
- test -d \$dldir || mkdir -p \$dldir~
- $install_prog $dir/$dlname \$dldir/$dlname~
- chmod a+x \$dldir/$dlname'
- postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~
- dlpath=$dir/\$dldll~
- $rm \$dlpath'
- shlibpath_overrides_runpath=yes
-
- case $host_os in
- cygwin*)
- # Cygwin DLLs use 'cyg' prefix rather than 'lib'
- soname_spec='`echo ${libname} | sed -e 's/^lib/cyg/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}'
- sys_lib_search_path_spec="/usr/lib /lib/w32api /lib /usr/local/lib"
- ;;
- mingw*)
- # MinGW DLLs use traditional 'lib' prefix
- soname_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}'
- sys_lib_search_path_spec=`$CC -print-search-dirs | grep "^libraries:" | $SED -e "s/^libraries://" -e "s,=/,/,g"`
- if echo "$sys_lib_search_path_spec" | grep ';[c-zC-Z]:/' >/dev/null; then
- # It is most probably a Windows format PATH printed by
- # mingw gcc, but we are running on Cygwin. Gcc prints its search
- # path with ; separators, and with drive letters. We can handle the
- # drive letters (cygwin fileutils understands them), so leave them,
- # especially as we might pass files found there to a mingw objdump,
- # which wouldn't understand a cygwinified path. Ahh.
- sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'`
- else
- sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"`
- fi
- ;;
- pw32*)
- # pw32 DLLs use 'pw' prefix rather than 'lib'
- library_names_spec='`echo ${libname} | sed -e 's/^lib/pw/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}'
- ;;
- esac
- ;;
-
- *)
- library_names_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext} $libname.lib'
- ;;
- esac
- dynamic_linker='Win32 ld.exe'
- # FIXME: first we should search . and the directory the executable is in
- shlibpath_var=PATH
- ;;
-
-darwin* | rhapsody*)
- dynamic_linker="$host_os dyld"
- version_type=darwin
- need_lib_prefix=no
- need_version=no
- library_names_spec='${libname}${release}${versuffix}$shared_ext ${libname}${release}${major}$shared_ext ${libname}$shared_ext'
- soname_spec='${libname}${release}${major}$shared_ext'
- shlibpath_overrides_runpath=yes
- shlibpath_var=DYLD_LIBRARY_PATH
- shrext_cmds='`test .$module = .yes && echo .so || echo .dylib`'
- # Apple's gcc prints 'gcc -print-search-dirs' doesn't operate the same.
- if test "$GCC" = yes; then
- sys_lib_search_path_spec=`$CC -print-search-dirs | tr "\n" "$PATH_SEPARATOR" | sed -e 's/libraries:/@libraries:/' | tr "@" "\n" | grep "^libraries:" | sed -e "s/^libraries://" -e "s,=/,/,g" -e "s,$PATH_SEPARATOR, ,g" -e "s,.*,& /lib /usr/lib /usr/local/lib,g"`
- else
- sys_lib_search_path_spec='/lib /usr/lib /usr/local/lib'
- fi
- sys_lib_dlsearch_path_spec='/usr/local/lib /lib /usr/lib'
- ;;
-
-dgux*)
- version_type=linux
- need_lib_prefix=no
- need_version=no
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname$shared_ext'
- soname_spec='${libname}${release}${shared_ext}$major'
- shlibpath_var=LD_LIBRARY_PATH
- ;;
-
-freebsd1*)
- dynamic_linker=no
- ;;
-
-kfreebsd*-gnu)
- version_type=linux
- need_lib_prefix=no
- need_version=no
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
- soname_spec='${libname}${release}${shared_ext}$major'
- shlibpath_var=LD_LIBRARY_PATH
- shlibpath_overrides_runpath=no
- hardcode_into_libs=yes
- dynamic_linker='GNU ld.so'
- ;;
-
-freebsd* | dragonfly*)
- # DragonFly does not have aout. When/if they implement a new
- # versioning mechanism, adjust this.
- if test -x /usr/bin/objformat; then
- objformat=`/usr/bin/objformat`
- else
- case $host_os in
- freebsd[123]*) objformat=aout ;;
- *) objformat=elf ;;
- esac
- fi
- version_type=freebsd-$objformat
- case $version_type in
- freebsd-elf*)
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}'
- need_version=no
- need_lib_prefix=no
- ;;
- freebsd-*)
- library_names_spec='${libname}${release}${shared_ext}$versuffix $libname${shared_ext}$versuffix'
- need_version=yes
- ;;
- esac
- shlibpath_var=LD_LIBRARY_PATH
- case $host_os in
- freebsd2*)
- shlibpath_overrides_runpath=yes
- ;;
- freebsd3.[01]* | freebsdelf3.[01]*)
- shlibpath_overrides_runpath=yes
- hardcode_into_libs=yes
- ;;
- freebsd3.[2-9]* | freebsdelf3.[2-9]* | \
- freebsd4.[0-5] | freebsdelf4.[0-5] | freebsd4.1.1 | freebsdelf4.1.1)
- shlibpath_overrides_runpath=no
- hardcode_into_libs=yes
- ;;
- freebsd*) # from 4.6 on
- shlibpath_overrides_runpath=yes
- hardcode_into_libs=yes
- ;;
- esac
- ;;
-
-gnu*)
- version_type=linux
- need_lib_prefix=no
- need_version=no
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}'
- soname_spec='${libname}${release}${shared_ext}$major'
- shlibpath_var=LD_LIBRARY_PATH
- hardcode_into_libs=yes
- ;;
-
-hpux9* | hpux10* | hpux11*)
- # Give a soname corresponding to the major version so that dld.sl refuses to
- # link against other versions.
- version_type=sunos
- need_lib_prefix=no
- need_version=no
- case $host_cpu in
- ia64*)
- shrext_cmds='.so'
- hardcode_into_libs=yes
- dynamic_linker="$host_os dld.so"
- shlibpath_var=LD_LIBRARY_PATH
- shlibpath_overrides_runpath=yes # Unless +noenvvar is specified.
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
- soname_spec='${libname}${release}${shared_ext}$major'
- if test "X$HPUX_IA64_MODE" = X32; then
- sys_lib_search_path_spec="/usr/lib/hpux32 /usr/local/lib/hpux32 /usr/local/lib"
- else
- sys_lib_search_path_spec="/usr/lib/hpux64 /usr/local/lib/hpux64"
- fi
- sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec
- ;;
- hppa*64*)
- shrext_cmds='.sl'
- hardcode_into_libs=yes
- dynamic_linker="$host_os dld.sl"
- shlibpath_var=LD_LIBRARY_PATH # How should we handle SHLIB_PATH
- shlibpath_overrides_runpath=yes # Unless +noenvvar is specified.
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
- soname_spec='${libname}${release}${shared_ext}$major'
- sys_lib_search_path_spec="/usr/lib/pa20_64 /usr/ccs/lib/pa20_64"
- sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec
- ;;
- *)
- shrext_cmds='.sl'
- dynamic_linker="$host_os dld.sl"
- shlibpath_var=SHLIB_PATH
- shlibpath_overrides_runpath=no # +s is required to enable SHLIB_PATH
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
- soname_spec='${libname}${release}${shared_ext}$major'
- ;;
- esac
- # HP-UX runs *really* slowly unless shared libraries are mode 555.
- postinstall_cmds='chmod 555 $lib'
- ;;
-
-interix3*)
- version_type=linux
- need_lib_prefix=no
- need_version=no
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
- soname_spec='${libname}${release}${shared_ext}$major'
- dynamic_linker='Interix 3.x ld.so.1 (PE, like ELF)'
- shlibpath_var=LD_LIBRARY_PATH
- shlibpath_overrides_runpath=no
- hardcode_into_libs=yes
- ;;
-
-irix5* | irix6* | nonstopux*)
- case $host_os in
- nonstopux*) version_type=nonstopux ;;
- *)
- if test "$lt_cv_prog_gnu_ld" = yes; then
- version_type=linux
- else
- version_type=irix
- fi ;;
- esac
- need_lib_prefix=no
- need_version=no
- soname_spec='${libname}${release}${shared_ext}$major'
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext} $libname${shared_ext}'
- case $host_os in
- irix5* | nonstopux*)
- libsuff= shlibsuff=
- ;;
- *)
- case $LD in # libtool.m4 will add one of these switches to LD
- *-32|*"-32 "|*-melf32bsmip|*"-melf32bsmip ")
- libsuff= shlibsuff= libmagic=32-bit;;
- *-n32|*"-n32 "|*-melf32bmipn32|*"-melf32bmipn32 ")
- libsuff=32 shlibsuff=N32 libmagic=N32;;
- *-64|*"-64 "|*-melf64bmip|*"-melf64bmip ")
- libsuff=64 shlibsuff=64 libmagic=64-bit;;
- *) libsuff= shlibsuff= libmagic=never-match;;
- esac
- ;;
- esac
- shlibpath_var=LD_LIBRARY${shlibsuff}_PATH
- shlibpath_overrides_runpath=no
- sys_lib_search_path_spec="/usr/lib${libsuff} /lib${libsuff} /usr/local/lib${libsuff}"
- sys_lib_dlsearch_path_spec="/usr/lib${libsuff} /lib${libsuff}"
- hardcode_into_libs=yes
- ;;
-
-# No shared lib support for Linux oldld, aout, or coff.
-linux*oldld* | linux*aout* | linux*coff*)
- dynamic_linker=no
- ;;
-
-# This must be Linux ELF.
-linux*)
- version_type=linux
- need_lib_prefix=no
- need_version=no
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
- soname_spec='${libname}${release}${shared_ext}$major'
- finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir'
- shlibpath_var=LD_LIBRARY_PATH
- shlibpath_overrides_runpath=no
- # This implies no fast_install, which is unacceptable.
- # Some rework will be needed to allow for fast_install
- # before this can be enabled.
- hardcode_into_libs=yes
-
- # Append ld.so.conf contents to the search path
- if test -f /etc/ld.so.conf; then
- lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s", \$2)); skip = 1; } { if (!skip) print \$0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;s/[:, ]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;/^$/d' | tr '\n' ' '`
- sys_lib_dlsearch_path_spec="/lib /usr/lib $lt_ld_extra"
- fi
-
- # We used to test for /lib/ld.so.1 and disable shared libraries on
- # powerpc, because MkLinux only supported shared libraries with the
- # GNU dynamic linker. Since this was broken with cross compilers,
- # most powerpc-linux boxes support dynamic linking these days and
- # people can always --disable-shared, the test was removed, and we
- # assume the GNU/Linux dynamic linker is in use.
- dynamic_linker='GNU/Linux ld.so'
- ;;
-
-netbsdelf*-gnu)
- version_type=linux
- need_lib_prefix=no
- need_version=no
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
- soname_spec='${libname}${release}${shared_ext}$major'
- shlibpath_var=LD_LIBRARY_PATH
- shlibpath_overrides_runpath=no
- hardcode_into_libs=yes
- dynamic_linker='NetBSD ld.elf_so'
- ;;
-
-knetbsd*-gnu)
- version_type=linux
- need_lib_prefix=no
- need_version=no
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
- soname_spec='${libname}${release}${shared_ext}$major'
- shlibpath_var=LD_LIBRARY_PATH
- shlibpath_overrides_runpath=no
- hardcode_into_libs=yes
- dynamic_linker='GNU ld.so'
- ;;
-
-netbsd*)
- version_type=sunos
- need_lib_prefix=no
- need_version=no
- if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
- finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir'
- dynamic_linker='NetBSD (a.out) ld.so'
- else
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
- soname_spec='${libname}${release}${shared_ext}$major'
- dynamic_linker='NetBSD ld.elf_so'
- fi
- shlibpath_var=LD_LIBRARY_PATH
- shlibpath_overrides_runpath=yes
- hardcode_into_libs=yes
- ;;
-
-newsos6)
- version_type=linux
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
- shlibpath_var=LD_LIBRARY_PATH
- shlibpath_overrides_runpath=yes
- ;;
-
-nto-qnx*)
- version_type=linux
- need_lib_prefix=no
- need_version=no
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
- soname_spec='${libname}${release}${shared_ext}$major'
- shlibpath_var=LD_LIBRARY_PATH
- shlibpath_overrides_runpath=yes
- ;;
-
-openbsd*)
- version_type=sunos
- sys_lib_dlsearch_path_spec="/usr/lib"
- need_lib_prefix=no
- # Some older versions of OpenBSD (3.3 at least) *do* need versioned libs.
- case $host_os in
- openbsd3.3 | openbsd3.3.*) need_version=yes ;;
- *) need_version=no ;;
- esac
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
- finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir'
- shlibpath_var=LD_LIBRARY_PATH
- if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
- case $host_os in
- openbsd2.[89] | openbsd2.[89].*)
- shlibpath_overrides_runpath=no
- ;;
- *)
- shlibpath_overrides_runpath=yes
- ;;
- esac
- else
- shlibpath_overrides_runpath=yes
- fi
- ;;
-
-os2*)
- libname_spec='$name'
- shrext_cmds=".dll"
- need_lib_prefix=no
- library_names_spec='$libname${shared_ext} $libname.a'
- dynamic_linker='OS/2 ld.exe'
- shlibpath_var=LIBPATH
- ;;
-
-osf3* | osf4* | osf5*)
- version_type=osf
- need_lib_prefix=no
- need_version=no
- soname_spec='${libname}${release}${shared_ext}$major'
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
- shlibpath_var=LD_LIBRARY_PATH
- sys_lib_search_path_spec="/usr/shlib /usr/ccs/lib /usr/lib/cmplrs/cc /usr/lib /usr/local/lib /var/shlib"
- sys_lib_dlsearch_path_spec="$sys_lib_search_path_spec"
- ;;
-
-solaris*)
- version_type=linux
- need_lib_prefix=no
- need_version=no
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
- soname_spec='${libname}${release}${shared_ext}$major'
- shlibpath_var=LD_LIBRARY_PATH
- shlibpath_overrides_runpath=yes
- hardcode_into_libs=yes
- # ldd complains unless libraries are executable
- postinstall_cmds='chmod +x $lib'
- ;;
-
-sunos4*)
- version_type=sunos
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
- finish_cmds='PATH="\$PATH:/usr/etc" ldconfig $libdir'
- shlibpath_var=LD_LIBRARY_PATH
- shlibpath_overrides_runpath=yes
- if test "$with_gnu_ld" = yes; then
- need_lib_prefix=no
- fi
- need_version=yes
- ;;
-
-sysv4 | sysv4.3*)
- version_type=linux
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
- soname_spec='${libname}${release}${shared_ext}$major'
- shlibpath_var=LD_LIBRARY_PATH
- case $host_vendor in
- sni)
- shlibpath_overrides_runpath=no
- need_lib_prefix=no
- export_dynamic_flag_spec='${wl}-Blargedynsym'
- runpath_var=LD_RUN_PATH
- ;;
- siemens)
- need_lib_prefix=no
- ;;
- motorola)
- need_lib_prefix=no
- need_version=no
- shlibpath_overrides_runpath=no
- sys_lib_search_path_spec='/lib /usr/lib /usr/ccs/lib'
- ;;
- esac
- ;;
-
-sysv4*MP*)
- if test -d /usr/nec ;then
- version_type=linux
- library_names_spec='$libname${shared_ext}.$versuffix $libname${shared_ext}.$major $libname${shared_ext}'
- soname_spec='$libname${shared_ext}.$major'
- shlibpath_var=LD_LIBRARY_PATH
- fi
- ;;
-
-sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*)
- version_type=freebsd-elf
- need_lib_prefix=no
- need_version=no
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}'
- soname_spec='${libname}${release}${shared_ext}$major'
- shlibpath_var=LD_LIBRARY_PATH
- hardcode_into_libs=yes
- if test "$with_gnu_ld" = yes; then
- sys_lib_search_path_spec='/usr/local/lib /usr/gnu/lib /usr/ccs/lib /usr/lib /lib'
- shlibpath_overrides_runpath=no
- else
- sys_lib_search_path_spec='/usr/ccs/lib /usr/lib'
- shlibpath_overrides_runpath=yes
- case $host_os in
- sco3.2v5*)
- sys_lib_search_path_spec="$sys_lib_search_path_spec /lib"
- ;;
- esac
- fi
- sys_lib_dlsearch_path_spec='/usr/lib'
- ;;
-
-uts4*)
- version_type=linux
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
- soname_spec='${libname}${release}${shared_ext}$major'
- shlibpath_var=LD_LIBRARY_PATH
- ;;
-
-*)
- dynamic_linker=no
- ;;
-esac
-echo "$as_me:$LINENO: result: $dynamic_linker" >&5
-echo "${ECHO_T}$dynamic_linker" >&6
-test "$dynamic_linker" = no && can_build_shared=no
-
-variables_saved_for_relink="PATH $shlibpath_var $runpath_var"
-if test "$GCC" = yes; then
- variables_saved_for_relink="$variables_saved_for_relink GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH"
-fi
-
-echo "$as_me:$LINENO: checking how to hardcode library paths into programs" >&5
-echo $ECHO_N "checking how to hardcode library paths into programs... $ECHO_C" >&6
-hardcode_action_GCJ=
-if test -n "$hardcode_libdir_flag_spec_GCJ" || \
- test -n "$runpath_var_GCJ" || \
- test "X$hardcode_automatic_GCJ" = "Xyes" ; then
-
- # We can hardcode non-existant directories.
- if test "$hardcode_direct_GCJ" != no &&
- # If the only mechanism to avoid hardcoding is shlibpath_var, we
- # have to relink, otherwise we might link with an installed library
- # when we should be linking with a yet-to-be-installed one
- ## test "$_LT_AC_TAGVAR(hardcode_shlibpath_var, GCJ)" != no &&
- test "$hardcode_minus_L_GCJ" != no; then
- # Linking always hardcodes the temporary library directory.
- hardcode_action_GCJ=relink
- else
- # We can link without hardcoding, and we can hardcode nonexisting dirs.
- hardcode_action_GCJ=immediate
- fi
-else
- # We cannot hardcode anything, or else we can only hardcode existing
- # directories.
- hardcode_action_GCJ=unsupported
-fi
-echo "$as_me:$LINENO: result: $hardcode_action_GCJ" >&5
-echo "${ECHO_T}$hardcode_action_GCJ" >&6
-
-if test "$hardcode_action_GCJ" = relink; then
- # Fast installation is not supported
- enable_fast_install=no
-elif test "$shlibpath_overrides_runpath" = yes ||
- test "$enable_shared" = no; then
- # Fast installation is not necessary
- enable_fast_install=needless
-fi
-
-
-# The else clause should only fire when bootstrapping the
-# libtool distribution, otherwise you forgot to ship ltmain.sh
-# with your package, and you will get complaints that there are
-# no rules to generate ltmain.sh.
-if test -f "$ltmain"; then
- # See if we are running on zsh, and set the options which allow our commands through
- # without removal of \ escapes.
- if test -n "${ZSH_VERSION+set}" ; then
- setopt NO_GLOB_SUBST
- fi
- # Now quote all the things that may contain metacharacters while being
- # careful not to overquote the AC_SUBSTed values. We take copies of the
- # variables and quote the copies for generation of the libtool script.
- for var in echo old_CC old_CFLAGS AR AR_FLAGS EGREP RANLIB LN_S LTCC LTCFLAGS NM \
- SED SHELL STRIP \
- libname_spec library_names_spec soname_spec extract_expsyms_cmds \
- old_striplib striplib file_magic_cmd finish_cmds finish_eval \
- deplibs_check_method reload_flag reload_cmds need_locks \
- lt_cv_sys_global_symbol_pipe lt_cv_sys_global_symbol_to_cdecl \
- lt_cv_sys_global_symbol_to_c_name_address \
- sys_lib_search_path_spec sys_lib_dlsearch_path_spec \
- old_postinstall_cmds old_postuninstall_cmds \
- compiler_GCJ \
- CC_GCJ \
- LD_GCJ \
- lt_prog_compiler_wl_GCJ \
- lt_prog_compiler_pic_GCJ \
- lt_prog_compiler_static_GCJ \
- lt_prog_compiler_no_builtin_flag_GCJ \
- export_dynamic_flag_spec_GCJ \
- thread_safe_flag_spec_GCJ \
- whole_archive_flag_spec_GCJ \
- enable_shared_with_static_runtimes_GCJ \
- old_archive_cmds_GCJ \
- old_archive_from_new_cmds_GCJ \
- predep_objects_GCJ \
- postdep_objects_GCJ \
- predeps_GCJ \
- postdeps_GCJ \
- compiler_lib_search_path_GCJ \
- archive_cmds_GCJ \
- archive_expsym_cmds_GCJ \
- postinstall_cmds_GCJ \
- postuninstall_cmds_GCJ \
- old_archive_from_expsyms_cmds_GCJ \
- allow_undefined_flag_GCJ \
- no_undefined_flag_GCJ \
- export_symbols_cmds_GCJ \
- hardcode_libdir_flag_spec_GCJ \
- hardcode_libdir_flag_spec_ld_GCJ \
- hardcode_libdir_separator_GCJ \
- hardcode_automatic_GCJ \
- module_cmds_GCJ \
- module_expsym_cmds_GCJ \
- lt_cv_prog_compiler_c_o_GCJ \
- exclude_expsyms_GCJ \
- include_expsyms_GCJ; do
-
- case $var in
- old_archive_cmds_GCJ | \
- old_archive_from_new_cmds_GCJ | \
- archive_cmds_GCJ | \
- archive_expsym_cmds_GCJ | \
- module_cmds_GCJ | \
- module_expsym_cmds_GCJ | \
- old_archive_from_expsyms_cmds_GCJ | \
- export_symbols_cmds_GCJ | \
- extract_expsyms_cmds | reload_cmds | finish_cmds | \
- postinstall_cmds | postuninstall_cmds | \
- old_postinstall_cmds | old_postuninstall_cmds | \
- sys_lib_search_path_spec | sys_lib_dlsearch_path_spec)
- # Double-quote double-evaled strings.
- eval "lt_$var=\\\"\`\$echo \"X\$$var\" | \$Xsed -e \"\$double_quote_subst\" -e \"\$sed_quote_subst\" -e \"\$delay_variable_subst\"\`\\\""
- ;;
- *)
- eval "lt_$var=\\\"\`\$echo \"X\$$var\" | \$Xsed -e \"\$sed_quote_subst\"\`\\\""
- ;;
- esac
- done
-
- case $lt_echo in
- *'\$0 --fallback-echo"')
- lt_echo=`$echo "X$lt_echo" | $Xsed -e 's/\\\\\\\$0 --fallback-echo"$/$0 --fallback-echo"/'`
- ;;
- esac
-
-cfgfile="$ofile"
-
- cat <<__EOF__ >> "$cfgfile"
-# ### BEGIN LIBTOOL TAG CONFIG: $tagname
-
-# Libtool was configured on host `(hostname || uname -n) 2>/dev/null | sed 1q`:
-
-# Shell to use when invoking shell scripts.
-SHELL=$lt_SHELL
-
-# Whether or not to build shared libraries.
-build_libtool_libs=$enable_shared
-
-# Whether or not to build static libraries.
-build_old_libs=$enable_static
-
-# Whether or not to add -lc for building shared libraries.
-build_libtool_need_lc=$archive_cmds_need_lc_GCJ
-
-# Whether or not to disallow shared libs when runtime libs are static
-allow_libtool_libs_with_static_runtimes=$enable_shared_with_static_runtimes_GCJ
-
-# Whether or not to optimize for fast installation.
-fast_install=$enable_fast_install
-
-# The host system.
-host_alias=$host_alias
-host=$host
-host_os=$host_os
-
-# The build system.
-build_alias=$build_alias
-build=$build
-build_os=$build_os
-
-# An echo program that does not interpret backslashes.
-echo=$lt_echo
-
-# The archiver.
-AR=$lt_AR
-AR_FLAGS=$lt_AR_FLAGS
-
-# A C compiler.
-LTCC=$lt_LTCC
-
-# LTCC compiler flags.
-LTCFLAGS=$lt_LTCFLAGS
-
-# A language-specific compiler.
-CC=$lt_compiler_GCJ
-
-# Is the compiler the GNU C compiler?
-with_gcc=$GCC_GCJ
-
-# An ERE matcher.
-EGREP=$lt_EGREP
-
-# The linker used to build libraries.
-LD=$lt_LD_GCJ
-
-# Whether we need hard or soft links.
-LN_S=$lt_LN_S
-
-# A BSD-compatible nm program.
-NM=$lt_NM
-
-# A symbol stripping program
-STRIP=$lt_STRIP
-
-# Used to examine libraries when file_magic_cmd begins "file"
-MAGIC_CMD=$MAGIC_CMD
-
-# Used on cygwin: DLL creation program.
-DLLTOOL="$DLLTOOL"
-
-# Used on cygwin: object dumper.
-OBJDUMP="$OBJDUMP"
-
-# Used on cygwin: assembler.
-AS="$AS"
-
-# The name of the directory that contains temporary libtool files.
-objdir=$objdir
-
-# How to create reloadable object files.
-reload_flag=$lt_reload_flag
-reload_cmds=$lt_reload_cmds
-
-# How to pass a linker flag through the compiler.
-wl=$lt_lt_prog_compiler_wl_GCJ
-
-# Object file suffix (normally "o").
-objext="$ac_objext"
-
-# Old archive suffix (normally "a").
-libext="$libext"
-
-# Shared library suffix (normally ".so").
-shrext_cmds='$shrext_cmds'
-
-# Executable file suffix (normally "").
-exeext="$exeext"
-
-# Additional compiler flags for building library objects.
-pic_flag=$lt_lt_prog_compiler_pic_GCJ
-pic_mode=$pic_mode
-
-# What is the maximum length of a command?
-max_cmd_len=$lt_cv_sys_max_cmd_len
-
-# Does compiler simultaneously support -c and -o options?
-compiler_c_o=$lt_lt_cv_prog_compiler_c_o_GCJ
-
-# Must we lock files when doing compilation?
-need_locks=$lt_need_locks
-
-# Do we need the lib prefix for modules?
-need_lib_prefix=$need_lib_prefix
-
-# Do we need a version for libraries?
-need_version=$need_version
-
-# Whether dlopen is supported.
-dlopen_support=$enable_dlopen
-
-# Whether dlopen of programs is supported.
-dlopen_self=$enable_dlopen_self
-
-# Whether dlopen of statically linked programs is supported.
-dlopen_self_static=$enable_dlopen_self_static
-
-# Compiler flag to prevent dynamic linking.
-link_static_flag=$lt_lt_prog_compiler_static_GCJ
-
-# Compiler flag to turn off builtin functions.
-no_builtin_flag=$lt_lt_prog_compiler_no_builtin_flag_GCJ
-
-# Compiler flag to allow reflexive dlopens.
-export_dynamic_flag_spec=$lt_export_dynamic_flag_spec_GCJ
-
-# Compiler flag to generate shared objects directly from archives.
-whole_archive_flag_spec=$lt_whole_archive_flag_spec_GCJ
-
-# Compiler flag to generate thread-safe objects.
-thread_safe_flag_spec=$lt_thread_safe_flag_spec_GCJ
-
-# Library versioning type.
-version_type=$version_type
-
-# Format of library name prefix.
-libname_spec=$lt_libname_spec
-
-# List of archive names. First name is the real one, the rest are links.
-# The last name is the one that the linker finds with -lNAME.
-library_names_spec=$lt_library_names_spec
-
-# The coded name of the library, if different from the real name.
-soname_spec=$lt_soname_spec
-
-# Commands used to build and install an old-style archive.
-RANLIB=$lt_RANLIB
-old_archive_cmds=$lt_old_archive_cmds_GCJ
-old_postinstall_cmds=$lt_old_postinstall_cmds
-old_postuninstall_cmds=$lt_old_postuninstall_cmds
-
-# Create an old-style archive from a shared archive.
-old_archive_from_new_cmds=$lt_old_archive_from_new_cmds_GCJ
-
-# Create a temporary old-style archive to link instead of a shared archive.
-old_archive_from_expsyms_cmds=$lt_old_archive_from_expsyms_cmds_GCJ
-
-# Commands used to build and install a shared archive.
-archive_cmds=$lt_archive_cmds_GCJ
-archive_expsym_cmds=$lt_archive_expsym_cmds_GCJ
-postinstall_cmds=$lt_postinstall_cmds
-postuninstall_cmds=$lt_postuninstall_cmds
-
-# Commands used to build a loadable module (assumed same as above if empty)
-module_cmds=$lt_module_cmds_GCJ
-module_expsym_cmds=$lt_module_expsym_cmds_GCJ
-
-# Commands to strip libraries.
-old_striplib=$lt_old_striplib
-striplib=$lt_striplib
-
-# Dependencies to place before the objects being linked to create a
-# shared library.
-predep_objects=$lt_predep_objects_GCJ
-
-# Dependencies to place after the objects being linked to create a
-# shared library.
-postdep_objects=$lt_postdep_objects_GCJ
-
-# Dependencies to place before the objects being linked to create a
-# shared library.
-predeps=$lt_predeps_GCJ
-
-# Dependencies to place after the objects being linked to create a
-# shared library.
-postdeps=$lt_postdeps_GCJ
-
-# The library search path used internally by the compiler when linking
-# a shared library.
-compiler_lib_search_path=$lt_compiler_lib_search_path_GCJ
-
-# Method to check whether dependent libraries are shared objects.
-deplibs_check_method=$lt_deplibs_check_method
-
-# Command to use when deplibs_check_method == file_magic.
-file_magic_cmd=$lt_file_magic_cmd
-
-# Flag that allows shared libraries with undefined symbols to be built.
-allow_undefined_flag=$lt_allow_undefined_flag_GCJ
-
-# Flag that forces no undefined symbols.
-no_undefined_flag=$lt_no_undefined_flag_GCJ
-
-# Commands used to finish a libtool library installation in a directory.
-finish_cmds=$lt_finish_cmds
-
-# Same as above, but a single script fragment to be evaled but not shown.
-finish_eval=$lt_finish_eval
-
-# Take the output of nm and produce a listing of raw symbols and C names.
-global_symbol_pipe=$lt_lt_cv_sys_global_symbol_pipe
-
-# Transform the output of nm in a proper C declaration
-global_symbol_to_cdecl=$lt_lt_cv_sys_global_symbol_to_cdecl
-
-# Transform the output of nm in a C name address pair
-global_symbol_to_c_name_address=$lt_lt_cv_sys_global_symbol_to_c_name_address
-
-# This is the shared library runtime path variable.
-runpath_var=$runpath_var
-
-# This is the shared library path variable.
-shlibpath_var=$shlibpath_var
-
-# Is shlibpath searched before the hard-coded library search path?
-shlibpath_overrides_runpath=$shlibpath_overrides_runpath
-
-# How to hardcode a shared library path into an executable.
-hardcode_action=$hardcode_action_GCJ
-
-# Whether we should hardcode library paths into libraries.
-hardcode_into_libs=$hardcode_into_libs
-
-# Flag to hardcode \$libdir into a binary during linking.
-# This must work even if \$libdir does not exist.
-hardcode_libdir_flag_spec=$lt_hardcode_libdir_flag_spec_GCJ
-
-# If ld is used when linking, flag to hardcode \$libdir into
-# a binary during linking. This must work even if \$libdir does
-# not exist.
-hardcode_libdir_flag_spec_ld=$lt_hardcode_libdir_flag_spec_ld_GCJ
-
-# Whether we need a single -rpath flag with a separated argument.
-hardcode_libdir_separator=$lt_hardcode_libdir_separator_GCJ
-
-# Set to yes if using DIR/libNAME${shared_ext} during linking hardcodes DIR into the
-# resulting binary.
-hardcode_direct=$hardcode_direct_GCJ
-
-# Set to yes if using the -LDIR flag during linking hardcodes DIR into the
-# resulting binary.
-hardcode_minus_L=$hardcode_minus_L_GCJ
-
-# Set to yes if using SHLIBPATH_VAR=DIR during linking hardcodes DIR into
-# the resulting binary.
-hardcode_shlibpath_var=$hardcode_shlibpath_var_GCJ
-
-# Set to yes if building a shared library automatically hardcodes DIR into the library
-# and all subsequent libraries and executables linked against it.
-hardcode_automatic=$hardcode_automatic_GCJ
-
-# Variables whose values should be saved in libtool wrapper scripts and
-# restored at relink time.
-variables_saved_for_relink="$variables_saved_for_relink"
-
-# Whether libtool must link a program against all its dependency libraries.
-link_all_deplibs=$link_all_deplibs_GCJ
-
-# Compile-time system search path for libraries
-sys_lib_search_path_spec=$lt_sys_lib_search_path_spec
-
-# Run-time system search path for libraries
-sys_lib_dlsearch_path_spec=$lt_sys_lib_dlsearch_path_spec
-
-# Fix the shell variable \$srcfile for the compiler.
-fix_srcfile_path="$fix_srcfile_path_GCJ"
-
-# Set to yes if exported symbols are required.
-always_export_symbols=$always_export_symbols_GCJ
-
-# The commands to list exported symbols.
-export_symbols_cmds=$lt_export_symbols_cmds_GCJ
-
-# The commands to extract the exported symbol list from a shared archive.
-extract_expsyms_cmds=$lt_extract_expsyms_cmds
-
-# Symbols that should not be listed in the preloaded symbols.
-exclude_expsyms=$lt_exclude_expsyms_GCJ
-
-# Symbols that must always be exported.
-include_expsyms=$lt_include_expsyms_GCJ
-
-# ### END LIBTOOL TAG CONFIG: $tagname
-
-__EOF__
-
-
-else
- # If there is no Makefile yet, we rely on a make rule to execute
- # `config.status --recheck' to rerun these tests and create the
- # libtool script then.
- ltmain_in=`echo $ltmain | sed -e 's/\.sh$/.in/'`
- if test -f "$ltmain_in"; then
- test -f Makefile && make "$ltmain"
- fi
-fi
-
-
-ac_ext=c
-ac_cpp='$CPP $CPPFLAGS'
-ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
-ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
-ac_compiler_gnu=$ac_cv_c_compiler_gnu
-
-CC="$lt_save_CC"
-
- else
- tagname=""
- fi
- ;;
-
- RC)
-
-
-
-# Source file extension for RC test sources.
-ac_ext=rc
-
-# Object file extension for compiled RC test sources.
-objext=o
-objext_RC=$objext
-
-# Code to be used in simple compile tests
-lt_simple_compile_test_code='sample MENU { MENUITEM "&Soup", 100, CHECKED }\n'
-
-# Code to be used in simple link tests
-lt_simple_link_test_code="$lt_simple_compile_test_code"
-
-# ltmain only uses $CC for tagged configurations so make sure $CC is set.
-
-# If no C compiler was specified, use CC.
-LTCC=${LTCC-"$CC"}
-
-# If no C compiler flags were specified, use CFLAGS.
-LTCFLAGS=${LTCFLAGS-"$CFLAGS"}
-
-# Allow CC to be a program name with arguments.
-compiler=$CC
-
-
-# save warnings/boilerplate of simple test code
-ac_outfile=conftest.$ac_objext
-printf "$lt_simple_compile_test_code" >conftest.$ac_ext
-eval "$ac_compile" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err
-_lt_compiler_boilerplate=`cat conftest.err`
-$rm conftest*
-
-ac_outfile=conftest.$ac_objext
-printf "$lt_simple_link_test_code" >conftest.$ac_ext
-eval "$ac_link" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err
-_lt_linker_boilerplate=`cat conftest.err`
-$rm conftest*
-
-
-# Allow CC to be a program name with arguments.
-lt_save_CC="$CC"
-CC=${RC-"windres"}
-compiler=$CC
-compiler_RC=$CC
-for cc_temp in $compiler""; do
- case $cc_temp in
- compile | *[\\/]compile | ccache | *[\\/]ccache ) ;;
- distcc | *[\\/]distcc | purify | *[\\/]purify ) ;;
- \-*) ;;
- *) break;;
- esac
-done
-cc_basename=`$echo "X$cc_temp" | $Xsed -e 's%.*/%%' -e "s%^$host_alias-%%"`
-
-lt_cv_prog_compiler_c_o_RC=yes
-
-# The else clause should only fire when bootstrapping the
-# libtool distribution, otherwise you forgot to ship ltmain.sh
-# with your package, and you will get complaints that there are
-# no rules to generate ltmain.sh.
-if test -f "$ltmain"; then
- # See if we are running on zsh, and set the options which allow our commands through
- # without removal of \ escapes.
- if test -n "${ZSH_VERSION+set}" ; then
- setopt NO_GLOB_SUBST
- fi
- # Now quote all the things that may contain metacharacters while being
- # careful not to overquote the AC_SUBSTed values. We take copies of the
- # variables and quote the copies for generation of the libtool script.
- for var in echo old_CC old_CFLAGS AR AR_FLAGS EGREP RANLIB LN_S LTCC LTCFLAGS NM \
- SED SHELL STRIP \
- libname_spec library_names_spec soname_spec extract_expsyms_cmds \
- old_striplib striplib file_magic_cmd finish_cmds finish_eval \
- deplibs_check_method reload_flag reload_cmds need_locks \
- lt_cv_sys_global_symbol_pipe lt_cv_sys_global_symbol_to_cdecl \
- lt_cv_sys_global_symbol_to_c_name_address \
- sys_lib_search_path_spec sys_lib_dlsearch_path_spec \
- old_postinstall_cmds old_postuninstall_cmds \
- compiler_RC \
- CC_RC \
- LD_RC \
- lt_prog_compiler_wl_RC \
- lt_prog_compiler_pic_RC \
- lt_prog_compiler_static_RC \
- lt_prog_compiler_no_builtin_flag_RC \
- export_dynamic_flag_spec_RC \
- thread_safe_flag_spec_RC \
- whole_archive_flag_spec_RC \
- enable_shared_with_static_runtimes_RC \
- old_archive_cmds_RC \
- old_archive_from_new_cmds_RC \
- predep_objects_RC \
- postdep_objects_RC \
- predeps_RC \
- postdeps_RC \
- compiler_lib_search_path_RC \
- archive_cmds_RC \
- archive_expsym_cmds_RC \
- postinstall_cmds_RC \
- postuninstall_cmds_RC \
- old_archive_from_expsyms_cmds_RC \
- allow_undefined_flag_RC \
- no_undefined_flag_RC \
- export_symbols_cmds_RC \
- hardcode_libdir_flag_spec_RC \
- hardcode_libdir_flag_spec_ld_RC \
- hardcode_libdir_separator_RC \
- hardcode_automatic_RC \
- module_cmds_RC \
- module_expsym_cmds_RC \
- lt_cv_prog_compiler_c_o_RC \
- exclude_expsyms_RC \
- include_expsyms_RC; do
-
- case $var in
- old_archive_cmds_RC | \
- old_archive_from_new_cmds_RC | \
- archive_cmds_RC | \
- archive_expsym_cmds_RC | \
- module_cmds_RC | \
- module_expsym_cmds_RC | \
- old_archive_from_expsyms_cmds_RC | \
- export_symbols_cmds_RC | \
- extract_expsyms_cmds | reload_cmds | finish_cmds | \
- postinstall_cmds | postuninstall_cmds | \
- old_postinstall_cmds | old_postuninstall_cmds | \
- sys_lib_search_path_spec | sys_lib_dlsearch_path_spec)
- # Double-quote double-evaled strings.
- eval "lt_$var=\\\"\`\$echo \"X\$$var\" | \$Xsed -e \"\$double_quote_subst\" -e \"\$sed_quote_subst\" -e \"\$delay_variable_subst\"\`\\\""
- ;;
- *)
- eval "lt_$var=\\\"\`\$echo \"X\$$var\" | \$Xsed -e \"\$sed_quote_subst\"\`\\\""
- ;;
- esac
- done
-
- case $lt_echo in
- *'\$0 --fallback-echo"')
- lt_echo=`$echo "X$lt_echo" | $Xsed -e 's/\\\\\\\$0 --fallback-echo"$/$0 --fallback-echo"/'`
- ;;
- esac
-
-cfgfile="$ofile"
-
- cat <<__EOF__ >> "$cfgfile"
-# ### BEGIN LIBTOOL TAG CONFIG: $tagname
-
-# Libtool was configured on host `(hostname || uname -n) 2>/dev/null | sed 1q`:
-
-# Shell to use when invoking shell scripts.
-SHELL=$lt_SHELL
-
-# Whether or not to build shared libraries.
-build_libtool_libs=$enable_shared
-
-# Whether or not to build static libraries.
-build_old_libs=$enable_static
-
-# Whether or not to add -lc for building shared libraries.
-build_libtool_need_lc=$archive_cmds_need_lc_RC
-
-# Whether or not to disallow shared libs when runtime libs are static
-allow_libtool_libs_with_static_runtimes=$enable_shared_with_static_runtimes_RC
-
-# Whether or not to optimize for fast installation.
-fast_install=$enable_fast_install
-
-# The host system.
-host_alias=$host_alias
-host=$host
-host_os=$host_os
-
-# The build system.
-build_alias=$build_alias
-build=$build
-build_os=$build_os
-
-# An echo program that does not interpret backslashes.
-echo=$lt_echo
-
-# The archiver.
-AR=$lt_AR
-AR_FLAGS=$lt_AR_FLAGS
-
-# A C compiler.
-LTCC=$lt_LTCC
-
-# LTCC compiler flags.
-LTCFLAGS=$lt_LTCFLAGS
-
-# A language-specific compiler.
-CC=$lt_compiler_RC
-
-# Is the compiler the GNU C compiler?
-with_gcc=$GCC_RC
-
-# An ERE matcher.
-EGREP=$lt_EGREP
-
-# The linker used to build libraries.
-LD=$lt_LD_RC
-
-# Whether we need hard or soft links.
-LN_S=$lt_LN_S
-
-# A BSD-compatible nm program.
-NM=$lt_NM
-
-# A symbol stripping program
-STRIP=$lt_STRIP
-
-# Used to examine libraries when file_magic_cmd begins "file"
-MAGIC_CMD=$MAGIC_CMD
-
-# Used on cygwin: DLL creation program.
-DLLTOOL="$DLLTOOL"
-
-# Used on cygwin: object dumper.
-OBJDUMP="$OBJDUMP"
-
-# Used on cygwin: assembler.
-AS="$AS"
-
-# The name of the directory that contains temporary libtool files.
-objdir=$objdir
-
-# How to create reloadable object files.
-reload_flag=$lt_reload_flag
-reload_cmds=$lt_reload_cmds
-
-# How to pass a linker flag through the compiler.
-wl=$lt_lt_prog_compiler_wl_RC
-
-# Object file suffix (normally "o").
-objext="$ac_objext"
-
-# Old archive suffix (normally "a").
-libext="$libext"
-
-# Shared library suffix (normally ".so").
-shrext_cmds='$shrext_cmds'
-
-# Executable file suffix (normally "").
-exeext="$exeext"
-
-# Additional compiler flags for building library objects.
-pic_flag=$lt_lt_prog_compiler_pic_RC
-pic_mode=$pic_mode
-
-# What is the maximum length of a command?
-max_cmd_len=$lt_cv_sys_max_cmd_len
-
-# Does compiler simultaneously support -c and -o options?
-compiler_c_o=$lt_lt_cv_prog_compiler_c_o_RC
-
-# Must we lock files when doing compilation?
-need_locks=$lt_need_locks
-
-# Do we need the lib prefix for modules?
-need_lib_prefix=$need_lib_prefix
-
-# Do we need a version for libraries?
-need_version=$need_version
-
-# Whether dlopen is supported.
-dlopen_support=$enable_dlopen
-
-# Whether dlopen of programs is supported.
-dlopen_self=$enable_dlopen_self
-
-# Whether dlopen of statically linked programs is supported.
-dlopen_self_static=$enable_dlopen_self_static
-
-# Compiler flag to prevent dynamic linking.
-link_static_flag=$lt_lt_prog_compiler_static_RC
-
-# Compiler flag to turn off builtin functions.
-no_builtin_flag=$lt_lt_prog_compiler_no_builtin_flag_RC
-
-# Compiler flag to allow reflexive dlopens.
-export_dynamic_flag_spec=$lt_export_dynamic_flag_spec_RC
-
-# Compiler flag to generate shared objects directly from archives.
-whole_archive_flag_spec=$lt_whole_archive_flag_spec_RC
-
-# Compiler flag to generate thread-safe objects.
-thread_safe_flag_spec=$lt_thread_safe_flag_spec_RC
-
-# Library versioning type.
-version_type=$version_type
-
-# Format of library name prefix.
-libname_spec=$lt_libname_spec
-
-# List of archive names. First name is the real one, the rest are links.
-# The last name is the one that the linker finds with -lNAME.
-library_names_spec=$lt_library_names_spec
-
-# The coded name of the library, if different from the real name.
-soname_spec=$lt_soname_spec
-
-# Commands used to build and install an old-style archive.
-RANLIB=$lt_RANLIB
-old_archive_cmds=$lt_old_archive_cmds_RC
-old_postinstall_cmds=$lt_old_postinstall_cmds
-old_postuninstall_cmds=$lt_old_postuninstall_cmds
-
-# Create an old-style archive from a shared archive.
-old_archive_from_new_cmds=$lt_old_archive_from_new_cmds_RC
-
-# Create a temporary old-style archive to link instead of a shared archive.
-old_archive_from_expsyms_cmds=$lt_old_archive_from_expsyms_cmds_RC
-
-# Commands used to build and install a shared archive.
-archive_cmds=$lt_archive_cmds_RC
-archive_expsym_cmds=$lt_archive_expsym_cmds_RC
-postinstall_cmds=$lt_postinstall_cmds
-postuninstall_cmds=$lt_postuninstall_cmds
-
-# Commands used to build a loadable module (assumed same as above if empty)
-module_cmds=$lt_module_cmds_RC
-module_expsym_cmds=$lt_module_expsym_cmds_RC
-
-# Commands to strip libraries.
-old_striplib=$lt_old_striplib
-striplib=$lt_striplib
-
-# Dependencies to place before the objects being linked to create a
-# shared library.
-predep_objects=$lt_predep_objects_RC
-
-# Dependencies to place after the objects being linked to create a
-# shared library.
-postdep_objects=$lt_postdep_objects_RC
-
-# Dependencies to place before the objects being linked to create a
-# shared library.
-predeps=$lt_predeps_RC
-
-# Dependencies to place after the objects being linked to create a
-# shared library.
-postdeps=$lt_postdeps_RC
-
-# The library search path used internally by the compiler when linking
-# a shared library.
-compiler_lib_search_path=$lt_compiler_lib_search_path_RC
-
-# Method to check whether dependent libraries are shared objects.
-deplibs_check_method=$lt_deplibs_check_method
-
-# Command to use when deplibs_check_method == file_magic.
-file_magic_cmd=$lt_file_magic_cmd
-
-# Flag that allows shared libraries with undefined symbols to be built.
-allow_undefined_flag=$lt_allow_undefined_flag_RC
-
-# Flag that forces no undefined symbols.
-no_undefined_flag=$lt_no_undefined_flag_RC
-
-# Commands used to finish a libtool library installation in a directory.
-finish_cmds=$lt_finish_cmds
-
-# Same as above, but a single script fragment to be evaled but not shown.
-finish_eval=$lt_finish_eval
-
-# Take the output of nm and produce a listing of raw symbols and C names.
-global_symbol_pipe=$lt_lt_cv_sys_global_symbol_pipe
-
-# Transform the output of nm in a proper C declaration
-global_symbol_to_cdecl=$lt_lt_cv_sys_global_symbol_to_cdecl
-
-# Transform the output of nm in a C name address pair
-global_symbol_to_c_name_address=$lt_lt_cv_sys_global_symbol_to_c_name_address
-
-# This is the shared library runtime path variable.
-runpath_var=$runpath_var
-
-# This is the shared library path variable.
-shlibpath_var=$shlibpath_var
-
-# Is shlibpath searched before the hard-coded library search path?
-shlibpath_overrides_runpath=$shlibpath_overrides_runpath
-
-# How to hardcode a shared library path into an executable.
-hardcode_action=$hardcode_action_RC
-
-# Whether we should hardcode library paths into libraries.
-hardcode_into_libs=$hardcode_into_libs
-
-# Flag to hardcode \$libdir into a binary during linking.
-# This must work even if \$libdir does not exist.
-hardcode_libdir_flag_spec=$lt_hardcode_libdir_flag_spec_RC
-
-# If ld is used when linking, flag to hardcode \$libdir into
-# a binary during linking. This must work even if \$libdir does
-# not exist.
-hardcode_libdir_flag_spec_ld=$lt_hardcode_libdir_flag_spec_ld_RC
-
-# Whether we need a single -rpath flag with a separated argument.
-hardcode_libdir_separator=$lt_hardcode_libdir_separator_RC
-
-# Set to yes if using DIR/libNAME${shared_ext} during linking hardcodes DIR into the
-# resulting binary.
-hardcode_direct=$hardcode_direct_RC
-
-# Set to yes if using the -LDIR flag during linking hardcodes DIR into the
-# resulting binary.
-hardcode_minus_L=$hardcode_minus_L_RC
-
-# Set to yes if using SHLIBPATH_VAR=DIR during linking hardcodes DIR into
-# the resulting binary.
-hardcode_shlibpath_var=$hardcode_shlibpath_var_RC
-
-# Set to yes if building a shared library automatically hardcodes DIR into the library
-# and all subsequent libraries and executables linked against it.
-hardcode_automatic=$hardcode_automatic_RC
-
-# Variables whose values should be saved in libtool wrapper scripts and
-# restored at relink time.
-variables_saved_for_relink="$variables_saved_for_relink"
-
-# Whether libtool must link a program against all its dependency libraries.
-link_all_deplibs=$link_all_deplibs_RC
-
-# Compile-time system search path for libraries
-sys_lib_search_path_spec=$lt_sys_lib_search_path_spec
-
-# Run-time system search path for libraries
-sys_lib_dlsearch_path_spec=$lt_sys_lib_dlsearch_path_spec
-
-# Fix the shell variable \$srcfile for the compiler.
-fix_srcfile_path="$fix_srcfile_path_RC"
-
-# Set to yes if exported symbols are required.
-always_export_symbols=$always_export_symbols_RC
-
-# The commands to list exported symbols.
-export_symbols_cmds=$lt_export_symbols_cmds_RC
-
-# The commands to extract the exported symbol list from a shared archive.
-extract_expsyms_cmds=$lt_extract_expsyms_cmds
-
-# Symbols that should not be listed in the preloaded symbols.
-exclude_expsyms=$lt_exclude_expsyms_RC
-
-# Symbols that must always be exported.
-include_expsyms=$lt_include_expsyms_RC
-
-# ### END LIBTOOL TAG CONFIG: $tagname
-
-__EOF__
-
-
-else
- # If there is no Makefile yet, we rely on a make rule to execute
- # `config.status --recheck' to rerun these tests and create the
- # libtool script then.
- ltmain_in=`echo $ltmain | sed -e 's/\.sh$/.in/'`
- if test -f "$ltmain_in"; then
- test -f Makefile && make "$ltmain"
- fi
-fi
-
-
-ac_ext=c
-ac_cpp='$CPP $CPPFLAGS'
-ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
-ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
-ac_compiler_gnu=$ac_cv_c_compiler_gnu
-
-CC="$lt_save_CC"
-
- ;;
-
- *)
- { { echo "$as_me:$LINENO: error: Unsupported tag name: $tagname" >&5
-echo "$as_me: error: Unsupported tag name: $tagname" >&2;}
- { (exit 1); exit 1; }; }
- ;;
- esac
-
- # Append the new tag name to the list of available tags.
- if test -n "$tagname" ; then
- available_tags="$available_tags $tagname"
- fi
- fi
- done
- IFS="$lt_save_ifs"
-
- # Now substitute the updated list of available tags.
- if eval "sed -e 's/^available_tags=.*\$/available_tags=\"$available_tags\"/' \"$ofile\" > \"${ofile}T\""; then
- mv "${ofile}T" "$ofile"
- chmod +x "$ofile"
- else
- rm -f "${ofile}T"
- { { echo "$as_me:$LINENO: error: unable to update list of available tagged configurations." >&5
-echo "$as_me: error: unable to update list of available tagged configurations." >&2;}
- { (exit 1); exit 1; }; }
- fi
-fi
-
-
-
-# This can be used to rebuild libtool when needed
-LIBTOOL_DEPS="$ac_aux_dir/ltmain.sh"
-
-# Always use our own libtool.
-LIBTOOL='$(SHELL) $(top_builddir)/libtool'
-
-# Prevent multiple expansion
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-# Check whether --with-valgrind or --without-valgrind was given.
-if test "${with_valgrind+set}" = set; then
- withval="$with_valgrind"
-
-fi;
-
-if test "$with_valgrind" != "" && test "$with_valgrind" != "no"; then
-
-cat >>confdefs.h <<\_ACEOF
-#define INCLUDE_VALGRIND 1
-_ACEOF
-
- if test -d $with_valgrind; then
- CPPFLAGS="$CPPLFAGS -I$with_valgrind/include"
- fi
-fi
-
-# Check whether --enable-libcheck or --disable-libcheck was given.
-if test "${enable_libcheck+set}" = set; then
- enableval="$enable_libcheck"
- if test "$enableval" = "no"; then
- disable_libcheck=yes
- fi
-
-fi;
-
-ac_ext=c
-ac_cpp='$CPP $CPPFLAGS'
-ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
-ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
-ac_compiler_gnu=$ac_cv_c_compiler_gnu
-if test -n "$ac_tool_prefix"; then
- # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args.
-set dummy ${ac_tool_prefix}gcc; ac_word=$2
-echo "$as_me:$LINENO: checking for $ac_word" >&5
-echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
-if test "${ac_cv_prog_CC+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- if test -n "$CC"; then
- ac_cv_prog_CC="$CC" # Let the user override the test.
-else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
- IFS=$as_save_IFS
- test -z "$as_dir" && as_dir=.
- for ac_exec_ext in '' $ac_executable_extensions; do
- if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
- ac_cv_prog_CC="${ac_tool_prefix}gcc"
- echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
- break 2
- fi
-done
-done
-
-fi
-fi
-CC=$ac_cv_prog_CC
-if test -n "$CC"; then
- echo "$as_me:$LINENO: result: $CC" >&5
-echo "${ECHO_T}$CC" >&6
-else
- echo "$as_me:$LINENO: result: no" >&5
-echo "${ECHO_T}no" >&6
-fi
-
-fi
-if test -z "$ac_cv_prog_CC"; then
- ac_ct_CC=$CC
- # Extract the first word of "gcc", so it can be a program name with args.
-set dummy gcc; ac_word=$2
-echo "$as_me:$LINENO: checking for $ac_word" >&5
-echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
-if test "${ac_cv_prog_ac_ct_CC+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- if test -n "$ac_ct_CC"; then
- ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test.
-else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
- IFS=$as_save_IFS
- test -z "$as_dir" && as_dir=.
- for ac_exec_ext in '' $ac_executable_extensions; do
- if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
- ac_cv_prog_ac_ct_CC="gcc"
- echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
- break 2
- fi
-done
-done
-
-fi
-fi
-ac_ct_CC=$ac_cv_prog_ac_ct_CC
-if test -n "$ac_ct_CC"; then
- echo "$as_me:$LINENO: result: $ac_ct_CC" >&5
-echo "${ECHO_T}$ac_ct_CC" >&6
-else
- echo "$as_me:$LINENO: result: no" >&5
-echo "${ECHO_T}no" >&6
-fi
-
- CC=$ac_ct_CC
-else
- CC="$ac_cv_prog_CC"
-fi
-
-if test -z "$CC"; then
- if test -n "$ac_tool_prefix"; then
- # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args.
-set dummy ${ac_tool_prefix}cc; ac_word=$2
-echo "$as_me:$LINENO: checking for $ac_word" >&5
-echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
-if test "${ac_cv_prog_CC+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- if test -n "$CC"; then
- ac_cv_prog_CC="$CC" # Let the user override the test.
-else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
- IFS=$as_save_IFS
- test -z "$as_dir" && as_dir=.
- for ac_exec_ext in '' $ac_executable_extensions; do
- if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
- ac_cv_prog_CC="${ac_tool_prefix}cc"
- echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
- break 2
- fi
-done
-done
-
-fi
-fi
-CC=$ac_cv_prog_CC
-if test -n "$CC"; then
- echo "$as_me:$LINENO: result: $CC" >&5
-echo "${ECHO_T}$CC" >&6
-else
- echo "$as_me:$LINENO: result: no" >&5
-echo "${ECHO_T}no" >&6
-fi
-
-fi
-if test -z "$ac_cv_prog_CC"; then
- ac_ct_CC=$CC
- # Extract the first word of "cc", so it can be a program name with args.
-set dummy cc; ac_word=$2
-echo "$as_me:$LINENO: checking for $ac_word" >&5
-echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
-if test "${ac_cv_prog_ac_ct_CC+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- if test -n "$ac_ct_CC"; then
- ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test.
-else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
- IFS=$as_save_IFS
- test -z "$as_dir" && as_dir=.
- for ac_exec_ext in '' $ac_executable_extensions; do
- if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
- ac_cv_prog_ac_ct_CC="cc"
- echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
- break 2
- fi
-done
-done
-
-fi
-fi
-ac_ct_CC=$ac_cv_prog_ac_ct_CC
-if test -n "$ac_ct_CC"; then
- echo "$as_me:$LINENO: result: $ac_ct_CC" >&5
-echo "${ECHO_T}$ac_ct_CC" >&6
-else
- echo "$as_me:$LINENO: result: no" >&5
-echo "${ECHO_T}no" >&6
-fi
-
- CC=$ac_ct_CC
-else
- CC="$ac_cv_prog_CC"
-fi
-
-fi
-if test -z "$CC"; then
- # Extract the first word of "cc", so it can be a program name with args.
-set dummy cc; ac_word=$2
-echo "$as_me:$LINENO: checking for $ac_word" >&5
-echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
-if test "${ac_cv_prog_CC+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- if test -n "$CC"; then
- ac_cv_prog_CC="$CC" # Let the user override the test.
-else
- ac_prog_rejected=no
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
- IFS=$as_save_IFS
- test -z "$as_dir" && as_dir=.
- for ac_exec_ext in '' $ac_executable_extensions; do
- if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
- if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then
- ac_prog_rejected=yes
- continue
- fi
- ac_cv_prog_CC="cc"
- echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
- break 2
- fi
-done
-done
-
-if test $ac_prog_rejected = yes; then
- # We found a bogon in the path, so make sure we never use it.
- set dummy $ac_cv_prog_CC
- shift
- if test $# != 0; then
- # We chose a different compiler from the bogus one.
- # However, it has the same basename, so the bogon will be chosen
- # first if we set CC to just the basename; use the full file name.
- shift
- ac_cv_prog_CC="$as_dir/$ac_word${1+' '}$@"
- fi
-fi
-fi
-fi
-CC=$ac_cv_prog_CC
-if test -n "$CC"; then
- echo "$as_me:$LINENO: result: $CC" >&5
-echo "${ECHO_T}$CC" >&6
-else
- echo "$as_me:$LINENO: result: no" >&5
-echo "${ECHO_T}no" >&6
-fi
-
-fi
-if test -z "$CC"; then
- if test -n "$ac_tool_prefix"; then
- for ac_prog in cl
- do
- # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args.
-set dummy $ac_tool_prefix$ac_prog; ac_word=$2
-echo "$as_me:$LINENO: checking for $ac_word" >&5
-echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
-if test "${ac_cv_prog_CC+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- if test -n "$CC"; then
- ac_cv_prog_CC="$CC" # Let the user override the test.
-else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
- IFS=$as_save_IFS
- test -z "$as_dir" && as_dir=.
- for ac_exec_ext in '' $ac_executable_extensions; do
- if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
- ac_cv_prog_CC="$ac_tool_prefix$ac_prog"
- echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
- break 2
- fi
-done
-done
-
-fi
-fi
-CC=$ac_cv_prog_CC
-if test -n "$CC"; then
- echo "$as_me:$LINENO: result: $CC" >&5
-echo "${ECHO_T}$CC" >&6
-else
- echo "$as_me:$LINENO: result: no" >&5
-echo "${ECHO_T}no" >&6
-fi
-
- test -n "$CC" && break
- done
-fi
-if test -z "$CC"; then
- ac_ct_CC=$CC
- for ac_prog in cl
-do
- # Extract the first word of "$ac_prog", so it can be a program name with args.
-set dummy $ac_prog; ac_word=$2
-echo "$as_me:$LINENO: checking for $ac_word" >&5
-echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
-if test "${ac_cv_prog_ac_ct_CC+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- if test -n "$ac_ct_CC"; then
- ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test.
-else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
- IFS=$as_save_IFS
- test -z "$as_dir" && as_dir=.
- for ac_exec_ext in '' $ac_executable_extensions; do
- if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
- ac_cv_prog_ac_ct_CC="$ac_prog"
- echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
- break 2
- fi
-done
-done
-
-fi
-fi
-ac_ct_CC=$ac_cv_prog_ac_ct_CC
-if test -n "$ac_ct_CC"; then
- echo "$as_me:$LINENO: result: $ac_ct_CC" >&5
-echo "${ECHO_T}$ac_ct_CC" >&6
-else
- echo "$as_me:$LINENO: result: no" >&5
-echo "${ECHO_T}no" >&6
-fi
-
- test -n "$ac_ct_CC" && break
-done
-
- CC=$ac_ct_CC
-fi
-
-fi
-
-
-test -z "$CC" && { { echo "$as_me:$LINENO: error: no acceptable C compiler found in \$PATH
-See \`config.log' for more details." >&5
-echo "$as_me: error: no acceptable C compiler found in \$PATH
-See \`config.log' for more details." >&2;}
- { (exit 1); exit 1; }; }
-
-# Provide some information about the compiler.
-echo "$as_me:$LINENO:" \
- "checking for C compiler version" >&5
-ac_compiler=`set X $ac_compile; echo $2`
-{ (eval echo "$as_me:$LINENO: \"$ac_compiler --version </dev/null >&5\"") >&5
- (eval $ac_compiler --version </dev/null >&5) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }
-{ (eval echo "$as_me:$LINENO: \"$ac_compiler -v </dev/null >&5\"") >&5
- (eval $ac_compiler -v </dev/null >&5) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }
-{ (eval echo "$as_me:$LINENO: \"$ac_compiler -V </dev/null >&5\"") >&5
- (eval $ac_compiler -V </dev/null >&5) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }
-
-echo "$as_me:$LINENO: checking whether we are using the GNU C compiler" >&5
-echo $ECHO_N "checking whether we are using the GNU C compiler... $ECHO_C" >&6
-if test "${ac_cv_c_compiler_gnu+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-
-int
-main ()
-{
-#ifndef __GNUC__
- choke me
-#endif
-
- ;
- return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
- (eval $ac_compile) 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } &&
- { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; } &&
- { ac_try='test -s conftest.$ac_objext'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
- ac_compiler_gnu=yes
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-ac_compiler_gnu=no
-fi
-rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
-ac_cv_c_compiler_gnu=$ac_compiler_gnu
-
-fi
-echo "$as_me:$LINENO: result: $ac_cv_c_compiler_gnu" >&5
-echo "${ECHO_T}$ac_cv_c_compiler_gnu" >&6
-GCC=`test $ac_compiler_gnu = yes && echo yes`
-ac_test_CFLAGS=${CFLAGS+set}
-ac_save_CFLAGS=$CFLAGS
-CFLAGS="-g"
-echo "$as_me:$LINENO: checking whether $CC accepts -g" >&5
-echo $ECHO_N "checking whether $CC accepts -g... $ECHO_C" >&6
-if test "${ac_cv_prog_cc_g+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-
-int
-main ()
-{
-
- ;
- return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
- (eval $ac_compile) 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } &&
- { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; } &&
- { ac_try='test -s conftest.$ac_objext'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
- ac_cv_prog_cc_g=yes
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-ac_cv_prog_cc_g=no
-fi
-rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
-fi
-echo "$as_me:$LINENO: result: $ac_cv_prog_cc_g" >&5
-echo "${ECHO_T}$ac_cv_prog_cc_g" >&6
-if test "$ac_test_CFLAGS" = set; then
- CFLAGS=$ac_save_CFLAGS
-elif test $ac_cv_prog_cc_g = yes; then
- if test "$GCC" = yes; then
- CFLAGS="-g -O2"
- else
- CFLAGS="-g"
- fi
-else
- if test "$GCC" = yes; then
- CFLAGS="-O2"
- else
- CFLAGS=
- fi
-fi
-echo "$as_me:$LINENO: checking for $CC option to accept ANSI C" >&5
-echo $ECHO_N "checking for $CC option to accept ANSI C... $ECHO_C" >&6
-if test "${ac_cv_prog_cc_stdc+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- ac_cv_prog_cc_stdc=no
-ac_save_CC=$CC
-cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-#include <stdarg.h>
-#include <stdio.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-/* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */
-struct buf { int x; };
-FILE * (*rcsopen) (struct buf *, struct stat *, int);
-static char *e (p, i)
- char **p;
- int i;
-{
- return p[i];
-}
-static char *f (char * (*g) (char **, int), char **p, ...)
-{
- char *s;
- va_list v;
- va_start (v,p);
- s = g (p, va_arg (v,int));
- va_end (v);
- return s;
-}
-
-/* OSF 4.0 Compaq cc is some sort of almost-ANSI by default. It has
- function prototypes and stuff, but not '\xHH' hex character constants.
- These don't provoke an error unfortunately, instead are silently treated
- as 'x'. The following induces an error, until -std1 is added to get
- proper ANSI mode. Curiously '\x00'!='x' always comes out true, for an
- array size at least. It's necessary to write '\x00'==0 to get something
- that's true only with -std1. */
-int osf4_cc_array ['\x00' == 0 ? 1 : -1];
-
-int test (int i, double x);
-struct s1 {int (*f) (int a);};
-struct s2 {int (*f) (double a);};
-int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int);
-int argc;
-char **argv;
-int
-main ()
-{
-return f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1];
- ;
- return 0;
-}
-_ACEOF
-# Don't try gcc -ansi; that turns off useful extensions and
-# breaks some systems' header files.
-# AIX -qlanglvl=ansi
-# Ultrix and OSF/1 -std1
-# HP-UX 10.20 and later -Ae
-# HP-UX older versions -Aa -D_HPUX_SOURCE
-# SVR4 -Xc -D__EXTENSIONS__
-for ac_arg in "" -qlanglvl=ansi -std1 -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__"
-do
- CC="$ac_save_CC $ac_arg"
- rm -f conftest.$ac_objext
-if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
- (eval $ac_compile) 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } &&
- { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; } &&
- { ac_try='test -s conftest.$ac_objext'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
- ac_cv_prog_cc_stdc=$ac_arg
-break
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-fi
-rm -f conftest.err conftest.$ac_objext
-done
-rm -f conftest.$ac_ext conftest.$ac_objext
-CC=$ac_save_CC
-
-fi
-
-case "x$ac_cv_prog_cc_stdc" in
- x|xno)
- echo "$as_me:$LINENO: result: none needed" >&5
-echo "${ECHO_T}none needed" >&6 ;;
- *)
- echo "$as_me:$LINENO: result: $ac_cv_prog_cc_stdc" >&5
-echo "${ECHO_T}$ac_cv_prog_cc_stdc" >&6
- CC="$CC $ac_cv_prog_cc_stdc" ;;
-esac
-
-# Some people use a C++ compiler to compile C. Since we use `exit',
-# in C++ we need to declare it. In case someone uses the same compiler
-# for both compiling C and C++ we need to have the C++ compiler decide
-# the declaration of exit, since it's the most demanding environment.
-cat >conftest.$ac_ext <<_ACEOF
-#ifndef __cplusplus
- choke me
-#endif
-_ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
- (eval $ac_compile) 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } &&
- { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; } &&
- { ac_try='test -s conftest.$ac_objext'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
- for ac_declaration in \
- '' \
- 'extern "C" void std::exit (int) throw (); using std::exit;' \
- 'extern "C" void std::exit (int); using std::exit;' \
- 'extern "C" void exit (int) throw ();' \
- 'extern "C" void exit (int);' \
- 'void exit (int);'
-do
- cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-$ac_declaration
-#include <stdlib.h>
-int
-main ()
-{
-exit (42);
- ;
- return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
- (eval $ac_compile) 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } &&
- { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; } &&
- { ac_try='test -s conftest.$ac_objext'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
- :
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-continue
-fi
-rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
- cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-$ac_declaration
-int
-main ()
-{
-exit (42);
- ;
- return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
- (eval $ac_compile) 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } &&
- { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; } &&
- { ac_try='test -s conftest.$ac_objext'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
- break
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-fi
-rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
-done
-rm -f conftest*
-if test -n "$ac_declaration"; then
- echo '#ifdef __cplusplus' >>confdefs.h
- echo $ac_declaration >>confdefs.h
- echo '#endif' >>confdefs.h
-fi
-
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-fi
-rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
-ac_ext=c
-ac_cpp='$CPP $CPPFLAGS'
-ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
-ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
-ac_compiler_gnu=$ac_cv_c_compiler_gnu
-
-depcc="$CC" am_compiler_list=
-
-echo "$as_me:$LINENO: checking dependency style of $depcc" >&5
-echo $ECHO_N "checking dependency style of $depcc... $ECHO_C" >&6
-if test "${am_cv_CC_dependencies_compiler_type+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then
- # We make a subdir and do the tests there. Otherwise we can end up
- # making bogus files that we don't know about and never remove. For
- # instance it was reported that on HP-UX the gcc test will end up
- # making a dummy file named `D' -- because `-MD' means `put the output
- # in D'.
- mkdir conftest.dir
- # Copy depcomp to subdir because otherwise we won't find it if we're
- # using a relative directory.
- cp "$am_depcomp" conftest.dir
- cd conftest.dir
- # We will build objects and dependencies in a subdirectory because
- # it helps to detect inapplicable dependency modes. For instance
- # both Tru64's cc and ICC support -MD to output dependencies as a
- # side effect of compilation, but ICC will put the dependencies in
- # the current directory while Tru64 will put them in the object
- # directory.
- mkdir sub
-
- am_cv_CC_dependencies_compiler_type=none
- if test "$am_compiler_list" = ""; then
- am_compiler_list=`sed -n 's/^#*\([a-zA-Z0-9]*\))$/\1/p' < ./depcomp`
- fi
- for depmode in $am_compiler_list; do
- # Setup a source with many dependencies, because some compilers
- # like to wrap large dependency lists on column 80 (with \), and
- # we should not choose a depcomp mode which is confused by this.
- #
- # We need to recreate these files for each test, as the compiler may
- # overwrite some of them when testing with obscure command lines.
- # This happens at least with the AIX C compiler.
- : > sub/conftest.c
- for i in 1 2 3 4 5 6; do
- echo '#include "conftst'$i'.h"' >> sub/conftest.c
- # Using `: > sub/conftst$i.h' creates only sub/conftst1.h with
- # Solaris 8's {/usr,}/bin/sh.
- touch sub/conftst$i.h
- done
- echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf
-
- case $depmode in
- nosideeffect)
- # after this tag, mechanisms are not by side-effect, so they'll
- # only be used when explicitly requested
- if test "x$enable_dependency_tracking" = xyes; then
- continue
- else
- break
- fi
- ;;
- none) break ;;
- esac
- # We check with `-c' and `-o' for the sake of the "dashmstdout"
- # mode. It turns out that the SunPro C++ compiler does not properly
- # handle `-M -o', and we need to detect this.
- if depmode=$depmode \
- source=sub/conftest.c object=sub/conftest.${OBJEXT-o} \
- depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \
- $SHELL ./depcomp $depcc -c -o sub/conftest.${OBJEXT-o} sub/conftest.c \
- >/dev/null 2>conftest.err &&
- grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 &&
- grep sub/conftest.${OBJEXT-o} sub/conftest.Po > /dev/null 2>&1 &&
- ${MAKE-make} -s -f confmf > /dev/null 2>&1; then
- # icc doesn't choke on unknown options, it will just issue warnings
- # or remarks (even with -Werror). So we grep stderr for any message
- # that says an option was ignored or not supported.
- # When given -MP, icc 7.0 and 7.1 complain thusly:
- # icc: Command line warning: ignoring option '-M'; no argument required
- # The diagnosis changed in icc 8.0:
- # icc: Command line remark: option '-MP' not supported
- if (grep 'ignoring option' conftest.err ||
- grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else
- am_cv_CC_dependencies_compiler_type=$depmode
- break
- fi
- fi
- done
-
- cd ..
- rm -rf conftest.dir
-else
- am_cv_CC_dependencies_compiler_type=none
-fi
-
-fi
-echo "$as_me:$LINENO: result: $am_cv_CC_dependencies_compiler_type" >&5
-echo "${ECHO_T}$am_cv_CC_dependencies_compiler_type" >&6
-CCDEPMODE=depmode=$am_cv_CC_dependencies_compiler_type
-
-
-
-if
- test "x$enable_dependency_tracking" != xno \
- && test "$am_cv_CC_dependencies_compiler_type" = gcc3; then
- am__fastdepCC_TRUE=
- am__fastdepCC_FALSE='#'
-else
- am__fastdepCC_TRUE='#'
- am__fastdepCC_FALSE=
-fi
-
-
-
-echo "$as_me:$LINENO: checking for an ANSI C-conforming const" >&5
-echo $ECHO_N "checking for an ANSI C-conforming const... $ECHO_C" >&6
-if test "${ac_cv_c_const+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-
-int
-main ()
-{
-/* FIXME: Include the comments suggested by Paul. */
-#ifndef __cplusplus
- /* Ultrix mips cc rejects this. */
- typedef int charset[2];
- const charset x;
- /* SunOS 4.1.1 cc rejects this. */
- char const *const *ccp;
- char **p;
- /* NEC SVR4.0.2 mips cc rejects this. */
- struct point {int x, y;};
- static struct point const zero = {0,0};
- /* AIX XL C 1.02.0.0 rejects this.
- It does not let you subtract one const X* pointer from another in
- an arm of an if-expression whose if-part is not a constant
- expression */
- const char *g = "string";
- ccp = &g + (g ? g-g : 0);
- /* HPUX 7.0 cc rejects these. */
- ++ccp;
- p = (char**) ccp;
- ccp = (char const *const *) p;
- { /* SCO 3.2v4 cc rejects this. */
- char *t;
- char const *s = 0 ? (char *) 0 : (char const *) 0;
-
- *t++ = 0;
- }
- { /* Someone thinks the Sun supposedly-ANSI compiler will reject this. */
- int x[] = {25, 17};
- const int *foo = &x[0];
- ++foo;
- }
- { /* Sun SC1.0 ANSI compiler rejects this -- but not the above. */
- typedef const int *iptr;
- iptr p = 0;
- ++p;
- }
- { /* AIX XL C 1.02.0.0 rejects this saying
- "k.c", line 2.27: 1506-025 (S) Operand must be a modifiable lvalue. */
- struct s { int j; const int *ap[3]; };
- struct s *b; b->j = 5;
- }
- { /* ULTRIX-32 V3.1 (Rev 9) vcc rejects this */
- const int foo = 10;
- }
-#endif
-
- ;
- return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
- (eval $ac_compile) 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } &&
- { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; } &&
- { ac_try='test -s conftest.$ac_objext'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
- ac_cv_c_const=yes
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-ac_cv_c_const=no
-fi
-rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
-fi
-echo "$as_me:$LINENO: result: $ac_cv_c_const" >&5
-echo "${ECHO_T}$ac_cv_c_const" >&6
-if test $ac_cv_c_const = no; then
-
-cat >>confdefs.h <<\_ACEOF
-#define const
-_ACEOF
-
-fi
-
-echo "$as_me:$LINENO: checking for long" >&5
-echo $ECHO_N "checking for long... $ECHO_C" >&6
-if test "${ac_cv_type_long+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-$ac_includes_default
-int
-main ()
-{
-if ((long *) 0)
- return 0;
-if (sizeof (long))
- return 0;
- ;
- return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
- (eval $ac_compile) 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } &&
- { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; } &&
- { ac_try='test -s conftest.$ac_objext'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
- ac_cv_type_long=yes
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-ac_cv_type_long=no
-fi
-rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
-fi
-echo "$as_me:$LINENO: result: $ac_cv_type_long" >&5
-echo "${ECHO_T}$ac_cv_type_long" >&6
-
-echo "$as_me:$LINENO: checking size of long" >&5
-echo $ECHO_N "checking size of long... $ECHO_C" >&6
-if test "${ac_cv_sizeof_long+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- if test "$ac_cv_type_long" = yes; then
- # The cast to unsigned long works around a bug in the HP C Compiler
- # version HP92453-01 B.11.11.23709.GP, which incorrectly rejects
- # declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'.
- # This bug is HP SR number 8606223364.
- if test "$cross_compiling" = yes; then
- # Depending upon the size, compute the lo and hi bounds.
-cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-$ac_includes_default
-int
-main ()
-{
-static int test_array [1 - 2 * !(((long) (sizeof (long))) >= 0)];
-test_array [0] = 0
-
- ;
- return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
- (eval $ac_compile) 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } &&
- { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; } &&
- { ac_try='test -s conftest.$ac_objext'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
- ac_lo=0 ac_mid=0
- while :; do
- cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-$ac_includes_default
-int
-main ()
-{
-static int test_array [1 - 2 * !(((long) (sizeof (long))) <= $ac_mid)];
-test_array [0] = 0
-
- ;
- return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
- (eval $ac_compile) 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } &&
- { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; } &&
- { ac_try='test -s conftest.$ac_objext'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
- ac_hi=$ac_mid; break
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-ac_lo=`expr $ac_mid + 1`
- if test $ac_lo -le $ac_mid; then
- ac_lo= ac_hi=
- break
- fi
- ac_mid=`expr 2 '*' $ac_mid + 1`
-fi
-rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
- done
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-$ac_includes_default
-int
-main ()
-{
-static int test_array [1 - 2 * !(((long) (sizeof (long))) < 0)];
-test_array [0] = 0
-
- ;
- return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
- (eval $ac_compile) 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } &&
- { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; } &&
- { ac_try='test -s conftest.$ac_objext'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
- ac_hi=-1 ac_mid=-1
- while :; do
- cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-$ac_includes_default
-int
-main ()
-{
-static int test_array [1 - 2 * !(((long) (sizeof (long))) >= $ac_mid)];
-test_array [0] = 0
-
- ;
- return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
- (eval $ac_compile) 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } &&
- { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; } &&
- { ac_try='test -s conftest.$ac_objext'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
- ac_lo=$ac_mid; break
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-ac_hi=`expr '(' $ac_mid ')' - 1`
- if test $ac_mid -le $ac_hi; then
- ac_lo= ac_hi=
- break
- fi
- ac_mid=`expr 2 '*' $ac_mid`
-fi
-rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
- done
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-ac_lo= ac_hi=
-fi
-rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
-fi
-rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
-# Binary search between lo and hi bounds.
-while test "x$ac_lo" != "x$ac_hi"; do
- ac_mid=`expr '(' $ac_hi - $ac_lo ')' / 2 + $ac_lo`
- cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-$ac_includes_default
-int
-main ()
-{
-static int test_array [1 - 2 * !(((long) (sizeof (long))) <= $ac_mid)];
-test_array [0] = 0
-
- ;
- return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
- (eval $ac_compile) 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } &&
- { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; } &&
- { ac_try='test -s conftest.$ac_objext'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
- ac_hi=$ac_mid
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-ac_lo=`expr '(' $ac_mid ')' + 1`
-fi
-rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
-done
-case $ac_lo in
-?*) ac_cv_sizeof_long=$ac_lo;;
-'') { { echo "$as_me:$LINENO: error: cannot compute sizeof (long), 77
-See \`config.log' for more details." >&5
-echo "$as_me: error: cannot compute sizeof (long), 77
-See \`config.log' for more details." >&2;}
- { (exit 1); exit 1; }; } ;;
-esac
-else
- if test "$cross_compiling" = yes; then
- { { echo "$as_me:$LINENO: error: internal error: not reached in cross-compile" >&5
-echo "$as_me: error: internal error: not reached in cross-compile" >&2;}
- { (exit 1); exit 1; }; }
-else
- cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-$ac_includes_default
-long longval () { return (long) (sizeof (long)); }
-unsigned long ulongval () { return (long) (sizeof (long)); }
-#include <stdio.h>
-#include <stdlib.h>
-int
-main ()
-{
-
- FILE *f = fopen ("conftest.val", "w");
- if (! f)
- exit (1);
- if (((long) (sizeof (long))) < 0)
- {
- long i = longval ();
- if (i != ((long) (sizeof (long))))
- exit (1);
- fprintf (f, "%ld\n", i);
- }
- else
- {
- unsigned long i = ulongval ();
- if (i != ((long) (sizeof (long))))
- exit (1);
- fprintf (f, "%lu\n", i);
- }
- exit (ferror (f) || fclose (f) != 0);
-
- ;
- return 0;
-}
-_ACEOF
-rm -f conftest$ac_exeext
-if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
- (eval $ac_link) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
- ac_cv_sizeof_long=`cat conftest.val`
-else
- echo "$as_me: program exited with status $ac_status" >&5
-echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-( exit $ac_status )
-{ { echo "$as_me:$LINENO: error: cannot compute sizeof (long), 77
-See \`config.log' for more details." >&5
-echo "$as_me: error: cannot compute sizeof (long), 77
-See \`config.log' for more details." >&2;}
- { (exit 1); exit 1; }; }
-fi
-rm -f core *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
-fi
-fi
-rm -f conftest.val
-else
- ac_cv_sizeof_long=0
-fi
-fi
-echo "$as_me:$LINENO: result: $ac_cv_sizeof_long" >&5
-echo "${ECHO_T}$ac_cv_sizeof_long" >&6
-cat >>confdefs.h <<_ACEOF
-#define SIZEOF_LONG $ac_cv_sizeof_long
-_ACEOF
-
-
-
-if test "$disable_libcheck" != "yes"; then
-
-echo "$as_me:$LINENO: checking for ibv_get_device_list in -libverbs" >&5
-echo $ECHO_N "checking for ibv_get_device_list in -libverbs... $ECHO_C" >&6
-if test "${ac_cv_lib_ibverbs_ibv_get_device_list+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- ac_check_lib_save_LIBS=$LIBS
-LIBS="-libverbs $LIBS"
-cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-
-/* Override any gcc2 internal prototype to avoid an error. */
-#ifdef __cplusplus
-extern "C"
-#endif
-/* We use char because int might match the return type of a gcc2
- builtin and then its argument prototype would still apply. */
-char ibv_get_device_list ();
-int
-main ()
-{
-ibv_get_device_list ();
- ;
- return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
- (eval $ac_link) 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } &&
- { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; } &&
- { ac_try='test -s conftest$ac_exeext'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
- ac_cv_lib_ibverbs_ibv_get_device_list=yes
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-ac_cv_lib_ibverbs_ibv_get_device_list=no
-fi
-rm -f conftest.err conftest.$ac_objext \
- conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
-fi
-echo "$as_me:$LINENO: result: $ac_cv_lib_ibverbs_ibv_get_device_list" >&5
-echo "${ECHO_T}$ac_cv_lib_ibverbs_ibv_get_device_list" >&6
-if test $ac_cv_lib_ibverbs_ibv_get_device_list = yes; then
- cat >>confdefs.h <<_ACEOF
-#define HAVE_LIBIBVERBS 1
-_ACEOF
-
- LIBS="-libverbs $LIBS"
-
-else
- { { echo "$as_me:$LINENO: error: ibv_get_device_list() not found. librdmacm requires libibverbs." >&5
-echo "$as_me: error: ibv_get_device_list() not found. librdmacm requires libibverbs." >&2;}
- { (exit 1); exit 1; }; }
-fi
-
-fi
-
-echo "$as_me:$LINENO: checking for ANSI C header files" >&5
-echo $ECHO_N "checking for ANSI C header files... $ECHO_C" >&6
-if test "${ac_cv_header_stdc+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-#include <stdlib.h>
-#include <stdarg.h>
-#include <string.h>
-#include <float.h>
-
-int
-main ()
-{
-
- ;
- return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
- (eval $ac_compile) 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } &&
- { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; } &&
- { ac_try='test -s conftest.$ac_objext'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
- ac_cv_header_stdc=yes
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-ac_cv_header_stdc=no
-fi
-rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
-
-if test $ac_cv_header_stdc = yes; then
- # SunOS 4.x string.h does not declare mem*, contrary to ANSI.
- cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-#include <string.h>
-
-_ACEOF
-if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
- $EGREP "memchr" >/dev/null 2>&1; then
- :
-else
- ac_cv_header_stdc=no
-fi
-rm -f conftest*
-
-fi
-
-if test $ac_cv_header_stdc = yes; then
- # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI.
- cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-#include <stdlib.h>
-
-_ACEOF
-if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
- $EGREP "free" >/dev/null 2>&1; then
- :
-else
- ac_cv_header_stdc=no
-fi
-rm -f conftest*
-
-fi
-
-if test $ac_cv_header_stdc = yes; then
- # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi.
- if test "$cross_compiling" = yes; then
- :
-else
- cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-#include <ctype.h>
-#if ((' ' & 0x0FF) == 0x020)
-# define ISLOWER(c) ('a' <= (c) && (c) <= 'z')
-# define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c))
-#else
-# define ISLOWER(c) \
- (('a' <= (c) && (c) <= 'i') \
- || ('j' <= (c) && (c) <= 'r') \
- || ('s' <= (c) && (c) <= 'z'))
-# define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c))
-#endif
-
-#define XOR(e, f) (((e) && !(f)) || (!(e) && (f)))
-int
-main ()
-{
- int i;
- for (i = 0; i < 256; i++)
- if (XOR (islower (i), ISLOWER (i))
- || toupper (i) != TOUPPER (i))
- exit(2);
- exit (0);
-}
-_ACEOF
-rm -f conftest$ac_exeext
-if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
- (eval $ac_link) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
- :
-else
- echo "$as_me: program exited with status $ac_status" >&5
-echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-( exit $ac_status )
-ac_cv_header_stdc=no
-fi
-rm -f core *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
-fi
-fi
-fi
-echo "$as_me:$LINENO: result: $ac_cv_header_stdc" >&5
-echo "${ECHO_T}$ac_cv_header_stdc" >&6
-if test $ac_cv_header_stdc = yes; then
-
-cat >>confdefs.h <<\_ACEOF
-#define STDC_HEADERS 1
-_ACEOF
-
-fi
-
-if test "$disable_libcheck" != "yes"; then
-if test "${ac_cv_header_infiniband_verbs_h+set}" = set; then
- echo "$as_me:$LINENO: checking for infiniband/verbs.h" >&5
-echo $ECHO_N "checking for infiniband/verbs.h... $ECHO_C" >&6
-if test "${ac_cv_header_infiniband_verbs_h+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-fi
-echo "$as_me:$LINENO: result: $ac_cv_header_infiniband_verbs_h" >&5
-echo "${ECHO_T}$ac_cv_header_infiniband_verbs_h" >&6
-else
- # Is the header compilable?
-echo "$as_me:$LINENO: checking infiniband/verbs.h usability" >&5
-echo $ECHO_N "checking infiniband/verbs.h usability... $ECHO_C" >&6
-cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-$ac_includes_default
-#include <infiniband/verbs.h>
-_ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
- (eval $ac_compile) 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } &&
- { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; } &&
- { ac_try='test -s conftest.$ac_objext'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
- ac_header_compiler=yes
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-ac_header_compiler=no
-fi
-rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
-echo "$as_me:$LINENO: result: $ac_header_compiler" >&5
-echo "${ECHO_T}$ac_header_compiler" >&6
-
-# Is the header present?
-echo "$as_me:$LINENO: checking infiniband/verbs.h presence" >&5
-echo $ECHO_N "checking infiniband/verbs.h presence... $ECHO_C" >&6
-cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-#include <infiniband/verbs.h>
-_ACEOF
-if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5
- (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } >/dev/null; then
- if test -s conftest.err; then
- ac_cpp_err=$ac_c_preproc_warn_flag
- ac_cpp_err=$ac_cpp_err$ac_c_werror_flag
- else
- ac_cpp_err=
- fi
-else
- ac_cpp_err=yes
-fi
-if test -z "$ac_cpp_err"; then
- ac_header_preproc=yes
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
- ac_header_preproc=no
-fi
-rm -f conftest.err conftest.$ac_ext
-echo "$as_me:$LINENO: result: $ac_header_preproc" >&5
-echo "${ECHO_T}$ac_header_preproc" >&6
-
-# So? What about this header?
-case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in
- yes:no: )
- { echo "$as_me:$LINENO: WARNING: infiniband/verbs.h: accepted by the compiler, rejected by the preprocessor!" >&5
-echo "$as_me: WARNING: infiniband/verbs.h: accepted by the compiler, rejected by the preprocessor!" >&2;}
- { echo "$as_me:$LINENO: WARNING: infiniband/verbs.h: proceeding with the compiler's result" >&5
-echo "$as_me: WARNING: infiniband/verbs.h: proceeding with the compiler's result" >&2;}
- ac_header_preproc=yes
- ;;
- no:yes:* )
- { echo "$as_me:$LINENO: WARNING: infiniband/verbs.h: present but cannot be compiled" >&5
-echo "$as_me: WARNING: infiniband/verbs.h: present but cannot be compiled" >&2;}
- { echo "$as_me:$LINENO: WARNING: infiniband/verbs.h: check for missing prerequisite headers?" >&5
-echo "$as_me: WARNING: infiniband/verbs.h: check for missing prerequisite headers?" >&2;}
- { echo "$as_me:$LINENO: WARNING: infiniband/verbs.h: see the Autoconf documentation" >&5
-echo "$as_me: WARNING: infiniband/verbs.h: see the Autoconf documentation" >&2;}
- { echo "$as_me:$LINENO: WARNING: infiniband/verbs.h: section \"Present But Cannot Be Compiled\"" >&5
-echo "$as_me: WARNING: infiniband/verbs.h: section \"Present But Cannot Be Compiled\"" >&2;}
- { echo "$as_me:$LINENO: WARNING: infiniband/verbs.h: proceeding with the preprocessor's result" >&5
-echo "$as_me: WARNING: infiniband/verbs.h: proceeding with the preprocessor's result" >&2;}
- { echo "$as_me:$LINENO: WARNING: infiniband/verbs.h: in the future, the compiler will take precedence" >&5
-echo "$as_me: WARNING: infiniband/verbs.h: in the future, the compiler will take precedence" >&2;}
- (
- cat <<\_ASBOX
-## -------------------------------------------- ##
-## Report this to general@lists.openfabrics.org ##
-## -------------------------------------------- ##
-_ASBOX
- ) |
- sed "s/^/$as_me: WARNING: /" >&2
- ;;
-esac
-echo "$as_me:$LINENO: checking for infiniband/verbs.h" >&5
-echo $ECHO_N "checking for infiniband/verbs.h... $ECHO_C" >&6
-if test "${ac_cv_header_infiniband_verbs_h+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- ac_cv_header_infiniband_verbs_h=$ac_header_preproc
-fi
-echo "$as_me:$LINENO: result: $ac_cv_header_infiniband_verbs_h" >&5
-echo "${ECHO_T}$ac_cv_header_infiniband_verbs_h" >&6
-
-fi
-if test $ac_cv_header_infiniband_verbs_h = yes; then
- :
-else
- { { echo "$as_me:$LINENO: error: <infiniband/verbs.h> not found. Is libibverbs installed?" >&5
-echo "$as_me: error: <infiniband/verbs.h> not found. Is libibverbs installed?" >&2;}
- { (exit 1); exit 1; }; }
-fi
-
-
-
-if test "$with_valgrind" != "" && test "$with_valgrind" != "no"; then
-if test "${ac_cv_header_valgrind_memcheck_h+set}" = set; then
- echo "$as_me:$LINENO: checking for valgrind/memcheck.h" >&5
-echo $ECHO_N "checking for valgrind/memcheck.h... $ECHO_C" >&6
-if test "${ac_cv_header_valgrind_memcheck_h+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-fi
-echo "$as_me:$LINENO: result: $ac_cv_header_valgrind_memcheck_h" >&5
-echo "${ECHO_T}$ac_cv_header_valgrind_memcheck_h" >&6
-else
- # Is the header compilable?
-echo "$as_me:$LINENO: checking valgrind/memcheck.h usability" >&5
-echo $ECHO_N "checking valgrind/memcheck.h usability... $ECHO_C" >&6
-cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-$ac_includes_default
-#include <valgrind/memcheck.h>
-_ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
- (eval $ac_compile) 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } &&
- { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; } &&
- { ac_try='test -s conftest.$ac_objext'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
- ac_header_compiler=yes
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-ac_header_compiler=no
-fi
-rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
-echo "$as_me:$LINENO: result: $ac_header_compiler" >&5
-echo "${ECHO_T}$ac_header_compiler" >&6
-
-# Is the header present?
-echo "$as_me:$LINENO: checking valgrind/memcheck.h presence" >&5
-echo $ECHO_N "checking valgrind/memcheck.h presence... $ECHO_C" >&6
-cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-#include <valgrind/memcheck.h>
-_ACEOF
-if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5
- (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } >/dev/null; then
- if test -s conftest.err; then
- ac_cpp_err=$ac_c_preproc_warn_flag
- ac_cpp_err=$ac_cpp_err$ac_c_werror_flag
- else
- ac_cpp_err=
- fi
-else
- ac_cpp_err=yes
-fi
-if test -z "$ac_cpp_err"; then
- ac_header_preproc=yes
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
- ac_header_preproc=no
-fi
-rm -f conftest.err conftest.$ac_ext
-echo "$as_me:$LINENO: result: $ac_header_preproc" >&5
-echo "${ECHO_T}$ac_header_preproc" >&6
-
-# So? What about this header?
-case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in
- yes:no: )
- { echo "$as_me:$LINENO: WARNING: valgrind/memcheck.h: accepted by the compiler, rejected by the preprocessor!" >&5
-echo "$as_me: WARNING: valgrind/memcheck.h: accepted by the compiler, rejected by the preprocessor!" >&2;}
- { echo "$as_me:$LINENO: WARNING: valgrind/memcheck.h: proceeding with the compiler's result" >&5
-echo "$as_me: WARNING: valgrind/memcheck.h: proceeding with the compiler's result" >&2;}
- ac_header_preproc=yes
- ;;
- no:yes:* )
- { echo "$as_me:$LINENO: WARNING: valgrind/memcheck.h: present but cannot be compiled" >&5
-echo "$as_me: WARNING: valgrind/memcheck.h: present but cannot be compiled" >&2;}
- { echo "$as_me:$LINENO: WARNING: valgrind/memcheck.h: check for missing prerequisite headers?" >&5
-echo "$as_me: WARNING: valgrind/memcheck.h: check for missing prerequisite headers?" >&2;}
- { echo "$as_me:$LINENO: WARNING: valgrind/memcheck.h: see the Autoconf documentation" >&5
-echo "$as_me: WARNING: valgrind/memcheck.h: see the Autoconf documentation" >&2;}
- { echo "$as_me:$LINENO: WARNING: valgrind/memcheck.h: section \"Present But Cannot Be Compiled\"" >&5
-echo "$as_me: WARNING: valgrind/memcheck.h: section \"Present But Cannot Be Compiled\"" >&2;}
- { echo "$as_me:$LINENO: WARNING: valgrind/memcheck.h: proceeding with the preprocessor's result" >&5
-echo "$as_me: WARNING: valgrind/memcheck.h: proceeding with the preprocessor's result" >&2;}
- { echo "$as_me:$LINENO: WARNING: valgrind/memcheck.h: in the future, the compiler will take precedence" >&5
-echo "$as_me: WARNING: valgrind/memcheck.h: in the future, the compiler will take precedence" >&2;}
- (
- cat <<\_ASBOX
-## -------------------------------------------- ##
-## Report this to general@lists.openfabrics.org ##
-## -------------------------------------------- ##
-_ASBOX
- ) |
- sed "s/^/$as_me: WARNING: /" >&2
- ;;
-esac
-echo "$as_me:$LINENO: checking for valgrind/memcheck.h" >&5
-echo $ECHO_N "checking for valgrind/memcheck.h... $ECHO_C" >&6
-if test "${ac_cv_header_valgrind_memcheck_h+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- ac_cv_header_valgrind_memcheck_h=$ac_header_preproc
-fi
-echo "$as_me:$LINENO: result: $ac_cv_header_valgrind_memcheck_h" >&5
-echo "${ECHO_T}$ac_cv_header_valgrind_memcheck_h" >&6
-
-fi
-if test $ac_cv_header_valgrind_memcheck_h = yes; then
- :
-else
- { { echo "$as_me:$LINENO: error: valgrind requested but <valgrind/memcheck.h> not found." >&5
-echo "$as_me: error: valgrind requested but <valgrind/memcheck.h> not found." >&2;}
- { (exit 1); exit 1; }; }
-fi
-
-
-fi
-
-fi
-
-echo "$as_me:$LINENO: checking whether ld accepts --version-script" >&5
-echo $ECHO_N "checking whether ld accepts --version-script... $ECHO_C" >&6
-if test "${ac_cv_version_script+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- if test -n "`$LD --help < /dev/null 2>/dev/null | grep version-script`"; then
- ac_cv_version_script=yes
- else
- ac_cv_version_script=no
- fi
-fi
-echo "$as_me:$LINENO: result: $ac_cv_version_script" >&5
-echo "${ECHO_T}$ac_cv_version_script" >&6
-
-
-
-if test "$ac_cv_version_script" = "yes"; then
- HAVE_LD_VERSION_SCRIPT_TRUE=
- HAVE_LD_VERSION_SCRIPT_FALSE='#'
-else
- HAVE_LD_VERSION_SCRIPT_TRUE='#'
- HAVE_LD_VERSION_SCRIPT_FALSE=
-fi
-
-
- ac_config_files="$ac_config_files Makefile librdmacm.spec"
-
-cat >confcache <<\_ACEOF
-# This file is a shell script that caches the results of configure
-# tests run on this system so they can be shared between configure
-# scripts and configure runs, see configure's option --config-cache.
-# It is not useful on other systems. If it contains results you don't
-# want to keep, you may remove or edit it.
-#
-# config.status only pays attention to the cache file if you give it
-# the --recheck option to rerun configure.
-#
-# `ac_cv_env_foo' variables (set or unset) will be overridden when
-# loading this file, other *unset* `ac_cv_foo' will be assigned the
-# following values.
-
-_ACEOF
-
-# The following way of writing the cache mishandles newlines in values,
-# but we know of no workaround that is simple, portable, and efficient.
-# So, don't put newlines in cache variables' values.
-# Ultrix sh set writes to stderr and can't be redirected directly,
-# and sets the high bit in the cache file unless we assign to the vars.
-{
- (set) 2>&1 |
- case `(ac_space=' '; set | grep ac_space) 2>&1` in
- *ac_space=\ *)
- # `set' does not quote correctly, so add quotes (double-quote
- # substitution turns \\\\ into \\, and sed turns \\ into \).
- sed -n \
- "s/'/'\\\\''/g;
- s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\\2'/p"
- ;;
- *)
- # `set' quotes correctly as required by POSIX, so do not add quotes.
- sed -n \
- "s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1=\\2/p"
- ;;
- esac;
-} |
- sed '
- t clear
- : clear
- s/^\([^=]*\)=\(.*[{}].*\)$/test "${\1+set}" = set || &/
- t end
- /^ac_cv_env/!s/^\([^=]*\)=\(.*\)$/\1=${\1=\2}/
- : end' >>confcache
-if diff $cache_file confcache >/dev/null 2>&1; then :; else
- if test -w $cache_file; then
- test "x$cache_file" != "x/dev/null" && echo "updating cache $cache_file"
- cat confcache >$cache_file
- else
- echo "not updating unwritable cache $cache_file"
- fi
-fi
-rm -f confcache
-
-test "x$prefix" = xNONE && prefix=$ac_default_prefix
-# Let make expand exec_prefix.
-test "x$exec_prefix" = xNONE && exec_prefix='${prefix}'
-
-# VPATH may cause trouble with some makes, so we remove $(srcdir),
-# ${srcdir} and @srcdir@ from VPATH if srcdir is ".", strip leading and
-# trailing colons and then remove the whole line if VPATH becomes empty
-# (actually we leave an empty line to preserve line numbers).
-if test "x$srcdir" = x.; then
- ac_vpsub='/^[ ]*VPATH[ ]*=/{
-s/:*\$(srcdir):*/:/;
-s/:*\${srcdir}:*/:/;
-s/:*@srcdir@:*/:/;
-s/^\([^=]*=[ ]*\):*/\1/;
-s/:*$//;
-s/^[^=]*=[ ]*$//;
-}'
-fi
-
-DEFS=-DHAVE_CONFIG_H
-
-ac_libobjs=
-ac_ltlibobjs=
-for ac_i in : $LIBOBJS; do test "x$ac_i" = x: && continue
- # 1. Remove the extension, and $U if already installed.
- ac_i=`echo "$ac_i" |
- sed 's/\$U\././;s/\.o$//;s/\.obj$//'`
- # 2. Add them.
- ac_libobjs="$ac_libobjs $ac_i\$U.$ac_objext"
- ac_ltlibobjs="$ac_ltlibobjs $ac_i"'$U.lo'
-done
-LIBOBJS=$ac_libobjs
-
-LTLIBOBJS=$ac_ltlibobjs
-
-
-if test -z "${AMDEP_TRUE}" && test -z "${AMDEP_FALSE}"; then
- { { echo "$as_me:$LINENO: error: conditional \"AMDEP\" was never defined.
-Usually this means the macro was only invoked conditionally." >&5
-echo "$as_me: error: conditional \"AMDEP\" was never defined.
-Usually this means the macro was only invoked conditionally." >&2;}
- { (exit 1); exit 1; }; }
-fi
-if test -z "${am__fastdepCC_TRUE}" && test -z "${am__fastdepCC_FALSE}"; then
- { { echo "$as_me:$LINENO: error: conditional \"am__fastdepCC\" was never defined.
-Usually this means the macro was only invoked conditionally." >&5
-echo "$as_me: error: conditional \"am__fastdepCC\" was never defined.
-Usually this means the macro was only invoked conditionally." >&2;}
- { (exit 1); exit 1; }; }
-fi
-if test -z "${am__fastdepCXX_TRUE}" && test -z "${am__fastdepCXX_FALSE}"; then
- { { echo "$as_me:$LINENO: error: conditional \"am__fastdepCXX\" was never defined.
-Usually this means the macro was only invoked conditionally." >&5
-echo "$as_me: error: conditional \"am__fastdepCXX\" was never defined.
-Usually this means the macro was only invoked conditionally." >&2;}
- { (exit 1); exit 1; }; }
-fi
-if test -z "${am__fastdepCC_TRUE}" && test -z "${am__fastdepCC_FALSE}"; then
- { { echo "$as_me:$LINENO: error: conditional \"am__fastdepCC\" was never defined.
-Usually this means the macro was only invoked conditionally." >&5
-echo "$as_me: error: conditional \"am__fastdepCC\" was never defined.
-Usually this means the macro was only invoked conditionally." >&2;}
- { (exit 1); exit 1; }; }
-fi
-if test -z "${HAVE_LD_VERSION_SCRIPT_TRUE}" && test -z "${HAVE_LD_VERSION_SCRIPT_FALSE}"; then
- { { echo "$as_me:$LINENO: error: conditional \"HAVE_LD_VERSION_SCRIPT\" was never defined.
-Usually this means the macro was only invoked conditionally." >&5
-echo "$as_me: error: conditional \"HAVE_LD_VERSION_SCRIPT\" was never defined.
-Usually this means the macro was only invoked conditionally." >&2;}
- { (exit 1); exit 1; }; }
-fi
-
-: ${CONFIG_STATUS=./config.status}
-ac_clean_files_save=$ac_clean_files
-ac_clean_files="$ac_clean_files $CONFIG_STATUS"
-{ echo "$as_me:$LINENO: creating $CONFIG_STATUS" >&5
-echo "$as_me: creating $CONFIG_STATUS" >&6;}
-cat >$CONFIG_STATUS <<_ACEOF
-#! $SHELL
-# Generated by $as_me.
-# Run this file to recreate the current configuration.
-# Compiler output produced by configure, useful for debugging
-# configure, is in config.log if it exists.
-
-debug=false
-ac_cs_recheck=false
-ac_cs_silent=false
-SHELL=\${CONFIG_SHELL-$SHELL}
-_ACEOF
-
-cat >>$CONFIG_STATUS <<\_ACEOF
-## --------------------- ##
-## M4sh Initialization. ##
-## --------------------- ##
-
-# Be Bourne compatible
-if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then
- emulate sh
- NULLCMD=:
- # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which
- # is contrary to our usage. Disable this feature.
- alias -g '${1+"$@"}'='"$@"'
-elif test -n "${BASH_VERSION+set}" && (set -o posix) >/dev/null 2>&1; then
- set -o posix
-fi
-DUALCASE=1; export DUALCASE # for MKS sh
-
-# Support unset when possible.
-if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then
- as_unset=unset
-else
- as_unset=false
-fi
-
-
-# Work around bugs in pre-3.0 UWIN ksh.
-$as_unset ENV MAIL MAILPATH
-PS1='$ '
-PS2='> '
-PS4='+ '
-
-# NLS nuisances.
-for as_var in \
- LANG LANGUAGE LC_ADDRESS LC_ALL LC_COLLATE LC_CTYPE LC_IDENTIFICATION \
- LC_MEASUREMENT LC_MESSAGES LC_MONETARY LC_NAME LC_NUMERIC LC_PAPER \
- LC_TELEPHONE LC_TIME
-do
- if (set +x; test -z "`(eval $as_var=C; export $as_var) 2>&1`"); then
- eval $as_var=C; export $as_var
- else
- $as_unset $as_var
- fi
-done
-
-# Required to use basename.
-if expr a : '\(a\)' >/dev/null 2>&1; then
- as_expr=expr
-else
- as_expr=false
-fi
-
-if (basename /) >/dev/null 2>&1 && test "X`basename / 2>&1`" = "X/"; then
- as_basename=basename
-else
- as_basename=false
-fi
-
-
-# Name of the executable.
-as_me=`$as_basename "$0" ||
-$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \
- X"$0" : 'X\(//\)$' \| \
- X"$0" : 'X\(/\)$' \| \
- . : '\(.\)' 2>/dev/null ||
-echo X/"$0" |
- sed '/^.*\/\([^/][^/]*\)\/*$/{ s//\1/; q; }
- /^X\/\(\/\/\)$/{ s//\1/; q; }
- /^X\/\(\/\).*/{ s//\1/; q; }
- s/.*/./; q'`
-
-
-# PATH needs CR, and LINENO needs CR and PATH.
-# Avoid depending upon Character Ranges.
-as_cr_letters='abcdefghijklmnopqrstuvwxyz'
-as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ'
-as_cr_Letters=$as_cr_letters$as_cr_LETTERS
-as_cr_digits='0123456789'
-as_cr_alnum=$as_cr_Letters$as_cr_digits
-
-# The user is always right.
-if test "${PATH_SEPARATOR+set}" != set; then
- echo "#! /bin/sh" >conf$$.sh
- echo "exit 0" >>conf$$.sh
- chmod +x conf$$.sh
- if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then
- PATH_SEPARATOR=';'
- else
- PATH_SEPARATOR=:
- fi
- rm -f conf$$.sh
-fi
-
-
- as_lineno_1=$LINENO
- as_lineno_2=$LINENO
- as_lineno_3=`(expr $as_lineno_1 + 1) 2>/dev/null`
- test "x$as_lineno_1" != "x$as_lineno_2" &&
- test "x$as_lineno_3" = "x$as_lineno_2" || {
- # Find who we are. Look in the path if we contain no path at all
- # relative or not.
- case $0 in
- *[\\/]* ) as_myself=$0 ;;
- *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
- IFS=$as_save_IFS
- test -z "$as_dir" && as_dir=.
- test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break
-done
-
- ;;
- esac
- # We did not find ourselves, most probably we were run as `sh COMMAND'
- # in which case we are not to be found in the path.
- if test "x$as_myself" = x; then
- as_myself=$0
- fi
- if test ! -f "$as_myself"; then
- { { echo "$as_me:$LINENO: error: cannot find myself; rerun with an absolute path" >&5
-echo "$as_me: error: cannot find myself; rerun with an absolute path" >&2;}
- { (exit 1); exit 1; }; }
- fi
- case $CONFIG_SHELL in
- '')
- as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH
-do
- IFS=$as_save_IFS
- test -z "$as_dir" && as_dir=.
- for as_base in sh bash ksh sh5; do
- case $as_dir in
- /*)
- if ("$as_dir/$as_base" -c '
- as_lineno_1=$LINENO
- as_lineno_2=$LINENO
- as_lineno_3=`(expr $as_lineno_1 + 1) 2>/dev/null`
- test "x$as_lineno_1" != "x$as_lineno_2" &&
- test "x$as_lineno_3" = "x$as_lineno_2" ') 2>/dev/null; then
- $as_unset BASH_ENV || test "${BASH_ENV+set}" != set || { BASH_ENV=; export BASH_ENV; }
- $as_unset ENV || test "${ENV+set}" != set || { ENV=; export ENV; }
- CONFIG_SHELL=$as_dir/$as_base
- export CONFIG_SHELL
- exec "$CONFIG_SHELL" "$0" ${1+"$@"}
- fi;;
- esac
- done
-done
-;;
- esac
-
- # Create $as_me.lineno as a copy of $as_myself, but with $LINENO
- # uniformly replaced by the line number. The first 'sed' inserts a
- # line-number line before each line; the second 'sed' does the real
- # work. The second script uses 'N' to pair each line-number line
- # with the numbered line, and appends trailing '-' during
- # substitution so that $LINENO is not a special case at line end.
- # (Raja R Harinath suggested sed '=', and Paul Eggert wrote the
- # second 'sed' script. Blame Lee E. McMahon for sed's syntax. :-)
- sed '=' <$as_myself |
- sed '
- N
- s,$,-,
- : loop
- s,^\(['$as_cr_digits']*\)\(.*\)[$]LINENO\([^'$as_cr_alnum'_]\),\1\2\1\3,
- t loop
- s,-$,,
- s,^['$as_cr_digits']*\n,,
- ' >$as_me.lineno &&
- chmod +x $as_me.lineno ||
- { { echo "$as_me:$LINENO: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&5
-echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2;}
- { (exit 1); exit 1; }; }
-
- # Don't try to exec as it changes $[0], causing all sort of problems
- # (the dirname of $[0] is not the place where we might find the
- # original and so on. Autoconf is especially sensible to this).
- . ./$as_me.lineno
- # Exit status is that of the last command.
- exit
-}
-
-
-case `echo "testing\c"; echo 1,2,3`,`echo -n testing; echo 1,2,3` in
- *c*,-n*) ECHO_N= ECHO_C='
-' ECHO_T=' ' ;;
- *c*,* ) ECHO_N=-n ECHO_C= ECHO_T= ;;
- *) ECHO_N= ECHO_C='\c' ECHO_T= ;;
-esac
-
-if expr a : '\(a\)' >/dev/null 2>&1; then
- as_expr=expr
-else
- as_expr=false
-fi
-
-rm -f conf$$ conf$$.exe conf$$.file
-echo >conf$$.file
-if ln -s conf$$.file conf$$ 2>/dev/null; then
- # We could just check for DJGPP; but this test a) works b) is more generic
- # and c) will remain valid once DJGPP supports symlinks (DJGPP 2.04).
- if test -f conf$$.exe; then
- # Don't use ln at all; we don't have any links
- as_ln_s='cp -p'
- else
- as_ln_s='ln -s'
- fi
-elif ln conf$$.file conf$$ 2>/dev/null; then
- as_ln_s=ln
-else
- as_ln_s='cp -p'
-fi
-rm -f conf$$ conf$$.exe conf$$.file
-
-if mkdir -p . 2>/dev/null; then
- as_mkdir_p=:
-else
- test -d ./-p && rmdir ./-p
- as_mkdir_p=false
-fi
-
-as_executable_p="test -f"
-
-# Sed expression to map a string onto a valid CPP name.
-as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'"
-
-# Sed expression to map a string onto a valid variable name.
-as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'"
-
-
-# IFS
-# We need space, tab and new line, in precisely that order.
-as_nl='
-'
-IFS=" $as_nl"
-
-# CDPATH.
-$as_unset CDPATH
-
-exec 6>&1
-
-# Open the log real soon, to keep \$[0] and so on meaningful, and to
-# report actual input values of CONFIG_FILES etc. instead of their
-# values after options handling. Logging --version etc. is OK.
-exec 5>>config.log
-{
- echo
- sed 'h;s/./-/g;s/^.../## /;s/...$/ ##/;p;x;p;x' <<_ASBOX
-## Running $as_me. ##
-_ASBOX
-} >&5
-cat >&5 <<_CSEOF
-
-This file was extended by librdmacm $as_me 1.0.11, which was
-generated by GNU Autoconf 2.59. Invocation command line was
-
- CONFIG_FILES = $CONFIG_FILES
- CONFIG_HEADERS = $CONFIG_HEADERS
- CONFIG_LINKS = $CONFIG_LINKS
- CONFIG_COMMANDS = $CONFIG_COMMANDS
- $ $0 $@
-
-_CSEOF
-echo "on `(hostname || uname -n) 2>/dev/null | sed 1q`" >&5
-echo >&5
-_ACEOF
-
-# Files that config.status was made for.
-if test -n "$ac_config_files"; then
- echo "config_files=\"$ac_config_files\"" >>$CONFIG_STATUS
-fi
-
-if test -n "$ac_config_headers"; then
- echo "config_headers=\"$ac_config_headers\"" >>$CONFIG_STATUS
-fi
-
-if test -n "$ac_config_links"; then
- echo "config_links=\"$ac_config_links\"" >>$CONFIG_STATUS
-fi
-
-if test -n "$ac_config_commands"; then
- echo "config_commands=\"$ac_config_commands\"" >>$CONFIG_STATUS
-fi
-
-cat >>$CONFIG_STATUS <<\_ACEOF
-
-ac_cs_usage="\
-\`$as_me' instantiates files from templates according to the
-current configuration.
-
-Usage: $0 [OPTIONS] [FILE]...
-
- -h, --help print this help, then exit
- -V, --version print version number, then exit
- -q, --quiet do not print progress messages
- -d, --debug don't remove temporary files
- --recheck update $as_me by reconfiguring in the same conditions
- --file=FILE[:TEMPLATE]
- instantiate the configuration file FILE
- --header=FILE[:TEMPLATE]
- instantiate the configuration header FILE
-
-Configuration files:
-$config_files
-
-Configuration headers:
-$config_headers
-
-Configuration commands:
-$config_commands
-
-Report bugs to <bug-autoconf@gnu.org>."
-_ACEOF
-
-cat >>$CONFIG_STATUS <<_ACEOF
-ac_cs_version="\\
-librdmacm config.status 1.0.11
-configured by $0, generated by GNU Autoconf 2.59,
- with options \\"`echo "$ac_configure_args" | sed 's/[\\""\`\$]/\\\\&/g'`\\"
-
-Copyright (C) 2003 Free Software Foundation, Inc.
-This config.status script is free software; the Free Software Foundation
-gives unlimited permission to copy, distribute and modify it."
-srcdir=$srcdir
-INSTALL="$INSTALL"
-_ACEOF
-
-cat >>$CONFIG_STATUS <<\_ACEOF
-# If no file are specified by the user, then we need to provide default
-# value. By we need to know if files were specified by the user.
-ac_need_defaults=:
-while test $# != 0
-do
- case $1 in
- --*=*)
- ac_option=`expr "x$1" : 'x\([^=]*\)='`
- ac_optarg=`expr "x$1" : 'x[^=]*=\(.*\)'`
- ac_shift=:
- ;;
- -*)
- ac_option=$1
- ac_optarg=$2
- ac_shift=shift
- ;;
- *) # This is not an option, so the user has probably given explicit
- # arguments.
- ac_option=$1
- ac_need_defaults=false;;
- esac
-
- case $ac_option in
- # Handling of the options.
-_ACEOF
-cat >>$CONFIG_STATUS <<\_ACEOF
- -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r)
- ac_cs_recheck=: ;;
- --version | --vers* | -V )
- echo "$ac_cs_version"; exit 0 ;;
- --he | --h)
- # Conflict between --help and --header
- { { echo "$as_me:$LINENO: error: ambiguous option: $1
-Try \`$0 --help' for more information." >&5
-echo "$as_me: error: ambiguous option: $1
-Try \`$0 --help' for more information." >&2;}
- { (exit 1); exit 1; }; };;
- --help | --hel | -h )
- echo "$ac_cs_usage"; exit 0 ;;
- --debug | --d* | -d )
- debug=: ;;
- --file | --fil | --fi | --f )
- $ac_shift
- CONFIG_FILES="$CONFIG_FILES $ac_optarg"
- ac_need_defaults=false;;
- --header | --heade | --head | --hea )
- $ac_shift
- CONFIG_HEADERS="$CONFIG_HEADERS $ac_optarg"
- ac_need_defaults=false;;
- -q | -quiet | --quiet | --quie | --qui | --qu | --q \
- | -silent | --silent | --silen | --sile | --sil | --si | --s)
- ac_cs_silent=: ;;
-
- # This is an error.
- -*) { { echo "$as_me:$LINENO: error: unrecognized option: $1
-Try \`$0 --help' for more information." >&5
-echo "$as_me: error: unrecognized option: $1
-Try \`$0 --help' for more information." >&2;}
- { (exit 1); exit 1; }; } ;;
-
- *) ac_config_targets="$ac_config_targets $1" ;;
-
- esac
- shift
-done
-
-ac_configure_extra_args=
-
-if $ac_cs_silent; then
- exec 6>/dev/null
- ac_configure_extra_args="$ac_configure_extra_args --silent"
-fi
-
-_ACEOF
-cat >>$CONFIG_STATUS <<_ACEOF
-if \$ac_cs_recheck; then
- echo "running $SHELL $0 " $ac_configure_args \$ac_configure_extra_args " --no-create --no-recursion" >&6
- exec $SHELL $0 $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion
-fi
-
-_ACEOF
-
-cat >>$CONFIG_STATUS <<_ACEOF
-#
-# INIT-COMMANDS section.
-#
-
-AMDEP_TRUE="$AMDEP_TRUE" ac_aux_dir="$ac_aux_dir"
-
-_ACEOF
-
-
-
-cat >>$CONFIG_STATUS <<\_ACEOF
-for ac_config_target in $ac_config_targets
-do
- case "$ac_config_target" in
- # Handling of arguments.
- "Makefile" ) CONFIG_FILES="$CONFIG_FILES Makefile" ;;
- "librdmacm.spec" ) CONFIG_FILES="$CONFIG_FILES librdmacm.spec" ;;
- "depfiles" ) CONFIG_COMMANDS="$CONFIG_COMMANDS depfiles" ;;
- "config.h" ) CONFIG_HEADERS="$CONFIG_HEADERS config.h" ;;
- *) { { echo "$as_me:$LINENO: error: invalid argument: $ac_config_target" >&5
-echo "$as_me: error: invalid argument: $ac_config_target" >&2;}
- { (exit 1); exit 1; }; };;
- esac
-done
-
-# If the user did not use the arguments to specify the items to instantiate,
-# then the envvar interface is used. Set only those that are not.
-# We use the long form for the default assignment because of an extremely
-# bizarre bug on SunOS 4.1.3.
-if $ac_need_defaults; then
- test "${CONFIG_FILES+set}" = set || CONFIG_FILES=$config_files
- test "${CONFIG_HEADERS+set}" = set || CONFIG_HEADERS=$config_headers
- test "${CONFIG_COMMANDS+set}" = set || CONFIG_COMMANDS=$config_commands
-fi
-
-# Have a temporary directory for convenience. Make it in the build tree
-# simply because there is no reason to put it here, and in addition,
-# creating and moving files from /tmp can sometimes cause problems.
-# Create a temporary directory, and hook for its removal unless debugging.
-$debug ||
-{
- trap 'exit_status=$?; rm -rf $tmp && exit $exit_status' 0
- trap '{ (exit 1); exit 1; }' 1 2 13 15
-}
-
-# Create a (secure) tmp directory for tmp files.
-
-{
- tmp=`(umask 077 && mktemp -d -q "./confstatXXXXXX") 2>/dev/null` &&
- test -n "$tmp" && test -d "$tmp"
-} ||
-{
- tmp=./confstat$$-$RANDOM
- (umask 077 && mkdir $tmp)
-} ||
-{
- echo "$me: cannot create a temporary directory in ." >&2
- { (exit 1); exit 1; }
-}
-
-_ACEOF
-
-cat >>$CONFIG_STATUS <<_ACEOF
-
-#
-# CONFIG_FILES section.
-#
-
-# No need to generate the scripts if there are no CONFIG_FILES.
-# This happens for instance when ./config.status config.h
-if test -n "\$CONFIG_FILES"; then
- # Protect against being on the right side of a sed subst in config.status.
- sed 's/,@/@@/; s/@,/@@/; s/,;t t\$/@;t t/; /@;t t\$/s/[\\\\&,]/\\\\&/g;
- s/@@/,@/; s/@@/@,/; s/@;t t\$/,;t t/' >\$tmp/subs.sed <<\\CEOF
-s,@SHELL@,$SHELL,;t t
-s,@PATH_SEPARATOR@,$PATH_SEPARATOR,;t t
-s,@PACKAGE_NAME@,$PACKAGE_NAME,;t t
-s,@PACKAGE_TARNAME@,$PACKAGE_TARNAME,;t t
-s,@PACKAGE_VERSION@,$PACKAGE_VERSION,;t t
-s,@PACKAGE_STRING@,$PACKAGE_STRING,;t t
-s,@PACKAGE_BUGREPORT@,$PACKAGE_BUGREPORT,;t t
-s,@exec_prefix@,$exec_prefix,;t t
-s,@prefix@,$prefix,;t t
-s,@program_transform_name@,$program_transform_name,;t t
-s,@bindir@,$bindir,;t t
-s,@sbindir@,$sbindir,;t t
-s,@libexecdir@,$libexecdir,;t t
-s,@datadir@,$datadir,;t t
-s,@sysconfdir@,$sysconfdir,;t t
-s,@sharedstatedir@,$sharedstatedir,;t t
-s,@localstatedir@,$localstatedir,;t t
-s,@libdir@,$libdir,;t t
-s,@includedir@,$includedir,;t t
-s,@oldincludedir@,$oldincludedir,;t t
-s,@infodir@,$infodir,;t t
-s,@mandir@,$mandir,;t t
-s,@build_alias@,$build_alias,;t t
-s,@host_alias@,$host_alias,;t t
-s,@target_alias@,$target_alias,;t t
-s,@DEFS@,$DEFS,;t t
-s,@ECHO_C@,$ECHO_C,;t t
-s,@ECHO_N@,$ECHO_N,;t t
-s,@ECHO_T@,$ECHO_T,;t t
-s,@LIBS@,$LIBS,;t t
-s,@INSTALL_PROGRAM@,$INSTALL_PROGRAM,;t t
-s,@INSTALL_SCRIPT@,$INSTALL_SCRIPT,;t t
-s,@INSTALL_DATA@,$INSTALL_DATA,;t t
-s,@CYGPATH_W@,$CYGPATH_W,;t t
-s,@PACKAGE@,$PACKAGE,;t t
-s,@VERSION@,$VERSION,;t t
-s,@ACLOCAL@,$ACLOCAL,;t t
-s,@AUTOCONF@,$AUTOCONF,;t t
-s,@AUTOMAKE@,$AUTOMAKE,;t t
-s,@AUTOHEADER@,$AUTOHEADER,;t t
-s,@MAKEINFO@,$MAKEINFO,;t t
-s,@install_sh@,$install_sh,;t t
-s,@STRIP@,$STRIP,;t t
-s,@ac_ct_STRIP@,$ac_ct_STRIP,;t t
-s,@INSTALL_STRIP_PROGRAM@,$INSTALL_STRIP_PROGRAM,;t t
-s,@mkdir_p@,$mkdir_p,;t t
-s,@AWK@,$AWK,;t t
-s,@SET_MAKE@,$SET_MAKE,;t t
-s,@am__leading_dot@,$am__leading_dot,;t t
-s,@AMTAR@,$AMTAR,;t t
-s,@am__tar@,$am__tar,;t t
-s,@am__untar@,$am__untar,;t t
-s,@build@,$build,;t t
-s,@build_cpu@,$build_cpu,;t t
-s,@build_vendor@,$build_vendor,;t t
-s,@build_os@,$build_os,;t t
-s,@host@,$host,;t t
-s,@host_cpu@,$host_cpu,;t t
-s,@host_vendor@,$host_vendor,;t t
-s,@host_os@,$host_os,;t t
-s,@CC@,$CC,;t t
-s,@CFLAGS@,$CFLAGS,;t t
-s,@LDFLAGS@,$LDFLAGS,;t t
-s,@CPPFLAGS@,$CPPFLAGS,;t t
-s,@ac_ct_CC@,$ac_ct_CC,;t t
-s,@EXEEXT@,$EXEEXT,;t t
-s,@OBJEXT@,$OBJEXT,;t t
-s,@DEPDIR@,$DEPDIR,;t t
-s,@am__include@,$am__include,;t t
-s,@am__quote@,$am__quote,;t t
-s,@AMDEP_TRUE@,$AMDEP_TRUE,;t t
-s,@AMDEP_FALSE@,$AMDEP_FALSE,;t t
-s,@AMDEPBACKSLASH@,$AMDEPBACKSLASH,;t t
-s,@CCDEPMODE@,$CCDEPMODE,;t t
-s,@am__fastdepCC_TRUE@,$am__fastdepCC_TRUE,;t t
-s,@am__fastdepCC_FALSE@,$am__fastdepCC_FALSE,;t t
-s,@EGREP@,$EGREP,;t t
-s,@LN_S@,$LN_S,;t t
-s,@ECHO@,$ECHO,;t t
-s,@AR@,$AR,;t t
-s,@ac_ct_AR@,$ac_ct_AR,;t t
-s,@RANLIB@,$RANLIB,;t t
-s,@ac_ct_RANLIB@,$ac_ct_RANLIB,;t t
-s,@CPP@,$CPP,;t t
-s,@CXX@,$CXX,;t t
-s,@CXXFLAGS@,$CXXFLAGS,;t t
-s,@ac_ct_CXX@,$ac_ct_CXX,;t t
-s,@CXXDEPMODE@,$CXXDEPMODE,;t t
-s,@am__fastdepCXX_TRUE@,$am__fastdepCXX_TRUE,;t t
-s,@am__fastdepCXX_FALSE@,$am__fastdepCXX_FALSE,;t t
-s,@CXXCPP@,$CXXCPP,;t t
-s,@F77@,$F77,;t t
-s,@FFLAGS@,$FFLAGS,;t t
-s,@ac_ct_F77@,$ac_ct_F77,;t t
-s,@LIBTOOL@,$LIBTOOL,;t t
-s,@HAVE_LD_VERSION_SCRIPT_TRUE@,$HAVE_LD_VERSION_SCRIPT_TRUE,;t t
-s,@HAVE_LD_VERSION_SCRIPT_FALSE@,$HAVE_LD_VERSION_SCRIPT_FALSE,;t t
-s,@LIBOBJS@,$LIBOBJS,;t t
-s,@LTLIBOBJS@,$LTLIBOBJS,;t t
-CEOF
-
-_ACEOF
-
- cat >>$CONFIG_STATUS <<\_ACEOF
- # Split the substitutions into bite-sized pieces for seds with
- # small command number limits, like on Digital OSF/1 and HP-UX.
- ac_max_sed_lines=48
- ac_sed_frag=1 # Number of current file.
- ac_beg=1 # First line for current file.
- ac_end=$ac_max_sed_lines # Line after last line for current file.
- ac_more_lines=:
- ac_sed_cmds=
- while $ac_more_lines; do
- if test $ac_beg -gt 1; then
- sed "1,${ac_beg}d; ${ac_end}q" $tmp/subs.sed >$tmp/subs.frag
- else
- sed "${ac_end}q" $tmp/subs.sed >$tmp/subs.frag
- fi
- if test ! -s $tmp/subs.frag; then
- ac_more_lines=false
- else
- # The purpose of the label and of the branching condition is to
- # speed up the sed processing (if there are no `@' at all, there
- # is no need to browse any of the substitutions).
- # These are the two extra sed commands mentioned above.
- (echo ':t
- /@[a-zA-Z_][a-zA-Z_0-9]*@/!b' && cat $tmp/subs.frag) >$tmp/subs-$ac_sed_frag.sed
- if test -z "$ac_sed_cmds"; then
- ac_sed_cmds="sed -f $tmp/subs-$ac_sed_frag.sed"
- else
- ac_sed_cmds="$ac_sed_cmds | sed -f $tmp/subs-$ac_sed_frag.sed"
- fi
- ac_sed_frag=`expr $ac_sed_frag + 1`
- ac_beg=$ac_end
- ac_end=`expr $ac_end + $ac_max_sed_lines`
- fi
- done
- if test -z "$ac_sed_cmds"; then
- ac_sed_cmds=cat
- fi
-fi # test -n "$CONFIG_FILES"
-
-_ACEOF
-cat >>$CONFIG_STATUS <<\_ACEOF
-for ac_file in : $CONFIG_FILES; do test "x$ac_file" = x: && continue
- # Support "outfile[:infile[:infile...]]", defaulting infile="outfile.in".
- case $ac_file in
- - | *:- | *:-:* ) # input from stdin
- cat >$tmp/stdin
- ac_file_in=`echo "$ac_file" | sed 's,[^:]*:,,'`
- ac_file=`echo "$ac_file" | sed 's,:.*,,'` ;;
- *:* ) ac_file_in=`echo "$ac_file" | sed 's,[^:]*:,,'`
- ac_file=`echo "$ac_file" | sed 's,:.*,,'` ;;
- * ) ac_file_in=$ac_file.in ;;
- esac
-
- # Compute @srcdir@, @top_srcdir@, and @INSTALL@ for subdirectories.
- ac_dir=`(dirname "$ac_file") 2>/dev/null ||
-$as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
- X"$ac_file" : 'X\(//\)[^/]' \| \
- X"$ac_file" : 'X\(//\)$' \| \
- X"$ac_file" : 'X\(/\)' \| \
- . : '\(.\)' 2>/dev/null ||
-echo X"$ac_file" |
- sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; }
- /^X\(\/\/\)[^/].*/{ s//\1/; q; }
- /^X\(\/\/\)$/{ s//\1/; q; }
- /^X\(\/\).*/{ s//\1/; q; }
- s/.*/./; q'`
- { if $as_mkdir_p; then
- mkdir -p "$ac_dir"
- else
- as_dir="$ac_dir"
- as_dirs=
- while test ! -d "$as_dir"; do
- as_dirs="$as_dir $as_dirs"
- as_dir=`(dirname "$as_dir") 2>/dev/null ||
-$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
- X"$as_dir" : 'X\(//\)[^/]' \| \
- X"$as_dir" : 'X\(//\)$' \| \
- X"$as_dir" : 'X\(/\)' \| \
- . : '\(.\)' 2>/dev/null ||
-echo X"$as_dir" |
- sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; }
- /^X\(\/\/\)[^/].*/{ s//\1/; q; }
- /^X\(\/\/\)$/{ s//\1/; q; }
- /^X\(\/\).*/{ s//\1/; q; }
- s/.*/./; q'`
- done
- test ! -n "$as_dirs" || mkdir $as_dirs
- fi || { { echo "$as_me:$LINENO: error: cannot create directory \"$ac_dir\"" >&5
-echo "$as_me: error: cannot create directory \"$ac_dir\"" >&2;}
- { (exit 1); exit 1; }; }; }
-
- ac_builddir=.
-
-if test "$ac_dir" != .; then
- ac_dir_suffix=/`echo "$ac_dir" | sed 's,^\.[\\/],,'`
- # A "../" for each directory in $ac_dir_suffix.
- ac_top_builddir=`echo "$ac_dir_suffix" | sed 's,/[^\\/]*,../,g'`
-else
- ac_dir_suffix= ac_top_builddir=
-fi
-
-case $srcdir in
- .) # No --srcdir option. We are building in place.
- ac_srcdir=.
- if test -z "$ac_top_builddir"; then
- ac_top_srcdir=.
- else
- ac_top_srcdir=`echo $ac_top_builddir | sed 's,/$,,'`
- fi ;;
- [\\/]* | ?:[\\/]* ) # Absolute path.
- ac_srcdir=$srcdir$ac_dir_suffix;
- ac_top_srcdir=$srcdir ;;
- *) # Relative path.
- ac_srcdir=$ac_top_builddir$srcdir$ac_dir_suffix
- ac_top_srcdir=$ac_top_builddir$srcdir ;;
-esac
-
-# Do not use `cd foo && pwd` to compute absolute paths, because
-# the directories may not exist.
-case `pwd` in
-.) ac_abs_builddir="$ac_dir";;
-*)
- case "$ac_dir" in
- .) ac_abs_builddir=`pwd`;;
- [\\/]* | ?:[\\/]* ) ac_abs_builddir="$ac_dir";;
- *) ac_abs_builddir=`pwd`/"$ac_dir";;
- esac;;
-esac
-case $ac_abs_builddir in
-.) ac_abs_top_builddir=${ac_top_builddir}.;;
-*)
- case ${ac_top_builddir}. in
- .) ac_abs_top_builddir=$ac_abs_builddir;;
- [\\/]* | ?:[\\/]* ) ac_abs_top_builddir=${ac_top_builddir}.;;
- *) ac_abs_top_builddir=$ac_abs_builddir/${ac_top_builddir}.;;
- esac;;
-esac
-case $ac_abs_builddir in
-.) ac_abs_srcdir=$ac_srcdir;;
-*)
- case $ac_srcdir in
- .) ac_abs_srcdir=$ac_abs_builddir;;
- [\\/]* | ?:[\\/]* ) ac_abs_srcdir=$ac_srcdir;;
- *) ac_abs_srcdir=$ac_abs_builddir/$ac_srcdir;;
- esac;;
-esac
-case $ac_abs_builddir in
-.) ac_abs_top_srcdir=$ac_top_srcdir;;
-*)
- case $ac_top_srcdir in
- .) ac_abs_top_srcdir=$ac_abs_builddir;;
- [\\/]* | ?:[\\/]* ) ac_abs_top_srcdir=$ac_top_srcdir;;
- *) ac_abs_top_srcdir=$ac_abs_builddir/$ac_top_srcdir;;
- esac;;
-esac
-
-
- case $INSTALL in
- [\\/$]* | ?:[\\/]* ) ac_INSTALL=$INSTALL ;;
- *) ac_INSTALL=$ac_top_builddir$INSTALL ;;
- esac
-
- # Let's still pretend it is `configure' which instantiates (i.e., don't
- # use $as_me), people would be surprised to read:
- # /* config.h. Generated by config.status. */
- if test x"$ac_file" = x-; then
- configure_input=
- else
- configure_input="$ac_file. "
- fi
- configure_input=$configure_input"Generated from `echo $ac_file_in |
- sed 's,.*/,,'` by configure."
-
- # First look for the input files in the build tree, otherwise in the
- # src tree.
- ac_file_inputs=`IFS=:
- for f in $ac_file_in; do
- case $f in
- -) echo $tmp/stdin ;;
- [\\/$]*)
- # Absolute (can't be DOS-style, as IFS=:)
- test -f "$f" || { { echo "$as_me:$LINENO: error: cannot find input file: $f" >&5
-echo "$as_me: error: cannot find input file: $f" >&2;}
- { (exit 1); exit 1; }; }
- echo "$f";;
- *) # Relative
- if test -f "$f"; then
- # Build tree
- echo "$f"
- elif test -f "$srcdir/$f"; then
- # Source tree
- echo "$srcdir/$f"
- else
- # /dev/null tree
- { { echo "$as_me:$LINENO: error: cannot find input file: $f" >&5
-echo "$as_me: error: cannot find input file: $f" >&2;}
- { (exit 1); exit 1; }; }
- fi;;
- esac
- done` || { (exit 1); exit 1; }
-
- if test x"$ac_file" != x-; then
- { echo "$as_me:$LINENO: creating $ac_file" >&5
-echo "$as_me: creating $ac_file" >&6;}
- rm -f "$ac_file"
- fi
-_ACEOF
-cat >>$CONFIG_STATUS <<_ACEOF
- sed "$ac_vpsub
-$extrasub
-_ACEOF
-cat >>$CONFIG_STATUS <<\_ACEOF
-:t
-/@[a-zA-Z_][a-zA-Z_0-9]*@/!b
-s,@configure_input@,$configure_input,;t t
-s,@srcdir@,$ac_srcdir,;t t
-s,@abs_srcdir@,$ac_abs_srcdir,;t t
-s,@top_srcdir@,$ac_top_srcdir,;t t
-s,@abs_top_srcdir@,$ac_abs_top_srcdir,;t t
-s,@builddir@,$ac_builddir,;t t
-s,@abs_builddir@,$ac_abs_builddir,;t t
-s,@top_builddir@,$ac_top_builddir,;t t
-s,@abs_top_builddir@,$ac_abs_top_builddir,;t t
-s,@INSTALL@,$ac_INSTALL,;t t
-" $ac_file_inputs | (eval "$ac_sed_cmds") >$tmp/out
- rm -f $tmp/stdin
- if test x"$ac_file" != x-; then
- mv $tmp/out $ac_file
- else
- cat $tmp/out
- rm -f $tmp/out
- fi
-
-done
-_ACEOF
-cat >>$CONFIG_STATUS <<\_ACEOF
-
-#
-# CONFIG_HEADER section.
-#
-
-# These sed commands are passed to sed as "A NAME B NAME C VALUE D", where
-# NAME is the cpp macro being defined and VALUE is the value it is being given.
-#
-# ac_d sets the value in "#define NAME VALUE" lines.
-ac_dA='s,^\([ ]*\)#\([ ]*define[ ][ ]*\)'
-ac_dB='[ ].*$,\1#\2'
-ac_dC=' '
-ac_dD=',;t'
-# ac_u turns "#undef NAME" without trailing blanks into "#define NAME VALUE".
-ac_uA='s,^\([ ]*\)#\([ ]*\)undef\([ ][ ]*\)'
-ac_uB='$,\1#\2define\3'
-ac_uC=' '
-ac_uD=',;t'
-
-for ac_file in : $CONFIG_HEADERS; do test "x$ac_file" = x: && continue
- # Support "outfile[:infile[:infile...]]", defaulting infile="outfile.in".
- case $ac_file in
- - | *:- | *:-:* ) # input from stdin
- cat >$tmp/stdin
- ac_file_in=`echo "$ac_file" | sed 's,[^:]*:,,'`
- ac_file=`echo "$ac_file" | sed 's,:.*,,'` ;;
- *:* ) ac_file_in=`echo "$ac_file" | sed 's,[^:]*:,,'`
- ac_file=`echo "$ac_file" | sed 's,:.*,,'` ;;
- * ) ac_file_in=$ac_file.in ;;
- esac
-
- test x"$ac_file" != x- && { echo "$as_me:$LINENO: creating $ac_file" >&5
-echo "$as_me: creating $ac_file" >&6;}
-
- # First look for the input files in the build tree, otherwise in the
- # src tree.
- ac_file_inputs=`IFS=:
- for f in $ac_file_in; do
- case $f in
- -) echo $tmp/stdin ;;
- [\\/$]*)
- # Absolute (can't be DOS-style, as IFS=:)
- test -f "$f" || { { echo "$as_me:$LINENO: error: cannot find input file: $f" >&5
-echo "$as_me: error: cannot find input file: $f" >&2;}
- { (exit 1); exit 1; }; }
- # Do quote $f, to prevent DOS paths from being IFS'd.
- echo "$f";;
- *) # Relative
- if test -f "$f"; then
- # Build tree
- echo "$f"
- elif test -f "$srcdir/$f"; then
- # Source tree
- echo "$srcdir/$f"
- else
- # /dev/null tree
- { { echo "$as_me:$LINENO: error: cannot find input file: $f" >&5
-echo "$as_me: error: cannot find input file: $f" >&2;}
- { (exit 1); exit 1; }; }
- fi;;
- esac
- done` || { (exit 1); exit 1; }
- # Remove the trailing spaces.
- sed 's/[ ]*$//' $ac_file_inputs >$tmp/in
-
-_ACEOF
-
-# Transform confdefs.h into two sed scripts, `conftest.defines' and
-# `conftest.undefs', that substitutes the proper values into
-# config.h.in to produce config.h. The first handles `#define'
-# templates, and the second `#undef' templates.
-# And first: Protect against being on the right side of a sed subst in
-# config.status. Protect against being in an unquoted here document
-# in config.status.
-rm -f conftest.defines conftest.undefs
-# Using a here document instead of a string reduces the quoting nightmare.
-# Putting comments in sed scripts is not portable.
-#
-# `end' is used to avoid that the second main sed command (meant for
-# 0-ary CPP macros) applies to n-ary macro definitions.
-# See the Autoconf documentation for `clear'.
-cat >confdef2sed.sed <<\_ACEOF
-s/[\\&,]/\\&/g
-s,[\\$`],\\&,g
-t clear
-: clear
-s,^[ ]*#[ ]*define[ ][ ]*\([^ (][^ (]*\)\(([^)]*)\)[ ]*\(.*\)$,${ac_dA}\1${ac_dB}\1\2${ac_dC}\3${ac_dD},gp
-t end
-s,^[ ]*#[ ]*define[ ][ ]*\([^ ][^ ]*\)[ ]*\(.*\)$,${ac_dA}\1${ac_dB}\1${ac_dC}\2${ac_dD},gp
-: end
-_ACEOF
-# If some macros were called several times there might be several times
-# the same #defines, which is useless. Nevertheless, we may not want to
-# sort them, since we want the *last* AC-DEFINE to be honored.
-uniq confdefs.h | sed -n -f confdef2sed.sed >conftest.defines
-sed 's/ac_d/ac_u/g' conftest.defines >conftest.undefs
-rm -f confdef2sed.sed
-
-# This sed command replaces #undef with comments. This is necessary, for
-# example, in the case of _POSIX_SOURCE, which is predefined and required
-# on some systems where configure will not decide to define it.
-cat >>conftest.undefs <<\_ACEOF
-s,^[ ]*#[ ]*undef[ ][ ]*[a-zA-Z_][a-zA-Z_0-9]*,/* & */,
-_ACEOF
-
-# Break up conftest.defines because some shells have a limit on the size
-# of here documents, and old seds have small limits too (100 cmds).
-echo ' # Handle all the #define templates only if necessary.' >>$CONFIG_STATUS
-echo ' if grep "^[ ]*#[ ]*define" $tmp/in >/dev/null; then' >>$CONFIG_STATUS
-echo ' # If there are no defines, we may have an empty if/fi' >>$CONFIG_STATUS
-echo ' :' >>$CONFIG_STATUS
-rm -f conftest.tail
-while grep . conftest.defines >/dev/null
-do
- # Write a limited-size here document to $tmp/defines.sed.
- echo ' cat >$tmp/defines.sed <<CEOF' >>$CONFIG_STATUS
- # Speed up: don't consider the non `#define' lines.
- echo '/^[ ]*#[ ]*define/!b' >>$CONFIG_STATUS
- # Work around the forget-to-reset-the-flag bug.
- echo 't clr' >>$CONFIG_STATUS
- echo ': clr' >>$CONFIG_STATUS
- sed ${ac_max_here_lines}q conftest.defines >>$CONFIG_STATUS
- echo 'CEOF
- sed -f $tmp/defines.sed $tmp/in >$tmp/out
- rm -f $tmp/in
- mv $tmp/out $tmp/in
-' >>$CONFIG_STATUS
- sed 1,${ac_max_here_lines}d conftest.defines >conftest.tail
- rm -f conftest.defines
- mv conftest.tail conftest.defines
-done
-rm -f conftest.defines
-echo ' fi # grep' >>$CONFIG_STATUS
-echo >>$CONFIG_STATUS
-
-# Break up conftest.undefs because some shells have a limit on the size
-# of here documents, and old seds have small limits too (100 cmds).
-echo ' # Handle all the #undef templates' >>$CONFIG_STATUS
-rm -f conftest.tail
-while grep . conftest.undefs >/dev/null
-do
- # Write a limited-size here document to $tmp/undefs.sed.
- echo ' cat >$tmp/undefs.sed <<CEOF' >>$CONFIG_STATUS
- # Speed up: don't consider the non `#undef'
- echo '/^[ ]*#[ ]*undef/!b' >>$CONFIG_STATUS
- # Work around the forget-to-reset-the-flag bug.
- echo 't clr' >>$CONFIG_STATUS
- echo ': clr' >>$CONFIG_STATUS
- sed ${ac_max_here_lines}q conftest.undefs >>$CONFIG_STATUS
- echo 'CEOF
- sed -f $tmp/undefs.sed $tmp/in >$tmp/out
- rm -f $tmp/in
- mv $tmp/out $tmp/in
-' >>$CONFIG_STATUS
- sed 1,${ac_max_here_lines}d conftest.undefs >conftest.tail
- rm -f conftest.undefs
- mv conftest.tail conftest.undefs
-done
-rm -f conftest.undefs
-
-cat >>$CONFIG_STATUS <<\_ACEOF
- # Let's still pretend it is `configure' which instantiates (i.e., don't
- # use $as_me), people would be surprised to read:
- # /* config.h. Generated by config.status. */
- if test x"$ac_file" = x-; then
- echo "/* Generated by configure. */" >$tmp/config.h
- else
- echo "/* $ac_file. Generated by configure. */" >$tmp/config.h
- fi
- cat $tmp/in >>$tmp/config.h
- rm -f $tmp/in
- if test x"$ac_file" != x-; then
- if diff $ac_file $tmp/config.h >/dev/null 2>&1; then
- { echo "$as_me:$LINENO: $ac_file is unchanged" >&5
-echo "$as_me: $ac_file is unchanged" >&6;}
- else
- ac_dir=`(dirname "$ac_file") 2>/dev/null ||
-$as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
- X"$ac_file" : 'X\(//\)[^/]' \| \
- X"$ac_file" : 'X\(//\)$' \| \
- X"$ac_file" : 'X\(/\)' \| \
- . : '\(.\)' 2>/dev/null ||
-echo X"$ac_file" |
- sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; }
- /^X\(\/\/\)[^/].*/{ s//\1/; q; }
- /^X\(\/\/\)$/{ s//\1/; q; }
- /^X\(\/\).*/{ s//\1/; q; }
- s/.*/./; q'`
- { if $as_mkdir_p; then
- mkdir -p "$ac_dir"
- else
- as_dir="$ac_dir"
- as_dirs=
- while test ! -d "$as_dir"; do
- as_dirs="$as_dir $as_dirs"
- as_dir=`(dirname "$as_dir") 2>/dev/null ||
-$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
- X"$as_dir" : 'X\(//\)[^/]' \| \
- X"$as_dir" : 'X\(//\)$' \| \
- X"$as_dir" : 'X\(/\)' \| \
- . : '\(.\)' 2>/dev/null ||
-echo X"$as_dir" |
- sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; }
- /^X\(\/\/\)[^/].*/{ s//\1/; q; }
- /^X\(\/\/\)$/{ s//\1/; q; }
- /^X\(\/\).*/{ s//\1/; q; }
- s/.*/./; q'`
- done
- test ! -n "$as_dirs" || mkdir $as_dirs
- fi || { { echo "$as_me:$LINENO: error: cannot create directory \"$ac_dir\"" >&5
-echo "$as_me: error: cannot create directory \"$ac_dir\"" >&2;}
- { (exit 1); exit 1; }; }; }
-
- rm -f $ac_file
- mv $tmp/config.h $ac_file
- fi
- else
- cat $tmp/config.h
- rm -f $tmp/config.h
- fi
-# Compute $ac_file's index in $config_headers.
-_am_stamp_count=1
-for _am_header in $config_headers :; do
- case $_am_header in
- $ac_file | $ac_file:* )
- break ;;
- * )
- _am_stamp_count=`expr $_am_stamp_count + 1` ;;
- esac
-done
-echo "timestamp for $ac_file" >`(dirname $ac_file) 2>/dev/null ||
-$as_expr X$ac_file : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
- X$ac_file : 'X\(//\)[^/]' \| \
- X$ac_file : 'X\(//\)$' \| \
- X$ac_file : 'X\(/\)' \| \
- . : '\(.\)' 2>/dev/null ||
-echo X$ac_file |
- sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; }
- /^X\(\/\/\)[^/].*/{ s//\1/; q; }
- /^X\(\/\/\)$/{ s//\1/; q; }
- /^X\(\/\).*/{ s//\1/; q; }
- s/.*/./; q'`/stamp-h$_am_stamp_count
-done
-_ACEOF
-cat >>$CONFIG_STATUS <<\_ACEOF
-
-#
-# CONFIG_COMMANDS section.
-#
-for ac_file in : $CONFIG_COMMANDS; do test "x$ac_file" = x: && continue
- ac_dest=`echo "$ac_file" | sed 's,:.*,,'`
- ac_source=`echo "$ac_file" | sed 's,[^:]*:,,'`
- ac_dir=`(dirname "$ac_dest") 2>/dev/null ||
-$as_expr X"$ac_dest" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
- X"$ac_dest" : 'X\(//\)[^/]' \| \
- X"$ac_dest" : 'X\(//\)$' \| \
- X"$ac_dest" : 'X\(/\)' \| \
- . : '\(.\)' 2>/dev/null ||
-echo X"$ac_dest" |
- sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; }
- /^X\(\/\/\)[^/].*/{ s//\1/; q; }
- /^X\(\/\/\)$/{ s//\1/; q; }
- /^X\(\/\).*/{ s//\1/; q; }
- s/.*/./; q'`
- { if $as_mkdir_p; then
- mkdir -p "$ac_dir"
- else
- as_dir="$ac_dir"
- as_dirs=
- while test ! -d "$as_dir"; do
- as_dirs="$as_dir $as_dirs"
- as_dir=`(dirname "$as_dir") 2>/dev/null ||
-$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
- X"$as_dir" : 'X\(//\)[^/]' \| \
- X"$as_dir" : 'X\(//\)$' \| \
- X"$as_dir" : 'X\(/\)' \| \
- . : '\(.\)' 2>/dev/null ||
-echo X"$as_dir" |
- sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; }
- /^X\(\/\/\)[^/].*/{ s//\1/; q; }
- /^X\(\/\/\)$/{ s//\1/; q; }
- /^X\(\/\).*/{ s//\1/; q; }
- s/.*/./; q'`
- done
- test ! -n "$as_dirs" || mkdir $as_dirs
- fi || { { echo "$as_me:$LINENO: error: cannot create directory \"$ac_dir\"" >&5
-echo "$as_me: error: cannot create directory \"$ac_dir\"" >&2;}
- { (exit 1); exit 1; }; }; }
-
- ac_builddir=.
-
-if test "$ac_dir" != .; then
- ac_dir_suffix=/`echo "$ac_dir" | sed 's,^\.[\\/],,'`
- # A "../" for each directory in $ac_dir_suffix.
- ac_top_builddir=`echo "$ac_dir_suffix" | sed 's,/[^\\/]*,../,g'`
-else
- ac_dir_suffix= ac_top_builddir=
-fi
-
-case $srcdir in
- .) # No --srcdir option. We are building in place.
- ac_srcdir=.
- if test -z "$ac_top_builddir"; then
- ac_top_srcdir=.
- else
- ac_top_srcdir=`echo $ac_top_builddir | sed 's,/$,,'`
- fi ;;
- [\\/]* | ?:[\\/]* ) # Absolute path.
- ac_srcdir=$srcdir$ac_dir_suffix;
- ac_top_srcdir=$srcdir ;;
- *) # Relative path.
- ac_srcdir=$ac_top_builddir$srcdir$ac_dir_suffix
- ac_top_srcdir=$ac_top_builddir$srcdir ;;
-esac
-
-# Do not use `cd foo && pwd` to compute absolute paths, because
-# the directories may not exist.
-case `pwd` in
-.) ac_abs_builddir="$ac_dir";;
-*)
- case "$ac_dir" in
- .) ac_abs_builddir=`pwd`;;
- [\\/]* | ?:[\\/]* ) ac_abs_builddir="$ac_dir";;
- *) ac_abs_builddir=`pwd`/"$ac_dir";;
- esac;;
-esac
-case $ac_abs_builddir in
-.) ac_abs_top_builddir=${ac_top_builddir}.;;
-*)
- case ${ac_top_builddir}. in
- .) ac_abs_top_builddir=$ac_abs_builddir;;
- [\\/]* | ?:[\\/]* ) ac_abs_top_builddir=${ac_top_builddir}.;;
- *) ac_abs_top_builddir=$ac_abs_builddir/${ac_top_builddir}.;;
- esac;;
-esac
-case $ac_abs_builddir in
-.) ac_abs_srcdir=$ac_srcdir;;
-*)
- case $ac_srcdir in
- .) ac_abs_srcdir=$ac_abs_builddir;;
- [\\/]* | ?:[\\/]* ) ac_abs_srcdir=$ac_srcdir;;
- *) ac_abs_srcdir=$ac_abs_builddir/$ac_srcdir;;
- esac;;
-esac
-case $ac_abs_builddir in
-.) ac_abs_top_srcdir=$ac_top_srcdir;;
-*)
- case $ac_top_srcdir in
- .) ac_abs_top_srcdir=$ac_abs_builddir;;
- [\\/]* | ?:[\\/]* ) ac_abs_top_srcdir=$ac_top_srcdir;;
- *) ac_abs_top_srcdir=$ac_abs_builddir/$ac_top_srcdir;;
- esac;;
-esac
-
-
- { echo "$as_me:$LINENO: executing $ac_dest commands" >&5
-echo "$as_me: executing $ac_dest commands" >&6;}
- case $ac_dest in
- depfiles ) test x"$AMDEP_TRUE" != x"" || for mf in $CONFIG_FILES; do
- # Strip MF so we end up with the name of the file.
- mf=`echo "$mf" | sed -e 's/:.*$//'`
- # Check whether this is an Automake generated Makefile or not.
- # We used to match only the files named `Makefile.in', but
- # some people rename them; so instead we look at the file content.
- # Grep'ing the first line is not enough: some people post-process
- # each Makefile.in and add a new line on top of each file to say so.
- # So let's grep whole file.
- if grep '^#.*generated by automake' $mf > /dev/null 2>&1; then
- dirpart=`(dirname "$mf") 2>/dev/null ||
-$as_expr X"$mf" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
- X"$mf" : 'X\(//\)[^/]' \| \
- X"$mf" : 'X\(//\)$' \| \
- X"$mf" : 'X\(/\)' \| \
- . : '\(.\)' 2>/dev/null ||
-echo X"$mf" |
- sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; }
- /^X\(\/\/\)[^/].*/{ s//\1/; q; }
- /^X\(\/\/\)$/{ s//\1/; q; }
- /^X\(\/\).*/{ s//\1/; q; }
- s/.*/./; q'`
- else
- continue
- fi
- # Extract the definition of DEPDIR, am__include, and am__quote
- # from the Makefile without running `make'.
- DEPDIR=`sed -n 's/^DEPDIR = //p' < "$mf"`
- test -z "$DEPDIR" && continue
- am__include=`sed -n 's/^am__include = //p' < "$mf"`
- test -z "am__include" && continue
- am__quote=`sed -n 's/^am__quote = //p' < "$mf"`
- # When using ansi2knr, U may be empty or an underscore; expand it
- U=`sed -n 's/^U = //p' < "$mf"`
- # Find all dependency output files, they are included files with
- # $(DEPDIR) in their names. We invoke sed twice because it is the
- # simplest approach to changing $(DEPDIR) to its actual value in the
- # expansion.
- for file in `sed -n "
- s/^$am__include $am__quote\(.*(DEPDIR).*\)$am__quote"'$/\1/p' <"$mf" | \
- sed -e 's/\$(DEPDIR)/'"$DEPDIR"'/g' -e 's/\$U/'"$U"'/g'`; do
- # Make sure the directory exists.
- test -f "$dirpart/$file" && continue
- fdir=`(dirname "$file") 2>/dev/null ||
-$as_expr X"$file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
- X"$file" : 'X\(//\)[^/]' \| \
- X"$file" : 'X\(//\)$' \| \
- X"$file" : 'X\(/\)' \| \
- . : '\(.\)' 2>/dev/null ||
-echo X"$file" |
- sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; }
- /^X\(\/\/\)[^/].*/{ s//\1/; q; }
- /^X\(\/\/\)$/{ s//\1/; q; }
- /^X\(\/\).*/{ s//\1/; q; }
- s/.*/./; q'`
- { if $as_mkdir_p; then
- mkdir -p $dirpart/$fdir
- else
- as_dir=$dirpart/$fdir
- as_dirs=
- while test ! -d "$as_dir"; do
- as_dirs="$as_dir $as_dirs"
- as_dir=`(dirname "$as_dir") 2>/dev/null ||
-$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
- X"$as_dir" : 'X\(//\)[^/]' \| \
- X"$as_dir" : 'X\(//\)$' \| \
- X"$as_dir" : 'X\(/\)' \| \
- . : '\(.\)' 2>/dev/null ||
-echo X"$as_dir" |
- sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; }
- /^X\(\/\/\)[^/].*/{ s//\1/; q; }
- /^X\(\/\/\)$/{ s//\1/; q; }
- /^X\(\/\).*/{ s//\1/; q; }
- s/.*/./; q'`
- done
- test ! -n "$as_dirs" || mkdir $as_dirs
- fi || { { echo "$as_me:$LINENO: error: cannot create directory $dirpart/$fdir" >&5
-echo "$as_me: error: cannot create directory $dirpart/$fdir" >&2;}
- { (exit 1); exit 1; }; }; }
-
- # echo "creating $dirpart/$file"
- echo '# dummy' > "$dirpart/$file"
- done
-done
- ;;
- esac
-done
-_ACEOF
-
-cat >>$CONFIG_STATUS <<\_ACEOF
-
-{ (exit 0); exit 0; }
-_ACEOF
-chmod +x $CONFIG_STATUS
-ac_clean_files=$ac_clean_files_save
-
-
-# configure is writing to config.log, and then calls config.status.
-# config.status does its own redirection, appending to config.log.
-# Unfortunately, on DOS this fails, as config.log is still kept open
-# by configure, so config.status won't be able to write to it; its
-# output is simply discarded. So we exec the FD to /dev/null,
-# effectively closing config.log, so it can be properly (re)opened and
-# appended to by config.status. When coming back to configure, we
-# need to make the FD available again.
-if test "$no_create" != yes; then
- ac_cs_success=:
- ac_config_status_args=
- test "$silent" = yes &&
- ac_config_status_args="$ac_config_status_args --quiet"
- exec 5>/dev/null
- $SHELL $CONFIG_STATUS $ac_config_status_args || ac_cs_success=false
- exec 5>>config.log
- # Use ||, not &&, to avoid exiting from the if with $? = 1, which
- # would make configure fail if this is the last instruction.
- $ac_cs_success || { (exit 1); exit 1; }
-fi
-
diff --git a/contrib/ofed/librdmacm/configure.in b/contrib/ofed/librdmacm/configure.in
deleted file mode 100644
index 1122966..0000000
--- a/contrib/ofed/librdmacm/configure.in
+++ /dev/null
@@ -1,66 +0,0 @@
-dnl Process this file with autoconf to produce a configure script.
-
-AC_PREREQ(2.57)
-AC_INIT(librdmacm, 1.0.11, general@lists.openfabrics.org)
-AC_CONFIG_SRCDIR([src/cma.c])
-AC_CONFIG_AUX_DIR(config)
-AM_CONFIG_HEADER(config.h)
-AM_INIT_AUTOMAKE(librdmacm, 1.0.11)
-
-AM_PROG_LIBTOOL
-
-AC_ARG_WITH([valgrind],
- AC_HELP_STRING([--with-valgrind],
- [Enable valgrind annotations - default NO]))
-
-if test "$with_valgrind" != "" && test "$with_valgrind" != "no"; then
- AC_DEFINE([INCLUDE_VALGRIND], 1,
- [Define to 1 to enable valgrind annotations])
- if test -d $with_valgrind; then
- CPPFLAGS="$CPPLFAGS -I$with_valgrind/include"
- fi
-fi
-
-AC_ARG_ENABLE(libcheck, [ --disable-libcheck do not test for presence of ib libraries],
-[ if test "$enableval" = "no"; then
- disable_libcheck=yes
- fi
-])
-
-dnl Checks for programs
-AC_PROG_CC
-
-dnl Checks for typedefs, structures, and compiler characteristics.
-AC_C_CONST
-AC_CHECK_SIZEOF(long)
-
-dnl Checks for libraries
-if test "$disable_libcheck" != "yes"; then
-AC_CHECK_LIB(ibverbs, ibv_get_device_list, [],
- AC_MSG_ERROR([ibv_get_device_list() not found. librdmacm requires libibverbs.]))
-fi
-
-dnl Checks for header files.
-AC_HEADER_STDC
-if test "$disable_libcheck" != "yes"; then
-AC_CHECK_HEADER(infiniband/verbs.h, [],
- AC_MSG_ERROR([<infiniband/verbs.h> not found. Is libibverbs installed?]))
-
-if test "$with_valgrind" != "" && test "$with_valgrind" != "no"; then
-AC_CHECK_HEADER(valgrind/memcheck.h, [],
- AC_MSG_ERROR([valgrind requested but <valgrind/memcheck.h> not found.]))
-fi
-
-fi
-
-AC_CACHE_CHECK(whether ld accepts --version-script, ac_cv_version_script,
- if test -n "`$LD --help < /dev/null 2>/dev/null | grep version-script`"; then
- ac_cv_version_script=yes
- else
- ac_cv_version_script=no
- fi)
-
-AM_CONDITIONAL(HAVE_LD_VERSION_SCRIPT, test "$ac_cv_version_script" = "yes")
-
-AC_CONFIG_FILES([Makefile librdmacm.spec])
-AC_OUTPUT
diff --git a/contrib/ofed/librdmacm/examples/build/Makefile b/contrib/ofed/librdmacm/examples/build/Makefile
index c949c05..c45d40e 100644
--- a/contrib/ofed/librdmacm/examples/build/Makefile
+++ b/contrib/ofed/librdmacm/examples/build/Makefile
@@ -1,3 +1,7 @@
-SUBDIR= cmatose mckey rping udaddy
+# $FreeBSD$
+
+SUBDIR= ucmatose mckey rping udaddy
+
+SUBDIR_PARALLEL=
.include <bsd.subdir.mk>
diff --git a/contrib/ofed/librdmacm/examples/build/Makefile.inc b/contrib/ofed/librdmacm/examples/build/Makefile.inc
index dbf7696..43b972b 100644
--- a/contrib/ofed/librdmacm/examples/build/Makefile.inc
+++ b/contrib/ofed/librdmacm/examples/build/Makefile.inc
@@ -1,11 +1,3 @@
-BINDIR?= /usr/bin
-
-IBDIR=../../../..
-
-CFLAGS+= \
- -I${IBDIR}/include/infiniband \
- -I${IBDIR}/include \
- -I${IBDIR}/librdmacm/include \
- -I${IBDIR}/libibv/include \
- -I${IBDIR}/libibverbs/include
-
+BINDIR?= /usr/bin
+CFLAGS+= -I${.CURDIR}/../../..
+LDFLAGS+= -libverbs -lrdmacm -lmlx4 -lmlx5 -lcxgb4 -lpthread
diff --git a/contrib/ofed/librdmacm/examples/build/cmatose/Makefile b/contrib/ofed/librdmacm/examples/build/cmatose/Makefile
deleted file mode 100644
index e2baf40..0000000
--- a/contrib/ofed/librdmacm/examples/build/cmatose/Makefile
+++ /dev/null
@@ -1,10 +0,0 @@
-#
-# $FreeBSD$
-#
-.PATH: ${.CURDIR}/../..
-PROG= cmatose
-MAN=
-SRCS= cmatose.c
-LIBADD= ibverbs rdmacm pthread mlx4
-
-.include <bsd.prog.mk>
diff --git a/contrib/ofed/librdmacm/examples/build/mckey/Makefile b/contrib/ofed/librdmacm/examples/build/mckey/Makefile
index 6ef498f..17f3b57 100644
--- a/contrib/ofed/librdmacm/examples/build/mckey/Makefile
+++ b/contrib/ofed/librdmacm/examples/build/mckey/Makefile
@@ -1,10 +1,9 @@
-#
# $FreeBSD$
-#
-.PATH: ${.CURDIR}/../..
+
+.PATH: ${.CURDIR}/../.. ${.CURDIR}/../../../man
+
PROG= mckey
-MAN=
+MAN= mckey.1
SRCS= mckey.c
-LIBADD= ibverbs rdmacm pthread mlx4
.include <bsd.prog.mk>
diff --git a/contrib/ofed/librdmacm/examples/build/rping/Makefile b/contrib/ofed/librdmacm/examples/build/rping/Makefile
index ee2efbd..93f608c 100644
--- a/contrib/ofed/librdmacm/examples/build/rping/Makefile
+++ b/contrib/ofed/librdmacm/examples/build/rping/Makefile
@@ -1,12 +1,9 @@
-#
# $FreeBSD$
-#
-.PATH: ${.CURDIR}/../..
+
+.PATH: ${.CURDIR}/../.. ${.CURDIR}/../../../man
+
PROG= rping
-MAN=
-SRCS= rping.c
-LIBADD+= ibverbs rdmacm pthread
-LIBADD+= mlx4
-LIBADD+= cxgb4
+MAN= rping.1
+SRCS= rping.c common.c
.include <bsd.prog.mk>
diff --git a/contrib/ofed/librdmacm/examples/build/ucmatose/Makefile b/contrib/ofed/librdmacm/examples/build/ucmatose/Makefile
new file mode 100644
index 0000000..22a88fa
--- /dev/null
+++ b/contrib/ofed/librdmacm/examples/build/ucmatose/Makefile
@@ -0,0 +1,9 @@
+# $FreeBSD$
+
+.PATH: ${.CURDIR}/../.. ${.CURDIR}/../../../man
+
+PROG= ucmatose
+MAN= ucmatose.1
+SRCS= cmatose.c common.c
+
+.include <bsd.prog.mk>
diff --git a/contrib/ofed/librdmacm/examples/build/udaddy/Makefile b/contrib/ofed/librdmacm/examples/build/udaddy/Makefile
index fc76534..8bb39c1 100644
--- a/contrib/ofed/librdmacm/examples/build/udaddy/Makefile
+++ b/contrib/ofed/librdmacm/examples/build/udaddy/Makefile
@@ -1,10 +1,9 @@
-#
# $FreeBSD$
-#
-.PATH: ${.CURDIR}/../..
+
+.PATH: ${.CURDIR}/../.. ${.CURDIR}/../../../man
+
PROG= udaddy
-MAN=
-SRCS= udaddy.c
-LIBADD= ibverbs rdmacm pthread mlx4
+MAN= udaddy.1
+SRCS= udaddy.c common.c
.include <bsd.prog.mk>
diff --git a/contrib/ofed/librdmacm/examples/cmatose.c b/contrib/ofed/librdmacm/examples/cmatose.c
index 84831ec..b1c9dd1 100644
--- a/contrib/ofed/librdmacm/examples/cmatose.c
+++ b/contrib/ofed/librdmacm/examples/cmatose.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2005-2006 Intel Corporation. All rights reserved.
+ * Copyright (c) 2005-2006,2011-2012 Intel Corporation. All rights reserved.
*
* This software is available to you under a choice of one of two
* licenses. You may choose to be licensed under the terms of the GNU
@@ -37,21 +37,12 @@
#include <stdio.h>
#include <errno.h>
#include <sys/types.h>
-#include <netinet/in.h>
#include <sys/socket.h>
#include <netdb.h>
-#include <byteswap.h>
#include <getopt.h>
#include <rdma/rdma_cma.h>
-
-#if __BYTE_ORDER == __BIG_ENDIAN
-static inline uint64_t cpu_to_be64(uint64_t x) { return x; }
-static inline uint32_t cpu_to_be32(uint32_t x) { return x; }
-#else
-static inline uint64_t cpu_to_be64(uint64_t x) { return bswap_64(x); }
-static inline uint32_t cpu_to_be32(uint32_t x) { return bswap_32(x); }
-#endif
+#include "common.h"
struct cmatest_node {
int id;
@@ -75,19 +66,20 @@ struct cmatest {
int connects_left;
int disconnects_left;
- struct rdma_addr addr;
+ struct rdma_addrinfo *rai;
};
static struct cmatest test;
static int connections = 1;
static int message_size = 100;
static int message_count = 10;
-static uint16_t port = 7471;
+static const char *port = "7471";
static uint8_t set_tos = 0;
static uint8_t tos;
static uint8_t migrate = 0;
static char *dst_addr;
static char *src_addr;
+static struct rdma_addrinfo hints;
static int create_message(struct cmatest_node *node)
{
@@ -127,8 +119,8 @@ static int init_node(struct cmatest_node *node)
}
cqe = message_count ? message_count : 1;
- node->cq[SEND_CQ_INDEX] = ibv_create_cq(node->cma_id->verbs, cqe, node, 0, 0);
- node->cq[RECV_CQ_INDEX] = ibv_create_cq(node->cma_id->verbs, cqe, node, 0, 0);
+ node->cq[SEND_CQ_INDEX] = ibv_create_cq(node->cma_id->verbs, cqe, node, NULL, 0);
+ node->cq[RECV_CQ_INDEX] = ibv_create_cq(node->cma_id->verbs, cqe, node, NULL, 0);
if (!node->cq[SEND_CQ_INDEX] || !node->cq[RECV_CQ_INDEX]) {
ret = -ENOMEM;
printf("cmatose: unable to create CQ\n");
@@ -218,7 +210,6 @@ static int post_sends(struct cmatest_node *node)
static void connect_error(void)
{
- test.disconnects_left--;
test.connects_left--;
}
@@ -258,6 +249,8 @@ static int route_handler(struct cmatest_node *node)
conn_param.responder_resources = 1;
conn_param.initiator_depth = 1;
conn_param.retry_count = 5;
+ conn_param.private_data = test.rai->ai_connect;
+ conn_param.private_data_len = test.rai->ai_connect_len;
ret = rdma_connect(node->cma_id, &conn_param);
if (ret) {
perror("cmatose: failure connecting");
@@ -272,7 +265,6 @@ err:
static int connect_handler(struct rdma_cm_id *cma_id)
{
struct cmatest_node *node;
- struct rdma_conn_param conn_param;
int ret;
if (test.conn_index == connections) {
@@ -292,10 +284,7 @@ static int connect_handler(struct rdma_cm_id *cma_id)
if (ret)
goto err2;
- memset(&conn_param, 0, sizeof conn_param);
- conn_param.responder_resources = 1;
- conn_param.initiator_depth = 1;
- ret = rdma_accept(node->cma_id, &conn_param);
+ ret = rdma_accept(node->cma_id, NULL);
if (ret) {
perror("cmatose: failure accepting");
goto err2;
@@ -328,6 +317,7 @@ static int cma_handler(struct rdma_cm_id *cma_id, struct rdma_cm_event *event)
case RDMA_CM_EVENT_ESTABLISHED:
((struct cmatest_node *) cma_id->context)->connected = 1;
test.connects_left--;
+ test.disconnects_left++;
break;
case RDMA_CM_EVENT_ADDR_ERROR:
case RDMA_CM_EVENT_ROUTE_ERROR:
@@ -337,6 +327,7 @@ static int cma_handler(struct rdma_cm_id *cma_id, struct rdma_cm_event *event)
printf("cmatose: event: %s, error: %d\n",
rdma_event_str(event->event), event->status);
connect_error();
+ ret = event->status;
break;
case RDMA_CM_EVENT_DISCONNECTED:
rdma_disconnect(cma_id);
@@ -393,7 +384,7 @@ static int alloc_nodes(void)
if (dst_addr) {
ret = rdma_create_id(test.channel,
&test.nodes[i].cma_id,
- &test.nodes[i], RDMA_PS_TCP);
+ &test.nodes[i], hints.ai_port_space);
if (ret)
goto err;
}
@@ -438,12 +429,12 @@ static int poll_cqs(enum CQ_INDEX index)
static int connect_events(void)
{
struct rdma_cm_event *event;
- int err = 0, ret = 0;
+ int ret = 0;
- while (test.connects_left && !err) {
- err = rdma_get_cm_event(test.channel, &event);
- if (!err) {
- cma_handler(event->id, event);
+ while (test.connects_left && !ret) {
+ ret = rdma_get_cm_event(test.channel, &event);
+ if (!ret) {
+ ret = cma_handler(event->id, event);
rdma_ack_cm_event(event);
} else {
perror("cmatose: failure in rdma_get_cm_event in connect events");
@@ -457,12 +448,12 @@ static int connect_events(void)
static int disconnect_events(void)
{
struct rdma_cm_event *event;
- int err = 0, ret = 0;
+ int ret = 0;
- while (test.disconnects_left && !err) {
- err = rdma_get_cm_event(test.channel, &event);
- if (!err) {
- cma_handler(event->id, event);
+ while (test.disconnects_left && !ret) {
+ ret = rdma_get_cm_event(test.channel, &event);
+ if (!ret) {
+ ret = cma_handler(event->id, event);
rdma_ack_cm_event(event);
} else {
perror("cmatose: failure in rdma_get_cm_event in disconnect events");
@@ -502,56 +493,25 @@ static int migrate_channel(struct rdma_cm_id *listen_id)
return ret;
}
-static int get_addr(char *dst, struct sockaddr *addr)
-{
- struct addrinfo *res;
- int ret;
-
- ret = getaddrinfo(dst, NULL, NULL, &res);
- if (ret) {
- printf("getaddrinfo failed - invalid hostname or IP address\n");
- return ret;
- }
-
- if (res->ai_family == PF_INET)
- memcpy(addr, res->ai_addr, sizeof(struct sockaddr_in));
- else if (res->ai_family == PF_INET6)
- memcpy(addr, res->ai_addr, sizeof(struct sockaddr_in6));
- else
- ret = -1;
-
- freeaddrinfo(res);
- return ret;
-}
-
static int run_server(void)
{
struct rdma_cm_id *listen_id;
int i, ret;
printf("cmatose: starting server\n");
- ret = rdma_create_id(test.channel, &listen_id, &test, RDMA_PS_TCP);
+ ret = rdma_create_id(test.channel, &listen_id, &test, hints.ai_port_space);
if (ret) {
perror("cmatose: listen request failed");
return ret;
}
- if (src_addr) {
- ret = get_addr(src_addr, &test.addr.src_addr);
- if (ret)
- goto out;
- if (test.addr.src_addr.sa_family == AF_INET)
- ((struct sockaddr_in *) &test.addr.src_addr)->sin_port = port;
- else
- ((struct sockaddr_in6 *) &test.addr.src_addr)->sin6_port = port;
-
- } else {
- test.addr.src_addr.sa_family = PF_INET;
- ((struct sockaddr_in *) &test.addr.src_addr)->sin_port = port;
+ ret = get_rdma_addr(src_addr, dst_addr, port, &hints, &test.rai);
+ if (ret) {
+ printf("cmatose: getrdmaaddr error: %s\n", gai_strerror(ret));
+ goto out;
}
- ret = rdma_bind_addr(listen_id, &test.addr.src_addr);
-
+ ret = rdma_bind_addr(listen_id, test.rai->ai_src_addr);
if (ret) {
perror("cmatose: bind address failed");
goto out;
@@ -617,26 +577,17 @@ static int run_client(void)
int i, ret, ret2;
printf("cmatose: starting client\n");
- if (src_addr) {
- ret = get_addr(src_addr, &test.addr.src_addr);
- if (ret)
- return ret;
- }
- ret = get_addr(dst_addr, &test.addr.dst_addr);
- if (ret)
+ ret = get_rdma_addr(src_addr, dst_addr, port, &hints, &test.rai);
+ if (ret) {
+ printf("cmatose: getaddrinfo error: %s\n", gai_strerror(ret));
return ret;
-
- if (test.addr.dst_addr.sa_family == AF_INET)
- ((struct sockaddr_in *) &test.addr.dst_addr)->sin_port = port;
- else
- ((struct sockaddr_in6 *) &test.addr.dst_addr)->sin6_port = port;
+ }
printf("cmatose: connecting\n");
for (i = 0; i < connections; i++) {
- ret = rdma_resolve_addr(test.nodes[i].cma_id,
- src_addr ? &test.addr.src_addr : NULL,
- &test.addr.dst_addr, 2000);
+ ret = rdma_resolve_addr(test.nodes[i].cma_id, test.rai->ai_src_addr,
+ test.rai->ai_dst_addr, 2000);
if (ret) {
perror("cmatose: failure getting addr");
connect_error();
@@ -683,7 +634,8 @@ int main(int argc, char **argv)
{
int op, ret;
- while ((op = getopt(argc, argv, "s:b:c:C:S:t:p:m")) != -1) {
+ hints.ai_port_space = RDMA_PS_TCP;
+ while ((op = getopt(argc, argv, "s:b:f:P:c:C:S:t:p:m")) != -1) {
switch (op) {
case 's':
dst_addr = optarg;
@@ -691,6 +643,23 @@ int main(int argc, char **argv)
case 'b':
src_addr = optarg;
break;
+ case 'f':
+ if (!strncasecmp("ip", optarg, 2)) {
+ hints.ai_flags = RAI_NUMERICHOST;
+ } else if (!strncasecmp("gid", optarg, 3)) {
+ hints.ai_flags = RAI_NUMERICHOST | RAI_FAMILY;
+ hints.ai_family = AF_IB;
+ } else if (strncasecmp("name", optarg, 4)) {
+ fprintf(stderr, "Warning: unknown address format\n");
+ }
+ break;
+ case 'P':
+ if (!strncasecmp("ib", optarg, 2)) {
+ hints.ai_port_space = RDMA_PS_IB;
+ } else if (strncasecmp("tcp", optarg, 3)) {
+ fprintf(stderr, "Warning: unknown port space format\n");
+ }
+ break;
case 'c':
connections = atoi(optarg);
break;
@@ -702,10 +671,10 @@ int main(int argc, char **argv)
break;
case 't':
set_tos = 1;
- tos = (uint8_t) atoi(optarg);
+ tos = (uint8_t) strtoul(optarg, NULL, 0);
break;
case 'p':
- port = atoi(optarg);
+ port = optarg;
break;
case 'm':
migrate = 1;
@@ -714,6 +683,10 @@ int main(int argc, char **argv)
printf("usage: %s\n", argv[0]);
printf("\t[-s server_address]\n");
printf("\t[-b bind_address]\n");
+ printf("\t[-f address_format]\n");
+ printf("\t name, ip, ipv6, or gid\n");
+ printf("\t[-P port_space]\n");
+ printf("\t tcp or ib\n");
printf("\t[-c connections]\n");
printf("\t[-C message_count]\n");
printf("\t[-S message_size]\n");
@@ -725,7 +698,6 @@ int main(int argc, char **argv)
}
test.connects_left = connections;
- test.disconnects_left = connections;
test.channel = rdma_create_event_channel();
if (!test.channel) {
@@ -736,14 +708,18 @@ int main(int argc, char **argv)
if (alloc_nodes())
exit(1);
- if (dst_addr)
+ if (dst_addr) {
ret = run_client();
- else
+ } else {
+ hints.ai_flags |= RAI_PASSIVE;
ret = run_server();
+ }
printf("test complete\n");
destroy_nodes();
rdma_destroy_event_channel(test.channel);
+ if (test.rai)
+ rdma_freeaddrinfo(test.rai);
printf("return status %d\n", ret);
return ret;
diff --git a/contrib/ofed/librdmacm/examples/cmtime.c b/contrib/ofed/librdmacm/examples/cmtime.c
new file mode 100644
index 0000000..aa96b90
--- /dev/null
+++ b/contrib/ofed/librdmacm/examples/cmtime.c
@@ -0,0 +1,677 @@
+/*
+ * Copyright (c) 2013 Intel Corporation. All rights reserved.
+ *
+ * This software is available to you under the OpenIB.org BSD license
+ * below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AWV
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <strings.h>
+#include <errno.h>
+#include <getopt.h>
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <sys/time.h>
+#include <sys/wait.h>
+#include <netdb.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <netinet/tcp.h>
+
+#include <rdma/rdma_cma.h>
+#include "common.h"
+
+static struct rdma_addrinfo hints, *rai;
+static struct rdma_event_channel *channel;
+static const char *port = "7471";
+static char *dst_addr;
+static char *src_addr;
+static int timeout = 2000;
+static int retries = 2;
+
+enum step {
+ STEP_CREATE_ID,
+ STEP_BIND,
+ STEP_RESOLVE_ADDR,
+ STEP_RESOLVE_ROUTE,
+ STEP_CREATE_QP,
+ STEP_CONNECT,
+ STEP_DISCONNECT,
+ STEP_DESTROY,
+ STEP_CNT
+};
+
+static const char *step_str[] = {
+ "create id",
+ "bind addr",
+ "resolve addr",
+ "resolve route",
+ "create qp",
+ "connect",
+ "disconnect",
+ "destroy"
+};
+
+struct node {
+ struct rdma_cm_id *id;
+ struct timeval times[STEP_CNT][2];
+ int error;
+ int retries;
+};
+
+struct list_head {
+ struct list_head *prev;
+ struct list_head *next;
+ struct rdma_cm_id *id;
+};
+
+struct work_list {
+ pthread_mutex_t lock;
+ pthread_cond_t cond;
+ struct list_head list;
+};
+
+#define INIT_LIST(x) ((x)->prev = (x)->next = (x))
+
+static struct work_list req_work;
+static struct work_list disc_work;
+static struct node *nodes;
+static struct timeval times[STEP_CNT][2];
+static int connections = 100;
+static volatile int started[STEP_CNT];
+static volatile int completed[STEP_CNT];
+static struct ibv_qp_init_attr init_qp_attr;
+static struct rdma_conn_param conn_param;
+
+#define start_perf(n, s) gettimeofday(&((n)->times[s][0]), NULL)
+#define end_perf(n, s) gettimeofday(&((n)->times[s][1]), NULL)
+#define start_time(s) gettimeofday(&times[s][0], NULL)
+#define end_time(s) gettimeofday(&times[s][1], NULL)
+
+static inline void __list_delete(struct list_head *list)
+{
+ struct list_head *prev, *next;
+ prev = list->prev;
+ next = list->next;
+ prev->next = next;
+ next->prev = prev;
+ INIT_LIST(list);
+}
+
+static inline int __list_empty(struct work_list *list)
+{
+ return list->list.next == &list->list;
+}
+
+static inline struct list_head *__list_remove_head(struct work_list *work_list)
+{
+ struct list_head *list_item;
+
+ list_item = work_list->list.next;
+ __list_delete(list_item);
+ return list_item;
+}
+
+static inline void list_add_tail(struct work_list *work_list, struct list_head *req)
+{
+ int empty;
+ pthread_mutex_lock(&work_list->lock);
+ empty = __list_empty(work_list);
+ req->prev = work_list->list.prev;
+ req->next = &work_list->list;
+ req->prev->next = work_list->list.prev = req;
+ pthread_mutex_unlock(&work_list->lock);
+ if (empty)
+ pthread_cond_signal(&work_list->cond);
+}
+
+static int zero_time(struct timeval *t)
+{
+ return !(t->tv_sec || t->tv_usec);
+}
+
+static float diff_us(struct timeval *end, struct timeval *start)
+{
+ return (end->tv_sec - start->tv_sec) * 1000000. + (end->tv_usec - start->tv_usec);
+}
+
+static void show_perf(void)
+{
+ int c, i;
+ float us, max[STEP_CNT], min[STEP_CNT];
+
+ for (i = 0; i < STEP_CNT; i++) {
+ max[i] = 0;
+ min[i] = 999999999.;
+ for (c = 0; c < connections; c++) {
+ if (!zero_time(&nodes[c].times[i][0]) &&
+ !zero_time(&nodes[c].times[i][1])) {
+ us = diff_us(&nodes[c].times[i][1], &nodes[c].times[i][0]);
+ if (us > max[i])
+ max[i] = us;
+ if (us < min[i])
+ min[i] = us;
+ }
+ }
+ }
+
+ printf("step total ms max ms min us us / conn\n");
+ for (i = 0; i < STEP_CNT; i++) {
+ if (i == STEP_BIND && !src_addr)
+ continue;
+
+ us = diff_us(&times[i][1], &times[i][0]);
+ printf("%-13s: %11.2f%11.2f%11.2f%11.2f\n", step_str[i], us / 1000.,
+ max[i] / 1000., min[i], us / connections);
+ }
+}
+
+static void addr_handler(struct node *n)
+{
+ end_perf(n, STEP_RESOLVE_ADDR);
+ completed[STEP_RESOLVE_ADDR]++;
+}
+
+static void route_handler(struct node *n)
+{
+ end_perf(n, STEP_RESOLVE_ROUTE);
+ completed[STEP_RESOLVE_ROUTE]++;
+}
+
+static void conn_handler(struct node *n)
+{
+ end_perf(n, STEP_CONNECT);
+ completed[STEP_CONNECT]++;
+}
+
+static void disc_handler(struct node *n)
+{
+ end_perf(n, STEP_DISCONNECT);
+ completed[STEP_DISCONNECT]++;
+}
+
+static void __req_handler(struct rdma_cm_id *id)
+{
+ int ret;
+
+ ret = rdma_create_qp(id, NULL, &init_qp_attr);
+ if (ret) {
+ perror("failure creating qp");
+ goto err;
+ }
+
+ ret = rdma_accept(id, NULL);
+ if (ret) {
+ perror("failure accepting");
+ goto err;
+ }
+ return;
+
+err:
+ printf("failing connection request\n");
+ rdma_reject(id, NULL, 0);
+ rdma_destroy_id(id);
+ return;
+}
+
+static void *req_handler_thread(void *arg)
+{
+ struct list_head *work;
+ do {
+ pthread_mutex_lock(&req_work.lock);
+ if (__list_empty(&req_work))
+ pthread_cond_wait(&req_work.cond, &req_work.lock);
+ work = __list_remove_head(&req_work);
+ pthread_mutex_unlock(&req_work.lock);
+ __req_handler(work->id);
+ free(work);
+ } while (1);
+ return NULL;
+}
+
+static void *disc_handler_thread(void *arg)
+{
+ struct list_head *work;
+ do {
+ pthread_mutex_lock(&disc_work.lock);
+ if (__list_empty(&disc_work))
+ pthread_cond_wait(&disc_work.cond, &disc_work.lock);
+ work = __list_remove_head(&disc_work);
+ pthread_mutex_unlock(&disc_work.lock);
+ rdma_disconnect(work->id);
+ rdma_destroy_id(work->id);
+ free(work);
+ } while (1);
+ return NULL;
+}
+
+static void cma_handler(struct rdma_cm_id *id, struct rdma_cm_event *event)
+{
+ struct node *n = id->context;
+ struct list_head *request;
+
+ switch (event->event) {
+ case RDMA_CM_EVENT_ADDR_RESOLVED:
+ addr_handler(n);
+ break;
+ case RDMA_CM_EVENT_ROUTE_RESOLVED:
+ route_handler(n);
+ break;
+ case RDMA_CM_EVENT_CONNECT_REQUEST:
+ request = malloc(sizeof *request);
+ if (!request) {
+ perror("out of memory accepting connect request");
+ rdma_reject(id, NULL, 0);
+ rdma_destroy_id(id);
+ } else {
+ INIT_LIST(request);
+ request->id = id;
+ list_add_tail(&req_work, request);
+ }
+ break;
+ case RDMA_CM_EVENT_ESTABLISHED:
+ if (n)
+ conn_handler(n);
+ break;
+ case RDMA_CM_EVENT_ADDR_ERROR:
+ if (n->retries--) {
+ if (!rdma_resolve_addr(n->id, rai->ai_src_addr,
+ rai->ai_dst_addr, timeout))
+ break;
+ }
+ printf("RDMA_CM_EVENT_ADDR_ERROR, error: %d\n", event->status);
+ addr_handler(n);
+ n->error = 1;
+ break;
+ case RDMA_CM_EVENT_ROUTE_ERROR:
+ if (n->retries--) {
+ if (!rdma_resolve_route(n->id, timeout))
+ break;
+ }
+ printf("RDMA_CM_EVENT_ROUTE_ERROR, error: %d\n", event->status);
+ route_handler(n);
+ n->error = 1;
+ break;
+ case RDMA_CM_EVENT_CONNECT_ERROR:
+ case RDMA_CM_EVENT_UNREACHABLE:
+ case RDMA_CM_EVENT_REJECTED:
+ printf("event: %s, error: %d\n",
+ rdma_event_str(event->event), event->status);
+ conn_handler(n);
+ n->error = 1;
+ break;
+ case RDMA_CM_EVENT_DISCONNECTED:
+ if (!n) {
+ request = malloc(sizeof *request);
+ if (!request) {
+ perror("out of memory queueing disconnect request, handling synchronously");
+ rdma_disconnect(id);
+ rdma_destroy_id(id);
+ } else {
+ INIT_LIST(request);
+ request->id = id;
+ list_add_tail(&disc_work, request);
+ }
+ } else
+ disc_handler(n);
+ break;
+ case RDMA_CM_EVENT_DEVICE_REMOVAL:
+ /* Cleanup will occur after test completes. */
+ break;
+ default:
+ break;
+ }
+ rdma_ack_cm_event(event);
+}
+
+static int alloc_nodes(void)
+{
+ int ret, i;
+
+ nodes = calloc(sizeof *nodes, connections);
+ if (!nodes)
+ return -ENOMEM;
+
+ printf("creating id\n");
+ start_time(STEP_CREATE_ID);
+ for (i = 0; i < connections; i++) {
+ start_perf(&nodes[i], STEP_CREATE_ID);
+ if (dst_addr) {
+ ret = rdma_create_id(channel, &nodes[i].id, &nodes[i],
+ hints.ai_port_space);
+ if (ret)
+ goto err;
+ }
+ end_perf(&nodes[i], STEP_CREATE_ID);
+ }
+ end_time(STEP_CREATE_ID);
+ return 0;
+
+err:
+ while (--i >= 0)
+ rdma_destroy_id(nodes[i].id);
+ free(nodes);
+ return ret;
+}
+
+static void cleanup_nodes(void)
+{
+ int i;
+
+ printf("destroying id\n");
+ start_time(STEP_DESTROY);
+ for (i = 0; i < connections; i++) {
+ start_perf(&nodes[i], STEP_DESTROY);
+ if (nodes[i].id)
+ rdma_destroy_id(nodes[i].id);
+ end_perf(&nodes[i], STEP_DESTROY);
+ }
+ end_time(STEP_DESTROY);
+}
+
+static void *process_events(void *arg)
+{
+ struct rdma_cm_event *event;
+ int ret = 0;
+
+ while (!ret) {
+ ret = rdma_get_cm_event(channel, &event);
+ if (!ret) {
+ cma_handler(event->id, event);
+ } else {
+ perror("failure in rdma_get_cm_event in process_server_events");
+ ret = errno;
+ }
+ }
+ return NULL;
+}
+
+static int run_server(void)
+{
+ pthread_t req_thread, disc_thread;
+ struct rdma_cm_id *listen_id;
+ int ret;
+
+ INIT_LIST(&req_work.list);
+ INIT_LIST(&disc_work.list);
+ ret = pthread_mutex_init(&req_work.lock, NULL);
+ if (ret) {
+ perror("initializing mutex for req work");
+ return ret;
+ }
+
+ ret = pthread_mutex_init(&disc_work.lock, NULL);
+ if (ret) {
+ perror("initializing mutex for disc work");
+ return ret;
+ }
+
+ ret = pthread_cond_init(&req_work.cond, NULL);
+ if (ret) {
+ perror("initializing cond for req work");
+ return ret;
+ }
+
+ ret = pthread_cond_init(&disc_work.cond, NULL);
+ if (ret) {
+ perror("initializing cond for disc work");
+ return ret;
+ }
+
+ ret = pthread_create(&req_thread, NULL, req_handler_thread, NULL);
+ if (ret) {
+ perror("failed to create req handler thread");
+ return ret;
+ }
+
+ ret = pthread_create(&disc_thread, NULL, disc_handler_thread, NULL);
+ if (ret) {
+ perror("failed to create disconnect handler thread");
+ return ret;
+ }
+
+ ret = rdma_create_id(channel, &listen_id, NULL, hints.ai_port_space);
+ if (ret) {
+ perror("listen request failed");
+ return ret;
+ }
+
+ ret = get_rdma_addr(src_addr, dst_addr, port, &hints, &rai);
+ if (ret) {
+ printf("getrdmaaddr error: %s\n", gai_strerror(ret));
+ goto out;
+ }
+
+ ret = rdma_bind_addr(listen_id, rai->ai_src_addr);
+ if (ret) {
+ perror("bind address failed");
+ goto out;
+ }
+
+ ret = rdma_listen(listen_id, 0);
+ if (ret) {
+ perror("failure trying to listen");
+ goto out;
+ }
+
+ process_events(NULL);
+ out:
+ rdma_destroy_id(listen_id);
+ return ret;
+}
+
+static int run_client(void)
+{
+ pthread_t event_thread;
+ int i, ret;
+
+ ret = get_rdma_addr(src_addr, dst_addr, port, &hints, &rai);
+ if (ret) {
+ printf("getaddrinfo error: %s\n", gai_strerror(ret));
+ return ret;
+ }
+
+ conn_param.responder_resources = 1;
+ conn_param.initiator_depth = 1;
+ conn_param.retry_count = retries;
+ conn_param.private_data = rai->ai_connect;
+ conn_param.private_data_len = rai->ai_connect_len;
+
+ ret = pthread_create(&event_thread, NULL, process_events, NULL);
+ if (ret) {
+ perror("failure creating event thread");
+ return ret;
+ }
+
+ if (src_addr) {
+ printf("binding source address\n");
+ start_time(STEP_BIND);
+ for (i = 0; i < connections; i++) {
+ start_perf(&nodes[i], STEP_BIND);
+ ret = rdma_bind_addr(nodes[i].id, rai->ai_src_addr);
+ if (ret) {
+ perror("failure bind addr");
+ nodes[i].error = 1;
+ continue;
+ }
+ end_perf(&nodes[i], STEP_BIND);
+ }
+ end_time(STEP_BIND);
+ }
+
+ printf("resolving address\n");
+ start_time(STEP_RESOLVE_ADDR);
+ for (i = 0; i < connections; i++) {
+ if (nodes[i].error)
+ continue;
+ nodes[i].retries = retries;
+ start_perf(&nodes[i], STEP_RESOLVE_ADDR);
+ ret = rdma_resolve_addr(nodes[i].id, rai->ai_src_addr,
+ rai->ai_dst_addr, timeout);
+ if (ret) {
+ perror("failure getting addr");
+ nodes[i].error = 1;
+ continue;
+ }
+ started[STEP_RESOLVE_ADDR]++;
+ }
+ while (started[STEP_RESOLVE_ADDR] != completed[STEP_RESOLVE_ADDR]) sched_yield();
+ end_time(STEP_RESOLVE_ADDR);
+
+ printf("resolving route\n");
+ start_time(STEP_RESOLVE_ROUTE);
+ for (i = 0; i < connections; i++) {
+ if (nodes[i].error)
+ continue;
+ nodes[i].retries = retries;
+ start_perf(&nodes[i], STEP_RESOLVE_ROUTE);
+ ret = rdma_resolve_route(nodes[i].id, timeout);
+ if (ret) {
+ perror("failure resolving route");
+ nodes[i].error = 1;
+ continue;
+ }
+ started[STEP_RESOLVE_ROUTE]++;
+ }
+ while (started[STEP_RESOLVE_ROUTE] != completed[STEP_RESOLVE_ROUTE]) sched_yield();
+ end_time(STEP_RESOLVE_ROUTE);
+
+ printf("creating qp\n");
+ start_time(STEP_CREATE_QP);
+ for (i = 0; i < connections; i++) {
+ if (nodes[i].error)
+ continue;
+ start_perf(&nodes[i], STEP_CREATE_QP);
+ ret = rdma_create_qp(nodes[i].id, NULL, &init_qp_attr);
+ if (ret) {
+ perror("failure creating qp");
+ nodes[i].error = 1;
+ continue;
+ }
+ end_perf(&nodes[i], STEP_CREATE_QP);
+ }
+ end_time(STEP_CREATE_QP);
+
+ printf("connecting\n");
+ start_time(STEP_CONNECT);
+ for (i = 0; i < connections; i++) {
+ if (nodes[i].error)
+ continue;
+ start_perf(&nodes[i], STEP_CONNECT);
+ ret = rdma_connect(nodes[i].id, &conn_param);
+ if (ret) {
+ perror("failure rconnecting");
+ nodes[i].error = 1;
+ continue;
+ }
+ started[STEP_CONNECT]++;
+ }
+ while (started[STEP_CONNECT] != completed[STEP_CONNECT]) sched_yield();
+ end_time(STEP_CONNECT);
+
+ printf("disconnecting\n");
+ start_time(STEP_DISCONNECT);
+ for (i = 0; i < connections; i++) {
+ if (nodes[i].error)
+ continue;
+ start_perf(&nodes[i], STEP_DISCONNECT);
+ rdma_disconnect(nodes[i].id);
+ started[STEP_DISCONNECT]++;
+ }
+ while (started[STEP_DISCONNECT] != completed[STEP_DISCONNECT]) sched_yield();
+ end_time(STEP_DISCONNECT);
+
+ return ret;
+}
+
+int main(int argc, char **argv)
+{
+ int op, ret;
+
+ hints.ai_port_space = RDMA_PS_TCP;
+ hints.ai_qp_type = IBV_QPT_RC;
+ while ((op = getopt(argc, argv, "s:b:c:p:r:t:")) != -1) {
+ switch (op) {
+ case 's':
+ dst_addr = optarg;
+ break;
+ case 'b':
+ src_addr = optarg;
+ break;
+ case 'c':
+ connections = atoi(optarg);
+ break;
+ case 'p':
+ port = optarg;
+ break;
+ case 'r':
+ retries = atoi(optarg);
+ break;
+ case 't':
+ timeout = atoi(optarg);
+ break;
+ default:
+ printf("usage: %s\n", argv[0]);
+ printf("\t[-s server_address]\n");
+ printf("\t[-b bind_address]\n");
+ printf("\t[-c connections]\n");
+ printf("\t[-p port_number]\n");
+ printf("\t[-r retries]\n");
+ printf("\t[-t timeout_ms]\n");
+ exit(1);
+ }
+ }
+
+ init_qp_attr.cap.max_send_wr = 1;
+ init_qp_attr.cap.max_recv_wr = 1;
+ init_qp_attr.cap.max_send_sge = 1;
+ init_qp_attr.cap.max_recv_sge = 1;
+ init_qp_attr.qp_type = IBV_QPT_RC;
+
+ channel = rdma_create_event_channel();
+ if (!channel) {
+ printf("failed to create event channel\n");
+ exit(1);
+ }
+
+ if (dst_addr) {
+ alloc_nodes();
+ ret = run_client();
+ } else {
+ hints.ai_flags |= RAI_PASSIVE;
+ ret = run_server();
+ }
+
+ cleanup_nodes();
+ rdma_destroy_event_channel(channel);
+ if (rai)
+ rdma_freeaddrinfo(rai);
+
+ show_perf();
+ free(nodes);
+ return ret;
+}
diff --git a/contrib/ofed/librdmacm/examples/common.c b/contrib/ofed/librdmacm/examples/common.c
new file mode 100644
index 0000000..f4e9421
--- /dev/null
+++ b/contrib/ofed/librdmacm/examples/common.c
@@ -0,0 +1,167 @@
+/*
+ * Copyright (c) 2005-2006,2012 Intel Corporation. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ * $Id$
+ */
+
+#include <stdlib.h>
+#include <string.h>
+#include <stdio.h>
+#include <errno.h>
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <netdb.h>
+
+#include <rdma/rdma_cma.h>
+#include "common.h"
+
+int use_rs = 1;
+
+int get_rdma_addr(const char *src, const char *dst, const char *port,
+ struct rdma_addrinfo *hints, struct rdma_addrinfo **rai)
+{
+ struct rdma_addrinfo rai_hints, *res;
+ int ret;
+
+ if (hints->ai_flags & RAI_PASSIVE)
+ return rdma_getaddrinfo(src, port, hints, rai);
+
+ rai_hints = *hints;
+ if (src) {
+ rai_hints.ai_flags |= RAI_PASSIVE;
+ ret = rdma_getaddrinfo(src, NULL, &rai_hints, &res);
+ if (ret)
+ return ret;
+
+ rai_hints.ai_src_addr = res->ai_src_addr;
+ rai_hints.ai_src_len = res->ai_src_len;
+ rai_hints.ai_flags &= ~RAI_PASSIVE;
+ }
+
+ ret = rdma_getaddrinfo(dst, port, &rai_hints, rai);
+ if (src)
+ rdma_freeaddrinfo(res);
+
+ return ret;
+}
+
+void size_str(char *str, size_t ssize, long long size)
+{
+ long long base, fraction = 0;
+ char mag;
+
+ if (size >= (1 << 30)) {
+ base = 1 << 30;
+ mag = 'g';
+ } else if (size >= (1 << 20)) {
+ base = 1 << 20;
+ mag = 'm';
+ } else if (size >= (1 << 10)) {
+ base = 1 << 10;
+ mag = 'k';
+ } else {
+ base = 1;
+ mag = '\0';
+ }
+
+ if (size / base < 10)
+ fraction = (size % base) * 10 / base;
+ if (fraction) {
+ snprintf(str, ssize, "%lld.%lld%c", size / base, fraction, mag);
+ } else {
+ snprintf(str, ssize, "%lld%c", size / base, mag);
+ }
+}
+
+void cnt_str(char *str, size_t ssize, long long cnt)
+{
+ if (cnt >= 1000000000)
+ snprintf(str, ssize, "%lldb", cnt / 1000000000);
+ else if (cnt >= 1000000)
+ snprintf(str, ssize, "%lldm", cnt / 1000000);
+ else if (cnt >= 1000)
+ snprintf(str, ssize, "%lldk", cnt / 1000);
+ else
+ snprintf(str, ssize, "%lld", cnt);
+}
+
+int size_to_count(int size)
+{
+ if (size >= (1 << 20))
+ return 100;
+ else if (size >= (1 << 16))
+ return 1000;
+ else if (size >= (1 << 10))
+ return 10000;
+ else
+ return 100000;
+}
+
+void format_buf(void *buf, int size)
+{
+ uint8_t *array = buf;
+ static uint8_t data;
+ int i;
+
+ for (i = 0; i < size; i++)
+ array[i] = data++;
+}
+
+int verify_buf(void *buf, int size)
+{
+ static long long total_bytes;
+ uint8_t *array = buf;
+ static uint8_t data;
+ int i;
+
+ for (i = 0; i < size; i++, total_bytes++) {
+ if (array[i] != data++) {
+ printf("data verification failed byte %lld\n", total_bytes);
+ return -1;
+ }
+ }
+ return 0;
+}
+
+int do_poll(struct pollfd *fds, int timeout)
+{
+ int ret;
+
+ do {
+#ifdef __linux__
+ ret = rs_poll(fds, 1, timeout);
+#else
+ ret = poll(fds, 1, timeout);
+#endif
+ } while (!ret);
+
+ return ret == 1 ? (fds->revents & (POLLERR | POLLHUP)) : ret;
+}
diff --git a/contrib/ofed/librdmacm/examples/common.h b/contrib/ofed/librdmacm/examples/common.h
new file mode 100644
index 0000000..757b425
--- /dev/null
+++ b/contrib/ofed/librdmacm/examples/common.h
@@ -0,0 +1,86 @@
+/*
+ * Copyright (c) 2005-2012 Intel Corporation. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ * $Id$
+ */
+
+#include <stdlib.h>
+#include <sys/types.h>
+#include <infiniband/endian.h>
+#include <poll.h>
+
+#include <rdma/rdma_cma.h>
+#include <rdma/rsocket.h>
+#include <infiniband/ib.h>
+
+extern int use_rs;
+
+#define rs_socket(f,t,p) use_rs ? rsocket(f,t,p) : socket(f,t,p)
+#define rs_bind(s,a,l) use_rs ? rbind(s,a,l) : bind(s,a,l)
+#define rs_listen(s,b) use_rs ? rlisten(s,b) : listen(s,b)
+#define rs_connect(s,a,l) use_rs ? rconnect(s,a,l) : connect(s,a,l)
+#define rs_accept(s,a,l) use_rs ? raccept(s,a,l) : accept(s,a,l)
+#define rs_shutdown(s,h) use_rs ? rshutdown(s,h) : shutdown(s,h)
+#define rs_close(s) use_rs ? rclose(s) : close(s)
+#define rs_recv(s,b,l,f) use_rs ? rrecv(s,b,l,f) : recv(s,b,l,f)
+#define rs_send(s,b,l,f) use_rs ? rsend(s,b,l,f) : send(s,b,l,f)
+#define rs_recvfrom(s,b,l,f,a,al) \
+ use_rs ? rrecvfrom(s,b,l,f,a,al) : recvfrom(s,b,l,f,a,al)
+#define rs_sendto(s,b,l,f,a,al) \
+ use_rs ? rsendto(s,b,l,f,a,al) : sendto(s,b,l,f,a,al)
+#define rs_poll(f,n,t) use_rs ? rpoll(f,n,t) : poll(f,n,t)
+#define rs_fcntl(s,c,p) use_rs ? rfcntl(s,c,p) : fcntl(s,c,p)
+#define rs_setsockopt(s,l,n,v,ol) \
+ use_rs ? rsetsockopt(s,l,n,v,ol) : setsockopt(s,l,n,v,ol)
+#define rs_getsockopt(s,l,n,v,ol) \
+ use_rs ? rgetsockopt(s,l,n,v,ol) : getsockopt(s,l,n,v,ol)
+
+union socket_addr {
+ struct sockaddr sa;
+ struct sockaddr_in sin;
+ struct sockaddr_in6 sin6;
+};
+
+enum rs_optimization {
+ opt_mixed,
+ opt_latency,
+ opt_bandwidth
+};
+
+int get_rdma_addr(const char *src, const char *dst, const char *port,
+ struct rdma_addrinfo *hints, struct rdma_addrinfo **rai);
+
+void size_str(char *str, size_t ssize, long long size);
+void cnt_str(char *str, size_t ssize, long long cnt);
+int size_to_count(int size);
+void format_buf(void *buf, int size);
+int verify_buf(void *buf, int size);
+int do_poll(struct pollfd *fds, int timeout);
diff --git a/contrib/ofed/librdmacm/examples/mckey.c b/contrib/ofed/librdmacm/examples/mckey.c
index ddc3495..60cf8a2 100644
--- a/contrib/ofed/librdmacm/examples/mckey.c
+++ b/contrib/ofed/librdmacm/examples/mckey.c
@@ -37,15 +37,14 @@
#include <stdio.h>
#include <errno.h>
#include <sys/types.h>
-#include <netinet/in.h>
#include <arpa/inet.h>
#include <sys/socket.h>
#include <netdb.h>
-#include <byteswap.h>
#include <unistd.h>
#include <getopt.h>
#include <rdma/rdma_cma.h>
+#include <infiniband/ib.h>
struct cmatest_node {
int id;
@@ -67,9 +66,9 @@ struct cmatest {
int conn_index;
int connects_left;
- struct sockaddr_in6 dst_in;
+ struct sockaddr_storage dst_in;
struct sockaddr *dst_addr;
- struct sockaddr_in6 src_in;
+ struct sockaddr_storage src_in;
struct sockaddr *src_addr;
};
@@ -141,7 +140,7 @@ static int init_node(struct cmatest_node *node)
}
cqe = message_count ? message_count * 2 : 2;
- node->cq = ibv_create_cq(node->cma_id->verbs, cqe, node, 0, 0);
+ node->cq = ibv_create_cq(node->cma_id->verbs, cqe, node, NULL, 0);
if (!node->cq) {
ret = -ENOMEM;
printf("mckey: unable to create CQ\n");
@@ -216,7 +215,7 @@ static int post_sends(struct cmatest_node *node, int signal_flag)
send_wr.opcode = IBV_WR_SEND_WITH_IMM;
send_wr.send_flags = signal_flag;
send_wr.wr_id = (unsigned long)node;
- send_wr.imm_data = htonl(node->cma_id->qp->qp_num);
+ send_wr.imm_data = htobe32(node->cma_id->qp->qp_num);
send_wr.wr.ud.ah = node->ah;
send_wr.wr.ud.remote_qpn = node->remote_qpn;
@@ -451,7 +450,7 @@ static int get_addr(char *dst, struct sockaddr *addr)
ret = getaddrinfo(dst, NULL, NULL, &res);
if (ret) {
- printf("getaddrinfo failed - invalid hostname or IP address\n");
+ printf("getaddrinfo failed (%s) - invalid hostname or IP address\n", gai_strerror(ret));
return ret;
}
@@ -460,6 +459,20 @@ static int get_addr(char *dst, struct sockaddr *addr)
return ret;
}
+static int get_dst_addr(char *dst, struct sockaddr *addr)
+{
+ struct sockaddr_ib *sib;
+
+ if (!unmapped_addr)
+ return get_addr(dst, addr);
+
+ sib = (struct sockaddr_ib *) addr;
+ memset(sib, 0, sizeof *sib);
+ sib->sib_family = AF_IB;
+ inet_pton(AF_INET6, dst, &sib->sib_addr);
+ return 0;
+}
+
static int run(void)
{
int i, ret;
@@ -471,7 +484,7 @@ static int run(void)
return ret;
}
- ret = get_addr(dst_addr, (struct sockaddr *) &test.dst_in);
+ ret = get_dst_addr(dst_addr, (struct sockaddr *) &test.dst_in);
if (ret)
return ret;
diff --git a/contrib/ofed/librdmacm/examples/rcopy.c b/contrib/ofed/librdmacm/examples/rcopy.c
new file mode 100644
index 0000000..c85ce8e
--- /dev/null
+++ b/contrib/ofed/librdmacm/examples/rcopy.c
@@ -0,0 +1,628 @@
+/*
+ * Copyright (c) 2011 Intel Corporation. All rights reserved.
+ *
+ * This software is available to you under the OpenIB.org BSD license
+ * below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AWV
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <strings.h>
+#include <errno.h>
+#include <getopt.h>
+#include <arpa/inet.h>
+#include <sys/mman.h>
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <sys/time.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <netdb.h>
+#include <unistd.h>
+
+#include <rdma/rsocket.h>
+
+union rsocket_address {
+ struct sockaddr sa;
+ struct sockaddr_in sin;
+ struct sockaddr_in6 sin6;
+ struct sockaddr_storage storage;
+};
+
+static const char *port = "7427";
+static char *dst_addr;
+static char *dst_file;
+static char *src_file;
+static struct timeval start, end;
+//static void buf[1024 * 1024];
+static uint64_t bytes;
+static int fd;
+static void *file_addr;
+
+enum {
+ CMD_NOOP,
+ CMD_OPEN,
+ CMD_CLOSE,
+ CMD_WRITE,
+ CMD_RESP = 0x80,
+};
+
+/* TODO: handle byte swapping */
+struct msg_hdr {
+ uint8_t version;
+ uint8_t command;
+ uint16_t len;
+ uint32_t data;
+ uint64_t id;
+};
+
+struct msg_open {
+ struct msg_hdr hdr;
+ char path[0];
+};
+
+struct msg_write {
+ struct msg_hdr hdr;
+ uint64_t size;
+};
+
+static void show_perf(void)
+{
+ float usec;
+
+ usec = (end.tv_sec - start.tv_sec) * 1000000 + (end.tv_usec - start.tv_usec);
+
+ printf("%lld bytes in %.2f seconds = %.2f Gb/sec\n",
+ (long long) bytes, usec / 1000000., (bytes * 8) / (1000. * usec));
+}
+
+static char *_ntop(union rsocket_address *rsa)
+{
+ static char addr[32];
+
+ switch (rsa->sa.sa_family) {
+ case AF_INET:
+ inet_ntop(AF_INET, &rsa->sin.sin_addr, addr, sizeof addr);
+ break;
+ case AF_INET6:
+ inet_ntop(AF_INET6, &rsa->sin6.sin6_addr, addr, sizeof addr);
+ break;
+ default:
+ addr[0] = '\0';
+ break;
+ }
+
+ return addr;
+}
+
+static size_t _recv(int rs, char *msg, size_t len)
+{
+ size_t ret, offset;
+
+ for (offset = 0; offset < len; offset += ret) {
+ ret = rrecv(rs, msg + offset, len - offset, 0);
+ if (ret <= 0)
+ return ret;
+ }
+
+ return len;
+}
+
+static int msg_recv_hdr(int rs, struct msg_hdr *hdr)
+{
+ int ret;
+
+ ret = _recv(rs, (char *) hdr, sizeof *hdr);
+ if (ret != sizeof *hdr)
+ return -1;
+
+ if (hdr->version || hdr->len < sizeof *hdr) {
+ printf("invalid version %d or length %d\n",
+ hdr->version, hdr->len);
+ return -1;
+ }
+
+ return sizeof *hdr;
+}
+
+static int msg_get_resp(int rs, struct msg_hdr *msg, uint8_t cmd)
+{
+ int ret;
+
+ ret = msg_recv_hdr(rs, msg);
+ if (ret != sizeof *msg)
+ return ret;
+
+ if ((msg->len != sizeof *msg) || (msg->command != (cmd | CMD_RESP))) {
+ printf("invalid length %d or bad command response %x:%x\n",
+ msg->len, msg->command, cmd | CMD_RESP);
+ return -1;
+ }
+
+ return msg->data;
+}
+
+static void msg_send_resp(int rs, struct msg_hdr *msg, uint32_t status)
+{
+ struct msg_hdr resp;
+
+ resp.version = 0;
+ resp.command = msg->command | CMD_RESP;
+ resp.len = sizeof resp;
+ resp.data = status;
+ resp.id = msg->id;
+ rsend(rs, (char *) &resp, sizeof resp, 0);
+}
+
+static int server_listen(void)
+{
+ struct addrinfo hints, *res;
+ int ret, rs;
+
+ memset(&hints, 0, sizeof hints);
+ hints.ai_flags = RAI_PASSIVE;
+ ret = getaddrinfo(NULL, port, &hints, &res);
+ if (ret) {
+ printf("getaddrinfo failed: %s\n", gai_strerror(ret));
+ return ret;
+ }
+
+ rs = rsocket(res->ai_family, res->ai_socktype, res->ai_protocol);
+ if (rs < 0) {
+ perror("rsocket failed\n");
+ ret = rs;
+ goto free;
+ }
+
+ ret = 1;
+ ret = rsetsockopt(rs, SOL_SOCKET, SO_REUSEADDR, &ret, sizeof ret);
+ if (ret) {
+ perror("rsetsockopt failed");
+ goto close;
+ }
+
+ ret = rbind(rs, res->ai_addr, res->ai_addrlen);
+ if (ret) {
+ perror("rbind failed");
+ goto close;
+ }
+
+ ret = rlisten(rs, 1);
+ if (ret) {
+ perror("rlisten failed");
+ goto close;
+ }
+
+ ret = rs;
+ goto free;
+
+close:
+ rclose(rs);
+free:
+ freeaddrinfo(res);
+ return ret;
+}
+
+static int server_open(int rs, struct msg_hdr *msg)
+{
+ char *path = NULL;
+ int ret, len;
+
+ printf("opening: ");
+ fflush(NULL);
+ if (file_addr || fd > 0) {
+ printf("cannot open another file\n");
+ ret = EBUSY;
+ goto out;
+ }
+
+ len = msg->len - sizeof *msg;
+ path = malloc(len);
+ if (!path) {
+ printf("cannot allocate path name\n");
+ ret = ENOMEM;
+ goto out;
+ }
+
+ ret = _recv(rs, path, len);
+ if (ret != len) {
+ printf("error receiving path\n");
+ goto out;
+ }
+
+ printf("%s, ", path);
+ fflush(NULL);
+ fd = open(path, O_RDWR | O_CREAT | O_TRUNC, msg->data);
+ if (fd < 0) {
+ printf("unable to open destination file\n");
+ ret = errno;
+ }
+
+ ret = 0;
+out:
+ if (path)
+ free(path);
+
+ msg_send_resp(rs, msg, ret);
+ return ret;
+}
+
+static void server_close(int rs, struct msg_hdr *msg)
+{
+ printf("closing...");
+ fflush(NULL);
+ msg_send_resp(rs, msg, 0);
+
+ if (file_addr) {
+ munmap(file_addr, bytes);
+ file_addr = NULL;
+ }
+
+ if (fd > 0) {
+ close(fd);
+ fd = 0;
+ }
+ printf("done\n");
+}
+
+static int server_write(int rs, struct msg_hdr *msg)
+{
+ size_t len;
+ int ret;
+
+ printf("transferring");
+ fflush(NULL);
+ if (fd <= 0) {
+ printf("...file not opened\n");
+ ret = EINVAL;
+ goto out;
+ }
+
+ if (msg->len != sizeof(struct msg_write)) {
+ printf("...invalid message length %d\n", msg->len);
+ ret = EINVAL;
+ goto out;
+ }
+
+ ret = _recv(rs, (char *) &bytes, sizeof bytes);
+ if (ret != sizeof bytes)
+ goto out;
+
+ ret = ftruncate(fd, bytes);
+ if (ret)
+ goto out;
+
+ file_addr = mmap(NULL, bytes, PROT_WRITE, MAP_SHARED, fd, 0);
+ if (file_addr == (void *) -1) {
+ printf("...error mapping file\n");
+ ret = errno;
+ goto out;
+ }
+
+ printf("...%lld bytes...", (long long) bytes);
+ fflush(NULL);
+ len = _recv(rs, file_addr, bytes);
+ if (len != bytes) {
+ printf("...error receiving data\n");
+ ret = (int) len;
+ }
+out:
+ msg_send_resp(rs, msg, ret);
+ return ret;
+}
+
+static void server_process(int rs)
+{
+ struct msg_hdr msg;
+ int ret;
+
+ do {
+ ret = msg_recv_hdr(rs, &msg);
+ if (ret != sizeof msg)
+ break;
+
+ switch (msg.command) {
+ case CMD_OPEN:
+ ret = server_open(rs, &msg);
+ break;
+ case CMD_CLOSE:
+ server_close(rs, &msg);
+ ret = 0;
+ break;
+ case CMD_WRITE:
+ ret = server_write(rs, &msg);
+ break;
+ default:
+ msg_send_resp(rs, &msg, EINVAL);
+ ret = -1;
+ break;
+ }
+
+ } while (!ret);
+}
+
+static int server_run(void)
+{
+ int lrs, rs;
+ union rsocket_address rsa;
+ socklen_t len;
+
+ lrs = server_listen();
+ if (lrs < 0)
+ return lrs;
+
+ while (1) {
+ len = sizeof rsa;
+ printf("waiting for connection...");
+ fflush(NULL);
+ rs = raccept(lrs, &rsa.sa, &len);
+
+ printf("client: %s\n", _ntop(&rsa));
+ server_process(rs);
+
+ rshutdown(rs, SHUT_RDWR);
+ rclose(rs);
+ }
+ return 0;
+}
+
+static int client_connect(void)
+{
+ struct addrinfo *res;
+ int ret, rs;
+
+ ret = getaddrinfo(dst_addr, port, NULL, &res);
+ if (ret) {
+ printf("getaddrinfo failed: %s\n", gai_strerror(ret));
+ return ret;
+ }
+
+ rs = rsocket(res->ai_family, res->ai_socktype, res->ai_protocol);
+ if (rs < 0) {
+ perror("rsocket failed\n");
+ goto free;
+ }
+
+ ret = rconnect(rs, res->ai_addr, res->ai_addrlen);
+ if (ret) {
+ perror("rconnect failed\n");
+ rclose(rs);
+ rs = ret;
+ }
+
+free:
+ freeaddrinfo(res);
+ return rs;
+}
+
+static int client_open(int rs)
+{
+ struct msg_open *msg;
+ struct stat stats;
+ uint32_t len;
+ int ret;
+
+ printf("opening...");
+ fflush(NULL);
+ fd = open(src_file, O_RDONLY);
+ if (fd < 0)
+ return fd;
+
+ ret = fstat(fd, &stats);
+ if (ret < 0)
+ goto err1;
+
+ bytes = (uint64_t) stats.st_size;
+ file_addr = mmap(NULL, bytes, PROT_READ, MAP_SHARED, fd, 0);
+ if (file_addr == (void *) -1) {
+ ret = errno;
+ goto err1;
+ }
+
+ len = (((uint32_t) strlen(dst_file)) + 8) & 0xFFFFFFF8;
+ msg = calloc(1, sizeof(*msg) + len);
+ if (!msg) {
+ ret = -1;
+ goto err2;
+ }
+
+ msg->hdr.command = CMD_OPEN;
+ msg->hdr.len = sizeof(*msg) + len;
+ msg->hdr.data = (uint32_t) stats.st_mode;
+ strcpy(msg->path, dst_file);
+ ret = rsend(rs, msg, msg->hdr.len, 0);
+ if (ret != msg->hdr.len)
+ goto err3;
+
+ ret = msg_get_resp(rs, &msg->hdr, CMD_OPEN);
+ if (ret)
+ goto err3;
+
+ return 0;
+
+err3:
+ free(msg);
+err2:
+ munmap(file_addr, bytes);
+err1:
+ close(fd);
+ return ret;
+}
+
+static int client_start_write(int rs)
+{
+ struct msg_write msg;
+ int ret;
+
+ printf("transferring");
+ fflush(NULL);
+ memset(&msg, 0, sizeof msg);
+ msg.hdr.command = CMD_WRITE;
+ msg.hdr.len = sizeof(msg);
+ msg.size = bytes;
+
+ ret = rsend(rs, &msg, sizeof msg, 0);
+ if (ret != msg.hdr.len)
+ return ret;
+
+ return 0;
+}
+
+static int client_close(int rs)
+{
+ struct msg_hdr msg;
+ int ret;
+
+ printf("closing...");
+ fflush(NULL);
+ memset(&msg, 0, sizeof msg);
+ msg.command = CMD_CLOSE;
+ msg.len = sizeof msg;
+ ret = rsend(rs, (char *) &msg, msg.len, 0);
+ if (ret != msg.len)
+ goto out;
+
+ ret = msg_get_resp(rs, &msg, CMD_CLOSE);
+ if (ret)
+ goto out;
+
+ printf("done\n");
+out:
+ munmap(file_addr, bytes);
+ close(fd);
+ return ret;
+}
+
+static int client_run(void)
+{
+ struct msg_hdr ack;
+ int ret, rs;
+ size_t len;
+
+ rs = client_connect();
+ if (rs < 0)
+ return rs;
+
+ ret = client_open(rs);
+ if (ret)
+ goto shutdown;
+
+ ret = client_start_write(rs);
+ if (ret)
+ goto close;
+
+ printf("...");
+ fflush(NULL);
+ gettimeofday(&start, NULL);
+ len = rsend(rs, file_addr, bytes, 0);
+ if (len == bytes)
+ ret = msg_get_resp(rs, &ack, CMD_WRITE);
+ else
+ ret = (int) len;
+
+ gettimeofday(&end, NULL);
+
+close:
+ client_close(rs);
+shutdown:
+ rshutdown(rs, SHUT_RDWR);
+ rclose(rs);
+ if (!ret)
+ show_perf();
+ return ret;
+}
+
+static void show_usage(char *program)
+{
+ printf("usage 1: %s [options]\n", program);
+ printf("\t starts the server application\n");
+ printf("\t[-p port_number]\n");
+ printf("usage 2: %s source server[:destination] [options]\n", program);
+ printf("\t source - file name and path\n");
+ printf("\t server - name or address\n");
+ printf("\t destination - file name and path\n");
+ printf("\t[-p port_number]\n");
+ exit(1);
+}
+
+static void server_opts(int argc, char **argv)
+{
+ int op;
+
+ while ((op = getopt(argc, argv, "p:")) != -1) {
+ switch (op) {
+ case 'p':
+ port = optarg;
+ break;
+ default:
+ show_usage(argv[0]);
+ }
+ }
+}
+
+static void client_opts(int argc, char **argv)
+{
+ int op;
+
+ if (argc < 3)
+ show_usage(argv[0]);
+
+ src_file = argv[1];
+ dst_addr = argv[2];
+ dst_file = strchr(dst_addr, ':');
+ if (dst_file) {
+ *dst_file = '\0';
+ dst_file++;
+ }
+ if (!dst_file)
+ dst_file = src_file;
+
+ while ((op = getopt(argc, argv, "p:")) != -1) {
+ switch (op) {
+ case 'p':
+ port = optarg;
+ break;
+ default:
+ show_usage(argv[0]);
+ }
+ }
+
+}
+
+int main(int argc, char **argv)
+{
+ int ret;
+
+ if (argc == 1 || argv[1][0] == '-') {
+ server_opts(argc, argv);
+ ret = server_run();
+ } else {
+ client_opts(argc, argv);
+ ret = client_run();
+ }
+
+ return ret;
+}
diff --git a/contrib/ofed/librdmacm/examples/rdma_client.c b/contrib/ofed/librdmacm/examples/rdma_client.c
new file mode 100644
index 0000000..c27047c
--- /dev/null
+++ b/contrib/ofed/librdmacm/examples/rdma_client.c
@@ -0,0 +1,166 @@
+/*
+ * Copyright (c) 2010 Intel Corporation. All rights reserved.
+ *
+ * This software is available to you under the OpenIB.org BSD license
+ * below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AWV
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <netdb.h>
+#include <errno.h>
+#include <getopt.h>
+#include <rdma/rdma_cma.h>
+#include <rdma/rdma_verbs.h>
+
+static const char *server = "127.0.0.1";
+static const char *port = "7471";
+
+static struct rdma_cm_id *id;
+static struct ibv_mr *mr, *send_mr;
+static int send_flags;
+static uint8_t send_msg[16];
+static uint8_t recv_msg[16];
+
+static int run(void)
+{
+ struct rdma_addrinfo hints, *res;
+ struct ibv_qp_init_attr attr;
+ struct ibv_wc wc;
+ int ret;
+
+ memset(&hints, 0, sizeof hints);
+ hints.ai_port_space = RDMA_PS_TCP;
+ ret = rdma_getaddrinfo(server, port, &hints, &res);
+ if (ret) {
+ printf("rdma_getaddrinfo: %s\n", gai_strerror(ret));
+ goto out;
+ }
+
+ memset(&attr, 0, sizeof attr);
+ attr.cap.max_send_wr = attr.cap.max_recv_wr = 1;
+ attr.cap.max_send_sge = attr.cap.max_recv_sge = 1;
+ attr.cap.max_inline_data = 16;
+ attr.qp_context = id;
+ attr.sq_sig_all = 1;
+ ret = rdma_create_ep(&id, res, NULL, &attr);
+ // Check to see if we got inline data allowed or not
+ if (attr.cap.max_inline_data >= 16)
+ send_flags = IBV_SEND_INLINE;
+ else
+ printf("rdma_client: device doesn't support IBV_SEND_INLINE, "
+ "using sge sends\n");
+
+ if (ret) {
+ perror("rdma_create_ep");
+ goto out_free_addrinfo;
+ }
+
+ mr = rdma_reg_msgs(id, recv_msg, 16);
+ if (!mr) {
+ perror("rdma_reg_msgs for recv_msg");
+ ret = -1;
+ goto out_destroy_ep;
+ }
+ if ((send_flags & IBV_SEND_INLINE) == 0) {
+ send_mr = rdma_reg_msgs(id, send_msg, 16);
+ if (!send_mr) {
+ perror("rdma_reg_msgs for send_msg");
+ ret = -1;
+ goto out_dereg_recv;
+ }
+ }
+
+ ret = rdma_post_recv(id, NULL, recv_msg, 16, mr);
+ if (ret) {
+ perror("rdma_post_recv");
+ goto out_dereg_send;
+ }
+
+ ret = rdma_connect(id, NULL);
+ if (ret) {
+ perror("rdma_connect");
+ goto out_dereg_send;
+ }
+
+ ret = rdma_post_send(id, NULL, send_msg, 16, send_mr, send_flags);
+ if (ret) {
+ perror("rdma_post_send");
+ goto out_disconnect;
+ }
+
+ while ((ret = rdma_get_send_comp(id, &wc)) == 0);
+ if (ret < 0) {
+ perror("rdma_get_send_comp");
+ goto out_disconnect;
+ }
+
+ while ((ret = rdma_get_recv_comp(id, &wc)) == 0);
+ if (ret < 0)
+ perror("rdma_get_recv_comp");
+ else
+ ret = 0;
+
+out_disconnect:
+ rdma_disconnect(id);
+out_dereg_send:
+ if ((send_flags & IBV_SEND_INLINE) == 0)
+ rdma_dereg_mr(send_mr);
+out_dereg_recv:
+ rdma_dereg_mr(mr);
+out_destroy_ep:
+ rdma_destroy_ep(id);
+out_free_addrinfo:
+ rdma_freeaddrinfo(res);
+out:
+ return ret;
+}
+
+int main(int argc, char **argv)
+{
+ int op, ret;
+
+ while ((op = getopt(argc, argv, "s:p:")) != -1) {
+ switch (op) {
+ case 's':
+ server = optarg;
+ break;
+ case 'p':
+ port = optarg;
+ break;
+ default:
+ printf("usage: %s\n", argv[0]);
+ printf("\t[-s server_address]\n");
+ printf("\t[-p port_number]\n");
+ exit(1);
+ }
+ }
+
+ printf("rdma_client: start\n");
+ ret = run();
+ printf("rdma_client: end %d\n", ret);
+ return ret;
+}
diff --git a/contrib/ofed/librdmacm/examples/rdma_server.c b/contrib/ofed/librdmacm/examples/rdma_server.c
new file mode 100644
index 0000000..bcf649f
--- /dev/null
+++ b/contrib/ofed/librdmacm/examples/rdma_server.c
@@ -0,0 +1,182 @@
+/*
+ * Copyright (c) 2005-2009 Intel Corporation. All rights reserved.
+ *
+ * This software is available to you under the OpenIB.org BSD license
+ * below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AWV
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
+#include <getopt.h>
+#include <netdb.h>
+#include <rdma/rdma_cma.h>
+#include <rdma/rdma_verbs.h>
+
+static const char *port = "7471";
+
+static struct rdma_cm_id *listen_id, *id;
+static struct ibv_mr *mr, *send_mr;
+static int send_flags;
+static uint8_t send_msg[16];
+static uint8_t recv_msg[16];
+
+static int run(void)
+{
+ struct rdma_addrinfo hints, *res;
+ struct ibv_qp_init_attr init_attr;
+ struct ibv_qp_attr qp_attr;
+ struct ibv_wc wc;
+ int ret;
+
+ memset(&hints, 0, sizeof hints);
+ hints.ai_flags = RAI_PASSIVE;
+ hints.ai_port_space = RDMA_PS_TCP;
+ ret = rdma_getaddrinfo(NULL, port, &hints, &res);
+ if (ret) {
+ printf("rdma_getaddrinfo: %s\n", gai_strerror(ret));
+ return ret;
+ }
+
+ memset(&init_attr, 0, sizeof init_attr);
+ init_attr.cap.max_send_wr = init_attr.cap.max_recv_wr = 1;
+ init_attr.cap.max_send_sge = init_attr.cap.max_recv_sge = 1;
+ init_attr.cap.max_inline_data = 16;
+ init_attr.sq_sig_all = 1;
+ ret = rdma_create_ep(&listen_id, res, NULL, &init_attr);
+ if (ret) {
+ perror("rdma_create_ep");
+ goto out_free_addrinfo;
+ }
+
+ ret = rdma_listen(listen_id, 0);
+ if (ret) {
+ perror("rdma_listen");
+ goto out_destroy_listen_ep;
+ }
+
+ ret = rdma_get_request(listen_id, &id);
+ if (ret) {
+ perror("rdma_get_request");
+ goto out_destroy_listen_ep;
+ }
+
+ memset(&qp_attr, 0, sizeof qp_attr);
+ memset(&init_attr, 0, sizeof init_attr);
+ ret = ibv_query_qp(id->qp, &qp_attr, IBV_QP_CAP,
+ &init_attr);
+ if (ret) {
+ perror("ibv_query_qp");
+ goto out_destroy_accept_ep;
+ }
+ if (init_attr.cap.max_inline_data >= 16)
+ send_flags = IBV_SEND_INLINE;
+ else
+ printf("rdma_server: device doesn't support IBV_SEND_INLINE, "
+ "using sge sends\n");
+
+ mr = rdma_reg_msgs(id, recv_msg, 16);
+ if (!mr) {
+ ret = -1;
+ perror("rdma_reg_msgs for recv_msg");
+ goto out_destroy_accept_ep;
+ }
+ if ((send_flags & IBV_SEND_INLINE) == 0) {
+ send_mr = rdma_reg_msgs(id, send_msg, 16);
+ if (!send_mr) {
+ ret = -1;
+ perror("rdma_reg_msgs for send_msg");
+ goto out_dereg_recv;
+ }
+ }
+
+ ret = rdma_post_recv(id, NULL, recv_msg, 16, mr);
+ if (ret) {
+ perror("rdma_post_recv");
+ goto out_dereg_send;
+ }
+
+ ret = rdma_accept(id, NULL);
+ if (ret) {
+ perror("rdma_accept");
+ goto out_dereg_send;
+ }
+
+ while ((ret = rdma_get_recv_comp(id, &wc)) == 0);
+ if (ret < 0) {
+ perror("rdma_get_recv_comp");
+ goto out_disconnect;
+ }
+
+ ret = rdma_post_send(id, NULL, send_msg, 16, send_mr, send_flags);
+ if (ret) {
+ perror("rdma_post_send");
+ goto out_disconnect;
+ }
+
+ while ((ret = rdma_get_send_comp(id, &wc)) == 0);
+ if (ret < 0)
+ perror("rdma_get_send_comp");
+ else
+ ret = 0;
+
+out_disconnect:
+ rdma_disconnect(id);
+out_dereg_send:
+ if ((send_flags & IBV_SEND_INLINE) == 0)
+ rdma_dereg_mr(send_mr);
+out_dereg_recv:
+ rdma_dereg_mr(mr);
+out_destroy_accept_ep:
+ rdma_destroy_ep(id);
+out_destroy_listen_ep:
+ rdma_destroy_ep(listen_id);
+out_free_addrinfo:
+ rdma_freeaddrinfo(res);
+ return ret;
+}
+
+int main(int argc, char **argv)
+{
+ int op, ret;
+
+ while ((op = getopt(argc, argv, "p:")) != -1) {
+ switch (op) {
+ case 'p':
+ port = optarg;
+ break;
+ default:
+ printf("usage: %s\n", argv[0]);
+ printf("\t[-p port_number]\n");
+ exit(1);
+ }
+ }
+
+ printf("rdma_server: start\n");
+ ret = run();
+ printf("rdma_server: end %d\n", ret);
+ return ret;
+}
diff --git a/contrib/ofed/librdmacm/examples/rdma_xclient.c b/contrib/ofed/librdmacm/examples/rdma_xclient.c
new file mode 100644
index 0000000..63dfb6d
--- /dev/null
+++ b/contrib/ofed/librdmacm/examples/rdma_xclient.c
@@ -0,0 +1,178 @@
+/*
+ * Copyright (c) 2010-2014 Intel Corporation. All rights reserved.
+ *
+ * This software is available to you under the OpenIB.org BSD license
+ * below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AWV
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#include <endian.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <netdb.h>
+#include <errno.h>
+#include <getopt.h>
+#include <ctype.h>
+#include <rdma/rdma_cma.h>
+#include <rdma/rdma_verbs.h>
+
+static const char *server = "127.0.0.1";
+static char port[6] = "7471";
+
+static struct rdma_cm_id *id;
+static struct ibv_mr *mr;
+static struct rdma_addrinfo hints;
+
+static uint8_t send_msg[16];
+static uint32_t srqn;
+
+static int post_send(void)
+{
+ struct ibv_send_wr wr, *bad;
+ struct ibv_sge sge;
+ int ret;
+
+ sge.addr = (uint64_t) (uintptr_t) send_msg;
+ sge.length = (uint32_t) sizeof send_msg;
+ sge.lkey = 0;
+ wr.wr_id = (uintptr_t) NULL;
+ wr.next = NULL;
+ wr.sg_list = &sge;
+ wr.num_sge = 1;
+ wr.opcode = IBV_WR_SEND;
+ wr.send_flags = IBV_SEND_INLINE;
+ if (hints.ai_qp_type == IBV_QPT_XRC_SEND)
+ wr.qp_type.xrc.remote_srqn = srqn;
+
+ ret = ibv_post_send(id->qp, &wr, &bad);
+ if (ret)
+ perror("rdma_post_send");
+
+ return ret;
+}
+
+static int test(void)
+{
+ struct rdma_addrinfo *res;
+ struct ibv_qp_init_attr attr;
+ struct ibv_wc wc;
+ int ret;
+
+ ret = rdma_getaddrinfo(server, port, &hints, &res);
+ if (ret) {
+ printf("rdma_getaddrinfo: %s\n", gai_strerror(ret));
+ return ret;
+ }
+
+ memset(&attr, 0, sizeof attr);
+ attr.cap.max_send_wr = attr.cap.max_recv_wr = 1;
+ attr.cap.max_send_sge = attr.cap.max_recv_sge = 1;
+ attr.sq_sig_all = 1;
+ ret = rdma_create_ep(&id, res, NULL, &attr);
+ rdma_freeaddrinfo(res);
+ if (ret) {
+ perror("rdma_create_ep");
+ return ret;
+ }
+
+ mr = rdma_reg_msgs(id, send_msg, sizeof send_msg);
+ if (!mr) {
+ perror("rdma_reg_msgs");
+ return ret;
+ }
+
+ ret = rdma_connect(id, NULL);
+ if (ret) {
+ perror("rdma_connect");
+ return ret;
+ }
+
+ if (hints.ai_qp_type == IBV_QPT_XRC_SEND)
+ srqn = be32toh(*(__be32 *) id->event->param.conn.private_data);
+
+ ret = post_send();
+ if (ret) {
+ perror("post_send");
+ return ret;
+ }
+
+ ret = rdma_get_send_comp(id, &wc);
+ if (ret <= 0) {
+ perror("rdma_get_recv_comp");
+ return ret;
+ }
+
+ rdma_disconnect(id);
+ rdma_dereg_mr(mr);
+ rdma_destroy_ep(id);
+ return 0;
+}
+
+int main(int argc, char **argv)
+{
+ int op, ret;
+
+ hints.ai_port_space = RDMA_PS_TCP;
+ hints.ai_qp_type = IBV_QPT_RC;
+
+ while ((op = getopt(argc, argv, "s:p:c:")) != -1) {
+ switch (op) {
+ case 's':
+ server = optarg;
+ break;
+ case 'p':
+ strncpy(port, optarg, sizeof port - 1);
+ break;
+ case 'c':
+ switch (tolower(optarg[0])) {
+ case 'r':
+ break;
+ case 'x':
+ hints.ai_port_space = RDMA_PS_IB;
+ hints.ai_qp_type = IBV_QPT_XRC_SEND;
+ break;
+ default:
+ goto err;
+ }
+ break;
+ default:
+ goto err;
+ }
+ }
+
+ printf("%s: start\n", argv[0]);
+ ret = test();
+ printf("%s: end %d\n", argv[0], ret);
+ return ret;
+
+err:
+ printf("usage: %s\n", argv[0]);
+ printf("\t[-s server]\n");
+ printf("\t[-p port_number]\n");
+ printf("\t[-c communication type]\n");
+ printf("\t r - RC: reliable-connected (default)\n");
+ printf("\t x - XRC: extended-reliable-connected\n");
+ exit(1);
+}
diff --git a/contrib/ofed/librdmacm/examples/rdma_xserver.c b/contrib/ofed/librdmacm/examples/rdma_xserver.c
new file mode 100644
index 0000000..8d8ac31
--- /dev/null
+++ b/contrib/ofed/librdmacm/examples/rdma_xserver.c
@@ -0,0 +1,190 @@
+/*
+ * Copyright (c) 2005-2014 Intel Corporation. All rights reserved.
+ *
+ * This software is available to you under the OpenIB.org BSD license
+ * below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AWV
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#include <endian.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
+#include <getopt.h>
+#include <netdb.h>
+#include <ctype.h>
+#include <rdma/rdma_cma.h>
+#include <rdma/rdma_verbs.h>
+
+static const char *port = "7471";
+
+static struct rdma_cm_id *listen_id, *id;
+static struct ibv_mr *mr;
+static struct rdma_addrinfo hints;
+
+static uint8_t recv_msg[16];
+static __be32 srqn;
+
+static int create_srq(void)
+{
+ struct ibv_srq_init_attr attr;
+ int ret;
+ uint32_t tmp_srqn;
+
+ attr.attr.max_wr = 1;
+ attr.attr.max_sge = 1;
+ attr.attr.srq_limit = 0;
+ attr.srq_context = id;
+
+ ret = rdma_create_srq(id, NULL, &attr);
+ if (ret)
+ perror("rdma_create_srq:");
+
+ if (id->srq) {
+ ibv_get_srq_num(id->srq, &tmp_srqn);
+ srqn = htobe32(tmp_srqn);
+ }
+ return ret;
+}
+
+static int test(void)
+{
+ struct rdma_addrinfo *res;
+ struct ibv_qp_init_attr attr;
+ struct rdma_conn_param param;
+ struct ibv_wc wc;
+ int ret;
+
+ ret = rdma_getaddrinfo(NULL, port, &hints, &res);
+ if (ret) {
+ printf("rdma_getaddrinfo: %s\n", gai_strerror(ret));
+ return ret;
+ }
+
+ memset(&attr, 0, sizeof attr);
+ attr.cap.max_send_wr = attr.cap.max_recv_wr = 1;
+ attr.cap.max_send_sge = attr.cap.max_recv_sge = 1;
+ ret = rdma_create_ep(&listen_id, res, NULL, &attr);
+ rdma_freeaddrinfo(res);
+ if (ret) {
+ perror("rdma_create_ep");
+ return ret;
+ }
+
+ ret = rdma_listen(listen_id, 0);
+ if (ret) {
+ perror("rdma_listen");
+ return ret;
+ }
+
+ ret = rdma_get_request(listen_id, &id);
+ if (ret) {
+ perror("rdma_get_request");
+ return ret;
+ }
+
+ if (hints.ai_qp_type == IBV_QPT_XRC_RECV) {
+ ret = create_srq();
+ if (ret)
+ return ret;
+ }
+
+ mr = rdma_reg_msgs(id, recv_msg, sizeof recv_msg);
+ if (!mr) {
+ perror("rdma_reg_msgs");
+ return ret;
+ }
+
+ ret = rdma_post_recv(id, NULL, recv_msg, sizeof recv_msg, mr);
+ if (ret) {
+ perror("rdma_post_recv");
+ return ret;
+ }
+
+ memset(&param, 0, sizeof param);
+ param.private_data = &srqn;
+ param.private_data_len = sizeof srqn;
+ ret = rdma_accept(id, &param);
+ if (ret) {
+ perror("rdma_accept");
+ return ret;
+ }
+
+ ret = rdma_get_recv_comp(id, &wc);
+ if (ret <= 0) {
+ perror("rdma_get_recv_comp");
+ return ret;
+ }
+
+ rdma_disconnect(id);
+ rdma_dereg_mr(mr);
+ rdma_destroy_ep(id);
+ rdma_destroy_ep(listen_id);
+ return 0;
+}
+
+int main(int argc, char **argv)
+{
+ int op, ret;
+
+ hints.ai_flags = RAI_PASSIVE;
+ hints.ai_port_space = RDMA_PS_TCP;
+ hints.ai_qp_type = IBV_QPT_RC;
+
+ while ((op = getopt(argc, argv, "p:c:")) != -1) {
+ switch (op) {
+ case 'p':
+ port = optarg;
+ break;
+ case 'c':
+ switch (tolower(optarg[0])) {
+ case 'r':
+ break;
+ case 'x':
+ hints.ai_port_space = RDMA_PS_IB;
+ hints.ai_qp_type = IBV_QPT_XRC_RECV;
+ break;
+ default:
+ goto err;
+ }
+ break;
+ default:
+ goto err;
+ }
+ }
+
+ printf("%s: start\n", argv[0]);
+ ret = test();
+ printf("%s: end %d\n", argv[0], ret);
+ return ret;
+
+err:
+ printf("usage: %s\n", argv[0]);
+ printf("\t[-p port_number]\n");
+ printf("\t[-c communication type]\n");
+ printf("\t r - RC: reliable-connected (default)\n");
+ printf("\t x - XRC: extended-reliable-connected\n");
+ exit(1);
+}
diff --git a/contrib/ofed/librdmacm/examples/riostream.c b/contrib/ofed/librdmacm/examples/riostream.c
new file mode 100644
index 0000000..bdf4fd3
--- /dev/null
+++ b/contrib/ofed/librdmacm/examples/riostream.c
@@ -0,0 +1,674 @@
+/*
+ * Copyright (c) 2011-2012 Intel Corporation. All rights reserved.
+ * Copyright (c) 2014 Mellanox Technologies LTD. All rights reserved.
+ *
+ * This software is available to you under the OpenIB.org BSD license
+ * below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AWV
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <strings.h>
+#include <errno.h>
+#include <getopt.h>
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <sys/time.h>
+#include <sys/wait.h>
+#include <netdb.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <netinet/tcp.h>
+
+#include <rdma/rdma_cma.h>
+#include <rdma/rsocket.h>
+#include <util/compiler.h>
+#include "common.h"
+
+struct test_size_param {
+ int size;
+ int option;
+};
+
+static struct test_size_param test_size[] = {
+ { 1 << 6, 0 },
+ { 1 << 7, 1 }, { (1 << 7) + (1 << 6), 1},
+ { 1 << 8, 1 }, { (1 << 8) + (1 << 7), 1},
+ { 1 << 9, 1 }, { (1 << 9) + (1 << 8), 1},
+ { 1 << 10, 1 }, { (1 << 10) + (1 << 9), 1},
+ { 1 << 11, 1 }, { (1 << 11) + (1 << 10), 1},
+ { 1 << 12, 0 }, { (1 << 12) + (1 << 11), 1},
+ { 1 << 13, 1 }, { (1 << 13) + (1 << 12), 1},
+ { 1 << 14, 1 }, { (1 << 14) + (1 << 13), 1},
+ { 1 << 15, 1 }, { (1 << 15) + (1 << 14), 1},
+ { 1 << 16, 0 }, { (1 << 16) + (1 << 15), 1},
+ { 1 << 17, 1 }, { (1 << 17) + (1 << 16), 1},
+ { 1 << 18, 1 }, { (1 << 18) + (1 << 17), 1},
+ { 1 << 19, 1 }, { (1 << 19) + (1 << 18), 1},
+ { 1 << 20, 0 }, { (1 << 20) + (1 << 19), 1},
+ { 1 << 21, 1 }, { (1 << 21) + (1 << 20), 1},
+ { 1 << 22, 1 }, { (1 << 22) + (1 << 21), 1},
+};
+#define TEST_CNT (sizeof test_size / sizeof test_size[0])
+
+static int rs, lrs;
+static int use_async;
+static int use_rgai;
+static int verify;
+static int flags = MSG_DONTWAIT;
+static int poll_timeout = 0;
+static int custom;
+static enum rs_optimization optimization;
+static int size_option;
+static int iterations = 1;
+static int transfer_size = 1000;
+static int transfer_count = 1000;
+static int buffer_size, inline_size = 64;
+static char test_name[10] = "custom";
+static const char *port = "7471";
+static char *dst_addr;
+static char *src_addr;
+static struct timeval start, end;
+static void *buf;
+static volatile uint8_t *poll_byte;
+static struct rdma_addrinfo rai_hints;
+static struct addrinfo ai_hints;
+
+static void show_perf(void)
+{
+ char str[32];
+ float usec;
+ long long bytes;
+
+ usec = (end.tv_sec - start.tv_sec) * 1000000 + (end.tv_usec - start.tv_usec);
+ bytes = (long long) iterations * transfer_count * transfer_size * 2;
+
+ /* name size transfers iterations bytes seconds Gb/sec usec/xfer */
+ printf("%-10s", test_name);
+ size_str(str, sizeof str, transfer_size);
+ printf("%-8s", str);
+ cnt_str(str, sizeof str, transfer_count);
+ printf("%-8s", str);
+ cnt_str(str, sizeof str, iterations);
+ printf("%-8s", str);
+ size_str(str, sizeof str, bytes);
+ printf("%-8s", str);
+ printf("%8.2fs%10.2f%11.2f\n",
+ usec / 1000000., (bytes * 8) / (1000. * usec),
+ (usec / iterations) / (transfer_count * 2));
+}
+
+static void init_latency_test(int size)
+{
+ char sstr[5];
+
+ size_str(sstr, sizeof sstr, size);
+ snprintf(test_name, sizeof test_name, "%s_lat", sstr);
+ transfer_count = 1;
+ transfer_size = size;
+ iterations = size_to_count(transfer_size);
+}
+
+static void init_bandwidth_test(int size)
+{
+ char sstr[5];
+
+ size_str(sstr, sizeof sstr, size);
+ snprintf(test_name, sizeof test_name, "%s_bw", sstr);
+ iterations = 1;
+ transfer_size = size;
+ transfer_count = size_to_count(transfer_size);
+}
+
+static int send_msg(int size)
+{
+ struct pollfd fds;
+ int offset, ret;
+
+ if (use_async) {
+ fds.fd = rs;
+ fds.events = POLLOUT;
+ }
+
+ for (offset = 0; offset < size; ) {
+ if (use_async) {
+ ret = do_poll(&fds, poll_timeout);
+ if (ret)
+ return ret;
+ }
+
+ ret = rsend(rs, buf + offset, size - offset, flags);
+ if (ret > 0) {
+ offset += ret;
+ } else if (errno != EWOULDBLOCK && errno != EAGAIN) {
+ perror("rsend");
+ return ret;
+ }
+ }
+
+ return 0;
+}
+
+static int send_xfer(int size)
+{
+ struct pollfd fds;
+ int offset, ret;
+
+ if (use_async) {
+ fds.fd = rs;
+ fds.events = POLLOUT;
+ }
+
+ for (offset = 0; offset < size; ) {
+ if (use_async) {
+ ret = do_poll(&fds, poll_timeout);
+ if (ret)
+ return ret;
+ }
+
+ ret = riowrite(rs, buf + offset, size - offset, offset, flags);
+ if (ret > 0) {
+ offset += ret;
+ } else if (errno != EWOULDBLOCK && errno != EAGAIN) {
+ perror("riowrite");
+ return ret;
+ }
+ }
+
+ return 0;
+}
+
+static int recv_msg(int size)
+{
+ struct pollfd fds;
+ int offset, ret;
+
+ if (use_async) {
+ fds.fd = rs;
+ fds.events = POLLIN;
+ }
+
+ for (offset = 0; offset < size; ) {
+ if (use_async) {
+ ret = do_poll(&fds, poll_timeout);
+ if (ret)
+ return ret;
+ }
+
+ ret = rrecv(rs, buf + offset, size - offset, flags);
+ if (ret > 0) {
+ offset += ret;
+ } else if (errno != EWOULDBLOCK && errno != EAGAIN) {
+ perror("rrecv");
+ return ret;
+ }
+ }
+
+ return 0;
+}
+
+static int recv_xfer(int size, uint8_t marker)
+{
+ int ret;
+
+ while (*poll_byte != marker)
+ ;
+
+ if (verify) {
+ ret = verify_buf(buf, size - 1);
+ if (ret)
+ return ret;
+ }
+
+ return 0;
+}
+
+static int sync_test(void)
+{
+ int ret;
+
+ ret = dst_addr ? send_msg(16) : recv_msg(16);
+ if (ret)
+ return ret;
+
+ return dst_addr ? recv_msg(16) : send_msg(16);
+}
+
+static int run_test(void)
+{
+ int ret, i, t;
+ off_t offset;
+ uint8_t marker = 0;
+
+ poll_byte = buf + transfer_size - 1;
+ *poll_byte = -1;
+ offset = riomap(rs, buf, transfer_size, PROT_WRITE, 0, 0);
+ if (offset == -1) {
+ perror("riomap");
+ ret = -1;
+ goto out;
+ }
+ ret = sync_test();
+ if (ret)
+ goto out;
+
+ gettimeofday(&start, NULL);
+ for (i = 0; i < iterations; i++) {
+ if (dst_addr) {
+ for (t = 0; t < transfer_count - 1; t++) {
+ ret = send_xfer(transfer_size);
+ if (ret)
+ goto out;
+ }
+ *poll_byte = (uint8_t) marker++;
+ if (verify)
+ format_buf(buf, transfer_size - 1);
+ ret = send_xfer(transfer_size);
+ if (ret)
+ goto out;
+
+ ret = recv_xfer(transfer_size, marker++);
+ } else {
+ ret = recv_xfer(transfer_size, marker++);
+ if (ret)
+ goto out;
+
+ for (t = 0; t < transfer_count - 1; t++) {
+ ret = send_xfer(transfer_size);
+ if (ret)
+ goto out;
+ }
+ *poll_byte = (uint8_t) marker++;
+ if (verify)
+ format_buf(buf, transfer_size - 1);
+ ret = send_xfer(transfer_size);
+ }
+ if (ret)
+ goto out;
+ }
+ gettimeofday(&end, NULL);
+ show_perf();
+ ret = riounmap(rs, buf, transfer_size);
+
+out:
+ return ret;
+}
+
+static void set_options(int fd)
+{
+ int val;
+
+ if (buffer_size) {
+ rsetsockopt(fd, SOL_SOCKET, SO_SNDBUF, (void *) &buffer_size,
+ sizeof buffer_size);
+ rsetsockopt(fd, SOL_SOCKET, SO_RCVBUF, (void *) &buffer_size,
+ sizeof buffer_size);
+ } else {
+ val = 1 << 19;
+ rsetsockopt(fd, SOL_SOCKET, SO_SNDBUF, (void *) &val, sizeof val);
+ rsetsockopt(fd, SOL_SOCKET, SO_RCVBUF, (void *) &val, sizeof val);
+ }
+
+ val = 1;
+ rsetsockopt(fd, IPPROTO_TCP, TCP_NODELAY, (void *) &val, sizeof(val));
+ rsetsockopt(fd, SOL_RDMA, RDMA_IOMAPSIZE, (void *) &val, sizeof val);
+
+ if (flags & MSG_DONTWAIT)
+ rfcntl(fd, F_SETFL, O_NONBLOCK);
+
+ /* Inline size based on experimental data */
+ if (optimization == opt_latency) {
+ rsetsockopt(fd, SOL_RDMA, RDMA_INLINE, &inline_size,
+ sizeof inline_size);
+ } else if (optimization == opt_bandwidth) {
+ val = 0;
+ rsetsockopt(fd, SOL_RDMA, RDMA_INLINE, &val, sizeof val);
+ }
+}
+
+static int server_listen(void)
+{
+ struct rdma_addrinfo *rai = NULL;
+ struct addrinfo *ai;
+ int val, ret;
+
+ if (use_rgai) {
+ rai_hints.ai_flags |= RAI_PASSIVE;
+ ret = rdma_getaddrinfo(src_addr, port, &rai_hints, &rai);
+ } else {
+ ai_hints.ai_flags |= AI_PASSIVE;
+ ret = getaddrinfo(src_addr, port, &ai_hints, &ai);
+ }
+ if (ret) {
+ printf("getaddrinfo: %s\n", gai_strerror(ret));
+ return ret;
+ }
+
+ lrs = rai ? rsocket(rai->ai_family, SOCK_STREAM, 0) :
+ rsocket(ai->ai_family, SOCK_STREAM, 0);
+ if (lrs < 0) {
+ perror("rsocket");
+ ret = lrs;
+ goto free;
+ }
+
+ val = 1;
+ ret = rsetsockopt(lrs, SOL_SOCKET, SO_REUSEADDR, &val, sizeof val);
+ if (ret) {
+ perror("rsetsockopt SO_REUSEADDR");
+ goto close;
+ }
+
+ ret = rai ? rbind(lrs, rai->ai_src_addr, rai->ai_src_len) :
+ rbind(lrs, ai->ai_addr, ai->ai_addrlen);
+ if (ret) {
+ perror("rbind");
+ goto close;
+ }
+
+ ret = rlisten(lrs, 1);
+ if (ret)
+ perror("rlisten");
+
+close:
+ if (ret)
+ rclose(lrs);
+free:
+ if (rai)
+ rdma_freeaddrinfo(rai);
+ else
+ freeaddrinfo(ai);
+ return ret;
+}
+
+static int server_connect(void)
+{
+ struct pollfd fds;
+ int ret = 0;
+
+ set_options(lrs);
+ do {
+ if (use_async) {
+ fds.fd = lrs;
+ fds.events = POLLIN;
+
+ ret = do_poll(&fds, poll_timeout);
+ if (ret) {
+ perror("rpoll");
+ return ret;
+ }
+ }
+
+ rs = raccept(lrs, NULL, NULL);
+ } while (rs < 0 && (errno == EAGAIN || errno == EWOULDBLOCK));
+ if (rs < 0) {
+ perror("raccept");
+ return rs;
+ }
+
+ set_options(rs);
+ return ret;
+}
+
+static int client_connect(void)
+{
+ struct rdma_addrinfo *rai = NULL;
+ struct addrinfo *ai;
+ struct pollfd fds;
+ int ret, err;
+ socklen_t len;
+
+ ret = use_rgai ? rdma_getaddrinfo(dst_addr, port, &rai_hints, &rai) :
+ getaddrinfo(dst_addr, port, &ai_hints, &ai);
+ if (ret) {
+ printf("getaddrinfo: %s\n", gai_strerror(ret));
+ return ret;
+ }
+
+ rs = rai ? rsocket(rai->ai_family, SOCK_STREAM, 0) :
+ rsocket(ai->ai_family, SOCK_STREAM, 0);
+ if (rs < 0) {
+ perror("rsocket");
+ ret = rs;
+ goto free;
+ }
+
+ set_options(rs);
+ /* TODO: bind client to src_addr */
+
+ ret = rai ? rconnect(rs, rai->ai_dst_addr, rai->ai_dst_len) :
+ rconnect(rs, ai->ai_addr, ai->ai_addrlen);
+ if (ret && (errno != EINPROGRESS)) {
+ perror("rconnect");
+ goto close;
+ }
+
+ if (ret && (errno == EINPROGRESS)) {
+ fds.fd = rs;
+ fds.events = POLLOUT;
+ ret = do_poll(&fds, poll_timeout);
+ if (ret) {
+ perror("rpoll");
+ goto close;
+ }
+
+ len = sizeof err;
+ ret = rgetsockopt(rs, SOL_SOCKET, SO_ERROR, &err, &len);
+ if (ret)
+ goto close;
+ if (err) {
+ ret = -1;
+ errno = err;
+ perror("async rconnect");
+ }
+ }
+
+close:
+ if (ret)
+ rclose(rs);
+free:
+ if (rai)
+ rdma_freeaddrinfo(rai);
+ else
+ freeaddrinfo(ai);
+ return ret;
+}
+
+static int run(void)
+{
+ int i, ret = 0;
+
+ buf = malloc(!custom ? test_size[TEST_CNT - 1].size : transfer_size);
+ if (!buf) {
+ perror("malloc");
+ return -1;
+ }
+
+ if (!dst_addr) {
+ ret = server_listen();
+ if (ret)
+ goto free;
+ }
+
+ printf("%-10s%-8s%-8s%-8s%-8s%8s %10s%13s\n",
+ "name", "bytes", "xfers", "iters", "total", "time", "Gb/sec", "usec/xfer");
+ if (!custom) {
+ optimization = opt_latency;
+ ret = dst_addr ? client_connect() : server_connect();
+ if (ret)
+ goto free;
+
+ for (i = 0; i < TEST_CNT; i++) {
+ if (test_size[i].option > size_option)
+ continue;
+ init_latency_test(test_size[i].size);
+ run_test();
+ }
+ rshutdown(rs, SHUT_RDWR);
+ rclose(rs);
+
+ optimization = opt_bandwidth;
+ ret = dst_addr ? client_connect() : server_connect();
+ if (ret)
+ goto free;
+ for (i = 0; i < TEST_CNT; i++) {
+ if (test_size[i].option > size_option)
+ continue;
+ init_bandwidth_test(test_size[i].size);
+ run_test();
+ }
+ } else {
+ ret = dst_addr ? client_connect() : server_connect();
+ if (ret)
+ goto free;
+
+ ret = run_test();
+ }
+
+ rshutdown(rs, SHUT_RDWR);
+ rclose(rs);
+free:
+ free(buf);
+ return ret;
+}
+
+static int set_test_opt(const char *arg)
+{
+ if (strlen(arg) == 1) {
+ switch (arg[0]) {
+ case 'a':
+ use_async = 1;
+ break;
+ case 'b':
+ flags = (flags & ~MSG_DONTWAIT) | MSG_WAITALL;
+ break;
+ case 'n':
+ flags |= MSG_DONTWAIT;
+ break;
+ case 'v':
+ verify = 1;
+ break;
+ default:
+ return -1;
+ }
+ } else {
+ if (!strncasecmp("async", arg, 5)) {
+ use_async = 1;
+ } else if (!strncasecmp("block", arg, 5)) {
+ flags = (flags & ~MSG_DONTWAIT) | MSG_WAITALL;
+ } else if (!strncasecmp("nonblock", arg, 8)) {
+ flags |= MSG_DONTWAIT;
+ } else if (!strncasecmp("verify", arg, 6)) {
+ verify = 1;
+ } else {
+ return -1;
+ }
+ }
+ return 0;
+}
+
+int main(int argc, char **argv)
+{
+ int op, ret;
+
+ ai_hints.ai_socktype = SOCK_STREAM;
+ rai_hints.ai_port_space = RDMA_PS_TCP;
+ while ((op = getopt(argc, argv, "s:b:f:B:i:I:C:S:p:T:")) != -1) {
+ switch (op) {
+ case 's':
+ dst_addr = optarg;
+ break;
+ case 'b':
+ src_addr = optarg;
+ break;
+ case 'f':
+ if (!strncasecmp("ip", optarg, 2)) {
+ ai_hints.ai_flags = AI_NUMERICHOST;
+ } else if (!strncasecmp("gid", optarg, 3)) {
+ rai_hints.ai_flags = RAI_NUMERICHOST | RAI_FAMILY;
+ rai_hints.ai_family = AF_IB;
+ use_rgai = 1;
+ } else {
+ fprintf(stderr, "Warning: unknown address format\n");
+ }
+ break;
+ case 'B':
+ buffer_size = atoi(optarg);
+ break;
+ case 'i':
+ inline_size = atoi(optarg);
+ break;
+ case 'I':
+ custom = 1;
+ iterations = atoi(optarg);
+ break;
+ case 'C':
+ custom = 1;
+ transfer_count = atoi(optarg);
+ break;
+ case 'S':
+ if (!strncasecmp("all", optarg, 3)) {
+ size_option = 1;
+ } else {
+ custom = 1;
+ transfer_size = atoi(optarg);
+ }
+ break;
+ case 'p':
+ port = optarg;
+ break;
+ case 'T':
+ if (!set_test_opt(optarg))
+ break;
+ /* invalid option - fall through */
+ SWITCH_FALLTHROUGH;
+ default:
+ printf("usage: %s\n", argv[0]);
+ printf("\t[-s server_address]\n");
+ printf("\t[-b bind_address]\n");
+ printf("\t[-f address_format]\n");
+ printf("\t name, ip, ipv6, or gid\n");
+ printf("\t[-B buffer_size]\n");
+ printf("\t[-i inline_size]\n");
+ printf("\t[-I iterations]\n");
+ printf("\t[-C transfer_count]\n");
+ printf("\t[-S transfer_size or all]\n");
+ printf("\t[-p port_number]\n");
+ printf("\t[-T test_option]\n");
+ printf("\t a|async - asynchronous operation (use poll)\n");
+ printf("\t b|blocking - use blocking calls\n");
+ printf("\t n|nonblocking - use nonblocking calls\n");
+ printf("\t v|verify - verify data\n");
+ exit(1);
+ }
+ }
+
+ if (!(flags & MSG_DONTWAIT))
+ poll_timeout = -1;
+
+ ret = run();
+ return ret;
+}
diff --git a/contrib/ofed/librdmacm/examples/rping.c b/contrib/ofed/librdmacm/examples/rping.c
index 44f1232..1448162 100644
--- a/contrib/ofed/librdmacm/examples/rping.c
+++ b/contrib/ofed/librdmacm/examples/rping.c
@@ -30,23 +30,21 @@
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
-
+#define _GNU_SOURCE
+#include <infiniband/endian.h>
#include <getopt.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <errno.h>
#include <sys/types.h>
-#include <netinet/in.h>
#include <sys/socket.h>
#include <netdb.h>
#include <semaphore.h>
-#include <arpa/inet.h>
#include <pthread.h>
#include <inttypes.h>
-
+#include <libgen.h>
#include <rdma/rdma_cma.h>
-#include <infiniband/arch.h>
static int debug = 0;
#define DEBUG_LOG if (debug) printf
@@ -81,13 +79,14 @@ enum test_state {
RDMA_READ_COMPLETE,
RDMA_WRITE_ADV,
RDMA_WRITE_COMPLETE,
+ DISCONNECTED,
ERROR
};
struct rping_rdma_info {
- uint64_t buf;
- uint32_t rkey;
- uint32_t size;
+ __be64 buf;
+ __be32 rkey;
+ __be32 size;
};
/*
@@ -143,7 +142,8 @@ struct rping_cb {
sem_t sem;
struct sockaddr_storage sin;
- uint16_t port; /* dst port in NBO */
+ struct sockaddr_storage ssource;
+ __be16 port; /* dst port in NBO */
int verbose; /* verbose logging */
int count; /* ping count */
int size; /* ping data size */
@@ -216,11 +216,14 @@ static int rping_cma_event_handler(struct rdma_cm_id *cma_id,
case RDMA_CM_EVENT_DISCONNECTED:
fprintf(stderr, "%s DISCONNECT EVENT...\n",
cb->server ? "server" : "client");
+ cb->state = DISCONNECTED;
sem_post(&cb->sem);
break;
case RDMA_CM_EVENT_DEVICE_REMOVAL:
fprintf(stderr, "cma detected device removal!!!!\n");
+ cb->state = ERROR;
+ sem_post(&cb->sem);
ret = -1;
break;
@@ -240,9 +243,9 @@ static int server_recv(struct rping_cb *cb, struct ibv_wc *wc)
return -1;
}
- cb->remote_rkey = ntohl(cb->recv_buf.rkey);
- cb->remote_addr = ntohll(cb->recv_buf.buf);
- cb->remote_len = ntohl(cb->recv_buf.size);
+ cb->remote_rkey = be32toh(cb->recv_buf.rkey);
+ cb->remote_addr = be64toh(cb->recv_buf.buf);
+ cb->remote_len = be32toh(cb->recv_buf.size);
DEBUG_LOG("Received rkey %x addr %" PRIx64 " len %d from peer\n",
cb->remote_rkey, cb->remote_addr, cb->remote_len);
@@ -274,14 +277,20 @@ static int rping_cq_event_handler(struct rping_cb *cb)
struct ibv_wc wc;
struct ibv_recv_wr *bad_wr;
int ret;
+ int flushed = 0;
while ((ret = ibv_poll_cq(cb->cq, 1, &wc)) == 1) {
ret = 0;
if (wc.status) {
- if (wc.status != IBV_WC_WR_FLUSH_ERR)
- fprintf(stderr, "cq completion failed status %d\n",
- wc.status);
+ if (wc.status == IBV_WC_WR_FLUSH_ERR) {
+ flushed = 1;
+ continue;
+
+ }
+ fprintf(stderr,
+ "cq completion failed status %d\n",
+ wc.status);
ret = -1;
goto error;
}
@@ -330,7 +339,7 @@ static int rping_cq_event_handler(struct rping_cb *cb)
fprintf(stderr, "poll error %d\n", ret);
goto error;
}
- return 0;
+ return flushed;
error:
cb->state = ERROR;
@@ -340,16 +349,11 @@ error:
static int rping_accept(struct rping_cb *cb)
{
- struct rdma_conn_param conn_param;
int ret;
DEBUG_LOG("accepting client connection request\n");
- memset(&conn_param, 0, sizeof conn_param);
- conn_param.responder_resources = 1;
- conn_param.initiator_depth = 1;
-
- ret = rdma_accept(cb->child_cm_id, &conn_param);
+ ret = rdma_accept(cb->child_cm_id, NULL);
if (ret) {
perror("rdma_accept");
return ret;
@@ -616,12 +620,12 @@ static void rping_format_send(struct rping_cb *cb, char *buf, struct ibv_mr *mr)
{
struct rping_rdma_info *info = &cb->send_buf;
- info->buf = htonll((uint64_t) (unsigned long) buf);
- info->rkey = htonl(mr->rkey);
- info->size = htonl(cb->size);
+ info->buf = htobe64((uint64_t) (unsigned long) buf);
+ info->rkey = htobe32(mr->rkey);
+ info->size = htobe32(cb->size);
DEBUG_LOG("RDMA addr %" PRIx64" rkey %x len %d\n",
- ntohll(info->buf), ntohl(info->rkey), ntohl(info->size));
+ be64toh(info->buf), be32toh(info->rkey), be32toh(info->size));
}
static int rping_test_server(struct rping_cb *cb)
@@ -721,7 +725,7 @@ static int rping_test_server(struct rping_cb *cb)
DEBUG_LOG("server posted go ahead\n");
}
- return ret;
+ return (cb->state == DISCONNECTED) ? 0 : ret;
}
static int rping_bind_server(struct rping_cb *cb)
@@ -755,6 +759,7 @@ static struct rping_cb *clone_cb(struct rping_cb *listening_cb)
struct rping_cb *cb = malloc(sizeof *cb);
if (!cb)
return NULL;
+ memset(cb, 0, sizeof *cb);
*cb = *listening_cb;
cb->child_cm_id->context = cb;
return cb;
@@ -789,7 +794,11 @@ static void *rping_persistent_server_thread(void *arg)
goto err2;
}
- pthread_create(&cb->cqthread, NULL, cq_thread, cb);
+ ret = pthread_create(&cb->cqthread, NULL, cq_thread, cb);
+ if (ret) {
+ perror("pthread_create");
+ goto err2;
+ }
ret = rping_accept(cb);
if (ret) {
@@ -821,11 +830,27 @@ static int rping_run_persistent_server(struct rping_cb *listening_cb)
{
int ret;
struct rping_cb *cb;
+ pthread_attr_t attr;
ret = rping_bind_server(listening_cb);
if (ret)
return ret;
+ /*
+ * Set persistent server threads to DEATCHED state so
+ * they release all their resources when they exit.
+ */
+ ret = pthread_attr_init(&attr);
+ if (ret) {
+ perror("pthread_attr_init");
+ return ret;
+ }
+ ret = pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
+ if (ret) {
+ perror("pthread_attr_setdetachstate");
+ return ret;
+ }
+
while (1) {
sem_wait(&listening_cb->sem);
if (listening_cb->state != CONNECT_REQUEST) {
@@ -837,7 +862,12 @@ static int rping_run_persistent_server(struct rping_cb *listening_cb)
cb = clone_cb(listening_cb);
if (!cb)
return -1;
- pthread_create(&cb->persistent_server_thread, NULL, rping_persistent_server_thread, cb);
+
+ ret = pthread_create(&cb->persistent_server_thread, &attr, rping_persistent_server_thread, cb);
+ if (ret) {
+ perror("pthread_create");
+ return ret;
+ }
}
return 0;
}
@@ -876,7 +906,11 @@ static int rping_run_server(struct rping_cb *cb)
goto err2;
}
- pthread_create(&cb->cqthread, NULL, cq_thread, cb);
+ ret = pthread_create(&cb->cqthread, NULL, cq_thread, cb);
+ if (ret) {
+ perror("pthread_create");
+ goto err2;
+ }
ret = rping_accept(cb);
if (ret) {
@@ -884,7 +918,14 @@ static int rping_run_server(struct rping_cb *cb)
goto err2;
}
- rping_test_server(cb);
+ ret = rping_test_server(cb);
+ if (ret) {
+ fprintf(stderr, "rping server failed: %d\n", ret);
+ goto err3;
+ }
+
+ ret = 0;
+err3:
rdma_disconnect(cb->child_cm_id);
pthread_join(cb->cqthread, NULL);
rdma_destroy_id(cb->child_cm_id);
@@ -907,7 +948,7 @@ static int rping_test_client(struct rping_cb *cb)
cb->state = RDMA_READ_ADV;
/* Put some ascii text in the buffer. */
- cc = sprintf(cb->start_buf, RPING_MSG_FMT, ping);
+ cc = snprintf(cb->start_buf, cb->size, RPING_MSG_FMT, ping);
for (i = cc, c = start; i < cb->size; i++) {
cb->start_buf[i] = c;
c++;
@@ -962,7 +1003,7 @@ static int rping_test_client(struct rping_cb *cb)
printf("ping data: %s\n", cb->rdma_buf);
}
- return ret;
+ return (cb->state == DISCONNECTED) ? 0 : ret;
}
static int rping_connect_client(struct rping_cb *cb)
@@ -973,7 +1014,7 @@ static int rping_connect_client(struct rping_cb *cb)
memset(&conn_param, 0, sizeof conn_param);
conn_param.responder_resources = 1;
conn_param.initiator_depth = 1;
- conn_param.retry_count = 10;
+ conn_param.retry_count = 7;
ret = rdma_connect(cb->cm_id, &conn_param);
if (ret) {
@@ -1000,7 +1041,12 @@ static int rping_bind_client(struct rping_cb *cb)
else
((struct sockaddr_in6 *) &cb->sin)->sin6_port = cb->port;
- ret = rdma_resolve_addr(cb->cm_id, NULL, (struct sockaddr *) &cb->sin, 2000);
+ if (cb->ssource.ss_family)
+ ret = rdma_resolve_addr(cb->cm_id, (struct sockaddr *) &cb->ssource,
+ (struct sockaddr *) &cb->sin, 2000);
+ else
+ ret = rdma_resolve_addr(cb->cm_id, NULL, (struct sockaddr *) &cb->sin, 2000);
+
if (ret) {
perror("rdma_resolve_addr");
return ret;
@@ -1044,7 +1090,11 @@ static int rping_run_client(struct rping_cb *cb)
goto err2;
}
- pthread_create(&cb->cqthread, NULL, cq_thread, cb);
+ ret = pthread_create(&cb->cqthread, NULL, cq_thread, cb);
+ if (ret) {
+ perror("pthread_create");
+ goto err2;
+ }
ret = rping_connect_client(cb);
if (ret) {
@@ -1057,6 +1107,7 @@ static int rping_run_client(struct rping_cb *cb)
fprintf(stderr, "rping client failed: %d\n", ret);
goto err4;
}
+
ret = 0;
err4:
rdma_disconnect(cb->cm_id);
@@ -1077,7 +1128,7 @@ static int get_addr(char *dst, struct sockaddr *addr)
ret = getaddrinfo(dst, NULL, NULL, &res);
if (ret) {
- printf("getaddrinfo failed - invalid hostname or IP address\n");
+ printf("getaddrinfo failed (%s) - invalid hostname or IP address\n", gai_strerror(ret));
return ret;
}
@@ -1092,13 +1143,14 @@ static int get_addr(char *dst, struct sockaddr *addr)
return ret;
}
-static void usage(char *name)
+static void usage(const char *name)
{
printf("%s -s [-vVd] [-S size] [-C count] [-a addr] [-p port]\n",
- name);
- printf("%s -c [-vVd] [-S size] [-C count] -a addr [-p port]\n",
- name);
+ basename(name));
+ printf("%s -c [-vVd] [-S size] [-C count] [-I addr] -a addr [-p port]\n",
+ basename(name));
printf("\t-c\t\tclient side\n");
+ printf("\t-I\t\tSource address to bind to for client.\n");
printf("\t-s\t\tserver side. To bind to any address with IPv6 use -a ::0\n");
printf("\t-v\t\tdisplay ping data to stdout\n");
printf("\t-V\t\tvalidate ping data\n");
@@ -1126,20 +1178,23 @@ int main(int argc, char *argv[])
cb->state = IDLE;
cb->size = 64;
cb->sin.ss_family = PF_INET;
- cb->port = htons(7174);
+ cb->port = htobe16(7174);
sem_init(&cb->sem, 0, 0);
opterr = 0;
- while ((op=getopt(argc, argv, "a:Pp:C:S:t:scvVd")) != -1) {
+ while ((op=getopt(argc, argv, "a:I:Pp:C:S:t:scvVd")) != -1) {
switch (op) {
case 'a':
ret = get_addr(optarg, (struct sockaddr *) &cb->sin);
break;
+ case 'I':
+ ret = get_addr(optarg, (struct sockaddr *) &cb->ssource);
+ break;
case 'P':
persistent_server = 1;
break;
case 'p':
- cb->port = htons(atoi(optarg));
+ cb->port = htobe16(atoi(optarg));
DEBUG_LOG("port %d\n", (int) atoi(optarg));
break;
case 's':
@@ -1155,9 +1210,8 @@ int main(int argc, char *argv[])
if ((cb->size < RPING_MIN_BUFSIZE) ||
(cb->size > (RPING_BUFSIZE - 1))) {
fprintf(stderr, "Invalid size %d "
- "(valid range is %d to %d)\n",
- (int)cb->size, (int)(RPING_MIN_BUFSIZE),
- (int)(RPING_BUFSIZE));
+ "(valid range is %zd to %d)\n",
+ cb->size, RPING_MIN_BUFSIZE, RPING_BUFSIZE);
ret = EINVAL;
} else
DEBUG_LOG("size %d\n", (int) atoi(optarg));
@@ -1200,6 +1254,7 @@ int main(int argc, char *argv[])
cb->cm_channel = rdma_create_event_channel();
if (!cb->cm_channel) {
perror("rdma_create_event_channel");
+ ret = errno;
goto out;
}
@@ -1210,15 +1265,20 @@ int main(int argc, char *argv[])
}
DEBUG_LOG("created cm_id %p\n", cb->cm_id);
- pthread_create(&cb->cmthread, NULL, cm_thread, cb);
+ ret = pthread_create(&cb->cmthread, NULL, cm_thread, cb);
+ if (ret) {
+ perror("pthread_create");
+ goto out2;
+ }
if (cb->server) {
if (persistent_server)
ret = rping_run_persistent_server(cb);
else
ret = rping_run_server(cb);
- } else
+ } else {
ret = rping_run_client(cb);
+ }
DEBUG_LOG("destroy cm_id %p\n", cb->cm_id);
rdma_destroy_id(cb->cm_id);
diff --git a/contrib/ofed/librdmacm/examples/rstream.c b/contrib/ofed/librdmacm/examples/rstream.c
new file mode 100644
index 0000000..7523269
--- /dev/null
+++ b/contrib/ofed/librdmacm/examples/rstream.c
@@ -0,0 +1,707 @@
+/*
+ * Copyright (c) 2011-2012 Intel Corporation. All rights reserved.
+ * Copyright (c) 2014-2015 Mellanox Technologies LTD. All rights reserved.
+ *
+ * This software is available to you under the OpenIB.org BSD license
+ * below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AWV
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <strings.h>
+#include <errno.h>
+#include <getopt.h>
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <sys/time.h>
+#include <sys/wait.h>
+#include <netdb.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <netinet/tcp.h>
+
+#include <rdma/rdma_cma.h>
+#include <rdma/rsocket.h>
+#include <util/compiler.h>
+#include "common.h"
+
+struct test_size_param {
+ int size;
+ int option;
+};
+
+static struct test_size_param test_size[] = {
+ { 1 << 6, 0 },
+ { 1 << 7, 1 }, { (1 << 7) + (1 << 6), 1},
+ { 1 << 8, 1 }, { (1 << 8) + (1 << 7), 1},
+ { 1 << 9, 1 }, { (1 << 9) + (1 << 8), 1},
+ { 1 << 10, 1 }, { (1 << 10) + (1 << 9), 1},
+ { 1 << 11, 1 }, { (1 << 11) + (1 << 10), 1},
+ { 1 << 12, 0 }, { (1 << 12) + (1 << 11), 1},
+ { 1 << 13, 1 }, { (1 << 13) + (1 << 12), 1},
+ { 1 << 14, 1 }, { (1 << 14) + (1 << 13), 1},
+ { 1 << 15, 1 }, { (1 << 15) + (1 << 14), 1},
+ { 1 << 16, 0 }, { (1 << 16) + (1 << 15), 1},
+ { 1 << 17, 1 }, { (1 << 17) + (1 << 16), 1},
+ { 1 << 18, 1 }, { (1 << 18) + (1 << 17), 1},
+ { 1 << 19, 1 }, { (1 << 19) + (1 << 18), 1},
+ { 1 << 20, 0 }, { (1 << 20) + (1 << 19), 1},
+ { 1 << 21, 1 }, { (1 << 21) + (1 << 20), 1},
+ { 1 << 22, 1 }, { (1 << 22) + (1 << 21), 1},
+};
+#define TEST_CNT (sizeof test_size / sizeof test_size[0])
+
+static int rs, lrs;
+static int use_async;
+static int use_rgai;
+static int verify;
+static int flags = MSG_DONTWAIT;
+static int poll_timeout = 0;
+static int custom;
+static int use_fork;
+static pid_t fork_pid;
+static enum rs_optimization optimization;
+static int size_option;
+static int iterations = 1;
+static int transfer_size = 1000;
+static int transfer_count = 1000;
+static int buffer_size, inline_size = 64;
+static char test_name[10] = "custom";
+static const char *port = "7471";
+static int keepalive;
+static char *dst_addr;
+static char *src_addr;
+static struct timeval start, end;
+static void *buf;
+static struct rdma_addrinfo rai_hints;
+static struct addrinfo ai_hints;
+
+static void show_perf(void)
+{
+ char str[32];
+ float usec;
+ long long bytes;
+
+ usec = (end.tv_sec - start.tv_sec) * 1000000 + (end.tv_usec - start.tv_usec);
+ bytes = (long long) iterations * transfer_count * transfer_size * 2;
+
+ /* name size transfers iterations bytes seconds Gb/sec usec/xfer */
+ printf("%-10s", test_name);
+ size_str(str, sizeof str, transfer_size);
+ printf("%-8s", str);
+ cnt_str(str, sizeof str, transfer_count);
+ printf("%-8s", str);
+ cnt_str(str, sizeof str, iterations);
+ printf("%-8s", str);
+ size_str(str, sizeof str, bytes);
+ printf("%-8s", str);
+ printf("%8.2fs%10.2f%11.2f\n",
+ usec / 1000000., (bytes * 8) / (1000. * usec),
+ (usec / iterations) / (transfer_count * 2));
+}
+
+static void init_latency_test(int size)
+{
+ char sstr[5];
+
+ size_str(sstr, sizeof sstr, size);
+ snprintf(test_name, sizeof test_name, "%s_lat", sstr);
+ transfer_count = 1;
+ transfer_size = size;
+ iterations = size_to_count(transfer_size);
+}
+
+static void init_bandwidth_test(int size)
+{
+ char sstr[5];
+
+ size_str(sstr, sizeof sstr, size);
+ snprintf(test_name, sizeof test_name, "%s_bw", sstr);
+ iterations = 1;
+ transfer_size = size;
+ transfer_count = size_to_count(transfer_size);
+}
+
+static int send_xfer(int size)
+{
+ struct pollfd fds;
+ int offset, ret;
+
+ if (verify)
+ format_buf(buf, size);
+
+ if (use_async) {
+ fds.fd = rs;
+ fds.events = POLLOUT;
+ }
+
+ for (offset = 0; offset < size; ) {
+ if (use_async) {
+ ret = do_poll(&fds, poll_timeout);
+ if (ret)
+ return ret;
+ }
+
+ ret = rs_send(rs, buf + offset, size - offset, flags);
+ if (ret > 0) {
+ offset += ret;
+ } else if (errno != EWOULDBLOCK && errno != EAGAIN) {
+ perror("rsend");
+ return ret;
+ }
+ }
+
+ return 0;
+}
+
+static int recv_xfer(int size)
+{
+ struct pollfd fds;
+ int offset, ret;
+
+ if (use_async) {
+ fds.fd = rs;
+ fds.events = POLLIN;
+ }
+
+ for (offset = 0; offset < size; ) {
+ if (use_async) {
+ ret = do_poll(&fds, poll_timeout);
+ if (ret)
+ return ret;
+ }
+
+ ret = rs_recv(rs, buf + offset, size - offset, flags);
+ if (ret > 0) {
+ offset += ret;
+ } else if (errno != EWOULDBLOCK && errno != EAGAIN) {
+ perror("rrecv");
+ return ret;
+ }
+ }
+
+ if (verify) {
+ ret = verify_buf(buf, size);
+ if (ret)
+ return ret;
+ }
+
+ return 0;
+}
+
+static int sync_test(void)
+{
+ int ret;
+
+ ret = dst_addr ? send_xfer(16) : recv_xfer(16);
+ if (ret)
+ return ret;
+
+ return dst_addr ? recv_xfer(16) : send_xfer(16);
+}
+
+static int run_test(void)
+{
+ int ret, i, t;
+
+ ret = sync_test();
+ if (ret)
+ goto out;
+
+ gettimeofday(&start, NULL);
+ for (i = 0; i < iterations; i++) {
+ for (t = 0; t < transfer_count; t++) {
+ ret = dst_addr ? send_xfer(transfer_size) :
+ recv_xfer(transfer_size);
+ if (ret)
+ goto out;
+ }
+
+ for (t = 0; t < transfer_count; t++) {
+ ret = dst_addr ? recv_xfer(transfer_size) :
+ send_xfer(transfer_size);
+ if (ret)
+ goto out;
+ }
+ }
+ gettimeofday(&end, NULL);
+ show_perf();
+ ret = 0;
+
+out:
+ return ret;
+}
+
+static void set_keepalive(int fd)
+{
+ int optval;
+ socklen_t optlen = sizeof(optlen);
+
+ optval = 1;
+ if (rs_setsockopt(fd, SOL_SOCKET, SO_KEEPALIVE, &optval, optlen)) {
+ perror("rsetsockopt SO_KEEPALIVE");
+ return;
+ }
+
+ optval = keepalive;
+ if (rs_setsockopt(fd, IPPROTO_TCP, TCP_KEEPIDLE, &optval, optlen))
+ perror("rsetsockopt TCP_KEEPIDLE");
+
+ if (!(rs_getsockopt(fd, SOL_SOCKET, SO_KEEPALIVE, &optval, &optlen)))
+ printf("Keepalive: %s\n", (optval ? "ON" : "OFF"));
+
+ if (!(rs_getsockopt(fd, IPPROTO_TCP, TCP_KEEPIDLE, &optval, &optlen)))
+ printf(" time: %i\n", optval);
+}
+
+static void set_options(int fd)
+{
+ int val;
+
+ if (buffer_size) {
+ rs_setsockopt(fd, SOL_SOCKET, SO_SNDBUF, (void *) &buffer_size,
+ sizeof buffer_size);
+ rs_setsockopt(fd, SOL_SOCKET, SO_RCVBUF, (void *) &buffer_size,
+ sizeof buffer_size);
+ } else {
+ val = 1 << 19;
+ rs_setsockopt(fd, SOL_SOCKET, SO_SNDBUF, (void *) &val, sizeof val);
+ rs_setsockopt(fd, SOL_SOCKET, SO_RCVBUF, (void *) &val, sizeof val);
+ }
+
+ val = 1;
+ rs_setsockopt(fd, IPPROTO_TCP, TCP_NODELAY, (void *) &val, sizeof(val));
+
+ if (flags & MSG_DONTWAIT)
+ rs_fcntl(fd, F_SETFL, O_NONBLOCK);
+
+ if (use_rs) {
+ /* Inline size based on experimental data */
+ if (optimization == opt_latency) {
+ rs_setsockopt(fd, SOL_RDMA, RDMA_INLINE, &inline_size,
+ sizeof inline_size);
+ } else if (optimization == opt_bandwidth) {
+ val = 0;
+ rs_setsockopt(fd, SOL_RDMA, RDMA_INLINE, &val, sizeof val);
+ }
+ }
+
+ if (keepalive)
+ set_keepalive(fd);
+}
+
+static int server_listen(void)
+{
+ struct rdma_addrinfo *rai = NULL;
+ struct addrinfo *ai;
+ int val, ret;
+
+ if (use_rgai) {
+ rai_hints.ai_flags |= RAI_PASSIVE;
+ ret = rdma_getaddrinfo(src_addr, port, &rai_hints, &rai);
+ } else {
+ ai_hints.ai_flags |= AI_PASSIVE;
+ ret = getaddrinfo(src_addr, port, &ai_hints, &ai);
+ }
+ if (ret) {
+ printf("getaddrinfo: %s\n", gai_strerror(ret));
+ return ret;
+ }
+
+ lrs = rai ? rs_socket(rai->ai_family, SOCK_STREAM, 0) :
+ rs_socket(ai->ai_family, SOCK_STREAM, 0);
+ if (lrs < 0) {
+ perror("rsocket");
+ ret = lrs;
+ goto free;
+ }
+
+ val = 1;
+ ret = rs_setsockopt(lrs, SOL_SOCKET, SO_REUSEADDR, &val, sizeof val);
+ if (ret) {
+ perror("rsetsockopt SO_REUSEADDR");
+ goto close;
+ }
+
+ ret = rai ? rs_bind(lrs, rai->ai_src_addr, rai->ai_src_len) :
+ rs_bind(lrs, ai->ai_addr, ai->ai_addrlen);
+ if (ret) {
+ perror("rbind");
+ goto close;
+ }
+
+ ret = rs_listen(lrs, 1);
+ if (ret)
+ perror("rlisten");
+
+close:
+ if (ret)
+ rs_close(lrs);
+free:
+ if (rai)
+ rdma_freeaddrinfo(rai);
+ else
+ freeaddrinfo(ai);
+ return ret;
+}
+
+static int server_connect(void)
+{
+ struct pollfd fds;
+ int ret = 0;
+
+ set_options(lrs);
+ do {
+ if (use_async) {
+ fds.fd = lrs;
+ fds.events = POLLIN;
+
+ ret = do_poll(&fds, poll_timeout);
+ if (ret) {
+ perror("rpoll");
+ return ret;
+ }
+ }
+
+ rs = rs_accept(lrs, NULL, NULL);
+ } while (rs < 0 && (errno == EAGAIN || errno == EWOULDBLOCK));
+ if (rs < 0) {
+ perror("raccept");
+ return rs;
+ }
+
+ if (use_fork)
+ fork_pid = fork();
+ if (!fork_pid)
+ set_options(rs);
+ return ret;
+}
+
+static int client_connect(void)
+{
+ struct rdma_addrinfo *rai = NULL, *rai_src = NULL;
+ struct addrinfo *ai, *ai_src;
+ struct pollfd fds;
+ int ret, err;
+ socklen_t len;
+
+ ret = use_rgai ? rdma_getaddrinfo(dst_addr, port, &rai_hints, &rai) :
+ getaddrinfo(dst_addr, port, &ai_hints, &ai);
+
+ if (ret) {
+ printf("getaddrinfo: %s\n", gai_strerror(ret));
+ return ret;
+ }
+
+ if (src_addr) {
+ if (use_rgai) {
+ rai_hints.ai_flags |= RAI_PASSIVE;
+ ret = rdma_getaddrinfo(src_addr, port, &rai_hints, &rai_src);
+ } else {
+ ai_hints.ai_flags |= AI_PASSIVE;
+ ret = getaddrinfo(src_addr, port, &ai_hints, &ai_src);
+ }
+ if (ret) {
+ printf("getaddrinfo src_addr: %s\n", gai_strerror(ret));
+ return ret;
+ }
+ }
+
+ rs = rai ? rs_socket(rai->ai_family, SOCK_STREAM, 0) :
+ rs_socket(ai->ai_family, SOCK_STREAM, 0);
+ if (rs < 0) {
+ perror("rsocket");
+ ret = rs;
+ goto free;
+ }
+
+ set_options(rs);
+
+ if (src_addr) {
+ ret = rai ? rs_bind(rs, rai_src->ai_src_addr, rai_src->ai_src_len) :
+ rs_bind(rs, ai_src->ai_addr, ai_src->ai_addrlen);
+ if (ret) {
+ perror("rbind");
+ goto close;
+ }
+ }
+
+ if (rai && rai->ai_route) {
+ ret = rs_setsockopt(rs, SOL_RDMA, RDMA_ROUTE, rai->ai_route,
+ rai->ai_route_len);
+ if (ret) {
+ perror("rsetsockopt RDMA_ROUTE");
+ goto close;
+ }
+ }
+
+ ret = rai ? rs_connect(rs, rai->ai_dst_addr, rai->ai_dst_len) :
+ rs_connect(rs, ai->ai_addr, ai->ai_addrlen);
+ if (ret && (errno != EINPROGRESS)) {
+ perror("rconnect");
+ goto close;
+ }
+
+ if (ret && (errno == EINPROGRESS)) {
+ fds.fd = rs;
+ fds.events = POLLOUT;
+ ret = do_poll(&fds, poll_timeout);
+ if (ret) {
+ perror("rpoll");
+ goto close;
+ }
+
+ len = sizeof err;
+ ret = rs_getsockopt(rs, SOL_SOCKET, SO_ERROR, &err, &len);
+ if (ret)
+ goto close;
+ if (err) {
+ ret = -1;
+ errno = err;
+ perror("async rconnect");
+ }
+ }
+
+close:
+ if (ret)
+ rs_close(rs);
+free:
+ if (rai)
+ rdma_freeaddrinfo(rai);
+ else
+ freeaddrinfo(ai);
+ return ret;
+}
+
+static int run(void)
+{
+ int i, ret = 0;
+
+ buf = malloc(!custom ? test_size[TEST_CNT - 1].size : transfer_size);
+ if (!buf) {
+ perror("malloc");
+ return -1;
+ }
+
+ if (!dst_addr) {
+ ret = server_listen();
+ if (ret)
+ goto free;
+ }
+
+ printf("%-10s%-8s%-8s%-8s%-8s%8s %10s%13s\n",
+ "name", "bytes", "xfers", "iters", "total", "time", "Gb/sec", "usec/xfer");
+ if (!custom) {
+ optimization = opt_latency;
+ ret = dst_addr ? client_connect() : server_connect();
+ if (ret)
+ goto free;
+
+ for (i = 0; i < TEST_CNT && !fork_pid; i++) {
+ if (test_size[i].option > size_option)
+ continue;
+ init_latency_test(test_size[i].size);
+ run_test();
+ }
+ if (fork_pid)
+ waitpid(fork_pid, NULL, 0);
+ else
+ rs_shutdown(rs, SHUT_RDWR);
+ rs_close(rs);
+
+ if (!dst_addr && use_fork && !fork_pid)
+ goto free;
+
+ optimization = opt_bandwidth;
+ ret = dst_addr ? client_connect() : server_connect();
+ if (ret)
+ goto free;
+ for (i = 0; i < TEST_CNT && !fork_pid; i++) {
+ if (test_size[i].option > size_option)
+ continue;
+ init_bandwidth_test(test_size[i].size);
+ run_test();
+ }
+ } else {
+ ret = dst_addr ? client_connect() : server_connect();
+ if (ret)
+ goto free;
+
+ if (!fork_pid)
+ ret = run_test();
+ }
+
+ if (fork_pid)
+ waitpid(fork_pid, NULL, 0);
+ else
+ rs_shutdown(rs, SHUT_RDWR);
+ rs_close(rs);
+free:
+ free(buf);
+ return ret;
+}
+
+static int set_test_opt(const char *arg)
+{
+ if (strlen(arg) == 1) {
+ switch (arg[0]) {
+ case 's':
+ use_rs = 0;
+ break;
+ case 'a':
+ use_async = 1;
+ break;
+ case 'b':
+ flags = (flags & ~MSG_DONTWAIT) | MSG_WAITALL;
+ break;
+ case 'f':
+ use_fork = 1;
+ use_rs = 0;
+ break;
+ case 'n':
+ flags |= MSG_DONTWAIT;
+ break;
+ case 'r':
+ use_rgai = 1;
+ break;
+ case 'v':
+ verify = 1;
+ break;
+ default:
+ return -1;
+ }
+ } else {
+ if (!strncasecmp("socket", arg, 6)) {
+ use_rs = 0;
+ } else if (!strncasecmp("async", arg, 5)) {
+ use_async = 1;
+ } else if (!strncasecmp("block", arg, 5)) {
+ flags = (flags & ~MSG_DONTWAIT) | MSG_WAITALL;
+ } else if (!strncasecmp("nonblock", arg, 8)) {
+ flags |= MSG_DONTWAIT;
+ } else if (!strncasecmp("resolve", arg, 7)) {
+ use_rgai = 1;
+ } else if (!strncasecmp("verify", arg, 6)) {
+ verify = 1;
+ } else if (!strncasecmp("fork", arg, 4)) {
+ use_fork = 1;
+ use_rs = 0;
+ } else {
+ return -1;
+ }
+ }
+ return 0;
+}
+
+int main(int argc, char **argv)
+{
+ int op, ret;
+
+ ai_hints.ai_socktype = SOCK_STREAM;
+ rai_hints.ai_port_space = RDMA_PS_TCP;
+ while ((op = getopt(argc, argv, "s:b:f:B:i:I:C:S:p:k:T:")) != -1) {
+ switch (op) {
+ case 's':
+ dst_addr = optarg;
+ break;
+ case 'b':
+ src_addr = optarg;
+ break;
+ case 'f':
+ if (!strncasecmp("ip", optarg, 2)) {
+ ai_hints.ai_flags = AI_NUMERICHOST;
+ } else if (!strncasecmp("gid", optarg, 3)) {
+ rai_hints.ai_flags = RAI_NUMERICHOST | RAI_FAMILY;
+ rai_hints.ai_family = AF_IB;
+ use_rgai = 1;
+ } else {
+ fprintf(stderr, "Warning: unknown address format\n");
+ }
+ break;
+ case 'B':
+ buffer_size = atoi(optarg);
+ break;
+ case 'i':
+ inline_size = atoi(optarg);
+ break;
+ case 'I':
+ custom = 1;
+ iterations = atoi(optarg);
+ break;
+ case 'C':
+ custom = 1;
+ transfer_count = atoi(optarg);
+ break;
+ case 'S':
+ if (!strncasecmp("all", optarg, 3)) {
+ size_option = 1;
+ } else {
+ custom = 1;
+ transfer_size = atoi(optarg);
+ }
+ break;
+ case 'p':
+ port = optarg;
+ break;
+ case 'k':
+ keepalive = atoi(optarg);
+ break;
+ case 'T':
+ if (!set_test_opt(optarg))
+ break;
+ /* invalid option - fall through */
+ SWITCH_FALLTHROUGH;
+ default:
+ printf("usage: %s\n", argv[0]);
+ printf("\t[-s server_address]\n");
+ printf("\t[-b bind_address]\n");
+ printf("\t[-f address_format]\n");
+ printf("\t name, ip, ipv6, or gid\n");
+ printf("\t[-B buffer_size]\n");
+ printf("\t[-i inline_size]\n");
+ printf("\t[-I iterations]\n");
+ printf("\t[-C transfer_count]\n");
+ printf("\t[-S transfer_size or all]\n");
+ printf("\t[-p port_number]\n");
+ printf("\t[-k keepalive_time]\n");
+ printf("\t[-T test_option]\n");
+ printf("\t s|sockets - use standard tcp/ip sockets\n");
+ printf("\t a|async - asynchronous operation (use poll)\n");
+ printf("\t b|blocking - use blocking calls\n");
+ printf("\t f|fork - fork server processing\n");
+ printf("\t n|nonblocking - use nonblocking calls\n");
+ printf("\t r|resolve - use rdma cm to resolve address\n");
+ printf("\t v|verify - verify data\n");
+ exit(1);
+ }
+ }
+
+ if (!(flags & MSG_DONTWAIT))
+ poll_timeout = -1;
+
+ ret = run();
+ return ret;
+}
diff --git a/contrib/ofed/librdmacm/examples/udaddy.c b/contrib/ofed/librdmacm/examples/udaddy.c
index 637306a..b1ac90c 100644
--- a/contrib/ofed/librdmacm/examples/udaddy.c
+++ b/contrib/ofed/librdmacm/examples/udaddy.c
@@ -37,13 +37,12 @@
#include <stdio.h>
#include <errno.h>
#include <sys/types.h>
-#include <netinet/in.h>
#include <sys/socket.h>
#include <netdb.h>
-#include <byteswap.h>
#include <getopt.h>
#include <rdma/rdma_cma.h>
+#include "common.h"
struct cmatest_node {
int id;
@@ -64,22 +63,19 @@ struct cmatest {
int conn_index;
int connects_left;
- struct sockaddr_in dst_in;
- struct sockaddr *dst_addr;
- struct sockaddr_in src_in;
- struct sockaddr *src_addr;
+ struct rdma_addrinfo *rai;
};
static struct cmatest test;
static int connections = 1;
static int message_size = 100;
static int message_count = 10;
-static uint16_t port = 7174;
+static const char *port = "7174";
static uint8_t set_tos = 0;
static uint8_t tos;
static char *dst_addr;
static char *src_addr;
-static enum rdma_port_space port_space = RDMA_PS_UDP;
+static struct rdma_addrinfo hints;
static int create_message(struct cmatest_node *node)
{
@@ -139,7 +135,7 @@ static int init_node(struct cmatest_node *node)
}
cqe = message_count ? message_count * 2 : 2;
- node->cq = ibv_create_cq(node->cma_id->verbs, cqe, node, 0, 0);
+ node->cq = ibv_create_cq(node->cma_id->verbs, cqe, node, NULL, 0);
if (!node->cq) {
ret = -ENOMEM;
printf("udaddy: unable to create CQ\n");
@@ -214,7 +210,7 @@ static int post_sends(struct cmatest_node *node, int signal_flag)
send_wr.opcode = IBV_WR_SEND_WITH_IMM;
send_wr.send_flags = signal_flag;
send_wr.wr_id = (unsigned long)node;
- send_wr.imm_data = htonl(node->cma_id->qp->qp_num);
+ send_wr.imm_data = htobe32(node->cma_id->qp->qp_num);
send_wr.wr.ud.ah = node->ah;
send_wr.wr.ud.remote_qpn = node->remote_qpn;
@@ -274,6 +270,8 @@ static int route_handler(struct cmatest_node *node)
goto err;
memset(&conn_param, 0, sizeof conn_param);
+ conn_param.private_data = test.rai->ai_connect;
+ conn_param.private_data_len = test.rai->ai_connect_len;
ret = rdma_connect(node->cma_id, &conn_param);
if (ret) {
perror("udaddy: failure connecting");
@@ -429,7 +427,7 @@ static int alloc_nodes(void)
if (dst_addr) {
ret = rdma_create_id(test.channel,
&test.nodes[i].cma_id,
- &test.nodes[i], port_space);
+ &test.nodes[i], hints.ai_port_space);
if (ret)
goto err;
}
@@ -458,7 +456,7 @@ static void create_reply_ah(struct cmatest_node *node, struct ibv_wc *wc)
node->ah = ibv_create_ah_from_wc(node->pd, wc, node->mem,
node->cma_id->port_num);
- node->remote_qpn = ntohl(wc->imm_data);
+ node->remote_qpn = be32toh(wc->imm_data);
ibv_query_qp(node->cma_id->qp, &attr, IBV_QP_QKEY, &init_attr);
node->remote_qkey = attr.qkey;
@@ -502,52 +500,28 @@ static int connect_events(void)
return ret;
}
-static int get_addr(char *dst, struct sockaddr_in *addr)
-{
- struct addrinfo *res;
- int ret;
-
- ret = getaddrinfo(dst, NULL, NULL, &res);
- if (ret) {
- printf("getaddrinfo failed - invalid hostname or IP address\n");
- return ret;
- }
-
- if (res->ai_family != PF_INET) {
- ret = -1;
- goto out;
- }
-
- *addr = *(struct sockaddr_in *) res->ai_addr;
-out:
- freeaddrinfo(res);
- return ret;
-}
-
static int run_server(void)
{
struct rdma_cm_id *listen_id;
int i, ret;
printf("udaddy: starting server\n");
- ret = rdma_create_id(test.channel, &listen_id, &test, port_space);
+ ret = rdma_create_id(test.channel, &listen_id, &test, hints.ai_port_space);
if (ret) {
perror("udaddy: listen request failed");
return ret;
}
- if (src_addr) {
- ret = get_addr(src_addr, &test.src_in);
- if (ret)
- goto out;
- } else
- test.src_in.sin_family = PF_INET;
+ ret = get_rdma_addr(src_addr, dst_addr, port, &hints, &test.rai);
+ if (ret) {
+ printf("udaddy: getrdmaaddr error: %s\n", gai_strerror(ret));
+ goto out;
+ }
- test.src_in.sin_port = port;
- ret = rdma_bind_addr(listen_id, test.src_addr);
+ ret = rdma_bind_addr(listen_id, test.rai->ai_src_addr);
if (ret) {
perror("udaddy: bind address failed");
- return ret;
+ goto out;
}
ret = rdma_listen(listen_id, 0);
@@ -586,23 +560,17 @@ static int run_client(void)
int i, ret;
printf("udaddy: starting client\n");
- if (src_addr) {
- ret = get_addr(src_addr, &test.src_in);
- if (ret)
- return ret;
- }
- ret = get_addr(dst_addr, &test.dst_in);
- if (ret)
+ ret = get_rdma_addr(src_addr, dst_addr, port, &hints, &test.rai);
+ if (ret) {
+ printf("udaddy: getaddrinfo error: %s\n", gai_strerror(ret));
return ret;
-
- test.dst_in.sin_port = port;
+ }
printf("udaddy: connecting\n");
for (i = 0; i < connections; i++) {
- ret = rdma_resolve_addr(test.nodes[i].cma_id,
- src_addr ? test.src_addr : NULL,
- test.dst_addr, 2000);
+ ret = rdma_resolve_addr(test.nodes[i].cma_id, test.rai->ai_src_addr,
+ test.rai->ai_dst_addr, 2000);
if (ret) {
perror("udaddy: failure getting addr");
connect_error();
@@ -636,7 +604,8 @@ int main(int argc, char **argv)
{
int op, ret;
- while ((op = getopt(argc, argv, "s:b:c:C:S:t:p:")) != -1) {
+ hints.ai_port_space = RDMA_PS_UDP;
+ while ((op = getopt(argc, argv, "s:b:c:C:S:t:p:P:f:")) != -1) {
switch (op) {
case 's':
dst_addr = optarg;
@@ -655,15 +624,36 @@ int main(int argc, char **argv)
break;
case 't':
set_tos = 1;
- tos = (uint8_t) atoi(optarg);
+ tos = (uint8_t) strtoul(optarg, NULL, 0);
+ break;
+ case 'p': /* for backwards compatibility - use -P */
+ hints.ai_port_space = strtol(optarg, NULL, 0);
break;
- case 'p':
- port_space = strtol(optarg, NULL, 0);
+ case 'f':
+ if (!strncasecmp("ip", optarg, 2)) {
+ hints.ai_flags = RAI_NUMERICHOST;
+ } else if (!strncasecmp("gid", optarg, 3)) {
+ hints.ai_flags = RAI_NUMERICHOST | RAI_FAMILY;
+ hints.ai_family = AF_IB;
+ } else if (strncasecmp("name", optarg, 4)) {
+ fprintf(stderr, "Warning: unknown address format\n");
+ }
+ break;
+ case 'P':
+ if (!strncasecmp("ipoib", optarg, 5)) {
+ hints.ai_port_space = RDMA_PS_IPOIB;
+ } else if (strncasecmp("udp", optarg, 3)) {
+ fprintf(stderr, "Warning: unknown port space format\n");
+ }
break;
default:
printf("usage: %s\n", argv[0]);
printf("\t[-s server_address]\n");
printf("\t[-b bind_address]\n");
+ printf("\t[-f address_format]\n");
+ printf("\t name, ip, ipv6, or gid\n");
+ printf("\t[-P port_space]\n");
+ printf("\t udp or ipoib\n");
printf("\t[-c connections]\n");
printf("\t[-C message_count]\n");
printf("\t[-S message_size]\n");
@@ -674,8 +664,6 @@ int main(int argc, char **argv)
}
}
- test.dst_addr = (struct sockaddr *) &test.dst_in;
- test.src_addr = (struct sockaddr *) &test.src_in;
test.connects_left = connections;
test.channel = rdma_create_event_channel();
@@ -687,14 +675,18 @@ int main(int argc, char **argv)
if (alloc_nodes())
exit(1);
- if (dst_addr)
+ if (dst_addr) {
ret = run_client();
- else
+ } else {
+ hints.ai_flags |= RAI_PASSIVE;
ret = run_server();
+ }
printf("test complete\n");
destroy_nodes();
rdma_destroy_event_channel(test.channel);
+ if (test.rai)
+ rdma_freeaddrinfo(test.rai);
printf("return status %d\n", ret);
return ret;
diff --git a/contrib/ofed/librdmacm/examples/udpong.c b/contrib/ofed/librdmacm/examples/udpong.c
new file mode 100644
index 0000000..8894a07
--- /dev/null
+++ b/contrib/ofed/librdmacm/examples/udpong.c
@@ -0,0 +1,570 @@
+/*
+ * Copyright (c) 2012 Intel Corporation. All rights reserved.
+ *
+ * This software is available to you under the OpenIB.org BSD license
+ * below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AWV
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <strings.h>
+#include <errno.h>
+#include <getopt.h>
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <sys/time.h>
+#include <sys/wait.h>
+#include <netdb.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <netinet/tcp.h>
+#include <arpa/inet.h>
+
+#include <rdma/rdma_cma.h>
+#include <rdma/rsocket.h>
+#include <util/compiler.h>
+#include "common.h"
+
+static int test_size[] = {
+ (1 << 6),
+ (1 << 7), ((1 << 7) + (1 << 6)),
+ (1 << 8), ((1 << 8) + (1 << 7)),
+ (1 << 9), ((1 << 9) + (1 << 8)),
+ (1 << 10), ((1 << 10) + (1 << 9)),
+};
+#define TEST_CNT (sizeof test_size / sizeof test_size[0])
+
+enum {
+ msg_op_login,
+ msg_op_start,
+ msg_op_data,
+ msg_op_echo,
+ msg_op_end
+};
+
+struct message {
+ uint8_t op;
+ uint8_t id;
+ uint8_t seqno;
+ uint8_t reserved;
+ __be32 data;
+ uint8_t buf[2048];
+};
+
+#define CTRL_MSG_SIZE 16
+
+struct client {
+ uint64_t recvcnt;
+};
+
+static struct client clients[256];
+static uint8_t id;
+
+static int rs;
+static int use_async;
+static int flags = MSG_DONTWAIT;
+static int poll_timeout;
+static int custom;
+static int echo;
+static int transfer_size = 1000;
+static int transfer_count = 1000;
+static int buffer_size;
+static char test_name[10] = "custom";
+static const char *port = "7174";
+static char *dst_addr;
+static char *src_addr;
+static union socket_addr g_addr;
+static socklen_t g_addrlen;
+static struct timeval start, end;
+static struct message g_msg;
+
+static void show_perf(void)
+{
+ char str[32];
+ float usec;
+ long long bytes;
+ int transfers;
+
+ usec = (end.tv_sec - start.tv_sec) * 1000000 + (end.tv_usec - start.tv_usec);
+ transfers = echo ? transfer_count * 2 : be32toh(g_msg.data);
+ bytes = (long long) transfers * transfer_size;
+
+ /* name size transfers bytes seconds Gb/sec usec/xfer */
+ printf("%-10s", test_name);
+ size_str(str, sizeof str, transfer_size);
+ printf("%-8s", str);
+ cnt_str(str, sizeof str, transfers);
+ printf("%-8s", str);
+ size_str(str, sizeof str, bytes);
+ printf("%-8s", str);
+ printf("%8.2fs%10.2f%11.2f\n",
+ usec / 1000000., (bytes * 8) / (1000. * usec),
+ (usec / transfers));
+}
+
+static void init_latency_test(int size)
+{
+ char sstr[5];
+
+ size_str(sstr, sizeof sstr, size);
+ snprintf(test_name, sizeof test_name, "%s_lat", sstr);
+ transfer_size = size;
+ transfer_count = size_to_count(transfer_size) / 10;
+ echo = 1;
+}
+
+static void init_bandwidth_test(int size)
+{
+ char sstr[5];
+
+ size_str(sstr, sizeof sstr, size);
+ snprintf(test_name, sizeof test_name, "%s_bw", sstr);
+ transfer_size = size;
+ transfer_count = size_to_count(transfer_size);
+ echo = 0;
+}
+
+static void set_options(int fd)
+{
+ int val;
+
+ if (buffer_size) {
+ rs_setsockopt(fd, SOL_SOCKET, SO_SNDBUF, (void *) &buffer_size,
+ sizeof buffer_size);
+ rs_setsockopt(fd, SOL_SOCKET, SO_RCVBUF, (void *) &buffer_size,
+ sizeof buffer_size);
+ } else {
+ val = 1 << 19;
+ rs_setsockopt(fd, SOL_SOCKET, SO_SNDBUF, (void *) &val, sizeof val);
+ rs_setsockopt(fd, SOL_SOCKET, SO_RCVBUF, (void *) &val, sizeof val);
+ }
+
+ if (flags & MSG_DONTWAIT)
+ rs_fcntl(fd, F_SETFL, O_NONBLOCK);
+}
+
+static ssize_t svr_send(struct message *msg, size_t size,
+ union socket_addr *addr, socklen_t addrlen)
+{
+ struct pollfd fds;
+ ssize_t ret;
+
+ if (use_async) {
+ fds.fd = rs;
+ fds.events = POLLOUT;
+ }
+
+ do {
+ if (use_async) {
+ ret = do_poll(&fds, poll_timeout);
+ if (ret)
+ return ret;
+ }
+
+ ret = rs_sendto(rs, msg, size, flags, &addr->sa, addrlen);
+ } while (ret < 0 && (errno == EWOULDBLOCK || errno == EAGAIN));
+
+ if (ret < 0)
+ perror("rsend");
+
+ return ret;
+}
+
+static ssize_t svr_recv(struct message *msg, size_t size,
+ union socket_addr *addr, socklen_t *addrlen)
+{
+ struct pollfd fds;
+ ssize_t ret;
+
+ if (use_async) {
+ fds.fd = rs;
+ fds.events = POLLIN;
+ }
+
+ do {
+ if (use_async) {
+ ret = do_poll(&fds, poll_timeout);
+ if (ret)
+ return ret;
+ }
+
+ ret = rs_recvfrom(rs, msg, size, flags, &addr->sa, addrlen);
+ } while (ret < 0 && (errno == EWOULDBLOCK || errno == EAGAIN));
+
+ if (ret < 0)
+ perror("rrecv");
+
+ return ret;
+}
+
+static int svr_process(struct message *msg, size_t size,
+ union socket_addr *addr, socklen_t addrlen)
+{
+ char str[64];
+ ssize_t ret;
+
+ switch (msg->op) {
+ case msg_op_login:
+ if (addr->sa.sa_family == AF_INET) {
+ printf("client login from %s\n",
+ inet_ntop(AF_INET, &addr->sin.sin_addr.s_addr,
+ str, sizeof str));
+ } else {
+ printf("client login from %s\n",
+ inet_ntop(AF_INET6, &addr->sin6.sin6_addr.s6_addr,
+ str, sizeof str));
+ }
+ msg->id = id++;
+ /* fall through */
+ case msg_op_start:
+ memset(&clients[msg->id], 0, sizeof clients[msg->id]);
+ break;
+ case msg_op_echo:
+ clients[msg->id].recvcnt++;
+ break;
+ case msg_op_end:
+ msg->data = htobe32(clients[msg->id].recvcnt);
+ break;
+ default:
+ clients[msg->id].recvcnt++;
+ return 0;
+ }
+
+ ret = svr_send(msg, size, addr, addrlen);
+ return (ret == size) ? 0 : (int) ret;
+}
+
+static int svr_bind(void)
+{
+ struct addrinfo hints, *res;
+ int ret;
+
+ memset(&hints, 0, sizeof hints);
+ hints.ai_socktype = SOCK_DGRAM;
+ ret = getaddrinfo(src_addr, port, &hints, &res);
+ if (ret) {
+ printf("getaddrinfo: %s\n", gai_strerror(ret));
+ return ret;
+ }
+
+ rs = rs_socket(res->ai_family, res->ai_socktype, res->ai_protocol);
+ if (rs < 0) {
+ perror("rsocket");
+ ret = rs;
+ goto out;
+ }
+
+ set_options(rs);
+ ret = rs_bind(rs, res->ai_addr, res->ai_addrlen);
+ if (ret) {
+ perror("rbind");
+ rs_close(rs);
+ }
+
+out:
+ free(res);
+ return ret;
+}
+
+static int svr_run(void)
+{
+ ssize_t len;
+ int ret;
+
+ ret = svr_bind();
+ while (!ret) {
+ g_addrlen = sizeof g_addr;
+ len = svr_recv(&g_msg, sizeof g_msg, &g_addr, &g_addrlen);
+ if (len < 0)
+ return len;
+
+ ret = svr_process(&g_msg, len, &g_addr, g_addrlen);
+ }
+ return ret;
+}
+
+static ssize_t client_send(struct message *msg, size_t size)
+{
+ struct pollfd fds;
+ int ret;
+
+ if (use_async) {
+ fds.fd = rs;
+ fds.events = POLLOUT;
+ }
+
+ do {
+ if (use_async) {
+ ret = do_poll(&fds, poll_timeout);
+ if (ret)
+ return ret;
+ }
+
+ ret = rs_send(rs, msg, size, flags);
+ } while (ret < 0 && (errno == EWOULDBLOCK || errno == EAGAIN));
+
+ if (ret < 0)
+ perror("rsend");
+
+ return ret;
+}
+
+static ssize_t client_recv(struct message *msg, size_t size, int timeout)
+{
+ struct pollfd fds;
+ int ret;
+
+ if (timeout) {
+ fds.fd = rs;
+ fds.events = POLLIN;
+
+ ret = rs_poll(&fds, 1, timeout);
+ if (ret <= 0)
+ return ret;
+ }
+
+ ret = rs_recv(rs, msg, size, flags | MSG_DONTWAIT);
+ if (ret < 0 && errno != EWOULDBLOCK && errno != EAGAIN)
+ perror("rrecv");
+
+ return ret;
+}
+
+static int client_send_recv(struct message *msg, size_t size, int timeout)
+{
+ static uint8_t seqno;
+ int ret;
+
+ msg->seqno = seqno;
+ do {
+ ret = client_send(msg, size);
+ if (ret != size)
+ return ret;
+
+ ret = client_recv(msg, size, timeout);
+ } while (ret <= 0 || msg->seqno != seqno);
+
+ seqno++;
+ return ret;
+}
+
+static int run_test(void)
+{
+ int ret, i;
+
+ g_msg.op = msg_op_start;
+ ret = client_send_recv(&g_msg, CTRL_MSG_SIZE, 1000);
+ if (ret != CTRL_MSG_SIZE)
+ goto out;
+
+ g_msg.op = echo ? msg_op_echo : msg_op_data;
+ gettimeofday(&start, NULL);
+ for (i = 0; i < transfer_count; i++) {
+ ret = echo ? client_send_recv(&g_msg, transfer_size, 1) :
+ client_send(&g_msg, transfer_size);
+ if (ret != transfer_size)
+ goto out;
+ }
+
+ g_msg.op = msg_op_end;
+ ret = client_send_recv(&g_msg, CTRL_MSG_SIZE, 1);
+ if (ret != CTRL_MSG_SIZE)
+ goto out;
+
+ gettimeofday(&end, NULL);
+ show_perf();
+ ret = 0;
+
+out:
+ return ret;
+}
+
+static int client_connect(void)
+{
+ struct addrinfo hints, *res;
+ int ret;
+
+ memset(&hints, 0, sizeof hints);
+ hints.ai_socktype = SOCK_DGRAM;
+ ret = getaddrinfo(dst_addr, port, &hints, &res);
+ if (ret) {
+ printf("getaddrinfo: %s\n", gai_strerror(ret));
+ return ret;
+ }
+
+ rs = rs_socket(res->ai_family, res->ai_socktype, res->ai_protocol);
+ if (rs < 0) {
+ perror("rsocket");
+ ret = rs;
+ goto out;
+ }
+
+ set_options(rs);
+ ret = rs_connect(rs, res->ai_addr, res->ai_addrlen);
+ if (ret) {
+ perror("rconnect");
+ rs_close(rs);
+ goto out;
+ }
+
+ g_msg.op = msg_op_login;
+ ret = client_send_recv(&g_msg, CTRL_MSG_SIZE, 1000);
+ if (ret == CTRL_MSG_SIZE)
+ ret = 0;
+
+out:
+ freeaddrinfo(res);
+ return ret;
+}
+
+static int client_run(void)
+{
+ int i, ret;
+
+ printf("%-10s%-8s%-8s%-8s%8s %10s%13s\n",
+ "name", "bytes", "xfers", "total", "time", "Gb/sec", "usec/xfer");
+
+ ret = client_connect();
+ if (ret)
+ return ret;
+
+ if (!custom) {
+ for (i = 0; i < TEST_CNT; i++) {
+ init_latency_test(test_size[i]);
+ run_test();
+ }
+ for (i = 0; i < TEST_CNT; i++) {
+ init_bandwidth_test(test_size[i]);
+ run_test();
+ }
+ } else {
+ run_test();
+ }
+ rs_close(rs);
+
+ return ret;
+}
+
+static int set_test_opt(const char *arg)
+{
+ if (strlen(arg) == 1) {
+ switch (arg[0]) {
+ case 's':
+ use_rs = 0;
+ break;
+ case 'a':
+ use_async = 1;
+ break;
+ case 'b':
+ flags = 0;
+ break;
+ case 'n':
+ flags = MSG_DONTWAIT;
+ break;
+ case 'e':
+ echo = 1;
+ break;
+ default:
+ return -1;
+ }
+ } else {
+ if (!strncasecmp("socket", arg, 6)) {
+ use_rs = 0;
+ } else if (!strncasecmp("async", arg, 5)) {
+ use_async = 1;
+ } else if (!strncasecmp("block", arg, 5)) {
+ flags = 0;
+ } else if (!strncasecmp("nonblock", arg, 8)) {
+ flags = MSG_DONTWAIT;
+ } else if (!strncasecmp("echo", arg, 4)) {
+ echo = 1;
+ } else {
+ return -1;
+ }
+ }
+ return 0;
+}
+
+int main(int argc, char **argv)
+{
+ int op, ret;
+
+ while ((op = getopt(argc, argv, "s:b:B:C:S:p:T:")) != -1) {
+ switch (op) {
+ case 's':
+ dst_addr = optarg;
+ break;
+ case 'b':
+ src_addr = optarg;
+ break;
+ case 'B':
+ buffer_size = atoi(optarg);
+ break;
+ case 'C':
+ custom = 1;
+ transfer_count = atoi(optarg);
+ break;
+ case 'S':
+ custom = 1;
+ transfer_size = atoi(optarg);
+ if (transfer_size < CTRL_MSG_SIZE) {
+ printf("size must be at least %d bytes\n",
+ CTRL_MSG_SIZE);
+ exit(1);
+ }
+ break;
+ case 'p':
+ port = optarg;
+ break;
+ case 'T':
+ if (!set_test_opt(optarg))
+ break;
+ /* invalid option - fall through */
+ SWITCH_FALLTHROUGH;
+ default:
+ printf("usage: %s\n", argv[0]);
+ printf("\t[-s server_address]\n");
+ printf("\t[-b bind_address]\n");
+ printf("\t[-B buffer_size]\n");
+ printf("\t[-C transfer_count]\n");
+ printf("\t[-S transfer_size]\n");
+ printf("\t[-p port_number]\n");
+ printf("\t[-T test_option]\n");
+ printf("\t s|sockets - use standard tcp/ip sockets\n");
+ printf("\t a|async - asynchronous operation (use poll)\n");
+ printf("\t b|blocking - use blocking calls\n");
+ printf("\t n|nonblocking - use nonblocking calls\n");
+ printf("\t e|echo - server echoes all messages\n");
+ exit(1);
+ }
+ }
+
+ if (flags)
+ poll_timeout = -1;
+
+ ret = dst_addr ? client_run() : svr_run();
+ return ret;
+}
diff --git a/contrib/ofed/librdmacm/ib.h b/contrib/ofed/librdmacm/ib.h
new file mode 100644
index 0000000..38d5dba
--- /dev/null
+++ b/contrib/ofed/librdmacm/ib.h
@@ -0,0 +1,98 @@
+/*
+ * Copyright (c) 2010 Intel Corporation. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#if !defined(_RDMA_IB_H)
+#define _RDMA_IB_H
+
+#include <infiniband/types.h>
+#include <infiniband/endian.h>
+#include <string.h>
+
+#ifndef AF_IB
+#define AF_IB 41
+#endif
+#ifndef PF_IB
+#define PF_IB AF_IB
+#endif
+
+struct ib_addr {
+ union {
+ __u8 uib_addr8[16];
+ __be16 uib_addr16[8];
+ __be32 uib_addr32[4];
+ __be64 uib_addr64[2];
+ } ib_u;
+#define sib_addr8 ib_u.uib_addr8
+#define sib_addr16 ib_u.uib_addr16
+#define sib_addr32 ib_u.uib_addr32
+#define sib_addr64 ib_u.uib_addr64
+#define sib_raw ib_u.uib_addr8
+#define sib_subnet_prefix ib_u.uib_addr64[0]
+#define sib_interface_id ib_u.uib_addr64[1]
+};
+
+static inline int ib_addr_any(const struct ib_addr *a)
+{
+ return ((a->sib_addr64[0] | a->sib_addr64[1]) == 0);
+}
+
+static inline int ib_addr_loopback(const struct ib_addr *a)
+{
+ return ((a->sib_addr32[0] | a->sib_addr32[1] |
+ a->sib_addr32[2] | (a->sib_addr32[3] ^ htobe32(1))) == 0);
+}
+
+static inline void ib_addr_set(struct ib_addr *addr,
+ __be32 w1, __be32 w2, __be32 w3, __be32 w4)
+{
+ addr->sib_addr32[0] = w1;
+ addr->sib_addr32[1] = w2;
+ addr->sib_addr32[2] = w3;
+ addr->sib_addr32[3] = w4;
+}
+
+static inline int ib_addr_cmp(const struct ib_addr *a1, const struct ib_addr *a2)
+{
+ return memcmp(a1, a2, sizeof(struct ib_addr));
+}
+
+struct sockaddr_ib {
+ unsigned short int sib_family; /* AF_IB */
+ __be16 sib_pkey;
+ __be32 sib_flowinfo;
+ struct ib_addr sib_addr;
+ __be64 sib_sid;
+ __be64 sib_sid_mask;
+ __u64 sib_scope_id;
+};
+
+#endif /* _RDMA_IB_H */
diff --git a/contrib/ofed/librdmacm/include/rdma/rdma_cma.h b/contrib/ofed/librdmacm/include/rdma/rdma_cma.h
deleted file mode 100644
index 534489d..0000000
--- a/contrib/ofed/librdmacm/include/rdma/rdma_cma.h
+++ /dev/null
@@ -1,580 +0,0 @@
-/*
- * Copyright (c) 2005 Voltaire Inc. All rights reserved.
- * Copyright (c) 2005-2007 Intel Corporation. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-#if !defined(RDMA_CMA_H)
-#define RDMA_CMA_H
-
-#include <netinet/in.h>
-#include <sys/socket.h>
-#include <infiniband/verbs.h>
-#include <infiniband/sa.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/*
- * Upon receiving a device removal event, users must destroy the associated
- * RDMA identifier and release all resources allocated with the device.
- */
-enum rdma_cm_event_type {
- RDMA_CM_EVENT_ADDR_RESOLVED,
- RDMA_CM_EVENT_ADDR_ERROR,
- RDMA_CM_EVENT_ROUTE_RESOLVED,
- RDMA_CM_EVENT_ROUTE_ERROR,
- RDMA_CM_EVENT_CONNECT_REQUEST,
- RDMA_CM_EVENT_CONNECT_RESPONSE,
- RDMA_CM_EVENT_CONNECT_ERROR,
- RDMA_CM_EVENT_UNREACHABLE,
- RDMA_CM_EVENT_REJECTED,
- RDMA_CM_EVENT_ESTABLISHED,
- RDMA_CM_EVENT_DISCONNECTED,
- RDMA_CM_EVENT_DEVICE_REMOVAL,
- RDMA_CM_EVENT_MULTICAST_JOIN,
- RDMA_CM_EVENT_MULTICAST_ERROR,
- RDMA_CM_EVENT_ADDR_CHANGE,
- RDMA_CM_EVENT_TIMEWAIT_EXIT
-};
-
-enum rdma_port_space {
- RDMA_PS_IPOIB= 0x0002,
- RDMA_PS_TCP = 0x0106,
- RDMA_PS_UDP = 0x0111,
-};
-
-/*
- * Global qkey value for UDP QPs and multicast groups created via the
- * RDMA CM.
- */
-#define RDMA_UDP_QKEY 0x01234567
-
-struct ib_addr {
- union ibv_gid sgid;
- union ibv_gid dgid;
- uint16_t pkey;
-};
-
-struct rdma_addr {
- struct sockaddr src_addr;
- uint8_t src_pad[sizeof(struct sockaddr_storage) -
- sizeof(struct sockaddr)];
- struct sockaddr dst_addr;
- uint8_t dst_pad[sizeof(struct sockaddr_storage) -
- sizeof(struct sockaddr)];
- union {
- struct ib_addr ibaddr;
- } addr;
-};
-
-struct rdma_route {
- struct rdma_addr addr;
- struct ibv_sa_path_rec *path_rec;
- int num_paths;
-};
-
-struct rdma_event_channel {
- int fd;
-};
-
-struct rdma_cm_id {
- struct ibv_context *verbs;
- struct rdma_event_channel *channel;
- void *context;
- struct ibv_qp *qp;
- struct rdma_route route;
- enum rdma_port_space ps;
- uint8_t port_num;
-};
-
-struct rdma_conn_param {
- const void *private_data;
- uint8_t private_data_len;
- uint8_t responder_resources;
- uint8_t initiator_depth;
- uint8_t flow_control;
- uint8_t retry_count; /* ignored when accepting */
- uint8_t rnr_retry_count;
- /* Fields below ignored if a QP is created on the rdma_cm_id. */
- uint8_t srq;
- uint32_t qp_num;
-};
-
-struct rdma_ud_param {
- const void *private_data;
- uint8_t private_data_len;
- struct ibv_ah_attr ah_attr;
- uint32_t qp_num;
- uint32_t qkey;
-};
-
-struct rdma_cm_event {
- struct rdma_cm_id *id;
- struct rdma_cm_id *listen_id;
- enum rdma_cm_event_type event;
- int status;
- union {
- struct rdma_conn_param conn;
- struct rdma_ud_param ud;
- } param;
-};
-
-/**
- * rdma_create_event_channel - Open a channel used to report communication events.
- * Description:
- * Asynchronous events are reported to users through event channels. Each
- * event channel maps to a file descriptor.
- * Notes:
- * All created event channels must be destroyed by calling
- * rdma_destroy_event_channel. Users should call rdma_get_cm_event to
- * retrieve events on an event channel.
- * See also:
- * rdma_get_cm_event, rdma_destroy_event_channel
- */
-struct rdma_event_channel *rdma_create_event_channel(void);
-
-/**
- * rdma_destroy_event_channel - Close an event communication channel.
- * @channel: The communication channel to destroy.
- * Description:
- * Release all resources associated with an event channel and closes the
- * associated file descriptor.
- * Notes:
- * All rdma_cm_id's associated with the event channel must be destroyed,
- * and all returned events must be acked before calling this function.
- * See also:
- * rdma_create_event_channel, rdma_get_cm_event, rdma_ack_cm_event
- */
-void rdma_destroy_event_channel(struct rdma_event_channel *channel);
-
-/**
- * rdma_create_id - Allocate a communication identifier.
- * @channel: The communication channel that events associated with the
- * allocated rdma_cm_id will be reported on.
- * @id: A reference where the allocated communication identifier will be
- * returned.
- * @context: User specified context associated with the rdma_cm_id.
- * @ps: RDMA port space.
- * Description:
- * Creates an identifier that is used to track communication information.
- * Notes:
- * Rdma_cm_id's are conceptually equivalent to a socket for RDMA
- * communication. The difference is that RDMA communication requires
- * explicitly binding to a specified RDMA device before communication
- * can occur, and most operations are asynchronous in nature. Communication
- * events on an rdma_cm_id are reported through the associated event
- * channel. Users must release the rdma_cm_id by calling rdma_destroy_id.
- * See also:
- * rdma_create_event_channel, rdma_destroy_id, rdma_get_devices,
- * rdma_bind_addr, rdma_resolve_addr, rdma_connect, rdma_listen,
- */
-int rdma_create_id(struct rdma_event_channel *channel,
- struct rdma_cm_id **id, void *context,
- enum rdma_port_space ps);
-
-/**
- * rdma_destroy_id - Release a communication identifier.
- * @id: The communication identifier to destroy.
- * Description:
- * Destroys the specified rdma_cm_id and cancels any outstanding
- * asynchronous operation.
- * Notes:
- * Users must free any associated QP with the rdma_cm_id before
- * calling this routine and ack an related events.
- * See also:
- * rdma_create_id, rdma_destroy_qp, rdma_ack_cm_event
- */
-int rdma_destroy_id(struct rdma_cm_id *id);
-
-/**
- * rdma_bind_addr - Bind an RDMA identifier to a source address.
- * @id: RDMA identifier.
- * @addr: Local address information. Wildcard values are permitted.
- * Description:
- * Associates a source address with an rdma_cm_id. The address may be
- * wildcarded. If binding to a specific local address, the rdma_cm_id
- * will also be bound to a local RDMA device.
- * Notes:
- * Typically, this routine is called before calling rdma_listen to bind
- * to a specific port number, but it may also be called on the active side
- * of a connection before calling rdma_resolve_addr to bind to a specific
- * address.
- * See also:
- * rdma_create_id, rdma_listen, rdma_resolve_addr, rdma_create_qp
- */
-int rdma_bind_addr(struct rdma_cm_id *id, struct sockaddr *addr);
-
-/**
- * rdma_resolve_addr - Resolve destination and optional source addresses.
- * @id: RDMA identifier.
- * @src_addr: Source address information. This parameter may be NULL.
- * @dst_addr: Destination address information.
- * @timeout_ms: Time to wait for resolution to complete.
- * Description:
- * Resolve destination and optional source addresses from IP addresses
- * to an RDMA address. If successful, the specified rdma_cm_id will
- * be bound to a local device.
- * Notes:
- * This call is used to map a given destination IP address to a usable RDMA
- * address. If a source address is given, the rdma_cm_id is bound to that
- * address, the same as if rdma_bind_addr were called. If no source
- * address is given, and the rdma_cm_id has not yet been bound to a device,
- * then the rdma_cm_id will be bound to a source address based on the
- * local routing tables. After this call, the rdma_cm_id will be bound to
- * an RDMA device. This call is typically made from the active side of a
- * connection before calling rdma_resolve_route and rdma_connect.
- * See also:
- * rdma_create_id, rdma_resolve_route, rdma_connect, rdma_create_qp,
- * rdma_get_cm_event, rdma_bind_addr
- */
-int rdma_resolve_addr(struct rdma_cm_id *id, struct sockaddr *src_addr,
- struct sockaddr *dst_addr, int timeout_ms);
-
-/**
- * rdma_resolve_route - Resolve the route information needed to establish a connection.
- * @id: RDMA identifier.
- * @timeout_ms: Time to wait for resolution to complete.
- * Description:
- * Resolves an RDMA route to the destination address in order to establish
- * a connection. The destination address must have already been resolved
- * by calling rdma_resolve_addr.
- * Notes:
- * This is called on the client side of a connection after calling
- * rdma_resolve_addr, but before calling rdma_connect.
- * See also:
- * rdma_resolve_addr, rdma_connect, rdma_get_cm_event
- */
-int rdma_resolve_route(struct rdma_cm_id *id, int timeout_ms);
-
-/**
- * rdma_create_qp - Allocate a QP.
- * @id: RDMA identifier.
- * @pd: protection domain for the QP.
- * @qp_init_attr: initial QP attributes.
- * Description:
- * Allocate a QP associated with the specified rdma_cm_id and transition it
- * for sending and receiving.
- * Notes:
- * The rdma_cm_id must be bound to a local RDMA device before calling this
- * function, and the protection domain must be for that same device.
- * QPs allocated to an rdma_cm_id are automatically transitioned by the
- * librdmacm through their states. After being allocated, the QP will be
- * ready to handle posting of receives. If the QP is unconnected, it will
- * be ready to post sends.
- * See also:
- * rdma_bind_addr, rdma_resolve_addr, rdma_destroy_qp, ibv_create_qp,
- * ibv_modify_qp
- */
-int rdma_create_qp(struct rdma_cm_id *id, struct ibv_pd *pd,
- struct ibv_qp_init_attr *qp_init_attr);
-
-/**
- * rdma_destroy_qp - Deallocate a QP.
- * @id: RDMA identifier.
- * Description:
- * Destroy a QP allocated on the rdma_cm_id.
- * Notes:
- * Users must destroy any QP associated with an rdma_cm_id before
- * destroying the ID.
- * See also:
- * rdma_create_qp, rdma_destroy_id, ibv_destroy_qp
- */
-void rdma_destroy_qp(struct rdma_cm_id *id);
-
-/**
- * rdma_connect - Initiate an active connection request.
- * @id: RDMA identifier.
- * @conn_param: connection parameters.
- * Description:
- * For a connected rdma_cm_id, this call initiates a connection request
- * to a remote destination. For an unconnected rdma_cm_id, it initiates
- * a lookup of the remote QP providing the datagram service.
- * Notes:
- * Users must have resolved a route to the destination address
- * by having called rdma_resolve_route before calling this routine.
- * See also:
- * rdma_resolve_route, rdma_disconnect, rdma_listen, rdma_get_cm_event
- */
-int rdma_connect(struct rdma_cm_id *id, struct rdma_conn_param *conn_param);
-
-/**
- * rdma_listen - Listen for incoming connection requests.
- * @id: RDMA identifier.
- * @backlog: backlog of incoming connection requests.
- * Description:
- * Initiates a listen for incoming connection requests or datagram service
- * lookup. The listen will be restricted to the locally bound source
- * address.
- * Notes:
- * Users must have bound the rdma_cm_id to a local address by calling
- * rdma_bind_addr before calling this routine. If the rdma_cm_id is
- * bound to a specific IP address, the listen will be restricted to that
- * address and the associated RDMA device. If the rdma_cm_id is bound
- * to an RDMA port number only, the listen will occur across all RDMA
- * devices.
- * See also:
- * rdma_bind_addr, rdma_connect, rdma_accept, rdma_reject, rdma_get_cm_event
- */
-int rdma_listen(struct rdma_cm_id *id, int backlog);
-
-/**
- * rdma_accept - Called to accept a connection request.
- * @id: Connection identifier associated with the request.
- * @conn_param: Information needed to establish the connection.
- * Description:
- * Called from the listening side to accept a connection or datagram
- * service lookup request.
- * Notes:
- * Unlike the socket accept routine, rdma_accept is not called on a
- * listening rdma_cm_id. Instead, after calling rdma_listen, the user
- * waits for a connection request event to occur. Connection request
- * events give the user a newly created rdma_cm_id, similar to a new
- * socket, but the rdma_cm_id is bound to a specific RDMA device.
- * rdma_accept is called on the new rdma_cm_id.
- * See also:
- * rdma_listen, rdma_reject, rdma_get_cm_event
- */
-int rdma_accept(struct rdma_cm_id *id, struct rdma_conn_param *conn_param);
-
-/**
- * rdma_reject - Called to reject a connection request.
- * @id: Connection identifier associated with the request.
- * @private_data: Optional private data to send with the reject message.
- * @private_data_len: Size of the private_data to send, in bytes.
- * Description:
- * Called from the listening side to reject a connection or datagram
- * service lookup request.
- * Notes:
- * After receiving a connection request event, a user may call rdma_reject
- * to reject the request. If the underlying RDMA transport supports
- * private data in the reject message, the specified data will be passed to
- * the remote side.
- * See also:
- * rdma_listen, rdma_accept, rdma_get_cm_event
- */
-int rdma_reject(struct rdma_cm_id *id, const void *private_data,
- uint8_t private_data_len);
-
-/**
- * rdma_notify - Notifies the librdmacm of an asynchronous event.
- * @id: RDMA identifier.
- * @event: Asynchronous event.
- * Description:
- * Used to notify the librdmacm of asynchronous events that have occurred
- * on a QP associated with the rdma_cm_id.
- * Notes:
- * Asynchronous events that occur on a QP are reported through the user's
- * device event handler. This routine is used to notify the librdmacm of
- * communication events. In most cases, use of this routine is not
- * necessary, however if connection establishment is done out of band
- * (such as done through Infiniband), it's possible to receive data on a
- * QP that is not yet considered connected. This routine forces the
- * connection into an established state in this case in order to handle
- * the rare situation where the connection never forms on its own.
- * Events that should be reported to the CM are: IB_EVENT_COMM_EST.
- * See also:
- * rdma_connect, rdma_accept, rdma_listen
- */
-int rdma_notify(struct rdma_cm_id *id, enum ibv_event_type event);
-
-/**
- * rdma_disconnect - This function disconnects a connection.
- * @id: RDMA identifier.
- * Description:
- * Disconnects a connection and transitions any associated QP to the
- * error state.
- * See also:
- * rdma_connect, rdma_listen, rdma_accept
- */
-int rdma_disconnect(struct rdma_cm_id *id);
-
-/**
- * rdma_join_multicast - Joins a multicast group.
- * @id: Communication identifier associated with the request.
- * @addr: Multicast address identifying the group to join.
- * @context: User-defined context associated with the join request.
- * Description:
- * Joins a multicast group and attaches an associated QP to the group.
- * Notes:
- * Before joining a multicast group, the rdma_cm_id must be bound to
- * an RDMA device by calling rdma_bind_addr or rdma_resolve_addr. Use of
- * rdma_resolve_addr requires the local routing tables to resolve the
- * multicast address to an RDMA device. The user must call
- * rdma_leave_multicast to leave the multicast group and release any
- * multicast resources. The context is returned to the user through
- * the private_data field in the rdma_cm_event.
- * See also:
- * rdma_leave_multicast, rdma_bind_addr, rdma_resolve_addr, rdma_create_qp
- */
-int rdma_join_multicast(struct rdma_cm_id *id, struct sockaddr *addr,
- void *context);
-
-/**
- * rdma_leave_multicast - Leaves a multicast group.
- * @id: Communication identifier associated with the request.
- * @addr: Multicast address identifying the group to leave.
- * Description:
- * Leaves a multicast group and detaches an associated QP from the group.
- * Notes:
- * Calling this function before a group has been fully joined results in
- * canceling the join operation. Users should be aware that messages
- * received from the multicast group may stilled be queued for
- * completion processing immediately after leaving a multicast group.
- * Destroying an rdma_cm_id will automatically leave all multicast groups.
- * See also:
- * rdma_join_multicast, rdma_destroy_qp
- */
-int rdma_leave_multicast(struct rdma_cm_id *id, struct sockaddr *addr);
-
-/**
- * rdma_get_cm_event - Retrieves the next pending communication event.
- * @channel: Event channel to check for events.
- * @event: Allocated information about the next communication event.
- * Description:
- * Retrieves a communication event. If no events are pending, by default,
- * the call will block until an event is received.
- * Notes:
- * The default synchronous behavior of this routine can be changed by
- * modifying the file descriptor associated with the given channel. All
- * events that are reported must be acknowledged by calling rdma_ack_cm_event.
- * Destruction of an rdma_cm_id will block until related events have been
- * acknowledged.
- * See also:
- * rdma_ack_cm_event, rdma_create_event_channel, rdma_event_str
- */
-int rdma_get_cm_event(struct rdma_event_channel *channel,
- struct rdma_cm_event **event);
-
-/**
- * rdma_ack_cm_event - Free a communication event.
- * @event: Event to be released.
- * Description:
- * All events which are allocated by rdma_get_cm_event must be released,
- * there should be a one-to-one correspondence between successful gets
- * and acks.
- * See also:
- * rdma_get_cm_event, rdma_destroy_id
- */
-int rdma_ack_cm_event(struct rdma_cm_event *event);
-
-static inline uint16_t rdma_get_src_port(struct rdma_cm_id *id)
-{
- return id->route.addr.src_addr.sa_family == PF_INET6 ?
- ((struct sockaddr_in6 *) &id->route.addr.src_addr)->sin6_port :
- ((struct sockaddr_in *) &id->route.addr.src_addr)->sin_port;
-}
-
-static inline uint16_t rdma_get_dst_port(struct rdma_cm_id *id)
-{
- return id->route.addr.dst_addr.sa_family == PF_INET6 ?
- ((struct sockaddr_in6 *) &id->route.addr.dst_addr)->sin6_port :
- ((struct sockaddr_in *) &id->route.addr.dst_addr)->sin_port;
-}
-
-static inline struct sockaddr *rdma_get_local_addr(struct rdma_cm_id *id)
-{
- return &id->route.addr.src_addr;
-}
-
-static inline struct sockaddr *rdma_get_peer_addr(struct rdma_cm_id *id)
-{
- return &id->route.addr.dst_addr;
-}
-
-/**
- * rdma_get_devices - Get list of RDMA devices currently available.
- * @num_devices: If non-NULL, set to the number of devices returned.
- * Description:
- * Return a NULL-terminated array of opened RDMA devices. Callers can use
- * this routine to allocate resources on specific RDMA devices that will be
- * shared across multiple rdma_cm_id's.
- * Notes:
- * The returned array must be released by calling rdma_free_devices. Devices
- * remain opened while the librdmacm is loaded.
- * See also:
- * rdma_free_devices
- */
-struct ibv_context **rdma_get_devices(int *num_devices);
-
-/**
- * rdma_free_devices - Frees the list of devices returned by rdma_get_devices.
- * @list: List of devices returned from rdma_get_devices.
- * Description:
- * Frees the device array returned by rdma_get_devices.
- * See also:
- * rdma_get_devices
- */
-void rdma_free_devices(struct ibv_context **list);
-
-/**
- * rdma_event_str - Returns a string representation of an rdma cm event.
- * @event: Asynchronous event.
- * Description:
- * Returns a string representation of an asynchronous event.
- * See also:
- * rdma_get_cm_event
- */
-const char *rdma_event_str(enum rdma_cm_event_type event);
-
-/* Option levels */
-enum {
- RDMA_OPTION_ID = 0
-};
-
-/* Option details */
-enum {
- RDMA_OPTION_ID_TOS = 0 /* uint8_t: RFC 2474 */
-};
-
-/**
- * rdma_set_option - Set options for an rdma_cm_id.
- * @id: Communication identifier to set option for.
- * @level: Protocol level of the option to set.
- * @optname: Name of the option to set.
- * @optval: Reference to the option data.
- * @optlen: The size of the %optval buffer.
- */
-int rdma_set_option(struct rdma_cm_id *id, int level, int optname,
- void *optval, size_t optlen);
-
-/**
- * rdma_migrate_id - Move an rdma_cm_id to a new event channel.
- * @id: Communication identifier to migrate.
- * @channel: New event channel for rdma_cm_id events.
- */
-int rdma_migrate_id(struct rdma_cm_id *id, struct rdma_event_channel *channel);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* RDMA_CMA_H */
diff --git a/contrib/ofed/librdmacm/include/rdma/rdma_cma_abi.h b/contrib/ofed/librdmacm/include/rdma/rdma_cma_abi.h
deleted file mode 100644
index 1a3a9c2..0000000
--- a/contrib/ofed/librdmacm/include/rdma/rdma_cma_abi.h
+++ /dev/null
@@ -1,235 +0,0 @@
-/*
- * Copyright (c) 2005-2006 Intel Corporation. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-#ifndef RDMA_CMA_ABI_H
-#define RDMA_CMA_ABI_H
-
-#include <infiniband/kern-abi.h>
-#include <infiniband/sa-kern-abi.h>
-
-/*
- * This file must be kept in sync with the kernel's version of rdma_user_cm.h
- */
-
-#define RDMA_USER_CM_MIN_ABI_VERSION 3
-#define RDMA_USER_CM_MAX_ABI_VERSION 4
-
-#define RDMA_MAX_PRIVATE_DATA 256
-
-enum {
- UCMA_CMD_CREATE_ID,
- UCMA_CMD_DESTROY_ID,
- UCMA_CMD_BIND_ADDR,
- UCMA_CMD_RESOLVE_ADDR,
- UCMA_CMD_RESOLVE_ROUTE,
- UCMA_CMD_QUERY_ROUTE,
- UCMA_CMD_CONNECT,
- UCMA_CMD_LISTEN,
- UCMA_CMD_ACCEPT,
- UCMA_CMD_REJECT,
- UCMA_CMD_DISCONNECT,
- UCMA_CMD_INIT_QP_ATTR,
- UCMA_CMD_GET_EVENT,
- UCMA_CMD_GET_OPTION,
- UCMA_CMD_SET_OPTION,
- UCMA_CMD_NOTIFY,
- UCMA_CMD_JOIN_MCAST,
- UCMA_CMD_LEAVE_MCAST,
- UCMA_CMD_MIGRATE_ID
-};
-
-struct ucma_abi_cmd_hdr {
- __u32 cmd;
- __u16 in;
- __u16 out;
-};
-
-struct ucma_abi_create_id {
- __u64 uid;
- __u64 response;
- __u16 ps;
- __u8 reserved[6];
-};
-
-struct ucma_abi_create_id_resp {
- __u32 id;
-};
-
-struct ucma_abi_destroy_id {
- __u64 response;
- __u32 id;
- __u32 reserved;
-};
-
-struct ucma_abi_destroy_id_resp {
- __u32 events_reported;
-};
-
-struct ucma_abi_bind_addr {
- __u64 response;
- struct sockaddr_in6 addr;
- __u32 id;
-};
-
-struct ucma_abi_resolve_addr {
- struct sockaddr_in6 src_addr;
- struct sockaddr_in6 dst_addr;
- __u32 id;
- __u32 timeout_ms;
-};
-
-struct ucma_abi_resolve_route {
- __u32 id;
- __u32 timeout_ms;
-};
-
-struct ucma_abi_query_route {
- __u64 response;
- __u32 id;
- __u32 reserved;
-};
-
-struct ucma_abi_query_route_resp {
- __u64 node_guid;
- struct ibv_kern_path_rec ib_route[2];
- struct sockaddr_in6 src_addr;
- struct sockaddr_in6 dst_addr;
- __u32 num_paths;
- __u8 port_num;
- __u8 reserved[3];
-};
-
-struct ucma_abi_conn_param {
- __u32 qp_num;
- __u32 reserved;
- __u8 private_data[RDMA_MAX_PRIVATE_DATA];
- __u8 private_data_len;
- __u8 srq;
- __u8 responder_resources;
- __u8 initiator_depth;
- __u8 flow_control;
- __u8 retry_count;
- __u8 rnr_retry_count;
- __u8 valid;
-};
-
-struct ucma_abi_ud_param {
- __u32 qp_num;
- __u32 qkey;
- struct ibv_kern_ah_attr ah_attr;
- __u8 private_data[RDMA_MAX_PRIVATE_DATA];
- __u8 private_data_len;
- __u8 reserved[7];
- __u8 reserved2[4]; /* Round to 8-byte boundary to support 32/64 */
-};
-
-struct ucma_abi_connect {
- struct ucma_abi_conn_param conn_param;
- __u32 id;
- __u32 reserved;
-};
-
-struct ucma_abi_listen {
- __u32 id;
- __u32 backlog;
-};
-
-struct ucma_abi_accept {
- __u64 uid;
- struct ucma_abi_conn_param conn_param;
- __u32 id;
- __u32 reserved;
-};
-
-struct ucma_abi_reject {
- __u32 id;
- __u8 private_data_len;
- __u8 reserved[3];
- __u8 private_data[RDMA_MAX_PRIVATE_DATA];
-};
-
-struct ucma_abi_disconnect {
- __u32 id;
-};
-
-struct ucma_abi_init_qp_attr {
- __u64 response;
- __u32 id;
- __u32 qp_state;
-};
-
-struct ucma_abi_notify {
- __u32 id;
- __u32 event;
-};
-
-struct ucma_abi_join_mcast {
- __u64 response; /* ucma_abi_create_id_resp */
- __u64 uid;
- struct sockaddr_in6 addr;
- __u32 id;
-};
-
-struct ucma_abi_get_event {
- __u64 response;
-};
-
-struct ucma_abi_event_resp {
- __u64 uid;
- __u32 id;
- __u32 event;
- __u32 status;
- union {
- struct ucma_abi_conn_param conn;
- struct ucma_abi_ud_param ud;
- } param;
-};
-
-struct ucma_abi_set_option {
- __u64 optval;
- __u32 id;
- __u32 level;
- __u32 optname;
- __u32 optlen;
-};
-
-struct ucma_abi_migrate_id {
- __u64 response;
- __u32 id;
- __u32 fd;
-};
-
-struct ucma_abi_migrate_resp {
- __u32 events_reported;
-};
-
-#endif /* RDMA_CMA_ABI_H */
diff --git a/contrib/ofed/librdmacm/indexer.c b/contrib/ofed/librdmacm/indexer.c
new file mode 100644
index 0000000..00be7d0
--- /dev/null
+++ b/contrib/ofed/librdmacm/indexer.c
@@ -0,0 +1,164 @@
+/*
+ * Copyright (c) 2011 Intel Corporation. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+#include <config.h>
+
+#include <errno.h>
+#include <sys/types.h>
+#include <stdlib.h>
+
+#include "indexer.h"
+
+/*
+ * Indexer - to find a structure given an index
+ *
+ * We store pointers using a double lookup and return an index to the
+ * user which is then used to retrieve the pointer. The upper bits of
+ * the index are itself an index into an array of memory allocations.
+ * The lower bits specify the offset into the allocated memory where
+ * the pointer is stored.
+ *
+ * This allows us to adjust the number of pointers stored by the index
+ * list without taking a lock during data lookups.
+ */
+
+static int idx_grow(struct indexer *idx)
+{
+ union idx_entry *entry;
+ int i, start_index;
+
+ if (idx->size >= IDX_ARRAY_SIZE)
+ goto nomem;
+
+ idx->array[idx->size] = calloc(IDX_ENTRY_SIZE, sizeof(union idx_entry));
+ if (!idx->array[idx->size])
+ goto nomem;
+
+ entry = idx->array[idx->size];
+ start_index = idx->size << IDX_ENTRY_BITS;
+ entry[IDX_ENTRY_SIZE - 1].next = idx->free_list;
+
+ for (i = IDX_ENTRY_SIZE - 2; i >= 0; i--)
+ entry[i].next = start_index + i + 1;
+
+ /* Index 0 is reserved */
+ if (start_index == 0)
+ start_index++;
+ idx->free_list = start_index;
+ idx->size++;
+ return start_index;
+
+nomem:
+ errno = ENOMEM;
+ return -1;
+}
+
+int idx_insert(struct indexer *idx, void *item)
+{
+ union idx_entry *entry;
+ int index;
+
+ if ((index = idx->free_list) == 0) {
+ if ((index = idx_grow(idx)) <= 0)
+ return index;
+ }
+
+ entry = idx->array[idx_array_index(index)];
+ idx->free_list = entry[idx_entry_index(index)].next;
+ entry[idx_entry_index(index)].item = item;
+ return index;
+}
+
+void *idx_remove(struct indexer *idx, int index)
+{
+ union idx_entry *entry;
+ void *item;
+
+ entry = idx->array[idx_array_index(index)];
+ item = entry[idx_entry_index(index)].item;
+ entry[idx_entry_index(index)].next = idx->free_list;
+ idx->free_list = index;
+ return item;
+}
+
+void idx_replace(struct indexer *idx, int index, void *item)
+{
+ union idx_entry *entry;
+
+ entry = idx->array[idx_array_index(index)];
+ entry[idx_entry_index(index)].item = item;
+}
+
+
+static int idm_grow(struct index_map *idm, int index)
+{
+ idm->array[idx_array_index(index)] = calloc(IDX_ENTRY_SIZE, sizeof(void *));
+ if (!idm->array[idx_array_index(index)])
+ goto nomem;
+
+ return index;
+
+nomem:
+ errno = ENOMEM;
+ return -1;
+}
+
+int idm_set(struct index_map *idm, int index, void *item)
+{
+ void **entry;
+
+ if (index > IDX_MAX_INDEX) {
+ errno = ENOMEM;
+ return -1;
+ }
+
+ if (!idm->array[idx_array_index(index)]) {
+ if (idm_grow(idm, index) < 0)
+ return -1;
+ }
+
+ entry = idm->array[idx_array_index(index)];
+ entry[idx_entry_index(index)] = item;
+ return index;
+}
+
+void *idm_clear(struct index_map *idm, int index)
+{
+ void **entry;
+ void *item;
+
+ entry = idm->array[idx_array_index(index)];
+ item = entry[idx_entry_index(index)];
+ entry[idx_entry_index(index)] = NULL;
+ return item;
+}
diff --git a/contrib/ofed/librdmacm/indexer.h b/contrib/ofed/librdmacm/indexer.h
new file mode 100644
index 0000000..e6ffc60
--- /dev/null
+++ b/contrib/ofed/librdmacm/indexer.h
@@ -0,0 +1,142 @@
+/*
+ * Copyright (c) 2011 Intel Corporation. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+#if !defined(INDEXER_H)
+#define INDEXER_H
+
+#include <config.h>
+#include <stddef.h>
+#include <sys/types.h>
+
+/*
+ * Indexer - to find a structure given an index. Synchronization
+ * must be provided by the caller. Caller must initialize the
+ * indexer by setting free_list and size to 0.
+ */
+
+union idx_entry {
+ void *item;
+ int next;
+};
+
+#define IDX_INDEX_BITS 16
+#define IDX_ENTRY_BITS 10
+#define IDX_ENTRY_SIZE (1 << IDX_ENTRY_BITS)
+#define IDX_ARRAY_SIZE (1 << (IDX_INDEX_BITS - IDX_ENTRY_BITS))
+#define IDX_MAX_INDEX ((1 << IDX_INDEX_BITS) - 1)
+
+struct indexer
+{
+ union idx_entry *array[IDX_ARRAY_SIZE];
+ int free_list;
+ int size;
+};
+
+#define idx_array_index(index) (index >> IDX_ENTRY_BITS)
+#define idx_entry_index(index) (index & (IDX_ENTRY_SIZE - 1))
+
+int idx_insert(struct indexer *idx, void *item);
+void *idx_remove(struct indexer *idx, int index);
+void idx_replace(struct indexer *idx, int index, void *item);
+
+static inline void *idx_at(struct indexer *idx, int index)
+{
+ return (idx->array[idx_array_index(index)] + idx_entry_index(index))->item;
+}
+
+/*
+ * Index map - associates a structure with an index. Synchronization
+ * must be provided by the caller. Caller must initialize the
+ * index map by setting it to 0.
+ */
+
+struct index_map
+{
+ void **array[IDX_ARRAY_SIZE];
+};
+
+int idm_set(struct index_map *idm, int index, void *item);
+void *idm_clear(struct index_map *idm, int index);
+
+static inline void *idm_at(struct index_map *idm, int index)
+{
+ void **entry;
+ entry = idm->array[idx_array_index(index)];
+ return entry[idx_entry_index(index)];
+}
+
+static inline void *idm_lookup(struct index_map *idm, int index)
+{
+ return ((index <= IDX_MAX_INDEX) && idm->array[idx_array_index(index)]) ?
+ idm_at(idm, index) : NULL;
+}
+
+typedef struct _dlist_entry {
+ struct _dlist_entry *next;
+ struct _dlist_entry *prev;
+} dlist_entry;
+
+static inline void dlist_init(dlist_entry *head)
+{
+ head->next = head;
+ head->prev = head;
+}
+
+static inline int dlist_empty(dlist_entry *head)
+{
+ return head->next == head;
+}
+
+static inline void dlist_insert_after(dlist_entry *item, dlist_entry *head)
+{
+ item->next = head->next;
+ item->prev = head;
+ head->next->prev = item;
+ head->next = item;
+}
+
+static inline void dlist_insert_before(dlist_entry *item, dlist_entry *head)
+{
+ dlist_insert_after(item, head->prev);
+}
+
+#define dlist_insert_head dlist_insert_after
+#define dlist_insert_tail dlist_insert_before
+
+static inline void dlist_remove(dlist_entry *item)
+{
+ item->prev->next = item->next;
+ item->next->prev = item->prev;
+}
+
+#endif /* INDEXER_H */
diff --git a/contrib/ofed/librdmacm/librdmacm.map b/contrib/ofed/librdmacm/librdmacm.map
new file mode 100644
index 0000000..1c8d74350
--- /dev/null
+++ b/contrib/ofed/librdmacm/librdmacm.map
@@ -0,0 +1,69 @@
+/* Do not change this file without reading Documentation/versioning.md */
+RDMACM_1.0 {
+ global:
+ rdma_create_event_channel;
+ rdma_destroy_event_channel;
+ rdma_create_id;
+ rdma_destroy_id;
+ rdma_bind_addr;
+ rdma_resolve_addr;
+ rdma_resolve_route;
+ rdma_create_qp;
+ rdma_destroy_qp;
+ rdma_connect;
+ rdma_listen;
+ rdma_accept;
+ rdma_reject;
+ rdma_notify;
+ rdma_disconnect;
+ rdma_get_cm_event;
+ rdma_ack_cm_event;
+ rdma_get_src_port;
+ rdma_get_dst_port;
+ rdma_join_multicast;
+ rdma_leave_multicast;
+ rdma_get_devices;
+ rdma_free_devices;
+ rdma_event_str;
+ rdma_set_option;
+ rdma_get_local_addr;
+ rdma_get_peer_addr;
+ rdma_migrate_id;
+ rdma_getaddrinfo;
+ rdma_freeaddrinfo;
+ rdma_get_request;
+ rdma_create_ep;
+ rdma_destroy_ep;
+ rdma_create_srq;
+ rdma_destroy_srq;
+ rsocket;
+ rbind;
+ rlisten;
+ raccept;
+ rconnect;
+ rshutdown;
+ rclose;
+ rrecv;
+ rrecvfrom;
+ rrecvmsg;
+ rsend;
+ rsendto;
+ rsendmsg;
+ rread;
+ rreadv;
+ rwrite;
+ rwritev;
+ rpoll;
+ rselect;
+ rgetpeername;
+ rgetsockname;
+ rsetsockopt;
+ rgetsockopt;
+ rfcntl;
+ riomap;
+ riounmap;
+ riowrite;
+ rdma_create_srq_ex;
+ rdma_create_qp_ex;
+ local: *;
+};
diff --git a/contrib/ofed/librdmacm/librdmacm.spec b/contrib/ofed/librdmacm/librdmacm.spec
deleted file mode 100644
index 2405d9a..0000000
--- a/contrib/ofed/librdmacm/librdmacm.spec
+++ /dev/null
@@ -1,75 +0,0 @@
-%define ver 1.0.11
-
-Name: librdmacm
-Version: 1.0.11
-Release: 1%{?dist}
-Summary: Userspace RDMA Connection Manager
-
-Group: System Environment/Libraries
-License: GPLv2 or BSD
-Url: http://www.openfabrics.org/
-Source: http://www.openfabrics.org/downloads/rdmacm/%{name}-%{version}.tar.gz
-BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
-
-BuildRequires: libibverbs-devel >= 1.1-1
-
-%description
-librdmacm provides a userspace RDMA Communication Managment API.
-
-%package devel
-Summary: Development files for the librdmacm library
-Group: System Environment/Libraries
-Requires: %{name} = %{version}-%{release} %{_includedir}/infiniband/verbs.h
-
-%description devel
-Development files for the librdmacm library.
-
-%package utils
-Summary: Examples for the librdmacm library
-Group: System Environment/Libraries
-Requires: %{name} = %{version}-%{release}
-
-%description utils
-Example test programs for the librdmacm library.
-
-%prep
-%setup -q -n %{name}-%{ver}
-
-%build
-%configure
-make %{?_smp_mflags}
-
-%install
-rm -rf $RPM_BUILD_ROOT
-%makeinstall
-# remove unpackaged files from the buildroot
-rm -f $RPM_BUILD_ROOT%{_libdir}/*.la
-
-%clean
-rm -rf $RPM_BUILD_ROOT
-
-%post -p /sbin/ldconfig
-%postun -p /sbin/ldconfig
-
-%files
-%defattr(-,root,root,-)
-%{_libdir}/librdmacm*.so.*
-%doc AUTHORS COPYING README
-
-%files devel
-%defattr(-,root,root)
-%{_libdir}/lib*.so
-%{_libdir}/*.a
-%{_includedir}/*
-%{_mandir}/man3/*
-%{_mandir}/man7/*
-
-%files utils
-%defattr(-,root,root,-)
-%{_bindir}/*
-%{_mandir}/man1/*
-
-%changelog
-
-* Fri Feb 15 2008 Roland Dreier <rdreier@cisco.com> - 1.0.6-1
-- Initial Fedora spec file
diff --git a/contrib/ofed/librdmacm/librdmacm.spec.in b/contrib/ofed/librdmacm/librdmacm.spec.in
deleted file mode 100644
index 85c7118..0000000
--- a/contrib/ofed/librdmacm/librdmacm.spec.in
+++ /dev/null
@@ -1,75 +0,0 @@
-%define ver @VERSION@
-
-Name: librdmacm
-Version: 1.0.11
-Release: 1%{?dist}
-Summary: Userspace RDMA Connection Manager
-
-Group: System Environment/Libraries
-License: GPLv2 or BSD
-Url: http://www.openfabrics.org/
-Source: http://www.openfabrics.org/downloads/rdmacm/%{name}-%{version}.tar.gz
-BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
-
-BuildRequires: libibverbs-devel >= 1.1-1
-
-%description
-librdmacm provides a userspace RDMA Communication Managment API.
-
-%package devel
-Summary: Development files for the librdmacm library
-Group: System Environment/Libraries
-Requires: %{name} = %{version}-%{release} %{_includedir}/infiniband/verbs.h
-
-%description devel
-Development files for the librdmacm library.
-
-%package utils
-Summary: Examples for the librdmacm library
-Group: System Environment/Libraries
-Requires: %{name} = %{version}-%{release}
-
-%description utils
-Example test programs for the librdmacm library.
-
-%prep
-%setup -q -n %{name}-%{ver}
-
-%build
-%configure
-make %{?_smp_mflags}
-
-%install
-rm -rf $RPM_BUILD_ROOT
-%makeinstall
-# remove unpackaged files from the buildroot
-rm -f $RPM_BUILD_ROOT%{_libdir}/*.la
-
-%clean
-rm -rf $RPM_BUILD_ROOT
-
-%post -p /sbin/ldconfig
-%postun -p /sbin/ldconfig
-
-%files
-%defattr(-,root,root,-)
-%{_libdir}/librdmacm*.so.*
-%doc AUTHORS COPYING README
-
-%files devel
-%defattr(-,root,root)
-%{_libdir}/lib*.so
-%{_libdir}/*.a
-%{_includedir}/*
-%{_mandir}/man3/*
-%{_mandir}/man7/*
-
-%files utils
-%defattr(-,root,root,-)
-%{_bindir}/*
-%{_mandir}/man1/*
-
-%changelog
-
-* Fri Feb 15 2008 Roland Dreier <rdreier@cisco.com> - 1.0.6-1
-- Initial Fedora spec file
diff --git a/contrib/ofed/librdmacm/librspreload.map b/contrib/ofed/librdmacm/librspreload.map
new file mode 100644
index 0000000..67ecf33
--- /dev/null
+++ b/contrib/ofed/librdmacm/librspreload.map
@@ -0,0 +1,33 @@
+{
+ /* FIXME: It is probably not a great idea to not tag these with the
+ proper symbol version from glibc, at least if glibc ever changes
+ the signature this will go sideways.. */
+ global:
+ accept;
+ bind;
+ close;
+ connect;
+ dup2;
+ fcntl;
+ getpeername;
+ getsockname;
+ getsockopt;
+ listen;
+ poll;
+ read;
+ readv;
+ recv;
+ recvfrom;
+ recvmsg;
+ select;
+ send;
+ sendfile;
+ sendmsg;
+ sendto;
+ setsockopt;
+ shutdown;
+ socket;
+ write;
+ writev;
+ local: *;
+};
diff --git a/contrib/ofed/librdmacm/man/CMakeLists.txt b/contrib/ofed/librdmacm/man/CMakeLists.txt
new file mode 100644
index 0000000..d4d54c5
--- /dev/null
+++ b/contrib/ofed/librdmacm/man/CMakeLists.txt
@@ -0,0 +1,66 @@
+rdma_man_pages(
+ cmtime.1
+ mckey.1
+ rcopy.1
+ rdma_accept.3
+ rdma_ack_cm_event.3
+ rdma_bind_addr.3
+ rdma_client.1
+ rdma_cm.7
+ rdma_connect.3
+ rdma_create_ep.3
+ rdma_create_event_channel.3
+ rdma_create_id.3
+ rdma_create_qp.3
+ rdma_create_srq.3
+ rdma_dereg_mr.3
+ rdma_destroy_ep.3
+ rdma_destroy_event_channel.3
+ rdma_destroy_id.3
+ rdma_destroy_qp.3
+ rdma_destroy_srq.3
+ rdma_disconnect.3
+ rdma_event_str.3
+ rdma_free_devices.3
+ rdma_get_cm_event.3
+ rdma_get_devices.3
+ rdma_get_dst_port.3
+ rdma_get_local_addr.3
+ rdma_get_peer_addr.3
+ rdma_get_recv_comp.3
+ rdma_get_request.3
+ rdma_get_send_comp.3
+ rdma_get_src_port.3
+ rdma_getaddrinfo.3
+ rdma_join_multicast.3
+ rdma_leave_multicast.3
+ rdma_listen.3
+ rdma_migrate_id.3
+ rdma_notify.3
+ rdma_post_read.3
+ rdma_post_readv.3
+ rdma_post_recv.3
+ rdma_post_recvv.3
+ rdma_post_send.3
+ rdma_post_sendv.3
+ rdma_post_ud_send.3
+ rdma_post_write.3
+ rdma_post_writev.3
+ rdma_reg_msgs.3
+ rdma_reg_read.3
+ rdma_reg_write.3
+ rdma_reject.3
+ rdma_resolve_addr.3
+ rdma_resolve_route.3
+ rdma_server.1
+ rdma_set_option.3
+ rdma_xclient.1
+ rdma_xserver.1
+ riostream.1
+ rping.1
+ rsocket.7.in
+ rstream.1
+ ucmatose.1
+ udaddy.1
+ udpong.1
+ )
diff --git a/contrib/ofed/librdmacm/man/cmtime.1 b/contrib/ofed/librdmacm/man/cmtime.1
new file mode 100644
index 0000000..434373d
--- /dev/null
+++ b/contrib/ofed/librdmacm/man/cmtime.1
@@ -0,0 +1,50 @@
+.\" Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md
+.TH "CMTIME" 1 "2017-04-28" "librdmacm" "librdmacm" librdmacm
+.SH NAME
+cmtime \- RDMA CM connection steps timing test.
+.SH SYNOPSIS
+.sp
+.nf
+\fIcmtime\fR [-s server_address] [-b bind_address]
+ [-c connections] [-p port_number]
+ [-r retries] [-t timeout_ms]
+.fi
+.SH "DESCRIPTION"
+Determines min and max times for various "steps" in RDMA CM
+connection setup and teardown between a client and server
+application.
+
+"Steps" that are timed are: create id, bind address, resolve address,
+resolve route, create qp, connect, disconnect, and destroy.
+.SH "OPTIONS"
+.TP
+\-s server_address
+The network name or IP address of the server system listening for
+connections. The used name or address must route over an RDMA device.
+This option must be specified by the client.
+.TP
+\-b bind_address
+The local network address to bind to.
+.TP
+\-c connections
+The number of connections to establish between the client and
+server. (default 100)
+.TP
+\-p port_number
+The server's port number.
+.TP
+\-r retries
+Number of retries when resolving address or route. (default 2)
+.TP
+\-t timeout_ms
+Timeout in millseconds (ms) when resolving address or
+route. (default 2000 - 2 seconds)
+.SH "NOTES"
+Basic usage is to start cmtime on a server system, then run
+cmtime -s server_name on a client system.
+.P
+Because this test maps RDMA resources to userspace, users must ensure
+that they have available system resources and permissions. See the
+libibverbs README file for additional details.
+.SH "SEE ALSO"
+rdma_cm(7)
diff --git a/contrib/ofed/librdmacm/man/mckey.1 b/contrib/ofed/librdmacm/man/mckey.1
index 4418819..a36f57b 100644
--- a/contrib/ofed/librdmacm/man/mckey.1
+++ b/contrib/ofed/librdmacm/man/mckey.1
@@ -1,3 +1,4 @@
+.\" Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md
.TH "MCKEY" 1 "2007-05-15" "librdmacm" "librdmacm" librdmacm
.SH NAME
mckey \- RDMA CM multicast setup and simple data transfer test.
@@ -47,7 +48,7 @@ UDP (0x0111) or IPoIB (0x0002) port space. (default RDMA_PS_UDP)
Basic usage is to start mckey -m multicast_address on a server system,
then run mckey -m multicast_address -s on a client system.
.P
-Unique Infiniband SA assigned multicast GIDs can be retrived by
+Unique Infiniband SA assigned multicast GIDs can be retrieved by
invoking mckey with a zero MGID or IP address. (Example, -M 0 or
-m 0.0.0.0). The assigned address will be displayed to allow
mckey clients to join the created group.
diff --git a/contrib/ofed/librdmacm/man/rcopy.1 b/contrib/ofed/librdmacm/man/rcopy.1
new file mode 100644
index 0000000..1dcca49
--- /dev/null
+++ b/contrib/ofed/librdmacm/man/rcopy.1
@@ -0,0 +1,38 @@
+.\" Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md
+.TH "RCOPY" 1 "2011-12-2" "librdmacm" "librdmacm" librdmacm
+.SH NAME
+rcopy \- simple file copy over RDMA.
+.SH SYNOPSIS
+.sp
+.nf
+\fIrcopy\fR source server[:destination] [-p port]
+\fIrcopy\fR [-p port]
+.fi
+.SH "DESCRIPTION"
+Uses sockets over RDMA interface to copy a source file to the
+specified destination.
+.SH "OPTIONS"
+.TP
+source
+The name and path of the source file to copy.
+.TP
+server
+The name or address of the destination server.
+.TP
+:destination
+An optional destination filename and path. If not given, the destination
+filename will match that of the source.
+.TP
+\-p server_port
+The server's port number.
+.TP
+.SH "NOTES"
+Basic usage is to start rcopy on a server system, then run
+rcopy sourcefile servername. The server application will continue to run after
+copying the file, but is currently single-threaded.
+.P
+Because this test maps RDMA resources to userspace, users must ensure
+that they have available system resources and permissions. See the
+libibverbs README file for additional details.
+.SH "SEE ALSO"
+rdma_cm(7)
diff --git a/contrib/ofed/librdmacm/man/rdma_accept.3 b/contrib/ofed/librdmacm/man/rdma_accept.3
index bdf90bd..a146a8d 100644
--- a/contrib/ofed/librdmacm/man/rdma_accept.3
+++ b/contrib/ofed/librdmacm/man/rdma_accept.3
@@ -1,4 +1,5 @@
-.TH "RDMA_ACCEPT" 3 "2007-10-31" "librdmacm" "Librdmacm Programmer's Manual" librdmacm
+.\" Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md
+.TH "RDMA_ACCEPT" 3 "2014-05-27" "librdmacm" "Librdmacm Programmer's Manual" librdmacm
.SH NAME
rdma_accept \- Called to accept a connection request.
.SH SYNOPSIS
@@ -16,6 +17,9 @@ below for details.
.SH "DESCRIPTION"
Called from the listening side to accept a connection or datagram
service lookup request.
+.SH "RETURN VALUE"
+Returns 0 on success, or -1 on error. If an error occurs, errno will be
+set to indicate the failure reason.
.SH "NOTES"
Unlike the socket accept routine, rdma_accept is not called on a
listening rdma_cm_id. Instead, after calling rdma_listen, the user
@@ -32,6 +36,9 @@ fields when accepting. Users may reference the rdma_conn_param structure in
the connection event directly, or can reference their own structure. If the
rdma_conn_param structure from an event is referenced, the event must not be
acked until after this call returns.
+.P
+If the conn_param parameter is NULL, the values reported in the connection
+request event are used, adjusted down based on local hardware restrictions.
.IP private_data
References a user-controlled data buffer. The contents of the buffer are
copied and transparently passed to the remote side as part of the
@@ -44,8 +51,8 @@ be larger than that requested.
The maximum number of outstanding RDMA read and atomic operations that the
local side will accept from the remote side. Applies only to RDMA_PS_TCP.
This value must be less than or equal to the local RDMA device attribute
-max_qp_rd_atom and the responder_resources value reported in the connect
-request event.
+max_qp_rd_atom, but preferably greater than or equal to the responder_resources
+value reported in the connect request event.
.IP initiator_depth
The maximum number of outstanding RDMA read and atomic operations that the
local side will have to the remote side. Applies only to RDMA_PS_TCP.
@@ -81,5 +88,8 @@ by the active side of the connection. The HCA ACK delay is a property of
the locally used HCA.
.P
The RNR retry count is a 3-bit value.
+.P
+The length of the private data provided by the user is limited to 196 bytes
+for RDMA_PS_TCP, or 136 bytes for RDMA_PS_UDP.
.SH "SEE ALSO"
rdma_listen(3), rdma_reject(3), rdma_get_cm_event(3)
diff --git a/contrib/ofed/librdmacm/man/rdma_ack_cm_event.3 b/contrib/ofed/librdmacm/man/rdma_ack_cm_event.3
index 3c24357..a9a616a 100644
--- a/contrib/ofed/librdmacm/man/rdma_ack_cm_event.3
+++ b/contrib/ofed/librdmacm/man/rdma_ack_cm_event.3
@@ -1,3 +1,4 @@
+.\" Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md
.TH "RDMA_ACK_CM_EVENT" 3 "2007-05-15" "librdmacm" "Librdmacm Programmer's Manual" librdmacm
.SH NAME
rdma_ack_cm_event \- Free a communication event.
@@ -14,5 +15,8 @@ All events which are allocated by rdma_get_cm_event must be released,
there should be a one-to-one correspondence between successful gets
and acks. This call frees the event structure and any memory that it
references.
+.SH "RETURN VALUE"
+Returns 0 on success, or -1 on error. If an error occurs, errno will be
+set to indicate the failure reason.
.SH "SEE ALSO"
rdma_get_cm_event(3), rdma_destroy_id(3)
diff --git a/contrib/ofed/librdmacm/man/rdma_bind_addr.3 b/contrib/ofed/librdmacm/man/rdma_bind_addr.3
index 06f30ce..37db52c 100644
--- a/contrib/ofed/librdmacm/man/rdma_bind_addr.3
+++ b/contrib/ofed/librdmacm/man/rdma_bind_addr.3
@@ -1,3 +1,4 @@
+.\" Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md
.TH "RDMA_BIND_ADDR" 3 "2007-05-15" "librdmacm" "Librdmacm Programmer's Manual" librdmacm
.SH NAME
rdma_bind_addr \- Bind an RDMA identifier to a source address.
@@ -16,6 +17,9 @@ Local address information. Wildcard values are permitted.
Associates a source address with an rdma_cm_id. The address may be
wildcarded. If binding to a specific local address, the rdma_cm_id
will also be bound to a local RDMA device.
+.SH "RETURN VALUE"
+Returns 0 on success, or -1 on error. If an error occurs, errno will be
+set to indicate the failure reason.
.SH "NOTES"
Typically, this routine is called before calling rdma_listen to bind
to a specific port number, but it may also be called on the active side
diff --git a/contrib/ofed/librdmacm/man/rdma_client.1 b/contrib/ofed/librdmacm/man/rdma_client.1
new file mode 100644
index 0000000..91b2d63
--- /dev/null
+++ b/contrib/ofed/librdmacm/man/rdma_client.1
@@ -0,0 +1,32 @@
+.\" Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md
+.TH "RDMA_CLIENT" 1 "2010-07-19" "librdmacm" "librdmacm" librdmacm
+.SH NAME
+rdma_client \- simple RDMA CM connection and ping-pong test.
+.SH SYNOPSIS
+.sp
+.nf
+\fIrdma_client\fR [-s server_address] [-p server_port]
+.fi
+.SH "DESCRIPTION"
+Uses synchronous librdmam calls to establish an RDMA connection between
+two nodes. This example is intended to provide a very simple coding
+example of how to use RDMA.
+.SH "OPTIONS"
+.TP
+\-s server_address
+Specifies the address of the system that the rdma_server is running on.
+By default, the client will attempt to connect to the server using
+127.0.0.1.
+.TP
+\-p server_port
+Specifies the port number that the server listens on. By default the server
+listens on port 7471.
+.SH "NOTES"
+Basic usage is to start rdma_server, then connect to the server using the
+rdma_client program.
+.P
+Because this test maps RDMA resources to userspace, users must ensure
+that they have available system resources and permissions. See the
+libibverbs README file for additional details.
+.SH "SEE ALSO"
+rdma_cm(7), udaddy(1), mckey(1), rping(1), rdma_server(1)
diff --git a/contrib/ofed/librdmacm/man/rdma_cm.7 b/contrib/ofed/librdmacm/man/rdma_cm.7
index fd0495925..8e5ad99 100644
--- a/contrib/ofed/librdmacm/man/rdma_cm.7
+++ b/contrib/ofed/librdmacm/man/rdma_cm.7
@@ -1,4 +1,5 @@
-.TH "RDMA_CM" 7 "2008-01-02" "librdmacm" "Librdmacm Programmer's Manual" librdmacm
+.\" Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md
+.TH "RDMA_CM" 7 "2010-07-19" "librdmacm" "Librdmacm Programmer's Manual" librdmacm
.SH NAME
rdma_cm \- RDMA communication manager.
.SH SYNOPSIS
@@ -8,17 +9,70 @@ Used to establish communication over RDMA transports.
.SH "NOTES"
The RDMA CM is a communication manager used to setup reliable, connected
and unreliable datagram data transfers. It provides an RDMA transport
-neutral interface for establishing connections. The API is based on sockets,
-but adapted for queue pair (QP) based semantics: communication must be
-over a specific RDMA device, and data transfers are message based.
+neutral interface for establishing connections. The API concepts are
+based on sockets, but adapted for queue pair (QP) based semantics:
+communication must be over a specific RDMA device, and data transfers
+are message based.
.P
-The RDMA CM only provides the communication management (connection setup /
-teardown) portion of an RDMA API. It works in conjunction with the verbs
+The RDMA CM can control both the QP and communication management (connection setup /
+teardown) portions of an RDMA API, or only the communication management
+piece. It works in conjunction with the verbs
API defined by the libibverbs library. The libibverbs library provides the
-interfaces needed to send and receive data.
+underlying interfaces needed to send and receive data.
+.P
+The RDMA CM can operate asynchronously or synchronously. The mode of
+operation is controlled by the user through the use of the rdma_cm event channel
+parameter in specific calls. If an event channel is provided, an rdma_cm identifier
+will report its event data (results of connecting, for example), on that channel.
+If a channel is not provided, then all rdma_cm operations for the selected
+rdma_cm identifier will block until they complete.
+.SH "RDMA VERBS"
+The rdma_cm supports the full range of verbs available through the libibverbs
+library and interfaces. However, it also provides wrapper functions for some
+of the more commonly used verbs funcationality. The full set of abstracted
+verb calls are:
+.P
+rdma_reg_msgs - register an array of buffers for sending and receiving
+.P
+rdma_reg_read - registers a buffer for RDMA read operations
+.P
+rdma_reg_write - registers a buffer for RDMA write operations
+.P
+rdma_dereg_mr - deregisters a memory region
+.P
+rdma_post_recv - post a buffer to receive a message
+.P
+rdma_post_send - post a buffer to send a message
+.P
+rdma_post_read - post an RDMA to read data into a buffer
+.P
+rdma_post_write - post an RDMA to send data from a buffer
+.P
+rdma_post_recvv - post a vector of buffers to receive a message
+.P
+rdma_post_sendv - post a vector of buffers to send a message
+.P
+rdma_post_readv - post a vector of buffers to receive an RDMA read
+.P
+rdma_post_writev - post a vector of buffers to send an RDMA write
+.P
+rdma_post_ud_send - post a buffer to send a message on a UD QP
+.P
+rdma_get_send_comp - get completion status for a send or RDMA operation
+.P
+rdma_get_recv_comp - get information about a completed receive
.SH "CLIENT OPERATION"
This section provides a general overview of the basic operation for the active,
-or client, side of communication. A general connection flow would be:
+or client, side of communication. This flow assume asynchronous operation with
+low level call details shown. For
+synchronous operation, calls to rdma_create_event_channel, rdma_get_cm_event,
+rdma_ack_cm_event, and rdma_destroy_event_channel
+would be eliminated. Abstracted calls, such as rdma_create_ep encapsulate
+several of these calls under a single API.
+Users may also refer to the example applications for
+code samples. A general connection flow would be:
+.IP rdma_getaddrinfo
+retrieve address information of the destination
.IP rdma_create_event_channel
create channel to receive events
.IP rdma_create_id
@@ -109,7 +163,7 @@ success
.IP "= -1"
error - see errno for more details
.P
-Librdmacm functions return 0 to indicate success, and a -1 return value
+Most librdmacm functions return 0 to indicate success, and a -1 return value
to indicate failure. If a function operates asynchronously, a return value of 0
means that the operation was successfully started. The operation could still
complete in error; users should check the status of the related event. If the
@@ -118,15 +172,59 @@ regarding the reason for the failure.
.P
Prior versions of the library would return -errno and not set errno for some cases
related to ENOMEM, ENODEV, ENODATA, EINVAL, and EADDRNOTAVAIL codes. Applications
-that want to check these codes and have compatability with prior library versions
+that want to check these codes and have compatibility with prior library versions
must manually set errno to the negative of the return code if it is < -1.
.SH "SEE ALSO"
-rdma_create_event_channel(3), rdma_get_cm_event(3), rdma_create_id(3),
-rdma_resolve_addr(3), rdma_bind_addr(3), rdma_create_qp(3),
-rdma_resolve_route(3), rdma_connect(3), rdma_listen(3), rdma_accept(3),
-rdma_reject(3), rdma_join_multicast(3), rdma_leave_multicast(3), rdma_notify(3),
-rdma_ack_cm_event(3), rdma_disconnect(3), rdma_destroy_qp(3), rdma_destroy_id(3),
-rdma_destroy_event_channel(3), rdma_get_devices(3), rdma_free_devices(3),
-rdma_get_peer_addr(3), rdma_get_local_addr(3),
-rdma_get_dst_port(3), rdma_get_src_port(3), rdma_set_option(3)
-ucmatose(1), udaddy(1), mckey(1), rping(1)
+rdma_accept(3),
+rdma_ack_cm_event(3),
+rdma_bind_addr(3),
+rdma_connect(3),
+rdma_create_ep(3),
+rdma_create_event_channel(3),
+rdma_create_id(3),
+rdma_create_qp(3),
+rdma_dereg_mr(3),
+rdma_destroy_ep(3),
+rdma_destroy_event_channel(3),
+rdma_destroy_id(3),
+rdma_destroy_qp(3),
+rdma_disconnect(3),
+rdma_event_str(3),
+rdma_free_devices(3),
+rdma_getaddrinfo(3),
+rdma_get_cm_event(3),
+rdma_get_devices(3),
+rdma_get_dst_port(3),
+rdma_get_local_addr(3),
+rdma_get_peer_addr(3),
+rdma_get_recv_comp(3),
+rdma_get_request(3),
+rdma_get_send_comp(3),
+rdma_get_src_port(3),
+rdma_join_multicast(3),
+rdma_leave_multicast(3),
+rdma_listen(3),
+rdma_migrate_id(3),
+rdma_notify(3),
+rdma_post_read(3)
+rdma_post_readv(3),
+rdma_post_recv(3),
+rdma_post_recvv(3),
+rdma_post_send(3),
+rdma_post_sendv(3),
+rdma_post_ud_send(3),
+rdma_post_write(3),
+rdma_post_writev(3),
+rdma_reg_msgs(3),
+rdma_reg_read(3),
+rdma_reg_write(3),
+rdma_reject(3),
+rdma_resolve_addr(3),
+rdma_resolve_route(3),
+rdma_set_option(3)
+mckey(1),
+rdma_client(1),
+rdma_server(1),
+rping(1),
+ucmatose(1),
+udaddy(1)
diff --git a/contrib/ofed/librdmacm/man/rdma_connect.3 b/contrib/ofed/librdmacm/man/rdma_connect.3
index 8dab9ee..ef88e38 100644
--- a/contrib/ofed/librdmacm/man/rdma_connect.3
+++ b/contrib/ofed/librdmacm/man/rdma_connect.3
@@ -1,4 +1,5 @@
-.TH "RDMA_CONNECT" 3 "2007-10-31" "librdmacm" "Librdmacm Programmer's Manual" librdmacm
+.\" Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md
+.TH "RDMA_CONNECT" 3 "2010-07-19" "librdmacm" "Librdmacm Programmer's Manual" librdmacm
.SH NAME
rdma_connect \- Initiate an active connection request.
.SH SYNOPSIS
@@ -16,9 +17,13 @@ connection parameters. See CONNECTION PROPERTIES below for details.
For an rdma_cm_id of type RDMA_PS_TCP, this call initiates a connection request
to a remote destination. For an rdma_cm_id of type RDMA_PS_UDP, it initiates
a lookup of the remote QP providing the datagram service.
+.SH "RETURN VALUE"
+Returns 0 on success, or -1 on error. If an error occurs, errno will be
+set to indicate the failure reason.
.SH "NOTES"
Users must have resolved a route to the destination address
-by having called rdma_resolve_route before calling this routine.
+by having called rdma_resolve_route or rdma_create_ep before calling
+this routine.
.SH "CONNECTION PROPERTIES"
The following properties are used to configure the communication and specified
by the conn_param parameter when connecting or establishing datagram
@@ -75,6 +80,9 @@ Administrator and is part of the resolved route (path record) information.
The HCA ACK delay is a property of the locally used HCA.
.P
Retry count and RNR retry count values are 3-bit values.
+.P
+The length of the private data provided by the user is limited to 56 bytes
+for RDMA_PS_TCP, or 180 bytes for RDMA_PS_UDP.
.SH "IWARP SPECIFIC"
Connections established over iWarp RDMA devices currently require that the
active side of the connection send the first message.
diff --git a/contrib/ofed/librdmacm/man/rdma_create_ep.3 b/contrib/ofed/librdmacm/man/rdma_create_ep.3
new file mode 100644
index 0000000..b1f3976
--- /dev/null
+++ b/contrib/ofed/librdmacm/man/rdma_create_ep.3
@@ -0,0 +1,61 @@
+.\" Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md
+.TH "RDMA_CREATE_EP" 3 "2010-07-19" "librdmacm" "Librdmacm Programmer's Manual" librdmacm
+.SH NAME
+rdma_create_ep \- Allocate a communication identifier and optional QP.
+.SH SYNOPSIS
+.B "#include <rdma/rdma_cma.h>"
+.P
+.B "int" rdma_create_ep
+.BI "(struct rdma_cm_id **" id ","
+.BI "struct rdma_addrinfo *" res ","
+.BI "struct ibv_pd *" pd ","
+.BI "struct ibv_qp_init_attr *" qp_init_attr ");"
+.SH ARGUMENTS
+.IP "id" 12
+A reference where the allocated communication identifier will be
+returned.
+.IP "res" 12
+Address information associated with the rdma_cm_id returned from
+rdma_getaddrinfo.
+.IP "pd" 12
+Optional protection domain if a QP is associated with the rdma_cm_id.
+.IP "qp_init_attr" 12
+Optional initial QP attributes.
+.SH "DESCRIPTION"
+Creates an identifier that is used to track communication information.
+.SH "RETURN VALUE"
+Returns 0 on success, or -1 on error. If an error occurs, errno will be
+set to indicate the failure reason.
+.SH "NOTES"
+After resolving address information using rdma_getaddrinfo, a user
+may use this call to allocate an rdma_cm_id based on the results.
+.P
+If the rdma_cm_id will be used on the active side of a connection,
+meaning that res->ai_flag does not have RAI_PASSIVE set, rdma_create_ep
+will automatically create a QP on the rdma_cm_id if qp_init_attr is
+not NULL. The QP will be associated with the specified protection
+domain, if provided, or a default protection domain if not. Users
+should see rdma_create_qp for details on the use of the pd and
+qp_init_attr parameters. After calling rdma_create_ep, the returned
+rdma_cm_id may be connected by calling rdma_connect. The active side
+calls rdma_resolve_addr and rdma_resolve_route are not necessary.
+.P
+If the rdma_cm_id will be used on the passive side of a connection,
+indicated by having res->ai_flag RAI_PASSIVE set, this call will save
+the provided pd and qp_init_attr parameters. When a new connection
+request is retrieved by calling rdma_get_request, the rdma_cm_id
+associated with the new connection will automatically be associated
+with a QP using the pd and qp_init_attr parameters. After calling
+rdma_create_ep, the returned rdma_cm_id may be placed into a listening
+state by immediately calling rdma_listen. The passive side call
+rdma_bind_addr is not necessary. Connection requests may then be
+retrieved by calling rdma_get_request.
+.P
+The newly created rdma_cm_id will be set to use synchronous operation.
+Users that wish asynchronous operation must migrate the rdma_cm_id
+to a user created event channel using rdma_migrate_id.
+.P
+Users must release the created rdma_cm_id by calling rdma_destroy_ep.
+.SH "SEE ALSO"
+rdma_cm(7), rdma_getaddrinfo(3), rdma_create_event_channel(3),
+rdma_connect(3), rdma_listen(3), rdma_destroy_ep(3), rdma_migrate_id(3)
diff --git a/contrib/ofed/librdmacm/man/rdma_create_event_channel.3 b/contrib/ofed/librdmacm/man/rdma_create_event_channel.3
index 67db268..928c797 100644
--- a/contrib/ofed/librdmacm/man/rdma_create_event_channel.3
+++ b/contrib/ofed/librdmacm/man/rdma_create_event_channel.3
@@ -1,3 +1,4 @@
+.\" Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md
.TH "RDMA_CREATE_EVENT_CHANNEL" 3 "2007-05-15" "librdmacm" "Librdmacm Programmer's Manual" librdmacm
.SH NAME
rdma_create_event_channel \- Open a channel used to report communication events.
@@ -11,6 +12,9 @@ rdma_create_event_channel \- Open a channel used to report communication events.
no arguments
.SH "DESCRIPTION"
Asynchronous events are reported to users through event channels.
+.SH "RETURN VALUE"
+Returns a pointer to the created event channel, or NULL if the request
+fails. On failure, errno will be set to indicate the failure reason.
.SH "NOTES"
Event channels are used to direct all events on an rdma_cm_id. For many
clients, a single event channel may be sufficient, however, when managing
diff --git a/contrib/ofed/librdmacm/man/rdma_create_id.3 b/contrib/ofed/librdmacm/man/rdma_create_id.3
index eb29f3c..0a5093a 100644
--- a/contrib/ofed/librdmacm/man/rdma_create_id.3
+++ b/contrib/ofed/librdmacm/man/rdma_create_id.3
@@ -1,4 +1,5 @@
-.TH "RDMA_CREATE_ID" 3 "2007-08-06" "librdmacm" "Librdmacm Programmer's Manual" librdmacm
+.\" Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md
+.TH "RDMA_CREATE_ID" 3 "2010-07-19" "librdmacm" "Librdmacm Programmer's Manual" librdmacm
.SH NAME
rdma_create_id \- Allocate a communication identifier.
.SH SYNOPSIS
@@ -12,7 +13,7 @@ rdma_create_id \- Allocate a communication identifier.
.SH ARGUMENTS
.IP "channel" 12
The communication channel that events associated with the
-allocated rdma_cm_id will be reported on.
+allocated rdma_cm_id will be reported on. This may be NULL.
.IP "id" 12
A reference where the allocated communication identifier will be
returned.
@@ -22,13 +23,22 @@ User specified context associated with the rdma_cm_id.
RDMA port space.
.SH "DESCRIPTION"
Creates an identifier that is used to track communication information.
+.SH "RETURN VALUE"
+Returns 0 on success, or -1 on error. If an error occurs, errno will be
+set to indicate the failure reason.
.SH "NOTES"
Rdma_cm_id's are conceptually equivalent to a socket for RDMA
communication. The difference is that RDMA communication requires
explicitly binding to a specified RDMA device before communication
-can occur, and most operations are asynchronous in nature. Communication
-events on an rdma_cm_id are reported through the associated event
-channel. Users must release the rdma_cm_id by calling rdma_destroy_id.
+can occur, and most operations are asynchronous in nature. Asynchronous
+communication events on an rdma_cm_id are reported through the associated
+event channel. If the channel parameter is NULL, the rdma_cm_id will
+be placed into synchronous operation. While operating synchronously,
+calls that result in an event will block until the operation completes.
+The event will be returned to the user through the rdma_cm_id structure,
+and be available for access until another rdma_cm call is made.
+.P
+Users must release the rdma_cm_id by calling rdma_destroy_id.
.SH "PORT SPACE"
Details of the services provided by the different port spaces are outlined
below.
@@ -38,6 +48,8 @@ port space provides message, not stream, based communication.
.IP RDMA_PS_UDP
Provides unreliable, connectionless QP communication. Supports both datagram
and multicast communication.
+.IP RDMA_PS_IB
+Provides for any IB services (UD, UC, RC, XRC, etc.).
.SH "SEE ALSO"
rdma_cm(7), rdma_create_event_channel(3), rdma_destroy_id(3), rdma_get_devices(3),
rdma_bind_addr(3), rdma_resolve_addr(3), rdma_connect(3), rdma_listen(3),
diff --git a/contrib/ofed/librdmacm/man/rdma_create_qp.3 b/contrib/ofed/librdmacm/man/rdma_create_qp.3
index 0931499..cd4708f 100644
--- a/contrib/ofed/librdmacm/man/rdma_create_qp.3
+++ b/contrib/ofed/librdmacm/man/rdma_create_qp.3
@@ -1,3 +1,4 @@
+.\" Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md
.TH "RDMA_CREATE_QP" 3 "2007-05-15" "librdmacm" "Librdmacm Programmer's Manual" librdmacm
.SH NAME
rdma_create_qp \- Allocate a QP.
@@ -12,12 +13,15 @@ rdma_create_qp \- Allocate a QP.
.IP "id" 12
RDMA identifier.
.IP "pd" 12
-protection domain for the QP.
+Optional protection domain for the QP.
.IP "qp_init_attr" 12
-initial QP attributes.
+Initial QP attributes.
.SH "DESCRIPTION"
Allocate a QP associated with the specified rdma_cm_id and transition it
for sending and receiving.
+.SH "RETURN VALUE"
+Returns 0 on success, or -1 on error. If an error occurs, errno will be
+set to indicate the failure reason.
.SH "NOTES"
The rdma_cm_id must be bound to a local RDMA device before calling this
function, and the protection domain must be for that same device.
@@ -25,6 +29,21 @@ QPs allocated to an rdma_cm_id are automatically transitioned by the
librdmacm through their states. After being allocated, the QP will be
ready to handle posting of receives. If the QP is unconnected, it will
be ready to post sends.
+.P
+If a protection domain is not given - pd parameter is NULL - then
+the rdma_cm_id will be created using a default protection domain. One
+default protection domain is allocated per RDMA device.
+.P
+The initial QP attributes are specified by the qp_init_attr parameter. The
+send_cq and recv_cq fields in the ibv_qp_init_attr are optional. If
+a send or receive completion queue is not specified, then a CQ will be
+allocated by the rdma_cm for the QP, along with corresponding completion
+channels. Completion channels and CQ data created by the rdma_cm are
+exposed to the user through the rdma_cm_id structure.
+.P
+The actual capabilities and properties of the created QP will be
+returned to the user through the qp_init_attr parameter. An rdma_cm_id
+may only be associated with a single QP.
.SH "SEE ALSO"
rdma_bind_addr(3), rdma_resolve_addr(3), rdma_destroy_qp(3), ibv_create_qp(3),
ibv_modify_qp(3)
diff --git a/contrib/ofed/librdmacm/man/rdma_create_srq.3 b/contrib/ofed/librdmacm/man/rdma_create_srq.3
new file mode 100644
index 0000000..6257e86
--- /dev/null
+++ b/contrib/ofed/librdmacm/man/rdma_create_srq.3
@@ -0,0 +1,45 @@
+.\" Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md
+.TH "RDMA_CREATE_SRQ" 3 "2011-06-15" "librdmacm" "Librdmacm Programmer's Manual" librdmacm
+.SH NAME
+rdma_create_srq \- Allocate a shared receive queue.
+.SH SYNOPSIS
+.B "#include <rdma/rdma_verbs.h>"
+.P
+.B "int" rdma_create_srq
+.BI "(struct rdma_cm_id *" id ","
+.BI "struct ibv_pd *" pd ","
+.BI "struct ibv_srq_init_attr *" attr ");"
+.SH ARGUMENTS
+.IP "id" 12
+RDMA identifier.
+.IP "pd" 12
+Optional protection domain for the SRQ.
+.IP "attr" 12
+Initial SRQ attributes.
+.SH "DESCRIPTION"
+Allocate a SRQ associated with the specified rdma_cm_id.
+.SH "RETURN VALUE"
+Returns 0 on success, or -1 on error. If an error occurs, errno will be
+set to indicate the failure reason.
+.SH "NOTES"
+The rdma_cm_id must be bound to a local RDMA device before calling this
+function, and the protection domain, if provided, must be for that same device.
+After being allocated, the SRQ will be ready to handle posting of receives.
+.P
+If a protection domain is not given - pd parameter is NULL - then
+the rdma_cm_id will be created using a default protection domain. One
+default protection domain is allocated per RDMA device.
+.P
+The initial SRQ attributes are specified by the attr parameter. The
+ext.xrc.cq fields in the ibv_srq_init_attr is optional. If
+a completion queue is not specified for an XRC SRQ, then a CQ will be
+allocated by the rdma_cm for the SRQ, along with corresponding completion
+channels. Completion channels and CQ data created by the rdma_cm are
+exposed to the user through the rdma_cm_id structure.
+.P
+The actual capabilities and properties of the created SRQ will be
+returned to the user through the attr parameter. An rdma_cm_id
+may only be associated with a single SRQ.
+.SH "SEE ALSO"
+rdma_bind_addr(3), rdma_resolve_addr(3), rdma_create_ep(3),
+rdma_destroy_srq(3), ibv_create_srq(3), ibv_create_xsrq(3)
diff --git a/contrib/ofed/librdmacm/man/rdma_dereg_mr.3 b/contrib/ofed/librdmacm/man/rdma_dereg_mr.3
new file mode 100644
index 0000000..1fe936b
--- /dev/null
+++ b/contrib/ofed/librdmacm/man/rdma_dereg_mr.3
@@ -0,0 +1,29 @@
+.\" Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md
+.TH "RDMA_DEREG_MR" 3 "2010-07-19" "librdmacm" "Librdmacm Programmer's Manual" librdmacm
+.SH NAME
+rdma_dereg_mr \- deregisters a registered memory region.
+.SH SYNOPSIS
+.B "#include <rdma/rdma_verbs.h>"
+.P
+.B "struct ibv_mr *" rdma_dereg_mr
+.BI "(struct ibv_mr *" mr ");"
+.SH ARGUMENTS
+.IP "mr" 12
+A reference to a registered memory buffer.
+.SH "DESCRIPTION"
+Deregisters a memory buffer that had been registered for RDMA
+or message operations. A user should call rdma_dereg_mr for all
+registered memory associated with an rdma_cm_id before destroying
+the rdma_cm_id.
+.SH "RETURN VALUE"
+Returns 0 on success, or -1 on error. If an error occurs, errno will be
+set to indicate the failure reason.
+.SH "NOTES"
+All memory registered with an rdma_cm_id is associated with the
+protection domain associated with the id. Users must deregister
+all registered memory before the protection domain can be destroyed.
+.SH "SEE ALSO"
+rdma_cm(7), rdma_create_id(3), rdma_create_ep(3),
+rdma_destroy_id(3), rdma_destroy_ep(3),
+rdma_reg_msgs(3), rdma_reg_read(3), rdma_reg_write(3),
+ibv_reg_mr(3), ibv_dereg_mr(3)
diff --git a/contrib/ofed/librdmacm/man/rdma_destroy_ep.3 b/contrib/ofed/librdmacm/man/rdma_destroy_ep.3
new file mode 100644
index 0000000..1211f4b
--- /dev/null
+++ b/contrib/ofed/librdmacm/man/rdma_destroy_ep.3
@@ -0,0 +1,20 @@
+.\" Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md
+
+.TH "RDMA_DESTROY_EP" 3 "2011-06-15" "librdmacm" "Librdmacm Programmer's Manual" librdmacm
+.SH NAME
+rdma_destroy_ep \- Release a communication identifier.
+.SH SYNOPSIS
+.B "#include <rdma/rdma_cma.h>"
+.P
+.B "void" rdma_destroy_ep
+.BI "(struct rdma_cm_id *" id ");"
+.SH ARGUMENTS
+.IP "id" 12
+The communication identifier to destroy.
+.SH "DESCRIPTION"
+Destroys the specified rdma_cm_id and all associated resources
+.SH "NOTES"
+rdma_destroy_ep will automatically destroy any QP and SRQ associated with
+the rdma_cm_id.
+.SH "SEE ALSO"
+rdma_create_ep(3)
diff --git a/contrib/ofed/librdmacm/man/rdma_destroy_event_channel.3 b/contrib/ofed/librdmacm/man/rdma_destroy_event_channel.3
index ed4636e..5bc982a 100644
--- a/contrib/ofed/librdmacm/man/rdma_destroy_event_channel.3
+++ b/contrib/ofed/librdmacm/man/rdma_destroy_event_channel.3
@@ -1,3 +1,4 @@
+.\" Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md
.TH "RDMA_DESTROY_EVENT_CHANNEL" 3 "2007-05-15" "librdmacm" "Librdmacm Programmer's Manual" librdmacm
.SH NAME
rdma_destroy_event_channel \- Close an event communication channel.
@@ -12,6 +13,9 @@ The communication channel to destroy.
.SH "DESCRIPTION"
Release all resources associated with an event channel and closes the
associated file descriptor.
+.SH "RETURN VALUE"
+Returns 0 on success, or -1 on error. If an error occurs, errno will be
+set to indicate the failure reason.
.SH "NOTES"
All rdma_cm_id's associated with the event channel must be destroyed,
and all returned events must be acked before calling this function.
diff --git a/contrib/ofed/librdmacm/man/rdma_destroy_id.3 b/contrib/ofed/librdmacm/man/rdma_destroy_id.3
index 77e8151..1d95ff2 100644
--- a/contrib/ofed/librdmacm/man/rdma_destroy_id.3
+++ b/contrib/ofed/librdmacm/man/rdma_destroy_id.3
@@ -1,4 +1,5 @@
-.TH "RDMA_DESTROY_ID" 3 "2007-05-15" "librdmacm" "Librdmacm Programmer's Manual" librdmacm
+.\" Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md
+.TH "RDMA_DESTROY_ID" 3 "2010-07-19" "librdmacm" "Librdmacm Programmer's Manual" librdmacm
.SH NAME
rdma_destroy_id \- Release a communication identifier.
.SH SYNOPSIS
@@ -12,8 +13,11 @@ The communication identifier to destroy.
.SH "DESCRIPTION"
Destroys the specified rdma_cm_id and cancels any outstanding
asynchronous operation.
+.SH "RETURN VALUE"
+Returns 0 on success, or -1 on error. If an error occurs, errno will be
+set to indicate the failure reason.
.SH "NOTES"
Users must free any associated QP with the rdma_cm_id before
-calling this routine and ack an related events.
+calling this routine and ack all related events.
.SH "SEE ALSO"
rdma_create_id(3), rdma_destroy_qp(3), rdma_ack_cm_event(3)
diff --git a/contrib/ofed/librdmacm/man/rdma_destroy_qp.3 b/contrib/ofed/librdmacm/man/rdma_destroy_qp.3
index bb1360e..03fba27 100644
--- a/contrib/ofed/librdmacm/man/rdma_destroy_qp.3
+++ b/contrib/ofed/librdmacm/man/rdma_destroy_qp.3
@@ -1,3 +1,4 @@
+.\" Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md
.TH "RDMA_DESTROY_QP" 3 "2007-05-15" "librdmacm" "Librdmacm Programmer's Manual" librdmacm
.SH NAME
rdma_destroy_qp \- Deallocate a QP.
diff --git a/contrib/ofed/librdmacm/man/rdma_destroy_srq.3 b/contrib/ofed/librdmacm/man/rdma_destroy_srq.3
new file mode 100644
index 0000000..5c633a8
--- /dev/null
+++ b/contrib/ofed/librdmacm/man/rdma_destroy_srq.3
@@ -0,0 +1,22 @@
+.\" Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md
+.TH "RDMA_DESTROY_SRQ" 3 "2011-06-15" "librdmacm" "Librdmacm Programmer's Manual" librdmacm
+.SH NAME
+rdma_destroy_srq \- Deallocate a SRQ.
+.SH SYNOPSIS
+.B "#include <rdma/rdma_verbs.h>"
+.P
+.B "void" rdma_destroy_srq
+.BI "(struct rdma_cm_id *" id ");"
+.SH ARGUMENTS
+.IP "id" 12
+RDMA identifier.
+.SH "DESCRIPTION"
+Destroy an SRQ allocated on the rdma_cm_id.
+.SH "RETURN VALUE"
+Returns 0 on success, or -1 on error. If an error occurs, errno will be
+set to indicate the failure reason.
+.SH "NOTES"
+Users should destroy any SRQ associated with an rdma_cm_id before
+destroying the ID.
+.SH "SEE ALSO"
+rdma_create_srq(3), rdma_destroy_id(3), ibv_destroy_srq(3)
diff --git a/contrib/ofed/librdmacm/man/rdma_disconnect.3 b/contrib/ofed/librdmacm/man/rdma_disconnect.3
index 8b2a035..23aec98 100644
--- a/contrib/ofed/librdmacm/man/rdma_disconnect.3
+++ b/contrib/ofed/librdmacm/man/rdma_disconnect.3
@@ -1,3 +1,4 @@
+.\" Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md
.TH "RDMA_DISCONNECT" 3 "2008-01-02" "librdmacm" "Librdmacm Programmer's Manual" librdmacm
.SH NAME
rdma_disconnect \- This function disconnects a connection.
@@ -12,8 +13,11 @@ RDMA identifier.
.SH "DESCRIPTION"
Disconnects a connection and transitions any associated QP to the error state,
which will flush any posted work requests to the completion queue. This
-routine may be called by both the client and server side of a connection.
+routine should be called by both the client and server side of a connection.
After successfully disconnecting, an RDMA_CM_EVENT_DISCONNECTED event will be
generated on both sides of the connection.
+.SH "RETURN VALUE"
+Returns 0 on success, or -1 on error. If an error occurs, errno will be
+set to indicate the failure reason.
.SH "SEE ALSO"
rdma_connect(3), rdma_listen(3), rdma_accept(3), rdma_get_cm_event(3)
diff --git a/contrib/ofed/librdmacm/man/rdma_event_str.3 b/contrib/ofed/librdmacm/man/rdma_event_str.3
index 6126983..24c9e16 100644
--- a/contrib/ofed/librdmacm/man/rdma_event_str.3
+++ b/contrib/ofed/librdmacm/man/rdma_event_str.3
@@ -1,3 +1,4 @@
+.\" Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md
.TH "RDMA_EVENT_STR" 3 "2007-05-15" "librdmacm" "Librdmacm Programmer's Manual" librdmacm
.SH NAME
rdma_event_str \- Returns a string representation of an rdma cm event.
@@ -11,5 +12,7 @@ rdma_event_str \- Returns a string representation of an rdma cm event.
Asynchronous event.
.SH "DESCRIPTION"
Returns a string representation of an asynchronous event.
+.SH "RETURN VALUE"
+Returns a pointer to a static character string corresponding to the event.
.SH "SEE ALSO"
rdma_get_cm_event(3)
diff --git a/contrib/ofed/librdmacm/man/rdma_free_devices.3 b/contrib/ofed/librdmacm/man/rdma_free_devices.3
index 1ed4cb3..c46bcbf 100644
--- a/contrib/ofed/librdmacm/man/rdma_free_devices.3
+++ b/contrib/ofed/librdmacm/man/rdma_free_devices.3
@@ -1,3 +1,4 @@
+.\" Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md
.TH "RDMA_FREE_DEVICES" 3 "2007-05-15" "librdmacm" "Librdmacm Programmer's Manual" librdmacm
.SH NAME
rdma_free_devices \- Frees the list of devices returned by rdma_get_devices.
@@ -11,5 +12,7 @@ rdma_free_devices \- Frees the list of devices returned by rdma_get_devices.
List of devices returned from rdma_get_devices.
.SH "DESCRIPTION"
Frees the device array returned by rdma_get_devices.
+.SH "RETURN VALUE"
+None
.SH "SEE ALSO"
rdma_get_devices(3)
diff --git a/contrib/ofed/librdmacm/man/rdma_get_cm_event.3 b/contrib/ofed/librdmacm/man/rdma_get_cm_event.3
index 79bf606..2623eab 100644
--- a/contrib/ofed/librdmacm/man/rdma_get_cm_event.3
+++ b/contrib/ofed/librdmacm/man/rdma_get_cm_event.3
@@ -1,3 +1,4 @@
+.\" Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md
.TH "RDMA_GET_CM_EVENT" 3 "2007-10-31" "librdmacm" "Librdmacm Programmer's Manual" librdmacm
.SH NAME
rdma_get_cm_event \- Retrieves the next pending communication event.
@@ -15,6 +16,9 @@ Allocated information about the next communication event.
.SH "DESCRIPTION"
Retrieves a communication event. If no events are pending, by default,
the call will block until an event is received.
+.SH "RETURN VALUE"
+Returns 0 on success, or -1 on error. If an error occurs, errno will be
+set to indicate the failure reason.
.SH "NOTES"
The default synchronous behavior of this routine can be changed by
modifying the file descriptor associated with the given channel. All
@@ -38,7 +42,10 @@ Specifies the type of communication event which occurred. See EVENT TYPES
below.
.IP "status" 12
Returns any asynchronous error information associated with an event. The
-status is zero unless the corresponding operation failed.
+status is zero if the operation was successful, otherwise the status value
+is non-zero and is either set to an errno or a transport specific value.
+For details on transport specific status values, see the event type information
+below.
.IP "param" 12
Provides additional details based on the type of event. Users should
select the conn or ud subfields based on the rdma_port_space of the
@@ -123,10 +130,15 @@ Indicates that an error has occurred trying to establish or a connection.
May be generated on the active or passive side of a connection.
.IP RDMA_CM_EVENT_UNREACHABLE
Generated on the active side to notify the user that the remote server is
-not reachable or unable to respond to a connection request.
+not reachable or unable to respond to a connection request. If this event
+is generated in response to a UD QP resolution request over InfiniBand,
+the event status field will contain an errno, if negative, or the status
+result carried in the IB CM SIDR REP message.
.IP RDMA_CM_EVENT_REJECTED
Indicates that a connection request or response was rejected by the remote
-end point.
+end point. The event status field will contain the transport specific
+reject reason if available. Under InfiniBand, this is the reject reason
+carried in the IB CM REJ message.
.IP RDMA_CM_EVENT_ESTABLISHED
Indicates that a connection has been established with the remote end point.
.IP RDMA_CM_EVENT_DISCONNECTED
diff --git a/contrib/ofed/librdmacm/man/rdma_get_devices.3 b/contrib/ofed/librdmacm/man/rdma_get_devices.3
index 05dcee2..be41514 100644
--- a/contrib/ofed/librdmacm/man/rdma_get_devices.3
+++ b/contrib/ofed/librdmacm/man/rdma_get_devices.3
@@ -1,3 +1,4 @@
+.\" Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md
.TH "RDMA_GET_DEVICES" 3 "2007-05-15" "librdmacm" "Librdmacm Programmer's Manual" librdmacm
.SH NAME
rdma_get_devices \- Get a list of RDMA devices currently available.
@@ -13,6 +14,9 @@ If non-NULL, set to the number of devices returned.
Return a NULL-terminated array of opened RDMA devices. Callers can use
this routine to allocate resources on specific RDMA devices that will be
shared across multiple rdma_cm_id's.
+.SH "RETURN VALUE"
+Returns an array of available RDMA devices, or NULL if the request
+fails. On failure, errno will be set to indicate the failure reason.
.SH "NOTES"
The returned array must be released by calling rdma_free_devices. Devices
remain opened while the librdmacm is loaded.
diff --git a/contrib/ofed/librdmacm/man/rdma_get_dst_port.3 b/contrib/ofed/librdmacm/man/rdma_get_dst_port.3
index 92932e9..1863783 100644
--- a/contrib/ofed/librdmacm/man/rdma_get_dst_port.3
+++ b/contrib/ofed/librdmacm/man/rdma_get_dst_port.3
@@ -1,3 +1,4 @@
+.\" Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md
.TH "RDMA_GET_DST_PORT" 3 "2007-05-15" "librdmacm" "Librdmacm Programmer's Manual" librdmacm
.SH NAME
rdma_get_dst_port \- Returns the remote port number of a bound rdma_cm_id.
@@ -12,6 +13,9 @@ RDMA identifier.
.SH "DESCRIPTION"
Returns the remote port number for an rdma_cm_id that has been bound to
a remote address.
+.SH "RETURN VALUE"
+Returns the 16-bit port identifier associated with the peer endpoint. If
+the rdma_cm_id is not connected, the returned value is 0.
.SH "SEE ALSO"
rdma_connect(3), rdma_accept(3), rdma_get_cm_event(3), rdma_get_src_port(3),
rdma_get_local_addr(3), rdma_get_peer_addr(3)
diff --git a/contrib/ofed/librdmacm/man/rdma_get_local_addr.3 b/contrib/ofed/librdmacm/man/rdma_get_local_addr.3
index 8085627..eeaa714 100644
--- a/contrib/ofed/librdmacm/man/rdma_get_local_addr.3
+++ b/contrib/ofed/librdmacm/man/rdma_get_local_addr.3
@@ -1,3 +1,4 @@
+.\" Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md
.TH "RDMA_GET_LOCAL_ADDR" 3 "2007-05-15" "librdmacm" "Librdmacm Programmer's Manual" librdmacm
.SH NAME
rdma_get_local_addr \- Returns the local IP address of a bound rdma_cm_id.
@@ -12,6 +13,10 @@ RDMA identifier.
.SH "DESCRIPTION"
Returns the local IP address for an rdma_cm_id that has been bound to
a local device.
+.SH "RETURN VALUE"
+Returns a pointer to the local sockaddr address of the rdma_cm_id. If
+the rdma_cm_id is not bound to an address, the contents of the sockaddr
+structure will be set to all zeroes.
.SH "SEE ALSO"
rdma_bind_addr(3), rdma_resolve_addr(3), rdma_get_src_port(3),
rdma_get_dst_port(3), rdma_get_peer_addr(3)
diff --git a/contrib/ofed/librdmacm/man/rdma_get_peer_addr.3 b/contrib/ofed/librdmacm/man/rdma_get_peer_addr.3
index 880e9c5..ff8ce4e 100644
--- a/contrib/ofed/librdmacm/man/rdma_get_peer_addr.3
+++ b/contrib/ofed/librdmacm/man/rdma_get_peer_addr.3
@@ -1,3 +1,4 @@
+.\" Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md
.TH "RDMA_GET_PEER_ADDR" 3 "2007-05-15" "librdmacm" "Librdmacm Programmer's Manual" librdmacm
.SH NAME
rdma_get_peer_addr \- Returns the remote IP address of a bound rdma_cm_id.
@@ -11,6 +12,10 @@ rdma_get_peer_addr \- Returns the remote IP address of a bound rdma_cm_id.
RDMA identifier.
.SH "DESCRIPTION"
Returns the remote IP address associated with an rdma_cm_id.
+.SH "RETURN VALUE"
+Returns a pointer to the sockaddr address of the connected peer. If
+the rdma_cm_id is not connected, the contents of the sockaddr
+structure will be set to all zeroes.
.SH "SEE ALSO"
rdma_resolve_addr(3), rdma_get_src_port(3), rdma_get_dst_port(3),
rdma_get_local_addr(3)
diff --git a/contrib/ofed/librdmacm/man/rdma_get_recv_comp.3 b/contrib/ofed/librdmacm/man/rdma_get_recv_comp.3
new file mode 100644
index 0000000..6894e5d
--- /dev/null
+++ b/contrib/ofed/librdmacm/man/rdma_get_recv_comp.3
@@ -0,0 +1,32 @@
+.\" Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md
+.TH "RDMA_GET_RECV_COMP" 3 "2010-07-19" "librdmacm" "Librdmacm Programmer's Manual" librdmacm
+.SH NAME
+rdma_get_recv_comp \- retrieves a completed receive request.
+.SH SYNOPSIS
+.B "#include <rdma/rdma_verbs.h>"
+.P
+.B "int" rdma_get_recv_comp
+.BI "(struct rdma_cm_id *" id ","
+.BI "struct ibv_wc *" wc ");"
+.SH ARGUMENTS
+.IP "id" 12
+A reference to a communication identifier to check for completions.
+.IP "wc" 12
+A reference to a work completion structure to fill in.
+.SH "DESCRIPTION"
+Retrieves a completed work request for a receive
+operation. Information about the completed request is returned through
+the wc parameter, with the wr_id set to the context of the request. For
+details on the work completion structure, see ibv_poll_cq.
+.SH "RETURN VALUE"
+Returns the number of returned completions (0 or 1) on success, or -1 on error.
+If an error occurs, errno will be set to indicate the failure reason.
+.SH "NOTES"
+This calls polls the receive completion queue associated with an rdma_cm_id.
+If a completion is not found, the call blocks until a request completes.
+This call should only be used on rdma_cm_id's that do not share CQs
+with other rdma_cm_id's, and maintain separate CQs for sends and receive
+completions.
+.SH "SEE ALSO"
+rdma_cm(7), ibv_poll_cq(3), rdma_get_send_comp(3),
+rdma_post_send(3), rdma_post_read(3), rdma_post_write(3)
diff --git a/contrib/ofed/librdmacm/man/rdma_get_request.3 b/contrib/ofed/librdmacm/man/rdma_get_request.3
new file mode 100644
index 0000000..86cb610
--- /dev/null
+++ b/contrib/ofed/librdmacm/man/rdma_get_request.3
@@ -0,0 +1,35 @@
+.\" Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md
+.TH "RDMA_GET_REQUEST" 3 "2007-10-31" "librdmacm" "Librdmacm Programmer's Manual" librdmacm
+.SH NAME
+rdma_get_request \- Retrieves the next pending connection request event.
+.SH SYNOPSIS
+.B "#include <rdma/rdma_cma.h>"
+.P
+.B "int" rdma_get_request
+.BI "(struct rdma_cm_id *" listen ","
+.BI "struct rdma_cm_id **" id ");"
+.SH ARGUMENTS
+.IP "listen" 12
+Listening rdma_cm_id.
+.IP "id" 12
+rdma_cm_id associated with the new connection.
+.SH "DESCRIPTION"
+Retrieves a connection request event. If no requests are pending,
+the call will block until an event is received.
+.SH "RETURN VALUE"
+Returns 0 on success, or -1 on error. If an error occurs, errno will be
+set to indicate the failure reason.
+.SH "NOTES"
+This call may only be used on listening rdma_cm_id's operating
+synchronously. On success, a new rdma_cm_id representing the
+connection request will be returned to the user. The new rdma_cm_id
+will reference event information associated with the request until
+the user calls rdma_reject, rdma_accept, or rdma_destroy_id on the
+newly created identifier. For a description of the event data,
+see rdma_get_cm_event.
+.P
+If QP attributes are associated with the listening endpoint, the
+returned rdma_cm_id will also reference an allocated QP.
+.SH "SEE ALSO"
+rdma_get_cm_event(3), rdma_accept(3), rdma_reject(3),
+rdma_connect(3), rdma_listen(3), rdma_destroy_id(3)
diff --git a/contrib/ofed/librdmacm/man/rdma_get_send_comp.3 b/contrib/ofed/librdmacm/man/rdma_get_send_comp.3
new file mode 100644
index 0000000..5085ddb
--- /dev/null
+++ b/contrib/ofed/librdmacm/man/rdma_get_send_comp.3
@@ -0,0 +1,32 @@
+.\" Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md
+.TH "RDMA_GET_SEND_COMP" 3 "2010-07-19" "librdmacm" "Librdmacm Programmer's Manual" librdmacm
+.SH NAME
+rdma_get_send_comp \- retrieves a completed send, read, or write request.
+.SH SYNOPSIS
+.B "#include <rdma/rdma_verbs.h>"
+.P
+.B "int" rdma_get_send_comp
+.BI "(struct rdma_cm_id *" id ","
+.BI "struct ibv_wc *" wc ");"
+.SH ARGUMENTS
+.IP "id" 12
+A reference to a communication identifier to check for completions.
+.IP "wc" 12
+A reference to a work completion structure to fill in.
+.SH "DESCRIPTION"
+Retrieves a completed work request for a send, RDMA read, or RDMA write
+operation. Information about the completed request is returned through
+the wc parameter, with the wr_id set to the context of the request. For
+details on the work completion structure, see ibv_poll_cq.
+.SH "RETURN VALUE"
+Returns the number of returned completions (0 or 1) on success, or -1 on error.
+If an error occurs, errno will be set to indicate the failure reason.
+.SH "NOTES"
+This calls polls the send completion queue associated with an rdma_cm_id.
+If a completion is not found, the call blocks until a request completes.
+This call should only be used on rdma_cm_id's that do not share CQs
+with other rdma_cm_id's, and maintain separate CQs for sends and receive
+completions.
+.SH "SEE ALSO"
+rdma_cm(7), ibv_poll_cq(3), rdma_get_recv_comp(3),
+rdma_post_send(3), rdma_post_read(3), rdma_post_write(3)
diff --git a/contrib/ofed/librdmacm/man/rdma_get_src_port.3 b/contrib/ofed/librdmacm/man/rdma_get_src_port.3
index 0a2f445..1e36a92 100644
--- a/contrib/ofed/librdmacm/man/rdma_get_src_port.3
+++ b/contrib/ofed/librdmacm/man/rdma_get_src_port.3
@@ -1,3 +1,4 @@
+.\" Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md
.TH "RDMA_GET_SRC_PORT" 3 "2007-05-15" "librdmacm" "Librdmacm Programmer's Manual" librdmacm
.SH NAME
rdma_get_src_port \- Returns the local port number of a bound rdma_cm_id.
@@ -12,6 +13,9 @@ RDMA identifier.
.SH "DESCRIPTION"
Returns the local port number for an rdma_cm_id that has been bound to
a local address.
+.SH "RETURN VALUE"
+Returns the 16-bit port identifier associated with the local endpoint. If
+the rdma_cm_id is not bound to a port, the returned value is 0.
.SH "SEE ALSO"
rdma_bind_addr(3), rdma_resolve_addr(3), rdma_get_dst_port(3),
rdma_get_local_addr(3), rdma_get_peer_addr(3)
diff --git a/contrib/ofed/librdmacm/man/rdma_getaddrinfo.3 b/contrib/ofed/librdmacm/man/rdma_getaddrinfo.3
new file mode 100644
index 0000000..3ad6393
--- /dev/null
+++ b/contrib/ofed/librdmacm/man/rdma_getaddrinfo.3
@@ -0,0 +1,105 @@
+.\" Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md
+.TH "RDMA_GETADDRINFO" 3 "2010-07-19" "librdmacm" "Librdmacm Programmer's Manual" librdmacm
+.SH NAME
+rdma_getaddrinfo \- Provides transport independent address translation.
+.SH SYNOPSIS
+.B "#include <rdma/rdma_cma.h>"
+.P
+.B "int" rdma_getaddrinfo
+.BI "(const char *" node ","
+.BI "const char *" service ","
+.BI "const struct rdma_addrinfo *" hints ","
+.BI "struct rdma_addrinfo **" res ");"
+.SH ARGUMENTS
+.IP "node" 12
+Optional, name, dotted-decimal IPv4, or IPv6 hex address to resolve.
+.IP "service" 12
+Service name or port number of address.
+.IP "hints" 12
+Reference to an rdma_addrinfo structure containing hints about the type
+of service the caller supports.
+.IP "res" 12
+A pointer to a linked list of rdma_addrinfo structures containing response
+information.
+.SH "DESCRIPTION"
+Resolves the destination node and service address and returns
+information needed to establish communication. Provides the
+RDMA functional equivalent to getaddrinfo.
+.SH "RETURN VALUE"
+Returns 0 on success, or -1 on error. If an error occurs, errno will be
+set to indicate the failure reason.
+.SH "NOTES"
+Either node, service, or hints must be provided. If hints are provided, the
+operation will be controlled by hints.ai_flags. If RAI_PASSIVE is
+specified, the call will resolve address information for use on the
+passive side of a connection.
+If node is provided, rdma_getaddrinfo will attempt to resolve the RDMA address,
+route, and connection data to the given node. The hints parameter, if provided,
+may be used to control the resulting output as indicated below.
+If node is not given, rdma_getaddrinfo will attempt to resolve the RDMA addressing
+information based on the hints.ai_src_addr, hints.ai_dst_addr, or hints.ai_route.
+.SH "rdma_addrinfo"
+.IP "ai_flags" 12
+Hint flags that control the operation. Supported flags are:
+.IP "RAI_PASSIVE" 12
+Indicates that the results will be used on the passive/listening
+side of a connection.
+.IP "RAI_NUMERICHOST" 12
+If specified, then the node parameter, if provided, must be a numerical
+network address. This flag suppresses any lengthy address resolution.
+.IP "RAI_NOROUTE" 12
+If set, this flag suppresses any lengthy route resolution.
+.IP "RAI_FAMILY" 12
+If set, the ai_family setting should be used as an input hint for interpretting
+the node parameter.
+.IP "ai_family" 12
+Address family for the source and destination address. Supported families
+are: AF_INET, AF_INET6, and AF_IB.
+.IP "ai_qp_type" 12
+Indicates the type of RDMA QP used for communication. Supported types are:
+IBV_UD (unreliable datagram) and IBV_RC (reliable connected).
+.IP "ai_port_space" 12
+RDMA port space in use. Supported values are: RDMA_PS_UDP, RDMA_PS_TCP,
+and RDMA_PS_IB.
+.IP "ai_src_len" 12
+The length of the source address referenced by ai_src_addr. This will be 0
+if an appropriate source address could not be discovered for a given
+destination.
+.IP "ai_dst_len" 12
+The length of the destination address referenced by ai_dst_addr. This
+will be 0 if the RAI_PASSIVE flag was specified as part of the hints.
+.IP "ai_src_addr" 12
+If provided, the address for the local RDMA device.
+.IP "ai_dst_addr" 12
+If provided, the address for the destination RDMA device.
+.IP "ai_src_canonname" 12
+The canonical for the source.
+.IP "ai_dst_canonname" 12
+The canonical for the destination.
+.IP "ai_route_len" 12
+Size of the routing information buffer referenced by ai_route. This will
+be 0 if the underlying transport does not require routing data, or none
+could be resolved.
+.IP "ai_route" 12
+Routing information for RDMA transports that require routing data as part
+of connection establishment. The format of the routing data depends on
+the underlying transport. If Infiniband transports are
+used, ai_route will reference an array of struct ibv_path_data on output,
+if routing data is available. Routing paths may be restricted by setting
+desired routing data fields on input to rdma_getaddrinfo. For Infiniband,
+hints.ai_route may reference an array of struct ibv_path_record or
+struct ibv_path_data on input.
+.IP "ai_connect_len" 12
+Size of connection information referenced by ai_connect. This will be
+0 if the underlying transport does not require additional connection
+information.
+.IP "ai_connect" 12
+Data exchanged as part of the connection establishment process. If provided,
+ai_connect data must be transferred as private data, with any user supplied
+private data following it.
+.IP "ai_next" 12
+Pointer to the next rdma_addrinfo structure in the list. Will be NULL
+if no more structures exist.
+.SH "SEE ALSO"
+rdma_create_id(3), rdma_resolve_route(3), rdma_connect(3), rdma_create_qp(3),
+rdma_bind_addr(3), rdma_create_ep(3)
diff --git a/contrib/ofed/librdmacm/man/rdma_join_multicast.3 b/contrib/ofed/librdmacm/man/rdma_join_multicast.3
index 2df57a0..4e52e85 100644
--- a/contrib/ofed/librdmacm/man/rdma_join_multicast.3
+++ b/contrib/ofed/librdmacm/man/rdma_join_multicast.3
@@ -1,3 +1,4 @@
+.\" Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md
.TH "RDMA_JOIN_MULTICAST" 3 "2008-01-02" "librdmacm" "Librdmacm Programmer's Manual" librdmacm
.SH NAME
rdma_join_multicast \- Joins a multicast group.
@@ -17,6 +18,9 @@ Multicast address identifying the group to join.
User-defined context associated with the join request.
.SH "DESCRIPTION"
Joins a multicast group and attaches an associated QP to the group.
+.SH "RETURN VALUE"
+Returns 0 on success, or -1 on error. If an error occurs, errno will be
+set to indicate the failure reason.
.SH "NOTES"
Before joining a multicast group, the rdma_cm_id must be bound to
an RDMA device by calling rdma_bind_addr or rdma_resolve_addr. Use of
@@ -24,9 +28,12 @@ rdma_resolve_addr requires the local routing tables to resolve the
multicast address to an RDMA device, unless a specific source address
is provided. The user must call rdma_leave_multicast to leave the
multicast group and release any multicast resources. After the join
-operation completes, any associated QP is automatically attached to the
-multicast group, and the join context is returned to the user through
-the private_data field in the rdma_cm_event.
+operation completes, if a QP is associated with the rdma_cm_id,
+it is automatically attached to the multicast group when the multicast
+event is retrieved by the user. Otherwise, the user is responsible
+for calling ibv_attach_mcast to bind the QP to the multicast group.
+The join context is returned to the user through the private_data
+field in the rdma_cm_event.
.SH "SEE ALSO"
rdma_leave_multicast(3), rdma_bind_addr(3), rdma_resolve_addr(3), rdma_create_qp(3),
rdma_get_cm_event(3)
diff --git a/contrib/ofed/librdmacm/man/rdma_leave_multicast.3 b/contrib/ofed/librdmacm/man/rdma_leave_multicast.3
index e4262e8..9e112d3 100644
--- a/contrib/ofed/librdmacm/man/rdma_leave_multicast.3
+++ b/contrib/ofed/librdmacm/man/rdma_leave_multicast.3
@@ -1,3 +1,4 @@
+.\" Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md
.TH "RDMA_LEAVE_MULTICAST" 3 "2007-05-15" "librdmacm" "Librdmacm Programmer's Manual" librdmacm
.SH NAME
rdma_leave_multicast \- Leaves a multicast group.
@@ -14,6 +15,9 @@ Communication identifier associated with the request.
Multicast address identifying the group to leave.
.SH "DESCRIPTION"
Leaves a multicast group and detaches an associated QP from the group.
+.SH "RETURN VALUE"
+Returns 0 on success, or -1 on error. If an error occurs, errno will be
+set to indicate the failure reason.
.SH "NOTES"
Calling this function before a group has been fully joined results in
canceling the join operation. Users should be aware that messages
diff --git a/contrib/ofed/librdmacm/man/rdma_listen.3 b/contrib/ofed/librdmacm/man/rdma_listen.3
index 4266184..78fd270 100644
--- a/contrib/ofed/librdmacm/man/rdma_listen.3
+++ b/contrib/ofed/librdmacm/man/rdma_listen.3
@@ -1,3 +1,4 @@
+.\" Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md
.TH "RDMA_LISTEN" 3 "2007-05-15" "librdmacm" "Librdmacm Programmer's Manual" librdmacm
.SH NAME
rdma_listen \- Listen for incoming connection requests.
@@ -16,6 +17,9 @@ backlog of incoming connection requests.
Initiates a listen for incoming connection requests or datagram service
lookup. The listen will be restricted to the locally bound source
address.
+.SH "RETURN VALUE"
+Returns 0 on success, or -1 on error. If an error occurs, errno will be
+set to indicate the failure reason.
.SH "NOTES"
Users must have bound the rdma_cm_id to a local address by calling
rdma_bind_addr before calling this routine. If the rdma_cm_id is
diff --git a/contrib/ofed/librdmacm/man/rdma_migrate_id.3 b/contrib/ofed/librdmacm/man/rdma_migrate_id.3
index ffbad45..f0f7bce 100644
--- a/contrib/ofed/librdmacm/man/rdma_migrate_id.3
+++ b/contrib/ofed/librdmacm/man/rdma_migrate_id.3
@@ -1,6 +1,7 @@
+.\" Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md
.TH "RDMA_MIGRATE_ID" 3 "2007-11-13" "librdmacm" "Librdmacm Programmer's Manual" librdmacm
.SH NAME
-rdma_migrate_id \- Move a communication identifer to a different event channel.
+rdma_migrate_id \- Move a communication identifier to a different event channel.
.SH SYNOPSIS
.B "#include <rdma/rdma_cma.h>"
.P
@@ -12,9 +13,12 @@ rdma_migrate_id \- Move a communication identifer to a different event channel.
An existing communication identifier to migrate.
.IP "channel" 12
The communication channel that events associated with the
-allocated rdma_cm_id will be reported on.
+allocated rdma_cm_id will be reported on. May be NULL.
.SH "DESCRIPTION"
Migrates a communication identifier to a different event channel.
+.SH "RETURN VALUE"
+Returns 0 on success, or -1 on error. If an error occurs, errno will be
+set to indicate the failure reason.
.SH "NOTES"
This routine migrates a communication identifier to the specified event
channel and moves any pending events associated with the rdma_cm_id
@@ -22,6 +26,10 @@ to the new channel. Users should not poll for events on the
rdma_cm_id's current event channel or invoke other routines on the
rdma_cm_id while migrating between channels. This call will block while
there are any unacknowledged events on the current event channel.
+.P
+If the channel parameter is NULL, the specified rdma_cm_id will be
+placed into synchronous operation mode. All calls on the id
+will block until the operation completes.
.SH "SEE ALSO"
rdma_cm(7), rdma_create_event_channel(3), rdma_create_id(3),
rdma_get_cm_event(3)
diff --git a/contrib/ofed/librdmacm/man/rdma_notify.3 b/contrib/ofed/librdmacm/man/rdma_notify.3
index 7114ac4..c80733a 100644
--- a/contrib/ofed/librdmacm/man/rdma_notify.3
+++ b/contrib/ofed/librdmacm/man/rdma_notify.3
@@ -1,3 +1,4 @@
+.\" Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md
.TH "RDMA_NOTIFY" 3 "2007-05-15" "librdmacm" "Librdmacm Programmer's Manual" librdmacm
.SH NAME
rdma_notify \- Notifies the librdmacm of an asynchronous event.
@@ -15,6 +16,13 @@ Asynchronous event.
.SH "DESCRIPTION"
Used to notify the librdmacm of asynchronous events that have occurred
on a QP associated with the rdma_cm_id.
+.SH "RETURN VALUE"
+Returns 0 on success, or -1 on error. If an error occurs, errno will be
+set to indicate the failure reason. If errno is set to EISCONN
+(transport endpoint is already connected), this indicates that the
+the underlying communication manager established the connection before
+the call to rdma_notify could be processed. In this case, the error may
+safely be ignored.
.SH "NOTES"
Asynchronous events that occur on a QP are reported through the user's
device event handler. This routine is used to notify the librdmacm of
@@ -24,6 +32,8 @@ necessary, however if connection establishment is done out of band
QP that is not yet considered connected. This routine forces the
connection into an established state in this case in order to handle
the rare situation where the connection never forms on its own.
+Calling this routine ensures the delivery of the RDMA_CM_EVENT_ESTABLISHED
+event to the application.
Events that should be reported to the CM are: IB_EVENT_COMM_EST.
.SH "SEE ALSO"
rdma_connect(3), rdma_accept(3), rdma_listen(3)
diff --git a/contrib/ofed/librdmacm/man/rdma_post_read.3 b/contrib/ofed/librdmacm/man/rdma_post_read.3
new file mode 100644
index 0000000..11b3e09
--- /dev/null
+++ b/contrib/ofed/librdmacm/man/rdma_post_read.3
@@ -0,0 +1,56 @@
+.\" Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md
+.TH "RDMA_POST_READ" 3 "2010-07-19" "librdmacm" "Librdmacm Programmer's Manual" librdmacm
+.SH NAME
+rdma_post_read \- post an RDMA read work request.
+.SH SYNOPSIS
+.B "#include <rdma/rdma_verbs.h>"
+.P
+.B "int" rdma_post_read
+.BI "(struct rdma_cm_id *" id ","
+.BI "void *" context ","
+.BI "void *" addr ","
+.BI "size_t " length ","
+.BI "struct ibv_mr *" mr ","
+.BI "int " flags ","
+.BI "uint64_t " remote_addr ","
+.BI "uint32_t " rkey ");"
+.SH ARGUMENTS
+.IP "id" 12
+A reference to a communication identifier where the request
+will be posted.
+.IP "context" 12
+User-defined context associated with the request.
+.IP "addr" 12
+The address of the local destination of the read request.
+.IP "length" 12
+The length of the read operation.
+.IP "mr" 12
+Registered memory region associated with the local buffer.
+.IP "flags" 12
+Optional flags used to control the read operation.
+.IP "remote_addr" 12
+The address of the remote registered memory to read from.
+.IP "rkey" 12
+The registered memory key associated with the remote address.
+.SH "DESCRIPTION"
+Posts a work request to the send queue of the queue pair associated
+with the rdma_cm_id. The contents of the remote memory region will be
+read into the local data buffer.
+.SH "RETURN VALUE"
+Returns 0 on success, or -1 on error. If an error occurs, errno will be
+set to indicate the failure reason.
+.SH "NOTES"
+For a list of supported flags, see ibv_post_send.
+Both the remote and local data buffers must have been registered
+before the read is issued, and the buffers must remain registered
+until the read completes.
+.P
+Read operations may not be posted to an rdma_cm_id or the corresponding
+queue pair until it has been connected.
+.P
+The user-defined context associated with the read request will be
+returned to the user through the work completion wr_id, work request
+identifier, field.
+.SH "SEE ALSO"
+rdma_cm(7), rdma_connect(3), rdma_accept(3),
+ibv_post_send(3), rdma_post_readv(3), rdma_reg_read(3), rdma_reg_msgs(3)
diff --git a/contrib/ofed/librdmacm/man/rdma_post_readv.3 b/contrib/ofed/librdmacm/man/rdma_post_readv.3
new file mode 100644
index 0000000..95e4155
--- /dev/null
+++ b/contrib/ofed/librdmacm/man/rdma_post_readv.3
@@ -0,0 +1,53 @@
+.\" Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md
+.TH "RDMA_POST_READV" 3 "2010-07-19" "librdmacm" "Librdmacm Programmer's Manual" librdmacm
+.SH NAME
+rdma_post_readv \- post an RDMA read work request.
+.SH SYNOPSIS
+.B "#include <rdma/rdma_verbs.h>"
+.P
+.B "int" rdma_post_readv
+.BI "(struct rdma_cm_id *" id ","
+.BI "void *" context ","
+.BI "struct ibv_sge *" sgl ","
+.BI "int " nsge ","
+.BI "int " flags ","
+.BI "uint64_t " remote_addr ","
+.BI "uint32_t " rkey ");"
+.SH ARGUMENTS
+.IP "id" 12
+A reference to a communication identifier where the request
+will be posted.
+.IP "context" 12
+User-defined context associated with the request.
+.IP "sgl" 12
+A scatter-gather list of the destination buffers of the read.
+.IP "nsge" 12
+The number of scatter-gather array entries.
+.IP "flags" 12
+Optional flags used to control the read operation.
+.IP "remote_addr" 12
+The address of the remote registered memory to read from.
+.IP "rkey" 12
+The registered memory key associated with the remote address.
+.SH "DESCRIPTION"
+Posts a work request to the send queue of the queue pair associated
+with the rdma_cm_id. The contents of the remote memory region will be
+read into the local data buffers.
+.SH "RETURN VALUE"
+Returns 0 on success, or -1 on error. If an error occurs, errno will be
+set to indicate the failure reason.
+.SH "NOTES"
+For a list of supported flags, see ibv_post_send.
+Both the remote and local data buffers must have been registered
+before the read is issued, and the buffers must remain registered
+until the read completes.
+.P
+Read operations may not be posted to an rdma_cm_id or the corresponding
+queue pair until it has been connected.
+.P
+The user-defined context associated with the read request will be
+returned to the user through the work completion wr_id, work request
+identifier, field.
+.SH "SEE ALSO"
+rdma_cm(7), rdma_connect(3), rdma_accept(3),
+ibv_post_send(3), rdma_post_read(3), rdma_reg_read(3), rdma_reg_msgs(3)
diff --git a/contrib/ofed/librdmacm/man/rdma_post_recv.3 b/contrib/ofed/librdmacm/man/rdma_post_recv.3
new file mode 100644
index 0000000..5e0530d
--- /dev/null
+++ b/contrib/ofed/librdmacm/man/rdma_post_recv.3
@@ -0,0 +1,51 @@
+.\" Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md
+.TH "RDMA_POST_RECV" 3 "2010-07-19" "librdmacm" "Librdmacm Programmer's Manual" librdmacm
+.SH NAME
+rdma_post_recv \- post a work request to receive an incoming message.
+.SH SYNOPSIS
+.B "#include <rdma/rdma_verbs.h>"
+.P
+.B "int" rdma_post_recv
+.BI "(struct rdma_cm_id *" id ","
+.BI "void *" context ","
+.BI "void *" addr ","
+.BI "size_t " length ","
+.BI "struct ibv_mr *" mr ");"
+.SH ARGUMENTS
+.IP "id" 12
+A reference to a communication identifier where the message buffer
+will be posted.
+.IP "context" 12
+User-defined context associated with the request.
+.IP "addr" 12
+The address of the memory buffer to post.
+.IP "length" 12
+The length of the memory buffer.
+.IP "mr" 12
+A registered memory region associated with the posted buffer.
+.SH "DESCRIPTION"
+Posts a work request to the receive queue of the queue pair associated
+with the rdma_cm_id. The posted buffer will be queued to receive an incoming
+message sent by the remote peer.
+.SH "RETURN VALUE"
+Returns 0 on success, or -1 on error. If an error occurs, errno will be
+set to indicate the failure reason.
+.SH "NOTES"
+The user is responsible for ensuring that a receive buffer is posted
+and large enough to contain all sent data before the peer posts the
+corresponding send message. The message buffer must have been registered
+before being posted, with the mr parameter referencing the registration.
+The buffer must remain registered until the receive completes.
+.P
+Messages may be posted to an rdma_cm_id only after a queue pair has
+been associated with it. A queue pair is bound to an rdma_cm_id after
+calling rdma_create_ep or rdma_create_qp, if the rdma_cm_id is allocated
+using rdma_create_id.
+.P
+The user-defined context associated with the receive request will be
+returned to the user through the work completion wr_id, work request
+identifier, field.
+.SH "SEE ALSO"
+rdma_cm(7), rdma_create_id(3), rdma_create_ep(3), rdma_create_qp(3),
+rdma_reg_read(3), ibv_reg_mr(3), ibv_dereg_mr(3),
+rdma_post_recvv(3), rdma_post_send(3)
diff --git a/contrib/ofed/librdmacm/man/rdma_post_recvv.3 b/contrib/ofed/librdmacm/man/rdma_post_recvv.3
new file mode 100644
index 0000000..bd03930
--- /dev/null
+++ b/contrib/ofed/librdmacm/man/rdma_post_recvv.3
@@ -0,0 +1,48 @@
+.\" Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md
+.TH "RDMA_POST_RECVV" 3 "2010-07-19" "librdmacm" "Librdmacm Programmer's Manual" librdmacm
+.SH NAME
+rdma_post_recvv \- post a work request to receive incoming messages.
+.SH SYNOPSIS
+.B "#include <rdma/rdma_verbs.h>"
+.P
+.B "int" rdma_post_recvv
+.BI "(struct rdma_cm_id *" id ","
+.BI "void *" context ","
+.BI "struct ibv_sge *" sgl ","
+.BI "int " nsge ");"
+.SH ARGUMENTS
+.IP "id" 12
+A reference to a communication identifier where the message buffer(s)
+will be posted.
+.IP "context" 12
+User-defined context associated with the request.
+.IP "sgl" 12
+A scatter-gather list of memory buffers posted as a single request.
+.IP "nsge" 12
+The number of scatter-gather entries in the sgl array.
+.SH "DESCRIPTION"
+Posts a single work request to the receive queue of the queue pair associated
+with the rdma_cm_id. The posted buffers will be queued to receive an
+incoming message sent by the remote peer.
+.SH "RETURN VALUE"
+Returns 0 on success, or -1 on error. If an error occurs, errno will be
+set to indicate the failure reason.
+.SH "NOTES"
+The user is responsible for ensuring that the receive is posted,
+and the total buffer space is large enough to contain all sent data
+before the peer posts the corresponding send message. The message buffers
+must have been registered before being posted, and the buffers must
+remain registered until the receive completes.
+.P
+Messages may be posted to an rdma_cm_id only after a queue pair has
+been associated with it. A queue pair is bound to an rdma_cm_id after
+calling rdma_create_ep or rdma_create_qp, if the rdma_cm_id is allocated
+using rdma_create_id.
+.P
+The user-defined context associated with the receive request will be
+returned to the user through the work completion wr_id, work request
+identifier, field.
+.SH "SEE ALSO"
+rdma_cm(7), rdma_create_id(3), rdma_create_ep(3), rdma_create_qp(3),
+rdma_reg_read(3), ibv_reg_mr(3), ibv_dereg_mr(3),
+rdma_post_recv(3), rdma_post_send(3)
diff --git a/contrib/ofed/librdmacm/man/rdma_post_send.3 b/contrib/ofed/librdmacm/man/rdma_post_send.3
new file mode 100644
index 0000000..5d0e6d6
--- /dev/null
+++ b/contrib/ofed/librdmacm/man/rdma_post_send.3
@@ -0,0 +1,52 @@
+.\" Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md
+.TH "RDMA_POST_SEND" 3 "2010-07-19" "librdmacm" "Librdmacm Programmer's Manual" librdmacm
+.SH NAME
+rdma_post_send \- post a work request to send a message.
+.SH SYNOPSIS
+.B "#include <rdma/rdma_verbs.h>"
+.P
+.B "int" rdma_post_send
+.BI "(struct rdma_cm_id *" id ","
+.BI "void *" context ","
+.BI "void *" addr ","
+.BI "size_t " length ","
+.BI "struct ibv_mr *" mr ","
+.BI "int " flags ");"
+.SH ARGUMENTS
+.IP "id" 12
+A reference to a communication identifier where the message buffer
+will be posted.
+.IP "context" 12
+User-defined context associated with the request.
+.IP "addr" 12
+The address of the memory buffer to post.
+.IP "length" 12
+The length of the memory buffer.
+.IP "mr" 12
+Optional registered memory region associated with the posted buffer.
+.IP "flags" 12
+Optional flags used to control the send operation.
+.SH "DESCRIPTION"
+Posts a work request to the send queue of the queue pair associated
+with the rdma_cm_id. The contents of the posted buffer will be sent
+to the remote peer of a connection.
+.SH "RETURN VALUE"
+Returns 0 on success, or -1 on error. If an error occurs, errno will be
+set to indicate the failure reason.
+.SH "NOTES"
+The user is responsible for ensuring that the remote peer has queued a
+receive request before issuing the send operations. For a list of
+supported flags, see ibv_post_send. Unless the send request is using
+inline data, the message buffer must have been registered
+before being posted, with the mr parameter referencing the registration.
+The buffer must remain registered until the send completes.
+.P
+Send operations may not be posted to an rdma_cm_id or the corresponding
+queue pair until it has been connected.
+.P
+The user-defined context associated with the send request will be
+returned to the user through the work completion wr_id, work request
+identifier, field.
+.SH "SEE ALSO"
+rdma_cm(7), rdma_connect(3), rdma_accept(3),
+ibv_post_send(3), rdma_post_sendv(3), rdma_post_recv(3)
diff --git a/contrib/ofed/librdmacm/man/rdma_post_sendv.3 b/contrib/ofed/librdmacm/man/rdma_post_sendv.3
new file mode 100644
index 0000000..9b347b1
--- /dev/null
+++ b/contrib/ofed/librdmacm/man/rdma_post_sendv.3
@@ -0,0 +1,49 @@
+.\" Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md
+.TH "RDMA_POST_SENDV" 3 "2010-07-19" "librdmacm" "Librdmacm Programmer's Manual" librdmacm
+.SH NAME
+rdma_post_sendv \- post a work request to send a message.
+.SH SYNOPSIS
+.B "#include <rdma/rdma_verbs.h>"
+.P
+.B "int" rdma_post_sendv
+.BI "(struct rdma_cm_id *" id ","
+.BI "void *" context ","
+.BI "struct ibv_sge *" slg ","
+.BI "int " nsge ","
+.BI "int " flags ");"
+.SH ARGUMENTS
+.IP "id" 12
+A reference to a communication identifier where the message buffer
+will be posted.
+.IP "context" 12
+User-defined context associated with the request.
+.IP "slg" 12
+A scatter-gather list of memory buffers posted as a single request.
+.IP "nsge" 12
+The number of scatter-gather entries in the slg array.
+.IP "flags" 12
+Optional flags used to control the send operation.
+.SH "DESCRIPTION"
+Posts a work request to the send queue of the queue pair associated
+with the rdma_cm_id. The contents of the posted buffers will be sent
+to the remote peer of a connection.
+.SH "RETURN VALUE"
+Returns 0 on success, or -1 on error. If an error occurs, errno will be
+set to indicate the failure reason.
+.SH "NOTES"
+The user is responsible for ensuring that the remote peer has queued a
+receive request before issuing the send operations. For a list of
+supported flags, see ibv_post_send. Unless the send request is using
+inline data, the message buffers must have been registered
+before being posted, and the buffers must remain registered
+until the send completes.
+.P
+Send operations may not be posted to an rdma_cm_id or the corresponding
+queue pair until it has been connected.
+.P
+The user-defined context associated with the send request will be
+returned to the user through the work completion wr_id, work request
+identifier, field.
+.SH "SEE ALSO"
+rdma_cm(7), rdma_connect(3), rdma_accept(3),
+ibv_post_send(3), rdma_post_send(3), rdma_post_recv(3)
diff --git a/contrib/ofed/librdmacm/man/rdma_post_ud_send.3 b/contrib/ofed/librdmacm/man/rdma_post_ud_send.3
new file mode 100644
index 0000000..0fcce79
--- /dev/null
+++ b/contrib/ofed/librdmacm/man/rdma_post_ud_send.3
@@ -0,0 +1,55 @@
+.\" Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md
+.TH "RDMA_POST_UD_SEND" 3 "2010-07-19" "librdmacm" "Librdmacm Programmer's Manual" librdmacm
+.SH NAME
+rdma_post_ud_send \- post a work request to send a datagram.
+.SH SYNOPSIS
+.B "#include <rdma/rdma_verbs.h>"
+.P
+.B "int" rdma_post_ud_send
+.BI "(struct rdma_cm_id *" id ","
+.BI "void *" context ","
+.BI "void *" addr ","
+.BI "size_t " length ","
+.BI "struct ibv_mr *" mr ","
+.BI "int " flags ","
+.BI "struct ibv_ah *" ah ","
+.BI "uint32_t " remote_qpn ");"
+.SH ARGUMENTS
+.IP "id" 12
+A reference to a communication identifier where the message buffer
+will be posted.
+.IP "context" 12
+User-defined context associated with the request.
+.IP "addr" 12
+The address of the memory buffer to post.
+.IP "length" 12
+The length of the memory buffer.
+.IP "mr" 12
+Optional registered memory region associated with the posted buffer.
+.IP "flags" 12
+Optional flags used to control the send operation.
+.IP "ah" 12
+An address handle describing the address of the remote node.
+.IP "remote_qpn" 12
+The number of the destination queue pair.
+.SH "DESCRIPTION"
+Posts a work request to the send queue of the queue pair associated
+with the rdma_cm_id. The contents of the posted buffer will be sent
+to the specified destination queue pair.
+.SH "RETURN VALUE"
+Returns 0 on success, or -1 on error. If an error occurs, errno will be
+set to indicate the failure reason.
+.SH "NOTES"
+The user is responsible for ensuring that the destination queue pair
+has queued a receive request before issuing the send operations. For a list of
+supported flags, see ibv_post_send. Unless the send request is using
+inline data, the message buffer must have been registered
+before being posted, with the mr parameter referencing the registration.
+The buffer must remain registered until the send completes.
+.P
+The user-defined context associated with the send request will be
+returned to the user through the work completion wr_id, work request
+identifier, field.
+.SH "SEE ALSO"
+rdma_cm(7), rdma_connect(3), rdma_accept(3), rdma_reg_msgs(3)
+ibv_post_send(3), rdma_post_recv(3)
diff --git a/contrib/ofed/librdmacm/man/rdma_post_write.3 b/contrib/ofed/librdmacm/man/rdma_post_write.3
new file mode 100644
index 0000000..62a1e49
--- /dev/null
+++ b/contrib/ofed/librdmacm/man/rdma_post_write.3
@@ -0,0 +1,56 @@
+.\" Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md
+.TH "RDMA_POST_WRITE" 3 "2010-07-19" "librdmacm" "Librdmacm Programmer's Manual" librdmacm
+.SH NAME
+rdma_post_write \- post an RDMA write work request.
+.SH SYNOPSIS
+.B "#include <rdma/rdma_verbs.h>"
+.P
+.B "int" rdma_post_write
+.BI "(struct rdma_cm_id *" id ","
+.BI "void *" context ","
+.BI "void *" addr ","
+.BI "size_t " length ","
+.BI "struct ibv_mr *" mr ","
+.BI "int " flags ","
+.BI "uint64_t " remote_addr ","
+.BI "uint32_t " rkey ");"
+.SH ARGUMENTS
+.IP "id" 12
+A reference to a communication identifier where the request
+will be posted.
+.IP "context" 12
+User-defined context associated with the request.
+.IP "addr" 12
+The local address of the source of the write request.
+.IP "length" 12
+The length of the write operation.
+.IP "mr" 12
+Optional memory region associated with the local buffer.
+.IP "flags" 12
+Optional flags used to control the write operation.
+.IP "remote_addr" 12
+The address of the remote registered memory to write into.
+.IP "rkey" 12
+The registered memory key associated with the remote address.
+.SH "DESCRIPTION"
+Posts a work request to the send queue of the queue pair associated
+with the rdma_cm_id. The contents of the local data buffer will be
+written into the remote memory region.
+.SH "RETURN VALUE"
+Returns 0 on success, or -1 on error. If an error occurs, errno will be
+set to indicate the failure reason.
+.SH "NOTES"
+For a list of supported flags, see ibv_post_send. Unless inline
+data is specified, the local data buffer must have been registered
+before the write is issued, and the buffer must remain registered
+until the write completes. The remote buffer must always be registered.
+.P
+Write operations may not be posted to an rdma_cm_id or the corresponding
+queue pair until it has been connected.
+.P
+The user-defined context associated with the write request will be
+returned to the user through the work completion wr_id, work request
+identifier, field.
+.SH "SEE ALSO"
+rdma_cm(7), rdma_connect(3), rdma_accept(3),
+ibv_post_send(3), rdma_post_writev(3), rdma_reg_write(3), rdma_reg_msgs(3)
diff --git a/contrib/ofed/librdmacm/man/rdma_post_writev.3 b/contrib/ofed/librdmacm/man/rdma_post_writev.3
new file mode 100644
index 0000000..22ee0fe
--- /dev/null
+++ b/contrib/ofed/librdmacm/man/rdma_post_writev.3
@@ -0,0 +1,53 @@
+.\" Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md
+.TH "RDMA_POST_WRITEV" 3 "2010-07-19" "librdmacm" "Librdmacm Programmer's Manual" librdmacm
+.SH NAME
+rdma_post_writev \- post an RDMA write work request.
+.SH SYNOPSIS
+.B "#include <rdma/rdma_verbs.h>"
+.P
+.B "int" rdma_post_writev
+.BI "(struct rdma_cm_id *" id ","
+.BI "void *" context ","
+.BI "struct ibv_sge *" sgl ","
+.BI "int " nsge ","
+.BI "int " flags ","
+.BI "uint64_t " remote_addr ","
+.BI "uint32_t " rkey ");"
+.SH ARGUMENTS
+.IP "id" 12
+A reference to a communication identifier where the request
+will be posted.
+.IP "context" 12
+User-defined context associated with the request.
+.IP "sgl" 12
+A scatter-gather list of the source buffers of the write.
+.IP "nsge" 12
+The number of scatter-gather array entries.
+.IP "flags" 12
+Optional flags used to control the write operation.
+.IP "remote_addr" 12
+The address of the remote registered memory to write into.
+.IP "rkey" 12
+The registered memory key associated with the remote address.
+.SH "DESCRIPTION"
+Posts a work request to the send queue of the queue pair associated
+with the rdma_cm_id. The contents of the local data buffers will be
+written into the remote memory region.
+.SH "RETURN VALUE"
+Returns 0 on success, or -1 on error. If an error occurs, errno will be
+set to indicate the failure reason.
+.SH "NOTES"
+For a list of supported flags, see ibv_post_send. Unless inline
+data is specified, the local data buffers must have been registered
+before the write is issued, and the buffers must remain registered
+until the write completes. The remote buffers must always be registered.
+.P
+Write operations may not be posted to an rdma_cm_id or the corresponding
+queue pair until it has been connected.
+.P
+The user-defined context associated with the write request will be
+returned to the user through the work completion wr_id, work request
+identifier, field.
+.SH "SEE ALSO"
+rdma_cm(7), rdma_connect(3), rdma_accept(3),
+ibv_post_send(3), rdma_post_write(3), rdma_reg_write(3), rdma_reg_msgs(3)
diff --git a/contrib/ofed/librdmacm/man/rdma_reg_msgs.3 b/contrib/ofed/librdmacm/man/rdma_reg_msgs.3
new file mode 100644
index 0000000..48c75b3
--- /dev/null
+++ b/contrib/ofed/librdmacm/man/rdma_reg_msgs.3
@@ -0,0 +1,43 @@
+.\" Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md
+.TH "RDMA_REG_MSGS" 3 "2010-07-19" "librdmacm" "Librdmacm Programmer's Manual" librdmacm
+.SH NAME
+rdma_reg_msgs \- register data buffer(s) for sending or receiving messages.
+.SH SYNOPSIS
+.B "#include <rdma/rdma_verbs.h>"
+.P
+.B "struct ibv_mr *" rdma_reg_msgs
+.BI "(struct rdma_cm_id *" id ","
+.BI "void *" addr ","
+.BI "size_t " length ");"
+.SH ARGUMENTS
+.IP "id" 12
+A reference to a communication identifier where the message buffer(s)
+will be used.
+.IP "addr" 12
+The address of the memory buffer(s) to register.
+.IP "length" 12
+The total length of the memory to register.
+.SH "DESCRIPTION"
+Registers an array of memory buffers used for sending and receiving
+messages or for RDMA operations. Memory buffers registered using
+rdma_reg_msgs may be posted to an rdma_cm_id using
+rdma_post_send or rdma_post_recv, or specified as the target of an RDMA
+read operation or the source of an RDMA write request.
+.SH "RETURN VALUE"
+Returns a reference to the registered memory region on success, or NULL on
+error. If an error occurs, errno will be set to indicate the failure reason.
+.SH "NOTES"
+rdma_reg_msgs is used to register an array of data buffers
+that will be used send and/or receive messages on a queue pair associated with
+an rdma_cm_id. The memory buffer is registered with the proteection
+domain associated with the idenfier. The start of the data buffer array
+is specified through the addr parameter, and the total size of the array
+is given by length.
+.P
+All data buffers should be registered before being posted as a work request.
+Users must deregister all registered memory by calling rdma_dereg_mr.
+.SH "SEE ALSO"
+rdma_cm(7), rdma_create_id(3), rdma_create_ep(3),
+rdma_reg_read(3), rdma_reg_write(3),
+ibv_reg_mr(3), ibv_dereg_mr(3), rdma_post_send(3), rdma_post_recv(3),
+rdma_post_read(3), rdma_post_readv(3), rdma_post_write(3), rdma_post_writev(3)
diff --git a/contrib/ofed/librdmacm/man/rdma_reg_read.3 b/contrib/ofed/librdmacm/man/rdma_reg_read.3
new file mode 100644
index 0000000..07813e8
--- /dev/null
+++ b/contrib/ofed/librdmacm/man/rdma_reg_read.3
@@ -0,0 +1,42 @@
+.\" Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md
+.TH "RDMA_REG_READ" 3 "2010-07-19" "librdmacm" "Librdmacm Programmer's Manual" librdmacm
+.SH NAME
+rdma_reg_read \- register data buffer(s) for remote RDMA read access.
+.SH SYNOPSIS
+.B "#include <rdma/rdma_verbs.h>"
+.P
+.B "struct ibv_mr *" rdma_reg_read
+.BI "(struct rdma_cm_id *" id ","
+.BI "void *" addr ","
+.BI "size_t " length ");"
+.SH ARGUMENTS
+.IP "id" 12
+A reference to a communication identifier where the message buffer(s)
+will be used.
+.IP "addr" 12
+The address of the memory buffer(s) to register.
+.IP "length" 12
+The total length of the memory to register.
+.SH "DESCRIPTION"
+Registers a memory buffer that will be accessed by a remote RDMA read
+operation. Memory buffers registered using rdma_reg_read may be
+targeted in an RDMA read request, allowing the buffer to be
+specified on the remote side of an RDMA connection as the remote_addr
+of rdma_post_read, or similar call.
+.SH "RETURN VALUE"
+Returns a reference to the registered memory region on success, or NULL on
+error. If an error occurs, errno will be set to indicate the failure reason.
+.SH "NOTES"
+rdma_reg_read is used to register a data buffer that will be the
+target of an RDMA read operation on a queue pair associated with
+an rdma_cm_id. The memory buffer is registered with the proteection
+domain associated with the idenfier. The start of the data buffer
+is specified through the addr parameter, and the total size of the buffer
+is given by length.
+.P
+All data buffers should be registered before being posted as a work request.
+Users must deregister all registered memory by calling rdma_dereg_mr.
+.SH "SEE ALSO"
+rdma_cm(7), rdma_create_id(3), rdma_create_ep(3),
+rdma_reg_msgs(3), rdma_reg_write(3),
+ibv_reg_mr(3), ibv_dereg_mr(3), rdma_post_read(3)
diff --git a/contrib/ofed/librdmacm/man/rdma_reg_write.3 b/contrib/ofed/librdmacm/man/rdma_reg_write.3
new file mode 100644
index 0000000..2be3cc0
--- /dev/null
+++ b/contrib/ofed/librdmacm/man/rdma_reg_write.3
@@ -0,0 +1,42 @@
+.\" Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md
+.TH "RDMA_REG_WRITE" 3 "2010-07-19" "librdmacm" "Librdmacm Programmer's Manual" librdmacm
+.SH NAME
+rdma_reg_write \- register data buffer(s) for remote RDMA write access.
+.SH SYNOPSIS
+.B "#include <rdma/rdma_verbs.h>"
+.P
+.B "struct ibv_mr *" rdma_reg_write
+.BI "(struct rdma_cm_id *" id ","
+.BI "void *" addr ","
+.BI "size_t " length ");"
+.SH ARGUMENTS
+.IP "id" 12
+A reference to a communication identifier where the message buffer(s)
+will be used.
+.IP "addr" 12
+The address of the memory buffer(s) to register.
+.IP "length" 12
+The total length of the memory to register.
+.SH "DESCRIPTION"
+Registers a memory buffer that will be accessed by a remote RDMA write
+operation. Memory buffers registered using rdma_reg_write may be
+targeted in an RDMA write request, allowing the buffer to be
+specified on the remote side of an RDMA connection as the remote_addr
+of rdma_post_write, or similar call.
+.SH "RETURN VALUE"
+Returns a reference to the registered memory region on success, or NULL on
+error. If an error occurs, errno will be set to indicate the failure reason.
+.SH "NOTES"
+rdma_reg_write is used to register a data buffer that will be the
+target of an RDMA write operation on a queue pair associated with
+an rdma_cm_id. The memory buffer is registered with the proteection
+domain associated with the idenfier. The start of the data buffer
+is specified through the addr parameter, and the total size of the buffer
+is given by length.
+.P
+All data buffers should be registered before being posted as a work request.
+Users must deregister all registered memory by calling rdma_dereg_mr.
+.SH "SEE ALSO"
+rdma_cm(7), rdma_create_id(3), rdma_create_ep(3),
+rdma_reg_msgs(3), rdma_reg_read(3),
+ibv_reg_mr(3), ibv_dereg_mr(3), rdma_post_write(3)
diff --git a/contrib/ofed/librdmacm/man/rdma_reject.3 b/contrib/ofed/librdmacm/man/rdma_reject.3
index dc32160..53f038f 100644
--- a/contrib/ofed/librdmacm/man/rdma_reject.3
+++ b/contrib/ofed/librdmacm/man/rdma_reject.3
@@ -1,3 +1,4 @@
+.\" Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md
.TH "RDMA_REJECT" 3 "2007-05-15" "librdmacm" "Librdmacm Programmer's Manual" librdmacm
.SH NAME
rdma_reject \- Called to reject a connection request.
@@ -20,6 +21,9 @@ be larger than that requested.
.SH "DESCRIPTION"
Called from the listening side to reject a connection or datagram
service lookup request.
+.SH "RETURN VALUE"
+Returns 0 on success, or -1 on error. If an error occurs, errno will be
+set to indicate the failure reason.
.SH "NOTES"
After receiving a connection request event, a user may call rdma_reject
to reject the request. If the underlying RDMA transport supports
diff --git a/contrib/ofed/librdmacm/man/rdma_resolve_addr.3 b/contrib/ofed/librdmacm/man/rdma_resolve_addr.3
index e612606..ce6dcd6 100644
--- a/contrib/ofed/librdmacm/man/rdma_resolve_addr.3
+++ b/contrib/ofed/librdmacm/man/rdma_resolve_addr.3
@@ -1,3 +1,4 @@
+.\" Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md
.TH "RDMA_RESOLVE_ADDR" 3 "2007-10-31" "librdmacm" "Librdmacm Programmer's Manual" librdmacm
.SH NAME
rdma_resolve_addr \- Resolve destination and optional source addresses.
@@ -22,6 +23,9 @@ Time to wait for resolution to complete.
Resolve destination and optional source addresses from IP addresses
to an RDMA address. If successful, the specified rdma_cm_id will
be bound to a local device.
+.SH "RETURN VALUE"
+Returns 0 on success, or -1 on error. If an error occurs, errno will be
+set to indicate the failure reason.
.SH "NOTES"
This call is used to map a given destination IP address to a usable RDMA
address. The IP to RDMA address mapping is done using the local routing
diff --git a/contrib/ofed/librdmacm/man/rdma_resolve_route.3 b/contrib/ofed/librdmacm/man/rdma_resolve_route.3
index ac1b3bc..114f666 100644
--- a/contrib/ofed/librdmacm/man/rdma_resolve_route.3
+++ b/contrib/ofed/librdmacm/man/rdma_resolve_route.3
@@ -1,3 +1,4 @@
+.\" Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md
.TH "RDMA_RESOLVE_ROUTE" 3 "2007-10-31" "librdmacm" "Librdmacm Programmer's Manual" librdmacm
.SH NAME
rdma_resolve_route \- Resolve the route information needed to establish a connection.
@@ -16,6 +17,9 @@ Time to wait for resolution to complete.
Resolves an RDMA route to the destination address in order to establish
a connection. The destination address must have already been resolved
by calling rdma_resolve_addr.
+.SH "RETURN VALUE"
+Returns 0 on success, or -1 on error. If an error occurs, errno will be
+set to indicate the failure reason.
.SH "NOTES"
This is called on the client side of a connection after calling
rdma_resolve_addr, but before calling rdma_connect.
diff --git a/contrib/ofed/librdmacm/man/rdma_server.1 b/contrib/ofed/librdmacm/man/rdma_server.1
new file mode 100644
index 0000000..ada2564
--- /dev/null
+++ b/contrib/ofed/librdmacm/man/rdma_server.1
@@ -0,0 +1,27 @@
+.\" Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md
+.TH "RDMA_SERVER" 1 "2010-07-19" "librdmacm" "librdmacm" librdmacm
+.SH NAME
+rdma_server \- simple RDMA CM connection and ping-pong test.
+.SH SYNOPSIS
+.sp
+.nf
+\fIrdma_server\fR [-p port]
+.fi
+.SH "DESCRIPTION"
+Uses synchronous librdmam calls to establish an RDMA connections between
+two nodes. This example is intended to provide a very simple coding
+example of how to use RDMA.
+.SH "OPTIONS"
+.TP
+\-p port
+Changes the port number that the server listens on. By default the server
+listens on port 7471.
+.SH "NOTES"
+Basic usage is to start rdma_server, then connect to the server using the
+rdma_client program.
+.P
+Because this test maps RDMA resources to userspace, users must ensure
+that they have available system resources and permissions. See the
+libibverbs README file for additional details.
+.SH "SEE ALSO"
+rdma_cm(7), udaddy(1), mckey(1), rping(1), rdma_client(1)
diff --git a/contrib/ofed/librdmacm/man/rdma_set_option.3 b/contrib/ofed/librdmacm/man/rdma_set_option.3
index ffa516c..93a6047 100644
--- a/contrib/ofed/librdmacm/man/rdma_set_option.3
+++ b/contrib/ofed/librdmacm/man/rdma_set_option.3
@@ -1,3 +1,4 @@
+.\" Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md
.TH "RDMA_SET_OPTION" 3 "2007-08-06" "librdmacm" "Librdmacm Programmer's Manual" librdmacm
.SH NAME
rdma_set_option \- Set communication options for an rdma_cm_id.
@@ -24,7 +25,10 @@ The size of the %optval buffer.
.SH "DESCRIPTION"
Sets communication options for an rdma_cm_id. This call is used to override
the default system settings.
+.SH "RETURN VALUE"
+Returns 0 on success, or -1 on error. If an error occurs, errno will be
+set to indicate the failure reason.
.SH "NOTES"
-Option details may be found in the relevent header files.
+Option details may be found in the relevant header files.
.SH "SEE ALSO"
rdma_create_id(3)
diff --git a/contrib/ofed/librdmacm/man/rdma_xclient.1 b/contrib/ofed/librdmacm/man/rdma_xclient.1
new file mode 100644
index 0000000..d874c6e
--- /dev/null
+++ b/contrib/ofed/librdmacm/man/rdma_xclient.1
@@ -0,0 +1,37 @@
+.\" Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md
+.TH "RDMA_XCLIENT" 1 "2011-06-15" "librdmacm" "librdmacm" librdmacm
+.SH NAME
+rdma_xclient \- RDMA CM communication client test program
+.SH SYNOPSIS
+.sp
+.nf
+\fIrdma_xclient\fR [-s server_address] [-p server_port] [-c comm_type]
+.fi
+.SH "DESCRIPTION"
+Uses synchronous librdmam calls to establish an RDMA connection between
+two nodes. This example is intended to provide a very simple coding
+example of how to use RDMA.
+.SH "OPTIONS"
+.TP
+\-s server_address
+Specifies the address of the system that the rdma_server is running on.
+By default, the client will attempt to connect to the server using
+127.0.0.1.
+.TP
+\-p server_port
+Specifies the port number that the server listens on. By default the server
+listens on port 7471.
+.TP
+\-c communication type
+Specifies the type of communication established with the server program. 'r'
+results in using a reliable-connected QP (the default). 'x' uses
+extended reliable-connected XRC QPs.
+.SH "NOTES"
+Basic usage is to start rdma_xserver, then connect to the server using the
+rdma_client program.
+.P
+Because this test maps RDMA resources to userspace, users must ensure
+that they have available system resources and permissions. See the
+libibverbs README file for additional details.
+.SH "SEE ALSO"
+rdma_cm(7), udaddy(1), mckey(1), rping(1), rdma_xserver(1), rdma_client(1)
diff --git a/contrib/ofed/librdmacm/man/rdma_xserver.1 b/contrib/ofed/librdmacm/man/rdma_xserver.1
new file mode 100644
index 0000000..4c12e25
--- /dev/null
+++ b/contrib/ofed/librdmacm/man/rdma_xserver.1
@@ -0,0 +1,31 @@
+.\" Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md
+.TH "RDMA_XSERVER" 1 "2011-06-15" "librdmacm" "librdmacm" librdmacm
+.SH NAME
+rdma_xserver \- RDMA CM communication server test program
+.SH SYNOPSIS
+.sp
+.nf
+\fIrdma_xserver\fR [-p port] [-c comm_type]
+.fi
+.SH "DESCRIPTION"
+Uses the librdmacm to establish various forms of communication and exchange
+data.
+.SH "OPTIONS"
+.TP
+\-p port
+Changes the port number that the server listens on. By default the server
+listens on port 7471.
+.TP
+\-c communication type
+Specifies the type of communication established with the client program. 'r'
+results in using a reliable-connected QP (the default). 'x' uses
+extended reliable-connected XRC QPs.
+.SH "NOTES"
+Basic usage is to start rdma_xserver, then connect to the server using the
+rdma_xclient program.
+.P
+Because this test maps RDMA resources to userspace, users must ensure
+that they have available system resources and permissions. See the
+libibverbs README file for additional details.
+.SH "SEE ALSO"
+rdma_cm(7), udaddy(1), mckey(1), rping(1), rdma_server(1), rdma_xclient(1)
diff --git a/contrib/ofed/librdmacm/man/riostream.1 b/contrib/ofed/librdmacm/man/riostream.1
new file mode 100644
index 0000000..537302b
--- /dev/null
+++ b/contrib/ofed/librdmacm/man/riostream.1
@@ -0,0 +1,65 @@
+.\" Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md
+.TH "RIOSTREAM" 1 "2012-10-24" "librdmacm" "librdmacm" librdmacm
+.SH NAME
+riostream \- zero-copy streaming over RDMA ping-pong test.
+.SH SYNOPSIS
+.sp
+.nf
+\fIriostream\fR [-s server_address] [-b bind_address] [-B buffer_size]
+ [-I iterations] [-C transfer_count]
+ [-S transfer_size] [-p server_port] [-T test_option]
+.fi
+.SH "DESCRIPTION"
+Uses the streaming over RDMA protocol (rsocket) to connect and exchange
+data between a client and server application.
+.SH "OPTIONS"
+.TP
+\-s server_address
+The network name or IP address of the server system listening for
+connections. The used name or address must route over an RDMA device.
+This option must be specified by the client.
+.TP
+\-b bind_address
+The local network address to bind to.
+.TP
+\-B buffer_size
+Indicates the size of the send and receive network buffers.
+.TP
+\-I iterations
+The number of times that the specified number of messages will be
+exchanged between the client and server. (default 1000)
+.TP
+\-C transfer_count
+The number of messages to transfer from the client to the server and
+back again on each iteration. (default 1)
+.TP
+\-S transfer_size
+The size of each send transfer, in bytes. (default 1000) If 'all'
+is specified, rstream will run a series of tests of various sizes.
+.TP
+\-p server_port
+The server's port number.
+.TP
+\-T test_option
+Specifies test parameters. Available options are:
+.P
+a | async - uses asynchronous operation (e.g. select / poll)
+.P
+b | blocking - uses blocking calls
+.P
+n | nonblocking - uses non-blocking calls
+.P
+v | verify - verifies data transfers
+.SH "NOTES"
+Basic usage is to start riostream on a server system, then run
+riostream -s server_name on a client system. By default, riostream
+will run a series of latency and bandwidth performance tests.
+Specifying a different iterations, transfer_count, or transfer_size
+will run a user customized test using default values where none
+have been specified.
+.P
+Because this test maps RDMA resources to userspace, users must ensure
+that they have available system resources and permissions. See the
+libibverbs README file for additional details.
+.SH "SEE ALSO"
+rdma_cm(7) rstream(1)
diff --git a/contrib/ofed/librdmacm/man/rping.1 b/contrib/ofed/librdmacm/man/rping.1
index a2b7b6b..8d4f157 100644
--- a/contrib/ofed/librdmacm/man/rping.1
+++ b/contrib/ofed/librdmacm/man/rping.1
@@ -1,3 +1,4 @@
+.\" Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md
.TH "RPING" 1 "2007-05-15" "librdmacm" "librdmacm" librdmacm
.SH NAME
rping \- RDMA CM connection and RDMA ping-pong test.
@@ -6,7 +7,7 @@ rping \- RDMA CM connection and RDMA ping-pong test.
.nf
\fIrping\fR -s [-v] [-V] [-d] [-P] [-a address] [-p port]
[-C message_count] [-S message_size]
-\fIrping\fR -c [-v] [-V] [-d] -a address [-p port]
+\fIrping\fR -c [-v] [-V] [-d] [-I address] -a address [-p port]
[-C message_count] [-S message_size]
.fi
.SH "DESCRIPTION"
@@ -23,8 +24,13 @@ Run as the client.
.TP
\-a address
On the server, specifies the network address to bind the connection to.
+To bind to any address with IPv6 use -a ::0 .
On the client, specifies the server address to connect to.
.TP
+\-I address
+The address to bind to as the source IP address to use. This is useful
+if you have multiple addresses on the same network or complex routing.
+.TP
\-p
Port number for listening server.
.TP
diff --git a/contrib/ofed/librdmacm/man/rsocket.7.in b/contrib/ofed/librdmacm/man/rsocket.7.in
new file mode 100644
index 0000000..5b77769
--- /dev/null
+++ b/contrib/ofed/librdmacm/man/rsocket.7.in
@@ -0,0 +1,159 @@
+.\" Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md
+.TH "RSOCKET" 7 "2013-01-21" "librdmacm" "Librdmacm Programmer's Manual" librdmacm
+.SH NAME
+rsocket \- RDMA socket API
+.SH SYNOPSIS
+.B "#include <rdma/rsocket.h>"
+.SH "DESCRIPTION"
+RDMA socket API and protocol
+.SH "NOTES"
+Rsockets is a protocol over RDMA that supports a socket-level API
+for applications. Rsocket APIs are intended to match the behavior
+of corresponding socket calls, except where noted. Rsocket
+functions match the name and function signature of socket calls,
+with the exception that all function calls are prefixed with an 'r'.
+.P
+The following functions are defined:
+.P
+rsocket
+.P
+rbind, rlisten, raccept, rconnect
+.P
+rshutdown, rclose
+.P
+rrecv, rrecvfrom, rrecvmsg, rread, rreadv
+.P
+rsend, rsendto, rsendmsg, rwrite, rwritev
+.P
+rpoll, rselect
+.P
+rgetpeername, rgetsockname
+.P
+rsetsockopt, rgetsockopt, rfcntl
+.P
+Functions take the same parameters as that used for sockets. The
+follow capabilities and flags are supported at this time:
+.P
+PF_INET, PF_INET6, SOCK_STREAM, SOCK_DGRAM
+.P
+SOL_SOCKET - SO_ERROR, SO_KEEPALIVE (flag supported, but ignored),
+SO_LINGER, SO_OOBINLINE, SO_RCVBUF, SO_REUSEADDR, SO_SNDBUF
+.P
+IPPROTO_TCP - TCP_NODELAY, TCP_MAXSEG
+.P
+IPPROTO_IPV6 - IPV6_V6ONLY
+.P
+MSG_DONTWAIT, MSG_PEEK, O_NONBLOCK
+.P
+Rsockets provides extensions beyond normal socket routines that
+allow for direct placement of data into an application's buffer.
+This is also known as zero-copy support, since data is sent and
+received directly, bypassing copies into network controlled buffers.
+The following calls and options support direct data placement.
+.P
+riomap, riounmap, riowrite
+.TP
+off_t riomap(int socket, void *buf, size_t len, int prot, int flags, off_t offset)
+.TP
+Riomap registers an application buffer with the RDMA hardware
+associated with an rsocket. The buffer is registered either for
+local only access (PROT_NONE) or for remote write access (PROT_WRITE).
+When registered for remote access, the buffer is mapped to a given
+offset. The offset is either provided by the user, or if the user
+selects -1 for the offset, rsockets selects one. The remote peer may
+access an iomapped buffer directly by specifying the correct offset.
+The mapping is not guaranteed to be available until after the remote
+peer receives a data transfer initiated after riomap has completed.
+.PP
+In order to enable the use of remote IO mapping calls on an rsocket,
+an application must set the number of IO mappings that are available
+to the remote peer. This may be done using the rsetsockopt
+RDMA_IOMAPSIZE option. By default, an rsocket does not support
+remote IO mappings.
+riounmap
+.TP
+int riounmap(int socket, void *buf, size_t len)
+.TP
+Riounmap removes the mapping between a buffer and an rsocket.
+.P
+riowrite
+.TP
+size_t riowrite(int socket, const void *buf, size_t count, off_t offset, int flags)
+.TP
+Riowrite allows an application to transfer data over an rsocket
+directly into a remotely iomapped buffer. The remote buffer is specified
+through an offset parameter, which corresponds to a remote iomapped buffer.
+From the sender's perspective, riowrite behaves similar to rwrite. From
+a receiver's view, riowrite transfers are silently redirected into a pre-
+determined data buffer. Data is received automatically, and the receiver
+is not informed of the transfer. However, iowrite data is still considered
+part of the data stream, such that iowrite data will be written before a
+subsequent transfer is received. A message sent immediately after initiating
+an iowrite may be used to notify the receiver of the iowrite.
+.P
+In addition to standard socket options, rsockets supports options
+specific to RDMA devices and protocols. These options are accessible
+through rsetsockopt using SOL_RDMA option level.
+.TP
+RDMA_SQSIZE - Integer size of the underlying send queue.
+.TP
+RDMA_RQSIZE - Integer size of the underlying receive queue.
+.TP
+RDMA_INLINE - Integer size of inline data.
+.TP
+RDMA_IOMAPSIZE - Integer number of remote IO mappings supported
+.TP
+RDMA_ROUTE - struct ibv_path_data of path record for connection.
+.P
+Note that rsockets fd's cannot be passed into non-rsocket calls. For
+applications which must mix rsocket fd's with standard socket fd's or
+opened files, rpoll and rselect support polling both rsockets and
+normal fd's.
+.P
+Existing applications can make use of rsockets through the use of a
+preload library. Because rsockets implements an end-to-end protocol,
+both sides of a connection must use rsockets. The rdma_cm library
+provides such a preload library, librspreload. To reduce the chance
+of the preload library intercepting calls without the user's explicit
+knowledge, the librspreload library is installed into %libdir%/rsocket
+subdirectory.
+.P
+The preload library can be used by setting LD_PRELOAD when running.
+Note that not all applications will work with rsockets. Support is
+limited based on the socket options used by the application.
+Support for fork() is limited, but available. To use rsockets with
+the preload library for applications that call fork, users must
+set the environment variable RDMAV_FORK_SAFE=1 on both the client
+and server side of the connection. In general, fork is
+supportable for server applications that accept a connection, then
+fork off a process to handle the new connection.
+.P
+rsockets uses configuration files that give an administrator control
+over the default settings used by rsockets. Use files under
+@CMAKE_INSTALL_FULL_SYSCONFDIR@/rdma/rsocket as shown:
+.P
+.P
+mem_default - default size of receive buffer(s)
+.P
+wmem_default - default size of send buffer(s)
+.P
+sqsize_default - default size of send queue
+.P
+rqsize_default - default size of receive queue
+.P
+inline_default - default size of inline data
+.P
+iomap_size - default size of remote iomapping table
+.P
+polling_time - default number of microseconds to poll for data before waiting
+.P
+All configuration files should contain a single integer value. Values may
+be set by issuing a command similar to the following example.
+.P
+echo 1000000 > @CMAKE_INSTALL_FULL_SYSCONFDIR@/rdma/rsocket/mem_default
+.P
+If configuration files are not available, rsockets uses internal defaults.
+Applications can override default values programmatically through the
+rsetsockopt routine.
+.SH "SEE ALSO"
+rdma_cm(7)
diff --git a/contrib/ofed/librdmacm/man/rstream.1 b/contrib/ofed/librdmacm/man/rstream.1
new file mode 100644
index 0000000..3fc3b17
--- /dev/null
+++ b/contrib/ofed/librdmacm/man/rstream.1
@@ -0,0 +1,74 @@
+.\" Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md
+.TH "RSTREAM" 1 "2011-11-16" "librdmacm" "librdmacm" librdmacm
+.SH NAME
+rstream \- streaming over RDMA ping-pong test.
+.SH SYNOPSIS
+.sp
+.nf
+\fIrstream\fR [-s server_address] [-b bind_address] [-f address_format]
+ [-B buffer_size] [-I iterations] [-C transfer_count]
+ [-S transfer_size] [-p server_port] [-T test_option]
+.fi
+.SH "DESCRIPTION"
+Uses the streaming over RDMA protocol (rsocket) to connect and exchange
+data between a client and server application.
+.SH "OPTIONS"
+.TP
+\-s server_address
+The network name or IP address of the server system listening for
+connections. The used name or address must route over an RDMA device.
+This option must be specified by the client.
+.TP
+\-b bind_address
+The local network address to bind to.
+.TP
+\-f address_format
+Supported address formats are ip, ipv6, gid, or name.
+.TP
+\-B buffer_size
+Indicates the size of the send and receive network buffers.
+.TP
+\-I iterations
+The number of times that the specified number of messages will be
+exchanged between the client and server. (default 1000)
+.TP
+\-C transfer_count
+The number of messages to transfer from the client to the server and
+back again on each iteration. (default 1000)
+.TP
+\-S transfer_size
+The size of each send transfer, in bytes. (default 1000) If 'all'
+is specified, rstream will run a series of tests of various sizes.
+.TP
+\-p server_port
+The server's port number.
+.TP
+\-T test_option
+Specifies test parameters. Available options are:
+.P
+s | socket - uses standard socket calls to transfer data
+.P
+a | async - uses asynchronous operation (e.g. select / poll)
+.P
+b | blocking - uses blocking calls
+.P
+f | fork - fork server processing (forces -T s option)
+.P
+n | nonblocking - uses non-blocking calls
+.P
+r | resolve - use rdma cm to resolve address
+.P
+v | verify - verifies data transfers
+.SH "NOTES"
+Basic usage is to start rstream on a server system, then run
+rstream -s server_name on a client system. By default, rstream
+will run a series of latency and bandwidth performance tests.
+Specifying a different iterations, transfer_count, or transfer_size
+will run a user customized test using default values where none
+have been specified.
+.P
+Because this test maps RDMA resources to userspace, users must ensure
+that they have available system resources and permissions. See the
+libibverbs README file for additional details.
+.SH "SEE ALSO"
+rdma_cm(7)
diff --git a/contrib/ofed/librdmacm/man/ucmatose.1 b/contrib/ofed/librdmacm/man/ucmatose.1
index 73477ea..56e0702 100644
--- a/contrib/ofed/librdmacm/man/ucmatose.1
+++ b/contrib/ofed/librdmacm/man/ucmatose.1
@@ -1,13 +1,16 @@
+.\" Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md
.TH "UCMATOSE" 1 "2007-05-15" "librdmacm" "librdmacm" librdmacm
.SH NAME
ucmatose \- RDMA CM connection and simple ping-pong test.
.SH SYNOPSIS
.sp
.nf
-\fIucmatose\fR [-s server_address] [-b bind_address] [-c connections]
- [-C message_count] [-S message_size]
-\fIucmatose\fR -s server_address [-b bind_address] [-c connections]
- [-C message_count] [-S message_size] [-t tos]
+\fIucmatose\fR [-s server_address] [-b bind_address]
+ [-f address_format] [-P port_space]
+ [-c connections] [-C message_count] [-S message_size]
+\fIucmatose\fR -s server_address [-b bind_address]
+ [-f address_format] [-P port_space]
+ [-c connections] [-C message_count] [-S message_size] [-t tos]
.fi
.SH "DESCRIPTION"
Establishes a set of reliable RDMA connections between two nodes using the
@@ -21,6 +24,19 @@ This option must be specified by the client.
.TP
\-b bind_address
The local network address to bind to.
+To bind to any address with IPv6 use -b ::0 .
+.TP
+\-f address_format
+Specifies the format of the server and bind address. Be default, the
+format is determined by getaddrinfo() as either being a hostname, an IPv4
+address, or an IPv6 address. This option may be used to indicate that
+a specific address format has been provided. Supported address_format
+values are: name, ip, ipv6, and gid.
+.TP
+\-P port_space
+Specifies the port space for the connection. Be default, the port space
+is the RDMA TCP port space. (Note that the RDMA port space may be separate
+from that used for IP.) Supported port_space values are: tcp and ib.
.TP
\-c connections
The number of connections to establish between the client and server.
diff --git a/contrib/ofed/librdmacm/man/udaddy.1 b/contrib/ofed/librdmacm/man/udaddy.1
index 2f56b46..bc84504 100644
--- a/contrib/ofed/librdmacm/man/udaddy.1
+++ b/contrib/ofed/librdmacm/man/udaddy.1
@@ -1,3 +1,4 @@
+.\" Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md
.TH "UDADDY" 1 "2007-05-15" "librdmacm" "librdmacm" librdmacm
.SH NAME
udaddy \- RDMA CM datagram setup and simple ping-pong test.
@@ -22,6 +23,7 @@ This option must be specified by the client.
.TP
\-b bind_address
The local network address to bind to.
+To bind to any address with IPv6 use -b ::0 .
.TP
\-c connections
The number of communication paths to establish between the client and server.
diff --git a/contrib/ofed/librdmacm/man/udpong.1 b/contrib/ofed/librdmacm/man/udpong.1
new file mode 100644
index 0000000..008178b
--- /dev/null
+++ b/contrib/ofed/librdmacm/man/udpong.1
@@ -0,0 +1,62 @@
+.\" Licensed under the OpenIB.org BSD license (FreeBSD Variant) - See COPYING.md
+.TH "UDPONG" 1 "2017-04-28" "librdmacm" "librdmacm" librdmacm
+.SH NAME
+udpong \- unreliable datagram streaming over RDMA ping-pong test.
+.SH SYNOPSIS
+.sp
+.nf
+\fIudpong\fR [-s server_address] [-b bind_address]
+ [-B buffer_size] [-C transfer_count]
+ [-S transfer_size] [-p server_port] [-T test_option]
+.fi
+.SH "DESCRIPTION"
+Uses unreliable datagram streaming over RDMA protocol (rsocket) to
+connect and exchange data between a client and server application.
+.SH "OPTIONS"
+.TP
+\-s server_address
+The network name or IP address of the server system listening for
+connections. The used name or address must route over an RDMA device.
+This option must be specified by the client.
+.TP
+\-b bind_address
+The local network address to bind to.
+.TP
+\-B buffer_size
+Indicates the size of the send and receive network buffers.
+.TP
+\-C transfer_count
+The number of messages to transfer from the client to the server and
+back again on each iteration. (default 1000)
+.TP
+\-S transfer_size
+The size of each send transfer, in bytes. (default 1000)
+.TP
+\-p server_port
+The server's port number.
+.TP
+\-T test_option
+Specifies test parameters. Available options are:
+.P
+s | socket - uses standard socket calls to transfer data
+.P
+a | async - uses asynchronous operation (e.g. select / poll)
+.P
+b | blocking - uses blocking calls
+.P
+n | nonblocking - uses non-blocking calls
+.P
+e | echo - server echoes all messages
+.SH "NOTES"
+Basic usage is to start udpong on a server system, then run
+udpong -s server_name on a client system. udpong
+will run a series of latency and bandwidth performance tests.
+Specifying a different transfer_count or transfer_size
+will run a user customized test using default values where none
+have been specified.
+.P
+Because this test maps RDMA resources to userspace, users must ensure
+that they have available system resources and permissions. See the
+libibverbs README file for additional details.
+.SH "SEE ALSO"
+rdma_cm(7)
diff --git a/contrib/ofed/librdmacm/preload.c b/contrib/ofed/librdmacm/preload.c
new file mode 100644
index 0000000..20692bb
--- /dev/null
+++ b/contrib/ofed/librdmacm/preload.c
@@ -0,0 +1,1186 @@
+/*
+ * Copyright (c) 2011-2012 Intel Corporation. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+#define _GNU_SOURCE
+#include <config.h>
+
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <sys/uio.h>
+#include <sys/stat.h>
+#include <sys/mman.h>
+#include <stdarg.h>
+#include <dlfcn.h>
+#include <netdb.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <string.h>
+#include <netinet/tcp.h>
+#include <unistd.h>
+#include <semaphore.h>
+#include <ctype.h>
+#include <stdlib.h>
+#include <stdio.h>
+
+#include <rdma/rdma_cma.h>
+#include <rdma/rdma_verbs.h>
+#include <rdma/rsocket.h>
+#include "cma.h"
+#include "indexer.h"
+
+struct socket_calls {
+ int (*socket)(int domain, int type, int protocol);
+ int (*bind)(int socket, const struct sockaddr *addr, socklen_t addrlen);
+ int (*listen)(int socket, int backlog);
+ int (*accept)(int socket, struct sockaddr *addr, socklen_t *addrlen);
+ int (*connect)(int socket, const struct sockaddr *addr, socklen_t addrlen);
+ ssize_t (*recv)(int socket, void *buf, size_t len, int flags);
+ ssize_t (*recvfrom)(int socket, void *buf, size_t len, int flags,
+ struct sockaddr *src_addr, socklen_t *addrlen);
+ ssize_t (*recvmsg)(int socket, struct msghdr *msg, int flags);
+ ssize_t (*read)(int socket, void *buf, size_t count);
+ ssize_t (*readv)(int socket, const struct iovec *iov, int iovcnt);
+ ssize_t (*send)(int socket, const void *buf, size_t len, int flags);
+ ssize_t (*sendto)(int socket, const void *buf, size_t len, int flags,
+ const struct sockaddr *dest_addr, socklen_t addrlen);
+ ssize_t (*sendmsg)(int socket, const struct msghdr *msg, int flags);
+ ssize_t (*write)(int socket, const void *buf, size_t count);
+ ssize_t (*writev)(int socket, const struct iovec *iov, int iovcnt);
+ int (*poll)(struct pollfd *fds, nfds_t nfds, int timeout);
+ int (*shutdown)(int socket, int how);
+ int (*close)(int socket);
+ int (*getpeername)(int socket, struct sockaddr *addr, socklen_t *addrlen);
+ int (*getsockname)(int socket, struct sockaddr *addr, socklen_t *addrlen);
+ int (*setsockopt)(int socket, int level, int optname,
+ const void *optval, socklen_t optlen);
+ int (*getsockopt)(int socket, int level, int optname,
+ void *optval, socklen_t *optlen);
+ int (*fcntl)(int socket, int cmd, ... /* arg */);
+ int (*dup2)(int oldfd, int newfd);
+ ssize_t (*sendfile)(int out_fd, int in_fd, off_t *offset, size_t count);
+ int (*fxstat)(int ver, int fd, struct stat *buf);
+};
+
+static struct socket_calls real;
+static struct socket_calls rs;
+
+static struct index_map idm;
+static pthread_mutex_t mut = PTHREAD_MUTEX_INITIALIZER;
+
+static int sq_size;
+static int rq_size;
+static int sq_inline;
+static int fork_support;
+
+enum fd_type {
+ fd_normal,
+ fd_rsocket
+};
+
+enum fd_fork_state {
+ fd_ready,
+ fd_fork,
+ fd_fork_listen,
+ fd_fork_active,
+ fd_fork_passive
+};
+
+struct fd_info {
+ enum fd_type type;
+ enum fd_fork_state state;
+ int fd;
+ int dupfd;
+ _Atomic(int) refcnt;
+};
+
+struct config_entry {
+ char *name;
+ int domain;
+ int type;
+ int protocol;
+};
+
+static struct config_entry *config;
+static int config_cnt;
+
+static void free_config(void)
+{
+ while (config_cnt)
+ free(config[--config_cnt].name);
+
+ free(config);
+}
+
+/*
+ * Config file format:
+ * # Starting '#' indicates comment
+ * # wild card values are supported using '*'
+ * # domain - *, INET, INET6, IB
+ * # type - *, STREAM, DGRAM
+ * # protocol - *, TCP, UDP
+ * program_name domain type protocol
+ */
+static void scan_config(void)
+{
+ struct config_entry *new_config;
+ FILE *fp;
+ char line[120], prog[64], dom[16], type[16], proto[16];
+
+ fp = fopen(RS_CONF_DIR "/preload_config", "r");
+ if (!fp)
+ return;
+
+ while (fgets(line, sizeof(line), fp)) {
+ if (line[0] == '#')
+ continue;
+
+ if (sscanf(line, "%64s%16s%16s%16s", prog, dom, type, proto) != 4)
+ continue;
+
+ new_config = realloc(config, (config_cnt + 1) *
+ sizeof(struct config_entry));
+ if (!new_config)
+ break;
+
+ config = new_config;
+ memset(&config[config_cnt], 0, sizeof(struct config_entry));
+
+ if (!strcasecmp(dom, "INET") ||
+ !strcasecmp(dom, "AF_INET") ||
+ !strcasecmp(dom, "PF_INET")) {
+ config[config_cnt].domain = AF_INET;
+ } else if (!strcasecmp(dom, "INET6") ||
+ !strcasecmp(dom, "AF_INET6") ||
+ !strcasecmp(dom, "PF_INET6")) {
+ config[config_cnt].domain = AF_INET6;
+ } else if (!strcasecmp(dom, "IB") ||
+ !strcasecmp(dom, "AF_IB") ||
+ !strcasecmp(dom, "PF_IB")) {
+ config[config_cnt].domain = AF_IB;
+ } else if (strcmp(dom, "*")) {
+ continue;
+ }
+
+ if (!strcasecmp(type, "STREAM") ||
+ !strcasecmp(type, "SOCK_STREAM")) {
+ config[config_cnt].type = SOCK_STREAM;
+ } else if (!strcasecmp(type, "DGRAM") ||
+ !strcasecmp(type, "SOCK_DGRAM")) {
+ config[config_cnt].type = SOCK_DGRAM;
+ } else if (strcmp(type, "*")) {
+ continue;
+ }
+
+ if (!strcasecmp(proto, "TCP") ||
+ !strcasecmp(proto, "IPPROTO_TCP")) {
+ config[config_cnt].protocol = IPPROTO_TCP;
+ } else if (!strcasecmp(proto, "UDP") ||
+ !strcasecmp(proto, "IPPROTO_UDP")) {
+ config[config_cnt].protocol = IPPROTO_UDP;
+ } else if (strcmp(proto, "*")) {
+ continue;
+ }
+
+ if (strcmp(prog, "*")) {
+ if (!(config[config_cnt].name = strdup(prog)))
+ continue;
+ }
+
+ config_cnt++;
+ }
+
+ fclose(fp);
+ if (config_cnt)
+ atexit(free_config);
+}
+
+static int intercept_socket(int domain, int type, int protocol)
+{
+ int i;
+
+ if (!config_cnt)
+ return 1;
+
+ if (!protocol) {
+ if (type == SOCK_STREAM)
+ protocol = IPPROTO_TCP;
+ else if (type == SOCK_DGRAM)
+ protocol = IPPROTO_UDP;
+ }
+
+ for (i = 0; i < config_cnt; i++) {
+ if ((!config[i].name ||
+ !strncasecmp(config[i].name, program_invocation_short_name,
+ strlen(config[i].name))) &&
+ (!config[i].domain || config[i].domain == domain) &&
+ (!config[i].type || config[i].type == type) &&
+ (!config[i].protocol || config[i].protocol == protocol))
+ return 1;
+ }
+
+ return 0;
+}
+
+static int fd_open(void)
+{
+ struct fd_info *fdi;
+ int ret, index;
+
+ fdi = calloc(1, sizeof(*fdi));
+ if (!fdi)
+ return ERR(ENOMEM);
+
+ index = open("/dev/null", O_RDONLY);
+ if (index < 0) {
+ ret = index;
+ goto err1;
+ }
+
+ fdi->dupfd = -1;
+ atomic_store(&fdi->refcnt, 1);
+ pthread_mutex_lock(&mut);
+ ret = idm_set(&idm, index, fdi);
+ pthread_mutex_unlock(&mut);
+ if (ret < 0)
+ goto err2;
+
+ return index;
+
+err2:
+ real.close(index);
+err1:
+ free(fdi);
+ return ret;
+}
+
+static void fd_store(int index, int fd, enum fd_type type, enum fd_fork_state state)
+{
+ struct fd_info *fdi;
+
+ fdi = idm_at(&idm, index);
+ fdi->fd = fd;
+ fdi->type = type;
+ fdi->state = state;
+}
+
+static inline enum fd_type fd_get(int index, int *fd)
+{
+ struct fd_info *fdi;
+
+ fdi = idm_lookup(&idm, index);
+ if (fdi) {
+ *fd = fdi->fd;
+ return fdi->type;
+
+ } else {
+ *fd = index;
+ return fd_normal;
+ }
+}
+
+static inline int fd_getd(int index)
+{
+ struct fd_info *fdi;
+
+ fdi = idm_lookup(&idm, index);
+ return fdi ? fdi->fd : index;
+}
+
+static inline enum fd_fork_state fd_gets(int index)
+{
+ struct fd_info *fdi;
+
+ fdi = idm_lookup(&idm, index);
+ return fdi ? fdi->state : fd_ready;
+}
+
+static inline enum fd_type fd_gett(int index)
+{
+ struct fd_info *fdi;
+
+ fdi = idm_lookup(&idm, index);
+ return fdi ? fdi->type : fd_normal;
+}
+
+static enum fd_type fd_close(int index, int *fd)
+{
+ struct fd_info *fdi;
+ enum fd_type type;
+
+ fdi = idm_lookup(&idm, index);
+ if (fdi) {
+ idm_clear(&idm, index);
+ *fd = fdi->fd;
+ type = fdi->type;
+ real.close(index);
+ free(fdi);
+ } else {
+ *fd = index;
+ type = fd_normal;
+ }
+ return type;
+}
+
+static void getenv_options(void)
+{
+ char *var;
+
+ var = getenv("RS_SQ_SIZE");
+ if (var)
+ sq_size = atoi(var);
+
+ var = getenv("RS_RQ_SIZE");
+ if (var)
+ rq_size = atoi(var);
+
+ var = getenv("RS_INLINE");
+ if (var)
+ sq_inline = atoi(var);
+
+ var = getenv("RDMAV_FORK_SAFE");
+ if (var)
+ fork_support = atoi(var);
+}
+
+static void init_preload(void)
+{
+ static int init;
+
+ /* Quick check without lock */
+ if (init)
+ return;
+
+ pthread_mutex_lock(&mut);
+ if (init)
+ goto out;
+
+ real.socket = dlsym(RTLD_NEXT, "socket");
+ real.bind = dlsym(RTLD_NEXT, "bind");
+ real.listen = dlsym(RTLD_NEXT, "listen");
+ real.accept = dlsym(RTLD_NEXT, "accept");
+ real.connect = dlsym(RTLD_NEXT, "connect");
+ real.recv = dlsym(RTLD_NEXT, "recv");
+ real.recvfrom = dlsym(RTLD_NEXT, "recvfrom");
+ real.recvmsg = dlsym(RTLD_NEXT, "recvmsg");
+ real.read = dlsym(RTLD_NEXT, "read");
+ real.readv = dlsym(RTLD_NEXT, "readv");
+ real.send = dlsym(RTLD_NEXT, "send");
+ real.sendto = dlsym(RTLD_NEXT, "sendto");
+ real.sendmsg = dlsym(RTLD_NEXT, "sendmsg");
+ real.write = dlsym(RTLD_NEXT, "write");
+ real.writev = dlsym(RTLD_NEXT, "writev");
+ real.poll = dlsym(RTLD_NEXT, "poll");
+ real.shutdown = dlsym(RTLD_NEXT, "shutdown");
+ real.close = dlsym(RTLD_NEXT, "close");
+ real.getpeername = dlsym(RTLD_NEXT, "getpeername");
+ real.getsockname = dlsym(RTLD_NEXT, "getsockname");
+ real.setsockopt = dlsym(RTLD_NEXT, "setsockopt");
+ real.getsockopt = dlsym(RTLD_NEXT, "getsockopt");
+ real.fcntl = dlsym(RTLD_NEXT, "fcntl");
+ real.dup2 = dlsym(RTLD_NEXT, "dup2");
+ real.sendfile = dlsym(RTLD_NEXT, "sendfile");
+ real.fxstat = dlsym(RTLD_NEXT, "__fxstat");
+
+ rs.socket = dlsym(RTLD_DEFAULT, "rsocket");
+ rs.bind = dlsym(RTLD_DEFAULT, "rbind");
+ rs.listen = dlsym(RTLD_DEFAULT, "rlisten");
+ rs.accept = dlsym(RTLD_DEFAULT, "raccept");
+ rs.connect = dlsym(RTLD_DEFAULT, "rconnect");
+ rs.recv = dlsym(RTLD_DEFAULT, "rrecv");
+ rs.recvfrom = dlsym(RTLD_DEFAULT, "rrecvfrom");
+ rs.recvmsg = dlsym(RTLD_DEFAULT, "rrecvmsg");
+ rs.read = dlsym(RTLD_DEFAULT, "rread");
+ rs.readv = dlsym(RTLD_DEFAULT, "rreadv");
+ rs.send = dlsym(RTLD_DEFAULT, "rsend");
+ rs.sendto = dlsym(RTLD_DEFAULT, "rsendto");
+ rs.sendmsg = dlsym(RTLD_DEFAULT, "rsendmsg");
+ rs.write = dlsym(RTLD_DEFAULT, "rwrite");
+ rs.writev = dlsym(RTLD_DEFAULT, "rwritev");
+ rs.poll = dlsym(RTLD_DEFAULT, "rpoll");
+ rs.shutdown = dlsym(RTLD_DEFAULT, "rshutdown");
+ rs.close = dlsym(RTLD_DEFAULT, "rclose");
+ rs.getpeername = dlsym(RTLD_DEFAULT, "rgetpeername");
+ rs.getsockname = dlsym(RTLD_DEFAULT, "rgetsockname");
+ rs.setsockopt = dlsym(RTLD_DEFAULT, "rsetsockopt");
+ rs.getsockopt = dlsym(RTLD_DEFAULT, "rgetsockopt");
+ rs.fcntl = dlsym(RTLD_DEFAULT, "rfcntl");
+
+ getenv_options();
+ scan_config();
+ init = 1;
+out:
+ pthread_mutex_unlock(&mut);
+}
+
+/*
+ * We currently only handle copying a few common values.
+ */
+static int copysockopts(int dfd, int sfd, struct socket_calls *dapi,
+ struct socket_calls *sapi)
+{
+ socklen_t len;
+ int param, ret;
+
+ ret = sapi->fcntl(sfd, F_GETFL);
+ if (ret > 0)
+ ret = dapi->fcntl(dfd, F_SETFL, ret);
+ if (ret)
+ return ret;
+
+ len = sizeof param;
+ ret = sapi->getsockopt(sfd, SOL_SOCKET, SO_REUSEADDR, &param, &len);
+ if (param && !ret)
+ ret = dapi->setsockopt(dfd, SOL_SOCKET, SO_REUSEADDR, &param, len);
+ if (ret)
+ return ret;
+
+ len = sizeof param;
+ ret = sapi->getsockopt(sfd, IPPROTO_TCP, TCP_NODELAY, &param, &len);
+ if (param && !ret)
+ ret = dapi->setsockopt(dfd, IPPROTO_TCP, TCP_NODELAY, &param, len);
+ if (ret)
+ return ret;
+
+ return 0;
+}
+
+/*
+ * Convert between an rsocket and a normal socket.
+ */
+static int transpose_socket(int socket, enum fd_type new_type)
+{
+ socklen_t len = 0;
+ int sfd, dfd, param, ret;
+ struct socket_calls *sapi, *dapi;
+
+ sfd = fd_getd(socket);
+ if (new_type == fd_rsocket) {
+ dapi = &rs;
+ sapi = &real;
+ } else {
+ dapi = &real;
+ sapi = &rs;
+ }
+
+ ret = sapi->getsockname(sfd, NULL, &len);
+ if (ret)
+ return ret;
+
+ param = (len == sizeof(struct sockaddr_in6)) ? PF_INET6 : PF_INET;
+ dfd = dapi->socket(param, SOCK_STREAM, 0);
+ if (dfd < 0)
+ return dfd;
+
+ ret = copysockopts(dfd, sfd, dapi, sapi);
+ if (ret)
+ goto err;
+
+ fd_store(socket, dfd, new_type, fd_ready);
+ return dfd;
+
+err:
+ dapi->close(dfd);
+ return ret;
+}
+
+/*
+ * Use defaults on failure.
+ */
+static void set_rsocket_options(int rsocket)
+{
+ if (sq_size)
+ rsetsockopt(rsocket, SOL_RDMA, RDMA_SQSIZE, &sq_size, sizeof sq_size);
+
+ if (rq_size)
+ rsetsockopt(rsocket, SOL_RDMA, RDMA_RQSIZE, &rq_size, sizeof rq_size);
+
+ if (sq_inline)
+ rsetsockopt(rsocket, SOL_RDMA, RDMA_INLINE, &sq_inline, sizeof sq_inline);
+}
+
+int socket(int domain, int type, int protocol)
+{
+ static __thread int recursive;
+ int index, ret;
+
+ init_preload();
+
+ if (recursive || !intercept_socket(domain, type, protocol))
+ goto real;
+
+ index = fd_open();
+ if (index < 0)
+ return index;
+
+ if (fork_support && (domain == PF_INET || domain == PF_INET6) &&
+ (type == SOCK_STREAM) && (!protocol || protocol == IPPROTO_TCP)) {
+ ret = real.socket(domain, type, protocol);
+ if (ret < 0)
+ return ret;
+ fd_store(index, ret, fd_normal, fd_fork);
+ return index;
+ }
+
+ recursive = 1;
+ ret = rsocket(domain, type, protocol);
+ recursive = 0;
+ if (ret >= 0) {
+ fd_store(index, ret, fd_rsocket, fd_ready);
+ set_rsocket_options(ret);
+ return index;
+ }
+ fd_close(index, &ret);
+real:
+ return real.socket(domain, type, protocol);
+}
+
+int bind(int socket, const struct sockaddr *addr, socklen_t addrlen)
+{
+ int fd;
+ return (fd_get(socket, &fd) == fd_rsocket) ?
+ rbind(fd, addr, addrlen) : real.bind(fd, addr, addrlen);
+}
+
+int listen(int socket, int backlog)
+{
+ int fd, ret;
+ if (fd_get(socket, &fd) == fd_rsocket) {
+ ret = rlisten(fd, backlog);
+ } else {
+ ret = real.listen(fd, backlog);
+ if (!ret && fd_gets(socket) == fd_fork)
+ fd_store(socket, fd, fd_normal, fd_fork_listen);
+ }
+ return ret;
+}
+
+int accept(int socket, struct sockaddr *addr, socklen_t *addrlen)
+{
+ int fd, index, ret;
+
+ if (fd_get(socket, &fd) == fd_rsocket) {
+ index = fd_open();
+ if (index < 0)
+ return index;
+
+ ret = raccept(fd, addr, addrlen);
+ if (ret < 0) {
+ fd_close(index, &fd);
+ return ret;
+ }
+
+ fd_store(index, ret, fd_rsocket, fd_ready);
+ return index;
+ } else if (fd_gets(socket) == fd_fork_listen) {
+ index = fd_open();
+ if (index < 0)
+ return index;
+
+ ret = real.accept(fd, addr, addrlen);
+ if (ret < 0) {
+ fd_close(index, &fd);
+ return ret;
+ }
+
+ fd_store(index, ret, fd_normal, fd_fork_passive);
+ return index;
+ } else {
+ return real.accept(fd, addr, addrlen);
+ }
+}
+
+/*
+ * We can't fork RDMA connections and pass them from the parent to the child
+ * process. Instead, we need to establish the RDMA connection after calling
+ * fork. To do this, we delay establishing the RDMA connection until we try
+ * to send/receive on the server side.
+ */
+static void fork_active(int socket)
+{
+ struct sockaddr_storage addr;
+ int sfd, dfd, ret;
+ socklen_t len;
+ uint32_t msg;
+ long flags;
+
+ sfd = fd_getd(socket);
+
+ flags = real.fcntl(sfd, F_GETFL);
+ real.fcntl(sfd, F_SETFL, 0);
+ ret = real.recv(sfd, &msg, sizeof msg, MSG_PEEK);
+ real.fcntl(sfd, F_SETFL, flags);
+ if ((ret != sizeof msg) || msg)
+ goto err1;
+
+ len = sizeof addr;
+ ret = real.getpeername(sfd, (struct sockaddr *) &addr, &len);
+ if (ret)
+ goto err1;
+
+ dfd = rsocket(addr.ss_family, SOCK_STREAM, 0);
+ if (dfd < 0)
+ goto err1;
+
+ ret = rconnect(dfd, (struct sockaddr *) &addr, len);
+ if (ret)
+ goto err2;
+
+ set_rsocket_options(dfd);
+ copysockopts(dfd, sfd, &rs, &real);
+ real.shutdown(sfd, SHUT_RDWR);
+ real.close(sfd);
+ fd_store(socket, dfd, fd_rsocket, fd_ready);
+ return;
+
+err2:
+ rclose(dfd);
+err1:
+ fd_store(socket, sfd, fd_normal, fd_ready);
+}
+
+/*
+ * The server will start listening for the new connection, then send a
+ * message to the active side when the listen is ready. This does leave
+ * fork unsupported in the following case: the server is nonblocking and
+ * calls select/poll waiting to receive data from the client.
+ */
+static void fork_passive(int socket)
+{
+ struct sockaddr_in6 sin6;
+ sem_t *sem;
+ int lfd, sfd, dfd, ret, param;
+ socklen_t len;
+ uint32_t msg;
+
+ sfd = fd_getd(socket);
+
+ len = sizeof sin6;
+ ret = real.getsockname(sfd, (struct sockaddr *) &sin6, &len);
+ if (ret)
+ goto out;
+ sin6.sin6_flowinfo = 0;
+ sin6.sin6_scope_id = 0;
+ memset(&sin6.sin6_addr, 0, sizeof sin6.sin6_addr);
+
+ sem = sem_open("/rsocket_fork", O_CREAT | O_RDWR,
+ S_IRWXU | S_IRWXG, 1);
+ if (sem == SEM_FAILED) {
+ ret = -1;
+ goto out;
+ }
+
+ lfd = rsocket(sin6.sin6_family, SOCK_STREAM, 0);
+ if (lfd < 0) {
+ ret = lfd;
+ goto sclose;
+ }
+
+ param = 1;
+ rsetsockopt(lfd, SOL_SOCKET, SO_REUSEADDR, &param, sizeof param);
+
+ sem_wait(sem);
+ ret = rbind(lfd, (struct sockaddr *) &sin6, sizeof sin6);
+ if (ret)
+ goto lclose;
+
+ ret = rlisten(lfd, 1);
+ if (ret)
+ goto lclose;
+
+ msg = 0;
+ len = real.write(sfd, &msg, sizeof msg);
+ if (len != sizeof msg)
+ goto lclose;
+
+ dfd = raccept(lfd, NULL, NULL);
+ if (dfd < 0) {
+ ret = dfd;
+ goto lclose;
+ }
+
+ set_rsocket_options(dfd);
+ copysockopts(dfd, sfd, &rs, &real);
+ real.shutdown(sfd, SHUT_RDWR);
+ real.close(sfd);
+ fd_store(socket, dfd, fd_rsocket, fd_ready);
+
+lclose:
+ rclose(lfd);
+ sem_post(sem);
+sclose:
+ sem_close(sem);
+out:
+ if (ret)
+ fd_store(socket, sfd, fd_normal, fd_ready);
+}
+
+static inline enum fd_type fd_fork_get(int index, int *fd)
+{
+ struct fd_info *fdi;
+
+ fdi = idm_lookup(&idm, index);
+ if (fdi) {
+ if (fdi->state == fd_fork_passive)
+ fork_passive(index);
+ else if (fdi->state == fd_fork_active)
+ fork_active(index);
+ *fd = fdi->fd;
+ return fdi->type;
+
+ } else {
+ *fd = index;
+ return fd_normal;
+ }
+}
+
+int connect(int socket, const struct sockaddr *addr, socklen_t addrlen)
+{
+ int fd, ret;
+
+ if (fd_get(socket, &fd) == fd_rsocket) {
+ ret = rconnect(fd, addr, addrlen);
+ if (!ret || errno == EINPROGRESS)
+ return ret;
+
+ ret = transpose_socket(socket, fd_normal);
+ if (ret < 0)
+ return ret;
+
+ rclose(fd);
+ fd = ret;
+ } else if (fd_gets(socket) == fd_fork) {
+ fd_store(socket, fd, fd_normal, fd_fork_active);
+ }
+
+ return real.connect(fd, addr, addrlen);
+}
+
+ssize_t recv(int socket, void *buf, size_t len, int flags)
+{
+ int fd;
+ return (fd_fork_get(socket, &fd) == fd_rsocket) ?
+ rrecv(fd, buf, len, flags) : real.recv(fd, buf, len, flags);
+}
+
+ssize_t recvfrom(int socket, void *buf, size_t len, int flags,
+ struct sockaddr *src_addr, socklen_t *addrlen)
+{
+ int fd;
+ return (fd_fork_get(socket, &fd) == fd_rsocket) ?
+ rrecvfrom(fd, buf, len, flags, src_addr, addrlen) :
+ real.recvfrom(fd, buf, len, flags, src_addr, addrlen);
+}
+
+ssize_t recvmsg(int socket, struct msghdr *msg, int flags)
+{
+ int fd;
+ return (fd_fork_get(socket, &fd) == fd_rsocket) ?
+ rrecvmsg(fd, msg, flags) : real.recvmsg(fd, msg, flags);
+}
+
+ssize_t read(int socket, void *buf, size_t count)
+{
+ int fd;
+ init_preload();
+ return (fd_fork_get(socket, &fd) == fd_rsocket) ?
+ rread(fd, buf, count) : real.read(fd, buf, count);
+}
+
+ssize_t readv(int socket, const struct iovec *iov, int iovcnt)
+{
+ int fd;
+ init_preload();
+ return (fd_fork_get(socket, &fd) == fd_rsocket) ?
+ rreadv(fd, iov, iovcnt) : real.readv(fd, iov, iovcnt);
+}
+
+ssize_t send(int socket, const void *buf, size_t len, int flags)
+{
+ int fd;
+ return (fd_fork_get(socket, &fd) == fd_rsocket) ?
+ rsend(fd, buf, len, flags) : real.send(fd, buf, len, flags);
+}
+
+ssize_t sendto(int socket, const void *buf, size_t len, int flags,
+ const struct sockaddr *dest_addr, socklen_t addrlen)
+{
+ int fd;
+ return (fd_fork_get(socket, &fd) == fd_rsocket) ?
+ rsendto(fd, buf, len, flags, dest_addr, addrlen) :
+ real.sendto(fd, buf, len, flags, dest_addr, addrlen);
+}
+
+ssize_t sendmsg(int socket, const struct msghdr *msg, int flags)
+{
+ int fd;
+ return (fd_fork_get(socket, &fd) == fd_rsocket) ?
+ rsendmsg(fd, msg, flags) : real.sendmsg(fd, msg, flags);
+}
+
+ssize_t write(int socket, const void *buf, size_t count)
+{
+ int fd;
+ init_preload();
+ return (fd_fork_get(socket, &fd) == fd_rsocket) ?
+ rwrite(fd, buf, count) : real.write(fd, buf, count);
+}
+
+ssize_t writev(int socket, const struct iovec *iov, int iovcnt)
+{
+ int fd;
+ init_preload();
+ return (fd_fork_get(socket, &fd) == fd_rsocket) ?
+ rwritev(fd, iov, iovcnt) : real.writev(fd, iov, iovcnt);
+}
+
+static struct pollfd *fds_alloc(nfds_t nfds)
+{
+ static __thread struct pollfd *rfds;
+ static __thread nfds_t rnfds;
+
+ if (nfds > rnfds) {
+ if (rfds)
+ free(rfds);
+
+ rfds = malloc(sizeof(*rfds) * nfds);
+ rnfds = rfds ? nfds : 0;
+ }
+
+ return rfds;
+}
+
+int poll(struct pollfd *fds, nfds_t nfds, int timeout)
+{
+ struct pollfd *rfds;
+ int i, ret;
+
+ init_preload();
+ for (i = 0; i < nfds; i++) {
+ if (fd_gett(fds[i].fd) == fd_rsocket)
+ goto use_rpoll;
+ }
+
+ return real.poll(fds, nfds, timeout);
+
+use_rpoll:
+ rfds = fds_alloc(nfds);
+ if (!rfds)
+ return ERR(ENOMEM);
+
+ for (i = 0; i < nfds; i++) {
+ rfds[i].fd = fd_getd(fds[i].fd);
+ rfds[i].events = fds[i].events;
+ rfds[i].revents = 0;
+ }
+
+ ret = rpoll(rfds, nfds, timeout);
+
+ for (i = 0; i < nfds; i++)
+ fds[i].revents = rfds[i].revents;
+
+ return ret;
+}
+
+static void select_to_rpoll(struct pollfd *fds, int *nfds,
+ fd_set *readfds, fd_set *writefds, fd_set *exceptfds)
+{
+ int fd, events, i = 0;
+
+ for (fd = 0; fd < *nfds; fd++) {
+ events = (readfds && FD_ISSET(fd, readfds)) ? POLLIN : 0;
+ if (writefds && FD_ISSET(fd, writefds))
+ events |= POLLOUT;
+
+ if (events || (exceptfds && FD_ISSET(fd, exceptfds))) {
+ fds[i].fd = fd_getd(fd);
+ fds[i++].events = events;
+ }
+ }
+
+ *nfds = i;
+}
+
+static int rpoll_to_select(struct pollfd *fds, int nfds,
+ fd_set *readfds, fd_set *writefds, fd_set *exceptfds)
+{
+ int fd, rfd, i, cnt = 0;
+
+ for (i = 0, fd = 0; i < nfds; fd++) {
+ rfd = fd_getd(fd);
+ if (rfd != fds[i].fd)
+ continue;
+
+ if (readfds && (fds[i].revents & POLLIN)) {
+ FD_SET(fd, readfds);
+ cnt++;
+ }
+
+ if (writefds && (fds[i].revents & POLLOUT)) {
+ FD_SET(fd, writefds);
+ cnt++;
+ }
+
+ if (exceptfds && (fds[i].revents & ~(POLLIN | POLLOUT))) {
+ FD_SET(fd, exceptfds);
+ cnt++;
+ }
+ i++;
+ }
+
+ return cnt;
+}
+
+static int rs_convert_timeout(struct timeval *timeout)
+{
+ return !timeout ? -1 : timeout->tv_sec * 1000 + timeout->tv_usec / 1000;
+}
+
+int select(int nfds, fd_set *readfds, fd_set *writefds,
+ fd_set *exceptfds, struct timeval *timeout)
+{
+ struct pollfd *fds;
+ int ret;
+
+ fds = fds_alloc(nfds);
+ if (!fds)
+ return ERR(ENOMEM);
+
+ select_to_rpoll(fds, &nfds, readfds, writefds, exceptfds);
+ ret = rpoll(fds, nfds, rs_convert_timeout(timeout));
+
+ if (readfds)
+ FD_ZERO(readfds);
+ if (writefds)
+ FD_ZERO(writefds);
+ if (exceptfds)
+ FD_ZERO(exceptfds);
+
+ if (ret > 0)
+ ret = rpoll_to_select(fds, nfds, readfds, writefds, exceptfds);
+
+ return ret;
+}
+
+int shutdown(int socket, int how)
+{
+ int fd;
+ return (fd_get(socket, &fd) == fd_rsocket) ?
+ rshutdown(fd, how) : real.shutdown(fd, how);
+}
+
+int close(int socket)
+{
+ struct fd_info *fdi;
+ int ret;
+
+ init_preload();
+ fdi = idm_lookup(&idm, socket);
+ if (!fdi)
+ return real.close(socket);
+
+ if (fdi->dupfd != -1) {
+ ret = close(fdi->dupfd);
+ if (ret)
+ return ret;
+ }
+
+ if (atomic_fetch_sub(&fdi->refcnt, 1) != 1)
+ return 0;
+
+ idm_clear(&idm, socket);
+ real.close(socket);
+ ret = (fdi->type == fd_rsocket) ? rclose(fdi->fd) : real.close(fdi->fd);
+ free(fdi);
+ return ret;
+}
+
+int getpeername(int socket, struct sockaddr *addr, socklen_t *addrlen)
+{
+ int fd;
+ return (fd_get(socket, &fd) == fd_rsocket) ?
+ rgetpeername(fd, addr, addrlen) :
+ real.getpeername(fd, addr, addrlen);
+}
+
+int getsockname(int socket, struct sockaddr *addr, socklen_t *addrlen)
+{
+ int fd;
+ init_preload();
+ return (fd_get(socket, &fd) == fd_rsocket) ?
+ rgetsockname(fd, addr, addrlen) :
+ real.getsockname(fd, addr, addrlen);
+}
+
+int setsockopt(int socket, int level, int optname,
+ const void *optval, socklen_t optlen)
+{
+ int fd;
+ return (fd_get(socket, &fd) == fd_rsocket) ?
+ rsetsockopt(fd, level, optname, optval, optlen) :
+ real.setsockopt(fd, level, optname, optval, optlen);
+}
+
+int getsockopt(int socket, int level, int optname,
+ void *optval, socklen_t *optlen)
+{
+ int fd;
+ return (fd_get(socket, &fd) == fd_rsocket) ?
+ rgetsockopt(fd, level, optname, optval, optlen) :
+ real.getsockopt(fd, level, optname, optval, optlen);
+}
+
+int fcntl(int socket, int cmd, ... /* arg */)
+{
+ va_list args;
+ long lparam;
+ void *pparam;
+ int fd, ret;
+
+ init_preload();
+ va_start(args, cmd);
+ switch (cmd) {
+ case F_GETFD:
+ case F_GETFL:
+ case F_GETOWN:
+ case F_GETSIG:
+ case F_GETLEASE:
+ ret = (fd_get(socket, &fd) == fd_rsocket) ?
+ rfcntl(fd, cmd) : real.fcntl(fd, cmd);
+ break;
+ case F_DUPFD:
+ /*case F_DUPFD_CLOEXEC:*/
+ case F_SETFD:
+ case F_SETFL:
+ case F_SETOWN:
+ case F_SETSIG:
+ case F_SETLEASE:
+ case F_NOTIFY:
+ lparam = va_arg(args, long);
+ ret = (fd_get(socket, &fd) == fd_rsocket) ?
+ rfcntl(fd, cmd, lparam) : real.fcntl(fd, cmd, lparam);
+ break;
+ default:
+ pparam = va_arg(args, void *);
+ ret = (fd_get(socket, &fd) == fd_rsocket) ?
+ rfcntl(fd, cmd, pparam) : real.fcntl(fd, cmd, pparam);
+ break;
+ }
+ va_end(args);
+ return ret;
+}
+
+/*
+ * dup2 is not thread safe
+ */
+int dup2(int oldfd, int newfd)
+{
+ struct fd_info *oldfdi, *newfdi;
+ int ret;
+
+ init_preload();
+ oldfdi = idm_lookup(&idm, oldfd);
+ if (oldfdi) {
+ if (oldfdi->state == fd_fork_passive)
+ fork_passive(oldfd);
+ else if (oldfdi->state == fd_fork_active)
+ fork_active(oldfd);
+ }
+
+ newfdi = idm_lookup(&idm, newfd);
+ if (newfdi) {
+ /* newfd cannot have been dup'ed directly */
+ if (atomic_load(&newfdi->refcnt) > 1)
+ return ERR(EBUSY);
+ close(newfd);
+ }
+
+ ret = real.dup2(oldfd, newfd);
+ if (!oldfdi || ret != newfd)
+ return ret;
+
+ newfdi = calloc(1, sizeof(*newfdi));
+ if (!newfdi) {
+ close(newfd);
+ return ERR(ENOMEM);
+ }
+
+ pthread_mutex_lock(&mut);
+ idm_set(&idm, newfd, newfdi);
+ pthread_mutex_unlock(&mut);
+
+ newfdi->fd = oldfdi->fd;
+ newfdi->type = oldfdi->type;
+ if (oldfdi->dupfd != -1) {
+ newfdi->dupfd = oldfdi->dupfd;
+ oldfdi = idm_lookup(&idm, oldfdi->dupfd);
+ } else {
+ newfdi->dupfd = oldfd;
+ }
+ atomic_store(&newfdi->refcnt, 1);
+ atomic_fetch_add(&oldfdi->refcnt, 1);
+ return newfd;
+}
+
+ssize_t sendfile(int out_fd, int in_fd, off_t *offset, size_t count)
+{
+ void *file_addr;
+ int fd;
+ size_t ret;
+
+ if (fd_get(out_fd, &fd) != fd_rsocket)
+ return real.sendfile(fd, in_fd, offset, count);
+
+ file_addr = mmap(NULL, count, PROT_READ, 0, in_fd, offset ? *offset : 0);
+ if (file_addr == (void *) -1)
+ return -1;
+
+ ret = rwrite(fd, file_addr, count);
+ if ((ret > 0) && offset)
+ lseek(in_fd, ret, SEEK_CUR);
+ munmap(file_addr, count);
+ return ret;
+}
+
+int __fxstat(int ver, int socket, struct stat *buf)
+{
+ int fd, ret;
+
+ init_preload();
+ if (fd_get(socket, &fd) == fd_rsocket) {
+ ret = real.fxstat(ver, socket, buf);
+ if (!ret)
+ buf->st_mode = (buf->st_mode & ~S_IFMT) | __S_IFSOCK;
+ } else {
+ ret = real.fxstat(ver, fd, buf);
+ }
+ return ret;
+}
diff --git a/contrib/ofed/librdmacm/rdma_cma.h b/contrib/ofed/librdmacm/rdma_cma.h
new file mode 100644
index 0000000..e0fc58e
--- /dev/null
+++ b/contrib/ofed/librdmacm/rdma_cma.h
@@ -0,0 +1,681 @@
+/*
+ * Copyright (c) 2005 Voltaire Inc. All rights reserved.
+ * Copyright (c) 2005-2014 Intel Corporation. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#if !defined(RDMA_CMA_H)
+#define RDMA_CMA_H
+
+#include <netinet/in.h>
+#include <sys/socket.h>
+#include <infiniband/verbs.h>
+#include <infiniband/sa.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*
+ * Upon receiving a device removal event, users must destroy the associated
+ * RDMA identifier and release all resources allocated with the device.
+ */
+enum rdma_cm_event_type {
+ RDMA_CM_EVENT_ADDR_RESOLVED,
+ RDMA_CM_EVENT_ADDR_ERROR,
+ RDMA_CM_EVENT_ROUTE_RESOLVED,
+ RDMA_CM_EVENT_ROUTE_ERROR,
+ RDMA_CM_EVENT_CONNECT_REQUEST,
+ RDMA_CM_EVENT_CONNECT_RESPONSE,
+ RDMA_CM_EVENT_CONNECT_ERROR,
+ RDMA_CM_EVENT_UNREACHABLE,
+ RDMA_CM_EVENT_REJECTED,
+ RDMA_CM_EVENT_ESTABLISHED,
+ RDMA_CM_EVENT_DISCONNECTED,
+ RDMA_CM_EVENT_DEVICE_REMOVAL,
+ RDMA_CM_EVENT_MULTICAST_JOIN,
+ RDMA_CM_EVENT_MULTICAST_ERROR,
+ RDMA_CM_EVENT_ADDR_CHANGE,
+ RDMA_CM_EVENT_TIMEWAIT_EXIT
+};
+
+enum rdma_port_space {
+ RDMA_PS_IPOIB = 0x0002,
+ RDMA_PS_TCP = 0x0106,
+ RDMA_PS_UDP = 0x0111,
+ RDMA_PS_IB = 0x013F,
+};
+
+#define RDMA_IB_IP_PS_MASK 0xFFFFFFFFFFFF0000ULL
+#define RDMA_IB_IP_PORT_MASK 0x000000000000FFFFULL
+#define RDMA_IB_IP_PS_TCP 0x0000000001060000ULL
+#define RDMA_IB_IP_PS_UDP 0x0000000001110000ULL
+#define RDMA_IB_PS_IB 0x00000000013F0000ULL
+
+/*
+ * Global qkey value for UDP QPs and multicast groups created via the
+ * RDMA CM.
+ */
+#define RDMA_UDP_QKEY 0x01234567
+
+struct rdma_ib_addr {
+ union ibv_gid sgid;
+ union ibv_gid dgid;
+ __be16 pkey;
+};
+
+struct rdma_addr {
+ union {
+ struct sockaddr src_addr;
+ struct sockaddr_in src_sin;
+ struct sockaddr_in6 src_sin6;
+ struct sockaddr_storage src_storage;
+ };
+ union {
+ struct sockaddr dst_addr;
+ struct sockaddr_in dst_sin;
+ struct sockaddr_in6 dst_sin6;
+ struct sockaddr_storage dst_storage;
+ };
+ union {
+ struct rdma_ib_addr ibaddr;
+ } addr;
+};
+
+struct rdma_route {
+ struct rdma_addr addr;
+ struct ibv_sa_path_rec *path_rec;
+ int num_paths;
+};
+
+struct rdma_event_channel {
+ int fd;
+};
+
+struct rdma_cm_id {
+ struct ibv_context *verbs;
+ struct rdma_event_channel *channel;
+ void *context;
+ struct ibv_qp *qp;
+ struct rdma_route route;
+ enum rdma_port_space ps;
+ uint8_t port_num;
+ struct rdma_cm_event *event;
+ struct ibv_comp_channel *send_cq_channel;
+ struct ibv_cq *send_cq;
+ struct ibv_comp_channel *recv_cq_channel;
+ struct ibv_cq *recv_cq;
+ struct ibv_srq *srq;
+ struct ibv_pd *pd;
+ enum ibv_qp_type qp_type;
+};
+
+enum {
+ RDMA_MAX_RESP_RES = 0xFF,
+ RDMA_MAX_INIT_DEPTH = 0xFF
+};
+
+struct rdma_conn_param {
+ const void *private_data;
+ uint8_t private_data_len;
+ uint8_t responder_resources;
+ uint8_t initiator_depth;
+ uint8_t flow_control;
+ uint8_t retry_count; /* ignored when accepting */
+ uint8_t rnr_retry_count;
+ /* Fields below ignored if a QP is created on the rdma_cm_id. */
+ uint8_t srq;
+ uint32_t qp_num;
+};
+
+struct rdma_ud_param {
+ const void *private_data;
+ uint8_t private_data_len;
+ struct ibv_ah_attr ah_attr;
+ uint32_t qp_num;
+ uint32_t qkey;
+};
+
+struct rdma_cm_event {
+ struct rdma_cm_id *id;
+ struct rdma_cm_id *listen_id;
+ enum rdma_cm_event_type event;
+ int status;
+ union {
+ struct rdma_conn_param conn;
+ struct rdma_ud_param ud;
+ } param;
+};
+
+#define RAI_PASSIVE 0x00000001
+#define RAI_NUMERICHOST 0x00000002
+#define RAI_NOROUTE 0x00000004
+#define RAI_FAMILY 0x00000008
+
+struct rdma_addrinfo {
+ int ai_flags;
+ int ai_family;
+ int ai_qp_type;
+ int ai_port_space;
+ socklen_t ai_src_len;
+ socklen_t ai_dst_len;
+ struct sockaddr *ai_src_addr;
+ struct sockaddr *ai_dst_addr;
+ char *ai_src_canonname;
+ char *ai_dst_canonname;
+ size_t ai_route_len;
+ void *ai_route;
+ size_t ai_connect_len;
+ void *ai_connect;
+ struct rdma_addrinfo *ai_next;
+};
+
+/**
+ * rdma_create_event_channel - Open a channel used to report communication events.
+ * Description:
+ * Asynchronous events are reported to users through event channels. Each
+ * event channel maps to a file descriptor.
+ * Notes:
+ * All created event channels must be destroyed by calling
+ * rdma_destroy_event_channel. Users should call rdma_get_cm_event to
+ * retrieve events on an event channel.
+ * See also:
+ * rdma_get_cm_event, rdma_destroy_event_channel
+ */
+struct rdma_event_channel *rdma_create_event_channel(void);
+
+/**
+ * rdma_destroy_event_channel - Close an event communication channel.
+ * @channel: The communication channel to destroy.
+ * Description:
+ * Release all resources associated with an event channel and closes the
+ * associated file descriptor.
+ * Notes:
+ * All rdma_cm_id's associated with the event channel must be destroyed,
+ * and all returned events must be acked before calling this function.
+ * See also:
+ * rdma_create_event_channel, rdma_get_cm_event, rdma_ack_cm_event
+ */
+void rdma_destroy_event_channel(struct rdma_event_channel *channel);
+
+/**
+ * rdma_create_id - Allocate a communication identifier.
+ * @channel: The communication channel that events associated with the
+ * allocated rdma_cm_id will be reported on.
+ * @id: A reference where the allocated communication identifier will be
+ * returned.
+ * @context: User specified context associated with the rdma_cm_id.
+ * @ps: RDMA port space.
+ * Description:
+ * Creates an identifier that is used to track communication information.
+ * Notes:
+ * Rdma_cm_id's are conceptually equivalent to a socket for RDMA
+ * communication. The difference is that RDMA communication requires
+ * explicitly binding to a specified RDMA device before communication
+ * can occur, and most operations are asynchronous in nature. Communication
+ * events on an rdma_cm_id are reported through the associated event
+ * channel. Users must release the rdma_cm_id by calling rdma_destroy_id.
+ * See also:
+ * rdma_create_event_channel, rdma_destroy_id, rdma_get_devices,
+ * rdma_bind_addr, rdma_resolve_addr, rdma_connect, rdma_listen,
+ */
+int rdma_create_id(struct rdma_event_channel *channel,
+ struct rdma_cm_id **id, void *context,
+ enum rdma_port_space ps);
+
+/**
+ * rdma_create_ep - Allocate a communication identifier and qp.
+ * @id: A reference where the allocated communication identifier will be
+ * returned.
+ * @res: Result from rdma_getaddrinfo, which specifies the source and
+ * destination addresses, plus optional routing and connection information.
+ * @pd: Optional protection domain. This parameter is ignored if qp_init_attr
+ * is NULL.
+ * @qp_init_attr: Optional attributes for a QP created on the rdma_cm_id.
+ * Description:
+ * Create an identifier and option QP used for communication.
+ * Notes:
+ * If qp_init_attr is provided, then a queue pair will be allocated and
+ * associated with the rdma_cm_id. If a pd is provided, the QP will be
+ * created on that PD. Otherwise, the QP will be allocated on a default
+ * PD.
+ * The rdma_cm_id will be set to use synchronous operations (connect,
+ * listen, and get_request). To convert to asynchronous operation, the
+ * rdma_cm_id should be migrated to a user allocated event channel.
+ * See also:
+ * rdma_create_id, rdma_create_qp, rdma_migrate_id, rdma_connect,
+ * rdma_listen
+ */
+int rdma_create_ep(struct rdma_cm_id **id, struct rdma_addrinfo *res,
+ struct ibv_pd *pd, struct ibv_qp_init_attr *qp_init_attr);
+
+/**
+ * rdma_destroy_ep - Deallocates a communication identifier and qp.
+ * @id: The communication identifier to destroy.
+ * Description:
+ * Destroys the specified rdma_cm_id and any associated QP created
+ * on that id.
+ * See also:
+ * rdma_create_ep
+ */
+void rdma_destroy_ep(struct rdma_cm_id *id);
+
+/**
+ * rdma_destroy_id - Release a communication identifier.
+ * @id: The communication identifier to destroy.
+ * Description:
+ * Destroys the specified rdma_cm_id and cancels any outstanding
+ * asynchronous operation.
+ * Notes:
+ * Users must free any associated QP with the rdma_cm_id before
+ * calling this routine and ack an related events.
+ * See also:
+ * rdma_create_id, rdma_destroy_qp, rdma_ack_cm_event
+ */
+int rdma_destroy_id(struct rdma_cm_id *id);
+
+/**
+ * rdma_bind_addr - Bind an RDMA identifier to a source address.
+ * @id: RDMA identifier.
+ * @addr: Local address information. Wildcard values are permitted.
+ * Description:
+ * Associates a source address with an rdma_cm_id. The address may be
+ * wildcarded. If binding to a specific local address, the rdma_cm_id
+ * will also be bound to a local RDMA device.
+ * Notes:
+ * Typically, this routine is called before calling rdma_listen to bind
+ * to a specific port number, but it may also be called on the active side
+ * of a connection before calling rdma_resolve_addr to bind to a specific
+ * address.
+ * See also:
+ * rdma_create_id, rdma_listen, rdma_resolve_addr, rdma_create_qp
+ */
+int rdma_bind_addr(struct rdma_cm_id *id, struct sockaddr *addr);
+
+/**
+ * rdma_resolve_addr - Resolve destination and optional source addresses.
+ * @id: RDMA identifier.
+ * @src_addr: Source address information. This parameter may be NULL.
+ * @dst_addr: Destination address information.
+ * @timeout_ms: Time to wait for resolution to complete.
+ * Description:
+ * Resolve destination and optional source addresses from IP addresses
+ * to an RDMA address. If successful, the specified rdma_cm_id will
+ * be bound to a local device.
+ * Notes:
+ * This call is used to map a given destination IP address to a usable RDMA
+ * address. If a source address is given, the rdma_cm_id is bound to that
+ * address, the same as if rdma_bind_addr were called. If no source
+ * address is given, and the rdma_cm_id has not yet been bound to a device,
+ * then the rdma_cm_id will be bound to a source address based on the
+ * local routing tables. After this call, the rdma_cm_id will be bound to
+ * an RDMA device. This call is typically made from the active side of a
+ * connection before calling rdma_resolve_route and rdma_connect.
+ * See also:
+ * rdma_create_id, rdma_resolve_route, rdma_connect, rdma_create_qp,
+ * rdma_get_cm_event, rdma_bind_addr
+ */
+int rdma_resolve_addr(struct rdma_cm_id *id, struct sockaddr *src_addr,
+ struct sockaddr *dst_addr, int timeout_ms);
+
+/**
+ * rdma_resolve_route - Resolve the route information needed to establish a connection.
+ * @id: RDMA identifier.
+ * @timeout_ms: Time to wait for resolution to complete.
+ * Description:
+ * Resolves an RDMA route to the destination address in order to establish
+ * a connection. The destination address must have already been resolved
+ * by calling rdma_resolve_addr.
+ * Notes:
+ * This is called on the client side of a connection after calling
+ * rdma_resolve_addr, but before calling rdma_connect.
+ * See also:
+ * rdma_resolve_addr, rdma_connect, rdma_get_cm_event
+ */
+int rdma_resolve_route(struct rdma_cm_id *id, int timeout_ms);
+
+/**
+ * rdma_create_qp - Allocate a QP.
+ * @id: RDMA identifier.
+ * @pd: Optional protection domain for the QP.
+ * @qp_init_attr: initial QP attributes.
+ * Description:
+ * Allocate a QP associated with the specified rdma_cm_id and transition it
+ * for sending and receiving.
+ * Notes:
+ * The rdma_cm_id must be bound to a local RDMA device before calling this
+ * function, and the protection domain must be for that same device.
+ * QPs allocated to an rdma_cm_id are automatically transitioned by the
+ * librdmacm through their states. After being allocated, the QP will be
+ * ready to handle posting of receives. If the QP is unconnected, it will
+ * be ready to post sends.
+ * If pd is NULL, then the QP will be allocated using a default protection
+ * domain associated with the underlying RDMA device.
+ * See also:
+ * rdma_bind_addr, rdma_resolve_addr, rdma_destroy_qp, ibv_create_qp,
+ * ibv_modify_qp
+ */
+int rdma_create_qp(struct rdma_cm_id *id, struct ibv_pd *pd,
+ struct ibv_qp_init_attr *qp_init_attr);
+int rdma_create_qp_ex(struct rdma_cm_id *id,
+ struct ibv_qp_init_attr_ex *qp_init_attr);
+
+/**
+ * rdma_destroy_qp - Deallocate a QP.
+ * @id: RDMA identifier.
+ * Description:
+ * Destroy a QP allocated on the rdma_cm_id.
+ * Notes:
+ * Users must destroy any QP associated with an rdma_cm_id before
+ * destroying the ID.
+ * See also:
+ * rdma_create_qp, rdma_destroy_id, ibv_destroy_qp
+ */
+void rdma_destroy_qp(struct rdma_cm_id *id);
+
+/**
+ * rdma_connect - Initiate an active connection request.
+ * @id: RDMA identifier.
+ * @conn_param: optional connection parameters.
+ * Description:
+ * For a connected rdma_cm_id, this call initiates a connection request
+ * to a remote destination. For an unconnected rdma_cm_id, it initiates
+ * a lookup of the remote QP providing the datagram service.
+ * Notes:
+ * Users must have resolved a route to the destination address
+ * by having called rdma_resolve_route before calling this routine.
+ * A user may override the default connection parameters and exchange
+ * private data as part of the connection by using the conn_param parameter.
+ * See also:
+ * rdma_resolve_route, rdma_disconnect, rdma_listen, rdma_get_cm_event
+ */
+int rdma_connect(struct rdma_cm_id *id, struct rdma_conn_param *conn_param);
+
+/**
+ * rdma_listen - Listen for incoming connection requests.
+ * @id: RDMA identifier.
+ * @backlog: backlog of incoming connection requests.
+ * Description:
+ * Initiates a listen for incoming connection requests or datagram service
+ * lookup. The listen will be restricted to the locally bound source
+ * address.
+ * Notes:
+ * Users must have bound the rdma_cm_id to a local address by calling
+ * rdma_bind_addr before calling this routine. If the rdma_cm_id is
+ * bound to a specific IP address, the listen will be restricted to that
+ * address and the associated RDMA device. If the rdma_cm_id is bound
+ * to an RDMA port number only, the listen will occur across all RDMA
+ * devices.
+ * See also:
+ * rdma_bind_addr, rdma_connect, rdma_accept, rdma_reject, rdma_get_cm_event
+ */
+int rdma_listen(struct rdma_cm_id *id, int backlog);
+
+/**
+ * rdma_get_request
+ */
+int rdma_get_request(struct rdma_cm_id *listen, struct rdma_cm_id **id);
+
+/**
+ * rdma_accept - Called to accept a connection request.
+ * @id: Connection identifier associated with the request.
+ * @conn_param: Optional information needed to establish the connection.
+ * Description:
+ * Called from the listening side to accept a connection or datagram
+ * service lookup request.
+ * Notes:
+ * Unlike the socket accept routine, rdma_accept is not called on a
+ * listening rdma_cm_id. Instead, after calling rdma_listen, the user
+ * waits for a connection request event to occur. Connection request
+ * events give the user a newly created rdma_cm_id, similar to a new
+ * socket, but the rdma_cm_id is bound to a specific RDMA device.
+ * rdma_accept is called on the new rdma_cm_id.
+ * A user may override the default connection parameters and exchange
+ * private data as part of the connection by using the conn_param parameter.
+ * See also:
+ * rdma_listen, rdma_reject, rdma_get_cm_event
+ */
+int rdma_accept(struct rdma_cm_id *id, struct rdma_conn_param *conn_param);
+
+/**
+ * rdma_reject - Called to reject a connection request.
+ * @id: Connection identifier associated with the request.
+ * @private_data: Optional private data to send with the reject message.
+ * @private_data_len: Size of the private_data to send, in bytes.
+ * Description:
+ * Called from the listening side to reject a connection or datagram
+ * service lookup request.
+ * Notes:
+ * After receiving a connection request event, a user may call rdma_reject
+ * to reject the request. If the underlying RDMA transport supports
+ * private data in the reject message, the specified data will be passed to
+ * the remote side.
+ * See also:
+ * rdma_listen, rdma_accept, rdma_get_cm_event
+ */
+int rdma_reject(struct rdma_cm_id *id, const void *private_data,
+ uint8_t private_data_len);
+
+/**
+ * rdma_notify - Notifies the librdmacm of an asynchronous event.
+ * @id: RDMA identifier.
+ * @event: Asynchronous event.
+ * Description:
+ * Used to notify the librdmacm of asynchronous events that have occurred
+ * on a QP associated with the rdma_cm_id.
+ * Notes:
+ * Asynchronous events that occur on a QP are reported through the user's
+ * device event handler. This routine is used to notify the librdmacm of
+ * communication events. In most cases, use of this routine is not
+ * necessary, however if connection establishment is done out of band
+ * (such as done through Infiniband), it's possible to receive data on a
+ * QP that is not yet considered connected. This routine forces the
+ * connection into an established state in this case in order to handle
+ * the rare situation where the connection never forms on its own.
+ * Events that should be reported to the CM are: IB_EVENT_COMM_EST.
+ * See also:
+ * rdma_connect, rdma_accept, rdma_listen
+ */
+int rdma_notify(struct rdma_cm_id *id, enum ibv_event_type event);
+
+/**
+ * rdma_disconnect - This function disconnects a connection.
+ * @id: RDMA identifier.
+ * Description:
+ * Disconnects a connection and transitions any associated QP to the
+ * error state.
+ * See also:
+ * rdma_connect, rdma_listen, rdma_accept
+ */
+int rdma_disconnect(struct rdma_cm_id *id);
+
+/**
+ * rdma_join_multicast - Joins a multicast group.
+ * @id: Communication identifier associated with the request.
+ * @addr: Multicast address identifying the group to join.
+ * @context: User-defined context associated with the join request.
+ * Description:
+ * Joins a multicast group and attaches an associated QP to the group.
+ * Notes:
+ * Before joining a multicast group, the rdma_cm_id must be bound to
+ * an RDMA device by calling rdma_bind_addr or rdma_resolve_addr. Use of
+ * rdma_resolve_addr requires the local routing tables to resolve the
+ * multicast address to an RDMA device. The user must call
+ * rdma_leave_multicast to leave the multicast group and release any
+ * multicast resources. The context is returned to the user through
+ * the private_data field in the rdma_cm_event.
+ * See also:
+ * rdma_leave_multicast, rdma_bind_addr, rdma_resolve_addr, rdma_create_qp
+ */
+int rdma_join_multicast(struct rdma_cm_id *id, struct sockaddr *addr,
+ void *context);
+
+/**
+ * rdma_leave_multicast - Leaves a multicast group.
+ * @id: Communication identifier associated with the request.
+ * @addr: Multicast address identifying the group to leave.
+ * Description:
+ * Leaves a multicast group and detaches an associated QP from the group.
+ * Notes:
+ * Calling this function before a group has been fully joined results in
+ * canceling the join operation. Users should be aware that messages
+ * received from the multicast group may stilled be queued for
+ * completion processing immediately after leaving a multicast group.
+ * Destroying an rdma_cm_id will automatically leave all multicast groups.
+ * See also:
+ * rdma_join_multicast, rdma_destroy_qp
+ */
+int rdma_leave_multicast(struct rdma_cm_id *id, struct sockaddr *addr);
+
+/**
+ * rdma_get_cm_event - Retrieves the next pending communication event.
+ * @channel: Event channel to check for events.
+ * @event: Allocated information about the next communication event.
+ * Description:
+ * Retrieves a communication event. If no events are pending, by default,
+ * the call will block until an event is received.
+ * Notes:
+ * The default synchronous behavior of this routine can be changed by
+ * modifying the file descriptor associated with the given channel. All
+ * events that are reported must be acknowledged by calling rdma_ack_cm_event.
+ * Destruction of an rdma_cm_id will block until related events have been
+ * acknowledged.
+ * See also:
+ * rdma_ack_cm_event, rdma_create_event_channel, rdma_event_str
+ */
+int rdma_get_cm_event(struct rdma_event_channel *channel,
+ struct rdma_cm_event **event);
+
+/**
+ * rdma_ack_cm_event - Free a communication event.
+ * @event: Event to be released.
+ * Description:
+ * All events which are allocated by rdma_get_cm_event must be released,
+ * there should be a one-to-one correspondence between successful gets
+ * and acks.
+ * See also:
+ * rdma_get_cm_event, rdma_destroy_id
+ */
+int rdma_ack_cm_event(struct rdma_cm_event *event);
+
+__be16 rdma_get_src_port(struct rdma_cm_id *id);
+__be16 rdma_get_dst_port(struct rdma_cm_id *id);
+
+static inline struct sockaddr *rdma_get_local_addr(struct rdma_cm_id *id)
+{
+ return &id->route.addr.src_addr;
+}
+
+static inline struct sockaddr *rdma_get_peer_addr(struct rdma_cm_id *id)
+{
+ return &id->route.addr.dst_addr;
+}
+
+/**
+ * rdma_get_devices - Get list of RDMA devices currently available.
+ * @num_devices: If non-NULL, set to the number of devices returned.
+ * Description:
+ * Return a NULL-terminated array of opened RDMA devices. Callers can use
+ * this routine to allocate resources on specific RDMA devices that will be
+ * shared across multiple rdma_cm_id's.
+ * Notes:
+ * The returned array must be released by calling rdma_free_devices. Devices
+ * remain opened while the librdmacm is loaded.
+ * See also:
+ * rdma_free_devices
+ */
+struct ibv_context **rdma_get_devices(int *num_devices);
+
+/**
+ * rdma_free_devices - Frees the list of devices returned by rdma_get_devices.
+ * @list: List of devices returned from rdma_get_devices.
+ * Description:
+ * Frees the device array returned by rdma_get_devices.
+ * See also:
+ * rdma_get_devices
+ */
+void rdma_free_devices(struct ibv_context **list);
+
+/**
+ * rdma_event_str - Returns a string representation of an rdma cm event.
+ * @event: Asynchronous event.
+ * Description:
+ * Returns a string representation of an asynchronous event.
+ * See also:
+ * rdma_get_cm_event
+ */
+const char *rdma_event_str(enum rdma_cm_event_type event);
+
+/* Option levels */
+enum {
+ RDMA_OPTION_ID = 0,
+ RDMA_OPTION_IB = 1
+};
+
+/* Option details */
+enum {
+ RDMA_OPTION_ID_TOS = 0, /* uint8_t: RFC 2474 */
+ RDMA_OPTION_ID_REUSEADDR = 1, /* int: ~SO_REUSEADDR */
+ RDMA_OPTION_ID_AFONLY = 2, /* int: ~IPV6_V6ONLY */
+ RDMA_OPTION_IB_PATH = 1 /* struct ibv_path_data[] */
+};
+
+/**
+ * rdma_set_option - Set options for an rdma_cm_id.
+ * @id: Communication identifier to set option for.
+ * @level: Protocol level of the option to set.
+ * @optname: Name of the option to set.
+ * @optval: Reference to the option data.
+ * @optlen: The size of the %optval buffer.
+ */
+int rdma_set_option(struct rdma_cm_id *id, int level, int optname,
+ void *optval, size_t optlen);
+
+/**
+ * rdma_migrate_id - Move an rdma_cm_id to a new event channel.
+ * @id: Communication identifier to migrate.
+ * @channel: New event channel for rdma_cm_id events.
+ */
+int rdma_migrate_id(struct rdma_cm_id *id, struct rdma_event_channel *channel);
+
+/**
+ * rdma_getaddrinfo - RDMA address and route resolution service.
+ */
+int rdma_getaddrinfo(const char *node, const char *service,
+ const struct rdma_addrinfo *hints,
+ struct rdma_addrinfo **res);
+
+void rdma_freeaddrinfo(struct rdma_addrinfo *res);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* RDMA_CMA_H */
diff --git a/contrib/ofed/librdmacm/rdma_cma_abi.h b/contrib/ofed/librdmacm/rdma_cma_abi.h
new file mode 100644
index 0000000..29d6f0d
--- /dev/null
+++ b/contrib/ofed/librdmacm/rdma_cma_abi.h
@@ -0,0 +1,351 @@
+/*
+ * Copyright (c) 2005-2011 Intel Corporation. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#ifndef RDMA_CMA_ABI_H
+#define RDMA_CMA_ABI_H
+
+#include <infiniband/kern-abi.h>
+#include <rdma/ib_user_sa.h>
+#include <infiniband/sa.h>
+#include <netinet/in.h>
+
+/*
+ * This file must be kept in sync with the kernel's version of rdma_user_cm.h
+ */
+
+#define RDMA_USER_CM_MIN_ABI_VERSION 3
+#define RDMA_USER_CM_MAX_ABI_VERSION 4
+
+#define RDMA_MAX_PRIVATE_DATA 256
+
+enum {
+ UCMA_CMD_CREATE_ID,
+ UCMA_CMD_DESTROY_ID,
+ UCMA_CMD_BIND_IP,
+ UCMA_CMD_RESOLVE_IP,
+ UCMA_CMD_RESOLVE_ROUTE,
+ UCMA_CMD_QUERY_ROUTE,
+ UCMA_CMD_CONNECT,
+ UCMA_CMD_LISTEN,
+ UCMA_CMD_ACCEPT,
+ UCMA_CMD_REJECT,
+ UCMA_CMD_DISCONNECT,
+ UCMA_CMD_INIT_QP_ATTR,
+ UCMA_CMD_GET_EVENT,
+ UCMA_CMD_GET_OPTION,
+ UCMA_CMD_SET_OPTION,
+ UCMA_CMD_NOTIFY,
+ UCMA_CMD_JOIN_IP_MCAST,
+ UCMA_CMD_LEAVE_MCAST,
+ UCMA_CMD_MIGRATE_ID,
+ UCMA_CMD_QUERY,
+ UCMA_CMD_BIND,
+ UCMA_CMD_RESOLVE_ADDR,
+ UCMA_CMD_JOIN_MCAST
+};
+
+struct ucma_abi_cmd_hdr {
+ __u32 cmd;
+ __u16 in;
+ __u16 out;
+};
+
+struct ucma_abi_create_id {
+ __u32 cmd;
+ __u16 in;
+ __u16 out;
+ __u64 uid;
+ __u64 response;
+ __u16 ps;
+ __u8 qp_type;
+ __u8 reserved[5];
+};
+
+struct ucma_abi_create_id_resp {
+ __u32 id;
+};
+
+struct ucma_abi_destroy_id {
+ __u32 cmd;
+ __u16 in;
+ __u16 out;
+ __u64 response;
+ __u32 id;
+ __u32 reserved;
+};
+
+struct ucma_abi_destroy_id_resp {
+ __u32 events_reported;
+};
+
+struct ucma_abi_bind_ip {
+ __u32 cmd;
+ __u16 in;
+ __u16 out;
+ __u64 response;
+ struct sockaddr_in6 addr;
+ __u32 id;
+};
+
+struct ucma_abi_bind {
+ __u32 cmd;
+ __u16 in;
+ __u16 out;
+ __u32 id;
+ __u16 addr_size;
+ __u16 reserved;
+ struct sockaddr_storage addr;
+};
+
+struct ucma_abi_resolve_ip {
+ __u32 cmd;
+ __u16 in;
+ __u16 out;
+ struct sockaddr_in6 src_addr;
+ struct sockaddr_in6 dst_addr;
+ __u32 id;
+ __u32 timeout_ms;
+};
+
+struct ucma_abi_resolve_addr {
+ __u32 cmd;
+ __u16 in;
+ __u16 out;
+ __u32 id;
+ __u32 timeout_ms;
+ __u16 src_size;
+ __u16 dst_size;
+ __u32 reserved;
+ struct sockaddr_storage src_addr;
+ struct sockaddr_storage dst_addr;
+};
+
+struct ucma_abi_resolve_route {
+ __u32 cmd;
+ __u16 in;
+ __u16 out;
+ __u32 id;
+ __u32 timeout_ms;
+};
+
+enum {
+ UCMA_QUERY_ADDR,
+ UCMA_QUERY_PATH,
+ UCMA_QUERY_GID
+};
+
+struct ucma_abi_query {
+ __u32 cmd;
+ __u16 in;
+ __u16 out;
+ __u64 response;
+ __u32 id;
+ __u32 option;
+};
+
+struct ucma_abi_query_route_resp {
+ __be64 node_guid;
+ struct ib_user_path_rec ib_route[2];
+ struct sockaddr_in6 src_addr;
+ struct sockaddr_in6 dst_addr;
+ __u32 num_paths;
+ __u8 port_num;
+ __u8 reserved[3];
+};
+
+struct ucma_abi_query_addr_resp {
+ __be64 node_guid;
+ __u8 port_num;
+ __u8 reserved;
+ __be16 pkey;
+ __u16 src_size;
+ __u16 dst_size;
+ struct sockaddr_storage src_addr;
+ struct sockaddr_storage dst_addr;
+};
+
+struct ucma_abi_query_path_resp {
+ __u32 num_paths;
+ __u32 reserved;
+ struct ibv_path_data path_data[0];
+};
+
+struct ucma_abi_conn_param {
+ __u32 qp_num;
+ __u32 reserved;
+ __u8 private_data[RDMA_MAX_PRIVATE_DATA];
+ __u8 private_data_len;
+ __u8 srq;
+ __u8 responder_resources;
+ __u8 initiator_depth;
+ __u8 flow_control;
+ __u8 retry_count;
+ __u8 rnr_retry_count;
+ __u8 valid;
+};
+
+struct ucma_abi_ud_param {
+ __u32 qp_num;
+ __u32 qkey;
+ struct ibv_kern_ah_attr ah_attr;
+ __u8 private_data[RDMA_MAX_PRIVATE_DATA];
+ __u8 private_data_len;
+ __u8 reserved[7];
+ __u8 reserved2[4]; /* Round to 8-byte boundary to support 32/64 */
+};
+
+struct ucma_abi_connect {
+ __u32 cmd;
+ __u16 in;
+ __u16 out;
+ struct ucma_abi_conn_param conn_param;
+ __u32 id;
+ __u32 reserved;
+};
+
+struct ucma_abi_listen {
+ __u32 cmd;
+ __u16 in;
+ __u16 out;
+ __u32 id;
+ __u32 backlog;
+};
+
+struct ucma_abi_accept {
+ __u32 cmd;
+ __u16 in;
+ __u16 out;
+ __u64 uid;
+ struct ucma_abi_conn_param conn_param;
+ __u32 id;
+ __u32 reserved;
+};
+
+struct ucma_abi_reject {
+ __u32 cmd;
+ __u16 in;
+ __u16 out;
+ __u32 id;
+ __u8 private_data_len;
+ __u8 reserved[3];
+ __u8 private_data[RDMA_MAX_PRIVATE_DATA];
+};
+
+struct ucma_abi_disconnect {
+ __u32 cmd;
+ __u16 in;
+ __u16 out;
+ __u32 id;
+};
+
+struct ucma_abi_init_qp_attr {
+ __u32 cmd;
+ __u16 in;
+ __u16 out;
+ __u64 response;
+ __u32 id;
+ __u32 qp_state;
+};
+
+struct ucma_abi_notify {
+ __u32 cmd;
+ __u16 in;
+ __u16 out;
+ __u32 id;
+ __u32 event;
+};
+
+struct ucma_abi_join_ip_mcast {
+ __u32 cmd;
+ __u16 in;
+ __u16 out;
+ __u64 response; /* ucma_abi_create_id_resp */
+ __u64 uid;
+ struct sockaddr_in6 addr;
+ __u32 id;
+};
+
+struct ucma_abi_join_mcast {
+ __u32 cmd;
+ __u16 in;
+ __u16 out;
+ __u64 response; /* rdma_ucma_create_id_resp */
+ __u64 uid;
+ __u32 id;
+ __u16 addr_size;
+ __u16 reserved;
+ struct sockaddr_storage addr;
+};
+
+struct ucma_abi_get_event {
+ __u32 cmd;
+ __u16 in;
+ __u16 out;
+ __u64 response;
+};
+
+struct ucma_abi_event_resp {
+ __u64 uid;
+ __u32 id;
+ __u32 event;
+ __u32 status;
+ union {
+ struct ucma_abi_conn_param conn;
+ struct ucma_abi_ud_param ud;
+ } param;
+};
+
+struct ucma_abi_set_option {
+ __u32 cmd;
+ __u16 in;
+ __u16 out;
+ __u64 optval;
+ __u32 id;
+ __u32 level;
+ __u32 optname;
+ __u32 optlen;
+};
+
+struct ucma_abi_migrate_id {
+ __u32 cmd;
+ __u16 in;
+ __u16 out;
+ __u64 response;
+ __u32 id;
+ __u32 fd;
+};
+
+struct ucma_abi_migrate_resp {
+ __u32 events_reported;
+};
+
+#endif /* RDMA_CMA_ABI_H */
diff --git a/contrib/ofed/librdmacm/rdma_verbs.h b/contrib/ofed/librdmacm/rdma_verbs.h
new file mode 100644
index 0000000..10049c3
--- /dev/null
+++ b/contrib/ofed/librdmacm/rdma_verbs.h
@@ -0,0 +1,317 @@
+/*
+ * Copyright (c) 2010-2014 Intel Corporation. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#if !defined(RDMA_VERBS_H)
+#define RDMA_VERBS_H
+
+#include <assert.h>
+#include <infiniband/verbs.h>
+#include <rdma/rdma_cma.h>
+#include <errno.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+static inline int rdma_seterrno(int ret)
+{
+ if (ret) {
+ errno = ret;
+ ret = -1;
+ }
+ return ret;
+}
+
+/*
+ * Shared receive queues.
+ */
+int rdma_create_srq(struct rdma_cm_id *id, struct ibv_pd *pd,
+ struct ibv_srq_init_attr *attr);
+int rdma_create_srq_ex(struct rdma_cm_id *id, struct ibv_srq_init_attr_ex *attr);
+
+void rdma_destroy_srq(struct rdma_cm_id *id);
+
+
+/*
+ * Memory registration helpers.
+ */
+static inline struct ibv_mr *
+rdma_reg_msgs(struct rdma_cm_id *id, void *addr, size_t length)
+{
+ return ibv_reg_mr(id->pd, addr, length, IBV_ACCESS_LOCAL_WRITE);
+}
+
+static inline struct ibv_mr *
+rdma_reg_read(struct rdma_cm_id *id, void *addr, size_t length)
+{
+ return ibv_reg_mr(id->pd, addr, length, IBV_ACCESS_LOCAL_WRITE |
+ IBV_ACCESS_REMOTE_READ);
+}
+
+static inline struct ibv_mr *
+rdma_reg_write(struct rdma_cm_id *id, void *addr, size_t length)
+{
+ return ibv_reg_mr(id->pd, addr, length, IBV_ACCESS_LOCAL_WRITE |
+ IBV_ACCESS_REMOTE_WRITE);
+}
+
+static inline int
+rdma_dereg_mr(struct ibv_mr *mr)
+{
+ return rdma_seterrno(ibv_dereg_mr(mr));
+}
+
+
+/*
+ * Vectored send, receive, and RDMA operations.
+ * Support multiple scatter-gather entries.
+ */
+static inline int
+rdma_post_recvv(struct rdma_cm_id *id, void *context, struct ibv_sge *sgl,
+ int nsge)
+{
+ struct ibv_recv_wr wr, *bad;
+
+ wr.wr_id = (uintptr_t) context;
+ wr.next = NULL;
+ wr.sg_list = sgl;
+ wr.num_sge = nsge;
+
+ if (id->srq)
+ return rdma_seterrno(ibv_post_srq_recv(id->srq, &wr, &bad));
+ else
+ return rdma_seterrno(ibv_post_recv(id->qp, &wr, &bad));
+}
+
+static inline int
+rdma_post_sendv(struct rdma_cm_id *id, void *context, struct ibv_sge *sgl,
+ int nsge, int flags)
+{
+ struct ibv_send_wr wr, *bad;
+
+ wr.wr_id = (uintptr_t) context;
+ wr.next = NULL;
+ wr.sg_list = sgl;
+ wr.num_sge = nsge;
+ wr.opcode = IBV_WR_SEND;
+ wr.send_flags = flags;
+
+ return rdma_seterrno(ibv_post_send(id->qp, &wr, &bad));
+}
+
+static inline int
+rdma_post_readv(struct rdma_cm_id *id, void *context, struct ibv_sge *sgl,
+ int nsge, int flags, uint64_t remote_addr, uint32_t rkey)
+{
+ struct ibv_send_wr wr, *bad;
+
+ wr.wr_id = (uintptr_t) context;
+ wr.next = NULL;
+ wr.sg_list = sgl;
+ wr.num_sge = nsge;
+ wr.opcode = IBV_WR_RDMA_READ;
+ wr.send_flags = flags;
+ wr.wr.rdma.remote_addr = remote_addr;
+ wr.wr.rdma.rkey = rkey;
+
+ return rdma_seterrno(ibv_post_send(id->qp, &wr, &bad));
+}
+
+static inline int
+rdma_post_writev(struct rdma_cm_id *id, void *context, struct ibv_sge *sgl,
+ int nsge, int flags, uint64_t remote_addr, uint32_t rkey)
+{
+ struct ibv_send_wr wr, *bad;
+
+ wr.wr_id = (uintptr_t) context;
+ wr.next = NULL;
+ wr.sg_list = sgl;
+ wr.num_sge = nsge;
+ wr.opcode = IBV_WR_RDMA_WRITE;
+ wr.send_flags = flags;
+ wr.wr.rdma.remote_addr = remote_addr;
+ wr.wr.rdma.rkey = rkey;
+
+ return rdma_seterrno(ibv_post_send(id->qp, &wr, &bad));
+}
+
+/*
+ * Simple send, receive, and RDMA calls.
+ */
+static inline int
+rdma_post_recv(struct rdma_cm_id *id, void *context, void *addr,
+ size_t length, struct ibv_mr *mr)
+{
+ struct ibv_sge sge;
+
+ assert((addr >= mr->addr) &&
+ (((uint8_t *) addr + length) <= ((uint8_t *) mr->addr + mr->length)));
+ sge.addr = (uint64_t) (uintptr_t) addr;
+ sge.length = (uint32_t) length;
+ sge.lkey = mr->lkey;
+
+ return rdma_post_recvv(id, context, &sge, 1);
+}
+
+static inline int
+rdma_post_send(struct rdma_cm_id *id, void *context, void *addr,
+ size_t length, struct ibv_mr *mr, int flags)
+{
+ struct ibv_sge sge;
+
+ sge.addr = (uint64_t) (uintptr_t) addr;
+ sge.length = (uint32_t) length;
+ sge.lkey = mr ? mr->lkey : 0;
+
+ return rdma_post_sendv(id, context, &sge, 1, flags);
+}
+
+static inline int
+rdma_post_read(struct rdma_cm_id *id, void *context, void *addr,
+ size_t length, struct ibv_mr *mr, int flags,
+ uint64_t remote_addr, uint32_t rkey)
+{
+ struct ibv_sge sge;
+
+ sge.addr = (uint64_t) (uintptr_t) addr;
+ sge.length = (uint32_t) length;
+ sge.lkey = mr->lkey;
+
+ return rdma_post_readv(id, context, &sge, 1, flags, remote_addr, rkey);
+}
+
+static inline int
+rdma_post_write(struct rdma_cm_id *id, void *context, void *addr,
+ size_t length, struct ibv_mr *mr, int flags,
+ uint64_t remote_addr, uint32_t rkey)
+{
+ struct ibv_sge sge;
+
+ sge.addr = (uint64_t) (uintptr_t) addr;
+ sge.length = (uint32_t) length;
+ sge.lkey = mr ? mr->lkey : 0;
+
+ return rdma_post_writev(id, context, &sge, 1, flags, remote_addr, rkey);
+}
+
+static inline int
+rdma_post_ud_send(struct rdma_cm_id *id, void *context, void *addr,
+ size_t length, struct ibv_mr *mr, int flags,
+ struct ibv_ah *ah, uint32_t remote_qpn)
+{
+ struct ibv_send_wr wr, *bad;
+ struct ibv_sge sge;
+
+ sge.addr = (uint64_t) (uintptr_t) addr;
+ sge.length = (uint32_t) length;
+ sge.lkey = mr ? mr->lkey : 0;
+
+ wr.wr_id = (uintptr_t) context;
+ wr.next = NULL;
+ wr.sg_list = &sge;
+ wr.num_sge = 1;
+ wr.opcode = IBV_WR_SEND;
+ wr.send_flags = flags;
+ wr.wr.ud.ah = ah;
+ wr.wr.ud.remote_qpn = remote_qpn;
+ wr.wr.ud.remote_qkey = RDMA_UDP_QKEY;
+
+ return rdma_seterrno(ibv_post_send(id->qp, &wr, &bad));
+}
+
+static inline int
+rdma_get_send_comp(struct rdma_cm_id *id, struct ibv_wc *wc)
+{
+ struct ibv_cq *cq;
+ void *context;
+ int ret;
+
+ do {
+ ret = ibv_poll_cq(id->send_cq, 1, wc);
+ if (ret)
+ break;
+
+ ret = ibv_req_notify_cq(id->send_cq, 0);
+ if (ret)
+ return rdma_seterrno(ret);
+
+ ret = ibv_poll_cq(id->send_cq, 1, wc);
+ if (ret)
+ break;
+
+ ret = ibv_get_cq_event(id->send_cq_channel, &cq, &context);
+ if (ret)
+ return ret;
+
+ assert(cq == id->send_cq && context == id);
+ ibv_ack_cq_events(id->send_cq, 1);
+ } while (1);
+
+ return (ret < 0) ? rdma_seterrno(ret) : ret;
+}
+
+static inline int
+rdma_get_recv_comp(struct rdma_cm_id *id, struct ibv_wc *wc)
+{
+ struct ibv_cq *cq;
+ void *context;
+ int ret;
+
+ do {
+ ret = ibv_poll_cq(id->recv_cq, 1, wc);
+ if (ret)
+ break;
+
+ ret = ibv_req_notify_cq(id->recv_cq, 0);
+ if (ret)
+ return rdma_seterrno(ret);
+
+ ret = ibv_poll_cq(id->recv_cq, 1, wc);
+ if (ret)
+ break;
+
+ ret = ibv_get_cq_event(id->recv_cq_channel, &cq, &context);
+ if (ret)
+ return ret;
+
+ assert(cq == id->recv_cq && context == id);
+ ibv_ack_cq_events(id->recv_cq, 1);
+ } while (1);
+
+ return (ret < 0) ? rdma_seterrno(ret) : ret;
+}
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* RDMA_CMA_H */
diff --git a/contrib/ofed/librdmacm/rsocket.c b/contrib/ofed/librdmacm/rsocket.c
new file mode 100644
index 0000000..520d8ca
--- /dev/null
+++ b/contrib/ofed/librdmacm/rsocket.c
@@ -0,0 +1,4343 @@
+/*
+ * Copyright (c) 2008-2014 Intel Corporation. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+#define _GNU_SOURCE
+#include <config.h>
+
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <sys/time.h>
+#include <infiniband/endian.h>
+#include <stdarg.h>
+#include <netdb.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <stdio.h>
+#include <stddef.h>
+#include <string.h>
+#include <netinet/tcp.h>
+#include <sys/epoll.h>
+#include <search.h>
+#include <byteswap.h>
+#include <util/compiler.h>
+
+#include <rdma/rdma_cma.h>
+#include <rdma/rdma_verbs.h>
+#include <rdma/rsocket.h>
+#include "cma.h"
+#include "indexer.h"
+
+#define RS_OLAP_START_SIZE 2048
+#define RS_MAX_TRANSFER 65536
+#define RS_SNDLOWAT 2048
+#define RS_QP_MIN_SIZE 16
+#define RS_QP_MAX_SIZE 0xFFFE
+#define RS_QP_CTRL_SIZE 4 /* must be power of 2 */
+#define RS_CONN_RETRIES 6
+#define RS_SGL_SIZE 2
+static struct index_map idm;
+static pthread_mutex_t mut = PTHREAD_MUTEX_INITIALIZER;
+
+struct rsocket;
+
+enum {
+ RS_SVC_NOOP,
+ RS_SVC_ADD_DGRAM,
+ RS_SVC_REM_DGRAM,
+ RS_SVC_ADD_KEEPALIVE,
+ RS_SVC_REM_KEEPALIVE,
+ RS_SVC_MOD_KEEPALIVE
+};
+
+struct rs_svc_msg {
+ uint32_t cmd;
+ uint32_t status;
+ struct rsocket *rs;
+};
+
+struct rs_svc {
+ pthread_t id;
+ int sock[2];
+ int cnt;
+ int size;
+ int context_size;
+ void *(*run)(void *svc);
+ struct rsocket **rss;
+ void *contexts;
+};
+
+static struct pollfd *udp_svc_fds;
+static void *udp_svc_run(void *arg);
+static struct rs_svc udp_svc = {
+ .context_size = sizeof(*udp_svc_fds),
+ .run = udp_svc_run
+};
+static uint32_t *tcp_svc_timeouts;
+static void *tcp_svc_run(void *arg);
+static struct rs_svc tcp_svc = {
+ .context_size = sizeof(*tcp_svc_timeouts),
+ .run = tcp_svc_run
+};
+
+static uint16_t def_iomap_size = 0;
+static uint16_t def_inline = 64;
+static uint16_t def_sqsize = 384;
+static uint16_t def_rqsize = 384;
+static uint32_t def_mem = (1 << 17);
+static uint32_t def_wmem = (1 << 17);
+static uint32_t polling_time = 10;
+
+/*
+ * Immediate data format is determined by the upper bits
+ * bit 31: message type, 0 - data, 1 - control
+ * bit 30: buffers updated, 0 - target, 1 - direct-receive
+ * bit 29: more data, 0 - end of transfer, 1 - more data available
+ *
+ * for data transfers:
+ * bits [28:0]: bytes transferred
+ * for control messages:
+ * SGL, CTRL
+ * bits [28-0]: receive credits granted
+ * IOMAP_SGL
+ * bits [28-16]: reserved, bits [15-0]: index
+ */
+
+enum {
+ RS_OP_DATA,
+ RS_OP_RSVD_DATA_MORE,
+ RS_OP_WRITE, /* opcode is not transmitted over the network */
+ RS_OP_RSVD_DRA_MORE,
+ RS_OP_SGL,
+ RS_OP_RSVD,
+ RS_OP_IOMAP_SGL,
+ RS_OP_CTRL
+};
+#define rs_msg_set(op, data) ((op << 29) | (uint32_t) (data))
+#define rs_msg_op(imm_data) (imm_data >> 29)
+#define rs_msg_data(imm_data) (imm_data & 0x1FFFFFFF)
+#define RS_MSG_SIZE sizeof(uint32_t)
+
+#define RS_WR_ID_FLAG_RECV (((uint64_t) 1) << 63)
+#define RS_WR_ID_FLAG_MSG_SEND (((uint64_t) 1) << 62) /* See RS_OPT_MSG_SEND */
+#define rs_send_wr_id(data) ((uint64_t) data)
+#define rs_recv_wr_id(data) (RS_WR_ID_FLAG_RECV | (uint64_t) data)
+#define rs_wr_is_recv(wr_id) (wr_id & RS_WR_ID_FLAG_RECV)
+#define rs_wr_is_msg_send(wr_id) (wr_id & RS_WR_ID_FLAG_MSG_SEND)
+#define rs_wr_data(wr_id) ((uint32_t) wr_id)
+
+enum {
+ RS_CTRL_DISCONNECT,
+ RS_CTRL_KEEPALIVE,
+ RS_CTRL_SHUTDOWN
+};
+
+struct rs_msg {
+ uint32_t op;
+ uint32_t data;
+};
+
+struct ds_qp;
+
+struct ds_rmsg {
+ struct ds_qp *qp;
+ uint32_t offset;
+ uint32_t length;
+};
+
+struct ds_smsg {
+ struct ds_smsg *next;
+};
+
+struct rs_sge {
+ uint64_t addr;
+ uint32_t key;
+ uint32_t length;
+};
+
+struct rs_iomap {
+ uint64_t offset;
+ struct rs_sge sge;
+};
+
+struct rs_iomap_mr {
+ uint64_t offset;
+ struct ibv_mr *mr;
+ dlist_entry entry;
+ _Atomic(int) refcnt;
+ int index; /* -1 if mapping is local and not in iomap_list */
+};
+
+#define RS_MAX_CTRL_MSG (sizeof(struct rs_sge))
+#define rs_host_is_net() (__BYTE_ORDER == __BIG_ENDIAN)
+#define RS_CONN_FLAG_NET (1 << 0)
+#define RS_CONN_FLAG_IOMAP (1 << 1)
+
+struct rs_conn_data {
+ uint8_t version;
+ uint8_t flags;
+ __be16 credits;
+ uint8_t reserved[3];
+ uint8_t target_iomap_size;
+ struct rs_sge target_sgl;
+ struct rs_sge data_buf;
+};
+
+struct rs_conn_private_data {
+ union {
+ struct rs_conn_data conn_data;
+ struct {
+ struct ib_connect_hdr ib_hdr;
+ struct rs_conn_data conn_data;
+ } af_ib;
+ };
+};
+
+/*
+ * rsocket states are ordered as passive, connecting, connected, disconnected.
+ */
+enum rs_state {
+ rs_init,
+ rs_bound = 0x0001,
+ rs_listening = 0x0002,
+ rs_opening = 0x0004,
+ rs_resolving_addr = rs_opening | 0x0010,
+ rs_resolving_route = rs_opening | 0x0020,
+ rs_connecting = rs_opening | 0x0040,
+ rs_accepting = rs_opening | 0x0080,
+ rs_connected = 0x0100,
+ rs_writable = 0x0200,
+ rs_readable = 0x0400,
+ rs_connect_rdwr = rs_connected | rs_readable | rs_writable,
+ rs_connect_error = 0x0800,
+ rs_disconnected = 0x1000,
+ rs_error = 0x2000,
+};
+
+#define RS_OPT_SWAP_SGL (1 << 0)
+/*
+ * iWarp does not support RDMA write with immediate data. For iWarp, we
+ * transfer rsocket messages as inline sends.
+ */
+#define RS_OPT_MSG_SEND (1 << 1)
+#define RS_OPT_SVC_ACTIVE (1 << 2)
+
+union socket_addr {
+ struct sockaddr sa;
+ struct sockaddr_in sin;
+ struct sockaddr_in6 sin6;
+};
+
+struct ds_header {
+ uint8_t version;
+ uint8_t length;
+ __be16 port;
+ union {
+ __be32 ipv4;
+ struct {
+ __be32 flowinfo;
+ uint8_t addr[16];
+ } ipv6;
+ } addr;
+};
+
+#define DS_IPV4_HDR_LEN 8
+#define DS_IPV6_HDR_LEN 24
+
+struct ds_dest {
+ union socket_addr addr; /* must be first */
+ struct ds_qp *qp;
+ struct ibv_ah *ah;
+ uint32_t qpn;
+};
+
+struct ds_qp {
+ dlist_entry list;
+ struct rsocket *rs;
+ struct rdma_cm_id *cm_id;
+ struct ds_header hdr;
+ struct ds_dest dest;
+
+ struct ibv_mr *smr;
+ struct ibv_mr *rmr;
+ uint8_t *rbuf;
+
+ int cq_armed;
+};
+
+struct rsocket {
+ int type;
+ int index;
+ fastlock_t slock;
+ fastlock_t rlock;
+ fastlock_t cq_lock;
+ fastlock_t cq_wait_lock;
+ fastlock_t map_lock; /* acquire slock first if needed */
+
+ union {
+ /* data stream */
+ struct {
+ struct rdma_cm_id *cm_id;
+ uint64_t tcp_opts;
+ unsigned int keepalive_time;
+
+ unsigned int ctrl_seqno;
+ unsigned int ctrl_max_seqno;
+ uint16_t sseq_no;
+ uint16_t sseq_comp;
+ uint16_t rseq_no;
+ uint16_t rseq_comp;
+
+ int remote_sge;
+ struct rs_sge remote_sgl;
+ struct rs_sge remote_iomap;
+
+ struct ibv_mr *target_mr;
+ int target_sge;
+ int target_iomap_size;
+ void *target_buffer_list;
+ volatile struct rs_sge *target_sgl;
+ struct rs_iomap *target_iomap;
+
+ int rbuf_msg_index;
+ int rbuf_bytes_avail;
+ int rbuf_free_offset;
+ int rbuf_offset;
+ struct ibv_mr *rmr;
+ uint8_t *rbuf;
+
+ int sbuf_bytes_avail;
+ struct ibv_mr *smr;
+ struct ibv_sge ssgl[2];
+ };
+ /* datagram */
+ struct {
+ struct ds_qp *qp_list;
+ void *dest_map;
+ struct ds_dest *conn_dest;
+
+ int udp_sock;
+ int epfd;
+ int rqe_avail;
+ struct ds_smsg *smsg_free;
+ };
+ };
+
+ int opts;
+ int fd_flags;
+ uint64_t so_opts;
+ uint64_t ipv6_opts;
+ void *optval;
+ size_t optlen;
+ int state;
+ int cq_armed;
+ int retries;
+ int err;
+
+ int sqe_avail;
+ uint32_t sbuf_size;
+ uint16_t sq_size;
+ uint16_t sq_inline;
+
+ uint32_t rbuf_size;
+ uint16_t rq_size;
+ int rmsg_head;
+ int rmsg_tail;
+ union {
+ struct rs_msg *rmsg;
+ struct ds_rmsg *dmsg;
+ };
+
+ uint8_t *sbuf;
+ struct rs_iomap_mr *remote_iomappings;
+ dlist_entry iomap_list;
+ dlist_entry iomap_queue;
+ int iomap_pending;
+ int unack_cqe;
+};
+
+#define DS_UDP_TAG 0x55555555
+
+struct ds_udp_header {
+ __be32 tag;
+ uint8_t version;
+ uint8_t op;
+ uint8_t length;
+ uint8_t reserved;
+ __be32 qpn; /* lower 8-bits reserved */
+ union {
+ __be32 ipv4;
+ uint8_t ipv6[16];
+ } addr;
+};
+
+#define DS_UDP_IPV4_HDR_LEN 16
+#define DS_UDP_IPV6_HDR_LEN 28
+
+#define ds_next_qp(qp) container_of((qp)->list.next, struct ds_qp, list)
+
+static void write_all(int fd, const void *msg, size_t len)
+{
+ // FIXME: if fd is a socket this really needs to handle EINTR and other conditions.
+ ssize_t rc = write(fd, msg, len);
+ assert(rc == len);
+}
+
+static void read_all(int fd, void *msg, size_t len)
+{
+ // FIXME: if fd is a socket this really needs to handle EINTR and other conditions.
+ ssize_t rc = read(fd, msg, len);
+ assert(rc == len);
+}
+
+static void ds_insert_qp(struct rsocket *rs, struct ds_qp *qp)
+{
+ if (!rs->qp_list)
+ dlist_init(&qp->list);
+ else
+ dlist_insert_head(&qp->list, &rs->qp_list->list);
+ rs->qp_list = qp;
+}
+
+static void ds_remove_qp(struct rsocket *rs, struct ds_qp *qp)
+{
+ if (qp->list.next != &qp->list) {
+ rs->qp_list = ds_next_qp(qp);
+ dlist_remove(&qp->list);
+ } else {
+ rs->qp_list = NULL;
+ }
+}
+
+static int rs_notify_svc(struct rs_svc *svc, struct rsocket *rs, int cmd)
+{
+ struct rs_svc_msg msg;
+ int ret;
+
+ pthread_mutex_lock(&mut);
+ if (!svc->cnt) {
+ ret = socketpair(AF_UNIX, SOCK_STREAM, 0, svc->sock);
+ if (ret)
+ goto unlock;
+
+ ret = pthread_create(&svc->id, NULL, svc->run, svc);
+ if (ret) {
+ ret = ERR(ret);
+ goto closepair;
+ }
+ }
+
+ msg.cmd = cmd;
+ msg.status = EINVAL;
+ msg.rs = rs;
+ write_all(svc->sock[0], &msg, sizeof msg);
+ read_all(svc->sock[0], &msg, sizeof msg);
+ ret = rdma_seterrno(msg.status);
+ if (svc->cnt)
+ goto unlock;
+
+ pthread_join(svc->id, NULL);
+closepair:
+ close(svc->sock[0]);
+ close(svc->sock[1]);
+unlock:
+ pthread_mutex_unlock(&mut);
+ return ret;
+}
+
+static int ds_compare_addr(const void *dst1, const void *dst2)
+{
+ const struct sockaddr *sa1, *sa2;
+ size_t len;
+
+ sa1 = (const struct sockaddr *) dst1;
+ sa2 = (const struct sockaddr *) dst2;
+
+ len = (sa1->sa_family == AF_INET6 && sa2->sa_family == AF_INET6) ?
+ sizeof(struct sockaddr_in6) : sizeof(struct sockaddr_in);
+ return memcmp(dst1, dst2, len);
+}
+
+static int rs_value_to_scale(int value, int bits)
+{
+ return value <= (1 << (bits - 1)) ?
+ value : (1 << (bits - 1)) | (value >> bits);
+}
+
+static int rs_scale_to_value(int value, int bits)
+{
+ return value <= (1 << (bits - 1)) ?
+ value : (value & ~(1 << (bits - 1))) << bits;
+}
+
+/* gcc > ~5 will not allow (void)fscanf to suppress -Wunused-result, but this
+ will do it. In this case ignoring the result is OK (but horribly
+ unfriendly to user) since the library has a sane default. */
+#define failable_fscanf(f, fmt, ...) \
+ { \
+ int rc = fscanf(f, fmt, __VA_ARGS__); \
+ (void) rc; \
+ }
+
+static void rs_configure(void)
+{
+ FILE *f;
+ static int init;
+
+ if (init)
+ return;
+
+ pthread_mutex_lock(&mut);
+ if (init)
+ goto out;
+
+ if (ucma_init())
+ goto out;
+ ucma_ib_init();
+
+ if ((f = fopen(RS_CONF_DIR "/polling_time", "r"))) {
+ failable_fscanf(f, "%u", &polling_time);
+ fclose(f);
+ }
+
+ if ((f = fopen(RS_CONF_DIR "/inline_default", "r"))) {
+ failable_fscanf(f, "%hu", &def_inline);
+ fclose(f);
+ }
+
+ if ((f = fopen(RS_CONF_DIR "/sqsize_default", "r"))) {
+ failable_fscanf(f, "%hu", &def_sqsize);
+ fclose(f);
+ }
+
+ if ((f = fopen(RS_CONF_DIR "/rqsize_default", "r"))) {
+ failable_fscanf(f, "%hu", &def_rqsize);
+ fclose(f);
+ }
+
+ if ((f = fopen(RS_CONF_DIR "/mem_default", "r"))) {
+ failable_fscanf(f, "%u", &def_mem);
+ fclose(f);
+
+ if (def_mem < 1)
+ def_mem = 1;
+ }
+
+ if ((f = fopen(RS_CONF_DIR "/wmem_default", "r"))) {
+ failable_fscanf(f, "%u", &def_wmem);
+ fclose(f);
+ if (def_wmem < RS_SNDLOWAT)
+ def_wmem = RS_SNDLOWAT << 1;
+ }
+
+ if ((f = fopen(RS_CONF_DIR "/iomap_size", "r"))) {
+ failable_fscanf(f, "%hu", &def_iomap_size);
+ fclose(f);
+
+ /* round to supported values */
+ def_iomap_size = (uint8_t) rs_value_to_scale(
+ (uint16_t) rs_scale_to_value(def_iomap_size, 8), 8);
+ }
+ init = 1;
+out:
+ pthread_mutex_unlock(&mut);
+}
+
+static int rs_insert(struct rsocket *rs, int index)
+{
+ pthread_mutex_lock(&mut);
+ rs->index = idm_set(&idm, index, rs);
+ pthread_mutex_unlock(&mut);
+ return rs->index;
+}
+
+static void rs_remove(struct rsocket *rs)
+{
+ pthread_mutex_lock(&mut);
+ idm_clear(&idm, rs->index);
+ pthread_mutex_unlock(&mut);
+}
+
+/* We only inherit from listening sockets */
+static struct rsocket *rs_alloc(struct rsocket *inherited_rs, int type)
+{
+ struct rsocket *rs;
+
+ rs = calloc(1, sizeof(*rs));
+ if (!rs)
+ return NULL;
+
+ rs->type = type;
+ rs->index = -1;
+ if (type == SOCK_DGRAM) {
+ rs->udp_sock = -1;
+ rs->epfd = -1;
+ }
+
+ if (inherited_rs) {
+ rs->sbuf_size = inherited_rs->sbuf_size;
+ rs->rbuf_size = inherited_rs->rbuf_size;
+ rs->sq_inline = inherited_rs->sq_inline;
+ rs->sq_size = inherited_rs->sq_size;
+ rs->rq_size = inherited_rs->rq_size;
+ if (type == SOCK_STREAM) {
+ rs->ctrl_max_seqno = inherited_rs->ctrl_max_seqno;
+ rs->target_iomap_size = inherited_rs->target_iomap_size;
+ }
+ } else {
+ rs->sbuf_size = def_wmem;
+ rs->rbuf_size = def_mem;
+ rs->sq_inline = def_inline;
+ rs->sq_size = def_sqsize;
+ rs->rq_size = def_rqsize;
+ if (type == SOCK_STREAM) {
+ rs->ctrl_max_seqno = RS_QP_CTRL_SIZE;
+ rs->target_iomap_size = def_iomap_size;
+ }
+ }
+ fastlock_init(&rs->slock);
+ fastlock_init(&rs->rlock);
+ fastlock_init(&rs->cq_lock);
+ fastlock_init(&rs->cq_wait_lock);
+ fastlock_init(&rs->map_lock);
+ dlist_init(&rs->iomap_list);
+ dlist_init(&rs->iomap_queue);
+ return rs;
+}
+
+static int rs_set_nonblocking(struct rsocket *rs, int arg)
+{
+ struct ds_qp *qp;
+ int ret = 0;
+
+ if (rs->type == SOCK_STREAM) {
+ if (rs->cm_id->recv_cq_channel)
+ ret = fcntl(rs->cm_id->recv_cq_channel->fd, F_SETFL, arg);
+
+ if (!ret && rs->state < rs_connected)
+ ret = fcntl(rs->cm_id->channel->fd, F_SETFL, arg);
+ } else {
+ ret = fcntl(rs->epfd, F_SETFL, arg);
+ if (!ret && rs->qp_list) {
+ qp = rs->qp_list;
+ do {
+ ret = fcntl(qp->cm_id->recv_cq_channel->fd,
+ F_SETFL, arg);
+ qp = ds_next_qp(qp);
+ } while (qp != rs->qp_list && !ret);
+ }
+ }
+
+ return ret;
+}
+
+static void rs_set_qp_size(struct rsocket *rs)
+{
+ uint16_t max_size;
+
+ max_size = min(ucma_max_qpsize(rs->cm_id), RS_QP_MAX_SIZE);
+
+ if (rs->sq_size > max_size)
+ rs->sq_size = max_size;
+ else if (rs->sq_size < RS_QP_MIN_SIZE)
+ rs->sq_size = RS_QP_MIN_SIZE;
+
+ if (rs->rq_size > max_size)
+ rs->rq_size = max_size;
+ else if (rs->rq_size < RS_QP_MIN_SIZE)
+ rs->rq_size = RS_QP_MIN_SIZE;
+}
+
+static void ds_set_qp_size(struct rsocket *rs)
+{
+ uint16_t max_size;
+
+ max_size = min(ucma_max_qpsize(NULL), RS_QP_MAX_SIZE);
+
+ if (rs->sq_size > max_size)
+ rs->sq_size = max_size;
+ if (rs->rq_size > max_size)
+ rs->rq_size = max_size;
+
+ if (rs->rq_size > (rs->rbuf_size / RS_SNDLOWAT))
+ rs->rq_size = rs->rbuf_size / RS_SNDLOWAT;
+ else
+ rs->rbuf_size = rs->rq_size * RS_SNDLOWAT;
+
+ if (rs->sq_size > (rs->sbuf_size / RS_SNDLOWAT))
+ rs->sq_size = rs->sbuf_size / RS_SNDLOWAT;
+ else
+ rs->sbuf_size = rs->sq_size * RS_SNDLOWAT;
+}
+
+static int rs_init_bufs(struct rsocket *rs)
+{
+ uint32_t total_rbuf_size, total_sbuf_size;
+ size_t len;
+
+ rs->rmsg = calloc(rs->rq_size + 1, sizeof(*rs->rmsg));
+ if (!rs->rmsg)
+ return ERR(ENOMEM);
+
+ total_sbuf_size = rs->sbuf_size;
+ if (rs->sq_inline < RS_MAX_CTRL_MSG)
+ total_sbuf_size += RS_MAX_CTRL_MSG * RS_QP_CTRL_SIZE;
+ rs->sbuf = calloc(total_sbuf_size, 1);
+ if (!rs->sbuf)
+ return ERR(ENOMEM);
+
+ rs->smr = rdma_reg_msgs(rs->cm_id, rs->sbuf, total_sbuf_size);
+ if (!rs->smr)
+ return -1;
+
+ len = sizeof(*rs->target_sgl) * RS_SGL_SIZE +
+ sizeof(*rs->target_iomap) * rs->target_iomap_size;
+ rs->target_buffer_list = malloc(len);
+ if (!rs->target_buffer_list)
+ return ERR(ENOMEM);
+
+ rs->target_mr = rdma_reg_write(rs->cm_id, rs->target_buffer_list, len);
+ if (!rs->target_mr)
+ return -1;
+
+ memset(rs->target_buffer_list, 0, len);
+ rs->target_sgl = rs->target_buffer_list;
+ if (rs->target_iomap_size)
+ rs->target_iomap = (struct rs_iomap *) (rs->target_sgl + RS_SGL_SIZE);
+
+ total_rbuf_size = rs->rbuf_size;
+ if (rs->opts & RS_OPT_MSG_SEND)
+ total_rbuf_size += rs->rq_size * RS_MSG_SIZE;
+ rs->rbuf = calloc(total_rbuf_size, 1);
+ if (!rs->rbuf)
+ return ERR(ENOMEM);
+
+ rs->rmr = rdma_reg_write(rs->cm_id, rs->rbuf, total_rbuf_size);
+ if (!rs->rmr)
+ return -1;
+
+ rs->ssgl[0].addr = rs->ssgl[1].addr = (uintptr_t) rs->sbuf;
+ rs->sbuf_bytes_avail = rs->sbuf_size;
+ rs->ssgl[0].lkey = rs->ssgl[1].lkey = rs->smr->lkey;
+
+ rs->rbuf_free_offset = rs->rbuf_size >> 1;
+ rs->rbuf_bytes_avail = rs->rbuf_size >> 1;
+ rs->sqe_avail = rs->sq_size - rs->ctrl_max_seqno;
+ rs->rseq_comp = rs->rq_size >> 1;
+ return 0;
+}
+
+static int ds_init_bufs(struct ds_qp *qp)
+{
+ qp->rbuf = calloc(qp->rs->rbuf_size + sizeof(struct ibv_grh), 1);
+ if (!qp->rbuf)
+ return ERR(ENOMEM);
+
+ qp->smr = rdma_reg_msgs(qp->cm_id, qp->rs->sbuf, qp->rs->sbuf_size);
+ if (!qp->smr)
+ return -1;
+
+ qp->rmr = rdma_reg_msgs(qp->cm_id, qp->rbuf, qp->rs->rbuf_size +
+ sizeof(struct ibv_grh));
+ if (!qp->rmr)
+ return -1;
+
+ return 0;
+}
+
+/*
+ * If a user is waiting on a datagram rsocket through poll or select, then
+ * we need the first completion to generate an event on the related epoll fd
+ * in order to signal the user. We arm the CQ on creation for this purpose
+ */
+static int rs_create_cq(struct rsocket *rs, struct rdma_cm_id *cm_id)
+{
+ cm_id->recv_cq_channel = ibv_create_comp_channel(cm_id->verbs);
+ if (!cm_id->recv_cq_channel)
+ return -1;
+
+ cm_id->recv_cq = ibv_create_cq(cm_id->verbs, rs->sq_size + rs->rq_size,
+ cm_id, cm_id->recv_cq_channel, 0);
+ if (!cm_id->recv_cq)
+ goto err1;
+
+ if (rs->fd_flags & O_NONBLOCK) {
+ if (fcntl(cm_id->recv_cq_channel->fd, F_SETFL, O_NONBLOCK))
+ goto err2;
+ }
+
+ ibv_req_notify_cq(cm_id->recv_cq, 0);
+ cm_id->send_cq_channel = cm_id->recv_cq_channel;
+ cm_id->send_cq = cm_id->recv_cq;
+ return 0;
+
+err2:
+ ibv_destroy_cq(cm_id->recv_cq);
+ cm_id->recv_cq = NULL;
+err1:
+ ibv_destroy_comp_channel(cm_id->recv_cq_channel);
+ cm_id->recv_cq_channel = NULL;
+ return -1;
+}
+
+static inline int rs_post_recv(struct rsocket *rs)
+{
+ struct ibv_recv_wr wr, *bad;
+ struct ibv_sge sge;
+
+ wr.next = NULL;
+ if (!(rs->opts & RS_OPT_MSG_SEND)) {
+ wr.wr_id = rs_recv_wr_id(0);
+ wr.sg_list = NULL;
+ wr.num_sge = 0;
+ } else {
+ wr.wr_id = rs_recv_wr_id(rs->rbuf_msg_index);
+ sge.addr = (uintptr_t) rs->rbuf + rs->rbuf_size +
+ (rs->rbuf_msg_index * RS_MSG_SIZE);
+ sge.length = RS_MSG_SIZE;
+ sge.lkey = rs->rmr->lkey;
+
+ wr.sg_list = &sge;
+ wr.num_sge = 1;
+ if(++rs->rbuf_msg_index == rs->rq_size)
+ rs->rbuf_msg_index = 0;
+ }
+
+ return rdma_seterrno(ibv_post_recv(rs->cm_id->qp, &wr, &bad));
+}
+
+static inline int ds_post_recv(struct rsocket *rs, struct ds_qp *qp, uint32_t offset)
+{
+ struct ibv_recv_wr wr, *bad;
+ struct ibv_sge sge[2];
+
+ sge[0].addr = (uintptr_t) qp->rbuf + rs->rbuf_size;
+ sge[0].length = sizeof(struct ibv_grh);
+ sge[0].lkey = qp->rmr->lkey;
+ sge[1].addr = (uintptr_t) qp->rbuf + offset;
+ sge[1].length = RS_SNDLOWAT;
+ sge[1].lkey = qp->rmr->lkey;
+
+ wr.wr_id = rs_recv_wr_id(offset);
+ wr.next = NULL;
+ wr.sg_list = sge;
+ wr.num_sge = 2;
+
+ return rdma_seterrno(ibv_post_recv(qp->cm_id->qp, &wr, &bad));
+}
+
+static int rs_create_ep(struct rsocket *rs)
+{
+ struct ibv_qp_init_attr qp_attr;
+ int i, ret;
+
+ rs_set_qp_size(rs);
+ if (rs->cm_id->verbs->device->transport_type == IBV_TRANSPORT_IWARP)
+ rs->opts |= RS_OPT_MSG_SEND;
+ ret = rs_create_cq(rs, rs->cm_id);
+ if (ret)
+ return ret;
+
+ memset(&qp_attr, 0, sizeof qp_attr);
+ qp_attr.qp_context = rs;
+ qp_attr.send_cq = rs->cm_id->send_cq;
+ qp_attr.recv_cq = rs->cm_id->recv_cq;
+ qp_attr.qp_type = IBV_QPT_RC;
+ qp_attr.sq_sig_all = 1;
+ qp_attr.cap.max_send_wr = rs->sq_size;
+ qp_attr.cap.max_recv_wr = rs->rq_size;
+ qp_attr.cap.max_send_sge = 2;
+ qp_attr.cap.max_recv_sge = 1;
+ qp_attr.cap.max_inline_data = rs->sq_inline;
+
+ ret = rdma_create_qp(rs->cm_id, NULL, &qp_attr);
+ if (ret)
+ return ret;
+
+ rs->sq_inline = qp_attr.cap.max_inline_data;
+ if ((rs->opts & RS_OPT_MSG_SEND) && (rs->sq_inline < RS_MSG_SIZE))
+ return ERR(ENOTSUP);
+
+ ret = rs_init_bufs(rs);
+ if (ret)
+ return ret;
+
+ for (i = 0; i < rs->rq_size; i++) {
+ ret = rs_post_recv(rs);
+ if (ret)
+ return ret;
+ }
+ return 0;
+}
+
+static void rs_release_iomap_mr(struct rs_iomap_mr *iomr)
+{
+ if (atomic_fetch_sub(&iomr->refcnt, 1) != 1)
+ return;
+
+ dlist_remove(&iomr->entry);
+ ibv_dereg_mr(iomr->mr);
+ if (iomr->index >= 0)
+ iomr->mr = NULL;
+ else
+ free(iomr);
+}
+
+static void rs_free_iomappings(struct rsocket *rs)
+{
+ struct rs_iomap_mr *iomr;
+
+ while (!dlist_empty(&rs->iomap_list)) {
+ iomr = container_of(rs->iomap_list.next,
+ struct rs_iomap_mr, entry);
+ riounmap(rs->index, iomr->mr->addr, iomr->mr->length);
+ }
+ while (!dlist_empty(&rs->iomap_queue)) {
+ iomr = container_of(rs->iomap_queue.next,
+ struct rs_iomap_mr, entry);
+ riounmap(rs->index, iomr->mr->addr, iomr->mr->length);
+ }
+}
+
+static void ds_free_qp(struct ds_qp *qp)
+{
+ if (qp->smr)
+ rdma_dereg_mr(qp->smr);
+
+ if (qp->rbuf) {
+ if (qp->rmr)
+ rdma_dereg_mr(qp->rmr);
+ free(qp->rbuf);
+ }
+
+ if (qp->cm_id) {
+ if (qp->cm_id->qp) {
+ tdelete(&qp->dest.addr, &qp->rs->dest_map, ds_compare_addr);
+ epoll_ctl(qp->rs->epfd, EPOLL_CTL_DEL,
+ qp->cm_id->recv_cq_channel->fd, NULL);
+ rdma_destroy_qp(qp->cm_id);
+ }
+ rdma_destroy_id(qp->cm_id);
+ }
+
+ free(qp);
+}
+
+static void ds_free(struct rsocket *rs)
+{
+ struct ds_qp *qp;
+
+ if (rs->udp_sock >= 0)
+ close(rs->udp_sock);
+
+ if (rs->index >= 0)
+ rs_remove(rs);
+
+ if (rs->dmsg)
+ free(rs->dmsg);
+
+ while ((qp = rs->qp_list)) {
+ ds_remove_qp(rs, qp);
+ ds_free_qp(qp);
+ }
+
+ if (rs->epfd >= 0)
+ close(rs->epfd);
+
+ if (rs->sbuf)
+ free(rs->sbuf);
+
+ tdestroy(rs->dest_map, free);
+ fastlock_destroy(&rs->map_lock);
+ fastlock_destroy(&rs->cq_wait_lock);
+ fastlock_destroy(&rs->cq_lock);
+ fastlock_destroy(&rs->rlock);
+ fastlock_destroy(&rs->slock);
+ free(rs);
+}
+
+static void rs_free(struct rsocket *rs)
+{
+ if (rs->type == SOCK_DGRAM) {
+ ds_free(rs);
+ return;
+ }
+
+ if (rs->rmsg)
+ free(rs->rmsg);
+
+ if (rs->sbuf) {
+ if (rs->smr)
+ rdma_dereg_mr(rs->smr);
+ free(rs->sbuf);
+ }
+
+ if (rs->rbuf) {
+ if (rs->rmr)
+ rdma_dereg_mr(rs->rmr);
+ free(rs->rbuf);
+ }
+
+ if (rs->target_buffer_list) {
+ if (rs->target_mr)
+ rdma_dereg_mr(rs->target_mr);
+ free(rs->target_buffer_list);
+ }
+
+ if (rs->cm_id) {
+ rs_free_iomappings(rs);
+ if (rs->cm_id->qp) {
+ ibv_ack_cq_events(rs->cm_id->recv_cq, rs->unack_cqe);
+ rdma_destroy_qp(rs->cm_id);
+ }
+ rdma_destroy_id(rs->cm_id);
+ }
+
+ if (rs->index >= 0)
+ rs_remove(rs);
+
+ fastlock_destroy(&rs->map_lock);
+ fastlock_destroy(&rs->cq_wait_lock);
+ fastlock_destroy(&rs->cq_lock);
+ fastlock_destroy(&rs->rlock);
+ fastlock_destroy(&rs->slock);
+ free(rs);
+}
+
+static size_t rs_conn_data_offset(struct rsocket *rs)
+{
+ return (rs->cm_id->route.addr.src_addr.sa_family == AF_IB) ?
+ sizeof(struct ib_connect_hdr) : 0;
+}
+
+static void rs_format_conn_data(struct rsocket *rs, struct rs_conn_data *conn)
+{
+ conn->version = 1;
+ conn->flags = RS_CONN_FLAG_IOMAP |
+ (rs_host_is_net() ? RS_CONN_FLAG_NET : 0);
+ conn->credits = htobe16(rs->rq_size);
+ memset(conn->reserved, 0, sizeof conn->reserved);
+ conn->target_iomap_size = (uint8_t) rs_value_to_scale(rs->target_iomap_size, 8);
+
+ conn->target_sgl.addr = (__force uint64_t)htobe64((uintptr_t) rs->target_sgl);
+ conn->target_sgl.length = (__force uint32_t)htobe32(RS_SGL_SIZE);
+ conn->target_sgl.key = (__force uint32_t)htobe32(rs->target_mr->rkey);
+
+ conn->data_buf.addr = (__force uint64_t)htobe64((uintptr_t) rs->rbuf);
+ conn->data_buf.length = (__force uint32_t)htobe32(rs->rbuf_size >> 1);
+ conn->data_buf.key = (__force uint32_t)htobe32(rs->rmr->rkey);
+}
+
+static void rs_save_conn_data(struct rsocket *rs, struct rs_conn_data *conn)
+{
+ rs->remote_sgl.addr = be64toh((__force __be64)conn->target_sgl.addr);
+ rs->remote_sgl.length = be32toh((__force __be32)conn->target_sgl.length);
+ rs->remote_sgl.key = be32toh((__force __be32)conn->target_sgl.key);
+ rs->remote_sge = 1;
+ if ((rs_host_is_net() && !(conn->flags & RS_CONN_FLAG_NET)) ||
+ (!rs_host_is_net() && (conn->flags & RS_CONN_FLAG_NET)))
+ rs->opts = RS_OPT_SWAP_SGL;
+
+ if (conn->flags & RS_CONN_FLAG_IOMAP) {
+ rs->remote_iomap.addr = rs->remote_sgl.addr +
+ sizeof(rs->remote_sgl) * rs->remote_sgl.length;
+ rs->remote_iomap.length = rs_scale_to_value(conn->target_iomap_size, 8);
+ rs->remote_iomap.key = rs->remote_sgl.key;
+ }
+
+ rs->target_sgl[0].addr = be64toh((__force __be64)conn->data_buf.addr);
+ rs->target_sgl[0].length = be32toh((__force __be32)conn->data_buf.length);
+ rs->target_sgl[0].key = be32toh((__force __be32)conn->data_buf.key);
+
+ rs->sseq_comp = be16toh(conn->credits);
+}
+
+static int ds_init(struct rsocket *rs, int domain)
+{
+ rs->udp_sock = socket(domain, SOCK_DGRAM, 0);
+ if (rs->udp_sock < 0)
+ return rs->udp_sock;
+
+ rs->epfd = epoll_create(2);
+ if (rs->epfd < 0)
+ return rs->epfd;
+
+ return 0;
+}
+
+static int ds_init_ep(struct rsocket *rs)
+{
+ struct ds_smsg *msg;
+ int i, ret;
+
+ ds_set_qp_size(rs);
+
+ rs->sbuf = calloc(rs->sq_size, RS_SNDLOWAT);
+ if (!rs->sbuf)
+ return ERR(ENOMEM);
+
+ rs->dmsg = calloc(rs->rq_size + 1, sizeof(*rs->dmsg));
+ if (!rs->dmsg)
+ return ERR(ENOMEM);
+
+ rs->sqe_avail = rs->sq_size;
+ rs->rqe_avail = rs->rq_size;
+
+ rs->smsg_free = (struct ds_smsg *) rs->sbuf;
+ msg = rs->smsg_free;
+ for (i = 0; i < rs->sq_size - 1; i++) {
+ msg->next = (void *) msg + RS_SNDLOWAT;
+ msg = msg->next;
+ }
+ msg->next = NULL;
+
+ ret = rs_notify_svc(&udp_svc, rs, RS_SVC_ADD_DGRAM);
+ if (ret)
+ return ret;
+
+ rs->state = rs_readable | rs_writable;
+ return 0;
+}
+
+int rsocket(int domain, int type, int protocol)
+{
+ struct rsocket *rs;
+ int index, ret;
+
+ if ((domain != AF_INET && domain != AF_INET6 && domain != AF_IB) ||
+ ((type != SOCK_STREAM) && (type != SOCK_DGRAM)) ||
+ (type == SOCK_STREAM && protocol && protocol != IPPROTO_TCP) ||
+ (type == SOCK_DGRAM && protocol && protocol != IPPROTO_UDP))
+ return ERR(ENOTSUP);
+
+ rs_configure();
+ rs = rs_alloc(NULL, type);
+ if (!rs)
+ return ERR(ENOMEM);
+
+ if (type == SOCK_STREAM) {
+ ret = rdma_create_id(NULL, &rs->cm_id, rs, RDMA_PS_TCP);
+ if (ret)
+ goto err;
+
+ rs->cm_id->route.addr.src_addr.sa_family = domain;
+ index = rs->cm_id->channel->fd;
+ } else {
+ ret = ds_init(rs, domain);
+ if (ret)
+ goto err;
+
+ index = rs->udp_sock;
+ }
+
+ ret = rs_insert(rs, index);
+ if (ret < 0)
+ goto err;
+
+ return rs->index;
+
+err:
+ rs_free(rs);
+ return ret;
+}
+
+int rbind(int socket, const struct sockaddr *addr, socklen_t addrlen)
+{
+ struct rsocket *rs;
+ int ret;
+
+ rs = idm_lookup(&idm, socket);
+ if (!rs)
+ return ERR(EBADF);
+ if (rs->type == SOCK_STREAM) {
+ ret = rdma_bind_addr(rs->cm_id, (struct sockaddr *) addr);
+ if (!ret)
+ rs->state = rs_bound;
+ } else {
+ if (rs->state == rs_init) {
+ ret = ds_init_ep(rs);
+ if (ret)
+ return ret;
+ }
+ ret = bind(rs->udp_sock, addr, addrlen);
+ }
+ return ret;
+}
+
+int rlisten(int socket, int backlog)
+{
+ struct rsocket *rs;
+ int ret;
+
+ rs = idm_lookup(&idm, socket);
+ if (!rs)
+ return ERR(EBADF);
+
+ if (rs->state != rs_listening) {
+ ret = rdma_listen(rs->cm_id, backlog);
+ if (!ret)
+ rs->state = rs_listening;
+ } else {
+ ret = 0;
+ }
+ return ret;
+}
+
+/*
+ * Nonblocking is usually not inherited between sockets, but we need to
+ * inherit it here to establish the connection only. This is needed to
+ * prevent rdma_accept from blocking until the remote side finishes
+ * establishing the connection. If we were to allow rdma_accept to block,
+ * then a single thread cannot establish a connection with itself, or
+ * two threads which try to connect to each other can deadlock trying to
+ * form a connection.
+ *
+ * Data transfers on the new socket remain blocking unless the user
+ * specifies otherwise through rfcntl.
+ */
+int raccept(int socket, struct sockaddr *addr, socklen_t *addrlen)
+{
+ struct rsocket *rs, *new_rs;
+ struct rdma_conn_param param;
+ struct rs_conn_data *creq, cresp;
+ int ret;
+
+ rs = idm_lookup(&idm, socket);
+ if (!rs)
+ return ERR(EBADF);
+ new_rs = rs_alloc(rs, rs->type);
+ if (!new_rs)
+ return ERR(ENOMEM);
+
+ ret = rdma_get_request(rs->cm_id, &new_rs->cm_id);
+ if (ret)
+ goto err;
+
+ ret = rs_insert(new_rs, new_rs->cm_id->channel->fd);
+ if (ret < 0)
+ goto err;
+
+ creq = (struct rs_conn_data *)
+ (new_rs->cm_id->event->param.conn.private_data + rs_conn_data_offset(rs));
+ if (creq->version != 1) {
+ ret = ERR(ENOTSUP);
+ goto err;
+ }
+
+ if (rs->fd_flags & O_NONBLOCK)
+ fcntl(new_rs->cm_id->channel->fd, F_SETFL, O_NONBLOCK);
+
+ ret = rs_create_ep(new_rs);
+ if (ret)
+ goto err;
+
+ rs_save_conn_data(new_rs, creq);
+ param = new_rs->cm_id->event->param.conn;
+ rs_format_conn_data(new_rs, &cresp);
+ param.private_data = &cresp;
+ param.private_data_len = sizeof cresp;
+ ret = rdma_accept(new_rs->cm_id, &param);
+ if (!ret)
+ new_rs->state = rs_connect_rdwr;
+ else if (errno == EAGAIN || errno == EWOULDBLOCK)
+ new_rs->state = rs_accepting;
+ else
+ goto err;
+
+ if (addr && addrlen)
+ rgetpeername(new_rs->index, addr, addrlen);
+ return new_rs->index;
+
+err:
+ rs_free(new_rs);
+ return ret;
+}
+
+static int rs_do_connect(struct rsocket *rs)
+{
+ struct rdma_conn_param param;
+ struct rs_conn_private_data cdata;
+ struct rs_conn_data *creq, *cresp;
+ int to, ret;
+
+ switch (rs->state) {
+ case rs_init:
+ case rs_bound:
+resolve_addr:
+ to = 1000 << rs->retries++;
+ ret = rdma_resolve_addr(rs->cm_id, NULL,
+ &rs->cm_id->route.addr.dst_addr, to);
+ if (!ret)
+ goto resolve_route;
+ if (errno == EAGAIN || errno == EWOULDBLOCK)
+ rs->state = rs_resolving_addr;
+ break;
+ case rs_resolving_addr:
+ ret = ucma_complete(rs->cm_id);
+ if (ret) {
+ if (errno == ETIMEDOUT && rs->retries <= RS_CONN_RETRIES)
+ goto resolve_addr;
+ break;
+ }
+
+ rs->retries = 0;
+resolve_route:
+ to = 1000 << rs->retries++;
+ if (rs->optval) {
+ ret = rdma_set_option(rs->cm_id, RDMA_OPTION_IB,
+ RDMA_OPTION_IB_PATH, rs->optval,
+ rs->optlen);
+ free(rs->optval);
+ rs->optval = NULL;
+ if (!ret) {
+ rs->state = rs_resolving_route;
+ goto resolving_route;
+ }
+ } else {
+ ret = rdma_resolve_route(rs->cm_id, to);
+ if (!ret)
+ goto do_connect;
+ }
+ if (errno == EAGAIN || errno == EWOULDBLOCK)
+ rs->state = rs_resolving_route;
+ break;
+ case rs_resolving_route:
+resolving_route:
+ ret = ucma_complete(rs->cm_id);
+ if (ret) {
+ if (errno == ETIMEDOUT && rs->retries <= RS_CONN_RETRIES)
+ goto resolve_route;
+ break;
+ }
+do_connect:
+ ret = rs_create_ep(rs);
+ if (ret)
+ break;
+
+ memset(&param, 0, sizeof param);
+ creq = (void *) &cdata + rs_conn_data_offset(rs);
+ rs_format_conn_data(rs, creq);
+ param.private_data = (void *) creq - rs_conn_data_offset(rs);
+ param.private_data_len = sizeof(*creq) + rs_conn_data_offset(rs);
+ param.flow_control = 1;
+ param.retry_count = 7;
+ param.rnr_retry_count = 7;
+ /* work-around: iWarp issues RDMA read during connection */
+ if (rs->opts & RS_OPT_MSG_SEND)
+ param.initiator_depth = 1;
+ rs->retries = 0;
+
+ ret = rdma_connect(rs->cm_id, &param);
+ if (!ret)
+ goto connected;
+ if (errno == EAGAIN || errno == EWOULDBLOCK)
+ rs->state = rs_connecting;
+ break;
+ case rs_connecting:
+ ret = ucma_complete(rs->cm_id);
+ if (ret)
+ break;
+connected:
+ cresp = (struct rs_conn_data *) rs->cm_id->event->param.conn.private_data;
+ if (cresp->version != 1) {
+ ret = ERR(ENOTSUP);
+ break;
+ }
+
+ rs_save_conn_data(rs, cresp);
+ rs->state = rs_connect_rdwr;
+ break;
+ case rs_accepting:
+ if (!(rs->fd_flags & O_NONBLOCK))
+ fcntl(rs->cm_id->channel->fd, F_SETFL, 0);
+
+ ret = ucma_complete(rs->cm_id);
+ if (ret)
+ break;
+
+ rs->state = rs_connect_rdwr;
+ break;
+ default:
+ ret = ERR(EINVAL);
+ break;
+ }
+
+ if (ret) {
+ if (errno == EAGAIN || errno == EWOULDBLOCK) {
+ errno = EINPROGRESS;
+ } else {
+ rs->state = rs_connect_error;
+ rs->err = errno;
+ }
+ }
+ return ret;
+}
+
+static int rs_any_addr(const union socket_addr *addr)
+{
+ if (addr->sa.sa_family == AF_INET) {
+ return (addr->sin.sin_addr.s_addr == htobe32(INADDR_ANY) ||
+ addr->sin.sin_addr.s_addr == htobe32(INADDR_LOOPBACK));
+ } else {
+ return (!memcmp(&addr->sin6.sin6_addr, &in6addr_any, 16) ||
+ !memcmp(&addr->sin6.sin6_addr, &in6addr_loopback, 16));
+ }
+}
+
+static int ds_get_src_addr(struct rsocket *rs,
+ const struct sockaddr *dest_addr, socklen_t dest_len,
+ union socket_addr *src_addr, socklen_t *src_len)
+{
+ int sock, ret;
+ __be16 port;
+
+ *src_len = sizeof(*src_addr);
+ ret = getsockname(rs->udp_sock, &src_addr->sa, src_len);
+ if (ret || !rs_any_addr(src_addr))
+ return ret;
+
+ port = src_addr->sin.sin_port;
+ sock = socket(dest_addr->sa_family, SOCK_DGRAM, 0);
+ if (sock < 0)
+ return sock;
+
+ ret = connect(sock, dest_addr, dest_len);
+ if (ret)
+ goto out;
+
+ *src_len = sizeof(*src_addr);
+ ret = getsockname(sock, &src_addr->sa, src_len);
+ src_addr->sin.sin_port = port;
+out:
+ close(sock);
+ return ret;
+}
+
+static void ds_format_hdr(struct ds_header *hdr, union socket_addr *addr)
+{
+ if (addr->sa.sa_family == AF_INET) {
+ hdr->version = 4;
+ hdr->length = DS_IPV4_HDR_LEN;
+ hdr->port = addr->sin.sin_port;
+ hdr->addr.ipv4 = addr->sin.sin_addr.s_addr;
+ } else {
+ hdr->version = 6;
+ hdr->length = DS_IPV6_HDR_LEN;
+ hdr->port = addr->sin6.sin6_port;
+ hdr->addr.ipv6.flowinfo= addr->sin6.sin6_flowinfo;
+ memcpy(&hdr->addr.ipv6.addr, &addr->sin6.sin6_addr, 16);
+ }
+}
+
+static int ds_add_qp_dest(struct ds_qp *qp, union socket_addr *addr,
+ socklen_t addrlen)
+{
+ struct ibv_port_attr port_attr;
+ struct ibv_ah_attr attr;
+ int ret;
+
+ memcpy(&qp->dest.addr, addr, addrlen);
+ qp->dest.qp = qp;
+ qp->dest.qpn = qp->cm_id->qp->qp_num;
+
+ ret = ibv_query_port(qp->cm_id->verbs, qp->cm_id->port_num, &port_attr);
+ if (ret)
+ return ret;
+
+ memset(&attr, 0, sizeof attr);
+ attr.dlid = port_attr.lid;
+ attr.port_num = qp->cm_id->port_num;
+ qp->dest.ah = ibv_create_ah(qp->cm_id->pd, &attr);
+ if (!qp->dest.ah)
+ return ERR(ENOMEM);
+
+ tsearch(&qp->dest.addr, &qp->rs->dest_map, ds_compare_addr);
+ return 0;
+}
+
+static int ds_create_qp(struct rsocket *rs, union socket_addr *src_addr,
+ socklen_t addrlen, struct ds_qp **new_qp)
+{
+ struct ds_qp *qp;
+ struct ibv_qp_init_attr qp_attr;
+ struct epoll_event event;
+ int i, ret;
+
+ qp = calloc(1, sizeof(*qp));
+ if (!qp)
+ return ERR(ENOMEM);
+
+ qp->rs = rs;
+ ret = rdma_create_id(NULL, &qp->cm_id, qp, RDMA_PS_UDP);
+ if (ret)
+ goto err;
+
+ ds_format_hdr(&qp->hdr, src_addr);
+ ret = rdma_bind_addr(qp->cm_id, &src_addr->sa);
+ if (ret)
+ goto err;
+
+ ret = ds_init_bufs(qp);
+ if (ret)
+ goto err;
+
+ ret = rs_create_cq(rs, qp->cm_id);
+ if (ret)
+ goto err;
+
+ memset(&qp_attr, 0, sizeof qp_attr);
+ qp_attr.qp_context = qp;
+ qp_attr.send_cq = qp->cm_id->send_cq;
+ qp_attr.recv_cq = qp->cm_id->recv_cq;
+ qp_attr.qp_type = IBV_QPT_UD;
+ qp_attr.sq_sig_all = 1;
+ qp_attr.cap.max_send_wr = rs->sq_size;
+ qp_attr.cap.max_recv_wr = rs->rq_size;
+ qp_attr.cap.max_send_sge = 1;
+ qp_attr.cap.max_recv_sge = 2;
+ qp_attr.cap.max_inline_data = rs->sq_inline;
+ ret = rdma_create_qp(qp->cm_id, NULL, &qp_attr);
+ if (ret)
+ goto err;
+
+ rs->sq_inline = qp_attr.cap.max_inline_data;
+ ret = ds_add_qp_dest(qp, src_addr, addrlen);
+ if (ret)
+ goto err;
+
+ event.events = EPOLLIN;
+ event.data.ptr = qp;
+ ret = epoll_ctl(rs->epfd, EPOLL_CTL_ADD,
+ qp->cm_id->recv_cq_channel->fd, &event);
+ if (ret)
+ goto err;
+
+ for (i = 0; i < rs->rq_size; i++) {
+ ret = ds_post_recv(rs, qp, i * RS_SNDLOWAT);
+ if (ret)
+ goto err;
+ }
+
+ ds_insert_qp(rs, qp);
+ *new_qp = qp;
+ return 0;
+err:
+ ds_free_qp(qp);
+ return ret;
+}
+
+static int ds_get_qp(struct rsocket *rs, union socket_addr *src_addr,
+ socklen_t addrlen, struct ds_qp **qp)
+{
+ if (rs->qp_list) {
+ *qp = rs->qp_list;
+ do {
+ if (!ds_compare_addr(rdma_get_local_addr((*qp)->cm_id),
+ src_addr))
+ return 0;
+
+ *qp = ds_next_qp(*qp);
+ } while (*qp != rs->qp_list);
+ }
+
+ return ds_create_qp(rs, src_addr, addrlen, qp);
+}
+
+static int ds_get_dest(struct rsocket *rs, const struct sockaddr *addr,
+ socklen_t addrlen, struct ds_dest **dest)
+{
+ union socket_addr src_addr;
+ socklen_t src_len;
+ struct ds_qp *qp;
+ struct ds_dest **tdest, *new_dest;
+ int ret = 0;
+
+ fastlock_acquire(&rs->map_lock);
+ tdest = tfind(addr, &rs->dest_map, ds_compare_addr);
+ if (tdest)
+ goto found;
+
+ ret = ds_get_src_addr(rs, addr, addrlen, &src_addr, &src_len);
+ if (ret)
+ goto out;
+
+ ret = ds_get_qp(rs, &src_addr, src_len, &qp);
+ if (ret)
+ goto out;
+
+ tdest = tfind(addr, &rs->dest_map, ds_compare_addr);
+ if (!tdest) {
+ new_dest = calloc(1, sizeof(*new_dest));
+ if (!new_dest) {
+ ret = ERR(ENOMEM);
+ goto out;
+ }
+
+ memcpy(&new_dest->addr, addr, addrlen);
+ new_dest->qp = qp;
+ tdest = tsearch(&new_dest->addr, &rs->dest_map, ds_compare_addr);
+ }
+
+found:
+ *dest = *tdest;
+out:
+ fastlock_release(&rs->map_lock);
+ return ret;
+}
+
+int rconnect(int socket, const struct sockaddr *addr, socklen_t addrlen)
+{
+ struct rsocket *rs;
+ int ret;
+
+ rs = idm_lookup(&idm, socket);
+ if (!rs)
+ return ERR(EBADF);
+ if (rs->type == SOCK_STREAM) {
+ memcpy(&rs->cm_id->route.addr.dst_addr, addr, addrlen);
+ ret = rs_do_connect(rs);
+ } else {
+ if (rs->state == rs_init) {
+ ret = ds_init_ep(rs);
+ if (ret)
+ return ret;
+ }
+
+ fastlock_acquire(&rs->slock);
+ ret = connect(rs->udp_sock, addr, addrlen);
+ if (!ret)
+ ret = ds_get_dest(rs, addr, addrlen, &rs->conn_dest);
+ fastlock_release(&rs->slock);
+ }
+ return ret;
+}
+
+static void *rs_get_ctrl_buf(struct rsocket *rs)
+{
+ return rs->sbuf + rs->sbuf_size +
+ RS_MAX_CTRL_MSG * (rs->ctrl_seqno & (RS_QP_CTRL_SIZE - 1));
+}
+
+static int rs_post_msg(struct rsocket *rs, uint32_t msg)
+{
+ struct ibv_send_wr wr, *bad;
+ struct ibv_sge sge;
+
+ wr.wr_id = rs_send_wr_id(msg);
+ wr.next = NULL;
+ if (!(rs->opts & RS_OPT_MSG_SEND)) {
+ wr.sg_list = NULL;
+ wr.num_sge = 0;
+ wr.opcode = IBV_WR_RDMA_WRITE_WITH_IMM;
+ wr.send_flags = 0;
+ wr.imm_data = htobe32(msg);
+ } else {
+ sge.addr = (uintptr_t) &msg;
+ sge.lkey = 0;
+ sge.length = sizeof msg;
+ wr.sg_list = &sge;
+ wr.num_sge = 1;
+ wr.opcode = IBV_WR_SEND;
+ wr.send_flags = IBV_SEND_INLINE;
+ }
+
+ return rdma_seterrno(ibv_post_send(rs->cm_id->qp, &wr, &bad));
+}
+
+static int rs_post_write(struct rsocket *rs,
+ struct ibv_sge *sgl, int nsge,
+ uint32_t wr_data, int flags,
+ uint64_t addr, uint32_t rkey)
+{
+ struct ibv_send_wr wr, *bad;
+
+ wr.wr_id = rs_send_wr_id(wr_data);
+ wr.next = NULL;
+ wr.sg_list = sgl;
+ wr.num_sge = nsge;
+ wr.opcode = IBV_WR_RDMA_WRITE;
+ wr.send_flags = flags;
+ wr.wr.rdma.remote_addr = addr;
+ wr.wr.rdma.rkey = rkey;
+
+ return rdma_seterrno(ibv_post_send(rs->cm_id->qp, &wr, &bad));
+}
+
+static int rs_post_write_msg(struct rsocket *rs,
+ struct ibv_sge *sgl, int nsge,
+ uint32_t msg, int flags,
+ uint64_t addr, uint32_t rkey)
+{
+ struct ibv_send_wr wr, *bad;
+ struct ibv_sge sge;
+ int ret;
+
+ wr.next = NULL;
+ if (!(rs->opts & RS_OPT_MSG_SEND)) {
+ wr.wr_id = rs_send_wr_id(msg);
+ wr.sg_list = sgl;
+ wr.num_sge = nsge;
+ wr.opcode = IBV_WR_RDMA_WRITE_WITH_IMM;
+ wr.send_flags = flags;
+ wr.imm_data = htobe32(msg);
+ wr.wr.rdma.remote_addr = addr;
+ wr.wr.rdma.rkey = rkey;
+
+ return rdma_seterrno(ibv_post_send(rs->cm_id->qp, &wr, &bad));
+ } else {
+ ret = rs_post_write(rs, sgl, nsge, msg, flags, addr, rkey);
+ if (!ret) {
+ wr.wr_id = rs_send_wr_id(rs_msg_set(rs_msg_op(msg), 0)) |
+ RS_WR_ID_FLAG_MSG_SEND;
+ sge.addr = (uintptr_t) &msg;
+ sge.lkey = 0;
+ sge.length = sizeof msg;
+ wr.sg_list = &sge;
+ wr.num_sge = 1;
+ wr.opcode = IBV_WR_SEND;
+ wr.send_flags = IBV_SEND_INLINE;
+
+ ret = rdma_seterrno(ibv_post_send(rs->cm_id->qp, &wr, &bad));
+ }
+ return ret;
+ }
+}
+
+static int ds_post_send(struct rsocket *rs, struct ibv_sge *sge,
+ uint32_t wr_data)
+{
+ struct ibv_send_wr wr, *bad;
+
+ wr.wr_id = rs_send_wr_id(wr_data);
+ wr.next = NULL;
+ wr.sg_list = sge;
+ wr.num_sge = 1;
+ wr.opcode = IBV_WR_SEND;
+ wr.send_flags = (sge->length <= rs->sq_inline) ? IBV_SEND_INLINE : 0;
+ wr.wr.ud.ah = rs->conn_dest->ah;
+ wr.wr.ud.remote_qpn = rs->conn_dest->qpn;
+ wr.wr.ud.remote_qkey = RDMA_UDP_QKEY;
+
+ return rdma_seterrno(ibv_post_send(rs->conn_dest->qp->cm_id->qp, &wr, &bad));
+}
+
+/*
+ * Update target SGE before sending data. Otherwise the remote side may
+ * update the entry before we do.
+ */
+static int rs_write_data(struct rsocket *rs,
+ struct ibv_sge *sgl, int nsge,
+ uint32_t length, int flags)
+{
+ uint64_t addr;
+ uint32_t rkey;
+
+ rs->sseq_no++;
+ rs->sqe_avail--;
+ if (rs->opts & RS_OPT_MSG_SEND)
+ rs->sqe_avail--;
+ rs->sbuf_bytes_avail -= length;
+
+ addr = rs->target_sgl[rs->target_sge].addr;
+ rkey = rs->target_sgl[rs->target_sge].key;
+
+ rs->target_sgl[rs->target_sge].addr += length;
+ rs->target_sgl[rs->target_sge].length -= length;
+
+ if (!rs->target_sgl[rs->target_sge].length) {
+ if (++rs->target_sge == RS_SGL_SIZE)
+ rs->target_sge = 0;
+ }
+
+ return rs_post_write_msg(rs, sgl, nsge, rs_msg_set(RS_OP_DATA, length),
+ flags, addr, rkey);
+}
+
+static int rs_write_direct(struct rsocket *rs, struct rs_iomap *iom, uint64_t offset,
+ struct ibv_sge *sgl, int nsge, uint32_t length, int flags)
+{
+ uint64_t addr;
+
+ rs->sqe_avail--;
+ rs->sbuf_bytes_avail -= length;
+
+ addr = iom->sge.addr + offset - iom->offset;
+ return rs_post_write(rs, sgl, nsge, rs_msg_set(RS_OP_WRITE, length),
+ flags, addr, iom->sge.key);
+}
+
+static int rs_write_iomap(struct rsocket *rs, struct rs_iomap_mr *iomr,
+ struct ibv_sge *sgl, int nsge, int flags)
+{
+ uint64_t addr;
+
+ rs->sseq_no++;
+ rs->sqe_avail--;
+ if (rs->opts & RS_OPT_MSG_SEND)
+ rs->sqe_avail--;
+ rs->sbuf_bytes_avail -= sizeof(struct rs_iomap);
+
+ addr = rs->remote_iomap.addr + iomr->index * sizeof(struct rs_iomap);
+ return rs_post_write_msg(rs, sgl, nsge, rs_msg_set(RS_OP_IOMAP_SGL, iomr->index),
+ flags, addr, rs->remote_iomap.key);
+}
+
+static uint32_t rs_sbuf_left(struct rsocket *rs)
+{
+ return (uint32_t) (((uint64_t) (uintptr_t) &rs->sbuf[rs->sbuf_size]) -
+ rs->ssgl[0].addr);
+}
+
+static void rs_send_credits(struct rsocket *rs)
+{
+ struct ibv_sge ibsge;
+ struct rs_sge sge, *sge_buf;
+ int flags;
+
+ rs->ctrl_seqno++;
+ rs->rseq_comp = rs->rseq_no + (rs->rq_size >> 1);
+ if (rs->rbuf_bytes_avail >= (rs->rbuf_size >> 1)) {
+ if (rs->opts & RS_OPT_MSG_SEND)
+ rs->ctrl_seqno++;
+
+ if (!(rs->opts & RS_OPT_SWAP_SGL)) {
+ sge.addr = (uintptr_t) &rs->rbuf[rs->rbuf_free_offset];
+ sge.key = rs->rmr->rkey;
+ sge.length = rs->rbuf_size >> 1;
+ } else {
+ sge.addr = bswap_64((uintptr_t) &rs->rbuf[rs->rbuf_free_offset]);
+ sge.key = bswap_32(rs->rmr->rkey);
+ sge.length = bswap_32(rs->rbuf_size >> 1);
+ }
+
+ if (rs->sq_inline < sizeof sge) {
+ sge_buf = rs_get_ctrl_buf(rs);
+ memcpy(sge_buf, &sge, sizeof sge);
+ ibsge.addr = (uintptr_t) sge_buf;
+ ibsge.lkey = rs->smr->lkey;
+ flags = 0;
+ } else {
+ ibsge.addr = (uintptr_t) &sge;
+ ibsge.lkey = 0;
+ flags = IBV_SEND_INLINE;
+ }
+ ibsge.length = sizeof(sge);
+
+ rs_post_write_msg(rs, &ibsge, 1,
+ rs_msg_set(RS_OP_SGL, rs->rseq_no + rs->rq_size), flags,
+ rs->remote_sgl.addr + rs->remote_sge * sizeof(struct rs_sge),
+ rs->remote_sgl.key);
+
+ rs->rbuf_bytes_avail -= rs->rbuf_size >> 1;
+ rs->rbuf_free_offset += rs->rbuf_size >> 1;
+ if (rs->rbuf_free_offset >= rs->rbuf_size)
+ rs->rbuf_free_offset = 0;
+ if (++rs->remote_sge == rs->remote_sgl.length)
+ rs->remote_sge = 0;
+ } else {
+ rs_post_msg(rs, rs_msg_set(RS_OP_SGL, rs->rseq_no + rs->rq_size));
+ }
+}
+
+static inline int rs_ctrl_avail(struct rsocket *rs)
+{
+ return rs->ctrl_seqno != rs->ctrl_max_seqno;
+}
+
+/* Protocols that do not support RDMA write with immediate may require 2 msgs */
+static inline int rs_2ctrl_avail(struct rsocket *rs)
+{
+ return (int)((rs->ctrl_seqno + 1) - rs->ctrl_max_seqno) < 0;
+}
+
+static int rs_give_credits(struct rsocket *rs)
+{
+ if (!(rs->opts & RS_OPT_MSG_SEND)) {
+ return ((rs->rbuf_bytes_avail >= (rs->rbuf_size >> 1)) ||
+ ((short) ((short) rs->rseq_no - (short) rs->rseq_comp) >= 0)) &&
+ rs_ctrl_avail(rs) && (rs->state & rs_connected);
+ } else {
+ return ((rs->rbuf_bytes_avail >= (rs->rbuf_size >> 1)) ||
+ ((short) ((short) rs->rseq_no - (short) rs->rseq_comp) >= 0)) &&
+ rs_2ctrl_avail(rs) && (rs->state & rs_connected);
+ }
+}
+
+static void rs_update_credits(struct rsocket *rs)
+{
+ if (rs_give_credits(rs))
+ rs_send_credits(rs);
+}
+
+static int rs_poll_cq(struct rsocket *rs)
+{
+ struct ibv_wc wc;
+ uint32_t msg;
+ int ret, rcnt = 0;
+
+ while ((ret = ibv_poll_cq(rs->cm_id->recv_cq, 1, &wc)) > 0) {
+ if (rs_wr_is_recv(wc.wr_id)) {
+ if (wc.status != IBV_WC_SUCCESS)
+ continue;
+ rcnt++;
+
+ if (wc.wc_flags & IBV_WC_WITH_IMM) {
+ msg = be32toh(wc.imm_data);
+ } else {
+ msg = ((uint32_t *) (rs->rbuf + rs->rbuf_size))
+ [rs_wr_data(wc.wr_id)];
+
+ }
+ switch (rs_msg_op(msg)) {
+ case RS_OP_SGL:
+ rs->sseq_comp = (uint16_t) rs_msg_data(msg);
+ break;
+ case RS_OP_IOMAP_SGL:
+ /* The iomap was updated, that's nice to know. */
+ break;
+ case RS_OP_CTRL:
+ if (rs_msg_data(msg) == RS_CTRL_DISCONNECT) {
+ rs->state = rs_disconnected;
+ return 0;
+ } else if (rs_msg_data(msg) == RS_CTRL_SHUTDOWN) {
+ if (rs->state & rs_writable) {
+ rs->state &= ~rs_readable;
+ } else {
+ rs->state = rs_disconnected;
+ return 0;
+ }
+ }
+ break;
+ case RS_OP_WRITE:
+ /* We really shouldn't be here. */
+ break;
+ default:
+ rs->rmsg[rs->rmsg_tail].op = rs_msg_op(msg);
+ rs->rmsg[rs->rmsg_tail].data = rs_msg_data(msg);
+ if (++rs->rmsg_tail == rs->rq_size + 1)
+ rs->rmsg_tail = 0;
+ break;
+ }
+ } else {
+ switch (rs_msg_op(rs_wr_data(wc.wr_id))) {
+ case RS_OP_SGL:
+ rs->ctrl_max_seqno++;
+ break;
+ case RS_OP_CTRL:
+ rs->ctrl_max_seqno++;
+ if (rs_msg_data(rs_wr_data(wc.wr_id)) == RS_CTRL_DISCONNECT)
+ rs->state = rs_disconnected;
+ break;
+ case RS_OP_IOMAP_SGL:
+ rs->sqe_avail++;
+ if (!rs_wr_is_msg_send(wc.wr_id))
+ rs->sbuf_bytes_avail += sizeof(struct rs_iomap);
+ break;
+ default:
+ rs->sqe_avail++;
+ rs->sbuf_bytes_avail += rs_msg_data(rs_wr_data(wc.wr_id));
+ break;
+ }
+ if (wc.status != IBV_WC_SUCCESS && (rs->state & rs_connected)) {
+ rs->state = rs_error;
+ rs->err = EIO;
+ }
+ }
+ }
+
+ if (rs->state & rs_connected) {
+ while (!ret && rcnt--)
+ ret = rs_post_recv(rs);
+
+ if (ret) {
+ rs->state = rs_error;
+ rs->err = errno;
+ }
+ }
+ return ret;
+}
+
+static int rs_get_cq_event(struct rsocket *rs)
+{
+ struct ibv_cq *cq;
+ void *context;
+ int ret;
+
+ if (!rs->cq_armed)
+ return 0;
+
+ ret = ibv_get_cq_event(rs->cm_id->recv_cq_channel, &cq, &context);
+ if (!ret) {
+ if (++rs->unack_cqe >= rs->sq_size + rs->rq_size) {
+ ibv_ack_cq_events(rs->cm_id->recv_cq, rs->unack_cqe);
+ rs->unack_cqe = 0;
+ }
+ rs->cq_armed = 0;
+ } else if (!(errno == EAGAIN || errno == EINTR)) {
+ rs->state = rs_error;
+ }
+
+ return ret;
+}
+
+/*
+ * Although we serialize rsend and rrecv calls with respect to themselves,
+ * both calls may run simultaneously and need to poll the CQ for completions.
+ * We need to serialize access to the CQ, but rsend and rrecv need to
+ * allow each other to make forward progress.
+ *
+ * For example, rsend may need to wait for credits from the remote side,
+ * which could be stalled until the remote process calls rrecv. This should
+ * not block rrecv from receiving data from the remote side however.
+ *
+ * We handle this by using two locks. The cq_lock protects against polling
+ * the CQ and processing completions. The cq_wait_lock serializes access to
+ * waiting on the CQ.
+ */
+static int rs_process_cq(struct rsocket *rs, int nonblock, int (*test)(struct rsocket *rs))
+{
+ int ret;
+
+ fastlock_acquire(&rs->cq_lock);
+ do {
+ rs_update_credits(rs);
+ ret = rs_poll_cq(rs);
+ if (test(rs)) {
+ ret = 0;
+ break;
+ } else if (ret) {
+ break;
+ } else if (nonblock) {
+ ret = ERR(EWOULDBLOCK);
+ } else if (!rs->cq_armed) {
+ ibv_req_notify_cq(rs->cm_id->recv_cq, 0);
+ rs->cq_armed = 1;
+ } else {
+ rs_update_credits(rs);
+ fastlock_acquire(&rs->cq_wait_lock);
+ fastlock_release(&rs->cq_lock);
+
+ ret = rs_get_cq_event(rs);
+ fastlock_release(&rs->cq_wait_lock);
+ fastlock_acquire(&rs->cq_lock);
+ }
+ } while (!ret);
+
+ rs_update_credits(rs);
+ fastlock_release(&rs->cq_lock);
+ return ret;
+}
+
+static int rs_get_comp(struct rsocket *rs, int nonblock, int (*test)(struct rsocket *rs))
+{
+ struct timeval s, e;
+ uint32_t poll_time = 0;
+ int ret;
+
+ do {
+ ret = rs_process_cq(rs, 1, test);
+ if (!ret || nonblock || errno != EWOULDBLOCK)
+ return ret;
+
+ if (!poll_time)
+ gettimeofday(&s, NULL);
+
+ gettimeofday(&e, NULL);
+ poll_time = (e.tv_sec - s.tv_sec) * 1000000 +
+ (e.tv_usec - s.tv_usec) + 1;
+ } while (poll_time <= polling_time);
+
+ ret = rs_process_cq(rs, 0, test);
+ return ret;
+}
+
+static int ds_valid_recv(struct ds_qp *qp, struct ibv_wc *wc)
+{
+ struct ds_header *hdr;
+
+ hdr = (struct ds_header *) (qp->rbuf + rs_wr_data(wc->wr_id));
+ return ((wc->byte_len >= sizeof(struct ibv_grh) + DS_IPV4_HDR_LEN) &&
+ ((hdr->version == 4 && hdr->length == DS_IPV4_HDR_LEN) ||
+ (hdr->version == 6 && hdr->length == DS_IPV6_HDR_LEN)));
+}
+
+/*
+ * Poll all CQs associated with a datagram rsocket. We need to drop any
+ * received messages that we do not have room to store. To limit drops,
+ * we only poll if we have room to store the receive or we need a send
+ * buffer. To ensure fairness, we poll the CQs round robin, remembering
+ * where we left off.
+ */
+static void ds_poll_cqs(struct rsocket *rs)
+{
+ struct ds_qp *qp;
+ struct ds_smsg *smsg;
+ struct ds_rmsg *rmsg;
+ struct ibv_wc wc;
+ int ret, cnt;
+
+ if (!(qp = rs->qp_list))
+ return;
+
+ do {
+ cnt = 0;
+ do {
+ ret = ibv_poll_cq(qp->cm_id->recv_cq, 1, &wc);
+ if (ret <= 0) {
+ qp = ds_next_qp(qp);
+ continue;
+ }
+
+ if (rs_wr_is_recv(wc.wr_id)) {
+ if (rs->rqe_avail && wc.status == IBV_WC_SUCCESS &&
+ ds_valid_recv(qp, &wc)) {
+ rs->rqe_avail--;
+ rmsg = &rs->dmsg[rs->rmsg_tail];
+ rmsg->qp = qp;
+ rmsg->offset = rs_wr_data(wc.wr_id);
+ rmsg->length = wc.byte_len - sizeof(struct ibv_grh);
+ if (++rs->rmsg_tail == rs->rq_size + 1)
+ rs->rmsg_tail = 0;
+ } else {
+ ds_post_recv(rs, qp, rs_wr_data(wc.wr_id));
+ }
+ } else {
+ smsg = (struct ds_smsg *) (rs->sbuf + rs_wr_data(wc.wr_id));
+ smsg->next = rs->smsg_free;
+ rs->smsg_free = smsg;
+ rs->sqe_avail++;
+ }
+
+ qp = ds_next_qp(qp);
+ if (!rs->rqe_avail && rs->sqe_avail) {
+ rs->qp_list = qp;
+ return;
+ }
+ cnt++;
+ } while (qp != rs->qp_list);
+ } while (cnt);
+}
+
+static void ds_req_notify_cqs(struct rsocket *rs)
+{
+ struct ds_qp *qp;
+
+ if (!(qp = rs->qp_list))
+ return;
+
+ do {
+ if (!qp->cq_armed) {
+ ibv_req_notify_cq(qp->cm_id->recv_cq, 0);
+ qp->cq_armed = 1;
+ }
+ qp = ds_next_qp(qp);
+ } while (qp != rs->qp_list);
+}
+
+static int ds_get_cq_event(struct rsocket *rs)
+{
+ struct epoll_event event;
+ struct ds_qp *qp;
+ struct ibv_cq *cq;
+ void *context;
+ int ret;
+
+ if (!rs->cq_armed)
+ return 0;
+
+ ret = epoll_wait(rs->epfd, &event, 1, -1);
+ if (ret <= 0)
+ return ret;
+
+ qp = event.data.ptr;
+ ret = ibv_get_cq_event(qp->cm_id->recv_cq_channel, &cq, &context);
+ if (!ret) {
+ ibv_ack_cq_events(qp->cm_id->recv_cq, 1);
+ qp->cq_armed = 0;
+ rs->cq_armed = 0;
+ }
+
+ return ret;
+}
+
+static int ds_process_cqs(struct rsocket *rs, int nonblock, int (*test)(struct rsocket *rs))
+{
+ int ret = 0;
+
+ fastlock_acquire(&rs->cq_lock);
+ do {
+ ds_poll_cqs(rs);
+ if (test(rs)) {
+ ret = 0;
+ break;
+ } else if (nonblock) {
+ ret = ERR(EWOULDBLOCK);
+ } else if (!rs->cq_armed) {
+ ds_req_notify_cqs(rs);
+ rs->cq_armed = 1;
+ } else {
+ fastlock_acquire(&rs->cq_wait_lock);
+ fastlock_release(&rs->cq_lock);
+
+ ret = ds_get_cq_event(rs);
+ fastlock_release(&rs->cq_wait_lock);
+ fastlock_acquire(&rs->cq_lock);
+ }
+ } while (!ret);
+
+ fastlock_release(&rs->cq_lock);
+ return ret;
+}
+
+static int ds_get_comp(struct rsocket *rs, int nonblock, int (*test)(struct rsocket *rs))
+{
+ struct timeval s, e;
+ uint32_t poll_time = 0;
+ int ret;
+
+ do {
+ ret = ds_process_cqs(rs, 1, test);
+ if (!ret || nonblock || errno != EWOULDBLOCK)
+ return ret;
+
+ if (!poll_time)
+ gettimeofday(&s, NULL);
+
+ gettimeofday(&e, NULL);
+ poll_time = (e.tv_sec - s.tv_sec) * 1000000 +
+ (e.tv_usec - s.tv_usec) + 1;
+ } while (poll_time <= polling_time);
+
+ ret = ds_process_cqs(rs, 0, test);
+ return ret;
+}
+
+static int rs_nonblocking(struct rsocket *rs, int flags)
+{
+ return (rs->fd_flags & O_NONBLOCK) || (flags & MSG_DONTWAIT);
+}
+
+static int rs_is_cq_armed(struct rsocket *rs)
+{
+ return rs->cq_armed;
+}
+
+static int rs_poll_all(struct rsocket *rs)
+{
+ return 1;
+}
+
+/*
+ * We use hardware flow control to prevent over running the remote
+ * receive queue. However, data transfers still require space in
+ * the remote rmsg queue, or we risk losing notification that data
+ * has been transfered.
+ *
+ * Be careful with race conditions in the check below. The target SGL
+ * may be updated by a remote RDMA write.
+ */
+static int rs_can_send(struct rsocket *rs)
+{
+ if (!(rs->opts & RS_OPT_MSG_SEND)) {
+ return rs->sqe_avail && (rs->sbuf_bytes_avail >= RS_SNDLOWAT) &&
+ (rs->sseq_no != rs->sseq_comp) &&
+ (rs->target_sgl[rs->target_sge].length != 0);
+ } else {
+ return (rs->sqe_avail >= 2) && (rs->sbuf_bytes_avail >= RS_SNDLOWAT) &&
+ (rs->sseq_no != rs->sseq_comp) &&
+ (rs->target_sgl[rs->target_sge].length != 0);
+ }
+}
+
+static int ds_can_send(struct rsocket *rs)
+{
+ return rs->sqe_avail;
+}
+
+static int ds_all_sends_done(struct rsocket *rs)
+{
+ return rs->sqe_avail == rs->sq_size;
+}
+
+static int rs_conn_can_send(struct rsocket *rs)
+{
+ return rs_can_send(rs) || !(rs->state & rs_writable);
+}
+
+static int rs_conn_can_send_ctrl(struct rsocket *rs)
+{
+ return rs_ctrl_avail(rs) || !(rs->state & rs_connected);
+}
+
+static int rs_have_rdata(struct rsocket *rs)
+{
+ return (rs->rmsg_head != rs->rmsg_tail);
+}
+
+static int rs_conn_have_rdata(struct rsocket *rs)
+{
+ return rs_have_rdata(rs) || !(rs->state & rs_readable);
+}
+
+static int rs_conn_all_sends_done(struct rsocket *rs)
+{
+ return ((((int) rs->ctrl_max_seqno) - ((int) rs->ctrl_seqno)) +
+ rs->sqe_avail == rs->sq_size) ||
+ !(rs->state & rs_connected);
+}
+
+static void ds_set_src(struct sockaddr *addr, socklen_t *addrlen,
+ struct ds_header *hdr)
+{
+ union socket_addr sa;
+
+ memset(&sa, 0, sizeof sa);
+ if (hdr->version == 4) {
+ if (*addrlen > sizeof(sa.sin))
+ *addrlen = sizeof(sa.sin);
+
+ sa.sin.sin_family = AF_INET;
+ sa.sin.sin_port = hdr->port;
+ sa.sin.sin_addr.s_addr = hdr->addr.ipv4;
+ } else {
+ if (*addrlen > sizeof(sa.sin6))
+ *addrlen = sizeof(sa.sin6);
+
+ sa.sin6.sin6_family = AF_INET6;
+ sa.sin6.sin6_port = hdr->port;
+ sa.sin6.sin6_flowinfo = hdr->addr.ipv6.flowinfo;
+ memcpy(&sa.sin6.sin6_addr, &hdr->addr.ipv6.addr, 16);
+ }
+ memcpy(addr, &sa, *addrlen);
+}
+
+static ssize_t ds_recvfrom(struct rsocket *rs, void *buf, size_t len, int flags,
+ struct sockaddr *src_addr, socklen_t *addrlen)
+{
+ struct ds_rmsg *rmsg;
+ struct ds_header *hdr;
+ int ret;
+
+ if (!(rs->state & rs_readable))
+ return ERR(EINVAL);
+
+ if (!rs_have_rdata(rs)) {
+ ret = ds_get_comp(rs, rs_nonblocking(rs, flags),
+ rs_have_rdata);
+ if (ret)
+ return ret;
+ }
+
+ rmsg = &rs->dmsg[rs->rmsg_head];
+ hdr = (struct ds_header *) (rmsg->qp->rbuf + rmsg->offset);
+ if (len > rmsg->length - hdr->length)
+ len = rmsg->length - hdr->length;
+
+ memcpy(buf, (void *) hdr + hdr->length, len);
+ if (addrlen)
+ ds_set_src(src_addr, addrlen, hdr);
+
+ if (!(flags & MSG_PEEK)) {
+ ds_post_recv(rs, rmsg->qp, rmsg->offset);
+ if (++rs->rmsg_head == rs->rq_size + 1)
+ rs->rmsg_head = 0;
+ rs->rqe_avail++;
+ }
+
+ return len;
+}
+
+static ssize_t rs_peek(struct rsocket *rs, void *buf, size_t len)
+{
+ size_t left = len;
+ uint32_t end_size, rsize;
+ int rmsg_head, rbuf_offset;
+
+ rmsg_head = rs->rmsg_head;
+ rbuf_offset = rs->rbuf_offset;
+
+ for (; left && (rmsg_head != rs->rmsg_tail); left -= rsize) {
+ if (left < rs->rmsg[rmsg_head].data) {
+ rsize = left;
+ } else {
+ rsize = rs->rmsg[rmsg_head].data;
+ if (++rmsg_head == rs->rq_size + 1)
+ rmsg_head = 0;
+ }
+
+ end_size = rs->rbuf_size - rbuf_offset;
+ if (rsize > end_size) {
+ memcpy(buf, &rs->rbuf[rbuf_offset], end_size);
+ rbuf_offset = 0;
+ buf += end_size;
+ rsize -= end_size;
+ left -= end_size;
+ }
+ memcpy(buf, &rs->rbuf[rbuf_offset], rsize);
+ rbuf_offset += rsize;
+ buf += rsize;
+ }
+
+ return len - left;
+}
+
+/*
+ * Continue to receive any queued data even if the remote side has disconnected.
+ */
+ssize_t rrecv(int socket, void *buf, size_t len, int flags)
+{
+ struct rsocket *rs;
+ size_t left = len;
+ uint32_t end_size, rsize;
+ int ret = 0;
+
+ rs = idm_at(&idm, socket);
+ if (rs->type == SOCK_DGRAM) {
+ fastlock_acquire(&rs->rlock);
+ ret = ds_recvfrom(rs, buf, len, flags, NULL, NULL);
+ fastlock_release(&rs->rlock);
+ return ret;
+ }
+
+ if (rs->state & rs_opening) {
+ ret = rs_do_connect(rs);
+ if (ret) {
+ if (errno == EINPROGRESS)
+ errno = EAGAIN;
+ return ret;
+ }
+ }
+ fastlock_acquire(&rs->rlock);
+ do {
+ if (!rs_have_rdata(rs)) {
+ ret = rs_get_comp(rs, rs_nonblocking(rs, flags),
+ rs_conn_have_rdata);
+ if (ret)
+ break;
+ }
+
+ if (flags & MSG_PEEK) {
+ left = len - rs_peek(rs, buf, left);
+ break;
+ }
+
+ for (; left && rs_have_rdata(rs); left -= rsize) {
+ if (left < rs->rmsg[rs->rmsg_head].data) {
+ rsize = left;
+ rs->rmsg[rs->rmsg_head].data -= left;
+ } else {
+ rs->rseq_no++;
+ rsize = rs->rmsg[rs->rmsg_head].data;
+ if (++rs->rmsg_head == rs->rq_size + 1)
+ rs->rmsg_head = 0;
+ }
+
+ end_size = rs->rbuf_size - rs->rbuf_offset;
+ if (rsize > end_size) {
+ memcpy(buf, &rs->rbuf[rs->rbuf_offset], end_size);
+ rs->rbuf_offset = 0;
+ buf += end_size;
+ rsize -= end_size;
+ left -= end_size;
+ rs->rbuf_bytes_avail += end_size;
+ }
+ memcpy(buf, &rs->rbuf[rs->rbuf_offset], rsize);
+ rs->rbuf_offset += rsize;
+ buf += rsize;
+ rs->rbuf_bytes_avail += rsize;
+ }
+
+ } while (left && (flags & MSG_WAITALL) && (rs->state & rs_readable));
+
+ fastlock_release(&rs->rlock);
+ return (ret && left == len) ? ret : len - left;
+}
+
+ssize_t rrecvfrom(int socket, void *buf, size_t len, int flags,
+ struct sockaddr *src_addr, socklen_t *addrlen)
+{
+ struct rsocket *rs;
+ int ret;
+
+ rs = idm_at(&idm, socket);
+ if (rs->type == SOCK_DGRAM) {
+ fastlock_acquire(&rs->rlock);
+ ret = ds_recvfrom(rs, buf, len, flags, src_addr, addrlen);
+ fastlock_release(&rs->rlock);
+ return ret;
+ }
+
+ ret = rrecv(socket, buf, len, flags);
+ if (ret > 0 && src_addr)
+ rgetpeername(socket, src_addr, addrlen);
+
+ return ret;
+}
+
+/*
+ * Simple, straightforward implementation for now that only tries to fill
+ * in the first vector.
+ */
+static ssize_t rrecvv(int socket, const struct iovec *iov, int iovcnt, int flags)
+{
+ return rrecv(socket, iov[0].iov_base, iov[0].iov_len, flags);
+}
+
+ssize_t rrecvmsg(int socket, struct msghdr *msg, int flags)
+{
+ if (msg->msg_control && msg->msg_controllen)
+ return ERR(ENOTSUP);
+
+ return rrecvv(socket, msg->msg_iov, (int) msg->msg_iovlen, msg->msg_flags);
+}
+
+ssize_t rread(int socket, void *buf, size_t count)
+{
+ return rrecv(socket, buf, count, 0);
+}
+
+ssize_t rreadv(int socket, const struct iovec *iov, int iovcnt)
+{
+ return rrecvv(socket, iov, iovcnt, 0);
+}
+
+static int rs_send_iomaps(struct rsocket *rs, int flags)
+{
+ struct rs_iomap_mr *iomr;
+ struct ibv_sge sge;
+ struct rs_iomap iom;
+ int ret;
+
+ fastlock_acquire(&rs->map_lock);
+ while (!dlist_empty(&rs->iomap_queue)) {
+ if (!rs_can_send(rs)) {
+ ret = rs_get_comp(rs, rs_nonblocking(rs, flags),
+ rs_conn_can_send);
+ if (ret)
+ break;
+ if (!(rs->state & rs_writable)) {
+ ret = ERR(ECONNRESET);
+ break;
+ }
+ }
+
+ iomr = container_of(rs->iomap_queue.next, struct rs_iomap_mr, entry);
+ if (!(rs->opts & RS_OPT_SWAP_SGL)) {
+ iom.offset = iomr->offset;
+ iom.sge.addr = (uintptr_t) iomr->mr->addr;
+ iom.sge.length = iomr->mr->length;
+ iom.sge.key = iomr->mr->rkey;
+ } else {
+ iom.offset = bswap_64(iomr->offset);
+ iom.sge.addr = bswap_64((uintptr_t) iomr->mr->addr);
+ iom.sge.length = bswap_32(iomr->mr->length);
+ iom.sge.key = bswap_32(iomr->mr->rkey);
+ }
+
+ if (rs->sq_inline >= sizeof iom) {
+ sge.addr = (uintptr_t) &iom;
+ sge.length = sizeof iom;
+ sge.lkey = 0;
+ ret = rs_write_iomap(rs, iomr, &sge, 1, IBV_SEND_INLINE);
+ } else if (rs_sbuf_left(rs) >= sizeof iom) {
+ memcpy((void *) (uintptr_t) rs->ssgl[0].addr, &iom, sizeof iom);
+ rs->ssgl[0].length = sizeof iom;
+ ret = rs_write_iomap(rs, iomr, rs->ssgl, 1, 0);
+ if (rs_sbuf_left(rs) > sizeof iom)
+ rs->ssgl[0].addr += sizeof iom;
+ else
+ rs->ssgl[0].addr = (uintptr_t) rs->sbuf;
+ } else {
+ rs->ssgl[0].length = rs_sbuf_left(rs);
+ memcpy((void *) (uintptr_t) rs->ssgl[0].addr, &iom,
+ rs->ssgl[0].length);
+ rs->ssgl[1].length = sizeof iom - rs->ssgl[0].length;
+ memcpy(rs->sbuf, ((void *) &iom) + rs->ssgl[0].length,
+ rs->ssgl[1].length);
+ ret = rs_write_iomap(rs, iomr, rs->ssgl, 2, 0);
+ rs->ssgl[0].addr = (uintptr_t) rs->sbuf + rs->ssgl[1].length;
+ }
+ dlist_remove(&iomr->entry);
+ dlist_insert_tail(&iomr->entry, &rs->iomap_list);
+ if (ret)
+ break;
+ }
+
+ rs->iomap_pending = !dlist_empty(&rs->iomap_queue);
+ fastlock_release(&rs->map_lock);
+ return ret;
+}
+
+static ssize_t ds_sendv_udp(struct rsocket *rs, const struct iovec *iov,
+ int iovcnt, int flags, uint8_t op)
+{
+ struct ds_udp_header hdr;
+ struct msghdr msg;
+ struct iovec miov[8];
+ ssize_t ret;
+
+ if (iovcnt > 8)
+ return ERR(ENOTSUP);
+
+ hdr.tag = htobe32(DS_UDP_TAG);
+ hdr.version = rs->conn_dest->qp->hdr.version;
+ hdr.op = op;
+ hdr.reserved = 0;
+ hdr.qpn = htobe32(rs->conn_dest->qp->cm_id->qp->qp_num & 0xFFFFFF);
+ if (rs->conn_dest->qp->hdr.version == 4) {
+ hdr.length = DS_UDP_IPV4_HDR_LEN;
+ hdr.addr.ipv4 = rs->conn_dest->qp->hdr.addr.ipv4;
+ } else {
+ hdr.length = DS_UDP_IPV6_HDR_LEN;
+ memcpy(hdr.addr.ipv6, &rs->conn_dest->qp->hdr.addr.ipv6, 16);
+ }
+
+ miov[0].iov_base = &hdr;
+ miov[0].iov_len = hdr.length;
+ if (iov && iovcnt)
+ memcpy(&miov[1], iov, sizeof(*iov) * iovcnt);
+
+ memset(&msg, 0, sizeof msg);
+ msg.msg_name = &rs->conn_dest->addr;
+ msg.msg_namelen = ucma_addrlen(&rs->conn_dest->addr.sa);
+ msg.msg_iov = miov;
+ msg.msg_iovlen = iovcnt + 1;
+ ret = sendmsg(rs->udp_sock, &msg, flags);
+ return ret > 0 ? ret - hdr.length : ret;
+}
+
+static ssize_t ds_send_udp(struct rsocket *rs, const void *buf, size_t len,
+ int flags, uint8_t op)
+{
+ struct iovec iov;
+ if (buf && len) {
+ iov.iov_base = (void *) buf;
+ iov.iov_len = len;
+ return ds_sendv_udp(rs, &iov, 1, flags, op);
+ } else {
+ return ds_sendv_udp(rs, NULL, 0, flags, op);
+ }
+}
+
+static ssize_t dsend(struct rsocket *rs, const void *buf, size_t len, int flags)
+{
+ struct ds_smsg *msg;
+ struct ibv_sge sge;
+ uint64_t offset;
+ int ret = 0;
+
+ if (!rs->conn_dest->ah)
+ return ds_send_udp(rs, buf, len, flags, RS_OP_DATA);
+
+ if (!ds_can_send(rs)) {
+ ret = ds_get_comp(rs, rs_nonblocking(rs, flags), ds_can_send);
+ if (ret)
+ return ret;
+ }
+
+ msg = rs->smsg_free;
+ rs->smsg_free = msg->next;
+ rs->sqe_avail--;
+
+ memcpy((void *) msg, &rs->conn_dest->qp->hdr, rs->conn_dest->qp->hdr.length);
+ memcpy((void *) msg + rs->conn_dest->qp->hdr.length, buf, len);
+ sge.addr = (uintptr_t) msg;
+ sge.length = rs->conn_dest->qp->hdr.length + len;
+ sge.lkey = rs->conn_dest->qp->smr->lkey;
+ offset = (uint8_t *) msg - rs->sbuf;
+
+ ret = ds_post_send(rs, &sge, offset);
+ return ret ? ret : len;
+}
+
+/*
+ * We overlap sending the data, by posting a small work request immediately,
+ * then increasing the size of the send on each iteration.
+ */
+ssize_t rsend(int socket, const void *buf, size_t len, int flags)
+{
+ struct rsocket *rs;
+ struct ibv_sge sge;
+ size_t left = len;
+ uint32_t xfer_size, olen = RS_OLAP_START_SIZE;
+ int ret = 0;
+
+ rs = idm_at(&idm, socket);
+ if (rs->type == SOCK_DGRAM) {
+ fastlock_acquire(&rs->slock);
+ ret = dsend(rs, buf, len, flags);
+ fastlock_release(&rs->slock);
+ return ret;
+ }
+
+ if (rs->state & rs_opening) {
+ ret = rs_do_connect(rs);
+ if (ret) {
+ if (errno == EINPROGRESS)
+ errno = EAGAIN;
+ return ret;
+ }
+ }
+
+ fastlock_acquire(&rs->slock);
+ if (rs->iomap_pending) {
+ ret = rs_send_iomaps(rs, flags);
+ if (ret)
+ goto out;
+ }
+ for (; left; left -= xfer_size, buf += xfer_size) {
+ if (!rs_can_send(rs)) {
+ ret = rs_get_comp(rs, rs_nonblocking(rs, flags),
+ rs_conn_can_send);
+ if (ret)
+ break;
+ if (!(rs->state & rs_writable)) {
+ ret = ERR(ECONNRESET);
+ break;
+ }
+ }
+
+ if (olen < left) {
+ xfer_size = olen;
+ if (olen < RS_MAX_TRANSFER)
+ olen <<= 1;
+ } else {
+ xfer_size = left;
+ }
+
+ if (xfer_size > rs->sbuf_bytes_avail)
+ xfer_size = rs->sbuf_bytes_avail;
+ if (xfer_size > rs->target_sgl[rs->target_sge].length)
+ xfer_size = rs->target_sgl[rs->target_sge].length;
+
+ if (xfer_size <= rs->sq_inline) {
+ sge.addr = (uintptr_t) buf;
+ sge.length = xfer_size;
+ sge.lkey = 0;
+ ret = rs_write_data(rs, &sge, 1, xfer_size, IBV_SEND_INLINE);
+ } else if (xfer_size <= rs_sbuf_left(rs)) {
+ memcpy((void *) (uintptr_t) rs->ssgl[0].addr, buf, xfer_size);
+ rs->ssgl[0].length = xfer_size;
+ ret = rs_write_data(rs, rs->ssgl, 1, xfer_size, 0);
+ if (xfer_size < rs_sbuf_left(rs))
+ rs->ssgl[0].addr += xfer_size;
+ else
+ rs->ssgl[0].addr = (uintptr_t) rs->sbuf;
+ } else {
+ rs->ssgl[0].length = rs_sbuf_left(rs);
+ memcpy((void *) (uintptr_t) rs->ssgl[0].addr, buf,
+ rs->ssgl[0].length);
+ rs->ssgl[1].length = xfer_size - rs->ssgl[0].length;
+ memcpy(rs->sbuf, buf + rs->ssgl[0].length, rs->ssgl[1].length);
+ ret = rs_write_data(rs, rs->ssgl, 2, xfer_size, 0);
+ rs->ssgl[0].addr = (uintptr_t) rs->sbuf + rs->ssgl[1].length;
+ }
+ if (ret)
+ break;
+ }
+out:
+ fastlock_release(&rs->slock);
+
+ return (ret && left == len) ? ret : len - left;
+}
+
+ssize_t rsendto(int socket, const void *buf, size_t len, int flags,
+ const struct sockaddr *dest_addr, socklen_t addrlen)
+{
+ struct rsocket *rs;
+ int ret;
+
+ rs = idm_at(&idm, socket);
+ if (rs->type == SOCK_STREAM) {
+ if (dest_addr || addrlen)
+ return ERR(EISCONN);
+
+ return rsend(socket, buf, len, flags);
+ }
+
+ if (rs->state == rs_init) {
+ ret = ds_init_ep(rs);
+ if (ret)
+ return ret;
+ }
+
+ fastlock_acquire(&rs->slock);
+ if (!rs->conn_dest || ds_compare_addr(dest_addr, &rs->conn_dest->addr)) {
+ ret = ds_get_dest(rs, dest_addr, addrlen, &rs->conn_dest);
+ if (ret)
+ goto out;
+ }
+
+ ret = dsend(rs, buf, len, flags);
+out:
+ fastlock_release(&rs->slock);
+ return ret;
+}
+
+static void rs_copy_iov(void *dst, const struct iovec **iov, size_t *offset, size_t len)
+{
+ size_t size;
+
+ while (len) {
+ size = (*iov)->iov_len - *offset;
+ if (size > len) {
+ memcpy (dst, (*iov)->iov_base + *offset, len);
+ *offset += len;
+ break;
+ }
+
+ memcpy(dst, (*iov)->iov_base + *offset, size);
+ len -= size;
+ dst += size;
+ (*iov)++;
+ *offset = 0;
+ }
+}
+
+static ssize_t rsendv(int socket, const struct iovec *iov, int iovcnt, int flags)
+{
+ struct rsocket *rs;
+ const struct iovec *cur_iov;
+ size_t left, len, offset = 0;
+ uint32_t xfer_size, olen = RS_OLAP_START_SIZE;
+ int i, ret = 0;
+
+ rs = idm_at(&idm, socket);
+ if (rs->state & rs_opening) {
+ ret = rs_do_connect(rs);
+ if (ret) {
+ if (errno == EINPROGRESS)
+ errno = EAGAIN;
+ return ret;
+ }
+ }
+
+ cur_iov = iov;
+ len = iov[0].iov_len;
+ for (i = 1; i < iovcnt; i++)
+ len += iov[i].iov_len;
+ left = len;
+
+ fastlock_acquire(&rs->slock);
+ if (rs->iomap_pending) {
+ ret = rs_send_iomaps(rs, flags);
+ if (ret)
+ goto out;
+ }
+ for (; left; left -= xfer_size) {
+ if (!rs_can_send(rs)) {
+ ret = rs_get_comp(rs, rs_nonblocking(rs, flags),
+ rs_conn_can_send);
+ if (ret)
+ break;
+ if (!(rs->state & rs_writable)) {
+ ret = ERR(ECONNRESET);
+ break;
+ }
+ }
+
+ if (olen < left) {
+ xfer_size = olen;
+ if (olen < RS_MAX_TRANSFER)
+ olen <<= 1;
+ } else {
+ xfer_size = left;
+ }
+
+ if (xfer_size > rs->sbuf_bytes_avail)
+ xfer_size = rs->sbuf_bytes_avail;
+ if (xfer_size > rs->target_sgl[rs->target_sge].length)
+ xfer_size = rs->target_sgl[rs->target_sge].length;
+
+ if (xfer_size <= rs_sbuf_left(rs)) {
+ rs_copy_iov((void *) (uintptr_t) rs->ssgl[0].addr,
+ &cur_iov, &offset, xfer_size);
+ rs->ssgl[0].length = xfer_size;
+ ret = rs_write_data(rs, rs->ssgl, 1, xfer_size,
+ xfer_size <= rs->sq_inline ? IBV_SEND_INLINE : 0);
+ if (xfer_size < rs_sbuf_left(rs))
+ rs->ssgl[0].addr += xfer_size;
+ else
+ rs->ssgl[0].addr = (uintptr_t) rs->sbuf;
+ } else {
+ rs->ssgl[0].length = rs_sbuf_left(rs);
+ rs_copy_iov((void *) (uintptr_t) rs->ssgl[0].addr, &cur_iov,
+ &offset, rs->ssgl[0].length);
+ rs->ssgl[1].length = xfer_size - rs->ssgl[0].length;
+ rs_copy_iov(rs->sbuf, &cur_iov, &offset, rs->ssgl[1].length);
+ ret = rs_write_data(rs, rs->ssgl, 2, xfer_size,
+ xfer_size <= rs->sq_inline ? IBV_SEND_INLINE : 0);
+ rs->ssgl[0].addr = (uintptr_t) rs->sbuf + rs->ssgl[1].length;
+ }
+ if (ret)
+ break;
+ }
+out:
+ fastlock_release(&rs->slock);
+
+ return (ret && left == len) ? ret : len - left;
+}
+
+ssize_t rsendmsg(int socket, const struct msghdr *msg, int flags)
+{
+ if (msg->msg_control && msg->msg_controllen)
+ return ERR(ENOTSUP);
+
+ return rsendv(socket, msg->msg_iov, (int) msg->msg_iovlen, flags);
+}
+
+ssize_t rwrite(int socket, const void *buf, size_t count)
+{
+ return rsend(socket, buf, count, 0);
+}
+
+ssize_t rwritev(int socket, const struct iovec *iov, int iovcnt)
+{
+ return rsendv(socket, iov, iovcnt, 0);
+}
+
+static struct pollfd *rs_fds_alloc(nfds_t nfds)
+{
+ static __thread struct pollfd *rfds;
+ static __thread nfds_t rnfds;
+
+ if (nfds > rnfds) {
+ if (rfds)
+ free(rfds);
+
+ rfds = malloc(sizeof(*rfds) * nfds);
+ rnfds = rfds ? nfds : 0;
+ }
+
+ return rfds;
+}
+
+static int rs_poll_rs(struct rsocket *rs, int events,
+ int nonblock, int (*test)(struct rsocket *rs))
+{
+ struct pollfd fds;
+ short revents;
+ int ret;
+
+check_cq:
+ if ((rs->type == SOCK_STREAM) && ((rs->state & rs_connected) ||
+ (rs->state == rs_disconnected) || (rs->state & rs_error))) {
+ rs_process_cq(rs, nonblock, test);
+
+ revents = 0;
+ if ((events & POLLIN) && rs_conn_have_rdata(rs))
+ revents |= POLLIN;
+ if ((events & POLLOUT) && rs_can_send(rs))
+ revents |= POLLOUT;
+ if (!(rs->state & rs_connected)) {
+ if (rs->state == rs_disconnected)
+ revents |= POLLHUP;
+ else
+ revents |= POLLERR;
+ }
+
+ return revents;
+ } else if (rs->type == SOCK_DGRAM) {
+ ds_process_cqs(rs, nonblock, test);
+
+ revents = 0;
+ if ((events & POLLIN) && rs_have_rdata(rs))
+ revents |= POLLIN;
+ if ((events & POLLOUT) && ds_can_send(rs))
+ revents |= POLLOUT;
+
+ return revents;
+ }
+
+ if (rs->state == rs_listening) {
+ fds.fd = rs->cm_id->channel->fd;
+ fds.events = events;
+ fds.revents = 0;
+ poll(&fds, 1, 0);
+ return fds.revents;
+ }
+
+ if (rs->state & rs_opening) {
+ ret = rs_do_connect(rs);
+ if (ret && (errno == EINPROGRESS)) {
+ errno = 0;
+ } else {
+ goto check_cq;
+ }
+ }
+
+ if (rs->state == rs_connect_error) {
+ revents = 0;
+ if (events & POLLOUT)
+ revents |= POLLOUT;
+ if (events & POLLIN)
+ revents |= POLLIN;
+ revents |= POLLERR;
+ return revents;
+ }
+
+ return 0;
+}
+
+static int rs_poll_check(struct pollfd *fds, nfds_t nfds)
+{
+ struct rsocket *rs;
+ int i, cnt = 0;
+
+ for (i = 0; i < nfds; i++) {
+ rs = idm_lookup(&idm, fds[i].fd);
+ if (rs)
+ fds[i].revents = rs_poll_rs(rs, fds[i].events, 1, rs_poll_all);
+ else
+ poll(&fds[i], 1, 0);
+
+ if (fds[i].revents)
+ cnt++;
+ }
+ return cnt;
+}
+
+static int rs_poll_arm(struct pollfd *rfds, struct pollfd *fds, nfds_t nfds)
+{
+ struct rsocket *rs;
+ int i;
+
+ for (i = 0; i < nfds; i++) {
+ rs = idm_lookup(&idm, fds[i].fd);
+ if (rs) {
+ fds[i].revents = rs_poll_rs(rs, fds[i].events, 0, rs_is_cq_armed);
+ if (fds[i].revents)
+ return 1;
+
+ if (rs->type == SOCK_STREAM) {
+ if (rs->state >= rs_connected)
+ rfds[i].fd = rs->cm_id->recv_cq_channel->fd;
+ else
+ rfds[i].fd = rs->cm_id->channel->fd;
+ } else {
+ rfds[i].fd = rs->epfd;
+ }
+ rfds[i].events = POLLIN;
+ } else {
+ rfds[i].fd = fds[i].fd;
+ rfds[i].events = fds[i].events;
+ }
+ rfds[i].revents = 0;
+ }
+ return 0;
+}
+
+static int rs_poll_events(struct pollfd *rfds, struct pollfd *fds, nfds_t nfds)
+{
+ struct rsocket *rs;
+ int i, cnt = 0;
+
+ for (i = 0; i < nfds; i++) {
+ if (!rfds[i].revents)
+ continue;
+
+ rs = idm_lookup(&idm, fds[i].fd);
+ if (rs) {
+ fastlock_acquire(&rs->cq_wait_lock);
+ if (rs->type == SOCK_STREAM)
+ rs_get_cq_event(rs);
+ else
+ ds_get_cq_event(rs);
+ fastlock_release(&rs->cq_wait_lock);
+ fds[i].revents = rs_poll_rs(rs, fds[i].events, 1, rs_poll_all);
+ } else {
+ fds[i].revents = rfds[i].revents;
+ }
+ if (fds[i].revents)
+ cnt++;
+ }
+ return cnt;
+}
+
+/*
+ * We need to poll *all* fd's that the user specifies at least once.
+ * Note that we may receive events on an rsocket that may not be reported
+ * to the user (e.g. connection events or credit updates). Process those
+ * events, then return to polling until we find ones of interest.
+ */
+int rpoll(struct pollfd *fds, nfds_t nfds, int timeout)
+{
+ struct timeval s, e;
+ struct pollfd *rfds;
+ uint32_t poll_time = 0;
+ int ret;
+
+ do {
+ ret = rs_poll_check(fds, nfds);
+ if (ret || !timeout)
+ return ret;
+
+ if (!poll_time)
+ gettimeofday(&s, NULL);
+
+ gettimeofday(&e, NULL);
+ poll_time = (e.tv_sec - s.tv_sec) * 1000000 +
+ (e.tv_usec - s.tv_usec) + 1;
+ } while (poll_time <= polling_time);
+
+ rfds = rs_fds_alloc(nfds);
+ if (!rfds)
+ return ERR(ENOMEM);
+
+ do {
+ ret = rs_poll_arm(rfds, fds, nfds);
+ if (ret)
+ break;
+
+ ret = poll(rfds, nfds, timeout);
+ if (ret <= 0)
+ break;
+
+ ret = rs_poll_events(rfds, fds, nfds);
+ } while (!ret);
+
+ return ret;
+}
+
+static struct pollfd *
+rs_select_to_poll(int *nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds)
+{
+ struct pollfd *fds;
+ int fd, i = 0;
+
+ fds = calloc(*nfds, sizeof(*fds));
+ if (!fds)
+ return NULL;
+
+ for (fd = 0; fd < *nfds; fd++) {
+ if (readfds && FD_ISSET(fd, readfds)) {
+ fds[i].fd = fd;
+ fds[i].events = POLLIN;
+ }
+
+ if (writefds && FD_ISSET(fd, writefds)) {
+ fds[i].fd = fd;
+ fds[i].events |= POLLOUT;
+ }
+
+ if (exceptfds && FD_ISSET(fd, exceptfds))
+ fds[i].fd = fd;
+
+ if (fds[i].fd)
+ i++;
+ }
+
+ *nfds = i;
+ return fds;
+}
+
+static int
+rs_poll_to_select(int nfds, struct pollfd *fds, fd_set *readfds,
+ fd_set *writefds, fd_set *exceptfds)
+{
+ int i, cnt = 0;
+
+ for (i = 0; i < nfds; i++) {
+ if (readfds && (fds[i].revents & (POLLIN | POLLHUP))) {
+ FD_SET(fds[i].fd, readfds);
+ cnt++;
+ }
+
+ if (writefds && (fds[i].revents & POLLOUT)) {
+ FD_SET(fds[i].fd, writefds);
+ cnt++;
+ }
+
+ if (exceptfds && (fds[i].revents & ~(POLLIN | POLLOUT))) {
+ FD_SET(fds[i].fd, exceptfds);
+ cnt++;
+ }
+ }
+ return cnt;
+}
+
+static int rs_convert_timeout(struct timeval *timeout)
+{
+ return !timeout ? -1 :
+ timeout->tv_sec * 1000 + timeout->tv_usec / 1000;
+}
+
+int rselect(int nfds, fd_set *readfds, fd_set *writefds,
+ fd_set *exceptfds, struct timeval *timeout)
+{
+ struct pollfd *fds;
+ int ret;
+
+ fds = rs_select_to_poll(&nfds, readfds, writefds, exceptfds);
+ if (!fds)
+ return ERR(ENOMEM);
+
+ ret = rpoll(fds, nfds, rs_convert_timeout(timeout));
+
+ if (readfds)
+ FD_ZERO(readfds);
+ if (writefds)
+ FD_ZERO(writefds);
+ if (exceptfds)
+ FD_ZERO(exceptfds);
+
+ if (ret > 0)
+ ret = rs_poll_to_select(nfds, fds, readfds, writefds, exceptfds);
+
+ free(fds);
+ return ret;
+}
+
+/*
+ * For graceful disconnect, notify the remote side that we're
+ * disconnecting and wait until all outstanding sends complete, provided
+ * that the remote side has not sent a disconnect message.
+ */
+int rshutdown(int socket, int how)
+{
+ struct rsocket *rs;
+ int ctrl, ret = 0;
+
+ rs = idm_lookup(&idm, socket);
+ if (!rs)
+ return ERR(EBADF);
+ if (rs->opts & RS_OPT_SVC_ACTIVE)
+ rs_notify_svc(&tcp_svc, rs, RS_SVC_REM_KEEPALIVE);
+
+ if (rs->fd_flags & O_NONBLOCK)
+ rs_set_nonblocking(rs, 0);
+
+ if (rs->state & rs_connected) {
+ if (how == SHUT_RDWR) {
+ ctrl = RS_CTRL_DISCONNECT;
+ rs->state &= ~(rs_readable | rs_writable);
+ } else if (how == SHUT_WR) {
+ rs->state &= ~rs_writable;
+ ctrl = (rs->state & rs_readable) ?
+ RS_CTRL_SHUTDOWN : RS_CTRL_DISCONNECT;
+ } else {
+ rs->state &= ~rs_readable;
+ if (rs->state & rs_writable)
+ goto out;
+ ctrl = RS_CTRL_DISCONNECT;
+ }
+ if (!rs_ctrl_avail(rs)) {
+ ret = rs_process_cq(rs, 0, rs_conn_can_send_ctrl);
+ if (ret)
+ goto out;
+ }
+
+ if ((rs->state & rs_connected) && rs_ctrl_avail(rs)) {
+ rs->ctrl_seqno++;
+ ret = rs_post_msg(rs, rs_msg_set(RS_OP_CTRL, ctrl));
+ }
+ }
+
+ if (rs->state & rs_connected)
+ rs_process_cq(rs, 0, rs_conn_all_sends_done);
+
+out:
+ if ((rs->fd_flags & O_NONBLOCK) && (rs->state & rs_connected))
+ rs_set_nonblocking(rs, rs->fd_flags);
+
+ if (rs->state & rs_disconnected) {
+ /* Generate event by flushing receives to unblock rpoll */
+ ibv_req_notify_cq(rs->cm_id->recv_cq, 0);
+ ucma_shutdown(rs->cm_id);
+ }
+
+ return ret;
+}
+
+static void ds_shutdown(struct rsocket *rs)
+{
+ if (rs->opts & RS_OPT_SVC_ACTIVE)
+ rs_notify_svc(&udp_svc, rs, RS_SVC_REM_DGRAM);
+
+ if (rs->fd_flags & O_NONBLOCK)
+ rs_set_nonblocking(rs, 0);
+
+ rs->state &= ~(rs_readable | rs_writable);
+ ds_process_cqs(rs, 0, ds_all_sends_done);
+
+ if (rs->fd_flags & O_NONBLOCK)
+ rs_set_nonblocking(rs, rs->fd_flags);
+}
+
+int rclose(int socket)
+{
+ struct rsocket *rs;
+
+ rs = idm_lookup(&idm, socket);
+ if (!rs)
+ return EBADF;
+ if (rs->type == SOCK_STREAM) {
+ if (rs->state & rs_connected)
+ rshutdown(socket, SHUT_RDWR);
+ else if (rs->opts & RS_OPT_SVC_ACTIVE)
+ rs_notify_svc(&tcp_svc, rs, RS_SVC_REM_KEEPALIVE);
+ } else {
+ ds_shutdown(rs);
+ }
+
+ rs_free(rs);
+ return 0;
+}
+
+static void rs_copy_addr(struct sockaddr *dst, struct sockaddr *src, socklen_t *len)
+{
+ socklen_t size;
+
+ if (src->sa_family == AF_INET) {
+ size = min_t(socklen_t, *len, sizeof(struct sockaddr_in));
+ *len = sizeof(struct sockaddr_in);
+ } else {
+ size = min_t(socklen_t, *len, sizeof(struct sockaddr_in6));
+ *len = sizeof(struct sockaddr_in6);
+ }
+ memcpy(dst, src, size);
+}
+
+int rgetpeername(int socket, struct sockaddr *addr, socklen_t *addrlen)
+{
+ struct rsocket *rs;
+
+ rs = idm_lookup(&idm, socket);
+ if (!rs)
+ return ERR(EBADF);
+ if (rs->type == SOCK_STREAM) {
+ rs_copy_addr(addr, rdma_get_peer_addr(rs->cm_id), addrlen);
+ return 0;
+ } else {
+ return getpeername(rs->udp_sock, addr, addrlen);
+ }
+}
+
+int rgetsockname(int socket, struct sockaddr *addr, socklen_t *addrlen)
+{
+ struct rsocket *rs;
+
+ rs = idm_lookup(&idm, socket);
+ if (!rs)
+ return ERR(EBADF);
+ if (rs->type == SOCK_STREAM) {
+ rs_copy_addr(addr, rdma_get_local_addr(rs->cm_id), addrlen);
+ return 0;
+ } else {
+ return getsockname(rs->udp_sock, addr, addrlen);
+ }
+}
+
+static int rs_set_keepalive(struct rsocket *rs, int on)
+{
+ FILE *f;
+ int ret;
+
+ if ((on && (rs->opts & RS_OPT_SVC_ACTIVE)) ||
+ (!on && !(rs->opts & RS_OPT_SVC_ACTIVE)))
+ return 0;
+
+ if (on) {
+ if (!rs->keepalive_time) {
+ if ((f = fopen("/proc/sys/net/ipv4/tcp_keepalive_time", "r"))) {
+ if (fscanf(f, "%u", &rs->keepalive_time) != 1)
+ rs->keepalive_time = 7200;
+ fclose(f);
+ } else {
+ rs->keepalive_time = 7200;
+ }
+ }
+ ret = rs_notify_svc(&tcp_svc, rs, RS_SVC_ADD_KEEPALIVE);
+ } else {
+ ret = rs_notify_svc(&tcp_svc, rs, RS_SVC_REM_KEEPALIVE);
+ }
+
+ return ret;
+}
+
+int rsetsockopt(int socket, int level, int optname,
+ const void *optval, socklen_t optlen)
+{
+ struct rsocket *rs;
+ int ret, opt_on = 0;
+ uint64_t *opts = NULL;
+
+ ret = ERR(ENOTSUP);
+ rs = idm_lookup(&idm, socket);
+ if (!rs)
+ return ERR(EBADF);
+ if (rs->type == SOCK_DGRAM && level != SOL_RDMA) {
+ ret = setsockopt(rs->udp_sock, level, optname, optval, optlen);
+ if (ret)
+ return ret;
+ }
+
+ switch (level) {
+ case SOL_SOCKET:
+ opts = &rs->so_opts;
+ switch (optname) {
+ case SO_REUSEADDR:
+ if (rs->type == SOCK_STREAM) {
+ ret = rdma_set_option(rs->cm_id, RDMA_OPTION_ID,
+ RDMA_OPTION_ID_REUSEADDR,
+ (void *) optval, optlen);
+ if (ret && ((errno == ENOSYS) || ((rs->state != rs_init) &&
+ rs->cm_id->context &&
+ (rs->cm_id->verbs->device->transport_type == IBV_TRANSPORT_IB))))
+ ret = 0;
+ }
+ opt_on = *(int *) optval;
+ break;
+ case SO_RCVBUF:
+ if ((rs->type == SOCK_STREAM && !rs->rbuf) ||
+ (rs->type == SOCK_DGRAM && !rs->qp_list))
+ rs->rbuf_size = (*(uint32_t *) optval) << 1;
+ ret = 0;
+ break;
+ case SO_SNDBUF:
+ if (!rs->sbuf)
+ rs->sbuf_size = (*(uint32_t *) optval) << 1;
+ if (rs->sbuf_size < RS_SNDLOWAT)
+ rs->sbuf_size = RS_SNDLOWAT << 1;
+ ret = 0;
+ break;
+ case SO_LINGER:
+ /* Invert value so default so_opt = 0 is on */
+ opt_on = !((struct linger *) optval)->l_onoff;
+ ret = 0;
+ break;
+ case SO_KEEPALIVE:
+ ret = rs_set_keepalive(rs, *(int *) optval);
+ opt_on = rs->opts & RS_OPT_SVC_ACTIVE;
+ break;
+ case SO_OOBINLINE:
+ opt_on = *(int *) optval;
+ ret = 0;
+ break;
+ default:
+ break;
+ }
+ break;
+ case IPPROTO_TCP:
+ opts = &rs->tcp_opts;
+ switch (optname) {
+ case TCP_KEEPCNT:
+ case TCP_KEEPINTVL:
+ ret = 0; /* N/A - we're using a reliable connection */
+ break;
+ case TCP_KEEPIDLE:
+ if (*(int *) optval <= 0) {
+ ret = ERR(EINVAL);
+ break;
+ }
+ rs->keepalive_time = *(int *) optval;
+ ret = (rs->opts & RS_OPT_SVC_ACTIVE) ?
+ rs_notify_svc(&tcp_svc, rs, RS_SVC_MOD_KEEPALIVE) : 0;
+ break;
+ case TCP_NODELAY:
+ opt_on = *(int *) optval;
+ ret = 0;
+ break;
+ case TCP_MAXSEG:
+ ret = 0;
+ break;
+ default:
+ break;
+ }
+ break;
+ case IPPROTO_IPV6:
+ opts = &rs->ipv6_opts;
+ switch (optname) {
+ case IPV6_V6ONLY:
+ if (rs->type == SOCK_STREAM) {
+ ret = rdma_set_option(rs->cm_id, RDMA_OPTION_ID,
+ RDMA_OPTION_ID_AFONLY,
+ (void *) optval, optlen);
+ }
+ opt_on = *(int *) optval;
+ break;
+ default:
+ break;
+ }
+ break;
+ case SOL_RDMA:
+ if (rs->state >= rs_opening) {
+ ret = ERR(EINVAL);
+ break;
+ }
+
+ switch (optname) {
+ case RDMA_SQSIZE:
+ rs->sq_size = min_t(uint32_t, (*(uint32_t *)optval),
+ RS_QP_MAX_SIZE);
+ ret = 0;
+ break;
+ case RDMA_RQSIZE:
+ rs->rq_size = min_t(uint32_t, (*(uint32_t *)optval),
+ RS_QP_MAX_SIZE);
+ ret = 0;
+ break;
+ case RDMA_INLINE:
+ rs->sq_inline = min_t(uint32_t, *(uint32_t *)optval,
+ RS_QP_MAX_SIZE);
+ ret = 0;
+ break;
+ case RDMA_IOMAPSIZE:
+ rs->target_iomap_size = (uint16_t) rs_scale_to_value(
+ (uint8_t) rs_value_to_scale(*(int *) optval, 8), 8);
+ ret = 0;
+ break;
+ case RDMA_ROUTE:
+ if ((rs->optval = malloc(optlen))) {
+ memcpy(rs->optval, optval, optlen);
+ rs->optlen = optlen;
+ ret = 0;
+ } else {
+ ret = ERR(ENOMEM);
+ }
+ break;
+ default:
+ break;
+ }
+ break;
+ default:
+ break;
+ }
+
+ if (!ret && opts) {
+ if (opt_on)
+ *opts |= (1 << optname);
+ else
+ *opts &= ~(1 << optname);
+ }
+
+ return ret;
+}
+
+static void rs_convert_sa_path(struct ibv_sa_path_rec *sa_path,
+ struct ibv_path_data *path_data)
+{
+ uint32_t fl_hop;
+
+ memset(path_data, 0, sizeof(*path_data));
+ path_data->path.dgid = sa_path->dgid;
+ path_data->path.sgid = sa_path->sgid;
+ path_data->path.dlid = sa_path->dlid;
+ path_data->path.slid = sa_path->slid;
+ fl_hop = be32toh(sa_path->flow_label) << 8;
+ path_data->path.flowlabel_hoplimit = htobe32(fl_hop | sa_path->hop_limit);
+ path_data->path.tclass = sa_path->traffic_class;
+ path_data->path.reversible_numpath = sa_path->reversible << 7 | 1;
+ path_data->path.pkey = sa_path->pkey;
+ path_data->path.qosclass_sl = htobe16(sa_path->sl);
+ path_data->path.mtu = sa_path->mtu | 2 << 6; /* exactly */
+ path_data->path.rate = sa_path->rate | 2 << 6;
+ path_data->path.packetlifetime = sa_path->packet_life_time | 2 << 6;
+ path_data->flags= sa_path->preference;
+}
+
+int rgetsockopt(int socket, int level, int optname,
+ void *optval, socklen_t *optlen)
+{
+ struct rsocket *rs;
+ void *opt;
+ struct ibv_sa_path_rec *path_rec;
+ struct ibv_path_data path_data;
+ socklen_t len;
+ int ret = 0;
+ int num_paths;
+
+ rs = idm_lookup(&idm, socket);
+ if (!rs)
+ return ERR(EBADF);
+ switch (level) {
+ case SOL_SOCKET:
+ switch (optname) {
+ case SO_REUSEADDR:
+ case SO_KEEPALIVE:
+ case SO_OOBINLINE:
+ *((int *) optval) = !!(rs->so_opts & (1 << optname));
+ *optlen = sizeof(int);
+ break;
+ case SO_RCVBUF:
+ *((int *) optval) = rs->rbuf_size;
+ *optlen = sizeof(int);
+ break;
+ case SO_SNDBUF:
+ *((int *) optval) = rs->sbuf_size;
+ *optlen = sizeof(int);
+ break;
+ case SO_LINGER:
+ /* Value is inverted so default so_opt = 0 is on */
+ ((struct linger *) optval)->l_onoff =
+ !(rs->so_opts & (1 << optname));
+ ((struct linger *) optval)->l_linger = 0;
+ *optlen = sizeof(struct linger);
+ break;
+ case SO_ERROR:
+ *((int *) optval) = rs->err;
+ *optlen = sizeof(int);
+ rs->err = 0;
+ break;
+ default:
+ ret = ENOTSUP;
+ break;
+ }
+ break;
+ case IPPROTO_TCP:
+ switch (optname) {
+ case TCP_KEEPCNT:
+ case TCP_KEEPINTVL:
+ *((int *) optval) = 1; /* N/A */
+ break;
+ case TCP_KEEPIDLE:
+ *((int *) optval) = (int) rs->keepalive_time;
+ *optlen = sizeof(int);
+ break;
+ case TCP_NODELAY:
+ *((int *) optval) = !!(rs->tcp_opts & (1 << optname));
+ *optlen = sizeof(int);
+ break;
+ case TCP_MAXSEG:
+ *((int *) optval) = (rs->cm_id && rs->cm_id->route.num_paths) ?
+ 1 << (7 + rs->cm_id->route.path_rec->mtu) :
+ 2048;
+ *optlen = sizeof(int);
+ break;
+ default:
+ ret = ENOTSUP;
+ break;
+ }
+ break;
+ case IPPROTO_IPV6:
+ switch (optname) {
+ case IPV6_V6ONLY:
+ *((int *) optval) = !!(rs->ipv6_opts & (1 << optname));
+ *optlen = sizeof(int);
+ break;
+ default:
+ ret = ENOTSUP;
+ break;
+ }
+ break;
+ case SOL_RDMA:
+ switch (optname) {
+ case RDMA_SQSIZE:
+ *((int *) optval) = rs->sq_size;
+ *optlen = sizeof(int);
+ break;
+ case RDMA_RQSIZE:
+ *((int *) optval) = rs->rq_size;
+ *optlen = sizeof(int);
+ break;
+ case RDMA_INLINE:
+ *((int *) optval) = rs->sq_inline;
+ *optlen = sizeof(int);
+ break;
+ case RDMA_IOMAPSIZE:
+ *((int *) optval) = rs->target_iomap_size;
+ *optlen = sizeof(int);
+ break;
+ case RDMA_ROUTE:
+ if (rs->optval) {
+ if (*optlen < rs->optlen) {
+ ret = EINVAL;
+ } else {
+ memcpy(rs->optval, optval, rs->optlen);
+ *optlen = rs->optlen;
+ }
+ } else {
+ if (*optlen < sizeof(path_data)) {
+ ret = EINVAL;
+ } else {
+ len = 0;
+ opt = optval;
+ path_rec = rs->cm_id->route.path_rec;
+ num_paths = 0;
+ while (len + sizeof(path_data) <= *optlen &&
+ num_paths < rs->cm_id->route.num_paths) {
+ rs_convert_sa_path(path_rec, &path_data);
+ memcpy(opt, &path_data, sizeof(path_data));
+ len += sizeof(path_data);
+ opt += sizeof(path_data);
+ path_rec++;
+ num_paths++;
+ }
+ *optlen = len;
+ ret = 0;
+ }
+ }
+ break;
+ default:
+ ret = ENOTSUP;
+ break;
+ }
+ break;
+ default:
+ ret = ENOTSUP;
+ break;
+ }
+
+ return rdma_seterrno(ret);
+}
+
+int rfcntl(int socket, int cmd, ... /* arg */ )
+{
+ struct rsocket *rs;
+ va_list args;
+ int param;
+ int ret = 0;
+
+ rs = idm_lookup(&idm, socket);
+ if (!rs)
+ return ERR(EBADF);
+ va_start(args, cmd);
+ switch (cmd) {
+ case F_GETFL:
+ ret = rs->fd_flags;
+ break;
+ case F_SETFL:
+ param = va_arg(args, int);
+ if ((rs->fd_flags & O_NONBLOCK) != (param & O_NONBLOCK))
+ ret = rs_set_nonblocking(rs, param & O_NONBLOCK);
+
+ if (!ret)
+ rs->fd_flags = param;
+ break;
+ default:
+ ret = ERR(ENOTSUP);
+ break;
+ }
+ va_end(args);
+ return ret;
+}
+
+static struct rs_iomap_mr *rs_get_iomap_mr(struct rsocket *rs)
+{
+ int i;
+
+ if (!rs->remote_iomappings) {
+ rs->remote_iomappings = calloc(rs->remote_iomap.length,
+ sizeof(*rs->remote_iomappings));
+ if (!rs->remote_iomappings)
+ return NULL;
+
+ for (i = 0; i < rs->remote_iomap.length; i++)
+ rs->remote_iomappings[i].index = i;
+ }
+
+ for (i = 0; i < rs->remote_iomap.length; i++) {
+ if (!rs->remote_iomappings[i].mr)
+ return &rs->remote_iomappings[i];
+ }
+ return NULL;
+}
+
+/*
+ * If an offset is given, we map to it. If offset is -1, then we map the
+ * offset to the address of buf. We do not check for conflicts, which must
+ * be fixed at some point.
+ */
+off_t riomap(int socket, void *buf, size_t len, int prot, int flags, off_t offset)
+{
+ struct rsocket *rs;
+ struct rs_iomap_mr *iomr;
+ int access = IBV_ACCESS_LOCAL_WRITE;
+
+ rs = idm_at(&idm, socket);
+ if (!rs->cm_id->pd || (prot & ~(PROT_WRITE | PROT_NONE)))
+ return ERR(EINVAL);
+
+ fastlock_acquire(&rs->map_lock);
+ if (prot & PROT_WRITE) {
+ iomr = rs_get_iomap_mr(rs);
+ access |= IBV_ACCESS_REMOTE_WRITE;
+ } else {
+ iomr = calloc(1, sizeof(*iomr));
+ iomr->index = -1;
+ }
+ if (!iomr) {
+ offset = ERR(ENOMEM);
+ goto out;
+ }
+
+ iomr->mr = ibv_reg_mr(rs->cm_id->pd, buf, len, access);
+ if (!iomr->mr) {
+ if (iomr->index < 0)
+ free(iomr);
+ offset = -1;
+ goto out;
+ }
+
+ if (offset == -1)
+ offset = (uintptr_t) buf;
+ iomr->offset = offset;
+ atomic_store(&iomr->refcnt, 1);
+
+ if (iomr->index >= 0) {
+ dlist_insert_tail(&iomr->entry, &rs->iomap_queue);
+ rs->iomap_pending = 1;
+ } else {
+ dlist_insert_tail(&iomr->entry, &rs->iomap_list);
+ }
+out:
+ fastlock_release(&rs->map_lock);
+ return offset;
+}
+
+int riounmap(int socket, void *buf, size_t len)
+{
+ struct rsocket *rs;
+ struct rs_iomap_mr *iomr;
+ dlist_entry *entry;
+ int ret = 0;
+
+ rs = idm_at(&idm, socket);
+ fastlock_acquire(&rs->map_lock);
+
+ for (entry = rs->iomap_list.next; entry != &rs->iomap_list;
+ entry = entry->next) {
+ iomr = container_of(entry, struct rs_iomap_mr, entry);
+ if (iomr->mr->addr == buf && iomr->mr->length == len) {
+ rs_release_iomap_mr(iomr);
+ goto out;
+ }
+ }
+
+ for (entry = rs->iomap_queue.next; entry != &rs->iomap_queue;
+ entry = entry->next) {
+ iomr = container_of(entry, struct rs_iomap_mr, entry);
+ if (iomr->mr->addr == buf && iomr->mr->length == len) {
+ rs_release_iomap_mr(iomr);
+ goto out;
+ }
+ }
+ ret = ERR(EINVAL);
+out:
+ fastlock_release(&rs->map_lock);
+ return ret;
+}
+
+static struct rs_iomap *rs_find_iomap(struct rsocket *rs, off_t offset)
+{
+ int i;
+
+ for (i = 0; i < rs->target_iomap_size; i++) {
+ if (offset >= rs->target_iomap[i].offset &&
+ offset < rs->target_iomap[i].offset + rs->target_iomap[i].sge.length)
+ return &rs->target_iomap[i];
+ }
+ return NULL;
+}
+
+size_t riowrite(int socket, const void *buf, size_t count, off_t offset, int flags)
+{
+ struct rsocket *rs;
+ struct rs_iomap *iom = NULL;
+ struct ibv_sge sge;
+ size_t left = count;
+ uint32_t xfer_size, olen = RS_OLAP_START_SIZE;
+ int ret = 0;
+
+ rs = idm_at(&idm, socket);
+ fastlock_acquire(&rs->slock);
+ if (rs->iomap_pending) {
+ ret = rs_send_iomaps(rs, flags);
+ if (ret)
+ goto out;
+ }
+ for (; left; left -= xfer_size, buf += xfer_size, offset += xfer_size) {
+ if (!iom || offset > iom->offset + iom->sge.length) {
+ iom = rs_find_iomap(rs, offset);
+ if (!iom)
+ break;
+ }
+
+ if (!rs_can_send(rs)) {
+ ret = rs_get_comp(rs, rs_nonblocking(rs, flags),
+ rs_conn_can_send);
+ if (ret)
+ break;
+ if (!(rs->state & rs_writable)) {
+ ret = ERR(ECONNRESET);
+ break;
+ }
+ }
+
+ if (olen < left) {
+ xfer_size = olen;
+ if (olen < RS_MAX_TRANSFER)
+ olen <<= 1;
+ } else {
+ xfer_size = left;
+ }
+
+ if (xfer_size > rs->sbuf_bytes_avail)
+ xfer_size = rs->sbuf_bytes_avail;
+ if (xfer_size > iom->offset + iom->sge.length - offset)
+ xfer_size = iom->offset + iom->sge.length - offset;
+
+ if (xfer_size <= rs->sq_inline) {
+ sge.addr = (uintptr_t) buf;
+ sge.length = xfer_size;
+ sge.lkey = 0;
+ ret = rs_write_direct(rs, iom, offset, &sge, 1,
+ xfer_size, IBV_SEND_INLINE);
+ } else if (xfer_size <= rs_sbuf_left(rs)) {
+ memcpy((void *) (uintptr_t) rs->ssgl[0].addr, buf, xfer_size);
+ rs->ssgl[0].length = xfer_size;
+ ret = rs_write_direct(rs, iom, offset, rs->ssgl, 1, xfer_size, 0);
+ if (xfer_size < rs_sbuf_left(rs))
+ rs->ssgl[0].addr += xfer_size;
+ else
+ rs->ssgl[0].addr = (uintptr_t) rs->sbuf;
+ } else {
+ rs->ssgl[0].length = rs_sbuf_left(rs);
+ memcpy((void *) (uintptr_t) rs->ssgl[0].addr, buf,
+ rs->ssgl[0].length);
+ rs->ssgl[1].length = xfer_size - rs->ssgl[0].length;
+ memcpy(rs->sbuf, buf + rs->ssgl[0].length, rs->ssgl[1].length);
+ ret = rs_write_direct(rs, iom, offset, rs->ssgl, 2, xfer_size, 0);
+ rs->ssgl[0].addr = (uintptr_t) rs->sbuf + rs->ssgl[1].length;
+ }
+ if (ret)
+ break;
+ }
+out:
+ fastlock_release(&rs->slock);
+
+ return (ret && left == count) ? ret : count - left;
+}
+
+/****************************************************************************
+ * Service Processing Threads
+ ****************************************************************************/
+
+static int rs_svc_grow_sets(struct rs_svc *svc, int grow_size)
+{
+ struct rsocket **rss;
+ void *set, *contexts;
+
+ set = calloc(svc->size + grow_size, sizeof(*rss) + svc->context_size);
+ if (!set)
+ return ENOMEM;
+
+ svc->size += grow_size;
+ rss = set;
+ contexts = set + sizeof(*rss) * svc->size;
+ if (svc->cnt) {
+ memcpy(rss, svc->rss, sizeof(*rss) * (svc->cnt + 1));
+ memcpy(contexts, svc->contexts, svc->context_size * (svc->cnt + 1));
+ }
+
+ free(svc->rss);
+ svc->rss = rss;
+ svc->contexts = contexts;
+ return 0;
+}
+
+/*
+ * Index 0 is reserved for the service's communication socket.
+ */
+static int rs_svc_add_rs(struct rs_svc *svc, struct rsocket *rs)
+{
+ int ret;
+
+ if (svc->cnt >= svc->size - 1) {
+ ret = rs_svc_grow_sets(svc, 4);
+ if (ret)
+ return ret;
+ }
+
+ svc->rss[++svc->cnt] = rs;
+ return 0;
+}
+
+static int rs_svc_index(struct rs_svc *svc, struct rsocket *rs)
+{
+ int i;
+
+ for (i = 1; i <= svc->cnt; i++) {
+ if (svc->rss[i] == rs)
+ return i;
+ }
+ return -1;
+}
+
+static int rs_svc_rm_rs(struct rs_svc *svc, struct rsocket *rs)
+{
+ int i;
+
+ if ((i = rs_svc_index(svc, rs)) >= 0) {
+ svc->rss[i] = svc->rss[svc->cnt];
+ memcpy(svc->contexts + i * svc->context_size,
+ svc->contexts + svc->cnt * svc->context_size,
+ svc->context_size);
+ svc->cnt--;
+ return 0;
+ }
+ return EBADF;
+}
+
+static void udp_svc_process_sock(struct rs_svc *svc)
+{
+ struct rs_svc_msg msg;
+
+ read_all(svc->sock[1], &msg, sizeof msg);
+ switch (msg.cmd) {
+ case RS_SVC_ADD_DGRAM:
+ msg.status = rs_svc_add_rs(svc, msg.rs);
+ if (!msg.status) {
+ msg.rs->opts |= RS_OPT_SVC_ACTIVE;
+ udp_svc_fds = svc->contexts;
+ udp_svc_fds[svc->cnt].fd = msg.rs->udp_sock;
+ udp_svc_fds[svc->cnt].events = POLLIN;
+ udp_svc_fds[svc->cnt].revents = 0;
+ }
+ break;
+ case RS_SVC_REM_DGRAM:
+ msg.status = rs_svc_rm_rs(svc, msg.rs);
+ if (!msg.status)
+ msg.rs->opts &= ~RS_OPT_SVC_ACTIVE;
+ break;
+ case RS_SVC_NOOP:
+ msg.status = 0;
+ break;
+ default:
+ break;
+ }
+
+ write_all(svc->sock[1], &msg, sizeof msg);
+}
+
+static uint8_t udp_svc_sgid_index(struct ds_dest *dest, union ibv_gid *sgid)
+{
+ union ibv_gid gid;
+ int i;
+
+ for (i = 0; i < 16; i++) {
+ ibv_query_gid(dest->qp->cm_id->verbs, dest->qp->cm_id->port_num,
+ i, &gid);
+ if (!memcmp(sgid, &gid, sizeof gid))
+ return i;
+ }
+ return 0;
+}
+
+static uint8_t udp_svc_path_bits(struct ds_dest *dest)
+{
+ struct ibv_port_attr attr;
+
+ if (!ibv_query_port(dest->qp->cm_id->verbs, dest->qp->cm_id->port_num, &attr))
+ return (uint8_t) ((1 << attr.lmc) - 1);
+ return 0x7f;
+}
+
+static void udp_svc_create_ah(struct rsocket *rs, struct ds_dest *dest, uint32_t qpn)
+{
+ union socket_addr saddr;
+ struct rdma_cm_id *id;
+ struct ibv_ah_attr attr;
+ int ret;
+
+ if (dest->ah) {
+ fastlock_acquire(&rs->slock);
+ ibv_destroy_ah(dest->ah);
+ dest->ah = NULL;
+ fastlock_release(&rs->slock);
+ }
+
+ ret = rdma_create_id(NULL, &id, NULL, dest->qp->cm_id->ps);
+ if (ret)
+ return;
+
+ memcpy(&saddr, rdma_get_local_addr(dest->qp->cm_id),
+ ucma_addrlen(rdma_get_local_addr(dest->qp->cm_id)));
+ if (saddr.sa.sa_family == AF_INET)
+ saddr.sin.sin_port = 0;
+ else
+ saddr.sin6.sin6_port = 0;
+ ret = rdma_resolve_addr(id, &saddr.sa, &dest->addr.sa, 2000);
+ if (ret)
+ goto out;
+
+ ret = rdma_resolve_route(id, 2000);
+ if (ret)
+ goto out;
+
+ memset(&attr, 0, sizeof attr);
+ if (id->route.path_rec->hop_limit > 1) {
+ attr.is_global = 1;
+ attr.grh.dgid = id->route.path_rec->dgid;
+ attr.grh.flow_label = be32toh(id->route.path_rec->flow_label);
+ attr.grh.sgid_index = udp_svc_sgid_index(dest, &id->route.path_rec->sgid);
+ attr.grh.hop_limit = id->route.path_rec->hop_limit;
+ attr.grh.traffic_class = id->route.path_rec->traffic_class;
+ }
+ attr.dlid = be16toh(id->route.path_rec->dlid);
+ attr.sl = id->route.path_rec->sl;
+ attr.src_path_bits = be16toh(id->route.path_rec->slid) & udp_svc_path_bits(dest);
+ attr.static_rate = id->route.path_rec->rate;
+ attr.port_num = id->port_num;
+
+ fastlock_acquire(&rs->slock);
+ dest->qpn = qpn;
+ dest->ah = ibv_create_ah(dest->qp->cm_id->pd, &attr);
+ fastlock_release(&rs->slock);
+out:
+ rdma_destroy_id(id);
+}
+
+static int udp_svc_valid_udp_hdr(struct ds_udp_header *udp_hdr,
+ union socket_addr *addr)
+{
+ return (udp_hdr->tag == htobe32(DS_UDP_TAG)) &&
+ ((udp_hdr->version == 4 && addr->sa.sa_family == AF_INET &&
+ udp_hdr->length == DS_UDP_IPV4_HDR_LEN) ||
+ (udp_hdr->version == 6 && addr->sa.sa_family == AF_INET6 &&
+ udp_hdr->length == DS_UDP_IPV6_HDR_LEN));
+}
+
+static void udp_svc_forward(struct rsocket *rs, void *buf, size_t len,
+ union socket_addr *src)
+{
+ struct ds_header hdr;
+ struct ds_smsg *msg;
+ struct ibv_sge sge;
+ uint64_t offset;
+
+ if (!ds_can_send(rs)) {
+ if (ds_get_comp(rs, 0, ds_can_send))
+ return;
+ }
+
+ msg = rs->smsg_free;
+ rs->smsg_free = msg->next;
+ rs->sqe_avail--;
+
+ ds_format_hdr(&hdr, src);
+ memcpy((void *) msg, &hdr, hdr.length);
+ memcpy((void *) msg + hdr.length, buf, len);
+ sge.addr = (uintptr_t) msg;
+ sge.length = hdr.length + len;
+ sge.lkey = rs->conn_dest->qp->smr->lkey;
+ offset = (uint8_t *) msg - rs->sbuf;
+
+ ds_post_send(rs, &sge, offset);
+}
+
+static void udp_svc_process_rs(struct rsocket *rs)
+{
+ static uint8_t buf[RS_SNDLOWAT];
+ struct ds_dest *dest, *cur_dest;
+ struct ds_udp_header *udp_hdr;
+ union socket_addr addr;
+ socklen_t addrlen = sizeof addr;
+ int len, ret;
+ uint32_t qpn;
+
+ ret = recvfrom(rs->udp_sock, buf, sizeof buf, 0, &addr.sa, &addrlen);
+ if (ret < DS_UDP_IPV4_HDR_LEN)
+ return;
+
+ udp_hdr = (struct ds_udp_header *) buf;
+ if (!udp_svc_valid_udp_hdr(udp_hdr, &addr))
+ return;
+
+ len = ret - udp_hdr->length;
+ qpn = be32toh(udp_hdr->qpn) & 0xFFFFFF;
+
+ udp_hdr->tag = (__force __be32)be32toh(udp_hdr->tag);
+ udp_hdr->qpn = (__force __be32)qpn;
+
+ ret = ds_get_dest(rs, &addr.sa, addrlen, &dest);
+ if (ret)
+ return;
+
+ if (udp_hdr->op == RS_OP_DATA) {
+ fastlock_acquire(&rs->slock);
+ cur_dest = rs->conn_dest;
+ rs->conn_dest = dest;
+ ds_send_udp(rs, NULL, 0, 0, RS_OP_CTRL);
+ rs->conn_dest = cur_dest;
+ fastlock_release(&rs->slock);
+ }
+
+ if (!dest->ah || (dest->qpn != qpn))
+ udp_svc_create_ah(rs, dest, qpn);
+
+ /* to do: handle when dest local ip address doesn't match udp ip */
+ if (udp_hdr->op == RS_OP_DATA) {
+ fastlock_acquire(&rs->slock);
+ cur_dest = rs->conn_dest;
+ rs->conn_dest = &dest->qp->dest;
+ udp_svc_forward(rs, buf + udp_hdr->length, len, &addr);
+ rs->conn_dest = cur_dest;
+ fastlock_release(&rs->slock);
+ }
+}
+
+static void *udp_svc_run(void *arg)
+{
+ struct rs_svc *svc = arg;
+ struct rs_svc_msg msg;
+ int i, ret;
+
+ ret = rs_svc_grow_sets(svc, 4);
+ if (ret) {
+ msg.status = ret;
+ write_all(svc->sock[1], &msg, sizeof msg);
+ return (void *) (uintptr_t) ret;
+ }
+
+ udp_svc_fds = svc->contexts;
+ udp_svc_fds[0].fd = svc->sock[1];
+ udp_svc_fds[0].events = POLLIN;
+ do {
+ for (i = 0; i <= svc->cnt; i++)
+ udp_svc_fds[i].revents = 0;
+
+ poll(udp_svc_fds, svc->cnt + 1, -1);
+ if (udp_svc_fds[0].revents)
+ udp_svc_process_sock(svc);
+
+ for (i = 1; i <= svc->cnt; i++) {
+ if (udp_svc_fds[i].revents)
+ udp_svc_process_rs(svc->rss[i]);
+ }
+ } while (svc->cnt >= 1);
+
+ return NULL;
+}
+
+static uint32_t rs_get_time(void)
+{
+ struct timeval now;
+
+ memset(&now, 0, sizeof now);
+ gettimeofday(&now, NULL);
+ return (uint32_t) now.tv_sec;
+}
+
+static void tcp_svc_process_sock(struct rs_svc *svc)
+{
+ struct rs_svc_msg msg;
+ int i;
+
+ read_all(svc->sock[1], &msg, sizeof msg);
+ switch (msg.cmd) {
+ case RS_SVC_ADD_KEEPALIVE:
+ msg.status = rs_svc_add_rs(svc, msg.rs);
+ if (!msg.status) {
+ msg.rs->opts |= RS_OPT_SVC_ACTIVE;
+ tcp_svc_timeouts = svc->contexts;
+ tcp_svc_timeouts[svc->cnt] = rs_get_time() +
+ msg.rs->keepalive_time;
+ }
+ break;
+ case RS_SVC_REM_KEEPALIVE:
+ msg.status = rs_svc_rm_rs(svc, msg.rs);
+ if (!msg.status)
+ msg.rs->opts &= ~RS_OPT_SVC_ACTIVE;
+ break;
+ case RS_SVC_MOD_KEEPALIVE:
+ i = rs_svc_index(svc, msg.rs);
+ if (i >= 0) {
+ tcp_svc_timeouts[i] = rs_get_time() + msg.rs->keepalive_time;
+ msg.status = 0;
+ } else {
+ msg.status = EBADF;
+ }
+ break;
+ case RS_SVC_NOOP:
+ msg.status = 0;
+ break;
+ default:
+ break;
+ }
+ write_all(svc->sock[1], &msg, sizeof msg);
+}
+
+/*
+ * Send a 0 byte RDMA write with immediate as keep-alive message.
+ * This avoids the need for the receive side to do any acknowledgment.
+ */
+static void tcp_svc_send_keepalive(struct rsocket *rs)
+{
+ fastlock_acquire(&rs->cq_lock);
+ if (rs_ctrl_avail(rs) && (rs->state & rs_connected)) {
+ rs->ctrl_seqno++;
+ rs_post_write(rs, NULL, 0, rs_msg_set(RS_OP_CTRL, RS_CTRL_KEEPALIVE),
+ 0, (uintptr_t) NULL, (uintptr_t) NULL);
+ }
+ fastlock_release(&rs->cq_lock);
+}
+
+static void *tcp_svc_run(void *arg)
+{
+ struct rs_svc *svc = arg;
+ struct rs_svc_msg msg;
+ struct pollfd fds;
+ uint32_t now, next_timeout;
+ int i, ret, timeout;
+
+ ret = rs_svc_grow_sets(svc, 16);
+ if (ret) {
+ msg.status = ret;
+ write_all(svc->sock[1], &msg, sizeof msg);
+ return (void *) (uintptr_t) ret;
+ }
+
+ tcp_svc_timeouts = svc->contexts;
+ fds.fd = svc->sock[1];
+ fds.events = POLLIN;
+ timeout = -1;
+ do {
+ poll(&fds, 1, timeout * 1000);
+ if (fds.revents)
+ tcp_svc_process_sock(svc);
+
+ now = rs_get_time();
+ next_timeout = ~0;
+ for (i = 1; i <= svc->cnt; i++) {
+ if (tcp_svc_timeouts[i] <= now) {
+ tcp_svc_send_keepalive(svc->rss[i]);
+ tcp_svc_timeouts[i] =
+ now + svc->rss[i]->keepalive_time;
+ }
+ if (tcp_svc_timeouts[i] < next_timeout)
+ next_timeout = tcp_svc_timeouts[i];
+ }
+ timeout = (int) (next_timeout - now);
+ } while (svc->cnt >= 1);
+
+ return NULL;
+}
diff --git a/contrib/ofed/librdmacm/rsocket.h b/contrib/ofed/librdmacm/rsocket.h
new file mode 100644
index 0000000..efd0db5
--- /dev/null
+++ b/contrib/ofed/librdmacm/rsocket.h
@@ -0,0 +1,99 @@
+/*
+ * Copyright (c) 2011-2012 Intel Corporation. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#if !defined(RSOCKET_H)
+#define RSOCKET_H
+
+#include <infiniband/verbs.h>
+#include <rdma/rdma_cma.h>
+#include <sys/socket.h>
+#include <errno.h>
+#include <poll.h>
+#include <sys/select.h>
+#include <sys/mman.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+int rsocket(int domain, int type, int protocol);
+int rbind(int socket, const struct sockaddr *addr, socklen_t addrlen);
+int rlisten(int socket, int backlog);
+int raccept(int socket, struct sockaddr *addr, socklen_t *addrlen);
+int rconnect(int socket, const struct sockaddr *addr, socklen_t addrlen);
+int rshutdown(int socket, int how);
+int rclose(int socket);
+
+ssize_t rrecv(int socket, void *buf, size_t len, int flags);
+ssize_t rrecvfrom(int socket, void *buf, size_t len, int flags,
+ struct sockaddr *src_addr, socklen_t *addrlen);
+ssize_t rrecvmsg(int socket, struct msghdr *msg, int flags);
+ssize_t rsend(int socket, const void *buf, size_t len, int flags);
+ssize_t rsendto(int socket, const void *buf, size_t len, int flags,
+ const struct sockaddr *dest_addr, socklen_t addrlen);
+ssize_t rsendmsg(int socket, const struct msghdr *msg, int flags);
+ssize_t rread(int socket, void *buf, size_t count);
+ssize_t rreadv(int socket, const struct iovec *iov, int iovcnt);
+ssize_t rwrite(int socket, const void *buf, size_t count);
+ssize_t rwritev(int socket, const struct iovec *iov, int iovcnt);
+
+int rpoll(struct pollfd *fds, nfds_t nfds, int timeout);
+int rselect(int nfds, fd_set *readfds, fd_set *writefds,
+ fd_set *exceptfds, struct timeval *timeout);
+
+int rgetpeername(int socket, struct sockaddr *addr, socklen_t *addrlen);
+int rgetsockname(int socket, struct sockaddr *addr, socklen_t *addrlen);
+
+#define SOL_RDMA 0x10000
+enum {
+ RDMA_SQSIZE,
+ RDMA_RQSIZE,
+ RDMA_INLINE,
+ RDMA_IOMAPSIZE,
+ RDMA_ROUTE
+};
+
+int rsetsockopt(int socket, int level, int optname,
+ const void *optval, socklen_t optlen);
+int rgetsockopt(int socket, int level, int optname,
+ void *optval, socklen_t *optlen);
+int rfcntl(int socket, int cmd, ... /* arg */ );
+
+off_t riomap(int socket, void *buf, size_t len, int prot, int flags, off_t offset);
+int riounmap(int socket, void *buf, size_t len);
+size_t riowrite(int socket, const void *buf, size_t count, off_t offset, int flags);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* RSOCKET_H */
diff --git a/contrib/ofed/librdmacm/src/cma.c b/contrib/ofed/librdmacm/src/cma.c
deleted file mode 100644
index bcffa77..0000000
--- a/contrib/ofed/librdmacm/src/cma.c
+++ /dev/null
@@ -1,1518 +0,0 @@
-/*
- * Copyright (c) 2005-2006 Intel Corporation. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- * $Id: cm.c 3453 2005-09-15 21:43:21Z sean.hefty $
- */
-
-#if HAVE_CONFIG_H
-# include <config.h>
-#endif /* HAVE_CONFIG_H */
-
-#include <stdlib.h>
-#include <string.h>
-#include <glob.h>
-#include <stdio.h>
-#include <fcntl.h>
-#include <errno.h>
-#include <stdint.h>
-#include <poll.h>
-#include <unistd.h>
-#include <pthread.h>
-#include <infiniband/endian.h>
-#include <infiniband/byteswap.h>
-#include <stddef.h>
-
-#include <infiniband/driver.h>
-#include <infiniband/marshall.h>
-#include <rdma/rdma_cma.h>
-#include <rdma/rdma_cma_abi.h>
-
-#ifdef INCLUDE_VALGRIND
-# include <valgrind/memcheck.h>
-# ifndef VALGRIND_MAKE_MEM_DEFINED
-# warning "Valgrind requested, but VALGRIND_MAKE_MEM_DEFINED undefined"
-# endif
-#endif
-
-#ifndef VALGRIND_MAKE_MEM_DEFINED
-# define VALGRIND_MAKE_MEM_DEFINED(addr,len)
-#endif
-
-#define PFX "librdmacm: "
-
-#if __BYTE_ORDER == __LITTLE_ENDIAN
-static inline uint64_t htonll(uint64_t x) { return bswap_64(x); }
-static inline uint64_t ntohll(uint64_t x) { return bswap_64(x); }
-#else
-static inline uint64_t htonll(uint64_t x) { return x; }
-static inline uint64_t ntohll(uint64_t x) { return x; }
-#endif
-
-static inline int ERR(int err)
-{
- errno = err;
- return -1;
-}
-
-#define CMA_CREATE_MSG_CMD_RESP(msg, cmd, resp, type, size) \
-do { \
- struct ucma_abi_cmd_hdr *hdr; \
- \
- size = sizeof(*hdr) + sizeof(*cmd); \
- msg = alloca(size); \
- if (!msg) \
- return ERR(ENOMEM); \
- hdr = msg; \
- cmd = msg + sizeof(*hdr); \
- hdr->cmd = type; \
- hdr->in = sizeof(*cmd); \
- hdr->out = sizeof(*resp); \
- memset(cmd, 0, sizeof(*cmd)); \
- resp = alloca(sizeof(*resp)); \
- if (!resp) \
- return ERR(ENOMEM); \
- cmd->response = (uintptr_t)resp;\
-} while (0)
-
-#define CMA_CREATE_MSG_CMD(msg, cmd, type, size) \
-do { \
- struct ucma_abi_cmd_hdr *hdr; \
- \
- size = sizeof(*hdr) + sizeof(*cmd); \
- msg = alloca(size); \
- if (!msg) \
- return ERR(ENOMEM); \
- hdr = msg; \
- cmd = msg + sizeof(*hdr); \
- hdr->cmd = type; \
- hdr->in = sizeof(*cmd); \
- hdr->out = 0; \
- memset(cmd, 0, sizeof(*cmd)); \
-} while (0)
-
-struct cma_device {
- struct ibv_context *verbs;
- uint64_t guid;
- int port_cnt;
- uint8_t max_initiator_depth;
- uint8_t max_responder_resources;
-};
-
-struct cma_id_private {
- struct rdma_cm_id id;
- struct cma_device *cma_dev;
- int events_completed;
- int connect_error;
- pthread_cond_t cond;
- pthread_mutex_t mut;
- uint32_t handle;
- struct cma_multicast *mc_list;
-};
-
-struct cma_multicast {
- struct cma_multicast *next;
- struct cma_id_private *id_priv;
- void *context;
- int events_completed;
- pthread_cond_t cond;
- uint32_t handle;
- union ibv_gid mgid;
- uint16_t mlid;
- struct sockaddr_storage addr;
-};
-
-struct cma_event {
- struct rdma_cm_event event;
- uint8_t private_data[RDMA_MAX_PRIVATE_DATA];
- struct cma_id_private *id_priv;
- struct cma_multicast *mc;
-};
-
-static struct cma_device *cma_dev_array;
-static int cma_dev_cnt;
-static pthread_mutex_t mut = PTHREAD_MUTEX_INITIALIZER;
-static int abi_ver = RDMA_USER_CM_MAX_ABI_VERSION;
-
-#define container_of(ptr, type, field) \
- ((type *) ((void *)ptr - offsetof(type, field)))
-
-static void ucma_cleanup(void)
-{
- if (cma_dev_cnt) {
- while (cma_dev_cnt)
- ibv_close_device(cma_dev_array[--cma_dev_cnt].verbs);
-
- free(cma_dev_array);
- cma_dev_cnt = 0;
- }
-}
-
-static int check_abi_version(void)
-{
- char value[8];
-
- if ((ibv_read_sysfs_file(ibv_get_sysfs_path(),
- "class/misc/rdma_cm/abi_version",
- value, sizeof value) < 0) &&
- (ibv_read_sysfs_file(ibv_get_sysfs_path(),
- "class/infiniband_ucma/abi_version",
- value, sizeof value) < 0)) {
- /*
- * Older version of Linux do not have class/misc. To support
- * backports, assume the most recent version of the ABI. If
- * we're wrong, we'll simply fail later when calling the ABI.
- */
- fprintf(stderr, "librdmacm: couldn't read ABI version.\n");
- fprintf(stderr, "librdmacm: assuming: %d\n", abi_ver);
- return 0;
- }
-
- abi_ver = strtol(value, NULL, 10);
- if (abi_ver < RDMA_USER_CM_MIN_ABI_VERSION ||
- abi_ver > RDMA_USER_CM_MAX_ABI_VERSION) {
- fprintf(stderr, "librdmacm: kernel ABI version %d "
- "doesn't match library version %d.\n",
- abi_ver, RDMA_USER_CM_MAX_ABI_VERSION);
- return -1;
- }
- return 0;
-}
-
-static int ucma_init(void)
-{
- struct ibv_device **dev_list = NULL;
- struct cma_device *cma_dev;
- struct ibv_device_attr attr;
- int i, ret, dev_cnt;
-
- pthread_mutex_lock(&mut);
- if (cma_dev_cnt) {
- pthread_mutex_unlock(&mut);
- return 0;
- }
-
- ret = check_abi_version();
- if (ret)
- goto err1;
-
- dev_list = ibv_get_device_list(&dev_cnt);
- if (!dev_list) {
- printf("CMA: unable to get RDMA device list\n");
- ret = ERR(ENODEV);
- goto err1;
- }
-
- cma_dev_array = malloc(sizeof *cma_dev * dev_cnt);
- if (!cma_dev_array) {
- ret = ERR(ENOMEM);
- goto err2;
- }
-
- for (i = 0; dev_list[i];) {
- cma_dev = &cma_dev_array[i];
-
- cma_dev->guid = ibv_get_device_guid(dev_list[i]);
- cma_dev->verbs = ibv_open_device(dev_list[i]);
- if (!cma_dev->verbs) {
- printf("CMA: unable to open RDMA device\n");
- ret = ERR(ENODEV);
- goto err3;
- }
-
- i++;
- ret = ibv_query_device(cma_dev->verbs, &attr);
- if (ret) {
- printf("CMA: unable to query RDMA device\n");
- goto err3;
- }
-
- cma_dev->port_cnt = attr.phys_port_cnt;
- cma_dev->max_initiator_depth = (uint8_t) attr.max_qp_init_rd_atom;
- cma_dev->max_responder_resources = (uint8_t) attr.max_qp_rd_atom;
- }
-
- cma_dev_cnt = dev_cnt;
- pthread_mutex_unlock(&mut);
- ibv_free_device_list(dev_list);
- return 0;
-
-err3:
- while (i--)
- ibv_close_device(cma_dev_array[i].verbs);
- free(cma_dev_array);
-err2:
- ibv_free_device_list(dev_list);
-err1:
- pthread_mutex_unlock(&mut);
- return ret;
-}
-
-struct ibv_context **rdma_get_devices(int *num_devices)
-{
- struct ibv_context **devs = NULL;
- int i;
-
- if (!cma_dev_cnt && ucma_init())
- goto out;
-
- devs = malloc(sizeof *devs * (cma_dev_cnt + 1));
- if (!devs)
- goto out;
-
- for (i = 0; i < cma_dev_cnt; i++)
- devs[i] = cma_dev_array[i].verbs;
- devs[i] = NULL;
-out:
- if (num_devices)
- *num_devices = devs ? cma_dev_cnt : 0;
- return devs;
-}
-
-void rdma_free_devices(struct ibv_context **list)
-{
- free(list);
-}
-
-static void __attribute__((destructor)) rdma_cma_fini(void)
-{
- ucma_cleanup();
-}
-
-struct rdma_event_channel *rdma_create_event_channel(void)
-{
- struct rdma_event_channel *channel;
-
- if (!cma_dev_cnt && ucma_init())
- return NULL;
-
- channel = malloc(sizeof *channel);
- if (!channel)
- return NULL;
-
- channel->fd = open("/dev/rdma_cm", O_RDWR);
- if (channel->fd < 0) {
- printf("CMA: unable to open /dev/rdma_cm\n");
- goto err;
- }
- return channel;
-err:
- free(channel);
- return NULL;
-}
-
-void rdma_destroy_event_channel(struct rdma_event_channel *channel)
-{
- close(channel->fd);
- free(channel);
-}
-
-static int ucma_get_device(struct cma_id_private *id_priv, uint64_t guid)
-{
- struct cma_device *cma_dev;
- int i;
-
- for (i = 0; i < cma_dev_cnt; i++) {
- cma_dev = &cma_dev_array[i];
- if (cma_dev->guid == guid) {
- id_priv->cma_dev = cma_dev;
- id_priv->id.verbs = cma_dev->verbs;
- return 0;
- }
- }
-
- return ERR(ENODEV);
-}
-
-static void ucma_free_id(struct cma_id_private *id_priv)
-{
- pthread_cond_destroy(&id_priv->cond);
- pthread_mutex_destroy(&id_priv->mut);
- if (id_priv->id.route.path_rec)
- free(id_priv->id.route.path_rec);
- free(id_priv);
-}
-
-static struct cma_id_private *ucma_alloc_id(struct rdma_event_channel *channel,
- void *context,
- enum rdma_port_space ps)
-{
- struct cma_id_private *id_priv;
-
- id_priv = malloc(sizeof *id_priv);
- if (!id_priv)
- return NULL;
-
- memset(id_priv, 0, sizeof *id_priv);
- id_priv->id.context = context;
- id_priv->id.ps = ps;
- id_priv->id.channel = channel;
- pthread_mutex_init(&id_priv->mut, NULL);
- if (pthread_cond_init(&id_priv->cond, NULL))
- goto err;
-
- return id_priv;
-
-err: ucma_free_id(id_priv);
- return NULL;
-}
-
-int rdma_create_id(struct rdma_event_channel *channel,
- struct rdma_cm_id **id, void *context,
- enum rdma_port_space ps)
-{
- struct ucma_abi_create_id_resp *resp;
- struct ucma_abi_create_id *cmd;
- struct cma_id_private *id_priv;
- void *msg;
- int ret, size;
-
- ret = cma_dev_cnt ? 0 : ucma_init();
- if (ret)
- return ret;
-
- id_priv = ucma_alloc_id(channel, context, ps);
- if (!id_priv)
- return ERR(ENOMEM);
-
- CMA_CREATE_MSG_CMD_RESP(msg, cmd, resp, UCMA_CMD_CREATE_ID, size);
- cmd->uid = (uintptr_t) id_priv;
- cmd->ps = ps;
-
- ret = write(channel->fd, msg, size);
- if (ret != size)
- goto err;
-
- VALGRIND_MAKE_MEM_DEFINED(resp, sizeof *resp);
-
- id_priv->handle = resp->id;
- *id = &id_priv->id;
- return 0;
-
-err: ucma_free_id(id_priv);
- return ret;
-}
-
-static int ucma_destroy_kern_id(int fd, uint32_t handle)
-{
- struct ucma_abi_destroy_id_resp *resp;
- struct ucma_abi_destroy_id *cmd;
- void *msg;
- int ret, size;
-
- CMA_CREATE_MSG_CMD_RESP(msg, cmd, resp, UCMA_CMD_DESTROY_ID, size);
- cmd->id = handle;
-
- ret = write(fd, msg, size);
- if (ret != size)
- return (ret >= 0) ? ERR(ECONNREFUSED) : -1;
-
- VALGRIND_MAKE_MEM_DEFINED(resp, sizeof *resp);
-
- return resp->events_reported;
-}
-
-int rdma_destroy_id(struct rdma_cm_id *id)
-{
- struct cma_id_private *id_priv;
- int ret;
-
- id_priv = container_of(id, struct cma_id_private, id);
- ret = ucma_destroy_kern_id(id->channel->fd, id_priv->handle);
- if (ret < 0)
- return ret;
-
- pthread_mutex_lock(&id_priv->mut);
- while (id_priv->events_completed < ret)
- pthread_cond_wait(&id_priv->cond, &id_priv->mut);
- pthread_mutex_unlock(&id_priv->mut);
-
- ucma_free_id(id_priv);
- return 0;
-}
-
-static int ucma_addrlen(struct sockaddr *addr)
-{
- if (!addr)
- return 0;
-
- switch (addr->sa_family) {
- case PF_INET:
- return sizeof(struct sockaddr_in);
- case PF_INET6:
- return sizeof(struct sockaddr_in6);
- default:
- return 0;
- }
-}
-
-static int ucma_query_route(struct rdma_cm_id *id)
-{
- struct ucma_abi_query_route_resp *resp;
- struct ucma_abi_query_route *cmd;
- struct cma_id_private *id_priv;
- void *msg;
- int ret, size, i;
-
- CMA_CREATE_MSG_CMD_RESP(msg, cmd, resp, UCMA_CMD_QUERY_ROUTE, size);
- id_priv = container_of(id, struct cma_id_private, id);
- cmd->id = id_priv->handle;
-
- ret = write(id->channel->fd, msg, size);
- if (ret != size)
- return (ret >= 0) ? ERR(ECONNREFUSED) : -1;
-
- VALGRIND_MAKE_MEM_DEFINED(resp, sizeof *resp);
-
- if (resp->num_paths) {
- id->route.path_rec = malloc(sizeof *id->route.path_rec *
- resp->num_paths);
- if (!id->route.path_rec)
- return ERR(ENOMEM);
-
- id->route.num_paths = resp->num_paths;
- for (i = 0; i < resp->num_paths; i++)
- ibv_copy_path_rec_from_kern(&id->route.path_rec[i],
- &resp->ib_route[i]);
- }
-
- memcpy(id->route.addr.addr.ibaddr.sgid.raw, resp->ib_route[0].sgid,
- sizeof id->route.addr.addr.ibaddr.sgid);
- memcpy(id->route.addr.addr.ibaddr.dgid.raw, resp->ib_route[0].dgid,
- sizeof id->route.addr.addr.ibaddr.dgid);
- id->route.addr.addr.ibaddr.pkey = resp->ib_route[0].pkey;
- memcpy(&id->route.addr.src_addr, &resp->src_addr,
- sizeof resp->src_addr);
- memcpy(&id->route.addr.dst_addr, &resp->dst_addr,
- sizeof resp->dst_addr);
-
- if (!id_priv->cma_dev && resp->node_guid) {
- ret = ucma_get_device(id_priv, resp->node_guid);
- if (ret)
- return ret;
- id_priv->id.port_num = resp->port_num;
- }
-
- return 0;
-}
-
-int rdma_bind_addr(struct rdma_cm_id *id, struct sockaddr *addr)
-{
- struct ucma_abi_bind_addr *cmd;
- struct cma_id_private *id_priv;
- void *msg;
- int ret, size, addrlen;
-
- addrlen = ucma_addrlen(addr);
- if (!addrlen)
- return ERR(EINVAL);
-
- CMA_CREATE_MSG_CMD(msg, cmd, UCMA_CMD_BIND_ADDR, size);
- id_priv = container_of(id, struct cma_id_private, id);
- cmd->id = id_priv->handle;
- memcpy(&cmd->addr, addr, addrlen);
-
- ret = write(id->channel->fd, msg, size);
- if (ret != size)
- return (ret >= 0) ? ERR(ECONNREFUSED) : -1;
-
- return ucma_query_route(id);
-}
-
-int rdma_resolve_addr(struct rdma_cm_id *id, struct sockaddr *src_addr,
- struct sockaddr *dst_addr, int timeout_ms)
-{
- struct ucma_abi_resolve_addr *cmd;
- struct cma_id_private *id_priv;
- void *msg;
- int ret, size, daddrlen;
-
- daddrlen = ucma_addrlen(dst_addr);
- if (!daddrlen)
- return ERR(EINVAL);
-
- CMA_CREATE_MSG_CMD(msg, cmd, UCMA_CMD_RESOLVE_ADDR, size);
- id_priv = container_of(id, struct cma_id_private, id);
- cmd->id = id_priv->handle;
- if (src_addr)
- memcpy(&cmd->src_addr, src_addr, ucma_addrlen(src_addr));
- memcpy(&cmd->dst_addr, dst_addr, daddrlen);
- cmd->timeout_ms = timeout_ms;
-
- ret = write(id->channel->fd, msg, size);
- if (ret != size)
- return (ret >= 0) ? ERR(ECONNREFUSED) : -1;
-
- memcpy(&id->route.addr.dst_addr, dst_addr, daddrlen);
- return 0;
-}
-
-int rdma_resolve_route(struct rdma_cm_id *id, int timeout_ms)
-{
- struct ucma_abi_resolve_route *cmd;
- struct cma_id_private *id_priv;
- void *msg;
- int ret, size;
-
- CMA_CREATE_MSG_CMD(msg, cmd, UCMA_CMD_RESOLVE_ROUTE, size);
- id_priv = container_of(id, struct cma_id_private, id);
- cmd->id = id_priv->handle;
- cmd->timeout_ms = timeout_ms;
-
- ret = write(id->channel->fd, msg, size);
- if (ret != size)
- return (ret >= 0) ? ERR(ECONNREFUSED) : -1;
-
- return 0;
-}
-
-static int ucma_is_ud_ps(enum rdma_port_space ps)
-{
- return (ps == RDMA_PS_UDP || ps == RDMA_PS_IPOIB);
-}
-
-static int rdma_init_qp_attr(struct rdma_cm_id *id, struct ibv_qp_attr *qp_attr,
- int *qp_attr_mask)
-{
- struct ucma_abi_init_qp_attr *cmd;
- struct ibv_kern_qp_attr *resp;
- struct cma_id_private *id_priv;
- void *msg;
- int ret, size;
-
- CMA_CREATE_MSG_CMD_RESP(msg, cmd, resp, UCMA_CMD_INIT_QP_ATTR, size);
- id_priv = container_of(id, struct cma_id_private, id);
- cmd->id = id_priv->handle;
- cmd->qp_state = qp_attr->qp_state;
-
- ret = write(id->channel->fd, msg, size);
- if (ret != size)
- return (ret >= 0) ? ERR(ECONNREFUSED) : -1;
-
- VALGRIND_MAKE_MEM_DEFINED(resp, sizeof *resp);
-
- ibv_copy_qp_attr_from_kern(qp_attr, resp);
- *qp_attr_mask = resp->qp_attr_mask;
- return 0;
-}
-
-static int ucma_modify_qp_rtr(struct rdma_cm_id *id,
- struct rdma_conn_param *conn_param)
-{
- struct ibv_qp_attr qp_attr;
- int qp_attr_mask, ret;
-
- if (!id->qp)
- return ERR(EINVAL);
-
- /* Need to update QP attributes from default values. */
- qp_attr.qp_state = IBV_QPS_INIT;
- ret = rdma_init_qp_attr(id, &qp_attr, &qp_attr_mask);
- if (ret)
- return ret;
-
- ret = ibv_modify_qp(id->qp, &qp_attr, qp_attr_mask);
- if (ret)
- return ret;
-
- qp_attr.qp_state = IBV_QPS_RTR;
- ret = rdma_init_qp_attr(id, &qp_attr, &qp_attr_mask);
- if (ret)
- return ret;
-
- if (conn_param)
- qp_attr.max_dest_rd_atomic = conn_param->responder_resources;
- return ibv_modify_qp(id->qp, &qp_attr, qp_attr_mask);
-}
-
-static int ucma_modify_qp_rts(struct rdma_cm_id *id)
-{
- struct ibv_qp_attr qp_attr;
- int qp_attr_mask, ret;
-
- qp_attr.qp_state = IBV_QPS_RTS;
- ret = rdma_init_qp_attr(id, &qp_attr, &qp_attr_mask);
- if (ret)
- return ret;
-
- return ibv_modify_qp(id->qp, &qp_attr, qp_attr_mask);
-}
-
-static int ucma_modify_qp_sqd(struct rdma_cm_id *id)
-{
- struct ibv_qp_attr qp_attr;
-
- if (!id->qp)
- return 0;
-
- qp_attr.qp_state = IBV_QPS_SQD;
- return ibv_modify_qp(id->qp, &qp_attr, IBV_QP_STATE);
-}
-
-static int ucma_modify_qp_err(struct rdma_cm_id *id)
-{
- struct ibv_qp_attr qp_attr;
-
- if (!id->qp)
- return 0;
-
- qp_attr.qp_state = IBV_QPS_ERR;
- return ibv_modify_qp(id->qp, &qp_attr, IBV_QP_STATE);
-}
-
-static int ucma_find_pkey(struct cma_device *cma_dev, uint8_t port_num,
- uint16_t pkey, uint16_t *pkey_index)
-{
- int ret, i;
- uint16_t chk_pkey;
-
- for (i = 0, ret = 0; !ret; i++) {
- ret = ibv_query_pkey(cma_dev->verbs, port_num, i, &chk_pkey);
- if (!ret && pkey == chk_pkey) {
- *pkey_index = (uint16_t) i;
- return 0;
- }
- }
- return ERR(EINVAL);
-}
-
-static int ucma_init_conn_qp3(struct cma_id_private *id_priv, struct ibv_qp *qp)
-{
- struct ibv_qp_attr qp_attr;
- int ret;
-
- ret = ucma_find_pkey(id_priv->cma_dev, id_priv->id.port_num,
- id_priv->id.route.addr.addr.ibaddr.pkey,
- &qp_attr.pkey_index);
- if (ret)
- return ret;
-
- qp_attr.port_num = id_priv->id.port_num;
- qp_attr.qp_state = IBV_QPS_INIT;
- qp_attr.qp_access_flags = 0;
-
- return ibv_modify_qp(qp, &qp_attr, IBV_QP_STATE | IBV_QP_ACCESS_FLAGS |
- IBV_QP_PKEY_INDEX | IBV_QP_PORT);
-}
-
-static int ucma_init_conn_qp(struct cma_id_private *id_priv, struct ibv_qp *qp)
-{
- struct ibv_qp_attr qp_attr;
- int qp_attr_mask, ret;
-
- if (abi_ver == 3)
- return ucma_init_conn_qp3(id_priv, qp);
-
- qp_attr.qp_state = IBV_QPS_INIT;
- ret = rdma_init_qp_attr(&id_priv->id, &qp_attr, &qp_attr_mask);
- if (ret)
- return ret;
-
- return ibv_modify_qp(qp, &qp_attr, qp_attr_mask);
-}
-
-static int ucma_init_ud_qp3(struct cma_id_private *id_priv, struct ibv_qp *qp)
-{
- struct ibv_qp_attr qp_attr;
- int ret;
-
- ret = ucma_find_pkey(id_priv->cma_dev, id_priv->id.port_num,
- id_priv->id.route.addr.addr.ibaddr.pkey,
- &qp_attr.pkey_index);
- if (ret)
- return ret;
-
- qp_attr.port_num = id_priv->id.port_num;
- qp_attr.qp_state = IBV_QPS_INIT;
- qp_attr.qkey = RDMA_UDP_QKEY;
-
- ret = ibv_modify_qp(qp, &qp_attr, IBV_QP_STATE | IBV_QP_QKEY |
- IBV_QP_PKEY_INDEX | IBV_QP_PORT);
- if (ret)
- return ret;
-
- qp_attr.qp_state = IBV_QPS_RTR;
- ret = ibv_modify_qp(qp, &qp_attr, IBV_QP_STATE);
- if (ret)
- return ret;
-
- qp_attr.qp_state = IBV_QPS_RTS;
- qp_attr.sq_psn = 0;
- return ibv_modify_qp(qp, &qp_attr, IBV_QP_STATE | IBV_QP_SQ_PSN);
-}
-
-static int ucma_init_ud_qp(struct cma_id_private *id_priv, struct ibv_qp *qp)
-{
- struct ibv_qp_attr qp_attr;
- int qp_attr_mask, ret;
-
- if (abi_ver == 3)
- return ucma_init_ud_qp3(id_priv, qp);
-
- qp_attr.qp_state = IBV_QPS_INIT;
- ret = rdma_init_qp_attr(&id_priv->id, &qp_attr, &qp_attr_mask);
- if (ret)
- return ret;
-
- ret = ibv_modify_qp(qp, &qp_attr, qp_attr_mask);
- if (ret)
- return ret;
-
- qp_attr.qp_state = IBV_QPS_RTR;
- ret = ibv_modify_qp(qp, &qp_attr, IBV_QP_STATE);
- if (ret)
- return ret;
-
- qp_attr.qp_state = IBV_QPS_RTS;
- qp_attr.sq_psn = 0;
- return ibv_modify_qp(qp, &qp_attr, IBV_QP_STATE | IBV_QP_SQ_PSN);
-}
-
-int rdma_create_qp(struct rdma_cm_id *id, struct ibv_pd *pd,
- struct ibv_qp_init_attr *qp_init_attr)
-{
- struct cma_id_private *id_priv;
- struct ibv_qp *qp;
- int ret;
-
- id_priv = container_of(id, struct cma_id_private, id);
- if (id->verbs != pd->context)
- return ERR(EINVAL);
-
- qp = ibv_create_qp(pd, qp_init_attr);
- if (!qp)
- return ERR(ENOMEM);
-
- if (ucma_is_ud_ps(id->ps))
- ret = ucma_init_ud_qp(id_priv, qp);
- else
- ret = ucma_init_conn_qp(id_priv, qp);
- if (ret)
- goto err;
-
- id->qp = qp;
- return 0;
-err:
- ibv_destroy_qp(qp);
- return ret;
-}
-
-void rdma_destroy_qp(struct rdma_cm_id *id)
-{
- ibv_destroy_qp(id->qp);
-}
-
-static int ucma_valid_param(struct cma_id_private *id_priv,
- struct rdma_conn_param *conn_param)
-{
- if (id_priv->id.ps != RDMA_PS_TCP)
- return 0;
-
- if ((conn_param->responder_resources >
- id_priv->cma_dev->max_responder_resources) ||
- (conn_param->initiator_depth >
- id_priv->cma_dev->max_initiator_depth))
- return ERR(EINVAL);
-
- return 0;
-}
-
-static void ucma_copy_conn_param_to_kern(struct ucma_abi_conn_param *dst,
- struct rdma_conn_param *src,
- uint32_t qp_num, uint8_t srq)
-{
- dst->qp_num = qp_num;
- dst->srq = srq;
- dst->responder_resources = src->responder_resources;
- dst->initiator_depth = src->initiator_depth;
- dst->flow_control = src->flow_control;
- dst->retry_count = src->retry_count;
- dst->rnr_retry_count = src->rnr_retry_count;
- dst->valid = 1;
-
- if (src->private_data && src->private_data_len) {
- memcpy(dst->private_data, src->private_data,
- src->private_data_len);
- dst->private_data_len = src->private_data_len;
- }
-}
-
-int rdma_connect(struct rdma_cm_id *id, struct rdma_conn_param *conn_param)
-{
- struct ucma_abi_connect *cmd;
- struct cma_id_private *id_priv;
- void *msg;
- int ret, size;
-
- id_priv = container_of(id, struct cma_id_private, id);
- ret = ucma_valid_param(id_priv, conn_param);
- if (ret)
- return ret;
-
- CMA_CREATE_MSG_CMD(msg, cmd, UCMA_CMD_CONNECT, size);
- cmd->id = id_priv->handle;
- if (id->qp)
- ucma_copy_conn_param_to_kern(&cmd->conn_param, conn_param,
- id->qp->qp_num,
- (id->qp->srq != NULL));
- else
- ucma_copy_conn_param_to_kern(&cmd->conn_param, conn_param,
- conn_param->qp_num,
- conn_param->srq);
-
- ret = write(id->channel->fd, msg, size);
- if (ret != size)
- return (ret >= 0) ? ERR(ECONNREFUSED) : -1;
-
- return 0;
-}
-
-int rdma_listen(struct rdma_cm_id *id, int backlog)
-{
- struct ucma_abi_listen *cmd;
- struct cma_id_private *id_priv;
- void *msg;
- int ret, size;
-
- CMA_CREATE_MSG_CMD(msg, cmd, UCMA_CMD_LISTEN, size);
- id_priv = container_of(id, struct cma_id_private, id);
- cmd->id = id_priv->handle;
- cmd->backlog = backlog;
-
- ret = write(id->channel->fd, msg, size);
- if (ret != size)
- return (ret >= 0) ? ERR(ECONNREFUSED) : -1;
-
- return ucma_query_route(id);
-}
-
-int rdma_accept(struct rdma_cm_id *id, struct rdma_conn_param *conn_param)
-{
- struct ucma_abi_accept *cmd;
- struct cma_id_private *id_priv;
- void *msg;
- int ret, size;
-
- id_priv = container_of(id, struct cma_id_private, id);
- ret = ucma_valid_param(id_priv, conn_param);
- if (ret)
- return ret;
-
- if (!ucma_is_ud_ps(id->ps)) {
- ret = ucma_modify_qp_rtr(id, conn_param);
- if (ret)
- return ret;
- }
-
- CMA_CREATE_MSG_CMD(msg, cmd, UCMA_CMD_ACCEPT, size);
- cmd->id = id_priv->handle;
- cmd->uid = (uintptr_t) id_priv;
- if (id->qp)
- ucma_copy_conn_param_to_kern(&cmd->conn_param, conn_param,
- id->qp->qp_num,
- (id->qp->srq != NULL));
- else
- ucma_copy_conn_param_to_kern(&cmd->conn_param, conn_param,
- conn_param->qp_num,
- conn_param->srq);
-
- ret = write(id->channel->fd, msg, size);
- if (ret != size) {
- ucma_modify_qp_err(id);
- return (ret >= 0) ? ERR(ECONNREFUSED) : -1;
- }
-
- return 0;
-}
-
-int rdma_reject(struct rdma_cm_id *id, const void *private_data,
- uint8_t private_data_len)
-{
- struct ucma_abi_reject *cmd;
- struct cma_id_private *id_priv;
- void *msg;
- int ret, size;
-
- CMA_CREATE_MSG_CMD(msg, cmd, UCMA_CMD_REJECT, size);
-
- id_priv = container_of(id, struct cma_id_private, id);
- cmd->id = id_priv->handle;
- if (private_data && private_data_len) {
- memcpy(cmd->private_data, private_data, private_data_len);
- cmd->private_data_len = private_data_len;
- } else
- cmd->private_data_len = 0;
-
- ret = write(id->channel->fd, msg, size);
- if (ret != size)
- return (ret >= 0) ? ERR(ECONNREFUSED) : -1;
-
- return 0;
-}
-
-int rdma_notify(struct rdma_cm_id *id, enum ibv_event_type event)
-{
- struct ucma_abi_notify *cmd;
- struct cma_id_private *id_priv;
- void *msg;
- int ret, size;
-
- CMA_CREATE_MSG_CMD(msg, cmd, UCMA_CMD_NOTIFY, size);
-
- id_priv = container_of(id, struct cma_id_private, id);
- cmd->id = id_priv->handle;
- cmd->event = event;
- ret = write(id->channel->fd, msg, size);
- if (ret != size)
- return (ret >= 0) ? ERR(ECONNREFUSED) : -1;
-
- return 0;
-}
-
-int rdma_disconnect(struct rdma_cm_id *id)
-{
- struct ucma_abi_disconnect *cmd;
- struct cma_id_private *id_priv;
- void *msg;
- int ret, size;
-
- switch (id->verbs->device->transport_type) {
- case IBV_TRANSPORT_IB:
- ret = ucma_modify_qp_err(id);
- break;
- case IBV_TRANSPORT_IWARP:
- ret = ucma_modify_qp_sqd(id);
- break;
- default:
- ret = ERR(EINVAL);
- }
- if (ret)
- return ret;
-
- CMA_CREATE_MSG_CMD(msg, cmd, UCMA_CMD_DISCONNECT, size);
- id_priv = container_of(id, struct cma_id_private, id);
- cmd->id = id_priv->handle;
-
- ret = write(id->channel->fd, msg, size);
- if (ret != size)
- return (ret >= 0) ? ERR(ECONNREFUSED) : -1;
-
- return 0;
-}
-
-int rdma_join_multicast(struct rdma_cm_id *id, struct sockaddr *addr,
- void *context)
-{
- struct ucma_abi_join_mcast *cmd;
- struct ucma_abi_create_id_resp *resp;
- struct cma_id_private *id_priv;
- struct cma_multicast *mc, **pos;
- void *msg;
- int ret, size, addrlen;
-
- id_priv = container_of(id, struct cma_id_private, id);
- addrlen = ucma_addrlen(addr);
- if (!addrlen)
- return ERR(EINVAL);
-
- mc = malloc(sizeof *mc);
- if (!mc)
- return ERR(ENOMEM);
-
- memset(mc, 0, sizeof *mc);
- mc->context = context;
- mc->id_priv = id_priv;
- memcpy(&mc->addr, addr, addrlen);
- if (pthread_cond_init(&mc->cond, NULL)) {
- ret = -1;
- goto err1;
- }
-
- pthread_mutex_lock(&id_priv->mut);
- mc->next = id_priv->mc_list;
- id_priv->mc_list = mc;
- pthread_mutex_unlock(&id_priv->mut);
-
- CMA_CREATE_MSG_CMD_RESP(msg, cmd, resp, UCMA_CMD_JOIN_MCAST, size);
- cmd->id = id_priv->handle;
- memcpy(&cmd->addr, addr, addrlen);
- cmd->uid = (uintptr_t) mc;
-
- ret = write(id->channel->fd, msg, size);
- if (ret != size) {
- ret = (ret >= 0) ? ERR(ECONNREFUSED) : -1;
- goto err2;
- }
-
- VALGRIND_MAKE_MEM_DEFINED(resp, sizeof *resp);
-
- mc->handle = resp->id;
- return 0;
-err2:
- pthread_mutex_lock(&id_priv->mut);
- for (pos = &id_priv->mc_list; *pos != mc; pos = &(*pos)->next)
- ;
- *pos = mc->next;
- pthread_mutex_unlock(&id_priv->mut);
-err1:
- free(mc);
- return ret;
-}
-
-int rdma_leave_multicast(struct rdma_cm_id *id, struct sockaddr *addr)
-{
- struct ucma_abi_destroy_id *cmd;
- struct ucma_abi_destroy_id_resp *resp;
- struct cma_id_private *id_priv;
- struct cma_multicast *mc, **pos;
- void *msg;
- int ret, size, addrlen;
-
- addrlen = ucma_addrlen(addr);
- if (!addrlen)
- return ERR(EINVAL);
-
- id_priv = container_of(id, struct cma_id_private, id);
- pthread_mutex_lock(&id_priv->mut);
- for (pos = &id_priv->mc_list; *pos; pos = &(*pos)->next)
- if (!memcmp(&(*pos)->addr, addr, addrlen))
- break;
-
- mc = *pos;
- if (*pos)
- *pos = mc->next;
- pthread_mutex_unlock(&id_priv->mut);
- if (!mc)
- return ERR(EADDRNOTAVAIL);
-
- if (id->qp)
- ibv_detach_mcast(id->qp, &mc->mgid, mc->mlid);
-
- CMA_CREATE_MSG_CMD_RESP(msg, cmd, resp, UCMA_CMD_LEAVE_MCAST, size);
- cmd->id = mc->handle;
-
- ret = write(id->channel->fd, msg, size);
- if (ret != size) {
- ret = (ret >= 0) ? ERR(ECONNREFUSED) : -1;
- goto free;
- }
-
- VALGRIND_MAKE_MEM_DEFINED(resp, sizeof *resp);
-
- pthread_mutex_lock(&id_priv->mut);
- while (mc->events_completed < resp->events_reported)
- pthread_cond_wait(&mc->cond, &id_priv->mut);
- pthread_mutex_unlock(&id_priv->mut);
-
- ret = 0;
-free:
- free(mc);
- return ret;
-}
-
-static void ucma_complete_event(struct cma_id_private *id_priv)
-{
- pthread_mutex_lock(&id_priv->mut);
- id_priv->events_completed++;
- pthread_cond_signal(&id_priv->cond);
- pthread_mutex_unlock(&id_priv->mut);
-}
-
-static void ucma_complete_mc_event(struct cma_multicast *mc)
-{
- pthread_mutex_lock(&mc->id_priv->mut);
- mc->events_completed++;
- pthread_cond_signal(&mc->cond);
- mc->id_priv->events_completed++;
- pthread_cond_signal(&mc->id_priv->cond);
- pthread_mutex_unlock(&mc->id_priv->mut);
-}
-
-int rdma_ack_cm_event(struct rdma_cm_event *event)
-{
- struct cma_event *evt;
-
- if (!event)
- return ERR(EINVAL);
-
- evt = container_of(event, struct cma_event, event);
-
- if (evt->mc)
- ucma_complete_mc_event(evt->mc);
- else
- ucma_complete_event(evt->id_priv);
- free(evt);
- return 0;
-}
-
-static int ucma_process_conn_req(struct cma_event *evt,
- uint32_t handle)
-{
- struct cma_id_private *id_priv;
- int ret;
-
- id_priv = ucma_alloc_id(evt->id_priv->id.channel,
- evt->id_priv->id.context, evt->id_priv->id.ps);
- if (!id_priv) {
- ucma_destroy_kern_id(evt->id_priv->id.channel->fd, handle);
- ret = ERR(ENOMEM);
- goto err;
- }
-
- evt->event.listen_id = &evt->id_priv->id;
- evt->event.id = &id_priv->id;
- id_priv->handle = handle;
-
- ret = ucma_query_route(&id_priv->id);
- if (ret) {
- rdma_destroy_id(&id_priv->id);
- goto err;
- }
-
- return 0;
-err:
- ucma_complete_event(evt->id_priv);
- return ret;
-}
-
-static int ucma_process_conn_resp(struct cma_id_private *id_priv)
-{
- struct ucma_abi_accept *cmd;
- void *msg;
- int ret, size;
-
- ret = ucma_modify_qp_rtr(&id_priv->id, NULL);
- if (ret)
- goto err;
-
- ret = ucma_modify_qp_rts(&id_priv->id);
- if (ret)
- goto err;
-
- CMA_CREATE_MSG_CMD(msg, cmd, UCMA_CMD_ACCEPT, size);
- cmd->id = id_priv->handle;
-
- ret = write(id_priv->id.channel->fd, msg, size);
- if (ret != size) {
- ret = (ret >= 0) ? ERR(ECONNREFUSED) : -1;
- goto err;
- }
-
- return 0;
-err:
- ucma_modify_qp_err(&id_priv->id);
- return ret;
-}
-
-static int ucma_process_establish(struct rdma_cm_id *id)
-{
- int ret;
-
- ret = ucma_modify_qp_rts(id);
- if (ret)
- ucma_modify_qp_err(id);
-
- return ret;
-}
-
-static int ucma_process_join(struct cma_event *evt)
-{
- evt->mc->mgid = evt->event.param.ud.ah_attr.grh.dgid;
- evt->mc->mlid = evt->event.param.ud.ah_attr.dlid;
-
- if (!evt->id_priv->id.qp)
- return 0;
-
- return ibv_attach_mcast(evt->id_priv->id.qp, &evt->mc->mgid,
- evt->mc->mlid);
-}
-
-static void ucma_copy_conn_event(struct cma_event *event,
- struct ucma_abi_conn_param *src)
-{
- struct rdma_conn_param *dst = &event->event.param.conn;
-
- dst->private_data_len = src->private_data_len;
- if (src->private_data_len) {
- dst->private_data = &event->private_data;
- memcpy(&event->private_data, src->private_data,
- src->private_data_len);
- }
-
- dst->responder_resources = src->responder_resources;
- dst->initiator_depth = src->initiator_depth;
- dst->flow_control = src->flow_control;
- dst->retry_count = src->retry_count;
- dst->rnr_retry_count = src->rnr_retry_count;
- dst->srq = src->srq;
- dst->qp_num = src->qp_num;
-}
-
-static void ucma_copy_ud_event(struct cma_event *event,
- struct ucma_abi_ud_param *src)
-{
- struct rdma_ud_param *dst = &event->event.param.ud;
-
- dst->private_data_len = src->private_data_len;
- if (src->private_data_len) {
- dst->private_data = &event->private_data;
- memcpy(&event->private_data, src->private_data,
- src->private_data_len);
- }
-
- ibv_copy_ah_attr_from_kern(&dst->ah_attr, &src->ah_attr);
- dst->qp_num = src->qp_num;
- dst->qkey = src->qkey;
-}
-
-int rdma_get_cm_event(struct rdma_event_channel *channel,
- struct rdma_cm_event **event)
-{
- struct ucma_abi_event_resp *resp;
- struct ucma_abi_get_event *cmd;
- struct cma_event *evt;
- void *msg;
- int ret, size;
-
- ret = cma_dev_cnt ? 0 : ucma_init();
- if (ret)
- return ret;
-
- if (!event)
- return ERR(EINVAL);
-
- evt = malloc(sizeof *evt);
- if (!evt)
- return ERR(ENOMEM);
-
-retry:
- memset(evt, 0, sizeof *evt);
- CMA_CREATE_MSG_CMD_RESP(msg, cmd, resp, UCMA_CMD_GET_EVENT, size);
- ret = write(channel->fd, msg, size);
- if (ret != size) {
- free(evt);
- return (ret >= 0) ? ERR(ECONNREFUSED) : -1;
- }
-
- VALGRIND_MAKE_MEM_DEFINED(resp, sizeof *resp);
-
- evt->event.event = resp->event;
- evt->id_priv = (void *) (uintptr_t) resp->uid;
- evt->event.id = &evt->id_priv->id;
- evt->event.status = resp->status;
-
- switch (resp->event) {
- case RDMA_CM_EVENT_ADDR_RESOLVED:
- evt->event.status = ucma_query_route(&evt->id_priv->id);
- if (evt->event.status)
- evt->event.event = RDMA_CM_EVENT_ADDR_ERROR;
- break;
- case RDMA_CM_EVENT_ROUTE_RESOLVED:
- evt->event.status = ucma_query_route(&evt->id_priv->id);
- if (evt->event.status)
- evt->event.event = RDMA_CM_EVENT_ROUTE_ERROR;
- break;
- case RDMA_CM_EVENT_CONNECT_REQUEST:
- evt->id_priv = (void *) (uintptr_t) resp->uid;
- if (ucma_is_ud_ps(evt->id_priv->id.ps))
- ucma_copy_ud_event(evt, &resp->param.ud);
- else
- ucma_copy_conn_event(evt, &resp->param.conn);
-
- ret = ucma_process_conn_req(evt, resp->id);
- if (ret)
- goto retry;
- break;
- case RDMA_CM_EVENT_CONNECT_RESPONSE:
- ucma_copy_conn_event(evt, &resp->param.conn);
- evt->event.status = ucma_process_conn_resp(evt->id_priv);
- if (!evt->event.status)
- evt->event.event = RDMA_CM_EVENT_ESTABLISHED;
- else {
- evt->event.event = RDMA_CM_EVENT_CONNECT_ERROR;
- evt->id_priv->connect_error = 1;
- }
- break;
- case RDMA_CM_EVENT_ESTABLISHED:
- if (ucma_is_ud_ps(evt->id_priv->id.ps)) {
- ucma_copy_ud_event(evt, &resp->param.ud);
- break;
- }
-
- ucma_copy_conn_event(evt, &resp->param.conn);
- evt->event.status = ucma_process_establish(&evt->id_priv->id);
- if (evt->event.status) {
- evt->event.event = RDMA_CM_EVENT_CONNECT_ERROR;
- evt->id_priv->connect_error = 1;
- }
- break;
- case RDMA_CM_EVENT_REJECTED:
- if (evt->id_priv->connect_error) {
- ucma_complete_event(evt->id_priv);
- goto retry;
- }
- ucma_copy_conn_event(evt, &resp->param.conn);
- ucma_modify_qp_err(evt->event.id);
- break;
- case RDMA_CM_EVENT_DISCONNECTED:
- if (evt->id_priv->connect_error) {
- ucma_complete_event(evt->id_priv);
- goto retry;
- }
- ucma_copy_conn_event(evt, &resp->param.conn);
- break;
- case RDMA_CM_EVENT_MULTICAST_JOIN:
- evt->mc = (void *) (uintptr_t) resp->uid;
- evt->id_priv = evt->mc->id_priv;
- evt->event.id = &evt->id_priv->id;
- ucma_copy_ud_event(evt, &resp->param.ud);
- evt->event.param.ud.private_data = evt->mc->context;
- evt->event.status = ucma_process_join(evt);
- if (evt->event.status)
- evt->event.event = RDMA_CM_EVENT_MULTICAST_ERROR;
- break;
- case RDMA_CM_EVENT_MULTICAST_ERROR:
- evt->mc = (void *) (uintptr_t) resp->uid;
- evt->id_priv = evt->mc->id_priv;
- evt->event.id = &evt->id_priv->id;
- evt->event.param.ud.private_data = evt->mc->context;
- break;
- default:
- evt->id_priv = (void *) (uintptr_t) resp->uid;
- evt->event.id = &evt->id_priv->id;
- evt->event.status = resp->status;
- if (ucma_is_ud_ps(evt->id_priv->id.ps))
- ucma_copy_ud_event(evt, &resp->param.ud);
- else
- ucma_copy_conn_event(evt, &resp->param.conn);
- break;
- }
-
- *event = &evt->event;
- return 0;
-}
-
-const char *rdma_event_str(enum rdma_cm_event_type event)
-{
- switch (event) {
- case RDMA_CM_EVENT_ADDR_RESOLVED:
- return "RDMA_CM_EVENT_ADDR_RESOLVED";
- case RDMA_CM_EVENT_ADDR_ERROR:
- return "RDMA_CM_EVENT_ADDR_ERROR";
- case RDMA_CM_EVENT_ROUTE_RESOLVED:
- return "RDMA_CM_EVENT_ROUTE_RESOLVED";
- case RDMA_CM_EVENT_ROUTE_ERROR:
- return "RDMA_CM_EVENT_ROUTE_ERROR";
- case RDMA_CM_EVENT_CONNECT_REQUEST:
- return "RDMA_CM_EVENT_CONNECT_REQUEST";
- case RDMA_CM_EVENT_CONNECT_RESPONSE:
- return "RDMA_CM_EVENT_CONNECT_RESPONSE";
- case RDMA_CM_EVENT_CONNECT_ERROR:
- return "RDMA_CM_EVENT_CONNECT_ERROR";
- case RDMA_CM_EVENT_UNREACHABLE:
- return "RDMA_CM_EVENT_UNREACHABLE";
- case RDMA_CM_EVENT_REJECTED:
- return "RDMA_CM_EVENT_REJECTED";
- case RDMA_CM_EVENT_ESTABLISHED:
- return "RDMA_CM_EVENT_ESTABLISHED";
- case RDMA_CM_EVENT_DISCONNECTED:
- return "RDMA_CM_EVENT_DISCONNECTED";
- case RDMA_CM_EVENT_DEVICE_REMOVAL:
- return "RDMA_CM_EVENT_DEVICE_REMOVAL";
- case RDMA_CM_EVENT_MULTICAST_JOIN:
- return "RDMA_CM_EVENT_MULTICAST_JOIN";
- case RDMA_CM_EVENT_MULTICAST_ERROR:
- return "RDMA_CM_EVENT_MULTICAST_ERROR";
- case RDMA_CM_EVENT_ADDR_CHANGE:
- return "RDMA_CM_EVENT_ADDR_CHANGE";
- case RDMA_CM_EVENT_TIMEWAIT_EXIT:
- return "RDMA_CM_EVENT_TIMEWAIT_EXIT";
- default:
- return "UNKNOWN EVENT";
- }
-}
-
-int rdma_set_option(struct rdma_cm_id *id, int level, int optname,
- void *optval, size_t optlen)
-{
- struct ucma_abi_set_option *cmd;
- struct cma_id_private *id_priv;
- void *msg;
- int ret, size;
-
- CMA_CREATE_MSG_CMD(msg, cmd, UCMA_CMD_SET_OPTION, size);
- id_priv = container_of(id, struct cma_id_private, id);
- cmd->id = id_priv->handle;
- cmd->optval = (uintptr_t) optval;
- cmd->level = level;
- cmd->optname = optname;
- cmd->optlen = optlen;
-
- ret = write(id->channel->fd, msg, size);
- if (ret != size)
- return (ret >= 0) ? ERR(ECONNREFUSED) : -1;
-
- return 0;
-}
-
-int rdma_migrate_id(struct rdma_cm_id *id, struct rdma_event_channel *channel)
-{
- struct ucma_abi_migrate_resp *resp;
- struct ucma_abi_migrate_id *cmd;
- struct cma_id_private *id_priv;
- void *msg;
- int ret, size;
-
- id_priv = container_of(id, struct cma_id_private, id);
- CMA_CREATE_MSG_CMD_RESP(msg, cmd, resp, UCMA_CMD_MIGRATE_ID, size);
- cmd->id = id_priv->handle;
- cmd->fd = id->channel->fd;
-
- ret = write(channel->fd, msg, size);
- if (ret != size)
- return (ret >= 0) ? ERR(ECONNREFUSED) : -1;
-
- VALGRIND_MAKE_MEM_DEFINED(resp, sizeof *resp);
-
- /*
- * Eventually if we want to support migrating channels while events are
- * being processed on the current channel, we need to block here while
- * there are any outstanding events on the current channel for this id
- * to prevent the user from processing events for this id on the old
- * channel after this call returns.
- */
- pthread_mutex_lock(&id_priv->mut);
- id->channel = channel;
- while (id_priv->events_completed < resp->events_reported)
- pthread_cond_wait(&id_priv->cond, &id_priv->mut);
- pthread_mutex_unlock(&id_priv->mut);
-
- return 0;
-}
diff --git a/contrib/ofed/librdmacm/src/librdmacm.map b/contrib/ofed/librdmacm/src/librdmacm.map
deleted file mode 100644
index cb94efe..0000000
--- a/contrib/ofed/librdmacm/src/librdmacm.map
+++ /dev/null
@@ -1,32 +0,0 @@
-RDMACM_1.0 {
- global:
- rdma_create_event_channel;
- rdma_destroy_event_channel;
- rdma_create_id;
- rdma_destroy_id;
- rdma_bind_addr;
- rdma_resolve_addr;
- rdma_resolve_route;
- rdma_create_qp;
- rdma_destroy_qp;
- rdma_connect;
- rdma_listen;
- rdma_accept;
- rdma_reject;
- rdma_notify;
- rdma_disconnect;
- rdma_get_cm_event;
- rdma_ack_cm_event;
- rdma_get_src_port;
- rdma_get_dst_port;
- rdma_join_multicast;
- rdma_leave_multicast;
- rdma_get_devices;
- rdma_free_devices;
- rdma_event_str;
- rdma_set_option;
- rdma_get_local_addr;
- rdma_get_peer_addr;
- rdma_migrate_id;
- local: *;
-};
diff --git a/contrib/ofed/libsdp/COPYING b/contrib/ofed/libsdp/COPYING
deleted file mode 100644
index fac7531..0000000
--- a/contrib/ofed/libsdp/COPYING
+++ /dev/null
@@ -1,36 +0,0 @@
-This software is available to you under a choice of one of two
-licenses. You may choose to be licensed under the terms of the GNU
-General Public License (GPL) Version 2, available at
-<http://www.fsf.org/copyleft/gpl.html>, or the OpenIB.org BSD
-license, included below.
-
-Copyright (c) 2004 Topspin Communications. All rights reserved.
-Copyright (c) 2005 Mellanox Technologies Ltd. All rights reserved.
-
-
-OpenIB.org BSD license:
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions
-are met:
-
- * Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
-
- * Redistributions in binary form must reproduce the above
- copyright notice, this list of conditions and the following
- disclaimer in the documentation and/or other materials provided
- with the distribution.
-
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
-FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
-COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
-INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
-BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
-LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
-CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
-ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-POSSIBILITY OF SUCH DAMAGE.
diff --git a/contrib/ofed/libsdp/ChangeLog b/contrib/ofed/libsdp/ChangeLog
deleted file mode 100644
index 8d382dc..0000000
--- a/contrib/ofed/libsdp/ChangeLog
+++ /dev/null
@@ -1,117 +0,0 @@
-2011-04-28 10:25:22 +0300 Amir Vadai <amirv@mellanox.co.il>
- * 8cc6058 libsdp: Use logroate on /var/log/libsdp.log
-
-2011-01-17 15:44:30 +0200 Amir Vadai <amirv@mellanox.co.il>
- * d7fdb72 libsdp: removed a debug print
-
-2011-01-12 11:24:57 +0200 Amir Vadai <amirv@mellanox.co.il>
- * 63e0cf1 libsdp: recompiled yacc files
-
-2011-01-10 17:29:14 +0200 Amir Vadai <amirv@mellanox.co.il>
- * 54de044 libsdp: Add IPv6 support to configuration file
-
-2011-01-05 09:52:05 +0200 Amir Vadai <amirv@mellanox.co.il>
- * e57ee9c libsdp: Do not set-user-ID on default.
-
-2011-01-03 11:33:44 +0200 Amir Vadai <amirv@mellanox.co.il>
- * 18447bb libsdp: Do not block other socket types
-
-2011-01-02 12:29:13 +0200 Amir Vadai <amirv@mellanox.co.il>
- * e9d2c10 libsdp: Fix bad errno value
-
-2010-12-26 18:14:02 +0200 Amir Vadai <amirv@mellanox.co.il>
- * 9c2ad15 libsdp: full ipv6 support
-
-2010-11-29 11:43:51 +0200 Amir Vadai <amirv@mellanox.co.il>
- * 0a3d5c3 libsdp: BUG2130 - libsdp.so is not installed + version
- 1.1.106
-2010-11-08 14:41:27 +0200 Amir Vadai <amirv@mellanox.co.il>
- * 7a1880f libsdp: updated version to 1.1.105
-
-2010-11-08 14:31:13 +0200 Amir Vadai <amirv@mellanox.co.il>
- * c6efc06 libsdp: fix security issues with log file
-
-2010-11-02 15:28:06 +0200 Amir Vadai <amirv@mellanox.co.il>
- * 09343d1 libsdp: fix bad permissions
-
-2010-10-28 13:46:39 +0200 root <root@swv300.lab.mtl.com>
- * 46d845d libsdp: fixed indentation
-
-2010-10-04 11:49:46 +0200 Amir Vadai <amirv@mellanox.co.il>
- * 59b6a36 libsdp: updated version to 1.1.104
-
-2010-10-04 11:22:23 +0200 Amir Vadai <amirv@mellanox.co.il>
- * 21b63e0 libsdp: fix libsdp.so permissions
-
-2010-10-04 11:20:49 +0200 Amir Vadai <amirv@mellanox.co.il>
- * 3180e25 libsdp: fix "make dist"
-
-2010-09-13 10:31:52 +0200 Amir Vadai <amirv@mellanox.co.il>
- * df744a5 libsdp: updated version to 1.1.103
-
-2010-09-13 10:45:40 +0200 Amir Vadai <amirv@mellanox.co.il>
- * e3ce469 libsdp: don't make libsdp depend on sdp_socket.h from ib-kernel
-
-2010-08-03 15:35:11 +0300 Amir Vadai <amirv@mellanox.co.il>
- * c5ff8e2 libsdp: updated version to 1.1.102
-
-2010-08-03 15:33:57 +0300 Amir Vadai <amirv@mellanox.co.il>
- * 82fe3f9 libsdp: search openib headers according to 'prefix'
-
-2010-04-11 11:38:47 +0300 Amir Vadai <amirv@mellanox.co.il>
- * 76060c5 libsdp: changed version to 1.1.101
-
-2010-04-08 09:33:29 +0300 Eldad Zinger <eldadz@mellanox.co.il>
- * 8bf57aa libsdp: added differentiation between bind failures of sdp.
-
-2010-03-23 10:13:45 +0200 Eldad Zinger <eldadz@mellanox.co.il>
- * 93706ed sdp: BUG1984 - fix for bad memory access.
-
-2010-04-08 15:40:55 +0300 Amir Vadai <amirv@mellanox.co.il>
- * dadef4b libsdp: add path to openib include's
-
-2010-02-18 11:04:29 +0200 Amir Vadai <amirv@mellanox.co.il>
- * 920ea31 libsdp: changed version to 1.1.100
-
-2010-02-18 11:02:20 +0200 Amir Vadai <amirv@mellanox.co.il>
- * 0fe8a11 libsdp: updated changelog from git + script to get change log
-
-2010-02-18 10:49:42 +0200 Amir Vadai <amirv@mellanox.co.il>
- * a298098 libsdp: Fix memory leak. free libsdp_fd_attributes
-
-2010-02-18 10:49:00 +0200 Amir Vadai <amirv@mellanox.co.il>
- * cf4ceab libsdp: make libsdp.so have gid bit on
-
-2008-11-26 13:44:26 +0200 Amir Vadai <amirv@mellanox.co.il>
- * b1eaecb libsdp: Enable building libsdp on Solaris
-
-2008-11-23 Amir Vadai <amirv@mellanox.co.il>
- * BUG1405 - conflict when running an application that use yacc.
-
-2008-12-08 18:29:09 +0200 Yossi Etigin <yossi.openib@gmail.com>
- * dcfca98 libsdp: BUG1256 - Add epoll support
-
-2008-11-23 16:09:21 +0200 Amir Vadai <amirv@mellanox.co.il>
- * 02404fb libsdp: BUG1405 - conflict when running an application that use yacc.
-
-2008-09-02 15:13:22 +0300 Yossi Etigin <[yossi.openib@gmail.com]>
- * 64adc0e libsdp: enable fallback to TCP for nonblocking sockets
-
-2008-08-21 10:52:19 +0300 Yossi Etigin <[yossi.openib@gmail.com]>
- * cee8053 libsdp: write fcntl argument in debug prints
-
-2008-07-21 22:01:21 +0300 Amir Vadai <amirv@mellanox.co.il>
- * 81d6ec3 removed not unnecessary use of va_copy.
-
-2008-06-12 14:13:07 +0300 Amir Vadai <amirv@mellanox.co.il>
- * 90f25b7 Fixed compilation error on Fedora Release 9
-
-2006-05-29 Eitan Zahavi <eitan@mellanox.co.il>
-
- * Support IPv4 embedded in IPv6 addresses. Since SDP currently does
- not support IPv6 we need to convert to IPv4 and back on queries.
-
- * port.c - cleanup abnd re-written for clearer flow. Added verbose
- messages.
-
- * Major re-write of the parser to support new syntax and using BNF
diff --git a/contrib/ofed/libsdp/Makefile.am b/contrib/ofed/libsdp/Makefile.am
deleted file mode 100644
index f9fd59f..0000000
--- a/contrib/ofed/libsdp/Makefile.am
+++ /dev/null
@@ -1,23 +0,0 @@
-SUBDIRS = src
-
-EXTRA_DIST = libsdp.spec.in libsdp.conf scripts/libsdp.logrotate
-
-dist-hook: libsdp.spec
- cp libsdp.spec $(distdir)
-
-install-data-hook:
- if test -e $(DESTDIR)$(sysconfdir)/libsdp.conf; then \
- diff -q $(srcdir)/libsdp.conf $(DESTDIR)$(sysconfdir)/libsdp.conf 1> /dev/null; \
- if test $$? == 1; then \
- t=$(shell date +'%Y%m%d%H%M%S'); \
- cp -p $(srcdir)/libsdp.conf \
- $(DESTDIR)$(sysconfdir)/libsdp.conf.$$t; \
- echo "NOTE: existing libsdp.conf was not updated."; \
- echo " libsdp.conf installed as ibsdp.conf.$$t instead."; \
- fi; \
- else \
- if test ! -d $(DESTDIR)$(sysconfdir); then \
- mkdir -p $(DESTDIR)$(sysconfdir); \
- fi; \
- cp -p $(srcdir)/libsdp.conf $(DESTDIR)$(sysconfdir)/libsdp.conf; \
- fi
diff --git a/contrib/ofed/libsdp/NEWS b/contrib/ofed/libsdp/NEWS
deleted file mode 100644
index 1fb082b..0000000
--- a/contrib/ofed/libsdp/NEWS
+++ /dev/null
@@ -1,4 +0,0 @@
-0.9.0 - Initial release.
-1.0.0 - Following RFC for enhanced configuration semantics, strong parsing,
- major cleanup, verbosity logging and thread safe code
- \ No newline at end of file
diff --git a/contrib/ofed/libsdp/README b/contrib/ofed/libsdp/README
deleted file mode 100644
index 6499bbc..0000000
--- a/contrib/ofed/libsdp/README
+++ /dev/null
@@ -1,68 +0,0 @@
-LIBSDP - A User Level Socket Switch for Seemless Migration to SDP
------------------------------------------------------------------
-
-OVERVIEW:
----------
-libsdp is a LD_PRELOAD-able library that can be used to migrate existing
-applications use InfiniBand Sockets Direct Protocol (SDP) instead of
-TCP sockets, transparently and without recompilations. To setup libsdp
-please follow the instructions below.
-
-SETUP:
-------
-libsdp.so isn't setup automatically. it can be used in one of 2 ways:
-1) LD_PRELOAD environment variable. Setting this to the name of the
- library you want to use will cause it to be preloaded.
-2) Adding the name of the library into /etc/ld.so.preload. This will
- cause the library to be preloaded for every executable that is linked
- with libc.
-
-The library should be installed in a directory in which the dynamic loader
-searches for shared libraries (as specified by LD_LIBRARY_PATH,
-/etc/ld.so.conf, etc). Alternatively, you can specify the full path to the
-library that you want to use in LD_PRELOAD or /etc/ld.so.preload as described
-above.
-
-The last option cant be used if you have multiple library versions
-(e.g. 64/32 bit) and want the linker to select between them automatically.
-The best way to handle such case is to use LD_LIBRARY_PATH to point to both the
-lib (the 32 bit version) and lib64 directories and LD_RELOAD the libsdp.so.
-This way the correct 32/64bit libsdp.so will be selected.
-For example running ssh over SDP with OFED distribution from bash this can be written:
-LD_LIBRARY_PATH=/usr/local/ofed/lib64:/usr/local/ofed/lib LD_PRELOAD=libsdp.so ssh
-
-CONFIGURATION:
---------------
-libsdp supports two modes of configuration:
-* simple operation where it converts all calls to socket(2) with a family
- of AF_INET(6) and a type of SOCK_STREAM into family of AF_INET_SDP.
-* selective mode where it uses a configuration file to select which sockets
- will be using SDP and which will not.
-
-For real world applications where communication with X, authentication,
-DNS and other servers connected through TCP is required the selective mode
-is required.
-
-Simple mode will be selected in one of the following conditions:
-* the environment variable SIMPLE_LIBSDP to a non-empty value
-* no configuration file is defined or is un-readble
-* the configuration file does not include any address family rule
-
-For information on how to configure libsdp, see libsdp.conf, which is installed
-in $(sysconfdir) (usually /usr/local/etc or /etc). The user can further control
-the file to be used for configuration by setting the environment variable:
-LIBSDP_CONFIG_FILE
-
-LIMITATIONS:
-------------
-1. Applications statically linked with libc will not allow dynamic pre-loading
- to port these applications to use SDP one needs to replace specific socket
- calls (within the application) with AF_INET_SDP and recompile.
-2. If for some reason the dynamic linker fail to pre-load libc before the
- libsdp.so is initialized or it does not support RTDL_NEXT, libsdp will
- fail to find the libc socket API. To overcome this situation a simple
- implementation of hijacking "socket" call is provided in libsdp_sys.
- This partial implementation does not support any configuration and is
- limited to i386 architecture.
-3. Non-blocking connect in "both" mode defaults to SDP. Specific rules might be
- needed for applications to operate properly.
diff --git a/contrib/ofed/libsdp/autogen.sh b/contrib/ofed/libsdp/autogen.sh
deleted file mode 100755
index fd47839..0000000
--- a/contrib/ofed/libsdp/autogen.sh
+++ /dev/null
@@ -1,8 +0,0 @@
-#! /bin/sh
-
-set -x
-aclocal -I config
-libtoolize --force --copy
-autoheader
-automake --foreign --add-missing --copy
-autoconf
diff --git a/contrib/ofed/libsdp/changelog_from_git.sh b/contrib/ofed/libsdp/changelog_from_git.sh
deleted file mode 100755
index e3d86b2..0000000
--- a/contrib/ofed/libsdp/changelog_from_git.sh
+++ /dev/null
@@ -1,3 +0,0 @@
-#!/bin/sh
-
-git log --pretty=format:"%ai %an <%ae>%n * %h %s%n"
diff --git a/contrib/ofed/libsdp/config/libsdp_indent b/contrib/ofed/libsdp/config/libsdp_indent
deleted file mode 100755
index 6bae67d..0000000
--- a/contrib/ofed/libsdp/config/libsdp_indent
+++ /dev/null
@@ -1,71 +0,0 @@
-#!/bin/bash
-#
-# Copyright (c) 2006 Mellanox Technologies LTD. All rights reserved.
-#
-# This software is available to you under a choice of one of two
-# licenses. You may choose to be licensed under the terms of the GNU
-# General Public License (GPL) Version 2, available from the file
-# COPYING in the main directory of this source tree, or the
-# OpenIB.org BSD license below:
-#
-# Redistribution and use in source and binary forms, with or
-# without modification, are permitted provided that the following
-# conditions are met:
-#
-# - Redistributions of source code must retain the above
-# copyright notice, this list of conditions and the following
-# disclaimer.
-#
-# - Redistributions in binary form must reproduce the above
-# copyright notice, this list of conditions and the following
-# disclaimer in the documentation and/or other materials
-# provided with the distribution.
-#
-# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
-# BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
-# ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
-# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-# SOFTWARE.
-#
-# $Id: osm_indent 4707 2006-01-03 16:18:08Z halr $
-#
-#########################################################################
-#
-# Abstract:
-# Indent script for enforcing source code formatting.
-#
-# This is the indent format used for libsdp:
-#
-# -bad Blank line after declarations
-# -bap Blank line after Procedures
-# -nbbb NO Blank line before block comments
-# -nbbo NO Break after Boolean operator
-# -bl Break after if line
-# -bli0 Indent for braces is 0
-# -bls Break after struct declarations
-# -cbi0 Case break indent 0
-# -ci3 Continue indent 3 spaces
-# -cli0 Case label indent 0 spaces
-# -ncs No space after cast operator
-# -hnl Honor existing newlines on long lines
-# -i3 Substitute indent with 3 spaces
-# -npcs No space after procedure calls
-# -prs Space after parenthesis
-# -nsai No space after if keyword - removed
-# -nsaw No space after while keyword - removed
-# -sc Put * at left of comments in a block comment style
-# -nsob Don't swallow unnecessary blank lines
-# -ts3 Tab size is 3
-# -psl Type of procedure return in a separate line
-# -bfda Function declaration arguments in a separate line.
-# -ut No tabs as we allow spaces
-# -br Put braces on line with if, etc
-# -ce Cuddle else and preceeding }
-#
-#########################################################################
-
-eval indent -bad -bap -nbbb -nbbo -bl -bli0 -bls -cbi0 -ci3 -cli0 -ncs \
- -hnl -i3 -npcs -prs -sc -nsob -ts3 -psl -bfda -ut -br -ce $*
diff --git a/contrib/ofed/libsdp/configure.in b/contrib/ofed/libsdp/configure.in
deleted file mode 100644
index b1f34a4..0000000
--- a/contrib/ofed/libsdp/configure.in
+++ /dev/null
@@ -1,59 +0,0 @@
-# -*- Autoconf -*-
-# Process this file with autoconf to produce a configure script.
-
-
-AC_PREREQ(2.57)
-AC_INIT(libsdp, 1.1.108, openib-general@openib.org)
-AC_CONFIG_SRCDIR([src/port.c])
-AC_CONFIG_AUX_DIR(config)
-AM_CONFIG_HEADER(config.h)
-AM_INIT_AUTOMAKE(libsdp, 1.1.108)
-
-AC_CANONICAL_HOST
-AM_MAINTAINER_MODE
-
-AC_DISABLE_STATIC
-AC_PROG_LIBTOOL
-
-# Checks for programs.
-AC_PROG_CC
-AM_PROG_LEX
-AC_PROG_YACC
-
-# Checks for libraries.
-
-# Checks for header files.
-AC_HEADER_STDC
-AC_CHECK_HEADERS([arpa/inet.h netinet/in.h stdlib.h string.h sys/socket.h syslog.h unistd.h])
-
-# Checks for typedefs, structures, and compiler characteristics.
-AC_C_CONST
-
-# Checks for library functions.
-AC_REPLACE_FNMATCH
-AC_PROG_GCC_TRADITIONAL
-AC_FUNC_MALLOC
-AC_FUNC_VPRINTF
-AC_CHECK_FUNCS([dup2 memset socket strcasecmp strchr strdup strpbrk strrchr strtoul])
-
-# check OS
-case "${host}" in
-i[[3456]]86-*-linux*) AC_DEFINE(LINUX_BUILD, 1, [OS is linux]) ac_cv_linux_build="yes" ;;
-sparc*-sun-solaris*) AC_DEFINE(SOLARIS_BUILD, 1, [OS is sparc solaris]) ac_cv_solaris_build="yes";;
-esac
-
-AM_CONDITIONAL(LINUX_BUILD, test "$ac_cv_linux_build" = "yes")
-AM_CONDITIONAL(SOLARIS_BUILD, test "$ac_cv_solaris_build" = "yes")
-
-# Check if we should build libsdp_sys
-AC_CACHE_CHECK(whether to build i386-specific libsdp_sys, ac_cv_libsdp_sys,
- AC_TRY_COMPILE(,[
- #if !i386
- #error Not i386
- #endif
- ], ac_cv_libsdp_sys="yes", ac_cv_libsdp_sys="no"))
-
-AM_CONDITIONAL(WANT_LIBSDP_SYS, test "$ac_cv_libsdp_sys" = "yes")
-
-AC_CONFIG_FILES([Makefile src/Makefile libsdp.spec])
-AC_OUTPUT
diff --git a/contrib/ofed/libsdp/libsdp.conf b/contrib/ofed/libsdp/libsdp.conf
deleted file mode 100644
index 9bbd633..0000000
--- a/contrib/ofed/libsdp/libsdp.conf
+++ /dev/null
@@ -1,145 +0,0 @@
-# libsdp.conf - configuration file for libsdp
-#
-# $Id$
-#
-# Comments are starts with # and cause the entire line after it to be ignored.
-# Any beginning whitespace is skipped. Any line that is empty is also skipped.
-#
-# There are 2 main types of statements supported by this configuration file:
-# - "use" - which defines the address family to be used for the sockets that
-# match the line
-# - "log" - for setting logging related configuration. As the log settings
-# takes immidiate effect we define these at the beggining of the file.
-#
-##############################################################################
-# DEAFUALT SETTINGS:
-# Please do not forget to comment if you want to change these.
-# (the rest of this file explains the syntax and give examples)
-#
-# Get errors printed into the files /tmp/libsdp.log.<uid>/log
-# or /var/log/<path> for root
-log min-level 9 destination file libsdp.log
-#
-# By default we let all servers and client try SDP first.
-# to exclude SDP add "use tcp" rules before these defaults.
-use both server * *:*
-use both client * *:*
-#
-#
-##############################################################################
-#
-# LOG CONFIGURATION:
-# ------------------
-# The log directive allows the user to specify which and where debug and error
-# messages get sent. The log statement format is:
-# log [destination stderr|syslog|file <path>] [min-level <1-9>]
-#
-# destination - defines the destination of the log messages:
-# stderr - messages will be forwarded to the stderr
-# syslog - messages sent to the syslog service
-# file <path> - messages will be written to the file /var/log/<path> for root.
-# for regular user, if full path is requsted <path>.<uid>/log
-# or /tmp/<path>.<uid>/log if no path is requested
-# Due to security reasons, <path> must not be:
-# 1. a soft link
-# 2. owned by other user.
-# 3. Other permissions except User permissions.
-#
-# min-level - defines the verbosity of the log:
-# 9 - only errors are printed
-# 8 - warnings
-# 7 - connect and listen summary (useful for tracking SDP usage)
-# 4 - positive match summary (useful for config file debug)
-# 3 - negative match summary (useful for config file debug)
-# 2 - function calls and return values
-# 1 - debug messages
-#
-# Examples:
-#
-# Get SDP usage per connect and listen into stderr
-# log min-level 7 destination stderr
-#
-# Send errors only into syslog
-# log min-level 9 destination syslog
-#
-##############################################################################
-#
-# SOCKET ADDRESS FAMILY CONTROL:
-# ------------------------------
-# The socket control statements allows the user to specify when libsdp will
-# replace AF_INET/SOCK_STREAM sockets with AF_SDP/SOCK_STREAM
-# sockets. Each control statement specifies a matching rule that all its
-# subexpressions must evaluate as true (logical and) to apply.
-#
-# The statements that control which type of sockets to open are made
-# of the following:
-# use <address-family> <role> <program name> <address|*>:<port range|*>
-#
-# <address-family> can be one of:
-# "sdp" - for specifying when an SDP should be used
-# "tcp" - for specifying when SDP socket should not be matched
-# "both" - for specifying when both SDP and AF_INET sockets should be used.
-#
-# Note: that "both" semantics is different between "server" and "client" roles:
-# For a "server" is means that the server will be listening on both sdp and tcp
-# For a "client" the connect will prefer using sdp but will silently
-# fall back to tcp if the sdp connection failed.
-#
-# <role> can be one of:
-# "server" or "listen" - for defining the listening port address family
-# "client" or "connect" - for defining the connected port address family
-#
-# <program-name|*> field:
-# Defines the program name (not including the path) the rule applies to.
-# Wildcards with same semantics as "ls" are supported (* and ?).
-# So db2* would match on any program with a name starting with db2.
-# t?cp would match on ttcp, etc.
-# If not provided (default) the statement matches all programs.
-#
-# <address|*> means:
-# Either the local address the server is bind to or the remote server
-# address the client connects to. Syntax for address matching is:
-# <IPv4/IPv6 address>[/<prefix_length>]|*
-# IP address = IPv4 in dotted-quad format, "ddd.ddd.ddd.ddd" or IPv6 network
-# address in any allowed IPv6 address format.
-# prefix_length = Number of bits to match. A prefix_length of 16 matches the
-# subnet mask 255.255.0.0 in IPv4, or ffff::0 in IPv6.
-# A prefix_length of 32 for IPv4 or 128 for IPv6 requires
-# matching of the exact IP.
-#
-# <port range> is:
-# start-port[-end-port] where port numbers are >0 and < 65536
-#
-# Rules are evaluated in order of definition. So the first match wins.
-# If no match is made libsdp will default to "both".
-#
-# Examples:
-#
-# Use SDP by clients connecting to machines that belongs to subnet 192.168.1.*
-# family role program address:port[-range]
-# use sdp connect * 192.168.1.0/24:*
-#
-# Use SDP by clients connecting to machines that belongs to subnet 1234:5678::*
-# family role program address:port[-range]
-# use sdp connect * 1234:5678::0/64:*
-#
-# Use SDP by ttcp when it connects to port 5001 of any machine
-# family role program address:port[-range]
-# use sdp listen ttcp *:5001
-#
-# Use TCP for any program with name starting with ttcp* serving ports 22 to 25
-# family role program address:port[-range]
-# use tcp server ttcp* *:22-25
-#
-# Listen on both TCP and SDP by any server that listen on port 8080
-# family role program address:port[-range]
-# use both server * *:8080
-#
-# Connect ssh through SDP and fallback to TCP to hosts on 11.4.8.* port 22
-# family role program address:port[-range]
-# use both connect * 11.4.8.0/24:22
-#
-# NOTE: If all "use" rules are commented SDP will take "simple SDP"
-# mode and use SDP for all connections
-#
-##############################################################################
diff --git a/contrib/ofed/libsdp/libsdp.spec.in b/contrib/ofed/libsdp/libsdp.spec.in
deleted file mode 100644
index 971f2bc..0000000
--- a/contrib/ofed/libsdp/libsdp.spec.in
+++ /dev/null
@@ -1,61 +0,0 @@
-
-Summary: LD_PRELOAD-able library for using SDP
-Name: libsdp
-Version: @VERSION@
-Release: 1%{?dist}
-License: GPL/BSD
-Group: System Environment/Libraries
-BuildRoot: %{_tmppath}/%{name}-%{version}-root
-Source: http://www.openfabrics.org/downloads/%{name}-%{version}.tar.gz
-Url: http://www.openfabrics.org/
-
-%description
-libsdp can be LD_PRELOAD-ed to have a sockets application use
-InfiniBand Sockets Direct Protocol (SDP) instead of TCP, transparently
-and without recompiling the application.
-
-%package devel
-Summary: Development files for the libsdp
-Group: System Environment/Libraries
-Requires: %{name} = %{version}-%{release}, logrotate
-
-%description devel
-Development files of libsdp that may be linked directly to an
-application, which may be useful for debugging.
-
-%prep
-%setup -q
-
-%build
-%configure
-make
-
-%install
-etc=$RPM_BUILD_ROOT%{_sysconfdir}
-make DESTDIR=${RPM_BUILD_ROOT} install
-# remove unpackaged files from the buildroot
-rm -f $RPM_BUILD_ROOT%{_libdir}/*.la
-mkdir -p $etc/logrotate.d
-install -m 644 scripts/libsdp.logrotate $etc/logrotate.d/libsdp
-
-%clean
-rm -rf $RPM_BUILD_ROOT
-
-%files
-# For set-user-ID/set-group-ID ELF binaries, only libraries in the standard search directories that are also set-user-ID
-# To do so, change line below to: %defattr(6644,root,root)
-%defattr(0644,root,root)
-%{_libdir}/libsdp*.so*
-%defattr(0644,root,root)
-%config(noreplace) %{_sysconfdir}/libsdp.conf
-%config(noreplace) %{_includedir}/linux/sdp_inet.h
-%doc README NEWS ChangeLog COPYING
-%config(noreplace) %{_sysconfdir}/logrotate.d/libsdp
-
-%files devel
-%defattr(0644,root,root,-)
-%{_libdir}/libsdp*.so
-
-%changelog
-* Sun Jul 22 2007 Vladimir Sokolovsky <vlad@mellanox.co.il>
-- Initial packaging
diff --git a/contrib/ofed/libsdp/scripts/libsdp.logrotate b/contrib/ofed/libsdp/scripts/libsdp.logrotate
deleted file mode 100644
index 3e54ff6..0000000
--- a/contrib/ofed/libsdp/scripts/libsdp.logrotate
+++ /dev/null
@@ -1,6 +0,0 @@
-/var/log/libsdp.log {
- missingok
- notifempty
- copytruncate
- compress
-}
diff --git a/contrib/ofed/libsdp/src/Makefile.am b/contrib/ofed/libsdp/src/Makefile.am
deleted file mode 100644
index f6907b27..0000000
--- a/contrib/ofed/libsdp/src/Makefile.am
+++ /dev/null
@@ -1,29 +0,0 @@
-lib_LTLIBRARIES = libsdp.la $(LIB_SDP_SYS)
-if WANT_LIBSDP_SYS
-LIB_SDP_SYS = libsdp_sys.la
-endif
-
-AM_CFLAGS = -Wall -DSYSCONFDIR=\"$(sysconfdir)\"
-
-libsdp_la_SOURCES = log.c match.c port.c config_parser.c config_scanner.c
-libsdp_la_LDFLAGS = -version-info 1 -ldl -lc
-if SOLARIS_BUILD
-libsdp_la_LDFLAGS += -lsocket
-endif
-libsdp_sys_la_SOURCES = socket.c
-libsdp_sys_la_LDFLAGS = -version-info 1
-
-EXTRA_DIST = libsdp.h linux/sdp_inet.h config_parser.h
-
-config_parser.c: @MAINTAINER_MODE_TRUE@ $(srcdir)/config_parser.y
- $(YACC) -y -plibsdp_yy -d $(srcdir)/config_parser.y
- mv y.tab.c config_parser.c
- mv y.tab.h config_parser.h
- cp -f config_parser.c config_parser.h $(srcdir)/
-
-config_scanner.c: @MAINTAINER_MODE_TRUE@ $(srcdir)/config_scanner.l
- $(LEX) -Plibsdp_yy $(srcdir)/config_scanner.l
- mv lex.libsdp_yy.c config_scanner.c
- cp -f config_scanner.c $(srcdir)/config_scanner.c
-
-nobase_include_HEADERS = linux/sdp_inet.h
diff --git a/contrib/ofed/libsdp/src/config_parser.c b/contrib/ofed/libsdp/src/config_parser.c
deleted file mode 100644
index 7f549d6..0000000
--- a/contrib/ofed/libsdp/src/config_parser.c
+++ /dev/null
@@ -1,1908 +0,0 @@
-/* A Bison parser, made by GNU Bison 2.3. */
-
-/* Skeleton implementation for Bison's Yacc-like parsers in C
-
- Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006
- Free Software Foundation, Inc.
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2, or (at your option)
- any later version.
-
- This program 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 this program; if not, write to the Free Software
- Foundation, Inc., 51 Franklin Street, Fifth Floor,
- Boston, MA 02110-1301, USA. */
-
-/* As a special exception, you may create a larger work that contains
- part or all of the Bison parser skeleton and distribute that work
- under terms of your choice, so long as that work isn't itself a
- parser generator using the skeleton or a modified version thereof
- as a parser skeleton. Alternatively, if you modify or redistribute
- the parser skeleton itself, you may (at your option) remove this
- special exception, which will cause the skeleton and the resulting
- Bison output files to be licensed under the GNU General Public
- License without this special exception.
-
- This special exception was added by the Free Software Foundation in
- version 2.2 of Bison. */
-
-/* C LALR(1) parser skeleton written by Richard Stallman, by
- simplifying the original so-called "semantic" parser. */
-
-/* All symbols defined below should begin with yy or YY, to avoid
- infringing on user name space. This should be done even for local
- variables, as they might otherwise be expanded by user macros.
- There are some unavoidable exceptions within include files to
- define necessary library symbols; they are noted "INFRINGES ON
- USER NAME SPACE" below. */
-
-/* Identify Bison output. */
-#define YYBISON 1
-
-/* Bison version. */
-#define YYBISON_VERSION "2.3"
-
-/* Skeleton name. */
-#define YYSKELETON_NAME "yacc.c"
-
-/* Pure parsers. */
-#define YYPURE 0
-
-/* Using locations. */
-#define YYLSP_NEEDED 0
-
-/* Substitute the variable and function names. */
-#define yyparse libsdp_yyparse
-#define yylex libsdp_yylex
-#define yyerror libsdp_yyerror
-#define yylval libsdp_yylval
-#define yychar libsdp_yychar
-#define yydebug libsdp_yydebug
-#define yynerrs libsdp_yynerrs
-
-
-/* Tokens. */
-#ifndef YYTOKENTYPE
-# define YYTOKENTYPE
- /* Put the tokens into the symbol table, so that GDB and other debuggers
- know about them. */
- enum yytokentype {
- USE = 258,
- CLIENT = 259,
- SERVER = 260,
- TCP = 261,
- SDP = 262,
- BOTH = 263,
- INT = 264,
- LOG = 265,
- DEST = 266,
- STDERR = 267,
- SYSLOG = 268,
- FILENAME = 269,
- NAME = 270,
- LEVEL = 271,
- LINE = 272,
- SUBNET = 273
- };
-#endif
-/* Tokens. */
-#define USE 258
-#define CLIENT 259
-#define SERVER 260
-#define TCP 261
-#define SDP 262
-#define BOTH 263
-#define INT 264
-#define LOG 265
-#define DEST 266
-#define STDERR 267
-#define SYSLOG 268
-#define FILENAME 269
-#define NAME 270
-#define LEVEL 271
-#define LINE 272
-#define SUBNET 273
-
-
-
-
-/* Copy the first part of user declarations. */
-#line 39 "./config_parser.y"
-
-
-/* header section */
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-#include "libsdp.h"
-#include <sys/socket.h>
-#include <netinet/in.h>
-#include <arpa/inet.h>
-
-#define YYERROR_VERBOSE 1
-
-extern int yyerror(char *msg);
-extern int yylex(void);
-static int parse_err = 0;
-
-struct use_family_rule *__sdp_clients_family_rules_head = NULL;
-struct use_family_rule *__sdp_clients_family_rules_tail = NULL;
-struct use_family_rule *__sdp_servers_family_rules_head = NULL;
-struct use_family_rule *__sdp_servers_family_rules_tail = NULL;
-
-/* some globals to store intermidiate parser state */
-static struct use_family_rule __sdp_rule;
-static int current_role = 0;
-
-int __sdp_config_empty(
- void
- )
-{
- return ( (__sdp_clients_family_rules_head == NULL) &&
- (__sdp_servers_family_rules_head == NULL) );
-}
-
-static void __sdp_set_ip_addr(char *addr)
-{
- int rc;
- char *addrlen;
- struct sockaddr_in *addr4 = (struct sockaddr_in *)(&__sdp_rule.ip);
- struct sockaddr_in6 *addr6 = (struct sockaddr_in6 *)(&__sdp_rule.ip);
- int prefixlen = 0;
-
- addrlen = strrchr(addr, '/');
- if (addrlen) {
- prefixlen = atoi(addrlen + 1);
- *addrlen = '\0';
- }
-
- rc = inet_pton(AF_INET, addr, &addr4->sin_addr);
- if (rc > 0) {
- addr4->sin_family = AF_INET;
- __sdp_rule.prefixlen = prefixlen ?: 32;
- return;
- }
-
- rc = inet_pton(AF_INET6, addr, &addr6->sin6_addr);
- if (rc > 0) {
- addr6->sin6_family = AF_INET6;
- __sdp_rule.prefixlen = prefixlen ?: 128;
- return;
- }
-
- parse_err = 1;
- yyerror("provided address is not legal");
-}
-
-static const char *addr2str(struct sockaddr_storage *src)
-{
- static char dst[INET6_ADDRSTRLEN];
- int af = src->ss_family;
- const struct sockaddr_in *addr4 = (const struct sockaddr_in *)src;
- const struct sockaddr_in6 *addr6 = (const struct sockaddr_in6 *)src;
-
- if (af == AF_INET6)
- return inet_ntop(af, &addr6->sin6_addr, dst, INET6_ADDRSTRLEN);
-
- return inet_ntop(af, &addr4->sin_addr, dst, INET6_ADDRSTRLEN);
-}
-
-static void __sdp_set_prog_name_expr(char *prog_name_expr)
-{
- __sdp_rule.prog_name_expr = strdup(prog_name_expr);
- if (!__sdp_rule.prog_name_expr) {
- yyerror("fail to allocate program name expression");
- }
-}
-
-static char *__sdp_get_role_str(int role)
-{
- if (role == 1) return("server");
- if (role == 2) return("client");
- return("unknown role");
-}
-
-extern int __sdp_min_level;
-
-/* dump the current state in readable format */
-static void __sdp_dump_config_state() {
- char buf[1024];
- sprintf(buf, "CONFIG: use %s %s %s",
- __sdp_get_family_str(__sdp_rule.target_family),
- __sdp_get_role_str( current_role ),
- __sdp_rule.prog_name_expr);
- if (__sdp_rule.match_by_addr) {
- sprintf(buf+strlen(buf), " %s/%d",
- addr2str(&__sdp_rule.ip), __sdp_rule.prefixlen);
- } else {
- sprintf(buf+strlen(buf), " *");
- }
- if (__sdp_rule.match_by_port) {
- sprintf(buf+strlen(buf), ":%d",__sdp_rule.sport);
- if (__sdp_rule.eport > __sdp_rule.sport)
- sprintf(buf+strlen(buf), "-%d",__sdp_rule.eport);
- }
- else
- sprintf(buf+strlen(buf), ":*");
- sprintf(buf+strlen(buf), "\n");
- __sdp_log(1, buf);
-}
-
-/* use the above state for making a new rule */
-static void __sdp_add_rule() {
- struct use_family_rule **p_tail, **p_head, *rule;
-
- if (__sdp_min_level <= 1) __sdp_dump_config_state();
- if ( current_role == 1 ) {
- p_tail = &__sdp_servers_family_rules_tail;
- p_head = &__sdp_servers_family_rules_head;
- } else if ( current_role == 2 ) {
- p_tail = &__sdp_clients_family_rules_tail;
- p_head = &__sdp_clients_family_rules_head;
- } else {
- yyerror("ignoring unknown role");
- parse_err = 1;
- return;
- }
-
- rule = (struct use_family_rule *)malloc(sizeof(*rule));
- if (!rule) {
- yyerror("fail to allocate new rule");
- parse_err = 1;
- return;
- }
-
- memset(rule, 0, sizeof(*rule));
- *rule = __sdp_rule;
- rule->prev = *p_tail;
- if (!(*p_head)) {
- *p_head = rule;
- } else {
- (*p_tail)->next = rule;
- } /* if */
- *p_tail = rule;
-}
-
-
-
-/* Enabling traces. */
-#ifndef YYDEBUG
-# define YYDEBUG 1
-#endif
-
-/* Enabling verbose error messages. */
-#ifdef YYERROR_VERBOSE
-# undef YYERROR_VERBOSE
-# define YYERROR_VERBOSE 1
-#else
-# define YYERROR_VERBOSE 1
-#endif
-
-/* Enabling the token table. */
-#ifndef YYTOKEN_TABLE
-# define YYTOKEN_TABLE 0
-#endif
-
-#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
-typedef union YYSTYPE
-#line 197 "./config_parser.y"
-{
- int ival;
- char *sval;
-}
-/* Line 193 of yacc.c. */
-#line 302 "y.tab.c"
- YYSTYPE;
-# define yystype YYSTYPE /* obsolescent; will be withdrawn */
-# define YYSTYPE_IS_DECLARED 1
-# define YYSTYPE_IS_TRIVIAL 1
-#endif
-
-
-
-/* Copy the second part of user declarations. */
-#line 223 "./config_parser.y"
-
- long __sdp_config_line_num;
-
-
-/* Line 216 of yacc.c. */
-#line 318 "y.tab.c"
-
-#ifdef short
-# undef short
-#endif
-
-#ifdef YYTYPE_UINT8
-typedef YYTYPE_UINT8 yytype_uint8;
-#else
-typedef unsigned char yytype_uint8;
-#endif
-
-#ifdef YYTYPE_INT8
-typedef YYTYPE_INT8 yytype_int8;
-#elif (defined __STDC__ || defined __C99__FUNC__ \
- || defined __cplusplus || defined _MSC_VER)
-typedef signed char yytype_int8;
-#else
-typedef short int yytype_int8;
-#endif
-
-#ifdef YYTYPE_UINT16
-typedef YYTYPE_UINT16 yytype_uint16;
-#else
-typedef unsigned short int yytype_uint16;
-#endif
-
-#ifdef YYTYPE_INT16
-typedef YYTYPE_INT16 yytype_int16;
-#else
-typedef short int yytype_int16;
-#endif
-
-#ifndef YYSIZE_T
-# ifdef __SIZE_TYPE__
-# define YYSIZE_T __SIZE_TYPE__
-# elif defined size_t
-# define YYSIZE_T size_t
-# elif ! defined YYSIZE_T && (defined __STDC__ || defined __C99__FUNC__ \
- || defined __cplusplus || defined _MSC_VER)
-# include <stddef.h> /* INFRINGES ON USER NAME SPACE */
-# define YYSIZE_T size_t
-# else
-# define YYSIZE_T unsigned int
-# endif
-#endif
-
-#define YYSIZE_MAXIMUM ((YYSIZE_T) -1)
-
-#ifndef YY_
-# if YYENABLE_NLS
-# if ENABLE_NLS
-# include <libintl.h> /* INFRINGES ON USER NAME SPACE */
-# define YY_(msgid) dgettext ("bison-runtime", msgid)
-# endif
-# endif
-# ifndef YY_
-# define YY_(msgid) msgid
-# endif
-#endif
-
-/* Suppress unused-variable warnings by "using" E. */
-#if ! defined lint || defined __GNUC__
-# define YYUSE(e) ((void) (e))
-#else
-# define YYUSE(e) /* empty */
-#endif
-
-/* Identity function, used to suppress warnings about constant conditions. */
-#ifndef lint
-# define YYID(n) (n)
-#else
-#if (defined __STDC__ || defined __C99__FUNC__ \
- || defined __cplusplus || defined _MSC_VER)
-static int
-YYID (int i)
-#else
-static int
-YYID (i)
- int i;
-#endif
-{
- return i;
-}
-#endif
-
-#if ! defined yyoverflow || YYERROR_VERBOSE
-
-/* The parser invokes alloca or malloc; define the necessary symbols. */
-
-# ifdef YYSTACK_USE_ALLOCA
-# if YYSTACK_USE_ALLOCA
-# ifdef __GNUC__
-# define YYSTACK_ALLOC __builtin_alloca
-# elif defined __BUILTIN_VA_ARG_INCR
-# include <alloca.h> /* INFRINGES ON USER NAME SPACE */
-# elif defined _AIX
-# define YYSTACK_ALLOC __alloca
-# elif defined _MSC_VER
-# include <malloc.h> /* INFRINGES ON USER NAME SPACE */
-# define alloca _alloca
-# else
-# define YYSTACK_ALLOC alloca
-# if ! defined _ALLOCA_H && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
- || defined __cplusplus || defined _MSC_VER)
-# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
-# ifndef _STDLIB_H
-# define _STDLIB_H 1
-# endif
-# endif
-# endif
-# endif
-# endif
-
-# ifdef YYSTACK_ALLOC
- /* Pacify GCC's `empty if-body' warning. */
-# define YYSTACK_FREE(Ptr) do { /* empty */; } while (YYID (0))
-# ifndef YYSTACK_ALLOC_MAXIMUM
- /* The OS might guarantee only one guard page at the bottom of the stack,
- and a page size can be as small as 4096 bytes. So we cannot safely
- invoke alloca (N) if N exceeds 4096. Use a slightly smaller number
- to allow for a few compiler-allocated temporary stack slots. */
-# define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */
-# endif
-# else
-# define YYSTACK_ALLOC YYMALLOC
-# define YYSTACK_FREE YYFREE
-# ifndef YYSTACK_ALLOC_MAXIMUM
-# define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
-# endif
-# if (defined __cplusplus && ! defined _STDLIB_H \
- && ! ((defined YYMALLOC || defined malloc) \
- && (defined YYFREE || defined free)))
-# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
-# ifndef _STDLIB_H
-# define _STDLIB_H 1
-# endif
-# endif
-# ifndef YYMALLOC
-# define YYMALLOC malloc
-# if ! defined malloc && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
- || defined __cplusplus || defined _MSC_VER)
-void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
-# endif
-# endif
-# ifndef YYFREE
-# define YYFREE free
-# if ! defined free && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
- || defined __cplusplus || defined _MSC_VER)
-void free (void *); /* INFRINGES ON USER NAME SPACE */
-# endif
-# endif
-# endif
-#endif /* ! defined yyoverflow || YYERROR_VERBOSE */
-
-
-#if (! defined yyoverflow \
- && (! defined __cplusplus \
- || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
-
-/* A type that is properly aligned for any stack member. */
-union yyalloc
-{
- yytype_int16 yyss;
- YYSTYPE yyvs;
- };
-
-/* The size of the maximum gap between one aligned stack and the next. */
-# define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
-
-/* The size of an array large to enough to hold all stacks, each with
- N elements. */
-# define YYSTACK_BYTES(N) \
- ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \
- + YYSTACK_GAP_MAXIMUM)
-
-/* Copy COUNT objects from FROM to TO. The source and destination do
- not overlap. */
-# ifndef YYCOPY
-# if defined __GNUC__ && 1 < __GNUC__
-# define YYCOPY(To, From, Count) \
- __builtin_memcpy (To, From, (Count) * sizeof (*(From)))
-# else
-# define YYCOPY(To, From, Count) \
- do \
- { \
- YYSIZE_T yyi; \
- for (yyi = 0; yyi < (Count); yyi++) \
- (To)[yyi] = (From)[yyi]; \
- } \
- while (YYID (0))
-# endif
-# endif
-
-/* Relocate STACK from its old location to the new one. The
- local variables YYSIZE and YYSTACKSIZE give the old and new number of
- elements in the stack, and YYPTR gives the new location of the
- stack. Advance YYPTR to a properly aligned location for the next
- stack. */
-# define YYSTACK_RELOCATE(Stack) \
- do \
- { \
- YYSIZE_T yynewbytes; \
- YYCOPY (&yyptr->Stack, Stack, yysize); \
- Stack = &yyptr->Stack; \
- yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
- yyptr += yynewbytes / sizeof (*yyptr); \
- } \
- while (YYID (0))
-
-#endif
-
-/* YYFINAL -- State number of the termination state. */
-#define YYFINAL 7
-/* YYLAST -- Last index in YYTABLE. */
-#define YYLAST 31
-
-/* YYNTOKENS -- Number of terminals. */
-#define YYNTOKENS 22
-/* YYNNTS -- Number of nonterminals. */
-#define YYNNTS 16
-/* YYNRULES -- Number of rules. */
-#define YYNRULES 31
-/* YYNRULES -- Number of states. */
-#define YYNSTATES 44
-
-/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
-#define YYUNDEFTOK 2
-#define YYMAXUTOK 273
-
-#define YYTRANSLATE(YYX) \
- ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
-
-/* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */
-static const yytype_uint8 yytranslate[] =
-{
- 0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 20, 2, 2, 21, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 19, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 1, 2, 3, 4,
- 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
- 15, 16, 17, 18
-};
-
-#if YYDEBUG
-/* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
- YYRHS. */
-static const yytype_uint8 yyprhs[] =
-{
- 0, 0, 3, 5, 8, 9, 11, 14, 15, 18,
- 20, 22, 26, 27, 30, 33, 36, 39, 43, 46,
- 55, 57, 59, 61, 63, 65, 67, 69, 71, 73,
- 75, 79
-};
-
-/* YYRHS -- A `-1'-separated list of the rules' RHS. */
-static const yytype_int8 yyrhs[] =
-{
- 25, 0, -1, 17, -1, 23, 17, -1, -1, 23,
- -1, 24, 26, -1, -1, 26, 27, -1, 28, -1,
- 32, -1, 10, 29, 23, -1, -1, 29, 30, -1,
- 29, 31, -1, 11, 12, -1, 11, 13, -1, 11,
- 14, 15, -1, 16, 9, -1, 3, 33, 34, 35,
- 36, 19, 37, 23, -1, 6, -1, 7, -1, 8,
- -1, 5, -1, 4, -1, 15, -1, 20, -1, 18,
- -1, 20, -1, 9, -1, 9, 21, 9, -1, 20,
- -1
-};
-
-/* YYRLINE[YYN] -- source line where rule number YYN was defined. */
-static const yytype_uint16 yyrline[] =
-{
- 0, 229, 229, 230, 232, 233, 236, 239, 240, 244,
- 245, 249, 252, 253, 254, 258, 259, 260, 264, 268,
- 272, 273, 274, 278, 279, 283, 284, 288, 289, 293,
- 294, 295
-};
-#endif
-
-#if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
-/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
- First, the terminals, then, starting at YYNTOKENS, nonterminals. */
-static const char *const yytname[] =
-{
- "$end", "error", "$undefined", "\"use\"", "\"client or connect\"",
- "\"server or listen\"", "\"tcp\"", "\"sdp\"", "\"both\"",
- "\"integer value\"", "\"log statement\"", "\"destination\"",
- "\"stderr\"", "\"syslog\"", "\"file\"", "\"a name\"", "\"min-level\"",
- "\"new line\"", "\"ip address\"", "':'", "'*'", "'-'", "$accept", "NL",
- "ONL", "config", "statements", "statement", "log_statement", "log_opts",
- "log_dest", "verbosity", "socket_statement", "family", "role", "program",
- "address", "ports", 0
-};
-#endif
-
-# ifdef YYPRINT
-/* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to
- token YYLEX-NUM. */
-static const yytype_uint16 yytoknum[] =
-{
- 0, 256, 257, 258, 259, 260, 261, 262, 263, 264,
- 265, 266, 267, 268, 269, 270, 271, 272, 273, 58,
- 42, 45
-};
-# endif
-
-/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
-static const yytype_uint8 yyr1[] =
-{
- 0, 22, 23, 23, 24, 24, 25, 26, 26, 27,
- 27, 28, 29, 29, 29, 30, 30, 30, 31, 32,
- 33, 33, 33, 34, 34, 35, 35, 36, 36, 37,
- 37, 37
-};
-
-/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
-static const yytype_uint8 yyr2[] =
-{
- 0, 2, 1, 2, 0, 1, 2, 0, 2, 1,
- 1, 3, 0, 2, 2, 2, 2, 3, 2, 8,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 3, 1
-};
-
-/* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state
- STATE-NUM when YYTABLE doesn't specify something else to do. Zero
- means the default is an error. */
-static const yytype_uint8 yydefact[] =
-{
- 4, 2, 5, 7, 0, 3, 6, 1, 0, 12,
- 8, 9, 10, 20, 21, 22, 0, 0, 24, 23,
- 0, 0, 0, 11, 13, 14, 25, 26, 0, 15,
- 16, 0, 18, 27, 28, 0, 17, 0, 29, 31,
- 0, 0, 19, 30
-};
-
-/* YYDEFGOTO[NTERM-NUM]. */
-static const yytype_int8 yydefgoto[] =
-{
- -1, 2, 3, 4, 6, 10, 11, 17, 24, 25,
- 12, 16, 20, 28, 35, 40
-};
-
-/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
- STATE-NUM. */
-#define YYPACT_NINF -18
-static const yytype_int8 yypact[] =
-{
- -10, -18, 5, -18, 21, -18, -1, -18, 7, -18,
- -18, -18, -18, -18, -18, -18, 15, -6, -18, -18,
- -12, 4, 16, 5, -18, -18, -18, -18, -14, -18,
- -18, 9, -18, -18, -18, 8, -18, -8, 10, -18,
- -10, 17, 5, -18
-};
-
-/* YYPGOTO[NTERM-NUM]. */
-static const yytype_int8 yypgoto[] =
-{
- -18, -17, -18, -18, -18, -18, -18, -18, -18, -18,
- -18, -18, -18, -18, -18, -18
-};
-
-/* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If
- positive, shift that token. If negative, reduce the rule which
- number is the opposite. If zero, do what YYDEFACT says.
- If YYTABLE_NINF, syntax error. */
-#define YYTABLE_NINF -1
-static const yytype_uint8 yytable[] =
-{
- 23, 38, 8, 26, 33, 21, 34, 1, 27, 9,
- 22, 1, 39, 13, 14, 15, 29, 30, 31, 18,
- 19, 7, 5, 42, 36, 32, 43, 37, 0, 0,
- 0, 41
-};
-
-static const yytype_int8 yycheck[] =
-{
- 17, 9, 3, 15, 18, 11, 20, 17, 20, 10,
- 16, 17, 20, 6, 7, 8, 12, 13, 14, 4,
- 5, 0, 17, 40, 15, 9, 9, 19, -1, -1,
- -1, 21
-};
-
-/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
- symbol of state STATE-NUM. */
-static const yytype_uint8 yystos[] =
-{
- 0, 17, 23, 24, 25, 17, 26, 0, 3, 10,
- 27, 28, 32, 6, 7, 8, 33, 29, 4, 5,
- 34, 11, 16, 23, 30, 31, 15, 20, 35, 12,
- 13, 14, 9, 18, 20, 36, 15, 19, 9, 20,
- 37, 21, 23, 9
-};
-
-#define yyerrok (yyerrstatus = 0)
-#define yyclearin (yychar = YYEMPTY)
-#define YYEMPTY (-2)
-#define YYEOF 0
-
-#define YYACCEPT goto yyacceptlab
-#define YYABORT goto yyabortlab
-#define YYERROR goto yyerrorlab
-
-
-/* Like YYERROR except do call yyerror. This remains here temporarily
- to ease the transition to the new meaning of YYERROR, for GCC.
- Once GCC version 2 has supplanted version 1, this can go. */
-
-#define YYFAIL goto yyerrlab
-
-#define YYRECOVERING() (!!yyerrstatus)
-
-#define YYBACKUP(Token, Value) \
-do \
- if (yychar == YYEMPTY && yylen == 1) \
- { \
- yychar = (Token); \
- yylval = (Value); \
- yytoken = YYTRANSLATE (yychar); \
- YYPOPSTACK (1); \
- goto yybackup; \
- } \
- else \
- { \
- yyerror (YY_("syntax error: cannot back up")); \
- YYERROR; \
- } \
-while (YYID (0))
-
-
-#define YYTERROR 1
-#define YYERRCODE 256
-
-
-/* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
- If N is 0, then set CURRENT to the empty location which ends
- the previous symbol: RHS[0] (always defined). */
-
-#define YYRHSLOC(Rhs, K) ((Rhs)[K])
-#ifndef YYLLOC_DEFAULT
-# define YYLLOC_DEFAULT(Current, Rhs, N) \
- do \
- if (YYID (N)) \
- { \
- (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \
- (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \
- (Current).last_line = YYRHSLOC (Rhs, N).last_line; \
- (Current).last_column = YYRHSLOC (Rhs, N).last_column; \
- } \
- else \
- { \
- (Current).first_line = (Current).last_line = \
- YYRHSLOC (Rhs, 0).last_line; \
- (Current).first_column = (Current).last_column = \
- YYRHSLOC (Rhs, 0).last_column; \
- } \
- while (YYID (0))
-#endif
-
-
-/* YY_LOCATION_PRINT -- Print the location on the stream.
- This macro was not mandated originally: define only if we know
- we won't break user code: when these are the locations we know. */
-
-#ifndef YY_LOCATION_PRINT
-# if YYLTYPE_IS_TRIVIAL
-# define YY_LOCATION_PRINT(File, Loc) \
- fprintf (File, "%d.%d-%d.%d", \
- (Loc).first_line, (Loc).first_column, \
- (Loc).last_line, (Loc).last_column)
-# else
-# define YY_LOCATION_PRINT(File, Loc) ((void) 0)
-# endif
-#endif
-
-
-/* YYLEX -- calling `yylex' with the right arguments. */
-
-#ifdef YYLEX_PARAM
-# define YYLEX yylex (YYLEX_PARAM)
-#else
-# define YYLEX yylex ()
-#endif
-
-/* Enable debugging if requested. */
-#if YYDEBUG
-
-# ifndef YYFPRINTF
-# include <stdio.h> /* INFRINGES ON USER NAME SPACE */
-# define YYFPRINTF fprintf
-# endif
-
-# define YYDPRINTF(Args) \
-do { \
- if (yydebug) \
- YYFPRINTF Args; \
-} while (YYID (0))
-
-# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
-do { \
- if (yydebug) \
- { \
- YYFPRINTF (stderr, "%s ", Title); \
- yy_symbol_print (stderr, \
- Type, Value); \
- YYFPRINTF (stderr, "\n"); \
- } \
-} while (YYID (0))
-
-
-/*--------------------------------.
-| Print this symbol on YYOUTPUT. |
-`--------------------------------*/
-
-/*ARGSUSED*/
-#if (defined __STDC__ || defined __C99__FUNC__ \
- || defined __cplusplus || defined _MSC_VER)
-static void
-yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep)
-#else
-static void
-yy_symbol_value_print (yyoutput, yytype, yyvaluep)
- FILE *yyoutput;
- int yytype;
- YYSTYPE const * const yyvaluep;
-#endif
-{
- if (!yyvaluep)
- return;
-# ifdef YYPRINT
- if (yytype < YYNTOKENS)
- YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
-# else
- YYUSE (yyoutput);
-# endif
- switch (yytype)
- {
- default:
- break;
- }
-}
-
-
-/*--------------------------------.
-| Print this symbol on YYOUTPUT. |
-`--------------------------------*/
-
-#if (defined __STDC__ || defined __C99__FUNC__ \
- || defined __cplusplus || defined _MSC_VER)
-static void
-yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep)
-#else
-static void
-yy_symbol_print (yyoutput, yytype, yyvaluep)
- FILE *yyoutput;
- int yytype;
- YYSTYPE const * const yyvaluep;
-#endif
-{
- if (yytype < YYNTOKENS)
- YYFPRINTF (yyoutput, "token %s (", yytname[yytype]);
- else
- YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]);
-
- yy_symbol_value_print (yyoutput, yytype, yyvaluep);
- YYFPRINTF (yyoutput, ")");
-}
-
-/*------------------------------------------------------------------.
-| yy_stack_print -- Print the state stack from its BOTTOM up to its |
-| TOP (included). |
-`------------------------------------------------------------------*/
-
-#if (defined __STDC__ || defined __C99__FUNC__ \
- || defined __cplusplus || defined _MSC_VER)
-static void
-yy_stack_print (yytype_int16 *bottom, yytype_int16 *top)
-#else
-static void
-yy_stack_print (bottom, top)
- yytype_int16 *bottom;
- yytype_int16 *top;
-#endif
-{
- YYFPRINTF (stderr, "Stack now");
- for (; bottom <= top; ++bottom)
- YYFPRINTF (stderr, " %d", *bottom);
- YYFPRINTF (stderr, "\n");
-}
-
-# define YY_STACK_PRINT(Bottom, Top) \
-do { \
- if (yydebug) \
- yy_stack_print ((Bottom), (Top)); \
-} while (YYID (0))
-
-
-/*------------------------------------------------.
-| Report that the YYRULE is going to be reduced. |
-`------------------------------------------------*/
-
-#if (defined __STDC__ || defined __C99__FUNC__ \
- || defined __cplusplus || defined _MSC_VER)
-static void
-yy_reduce_print (YYSTYPE *yyvsp, int yyrule)
-#else
-static void
-yy_reduce_print (yyvsp, yyrule)
- YYSTYPE *yyvsp;
- int yyrule;
-#endif
-{
- int yynrhs = yyr2[yyrule];
- int yyi;
- unsigned long int yylno = yyrline[yyrule];
- YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n",
- yyrule - 1, yylno);
- /* The symbols being reduced. */
- for (yyi = 0; yyi < yynrhs; yyi++)
- {
- fprintf (stderr, " $%d = ", yyi + 1);
- yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi],
- &(yyvsp[(yyi + 1) - (yynrhs)])
- );
- fprintf (stderr, "\n");
- }
-}
-
-# define YY_REDUCE_PRINT(Rule) \
-do { \
- if (yydebug) \
- yy_reduce_print (yyvsp, Rule); \
-} while (YYID (0))
-
-/* Nonzero means print parse trace. It is left uninitialized so that
- multiple parsers can coexist. */
-int yydebug;
-#else /* !YYDEBUG */
-# define YYDPRINTF(Args)
-# define YY_SYMBOL_PRINT(Title, Type, Value, Location)
-# define YY_STACK_PRINT(Bottom, Top)
-# define YY_REDUCE_PRINT(Rule)
-#endif /* !YYDEBUG */
-
-
-/* YYINITDEPTH -- initial size of the parser's stacks. */
-#ifndef YYINITDEPTH
-# define YYINITDEPTH 200
-#endif
-
-/* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
- if the built-in stack extension method is used).
-
- Do not make this value too large; the results are undefined if
- YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
- evaluated with infinite-precision integer arithmetic. */
-
-#ifndef YYMAXDEPTH
-# define YYMAXDEPTH 10000
-#endif
-
-
-
-#if YYERROR_VERBOSE
-
-# ifndef yystrlen
-# if defined __GLIBC__ && defined _STRING_H
-# define yystrlen strlen
-# else
-/* Return the length of YYSTR. */
-#if (defined __STDC__ || defined __C99__FUNC__ \
- || defined __cplusplus || defined _MSC_VER)
-static YYSIZE_T
-yystrlen (const char *yystr)
-#else
-static YYSIZE_T
-yystrlen (yystr)
- const char *yystr;
-#endif
-{
- YYSIZE_T yylen;
- for (yylen = 0; yystr[yylen]; yylen++)
- continue;
- return yylen;
-}
-# endif
-# endif
-
-# ifndef yystpcpy
-# if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE
-# define yystpcpy stpcpy
-# else
-/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
- YYDEST. */
-#if (defined __STDC__ || defined __C99__FUNC__ \
- || defined __cplusplus || defined _MSC_VER)
-static char *
-yystpcpy (char *yydest, const char *yysrc)
-#else
-static char *
-yystpcpy (yydest, yysrc)
- char *yydest;
- const char *yysrc;
-#endif
-{
- char *yyd = yydest;
- const char *yys = yysrc;
-
- while ((*yyd++ = *yys++) != '\0')
- continue;
-
- return yyd - 1;
-}
-# endif
-# endif
-
-# ifndef yytnamerr
-/* Copy to YYRES the contents of YYSTR after stripping away unnecessary
- quotes and backslashes, so that it's suitable for yyerror. The
- heuristic is that double-quoting is unnecessary unless the string
- contains an apostrophe, a comma, or backslash (other than
- backslash-backslash). YYSTR is taken from yytname. If YYRES is
- null, do not copy; instead, return the length of what the result
- would have been. */
-static YYSIZE_T
-yytnamerr (char *yyres, const char *yystr)
-{
- if (*yystr == '"')
- {
- YYSIZE_T yyn = 0;
- char const *yyp = yystr;
-
- for (;;)
- switch (*++yyp)
- {
- case '\'':
- case ',':
- goto do_not_strip_quotes;
-
- case '\\':
- if (*++yyp != '\\')
- goto do_not_strip_quotes;
- /* Fall through. */
- default:
- if (yyres)
- yyres[yyn] = *yyp;
- yyn++;
- break;
-
- case '"':
- if (yyres)
- yyres[yyn] = '\0';
- return yyn;
- }
- do_not_strip_quotes: ;
- }
-
- if (! yyres)
- return yystrlen (yystr);
-
- return yystpcpy (yyres, yystr) - yyres;
-}
-# endif
-
-/* Copy into YYRESULT an error message about the unexpected token
- YYCHAR while in state YYSTATE. Return the number of bytes copied,
- including the terminating null byte. If YYRESULT is null, do not
- copy anything; just return the number of bytes that would be
- copied. As a special case, return 0 if an ordinary "syntax error"
- message will do. Return YYSIZE_MAXIMUM if overflow occurs during
- size calculation. */
-static YYSIZE_T
-yysyntax_error (char *yyresult, int yystate, int yychar)
-{
- int yyn = yypact[yystate];
-
- if (! (YYPACT_NINF < yyn && yyn <= YYLAST))
- return 0;
- else
- {
- int yytype = YYTRANSLATE (yychar);
- YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]);
- YYSIZE_T yysize = yysize0;
- YYSIZE_T yysize1;
- int yysize_overflow = 0;
- enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
- char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
- int yyx;
-
-# if 0
- /* This is so xgettext sees the translatable formats that are
- constructed on the fly. */
- YY_("syntax error, unexpected %s");
- YY_("syntax error, unexpected %s, expecting %s");
- YY_("syntax error, unexpected %s, expecting %s or %s");
- YY_("syntax error, unexpected %s, expecting %s or %s or %s");
- YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s");
-# endif
- char *yyfmt;
- char const *yyf;
- static char const yyunexpected[] = "syntax error, unexpected %s";
- static char const yyexpecting[] = ", expecting %s";
- static char const yyor[] = " or %s";
- char yyformat[sizeof yyunexpected
- + sizeof yyexpecting - 1
- + ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2)
- * (sizeof yyor - 1))];
- char const *yyprefix = yyexpecting;
-
- /* Start YYX at -YYN if negative to avoid negative indexes in
- YYCHECK. */
- int yyxbegin = yyn < 0 ? -yyn : 0;
-
- /* Stay within bounds of both yycheck and yytname. */
- int yychecklim = YYLAST - yyn + 1;
- int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
- int yycount = 1;
-
- yyarg[0] = yytname[yytype];
- yyfmt = yystpcpy (yyformat, yyunexpected);
-
- for (yyx = yyxbegin; yyx < yyxend; ++yyx)
- if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
- {
- if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
- {
- yycount = 1;
- yysize = yysize0;
- yyformat[sizeof yyunexpected - 1] = '\0';
- break;
- }
- yyarg[yycount++] = yytname[yyx];
- yysize1 = yysize + yytnamerr (0, yytname[yyx]);
- yysize_overflow |= (yysize1 < yysize);
- yysize = yysize1;
- yyfmt = yystpcpy (yyfmt, yyprefix);
- yyprefix = yyor;
- }
-
- yyf = YY_(yyformat);
- yysize1 = yysize + yystrlen (yyf);
- yysize_overflow |= (yysize1 < yysize);
- yysize = yysize1;
-
- if (yysize_overflow)
- return YYSIZE_MAXIMUM;
-
- if (yyresult)
- {
- /* Avoid sprintf, as that infringes on the user's name space.
- Don't have undefined behavior even if the translation
- produced a string with the wrong number of "%s"s. */
- char *yyp = yyresult;
- int yyi = 0;
- while ((*yyp = *yyf) != '\0')
- {
- if (*yyp == '%' && yyf[1] == 's' && yyi < yycount)
- {
- yyp += yytnamerr (yyp, yyarg[yyi++]);
- yyf += 2;
- }
- else
- {
- yyp++;
- yyf++;
- }
- }
- }
- return yysize;
- }
-}
-#endif /* YYERROR_VERBOSE */
-
-
-/*-----------------------------------------------.
-| Release the memory associated to this symbol. |
-`-----------------------------------------------*/
-
-/*ARGSUSED*/
-#if (defined __STDC__ || defined __C99__FUNC__ \
- || defined __cplusplus || defined _MSC_VER)
-static void
-yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep)
-#else
-static void
-yydestruct (yymsg, yytype, yyvaluep)
- const char *yymsg;
- int yytype;
- YYSTYPE *yyvaluep;
-#endif
-{
- YYUSE (yyvaluep);
-
- if (!yymsg)
- yymsg = "Deleting";
- YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
-
- switch (yytype)
- {
-
- default:
- break;
- }
-}
-
-
-/* Prevent warnings from -Wmissing-prototypes. */
-
-#ifdef YYPARSE_PARAM
-#if defined __STDC__ || defined __cplusplus
-int yyparse (void *YYPARSE_PARAM);
-#else
-int yyparse ();
-#endif
-#else /* ! YYPARSE_PARAM */
-#if defined __STDC__ || defined __cplusplus
-int yyparse (void);
-#else
-int yyparse ();
-#endif
-#endif /* ! YYPARSE_PARAM */
-
-
-
-/* The look-ahead symbol. */
-int yychar;
-
-/* The semantic value of the look-ahead symbol. */
-YYSTYPE yylval;
-
-/* Number of syntax errors so far. */
-int yynerrs;
-
-
-
-/*----------.
-| yyparse. |
-`----------*/
-
-#ifdef YYPARSE_PARAM
-#if (defined __STDC__ || defined __C99__FUNC__ \
- || defined __cplusplus || defined _MSC_VER)
-int
-yyparse (void *YYPARSE_PARAM)
-#else
-int
-yyparse (YYPARSE_PARAM)
- void *YYPARSE_PARAM;
-#endif
-#else /* ! YYPARSE_PARAM */
-#if (defined __STDC__ || defined __C99__FUNC__ \
- || defined __cplusplus || defined _MSC_VER)
-int
-yyparse (void)
-#else
-int
-yyparse ()
-
-#endif
-#endif
-{
-
- int yystate;
- int yyn;
- int yyresult;
- /* Number of tokens to shift before error messages enabled. */
- int yyerrstatus;
- /* Look-ahead token as an internal (translated) token number. */
- int yytoken = 0;
-#if YYERROR_VERBOSE
- /* Buffer for error messages, and its allocated size. */
- char yymsgbuf[128];
- char *yymsg = yymsgbuf;
- YYSIZE_T yymsg_alloc = sizeof yymsgbuf;
-#endif
-
- /* Three stacks and their tools:
- `yyss': related to states,
- `yyvs': related to semantic values,
- `yyls': related to locations.
-
- Refer to the stacks thru separate pointers, to allow yyoverflow
- to reallocate them elsewhere. */
-
- /* The state stack. */
- yytype_int16 yyssa[YYINITDEPTH];
- yytype_int16 *yyss = yyssa;
- yytype_int16 *yyssp;
-
- /* The semantic value stack. */
- YYSTYPE yyvsa[YYINITDEPTH];
- YYSTYPE *yyvs = yyvsa;
- YYSTYPE *yyvsp;
-
-
-
-#define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N))
-
- YYSIZE_T yystacksize = YYINITDEPTH;
-
- /* The variables used to return semantic value and location from the
- action routines. */
- YYSTYPE yyval;
-
-
- /* The number of symbols on the RHS of the reduced rule.
- Keep to zero when no symbol should be popped. */
- int yylen = 0;
-
- YYDPRINTF ((stderr, "Starting parse\n"));
-
- yystate = 0;
- yyerrstatus = 0;
- yynerrs = 0;
- yychar = YYEMPTY; /* Cause a token to be read. */
-
- /* Initialize stack pointers.
- Waste one element of value and location stack
- so that they stay on the same level as the state stack.
- The wasted elements are never initialized. */
-
- yyssp = yyss;
- yyvsp = yyvs;
-
- goto yysetstate;
-
-/*------------------------------------------------------------.
-| yynewstate -- Push a new state, which is found in yystate. |
-`------------------------------------------------------------*/
- yynewstate:
- /* In all cases, when you get here, the value and location stacks
- have just been pushed. So pushing a state here evens the stacks. */
- yyssp++;
-
- yysetstate:
- *yyssp = yystate;
-
- if (yyss + yystacksize - 1 <= yyssp)
- {
- /* Get the current used size of the three stacks, in elements. */
- YYSIZE_T yysize = yyssp - yyss + 1;
-
-#ifdef yyoverflow
- {
- /* Give user a chance to reallocate the stack. Use copies of
- these so that the &'s don't force the real ones into
- memory. */
- YYSTYPE *yyvs1 = yyvs;
- yytype_int16 *yyss1 = yyss;
-
-
- /* Each stack pointer address is followed by the size of the
- data in use in that stack, in bytes. This used to be a
- conditional around just the two extra args, but that might
- be undefined if yyoverflow is a macro. */
- yyoverflow (YY_("memory exhausted"),
- &yyss1, yysize * sizeof (*yyssp),
- &yyvs1, yysize * sizeof (*yyvsp),
-
- &yystacksize);
-
- yyss = yyss1;
- yyvs = yyvs1;
- }
-#else /* no yyoverflow */
-# ifndef YYSTACK_RELOCATE
- goto yyexhaustedlab;
-# else
- /* Extend the stack our own way. */
- if (YYMAXDEPTH <= yystacksize)
- goto yyexhaustedlab;
- yystacksize *= 2;
- if (YYMAXDEPTH < yystacksize)
- yystacksize = YYMAXDEPTH;
-
- {
- yytype_int16 *yyss1 = yyss;
- union yyalloc *yyptr =
- (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
- if (! yyptr)
- goto yyexhaustedlab;
- YYSTACK_RELOCATE (yyss);
- YYSTACK_RELOCATE (yyvs);
-
-# undef YYSTACK_RELOCATE
- if (yyss1 != yyssa)
- YYSTACK_FREE (yyss1);
- }
-# endif
-#endif /* no yyoverflow */
-
- yyssp = yyss + yysize - 1;
- yyvsp = yyvs + yysize - 1;
-
-
- YYDPRINTF ((stderr, "Stack size increased to %lu\n",
- (unsigned long int) yystacksize));
-
- if (yyss + yystacksize - 1 <= yyssp)
- YYABORT;
- }
-
- YYDPRINTF ((stderr, "Entering state %d\n", yystate));
-
- goto yybackup;
-
-/*-----------.
-| yybackup. |
-`-----------*/
-yybackup:
-
- /* Do appropriate processing given the current state. Read a
- look-ahead token if we need one and don't already have one. */
-
- /* First try to decide what to do without reference to look-ahead token. */
- yyn = yypact[yystate];
- if (yyn == YYPACT_NINF)
- goto yydefault;
-
- /* Not known => get a look-ahead token if don't already have one. */
-
- /* YYCHAR is either YYEMPTY or YYEOF or a valid look-ahead symbol. */
- if (yychar == YYEMPTY)
- {
- YYDPRINTF ((stderr, "Reading a token: "));
- yychar = YYLEX;
- }
-
- if (yychar <= YYEOF)
- {
- yychar = yytoken = YYEOF;
- YYDPRINTF ((stderr, "Now at end of input.\n"));
- }
- else
- {
- yytoken = YYTRANSLATE (yychar);
- YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
- }
-
- /* If the proper action on seeing token YYTOKEN is to reduce or to
- detect an error, take that action. */
- yyn += yytoken;
- if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
- goto yydefault;
- yyn = yytable[yyn];
- if (yyn <= 0)
- {
- if (yyn == 0 || yyn == YYTABLE_NINF)
- goto yyerrlab;
- yyn = -yyn;
- goto yyreduce;
- }
-
- if (yyn == YYFINAL)
- YYACCEPT;
-
- /* Count tokens shifted since error; after three, turn off error
- status. */
- if (yyerrstatus)
- yyerrstatus--;
-
- /* Shift the look-ahead token. */
- YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
-
- /* Discard the shifted token unless it is eof. */
- if (yychar != YYEOF)
- yychar = YYEMPTY;
-
- yystate = yyn;
- *++yyvsp = yylval;
-
- goto yynewstate;
-
-
-/*-----------------------------------------------------------.
-| yydefault -- do the default action for the current state. |
-`-----------------------------------------------------------*/
-yydefault:
- yyn = yydefact[yystate];
- if (yyn == 0)
- goto yyerrlab;
- goto yyreduce;
-
-
-/*-----------------------------.
-| yyreduce -- Do a reduction. |
-`-----------------------------*/
-yyreduce:
- /* yyn is the number of a rule to reduce with. */
- yylen = yyr2[yyn];
-
- /* If YYLEN is nonzero, implement the default value of the action:
- `$$ = $1'.
-
- Otherwise, the following line sets YYVAL to garbage.
- This behavior is undocumented and Bison
- users should not rely upon it. Assigning to YYVAL
- unconditionally makes the parser a bit smaller, and it avoids a
- GCC warning that YYVAL may be used uninitialized. */
- yyval = yyvsp[1-yylen];
-
-
- YY_REDUCE_PRINT (yyn);
- switch (yyn)
- {
- case 15:
-#line 258 "./config_parser.y"
- { __sdp_log_set_log_stderr(); }
- break;
-
- case 16:
-#line 259 "./config_parser.y"
- { __sdp_log_set_log_syslog(); }
- break;
-
- case 17:
-#line 260 "./config_parser.y"
- { __sdp_log_set_log_file((yyvsp[(3) - (3)].sval)); }
- break;
-
- case 18:
-#line 264 "./config_parser.y"
- { __sdp_log_set_min_level((yyvsp[(2) - (2)].ival)); }
- break;
-
- case 19:
-#line 268 "./config_parser.y"
- { __sdp_add_rule(); }
- break;
-
- case 20:
-#line 272 "./config_parser.y"
- { __sdp_rule.target_family = USE_TCP; }
- break;
-
- case 21:
-#line 273 "./config_parser.y"
- { __sdp_rule.target_family = USE_SDP; }
- break;
-
- case 22:
-#line 274 "./config_parser.y"
- { __sdp_rule.target_family = USE_BOTH; }
- break;
-
- case 23:
-#line 278 "./config_parser.y"
- { current_role = 1; }
- break;
-
- case 24:
-#line 279 "./config_parser.y"
- { current_role = 2; }
- break;
-
- case 25:
-#line 283 "./config_parser.y"
- { __sdp_set_prog_name_expr((yyvsp[(1) - (1)].sval)); }
- break;
-
- case 26:
-#line 284 "./config_parser.y"
- { __sdp_set_prog_name_expr("*"); }
- break;
-
- case 27:
-#line 288 "./config_parser.y"
- { __sdp_rule.match_by_addr = 1; __sdp_set_ip_addr((yyvsp[(1) - (1)].sval)); }
- break;
-
- case 28:
-#line 289 "./config_parser.y"
- { __sdp_rule.match_by_addr = 0; __sdp_rule.prefixlen = 32; }
- break;
-
- case 29:
-#line 293 "./config_parser.y"
- { __sdp_rule.match_by_port = 1; __sdp_rule.sport= (yyvsp[(1) - (1)].ival); __sdp_rule.eport= (yyvsp[(1) - (1)].ival); }
- break;
-
- case 30:
-#line 294 "./config_parser.y"
- { __sdp_rule.match_by_port = 1; __sdp_rule.sport= (yyvsp[(1) - (3)].ival); __sdp_rule.eport= (yyvsp[(3) - (3)].ival); }
- break;
-
- case 31:
-#line 295 "./config_parser.y"
- { __sdp_rule.match_by_port = 0; __sdp_rule.sport= 0 ; __sdp_rule.eport= 0; }
- break;
-
-
-/* Line 1267 of yacc.c. */
-#line 1632 "y.tab.c"
- default: break;
- }
- YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);
-
- YYPOPSTACK (yylen);
- yylen = 0;
- YY_STACK_PRINT (yyss, yyssp);
-
- *++yyvsp = yyval;
-
-
- /* Now `shift' the result of the reduction. Determine what state
- that goes to, based on the state we popped back to and the rule
- number reduced by. */
-
- yyn = yyr1[yyn];
-
- yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
- if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
- yystate = yytable[yystate];
- else
- yystate = yydefgoto[yyn - YYNTOKENS];
-
- goto yynewstate;
-
-
-/*------------------------------------.
-| yyerrlab -- here on detecting error |
-`------------------------------------*/
-yyerrlab:
- /* If not already recovering from an error, report this error. */
- if (!yyerrstatus)
- {
- ++yynerrs;
-#if ! YYERROR_VERBOSE
- yyerror (YY_("syntax error"));
-#else
- {
- YYSIZE_T yysize = yysyntax_error (0, yystate, yychar);
- if (yymsg_alloc < yysize && yymsg_alloc < YYSTACK_ALLOC_MAXIMUM)
- {
- YYSIZE_T yyalloc = 2 * yysize;
- if (! (yysize <= yyalloc && yyalloc <= YYSTACK_ALLOC_MAXIMUM))
- yyalloc = YYSTACK_ALLOC_MAXIMUM;
- if (yymsg != yymsgbuf)
- YYSTACK_FREE (yymsg);
- yymsg = (char *) YYSTACK_ALLOC (yyalloc);
- if (yymsg)
- yymsg_alloc = yyalloc;
- else
- {
- yymsg = yymsgbuf;
- yymsg_alloc = sizeof yymsgbuf;
- }
- }
-
- if (0 < yysize && yysize <= yymsg_alloc)
- {
- (void) yysyntax_error (yymsg, yystate, yychar);
- yyerror (yymsg);
- }
- else
- {
- yyerror (YY_("syntax error"));
- if (yysize != 0)
- goto yyexhaustedlab;
- }
- }
-#endif
- }
-
-
-
- if (yyerrstatus == 3)
- {
- /* If just tried and failed to reuse look-ahead token after an
- error, discard it. */
-
- if (yychar <= YYEOF)
- {
- /* Return failure if at end of input. */
- if (yychar == YYEOF)
- YYABORT;
- }
- else
- {
- yydestruct ("Error: discarding",
- yytoken, &yylval);
- yychar = YYEMPTY;
- }
- }
-
- /* Else will try to reuse look-ahead token after shifting the error
- token. */
- goto yyerrlab1;
-
-
-/*---------------------------------------------------.
-| yyerrorlab -- error raised explicitly by YYERROR. |
-`---------------------------------------------------*/
-yyerrorlab:
-
- /* Pacify compilers like GCC when the user code never invokes
- YYERROR and the label yyerrorlab therefore never appears in user
- code. */
- if (/*CONSTCOND*/ 0)
- goto yyerrorlab;
-
- /* Do not reclaim the symbols of the rule which action triggered
- this YYERROR. */
- YYPOPSTACK (yylen);
- yylen = 0;
- YY_STACK_PRINT (yyss, yyssp);
- yystate = *yyssp;
- goto yyerrlab1;
-
-
-/*-------------------------------------------------------------.
-| yyerrlab1 -- common code for both syntax error and YYERROR. |
-`-------------------------------------------------------------*/
-yyerrlab1:
- yyerrstatus = 3; /* Each real token shifted decrements this. */
-
- for (;;)
- {
- yyn = yypact[yystate];
- if (yyn != YYPACT_NINF)
- {
- yyn += YYTERROR;
- if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
- {
- yyn = yytable[yyn];
- if (0 < yyn)
- break;
- }
- }
-
- /* Pop the current state because it cannot handle the error token. */
- if (yyssp == yyss)
- YYABORT;
-
-
- yydestruct ("Error: popping",
- yystos[yystate], yyvsp);
- YYPOPSTACK (1);
- yystate = *yyssp;
- YY_STACK_PRINT (yyss, yyssp);
- }
-
- if (yyn == YYFINAL)
- YYACCEPT;
-
- *++yyvsp = yylval;
-
-
- /* Shift the error token. */
- YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp);
-
- yystate = yyn;
- goto yynewstate;
-
-
-/*-------------------------------------.
-| yyacceptlab -- YYACCEPT comes here. |
-`-------------------------------------*/
-yyacceptlab:
- yyresult = 0;
- goto yyreturn;
-
-/*-----------------------------------.
-| yyabortlab -- YYABORT comes here. |
-`-----------------------------------*/
-yyabortlab:
- yyresult = 1;
- goto yyreturn;
-
-#ifndef yyoverflow
-/*-------------------------------------------------.
-| yyexhaustedlab -- memory exhaustion comes here. |
-`-------------------------------------------------*/
-yyexhaustedlab:
- yyerror (YY_("memory exhausted"));
- yyresult = 2;
- /* Fall through. */
-#endif
-
-yyreturn:
- if (yychar != YYEOF && yychar != YYEMPTY)
- yydestruct ("Cleanup: discarding lookahead",
- yytoken, &yylval);
- /* Do not reclaim the symbols of the rule which action triggered
- this YYABORT or YYACCEPT. */
- YYPOPSTACK (yylen);
- YY_STACK_PRINT (yyss, yyssp);
- while (yyssp != yyss)
- {
- yydestruct ("Cleanup: popping",
- yystos[*yyssp], yyvsp);
- YYPOPSTACK (1);
- }
-#ifndef yyoverflow
- if (yyss != yyssa)
- YYSTACK_FREE (yyss);
-#endif
-#if YYERROR_VERBOSE
- if (yymsg != yymsgbuf)
- YYSTACK_FREE (yymsg);
-#endif
- /* Make sure YYID is used. */
- return YYID (yyresult);
-}
-
-
-#line 298 "./config_parser.y"
-
-
-int yyerror(char *msg)
-{
- /* replace the $undefined and $end if exists */
- char *orig_msg = (char*)malloc(strlen(msg)+25);
- char *final_msg = (char*)malloc(strlen(msg)+25);
-
- strcpy(orig_msg, msg);
-
- char *word = strtok(orig_msg, " ");
- final_msg[0] = '\0';
- while (word != NULL) {
- if (!strncmp(word, "$undefined", 10)) {
- strcat(final_msg, "unrecognized-token ");
- } else if (!strncmp(word, "$end",4)) {
- strcat(final_msg, "end-of-file ");
- } else {
- strcat(final_msg, word);
- strcat(final_msg, " ");
- }
- word = strtok(NULL, " ");
- }
-
- __sdp_log(9, "Error (line:%ld) : %s\n", __sdp_config_line_num, final_msg);
- parse_err = 1;
-
- free(orig_msg);
- free(final_msg);
- return 1;
-}
-
-#include <unistd.h>
-#include <errno.h>
-
-/* parse apollo route dump file */
-int __sdp_parse_config (const char *fileName) {
- extern FILE * libsdp_yyin;
-
- /* open the file */
- if (access(fileName, R_OK)) {
- printf("libsdp Error: No access to open File:%s %s\n",
- fileName, strerror(errno));
- return(1);
- }
-
- libsdp_yyin = fopen(fileName,"r");
- if (!libsdp_yyin) {
- printf("libsdp Error: Fail to open File:%s\n", fileName);
- return(1);
- }
- parse_err = 0;
- __sdp_config_line_num = 1;
-
- /* parse it */
- yyparse();
-
- fclose(libsdp_yyin);
- return(parse_err);
-}
-
-
-
diff --git a/contrib/ofed/libsdp/src/config_parser.h b/contrib/ofed/libsdp/src/config_parser.h
deleted file mode 100644
index f1ce892..0000000
--- a/contrib/ofed/libsdp/src/config_parser.h
+++ /dev/null
@@ -1,97 +0,0 @@
-/* A Bison parser, made by GNU Bison 2.3. */
-
-/* Skeleton interface for Bison's Yacc-like parsers in C
-
- Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006
- Free Software Foundation, Inc.
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2, or (at your option)
- any later version.
-
- This program 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 this program; if not, write to the Free Software
- Foundation, Inc., 51 Franklin Street, Fifth Floor,
- Boston, MA 02110-1301, USA. */
-
-/* As a special exception, you may create a larger work that contains
- part or all of the Bison parser skeleton and distribute that work
- under terms of your choice, so long as that work isn't itself a
- parser generator using the skeleton or a modified version thereof
- as a parser skeleton. Alternatively, if you modify or redistribute
- the parser skeleton itself, you may (at your option) remove this
- special exception, which will cause the skeleton and the resulting
- Bison output files to be licensed under the GNU General Public
- License without this special exception.
-
- This special exception was added by the Free Software Foundation in
- version 2.2 of Bison. */
-
-/* Tokens. */
-#ifndef YYTOKENTYPE
-# define YYTOKENTYPE
- /* Put the tokens into the symbol table, so that GDB and other debuggers
- know about them. */
- enum yytokentype {
- USE = 258,
- CLIENT = 259,
- SERVER = 260,
- TCP = 261,
- SDP = 262,
- BOTH = 263,
- INT = 264,
- LOG = 265,
- DEST = 266,
- STDERR = 267,
- SYSLOG = 268,
- FILENAME = 269,
- NAME = 270,
- LEVEL = 271,
- LINE = 272,
- SUBNET = 273
- };
-#endif
-/* Tokens. */
-#define USE 258
-#define CLIENT 259
-#define SERVER 260
-#define TCP 261
-#define SDP 262
-#define BOTH 263
-#define INT 264
-#define LOG 265
-#define DEST 266
-#define STDERR 267
-#define SYSLOG 268
-#define FILENAME 269
-#define NAME 270
-#define LEVEL 271
-#define LINE 272
-#define SUBNET 273
-
-
-
-
-#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
-typedef union YYSTYPE
-#line 197 "./config_parser.y"
-{
- int ival;
- char *sval;
-}
-/* Line 1529 of yacc.c. */
-#line 90 "y.tab.h"
- YYSTYPE;
-# define yystype YYSTYPE /* obsolescent; will be withdrawn */
-# define YYSTYPE_IS_DECLARED 1
-# define YYSTYPE_IS_TRIVIAL 1
-#endif
-
-extern YYSTYPE libsdp_yylval;
-
diff --git a/contrib/ofed/libsdp/src/config_parser.y b/contrib/ofed/libsdp/src/config_parser.y
deleted file mode 100644
index d510283..0000000
--- a/contrib/ofed/libsdp/src/config_parser.y
+++ /dev/null
@@ -1,359 +0,0 @@
-/*
- * Copyright (c) 2006 Mellanox Technologies Ltd. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- * $Id: config_parser.y 1.5 2005/06/29 11:39:27 eitan Exp $
- */
-
-
-/*
-
-*/
-%{
-
-/* header section */
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-#include "libsdp.h"
-#include <sys/socket.h>
-#include <netinet/in.h>
-#include <arpa/inet.h>
-
-#define YYERROR_VERBOSE 1
-
-extern int yyerror(char *msg);
-extern int yylex(void);
-static int parse_err = 0;
-
-struct use_family_rule *__sdp_clients_family_rules_head = NULL;
-struct use_family_rule *__sdp_clients_family_rules_tail = NULL;
-struct use_family_rule *__sdp_servers_family_rules_head = NULL;
-struct use_family_rule *__sdp_servers_family_rules_tail = NULL;
-
-/* some globals to store intermidiate parser state */
-static struct use_family_rule __sdp_rule;
-static int current_role = 0;
-
-int __sdp_config_empty(
- void
- )
-{
- return ( (__sdp_clients_family_rules_head == NULL) &&
- (__sdp_servers_family_rules_head == NULL) );
-}
-
-static void __sdp_set_ip_addr(char *addr)
-{
- int rc;
- char *addrlen;
- struct sockaddr_in *addr4 = (struct sockaddr_in *)(&__sdp_rule.ip);
- struct sockaddr_in6 *addr6 = (struct sockaddr_in6 *)(&__sdp_rule.ip);
- int prefixlen = 0;
-
- addrlen = strrchr(addr, '/');
- if (addrlen) {
- prefixlen = atoi(addrlen + 1);
- *addrlen = '\0';
- }
-
- rc = inet_pton(AF_INET, addr, &addr4->sin_addr);
- if (rc > 0) {
- addr4->sin_family = AF_INET;
- __sdp_rule.prefixlen = prefixlen ?: 32;
- return;
- }
-
- rc = inet_pton(AF_INET6, addr, &addr6->sin6_addr);
- if (rc > 0) {
- addr6->sin6_family = AF_INET6;
- __sdp_rule.prefixlen = prefixlen ?: 128;
- return;
- }
-
- parse_err = 1;
- yyerror("provided address is not legal");
-}
-
-static const char *addr2str(struct sockaddr_storage *src)
-{
- static char dst[INET6_ADDRSTRLEN];
- int af = src->ss_family;
- const struct sockaddr_in *addr4 = (const struct sockaddr_in *)src;
- const struct sockaddr_in6 *addr6 = (const struct sockaddr_in6 *)src;
-
- if (af == AF_INET6)
- return inet_ntop(af, &addr6->sin6_addr, dst, INET6_ADDRSTRLEN);
-
- return inet_ntop(af, &addr4->sin_addr, dst, INET6_ADDRSTRLEN);
-}
-
-static void __sdp_set_prog_name_expr(char *prog_name_expr)
-{
- __sdp_rule.prog_name_expr = strdup(prog_name_expr);
- if (!__sdp_rule.prog_name_expr) {
- yyerror("fail to allocate program name expression");
- }
-}
-
-static char *__sdp_get_role_str(int role)
-{
- if (role == 1) return("server");
- if (role == 2) return("client");
- return("unknown role");
-}
-
-extern int __sdp_min_level;
-
-/* dump the current state in readable format */
-static void __sdp_dump_config_state() {
- char buf[1024];
- sprintf(buf, "CONFIG: use %s %s %s",
- __sdp_get_family_str(__sdp_rule.target_family),
- __sdp_get_role_str( current_role ),
- __sdp_rule.prog_name_expr);
- if (__sdp_rule.match_by_addr) {
- sprintf(buf+strlen(buf), " %s/%d",
- addr2str(&__sdp_rule.ip), __sdp_rule.prefixlen);
- } else {
- sprintf(buf+strlen(buf), " *");
- }
- if (__sdp_rule.match_by_port) {
- sprintf(buf+strlen(buf), ":%d",__sdp_rule.sport);
- if (__sdp_rule.eport > __sdp_rule.sport)
- sprintf(buf+strlen(buf), "-%d",__sdp_rule.eport);
- }
- else
- sprintf(buf+strlen(buf), ":*");
- sprintf(buf+strlen(buf), "\n");
- __sdp_log(1, buf);
-}
-
-/* use the above state for making a new rule */
-static void __sdp_add_rule() {
- struct use_family_rule **p_tail, **p_head, *rule;
-
- if (__sdp_min_level <= 1) __sdp_dump_config_state();
- if ( current_role == 1 ) {
- p_tail = &__sdp_servers_family_rules_tail;
- p_head = &__sdp_servers_family_rules_head;
- } else if ( current_role == 2 ) {
- p_tail = &__sdp_clients_family_rules_tail;
- p_head = &__sdp_clients_family_rules_head;
- } else {
- yyerror("ignoring unknown role");
- parse_err = 1;
- return;
- }
-
- rule = (struct use_family_rule *)malloc(sizeof(*rule));
- if (!rule) {
- yyerror("fail to allocate new rule");
- parse_err = 1;
- return;
- }
-
- memset(rule, 0, sizeof(*rule));
- *rule = __sdp_rule;
- rule->prev = *p_tail;
- if (!(*p_head)) {
- *p_head = rule;
- } else {
- (*p_tail)->next = rule;
- } /* if */
- *p_tail = rule;
-}
-
-%}
-
-
-%union {
- int ival;
- char *sval;
-}
-%token USE "use"
-%token CLIENT "client or connect"
-%token SERVER "server or listen"
-%token TCP "tcp"
-%token SDP "sdp"
-%token BOTH "both"
-%token INT "integer value"
-%token LOG "log statement"
-%token DEST "destination"
-%token STDERR "stderr"
-%token SYSLOG "syslog"
-%token FILENAME "file"
-%token NAME "a name"
-%token LEVEL "min-level"
-%token LINE "new line"
-%token SUBNET "ip address"
-%type <sval> NAME SUBNET
-%type <ival> INT LOG DEST STDERR SYSLOG FILENAME USE TCP SDP BOTH CLIENT SERVER LEVEL LINE
-%debug
-%error-verbose
-%start config
-
-%{
- long __sdp_config_line_num;
-%}
-%%
-
-NL:
- LINE
- | NL LINE;
-
-ONL:
- | NL;
-
-config:
- ONL statements
- ;
-
-statements:
- | statements statement
- ;
-
-statement:
- log_statement
- | socket_statement
- ;
-
-log_statement:
- LOG log_opts NL
- ;
-
-log_opts:
- | log_opts log_dest
- | log_opts verbosity
- ;
-
-log_dest:
- DEST STDERR { __sdp_log_set_log_stderr(); }
- | DEST SYSLOG { __sdp_log_set_log_syslog(); }
- | DEST FILENAME NAME { __sdp_log_set_log_file($3); }
- ;
-
-verbosity:
- LEVEL INT { __sdp_log_set_min_level($2); }
- ;
-
-socket_statement:
- USE family role program address ':' ports NL { __sdp_add_rule(); }
- ;
-
-family:
- TCP { __sdp_rule.target_family = USE_TCP; }
- | SDP { __sdp_rule.target_family = USE_SDP; }
- | BOTH { __sdp_rule.target_family = USE_BOTH; }
- ;
-
-role:
- SERVER { current_role = 1; }
- | CLIENT { current_role = 2; }
- ;
-
-program:
- NAME { __sdp_set_prog_name_expr($1); }
- | '*' { __sdp_set_prog_name_expr("*"); }
- ;
-
-address:
- SUBNET { __sdp_rule.match_by_addr = 1; __sdp_set_ip_addr($1); }
- | '*' { __sdp_rule.match_by_addr = 0; __sdp_rule.prefixlen = 32; }
- ;
-
-ports:
- INT { __sdp_rule.match_by_port = 1; __sdp_rule.sport= $1; __sdp_rule.eport= $1; }
- | INT '-' INT { __sdp_rule.match_by_port = 1; __sdp_rule.sport= $1; __sdp_rule.eport= $3; }
- | '*' { __sdp_rule.match_by_port = 0; __sdp_rule.sport= 0 ; __sdp_rule.eport= 0; }
- ;
-
-%%
-
-int yyerror(char *msg)
-{
- /* replace the $undefined and $end if exists */
- char *orig_msg = (char*)malloc(strlen(msg)+25);
- char *final_msg = (char*)malloc(strlen(msg)+25);
-
- strcpy(orig_msg, msg);
-
- char *word = strtok(orig_msg, " ");
- final_msg[0] = '\0';
- while (word != NULL) {
- if (!strncmp(word, "$undefined", 10)) {
- strcat(final_msg, "unrecognized-token ");
- } else if (!strncmp(word, "$end",4)) {
- strcat(final_msg, "end-of-file ");
- } else {
- strcat(final_msg, word);
- strcat(final_msg, " ");
- }
- word = strtok(NULL, " ");
- }
-
- __sdp_log(9, "Error (line:%ld) : %s\n", __sdp_config_line_num, final_msg);
- parse_err = 1;
-
- free(orig_msg);
- free(final_msg);
- return 1;
-}
-
-#include <unistd.h>
-#include <errno.h>
-
-/* parse apollo route dump file */
-int __sdp_parse_config (const char *fileName) {
- extern FILE * libsdp_yyin;
-
- /* open the file */
- if (access(fileName, R_OK)) {
- printf("libsdp Error: No access to open File:%s %s\n",
- fileName, strerror(errno));
- return(1);
- }
-
- libsdp_yyin = fopen(fileName,"r");
- if (!libsdp_yyin) {
- printf("libsdp Error: Fail to open File:%s\n", fileName);
- return(1);
- }
- parse_err = 0;
- __sdp_config_line_num = 1;
-
- /* parse it */
- yyparse();
-
- fclose(libsdp_yyin);
- return(parse_err);
-}
-
-
diff --git a/contrib/ofed/libsdp/src/config_scanner.c b/contrib/ofed/libsdp/src/config_scanner.c
deleted file mode 100644
index 553da32..0000000
--- a/contrib/ofed/libsdp/src/config_scanner.c
+++ /dev/null
@@ -1,1932 +0,0 @@
-#define yy_create_buffer libsdp_yy_create_buffer
-#define yy_delete_buffer libsdp_yy_delete_buffer
-#define yy_scan_buffer libsdp_yy_scan_buffer
-#define yy_scan_string libsdp_yy_scan_string
-#define yy_scan_bytes libsdp_yy_scan_bytes
-#define yy_flex_debug libsdp_yy_flex_debug
-#define yy_init_buffer libsdp_yy_init_buffer
-#define yy_flush_buffer libsdp_yy_flush_buffer
-#define yy_load_buffer_state libsdp_yy_load_buffer_state
-#define yy_switch_to_buffer libsdp_yy_switch_to_buffer
-#define yyin libsdp_yyin
-#define yyleng libsdp_yyleng
-#define yylex libsdp_yylex
-#define yyout libsdp_yyout
-#define yyrestart libsdp_yyrestart
-#define yytext libsdp_yytext
-#define yywrap libsdp_yywrap
-
-/* A lexical scanner generated by flex*/
-
-/* Scanner skeleton version:
- * $Header: /home/daffy/u0/vern/flex/RCS/flex.skl,v 2.91 96/09/10 16:58:48 vern Exp $
- */
-
-#define FLEX_SCANNER
-#define YY_FLEX_MAJOR_VERSION 2
-#define YY_FLEX_MINOR_VERSION 5
-
-#include <stdio.h>
-#include <unistd.h>
-
-
-/* cfront 1.2 defines "c_plusplus" instead of "__cplusplus" */
-#ifdef c_plusplus
-#ifndef __cplusplus
-#define __cplusplus
-#endif
-#endif
-
-
-#ifdef __cplusplus
-
-#include <stdlib.h>
-
-/* Use prototypes in function declarations. */
-#define YY_USE_PROTOS
-
-/* The "const" storage-class-modifier is valid. */
-#define YY_USE_CONST
-
-#else /* ! __cplusplus */
-
-#if __STDC__
-
-#define YY_USE_PROTOS
-#define YY_USE_CONST
-
-#endif /* __STDC__ */
-#endif /* ! __cplusplus */
-
-#ifdef __TURBOC__
- #pragma warn -rch
- #pragma warn -use
-#include <io.h>
-#include <stdlib.h>
-#define YY_USE_CONST
-#define YY_USE_PROTOS
-#endif
-
-#ifdef YY_USE_CONST
-#define yyconst const
-#else
-#define yyconst
-#endif
-
-
-#ifdef YY_USE_PROTOS
-#define YY_PROTO(proto) proto
-#else
-#define YY_PROTO(proto) ()
-#endif
-
-/* Returned upon end-of-file. */
-#define YY_NULL 0
-
-/* Promotes a possibly negative, possibly signed char to an unsigned
- * integer for use as an array index. If the signed char is negative,
- * we want to instead treat it as an 8-bit unsigned char, hence the
- * double cast.
- */
-#define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c)
-
-/* Enter a start condition. This macro really ought to take a parameter,
- * but we do it the disgusting crufty way forced on us by the ()-less
- * definition of BEGIN.
- */
-#define BEGIN yy_start = 1 + 2 *
-
-/* Translate the current start state into a value that can be later handed
- * to BEGIN to return to the state. The YYSTATE alias is for lex
- * compatibility.
- */
-#define YY_START ((yy_start - 1) / 2)
-#define YYSTATE YY_START
-
-/* Action number for EOF rule of a given start state. */
-#define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1)
-
-/* Special action meaning "start processing a new file". */
-#define YY_NEW_FILE yyrestart( yyin )
-
-#define YY_END_OF_BUFFER_CHAR 0
-
-/* Size of default input buffer. */
-#define YY_BUF_SIZE 16384
-
-typedef struct yy_buffer_state *YY_BUFFER_STATE;
-
-extern int yyleng;
-extern FILE *yyin, *yyout;
-
-#define EOB_ACT_CONTINUE_SCAN 0
-#define EOB_ACT_END_OF_FILE 1
-#define EOB_ACT_LAST_MATCH 2
-
-/* The funky do-while in the following #define is used to turn the definition
- * int a single C statement (which needs a semi-colon terminator). This
- * avoids problems with code like:
- *
- * if ( condition_holds )
- * yyless( 5 );
- * else
- * do_something_else();
- *
- * Prior to using the do-while the compiler would get upset at the
- * "else" because it interpreted the "if" statement as being all
- * done when it reached the ';' after the yyless() call.
- */
-
-/* Return all but the first 'n' matched characters back to the input stream. */
-
-#define yyless(n) \
- do \
- { \
- /* Undo effects of setting up yytext. */ \
- *yy_cp = yy_hold_char; \
- YY_RESTORE_YY_MORE_OFFSET \
- yy_c_buf_p = yy_cp = yy_bp + n - YY_MORE_ADJ; \
- YY_DO_BEFORE_ACTION; /* set up yytext again */ \
- } \
- while ( 0 )
-
-#define unput(c) yyunput( c, yytext_ptr )
-
-/* Some routines like yy_flex_realloc() are emitted as static but are
- not called by all lexers. This generates warnings in some compilers,
- notably GCC. Arrange to suppress these. */
-#ifdef __GNUC__
-#define YY_MAY_BE_UNUSED __attribute__((unused))
-#else
-#define YY_MAY_BE_UNUSED
-#endif
-
-/* The following is because we cannot portably get our hands on size_t
- * (without autoconf's help, which isn't available because we want
- * flex-generated scanners to compile on their own).
- */
-typedef unsigned int yy_size_t;
-
-
-struct yy_buffer_state
- {
- FILE *yy_input_file;
-
- char *yy_ch_buf; /* input buffer */
- char *yy_buf_pos; /* current position in input buffer */
-
- /* Size of input buffer in bytes, not including room for EOB
- * characters.
- */
- yy_size_t yy_buf_size;
-
- /* Number of characters read into yy_ch_buf, not including EOB
- * characters.
- */
- int yy_n_chars;
-
- /* Whether we "own" the buffer - i.e., we know we created it,
- * and can realloc() it to grow it, and should free() it to
- * delete it.
- */
- int yy_is_our_buffer;
-
- /* Whether this is an "interactive" input source; if so, and
- * if we're using stdio for input, then we want to use getc()
- * instead of fread(), to make sure we stop fetching input after
- * each newline.
- */
- int yy_is_interactive;
-
- /* Whether we're considered to be at the beginning of a line.
- * If so, '^' rules will be active on the next match, otherwise
- * not.
- */
- int yy_at_bol;
-
- /* Whether to try to fill the input buffer when we reach the
- * end of it.
- */
- int yy_fill_buffer;
-
- int yy_buffer_status;
-#define YY_BUFFER_NEW 0
-#define YY_BUFFER_NORMAL 1
- /* When an EOF's been seen but there's still some text to process
- * then we mark the buffer as YY_EOF_PENDING, to indicate that we
- * shouldn't try reading from the input source any more. We might
- * still have a bunch of tokens to match, though, because of
- * possible backing-up.
- *
- * When we actually see the EOF, we change the status to "new"
- * (via yyrestart()), so that the user can continue scanning by
- * just pointing yyin at a new input file.
- */
-#define YY_BUFFER_EOF_PENDING 2
- };
-
-static YY_BUFFER_STATE yy_current_buffer = 0;
-
-/* We provide macros for accessing buffer states in case in the
- * future we want to put the buffer states in a more general
- * "scanner state".
- */
-#define YY_CURRENT_BUFFER yy_current_buffer
-
-
-/* yy_hold_char holds the character lost when yytext is formed. */
-static char yy_hold_char;
-
-static int yy_n_chars; /* number of characters read into yy_ch_buf */
-
-
-int yyleng;
-
-/* Points to current character in buffer. */
-static char *yy_c_buf_p = (char *) 0;
-static int yy_init = 1; /* whether we need to initialize */
-static int yy_start = 0; /* start state number */
-
-/* Flag which is used to allow yywrap()'s to do buffer switches
- * instead of setting up a fresh yyin. A bit of a hack ...
- */
-static int yy_did_buffer_switch_on_eof;
-
-void yyrestart YY_PROTO(( FILE *input_file ));
-
-void yy_switch_to_buffer YY_PROTO(( YY_BUFFER_STATE new_buffer ));
-void yy_load_buffer_state YY_PROTO(( void ));
-YY_BUFFER_STATE yy_create_buffer YY_PROTO(( FILE *file, int size ));
-void yy_delete_buffer YY_PROTO(( YY_BUFFER_STATE b ));
-void yy_init_buffer YY_PROTO(( YY_BUFFER_STATE b, FILE *file ));
-void yy_flush_buffer YY_PROTO(( YY_BUFFER_STATE b ));
-#define YY_FLUSH_BUFFER yy_flush_buffer( yy_current_buffer )
-
-YY_BUFFER_STATE yy_scan_buffer YY_PROTO(( char *base, yy_size_t size ));
-YY_BUFFER_STATE yy_scan_string YY_PROTO(( yyconst char *yy_str ));
-YY_BUFFER_STATE yy_scan_bytes YY_PROTO(( yyconst char *bytes, int len ));
-
-static void *yy_flex_alloc YY_PROTO(( yy_size_t ));
-static void *yy_flex_realloc YY_PROTO(( void *, yy_size_t )) YY_MAY_BE_UNUSED;
-static void yy_flex_free YY_PROTO(( void * ));
-
-#define yy_new_buffer yy_create_buffer
-
-#define yy_set_interactive(is_interactive) \
- { \
- if ( ! yy_current_buffer ) \
- yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE ); \
- yy_current_buffer->yy_is_interactive = is_interactive; \
- }
-
-#define yy_set_bol(at_bol) \
- { \
- if ( ! yy_current_buffer ) \
- yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE ); \
- yy_current_buffer->yy_at_bol = at_bol; \
- }
-
-#define YY_AT_BOL() (yy_current_buffer->yy_at_bol)
-
-typedef unsigned char YY_CHAR;
-FILE *yyin = (FILE *) 0, *yyout = (FILE *) 0;
-typedef int yy_state_type;
-extern char *yytext;
-#define yytext_ptr yytext
-
-static yy_state_type yy_get_previous_state YY_PROTO(( void ));
-static yy_state_type yy_try_NUL_trans YY_PROTO(( yy_state_type current_state ));
-static int yy_get_next_buffer YY_PROTO(( void ));
-static void yy_fatal_error YY_PROTO(( yyconst char msg[] ));
-
-/* Done after the current pattern has been matched and before the
- * corresponding action - sets up yytext.
- */
-#define YY_DO_BEFORE_ACTION \
- yytext_ptr = yy_bp; \
- yyleng = (int) (yy_cp - yy_bp); \
- yy_hold_char = *yy_cp; \
- *yy_cp = '\0'; \
- yy_c_buf_p = yy_cp;
-
-#define YY_NUM_RULES 21
-#define YY_END_OF_BUFFER 22
-static yyconst short int yy_accept[195] =
- { 0,
- 0, 0, 0, 0, 22, 20, 19, 17, 18, 20,
- 3, 3, 20, 20, 20, 20, 20, 20, 20, 20,
- 20, 20, 20, 19, 1, 16, 16, 16, 3, 3,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 1, 19, 18, 0, 0, 0, 0, 3, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 19, 1, 1, 16, 16, 16,
- 16, 16, 16, 3, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 1,
- 0, 2, 2, 0, 0, 0, 0, 0, 0, 4,
-
- 0, 12, 0, 0, 0, 11, 10, 1, 16, 2,
- 2, 16, 16, 16, 16, 16, 16, 4, 16, 12,
- 16, 16, 16, 11, 10, 0, 13, 0, 0, 0,
- 9, 0, 0, 0, 0, 0, 16, 13, 16, 16,
- 16, 9, 16, 16, 16, 16, 16, 0, 0, 0,
- 0, 0, 0, 0, 0, 16, 16, 16, 16, 16,
- 16, 16, 16, 14, 0, 0, 15, 0, 7, 8,
- 14, 16, 16, 15, 16, 7, 8, 0, 0, 16,
- 16, 0, 0, 16, 16, 0, 6, 16, 6, 0,
- 16, 5, 5, 0
-
- } ;
-
-static yyconst int yy_ec[256] =
- { 0,
- 1, 1, 1, 1, 1, 1, 1, 1, 2, 3,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 2, 1, 1, 4, 1, 1, 1, 1, 1,
- 1, 5, 1, 1, 6, 7, 8, 9, 10, 10,
- 10, 10, 10, 10, 10, 10, 10, 11, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 12, 13, 14, 15,
-
- 16, 17, 18, 19, 20, 1, 1, 21, 22, 23,
- 24, 25, 1, 26, 27, 28, 29, 30, 1, 1,
- 31, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
-
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1
- } ;
-
-static yyconst int yy_meta[32] =
- { 0,
- 1, 2, 3, 1, 1, 1, 4, 1, 4, 4,
- 4, 4, 4, 4, 4, 4, 4, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1
- } ;
-
-static yyconst short int yy_base[202] =
- { 0,
- 0, 30, 34, 64, 295, 296, 292, 296, 0, 60,
- 62, 65, 68, 0, 269, 56, 276, 271, 58, 270,
- 68, 275, 261, 83, 0, 0, 285, 93, 78, 82,
- 275, 86, 87, 104, 105, 106, 98, 265, 104, 270,
- 256, 280, 279, 0, 269, 0, 114, 128, 120, 271,
- 250, 257, 253, 248, 253, 246, 254, 248, 245, 243,
- 253, 240, 241, 249, 132, 0, 0, 0, 262, 0,
- 132, 132, 139, 142, 252, 234, 241, 237, 146, 238,
- 231, 239, 233, 230, 228, 238, 225, 226, 234, 247,
- 136, 296, 0, 229, 231, 223, 217, 228, 215, 296,
-
- 236, 296, 211, 224, 218, 296, 296, 0, 149, 0,
- 153, 219, 221, 213, 207, 218, 205, 0, 226, 0,
- 201, 214, 208, 0, 0, 157, 296, 205, 211, 206,
- 296, 209, 203, 207, 196, 197, 160, 0, 197, 203,
- 198, 0, 201, 195, 199, 188, 189, 184, 197, 187,
- 186, 192, 181, 180, 187, 176, 189, 179, 178, 184,
- 173, 172, 178, 296, 164, 176, 296, 154, 296, 296,
- 0, 155, 168, 0, 146, 0, 0, 144, 155, 140,
- 147, 136, 134, 111, 106, 77, 296, 64, 0, 58,
- 49, 296, 0, 296, 173, 29, 177, 181, 185, 189,
-
- 193
- } ;
-
-static yyconst short int yy_def[202] =
- { 0,
- 194, 1, 194, 3, 194, 194, 194, 194, 195, 196,
- 196, 11, 11, 11, 11, 11, 11, 11, 194, 194,
- 194, 194, 194, 194, 197, 198, 199, 198, 28, 28,
- 28, 28, 28, 28, 28, 28, 198, 198, 198, 198,
- 198, 200, 194, 195, 13, 11, 194, 13, 11, 11,
- 194, 194, 194, 11, 194, 194, 194, 194, 194, 194,
- 194, 194, 194, 194, 194, 201, 197, 198, 199, 28,
- 28, 198, 28, 28, 28, 198, 198, 198, 28, 198,
- 198, 198, 198, 198, 198, 198, 198, 198, 198, 200,
- 194, 194, 11, 194, 194, 194, 194, 194, 194, 194,
-
- 194, 194, 194, 194, 194, 194, 194, 201, 198, 198,
- 28, 198, 198, 198, 198, 198, 198, 198, 198, 198,
- 198, 198, 198, 198, 198, 194, 194, 194, 194, 194,
- 194, 194, 194, 194, 194, 194, 198, 198, 198, 198,
- 198, 198, 198, 198, 198, 198, 198, 194, 194, 194,
- 194, 194, 194, 194, 194, 198, 198, 198, 198, 198,
- 198, 198, 198, 194, 194, 194, 194, 194, 194, 194,
- 198, 198, 198, 198, 198, 198, 198, 194, 194, 198,
- 198, 194, 194, 198, 198, 194, 194, 198, 198, 194,
- 198, 194, 198, 0, 194, 194, 194, 194, 194, 194,
-
- 194
- } ;
-
-static yyconst short int yy_nxt[328] =
- { 0,
- 6, 7, 8, 9, 6, 6, 10, 6, 11, 12,
- 13, 14, 15, 16, 17, 14, 18, 6, 6, 6,
- 19, 20, 6, 6, 6, 6, 21, 22, 23, 6,
- 6, 24, 46, 25, 26, 7, 8, 27, 26, 26,
- 28, 26, 29, 30, 31, 32, 33, 34, 35, 32,
- 36, 26, 26, 26, 37, 38, 26, 26, 26, 26,
- 39, 40, 41, 26, 26, 24, 45, 42, 45, 47,
- 45, 193, 48, 49, 49, 194, 52, 56, 50, 53,
- 192, 57, 59, 60, 65, 72, 66, 191, 73, 72,
- 74, 74, 73, 72, 72, 61, 73, 73, 62, 70,
-
- 190, 71, 71, 70, 71, 71, 71, 71, 71, 71,
- 76, 72, 72, 72, 73, 73, 73, 81, 84, 85,
- 79, 82, 91, 91, 77, 80, 189, 78, 49, 49,
- 188, 86, 92, 65, 87, 66, 93, 93, 45, 72,
- 109, 109, 73, 110, 91, 91, 126, 111, 111, 72,
- 74, 74, 73, 72, 187, 186, 73, 109, 109, 137,
- 72, 92, 185, 73, 110, 92, 92, 184, 110, 110,
- 183, 182, 115, 44, 44, 181, 44, 67, 67, 180,
- 67, 68, 171, 179, 68, 69, 69, 178, 69, 90,
- 90, 164, 90, 108, 108, 177, 108, 176, 174, 175,
-
- 174, 173, 172, 171, 170, 169, 167, 168, 167, 166,
- 165, 164, 163, 162, 161, 160, 159, 158, 157, 156,
- 155, 154, 153, 152, 151, 150, 149, 148, 147, 146,
- 145, 144, 143, 142, 141, 140, 139, 138, 136, 135,
- 134, 133, 132, 131, 130, 129, 128, 127, 67, 125,
- 124, 123, 122, 121, 120, 119, 118, 117, 116, 114,
- 113, 112, 73, 44, 107, 106, 105, 104, 103, 102,
- 101, 100, 99, 98, 97, 96, 95, 94, 194, 45,
- 43, 67, 89, 88, 83, 75, 44, 64, 63, 58,
- 55, 54, 51, 43, 194, 5, 194, 194, 194, 194,
-
- 194, 194, 194, 194, 194, 194, 194, 194, 194, 194,
- 194, 194, 194, 194, 194, 194, 194, 194, 194, 194,
- 194, 194, 194, 194, 194, 194, 194
- } ;
-
-static yyconst short int yy_chk[328] =
- { 0,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 2, 196, 2, 3, 3, 3, 3, 3, 3,
- 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
- 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
- 3, 3, 3, 3, 3, 4, 10, 4, 11, 11,
- 10, 191, 11, 12, 12, 13, 16, 19, 13, 16,
- 190, 19, 21, 21, 24, 29, 24, 188, 29, 30,
- 30, 30, 30, 32, 33, 21, 32, 33, 21, 28,
-
- 186, 28, 28, 28, 28, 28, 28, 28, 28, 28,
- 33, 34, 35, 36, 34, 35, 36, 37, 39, 39,
- 35, 37, 47, 47, 34, 36, 185, 34, 49, 49,
- 184, 39, 48, 65, 39, 65, 48, 48, 48, 71,
- 72, 72, 71, 73, 91, 91, 91, 73, 73, 74,
- 74, 74, 74, 79, 183, 182, 79, 109, 109, 109,
- 111, 126, 181, 111, 137, 126, 126, 180, 137, 137,
- 179, 178, 79, 195, 195, 175, 195, 197, 197, 173,
- 197, 198, 172, 168, 198, 199, 199, 166, 199, 200,
- 200, 165, 200, 201, 201, 163, 201, 162, 161, 160,
-
- 159, 158, 157, 156, 155, 154, 153, 152, 151, 150,
- 149, 148, 147, 146, 145, 144, 143, 141, 140, 139,
- 136, 135, 134, 133, 132, 130, 129, 128, 123, 122,
- 121, 119, 117, 116, 115, 114, 113, 112, 105, 104,
- 103, 101, 99, 98, 97, 96, 95, 94, 90, 89,
- 88, 87, 86, 85, 84, 83, 82, 81, 80, 78,
- 77, 76, 75, 69, 64, 63, 62, 61, 60, 59,
- 58, 57, 56, 55, 54, 53, 52, 51, 50, 45,
- 43, 42, 41, 40, 38, 31, 27, 23, 22, 20,
- 18, 17, 15, 7, 5, 194, 194, 194, 194, 194,
-
- 194, 194, 194, 194, 194, 194, 194, 194, 194, 194,
- 194, 194, 194, 194, 194, 194, 194, 194, 194, 194,
- 194, 194, 194, 194, 194, 194, 194
- } ;
-
-static yy_state_type yy_last_accepting_state;
-static char *yy_last_accepting_cpos;
-
-/* The intent behind this definition is that it'll catch
- * any uses of REJECT which flex missed.
- */
-#define REJECT reject_used_but_not_detected
-#define yymore() yymore_used_but_not_detected
-#define YY_MORE_ADJ 0
-#define YY_RESTORE_YY_MORE_OFFSET
-char *yytext;
-#line 1 "./config_scanner.l"
-#define INITIAL 0
-/*
- * Copyright (c) 2006 Mellanox Technologies Ltd. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- * $Id: ibnl_scanner.ll,v 1.4 2005/02/23 21:08:37 eitan Exp $
- */
-#line 36 "./config_scanner.l"
-
-/* #define DEBUG 1 */
-
-#define yyparse libsdp_yyparse
-#define yylex libsdp_yylex
-#define yyerror libsdp_yyerror
-#define yylval libsdp_yylval
-#define yychar libsdp_yychar
-#define yydebug libsdp_yydebug
-#define yynerrs libsdp_yynerrs
-
-#define yywrap libsdp_yywrap
-
-#include <string.h>
-#include <stdio.h>
-#include "config_parser.h"
-extern long __sdp_config_line_num;
-#define CANNAME 1
-
-#line 581 "lex.libsdp_yy.c"
-
-/* Macros after this point can all be overridden by user definitions in
- * section 1.
- */
-
-#ifndef YY_SKIP_YYWRAP
-#ifdef __cplusplus
-extern "C" int yywrap YY_PROTO(( void ));
-#else
-extern int yywrap YY_PROTO(( void ));
-#endif
-#endif
-
-#ifndef YY_NO_UNPUT
-static void yyunput YY_PROTO(( int c, char *buf_ptr ));
-#endif
-
-#ifndef yytext_ptr
-static void yy_flex_strncpy YY_PROTO(( char *, yyconst char *, int ));
-#endif
-
-#ifdef YY_NEED_STRLEN
-static int yy_flex_strlen YY_PROTO(( yyconst char * ));
-#endif
-
-#ifndef YY_NO_INPUT
-#ifdef __cplusplus
-static int yyinput YY_PROTO(( void ));
-#else
-static int input YY_PROTO(( void ));
-#endif
-#endif
-
-#if YY_STACK_USED
-static int yy_start_stack_ptr = 0;
-static int yy_start_stack_depth = 0;
-static int *yy_start_stack = 0;
-#ifndef YY_NO_PUSH_STATE
-static void yy_push_state YY_PROTO(( int new_state ));
-#endif
-#ifndef YY_NO_POP_STATE
-static void yy_pop_state YY_PROTO(( void ));
-#endif
-#ifndef YY_NO_TOP_STATE
-static int yy_top_state YY_PROTO(( void ));
-#endif
-
-#else
-#define YY_NO_PUSH_STATE 1
-#define YY_NO_POP_STATE 1
-#define YY_NO_TOP_STATE 1
-#endif
-
-#ifdef YY_MALLOC_DECL
-YY_MALLOC_DECL
-#else
-#if __STDC__
-#ifndef __cplusplus
-#include <stdlib.h>
-#endif
-#else
-/* Just try to get by without declaring the routines. This will fail
- * miserably on non-ANSI systems for which sizeof(size_t) != sizeof(int)
- * or sizeof(void*) != sizeof(int).
- */
-#endif
-#endif
-
-/* Amount of stuff to slurp up with each read. */
-#ifndef YY_READ_BUF_SIZE
-#define YY_READ_BUF_SIZE 8192
-#endif
-
-/* Copy whatever the last rule matched to the standard output. */
-
-#ifndef ECHO
-/* This used to be an fputs(), but since the string might contain NUL's,
- * we now use fwrite().
- */
-#define ECHO (void) fwrite( yytext, yyleng, 1, yyout )
-#endif
-
-/* Gets input and stuffs it into "buf". number of characters read, or YY_NULL,
- * is returned in "result".
- */
-#ifndef YY_INPUT
-#define YY_INPUT(buf,result,max_size) \
- if ( yy_current_buffer->yy_is_interactive ) \
- { \
- int c = '*', n; \
- for ( n = 0; n < max_size && \
- (c = getc( yyin )) != EOF && c != '\n'; ++n ) \
- buf[n] = (char) c; \
- if ( c == '\n' ) \
- buf[n++] = (char) c; \
- if ( c == EOF && ferror( yyin ) ) \
- YY_FATAL_ERROR( "input in flex scanner failed" ); \
- result = n; \
- } \
- else if ( ((result = fread( buf, 1, max_size, yyin )) == 0) \
- && ferror( yyin ) ) \
- YY_FATAL_ERROR( "input in flex scanner failed" );
-#endif
-
-/* No semi-colon after return; correct usage is to write "yyterminate();" -
- * we don't want an extra ';' after the "return" because that will cause
- * some compilers to complain about unreachable statements.
- */
-#ifndef yyterminate
-#define yyterminate() return YY_NULL
-#endif
-
-/* Number of entries by which start-condition stack grows. */
-#ifndef YY_START_STACK_INCR
-#define YY_START_STACK_INCR 25
-#endif
-
-/* Report a fatal error. */
-#ifndef YY_FATAL_ERROR
-#define YY_FATAL_ERROR(msg) yy_fatal_error( msg )
-#endif
-
-/* Default declaration of generated scanner - a define so the user can
- * easily add parameters.
- */
-#ifndef YY_DECL
-#define YY_DECL int yylex YY_PROTO(( void ))
-#endif
-
-/* Code executed at the beginning of each rule, after yytext and yyleng
- * have been set up.
- */
-#ifndef YY_USER_ACTION
-#define YY_USER_ACTION
-#endif
-
-/* Code executed at the end of each rule. */
-#ifndef YY_BREAK
-#define YY_BREAK break;
-#endif
-
-#define YY_RULE_SETUP \
- if ( yyleng > 0 ) \
- yy_current_buffer->yy_at_bol = \
- (yytext[yyleng - 1] == '\n'); \
- YY_USER_ACTION
-
-YY_DECL
- {
- register yy_state_type yy_current_state;
- register char *yy_cp = NULL, *yy_bp = NULL;
- register int yy_act;
-
-#line 55 "./config_scanner.l"
-
-
-#line 738 "lex.libsdp_yy.c"
-
- if ( yy_init )
- {
- yy_init = 0;
-
-#ifdef YY_USER_INIT
- YY_USER_INIT;
-#endif
-
- if ( ! yy_start )
- yy_start = 1; /* first start state */
-
- if ( ! yyin )
- yyin = stdin;
-
- if ( ! yyout )
- yyout = stdout;
-
- if ( ! yy_current_buffer )
- yy_current_buffer =
- yy_create_buffer( yyin, YY_BUF_SIZE );
-
- yy_load_buffer_state();
- }
-
- while ( 1 ) /* loops until end-of-file is reached */
- {
- yy_cp = yy_c_buf_p;
-
- /* Support of yytext. */
- *yy_cp = yy_hold_char;
-
- /* yy_bp points to the position in yy_ch_buf of the start of
- * the current run.
- */
- yy_bp = yy_cp;
-
- yy_current_state = yy_start;
- yy_current_state += YY_AT_BOL();
-yy_match:
- do
- {
- register YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)];
- if ( yy_accept[yy_current_state] )
- {
- yy_last_accepting_state = yy_current_state;
- yy_last_accepting_cpos = yy_cp;
- }
- while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
- {
- yy_current_state = (int) yy_def[yy_current_state];
- if ( yy_current_state >= 195 )
- yy_c = yy_meta[(unsigned int) yy_c];
- }
- yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
- ++yy_cp;
- }
- while ( yy_base[yy_current_state] != 296 );
-
-yy_find_action:
- yy_act = yy_accept[yy_current_state];
- if ( yy_act == 0 )
- { /* have to back up */
- yy_cp = yy_last_accepting_cpos;
- yy_current_state = yy_last_accepting_state;
- yy_act = yy_accept[yy_current_state];
- }
-
- YY_DO_BEFORE_ACTION;
-
-
-do_action: /* This label is used only to access EOF actions. */
-
-
- switch ( yy_act )
- { /* beginning of action switch */
- case 0: /* must back up */
- /* undo the effects of YY_DO_BEFORE_ACTION */
- *yy_cp = yy_hold_char;
- yy_cp = yy_last_accepting_cpos;
- yy_current_state = yy_last_accepting_state;
- goto yy_find_action;
-
-case 1:
-YY_RULE_SETUP
-#line 57 "./config_scanner.l"
-{}
- YY_BREAK
-case 2:
-*yy_cp = yy_hold_char; /* undo effects of setting up yytext */
-yy_c_buf_p = yy_cp -= 2;
-YY_DO_BEFORE_ACTION; /* set up yytext again */
-YY_RULE_SETUP
-#line 59 "./config_scanner.l"
-{
- yylval.ival = SUBNET;
-#ifdef DEBUG
- printf("SUBNET: %s\n", yytext);
-#endif
- yylval.sval = (char *)malloc(strlen(yytext) + 1);
- strcpy(yylval.sval, yytext);
- return SUBNET;
-}
- YY_BREAK
-case 3:
-YY_RULE_SETUP
-#line 69 "./config_scanner.l"
-{
- yylval.ival = atoi(yytext);
-#ifdef DEBUG
- printf("INT:%d\n",yylval.ival);
-#endif
- return INT;
-}
- YY_BREAK
-case 4:
-YY_RULE_SETUP
-#line 77 "./config_scanner.l"
-{
- yylval.ival = LOG;
-#ifdef DEBUG
- printf("LOG\n");
-#endif
- return LOG;
-}
- YY_BREAK
-case 5:
-YY_RULE_SETUP
-#line 85 "./config_scanner.l"
-{
- yylval.ival = DEST;
-#ifdef DEBUG
- printf("DEST\n");
-#endif
- return DEST;
-}
- YY_BREAK
-case 6:
-YY_RULE_SETUP
-#line 93 "./config_scanner.l"
-{
- yylval.ival = LEVEL;
-#ifdef DEBUG
- printf("LEVEL\n");
-#endif
- return LEVEL;
-}
- YY_BREAK
-case 7:
-YY_RULE_SETUP
-#line 101 "./config_scanner.l"
-{
- yylval.ival = STDERR;
-#ifdef DEBUG
- printf("STDERR\n");
-#endif
- return STDERR;
-}
- YY_BREAK
-case 8:
-YY_RULE_SETUP
-#line 109 "./config_scanner.l"
-{
- yylval.ival = SYSLOG;
-#ifdef DEBUG
- printf("SYSLOG\n");
-#endif
- return SYSLOG;
-}
- YY_BREAK
-case 9:
-YY_RULE_SETUP
-#line 117 "./config_scanner.l"
-{
- yylval.ival = FILENAME;
-#ifdef DEBUG
- printf("FILENAME\n");
-#endif
- BEGIN(CANNAME);
- return FILENAME;
-}
- YY_BREAK
-case 10:
-YY_RULE_SETUP
-#line 126 "./config_scanner.l"
-{
- yylval.ival = USE;
-#ifdef DEBUG
- printf("USE\n");
-#endif
- return USE;
-}
- YY_BREAK
-case 11:
-YY_RULE_SETUP
-#line 134 "./config_scanner.l"
-{
- yylval.ival = TCP;
-#ifdef DEBUG
- printf("TCP\n");
-#endif
- return TCP;
-}
- YY_BREAK
-case 12:
-YY_RULE_SETUP
-#line 142 "./config_scanner.l"
-{
- yylval.ival = SDP;
-#ifdef DEBUG
- printf("SDP\n");
-#endif
- return SDP;
-}
- YY_BREAK
-case 13:
-YY_RULE_SETUP
-#line 150 "./config_scanner.l"
-{
- yylval.ival = BOTH;
-#ifdef DEBUG
- printf("BOTH\n");
-#endif
- return BOTH;
-}
- YY_BREAK
-case 14:
-YY_RULE_SETUP
-#line 158 "./config_scanner.l"
-{
- yylval.ival = CLIENT;
-#ifdef DEBUG
- printf("CLIENT\n");
-#endif
- BEGIN(CANNAME);
- return CLIENT;
-}
- YY_BREAK
-case 15:
-YY_RULE_SETUP
-#line 167 "./config_scanner.l"
-{
- yylval.ival = SERVER;
-#ifdef DEBUG
- printf("SERVER\n");
-#endif
- BEGIN(CANNAME);
- return SERVER;
-}
- YY_BREAK
-case 16:
-YY_RULE_SETUP
-#line 176 "./config_scanner.l"
-{
- yylval.sval = (char *)malloc(strlen(yytext) + 1);
- strcpy(yylval.sval, yytext);
-#ifdef DEBUG
- printf("NAME:%s\n",yylval.sval);
-#endif
- BEGIN(0);
- return (NAME);
-}
- YY_BREAK
-case 17:
-YY_RULE_SETUP
-#line 186 "./config_scanner.l"
-{
- __sdp_config_line_num++;
-#ifdef DEBUG
- printf("LINE\n");
-#endif
- yylval.ival = LINE;
- return(LINE);
-}
- YY_BREAK
-case 18:
-YY_RULE_SETUP
-#line 195 "./config_scanner.l"
-{
- __sdp_config_line_num++;
-}
- YY_BREAK
-case 19:
-YY_RULE_SETUP
-#line 199 "./config_scanner.l"
-{}
- YY_BREAK
-case 20:
-YY_RULE_SETUP
-#line 201 "./config_scanner.l"
-{
-#ifdef DEBUG
- printf("CHAR:%c\n",yytext[0]);
-#endif
- return(yytext[0]);
-}
- YY_BREAK
-case 21:
-YY_RULE_SETUP
-#line 208 "./config_scanner.l"
-ECHO;
- YY_BREAK
-#line 1041 "lex.libsdp_yy.c"
-case YY_STATE_EOF(INITIAL):
-case YY_STATE_EOF(CANNAME):
- yyterminate();
-
- case YY_END_OF_BUFFER:
- {
- /* Amount of text matched not including the EOB char. */
- int yy_amount_of_matched_text = (int) (yy_cp - yytext_ptr) - 1;
-
- /* Undo the effects of YY_DO_BEFORE_ACTION. */
- *yy_cp = yy_hold_char;
- YY_RESTORE_YY_MORE_OFFSET
-
- if ( yy_current_buffer->yy_buffer_status == YY_BUFFER_NEW )
- {
- /* We're scanning a new file or input source. It's
- * possible that this happened because the user
- * just pointed yyin at a new source and called
- * yylex(). If so, then we have to assure
- * consistency between yy_current_buffer and our
- * globals. Here is the right place to do so, because
- * this is the first action (other than possibly a
- * back-up) that will match for the new input source.
- */
- yy_n_chars = yy_current_buffer->yy_n_chars;
- yy_current_buffer->yy_input_file = yyin;
- yy_current_buffer->yy_buffer_status = YY_BUFFER_NORMAL;
- }
-
- /* Note that here we test for yy_c_buf_p "<=" to the position
- * of the first EOB in the buffer, since yy_c_buf_p will
- * already have been incremented past the NUL character
- * (since all states make transitions on EOB to the
- * end-of-buffer state). Contrast this with the test
- * in input().
- */
- if ( yy_c_buf_p <= &yy_current_buffer->yy_ch_buf[yy_n_chars] )
- { /* This was really a NUL. */
- yy_state_type yy_next_state;
-
- yy_c_buf_p = yytext_ptr + yy_amount_of_matched_text;
-
- yy_current_state = yy_get_previous_state();
-
- /* Okay, we're now positioned to make the NUL
- * transition. We couldn't have
- * yy_get_previous_state() go ahead and do it
- * for us because it doesn't know how to deal
- * with the possibility of jamming (and we don't
- * want to build jamming into it because then it
- * will run more slowly).
- */
-
- yy_next_state = yy_try_NUL_trans( yy_current_state );
-
- yy_bp = yytext_ptr + YY_MORE_ADJ;
-
- if ( yy_next_state )
- {
- /* Consume the NUL. */
- yy_cp = ++yy_c_buf_p;
- yy_current_state = yy_next_state;
- goto yy_match;
- }
-
- else
- {
- yy_cp = yy_c_buf_p;
- goto yy_find_action;
- }
- }
-
- else switch ( yy_get_next_buffer() )
- {
- case EOB_ACT_END_OF_FILE:
- {
- yy_did_buffer_switch_on_eof = 0;
-
- if ( yywrap() )
- {
- /* Note: because we've taken care in
- * yy_get_next_buffer() to have set up
- * yytext, we can now set up
- * yy_c_buf_p so that if some total
- * hoser (like flex itself) wants to
- * call the scanner after we return the
- * YY_NULL, it'll still work - another
- * YY_NULL will get returned.
- */
- yy_c_buf_p = yytext_ptr + YY_MORE_ADJ;
-
- yy_act = YY_STATE_EOF(YY_START);
- goto do_action;
- }
-
- else
- {
- if ( ! yy_did_buffer_switch_on_eof )
- YY_NEW_FILE;
- }
- break;
- }
-
- case EOB_ACT_CONTINUE_SCAN:
- yy_c_buf_p =
- yytext_ptr + yy_amount_of_matched_text;
-
- yy_current_state = yy_get_previous_state();
-
- yy_cp = yy_c_buf_p;
- yy_bp = yytext_ptr + YY_MORE_ADJ;
- goto yy_match;
-
- case EOB_ACT_LAST_MATCH:
- yy_c_buf_p =
- &yy_current_buffer->yy_ch_buf[yy_n_chars];
-
- yy_current_state = yy_get_previous_state();
-
- yy_cp = yy_c_buf_p;
- yy_bp = yytext_ptr + YY_MORE_ADJ;
- goto yy_find_action;
- }
- break;
- }
-
- default:
- YY_FATAL_ERROR(
- "fatal flex scanner internal error--no action found" );
- } /* end of action switch */
- } /* end of scanning one token */
- } /* end of yylex */
-
-
-/* yy_get_next_buffer - try to read in a new buffer
- *
- * Returns a code representing an action:
- * EOB_ACT_LAST_MATCH -
- * EOB_ACT_CONTINUE_SCAN - continue scanning from current position
- * EOB_ACT_END_OF_FILE - end of file
- */
-
-static int yy_get_next_buffer()
- {
- register char *dest = yy_current_buffer->yy_ch_buf;
- register char *source = yytext_ptr;
- register int number_to_move, i;
- int ret_val;
-
- if ( yy_c_buf_p > &yy_current_buffer->yy_ch_buf[yy_n_chars + 1] )
- YY_FATAL_ERROR(
- "fatal flex scanner internal error--end of buffer missed" );
-
- if ( yy_current_buffer->yy_fill_buffer == 0 )
- { /* Don't try to fill the buffer, so this is an EOF. */
- if ( yy_c_buf_p - yytext_ptr - YY_MORE_ADJ == 1 )
- {
- /* We matched a single character, the EOB, so
- * treat this as a final EOF.
- */
- return EOB_ACT_END_OF_FILE;
- }
-
- else
- {
- /* We matched some text prior to the EOB, first
- * process it.
- */
- return EOB_ACT_LAST_MATCH;
- }
- }
-
- /* Try to read more data. */
-
- /* First move last chars to start of buffer. */
- number_to_move = (int) (yy_c_buf_p - yytext_ptr) - 1;
-
- for ( i = 0; i < number_to_move; ++i )
- *(dest++) = *(source++);
-
- if ( yy_current_buffer->yy_buffer_status == YY_BUFFER_EOF_PENDING )
- /* don't do the read, it's not guaranteed to return an EOF,
- * just force an EOF
- */
- yy_current_buffer->yy_n_chars = yy_n_chars = 0;
-
- else
- {
- int num_to_read =
- yy_current_buffer->yy_buf_size - number_to_move - 1;
-
- while ( num_to_read <= 0 )
- { /* Not enough room in the buffer - grow it. */
-#ifdef YY_USES_REJECT
- YY_FATAL_ERROR(
-"input buffer overflow, can't enlarge buffer because scanner uses REJECT" );
-#else
-
- /* just a shorter name for the current buffer */
- YY_BUFFER_STATE b = yy_current_buffer;
-
- int yy_c_buf_p_offset =
- (int) (yy_c_buf_p - b->yy_ch_buf);
-
- if ( b->yy_is_our_buffer )
- {
- int new_size = b->yy_buf_size * 2;
-
- if ( new_size <= 0 )
- b->yy_buf_size += b->yy_buf_size / 8;
- else
- b->yy_buf_size *= 2;
-
- b->yy_ch_buf = (char *)
- /* Include room in for 2 EOB chars. */
- yy_flex_realloc( (void *) b->yy_ch_buf,
- b->yy_buf_size + 2 );
- }
- else
- /* Can't grow it, we don't own it. */
- b->yy_ch_buf = 0;
-
- if ( ! b->yy_ch_buf )
- YY_FATAL_ERROR(
- "fatal error - scanner input buffer overflow" );
-
- yy_c_buf_p = &b->yy_ch_buf[yy_c_buf_p_offset];
-
- num_to_read = yy_current_buffer->yy_buf_size -
- number_to_move - 1;
-#endif
- }
-
- if ( num_to_read > YY_READ_BUF_SIZE )
- num_to_read = YY_READ_BUF_SIZE;
-
- /* Read in more data. */
- YY_INPUT( (&yy_current_buffer->yy_ch_buf[number_to_move]),
- yy_n_chars, num_to_read );
-
- yy_current_buffer->yy_n_chars = yy_n_chars;
- }
-
- if ( yy_n_chars == 0 )
- {
- if ( number_to_move == YY_MORE_ADJ )
- {
- ret_val = EOB_ACT_END_OF_FILE;
- yyrestart( yyin );
- }
-
- else
- {
- ret_val = EOB_ACT_LAST_MATCH;
- yy_current_buffer->yy_buffer_status =
- YY_BUFFER_EOF_PENDING;
- }
- }
-
- else
- ret_val = EOB_ACT_CONTINUE_SCAN;
-
- yy_n_chars += number_to_move;
- yy_current_buffer->yy_ch_buf[yy_n_chars] = YY_END_OF_BUFFER_CHAR;
- yy_current_buffer->yy_ch_buf[yy_n_chars + 1] = YY_END_OF_BUFFER_CHAR;
-
- yytext_ptr = &yy_current_buffer->yy_ch_buf[0];
-
- return ret_val;
- }
-
-
-/* yy_get_previous_state - get the state just before the EOB char was reached */
-
-static yy_state_type yy_get_previous_state()
- {
- register yy_state_type yy_current_state;
- register char *yy_cp;
-
- yy_current_state = yy_start;
- yy_current_state += YY_AT_BOL();
-
- for ( yy_cp = yytext_ptr + YY_MORE_ADJ; yy_cp < yy_c_buf_p; ++yy_cp )
- {
- register YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1);
- if ( yy_accept[yy_current_state] )
- {
- yy_last_accepting_state = yy_current_state;
- yy_last_accepting_cpos = yy_cp;
- }
- while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
- {
- yy_current_state = (int) yy_def[yy_current_state];
- if ( yy_current_state >= 195 )
- yy_c = yy_meta[(unsigned int) yy_c];
- }
- yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
- }
-
- return yy_current_state;
- }
-
-
-/* yy_try_NUL_trans - try to make a transition on the NUL character
- *
- * synopsis
- * next_state = yy_try_NUL_trans( current_state );
- */
-
-#ifdef YY_USE_PROTOS
-static yy_state_type yy_try_NUL_trans( yy_state_type yy_current_state )
-#else
-static yy_state_type yy_try_NUL_trans( yy_current_state )
-yy_state_type yy_current_state;
-#endif
- {
- register int yy_is_jam;
- register char *yy_cp = yy_c_buf_p;
-
- register YY_CHAR yy_c = 1;
- if ( yy_accept[yy_current_state] )
- {
- yy_last_accepting_state = yy_current_state;
- yy_last_accepting_cpos = yy_cp;
- }
- while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
- {
- yy_current_state = (int) yy_def[yy_current_state];
- if ( yy_current_state >= 195 )
- yy_c = yy_meta[(unsigned int) yy_c];
- }
- yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
- yy_is_jam = (yy_current_state == 194);
-
- return yy_is_jam ? 0 : yy_current_state;
- }
-
-
-#ifndef YY_NO_UNPUT
-#ifdef YY_USE_PROTOS
-static void yyunput( int c, register char *yy_bp )
-#else
-static void yyunput( c, yy_bp )
-int c;
-register char *yy_bp;
-#endif
- {
- register char *yy_cp = yy_c_buf_p;
-
- /* undo effects of setting up yytext */
- *yy_cp = yy_hold_char;
-
- if ( yy_cp < yy_current_buffer->yy_ch_buf + 2 )
- { /* need to shift things up to make room */
- /* +2 for EOB chars. */
- register int number_to_move = yy_n_chars + 2;
- register char *dest = &yy_current_buffer->yy_ch_buf[
- yy_current_buffer->yy_buf_size + 2];
- register char *source =
- &yy_current_buffer->yy_ch_buf[number_to_move];
-
- while ( source > yy_current_buffer->yy_ch_buf )
- *--dest = *--source;
-
- yy_cp += (int) (dest - source);
- yy_bp += (int) (dest - source);
- yy_current_buffer->yy_n_chars =
- yy_n_chars = yy_current_buffer->yy_buf_size;
-
- if ( yy_cp < yy_current_buffer->yy_ch_buf + 2 )
- YY_FATAL_ERROR( "flex scanner push-back overflow" );
- }
-
- *--yy_cp = (char) c;
-
-
- yytext_ptr = yy_bp;
- yy_hold_char = *yy_cp;
- yy_c_buf_p = yy_cp;
- }
-#endif /* ifndef YY_NO_UNPUT */
-
-
-#ifndef YY_NO_INPUT
-#ifdef __cplusplus
-static int yyinput()
-#else
-static int input()
-#endif
- {
- int c;
-
- *yy_c_buf_p = yy_hold_char;
-
- if ( *yy_c_buf_p == YY_END_OF_BUFFER_CHAR )
- {
- /* yy_c_buf_p now points to the character we want to return.
- * If this occurs *before* the EOB characters, then it's a
- * valid NUL; if not, then we've hit the end of the buffer.
- */
- if ( yy_c_buf_p < &yy_current_buffer->yy_ch_buf[yy_n_chars] )
- /* This was really a NUL. */
- *yy_c_buf_p = '\0';
-
- else
- { /* need more input */
- int offset = yy_c_buf_p - yytext_ptr;
- ++yy_c_buf_p;
-
- switch ( yy_get_next_buffer() )
- {
- case EOB_ACT_LAST_MATCH:
- /* This happens because yy_g_n_b()
- * sees that we've accumulated a
- * token and flags that we need to
- * try matching the token before
- * proceeding. But for input(),
- * there's no matching to consider.
- * So convert the EOB_ACT_LAST_MATCH
- * to EOB_ACT_END_OF_FILE.
- */
-
- /* Reset buffer status. */
- yyrestart( yyin );
-
- /* fall through */
-
- case EOB_ACT_END_OF_FILE:
- {
- if ( yywrap() )
- return EOF;
-
- if ( ! yy_did_buffer_switch_on_eof )
- YY_NEW_FILE;
-#ifdef __cplusplus
- return yyinput();
-#else
- return input();
-#endif
- }
-
- case EOB_ACT_CONTINUE_SCAN:
- yy_c_buf_p = yytext_ptr + offset;
- break;
- }
- }
- }
-
- c = *(unsigned char *) yy_c_buf_p; /* cast for 8-bit char's */
- *yy_c_buf_p = '\0'; /* preserve yytext */
- yy_hold_char = *++yy_c_buf_p;
-
- yy_current_buffer->yy_at_bol = (c == '\n');
-
- return c;
- }
-#endif /* YY_NO_INPUT */
-
-#ifdef YY_USE_PROTOS
-void yyrestart( FILE *input_file )
-#else
-void yyrestart( input_file )
-FILE *input_file;
-#endif
- {
- if ( ! yy_current_buffer )
- yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE );
-
- yy_init_buffer( yy_current_buffer, input_file );
- yy_load_buffer_state();
- }
-
-
-#ifdef YY_USE_PROTOS
-void yy_switch_to_buffer( YY_BUFFER_STATE new_buffer )
-#else
-void yy_switch_to_buffer( new_buffer )
-YY_BUFFER_STATE new_buffer;
-#endif
- {
- if ( yy_current_buffer == new_buffer )
- return;
-
- if ( yy_current_buffer )
- {
- /* Flush out information for old buffer. */
- *yy_c_buf_p = yy_hold_char;
- yy_current_buffer->yy_buf_pos = yy_c_buf_p;
- yy_current_buffer->yy_n_chars = yy_n_chars;
- }
-
- yy_current_buffer = new_buffer;
- yy_load_buffer_state();
-
- /* We don't actually know whether we did this switch during
- * EOF (yywrap()) processing, but the only time this flag
- * is looked at is after yywrap() is called, so it's safe
- * to go ahead and always set it.
- */
- yy_did_buffer_switch_on_eof = 1;
- }
-
-
-#ifdef YY_USE_PROTOS
-void yy_load_buffer_state( void )
-#else
-void yy_load_buffer_state()
-#endif
- {
- yy_n_chars = yy_current_buffer->yy_n_chars;
- yytext_ptr = yy_c_buf_p = yy_current_buffer->yy_buf_pos;
- yyin = yy_current_buffer->yy_input_file;
- yy_hold_char = *yy_c_buf_p;
- }
-
-
-#ifdef YY_USE_PROTOS
-YY_BUFFER_STATE yy_create_buffer( FILE *file, int size )
-#else
-YY_BUFFER_STATE yy_create_buffer( file, size )
-FILE *file;
-int size;
-#endif
- {
- YY_BUFFER_STATE b;
-
- b = (YY_BUFFER_STATE) yy_flex_alloc( sizeof( struct yy_buffer_state ) );
- if ( ! b )
- YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" );
-
- b->yy_buf_size = size;
-
- /* yy_ch_buf has to be 2 characters longer than the size given because
- * we need to put in 2 end-of-buffer characters.
- */
- b->yy_ch_buf = (char *) yy_flex_alloc( b->yy_buf_size + 2 );
- if ( ! b->yy_ch_buf )
- YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" );
-
- b->yy_is_our_buffer = 1;
-
- yy_init_buffer( b, file );
-
- return b;
- }
-
-
-#ifdef YY_USE_PROTOS
-void yy_delete_buffer( YY_BUFFER_STATE b )
-#else
-void yy_delete_buffer( b )
-YY_BUFFER_STATE b;
-#endif
- {
- if ( ! b )
- return;
-
- if ( b == yy_current_buffer )
- yy_current_buffer = (YY_BUFFER_STATE) 0;
-
- if ( b->yy_is_our_buffer )
- yy_flex_free( (void *) b->yy_ch_buf );
-
- yy_flex_free( (void *) b );
- }
-
-
-
-#ifdef YY_USE_PROTOS
-void yy_init_buffer( YY_BUFFER_STATE b, FILE *file )
-#else
-void yy_init_buffer( b, file )
-YY_BUFFER_STATE b;
-FILE *file;
-#endif
-
-
- {
- yy_flush_buffer( b );
-
- b->yy_input_file = file;
- b->yy_fill_buffer = 1;
-
-#if YY_ALWAYS_INTERACTIVE
- b->yy_is_interactive = 1;
-#else
-#if YY_NEVER_INTERACTIVE
- b->yy_is_interactive = 0;
-#else
- b->yy_is_interactive = file ? (isatty( fileno(file) ) > 0) : 0;
-#endif
-#endif
- }
-
-
-#ifdef YY_USE_PROTOS
-void yy_flush_buffer( YY_BUFFER_STATE b )
-#else
-void yy_flush_buffer( b )
-YY_BUFFER_STATE b;
-#endif
-
- {
- if ( ! b )
- return;
-
- b->yy_n_chars = 0;
-
- /* We always need two end-of-buffer characters. The first causes
- * a transition to the end-of-buffer state. The second causes
- * a jam in that state.
- */
- b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR;
- b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR;
-
- b->yy_buf_pos = &b->yy_ch_buf[0];
-
- b->yy_at_bol = 1;
- b->yy_buffer_status = YY_BUFFER_NEW;
-
- if ( b == yy_current_buffer )
- yy_load_buffer_state();
- }
-
-
-#ifndef YY_NO_SCAN_BUFFER
-#ifdef YY_USE_PROTOS
-YY_BUFFER_STATE yy_scan_buffer( char *base, yy_size_t size )
-#else
-YY_BUFFER_STATE yy_scan_buffer( base, size )
-char *base;
-yy_size_t size;
-#endif
- {
- YY_BUFFER_STATE b;
-
- if ( size < 2 ||
- base[size-2] != YY_END_OF_BUFFER_CHAR ||
- base[size-1] != YY_END_OF_BUFFER_CHAR )
- /* They forgot to leave room for the EOB's. */
- return 0;
-
- b = (YY_BUFFER_STATE) yy_flex_alloc( sizeof( struct yy_buffer_state ) );
- if ( ! b )
- YY_FATAL_ERROR( "out of dynamic memory in yy_scan_buffer()" );
-
- b->yy_buf_size = size - 2; /* "- 2" to take care of EOB's */
- b->yy_buf_pos = b->yy_ch_buf = base;
- b->yy_is_our_buffer = 0;
- b->yy_input_file = 0;
- b->yy_n_chars = b->yy_buf_size;
- b->yy_is_interactive = 0;
- b->yy_at_bol = 1;
- b->yy_fill_buffer = 0;
- b->yy_buffer_status = YY_BUFFER_NEW;
-
- yy_switch_to_buffer( b );
-
- return b;
- }
-#endif
-
-
-#ifndef YY_NO_SCAN_STRING
-#ifdef YY_USE_PROTOS
-YY_BUFFER_STATE yy_scan_string( yyconst char *yy_str )
-#else
-YY_BUFFER_STATE yy_scan_string( yy_str )
-yyconst char *yy_str;
-#endif
- {
- int len;
- for ( len = 0; yy_str[len]; ++len )
- ;
-
- return yy_scan_bytes( yy_str, len );
- }
-#endif
-
-
-#ifndef YY_NO_SCAN_BYTES
-#ifdef YY_USE_PROTOS
-YY_BUFFER_STATE yy_scan_bytes( yyconst char *bytes, int len )
-#else
-YY_BUFFER_STATE yy_scan_bytes( bytes, len )
-yyconst char *bytes;
-int len;
-#endif
- {
- YY_BUFFER_STATE b;
- char *buf;
- yy_size_t n;
- int i;
-
- /* Get memory for full buffer, including space for trailing EOB's. */
- n = len + 2;
- buf = (char *) yy_flex_alloc( n );
- if ( ! buf )
- YY_FATAL_ERROR( "out of dynamic memory in yy_scan_bytes()" );
-
- for ( i = 0; i < len; ++i )
- buf[i] = bytes[i];
-
- buf[len] = buf[len+1] = YY_END_OF_BUFFER_CHAR;
-
- b = yy_scan_buffer( buf, n );
- if ( ! b )
- YY_FATAL_ERROR( "bad buffer in yy_scan_bytes()" );
-
- /* It's okay to grow etc. this buffer, and we should throw it
- * away when we're done.
- */
- b->yy_is_our_buffer = 1;
-
- return b;
- }
-#endif
-
-
-#ifndef YY_NO_PUSH_STATE
-#ifdef YY_USE_PROTOS
-static void yy_push_state( int new_state )
-#else
-static void yy_push_state( new_state )
-int new_state;
-#endif
- {
- if ( yy_start_stack_ptr >= yy_start_stack_depth )
- {
- yy_size_t new_size;
-
- yy_start_stack_depth += YY_START_STACK_INCR;
- new_size = yy_start_stack_depth * sizeof( int );
-
- if ( ! yy_start_stack )
- yy_start_stack = (int *) yy_flex_alloc( new_size );
-
- else
- yy_start_stack = (int *) yy_flex_realloc(
- (void *) yy_start_stack, new_size );
-
- if ( ! yy_start_stack )
- YY_FATAL_ERROR(
- "out of memory expanding start-condition stack" );
- }
-
- yy_start_stack[yy_start_stack_ptr++] = YY_START;
-
- BEGIN(new_state);
- }
-#endif
-
-
-#ifndef YY_NO_POP_STATE
-static void yy_pop_state()
- {
- if ( --yy_start_stack_ptr < 0 )
- YY_FATAL_ERROR( "start-condition stack underflow" );
-
- BEGIN(yy_start_stack[yy_start_stack_ptr]);
- }
-#endif
-
-
-#ifndef YY_NO_TOP_STATE
-static int yy_top_state()
- {
- return yy_start_stack[yy_start_stack_ptr - 1];
- }
-#endif
-
-#ifndef YY_EXIT_FAILURE
-#define YY_EXIT_FAILURE 2
-#endif
-
-#ifdef YY_USE_PROTOS
-static void yy_fatal_error( yyconst char msg[] )
-#else
-static void yy_fatal_error( msg )
-char msg[];
-#endif
- {
- (void) fprintf( stderr, "%s\n", msg );
- exit( YY_EXIT_FAILURE );
- }
-
-
-
-/* Redefine yyless() so it works in section 3 code. */
-
-#undef yyless
-#define yyless(n) \
- do \
- { \
- /* Undo effects of setting up yytext. */ \
- yytext[yyleng] = yy_hold_char; \
- yy_c_buf_p = yytext + n; \
- yy_hold_char = *yy_c_buf_p; \
- *yy_c_buf_p = '\0'; \
- yyleng = n; \
- } \
- while ( 0 )
-
-
-/* Internal utility routines. */
-
-#ifndef yytext_ptr
-#ifdef YY_USE_PROTOS
-static void yy_flex_strncpy( char *s1, yyconst char *s2, int n )
-#else
-static void yy_flex_strncpy( s1, s2, n )
-char *s1;
-yyconst char *s2;
-int n;
-#endif
- {
- register int i;
- for ( i = 0; i < n; ++i )
- s1[i] = s2[i];
- }
-#endif
-
-#ifdef YY_NEED_STRLEN
-#ifdef YY_USE_PROTOS
-static int yy_flex_strlen( yyconst char *s )
-#else
-static int yy_flex_strlen( s )
-yyconst char *s;
-#endif
- {
- register int n;
- for ( n = 0; s[n]; ++n )
- ;
-
- return n;
- }
-#endif
-
-
-#ifdef YY_USE_PROTOS
-static void *yy_flex_alloc( yy_size_t size )
-#else
-static void *yy_flex_alloc( size )
-yy_size_t size;
-#endif
- {
- return (void *) malloc( size );
- }
-
-#ifdef YY_USE_PROTOS
-static void *yy_flex_realloc( void *ptr, yy_size_t size )
-#else
-static void *yy_flex_realloc( ptr, size )
-void *ptr;
-yy_size_t size;
-#endif
- {
- /* The cast to (char *) in the following accommodates both
- * implementations that use char* generic pointers, and those
- * that use void* generic pointers. It works with the latter
- * because both ANSI C and C++ allow castless assignment from
- * any pointer type to void*, and deal with argument conversions
- * as though doing an assignment.
- */
- return (void *) realloc( (char *) ptr, size );
- }
-
-#ifdef YY_USE_PROTOS
-static void yy_flex_free( void *ptr )
-#else
-static void yy_flex_free( ptr )
-void *ptr;
-#endif
- {
- free( ptr );
- }
-
-#if YY_MAIN
-int main()
- {
- yylex();
- return 0;
- }
-#endif
-#line 208 "./config_scanner.l"
-
-
-int yywrap ()
-{
- return (1);
-}
-
diff --git a/contrib/ofed/libsdp/src/config_scanner.l b/contrib/ofed/libsdp/src/config_scanner.l
deleted file mode 100644
index cfb7fa2..0000000
--- a/contrib/ofed/libsdp/src/config_scanner.l
+++ /dev/null
@@ -1,214 +0,0 @@
-/*
- * Copyright (c) 2006 Mellanox Technologies Ltd. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- * $Id: ibnl_scanner.ll,v 1.4 2005/02/23 21:08:37 eitan Exp $
- */
-
-%{
-
-/* #define DEBUG 1 */
-
-#define yyparse libsdp_yyparse
-#define yylex libsdp_yylex
-#define yyerror libsdp_yyerror
-#define yylval libsdp_yylval
-#define yychar libsdp_yychar
-#define yydebug libsdp_yydebug
-#define yynerrs libsdp_yynerrs
-
-#define yywrap libsdp_yywrap
-
-#include <string.h>
-#include <stdio.h>
-#include "config_parser.h"
-extern long __sdp_config_line_num;
-%}
-%s CANNAME
-%%
-
-^[ \t]*#.* {}
-
-::|[0-9a-f:\.]*[0-9a-f](\/[0-9]+)?/:[0-9*] {
- yylval.ival = SUBNET;
-#ifdef DEBUG
- printf("SUBNET: %s\n", yytext);
-#endif
- yylval.sval = (char *)malloc(strlen(yytext) + 1);
- strcpy(yylval.sval, yytext);
- return SUBNET;
-}
-
-([1-9][0-9]*|0) {
- yylval.ival = atoi(yytext);
-#ifdef DEBUG
- printf("INT:%d\n",yylval.ival);
-#endif
- return INT;
-}
-
-log {
- yylval.ival = LOG;
-#ifdef DEBUG
- printf("LOG\n");
-#endif
- return LOG;
-}
-
-destination {
- yylval.ival = DEST;
-#ifdef DEBUG
- printf("DEST\n");
-#endif
- return DEST;
-}
-
-min-level {
- yylval.ival = LEVEL;
-#ifdef DEBUG
- printf("LEVEL\n");
-#endif
- return LEVEL;
-}
-
-stderr {
- yylval.ival = STDERR;
-#ifdef DEBUG
- printf("STDERR\n");
-#endif
- return STDERR;
-}
-
-syslog {
- yylval.ival = SYSLOG;
-#ifdef DEBUG
- printf("SYSLOG\n");
-#endif
- return SYSLOG;
-}
-
-file {
- yylval.ival = FILENAME;
-#ifdef DEBUG
- printf("FILENAME\n");
-#endif
- BEGIN(CANNAME);
- return FILENAME;
-}
-
-use {
- yylval.ival = USE;
-#ifdef DEBUG
- printf("USE\n");
-#endif
- return USE;
-}
-
-tcp {
- yylval.ival = TCP;
-#ifdef DEBUG
- printf("TCP\n");
-#endif
- return TCP;
-}
-
-sdp {
- yylval.ival = SDP;
-#ifdef DEBUG
- printf("SDP\n");
-#endif
- return SDP;
-}
-
-both {
- yylval.ival = BOTH;
-#ifdef DEBUG
- printf("BOTH\n");
-#endif
- return BOTH;
-}
-
-client|connect {
- yylval.ival = CLIENT;
-#ifdef DEBUG
- printf("CLIENT\n");
-#endif
- BEGIN(CANNAME);
- return CLIENT;
-}
-
-server|listen {
- yylval.ival = SERVER;
-#ifdef DEBUG
- printf("SERVER\n");
-#endif
- BEGIN(CANNAME);
- return SERVER;
-}
-
-<CANNAME>[^ \t\n]+ {
- yylval.sval = (char *)malloc(strlen(yytext) + 1);
- strcpy(yylval.sval, yytext);
-#ifdef DEBUG
- printf("NAME:%s\n",yylval.sval);
-#endif
- BEGIN(0);
- return (NAME);
-}
-
-\n {
- __sdp_config_line_num++;
-#ifdef DEBUG
- printf("LINE\n");
-#endif
- yylval.ival = LINE;
- return(LINE);
-}
-
-[#][^\n]* {
- __sdp_config_line_num++;
-}
-
-[ \t]+ {}
-
-. {
-#ifdef DEBUG
- printf("CHAR:%c\n",yytext[0]);
-#endif
- return(yytext[0]);
-}
-
-%%
-
-int yywrap ()
-{
- return (1);
-}
-
diff --git a/contrib/ofed/libsdp/src/libsdp.h b/contrib/ofed/libsdp/src/libsdp.h
deleted file mode 100644
index 07c52d0..0000000
--- a/contrib/ofed/libsdp/src/libsdp.h
+++ /dev/null
@@ -1,124 +0,0 @@
-/*
- This software is available to you under a choice of one of two
- licenses. You may choose to be licensed under the terms of the GNU
- General Public License (GPL) Version 2, available at
- <http://www.fsf.org/copyleft/gpl.html>, or the OpenIB.org BSD
- license, available in the LICENSE.TXT file accompanying this
- software. These details are also available at
- <http://openib.org/license.html>.
-
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- SOFTWARE.
-
- Copyright (c) 2004 Topspin Communications. All rights reserved.
- Copyright (c) 2005-2006 Mellanox Technologies Ltd. All rights reserved.
-
- $Id$
-*/
-
-#include <netinet/in.h>
-
-/*
- * SDP specific includes
- */
-#include "linux/sdp_inet.h"
-
-/* --------------------------------------------------------------------- */
-/* library static and global variables */
-/* --------------------------------------------------------------------- */
-
-/* max string length to store any IPv4/IPv6 address */
-#define MAX_ADDR_STR_LEN 49
-
-typedef enum
-{
- USE_TCP = 1,
- USE_SDP,
- USE_BOTH,
-} use_family_t;
-
-/* some state to string functions */
-static inline char *
-__sdp_get_family_str(
- use_family_t family )
-{
- switch ( family ) {
- case USE_TCP:
- return "tcp";
- break;
- case USE_SDP:
- return "sdp";
- break;
- case USE_BOTH:
- return "both";
- break;
- }
- return ( "unknown-family" );
-}
-
-/* data structure for holding address family mapoping rules */
-/* note we filter non relevant programs during parsing ... */
-struct use_family_rule
-{
- struct use_family_rule *prev, *next;
- int match_by_addr; /* if 0 ignore address match */
- struct sockaddr_storage ip; /* IPv4/6 address for mapping */
- unsigned char prefixlen; /* length of CIDR prefix (ie /24) */
- int match_by_port; /* if 0 ignore port match */
- unsigned short sport, eport; /* start port - end port, inclusive */
- use_family_t target_family; /* if match - use this family */
- char *prog_name_expr; /* expression for program name */
-};
-
-extern struct use_family_rule *__sdp_clients_family_rules_head;
-extern struct use_family_rule *__sdp_clients_family_rules_tail;
-extern struct use_family_rule *__sdp_servers_family_rules_head;
-extern struct use_family_rule *__sdp_servers_family_rules_tail;
-
-#define SDP_NETMASK(n) ((n == 0) ? 0 : ~((1UL<<(32 - n)) - 1))
-
-/* match.c */
-use_family_t __sdp_match_connect(
- const struct sockaddr *sin,
- const socklen_t addrlen );
-
-use_family_t __sdp_match_listen(
- const struct sockaddr *sin,
- const socklen_t addrlen );
-
-/* config.c */
-int __sdp_config_empty(
- void );
-
-int __sdp_parse_config(
- const char *config_file );
-
-use_family_t __sdp_match_by_program(
- );
-
-/* log.c */
-void __sdp_log(
- int level,
- char *format,
- ... );
-
-int __sdp_log_get_level(
- void );
-
-void __sdp_log_set_min_level(
- int level );
-
-int __sdp_log_set_log_stderr(
- void );
-
-int __sdp_log_set_log_syslog(
- void );
-
-int __sdp_log_set_log_file(
- char *filename );
diff --git a/contrib/ofed/libsdp/src/linux/sdp_inet.h b/contrib/ofed/libsdp/src/linux/sdp_inet.h
deleted file mode 100644
index 02d37dd..0000000
--- a/contrib/ofed/libsdp/src/linux/sdp_inet.h
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- This software is available to you under a choice of one of two
- licenses. You may choose to be licensed under the terms of the GNU
- General Public License (GPL) Version 2, available at
- <http://www.fsf.org/copyleft/gpl.html>, or the OpenIB.org BSD
- license, available in the LICENSE.TXT file accompanying this
- software. These details are also available at
- <http://openib.org/license.html>.
-
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- SOFTWARE.
-
- Copyright (c) 2004 Topspin Communications. All rights reserved.
-
- $Id$
-*/
-
-#ifndef _SDP_INET_H
-#define _SDP_INET_H
-
-/*
- * constants shared between user and kernel space.
- */
-
-#ifndef SOLARIS_BUILD
-#ifdef __FreeBSD__
-#include <sys/socket.h>
-#else
-#define AF_INET_SDP 27 /* SDP socket protocol family */
-#define AF_INET6_SDP 28 /* SDP socket protocol family */
-#endif
-#else
-#define AF_INET_SDP 31 /* This is an invalid family on native solaris
- * and will only work using QuickTransit */
-//TODO XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXx
-#define AF_INET6_SDP 32 /* SDP socket protocol family */
-#endif
-
-#define AF_INET_STR "AF_INET_SDP" /* SDP enabled environment variable */
-#define AF_INET6_STR "AF_INET6_SDP" /* SDP enabled environment variable */
-
-#ifndef SDP_ZCOPY_THRESH
-#define SDP_ZCOPY_THRESH 80
-#endif
-
-#ifndef SDP_LAST_BIND_ERR
-#define SDP_LAST_BIND_ERR 81
-#endif
-
-#endif /* _SDP_INET_H */
diff --git a/contrib/ofed/libsdp/src/log.c b/contrib/ofed/libsdp/src/log.c
deleted file mode 100644
index c98ee46..0000000
--- a/contrib/ofed/libsdp/src/log.c
+++ /dev/null
@@ -1,236 +0,0 @@
-/*
- This software is available to you under a choice of one of two
- licenses. You may choose to be licensed under the terms of the GNU
- General Public License (GPL) Version 2, available at
- <http://www.fsf.org/copyleft/gpl.html>, or the OpenIB.org BSD
- license, available in the LICENSE.TXT file accompanying this
- software. These details are also available at
- <http://openib.org/license.html>.
-
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- SOFTWARE.
-
- Copyright (c) 2004 Topspin Communications. All rights reserved.
- Copyright (c) 2006 Mellanox Technologies Ltd. All rights reserved.
-
- $Id$
-*/
-
-/*
- * system includes
- */
-#if HAVE_CONFIG_H
-# include <config.h>
-#endif /* HAVE_CONFIG_H */
-#include <unistd.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <errno.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <stdarg.h>
-#include <string.h>
-#include <syslog.h>
-#include <time.h>
-#include <limits.h>
-
-/*
- * SDP specific includes
- */
-#include "libsdp.h"
-
-extern char *program_invocation_short_name;
-
-typedef enum
-{
- SDP_LOG_FILE,
- SDP_LOG_SYSLOG,
-} __sdp_log_type_t;
-
-/* --------------------------------------------------------------------- */
-/* library static and global variables */
-/* --------------------------------------------------------------------- */
-int __sdp_min_level = 9;
-static __sdp_log_type_t __sdp_log_type = SDP_LOG_FILE;
-static FILE *__sdp_log_file = NULL;
-
-void
-__sdp_log(
- int level,
- char *format,
- ... )
-{
- va_list ap;
- char extra_format[512];
- time_t timeval;
- char timestr[32];
-
- if ( level < __sdp_min_level ) {
- return;
- }
-
- va_start( ap, format );
- switch ( __sdp_log_type ) {
- case SDP_LOG_SYSLOG:
- sprintf( extra_format, "%s[%d] libsdp %s ",
- program_invocation_short_name, getpid( ), format );
- vsyslog( LOG_USER | LOG_NOTICE, extra_format, ap );
- break;
- case SDP_LOG_FILE:
- timeval = time(NULL);
-#ifdef SOLARIS_BUILD
- ctime_r(&timeval, timestr, sizeof timestr);
-#else
- ctime_r(&timeval, timestr);
-#endif
- timestr[strlen(timestr)-1] = '\0';
- sprintf( extra_format, "%s %s[%d] libsdp %s ",
- timestr, program_invocation_short_name,
- getpid( ), format );
- if ( __sdp_log_file == NULL ) {
- vfprintf( stderr, extra_format, ap );
-#if 0 /* might slow everything too much? */
- ( void )fflush( stderr );
-#endif
- } else {
- vfprintf( __sdp_log_file, extra_format, ap );
-#if 0 /* might slow everything too much? */
- ( void )fflush( __sdp_log_file );
-#endif
- }
- break;
- }
- va_end( ap );
-}
-
-int
-__sdp_log_get_level(
- void )
-{
- return ( __sdp_min_level );
-}
-
-void
-__sdp_log_set_min_level(
- int level )
-{
- __sdp_min_level = level;
-}
-
-static void
-__sdp_log_set_log_type(
- __sdp_log_type_t type )
-{
- if ( __sdp_log_file != NULL ) {
- fclose( __sdp_log_file );
- __sdp_log_file = NULL;
- }
-
- __sdp_log_type = type;
-}
-
-int
-__sdp_log_set_log_stderr(
- void )
-{
- __sdp_log_set_log_type( SDP_LOG_FILE );
- /* NULL means stderr */
-
- return 1;
-}
-
-int
-__sdp_log_set_log_syslog(
- void )
-{
- __sdp_log_set_log_type( SDP_LOG_SYSLOG );
-
- return 1;
-}
-
-int
-__sdp_log_set_log_file(
- char *filename )
-{
- FILE *f;
- uid_t uid;
- struct stat lstat_res;
- int status;
-
- char *p, tfilename[PATH_MAX + 1];
-
- /* Strip off any paths from the filename */
- p = strrchr( filename, '/' );
-
- /*
- base on the active user ID we either use /var/log for root or
- append the uid to the name
- */
- uid = geteuid();
- if (uid == 0) {
- if ( p )
- filename = p + 1;
- snprintf( tfilename, sizeof(tfilename), "/var/log/%s", filename );
- } else {
- char tdir[PATH_MAX + 1];
- /*
- for regular user, allow log file to be placed in a user
- requested path. If no path is requested the log file is
- placed in /tmp/
- */
- if ( p )
- snprintf(tdir, sizeof(tdir), "%s.%d", filename, uid );
- else
- snprintf(tdir, sizeof(tdir ), "/tmp/%s.%d", filename, uid );
-
- if (mkdir(tdir, 0700)) {
- struct stat stat;
-
- if (errno != EEXIST) {
- __sdp_log( 9, "Couldn't create directory '%s' for logging (%m)\n", tdir );
- return 0;
- }
-
- if (lstat(tdir, &stat)) {
- __sdp_log(9, "Couldn't lstat directory %s\n", tdir);
- return 0;
- }
-
- if (!S_ISDIR(stat.st_mode) || stat.st_uid != uid ||
- (stat.st_mode & ~(S_IFMT | S_IRWXU))) {
- __sdp_log( 9, "Cowardly refusing to log into directory:'%s'. "
- "Make sure it is not: (1) link, (2) other uid, (3) bad permissions."
- "thus is a security issue.\n", tdir );
- return 0;
- }
- }
-
- snprintf(tfilename, sizeof(tfilename), "%s/log", tdir);
- printf("dir: %s file: %s\n", tdir, tfilename);
- }
-
- /* double check the file is not a link */
- status = lstat(tfilename, &lstat_res);
- if ( (status == 0) && S_ISLNK(lstat_res.st_mode) ) {
- __sdp_log( 9, "Cowardly refusing to log into:'%s'. "
- "It is a link - thus is a security issue.\n", tfilename );
- return 0;
- }
-
- f = fopen( tfilename, "a" );
- if ( !f ) {
- __sdp_log( 9, "Couldn't open '%s' for logging (%m)\n", tfilename );
- return 0;
- }
-
- __sdp_log_set_log_type( SDP_LOG_FILE );
- __sdp_log_file = f;
-
- return 1;
-}
diff --git a/contrib/ofed/libsdp/src/match.c b/contrib/ofed/libsdp/src/match.c
deleted file mode 100644
index 7d0a057..0000000
--- a/contrib/ofed/libsdp/src/match.c
+++ /dev/null
@@ -1,340 +0,0 @@
-/*
- This software is available to you under a choice of one of two
- licenses. You may choose to be licensed under the terms of the GNU
- General Public License (GPL) Version 2, available at
- <http://www.fsf.org/copyleft/gpl.html>, or the OpenIB.org BSD
- license, available in the LICENSE.TXT file accompanying this
- software. These details are also available at
- <http://openib.org/license.html>.
-
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- SOFTWARE.
-
- Copyright (c) 2004 Topspin Communications. All rights reserved.
- Copyright (c) 2005-2006 Mellanox Technologies Ltd. All rights reserved.
-
- $Id$
-*/
-
-/*
- * system includes
- */
-#if HAVE_CONFIG_H
-# include <config.h>
-#endif /* HAVE_CONFIG_H */
-
-#include <unistd.h>
-#include <errno.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <fnmatch.h>
-#include <sys/socket.h>
-#include <netinet/in.h>
-#include <arpa/inet.h>
-#include <sys/types.h>
-#ifdef __linux__
-#include <linux/types.h>
-#elif defined(__FreeBSD__)
-#define s6_addr32 __u6_addr.__u6_addr32
-#define __be32 uint32_t
-#endif
-
-/*
- * SDP specific includes
- */
-#include "libsdp.h"
-
-/* --------------------------------------------------------------------- */
-/* library static and global variables */
-/* --------------------------------------------------------------------- */
-extern char *program_invocation_name, *program_invocation_short_name;
-
-static void
-get_rule_str(
- struct use_family_rule *rule,
- char *buf,
- size_t len )
-{
- char addr_buf[MAX_ADDR_STR_LEN];
- char ports_buf[16];
- char *target = __sdp_get_family_str( rule->target_family );
- char *prog = rule->prog_name_expr;
-
- /* TODO: handle IPv6 in rule */
- if ( rule->match_by_addr ) {
- char tmp[INET6_ADDRSTRLEN] = "BAD ADDRESS";
-
- if (rule->ip.ss_family == AF_INET)
- inet_ntop(AF_INET, &((struct sockaddr_in *)&rule->ip)->sin_addr, tmp, sizeof(tmp));
- else if (rule->ip.ss_family == AF_INET6)
- inet_ntop(AF_INET6, &((struct sockaddr_in6 *)&rule->ip)->sin6_addr, tmp, sizeof(tmp));
-
- sprintf( addr_buf, "%s/%d", tmp, rule->prefixlen);
- } else {
- strcpy( addr_buf, "*" );
- }
-
- if ( rule->match_by_port )
- if ( rule->eport > rule->sport )
- sprintf( ports_buf, "%d", rule->sport );
- else
- sprintf( ports_buf, "%d-%d", rule->sport, rule->eport );
- else
- sprintf( ports_buf, "*" );
-
- snprintf( buf, len, "use %s %s %s:%s", target, prog, addr_buf, ports_buf );
-}
-
-static inline int __ipv6_prefix_equal(const __be32 *a1, const __be32 *a2,
- unsigned int prefixlen)
-{
- unsigned pdw, pbi;
-
- /* check complete u32 in prefix */
- pdw = prefixlen >> 5;
- if (pdw && memcmp(a1, a2, pdw << 2))
- return 0;
-
- /* check incomplete u32 in prefix */
- pbi = prefixlen & 0x1f;
- if (pbi && ((a1[pdw] ^ a2[pdw]) & htonl((0xffffffff) << (32 - pbi))))
- return 0;
-
- return 1;
-}
-
-static inline int ipv6_prefix_equal(const struct in6_addr *a1,
- const struct in6_addr *a2,
- unsigned int prefixlen)
-{
- return __ipv6_prefix_equal(a1->s6_addr32, a2->s6_addr32,
- prefixlen);
-}
-
-/* return 0 if the addresses match */
-static inline int
-match_addr(
- struct use_family_rule *rule,
- const struct sockaddr *addr_in )
-{
- const struct sockaddr_in *sin = ( const struct sockaddr_in * )addr_in;
- const struct sockaddr_in6 *sin6 = ( const struct sockaddr_in6 * )addr_in;
- const struct sockaddr_in *rule_sin = ( const struct sockaddr_in * )(&rule->ip);
- const struct sockaddr_in6 *rule_sin6 = ( const struct sockaddr_in6 * )(&rule->ip);
-
- if (rule_sin->sin_family == AF_INET && !rule_sin->sin_addr.s_addr)
- return 0;
-
- if (addr_in->sa_family != rule->ip.ss_family)
- return -1;
-
- if (addr_in->sa_family == AF_INET) {
- return ( rule_sin->sin_addr.s_addr !=
- ( sin->sin_addr.s_addr &
- htonl( SDP_NETMASK( rule->prefixlen ) ) ) );
- }
-
- /* IPv6 */
- return !ipv6_prefix_equal(&sin6->sin6_addr, &rule_sin6->sin6_addr, rule->prefixlen);
-}
-
-static int
-match_ip_addr_and_port(
- struct use_family_rule *rule,
- const struct sockaddr *addr_in,
- const socklen_t addrlen )
-{
- const struct sockaddr_in *sin = ( const struct sockaddr_in * )addr_in;
- const struct sockaddr_in6 *sin6 = ( const struct sockaddr_in6 * )addr_in;
- unsigned short port;
- int match = 1;
- char addr_buf[MAX_ADDR_STR_LEN];
- const char *addr_str;
- char rule_str[512];
-
- if ( __sdp_log_get_level( ) <= 3 ) {
- if ( sin6->sin6_family == AF_INET6 ) {
- addr_str = inet_ntop( AF_INET6, ( void * )&( sin6->sin6_addr ),
- addr_buf, MAX_ADDR_STR_LEN );
- port = ntohs( sin6->sin6_port );
- } else {
- addr_str = inet_ntop( AF_INET, ( void * )&( sin->sin_addr ),
- addr_buf, MAX_ADDR_STR_LEN );
- port = ntohs( sin->sin_port );
- }
- if ( addr_str == NULL )
- addr_str = "INVALID_ADDR";
-
- get_rule_str( rule, rule_str, sizeof( rule_str ) );
-
- __sdp_log( 3, "MATCH: matching %s:%d to %s => \n", addr_str, port,
- rule_str );
- }
-
- if ( rule->match_by_port ) {
- port = ntohs( sin->sin_port );
-
- if ( ( port < rule->sport ) || ( port > rule->eport ) ) {
- __sdp_log( 3, "NEGATIVE by port range\n" );
- match = 0;
- }
- }
-
- if ( match && rule->match_by_addr ) {
- if ( match_addr( rule, addr_in ) ) {
- __sdp_log( 3, "NEGATIVE by address\n" );
- match = 0;
- }
- }
-
- if ( match )
- __sdp_log( 3, "POSITIVE\n" );
-
- return match;
-}
-
-/* return 1 on match */
-static int
-match_program_name(
- struct use_family_rule *rule )
-{
- return !fnmatch( rule->prog_name_expr, program_invocation_short_name, 0 );
-}
-
-static use_family_t
-get_family_by_first_matching_rule(
- const struct sockaddr *sin,
- const socklen_t addrlen,
- struct use_family_rule *rules )
-{
- struct use_family_rule *rule;
-
- for ( rule = rules; rule != NULL; rule = rule->next ) {
- /* skip if not our program */
- if ( !match_program_name( rule ) )
- continue;
-
- /* first rule wins */
- if ( match_ip_addr_and_port( rule, sin, addrlen ) )
- return ( rule->target_family );
- }
-
- return ( USE_BOTH );
-}
-
-/* return the result of the first matching rule found */
-use_family_t
-__sdp_match_listen(
- const struct sockaddr * sin,
- const socklen_t addrlen )
-{
- use_family_t target_family;
-
- /* if we do not have any rules we use sdp */
- if ( __sdp_config_empty( ) )
- target_family = USE_SDP;
- else
- target_family =
- get_family_by_first_matching_rule( sin, addrlen,
- __sdp_servers_family_rules_head );
-
- __sdp_log( 4, "MATCH LISTEN: => %s\n",
- __sdp_get_family_str( target_family ) );
-
- return ( target_family );
-}
-
-use_family_t
-__sdp_match_connect(
- const struct sockaddr * sin,
- const socklen_t addrlen )
-{
- use_family_t target_family;
-
- /* if we do not have any rules we use sdp */
- if ( __sdp_config_empty( ) )
- target_family = USE_SDP;
- else
- target_family =
- get_family_by_first_matching_rule( sin, addrlen,
- __sdp_clients_family_rules_head );
-
- __sdp_log( 4, "MATCH CONNECT: => %s\n",
- __sdp_get_family_str( target_family ) );
-
- return ( target_family );
-}
-
-/* given a set of rules see if there is a global match for current program */
-static use_family_t
-match_by_all_rules_program(
- struct use_family_rule *rules )
-{
- int any_sdp = 0;
- int any_tcp = 0;
- use_family_t target_family = USE_BOTH;
- struct use_family_rule *rule;
-
- for ( rule = rules; ( rule != NULL ) && ( target_family == USE_BOTH );
- rule = rule->next ) {
- /* skip if not our program */
- if ( !match_program_name( rule ) )
- continue;
-
- /*
- * to declare a dont care we either have a dont care address and port
- * or the previous non global rules use the same target family as the
- * global rule
- */
- if ( rule->match_by_addr || rule->match_by_port ) {
- /* not a glocal match rule - just track the target family */
- if ( rule->target_family == USE_SDP )
- any_sdp++;
- else if ( rule->target_family == USE_TCP )
- any_tcp++;
- } else {
- /* a global match so we can declare a match by program */
- if ( ( rule->target_family == USE_SDP ) && ( any_tcp == 0 ) )
- target_family = USE_SDP;
- else if ( ( rule->target_family == USE_TCP ) && ( any_sdp == 0 ) )
- target_family = USE_TCP;
- }
- }
- return ( target_family );
-}
-
-/* return tcp or sdp if the port and role are dont cares */
-use_family_t
-__sdp_match_by_program(
- )
-{
- use_family_t server_target_family;
- use_family_t client_target_family;
- use_family_t target_family = USE_BOTH;
-
- if ( __sdp_config_empty( ) ) {
- target_family = USE_SDP;
- } else {
- /* need to try both server and client rules */
- server_target_family =
- match_by_all_rules_program( __sdp_servers_family_rules_head );
- client_target_family =
- match_by_all_rules_program( __sdp_clients_family_rules_head );
-
- /* only if both agree */
- if ( server_target_family == client_target_family )
- target_family = server_target_family;
- }
-
- __sdp_log( 4, "MATCH PROGRAM: => %s\n",
- __sdp_get_family_str( target_family ) );
-
- return ( target_family );
-}
diff --git a/contrib/ofed/libsdp/src/port.c b/contrib/ofed/libsdp/src/port.c
deleted file mode 100644
index d5b265e..0000000
--- a/contrib/ofed/libsdp/src/port.c
+++ /dev/null
@@ -1,2643 +0,0 @@
-/*
- This software is available to you under a choice of one of two
- licenses. You may choose to be licensed under the terms of the GNU
- General Public License (GPL) Version 2, available at
- <http://www.fsf.org/copyleft/gpl.html>, or the OpenIB.org BSD
- license, available in the LICENSE.TXT file accompanying this
- software. These details are also available at
- <http://openib.org/license.html>.
-
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- SOFTWARE.
-
- Copyright (c) 2004 Topspin Communications. All rights reserved.
- Copyright (c) 2005-2006 Mellanox Technologies Ltd. All rights reserved.
-
- $Id$
-*/
-
-/*
- * system includes
- */
-#if HAVE_CONFIG_H
-# include <config.h>
-#endif /* HAVE_CONFIG_H */
-
-#ifdef SOLARIS_BUILD
-/* Our prototypes for ioctl, get*name and accept do not strictly
- match the headers - we use the following lines to move the header
- versions 'out of the way' temporarily. */
-#define ioctl __real_ioctl
-#define getsockname __real_getsockname
-#define getpeername __real_getpeername
-#define accept __real_accept
-#define FASYNC 0
-#include <libgen.h>
-#endif
-#ifdef __FreeBSD__
-#include <libgen.h>
-#endif
-#include <unistd.h>
-#include <errno.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#define __USE_GNU
-#define _GNU_SOURCE /* define RTLD_NEXT */
-#include <dlfcn.h>
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <netinet/tcp.h>
-#include <arpa/inet.h>
-#include <netinet/in.h>
-#include <stdarg.h>
-#include <sys/time.h>
-#include <sys/resource.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <signal.h>
-#include <sys/poll.h>
-#ifdef __linux__
-#include <sys/epoll.h>
-#endif
-
-#ifdef SOLARIS_BUILD
-/* We're done protecting ourselves from the header prototypes */
-#undef ioctl
-#undef getsockname
-#undef getpeername
-#undef accept
-#endif
-
-/*
- * SDP specific includes
- */
-#include "libsdp.h"
-
-/* We can not use sizeof(sockaddr_in6) as the extra scope_id field is not a must have */
-#define IPV6_ADDR_IN_MIN_LEN 24
-
-/* setsockopt() level and optname declarations */
-#define SOL_SDP 1025
-#define SDP_UNBIND 259 /* Unbind socket */
-
-/* Solaris has two entry socket creation functions */
-#define SOCKET_SEMANTIC_DEFAULT 0
-#define SOCKET_SEMANTIC_XNET 1
-
-/* HACK: filter ioctl errors for FIONREAD */
-#define FIONREAD 0x541B
-
-void __attribute__ ((constructor)) __sdp_init(void);
-void __attribute__ ((destructor)) __sdp_fini(void);
-
-/* --------------------------------------------------------------------- */
-/* library type definitions. */
-/* --------------------------------------------------------------------- */
-
-typedef int (*ioctl_func_t) (int fd,
- int request,
- void *arg0,
- void *arg1,
- void *arg2,
- void *arg3,
- void *arg4, void *arg5, void *arg6, void *arg7);
-
-typedef int (*fcntl_func_t) (int fd, int cmd, ...);
-
-typedef int (*socket_func_t) (int domain, int type, int protocol);
-
-typedef int (*setsockopt_func_t) (int s,
- int level,
- int optname,
- const void *optval, socklen_t optlen);
-
-typedef int (*connect_func_t) (int sockfd,
- const struct sockaddr * serv_addr,
- socklen_t addrlen);
-
-typedef int (*listen_func_t) (int s, int backlog);
-
-typedef int (*bind_func_t) (int sockfd,
- const struct sockaddr * my_addr, socklen_t addrlen);
-
-typedef int (*close_func_t) (int fd);
-
-typedef int (*dup_func_t) (int fd);
-
-typedef int (*dup2_func_t) (int oldfd, int newfd);
-
-typedef int (*getsockname_func_t) (int fd,
- struct sockaddr * name, socklen_t * namelen);
-
-typedef int (*getpeername_func_t) (int fd,
- struct sockaddr * name, socklen_t * namelen);
-
-typedef int (*accept_func_t) (int fd,
- struct sockaddr * addr, socklen_t * addrlen);
-
-typedef int (*select_func_t) (int n,
- fd_set * readfds,
- fd_set * writefds,
- fd_set * exceptfds, struct timeval * timeout);
-
-typedef int (*pselect_func_t) (int n,
- fd_set * readfds,
- fd_set * writefds,
- fd_set * exceptfds,
- const struct timespec * timeout,
- const sigset_t * sigmask);
-
-typedef int (*poll_func_t) (struct pollfd * ufds,
- unsigned long int nfds, int timeout);
-
-#ifdef __linux__
-typedef int (*epoll_create_func_t) (int size);
-
-typedef int (*epoll_ctl_func_t) (int epfd,
- int op, int fd, struct epoll_event * event);
-
-typedef int (*epoll_wait_func_t) (int epfd,
- struct epoll_event * events,
- int maxevents, int timeout);
-
-typedef int (*epoll_pwait_func_t) (int epfd,
- struct epoll_event * events,
- int maxevents,
- int timeout, const sigset_t * sigmask);
-#endif
-
-
-struct socket_lib_funcs {
- ioctl_func_t ioctl;
- fcntl_func_t fcntl;
- socket_func_t socket;
- setsockopt_func_t setsockopt;
- connect_func_t connect;
- listen_func_t listen;
- bind_func_t bind;
- close_func_t close;
- dup_func_t dup;
- dup2_func_t dup2;
- getpeername_func_t getpeername;
- getsockname_func_t getsockname;
- accept_func_t accept;
- select_func_t select;
- pselect_func_t pselect;
- poll_func_t poll;
-#ifdef __linux__
- epoll_create_func_t epoll_create;
- epoll_ctl_func_t epoll_ctl;
- epoll_wait_func_t epoll_wait;
- epoll_pwait_func_t epoll_pwait;
-#endif
-}; /* socket_lib_funcs */
-
-#ifdef SOLARIS_BUILD
-/* Solaris has another interface to socket functions prefixed with __xnet_ */
-struct socket_lib_xnet_funcs {
- socket_func_t socket;
- connect_func_t connect;
- listen_func_t listen;
- bind_func_t bind;
-};
-#endif
-
-static int simple_sdp_library;
-static int max_file_descriptors;
-static int dev_null_fd;
-volatile static int init_status = 0; /* 0: idle, 1:during, 2:ready */
-
-/* --------------------------------------------------------------------- */
-/* library static and global variables */
-/* --------------------------------------------------------------------- */
-
-/* glibc provides these symbols - for Solaris builds we fake them
- * until _init is called, at which point we quiz libdl.. */
-#if defined(SOLARIS_BUILD) || defined(__FreeBSD__)
-char *program_invocation_name = "[progname]", *program_invocation_short_name =
- "[short_progname]";
-#else
-extern char *program_invocation_name, *program_invocation_short_name;
-#endif
-
-#ifdef RTLD_NEXT
-static void *__libc_dl_handle = RTLD_NEXT;
-#else
-static void *__libc_dl_handle;
-#endif
-
-/* extra fd attributes we need for our algorithms */
-struct sdp_extra_fd_attributes {
- int shadow_fd; /* file descriptor of shadow sdp socket */
- short last_accept_was_tcp; /* used by accept to alternate tcp and sdp */
- short is_sdp; /* 1 if the fd represents an sdp socket */
-}; /* sdp_extra_fd_attributes */
-
-/* stores the extra attributes struct by fd */
-static struct sdp_extra_fd_attributes *libsdp_fd_attributes;
-
-static struct socket_lib_funcs _socket_funcs = {
- .socket = NULL,
- /* Automatically sets all other elements to NULL */
-}; /* _socket_funcs */
-
-#ifdef SOLARIS_BUILD
-static struct socket_lib_xnet_funcs _socket_xnet_funcs = {
- .socket = NULL,
- /* Automatically sets all other elements to NULL */
-};
-#endif
-
-/* --------------------------------------------------------------------- */
-/* Prototypes */
-/* --------------------------------------------------------------------- */
-void __sdp_init(void);
-
-/* --------------------------------------------------------------------- */
-/* */
-/* local static functions. */
-/* */
-/* --------------------------------------------------------------------- */
-
-/* ========================================================================= */
-/*..init_extra_attribute -- initialize the set of extra attributes for a fd */
-static void init_extra_attribute(int fd)
-{
- if ((0 <= fd) && (max_file_descriptors > fd)) {
- libsdp_fd_attributes[fd].shadow_fd = -1;
- libsdp_fd_attributes[fd].is_sdp = 0;
- libsdp_fd_attributes[fd].last_accept_was_tcp = -1;
- }
-}
-
-static inline int is_valid_fd(int fd)
-{
- return (0 <= fd) && (fd < max_file_descriptors);
-}
-
-/* ========================================================================= */
-/*..get_shadow_fd_by_fd -- given an fd return its shadow fd if exists */
-static inline int get_shadow_fd_by_fd(int fd)
-{
- if (is_valid_fd(fd))
- return libsdp_fd_attributes[fd].shadow_fd;
- else
- return -1;
-}
-
-/* ========================================================================= */
-/*..set_shadow_for_fd -- */
-static inline void set_shadow_for_fd(int fd, int shadow_fd)
-{
- if (is_valid_fd(fd))
- libsdp_fd_attributes[fd].shadow_fd = shadow_fd;
-}
-
-/* ========================================================================= */
-/*..set_is_sdp_socket -- */
-static inline void set_is_sdp_socket(int fd, short is_sdp)
-{
- if (is_valid_fd(fd))
- libsdp_fd_attributes[fd].is_sdp = is_sdp;
-}
-
-/* ========================================================================= */
-/*..get_is_sdp_socket -- given an fd return 1 if it is an SDP socket */
-static inline int get_is_sdp_socket(int fd)
-{
- if (is_valid_fd(fd))
- return libsdp_fd_attributes[fd].is_sdp;
- else
- return 0;
-}
-
-/* ========================================================================= */
-/*..last_accept_was_tcp -- given an fd return 1 if last accept was tcp */
-static inline int last_accept_was_tcp(int fd)
-{
- if (is_valid_fd(fd))
- return libsdp_fd_attributes[fd].last_accept_was_tcp;
- else
- return 0;
-}
-
-/* ========================================================================= */
-/*..set_last_accept -- given an fd set last accept was tcp */
-static inline void set_last_accept(int fd, int was_tcp)
-{
- if (is_valid_fd(fd))
- libsdp_fd_attributes[fd].last_accept_was_tcp = was_tcp;
-}
-
-/* ========================================================================= */
-/*..cleanup_shadow -- an error occured on an SDP socket, cleanup */
-static int cleanup_shadow(int fd)
-{
- int shadow_fd = get_shadow_fd_by_fd(fd);
-
- if (shadow_fd == -1)
- return 0;
- libsdp_fd_attributes[fd].shadow_fd = -1;
- libsdp_fd_attributes[fd].last_accept_was_tcp = 0;
- return (_socket_funcs.close(shadow_fd));
-} /* cleanup_shadow */
-
-/* ========================================================================= */
-/*..replace_fd_with_its_shadow -- perform all required for such promotion */
-static int replace_fd_with_its_shadow(int fd)
-{
- int shadow_fd = libsdp_fd_attributes[fd].shadow_fd;
-
- if (shadow_fd == -1) {
- __sdp_log(8, "Error replace_fd_with_its_shadow: no shadow for fd:%d\n",
- fd);
- return EINVAL;
- }
-
- /* copy the attributes of the shadow before we clean them up */
- libsdp_fd_attributes[fd] = libsdp_fd_attributes[shadow_fd];
- libsdp_fd_attributes[fd].shadow_fd = -1;
- if (_socket_funcs.dup2(shadow_fd, fd) < 0) {
- init_extra_attribute(fd);
- _socket_funcs.close(shadow_fd);
- return EINVAL;
- }
- _socket_funcs.close(shadow_fd);
- return 0;
-}
-
-static sa_family_t get_sdp_domain(int domain)
-{
- if (AF_INET_SDP == domain || AF_INET6_SDP == domain)
- return domain;
-
- if (AF_INET == domain)
- return AF_INET_SDP;
- else if (AF_INET6 == domain)
- return AF_INET6_SDP;
-
- __sdp_log(8, "Error %s: unknown TCP domain: %d\n", __func__, domain);
-
- return -1;
-}
-
-static int get_sock_domain(int sd)
-{
- struct sockaddr_storage tmp_sin;
- socklen_t tmp_sinlen = sizeof(tmp_sin);
-
- if (_socket_funcs.getsockname(sd, (struct sockaddr *) &tmp_sin, &tmp_sinlen) < 0) {
- __sdp_log(8, "Error %s: getsockname return <%d> for socket\n", __func__, errno);
- return -1;
- }
-
- return ((struct sockaddr *)&tmp_sin)->sa_family;
-}
-
-/* ========================================================================= */
-/*..is_filtered_unsuported_sockopt -- return 1 if to filter sockopt failure */
-static inline int is_filtered_unsuported_sockopt(int level, int optname)
-{
- /*
- * TODO: until we know exactly which unsupported opts are really
- * a don't care we always pass the error
- */
- return 0;
-#if 0
- /* these are the SOL_TCP OPTS we should consider filterring */
- TCP_NODELAY 1 /* Don't delay send to coalesce packets */
- TCP_MAXSEG 2 /* Set maximum segment size */
- TCP_CORK 3 /* Control sending of partial frames */
- TCP_KEEPIDLE 4 /* Start keeplives after this period */
- TCP_KEEPINTVL 5 /* Interval between keepalives */
- TCP_KEEPCNT 6 /* Number of keepalives before death */
- TCP_SYNCNT 7 /* Number of SYN retransmits */
- TCP_LINGER2 8 /* Life time of orphaned FIN-WAIT-2 state */
- TCP_DEFER_ACCEPT 9 /* Wake up listener only when data arrive */
- TCP_WINDOW_CLAMP 10 /* Bound advertised window */
- TCP_INFO 11 /* Information about this connection. */
- TCP_QUICKACK 12 /* Bock/reenable quick ACKs. */
-#endif
-}
-
-/* ========================================================================= */
-/*..is_invalid_addr -- return 1 if given pointer is not valid */
-/* NOTE: invalidation of the size is going to happen during actual call */
-static inline int is_invalid_addr(const void *p)
-{
- /* HACK: on some systems we can not write to check for pointer validity */
- size_t ret = fcntl(dev_null_fd, F_GETLK, p);
-
- ret = (errno == EFAULT);
- errno = 0;
- return ret;
-}
-
-/* ========================================================================= */
-/*..get_addr_str -- fill in the given buffer with addr str or return 1 */
-static int get_addr_str(const struct sockaddr *addr, char *buf, size_t len)
-{
- const struct sockaddr_in *sin = (struct sockaddr_in *) addr;
- const struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *) addr;
- char const *conv_res;
-
- if (sin->sin_family == AF_INET) {
- conv_res = inet_ntop(AF_INET, (void *) &(sin->sin_addr), buf, len);
- } else if (sin6->sin6_family == AF_INET6) {
- conv_res = inet_ntop(AF_INET6, (void *) &sin6->sin6_addr, buf, len);
- } else {
- strncpy(buf, "unknown address family", len);
- conv_res = (char *) 1;
- }
- return conv_res == NULL;
-}
-
-/* --------------------------------------------------------------------- */
-/* */
-/* Socket library function overrides. */
-/* */
-/* --------------------------------------------------------------------- */
-
-/* ========================================================================= */
-/*..ioctl -- replacement ioctl call. */
-int
-ioctl(int fd,
- int request,
- void *arg0,
- void *arg1,
- void *arg2, void *arg3, void *arg4, void *arg5, void *arg6, void *arg7)
-{
- int shadow_fd;
- int sret = 0;
- int ret = 0;
-
- if (init_status == 0)
- __sdp_init();
-
- if (NULL == _socket_funcs.ioctl) {
- __sdp_log(9, "Error ioctl: no implementation for ioctl found\n");
- return -1;
- }
-
- shadow_fd = get_shadow_fd_by_fd(fd);
-
- __sdp_log(2, "IOCTL: <%s:%d:%d> request <%d>\n",
- program_invocation_short_name, fd, shadow_fd, request);
-
- ret = _socket_funcs.ioctl(fd, request,
- arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7);
-
- /* HACK: avoid failing on FIONREAD error as SDP does not support it at the moment */
- if ((ret < 0) && get_is_sdp_socket(fd) && (request == FIONREAD)) {
- __sdp_log(8, "Warning ioctl: "
- "Ignoring FIONREAD error for SDP socket.\n");
- ret = 0;
- }
-
- /* if shadow and no error on tcp */
- if ((ret >= 0) && (-1 != shadow_fd)) {
- sret = _socket_funcs.ioctl(shadow_fd, request,
- arg0, arg1, arg2, arg3, arg4, arg5, arg6,
- arg7);
- /* HACK: avoid failing on FIONREAD error as SDP does not support it at the moment */
- if ((sret < 0) && (request == FIONREAD)) {
- __sdp_log(8, "Warning ioctl: "
- "Ignoring FIONREAD error for shadow SDP socket.\n");
- sret = 0;
- }
-
- if (sret < 0) {
- __sdp_log(8, "Error ioctl: "
- "<%d> calling ioctl for SDP socket, closing it.\n",
- errno);
- cleanup_shadow(fd);
- }
- }
-
- __sdp_log(2, "IOCTL: <%s:%d:%d> result <%d:%d>\n",
- program_invocation_short_name, fd, shadow_fd, ret, sret);
-
- return ret;
-} /* ioctl */
-
-/* ========================================================================= */
-/*..fcntl -- replacement fcntl call. */
-int fcntl(int fd, int cmd, ...)
-{
- int shadow_fd;
- int sret = 0;
- int ret = 0;
-
- void *arg;
- va_list ap;
-
- va_start(ap, cmd);
- arg = va_arg(ap, void *);
- va_end(ap);
-
-
- if (init_status == 0)
- __sdp_init();
-
- if (NULL == _socket_funcs.fcntl) {
- __sdp_log(9, "Error fcntl: no implementation for fcntl found\n");
- return -1;
- }
-
- shadow_fd = get_shadow_fd_by_fd(fd);
-
- __sdp_log(2, "FCNTL: <%s:%d:%d> command <%d> argument <%p>\n",
- program_invocation_short_name, fd, shadow_fd, cmd, arg);
-
- ret = _socket_funcs.fcntl(fd, cmd, arg);
- if ((ret >= 0) && (-1 != shadow_fd)) {
- sret = _socket_funcs.fcntl(shadow_fd, cmd, arg);
- if (sret < 0) {
- __sdp_log(8, "Error fcntl:"
- " <%d> calling fcntl(%d, %d, %p) for SDP socket. Closing it.\n",
- shadow_fd, cmd, arg, errno);
- cleanup_shadow(fd);
- }
- }
-
- __sdp_log(2, "FCNTL: <%s:%d:%d> result <%d:%d>\n",
- program_invocation_short_name, fd, shadow_fd, ret, sret);
-
- return ret;
-} /* fcntl */
-
-/* ========================================================================= */
-/*..setsockopt -- replacement setsockopt call. */
-int
-setsockopt(int fd, int level, int optname, const void *optval, socklen_t optlen)
-{
- int shadow_fd;
- int sret = 0;
- int ret = 0;
-
- if (init_status == 0)
- __sdp_init();
-
- if (NULL == _socket_funcs.setsockopt) {
- __sdp_log(9, "Error setsockopt:"
- " no implementation for setsockopt found\n");
- return -1;
- }
-
- shadow_fd = get_shadow_fd_by_fd(fd);
-
- __sdp_log(2, "SETSOCKOPT: <%s:%d:%d> level <%d> name <%d>\n",
- program_invocation_short_name, fd, shadow_fd, level, optname);
-
- if (level == SOL_SOCKET && optname == SO_KEEPALIVE && get_is_sdp_socket(fd)) {
- level = AF_INET_SDP;
- __sdp_log(2, "SETSOCKOPT: <%s:%d:%d> substitute level %d\n",
- program_invocation_short_name, fd, shadow_fd, level);
- }
-
- ret = _socket_funcs.setsockopt(fd, level, optname, optval, optlen);
- if ((ret >= 0) && (shadow_fd != -1)) {
- if (level == SOL_SOCKET && optname == SO_KEEPALIVE &&
- get_is_sdp_socket(shadow_fd)) {
- level = AF_INET_SDP;
- __sdp_log(2, "SETSOCKOPT: <%s:%d:%d> substitute level %d\n",
- program_invocation_short_name, fd, shadow_fd, level);
- }
-
- sret = _socket_funcs.setsockopt(shadow_fd, level, optname, optval, optlen);
- if (sret < 0) {
- __sdp_log(8, "Warning sockopts:"
- " ignoring error on shadow SDP socket fd:<%d>\n", fd);
- /*
- * HACK: we should allow some errors as some sock opts are unsupported
- * __sdp_log(8, "Error %d calling setsockopt for SDP socket, closing\n", errno);
- * cleanup_shadow(fd);
- */
- }
- }
-
- /* Due to SDP limited implmentation of sockopts we ignore some errors */
- if ((ret < 0) && get_is_sdp_socket(fd) &&
- is_filtered_unsuported_sockopt(level, optname)) {
- __sdp_log(8, "Warning sockopts: "
- "ignoring error on non implemented sockopt on SDP socket"
- " fd:<%d> level:<%d> opt:<%d>\n", fd, level, optval);
- ret = 0;
- }
-
- __sdp_log(2, "SETSOCKOPT: <%s:%d:%d> result <%d:%d>\n",
- program_invocation_short_name, fd, shadow_fd, ret, sret);
-
- return ret;
-} /* setsockopt */
-
-/* ========================================================================= */
-/*..socket -- replacement socket call. */
-
-static inline int __create_socket_semantic(int domain,
- int type,
- int protocol, int semantics)
-{
- return
-#ifdef SOLARIS_BUILD
- (semantics == SOCKET_SEMANTIC_XNET) ?
- _socket_xnet_funcs.socket(domain, type, protocol) :
-#endif
- _socket_funcs.socket(domain, type, protocol);
-}
-
-/* Contains the main logic for creating shadow SDP sockets */
-static int __create_socket(int domain, int type, int protocol, int semantics)
-{
- int s = -1;
- int shadow_fd = -1;
- use_family_t family_by_prog;
- int sdp_domain;
-
- if (init_status == 0)
- __sdp_init();
-
- if (NULL == _socket_funcs.socket) {
- __sdp_log(9, "Error socket: no implementation for socket found\n");
- return -1;
- }
-
- __sdp_log(2, "SOCKET: <%s> domain <%d> type <%d> protocol <%d>\n",
- program_invocation_short_name, domain, type, protocol);
-
- if (!(AF_INET == domain || AF_INET6 == domain ||
- AF_INET_SDP == domain || AF_INET6_SDP == domain)) {
- __sdp_log(1, "SOCKET: making other socket\n");
- s = __create_socket_semantic(domain, type, protocol, semantics);
- goto done;
- }
-
- sdp_domain = get_sdp_domain(domain);
- if (sdp_domain < 0) {
- errno = EAFNOSUPPORT;
- s = -1;
- goto done;
- }
-
- /* check to see if we can skip the shadow */
- if ((AF_INET == domain || AF_INET6 == domain) && (SOCK_STREAM == type))
- if (simple_sdp_library)
- family_by_prog = USE_SDP;
- else
- family_by_prog = __sdp_match_by_program();
- else if (AF_INET_SDP == domain || AF_INET6_SDP == domain)
- family_by_prog = USE_SDP;
- else
- family_by_prog = USE_TCP;
-
- if (family_by_prog == USE_TCP) {
- __sdp_log(1, "SOCKET: making TCP only socket (no shadow)\n");
- s = __create_socket_semantic(domain, type, protocol, semantics);
- init_extra_attribute(s);
- set_is_sdp_socket(s, 0);
- goto done;
- }
-
- if (family_by_prog == USE_SDP) {
- /* HACK: convert the protocol if IPPROTO_IP */
- if (protocol == 0)
- protocol = IPPROTO_TCP;
-
- __sdp_log(1, "SOCKET: making SDP socket type:%d proto:%d\n",
- type, protocol);
- s = __create_socket_semantic(sdp_domain, type, protocol, semantics);
- init_extra_attribute(s);
- set_is_sdp_socket(s, 1);
- goto done;
- }
-
- /* HACK: if we fail creating the TCP socket should we abort ? */
- __sdp_log(1, "SOCKET: making TCP socket\n");
- s = __create_socket_semantic(domain, type, protocol, semantics);
- init_extra_attribute(s);
- set_is_sdp_socket(s, 0);
- if (is_valid_fd(s)) {
- if (((AF_INET == domain) || (AF_INET6 == domain)) &&
- (SOCK_STREAM == type)) {
-
- if (protocol == 0)
- protocol = IPPROTO_TCP;
- __sdp_log(1, "SOCKET: making SDP shadow socket type:%d proto:%d\n",
- type, protocol);
- shadow_fd =
- __create_socket_semantic(sdp_domain, type, protocol,
- semantics);
- if (is_valid_fd(shadow_fd)) {
- init_extra_attribute(shadow_fd);
- if (libsdp_fd_attributes[s].shadow_fd != -1) {
- __sdp_log(8, "Warning socket: "
- "overriding existing shadow fd:%d for fd:%d\n",
- libsdp_fd_attributes[s].shadow_fd, s);
- }
- set_is_sdp_socket(shadow_fd, 1);
- set_shadow_for_fd(s, shadow_fd);
- } else {
- __sdp_log(8,
- "Error socket: <%d> calling socket for SDP socket\n",
- errno);
- /* fail if we did not make the SDP socket */
- __sdp_log(1, "SOCKET: closing TCP socket:<%d>\n", s);
- _socket_funcs.close(s);
- s = -1;
- }
- }
- } else {
- __sdp_log(8, "Error socket: "
- "ignoring SDP socket since TCP fd:%d out of range\n", s);
- }
-
-done:
- __sdp_log(2, "SOCKET: <%s:%d:%d>\n",
- program_invocation_short_name, s, shadow_fd);
-
- return s;
-} /* socket */
-
-int socket(int domain, int type, int protocol)
-{
- return __create_socket(domain, type, protocol, SOCKET_SEMANTIC_DEFAULT);
-}
-
-#ifdef SOLARIS_BUILD
-int __xnet_socket(int domain, int type, int protocol)
-{
- return __create_socket(domain, type, protocol, SOCKET_SEMANTIC_XNET);
-}
-#endif
-
-/* ========================================================================= */
-/*..get_fd_addr_port_num - obtain the port the fd is attached to */
-static int get_fd_addr_port_num(int sd)
-{
- struct sockaddr_storage addr;
- int ret;
- const struct sockaddr_in *sin;
- socklen_t addrlen = sizeof(addr);
-
- ret = _socket_funcs.getsockname(sd, (struct sockaddr *) &addr, &addrlen);
-
- if (ret) {
- __sdp_log(8, "Error: in get_fd_addr_port_num - Failed to get getsockname\n");
- return -1;
- }
-
- /* port num is in same location for IPv4 and IPv6 */
- sin = (const struct sockaddr_in *) &addr;
- return ntohs(sin->sin_port);
-}
-
-/* ========================================================================= */
-/*..set_addr_port_num - sets the port in the given address */
-static int set_addr_port_num(const struct sockaddr *addr, int port)
-{
- struct sockaddr_in *sin = (struct sockaddr_in *) addr;
-
- /* port num is in same location for IPv4 and IPv6 */
- sin->sin_port = htons(port);
- return 0;
-}
-
-/* ========================================================================= */
-/* perform a bind with the given socket semantics */
-static inline int
-__bind_semantics(int fd,
- const struct sockaddr *my_addr,
- socklen_t addrlen, int semantics)
-{
- return
-#ifdef SOLARIS_BUILD
- (semantics == SOCKET_SEMANTIC_XNET) ?
- _socket_xnet_funcs.bind(fd, my_addr, addrlen) :
-#endif
- _socket_funcs.bind(fd, my_addr, addrlen);
-}
-
-/* ========================================================================= */
-/*..find_free_port - find same free port on both TCP and SDP */
-#define MAX_BIND_ANY_PORT_TRIES 20000
-static int
-find_free_port(const struct sockaddr *sin_addr,
- const socklen_t addrlen,
- int orig_sd,
- int *sdp_sd, int *tcp_sd, int semantics)
-{
- static int tcp_turn = 1;
- int tmp_turn = tcp_turn;
- int num_of_loops = 0;
- int port = -1;
- int tmp_sd[2];
- unsigned int yes = 1;
- int ret;
- int domain, sdp_domain;
-
- __sdp_log(2, "find_free_port: starting search for common free port\n");
-
- /* need to obtain the address family from the fd */
- domain = get_sock_domain(orig_sd);
- if (domain == -1) {
- errno = EFAULT;
- goto done;
- }
-
- sdp_domain = get_sdp_domain(domain);
- if (sdp_domain < 0) {
- errno = EFAULT;
- goto done;
- }
-
- do {
- __sdp_log(1, "find_free_port: taking loop (%d)\n", ++num_of_loops);
-
- __sdp_log(1, "find_free_port: creating the two sockets\n");
- tmp_sd[0] = _socket_funcs.socket(sdp_domain, SOCK_STREAM, IPPROTO_TCP);
- if (tmp_sd[0] < 0) {
- __sdp_log(8, "Warning find_free_port: creating first socket failed\n");
- goto done;
- }
-
- _socket_funcs.setsockopt(tmp_sd[0], SOL_SOCKET, SO_REUSEADDR, &yes, sizeof(yes));
-
- tmp_sd[1] = _socket_funcs.socket(domain, SOCK_STREAM, IPPROTO_TCP);
- if (tmp_sd[1] < 0) {
- __sdp_log(8, "Warning find_free_port: creating second socket failed\n");
- _socket_funcs.close(tmp_sd[0]);
- goto done;
- }
-
- _socket_funcs.setsockopt(tmp_sd[1], SOL_SOCKET, SO_REUSEADDR, &yes,
- sizeof(yes));
-
- __sdp_log(1, "find_free_port: binding first %s socket\n",
- tmp_turn ? "tcp" : "sdp");
- ret = __bind_semantics(tmp_sd[tmp_turn], sin_addr, addrlen, semantics);
- if (ret < 0) {
- __sdp_log(8,
- "Warning find_free_port: binding first socket failed:%s\n",
- strerror(errno));
- _socket_funcs.close(tmp_sd[0]);
- _socket_funcs.close(tmp_sd[1]);
- goto done;
- }
-
- __sdp_log(1, "find_free_port: listening on first socket\n");
- ret = _socket_funcs.listen(tmp_sd[tmp_turn], 5);
- if (ret < 0) {
- __sdp_log(8, "Warning find_free_port: listening on first socket failed:%s\n",
- strerror(errno));
- _socket_funcs.close(tmp_sd[0]);
- _socket_funcs.close(tmp_sd[1]);
- goto done;
- }
-
- port = get_fd_addr_port_num(tmp_sd[tmp_turn]);
- if (port < 0) {
- __sdp_log(8, "Warning find_free_port: first socket port:%d < 0\n",
- port);
- _socket_funcs.close(tmp_sd[0]);
- _socket_funcs.close(tmp_sd[1]);
- goto done;
- }
- __sdp_log(1, "find_free_port: first socket port:%u\n", port);
-
- set_addr_port_num(sin_addr, port);
-
- __sdp_log(1, "find_free_port: binding second socket\n");
- ret = __bind_semantics(tmp_sd[1 - tmp_turn], sin_addr, addrlen, semantics);
- if (ret < 0) {
- /* bind() for sdp socket failed. It is acceptable only
- * if the IP is not part of IB network. */
-
- if (errno != EADDRINUSE) {
- __sdp_log(8, "Warning find_free_port: "
- "binding second socket failed with %s\n",
- strerror(errno));
- goto close_and_mark;
- } else {
- int err;
-#ifdef __linux__
- socklen_t len = sizeof(int);
-
- ret = getsockopt(tmp_sd[1 - tmp_turn], SOL_TCP,
- SDP_LAST_BIND_ERR, &err, &len);
- if (-1 == ret) {
- __sdp_log(8, "Error %s:getsockopt: %s\n",
- __func__, strerror(errno));
- goto close_and_mark;
- }
-#else
- err = -errno;
-#endif
- if (-ENOENT == err || -EADDRINUSE != err) {
- /* bind() failed due to either:
- * 1. IP is ETH, not IB, so can't bind() to sdp socket.
- * 2. real error.
- * Continue only with TCP */
- goto close_and_mark;
- }
- __sdp_log(1, "find_free_port: %s port %u was busy\n",
- 1 - tmp_turn ? "tcp" : "sdp",
- ntohs(((const struct sockaddr_in *)sin_addr)->sin_port));
- }
-
- /* close the sockets - we will need new ones ... */
- __sdp_log(1,
- "find_free_port: closing the two sockets before next loop\n");
- _socket_funcs.close(tmp_sd[0]);
- _socket_funcs.close(tmp_sd[1]);
-
- port = -1;
- /* we always start with tcp so we keep the original setting for now */
- /* tmp_turn = 1 - tmp_turn; */
- }
-
- } while ((port < 0) && (num_of_loops < MAX_BIND_ANY_PORT_TRIES));
-
-setfds:
- tcp_turn = tmp_turn;
- *sdp_sd = tmp_sd[0];
- *tcp_sd = tmp_sd[1];
-
-done:
- __sdp_log(2, "find_free_port: return port:<%d>\n", port);
- return port;
-
-close_and_mark:
- _socket_funcs.close(tmp_sd[0]);
- tmp_sd[0] = -1; /* mark with error */
- goto setfds;
-
-}
-
-/* ========================================================================= */
-/*..check_legal_bind - check if given address is okay for both TCP and SDP */
-static int
-check_legal_bind(const struct sockaddr *sin_addr,
- const socklen_t addrlen,
- int orig_sd,
- int *sdp_sd, int *tcp_sd, int semantics)
-{
- unsigned int yes = 1;
- int ret = -1;
- int sret = -1;
- int domain, sdp_domain;
-
- /* need to obtain the address family from the fd */
- domain = get_sock_domain(orig_sd);
- if (domain == -1) {
- errno = EFAULT;
- ret = -1;
- goto done;
- }
-
- sdp_domain = get_sdp_domain(domain);
- if (sdp_domain < 0) {
- errno = EFAULT;
- goto done;
- }
-
- __sdp_log(2, "check_legal_bind: binding two temporary sockets\n");
- *sdp_sd = _socket_funcs.socket(sdp_domain, SOCK_STREAM, IPPROTO_TCP);
- if (*sdp_sd < 0) {
- __sdp_log(8, "Error check_legal_bind: " "creating SDP socket failed\n");
- goto done;
- }
-
- __sdp_log(2, "check_legal_bind: reusing <%d> \n", *sdp_sd);
- sret =
- _socket_funcs.setsockopt(*sdp_sd, SOL_SOCKET, SO_REUSEADDR, &yes,
- sizeof(yes));
- if (sret < 0) {
- __sdp_log(8, "Error bind: Could not setsockopt sdp_sd\n");
- }
-
- *tcp_sd = _socket_funcs.socket(domain, SOCK_STREAM, IPPROTO_TCP);
- if (*tcp_sd < 0) {
- __sdp_log(8, "Error check_legal_bind: "
- "creating second socket failed:%s\n", strerror(errno));
- _socket_funcs.close(*sdp_sd);
- goto done;
- }
-
- __sdp_log(2, "check_legal_bind: reusing <%d> \n", *tcp_sd);
- sret =
- _socket_funcs.setsockopt(*tcp_sd, SOL_SOCKET, SO_REUSEADDR, &yes,
- sizeof(yes));
- if (sret < 0) {
- __sdp_log(8, "Error bind: Could not setsockopt tcp_sd\n");
- }
-
- __sdp_log(1, "check_legal_bind: binding SDP socket\n");
- ret = __bind_semantics(*sdp_sd, sin_addr, addrlen, semantics);
- if (ret < 0) {
- /* bind() for sdp socket failed. It is acceptable only if
- * the IP is not part of IB network. */
- int err;
- socklen_t len = sizeof(int);
-
- if (EADDRINUSE != errno)
- goto done;
-#ifdef __linux__
- if (-1 == getsockopt(*sdp_sd, SOL_TCP, SDP_LAST_BIND_ERR, &err, &len)) {
- __sdp_log(8, "Error check_legal_bind:getsockopt: %s\n",
- strerror(errno));
- goto done;
- }
-#else
- err = -errno;
-#endif
- if (-ENOENT != err) {
- /* bind() failed due to real error. Can't continue */
- __sdp_log(8, "Error check_legal_bind: "
- "binding SDP socket failed:%s\n", strerror(errno));
- _socket_funcs.close(*sdp_sd);
- _socket_funcs.close(*tcp_sd);
-
- /* TCP and SDP without library return EINVAL */
- if (errno == EADDRINUSE)
- errno = EINVAL;
-
- goto done;
- }
- /* IP is ETH, not IB, so can't bind() to sdp socket */
- /* Continue only with TCP */
- _socket_funcs.close(*sdp_sd);
- *sdp_sd = -1;
- }
-
- __sdp_log(1, "check_legal_bind: binding TCP socket\n");
- ret = __bind_semantics(*tcp_sd, sin_addr, addrlen, semantics);
- if (ret < 0) {
- __sdp_log(8, "Error check_legal_bind: "
- "binding TCP socket failed:%s\n", strerror(errno));
- if (-1 != *sdp_sd)
- _socket_funcs.close(*sdp_sd);
- _socket_funcs.close(*tcp_sd);
- goto done;
- }
- ret = 0;
- __sdp_log(2, "check_legal_bind: result:<%d>\n", ret);
-done:
- return ret;
-}
-
-/* ========================================================================= */
-/*..close_and_bind - close an open fd and bind another one immediately */
-static int
-close_and_bind(int old_sd,
- int new_sd,
- const struct sockaddr *addr, socklen_t addrlen, int semantics)
-{
- int ret;
-
- __sdp_log(2, "close_and_bind: closing <%d> binding <%d>\n", old_sd, new_sd);
- ret = _socket_funcs.close(old_sd);
- if (ret < 0) {
- __sdp_log(8, "Error bind: Could not close old_sd\n");
- goto done;
- }
-
- ret = __bind_semantics(new_sd, addr, addrlen, semantics);
- if (ret < 0)
- __sdp_log(8, "Error bind: Could not bind new_sd\n");
-
-done:
- __sdp_log(2, "close_and_bind: returning <%d>\n", ret);
- return ret;
-}
-
-/* ========================================================================= */
-/*..bind -- replacement bind call. */
-/*
- As we do not know the role of this socket yet so we cannot choose AF.
- We need to be able to handle shadow too.
- SDP sockets (may be shadow or not) must be using converted address
-
- Since there is no way to "rebind" a socket we have to avoid "false" bind:
- 1. When the given address for the bind includes a port we need to
- guarantee the port is free on both address families. We do that
- by creating temporary sockets and biding them first. Then we close and
- re-use the address on the real sockets.
- 2. When ANY_PORT is requested we need to make sure the port we obtain from
- the first address family is also free on the second one. We use temporary
- sockets for that task too. We loop several times to find such common
- available socket
-*/
-static int
-__perform_bind(int fd,
- const struct sockaddr *addr, socklen_t addrlen, int semantics)
-{
- int shadow_fd;
- struct sockaddr_in *sin_addr = (struct sockaddr_in *) addr;
- int ret, sret = -1;
- char buf[MAX_ADDR_STR_LEN];
-
- if (init_status == 0)
- __sdp_init();
-
- if (NULL == _socket_funcs.bind) {
- __sdp_log(9, "Error bind: no implementation for bind found\n");
- return -1;
- }
-
- shadow_fd = get_shadow_fd_by_fd(fd);
-
- if ((addr == NULL) || is_invalid_addr(addr)) {
- errno = EFAULT;
- __sdp_log(8, "Error bind: illegal address provided\n");
- return -1;
- }
-
- if (get_addr_str(addr, buf, MAX_ADDR_STR_LEN)) {
- __sdp_log(8, "Error bind: provided illegal address: %s\n",
- strerror(errno));
- return -1;
- }
-
- __sdp_log(2, "BIND: <%s:%d:%d> type <%d> IP <%s> port <%d>\n",
- program_invocation_short_name, fd, shadow_fd,
- sin_addr->sin_family, buf, ntohs(sin_addr->sin_port));
-
- if (get_is_sdp_socket(fd)) {
- __sdp_log(1, "BIND: binding SDP socket:<%d>\n", fd);
- ret = __bind_semantics(fd, addr, addrlen, semantics);
- goto done;
- } else if (shadow_fd != -1) {
- /* has shadow */
- /* we need to validate the given address or find a common port
- * so we use the following tmp address and sockets */
- struct sockaddr_storage tmp_addr;
- int sdp_sd = -1, tcp_sd = -1, port;
-
- memcpy(&tmp_addr, addr, addrlen);
- ret = 0;
- if (ntohs(sin_addr->sin_port) == 0) {
- /* When we get ANY_PORT we need to make sure that both TCP
- * and SDP sockets will use the same port */
-
- port = find_free_port(addr, addrlen, fd, &sdp_sd, &tcp_sd, semantics);
- if (port < 0) {
- ret = -1;
- __sdp_log(9, "BIND: Failed to find common free port\n");
- /* We cannot bind both tcp and sdp on the same port, we will close
- * the sdp and continue with tcp only */
- goto done;
- } else {
- /* copy the port to the tmp address */
- set_addr_port_num((struct sockaddr *) &tmp_addr, port);
- }
- } else {
- /* have a shadow but requested specific port - check that we
- * can actually bind the two addresses and then reuse */
- ret = check_legal_bind(addr, addrlen, fd, &sdp_sd, &tcp_sd, semantics);
- if (ret < 0) {
- __sdp_log(8, "Error bind: "
- "Provided address can not bind on the two sockets\n");
- }
- }
-
- /* if we fail to find a common port or given address can not be used
- * we return error */
- if (ret < 0) {
- /* Temporary sockets already closed by check_legal_bind or
- * find_free_port */
- errno = EADDRINUSE;
- goto done;
- }
-
- /* close temporary sockets and reuse their address */
- /* HACK: close_and_bind might race with other applications. */
- /* When the race occur we return EADDRINUSE */
- ret = close_and_bind(tcp_sd, fd, (struct sockaddr *) &tmp_addr,
- addrlen, semantics);
- if (ret < 0) {
- __sdp_log(8, "Error bind: " "Could not close_and_bind TCP side\n");
- if (-1 != sdp_sd)
- _socket_funcs.close(sdp_sd);
- goto done;
- }
-
- if (-1 != sdp_sd) {
- ret = close_and_bind(sdp_sd, shadow_fd, (struct sockaddr *) &tmp_addr,
- addrlen, semantics);
-
- if (ret < 0) {
- __sdp_log(8,
- "Error bind: " "Could not close_and_bind sdp side\n");
- goto done;
- }
- }
- goto done;
- }
-
- /* we can only get here on single TCP socket */
- __sdp_log(1, "BIND: binding TCP socket:<%d>\n", fd);
- ret = __bind_semantics(fd, addr, addrlen, semantics);
-
-done:
- __sdp_log(2, "BIND: <%s:%d:%d> result <%d:%d>\n",
- program_invocation_short_name, fd, shadow_fd, ret, sret);
-
- return ret;
-} /* bind */
-
-
-int bind(int fd, const struct sockaddr *my_addr, socklen_t addrlen)
-{
- return __perform_bind(fd, my_addr, addrlen, SOCKET_SEMANTIC_DEFAULT);
-}
-
-#ifdef SOLARIS_BUILD
-int __xnet_bind(int fd, const struct sockaddr *my_addr, socklen_t addrlen)
-{
- return __perform_bind(fd, my_addr, addrlen, SOCKET_SEMANTIC_XNET);
-}
-#endif
-
-
-/* ========================================================================= */
-/*..connect -- replacement connect call. */
-/*
- Given the connect address we can take out AF decision
- if target AF == both it means SDP and fall back to TCP
- if any connect worked we are fine
-*/
-static inline int
-__connect_semantics(int fd,
- const struct sockaddr *serv_addr,
- socklen_t addrlen, int semantics)
-{
- return
-#ifdef SOLARIS_BUILD
- (semantics == SOCKET_SEMANTIC_XNET) ?
- _socket_xnet_funcs.connect(fd, serv_addr, addrlen) :
-#endif
- _socket_funcs.connect(fd, serv_addr, addrlen);
-}
-
-static int
-__perform_connect(int fd, const struct sockaddr *serv_addr,
- socklen_t addrlen, int semantics)
-{
- struct sockaddr_in *serv_sin = (struct sockaddr_in *) serv_addr;
- char buf[MAX_ADDR_STR_LEN];
- int shadow_fd;
- int ret = -1, dup_ret;
- use_family_t target_family;
- int fopts;
-
- if (init_status == 0)
- __sdp_init();
-
- if (NULL == _socket_funcs.connect) {
- __sdp_log(9, "Error connect: no implementation for connect found\n");
- return -1;
- }
-
- shadow_fd = get_shadow_fd_by_fd(fd);
-
- if ((serv_addr == NULL) || is_invalid_addr(serv_addr)) {
- errno = EFAULT;
- __sdp_log(8, "Error connect: illegal address provided\n");
- return -1;
- }
-
- if (get_addr_str(serv_addr, buf, MAX_ADDR_STR_LEN)) {
- __sdp_log(8, "Error connect: provided illegal address: %s\n",
- strerror(errno));
- return EADDRNOTAVAIL;
- }
-
- __sdp_log(2, "CONNECT: <%s:%d:%d> domain <%d> IP <%s> port <%d>\n",
- program_invocation_short_name, fd, shadow_fd,
- serv_sin->sin_family, buf, ntohs(serv_sin->sin_port));
-
-
- /* obtain the target address family */
- target_family = __sdp_match_connect(serv_addr, addrlen);
-
- /* if we do not have a shadow - just do the work */
- if (shadow_fd == -1) {
- __sdp_log(1, "CONNECT: connectingthrough %s\n",
- get_is_sdp_socket(fd) ? "SDP" : "TCP");
- ret = __connect_semantics(fd, serv_addr, addrlen, semantics);
- if ((ret == 0) || (errno == EINPROGRESS)) {
- __sdp_log(7, "CONNECT: connected SDP fd:%d to:%s port %d\n",
- fd, buf, ntohs(serv_sin->sin_port));
- }
- goto done;
- }
-
- if ((target_family == USE_SDP) || (target_family == USE_BOTH)) {
- /* NOTE: the entire if sequence is negative logic */
- __sdp_log(1, "CONNECT: connecting SDP fd:%d\n", shadow_fd);
-
- /* make the socket blocking on shadow SDP */
- fopts = _socket_funcs.fcntl(shadow_fd, F_GETFL);
- if ((target_family == USE_BOTH) && (fopts & O_NONBLOCK)) {
- __sdp_log(1,
- "CONNECT: shadow_fd <%d> will be blocking during connect\n",
- shadow_fd);
- _socket_funcs.fcntl(shadow_fd, F_SETFL, fopts & (~O_NONBLOCK));
- }
-
- ret = __connect_semantics(shadow_fd, serv_addr, addrlen, semantics);
- if ((ret < 0) && (errno != EINPROGRESS)) {
- __sdp_log(7, "Error connect: "
- "failed for SDP fd:%d with error:%m\n", shadow_fd);
- } else {
- __sdp_log(7, "CONNECT: connected SDP fd:%d to:%s port %d\n",
- fd, buf, ntohs(serv_sin->sin_port));
- }
-
- /* restore socket options */
- _socket_funcs.fcntl(shadow_fd, F_SETFL, fopts);
-
- /* if target is SDP or we succeeded we need to dup SDP fd into TCP fd */
- if ((target_family == USE_SDP) || (ret >= 0)) {
- dup_ret = replace_fd_with_its_shadow(fd);
- if (dup_ret < 0) {
- __sdp_log(9, "Error connect: "
- "failed to dup2 shadow into orig fd:%d\n", fd);
- ret = dup_ret;
- } else {
- /* we can skip the TCP option if we are done */
- __sdp_log(1, "CONNECT: "
- "matched SDP fd:%d so shadow dup into TCP\n", fd);
- goto done;
- }
- }
- }
-
- if ((target_family == USE_TCP) || (target_family == USE_BOTH)) {
- __sdp_log(1, "CONNECT: connecting TCP fd:%d\n", fd);
- ret = __connect_semantics(fd, serv_addr, addrlen, semantics);
- if ((ret < 0) && (errno != EINPROGRESS))
- __sdp_log(8, "Error connect: for TCP fd:%d failed with error:%m\n",
- fd);
- else
- __sdp_log(7, "CONNECT: connected TCP fd:%d to:%s port %d\n",
- fd, buf, ntohs(serv_sin->sin_port));
-
- if ((target_family == USE_TCP) || (ret >= 0) || (errno == EINPROGRESS)) {
- if (cleanup_shadow(fd) < 0)
- __sdp_log(8,
- "Error connect: failed to cleanup shadow for fd:%d\n",
- fd);
- }
- }
-
-done:
- __sdp_log(2, "CONNECT: <%s:%d:%d> result <%d>\n",
- program_invocation_short_name, fd, shadow_fd, ret);
-
- return ret;
-} /* connect */
-
-int connect(int fd, const struct sockaddr *serv_addr, socklen_t addrlen)
-{
- return __perform_connect(fd, serv_addr, addrlen, SOCKET_SEMANTIC_DEFAULT);
-}
-
-#if defined( SOLARIS_BUILD )
-int __xnet_connect(int fd, const struct sockaddr *serv_addr, socklen_t addrlen)
-{
- return __perform_connect(fd, serv_addr, addrlen, SOCKET_SEMANTIC_XNET);
-}
-#endif
-
-/* ========================================================================= */
-/*..listen -- replacement listen call. */
-/*
- Now we know our role (passive/server) and our address so we can get AF.
- If both we should try listening on both
-*/
-
-static inline int __listen_semantics(int fd, int backlog, int semantics)
-{
- return
-#ifdef SOLARIS_BUILD
- (semantics == SOCKET_SEMANTIC_XNET) ?
- _socket_xnet_funcs.listen(fd, backlog) :
-#endif
- _socket_funcs.listen(fd, backlog);
-}
-
-static int __perform_listen(int fd, int backlog, int semantics)
-{
- use_family_t target_family;
- int shadow_fd;
- int ret = 0, sret = 0;
- struct sockaddr_storage tmp_sin;
- socklen_t tmp_sinlen = sizeof(tmp_sin);
- struct sockaddr_in *sin4 = (struct sockaddr_in *) &tmp_sin;
- char buf[MAX_ADDR_STR_LEN];
- int actual_port;
-
- if (init_status == 0)
- __sdp_init();
-
- if (NULL == _socket_funcs.listen) {
- __sdp_log(9, "Error listen: no implementation for listen found\n");
- return -1;
- }
-
- shadow_fd = get_shadow_fd_by_fd(fd);
- __sdp_log(2, "LISTEN: <%s:%d:%d>\n",
- program_invocation_short_name, fd, shadow_fd);
-
- /* if there is no shadow - simply call listen */
- if (shadow_fd == -1) {
- __sdp_log(1, "LISTEN: calling listen on fd:%d\n", fd);
- ret = __listen_semantics(fd, backlog, semantics);
- goto done;
- }
-
- /* we need to obtain the address from the fd */
- if (_socket_funcs.getsockname(fd, (struct sockaddr *) &tmp_sin, &tmp_sinlen)
- < 0) {
- __sdp_log(8, "Error listen: getsockname return <%d> for TCP socket\n",
- errno);
- errno = EADDRNOTAVAIL;
- sret = -1;
- goto done;
- }
-
- if (get_addr_str((struct sockaddr *) &tmp_sin, buf, MAX_ADDR_STR_LEN)) {
- __sdp_log(8, "Error listen: provided illegal address: %s\n",
- strerror(errno));
- }
-
- __sdp_log(2, "LISTEN: <%s:%d:%d> domain <%d> IP <%s> port <%d>\n",
- program_invocation_short_name, fd, shadow_fd,
- sin4->sin_family, buf, ntohs(sin4->sin_port));
-
- target_family =
- __sdp_match_listen((struct sockaddr *) &tmp_sin, sizeof(tmp_sin));
-
- /*
- * in case of an implicit bind and "USE_BOTH" rule we need to first bind the
- * two sockets to the same port number
- */
- actual_port = ntohs(sin4->sin_port);
-
- /* do we need to implicit bind both */
- if ((actual_port == 0) && (target_family == USE_BOTH)) {
- int sdp_sd = -1, tcp_sd = -1;
-
- actual_port = find_free_port((struct sockaddr *) &tmp_sin, tmp_sinlen,
- fd, &sdp_sd, &tcp_sd, semantics);
- if (actual_port < 0) {
- ret = -1;
- __sdp_log(8, "LISTEN: Failed to find common free port. Only TCP will be used.\n");
- target_family = USE_TCP;
- } else {
- /* copy the port to the tmp address */
- set_addr_port_num((struct sockaddr *) sin4, actual_port);
-
- __sdp_log(2, "LISTEN: BOTH on IP <%s> port <%d>\n",
- buf, actual_port);
- /* perform the bind */
- ret = close_and_bind(tcp_sd, fd, (struct sockaddr *) sin4,
- tmp_sinlen, semantics);
- if (ret < 0) {
- __sdp_log(8, "Error listen: "
- "Could not close_and_bind TCP side\n");
- }
-
- ret = close_and_bind(sdp_sd, shadow_fd, (struct sockaddr *) sin4,
- tmp_sinlen, semantics);
- if (ret < 0) {
- __sdp_log(8, "Error listen: "
- "Could not close_and_bind SDP side\n");
- }
- }
- }
-
- if ((target_family == USE_TCP) || (target_family == USE_BOTH)) {
- __sdp_log(1, "LISTEN: calling listen on TCP fd:%d\n", fd);
- ret = __listen_semantics(fd, backlog, semantics);
- if (ret < 0) {
- __sdp_log(8, "Error listen: failed with code <%d> on TCP fd:<%d>\n",
- errno, fd);
- } else {
- __sdp_log(7, "LISTEN: fd:%d listening on TCP bound to:%s port:%d\n",
- fd, buf, actual_port);
- }
- }
-
- if ((target_family == USE_SDP) || (target_family == USE_BOTH)) {
- __sdp_log(1, "LISTEN: calling listen on SDP fd:<%d>\n", shadow_fd);
- sret = __listen_semantics(shadow_fd, backlog, semantics);
- if (sret < 0) {
- __sdp_log(8, "Error listen: failed with code <%d> SDP fd:<%d>\n",
- errno, shadow_fd);
- } else {
- __sdp_log(7, "LISTEN: fd:%d listening on SDP bound to:%s port:%d\n",
- fd, buf, actual_port);
- }
- }
-
- /* cleanup the un-needed shadow if TCP and did not fail */
- if ((target_family == USE_TCP) && (ret >= 0)) {
- __sdp_log(1, "LISTEN: cleaning up shadow SDP\n");
- if (cleanup_shadow(fd) < 0)
- __sdp_log(8, "Error listen: failed to cleanup shadow for fd:%d\n",
- fd);
- }
-
- /* cleanup the TCP socket and replace with SDP */
- if ((target_family == USE_SDP) && (sret >= 0)) {
- __sdp_log(1, "LISTEN: cleaning TCP socket and dup2 SDP into it\n");
- if (0 > (sret = replace_fd_with_its_shadow(fd)))
- __sdp_log(9, "Error listen: "
- "failed to dup2 shadow into orig fd:%d\n", fd);
- }
-
-done:
- __sdp_log(2, "LISTEN: <%s:%d:%d> result <%d>\n",
- program_invocation_short_name, fd, shadow_fd, ret);
- /* its a success only if both are ok */
- if (ret < 0)
- return (ret);
- if (sret < 0)
- return (sret);
- return 0;
-} /* listen */
-
-int listen(int fd, int backlog)
-{
- return __perform_listen(fd, backlog, SOCKET_SEMANTIC_DEFAULT);
-}
-
-#ifdef SOLARIS_BUILD
-int __xnet_listen(int fd, int backlog)
-{
- return __perform_listen(fd, backlog, SOCKET_SEMANTIC_XNET);
-}
-#endif
-
-/* ========================================================================= */
-/*..close -- replacement close call. */
-int close(int fd)
-{
- int shadow_fd;
- int ret;
-
- if (init_status == 0)
- __sdp_init();
-
- if (NULL == _socket_funcs.close) {
- __sdp_log(9, "Error close: no implementation for close found\n");
- return -1;
- }
-
- shadow_fd = get_shadow_fd_by_fd(fd);
-
- __sdp_log(2, "CLOSE: <%s:%d:%d>\n",
- program_invocation_short_name, fd, shadow_fd);
-
- if (shadow_fd != -1) {
- __sdp_log(1, "CLOSE: closing shadow fd:<%d>\n", shadow_fd);
- if (cleanup_shadow(fd) < 0)
- __sdp_log(8, "Error close: failed to cleanup shadow for fd:%d\n",
- fd);
- }
-
- init_extra_attribute(fd);
- ret = _socket_funcs.close(fd);
- __sdp_log(2, "CLOSE: <%s:%d:%d> result <%d>\n",
- program_invocation_short_name, fd, shadow_fd, ret);
- return ret;
-} /* close */
-
-/* ========================================================================= */
-/*..dup -- replacement dup call. */
-/* we duplicate the fd and its shadow if exists - ok if the main worked */
-int dup(int fd)
-{
- int newfd, new_shadow_fd = -1;
- int shadow_fd;
-
- if (init_status == 0)
- __sdp_init();
-
- if (NULL == _socket_funcs.dup) {
- __sdp_log(9, "Error dup: no implementation for dup found\n");
- return -1;
- }
-
- shadow_fd = get_shadow_fd_by_fd(fd);
-
- __sdp_log(2, "DUP: <%s:%d:%d>\n",
- program_invocation_short_name, fd, shadow_fd);
-
- __sdp_log(1, "DUP: duplication fd:<%d>\n", fd);
- newfd = _socket_funcs.dup(fd);
-
- if (newfd == fd)
- return (fd);
-
- if (!is_valid_fd(newfd)) {
- __sdp_log(8, "Error dup: new fd <%d> out of range.\n", newfd);
- } else {
- /* copy attributes from old fd */
- libsdp_fd_attributes[newfd] = libsdp_fd_attributes[fd];
- libsdp_fd_attributes[newfd].shadow_fd = -1;
-
- if (shadow_fd != -1) {
- __sdp_log(1, "DUP: duplication shadow fd:<%d>\n", shadow_fd);
- new_shadow_fd = _socket_funcs.dup(shadow_fd);
- if ((new_shadow_fd > max_file_descriptors) || (new_shadow_fd < 0)) {
- __sdp_log(8, "Error dup: new shadow fd <%d> out of range.\n",
- new_shadow_fd);
- } else {
- libsdp_fd_attributes[new_shadow_fd] =
- libsdp_fd_attributes[shadow_fd];
- libsdp_fd_attributes[newfd].shadow_fd = new_shadow_fd;
- }
- } /* shadow exists */
- }
-
- __sdp_log(2, "DUP: <%s:%d:%d> return <%d:%d>\n",
- program_invocation_short_name, fd, shadow_fd, newfd,
- new_shadow_fd);
-
- return newfd;
-} /* dup */
-
-/* ========================================================================= */
-/*..dup2 -- replacement dup2 call. */
-/* since only the main new fd is given we only move the shadow if exists */
-int dup2(int fd, int newfd)
-{
- int shadow_fd;
- int shadow_newfd;
- int new_shadow_fd = -1;
- int ret = 0;
-
- if (init_status == 0)
- __sdp_init();
-
- if (NULL == _socket_funcs.dup2) {
- __sdp_log(9, "Error dup2: no implementation for dup2 found\n");
- return -1;
- }
-
- shadow_fd = get_shadow_fd_by_fd(fd);
- shadow_newfd = get_shadow_fd_by_fd(newfd);
-
- __sdp_log(2, "DUP2: <%s:%d:%d>\n",
- program_invocation_short_name, fd, shadow_fd);
-
- if (newfd == fd) {
- __sdp_log(1, "DUP2: skip duplicating fd:<%d> into:<%d>\n", fd, newfd);
- goto done;
- }
-
- /* dup2 closes the target file desc if it is a valid fd */
- if (shadow_newfd != -1) {
- __sdp_log(1, "DUP2: closing newfd:<%d> shadow:<%d>\n", newfd,
- shadow_newfd);
- ret = _socket_funcs.close(shadow_newfd);
- if (ret != 0) {
- __sdp_log(8,
- "DUP2: fail to close newfd:<%d> shadow:<%d> with: %d %s\n",
- newfd, shadow_newfd, ret, strerror(errno));
- }
- }
-
- __sdp_log(1, "DUP2: duplicating fd:<%d> into:<%d>\n", fd, newfd);
- newfd = _socket_funcs.dup2(fd, newfd);
- if ((newfd > max_file_descriptors) || (newfd < 0)) {
- __sdp_log(8, "Error dup2: new fd <%d> out of range.\n", newfd);
- } else {
- /* copy attributes from old fd */
- libsdp_fd_attributes[fd].shadow_fd = -1;
- libsdp_fd_attributes[newfd] = libsdp_fd_attributes[fd];
-
- /* if it had a shadow create a new shadow */
- if (shadow_fd != -1) {
- __sdp_log(1, "DUP2: duplication shadow fd:<%d>\n", shadow_fd);
- new_shadow_fd = _socket_funcs.dup(shadow_fd);
- if ((new_shadow_fd > max_file_descriptors) || (new_shadow_fd < 0)) {
- __sdp_log(8, "Error dup2: new shadow fd <%d> out of range.\n",
- new_shadow_fd);
- } else {
- libsdp_fd_attributes[new_shadow_fd] =
- libsdp_fd_attributes[shadow_fd];
- libsdp_fd_attributes[newfd].shadow_fd = new_shadow_fd;
- }
- } /* newfd is ok */
- }
-
-done:
- __sdp_log(2, "DUP2: <%s:%d:%d> return <%d:%d>\n",
- program_invocation_short_name, fd, shadow_fd, newfd,
- new_shadow_fd);
-
- return newfd;
-} /* dup */
-
-/* ========================================================================= */
-/*..getsockname -- replacement getsocknanme call. */
-int getsockname(int fd, struct sockaddr *name, socklen_t * namelen)
-{
- int ret = 0;
- char buf[MAX_ADDR_STR_LEN];
-
- if (init_status == 0)
- __sdp_init();
-
- /*
- * ensure the SDP protocol family is not exposed to the user, since
- * this is meant to be a transparency layer.
- */
- if (NULL == _socket_funcs.getsockname) {
- __sdp_log(9,
- "Error getsockname: no implementation for getsockname found\n");
- return -1;
- }
-
- /* double check provided pointers */
- if ((name == NULL) || is_invalid_addr(name)) {
- errno = EFAULT;
- __sdp_log(8, "Error getsockname: illegal address provided\n");
- return -1;
- }
-
- if ((namelen != NULL) && is_invalid_addr(namelen)) {
- errno = EFAULT;
- __sdp_log(8, "Error getsockname: illegal address length pointer provided\n");
- return -1;
- }
-
- __sdp_log(2, "GETSOCKNAME <%s:%d>\n", program_invocation_short_name, fd);
-
- ret = _socket_funcs.getsockname(fd, name, namelen);
-
- if (__sdp_log_get_level() <= 1) {
- if (get_addr_str(name, buf, MAX_ADDR_STR_LEN)) {
- __sdp_log(1, "GETSOCKNAME: " "address is illegal\n");
- } else {
- __sdp_log(1, "GETSOCKNAME: address is:%s port:%d\n", buf,
- ntohs(((struct sockaddr_in *) name)->sin_port));
- }
- }
- __sdp_log(2, "GETSOCKNAME <%s:%d> result <%d>\n",
- program_invocation_short_name, fd, ret);
-
- return ret;
-} /* getsockname */
-
-/* ========================================================================= */
-/*..getpeername -- replacement getpeername call. */
-int getpeername(int fd, struct sockaddr *name, socklen_t * namelen)
-{
- int ret = 0;
-
- if (init_status == 0)
- __sdp_init();
-
- if (NULL == _socket_funcs.getpeername) {
- __sdp_log(9, "Error getpeername: "
- "no implementation for getpeername found\n");
- return -1;
- }
-
- /* double check provided pointers */
- if ((name == NULL) || is_invalid_addr(name)) {
- errno = EFAULT;
- __sdp_log(8, "Error getsockname: illegal address provided\n");
- return -1;
- }
-
- if ((namelen != NULL) && is_invalid_addr(namelen)) {
- errno = EFAULT;
- __sdp_log(8,
- "Error getsockname: illegal address length pointer provided\n");
- return -1;
- }
-
- __sdp_log(2, "GETPEERNAME <%s:%d>\n", program_invocation_short_name, fd);
-
- ret = _socket_funcs.getpeername(fd, name, namelen);
-
- __sdp_log(2, "GETPEERNAME <%s:%d> result <%d:%d> family=%d s_addr=%d\n",
- program_invocation_short_name, fd, ret,
- (!(0 > ret) ? 0 : -1), name->sa_family,
- ((struct sockaddr_in *) name)->sin_addr.s_addr);
-
- return ret;
-} /* getpeername */
-
-
-
-/* ========================================================================= */
-/*..accept -- replacement accept call. */
-/*
- If we have a shadow we need to decide which socket we want to accept on
- so we select first and then give priority based on previous selection
-*/
-int accept(int fd, struct sockaddr *addr, socklen_t * addrlen)
-{
- int shadow_fd;
- int ret = 0;
- fd_set fds;
- socklen_t saved_addrlen = 0;
- int fopts;
- char buf[MAX_ADDR_STR_LEN];
-
- if (init_status == 0)
- __sdp_init();
-
- shadow_fd = get_shadow_fd_by_fd(fd);
-
- /*
- * ensure the SDP protocol family is not exposed to the user, since
- * this is meant to be a transparency layer.
- */
- if (NULL == _socket_funcs.accept) {
- __sdp_log(9, "Error accept: no implementation for accept found\n");
- return -1;
- }
-
- /* double check provided pointers */
- if ((addr != NULL) && is_invalid_addr(addr)) {
- errno = EINVAL;
- __sdp_log(8, "Error accept: illegal address provided\n");
- return -1;
- }
-
- if ((addrlen != NULL) && is_invalid_addr(addrlen)) {
- errno = EINVAL;
- __sdp_log(8, "Error accept: illegal address length pointer provided\n");
- return -1;
- }
-
- if (addr && addrlen)
- saved_addrlen = *addrlen;
-
- __sdp_log(2, "ACCEPT: <%s:%d>\n", program_invocation_short_name, fd);
-
- if (shadow_fd == -1) {
- fopts = _socket_funcs.fcntl(fd, F_GETFL);
- __sdp_log(1, "ACCEPT: fd <%d> opts are <0x%x>\n", fd, fopts);
-
- __sdp_log(7, "ACCEPT: accepting on single fd:<%d>\n", fd);
- ret = _socket_funcs.accept(fd, addr, addrlen);
- if (ret < 0) {
- if (!(fopts & O_NONBLOCK && errno == EWOULDBLOCK))
- __sdp_log(8, "Error accept: accept returned :<%d> %s\n",
- ret, strerror(errno));
- } else {
- set_is_sdp_socket(ret, get_is_sdp_socket(fd));
- }
- } else {
-
- fopts = _socket_funcs.fcntl(shadow_fd, F_GETFL);
- __sdp_log(1, "ACCEPT: shadow_fd <%d> opts are <0x%x>\n",
- shadow_fd, fopts);
-
- /* we need different behavior for NONBLOCK or signal IO and BLOCK */
- if ((fopts > 0) && (fopts & (O_NONBLOCK | FASYNC))) {
- __sdp_log(1, "ACCEPT: accepting (nonblock) on SDP fd:<%d>\n", shadow_fd);
-
- ret = _socket_funcs.accept(shadow_fd, addr, addrlen);
- if (ret >= 0) {
- set_is_sdp_socket(ret, 1);
-
- __sdp_log(7, "ACCEPT: accepted (nonblock) SDP fd:<%d>\n",
- shadow_fd);
- } else {
- __sdp_log(1, "ACCEPT: accept on SDP fd:<%d> return:%d errno:%d\n",
- shadow_fd, ret, errno);
-
- __sdp_log(1, "ACCEPT: accepting (nonblock) on TCP fd:<%d>\n", fd);
- ret = _socket_funcs.accept(fd, addr, addrlen);
- if (ret >= 0) {
- __sdp_log(7, "ACCEPT: accepted (nonblock) TCP fd:<%d>\n",
- shadow_fd);
- } else {
- __sdp_log(1, "ACCEPT: accept on TCP fd:<%d> "
- "return:%d errno:%d\n", fd, ret, errno);
- }
- }
- } else {
- __sdp_log(1, "ACCEPT: selecting both fd:<%d> and shadow:<%d>\n",
- fd, shadow_fd);
- FD_ZERO(&fds);
- FD_SET(fd, &fds);
- FD_SET(shadow_fd, &fds);
- ret =
- _socket_funcs.select(1 + ((fd > shadow_fd) ? fd : shadow_fd),
- &fds, NULL, NULL, NULL);
- if (ret >= 0) {
- if (last_accept_was_tcp(fd) == 0) {
- if (FD_ISSET(fd, &fds)) {
- set_last_accept(fd, 1);
- __sdp_log(7, "ACCEPT: accepting on TCP fd:<%d>\n", fd);
- ret = _socket_funcs.accept(fd, addr, addrlen);
- } else {
- __sdp_log(7, "ACCEPT: accepting on SDP fd:<%d>\n",
- shadow_fd);
- ret = _socket_funcs.accept(shadow_fd, addr, addrlen);
- if (ret >= 0)
- set_is_sdp_socket(ret, 1);
- }
- } else {
- if (FD_ISSET(shadow_fd, &fds)) {
- set_last_accept(fd, 1);
- __sdp_log(7, "ACCEPT: accepting on SDP fd:<%d>\n",
- shadow_fd);
- ret = _socket_funcs.accept(shadow_fd, addr, addrlen);
- if (ret >= 0)
- set_is_sdp_socket(ret, 1);
- } else {
- __sdp_log(7, "ACCEPT: accepting on TCP fd:<%d>\n", fd);
- ret = _socket_funcs.accept(fd, addr, addrlen);
- }
- }
- } else {
- if (errno != EINTR) {
- __sdp_log(8,
- "Error accept: select returned :<%d> (%d) %s\n",
- ret, errno, strerror(errno));
- } else {
- __sdp_log(1, "ACCEPT: select returned :<%d> (%d) %s\n",
- ret, errno, strerror(errno));
- }
- }
- } /* blocking mode */
- } /* shadow fd */
-
- if ((__sdp_log_get_level() <= 1) && (ret >= 0) && addr && addrlen) {
- get_addr_str(addr, buf, *addrlen);
- __sdp_log(1, "ACCEPT: accepted from:%s port:%d into fd:%d\n",
- buf, ntohs(((struct sockaddr_in *) addr)->sin_port), ret);
- }
- __sdp_log(2, "ACCEPT: <%s:%d> return <%d>\n",
- program_invocation_short_name, fd, ret);
-
- return ret;
-} /* accept */
-
-/* ========================================================================= */
-/*..select -- replacement socket call. */
-/*
- if we have shadow we must select on it too - which requires a hack back
- and forth
-*/
-int
-select(int n,
- fd_set * readfds,
- fd_set * writefds, fd_set * exceptfds, struct timeval *timeout)
-{
- int shadow_fd;
- int ret;
- int current;
- int maxi = 0;
- fd_set new_fds;
-
- if (init_status == 0)
- __sdp_init();
-
- if (NULL == _socket_funcs.select) {
- __sdp_log(9, "Error select: no implementation for select found\n");
- return -1;
- }
-
- __sdp_log(2, "SELECT: <%s:%d>\n", program_invocation_short_name, n);
-
- /* if we do not read - nothing to do */
- if (readfds == NULL) {
- ret = _socket_funcs.select(n, readfds, writefds, exceptfds, timeout);
- goto done;
- }
-
- FD_ZERO(&new_fds);
- if (n > 0) {
- maxi = n - 1;
- }
-
- /* add shadow bits */
- for (current = 0; current < n; current++) {
- if (FD_ISSET(current, readfds)) {
- FD_SET(current, &new_fds);
- if (current > maxi) {
- maxi = current;
- }
- shadow_fd = get_shadow_fd_by_fd(current);
- if (shadow_fd != -1) {
- __sdp_log(1,
- "SELECT: adding fd:<%d> shadow_fd:<%d> to readfs\n",
- current, shadow_fd);
- FD_SET(shadow_fd, &new_fds);
- if (shadow_fd > maxi) {
- maxi = shadow_fd;
- }
- }
- }
- }
-
- __sdp_log(1, "SELECT: invoking select n=<%d>\n", 1 + maxi);
- ret = _socket_funcs.select(1 + maxi,
- &new_fds, writefds, exceptfds, timeout);
-
- /* remove the count and bits of the shadows */
- if (ret >= 0) {
- for (current = 0; current < n; current++) {
- shadow_fd = get_shadow_fd_by_fd(current);
- if (shadow_fd == -1) {
- if (FD_ISSET(current, readfds) &&
- FD_ISSET(current, &new_fds) == 0) {
- FD_CLR(current, readfds);
- }
- } else {
- if (FD_ISSET(current, readfds) && FD_ISSET(current, &new_fds)
- && FD_ISSET(shadow_fd, &new_fds)) {
- ret -= 1;
- }
- if (FD_ISSET(current, readfds) &&
- FD_ISSET(current, &new_fds) == 0 &&
- FD_ISSET(shadow_fd, &new_fds) == 0) {
- FD_CLR(current, readfds);
- }
- }
- }
- }
-
-done:
-
- __sdp_log(2, "SELECT: <%s:%d> return <%d>\n",
- program_invocation_short_name, n, ret);
- return ret;
-} /* select */
-
-/* ========================================================================= */
-/*..pselect -- replacement socket call. */
-/*
- if we have shadow we must pselect on it too - which requires a hack back
- and forth
-*/
-int
-pselect(int n,
- fd_set * readfds,
- fd_set * writefds,
- fd_set * exceptfds,
- const struct timespec *timeout, const sigset_t * sigmask)
-{
- int shadow_fd;
- int ret;
- int current;
- int maxi = 0;
- fd_set new_fds;
-
- if (init_status == 0)
- __sdp_init();
-
- if (NULL == _socket_funcs.pselect) {
- __sdp_log(9, "Error pselect: no implementation for pselect found\n");
- return -1;
- }
-
- __sdp_log(2, "PSELECT: <%s:%d>\n", program_invocation_short_name, n);
-
- /* if we do not read - nothing to do */
- if (readfds == NULL) {
- ret =
- _socket_funcs.pselect(n, readfds, writefds, exceptfds, timeout,
- sigmask);
- goto done;
- }
-
- FD_ZERO(&new_fds);
- if (n > 0) {
- maxi = n - 1;
- }
-
- /* add shadow bits */
- for (current = 0; current < n; current++) {
- if (FD_ISSET(current, readfds)) {
- FD_SET(current, &new_fds);
- if (current > maxi) {
- maxi = current;
- }
- shadow_fd = get_shadow_fd_by_fd(current);
- if (shadow_fd != -1) {
- __sdp_log(1,
- "PSELECT: adding fd:<%d> shadow_fd:<%d> to readfs\n",
- current, shadow_fd);
- FD_SET(shadow_fd, &new_fds);
- if (shadow_fd > maxi) {
- maxi = shadow_fd;
- }
- }
- }
- }
-
- __sdp_log(1, "PSELECT: invoking pselect n=<%d>\n", 1 + maxi);
- ret = _socket_funcs.pselect(1 + maxi,
- &new_fds, writefds, exceptfds,
- timeout, sigmask);
-
- /* remove the count and bits of the shadows */
- if (ret >= 0) {
- for (current = 0; current < n; current++) {
- shadow_fd = get_shadow_fd_by_fd(current);
- if (shadow_fd == -1) {
- if (FD_ISSET(current, readfds) &&
- FD_ISSET(current, &new_fds) == 0) {
- FD_CLR(current, readfds);
- }
- } else {
- if (FD_ISSET(current, readfds) && FD_ISSET(current, &new_fds)
- && FD_ISSET(shadow_fd, &new_fds)) {
- ret -= 1;
- }
- if (FD_ISSET(current, readfds) &&
- FD_ISSET(current, &new_fds) == 0 &&
- FD_ISSET(shadow_fd, &new_fds) == 0) {
- FD_CLR(current, readfds);
- }
- }
- }
- }
-
-done:
-
- __sdp_log(2, "PSELECT: <%s:%d> return <%d>\n",
- program_invocation_short_name, n, ret);
- return ret;
-} /* pselect */
-
-/* ========================================================================= */
-/*..poll -- replacement socket call. */
-/*
- if we have shadow we must poll on it too - which requires a hack back
- and forth
-*/
-int poll(struct pollfd *ufds, nfds_t nfds, int timeout)
-{
- int ret;
- int shadow_fd;
- int current;
- int extra = 0;
- struct pollfd *poll_fds = NULL;
- struct pollfd *poll_fd_ptr = NULL;
-
- if (init_status == 0)
- __sdp_init();
-
- if (NULL == _socket_funcs.poll) {
- __sdp_log(9, "Error poll: no implementation for poll found\n");
- return -1;
- }
-
- __sdp_log(2, "POLL: <%s:%d>\n", program_invocation_short_name, nfds);
-
- /* if we do not have any file desc - nothing to do */
- if (ufds == NULL) {
- ret = _socket_funcs.poll(ufds, nfds, timeout);
- goto done;
- }
-
- /* scan for how many extra fds are required */
- for (current = 0; current < nfds; current++) {
- shadow_fd = get_shadow_fd_by_fd(ufds[current].fd);
- if (shadow_fd != -1)
- extra++;
- }
-
- if (!extra) {
- poll_fds = ufds;
- } else {
- poll_fds =
- (struct pollfd *) malloc((nfds + extra) * sizeof(struct pollfd));
- if (!poll_fds) {
- __sdp_log(9,
- "Error poll: malloc of extended pollfd array failed\n");
- ret = -1;
- errno = ENOMEM;
- goto done;
- }
- poll_fd_ptr = poll_fds;
- for (current = 0; current < nfds; current++) {
- *poll_fd_ptr = ufds[current];
- poll_fd_ptr++;
- shadow_fd = get_shadow_fd_by_fd(ufds[current].fd);
- if (shadow_fd != -1) {
- __sdp_log(1, "POLL: adding fd:<%d> shadow_fd:<%d> to readfs\n",
- current, shadow_fd);
- *poll_fd_ptr = ufds[current];
- poll_fd_ptr->fd = shadow_fd;
- poll_fd_ptr++;
- }
- }
- }
-
- __sdp_log(1, "POLL: invoking poll nfds=<%d>\n", nfds + extra);
- ret = _socket_funcs.poll(poll_fds, nfds + extra, timeout);
-
- /* refactor into original list if any events */
- if ((ret > 0) && extra) {
- poll_fd_ptr = poll_fds;
- for (current = 0; current < nfds; current++) {
- shadow_fd = get_shadow_fd_by_fd(ufds[current].fd);
- if (shadow_fd == -1) {
- ufds[current] = *poll_fd_ptr;
- } else {
- ufds[current] = *poll_fd_ptr;
- poll_fd_ptr++;
- if (poll_fd_ptr->revents) {
- if (ufds[current].revents)
- ret--;
- ufds[current].revents |= poll_fd_ptr->revents;
- }
- }
- poll_fd_ptr++;
- }
- }
-
- if (extra)
- free(poll_fds);
-done:
-
- __sdp_log(2, "POLL: <%s:%d> return <%d>\n",
- program_invocation_short_name, nfds, ret);
- return ret;
-} /* poll */
-
-#ifdef __linux__
-/* ========================================================================= */
-/*..epoll_create -- replacement socket call. */
-/*
- Need to make the size twice as large for shadow fds
-*/
-int epoll_create(int size)
-{
- int epfd;
-
- if (init_status == 0)
- __sdp_init();
-
- if (NULL == _socket_funcs.epoll_create) {
- __sdp_log(9,
- "Error epoll_create: no implementation for epoll_create found\n");
- return -1;
- }
-
- __sdp_log(2, "EPOLL_CREATE: <%s:%d>\n", program_invocation_short_name,
- size);
-
- epfd = _socket_funcs.epoll_create(size * 2);
-
- __sdp_log(2, "EPOLL_CREATE: <%s:%d> return %d\n",
- program_invocation_short_name, size, epfd);
- return epfd;
-} /* epoll_create */
-
-/* ========================================================================= */
-/*..epoll_ctl -- replacement socket call. */
-/*
- Need to add/delete/modify shadow fds as well
-*/
-int epoll_ctl(int epfd, int op, int fd, struct epoll_event *event)
-{
- int ret, shadow_fd, ret2;
-
- if (init_status == 0)
- __sdp_init();
-
- if (NULL == _socket_funcs.epoll_ctl) {
- __sdp_log(9,
- "Error epoll_ctl: no implementation for epoll_ctl found\n");
- return -1;
- }
-
- __sdp_log(2, "EPOLL_CTL: <%s:%d> op <%d:%d>\n",
- program_invocation_short_name, epfd, op, fd);
-
- ret = _socket_funcs.epoll_ctl(epfd, op, fd, event);
-
- shadow_fd = get_shadow_fd_by_fd(fd);
- if (shadow_fd != -1) {
- ret2 = _socket_funcs.epoll_ctl(epfd, op, shadow_fd, event);
- if (ret2 < 0) {
- __sdp_log(8, "Error epoll_ctl <%s:%d:%d>",
- program_invocation_short_name, fd, shadow_fd);
- return ret2;
- }
- }
-
- __sdp_log(2, "EPOLL_CTL: <%s:%d> return <%d>\n",
- program_invocation_short_name, epfd, ret);
- return ret;
-} /* epoll_ctl */
-
-/* ========================================================================= */
-/*..epoll_wait -- replacement socket call. */
-/*
- We don't care who generated the event because all we get is user-context
- values.
-*/
-int epoll_wait(int epfd, struct epoll_event *events, int maxevents, int timeout)
-{
- int ret;
-
- if (init_status == 0)
- __sdp_init();
-
- if (NULL == _socket_funcs.epoll_wait) {
- __sdp_log(9,
- "Error epoll_wait: no implementation for epoll_wait found\n");
- return -1;
- }
-
- __sdp_log(2, "EPOLL_WAIT: <%s:%d>\n", program_invocation_short_name, epfd);
-
- ret = _socket_funcs.epoll_wait(epfd, events, maxevents, timeout);
-
- __sdp_log(2, "EPOLL_WAIT: <%s:%d> return <%d>\n",
- program_invocation_short_name, epfd, ret);
- return ret;
-} /* epoll_wait */
-
-/* ========================================================================= */
-/*..epoll_pwait -- replacement socket call. */
-/*
- We don't care who generated the event because all we get is user-context
- values.
-*/
-int
-epoll_pwait(int epfd,
- struct epoll_event *events,
- int maxevents, int timeout, const sigset_t * sigmask)
-{
- int ret;
-
- if (init_status == 0)
- __sdp_init();
-
- if (NULL == _socket_funcs.epoll_pwait) {
- __sdp_log(9,
- "Error epoll_pwait: no implementation for epoll_pwait found\n");
- return -1;
- }
-
- __sdp_log(2, "EPOLL_PWAIT: <%s:%d>\n", program_invocation_short_name, epfd);
-
- ret = _socket_funcs.epoll_pwait(epfd, events, maxevents, timeout, sigmask);
-
- __sdp_log(2, "EPOLL_PWAIT: <%s:%d> return <%d>\n",
- program_invocation_short_name, epfd, ret);
- return ret;
-} /* epoll_pwait */
-#endif
-
-/* ========================================================================= */
-
-/* --------------------------------------------------------------------- */
-/* */
-/* Library load/unload initialization/cleanup */
-/* */
-/* --------------------------------------------------------------------- */
-/* ========================================================================= */
-/*..__sdp_init -- intialize the library */
-void __sdp_init(void)
-{
- char *config_file, *error_str;
- int fd;
- struct rlimit nofiles_limit;
-
- /* HACK: races might apply here: can we assume init is happening
- only within one thread ? */
- if (init_status != 0)
- return;
- init_status = 1;
-
- dev_null_fd = open("/dev/null", O_WRONLY);
-
- /* figure out the max number of file descriptors */
- if (getrlimit(RLIMIT_NOFILE, &nofiles_limit))
- max_file_descriptors = 1024;
- else
- max_file_descriptors = nofiles_limit.rlim_cur;
-
- /* allocate and initialize the shadow sdp sockets array */
- libsdp_fd_attributes =
- (struct sdp_extra_fd_attributes *) calloc(max_file_descriptors,
- sizeof(struct
- sdp_extra_fd_attributes));
- for (fd = 0; fd < max_file_descriptors; fd++)
- init_extra_attribute(fd);
-
-#ifndef RTLD_NEXT
- /*
- * open libc for original socket call.
- * Solaris relies on RTLD next - since the socket calls are
- * actually in libsocket rather than libc.
- */
- __libc_dl_handle = dlopen("/lib64/libc.so.6", RTLD_LAZY);
- if (NULL == __libc_dl_handle) {
- __libc_dl_handle = dlopen("/lib/libc.so.6", RTLD_LAZY);
- if (NULL == __libc_dl_handle) {
- fprintf(stderr, "%s\n", dlerror());
- return;
- }
- }
-#endif
-
- /*
- * Get the original functions
- */
- _socket_funcs.ioctl = dlsym(__libc_dl_handle, "ioctl");
- if (NULL != (error_str = dlerror())) {
- fprintf(stderr, "%s\n", error_str);
- }
-
- _socket_funcs.fcntl = dlsym(__libc_dl_handle, "fcntl");
- if (NULL != (error_str = dlerror())) {
- fprintf(stderr, "%s\n", error_str);
- }
-
- _socket_funcs.socket = dlsym(__libc_dl_handle, "socket");
- if (NULL != (error_str = dlerror())) {
- fprintf(stderr, "%s\n", error_str);
- }
-
- _socket_funcs.setsockopt = dlsym(__libc_dl_handle, "setsockopt");
- if (NULL != (error_str = dlerror())) {
- fprintf(stderr, "%s\n", error_str);
- }
-
- _socket_funcs.connect = dlsym(__libc_dl_handle, "connect");
- if (NULL != (error_str = dlerror())) {
- fprintf(stderr, "%s\n", error_str);
- }
-
- _socket_funcs.listen = dlsym(__libc_dl_handle, "listen");
- if (NULL != (error_str = dlerror())) {
- fprintf(stderr, "%s\n", error_str);
- }
-
- _socket_funcs.bind = dlsym(__libc_dl_handle, "bind");
- if (NULL != (error_str = dlerror())) {
- fprintf(stderr, "%s\n", error_str);
- }
-
- _socket_funcs.close = dlsym(__libc_dl_handle, "close");
- if (NULL != (error_str = dlerror())) {
- fprintf(stderr, "%s\n", error_str);
- }
-
- _socket_funcs.dup = dlsym(__libc_dl_handle, "dup");
- if (NULL != (error_str = dlerror())) {
- fprintf(stderr, "%s\n", error_str);
- }
-
- _socket_funcs.dup2 = dlsym(__libc_dl_handle, "dup2");
- if (NULL != (error_str = dlerror())) {
- fprintf(stderr, "%s\n", error_str);
- }
-
- _socket_funcs.getpeername = dlsym(__libc_dl_handle, "getpeername");
- if (NULL != (error_str = dlerror())) {
- fprintf(stderr, "%s\n", error_str);
- }
-
- _socket_funcs.getsockname = dlsym(__libc_dl_handle, "getsockname");
- if (NULL != (error_str = dlerror())) {
- fprintf(stderr, "%s\n", error_str);
- }
-
- _socket_funcs.accept = dlsym(__libc_dl_handle, "accept");
- if (NULL != (error_str = dlerror())) {
- fprintf(stderr, "%s\n", error_str);
- }
-
- _socket_funcs.select = dlsym(__libc_dl_handle, "select");
- if (NULL != (error_str = dlerror())) {
- fprintf(stderr, "%s\n", error_str);
- }
-
- _socket_funcs.pselect = dlsym(__libc_dl_handle, "pselect");
- if (NULL != (error_str = dlerror())) {
- fprintf(stderr, "%s\n", error_str);
- }
-
- _socket_funcs.poll = dlsym(__libc_dl_handle, "poll");
- if (NULL != (error_str = dlerror())) {
- fprintf(stderr, "%s\n", error_str);
- }
-
-#ifdef __linux__
- _socket_funcs.epoll_create = dlsym(__libc_dl_handle, "epoll_create");
- if (NULL != (error_str = dlerror())) {
- fprintf(stderr, "%s\n", error_str);
- }
-
- _socket_funcs.epoll_ctl = dlsym(__libc_dl_handle, "epoll_ctl");
- if (NULL != (error_str = dlerror())) {
- fprintf(stderr, "%s\n", error_str);
- }
-
- _socket_funcs.epoll_wait = dlsym(__libc_dl_handle, "epoll_wait");
- if (NULL != (error_str = dlerror())) {
- fprintf(stderr, "%s\n", error_str);
- }
-
- _socket_funcs.epoll_pwait = dlsym(__libc_dl_handle, "epoll_pwait");
- if (NULL != (error_str = dlerror())) {
- fprintf(stderr, "%s\n", error_str);
- }
-#endif
-#ifdef SOLARIS_BUILD
- _socket_xnet_funcs.socket = dlsym(__libc_dl_handle, "__xnet_socket");
- if (NULL != (error_str = dlerror())) {
- fprintf(stderr, "%s\n", error_str);
- }
-
- _socket_xnet_funcs.connect = dlsym(__libc_dl_handle, "__xnet_connect");
- if (NULL != (error_str = dlerror())) {
- fprintf(stderr, "%s\n", error_str);
- }
-
- _socket_xnet_funcs.listen = dlsym(__libc_dl_handle, "__xnet_listen");
- if (NULL != (error_str = dlerror())) {
- fprintf(stderr, "%s\n", error_str);
- }
-
- _socket_xnet_funcs.bind = dlsym(__libc_dl_handle, "__xnet_bind");
- if (NULL != (error_str = dlerror())) {
- fprintf(stderr, "%s\n", error_str);
- }
-
- /* Determine program name by asking libdl */
- Dl_argsinfo args_info;
- if (NULL != dlinfo(RTLD_SELF, RTLD_DI_ARGSINFO, &args_info)) {
- fprintf(stderr, "args_info: %s\n", dlerror());
- } else {
- program_invocation_name = args_info.dla_argv[0];
- program_invocation_short_name = basename(args_info.dla_argv[0]);
- }
-#endif
-#ifdef __FreeBSD__
- program_invocation_short_name = (char *)getprogname();
- program_invocation_name = program_invocation_short_name;
-#endif
-
- if (getenv("SIMPLE_LIBSDP") != NULL) {
- simple_sdp_library = 1;
- }
-
- if (getenv("ALWAYS_USE_SDP") != NULL) {
- simple_sdp_library = 1;
- }
-#define LIBSDP_DEFAULT_CONFIG_FILE SYSCONFDIR "/libsdp.conf"
- if (!simple_sdp_library) {
- config_file = getenv("LIBSDP_CONFIG_FILE");
- if (!config_file)
- config_file = LIBSDP_DEFAULT_CONFIG_FILE;
-
- if (__sdp_parse_config(config_file)) {
- fprintf(stderr,
- "libsdp Error: failed to parse config file:%s. Using defaults.\n",
- config_file);
- }
- }
-
- __sdp_log(1, "Max file descriptors:%d\n", max_file_descriptors);
- init_status = 2;
-
-} /* __sdp_init */
-
-/* ========================================================================= */
-/*..__sdp_fini -- when the library is unloaded this is called */
-void __sdp_fini(void)
-{
- struct use_family_rule *rule;
- for (rule = __sdp_clients_family_rules_head; rule != NULL;
- rule = rule->next)
- free(rule->prog_name_expr);
- for (rule = __sdp_servers_family_rules_head; rule != NULL;
- rule = rule->next)
- free(rule->prog_name_expr);
-
- free(libsdp_fd_attributes);
-
-#ifndef RTLD_NEXT
- dlclose(__libc_dl_handle);
-#endif
-} /* _fini */
diff --git a/contrib/ofed/libsdp/src/socket.c b/contrib/ofed/libsdp/src/socket.c
deleted file mode 100644
index d40265b..0000000
--- a/contrib/ofed/libsdp/src/socket.c
+++ /dev/null
@@ -1,167 +0,0 @@
-/*
- This software is available to you under a choice of one of two
- licenses. You may choose to be licensed under the terms of the GNU
- General Public License (GPL) Version 2, available at
- <http://www.fsf.org/copyleft/gpl.html>, or the OpenIB.org BSD
- license, available in the LICENSE.TXT file accompanying this
- software. These details are also available at
- <http://openib.org/license.html>.
-
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- SOFTWARE.
-
- Copyright (c) 2004 Topspin Communications. All rights reserved.
- Copyright (c) 2005 Mellanox Technologies Ltd. All rights reserved.
-
- $Id$
-*/
-
-/*
- * system includes
- */
-#if HAVE_CONFIG_H
-# include <config.h>
-#endif /* HAVE_CONFIG_H */
-
-/*
- For non-i386 systems, we pass socket() through to library code using
- dlsym() instead of trying to make the system call directly. This
- may cause problems if this library is LD_PRELOADed before the real C
- library is available. Eventually we may want to add the same type
- of system call assembly code as i386 has for IA64 and AMD64, but for
- now....
-*/
-#ifndef i386
-#define _GNU_SOURCE /* Get RTLD_NEXT */
-#include <dlfcn.h>
-#else
-#include <sys/syscall.h>
-#endif
-
-#include <errno.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <sys/socket.h>
-#include <string.h>
-/*
- * SDP specific includes
- */
-#include "linux/sdp_inet.h"
-
-#if 0
-#define _SDP_VERBOSE_PRELOAD
-#endif
-
-#define SOCKOP_socket 1
-#define SOCKOP_bind 2
-#define SOCKOP_connect 3
-#define SOCKOP_listen 4
-#define SOCKOP_accept 5
-#define SOCKOP_getsockname 6
-#define SOCKOP_getpeername 7
-#define SOCKOP_socketpair 8
-#define SOCKOP_send 9
-#define SOCKOP_recv 10
-#define SOCKOP_sendto 11
-#define SOCKOP_recvfrom 12
-#define SOCKOP_shutdown 13
-#define SOCKOP_setsockopt 14
-#define SOCKOP_getsockopt 15
-#define SOCKOP_sendmsg 16
-#define SOCKOP_recvmsg 17
-
-extern char * program_invocation_name;
-extern char * program_invocation_short_name;
-extern char ** const environ;
-
-/* ========================================================================= */
-/*..socket -- replacment socket call. */
-int socket
-(
- int domain,
- int type,
- int protocol
-)
-{
-#ifdef i386
- long __ret;
- void *__scratch;
- int call[3];
-#endif
- char *test;
- char *inet;
- char **tenviron;
-
-#ifdef _SDP_VERBOSE_PRELOAD
- FILE *fd;
-#endif
- /*
- * check for magic enviroment variable
- */
- if ((AF_INET == domain || AF_INET6 == domain) &&
- SOCK_STREAM == type) {
-
- if (environ) {
- tenviron = environ;
- for (test = *tenviron; NULL != test; test = *++tenviron) {
-
- inet = AF_INET_STR;
-
- while (*inet == *test && '\0' != *inet) {
-
- inet++;
- test++;
- } /* while */
-
- if ('\0' == *inet && '=' == *test) {
-
- domain = AF_INET_SDP;
- break;
- } /* if */
- } /* for */
- } /* if */
- } /* if */
-
-#ifdef _SDP_VERBOSE_PRELOAD
- fd = fopen("/tmp/libsdp.log.txt", "a+");
-
- fprintf(fd, "SOCKET: <%s> domain <%d> type <%d> protocol <%d>\n",
- program_invocation_short_name, domain, type, protocol);
-
- fclose(fd);
-#endif
-
-#ifdef i386
- /* Make the socket() system call directly, as described above */
- call[0] = domain;
- call[1] = type;
- call[2] = protocol;
-
- __asm__ __volatile__("movl %%ebx, %1\n" /* save %ebx */
- "movl %3, %%ebx\n" /* put sockopt in %ebx as arg */
- "int $0x80\n" /* do syscall */
- "movl %1, %%ebx\n" /* restore %ebx */
- : "=a" (__ret), "=r" (__scratch)
- : "0" (__NR_socketcall),
- "g" (SOCKOP_socket),
- "c" (call));
- return __ret;
-#else /* i386 */
- /* Use the standard library socket() to pass through the call */
- {
- static int (*orig_socket)(int, int, int);
-
- if (!orig_socket) {
- orig_socket = dlsym(RTLD_NEXT, "socket");
- }
-
- return orig_socket(domain, type, protocol);
- }
-#endif /* i386 */
-} /* socket */
diff --git a/contrib/ofed/management/AUTHORS b/contrib/ofed/management/AUTHORS
deleted file mode 100644
index d09c13f..0000000
--- a/contrib/ofed/management/AUTHORS
+++ /dev/null
@@ -1,3 +0,0 @@
-Shahar Frank <shahar@voltaire.com>
-Hal Rosenstock <halr@voltaire.com>
-Sasha Khapyorsky <sashak@voltaire.com>
diff --git a/contrib/ofed/management/COPYING b/contrib/ofed/management/COPYING
deleted file mode 100644
index 1b1ca1d..0000000
--- a/contrib/ofed/management/COPYING
+++ /dev/null
@@ -1,384 +0,0 @@
-This software with the exception of OpenSM is available to you
-under a choice of one of two licenses. You may chose to be
-licensed under the terms of the the OpenIB.org BSD license or
-the GNU General Public License (GPL) Version 2, both included
-below.
-
-OpenSM is licensed under either GNU General Public License (GPL)
-Version 2, or Intel BSD + Patent license. See OpenSM for the
-specific language for the latter licensing terms.
-
-
-Copyright (c) 2004-2008 Voltaire, Inc. All rights reserved.
-
-==================================================================
-
- OpenIB.org BSD license
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions
-are met:
-
- * Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
-
- * Redistributions in binary form must reproduce the above
- copyright notice, this list of conditions and the following
- disclaimer in the documentation and/or other materials provided
- with the distribution.
-
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
-FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
-COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
-INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
-BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
-LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
-CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
-ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-POSSIBILITY OF SUCH DAMAGE.
-
-==================================================================
-
- GNU GENERAL PUBLIC LICENSE
- Version 2, June 1991
-
- Copyright (C) 1989, 1991 Free Software Foundation, Inc.
- 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- Everyone is permitted to copy and distribute verbatim copies
- of this license document, but changing it is not allowed.
-
- Preamble
-
- The licenses for most software are designed to take away your
-freedom to share and change it. By contrast, the GNU General Public
-License is intended to guarantee your freedom to share and change free
-software--to make sure the software is free for all its users. This
-General Public License applies to most of the Free Software
-Foundation's software and to any other program whose authors commit to
-using it. (Some other Free Software Foundation software is covered by
-the GNU Library General Public License instead.) You can apply it to
-your programs, too.
-
- When we speak of free software, we are referring to freedom, not
-price. Our General Public Licenses are designed to make sure that you
-have the freedom to distribute copies of free software (and charge for
-this service if you wish), that you receive source code or can get it
-if you want it, that you can change the software or use pieces of it
-in new free programs; and that you know you can do these things.
-
- To protect your rights, we need to make restrictions that forbid
-anyone to deny you these rights or to ask you to surrender the rights.
-These restrictions translate to certain responsibilities for you if you
-distribute copies of the software, or if you modify it.
-
- For example, if you distribute copies of such a program, whether
-gratis or for a fee, you must give the recipients all the rights that
-you have. You must make sure that they, too, receive or can get the
-source code. And you must show them these terms so they know their
-rights.
-
- We protect your rights with two steps: (1) copyright the software, and
-(2) offer you this license which gives you legal permission to copy,
-distribute and/or modify the software.
-
- Also, for each author's protection and ours, we want to make certain
-that everyone understands that there is no warranty for this free
-software. If the software is modified by someone else and passed on, we
-want its recipients to know that what they have is not the original, so
-that any problems introduced by others will not reflect on the original
-authors' reputations.
-
- Finally, any free program is threatened constantly by software
-patents. We wish to avoid the danger that redistributors of a free
-program will individually obtain patent licenses, in effect making the
-program proprietary. To prevent this, we have made it clear that any
-patent must be licensed for everyone's free use or not licensed at all.
-
- The precise terms and conditions for copying, distribution and
-modification follow.
-
- GNU GENERAL PUBLIC LICENSE
- TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
-
- 0. This License applies to any program or other work which contains
-a notice placed by the copyright holder saying it may be distributed
-under the terms of this General Public License. The "Program", below,
-refers to any such program or work, and a "work based on the Program"
-means either the Program or any derivative work under copyright law:
-that is to say, a work containing the Program or a portion of it,
-either verbatim or with modifications and/or translated into another
-language. (Hereinafter, translation is included without limitation in
-the term "modification".) Each licensee is addressed as "you".
-
-Activities other than copying, distribution and modification are not
-covered by this License; they are outside its scope. The act of
-running the Program is not restricted, and the output from the Program
-is covered only if its contents constitute a work based on the
-Program (independent of having been made by running the Program).
-Whether that is true depends on what the Program does.
-
- 1. You may copy and distribute verbatim copies of the Program's
-source code as you receive it, in any medium, provided that you
-conspicuously and appropriately publish on each copy an appropriate
-copyright notice and disclaimer of warranty; keep intact all the
-notices that refer to this License and to the absence of any warranty;
-and give any other recipients of the Program a copy of this License
-along with the Program.
-
-You may charge a fee for the physical act of transferring a copy, and
-you may at your option offer warranty protection in exchange for a fee.
-
- 2. You may modify your copy or copies of the Program or any portion
-of it, thus forming a work based on the Program, and copy and
-distribute such modifications or work under the terms of Section 1
-above, provided that you also meet all of these conditions:
-
- a) You must cause the modified files to carry prominent notices
- stating that you changed the files and the date of any change.
-
- b) You must cause any work that you distribute or publish, that in
- whole or in part contains or is derived from the Program or any
- part thereof, to be licensed as a whole at no charge to all third
- parties under the terms of this License.
-
- c) If the modified program normally reads commands interactively
- when run, you must cause it, when started running for such
- interactive use in the most ordinary way, to print or display an
- announcement including an appropriate copyright notice and a
- notice that there is no warranty (or else, saying that you provide
- a warranty) and that users may redistribute the program under
- these conditions, and telling the user how to view a copy of this
- License. (Exception: if the Program itself is interactive but
- does not normally print such an announcement, your work based on
- the Program is not required to print an announcement.)
-
-These requirements apply to the modified work as a whole. If
-identifiable sections of that work are not derived from the Program,
-and can be reasonably considered independent and separate works in
-themselves, then this License, and its terms, do not apply to those
-sections when you distribute them as separate works. But when you
-distribute the same sections as part of a whole which is a work based
-on the Program, the distribution of the whole must be on the terms of
-this License, whose permissions for other licensees extend to the
-entire whole, and thus to each and every part regardless of who wrote it.
-
-Thus, it is not the intent of this section to claim rights or contest
-your rights to work written entirely by you; rather, the intent is to
-exercise the right to control the distribution of derivative or
-collective works based on the Program.
-
-In addition, mere aggregation of another work not based on the Program
-with the Program (or with a work based on the Program) on a volume of
-a storage or distribution medium does not bring the other work under
-the scope of this License.
-
- 3. You may copy and distribute the Program (or a work based on it,
-under Section 2) in object code or executable form under the terms of
-Sections 1 and 2 above provided that you also do one of the following:
-
- a) Accompany it with the complete corresponding machine-readable
- source code, which must be distributed under the terms of Sections
- 1 and 2 above on a medium customarily used for software interchange; or,
-
- b) Accompany it with a written offer, valid for at least three
- years, to give any third party, for a charge no more than your
- cost of physically performing source distribution, a complete
- machine-readable copy of the corresponding source code, to be
- distributed under the terms of Sections 1 and 2 above on a medium
- customarily used for software interchange; or,
-
- c) Accompany it with the information you received as to the offer
- to distribute corresponding source code. (This alternative is
- allowed only for noncommercial distribution and only if you
- received the program in object code or executable form with such
- an offer, in accord with Subsection b above.)
-
-The source code for a work means the preferred form of the work for
-making modifications to it. For an executable work, complete source
-code means all the source code for all modules it contains, plus any
-associated interface definition files, plus the scripts used to
-control compilation and installation of the executable. However, as a
-special exception, the source code distributed need not include
-anything that is normally distributed (in either source or binary
-form) with the major components (compiler, kernel, and so on) of the
-operating system on which the executable runs, unless that component
-itself accompanies the executable.
-
-If distribution of executable or object code is made by offering
-access to copy from a designated place, then offering equivalent
-access to copy the source code from the same place counts as
-distribution of the source code, even though third parties are not
-compelled to copy the source along with the object code.
-
- 4. You may not copy, modify, sublicense, or distribute the Program
-except as expressly provided under this License. Any attempt
-otherwise to copy, modify, sublicense or distribute the Program is
-void, and will automatically terminate your rights under this License.
-However, parties who have received copies, or rights, from you under
-this License will not have their licenses terminated so long as such
-parties remain in full compliance.
-
- 5. You are not required to accept this License, since you have not
-signed it. However, nothing else grants you permission to modify or
-distribute the Program or its derivative works. These actions are
-prohibited by law if you do not accept this License. Therefore, by
-modifying or distributing the Program (or any work based on the
-Program), you indicate your acceptance of this License to do so, and
-all its terms and conditions for copying, distributing or modifying
-the Program or works based on it.
-
- 6. Each time you redistribute the Program (or any work based on the
-Program), the recipient automatically receives a license from the
-original licensor to copy, distribute or modify the Program subject to
-these terms and conditions. You may not impose any further
-restrictions on the recipients' exercise of the rights granted herein.
-You are not responsible for enforcing compliance by third parties to
-this License.
-
- 7. If, as a consequence of a court judgment or allegation of patent
-infringement or for any other reason (not limited to patent issues),
-conditions are imposed on you (whether by court order, agreement or
-otherwise) that contradict the conditions of this License, they do not
-excuse you from the conditions of this License. If you cannot
-distribute so as to satisfy simultaneously your obligations under this
-License and any other pertinent obligations, then as a consequence you
-may not distribute the Program at all. For example, if a patent
-license would not permit royalty-free redistribution of the Program by
-all those who receive copies directly or indirectly through you, then
-the only way you could satisfy both it and this License would be to
-refrain entirely from distribution of the Program.
-
-If any portion of this section is held invalid or unenforceable under
-any particular circumstance, the balance of the section is intended to
-apply and the section as a whole is intended to apply in other
-circumstances.
-
-It is not the purpose of this section to induce you to infringe any
-patents or other property right claims or to contest validity of any
-such claims; this section has the sole purpose of protecting the
-integrity of the free software distribution system, which is
-implemented by public license practices. Many people have made
-generous contributions to the wide range of software distributed
-through that system in reliance on consistent application of that
-system; it is up to the author/donor to decide if he or she is willing
-to distribute software through any other system and a licensee cannot
-impose that choice.
-
-This section is intended to make thoroughly clear what is believed to
-be a consequence of the rest of this License.
-
- 8. If the distribution and/or use of the Program is restricted in
-certain countries either by patents or by copyrighted interfaces, the
-original copyright holder who places the Program under this License
-may add an explicit geographical distribution limitation excluding
-those countries, so that distribution is permitted only in or among
-countries not thus excluded. In such case, this License incorporates
-the limitation as if written in the body of this License.
-
- 9. The Free Software Foundation may publish revised and/or new versions
-of the General Public License from time to time. Such new versions will
-be similar in spirit to the present version, but may differ in detail to
-address new problems or concerns.
-
-Each version is given a distinguishing version number. If the Program
-specifies a version number of this License which applies to it and "any
-later version", you have the option of following the terms and conditions
-either of that version or of any later version published by the Free
-Software Foundation. If the Program does not specify a version number of
-this License, you may choose any version ever published by the Free Software
-Foundation.
-
- 10. If you wish to incorporate parts of the Program into other free
-programs whose distribution conditions are different, write to the author
-to ask for permission. For software which is copyrighted by the Free
-Software Foundation, write to the Free Software Foundation; we sometimes
-make exceptions for this. Our decision will be guided by the two goals
-of preserving the free status of all derivatives of our free software and
-of promoting the sharing and reuse of software generally.
-
- NO WARRANTY
-
- 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
-FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
-OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
-PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
-OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
-MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
-TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
-PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
-REPAIR OR CORRECTION.
-
- 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
-WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
-REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
-INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
-OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
-TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
-YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
-PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
-POSSIBILITY OF SUCH DAMAGES.
-
- END OF TERMS AND CONDITIONS
-
- How to Apply These Terms to Your New Programs
-
- If you develop a new program, and you want it to be of the greatest
-possible use to the public, the best way to achieve this is to make it
-free software which everyone can redistribute and change under these terms.
-
- To do so, attach the following notices to the program. It is safest
-to attach them to the start of each source file to most effectively
-convey the exclusion of warranty; and each file should have at least
-the "copyright" line and a pointer to where the full notice is found.
-
- <one line to give the program's name and a brief idea of what it does.>
- Copyright (C) <year> <name of author>
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program 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 this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-
-Also add information on how to contact you by electronic and paper mail.
-
-If the program is interactive, make it output a short notice like this
-when it starts in an interactive mode:
-
- Gnomovision version 69, Copyright (C) year name of author
- Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
- This is free software, and you are welcome to redistribute it
- under certain conditions; type `show c' for details.
-
-The hypothetical commands `show w' and `show c' should show the appropriate
-parts of the General Public License. Of course, the commands you use may
-be called something other than `show w' and `show c'; they could even be
-mouse-clicks or menu items--whatever suits your program.
-
-You should also get your employer (if you work as a programmer) or your
-school, if any, to sign a "copyright disclaimer" for the program, if
-necessary. Here is a sample; alter the names:
-
- Yoyodyne, Inc., hereby disclaims all copyright interest in the program
- `Gnomovision' (which makes passes at compilers) written by James Hacker.
-
- <signature of Ty Coon>, 1 April 1989
- Ty Coon, President of Vice
-
-This General Public License does not permit incorporating your program into
-proprietary programs. If your program is a subroutine library, you may
-consider it more useful to permit linking proprietary applications with the
-library. If this is what you want to do, use the GNU Library General
-Public License instead of this License.
diff --git a/contrib/ofed/management/ChangeLog b/contrib/ofed/management/ChangeLog
deleted file mode 100644
index e69de29..0000000
--- a/contrib/ofed/management/ChangeLog
+++ /dev/null
diff --git a/contrib/ofed/management/INSTALL b/contrib/ofed/management/INSTALL
deleted file mode 100644
index e69de29..0000000
--- a/contrib/ofed/management/INSTALL
+++ /dev/null
diff --git a/contrib/ofed/management/Makefile b/contrib/ofed/management/Makefile
deleted file mode 100644
index 863c3aa..0000000
--- a/contrib/ofed/management/Makefile
+++ /dev/null
@@ -1,21 +0,0 @@
-
-SUBDIRS:= libibcommon libibumad libibmad opensm infiniband-diags
-
-all:
-
-config:
- $(foreach dir, $(SUBDIRS), \
- if [ ! -z "$(force)" -o ! -x $(dir)/configure ] ; then \
- ( cd $(dir) && ./autogen.sh && ./configure $(CONFIG_OPTS) ) \
- || exit 1 ; \
- elif [ ! -e $(dir)/Makefile ] ; then \
- ( cd $(dir) && ./configure $(CONFIG_OPTS) ) \
- || exit 1 ; \
- fi ; )
-
-automake: force=1
-automake: config
-
-all install: config
-all install clean:
- $(foreach dir, $(SUBDIRS), $(MAKE) -C $(dir) $@ && ) echo $@ done
diff --git a/contrib/ofed/management/NEWS b/contrib/ofed/management/NEWS
deleted file mode 100644
index e69de29..0000000
--- a/contrib/ofed/management/NEWS
+++ /dev/null
diff --git a/contrib/ofed/management/README b/contrib/ofed/management/README
deleted file mode 100644
index c6efd9f..0000000
--- a/contrib/ofed/management/README
+++ /dev/null
@@ -1,132 +0,0 @@
-This README is for OpenSM and the InfiniBand diagnostic utilities
-in this directory (management).
-
-The master source repository is
-git://git.openfabrics.org/~sashak/management.git and can be cloned by:
-
- git clone git://git.openfabrics.org/~sashak/management.git
-
-
-Packages
---------
-libibcommon - common stuff
-libibumad - interface to ib_umad module (user_mad) library
-libibmad - generic MAD handling library
-opensm - OpenSM
-infiniband-diags - various diagnostic tools
-
-
-Building
---------
-To make this unpack tarballs and in directories libibcommon, libibumad,
-libibmad, opensm, infiniband-diags (in that order) run:
-
- ./configure && make && make install
-
-(If you are building the cloned repository run also ./autogen.sh first)
-
-Typically the autogen and configure steps only need be done the first
-time unless configure.in or Makefile.am changes in the directories.
-
-Libraries are installed by default at /usr/local/lib and binaries at
-/usr/local/sbin.
-
-
-Running
--------
-After compiling and installing, you can run opensm by invoking
-
- /usr/local/sbin/opensm
-
-opensm must be run as root. Run 'opensm --help' to see the options.
-
-Note also that you must have udev mount /dev/infiniband or do it manually.
-See .../src/linux-kernel/docs/user_mad.txt. Also, ib_umad module must be
-loaded.
-
-opensm will run on the first existing port on the first IB device (HCA).
-You can override that by using "-g <portguid_in_hex>".
-Verify that the first port is active. This assumes the port is plugged
-into another IB device.
-
-In case of problems, run the opensm with -V and send the log file
-(/var/log/opensm.log).
-
-IMPORTANT:
-Don't forget to modprobe ib_umad and make sure udev is configured before
-using any of the userspace programs.
-
-
-OpenSM Limitations:
-1. Retry mechanism in SM is primitive and needs enhancing to deal with
-ports which are active but don't respond to SM MADs.
-2. Async events are not yet supported (by OpenSM). The only one supported
-is local LID change (and this is handled in the mthca driver). Future
-versions of OpenSM may need to act on more local events.
-
-
-Tuning OpenSM for Large Clusters
---------------------------------
-Currently OpenSM is compiled with debug and no optimization. This
-should be changed to at least -O2 (and perhaps -O4) but I would start
-with -O2. This results in a 2x speedup for some code paths.
-
-OpenSM supports a pipelining mode for SMPs. The default is 4
-outstanding SMPs. -maxsmps <#> indicates the number of outstanding SMPs
-allowed and should speed up the initialization. Useful values of this
-are 16 and 32.
-
-Beyond this, there may be some issue with a link which is causing
-timeout and retries to kick in. The OpenSM log should have some messages
-in there indicating this.
-
-
-Other utilities (infiniband diagnostics)
----------------------------------------
-ibstat - show host adapters status
-ibstatus - similar to ibstat but implemented as a script
-ibnetdiscover - scan topology
-ibaddr - shows the lid range and default GID of the target (default is
- the local port)
-ibroute - display unicast and multicast forwarding tables of switches
-ibtracert - display unicast or multicast route from source to destination
-ibping - ping/pong between IB nodes (currently using vendor MADs)
-ibsysstat - obtain basic information for node (hostname, cpus, memory,
- utilization) which may be remote
-sminfo - query the SMInfo attribute on a node
-smpdump - simple solicited SMP query tool. Output is hex dump
- (unless requested otherwise, e.g. using -s)
-smpquery - formatted SMP query tool
-perfquery - dump (and optionally clear) the performance (including error)
- counters of the destination port
-ibcheckport - perform some basic tests on the specified port
-ibchecknode - perform some basic tests on the specified node
-ibcheckerrs - check if the error counters of the port/node have passed
- some predefined thresholds
-ibchecknet - perform port/node/errors check on the subnet. ibnetdiscover
- output can be used as in input topology
-ibswitches - scan the net or use existing net topology file and list all
- switches
-ibhosts - scan the net or use existing net topology file and list all hosts
-ibnodes - scan the net or use existing net topology file and list all nodes
-ibportstate - get the logical and physical port state of an IB port or
- disable or enable the port (only on a switch)
-ibcheckwidth - perform port width check on the subnet. Used to find ports
- with 1x link width.
-ibcheckportwidth - perform 1x port width check on specified port
-ibcheckstate - perform port state (and physical port state) check on
- the subnet. Used to find ports not in LinkUp physical port state
- and not Active port state
-ibcheckportstate - perform port state (and physical port state) check on
- specified port
-ibcheckerrors - perform error check on subnet. Used to find ports with
- error counters (PMA PortCounters) beyond the indicated thresholds
-ibclearerrors - clear all error counters on subnet
-ibclearcounters - clear all port counters on subnet
-ibdiscover.pl - takes output of ibnetdiscover and a map file and produces
- a topology file (local node GUID and port connected to remote
- node GUID and port)
-saquery - issue some SA queries
-
-Note that the above list is not up to date and the infiniband-diags
-subdirectory should be checked for the latest tools.
diff --git a/contrib/ofed/management/doc/diagtools-proposal.txt b/contrib/ofed/management/doc/diagtools-proposal.txt
deleted file mode 100644
index f0f15cb..0000000
--- a/contrib/ofed/management/doc/diagtools-proposal.txt
+++ /dev/null
@@ -1,169 +0,0 @@
-Diagnostic Tools
-11/29/04
-
-user space applications (also library support)
-two categories: host and network
-
-Host Oriented Diagnostic Tools
-
-1. ibstatus
-
-Description:
-ibstatus displays basic information obtained from the local IB driver.
--v enables verbose mode. Normal output includes LID, SMLID, port state,
-link width active, and port physical state. Verbose includes all sysfs
-supported parameters for that interface and port.
-
-Syntax:
-ibstatus [-v] [-I mthca0] [-p port]
-
-Dependencies:
-sysfs support in mthca
-
-2. ibroute
-
-Description:
-ibroute uses SMPs to display the forwarding tables (unicast
-(LinearForwardingTable or LFT) or multicast (MulticastForwardingTable or MFT))
-for the specified LID.
-
-Syntax:
-ibroute [-multi] [-m mkey] [-pa path] [-I mthca0] [-p port] LID
-
-Dependencies:
-user MAD access, SMA
-
-3. ibtracert
-
-Description:
-ibtracert uses SMPs to trace the path from a source GID/LID to a
-destination GID/LID. The source GID/LID must be local to the node.
-Each hop along the path is displayed until the destination is reached or
-a hop does not respond. By using -mg and/or -ml options, multicast path
-tracing can be performed between source and destination nodes.
-
-Syntax:
-ibtracert [-m mkey] [-pa path] [-sg SGID] [-sl SLID] [-dg DGID] [-dl DLID] \
- [-mg MGID] [-ml MLID] [-I mthca0] [-p port]
-
-Dependencies:
-user MAD access, SMA
-
-4. smpquery
-
-Description:
-smpquery allows a basic subset of standard SMP queries including the following:
-local information (LID, GID, etc.), node information (from NodeDescription,
-NodeInfo, and possibly SwitchInfo if node is a switch), port information
-(port address and state), and port parameters (SLtoVLMappingTable,
-VLArbitrationTable, HOQLife, ...).
-
-Syntax:
-smpquery [-m mkey] [-l LID] [-pa path] [-I mthca0] [-p port] \
- [-l] [-n] [-pi] [-pp]
-
-Dependencies:
-User MAD access
-
-5. smpdump
-
-Description:
-smpdump is a general purpose SMP utility which gets SM attributes from a
-specified SMA. The result is dumped as hex (-x) or string (-s), with hex
-as the default.
-
-Syntax:
-smpdump [-m mkey] [-l LID] [-p path] [-I mthca0] [-p port] \
- [-a attributeID] [-am attributeModifier] [-s] [-x]
-
-Dependencies:
-User MAD access, MAD snooping support
-
-6. perfquery
-
-Description:
-perfquery uses PerfMgt GMPs to obtain the PortCounters (basic performance
-and error counters) from the PMA at the node specified. -r resets these
-counters after obtaining them.
-
-Syntax:
-perfquery [-I mthca0] [-p port] [-r] [-g GID] LID
-
-Dependencies:
-User MAD access, PMA
-
-7. ibping
-
-Description:
-ibping uses UD transport to validate connectivity between IB nodes.
-It is run as client/server (daemon). -v option uses vendor MADs rather than
-normal UD transport.
-
-Syntax:
-ibping [-d] [-v] [-c count] [-i interval] [-s packetsize] \
- [-I mthca0] [-p port] [-q qkey] [-g DGID] [-qp dqp] [-dl DLID]
-
--d: run as daemon (server)
-
-Dependencies:
-user MAD access
-
-
-Network Oriented Diagnostics
-
-8. ibnetdiscover
-
-Description:
-ibnetdiscover performs IB subnet discovery and outputs a human readable
-topology file. GUIDs, node types, and port numbers are displayed
-as well as port LIDs and NodeDescriptions. All nodes (and links) are displayed
-(full topology).
-
-Syntax:
-ibnetdiscover [-I mthca0] [-p port] [-o topology-filename]
-
-Dependencies:
-user MAD access
-
-Future versions of this file will be annotated with additional information
-including system guid, system type, internal to physical mapping, and physical
-location information (blade or ASIC number, etc.).
-
-9. ibhosts
-
-Description:
-ibhosts either walks the IB subnet topology or uses an already saved topology
-file and extracts the HCA nodes.
-
-Syntax:
-ibhosts [-I mthca0] [-p port] [-i topology-filename] [-o ibhosts-filename]
-
-Dependencies:
-user MAD access, ibnetdiscover
-
-10. ibswitches
-
-Description:
-ibswitches either walks the IB subnet topology or uses an already saved
-topology file and extracts the IB switches.
-
-Syntax:
-ibswitches [-I mthca0] [-p port] \
- [-i topology-filename] [-o ibswitches-filename]
-
-Dependencies:
-user MAD access, ibnetdiscover
-
-11. ibnetverify
-
-Description:
-ibnetverify uses a full topology file that was created by ibnetdiscover,
-scans the network to see if the current topology matches or not displaying
-any discrepancies, and validates the connectivity and reports errors
-(from port counters).
-
-Syntax:
-ibnetverify -f filename [-I mthca0] [-p port]
-
-Dependencies:
-user MAD access, ibnetdiscover
diff --git a/contrib/ofed/management/doc/diagtools.txt b/contrib/ofed/management/doc/diagtools.txt
deleted file mode 100644
index 8ef2590..0000000
--- a/contrib/ofed/management/doc/diagtools.txt
+++ /dev/null
@@ -1,565 +0,0 @@
-Diagnostic Tools
-shaharf@voltaire.com, halr@voltaire.com
-
-General:
-
-Model of operation: All utilities use direct MAD access to perform their
-operations. Operations that require QP 0 mads only, may use direct routed
-mads, and therefore may work even in unconfigured subnets. Almost all
-utilities can operate without accessing the SM, unless GUID to lid translation
-is required.
-
-Dependencies: Most utilities depend on libibmad and libibumad.
- All utilities depend on the ib_umad kernel module.
-
-Multiple port/Multiple CA support: when no IB device or port is specified
- (see the "local umad parameters" below), the libibumad library
- selects the port to use by the following criteria:
- 1. the first port that is ACTIVE.
- 2. if not found, the first port that is UP (physical link up).
-
- If a port and/or CA name is specified, the libibumad library
- attempts to fulfill the user request, and will fail if it is not
- possible.
- For example:
- ibaddr # use the 'best port'
- ibaddr -C mthca1 # pick the best port from mthca1 only.
- ibaddr -P 2 # use the second (active/up) port from the
- first available IB device.
- ibaddr -C mthca0 -P 2 # use the specified port only.
-
-Common options & flags:
- Most diagnostics take the following flags. The exact list of supported
- flags per utility can be found in the usage message and can be shown
- using util_name -h syntax.
-
- # Debugging flags
- -d raise the IB debugging level. May be used
- several times (-ddd or -d -d -d).
- -e show umad send receive errors (timeouts and others)
- -h show the usage message
- -v increase the application verbosity level.
- May be used several times (-vv or -v -v -v)
- -V show the internal version info.
-
- # Addressing flags
- -D use directed path address arguments. The path
- is a comma separated list of out ports.
- Examples:
- "0" # self port
- "0,1,2,1,4" # out via port 1, then 2, ...
- -G use GUID address arguments. In most cases, it is the Port GUID.
- Examples:
- "0x08f1040023"
- -s <smlid> use 'smlid' as the target lid for SA queries.
-
- # Local umad parameters:
- -C <ca_name> use the specified ca_name.
- -P <ca_port> use the specified ca_port.
- -t <timeout_ms> override the default timeout for the solicited mads.
-
-CLI notation: all utilities use the POSIX style notation,
- meaning that all options (flags) must precede all arguments
- (parameters).
-
-
-Utilities descriptions:
-
-1. ibstatus
-
-Description:
-ibstatus is a script which displays basic information obtained from the local
-IB driver. Output includes LID, SMLID, port state, link width active, and port
-physical state.
-
-Syntax:
-ibstatus [-h] [devname[:port]]...
-
-Examples:
- ibstatus # display status of all IB ports
- ibstatus mthca1 # status of mthca1 ports
- ibstatus mthca1:1 mthca0:2 # show status of specified ports
-
-See also:
- ibstat
-
-2. ibstat
-
-Description:
-Similar to the ibstatus utility but implemented as a binary and not a script.
-It has options to list CAs and/or ports.
-
-Syntax:
-ibstat [-d(ebug) -l(ist_of_cas) -p(ort_list) -s(hort)] <ca_name> [portnum]
-
-Examples:
- ibstat # display status of all IB ports
- ibstat mthca1 # status of mthca1 ports
- ibstat mthca1 2 # show status of specified ports
- ibstat -p mthca0 # list the port guids of mthca0
- ibstat -l # list all CA names
-
-See also:
- ibstatus
-
-3. ibroute
-
-Description:
-ibroute uses SMPs to display the forwarding tables (unicast
-(LinearForwardingTable or LFT) or multicast (MulticastForwardingTable or MFT))
-for the specified switch LID and the optional lid (mlid) range.
-The default range is all valid entries in the range 1...FDBTop.
-
-Syntax:
-ibroute [options] <switch_addr> [<startlid> [<endlid>]]]
-
-Non standard flags:
- -a show all lids in range, even invalid entries.
- -n do not try to resolve destinations.
- -M show multicast forwarding tables. In this case the range
- parameters are specifying mlid range.
-
-Examples:
- ibroute 2 # dump all valid entries of switch lid 2
- ibroute 2 15 # dump entries in the range 15...FDBTop.
- ibroute -a 2 10 20 # dump all entries in the range 10..20
- ibroute -n 2 # simple format
- ibroute -M 2 # show multicast tables
-
-See also:
- ibtracert
-
-4. ibtracert
-
-Description:
-ibtracert uses SMPs to trace the path from a source GID/LID to a
-destination GID/LID. Each hop along the path is displayed until the destination
-is reached or a hop does not respond. By using the -m option, multicast path
-tracing can be performed between source and destination nodes.
-
-Syntax:
-ibtracert [options] <src-addr> <dest-addr>
-
-Non standard flags:
- -n simple format; don't show additional information.
- -m <mlid> show the multicast trace of the specified mlid.
-
-Examples:
- ibtracert 2 23 # show trace between lid 2 and 23
- ibtracert -m 0xc000 3 5 # show multicast trace between lid 3 and 5
- for mcast lid 0xc000.
-
-5. smpquery
-
-Description:
-smpquery allows a basic subset of standard SMP queries including the following:
-node info, node description, switch info, port info. Fields are displayed in
-human readable format.
-
-Syntax:
-smpquery [options] <op> <dest_addr> [op_params]
-
-Current supported operations and their parameters:
- nodeinfo <addr>
- nodedesc <addr>
- portinfo <addr> [<portnum>] # default port is zero
- switchinfo <addr>
- pkeys <addr> [<portnum>]
- sl2vl <addr> [<portnum>]
- vlarb <addr> [<portnum>]
-
-Examples:
- smpquery nodeinfo 2 # show nodeinfo for lid 2
- smpquery portinfo 2 5 # show portinfo for lid 2 port 5
-
-6. smpdump
-
-Description:
-smpdump is a general purpose SMP utility which gets SM attributes from a
-specified SMA. The result is dumped in hex by default.
-
-Syntax:
-smpdump [options] <dest_addr> <attr> [mod]
-
-Non standard flags:
- -s show output as string
-
-Examples:
- smpdump -D 0,1,2 0x15 2 # port info, port 2
- smpdump 3 0x15 2 # port info, lid 3 port 2
-
-7. ibaddr
-
-Description:
-ibaddr can be used to show the lid and GID addresses of the specified port,
-or the local port by default.
-Note: this utility can be used as simple address resolver.
-
-Syntax:
-ibaddr [options] [<dest_addr>]
-
-Examples:
- ibaddr # show local address
- ibaddr 2 # show address of the specified port lid
- ibaddr -G 0x8f1040023 # show address of the specified port guid
-
-8. sminfo
-
-Description:
-sminfo issue and dumps the output of a sminfo query in human readable format.
-The target SM is the one listed in the local port info, or the SM specified
-by the optional SM lid or by the SM direct routed path.
-Note: using sminfo for any purposes other then simple query may be very
-dangerous, and may result in a malfunction of the target SM.
-
-Syntax:
-sminfo [options] <sm_lid|sm_dr_path> [sminfo_modifier]
-
-Non standard flags:
- -s <state> # use the specified state in sminfo mad
- -p <priority> # use the specified priority in sminfo mad
- -a <activity> # use the specified activity in sminfo mad
-
-Examples:
- sminfo # show sminfo of SM listed in local portinfo
- sminfo 2 # query SM on port lid 2
-
-9. perfquery
-
-Description:
-perfquery uses PerfMgt GMPs to obtain the PortCounters (basic performance
-and error counters) from the PMA at the node specified. Optionally
-show aggregated counters for all ports of node. Also, optionally, reset
-after read, or only reset counters.
-
-Syntax:
-perfquery [options] [<lid|guid> [[port] [reset_mask]]]
-
-Non standard flags:
- -a show aggregated counters for all ports of the destination lid.
- -r reset counters after read.
- -R only reset counters.
-
-Examples:
- perfquery # read local port's performance counters
- perfquery 32 1 # read performance counters from lid 32, port 1
- perfquery -a 32 # read node aggregated performance counters
- perfquery -r 32 1 # read performance counters and reset
- perfquery -R 32 1 # reset performance counters of port 1 only
- perfquery -R -a 32 # reset performance counters of all ports
- perfquery -R 32 2 0xf000 # reset only non-error counters of port 2
-
-10. ibping
-
-Description:
-ibping uses vendor mads to validate connectivity between IB nodes.
-On exit, (IP) ping like output is show. ibping is run as client/server.
-Default is to run as client. Note also that a default ping server is
-implemented within the kernel.
-
-Syntax:
-ibping [options] <dest lid|guid>
-
-Non standard flags:
- -c <count> stop after count packets
- -f flood destination: send packets back to back w/o delay
- -o <oui> use specified OUI number to multiplex vendor mads
- -S start in server mode (do not return)
-
-11. ibnetdiscover
-
-Description:
-ibnetdiscover performs IB subnet discovery and outputs a human readable
-topology file. GUIDs, node types, and port numbers are displayed
-as well as port LIDs and NodeDescriptions. All nodes (and links) are displayed
-(full topology). Optionally this utility can be used to list the current
-connected nodes. The output is printed to the standard output unless a
-topology file is specified.
-
-Syntax:
-ibnetdiscover [options] [<topology-filename>]
-
-Non standard flags:
- -l List of connected nodes
- -H List of connected HCAs
- -S List of connected switches
- -g Grouping
-
-12. ibhosts
-
-Description:
-ibhosts either walks the IB subnet topology or uses an already saved topology
-file and extracts the CA nodes.
-
-Syntax:
-ibhosts [-h] [<topology-file>]
-
-Dependencies:
-ibnetdiscover, ibnetdiscover format
-
-13. ibswitches
-
-Description:
-ibswitches either walks the IB subnet topology or uses an already saved
-topology file and extracts the IB switches.
-
-Syntax:
-ibswitches [-h] [<topology-file>]
-
-Dependencies:
-ibnetdiscover, ibnetdiscover format
-
-14. ibchecknet
-
-Description:
-ibchecknet uses a full topology file that was created by ibnetdiscover,
-scans the network to validate the connectivity and reports errors
-(from port counters).
-
-Syntax:
-ibchecknet [-h] [<topology-file>]
-
-Dependencies:
-ibnetdiscover, ibnetdiscover format, ibchecknode, ibcheckport, ibcheckerrs
-
-15. ibcheckport
-
-Description:
-Check connectivity and do some simple sanity checks for the specified port.
-Port address is lid unless -G option is used to specify a GUID address.
-
-Syntax:
-ibcheckport [-h] [-G] <lid|guid> <port_number>
-
-Example:
- ibcheckport 2 3 # check lid 2 port 3
-
-Dependencies:
-smpquery, smpquery output format, ibaddr
-
-16. ibchecknode
-
-Description:
-Check connectivity and do some simple sanity checks for the specified node.
-Port address is lid unless -G option is used to specify a GUID address.
-
-Syntax:
-ibchecknode [-h] [-G] <lid|guid>
-
-Example:
- ibchecknode 2 # check node via lid 2
-
-Dependencies:
-smpquery, smpquery output format, ibaddr
-
-Usage:
-
-17. ibcheckerrs
-
-Description:
-Check specified port (or node) and report errors that surpassed their predefined
-threshold. Port address is lid unless -G option is used to specify a GUID
-address. The predefined thresholds can be dumped using the -s option, and a
-user defined threshold_file (using the same format as the dump) can be
-specified using the -t <file> option.
-
-Syntax:
-ibcheckerrs [-h] [-G] [-t <threshold_file>] [-s(how_thresholds)] <lid|guid> [<port>]
-
-Examples:
- ibcheckerrs 2 # check aggregated node counter for lid 2
- ibcheckerrs 2 4 # check port counters for lid 2 port 4
- ibcheckerrs -t xxx 2 # check node using xxx threshold file
-
-Dependencies:
-perfquery, perfquery output format, ibaddr
-
-18. ibportstate
-
-Description:
-ibportstate allows the port state and port physical state of an IB port
-to be queried or a switch port to be disabled or enabled.
-
-Syntax:
-ibportstate [-d(ebug) -e(rr_show) -v(erbose) -D(irect) -G(uid) -s smlid
--V(ersion) -C ca_name -P ca_port -t timeout_ms] <dest dr_path|lid|guid>
-<portnum> [<op>]
- supported ops: enable, disable, query
-
-Examples:
- ibportstate 3 1 disable # by lid
- ibportstate -G 0x2C9000100D051 1 enable # by guid
- ibportstate -D 0 1 # by direct route
-
-19. ibcheckwidth
-
-Description:
-ibcheckwidth uses a full topology file that was created by ibnetdiscover,
-scans the network to validate the active link widths and reports any 1x
-links.
-
-Syntax:
-ibcheckwidth [-h] [<topology-file>]
-
-Dependencies:
-ibnetdiscover, ibnetdiscover format, ibchecknode, ibcheckportwidth
-
-20. ibcheckportwidth
-
-Description:
-Check connectivity and check the specified port for 1x link width.
-Port address is lid unless -G option is used to specify a GUID address.
-
-Syntax:
-ibcheckportwidth [-h] [-G] <lid|guid> <port>
-
-Example:
- ibcheckportwidth 2 3 # check lid 2 port 3
-
-Dependencies:
-smpquery, smpquery output format, ibaddr
-
-21. ibcheckstate
-
-Description:
-ibcheckstate uses a full topology file that was created by ibnetdiscover,
-scans the network to validate the port state and port physical state,
-and reports any ports which have a port state other than Active or
-a port physical state other than LinkUp.
-
-Syntax:
-ibcheckstate [-h] [<topology-file>]
-
-Dependencies:
-ibnetdiscover, ibnetdiscover format, ibchecknode, ibcheckportstate
-
-22. ibcheckportstate
-
-Description:
-Check connectivity and check the specified port for proper port state
-(Active) and port physical state (LinkUp).
-Port address is lid unless -G option is used to specify a GUID address.
-
-yntax:
-ibcheckportstate [-h] [-G] <lid|guid> <port_number>
-
-Example:
- ibcheckportstate 2 3 # check lid 2 port 3
-
-Dependencies:
-smpquery, smpquery output format, ibaddr
-
-23. ibcheckerrors
-
-ibcheckerrors uses a full topology file that was created by ibnetdiscover,
-scans the network to validate the connectivity and reports errors
-(from port counters).
-
-Syntax:
-ibnetcheckerrors [-h] [<topology-file>]
-
-Dependencies:
-ibnetdiscover, ibnetdiscover format, ibchecknode, ibcheckport, ibcheckerrs
-
-24. ibdiscover.pl
-
-ibdiscover.pl uses a topology file create by ibnetdiscover and a discover.map
-file which the network administrator creates which indicates the nodes
-to be expected and a ibdiscover.topo file which is the expected connectivity
-and produces a new connectivity file (discover.topo.new) and outputs
-the changes to stdout. The network administrator can choose to replace
-the "old" topo file with the new one or certain changes in.
-
-The syntax of the ibdiscover.map file is:
-<nodeGUID>|port|"Text for node"|<NodeDescription from ibnetdiscover format>
-e.g.
-8f10400410015|8|"ISR 6000"|# SW-6IB4 Voltaire port 0 lid 5
-8f10403960558|2|"HCA 1"|# MT23108 InfiniHost Mellanox Technologies
-
-The syntax of the old and new topo files (ibdiscover.topo and
-ibdiscover.topo.new) are:
-<LocalPort>|<LocalNodeGUID>|<RemotePort>|<RemoteNodeGUID>
-e.g.
-10|5442ba00003080|1|8f10400410015
-
-These topo files are produced by the ibdiscover.pl tool.
-
-Syntax:
-ibnetdiscover | ibdiscover.pl
-
-Dependencies:
-ibnetdiscover, ibnetdiscover format
-
-25. ibnodes
-
-Description:
-ibnodes either walks the IB subnet topology or uses an already saved topology
-file and extracts the IB nodes (CAs and switches).
-
-Syntax:
-ibnodes [<topology-file>]
-
-Dependencies:
-ibnetdiscover, ibnetdiscover format
-
-26. ibclearerrors
-
-Description:
-ibclearerrors clears the PMA error counters in PortCounters by either walking
-the IB subnet topology or using an already saved topology file.
-
-Syntax:
-ibclearerrors [-h] [<topology-file>]
-
-Dependencies:
-ibnetdiscover, ibnetdiscover format, perfquery
-
-27. ibclearcounters
-
-Description:
-ibclearcounters clears the PMA port counters by either walking
-the IB subnet topology or using an already saved topology file.
-
-Syntax:
-ibclearcounters [-h] [<topology-file>]
-
-Dependencies:
-ibnetdiscover, ibnetdiscover format, perfquery
-
-28. saquery
-
-Description:
-Issue some SA queries.
-
-Syntax:
-Usage: saquery [-h -d -P -N -L -G -s -g][<name>]
- Queries node records by default
- -d enable debugging
- -P get PathRecord info
- -N get NodeRecord info
- -L Return just the Lid of the name specified
- -G Return just the Guid of the name specified
- -s Return the PortInfoRecords with isSM capability mask bit on
- -g get multicast group info
-
-Dependencies:
-OpenSM libvendor, OpenSM libopensm, libibumad
-
-29. ibsysstat
-
-Description:
-ibsysstat uses vendor mads to validate connectivity between IB nodes
-and obtain other information about the IB node. ibsysstat is run as
-client/server. Default is to run as client.
-
-Syntax:
-ibsysstat [options] <dest lid|guid> [<op>]
-
-Non standard flags:
- Current supported operations:
- ping - verify connectivity to server (default)
- host - obtain host information from server
- cpu - obtain cpu information from server
- -o <oui> use specified OUI number to multiplex vendor mads
- -S start in server mode (do not return)
-
diff --git a/contrib/ofed/management/doc/ibtracer.txt b/contrib/ofed/management/doc/ibtracer.txt
deleted file mode 100644
index c86000c..0000000
--- a/contrib/ofed/management/doc/ibtracer.txt
+++ /dev/null
@@ -1,106 +0,0 @@
-ibtracer
-1/11/05
-
-Description:
-ibtracer is used to build a source route into a UD packet and validate the
-path taken to a destination. It is based on a client/server architecture and
-relies on a special ibtracer IB agent in each node along the way. It can
-deal with switches which do not currently run this agent but validation for
-that part of the path is impossible.
-
-Syntax:
-ibtracer [-I mthca0] [-p port] [-r <# retries>] [-t <timeout in msec>] \
- [-l LID] [-g DGID] [-v]
-
-Architecture:
-IBA 1.2 defines a new set of vendor specific MADs which include OUI. OpenIB
-will use one of these classes (0x30) to implement ibtracer (and the vendor
-MAD option of ibping).
-
-Note that these are general service MADs and rely on the network being up.
-If the network is not up, then DR SMPs must be used. There are a number of
-separate SMP tools for this.
-
-The OpenIB vendor specific MAD agent will support the following attributes:
-ClassPortInfo (0x0001) and SourceRoute (0x0010). There may be an additional
-attribute (TBD) to support ibping but this can be done out of the same agent.
-
-Only the VendorGet method needs to be supported by this agent. No traps
-are currently defined for this class.
-
-Although from the ibtracer client perspective, these vendor MADs are sent
-on outgoing ports, it is the server (agent) which needs to validate the
-incoming port. As a result of this, it is the expected incoming port
-at the next hop which needs to be added to the SourceRoute attribute.
-SourceRoute requests (Gets) and responses (GetResps) are exchanged
-directly between the source node where the ibtracer command is initiated
-and each hop along the way to the destination until the destination is
-reached. As the hops to the destination are walked, the incoming ports are
-added to the SourceRoute attribute and checked when the packet is received
-by that hop that it did arrive on that port. If it did not arrive on that
-port, an error is indicated in the status field (status 7). In either case,
-the port it did arrive on is put in the SourceRoute attribute in the GetResp.
-
-One of DLID or DGID must be specified in the ibtracer invocation.
-If DGID is specified, a PathRecord request is made to the SA
-to obtain the DLID. Other than that, no SM or SA is involved with
-ibtracer although the SM is needed to set up the forwarding tables.
-
-Once the DLID is obtained from either the command invoication or the SA,
-a DR SMP packet is sent to the next hop to obtain the PortInfo attribute
-to obtain the base LID for the next hop. A VendorGet(ClassPortInfo) is
-then attempted to see if this management class is supported on that node.
-If it is (a VendorGetResp is received), a VendorGet(SourceRoute)
-to the next hop LID is attempted after updating the source route attribute
-with the local port number from the returned PortInfo attribute. Upon
-receipt of the VendorGet(SourceRoute), the receiving agent validates the
-port number it is received on with the port number in the SourceRoute
-attribute. It indicates failure when they do not match and in either case
-the port is was received on is put back into the VendorGetResp(SourceRoute).
-
-If the next hop does not support this management class, this is indicated
-(if -v is enabled) and the algorithm proceeds with the next hop. The
-algorithm is terminated when the next hop LID is the DLID (factoring in
-the LMC).
-
-Note that rather than doing much of this with DR SMPs directly,
-these could be SA requests (using PortInfoRecords and LinkRecords,
-or TraceRecords). Investigation would need to be done to validate
-whether these SA attributes are supported by the various SMs
-(although OpenSM is most important in terms of OpenIB). TraceRecords
-are optional and are not believed to be currently supported. It can
-be done with just PortInfoRecords and LinkRecords.
-
-Since vendor MADs are UD, there is a retransmission strategy (timeout/retry)
-which have defaults but are settable on the command line.
-
--v option displays entire path. Note that the incoming (rather than outgoing)
-ports are displayed. Without -v specified, just success or failure is
-displayed.
-
-Reversible paths are used for the responses. Note that the path from A to
-B might not be the same from B to A so ibtracer needs to be initiated at
-both ends if this is of interest.
-
-This tool cannot currently be used for multicast tracing. There are a
-couple of reasons for this. Base switch port 0 does not support
-multicast and it is not a requirement of enhanced switch port 0
-to support this so there would be more hop skipping. Also, the attribute
-format would need to be enhanced for this as well as the client needing
-to handle multiple responses to a single request.
-
-
-SourceRoute attribute format
-
-Actual Incoming Port Number (valid on response) - 1 byte
-Current Hop Count - 1 byte
-Vector of Incoming Port Numbers (0-63) - 64 bytes
-
-
-Outstanding Questions
-
-Should SL be supported rather than assume SL 0 ?
-
-Should GRH be supported (and tied to GID specification in command invocation) ?
-
-Is multicast tracing important ?
diff --git a/contrib/ofed/management/doc/libibmad.txt b/contrib/ofed/management/doc/libibmad.txt
deleted file mode 100644
index 42a61d4..0000000
--- a/contrib/ofed/management/doc/libibmad.txt
+++ /dev/null
@@ -1,687 +0,0 @@
-libibmad:
-
-Overview: libibmad provides the following functionalities:
- * common declarations: IB structures, fields, and enumerations
- * general IB mad interface encapsulation (init port, registration,
- etc.)
- * IB mads marshaling and de-marshaling
- * Reliable mad RPC mechanisms (solicited mads)
- * Server side mad io functions (send, receive)
- * General SMP support
- * General SA (queries) support
- * Port performance class support
- * IB addresses resolution (path record queries)
- * Fields parsing and dump functions
- * Debugging support
-
-Model of operation: libibmad is designed to easy the implementation of MAD
- client and server tools and applications. Mad clients (i.e. application
- that do not reply to requests) should use the mad RPC mechanism. Mad
- servers should use the send/receive mechanisms. Applications are
- assumed to be single threaded, but some multiple threading support
- is provided. Most IO mechanisms may be blocking. Currently no
- explicit asynchronous support is implemented.
-
-Marshaling/De-marshaling model: libibmad handles two types of data - opaque
- network data images and native host ordered fields. libibmad do
- not define C structures to access MAD fields. Instead, it defines
- a field structure for every separate field and implements a set
- of conversion functions from the native types to the opaque
- network image and back. The advantage of this approach is
- that the marshaling/de-marshaling problems are transparent to most
- of the application code resulting a clean, machine independent
- code. Furthermore, even the marshaling/de-marshaling code itself
- is extremely straight-forward due that fact that the library
- automatically knows what marshaling/de-marshaling method it has
- to apply to each field. The disadvantage of this approach is that
- the marshaling/de-marshaling implementation itself is somehow less
- efficient then manually crafted manipulations, but this seem a fair
- tradeoff comparing to the simplicity and cleanness factors.
-
-Field dump functions: a side benefit of the marshaling/de-marshaling model
- (see above), is that the library is aware to the size and the type
- of each field and therefore is able to print out a human readable
- representation of the field value.
-
-
-Library objects:
-
-ib_field_t: IB field structure
-
-ib_dr_path_t: direct routed address structure
-
-ib_portid_t: (endpoint) address structure
-
-ib_attr_t: mad attribute and modifier
-
-ib_rpc_t: encapsulate information required for the RPC mechanism
-
-ib_rmpp_hdr_t: RMPP information structure (currently not supported)
-
-ib_sa_call_t: SA request structure
-
-ib_vendor_call_t: vendor specific mad structure
-
-
-Mad RPC functions:
-
-madrpc_init:
-
-Synopsis:
- void madrpc_init(char *dev_name, int dev_port,
- int *mgmt_classes, int num_classes);
-
-Description: library main initialization function. Open the user mad port
-specified by 'dev_name' and 'dev_port', and registers the application as mad
-client for the 'num_classes' management classes specified in 'mgmt_classes'
-array. This function must be called before any other call to the library.
-Initialization errors cause this function to panic.
-
-madrpc:
-
-Synopsis:
- void * madrpc(ib_rpc_t *rpc, ib_portid_t *dport,
- void *payload, void *rcvdata);
-
-Description: Perform RPC to the destination port specified by 'dport' using
-'rpc' parameters. If 'payload' in non-null, copy the payload buffer to the
-outgoing packet, while if the 'rcvdata' is non-null, copy the received packet
-payload to the 'rcvdata' buffer. Both buffer must be big enough to contain the
-maximal mad data payload length. If in doubt, use 256 bytes sized buffers.
-Return rcvdata pointer on success, and null on errors.
-
-madrpc_rmpp:
-
-Synopsis:
- void * madrpc_rmpp(ib_rpc_t *rpc, ib_portid_t *dport,
- ib_rmpp_hdr_t *rmpp, void *data);
-
-Description: Same as madrpc but supports also RMPP mads.
-
-Bugs:
- RMPP is not supported yet.
-
-madrpc_portid:
-
-Synopsis:
- int madrpc_portid(void);
-
-Description: return the portid the library uses. See libibumad:portid for
-details.
-
-See also:
- libibumad:umad_open_port
-
-madrpc_set_retries:
-
-Synopsis:
- int madrpc_set_retries(int retries);
-
-Description: Change the maximal number of retries attempted by the library
-before it times out to 'retries'. Non-positive values are ignored. Return
-the current retries count.
-
-madrpc_set_timeout:
-
-Synopsis:
- int madrpc_set_timeout(int timeout);
-
-Description: Change the default timeout value used for solicited mads to
-'timeout' milliseconds. Return 0 on success, -1 on errors. Note that the
-'timeout' value is used per retry, meaning the total timeout value is acctualy
-'timeout' * max_retries (see madrpc_set_retries()).
-
-madrpc_save_mad:
-
-Synopsis:
- void madrpc_save_mad(void *madbuf, int len);
-
-Description: Save the next replied mad image in 'madbuf', copying maximux 'len'
-bytes. In fact, this function snoop a single incoming mad. To snoop several
-packets, this function has to be called repeatedly after each RPC operation.
-
-Bugs:
- Not applicable to mad_receive
-
-madrpc_lock:
-
-Synopsis:
- void madrpc_lock(void);
-
-Description: Locks the mad RPC mechanism until madrpc_unlock() is called. Calls
-to this function while the RPC mechanism is already locked cause the calling
-process to be blocked until madrpc_unlock(). This function should be used
-only by multiple-threaded applications.
-
-See also:
- madrpc_unlock
-
-madrpc_unlock:
-
-Synopsis:
- void madrpc_unlock(void);
-
-Description: Unlock the mad RPC mechanism. See madrpc_lock() for details.
-
-madrpc_show_errors:
-
-Synopsis:
- void madrpc_show_errors(int set);
-
-Description: If 'set' is non-null, print out warning messages on some error
-events: retries, timeouts, replies with error status, etc. Zero 'set' value
-causes the library to be quiet.
-
-ib_mad_dump_fn:
-
-Synopsis:
- typedef void (ib_mad_dump_fn)(char *buf, int bufsz,
- void *val, int valsz);
-
-Description: Dump the value given in 'val' that have 'valsz' size (in bytes),
-to the specified 'buf' buffer and limit the output to 'bufsz' bytes. The
-output is expected to be human readable.
-
-
-Management classes' registration functions:
-
-Synopsis:
- int mad_register_client(int mgmt);
-
-Description: Register the application as a client of the specified
-'mgmt'. Return a non-negative agentid on success and -1 on errors.
-Note that madrpc_init provides more efficient method to register to several
-classes.
-
-See also:
- madrpc_init
-
-mad_register_server:
-
-Synopsis:
- int mad_register_server(int mgmt, uint32 method_mask[4],
- uint32 class_oui);
-
-Description: Register the appication as the default responder of the class
-methods specified by 'mngt' and 'method_mask' bitmap. Vendor classes in
-range 2 require also non-zero 'class_oui'. Return a non-negative agentid on
-success and -1 on errors.
-
-mad_class_agent:
-
-Synopsis:
- int mad_class_agent(int mgmt);
-
-Description: Map the given 'mgmt' class to agentid of the agent handling
-this class. Return non-negative agentid or -1 if the specified class is
-not registered.
-
-Synopsis:
- int mad_agent_class(int agent);
-
-Description: Map the given 'agent' id to the management class registered
-for it. Return positive class value on success, 0 if no management class
-is registered for this agentid, or -1 if the agent id is invalid.
-
-MAD client functions:
-
-ib_vendor_call:
-
-Synopsis:
- uint8 *ib_vendor_call(void *data, ib_portid_t *dport,
- ib_vendor_call_t *call);
-
-Description: Perform vendor specific RPC specified by 'call' to the destination
-port specified by 'dport'. The buffer pointed by 'data' is used as payload
-for the outgoing packet, and the received packet payload is copied back
-to the 'data' buffer. The 'data' buffer must be big enough to contain the
-replied data. Note that if the 'call' method is not get/set/trap, then a
-simple send operation is performed and the function returns immediately.
-Return the 'data' pointer on success, or null on errors.
-
-mad_is_vendor_range1:
-
-Synopsis:
- int mad_is_vendor_range1(int mgmt);
-
-Description: return non-zero value if 'mgmt' is in the vendor specific range
-1, and zero otherwise.
-
-mad_is_vendor_range2:
-
-Synopsis:
- int mad_is_vendor_range2(int mgmt);
-
-Description: return non-zero value if 'mgmt' is in the vendor specific range
-2, and zero otherwise.
-
-smp_query:
-
-Synopsis:
- uint8 * smp_query(void *buf, ib_portid_t *dport,
- uint attrid, uint mod, uint timeout);
-
-Description: Perform the SMP query (get) RPC specified by 'attrid' and 'mod'
-to the destination port 'dport'. The data in 'buf' is used as the outgoing
-SMP payload, and the replied packet's data is copied back to 'buf'. The
-buffer pointed by 'buf' should be big enough to contain the reply - i.e. at
-least 64 bytes. If timeout is non-zero then it is used as the query's
-timeout. Otherwise the default timeout value is used.
-
-See also:
- madrpc_set_timeout
-
-smp_set:
-
-Synopsis:
- uint8 * smp_set(void *buf, ib_portid_t *dport,
- uint attrid, uint mod, uint timeout);
-
-Description: Same as smp_query() but a set method is used instead of get.
-Note that SMP sets may lead to many (desired or less desired) results.
-Specifically it may cause the destination port to malfunction, confuse the
-current master SM, and lead to non-functioning network. Do not use this
-function unless you really know what you are doing.
-
-See also:
- smp_set
-
-Bugs:
- very dangerous. Shouldn't be allowed to non-privileged applications
-
-Synopsis:
- uint8 * safe_smp_query(void *rcvbuf, ib_portid_t *portid,
- uint attrid, uint mod, uint timeout)
-
-Description: Thread-safe version of smp_query().
-
-See also:
- smp_query
-
-safe_smp_set:
-
-Synopsis:
- uint8 * safe_smp_set(void *rcvbuf, ib_portid_t *portid,
- uint attrid, uint mod, uint timeout)
-
-Description: Thread-safe version of smp_set().
-
-See also:
- smp_set
-
-sa_call:
-
-Synopsis:
- uint8 * sa_call(void *data, ib_portid_t *dport,
- ib_sa_call_t *sa, uint timeout);
-
-Description: Perform SA RPC specified by 'sa' to the specified port
-'dport'. The 'data' buffer is used as the outgoing mad payload, and the
-returned packet's payload is copied back to the 'data' buffer. The buffer
-must be big enough to contain the response. If timeout is non-zero then it
-is used as the query's timeout. Otherwise the default timeout value is used.
-Return 'data' pointer on success, and null on errors.
-
-See also:
- smp_query, smp_set_timeout
-
-Bugs:
- RMPP support is missing, not all methods are supported
-
-ib_path_query:
-
-Synopsis:
- int ib_path_query(ib_gid_t srcgid, ib_gid_t destgid,
- ib_portid_t *sm_id, void *buf);
-
-Description: Perform a simple path record get query using the 'srcgid' and the
-'destgid' arguments. The query is targeted to the SM specified by 'sm_id'.
-Copy the query's result to the buffer 'buf' and returns the destination
-LID. If the query fails return -1.
-
-
-Synopsis:
- uint8 * safe_sa_call(void *rcvbuf, ib_portid_t *portid,
- ib_sa_call_t *sa, uint timeout);
-
-Description: Thread-safe version of sa_call().
-
-See also
- sa_call
-
-port_performance_query:
-
-Synopsis:
- uint8 *port_performance_query(void *rcvbuf, ib_portid_t *dport,
- int portnum, uint timeout);
-
-Description: Perform a port counters get query to the destination port(s)
-specified by 'dport' and portnum. Use portnum of 0xff to get the aggregated
-counters of the entire node. The query result is copied to the 'rcvbuf' that
-must be big enough to contain the response. If timeout is non-zero then it
-is used as the query's timeout. Otherwise the default timeout value is used.
-Return 'rcvbuf' pointer on success, and null on errors.
-
-port_performance_reset:
-
-Synopsis:
- uint8 *port_performance_reset(void *rcvbuf, ib_portid_t *dest,
- int portnum, uint mask, uint timeout);
-
-Description: Perform a port counters set operation to clear the counters of the
-destination port(s) specified by 'dport' and 'portnum'. the 'mask' bit-field
-is used to specify which counters are cleared. Use 'portnum' of 0xff to clear
-the aggregated counters of the entire node. The operation result is copied
-to the 'rcvbuf' that must be big enough to contain the response. If timeout
-is non-zero then it is used as the query's timeout. Otherwise the default
-timeout value is used. Return 'rcvbuf' pointer on success, and null on errors.
-
-Mad server functions:
-
-mad_send:
-
-Synopsis:
- int mad_send(ib_rpc_t *rpc, ib_portid_t *dport,
- ib_rmpp_hdr_t *rmpp, void *data);
-
-Description: Send a single mad to the destination port specified by
-'dport'. The mad is build using 'rpc' and rmpp arguments and the payload
-'data'. Note that this function operates similarly to send part of madrpc
-and madrpc_rmpp returns immediately after the send without retrying or
-waiting for the response (if any). Note that if solicited mads are send
-using this function, it is the caller responsibility to handle retries and
-timeouts. Return zero on success, -1 on errors.
-
-See also:
- madrpc, madrpc_rmpp
-
-mad_receive:
-
-Synopsis:
- void * mad_receive(void *umad, int timeout_ms);
-
-Description: Wait 'timeout_ms' milliseconds for a packet to be received. Once
-a packet is received, it is copied to the specified 'umad' buffer allocated
-by mad_alloc() or to a internally allocated umad buffer if 'umad' is null. In
-any case it is the caller responsibility to free the received packet using
-mad_free(). Negative 'timeout_ms' value makes the function to block until
-a packet is received. Zero 'timeout_ms' guarantees non blocking read,
-i.e. either the function returns immediately with new received packet,
-or it will return with error. Return a pointer to the received umad buffer
-or null in case of errors.
-
-mad_respond:
-
-Synopsis:
- int mad_respond(void *umad, ib_portid_t *portid, uint32 rstatus);
-
-Description: Respond to the request mad specified by 'umad'. Send the
-response mad to the port specified by 'portid' or the original caller of
-'umad' if 'portid' is null. The status 'rstatus' is used to fill the mad
-status field. The following outgoing fields are set by the function using the
-original 'umad' fields: mgt_class, method, attribute_id, attribute_modifier,
-SA attribute offset, vendor class OUI, mad transaction id (only the relevant
-fields are set). Return zero on success, -1 on errors.
-
-mad_alloc:
-
-Synopsis:
- void * mad_alloc(void);
-
-Description: Allocate a user mad buffer. This buffer should be de-allocated
-using mad_free(). The mad buffer (umad) should be used be used as opaque.
-Return a pointer to the buffer, or null if the allocation fails.
-
-See also:
- mad_free
-
-Synopsis:
- void mad_free(void *umad);
-
-Description: Free a umad buffer previously allocated by mad_alloc
-
-See also:
- mad_alloc
-
-Address resolving functions:
-
-ib_resolve_smlid:
-
-Synopsis:
- int ib_resolve_smlid(ib_portid_t *sm_id, int timeout);
-
-Description: Resolve the current SM address (LID) and copy it to
-'sm_id'. Internally this function queries the local port for the smlid
-field. 'timeout' is used similarly to madrpc(). Return zero on success,
--1 on errors.
-
-ib_resolve_guid:
-
-Synopsis:
- int ib_resolve_guid(ib_portid_t *portid, uint64_t *guid,
- ib_portid_t *sm_id, int timeout);
-
-Description: Resolve the given 'guid' to find the port lid and set 'portid'
-accordingly. The resolving process is done by sending a path record query
-to the SM using the specified address 'sm_id'. If the 'sm_id' is null, the
-SM address is resolved using ib_resove_smlid(). 'timeout' is used similary
-to madrpc(). Return zero on success, -1 on errors.
-
-See also:
- ib_resolve_smlid, ib_path_query, madrpc
-
-ib_resolve_portid_str:
-
-Synopsis:
- int ib_resolve_portid_str(ib_portid_t *portid, char *addr_str,
- int dest_type, ib_portid_t *sm_id);
-
-Description: Resolve the port address specified by the string 'addr_str'
-and the type 'dest_type' and set 'portid' accordingly. If the dest_type
-is IB_DEST_GUID, then a path record query is sent to the SM specified by
-'sm_id' or to the SM address found by ib_resolve_smlid() if sm_id is null. The
-following string formats are supported:
- Type String
- IB_DEST_LID: (Decimal/Hex) integer (see strtoul for details)
- IB_DEST_DRPATH out-ports vector "p1,p2,p3" (e.g. "0,1,6,5,20,1")
- IB_DEST_GUID: 64 bit integer (see strtoll for details)
-Return zero on success, -1 on errors.
-
-See also:
- str2drpath, ib_resolve_smlid, ib_resolve_guid
-
-ib_resolve_self:
-
-Synopsis:
- int ib_resolve_self(ib_portid_t *portid, int *portnum,
- ib_gid_t *gid);
-
-Description: Resolve the local port address and set 'portid', 'portnum' and
-'gid' accordingly. The resolve process is done by issuing a NodeInfo and
-PortInfo to the local port. Return zero on success, -1 on errors.
-
-Port ID helper functions:
-
-portid2str:
-
-Synopsis:
- char * portid2str(ib_portid_t *portid);
-
-Description: Return a string representation of the specified 'portid'.
-
-Bugs:
- uses a static string buffer and therefore not thread safe.
-
-portid2portnum:
-
-Synopsis:
- int portid2portnum(ib_portid_t *portid);
-
-Description: Return the port number of the destination port specified by
-the direct routed address 'portid'. Return -1 if the portid is not directed
-route address, and 0 if it is local port address (vector [0]).
-
-str2drpath:
-
-Synopsis:
- int str2drpath(ib_dr_path_t *path, char *routepath,
- int drslid, int drdlid);
-
-Description: Parse the 'routepath' string, and use the given 'drslid' and
-'drdlid' set the given 'path'. Return path count or -1 on invalid string.
-
-ib_portid_set:
-
-Synopsis:
- int ib_portid_set(ib_portid_t *portid, int lid, int qp, int qkey);
-
-Description: Set the given 'portid' fields using the 'lid', 'qp' and 'qkey'
-arguments.
-
-Mad fields manipulation functions:
-
-mad_get_field:
-
-Synopsis:
- uint32 mad_get_field(void *buf, int base_offset, int field);
-
-Description: Return the value of 'field' from the mad buffer specified by
-'buf' and the offset 'base_offset' within. The result is in host order.
-
-See also:
- ib_mad_f fields array, model of operation
-
-mad_set_field:
-
-Synopsis:
- void mad_set_field(void *buf, int base_offs, int field, uint32 val);
-
-Description: Set the value of 'field' in the mad buffer specified by 'buf'
-and the offset 'base_offset' within, using host ordered 'val'.
-
-See also:
- ib_mad_f fields array, model of operation
-
-mad_get_field64:
-
-Synopsis:
- uint64 mad_get_field64(void *buf, int base_offs, int field);
-
-Description: Same as mad_get_field, but for 64 bit fields.
-
-mad_set_field64:
-
-Synopsis:
- void mad_set_field64(void *buf, int base_offs,
- int field, uint64 val);
-
-Description: Same as mad_set_field, but for 64 bit fields.
-
-mad_set_array:
-
-Synopsis:
- void mad_set_array(void *buf, int base_offs, int field, void *val);
-
-Description: Same as mad_get_field, but for opaque byte arrays.
-
-mad_get_array:
-
-Synopsis:
- void mad_get_array(void *buf, int base_offs, int field, void *val);
-
-Description: Same as mad_set_field, but for opaque byte arrays.
-
-mad_decode_field:
-
-Synopsis:
- void mad_decode_field(uint8 *buf, int field, void *val);
-
-Description: Decode 'field' within the mad buffer specified by 'buf' and
-return it in 'val'. The result is in host order. Note that the buffer pointer
-by 'val' must be big enough to contain the value.
-
-See also:
- ib_mad_f fields array, model of operation
-
-mad_encode_field:
-
-Synopsis:
- void mad_encode_field(uint8 *buf, int field, void *val);
-
-Description: Encode the 'field' within the mad buffer specified by 'buf'
-using the host ordered value 'val'.
-
-See also:
- ib_mad_f fields array, model of operation
-
-mad_encode:
-
-Synopsis:
- void * mad_encode(void *buf, ib_rpc_t *rpc,
- ib_dr_path_t *drpath, void *data);
-Description: Encode an outgoing mad headers in 'buf' using the given 'rpc',
-the optional direct routed address 'drpath', and the optional payload
-'data'. Return a pointer to the first byte after the mad image, or null
-on errors.
-
-mad_trid:
-
-Synopsis:
- uint64 mad_trid(void);
-
-Description: Set the given 'portid' fields using the 'lid', 'qp' and 'qkey'
-
-mad_build_pkt:
-
-Synopsis:
- int mad_build_pkt(void *umad, ib_rpc_t *rpc, ib_portid_t *dport,
- ib_rmpp_hdr_t *rmpp, void *data);
-
-Description: Encode a mad in the buffer 'umad' given the structures 'rpc',
-'dport', the optional 'rmpp' structure and the payload 'data'. Return
-number of encode bytes or a negative number if failed.
-
-Dump functions:
-
-mad_print_field:
-
-Synopsis:
- int mad_print_field(int field, char *name, void *val);
-
-Description: Print a human readable format of the 'field' given the value
-'val' to the standard output. If 'name' is non-null, it is printed as the
-field name. Otherwise the default field name is used. Return the number of
-printed bytes.
-
-See also:
- ib_mad_f fields array, model of operation
-
-mad_dump_field:
-
-Synopsis:
- char * mad_dump_field(int field, char *buf, int bufsz, void *val);
-
-Description: Print a human readable format of the 'field' given the value
-'val' to the given buffer 'buf'. The default field name is used. No more than
-'bufsz' bytes are printed. Return the number of printed bytes.
-
-mad_dump_val:
-
-Synopsis:
- char * mad_dump_val(int field, char *buf, int bufsz, void *val);
-
-Description: Same as mad_print_field, but only the field value is printed.
-
-Debugging support:
-
-ibdebug:
-
-Synopsis:
- extern int ibdebug;
-
-Description: Control the library debugging level. The following levels
-are supported:
- 0 - no debugging
- 1 - print debugging information
- 2 - as level 1 but also xdump the umad IO
-
diff --git a/contrib/ofed/management/doc/libibumad.txt b/contrib/ofed/management/doc/libibumad.txt
deleted file mode 100644
index 76809f7..0000000
--- a/contrib/ofed/management/doc/libibumad.txt
+++ /dev/null
@@ -1,392 +0,0 @@
-libibumad:
-
-Overview: libibumad provides the following functionality:
- * Provide information about the IB devices installed. This includes
- list of IB devices names, list of port, device and port
- attributes.
- * Basic user mode mad functions: open/close port,
- register/unregister, send/receive/poll mad, etc.
- * Umad packet helper functions.
- * debugging support.
-
-
-Library objects:
-
-umad_ca: encapsulate an IB device. Identified by CA_NAME.
-
-umad_port: encapsulate an IB port within an IB device. Identified by CA_NAME
- and port number.
-
-ib_umad_addr: IB destination address structure.
-
-portid (int): opened port handle.
-
-agentid (int): mad multiplexing agent handle.
-
-
-Module management functions:
-
-umad_init:
-
-Synopsis:
- int umad_init(void)
-
-Description: library main initialization function. Must be called before any
-other call to the library. Return zero on success, -1 if the infiniband mad
-class can't be opened, or the abi version doesn't match.
-
-umad_done:
-
-Synopsis:
- int umad_done(void)
-
-Description: library main destruction function. library should not be called after calling this function. Return zero on success, -1 on errors.
-
-
-IB devices and ports information functions:
-
-umad_get_cas_names:
-
-Synopsis:
- int umad_get_cas_names(char cas[][UMAD_CA_NAME_LEN], int max);
-
-Description: Fill 'cas' array with up to 'max' local ib devices (CAs) names.
-The return value is the number of entries actually filled, or -1 on errors.
-
-umad_get_ca_portguids:
-
-Synopsis:
- int umad_get_ca_portguids(char *ca_name, uint64_t *portguids,
- int max);
-
-Description: Fill 'portguids' array with up to 'max' port GUIDs belonging the
-specified IB device 'ca_name', or to the default ib device if 'ca_name' is null.
-The return value is the number of entries actually filled, or -1 on errors.
-
-umad_get_ca:
-
-Synopsis:
- int umad_get_ca(char *ca_name, umad_ca_t *ca);
-
-Description: Fill 'ca' structure with the ib device attributes specified by
-'ca_name', or with the default ib device attributes if 'ca_name' is null.
-Return zero on success, -1 on error.
-Note that the library allocates memory for some of the 'ca' fields, and
-therefore umad_release_ca() should be used to free these fields before the
-'ca' structure can be de-allocated.
-
-See also:
- umad_release_ca
-
-umad_release_ca:
-
-Synopsis:
- int umad_release_ca(umad_ca_t *ca);
-
-Description: de-allocated any fields within 'ca' that were allocated by
-umad_get_ca(). Return zero on success, -1 on error.
-
-See also:
- umad_get_ca
-
-umad_get_port:
-
-Synopsis:
- int umad_get_port(char *ca_name, int portnum, umad_port_t *port);
-
-Description: Fill the 'port' structure with the specified ib port attributes
-specified by 'ca_name' and 'portnum', or the default port if 'ca_name' is null
-and 'portnum' is zero. If only one of the 'ca_name' and 'portnum' are specified,
-the other is used as a filter. For example, passing a null ca_name and 2 for the
-portnum means - get a port from any of the local ib devices, as long as it is
-the second port. Return zero on success, -1 on error.
-Note that the library may use some reference scheme to support port caching
-therefore umad_release_port() should be called before the 'port' structure can
-be deallocated.
-
-See also:
- umad_release_port
-
-umad_release_port:
-
-Synopsis:
- int umad_release_port(umad_port_t *port);
-
-Description: Notify the library that the 'port' that was filled by
-umad_get_port() is not required anymore. Return zero on success, -1 on error.
-
-See also:
- umad_get_port
-
-
-Port oriented functions:
-
-umad_open_port:
-
-Synopsis:
- int umad_open_port(char *ca_name, int portnum);
-
-Description: Open the port specified by 'ca_name' and 'portnum' for umad IO.
-The port is selected by the library if not all parameters are provided (see
-umad_get_port() for details). Return non-negative portid handle (int) or
-negative value on errors.
-
-Errors:
- -ENODEV ib device can't be resolved
- -EINVAL port is not valid (bad 'portnum' or no umad device)
- -EIO umad device for this port can't be opened
-
-See also:
- umad_get_port
-
-umad_close_port:
-
-Synopsis:
- int umad_close_port(int portid);
-
-Description: Close the port specified by the handle 'portid'. Return 0 on
-success and -EINVAL if the portid is not a handle to a valid (open) port.
-
-See also:
- umad_open_port
-
-Register/unregister functions:
-
-umad_register:
-
-Synopsis:
- int umad_register(int portid, int mgmt_class,
- int mgmt_version, uint32_t method_mask[4]);
-
-Description: Register to the specified management class and version in the port
-specified by the 'portid' handle. If 'method_mask' array is provided, the caller
-is registered as a replier (server) for the methods having their coresponding
-bit on in the 'method_mask'. If 'method_mask' is null, the caller is registered
-as a mad client, meaning that it can only receive replies on mads it sent
-(solicited mads).
-Return non-negative agent id number on success, and a negative value on errors.
-
-Errors:
- -EINVAL invalid port handle
- -EPERM registration failed
-
-umad_register_oui:
-
-Synopsis:
- int umad_register_oui(int portid, int mgmt_class, uint8_t
-rmpp_version,
- uint8 oui[3], uint32 method_mask[4]);
-
-Description: Register to the specified vendor class range 2, the specified
-oui, and whether rmpp is being used. Otherwise operate similarly to
-umad_register().
-
-Errors:
- -EINVAL invalid port handle or class is not in the vendor class 2 range
- -EPERM registration failed
-
-umad_unregister:
-
-Synopsis:
- int umad_unregister(int portid, int agentid);
-
-Description: Unregister the specified 'agentid' previously registered using
-umad_register() or umad_register_oui(). Returns 0 on success and negative
-value on errors.
-
-Errors:
- -EINVAL invalid port handle or agentid
- * (kernel error codes)
-
-
-Port IO functions:
-
-umad_send:
-
-Synopsis:
- int umad_send(int portid, int agentid, void *umad,
- int timeout_ms, int retries);
-
-Description: Send the specified 'umad' buffer from the port specified by
-'portid' and using the agent specified by 'agentid'. 'timeout_ms' controls
-solicited mads behavior as follows: zero value means not solicited. Positive
-value makes the kernel indicate timeout if the reply is not received within the
-specified value, and return the original buffer in the read channel with
-the status field set (non zero). Negative 'timeout_ms' value makes the kernel
-wait forever for the reply. Returns 0 on success and negative value on errors.
-
-Errors:
- -EINVAL invalid port handle or agentid
- -EIO send operation failed
-
-umad_recv:
-
-Synopsis:
- int umad_recv(int portid, void *umad, int timeout_ms);
-
-Description: Wait up to 'timeout_ms' for a packet to be received from the
-port specified by 'portid'. The packet is copied to the 'umad' buffer.
-Negative 'timeout_ms' value makes the function block until a packet
-is received. Zero 'timeout_ms' indicates a non blocking read.
-Return non negative receiving agentid on success and negative value on errors.
-
-Errors:
- -EINVAL invalid port handle or agentid
- -EIO receive operation failed
- -EWOULDBLOCK non blocking read can't be fulfilled
-
-umad_poll:
-
-Synopsis:
- int umad_poll(int portid, int timeout_ms);
-
-Description: Wait up to 'timeout_ms' for a packet to be received from the
-port specified by 'portid'. Once a packet is ready to be read the function
-returns 0 after that the packet can be read using umad_recv(). Otherwise
--ETIMEDOUT is returned. Note that successfully polling a port does not guarantee
-that the following umad_recv will be non blocking when several threads are using
-the same port. Instead, use timeout_ms parameter of zero to umad_recv to ensure
-a non-blocking read.
-
-Errors:
- -EINVAL invalid port handle or agentid
- -ETIMEDOUT poll operation timed out
- -EIO poll operation failed
-
-umad_get_fd:
-
-Synopsis:
- int umad_get_fd(int portid)
-
-Description: Return umad fd for port specified by 'portid'. Returns fd
-for port or -EINVAL if portid is invalid.
-
-Errors:
- -EINVAL invalid port handle
-
-
-umad helper functions:
-
-umad_get_mad:
-
-Synopsis:
- void * umad_get_mad(void *umad);
-
-Description: Return a pointer to the mad image within the 'umad' buffer.
-
-umad_size:
-
-Synopsis:
- size_t umad_size(void);
-
-Description: Return the size of umad buffer (in bytes).
-
-umad_status:
-
-Synopsis:
- int umad_status(void *umad);
-
-Description: Return the internal 'umad' status field. After a packet is
-received, a non zero status means the packet had a send-timeout
-indication. Otherwise, it is a valid packet.
-
-umad_get_mad_addr:
-
-Synopsis:
- ib_mad_addr_t *umad_get_mad_addr(void *umad);
-
-Description: Return a pointer to the ib_mad_addr struct within 'umad' buffer.
-
-umad_set_grh_net:
-
-Synopsis:
- int umad_set_grh_net(void *umad, void *grh);
-
-Description: set the GRH fields within the 'umad' buffer. The given 'grh'
-fields are expected to be in network order. Returns 0 on success, -1 on errors.
-
-BUGS:
- not implemented.
-
-umad_set_grh:
-
-Synopsis:
- int umad_set_grh(void *umad, void *grh);
-
-Description: set the GRH fields within the 'umad' buffer. The given 'grh'
-fields are expected to be in host order. Returns 0 on success, -1 on errors.
-
-umad_set_addr_net:
-
-Synopsis:
- int umad_set_addr_net(void *umad, int dlid, int dqp,
- int sl, int qkey);
-
-Description: Set the mad address fields within the 'umad' buffer using
-the given network ordered fields. Return 0 on success, -1 on errors.
-
-umad_set_addr:
-
-Synopsis:
- int umad_set_addr(void *umad, int dlid, int dqp, int sl, int qkey);
-
-Description: Set the mad address fields within the 'umad' buffer using
-the given host ordered fields. Return 0 on success, -1 on errors.
-
-umad_set_pkey:
-
-Synopsis:
- int umad_set_pkey(void *umad, int pkey_index);
-
-Description: Set the pkey within the 'umad' buffer. Return 0 on success,
--1 on errors.
-
-BUGS:
- not implemented.
-
-umad_alloc:
-
-Synopsis:
- void *umad_alloc(int num);
-
-Description: Allocate memory for 'num' umad buffers array. Return null if
-out of memory.
-
-umad_free:
-
-Synopsis:
- void umad_free(void *umad);
-
-Description: Deallocate memory previously allocated with uamd_alloc().
-
-See also:
- umad_alloc
-
-
-Debugging support functions:
-
-umad_debug:
-
-Synopsis:
- int umad_debug(int level);
-
-Description: Set the library internal debugging level to 'level'. The following
-debugging levels are supported: 0 - no debugging (the default),
-1 - basic debugging information, 2 - verbose debugging. Negative values are
-ignored. Returns the new level. Note that the current debugging level can
-be queried by passing negative values.
-
-umad_addr_dump:
-
-Synopsis:
- void umad_addr_dump(ib_mad_addr_t *addr);
-
-Description: Dump the given 'addr' structure to the stderr.
-
-umad_dump:
-
-Synopsis:
- void umad_dump(void *umad);
-
-Description: Dump the given 'umad' buffer to the stderr.
-
diff --git a/contrib/ofed/management/gen_chlog.sh b/contrib/ofed/management/gen_chlog.sh
deleted file mode 100755
index bd1dbd8..0000000
--- a/contrib/ofed/management/gen_chlog.sh
+++ /dev/null
@@ -1,74 +0,0 @@
-#!/bin/sh
-
-usage()
-{
- echo "Usage: $0 [--spec] <target>"
- exit 2
-}
-
-test -z "$1" && usage
-
-if [ "$1" = "--spec" ] ; then
- spec_format=1
- shift
- test -z "$1" && usage
-fi
-
-TARGET=$1
-
-GIT_DIR=`git rev-parse --git-dir 2>/dev/null`
-
-test -z "$GIT_DIR" && usage
-
-
-export GIT_DIR
-export GIT_PAGER=""
-export PAGER=""
-
-
-mkchlog()
-{
- target=$1
- format=$2
-
- prev_tag=""
-
- for tag in `git tag -l ${target}-'*'` ; do
- obj=`git cat-file tag $tag | awk '/^object /{print $2}'`
- base=`git merge-base $obj HEAD`
- if [ -z "$base" -o "$base" != $obj ] ; then
- continue
- fi
- all_vers="$prev_tag$tag $all_vers"
- prev_tag=$tag..
- done
-
- if [ -z "$prev_tag" ] ; then
- all_vers=HEAD
- else
- all_vers="${prev_tag}HEAD $all_vers"
- fi
-
- for ver in $all_vers ; do
- log_out=`git log $ver -- $target`
- if [ -z "$log_out" ] ; then
- continue
- fi
- ver_name=`echo $ver | sed -e 's/^.*\.\.//'`
- echo ""
- echo "** Version: $ver_name"
- echo ""
- git log --no-merges "${format}" $ver -- $target
- prev_t=$tag..
- done
-}
-
-
-if [ -z "$spec_format" ] ; then
- mkchlog $TARGET --pretty=format:"%ad %an%n%H%n%n* %s%n" \
- | sed -e 's/^\* /\t* /'
-else
- echo "%changelog"
- mkchlog $TARGET --pretty=format:"- %ad %an: %s"
- echo ""
-fi
diff --git a/contrib/ofed/management/gen_ver.sh b/contrib/ofed/management/gen_ver.sh
deleted file mode 100755
index 93882d4..0000000
--- a/contrib/ofed/management/gen_ver.sh
+++ /dev/null
@@ -1,38 +0,0 @@
-#!/bin/sh
-#
-# This generates a version string which includes recent version as
-# specified in correspondent sub project's configure.in file, plus
-# git revision abbreviation in the case if sub-project HEAD is different
-# from recent tag, plus "-dirty" suffix if local uncommitted changes are
-# in the sub project tree.
-#
-
-usage()
-{
- echo "Usage: $0 <target>"
- exit 2
-}
-
-test -z "$1" && usage
-
-package=$1
-
-cd `dirname $0`
-
-conf_file=$package/configure.in
-version=`cat $conf_file | sed -ne '/AC_INIT.*'$package'.*/s/^AC_INIT.*'$package', \(.*\),.*$/\1/p'`
-
-git diff --quiet $package-$version..HEAD -- $package > /dev/null 2>&1
-if [ $? -eq 1 ] ; then
- abbr=`git rev-parse --short --verify HEAD 2>/dev/null`
- if [ ! -z "$abbr" ] ; then
- version="${version}_${abbr}"
- fi
-fi
-
-git diff-index --quiet HEAD -- $package > /dev/null 2>&1
-if [ $? -eq 1 ] ; then
- version="${version}_dirty"
-fi
-
-echo $version
diff --git a/contrib/ofed/management/infiniband-diags/COPYING b/contrib/ofed/management/infiniband-diags/COPYING
deleted file mode 100644
index a017728..0000000
--- a/contrib/ofed/management/infiniband-diags/COPYING
+++ /dev/null
@@ -1,384 +0,0 @@
-This software with the exception of OpenSM is available to you
-under a choice of one of two licenses. You may chose to be
-licensed under the terms of the the OpenIB.org BSD license or
-the GNU General Public License (GPL) Version 2, both included
-below.
-
-OpenSM is licensed under either GNU General Public License (GPL)
-Version 2, or Intel BSD + Patent license. See OpenSM for the
-specific language for the latter licensing terms.
-
-
-Copyright (c) 2004, 2005 Voltaire, Inc. All rights reserved.
-
-==================================================================
-
- OpenIB.org BSD license
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions
-are met:
-
- * Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
-
- * Redistributions in binary form must reproduce the above
- copyright notice, this list of conditions and the following
- disclaimer in the documentation and/or other materials provided
- with the distribution.
-
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
-FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
-COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
-INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
-BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
-LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
-CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
-ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-POSSIBILITY OF SUCH DAMAGE.
-
-==================================================================
-
- GNU GENERAL PUBLIC LICENSE
- Version 2, June 1991
-
- Copyright (C) 1989, 1991 Free Software Foundation, Inc.
- 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- Everyone is permitted to copy and distribute verbatim copies
- of this license document, but changing it is not allowed.
-
- Preamble
-
- The licenses for most software are designed to take away your
-freedom to share and change it. By contrast, the GNU General Public
-License is intended to guarantee your freedom to share and change free
-software--to make sure the software is free for all its users. This
-General Public License applies to most of the Free Software
-Foundation's software and to any other program whose authors commit to
-using it. (Some other Free Software Foundation software is covered by
-the GNU Library General Public License instead.) You can apply it to
-your programs, too.
-
- When we speak of free software, we are referring to freedom, not
-price. Our General Public Licenses are designed to make sure that you
-have the freedom to distribute copies of free software (and charge for
-this service if you wish), that you receive source code or can get it
-if you want it, that you can change the software or use pieces of it
-in new free programs; and that you know you can do these things.
-
- To protect your rights, we need to make restrictions that forbid
-anyone to deny you these rights or to ask you to surrender the rights.
-These restrictions translate to certain responsibilities for you if you
-distribute copies of the software, or if you modify it.
-
- For example, if you distribute copies of such a program, whether
-gratis or for a fee, you must give the recipients all the rights that
-you have. You must make sure that they, too, receive or can get the
-source code. And you must show them these terms so they know their
-rights.
-
- We protect your rights with two steps: (1) copyright the software, and
-(2) offer you this license which gives you legal permission to copy,
-distribute and/or modify the software.
-
- Also, for each author's protection and ours, we want to make certain
-that everyone understands that there is no warranty for this free
-software. If the software is modified by someone else and passed on, we
-want its recipients to know that what they have is not the original, so
-that any problems introduced by others will not reflect on the original
-authors' reputations.
-
- Finally, any free program is threatened constantly by software
-patents. We wish to avoid the danger that redistributors of a free
-program will individually obtain patent licenses, in effect making the
-program proprietary. To prevent this, we have made it clear that any
-patent must be licensed for everyone's free use or not licensed at all.
-
- The precise terms and conditions for copying, distribution and
-modification follow.
-
- GNU GENERAL PUBLIC LICENSE
- TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
-
- 0. This License applies to any program or other work which contains
-a notice placed by the copyright holder saying it may be distributed
-under the terms of this General Public License. The "Program", below,
-refers to any such program or work, and a "work based on the Program"
-means either the Program or any derivative work under copyright law:
-that is to say, a work containing the Program or a portion of it,
-either verbatim or with modifications and/or translated into another
-language. (Hereinafter, translation is included without limitation in
-the term "modification".) Each licensee is addressed as "you".
-
-Activities other than copying, distribution and modification are not
-covered by this License; they are outside its scope. The act of
-running the Program is not restricted, and the output from the Program
-is covered only if its contents constitute a work based on the
-Program (independent of having been made by running the Program).
-Whether that is true depends on what the Program does.
-
- 1. You may copy and distribute verbatim copies of the Program's
-source code as you receive it, in any medium, provided that you
-conspicuously and appropriately publish on each copy an appropriate
-copyright notice and disclaimer of warranty; keep intact all the
-notices that refer to this License and to the absence of any warranty;
-and give any other recipients of the Program a copy of this License
-along with the Program.
-
-You may charge a fee for the physical act of transferring a copy, and
-you may at your option offer warranty protection in exchange for a fee.
-
- 2. You may modify your copy or copies of the Program or any portion
-of it, thus forming a work based on the Program, and copy and
-distribute such modifications or work under the terms of Section 1
-above, provided that you also meet all of these conditions:
-
- a) You must cause the modified files to carry prominent notices
- stating that you changed the files and the date of any change.
-
- b) You must cause any work that you distribute or publish, that in
- whole or in part contains or is derived from the Program or any
- part thereof, to be licensed as a whole at no charge to all third
- parties under the terms of this License.
-
- c) If the modified program normally reads commands interactively
- when run, you must cause it, when started running for such
- interactive use in the most ordinary way, to print or display an
- announcement including an appropriate copyright notice and a
- notice that there is no warranty (or else, saying that you provide
- a warranty) and that users may redistribute the program under
- these conditions, and telling the user how to view a copy of this
- License. (Exception: if the Program itself is interactive but
- does not normally print such an announcement, your work based on
- the Program is not required to print an announcement.)
-
-These requirements apply to the modified work as a whole. If
-identifiable sections of that work are not derived from the Program,
-and can be reasonably considered independent and separate works in
-themselves, then this License, and its terms, do not apply to those
-sections when you distribute them as separate works. But when you
-distribute the same sections as part of a whole which is a work based
-on the Program, the distribution of the whole must be on the terms of
-this License, whose permissions for other licensees extend to the
-entire whole, and thus to each and every part regardless of who wrote it.
-
-Thus, it is not the intent of this section to claim rights or contest
-your rights to work written entirely by you; rather, the intent is to
-exercise the right to control the distribution of derivative or
-collective works based on the Program.
-
-In addition, mere aggregation of another work not based on the Program
-with the Program (or with a work based on the Program) on a volume of
-a storage or distribution medium does not bring the other work under
-the scope of this License.
-
- 3. You may copy and distribute the Program (or a work based on it,
-under Section 2) in object code or executable form under the terms of
-Sections 1 and 2 above provided that you also do one of the following:
-
- a) Accompany it with the complete corresponding machine-readable
- source code, which must be distributed under the terms of Sections
- 1 and 2 above on a medium customarily used for software interchange; or,
-
- b) Accompany it with a written offer, valid for at least three
- years, to give any third party, for a charge no more than your
- cost of physically performing source distribution, a complete
- machine-readable copy of the corresponding source code, to be
- distributed under the terms of Sections 1 and 2 above on a medium
- customarily used for software interchange; or,
-
- c) Accompany it with the information you received as to the offer
- to distribute corresponding source code. (This alternative is
- allowed only for noncommercial distribution and only if you
- received the program in object code or executable form with such
- an offer, in accord with Subsection b above.)
-
-The source code for a work means the preferred form of the work for
-making modifications to it. For an executable work, complete source
-code means all the source code for all modules it contains, plus any
-associated interface definition files, plus the scripts used to
-control compilation and installation of the executable. However, as a
-special exception, the source code distributed need not include
-anything that is normally distributed (in either source or binary
-form) with the major components (compiler, kernel, and so on) of the
-operating system on which the executable runs, unless that component
-itself accompanies the executable.
-
-If distribution of executable or object code is made by offering
-access to copy from a designated place, then offering equivalent
-access to copy the source code from the same place counts as
-distribution of the source code, even though third parties are not
-compelled to copy the source along with the object code.
-
- 4. You may not copy, modify, sublicense, or distribute the Program
-except as expressly provided under this License. Any attempt
-otherwise to copy, modify, sublicense or distribute the Program is
-void, and will automatically terminate your rights under this License.
-However, parties who have received copies, or rights, from you under
-this License will not have their licenses terminated so long as such
-parties remain in full compliance.
-
- 5. You are not required to accept this License, since you have not
-signed it. However, nothing else grants you permission to modify or
-distribute the Program or its derivative works. These actions are
-prohibited by law if you do not accept this License. Therefore, by
-modifying or distributing the Program (or any work based on the
-Program), you indicate your acceptance of this License to do so, and
-all its terms and conditions for copying, distributing or modifying
-the Program or works based on it.
-
- 6. Each time you redistribute the Program (or any work based on the
-Program), the recipient automatically receives a license from the
-original licensor to copy, distribute or modify the Program subject to
-these terms and conditions. You may not impose any further
-restrictions on the recipients' exercise of the rights granted herein.
-You are not responsible for enforcing compliance by third parties to
-this License.
-
- 7. If, as a consequence of a court judgment or allegation of patent
-infringement or for any other reason (not limited to patent issues),
-conditions are imposed on you (whether by court order, agreement or
-otherwise) that contradict the conditions of this License, they do not
-excuse you from the conditions of this License. If you cannot
-distribute so as to satisfy simultaneously your obligations under this
-License and any other pertinent obligations, then as a consequence you
-may not distribute the Program at all. For example, if a patent
-license would not permit royalty-free redistribution of the Program by
-all those who receive copies directly or indirectly through you, then
-the only way you could satisfy both it and this License would be to
-refrain entirely from distribution of the Program.
-
-If any portion of this section is held invalid or unenforceable under
-any particular circumstance, the balance of the section is intended to
-apply and the section as a whole is intended to apply in other
-circumstances.
-
-It is not the purpose of this section to induce you to infringe any
-patents or other property right claims or to contest validity of any
-such claims; this section has the sole purpose of protecting the
-integrity of the free software distribution system, which is
-implemented by public license practices. Many people have made
-generous contributions to the wide range of software distributed
-through that system in reliance on consistent application of that
-system; it is up to the author/donor to decide if he or she is willing
-to distribute software through any other system and a licensee cannot
-impose that choice.
-
-This section is intended to make thoroughly clear what is believed to
-be a consequence of the rest of this License.
-
- 8. If the distribution and/or use of the Program is restricted in
-certain countries either by patents or by copyrighted interfaces, the
-original copyright holder who places the Program under this License
-may add an explicit geographical distribution limitation excluding
-those countries, so that distribution is permitted only in or among
-countries not thus excluded. In such case, this License incorporates
-the limitation as if written in the body of this License.
-
- 9. The Free Software Foundation may publish revised and/or new versions
-of the General Public License from time to time. Such new versions will
-be similar in spirit to the present version, but may differ in detail to
-address new problems or concerns.
-
-Each version is given a distinguishing version number. If the Program
-specifies a version number of this License which applies to it and "any
-later version", you have the option of following the terms and conditions
-either of that version or of any later version published by the Free
-Software Foundation. If the Program does not specify a version number of
-this License, you may choose any version ever published by the Free Software
-Foundation.
-
- 10. If you wish to incorporate parts of the Program into other free
-programs whose distribution conditions are different, write to the author
-to ask for permission. For software which is copyrighted by the Free
-Software Foundation, write to the Free Software Foundation; we sometimes
-make exceptions for this. Our decision will be guided by the two goals
-of preserving the free status of all derivatives of our free software and
-of promoting the sharing and reuse of software generally.
-
- NO WARRANTY
-
- 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
-FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
-OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
-PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
-OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
-MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
-TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
-PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
-REPAIR OR CORRECTION.
-
- 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
-WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
-REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
-INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
-OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
-TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
-YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
-PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
-POSSIBILITY OF SUCH DAMAGES.
-
- END OF TERMS AND CONDITIONS
-
- How to Apply These Terms to Your New Programs
-
- If you develop a new program, and you want it to be of the greatest
-possible use to the public, the best way to achieve this is to make it
-free software which everyone can redistribute and change under these terms.
-
- To do so, attach the following notices to the program. It is safest
-to attach them to the start of each source file to most effectively
-convey the exclusion of warranty; and each file should have at least
-the "copyright" line and a pointer to where the full notice is found.
-
- <one line to give the program's name and a brief idea of what it does.>
- Copyright (C) <year> <name of author>
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program 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 this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-
-Also add information on how to contact you by electronic and paper mail.
-
-If the program is interactive, make it output a short notice like this
-when it starts in an interactive mode:
-
- Gnomovision version 69, Copyright (C) year name of author
- Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
- This is free software, and you are welcome to redistribute it
- under certain conditions; type `show c' for details.
-
-The hypothetical commands `show w' and `show c' should show the appropriate
-parts of the General Public License. Of course, the commands you use may
-be called something other than `show w' and `show c'; they could even be
-mouse-clicks or menu items--whatever suits your program.
-
-You should also get your employer (if you work as a programmer) or your
-school, if any, to sign a "copyright disclaimer" for the program, if
-necessary. Here is a sample; alter the names:
-
- Yoyodyne, Inc., hereby disclaims all copyright interest in the program
- `Gnomovision' (which makes passes at compilers) written by James Hacker.
-
- <signature of Ty Coon>, 1 April 1989
- Ty Coon, President of Vice
-
-This General Public License does not permit incorporating your program into
-proprietary programs. If your program is a subroutine library, you may
-consider it more useful to permit linking proprietary applications with the
-library. If this is what you want to do, use the GNU Library General
-Public License instead of this License.
diff --git a/contrib/ofed/management/infiniband-diags/ChangeLog b/contrib/ofed/management/infiniband-diags/ChangeLog
deleted file mode 100644
index 6add52a..0000000
--- a/contrib/ofed/management/infiniband-diags/ChangeLog
+++ /dev/null
@@ -1,470 +0,0 @@
-2007-08-09 Ira Weiny <weiny2@llnl.gov>
-
- * scripts/set_mthca_nodedesc.sh: change to set_nodedesc.sh
- * scripts/set_mthca_nodedesc.sh: attempt to set nodedesc on all
- HCA's found in sysfs
-
-2007-07-10 Hal Rosenstock <halr@voltaire.com>
-
- * 1.3.1 release of infiniband-diags
-
-2007-06-20 Hal Rosenstock <halr@voltaire.com>
-
- * src/ibaddr.c, src/ibping.c, src/ibportstate.c,
- src/ibsysstat.c, src/perfquery.c, src/sminfo.c,
- src/smpquery.c, src/vendstat.c, Makefile.am:
- Use diag common code ib_error routine
-
-2007-06-18 Hal Rosenstock <halr@voltaire.com>
-
- * man/ibaddr.8: Improve description
-
-2007-06-04 Hal Rosenstock <halr@voltaire.com>
-
- * include/ibnetdiscover.h, src/ibnetdiscover.c,
- man/ibnetdiscover.8: Add link width and speed to topology
- file output
-
-2007-06-02 Hal Rosenstock <halr@voltaire.com>
-
- * man/ibnetdiscover.8: Add topology file format section
-
-2007-06-01 Hal Rosenstock <halr@voltaire.com>
-
- * man/ibnetdiscover.8: Add grouping information
-
- * include/ibnetdiscover.h, src/ibnetdiscover.c: Fix
- list by nodetype operations
-
- * src/ibnetdiscover.c, man/ibnetdiscover.8: Add support
- for -R(outer_list)
-
- * Makefile.am: Add ibidsverify
-
- * scripts/ibidsverify.pl, man/ibidsverify.8: Add script
- and man page for ibidsverify
-
-2007-05-31 Hal Rosenstock <halr@voltaire.com>
-
- * man/ibprintca.8, man/ibprintswitch.8, man/ibprintrt.8:
- Add description of list capability
-
- * Makefile.am, configure.in: Add ibdatacounters
-
- * scripts/ibdatacounters.in, man/ibdatacounters.8: Add
- script and man page for subnet wide data counters
-
- * configure.in: Change IBSCRIPTPATH from bindir to sbindir
-
-2007-05-30 Hal Rosenstock <halr@voltaire.com>
-
- * Makefile.am, configure.in: Add ibrouters and ibprintrt.pl
-
- * scripts/ibrouters.in, scripts/ibprintrt.pl,
- man/ibrouters.8, man/ibprintrt.8: Add scripts and man pages
- for display of IB routers
-
- * scripts/ibqueryerrors.pl: Add GUID to output line for ports
-
- * scripts/ibcheckerrs.in, scripts/ibcheckport.in,
- scripts/ibcheckportstate.in, scripts/ibcheckportwidth.in,
- scripts/ibdatacounts.in: Add lid and port into verbose output
-
- * scripts/ibcheckerrs.in, scripts/ibcheckport.in,
- scripts/ibdatacounts.in: Change portnum to port in output
-
- * Makefile.am, configure.in: Add ibdatacounts
-
- * scripts/ibdatacounts.in, man/ibdatacounts.8: Add script
- to display only data counters and associated man page
-
-2007-05-26 Hal Rosenstock <halr@voltaire.com>
-
- * scripts/IBswcountlimits.pm: Fix node description parsing
- for switches
-
- * scripts/iblinkinfo.pl: Add peer port link width and speed
- validation
-
-2007-05-25 Hal Rosenstock <halr@voltaire.com>
-
- * scripts/IBswcountlimits.pm: Add support for routers
-
- * scripts/iblinkinfo.pl: Display remote LID with peer port info
-
- * scripts/IBswcountlimits.pm: Add support for rem_lid in
- get_link_ends subroutine
-
- * src/ibportstate.c: Handle peer ports at 1x that
- should be wider and 2.5 Gbps that should be faster
-
- * src/ibportstate.c: Add LinkSpeed/Width related components
- to output
-
-2007-05-24 Hal Rosenstock <halr@voltaire.com>
-
- * scripts/ibprintca.pl: Add support for routers
-
-2007-05-23 Hal Rosenstock <halr@voltaire.com>
-
- * scripts/ibcheckerrors.in, scripts/ibchecknet.in,
- scripts/ibcheckstate.in, scripts/ibcheckwidth.in,
- scripts/ibclearcounters.in, scripts/ibclearerrors.in,
- scripts/ibfindnodesusing.in, scripts/IBswcountlimits.pm:
- Add support for routers
-
-2007-05-09 Hal Rosenstock <halr@voltaire.com>
-
- * src/grouping.c: Eliminate conditional compilation
- based on WORDSIZE
-
-2007-05-08 Hal Rosenstock <halr@voltaire.com>
-
- * src/ibnetdiscover.c: Bumped build version
-
- * include/grouping.h, src/grouping.c: Added support
- for ISR2012 and ISR2004
-
-2007-04-27 Ira K. Weiny <weiny2@llnl.gov>
-
- * scripts/IBswcountlimits.pm, scripts/ibfindnodesusing.pl,
- scripts/ibprintca.pl, scripts/ibprintswitch.pl,
- scripts/ibqueryerrors.pl, scripts/ibswportwatch.pl:
- Remove all uses of "/tmp" from perl diags
-
-2007-04-14 Albert L. Chu <chu11@llnl.gov>
-
- * src/saquery.c, man/saquery.8: Add switch map support
- (for -O and -U options)
-
- * man/ibtracert.8: Improve man page formatting
-
-2007-04-04 Hal Rosenstock <halr@voltaire.com>
-
- * src/saquery.c, man/saquery.8: Add support for isSMdisabled
- into -s query
-
-2007-04-02 Albert L. Chu <chu11@llnl.gov>
-
- * src/saquery.c, man/saquery.8: Add get name queries (-O and -U)
-
- * src/saquery.c: Add name input checks
-
-2007-03-29 Hal Rosenstock <halr@voltaire.com>
-
- * man/perfquery.8: Add note on Data components being octets
- divided by 4 rather than just octets
-
- * scripts/IBswcountlimits.pm, scripts/ibcheckerrs.in: Changed
- due to libibmad change (Xmt/RcvBytes now being Xmt/RcvData)
-
-2007-03-29 Hal Rosenstock <halr@voltaire.com>
-
- * 1.3.0 release of openib-diags
-
-2007-03-21 Albert L. Chu <chu11@llnl.gov>
-
- * scripts/IBswcountlimits.pm: Add some extra debug information
-
-2007-03-21 Hal Rosenstock <halr@voltaire.com>
-
- * src/ibtracert.c: Send normal output to stdout rather than stderr
-
- * src/ibdiag_common.c: Don't truncate NodeDescriptions with
- ctl characters
-
-2007=03-20 Hal Rosenstock <halr@voltaire.com>
-
- * src/ibnetdiscover.c: Chassis 0 is not a chassis
- Caused Cisco SFS7000 to be reported as a chassis
-
-2007-03-15 Hal Rosenstock <halr@voltaire.com>
-
- * src/smpquery.c: Modified guid_info to not use port number
- and not query unneeded SM attributes; also added guid to
- operations supported in help
-
- * man/smpquery.8: Add guid to list of supported operations
-
-2007-03-14 Dotan Barak <dotanb@mellanox.co.il>
-
- * src/smpquery.c: Add support to query the GUIDInfo
- table
-
-2007-03-12 Ira K. Weiny <weiny2@llnl.gov>
-
- * configure.in, diags.spec.in, ibdiag_common.c:
- Allow user to specify a default switch map file
-
-2007-03-09 Hal Rosenstock <halr@voltaire.com>
-
- * 1.2.5 release of openib-diags
-
-2007-03-09 Albert L. Chu <chu11@llnl.gov>
-
- * configure.in, scripts/ibcheck*, scripts/ibclear*,
- scripts/ibhosts, scripts/ibnodes, scripts/ibswitches:
- autoconf support for default pathname in scripts
-
-2007-03-05 Sasha Khapyorsky <sashak@voltaire.com>
-
- * include/ibdiag_common.h, src/ibdiag_common.c,
- src/saquery.c: Clean gcc-4.1 warnings
-
-2007-03-03 Hal Rosenstock <halr@voltaire.com>
-
- * 1.2.4 release of openib-diags
-
-2007-03-02 Ira K. Weiny <weiny2@llnl.gov>
-
- * diags.spec.in: Include set_mthca_nodedesc.sh and dump_lfts.sh
- in the rpm
-
- * Makefile.am, configure.in, diags.spec.in: Fix rpmbuild from make dist
-
-2007-03-01 Hal Rosenstock <halr@voltaire.com>
-
- * 1.2.3 release of openib-diags
-
- * src/saquery.c: Fixed timeout handling
- Also, changed default timeout to 1000 msec
-
-2007-02-27 Hal Rosenstock <halr@voltaire.com>
-
- * 1.2.2 release of openib-diags
-
- * scripts/ibswitches, scripts/ibhosts: Removed extra quotes
- around display of NodeDescription
-
-2007-02-15 Hal Rosenstock <halr@voltaire.com>
-
- * 1.2.1 release of openib-diags
-
- * src/vendstat.c, man/vendstat.8: Initial release
-
- * Makefile.am: Updated for vendstat
-
-2007-02-12 Hal Rosenstock <halr@voltaire.com>
-
- * 1.2.0 release of openib-diags
-
-2007-02-02 Ira Weiny <weiny2@llnl.gov>
-
- * scripts/ibcheckerrors, scripts/ibcheckerrs: Added
- brief option
- * man/ibcheckerrors.8, man/ibcheckerrs.8: Updated
- man pages for brief option
-
-2007-02-02 Hal Rosenstock <halr@voltaire.com>
-
- * src/ibportstate.c, src/sminfo.c, src/smpquery.c:
- Update build version tags
-
-2007-02-01 Hal Rosenstock <halr@voltaire.com>
-
- * src/saquery.c: Add build version option
-
-2007-02-01 Hal Rosenstock <halr@voltaire.com>
-
- * scripts/ibcheckerrors, scripts/ibcheckerrs,
- scripts/ibchecknet, scripts/ibchecknode, scripts/ibcheckport,
- scripts/ibcheckportstate, scripts/ibcheckportwidth,
- scripts/ibcheckstate, scripts/ibcheckwidth,
- scripts/ibclearcounters, scripts/ibclearerrors: Added -N |
- -nocolor to usage displays
-
- * man/ibcheckerrors.8, man/ibcheckerrs.8,
- man/ibchecknet.8, man/ibchecknode.8, man/ibcheckport.8,
- man/ibcheckportstate.8, man/ibcheckportwidth.8,
- man/ibcheckstate.8, man/ibcheckwidth.8,
- man/ibclearcounters.8, man/ibclearerrors.8: Updated
- man pages for nocolor option
-
-2007-02-01 Ira Weiny <weiny2@llnl.gov>
-
- * scripts/ibcheckportwidth, scripts/ibcheckportstate,
- scripts/ibcheckport, scripts/ibcheckerrs: Fix -nocolor
- and -G options
-
- * scripts/ibchecknode: Fix -G option
-
- * scripts/ibchecknet: Fix error return status
-
- * scripts/ibcheckerrors: Add exit code
-
- * scripts/ibcheckerrs: Add nodename to output
-
- * scripts/ibqueryerrors.pl: Reduce the "common" errors
- supressed by -c option; Fix -d option; Remove the use
- of tmp files
-
- * scripts/ibfindnodeusing.pl: Remove use of tmpfile
- for ibroute data
-
- * scripts/ibswportwatch.pl, scripts/IBswcountlimits.pm:
- Add data rate option
-
- * scripts/IBswcountlimits.pm: Fix undefined subroutine error
- in iblinkinfo.pl
-
-2007-01-31 Ira Weiny <weiny2@llnl.gov>
-
- * src/ibtracert.c, man/ibtracert.8,
- src/ibnetdiscover.c, man/ibnetdiscover.8: Add switch-map option
-
- * src/saquery.c: Clean up node descriptions before printing
-
-2007-01-31 Hal Rosenstock <halr@voltaire.com>
-
- * src/saquery.c, man/saquery.8: Clarifications for
- --src-to-dst option
-
- * src/saquery.c: Fix minor memory leak with --src-to-dst option
-
-2007-01-29 Hal Rosenstock <halr@voltaire.com>
-
- * src/ibnetdiscover.c: Add non Voltaire chassis listing back
- into dump_topology
-
-2007-01-29 Ira Weiny <weiny2@llnl.gov>
-
- * src/ibnetdiscover.c: Add peer NodeDescription and LID to output
- Also, for grouping, order Spind and Line Nodes (for Voltaire
- chassis)
-
-2007-01-28 Ira Weiny <weiny2@llnl.gov>
-
- * include/grouping.h, src/grouping.c: Change group_nodes API
- signature to return point to ChassisList rather than void
-
-2007-01-27 Ira Weiny <weiny2@llnl.gov>
-
- * src/ibtracert.c, src/ibroute.c: Add clean_nodedesc function
-
- * src/saquery.c, man/saquery.8: Add additional semantics to -m option
-
-2007-01-26 Hal Rosenstock <halr@voltaire.com>
-
- * src/ibnetdiscover.c: Cosmetic change to some router strings
-
-2007-01-24 Sasha Khapyorsky <sashak@voltaire.com>
-
- * src/ibnetdiscover.c: Minor clean_nodedesc simplification
-
-2007-01-18 Hal Rosenstock <halr@voltaire.com>
-
- * src/perfquery.c: Minor code reorder
-
-2007-01-17 Ira Weiny <weiny2@llnl.gov>
-
- * scripts/iblinkinfo.pl: Add better error handling
-
- * src/saquery.c: Add timeout option to command line
-
-2007-01-16 Hal Rosenstock <halr@voltaire.com>
-
- * man/perfquery.8: Removed unneeded DR description in common options
-
-2007-01-13 Hal Rosenstock <halr@voltaire.com>
-
- * scripts/dump_mfts.sh, man/dump_mfts.8: Add dump_mfts similar
- to dump_lfts
-
-2007-01-12 Hal Rosenstock <halr@voltaire.com>
-
- * man/dump_lfts.8: Minor changes based on existence of dump_mfts
-
-2007-01-04 Hal Rosenstock <halr@voltaire.com>
-
- * scripts/iblinkspeed.pl, man/iblinkspeed.8: Removed as no
- longer needed
-
-2007-01-03 Sasha Khapyorsky <sashak@voltaire.com>
-
- * src/ibnetdiscover.c: Discover improvements
- (memory leaks, ports moving, etc.)
-
-2007-01-02 Ira Weiny <weiny2@llnl.gov>
-
- * scripts/iblinkinfo.pl: Convert iblinkspeed.pl into
- iblinkinfo.pl and add additional capabilities
-
-2006-12-28 Hal Rosenstock <halr@voltaire.com>
-
- * src/ibtracert.c: Add 0x in front of GUID printing
-
-2006-12-28 Sasha Khapyorsky <sashak@voltaire.com>
-
- * src/ibnetdiscover.c: Fix loopback handling
-
- * src/ibnetdiscover.c, src/ibroute.c,
- src/ibtracert.c, src/sminfo.c:
- Eliminate __WORDSIZE ifdefs for printing
-
-2006-12-07 Hal Rosenstock <halr@voltaire.com>
-
- * src/saquery.c, man/saquery.8: Add support for
- querying ServiceRecords
-
-2006-11-21 Hal Rosenstock <halr@voltaire.com>
-
- * src/perfquery.c: Add support for PerfMgt ClassPortInfo:
- CapabilityMask IsExtendedWidthSupported IBA 1.2 erratum
-
-2006-11-20 Sasha Khapyorsky <sashak@voltaire.com>
-
- * src/ibnetdiscover.c, src/ibtracert.c: Fix various
- uses of printf() style functions
-
-2006-10-20 Hal Rosenstock <halr@voltaire.com>
-
- * man/ibportstate.8, man/smpquery.8: Updated man
- pages for DrSLID support.
-
- * src/ibportstate.c: For query operations, add peer
- port checking of link width and speed active.
-
- * src/smpquery.c: Add support for DrSLID.
-
-2006-10-19 Sasha Khapyorsky <sashak@voltaire.com>
-
- * src/ibroute.c: Fix double calculated block value.
-
-2006-10-16 Hal Rosenstock <halr@voltaire.com>
-
- * src/ibnetdiscover.c, src/ibtracert.c: IB router support.
-
-2006-10-09 Ira Weiny <weiny2@llnl.gov>
-
- * man/iblinkspeed.8, man/ibqueryerrors.8,
- man/ibswportwatch.8, man/ibprintswitch.8,
- man/ibprintca.8, man/ibfindnodesusing.8:
- Add man pages for new diag scripts.
-
- * scripts/iblinkspeed.pl, scripts/ibqueryerrors.pl,
- scripts/ibswportwatch.pl, scripts/ibprintswitch.pl,
- scripts/ibprintca.pl, scripts/ibfindnodesusing.pl:
- Add some new diag scripts.
-
- * src/saquery.c: Add additional options for
- NodeDescriptions of CAs only, Unique LID of name specified,
- SA's ClassPortInfo, and PathRecord by src/dest name.
-
-2006-10-03 Hal Rosenstock <halr@voltaire.com>
-
- * man/ibportstate.8: Update ibportstate man page for
- speed operations.
-
- * src/ibportstate.c: Support changing LinkSpeedEnabled
- on any IB port.
-
- * man/ibportstate.8: Update ibportstate man page for
- port reset, enable, and disable operations.
-
- * src/ibportstate.c: Support explicit port reset in
- addition to disable and enable.
-
-2006-09-28 Dotan Barak <dotanb@mellanox.co.il>
-
- * src/saquery.c: Fix compile warning.
-
diff --git a/contrib/ofed/management/infiniband-diags/Makefile.am b/contrib/ofed/management/infiniband-diags/Makefile.am
deleted file mode 100644
index c22ba5e..0000000
--- a/contrib/ofed/management/infiniband-diags/Makefile.am
+++ /dev/null
@@ -1,125 +0,0 @@
-
-INCLUDES = -I$(top_builddir)/include/ -I$(srcdir)/include -I$(includedir) -I$(includedir)/infiniband
-
-if DEBUG
-DBGFLAGS = -ggdb -D_DEBUG_
-else
-DBGFLAGS =
-endif
-
-sbin_PROGRAMS = src/ibaddr src/ibnetdiscover src/ibping src/ibportstate \
- src/ibroute src/ibstat src/ibsysstat src/ibtracert \
- src/perfquery src/sminfo src/smpdump src/smpquery \
- src/saquery src/vendstat
-
-if ENABLE_TEST_UTILS
-sbin_PROGRAMS += src/ibsendtrap src/mcm_rereg_test
-endif
-
-sbin_SCRIPTS = scripts/ibcheckerrs scripts/ibchecknet scripts/ibchecknode \
- scripts/ibcheckport scripts/ibhosts scripts/ibstatus \
- scripts/ibswitches scripts/ibnodes scripts/ibrouters \
- scripts/ibcheckwidth scripts/ibcheckportwidth \
- scripts/ibcheckstate scripts/ibcheckportstate \
- scripts/ibcheckerrors scripts/ibclearerrors \
- scripts/ibclearcounters scripts/ibdatacounts \
- scripts/ibdatacounters scripts/ibdiscover.pl \
- scripts/dump_lfts.sh scripts/dump_mfts.sh \
- scripts/set_nodedesc.sh \
- scripts/ibqueryerrors.pl scripts/ibswportwatch.pl \
- scripts/iblinkinfo.pl scripts/ibprintswitch.pl \
- scripts/ibprintca.pl scripts/ibprintrt.pl \
- scripts/ibfindnodesusing.pl scripts/ibidsverify.pl \
- scripts/check_lft_balance.pl
-
-src_ibaddr_SOURCES = src/ibaddr.c src/ibdiag_common.c
-src_ibaddr_CFLAGS = -Wall $(DBGFLAGS)
-
-src_ibnetdiscover_SOURCES = src/ibnetdiscover.c src/grouping.c src/ibdiag_common.c
-src_ibnetdiscover_CFLAGS = -Wall $(DBGFLAGS)
-src_ibnetdiscover_LDFLAGS = -Wl,--rpath -Wl,$(libdir)
-
-src_ibping_SOURCES = src/ibping.c src/ibdiag_common.c
-src_ibping_CFLAGS = -Wall $(DBGFLAGS)
-
-src_ibportstate_SOURCES = src/ibportstate.c src/ibdiag_common.c
-src_ibportstate_CFLAGS = -Wall $(DBGFLAGS)
-
-src_ibroute_SOURCES = src/ibroute.c src/ibdiag_common.c
-src_ibroute_CFLAGS = -Wall $(DBGFLAGS)
-
-src_ibstat_SOURCES = src/ibstat.c
-src_ibstat_CFLAGS = -Wall $(DBGFLAGS)
-
-src_ibsysstat_SOURCES = src/ibsysstat.c src/ibdiag_common.c
-src_ibsysstat_CFLAGS = -Wall $(DBGFLAGS)
-
-src_ibtracert_SOURCES = src/ibtracert.c src/ibdiag_common.c
-src_ibtracert_CFLAGS = -Wall $(DBGFLAGS)
-src_ibtracert_LDFLAGS = -Wl,--rpath -Wl,$(libdir)
-
-src_perfquery_SOURCES = src/perfquery.c src/ibdiag_common.c
-src_perfquery_CFLAGS = -Wall $(DBGFLAGS)
-
-src_sminfo_SOURCES = src/sminfo.c src/ibdiag_common.c
-src_sminfo_CFLAGS = -Wall $(DBGFLAGS)
-
-src_smpdump_SOURCES = src/smpdump.c
-src_smpdump_CFLAGS = -Wall $(DBGFLAGS)
-
-src_smpquery_SOURCES = src/smpquery.c src/ibdiag_common.c
-src_smpquery_CFLAGS = -Wall $(DBGFLAGS)
-src_smpquery_LDFLAGS = -Wl,--rpath -Wl,$(libdir)
-
-src_saquery_SOURCES = src/saquery.c src/ibdiag_common.c
-src_saquery_CFLAGS = -Wall -DOSM_VENDOR_INTF_OPENIB -DVENDOR_RMPP_SUPPORT -DDUAL_SIDED_RMPP $(DBGFLAGS)
-src_saquery_LDFLAGS = -Wl,--rpath -Wl,$(libdir)
-
-src_ibsendtrap_SOURCES = src/ibsendtrap.c src/ibdiag_common.c
-src_ibsendtrap_CFLAGS = -Wall $(DBGFLAGS)
-src_ibsendtrap_LDFLAGS = -Wl,--rpath -Wl,$(libdir)
-
-src_vendstat_SOURCES = src/vendstat.c src/ibdiag_common.c
-src_vendstat_CFLAGS = -Wall $(DBGFLAGS)
-
-src_mcm_rereg_test_SOURCES = src/mcm_rereg_test.c
-src_mcm_rereg_test_CFLAGS = -Wall $(DBGFLAGS)
-
-man_MANS = man/ibaddr.8 man/ibcheckerrors.8 man/ibcheckerrs.8 \
- man/ibchecknet.8 man/ibchecknode.8 man/ibcheckport.8 \
- man/ibcheckportstate.8 man/ibcheckportwidth.8 man/ibcheckstate.8 \
- man/ibcheckwidth.8 man/ibclearcounters.8 man/ibclearerrors.8 \
- man/ibhosts.8 man/ibnetdiscover.8 man/ibnodes.8 man/ibping.8 \
- man/ibportstate.8 man/ibroute.8 man/ibstat.8 man/ibstatus.8 \
- man/ibswitches.8 man/ibtracert.8 man/perfquery.8 man/sminfo.8 \
- man/smpdump.8 man/smpquery.8 man/saquery.8 man/vendstat.8 \
- man/dump_lfts.8 man/dump_mfts.8 man/ibdiscover.8 man/ibsysstat.8 \
- man/iblinkinfo.8 man/ibqueryerrors.8 man/ibswportwatch.8 \
- man/ibprintswitch.8 man/ibprintca.8 man/ibfindnodesusing.8 \
- man/ibdatacounts.8 man/ibdatacounters.8 \
- man/ibrouters.8 man/ibprintrt.8 man/ibidsverify.8 \
- man/check_lft_balance.8
-
-BUILT_SOURCES = ibdiag_version
-ibdiag_version:
- if [ -x $(top_srcdir)/../gen_ver.sh ] ; then \
- ver_file=$(top_builddir)/include/ibdiag_version.h ; \
- ibdiag_ver=`cat $$ver_file | sed -ne '/#define IBDIAG_VERSION /s/^.*\"\(.*\)\"$$/\1/p'` ; \
- ver=`$(top_srcdir)/../gen_ver.sh $(PACKAGE)` ; \
- if [ $$ver != $$ibdiag_ver ] ; then \
- cat $$ver_file | sed -e '/#define IBDIAG_VERSION /s/\".*\"/\"'$$ver'\"/' > tmp_new_version ; \
- cat tmp_new_version > $$ver_file && rm -f tmp_new_version ; \
- fi ; \
- fi
-
-EXTRA_DIST = scripts include infiniband-diags.spec.in infiniband-diags.spec \
- $(man_MANS) autogen.sh
-
-dist-hook:
- if [ -x $(top_srcdir)/../gen_chlog.sh ] ; then \
- $(top_srcdir)/../gen_chlog.sh $(PACKAGE) > $(distdir)/ChangeLog ; \
- fi
-
-# install this to a default location.
-install-data-hook:
- $(top_srcdir)/config/install-sh -c -m 444 $(top_srcdir)/scripts/IBswcountlimits.pm $(DESTDIR)/$(PERL_INSTALLDIR)/IBswcountlimits.pm
diff --git a/contrib/ofed/management/infiniband-diags/README b/contrib/ofed/management/infiniband-diags/README
deleted file mode 100644
index c251726..0000000
--- a/contrib/ofed/management/infiniband-diags/README
+++ /dev/null
@@ -1,564 +0,0 @@
-Diagnostic Tools
-shaharf@voltaire.com, halr@voltaire.com
-
-General:
-
-Model of operation: All utilities use direct MAD access to perform their
-operations. Operations that require QP 0 mads only, may use direct routed
-mads, and therefore may work even in unconfigured subnets. Almost all
-utilities can operate without accessing the SM, unless GUID to lid translation
-is required.
-
-Dependencies: Most utilities depend on libibmad and libibumad.
- All utilities depend on the ib_umad kernel module.
-
-Multiple port/Multiple CA support: when no IB device or port is specified
- (see the "local umad parameters" below), the libibumad library
- selects the port to use by the following criteria:
- 1. the first port that is ACTIVE.
- 2. if not found, the first port that is UP (physical link up).
-
- If a port and/or CA name is specified, the libibumad library
- attempts to fulfill the user request, and will fail if it is not
- possible.
- For example:
- ibaddr # use the 'best port'
- ibaddr -C mthca1 # pick the best port from mthca1 only.
- ibaddr -P 2 # use the second (active/up) port from the
- first available IB device.
- ibaddr -C mthca0 -P 2 # use the specified port only.
-
-Common options & flags:
- Most diagnostics take the following flags. The exact list of supported
- flags per utility can be found in the usage message and can be shown
- using util_name -h syntax.
-
- # Debugging flags
- -d raise the IB debugging level. May be used
- several times (-ddd or -d -d -d).
- -e show umad send receive errors (timeouts and others)
- -h show the usage message
- -v increase the application verbosity level.
- May be used several times (-vv or -v -v -v)
- -V show the internal version info.
-
- # Addressing flags
- -D use directed path address arguments. The path
- is a comma separated list of out ports.
- Examples:
- "0" # self port
- "0,1,2,1,4" # out via port 1, then 2, ...
- -G use GUID address arguments. In most cases, it is the Port GUID.
- Examples:
- "0x08f1040023"
- -s <smlid> use 'smlid' as the target lid for SA queries.
-
- # Local umad parameters:
- -C <ca_name> use the specified ca_name.
- -P <ca_port> use the specified ca_port.
- -t <timeout_ms> override the default timeout for the solicited mads.
-
-CLI notation: all utilities use the POSIX style notation,
- meaning that all options (flags) must precede all arguments
- (parameters).
-
-
-Utilities descriptions:
-
-1. ibstatus
-
-Description:
-ibstatus is a script which displays basic information obtained from the local
-IB driver. Output includes LID, SMLID, port state, link width active, and port
-physical state.
-
-Syntax:
-ibstatus [-h] [devname[:port]]...
-
-Examples:
- ibstatus # display status of all IB ports
- ibstatus mthca1 # status of mthca1 ports
- ibstatus mthca1:1 mthca0:2 # show status of specified ports
-
-See also:
- ibstat
-
-2. ibstat
-
-Description:
-Similar to the ibstatus utility but implemented as a binary and not a script.
-It has options to list CAs and/or ports.
-
-Syntax:
-ibstat [-d(ebug) -l(ist_of_cas) -p(ort_list) -s(hort)] <ca_name> [portnum]
-
-Examples:
- ibstat # display status of all IB ports
- ibstat mthca1 # status of mthca1 ports
- ibstat mthca1 2 # show status of specified ports
- ibstat -p mthca0 # list the port guids of mthca0
- ibstat -l # list all CA names
-
-See also:
- ibstatus
-
-3. ibroute
-
-Description:
-ibroute uses SMPs to display the forwarding tables (unicast
-(LinearForwardingTable or LFT) or multicast (MulticastForwardingTable or MFT))
-for the specified switch LID and the optional lid (mlid) range.
-The default range is all valid entries in the range 1...FDBTop.
-
-Syntax:
-ibroute [options] <switch_addr> [<startlid> [<endlid>]]]
-
-Non standard flags:
- -a show all lids in range, even invalid entries.
- -n do not try to resolve destinations.
- -M show multicast forwarding tables. In this case the range
- parameters are specifying mlid range.
-
-Examples:
- ibroute 2 # dump all valid entries of switch lid 2
- ibroute 2 15 # dump entries in the range 15...FDBTop.
- ibroute -a 2 10 20 # dump all entries in the range 10..20
- ibroute -n 2 # simple format
- ibroute -M 2 # show multicast tables
-
-See also:
- ibtracert
-
-4. ibtracert
-
-Description:
-ibtracert uses SMPs to trace the path from a source GID/LID to a
-destination GID/LID. Each hop along the path is displayed until the destination
-is reached or a hop does not respond. By using the -m option, multicast path
-tracing can be performed between source and destination nodes.
-
-Syntax:
-ibtracert [options] <src-addr> <dest-addr>
-
-Non standard flags:
- -n simple format; don't show additional information.
- -m <mlid> show the multicast trace of the specified mlid.
-
-Examples:
- ibtracert 2 23 # show trace between lid 2 and 23
- ibtracert -m 0xc000 3 5 # show multicast trace between lid 3 and 5
- for mcast lid 0xc000.
-
-5. smpquery
-
-Description:
-smpquery allows a basic subset of standard SMP queries including the following:
-node info, node description, switch info, port info. Fields are displayed in
-human readable format.
-
-Syntax:
-smpquery [options] <op> <dest_addr> [op_params]
-
-Current supported operations and their parameters:
- nodeinfo <addr>
- nodedesc <addr>
- portinfo <addr> [<portnum>] # default port is zero
- switchinfo <addr>
- pkeys <addr> [<portnum>]
- sl2vl <addr> [<portnum>]
- vlarb <addr> [<portnum>]
-
-Examples:
- smpquery nodeinfo 2 # show nodeinfo for lid 2
- smpquery portinfo 2 5 # show portinfo for lid 2 port 5
-
-6. smpdump
-
-Description:
-smpdump is a general purpose SMP utility which gets SM attributes from a
-specified SMA. The result is dumped in hex by default.
-
-Syntax:
-smpdump [options] <dest_addr> <attr> [mod]
-
-Non standard flags:
- -s show output as string
-
-Examples:
- smpdump -D 0,1,2 0x15 2 # port info, port 2
- smpdump 3 0x15 2 # port info, lid 3 port 2
-
-7. ibaddr
-
-Description:
-ibaddr can be used to show the lid and GID addresses of the specified port,
-or the local port by default.
-Note: this utility can be used as simple address resolver.
-
-Syntax:
-ibaddr [options] [<dest_addr>]
-
-Examples:
- ibaddr # show local address
- ibaddr 2 # show address of the specified port lid
- ibaddr -G 0x8f1040023 # show address of the specified port guid
-
-8. sminfo
-
-Description:
-sminfo issue and dumps the output of a sminfo query in human readable format.
-The target SM is the one listed in the local port info, or the SM specified
-by the optional SM lid or by the SM direct routed path.
-Note: using sminfo for any purposes other then simple query may be very
-dangerous, and may result in a malfunction of the target SM.
-
-Syntax:
-sminfo [options] <sm_lid|sm_dr_path> [sminfo_modifier]
-
-Non standard flags:
- -s <state> # use the specified state in sminfo mad
- -p <priority> # use the specified priority in sminfo mad
- -a <activity> # use the specified activity in sminfo mad
-
-Examples:
- sminfo # show sminfo of SM listed in local portinfo
- sminfo 2 # query SM on port lid 2
-
-9. perfquery
-
-Description:
-perfquery uses PerfMgt GMPs to obtain the PortCounters (basic performance
-and error counters) from the PMA at the node specified. Optionally reset all
-or
-
-Syntax:
-perfquery [options] [<lid|guid> [[port] [reset_mask]]]
-
-Non standard flags:
- -a show aggregated counters for all ports of the destination lid.
- -r reset counters after read.
- -R only reset counters.
-
-Examples:
- perfquery # read local port's performance counters
- perfquery 32 1 # read performance counters from lid 32, port 1
- perfquery -a 32 # read node aggregated performance counters
- perfquery -r 32 1 # read performance counters and reset
- perfquery -R 32 1 # reset performance counters of port 1 only
- perfquery -R -a 32 # reset performance counters of all ports
- perfquery -R 32 2 0xf000 # reset only non-error counters of port 2
-
-10. ibping
-
-Description:
-ibping uses vendor mads to validate connectivity between IB nodes.
-On exit, (IP) ping like output is show. ibping is run as client/server.
-Default is to run as client. Note also that a default ping server is
-implemented within the kernel.
-
-Syntax:
-ibping [options] <dest lid|guid>
-
-Non standard flags:
- -c <count> stop after count packets
- -f flood destination: send packets back to back w/o delay
- -o <oui> use specified OUI number to multiplex vendor mads
- -S start in server mode (do not return)
-
-11. ibnetdiscover
-
-Description:
-ibnetdiscover performs IB subnet discovery and outputs a human readable
-topology file. GUIDs, node types, and port numbers are displayed
-as well as port LIDs and NodeDescriptions. All nodes (and links) are displayed
-(full topology). Optionally this utility can be used to list the current
-connected nodes. The output is printed to the standard output unless a
-topology file is specified.
-
-Syntax:
-ibnetdiscover [options] [<topology-filename>]
-
-Non standard flags:
- -l List of connected nodes
- -H List of connected HCAs
- -S List of connected switches
- -g Grouping
-
-12. ibhosts
-
-Description:
-ibhosts either walks the IB subnet topology or uses an already saved topology
-file and extracts the CA nodes.
-
-Syntax:
-ibhosts [-h] [<topology-file>]
-
-Dependencies:
-ibnetdiscover, ibnetdiscover format
-
-13. ibswitches
-
-Description:
-ibswitches either walks the IB subnet topology or uses an already saved
-topology file and extracts the IB switches.
-
-Syntax:
-ibswitches [-h] [<topology-file>]
-
-Dependencies:
-ibnetdiscover, ibnetdiscover format
-
-14. ibchecknet
-
-Description:
-ibchecknet uses a full topology file that was created by ibnetdiscover,
-scans the network to validate the connectivity and reports errors
-(from port counters).
-
-Syntax:
-ibchecknet [-h] [<topology-file>]
-
-Dependencies:
-ibnetdiscover, ibnetdiscover format, ibchecknode, ibcheckport, ibcheckerrs
-
-15. ibcheckport
-
-Description:
-Check connectivity and do some simple sanity checks for the specified port.
-Port address is lid unless -G option is used to specify a GUID address.
-
-Syntax:
-ibcheckport [-h] [-G] <lid|guid> <port_number>
-
-Example:
- ibcheckport 2 3 # check lid 2 port 3
-
-Dependencies:
-smpquery, smpquery output format, ibaddr
-
-16. ibchecknode
-
-Description:
-Check connectivity and do some simple sanity checks for the specified node.
-Port address is lid unless -G option is used to specify a GUID address.
-
-Syntax:
-ibchecknode [-h] [-G] <lid|guid>
-
-Example:
- ibchecknode 2 # check node via lid 2
-
-Dependencies:
-smpquery, smpquery output format, ibaddr
-
-Usage:
-
-17. ibcheckerrs
-
-Description:
-Check specified port (or node) and report errors that surpassed their predefined
-threshold. Port address is lid unless -G option is used to specify a GUID
-address. The predefined thresholds can be dumped using the -s option, and a
-user defined threshold_file (using the same format as the dump) can be
-specified using the -t <file> option.
-
-Syntax:
-ibcheckerrs [-h] [-G] [-t <threshold_file>] [-s(how_thresholds)] <lid|guid> [<port>]
-
-Examples:
- ibcheckerrs 2 # check aggregated node counter for lid 2
- ibcheckerrs 2 4 # check port counters for lid 2 port 4
- ibcheckerrs -t xxx 2 # check node using xxx threshold file
-
-Dependencies:
-perfquery, perfquery output format, ibaddr
-
-18. ibportstate
-
-Description:
-ibportstate allows the port state and port physical state of an IB port
-to be queried or a switch port to be disabled or enabled.
-
-Syntax:
-ibportstate [-d(ebug) -e(rr_show) -v(erbose) -D(irect) -G(uid) -s smlid
--V(ersion) -C ca_name -P ca_port -t timeout_ms] <dest dr_path|lid|guid>
-<portnum> [<op>]
- supported ops: enable, disable, query
-
-Examples:
- ibportstate 3 1 disable # by lid
- ibportstate -G 0x2C9000100D051 1 enable # by guid
- ibportstate -D 0 1 # by direct route
-
-19. ibcheckwidth
-
-Description:
-ibcheckwidth uses a full topology file that was created by ibnetdiscover,
-scans the network to validate the active link widths and reports any 1x
-links.
-
-Syntax:
-ibcheckwidth [-h] [<topology-file>]
-
-Dependencies:
-ibnetdiscover, ibnetdiscover format, ibchecknode, ibcheckportwidth
-
-20. ibcheckportwidth
-
-Description:
-Check connectivity and check the specified port for 1x link width.
-Port address is lid unless -G option is used to specify a GUID address.
-
-Syntax:
-ibcheckportwidth [-h] [-G] <lid|guid> <port>
-
-Example:
- ibcheckportwidth 2 3 # check lid 2 port 3
-
-Dependencies:
-smpquery, smpquery output format, ibaddr
-
-21. ibcheckstate
-
-Description:
-ibcheckstate uses a full topology file that was created by ibnetdiscover,
-scans the network to validate the port state and port physical state,
-and reports any ports which have a port state other than Active or
-a port physical state other than LinkUp.
-
-Syntax:
-ibcheckstate [-h] [<topology-file>]
-
-Dependencies:
-ibnetdiscover, ibnetdiscover format, ibchecknode, ibcheckportstate
-
-22. ibcheckportstate
-
-Description:
-Check connectivity and check the specified port for proper port state
-(Active) and port physical state (LinkUp).
-Port address is lid unless -G option is used to specify a GUID address.
-
-yntax:
-ibcheckportstate [-h] [-G] <lid|guid> <port_number>
-
-Example:
- ibcheckportstate 2 3 # check lid 2 port 3
-
-Dependencies:
-smpquery, smpquery output format, ibaddr
-
-23. ibcheckerrors
-
-ibcheckerrors uses a full topology file that was created by ibnetdiscover,
-scans the network to validate the connectivity and reports errors
-(from port counters).
-
-Syntax:
-ibnetcheckerrors [-h] [<topology-file>]
-
-Dependencies:
-ibnetdiscover, ibnetdiscover format, ibchecknode, ibcheckport, ibcheckerrs
-
-24. ibdiscover.pl
-
-ibdiscover.pl uses a topology file create by ibnetdiscover and a discover.map
-file which the network administrator creates which indicates the nodes
-to be expected and a ibdiscover.topo file which is the expected connectivity
-and produces a new connectivity file (discover.topo.new) and outputs
-the changes to stdout. The network administrator can choose to replace
-the "old" topo file with the new one or certain changes in.
-
-The syntax of the ibdiscover.map file is:
-<nodeGUID>|port|"Text for node"|<NodeDescription from ibnetdiscover format>
-e.g.
-8f10400410015|8|"ISR 6000"|# SW-6IB4 Voltaire port 0 lid 5
-8f10403960558|2|"HCA 1"|# MT23108 InfiniHost Mellanox Technologies
-
-The syntax of the old and new topo files (ibdiscover.topo and
-ibdiscover.topo.new) are:
-<LocalPort>|<LocalNodeGUID>|<RemotePort>|<RemoteNodeGUID>
-e.g.
-10|5442ba00003080|1|8f10400410015
-
-These topo files are produced by the ibdiscover.pl tool.
-
-Syntax:
-ibnetdiscover | ibdiscover.pl
-
-Dependencies:
-ibnetdiscover, ibnetdiscover format
-
-25. ibnodes
-
-Description:
-ibnodes either walks the IB subnet topology or uses an already saved topology
-file and extracts the IB nodes (CAs and switches).
-
-Syntax:
-ibnodes [<topology-file>]
-
-Dependencies:
-ibnetdiscover, ibnetdiscover format
-
-26. ibclearerrors
-
-Description:
-ibclearerrors clears the PMA error counters in PortCounters by either walking
-the IB subnet topology or using an already saved topology file.
-
-Syntax:
-ibclearerrors [-h] [<topology-file>]
-
-Dependencies:
-ibnetdiscover, ibnetdiscover format, perfquery
-
-27. ibclearcounters
-
-Description:
-ibclearcounters clears the PMA port counters by either walking
-the IB subnet topology or using an already saved topology file.
-
-Syntax:
-ibclearcounters [-h] [<topology-file>]
-
-Dependencies:
-ibnetdiscover, ibnetdiscover format, perfquery
-
-28. saquery
-
-Description:
-Issue some SA queries.
-
-Syntax:
-Usage: saquery [-h -d -P -N -L -G -s -g][<name>]
- Queries node records by default
- -d enable debugging
- -P get PathRecord info
- -N get NodeRecord info
- -L Return just the Lid of the name specified
- -G Return just the Guid of the name specified
- -s Return the PortInfoRecords with isSM capability mask bit on
- -g get multicast group info
-
-Dependencies:
-OpenSM libvendor, OpenSM libopensm, libibumad
-
-29. ibsysstat
-
-Description:
-ibsysstat uses vendor mads to validate connectivity between IB nodes
-and obtain other information about the IB node. ibsysstat is run as
-client/server. Default is to run as client.
-
-Syntax:
-ibsysstat [options] <dest lid|guid> [<op>]
-
-Non standard flags:
- Current supported operations:
- ping - verify connectivity to server (default)
- host - obtain host information from server
- cpu - obtain cpu information from server
- -o <oui> use specified OUI number to multiplex vendor mads
- -S start in server mode (do not return)
-
diff --git a/contrib/ofed/management/infiniband-diags/autogen.sh b/contrib/ofed/management/infiniband-diags/autogen.sh
deleted file mode 100755
index 4827884..0000000
--- a/contrib/ofed/management/infiniband-diags/autogen.sh
+++ /dev/null
@@ -1,11 +0,0 @@
-#! /bin/sh
-
-# create config dir if not exist
-test -d config || mkdir config
-
-set -x
-aclocal -I config
-libtoolize --force --copy
-autoheader
-automake --foreign --add-missing --copy
-autoconf
diff --git a/contrib/ofed/management/infiniband-diags/configure.in b/contrib/ofed/management/infiniband-diags/configure.in
deleted file mode 100644
index d8524f4..0000000
--- a/contrib/ofed/management/infiniband-diags/configure.in
+++ /dev/null
@@ -1,170 +0,0 @@
-dnl Process this file with autoconf to produce a configure script.
-
-AC_PREREQ(2.57)
-AC_INIT(infiniband-diags, 1.5.0, general@lists.openfabrics.org)
-AC_CONFIG_AUX_DIR(config)
-AM_CONFIG_HEADER(config.h)
-AM_INIT_AUTOMAKE
-
-AC_SUBST(RELEASE, ${RELEASE:-unknown})
-AC_SUBST(TARBALL, ${TARBALL:-${PACKAGE}-${VERSION}.tar.gz})
-
-AC_ARG_ENABLE(libcheck, [ --disable-libcheck do not test for presence of ib libraries],
-[ if test x$enableval = xno ; then
- disable_libcheck=yes
- fi
-])
-
-dnl support debug mode
-AC_ARG_ENABLE(debug,
-[ --enable-debug Turn on debug mode],
-[case "${enableval}" in
- yes) debug=true ;;
- no) debug=false ;;
- *) AC_MSG_ERROR(bad value ${enableval} for --enable-debug) ;;
-esac],[debug=false])
-AM_CONDITIONAL(DEBUG, test x$debug = xtrue)
-
-dnl Checks for programs
-AC_PROG_CC
-AC_PROG_LIBTOOL
-
-if test "$disable_libcheck" != "yes"
-then
-dnl Checks for libraries
-AC_CHECK_LIB(ibcommon, sys_read_string, [],
- AC_MSG_ERROR([sys_read_string() not found. diags require libibcommon.]))
-AC_CHECK_LIB(ibumad, umad_init, [],
- AC_MSG_ERROR([umad_init() not found. diags require libibumad.]))
-AC_CHECK_LIB(ibmad, mad_dump_int, [],
- AC_MSG_ERROR([mad_dump_int() not found. diags require libibmad.]))
-AC_CHECK_LIB(ibmad, port_performance_ext_query, [],
- AC_MSG_ERROR([port_performance_ext_query() not found. diags require more recent libibmad.]))
-AC_CHECK_LIB(osmcomp, cl_thread_init, [],
- AC_MSG_ERROR([cl_thread_init() not found. diags require libosmcomp.]))
-AC_CHECK_LIB(osmvendor, osmv_query_sa, [],
- AC_MSG_ERROR([osmv_query_sa() not found. diags require libosmvendor.]), [-lopensm])
-AC_CHECK_LIB(opensm, osm_log_init_v2, [],
- AC_MSG_ERROR([osm_log_init_v2() not found. diags require libopensm.]))
-fi
-
-dnl Checks for header files.
-AC_HEADER_STDC
-AC_CHECK_HEADERS([stdlib.h string.h unistd.h fcntl.h inttypes.h netinet/in.h sys/ioctl.h syslog.h])
-if test "$disable_libcheck" != "yes"
-then
-AC_CHECK_HEADER(infiniband/common.h, [],
- AC_MSG_ERROR([<infiniband/common.h> not found. diags require libibcommon.])
-)
-AC_CHECK_HEADER(infiniband/umad.h, [],
- AC_MSG_ERROR([<infiniband/umad.h> not found. diags require libibumad.])
-)
-AC_CHECK_HEADER(infiniband/mad.h, [],
- AC_MSG_ERROR([<infiniband/mad.h> not found. diags require libibmad.])
-)
-fi
-
-dnl Checks for library functions
-AC_FUNC_ERROR_AT_LINE
-AC_FUNC_VPRINTF
-AC_CHECK_FUNCS([strchr strrchr strtol strtoul memset])
-
-dnl Checks for typedefs, structures, and compiler characteristics.
-AC_C_CONST
-
-dnl Check if we should include test utilities
-AC_MSG_CHECKING(for --enable-test-utils)
-AC_ARG_ENABLE(test-utils,
-[ --enable-test-utils build additional test utilities],
-[case "${enableval}" in
- yes) tutils=yes ;;
- no) tutils=no ;;
- *) AC_MSG_ERROR(bad value ${enableval} for --enable-test-utils) ;;
-esac],[tutils=no])
-AM_CONDITIONAL(ENABLE_TEST_UTILS, test x$tutils = xyes)
-AC_MSG_RESULT(${tutils=no})
-
-dnl Check for perl and perl install location
-AC_MSG_CHECKING(for --with-perl-path )
-AC_ARG_WITH(perl-path,
- AC_HELP_STRING([--with-perl-path=path],
- [define perl location]),
- [ case "$withval" in
- no)
- ;;
- *)
- withperlpath=yes
- PERL=$withval
- ;;
- esac ]
-)
-AC_MSG_RESULT(${withperlpath=no})
-AC_SUBST(PERL)
-
-if test $withperlpath = "no"
-then
- AC_PATH_PROG([PERL], [perl])
-fi
-AC_SUBST(PERL)
-
-AC_MSG_CHECKING(for --with-perl-installdir )
-AC_ARG_WITH(perl-installdir,
- AC_HELP_STRING([--with-perl-installdir=path],
- [define perl install path]),
- [ case "$withval" in
- no)
- ;;
- *)
- withperlinstalldir=yes
- PERL_INSTALLDIR=$withval
- ;;
- esac ]
-)
-AC_MSG_RESULT(${withperlinstalldir=no})
-AC_SUBST(PERL_INSTALLDIR)
-
-if test $withperlinstalldir = "no"
-then
- PERL_INSTALLDIR=`$PERL -e 'use Config; $T=$Config{installsitearch}; print $T;'`
-fi
-AC_SUBST(PERL_INSTALLDIR)
-
-AC_CACHE_CHECK(whether ld accepts --version-script, ac_cv_version_script,
- if test -n "`$LD --help < /dev/null 2>/dev/null | grep version-script`"; then
- ac_cv_version_script=yes
- else
- ac_cv_version_script=no
- fi)
-
-AM_CONDITIONAL(HAVE_LD_VERSION_SCRIPT, test "$ac_cv_version_script" = "yes")
-
-dnl Make appropriate substitution for IB script path
-dnl Must expand nested unquoting
-IBSCRIPTPATH_TMP1="`eval echo ${sbindir}`"
-IBSCRIPTPATH_TMP2="`echo $IBSCRIPTPATH_TMP1 | sed 's/^NONE/$ac_default_prefix/'`"
-IBSCRIPTPATH="`eval echo $IBSCRIPTPATH_TMP2`"
-AC_SUBST(IBSCRIPTPATH)
-
-AC_CONFIG_FILES([\
- Makefile \
- infiniband-diags.spec \
- include/ibdiag_version.h \
- scripts/ibcheckerrors \
- scripts/ibcheckerrs \
- scripts/ibchecknet \
- scripts/ibchecknode \
- scripts/ibcheckport \
- scripts/ibcheckportstate \
- scripts/ibcheckportwidth \
- scripts/ibcheckstate \
- scripts/ibcheckwidth \
- scripts/ibclearcounters \
- scripts/ibclearerrors \
- scripts/ibdatacounts \
- scripts/ibdatacounters \
- scripts/ibhosts \
- scripts/ibnodes \
- scripts/ibswitches \
- scripts/ibrouters
-])
-AC_OUTPUT
diff --git a/contrib/ofed/management/infiniband-diags/include/grouping.h b/contrib/ofed/management/infiniband-diags/include/grouping.h
deleted file mode 100644
index e54efef..0000000
--- a/contrib/ofed/management/infiniband-diags/include/grouping.h
+++ /dev/null
@@ -1,113 +0,0 @@
-/*
- * Copyright (c) 2004-2007 Voltaire Inc. All rights reserved.
- * Copyright (c) 2007 Xsigo Systems Inc. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- */
-
-#ifndef _GROUPING_H_
-#define _GROUPING_H_
-
-/*========================================================*/
-/* FABRIC SCANNER SPECIFIC DATA */
-/*========================================================*/
-
-#define SPINES_MAX_NUM 12
-#define LINES_MAX_NUM 36
-
-typedef struct ChassisList ChassisList;
-typedef struct AllChassisList AllChassisList;
-
-struct ChassisList {
- ChassisList *next;
- uint64_t chassisguid;
- int chassisnum;
- int chassistype;
- int nodecount; /* used for grouping by SystemImageGUID */
- Node *spinenode[SPINES_MAX_NUM + 1];
- Node *linenode[LINES_MAX_NUM + 1];
-};
-
-struct AllChassisList {
- ChassisList *first;
- ChassisList *current;
- ChassisList *last;
-};
-
-/*========================================================*/
-/* CHASSIS RECOGNITION SPECIFIC DATA */
-/*========================================================*/
-
-/* Device IDs */
-#define VTR_DEVID_IB_FC_ROUTER 0x5a00
-#define VTR_DEVID_IB_IP_ROUTER 0x5a01
-#define VTR_DEVID_ISR9600_SPINE 0x5a02
-#define VTR_DEVID_ISR9600_LEAF 0x5a03
-#define VTR_DEVID_HCA1 0x5a04
-#define VTR_DEVID_HCA2 0x5a44
-#define VTR_DEVID_HCA3 0x6278
-#define VTR_DEVID_SW_6IB4 0x5a05
-#define VTR_DEVID_ISR9024 0x5a06
-#define VTR_DEVID_ISR9288 0x5a07
-#define VTR_DEVID_SLB24 0x5a09
-#define VTR_DEVID_SFB12 0x5a08
-#define VTR_DEVID_SFB4 0x5a0b
-#define VTR_DEVID_ISR9024_12 0x5a0c
-#define VTR_DEVID_SLB8 0x5a0d
-#define VTR_DEVID_RLX_SWITCH_BLADE 0x5a20
-#define VTR_DEVID_ISR9024_DDR 0x5a31
-#define VTR_DEVID_SFB12_DDR 0x5a32
-#define VTR_DEVID_SFB4_DDR 0x5a33
-#define VTR_DEVID_SLB24_DDR 0x5a34
-#define VTR_DEVID_SFB2012 0x5a37
-#define VTR_DEVID_SLB2024 0x5a38
-#define VTR_DEVID_ISR2012 0x5a39
-#define VTR_DEVID_SFB2004 0x5a40
-#define VTR_DEVID_ISR2004 0x5a41
-#define VTR_DEVID_SRB2004 0x5a42
-
-enum ChassisType { UNRESOLVED_CT, ISR9288_CT, ISR9096_CT, ISR2012_CT, ISR2004_CT };
-enum ChassisSlot { UNRESOLVED_CS, LINE_CS, SPINE_CS, SRBD_CS };
-
-/*========================================================*/
-/* External interface */
-/*========================================================*/
-
-ChassisList *group_nodes();
-char *portmapstring(Port *port);
-char *get_chassis_type(unsigned char chassistype);
-char *get_chassis_slot(unsigned char chassisslot);
-uint64_t get_chassis_guid(unsigned char chassisnum);
-
-int is_xsigo_guid(uint64_t guid);
-int is_xsigo_tca(uint64_t guid);
-int is_xsigo_hca(uint64_t guid);
-
-#endif /* _GROUPING_H_ */
diff --git a/contrib/ofed/management/infiniband-diags/include/ibdiag_common.h b/contrib/ofed/management/infiniband-diags/include/ibdiag_common.h
deleted file mode 100644
index 39e09d7..0000000
--- a/contrib/ofed/management/infiniband-diags/include/ibdiag_common.h
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * Copyright (c) 2006-2007 The Regents of the University of California.
- * Copyright (c) 2004-2008 Voltaire Inc. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- */
-
-#ifndef _IBDIAG_COMMON_H_
-#define _IBDIAG_COMMON_H_
-
-#include <stdio.h>
-#include <inttypes.h>
-
-extern char *argv0;
-extern int ibdebug;
-
-/*========================================================*/
-/* External interface */
-/*========================================================*/
-
-#undef DEBUG
-#define DEBUG if (ibdebug || verbose) IBWARN
-#define VERBOSE if (ibdebug || verbose > 1) IBWARN
-#define IBERROR(fmt, args...) iberror(__FUNCTION__, fmt, ## args)
-
-void iberror(const char *fn, char *msg, ...);
-
-#include <ibdiag_version.h>
-
-static inline const char* get_build_version(void)
-{
- return "BUILD VERSION: " IBDIAG_VERSION " Build date: " __DATE__ " " __TIME__ ;
-}
-
-#endif /* _IBDIAG_COMMON_H_ */
diff --git a/contrib/ofed/management/infiniband-diags/include/ibdiag_version.h b/contrib/ofed/management/infiniband-diags/include/ibdiag_version.h
deleted file mode 100644
index da9ed51..0000000
--- a/contrib/ofed/management/infiniband-diags/include/ibdiag_version.h
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Copyright (c) 2008 Voltaire Inc. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- */
-
-#ifndef _IBDIAG_VERSION_H_
-#define _IBDIAG_VERSION_H_
-
-#define IBDIAG_VERSION "1.4.4"
-
-#endif /* _IBDIAG_VERSION_H_ */
diff --git a/contrib/ofed/management/infiniband-diags/include/ibdiag_version.h.in b/contrib/ofed/management/infiniband-diags/include/ibdiag_version.h.in
deleted file mode 100644
index 62430c5..0000000
--- a/contrib/ofed/management/infiniband-diags/include/ibdiag_version.h.in
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Copyright (c) 2008 Voltaire Inc. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- */
-
-#ifndef _IBDIAG_VERSION_H_
-#define _IBDIAG_VERSION_H_
-
-#define IBDIAG_VERSION "@VERSION@"
-
-#endif /* _IBDIAG_VERSION_H_ */
diff --git a/contrib/ofed/management/infiniband-diags/include/ibnetdiscover.h b/contrib/ofed/management/infiniband-diags/include/ibnetdiscover.h
deleted file mode 100644
index 0226615..0000000
--- a/contrib/ofed/management/infiniband-diags/include/ibnetdiscover.h
+++ /dev/null
@@ -1,107 +0,0 @@
-/*
- * Copyright (c) 2004-2007 Voltaire Inc. All rights reserved.
- * Copyright (c) 2007 Xsigo Systems Inc. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- */
-
-#ifndef _IBNETDISCOVER_H_
-#define _IBNETDISCOVER_H_
-
-#define MAXHOPS 63
-
-#define CA_NODE 1
-#define SWITCH_NODE 2
-#define ROUTER_NODE 3
-
-#define LIST_CA_NODE (1 << CA_NODE)
-#define LIST_SWITCH_NODE (1 << SWITCH_NODE)
-#define LIST_ROUTER_NODE (1 << ROUTER_NODE)
-
-/* Vendor IDs (for chassis based systems) */
-#define VTR_VENDOR_ID 0x8f1 /* Voltaire */
-#define TS_VENDOR_ID 0x5ad /* Cisco */
-#define SS_VENDOR_ID 0x66a /* InfiniCon */
-#define XS_VENDOR_ID 0x1397 /* Xsigo */
-
-
-typedef struct Port Port;
-typedef struct Node Node;
-typedef struct ChassisRecord ChassisRecord;
-
-struct ChassisRecord {
- ChassisRecord *next;
-
- unsigned char chassisnum;
- unsigned char anafanum;
- unsigned char slotnum;
- unsigned char chassistype;
- unsigned char chassisslot;
-};
-
-struct Port {
- Port *next;
- uint64_t portguid;
- int portnum;
- int lid;
- int lmc;
- int state;
- int physstate;
- int linkwidth;
- int linkspeed;
-
- Node *node;
- Port *remoteport; /* null if SMA */
-};
-
-struct Node {
- Node *htnext;
- Node *dnext;
- Port *ports;
- ib_portid_t path;
- int type;
- int dist;
- int numports;
- int localport;
- int smalid;
- int smalmc;
- int smaenhsp0;
- uint32_t devid;
- uint32_t vendid;
- uint64_t sysimgguid;
- uint64_t nodeguid;
- uint64_t portguid;
- char nodedesc[64];
- uint8_t nodeinfo[64];
-
- ChassisRecord *chrecord;
-};
-
-#endif /* _IBNETDISCOVER_H_ */
diff --git a/contrib/ofed/management/infiniband-diags/infiniband-diags.spec.in b/contrib/ofed/management/infiniband-diags/infiniband-diags.spec.in
deleted file mode 100644
index 9c8c0c4..0000000
--- a/contrib/ofed/management/infiniband-diags/infiniband-diags.spec.in
+++ /dev/null
@@ -1,194 +0,0 @@
-
-%define RELEASE @RELEASE@
-%define rel %{?CUSTOM_RELEASE} %{!?CUSTOM_RELEASE:%RELEASE}
-
-Summary: OpenFabrics Alliance InfiniBand Diagnostic Tools
-Name: infiniband-diags
-Version: @VERSION@
-Release: %rel%{?dist}
-License: GPLv2 or BSD
-Group: System Environment/Libraries
-BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
-Source: http://www.openfabrics.org/downloads/management/@TARBALL@
-Url: http://openfabrics.org/
-BuildRequires: libibmad-devel, opensm-devel, libibcommon-devel, libibumad-devel
-Provides: perl(IBswcountlimits)
-Obsoletes: openib-diags
-
-%description
-This package provides IB diagnostic programs and scripts needed to
-diagnose an IB subnet.
-
-%prep
-%setup -q
-
-%if %{?_with_node_name_map:1}%{!?_with_node_name_map:0}
-%define _enable_node_name_map --with-node-name-map%{?_with_node_name_map}
-%endif
-
-%build
-%configure %{?_enable_node_name_map}
-make
-
-%install
-rm -rf $RPM_BUILD_ROOT
-make DESTDIR=${RPM_BUILD_ROOT} install
-# remove unpackaged files from the buildroot
-rm -f $RPM_BUILD_ROOT%{_libdir}/*.la
-
-%clean
-rm -rf $RPM_BUILD_ROOT
-
-%files
-%defattr(-,root,root)
-%{_sbindir}/ibdiscover.pl
-%{_sbindir}/ib*
-%{_sbindir}/perfquery
-%{_sbindir}/saquery
-%{_sbindir}/vendstat
-%{_sbindir}/dump_mfts.sh
-%{_sbindir}/dump_lfts.sh
-%{_sbindir}/check_lft_balance.pl
-%{_sbindir}/set_nodedesc.sh
-%{_sbindir}/sm*
-%define _perldir %(perl -e 'use Config; $T=$Config{installsitearch}; $T=~/(.*)\\/site_perl.*/; print $1;')
-%{_perldir}/*
-%{_mandir}/man8/*
-%doc README COPYING ChangeLog
-
-%changelog
-* Mon Mar 03 2008 Albert Chu <chu11@llnl.gov> - 1.3.5
-- Add check_lft_balance script.
-
-* Wed Oct 31 2007 Ira Weiny <weiny2@llnl.gov> - 1.3.2
-- Change switch-map option to node-name-map
-
-* Thu Aug 9 2007 Ira Weiny <weiny2@llnl.gov> - 1.3.1
-- Change set_mthca_nodedesc.sh to set_nodedesc.sh
-
-* Tue Jul 10 2007 Hal Rosenstock <halr@voltaire.com> - 1.3.1
-- Add link width and speed to topology file output in ibnetdiscover
-- Add support for -R(outer_list) in ibnetdiscover
-- Add script and man page for ibidsverify
-- Moved diags from bin to sbin
-- Add scripts and man pages for display on IB routers
-- Add GUID to output line for ports in ibqueryerrors.pl
-- Add ibdatacounts and ibdatacounters scripts and man pages
-- Add peer port link width and speed validation in iblinkinfo.pl
-- Display remote LID with peer port info in IBswcountlimits.pm
-- Handle peer ports at 1x that should be wider and 2.5 Gbps
- links that should be faster in ibportstate
-- Add LinkSpeed/Width components to output of ibportstate
-- Add support for IB routers
-- Add grouping support for ISR2012 and ISR2004 in ibnetdiscover
-- Remove all uses of "/tmp" from perl scripts
-- Add switch map support for saquery -O and -U options
-- Add support for saquery -s (isSMdisabled)
-- Add name input checks to saquery (-O and -U)
-
-* Thu Mar 29 2007 Hal Rosenstock <halr@voltaire.com> - 1.3.0
-- Add some extra debug information to IBswcountlimits.pm
-- Send normal output to stdout in ibtracert
-- Don't truncate NodeDescriptions containing ctl characters in ibdiag_common
-- Fix ibnetdiscover grouping for Cisco SFS7000
-- Add support to query the GUIDInfo table in smpquery
-- Allow user to specify a default switch map file
-
-* Fri Mar 9 2007 Hal Rosenstock <halr@voltaire.com> - 1.2.5
-- Find perl modules in perl sitearch directory
-- Fix non standard prefix install for diag scripts
-- Clean gcc-4.1 warnings in saquery and ibdiag_common
-
-* Fri Mar 2 2007 Hal Rosenstock <halr@voltaire.com> - 1.2.4
-- OpenFabrics 1.2.4 release
-- Fix diag rpmbuild from make dist
-- Include set_mthca_nodedesc.sh and dump_lfts.sh in the rpm
-
-* Thu Mar 1 2007 Hal Rosenstock <halr@voltaire.com> - 1.2.3
-- OpenFabrics 1.2.3 release
-- Fixed saquery timeout handling
-
-* Tue Feb 27 2007 Hal Rosenstock <halr@voltaire.com> - 1.2.2
-- OpenFabrics 1.2.2 release
-- Minor changes to ibswitches and ibhosts output
-
-* Thu Feb 14 2007 Hal Rosenstock <halr@voltaire.com> - 1.2.1
-- OpenFabrics 1.2.1 release
-- Initial release of vendstat tool
-
-* Fri Feb 2 2007 Hal Rosenstock <halr@voltaire.com> - 1.2.0
-- OpenFabrics 1.2.0 release
-- Added brief option to ibcheckerrors and ibcheckerrs
-- Updated man pages
-- Added build version to saquery and updated build version tags of other tools
-- Added -N | nocolor to usage display of scripts
-- Fixed -nocolor and -G options on scripts
-- Fixed error return status in ibchecknet
-- Added exit code to ibcheckerrors
-- Added nodename to output of ibcheckerrs
-- ibqueryerrors.pl fixes and improvements
-- Removed use of tmpfile for ibroute data in ibfindnodeusing.pl
-- Fixed undefined subroutine error in iblinkinfo.pl
-- Added switch-map option to ibtracert and ibnetdiscover
-- Cleaned up node descriptions before printing in saquery
-- Clarified --src-to-dst option in saquery
-- Added peer NodeDescription and LID to output of inbetdiscover
-- For grouping, ordered Spine and Line Nodes (for Voltaire chassis) in ibnetdiscover
-- Cleaned up node descriptions before printing in ibtracert and ibroute
-- Added additional sematics to -m option of saquery
-- Added dump_mfts.sh similar to dump_lfts.sh
-- ibnetdiscover improvements (memory leaks, ports moving, etc.)
-- Converted iblinkspeed.pl into iblinkinfo.pl and added additional capabilities
-- Added 0x in front of GUID printing of ibtracert
-- Fixed loopback handling in ibnetdiscover
-- Added support for querying Service Records to saquery
-- Added support for PerfMgt IsExtendedWidthSupported IBA 1.2 erratum in perfquery
-- For query operations, added peer port checking of linkwidth and speed
- active in ibportstate
-- Added support for DrSLID in smpquery
-- Added IB router support to ibnetdiscover and ibtracert
-- Added additional options to saquery
-- Added support to change LinkSpeedEnabled in ibportstate
-
-* Fri Sep 22 2006 Hal Rosenstock <halr@voltaire.com> - 1.1.0
-- OpenFabrics 1.1 release
-
-* Wed Sep 13 2006 Hal Rosenstock <halr@voltaire.com> - 1.1.0-rc5
-- OpenFabrics 1.1-rc5 release
-
-* Wed Sep 6 2006 Hal Rosenstock <halr@voltaire.com> - 1.1.0-rc4
-- OpenFabrics 1.1-rc4 release
-
-* Wed Aug 23 2006 Hal Rosenstock <halr@voltaire.com> - 1.1.0-rc3
-- OpenFabrics 1.1-rc3 release
-
-* Mon Aug 14 2006 Hal Rosenstock <halr@voltaire.com> - 1.1.0-rc2
-- OpenFabrics 1.1-rc2 release
-- Added ibsysstat man page
-
-* Wed Jul 26 2006 Hal Rosenstock <halr@voltaire.com> - 1.1.0-rc1
-- OpenFabrics 1.1-rc1 release
-- Added man pages
-- Made diag command/script options more consistent
-- saquery tool added
-- dump_lft.sh script added
-- Renamed discover.pl to ibdiscover.pl
-
-* Sun Jun 10 2006 Hal Rosenstock <halr@voltaire.com> - 1.0-1
-- OpenFabrics 1.0 release
-
-* Tue May 30 2006 Hal Rosenstock <halr@voltaire.com> - 1.0.0-rc6
-- Maintenance release
-
-* Fri May 12 2006 Hal Rosenstock <halr@voltaire.com> - 1.0.0-rc5
-- Maintenance release
-
-* Thu Apr 27 2006 Hal Rosenstock <halr@voltaire.com> - 1.0.0-rc4
-- Maintenance release
-- Note rc3 skipped to sync with OFED
-
-* Mon Apr 10 2006 Hal Rosenstock <halr@voltaire.com> - 1.0.0-rc2
-- Maintenance release
-
-* Mon Feb 27 2006 Hal Rosenstock <halr@voltaire.com> - 1.0.0-rc1
-- Initial spec file and release
diff --git a/contrib/ofed/management/infiniband-diags/man/check_lft_balance.8 b/contrib/ofed/management/infiniband-diags/man/check_lft_balance.8
deleted file mode 100644
index 3eeca0dd..0000000
--- a/contrib/ofed/management/infiniband-diags/man/check_lft_balance.8
+++ /dev/null
@@ -1,42 +0,0 @@
-.TH CHECK_LFT_BALANCE.SH 8 "March 1, 2008" "OpenIB" "OpenIB Diagnostics"
-
-.SH NAME
-check_lft_balance.sh \- check InfiniBand unicast forwarding tables balance
-
-.SH SYNOPSIS
-.B check_lft_balance.sh
-[-hRv]
-
-
-.SH DESCRIPTION
-.PP
-check_lft_balance.sh is a script which checks for balancing in Infiniband
-unicast forwarding tables. It analyzes the output of
-.BR dump_lfts(8)
-and
-.BR iblinkinfo(8).
-
-.SH OPTIONS
-
-.PP
-.TP
-\fB\-h\fR
-show help
-.TP
-\fB\-R\fR
-Recalculate dump_lfts information, ie do not use the cached
-information. This option is slower but should be used if the diag tools have
-not been used for some time or if there are other reasons to believe that
-the fabric has changed.
-.TP
-\fB\-v\fR
-verbose output
-
-.SH SEE ALSO
-.BR dump_lfts(8),
-.BR iblinkinfo(8)
-
-.SH AUTHORS
-.TP
-Albert Chu
-.RI < chu11@llnl.gov >
diff --git a/contrib/ofed/management/infiniband-diags/man/dump_lfts.8 b/contrib/ofed/management/infiniband-diags/man/dump_lfts.8
deleted file mode 100644
index 4498260..0000000
--- a/contrib/ofed/management/infiniband-diags/man/dump_lfts.8
+++ /dev/null
@@ -1,50 +0,0 @@
-.TH DUMP_LFTS.SH 8 "May 21, 2007" "OpenIB" "OpenIB Diagnostics"
-
-.SH NAME
-dump_lfts.sh \- dump InfiniBand unicast forwarding tables
-
-.SH SYNOPSIS
-.B dump_lfts.sh
-[\-h] [\-D] [\-C ca_name] [\-P ca_port] [\-t(imeout) timeout_ms] [>/path/to/dump-file]
-
-
-.SH DESCRIPTION
-.PP
-dump_lfts.sh is a script which dumps the InfiniBand unciast forwarding
-tables (MFTs) in the switch nodes in the subnet.
-
-The dump file format is compatible with loading into OpenSM using
-the -R file -U /path/to/dump-file syntax.
-
-.SH OPTIONS
-
-.PP
-.TP
-\fB\-D\fR
-dump forwarding tables using direct routed rather than LID routed SMPs
-.TP
-\fB\-h\fR
-show help
-.TP
-\fB\-C\fR <ca_name>
-use the specified ca_name.
-.TP
-\fB\-P\fR <ca_port>
-use the specified ca_port.
-.TP
-\fB\-t\fR <timeout_ms>
-override the default timeout for the solicited mads.
-
-.SH SEE ALSO
-.BR dump_mfts(8),
-.BR ibroute(8),
-.BR ibswitches(8),
-.BR opensm(8)
-
-.SH AUTHORS
-.TP
-Sasha Khapyorsky
-.RI < sashak@voltaire.com >
-.TP
-Hal Rosenstock
-.RI < halr@voltaire.com >
diff --git a/contrib/ofed/management/infiniband-diags/man/dump_mfts.8 b/contrib/ofed/management/infiniband-diags/man/dump_mfts.8
deleted file mode 100644
index 885301e..0000000
--- a/contrib/ofed/management/infiniband-diags/man/dump_mfts.8
+++ /dev/null
@@ -1,45 +0,0 @@
-.TH DUMP_MFTS.SH 8 "May 21, 2007" "OpenIB" "OpenIB Diagnostics"
-
-.SH NAME
-dump_lfts.sh \- dump InfiniBand multicast forwarding tables
-
-.SH SYNOPSIS
-.B dump_mfts.sh
-[\-h] [\-D] [\-C ca_name] [\-P ca_port] [\-t(imeout) timeout_ms]
-[>/path/to/file]
-
-.SH DESCRIPTION
-.PP
-dump_mfts.sh is a script which dumps the InfiniBand multicast
-forwarding tables (MFTs) in the switch nodes in the subnet.
-
-.SH OPTIONS
-
-.PP
-.TP
-\fB\-D\fR
-dump forwarding tables using direct routed rather than LID routed SMPs
-.TP
-\fB\-h\fR
-show help
-.TP
-\fB\-C\fR <ca_name>
-use the specified ca_name.
-.TP
-\fB\-P\fR <ca_port>
-use the specified ca_port.
-.TP
-\fB\-t\fR <timeout_ms>
-override the default timeout for the solicited mads.
-
-
-.SH SEE ALSO
-.BR dump_lfts(8),
-.BR ibroute(8),
-.BR ibswitches(8),
-.BR opensm(8)
-
-.SH AUTHOR
-.TP
-Hal Rosenstock
-.RI < halr@voltaire.com >
diff --git a/contrib/ofed/management/infiniband-diags/man/ibaddr.8 b/contrib/ofed/management/infiniband-diags/man/ibaddr.8
deleted file mode 100644
index 622c6f9..0000000
--- a/contrib/ofed/management/infiniband-diags/man/ibaddr.8
+++ /dev/null
@@ -1,109 +0,0 @@
-.TH IBADDR 8 "June 18, 2007" "OpenIB" "OpenIB Diagnostics"
-
-.SH NAME
-ibaddr \- query InfiniBand address(es)
-
-.SH SYNOPSIS
-.B ibaddr
-[\-d(ebug)] [\-D(irect)] [\-G(uid)] [\-l(id_show)] [\-g(id_show)] [\-C ca_name] [\-P ca_port] [\-t(imeout) timeout_ms] [\-V(ersion)] [\-h(elp)] [<lid | dr_path | guid>]
-
-.SH DESCRIPTION
-.PP
-Display the lid (and range) as well as the GID address of the
-port specified (by DR path, lid, or GUID) or the local port by default.
-.PP
-Note: this utility can be used as simple address resolver.
-
-.SH OPTIONS
-
-.PP
-.TP
-\fB\-G\fR, \fB\-\-Guid\fR
-show lid range and gid for GUID address
-.TP
-\fB\-l\fR, \fB\-\-lid_show\fR
-show lid range only
-.TP
-\fB\-L\fR, \fB\-\-Lid_show\fR
-show lid range (in decimal) only
-.TP
-\fB\-g\fR, \fB\-\-gid_show\fR
-show gid address only
-
-.SH COMMON OPTIONS
-
-Most OpenIB diagnostics take the following common flags. The exact list of
-supported flags per utility can be found in the usage message and can be shown
-using the util_name -h syntax.
-
-# Debugging flags
-.PP
-\-d raise the IB debugging level.
- May be used several times (-ddd or -d -d -d).
-.PP
-\-e show send and receive errors (timeouts and others)
-.PP
-\-h show the usage message
-.PP
-\-v increase the application verbosity level.
- May be used several times (-vv or -v -v -v)
-.PP
-\-V show the version info.
-
-# Addressing flags
-.PP
-\-D use directed path address arguments. The path
- is a comma separated list of out ports.
- Examples:
- "0" # self port
- "0,1,2,1,4" # out via port 1, then 2, ...
-.PP
-\-G use GUID address argument. In most cases, it is the Port GUID.
- Example:
- "0x08f1040023"
-.PP
-\-s <smlid> use 'smlid' as the target lid for SM/SA queries.
-
-# Other common flags:
-.PP
-\-C <ca_name> use the specified ca_name.
-.PP
-\-P <ca_port> use the specified ca_port.
-.PP
-\-t <timeout_ms> override the default timeout for the solicited mads.
-
-Multiple CA/Multiple Port Support
-
-When no IB device or port is specified, the port to use is selected
-by the following criteria:
-.PP
-1. the first port that is ACTIVE.
-.PP
-2. if not found, the first port that is UP (physical link up).
-
-If a port and/or CA name is specified, the user request is
-attempted to be fulfilled, and will fail if it is not possible.
-
-.SH EXAMPLES
-
-.PP
-ibaddr # local port\'s address
-.PP
-ibaddr 32 # show lid range and gid of lid 32
-.PP
-ibaddr -G 0x8f1040023 # same but using guid address
-.PP
-ibaddr -l 32 # show lid range only
-.PP
-ibaddr -L 32 # show decimal lid range only
-.PP
-ibaddr -g 32 # show gid address only
-
-.SH SEE ALSO
-.BR ibroute (8),
-.BR ibtracert (8)
-
-.SH AUTHOR
-.TP
-Hal Rosenstock
-.RI < halr@voltaire.com >
diff --git a/contrib/ofed/management/infiniband-diags/man/ibcheckerrors.8 b/contrib/ofed/management/infiniband-diags/man/ibcheckerrors.8
deleted file mode 100644
index 7c2467f..0000000
--- a/contrib/ofed/management/infiniband-diags/man/ibcheckerrors.8
+++ /dev/null
@@ -1,41 +0,0 @@
-.TH IBCHECKERRORS 8 "May 21, 2007" "OpenIB" "OpenIB Diagnostics"
-
-.SH NAME
-ibcheckerrors \- validate IB subnet and report errors
-
-.SH SYNOPSIS
-.B ibcheckerrors
-[\-h] [\-b] [\-v] [\-N | \-nocolor] [<topology-file> | \-C ca_name
-\-P ca_port \-t(imeout) timeout_ms]
-
-.SH DESCRIPTION
-.PP
-ibcheckerrors is a script which uses a full topology file that was created by
-ibnetdiscover, scans the network to validate the connectivity and reports
-errors (from port counters).
-
-.SH OPTIONS
-.PP
-\-v increase the verbosity level
-.PP
-\-b brief mode. Reduce the output to show only if errors are present,
- not what they are.
-.PP
-\-N | \-nocolor use mono rather than color mode
-.PP
-\-C <ca_name> use the specified ca_name.
-.PP
-\-P <ca_port> use the specified ca_port.
-.PP
-\-t <timeout_ms> override the default timeout for the solicited mads.
-
-.SH SEE ALSO
-.BR ibnetdiscover(8),
-.BR ibchecknode(8),
-.BR ibcheckport(8),
-.BR ibcheckerrs(8)
-
-.SH AUTHOR
-.TP
-Hal Rosenstock
-.RI < halr@voltaire.com >
diff --git a/contrib/ofed/management/infiniband-diags/man/ibcheckerrs.8 b/contrib/ofed/management/infiniband-diags/man/ibcheckerrs.8
deleted file mode 100644
index f8aa848..0000000
--- a/contrib/ofed/management/infiniband-diags/man/ibcheckerrs.8
+++ /dev/null
@@ -1,59 +0,0 @@
-.TH IBCHECKERRS 8 "May 30, 2007" "OpenIB" "OpenIB Diagnostics"
-
-.SH NAME
-ibcheckerrs \- validate IB port (or node) and report errors in counters above threshold
-
-.SH SYNOPSIS
-.B ibcheckerrs
-[\-h] [\-b] [\-v] [\-G] [\-T <threshold_file>] [\-s(how_thresholds)]
-[\-N | \-nocolor] [\-C ca_name] [\-P ca_port] [\-t(imeout) timeout_ms]
-<lid|guid> <port>
-
-
-.SH DESCRIPTION
-.PP
-Check specified port (or node) and report errors that surpassed their predefined
-threshold. Port address is lid unless -G option is used to specify a GUID
-address. The predefined thresholds can be dumped using the -s option, and a
-user defined threshold_file (using the same format as the dump) can be
-specified using the -t <file> option.
-
-.SH OPTIONS
-.PP
-\-G use GUID address argument. In most cases, it is the Port GUID.
- Example:
- "0x08f1040023"
-.PP
-\-s show predefined thresholds
-.PP
-\-T use specified threshold file
-.PP
-\-v increase the verbosity level
-.PP
-\-b brief mode. Reduce the output to show only if errors are
- present, not what they are.
-.PP
-\-N | \-nocolor use mono rather than color mode
-.PP
-\-C <ca_name> use the specified ca_name.
-.PP
-\-P <ca_port> use the specified ca_port.
-.PP
-\-t <timeout_ms> override the default timeout for the solicited mads.
-
-.SH EXAMPLE
-.PP
-ibcheckerrs 2 # check aggregated node counter for lid 2
-.PP
-ibcheckerrs 2 4 # check port counters for lid 2 port 4
-.PP
-ibcheckerrs -T xxx 2 # check node using xxx threshold file
-
-.SH SEE ALSO
-.BR perfquery(8),
-.BR ibaddr(8)
-
-.SH AUTHOR
-.TP
-Hal Rosenstock
-.RI < halr@voltaire.com >
diff --git a/contrib/ofed/management/infiniband-diags/man/ibchecknet.8 b/contrib/ofed/management/infiniband-diags/man/ibchecknet.8
deleted file mode 100644
index f907823..0000000
--- a/contrib/ofed/management/infiniband-diags/man/ibchecknet.8
+++ /dev/null
@@ -1,36 +0,0 @@
-.TH IBCHECKNET 8 "May 21, 2007" "OpenIB" "OpenIB Diagnostics"
-
-.SH NAME
-ibchecknet \- validate IB subnet and report errors
-
-.SH SYNOPSIS
-.B ibchecknet
-[\-h] [\-N | \-nocolor] [<topology-file> | \-C ca_name \-P ca_port
-\-t(imeout) timeout_ms]
-
-.SH DESCRIPTION
-.PP
-ibchecknet is a script which uses a full topology file that was created
-by ibnetdiscover, and scans the network to validate the connectivity and
-reports errors (from port counters).
-
-.SH OPTIONS
-.PP
-\-N | \-nocolor use mono rather than color mode
-.PP
-\-C <ca_name> use the specified ca_name.
-.PP
-\-P <ca_port> use the specified ca_port.
-.PP
-\-t <timeout_ms> override the default timeout for the solicited mads.
-
-.SH SEE ALSO
-.BR ibnetdiscover(8),
-.BR ibchecknode(8),
-.BR ibcheckport(8),
-.BR ibcheckerrs(8)
-
-.SH AUTHOR
-.TP
-Hal Rosenstock
-.RI < halr@voltaire.com >
diff --git a/contrib/ofed/management/infiniband-diags/man/ibchecknode.8 b/contrib/ofed/management/infiniband-diags/man/ibchecknode.8
deleted file mode 100644
index 3d65d8a..0000000
--- a/contrib/ofed/management/infiniband-diags/man/ibchecknode.8
+++ /dev/null
@@ -1,43 +0,0 @@
-.TH IBCHECKNODE 8 "May 21, 2007" "OpenIB" "OpenIB Diagnostics"
-
-.SH NAME
-ibchecknode \- validate IB node and report errors
-
-.SH SYNOPSIS
-.B ibchecknode
-[\-h] [\-v] [\-N | \-nocolor] [\-G] [\-C ca_name] [\-P ca_port]
-[\-t(imeout) timeout_ms] <lid|guid>
-
-.SH DESCRIPTION
-.PP
-Check connectivity and do some simple sanity checks for the specified node.
-Port address is a lid unless -G option is used to specify a GUID address.
-
-.SH OPTIONS
-.PP
-\-G use GUID address argument. In most cases, it is the Port GUID.
- Example:
- "0x08f1040023"
-.PP
-\-v increase the verbosity level
-.PP
-\-N | \-nocolor use mono rather than color mode
-.PP
-\-C <ca_name> use the specified ca_name.
-.PP
-\-P <ca_port> use the specified ca_port.
-.PP
-\-t <timeout_ms> override the default timeout for the solicited mads.
-
-.SH EXAMPLE
-.PP
-ibchecknode 2 # check node via lid 2
-
-.SH SEE ALSO
-.BR smpquery(8),
-.BR ibaddr(8)
-
-.SH AUTHOR
-.TP
-Hal Rosenstock
-.RI < halr@voltaire.com >
diff --git a/contrib/ofed/management/infiniband-diags/man/ibcheckport.8 b/contrib/ofed/management/infiniband-diags/man/ibcheckport.8
deleted file mode 100644
index f01095b..0000000
--- a/contrib/ofed/management/infiniband-diags/man/ibcheckport.8
+++ /dev/null
@@ -1,43 +0,0 @@
-.TH IBCHECKPORT 8 "May 21, 2007" "OpenIB" "OpenIB Diagnostics"
-
-.SH NAME
-ibcheckport \- validate IB port and report errors
-
-.SH SYNOPSIS
-.B ibcheckport
-[\-h] [\-v] [\-N | \-nocolor] [\-G] [\-C ca_name] [\-P ca_port]
-[\-t(imeout) timeout_ms] <lid|guid> <port>
-
-.SH DESCRIPTION
-.PP
-Check connectivity and do some simple sanity checks for the specified port.
-Port address is a lid unless -G option is used to specify a GUID address.
-
-.SH OPTIONS
-.PP
-\-G use GUID address argument. In most cases, it is the Port GUID.
- Example:
- "0x08f1040023"
-.PP
-\-v increase the verbosity level
-.PP
-\-N | \-nocolor use mono rather than color mode
-.PP
-\-C <ca_name> use the specified ca_name.
-.PP
-\-P <ca_port> use the specified ca_port.
-.PP
-\-t <timeout_ms> override the default timeout for the solicited mads.
-
-.SH EXAMPLE
-.PP
-ibcheckport 2 3 # check lid 2 port 3
-
-.SH SEE ALSO
-.BR smpquery(8),
-.BR ibaddr(8)
-
-.SH AUTHOR
-.TP
-Hal Rosenstock
-.RI < halr@voltaire.com >
diff --git a/contrib/ofed/management/infiniband-diags/man/ibcheckportstate.8 b/contrib/ofed/management/infiniband-diags/man/ibcheckportstate.8
deleted file mode 100644
index 8d7f38b..0000000
--- a/contrib/ofed/management/infiniband-diags/man/ibcheckportstate.8
+++ /dev/null
@@ -1,44 +0,0 @@
-.TH IBCHECKPORTSTATE 8 "May 21, 2007" "OpenIB" "OpenIB Diagnostics"
-
-.SH NAME
-ibcheckportstate \- validate IB port for LinkUp and not Active state
-
-.SH SYNOPSIS
-.B ibcheckportstate
-[\-h] [\-v] [\-N | \-nocolor] [\-G] [\-C ca_name] [\-P ca_port]
-[\-t(imeout) timeout_ms] <lid|guid> <port>
-
-.SH DESCRIPTION
-.PP
-Check connectivity and check the specified port for proper port state
-(Active) and port physical state (LinkUp).
-Port address is a lid unless -G option is used to specify a GUID address.
-
-.SH OPTIONS
-.PP
-\-G use GUID address argument. In most cases, it is the Port GUID.
- Example:
- "0x08f1040023"
-.PP
-\-v increase the verbosity level
-.PP
-\-N | \-nocolor use mono rather than color mode
-.PP
-\-C <ca_name> use the specified ca_name.
-.PP
-\-P <ca_port> use the specified ca_port.
-.PP
-\-t <timeout_ms> override the default timeout for the solicited mads.
-
-.SH EXAMPLE
-.PP
-ibcheckportstate 2 3 # check lid 2 port 3
-
-.SH SEE ALSO
-.BR smpquery(8),
-.BR ibaddr(8)
-
-.SH AUTHOR
-.TP
-Hal Rosenstock
-.RI < halr@voltaire.com >
diff --git a/contrib/ofed/management/infiniband-diags/man/ibcheckportwidth.8 b/contrib/ofed/management/infiniband-diags/man/ibcheckportwidth.8
deleted file mode 100644
index 85c06fc..0000000
--- a/contrib/ofed/management/infiniband-diags/man/ibcheckportwidth.8
+++ /dev/null
@@ -1,43 +0,0 @@
-.TH IBCHECKPORTWIDTH 8 "May 21, 2007" "OpenIB" "OpenIB Diagnostics"
-
-.SH NAME
-ibcheckportwidth \- validate IB port for 1x link width
-
-.SH SYNOPSIS
-.B ibcheckport
-[\-h] [\-v] [\-N | \-nocolor] [\-G] [\-C ca_name] [\-P ca_port]
-[\-t(imeout) timeout_ms] <lid|guid> <port>
-
-.SH DESCRIPTION
-.PP
-Check connectivity and check the specified port for 1x link width.
-Port address is a lid unless -G option is used to specify a GUID address.
-
-.SH OPTIONS
-.PP
-\-G use GUID address argument. In most cases, it is the Port GUID.
- Example:
- "0x08f1040023"
-.PP
-\-v increase the verbosity level
-.PP
-\-N | \-nocolor use mono rather than color mode
-.PP
-\-C <ca_name> use the specified ca_name.
-.PP
-\-P <ca_port> use the specified ca_port.
-.PP
-\-t <timeout_ms> override the default timeout for the solicited mads.
-
-.SH EXAMPLE
-.PP
-ibcheckportwidth 2 3 # check lid 2 port 3
-
-.SH SEE ALSO
-.BR smpquery(8),
-.BR ibaddr(8)
-
-.SH AUTHOR
-.TP
-Hal Rosenstock
-.RI < halr@voltaire.com >
diff --git a/contrib/ofed/management/infiniband-diags/man/ibcheckstate.8 b/contrib/ofed/management/infiniband-diags/man/ibcheckstate.8
deleted file mode 100644
index 89daeb8..0000000
--- a/contrib/ofed/management/infiniband-diags/man/ibcheckstate.8
+++ /dev/null
@@ -1,36 +0,0 @@
-.TH IBCHECKSTATE 8 "May 21, 2007" "OpenIB" "OpenIB Diagnostics"
-
-.SH NAME
-ibcheckstate \- find ports in IB subnet which are link up but not active
-
-.SH SYNOPSIS
-.B ibcheckstate
-[\-h] [\-v] [\-N | \-nocolor] [<topology-file> | \-C ca_name \-P ca_port
-\-t(imeout) timeout_ms]
-
-.SH DESCRIPTION
-.PP
-ibcheckstat is a script which uses a full topology file that was created by
-ibnetdiscover, scans the network to validate the port state and port physical
-state, and reports any ports which have a port state other than Active or
-a port physical state other than LinkUp.
-
-.SH OPTIONS
-.PP
-\-N | \-nocolor use mono rather than color mode
-.PP
-\-C <ca_name> use the specified ca_name.
-.PP
-\-P <ca_port> use the specified ca_port.
-.PP
-\-t <timeout_ms> override the default timeout for the solicited mads.
-
-.SH SEE ALSO
-.BR ibnetdiscover(8),
-.BR ibchecknode(8),
-.BR ibcheckportstate(8)
-
-.SH AUTHOR
-.TP
-Hal Rosenstock
-.RI < halr@voltaire.com >
diff --git a/contrib/ofed/management/infiniband-diags/man/ibcheckwidth.8 b/contrib/ofed/management/infiniband-diags/man/ibcheckwidth.8
deleted file mode 100644
index 1414fb2..0000000
--- a/contrib/ofed/management/infiniband-diags/man/ibcheckwidth.8
+++ /dev/null
@@ -1,36 +0,0 @@
-.TH IBCHECKWIDTH 8 "May 21, 2007" "OpenIB" "OpenIB Diagnostics"
-
-.SH NAME
-ibcheckwidth \- find 1x links in IB subnet
-
-.SH SYNOPSIS
-.B ibcheckwidth
-[\-h] [\-v] [\-N | \-nocolor] [<topology-file> | \-C ca_name
-\-P ca_port \-t(imeout) timeout_ms]
-
-
-.SH DESCRIPTION
-.PP
-ibcheckwidth is a script which uses a full topology file that was created by
-ibnetdiscover, scans the network to validate the active link widths and
-reports any 1x links.
-
-.SH OPTIONS
-.PP
-\-N | \-nocolor use mono rather than color mode
-.PP
-\-C <ca_name> use the specified ca_name.
-.PP
-\-P <ca_port> use the specified ca_port.
-.PP
-\-t <timeout_ms> override the default timeout for the solicited mads.
-
-.SH SEE ALSO
-.BR ibnetdiscover(8),
-.BR ibchecknode(8),
-.BR ibcheckportwidth(8)
-
-.SH AUTHOR
-.TP
-Hal Rosenstock
-.RI < halr@voltaire.com >
diff --git a/contrib/ofed/management/infiniband-diags/man/ibclearcounters.8 b/contrib/ofed/management/infiniband-diags/man/ibclearcounters.8
deleted file mode 100644
index 1fca7bd..0000000
--- a/contrib/ofed/management/infiniband-diags/man/ibclearcounters.8
+++ /dev/null
@@ -1,30 +0,0 @@
-.TH IBCLEARCOUNTERS 8 "May 21, 2007" "OpenIB" "OpenIB Diagnostics"
-
-.SH NAME
-ibclearcounters \- clear port counters in IB subnet
-
-.SH SYNOPSIS
-.B ibclearcounters
-[\-h] [<topology-file> | \-C ca_name \-P ca_port \-t(imeout) timeout_ms]
-
-.SH DESCRIPTION
-.PP
-ibclearcounters is a script that clears the PMA port counters by either walking
-the IB subnet topology or using an already saved topology file.
-
-.SH OPTIONS
-.PP
-\-C <ca_name> use the specified ca_name.
-.PP
-\-P <ca_port> use the specified ca_port.
-.PP
-\-t <timeout_ms> override the default timeout for the solicited mads.
-
-.SH SEE ALSO
-.BR ibnetdiscover(8),
-.BR perfquery(8)
-
-.SH AUTHOR
-.TP
-Hal Rosenstock
-.RI < halr@voltaire.com >
diff --git a/contrib/ofed/management/infiniband-diags/man/ibclearerrors.8 b/contrib/ofed/management/infiniband-diags/man/ibclearerrors.8
deleted file mode 100644
index 7692c64..0000000
--- a/contrib/ofed/management/infiniband-diags/man/ibclearerrors.8
+++ /dev/null
@@ -1,34 +0,0 @@
-.TH IBCLEARERRORS 8 "May 21, 2007" "OpenIB" "OpenIB Diagnostics"
-
-.SH NAME
-ibclearerrors \- clear error counters in IB subnet
-
-.SH SYNOPSIS
-.B ibclearerrors
-[\-h] [\-N | \-nocolor] [<topology-file> | \-C ca_name \-P ca_port
-\-t(imeout) timeout_ms]
-
-.SH DESCRIPTION
-.PP
-ibclearerrors is a script which clears the PMA error counters in PortCounters
-by either walking the IB subnet topology or using an already saved topology
-file.
-
-.SH OPTIONS
-.PP
-\-N | \-nocolor use mono rather than color mode
-.PP
-\-C <ca_name> use the specified ca_name.
-.PP
-\-P <ca_port> use the specified ca_port.
-.PP
-\-t <timeout_ms> override the default timeout for the solicited mads.
-
-.SH SEE ALSO
-.BR ibnetdiscover(8),
-.BR perfquery(8)
-
-.SH AUTHOR
-.TP
-Hal Rosenstock
-.RI < halr@voltaire.com >
diff --git a/contrib/ofed/management/infiniband-diags/man/ibdatacounters.8 b/contrib/ofed/management/infiniband-diags/man/ibdatacounters.8
deleted file mode 100644
index 60fec8f..0000000
--- a/contrib/ofed/management/infiniband-diags/man/ibdatacounters.8
+++ /dev/null
@@ -1,38 +0,0 @@
-.TH IBDATACOUNTERS 8 "May 31, 2007" "OpenIB" "OpenIB Diagnostics"
-
-.SH NAME
-ibdatacounters \- query IB subnet for data counters
-
-.SH SYNOPSIS
-.B ibdatacounters
-[\-h] [\-b] [\-v] [\-N | \-nocolor] [<topology-file> | \-C ca_name \-P ca_port \-t(imeout) timeout_ms]
-
-.SH DESCRIPTION
-.PP
-ibdatacounters is a script which uses a full topology file that was created by
-ibnetdiscover, scans the network to validate the connectivity and reports
-the data counters (from port counters).
-
-.SH OPTIONS
-.PP
-\-v increase the verbosity level
-.PP
-\-b brief mode. Reduce the output to show only if errors are present,
- not what they are.
-.PP
-\-N | \-nocolor use mono rather than color mode
-.PP
-\-C <ca_name> use the specified ca_name.
-.PP
-\-P <ca_port> use the specified ca_port.
-.PP
-\-t <timeout_ms> override the default timeout for the solicited mads.
-
-.SH SEE ALSO
-.BR ibnetdiscover(8),
-.BR ibdatacounts(8)
-
-.SH AUTHOR
-.TP
-Hal Rosenstock
-.RI < halr@voltaire.com >
diff --git a/contrib/ofed/management/infiniband-diags/man/ibdatacounts.8 b/contrib/ofed/management/infiniband-diags/man/ibdatacounts.8
deleted file mode 100644
index d1b31e3..0000000
--- a/contrib/ofed/management/infiniband-diags/man/ibdatacounts.8
+++ /dev/null
@@ -1,48 +0,0 @@
-.TH IBDATACOUNTS 8 "May 30, 2007" "OpenIB" "OpenIB Diagnostics"
-
-.SH NAME
-ibdatacounts \- get IB port data counters
-
-.SH SYNOPSIS
-.B ibdatacounts
-[\-h] [\-b] [\-v] [\-G] [\-N | \-nocolor] [\-C ca_name] [\-P ca_port]
-[\-t(imeout) timeout_ms] <lid|guid> [<port>]
-
-.SH DESCRIPTION
-.PP
-Obtain PMA data counters from specified port (or node).
-Port address is lid unless -G option is used to specify a GUID
-address.
-
-.SH OPTIONS
-.PP
-\-G use GUID address argument. In most cases, it is the Port GUID.
- Example:
- "0x08f1040023"
-.PP
-\-v increase the verbosity level
-.PP
-\-b brief mode
-.PP
-\-N | \-nocolor use mono rather than color mode
-.PP
-\-C <ca_name> use the specified ca_name.
-.PP
-\-P <ca_port> use the specified ca_port.
-.PP
-\-t <timeout_ms> override the default timeout for the solicited mads.
-
-.SH EXAMPLE
-.PP
-ibdatacounts 2 # show data counters for lid 2
-.PP
-ibdatacounts 2 4 # show data counters for lid 2 port 4
-
-.SH SEE ALSO
-.BR perfquery(8),
-.BR ibaddr(8)
-
-.SH AUTHOR
-.TP
-Hal Rosenstock
-.RI < halr@voltaire.com >
diff --git a/contrib/ofed/management/infiniband-diags/man/ibdiscover.8 b/contrib/ofed/management/infiniband-diags/man/ibdiscover.8
deleted file mode 100644
index 5e1e019..0000000
--- a/contrib/ofed/management/infiniband-diags/man/ibdiscover.8
+++ /dev/null
@@ -1,50 +0,0 @@
-.TH IBDISCOVER.PL 8 "September 21, 2006" "OpenIB" "OpenIB Diagnostics"
-
-.SH NAME
-ibdiscover.pl \- annotate and compare InfiniBand topology
-
-.SH SYNOPSIS
-.B ibdiscover.pl
-
-.SH DESCRIPTION
-.PP
-ibdiscover.pl uses a topology file create by ibnetdiscover and a discover.map
-file which the network administrator creates which indicates the nodes
-to be expected and a ibdiscover.topo file which is the expected connectivity
-and produces a new connectivity file (discover.topo.new) and outputs
-the changes to stdout. The network administrator can choose to replace
-the "old" topo file with the new one or certain changes in.
-
-The syntax of the ibdiscover.map file is:
-
-<nodeGUID>|port|"Text for node"|<NodeDescription from ibnetdiscover format>
-
-e.g.
-
-8f10400410015|8|"ISR 6000"|# SW-6IB4 Voltaire port 0 lid 5
-
-8f10403960558|2|"HCA 1"|# MT23108 InfiniHost Mellanox Technologies
-
-The syntax of the old and new topo files (ibdiscover.topo and
-ibdiscover.topo.new) are:
-
-<LocalPort>|<LocalNodeGUID>|<RemotePort>|<RemoteNodeGUID>
-
-e.g.
-
-10|5442ba00003080|1|8f10400410015
-
-These topo files are produced by the ibdiscover.pl tool.
-
-.SH USAGE
-
-.PP
-ibnetdiscover | ibdiscover.pl
-
-.SH SEE ALSO
-.BR ibnetdiscover(8)
-
-.SH AUTHOR
-.TP
-Hal Rosenstock
-.RI < halr@voltaire.com >
diff --git a/contrib/ofed/management/infiniband-diags/man/ibfindnodesusing.8 b/contrib/ofed/management/infiniband-diags/man/ibfindnodesusing.8
deleted file mode 100644
index d5e3e68..0000000
--- a/contrib/ofed/management/infiniband-diags/man/ibfindnodesusing.8
+++ /dev/null
@@ -1,30 +0,0 @@
-.TH IBFINDNODESUSING 8 "May 22, 2007" "OpenIB" "OpenIB Diagnostics"
-
-.SH NAME
-ibfindnodesusing.pl \- find a list of end nodes which are routed through the specified switch and port
-
-.SH SYNOPSIS
-.B ibfindnodesusing.pl
-[-R] <switch_guid|switch_name> <port>
-
-.SH DESCRIPTION
-.PP
-ibfindnodesusing.pl uses ibroute and detects the current nodes which are routed
-through both directions of the link specified. The link is specified by one
-switch port end; the script finds the remote end automatically.
-
-
-.SH OPTIONS
-
-.PP
-.TP
-\fB\-R\fR
-Recalculate the ibnetdiscover information, ie do not use the cached
-information. This option is slower but should be used if the diag tools have
-not been used for some time or if there are other reasons to believe that
-the fabric has changed.
-
-.SH AUTHOR
-.TP
-Ira Weiny
-.RI < weiny2@llnl.gov >
diff --git a/contrib/ofed/management/infiniband-diags/man/ibhosts.8 b/contrib/ofed/management/infiniband-diags/man/ibhosts.8
deleted file mode 100644
index db3c8ce..0000000
--- a/contrib/ofed/management/infiniband-diags/man/ibhosts.8
+++ /dev/null
@@ -1,31 +0,0 @@
-.TH IBHOSTS 8 "July 25, 2006" "OpenIB" "OpenIB Diagnostics"
-
-.SH NAME
-ibhosts \- show InfiniBand host nodes in topology
-
-.SH SYNOPSIS
-.B ibhosts
-[\-h] [<topology-file> | \-C ca_name \-P ca_port \-t(imeout) timeout_ms]
-
-.SH DESCRIPTION
-.PP
-ibhosts is a script which either walks the IB subnet topology or uses an
-already saved topology file and extracts the CA nodes.
-
-.SH OPTIONS
-.PP
-\-h show the usage message
-.PP
-\-C <ca_name> use the specified ca_name.
-.PP
-\-P <ca_port> use the specified ca_port.
-.PP
-\-t <timeout_ms> override the default timeout for the solicited mads.
-
-.SH SEE ALSO
-.BR ibnetdiscover(8)
-
-.SH AUTHOR
-.TP
-Hal Rosenstock
-.RI < halr@voltaire.com >
diff --git a/contrib/ofed/management/infiniband-diags/man/ibidsverify.8 b/contrib/ofed/management/infiniband-diags/man/ibidsverify.8
deleted file mode 100644
index f42fd44..0000000
--- a/contrib/ofed/management/infiniband-diags/man/ibidsverify.8
+++ /dev/null
@@ -1,36 +0,0 @@
-.TH IBIDSVERIFY 8 "June 1, 2007" "OpenIB" "OpenIB Diagnostics"
-
-.SH NAME
-ibidsverify.pl \- validate IB identifiers in subnet and report errors
-
-.SH SYNOPSIS
-.B ibidsverify.pl
-[\-h] [\-R]
-
-.SH DESCRIPTION
-.PP
-ibidsverify.pl is a perl script which uses a full topology file that was created
-by ibnetdiscover, scans the network to validate the LIDs and GUIDs in the
-subnet. The validation consists of checking that there are no zero or duplicate
-identifiers.
-
-Finally, ibidsverify.pl will also reuse the cached ibnetdiscover output from
-some of the other diag tools which makes it a bit faster than running
-ibnetdiscover from scratch.
-
-.SH OPTIONS
-.PP
-.TP
-\fB\-R\fR
-Recalculate the ibnetdiscover information, ie do not use the cached
-information. This option is slower but should be used if the diag tools have
-not been used for some time or if there are other reasons to believe the
-fabric has changed.
-
-.SH SEE ALSO
-.BR ibnetdiscover(8)
-
-.SH AUTHOR
-.TP
-Hal Rosenstock
-.RI < halr@voltaire.com >
diff --git a/contrib/ofed/management/infiniband-diags/man/iblinkinfo.8 b/contrib/ofed/management/infiniband-diags/man/iblinkinfo.8
deleted file mode 100644
index ebb0394..0000000
--- a/contrib/ofed/management/infiniband-diags/man/iblinkinfo.8
+++ /dev/null
@@ -1,52 +0,0 @@
-.TH IBLINKINFO 8 "Jan 24, 2008" "OpenIB" "OpenIB Diagnostics"
-
-.SH NAME
-iblinkinfo.pl \- report link info for all links in the fabric
-
-.SH SYNOPSIS
-.B iblinkinfo.pl
- [-Rhcdl -C <ca_name> -P <ca_port> -v <lt,hoq,vlstall> -S <guid> -D <direct_route>]
-
-.SH DESCRIPTION
-.PP
-iblinkinfo.pl reports the link info for each port of each switch active in the
-IB fabric.
-
-.SH OPTIONS
-
-.PP
-.TP
-\fB\-R\fR
-Recalculate the ibnetdiscover information, ie do not use the cached
-information. This option is slower but should be used if the diag tools have
-not been used for some time or if there are other reasons to believe the
-fabric has changed.
-.TP
-\fB\-S <guid>\fR
-Output only the switch specified by <guid> (hex format)
-.TP
-\fB\-D <direct_route>\fR
-Output only the switch specified by the direct route path.
-.TP
-\fB\-l\fR
-Print all information for each link on one line. Default is to print a header
-with the switch information and then a list for each port (useful for grep\'ing output).
-.TP
-\fB\-d\fR
-Print only switches which have a port in the "Down" state.
-.TP
-\fB\-v <lt,hoq,vlstall>\fR
-Verify additional switch settings (<LifeTime>,<HoqLife>,<VLStallCount>)
-.TP
-\fB\-c\fR
-Print port capabilities (enabled and supported values)
-.TP
-\fB\-C <ca_name>\fR use the specified ca_name for the search.
-.TP
-\fB\-P <ca_port>\fR use the specified ca_port for the search.
-
-
-.SH AUTHOR
-.TP
-Ira Weiny
-.RI < weiny2@llnl.gov >
diff --git a/contrib/ofed/management/infiniband-diags/man/ibnetdiscover.8 b/contrib/ofed/management/infiniband-diags/man/ibnetdiscover.8
deleted file mode 100644
index 958efa9..0000000
--- a/contrib/ofed/management/infiniband-diags/man/ibnetdiscover.8
+++ /dev/null
@@ -1,233 +0,0 @@
-.TH IBNETDISCOVER 8 "January 3, 2008" "OpenIB" "OpenIB Diagnostics"
-
-.SH NAME
-ibnetdiscover \- discover InfiniBand topology
-
-.SH SYNOPSIS
-.B ibnetdiscover
-[\-d(ebug)] [\-e(rr_show)] [\-v(erbose)] [\-s(how)] [\-l(ist)] [\-g(rouping)] [\-H(ca_list)] [\-S(witch_list)] [\-R(outer_list)] [\-C ca_name] [\-P ca_port] [\-t(imeout) timeout_ms] [\-V(ersion)] [\--node-name-map <node-name-map>] [\-p(orts)] [\-h(elp)] [<topology-file>]
-
-.SH DESCRIPTION
-.PP
-ibnetdiscover performs IB subnet discovery and outputs a human readable
-topology file. GUIDs, node types, and port numbers are displayed
-as well as port LIDs and NodeDescriptions. All nodes (and links) are displayed
-(full topology). Optionally, this utility can be used to list the current
-connected nodes by nodetype. The output is printed to standard output
-unless a topology file is specified.
-
-.SH OPTIONS
-
-.PP
-.TP
-\fB\-l\fR, \fB\-\-list\fR
-List of connected nodes
-.TP
-\fB\-g\fR, \fB\-\-grouping\fR
-Show grouping. Grouping correlates IB nodes by different vendor specific
-schemes. It may also show the switch external ports correspondence.
-.TP
-\fB\-H\fR, \fB\-\-Hca_list\fR
-List of connected CAs
-.TP
-\fB\-S\fR, \fB\-\-Switch_list\fR
-List of connected switches
-.TP
-\fB\-R\fR, \fB\-\-Router_list\fR
-List of connected routers
-.TP
-\fB\-s\fR, \fB\-\-show\fR
-Show more information
-.TP
-\fB\-\-node\-name\-map\fR <node-name-map>
-Specify a node name map. The node name map file maps GUIDs to more user friendly
-names. See file format below.
-.TP
-\fB\-p\fR, \fB\-\-ports\fR
-Obtain a ports report which is a
-list of connected ports with relevant information (like LID, portnum,
-GUID, width, speed, and NodeDescription).
-
-.SH COMMON OPTIONS
-
-Most OpenIB diagnostics take the following common flags. The exact list of
-supported flags per utility can be found in the usage message and can be shown
-using the util_name -h syntax.
-
-# Debugging flags
-.PP
-\-d raise the IB debugging level.
- May be used several times (-ddd or -d -d -d).
-.PP
-\-e show send and receive errors (timeouts and others)
-.PP
-\-h show the usage message
-.PP
-\-v increase the application verbosity level.
- May be used several times (-vv or -v -v -v)
-.PP
-\-V show the version info.
-
-# Other common flags:
-.PP
-\-C <ca_name> use the specified ca_name.
-.PP
-\-P <ca_port> use the specified ca_port.
-.PP
-\-t <timeout_ms> override the default timeout for the solicited mads.
-
-Multiple CA/Multiple Port Support
-
-When no IB device or port is specified, the port to use is selected
-by the following criteria:
-.PP
-1. the first port that is ACTIVE.
-.PP
-2. if not found, the first port that is UP (physical link up).
-
-If a port and/or CA name is specified, the user request is
-attempted to be fulfilled, and will fail if it is not possible.
-
-.SH TOPOLOGY FILE FORMAT
-The topology file format is human readable and largely intuitive.
-Most identifiers are given textual names like vendor ID (vendid), device ID
-(device ID), GUIDs of various types (sysimgguid, caguid, switchguid, etc.).
-PortGUIDs are shown in parentheses (). For switches, this is shown on the
-switchguid line. For CA and router ports, it is shown on the connectivity lines. The IB node is identified followed by the number of ports and a quoted
-the node GUID. On the right of this line is a comment (#) followed by the
-NodeDescription in quotes. If the node is a switch, this line also contains
-whether switch port 0 is base or enhanced, and the LID and LMC of port 0.
-Subsequent lines pertaining to this node show the connectivity. On the
-left is the port number of the current node. On the right is the peer node
-(node at other end of link). It is identified in quotes with nodetype
-followed by - followed by NodeGUID with the port number in square brackets.
-Further on the right is a comment (#). What follows the comment is
-dependent on the node type. If it it a switch node, it is followed by
-the NodeDescription in quotes and the LID of the peer node. If it is a
-CA or router node, it is followed by the local LID and LMC and then
-followed by the NodeDescription in quotes and the LID of the peer node.
-The active link width and speed are then appended to the end of this
-output line.
-
-An example of this is:
-.nf
-#
-# Topology file: generated on Tue Jun 5 14:15:10 2007
-#
-# Max of 3 hops discovered
-# Initiated from node 0008f10403960558 port 0008f10403960559
-
-Non-Chassis Nodes
-
-vendid=0x8f1
-devid=0x5a06
-sysimgguid=0x5442ba00003000
-switchguid=0x5442ba00003080(5442ba00003080)
-Switch 24 "S-005442ba00003080" # "ISR9024 Voltaire" base port 0 lid 6 lmc 0
-[22] "H-0008f10403961354"[1](8f10403961355) # "MT23108 InfiniHost Mellanox Technologies" lid 4 4xSDR
-[10] "S-0008f10400410015"[1] # "SW-6IB4 Voltaire" lid 3 4xSDR
-[8] "H-0008f10403960558"[2](8f1040396055a) # "MT23108 InfiniHost Mellanox Technologies" lid 14 4xSDR
-[6] "S-0008f10400410015"[3] # "SW-6IB4 Voltaire" lid 3 4xSDR
-[12] "H-0008f10403960558"[1](8f10403960559) # "MT23108 InfiniHost Mellanox Technologies" lid 10 4xSDR
-
-vendid=0x8f1
-devid=0x5a05
-switchguid=0x8f10400410015(8f10400410015)
-Switch 8 "S-0008f10400410015" # "SW-6IB4 Voltaire" base port 0 lid 3 lmc 0
-[6] "H-0008f10403960984"[1](8f10403960985) # "MT23108 InfiniHost Mellanox Technologies" lid 16 4xSDR
-[4] "H-005442b100004900"[1](5442b100004901) # "MT23108 InfiniHost Mellanox Technologies" lid 12 4xSDR
-[1] "S-005442ba00003080"[10] # "ISR9024 Voltaire" lid 6 1xSDR
-[3] "S-005442ba00003080"[6] # "ISR9024 Voltaire" lid 6 4xSDR
-
-vendid=0x2c9
-devid=0x5a44
-caguid=0x8f10403960984
-Ca 2 "H-0008f10403960984" # "MT23108 InfiniHost Mellanox Technologies"
-[1](8f10403960985) "S-0008f10400410015"[6] # lid 16 lmc 1 "SW-6IB4 Voltaire" lid 3 4xSDR
-
-vendid=0x2c9
-devid=0x5a44
-caguid=0x5442b100004900
-Ca 2 "H-005442b100004900" # "MT23108 InfiniHost Mellanox Technologies"
-[1](5442b100004901) "S-0008f10400410015"[4] # lid 12 lmc 1 "SW-6IB4 Voltaire" lid 3 4xSDR
-
-vendid=0x2c9
-devid=0x5a44
-caguid=0x8f10403961354
-Ca 2 "H-0008f10403961354" # "MT23108 InfiniHost Mellanox Technologies"
-[1](8f10403961355) "S-005442ba00003080"[22] # lid 4 lmc 1 "ISR9024 Voltaire" lid 6 4xSDR
-
-vendid=0x2c9
-devid=0x5a44
-caguid=0x8f10403960558
-Ca 2 "H-0008f10403960558" # "MT23108 InfiniHost Mellanox Technologies"
-[2](8f1040396055a) "S-005442ba00003080"[8] # lid 14 lmc 1 "ISR9024 Voltaire" lid 6 4xSDR
-[1](8f10403960559) "S-005442ba00003080"[12] # lid 10 lmc 1 "ISR9024 Voltaire" lid 6 1xSDR
-.fi
-
-When grouping is used, IB nodes are organized into chasses which are
-numbered. Nodes which cannot be determined to be in a chassis are
-displayed as "Non-Chassis Nodes". External ports are also shown on the
-connectivity lines.
-
-
-.SH NODE NAME MAP FILE FORMAT
-The node name map is used to specify user friendly names for nodes in the
-output. GUIDs are used to perform the lookup.
-
-.TP
-\fBGenerically:\fR
-
-# comment
-.br
-<guid> "<name>"
-
-.TP
-\fBExample:\fR
-
-# IB1
-.br
-# Line cards
-.br
-0x0008f104003f125c "IB1 (Rack 11 slot 1 ) ISR9288/ISR9096 Voltaire sLB-24D"
-.br
-0x0008f104003f125d "IB1 (Rack 11 slot 1 ) ISR9288/ISR9096 Voltaire sLB-24D"
-.br
-0x0008f104003f10d2 "IB1 (Rack 11 slot 2 ) ISR9288/ISR9096 Voltaire sLB-24D"
-.br
-0x0008f104003f10d3 "IB1 (Rack 11 slot 2 ) ISR9288/ISR9096 Voltaire sLB-24D"
-.br
-0x0008f104003f10bf "IB1 (Rack 11 slot 12 ) ISR9288/ISR9096 Voltaire sLB-24D"
-.br
-.br
-# Spines
-.br
-0x0008f10400400e2d "IB1 (Rack 11 spine 1 ) ISR9288 Voltaire sFB-12D"
-.br
-0x0008f10400400e2e "IB1 (Rack 11 spine 1 ) ISR9288 Voltaire sFB-12D"
-.br
-0x0008f10400400e2f "IB1 (Rack 11 spine 1 ) ISR9288 Voltaire sFB-12D"
-.br
-0x0008f10400400e31 "IB1 (Rack 11 spine 2 ) ISR9288 Voltaire sFB-12D"
-.br
-0x0008f10400400e32 "IB1 (Rack 11 spine 2 ) ISR9288 Voltaire sFB-12D"
-.br
-.br
-# GUID Node Name
-.br
-0x0008f10400411a08 "SW1 (Rack 3) ISR9024 Voltaire 9024D"
-.br
-0x0008f10400411a28 "SW2 (Rack 3) ISR9024 Voltaire 9024D"
-.br
-0x0008f10400411a34 "SW3 (Rack 3) ISR9024 Voltaire 9024D"
-.br
-0x0008f104004119d0 "SW4 (Rack 3) ISR9024 Voltaire 9024D"
-.br
-
-.SH AUTHORS
-.TP
-Hal Rosenstock
-.RI < halr@voltaire.com >
-.TP
-Ira Weiny
-.RI < weiny2@llnl.gov >
diff --git a/contrib/ofed/management/infiniband-diags/man/ibnodes.8 b/contrib/ofed/management/infiniband-diags/man/ibnodes.8
deleted file mode 100644
index 901665d..0000000
--- a/contrib/ofed/management/infiniband-diags/man/ibnodes.8
+++ /dev/null
@@ -1,31 +0,0 @@
-.TH IBNODES 8 "July 25, 2006" "OpenIB" "OpenIB Diagnostics"
-
-.SH NAME
-ibnodes \- show InfiniBand nodes in topology
-
-.SH SYNOPSIS
-.B ibnodes
-[\-h] [<topology-file> | \-C ca_name \-P ca_port \-t(imeout) timeout_ms]
-
-.SH DESCRIPTION
-.PP
-ibnodes is a script which either walks the IB subnet topology or uses an
-already saved topology file and extracts the IB nodes (CAs and switches).
-
-.SH OPTIONS
-.PP
-\-h show the usage message
-.PP
-\-C <ca_name> use the specified ca_name.
-.PP
-\-P <ca_port> use the specified ca_port.
-.PP
-\-t <timeout_ms> override the default timeout for the solicited mads.
-.SH SEE ALSO
-
-.BR ibnetdiscover(8)
-
-.SH AUTHOR
-.TP
-Hal Rosenstock
-.RI < halr@voltaire.com >
diff --git a/contrib/ofed/management/infiniband-diags/man/ibping.8 b/contrib/ofed/management/infiniband-diags/man/ibping.8
deleted file mode 100644
index c25fc8d..0000000
--- a/contrib/ofed/management/infiniband-diags/man/ibping.8
+++ /dev/null
@@ -1,84 +0,0 @@
-.TH IBPING 8 "August 11, 2006" "OpenIB" "OpenIB Diagnostics"
-
-.SH NAME
-ibping \- ping an InfiniBand address
-
-.SH SYNOPSIS
-.B ibping
-[\-d(ebug)] [\-e(rr_show)] [\-v(erbose)] [\-G(uid)] [\-C ca_name] [\-P ca_port] [\-s smlid] [\-t(imeout) timeout_ms] [\-V(ersion)] [\-c ping_count] [\-f(lood)] [\-o oui] [\-S(erver)] [\-h(elp)] <dest lid | guid>
-
-.SH DESCRIPTION
-.PP
-ibping uses vendor mads to validate connectivity between IB nodes.
-On exit, (IP) ping like output is show. ibping is run as client/server.
-Default is to run as client. Note also that a default ping server is
-implemented within the kernel.
-
-.SH OPTIONS
-
-.PP
-.TP
-\fB\-c\fR
-stop after count packets
-.TP
-\fB\-f\fR, \fB\-\-flood\fR
-flood destination: send packets back to back without delay
-.TP
-\fB\-o\fR, \fB\-\-oui\fR
-use specified OUI number to multiplex vendor mads
-.TP
-\fB\-S\fR, \fB\-\-Server\fR
-start in server mode (do not return)
-
-.SH COMMON OPTIONS
-
-Most OpenIB diagnostics take the following common flags. The exact list of
-supported flags per utility can be found in the usage message and can be shown
-using the util_name -h syntax.
-
-# Debugging flags
-.PP
-\-d raise the IB debugging level.
- May be used several times (-ddd or -d -d -d).
-.PP
-\-e show send and receive errors (timeouts and others)
-.PP
-\-h show the usage message
-.PP
-\-v increase the application verbosity level.
- May be used several times (-vv or -v -v -v)
-.PP
-\-V show the version info.
-
-# Addressing flags
-.PP
-\-G use GUID address argument. In most cases, it is the Port GUID.
- Example:
- "0x08f1040023"
-.PP
-\-s <smlid> use 'smlid' as the target lid for SM/SA queries.
-
-# Other common flags:
-.PP
-\-C <ca_name> use the specified ca_name.
-.PP
-\-P <ca_port> use the specified ca_port.
-.PP
-\-t <timeout_ms> override the default timeout for the solicited mads.
-
-Multiple CA/Multiple Port Support
-
-When no IB device or port is specified, the port to use is selected
-by the following criteria:
-.PP
-1. the first port that is ACTIVE.
-.PP
-2. if not found, the first port that is UP (physical link up).
-
-If a port and/or CA name is specified, the user request is
-attempted to be fulfilled, and will fail if it is not possible.
-
-.SH AUTHOR
-.TP
-Hal Rosenstock
-.RI < halr@voltaire.com >
diff --git a/contrib/ofed/management/infiniband-diags/man/ibportstate.8 b/contrib/ofed/management/infiniband-diags/man/ibportstate.8
deleted file mode 100644
index 0306f29..0000000
--- a/contrib/ofed/management/infiniband-diags/man/ibportstate.8
+++ /dev/null
@@ -1,113 +0,0 @@
-.TH IBPORTSTATE 8 "October 19, 2006" "OpenIB" "OpenIB Diagnostics"
-
-.SH NAME
-ibportstate \- handle port (physical) state and link speed of an InfiniBand port
-
-.SH SYNOPSIS
-.B ibportstate
-[\-d(ebug)] [\-e(rr_show)] [\-v(erbose)] [\-D(irect)] [\-G(uid)] [\-s smlid] [\-V(ersion)] [\-C ca_name] [\-P ca_port] [\-t(imeout) timeout_ms] [\-h(elp)] <dest dr_path|lid|guid> <portnum> [<op>]
-
-.SH DESCRIPTION
-.PP
-ibportstate allows the port state and port physical state of an IB port
-to be queried (in addition to link width and speed being validated
-relative to the peer port when the port queried is a switch port),
-or a switch port to be disabled, enabled, or reset. It
-also allows the link speed enabled on any IB port to be adjusted.
-
-.SH OPTIONS
-
-.PP
-.TP
-op
-Port operations allowed
- supported ops: enable, disable, reset, speed, query
- Default is query
-.PP
- ops enable, disable, and reset are only allowed on switch ports
- (An error is indicated if attempted on CA or router ports)
- speed op is allowed on any port
- speed values are legal values for PortInfo:LinkSpeedEnabled
- (An error is indicated if PortInfo:LinkSpeedSupported does not support
- this setting)
- (NOTE: Speed changes are not effected until the port goes through
- link renegotiation)
- query also validates port characteristics (link width and speed)
- based on the peer port. This checking is done when the port
- queried is a switch port as it relies on combined routing
- (an initial LID route with directed routing to the peer) which
- can only be done on a switch. This peer port validation feature
- of query op requires LID routing to be functioning in the subnet.
-
-
-.SH COMMON OPTIONS
-
-Most OpenIB diagnostics take the following common flags. The exact list of
-supported flags per utility can be found in the usage message and can be shown
-using the util_name -h syntax.
-
-# Debugging flags
-.PP
-\-d raise the IB debugging level.
- May be used several times (-ddd or -d -d -d).
-.PP
-\-e show send and receive errors (timeouts and others)
-.PP
-\-h show the usage message
-.PP
-\-v increase the application verbosity level.
- May be used several times (-vv or -v -v -v)
-.PP
-\-V show the version info.
-
-# Addressing flags
-.PP
-\-D use directed path address arguments. The path
- is a comma separated list of out ports.
- Examples:
- "0" # self port
- "0,1,2,1,4" # out via port 1, then 2, ...
-.PP
-\-G use GUID address argument. In most cases, it is the Port GUID.
- Example:
- "0x08f1040023"
-.PP
-\-s <smlid> use 'smlid' as the target lid for SM/SA queries.
-
-# Other common flags:
-.PP
-\-C <ca_name> use the specified ca_name.
-.PP
-\-P <ca_port> use the specified ca_port.
-.PP
-\-t <timeout_ms> override the default timeout for the solicited mads.
-
-Multiple CA/Multiple Port Support
-
-When no IB device or port is specified, the port to use is selected
-by the following criteria:
-.PP
-1. the first port that is ACTIVE.
-.PP
-2. if not found, the first port that is UP (physical link up).
-
-If a port and/or CA name is specified, the user request is
-attempted to be fulfilled, and will fail if it is not possible.
-
-.SH EXAMPLES
-
-.PP
-ibportstate 3 1 disable # by lid
-.PP
-ibportstate -G 0x2C9000100D051 1 enable # by guid
-.PP
-ibportstate -D 0 1 # (query) by direct route
-.PP
-ibportstate 3 1 reset # by lid
-.PP
-ibportstate 3 1 speed 1 # by lid
-
-.SH AUTHOR
-.TP
-Hal Rosenstock
-.RI < halr@voltaire.com >
diff --git a/contrib/ofed/management/infiniband-diags/man/ibprintca.8 b/contrib/ofed/management/infiniband-diags/man/ibprintca.8
deleted file mode 100644
index ae304f7..0000000
--- a/contrib/ofed/management/infiniband-diags/man/ibprintca.8
+++ /dev/null
@@ -1,44 +0,0 @@
-.TH IBPRINTCA 8 "May 31, 2007" "OpenIB" "OpenIB Diagnostics"
-
-.SH NAME
-ibprintca.pl \- print either the ca specified or the list of cas from the ibnetdiscover output
-
-.SH SYNOPSIS
-.B ibprintca.pl
-[-R -l -C <ca_name> -P <ca_port>] [<ca_guid|node_name>]
-
-.SH DESCRIPTION
-.PP
-Faster than greping/viewing with an editor the output of ibnetdiscover,
-ibprintca.pl will parse out and print either the CA information for the
-specified CA or a list of all the CAs in the subnet.
-
-Finally, ibprintca.pl will also reuse the cached ibnetdiscover output from
-some of the other diag tools which makes it a bit faster than running
-ibnetdiscover from scratch.
-
-
-.SH OPTIONS
-
-.PP
-.TP
-\fB\-l\fR
-List the CAs (simply a wrapper for ibhosts).
-.TP
-\fB\-R\fR
-Recalculate the ibnetdiscover information, ie do not use the cached
-information. This option is slower but should be used if the diag tools have
-not been used for some time or if there are other reasons to believe that
-the fabric has changed.
-.TP
-\fB\-C <ca_name>\fR use the specified ca_name for the search.
-.TP
-\fB\-P <ca_port>\fR use the specified ca_port for the search.
-
-.SH AUTHORS
-.TP
-Ira Weiny
-.RI < weiny2@llnl.gov >
-.TP
-Hal Rosenstock
-.RI < halr@voltaire.com >
diff --git a/contrib/ofed/management/infiniband-diags/man/ibprintrt.8 b/contrib/ofed/management/infiniband-diags/man/ibprintrt.8
deleted file mode 100644
index 4929586..0000000
--- a/contrib/ofed/management/infiniband-diags/man/ibprintrt.8
+++ /dev/null
@@ -1,42 +0,0 @@
-.TH IBPRINTRT 8 "May 31, 2007" "OpenIB" "OpenIB Diagnostics"
-
-.SH NAME
-ibprintrt.pl \- print either only the router specified or a list of routers from the ibnetdiscover output
-
-.SH SYNOPSIS
-.B ibprintrt.pl
-[-R -l -C <ca_name> -P <ca_port>] [<rt_guid|node_name>]
-
-.SH DESCRIPTION
-.PP
-Faster than greping/viewing with an editor the output of ibnetdiscover,
-ibprintrt.pl will parse out and print either the router information for the
-specified IB router or a list of all IB routers in the subnet.
-
-Finally, ibprintrt.pl will also reuse the cached ibnetdiscover output from
-some of the other diag tools which makes it a bit faster than running
-ibnetdiscover from scratch.
-
-
-.SH OPTIONS
-
-.PP
-.TP
-\fB\-l\fR
-List the Rts (simply a wrapper for ibrouters).
-.TP
-\fB\-R\fR
-Recalculate the ibnetdiscover information, ie do not use the cached
-information. This option is slower but should be used if the diag tools have
-not been used for some time or if there are other reasons to believe that
-the fabric has changed.
-.TP
-\fB\-C <ca_name>\fR use the specified ca_name for the search.
-.TP
-\fB\-P <ca_port>\fR use the specified ca_port for the search.
-
-
-.SH AUTHOR
-.TP
-Hal Rosenstock
-.RI < halr@voltaire.com >
diff --git a/contrib/ofed/management/infiniband-diags/man/ibprintswitch.8 b/contrib/ofed/management/infiniband-diags/man/ibprintswitch.8
deleted file mode 100644
index 11e0a87..0000000
--- a/contrib/ofed/management/infiniband-diags/man/ibprintswitch.8
+++ /dev/null
@@ -1,47 +0,0 @@
-.TH IBPRINTSWITCH 8 "May 31, 2007" "OpenIB" "OpenIB Diagnostics"
-
-.SH NAME
-ibprintswitch.pl \- print either the switch specified or a list of switches from the ibnetdiscover output
-
-.SH SYNOPSIS
-.B ibprintswitch.pl
-[-R -l -C <ca_name> -P <ca_port>] [<switch_guid|switch_name>]
-
-.SH DESCRIPTION
-.PP
-Faster than greping/viewing with an editor the output of ibnetdiscover,
-ibprintswitch.pl will parse out and print either the switch information for the
-switch specified or a list of all the switches found in the subnet.
-In addition, it will crudely parse on the node description
-information and if found report all the information for an entire chasis if the
-description information is consistent.
-
-Finally, ibprintswitch.pl will also reuse the cached ibnetdiscover output from
-some of the other diag tools which makes it a bit faster than running
-ibnetdiscover from scratch.
-
-.SH OPTIONS
-
-.PP
-.TP
-\fB\-l\fR
-List the switches (simply a wrapper for ibswitches).
-.TP
-\fB\-R\fR
-Recalculate the ibnetdiscover information, ie do not use the cached
-information. This option is slower but should be used if the diag tools have
-not been used for some time or if there are other reasons to believe that
-the fabric has changed.
-.TP
-\fB\-C <ca_name>\fR use the specified ca_name for the search.
-.TP
-\fB\-P <ca_port>\fR use the specified ca_port for the search.
-
-
-.SH AUTHORS
-.TP
-Ira Weiny
-.RI < weiny2@llnl.gov >
-.TP
-Hal Rosenstock
-.RI < halr@voltaire.com >
diff --git a/contrib/ofed/management/infiniband-diags/man/ibqueryerrors.8 b/contrib/ofed/management/infiniband-diags/man/ibqueryerrors.8
deleted file mode 100644
index 5c7eb17..0000000
--- a/contrib/ofed/management/infiniband-diags/man/ibqueryerrors.8
+++ /dev/null
@@ -1,63 +0,0 @@
-.TH IBQUERYERRORS 8 "Jan 24, 2008" "OpenIB" "OpenIB Diagnostics"
-
-.SH NAME
-ibqueryerrors.pl \- query and report non-zero IB port counters
-
-.SH SYNOPSIS
-.B ibqueryerrors.pl
-[-a -c -r -R -C <ca_name> -P <ca_port> -s <err1,err2,...> -S <switch_guid> -D <direct_route> -d]
-
-.SH DESCRIPTION
-.PP
-ibqueryerrors.pl reports the port counters of switches. This is similar to
-ibcheckerrors with the additional ability to filter out selected errors,
-include the optional transmit and receive data counters, report actions to
-remedy a non-zero count, and report full link information for the link
-reported.
-
-.SH OPTIONS
-
-.PP
-.TP
-\fB\-a\fR
-Report an action to take. Some of the counters are not errors in and of
-themselves. This reports some more information on what the counters mean and
-what actions can/should be taken if they are non-zero.
-.TP
-\fB\-c\fR
-Suppress some of the common "side effect" counters. These counters usually do
-not indicate an error condition and can be usually be safely ignored.
-.TP
-\fB\-r\fR
-Report the port information. This includes LID, port, external port (if
-applicable), link speed setting, remote GUID, remote port, remote external port
-(if applicable), and remote node description information.
-.TP
-\fB\-R\fR
-Recalculate the ibnetdiscover information, ie do not use the cached
-information. This option is slower but should be used if the diag tools have
-not been used for some time or if there are other reasons to believe that
-the fabric has changed.
-.TP
-\fB\-s <err1,err2,...>\fR
-Suppress the errors listed in the comma separated list provided.
-.TP
-\fB\-S <switch_guid>\fR
-Report results only for the switch specified. (hex format)
-.TP
-\fB\-D <direct_route>\fR
-Report results only for the switch specified by the direct route path.
-.TP
-\fB\-d\fR
-Include the optional transmit and receive data counters.
-.TP
-\fB\-C <ca_name>\fR use the specified ca_name for the search.
-.TP
-\fB\-P <ca_port>\fR use the specified ca_port for the search.
-
-
-.SH AUTHOR
-.TP
-Ira Weiny
-.RI < weiny2@llnl.gov >
-
diff --git a/contrib/ofed/management/infiniband-diags/man/ibroute.8 b/contrib/ofed/management/infiniband-diags/man/ibroute.8
deleted file mode 100644
index 9f28477..0000000
--- a/contrib/ofed/management/infiniband-diags/man/ibroute.8
+++ /dev/null
@@ -1,119 +0,0 @@
-.TH IBROUTE 8 "July 25, 2006" "OpenIB" "OpenIB Diagnostics"
-
-.SH NAME
-ibroute \- query InfiniBand switch forwarding tables
-
-.SH SYNOPSIS
-.B ibroute
-[\-d(ebug)] [-a(ll)] [-n(o_dests)] [-v(erbose)] [\-D(irect)] [\-G(uid)] [-M(ulticast)] [-s smlid] [\-C ca_name] [\-P ca_port] [\-t(imeout) timeout_ms] [\-V(ersion)] [\-h(elp)] [<dest dr_path|lid|guid> [<startlid> [<endlid>]]]
-
-.SH DESCRIPTION
-.PP
-ibroute uses SMPs to display the forwarding tables (unicast
-(LinearForwardingTable or LFT) or multicast (MulticastForwardingTable or MFT))
-for the specified switch LID and the optional lid (mlid) range.
-The default range is all valid entries in the range 1...FDBTop.
-
-.SH OPTIONS
-
-.PP
-.TP
-\fB\-a\fR, \fB\-\-all\fR
-show all lids in range, even invalid entries
-.TP
-\fB\-n\fR, \fB\-\-no_dests\fR
-do not try to resolve destinations
-.TP
-\fB\-M\fR, \fB\-\-Multicast\fR
-show multicast forwarding tables
-In this case, the range parameters are specifying the mlid range.
-
-.SH COMMON OPTIONS
-
-Most OpenIB diagnostics take the following common flags. The exact list of
-supported flags per utility can be found in the usage message and can be shown
-using the util_name -h syntax.
-
-# Debugging flags
-.PP
-\-d raise the IB debugging level.
- May be used several times (-ddd or -d -d -d).
-.PP
-\-e show send and receive errors (timeouts and others)
-.PP
-\-h show the usage message
-.PP
-\-v increase the application verbosity level.
- May be used several times (-vv or -v -v -v)
-.PP
-\-V show the version info.
-
-# Addressing flags
-.PP
-\-D use directed path address arguments. The path
- is a comma separated list of out ports.
- Examples:
- "0" # self port
- "0,1,2,1,4" # out via port 1, then 2, ...
-.PP
-\-G use GUID address argument. In most cases, it is the Port GUID.
- Example:
- "0x08f1040023"
-.PP
-\-s <smlid> use 'smlid' as the target lid for SM/SA queries.
-
-# Other common flags:
-.PP
-\-C <ca_name> use the specified ca_name.
-.PP
-\-P <ca_port> use the specified ca_port.
-.PP
-\-t <timeout_ms> override the default timeout for the solicited mads.
-
-Multiple CA/Multiple Port Support
-
-When no IB device or port is specified, the port to use is selected
-by the following criteria:
-.PP
-1. the first port that is ACTIVE.
-.PP
-2. if not found, the first port that is UP (physical link up).
-
-If a port and/or CA name is specified, the user request is
-attempted to be fulfilled, and will fail if it is not possible.
-
-.SH EXAMPLES
-
-.PP
-Unicast examples
-.PP
-ibroute 4 # dump all lids with valid out ports of switch with lid 4
-.PP
-ibroute -a 4 # same, but dump all lids, even with invalid out ports
-.PP
-ibroute -n 4 # simple dump format - no destination resolution
-.PP
-ibroute 4 10 # dump lids starting from 10 (up to FDBTop)
-.PP
-ibroute 4 0x10 0x20 # dump lid range
-.PP
-ibroute -G 0x08f1040023 # resolve switch by GUID
-.PP
-ibroute -D 0,1 # resolve switch by direct path
-
-.PP
-Multicast examples
-.PP
-ibroute -M 4 # dump all non empty mlids of switch with lid 4
-.PP
-ibroute -M 4 0xc010 0xc020 # same, but with range
-.PP
-ibroute -M -n 4 # simple dump format
-
-.SH SEE ALSO
-.BR ibtracert (8)
-
-.SH AUTHOR
-.TP
-Hal Rosenstock
-.RI < halr@voltaire.com >
diff --git a/contrib/ofed/management/infiniband-diags/man/ibrouters.8 b/contrib/ofed/management/infiniband-diags/man/ibrouters.8
deleted file mode 100644
index 9c3ef68..0000000
--- a/contrib/ofed/management/infiniband-diags/man/ibrouters.8
+++ /dev/null
@@ -1,31 +0,0 @@
-.TH IBROUTERS 8 "May 30, 2007" "OpenIB" "OpenIB Diagnostics"
-
-.SH NAME
-ibrouters \- show InfiniBand router nodes in topology
-
-.SH SYNOPSIS
-.B ibrouters
-[\-h] [<topology-file> | \-C ca_name \-P ca_port \-t(imeout) timeout_ms]
-
-.SH DESCRIPTION
-.PP
-ibrouters is a script which either walks the IB subnet topology or uses an
-already saved topology file and extracts the Rt nodes.
-
-.SH OPTIONS
-.PP
-\-h show the usage message
-.PP
-\-C <ca_name> use the specified ca_name.
-.PP
-\-P <ca_port> use the specified ca_port.
-.PP
-\-t <timeout_ms> override the default timeout for the solicited mads.
-
-.SH SEE ALSO
-.BR ibnetdiscover(8)
-
-.SH AUTHOR
-.TP
-Hal Rosenstock
-.RI < halr@voltaire.com >
diff --git a/contrib/ofed/management/infiniband-diags/man/ibstat.8 b/contrib/ofed/management/infiniband-diags/man/ibstat.8
deleted file mode 100644
index b607d83..0000000
--- a/contrib/ofed/management/infiniband-diags/man/ibstat.8
+++ /dev/null
@@ -1,110 +0,0 @@
-.TH IBSTAT 8 "July 25, 2006" "OpenIB" "OpenIB Diagnostics"
-
-.SH NAME
-ibstat \- query basic status of InfiniBand device(s)
-
-.SH SYNOPSIS
-.B ibstat
-[\-d(ebug)] [\-l(ist_of_cas)] [\-s(hort)] [\-p(ort_list)] [\-V(ersion)] [\-h] <ca_name> [portnum]
-
-.SH DESCRIPTION
-.PP
-ibstat is a binary which displays basic information obtained from the local
-IB driver. Output includes LID, SMLID, port state, link width active, and port
-physical state.
-
-It is similar to the ibstatus utility but implemented as a binary rather
-than a script. It has options to list CAs and/or ports and displays more
-information than ibstatus.
-
-.SH OPTIONS
-
-.PP
-.TP
-\fB\-l\fR, \fB\-\-list_of_cas\fR
-list all IB devices
-.TP
-\fB\-s\fR, \fB\-\-short\fR
-short output
-.TP
-\fB\-p\fR, \fB\-\-port_list\fR
-show port list
-.TP
-ca_name
-InfiniBand device name
-.TP
-portnum
-port number of InfiniBand device
-
-.SH COMMON OPTIONS
-
-Most OpenIB diagnostics take the following common flags. The exact list of
-supported flags per utility can be found in the usage message and can be shown
-using the util_name -h syntax.
-
-# Debugging flags
-.PP
-\-d raise the IB debugging level.
- May be used several times (-ddd or -d -d -d).
-.PP
-\-e show send and receive errors (timeouts and others)
-.PP
-\-h show the usage message
-.PP
-\-v increase the application verbosity level.
- May be used several times (-vv or -v -v -v)
-.PP
-\-V show the version info.
-
-# Addressing flags
-.PP
-\-D use directed path address arguments. The path
- is a comma separated list of out ports.
- Examples:
- "0" # self port
- "0,1,2,1,4" # out via port 1, then 2, ...
-.PP
-\-G use GUID address argument. In most cases, it is the Port GUID.
- Example:
- "0x08f1040023"
-.PP
-\-s <smlid> use 'smlid' as the target lid for SM/SA queries.
-
-# Other common flags:
-.PP
-\-C <ca_name> use the specified ca_name.
-.PP
-\-P <ca_port> use the specified ca_port.
-.PP
-\-t <timeout_ms> override the default timeout for the solicited mads.
-
-Multiple CA/Multiple Port Support
-
-When no IB device or port is specified, the port to use is selected
-by the following criteria:
-.PP
-1. the first port that is ACTIVE.
-.PP
-2. if not found, the first port that is UP (physical link up).
-
-If a port and/or CA name is specified, the user request is
-attempted to be fulfilled, and will fail if it is not possible.
-
-.SH EXAMPLES
-
-.PP
-ibstat # display status of all ports on all IB devices
-.PP
-ibstat -l # list all IB devices
-.PP
-ibstat -p # show port guids
-.PP
-ibstat mthca0 2 # show status of port 2 of 'mthca0'
-
-.SH SEE ALSO
-.BR ibstatus (8)
-
-.SH AUTHOR
-.TP
-Hal Rosenstock
-.RI < halr@voltaire.com >
diff --git a/contrib/ofed/management/infiniband-diags/man/ibstatus.8 b/contrib/ofed/management/infiniband-diags/man/ibstatus.8
deleted file mode 100644
index c4b3831..0000000
--- a/contrib/ofed/management/infiniband-diags/man/ibstatus.8
+++ /dev/null
@@ -1,41 +0,0 @@
-.TH IBSTATUS 8 "July 25, 2006" "OpenIB" "OpenIB Diagnostics"
-
-.SH NAME
-ibstatus \- query basic status of InfiniBand device(s)
-
-.SH SYNOPSIS
-.B ibstatus
-[\-h] [devname[:port]]...
-
-.SH DESCRIPTION
-.PP
-ibstatus is a script which displays basic information obtained from the local
-IB driver. Output includes LID, SMLID, port state, link width active, and port
-physical state.
-
-.SH OPTIONS
-
-.PP
-.TP
-devname
-InfiniBand device name
-.TP
-portnum
-port number of InfiniBand device
-
-.SH EXAMPLES
-
-.PP
-ibstatus # display status of all IB ports
-.PP
-ibstatus mthca1 # status of mthca1 ports
-.PP
-ibstatus mthca1:1 mthca0:2 # show status of specified ports
-
-.SH SEE ALSO
-.BR ibstat (8)
-
-.SH AUTHOR
-.TP
-Hal Rosenstock
-.RI < halr@voltaire.com >
diff --git a/contrib/ofed/management/infiniband-diags/man/ibswitches.8 b/contrib/ofed/management/infiniband-diags/man/ibswitches.8
deleted file mode 100644
index 3bd9904..0000000
--- a/contrib/ofed/management/infiniband-diags/man/ibswitches.8
+++ /dev/null
@@ -1,31 +0,0 @@
-.TH IBSWITCHES 8 "July 25, 2006" "OpenIB" "OpenIB Diagnostics"
-
-.SH NAME
-ibswitches\- show InfiniBand switch nodes in topology
-
-.SH SYNOPSIS
-.B ibswitches
-[\-h] [<topology-file> | \-C ca_name \-P ca_port \-t(imeout) timeout_ms]
-
-.SH DESCRIPTION
-.PP
-ibswitches is a script which either walks the IB subnet topology or uses an
-already saved topology file and extracts the switch nodes.
-
-.SH OPTIONS
-.PP
-\-h show the usage message
-.PP
-\-C <ca_name> use the specified ca_name.
-.PP
-\-P <ca_port> use the specified ca_port.
-.PP
-\-t <timeout_ms> override the default timeout for the solicited mads.
-
-.SH SEE ALSO
-.BR ibnetdiscover(8)
-
-.SH AUTHOR
-.TP
-Hal Rosenstock
-.RI < halr@voltaire.com >
diff --git a/contrib/ofed/management/infiniband-diags/man/ibswportwatch.8 b/contrib/ofed/management/infiniband-diags/man/ibswportwatch.8
deleted file mode 100644
index 72501ab..0000000
--- a/contrib/ofed/management/infiniband-diags/man/ibswportwatch.8
+++ /dev/null
@@ -1,35 +0,0 @@
-.TH IBSWPORTWATCH 8 "September 27, 2006" "OpenIB" "OpenIB Diagnostics"
-
-.SH NAME
-ibswportwatch.pl \- poll the counters on the specified switch/port and report rate
-of change information.
-
-.SH SYNOPSIS
-.B ibswportwatch.pl
-[-p <pause_time> -v -n <cycles> -G] <guid|lid> <port>
-
-.SH DESCRIPTION
-.PP
-ibswportwatch.pl polls the port counters of the specified port and calculates rate
-of change information.
-
-.SH OPTIONS
-
-.PP
-.TP
-\fB\-p <pause_time>\fR
-Specify a pause time (polling interval) other than the default.
-.TP
-\fB\-v\fR
-Be verbose.
-.TP
-\fB\-n <cycles>\fR
-Run for a set number of poll intervals and stop. (Default == -1 == forever)
-.TP
-\fB\-G\fR
-The address provided is a GUID rather than LID.
-
-.SH AUTHOR
-.TP
-Ira Weiny
-.RI < weiny2@llnl.gov >
diff --git a/contrib/ofed/management/infiniband-diags/man/ibsysstat.8 b/contrib/ofed/management/infiniband-diags/man/ibsysstat.8
deleted file mode 100644
index 2f2c69f..0000000
--- a/contrib/ofed/management/infiniband-diags/man/ibsysstat.8
+++ /dev/null
@@ -1,83 +0,0 @@
-.TH IBSYSSTAT 8 "August 11, 2006" "OpenIB" "OpenIB Diagnostics"
-
-.SH NAME
-ibsysstat \- system status on an InfiniBand address
-
-.SH SYNOPSIS
-.B ibsysstat
-[\-d(ebug)] [\-e(rr_show)] [\-v(erbose)] [\-G(uid)] [\-C ca_name] [\-P ca_port] [\-s smlid] [\-t(imeout) timeout_ms] [\-V(ersion)] [\-o oui] [\-S(erver)] [\-h(elp)] <dest lid | guid> [<op>]
-
-.SH DESCRIPTION
-.PP
-ibsysstat uses vendor mads to validate connectivity between IB nodes
-and obtain other information about the IB node. ibsysstat is run as
-client/server. Default is to run as client.
-
-.SH OPTIONS
-
-.PP
-.TP
-Current supported operations:
- ping \- verify connectivity to server (default)
- host \- obtain host information from server
- cpu \- obtain cpu information from server
-.TP
-\fB\-o\fR, \fB\-\-oui\fR
-use specified OUI number to multiplex vendor mads
-.TP
-\fB\-S\fR, \fB\-\-Server\fR
-start in server mode (do not return)
-
-
-.SH COMMON OPTIONS
-
-Most OpenIB diagnostics take the following common flags. The exact list of
-supported flags per utility can be found in the usage message and can be shown
-using the util_name -h syntax.
-
-# Debugging flags
-.PP
-\-d raise the IB debugging level.
- May be used several times (-ddd or -d -d -d).
-.PP
-\-e show send and receive errors (timeouts and others)
-.PP
-\-h show the usage message
-.PP
-\-v increase the application verbosity level.
- May be used several times (-vv or -v -v -v)
-.PP
-\-V show the version info.
-
-# Addressing flags
-.PP
-\-G use GUID address argument. In most cases, it is the Port GUID.
- Example:
- "0x08f1040023"
-.PP
-\-s <smlid> use 'smlid' as the target lid for SM/SA queries.
-
-# Other common flags:
-.PP
-\-C <ca_name> use the specified ca_name.
-.PP
-\-P <ca_port> use the specified ca_port.
-.PP
-\-t <timeout_ms> override the default timeout for the solicited mads.
-
-Multiple CA/Multiple Port Support
-
-When no IB device or port is specified, the port to use is selected
-by the following criteria:
-.PP
-1. the first port that is ACTIVE.
-.PP
-2. if not found, the first port that is UP (physical link up).
-
-If a port and/or CA name is specified, the user request is
-attempted to be fulfilled, and will fail if it is not possible.
-
-.SH AUTHOR
-.TP
-Hal Rosenstock
-.RI < halr@voltaire.com >
diff --git a/contrib/ofed/management/infiniband-diags/man/ibtracert.8 b/contrib/ofed/management/infiniband-diags/man/ibtracert.8
deleted file mode 100644
index 1b48572..0000000
--- a/contrib/ofed/management/infiniband-diags/man/ibtracert.8
+++ /dev/null
@@ -1,112 +0,0 @@
-.TH IBTRACERT 8 "April 14, 2007" "OpenIB" "OpenIB Diagnostics"
-
-.SH NAME
-ibtracert\- trace InfiniBand path
-
-.SH SYNOPSIS
-.B ibtracert
-[\-d(ebug)] [-v(erbose)] [\-D(irect)] [\-G(uids)] [-n(o_info)] [-m mlid] [-s
-smlid] [\-C ca_name] [\-P ca_port] [\-t(imeout) timeout_ms] [\-V(ersion)]
-[\-\-node\-name\-\-map <node-name-map>] [\-h(elp)] [<dest dr_path|lid|guid> [<startlid> [<endlid>]]]
-
-.SH DESCRIPTION
-.PP
-ibtracert uses SMPs to trace the path from a source GID/LID to a
-destination GID/LID. Each hop along the path is displayed until the destination
-is reached or a hop does not respond. By using the -m option, multicast path
-tracing can be performed between source and destination nodes.
-
-.SH OPTIONS
-
-.PP
-.TP
-\fB\-n\fR, \fB\-\-no_info\fR
-simple format; don't show additional information
-.TP
-\fB\-m\fR
-show the multicast trace of the specified mlid
-.TP
-\fB\-\-node\-name\-map\fR <node-name-map>
-Specify a node name map. The node name map file maps GUIDs to more user friendly
-names. See
-.B ibnetdiscover(8)
-for node name map file format.
-
-.SH COMMON OPTIONS
-
-Most OpenIB diagnostics take the following common flags. The exact list of
-supported flags per utility can be found in the usage message and can be shown
-using the util_name -h syntax.
-
-# Debugging flags
-.PP
-\-d raise the IB debugging level.
- May be used several times (-ddd or -d -d -d).
-.PP
-\-h show the usage message
-.PP
-\-v increase the application verbosity level.
- May be used several times (-vv or -v -v -v)
-.PP
-\-V show the version info.
-
-# Addressing flags
-.PP
-\-D use directed path address arguments. The path
- is a comma separated list of out ports.
- Examples:
- "0" # self port
- "0,1,2,1,4" # out via port 1, then 2, ...
-.PP
-\-G use GUID address argument. In most cases, it is the Port GUID.
- Example:
- "0x08f1040023"
-.PP
-\-s <smlid> use 'smlid' as the target lid for SM/SA queries.
-
-# Other common flags:
-.PP
-\-C <ca_name> use the specified ca_name.
-.PP
-\-P <ca_port> use the specified ca_port.
-.PP
-\-t <timeout_ms> override the default timeout for the solicited mads.
-
-Multiple CA/Multiple Port Support
-
-When no IB device or port is specified, the port to use is selected
-by the following criteria:
-.PP
-1. the first port that is ACTIVE.
-.PP
-2. if not found, the first port that is UP (physical link up).
-
-If a port and/or CA name is specified, the user request is
-attempted to be fulfilled, and will fail if it is not possible.
-
-.SH EXAMPLES
-
-.PP
-Unicast examples
-.PP
-ibtracert 4 16 # show path between lids 4 and 16
-.PP
-ibtracert -n 4 16 # same, but using simple output format
-.PP
-ibtracert -G 0x8f1040396522d 0x002c9000100d051 # use guid addresses
-
-.PP
-Multicast example
-.PP
-ibtracert -m 0xc000 4 16 # show multicast path of mlid 0xc000 between lids 4 and 16
-
-.SH SEE ALSO
-.BR ibroute (8)
-
-.SH AUTHOR
-.TP
-Hal Rosenstock
-.RI < halr@voltaire.com >
-.TP
-Ira Weiny
-.RI < weiny2@llnl.gov >
diff --git a/contrib/ofed/management/infiniband-diags/man/perfquery.8 b/contrib/ofed/management/infiniband-diags/man/perfquery.8
deleted file mode 100644
index 716d6ff..0000000
--- a/contrib/ofed/management/infiniband-diags/man/perfquery.8
+++ /dev/null
@@ -1,124 +0,0 @@
-.TH PERFQUERY 8 "March 29, 2007" "OpenIB" "OpenIB Diagnostics"
-
-.SH NAME
-perfquery \- query InfiniBand port counters
-
-.SH SYNOPSIS
-.B perfquery
-[\-d(ebug)] [\-G(uid)] [-e(xtended)] [-a(ll_ports)] [-l(oop_ports)] [-r(eset_after_read)] [-R(eset_only)] [\-C ca_name] [\-P ca_port] [\-t(imeout) timeout_ms] [\-V(ersion)] [\-h(elp)] [<lid|guid> [[port] [reset_mask]]]
-
-.SH DESCRIPTION
-.PP
-perfquery uses PerfMgt GMPs to obtain the PortCounters (basic performance
-and error counters) or PortExtendedCounters from the PMA at the node/port
-specified. Optionally shows aggregated counters for all ports of node.
-Also, optionally, reset after read, or only reset counters.
-
-Note: In both PortCounters and PortCountersExtended, components
-that represent Data (e.g. PortXmitData and PortRcvData) indicate octets
-divided by 4 rather than just octets.
-
-Note: Inputting a port of 255 indicates an operation be performed on all ports.
-
-.SH OPTIONS
-
-.PP
-.TP
-\fB\-e\fR, \fB\-\-extended\fR
-show extended port counters rather than (basic) port counters.
-Note that extended port counters attribute is optional.
-.TP
-\fB\-a\fR, \fB\-\-all_ports\fR
-show aggregated counters for all ports of the destination lid
-or reset all counters for all ports. If the destination lid
-does not support the AllPortSelect flag, all ports will be
-iterated through to emulate AllPortSelect behavior.
-.TP
-\fB\-l\fR, \fB\-\-loop_ports\fR
-If all ports are selected by the user (either through the
-\fB\-a\fR option or port 255) iterate through each port
-rather than doing than aggregate operation.
-.TP
-\fB\-r\fR, \fB\-\-reset_after_read\fR
-reset counters after read
-.TP
-\fB\-R\fR, \fB\-\-Reset_only\fR
-only reset counters
-
-.SH COMMON OPTIONS
-
-Most OpenIB diagnostics take the following common flags. The exact list of
-supported flags per utility can be found in the usage message and can be shown
-using the util_name -h syntax.
-
-# Debugging flags
-.PP
-\-d raise the IB debugging level.
- May be used several times (-ddd or -d -d -d).
-.PP
-\-e show send and receive errors (timeouts and others)
-.PP
-\-h show the usage message
-.PP
-\-v increase the application verbosity level.
- May be used several times (-vv or -v -v -v)
-.PP
-\-V show the version info.
-
-# Addressing flags
-.PP
-\-G use GUID address argument. In most cases, it is the Port GUID.
- Example:
- "0x08f1040023"
-.PP
-\-s <smlid> use 'smlid' as the target lid for SM/SA queries.
-
-# Other common flags:
-.PP
-\-C <ca_name> use the specified ca_name.
-.PP
-\-P <ca_port> use the specified ca_port.
-.PP
-\-t <timeout_ms> override the default timeout for the solicited mads.
-
-Multiple CA/Multiple Port Support
-
-When no IB device or port is specified, the port to use is selected
-by the following criteria:
-.PP
-1. the first port that is ACTIVE.
-.PP
-2. if not found, the first port that is UP (physical link up).
-
-If a port and/or CA name is specified, the user request is
-attempted to be fulfilled, and will fail if it is not possible.
-
-.SH EXAMPLES
-
-.PP
-perfquery # read local port performance counters
-.PP
-perfquery 32 1 # read performance counters from lid 32, port 1
-.PP
-perfquery -e 32 1 # read extended performance counters from lid 32, port 1
-.PP
-perfquery -a 32 # read perf counters from lid 32, all ports
-.PP
-perfquery -r 32 1 # read performance counters and reset
-.PP
-perfquery -e -r 32 1 # read extended performance counters and reset
-.PP
-perfquery -R 0x20 1 # reset performance counters of port 1 only
-.PP
-perfquery -e -R 0x20 1 # reset extended performance counters of port 1 only
-.PP
-perfquery -R -a 32 # reset performance counters of all ports
-.PP
-perfquery -R 32 2 0x0fff # reset only error counters of port 2
-.PP
-perfquery -R 32 2 0xf000 # reset only non-error counters of port 2
-
-.SH AUTHOR
-.TP
-Hal Rosenstock
-.RI < halr@voltaire.com >
diff --git a/contrib/ofed/management/infiniband-diags/man/saquery.8 b/contrib/ofed/management/infiniband-diags/man/saquery.8
deleted file mode 100644
index 82a5fed..0000000
--- a/contrib/ofed/management/infiniband-diags/man/saquery.8
+++ /dev/null
@@ -1,132 +0,0 @@
-.TH SAQUERY 8 "October 19, 2008" "OpenIB" "OpenIB Diagnostics"
-
-.SH NAME
-saquery \- query InfiniBand subnet administration attributes
-
-.SH SYNOPSIS
-.B saquery
-[\-h] [\-d] [\-p] [\-N] [\-\-list | \-D] [\-S] [\-I] [\-L] [\-l] [\-G] [\-O]
-[\-U] [\-c] [\-s] [\-g] [\-m] [\-x]
-[\-C ca_name] [\-P ca_port] [\-\-smkey val] [\-t(imeout) <msec>]
-[\-\-src\-to\-dst <src:dst>]
-[\-\-sgid\-to\-dgid <sgid\-dgid>]
-[\-\-node\-name\-map <node\-name\-map>]
-[<name> | <lid> | <guid>]
-
-.SH DESCRIPTION
-.PP
-saquery issues the selected SA query. Node records are queried by default.
-
-.SH OPTIONS
-
-.PP
-.TP
-\fB\-p\fR
-get PathRecord info
-.TP
-\fB\-N\fR
-get NodeRecord info
-.TP
-\fB\-\-list | \-D\fR
-get NodeDescriptions of CAs only
-.TP
-\fB\-S\fR
-get ServiceRecord info
-.TP
-\fB\-I\fR
-get InformInfoRecord (subscription) info
-.TP
-\fB\-L\fR
-return the Lids of the name specified
-.TP
-\fB\-l\fR
-return the unique Lid of the name specified
-.TP
-\fB\-G\fR
-return the Guids of the name specified
-.TP
-\fB\-O\fR
-return the name for the Lid specified
-.TP
-\fB\-U\fR
-return the name for the Guid specified
-.TP
-\fB\-c\fR
-get the SA's class port info
-.TP
-\fB\-s\fR
-return the PortInfoRecords with isSM or isSMdisabled capability mask bit on
-.TP
-\fB\-g\fR
-get multicast group info
-.TP
-\fB\-m\fR
-get multicast member info. If a group is specified, limit the output to the
-group specified and print one line containing only the GUID and node
-description for each entry. Example: saquery -m 0xc000
-.TP
-\fB\-x\fR
-get LinkRecord info
-.TP
-\fB\-\-src-to-dst\fR
-get a PathRecord for <src:dst>
-where src and dst are either node names or LIDs
-.TP
-.B \-\-sgid\-to\-dgid
-get a PathRecord for
-.I sgid
-to
-.I dgid
-where both GIDs are in an IPv6 format acceptable to
-.BR inet_pton (3).
-.TP
-\fB\-C\fR <ca_name>
-use the specified ca_name.
-.TP
-\fB\-P\fR <ca_port>
-use the specified ca_port.
-.TP
-\fB\-\-smkey\fR <val>
-use SM_Key value for the query. Will be used only with "trusted" queries.
-If non-numeric value (like 'x') is specified then saquery will prompt for
-a value.
-.TP
-\fB\-t\fR, \fB\-timeout\fR <msec>
-Specify SA query response timeout in milliseconds.
-Default is 100 milliseconds. You may want to use
-this option if IB_TIMEOUT is indicated.
-.TP
-\fB\-\-node\-name\-map\fR <node-name-map>
-Specify a node name map. The node name map file maps GUIDs to more user friendly
-names. See
-.B ibnetdiscover(8)
-for node name map file format. Only used with the \fB\-O\fR and \fB\-U\fR options.
-.TP
-Supported query names (and aliases):
- ClassPortInfo (CPI)
- NodeRecord (NR)
- PortInfoRecord (PIR) [[lid]/[port]]
- SL2VLTableRecord (SL2VL) [[lid]/[in_port]/[out_port]]
- PKeyTableRecord (PKTR) [[lid]/[port]/[block]]
- VLArbitrationTableRecord (VLAR) [[lid]/[port]/[block]]
- InformInfoRecord (IIR)
- LinkRecord (LR) [[from_lid]/[from_port]] [[to_lid]/[to_port]]
- ServiceRecord (SR)
- PathRecord (PR)
- MCMemberRecord (MCMR)
- LFTRecord (LFTR) [[lid]/[block]]
- MFTRecord (MFTR) [[mlid]/[position]/[block]]
-.TP
-\fB\-d\fR
-enable debugging
-.TP
-\fB\-h\fR
-show help
-
-.SH AUTHORS
-.TP
-Ira Weiny
-.RI < weiny2@llnl.gov >
-.TP
-Hal Rosenstock
-.RI < halr@voltaire.com >
diff --git a/contrib/ofed/management/infiniband-diags/man/sminfo.8 b/contrib/ofed/management/infiniband-diags/man/sminfo.8
deleted file mode 100644
index 6c57362..0000000
--- a/contrib/ofed/management/infiniband-diags/man/sminfo.8
+++ /dev/null
@@ -1,105 +0,0 @@
-.TH SMINFO 8 "July 25, 2006" "OpenIB" "OpenIB Diagnostics"
-
-.SH NAME
-sminfo \- query InfiniBand SMInfo attribute
-
-.SH SYNOPSIS
-.B sminfo
-[\-d(ebug)] [\-e(rr_show)] -s state -p prio -a activity [\-D(irect)] [\-G(uid)] [\-C ca_name] [\-P ca_port] [\-t(imeout) timeout_ms] [\-V(ersion)] [\-h(elp)] sm_lid | sm_dr_path [modifier]
-
-.SH DESCRIPTION
-.PP
-Optionally set and display the output of a sminfo query in human readable
-format. The target SM is the one listed in the local port info, or the SM
-specified by the optional SM lid or by the SM direct routed path.
-.PP
-Note: using sminfo for any purposes other then simple query may be very
-dangerous, and may result in a malfunction of the target SM.
-
-.SH OPTIONS
-
-.PP
-.TP
-\fB\-s\fR
-set SM state
- 0 - not active
- 1 - discovering
- 2 - standby
- 3 - master
-.TP
-\fB\-p\fR
-set priority (0-15)
-.TP
-\fB\-a\fR
-set activity count
-
-.SH COMMON OPTIONS
-
-Most OpenIB diagnostics take the following common flags. The exact list of
-supported flags per utility can be found in the usage message and can be shown
-using the util_name -h syntax.
-
-# Debugging flags
-.PP
-\-d raise the IB debugging level.
- May be used several times (-ddd or -d -d -d).
-.PP
-\-e show send and receive errors (timeouts and others)
-.PP
-\-h show the usage message
-.PP
-\-v increase the application verbosity level.
- May be used several times (-vv or -v -v -v)
-.PP
-\-V show the version info.
-
-# Addressing flags
-.PP
-\-D use directed path address arguments. The path
- is a comma separated list of out ports.
- Examples:
- "0" # self port
- "0,1,2,1,4" # out via port 1, then 2, ...
-.PP
-\-G use GUID address argument. In most cases, it is the Port GUID.
- Example:
- "0x08f1040023"
-.PP
-\-s <smlid> use 'smlid' as the target lid for SM/SA queries.
-
-# Other common flags:
-.PP
-\-C <ca_name> use the specified ca_name.
-.PP
-\-P <ca_port> use the specified ca_port.
-.PP
-\-t <timeout_ms> override the default timeout for the solicited mads.
-
-Multiple CA/Multiple Port Support
-
-When no IB device or port is specified, the port to use is selected
-by the following criteria:
-.PP
-1. the first port that is ACTIVE.
-.PP
-2. if not found, the first port that is UP (physical link up).
-
-If a port and/or CA name is specified, the user request is
-attempted to be fulfilled, and will fail if it is not possible.
-
-.SH EXAMPLES
-
-.PP
-sminfo # local port\'s sminfo
-.PP
-sminfo 32 # show sminfo of lid 32
-.PP
-sminfo -G 0x8f1040023 # same but using guid address
-
-.SH SEE ALSO
-.BR smpdump (8)
-
-.SH AUTHOR
-.TP
-Hal Rosenstock
-.RI < halr@voltaire.com >
diff --git a/contrib/ofed/management/infiniband-diags/man/smpdump.8 b/contrib/ofed/management/infiniband-diags/man/smpdump.8
deleted file mode 100644
index 2a08753..0000000
--- a/contrib/ofed/management/infiniband-diags/man/smpdump.8
+++ /dev/null
@@ -1,98 +0,0 @@
-.TH SMPDUMP 8 "July 25, 2006" "OpenIB" "OpenIB Diagnostics"
-
-.SH NAME
-smpdump \- dump InfiniBand subnet management attributes
-
-.SH SYNOPSIS
-.B smpdump
-[\-s(ring)] [\-D(irect)] [\-C ca_name] [\-P ca_port] [\-t(imeout) timeout_ms] [\-V(ersion)] [\-h(elp)] <dlid|dr_path> <attr> [mod]
-
-.SH DESCRIPTION
-.PP
-smpdump is a general purpose SMP utility which gets SM attributes from a
-specified SMA. The result is dumped in hex by default.
-
-.SH OPTIONS
-
-.TP
-attr
-IBA attribute ID for SM attribute
-.TP
-mod
-IBA modifier for SM attribute
-
-.SH COMMON OPTIONS
-
-Most OpenIB diagnostics take the following common flags. The exact list of
-supported flags per utility can be found in the usage message and can be shown
-using the util_name -h syntax.
-
-# Debugging flags
-.PP
-\-d raise the IB debugging level.
- May be used several times (-ddd or -d -d -d).
-.PP
-\-e show send and receive errors (timeouts and others)
-.PP
-\-h show the usage message
-.PP
-\-v increase the application verbosity level.
- May be used several times (-vv or -v -v -v)
-.PP
-\-V show the version info.
-
-# Addressing flags
-.PP
-\-D use directed path address arguments. The path
- is a comma separated list of out ports.
- Examples:
- "0" # self port
- "0,1,2,1,4" # out via port 1, then 2, ...
-.PP
-\-G use GUID address argument. In most cases, it is the Port GUID.
- Example:
- "0x08f1040023"
-.PP
-\-s <smlid> use 'smlid' as the target lid for SM/SA queries.
-
-# Other common flags:
-.PP
-\-C <ca_name> use the specified ca_name.
-.PP
-\-P <ca_port> use the specified ca_port.
-.PP
-\-t <timeout_ms> override the default timeout for the solicited mads.
-
-Multiple CA/Multiple Port Support
-
-When no IB device or port is specified, the port to use is selected
-by the following criteria:
-.PP
-1. the first port that is ACTIVE.
-.PP
-2. if not found, the first port that is UP (physical link up).
-
-If a port and/or CA name is specified, the user request is
-attempted to be fulfilled, and will fail if it is not possible.
-
-.SH EXAMPLES
-
-Direct Routed Examples
-.PP
-smpdump -D 0,1,2,3,5 16 # NODE DESC
-.PP
-smpdump -D 0,1,2 0x15 2 # PORT INFO, port 2
-
-LID Routed Examples
-.PP
-smpdump 3 0x15 2 # PORT INFO, lid 3 port 2
-.PP
-smpdump 0xa0 0x11 # NODE INFO, lid 0xa0
-
-.SH SEE ALSO
-.BR smpquery (8)
-
-.SH AUTHOR
-.TP
-Hal Rosenstock
-.RI < halr@voltaire.com >
diff --git a/contrib/ofed/management/infiniband-diags/man/smpquery.8 b/contrib/ofed/management/infiniband-diags/man/smpquery.8
deleted file mode 100644
index 5b719c4..0000000
--- a/contrib/ofed/management/infiniband-diags/man/smpquery.8
+++ /dev/null
@@ -1,113 +0,0 @@
-.TH SMPQUERY 8 "March 14, 2007" "OpenIB" "OpenIB Diagnostics"
-
-.SH NAME
-smpquery \- query InfiniBand subnet management attributes
-
-.SH SYNOPSIS
-.B smpquery
-[\-d(ebug)] [\-e(rr_show)] [\-v(erbose)] [\-D(irect)] [\-G(uid)] [\-C ca_name] [\-P ca_port] [\-t(imeout) timeout_ms] [--node-name-map node-name-map] [\-V(ersion)] [\-h(elp)] <op> <dest dr_path|lid|guid> [op params]
-
-.SH DESCRIPTION
-.PP
-smpquery allows a basic subset of standard SMP queries including the following:
-node info, node description, switch info, port info. Fields are displayed in
-human readable format.
-
-.SH OPTIONS
-
-.PP
-.TP
-Current supported operations and their parameters:
- nodeinfo <addr>
- nodedesc <addr>
- portinfo <addr> [<portnum>] # default port is zero
- switchinfo <addr>
- pkeys <addr> [<portnum>]
- sl2vl <addr> [<portnum>]
- vlarb <addr> [<portnum>]
- guids <addr>
-
-.TP
-\fB\-\-node\-name\-map\fR <node-name-map>
-Specify a node name map. The node name map file maps GUIDs to more user friendly
-names. See
-.B ibnetdiscover(8)
-for node name map file format.
-
-.SH COMMON OPTIONS
-
-Most OpenIB diagnostics take the following common flags. The exact list of
-supported flags per utility can be found in the usage message and can be shown
-using the util_name -h syntax.
-
-# Debugging flags
-.PP
-\-d raise the IB debugging level.
- May be used several times (-ddd or -d -d -d).
-.PP
-\-e show send and receive errors (timeouts and others)
-.PP
-\-h show the usage message
-.PP
-\-v increase the application verbosity level.
- May be used several times (-vv or -v -v -v)
-.PP
-\-V show the version info.
-
-# Addressing flags
-.PP
-\-D use directed path address arguments. The path
- is a comma separated list of out ports.
- Examples:
- "0" # self port
- "0,1,2,1,4" # out via port 1, then 2, ...
-.PP
-\-c use combined route address arguments. The
- address is a combination of a LID and a direct route path.
- The LID specified is the DLID and the local LID is used
- as the DrSLID.
-.PP
-\-G use GUID address argument. In most cases, it is the Port GUID.
- Example:
- "0x08f1040023"
-.PP
-\-s <smlid> use 'smlid' as the target lid for SM/SA queries.
-
-# Other common flags:
-.PP
-\-C <ca_name> use the specified ca_name.
-.PP
-\-P <ca_port> use the specified ca_port.
-.PP
-\-t <timeout_ms> override the default timeout for the solicited mads.
-
-Multiple CA/Multiple Port Support
-
-When no IB device or port is specified, the port to use is selected
-by the following criteria:
-.PP
-1. the first port that is ACTIVE.
-.PP
-2. if not found, the first port that is UP (physical link up).
-
-If a port and/or CA name is specified, the user request is
-attempted to be fulfilled, and will fail if it is not possible.
-
-.SH EXAMPLES
-
-.PP
-smpquery portinfo 3 1 # portinfo by lid, with port modifier
-.PP
-smpquery -G switchinfo 0x2C9000100D051 1 # switchinfo by guid
-.PP
-smpquery -D nodeinfo 0 # nodeinfo by direct route
-.PP
-smpquery -c nodeinfo 6 0,12 # nodeinfo by combined route
-
-.SH SEE ALSO
-.BR smpdump (8)
-
-.SH AUTHOR
-.TP
-Hal Rosenstock
-.RI < halr@voltaire.com >
diff --git a/contrib/ofed/management/infiniband-diags/man/vendstat.8 b/contrib/ofed/management/infiniband-diags/man/vendstat.8
deleted file mode 100644
index e32650a..0000000
--- a/contrib/ofed/management/infiniband-diags/man/vendstat.8
+++ /dev/null
@@ -1,84 +0,0 @@
-.TH VENDSTAT 8 "February 15, 2007" "OpenIB" "OpenIB Diagnostics"
-
-.SH NAME
-vendstat \- query InfiniBand vendor specific functions
-
-.SH SYNOPSIS
-.B vendstat
-[\-d(ebug)] [\-G(uid)] [\-N] [\-w] [\-C ca_name] [\-P ca_port] [\-t(imeout) timeout_ms] [\-V(ersion)] [\-h(elp)] <lid|guid>
-
-.SH DESCRIPTION
-.PP
-vendstat uses vendor specific MADs to access beyond the IB spec
-vendor specific functionality. Currently, there is support only for
-Mellanox InfiniSwitch-III (IS3).
-
-.SH OPTIONS
-
-.PP
-.TP
-\fB\-N\fR
-show IS3 general information.
-.TP
-\fB\-w\fR
-show IS3 port xmit wait counters.
-
-.SH COMMON OPTIONS
-
-Most OpenIB diagnostics take the following common flags. The exact list of
-supported flags per utility can be found in the usage message and can be shown
-using the util_name -h syntax.
-
-# Debugging flags
-.PP
-\-d raise the IB debugging level.
- May be used several times (-ddd or -d -d -d).
-.PP
-\-e show send and receive errors (timeouts and others)
-.PP
-\-h show the usage message
-.PP
-\-v increase the application verbosity level.
- May be used several times (-vv or -v -v -v)
-.PP
-\-V show the version info.
-
-# Addressing flags
-.PP
-\-G use GUID address argument. In most cases, it is the Port GUID.
- Example:
- "0x08f1040023"
-.PP
-\-s <smlid> use 'smlid' as the target lid for SM/SA queries.
-
-# Other common flags:
-.PP
-\-C <ca_name> use the specified ca_name.
-.PP
-\-P <ca_port> use the specified ca_port.
-.PP
-\-t <timeout_ms> override the default timeout for the solicited mads.
-
-Multiple CA/Multiple Port Support
-
-When no IB device or port is specified, the port to use is selected
-by the following criteria:
-.PP
-1. the first port that is ACTIVE.
-.PP
-2. if not found, the first port that is UP (physical link up).
-
-If a port and/or CA name is specified, the user request is
-attempted to be fulfilled, and will fail if it is not possible.
-
-.SH EXAMPLES
-
-.PP
-vendstat -N 6 # read IS3 general information
-.PP
-vendstat -w 6 # read IS3 port xmit wait counters
-
-.SH AUTHOR
-.TP
-Hal Rosenstock
-.RI < halr@voltaire.com >
diff --git a/contrib/ofed/management/infiniband-diags/perltidy.sh b/contrib/ofed/management/infiniband-diags/perltidy.sh
deleted file mode 100755
index bc5f0de..0000000
--- a/contrib/ofed/management/infiniband-diags/perltidy.sh
+++ /dev/null
@@ -1,60 +0,0 @@
-#!/bin/bash
-#
-# Copyright (c) 2006 The Regents of the University of California.
-#
-# Produced at Lawrence Livermore National Laboratory.
-# Written by Ira Weiny <weiny2@llnl.gov>.
-#
-# This software is available to you under a choice of one of two
-# licenses. You may choose to be licensed under the terms of the GNU
-# General Public License (GPL) Version 2, available from the file
-# COPYING in the main directory of this source tree, or the
-# OpenIB.org BSD license below:
-#
-# Redistribution and use in source and binary forms, with or
-# without modification, are permitted provided that the following
-# conditions are met:
-#
-# - Redistributions of source code must retain the above
-# copyright notice, this list of conditions and the following
-# disclaimer.
-#
-# - Redistributions in binary form must reproduce the above
-# copyright notice, this list of conditions and the following
-# disclaimer in the documentation and/or other materials
-# provided with the distribution.
-#
-# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
-# BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
-# ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
-# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-# SOFTWARE.
-#
-
-tidy_cmd="perltidy -pt=2 -sbt=2 -bt=2 -nsfs -b -t -nola -ce -sbl -nbbc"
-
-argv0=`basename $0`
-scripts_dir=`dirname $0`/scripts
-
-if [ "$1" == "-h" ]; then
- echo "$argv0 [-h]"
- echo " Run perltidy on all perl scripts and modules in the scripts directory"
- exit 1
-fi
-
-cd $scripts_dir
-
-for file in *.pl ; do
- echo "tidy : $scripts_dir/$file"
- $tidy_cmd $file
-done
-
-for file in *.pm ; do
- echo "tidy : $scripts_dir/$file"
- $tidy_cmd $file
-done
-
-exit 0
diff --git a/contrib/ofed/management/infiniband-diags/scripts/IBswcountlimits.pm b/contrib/ofed/management/infiniband-diags/scripts/IBswcountlimits.pm
deleted file mode 100755
index 6623b8b..0000000
--- a/contrib/ofed/management/infiniband-diags/scripts/IBswcountlimits.pm
+++ /dev/null
@@ -1,501 +0,0 @@
-#!/usr/bin/perl
-#
-# Copyright (c) 2006 The Regents of the University of California.
-# Copyright (c) 2006-2008 Voltaire, Inc. All rights reserved.
-#
-# Produced at Lawrence Livermore National Laboratory.
-# Written by Ira Weiny <weiny2@llnl.gov>.
-# Erez Strauss from Voltaire for help in the get_link_ends code.
-#
-# This software is available to you under a choice of one of two
-# licenses. You may choose to be licensed under the terms of the GNU
-# General Public License (GPL) Version 2, available from the file
-# COPYING in the main directory of this source tree, or the
-# OpenIB.org BSD license below:
-#
-# Redistribution and use in source and binary forms, with or
-# without modification, are permitted provided that the following
-# conditions are met:
-#
-# - Redistributions of source code must retain the above
-# copyright notice, this list of conditions and the following
-# disclaimer.
-#
-# - Redistributions in binary form must reproduce the above
-# copyright notice, this list of conditions and the following
-# disclaimer in the documentation and/or other materials
-# provided with the distribution.
-#
-# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
-# BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
-# ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
-# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-# SOFTWARE.
-#
-
-use strict;
-
-%IBswcountlimits::cur_counts = ();
-%IBswcountlimits::new_counts = ();
-@IBswcountlimits::suppress_errors = ();
-$IBswcountlimits::link_ends = undef;
-$IBswcountlimits::pause_time = 10;
-$IBswcountlimits::cache_dir = "/var/cache/infiniband-diags";
-
-# all the PerfMgt counters
-@IBswcountlimits::counters = (
- "SymbolErrors", "LinkRecovers",
- "LinkDowned", "RcvErrors",
- "RcvRemotePhysErrors", "RcvSwRelayErrors",
- "XmtDiscards", "XmtConstraintErrors",
- "RcvConstraintErrors", "LinkIntegrityErrors",
- "ExcBufOverrunErrors", "VL15Dropped",
- "XmtData", "RcvData",
- "XmtPkts", "RcvPkts"
-);
-
-# non-critical counters
-%IBswcountlimits::error_counters = (
- "SymbolErrors",
-"No action is required except if counter is increasing along with LinkRecovers",
- "LinkRecovers",
-"If this is increasing along with SymbolErrors this may indicate a bad link, run ibswportwatch.pl on this port",
- "LinkDowned",
- "Number of times the port has gone down (Usually for valid reasons)",
- "RcvErrors",
-"This is a bad link, if the link is internal to a 288 try setting SDR, otherwise check the cable",
- "RcvRemotePhysErrors",
- "This indicates a problem ELSEWHERE in the fabric.",
- "XmtDiscards",
-"This is a symptom of congestion and may require tweaking either HOQ or switch lifetime values",
- "XmtConstraintErrors",
- "This is a result of bad partitioning, check partition configuration.",
- "RcvConstraintErrors",
- "This is a result of bad partitioning, check partition configuration.",
- "LinkIntegrityErrors",
- "May indicate a bad link, run ibswportwatch.pl on this port",
- "ExcBufOverrunErrors",
-"This is a flow control state machine error and can be caused by packets with physical errors",
- "VL15Dropped",
- "check with ibswportwatch.pl, if increasing in SMALL increments, OK",
- "RcvSwRelayErrors",
- "This counter can increase due to a valid network event"
-);
-
-sub check_counters
-{
- my $print_action = $_[0];
- my $actions = undef;
-
- COUNTER: foreach my $cnt (keys %IBswcountlimits::error_counters) {
- if ($IBswcountlimits::cur_counts{$cnt} > 0) {
- foreach my $sup_cnt (@IBswcountlimits::suppress_errors) {
- if ("$cnt" eq $sup_cnt) { next COUNTER; }
- }
- print " [$cnt == $IBswcountlimits::cur_counts{$cnt}]";
- if ("$print_action" eq "yes") {
- $actions = join " ",
- (
- $actions,
- " $cnt: $IBswcountlimits::error_counters{$cnt}\n"
- );
- }
- }
- }
-
- if ($actions) {
- print "\n Actions:\n$actions";
- }
-}
-
-# Data counters
-%IBswcountlimits::data_counters = (
- "XmtData",
-"Total number of data octets, divided by 4, transmitted on all VLs from the port",
- "RcvData",
-"Total number of data octets, divided by 4, received on all VLs to the port",
- "XmtPkts",
-"Total number of packets, excluding link packets, transmitted on all VLs from the port",
- "RcvPkts",
-"Total number of packets, excluding link packets, received on all VLs to the port"
-);
-
-sub check_data_counters
-{
- my $print_action = $_[0];
- my $actions = undef;
-
- COUNTER: foreach my $cnt (keys %IBswcountlimits::data_counters) {
- print " [$cnt == $IBswcountlimits::cur_counts{$cnt}]";
- if ("$print_action" eq "yes") {
- $actions = join " ",
- (
- $actions,
- " $cnt: $IBswcountlimits::data_counters{$cnt}\n"
- );
- }
- }
- if ($actions) {
- print "\n Descriptions:\n$actions";
- }
-}
-
-sub print_data_rates
-{
- COUNTER: foreach my $cnt (keys %IBswcountlimits::data_counters) {
- my $cnt_per_second = calculate_rate(
- $IBswcountlimits::cur_counts{$cnt},
- $IBswcountlimits::new_counts{$cnt}
- );
- print " $cnt_per_second $cnt/second\n";
- }
-}
-
-# =========================================================================
-# Rate dependent counters
-# calculate the count/sec
-# calculate_rate old_count new_count
-sub calculate_rate
-{
- my $rate = 0;
- my $old_val = $_[0];
- my $new_val = $_[1];
- my $rate = ($new_val - $old_val) / $IBswcountlimits::pause_time;
- return ($rate);
-}
-%IBswcountlimits::rate_dep_thresholds = (
- "SymbolErrors", 10, "LinkRecovers", 10,
- "RcvErrors", 10, "LinkIntegrityErrors", 10,
- "XmtDiscards", 10
-);
-
-sub check_counter_rates
-{
- foreach my $rate_count (keys %IBswcountlimits::rate_dep_thresholds) {
- my $rate = calculate_rate(
- $IBswcountlimits::cur_counts{$rate_count},
- $IBswcountlimits::new_counts{$rate_count}
- );
- if ($rate > $IBswcountlimits::rate_dep_thresholds{$rate_count}) {
- print "Detected excessive rate for $rate_count ($rate cnts/sec)\n";
- } elsif ($rate > 0) {
- print "Detected rate for $rate_count ($rate cnts/sec)\n";
- }
- }
-}
-
-# =========================================================================
-#
-sub clear_counters
-{
- # clear the counters
- foreach my $count (@IBswcountlimits::counters) {
- $IBswcountlimits::cur_counts{$count} = 0;
- }
-}
-
-# =========================================================================
-#
-sub any_counts
-{
- my $total = 0;
- my $count = 0;
- foreach $count (keys %IBswcountlimits::critical) {
- $total = $total + $IBswcountlimits::cur_counts{$count};
- }
- COUNTER: foreach $count (keys %IBswcountlimits::error_counters) {
- foreach my $sup_cnt (@IBswcountlimits::suppress_errors) {
- if ("$count" eq $sup_cnt) { next COUNTER; }
- }
- $total = $total + $IBswcountlimits::cur_counts{$count};
- }
- return ($total);
-}
-
-# =========================================================================
-#
-sub ensure_cache_dir
-{
- if (!(-d "$IBswcountlimits::cache_dir") &&
- !mkdir($IBswcountlimits::cache_dir, 0700)) {
- die "cannot create $IBswcountlimits::cache_dir: $!\n";
- }
-}
-
-# =========================================================================
-# get_cache_file(ca_name, ca_port)
-#
-sub get_cache_file
-{
- my $ca_name = $_[0];
- my $ca_port = $_[1];
- ensure_cache_dir;
- return (
- "$IBswcountlimits::cache_dir/ibnetdiscover-$ca_name-$ca_port.topology");
-}
-
-# =========================================================================
-# get_ca_name_port_param_string(ca_name, ca_port)
-#
-sub get_ca_name_port_param_string
-{
- my $ca_name = $_[0];
- my $ca_port = $_[1];
-
- if ("$ca_name" ne "") { $ca_name = "-C $ca_name"; }
- if ("$ca_port" ne "") { $ca_port = "-P $ca_port"; }
-
- return ("$ca_name $ca_port");
-}
-
-# =========================================================================
-# generate_ibnetdiscover_topology(ca_name, ca_port)
-#
-sub generate_ibnetdiscover_topology
-{
- my $ca_name = $_[0];
- my $ca_port = $_[1];
- my $cache_file = get_cache_file($ca_name, $ca_port);
- my $extra_params = get_ca_name_port_param_string($ca_name, $ca_port);
-
- if (`ibnetdiscover -g $extra_params > $cache_file`) {
- die "Execution of ibnetdiscover failed: $!\n";
- }
-}
-
-# =========================================================================
-# get_link_ends(regenerate_map, ca_name, ca_port)
-#
-sub get_link_ends
-{
- my $regenerate_map = $_[0];
- my $ca_name = $_[1];
- my $ca_port = $_[2];
-
- my $cache_file = get_cache_file($ca_name, $ca_port);
-
- if ($regenerate_map || !(-f "$cache_file")) {
- generate_ibnetdiscover_topology($ca_name, $ca_port);
- }
- open IBNET_TOPO, "<$cache_file"
- or die "Failed to open ibnet topology: $!\n";
- my $in_switch = "no";
- my $desc = "";
- my $guid = "";
- my $loc_sw_lid = "";
-
- my $loc_port = "";
- my $line = "";
-
- while ($line = <IBNET_TOPO>) {
- if ($line =~ /^Switch.*\"S-(.*)\"\s+#.*\"(.*)\".* lid (\d+).*/) {
- $guid = $1;
- $desc = $2;
- $loc_sw_lid = $3;
- $in_switch = "yes";
- }
- if ($in_switch eq "yes") {
- my $rec = undef;
- if ($line =~
-/^\[(\d+)\]\s+\"[HSR]-(.+)\"\[(\d+)\](\(.+\))?\s+#.*\"(.*)\"\.* lid (\d+).*/
- )
- {
- $loc_port = $1;
- my $rem_guid = $2;
- my $rem_port = $3;
- my $rem_port_guid = $4;
- my $rem_desc = $5;
- my $rem_lid = $6;
- $rec = {
- loc_guid => "0x$guid",
- loc_port => $loc_port,
- loc_ext_port => "",
- loc_desc => $desc,
- loc_sw_lid => $loc_sw_lid,
- rem_guid => "0x$rem_guid",
- rem_lid => $rem_lid,
- rem_port => $rem_port,
- rem_ext_port => "",
- rem_desc => $rem_desc,
- rem_port_guid => $rem_port_guid
- };
- }
- if ($line =~
-/^\[(\d+)\]\[ext (\d+)\]\s+\"[HSR]-(.+)\"\[(\d+)\](\(.+\))?\s+#.*\"(.*)\"\.* lid (\d+).*/
- )
- {
- $loc_port = $1;
- my $loc_ext_port = $2;
- my $rem_guid = $3;
- my $rem_port = $4;
- my $rem_port_guid = $5;
- my $rem_desc = $6;
- my $rem_lid = $7;
- $rec = {
- loc_guid => "0x$guid",
- loc_port => $loc_port,
- loc_ext_port => $loc_ext_port,
- loc_desc => $desc,
- loc_sw_lid => $loc_sw_lid,
- rem_guid => "0x$rem_guid",
- rem_lid => $rem_lid,
- rem_port => $rem_port,
- rem_ext_port => "",
- rem_desc => $rem_desc,
- rem_port_guid => $rem_port_guid
- };
- }
- if ($line =~
-/^\[(\d+)\]\s+\"[HSR]-(.+)\"\[(\d+)\]\[ext (\d+)\](\(.+\))?\s+#.*\"(.*)\"\.* lid (\d+).*/
- )
- {
- $loc_port = $1;
- my $rem_guid = $2;
- my $rem_port = $3;
- my $rem_ext_port = $4;
- my $rem_port_guid = $5;
- my $rem_desc = $6;
- my $rem_lid = $7;
- $rec = {
- loc_guid => "0x$guid",
- loc_port => $loc_port,
- loc_ext_port => "",
- loc_desc => $desc,
- loc_sw_lid => $loc_sw_lid,
- rem_guid => "0x$rem_guid",
- rem_lid => $rem_lid,
- rem_port => $rem_port,
- rem_ext_port => $rem_ext_port,
- rem_desc => $rem_desc,
- rem_port_guid => $rem_port_guid
- };
- }
- if ($line =~
-/^\[(\d+)\]\[ext (\d+)\]\s+\"[HSR]-(.+)\"\[(\d+)\]\[ext (\d+)\](\(.+\))?\s+#.*\"(.*)\"\.* lid (\d+).*/
- )
- {
- $loc_port = $1;
- my $loc_ext_port = $2;
- my $rem_guid = $3;
- my $rem_port = $4;
- my $rem_ext_port = $5;
- my $rem_port_guid = $6;
- my $rem_desc = $7;
- my $rem_lid = $8;
- $rec = {
- loc_guid => "0x$guid",
- loc_port => $loc_port,
- loc_ext_port => $loc_ext_port,
- loc_desc => $desc,
- loc_sw_lid => $loc_sw_lid,
- rem_guid => "0x$rem_guid",
- rem_lid => $rem_lid,
- rem_port => $rem_port,
- rem_ext_port => $rem_ext_port,
- rem_desc => $rem_desc,
- rem_port_guid => $rem_port_guid
- };
- }
- if ($rec) {
- $rec->{rem_port_guid} =~ s/\((.*)\)/$1/;
- $IBswcountlimits::link_ends{"0x$guid"}{$loc_port} = $rec;
- }
- }
-
- if ($line =~ /^Ca.*/ || $line =~ /^Rt.*/) { $in_switch = "no"; }
- }
- close IBNET_TOPO;
-}
-
-# =========================================================================
-# get_num_ports(switch_guid, ca_name, ca_port)
-#
-sub get_num_ports
-{
- my $guid = $_[0];
- my $ca_name = $_[1];
- my $ca_port = $_[2];
- my $num_ports = 0;
- my $extra_params = get_ca_name_port_param_string($ca_name, $ca_port);
-
- my $data = `smpquery $extra_params -G nodeinfo $guid` ||
- die "'smpquery $extra_params -G nodeinfo $guid' faild\n";
- my @lines = split("\n", $data);
- my $pkt_lifetime = "";
- foreach my $line (@lines) {
- if ($line =~ /^NumPorts:\.+(.*)/) { $num_ports = $1; }
- }
- return ($num_ports);
-}
-
-# =========================================================================
-# format_guid(guid)
-# The diags store the guids as strings. This converts the guid supplied
-# to the correct string format.
-# eg: 0x0008f10400411f56 == 0x8f10400411f56
-#
-sub format_guid
-{
- my $guid = $_[0];
- my $guid_str = "";
-
- $guid =~ tr/[A-F]/[a-f]/;
- if ($guid =~ /0x(.*)/) {
- $guid_str = sprintf("0x%016s", $1);
- } else {
- $guid_str = sprintf("0x%016s", $guid);
- }
- return ($guid_str);
-}
-
-# =========================================================================
-# convert_dr_to_guid(direct_route)
-#
-sub convert_dr_to_guid
-{
- my $guid = undef;
-
- my $data = `smpquery nodeinfo -D $_[0]` ||
- die "'mpquery nodeinfo -D $_[0]' failed\n";
- my @lines = split("\n", $data);
- foreach my $line (@lines) {
- if ($line =~ /^PortGuid:\.+(.*)/) { $guid = $1; }
- }
- return format_guid($guid);
-}
-
-# =========================================================================
-# get_node_type(guid_or_direct_route)
-#
-sub get_node_type
-{
- my $type = undef;
- my $query_arg = "smpquery nodeinfo ";
- if ($_[0] =~ /x/) {
- # assume arg is a guid if contains an x
- $query_arg .= "-G " . $_[0];
- } else {
- # assume arg is a direct path
- $query_arg .= "-D " . $_[0];
- }
-
- my $data = `$query_arg` ||
- die "'$query_arg' failed\n";
- my @lines = split("\n", $data);
- foreach my $line (@lines) {
- if ($line =~ /^NodeType:\.+(.*)/) { $type = $1; }
- }
- return $type;
-}
-
-# =========================================================================
-# is_switch(guid_or_direct_route)
-#
-sub is_switch
-{
- my $node_type = &get_node_type($_[0]);
- return ($node_type =~ /Switch/);
-}
diff --git a/contrib/ofed/management/infiniband-diags/scripts/check_lft_balance.pl b/contrib/ofed/management/infiniband-diags/scripts/check_lft_balance.pl
deleted file mode 100755
index cd4950f..0000000
--- a/contrib/ofed/management/infiniband-diags/scripts/check_lft_balance.pl
+++ /dev/null
@@ -1,321 +0,0 @@
-#!/usr/bin/perl
-#
-# Copyright (C) 2001-2003 The Regents of the University of California.
-# Copyright (c) 2006 The Regents of the University of California.
-# Copyright (c) 2007-2008 Voltaire, Inc. All rights reserved.
-#
-# Produced at Lawrence Livermore National Laboratory.
-# Written by Ira Weiny <weiny2@llnl.gov>
-# Jim Garlick <garlick@llnl.gov>
-# Albert Chu <chu11@llnl.gov>
-#
-# This software is available to you under a choice of one of two
-# licenses. You may choose to be licensed under the terms of the GNU
-# General Public License (GPL) Version 2, available from the file
-# COPYING in the main directory of this source tree, or the
-# OpenIB.org BSD license below:
-#
-# Redistribution and use in source and binary forms, with or
-# without modification, are permitted provided that the following
-# conditions are met:
-#
-# - Redistributions of source code must retain the above
-# copyright notice, this list of conditions and the following
-# disclaimer.
-#
-# - Redistributions in binary form must reproduce the above
-# copyright notice, this list of conditions and the following
-# disclaimer in the documentation and/or other materials
-# provided with the distribution.
-#
-# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
-# BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
-# ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
-# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-# SOFTWARE.
-#
-
-use strict;
-
-use Getopt::Std;
-use IBswcountlimits;
-
-my $regenerate_cache = 0;
-my $verbose = 0;
-
-my $switch_lid = undef;
-my $switch_guid = undef;
-my $switch_name = undef;
-my %switch_port_count = ();
-my @switch_maybe_directly_connected_hosts = ();
-my $host = undef;
-my @host_ports = ();
-
-my @lft_lines = ();
-my $lft_line;
-
-my $lids_per_port;
-my $lids_per_port_calculated;
-
-my $iblinkinfo_regenerate = 0;
-
-my $cache_file;
-
-sub usage
-{
- my $prog = `basename $0`;
-
- chomp($prog);
- print "Usage: $prog [-R -v]\n";
- print " -R recalculate all cached information\n";
- print " -v verbose output\n";
- exit 2;
-}
-
-sub is_port_up
-{
- my $iblinkinfo_output = $_[0];
- my $port = $_[1];
- my $decport;
- my @lines;
- my $line;
-
- $port =~ /0+(.+)/;
- $decport = $1;
-
- # Add a space if necessary
- if ($decport >= 1 && $decport <= 9) {
- $decport = " $decport";
- }
-
- @lines = split("\n", $iblinkinfo_output);
- foreach $line (@lines) {
- if ($line =~ /$decport\[..\] ==/) {
- if ($line =~ /Down/) {
- return 0;
- }
- }
- }
- return 1;
-}
-
-sub is_directly_connected
-{
- my $iblinkinfo_output = $_[0];
- my $port = $_[1];
- my $decport;
- my $str;
- my $rv = 0;
- my $host_tmp;
- my @lines;
- my $line;
-
- if (($switch_port_count{$port} != $lids_per_port)
- || !(@switch_maybe_directly_connected_hosts))
- {
- return $rv;
- }
-
- $port =~ /0+(.+)/;
- $decport = $1;
-
- # Add a space if necessary
- if ($decport >= 1 && $decport <= 9) {
- $decport = " $decport";
- }
-
- @lines = split("\n", $iblinkinfo_output);
- foreach $line (@lines) {
- if ($line =~ /$decport\[..\] ==/) {
- $str = $line;
- }
- }
-
- if ($str =~ "Active") {
- $str =~
-/[\d]+[\s]+[\d]+\[.+\] \=\=.+\=\=>[\s]+[\d]+[\s]+[\d]+\[.+\] \"(.+)\".+/;
- for $host_tmp (@switch_maybe_directly_connected_hosts) {
- if ($1 == $host_tmp) {
- $rv = 1;
- last;
- }
- }
- }
-
- return $rv;
-}
-
-sub output_switch_port_usage
-{
- my $min_usage = 999999;
- my $max_usage = 0;
- my @ports = (
- "001", "002", "003", "004", "005", "006", "007", "008",
- "009", "010", "011", "012", "013", "014", "015", "016",
- "017", "018", "019", "020", "021", "022", "023", "024"
- );
- my @output_ports = ();
- my $port;
- my $iblinkinfo_output;
- my $ret;
-
- # Run command once to reduce number of calls to iblinkinfo.pl
- if ($regenerate_cache && !$iblinkinfo_regenerate) {
- $iblinkinfo_output = `iblinkinfo.pl -R -S $switch_guid`;
- $iblinkinfo_regenerate++;
- }
- else {
- $iblinkinfo_output = `iblinkinfo.pl -S $switch_guid`;
- }
-
- for $port (@ports) {
- if (!defined($switch_port_count{$port})) {
- $switch_port_count{$port} = 0;
- }
-
- if ($switch_port_count{$port} == 0) {
- # If port is down, don't use it in this calculation
- $ret = is_port_up($iblinkinfo_output, $port);
- if ($ret == 0) {
- next;
- }
- }
-
- # If port is directly connected to a node, don't use
- # it in this calculation.
- if (is_directly_connected($iblinkinfo_output, $port) == 1) {
- next;
- }
-
- # Save off ports that should be output later
- push(@output_ports, $port);
-
- if ($switch_port_count{$port} < $min_usage) {
- $min_usage = $switch_port_count{$port};
- }
- if ($switch_port_count{$port} > $max_usage) {
- $max_usage = $switch_port_count{$port};
- }
- }
-
- if ($verbose || ($max_usage > ($min_usage + 1))) {
- if ($max_usage > ($min_usage + 1)) {
- print "Unbalanced Switch Port Usage: ";
- print "$switch_name, $switch_guid, $switch_lid\n";
- } else {
- print
- "Switch Port Usage: $switch_name, $switch_guid, $switch_lid\n";
- }
- for $port (@output_ports) {
- print "Port $port: $switch_port_count{$port}\n";
- }
- }
-}
-
-sub process_host_ports
-{
- my $test_port;
- my $tmp;
- my $flag = 0;
-
- if (@host_ports == $lids_per_port) {
- # Are all the host ports identical?
- $test_port = $host_ports[0];
- for $tmp (@host_ports) {
- if ($tmp != $test_port) {
- $flag = 1;
- last;
- }
- }
- # If all host ports are identical, maybe its directly
- # connected to a host.
- if ($flag == 0) {
- push(@switch_maybe_directly_connected_hosts, $host);
- }
- }
-}
-
-if (!getopts("hRv")) {
- usage();
-}
-
-if (defined($main::opt_h)) {
- usage();
-}
-
-if (defined($main::opt_R)) {
- $regenerate_cache = 1;
-}
-
-if (defined($main::opt_v)) {
- $verbose = 1;
-}
-
-$cache_file = "$IBswcountlimits::cache_dir/dump_lfts.out";
-if ($regenerate_cache || !(-f $cache_file)) {
- `dump_lfts.sh > $cache_file`;
- if ($? != 0) {
- die "Execution of dump_lfts.sh failed with errors\n";
- }
-}
-
-if (!open(FH, "< $cache_file")) {
- print STDERR ("Couldn't open cache file: $cache_file: $!\n");
-}
-
-@lft_lines = <FH>;
-
-foreach $lft_line (@lft_lines) {
- chomp($lft_line);
- if ($lft_line =~ /Unicast/) {
- $lft_line =~ /Unicast lids .+ of switch Lid (.+) guid (.+) \((.+)\)/;
- if (@host_ports) {
- process_host_ports();
- }
- if (defined($switch_name)) {
- output_switch_port_usage();
- }
- $switch_lid = $1;
- $switch_guid = $2;
- $switch_name = $3;
- @switch_maybe_directly_connected_hosts = ();
- %switch_port_count = ();
- @host_ports = ();
- $lids_per_port = 0;
- $lids_per_port_calculated = 0;
- } elsif ($lft_line =~ /Channel/ || $lft_line =~ /Router/) {
- $lft_line =~ /.+ (.+) : \(.+ portguid .+: '(.+)'\)/;
- $host = $2;
- $switch_port_count{$1}++;
- if (@host_ports) {
- process_host_ports();
- }
- @host_ports = ($1);
-
- if ($lids_per_port == 0) {
- $lids_per_port++;
- } else {
- $lids_per_port_calculated++;
- }
- } elsif ($lft_line =~ /path/) {
- $lft_line =~ /.+ (.+) : \(path #. out of .: portguid .+\)/;
- $switch_port_count{$1}++;
- if ($lids_per_port_calculated == 0) {
- $lids_per_port++;
- }
- push(@host_ports, $1);
- } else {
- if ($lids_per_port) {
- $lids_per_port_calculated++;
- }
- next;
- }
-}
-
-if (@host_ports) {
- process_host_ports();
-}
-output_switch_port_usage();
diff --git a/contrib/ofed/management/infiniband-diags/scripts/dump_lfts.sh b/contrib/ofed/management/infiniband-diags/scripts/dump_lfts.sh
deleted file mode 100755
index ebca705..0000000
--- a/contrib/ofed/management/infiniband-diags/scripts/dump_lfts.sh
+++ /dev/null
@@ -1,72 +0,0 @@
-#!/bin/sh
-#
-# This simple script will collect outputs of ibroute for all switches
-# on the subnet and drop it on stdout. It can be used for LFTs dump
-# generation.
-#
-
-usage ()
-{
- echo Usage: `basename $0` "[-h] [-D] [-C ca_name]" \
- "[-P ca_port] [-t(imeout) timeout_ms]"
- exit 2
-}
-
-dump_by_lid ()
-{
-for sw_lid in `ibswitches $ca_info \
- | sed -ne 's/^.* lid \([0-9a-f]*\) .*$/\1/p'` ; do
- ibroute $ca_info $sw_lid
-done
-}
-
-dump_by_dr_path ()
-{
-for sw_dr in `ibnetdiscover $ca_info -v \
- | sed -ne '/^DR path .* switch /s/^DR path \([,|0-9]\+\) ->.*{\([0-9|a-f]\+\)}.*$/\2 \1/p' \
- | sort -u \
- | awk 'BEGIN {guid=0;} {if ($1 != guid) { guid=$1; print $2; }}'` ; do
- ibroute $ca_info -D ${sw_dr}
-done
-}
-
-use_d=""
-ca_info=""
-
-while [ "$1" ]; do
- case $1 in
- -D)
- use_d="-D"
- ;;
- -h)
- usage
- ;;
- -P | -C | -t | -timeout)
- case $2 in
- -*)
- usage
- ;;
- esac
- if [ x$2 = x ] ; then
- usage
- fi
- ca_info="$ca_info $1 $2"
- shift
- ;;
- -*)
- usage
- ;;
- *)
- usage
- ;;
- esac
- shift
-done
-
-if [ "$use_d" = "-D" ] ; then
- dump_by_dr_path
-else
- dump_by_lid
-fi
-
-exit
diff --git a/contrib/ofed/management/infiniband-diags/scripts/dump_mfts.sh b/contrib/ofed/management/infiniband-diags/scripts/dump_mfts.sh
deleted file mode 100755
index 39fc5fb..0000000
--- a/contrib/ofed/management/infiniband-diags/scripts/dump_mfts.sh
+++ /dev/null
@@ -1,72 +0,0 @@
-#!/bin/sh
-#
-# This simple script will collect outputs of ibroute for all switches
-# on the subnet and drop it on stdout. It can be used for MFTs dump
-# generation.
-#
-
-usage ()
-{
- echo Usage: `basename $0` "[-h] [-D] [-C ca_name]" \
- "[-P ca_port] [-t(imeout) timeout_ms]"
- exit 2
-}
-
-dump_by_lid ()
-{
-for sw_lid in `ibswitches $ca_info \
- | sed -ne 's/^.* lid \([0-9a-f]*\) .*$/\1/p'` ; do
- ibroute $ca_info -M $sw_lid
-done
-}
-
-dump_by_dr_path ()
-{
-for sw_dr in `ibnetdiscover $ca_info -v \
- | sed -ne '/^DR path .* switch /s/^DR path \[\(.*\)\].*$/\1/p' \
- | sed -e 's/\]\[/,/g' \
- | sort -u` ; do
- ibroute $ca_info -M -D ${sw_dr}
-done
-}
-
-use_d=""
-ca_info=""
-
-while [ "$1" ]; do
- case $1 in
- -D)
- use_d="-D"
- ;;
- -h)
- usage
- ;;
- -P | -C | -t | -timeout)
- case $2 in
- -*)
- usage
- ;;
- esac
- if [ x$2 = x ] ; then
- usage
- fi
- ca_info="$ca_info $1 $2"
- shift
- ;;
- -*)
- usage
- ;;
- *)
- usage
- ;;
- esac
- shift
-done
-
-if [ "$use_d" = "-D" ] ; then
- dump_by_dr_path
-else
- dump_by_lid
-fi
-
-exit
diff --git a/contrib/ofed/management/infiniband-diags/scripts/ibcheckerrors.in b/contrib/ofed/management/infiniband-diags/scripts/ibcheckerrors.in
deleted file mode 100644
index a45bd63..0000000
--- a/contrib/ofed/management/infiniband-diags/scripts/ibcheckerrors.in
+++ /dev/null
@@ -1,133 +0,0 @@
-#!/bin/sh
-
-IBPATH=${IBPATH:-@IBSCRIPTPATH@}
-
-function usage() {
- echo Usage: `basename $0` "[-h] [-b] [-v] [-N | -nocolor]"\
- "[<topology-file> | -C ca_name -P ca_port -t(imeout) timeout_ms]"
- exit -1
-}
-
-function user_abort() {
- echo "Aborted"
- exit 1
-}
-
-trap user_abort SIGINT
-
-gflags=""
-verbose=""
-brief=""
-v=0
-ntype=""
-nodeguid=""
-topofile=""
-ca_info=""
-
-while [ "$1" ]; do
- case $1 in
- -h)
- usage
- ;;
- -N|-nocolor)
- gflags=-N
- ;;
- -v)
- verbose=-v
- brief=""
- v=1
- ;;
- -b)
- brief=-b
- verbose=""
- ;;
- -P | -C | -t | -timeout)
- case $2 in
- -*)
- usage
- ;;
- esac
- if [ x$2 = x ] ; then
- usage
- fi
- ca_info="$ca_info $1 $2"
- shift
- ;;
- -*)
- usage
- ;;
- *)
- if [ "$topofile" ]; then
- usage
- fi
- topofile="$1"
- ;;
- esac
- shift
-done
-
-if [ "$topofile" ]; then
- netcmd="cat $topofile"
-else
- netcmd="$IBPATH/ibnetdiscover $ca_info"
-fi
-
-text="`eval $netcmd`"
-rv=$?
-echo "$text" | awk '
-BEGIN {
- ne=0
-}
-function check_node(lid, port)
-{
- if (system("'$IBPATH'/ibchecknode '"$ca_info"' '$gflags' '$verbose' " lid)) {
- ne++
- print "\n# " ntype ": nodeguid 0x" nodeguid " failed"
- return 1;
- }
- if (system("'$IBPATH'/ibcheckerrs '"$ca_info"' '$gflags' '$verbose' '$brief' " lid " " port))
- return 2;
- return 0;
-}
-
-/^Ca/ || /^Switch/ || /^Rt/ {
- nnodes++
- ntype=$1; nodeguid=substr($3, 4, 16); ports=$2
- if ('$v')
- print "\n# Checking " ntype ": nodeguid 0x" nodeguid
-
- err = 0;
- if (ntype != "Switch")
- next
-
- lid = substr($0, index($0, "port 0 lid ") + 11)
- lid = substr(lid, 1, index(lid, " ") - 1)
- err = check_node(lid, 255)
- }
-/^\[/ {
- nports++
- port = $1
- sub("\\(.*\\)", "", port)
- gsub("[\\[\\]]", "", port)
- if (ntype != "Switch") {
- lid = substr($0, index($0, " lid ") + 5)
- lid = substr(lid, 1, index(lid, " ") - 1)
- if (check_node(lid, port) == 2)
- pcnterr++;
- } else if (err &&
- system("'$IBPATH'/ibcheckerrs '"$ca_info"' '$gflags' '$verbose' '$brief' " lid " " port))
- pcnterr++;
-}
-
-/^ib/ {print $0; next}
-/ibpanic:/ {print $0}
-/ibwarn:/ {print $0}
-/iberror:/ {print $0}
-
-END {
- printf "\n## Summary: %d nodes checked, %d bad nodes found\n", nnodes, ne
- printf "## %d ports checked, %d ports have errors beyond threshold\n", nports, pcnterr
- exit (ne + pcnterr)
-}
-'
-exit $rv
diff --git a/contrib/ofed/management/infiniband-diags/scripts/ibcheckerrs.in b/contrib/ofed/management/infiniband-diags/scripts/ibcheckerrs.in
deleted file mode 100644
index 305379a..0000000
--- a/contrib/ofed/management/infiniband-diags/scripts/ibcheckerrs.in
+++ /dev/null
@@ -1,223 +0,0 @@
-#!/bin/sh
-
-IBPATH=${IBPATH:-@IBSCRIPTPATH@}
-
-function usage() {
- echo Usage: `basename $0` "[-h] [-b] [-v] [-G] [-T <threshold_file>]" \
- "[-s(how_thresholds)] [-N \| -nocolor] [-C ca_name] [-P ca_port]" \
- "[-t(imeout) timeout_ms] <lid|guid> [<port>]"
- exit -1
-}
-
-function green() {
- if [ "$bw" = "yes" ]; then
- if [ "$verbose" = "yes" ]; then
- echo $1
- fi
- return
- fi
- if [ "$verbose" = "yes" ]; then
- echo -e "\\033[1;032m" $1 "\\033[0;39m"
- fi
-}
-
-function red() {
- if [ "$bw" = "yes" ]; then
- echo $1
- return
- fi
- echo -e "\\033[1;031m" $1 "\\033[0;39m"
-}
-
-function show_thresholds() {
- echo "SymbolErrors=$SymbolErrors"
- echo "LinkRecovers=$LinkRecovers"
- echo "LinkDowned=$LinkDowned"
- echo "RcvErrors=$RcvErrors"
- echo "RcvRemotePhysErrors=$RcvRemotePhysErrors"
- echo "RcvSwRelayErrors=$RcvSwRelayErrors"
- echo "XmtDiscards=$XmtDiscards"
- echo "XmtConstraintErrors=$XmtConstraintErrors"
- echo "RcvConstraintErrors=$RcvConstraintErrors"
- echo "LinkIntegrityErrors=$LinkIntegrityErrors"
- echo "ExcBufOverrunErrors=$ExcBufOverrunErrors"
- echo "VL15Dropped=$VL15Dropped"
-}
-
-function get_thresholds() {
- . $1
-}
-
-# Default thresholds
-SymbolErrors=10
-LinkRecovers=10
-LinkDowned=10
-RcvErrors=10
-RcvRemotePhysErrors=100
-RcvSwRelayErrors=100
-XmtDiscards=100
-XmtConstraintErrors=100
-RcvConstraintErrors=100
-LinkIntegrityErrors=10
-ExcBufOverrunErrors=10
-VL15Dropped=100
-
-guid_addr=""
-bw=""
-verbose=""
-brief=""
-ca_info=""
-
-while [ "$1" ]; do
- case $1 in
- -G)
- guid_addr=yes
- ;;
- -nocolor|-N)
- bw=yes
- ;;
- -v)
- verbose=yes
- brief=""
- ;;
- -b)
- brief=yes
- verbose=""
- ;;
- -T)
- if ! [ -r $2 ]; then
- echo "Can't use threshold file '$2'"
- usage
- fi
- get_thresholds $2
- shift
- ;;
- -s)
- show_thresholds
- exit 0
- ;;
- -P | -C | -t | -timeout)
- case $2 in
- -*)
- usage
- ;;
- esac
- if [ x$2 = x ] ; then
- usage
- fi
- ca_info="$ca_info $1 $2"
- shift
- ;;
- -*)
- usage
- ;;
- *)
- break
- ;;
- esac
- shift
-done
-
-#default is all ports
-portnum=255
-
-if [ $# -lt 1 ]; then
- usage
-fi
-
-if [ "$2" ]; then
- portnum=$2
-fi
-
-if [ "$portnum" = "255" ]; then
- portname="all"
-else
- portname=$2
-fi
-
-if [ "$guid_addr" ]; then
- if ! lid=`$IBPATH/ibaddr $ca_info -G -L $1 | awk '/failed/{exit -1} {print $3}'`; then
- echo -n "guid $1 address resolution: "
- red "FAILED"
- exit -1
- fi
- guid=$1
-else
- lid=$1
- if ! temp=`$IBPATH/ibaddr $ca_info -L $1 | awk '/failed/{exit -1} {print $1}'`; then
- echo -n "lid $1 address resolution: "
- red "FAILED"
- exit -1
- fi
-fi
-
-nodename=`$IBPATH/smpquery $ca_info nodedesc $lid | sed -e "s/^Node Description:\.*\(.*\)/\1/"`
-
-text="`eval $IBPATH/perfquery $ca_info $lid $portnum`"
-rv=$?
-if echo "$text" | awk -v mono=$bw -v brief=$brief -F '[.:]*' '
-function blue(s)
-{
- if (brief == "yes") {
- return
- }
- if (mono)
- printf s
- else if (!quiet) {
- printf "\033[1;034m" s
- printf "\033[0;39m"
- }
-}
-
-BEGIN {
- th["SymbolErrors"] = '$SymbolErrors'
- th["LinkRecovers"] = '$LinkRecovers'
- th["LinkDowned"] = '$LinkDowned'
- th["RcvErrors"] = '$RcvErrors'
- th["RcvRemotePhysErrors"] = '$RcvRemotePhysErrors'
- th["RcvSwRelayErrors"] = '$RcvSwRelayErrors'
- th["XmtDiscards"] = '$XmtDiscards'
- th["XmtConstraintErrors"] = '$XmtConstraintErrors'
- th["RcvConstraintErrors"] = '$RcvConstraintErrors'
- th["LinkIntegrityErrors"] = '$LinkIntegrityErrors'
- th["ExcBufOverrunErrors"] = '$ExcBufOverrunErrors'
- th["VL15Dropped"] = '$VL15Dropped'
-}
-
-/^CounterSelect/ {next}
-
-/AllPortSelect/ {next}
-
-/^ib/ {print $0; next}
-/ibpanic:/ {print $0}
-/ibwarn:/ {print $0}
-/iberror:/ {print $0}
-
-/^PortSelect/ { if ($2 != '$portnum') {err = err "error: lid '$lid' port " $2 " does not match query ('$portnum')\n"; exit -1}}
-
-$1 ~ "(Xmt|Rcv)(Pkts|Data)" { next }
-
- { if (th[$1] > 0 && $2 >= th[$1])
- warn = warn "#warn: counter " $1 " = " $2 " \t(threshold " th[$1] ") lid '$lid' port '$portnum'\n"
- }
-END {
- if (err != "") {
- blue(err)
- exit -1
- }
- if (warn != "") {
- blue(warn)
- exit -1
- }
- exit 0
-}' 2>&1 && test $rv -eq 0 ; then
- if [ "$verbose" = "yes" ]; then
- echo -n "Error check on lid $lid ($nodename) port $portname: "
- green OK
- fi
- exit 0
-else
- echo -n "Error check on lid $lid ($nodename) port $portname: "
- red FAILED
- exit -1
-fi
diff --git a/contrib/ofed/management/infiniband-diags/scripts/ibchecknet.in b/contrib/ofed/management/infiniband-diags/scripts/ibchecknet.in
deleted file mode 100644
index 6447835..0000000
--- a/contrib/ofed/management/infiniband-diags/scripts/ibchecknet.in
+++ /dev/null
@@ -1,140 +0,0 @@
-#!/bin/sh
-
-IBPATH=${IBPATH:-@IBSCRIPTPATH@}
-
-function usage() {
- echo Usage: `basename $0` "[-h] [-v] [-N | -nocolor]" \
- "[<topology-file> | -C ca_name -P ca_port -t(imeout) timeout_ms]"
- exit -1
-}
-
-function user_abort() {
- echo "Aborted"
- exit 1
-}
-
-trap user_abort SIGINT
-
-gflags=""
-verbose=""
-v=0
-oldlid=""
-topofile=""
-ca_info=""
-
-while [ "$1" ]; do
- case $1 in
- -h)
- usage
- ;;
- -N|-nocolor)
- gflags=-N
- ;;
- -v)
- verbose=-v
- v=0
- ;;
- -P | -C | -t | -timeout)
- case $2 in
- -*)
- usage
- ;;
- esac
- if [ x$2 = x ] ; then
- usage
- fi
- ca_info="$ca_info $1 $2"
- shift
- ;;
- -*)
- usage
- ;;
- *)
- if [ "$topofile" ]; then
- usage
- fi
- topofile="$1"
- ;;
- esac
- shift
-done
-
-if [ "$topofile" ]; then
- netcmd="cat $topofile"
-else
- netcmd="$IBPATH/ibnetdiscover $ca_info"
-fi
-
-text="`eval $netcmd`"
-rv=$?
-echo "$text" | awk '
-BEGIN {
- ne=0
- pe=0
-}
-function check_node(lid, port)
-{
- if (system("'$IBPATH'/ibchecknode '"$ca_info"' '$gflags' '$verbose' " lid)) {
- ne++
- print "\n# " ntype ": nodeguid 0x" nodeguid " failed"
- return 1;
- }
- if (system("'$IBPATH'/ibcheckerrs '"$ca_info"' '$gflags' '$verbose' '$brief' " lid " " port))
- return 2;
- return 0;
-}
-
-/^Ca/ || /^Switch/ || /^Rt/ {
- nnodes++
- ntype=$1; nodeguid=substr($3, 4, 16); ports=$2
- if ('$v' || ntype != "Switch")
- print "\n# Checking " ntype ": nodeguid 0x" nodeguid
-
- err = 0;
- if (ntype != "Switch")
- next
-
- lid = substr($0, index($0, "port 0 lid ") + 11)
- lid = substr(lid, 1, index(lid, " ") - 1)
- err = check_node(lid, 255)
- }
-/^\[/ {
- nports++
- port = $1
- sub("\\(.*\\)", "", port)
- gsub("[\\[\\]]", "", port)
- if (ntype != "Switch") {
- lid = substr($0, index($0, " lid ") + 5)
- lid = substr(lid, 1, index(lid, " ") - 1)
- if (check_node(lid, port) == 2)
- pcnterr++;
- } else if (err &&
- system("'$IBPATH'/ibcheckerrs '"$ca_info"' '$gflags' '$verbose' '$brief' " lid " " port))
- pcnterr++;
- if (system("'$IBPATH'/ibcheckport'"$ca_info"' '$gflags' '$verbose' " lid " " port)) {
- if (!'$v' && oldlid != lid) {
- print "# Checked " ntype ": nodeguid 0x" nodeguid " with failure"
- oldlid = lid
- }
- pe++;
- }
-}
-
-/^ib/ {print $0; next}
-/ibpanic:/ {print $0}
-/ibwarn:/ {print $0}
-/iberror:/ {print $0}
-
-END {
- printf "\n## Summary: %d nodes checked, %d bad nodes found\n", nnodes, ne
- printf "## %d ports checked, %d bad ports found\n", nports, pe
- printf "## %d ports have errors beyond threshold\n", pcnterr
- exit (ne + pe + pcnterr)
-}
-'
-av=$?
-if [ $av -ne 0 ] ; then
- exit $av
-else
- exit $rv
-fi
diff --git a/contrib/ofed/management/infiniband-diags/scripts/ibchecknode.in b/contrib/ofed/management/infiniband-diags/scripts/ibchecknode.in
deleted file mode 100644
index 5eea7b5..0000000
--- a/contrib/ofed/management/infiniband-diags/scripts/ibchecknode.in
+++ /dev/null
@@ -1,100 +0,0 @@
-#!/bin/sh
-
-IBPATH=${IBPATH:-@IBSCRIPTPATH@}
-
-function usage() {
- echo Usage: `basename $0` "[-h] [-v] [-N | -nocolor] [-G]" \
- "[-C ca_name] [-P ca_port] [-t(imeout) timeout_ms] <lid|guid>"
- exit -1
-}
-
-function green() {
- if [ "$bw" = "yes" ]; then
- if [ "$verbose" = "yes" ]; then
- echo $1
- fi
- return
- fi
- if [ "$verbose" = "yes" ]; then
- echo -e "\\033[1;032m" $1 "\\033[0;39m"
- fi
-}
-
-function red() {
- if [ "$bw" = "yes" ]; then
- echo $1
- return
- fi
- echo -e "\\033[1;031m" $1 "\\033[0;39m"
-}
-
-guid_addr=""
-bw=""
-verbose=""
-ca_info=""
-
-while [ "$1" ]; do
- case $1 in
- -G)
- guid_addr=yes
- ;;
- -nocolor|-N)
- bw=yes
- ;;
- -v)
- verbose=yes
- ;;
- -P | -C | -t | -timeout)
- case $2 in
- -*)
- usage
- ;;
- esac
- if [ x$2 = x ] ; then
- usage
- fi
- ca_info="$ca_info $1 $2"
- shift
- ;;
- -*)
- usage
- ;;
- *)
- break
- ;;
- esac
- shift
-done
-
-if [ -z "$1" ]; then
- usage
-fi
-
-if [ "$guid_addr" ]; then
- if ! lid=`$IBPATH/ibaddr $ca_info -G -L $1 | awk '/failed/{exit -1} {print $3}'`; then
- echo -n "guid $1 address resolution: "
- red "FAILED"
- exit -1
- fi
-else
- lid=$1
- if ! temp=`$IBPATH/ibaddr $ca_info -L $1 | awk '/failed/{exit -1} {print $1}'`; then
- echo -n "lid $1 address resolution: "
- red "FAILED"
- exit -1
- fi
-fi
-
-## For now, check node only checks if node info is replied
-
-if $IBPATH/smpquery $ca_info nodeinfo $lid > /dev/null 2>&1 ; then
- if [ "$verbose" = "yes" ]; then
- echo -n "Node check lid $lid: "
- green OK
- fi
- exit 0
-else
- echo -n "Node check lid $lid: "
- red FAILED
- exit -1
-fi
diff --git a/contrib/ofed/management/infiniband-diags/scripts/ibcheckport.in b/contrib/ofed/management/infiniband-diags/scripts/ibcheckport.in
deleted file mode 100644
index fa5e81e..0000000
--- a/contrib/ofed/management/infiniband-diags/scripts/ibcheckport.in
+++ /dev/null
@@ -1,144 +0,0 @@
-#!/bin/sh
-
-IBPATH=${IBPATH:-@IBSCRIPTPATH@}
-
-function usage() {
- echo Usage: `basename $0` "[-h] [-v] [-N | -nocolor] [-G]" \
- "[-C ca_name] [-P ca_port] [-t(imeout) timeout_ms] <lid|guid> <port>"
- exit -1
-}
-
-function green() {
- if [ "$bw" = "yes" ]; then
- if [ "$verbose" = "yes" ]; then
- echo $1
- fi
- return
- fi
- if [ "$verbose" = "yes" ]; then
- echo -e "\\033[1;032m" $1 "\\033[0;39m"
- fi
-}
-
-function red() {
- if [ "$bw" = "yes" ]; then
- echo $1
- return
- fi
- echo -e "\\033[1;031m" $1 "\\033[0;39m"
-}
-
-guid_addr=""
-bw=""
-verbose=""
-ca_info=""
-
-while [ "$1" ]; do
- case $1 in
- -G)
- guid_addr=yes
- ;;
- -nocolor|-N)
- bw=yes
- ;;
- -v)
- verbose=yes
- ;;
- -P | -C | -t | -timeout)
- case $2 in
- -*)
- usage
- ;;
- esac
- if [ x$2 = x ] ; then
- usage
- fi
- ca_info="$ca_info $1 $2"
- shift
- ;;
- -*)
- usage
- ;;
- *)
- break
- ;;
- esac
- shift
-done
-
-if [ $# -lt 2 ]; then
- usage
-fi
-
-portnum=$2
-
-if [ "$guid_addr" ]; then
- if ! lid=`$IBPATH/ibaddr $ca_info -G -L $1 | awk '/failed/{exit -1} {print $3}'`; then
- echo -n "guid $1 address resolution: "
- red "FAILED"
- exit -1
- fi
- guid=$1
-else
- lid=$1
- if ! temp=`$IBPATH/ibaddr $ca_info -L $1 | awk '/failed/{exit -1} {print $1}'`; then
- echo -n "lid $1 address resolution: "
- red "FAILED"
- exit -1
- fi
-fi
-
-
-text="`eval $IBPATH/smpquery $ca_info portinfo $lid $portnum`"
-rv=$?
-if echo "$text" | awk -v mono=$bw -F '[.:]*' '
-function blue(s)
-{
- if (mono)
- printf s
- else if (!quiet) {
- printf "\033[1;034m" s
- printf "\033[0;39m"
- }
-}
-
-# Checks
-
-/^PhysLinkState/{ if ($2 != "LinkUp") {err = err "#error: Physical link state is " $2 " lid '$lid' port '$portnum'\n"; exit -1}}
-
-/^LinkState/{ if ($2 != "Active") warn = warn "#warn: Logical link state is " $2 " lid '$lid' port '$portnum'\n"}
-
-/^LinkWidthActive/{ if ($2 == "1X") warn = warn "#warn: Link configured as 1X lid '$lid' port '$portnum'\n"}
-
-/^Lid/{ if ($2 == "0") warn = warn "#warn: Lid is not configured lid '$lid' port '$portnum'\n"}
-
-/^SMLid/{ if ($2 == "0") warn = warn "#warn: SM Lid is not configured\n"}
-
-#/^LocalPort/ { if ($2 != '$portnum') {err = err "#error: port " $2 " does not match query ('$portnum')\n"; exit -1}}
-
-/^ib/ {print $0; next}
-/ibpanic:/ {print $0}
-/ibwarn:/ {print $0}
-/iberror:/ {print $0}
-
-END {
- if (err != "") {
- blue(err)
- exit -1
- }
- if (warn != "") {
- blue(warn)
- exit -1
- }
- exit 0
-}' 2>&1 && test $rv -eq 0 ; then
- if [ "$verbose" = "yes" ]; then
- echo -n "Port check lid $lid port $portnum: "
- green "OK"
- fi
- exit 0
-else
- echo -n "Port check lid $lid port $portnum: "
- red "FAILED"
- exit -1
-fi
diff --git a/contrib/ofed/management/infiniband-diags/scripts/ibcheckportstate.in b/contrib/ofed/management/infiniband-diags/scripts/ibcheckportstate.in
deleted file mode 100644
index dc4fb14..0000000
--- a/contrib/ofed/management/infiniband-diags/scripts/ibcheckportstate.in
+++ /dev/null
@@ -1,136 +0,0 @@
-#!/bin/sh
-
-IBPATH=${IBPATH:-@IBSCRIPTPATH@}
-
-function usage() {
- echo Usage: `basename $0` "[-h] [-v] [-N | -nocolor] [-G]" \
- "[-C ca_name] [-P ca_port] [-t(imeout) timeout_ms] <lid|guid> <port>"
- exit -1
-}
-
-function green() {
- if [ "$bw" = "yes" ]; then
- if [ "$verbose" = "yes" ]; then
- echo $1
- fi
- return
- fi
- if [ "$verbose" = "yes" ]; then
- echo -e "\\033[1;032m" $1 "\\033[0;39m"
- fi
-}
-
-function red() {
- if [ "$bw" = "yes" ]; then
- echo $1
- return
- fi
- echo -e "\\033[1;031m" $1 "\\033[0;39m"
-}
-
-guid_addr=""
-bw=""
-verbose=""
-ca_info=""
-
-while [ "$1" ]; do
- case $1 in
- -G)
- guid_addr=yes
- ;;
- -nocolor|-N)
- bw=yes
- ;;
- -v)
- verbose=yes
- ;;
- -P | -C | -t | -timeout)
- case $2 in
- -*)
- usage
- ;;
- esac
- if [ x$2 = x ] ; then
- usage
- fi
- ca_info="$ca_info $1 $2"
- shift
- ;;
- -*)
- usage
- ;;
- *)
- break
- ;;
- esac
- shift
-done
-
-if [ $# -lt 2 ]; then
- usage
-fi
-
-portnum=$2
-
-if [ "$guid_addr" ]; then
- if ! lid=`$IBPATH/ibaddr $ca_info -G -L $1 | awk '/failed/{exit -1} {print $3}'`; then
- echo -n "guid $1 address resolution: "
- red "FAILED"
- exit -1
- fi
- guid=$1
-else
- lid=$1
- if ! temp=`$IBPATH/ibaddr $ca_info -L $1 | awk '/failed/{exit -1} {print $1}'`; then
- echo -n "lid $1 address resolution: "
- red "FAILED"
- exit -1
- fi
-fi
-
-
-text="`eval $IBPATH/smpquery $ca_info portinfo $lid $portnum`"
-rv=$?
-if echo "$text" | awk -v mono=$bw -F '[.:]*' '
-function blue(s)
-{
- if (mono)
- printf s
- else if (!quiet) {
- printf "\033[1;034m" s
- printf "\033[0;39m"
- }
-}
-
-# Only check PortPhysicalState and PortState
-
-/^PhysLinkState/{ if ($2 != "LinkUp") {err = err "#error: Physical link state is " $2 " lid '$lid' port '$portnum'\n"; exit -1}}
-
-/^LinkState/{ if ($2 != "Active") warn = warn "#warn: Logical link state is " $2 " lid '$lid' port '$portnum'\n"}
-
-/^ib/ {print $0; next}
-/ibpanic:/ {print $0}
-/ibwarn:/ {print $0}
-/iberror:/ {print $0}
-
-END {
- if (err != "") {
- blue(err)
- exit -1
- }
- if (warn != "") {
- blue(warn)
- exit -1
- }
- exit 0
-}' 2>&1 && test $rv -eq 0 ; then
- if [ "$verbose" = "yes" ]; then
- echo -n "Port check lid $lid port $portnum: "
- green "OK"
- fi
- exit 0
-else
- echo -n "Port check lid $lid port $portnum: "
- red "FAILED"
- exit -1
-fi
diff --git a/contrib/ofed/management/infiniband-diags/scripts/ibcheckportwidth.in b/contrib/ofed/management/infiniband-diags/scripts/ibcheckportwidth.in
deleted file mode 100644
index 32c5c5e..0000000
--- a/contrib/ofed/management/infiniband-diags/scripts/ibcheckportwidth.in
+++ /dev/null
@@ -1,134 +0,0 @@
-#!/bin/sh
-
-IBPATH=${IBPATH:-@IBSCRIPTPATH@}
-
-function usage() {
- echo Usage: `basename $0` "[-h] [-v] [-N | -nocolor] [-G]" \
- "[-C ca_name] [-P ca_port] [-t(imeout) timeout_ms] <lid|guid> <port>"
- exit -1
-}
-
-function green() {
- if [ "$bw" = "yes" ]; then
- if [ "$verbose" = "yes" ]; then
- echo $1
- fi
- return
- fi
- if [ "$verbose" = "yes" ]; then
- echo -e "\\033[1;032m" $1 "\\033[0;39m"
- fi
-}
-
-function red() {
- if [ "$bw" = "yes" ]; then
- echo $1
- return
- fi
- echo -e "\\033[1;031m" $1 "\\033[0;39m"
-}
-
-guid_addr=""
-bw=""
-verbose=""
-ca_info=""
-
-while [ "$1" ]; do
- case $1 in
- -G)
- guid_addr=yes
- ;;
- -nocolor|-N)
- bw=yes
- ;;
- -v)
- verbose=yes
- ;;
- -P | -C | -t | -timeout)
- case $2 in
- -*)
- usage
- ;;
- esac
- if [ x$2 = x ] ; then
- usage
- fi
- ca_info="$ca_info $1 $2"
- shift
- ;;
- -*)
- usage
- ;;
- *)
- break
- ;;
- esac
- shift
-done
-
-if [ $# -lt 2 ]; then
- usage
-fi
-
-portnum=$2
-
-if [ "$guid_addr" ]; then
- if ! lid=`$IBPATH/ibaddr $ca_info -G -L $1 | awk '/failed/{exit -1} {print $3}'`; then
- echo -n "guid $1 address resolution: "
- red "FAILED"
- exit -1
- fi
- guid=$1
-else
- lid=$1
- if ! temp=`$IBPATH/ibaddr $ca_info -L $1 | awk '/failed/{exit -1} {print $1}'`; then
- echo -n "lid $1 address resolution: "
- red "FAILED"
- exit -1
- fi
-fi
-
-
-text="`eval $IBPATH/smpquery $ca_info portinfo $lid $portnum`"
-rv=$?
-if echo "$text" | awk -v mono=$bw -F '[.:]*' '
-function blue(s)
-{
- if (mono)
- printf s
- else if (!quiet) {
- printf "\033[1;034m" s
- printf "\033[0;39m"
- }
-}
-
-# Only check LinkWidthActive if LinkWidthSupported is not 1X
-/^LinkWidthSupported/{ if ($2 != "1X") { next } }
-/^LinkWidthActive/{ if ($2 == "1X") warn = warn "#warn: Link configured as 1X lid '$lid' port '$portnum'\n"}
-
-/^ib/ {print $0; next}
-/ibpanic:/ {print $0}
-/ibwarn:/ {print $0}
-/iberror:/ {print $0}
-
-END {
- if (err != "") {
- blue(err)
- exit -1
- }
- if (warn != "") {
- blue(warn)
- exit -1
- }
- exit 0
-}' 2>&1 && test $rv -eq 0 ; then
- if [ "$verbose" = "yes" ]; then
- echo -n "Port check lid $lid port $portnum: "
- green "OK"
- fi
- exit 0
-else
- echo -n "Port check lid $lid port $portnum: "
- red "FAILED"
- exit -1
-fi
diff --git a/contrib/ofed/management/infiniband-diags/scripts/ibcheckstate.in b/contrib/ofed/management/infiniband-diags/scripts/ibcheckstate.in
deleted file mode 100644
index 63551d5..0000000
--- a/contrib/ofed/management/infiniband-diags/scripts/ibcheckstate.in
+++ /dev/null
@@ -1,135 +0,0 @@
-#!/bin/sh
-
-IBPATH=${IBPATH:-@IBSCRIPTPATH@}
-
-function usage() {
- echo Usage: `basename $0` "[-h] [-v] [-N | -nocolor]" \
- "[<topology-file> | -C ca_name -P ca_port -t(imeout) timeout_ms]"
- exit -1
-}
-
-function user_abort() {
- echo "Aborted"
- exit 1
-}
-
-trap user_abort SIGINT
-
-gflags=""
-verbose=""
-v=0
-ntype=""
-nodeguid=""
-oldlid=""
-topofile=""
-ca_info=""
-
-while [ "$1" ]; do
- case $1 in
- -h)
- usage
- ;;
- -N|-nocolor)
- gflags=-N
- ;;
- -v)
- verbose=-v
- v=1
- ;;
- -P | -C | -t | -timeout)
- case $2 in
- -*)
- usage
- ;;
- esac
- if [ x$2 = x ] ; then
- usage
- fi
- ca_info="$ca_info $1 $2"
- shift
- ;;
- -*)
- usage
- ;;
- *)
- if [ "$topofile" ]; then
- usage
- fi
- topofile="$1"
- ;;
- esac
- shift
-done
-
-if [ "$topofile" ]; then
- netcmd="cat $topofile"
-else
- netcmd="$IBPATH/ibnetdiscover $ca_info"
-fi
-
-text="`eval $netcmd`"
-rv=$?
-echo "$text" | awk '
-BEGIN {
- ne=0
- pe=0
-}
-function check_node(lid)
-{
- nodechecked=1
- if (system("'$IBPATH'/ibchecknode'"$ca_info"' '$gflags' '$verbose' " lid)) {
- ne++
- badnode=1
- return
- }
-}
-
-/^Ca/ || /^Switch/ || /^Rt/ {
- nnodes++
- ntype=$1; nodeguid=substr($3, 4, 16); ports=$2
- if ('$v')
- print "\n# Checking " ntype ": nodeguid 0x" nodeguid
-
- nodechecked=0
- badnode=0
- if (ntype != "Switch")
- next
-
- lid = substr($0, index($0, "port 0 lid ") + 11)
- lid = substr(lid, 1, index(lid, " ") - 1)
- check_node(lid)
- }
-/^\[/ {
- nports++
- port = $1
- if (!nodechecked) {
- lid = substr($0, index($0, " lid ") + 5)
- lid = substr(lid, 1, index(lid, " ") - 1)
- check_node(lid)
- }
- if (badnode) {
- print "\n# " ntype ": nodeguid 0x" nodeguid " failed"
- next
- }
- sub("\\(.*\\)", "", port)
- gsub("[\\[\\]]", "", port)
- if (system("'$IBPATH'/ibcheckportstate'"$ca_info"' '$gflags' '$verbose' " lid " " port)) {
- if (!'$v' && oldlid != lid) {
- print "# Checked " ntype ": nodeguid 0x" nodeguid " with failure"
- oldlid = lid
- }
- pe++;
- }
-}
-
-/^ib/ {print $0; next}
-/ibpanic:/ {print $0}
-/ibwarn:/ {print $0}
-/iberror:/ {print $0}
-
-END {
- printf "\n## Summary: %d nodes checked, %d bad nodes found\n", nnodes, ne
- printf "## %d ports checked, %d ports with bad state found\n", nports, pe
-}
-'
-exit $rv
diff --git a/contrib/ofed/management/infiniband-diags/scripts/ibcheckwidth.in b/contrib/ofed/management/infiniband-diags/scripts/ibcheckwidth.in
deleted file mode 100644
index 6b723c5..0000000
--- a/contrib/ofed/management/infiniband-diags/scripts/ibcheckwidth.in
+++ /dev/null
@@ -1,135 +0,0 @@
-#!/bin/sh
-
-IBPATH=${IBPATH:-@IBSCRIPTPATH@}
-
-function usage() {
- echo Usage: `basename $0` "[-h] [-v] [-N | -nocolor]" \
- "[<topology-file> \| -C ca_name -P ca_port -t(imeout) timeout_ms]"
- exit -1
-}
-
-function user_abort() {
- echo "Aborted"
- exit 1
-}
-
-trap user_abort SIGINT
-
-gflags=""
-verbose=""
-v=0
-ntype=""
-nodeguid=""
-oldlid=""
-topofile=""
-ca_info=""
-
-while [ "$1" ]; do
- case $1 in
- -h)
- usage
- ;;
- -N|-nocolor)
- gflags=-N
- ;;
- -v)
- verbose="-v"
- v=1
- ;;
- -P | -C | -t | -timeout)
- case $2 in
- -*)
- usage
- ;;
- esac
- if [ x$2 = x ] ; then
- usage
- fi
- ca_info="$ca_info $1 $2"
- shift
- ;;
- -*)
- usage
- ;;
- *)
- if [ "$topofile" ]; then
- usage
- fi
- topofile="$1"
- ;;
- esac
- shift
-done
-
-if [ "$topofile" ]; then
- netcmd="cat $topofile"
-else
- netcmd="$IBPATH/ibnetdiscover $ca_info"
-fi
-
-text="`eval $netcmd`"
-rv=$?
-echo "$text" | awk '
-BEGIN {
- ne=0
- pe=0
-}
-function check_node(lid)
-{
- nodechecked=1
- if (system("'$IBPATH'/ibchecknode'"$ca_info"' '$gflags' '$verbose' " lid)) {
- ne++
- badnode=1
- return
- }
-}
-
-/^Ca/ || /^Switch/ || /^Rt/ {
- nnodes++
- ntype=$1; nodeguid=substr($3, 4, 16); ports=$2
- if ('$v')
- print "\n# Checking " ntype ": nodeguid 0x" nodeguid
-
- nodechecked=0
- badnode=0
- if (ntype != "Switch")
- next
-
- lid = substr($0, index($0, "port 0 lid ") + 11)
- lid = substr(lid, 1, index(lid, " ") - 1)
- check_node(lid)
- }
-/^\[/ {
- nports++
- port = $1
- if (!nodechecked) {
- lid = substr($0, index($0, " lid ") + 5)
- lid = substr(lid, 1, index(lid, " ") - 1)
- check_node(lid)
- }
- if (badnode) {
- print "\n# " ntype ": nodeguid 0x" nodeguid " failed"
- next
- }
- sub("\\(.*\\)", "", port)
- gsub("[\\[\\]]", "", port)
- if (system("'$IBPATH'/ibcheckportwidth'"$ca_info"' '$gflags' '$verbose' " lid " " port)) {
- if (!'$v' && oldlid != lid) {
- print "# Checked " ntype ": nodeguid 0x" nodeguid " with failure"
- oldlid = lid
- }
- pe++;
- }
-}
-
-/^ib/ {print $0; next}
-/ibpanic:/ {print $0}
-/ibwarn:/ {print $0}
-/iberror:/ {print $0}
-
-END {
- printf "\n## Summary: %d nodes checked, %d bad nodes found\n", nnodes, ne
- printf "## %d ports checked, %d ports with 1x width in error found\n", nports, pe
-}
-'
-exit $rv
diff --git a/contrib/ofed/management/infiniband-diags/scripts/ibclearcounters.in b/contrib/ofed/management/infiniband-diags/scripts/ibclearcounters.in
deleted file mode 100644
index 86a5528..0000000
--- a/contrib/ofed/management/infiniband-diags/scripts/ibclearcounters.in
+++ /dev/null
@@ -1,107 +0,0 @@
-#!/bin/sh
-
-IBPATH=${IBPATH:-@IBSCRIPTPATH@}
-
-function usage() {
- echo Usage: `basename $0` "[-h] [<topology-file>" \
- "| -C ca_name -P ca_port -t(imeout) timeout_ms]"
- exit -1
-}
-
-function user_abort() {
- echo "Aborted"
- exit 1
-}
-
-trap user_abort SIGINT
-
-gflags=""
-verbose=""
-v=0
-topofile=""
-ca_info=""
-
-while [ "$1" ]; do
- case $1 in
- -h)
- usage
- ;;
- -P | -C | -t | -timeout)
- case $2 in
- -*)
- usage
- ;;
- esac
- if [ x$2 = x ] ; then
- usage
- fi
- ca_info="$ca_info $1 $2"
- shift
- ;;
- -*)
- usage
- ;;
- *)
- if [ "$topofile" ]; then
- usage
- fi
- topofile="$1"
- ;;
- esac
- shift
-done
-
-if [ "$topofile" ]; then
- netcmd="cat $topofile"
-else
- netcmd="$IBPATH/ibnetdiscover $ca_info"
-fi
-
-text="`eval $netcmd`"
-rv=$?
-echo "$text" | awk '
-
-function clear_counters(lid)
-{
- if (system("'$IBPATH'/perfquery'"$ca_info"' '$gflags' -R -a " lid))
- nodeerr++
-}
-
-function clear_port_counters(lid, port)
-{
- if (system("'$IBPATH'/perfquery'"$ca_info"' '$gflags' -R " lid " " port))
- nodeerr++
-}
-
-/^Ca/ || /^Switch/ || /^Rt/ {
- nnodes++
- ntype=$1; nodeguid=substr($3, 4, 16); ports=$2
- if (ntype != "Switch")
- next
-
- lid = substr($0, index($0, "port 0 lid ") + 11)
- lid = substr(lid, 1, index(lid, " ") - 1)
- clear_counters(lid)
- }
-
-/^\[/ {
- port = $1
- sub("\\(.*\\)", "", port)
- gsub("[\\[\\]]", "", port)
- if (ntype != "Switch") {
- lid = substr($0, index($0, " lid ") + 5)
- lid = substr(lid, 1, index(lid, " ") - 1)
- clear_port_counters(lid, port)
- }
- }
-
-/^ib/ {print $0; next}
-/ibpanic:/ {print $0}
-/ibwarn:/ {print $0}
-/iberror:/ {print $0}
-
-END {
- printf "\n## Summary: %d nodes cleared %d errors\n", nnodes, nodeerr
-}
-'
-exit $rv
diff --git a/contrib/ofed/management/infiniband-diags/scripts/ibclearerrors.in b/contrib/ofed/management/infiniband-diags/scripts/ibclearerrors.in
deleted file mode 100644
index 3dfb96b..0000000
--- a/contrib/ofed/management/infiniband-diags/scripts/ibclearerrors.in
+++ /dev/null
@@ -1,111 +0,0 @@
-#!/bin/sh
-
-IBPATH=${IBPATH:-@IBSCRIPTPATH@}
-
-function usage() {
- echo Usage: `basename $0` "[-h] [-N | -nocolor] [<topology-file>" \
- "| -C ca_name -P ca_port -t(imeout) timeout_ms]"
- exit -1
-}
-
-function user_abort() {
- echo "Aborted"
- exit 1
-}
-
-trap user_abort SIGINT
-
-gflags=""
-verbose=""
-v=0
-oldlid=""
-topofile=""
-ca_info=""
-
-while [ "$1" ]; do
- case $1 in
- -h)
- usage
- ;;
- -N|-nocolor)
- gflags=-N
- ;;
- -P | -C | -t | -timeout)
- case $2 in
- -*)
- usage
- ;;
- esac
- if [ x$2 = x ] ; then
- usage
- fi
- ca_info="$ca_info $1 $2"
- shift
- ;;
- -*)
- usage
- ;;
- *)
- if [ "$topofile" ]; then
- usage
- fi
- topofile="$1"
- ;;
- esac
- shift
-done
-
-if [ "$topofile" ]; then
- netcmd="cat $topofile"
-else
- netcmd="$IBPATH/ibnetdiscover $ca_info"
-fi
-
-text="`eval $netcmd`"
-rv=$?
-echo "$text" | awk '
-
-function clear_all_errors(lid, port)
-{
- if (system("'$IBPATH'/perfquery'"$ca_info"' '$gflags' -R -a " lid " " port " 0x0fff"))
- nodeerr++
-}
-
-function clear_errors(lid, port)
-{
- if (system("'$IBPATH'/perfquery'"$ca_info"' '$gflags' -R " lid " " port " 0x0fff"))
- nodeerr++
-}
-
-/^Ca/ || /^Switch/ || /^Rt/ {
- nnodes++
- ntype=$1; nodeguid=substr($3, 4, 16); ports=$2
- if (ntype != "Switch")
- next
-
- lid = substr($0, index($0, "port 0 lid ") + 11)
- lid = substr(lid, 1, index(lid, " ") - 1)
- clear_all_errors(lid, 255)
- }
-
-/^\[/ {
- port = $1
- sub("\\(.*\\)", "", port)
- gsub("[\\[\\]]", "", port)
- if (ntype != "Switch") {
- lid = substr($0, index($0, " lid ") + 5)
- lid = substr(lid, 1, index(lid, " ") - 1)
- clear_errors(lid, port)
- }
- }
-
-/^ib/ {print $0; next}
-/ibpanic:/ {print $0}
-/ibwarn:/ {print $0}
-/iberror:/ {print $0}
-
-END {
- printf "\n## Summary: %d nodes cleared %d errors\n", nnodes, nodeerr
-}
-'
-exit $rv
diff --git a/contrib/ofed/management/infiniband-diags/scripts/ibdatacounters.in b/contrib/ofed/management/infiniband-diags/scripts/ibdatacounters.in
deleted file mode 100644
index 5967406..0000000
--- a/contrib/ofed/management/infiniband-diags/scripts/ibdatacounters.in
+++ /dev/null
@@ -1,129 +0,0 @@
-#!/bin/sh
-
-IBPATH=${IBPATH:-@IBSCRIPTPATH@}
-
-function usage() {
- echo Usage: `basename $0` "[-h] [-b] [-v] [-N | -nocolor]" \
- "[<topology-file> \| -C ca_name -P ca_port -t(imeout) timeout_ms]"
- exit -1
-}
-
-function user_abort() {
- echo "Aborted"
- exit 1
-}
-
-trap user_abort SIGINT
-
-gflags=""
-verbose=""
-brief=""
-v=0
-ntype=""
-nodeguid=""
-topofile=""
-ca_info=""
-
-while [ "$1" ]; do
- case $1 in
- -h)
- usage
- ;;
- -N|-nocolor)
- gflags=-N
- ;;
- -v)
- verbose=-v
- brief=""
- v=1
- ;;
- -b)
- brief=-b
- verbose=""
- ;;
- -P | -C | -t | -timeout)
- case $2 in
- -*)
- usage
- ;;
- esac
- if [ x$2 = x ] ; then
- usage
- fi
- ca_info="$ca_info $1 $2"
- shift
- ;;
- -*)
- usage
- ;;
- *)
- if [ "$topofile" ]; then
- usage
- fi
- topofile="$1"
- ;;
- esac
- shift
-done
-
-if [ "$topofile" ]; then
- netcmd="cat $topofile"
-else
- netcmd="$IBPATH/ibnetdiscover $ca_info"
-fi
-
-text="`eval $netcmd`"
-rv=$?
-echo "$text" | awk '
-BEGIN {
- ne=0
-}
-function check_node(lid, port)
-{
- if (system("'$IBPATH'/ibchecknode '"$ca_info"' '$gflags' '$verbose' " lid)) {
- ne++
- print "\n# " ntype ": nodeguid 0x" nodeguid " failed"
- return 1;
- }
- return system("'$IBPATH'/ibcheckerrs '"$ca_info"' '$gflags' '$verbose' '$brief' " lid " " port);
-}
-
-/^Ca/ || /^Switch/ || /^Rt/ {
- nnodes++
- ntype=$1; nodeguid=substr($3, 4, 16); ports=$2
- if ('$v')
- print "\n# Checking " ntype ": nodeguid 0x" nodeguid
-
- err = 0;
- if (ntype != "Switch")
- next
-
- lid = substr($0, index($0, "port 0 lid ") + 11)
- lid = substr(lid, 1, index(lid, " ") - 1)
- err = check_node(lid, 255)
- }
-/^\[/ {
- nports++
- port = $1
- sub("\\(.*\\)", "", port)
- gsub("[\\[\\]]", "", port)
- if (ntype != "Switch") {
- lid = substr($0, index($0, " lid ") + 5)
- lid = substr(lid, 1, index(lid, " ") - 1)
- check_node(lid, port)
- } else if (err)
- system("'$IBPATH'/ibdatacounts '"$ca_info"' '$gflags' '$verbose' '$brief' " lid " " port);
-}
-
-/^ib/ {print $0; next}
-/ibpanic:/ {print $0}
-/ibwarn:/ {print $0}
-/iberror:/ {print $0}
-
-END {
- printf "\n## Summary: %d nodes checked, %d bad nodes found\n", nnodes, ne
- printf "## %d ports checked\n", nports
- exit (ne )
-}
-'
-exit $rv
diff --git a/contrib/ofed/management/infiniband-diags/scripts/ibdatacounts.in b/contrib/ofed/management/infiniband-diags/scripts/ibdatacounts.in
deleted file mode 100644
index 3dbc56a..0000000
--- a/contrib/ofed/management/infiniband-diags/scripts/ibdatacounts.in
+++ /dev/null
@@ -1,164 +0,0 @@
-#!/bin/sh
-
-IBPATH=${IBPATH:-@IBSCRIPTPATH@}
-
-function usage() {
- echo Usage: `basename $0` "[-h] [-b] [-v] [-G] [-N | -nocolor]" \
- "[-C ca_name] [-P ca_port] [-t(imeout) timeout_ms] <lid|guid>" \
- "[<port>]"
- exit -1
-}
-
-function green() {
- if [ "$bw" = "yes" ]; then
- if [ "$verbose" = "yes" ]; then
- echo $1
- fi
- return
- fi
- if [ "$verbose" = "yes" ]; then
- echo -e "\\033[1;032m" $1 "\\033[0;39m"
- fi
-}
-
-function red() {
- if [ "$bw" = "yes" ]; then
- echo $1
- return
- fi
- echo -e "\\033[1;031m" $1 "\\033[0;39m"
-}
-
-guid_addr=""
-bw=""
-verbose=""
-brief=""
-ca_info=""
-
-while [ "$1" ]; do
- case $1 in
- -G)
- guid_addr=yes
- ;;
- -nocolor|-N)
- bw=yes
- ;;
- -v)
- verbose=yes
- brief=""
- ;;
- -b)
- brief=yes
- verbose=""
- ;;
- -P | -C | -t | -timeout)
- case $2 in
- -*)
- usage
- ;;
- esac
- if [ x$2 = x ] ; then
- usage
- fi
- ca_info="$ca_info $1 $2"
- shift
- ;;
- -*)
- usage
- ;;
- *)
- break
- ;;
- esac
- shift
-done
-
-#default is all ports
-portnum=255
-
-if [ $# -lt 1 ]; then
- usage
-fi
-
-if [ "$2" ]; then
- portnum=$2
-fi
-
-if [ "$portnum" = "255" ]; then
- portname="all"
-else
- portname=$2
-fi
-
-if [ "$guid_addr" ]; then
- if ! lid=`$IBPATH/ibaddr $ca_info -G -L $1 | awk '/failed/{exit -1} {print $3}'`; then
- echo -n "guid $1 address resolution: "
- red "FAILED"
- exit -1
- fi
- guid=$1
-else
- lid=$1
- if ! temp=`$IBPATH/ibaddr $ca_info -L $1 | awk '/failed/{exit -1} {print $1}'`; then
- echo -n "lid $1 address resolution: "
- red "FAILED"
- exit -1
- fi
-fi
-
-nodename=`smpquery $ca_info nodedesc $lid | sed -e "s/^Node Description:\.*\(.*\)/\1/"`
-
-text="`eval $IBPATH/perfquery $ca_info $lid $portnum`"
-rv=$?
-if echo "$text" | awk -v mono=$bw -v brief=$brief -F '[.:]*' '
-function blue(s)
-{
- if (brief == "yes") {
- return
- }
- if (mono)
- printf s
- else if (!quiet) {
- printf "\033[1;034m" s
- printf "\033[0;39m"
- }
-}
-
-# Only display Xmit/Rcv Pkts/Data
-
-/^# Port counters/ {print}
-
-/^CounterSelect/ {next}
-
-/AllPortSelect/ {next}
-
-/^ib/ {print $0; next}
-/ibpanic:/ {print $0}
-/ibwarn:/ {print $0}
-/iberror:/ {print $0}
-
-/^PortSelect/ { if ($2 != '$portnum') {err = err "error: lid '$lid' port " $2 " does not match query ('$portnum')\n"; exit -1}}
-
-$1 ~ "(Xmt|Rcv)(Pkts|Data)" { print $1 ":........................." $2 }
-
-END {
- if (err != "") {
- blue(err)
- exit -1
- }
- if (warn != "") {
- blue(warn)
- exit -1
- }
- exit 0
-}' 2>&1 && test $rv -eq 0 ; then
- if [ "$verbose" = "yes" ]; then
- echo -n "Error on lid $lid ($nodename) port $portname: "
- green OK
- fi
- exit 0
-else
- echo -n "Error on lid $lid ($nodename) port $portname: "
- red FAILED
- exit -1
-fi
diff --git a/contrib/ofed/management/infiniband-diags/scripts/ibdiscover.map b/contrib/ofed/management/infiniband-diags/scripts/ibdiscover.map
deleted file mode 100644
index 58c69da..0000000
--- a/contrib/ofed/management/infiniband-diags/scripts/ibdiscover.map
+++ /dev/null
@@ -1,6 +0,0 @@
-8f10400410015|8|"ISR 6000"|# SW-6IB4 Voltaire port 0 lid 5
-5442ba00003080|24|"ISR 9024"|# ISR9024 Voltaire port 0 lid 2
-8f10403960558|2|"HCA 1"|# MT23108 InfiniHost Mellanox Technologies
-5442b100004900|2|"HCA 2"|# MT23108 InfiniHost Mellanox Technologies
-8f10403961354|2|"HCA 3"|# MT23108 InfiniHost Mellanox Technologies
-8f10403960984|2|"HCA 4"|# MT23108 InfiniHost Mellanox Technologies
diff --git a/contrib/ofed/management/infiniband-diags/scripts/ibdiscover.pl b/contrib/ofed/management/infiniband-diags/scripts/ibdiscover.pl
deleted file mode 100755
index 8606919..0000000
--- a/contrib/ofed/management/infiniband-diags/scripts/ibdiscover.pl
+++ /dev/null
@@ -1,86 +0,0 @@
-#!/usr/bin/perl
-
-#
-# Read mapfile
-#
-open(MAP, "< ibdiscover.map");
-
-while (<MAP>) {
- ($pre, $port, $desc) = split /\|/;
- $val{$pre} = $desc;
- # print "Ack1 - $pre - $port - $desc\n";
-}
-close(MAP);
-
-#
-# Read old topo map in
-#
-open(TOPO, "< ibdiscover.topo");
-$topomap = 0;
-
-while (<TOPO>) {
- $topomap = 1;
- ($localPort, $localGuid, $remotePort, $remoteGuid) = split /\|/;
- chomp $remoteGuid;
- $var = sprintf("%s|%2s|%2s|%s", $localGuid, $localPort, $remotePort,
- $remoteGuid);
- $topo{$var} = 1;
- # ${$pre} = $desc;
- # print "Ack1 - $pre - $port - $desc\n";
-}
-close(TOPO);
-
-#
-# Read stdin and output enhanced output
-#
-# Search and replace =0x???? with value
-# Search and replace -000???? with value
-
-open(TOPO2, " >ibdiscover.topo.new");
-while (<STDIN>) {
- ($a, $b, $local, $d) = /([sh])([\s\S]*)=0x([a-f\d]*)([\s\S]*)/;
- if ($local ne "") {
- printf(
- "\n%s GUID: %s %s\n",
- ($a eq "s" ? "Switch" : "Host"),
- $local, $val{$local}
- );
- chomp $local;
- $localGuid = $local;
- } else {
- ($localPort, $type, $remoteGuid, $remotePort) =
- /([\s\S]*)"([SH])\-000([a-f\d]*)"([\s\S]*)\n/;
- ($localPort) = $localPort =~ /\[(\d*)]/;
- ($remotePort) = $remotePort =~ /\[(\d*)]/;
- if ($remoteGuid ne "" && $localPort ne "") {
- printf(TOPO2 "%d|%s|%d|%s\n",
- $localPort, $localGuid, $remotePort, $remoteGuid);
- $var = sprintf("%s|%2s|%2s|%s",
- $localGuid, $localPort, $remotePort, $remoteGuid);
- $topo{$var} += 1;
- printf(
- "Local: %2s Remote: %2s %7s GUID: %s Location: %s\n",
- $localPort,
- $remotePort,
- ($type eq "H" ? "Host" : "Switch"),
- $remoteGuid,
- ($val{$remoteGuid} ne "" ? $val{$remoteGuid} : $remoteGuid)
- );
- }
- }
-}
-close(STDIN);
-close(TOPO2);
-
-printf("\nDelta change in topo (change between successive runs)\n\n");
-
-foreach $el (keys %topo) {
- if ($topo{$el} < 2 || $topomap == 0) {
- ($lg, $lp, $rp, $rg) = split(/\|/, $el);
- printf(
-"Link change: Local/Remote Port %2d/%2d Local/Remote GUID: %s/%s\n",
- $lp, $rp, $lg, $rg);
- printf("\tLocations: Local/Remote\n\t\t%s\n\t\t%s\n\n",
- $val{$lg}, $val{$rg});
- }
-}
diff --git a/contrib/ofed/management/infiniband-diags/scripts/ibfindnodesusing.pl b/contrib/ofed/management/infiniband-diags/scripts/ibfindnodesusing.pl
deleted file mode 100755
index a2102c7..0000000
--- a/contrib/ofed/management/infiniband-diags/scripts/ibfindnodesusing.pl
+++ /dev/null
@@ -1,231 +0,0 @@
-#!/usr/bin/perl
-#
-# Copyright (C) 2001-2003 The Regents of the University of California.
-# Copyright (c) 2006 The Regents of the University of California.
-# Copyright (c) 2007-2008 Voltaire, Inc. All rights reserved.
-#
-# Produced at Lawrence Livermore National Laboratory.
-# Written by Ira Weiny <weiny2@llnl.gov>
-# Jim Garlick <garlick@llnl.gov>
-# Albert Chu <chu11@llnl.gov>
-#
-# This software is available to you under a choice of one of two
-# licenses. You may choose to be licensed under the terms of the GNU
-# General Public License (GPL) Version 2, available from the file
-# COPYING in the main directory of this source tree, or the
-# OpenIB.org BSD license below:
-#
-# Redistribution and use in source and binary forms, with or
-# without modification, are permitted provided that the following
-# conditions are met:
-#
-# - Redistributions of source code must retain the above
-# copyright notice, this list of conditions and the following
-# disclaimer.
-#
-# - Redistributions in binary form must reproduce the above
-# copyright notice, this list of conditions and the following
-# disclaimer in the documentation and/or other materials
-# provided with the distribution.
-#
-# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
-# BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
-# ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
-# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-# SOFTWARE.
-#
-
-use strict;
-
-use Getopt::Std;
-use IBswcountlimits;
-my $ca_name = "";
-my $ca_port = "";
-
-# =========================================================================
-#
-sub get_hosts_routed
-{
- my $sw_guid = $_[0];
- my $sw_port = $_[1];
- my @hosts = undef;
- my $extra_params = get_ca_name_port_param_string($ca_name, $ca_port);
-
- if ($sw_guid eq "") { return (@hosts); }
-
- my $data = `ibroute $extra_params -G $sw_guid`;
- my @lines = split("\n", $data);
- foreach my $line (@lines) {
- if ($line =~ /\w+\s+(\d+)\s+:\s+\(Channel Adapter.*:\s+'(.*)'\)/) {
- if ($1 == $sw_port) {
- push @hosts, $2;
- }
- }
- }
-
- return (@hosts);
-}
-
-# =========================================================================
-#
-sub usage_and_exit
-{
- my $prog = $_[0];
- print
-"Usage: $prog [-R -C <ca_name> -P <ca_port>] <switch_guid|switch_name> <port>\n";
- print " find a list of nodes which are routed through switch:port\n";
- print " -R Recalculate ibnetdiscover information\n";
- print " -C <ca_name> use selected Channel Adaptor name for queries\n";
- print " -P <ca_port> use selected channel adaptor port for queries\n";
- exit 2;
-}
-
-my $argv0 = `basename $0`;
-my $regenerate_map = undef;
-chomp $argv0;
-if (!getopts("hRC:P:")) { usage_and_exit $argv0; }
-if (defined $Getopt::Std::opt_h) { usage_and_exit $argv0; }
-if (defined $Getopt::Std::opt_R) { $regenerate_map = $Getopt::Std::opt_R; }
-if (defined $Getopt::Std::opt_C) { $ca_name = $Getopt::Std::opt_C; }
-if (defined $Getopt::Std::opt_P) { $ca_port = $Getopt::Std::opt_P; }
-
-my $target_switch = format_guid($ARGV[0]);
-my $target_port = $ARGV[1];
-
-get_link_ends($regenerate_map, $ca_name, $ca_port);
-
-if ($target_switch eq "" || $target_port eq "") {
- usage_and_exit $argv0;
-}
-
-# sortn:
-#
-# sort a group of alphanumeric strings by the last group of digits on
-# those strings, if such exists (good for numerically suffixed host lists)
-#
-sub sortn
-{
- map { $$_[0] }
- sort { ($$a[1] || 0) <=> ($$b[1] || 0) } map { [$_, /(\d*)$/] } @_;
-}
-
-# comp2():
-#
-# takes a list of names and returns a hash of arrays, indexed by name prefix,
-# each containing a list of numerical ranges describing the initial list.
-#
-# e.g.: %hash = comp2(lx01,lx02,lx03,lx05,dev0,dev1,dev21)
-# will return:
-# $hash{"lx"} = ["01-03", "05"]
-# $hash{"dev"} = ["0-1", "21"]
-#
-sub comp2
-{
- my (%i) = ();
- my (%s) = ();
-
- # turn off warnings here to avoid perl complaints about
- # uninitialized values for members of %i and %s
- local ($^W) = 0;
- push(
- @{
- $s{$$_[0]}[
- (
- $s{$$_[0]}[$i{$$_[0]}][$#{$s{$$_[0]}[$i{$$_[0]}]}] ==
- ($$_[1] - 1)
- ) ? $i{$$_[0]} : ++$i{$$_[0]}
- ]
- },
- ($$_[1])
- ) for map { [/(.*?)(\d*)$/] } sortn(@_);
-
- for my $key (keys %s) {
- @{$s{$key}} =
- map { $#$_ > 0 ? "$$_[0]-$$_[$#$_]" : @{$_} } @{$s{$key}};
- }
-
- return %s;
-}
-
-sub compress_hostlist
-{
- my %rng = comp2(@_);
- my @list = ();
-
- local $" = ",";
-
- foreach my $k (keys %rng) {
- @{$rng{$k}} = map { "$k$_" } @{$rng{$k}};
- }
- @list = map { @{$rng{$_}} } sort keys %rng;
- return "@list";
-}
-
-# =========================================================================
-#
-sub main
-{
- my $found_switch = undef;
- my $cache_file = get_cache_file($ca_name, $ca_port);
- open IBNET_TOPO, "<$cache_file" or die "Failed to open ibnet topology\n";
- my $in_switch = "no";
- my $switch_guid = "";
- my $desc = undef;
- my %ports = undef;
- while (my $line = <IBNET_TOPO>) {
-
- if ($line =~ /^Switch.*\"S-(.*)\"\s+# (.*) port.*/) {
- $switch_guid = $1;
- $desc = $2;
- if ("0x$switch_guid" eq $target_switch
- || $desc =~ /.*$target_switch\s+.*/)
- {
- $found_switch = "yes";
- goto FOUND;
- }
- }
- if ($line =~ /^Ca.*/ || $line =~ /^Rt.*/) { $in_switch = "no"; }
-
- if ($line =~ /^\[(\d+)\].*/ && $in_switch eq "yes") {
- $ports{$1} = $line;
- }
-
- }
-
- FOUND:
- close IBNET_TOPO;
- if (!$found_switch) {
- print "Switch \"$target_switch\" not found\n";
- print " Try running with the \"-R\" or \"-P\" option.\n";
- exit 1;
- }
-
- $switch_guid = "0x$switch_guid";
-
- my $hr = $IBswcountlimits::link_ends{$switch_guid}{$target_port};
- my $rem_sw_guid = $hr->{rem_guid};
- my $rem_sw_port = $hr->{rem_port};
- my $rem_sw_desc = $hr->{rem_desc};
-
- my @hosts = undef;
- @hosts = get_hosts_routed($switch_guid, $target_port);
-
- my $hosts = compress_hostlist(@hosts);
- @hosts = split ",", $hosts;
- print
-"$switch_guid $target_port ($desc) ==>> $rem_sw_guid $rem_sw_port ($rem_sw_desc)\n";
- print "@hosts\n\n";
-
- @hosts = get_hosts_routed($rem_sw_guid, $rem_sw_port);
-
- $hosts = compress_hostlist(@hosts);
- @hosts = split ",", $hosts;
- print
-"$switch_guid $target_port ($desc) <<== $rem_sw_guid $rem_sw_port ($rem_sw_desc)\n";
- print "@hosts\n";
-}
-main
-
diff --git a/contrib/ofed/management/infiniband-diags/scripts/ibhosts.in b/contrib/ofed/management/infiniband-diags/scripts/ibhosts.in
deleted file mode 100644
index baba105..0000000
--- a/contrib/ofed/management/infiniband-diags/scripts/ibhosts.in
+++ /dev/null
@@ -1,60 +0,0 @@
-#!/bin/sh
-
-IBPATH=${IBPATH:-@IBSCRIPTPATH@}
-
-function usage() {
- echo Usage: `basename $0` "[-h] [<topology-file> | -C ca_name" \
- "-P ca_port -t(imeout) timeout_ms]"
- exit -1
-}
-
-topofile=""
-ca_info=""
-
-while [ "$1" ]; do
- case $1 in
- -h)
- usage
- ;;
- -P | -C | -t | -timeout)
- case $2 in
- -*)
- usage
- ;;
- esac
- if [ x$2 = x ] ; then
- usage
- fi
- ca_info="$ca_info $1 $2"
- shift
- ;;
- -*)
- usage
- ;;
- *)
- if [ "$topofile" ]; then
- usage
- fi
- topofile="$1"
- ;;
- esac
- shift
-done
-
-if [ "$topofile" ]; then
- netcmd="cat $topofile"
-else
- netcmd="$IBPATH/ibnetdiscover $ca_info"
-fi
-
-text="`eval $netcmd`"
-rv=$?
-echo "$text" | awk '
-/^Ca/ {print $1 "\t: 0x" substr($3, 4, 16) " ports " $2 " "\
- substr($0, match($0, "#[ \t]*")+RLENGTH)}
-/^ib/ {print $0; next}
-/ibpanic:/ {print $0}
-/ibwarn:/ {print $0}
-/iberror:/ {print $0}
-'
-exit $rv
diff --git a/contrib/ofed/management/infiniband-diags/scripts/ibidsverify.pl b/contrib/ofed/management/infiniband-diags/scripts/ibidsverify.pl
deleted file mode 100755
index 0d017ba..0000000
--- a/contrib/ofed/management/infiniband-diags/scripts/ibidsverify.pl
+++ /dev/null
@@ -1,254 +0,0 @@
-#!/usr/bin/perl
-#
-# Copyright (c) 2007-2008 Voltaire, Inc. All rights reserved.
-# Copyright (c) 2006 The Regents of the University of California.
-#
-# This software is available to you under a choice of one of two
-# licenses. You may choose to be licensed under the terms of the GNU
-# General Public License (GPL) Version 2, available from the file
-# COPYING in the main directory of this source tree, or the
-# OpenIB.org BSD license below:
-#
-# Redistribution and use in source and binary forms, with or
-# without modification, are permitted provided that the following
-# conditions are met:
-#
-# - Redistributions of source code must retain the above
-# copyright notice, this list of conditions and the following
-# disclaimer.
-#
-# - Redistributions in binary form must reproduce the above
-# copyright notice, this list of conditions and the following
-# disclaimer in the documentation and/or other materials
-# provided with the distribution.
-#
-# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
-# BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
-# ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
-# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-# SOFTWARE.
-#
-
-use strict;
-
-use Getopt::Std;
-use IBswcountlimits;
-
-sub usage_and_exit
-{
- my $prog = $_[0];
- print "Usage: $prog [-Rh]\n";
- print
-" Validate LIDs and GUIDs (check for zero and duplicates) in the local subnet\n";
- print " -h This help message\n";
- print
-" -R Recalculate ibnetdiscover information (Default is to reuse ibnetdiscover output)\n";
- exit 2;
-}
-
-my $argv0 = `basename $0`;
-my $regenerate_map = undef;
-
-chomp $argv0;
-if (!getopts("hR")) { usage_and_exit $argv0; }
-if (defined $Getopt::Std::opt_h) { usage_and_exit $argv0; }
-if (defined $Getopt::Std::opt_R) { $regenerate_map = $Getopt::Std::opt_R; }
-
-sub validate_non_zero_lid
-{
- my ($lid) = shift(@_);
- my ($nodeguid) = shift(@_);
- my ($nodetype) = shift(@_);
-
- if ($lid eq 0) {
- print "LID 0 found for $nodetype NodeGUID $nodeguid\n";
- return 1;
- }
- return 0;
-}
-
-sub validate_non_zero_guid
-{
- my ($lid) = shift(@_);
- my ($guid) = shift(@_);
- my ($nodetype) = shift(@_);
-
- if ($guid eq 0x0) {
- print "$nodetype GUID 0x0 found with LID $lid\n";
- return 1;
- }
- return 0;
-}
-
-$insert_lid::lids = undef;
-$insert_nodeguid::nodeguids = undef;
-$insert_portguid::portguids = undef;
-
-sub insert_lid
-{
- my ($lid) = shift(@_);
- my ($nodeguid) = shift(@_);
- my ($nodetype) = shift(@_);
- my $rec = undef;
- my $status = "";
-
- $status = validate_non_zero_lid($lid, $nodeguid, $nodetype);
- if ($status eq 0) {
- if (defined($insert_lid::lids{$lid})) {
- print
-"LID $lid already defined for NodeGUID $insert_lid::lids{$lid}->{nodeguid}\n";
- } else {
- $rec = {lid => $lid, nodeguid => $nodeguid};
- $insert_lid::lids{$lid} = $rec;
- }
- }
-}
-
-sub insert_nodeguid
-{
- my ($lid) = shift(@_);
- my ($nodeguid) = shift(@_);
- my ($nodetype) = shift(@_);
- my $rec = undef;
- my $status = "";
-
- $status = validate_non_zero_guid($lid, $nodeguid, $nodetype);
- if ($status eq 0) {
- if (defined($insert_nodeguid::nodeguids{$nodeguid})) {
- print
-"NodeGUID $nodeguid already defined for LID $insert_nodeguid::nodeguids{$nodeguid}->{lid}\n";
- } else {
- $rec = {lid => $lid, nodeguid => $nodeguid};
- $insert_nodeguid::nodeguids{$nodeguid} = $rec;
- }
- }
-}
-
-sub validate_portguid
-{
- my ($portguid) = shift(@_);
- my ($firstport) = shift(@_);
-
- if (defined($insert_nodeguid::nodeguids{$portguid})
- && ($firstport ne "yes"))
- {
- print "PortGUID $portguid is invalid duplicate of a NodeGUID\n";
- }
-}
-
-sub insert_portguid
-{
- my ($lid) = shift(@_);
- my ($portguid) = shift(@_);
- my ($nodetype) = shift(@_);
- my ($firstport) = shift(@_);
- my $rec = undef;
- my $status = "";
-
- $status = validate_non_zero_guid($lid, $portguid, $nodetype);
- if ($status eq 0) {
- if (defined($insert_portguid::portguids{$portguid})) {
- print
-"PortGUID $portguid already defined for LID $insert_portguid::portguids{$portguid}->{lid}\n";
- } else {
- $rec = {lid => $lid, portguid => $portguid};
- $insert_portguid::portguids{$portguid} = $rec;
- validate_portguid($portguid, $firstport);
- }
- }
-}
-
-sub main
-{
- if ($regenerate_map
- || !(-f "$IBswcountlimits::cache_dir/ibnetdiscover.topology"))
- {
- generate_ibnetdiscover_topology;
- }
-
- open IBNET_TOPO, "<$IBswcountlimits::cache_dir/ibnetdiscover.topology"
- or die "Failed to open ibnet topology: $!\n";
-
- my $nodetype = "";
- my $nodeguid = "";
- my $portguid = "";
- my $lid = "";
- my $line = "";
- my $firstport = "";
-
- while ($line = <IBNET_TOPO>) {
-
- if ($line =~ /^caguid=(.*)/ || $line =~ /^rtguid=(.*)/) {
- $nodeguid = $1;
- $nodetype = "";
- }
-
- if ($line =~ /^switchguid=(.*)/) {
- $nodeguid = $1;
- $portguid = "";
- $nodetype = "";
- }
- if ($line =~ /^switchguid=(.*)\((.*)\)/) {
- $nodeguid = $1;
- $portguid = "0x" . $2;
- }
-
- if ($line =~ /^Switch.*\"S-(.*)\"\s+# (.*) port.* lid (\d+) .*/) {
- $nodetype = "switch";
- $firstport = "yes";
- $lid = $3;
- insert_lid($lid, $nodeguid, $nodetype);
- insert_nodeguid($lid, $nodeguid, $nodetype);
- if ($portguid ne "") {
- insert_portguid($lid, $portguid, $nodetype, $firstport);
- }
- }
- if ($line =~ /^Ca.*/) {
- $nodetype = "ca";
- $firstport = "yes";
- }
- if ($line =~ /^Rt.*/) {
- $nodetype = "router";
- $firstport = "yes";
- }
-
- if ($nodetype eq "ca" || $nodetype eq "router") {
- if ($line =~ /"S-(.*)\# lid (\d+) .*/) {
- $lid = $2;
- insert_lid($lid, $nodeguid, $nodetype);
- if ($firstport eq "yes") {
- insert_nodeguid($lid, $nodeguid, $nodetype);
- $firstport = "no";
- }
- }
- if ($line =~ /^.*"H-(.*)\# lid (\d+) .*/) {
- $lid = $2;
- insert_lid($lid, $nodeguid, $nodetype);
- if ($firstport eq "yes") {
- insert_nodeguid($lid, $nodeguid, $nodetype);
- $firstport = "no";
- }
- }
- if ($line =~ /^.*"R-(.*)\# lid (\d+) .*/) {
- $lid = $2;
- insert_lid($lid, $nodeguid, $nodetype);
- if ($firstport eq "yes") {
- insert_nodeguid($lid, $nodeguid, $nodetype);
- $firstport = "no";
- }
- }
- if ($line =~ /^\[(\d+)\]\((.*)\)/) {
- $portguid = "0x" . $2;
- insert_portguid($lid, $portguid, $nodetype, $firstport);
- }
- }
-
- }
-
- close IBNET_TOPO;
-}
-main;
-
diff --git a/contrib/ofed/management/infiniband-diags/scripts/iblinkinfo.pl b/contrib/ofed/management/infiniband-diags/scripts/iblinkinfo.pl
deleted file mode 100755
index b6b27ce..0000000
--- a/contrib/ofed/management/infiniband-diags/scripts/iblinkinfo.pl
+++ /dev/null
@@ -1,327 +0,0 @@
-#!/usr/bin/perl
-#
-# Copyright (c) 2006 The Regents of the University of California.
-# Copyright (c) 2007-2008 Voltaire, Inc. All rights reserved.
-#
-# Produced at Lawrence Livermore National Laboratory.
-# Written by Ira Weiny <weiny2@llnl.gov>.
-#
-# This software is available to you under a choice of one of two
-# licenses. You may choose to be licensed under the terms of the GNU
-# General Public License (GPL) Version 2, available from the file
-# COPYING in the main directory of this source tree, or the
-# OpenIB.org BSD license below:
-#
-# Redistribution and use in source and binary forms, with or
-# without modification, are permitted provided that the following
-# conditions are met:
-#
-# - Redistributions of source code must retain the above
-# copyright notice, this list of conditions and the following
-# disclaimer.
-#
-# - Redistributions in binary form must reproduce the above
-# copyright notice, this list of conditions and the following
-# disclaimer in the documentation and/or other materials
-# provided with the distribution.
-#
-# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
-# BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
-# ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
-# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-# SOFTWARE.
-#
-
-use strict;
-
-use Getopt::Std;
-use IBswcountlimits;
-
-sub usage_and_exit
-{
- my $prog = $_[0];
- print
-"Usage: $prog [-Rhclp -S <guid> -D <direct route> -C <ca_name> -P <ca_port>]\n";
- print
-" Report link speed and connection for each port of each switch which is active\n";
- print " -h This help message\n";
- print
-" -R Recalculate ibnetdiscover information (Default is to reuse ibnetdiscover output)\n";
- print
-" -D <direct route> output only the switch specified by direct route path\n";
- print " -S <guid> output only the switch specified by <guid> (hex format)\n";
- print " -d print only down links\n";
- print
- " -l (line mode) print all information for each link on each line\n";
- print
-" -p print additional switch settings (PktLifeTime,HoqLife,VLStallCount)\n";
- print " -c print port capabilities (enabled/supported values)\n";
- print " -C <ca_name> use selected Channel Adaptor name for queries\n";
- print " -P <ca_port> use selected channel adaptor port for queries\n";
- print " -g print port guids instead of node guids\n";
- exit 2;
-}
-
-my $argv0 = `basename $0`;
-my $regenerate_map = undef;
-my $single_switch = undef;
-my $direct_route = undef;
-my $line_mode = undef;
-my $print_add_switch = undef;
-my $print_extended_cap = undef;
-my $only_down_links = undef;
-my $ca_name = "";
-my $ca_port = "";
-my $print_port_guids = undef;
-my $switch_found = "no";
-chomp $argv0;
-
-if (!getopts("hcpldRS:D:C:P:g")) { usage_and_exit $argv0; }
-if (defined $Getopt::Std::opt_h) { usage_and_exit $argv0; }
-if (defined $Getopt::Std::opt_D) { $direct_route = $Getopt::Std::opt_D; }
-if (defined $Getopt::Std::opt_R) { $regenerate_map = $Getopt::Std::opt_R; }
-if (defined $Getopt::Std::opt_S) {
- $single_switch = format_guid($Getopt::Std::opt_S);
-}
-if (defined $Getopt::Std::opt_d) { $only_down_links = $Getopt::Std::opt_d; }
-if (defined $Getopt::Std::opt_l) { $line_mode = $Getopt::Std::opt_l; }
-if (defined $Getopt::Std::opt_p) { $print_add_switch = $Getopt::Std::opt_p; }
-if (defined $Getopt::Std::opt_c) { $print_extended_cap = $Getopt::Std::opt_c; }
-if (defined $Getopt::Std::opt_C) { $ca_name = $Getopt::Std::opt_C; }
-if (defined $Getopt::Std::opt_P) { $ca_port = $Getopt::Std::opt_P; }
-if (defined $Getopt::Std::opt_g) { $print_port_guids = $Getopt::Std::opt_g; }
-
-my $extra_smpquery_params = get_ca_name_port_param_string($ca_name, $ca_port);
-
-sub main
-{
- get_link_ends($regenerate_map, $ca_name, $ca_port);
- if (defined($direct_route)) {
- # convert DR to guid, then use original single_switch option
- $single_switch = convert_dr_to_guid($direct_route);
- if (!defined($single_switch) || !is_switch($single_switch)) {
- printf("The direct route (%s) does not map to a switch.\n",
- $direct_route);
- return;
- }
- }
- foreach my $switch (sort (keys(%IBswcountlimits::link_ends))) {
- if ($single_switch && $switch ne $single_switch) {
- next;
- } else {
- $switch_found = "yes";
- }
- my $switch_prompt = "no";
- my $num_ports = get_num_ports($switch, $ca_name, $ca_port);
- if ($num_ports == 0) {
- printf("ERROR: switch $switch has 0 ports???\n");
- }
- my @output_lines = undef;
- my $pkt_lifetime = "";
- my $pkt_life_prompt = "";
- my $port_timeouts = "";
- my $print_switch = "yes";
- if ($only_down_links) { $print_switch = "no"; }
- if ($print_add_switch) {
- my $data = `smpquery $extra_smpquery_params -G switchinfo $switch`;
- if ($data eq "") {
- printf("ERROR: failed to get switchinfo for $switch\n");
- }
- my @lines = split("\n", $data);
- foreach my $line (@lines) {
- if ($line =~ /^LifeTime:\.+(.*)/) { $pkt_lifetime = $1; }
- }
- $pkt_life_prompt = sprintf(" (LT: %2s)", $pkt_lifetime);
- }
- foreach my $port (1 .. $num_ports) {
- my $hr = $IBswcountlimits::link_ends{$switch}{$port};
- if ($switch_prompt eq "no" && !$line_mode) {
- my $switch_name = "";
- my $tmp_port = $port;
- while ($switch_name eq "" && $tmp_port <= $num_ports) {
- # the first port is down find switch name with up port
- my $hr = $IBswcountlimits::link_ends{$switch}{$tmp_port};
- $switch_name = $hr->{loc_desc};
- $tmp_port++;
- }
- if ($switch_name eq "") {
- printf(
- "WARNING: Switch Name not found for $switch\n");
- }
- push(
- @output_lines,
- sprintf(
- "Switch %18s %s%s:\n",
- $switch, $switch_name, $pkt_life_prompt
- )
- );
- $switch_prompt = "yes";
- }
- my $data =
- `smpquery $extra_smpquery_params -G portinfo $switch $port`;
- if ($data eq "") {
- printf(
- "ERROR: failed to get portinfo for $switch port $port\n");
- }
- my @lines = split("\n", $data);
- my $speed = "";
- my $speed_sup = "";
- my $speed_enable = "";
- my $width = "";
- my $width_sup = "";
- my $width_enable = "";
- my $state = "";
- my $hoq_life = "";
- my $vl_stall = "";
- my $phy_link_state = "";
-
- foreach my $line (@lines) {
- if ($line =~ /^LinkSpeedActive:\.+(.*)/) { $speed = $1; }
- if ($line =~ /^LinkSpeedEnabled:\.+(.*)/) {
- $speed_enable = $1;
- }
- if ($line =~ /^LinkSpeedSupported:\.+(.*)/) { $speed_sup = $1; }
- if ($line =~ /^LinkWidthActive:\.+(.*)/) { $width = $1; }
- if ($line =~ /^LinkWidthEnabled:\.+(.*)/) {
- $width_enable = $1;
- }
- if ($line =~ /^LinkWidthSupported:\.+(.*)/) { $width_sup = $1; }
- if ($line =~ /^LinkState:\.+(.*)/) { $state = $1; }
- if ($line =~ /^HoqLife:\.+(.*)/) { $hoq_life = $1; }
- if ($line =~ /^VLStallCount:\.+(.*)/) { $vl_stall = $1; }
- if ($line =~ /^PhysLinkState:\.+(.*)/) { $phy_link_state = $1; }
- }
- my $rem_port = $hr->{rem_port};
- my $rem_lid = $hr->{rem_lid};
- my $rem_speed_sup = "";
- my $rem_speed_enable = "";
- my $rem_width_sup = "";
- my $rem_width_enable = "";
- if ($rem_lid ne "" && $rem_port ne "") {
- $data =
- `smpquery $extra_smpquery_params portinfo $rem_lid $rem_port`;
- if ($data eq "") {
- printf(
- "ERROR: failed to get portinfo for $switch port $port\n"
- );
- }
- my @lines = split("\n", $data);
- foreach my $line (@lines) {
- if ($line =~ /^LinkSpeedEnabled:\.+(.*)/) {
- $rem_speed_enable = $1;
- }
- if ($line =~ /^LinkSpeedSupported:\.+(.*)/) {
- $rem_speed_sup = $1;
- }
- if ($line =~ /^LinkWidthEnabled:\.+(.*)/) {
- $rem_width_enable = $1;
- }
- if ($line =~ /^LinkWidthSupported:\.+(.*)/) {
- $rem_width_sup = $1;
- }
- }
- }
- my $capabilities = "";
- if ($print_extended_cap) {
- $capabilities = sprintf("(%3s %s %6s / %8s [%s/%s][%s/%s])",
- $width, $speed, $state, $phy_link_state, $width_enable,
- $width_sup, $speed_enable, $speed_sup);
- } else {
- $capabilities = sprintf("(%3s %s %6s / %8s)",
- $width, $speed, $state, $phy_link_state);
- }
- if ($print_add_switch) {
- $port_timeouts =
- sprintf(" (HOQ:%s VL_Stall:%s)", $hoq_life, $vl_stall);
- }
- if (!$only_down_links || ($only_down_links && $state eq "Down")) {
- my $width_msg = "";
- my $speed_msg = "";
- if ($rem_width_enable ne "" && $rem_width_sup ne "") {
- if ( $width_enable =~ /12X/
- && $rem_width_enable =~ /12X/
- && $width !~ /12X/)
- {
- $width_msg = "Could be 12X";
- } else {
- if ( $width_enable =~ /8X/
- && $rem_width_enable =~ /8X/
- && $width !~ /8X/)
- {
- $width_msg = "Could be 8X";
- } else {
- if ( $width_enable =~ /4X/
- && $rem_width_enable =~ /4X/
- && $width !~ /4X/)
- {
- $width_msg = "Could be 4X";
- }
- }
- }
- }
- if ($rem_speed_enable ne "" && $rem_speed_sup ne "") {
- if ( $speed_enable =~ /10\.0/
- && $rem_speed_enable =~ /10\.0/
- && $speed !~ /10\.0/)
- {
- $speed_msg = "Could be 10.0 Gbps";
- } else {
- if ( $speed_enable =~ /5\.0/
- && $rem_speed_enable =~ /5\.0/
- && $speed !~ /5\.0/)
- {
- $speed_msg = "Could be 5.0 Gbps";
- }
- }
- }
-
- if ($line_mode) {
- my $line_begin = sprintf("%18s \"%30s\"%s",
- $switch, $hr->{loc_desc}, $pkt_life_prompt);
- my $ext_guid = sprintf("%18s", $hr->{rem_guid});
- if ($print_port_guids && $hr->{rem_port_guid} ne "") {
- $ext_guid = sprintf("0x%016s", $hr->{rem_port_guid});
- }
- push(
- @output_lines,
- sprintf(
-"%s %6s %4s[%2s] ==%s%s==> %18s %6s %4s[%2s] \"%s\" ( %s %s)\n",
- $line_begin, $hr->{loc_sw_lid},
- $port, $hr->{loc_ext_port},
- $capabilities, $port_timeouts,
- $ext_guid, $hr->{rem_lid},
- $hr->{rem_port}, $hr->{rem_ext_port},
- $hr->{rem_desc}, $width_msg,
- $speed_msg
- )
- );
- } else {
- push(
- @output_lines,
- sprintf(
-" %6s %4s[%2s] ==%s%s==> %6s %4s[%2s] \"%s\" ( %s %s)\n",
- $hr->{loc_sw_lid}, $port,
- $hr->{loc_ext_port}, $capabilities,
- $port_timeouts, $hr->{rem_lid},
- $hr->{rem_port}, $hr->{rem_ext_port},
- $hr->{rem_desc}, $width_msg,
- $speed_msg
- )
- );
- }
- $print_switch = "yes";
- }
- }
- if ($print_switch eq "yes") {
- foreach my $line (@output_lines) { print $line; }
- }
- }
- if ($single_switch && $switch_found ne "yes") {
- printf("Switch \"%s\" not found.\n", $single_switch);
- }
-}
-main;
-
diff --git a/contrib/ofed/management/infiniband-diags/scripts/ibnodes.in b/contrib/ofed/management/infiniband-diags/scripts/ibnodes.in
deleted file mode 100644
index 5871da8..0000000
--- a/contrib/ofed/management/infiniband-diags/scripts/ibnodes.in
+++ /dev/null
@@ -1,5 +0,0 @@
-#!/bin/sh
-
-IBPATH=${IBPATH:-@IBSCRIPTPATH@}
-
-$IBPATH/ibhosts $@; $IBPATH/ibswitches $@
diff --git a/contrib/ofed/management/infiniband-diags/scripts/ibprintca.pl b/contrib/ofed/management/infiniband-diags/scripts/ibprintca.pl
deleted file mode 100755
index 3cac9b4..0000000
--- a/contrib/ofed/management/infiniband-diags/scripts/ibprintca.pl
+++ /dev/null
@@ -1,136 +0,0 @@
-#!/usr/bin/perl
-#
-# Copyright (c) 2006 The Regents of the University of California.
-# Copyright (c) 2007-2008 Voltaire, Inc. All rights reserved.
-#
-# Produced at Lawrence Livermore National Laboratory.
-# Written by Ira Weiny <weiny2@llnl.gov>.
-#
-# This software is available to you under a choice of one of two
-# licenses. You may choose to be licensed under the terms of the GNU
-# General Public License (GPL) Version 2, available from the file
-# COPYING in the main directory of this source tree, or the
-# OpenIB.org BSD license below:
-#
-# Redistribution and use in source and binary forms, with or
-# without modification, are permitted provided that the following
-# conditions are met:
-#
-# - Redistributions of source code must retain the above
-# copyright notice, this list of conditions and the following
-# disclaimer.
-#
-# - Redistributions in binary form must reproduce the above
-# copyright notice, this list of conditions and the following
-# disclaimer in the documentation and/or other materials
-# provided with the distribution.
-#
-# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
-# BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
-# ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
-# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-# SOFTWARE.
-#
-
-use strict;
-
-use Getopt::Std;
-use IBswcountlimits;
-
-# =========================================================================
-#
-sub usage_and_exit
-{
- my $prog = $_[0];
- print "Usage: $prog [-R -l] [-G <ca_guid> | <node_name>]\n";
- print " print only the ca specified from the ibnetdiscover output\n";
- print " -R Recalculate ibnetdiscover information\n";
- print " -l list cas\n";
- print " -C <ca_name> use selected channel adaptor name for queries\n";
- print " -P <ca_port> use selected channel adaptor port for queries\n";
- print " -G node is specified with GUID\n";
- exit 2;
-}
-
-my $argv0 = `basename $0`;
-my $regenerate_map = undef;
-my $list_hcas = undef;
-my $ca_name = "";
-my $ca_port = "";
-my $name_is_guid = "no";
-chomp $argv0;
-if (!getopts("hRlC:P:G")) { usage_and_exit $argv0; }
-if (defined $Getopt::Std::opt_h) { usage_and_exit $argv0; }
-if (defined $Getopt::Std::opt_R) { $regenerate_map = $Getopt::Std::opt_R; }
-if (defined $Getopt::Std::opt_l) { $list_hcas = $Getopt::Std::opt_l; }
-if (defined $Getopt::Std::opt_C) { $ca_name = $Getopt::Std::opt_C; }
-if (defined $Getopt::Std::opt_P) { $ca_port = $Getopt::Std::opt_P; }
-if (defined $Getopt::Std::opt_G) { $name_is_guid = "yes"; }
-
-my $target_hca = $ARGV[0];
-
-if ($name_is_guid eq "yes") {
- $target_hca = format_guid($target_hca);
-}
-
-my $cache_file = get_cache_file($ca_name, $ca_port);
-
-if ($regenerate_map || !(-f "$cache_file")) {
- generate_ibnetdiscover_topology($ca_name, $ca_port);
-}
-
-if ($list_hcas) {
- system("ibhosts $cache_file");
- exit 1;
-}
-
-if ($target_hca eq "") {
- usage_and_exit $argv0;
-}
-
-# =========================================================================
-#
-sub main
-{
- my $found_hca = 0;
- open IBNET_TOPO, "<$cache_file" or die "Failed to open ibnet topology\n";
- my $in_hca = "no";
- my %ports = undef;
- while (my $line = <IBNET_TOPO>) {
- if ($line =~ /^Ca.*\"H-(.*)\"\s+# (.*)/) {
- my $guid = $1;
- my $desc = $2;
- if ($in_hca eq "yes") {
- $in_hca = "no";
- foreach my $port (sort { $a <=> $b } (keys %ports)) {
- print $ports{$port};
- }
- }
- if ("0x$guid" eq $target_hca || $desc =~ /[\s\"]$target_hca[\s\"]/) {
- print $line;
- $in_hca = "yes";
- $found_hca++;
- }
- }
- if ($line =~ /^Switch.*/ || $line =~ /^Rt.*/) { $in_hca = "no"; }
-
- if ($line =~ /^\[(\d+)\].*/ && $in_hca eq "yes") {
- $ports{$1} = $line;
- }
-
- }
- if ($found_hca == 0) {
- die "\"$target_hca\" not found\n" .
- " Try running with the \"-R\" option.\n" .
- " If still not found the node is probably down.\n";
- }
- if ($found_hca > 1) {
- print "\nWARNING: Found $found_hca CA's with the name \"$target_hca\"\n";
- }
- close IBNET_TOPO;
-}
-main
-
diff --git a/contrib/ofed/management/infiniband-diags/scripts/ibprintrt.pl b/contrib/ofed/management/infiniband-diags/scripts/ibprintrt.pl
deleted file mode 100755
index 48c20f8..0000000
--- a/contrib/ofed/management/infiniband-diags/scripts/ibprintrt.pl
+++ /dev/null
@@ -1,136 +0,0 @@
-#!/usr/bin/perl
-#
-# Copyright (c) 2006 The Regents of the University of California.
-# Copyright (c) 2007-2008 Voltaire, Inc. All rights reserved.
-#
-# Produced at Lawrence Livermore National Laboratory.
-# Written by Ira Weiny <weiny2@llnl.gov>.
-#
-# This software is available to you under a choice of one of two
-# licenses. You may choose to be licensed under the terms of the GNU
-# General Public License (GPL) Version 2, available from the file
-# COPYING in the main directory of this source tree, or the
-# OpenIB.org BSD license below:
-#
-# Redistribution and use in source and binary forms, with or
-# without modification, are permitted provided that the following
-# conditions are met:
-#
-# - Redistributions of source code must retain the above
-# copyright notice, this list of conditions and the following
-# disclaimer.
-#
-# - Redistributions in binary form must reproduce the above
-# copyright notice, this list of conditions and the following
-# disclaimer in the documentation and/or other materials
-# provided with the distribution.
-#
-# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
-# BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
-# ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
-# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-# SOFTWARE.
-#
-
-use strict;
-
-use Getopt::Std;
-use IBswcountlimits;
-
-# =========================================================================
-#
-sub usage_and_exit
-{
- my $prog = $_[0];
- print "Usage: $prog [-R -l] [-G <rt_guid> | <node_name>]\n";
- print " print only the rt specified from the ibnetdiscover output\n";
- print " -R Recalculate ibnetdiscover information\n";
- print " -l list rts\n";
- print " -C <ca_name> use selected channel adaptor name for queries\n";
- print " -P <ca_port> use selected channel adaptor port for queries\n";
- print " -G node is specified with GUID\n";
- exit 2;
-}
-
-my $argv0 = `basename $0`;
-my $regenerate_map = undef;
-my $list_rts = undef;
-my $ca_name = "";
-my $ca_port = "";
-my $name_is_guid = "no";
-chomp $argv0;
-if (!getopts("hRlC:P:G")) { usage_and_exit $argv0; }
-if (defined $Getopt::Std::opt_h) { usage_and_exit $argv0; }
-if (defined $Getopt::Std::opt_R) { $regenerate_map = $Getopt::Std::opt_R; }
-if (defined $Getopt::Std::opt_l) { $list_rts = $Getopt::Std::opt_l; }
-if (defined $Getopt::Std::opt_C) { $ca_name = $Getopt::Std::opt_C; }
-if (defined $Getopt::Std::opt_P) { $ca_port = $Getopt::Std::opt_P; }
-if (defined $Getopt::Std::opt_G) { $name_is_guid = "yes"; }
-
-my $target_rt = $ARGV[0];
-
-if ($name_is_guid eq "yes") {
- $target_rt = format_guid($target_rt);
-}
-
-my $cache_file = get_cache_file($ca_name, $ca_port);
-
-if ($regenerate_map || !(-f "$cache_file")) {
- generate_ibnetdiscover_topology($ca_name, $ca_port);
-}
-
-if ($list_rts) {
- system("ibrouters $cache_file");
- exit 1;
-}
-
-if ($target_rt eq "") {
- usage_and_exit $argv0;
-}
-
-# =========================================================================
-#
-sub main
-{
- my $found_rt = 0;
- open IBNET_TOPO, "<$cache_file" or die "Failed to open ibnet topology\n";
- my $in_rt = "no";
- my %ports = undef;
- while (my $line = <IBNET_TOPO>) {
- if ($line =~ /^Rt.*\"R-(.*)\"\s+# (.*)/) {
- my $guid = $1;
- my $desc = $2;
- if ($in_rt eq "yes") {
- $in_rt = "no";
- foreach my $port (sort { $a <=> $b } (keys %ports)) {
- print $ports{$port};
- }
- }
- if ("0x$guid" eq $target_rt || $desc =~ /[\s\"]$target_rt[\s\"]/) {
- print $line;
- $in_rt = "yes";
- $found_rt++;
- }
- }
- if ($line =~ /^Switch.*/ || $line =~ /^Ca.*/) { $in_rt = "no"; }
-
- if ($line =~ /^\[(\d+)\].*/ && $in_rt eq "yes") {
- $ports{$1} = $line;
- }
-
- }
- if ($found_rt == 0) {
- die "\"$target_rt\" not found\n" .
- " Try running with the \"-R\" option.\n" .
- " If still not found the node is probably down.\n";
- }
- if ($found_rt > 1) {
- print "\nWARNING: Found $found_rt Router's with the name \"$target_rt\"\n";
- }
- close IBNET_TOPO;
-}
-main
-
diff --git a/contrib/ofed/management/infiniband-diags/scripts/ibprintswitch.pl b/contrib/ofed/management/infiniband-diags/scripts/ibprintswitch.pl
deleted file mode 100755
index f20bd4b..0000000
--- a/contrib/ofed/management/infiniband-diags/scripts/ibprintswitch.pl
+++ /dev/null
@@ -1,135 +0,0 @@
-#!/usr/bin/perl
-#
-# Copyright (c) 2008 Voltaire, Inc. All rights reserved.
-# Copyright (c) 2006 The Regents of the University of California.
-#
-# Produced at Lawrence Livermore National Laboratory.
-# Written by Ira Weiny <weiny2@llnl.gov>.
-#
-# This software is available to you under a choice of one of two
-# licenses. You may choose to be licensed under the terms of the GNU
-# General Public License (GPL) Version 2, available from the file
-# COPYING in the main directory of this source tree, or the
-# OpenIB.org BSD license below:
-#
-# Redistribution and use in source and binary forms, with or
-# without modification, are permitted provided that the following
-# conditions are met:
-#
-# - Redistributions of source code must retain the above
-# copyright notice, this list of conditions and the following
-# disclaimer.
-#
-# - Redistributions in binary form must reproduce the above
-# copyright notice, this list of conditions and the following
-# disclaimer in the documentation and/or other materials
-# provided with the distribution.
-#
-# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
-# BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
-# ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
-# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-# SOFTWARE.
-#
-
-use strict;
-
-use Getopt::Std;
-use IBswcountlimits;
-
-# =========================================================================
-#
-sub usage_and_exit
-{
- my $prog = $_[0];
- print "Usage: $prog [-R -l] [-G <switch_guid> | <switch_name>]\n";
- print " print only the switch specified from the ibnetdiscover output\n";
- print " -R Recalculate ibnetdiscover information\n";
- print " -l list switches\n";
- print " -C <ca_name> use selected channel adaptor name for queries\n";
- print " -P <ca_port> use selected channel adaptor port for queries\n";
- print " -G node is specified with GUID\n";
- exit 2;
-}
-
-my $argv0 = `basename $0`;
-my $regenerate_map = undef;
-my $list_switches = undef;
-my $ca_name = "";
-my $ca_port = "";
-my $name_is_guid = "no";
-chomp $argv0;
-if (!getopts("hRlC:P:G")) { usage_and_exit $argv0; }
-if (defined $Getopt::Std::opt_h) { usage_and_exit $argv0; }
-if (defined $Getopt::Std::opt_R) { $regenerate_map = $Getopt::Std::opt_R; }
-if (defined $Getopt::Std::opt_l) { $list_switches = $Getopt::Std::opt_l; }
-if (defined $Getopt::Std::opt_C) { $ca_name = $Getopt::Std::opt_C; }
-if (defined $Getopt::Std::opt_P) { $ca_port = $Getopt::Std::opt_P; }
-if (defined $Getopt::Std::opt_G) { $name_is_guid = "yes"; }
-
-my $target_switch = $ARGV[0];
-
-if ($name_is_guid eq "yes") {
- $target_switch = format_guid($target_switch);
-}
-
-my $cache_file = get_cache_file($ca_name, $ca_port);
-
-if ($regenerate_map || !(-f "$cache_file")) {
- generate_ibnetdiscover_topology($ca_name, $ca_port);
-}
-
-if ($list_switches) {
- system("ibswitches $cache_file");
- exit 1;
-}
-
-if ($target_switch eq "") {
- usage_and_exit $argv0;
-}
-
-# =========================================================================
-#
-sub main
-{
- my $found_switch = 0;
- open IBNET_TOPO, "<$cache_file" or die "Failed to open ibnet topology\n";
- my $in_switch = "no";
- my %ports = undef;
- while (my $line = <IBNET_TOPO>) {
- if ($line =~ /^Switch.*\"S-(.*)\"\s+# (.*) port.*/) {
- my $guid = $1;
- my $desc = $2;
- if ($in_switch eq "yes") {
- $in_switch = "no";
- foreach my $port (sort { $a <=> $b } (keys %ports)) {
- print $ports{$port};
- }
- }
- if ("0x$guid" eq $target_switch || $desc =~ /[\s\"]$target_switch[\s\"]/) {
- print $line;
- $in_switch = "yes";
- $found_switch++;
- }
- }
- if ($line =~ /^Ca.*/) { $in_switch = "no"; }
-
- if ($line =~ /^\[(\d+)\].*/ && $in_switch eq "yes") {
- $ports{$1} = $line;
- }
-
- }
- if ($found_switch == 0) {
- die "Switch \"$target_switch\" not found\n" .
- " Try running with the \"-R\" option.\n";
- }
- if ($found_switch > 1) {
- print "\nWARNING: Found $found_switch switches with the name \"$target_switch\"\n";
- }
- close IBNET_TOPO;
-}
-main
-
diff --git a/contrib/ofed/management/infiniband-diags/scripts/ibqueryerrors.pl b/contrib/ofed/management/infiniband-diags/scripts/ibqueryerrors.pl
deleted file mode 100755
index 99adac7..0000000
--- a/contrib/ofed/management/infiniband-diags/scripts/ibqueryerrors.pl
+++ /dev/null
@@ -1,230 +0,0 @@
-#!/usr/bin/perl
-#
-# Copyright (c) 2008 Voltaire, Inc. All rights reserved.
-# Copyright (c) 2006 The Regents of the University of California.
-#
-# Produced at Lawrence Livermore National Laboratory.
-# Written by Ira Weiny <weiny2@llnl.gov>.
-#
-# This software is available to you under a choice of one of two
-# licenses. You may choose to be licensed under the terms of the GNU
-# General Public License (GPL) Version 2, available from the file
-# COPYING in the main directory of this source tree, or the
-# OpenIB.org BSD license below:
-#
-# Redistribution and use in source and binary forms, with or
-# without modification, are permitted provided that the following
-# conditions are met:
-#
-# - Redistributions of source code must retain the above
-# copyright notice, this list of conditions and the following
-# disclaimer.
-#
-# - Redistributions in binary form must reproduce the above
-# copyright notice, this list of conditions and the following
-# disclaimer in the documentation and/or other materials
-# provided with the distribution.
-#
-# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
-# BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
-# ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
-# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-# SOFTWARE.
-#
-
-use strict;
-
-use Getopt::Std;
-use IBswcountlimits;
-
-my $print_action = "no";
-my $report_port_info = undef;
-my $single_switch = undef;
-my $include_data_counters = undef;
-my $cache_file = "";
-my $switch_found = "no";
-
-# =========================================================================
-#
-sub report_counts
-{
- my $addr = $_[0];
- my $port = $_[1];
- my $ca_name = $_[2];
- my $ca_port = $_[3];
- my $extra_params = get_ca_name_port_param_string($ca_name, $ca_port);
-
- if (any_counts()) {
- print(" GUID $addr port $port:");
- check_counters($print_action);
- if ($include_data_counters) {
- check_data_counters($print_action);
- }
- print("\n");
-
- if ($report_port_info) {
- my $lid = "";
- my $speed = "";
- my $width = "";
- my $data = `smpquery $extra_params -G portinfo $addr $port`;
- my @lines = split("\n", $data);
- foreach my $line (@lines) {
- if ($line =~ /^# Port info: Lid (\w+) port.*/) { $lid = $1; }
- if ($line =~ /^LinkSpeedActive:\.+(.*)/) { $speed = $1; }
- if ($line =~ /^LinkWidthActive:\.+(.*)/) { $width = $1; }
- }
- my $hr = $IBswcountlimits::link_ends{"$addr"}{$port};
- if ($hr) {
- printf(
-" Link info: %6s %4s[%2s] ==(%3s %s)==> %18s %4s[%2s] \"%s\"\n",
- $lid, $port,
- $hr->{loc_ext_port}, $width,
- $speed, $hr->{rem_guid},
- $hr->{rem_port}, $hr->{rem_ext_port},
- $hr->{rem_desc}
- );
- } else {
- printf(
-" Link info: %6s %4s[ ] ==(%3s %s)==> (Disconnected)\n",
- $lid, $port, $width, $speed);
- }
- }
- }
-}
-
-# =========================================================================
-# use perfquery to get the counters.
-sub get_counts
-{
- my $addr = $_[0];
- my $port = $_[1];
- my $ca_name = $_[2];
- my $ca_port = $_[3];
- my $extra_params = get_ca_name_port_param_string($ca_name, $ca_port);
-
- my $data = `perfquery $extra_params -G $addr $port` ||
- die "'perfquery $extra_params -G $addr $port' FAILED.\n";
- my @lines = split("\n", $data);
- foreach my $line (@lines) {
- foreach my $count (@IBswcountlimits::counters) {
- if ($line =~ /^$count:\.+(\d+)/) {
- $IBswcountlimits::cur_counts{$count} = $1;
- }
- }
- }
-}
-
-# =========================================================================
-#
-my %switches = ();
-
-sub get_switches
-{
- my $data = `ibswitches $cache_file` ||
- die "'ibswitches $cache_file' failed.\n";
- my @lines = split("\n", $data);
- foreach my $line (@lines) {
- if ($line =~ /^Switch\s+:\s+(\w+)\s+ports\s+(\d+)\s+.*/) {
- $switches{$1} = $2;
- }
- }
-}
-
-# =========================================================================
-#
-sub usage_and_exit
-{
- my $prog = $_[0];
- print
-"Usage: $prog [-a -c -r -R -s <err1,err2,...> -S <switch_guid> -D <direct route> -d -C <ca_name> -P <ca_port>]\n";
- print " Report counters on all switches in subnet\n";
- print " -a Report an action to take\n";
- print " -c suppress some of the common counters\n";
- print " -r report port configuration information\n";
- print " -R Recalculate ibnetdiscover information\n";
- print " -s <err1,err2,...> suppress errors listed\n";
- print
-" -D <direct route> output only the switch specified by direct route path\n";
- print " -S <switch_guid> query only <switch_guid> (hex format)\n";
- print " -d include the data counters in the output\n";
- print " -C <ca_name> use selected Channel Adaptor name for queries\n";
- print " -P <ca_port> use selected channel adaptor port for queries\n";
- exit 2;
-}
-
-my $argv0 = `basename $0`;
-my $regenerate_map = undef;
-my $single_switch = undef;
-my $direct_route = undef;
-my $ca_name = "";
-my $ca_port = "";
-
-chomp $argv0;
-if (!getopts("has:crRS:D:dC:P:")) { usage_and_exit $argv0; }
-if (defined $Getopt::Std::opt_h) { usage_and_exit $argv0; }
-if (defined $Getopt::Std::opt_a) { $print_action = "yes"; }
-if (defined $Getopt::Std::opt_s) {
- @IBswcountlimits::suppress_errors = split(",", $Getopt::Std::opt_s);
-}
-if (defined $Getopt::Std::opt_c) {
- @IBswcountlimits::suppress_errors = split(",", "RcvSwRelayErrors");
-}
-if (defined $Getopt::Std::opt_r) { $report_port_info = $Getopt::Std::opt_r; }
-if (defined $Getopt::Std::opt_R) { $regenerate_map = $Getopt::Std::opt_R; }
-if (defined $Getopt::Std::opt_D) { $direct_route = $Getopt::Std::opt_D; }
-if (defined $Getopt::Std::opt_S) {
- $single_switch = format_guid($Getopt::Std::opt_S);
-}
-if (defined $Getopt::Std::opt_d) {
- $include_data_counters = $Getopt::Std::opt_d;
-}
-if (defined $Getopt::Std::opt_C) { $ca_name = $Getopt::Std::opt_C; }
-if (defined $Getopt::Std::opt_P) { $ca_port = $Getopt::Std::opt_P; }
-
-$cache_file = get_cache_file($ca_name, $ca_port);
-
-sub main
-{
- if (@IBswcountlimits::suppress_errors) {
- my $msg = join(",", @IBswcountlimits::suppress_errors);
- print "Suppressing: $msg\n";
- }
- get_link_ends($regenerate_map, $ca_name, $ca_port);
- get_switches;
- if (defined($direct_route)) {
- # convert DR to guid, then use original single_switch option
- $single_switch = convert_dr_to_guid($direct_route);
- if (!defined($single_switch) || !is_switch($single_switch)) {
- printf("The direct route (%s) does not map to a switch.\n",
- $direct_route);
- return;
- }
- }
- foreach my $sw_addr (keys %switches) {
- if ($single_switch && $sw_addr ne "$single_switch") {
- next;
- } else {
- $switch_found = "yes";
- }
-
- my $switch_prompt = "no";
- foreach my $sw_port (1 .. $switches{$sw_addr}) {
- clear_counters;
- get_counts($sw_addr, $sw_port, $ca_name, $ca_port);
- if (any_counts() && $switch_prompt eq "no") {
- my $hr = $IBswcountlimits::link_ends{"$sw_addr"}{$sw_port};
- printf("Errors for %18s \"%s\"\n", $sw_addr, $hr->{loc_desc});
- $switch_prompt = "yes";
- }
- report_counts($sw_addr, $sw_port);
- }
- }
- if ($single_switch && $switch_found ne "yes") {
- printf("Switch \"%s\" not found.\n", $single_switch);
- }
-}
-main;
-
diff --git a/contrib/ofed/management/infiniband-diags/scripts/ibrouters.in b/contrib/ofed/management/infiniband-diags/scripts/ibrouters.in
deleted file mode 100644
index 6404aca..0000000
--- a/contrib/ofed/management/infiniband-diags/scripts/ibrouters.in
+++ /dev/null
@@ -1,60 +0,0 @@
-#!/bin/sh
-
-IBPATH=${IBPATH:-@IBSCRIPTPATH@}
-
-function usage() {
- echo Usage: `basename $0` "[-h] [<topology-file> | -C ca_name" \
- "-P ca_port -t(imeout) timeout_ms]"
- exit -1
-}
-
-topofile=""
-ca_info=""
-
-while [ "$1" ]; do
- case $1 in
- -h)
- usage
- ;;
- -P | -C | -t | -timeout)
- case $2 in
- -*)
- usage
- ;;
- esac
- if [ x$2 = x ] ; then
- usage
- fi
- ca_info="$ca_info $1 $2"
- shift
- ;;
- -*)
- usage
- ;;
- *)
- if [ "$topofile" ]; then
- usage
- fi
- topofile="$1"
- ;;
- esac
- shift
-done
-
-if [ "$topofile" ]; then
- netcmd="cat $topofile"
-else
- netcmd="$IBPATH/ibnetdiscover $ca_info"
-fi
-
-text="`eval $netcmd`"
-rv=$?
-echo "$text" | awk '
-/^Rt/ {print $1 "\t: 0x" substr($3, 4, 16) " ports " $2 " "\
- substr($0, match($0, "#[ \t]*")+RLENGTH)}
-/^ib/ {print $0; next}
-/ibpanic:/ {print $0}
-/ibwarn:/ {print $0}
-/iberror:/ {print $0}
-'
-exit $rv
diff --git a/contrib/ofed/management/infiniband-diags/scripts/ibstatus b/contrib/ofed/management/infiniband-diags/scripts/ibstatus
deleted file mode 100755
index 87fbb0c..0000000
--- a/contrib/ofed/management/infiniband-diags/scripts/ibstatus
+++ /dev/null
@@ -1,77 +0,0 @@
-#!/bin/sh
-
-# Usage ibstatus [devname[:port]]
-
-infiniband_base="/sys/class/infiniband"
-def_ibdev="mthca0"
-
-usage() {
- prog=`basename $0`
- echo "Usage: " $prog " [-h] [devname[:portnum]]"
- echo " -h: this help screen"
- echo " Examples:"
- echo " $prog mthca1 # shows status of all ports of 'mthca1'"
- echo " $prog mthca0:2 # shows status port number 2 of 'mthca0'"
- echo " $prog # default: shows status of all '$def_ibdev' ports"
- exit -1
-}
-
-fatal() {
- echo "Fatal error: " $*
- exit -1
-}
-
-
-port_status() {
- port_dir="$infiniband_base/$1/ports/$2"
- echo "Infiniband device '$1' port $2 status:"
- echo " default gid: " `[ -r $port_dir/gids/0 ] && cat $port_dir/gids/0 || echo unknown`
- echo " base lid: " `[ -r $port_dir/lid ] && cat $port_dir/lid || echo unknown`
- echo " sm lid: " `[ -r $port_dir/sm_lid ] && cat $port_dir/sm_lid || echo unknown`
- echo " state: " `[ -r $port_dir/state ] && cat $port_dir/state || echo unknown`
- echo " phys state: " `[ -r $port_dir/phys_state ] && cat $port_dir/phys_state || echo unknown`
- echo " rate: " `[ -r $port_dir/rate ] && cat $port_dir/rate || echo unknown`
- echo
-}
-
-ib_status() {
- ports_dir="$infiniband_base/$1/ports"
-
- if ! [ -d "$ports_dir" ]; then
- fatal "device '$1': sys files not found ($ports_dir)"
- fi
-
- if [ "$2" = "+" ]; then
- ports=`(cd "$infiniband_base/$1/ports" 2>/dev/null || fatal No devices; echo *)`
- else
- ports=$2
- fi
-
- for i in $ports; do
- port_status $1 $i
- done
-}
-
-if [ "$1" = "-h" ]; then
- usage
-fi
-
-if [ -z "$1" ]; then
- cd $infiniband_base 2>/dev/null || fatal No devices
- for dev in *; do
- ib_status $dev "+";
- done
- exit 0
-fi
-
-while [ "$1" ]; do
- dev=`echo $1 | sed 's/:.*$//'`
- port=`echo $1 | sed 's/^.*://'`
-
- if [ "$port" = "$dev" ]; then
- port="+"
- fi
-
- ib_status $dev $port
- shift
-done
diff --git a/contrib/ofed/management/infiniband-diags/scripts/ibswitches.in b/contrib/ofed/management/infiniband-diags/scripts/ibswitches.in
deleted file mode 100644
index 163620a..0000000
--- a/contrib/ofed/management/infiniband-diags/scripts/ibswitches.in
+++ /dev/null
@@ -1,79 +0,0 @@
-#!/bin/sh
-
-IBPATH=${IBPATH:-@IBSCRIPTPATH@}
-
-function usage() {
- echo Usage: `basename $0` "[-h] [<topology-file> | -C ca_name" \
- "-P ca_port -t(imeout) timeout_ms]"
- exit -1
-}
-
-topofile=""
-ca_info=""
-
-while [ "$1" ]; do
- case $1 in
- -h)
- usage
- ;;
- -P | -C | -t | -timeout)
- case $2 in
- -*)
- usage
- ;;
- esac
- if [ x$2 = x ] ; then
- usage
- fi
- ca_info="$ca_info $1 $2"
- shift
- ;;
- -*)
- usage
- ;;
- *)
- if [ "$topofile" ]; then
- usage
- fi
- topofile="$1"
- ;;
- esac
- shift
-done
-
-if [ "$topofile" ]; then
- netcmd="cat $topofile"
-else
- netcmd="$IBPATH/ibnetdiscover $ca_info"
-fi
-
-text="`eval $netcmd`"
-rv=$?
-echo "$text" | awk '
-/^Switch/ {
- l=$0
- desc=substr(l, match(l, "#[ \t]*")+RLENGTH)
- pi=match(desc, "port 0.*")
- pinfo=substr(desc, pi)
- desc=substr(desc, 1, pi-2)
- type="base"
- ti=match(desc, type)
- if (ti==0) {
- type="enhanced"
- ti=match(desc, type)
- if (ti!=0)
- desc=substr(desc, 1, ti-2)
- } else
- desc=substr(desc, 1, ti-2)
- if (ti==0)
- print $1 "\t: 0x" substr($3, 4, 16) " ports " $2 " "\
- desc " " pinfo
- else
- print $1 "\t: 0x" substr($3, 4, 16) " ports " $2 " "\
- desc " " type " " pinfo}
-/^ib/ {print $0; next}
-/ibpanic:/ {print $0}
-/ibwarn:/ {print $0}
-/iberror:/ {print $0}
-'
-exit $rv
diff --git a/contrib/ofed/management/infiniband-diags/scripts/ibswportwatch.pl b/contrib/ofed/management/infiniband-diags/scripts/ibswportwatch.pl
deleted file mode 100755
index a2880aac..0000000
--- a/contrib/ofed/management/infiniband-diags/scripts/ibswportwatch.pl
+++ /dev/null
@@ -1,174 +0,0 @@
-#!/usr/bin/perl
-#
-# Copyright (c) 2008 Voltaire, Inc. All rights reserved.
-# Copyright (c) 2006 The Regents of the University of California.
-#
-# Produced at Lawrence Livermore National Laboratory.
-# Written by Ira Weiny <weiny2@llnl.gov>.
-#
-# This software is available to you under a choice of one of two
-# licenses. You may choose to be licensed under the terms of the GNU
-# General Public License (GPL) Version 2, available from the file
-# COPYING in the main directory of this source tree, or the
-# OpenIB.org BSD license below:
-#
-# Redistribution and use in source and binary forms, with or
-# without modification, are permitted provided that the following
-# conditions are met:
-#
-# - Redistributions of source code must retain the above
-# copyright notice, this list of conditions and the following
-# disclaimer.
-#
-# - Redistributions in binary form must reproduce the above
-# copyright notice, this list of conditions and the following
-# disclaimer in the documentation and/or other materials
-# provided with the distribution.
-#
-# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
-# BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
-# ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
-# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-# SOFTWARE.
-#
-
-use strict;
-
-use Getopt::Std;
-use IBswcountlimits;
-
-my $sw_addr = "";
-my $sw_port = "";
-my $verbose = undef;
-
-# =========================================================================
-#
-sub print_verbose
-{
- if ($verbose) {
- print $_[0];
- }
-}
-
-# =========================================================================
-#
-sub print_all_counts
-{
- if (!$verbose) { return; }
-
- print " Counter\t\t\tNew ==> Old\n";
- foreach my $cnt (@IBswcountlimits::counters) {
- print
-" $cnt\t\t\t$IBswcountlimits::new_counts{$cnt} ==> $IBswcountlimits::cur_counts{$cnt}\n";
- }
-}
-
-# =========================================================================
-#
-sub usage_and_exit
-{
- my $prog = $_[0];
- print
- "Usage: $prog [-p <pause_time> -b -v -n <cycles> -G] <guid|lid> <port>\n";
- print " Attempt to diagnose a problem on a port\n";
- print
-" Run this on a link while a job is running which utilizes that link.\n";
- print
-" -p <pause_time> define the ammount of time between counter polls (default $IBswcountlimits::pause_time)\n";
- print " -v Be verbose\n";
- print " -n <cycles> run n cycles then exit (default -1 == forever)\n";
- print " -G Address provided is a GUID\n";
- print " -b report bytes/second packets/second\n";
- exit 2;
-}
-
-# =========================================================================
-#
-sub clear_counters
-{
- # clear the counters
- foreach my $count (@IBswcountlimits::counters) {
- $IBswcountlimits::cur_counts{$count} = 0;
- $IBswcountlimits::new_counts{$count} = 0;
- }
-}
-
-# =========================================================================
-#
-sub mv_counts
-{
- foreach my $count (@IBswcountlimits::counters) {
- $IBswcountlimits::cur_counts{$count} =
- $IBswcountlimits::new_counts{$count};
- }
-}
-
-# =========================================================================
-# use perfquery to get the counters.
-my $GUID = "";
-
-sub get_new_counts
-{
- my $addr = $_[0];
- my $port = $_[1];
- mv_counts;
- ensure_cache_dir;
- if (
- system(
-"perfquery $GUID $addr $port > $IBswcountlimits::cache_dir/perfquery.out"
- )
- )
- {
- die "perfquery failed : \"perfquery $GUID $addr $port\"\n";
- }
- open PERF_QUERY, "<$IBswcountlimits::cache_dir/perfquery.out"
- or die "cannot read '$IBswcountlimits::cache_dir/perfquery.out': $!\n";
- while (my $line = <PERF_QUERY>) {
- foreach my $count (@IBswcountlimits::counters) {
- if ($line =~ /^$count:\.+(\d+)/) {
- $IBswcountlimits::new_counts{$count} = $1;
- }
- }
- }
- close PERF_QUERY;
-}
-
-my $cycle = -1; # forever
-
-my $bytes_per_second = undef;
-my $argv0 = `basename $0`;
-chomp $argv0;
-if (!getopts("hbvp:n:G")) { usage_and_exit $argv0; }
-if (defined $Getopt::Std::opt_h) { usage_and_exit $argv0; }
-if (defined $Getopt::Std::opt_p) {
- $IBswcountlimits::pause_time = $Getopt::Std::opt_p;
-}
-if (defined $Getopt::Std::opt_v) { $verbose = $Getopt::Std::opt_v; }
-if (defined $Getopt::Std::opt_n) { $cycle = $Getopt::Std::opt_n; }
-if (defined $Getopt::Std::opt_G) { $GUID = "-G"; }
-if (defined $Getopt::Std::opt_b) { $bytes_per_second = $Getopt::Std::opt_b; }
-
-my $sw_addr = $ARGV[0];
-my $sw_port = $ARGV[1];
-
-sub main
-{
- clear_counters;
- get_new_counts($sw_addr, $sw_port);
- while ($cycle != 0) {
- print "Checking counts...\n";
- sleep($IBswcountlimits::pause_time);
- get_new_counts($sw_addr, $sw_port);
- check_counter_rates;
- if ($bytes_per_second) {
- print_data_rates;
- }
- print_all_counts;
- if ($cycle != -1) { $cycle = $cycle - 1; }
- }
-}
-main;
-
diff --git a/contrib/ofed/management/infiniband-diags/scripts/set_nodedesc.sh b/contrib/ofed/management/infiniband-diags/scripts/set_nodedesc.sh
deleted file mode 100755
index 855ced7..0000000
--- a/contrib/ofed/management/infiniband-diags/scripts/set_nodedesc.sh
+++ /dev/null
@@ -1,57 +0,0 @@
-#!/bin/sh
-
-if [ -f /etc/sysconfig/network ]; then
-. /etc/sysconfig/network
-fi
-
-ib_sysfs="/sys/class/infiniband"
-newname="$HOSTNAME"
-
-
-function usage
-{
- echo "Usage: `basename $0` [-hv] [<name>]"
- echo " set the node_desc field of all hca's found in \"$ib_sysfs\""
- echo " -h this help"
- echo " -v view all node descriptors"
- echo " [<name>] set name to name specified."
- echo " Default is to use the hostname: \"$HOSTNAME\""
- exit 2
-}
-
-function viewall
-{
- for hca in `ls $ib_sysfs`; do
- if [ -f $ib_sysfs/$hca/node_desc ]; then
- echo -n "$hca: "
- cat $ib_sysfs/$hca/node_desc
- else
- logger -s "Failed to set node_desc for : $hca"
- fi
- done
- exit 0
-}
-
-while getopts "hv" flag
-do
- case $flag in
- "h") usage;;
- "v") viewall;;
- esac
-done
-
-shift $(($OPTIND - 1))
-
-if [ "$1" != "" ]; then
- newname="$1"
-fi
-
-for hca in `ls $ib_sysfs`; do
- if [ -f $ib_sysfs/$hca/node_desc ]; then
- echo -n "$newname" >> $ib_sysfs/$hca/node_desc
- else
- logger -s "Failed to set node_desc for : $hca"
- fi
-done
-
-exit 0
diff --git a/contrib/ofed/management/infiniband-diags/src/grouping.c b/contrib/ofed/management/infiniband-diags/src/grouping.c
deleted file mode 100644
index f1a996f..0000000
--- a/contrib/ofed/management/infiniband-diags/src/grouping.c
+++ /dev/null
@@ -1,787 +0,0 @@
-/*
- * Copyright (c) 2004-2007 Voltaire Inc. All rights reserved.
- * Copyright (c) 2007 Xsigo Systems Inc. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- */
-
-/*========================================================*/
-/* FABRIC SCANNER SPECIFIC DATA */
-/*========================================================*/
-
-#if HAVE_CONFIG_H
-# include <config.h>
-#endif /* HAVE_CONFIG_H */
-
-#include <stdint.h>
-#include <stdlib.h>
-#include <inttypes.h>
-
-#include <infiniband/common.h>
-#include <infiniband/mad.h>
-
-#include "ibnetdiscover.h"
-#include "grouping.h"
-
-#define OUT_BUFFER_SIZE 16
-
-
-extern Node *nodesdist[MAXHOPS+1]; /* last is CA list */
-extern Node *mynode;
-extern Port *myport;
-extern int maxhops_discovered;
-
-AllChassisList mylist;
-
-char *ChassisTypeStr[5] = { "", "ISR9288", "ISR9096", "ISR2012", "ISR2004" };
-char *ChassisSlotStr[4] = { "", "Line", "Spine", "SRBD" };
-
-
-char *get_chassis_type(unsigned char chassistype)
-{
- if (chassistype == UNRESOLVED_CT || chassistype > ISR2004_CT)
- return NULL;
- return ChassisTypeStr[chassistype];
-}
-
-char *get_chassis_slot(unsigned char chassisslot)
-{
- if (chassisslot == UNRESOLVED_CS || chassisslot > SRBD_CS)
- return NULL;
- return ChassisSlotStr[chassisslot];
-}
-
-static struct ChassisList *find_chassisnum(unsigned char chassisnum)
-{
- ChassisList *current;
-
- for (current = mylist.first; current; current = current->next) {
- if (current->chassisnum == chassisnum)
- return current;
- }
-
- return NULL;
-}
-
-static uint64_t topspin_chassisguid(uint64_t guid)
-{
- /* Byte 3 in system image GUID is chassis type, and */
- /* Byte 4 is location ID (slot) so just mask off byte 4 */
- return guid & 0xffffffff00ffffffULL;
-}
-
-int is_xsigo_guid(uint64_t guid)
-{
- if ((guid & 0xffffff0000000000ULL) == 0x0013970000000000ULL)
- return 1;
- else
- return 0;
-}
-
-static int is_xsigo_leafone(uint64_t guid)
-{
- if ((guid & 0xffffffffff000000ULL) == 0x0013970102000000ULL)
- return 1;
- else
- return 0;
-}
-
-int is_xsigo_hca(uint64_t guid)
-{
- /* NodeType 2 is HCA */
- if ((guid & 0xffffffff00000000ULL) == 0x0013970200000000ULL)
- return 1;
- else
- return 0;
-}
-
-int is_xsigo_tca(uint64_t guid)
-{
- /* NodeType 3 is TCA */
- if ((guid & 0xffffffff00000000ULL) == 0x0013970300000000ULL)
- return 1;
- else
- return 0;
-}
-
-static int is_xsigo_ca(uint64_t guid)
-{
- if (is_xsigo_hca(guid) || is_xsigo_tca(guid))
- return 1;
- else
- return 0;
-}
-
-static int is_xsigo_switch(uint64_t guid)
-{
- if ((guid & 0xffffffff00000000ULL) == 0x0013970100000000ULL)
- return 1;
- else
- return 0;
-}
-
-static uint64_t xsigo_chassisguid(Node *node)
-{
- if (!is_xsigo_ca(node->sysimgguid)) {
- /* Byte 3 is NodeType and byte 4 is PortType */
- /* If NodeType is 1 (switch), PortType is masked */
- if (is_xsigo_switch(node->sysimgguid))
- return node->sysimgguid & 0xffffffff00ffffffULL;
- else
- return node->sysimgguid;
- } else {
- /* Is there a peer port ? */
- if (!node->ports->remoteport)
- return node->sysimgguid;
-
- /* If peer port is Leaf 1, use its chassis GUID */
- if (is_xsigo_leafone(node->ports->remoteport->node->sysimgguid))
- return node->ports->remoteport->node->sysimgguid &
- 0xffffffff00ffffffULL;
- else
- return node->sysimgguid;
- }
-}
-
-static uint64_t get_chassisguid(Node *node)
-{
- if (node->vendid == TS_VENDOR_ID || node->vendid == SS_VENDOR_ID)
- return topspin_chassisguid(node->sysimgguid);
- else if (node->vendid == XS_VENDOR_ID || is_xsigo_guid(node->sysimgguid))
- return xsigo_chassisguid(node);
- else
- return node->sysimgguid;
-}
-
-static struct ChassisList *find_chassisguid(Node *node)
-{
- ChassisList *current;
- uint64_t chguid;
-
- chguid = get_chassisguid(node);
- for (current = mylist.first; current; current = current->next) {
- if (current->chassisguid == chguid)
- return current;
- }
-
- return NULL;
-}
-
-uint64_t get_chassis_guid(unsigned char chassisnum)
-{
- ChassisList *chassis;
-
- chassis = find_chassisnum(chassisnum);
- if (chassis)
- return chassis->chassisguid;
- else
- return 0;
-}
-
-static int is_router(Node *node)
-{
- return (node->devid == VTR_DEVID_IB_FC_ROUTER ||
- node->devid == VTR_DEVID_IB_IP_ROUTER);
-}
-
-static int is_spine_9096(Node *node)
-{
- return (node->devid == VTR_DEVID_SFB4 ||
- node->devid == VTR_DEVID_SFB4_DDR);
-}
-
-static int is_spine_9288(Node *node)
-{
- return (node->devid == VTR_DEVID_SFB12 ||
- node->devid == VTR_DEVID_SFB12_DDR);
-}
-
-static int is_spine_2004(Node *node)
-{
- return (node->devid == VTR_DEVID_SFB2004);
-}
-
-static int is_spine_2012(Node *node)
-{
- return (node->devid == VTR_DEVID_SFB2012);
-}
-
-static int is_spine(Node *node)
-{
- return (is_spine_9096(node) || is_spine_9288(node) ||
- is_spine_2004(node) || is_spine_2012(node));
-}
-
-static int is_line_24(Node *node)
-{
- return (node->devid == VTR_DEVID_SLB24 ||
- node->devid == VTR_DEVID_SLB24_DDR ||
- node->devid == VTR_DEVID_SRB2004);
-}
-
-static int is_line_8(Node *node)
-{
- return (node->devid == VTR_DEVID_SLB8);
-}
-
-static int is_line_2024(Node *node)
-{
- return (node->devid == VTR_DEVID_SLB2024);
-}
-
-static int is_line(Node *node)
-{
- return (is_line_24(node) || is_line_8(node) || is_line_2024(node));
-}
-
-int is_chassis_switch(Node *node)
-{
- return (is_spine(node) || is_line(node));
-}
-
-/* these structs help find Line (Anafa) slot number while using spine portnum */
-int line_slot_2_sfb4[25] = { 0, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4 };
-int anafa_line_slot_2_sfb4[25] = { 0, 1, 1, 1, 2, 2, 2, 1, 1, 1, 2, 2, 2, 1, 1, 1, 2, 2, 2, 1, 1, 1, 2, 2, 2 };
-int line_slot_2_sfb12[25] = { 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9,10, 10, 11, 11, 12, 12 };
-int anafa_line_slot_2_sfb12[25] = { 0, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2 };
-
-/* IPR FCR modules connectivity while using sFB4 port as reference */
-int ipr_slot_2_sfb4_port[25] = { 0, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1 };
-
-/* these structs help find Spine (Anafa) slot number while using spine portnum */
-int spine12_slot_2_slb[25] = { 0, 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
-int anafa_spine12_slot_2_slb[25]= { 0, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
-int spine4_slot_2_slb[25] = { 0, 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
-int anafa_spine4_slot_2_slb[25] = { 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
-/* reference { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24 }; */
-
-static void get_sfb_slot(Node *node, Port *lineport)
-{
- ChassisRecord *ch = node->chrecord;
-
- ch->chassisslot = SPINE_CS;
- if (is_spine_9096(node)) {
- ch->chassistype = ISR9096_CT;
- ch->slotnum = spine4_slot_2_slb[lineport->portnum];
- ch->anafanum = anafa_spine4_slot_2_slb[lineport->portnum];
- } else if (is_spine_9288(node)) {
- ch->chassistype = ISR9288_CT;
- ch->slotnum = spine12_slot_2_slb[lineport->portnum];
- ch->anafanum = anafa_spine12_slot_2_slb[lineport->portnum];
- } else if (is_spine_2012(node)) {
- ch->chassistype = ISR2012_CT;
- ch->slotnum = spine12_slot_2_slb[lineport->portnum];
- ch->anafanum = anafa_spine12_slot_2_slb[lineport->portnum];
- } else if (is_spine_2004(node)) {
- ch->chassistype = ISR2004_CT;
- ch->slotnum = spine4_slot_2_slb[lineport->portnum];
- ch->anafanum = anafa_spine4_slot_2_slb[lineport->portnum];
- } else {
- IBPANIC("Unexpected node found: guid 0x%016" PRIx64, node->nodeguid);
- }
-}
-
-static void get_router_slot(Node *node, Port *spineport)
-{
- ChassisRecord *ch = node->chrecord;
- int guessnum = 0;
-
- if (!ch) {
- if (!(node->chrecord = calloc(1, sizeof(ChassisRecord))))
- IBPANIC("out of mem");
- ch = node->chrecord;
- }
-
- ch->chassisslot = SRBD_CS;
- if (is_spine_9096(spineport->node)) {
- ch->chassistype = ISR9096_CT;
- ch->slotnum = line_slot_2_sfb4[spineport->portnum];
- ch->anafanum = ipr_slot_2_sfb4_port[spineport->portnum];
- } else if (is_spine_9288(spineport->node)) {
- ch->chassistype = ISR9288_CT;
- ch->slotnum = line_slot_2_sfb12[spineport->portnum];
- /* this is a smart guess based on nodeguids order on sFB-12 module */
- guessnum = spineport->node->nodeguid % 4;
- /* module 1 <--> remote anafa 3 */
- /* module 2 <--> remote anafa 2 */
- /* module 3 <--> remote anafa 1 */
- ch->anafanum = (guessnum == 3 ? 1 : (guessnum == 1 ? 3 : 2));
- } else if (is_spine_2012(spineport->node)) {
- ch->chassistype = ISR2012_CT;
- ch->slotnum = line_slot_2_sfb12[spineport->portnum];
- /* this is a smart guess based on nodeguids order on sFB-12 module */
- guessnum = spineport->node->nodeguid % 4;
- // module 1 <--> remote anafa 3
- // module 2 <--> remote anafa 2
- // module 3 <--> remote anafa 1
- ch->anafanum = (guessnum == 3? 1 : (guessnum == 1 ? 3 : 2));
- } else if (is_spine_2004(spineport->node)) {
- ch->chassistype = ISR2004_CT;
- ch->slotnum = line_slot_2_sfb4[spineport->portnum];
- ch->anafanum = ipr_slot_2_sfb4_port[spineport->portnum];
- } else {
- IBPANIC("Unexpected node found: guid 0x%016" PRIx64, spineport->node->nodeguid);
- }
-}
-
-static void get_slb_slot(ChassisRecord *ch, Port *spineport)
-{
- ch->chassisslot = LINE_CS;
- if (is_spine_9096(spineport->node)) {
- ch->chassistype = ISR9096_CT;
- ch->slotnum = line_slot_2_sfb4[spineport->portnum];
- ch->anafanum = anafa_line_slot_2_sfb4[spineport->portnum];
- } else if (is_spine_9288(spineport->node)) {
- ch->chassistype = ISR9288_CT;
- ch->slotnum = line_slot_2_sfb12[spineport->portnum];
- ch->anafanum = anafa_line_slot_2_sfb12[spineport->portnum];
- } else if (is_spine_2012(spineport->node)) {
- ch->chassistype = ISR2012_CT;
- ch->slotnum = line_slot_2_sfb12[spineport->portnum];
- ch->anafanum = anafa_line_slot_2_sfb12[spineport->portnum];
- } else if (is_spine_2004(spineport->node)) {
- ch->chassistype = ISR2004_CT;
- ch->slotnum = line_slot_2_sfb4[spineport->portnum];
- ch->anafanum = anafa_line_slot_2_sfb4[spineport->portnum];
- } else {
- IBPANIC("Unexpected node found: guid 0x%016" PRIx64, spineport->node->nodeguid);
- }
-}
-
-/*
- This function called for every Voltaire node in fabric
- It could be optimized so, but time overhead is very small
- and its only diag.util
-*/
-static void fill_chassis_record(Node *node)
-{
- Port *port;
- Node *remnode = 0;
- ChassisRecord *ch = 0;
-
- if (node->chrecord) /* somehow this node has already been passed */
- return;
-
- if (!(node->chrecord = calloc(1, sizeof(ChassisRecord))))
- IBPANIC("out of mem");
-
- ch = node->chrecord;
-
- /* node is router only in case of using unique lid */
- /* (which is lid of chassis router port) */
- /* in such case node->ports is actually a requested port... */
- if (is_router(node) && is_spine(node->ports->remoteport->node))
- get_router_slot(node, node->ports->remoteport);
- else if (is_spine(node)) {
- for (port = node->ports; port; port = port->next) {
- if (!port->remoteport)
- continue;
- remnode = port->remoteport->node;
- if (remnode->type != SWITCH_NODE) {
- if (!remnode->chrecord)
- get_router_slot(remnode, port);
- continue;
- }
- if (!ch->chassistype)
- /* we assume here that remoteport belongs to line */
- get_sfb_slot(node, port->remoteport);
-
- /* we could break here, but need to find if more routers connected */
- }
-
- } else if (is_line(node)) {
- for (port = node->ports; port; port = port->next) {
- if (port->portnum > 12)
- continue;
- if (!port->remoteport)
- continue;
- /* we assume here that remoteport belongs to spine */
- get_slb_slot(ch, port->remoteport);
- break;
- }
- }
-
- return;
-}
-
-static int get_line_index(Node *node)
-{
- int retval = 3 * (node->chrecord->slotnum - 1) + node->chrecord->anafanum;
-
- if (retval > LINES_MAX_NUM || retval < 1)
- IBPANIC("Internal error");
- return retval;
-}
-
-static int get_spine_index(Node *node)
-{
- int retval;
-
- if (is_spine_9288(node) || is_spine_2012(node))
- retval = 3 * (node->chrecord->slotnum - 1) + node->chrecord->anafanum;
- else
- retval = node->chrecord->slotnum;
-
- if (retval > SPINES_MAX_NUM || retval < 1)
- IBPANIC("Internal error");
- return retval;
-}
-
-static void insert_line_router(Node *node, ChassisList *chassislist)
-{
- int i = get_line_index(node);
-
- if (chassislist->linenode[i])
- return; /* already filled slot */
-
- chassislist->linenode[i] = node;
- node->chrecord->chassisnum = chassislist->chassisnum;
-}
-
-static void insert_spine(Node *node, ChassisList *chassislist)
-{
- int i = get_spine_index(node);
-
- if (chassislist->spinenode[i])
- return; /* already filled slot */
-
- chassislist->spinenode[i] = node;
- node->chrecord->chassisnum = chassislist->chassisnum;
-}
-
-static void pass_on_lines_catch_spines(ChassisList *chassislist)
-{
- Node *node, *remnode;
- Port *port;
- int i;
-
- for (i = 1; i <= LINES_MAX_NUM; i++) {
- node = chassislist->linenode[i];
-
- if (!(node && is_line(node)))
- continue; /* empty slot or router */
-
- for (port = node->ports; port; port = port->next) {
- if (port->portnum > 12)
- continue;
-
- if (!port->remoteport)
- continue;
- remnode = port->remoteport->node;
-
- if (!remnode->chrecord)
- continue; /* some error - spine not initialized ? FIXME */
- insert_spine(remnode, chassislist);
- }
- }
-}
-
-static void pass_on_spines_catch_lines(ChassisList *chassislist)
-{
- Node *node, *remnode;
- Port *port;
- int i;
-
- for (i = 1; i <= SPINES_MAX_NUM; i++) {
- node = chassislist->spinenode[i];
- if (!node)
- continue; /* empty slot */
- for (port = node->ports; port; port = port->next) {
- if (!port->remoteport)
- continue;
- remnode = port->remoteport->node;
-
- if (!remnode->chrecord)
- continue; /* some error - line/router not initialized ? FIXME */
- insert_line_router(remnode, chassislist);
- }
- }
-}
-
-/*
- Stupid interpolation algorithm...
- But nothing to do - have to be compliant with VoltaireSM/NMS
-*/
-static void pass_on_spines_interpolate_chguid(ChassisList *chassislist)
-{
- Node *node;
- int i;
-
- for (i = 1; i <= SPINES_MAX_NUM; i++) {
- node = chassislist->spinenode[i];
- if (!node)
- continue; /* skip the empty slots */
-
- /* take first guid minus one to be consistent with SM */
- chassislist->chassisguid = node->nodeguid - 1;
- break;
- }
-}
-
-/*
- This function fills chassislist structure with all nodes
- in that chassis
- chassislist structure = structure of one standalone chassis
-*/
-static void build_chassis(Node *node, ChassisList *chassislist)
-{
- Node *remnode = 0;
- Port *port = 0;
-
- /* we get here with node = chassis_spine */
- chassislist->chassistype = node->chrecord->chassistype;
- insert_spine(node, chassislist);
-
- /* loop: pass on all ports of node */
- for (port = node->ports; port; port = port->next) {
- if (!port->remoteport)
- continue;
- remnode = port->remoteport->node;
-
- if (!remnode->chrecord)
- continue; /* some error - line or router not initialized ? FIXME */
-
- insert_line_router(remnode, chassislist);
- }
-
- pass_on_lines_catch_spines(chassislist);
- /* this pass needed for to catch routers, since routers connected only */
- /* to spines in slot 1 or 4 and we could miss them first time */
- pass_on_spines_catch_lines(chassislist);
-
- /* additional 2 passes needed for to overcome a problem of pure "in-chassis" */
- /* connectivity - extra pass to ensure that all related chips/modules */
- /* inserted into the chassislist */
- pass_on_lines_catch_spines(chassislist);
- pass_on_spines_catch_lines(chassislist);
- pass_on_spines_interpolate_chguid(chassislist);
-}
-
-/*========================================================*/
-/* INTERNAL TO EXTERNAL PORT MAPPING */
-/*========================================================*/
-
-/*
-Description : On ISR9288/9096 external ports indexing
- is not matching the internal ( anafa ) port
- indexes. Use this MAP to translate the data you get from
- the OpenIB diagnostics (smpquery, ibroute, ibtracert, etc.)
-
-
-Module : sLB-24
- anafa 1 anafa 2
-ext port | 13 14 15 16 17 18 | 19 20 21 22 23 24
-int port | 22 23 24 18 17 16 | 22 23 24 18 17 16
-ext port | 1 2 3 4 5 6 | 7 8 9 10 11 12
-int port | 19 20 21 15 14 13 | 19 20 21 15 14 13
-------------------------------------------------
-
-Module : sLB-8
- anafa 1 anafa 2
-ext port | 13 14 15 16 17 18 | 19 20 21 22 23 24
-int port | 24 23 22 18 17 16 | 24 23 22 18 17 16
-ext port | 1 2 3 4 5 6 | 7 8 9 10 11 12
-int port | 21 20 19 15 14 13 | 21 20 19 15 14 13
-
------------>
- anafa 1 anafa 2
-ext port | - - 5 - - 6 | - - 7 - - 8
-int port | 24 23 22 18 17 16 | 24 23 22 18 17 16
-ext port | - - 1 - - 2 | - - 3 - - 4
-int port | 21 20 19 15 14 13 | 21 20 19 15 14 13
-------------------------------------------------
-
-Module : sLB-2024
-
-ext port | 13 14 15 16 17 18 19 20 21 22 23 24
-A1 int port| 13 14 15 16 17 18 19 20 21 22 23 24
-ext port | 1 2 3 4 5 6 7 8 9 10 11 12
-A2 int port| 13 14 15 16 17 18 19 20 21 22 23 24
----------------------------------------------------
-
-*/
-
-int int2ext_map_slb24[2][25] = {
- { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6, 5, 4, 18, 17, 16, 1, 2, 3, 13, 14, 15 },
- { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 12, 11, 10, 24, 23, 22, 7, 8, 9, 19, 20, 21 }
- };
-int int2ext_map_slb8[2][25] = {
- { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 2, 2, 6, 6, 6, 1, 1, 1, 5, 5, 5 },
- { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 4, 4, 8, 8, 8, 3, 3, 3, 7, 7, 7 }
- };
-int int2ext_map_slb2024[2][25] = {
- { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24 },
- { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 }
- };
-/* reference { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24 }; */
-
-/*
- This function relevant only for line modules/chips
- Returns string with external port index
-*/
-char *portmapstring(Port *port)
-{
- static char mapping[OUT_BUFFER_SIZE];
- ChassisRecord *ch = port->node->chrecord;
- int portnum = port->portnum;
- int chipnum = 0;
- int pindex = 0;
- Node *node = port->node;
-
- if (!ch || !is_line(node) || (portnum < 13 || portnum > 24))
- return NULL;
-
- if (ch->anafanum < 1 || ch->anafanum > 2)
- return NULL;
-
- memset(mapping, 0, sizeof(mapping));
-
- chipnum = ch->anafanum - 1;
-
- if (is_line_24(node))
- pindex = int2ext_map_slb24[chipnum][portnum];
- else if (is_line_2024(node))
- pindex = int2ext_map_slb2024[chipnum][portnum];
- else
- pindex = int2ext_map_slb8[chipnum][portnum];
-
- sprintf(mapping, "[ext %d]", pindex);
-
- return mapping;
-}
-
-static void add_chassislist()
-{
- if (!(mylist.current = calloc(1, sizeof(ChassisList))))
- IBPANIC("out of mem");
-
- if (mylist.first == NULL) {
- mylist.first = mylist.current;
- mylist.last = mylist.current;
- } else {
- mylist.last->next = mylist.current;
- mylist.current->next = NULL;
- mylist.last = mylist.current;
- }
-}
-
-/*
- Main grouping function
- Algorithm:
- 1. pass on every Voltaire node
- 2. catch spine chip for every Voltaire node
- 2.1 build/interpolate chassis around this chip
- 2.2 go to 1.
- 3. pass on non Voltaire nodes (SystemImageGUID based grouping)
- 4. now group non Voltaire nodes by SystemImageGUID
-*/
-ChassisList *group_nodes()
-{
- Node *node;
- int dist;
- int chassisnum = 0;
- struct ChassisList *chassis;
-
- mylist.first = NULL;
- mylist.current = NULL;
- mylist.last = NULL;
-
- /* first pass on switches and build for every Voltaire node */
- /* an appropriate chassis record (slotnum and position) */
- /* according to internal connectivity */
- /* not very efficient but clear code so... */
- for (dist = 0; dist <= maxhops_discovered; dist++) {
- for (node = nodesdist[dist]; node; node = node->dnext) {
- if (node->vendid == VTR_VENDOR_ID)
- fill_chassis_record(node);
- }
- }
-
- /* separate every Voltaire chassis from each other and build linked list of them */
- /* algorithm: catch spine and find all surrounding nodes */
- for (dist = 0; dist <= maxhops_discovered; dist++) {
- for (node = nodesdist[dist]; node; node = node->dnext) {
- if (node->vendid != VTR_VENDOR_ID)
- continue;
- if (!node->chrecord || node->chrecord->chassisnum || !is_spine(node))
- continue;
- add_chassislist();
- mylist.current->chassisnum = ++chassisnum;
- build_chassis(node, mylist.current);
- }
- }
-
- /* now make pass on nodes for chassis which are not Voltaire */
- /* grouped by common SystemImageGUID */
- for (dist = 0; dist <= maxhops_discovered; dist++) {
- for (node = nodesdist[dist]; node; node = node->dnext) {
- if (node->vendid == VTR_VENDOR_ID)
- continue;
- if (node->sysimgguid) {
- chassis = find_chassisguid(node);
- if (chassis)
- chassis->nodecount++;
- else {
- /* Possible new chassis */
- add_chassislist();
- mylist.current->chassisguid = get_chassisguid(node);
- mylist.current->nodecount = 1;
- }
- }
- }
- }
-
- /* now, make another pass to see which nodes are part of chassis */
- /* (defined as chassis->nodecount > 1) */
- for (dist = 0; dist <= MAXHOPS; ) {
- for (node = nodesdist[dist]; node; node = node->dnext) {
- if (node->vendid == VTR_VENDOR_ID)
- continue;
- if (node->sysimgguid) {
- chassis = find_chassisguid(node);
- if (chassis && chassis->nodecount > 1) {
- if (!chassis->chassisnum)
- chassis->chassisnum = ++chassisnum;
- if (!node->chrecord) {
- if (!(node->chrecord = calloc(1, sizeof(ChassisRecord))))
- IBPANIC("out of mem");
- node->chrecord->chassisnum = chassis->chassisnum;
- }
- }
- }
- }
- if (dist == maxhops_discovered)
- dist = MAXHOPS; /* skip to CAs */
- else
- dist++;
- }
-
- return (mylist.first);
-}
diff --git a/contrib/ofed/management/infiniband-diags/src/ibaddr.c b/contrib/ofed/management/infiniband-diags/src/ibaddr.c
deleted file mode 100644
index 0e2f9ac..0000000
--- a/contrib/ofed/management/infiniband-diags/src/ibaddr.c
+++ /dev/null
@@ -1,217 +0,0 @@
-/*
- * Copyright (c) 2004-2008 Voltaire Inc. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- */
-
-#if HAVE_CONFIG_H
-# include <config.h>
-#endif /* HAVE_CONFIG_H */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <stdarg.h>
-#include <getopt.h>
-#include <arpa/inet.h>
-
-#include <infiniband/common.h>
-#include <infiniband/umad.h>
-#include <infiniband/mad.h>
-
-#include <sys/socket.h>
-
-#include "ibdiag_common.h"
-
-char *argv0 = "ibaddr";
-
-static int
-ib_resolve_addr(ib_portid_t *portid, int portnum, int show_lid, int show_gid)
-{
- char gid_str[INET6_ADDRSTRLEN];
- uint8_t portinfo[64];
- uint8_t nodeinfo[64];
- uint64_t guid, prefix;
- ibmad_gid_t gid;
- int lmc;
-
- if (!smp_query(nodeinfo, portid, IB_ATTR_NODE_INFO, 0, 0))
- return -1;
-
- if (!smp_query(portinfo, portid, IB_ATTR_PORT_INFO, portnum, 0))
- return -1;
-
- mad_decode_field(portinfo, IB_PORT_LID_F, &portid->lid);
- mad_decode_field(portinfo, IB_PORT_GID_PREFIX_F, &prefix);
- mad_decode_field(portinfo, IB_PORT_LMC_F, &lmc);
- mad_decode_field(nodeinfo, IB_NODE_PORT_GUID_F, &guid);
-
- mad_encode_field(gid, IB_GID_PREFIX_F, &prefix);
- mad_encode_field(gid, IB_GID_GUID_F, &guid);
-
- if (show_gid) {
- printf("GID %s ", inet_ntop(AF_INET6, gid, gid_str,
- sizeof gid_str));
- }
-
- if (show_lid > 0)
- printf("LID start 0x%x end 0x%x", portid->lid, portid->lid + (1 << lmc) - 1);
- else if (show_lid < 0)
- printf("LID start %d end %d", portid->lid, portid->lid + (1 << lmc) - 1);
- printf("\n");
- return 0;
-}
-
-static void
-usage(void)
-{
- char *basename;
-
- if (!(basename = strrchr(argv0, '/')))
- basename = argv0;
- else
- basename++;
-
- fprintf(stderr, "Usage: %s [-d(ebug) -D(irect) -G(uid) -l(id_show) -g(id_show) -s(m_port) sm_lid -C ca_name -P ca_port "
- "-t(imeout) timeout_ms -V(ersion) -h(elp)] [<lid|dr_path|guid>]\n",
- basename);
- fprintf(stderr, "\tExamples:\n");
- fprintf(stderr, "\t\t%s\t\t\t# local port's address\n", basename);
- fprintf(stderr, "\t\t%s 32\t\t# show lid range and gid of lid 32\n", basename);
- fprintf(stderr, "\t\t%s -G 0x8f1040023\t# same but using guid address\n", basename);
- fprintf(stderr, "\t\t%s -l 32\t\t# show lid range only\n", basename);
- fprintf(stderr, "\t\t%s -L 32\t\t# show decimal lid range only\n", basename);
- fprintf(stderr, "\t\t%s -g 32\t\t# show gid address only\n", basename);
- exit(-1);
-}
-
-int
-main(int argc, char **argv)
-{
- int mgmt_classes[3] = {IB_SMI_CLASS, IB_SMI_DIRECT_CLASS, IB_SA_CLASS};
- ib_portid_t *sm_id = 0, sm_portid = {0};
- ib_portid_t portid = {0};
- extern int ibdebug;
- int dest_type = IB_DEST_LID;
- int timeout = 0; /* use default */
- int show_lid = 0, show_gid = 0;
- int port = 0;
- char *ca = 0;
- int ca_port = 0;
-
- static char const str_opts[] = "C:P:t:s:dDGglLVhu";
- static const struct option long_opts[] = {
- { "C", 1, 0, 'C'},
- { "P", 1, 0, 'P'},
- { "debug", 0, 0, 'd'},
- { "Direct", 0, 0, 'D'},
- { "Guid", 0, 0, 'G'},
- { "gid_show", 0, 0, 'g'},
- { "lid_show", 0, 0, 'l'},
- { "Lid_show", 0, 0, 'L'},
- { "timeout", 1, 0, 't'},
- { "sm_port", 1, 0, 's'},
- { "Version", 0, 0, 'V'},
- { "help", 0, 0, 'h'},
- { "usage", 0, 0, 'u'},
- { }
- };
-
- argv0 = argv[0];
-
- while (1) {
- int ch = getopt_long(argc, argv, str_opts, long_opts, NULL);
- if ( ch == -1 )
- break;
- switch(ch) {
- case 'C':
- ca = optarg;
- break;
- case 'P':
- ca_port = strtoul(optarg, 0, 0);
- break;
- case 'd':
- ibdebug++;
- break;
- case 'D':
- dest_type = IB_DEST_DRPATH;
- break;
- case 'g':
- show_gid++;
- break;
- case 'G':
- dest_type = IB_DEST_GUID;
- break;
- case 'l':
- show_lid++;
- break;
- case 'L':
- show_lid = -100;
- break;
- case 's':
- if (ib_resolve_portid_str(&sm_portid, optarg, IB_DEST_LID, 0) < 0)
- IBERROR("can't resolve SM destination port %s", optarg);
- sm_id = &sm_portid;
- break;
- case 't':
- timeout = strtoul(optarg, 0, 0);
- madrpc_set_timeout(timeout);
- break;
- case 'V':
- fprintf(stderr, "%s %s\n", argv0, get_build_version() );
- exit(-1);
- default:
- usage();
- break;
- }
- }
- argc -= optind;
- argv += optind;
-
- if (argc > 1)
- port = strtoul(argv[1], 0, 0);
-
- if (!show_lid && !show_gid)
- show_lid = show_gid = 1;
-
- madrpc_init(ca, ca_port, mgmt_classes, 3);
-
- if (argc) {
- if (ib_resolve_portid_str(&portid, argv[0], dest_type, sm_id) < 0)
- IBERROR("can't resolve destination port %s", argv[0]);
- } else {
- if (ib_resolve_self(&portid, &port, 0) < 0)
- IBERROR("can't resolve self port %s", argv[0]);
- }
-
- if (ib_resolve_addr(&portid, port, show_lid, show_gid) < 0)
- IBERROR("can't resolve requested address");
- exit(0);
-}
diff --git a/contrib/ofed/management/infiniband-diags/src/ibdiag_common.c b/contrib/ofed/management/infiniband-diags/src/ibdiag_common.c
deleted file mode 100644
index 90e2cec..0000000
--- a/contrib/ofed/management/infiniband-diags/src/ibdiag_common.c
+++ /dev/null
@@ -1,78 +0,0 @@
-/*
- * Copyright (c) 2006-2007 The Regents of the University of California.
- * Copyright (c) 2004-2006 Voltaire, Inc. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- */
-
-/**
- * Define common functions which can be included in the various C based diags.
- */
-
-#define _GNU_SOURCE
-#include <stdio.h>
-#include <errno.h>
-#include <string.h>
-#include <stdlib.h>
-#include <stdarg.h>
-#include <sys/types.h>
-#include <unistd.h>
-#include <ctype.h>
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include "ibdiag_common.h"
-
-int ibdebug;
-
-void
-iberror(const char *fn, char *msg, ...)
-{
- char buf[512], *s;
- va_list va;
- int n;
-
- va_start(va, msg);
- n = vsprintf(buf, msg, va);
- va_end(va);
- buf[n] = 0;
-
- if ((s = strrchr(argv0, '/')))
- argv0 = s + 1;
-
- if (ibdebug)
- printf("%s: iberror: [pid %d] %s: failed: %s\n", argv0, getpid(), fn, buf);
- else
- printf("%s: iberror: failed: %s\n", argv0, buf);
-
- exit(-1);
-}
-
diff --git a/contrib/ofed/management/infiniband-diags/src/ibnetdiscover.c b/contrib/ofed/management/infiniband-diags/src/ibnetdiscover.c
deleted file mode 100644
index a79aa3e..0000000
--- a/contrib/ofed/management/infiniband-diags/src/ibnetdiscover.c
+++ /dev/null
@@ -1,1051 +0,0 @@
-/*
- * Copyright (c) 2004-2008 Voltaire Inc. All rights reserved.
- * Copyright (c) 2007 Xsigo Systems Inc. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- */
-
-#if HAVE_CONFIG_H
-# include <config.h>
-#endif /* HAVE_CONFIG_H */
-
-#define _GNU_SOURCE
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <stdarg.h>
-#include <time.h>
-#include <string.h>
-#include <getopt.h>
-#include <errno.h>
-#include <inttypes.h>
-
-#include <infiniband/common.h>
-#include <infiniband/umad.h>
-#include <infiniband/mad.h>
-#include <complib/cl_nodenamemap.h>
-
-#include "ibnetdiscover.h"
-#include "grouping.h"
-#include "ibdiag_common.h"
-
-static char *node_type_str[] = {
- "???",
- "ca",
- "switch",
- "router",
- "iwarp rnic"
-};
-
-static char *linkwidth_str[] = {
- "??",
- "1x",
- "4x",
- "??",
- "8x",
- "??",
- "??",
- "??",
- "12x"
-};
-
-static char *linkspeed_str[] = {
- "???",
- "SDR",
- "DDR",
- "???",
- "QDR"
-};
-
-static int timeout = 2000; /* ms */
-static int dumplevel = 0;
-static int verbose;
-static FILE *f;
-
-char *argv0 = "ibnetdiscover";
-
-static char *node_name_map_file = NULL;
-static nn_map_t *node_name_map = NULL;
-
-Node *nodesdist[MAXHOPS+1]; /* last is Ca list */
-Node *mynode;
-int maxhops_discovered = 0;
-
-struct ChassisList *chassis = NULL;
-
-static char *
-get_linkwidth_str(int linkwidth)
-{
- if (linkwidth > 8)
- return linkwidth_str[0];
- else
- return linkwidth_str[linkwidth];
-}
-
-static char *
-get_linkspeed_str(int linkspeed)
-{
- if (linkspeed > 4)
- return linkspeed_str[0];
- else
- return linkspeed_str[linkspeed];
-}
-
-static inline const char*
-node_type_str2(Node *node)
-{
- switch(node->type) {
- case SWITCH_NODE: return "SW";
- case CA_NODE: return "CA";
- case ROUTER_NODE: return "RT";
- }
- return "??";
-}
-
-void
-decode_port_info(void *pi, Port *port)
-{
- mad_decode_field(pi, IB_PORT_LID_F, &port->lid);
- mad_decode_field(pi, IB_PORT_LMC_F, &port->lmc);
- mad_decode_field(pi, IB_PORT_STATE_F, &port->state);
- mad_decode_field(pi, IB_PORT_PHYS_STATE_F, &port->physstate);
- mad_decode_field(pi, IB_PORT_LINK_WIDTH_ACTIVE_F, &port->linkwidth);
- mad_decode_field(pi, IB_PORT_LINK_SPEED_ACTIVE_F, &port->linkspeed);
-}
-
-
-int
-get_port(Port *port, int portnum, ib_portid_t *portid)
-{
- char portinfo[64];
- void *pi = portinfo;
-
- port->portnum = portnum;
-
- if (!smp_query(pi, portid, IB_ATTR_PORT_INFO, portnum, timeout))
- return -1;
- decode_port_info(pi, port);
-
- DEBUG("portid %s portnum %d: lid %d state %d physstate %d %s %s",
- portid2str(portid), portnum, port->lid, port->state, port->physstate, get_linkwidth_str(port->linkwidth), get_linkspeed_str(port->linkspeed));
- return 1;
-}
-/*
- * Returns 0 if non switch node is found, 1 if switch is found, -1 if error.
- */
-int
-get_node(Node *node, Port *port, ib_portid_t *portid)
-{
- char portinfo[64];
- char switchinfo[64];
- void *pi = portinfo, *ni = node->nodeinfo, *nd = node->nodedesc;
- void *si = switchinfo;
-
- if (!smp_query(ni, portid, IB_ATTR_NODE_INFO, 0, timeout))
- return -1;
-
- mad_decode_field(ni, IB_NODE_GUID_F, &node->nodeguid);
- mad_decode_field(ni, IB_NODE_TYPE_F, &node->type);
- mad_decode_field(ni, IB_NODE_NPORTS_F, &node->numports);
- mad_decode_field(ni, IB_NODE_DEVID_F, &node->devid);
- mad_decode_field(ni, IB_NODE_VENDORID_F, &node->vendid);
- mad_decode_field(ni, IB_NODE_SYSTEM_GUID_F, &node->sysimgguid);
- mad_decode_field(ni, IB_NODE_PORT_GUID_F, &node->portguid);
- mad_decode_field(ni, IB_NODE_LOCAL_PORT_F, &node->localport);
- port->portnum = node->localport;
- port->portguid = node->portguid;
-
- if (!smp_query(nd, portid, IB_ATTR_NODE_DESC, 0, timeout))
- return -1;
-
- if (!smp_query(pi, portid, IB_ATTR_PORT_INFO, 0, timeout))
- return -1;
- decode_port_info(pi, port);
-
- if (node->type != SWITCH_NODE)
- return 0;
-
- node->smalid = port->lid;
- node->smalmc = port->lmc;
-
- /* after we have the sma information find out the real PortInfo for this port */
- if (!smp_query(pi, portid, IB_ATTR_PORT_INFO, node->localport, timeout))
- return -1;
- decode_port_info(pi, port);
-
- if (!smp_query(si, portid, IB_ATTR_SWITCH_INFO, 0, timeout))
- node->smaenhsp0 = 0; /* assume base SP0 */
- else
- mad_decode_field(si, IB_SW_ENHANCED_PORT0_F, &node->smaenhsp0);
-
- DEBUG("portid %s: got switch node %" PRIx64 " '%s'",
- portid2str(portid), node->nodeguid, node->nodedesc);
- return 1;
-}
-
-static int
-extend_dpath(ib_dr_path_t *path, int nextport)
-{
- if (path->cnt+2 >= sizeof(path->p))
- return -1;
- ++path->cnt;
- if (path->cnt > maxhops_discovered)
- maxhops_discovered = path->cnt;
- path->p[path->cnt] = nextport;
- return path->cnt;
-}
-
-static void
-dump_endnode(ib_portid_t *path, char *prompt, Node *node, Port *port)
-{
- if (!dumplevel)
- return;
-
- fprintf(f, "%s -> %s %s {%016" PRIx64 "} portnum %d lid %d-%d\"%s\"\n",
- portid2str(path), prompt,
- (node->type <= IB_NODE_MAX ? node_type_str[node->type] : "???"),
- node->nodeguid, node->type == SWITCH_NODE ? 0 : port->portnum,
- port->lid, port->lid + (1 << port->lmc) - 1,
- clean_nodedesc(node->nodedesc));
-}
-
-#define HASHGUID(guid) ((uint32_t)(((uint32_t)(guid) * 101) ^ ((uint32_t)((guid) >> 32) * 103)))
-#define HTSZ 137
-
-static Node *nodestbl[HTSZ];
-
-static Node *
-find_node(Node *new)
-{
- int hash = HASHGUID(new->nodeguid) % HTSZ;
- Node *node;
-
- for (node = nodestbl[hash]; node; node = node->htnext)
- if (node->nodeguid == new->nodeguid)
- return node;
-
- return NULL;
-}
-
-static Node *
-create_node(Node *temp, ib_portid_t *path, int dist)
-{
- Node *node;
- int hash = HASHGUID(temp->nodeguid) % HTSZ;
-
- node = malloc(sizeof(*node));
- if (!node)
- return NULL;
-
- memcpy(node, temp, sizeof(*node));
- node->dist = dist;
- node->path = *path;
-
- node->htnext = nodestbl[hash];
- nodestbl[hash] = node;
-
- if (node->type != SWITCH_NODE)
- dist = MAXHOPS; /* special Ca list */
-
- node->dnext = nodesdist[dist];
- nodesdist[dist] = node;
-
- return node;
-}
-
-static Port *
-find_port(Node *node, Port *port)
-{
- Port *old;
-
- for (old = node->ports; old; old = old->next)
- if (old->portnum == port->portnum)
- return old;
-
- return NULL;
-}
-
-static Port *
-create_port(Node *node, Port *temp)
-{
- Port *port;
-
- port = malloc(sizeof(*port));
- if (!port)
- return NULL;
-
- memcpy(port, temp, sizeof(*port));
- port->node = node;
- port->next = node->ports;
- node->ports = port;
-
- return port;
-}
-
-static void
-link_ports(Node *node, Port *port, Node *remotenode, Port *remoteport)
-{
- DEBUG("linking: 0x%" PRIx64 " %p->%p:%u and 0x%" PRIx64 " %p->%p:%u",
- node->nodeguid, node, port, port->portnum,
- remotenode->nodeguid, remotenode, remoteport, remoteport->portnum);
- if (port->remoteport)
- port->remoteport->remoteport = NULL;
- if (remoteport->remoteport)
- remoteport->remoteport->remoteport = NULL;
- port->remoteport = remoteport;
- remoteport->remoteport = port;
-}
-
-static int
-handle_port(Node *node, Port *port, ib_portid_t *path, int portnum, int dist)
-{
- Node node_buf;
- Port port_buf;
- Node *remotenode, *oldnode;
- Port *remoteport, *oldport;
-
- memset(&node_buf, 0, sizeof(node_buf));
- memset(&port_buf, 0, sizeof(port_buf));
-
- DEBUG("handle node %p port %p:%d dist %d", node, port, portnum, dist);
- if (port->physstate != 5) /* LinkUp */
- return -1;
-
- if (extend_dpath(&path->drpath, portnum) < 0)
- return -1;
-
- if (get_node(&node_buf, &port_buf, path) < 0) {
- IBWARN("NodeInfo on %s failed, skipping port",
- portid2str(path));
- path->drpath.cnt--; /* restore path */
- return -1;
- }
-
- oldnode = find_node(&node_buf);
- if (oldnode)
- remotenode = oldnode;
- else if (!(remotenode = create_node(&node_buf, path, dist + 1)))
- IBERROR("no memory");
-
- oldport = find_port(remotenode, &port_buf);
- if (oldport) {
- remoteport = oldport;
- if (node != remotenode || port != remoteport)
- IBWARN("port moving...");
- } else if (!(remoteport = create_port(remotenode, &port_buf)))
- IBERROR("no memory");
-
- dump_endnode(path, oldnode ? "known remote" : "new remote",
- remotenode, remoteport);
-
- link_ports(node, port, remotenode, remoteport);
-
- path->drpath.cnt--; /* restore path */
- return 0;
-}
-
-/*
- * Return 1 if found, 0 if not, -1 on errors.
- */
-static int
-discover(ib_portid_t *from)
-{
- Node node_buf;
- Port port_buf;
- Node *node;
- Port *port;
- int i;
- int dist = 0;
- ib_portid_t *path;
-
- DEBUG("from %s", portid2str(from));
-
- memset(&node_buf, 0, sizeof(node_buf));
- memset(&port_buf, 0, sizeof(port_buf));
-
- if (get_node(&node_buf, &port_buf, from) < 0) {
- IBWARN("can't reach node %s", portid2str(from));
- return -1;
- }
-
- node = create_node(&node_buf, from, 0);
- if (!node)
- IBERROR("out of memory");
-
- mynode = node;
-
- port = create_port(node, &port_buf);
- if (!port)
- IBERROR("out of memory");
-
- if (node->type != SWITCH_NODE &&
- handle_port(node, port, from, node->localport, 0) < 0)
- return 0;
-
- for (dist = 0; dist < MAXHOPS; dist++) {
-
- for (node = nodesdist[dist]; node; node = node->dnext) {
-
- path = &node->path;
-
- DEBUG("dist %d node %p", dist, node);
- dump_endnode(path, "processing", node, port);
-
- for (i = 1; i <= node->numports; i++) {
- if (i == node->localport)
- continue;
-
- if (get_port(&port_buf, i, path) < 0) {
- IBWARN("can't reach node %s port %d", portid2str(path), i);
- continue;
- }
-
- port = find_port(node, &port_buf);
- if (port)
- continue;
-
- port = create_port(node, &port_buf);
- if (!port)
- IBERROR("out of memory");
-
- /* If switch, set port GUID to node GUID */
- if (node->type == SWITCH_NODE)
- port->portguid = node->portguid;
-
- handle_port(node, port, path, i, dist);
- }
- }
- }
-
- return 0;
-}
-
-char *
-node_name(Node *node)
-{
- static char buf[256];
-
- switch(node->type) {
- case SWITCH_NODE:
- sprintf(buf, "\"%s", "S");
- break;
- case CA_NODE:
- sprintf(buf, "\"%s", "H");
- break;
- case ROUTER_NODE:
- sprintf(buf, "\"%s", "R");
- break;
- default:
- sprintf(buf, "\"%s", "?");
- break;
- }
- sprintf(buf+2, "-%016" PRIx64 "\"", node->nodeguid);
-
- return buf;
-}
-
-void
-list_node(Node *node)
-{
- char *node_type;
- char *nodename = remap_node_name(node_name_map, node->nodeguid,
- node->nodedesc);
-
- switch(node->type) {
- case SWITCH_NODE:
- node_type = "Switch";
- break;
- case CA_NODE:
- node_type = "Ca";
- break;
- case ROUTER_NODE:
- node_type = "Router";
- break;
- default:
- node_type = "???";
- break;
- }
- fprintf(f, "%s\t : 0x%016" PRIx64 " ports %d devid 0x%x vendid 0x%x \"%s\"\n",
- node_type,
- node->nodeguid, node->numports, node->devid, node->vendid,
- nodename);
-
- free(nodename);
-}
-
-void
-out_ids(Node *node, int group, char *chname)
-{
- fprintf(f, "\nvendid=0x%x\ndevid=0x%x\n", node->vendid, node->devid);
- if (node->sysimgguid)
- fprintf(f, "sysimgguid=0x%" PRIx64, node->sysimgguid);
- if (group
- && node->chrecord && node->chrecord->chassisnum) {
- fprintf(f, "\t\t# Chassis %d", node->chrecord->chassisnum);
- if (chname)
- fprintf(f, " (%s)", chname);
- if (is_xsigo_tca(node->nodeguid) && node->ports->remoteport)
- fprintf(f, " slot %d", node->ports->remoteport->portnum);
- }
- fprintf(f, "\n");
-}
-
-uint64_t
-out_chassis(int chassisnum)
-{
- uint64_t guid;
-
- fprintf(f, "\nChassis %d", chassisnum);
- guid = get_chassis_guid(chassisnum);
- if (guid)
- fprintf(f, " (guid 0x%" PRIx64 ")", guid);
- fprintf(f, "\n");
- return guid;
-}
-
-void
-out_switch(Node *node, int group, char *chname)
-{
- char *str;
- char *nodename = NULL;
-
- out_ids(node, group, chname);
- fprintf(f, "switchguid=0x%" PRIx64, node->nodeguid);
- fprintf(f, "(%" PRIx64 ")", node->portguid);
- /* Currently, only if Voltaire chassis */
- if (group
- && node->chrecord && node->chrecord->chassisnum
- && node->vendid == VTR_VENDOR_ID) {
- str = get_chassis_type(node->chrecord->chassistype);
- if (str)
- fprintf(f, "%s ", str);
- str = get_chassis_slot(node->chrecord->chassisslot);
- if (str)
- fprintf(f, "%s ", str);
- fprintf(f, "%d Chip %d", node->chrecord->slotnum, node->chrecord->anafanum);
- }
-
- nodename = remap_node_name(node_name_map, node->nodeguid,
- node->nodedesc);
-
- fprintf(f, "\nSwitch\t%d %s\t\t# \"%s\" %s port 0 lid %d lmc %d\n",
- node->numports, node_name(node),
- nodename,
- node->smaenhsp0 ? "enhanced" : "base",
- node->smalid, node->smalmc);
-
- free(nodename);
-}
-
-void
-out_ca(Node *node, int group, char *chname)
-{
- char *node_type;
- char *node_type2;
- char *nodename = remap_node_name(node_name_map, node->nodeguid,
- node->nodedesc);
-
- out_ids(node, group, chname);
- switch(node->type) {
- case CA_NODE:
- node_type = "ca";
- node_type2 = "Ca";
- break;
- case ROUTER_NODE:
- node_type = "rt";
- node_type2 = "Rt";
- break;
- default:
- node_type = "???";
- node_type2 = "???";
- break;
- }
-
- fprintf(f, "%sguid=0x%" PRIx64 "\n", node_type, node->nodeguid);
- fprintf(f, "%s\t%d %s\t\t# \"%s\"",
- node_type2, node->numports, node_name(node),
- nodename);
- if (group && is_xsigo_hca(node->nodeguid))
- fprintf(f, " (scp)");
- fprintf(f, "\n");
-
- free(nodename);
-}
-
-static char *
-out_ext_port(Port *port, int group)
-{
- char *str = NULL;
-
- /* Currently, only if Voltaire chassis */
- if (group
- && port->node->chrecord && port->node->vendid == VTR_VENDOR_ID)
- str = portmapstring(port);
-
- return (str);
-}
-
-void
-out_switch_port(Port *port, int group)
-{
- char *ext_port_str = NULL;
- char *rem_nodename = NULL;
-
- DEBUG("port %p:%d remoteport %p", port, port->portnum, port->remoteport);
- fprintf(f, "[%d]", port->portnum);
-
- ext_port_str = out_ext_port(port, group);
- if (ext_port_str)
- fprintf(f, "%s", ext_port_str);
-
- rem_nodename = remap_node_name(node_name_map,
- port->remoteport->node->nodeguid,
- port->remoteport->node->nodedesc);
-
- ext_port_str = out_ext_port(port->remoteport, group);
- fprintf(f, "\t%s[%d]%s",
- node_name(port->remoteport->node),
- port->remoteport->portnum,
- ext_port_str ? ext_port_str : "");
- if (port->remoteport->node->type != SWITCH_NODE)
- fprintf(f, "(%" PRIx64 ") ", port->remoteport->portguid);
- fprintf(f, "\t\t# \"%s\" lid %d %s%s",
- rem_nodename,
- port->remoteport->node->type == SWITCH_NODE ? port->remoteport->node->smalid : port->remoteport->lid,
- get_linkwidth_str(port->linkwidth),
- get_linkspeed_str(port->linkspeed));
-
- if (is_xsigo_tca(port->remoteport->portguid))
- fprintf(f, " slot %d", port->portnum);
- else if (is_xsigo_hca(port->remoteport->portguid))
- fprintf(f, " (scp)");
- fprintf(f, "\n");
-
- free(rem_nodename);
-}
-
-void
-out_ca_port(Port *port, int group)
-{
- char *str = NULL;
- char *rem_nodename = NULL;
-
- fprintf(f, "[%d]", port->portnum);
- if (port->node->type != SWITCH_NODE)
- fprintf(f, "(%" PRIx64 ") ", port->portguid);
- fprintf(f, "\t%s[%d]",
- node_name(port->remoteport->node),
- port->remoteport->portnum);
- str = out_ext_port(port->remoteport, group);
- if (str)
- fprintf(f, "%s", str);
- if (port->remoteport->node->type != SWITCH_NODE)
- fprintf(f, " (%" PRIx64 ") ", port->remoteport->portguid);
-
- rem_nodename = remap_node_name(node_name_map,
- port->remoteport->node->nodeguid,
- port->remoteport->node->nodedesc);
-
- fprintf(f, "\t\t# lid %d lmc %d \"%s\" lid %d %s%s\n",
- port->lid, port->lmc, rem_nodename,
- port->remoteport->node->type == SWITCH_NODE ? port->remoteport->node->smalid : port->remoteport->lid,
- get_linkwidth_str(port->linkwidth),
- get_linkspeed_str(port->linkspeed));
-
- free(rem_nodename);
-}
-
-int
-dump_topology(int listtype, int group)
-{
- Node *node;
- Port *port;
- int i = 0, dist = 0;
- time_t t = time(0);
- uint64_t chguid;
- char *chname = NULL;
-
- if (!listtype) {
- fprintf(f, "#\n# Topology file: generated on %s#\n", ctime(&t));
- fprintf(f, "# Max of %d hops discovered\n", maxhops_discovered);
- fprintf(f, "# Initiated from node %016" PRIx64 " port %016" PRIx64 "\n", mynode->nodeguid, mynode->portguid);
- }
-
- /* Make pass on switches */
- if (group && !listtype) {
- ChassisList *ch = NULL;
-
- /* Chassis based switches first */
- for (ch = chassis; ch; ch = ch->next) {
- int n = 0;
-
- if (!ch->chassisnum)
- continue;
- chguid = out_chassis(ch->chassisnum);
- if (chname)
- free(chname);
- chname = NULL;
- if (is_xsigo_guid(chguid)) {
- for (node = nodesdist[MAXHOPS]; node; node = node->dnext) {
- if (!node->chrecord ||
- !node->chrecord->chassisnum)
- continue;
-
- if (node->chrecord->chassisnum != ch->chassisnum)
- continue;
-
- if (is_xsigo_hca(node->nodeguid)) {
- chname = remap_node_name(node_name_map,
- node->nodeguid,
- node->nodedesc);
- fprintf(f, "Hostname: %s\n", chname);
- }
- }
- }
-
- fprintf(f, "\n# Spine Nodes");
- for (n = 1; n <= (SPINES_MAX_NUM); n++) {
- if (ch->spinenode[n]) {
- out_switch(ch->spinenode[n], group, chname);
- for (port = ch->spinenode[n]->ports; port; port = port->next, i++)
- if (port->remoteport)
- out_switch_port(port, group);
- }
- }
- fprintf(f, "\n# Line Nodes");
- for (n = 1; n <= (LINES_MAX_NUM); n++) {
- if (ch->linenode[n]) {
- out_switch(ch->linenode[n], group, chname);
- for (port = ch->linenode[n]->ports; port; port = port->next, i++)
- if (port->remoteport)
- out_switch_port(port, group);
- }
- }
-
- fprintf(f, "\n# Chassis Switches");
- for (dist = 0; dist <= maxhops_discovered; dist++) {
-
- for (node = nodesdist[dist]; node; node = node->dnext) {
-
- /* Non Voltaire chassis */
- if (node->vendid == VTR_VENDOR_ID)
- continue;
- if (!node->chrecord ||
- !node->chrecord->chassisnum)
- continue;
-
- if (node->chrecord->chassisnum != ch->chassisnum)
- continue;
-
- out_switch(node, group, chname);
- for (port = node->ports; port; port = port->next, i++)
- if (port->remoteport)
- out_switch_port(port, group);
-
- }
-
- }
-
- fprintf(f, "\n# Chassis CAs");
- for (node = nodesdist[MAXHOPS]; node; node = node->dnext) {
- if (!node->chrecord ||
- !node->chrecord->chassisnum)
- continue;
-
- if (node->chrecord->chassisnum != ch->chassisnum)
- continue;
-
- out_ca(node, group, chname);
- for (port = node->ports; port; port = port->next, i++)
- if (port->remoteport)
- out_ca_port(port, group);
-
- }
-
- }
-
- } else {
- for (dist = 0; dist <= maxhops_discovered; dist++) {
-
- for (node = nodesdist[dist]; node; node = node->dnext) {
-
- DEBUG("SWITCH: dist %d node %p", dist, node);
- if (!listtype)
- out_switch(node, group, chname);
- else {
- if (listtype & LIST_SWITCH_NODE)
- list_node(node);
- continue;
- }
-
- for (port = node->ports; port; port = port->next, i++)
- if (port->remoteport)
- out_switch_port(port, group);
- }
- }
- }
-
- if (chname)
- free(chname);
- chname = NULL;
- if (group && !listtype) {
-
- fprintf(f, "\nNon-Chassis Nodes\n");
-
- for (dist = 0; dist <= maxhops_discovered; dist++) {
-
- for (node = nodesdist[dist]; node; node = node->dnext) {
-
- DEBUG("SWITCH: dist %d node %p", dist, node);
- /* Now, skip chassis based switches */
- if (node->chrecord &&
- node->chrecord->chassisnum)
- continue;
- out_switch(node, group, chname);
-
- for (port = node->ports; port; port = port->next, i++)
- if (port->remoteport)
- out_switch_port(port, group);
- }
-
- }
-
- }
-
- /* Make pass on CAs */
- for (node = nodesdist[MAXHOPS]; node; node = node->dnext) {
-
- DEBUG("CA: dist %d node %p", dist, node);
- if (!listtype) {
- /* Now, skip chassis based CAs */
- if (group && node->chrecord &&
- node->chrecord->chassisnum)
- continue;
- out_ca(node, group, chname);
- } else {
- if (((listtype & LIST_CA_NODE) && (node->type == CA_NODE)) ||
- ((listtype & LIST_ROUTER_NODE) && (node->type == ROUTER_NODE)))
- list_node(node);
- continue;
- }
-
- for (port = node->ports; port; port = port->next, i++)
- if (port->remoteport)
- out_ca_port(port, group);
- }
-
- if (chname)
- free(chname);
-
- return i;
-}
-
-void dump_ports_report ()
-{
- int b, n = 0, p;
- Node *node;
- Port *port;
-
- // If switch and LID == 0, search of other switch ports with
- // valid LID and assign it to all ports of that switch
- for (b = 0; b <= MAXHOPS; b++)
- for (node = nodesdist[b]; node; node = node->dnext)
- if (node->type == SWITCH_NODE) {
- int swlid = 0;
- for (p = 0, port = node->ports;
- p < node->numports && port && !swlid;
- port = port->next)
- if (port->lid != 0)
- swlid = port->lid;
- for (p = 0, port = node->ports;
- p < node->numports && port;
- port = port->next)
- port->lid = swlid;
- }
-
- for (b = 0; b <= MAXHOPS; b++)
- for (node = nodesdist[b]; node; node = node->dnext) {
- for (p = 0, port = node->ports;
- p < node->numports && port;
- p++, port = port->next) {
- fprintf(stdout,
- "%2s %5d %2d 0x%016" PRIx64 " %s %s",
- node_type_str2(port->node), port->lid,
- port->portnum,
- port->portguid,
- get_linkwidth_str(port->linkwidth),
- get_linkspeed_str(port->linkspeed));
- if (port->remoteport)
- fprintf(stdout,
- " - %2s %5d %2d 0x%016" PRIx64
- " ( '%s' - '%s' )\n",
- node_type_str2(port->remoteport->node),
- port->remoteport->lid,
- port->remoteport->portnum,
- port->remoteport->portguid,
- port->node->nodedesc,
- port->remoteport->node->nodedesc);
- else
- fprintf(stdout, "%36s'%s'\n", "",
- port->node->nodedesc);
- }
- n++;
- }
-}
-
-void
-usage(void)
-{
- fprintf(stderr, "Usage: %s [-d(ebug)] -e(rr_show) -v(erbose) -s(how) -l(ist) -g(rouping) -H(ca_list) -S(witch_list) -R(outer_list) -V(ersion) -C ca_name -P ca_port "
- "-t(imeout) timeout_ms --node-name-map node-name-map] -p(orts) [<topology-file>]\n",
- argv0);
- fprintf(stderr, " --node-name-map <node-name-map> specify a node name map file\n");
- exit(-1);
-}
-
-int
-main(int argc, char **argv)
-{
- int mgmt_classes[2] = {IB_SMI_CLASS, IB_SMI_DIRECT_CLASS};
- ib_portid_t my_portid = {0};
- int udebug = 0, list = 0;
- char *ca = 0;
- int ca_port = 0;
- int group = 0;
- int ports_report = 0;
-
- static char const str_opts[] = "C:P:t:devslgHSRpVhu";
- static const struct option long_opts[] = {
- { "C", 1, 0, 'C'},
- { "P", 1, 0, 'P'},
- { "debug", 0, 0, 'd'},
- { "err_show", 0, 0, 'e'},
- { "verbose", 0, 0, 'v'},
- { "show", 0, 0, 's'},
- { "list", 0, 0, 'l'},
- { "grouping", 0, 0, 'g'},
- { "Hca_list", 0, 0, 'H'},
- { "Switch_list", 0, 0, 'S'},
- { "Router_list", 0, 0, 'R'},
- { "timeout", 1, 0, 't'},
- { "node-name-map", 1, 0, 1},
- { "ports", 0, 0, 'p'},
- { "Version", 0, 0, 'V'},
- { "help", 0, 0, 'h'},
- { "usage", 0, 0, 'u'},
- { }
- };
-
- f = stdout;
-
- argv0 = argv[0];
-
- while (1) {
- int ch = getopt_long(argc, argv, str_opts, long_opts, NULL);
- if ( ch == -1 )
- break;
- switch(ch) {
- case 1:
- node_name_map_file = strdup(optarg);
- break;
- case 'C':
- ca = optarg;
- break;
- case 'P':
- ca_port = strtoul(optarg, 0, 0);
- break;
- case 'd':
- ibdebug++;
- madrpc_show_errors(1);
- umad_debug(udebug);
- udebug++;
- break;
- case 't':
- timeout = strtoul(optarg, 0, 0);
- break;
- case 'v':
- verbose++;
- dumplevel++;
- break;
- case 's':
- dumplevel = 1;
- break;
- case 'e':
- madrpc_show_errors(1);
- break;
- case 'l':
- list = LIST_CA_NODE | LIST_SWITCH_NODE | LIST_ROUTER_NODE;
- break;
- case 'g':
- group = 1;
- break;
- case 'S':
- list = LIST_SWITCH_NODE;
- break;
- case 'H':
- list = LIST_CA_NODE;
- break;
- case 'R':
- list = LIST_ROUTER_NODE;
- break;
- case 'V':
- fprintf(stderr, "%s %s\n", argv0, get_build_version() );
- exit(-1);
- case 'p':
- ports_report = 1;
- break;
- default:
- usage();
- break;
- }
- }
- argc -= optind;
- argv += optind;
-
- if (argc && !(f = fopen(argv[0], "w")))
- IBERROR("can't open file %s for writing", argv[0]);
-
- madrpc_init(ca, ca_port, mgmt_classes, 2);
- node_name_map = open_node_name_map(node_name_map_file);
-
- if (discover(&my_portid) < 0)
- IBERROR("discover");
-
- if (group)
- chassis = group_nodes();
-
- if (ports_report)
- dump_ports_report();
- else
- dump_topology(list, group);
-
- close_node_name_map(node_name_map);
- exit(0);
-}
diff --git a/contrib/ofed/management/infiniband-diags/src/ibping.c b/contrib/ofed/management/infiniband-diags/src/ibping.c
deleted file mode 100644
index 4fd2dcb..0000000
--- a/contrib/ofed/management/infiniband-diags/src/ibping.c
+++ /dev/null
@@ -1,331 +0,0 @@
-/*
- * Copyright (c) 2004-2008 Voltaire Inc. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- */
-
-#if HAVE_CONFIG_H
-# include <config.h>
-#endif /* HAVE_CONFIG_H */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <stdarg.h>
-#include <time.h>
-#include <string.h>
-#include <signal.h>
-#include <getopt.h>
-
-#include <infiniband/common.h>
-#include <infiniband/umad.h>
-#include <infiniband/mad.h>
-
-#include "ibdiag_common.h"
-
-#undef DEBUG
-#define DEBUG if (verbose) IBWARN
-
-static int dest_type = IB_DEST_LID;
-static int verbose;
-static char host_and_domain[IB_VENDOR_RANGE2_DATA_SIZE];
-static char last_host[IB_VENDOR_RANGE2_DATA_SIZE];
-
-char *argv0 = "ibping";
-
-static void
-get_host_and_domain(char *data, int sz)
-{
- char *s = data;
- int n;
-
- if (gethostname(s, sz) < 0)
- snprintf(s, sz, "?hostname?");
-
- s[sz-1] = 0;
- if ((n = strlen(s)) >= sz)
- return;
- s[n] = '.';
- s += n + 1;
- sz -= n + 1;
-
- if (getdomainname(s, sz) < 0)
- snprintf(s, sz, "?domainname?");
- if (strlen(s) == 0)
- s[-1] = 0; /* no domain */
-}
-
-static char *
-ibping_serv(void)
-{
- void *umad;
- void *mad;
- char *data;
-
- DEBUG("starting to serve...");
-
- while ((umad = mad_receive(0, -1))) {
-
- mad = umad_get_mad(umad);
- data = (char *)mad + IB_VENDOR_RANGE2_DATA_OFFS;
-
- memcpy(data, host_and_domain, IB_VENDOR_RANGE2_DATA_SIZE);
-
- DEBUG("Pong: %s", data);
-
- if (mad_respond(umad, 0, 0) < 0)
- DEBUG("respond failed");
-
- mad_free(umad);
- }
-
- DEBUG("server out");
- return 0;
-}
-
-static uint64_t
-ibping(ib_portid_t *portid, int quiet)
-{
- char data[IB_VENDOR_RANGE2_DATA_SIZE] = {0};
- ib_vendor_call_t call;
- uint64_t start, rtt;
-
- DEBUG("Ping..");
-
- start = getcurrenttime();
-
- call.method = IB_MAD_METHOD_GET;
- call.mgmt_class = IB_VENDOR_OPENIB_PING_CLASS;
- call.attrid = 0;
- call.mod = 0;
- call.oui = IB_OPENIB_OUI;
- call.timeout = 0;
- memset(&call.rmpp, 0, sizeof call.rmpp);
-
- if (!ib_vendor_call(data, portid, &call))
- return ~0llu;
-
- rtt = getcurrenttime() - start;
-
- if (!last_host[0])
- memcpy(last_host, data, sizeof last_host);
-
- if (!quiet)
- printf("Pong from %s (%s): time %" PRIu64 ".%03" PRIu64 " ms\n",
- data, portid2str(portid), rtt/1000, rtt%1000);
-
- return rtt;
-}
-
-static void
-usage(void)
-{
- char *basename;
-
- if (!(basename = strrchr(argv0, '/')))
- basename = argv0;
- else
- basename++;
-
- fprintf(stderr, "Usage: %s [-d(ebug) -e(rr_show) -v(erbose) -G(uid) -s smlid -V(ersion) -C ca_name -P ca_port "
- "-t(imeout) timeout_ms -c ping_count -f(lood) -o oui -S(erver)] <dest lid|guid>\n",
- basename);
- exit(-1);
-}
-
-static uint64_t minrtt = ~0ull, maxrtt, total_rtt;
-static uint64_t start, total_time, replied, lost, ntrans;
-static ib_portid_t portid = {0};
-
-void
-report(int sig)
-{
- total_time = getcurrenttime() - start;
-
- DEBUG("out due signal %d", sig);
-
- printf("\n--- %s (%s) ibping statistics ---\n", last_host, portid2str(&portid));
- printf("%" PRIu64 " packets transmitted, %" PRIu64 " received, %" PRIu64 "%% packet loss, time %" PRIu64 " ms\n",
- ntrans, replied,
- (lost != 0) ? lost * 100 / ntrans : 0, total_time / 1000);
- printf("rtt min/avg/max = %" PRIu64 ".%03" PRIu64 "/%" PRIu64 ".%03" PRIu64 "/%" PRIu64 ".%03" PRIu64 " ms\n",
- minrtt == ~0ull ? 0 : minrtt/1000,
- minrtt == ~0ull ? 0 : minrtt%1000,
- replied ? total_rtt/replied/1000 : 0,
- replied ? (total_rtt/replied)%1000 : 0,
- maxrtt/1000, maxrtt%1000);
-
- exit(0);
-}
-
-int
-main(int argc, char **argv)
-{
- int mgmt_classes[3] = {IB_SMI_CLASS, IB_SMI_DIRECT_CLASS, IB_SA_CLASS};
- int ping_class = IB_VENDOR_OPENIB_PING_CLASS;
- ib_portid_t *sm_id = 0, sm_portid = {0};
- int timeout = 0, udebug = 0, server = 0, flood = 0;
- int oui = IB_OPENIB_OUI;
- uint64_t rtt;
- unsigned count = ~0;
- extern int ibdebug;
- char *err;
- char *ca = 0;
- int ca_port = 0;
-
- static char const str_opts[] = "C:P:t:s:c:o:devGfSVhu";
- static const struct option long_opts[] = {
- { "C", 1, 0, 'C'},
- { "P", 1, 0, 'P'},
- { "debug", 0, 0, 'd'},
- { "err_show", 0, 0, 'e'},
- { "verbose", 0, 0, 'v'},
- { "Guid", 0, 0, 'G'},
- { "s", 1, 0, 's'},
- { "timeout", 1, 0, 't'},
- { "c", 1, 0, 'c'},
- { "flood", 0, 0, 'f'},
- { "o", 1, 0, 'o'},
- { "Server", 0, 0, 'S'},
- { "Version", 0, 0, 'V'},
- { "help", 0, 0, 'h'},
- { "usage", 0, 0, 'u'},
- { }
- };
-
- argv0 = argv[0];
-
- while (1) {
- int ch = getopt_long(argc, argv, str_opts, long_opts, NULL);
- if ( ch == -1 )
- break;
- switch(ch) {
- case 'C':
- ca = optarg;
- break;
- case 'P':
- ca_port = strtoul(optarg, 0, 0);
- break;
- case 'c':
- count = strtoul(optarg, 0, 0);
- break;
- case 'd':
- ibdebug++;
- madrpc_show_errors(1);
- umad_debug(udebug);
- udebug++;
- break;
- case 'e':
- madrpc_show_errors(1);
- break;
- case 'f':
- flood++;
- break;
- case 'G':
- dest_type = IB_DEST_GUID;
- break;
- case 'o':
- oui = strtoul(optarg, 0, 0);
- break;
- case 's':
- if (ib_resolve_portid_str(&sm_portid, optarg, IB_DEST_LID, 0) < 0)
- IBERROR("can't resolve SM destination port %s", optarg);
- sm_id = &sm_portid;
- break;
- case 'S':
- server++;
- break;
- case 't':
- timeout = strtoul(optarg, 0, 0);
- madrpc_set_timeout(timeout);
- break;
- case 'v':
- verbose++;
- break;
- case 'V':
- fprintf(stderr, "%s %s\n", argv0, get_build_version() );
- exit(-1);
- default:
- usage();
- break;
- }
- }
- argc -= optind;
- argv += optind;
-
- if (!argc && !server)
- usage();
-
- madrpc_init(ca, ca_port, mgmt_classes, 3);
-
- if (server) {
- if (mad_register_server(ping_class, 0, 0, oui) < 0)
- IBERROR("can't serve class %d on this port", ping_class);
-
- get_host_and_domain(host_and_domain, sizeof host_and_domain);
-
- if ((err = ibping_serv()))
- IBERROR("ibping to %s: %s", portid2str(&portid), err);
- exit(0);
- }
-
- if (mad_register_client(ping_class, 0) < 0)
- IBERROR("can't register ping class %d on this port", ping_class);
-
- if (ib_resolve_portid_str(&portid, argv[0], dest_type, sm_id) < 0)
- IBERROR("can't resolve destination port %s", argv[0]);
-
- signal(SIGINT, report);
- signal(SIGTERM, report);
-
- start = getcurrenttime();
-
- while (count-- > 0) {
- ntrans++;
- if ((rtt = ibping(&portid, flood)) == ~0ull) {
- DEBUG("ibping to %s failed", portid2str(&portid));
- lost++;
- } else {
- if (rtt < minrtt)
- minrtt = rtt;
- if (rtt > maxrtt)
- maxrtt = rtt;
- total_rtt += rtt;
- replied++;
- }
-
- if (!flood)
- sleep(1);
- }
-
- report(0);
-
- exit(-1);
-}
diff --git a/contrib/ofed/management/infiniband-diags/src/ibportstate.c b/contrib/ofed/management/infiniband-diags/src/ibportstate.c
deleted file mode 100644
index 36453bb..0000000
--- a/contrib/ofed/management/infiniband-diags/src/ibportstate.c
+++ /dev/null
@@ -1,448 +0,0 @@
-/*
- * Copyright (c) 2004-2008 Voltaire Inc. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- */
-
-#if HAVE_CONFIG_H
-# include <config.h>
-#endif /* HAVE_CONFIG_H */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <stdarg.h>
-#include <time.h>
-#include <string.h>
-#include <getopt.h>
-
-#include <infiniband/common.h>
-#include <infiniband/umad.h>
-#include <infiniband/mad.h>
-
-#include "ibdiag_common.h"
-
-#undef DEBUG
-#define DEBUG if (verbose>1) IBWARN
-
-static int dest_type = IB_DEST_LID;
-static int verbose;
-
-char *argv0 = "ibportstate";
-
-/*******************************************/
-
-static int
-get_node_info(ib_portid_t *dest, uint8_t *data)
-{
- int node_type;
-
- if (!smp_query(data, dest, IB_ATTR_NODE_INFO, 0, 0))
- return -1;
-
- node_type = mad_get_field(data, 0, IB_NODE_TYPE_F);
- if (node_type == IB_NODE_SWITCH) /* Switch NodeType ? */
- return 0;
- else
- return 1;
-}
-
-static int
-get_port_info(ib_portid_t *dest, uint8_t *data, int portnum, int port_op)
-{
- char buf[2048];
- char val[64];
-
- if (!smp_query(data, dest, IB_ATTR_PORT_INFO, portnum, 0))
- return -1;
-
- if (port_op != 4) {
- mad_dump_portstates(buf, sizeof buf, data, sizeof data);
- mad_decode_field(data, IB_PORT_LINK_WIDTH_SUPPORTED_F, val);
- mad_dump_field(IB_PORT_LINK_WIDTH_SUPPORTED_F, buf + strlen(buf), sizeof buf - strlen(buf), val);
- sprintf(buf+strlen(buf), "%s", "\n");
- mad_decode_field(data, IB_PORT_LINK_WIDTH_ENABLED_F, val);
- mad_dump_field(IB_PORT_LINK_WIDTH_ENABLED_F, buf + strlen(buf), sizeof buf - strlen(buf), val);
- sprintf(buf+strlen(buf), "%s", "\n");
- mad_decode_field(data, IB_PORT_LINK_WIDTH_ACTIVE_F, val);
- mad_dump_field(IB_PORT_LINK_WIDTH_ACTIVE_F, buf + strlen(buf), sizeof buf - strlen(buf), val);
- sprintf(buf+strlen(buf), "%s", "\n");
- mad_decode_field(data, IB_PORT_LINK_SPEED_SUPPORTED_F, val);
- mad_dump_field(IB_PORT_LINK_SPEED_SUPPORTED_F, buf + strlen(buf), sizeof buf - strlen(buf), val);
- sprintf(buf+strlen(buf), "%s", "\n");
- mad_decode_field(data, IB_PORT_LINK_SPEED_ENABLED_F, val);
- mad_dump_field(IB_PORT_LINK_SPEED_ENABLED_F, buf + strlen(buf), sizeof buf - strlen(buf), val);
- sprintf(buf+strlen(buf), "%s", "\n");
- mad_decode_field(data, IB_PORT_LINK_SPEED_ACTIVE_F, val);
- mad_dump_field(IB_PORT_LINK_SPEED_ACTIVE_F, buf + strlen(buf), sizeof buf - strlen(buf), val);
- sprintf(buf+strlen(buf), "%s", "\n");
- } else {
- mad_decode_field(data, IB_PORT_LINK_SPEED_ENABLED_F, val);
- mad_dump_field(IB_PORT_LINK_SPEED_ENABLED_F, buf, sizeof buf, val);
- sprintf(buf+strlen(buf), "%s", "\n");
- }
-
- printf("# Port info: %s port %d\n%s", portid2str(dest), portnum, buf);
- return 0;
-}
-
-static int
-set_port_info(ib_portid_t *dest, uint8_t *data, int portnum, int port_op)
-{
- char buf[2048];
- char val[64];
-
- if (!smp_set(data, dest, IB_ATTR_PORT_INFO, portnum, 0))
- return -1;
-
- if (port_op != 4)
- mad_dump_portstates(buf, sizeof buf, data, sizeof data);
- else {
- mad_decode_field(data, IB_PORT_LINK_SPEED_ENABLED_F, val);
- mad_dump_field(IB_PORT_LINK_SPEED_ENABLED_F, buf, sizeof buf, val);
- sprintf(buf+strlen(buf), "%s", "\n");
- }
-
- printf("\nAfter PortInfo set:\n");
- printf("# Port info: %s port %d\n%s", portid2str(dest), portnum, buf);
- return 0;
-}
-
-static int
-get_link_width(int lwe, int lws)
-{
- if (lwe == 255)
- return lws;
- else
- return lwe;
-}
-
-static int
-get_link_speed(int lse, int lss)
-{
- if (lse == 15)
- return lss;
- else
- return lse;
-}
-
-static void
-validate_width(int width, int peerwidth, int lwa)
-{
- if ((width & 0x8) && (peerwidth & 0x8)) {
- if (lwa != 8)
- IBWARN("Peer ports operating at active width %d rather than 8 (12x)", lwa);
- } else {
- if ((width & 0x4) && (peerwidth & 0x4)) {
- if (lwa != 4)
- IBWARN("Peer ports operating at active width %d rather than 4 (8x)", lwa);
- } else {
- if ((width & 0x2) && (peerwidth & 0x2)) {
- if (lwa != 2)
- IBWARN("Peer ports operating at active width %d rather than 2 (4x)", lwa);
- } else {
- if ((width & 0x1) && (peerwidth & 0x1)) {
- if (lwa != 1)
- IBWARN("Peer ports operating at active width %d rather than 1 (1x)", lwa);
- }
- }
- }
- }
-}
-
-static void
-validate_speed(int speed, int peerspeed, int lsa)
-{
- if ((speed & 0x4) && (peerspeed & 0x4)) {
- if (lsa != 4)
- IBWARN("Peer ports operating at active speed %d rather than 4 (10.0 Gbps)", lsa);
- } else {
- if ((speed & 0x2) && (peerspeed & 0x2)) {
- if (lsa != 2)
- IBWARN("Peer ports operating at active speed %d rather than 2 (5.0 Gbps)", lsa);
- } else {
- if ((speed & 0x1) && (peerspeed & 0x1)) {
- if (lsa != 1)
- IBWARN("Peer ports operating at active speed %d rather than 1 (2.5 Gbps)", lsa);
- }
- }
- }
-}
-
-void
-usage(void)
-{
- char *basename;
-
- if (!(basename = strrchr(argv0, '/')))
- basename = argv0;
- else
- basename++;
-
- fprintf(stderr, "Usage: %s [-d(ebug) -e(rr_show) -v(erbose) -D(irect) -G(uid) -s smlid -V(ersion) -C ca_name -P ca_port "
- "-t(imeout) timeout_ms] <dest dr_path|lid|guid> <portnum> [<op>]\n",
- basename);
- fprintf(stderr, "\tsupported ops: enable, disable, reset, speed, query\n");
- fprintf(stderr, "\n\texamples:\n");
- fprintf(stderr, "\t\t%s 3 1 disable\t\t\t# by lid\n", basename);
- fprintf(stderr, "\t\t%s -G 0x2C9000100D051 1 enable\t# by guid\n", basename);
- fprintf(stderr, "\t\t%s -D 0 1\t\t\t# (query) by direct route\n", basename);
- fprintf(stderr, "\t\t%s 3 1 reset\t\t\t# by lid\n", basename);
- fprintf(stderr, "\t\t%s 3 1 speed 1\t\t\t# by lid\n", basename);
- exit(-1);
-}
-
-int
-main(int argc, char **argv)
-{
- int mgmt_classes[3] = {IB_SMI_CLASS, IB_SMI_DIRECT_CLASS, IB_SA_CLASS};
- ib_portid_t portid = {0};
- ib_portid_t *sm_id = 0, sm_portid = {0};
- extern int ibdebug;
- int err;
- int timeout = 0, udebug = 0;
- char *ca = 0;
- int ca_port = 0;
- int port_op = 0; /* default to query */
- int speed = 15;
- int is_switch = 1;
- int state, physstate, lwe, lws, lwa, lse, lss, lsa;
- int peerlocalportnum, peerlwe, peerlws, peerlwa, peerlse, peerlss, peerlsa;
- int width, peerwidth, peerspeed;
- uint8_t data[IB_SMP_DATA_SIZE];
- ib_portid_t peerportid = {0};
- int portnum = 0;
- ib_portid_t selfportid = {0};
- int selfport = 0;
-
- static char const str_opts[] = "C:P:t:s:devDGVhu";
- static const struct option long_opts[] = {
- { "C", 1, 0, 'C'},
- { "P", 1, 0, 'P'},
- { "debug", 0, 0, 'd'},
- { "err_show", 0, 0, 'e'},
- { "verbose", 0, 0, 'v'},
- { "Direct", 0, 0, 'D'},
- { "Guid", 0, 0, 'G'},
- { "timeout", 1, 0, 't'},
- { "s", 1, 0, 's'},
- { "Version", 0, 0, 'V'},
- { "help", 0, 0, 'h'},
- { "usage", 0, 0, 'u'},
- { }
- };
-
- argv0 = argv[0];
-
- while (1) {
- int ch = getopt_long(argc, argv, str_opts, long_opts, NULL);
- if ( ch == -1 )
- break;
- switch(ch) {
- case 'd':
- ibdebug++;
- madrpc_show_errors(1);
- umad_debug(udebug);
- udebug++;
- break;
- case 'e':
- madrpc_show_errors(1);
- break;
- case 'D':
- dest_type = IB_DEST_DRPATH;
- break;
- case 'G':
- dest_type = IB_DEST_GUID;
- break;
- case 'C':
- ca = optarg;
- break;
- case 'P':
- ca_port = strtoul(optarg, 0, 0);
- break;
- case 's':
- if (ib_resolve_portid_str(&sm_portid, optarg, IB_DEST_LID, 0) < 0)
- IBERROR("can't resolve SM destination port %s", optarg);
- sm_id = &sm_portid;
- break;
- case 't':
- timeout = strtoul(optarg, 0, 0);
- madrpc_set_timeout(timeout);
- break;
- case 'v':
- verbose++;
- break;
- case 'V':
- fprintf(stderr, "%s %s\n", argv0, get_build_version() );
- exit(-1);
- default:
- usage();
- break;
- }
- }
- argc -= optind;
- argv += optind;
-
- if (argc < 2)
- usage();
-
- madrpc_init(ca, ca_port, mgmt_classes, 3);
-
- if (ib_resolve_portid_str(&portid, argv[0], dest_type, sm_id) < 0)
- IBERROR("can't resolve destination port %s", argv[0]);
-
- /* First, make sure it is a switch port if it is a "set" */
- if (argc >= 3) {
- if (!strcmp(argv[2], "enable"))
- port_op = 1;
- else if (!strcmp(argv[2], "disable"))
- port_op = 2;
- else if (!strcmp(argv[2], "reset"))
- port_op = 3;
- else if (!strcmp(argv[2], "speed")) {
- if (argc < 4)
- IBERROR("speed requires an additional parameter");
- port_op = 4;
- /* Parse speed value */
- speed = strtoul(argv[3], 0, 0);
- if (speed > 15)
- IBERROR("invalid speed value %d", speed);
- }
- }
-
- err = get_node_info(&portid, data);
- if (err < 0)
- IBERROR("smp query nodeinfo failed");
- if (err) { /* not switch */
- if (port_op == 0) /* query op */
- is_switch = 0;
- else if (port_op != 4) /* other than speed op */
- IBERROR("smp query nodeinfo: Node type not switch");
- }
-
- if (argc-1 > 0)
- portnum = strtol(argv[1], 0, 0);
-
- if (port_op)
- printf("Initial PortInfo:\n");
- else
- printf("PortInfo:\n");
- err = get_port_info(&portid, data, portnum, port_op);
- if (err < 0)
- IBERROR("smp query portinfo failed");
-
- /* Only if one of the "set" options is chosen */
- if (port_op) {
- if (port_op == 1) /* Enable port */
- mad_set_field(data, 0, IB_PORT_PHYS_STATE_F, 2); /* Polling */
- else if ((port_op == 2) || (port_op == 3)) { /* Disable port */
- mad_set_field(data, 0, IB_PORT_STATE_F, 1); /* Down */
- mad_set_field(data, 0, IB_PORT_PHYS_STATE_F, 3); /* Disabled */
- } else if (port_op == 4) { /* Set speed */
- mad_set_field(data, 0, IB_PORT_LINK_SPEED_ENABLED_F, speed);
- mad_set_field(data, 0, IB_PORT_STATE_F, 0);
- mad_set_field(data, 0, IB_PORT_PHYS_STATE_F, 0);
- }
-
- err = set_port_info(&portid, data, portnum, port_op);
- if (err < 0)
- IBERROR("smp set portinfo failed");
-
- if (port_op == 3) { /* Reset port - so also enable */
- mad_set_field(data, 0, IB_PORT_PHYS_STATE_F, 2); /* Polling */
- err = set_port_info(&portid, data, portnum, port_op);
- if (err < 0)
- IBERROR("smp set portinfo failed");
- }
- } else { /* query op */
- /* only compare peer port if switch port */
- if (is_switch) {
- /* First, exclude SP0 */
- if (portnum) {
- /* Now, make sure PortState is Active */
- /* Or is PortPhysicalState LinkUp sufficient ? */
- mad_decode_field(data, IB_PORT_STATE_F, &state);
- mad_decode_field(data, IB_PORT_PHYS_STATE_F, &physstate);
- if (state == 4) { /* Active */
- mad_decode_field(data, IB_PORT_LINK_WIDTH_ENABLED_F, &lwe );
- mad_decode_field(data, IB_PORT_LINK_WIDTH_SUPPORTED_F, &lws);
- mad_decode_field(data, IB_PORT_LINK_WIDTH_ACTIVE_F, &lwa);
- mad_decode_field(data, IB_PORT_LINK_SPEED_SUPPORTED_F, &lss);
- mad_decode_field(data, IB_PORT_LINK_SPEED_ACTIVE_F, &lsa);
- mad_decode_field(data, IB_PORT_LINK_SPEED_ENABLED_F, &lse);
-
- /* Setup portid for peer port */
- memcpy(&peerportid, &portid, sizeof(peerportid));
- peerportid.drpath.cnt = 1;
- peerportid.drpath.p[1] = portnum;
-
- /* Set DrSLID to local lid */
- if (ib_resolve_self(&selfportid, &selfport, 0) < 0)
- IBERROR("could not resolve self");
- peerportid.drpath.drslid = selfportid.lid;
- peerportid.drpath.drdlid = 0xffff;
-
- /* Get peer port NodeInfo to obtain peer port number */
- err = get_node_info(&peerportid, data);
- if (err < 0)
- IBERROR("smp query nodeinfo failed");
-
- mad_decode_field(data, IB_NODE_LOCAL_PORT_F, &peerlocalportnum);
-
- printf("Peer PortInfo:\n");
- /* Get peer port characteristics */
- err = get_port_info(&peerportid, data, peerlocalportnum, port_op);
- if (err < 0)
- IBERROR("smp query peer portinfofailed");
-
- mad_decode_field(data, IB_PORT_LINK_WIDTH_ENABLED_F, &peerlwe );
- mad_decode_field(data, IB_PORT_LINK_WIDTH_SUPPORTED_F, &peerlws);
- mad_decode_field(data, IB_PORT_LINK_WIDTH_ACTIVE_F, &peerlwa);
- mad_decode_field(data, IB_PORT_LINK_SPEED_SUPPORTED_F, &peerlss);
- mad_decode_field(data, IB_PORT_LINK_SPEED_ACTIVE_F, &peerlsa);
- mad_decode_field(data, IB_PORT_LINK_SPEED_ENABLED_F, &peerlse);
-
- /* Now validate peer port characteristics */
- /* Examine Link Width */
- width = get_link_width(lwe, lws);
- peerwidth = get_link_width(peerlwe, peerlws);
- validate_width(width, peerwidth, lwa);
-
- /* Examine Link Speed */
- speed = get_link_speed(lse, lss);
- peerspeed = get_link_speed(peerlse, peerlss);
- validate_speed(speed, peerspeed, lsa);
- }
- }
- }
- }
-
- exit(0);
-}
diff --git a/contrib/ofed/management/infiniband-diags/src/ibroute.c b/contrib/ofed/management/infiniband-diags/src/ibroute.c
deleted file mode 100644
index 9607aa9..0000000
--- a/contrib/ofed/management/infiniband-diags/src/ibroute.c
+++ /dev/null
@@ -1,495 +0,0 @@
-/*
- * Copyright (c) 2004-2008 Voltaire Inc. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- */
-
-#if HAVE_CONFIG_H
-# include <config.h>
-#endif /* HAVE_CONFIG_H */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <stdarg.h>
-#include <time.h>
-#include <string.h>
-#include <inttypes.h>
-#include <getopt.h>
-#include <netinet/in.h>
-#include <ctype.h>
-
-#include <infiniband/common.h>
-#include <infiniband/umad.h>
-#include <infiniband/mad.h>
-#include <complib/cl_nodenamemap.h>
-
-#include "ibdiag_common.h"
-
-static int dest_type = IB_DEST_LID;
-static int brief;
-static int verbose;
-static int dump_all;
-
-char *argv0 = "ibroute";
-
-/*******************************************/
-
-char *
-check_switch(ib_portid_t *portid, int *nports, uint64_t *guid,
- uint8_t *sw, char *nd)
-{
- uint8_t ni[IB_SMP_DATA_SIZE] = {0};
- int type;
-
- DEBUG("checking node type");
- if (!smp_query(ni, portid, IB_ATTR_NODE_INFO, 0, 0)) {
- xdump(stderr, "nodeinfo\n", ni, sizeof ni);
- return "node info failed: valid addr?";
- }
-
- if (!smp_query(nd, portid, IB_ATTR_NODE_DESC, 0, 0))
- return "node desc failed";
-
- mad_decode_field(ni, IB_NODE_TYPE_F, &type);
- if (type != IB_NODE_SWITCH)
- return "not a switch";
-
- DEBUG("Gathering information about switch");
- mad_decode_field(ni, IB_NODE_NPORTS_F, nports);
- mad_decode_field(ni, IB_NODE_GUID_F, guid);
-
- if (!smp_query(sw, portid, IB_ATTR_SWITCH_INFO, 0, 0))
- return "switch info failed: is a switch node?";
-
- return 0;
-}
-
-#define IB_MLIDS_IN_BLOCK (IB_SMP_DATA_SIZE/2)
-
-int
-dump_mlid(char *str, int strlen, int mlid, int nports,
- uint16_t mft[16][IB_MLIDS_IN_BLOCK])
-{
- uint16_t mask;
- int i, chunk, bit;
- int nonzero = 0;
-
- if (brief) {
- int n = 0, chunks = ALIGN(nports + 1, 16) / 16;
- for (i = 0; i < chunks; i++) {
- mask = ntohs(mft[i][mlid%IB_MLIDS_IN_BLOCK]);
- if (mask)
- nonzero++;
- n += snprintf(str + n, strlen - n, "%04hx", mask);
- if (n >= strlen) {
- n = strlen;
- break;
- }
- }
- if (!nonzero && !dump_all) {
- str[0] = 0;
- return 0;
- }
- return n;
- }
- for (i = 0; i <= nports; i++) {
- chunk = i / 16;
- bit = i % 16;
-
- mask = ntohs(mft[chunk][mlid%IB_MLIDS_IN_BLOCK]);
- if (mask)
- nonzero++;
- str[i*2] = (mask & (1 << bit)) ? 'x' : ' ';
- str[i*2+1] = ' ';
- }
- if (!nonzero && !dump_all) {
- str[0] = 0;
- return 0;
- }
- str[i*2] = 0;
- return i * 2;
-}
-
-uint16_t mft[16][IB_MLIDS_IN_BLOCK];
-
-char *
-dump_multicast_tables(ib_portid_t *portid, int startlid, int endlid)
-{
- char nd[IB_SMP_DATA_SIZE] = {0};
- uint8_t sw[IB_SMP_DATA_SIZE] = {0};
- char str[512];
- char *s;
- uint64_t nodeguid;
- uint32_t mod;
- int block, i, j, e, nports, cap, chunks;
- int n = 0, startblock, lastblock;
-
- if ((s = check_switch(portid, &nports, &nodeguid, sw, nd)))
- return s;
-
- mad_decode_field(sw, IB_SW_MCAST_FDB_CAP_F, &cap);
-
- if (!endlid || endlid > IB_MIN_MCAST_LID + cap - 1)
- endlid = IB_MIN_MCAST_LID + cap - 1;
-
- if (!startlid)
- startlid = IB_MIN_MCAST_LID;
-
- if (startlid < IB_MIN_MCAST_LID) {
- IBWARN("illegal start mlid %x, set to %x", startlid, IB_MIN_MCAST_LID);
- startlid = IB_MIN_MCAST_LID;
- }
-
- if (endlid > IB_MAX_MCAST_LID) {
- IBWARN("illegal end mlid %x, truncate to %x", endlid, IB_MAX_MCAST_LID);
- endlid = IB_MAX_MCAST_LID;
- }
-
- printf("Multicast mlids [0x%x-0x%x] of switch %s guid 0x%016" PRIx64 " (%s):\n",
- startlid, endlid, portid2str(portid), nodeguid, clean_nodedesc(nd));
-
- if (brief)
- printf(" MLid Port Mask\n");
- else {
- if (nports > 9) {
- for (i = 0, s = str; i <= nports; i++) {
- *s++ = (i%10) ? ' ' : '0' + i/10;
- *s++ = ' ';
- }
- *s = 0;
- printf(" %s\n", str);
- }
- for (i = 0, s = str; i <= nports; i++)
- s += sprintf(s, "%d ", i%10);
- printf(" Ports: %s\n", str);
- printf(" MLid\n");
- }
- if (verbose)
- printf("Switch muticast mlids capability is 0x%d\n", cap);
-
- chunks = ALIGN(nports + 1, 16) / 16;
-
- startblock = startlid / IB_MLIDS_IN_BLOCK;
- lastblock = endlid / IB_MLIDS_IN_BLOCK;
- for (block = startblock; block <= lastblock; block++) {
- for (j = 0; j < chunks; j++) {
- mod = (block - IB_MIN_MCAST_LID/IB_MLIDS_IN_BLOCK) | (j << 28);
-
- DEBUG("reading block %x chunk %d mod %x", block, j, mod);
- if (!smp_query(mft + j, portid, IB_ATTR_MULTICASTFORWTBL, mod, 0))
- return "multicast forwarding table get failed";
- }
-
- i = block * IB_MLIDS_IN_BLOCK;
- e = i + IB_MLIDS_IN_BLOCK;
- if (i < startlid)
- i = startlid;
- if (e > endlid + 1)
- e = endlid + 1;
-
- for (; i < e; i++) {
- if (dump_mlid(str, sizeof str, i, nports, mft) == 0)
- continue;
- printf("0x%04x %s\n", i, str);
- n++;
- }
- }
-
- printf("%d %smlids dumped \n", n, dump_all ? "" : "valid ");
- return 0;
-}
-
-int
-dump_lid(char *str, int strlen, int lid, int valid)
-{
- char nd[IB_SMP_DATA_SIZE] = {0};
- uint8_t ni[IB_SMP_DATA_SIZE] = {0};
- uint8_t pi[IB_SMP_DATA_SIZE] = {0};
- ib_portid_t lidport = {0};
- static int last_port_lid, base_port_lid;
- char ntype[50], sguid[30], desc[64];
- static uint64_t portguid;
- int baselid, lmc, type;
-
- if (brief) {
- str[0] = 0;
- return 0;
- }
-
- if (lid <= last_port_lid) {
- if (!valid)
- return snprintf(str, strlen, ": (path #%d - illegal port)",
- lid - base_port_lid);
- else if (!portguid)
- return snprintf(str, strlen,
- ": (path #%d out of %d)",
- lid - base_port_lid + 1,
- last_port_lid - base_port_lid + 1);
- else {
- return snprintf(str, strlen,
- ": (path #%d out of %d: portguid %s)",
- lid - base_port_lid + 1,
- last_port_lid - base_port_lid + 1,
- mad_dump_val(IB_NODE_PORT_GUID_F, sguid, sizeof sguid, &portguid));
- }
- }
-
- if (!valid)
- return snprintf(str, strlen, ": (illegal port)");
-
- portguid = 0;
- lidport.lid = lid;
-
- if (!smp_query(nd, &lidport, IB_ATTR_NODE_DESC, 0, 100) ||
- !smp_query(pi, &lidport, IB_ATTR_PORT_INFO, 0, 100) ||
- !smp_query(ni, &lidport, IB_ATTR_NODE_INFO, 0, 100))
- return snprintf(str, strlen, ": (unknown node and type)");
-
- mad_decode_field(ni, IB_NODE_PORT_GUID_F, &portguid);
- mad_decode_field(ni, IB_NODE_TYPE_F, &type);
-
- mad_decode_field(pi, IB_PORT_LID_F, &baselid);
- mad_decode_field(pi, IB_PORT_LMC_F, &lmc);
-
- if (lmc > 0) {
- base_port_lid = baselid;
- last_port_lid = baselid + (1 << lmc) - 1;
- }
-
- return snprintf(str, strlen, ": (%s portguid %s: %s)",
- mad_dump_val(IB_NODE_TYPE_F, ntype, sizeof ntype, &type),
- mad_dump_val(IB_NODE_PORT_GUID_F, sguid, sizeof sguid, &portguid),
- mad_dump_val(IB_NODE_DESC_F, desc, sizeof desc, clean_nodedesc(nd)));
-}
-
-char *
-dump_unicast_tables(ib_portid_t *portid, int startlid, int endlid)
-{
- char lft[IB_SMP_DATA_SIZE];
- char nd[IB_SMP_DATA_SIZE];
- uint8_t sw[IB_SMP_DATA_SIZE];
- char str[200], *s;
- uint64_t nodeguid;
- int block, i, e, nports, top;
- int n = 0, startblock, endblock;
-
- if ((s = check_switch(portid, &nports, &nodeguid, sw, nd)))
- return s;
-
- mad_decode_field(sw, IB_SW_LINEAR_FDB_TOP_F, &top);
-
- if (!endlid || endlid > top)
- endlid = top;
-
- if (endlid > IB_MAX_UCAST_LID) {
- IBWARN("ilegal lft top %d, truncate to %d", endlid, IB_MAX_UCAST_LID);
- endlid = IB_MAX_UCAST_LID;
- }
-
- printf("Unicast lids [0x%x-0x%x] of switch %s guid 0x%016" PRIx64 " (%s):\n",
- startlid, endlid, portid2str(portid), nodeguid, clean_nodedesc(nd));
-
- DEBUG("Switch top is 0x%x\n", top);
-
- printf(" Lid Out Destination\n");
- printf(" Port Info \n");
- startblock = startlid / IB_SMP_DATA_SIZE;
- endblock = ALIGN(endlid, IB_SMP_DATA_SIZE) / IB_SMP_DATA_SIZE;
- for (block = startblock; block <= endblock; block++) {
- DEBUG("reading block %d", block);
- if (!smp_query(lft, portid, IB_ATTR_LINEARFORWTBL, block, 0))
- return "linear forwarding table get failed";
- i = block * IB_SMP_DATA_SIZE;
- e = i + IB_SMP_DATA_SIZE;
- if (i < startlid)
- i = startlid;
- if (e > endlid + 1)
- e = endlid + 1;
-
- for (;i < e; i++) {
- unsigned outport = lft[i % IB_SMP_DATA_SIZE];
- unsigned valid = (outport <= nports);
-
- if (!valid && !dump_all)
- continue;
- dump_lid(str, sizeof str, i, valid);
- printf("0x%04x %03u %s\n", i, outport & 0xff, str);
- n++;
- }
- }
-
- printf("%d %slids dumped \n", n, dump_all ? "" : "valid ");
- return 0;
-}
-
-void
-usage(void)
-{
- char *basename;
-
- if (!(basename = strrchr(argv0, '/')))
- basename = argv0;
- else
- basename++;
-
- fprintf(stderr, "Usage: %s [-d(ebug)] -a(ll) -n(o_dests) -v(erbose) -D(irect) -G(uid) -M(ulticast) -s smlid -V(ersion) -C ca_name -P ca_port "
- "-t(imeout) timeout_ms] [<dest dr_path|lid|guid> [<startlid> [<endlid>]]]\n",
- basename);
- fprintf(stderr, "\n\tUnicast examples:\n");
- fprintf(stderr, "\t\t%s 4\t# dump all lids with valid out ports of switch with lid 4\n", basename);
- fprintf(stderr, "\t\t%s -a 4\t# same, but dump all lids, even with invalid out ports\n", basename);
- fprintf(stderr, "\t\t%s -n 4\t# simple dump format - no destination resolving\n", basename);
- fprintf(stderr, "\t\t%s 4 10\t# dump lids starting from 10\n", basename);
- fprintf(stderr, "\t\t%s 4 0x10 0x20\t# dump lid range\n", basename);
- fprintf(stderr, "\t\t%s -G 0x08f1040023\t# resolve switch by GUID\n", basename);
- fprintf(stderr, "\t\t%s -D 0,1\t# resolve switch by direct path\n", basename);
-
- fprintf(stderr, "\n\tMulticast examples:\n");
- fprintf(stderr, "\t\t%s -M 4\t# dump all non empty mlids of switch with lid 4\n", basename);
- fprintf(stderr, "\t\t%s -M 4 0xc010 0xc020\t# same, but with range\n", basename);
- fprintf(stderr, "\t\t%s -M -n 4\t# simple dump format\n", basename);
- exit(-1);
-}
-
-int
-main(int argc, char **argv)
-{
- int mgmt_classes[3] = {IB_SMI_CLASS, IB_SMI_DIRECT_CLASS, IB_SA_CLASS};
- ib_portid_t portid = {0};
- ib_portid_t *sm_id = 0, sm_portid = {0};
- int timeout;
- int multicast = 0, startlid = 0, endlid = 0;
- char *err;
- char *ca = 0;
- int ca_port = 0;
-
- static char const str_opts[] = "C:P:t:s:danvDGMVhu";
- static const struct option long_opts[] = {
- { "C", 1, 0, 'C'},
- { "P", 1, 0, 'P'},
- { "debug", 0, 0, 'd'},
- { "all", 0, 0, 'a'},
- { "no_dests", 0, 0, 'n'},
- { "verbose", 0, 0, 'v'},
- { "Direct", 0, 0, 'D'},
- { "Guid", 0, 0, 'G'},
- { "Multicast", 0, 0, 'M'},
- { "timeout", 1, 0, 't'},
- { "s", 1, 0, 's'},
- { "Version", 0, 0, 'V'},
- { "help", 0, 0, 'h'},
- { "usage", 0, 0, 'u'},
- { }
- };
-
- argv0 = argv[0];
-
- while (1) {
- int ch = getopt_long(argc, argv, str_opts, long_opts, NULL);
- if ( ch == -1 )
- break;
- switch(ch) {
- case 'C':
- ca = optarg;
- break;
- case 'P':
- ca_port = strtoul(optarg, 0, 0);
- break;
- case 'a':
- dump_all++;
- break;
- case 'd':
- ibdebug++;
- break;
- case 'D':
- dest_type = IB_DEST_DRPATH;
- break;
- case 'G':
- dest_type = IB_DEST_GUID;
- break;
- case 'M':
- multicast++;
- break;
- case 'n':
- brief++;
- break;
- case 's':
- if (ib_resolve_portid_str(&sm_portid, optarg, IB_DEST_LID, 0) < 0)
- IBERROR("can't resolve SM destination port %s", optarg);
- sm_id = &sm_portid;
- break;
- case 't':
- timeout = strtoul(optarg, 0, 0);
- madrpc_set_timeout(timeout);
- break;
- case 'v':
- madrpc_show_errors(1);
- verbose++;
- break;
- case 'V':
- fprintf(stderr, "%s %s\n", argv0, get_build_version() );
- exit(-1);
- default:
- usage();
- break;
- }
- }
- argc -= optind;
- argv += optind;
-
- if (!argc)
- usage();
-
- if (argc > 1)
- startlid = strtoul(argv[1], 0, 0);
- if (argc > 2)
- endlid = strtoul(argv[2], 0, 0);
-
- madrpc_init(ca, ca_port, mgmt_classes, 3);
-
- if (!argc) {
- if (ib_resolve_self(&portid, 0, 0) < 0)
- IBERROR("can't resolve self addr");
- } else {
- if (ib_resolve_portid_str(&portid, argv[0], dest_type, sm_id) < 0)
- IBERROR("can't resolve destination port %s", argv[1]);
- }
-
- if (multicast)
- err = dump_multicast_tables(&portid, startlid, endlid);
- else
- err = dump_unicast_tables(&portid, startlid, endlid);
-
- if (err)
- IBERROR("dump tables: %s", err);
-
- exit(0);
-}
diff --git a/contrib/ofed/management/infiniband-diags/src/ibsendtrap.c b/contrib/ofed/management/infiniband-diags/src/ibsendtrap.c
deleted file mode 100644
index 2754dc0..0000000
--- a/contrib/ofed/management/infiniband-diags/src/ibsendtrap.c
+++ /dev/null
@@ -1,176 +0,0 @@
-/*
- * Copyright (c) 2008 Lawrence Livermore National Security
- *
- * Produced at Lawrence Livermore National Laboratory.
- * Written by Ira Weiny <weiny2@llnl.gov>.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- */
-
-#include <stdlib.h>
-#include <stdio.h>
-#include <unistd.h>
-#include <string.h>
-
-#define _GNU_SOURCE
-#include <getopt.h>
-
-#include <infiniband/mad.h>
-#include <iba/ib_types.h>
-
-#include "ibdiag_common.h"
-
-char *argv0 = "";
-
-static int send_144_node_desc_update(void)
-{
- ib_portid_t sm_port;
- ib_portid_t selfportid;
- int selfport;
- ib_rpc_t trap_rpc;
- ib_mad_notice_attr_t notice;
-
- if (ib_resolve_self(&selfportid, &selfport, NULL))
- IBERROR("can't resolve self");
-
- if (ib_resolve_smlid(&sm_port, 0))
- IBERROR("can't resolve SM destination port");
-
- memset(&trap_rpc, 0, sizeof(trap_rpc));
- trap_rpc.mgtclass = IB_SMI_CLASS;
- trap_rpc.method = IB_MAD_METHOD_TRAP;
- trap_rpc.trid = mad_trid();
- trap_rpc.attr.id = NOTICE;
- trap_rpc.datasz = IB_SMP_DATA_SIZE;
- trap_rpc.dataoffs = IB_SMP_DATA_OFFS;
-
- memset(&notice, 0, sizeof(notice));
- notice.generic_type = 0x80 | IB_NOTICE_TYPE_INFO;
- notice.g_or_v.generic.prod_type_lsb = cl_hton16(IB_NODE_TYPE_CA);
- notice.g_or_v.generic.trap_num = cl_hton16(144);
- notice.issuer_lid = cl_hton16(selfportid.lid);
- notice.data_details.ntc_144.lid = cl_hton16(selfportid.lid);
- notice.data_details.ntc_144.local_changes =
- TRAP_144_MASK_OTHER_LOCAL_CHANGES;
- notice.data_details.ntc_144.change_flgs =
- TRAP_144_MASK_NODE_DESCRIPTION_CHANGE;
-
- return (mad_send(&trap_rpc, &sm_port, NULL, &notice));
-}
-
-typedef struct _trap_def {
- char *trap_name;
- int (*send_func) (void);
-} trap_def_t;
-
-trap_def_t traps[2] = {
- {"node_desc_change", send_144_node_desc_update},
- {NULL, NULL}
-};
-
-static void usage(void)
-{
- int i;
-
- fprintf(stderr, "Usage: %s [-hV]"
- " [-C <ca_name>] [-P <ca_port>] [<trap_name>]\n", argv0);
- fprintf(stderr, " -V print version\n");
- fprintf(stderr, " <trap_name> can be one of the following\n");
- for (i = 0; traps[i].trap_name; i++) {
- fprintf(stderr, " %s\n", traps[i].trap_name);
- }
- fprintf(stderr, " default behavior is to send \"%s\"\n",
- traps[0].trap_name);
-
- exit(-1);
-}
-
-int send_trap(char *trap_name)
-{
- int i;
-
- for (i = 0; traps[i].trap_name; i++) {
- if (strcmp(traps[i].trap_name, trap_name) == 0) {
- return (traps[i].send_func());
- }
- }
- usage();
- exit(1);
-}
-
-int main(int argc, char **argv)
-{
- int mgmt_classes[2] = { IB_SMI_CLASS, IB_SMI_DIRECT_CLASS };
- int ch = 0;
- char *trap_name = NULL;
- char *ca = NULL;
- int ca_port = 0;
-
- static char const str_opts[] = "hVP:C:";
- static const struct option long_opts[] = {
- {"Version", 0, 0, 'V'},
- {"P", 1, 0, 'P'},
- {"C", 1, 0, 'C'},
- {"help", 0, 0, 'h'},
- {}
- };
-
- argv0 = argv[0];
-
- while ((ch = getopt_long(argc, argv, str_opts, long_opts, NULL)) != -1) {
- switch (ch) {
- case 'V':
- fprintf(stderr, "%s %s\n", argv0, get_build_version());
- exit(-1);
- case 'C':
- ca = optarg;
- break;
- case 'P':
- ca_port = strtoul(optarg, NULL, 0);
- break;
- case 'h':
- default:
- usage();
- }
- }
- argc -= optind;
- argv += optind;
-
- if (!argv[0]) {
- trap_name = traps[0].trap_name;
- } else {
- trap_name = argv[0];
- }
-
- madrpc_show_errors(1);
- madrpc_init(ca, ca_port, mgmt_classes, 2);
-
- return (send_trap(trap_name));
-}
diff --git a/contrib/ofed/management/infiniband-diags/src/ibstat.c b/contrib/ofed/management/infiniband-diags/src/ibstat.c
deleted file mode 100644
index 600a657..0000000
--- a/contrib/ofed/management/infiniband-diags/src/ibstat.c
+++ /dev/null
@@ -1,292 +0,0 @@
-/*
- * Copyright (c) 2004-2008 Voltaire Inc. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- */
-
-#define _GNU_SOURCE
-
-#if HAVE_CONFIG_H
-# include <config.h>
-#endif /* HAVE_CONFIG_H */
-
-#include <inttypes.h>
-#include <string.h>
-#include <errno.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <stdarg.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <sys/ioctl.h>
-#include <unistd.h>
-#include <string.h>
-#include <getopt.h>
-#include <endian.h>
-#include <byteswap.h>
-#include <sys/poll.h>
-#include <syslog.h>
-#include <netinet/in.h>
-
-#include <infiniband/common.h>
-#include <infiniband/umad.h>
-#include <infiniband/mad.h>
-
-#include <ibdiag_common.h>
-
-static int debug;
-
-char *argv0 = "ibstat";
-
-static char *node_type_str[] = {
- "???",
- "CA",
- "Switch",
- "Router",
- "iWARP RNIC"
-};
-
-static void
-ca_dump(umad_ca_t *ca)
-{
- if (!ca->node_type)
- return;
- printf("%s '%s'\n", ((uint)ca->node_type <= IB_NODE_MAX ? node_type_str[ca->node_type] : "???"), ca->ca_name);
- printf("\t%s type: %s\n", ((uint)ca->node_type <= IB_NODE_MAX ? node_type_str[ca->node_type] : "???"),ca->ca_type);
- printf("\tNumber of ports: %d\n", ca->numports);
- printf("\tFirmware version: %s\n", ca->fw_ver);
- printf("\tHardware version: %s\n", ca->hw_ver);
- printf("\tNode GUID: 0x%016llx\n", (long long unsigned)ntohll(ca->node_guid));
- printf("\tSystem image GUID: 0x%016llx\n", (long long unsigned)ntohll(ca->system_guid));
-}
-
-static char *port_state_str[] = {
- "???",
- "Down",
- "Initializing",
- "Armed",
- "Active"
-};
-
-static char *port_phy_state_str[] = {
- "No state change",
- "Sleep",
- "Polling",
- "Disabled",
- "PortConfigurationTraining",
- "LinkUp",
- "LinkErrorRecovery",
- "PhyTest"
-};
-
-static int
-port_dump(umad_port_t *port, int alone)
-{
- char *pre = "";
- char *hdrpre = "";
-
- if (!port)
- return -1;
-
- if (!alone) {
- pre = " ";
- hdrpre = " ";
- }
-
- printf("%sPort %d:\n", hdrpre, port->portnum);
- printf("%sState: %s\n", pre, (uint)port->state <= 4 ? port_state_str[port->state] : "???");
- printf("%sPhysical state: %s\n", pre, (uint)port->state <= 7 ? port_phy_state_str[port->phys_state] : "???");
- printf("%sRate: %d\n", pre, port->rate);
- printf("%sBase lid: %d\n", pre, port->base_lid);
- printf("%sLMC: %d\n", pre, port->lmc);
- printf("%sSM lid: %d\n", pre, port->sm_lid);
- printf("%sCapability mask: 0x%08x\n", pre, (unsigned)ntohl(port->capmask));
- printf("%sPort GUID: 0x%016llx\n", pre, (long long unsigned)ntohll(port->port_guid));
- return 0;
-}
-
-static int
-ca_stat(char *ca_name, int portnum, int no_ports)
-{
- umad_ca_t ca;
- int r;
-
- if ((r = umad_get_ca(ca_name, &ca)) < 0)
- return r;
-
- if (!ca.node_type)
- return 0;
-
- if (!no_ports && portnum >= 0) {
- if (portnum > ca.numports || !ca.ports[portnum]) {
- IBWARN("%s: '%s' has no port number %d - max (%d)",
- ((uint)ca.node_type <= IB_NODE_MAX ? node_type_str[ca.node_type] : "???"),
- ca_name, portnum, ca.numports);
- return -1;
- }
- printf("%s: '%s'\n", ((uint)ca.node_type <= IB_NODE_MAX ? node_type_str[ca.node_type] : "???"), ca.ca_name);
- port_dump(ca.ports[portnum], 1);
- return 0;
- }
-
- /* print ca header */
- ca_dump(&ca);
-
- if (no_ports)
- return 0;
-
- for (portnum = 0; portnum <= ca.numports; portnum++)
- port_dump(ca.ports[portnum], 0);
-
- return 0;
-}
-
-static int
-ports_list(char names[][UMAD_CA_NAME_LEN], int n)
-{
- uint64_t guids[64];
- int found, ports, i;
-
- for (i = 0, found = 0; i < n && found < 64; i++) {
- if ((ports = umad_get_ca_portguids(names[i], guids + found, 64 - found)) < 0)
- return -1;
- found += ports;
- }
-
- for (i = 0; i < found; i++)
- if (guids[i])
- printf("0x%016llx\n", (long long unsigned)ntohll(guids[i]));
- return found;
-}
-
-void
-usage(void)
-{
- fprintf(stderr, "Usage: %s [-d(ebug) -l(ist_of_cas) -s(hort) -p(ort_list) -V(ersion)] <ca_name> [portnum]\n", argv0);
- fprintf(stderr, "\tExamples:\n");
- fprintf(stderr, "\t\t%s -l # list all IB devices\n", argv0);
- fprintf(stderr, "\t\t%s mthca0 2 # stat port 2 of 'mthca0'\n", argv0);
- exit(-1);
-}
-
-int
-main(int argc, char *argv[])
-{
- char names[UMAD_MAX_DEVICES][UMAD_CA_NAME_LEN];
- int dev_port = -1;
- int list_only = 0, short_format = 0, list_ports = 0;
- int n, i;
-
- static char const str_opts[] = "dlspVhu";
- static const struct option long_opts[] = {
- { "debug", 0, 0, 'd'},
- { "list_of_cas", 0, 0, 'l'},
- { "short", 0, 0, 's'},
- { "port_list", 0, 0, 'p'},
- { "Version", 0, 0, 'V'},
- { "help", 0, 0, 'h'},
- { "usage", 0, 0, 'u'},
- { }
- };
-
- argv0 = argv[0];
-
- while (1) {
- int ch = getopt_long(argc, argv, str_opts, long_opts, NULL);
- if ( ch == -1 )
- break;
- switch(ch) {
- case 'd':
- debug++;
- break;
- case 'l':
- list_only++;
- break;
- case 's':
- short_format++;
- break;
- case 'p':
- list_ports++;
- break;
- case 'V':
- fprintf(stderr, "%s %s\n", argv0, get_build_version() );
- exit(-1);
- default:
- usage();
- break;
- }
- }
- argc -= optind;
- argv += optind;
-
- if (argc > 1)
- dev_port = strtol(argv[1], 0, 0);
-
- if (umad_init() < 0)
- IBPANIC("can't init UMAD library");
-
- if ((n = umad_get_cas_names(names, UMAD_MAX_DEVICES)) < 0)
- IBPANIC("can't list IB device names");
-
- if (argc) {
- for (i = 0; i < n; i++)
- if (!strncmp(names[i], argv[0], sizeof names[i]))
- break;
- if (i >= n)
- IBPANIC("'%s' IB device can't be found", argv[0]);
-
- strncpy(names[i], argv[0], sizeof names[i]);
- n = 1;
- }
-
- if (list_ports) {
- if (ports_list(names, n) < 0)
- IBPANIC("can't list ports");
- return 0;
- }
-
- if (!list_only && argc) {
- if (ca_stat(argv[0], dev_port, short_format) < 0)
- IBPANIC("stat of IB device '%s' failed", argv[0]);
- return 0;
- }
-
- for (i = 0; i < n; i++) {
- if (list_only)
- printf("%s\n", names[i]);
- else
- if (ca_stat(names[i], -1, short_format) < 0)
- IBPANIC("stat of IB device '%s' failed", names[i]);
- }
-
- return 0;
-}
diff --git a/contrib/ofed/management/infiniband-diags/src/ibsysstat.c b/contrib/ofed/management/infiniband-diags/src/ibsysstat.c
deleted file mode 100644
index e3d0b9f..0000000
--- a/contrib/ofed/management/infiniband-diags/src/ibsysstat.c
+++ /dev/null
@@ -1,354 +0,0 @@
-/*
- * Copyright (c) 2004-2008 Voltaire Inc. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- */
-
-#if HAVE_CONFIG_H
-# include <config.h>
-#endif /* HAVE_CONFIG_H */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <stdarg.h>
-#include <time.h>
-#include <string.h>
-#include <getopt.h>
-
-#include <infiniband/common.h>
-#include <infiniband/umad.h>
-#include <infiniband/mad.h>
-
-#include "ibdiag_common.h"
-
-#undef DEBUG
-#define DEBUG if (verbose) IBWARN
-
-static int dest_type = IB_DEST_LID;
-static int verbose;
-
-#define MAX_CPUS 8
-
-enum ib_sysstat_attr_t {
- IB_PING_ATTR = 0x10,
- IB_HOSTINFO_ATTR = 0x11,
- IB_CPUINFO_ATTR = 0x12,
-};
-
-typedef struct cpu_info {
- char *model;
- char *mhz;
-} cpu_info;
-
-static cpu_info cpus[MAX_CPUS];
-static int host_ncpu;
-
-char *argv0 = "ibsysstat";
-
-static void
-mk_reply(int attr, void *data, int sz)
-{
- char *s = data;
- int n, i;
-
- switch (attr) {
- case IB_PING_ATTR:
- break; /* nothing to do here, just reply */
- case IB_HOSTINFO_ATTR:
- if (gethostname(s, sz) < 0)
- snprintf(s, sz, "?hostname?");
- s[sz-1] = 0;
- if ((n = strlen(s)) >= sz)
- break;
- s[n] = '.';
- s += n+1;
- sz -= n+1;
- if (getdomainname(s, sz) < 0)
- snprintf(s, sz, "?domainname?");
- if (strlen(s) == 0)
- s[-1] = 0; /* no domain */
- break;
- case IB_CPUINFO_ATTR:
- for (i = 0; i < host_ncpu && sz > 0; i++) {
- n = snprintf(s, sz, "cpu %d: model %s MHZ %s\n",
- i, cpus[i].model, cpus[i].mhz);
- if (n >= sz) {
- IBWARN("cpuinfo truncated");
- break;
- }
- sz -= n;
- s += n;
- }
- break;
- default:
- DEBUG("unknown attr %d", attr);
- }
-}
-
-static char *
-ibsystat_serv(void)
-{
- void *umad;
- void *mad;
- int attr, mod;
-
- DEBUG("starting to serve...");
-
- while ((umad = mad_receive(0, -1))) {
-
- mad = umad_get_mad(umad);
-
- attr = mad_get_field(mad, 0, IB_MAD_ATTRID_F);
- mod = mad_get_field(mad, 0, IB_MAD_ATTRMOD_F);
-
- DEBUG("got packet: attr 0x%x mod 0x%x", attr, mod);
-
- mk_reply(attr, (char *)mad + IB_VENDOR_RANGE2_DATA_OFFS, IB_VENDOR_RANGE2_DATA_SIZE);
-
- if (mad_respond(umad, 0, 0) < 0)
- DEBUG("respond failed");
-
- mad_free(umad);
- }
-
- DEBUG("server out");
- return 0;
-}
-
-static int
-match_attr(char *str)
-{
- if (!strcmp(str, "ping"))
- return IB_PING_ATTR;
- if (!strcmp(str, "host"))
- return IB_HOSTINFO_ATTR;
- if (!strcmp(str, "cpu"))
- return IB_CPUINFO_ATTR;
- return -1;
-}
-
-static char *
-ibsystat(ib_portid_t *portid, int attr)
-{
- char data[IB_VENDOR_RANGE2_DATA_SIZE] = {0};
- ib_vendor_call_t call;
-
- DEBUG("Sysstat ping..");
-
- call.method = IB_MAD_METHOD_GET;
- call.mgmt_class = IB_VENDOR_OPENIB_SYSSTAT_CLASS;
- call.attrid = attr;
- call.mod = 0;
- call.oui = IB_OPENIB_OUI;
- call.timeout = 0;
- memset(&call.rmpp, 0, sizeof call.rmpp);
-
- if (!ib_vendor_call(data, portid, &call))
- return "vendor call failed";
-
- DEBUG("Got sysstat pong..");
- if (attr != IB_PING_ATTR)
- puts(data);
- else
- printf("sysstat ping succeeded\n");
- return 0;
-}
-
-int
-build_cpuinfo(void)
-{
- char line[1024] = {0}, *s, *e;
- FILE *f;
- int ncpu = 0;
-
- if (!(f = fopen("/proc/cpuinfo", "r"))) {
- IBWARN("couldn't open /proc/cpuinfo");
- return 0;
- }
-
- while (fgets(line, sizeof(line) - 1, f)) {
- if (!strncmp(line, "processor\t", 10)) {
- ncpu++;
- if (ncpu > MAX_CPUS)
- return MAX_CPUS;
- continue;
- }
-
- if (!ncpu || !(s = strchr(line, ':')))
- continue;
-
- if ((e = strchr(s, '\n')))
- *e = 0;
- if (!strncmp(line, "model name\t", 11))
- cpus[ncpu-1].model = strdup(s+1);
- else if (!strncmp(line, "cpu MHz\t", 8))
- cpus[ncpu-1].mhz = strdup(s+1);
- }
-
- fclose(f);
-
- DEBUG("ncpu %d", ncpu);
-
- return ncpu;
-}
-
-static void
-usage(void)
-{
- char *basename;
-
- if (!(basename = strrchr(argv0, '/')))
- basename = argv0;
- else
- basename++;
-
- fprintf(stderr, "Usage: %s [-d(ebug) -e(rr_show) -v(erbose) -G(uid) -s smlid -V(ersion) -C ca_name -P ca_port "
- "-t(imeout) timeout_ms -o oui -S(erver)] <dest lid|guid> [<op>]\n",
- basename);
- exit(-1);
-}
-
-int
-main(int argc, char **argv)
-{
- int mgmt_classes[3] = {IB_SMI_CLASS, IB_SMI_DIRECT_CLASS, IB_SA_CLASS};
- int sysstat_class = IB_VENDOR_OPENIB_SYSSTAT_CLASS;
- ib_portid_t portid = {0};
- ib_portid_t *sm_id = 0, sm_portid = {0};
- int timeout = 0, udebug = 0, server = 0;
- int oui = IB_OPENIB_OUI, attr = IB_PING_ATTR;
- extern int ibdebug;
- char *err;
- char *ca = 0;
- int ca_port = 0;
-
- static char const str_opts[] = "C:P:t:s:o:devGSVhu";
- static const struct option long_opts[] = {
- { "C", 1, 0, 'C'},
- { "P", 1, 0, 'P'},
- { "debug", 0, 0, 'd'},
- { "err_show", 0, 0, 'e'},
- { "verbose", 0, 0, 'v'},
- { "Guid", 0, 0, 'G'},
- { "timeout", 1, 0, 't'},
- { "s", 1, 0, 's'},
- { "o", 1, 0, 'o'},
- { "Server", 0, 0, 'S'},
- { "Version", 0, 0, 'V'},
- { "help", 0, 0, 'h'},
- { "usage", 0, 0, 'u'},
- { }
- };
-
- argv0 = argv[0];
-
- while (1) {
- int ch = getopt_long(argc, argv, str_opts, long_opts, NULL);
- if ( ch == -1 )
- break;
- switch(ch) {
- case 'C':
- ca = optarg;
- break;
- case 'P':
- ca_port = strtoul(optarg, 0, 0);
- break;
- case 'd':
- ibdebug++;
- madrpc_show_errors(1);
- umad_debug(udebug);
- udebug++;
- break;
- case 'e':
- madrpc_show_errors(1);
- break;
- case 'G':
- dest_type = IB_DEST_GUID;
- break;
- case 'o':
- oui = strtoul(optarg, 0, 0);
- break;
- case 's':
- if (ib_resolve_portid_str(&sm_portid, optarg, IB_DEST_LID, 0) < 0)
- IBERROR("can't resolve SM destination port %s", optarg);
- sm_id = &sm_portid;
- break;
- case 'S':
- server++;
- break;
- case 't':
- timeout = strtoul(optarg, 0, 0);
- madrpc_set_timeout(timeout);
- break;
- case 'v':
- verbose++;
- break;
- case 'V':
- fprintf(stderr, "%s %s\n", argv0, get_build_version() );
- exit(-1);
- default:
- usage();
- break;
- }
- }
- argc -= optind;
- argv += optind;
-
- if (!argc && !server)
- usage();
-
- if (argc > 1 && (attr = match_attr(argv[1])) < 0)
- usage();
-
- madrpc_init(ca, ca_port, mgmt_classes, 3);
-
- if (server) {
- if (mad_register_server(sysstat_class, 0, 0, oui) < 0)
- IBERROR("can't serve class %d", sysstat_class);
-
- host_ncpu = build_cpuinfo();
-
- if ((err = ibsystat_serv()))
- IBERROR("ibssystat to %s: %s", portid2str(&portid), err);
- exit(0);
- }
-
- if (mad_register_client(sysstat_class, 0) < 0)
- IBERROR("can't register to sysstat class %d", sysstat_class);
-
- if (ib_resolve_portid_str(&portid, argv[0], dest_type, sm_id) < 0)
- IBERROR("can't resolve destination port %s", argv[0]);
-
- if ((err = ibsystat(&portid, attr)))
- IBERROR("ibsystat to %s: %s", portid2str(&portid), err);
-
- exit(0);
-}
diff --git a/contrib/ofed/management/infiniband-diags/src/ibtracert.c b/contrib/ofed/management/infiniband-diags/src/ibtracert.c
deleted file mode 100644
index f8ecf76..0000000
--- a/contrib/ofed/management/infiniband-diags/src/ibtracert.c
+++ /dev/null
@@ -1,865 +0,0 @@
-/*
- * Copyright (c) 2004-2008 Voltaire Inc. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- */
-
-#if HAVE_CONFIG_H
-# include <config.h>
-#endif /* HAVE_CONFIG_H */
-
-#define _GNU_SOURCE
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <stdarg.h>
-#include <ctype.h>
-#include <getopt.h>
-#include <netinet/in.h>
-#include <inttypes.h>
-#include <errno.h>
-
-#include <infiniband/common.h>
-#include <infiniband/umad.h>
-#include <infiniband/mad.h>
-#include <complib/cl_nodenamemap.h>
-
-#include "ibdiag_common.h"
-
-#define MAXHOPS 63
-
-static char *node_type_str[] = {
- "???",
- "ca",
- "switch",
- "router",
- "iwarp rnic"
-};
-
-static int timeout = 0; /* ms */
-static int verbose;
-static int force;
-static FILE *f;
-
-char *argv0 = "ibtracert";
-
-static char *node_name_map_file = NULL;
-static nn_map_t *node_name_map = NULL;
-
-typedef struct Port Port;
-typedef struct Switch Switch;
-typedef struct Node Node;
-
-struct Port {
- Port *next;
- Port *remoteport;
- uint64_t portguid;
- int portnum;
- int lid;
- int lmc;
- int state;
- int physstate;
- char portinfo[64];
-};
-
-struct Switch {
- int linearcap;
- int mccap;
- int linearFDBtop;
- int fdb_base;
- int8_t fdb[64];
- char switchinfo[64];
-};
-
-struct Node {
- Node *htnext;
- Node *dnext;
- Port *ports;
- ib_portid_t path;
- int type;
- int dist;
- int numports;
- int upport;
- Node *upnode;
- uint64_t nodeguid; /* also portguid */
- char nodedesc[64];
- char nodeinfo[64];
-};
-
-Node *nodesdist[MAXHOPS];
-uint64_t target_portguid;
-
-static int
-get_node(Node *node, Port *port, ib_portid_t *portid)
-{
- void *pi = port->portinfo, *ni = node->nodeinfo, *nd = node->nodedesc;
- char *s, *e;
-
- if (!smp_query(ni, portid, IB_ATTR_NODE_INFO, 0, timeout))
- return -1;
-
- if (!smp_query(nd, portid, IB_ATTR_NODE_DESC, 0, timeout))
- return -1;
-
- for (s = nd, e = s + 64; s < e; s++) {
- if (!*s)
- break;
- if (!isprint(*s))
- *s = ' ';
- }
-
- if (!smp_query(pi, portid, IB_ATTR_PORT_INFO, 0, timeout))
- return -1;
-
- mad_decode_field(ni, IB_NODE_GUID_F, &node->nodeguid);
- mad_decode_field(ni, IB_NODE_TYPE_F, &node->type);
- mad_decode_field(ni, IB_NODE_NPORTS_F, &node->numports);
-
- mad_decode_field(ni, IB_NODE_PORT_GUID_F, &port->portguid);
- mad_decode_field(ni, IB_NODE_LOCAL_PORT_F, &port->portnum);
- mad_decode_field(pi, IB_PORT_LID_F, &port->lid);
- mad_decode_field(pi, IB_PORT_LMC_F, &port->lmc);
- mad_decode_field(pi, IB_PORT_STATE_F, &port->state);
-
- DEBUG("portid %s: got node %" PRIx64 " '%s'", portid2str(portid), node->nodeguid, node->nodedesc);
- return 0;
-}
-
-static int
-switch_lookup(Switch *sw, ib_portid_t *portid, int lid)
-{
- void *si = sw->switchinfo, *fdb = sw->fdb;
-
- if (!smp_query(si, portid, IB_ATTR_SWITCH_INFO, 0, timeout))
- return -1;
-
- mad_decode_field(si, IB_SW_LINEAR_FDB_CAP_F, &sw->linearcap);
- mad_decode_field(si, IB_SW_LINEAR_FDB_TOP_F, &sw->linearFDBtop);
-
- if (lid > sw->linearcap && lid > sw->linearFDBtop)
- return -1;
-
- if (!smp_query(fdb, portid, IB_ATTR_LINEARFORWTBL, lid / 64, timeout))
- return -1;
-
- DEBUG("portid %s: forward lid %d to port %d",
- portid2str(portid), lid, sw->fdb[lid % 64]);
- return sw->fdb[lid % 64];
-}
-
-static int
-sameport(Port *a, Port *b)
-{
- return a->portguid == b->portguid || (force && a->lid == b->lid);
-}
-
-static int
-extend_dpath(ib_dr_path_t *path, int nextport)
-{
- if (path->cnt+2 >= sizeof(path->p))
- return -1;
- ++path->cnt;
- path->p[path->cnt] = nextport;
- return path->cnt;
-}
-
-static void
-dump_endnode(int dump, char *prompt, Node *node, Port *port)
-{
- char *nodename = NULL;
-
- if (!dump)
- return;
- if (dump == 1) {
- fprintf(f, "%s {0x%016" PRIx64 "}[%d]\n",
- prompt, node->nodeguid,
- node->type == IB_NODE_SWITCH ? 0 : port->portnum);
- return;
- }
-
- nodename = remap_node_name(node_name_map, node->nodeguid, node->nodedesc);
-
- fprintf(f, "%s %s {0x%016" PRIx64 "} portnum %d lid %u-%u \"%s\"\n",
- prompt,
- (node->type <= IB_NODE_MAX ? node_type_str[node->type] : "???"),
- node->nodeguid, node->type == IB_NODE_SWITCH ? 0 : port->portnum,
- port->lid, port->lid + (1 << port->lmc) - 1,
- nodename);
-
- free(nodename);
-}
-
-static void
-dump_route(int dump, Node *node, int outport, Port *port)
-{
- char *nodename = NULL;
-
- if (!dump && !verbose)
- return;
-
- nodename = remap_node_name(node_name_map, node->nodeguid, node->nodedesc);
-
- if (dump == 1)
- fprintf(f, "[%d] -> {0x%016" PRIx64 "}[%d]\n",
- outport, port->portguid, port->portnum);
- else
- fprintf(f, "[%d] -> %s port {0x%016" PRIx64 "}[%d] lid %u-%u \"%s\"\n",
- outport,
- (node->type <= IB_NODE_MAX ? node_type_str[node->type] : "???"),
- port->portguid, port->portnum,
- port->lid, port->lid + (1 << port->lmc) - 1,
- nodename);
-
- free(nodename);
-}
-
-static int
-find_route(ib_portid_t *from, ib_portid_t *to, int dump)
-{
- Node *node, fromnode, tonode, nextnode;
- Port *port, fromport, toport, nextport;
- Switch sw;
- int maxhops = MAXHOPS;
- int portnum, outport;
-
- DEBUG("from %s", portid2str(from));
-
- if (get_node(&fromnode, &fromport, from) < 0 ||
- get_node(&tonode, &toport, to) < 0) {
- IBWARN("can't reach to/from ports");
- if (!force)
- return -1;
- if (to->lid > 0)
- toport.lid = to->lid;
- IBWARN("Force: look for lid %d", to->lid);
- }
-
- node = &fromnode;
- port = &fromport;
- portnum = port->portnum;
-
- dump_endnode(dump, "From", node, port);
-
- while (maxhops--) {
- if (port->state != 4)
- goto badport;
-
- if (sameport(port, &toport))
- break; /* found */
-
- outport = portnum;
- if (node->type == IB_NODE_SWITCH) {
- DEBUG("switch node");
- if ((outport = switch_lookup(&sw, from, to->lid)) < 0 ||
- outport > node->numports)
- goto badtbl;
-
- if (extend_dpath(&from->drpath, outport) < 0)
- goto badpath;
-
- if (get_node(&nextnode, &nextport, from) < 0) {
- IBWARN("can't reach port at %s", portid2str(from));
- return -1;
- }
- if (outport == 0) {
- if (!sameport(&nextport, &toport))
- goto badtbl;
- else
- break; /* found SMA port */
- }
- } else if ((node->type == IB_NODE_CA) ||
- (node->type == IB_NODE_ROUTER)) {
- int ca_src = 0;
-
- DEBUG("ca or router node");
- if (!sameport(port, &fromport)) {
- IBWARN("can't continue: reached CA or router port %" PRIx64 ", lid %d",
- port->portguid, port->lid);
- return -1;
- }
- /* we are at CA or router "from" - go one hop back to (hopefully) a switch */
- if (from->drpath.cnt > 0) {
- DEBUG("ca or router node - return back 1 hop");
- from->drpath.cnt--;
- } else {
- ca_src = 1;
- if (portnum && extend_dpath(&from->drpath, portnum) < 0)
- goto badpath;
- }
- if (get_node(&nextnode, &nextport, from) < 0) {
- IBWARN("can't reach port at %s", portid2str(from));
- return -1;
- }
- /* fix port num to be seen from the CA or router side */
- if (!ca_src)
- nextport.portnum = from->drpath.p[from->drpath.cnt+1];
- }
- port = &nextport;
- if (port->state != 4)
- goto badoutport;
- node = &nextnode;
- portnum = port->portnum;
- dump_route(dump, node, outport, port);
- }
-
- if (maxhops <= 0) {
- IBWARN("no route found after %d hops", MAXHOPS);
- return -1;
- }
- dump_endnode(dump, "To", node, port);
- return 0;
-
-badport:
- IBWARN("Bad port state found: node \"%s\" port %d state %d",
- clean_nodedesc(node->nodedesc), portnum, port->state);
- return -1;
-badoutport:
- IBWARN("Bad out port state found: node \"%s\" outport %d state %d",
- clean_nodedesc(node->nodedesc), outport, port->state);
- return -1;
-badtbl:
- IBWARN("Bad forwarding table entry found at: node \"%s\" lid entry %d is %d (top %d)",
- clean_nodedesc(node->nodedesc), to->lid, outport, sw.linearFDBtop);
- return -1;
-badpath:
- IBWARN("Direct path too long!");
- return -1;
-}
-
-
-/**************************
- * MC span part
- */
-
-#define HASHGUID(guid) ((uint32_t)(((uint32_t)(guid) * 101) ^ ((uint32_t)((guid) >> 32) * 103)))
-#define HTSZ 137
-
-static int
-insert_node(Node *new)
-{
- static Node *nodestbl[HTSZ];
- int hash = HASHGUID(new->nodeguid) % HTSZ;
- Node *node ;
-
- for (node = nodestbl[hash]; node; node = node->htnext)
- if (node->nodeguid == new->nodeguid) {
- DEBUG("node %" PRIx64 " already exists", new->nodeguid);
- return -1;
- }
-
- new->htnext = nodestbl[hash];
- nodestbl[hash] = new;
-
- return 0;
-}
-
-static int
-get_port(Port *port, int portnum, ib_portid_t *portid)
-{
- char portinfo[64];
- void *pi = portinfo;
-
- port->portnum = portnum;
-
- if (!smp_query(pi, portid, IB_ATTR_PORT_INFO, portnum, timeout))
- return -1;
-
- mad_decode_field(pi, IB_PORT_LID_F, &port->lid);
- mad_decode_field(pi, IB_PORT_LMC_F, &port->lmc);
- mad_decode_field(pi, IB_PORT_STATE_F, &port->state);
- mad_decode_field(pi, IB_PORT_PHYS_STATE_F, &port->physstate);
-
- VERBOSE("portid %s portnum %d: lid %d state %d physstate %d",
- portid2str(portid), portnum, port->lid, port->state, port->physstate);
- return 1;
-}
-
-static void
-link_port(Port *port, Node *node)
-{
- port->next = node->ports;
- node->ports = port;
-}
-
-static int
-new_node(Node *node, Port *port, ib_portid_t *path, int dist)
-{
- if (port->portguid == target_portguid) {
- node->dist = -1; /* tag as target */
- link_port(port, node);
- dump_endnode(verbose, "found target", node, port);
- return 1; /* found; */
- }
-
- /* BFS search start with my self */
- if (insert_node(node) < 0)
- return -1; /* known switch */
-
- VERBOSE("insert dist %d node %p port %d lid %d", dist, node, port->portnum, port->lid);
-
- link_port(port, node);
-
- node->dist = dist;
- node->path = *path;
- node->dnext = nodesdist[dist];
- nodesdist[dist] = node;
-
- return 0;
-}
-
-static int
-switch_mclookup(Node *node, ib_portid_t *portid, int mlid, char *map)
-{
- Switch sw;
- char mdb[64];
- void *si = sw.switchinfo;
- uint16_t *msets = (uint16_t *)mdb;
- int maxsets, block, i, set;
-
- memset(map, 0, 256);
-
- if (!smp_query(si, portid, IB_ATTR_SWITCH_INFO, 0, timeout))
- return -1;
-
- mlid -= 0xc000;
-
- mad_decode_field(si, IB_SW_MCAST_FDB_CAP_F, &sw.mccap);
-
- if (mlid > sw.mccap)
- return -1;
-
- block = mlid / 32;
- maxsets = (node->numports + 15) / 16; /* round up */
-
- for (set = 0; set < maxsets; set++) {
- if (!smp_query(mdb, portid, IB_ATTR_MULTICASTFORWTBL,
- block | (set << 28), timeout))
- return -1;
-
- for (i = 0; i < 16; i++, map++) {
- uint16_t mask = ntohs(msets[mlid % 32]);
- if (mask & (1 << i))
- *map = 1;
- else
- continue;
- VERBOSE("Switch guid 0x%" PRIx64 ": mlid 0x%x is forwarded to port %d",
- node->nodeguid, mlid + 0xc000, i + set * 16);
- }
- }
-
- return 0;
-}
-
-/*
- * Return 1 if found, 0 if not, -1 on errors.
- */
-static Node *
-find_mcpath(ib_portid_t *from, int mlid)
-{
- Node *node, *remotenode;
- Port *port, *remoteport;
- char map[256];
- int r, i;
- int dist = 0, leafport = 0;
- ib_portid_t *path;
-
- DEBUG("from %s", portid2str(from));
-
- if (!(node = calloc(1, sizeof(Node))))
- IBERROR("out of memory");
-
- if (!(port = calloc(1, sizeof(Port))))
- IBERROR("out of memory");
-
- if (get_node(node, port, from) < 0) {
- IBWARN("can't reach node %s", portid2str(from));
- return 0;
- }
-
- node->upnode = 0; /* root */
- if ((r = new_node(node, port, from, 0)) > 0) {
- if (node->type != IB_NODE_SWITCH) {
- IBWARN("ibtracert from CA to CA is unsupported");
- return 0; /* ibtracert from host to itself is unsupported */
- }
-
- if (switch_mclookup(node, from, mlid, map) < 0 ||
- !map[0])
- return 0;
- return node;
- }
-
- for (dist = 0; dist < MAXHOPS; dist++) {
-
- for (node = nodesdist[dist]; node; node = node->dnext) {
-
- path = &node->path;
-
- VERBOSE("dist %d node %p", dist, node);
- dump_endnode(verbose, "processing", node, node->ports);
-
- memset(map, 0, sizeof(map));
-
- if (node->type != IB_NODE_SWITCH) {
- if (dist)
- continue;
- leafport = path->drpath.p[path->drpath.cnt];
- map[port->portnum] = 1;
- node->upport = 0; /* starting here */
- DEBUG("Starting from CA 0x%" PRIx64 " lid %d port %d (leafport %d)",
- node->nodeguid, port->lid, port->portnum, leafport);
- } else { /* switch */
-
- /* if starting from a leaf port fix up port (up port) */
- if (dist == 1 && leafport)
- node->upport = leafport;
-
- if (switch_mclookup(node, path, mlid, map) < 0) {
- IBWARN("skipping bad Switch 0x%" PRIx64 "",
- node->nodeguid);
- continue;
- }
- }
-
- for (i = 1; i <= node->numports; i++) {
- if (!map[i] || i == node->upport)
- continue;
-
- if (dist == 0 && leafport) {
- if (from->drpath.cnt > 0)
- path->drpath.cnt--;
- } else {
- if (!(port = calloc(1, sizeof(Port))))
- IBERROR("out of memory");
-
- if (get_port(port, i, path) < 0) {
- IBWARN("can't reach node %s port %d", portid2str(path), i);
- return 0;
- }
-
- if (port->physstate != 5) { /* LinkUP */
- free(port);
- continue;
- }
-
-#if 0
- link_port(port, node);
-#endif
-
- if (extend_dpath(&path->drpath, i) < 0)
- return 0;
- }
-
- if (!(remotenode = calloc(1, sizeof(Node))))
- IBERROR("out of memory");
-
- if (!(remoteport = calloc(1, sizeof(Port))))
- IBERROR("out of memory");
-
- if (get_node(remotenode, remoteport, path) < 0) {
- IBWARN("NodeInfo on %s port %d failed, skipping port",
- portid2str(path), i);
- path->drpath.cnt--; /* restore path */
- free(remotenode);
- free(remoteport);
- continue;
- }
-
- remotenode->upnode = node;
- remotenode->upport = remoteport->portnum;
- remoteport->remoteport = port;
-
- if ((r = new_node(remotenode, remoteport, path, dist+1)) > 0)
- return remotenode;
-
- if (r == 0)
- dump_endnode(verbose, "new remote",
- remotenode, remoteport);
- else if (remotenode->type == IB_NODE_SWITCH)
- dump_endnode(2, "ERR: circle discovered at",
- remotenode, remoteport);
-
- path->drpath.cnt--; /* restore path */
- }
- }
- }
-
- return 0; /* not found */
-}
-
-static uint64_t
-find_target_portguid(ib_portid_t *to)
-{
- Node tonode;
- Port toport;
-
- if (get_node(&tonode, &toport, to) < 0) {
- IBWARN("can't find to port\n");
- return -1;
- }
-
- return toport.portguid;
-}
-
-static void
-dump_mcpath(Node *node, int dumplevel)
-{
- char *nodename = NULL;
-
- if (node->upnode)
- dump_mcpath(node->upnode, dumplevel);
-
- nodename = remap_node_name(node_name_map, node->nodeguid, node->nodedesc);
-
- if (!node->dist) {
- printf("From %s 0x%" PRIx64 " port %d lid %u-%u \"%s\"\n",
- (node->type <= IB_NODE_MAX ? node_type_str[node->type] : "???"),
- node->nodeguid, node->ports->portnum, node->ports->lid,
- node->ports->lid + (1 << node->ports->lmc) - 1,
- nodename);
- goto free_name;
- }
-
- if (node->dist) {
- if (dumplevel == 1)
- printf("[%d] -> %s {0x%016" PRIx64 "}[%d]\n",
- node->ports->remoteport->portnum,
- (node->type <= IB_NODE_MAX ? node_type_str[node->type] : "???"),
- node->nodeguid, node->upport);
- else
- printf("[%d] -> %s 0x%" PRIx64 "[%d] lid %u \"%s\"\n",
- node->ports->remoteport->portnum,
- (node->type <= IB_NODE_MAX ? node_type_str[node->type] : "???"),
- node->nodeguid, node->upport,
- node->ports->lid, nodename);
- }
-
- if (node->dist < 0)
- /* target node */
- printf("To %s 0x%" PRIx64 " port %d lid %u-%u \"%s\"\n",
- (node->type <= IB_NODE_MAX ? node_type_str[node->type] : "???"),
- node->nodeguid, node->ports->portnum, node->ports->lid,
- node->ports->lid + (1 << node->ports->lmc) - 1,
- nodename);
-
-free_name:
- free(nodename);
-}
-
-static int resolve_lid(ib_portid_t *portid, const void *srcport)
-{
- uint8_t portinfo[64];
- uint16_t lid;
-
- if (!smp_query_via(portinfo, portid, IB_ATTR_PORT_INFO, 0, 0, srcport))
- return -1;
- mad_decode_field(portinfo, IB_PORT_LID_F, &lid);
-
- ib_portid_set(portid, lid, 0, 0);
-
- return 0;
-}
-
-static void
-usage(void)
-{
- char *basename;
-
- if (!(basename = strrchr(argv0, '/')))
- basename = argv0;
- else
- basename++;
-
- fprintf(stderr, "Usage: %s [-d(ebug) -v(erbose) -D(irect) -G(uids) -n(o_info) -C ca_name -P ca_port "
- "-s smlid -t(imeout) timeout_ms -m mlid --node-name-map node-name-map ] <src-addr> <dest-addr>\n",
- basename);
- fprintf(stderr, "\n\tUnicast examples:\n");
- fprintf(stderr, "\t\t%s 4 16\t\t\t# show path between lids 4 and 16\n", basename);
- fprintf(stderr, "\t\t%s -n 4 16\t\t# same, but using simple output format\n", basename);
- fprintf(stderr, "\t\t%s -G 0x8f1040396522d 0x002c9000100d051\t# use guid addresses\n", basename);
-
- fprintf(stderr, "\n\tMulticast example:\n");
- fprintf(stderr, "\t\t%s -m 0xc000 4 16\t# show multicast path of mlid 0xc000 between lids 4 and 16\n", basename);
- exit(-1);
-}
-
-int
-main(int argc, char **argv)
-{
- int mgmt_classes[3] = {IB_SMI_CLASS, IB_SMI_DIRECT_CLASS, IB_SA_CLASS};
- ib_portid_t my_portid = {0};
- ib_portid_t src_portid = {0};
- ib_portid_t dest_portid = {0};
- ib_portid_t *sm_id = 0, sm_portid = {0};
- int dumplevel = 2, dest_type = IB_DEST_LID, multicast = 0, mlid = 0;
- Node *endnode;
- int udebug = 0;
- char *ca = 0;
- int ca_port = 0;
-
- static char const str_opts[] = "C:P:t:s:m:dvfDGnVhu";
- static const struct option long_opts[] = {
- { "C", 1, 0, 'C'},
- { "P", 1, 0, 'P'},
- { "debug", 0, 0, 'd'},
- { "verbose", 0, 0, 'v'},
- { "force", 0, 0, 'f'},
- { "Direct", 0, 0, 'D'},
- { "Guids", 0, 0, 'G'},
- { "no_info", 0, 0, 'n'},
- { "timeout", 1, 0, 't'},
- { "s", 1, 0, 's'},
- { "m", 1, 0, 'm'},
- { "Version", 0, 0, 'V'},
- { "help", 0, 0, 'h'},
- { "usage", 0, 0, 'u'},
- { "node-name-map", 1, 0, 1},
- { }
- };
-
- argv0 = argv[0];
-
- f = stdout;
-
- while (1) {
- int ch = getopt_long(argc, argv, str_opts, long_opts, NULL);
- if ( ch == -1 )
- break;
- switch(ch) {
- case 1:
- node_name_map_file = strdup(optarg);
- break;
- case 'C':
- ca = optarg;
- break;
- case 'P':
- ca_port = strtoul(optarg, 0, 0);
- break;
- case 'd':
- ibdebug++;
- madrpc_show_errors(1);
- umad_debug(udebug);
- udebug++;
- break;
- case 'D':
- dest_type = IB_DEST_DRPATH;
- break;
- case 'G':
- dest_type = IB_DEST_GUID;
- break;
- case 'm':
- multicast++;
- mlid = strtoul(optarg, 0, 0);
- break;
- case 'f':
- force++;
- break;
- case 'n':
- dumplevel = 1;
- break;
- case 's':
- if (ib_resolve_portid_str(&sm_portid, optarg, IB_DEST_LID, 0) < 0)
- IBERROR("can't resolve SM destination port %s", optarg);
- sm_id = &sm_portid;
- break;
- case 't':
- timeout = strtoul(optarg, 0, 0);
- madrpc_set_timeout(timeout);
- break;
- case 'v':
- madrpc_show_errors(1);
- verbose++;
- break;
- case 'V':
- fprintf(stderr, "%s %s\n", argv0, get_build_version() );
- exit(-1);
- default:
- usage();
- break;
- }
- }
- argc -= optind;
- argv += optind;
-
- if (argc < 2)
- usage();
-
- madrpc_init(ca, ca_port, mgmt_classes, 3);
- node_name_map = open_node_name_map(node_name_map_file);
-
- if (ib_resolve_portid_str(&src_portid, argv[0], dest_type, sm_id) < 0)
- IBERROR("can't resolve source port %s", argv[0]);
-
- if (ib_resolve_portid_str(&dest_portid, argv[1], dest_type, sm_id) < 0)
- IBERROR("can't resolve destination port %s", argv[1]);
-
- if (dest_type == IB_DEST_DRPATH) {
- if (resolve_lid(&src_portid, NULL) < 0)
- IBERROR("cannot resolve lid for port \'%s\'",
- portid2str(&src_portid));
- if (resolve_lid(&dest_portid, NULL) < 0)
- IBERROR("cannot resolve lid for port \'%s\'",
- portid2str(&dest_portid));
- }
-
- if (dest_portid.lid == 0 || src_portid.lid == 0) {
- IBWARN("bad src/dest lid");
- usage();
- }
-
- if (dest_type != IB_DEST_DRPATH) {
- /* first find a direct path to the src port */
- if (find_route(&my_portid, &src_portid, 0) < 0)
- IBERROR("can't find a route to the src port");
-
- src_portid = my_portid;
- }
-
- if (!multicast) {
- if (find_route(&src_portid, &dest_portid, dumplevel) < 0)
- IBERROR("can't find a route from src to dest");
- exit(0);
- } else {
- if (mlid < 0xc000)
- IBWARN("invalid MLID; must be 0xc000 or larger");
- }
-
- if (!(target_portguid = find_target_portguid(&dest_portid)))
- IBERROR("can't reach target lid %d", dest_portid.lid);
-
- if (!(endnode = find_mcpath(&src_portid, mlid)))
- IBERROR("can't find a multicast route from src to dest");
-
- /* dump multicast path */
- dump_mcpath(endnode, dumplevel);
-
- close_node_name_map(node_name_map);
- exit(0);
-}
diff --git a/contrib/ofed/management/infiniband-diags/src/mcm_rereg_test.c b/contrib/ofed/management/infiniband-diags/src/mcm_rereg_test.c
deleted file mode 100644
index 9285b95..0000000
--- a/contrib/ofed/management/infiniband-diags/src/mcm_rereg_test.c
+++ /dev/null
@@ -1,489 +0,0 @@
-/*
- * Copyright (c) 2006 Voltaire, Inc. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- */
-
-#include <stdio.h>
-#include <string.h>
-#include <errno.h>
-#include <inttypes.h>
-
-#include <infiniband/umad.h>
-#include <infiniband/mad.h>
-
-#define info(fmt, arg...) fprintf(stderr, "INFO: " fmt, ##arg )
-#define err(fmt, arg...) fprintf(stderr, "ERR: " fmt, ##arg )
-#ifdef NOISY_DEBUG
-#define dbg(fmt, arg...) fprintf(stderr, "DBG: " fmt, ##arg )
-#else
-#define dbg(fmt, arg...)
-#endif
-
-#define TMO 100
-
-/* Multicast Member Record Component Masks */
-#define IB_MCR_COMPMASK_MGID (1ULL<<0)
-#define IB_MCR_COMPMASK_PORT_GID (1ULL<<1)
-#define IB_MCR_COMPMASK_QKEY (1ULL<<2)
-#define IB_MCR_COMPMASK_MLID (1ULL<<3)
-#define IB_MCR_COMPMASK_MTU_SEL (1ULL<<4)
-#define IB_MCR_COMPMASK_MTU (1ULL<<5)
-#define IB_MCR_COMPMASK_TCLASS (1ULL<<6)
-#define IB_MCR_COMPMASK_PKEY (1ULL<<7)
-#define IB_MCR_COMPMASK_RATE_SEL (1ULL<<8)
-#define IB_MCR_COMPMASK_RATE (1ULL<<9)
-#define IB_MCR_COMPMASK_LIFE_SEL (1ULL<<10)
-#define IB_MCR_COMPMASK_LIFE (1ULL<<11)
-#define IB_MCR_COMPMASK_SL (1ULL<<12)
-#define IB_MCR_COMPMASK_FLOW (1ULL<<13)
-#define IB_MCR_COMPMASK_HOP (1ULL<<14)
-#define IB_MCR_COMPMASK_SCOPE (1ULL<<15)
-#define IB_MCR_COMPMASK_JOIN_STATE (1ULL<<16)
-#define IB_MCR_COMPMASK_PROXY (1ULL<<17)
-
-static ibmad_gid_t mgid_ipoib = {
- 0xff, 0x12, 0x40, 0x1b, 0xff, 0xff, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff
-};
-
-uint64_t build_mcm_rec(uint8_t *data, ibmad_gid_t mgid, ibmad_gid_t port_gid)
-{
- memset(data, 0, IB_SA_DATA_SIZE);
- mad_set_array(data, 0, IB_SA_MCM_MGID_F, mgid);
- mad_set_array(data, 0, IB_SA_MCM_PORTGID_F, port_gid);
- mad_set_field(data, 0, IB_SA_MCM_JOIN_STATE_F, 1);
-
- return IB_MCR_COMPMASK_MGID|IB_MCR_COMPMASK_PORT_GID|
- IB_MCR_COMPMASK_JOIN_STATE;
-}
-
-static void build_mcm_rec_umad(void *umad, ib_portid_t *dport, int method,
- uint64_t comp_mask, uint8_t *data)
-{
- ib_rpc_t rpc;
-
- memset(&rpc, 0, sizeof(rpc));
- rpc.mgtclass = IB_SA_CLASS;
- rpc.method = method;
- rpc.attr.id = IB_SA_ATTR_MCRECORD;
- rpc.attr.mod = 0; // ???
- rpc.mask = comp_mask;
- rpc.datasz = IB_SA_DATA_SIZE;
- rpc.dataoffs = IB_SA_DATA_OFFS;
-
- mad_build_pkt(umad, &rpc, dport, NULL, data);
-}
-
-static int rereg_send(int port, int agent, ib_portid_t *dport,
- uint8_t *umad, int len, int method, ibmad_gid_t port_gid)
-{
- uint8_t data[IB_SA_DATA_SIZE];
- uint64_t comp_mask;
-
- comp_mask = build_mcm_rec(data, mgid_ipoib, port_gid);
-
- build_mcm_rec_umad(umad, dport, method, comp_mask, data);
- if(umad_send(port, agent, umad, len, TMO, 0) < 0) {
- err("umad_send leave failed: %s\n", strerror(errno));
- return -1;
- }
- dbg("umad_send %d: tid = 0x%016" PRIx64 "\n", method,
- mad_get_field64(umad_get_mad(umad), 0, IB_MAD_TRID_F));
-
- return 0;
-}
-
-static int rereg_port_gid(int port, int agent, ib_portid_t *dport,
- uint8_t *umad, int len, ibmad_gid_t port_gid)
-{
- uint8_t data[IB_SA_DATA_SIZE];
- uint64_t comp_mask;
-
- comp_mask = build_mcm_rec(data, mgid_ipoib, port_gid);
-
- build_mcm_rec_umad(umad, dport, IB_MAD_METHOD_DELETE,
- comp_mask, data);
- if(umad_send(port, agent, umad, len, TMO, 0) < 0) {
- err("umad_send leave failed: %s\n", strerror(errno));
- return -1;
- }
- dbg("umad_send leave: tid = 0x%016" PRIx64 "\n",
- mad_get_field64(umad_get_mad(umad), 0, IB_MAD_TRID_F));
-
- build_mcm_rec_umad(umad, dport, IB_MAD_METHOD_SET,
- comp_mask, data);
- if(umad_send(port, agent, umad, len, TMO, 0) < 0) {
- err("umad_send join failed: %s\n", strerror(errno));
- return -1;
- }
- dbg("umad_send join: tid = 0x%016" PRIx64 "\n",
- mad_get_field64(umad_get_mad(umad), 0, IB_MAD_TRID_F));
-
- return 0;
-}
-
-struct guid_trid {
- ibmad_gid_t gid;
- uint64_t guid;
- uint64_t trid;
-};
-
-static int rereg_send_all(int port, int agent, ib_portid_t *dport,
- struct guid_trid *list, unsigned cnt)
-{
- uint8_t *umad;
- int len = umad_size() + 256;
- int i, ret;
-
- info("rereg_send_all... cnt = %u\n", cnt);
-
- umad = calloc(1, len);
- if (!umad) {
- err("cannot alloc mem for umad: %s\n", strerror(errno));
- return -1;
- }
-
- for (i = 0; i < cnt; i++) {
- ret = rereg_port_gid(port, agent, dport, umad, len, list[i].gid);
- if (ret < 0) {
- err("rereg_send_all: rereg_port_gid 0x%016" PRIx64
- " failed\n", list[i].guid);
- continue;
- }
- list[i].trid = mad_get_field64(umad_get_mad(umad), 0,
- IB_MAD_TRID_F);
- }
-
- info("rereg_send_all: sent %u requests\n", cnt*2);
-
- free(umad);
-
- return 0;
-}
-
-#if 0
-static int rereg_mcm_rec_send(int port, int agent, ib_portid_t *dport, int cnt)
-{
- ib_portid_t portid;
- ibmad_gid_t port_gid;
- uint8_t *umad;
- int len, ret = 0;
-
- ib_resolve_self(&portid, NULL, &port_gid);
-
- len = umad_size() + 256;
- umad = calloc(1, len);
- if (!umad) {
- err("cannot alloc mem for umad: %s\n", strerror(errno));
- return -1;
- }
-
- while(cnt--) {
- if (!rereg_port_gid(port, agent, dport, umad, len, port_gid))
- ret += 2;
- }
-
- free(umad);
-
- return ret;
-}
-#endif
-
-static int rereg_recv(int port, int agent, ib_portid_t *dport,
- uint8_t *umad, int length, int tmo)
-{
- int ret, retry = 0;
- int len = length;
-
- while((ret = umad_recv(port, umad, &len, tmo)) < 0 &&
- errno == ETIMEDOUT) {
- if (retry++ > 3)
- return 0;
- }
- if (ret < 0) {
- err("umad_recv %d failed: %s\n", ret, strerror(errno));
- return -1;
- }
- dbg("umad_recv (retries %d), tid = 0x%016" PRIx64 ": len = %d, status = %d\n",
- retry,
- mad_get_field64(umad_get_mad(umad), 0, IB_MAD_TRID_F),
- len, umad_status(umad));
-
- return 1;
-}
-
-static int rereg_recv_all(int port, int agent, ib_portid_t *dport,
- struct guid_trid *list, unsigned cnt)
-{
- uint8_t *umad, *mad;
- int len = umad_size() + 256;
- uint64_t trid;
- unsigned n, method, status;
- int i;
-
- info("rereg_recv_all...\n");
-
- umad = calloc(1, len);
- if (!umad) {
- err("cannot alloc mem for umad: %s\n", strerror(errno));
- return -1;
- }
-
- n = 0;
- while (rereg_recv(port, agent, dport, umad, len, TMO) > 0) {
- dbg("rereg_recv_all: done %d\n", n);
- n++;
- mad = umad_get_mad(umad);
-
- method = mad_get_field(mad, 0, IB_MAD_METHOD_F);
- status = mad_get_field(mad, 0, IB_MAD_STATUS_F);
-
- if (status)
- dbg("MAD status %x, method %x\n", status, method);
-
- if (status &&
- (method&0x7f) == (IB_MAD_METHOD_GET_RESPONSE&0x7f)) {
- trid = mad_get_field64(mad, 0, IB_MAD_TRID_F);
- for (i = 0; i < cnt; i++)
- if (trid == list[i].trid)
- break;
- if (i == cnt) {
- err("cannot find trid 0x%016" PRIx64 "\n",
- trid);
- continue;
- }
- info("guid 0x%016" PRIx64 ": method = %x status = %x. Resending\n",
- ntohll(list[i].guid), method, status);
- rereg_port_gid(port, agent, dport, umad, len,
- list[i].gid);
- list[i].trid = mad_get_field64(umad_get_mad(umad), 0,
- IB_MAD_TRID_F);
- }
- }
-
- info("rereg_recv_all: got %u responses\n", n);
-
- free(umad);
- return 0;
-}
-
-static int rereg_query_all(int port, int agent, ib_portid_t *dport,
- struct guid_trid *list, unsigned cnt)
-{
- uint8_t *umad, *mad;
- int len = umad_size() + 256;
- unsigned method, status;
- int i, ret;
-
- info("rereg_query_all...\n");
-
- umad = calloc(1, len);
- if (!umad) {
- err("cannot alloc mem for umad: %s\n", strerror(errno));
- return -1;
- }
-
- for ( i = 0; i < cnt; i++ ) {
- ret = rereg_send(port, agent, dport, umad, len,
- IB_MAD_METHOD_GET, list[i].gid);
- if (ret < 0) {
- err("query_all: rereg_send failed.\n");
- continue;
- }
-
- ret = rereg_recv(port, agent, dport, umad, len, TMO);
- if (ret < 0) {
- err("query_all: rereg_recv failed.\n");
- continue;
- }
-
- mad = umad_get_mad(umad);
-
- method = mad_get_field(mad, 0, IB_MAD_METHOD_F);
- status = mad_get_field(mad, 0, IB_MAD_STATUS_F);
-
- if (status)
- info("guid 0x%016" PRIx64 ": status %x, method %x\n",
- ntohll(list[i].guid), status, method);
- }
-
- info("rereg_query_all: %u queried.\n", cnt);
-
- free(umad);
- return 0;
-}
-
-#if 0
-static int rereg_mcm_rec_recv(int port, int agent, int cnt)
-{
- uint8_t *umad, *mad;
- int len = umad_size() + 256;
- int i;
-
- umad = calloc(1, len);
- if (!umad) {
- err("cannot alloc mem for umad: %s\n", strerror(errno));
- return -1;
- }
-
- for ( i = 0; i < cnt; i++ ) {
- int retry;
- retry = 0;
- while (umad_recv(port, umad, &len, TMO) < 0 &&
- errno == ETIMEDOUT)
- if (retry++ > 3) {
- err("umad_recv %d failed: %s\n",
- i, strerror(errno));
- free(umad);
- return -1;
- }
- dbg("umad_recv %d (retries %d), tid = 0x%016" PRIx64 ": len = %d, status = %d\n",
- i, retry,
- mad_get_field64(umad_get_mad(umad), 0, IB_MAD_TRID_F),
- len, umad_status(umad));
- mad = umad_get_mad(umad);
- }
-
- free(umad);
- return 0;
-}
-#endif
-
-#define MAX_CLIENTS 50
-
-static int rereg_and_test_port(char *guid_file, int port, int agent, ib_portid_t *dport, int timeout)
-{
- char line[256];
- FILE *f;
- ibmad_gid_t port_gid;
- uint64_t prefix = htonll(0xfe80000000000000llu);
- uint64_t guid = htonll(0x0002c90200223825llu);
- struct guid_trid *list;
- int i = 0;
-
- list = calloc(MAX_CLIENTS, sizeof(*list));
- if (!list) {
- err("cannot alloc mem for guid/trid list: %s\n", strerror(errno));
- return -1;
- }
-
- f = fopen(guid_file, "r");
- if (!f) {
- err("cannot open %s: %s\n", guid_file, strerror(errno));
- return -1;
- }
-
- while (fgets(line, sizeof(line), f)) {
- guid = strtoull(line, NULL, 0);
- guid = htonll(guid);
- memcpy(&port_gid[0], &prefix, 8);
- memcpy(&port_gid[8], &guid, 8);
-
- list[i].guid = guid;
- memcpy(list[i].gid, port_gid, sizeof(list[i].gid));
- list[i].trid = 0;
- if (++i >= MAX_CLIENTS)
- break;
- }
- fclose(f);
-
- rereg_send_all(port, agent, dport, list, i);
- rereg_recv_all(port, agent, dport, list, i);
-
- rereg_query_all(port, agent, dport, list, i);
-
- free(list);
- return 0;
-}
-
-int main(int argc, char **argv)
-{
- char *guid_file = "port_guids.list";
- int mgmt_classes[2] = {IB_SMI_CLASS, IB_SMI_DIRECT_CLASS};
- ib_portid_t dport_id;
- int port, agent;
- uint8_t *umad, *mad;
- int len;
-
- if (argc > 1)
- guid_file = argv[1];
-
- madrpc_init(NULL, 0, mgmt_classes, 2);
-
-#if 1
- ib_resolve_smlid(&dport_id, TMO);
-#else
- memset(&dport_id, 0, sizeof(dport_id));
- dport_id.lid = 1;
-#endif
- dport_id.qp = 1;
- if (!dport_id.qkey)
- dport_id.qkey = IB_DEFAULT_QP1_QKEY;
-
-
- len = umad_size() + 256;
- umad = calloc(1, len);
- if (!umad) {
- err("cannot alloc mem for umad: %s\n", strerror(errno));
- return -1;
- }
-
-#if 1
- port = madrpc_portid();
-#else
- ret = umad_init();
-
- port = umad_open_port(NULL, 0);
- if (port < 0) {
- err("umad_open_port failed: %s\n", strerror(errno));
- return port;
- }
-#endif
-
- agent = umad_register(port, IB_SA_CLASS, 2, 0, NULL);
-
-#if 0
- int cnt;
- cnt = rereg_mcm_rec_send(port, agent, &dport_id, cnt);
-
- rereg_recv_all(port, agent, &dport_id);
-#else
- rereg_and_test_port(guid_file, port, agent, &dport_id, TMO);
-#endif
- mad = umad_get_mad(umad);
-
- free(umad);
- umad_unregister(port, agent);
- umad_close_port(port);
- umad_done();
-
- return 0;
-}
diff --git a/contrib/ofed/management/infiniband-diags/src/perfquery.c b/contrib/ofed/management/infiniband-diags/src/perfquery.c
deleted file mode 100644
index 7a53e92..0000000
--- a/contrib/ofed/management/infiniband-diags/src/perfquery.c
+++ /dev/null
@@ -1,512 +0,0 @@
-/*
- * Copyright (c) 2004-2008 Voltaire Inc. All rights reserved.
- * Copyright (c) 2007 Xsigo Systems Inc. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- */
-
-#if HAVE_CONFIG_H
-# include <config.h>
-#endif /* HAVE_CONFIG_H */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <stdarg.h>
-#include <getopt.h>
-#include <netinet/in.h>
-
-#include <infiniband/common.h>
-#include <infiniband/umad.h>
-#include <infiniband/mad.h>
-
-#include "ibdiag_common.h"
-
-struct perf_count {
- uint32_t portselect;
- uint32_t counterselect;
- uint32_t symbolerrors;
- uint32_t linkrecovers;
- uint32_t linkdowned;
- uint32_t rcverrors;
- uint32_t rcvremotephyerrors;
- uint32_t rcvswrelayerrors;
- uint32_t xmtdiscards;
- uint32_t xmtconstrainterrors;
- uint32_t rcvconstrainterrors;
- uint32_t linkintegrityerrors;
- uint32_t excbufoverrunerrors;
- uint32_t vl15dropped;
- uint32_t xmtdata;
- uint32_t rcvdata;
- uint32_t xmtpkts;
- uint32_t rcvpkts;
-};
-
-struct perf_count_ext {
- uint32_t portselect;
- uint32_t counterselect;
- uint64_t portxmitdata;
- uint64_t portrcvdata;
- uint64_t portxmitpkts;
- uint64_t portrcvpkts;
- uint64_t portunicastxmitpkts;
- uint64_t portunicastrcvpkts;
- uint64_t portmulticastxmitpkits;
- uint64_t portmulticastrcvpkts;
-};
-
-static uint8_t pc[1024];
-
-struct perf_count perf_count = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
-struct perf_count_ext perf_count_ext = {0,0,0,0,0,0,0,0,0,0};
-
-char *argv0 = "perfquery";
-
-#define ALL_PORTS 0xFF
-
-static void
-usage(void)
-{
- char *basename;
-
- if (!(basename = strrchr(argv0, '/')))
- basename = argv0;
- else
- basename++;
-
- fprintf(stderr, "Usage: %s [-d(ebug) -G(uid) -a(ll_ports) -l(oop_ports) -r(eset_after_read) -C ca_name -P ca_port "
- "-R(eset_only) -t(imeout) timeout_ms -V(ersion) -h(elp)] [<lid|guid> [[port] [reset_mask]]]\n",
- basename);
- fprintf(stderr, "\tExamples:\n");
- fprintf(stderr, "\t\t%s\t\t# read local port's performance counters\n", basename);
- fprintf(stderr, "\t\t%s 32 1\t\t# read performance counters from lid 32, port 1\n", basename);
- fprintf(stderr, "\t\t%s -e 32 1\t# read extended performance counters from lid 32, port 1\n", basename);
- fprintf(stderr, "\t\t%s -a 32\t\t# read performance counters from lid 32, all ports\n", basename);
- fprintf(stderr, "\t\t%s -r 32 1\t# read performance counters and reset\n", basename);
- fprintf(stderr, "\t\t%s -e -r 32 1\t# read extended performance counters and reset\n", basename);
- fprintf(stderr, "\t\t%s -R 0x20 1\t# reset performance counters of port 1 only\n", basename);
- fprintf(stderr, "\t\t%s -e -R 0x20 1\t# reset extended performance counters of port 1 only\n", basename);
- fprintf(stderr, "\t\t%s -R -a 32\t# reset performance counters of all ports\n", basename);
- fprintf(stderr, "\t\t%s -R 32 2 0x0fff\t# reset only error counters of port 2\n", basename);
- fprintf(stderr, "\t\t%s -R 32 2 0xf000\t# reset only non-error counters of port 2\n", basename);
- exit(-1);
-}
-
-/* Notes: IB semantics is to cap counters if count has exceeded limits.
- * Therefore we must check for overflows and cap the counters if necessary.
- *
- * mad_decode_field and mad_encode_field assume 32 bit integers passed in
- * for fields < 32 bits in length.
- */
-
-static void aggregate_4bit(uint32_t *dest, uint32_t val)
-{
- if ((((*dest) + val) < (*dest))
- || ((*dest) + val) > 0xf)
- (*dest) = 0xf;
- else
- (*dest) = (*dest) + val;
-}
-
-static void aggregate_8bit(uint32_t *dest, uint32_t val)
-{
- if ((((*dest) + val) < (*dest))
- || ((*dest) + val) > 0xff)
- (*dest) = 0xff;
- else
- (*dest) = (*dest) + val;
-}
-
-static void aggregate_16bit(uint32_t *dest, uint32_t val)
-{
- if ((((*dest) + val) < (*dest))
- || ((*dest) + val) > 0xffff)
- (*dest) = 0xffff;
- else
- (*dest) = (*dest) + val;
-}
-
-static void aggregate_32bit(uint32_t *dest, uint32_t val)
-{
- if (((*dest) + val) < (*dest))
- (*dest) = 0xffffffff;
- else
- (*dest) = (*dest) + val;
-}
-
-static void aggregate_64bit(uint64_t *dest, uint64_t val)
-{
- if (((*dest) + val) < (*dest))
- (*dest) = 0xffffffffffffffffULL;
- else
- (*dest) = (*dest) + val;
-}
-
-static void aggregate_perfcounters(void)
-{
- uint32_t val;
-
- mad_decode_field(pc, IB_PC_PORT_SELECT_F, &val);
- perf_count.portselect = val;
- mad_decode_field(pc, IB_PC_COUNTER_SELECT_F, &val);
- perf_count.counterselect = val;
- mad_decode_field(pc, IB_PC_ERR_SYM_F, &val);
- aggregate_16bit(&perf_count.symbolerrors, val);
- mad_decode_field(pc, IB_PC_LINK_RECOVERS_F, &val);
- aggregate_8bit(&perf_count.linkrecovers, val);
- mad_decode_field(pc, IB_PC_LINK_DOWNED_F, &val);
- aggregate_8bit(&perf_count.linkdowned, val);
- mad_decode_field(pc, IB_PC_ERR_RCV_F, &val);
- aggregate_16bit(&perf_count.rcverrors, val);
- mad_decode_field(pc, IB_PC_ERR_PHYSRCV_F, &val);
- aggregate_16bit(&perf_count.rcvremotephyerrors, val);
- mad_decode_field(pc, IB_PC_ERR_SWITCH_REL_F, &val);
- aggregate_16bit(&perf_count.rcvswrelayerrors, val);
- mad_decode_field(pc, IB_PC_XMT_DISCARDS_F, &val);
- aggregate_16bit(&perf_count.xmtdiscards, val);
- mad_decode_field(pc, IB_PC_ERR_XMTCONSTR_F, &val);
- aggregate_8bit(&perf_count.xmtconstrainterrors, val);
- mad_decode_field(pc, IB_PC_ERR_RCVCONSTR_F, &val);
- aggregate_8bit(&perf_count.rcvconstrainterrors, val);
- mad_decode_field(pc, IB_PC_ERR_LOCALINTEG_F, &val);
- aggregate_4bit(&perf_count.linkintegrityerrors, val);
- mad_decode_field(pc, IB_PC_ERR_EXCESS_OVR_F, &val);
- aggregate_4bit(&perf_count.excbufoverrunerrors, val);
- mad_decode_field(pc, IB_PC_VL15_DROPPED_F, &val);
- aggregate_16bit(&perf_count.vl15dropped, val);
- mad_decode_field(pc, IB_PC_XMT_BYTES_F, &val);
- aggregate_32bit(&perf_count.xmtdata, val);
- mad_decode_field(pc, IB_PC_RCV_BYTES_F, &val);
- aggregate_32bit(&perf_count.rcvdata, val);
- mad_decode_field(pc, IB_PC_XMT_PKTS_F, &val);
- aggregate_32bit(&perf_count.xmtpkts, val);
- mad_decode_field(pc, IB_PC_RCV_PKTS_F, &val);
- aggregate_32bit(&perf_count.rcvpkts, val);
-}
-
-static void output_aggregate_perfcounters(ib_portid_t *portid)
-{
- char buf[1024];
- uint32_t val = ALL_PORTS;
-
- /* set port_select to 255 to emulate AllPortSelect */
- mad_encode_field(pc, IB_PC_PORT_SELECT_F, &val);
- mad_encode_field(pc, IB_PC_COUNTER_SELECT_F, &perf_count.counterselect);
- mad_encode_field(pc, IB_PC_ERR_SYM_F, &perf_count.symbolerrors);
- mad_encode_field(pc, IB_PC_LINK_RECOVERS_F, &perf_count.linkrecovers);
- mad_encode_field(pc, IB_PC_LINK_DOWNED_F, &perf_count.linkdowned);
- mad_encode_field(pc, IB_PC_ERR_RCV_F, &perf_count.rcverrors);
- mad_encode_field(pc, IB_PC_ERR_PHYSRCV_F, &perf_count.rcvremotephyerrors);
- mad_encode_field(pc, IB_PC_ERR_SWITCH_REL_F, &perf_count.rcvswrelayerrors);
- mad_encode_field(pc, IB_PC_XMT_DISCARDS_F, &perf_count.xmtdiscards);
- mad_encode_field(pc, IB_PC_ERR_XMTCONSTR_F, &perf_count.xmtconstrainterrors);
- mad_encode_field(pc, IB_PC_ERR_RCVCONSTR_F, &perf_count.rcvconstrainterrors);
- mad_encode_field(pc, IB_PC_ERR_LOCALINTEG_F, &perf_count.linkintegrityerrors);
- mad_encode_field(pc, IB_PC_ERR_EXCESS_OVR_F, &perf_count.excbufoverrunerrors);
- mad_encode_field(pc, IB_PC_VL15_DROPPED_F, &perf_count.vl15dropped);
- mad_encode_field(pc, IB_PC_XMT_BYTES_F, &perf_count.xmtdata);
- mad_encode_field(pc, IB_PC_RCV_BYTES_F, &perf_count.rcvdata);
- mad_encode_field(pc, IB_PC_XMT_PKTS_F, &perf_count.xmtpkts);
- mad_encode_field(pc, IB_PC_RCV_PKTS_F, &perf_count.rcvpkts);
-
- mad_dump_perfcounters(buf, sizeof buf, pc, sizeof pc);
-
- printf("# Port counters: %s port %d\n%s", portid2str(portid), ALL_PORTS, buf);
-}
-
-static void aggregate_perfcounters_ext(void)
-{
- uint32_t val;
- uint64_t val64;
-
- mad_decode_field(pc, IB_PC_EXT_PORT_SELECT_F, &val);
- perf_count_ext.portselect = val;
- mad_decode_field(pc, IB_PC_EXT_COUNTER_SELECT_F, &val);
- perf_count_ext.counterselect = val;
- mad_decode_field(pc, IB_PC_EXT_XMT_BYTES_F, &val64);
- aggregate_64bit(&perf_count_ext.portxmitdata, val64);
- mad_decode_field(pc, IB_PC_EXT_RCV_BYTES_F, &val64);
- aggregate_64bit(&perf_count_ext.portrcvdata, val64);
- mad_decode_field(pc, IB_PC_EXT_XMT_PKTS_F, &val64);
- aggregate_64bit(&perf_count_ext.portxmitpkts, val64);
- mad_decode_field(pc, IB_PC_EXT_RCV_PKTS_F, &val64);
- aggregate_64bit(&perf_count_ext.portrcvpkts, val64);
- mad_decode_field(pc, IB_PC_EXT_XMT_UPKTS_F, &val64);
- aggregate_64bit(&perf_count_ext.portunicastxmitpkts, val64);
- mad_decode_field(pc, IB_PC_EXT_RCV_UPKTS_F, &val64);
- aggregate_64bit(&perf_count_ext.portunicastrcvpkts, val64);
- mad_decode_field(pc, IB_PC_EXT_XMT_MPKTS_F, &val64);
- aggregate_64bit(&perf_count_ext.portmulticastxmitpkits, val64);
- mad_decode_field(pc, IB_PC_EXT_RCV_MPKTS_F, &val64);
- aggregate_64bit(&perf_count_ext.portmulticastrcvpkts, val64);
-}
-
-static void output_aggregate_perfcounters_ext(ib_portid_t *portid)
-{
- char buf[1024];
- uint32_t val = ALL_PORTS;
-
- /* set port_select to 255 to emulate AllPortSelect */
- mad_encode_field(pc, IB_PC_EXT_PORT_SELECT_F, &val);
- mad_encode_field(pc, IB_PC_EXT_COUNTER_SELECT_F, &perf_count_ext.counterselect);
- mad_encode_field(pc, IB_PC_EXT_XMT_BYTES_F, &perf_count_ext.portxmitdata);
- mad_encode_field(pc, IB_PC_EXT_RCV_BYTES_F, &perf_count_ext.portrcvdata);
- mad_encode_field(pc, IB_PC_EXT_XMT_PKTS_F, &perf_count_ext.portxmitpkts);
- mad_encode_field(pc, IB_PC_EXT_RCV_PKTS_F, &perf_count_ext.portrcvpkts);
- mad_encode_field(pc, IB_PC_EXT_XMT_UPKTS_F, &perf_count_ext.portunicastxmitpkts);
- mad_encode_field(pc, IB_PC_EXT_RCV_UPKTS_F, &perf_count_ext.portunicastrcvpkts);
- mad_encode_field(pc, IB_PC_EXT_XMT_MPKTS_F, &perf_count_ext.portmulticastxmitpkits);
- mad_encode_field(pc, IB_PC_EXT_RCV_MPKTS_F, &perf_count_ext.portmulticastrcvpkts);
-
- mad_dump_perfcounters_ext(buf, sizeof buf, pc, sizeof pc);
-
- printf("# Port counters: %s port %d\n%s", portid2str(portid), ALL_PORTS, buf);
-}
-
-static void dump_perfcounters(int extended, int timeout, uint16_t cap_mask, ib_portid_t *portid,
- int port, int aggregate)
-{
- char buf[1024];
-
- if (extended != 1) {
- if (!port_performance_query(pc, portid, port, timeout))
- IBERROR("perfquery");
- if (aggregate)
- aggregate_perfcounters();
- else
- mad_dump_perfcounters(buf, sizeof buf, pc, sizeof pc);
- } else {
- if (!(cap_mask & 0x200)) /* 1.2 errata: bit 9 is extended counter support */
- IBWARN("PerfMgt ClassPortInfo 0x%x extended counters not indicated\n", cap_mask);
-
- if (!port_performance_ext_query(pc, portid, port, timeout))
- IBERROR("perfextquery");
- if (aggregate)
- aggregate_perfcounters_ext();
- else
- mad_dump_perfcounters_ext(buf, sizeof buf, pc, sizeof pc);
- }
-
- if (!aggregate)
- printf("# Port counters: %s port %d\n%s", portid2str(portid), port, buf);
-}
-
-static void reset_counters(int extended, int timeout, int mask, ib_portid_t *portid, int port)
-{
- if (extended != 1) {
- if (!port_performance_reset(pc, portid, port, mask, timeout))
- IBERROR("perf reset");
- } else {
- if (!port_performance_ext_reset(pc, portid, port, mask, timeout))
- IBERROR("perf ext reset");
- }
-}
-
-int
-main(int argc, char **argv)
-{
- int mgmt_classes[4] = {IB_SMI_CLASS, IB_SMI_DIRECT_CLASS, IB_SA_CLASS, IB_PERFORMANCE_CLASS};
- ib_portid_t *sm_id = 0, sm_portid = {0};
- ib_portid_t portid = {0};
- extern int ibdebug;
- int dest_type = IB_DEST_LID;
- int timeout = 0; /* use default */
- int mask = 0xffff, all_ports = 0;
- int reset = 0, reset_only = 0;
- int port = 0;
- int udebug = 0;
- char *ca = 0;
- int ca_port = 0;
- int extended = 0;
- uint16_t cap_mask;
- int all_ports_loop = 0;
- int loop_ports = 0;
- int node_type, num_ports = 0;
- uint8_t data[IB_SMP_DATA_SIZE];
- int start_port = 1;
- int enhancedport0;
- int i;
-
- static char const str_opts[] = "C:P:s:t:dGealrRVhu";
- static const struct option long_opts[] = {
- { "C", 1, 0, 'C'},
- { "P", 1, 0, 'P'},
- { "debug", 0, 0, 'd'},
- { "Guid", 0, 0, 'G'},
- { "extended", 0, 0, 'e'},
- { "all_ports", 0, 0, 'a'},
- { "loop_ports", 0, 0, 'l'},
- { "reset_after_read", 0, 0, 'r'},
- { "Reset_only", 0, 0, 'R'},
- { "sm_portid", 1, 0, 's'},
- { "timeout", 1, 0, 't'},
- { "Version", 0, 0, 'V'},
- { "help", 0, 0, 'h'},
- { "usage", 0, 0, 'u'},
- { }
- };
-
- argv0 = argv[0];
-
- while (1) {
- int ch = getopt_long(argc, argv, str_opts, long_opts, NULL);
- if ( ch == -1 )
- break;
- switch(ch) {
- case 'C':
- ca = optarg;
- break;
- case 'P':
- ca_port = strtoul(optarg, 0, 0);
- break;
- case 'e':
- extended = 1;
- break;
- case 'a':
- all_ports++;
- port = ALL_PORTS;
- break;
- case 'l':
- loop_ports++;
- break;
- case 'd':
- ibdebug++;
- madrpc_show_errors(1);
- umad_debug(udebug);
- udebug++;
- break;
- case 'G':
- dest_type = IB_DEST_GUID;
- break;
- case 's':
- if (ib_resolve_portid_str(&sm_portid, optarg, IB_DEST_LID, 0) < 0)
- IBERROR("can't resolve SM destination port %s", optarg);
- sm_id = &sm_portid;
- break;
- case 'r':
- reset++;
- break;
- case 'R':
- reset_only++;
- break;
- case 't':
- timeout = strtoul(optarg, 0, 0);
- madrpc_set_timeout(timeout);
- break;
- case 'V':
- fprintf(stderr, "%s %s\n", argv0, get_build_version() );
- exit(-1);
- default:
- usage();
- break;
- }
- }
- argc -= optind;
- argv += optind;
-
- if (argc > 1)
- port = strtoul(argv[1], 0, 0);
- if (argc > 2)
- mask = strtoul(argv[2], 0, 0);
-
- madrpc_init(ca, ca_port, mgmt_classes, 4);
-
- if (argc) {
- if (ib_resolve_portid_str(&portid, argv[0], dest_type, sm_id) < 0)
- IBERROR("can't resolve destination port %s", argv[0]);
- } else {
- if (ib_resolve_self(&portid, &port, 0) < 0)
- IBERROR("can't resolve self port %s", argv[0]);
- }
-
- /* PerfMgt ClassPortInfo is a required attribute */
- if (!perf_classportinfo_query(pc, &portid, port, timeout))
- IBERROR("classportinfo query");
- /* ClassPortInfo should be supported as part of libibmad */
- memcpy(&cap_mask, pc+2, sizeof(cap_mask)); /* CapabilityMask */
- cap_mask = ntohs(cap_mask);
- if (!(cap_mask & 0x100)) { /* bit 8 is AllPortSelect */
- if (!all_ports && port == ALL_PORTS)
- IBERROR("AllPortSelect not supported");
- if (all_ports)
- all_ports_loop = 1;
- }
-
- if (all_ports_loop || (loop_ports && (all_ports || port == ALL_PORTS))) {
- if (smp_query(data, &portid, IB_ATTR_NODE_INFO, 0, 0) < 0)
- IBERROR("smp query nodeinfo failed");
- node_type = mad_get_field(data, 0, IB_NODE_TYPE_F);
- mad_decode_field(data, IB_NODE_NPORTS_F, &num_ports);
- if (!num_ports)
- IBERROR("smp query nodeinfo: num ports invalid");
-
- if (node_type == IB_NODE_SWITCH) {
- if (smp_query(data, &portid, IB_ATTR_SWITCH_INFO, 0, 0) < 0)
- IBERROR("smp query nodeinfo failed");
- enhancedport0 = mad_get_field(data, 0, IB_SW_ENHANCED_PORT0_F);
- if (enhancedport0)
- start_port = 0;
- }
- if (all_ports_loop && !loop_ports)
- IBWARN("Emulating AllPortSelect by iterating through all ports");
- }
-
- if (reset_only)
- goto do_reset;
-
- if (all_ports_loop || (loop_ports && (all_ports || port == ALL_PORTS))) {
- for (i = start_port; i <= num_ports; i++)
- dump_perfcounters(extended, timeout, cap_mask, &portid, i,
- (all_ports_loop && !loop_ports));
- if (all_ports_loop && !loop_ports) {
- if (extended != 1)
- output_aggregate_perfcounters(&portid);
- else
- output_aggregate_perfcounters_ext(&portid);
- }
- }
- else
- dump_perfcounters(extended, timeout, cap_mask, &portid, port, 0);
-
- if (!reset)
- exit(0);
-
-do_reset:
-
- if (all_ports_loop || (loop_ports && (all_ports || port == ALL_PORTS))) {
- for (i = start_port; i <= num_ports; i++)
- reset_counters(extended, timeout, mask, &portid, i);
- }
- else
- reset_counters(extended, timeout, mask, &portid, port);
-
- exit(0);
-}
diff --git a/contrib/ofed/management/infiniband-diags/src/saquery.c b/contrib/ofed/management/infiniband-diags/src/saquery.c
deleted file mode 100644
index 9f882e7..0000000
--- a/contrib/ofed/management/infiniband-diags/src/saquery.c
+++ /dev/null
@@ -1,1891 +0,0 @@
-/*
- * Copyright (c) 2006,2007 The Regents of the University of California.
- * Copyright (c) 2004-2008 Voltaire, Inc. All rights reserved.
- * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved.
- * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
- *
- * Produced at Lawrence Livermore National Laboratory.
- * Written by Ira Weiny <weiny2@llnl.gov>.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- */
-
-#include <unistd.h>
-#include <stdio.h>
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <arpa/inet.h>
-#include <assert.h>
-#include <ctype.h>
-#include <string.h>
-
-#define _GNU_SOURCE
-#include <getopt.h>
-
-#include <infiniband/mad.h>
-#include <opensm/osm_log.h>
-#include <vendor/osm_vendor_api.h>
-#include <vendor/osm_vendor_sa_api.h>
-#include <opensm/osm_mad_pool.h>
-#include <complib/cl_debug.h>
-#include <complib/cl_nodenamemap.h>
-
-#include <netinet/in.h>
-
-#include "ibdiag_common.h"
-
-struct query_cmd {
- const char *name, *alias;
- ib_net16_t query_type;
- const char *usage;
- int (*handler) (const struct query_cmd * q, osm_bind_handle_t h,
- int argc, char *argv[]);
-};
-
-char *argv0 = "saquery";
-
-static char *node_name_map_file = NULL;
-static nn_map_t *node_name_map = NULL;
-static ib_net64_t smkey = OSM_DEFAULT_SA_KEY;
-
-/**
- * Declare some globals because I don't want this to be too complex.
- */
-#define MAX_PORTS (8)
-#define DEFAULT_SA_TIMEOUT_MS (1000)
-osmv_query_res_t result;
-osm_log_t log_osm;
-osm_mad_pool_t mad_pool;
-osm_vendor_t *vendor = NULL;
-int osm_debug = 0;
-uint32_t sa_timeout_ms = DEFAULT_SA_TIMEOUT_MS;
-char *sa_hca_name = NULL;
-uint32_t sa_port_num = 0;
-
-enum {
- ALL,
- LID_ONLY,
- UNIQUE_LID_ONLY,
- GUID_ONLY,
- ALL_DESC,
- NAME_OF_LID,
- NAME_OF_GUID,
-} node_print_desc = ALL;
-
-char *requested_name = NULL;
-ib_net16_t requested_lid = 0;
-int requested_lid_flag = 0;
-ib_net64_t requested_guid = 0;
-int requested_guid_flag = 0;
-
-static void format_buf(char *in, char *out, unsigned size)
-{
- unsigned i;
-
- for (i = 0; i < size - 3 && *in; i++) {
- *out++ = *in;
- if (*in++ == '\n' && *in) {
- *out++ = '\t';
- *out++ = '\t';
- }
- }
- *out = '\0';
-}
-
-/**
- * Call back for the various record requests.
- */
-static void query_res_cb(osmv_query_res_t * res)
-{
- result = *res;
-}
-
-static void print_node_desc(ib_node_record_t * node_record)
-{
- ib_node_info_t *p_ni = &(node_record->node_info);
- ib_node_desc_t *p_nd = &(node_record->node_desc);
-
- if (p_ni->node_type == IB_NODE_TYPE_CA) {
- printf("%6d \"%s\"\n",
- cl_ntoh16(node_record->lid),
- clean_nodedesc((char *)p_nd->description));
- }
-}
-
-static void print_node_record(ib_node_record_t * node_record)
-{
- ib_node_info_t *p_ni = NULL;
- ib_node_desc_t *p_nd = NULL;
- char *name;
-
- p_ni = &(node_record->node_info);
- p_nd = &(node_record->node_desc);
-
- switch (node_print_desc) {
- case LID_ONLY:
- case UNIQUE_LID_ONLY:
- printf("%d\n", cl_ntoh16(node_record->lid));
- return;
- case GUID_ONLY:
- printf("0x%016" PRIx64 "\n", cl_ntoh64(p_ni->port_guid));
- return;
- case NAME_OF_LID:
- case NAME_OF_GUID:
- name = remap_node_name(node_name_map,
- cl_ntoh64(p_ni->node_guid),
- (char *)p_nd->description);
- printf("%s\n", name);
- free(name);
- return;
- case ALL:
- default:
- break;
- }
-
- printf("NodeRecord dump:\n"
- "\t\tlid.....................0x%X\n"
- "\t\treserved................0x%X\n"
- "\t\tbase_version............0x%X\n"
- "\t\tclass_version...........0x%X\n"
- "\t\tnode_type...............%s\n"
- "\t\tnum_ports...............0x%X\n"
- "\t\tsys_guid................0x%016" PRIx64 "\n"
- "\t\tnode_guid...............0x%016" PRIx64 "\n"
- "\t\tport_guid...............0x%016" PRIx64 "\n"
- "\t\tpartition_cap...........0x%X\n"
- "\t\tdevice_id...............0x%X\n"
- "\t\trevision................0x%X\n"
- "\t\tport_num................0x%X\n"
- "\t\tvendor_id...............0x%X\n"
- "\t\tNodeDescription.........%s\n"
- "",
- cl_ntoh16(node_record->lid),
- cl_ntoh16(node_record->resv),
- p_ni->base_version,
- p_ni->class_version,
- ib_get_node_type_str(p_ni->node_type),
- p_ni->num_ports,
- cl_ntoh64(p_ni->sys_guid),
- cl_ntoh64(p_ni->node_guid),
- cl_ntoh64(p_ni->port_guid),
- cl_ntoh16(p_ni->partition_cap),
- cl_ntoh16(p_ni->device_id),
- cl_ntoh32(p_ni->revision),
- ib_node_info_get_local_port_num(p_ni),
- cl_ntoh32(ib_node_info_get_vendor_id(p_ni)),
- clean_nodedesc((char *)node_record->node_desc.description)
- );
-}
-
-static void dump_path_record(void *data)
-{
- char gid_str[INET6_ADDRSTRLEN];
- char gid_str2[INET6_ADDRSTRLEN];
- ib_path_rec_t *p_pr = data;
- printf("PathRecord dump:\n"
- "\t\tservice_id..............0x%016" PRIx64 "\n"
- "\t\tdgid....................%s\n"
- "\t\tsgid....................%s\n"
- "\t\tdlid....................0x%X\n"
- "\t\tslid....................0x%X\n"
- "\t\thop_flow_raw............0x%X\n"
- "\t\ttclass..................0x%X\n"
- "\t\tnum_path_revers.........0x%X\n"
- "\t\tpkey....................0x%X\n"
- "\t\tqos_class...............0x%X\n"
- "\t\tsl......................0x%X\n"
- "\t\tmtu.....................0x%X\n"
- "\t\trate....................0x%X\n"
- "\t\tpkt_life................0x%X\n"
- "\t\tpreference..............0x%X\n"
- "\t\tresv2...................0x%X\n"
- "\t\tresv3...................0x%X\n"
- "",
- cl_ntoh64(p_pr->service_id),
- inet_ntop(AF_INET6, p_pr->dgid.raw, gid_str, sizeof gid_str),
- inet_ntop(AF_INET6, p_pr->sgid.raw, gid_str2, sizeof gid_str2),
- cl_ntoh16(p_pr->dlid),
- cl_ntoh16(p_pr->slid),
- cl_ntoh32(p_pr->hop_flow_raw),
- p_pr->tclass,
- p_pr->num_path,
- cl_ntoh16(p_pr->pkey),
- ib_path_rec_qos_class(p_pr),
- ib_path_rec_sl(p_pr),
- p_pr->mtu,
- p_pr->rate,
- p_pr->pkt_life,
- p_pr->preference,
- *(uint32_t *) & p_pr->resv2, *((uint16_t *) & p_pr->resv2 + 2)
- );
-}
-
-static void dump_class_port_info(void *data)
-{
- char gid_str[INET6_ADDRSTRLEN];
- char gid_str2[INET6_ADDRSTRLEN];
- ib_class_port_info_t *class_port_info = data;
-
- printf("SA ClassPortInfo:\n"
- "\t\tBase version.............%d\n"
- "\t\tClass version............%d\n"
- "\t\tCapability mask..........0x%04X\n"
- "\t\tCapability mask 2........0x%08X\n"
- "\t\tResponse time value......0x%02X\n"
- "\t\tRedirect GID.............%s\n"
- "\t\tRedirect TC/SL/FL........0x%08X\n"
- "\t\tRedirect LID.............0x%04X\n"
- "\t\tRedirect PKey............0x%04X\n"
- "\t\tRedirect QP..............0x%08X\n"
- "\t\tRedirect QKey............0x%08X\n"
- "\t\tTrap GID.................%s\n"
- "\t\tTrap TC/SL/FL............0x%08X\n"
- "\t\tTrap LID.................0x%04X\n"
- "\t\tTrap PKey................0x%04X\n"
- "\t\tTrap HL/QP...............0x%08X\n"
- "\t\tTrap QKey................0x%08X\n"
- "",
- class_port_info->base_ver,
- class_port_info->class_ver,
- cl_ntoh16(class_port_info->cap_mask),
- ib_class_cap_mask2(class_port_info),
- ib_class_resp_time_val(class_port_info),
- inet_ntop(AF_INET6, &(class_port_info->redir_gid), gid_str,
- sizeof gid_str),
- cl_ntoh32(class_port_info->redir_tc_sl_fl),
- cl_ntoh16(class_port_info->redir_lid),
- cl_ntoh16(class_port_info->redir_pkey),
- cl_ntoh32(class_port_info->redir_qp),
- cl_ntoh32(class_port_info->redir_qkey),
- inet_ntop(AF_INET6, &(class_port_info->trap_gid), gid_str2,
- sizeof gid_str2),
- cl_ntoh32(class_port_info->trap_tc_sl_fl),
- cl_ntoh16(class_port_info->trap_lid),
- cl_ntoh16(class_port_info->trap_pkey),
- cl_ntoh32(class_port_info->trap_hop_qp),
- cl_ntoh32(class_port_info->trap_qkey)
- );
-}
-
-static void dump_portinfo_record(void *data)
-{
- ib_portinfo_record_t *p_pir = data;
- const ib_port_info_t *const p_pi = &p_pir->port_info;
-
- printf("PortInfoRecord dump:\n"
- "\t\tEndPortLid..............0x%X\n"
- "\t\tPortNum.................0x%X\n"
- "\t\tbase_lid................0x%X\n"
- "\t\tmaster_sm_base_lid......0x%X\n"
- "\t\tcapability_mask.........0x%X\n"
- "",
- cl_ntoh16(p_pir->lid),
- p_pir->port_num,
- cl_ntoh16(p_pi->base_lid),
- cl_ntoh16(p_pi->master_sm_base_lid),
- cl_ntoh32(p_pi->capability_mask)
- );
-}
-
-static void dump_one_portinfo_record(void *data)
-{
- char buf[2048], buf2[4096];
- ib_portinfo_record_t *pir = data;
- ib_port_info_t *pi = &pir->port_info;
-
- mad_dump_portinfo(buf, sizeof(buf), pi, sizeof(*pi));
-
- format_buf(buf, buf2, sizeof(buf2));
-
- printf("PortInfoRecord dump:\n"
- "\tRID:\n"
- "\t\tEndPortLid..............%u\n"
- "\t\tPortNum.................0x%x\n"
- "\t\tReserved................0x%x\n"
- "\tPortInfo dump:\n\t\t%s",
- cl_ntoh16(pir->lid), pir->port_num, pir->resv, buf2);
-}
-
-static void dump_multicast_group_record(void *data)
-{
- char gid_str[INET6_ADDRSTRLEN];
- ib_member_rec_t *p_mcmr = data;
- uint8_t sl;
- ib_member_get_sl_flow_hop(p_mcmr->sl_flow_hop, &sl, NULL, NULL);
- printf("MCMemberRecord group dump:\n"
- "\t\tMGID....................%s\n"
- "\t\tMlid....................0x%X\n"
- "\t\tMtu.....................0x%X\n"
- "\t\tpkey....................0x%X\n"
- "\t\tRate....................0x%X\n"
- "\t\tSL......................0x%X\n"
- "",
- inet_ntop(AF_INET6, p_mcmr->mgid.raw, gid_str, sizeof gid_str),
- cl_ntoh16(p_mcmr->mlid),
- p_mcmr->mtu, cl_ntoh16(p_mcmr->pkey), p_mcmr->rate, sl);
-}
-
-static void dump_multicast_member_record(void *data)
-{
- char gid_str[INET6_ADDRSTRLEN];
- char gid_str2[INET6_ADDRSTRLEN];
- ib_member_rec_t *p_mcmr = data;
- uint16_t mlid = cl_ntoh16(p_mcmr->mlid);
- int i = 0;
- char *node_name = "<unknown>";
-
- /* go through the node records searching for a port guid which matches
- * this port gid interface id.
- * This gives us a node name to print, if available.
- */
- for (i = 0; i < result.result_cnt; i++) {
- ib_node_record_t *nr =
- osmv_get_query_node_rec(result.p_result_madw, i);
- if (nr->node_info.port_guid ==
- p_mcmr->port_gid.unicast.interface_id) {
- node_name =
- clean_nodedesc((char *)nr->node_desc.description);
- break;
- }
- }
-
- if (requested_name) {
- if (strtol(requested_name, NULL, 0) == mlid) {
- printf("\t\tPortGid.................%s (%s)\n",
- inet_ntop(AF_INET6, p_mcmr->port_gid.raw,
- gid_str, sizeof gid_str), node_name);
- }
- } else {
- printf("MCMemberRecord member dump:\n"
- "\t\tMGID....................%s\n"
- "\t\tMlid....................0x%X\n"
- "\t\tPortGid.................%s\n"
- "\t\tScopeState..............0x%X\n"
- "\t\tProxyJoin...............0x%X\n"
- "\t\tNodeDescription.........%s\n"
- "",
- inet_ntop(AF_INET6, p_mcmr->mgid.raw, gid_str,
- sizeof gid_str),
- cl_ntoh16(p_mcmr->mlid),
- inet_ntop(AF_INET6, p_mcmr->port_gid.raw,
- gid_str2, sizeof gid_str2),
- p_mcmr->scope_state, p_mcmr->proxy_join, node_name);
- }
-}
-
-static void dump_service_record(void *data)
-{
- char gid_str[INET6_ADDRSTRLEN];
- char buf_service_key[35];
- char buf_service_name[65];
- ib_service_record_t *p_sr = data;
-
- sprintf(buf_service_key,
- "0x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x",
- p_sr->service_key[0], p_sr->service_key[1],
- p_sr->service_key[2], p_sr->service_key[3],
- p_sr->service_key[4], p_sr->service_key[5],
- p_sr->service_key[6], p_sr->service_key[7],
- p_sr->service_key[8], p_sr->service_key[9],
- p_sr->service_key[10], p_sr->service_key[11],
- p_sr->service_key[12], p_sr->service_key[13],
- p_sr->service_key[14], p_sr->service_key[15]);
- strncpy(buf_service_name, (char *)p_sr->service_name, 64);
- buf_service_name[64] = '\0';
-
- printf("ServiceRecord dump:\n"
- "\t\tServiceID...............0x%016" PRIx64 "\n"
- "\t\tServiceGID..............%s\n"
- "\t\tServiceP_Key............0x%X\n"
- "\t\tServiceLease............0x%X\n"
- "\t\tServiceKey..............%s\n"
- "\t\tServiceName.............%s\n"
- "\t\tServiceData8.1..........0x%X\n"
- "\t\tServiceData8.2..........0x%X\n"
- "\t\tServiceData8.3..........0x%X\n"
- "\t\tServiceData8.4..........0x%X\n"
- "\t\tServiceData8.5..........0x%X\n"
- "\t\tServiceData8.6..........0x%X\n"
- "\t\tServiceData8.7..........0x%X\n"
- "\t\tServiceData8.8..........0x%X\n"
- "\t\tServiceData8.9..........0x%X\n"
- "\t\tServiceData8.10.........0x%X\n"
- "\t\tServiceData8.11.........0x%X\n"
- "\t\tServiceData8.12.........0x%X\n"
- "\t\tServiceData8.13.........0x%X\n"
- "\t\tServiceData8.14.........0x%X\n"
- "\t\tServiceData8.15.........0x%X\n"
- "\t\tServiceData8.16.........0x%X\n"
- "\t\tServiceData16.1.........0x%X\n"
- "\t\tServiceData16.2.........0x%X\n"
- "\t\tServiceData16.3.........0x%X\n"
- "\t\tServiceData16.4.........0x%X\n"
- "\t\tServiceData16.5.........0x%X\n"
- "\t\tServiceData16.6.........0x%X\n"
- "\t\tServiceData16.7.........0x%X\n"
- "\t\tServiceData16.8.........0x%X\n"
- "\t\tServiceData32.1.........0x%X\n"
- "\t\tServiceData32.2.........0x%X\n"
- "\t\tServiceData32.3.........0x%X\n"
- "\t\tServiceData32.4.........0x%X\n"
- "\t\tServiceData64.1.........0x%016" PRIx64 "\n"
- "\t\tServiceData64.2.........0x%016" PRIx64 "\n"
- "",
- cl_ntoh64(p_sr->service_id),
- inet_ntop(AF_INET6, p_sr->service_gid.raw, gid_str,
- sizeof gid_str),
- cl_ntoh16(p_sr->service_pkey),
- cl_ntoh32(p_sr->service_lease),
- buf_service_key,
- buf_service_name,
- p_sr->service_data8[0], p_sr->service_data8[1],
- p_sr->service_data8[2], p_sr->service_data8[3],
- p_sr->service_data8[4], p_sr->service_data8[5],
- p_sr->service_data8[6], p_sr->service_data8[7],
- p_sr->service_data8[8], p_sr->service_data8[9],
- p_sr->service_data8[10], p_sr->service_data8[11],
- p_sr->service_data8[12], p_sr->service_data8[13],
- p_sr->service_data8[14], p_sr->service_data8[15],
- cl_ntoh16(p_sr->service_data16[0]),
- cl_ntoh16(p_sr->service_data16[1]),
- cl_ntoh16(p_sr->service_data16[2]),
- cl_ntoh16(p_sr->service_data16[3]),
- cl_ntoh16(p_sr->service_data16[4]),
- cl_ntoh16(p_sr->service_data16[5]),
- cl_ntoh16(p_sr->service_data16[6]),
- cl_ntoh16(p_sr->service_data16[7]),
- cl_ntoh32(p_sr->service_data32[0]),
- cl_ntoh32(p_sr->service_data32[1]),
- cl_ntoh32(p_sr->service_data32[2]),
- cl_ntoh32(p_sr->service_data32[3]),
- cl_ntoh64(p_sr->service_data64[0]),
- cl_ntoh64(p_sr->service_data64[1])
- );
-}
-
-static void dump_inform_info_record(void *data)
-{
- char gid_str[INET6_ADDRSTRLEN];
- char gid_str2[INET6_ADDRSTRLEN];
- ib_inform_info_record_t *p_iir = data;
- uint32_t qpn;
- uint8_t resp_time_val;
-
- ib_inform_info_get_qpn_resp_time(p_iir->inform_info.g_or_v.generic.
- qpn_resp_time_val, &qpn,
- &resp_time_val);
-
- if (p_iir->inform_info.is_generic) {
- printf("InformInfoRecord dump:\n"
- "\t\tRID\n"
- "\t\tSubscriberGID...........%s\n"
- "\t\tSubscriberEnum..........0x%X\n"
- "\t\tInformInfo dump:\n"
- "\t\tgid.....................%s\n"
- "\t\tlid_range_begin.........0x%X\n"
- "\t\tlid_range_end...........0x%X\n"
- "\t\tis_generic..............0x%X\n"
- "\t\tsubscribe...............0x%X\n"
- "\t\ttrap_type...............0x%X\n"
- "\t\ttrap_num................%u\n"
- "\t\tqpn.....................0x%06X\n"
- "\t\tresp_time_val...........0x%X\n"
- "\t\tnode_type...............0x%06X\n"
- "",
- inet_ntop(AF_INET6, p_iir->subscriber_gid.raw, gid_str,
- sizeof gid_str),
- cl_ntoh16(p_iir->subscriber_enum),
- inet_ntop(AF_INET6, p_iir->inform_info.gid.raw, gid_str2,
- sizeof gid_str2),
- cl_ntoh16(p_iir->inform_info.lid_range_begin),
- cl_ntoh16(p_iir->inform_info.lid_range_end),
- p_iir->inform_info.is_generic,
- p_iir->inform_info.subscribe,
- cl_ntoh16(p_iir->inform_info.trap_type),
- cl_ntoh16(p_iir->inform_info.g_or_v.generic.trap_num),
- cl_ntoh32(qpn),
- resp_time_val,
- cl_ntoh32(ib_inform_info_get_prod_type
- (&p_iir->inform_info))
- );
- } else {
- printf("InformInfoRecord dump:\n"
- "\t\tRID\n"
- "\t\tSubscriberGID...........%s\n"
- "\t\tSubscriberEnum..........0x%X\n"
- "\t\tInformInfo dump:\n"
- "\t\tgid.....................%s\n"
- "\t\tlid_range_begin.........0x%X\n"
- "\t\tlid_range_end...........0x%X\n"
- "\t\tis_generic..............0x%X\n"
- "\t\tsubscribe...............0x%X\n"
- "\t\ttrap_type...............0x%X\n"
- "\t\tdev_id..................0x%X\n"
- "\t\tqpn.....................0x%06X\n"
- "\t\tresp_time_val...........0x%X\n"
- "\t\tvendor_id...............0x%06X\n"
- "",
- inet_ntop(AF_INET6, p_iir->subscriber_gid.raw, gid_str,
- sizeof gid_str),
- cl_ntoh16(p_iir->subscriber_enum),
- inet_ntop(AF_INET6, p_iir->inform_info.gid.raw,
- gid_str2, sizeof gid_str2),
- cl_ntoh16(p_iir->inform_info.lid_range_begin),
- cl_ntoh16(p_iir->inform_info.lid_range_end),
- p_iir->inform_info.is_generic,
- p_iir->inform_info.subscribe,
- cl_ntoh16(p_iir->inform_info.trap_type),
- cl_ntoh16(p_iir->inform_info.g_or_v.vend.dev_id),
- cl_ntoh32(qpn),
- resp_time_val,
- cl_ntoh32(ib_inform_info_get_prod_type
- (&p_iir->inform_info))
- );
- }
-}
-
-static void dump_one_link_record(void *data)
-{
- ib_link_record_t *lr = data;
- printf("LinkRecord dump:\n"
- "\t\tFromLID....................%u\n"
- "\t\tFromPort...................%u\n"
- "\t\tToPort.....................%u\n"
- "\t\tToLID......................%u\n",
- cl_ntoh16(lr->from_lid), lr->from_port_num,
- lr->to_port_num, cl_ntoh16(lr->to_lid));
-}
-
-static void dump_one_slvl_record(void *data)
-{
- ib_slvl_table_record_t *slvl = data;
- ib_slvl_table_t *t = &slvl->slvl_tbl;
- printf("SL2VLTableRecord dump:\n"
- "\t\tLID........................%u\n"
- "\t\tInPort.....................%u\n"
- "\t\tOutPort....................%u\n"
- "\t\tSL: 0| 1| 2| 3| 4| 5| 6| 7| 8| 9|10|11|12|13|14|15|\n"
- "\t\tVL:%2u|%2u|%2u|%2u|%2u|%2u|%2u|%2u|%2u|%2u|%2u|%2u|%2u"
- "|%2u|%2u|%2u|\n",
- cl_ntoh16(slvl->lid), slvl->in_port_num, slvl->out_port_num,
- ib_slvl_table_get(t, 0), ib_slvl_table_get(t, 1),
- ib_slvl_table_get(t, 2), ib_slvl_table_get(t, 3),
- ib_slvl_table_get(t, 4), ib_slvl_table_get(t, 5),
- ib_slvl_table_get(t, 6), ib_slvl_table_get(t, 7),
- ib_slvl_table_get(t, 8), ib_slvl_table_get(t, 9),
- ib_slvl_table_get(t, 10), ib_slvl_table_get(t, 11),
- ib_slvl_table_get(t, 12), ib_slvl_table_get(t, 13),
- ib_slvl_table_get(t, 14), ib_slvl_table_get(t, 15));
-}
-
-static void dump_one_vlarb_record(void *data)
-{
- ib_vl_arb_table_record_t *vlarb = data;
- ib_vl_arb_element_t *e = vlarb->vl_arb_tbl.vl_entry;
- int i;
- printf("VLArbTableRecord dump:\n"
- "\t\tLID........................%u\n"
- "\t\tPort.......................%u\n"
- "\t\tBlock......................%u\n",
- cl_ntoh16(vlarb->lid), vlarb->port_num, vlarb->block_num);
- for (i = 0; i < 32; i += 16) {
- printf("\t\tVL :%2u|%2u|%2u|%2u|%2u|%2u|%2u|%2u|"
- "%2u|%2u|%2u|%2u|%2u|%2u|%2u|%2u|",
- e[i + 0].vl, e[i + 1].vl, e[i + 2].vl, e[i + 3].vl,
- e[i + 4].vl, e[i + 5].vl, e[i + 6].vl, e[i + 7].vl,
- e[i + 8].vl, e[i + 9].vl, e[i + 10].vl, e[i + 11].vl,
- e[i + 12].vl, e[i + 13].vl, e[i + 14].vl, e[i + 15].vl);
- printf("\n\t\tWeight:%2u|%2u|%2u|%2u|%2u|%2u|%2u|%2u|"
- "%2u|%2u|%2u|%2u|%2u|%2u|%2u|%2u|",
- e[i + 0].weight, e[i + 1].weight, e[i + 2].weight,
- e[i + 3].weight, e[i + 4].weight, e[i + 5].weight,
- e[i + 6].weight, e[i + 7].weight, e[i + 8].weight,
- e[i + 9].weight, e[i + 10].weight, e[i + 11].weight,
- e[i + 12].weight, e[i + 13].weight, e[i + 14].weight,
- e[i + 15].weight);
- printf("\n");
- }
-}
-
-static void dump_one_pkey_tbl_record(void *data)
-{
- ib_pkey_table_record_t *pktr = data;
- ib_net16_t *p = pktr->pkey_tbl.pkey_entry;
- int i;
- printf("PKeyTableRecord dump:\n"
- "\t\tLID........................%u\n"
- "\t\tPort.......................%u\n"
- "\t\tBlock......................%u\n"
- "\t\tPKey Table:\n",
- cl_ntoh16(pktr->lid), pktr->port_num, pktr->block_num);
- for (i = 0; i < 32; i += 8)
- printf("\t\t0x%04x 0x%04x 0x%04x 0x%04x"
- " 0x%04x 0x%04x 0x%04x 0x%04x\n",
- cl_ntoh16(p[i + 0]), cl_ntoh16(p[i + 1]),
- cl_ntoh16(p[i + 2]), cl_ntoh16(p[i + 3]),
- cl_ntoh16(p[i + 4]), cl_ntoh16(p[i + 5]),
- cl_ntoh16(p[i + 6]), cl_ntoh16(p[i + 7]));
- printf("\n");
-}
-
-static void dump_one_lft_record(void *data)
-{
- ib_lft_record_t *lftr = data;
- unsigned block = cl_ntoh16(lftr->block_num);
- int i;
- printf("LFT Record dump:\n"
- "\t\tLID........................%u\n"
- "\t\tBlock......................%u\n"
- "\t\tLFT:\n\t\tLID\tPort Number\n", cl_ntoh16(lftr->lid), block);
- for (i = 0; i < 64; i++)
- printf("\t\t%u\t%u\n", block * 64 + i, lftr->lft[i]);
- printf("\n");
-}
-
-static void dump_one_mft_record(void *data)
-{
- ib_mft_record_t *mftr = data;
- unsigned position = cl_ntoh16(mftr->position_block_num) >> 12;
- unsigned block = cl_ntoh16(mftr->position_block_num) &
- IB_MCAST_BLOCK_ID_MASK_HO;
- int i;
- printf("MFT Record dump:\n"
- "\t\tLID........................%u\n"
- "\t\tPosition...................%u\n"
- "\t\tBlock......................%u\n"
- "\t\tMFT:\n\t\tMLID\tPort Mask\n",
- cl_ntoh16(mftr->lid), position, block);
- for (i = 0; i < IB_MCAST_BLOCK_SIZE; i++)
- printf("\t\t0x%x\t0x%x\n",
- IB_LID_MCAST_START_HO + block * 64 + i,
- cl_ntoh16(mftr->mft[i]));
- printf("\n");
-}
-static void dump_results(osmv_query_res_t * r, void (*dump_func) (void *))
-{
- int i;
- for (i = 0; i < r->result_cnt; i++) {
- void *data = osmv_get_query_result(r->p_result_madw, i);
- dump_func(data);
- }
-}
-
-static void return_mad(void)
-{
- /*
- * Return the IB query MAD to the pool as necessary.
- */
- if (result.p_result_madw != NULL) {
- osm_mad_pool_put(&mad_pool, result.p_result_madw);
- result.p_result_madw = NULL;
- }
-}
-
-/**
- * Get any record(s)
- */
-static ib_api_status_t
-get_any_records(osm_bind_handle_t h,
- ib_net16_t attr_id, ib_net32_t attr_mod, ib_net64_t comp_mask,
- void *attr, ib_net16_t attr_offset, ib_net64_t sm_key)
-{
- ib_api_status_t status;
- osmv_query_req_t req;
- osmv_user_query_t user;
-
- memset(&req, 0, sizeof(req));
- memset(&user, 0, sizeof(user));
-
- user.attr_id = attr_id;
- user.attr_offset = attr_offset;
- user.attr_mod = attr_mod;
- user.comp_mask = comp_mask;
- user.p_attr = attr;
-
- req.query_type = OSMV_QUERY_USER_DEFINED;
- req.timeout_ms = sa_timeout_ms;
- req.retry_cnt = 1;
- req.flags = OSM_SA_FLAGS_SYNC;
- req.query_context = NULL;
- req.pfn_query_cb = query_res_cb;
- req.p_query_input = &user;
- req.sm_key = sm_key;
-
- if ((status = osmv_query_sa(h, &req)) != IB_SUCCESS) {
- fprintf(stderr, "Query SA failed: %s\n",
- ib_get_err_str(status));
- return status;
- }
-
- if (result.status != IB_SUCCESS) {
- fprintf(stderr, "Query result returned: %s\n",
- ib_get_err_str(result.status));
- return result.status;
- }
-
- return status;
-}
-
-/**
- * Get all the records available for requested query type.
- */
-static ib_api_status_t
-get_all_records(osm_bind_handle_t h,
- ib_net16_t query_id, ib_net16_t attr_offset, int trusted)
-{
- return get_any_records(h, query_id, 0, 0, NULL, attr_offset,
- trusted ? smkey : 0);
-}
-
-/**
- * return the lid from the node descriptor (name) supplied
- */
-static ib_api_status_t
-get_lid_from_name(osm_bind_handle_t h, const char *name, ib_net16_t * lid)
-{
- int i = 0;
- ib_node_record_t *node_record = NULL;
- ib_node_info_t *p_ni = NULL;
- ib_net16_t attr_offset = ib_get_attr_offset(sizeof(*node_record));
- ib_api_status_t status;
-
- status = get_all_records(h, IB_MAD_ATTR_NODE_RECORD, attr_offset, 0);
- if (status != IB_SUCCESS)
- return (status);
-
- for (i = 0; i < result.result_cnt; i++) {
- node_record = osmv_get_query_node_rec(result.p_result_madw, i);
- p_ni = &(node_record->node_info);
- if (name
- && strncmp(name, (char *)node_record->node_desc.description,
- sizeof(node_record->node_desc.description)) ==
- 0) {
- *lid = cl_ntoh16(node_record->lid);
- break;
- }
- }
- return_mad();
- return (status);
-}
-
-static ib_net16_t get_lid(osm_bind_handle_t h, const char *name)
-{
- ib_net16_t rc_lid = 0;
-
- if (!name)
- return (0);
- if (isalpha(name[0]))
- assert(get_lid_from_name(h, name, &rc_lid) == IB_SUCCESS);
- else
- rc_lid = atoi(name);
- if (rc_lid == 0)
- fprintf(stderr, "Failed to find lid for \"%s\"\n", name);
- return (rc_lid);
-}
-
-static int parse_lid_and_ports(osm_bind_handle_t h,
- char *str, int *lid, int *port1, int *port2)
-{
- char *p, *e;
-
- if (port1)
- *port1 = -1;
- if (port2)
- *port2 = -1;
-
- p = strchr(str, '/');
- if (p)
- *p = '\0';
- if (lid)
- *lid = get_lid(h, str);
-
- if (!p)
- return 0;
- str = p + 1;
- p = strchr(str, '/');
- if (p)
- *p = '\0';
- if (port1) {
- *port1 = strtoul(str, &e, 0);
- if (e == str)
- *port1 = -1;
- }
-
- if (!p)
- return 0;
- str = p + 1;
- if (port2) {
- *port2 = strtoul(str, &e, 0);
- if (e == str)
- *port2 = -1;
- }
-
- return 0;
-}
-
-/*
- * Get the portinfo records available with IsSM or IsSMdisabled CapabilityMask bit on.
- */
-static ib_api_status_t
-get_issm_records(osm_bind_handle_t h, ib_net32_t capability_mask)
-{
- ib_portinfo_record_t attr;
-
- memset(&attr, 0, sizeof(attr));
- attr.port_info.capability_mask = capability_mask;
-
- return get_any_records(h, IB_MAD_ATTR_PORTINFO_RECORD,
- cl_hton32(1 << 31), IB_PIR_COMPMASK_CAPMASK,
- &attr,
- ib_get_attr_offset(sizeof(ib_portinfo_record_t)),
- 0);
-}
-
-static ib_api_status_t print_node_records(osm_bind_handle_t h)
-{
- int i = 0;
- ib_node_record_t *node_record = NULL;
- ib_net16_t attr_offset = ib_get_attr_offset(sizeof(*node_record));
- ib_api_status_t status;
-
- status = get_all_records(h, IB_MAD_ATTR_NODE_RECORD, attr_offset, 0);
- if (status != IB_SUCCESS)
- return (status);
-
- if (node_print_desc == ALL_DESC) {
- printf(" LID \"name\"\n");
- printf("================\n");
- }
- for (i = 0; i < result.result_cnt; i++) {
- node_record = osmv_get_query_node_rec(result.p_result_madw, i);
- if (node_print_desc == ALL_DESC) {
- print_node_desc(node_record);
- } else if (node_print_desc == NAME_OF_LID) {
- if (requested_lid == cl_ntoh16(node_record->lid)) {
- print_node_record(node_record);
- }
- } else if (node_print_desc == NAME_OF_GUID) {
- ib_node_info_t *p_ni = &(node_record->node_info);
-
- if (requested_guid == cl_ntoh64(p_ni->port_guid)) {
- print_node_record(node_record);
- }
- } else {
- if (!requested_name ||
- (strncmp(requested_name,
- (char *)node_record->node_desc.description,
- sizeof(node_record->node_desc.
- description)) == 0)) {
- print_node_record(node_record);
- if (node_print_desc == UNIQUE_LID_ONLY) {
- return_mad();
- exit(0);
- }
- }
- }
- }
- return_mad();
- return (status);
-}
-
-static ib_api_status_t
-get_print_path_rec_lid(osm_bind_handle_t h,
- ib_net16_t src_lid, ib_net16_t dst_lid)
-{
- osmv_query_req_t req;
- osmv_lid_pair_t lid_pair;
- ib_api_status_t status;
-
- lid_pair.src_lid = cl_hton16(src_lid);
- lid_pair.dest_lid = cl_hton16(dst_lid);
-
- memset(&req, 0, sizeof(req));
-
- req.query_type = OSMV_QUERY_PATH_REC_BY_LIDS;
- req.timeout_ms = sa_timeout_ms;
- req.retry_cnt = 1;
- req.flags = OSM_SA_FLAGS_SYNC;
- req.query_context = NULL;
- req.pfn_query_cb = query_res_cb;
- req.p_query_input = (void *)&lid_pair;
- req.sm_key = 0;
-
- if ((status = osmv_query_sa(h, &req)) != IB_SUCCESS) {
- fprintf(stderr, "ERROR: Query SA failed: %s\n",
- ib_get_err_str(status));
- return (status);
- }
- if (result.status != IB_SUCCESS) {
- fprintf(stderr, "ERROR: Query result returned: %s\n",
- ib_get_err_str(result.status));
- return (result.status);
- }
- status = result.status;
- dump_results(&result, dump_path_record);
- return_mad();
- return (status);
-}
-
-static ib_api_status_t
-get_print_path_rec_gid(osm_bind_handle_t h,
- const ib_gid_t * src_gid, const ib_gid_t * dst_gid)
-{
- osmv_query_req_t req;
- osmv_gid_pair_t gid_pair;
- ib_api_status_t status;
-
- gid_pair.src_gid = *src_gid;
- gid_pair.dest_gid = *dst_gid;
-
- memset(&req, 0, sizeof(req));
-
- req.query_type = OSMV_QUERY_PATH_REC_BY_GIDS;
- req.timeout_ms = sa_timeout_ms;
- req.retry_cnt = 1;
- req.flags = OSM_SA_FLAGS_SYNC;
- req.query_context = NULL;
- req.pfn_query_cb = query_res_cb;
- req.p_query_input = (void *)&gid_pair;
- req.sm_key = 0;
-
- if ((status = osmv_query_sa(h, &req)) != IB_SUCCESS) {
- fprintf(stderr, "ERROR: Query SA failed: %s\n",
- ib_get_err_str(status));
- return (status);
- }
- if (result.status != IB_SUCCESS) {
- fprintf(stderr, "ERROR: Query result returned: %s\n",
- ib_get_err_str(result.status));
- return (result.status);
- }
- status = result.status;
- dump_results(&result, dump_path_record);
- return_mad();
- return (status);
-}
-
-static ib_api_status_t get_print_class_port_info(osm_bind_handle_t h)
-{
- osmv_query_req_t req;
- ib_api_status_t status;
-
- memset(&req, 0, sizeof(req));
-
- req.query_type = OSMV_QUERY_CLASS_PORT_INFO;
- req.timeout_ms = sa_timeout_ms;
- req.retry_cnt = 1;
- req.flags = OSM_SA_FLAGS_SYNC;
- req.query_context = NULL;
- req.pfn_query_cb = query_res_cb;
- req.p_query_input = NULL;
- req.sm_key = 0;
-
- if ((status = osmv_query_sa(h, &req)) != IB_SUCCESS) {
- fprintf(stderr, "ERROR: Query SA failed: %s\n",
- ib_get_err_str(status));
- return (status);
- }
- if (result.status != IB_SUCCESS) {
- fprintf(stderr, "ERROR: Query result returned: %s\n",
- ib_get_err_str(result.status));
- return (result.status);
- }
- status = result.status;
- dump_results(&result, dump_class_port_info);
- return_mad();
- return (status);
-}
-
-static int query_path_records(const struct query_cmd *q,
- osm_bind_handle_t h, int argc, char *argv[])
-{
- ib_net16_t attr_offset = ib_get_attr_offset(sizeof(ib_path_rec_t));
- ib_api_status_t status;
-
- status = get_all_records(h, IB_MAD_ATTR_PATH_RECORD, attr_offset, 0);
- if (status != IB_SUCCESS)
- return (status);
-
- dump_results(&result, dump_path_record);
- return_mad();
- return (status);
-}
-
-static ib_api_status_t print_issm_records(osm_bind_handle_t h)
-{
- ib_api_status_t status;
-
- /* First, get IsSM records */
- status = get_issm_records(h, IB_PORT_CAP_IS_SM);
- if (status != IB_SUCCESS)
- return (status);
-
- printf("IsSM ports\n");
- dump_results(&result, dump_portinfo_record);
- return_mad();
-
- /* Now, get IsSMdisabled records */
- status = get_issm_records(h, IB_PORT_CAP_SM_DISAB);
- if (status != IB_SUCCESS)
- return (status);
-
- printf("\nIsSMdisabled ports\n");
- dump_results(&result, dump_portinfo_record);
- return_mad();
-
- return (status);
-}
-
-static ib_api_status_t print_multicast_member_records(osm_bind_handle_t h)
-{
- osmv_query_res_t mc_group_result;
- ib_api_status_t status;
-
- status = get_all_records(h, IB_MAD_ATTR_MCMEMBER_RECORD,
- ib_get_attr_offset(sizeof(ib_member_rec_t)),
- 1);
- if (status != IB_SUCCESS)
- return (status);
-
- mc_group_result = result;
-
- status = get_all_records(h, IB_MAD_ATTR_NODE_RECORD,
- ib_get_attr_offset(sizeof(ib_node_record_t)),
- 0);
- if (status != IB_SUCCESS)
- goto return_mc;
-
- dump_results(&mc_group_result, dump_multicast_member_record);
- return_mad();
-
-return_mc:
- /* return_mad for the mc_group_result */
- if (mc_group_result.p_result_madw != NULL) {
- osm_mad_pool_put(&mad_pool, mc_group_result.p_result_madw);
- mc_group_result.p_result_madw = NULL;
- }
-
- return (status);
-}
-
-static ib_api_status_t print_multicast_group_records(osm_bind_handle_t h)
-{
- ib_api_status_t status;
-
- status = get_all_records(h, IB_MAD_ATTR_MCMEMBER_RECORD,
- ib_get_attr_offset(sizeof(ib_member_rec_t)),
- 0);
- if (status != IB_SUCCESS)
- return (status);
-
- dump_results(&result, dump_multicast_group_record);
- return_mad();
- return (status);
-}
-
-static int query_class_port_info(const struct query_cmd *q,
- osm_bind_handle_t h, int argc, char *argv[])
-{
- return get_print_class_port_info(h);
-}
-
-static int query_node_records(const struct query_cmd *q,
- osm_bind_handle_t h, int argc, char *argv[])
-{
- return print_node_records(h);
-}
-
-static int query_portinfo_records(const struct query_cmd *q,
- osm_bind_handle_t h, int argc, char *argv[])
-{
- ib_portinfo_record_t pir;
- ib_net64_t comp_mask = 0;
- int lid = 0, port = -1;
- ib_api_status_t status;
-
- if (argc > 0)
- parse_lid_and_ports(h, argv[0], &lid, &port, NULL);
-
- memset(&pir, 0, sizeof(pir));
-
- if (lid > 0) {
- pir.lid = cl_hton16(lid);
- comp_mask |= IB_PIR_COMPMASK_LID;
- }
- if (port >= 0) {
- pir.port_num = cl_hton16(port);
- comp_mask |= IB_PIR_COMPMASK_PORTNUM;
- }
-
- status = get_any_records(h, IB_MAD_ATTR_PORTINFO_RECORD, 0,
- comp_mask, &pir,
- ib_get_attr_offset(sizeof(pir)), 0);
-
- if (status != IB_SUCCESS)
- return status;
-
- dump_results(&result, dump_one_portinfo_record);
- return_mad();
-
- return 0;
-}
-
-static int query_mcmember_records(const struct query_cmd *q,
- osm_bind_handle_t h, int argc, char *argv[])
-{
- return print_multicast_member_records(h);
-}
-
-static int query_service_records(const struct query_cmd *q,
- osm_bind_handle_t h, int argc, char *argv[])
-{
- ib_net16_t attr_offset =
- ib_get_attr_offset(sizeof(ib_service_record_t));
- ib_api_status_t status;
-
- status = get_all_records(h, IB_MAD_ATTR_SERVICE_RECORD, attr_offset, 0);
- if (status != IB_SUCCESS)
- return (status);
-
- dump_results(&result, dump_service_record);
- return_mad();
- return (status);
-}
-
-static int query_informinfo_records(const struct query_cmd *q,
- osm_bind_handle_t h, int argc, char *argv[])
-{
- ib_net16_t attr_offset =
- ib_get_attr_offset(sizeof(ib_inform_info_record_t));
- ib_api_status_t status;
-
- status =
- get_all_records(h, IB_MAD_ATTR_INFORM_INFO_RECORD, attr_offset, 0);
- if (status != IB_SUCCESS)
- return (status);
-
- dump_results(&result, dump_inform_info_record);
- return_mad();
- return (status);
-}
-
-static int query_link_records(const struct query_cmd *q,
- osm_bind_handle_t h, int argc, char *argv[])
-{
- ib_link_record_t lr;
- ib_net64_t comp_mask = 0;
- int from_lid = 0, to_lid = 0, from_port = -1, to_port = -1;
- ib_api_status_t status;
-
- if (argc > 0)
- parse_lid_and_ports(h, argv[0], &from_lid, &from_port, NULL);
-
- if (argc > 1)
- parse_lid_and_ports(h, argv[1], &to_lid, &to_port, NULL);
-
- memset(&lr, 0, sizeof(lr));
-
- if (from_lid > 0) {
- lr.from_lid = cl_hton16(from_lid);
- comp_mask |= IB_LR_COMPMASK_FROM_LID;
- }
- if (from_port >= 0) {
- lr.from_port_num = from_port;
- comp_mask |= IB_LR_COMPMASK_FROM_PORT;
- }
- if (to_lid > 0) {
- lr.to_lid = cl_hton16(to_lid);
- comp_mask |= IB_LR_COMPMASK_TO_LID;
- }
- if (to_port >= 0) {
- lr.to_port_num = to_port;
- comp_mask |= IB_LR_COMPMASK_TO_PORT;
- }
-
- status = get_any_records(h, IB_MAD_ATTR_LINK_RECORD, 0,
- comp_mask, &lr,
- ib_get_attr_offset(sizeof(lr)), 0);
- if (status != IB_SUCCESS)
- return status;
-
- dump_results(&result, dump_one_link_record);
- return_mad();
- return status;
-}
-
-static int query_sl2vl_records(const struct query_cmd *q,
- osm_bind_handle_t h, int argc, char *argv[])
-{
- ib_slvl_table_record_t slvl;
- ib_net64_t comp_mask = 0;
- int lid = 0, in_port = -1, out_port = -1;
- ib_api_status_t status;
-
- if (argc > 0)
- parse_lid_and_ports(h, argv[0], &lid, &in_port, &out_port);
-
- memset(&slvl, 0, sizeof(slvl));
-
- if (lid > 0) {
- slvl.lid = cl_hton16(lid);
- comp_mask |= IB_SLVL_COMPMASK_LID;
- }
- if (in_port >= 0) {
- slvl.in_port_num = in_port;
- comp_mask |= IB_SLVL_COMPMASK_IN_PORT;
- }
- if (out_port >= 0) {
- slvl.out_port_num = out_port;
- comp_mask |= IB_SLVL_COMPMASK_OUT_PORT;
- }
-
- status = get_any_records(h, IB_MAD_ATTR_SLVL_RECORD, 0,
- comp_mask, &slvl,
- ib_get_attr_offset(sizeof(slvl)), 0);
- if (status != IB_SUCCESS)
- return status;
-
- dump_results(&result, dump_one_slvl_record);
- return_mad();
- return status;
-}
-
-static int query_vlarb_records(const struct query_cmd *q,
- osm_bind_handle_t h, int argc, char *argv[])
-{
- ib_vl_arb_table_record_t vlarb;
- ib_net64_t comp_mask = 0;
- int lid = 0, port = -1, block = -1;
- ib_api_status_t status;
-
- if (argc > 0)
- parse_lid_and_ports(h, argv[0], &lid, &port, &block);
-
- memset(&vlarb, 0, sizeof(vlarb));
-
- if (lid > 0) {
- vlarb.lid = cl_hton16(lid);
- comp_mask |= IB_VLA_COMPMASK_LID;
- }
- if (port >= 0) {
- vlarb.port_num = port;
- comp_mask |= IB_VLA_COMPMASK_OUT_PORT;
- }
- if (block >= 0) {
- vlarb.block_num = block;
- comp_mask |= IB_VLA_COMPMASK_BLOCK;
- }
-
- status = get_any_records(h, IB_MAD_ATTR_VLARB_RECORD, 0,
- comp_mask, &vlarb,
- ib_get_attr_offset(sizeof(vlarb)), 0);
- if (status != IB_SUCCESS)
- return status;
-
- dump_results(&result, dump_one_vlarb_record);
- return_mad();
- return status;
-}
-
-static int query_pkey_tbl_records(const struct query_cmd *q,
- osm_bind_handle_t h, int argc, char *argv[])
-{
- ib_pkey_table_record_t pktr;
- ib_net64_t comp_mask = 0;
- int lid = 0, port = -1, block = -1;
- ib_api_status_t status;
-
- if (argc > 0)
- parse_lid_and_ports(h, argv[0], &lid, &port, &block);
-
- memset(&pktr, 0, sizeof(pktr));
-
- if (lid > 0) {
- pktr.lid = cl_hton16(lid);
- comp_mask |= IB_PKEY_COMPMASK_LID;
- }
- if (port >= 0) {
- pktr.port_num = port;
- comp_mask |= IB_PKEY_COMPMASK_PORT;
- }
- if (block >= 0) {
- pktr.block_num = block;
- comp_mask |= IB_PKEY_COMPMASK_BLOCK;
- }
-
- status = get_any_records(h, IB_MAD_ATTR_PKEY_TBL_RECORD, 0,
- comp_mask, &pktr,
- ib_get_attr_offset(sizeof(pktr)), smkey);
- if (status != IB_SUCCESS)
- return status;
-
- dump_results(&result, dump_one_pkey_tbl_record);
- return_mad();
- return status;
-}
-
-static int query_lft_records(const struct query_cmd *q,
- osm_bind_handle_t h, int argc, char *argv[])
-{
- ib_lft_record_t lftr;
- ib_net64_t comp_mask = 0;
- int lid = 0, block = -1;
- ib_api_status_t status;
-
- if (argc > 0)
- parse_lid_and_ports(h, argv[0], &lid, &block, NULL);
-
- memset(&lftr, 0, sizeof(lftr));
-
- if (lid > 0) {
- lftr.lid = cl_hton16(lid);
- comp_mask |= IB_LFTR_COMPMASK_LID;
- }
- if (block >= 0) {
- lftr.block_num = cl_hton16(block);
- comp_mask |= IB_LFTR_COMPMASK_BLOCK;
- }
-
- status = get_any_records(h, IB_MAD_ATTR_LFT_RECORD, 0,
- comp_mask, &lftr,
- ib_get_attr_offset(sizeof(lftr)), 0);
- if (status != IB_SUCCESS)
- return status;
-
- dump_results(&result, dump_one_lft_record);
- return_mad();
- return status;
-}
-
-static int query_mft_records(const struct query_cmd *q,
- osm_bind_handle_t h, int argc, char *argv[])
-{
- ib_mft_record_t mftr;
- ib_net64_t comp_mask = 0;
- int lid = 0, block = -1, position = -1;
- ib_api_status_t status;
-
- if (argc > 0)
- parse_lid_and_ports(h, argv[0], &lid, &position, &block);
-
- memset(&mftr, 0, sizeof(mftr));
-
- if (lid > 0) {
- mftr.lid = cl_hton16(lid);
- comp_mask |= IB_MFTR_COMPMASK_LID;
- }
- if (position >= 0) {
- mftr.position_block_num = cl_hton16(position << 12);
- comp_mask |= IB_MFTR_COMPMASK_POSITION;
- }
- if (block >= 0) {
- mftr.position_block_num |=
- cl_hton16(block & IB_MCAST_BLOCK_ID_MASK_HO);
- comp_mask |= IB_MFTR_COMPMASK_BLOCK;
- }
-
- status = get_any_records(h, IB_MAD_ATTR_MFT_RECORD, 0,
- comp_mask, &mftr,
- ib_get_attr_offset(sizeof(mftr)), 0);
- if (status != IB_SUCCESS)
- return status;
-
- dump_results(&result, dump_one_mft_record);
- return_mad();
- return status;
-}
-
-static osm_bind_handle_t get_bind_handle(void)
-{
- uint32_t i = 0;
- uint64_t port_guid = (uint64_t) - 1;
- osm_bind_handle_t h;
- ib_api_status_t status;
- ib_port_attr_t attr_array[MAX_PORTS];
- uint32_t num_ports = MAX_PORTS;
- uint32_t ca_name_index = 0;
-
- complib_init();
-
- osm_log_construct(&log_osm);
- if ((status = osm_log_init_v2(&log_osm, TRUE, 0x0001, NULL,
- 0, TRUE)) != IB_SUCCESS) {
- fprintf(stderr, "Failed to init osm_log: %s\n",
- ib_get_err_str(status));
- exit(-1);
- }
- osm_log_set_level(&log_osm, OSM_LOG_NONE);
- if (osm_debug)
- osm_log_set_level(&log_osm, OSM_LOG_DEFAULT_LEVEL);
-
- vendor = osm_vendor_new(&log_osm, sa_timeout_ms);
- osm_mad_pool_construct(&mad_pool);
- if ((status = osm_mad_pool_init(&mad_pool)) != IB_SUCCESS) {
- fprintf(stderr, "Failed to init mad pool: %s\n",
- ib_get_err_str(status));
- exit(-1);
- }
-
- if ((status =
- osm_vendor_get_all_port_attr(vendor, attr_array,
- &num_ports)) != IB_SUCCESS) {
- fprintf(stderr, "Failed to get port attributes: %s\n",
- ib_get_err_str(status));
- exit(-1);
- }
-
- for (i = 0; i < num_ports; i++) {
- if (i > 1 && cl_ntoh64(attr_array[i].port_guid)
- != (cl_ntoh64(attr_array[i - 1].port_guid) + 1))
- ca_name_index++;
- if (sa_port_num && sa_port_num != attr_array[i].port_num)
- continue;
- if (sa_hca_name
- && strcmp(sa_hca_name,
- vendor->ca_names[ca_name_index]) != 0)
- continue;
- if (attr_array[i].link_state == IB_LINK_ACTIVE) {
- port_guid = attr_array[i].port_guid;
- break;
- }
- }
-
- if (port_guid == (uint64_t) - 1) {
- fprintf(stderr,
- "Failed to find active port, check port status with \"ibstat\"\n");
- exit(-1);
- }
-
- h = osmv_bind_sa(vendor, &mad_pool, port_guid);
-
- if (h == OSM_BIND_INVALID_HANDLE) {
- fprintf(stderr, "Failed to bind to SA\n");
- exit(-1);
- }
- return h;
-}
-
-static void clean_up(void)
-{
- osm_mad_pool_destroy(&mad_pool);
- osm_vendor_delete(&vendor);
-}
-
-static const struct query_cmd query_cmds[] = {
- {"ClassPortInfo", "CPI", IB_MAD_ATTR_CLASS_PORT_INFO,
- NULL, query_class_port_info},
- {"NodeRecord", "NR", IB_MAD_ATTR_NODE_RECORD,
- NULL, query_node_records},
- {"PortInfoRecord", "PIR", IB_MAD_ATTR_PORTINFO_RECORD,
- "[[lid]/[port]]", query_portinfo_records},
- {"SL2VLTableRecord", "SL2VL", IB_MAD_ATTR_SLVL_RECORD,
- "[[lid]/[in_port]/[out_port]]", query_sl2vl_records},
- {"PKeyTableRecord", "PKTR", IB_MAD_ATTR_PKEY_TBL_RECORD,
- "[[lid]/[port]/[block]]", query_pkey_tbl_records},
- {"VLArbitrationTableRecord", "VLAR", IB_MAD_ATTR_VLARB_RECORD,
- "[[lid]/[port]/[block]]", query_vlarb_records},
- {"InformInfoRecord", "IIR", IB_MAD_ATTR_INFORM_INFO_RECORD,
- NULL, query_informinfo_records},
- {"LinkRecord", "LR", IB_MAD_ATTR_LINK_RECORD,
- "[[from_lid]/[from_port]] [[to_lid]/[to_port]]", query_link_records},
- {"ServiceRecord", "SR", IB_MAD_ATTR_SERVICE_RECORD,
- NULL, query_service_records},
- {"PathRecord", "PR", IB_MAD_ATTR_PATH_RECORD,
- NULL, query_path_records},
- {"MCMemberRecord", "MCMR", IB_MAD_ATTR_MCMEMBER_RECORD,
- NULL, query_mcmember_records},
- {"LFTRecord", "LFTR", IB_MAD_ATTR_LFT_RECORD,
- "[[lid]/[block]]", query_lft_records},
- {"MFTRecord", "MFTR", IB_MAD_ATTR_MFT_RECORD,
- "[[mlid]/[position]/[block]]", query_mft_records},
- {0}
-};
-
-static const struct query_cmd *find_query(const char *name)
-{
- const struct query_cmd *q;
- unsigned len = strlen(name);
-
- for (q = query_cmds; q->name; q++)
- if (!strncasecmp(name, q->name, len) ||
- (q->alias && !strncasecmp(name, q->alias, len)))
- return q;
-
- return NULL;
-}
-
-static const struct query_cmd *find_query_by_type(ib_net16_t type)
-{
- const struct query_cmd *q;
-
- for (q = query_cmds; q->name; q++)
- if (q->query_type == type)
- return q;
-
- return NULL;
-}
-
-static void usage(void)
-{
- const struct query_cmd *q;
-
- fprintf(stderr, "Usage: %s [-h -d -p -N] [--list | -D] [-S -I -L -l -G"
- " -O -U -c -s -g -m --src-to-dst <src:dst> --sgid-to-dgid <src-dst> "
- "-C <ca_name> -P <ca_port> -t(imeout) <msec>] [query-name] [<name> | <lid> | <guid>]\n",
- argv0);
- fprintf(stderr, " Queries node records by default\n");
- fprintf(stderr, " -d enable debugging\n");
- fprintf(stderr, " -p get PathRecord info\n");
- fprintf(stderr, " -N get NodeRecord info\n");
- fprintf(stderr, " --list | -D the node desc of the CA's\n");
- fprintf(stderr, " -S get ServiceRecord info\n");
- fprintf(stderr, " -I get InformInfoRecord (subscription) info\n");
- fprintf(stderr, " -L return the Lids of the name specified\n");
- fprintf(stderr, " -l return the unique Lid of the name specified\n");
- fprintf(stderr, " -G return the Guids of the name specified\n");
- fprintf(stderr, " -O return name for the Lid specified\n");
- fprintf(stderr, " -U return name for the Guid specified\n");
- fprintf(stderr, " -c get the SA's class port info\n");
- fprintf(stderr, " -s return the PortInfoRecords with isSM or "
- "isSMdisabled capability mask bit on\n");
- fprintf(stderr, " -g get multicast group info\n");
- fprintf(stderr, " -m get multicast member info\n");
- fprintf(stderr, " (if multicast group specified, list member GIDs"
- " only for group specified\n");
- fprintf(stderr, " specified, for example 'saquery -m 0xC000')\n");
- fprintf(stderr, " -x get LinkRecord info\n");
- fprintf(stderr, " --src-to-dst get a PathRecord for <src:dst>\n"
- " where src and dst are either node "
- "names or LIDs\n");
- fprintf(stderr, " --sgid-to-dgid get a PathRecord for <sgid-dgid>\n"
- " where sgid and dgid are addresses in "
- "IPv6 format\n");
- fprintf(stderr, " -C <ca_name> specify the SA query HCA\n");
- fprintf(stderr, " -P <ca_port> specify the SA query port\n");
- fprintf(stderr, " --smkey <val> specify SM_Key value for the query."
- " If non-numeric value \n"
- " (like 'x') is specified then "
- "saquery will prompt for a value\n");
- fprintf(stderr, " -t | --timeout <msec> specify the SA query "
- "response timeout (default %u msec)\n", DEFAULT_SA_TIMEOUT_MS);
- fprintf(stderr,
- " --node-name-map <node-name-map> specify a node name map\n");
- fprintf(stderr, "\n Supported query names (and aliases):\n");
- for (q = query_cmds; q->name; q++)
- fprintf(stderr, " %s (%s) %s\n", q->name,
- q->alias ? q->alias : "", q->usage ? q->usage : "");
- fprintf(stderr, "\n");
-
- exit(-1);
-}
-
-enum saquery_command {
- SAQUERY_CMD_QUERY,
- SAQUERY_CMD_NODE_RECORD,
- SAQUERY_CMD_PATH_RECORD,
- SAQUERY_CMD_CLASS_PORT_INFO,
- SAQUERY_CMD_ISSM,
- SAQUERY_CMD_MCGROUPS,
- SAQUERY_CMD_MCMEMBERS,
-};
-
-int main(int argc, char **argv)
-{
- int ch = 0;
- osm_bind_handle_t h;
- enum saquery_command command = SAQUERY_CMD_QUERY;
- const struct query_cmd *q = NULL;
- char *src = NULL, *dst = NULL;
- char *sgid = NULL, *dgid = NULL;
- ib_net16_t query_type = 0;
- ib_net16_t src_lid, dst_lid;
- ib_api_status_t status;
-
- static char const str_opts[] = "pVNDLlGOUcSIsgmxdhP:C:t:";
- static const struct option long_opts[] = {
- {"p", 0, 0, 'p'},
- {"Version", 0, 0, 'V'},
- {"N", 0, 0, 'N'},
- {"L", 0, 0, 'L'},
- {"l", 0, 0, 'l'},
- {"G", 0, 0, 'G'},
- {"O", 0, 0, 'O'},
- {"U", 0, 0, 'U'},
- {"s", 0, 0, 's'},
- {"g", 0, 0, 'g'},
- {"m", 0, 0, 'm'},
- {"x", 0, 0, 'x'},
- {"d", 0, 0, 'd'},
- {"c", 0, 0, 'c'},
- {"S", 0, 0, 'S'},
- {"I", 0, 0, 'I'},
- {"P", 1, 0, 'P'},
- {"C", 1, 0, 'C'},
- {"help", 0, 0, 'h'},
- {"list", 0, 0, 'D'},
- {"src-to-dst", 1, 0, 1},
- {"sgid-to-dgid", 1, 0, 2},
- {"timeout", 1, 0, 't'},
- {"node-name-map", 1, 0, 3},
- {"smkey", 1, 0, 4},
- {}
- };
-
- argv0 = argv[0];
-
- while ((ch = getopt_long(argc, argv, str_opts, long_opts, NULL)) != -1) {
- switch (ch) {
- case 1:
- {
- char *opt = strdup(optarg);
- char *ch = strchr(opt, ':');
- if (!ch) {
- fprintf(stderr,
- "ERROR: --src-to-dst <node>:<node>\n");
- usage();
- }
- *ch++ = '\0';
- if (*opt)
- src = strdup(opt);
- if (*ch)
- dst = strdup(ch);
- free(opt);
- command = SAQUERY_CMD_PATH_RECORD;
- break;
- }
- case 2:
- {
- char *opt = strdup(optarg);
- char *tok1 = strtok(opt, "-");
- char *tok2 = strtok(NULL, "\0");
-
- if (tok1 && tok2) {
- sgid = strdup(tok1);
- dgid = strdup(tok2);
- } else {
- fprintf(stderr,
- "ERROR: --sgid-to-dgid <GID>-<GID>\n");
- usage();
- }
- free(opt);
- command = SAQUERY_CMD_PATH_RECORD;
- break;
- }
- case 3:
- node_name_map_file = strdup(optarg);
- break;
- case 4:
- if (!isxdigit(*optarg) &&
- !(optarg = getpass("SM_Key: "))) {
- fprintf(stderr, "cannot get SM_Key\n");
- usage();
- }
- smkey = cl_hton64(strtoull(optarg, NULL, 0));
- break;
- case 'p':
- command = SAQUERY_CMD_PATH_RECORD;
- break;
- case 'V':
- fprintf(stderr, "%s %s\n", argv0, get_build_version());
- exit(-1);
- case 'D':
- node_print_desc = ALL_DESC;
- break;
- case 'c':
- command = SAQUERY_CMD_CLASS_PORT_INFO;
- break;
- case 'S':
- query_type = IB_MAD_ATTR_SERVICE_RECORD;
- break;
- case 'I':
- query_type = IB_MAD_ATTR_INFORM_INFO_RECORD;
- break;
- case 'N':
- command = SAQUERY_CMD_NODE_RECORD;
- break;
- case 'L':
- node_print_desc = LID_ONLY;
- break;
- case 'l':
- node_print_desc = UNIQUE_LID_ONLY;
- break;
- case 'G':
- node_print_desc = GUID_ONLY;
- break;
- case 'O':
- node_print_desc = NAME_OF_LID;
- break;
- case 'U':
- node_print_desc = NAME_OF_GUID;
- break;
- case 's':
- command = SAQUERY_CMD_ISSM;
- break;
- case 'g':
- command = SAQUERY_CMD_MCGROUPS;
- break;
- case 'm':
- command = SAQUERY_CMD_MCMEMBERS;
- break;
- case 'x':
- query_type = IB_MAD_ATTR_LINK_RECORD;
- break;
- case 'd':
- osm_debug = 1;
- break;
- case 'C':
- sa_hca_name = optarg;
- break;
- case 'P':
- sa_port_num = strtoul(optarg, NULL, 0);
- break;
- case 't':
- sa_timeout_ms = strtoul(optarg, NULL, 0);
- break;
- case 'h':
- default:
- usage();
- }
- }
- argc -= optind;
- argv += optind;
-
- if (!query_type) {
- if (!argc || !(q = find_query(argv[0])))
- query_type = IB_MAD_ATTR_NODE_RECORD;
- else {
- query_type = q->query_type;
- argc--;
- argv++;
- }
- }
-
- if (argc) {
- if (node_print_desc == NAME_OF_LID) {
- requested_lid = (ib_net16_t) strtoul(argv[0], NULL, 0);
- requested_lid_flag++;
- } else if (node_print_desc == NAME_OF_GUID) {
- requested_guid = (ib_net64_t) strtoul(argv[0], NULL, 0);
- requested_guid_flag++;
- } else {
- requested_name = argv[0];
- }
- }
-
- if ((node_print_desc == LID_ONLY ||
- node_print_desc == UNIQUE_LID_ONLY ||
- node_print_desc == GUID_ONLY) && !requested_name) {
- fprintf(stderr, "ERROR: name not specified\n");
- usage();
- }
-
- if (node_print_desc == NAME_OF_LID && !requested_lid_flag) {
- fprintf(stderr, "ERROR: lid not specified\n");
- usage();
- }
-
- if (node_print_desc == NAME_OF_GUID && !requested_guid_flag) {
- fprintf(stderr, "ERROR: guid not specified\n");
- usage();
- }
-
- /* Note: lid cannot be 0; see infiniband spec 4.1.3 */
- if (node_print_desc == NAME_OF_LID && !requested_lid) {
- fprintf(stderr, "ERROR: lid invalid\n");
- usage();
- }
-
- h = get_bind_handle();
- node_name_map = open_node_name_map(node_name_map_file);
-
- switch (command) {
- case SAQUERY_CMD_NODE_RECORD:
- status = print_node_records(h);
- break;
- case SAQUERY_CMD_PATH_RECORD:
- if (src && dst) {
- src_lid = get_lid(h, src);
- dst_lid = get_lid(h, dst);
- printf("Path record for %s -> %s\n", src, dst);
- if (src_lid == 0 || dst_lid == 0) {
- status = IB_UNKNOWN_ERROR;
- } else {
- status =
- get_print_path_rec_lid(h, src_lid, dst_lid);
- }
- } else if (sgid && dgid) {
- struct in6_addr src_addr, dst_addr;
-
- if (inet_pton(AF_INET6, sgid, &src_addr) <= 0) {
- fprintf(stderr, "invalid src gid: %s\n", sgid);
- exit(-1);
- }
- if (inet_pton(AF_INET6, dgid, &dst_addr) <= 0) {
- fprintf(stderr, "invalid dst gid: %s\n", dgid);
- exit(-1);
- }
- status = get_print_path_rec_gid(h,
- (ib_gid_t *) & src_addr.s6_addr,
- (ib_gid_t *) & dst_addr.s6_addr);
- } else {
- status = query_path_records(q, h, 0, NULL);
- }
- break;
- case SAQUERY_CMD_CLASS_PORT_INFO:
- status = get_print_class_port_info(h);
- break;
- case SAQUERY_CMD_ISSM:
- status = print_issm_records(h);
- break;
- case SAQUERY_CMD_MCGROUPS:
- status = print_multicast_group_records(h);
- break;
- case SAQUERY_CMD_MCMEMBERS:
- status = print_multicast_member_records(h);
- break;
- default:
- if ((!q && !(q = find_query_by_type(query_type)))
- || !q->handler) {
- fprintf(stderr, "Unknown query type %d\n",
- ntohs(query_type));
- status = IB_UNKNOWN_ERROR;
- } else
- status = q->handler(q, h, argc, argv);
- break;
- }
-
- if (src)
- free(src);
- if (dst)
- free(dst);
- clean_up();
- close_node_name_map(node_name_map);
- return (status);
-}
diff --git a/contrib/ofed/management/infiniband-diags/src/sminfo.c b/contrib/ofed/management/infiniband-diags/src/sminfo.c
deleted file mode 100644
index a8144ac..0000000
--- a/contrib/ofed/management/infiniband-diags/src/sminfo.c
+++ /dev/null
@@ -1,206 +0,0 @@
-/*
- * Copyright (c) 2004-2008 Voltaire Inc. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- */
-
-#if HAVE_CONFIG_H
-# include <config.h>
-#endif /* HAVE_CONFIG_H */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <stdarg.h>
-#include <inttypes.h>
-#include <getopt.h>
-
-#include <infiniband/common.h>
-#include <infiniband/umad.h>
-#include <infiniband/mad.h>
-
-#include "ibdiag_common.h"
-
-static uint8_t sminfo[1024];
-
-char *argv0 = "sminfo";
-
-static void
-usage(void)
-{
- fprintf(stderr, "Usage: %s [-d(ebug) -e(rr_show) -s state -p prio -a activity -D(irect) -G(uid) -V(ersion) -C ca_name -P ca_port "
- "-t(imeout) timeout_ms] <sm_lid|sm_dr_path> [modifier]\n",
- argv0);
- exit(-1);
-}
-
-int strdata, xdata=1, bindata;
-enum {
- SMINFO_NOTACT,
- SMINFO_DISCOVER,
- SMINFO_STANDBY,
- SMINFO_MASTER,
-
- SMINFO_STATE_LAST,
-};
-
-char *statestr[] = {
- [SMINFO_NOTACT] = "SMINFO_NOTACT",
- [SMINFO_DISCOVER] = "SMINFO_DISCOVER",
- [SMINFO_STANDBY] = "SMINFO_STANDBY",
- [SMINFO_MASTER] = "SMINFO_MASTER",
-};
-
-#define STATESTR(s) (((unsigned)(s)) < SMINFO_STATE_LAST ? statestr[s] : "???")
-
-int
-main(int argc, char **argv)
-{
- int mgmt_classes[3] = {IB_SMI_CLASS, IB_SMI_DIRECT_CLASS, IB_SA_CLASS};
- int mod = 0;
- ib_portid_t portid = {0};
- int timeout = 0; /* use default */
- uint8_t *p;
- unsigned act = 0;
- int prio = 0, state = SMINFO_STANDBY;
- uint64_t guid = 0, key = 0;
- extern int ibdebug;
- int dest_type = IB_DEST_LID;
- int udebug = 0;
- char *ca = 0;
- int ca_port = 0;
-
- static char const str_opts[] = "C:P:t:s:p:a:deDGVhu";
- static const struct option long_opts[] = {
- { "C", 1, 0, 'C'},
- { "P", 1, 0, 'P'},
- { "debug", 0, 0, 'd'},
- { "err_show", 0, 0, 'e'},
- { "s", 1, 0, 's'},
- { "p", 1, 0, 'p'},
- { "a", 1, 0, 'a'},
- { "Direct", 0, 0, 'D'},
- { "Guid", 0, 0, 'G'},
- { "Version", 0, 0, 'V'},
- { "timeout", 1, 0, 't'},
- { "help", 0, 0, 'h'},
- { "usage", 0, 0, 'u'},
- { }
- };
-
- argv0 = argv[0];
-
- while (1) {
- int ch = getopt_long(argc, argv, str_opts, long_opts, NULL);
- if ( ch == -1 )
- break;
- switch(ch) {
- case 'C':
- ca = optarg;
- break;
- case 'P':
- ca_port = strtoul(optarg, 0, 0);
- break;
- case 'd':
- ibdebug++;
- madrpc_show_errors(1);
- umad_debug(udebug);
- udebug++;
- break;
- case 'e':
- madrpc_show_errors(1);
- break;
- case 'D':
- dest_type = IB_DEST_DRPATH;
- break;
- case 'G':
- dest_type = IB_DEST_GUID;
- break;
- case 't':
- timeout = strtoul(optarg, 0, 0);
- madrpc_set_timeout(timeout);
- break;
- case 'a':
- act = strtoul(optarg, 0, 0);
- break;
- case 's':
- state = strtoul(optarg, 0, 0);
- break;
- case 'p':
- prio = strtoul(optarg, 0, 0);
- break;
- case 'V':
- fprintf(stderr, "%s %s\n", argv0, get_build_version() );
- exit(-1);
- default:
- usage();
- break;
- }
- }
- argc -= optind;
- argv += optind;
-
- if (argc > 1)
- mod = atoi(argv[1]);
-
- madrpc_init(ca, ca_port, mgmt_classes, 3);
-
- if (argc) {
- if (ib_resolve_portid_str(&portid, argv[0], dest_type, 0) < 0)
- IBERROR("can't resolve destination port %s", argv[0]);
- } else {
- if (ib_resolve_smlid(&portid, timeout) < 0)
- IBERROR("can't resolve sm port %s", argv[0]);
- }
-
- mad_encode_field(sminfo, IB_SMINFO_GUID_F, &guid);
- mad_encode_field(sminfo, IB_SMINFO_ACT_F, &act);
- mad_encode_field(sminfo, IB_SMINFO_KEY_F, &key);
- mad_encode_field(sminfo, IB_SMINFO_PRIO_F, &prio);
- mad_encode_field(sminfo, IB_SMINFO_STATE_F, &state);
-
- if (mod) {
- if (!(p = smp_set(sminfo, &portid, IB_ATTR_SMINFO, mod, timeout)))
- IBERROR("query");
- } else
- if (!(p = smp_query(sminfo, &portid, IB_ATTR_SMINFO, 0, timeout)))
- IBERROR("query");
-
- mad_decode_field(sminfo, IB_SMINFO_GUID_F, &guid);
- mad_decode_field(sminfo, IB_SMINFO_ACT_F, &act);
- mad_decode_field(sminfo, IB_SMINFO_KEY_F, &key);
- mad_decode_field(sminfo, IB_SMINFO_PRIO_F, &prio);
- mad_decode_field(sminfo, IB_SMINFO_STATE_F, &state);
-
- printf("sminfo: sm lid %d sm guid 0x%" PRIx64 ", activity count %u priority %d state %d %s\n",
- portid.lid, guid, act, prio, state, STATESTR(state));
-
- exit(0);
-}
diff --git a/contrib/ofed/management/infiniband-diags/src/smpdump.c b/contrib/ofed/management/infiniband-diags/src/smpdump.c
deleted file mode 100644
index de2ee8d..0000000
--- a/contrib/ofed/management/infiniband-diags/src/smpdump.c
+++ /dev/null
@@ -1,354 +0,0 @@
-/*
- * Copyright (c) 2004-2008 Voltaire Inc. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- */
-
-#define _GNU_SOURCE
-
-#if HAVE_CONFIG_H
-# include <config.h>
-#endif /* HAVE_CONFIG_H */
-
-#include <inttypes.h>
-#include <string.h>
-#include <errno.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <stdarg.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <sys/ioctl.h>
-#include <unistd.h>
-#include <getopt.h>
-#include <endian.h>
-#include <byteswap.h>
-#include <sys/poll.h>
-#include <syslog.h>
-#include <netinet/in.h>
-
-#include <infiniband/common.h>
-#include <infiniband/mad.h>
-#include <infiniband/umad.h>
-
-#include <ibdiag_common.h>
-
-static const uint8_t CLASS_SUBN_DIRECTED_ROUTE = 0x81;
-static const uint8_t CLASS_SUBN_LID_ROUTE = 0x1;
-
-#define ATTR_NODE_DESC ((uint16_t)(htons(0x10)))
-#define ATTR_NODE_INFO ((uint16_t)(htons(0x11)))
-#define ATTR_PORT_INFO ((uint16_t)(htons(0x15)))
-
-static int mad_agent;
-static int drmad_tid = 0x123;
-
-static int debug, verbose;
-
-char *argv0 = "smpdump";
-
-typedef struct {
- char path[64];
- int hop_cnt;
-} DRPath;
-
-struct drsmp {
- uint8_t base_version;
- uint8_t mgmt_class;
- uint8_t class_version;
- uint8_t method;
- uint16_t status;
- uint8_t hop_ptr;
- uint8_t hop_cnt;
- uint64_t tid;
- uint16_t attr_id;
- uint16_t resv;
- uint32_t attr_mod;
- uint64_t mkey;
- uint16_t dr_slid;
- uint16_t dr_dlid;
- uint8_t reserved[28];
- uint8_t data[64];
- uint8_t initial_path[64];
- uint8_t return_path[64];
-};
-
-void
-drsmp_get_init(void *umad, DRPath *path, int attr, int mod)
-{
- struct drsmp *smp = (struct drsmp *)(umad_get_mad(umad));
-
- memset(smp, 0, sizeof (*smp));
-
- smp->base_version = 1;
- smp->mgmt_class = CLASS_SUBN_DIRECTED_ROUTE;
- smp->class_version = 1;
-
- smp->method = 1;
- smp->attr_id = (uint16_t)htons((uint16_t)attr);
- smp->attr_mod = htonl(mod);
- smp->tid = htonll(drmad_tid++);
- smp->dr_slid = 0xffff;
- smp->dr_dlid = 0xffff;
-
- umad_set_addr(umad, 0xffff, 0, 0, 0);
-
- if (path)
- memcpy(smp->initial_path, path->path, path->hop_cnt+1);
-
- smp->hop_cnt = path->hop_cnt;
-}
-
-void
-smp_get_init(void *umad, int lid, int attr, int mod)
-{
- struct drsmp *smp = (struct drsmp *)(umad_get_mad(umad));
-
- memset(smp, 0, sizeof (*smp));
-
- smp->base_version = 1;
- smp->mgmt_class = CLASS_SUBN_LID_ROUTE;
- smp->class_version = 1;
-
- smp->method = 1;
- smp->attr_id = (uint16_t)htons((uint16_t)attr);
- smp->attr_mod = htonl(mod);
- smp->tid = htonll(drmad_tid++);
-
- umad_set_addr(umad, lid, 0, 0xffff, 0);
-}
-
-void
-drsmp_set_init(void *umad, DRPath *path, int attr, int mod, void *data)
-{
- struct drsmp *smp = (struct drsmp *)(umad_get_mad(umad));
-
- memset(smp, 0, sizeof (*smp));
-
- smp->method = 2; /* SET */
- smp->attr_id = (uint16_t)htons((uint16_t)attr);
- smp->attr_mod = htonl(mod);
- smp->tid = htonll(drmad_tid++);
- smp->dr_slid = 0xffff;
- smp->dr_dlid = 0xffff;
-
- umad_set_addr(umad, 0xffff, 0, 0, 0);
-
- if (path)
- memcpy(smp->initial_path, path->path, path->hop_cnt+1);
-
- if (data)
- memcpy(smp->data, data, sizeof smp->data);
-
- smp->hop_cnt = path->hop_cnt;
-}
-
-char *
-drmad_status_str(struct drsmp *drsmp)
-{
- switch (drsmp->status) {
- case 0:
- return "success";
- case ETIMEDOUT:
- return "timeout";
- }
- return "unknown error";
-}
-
-int
-str2DRPath(char *str, DRPath *path)
-{
- char *s;
-
- path->hop_cnt = -1;
-
- DEBUG("DR str: %s", str);
- while (str && *str) {
- if ((s = strchr(str, ',')))
- *s = 0;
- path->path[++path->hop_cnt] = atoi(str);
- if (!s)
- break;
- str = s+1;
- }
-
-#if 0
- if (path->path[0] != 0 ||
- (path->hop_cnt > 0 && dev_port && path->path[1] != dev_port)) {
- DEBUG("hop 0 != 0 or hop 1 != dev_port");
- return -1;
- }
-#endif
-
- return path->hop_cnt;
-}
-
-void
-usage(void)
-{
- fprintf(stderr, "Usage: %s [-s(ring) -D(irect) -V(ersion) -C ca_name -P ca_port -t(imeout) timeout_ms] <dlid|dr_path> <attr> [mod]\n", argv0);
- fprintf(stderr, "\tDR examples:\n");
- fprintf(stderr, "\t\t%s -D 0,1,2,3,5 16 # NODE DESC\n", argv0);
- fprintf(stderr, "\t\t%s -D 0,1,2 0x15 2 # PORT INFO, port 2\n", argv0);
- fprintf(stderr, "\n\tLID routed examples:\n");
- fprintf(stderr, "\t\t%s 3 0x15 2 # PORT INFO, lid 3 port 2\n", argv0);
- fprintf(stderr, "\t\t%s 0xa0 0x11 # NODE INFO, lid 0xa0\n", argv0);
- fprintf(stderr, "\n");
- exit(-1);
-}
-
-int
-main(int argc, char *argv[])
-{
- int dump_char = 0, timeout_ms = 1000;
- int dev_port = 0, mgmt_class = CLASS_SUBN_LID_ROUTE, dlid = 0;
- char *dev_name = 0;
- void *umad;
- struct drsmp *smp;
- int i, portid, mod = 0, attr;
- DRPath path;
- uint8_t *desc;
- int length;
-
- static char const str_opts[] = "C:P:t:dsDVhu";
- static const struct option long_opts[] = {
- { "C", 1, 0, 'C'},
- { "P", 1, 0, 'P'},
- { "debug", 0, 0, 'd'},
- { "sring", 0, 0, 's'},
- { "Direct", 0, 0, 'D'},
- { "timeout", 1, 0, 't'},
- { "Version", 0, 0, 'V'},
- { "help", 0, 0, 'h'},
- { "usage", 0, 0, 'u'},
- { }
- };
-
- argv0 = argv[0];
-
- while (1) {
- int ch = getopt_long(argc, argv, str_opts, long_opts, NULL);
- if ( ch == -1 )
- break;
- switch(ch) {
- case 's':
- dump_char++;
- break;
- case 'd':
- debug++;
- if (debug > 1)
- umad_debug(debug-1);
- break;
- case 'D':
- mgmt_class = CLASS_SUBN_DIRECTED_ROUTE;
- break;
- case 'C':
- dev_name = optarg;
- break;
- case 'P':
- dev_port = atoi(optarg);
- break;
- case 't':
- timeout_ms = strtoul(optarg, 0, 0);
- break;
- case 'V':
- fprintf(stderr, "%s %s\n", argv0, get_build_version() );
- exit(-1);
- default:
- usage();
- break;
- }
- }
- argc -= optind;
- argv += optind;
-
- if (argc < 2)
- usage();
-
- if (mgmt_class == CLASS_SUBN_DIRECTED_ROUTE &&
- str2DRPath(strdup(argv[0]), &path) < 0)
- IBPANIC("bad path str '%s'", argv[0]);
-
- if (mgmt_class == CLASS_SUBN_LID_ROUTE)
- dlid = strtoul(argv[0], 0, 0);
-
- attr = strtoul(argv[1], 0, 0);
- if (argc > 2)
- mod = strtoul(argv[2], 0, 0);
-
- if (umad_init() < 0)
- IBPANIC("can't init UMAD library");
-
- if ((portid = umad_open_port(dev_name, dev_port)) < 0)
- IBPANIC("can't open UMAD port (%s:%d)", dev_name, dev_port);
-
- if ((mad_agent = umad_register(portid, mgmt_class, 1, 0, 0)) < 0)
- IBPANIC("Couldn't register agent for SMPs");
-
- if (!(umad = umad_alloc(1, umad_size() + IB_MAD_SIZE)))
- IBPANIC("can't alloc MAD");
-
- smp = umad_get_mad(umad);
-
- if (mgmt_class == CLASS_SUBN_DIRECTED_ROUTE)
- drsmp_get_init(umad, &path, attr, mod);
- else
- smp_get_init(umad, dlid, attr, mod);
-
- if (debug > 1)
- xdump(stderr, "before send:\n", smp, 256);
-
- length = IB_MAD_SIZE;
- if (umad_send(portid, mad_agent, umad, length, timeout_ms, 0) < 0)
- IBPANIC("send failed");
-
- if (umad_recv(portid, umad, &length, -1) != mad_agent)
- IBPANIC("recv error: %s", drmad_status_str(smp));
-
- if (!dump_char) {
- xdump(stdout, 0, smp->data, 64);
- if (smp->status)
- fprintf(stdout, "SMP status: 0x%x\n", ntohs(smp->status));
- return 0;
- }
-
- desc = smp->data;
- for (i = 0; i < 64; ++i) {
- if (!desc[i])
- break;
- putchar(desc[i]);
- }
- putchar('\n');
- if (smp->status)
- fprintf(stdout, "SMP status: 0x%x\n", ntohs(smp->status));
- return 0;
-}
diff --git a/contrib/ofed/management/infiniband-diags/src/smpquery.c b/contrib/ofed/management/infiniband-diags/src/smpquery.c
deleted file mode 100644
index 01ccfaf..0000000
--- a/contrib/ofed/management/infiniband-diags/src/smpquery.c
+++ /dev/null
@@ -1,538 +0,0 @@
-/*
- * Copyright (c) 2004-2008 Voltaire Inc. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- */
-
-#if HAVE_CONFIG_H
-# include <config.h>
-#endif /* HAVE_CONFIG_H */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <stdarg.h>
-#include <time.h>
-#include <string.h>
-#include <getopt.h>
-#include <netinet/in.h>
-
-#define __STDC_FORMAT_MACROS
-#include <inttypes.h>
-
-#include <infiniband/common.h>
-#include <infiniband/umad.h>
-#include <infiniband/mad.h>
-#include <complib/cl_nodenamemap.h>
-
-#include "ibdiag_common.h"
-
-#undef DEBUG
-#define DEBUG if (verbose>1) IBWARN
-
-static int dest_type = IB_DEST_LID;
-static int verbose;
-
-typedef char *(op_fn_t)(ib_portid_t *dest, char **argv, int argc);
-
-typedef struct match_rec {
- char *name;
- op_fn_t *fn;
- unsigned opt_portnum;
-} match_rec_t;
-
-static op_fn_t node_desc, node_info, port_info, switch_info, pkey_table,
- sl2vl_table, vlarb_table, guid_info;
-
-static const match_rec_t match_tbl[] = {
- { "nodeinfo", node_info },
- { "nodedesc", node_desc },
- { "portinfo", port_info, 1 },
- { "switchinfo", switch_info },
- { "pkeys", pkey_table, 1 },
- { "sl2vl", sl2vl_table, 1 },
- { "vlarb", vlarb_table, 1 },
- { "guids", guid_info },
- {0}
-};
-
-char *argv0 = "smpquery";
-static char *node_name_map_file = NULL;
-static nn_map_t *node_name_map = NULL;
-
-/*******************************************/
-static char *
-node_desc(ib_portid_t *dest, char **argv, int argc)
-{
- int node_type, l;
- uint64_t node_guid;
- char nd[IB_SMP_DATA_SIZE];
- uint8_t data[IB_SMP_DATA_SIZE];
- char dots[128];
- char *nodename = NULL;
-
- if (!smp_query(data, dest, IB_ATTR_NODE_INFO, 0, 0))
- return "node info query failed";
-
- mad_decode_field(data, IB_NODE_TYPE_F, &node_type);
- mad_decode_field(data, IB_NODE_GUID_F, &node_guid);
-
- if (!smp_query(nd, dest, IB_ATTR_NODE_DESC, 0, 0))
- return "node desc query failed";
-
- nodename = remap_node_name(node_name_map, node_guid, nd);
-
- l = strlen(nodename);
- if (l < 32) {
- memset(dots, '.', 32 - l);
- dots[32 - l] = '\0';
- } else {
- dots[0] = '.';
- dots[1] = '\0';
- }
-
- printf("Node Description:%s%s\n", dots, nodename);
- free(nodename);
- return 0;
-}
-
-static char *
-node_info(ib_portid_t *dest, char **argv, int argc)
-{
- char buf[2048];
- char data[IB_SMP_DATA_SIZE];
-
- if (!smp_query(data, dest, IB_ATTR_NODE_INFO, 0, 0))
- return "node info query failed";
-
- mad_dump_nodeinfo(buf, sizeof buf, data, sizeof data);
-
- printf("# Node info: %s\n%s", portid2str(dest), buf);
- return 0;
-}
-
-static char *
-port_info(ib_portid_t *dest, char **argv, int argc)
-{
- char buf[2048];
- char data[IB_SMP_DATA_SIZE];
- int portnum = 0;
-
- if (argc > 0)
- portnum = strtol(argv[0], 0, 0);
-
- if (!smp_query(data, dest, IB_ATTR_PORT_INFO, portnum, 0))
- return "port info query failed";
-
- mad_dump_portinfo(buf, sizeof buf, data, sizeof data);
-
- printf("# Port info: %s port %d\n%s", portid2str(dest), portnum, buf);
- return 0;
-}
-
-static char *
-switch_info(ib_portid_t *dest, char **argv, int argc)
-{
- char buf[2048];
- char data[IB_SMP_DATA_SIZE];
-
- if (!smp_query(data, dest, IB_ATTR_SWITCH_INFO, 0, 0))
- return "switch info query failed";
-
- mad_dump_switchinfo(buf, sizeof buf, data, sizeof data);
-
- printf("# Switch info: %s\n%s", portid2str(dest), buf);
- return 0;
-}
-
-static char *
-pkey_table(ib_portid_t *dest, char **argv, int argc)
-{
- uint8_t data[IB_SMP_DATA_SIZE];
- uint32_t i, j, k;
- uint16_t *p;
- unsigned mod;
- int n, t, phy_ports;
- int portnum = 0;
-
- if (argc > 0)
- portnum = strtol(argv[0], 0, 0);
-
- /* Get the partition capacity */
- if (!smp_query(data, dest, IB_ATTR_NODE_INFO, 0, 0))
- return "node info query failed";
-
- mad_decode_field(data, IB_NODE_TYPE_F, &t);
- mad_decode_field(data, IB_NODE_NPORTS_F, &phy_ports);
- if (portnum > phy_ports)
- return "invalid port number";
-
- if ((t == IB_NODE_SWITCH) && (portnum != 0)) {
- if (!smp_query(data, dest, IB_ATTR_SWITCH_INFO, 0, 0))
- return "switch info failed";
- mad_decode_field(data, IB_SW_PARTITION_ENFORCE_CAP_F, &n);
- } else
- mad_decode_field(data, IB_NODE_PARTITION_CAP_F, &n);
-
- for (i = 0; i < (n + 31) / 32; i++) {
- mod = i | (portnum << 16);
- if (!smp_query(data, dest, IB_ATTR_PKEY_TBL, mod, 0))
- return "pkey table query failed";
- if (i + 1 == (n + 31) / 32)
- k = ((n + 7 - i * 32) / 8) * 8;
- else
- k = 32;
- p = (uint16_t *) data;
- for (j = 0; j < k; j += 8, p += 8) {
- printf("%4u: 0x%04x 0x%04x 0x%04x 0x%04x 0x%04x 0x%04x 0x%04x 0x%04x\n",
- (i * 32) + j,
- ntohs(p[0]), ntohs(p[1]),
- ntohs(p[2]), ntohs(p[3]),
- ntohs(p[4]), ntohs(p[5]),
- ntohs(p[6]), ntohs(p[7]));
- }
- }
- printf("%d pkeys capacity for this port\n", n);
-
- return 0;
-}
-
-static char *sl2vl_dump_table_entry(ib_portid_t *dest, int in, int out)
-{
- char buf[2048];
- char data[IB_SMP_DATA_SIZE];
- int portnum = (in << 8) | out;
-
- if (!smp_query(data, dest, IB_ATTR_SLVL_TABLE, portnum, 0))
- return "slvl query failed";
-
- mad_dump_sltovl(buf, sizeof buf, data, sizeof data);
- printf("ports: in %2d, out %2d: ", in, out);
- printf("%s", buf);
- return 0;
-}
-
-static char *
-sl2vl_table(ib_portid_t *dest, char **argv, int argc)
-{
- uint8_t data[IB_SMP_DATA_SIZE];
- int type, num_ports, portnum = 0;
- int i;
- char *ret;
-
- if (argc > 0)
- portnum = strtol(argv[0], 0, 0);
-
- if (!smp_query(data, dest, IB_ATTR_NODE_INFO, 0, 0))
- return "node info query failed";
-
- mad_decode_field(data, IB_NODE_TYPE_F, &type);
- mad_decode_field(data, IB_NODE_NPORTS_F, &num_ports);
- if (portnum > num_ports)
- return "invalid port number";
-
- printf("# SL2VL table: %s\n", portid2str(dest));
- printf("# SL: |");
- for (i = 0 ; i < 16 ; i++)
- printf("%2d|", i);
- printf("\n");
-
- if (type != IB_NODE_SWITCH)
- return sl2vl_dump_table_entry(dest, 0, 0);
-
- for (i = 0 ; i <= num_ports ; i++) {
- ret = sl2vl_dump_table_entry(dest, i, portnum);
- if (ret)
- return ret;
- }
- return 0;
-}
-
-static char *vlarb_dump_table_entry(ib_portid_t *dest, int portnum, int offset, unsigned cap)
-{
- char buf[2048];
- char data[IB_SMP_DATA_SIZE];
-
- if (!smp_query(data, dest, IB_ATTR_VL_ARBITRATION,
- (offset << 16) | portnum, 0))
- return "vl arb query failed";
- mad_dump_vlarbitration(buf, sizeof(buf), data, cap * 2);
- printf("%s", buf);
- return 0;
-}
-
-static char *vlarb_dump_table(ib_portid_t *dest, int portnum,
- char *name, int offset, int cap)
-{
- char *ret;
-
- printf("# %s priority VL Arbitration Table:", name);
- ret = vlarb_dump_table_entry(dest, portnum, offset,
- cap < 32 ? cap : 32);
- if (!ret && cap > 32)
- ret = vlarb_dump_table_entry(dest, portnum, offset + 1,
- cap - 32);
- return ret;
-}
-
-static char *
-vlarb_table(ib_portid_t *dest, char **argv, int argc)
-{
- uint8_t data[IB_SMP_DATA_SIZE];
- int portnum = 0;
- int type, enhsp0, lowcap, highcap;
- char *ret = 0;
-
- if (argc > 0)
- portnum = strtol(argv[0], 0, 0);
-
- /* port number of 0 could mean SP0 or port MAD arrives on */
- if (portnum == 0) {
- if (!smp_query(data, dest, IB_ATTR_NODE_INFO, 0, 0))
- return "node info query failed";
-
- mad_decode_field(data, IB_NODE_TYPE_F, &type);
- if (type == IB_NODE_SWITCH) {
- if (!smp_query(data, dest, IB_ATTR_SWITCH_INFO, 0, 0))
- return "switch info query failed";
- mad_decode_field(data, IB_SW_ENHANCED_PORT0_F, &enhsp0);
- if (!enhsp0) {
- printf("# No VLArbitration tables (BSP0): %s port %d\n",
- portid2str(dest), 0);
- return 0;
- }
- }
- }
-
- if (!smp_query(data, dest, IB_ATTR_PORT_INFO, portnum, 0))
- return "port info query failed";
-
- mad_decode_field(data, IB_PORT_VL_ARBITRATION_LOW_CAP_F, &lowcap);
- mad_decode_field(data, IB_PORT_VL_ARBITRATION_HIGH_CAP_F,&highcap);
-
- printf("# VLArbitration tables: %s port %d LowCap %d HighCap %d\n",
- portid2str(dest), portnum, lowcap, highcap);
-
- if (lowcap > 0)
- ret = vlarb_dump_table(dest, portnum, "Low", 1, lowcap);
-
- if (!ret && highcap > 0)
- ret = vlarb_dump_table(dest, portnum, "High", 3, highcap);
-
- return ret;
-}
-
-static char *
-guid_info(ib_portid_t *dest, char **argv, int argc)
-{
- uint8_t data[IB_SMP_DATA_SIZE];
- uint32_t i, j, k;
- uint64_t *p;
- unsigned mod;
- int n;
-
- /* Get the guid capacity */
- if (!smp_query(data, dest, IB_ATTR_PORT_INFO, 0, 0))
- return "port info failed";
- mad_decode_field(data, IB_PORT_GUID_CAP_F, &n);
-
- for (i = 0; i < (n + 7) / 8; i++) {
- mod = i;
- if (!smp_query(data, dest, IB_ATTR_GUID_INFO, mod, 0))
- return "guid info query failed";
- if (i + 1 == (n + 7) / 8)
- k = ((n + 1 - i * 8) / 2) * 2;
- else
- k = 8;
- p = (uint64_t *) data;
- for (j = 0; j < k; j += 2, p += 2) {
- printf("%4u: 0x%016"PRIx64" 0x%016"PRIx64"\n",
- (i * 8) + j,
- ntohll(p[0]), ntohll(p[1]));
- }
- }
- printf("%d guids capacity for this port\n", n);
-
- return 0;
-}
-
-static op_fn_t *
-match_op(char *name)
-{
- const match_rec_t *r;
- for (r = match_tbl; r->name; r++)
- if (!strcmp(r->name, name))
- return r->fn;
- return 0;
-}
-
-static void
-usage(void)
-{
- char *basename;
- const match_rec_t *r;
-
- if (!(basename = strrchr(argv0, '/')))
- basename = argv0;
- else
- basename++;
-
- fprintf(stderr, "Usage: %s [-d(ebug) -e(rr_show) -v(erbose) -D(irect) -G(uid) -s smlid -V(ersion) -C ca_name -P ca_port "
- "-t(imeout) timeout_ms --node-name-map node-name-map] <op> <dest dr_path|lid|guid> [op params]\n",
- basename);
- fprintf(stderr, "\tsupported ops:\n");
- for (r = match_tbl ; r->name ; r++) {
- fprintf(stderr, "\t\t%s <addr>%s\n", r->name,
- r->opt_portnum ? " [<portnum>]" : "");
- }
- fprintf(stderr, "\n\texamples:\n");
- fprintf(stderr, "\t\t%s portinfo 3 1\t\t\t\t# portinfo by lid, with port modifier\n", basename);
- fprintf(stderr, "\t\t%s -G switchinfo 0x2C9000100D051 1\t# switchinfo by guid\n", basename);
- fprintf(stderr, "\t\t%s -D nodeinfo 0\t\t\t\t# nodeinfo by direct route\n", basename);
- fprintf(stderr, "\t\t%s -c nodeinfo 6 0,12\t\t\t# nodeinfo by combined route\n", basename);
- exit(-1);
-}
-
-int
-main(int argc, char **argv)
-{
- int mgmt_classes[3] = {IB_SMI_CLASS, IB_SMI_DIRECT_CLASS, IB_SA_CLASS};
- ib_portid_t portid = {0};
- ib_portid_t *sm_id = 0, sm_portid = {0};
- extern int ibdebug;
- int timeout = 0, udebug = 0;
- char *ca = 0;
- int ca_port = 0;
- char *err;
- op_fn_t *fn;
-
- static char const str_opts[] = "C:P:t:s:devDcGVhu";
- static const struct option long_opts[] = {
- { "C", 1, 0, 'C'},
- { "P", 1, 0, 'P'},
- { "debug", 0, 0, 'd'},
- { "err_show", 0, 0, 'e'},
- { "verbose", 0, 0, 'v'},
- { "Direct", 0, 0, 'D'},
- { "combined", 0, 0, 'c'},
- { "Guid", 0, 0, 'G'},
- { "smlid", 1, 0, 's'},
- { "timeout", 1, 0, 't'},
- { "node-name-map", 1, 0, 1},
- { "Version", 0, 0, 'V'},
- { "help", 0, 0, 'h'},
- { "usage", 0, 0, 'u'},
- { }
- };
-
- argv0 = argv[0];
-
- while (1) {
- int ch = getopt_long(argc, argv, str_opts, long_opts, NULL);
- if ( ch == -1 )
- break;
- switch(ch) {
- case 1:
- node_name_map_file = strdup(optarg);
- break;
- case 'd':
- ibdebug++;
- madrpc_show_errors(1);
- umad_debug(udebug);
- udebug++;
- break;
- case 'e':
- madrpc_show_errors(1);
- break;
- case 'D':
- dest_type = IB_DEST_DRPATH;
- break;
- case 'c':
- dest_type = IB_DEST_DRSLID;
- break;
- case 'G':
- dest_type = IB_DEST_GUID;
- break;
- case 'C':
- ca = optarg;
- break;
- case 'P':
- ca_port = strtoul(optarg, 0, 0);
- break;
- case 's':
- if (ib_resolve_portid_str(&sm_portid, optarg, IB_DEST_LID, 0) < 0)
- IBERROR("can't resolve SM destination port %s", optarg);
- sm_id = &sm_portid;
- break;
- case 't':
- timeout = strtoul(optarg, 0, 0);
- madrpc_set_timeout(timeout);
- break;
- case 'v':
- verbose++;
- break;
- case 'V':
- fprintf(stderr, "%s %s\n", argv0, get_build_version() );
- exit(-1);
- default:
- usage();
- break;
- }
- }
- argc -= optind;
- argv += optind;
-
- if (argc < 2)
- usage();
-
- if (!(fn = match_op(argv[0])))
- IBERROR("operation '%s' not supported", argv[0]);
-
- madrpc_init(ca, ca_port, mgmt_classes, 3);
- node_name_map = open_node_name_map(node_name_map_file);
-
- if (dest_type != IB_DEST_DRSLID) {
- if (ib_resolve_portid_str(&portid, argv[1], dest_type, sm_id) < 0)
- IBERROR("can't resolve destination port %s", argv[1]);
- if ((err = fn(&portid, argv+2, argc-2)))
- IBERROR("operation %s: %s", argv[0], err);
- } else {
- char concat[64];
-
- memset(concat, 0, 64);
- snprintf(concat, sizeof(concat), "%s %s", argv[1], argv[2]);
- if (ib_resolve_portid_str(&portid, concat, dest_type, sm_id) < 0)
- IBERROR("can't resolve destination port %s", concat);
- if ((err = fn(&portid, argv+3, argc-3)))
- IBERROR("operation %s: %s", argv[0], err);
- }
- close_node_name_map(node_name_map);
- exit(0);
-}
diff --git a/contrib/ofed/management/infiniband-diags/src/vendstat.c b/contrib/ofed/management/infiniband-diags/src/vendstat.c
deleted file mode 100644
index 0674986..0000000
--- a/contrib/ofed/management/infiniband-diags/src/vendstat.c
+++ /dev/null
@@ -1,308 +0,0 @@
-/*
- * Copyright (c) 2004-2008 Voltaire Inc. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- */
-
-#if HAVE_CONFIG_H
-# include <config.h>
-#endif /* HAVE_CONFIG_H */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <stdarg.h>
-#include <getopt.h>
-#include <netinet/in.h>
-
-#include <infiniband/common.h>
-#include <infiniband/umad.h>
-#include <infiniband/mad.h>
-
-#include "ibdiag_common.h"
-
-#define IS3_DEVICE_ID 47396
-
-#define IB_MLX_VENDOR_CLASS 10
-/* Vendor specific Attribute IDs */
-#define IB_MLX_IS3_GENERAL_INFO 0x17
-#define IB_MLX_IS3_CONFIG_SPACE_ACCESS 0x50
-/* Config space addresses */
-#define IB_MLX_IS3_PORT_XMIT_WAIT 0x10013C
-
-char *argv0 = "vendstat";
-
-typedef struct {
- uint16_t hw_revision;
- uint16_t device_id;
- uint8_t reserved[24];
- uint32_t uptime;
-} is3_hw_info_t;
-
-typedef struct {
- uint8_t resv1;
- uint8_t major;
- uint8_t minor;
- uint8_t sub_minor;
- uint32_t build_id;
- uint8_t month;
- uint8_t day;
- uint16_t year;
- uint16_t resv2;
- uint16_t hour;
- uint8_t psid[16];
- uint32_t ini_file_version;
-} is3_fw_info_t;
-
-typedef struct {
- uint8_t resv1;
- uint8_t major;
- uint8_t minor;
- uint8_t sub_minor;
- uint8_t resv2[28];
-} is3_sw_info_t;
-
-typedef struct {
- uint8_t reserved[8];
- is3_hw_info_t hw_info;
- is3_fw_info_t fw_info;
- is3_sw_info_t sw_info;
-} is3_general_info_t;
-
-typedef struct {
- uint32_t address;
- uint32_t data;
- uint32_t mask;
-} is3_record_t;
-
-typedef struct {
- uint8_t reserved[8];
- is3_record_t record[18];
-} is3_config_space_t;
-
-static void
-usage(void)
-{
- char *basename;
-
- if (!(basename = strrchr(argv0, '/')))
- basename = argv0;
- else
- basename++;
-
- fprintf(stderr, "Usage: %s [-d(ebug) -N -w -G(uid) -C ca_name -P ca_port "
- "-t(imeout) timeout_ms -V(ersion) -h(elp)] <lid|guid>\n",
- basename);
- fprintf(stderr, "\tExamples:\n");
- fprintf(stderr, "\t\t%s -N 6\t\t# read IS3 general information\n", basename);
- fprintf(stderr, "\t\t%s -w 6\t\t# read IS3 port xmit wait counters\n", basename);
- exit(-1);
-}
-
-int
-main(int argc, char **argv)
-{
- int mgmt_classes[4] = {IB_SMI_CLASS, IB_SMI_DIRECT_CLASS, IB_SA_CLASS, IB_MLX_VENDOR_CLASS};
- ib_portid_t *sm_id = 0, sm_portid = {0};
- ib_portid_t portid = {0};
- extern int ibdebug;
- int dest_type = IB_DEST_LID;
- int timeout = 0; /* use default */
- int port = 0;
- char buf[1024];
- int udebug = 0;
- char *ca = 0;
- int ca_port = 0;
- ib_vendor_call_t call;
- is3_general_info_t *gi;
- is3_config_space_t *cs;
- int general_info = 0;
- int xmit_wait = 0;
- int i;
-
- static char const str_opts[] = "C:P:s:t:dNwGVhu";
- static const struct option long_opts[] = {
- { "C", 1, 0, 'C'},
- { "P", 1, 0, 'P'},
- { "N", 1, 0, 'N'},
- { "w", 1, 0, 'w'},
- { "debug", 0, 0, 'd'},
- { "Guid", 0, 0, 'G'},
- { "sm_portid", 1, 0, 's'},
- { "timeout", 1, 0, 't'},
- { "Version", 0, 0, 'V'},
- { "help", 0, 0, 'h'},
- { "usage", 0, 0, 'u'},
- { }
- };
-
- argv0 = argv[0];
-
- while (1) {
- int ch = getopt_long(argc, argv, str_opts, long_opts, NULL);
- if ( ch == -1 )
- break;
- switch(ch) {
- case 'C':
- ca = optarg;
- break;
- case 'P':
- ca_port = strtoul(optarg, 0, 0);
- break;
- case 'N':
- general_info = 1;
- break;
- case 'w':
- xmit_wait = 1;
- break;
- case 'd':
- ibdebug++;
- madrpc_show_errors(1);
- umad_debug(udebug);
- udebug++;
- break;
- case 'G':
- dest_type = IB_DEST_GUID;
- break;
- case 's':
- if (ib_resolve_portid_str(&sm_portid, optarg, IB_DEST_LID, 0) < 0)
- IBERROR("can't resolve SM destination port %s", optarg);
- sm_id = &sm_portid;
- break;
- case 't':
- timeout = strtoul(optarg, 0, 0);
- madrpc_set_timeout(timeout);
- break;
- case 'V':
- fprintf(stderr, "%s %s\n", argv0, get_build_version() );
- exit(-1);
- default:
- usage();
- break;
- }
- }
- argc -= optind;
- argv += optind;
-
- if (argc > 1)
- port = strtoul(argv[1], 0, 0);
-
- madrpc_init(ca, ca_port, mgmt_classes, 4);
-
- if (argc) {
- if (ib_resolve_portid_str(&portid, argv[0], dest_type, sm_id) < 0)
- IBERROR("can't resolve destination port %s", argv[0]);
- } else {
- if (ib_resolve_self(&portid, &port, 0) < 0)
- IBERROR("can't resolve self port %s", argv[0]);
- }
-
- /* Only General Info and Port Xmit Wait Counters */
- /* queries are currently supported */
- if (!general_info && !xmit_wait)
- IBERROR("at least one of -N and -w must be specified");
-
- /* These are Mellanox specific vendor MADs */
- /* but vendors change the VendorId so how know for sure ? */
- /* Would need a list of these and it might not be complete */
- /* so for right now, punt on this */
-
- memset(&call, 0, sizeof(call));
- call.mgmt_class = IB_MLX_VENDOR_CLASS;
- call.method = IB_MAD_METHOD_GET;
- call.timeout = timeout;
-
- memset(&buf, 0, sizeof(buf));
- /* vendor ClassPortInfo is required attribute if class supported */
- call.attrid = CLASS_PORT_INFO;
- if (!ib_vendor_call(&buf, &portid, &call))
- IBERROR("classportinfo query");
-
- memset(&buf, 0, sizeof(buf));
- call.attrid = IB_MLX_IS3_GENERAL_INFO;
- if (!ib_vendor_call(&buf, &portid, &call))
- IBERROR("vendstat");
- gi = (is3_general_info_t *)&buf;
-
- if (general_info) {
- /* dump IS3 general info here */
- printf("hw_dev_rev: 0x%04x\n", ntohs(gi->hw_info.hw_revision));
- printf("hw_dev_id: 0x%04x\n", ntohs(gi->hw_info.device_id));
- printf("hw_uptime: 0x%08x\n", ntohl(gi->hw_info.uptime));
- printf("fw_version: %02d.%02d.%02d\n",
- gi->fw_info.major, gi->fw_info.minor, gi->fw_info.sub_minor);
- printf("fw_build_id: 0x%04x\n", ntohl(gi->fw_info.build_id));
- printf("fw_date: %02d/%02d/%04x\n",
- gi->fw_info.month, gi->fw_info.day, ntohs(gi->fw_info.year));
- printf("fw_psid: '%s'\n", gi->fw_info.psid);
- printf("fw_ini_ver: %d\n", ntohl(gi->fw_info.ini_file_version));
- printf("sw_version: %02d.%02d.%02d\n",
- gi->sw_info.major, gi->sw_info.minor, gi->sw_info.sub_minor);
- }
-
- if (xmit_wait) {
- if (ntohs(gi->hw_info.device_id) != IS3_DEVICE_ID)
- IBERROR("Unsupported device ID 0x%x", ntohs(gi->hw_info.device_id));
-
- memset(&buf, 0, sizeof(buf));
- call.attrid = IB_MLX_IS3_CONFIG_SPACE_ACCESS;
- /* Limit of 18 accesses per MAD ? */
- call.mod = 2 << 22 | 16 << 16; /* 16 records */
- /* Set record addresses for each port */
- cs = (is3_config_space_t *)&buf;
- for (i = 0; i < 16; i++)
- cs->record[i].address = htonl(IB_MLX_IS3_PORT_XMIT_WAIT + ((i + 1) << 12));
- if (!ib_vendor_call(&buf, &portid, &call))
- IBERROR("vendstat");
-
- for (i = 0; i < 16; i++)
- if (cs->record[i].data) /* PortXmitWait is 32 bit counter */
- printf("Port %d: PortXmitWait 0x%x\n", i + 4, ntohl(cs->record[i].data)); /* port 4 is first port */
-
- /* Last 8 ports is another query */
- memset(&buf, 0, sizeof(buf));
- call.attrid = IB_MLX_IS3_CONFIG_SPACE_ACCESS;
- call.mod = 2 << 22 | 8 << 16; /* 8 records */
- /* Set record addresses for each port */
- cs = (is3_config_space_t *)&buf;
- for (i = 0; i < 8; i++)
- cs->record[i].address = htonl(IB_MLX_IS3_PORT_XMIT_WAIT + ((i + 17) << 12));
- if (!ib_vendor_call(&buf, &portid, &call))
- IBERROR("vendstat");
-
- for (i = 0; i < 8; i++)
- if (cs->record[i].data) /* PortXmitWait is 32 bit counter */
- printf("Port %d: PortXmitWait 0x%x\n",
- i < 4 ? i + 21 : i - 3,
- ntohl(cs->record[i].data));
- }
-
- exit(0);
-}
diff --git a/contrib/ofed/management/libibcommon/AUTHORS b/contrib/ofed/management/libibcommon/AUTHORS
deleted file mode 100644
index d09c13f..0000000
--- a/contrib/ofed/management/libibcommon/AUTHORS
+++ /dev/null
@@ -1,3 +0,0 @@
-Shahar Frank <shahar@voltaire.com>
-Hal Rosenstock <halr@voltaire.com>
-Sasha Khapyorsky <sashak@voltaire.com>
diff --git a/contrib/ofed/management/libibcommon/COPYING b/contrib/ofed/management/libibcommon/COPYING
deleted file mode 100644
index 1b1ca1d..0000000
--- a/contrib/ofed/management/libibcommon/COPYING
+++ /dev/null
@@ -1,384 +0,0 @@
-This software with the exception of OpenSM is available to you
-under a choice of one of two licenses. You may chose to be
-licensed under the terms of the the OpenIB.org BSD license or
-the GNU General Public License (GPL) Version 2, both included
-below.
-
-OpenSM is licensed under either GNU General Public License (GPL)
-Version 2, or Intel BSD + Patent license. See OpenSM for the
-specific language for the latter licensing terms.
-
-
-Copyright (c) 2004-2008 Voltaire, Inc. All rights reserved.
-
-==================================================================
-
- OpenIB.org BSD license
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions
-are met:
-
- * Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
-
- * Redistributions in binary form must reproduce the above
- copyright notice, this list of conditions and the following
- disclaimer in the documentation and/or other materials provided
- with the distribution.
-
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
-FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
-COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
-INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
-BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
-LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
-CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
-ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-POSSIBILITY OF SUCH DAMAGE.
-
-==================================================================
-
- GNU GENERAL PUBLIC LICENSE
- Version 2, June 1991
-
- Copyright (C) 1989, 1991 Free Software Foundation, Inc.
- 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- Everyone is permitted to copy and distribute verbatim copies
- of this license document, but changing it is not allowed.
-
- Preamble
-
- The licenses for most software are designed to take away your
-freedom to share and change it. By contrast, the GNU General Public
-License is intended to guarantee your freedom to share and change free
-software--to make sure the software is free for all its users. This
-General Public License applies to most of the Free Software
-Foundation's software and to any other program whose authors commit to
-using it. (Some other Free Software Foundation software is covered by
-the GNU Library General Public License instead.) You can apply it to
-your programs, too.
-
- When we speak of free software, we are referring to freedom, not
-price. Our General Public Licenses are designed to make sure that you
-have the freedom to distribute copies of free software (and charge for
-this service if you wish), that you receive source code or can get it
-if you want it, that you can change the software or use pieces of it
-in new free programs; and that you know you can do these things.
-
- To protect your rights, we need to make restrictions that forbid
-anyone to deny you these rights or to ask you to surrender the rights.
-These restrictions translate to certain responsibilities for you if you
-distribute copies of the software, or if you modify it.
-
- For example, if you distribute copies of such a program, whether
-gratis or for a fee, you must give the recipients all the rights that
-you have. You must make sure that they, too, receive or can get the
-source code. And you must show them these terms so they know their
-rights.
-
- We protect your rights with two steps: (1) copyright the software, and
-(2) offer you this license which gives you legal permission to copy,
-distribute and/or modify the software.
-
- Also, for each author's protection and ours, we want to make certain
-that everyone understands that there is no warranty for this free
-software. If the software is modified by someone else and passed on, we
-want its recipients to know that what they have is not the original, so
-that any problems introduced by others will not reflect on the original
-authors' reputations.
-
- Finally, any free program is threatened constantly by software
-patents. We wish to avoid the danger that redistributors of a free
-program will individually obtain patent licenses, in effect making the
-program proprietary. To prevent this, we have made it clear that any
-patent must be licensed for everyone's free use or not licensed at all.
-
- The precise terms and conditions for copying, distribution and
-modification follow.
-
- GNU GENERAL PUBLIC LICENSE
- TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
-
- 0. This License applies to any program or other work which contains
-a notice placed by the copyright holder saying it may be distributed
-under the terms of this General Public License. The "Program", below,
-refers to any such program or work, and a "work based on the Program"
-means either the Program or any derivative work under copyright law:
-that is to say, a work containing the Program or a portion of it,
-either verbatim or with modifications and/or translated into another
-language. (Hereinafter, translation is included without limitation in
-the term "modification".) Each licensee is addressed as "you".
-
-Activities other than copying, distribution and modification are not
-covered by this License; they are outside its scope. The act of
-running the Program is not restricted, and the output from the Program
-is covered only if its contents constitute a work based on the
-Program (independent of having been made by running the Program).
-Whether that is true depends on what the Program does.
-
- 1. You may copy and distribute verbatim copies of the Program's
-source code as you receive it, in any medium, provided that you
-conspicuously and appropriately publish on each copy an appropriate
-copyright notice and disclaimer of warranty; keep intact all the
-notices that refer to this License and to the absence of any warranty;
-and give any other recipients of the Program a copy of this License
-along with the Program.
-
-You may charge a fee for the physical act of transferring a copy, and
-you may at your option offer warranty protection in exchange for a fee.
-
- 2. You may modify your copy or copies of the Program or any portion
-of it, thus forming a work based on the Program, and copy and
-distribute such modifications or work under the terms of Section 1
-above, provided that you also meet all of these conditions:
-
- a) You must cause the modified files to carry prominent notices
- stating that you changed the files and the date of any change.
-
- b) You must cause any work that you distribute or publish, that in
- whole or in part contains or is derived from the Program or any
- part thereof, to be licensed as a whole at no charge to all third
- parties under the terms of this License.
-
- c) If the modified program normally reads commands interactively
- when run, you must cause it, when started running for such
- interactive use in the most ordinary way, to print or display an
- announcement including an appropriate copyright notice and a
- notice that there is no warranty (or else, saying that you provide
- a warranty) and that users may redistribute the program under
- these conditions, and telling the user how to view a copy of this
- License. (Exception: if the Program itself is interactive but
- does not normally print such an announcement, your work based on
- the Program is not required to print an announcement.)
-
-These requirements apply to the modified work as a whole. If
-identifiable sections of that work are not derived from the Program,
-and can be reasonably considered independent and separate works in
-themselves, then this License, and its terms, do not apply to those
-sections when you distribute them as separate works. But when you
-distribute the same sections as part of a whole which is a work based
-on the Program, the distribution of the whole must be on the terms of
-this License, whose permissions for other licensees extend to the
-entire whole, and thus to each and every part regardless of who wrote it.
-
-Thus, it is not the intent of this section to claim rights or contest
-your rights to work written entirely by you; rather, the intent is to
-exercise the right to control the distribution of derivative or
-collective works based on the Program.
-
-In addition, mere aggregation of another work not based on the Program
-with the Program (or with a work based on the Program) on a volume of
-a storage or distribution medium does not bring the other work under
-the scope of this License.
-
- 3. You may copy and distribute the Program (or a work based on it,
-under Section 2) in object code or executable form under the terms of
-Sections 1 and 2 above provided that you also do one of the following:
-
- a) Accompany it with the complete corresponding machine-readable
- source code, which must be distributed under the terms of Sections
- 1 and 2 above on a medium customarily used for software interchange; or,
-
- b) Accompany it with a written offer, valid for at least three
- years, to give any third party, for a charge no more than your
- cost of physically performing source distribution, a complete
- machine-readable copy of the corresponding source code, to be
- distributed under the terms of Sections 1 and 2 above on a medium
- customarily used for software interchange; or,
-
- c) Accompany it with the information you received as to the offer
- to distribute corresponding source code. (This alternative is
- allowed only for noncommercial distribution and only if you
- received the program in object code or executable form with such
- an offer, in accord with Subsection b above.)
-
-The source code for a work means the preferred form of the work for
-making modifications to it. For an executable work, complete source
-code means all the source code for all modules it contains, plus any
-associated interface definition files, plus the scripts used to
-control compilation and installation of the executable. However, as a
-special exception, the source code distributed need not include
-anything that is normally distributed (in either source or binary
-form) with the major components (compiler, kernel, and so on) of the
-operating system on which the executable runs, unless that component
-itself accompanies the executable.
-
-If distribution of executable or object code is made by offering
-access to copy from a designated place, then offering equivalent
-access to copy the source code from the same place counts as
-distribution of the source code, even though third parties are not
-compelled to copy the source along with the object code.
-
- 4. You may not copy, modify, sublicense, or distribute the Program
-except as expressly provided under this License. Any attempt
-otherwise to copy, modify, sublicense or distribute the Program is
-void, and will automatically terminate your rights under this License.
-However, parties who have received copies, or rights, from you under
-this License will not have their licenses terminated so long as such
-parties remain in full compliance.
-
- 5. You are not required to accept this License, since you have not
-signed it. However, nothing else grants you permission to modify or
-distribute the Program or its derivative works. These actions are
-prohibited by law if you do not accept this License. Therefore, by
-modifying or distributing the Program (or any work based on the
-Program), you indicate your acceptance of this License to do so, and
-all its terms and conditions for copying, distributing or modifying
-the Program or works based on it.
-
- 6. Each time you redistribute the Program (or any work based on the
-Program), the recipient automatically receives a license from the
-original licensor to copy, distribute or modify the Program subject to
-these terms and conditions. You may not impose any further
-restrictions on the recipients' exercise of the rights granted herein.
-You are not responsible for enforcing compliance by third parties to
-this License.
-
- 7. If, as a consequence of a court judgment or allegation of patent
-infringement or for any other reason (not limited to patent issues),
-conditions are imposed on you (whether by court order, agreement or
-otherwise) that contradict the conditions of this License, they do not
-excuse you from the conditions of this License. If you cannot
-distribute so as to satisfy simultaneously your obligations under this
-License and any other pertinent obligations, then as a consequence you
-may not distribute the Program at all. For example, if a patent
-license would not permit royalty-free redistribution of the Program by
-all those who receive copies directly or indirectly through you, then
-the only way you could satisfy both it and this License would be to
-refrain entirely from distribution of the Program.
-
-If any portion of this section is held invalid or unenforceable under
-any particular circumstance, the balance of the section is intended to
-apply and the section as a whole is intended to apply in other
-circumstances.
-
-It is not the purpose of this section to induce you to infringe any
-patents or other property right claims or to contest validity of any
-such claims; this section has the sole purpose of protecting the
-integrity of the free software distribution system, which is
-implemented by public license practices. Many people have made
-generous contributions to the wide range of software distributed
-through that system in reliance on consistent application of that
-system; it is up to the author/donor to decide if he or she is willing
-to distribute software through any other system and a licensee cannot
-impose that choice.
-
-This section is intended to make thoroughly clear what is believed to
-be a consequence of the rest of this License.
-
- 8. If the distribution and/or use of the Program is restricted in
-certain countries either by patents or by copyrighted interfaces, the
-original copyright holder who places the Program under this License
-may add an explicit geographical distribution limitation excluding
-those countries, so that distribution is permitted only in or among
-countries not thus excluded. In such case, this License incorporates
-the limitation as if written in the body of this License.
-
- 9. The Free Software Foundation may publish revised and/or new versions
-of the General Public License from time to time. Such new versions will
-be similar in spirit to the present version, but may differ in detail to
-address new problems or concerns.
-
-Each version is given a distinguishing version number. If the Program
-specifies a version number of this License which applies to it and "any
-later version", you have the option of following the terms and conditions
-either of that version or of any later version published by the Free
-Software Foundation. If the Program does not specify a version number of
-this License, you may choose any version ever published by the Free Software
-Foundation.
-
- 10. If you wish to incorporate parts of the Program into other free
-programs whose distribution conditions are different, write to the author
-to ask for permission. For software which is copyrighted by the Free
-Software Foundation, write to the Free Software Foundation; we sometimes
-make exceptions for this. Our decision will be guided by the two goals
-of preserving the free status of all derivatives of our free software and
-of promoting the sharing and reuse of software generally.
-
- NO WARRANTY
-
- 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
-FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
-OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
-PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
-OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
-MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
-TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
-PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
-REPAIR OR CORRECTION.
-
- 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
-WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
-REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
-INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
-OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
-TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
-YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
-PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
-POSSIBILITY OF SUCH DAMAGES.
-
- END OF TERMS AND CONDITIONS
-
- How to Apply These Terms to Your New Programs
-
- If you develop a new program, and you want it to be of the greatest
-possible use to the public, the best way to achieve this is to make it
-free software which everyone can redistribute and change under these terms.
-
- To do so, attach the following notices to the program. It is safest
-to attach them to the start of each source file to most effectively
-convey the exclusion of warranty; and each file should have at least
-the "copyright" line and a pointer to where the full notice is found.
-
- <one line to give the program's name and a brief idea of what it does.>
- Copyright (C) <year> <name of author>
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program 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 this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-
-Also add information on how to contact you by electronic and paper mail.
-
-If the program is interactive, make it output a short notice like this
-when it starts in an interactive mode:
-
- Gnomovision version 69, Copyright (C) year name of author
- Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
- This is free software, and you are welcome to redistribute it
- under certain conditions; type `show c' for details.
-
-The hypothetical commands `show w' and `show c' should show the appropriate
-parts of the General Public License. Of course, the commands you use may
-be called something other than `show w' and `show c'; they could even be
-mouse-clicks or menu items--whatever suits your program.
-
-You should also get your employer (if you work as a programmer) or your
-school, if any, to sign a "copyright disclaimer" for the program, if
-necessary. Here is a sample; alter the names:
-
- Yoyodyne, Inc., hereby disclaims all copyright interest in the program
- `Gnomovision' (which makes passes at compilers) written by James Hacker.
-
- <signature of Ty Coon>, 1 April 1989
- Ty Coon, President of Vice
-
-This General Public License does not permit incorporating your program into
-proprietary programs. If your program is a subroutine library, you may
-consider it more useful to permit linking proprietary applications with the
-library. If this is what you want to do, use the GNU Library General
-Public License instead of this License.
diff --git a/contrib/ofed/management/libibcommon/ChangeLog b/contrib/ofed/management/libibcommon/ChangeLog
deleted file mode 100644
index 0fdeaa9..0000000
--- a/contrib/ofed/management/libibcommon/ChangeLog
+++ /dev/null
@@ -1,21 +0,0 @@
-2007-06-29 Hal Rosenstock <halr@voltaire.com>
-
- * Release version 1.0.4
-
-2007-06-26 Hal Rosenstock <halr@voltaire.com>
-
- * src/sysfs.c: Change uint to unsigned for strict ANSI
-
-2007-06-26 Michael S. Tsirkin <mst@dev.mellanox.co.il>
-
- * include/infiniband/common.h: Change uint to unsigned
- for strict ANSI
-
-2007-01-25 Hal Rosenstock <halr@voltaire.com>
-
- * Release version 1.0.2.
-
-2006-11-20 Sasha Khapyorsky <sashak@voltaire.com>
-
- * include/infiniband/common.h: Enable strict format/args
- checking for printf() style functions
diff --git a/contrib/ofed/management/libibcommon/Makefile.am b/contrib/ofed/management/libibcommon/Makefile.am
deleted file mode 100644
index 75889f4..0000000
--- a/contrib/ofed/management/libibcommon/Makefile.am
+++ /dev/null
@@ -1,32 +0,0 @@
-
-SUBDIRS = .
-
-INCLUDES = -I$(srcdir)/include/infiniband
-
-lib_LTLIBRARIES = libibcommon.la
-
-libibcommon_la_CFLAGS = -Wall
-
-if HAVE_LD_VERSION_SCRIPT
-libibcommon_version_script = -Wl,--version-script=$(srcdir)/src/libibcommon.map
-else
-libibcommon_version_script =
-endif
-
-libibcommon_la_SOURCES = src/stack.c src/sysfs.c src/util.c src/time.c src/hash.c
-libibcommon_la_LDFLAGS = -version-info $(ibcommon_api_version) \
- -export-dynamic $(libibcommon_version_script)
-libibcommon_la_DEPENDENCIES = $(srcdir)/src/libibcommon.map
-
-libibcommonincludedir = $(includedir)/infiniband
-
-libibcommoninclude_HEADERS = $(srcdir)/include/infiniband/common.h
-
-EXTRA_DIST = $(srcdir)/include/infiniband/common.h \
- libibcommon.spec.in libibcommon.spec \
- $(srcdir)/src/libibcommon.map libibcommon.ver autogen.sh
-
-dist-hook:
- if [ -x $(top_srcdir)/../gen_chlog.sh ] ; then \
- $(top_srcdir)/../gen_chlog.sh $(PACKAGE) > $(distdir)/ChangeLog ; \
- fi
diff --git a/contrib/ofed/management/libibcommon/autogen.sh b/contrib/ofed/management/libibcommon/autogen.sh
deleted file mode 100755
index 4827884..0000000
--- a/contrib/ofed/management/libibcommon/autogen.sh
+++ /dev/null
@@ -1,11 +0,0 @@
-#! /bin/sh
-
-# create config dir if not exist
-test -d config || mkdir config
-
-set -x
-aclocal -I config
-libtoolize --force --copy
-autoheader
-automake --foreign --add-missing --copy
-autoconf
diff --git a/contrib/ofed/management/libibcommon/configure.in b/contrib/ofed/management/libibcommon/configure.in
deleted file mode 100644
index 0f2fc33..0000000
--- a/contrib/ofed/management/libibcommon/configure.in
+++ /dev/null
@@ -1,52 +0,0 @@
-dnl Process this file with autoconf to produce a configure script.
-
-AC_PREREQ(2.57)
-AC_INIT(libibcommon, 1.2.0, general@lists.openfabrics.org)
-AC_CONFIG_SRCDIR([src/stack.c])
-AC_CONFIG_AUX_DIR(config)
-AM_CONFIG_HEADER(config.h)
-AM_INIT_AUTOMAKE
-
-AC_SUBST(RELEASE, ${RELEASE:-unknown})
-AC_SUBST(TARBALL, ${TARBALL:-${PACKAGE}-${VERSION}.tar.gz})
-
-dnl the library version info is available in the file: libibcommon.ver
-ibcommon_api_version=`grep LIBVERSION $srcdir/libibcommon.ver | sed 's/LIBVERSION=//'`
-if test -z $ibcommon_api_version; then
- ibcommon_api_version=1:0:0
-fi
-AC_SUBST(ibcommon_api_version)
-
-dnl Checks for programs
-AC_PROG_CC
-AC_PROG_CPP
-AC_PROG_INSTALL
-AC_PROG_LN_S
-AC_PROG_MAKE_SET
-AM_PROG_LIBTOOL
-
-dnl Checks for header files.
-AC_HEADER_STDC
-AC_CHECK_HEADERS([fcntl.h inttypes.h netinet/in.h stdint.h stdlib.h string.h sys/ioctl.h syslog.h unistd.h])
-
-dnl Checks for library functions
-AC_TYPE_SIGNAL
-AC_FUNC_VPRINTF
-AC_CHECK_FUNCS([strrchr strtoul strtoull])
-
-dnl Checks for typedefs, structures, and compiler characteristics.
-AC_C_CONST
-AC_C_INLINE
-AC_STRUCT_TM
-
-AC_CACHE_CHECK(whether ld accepts --version-script, ac_cv_version_script,
- if test -n "`$LD --help < /dev/null 2>/dev/null | grep version-script`"; then
- ac_cv_version_script=yes
- else
- ac_cv_version_script=no
- fi)
-
-AM_CONDITIONAL(HAVE_LD_VERSION_SCRIPT, test "$ac_cv_version_script" = "yes")
-
-AC_CONFIG_FILES([Makefile libibcommon.spec])
-AC_OUTPUT
diff --git a/contrib/ofed/management/libibcommon/include/infiniband/common.h b/contrib/ofed/management/libibcommon/include/infiniband/common.h
deleted file mode 100644
index e955593..0000000
--- a/contrib/ofed/management/libibcommon/include/infiniband/common.h
+++ /dev/null
@@ -1,149 +0,0 @@
-/*
- * Copyright (c) 2004-2007 Voltaire Inc. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- */
-#ifndef __COMMON_H__
-#define __COMMON_H__
-
-#include <stdio.h>
-#include <sys/select.h>
-#include <sys/types.h>
-#include <dirent.h>
-#include <stdint.h>
-#include <infiniband/byteswap.h>
-
-#ifdef __cplusplus
-# define BEGIN_C_DECLS extern "C" {
-# define END_C_DECLS }
-#else /* !__cplusplus */
-# define BEGIN_C_DECLS
-# define END_C_DECLS
-#endif /* __cplusplus */
-
-BEGIN_C_DECLS
-
-#if __BYTE_ORDER == __LITTLE_ENDIAN
-#ifndef ntohll
-static inline uint64_t ntohll(uint64_t x) {
- return bswap_64(x);
-}
-#endif
-#ifndef htonll
-static inline uint64_t htonll(uint64_t x) {
- return bswap_64(x);
-}
-#endif
-#elif __BYTE_ORDER == __BIG_ENDIAN
-#ifndef ntohll
-static inline uint64_t ntohll(uint64_t x) {
- return x;
-}
-#endif
-#ifndef htonll
-static inline uint64_t htonll(uint64_t x) {
- return x;
-}
-#endif
-#endif /* __BYTE_ORDER == __BIG_ENDIAN */
-
-/*****************************
- * COMMON MACHINE INDEPENDENT
- */
-
-/* Misc. macros: */
-/** align value \a l to \a size (ceil) */
-#ifndef ALIGN
-#define ALIGN(l, size) (((l) + ((size) - 1)) / (size) * (size))
-
-/** align value \a l to \a sizeof 32 bit int (ceil) */
-#define ALIGN32(l) (ALIGN((l), sizeof(uint32)))
-#endif
-
-/** printf style debugging MACRO, conmmon header includes name of function */
-#define IBWARN(fmt, args...) ibwarn(__FUNCTION__, fmt, ## args)
-
-/** printf style debugging MACRO, conmmon header includes name of function */
-#define LOG(fmt, args...) logmsg(__FUNCTION__, fmt, ## args)
-
-/** printf style abort MACRO, common header includes name of function */
-#define IBPANIC(fmt, args...) ibpanic(__FUNCTION__, fmt, ## args)
-
-/** abort program if expression \a x is \b false */
-#define SANITY(x) if (common.sanity && !(x))\
- ibpanic(__FUNCTION__,\
- "sanity check <%s> failed: line %d",\
- (x), __LINE__)
-
-/** avoid unused compilation warning */
-#ifndef USED
-#define USED(x) while(0) {void *v = &(x); printf("%p", v);}
-#endif
-
-/** define index macro for string array generated by enumstr.awk */
-#define ENUM_STR_DEF(enumname, last, val) (((unsigned)(val) < last) ? enumname ## _str[val] : "???")
-#define ENUM_STR_ARRAY(name) char * name ## _str[]
-
-#ifdef __GNUC__
-#define IBCOMMON_STRICT_FORMAT __attribute__((format(printf, 2, 3)))
-#else
-#define IBCOMMON_STRICT_FORMAT
-#endif
-
-/* util.c: debugging and tracing */
-void ibwarn(const char * const fn, char *msg, ...) IBCOMMON_STRICT_FORMAT;
-void ibpanic(const char * const fn, char *msg, ...) IBCOMMON_STRICT_FORMAT;
-void logmsg(const char *const fn, char *msg, ...) IBCOMMON_STRICT_FORMAT;
-
-void xdump(FILE *file, char *msg, void *p, int size);
-
-/* sysfs.c: /sys utilities */
-int sys_read_string(char *dir_name, char *file_name, char *str, int max_len);
-int sys_read_guid(char *dir_name, char *file_name, uint64_t *net_guid);
-int sys_read_gid(char *dir_name, char *file_name, uint8_t *gid);
-int sys_read_uint64(char *dir_name, char *file_name, uint64_t *u);
-int sys_read_uint(char *dir_name, char *file_name, unsigned *u);
-int sys_scandir(const char *dirname, struct dirent ***namelist,
- int (*select)(const struct dirent *),
- int (*compar)(const struct dirent **, const struct dirent **));
-
-/* stack.c */
-void stack_dump(void);
-void enable_stack_dump(int loop);
-
-/* time.c */
-uint64_t getcurrenttime(void);
-
-/* hash.c */
-uint32_t fhash(uint8_t *k, int length, uint32_t initval);
-
-END_C_DECLS
-
-#endif /* __COMMON_H__ */
diff --git a/contrib/ofed/management/libibcommon/libibcommon.spec.in b/contrib/ofed/management/libibcommon/libibcommon.spec.in
deleted file mode 100644
index bd328b0..0000000
--- a/contrib/ofed/management/libibcommon/libibcommon.spec.in
+++ /dev/null
@@ -1,72 +0,0 @@
-
-%define RELEASE @RELEASE@
-%define rel %{?CUSTOM_RELEASE} %{!?CUSTOM_RELEASE:%RELEASE}
-
-Summary: OpenFabrics Alliance InfiniBand management common library
-Name: libibcommon
-Version: @VERSION@
-Release: %rel%{?dist}
-License: GPLv2 or BSD
-Group: System Environment/Libraries
-BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
-Source: http://www.openfabrics.org/downloads/management/@TARBALL@
-Url: http://openfabrics.org/
-Requires(post): /sbin/ldconfig
-Requires(postun): /sbin/ldconfig
-BuildRequires: libtool
-
-%description
-libibcommon provides common utility functions for the OFA diagnostic and
-management tools.
-
-%package devel
-Summary: Development files for the libibcommon library
-Group: System Environment/Libraries
-Requires: %{name} = %{version}-%{release}
-Requires(post): /sbin/ldconfig
-Requires(postun): /sbin/ldconfig
-
-%description devel
-Development files for the libibcommon library.
-
-%package static
-Summary: Static library files for the libibcommon library
-Group: System Environment/Libraries
-Requires: %{name} = %{version}-%{release}
-
-%description static
-Static library files for the libibcommon library.
-
-%prep
-%setup -q
-
-%build
-%configure
-make %{?_smp_mflags}
-
-%install
-make DESTDIR=${RPM_BUILD_ROOT} install
-# remove unpackaged files from the buildroot
-rm -f $RPM_BUILD_ROOT%{_libdir}/*.la
-
-%clean
-rm -rf $RPM_BUILD_ROOT
-
-%post -p /sbin/ldconfig
-%postun -p /sbin/ldconfig
-%post devel -p /sbin/ldconfig
-%postun devel -p /sbin/ldconfig
-
-%files
-%defattr(-,root,root)
-%{_libdir}/libibcommon*.so.*
-%doc AUTHORS COPYING ChangeLog
-
-%files devel
-%defattr(-,root,root)
-%{_libdir}/libibcommon.so
-%{_includedir}/infiniband/*.h
-
-%files static
-%defattr(-,root,root)
-%{_libdir}/libibcommon.a
diff --git a/contrib/ofed/management/libibcommon/libibcommon.ver b/contrib/ofed/management/libibcommon/libibcommon.ver
deleted file mode 100644
index 7b88f1b..0000000
--- a/contrib/ofed/management/libibcommon/libibcommon.ver
+++ /dev/null
@@ -1,9 +0,0 @@
-# In this file we track the current API version
-# of the IB common interface (and libraries)
-# The version is built of the following
-# tree numbers:
-# API_REV:RUNNING_REV:AGE
-# API_REV - advance on any added API
-# RUNNING_REV - advance any change to the vendor files
-# AGE - number of backward versions the API still supports
-LIBVERSION=1:0:0
diff --git a/contrib/ofed/management/libibcommon/src/hash.c b/contrib/ofed/management/libibcommon/src/hash.c
deleted file mode 100644
index 05fbff2..0000000
--- a/contrib/ofed/management/libibcommon/src/hash.c
+++ /dev/null
@@ -1,153 +0,0 @@
-/*
- * Copyright (c) 2005 Voltaire Inc. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- */
-
-/*
- * By Bob Jenkins, 1996. bob_jenkins@burtleburtle.net. You may use this
- * code any way you wish, private, educational, or commercial. It's free.
- *
- * See http://burtleburtle.net/bob/hash/evahash.html
- * Use for hash table lookup, or anything where one collision in 2^^32 is
- * acceptable. Do NOT use for cryptographic purposes.
- */
-
-#include <common.h>
-
-#define hashsize(n) ((uint32)1<<(n))
-#define hashmask(n) (hashsize(n)-1)
-
-
-/*
---------------------------------------------------------------------
-mix -- mix 3 32-bit values reversibly.
-For every delta with one or two bits set, and the deltas of all three
- high bits or all three low bits, whether the original value of a,b,c
- is almost all zero or is uniformly distributed,
-* If mix() is run forward or backward, at least 32 bits in a,b,c
- have at least 1/4 probability of changing.
-* If mix() is run forward, every bit of c will change between 1/3 and
- 2/3 of the time. (Well, 22/100 and 78/100 for some 2-bit deltas.)
-mix() was built out of 36 single-cycle latency instructions in a
- structure that could supported 2x parallelism, like so:
- a -= b;
- a -= c; x = (c>>13);
- b -= c; a ^= x;
- b -= a; x = (a<<8);
- c -= a; b ^= x;
- c -= b; x = (b>>13);
- ...
- Unfortunately, superscalar Pentiums and Sparcs can't take advantage
- of that parallelism. They've also turned some of those single-cycle
- latency instructions into multi-cycle latency instructions. Still,
- this is the fastest good hash I could find. There were about 2^^68
- to choose from. I only looked at a billion or so.
---------------------------------------------------------------------
-*/
-#define mix(a,b,c) \
-{ \
- a -= b; a -= c; a ^= (c>>13); \
- b -= c; b -= a; b ^= (a<<8); \
- c -= a; c -= b; c ^= (b>>13); \
- a -= b; a -= c; a ^= (c>>12); \
- b -= c; b -= a; b ^= (a<<16); \
- c -= a; c -= b; c ^= (b>>5); \
- a -= b; a -= c; a ^= (c>>3); \
- b -= c; b -= a; b ^= (a<<10); \
- c -= a; c -= b; c ^= (b>>15); \
-}
-
-/*
---------------------------------------------------------------------
-fhash() -- hash a variable-length key into a 32-bit value
- k : the key (the unaligned variable-length array of bytes)
- len : the length of the key, counting by bytes
- initval : can be any 4-byte value
-Returns a 32-bit value. Every bit of the key affects every bit of
-the return value. Every 1-bit and 2-bit delta achieves avalanche.
-About 6*len+35 instructions.
-
-The best hash table sizes are powers of 2. There is no need to do
-mod a prime (mod is sooo slow!). If you need less than 32 bits,
-use a bitmask. For example, if you need only 10 bits, do
- h = (h & hashmask(10));
-In which case, the hash table should have hashsize(10) elements.
-
-If you are hashing n strings (uint8 **)k, do it like this:
- for (i=0, h=0; i<n; ++i) h = hash( k[i], len[i], h);
-
---------------------------------------------------------------------
-*/
-
-uint32_t
-fhash(uint8_t *k, int length, uint32_t initval)
-{
- uint32_t a, b, c, len;
-
- /* Set up the internal state */
- len = length;
- a = b = 0x9e3779b9; /* the golden ratio; an arbitrary value */
- c = initval; /* the previous hash value */
-
- /* handle most of the key */
- while (len >= 12) {
- a += (k[0] + ((uint32_t)k[1]<<8) +
- ((uint32_t)k[2]<<16) + ((uint32_t)k[3]<<24));
- b += (k[4] + ((uint32_t)k[5]<<8) + ((uint32_t)k[6]<<16) +
- ((uint32_t)k[7]<<24));
- c += (k[8] + ((uint32_t)k[9]<<8) + ((uint32_t)k[10]<<16) +
- ((uint32_t)k[11]<<24));
- mix(a, b, c);
- k += 12; len -= 12;
- }
-
- /* handle the last 11 bytes */
- c += length;
- switch (len) { /* all the case statements fall through */
- case 11: c += ((uint32_t)k[10]<<24);
- case 10: c += ((uint32_t)k[9]<<16);
- case 9 : c += ((uint32_t)k[8]<<8);
- /* the first byte of c is reserved for the length */
- case 8 : b += ((uint32_t)k[7]<<24);
- case 7 : b += ((uint32_t)k[6]<<16);
- case 6 : b += ((uint32_t)k[5]<<8);
- case 5 : b += k[4];
- case 4 : a += ((uint32_t)k[3]<<24);
- case 3 : a += ((uint32_t)k[2]<<16);
- case 2 : a += ((uint32_t)k[1]<<8);
- case 1 : a += k[0];
- /* case 0: nothing left to add */
- }
-
- mix(a, b, c);
-
- return c;
-}
diff --git a/contrib/ofed/management/libibcommon/src/libibcommon.map b/contrib/ofed/management/libibcommon/src/libibcommon.map
deleted file mode 100644
index 5829158..0000000
--- a/contrib/ofed/management/libibcommon/src/libibcommon.map
+++ /dev/null
@@ -1,18 +0,0 @@
-IBCOMMON_1.0 {
- global:
- enable_stack_dump;
- stack_dump;
- sys_read_gid;
- sys_read_guid;
- sys_read_string;
- sys_read_uint;
- sys_read_uint64;
- sys_scandir;
- getcurrenttime;
- fhash;
- logmsg;
- ibpanic;
- ibwarn;
- xdump;
- local: *;
-};
diff --git a/contrib/ofed/management/libibcommon/src/stack.c b/contrib/ofed/management/libibcommon/src/stack.c
deleted file mode 100644
index a51edae..0000000
--- a/contrib/ofed/management/libibcommon/src/stack.c
+++ /dev/null
@@ -1,178 +0,0 @@
-/*
- * Copyright (c) 2004,2005 Voltaire Inc. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- */
-
-#define _GNU_SOURCE
-
-#if HAVE_CONFIG_H
-# include <config.h>
-#endif /* HAVE_CONFIG_H */
-
-#include <inttypes.h>
-#include <string.h>
-#include <errno.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <stdarg.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <sys/ioctl.h>
-#include <unistd.h>
-#include <string.h>
-#include <endian.h>
-#include <byteswap.h>
-#include <sys/poll.h>
-#include <syslog.h>
-#include <time.h>
-#include <signal.h>
-
-#include "common.h"
-
-static int loop_on_panic;
-
-void
-stack_dump(void)
-{
- if (!__builtin_frame_address(1))
- return
- syslog(LOG_ALERT, "#1 %p\n", __builtin_return_address(1));
-
- if (!__builtin_frame_address(2))
- return
- syslog(LOG_ALERT, "#2 %p\n", __builtin_return_address(2));
-
- if (!__builtin_frame_address(3))
- return
- syslog(LOG_ALERT, "#3 %p\n", __builtin_return_address(3));
-
- if (!__builtin_frame_address(4))
- return
- syslog(LOG_ALERT, "#4 %p\n", __builtin_return_address(4));
-
- if (!__builtin_frame_address(5))
- return
- syslog(LOG_ALERT, "#5 %p\n", __builtin_return_address(5));
-
- if (!__builtin_frame_address(6))
- return
- syslog(LOG_ALERT, "#6 %p\n", __builtin_return_address(6));
-
- if (!__builtin_frame_address(7))
- return
- syslog(LOG_ALERT, "#7 %p\n", __builtin_return_address(7));
-
- if (!__builtin_frame_address(8))
- return
- syslog(LOG_ALERT, "#8 %p\n", __builtin_return_address(8));
-
- if (!__builtin_frame_address(9))
- return
- syslog(LOG_ALERT, "#9 %p\n", __builtin_return_address(9));
-
- if (!__builtin_frame_address(10))
- return
- syslog(LOG_ALERT, "#10 %p\n", __builtin_return_address(10));
-
- if (!__builtin_frame_address(11))
- return
- syslog(LOG_ALERT, "#11 %p\n", __builtin_return_address(11));
-
- if (!__builtin_frame_address(12))
- return
- syslog(LOG_ALERT, "#12 %p\n", __builtin_return_address(12));
-
- if (!__builtin_frame_address(13))
- return
- syslog(LOG_ALERT, "#13 %p\n", __builtin_return_address(13));
-
- if (!__builtin_frame_address(14))
- return
- syslog(LOG_ALERT, "#14 %p\n", __builtin_return_address(14));
-
- if (!__builtin_frame_address(15))
- return
- syslog(LOG_ALERT, "#15 %p\n", __builtin_return_address(15));
-
- if (!__builtin_frame_address(16))
- return
- syslog(LOG_ALERT, "#16 %p\n", __builtin_return_address(16));
-
- if (!__builtin_frame_address(17))
- return
- syslog(LOG_ALERT, "#17 %p\n", __builtin_return_address(17));
-
- if (!__builtin_frame_address(18))
- return
- syslog(LOG_ALERT, "#18 %p\n", __builtin_return_address(18));
-}
-
-static void
-handler(int x)
-{
- static int in;
- time_t tm;
-
- if (!in) {
- in++;
-
- syslog(LOG_ALERT, "*** exception handler: died with signal %d", x);
- stack_dump();
-
- fflush(NULL);
-
- tm = time(0);
- fprintf(stderr, "%s *** exception handler: died with signal %d pid %d\n",
- ctime(&tm), x, getpid());
-
- fflush(NULL);
- }
-
- if (loop_on_panic) {
- fprintf(stderr, "exception handler: entering tight loop ... pid %d\n",getpid());
- for (; ; )
- ;
- }
-
- signal(x, SIG_DFL);
-}
-
-void
-enable_stack_dump(int loop)
-{
- loop_on_panic = loop;
- signal(SIGILL, handler);
- signal(SIGBUS, handler);
- signal(SIGSEGV, handler);
- signal(SIGABRT, handler);
-}
diff --git a/contrib/ofed/management/libibcommon/src/sysfs.c b/contrib/ofed/management/libibcommon/src/sysfs.c
deleted file mode 100644
index dfa722f..0000000
--- a/contrib/ofed/management/libibcommon/src/sysfs.c
+++ /dev/null
@@ -1,294 +0,0 @@
-/*
- * Copyright (c) 2004-2008 Voltaire Inc. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- */
-
-#define _GNU_SOURCE
-
-#if HAVE_CONFIG_H
-# include <config.h>
-#endif /* HAVE_CONFIG_H */
-
-#include <inttypes.h>
-#include <string.h>
-#include <errno.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <stdarg.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <sys/ioctl.h>
-#include <unistd.h>
-#include <string.h>
-#include <endian.h>
-#include <byteswap.h>
-#include <sys/poll.h>
-#include <syslog.h>
-#include <netinet/in.h>
-#include <errno.h>
-
-#include <sys/types.h>
-#include <sys/sysctl.h>
-
-#include "common.h"
-
-static int
-ret_code(void)
-{
- int e = errno;
-
- if (e > 0)
- return -e;
- return e;
-}
-
-int
-sys_read_string(char *dir_name, char *file_name, char *str, int max_len)
-{
- char path[256], *s;
- size_t len;
-
- snprintf(path, sizeof(path), "%s/%s", dir_name, file_name);
-
- for (s = &path[0]; *s != '\0'; s++)
- if (*s == '/')
- *s = '.';
-
- len = max_len;
- if (sysctlbyname(&path[1], str, &len, NULL, 0) == -1)
- return ret_code();
-
- str[(len < max_len) ? len : max_len - 1] = 0;
-
- if ((s = strrchr(str, '\n')))
- *s = 0;
-
- return 0;
-}
-
-int
-sys_read_guid(char *dir_name, char *file_name, uint64_t *net_guid)
-{
- char buf[32], *str, *s;
- uint64_t guid;
- int r, i;
-
- if ((r = sys_read_string(dir_name, file_name, buf, sizeof(buf))) < 0)
- return r;
-
- guid = 0;
-
- for (s = buf, i = 0 ; i < 4; i++) {
- if (!(str = strsep(&s, ": \t\n")))
- return -EINVAL;
- guid = (guid << 16) | (strtoul(str, 0, 16) & 0xffff);
- }
-
- *net_guid = htonll(guid);
-
- return 0;
-}
-
-int
-sys_read_gid(char *dir_name, char *file_name, uint8_t *gid)
-{
- char buf[64], *str, *s;
- uint16_t *ugid = (uint16_t *)gid;
- int r, i;
-
- if ((r = sys_read_string(dir_name, file_name, buf, sizeof(buf))) < 0)
- return r;
-
- for (s = buf, i = 0 ; i < 8; i++) {
- if (!(str = strsep(&s, ": \t\n")))
- return -EINVAL;
- ugid[i] = htons(strtoul(str, 0, 16) & 0xffff);
- }
-
- return 0;
-}
-
-int
-sys_read_uint64(char *dir_name, char *file_name, uint64_t *u)
-{
- char buf[32];
- int r;
-
- if ((r = sys_read_string(dir_name, file_name, buf, sizeof(buf))) < 0)
- return r;
-
- *u = strtoull(buf, 0, 0);
-
- return 0;
-}
-
-int
-sys_read_uint(char *dir_name, char *file_name, unsigned *u)
-{
- char buf[32];
- int r;
-
- if ((r = sys_read_string(dir_name, file_name, buf, sizeof(buf))) < 0)
- return r;
-
- *u = strtoul(buf, 0, 0);
-
- return 0;
-}
-
-#define DIRECTSIZ(namlen) \
- (((uintptr_t)&((struct dirent *)0)->d_name + \
- ((namlen)+1)*sizeof(((struct dirent *)0)->d_name[0]) + 3) & ~3)
-
-int
-sys_scandir(const char *dirname, struct dirent ***namelist,
- int (*select)(const struct dirent *),
- int (*compar)(const struct dirent **, const struct dirent **))
-{
- struct dirent **names;
- struct dirent **names2;
- struct dirent *dp;
- char name[1024];
- int lsname[22];
- int chname[22];
- int name2[22];
- int oid[22];
- char *s;
- size_t n1, n2;
- size_t len, oidlen, namlen;
- int cnt, max;
- int err;
- int i;
-
- *namelist = NULL;
- /* Skip the leading / */
- strncpy(name, &dirname[1], sizeof(name));
- for (s = &name[0]; *s != '\0'; s++)
- if (*s == '/')
- *s = '.';
- /*
- * Resolve the path.
- */
- len = sizeof(oid) / sizeof(int);
- namlen = strlen(name) + 1;
- if (sysctlnametomib(name, oid, &len) != 0)
- return (-errno);
- lsname[0] = 0; /* Root */
- lsname[1] = 2; /* Get next */
- memcpy(lsname+2, oid, len * sizeof(int));
- n1 = 2 + len;
- oidlen = len;
- /*
- * Setup the return list of dirents.
- */
- cnt = 0;
- max = 64;
- names = malloc(max * sizeof(void *));
- if (names == NULL)
- return (-ENOMEM);
-
- for (;;) {
- n2 = sizeof(name2);
- if (sysctl(lsname, n1, name2, &n2, 0, 0) < 0) {
- if (errno == ENOENT)
- break;
- goto errout;
- }
- n2 /= sizeof(int);
- if (n2 < oidlen)
- break;
- for (i = 0; i < oidlen; i++)
- if (name2[i] != oid[i])
- goto out;
- chname[0] = 0; /* root */
- chname[1] = 1; /* oid name */
- memcpy(chname + 2, name2, n2 * sizeof(int));
- memcpy(lsname + 2, name2, n2 * sizeof(int));
- n1 = 2 + n2;
- /*
- * scandir() is not supposed to go deeper than the requested
- * directory but sysctl also doesn't return a node for
- * 'subdirectories' so we have to find a file in the subdir
- * and then truncate the name to report it.
- */
- if (n2 > oidlen + 1) {
- /* Skip to the next name after this one. */
- n1 = 2 + oidlen + 1;
- lsname[n1 - 1]++;
- }
- len = sizeof(name);
- if (sysctl(chname, n2 + 2, name, &len, 0, 0) < 0)
- goto errout;
- if (len <= 0 || len < namlen)
- goto out;
- s = name + namlen;
- /* Just keep the first level name. */
- if (strchr(s, '.'))
- *strchr(s, '.') = '\0';
- len = strlen(s) + 1;
- dp = malloc(DIRECTSIZ(len));
- dp->d_reclen = DIRECTSIZ(len);
- dp->d_namlen = len;
- memcpy(&dp->d_name, s, len);
- if (select && !select(dp)) {
- free(dp);
- continue;
- }
- if (cnt == max) {
- max *= 2;
- names2 = realloc(names, max * sizeof(void *));
- if (names2 == NULL) {
- errno = ENOMEM;
- free(dp);
- goto errout;
- }
- names = names2;
- }
- names[cnt++] = dp;
- }
-out:
- if (cnt && compar)
- qsort(names, cnt, sizeof(struct dirent *),
- (int (*)(const void *, const void *))compar);
-
- *namelist = names;
-
- return (cnt);
-
-errout:
- err = errno;
- for (i = 0; i < cnt; i++)
- free(names[i]);
- free(names);
- return (-err);
-}
diff --git a/contrib/ofed/management/libibcommon/src/time.c b/contrib/ofed/management/libibcommon/src/time.c
deleted file mode 100644
index 7354d6a..0000000
--- a/contrib/ofed/management/libibcommon/src/time.c
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Copyright (c) 2004,2005 Voltaire Inc. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- */
-
-#include <common.h>
-#include <sys/time.h>
-
-/**
- * getcurrenttime: Returns micro seconds elapsed from epoch.
- */
-uint64_t
-getcurrenttime(void)
-{
- struct timeval tv;
-
- gettimeofday(&tv, 0);
- return (uint64_t)tv.tv_sec * 1000000 + tv.tv_usec;
-}
diff --git a/contrib/ofed/management/libibcommon/src/util.c b/contrib/ofed/management/libibcommon/src/util.c
deleted file mode 100644
index 4b91644..0000000
--- a/contrib/ofed/management/libibcommon/src/util.c
+++ /dev/null
@@ -1,132 +0,0 @@
-/*
- * Copyright (c) 2004-2008 Voltaire Inc. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- */
-
-#define _GNU_SOURCE
-
-#if HAVE_CONFIG_H
-# include <config.h>
-#endif /* HAVE_CONFIG_H */
-
-#include <inttypes.h>
-#include <string.h>
-#include <errno.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <stdarg.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <sys/ioctl.h>
-#include <unistd.h>
-#include <string.h>
-#include <endian.h>
-#include <byteswap.h>
-#include <sys/poll.h>
-#include <syslog.h>
-#include <netinet/in.h>
-
-#include <common.h>
-
-void
-ibwarn(const char * const fn, char *msg, ...)
-{
- char buf[512];
- va_list va;
- int n;
-
- va_start(va, msg);
- n = vsnprintf(buf, sizeof(buf), msg, va);
- va_end(va);
-
- printf("ibwarn: [%d] %s: %s\n", getpid(), fn, buf);
-}
-
-void
-ibpanic(const char * const fn, char *msg, ...)
-{
- char buf[512];
- va_list va;
- int n;
-
- va_start(va, msg);
- n = vsnprintf(buf, sizeof(buf), msg, va);
- va_end(va);
-
- printf("ibpanic: [%d] %s: %s: (%m)\n", getpid(), fn, buf);
- syslog(LOG_ALERT, "ibpanic: [%d] %s: %s: (%m)\n", getpid(), fn, buf);
-
- exit(-1);
-}
-
-void
-logmsg(const char * const fn, char *msg, ...)
-{
- char buf[512];
- va_list va;
- int n;
-
- va_start(va, msg);
- n = vsnprintf(buf, sizeof(buf), msg, va);
- va_end(va);
-
- syslog(LOG_ALERT, "[%d] %s: %s: (%m)\n", getpid(), fn, buf);
-}
-
-void
-xdump(FILE *file, char *msg, void *p, int size)
-{
-#define HEX(x) ((x) < 10 ? '0' + (x) : 'a' + ((x) -10))
- uint8_t *cp = p;
- int i;
-
- if (msg)
- fputs(msg, file);
-
- for (i = 0; i < size;) {
- fputc(HEX(*cp >> 4), file);
- fputc(HEX(*cp & 0xf), file);
- if (++i >= size)
- break;
- fputc(HEX(cp[1] >> 4), file);
- fputc(HEX(cp[1] & 0xf), file);
- if ((++i) % 16)
- fputc(' ', file);
- else
- fputc('\n', file);
- cp += 2;
- }
- if (i % 16) {
- fputc('\n', file);
- }
-}
diff --git a/contrib/ofed/management/libibmad/AUTHORS b/contrib/ofed/management/libibmad/AUTHORS
deleted file mode 100644
index d09c13f..0000000
--- a/contrib/ofed/management/libibmad/AUTHORS
+++ /dev/null
@@ -1,3 +0,0 @@
-Shahar Frank <shahar@voltaire.com>
-Hal Rosenstock <halr@voltaire.com>
-Sasha Khapyorsky <sashak@voltaire.com>
diff --git a/contrib/ofed/management/libibmad/COPYING b/contrib/ofed/management/libibmad/COPYING
deleted file mode 100644
index 1b1ca1d..0000000
--- a/contrib/ofed/management/libibmad/COPYING
+++ /dev/null
@@ -1,384 +0,0 @@
-This software with the exception of OpenSM is available to you
-under a choice of one of two licenses. You may chose to be
-licensed under the terms of the the OpenIB.org BSD license or
-the GNU General Public License (GPL) Version 2, both included
-below.
-
-OpenSM is licensed under either GNU General Public License (GPL)
-Version 2, or Intel BSD + Patent license. See OpenSM for the
-specific language for the latter licensing terms.
-
-
-Copyright (c) 2004-2008 Voltaire, Inc. All rights reserved.
-
-==================================================================
-
- OpenIB.org BSD license
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions
-are met:
-
- * Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
-
- * Redistributions in binary form must reproduce the above
- copyright notice, this list of conditions and the following
- disclaimer in the documentation and/or other materials provided
- with the distribution.
-
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
-FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
-COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
-INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
-BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
-LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
-CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
-ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-POSSIBILITY OF SUCH DAMAGE.
-
-==================================================================
-
- GNU GENERAL PUBLIC LICENSE
- Version 2, June 1991
-
- Copyright (C) 1989, 1991 Free Software Foundation, Inc.
- 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- Everyone is permitted to copy and distribute verbatim copies
- of this license document, but changing it is not allowed.
-
- Preamble
-
- The licenses for most software are designed to take away your
-freedom to share and change it. By contrast, the GNU General Public
-License is intended to guarantee your freedom to share and change free
-software--to make sure the software is free for all its users. This
-General Public License applies to most of the Free Software
-Foundation's software and to any other program whose authors commit to
-using it. (Some other Free Software Foundation software is covered by
-the GNU Library General Public License instead.) You can apply it to
-your programs, too.
-
- When we speak of free software, we are referring to freedom, not
-price. Our General Public Licenses are designed to make sure that you
-have the freedom to distribute copies of free software (and charge for
-this service if you wish), that you receive source code or can get it
-if you want it, that you can change the software or use pieces of it
-in new free programs; and that you know you can do these things.
-
- To protect your rights, we need to make restrictions that forbid
-anyone to deny you these rights or to ask you to surrender the rights.
-These restrictions translate to certain responsibilities for you if you
-distribute copies of the software, or if you modify it.
-
- For example, if you distribute copies of such a program, whether
-gratis or for a fee, you must give the recipients all the rights that
-you have. You must make sure that they, too, receive or can get the
-source code. And you must show them these terms so they know their
-rights.
-
- We protect your rights with two steps: (1) copyright the software, and
-(2) offer you this license which gives you legal permission to copy,
-distribute and/or modify the software.
-
- Also, for each author's protection and ours, we want to make certain
-that everyone understands that there is no warranty for this free
-software. If the software is modified by someone else and passed on, we
-want its recipients to know that what they have is not the original, so
-that any problems introduced by others will not reflect on the original
-authors' reputations.
-
- Finally, any free program is threatened constantly by software
-patents. We wish to avoid the danger that redistributors of a free
-program will individually obtain patent licenses, in effect making the
-program proprietary. To prevent this, we have made it clear that any
-patent must be licensed for everyone's free use or not licensed at all.
-
- The precise terms and conditions for copying, distribution and
-modification follow.
-
- GNU GENERAL PUBLIC LICENSE
- TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
-
- 0. This License applies to any program or other work which contains
-a notice placed by the copyright holder saying it may be distributed
-under the terms of this General Public License. The "Program", below,
-refers to any such program or work, and a "work based on the Program"
-means either the Program or any derivative work under copyright law:
-that is to say, a work containing the Program or a portion of it,
-either verbatim or with modifications and/or translated into another
-language. (Hereinafter, translation is included without limitation in
-the term "modification".) Each licensee is addressed as "you".
-
-Activities other than copying, distribution and modification are not
-covered by this License; they are outside its scope. The act of
-running the Program is not restricted, and the output from the Program
-is covered only if its contents constitute a work based on the
-Program (independent of having been made by running the Program).
-Whether that is true depends on what the Program does.
-
- 1. You may copy and distribute verbatim copies of the Program's
-source code as you receive it, in any medium, provided that you
-conspicuously and appropriately publish on each copy an appropriate
-copyright notice and disclaimer of warranty; keep intact all the
-notices that refer to this License and to the absence of any warranty;
-and give any other recipients of the Program a copy of this License
-along with the Program.
-
-You may charge a fee for the physical act of transferring a copy, and
-you may at your option offer warranty protection in exchange for a fee.
-
- 2. You may modify your copy or copies of the Program or any portion
-of it, thus forming a work based on the Program, and copy and
-distribute such modifications or work under the terms of Section 1
-above, provided that you also meet all of these conditions:
-
- a) You must cause the modified files to carry prominent notices
- stating that you changed the files and the date of any change.
-
- b) You must cause any work that you distribute or publish, that in
- whole or in part contains or is derived from the Program or any
- part thereof, to be licensed as a whole at no charge to all third
- parties under the terms of this License.
-
- c) If the modified program normally reads commands interactively
- when run, you must cause it, when started running for such
- interactive use in the most ordinary way, to print or display an
- announcement including an appropriate copyright notice and a
- notice that there is no warranty (or else, saying that you provide
- a warranty) and that users may redistribute the program under
- these conditions, and telling the user how to view a copy of this
- License. (Exception: if the Program itself is interactive but
- does not normally print such an announcement, your work based on
- the Program is not required to print an announcement.)
-
-These requirements apply to the modified work as a whole. If
-identifiable sections of that work are not derived from the Program,
-and can be reasonably considered independent and separate works in
-themselves, then this License, and its terms, do not apply to those
-sections when you distribute them as separate works. But when you
-distribute the same sections as part of a whole which is a work based
-on the Program, the distribution of the whole must be on the terms of
-this License, whose permissions for other licensees extend to the
-entire whole, and thus to each and every part regardless of who wrote it.
-
-Thus, it is not the intent of this section to claim rights or contest
-your rights to work written entirely by you; rather, the intent is to
-exercise the right to control the distribution of derivative or
-collective works based on the Program.
-
-In addition, mere aggregation of another work not based on the Program
-with the Program (or with a work based on the Program) on a volume of
-a storage or distribution medium does not bring the other work under
-the scope of this License.
-
- 3. You may copy and distribute the Program (or a work based on it,
-under Section 2) in object code or executable form under the terms of
-Sections 1 and 2 above provided that you also do one of the following:
-
- a) Accompany it with the complete corresponding machine-readable
- source code, which must be distributed under the terms of Sections
- 1 and 2 above on a medium customarily used for software interchange; or,
-
- b) Accompany it with a written offer, valid for at least three
- years, to give any third party, for a charge no more than your
- cost of physically performing source distribution, a complete
- machine-readable copy of the corresponding source code, to be
- distributed under the terms of Sections 1 and 2 above on a medium
- customarily used for software interchange; or,
-
- c) Accompany it with the information you received as to the offer
- to distribute corresponding source code. (This alternative is
- allowed only for noncommercial distribution and only if you
- received the program in object code or executable form with such
- an offer, in accord with Subsection b above.)
-
-The source code for a work means the preferred form of the work for
-making modifications to it. For an executable work, complete source
-code means all the source code for all modules it contains, plus any
-associated interface definition files, plus the scripts used to
-control compilation and installation of the executable. However, as a
-special exception, the source code distributed need not include
-anything that is normally distributed (in either source or binary
-form) with the major components (compiler, kernel, and so on) of the
-operating system on which the executable runs, unless that component
-itself accompanies the executable.
-
-If distribution of executable or object code is made by offering
-access to copy from a designated place, then offering equivalent
-access to copy the source code from the same place counts as
-distribution of the source code, even though third parties are not
-compelled to copy the source along with the object code.
-
- 4. You may not copy, modify, sublicense, or distribute the Program
-except as expressly provided under this License. Any attempt
-otherwise to copy, modify, sublicense or distribute the Program is
-void, and will automatically terminate your rights under this License.
-However, parties who have received copies, or rights, from you under
-this License will not have their licenses terminated so long as such
-parties remain in full compliance.
-
- 5. You are not required to accept this License, since you have not
-signed it. However, nothing else grants you permission to modify or
-distribute the Program or its derivative works. These actions are
-prohibited by law if you do not accept this License. Therefore, by
-modifying or distributing the Program (or any work based on the
-Program), you indicate your acceptance of this License to do so, and
-all its terms and conditions for copying, distributing or modifying
-the Program or works based on it.
-
- 6. Each time you redistribute the Program (or any work based on the
-Program), the recipient automatically receives a license from the
-original licensor to copy, distribute or modify the Program subject to
-these terms and conditions. You may not impose any further
-restrictions on the recipients' exercise of the rights granted herein.
-You are not responsible for enforcing compliance by third parties to
-this License.
-
- 7. If, as a consequence of a court judgment or allegation of patent
-infringement or for any other reason (not limited to patent issues),
-conditions are imposed on you (whether by court order, agreement or
-otherwise) that contradict the conditions of this License, they do not
-excuse you from the conditions of this License. If you cannot
-distribute so as to satisfy simultaneously your obligations under this
-License and any other pertinent obligations, then as a consequence you
-may not distribute the Program at all. For example, if a patent
-license would not permit royalty-free redistribution of the Program by
-all those who receive copies directly or indirectly through you, then
-the only way you could satisfy both it and this License would be to
-refrain entirely from distribution of the Program.
-
-If any portion of this section is held invalid or unenforceable under
-any particular circumstance, the balance of the section is intended to
-apply and the section as a whole is intended to apply in other
-circumstances.
-
-It is not the purpose of this section to induce you to infringe any
-patents or other property right claims or to contest validity of any
-such claims; this section has the sole purpose of protecting the
-integrity of the free software distribution system, which is
-implemented by public license practices. Many people have made
-generous contributions to the wide range of software distributed
-through that system in reliance on consistent application of that
-system; it is up to the author/donor to decide if he or she is willing
-to distribute software through any other system and a licensee cannot
-impose that choice.
-
-This section is intended to make thoroughly clear what is believed to
-be a consequence of the rest of this License.
-
- 8. If the distribution and/or use of the Program is restricted in
-certain countries either by patents or by copyrighted interfaces, the
-original copyright holder who places the Program under this License
-may add an explicit geographical distribution limitation excluding
-those countries, so that distribution is permitted only in or among
-countries not thus excluded. In such case, this License incorporates
-the limitation as if written in the body of this License.
-
- 9. The Free Software Foundation may publish revised and/or new versions
-of the General Public License from time to time. Such new versions will
-be similar in spirit to the present version, but may differ in detail to
-address new problems or concerns.
-
-Each version is given a distinguishing version number. If the Program
-specifies a version number of this License which applies to it and "any
-later version", you have the option of following the terms and conditions
-either of that version or of any later version published by the Free
-Software Foundation. If the Program does not specify a version number of
-this License, you may choose any version ever published by the Free Software
-Foundation.
-
- 10. If you wish to incorporate parts of the Program into other free
-programs whose distribution conditions are different, write to the author
-to ask for permission. For software which is copyrighted by the Free
-Software Foundation, write to the Free Software Foundation; we sometimes
-make exceptions for this. Our decision will be guided by the two goals
-of preserving the free status of all derivatives of our free software and
-of promoting the sharing and reuse of software generally.
-
- NO WARRANTY
-
- 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
-FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
-OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
-PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
-OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
-MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
-TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
-PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
-REPAIR OR CORRECTION.
-
- 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
-WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
-REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
-INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
-OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
-TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
-YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
-PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
-POSSIBILITY OF SUCH DAMAGES.
-
- END OF TERMS AND CONDITIONS
-
- How to Apply These Terms to Your New Programs
-
- If you develop a new program, and you want it to be of the greatest
-possible use to the public, the best way to achieve this is to make it
-free software which everyone can redistribute and change under these terms.
-
- To do so, attach the following notices to the program. It is safest
-to attach them to the start of each source file to most effectively
-convey the exclusion of warranty; and each file should have at least
-the "copyright" line and a pointer to where the full notice is found.
-
- <one line to give the program's name and a brief idea of what it does.>
- Copyright (C) <year> <name of author>
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program 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 this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-
-Also add information on how to contact you by electronic and paper mail.
-
-If the program is interactive, make it output a short notice like this
-when it starts in an interactive mode:
-
- Gnomovision version 69, Copyright (C) year name of author
- Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
- This is free software, and you are welcome to redistribute it
- under certain conditions; type `show c' for details.
-
-The hypothetical commands `show w' and `show c' should show the appropriate
-parts of the General Public License. Of course, the commands you use may
-be called something other than `show w' and `show c'; they could even be
-mouse-clicks or menu items--whatever suits your program.
-
-You should also get your employer (if you work as a programmer) or your
-school, if any, to sign a "copyright disclaimer" for the program, if
-necessary. Here is a sample; alter the names:
-
- Yoyodyne, Inc., hereby disclaims all copyright interest in the program
- `Gnomovision' (which makes passes at compilers) written by James Hacker.
-
- <signature of Ty Coon>, 1 April 1989
- Ty Coon, President of Vice
-
-This General Public License does not permit incorporating your program into
-proprietary programs. If your program is a subroutine library, you may
-consider it more useful to permit linking proprietary applications with the
-library. If this is what you want to do, use the GNU Library General
-Public License instead of this License.
diff --git a/contrib/ofed/management/libibmad/ChangeLog b/contrib/ofed/management/libibmad/ChangeLog
deleted file mode 100644
index 0c4c337..0000000
--- a/contrib/ofed/management/libibmad/ChangeLog
+++ /dev/null
@@ -1,88 +0,0 @@
-2008-06-15 Max Matveev <makc@sgi.com>
- * Add extra entry points for most functions to allow explicit
- selection of HCA for MAD rpc.
- * Constify MAD port pointer for mad_rpc, mad_rpc_rmpp, and sa_rpc_call
-
-2007-07-10 Hal Rosenstock <halr@voltaire.com>
-
- * Release version 1.1.1.
-
-2007-06-26 Hal Rosenstock <halr@voltaire.com>
-
- * src/dump.c, src/fields.c, src/gs.c, src/rpc.c, src/sa.c,
- src/smp.c: Change uint to unsigned for strict ANSI
-
-2007-06-26 Michael S. Tsirkin <mst@dev.mellanox.co.il>
-
- * include/infiniband/mad.h: Change uint to unsigned
- for strict ANSI
-
-2007-06-18 Hal Rosenstock <halr@voltaire.com>
-
- * include/infiniband/mad.h, src/fields.c: Change IB_PORT_MTRU_CAP_F
- to IB_PORT_MTU_CAP_F
-
-2007-06-05 Sasha Khapyorsky <sashak@voltaire.com>
-
- * include/infiniband/mad.h, src/fields.c: Add Notice DataDetails
- fields for DataDetails, and trap 144 LID and CapabilityMask
-
-2007-05-21 Hal Rosenstock <halr@voltaire.com>
-
- * src/fields.c: Changed PortMulticastPkts to PortMulticastRcvPkts
-
-2007-03-29 Hal Rosenstock <halr@voltaire.com>
-
- * src/fields.c: Changed Xmt/RcvBytes to Xmt/RcvData
-
-2007-03-29 Hal Rosenstock <halr@voltaire.com>
-
- * Release version 1.1.0.
-
-2007-03-22 Hal Rosenstock <halr@voltaire.com>
-
- * src/mad.c: Implement GRH support in mad_build_pkt
-
- * include/infiniband/mad.h: In ib_portid_set, ensure
- grh_present is 0
-
- * src/portid.c: In portid2str, fix endian of dispay of GID
-
-2007-03-14 Hal Rosenstock <halr@voltaire.com>
-
- * include/infiniband/mad.h, src/fields.c: Add encode/decode
- support for GUID0 in SM GUIDInfo attribute
-
-2007-03-14 Dotan Barak <dotanb@mellanox.co.il>
-
- * include/infiniband/mad.h: Add GUIDInfo as SM attribute ID
-
-2007-02-08 Ira Weiny <weiny2@llnl.gov>
-
- * src/portid.c: Change DR path output to be comma separated
- decimal values like OpenSM
-
-2007-01-25 Hal Rosenstock <halr@voltaire.com>
-
- * Release version 1.0.2.
-
-2006-12-11 Hal Rosenstock <halr@voltaire.com>
-
- * src/(sa serv smp vendor).c: Change some debug parameters
- to hex from decimal
-
-2006-11-20 Sasha Khapyorsky <sashak@voltaire.com>
-
- * src/rpc.c: Fix various uses of printf() style functions
-
-2006-10-20 Hal Rosenstock <halr@voltaire.com>
-
- * include/infiniband/mad.h, src/resolve.c (ib_resolve_portid_str),
- src/smp.c (smp_set), src/mad.c (mad_build_pkt),
- src/portid.c (portid2str): Add and handle IB_DEST_DRSLID.
-
-2006-10-09 Hal Rosenstock <halr@voltaire.com>
-
- * src/resolve.c (ib_resolve_portid_str): Use strtoull rather than
- strtoll for IB_DEST_GUID
-
diff --git a/contrib/ofed/management/libibmad/Makefile.am b/contrib/ofed/management/libibmad/Makefile.am
deleted file mode 100644
index beae1a4..0000000
--- a/contrib/ofed/management/libibmad/Makefile.am
+++ /dev/null
@@ -1,34 +0,0 @@
-
-SUBDIRS = .
-
-INCLUDES = -I$(srcdir)/include/infiniband -I$(includedir)
-
-lib_LTLIBRARIES = libibmad.la
-
-libibmad_la_CFLAGS = -Wall
-
-if HAVE_LD_VERSION_SCRIPT
-libibmad_version_script = -Wl,--version-script=$(srcdir)/src/libibmad.map
-else
-libibmad_version_script =
-endif
-
-libibmad_la_SOURCES = src/dump.c src/fields.c src/mad.c src/portid.c \
- src/resolve.c src/rpc.c src/sa.c src/smp.c src/gs.c \
- src/serv.c src/register.c src/vendor.c
-
-libibmad_la_LDFLAGS = -version-info $(ibmad_api_version) \
- -export-dynamic $(libibmad_version_script)
-libibmad_la_DEPENDENCIES = $(srcdir)/src/libibmad.map
-
-libibmadincludedir = $(includedir)/infiniband
-
-libibmadinclude_HEADERS = $(srcdir)/include/infiniband/mad.h
-
-EXTRA_DIST = $(srcdir)/include/infiniband/mad.h libibmad.spec.in libibmad.spec \
- $(srcdir)/src/libibmad.map libibmad.ver autogen.sh
-
-dist-hook:
- if [ -x $(top_srcdir)/../gen_chlog.sh ] ; then \
- $(top_srcdir)/../gen_chlog.sh $(PACKAGE) > $(distdir)/ChangeLog ; \
- fi
diff --git a/contrib/ofed/management/libibmad/autogen.sh b/contrib/ofed/management/libibmad/autogen.sh
deleted file mode 100755
index 4827884..0000000
--- a/contrib/ofed/management/libibmad/autogen.sh
+++ /dev/null
@@ -1,11 +0,0 @@
-#! /bin/sh
-
-# create config dir if not exist
-test -d config || mkdir config
-
-set -x
-aclocal -I config
-libtoolize --force --copy
-autoheader
-automake --foreign --add-missing --copy
-autoconf
diff --git a/contrib/ofed/management/libibmad/configure.in b/contrib/ofed/management/libibmad/configure.in
deleted file mode 100644
index 3d8e73d..0000000
--- a/contrib/ofed/management/libibmad/configure.in
+++ /dev/null
@@ -1,70 +0,0 @@
-dnl Process this file with autoconf to produce a configure script.
-
-AC_PREREQ(2.57)
-AC_INIT(libibmad, 1.3.0, general@lists.openfabrics.org)
-AC_CONFIG_SRCDIR([src/sa.c])
-AC_CONFIG_AUX_DIR(config)
-AM_CONFIG_HEADER(config.h)
-AM_INIT_AUTOMAKE
-
-AC_SUBST(RELEASE, ${RELEASE:-unknown})
-AC_SUBST(TARBALL, ${TARBALL:-${PACKAGE}-${VERSION}.tar.gz})
-
-dnl the library version info is available in the file: libibmad.ver
-ibmad_api_version=`grep LIBVERSION $srcdir/libibmad.ver | sed 's/LIBVERSION=//'`
-if test -z $ibmad_api_version; then
- ibmad_api_version=1:0:0
-fi
-AC_SUBST(ibmad_api_version)
-
-AC_ARG_ENABLE(libcheck, [ --disable-libcheck do not test for presence of ib libraries],
-[ if test x$enableval = xno ; then
- disable_libcheck=yes
- fi
-])
-
-AM_PROG_LIBTOOL
-
-dnl Checks for programs
-AC_PROG_CC
-
-dnl Checks for libraries
-if test "$disable_libcheck" != "yes"
-then
-AC_CHECK_LIB(ibcommon, sys_read_string, [],
- AC_MSG_ERROR([sys_read_string() not found. libibmad requires libibcommon.]))
-AC_CHECK_LIB(ibumad, umad_init, [],
- AC_MSG_ERROR([umad_init() not found. libibmad requires libibumad.]))
-fi
-
-dnl Checks for header files.
-AC_HEADER_STDC
-AC_CHECK_HEADERS([netinet/in.h stdlib.h string.h sys/time.h unistd.h])
-if test "$disable_libcheck" != "yes"
-then
-AC_CHECK_HEADER(infiniband/common.h, [],
- AC_MSG_ERROR([<infiniband/common.h> not found. libibmad requires libibcommon.])
-)
-AC_CHECK_HEADER(infiniband/umad.h, [],
- AC_MSG_ERROR([<infiniband/umad.h> not found. libibmad requires libibumad.])
-)
-fi
-
-dnl Checks for library functions
-AC_CHECK_FUNCS([memset strrchr strtol])
-
-dnl Checks for typedefs, structures, and compiler characteristics.
-AC_C_CONST
-AC_C_INLINE
-
-AC_CACHE_CHECK(whether ld accepts --version-script, ac_cv_version_script,
- if test -n "`$LD --help < /dev/null 2>/dev/null | grep version-script`"; then
- ac_cv_version_script=yes
- else
- ac_cv_version_script=no
- fi)
-
-AM_CONDITIONAL(HAVE_LD_VERSION_SCRIPT, test "$ac_cv_version_script" = "yes")
-
-AC_CONFIG_FILES([Makefile libibmad.spec])
-AC_OUTPUT
diff --git a/contrib/ofed/management/libibmad/include/infiniband/mad.h b/contrib/ofed/management/libibmad/include/infiniband/mad.h
deleted file mode 100644
index c2ad148..0000000
--- a/contrib/ofed/management/libibmad/include/infiniband/mad.h
+++ /dev/null
@@ -1,905 +0,0 @@
-/*
- * Copyright (c) 2004-2007 Voltaire Inc. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- */
-#ifndef _MAD_H_
-#define _MAD_H_
-
-#include <stdint.h>
-#include <string.h>
-
-#ifdef __cplusplus
-# define BEGIN_C_DECLS extern "C" {
-# define END_C_DECLS }
-#else /* !__cplusplus */
-# define BEGIN_C_DECLS
-# define END_C_DECLS
-#endif /* __cplusplus */
-
-BEGIN_C_DECLS
-
-#define IB_SUBNET_PATH_HOPS_MAX 64
-#define IB_DEFAULT_SUBN_PREFIX 0xfe80000000000000llu
-#define IB_DEFAULT_QP1_QKEY 0x80010000
-
-#define IB_MAD_SIZE 256
-
-#define IB_SMP_DATA_OFFS 64
-#define IB_SMP_DATA_SIZE 64
-
-#define IB_VENDOR_RANGE1_DATA_OFFS 24
-#define IB_VENDOR_RANGE1_DATA_SIZE (IB_MAD_SIZE - IB_VENDOR_RANGE1_DATA_OFFS)
-
-#define IB_VENDOR_RANGE2_DATA_OFFS 40
-#define IB_VENDOR_RANGE2_DATA_SIZE (IB_MAD_SIZE - IB_VENDOR_RANGE2_DATA_OFFS)
-
-#define IB_SA_DATA_SIZE 200
-#define IB_SA_DATA_OFFS 56
-
-#define IB_PC_DATA_OFFS 64
-#define IB_PC_DATA_SZ (IB_MAD_SIZE - IB_PC_DATA_OFFS)
-
-#define IB_SA_MCM_RECSZ 53
-#define IB_SA_PR_RECSZ 64
-
-enum MAD_CLASSES {
- IB_SMI_CLASS = 0x1,
- IB_SMI_DIRECT_CLASS = 0x81,
- IB_SA_CLASS = 0x3,
- IB_PERFORMANCE_CLASS = 0x4,
- IB_BOARD_MGMT_CLASS = 0x5,
- IB_DEVICE_MGMT_CLASS = 0x6,
- IB_CM_CLASS = 0x7,
- IB_SNMP_CLASS = 0x8,
- IB_VENDOR_RANGE1_START_CLASS = 0x9,
- IB_VENDOR_RANGE1_END_CLASS = 0x0f,
- IB_CC_CLASS = 0x21,
- IB_VENDOR_RANGE2_START_CLASS = 0x30,
- IB_VENDOR_RANGE2_END_CLASS = 0x4f,
-};
-
-enum MAD_METHODS {
- IB_MAD_METHOD_GET = 0x1,
- IB_MAD_METHOD_SET = 0x2,
- IB_MAD_METHOD_GET_RESPONSE = 0x81,
-
- IB_MAD_METHOD_SEND = 0x3,
- IB_MAD_METHOD_TRAP = 0x5,
- IB_MAD_METHOD_TRAP_REPRESS = 0x7,
-
- IB_MAD_METHOD_REPORT = 0x6,
- IB_MAD_METHOD_REPORT_RESPONSE = 0x86,
- IB_MAD_METHOD_GET_TABLE = 0x12,
- IB_MAD_METHOD_GET_TABLE_RESPONSE = 0x92,
- IB_MAD_METHOD_GET_TRACE_TABLE = 0x13,
- IB_MAD_METHOD_GET_TRACE_TABLE_RESPONSE = 0x93,
- IB_MAD_METHOD_GETMULTI = 0x14,
- IB_MAD_METHOD_GETMULTI_RESPONSE = 0x94,
- IB_MAD_METHOD_DELETE = 0x15,
- IB_MAD_METHOD_DELETE_RESPONSE = 0x95,
-
- IB_MAD_RESPONSE = 0x80,
-};
-
-enum MAD_ATTR_ID {
- CLASS_PORT_INFO = 0x1,
- NOTICE = 0x2,
- INFORM_INFO = 0x3,
-};
-
-enum SMI_ATTR_ID {
- IB_ATTR_NODE_DESC = 0x10,
- IB_ATTR_NODE_INFO = 0x11,
- IB_ATTR_SWITCH_INFO = 0x12,
- IB_ATTR_GUID_INFO = 0x14,
- IB_ATTR_PORT_INFO = 0x15,
- IB_ATTR_PKEY_TBL = 0x16,
- IB_ATTR_SLVL_TABLE = 0x17,
- IB_ATTR_VL_ARBITRATION = 0x18,
- IB_ATTR_LINEARFORWTBL = 0x19,
- IB_ATTR_MULTICASTFORWTBL = 0x1b,
- IB_ATTR_SMINFO = 0x20,
-
- IB_ATTR_LAST
-};
-
-enum SA_ATTR_ID {
- IB_SA_ATTR_NOTICE = 0x02,
- IB_SA_ATTR_INFORMINFO = 0x03,
- IB_SA_ATTR_PORTINFORECORD = 0x12,
- IB_SA_ATTR_LINKRECORD = 0x20,
- IB_SA_ATTR_SERVICERECORD = 0x31,
- IB_SA_ATTR_PATHRECORD = 0x35,
- IB_SA_ATTR_MCRECORD = 0x38,
- IB_SA_ATTR_MULTIPATH = 0x3a,
-
- IB_SA_ATTR_LAST
-};
-
-enum GSI_ATTR_ID {
- IB_GSI_PORT_SAMPLES_CONTROL = 0x10,
- IB_GSI_PORT_SAMPLES_RESULT = 0x11,
- IB_GSI_PORT_COUNTERS = 0x12,
- IB_GSI_PORT_COUNTERS_EXT = 0x1D,
-
- IB_GSI_ATTR_LAST
-};
-
-#define IB_VENDOR_OPENIB_PING_CLASS (IB_VENDOR_RANGE2_START_CLASS + 2)
-#define IB_VENDOR_OPENIB_SYSSTAT_CLASS (IB_VENDOR_RANGE2_START_CLASS + 3)
-#define IB_OPENIB_OUI (0x001405)
-
-typedef uint8_t ibmad_gid_t[16];
-#ifdef USE_DEPRECATED_IB_GID_T
-typedef ibmad_gid_t ib_gid_t __attribute__((deprecated));
-#endif
-
-typedef struct {
- int cnt;
- uint8_t p[IB_SUBNET_PATH_HOPS_MAX];
- uint16_t drslid;
- uint16_t drdlid;
-} ib_dr_path_t;
-
-typedef struct {
- unsigned id;
- unsigned mod;
-} ib_attr_t;
-
-typedef struct {
- int mgtclass;
- int method;
- ib_attr_t attr;
- uint32_t rstatus; /* return status */
- int dataoffs;
- int datasz;
- uint64_t mkey;
- uint64_t trid; /* used for out mad if nonzero, return real val */
- uint64_t mask; /* for sa mads */
- unsigned recsz; /* for sa mads (attribute offset) */
- int timeout;
- uint32_t oui; /* for vendor range 2 mads */
-} ib_rpc_t;
-
-typedef struct portid {
- int lid; /* lid or 0 if directed route */
- ib_dr_path_t drpath;
- int grh_present; /* flag */
- ibmad_gid_t gid;
- uint32_t qp;
- uint32_t qkey;
- uint8_t sl;
- unsigned pkey_idx;
-} ib_portid_t;
-
-typedef void (ib_mad_dump_fn)(char *buf, int bufsz, void *val, int valsz);
-
-#define IB_FIELD_NAME_LEN 32
-
-typedef struct ib_field {
- int bitoffs;
- int bitlen;
- char name[IB_FIELD_NAME_LEN];
- ib_mad_dump_fn *def_dump_fn;
-} ib_field_t;
-
-enum MAD_FIELDS {
- IB_NO_FIELD,
-
- IB_GID_PREFIX_F,
- IB_GID_GUID_F,
-
- /* first MAD word (0-3 bytes) */
- IB_MAD_METHOD_F,
- IB_MAD_RESPONSE_F,
- IB_MAD_CLASSVER_F,
- IB_MAD_MGMTCLASS_F,
- IB_MAD_BASEVER_F,
-
- /* second MAD word (4-7 bytes) */
- IB_MAD_STATUS_F,
-
- /* DRSMP only */
- IB_DRSMP_HOPCNT_F,
- IB_DRSMP_HOPPTR_F,
- IB_DRSMP_STATUS_F,
- IB_DRSMP_DIRECTION_F,
-
- /* words 3,4,5,6 (8-23 bytes) */
- IB_MAD_TRID_F,
- IB_MAD_ATTRID_F,
- IB_MAD_ATTRMOD_F,
-
- /* word 7,8 (24-31 bytes) */
- IB_MAD_MKEY_F,
-
- /* word 9 (32-37 bytes) */
- IB_DRSMP_DRSLID_F,
- IB_DRSMP_DRDLID_F,
-
- /* word 10,11 (36-43 bytes) */
- IB_SA_MKEY_F,
-
- /* word 12 (44-47 bytes) */
- IB_SA_ATTROFFS_F,
-
- /* word 13,14 (48-55 bytes) */
- IB_SA_COMPMASK_F,
-
- /* word 13,14 (56-255 bytes) */
- IB_SA_DATA_F,
-
- /* bytes 64 - 127 */
- IB_SM_DATA_F,
-
- /* bytes 64 - 256 */
- IB_GS_DATA_F,
-
- /* bytes 128 - 191 */
- IB_DRSMP_PATH_F,
-
- /* bytes 192 - 255 */
- IB_DRSMP_RPATH_F,
-
- /*
- * PortInfo fields:
- */
- IB_PORT_FIRST_F,
- IB_PORT_MKEY_F = IB_PORT_FIRST_F,
- IB_PORT_GID_PREFIX_F,
- IB_PORT_LID_F,
- IB_PORT_SMLID_F,
- IB_PORT_CAPMASK_F,
- IB_PORT_DIAG_F,
- IB_PORT_MKEY_LEASE_F,
- IB_PORT_LOCAL_PORT_F,
- IB_PORT_LINK_WIDTH_ENABLED_F,
- IB_PORT_LINK_WIDTH_SUPPORTED_F,
- IB_PORT_LINK_WIDTH_ACTIVE_F,
- IB_PORT_LINK_SPEED_SUPPORTED_F,
- IB_PORT_STATE_F,
- IB_PORT_PHYS_STATE_F,
- IB_PORT_LINK_DOWN_DEF_F,
- IB_PORT_MKEY_PROT_BITS_F,
- IB_PORT_LMC_F,
- IB_PORT_LINK_SPEED_ACTIVE_F,
- IB_PORT_LINK_SPEED_ENABLED_F,
- IB_PORT_NEIGHBOR_MTU_F,
- IB_PORT_SMSL_F,
- IB_PORT_VL_CAP_F,
- IB_PORT_INIT_TYPE_F,
- IB_PORT_VL_HIGH_LIMIT_F,
- IB_PORT_VL_ARBITRATION_HIGH_CAP_F,
- IB_PORT_VL_ARBITRATION_LOW_CAP_F,
- IB_PORT_INIT_TYPE_REPLY_F,
- IB_PORT_MTU_CAP_F,
- IB_PORT_VL_STALL_COUNT_F,
- IB_PORT_HOQ_LIFE_F,
- IB_PORT_OPER_VLS_F,
- IB_PORT_PART_EN_INB_F,
- IB_PORT_PART_EN_OUTB_F,
- IB_PORT_FILTER_RAW_INB_F,
- IB_PORT_FILTER_RAW_OUTB_F,
- IB_PORT_MKEY_VIOL_F,
- IB_PORT_PKEY_VIOL_F,
- IB_PORT_QKEY_VIOL_F,
- IB_PORT_GUID_CAP_F,
- IB_PORT_CLIENT_REREG_F,
- IB_PORT_SUBN_TIMEOUT_F,
- IB_PORT_RESP_TIME_VAL_F,
- IB_PORT_LOCAL_PHYS_ERR_F,
- IB_PORT_OVERRUN_ERR_F,
- IB_PORT_MAX_CREDIT_HINT_F,
- IB_PORT_LINK_ROUND_TRIP_F,
- IB_PORT_LAST_F,
-
- /*
- * NodeInfo fields:
- */
- IB_NODE_FIRST_F,
- IB_NODE_BASE_VERS_F = IB_NODE_FIRST_F,
- IB_NODE_CLASS_VERS_F,
- IB_NODE_TYPE_F,
- IB_NODE_NPORTS_F,
- IB_NODE_SYSTEM_GUID_F,
- IB_NODE_GUID_F,
- IB_NODE_PORT_GUID_F,
- IB_NODE_PARTITION_CAP_F,
- IB_NODE_DEVID_F,
- IB_NODE_REVISION_F,
- IB_NODE_LOCAL_PORT_F,
- IB_NODE_VENDORID_F,
- IB_NODE_LAST_F,
-
- /*
- * SwitchInfo fields:
- */
- IB_SW_FIRST_F,
- IB_SW_LINEAR_FDB_CAP_F = IB_SW_FIRST_F,
- IB_SW_RANDOM_FDB_CAP_F,
- IB_SW_MCAST_FDB_CAP_F,
- IB_SW_LINEAR_FDB_TOP_F,
- IB_SW_DEF_PORT_F,
- IB_SW_DEF_MCAST_PRIM_F,
- IB_SW_DEF_MCAST_NOT_PRIM_F,
- IB_SW_LIFE_TIME_F,
- IB_SW_STATE_CHANGE_F,
- IB_SW_LIDS_PER_PORT_F,
- IB_SW_PARTITION_ENFORCE_CAP_F,
- IB_SW_PARTITION_ENF_INB_F,
- IB_SW_PARTITION_ENF_OUTB_F,
- IB_SW_FILTER_RAW_INB_F,
- IB_SW_FILTER_RAW_OUTB_F,
- IB_SW_ENHANCED_PORT0_F,
- IB_SW_LAST_F,
-
- /*
- * SwitchLinearForwardingTable fields:
- */
- IB_LINEAR_FORW_TBL_F,
-
- /*
- * SwitchMulticastForwardingTable fields:
- */
- IB_MULTICAST_FORW_TBL_F,
-
- /*
- * NodeDescription fields:
- */
- IB_NODE_DESC_F,
-
- /*
- * Notice/Trap fields
- */
- IB_NOTICE_IS_GENERIC_F,
- IB_NOTICE_TYPE_F,
- IB_NOTICE_PRODUCER_F,
- IB_NOTICE_TRAP_NUMBER_F,
- IB_NOTICE_ISSUER_LID_F,
- IB_NOTICE_TOGGLE_F,
- IB_NOTICE_COUNT_F,
- IB_NOTICE_DATA_DETAILS_F,
- IB_NOTICE_DATA_LID_F,
- IB_NOTICE_DATA_144_LID_F,
- IB_NOTICE_DATA_144_CAPMASK_F,
-
- /*
- * GS Performance
- */
- IB_PC_FIRST_F,
- IB_PC_PORT_SELECT_F = IB_PC_FIRST_F,
- IB_PC_COUNTER_SELECT_F,
- IB_PC_ERR_SYM_F,
- IB_PC_LINK_RECOVERS_F,
- IB_PC_LINK_DOWNED_F,
- IB_PC_ERR_RCV_F,
- IB_PC_ERR_PHYSRCV_F,
- IB_PC_ERR_SWITCH_REL_F,
- IB_PC_XMT_DISCARDS_F,
- IB_PC_ERR_XMTCONSTR_F,
- IB_PC_ERR_RCVCONSTR_F,
- IB_PC_ERR_LOCALINTEG_F,
- IB_PC_ERR_EXCESS_OVR_F,
- IB_PC_VL15_DROPPED_F,
- IB_PC_XMT_BYTES_F,
- IB_PC_RCV_BYTES_F,
- IB_PC_XMT_PKTS_F,
- IB_PC_RCV_PKTS_F,
- IB_PC_LAST_F,
-
- /*
- * SMInfo
- */
- IB_SMINFO_GUID_F,
- IB_SMINFO_KEY_F,
- IB_SMINFO_ACT_F,
- IB_SMINFO_PRIO_F,
- IB_SMINFO_STATE_F,
-
- /*
- * SA RMPP
- */
- IB_SA_RMPP_VERS_F,
- IB_SA_RMPP_TYPE_F,
- IB_SA_RMPP_RESP_F,
- IB_SA_RMPP_FLAGS_F,
- IB_SA_RMPP_STATUS_F,
-
- /* data1 */
- IB_SA_RMPP_D1_F,
- IB_SA_RMPP_SEGNUM_F,
- /* data2 */
- IB_SA_RMPP_D2_F,
- IB_SA_RMPP_LEN_F, /* DATA: Payload len */
- IB_SA_RMPP_NEWWIN_F, /* ACK: new window last */
-
- /*
- * SA Multi Path rec
- */
- IB_SA_MP_NPATH_F,
- IB_SA_MP_NSRC_F,
- IB_SA_MP_NDEST_F,
- IB_SA_MP_GID0_F,
-
- /*
- * SA Path rec
- */
- IB_SA_PR_DGID_F,
- IB_SA_PR_SGID_F,
- IB_SA_PR_DLID_F,
- IB_SA_PR_SLID_F,
- IB_SA_PR_NPATH_F,
-
- /*
- * MC Member rec
- */
- IB_SA_MCM_MGID_F,
- IB_SA_MCM_PORTGID_F,
- IB_SA_MCM_QKEY_F,
- IB_SA_MCM_MLID_F,
- IB_SA_MCM_SL_F,
- IB_SA_MCM_MTU_F,
- IB_SA_MCM_RATE_F,
- IB_SA_MCM_TCLASS_F,
- IB_SA_MCM_PKEY_F,
- IB_SA_MCM_FLOW_LABEL_F,
- IB_SA_MCM_JOIN_STATE_F,
- IB_SA_MCM_PROXY_JOIN_F,
-
- /*
- * Service record
- */
- IB_SA_SR_ID_F,
- IB_SA_SR_GID_F,
- IB_SA_SR_PKEY_F,
- IB_SA_SR_LEASE_F,
- IB_SA_SR_KEY_F,
- IB_SA_SR_NAME_F,
- IB_SA_SR_DATA_F,
-
- /*
- * ATS SM record - within SA_SR_DATA
- */
- IB_ATS_SM_NODE_ADDR_F,
- IB_ATS_SM_MAGIC_KEY_F,
- IB_ATS_SM_NODE_TYPE_F,
- IB_ATS_SM_NODE_NAME_F,
-
- /*
- * SLTOVL MAPPING TABLE
- */
- IB_SLTOVL_MAPPING_TABLE_F,
-
- /*
- * VL ARBITRATION TABLE
- */
- IB_VL_ARBITRATION_TABLE_F,
-
- /*
- * IB vendor class range 2
- */
- IB_VEND2_OUI_F,
- IB_VEND2_DATA_F,
-
- /*
- * PortCountersExtended
- */
- IB_PC_EXT_FIRST_F,
- IB_PC_EXT_PORT_SELECT_F = IB_PC_EXT_FIRST_F,
- IB_PC_EXT_COUNTER_SELECT_F,
- IB_PC_EXT_XMT_BYTES_F,
- IB_PC_EXT_RCV_BYTES_F,
- IB_PC_EXT_XMT_PKTS_F,
- IB_PC_EXT_RCV_PKTS_F,
- IB_PC_EXT_XMT_UPKTS_F,
- IB_PC_EXT_RCV_UPKTS_F,
- IB_PC_EXT_XMT_MPKTS_F,
- IB_PC_EXT_RCV_MPKTS_F,
- IB_PC_EXT_LAST_F,
-
- /*
- * GUIDInfo fields
- */
- IB_GUID_GUID0_F,
-
- IB_FIELD_LAST_ /* must be last */
-};
-
-/*
- * SA RMPP section
- */
-enum RMPP_TYPE_ENUM {
- IB_RMPP_TYPE_NONE,
- IB_RMPP_TYPE_DATA,
- IB_RMPP_TYPE_ACK,
- IB_RMPP_TYPE_STOP,
- IB_RMPP_TYPE_ABORT,
-};
-
-enum RMPP_FLAGS_ENUM {
- IB_RMPP_FLAG_ACTIVE = 1 << 0,
- IB_RMPP_FLAG_FIRST = 1 << 1,
- IB_RMPP_FLAG_LAST = 1 << 2,
-};
-
-typedef struct {
- int type;
- int flags;
- int status;
- union {
- uint32_t u;
- uint32_t segnum;
- } d1;
- union {
- uint32_t u;
- uint32_t len;
- uint32_t newwin;
- } d2;
-} ib_rmpp_hdr_t;
-
-enum SA_SIZES_ENUM {
- SA_HEADER_SZ = 20,
-};
-
-typedef struct ib_sa_call {
- unsigned attrid;
- unsigned mod;
- uint64_t mask;
- unsigned method;
-
- uint64_t trid; /* used for out mad if nonzero, return real val */
- unsigned recsz; /* return field */
- ib_rmpp_hdr_t rmpp;
-} ib_sa_call_t;
-
-typedef struct ib_vendor_call {
- unsigned method;
- unsigned mgmt_class;
- unsigned attrid;
- unsigned mod;
- uint32_t oui;
- unsigned timeout;
- ib_rmpp_hdr_t rmpp;
-} ib_vendor_call_t;
-
-#define IB_MIN_UCAST_LID 1
-#define IB_MAX_UCAST_LID (0xc000-1)
-#define IB_MIN_MCAST_LID 0xc000
-#define IB_MAX_MCAST_LID (0xffff-1)
-
-#define IB_LID_VALID(lid) ((lid) >= IB_MIN_UCAST_LID && lid <= IB_MAX_UCAST_LID)
-#define IB_MLID_VALID(lid) ((lid) >= IB_MIN_MCAST_LID && lid <= IB_MAX_MCAST_LID)
-
-#define MAD_DEF_RETRIES 3
-#define MAD_DEF_TIMEOUT_MS 1000
-
-enum {
- IB_DEST_LID,
- IB_DEST_DRPATH,
- IB_DEST_GUID,
- IB_DEST_DRSLID,
-};
-
-enum {
- IB_NODE_CA = 1,
- IB_NODE_SWITCH,
- IB_NODE_ROUTER,
- NODE_RNIC,
-
- IB_NODE_MAX = NODE_RNIC
-};
-
-/******************************************************************************/
-
-/* portid.c */
-char * portid2str(ib_portid_t *portid);
-int portid2portnum(ib_portid_t *portid);
-int str2drpath(ib_dr_path_t *path, char *routepath, int drslid, int drdlid);
-char * drpath2str(ib_dr_path_t *path, char *dstr, size_t dstr_size);
-
-static inline int
-ib_portid_set(ib_portid_t *portid, int lid, int qp, int qkey)
-{
- portid->lid = lid;
- portid->qp = qp;
- portid->qkey = qkey;
- portid->grh_present = 0;
-
- return 0;
-}
-
-/* fields.c */
-extern ib_field_t ib_mad_f[];
-
-void _set_field(void *buf, int base_offs, ib_field_t *f, uint32_t val);
-uint32_t _get_field(void *buf, int base_offs, ib_field_t *f);
-void _set_array(void *buf, int base_offs, ib_field_t *f, void *val);
-void _get_array(void *buf, int base_offs, ib_field_t *f, void *val);
-void _set_field64(void *buf, int base_offs, ib_field_t *f, uint64_t val);
-uint64_t _get_field64(void *buf, int base_offs, ib_field_t *f);
-
-/* mad.c */
-static inline uint32_t
-mad_get_field(void *buf, int base_offs, int field)
-{
- return _get_field(buf, base_offs, ib_mad_f + field);
-}
-
-static inline void
-mad_set_field(void *buf, int base_offs, int field, uint32_t val)
-{
- _set_field(buf, base_offs, ib_mad_f + field, val);
-}
-
-/* field must be byte aligned */
-static inline uint64_t
-mad_get_field64(void *buf, int base_offs, int field)
-{
- return _get_field64(buf, base_offs, ib_mad_f + field);
-}
-
-static inline void
-mad_set_field64(void *buf, int base_offs, int field, uint64_t val)
-{
- _set_field64(buf, base_offs, ib_mad_f + field, val);
-}
-
-static inline void
-mad_set_array(void *buf, int base_offs, int field, void *val)
-{
- _set_array(buf, base_offs, ib_mad_f + field, val);
-}
-
-static inline void
-mad_get_array(void *buf, int base_offs, int field, void *val)
-{
- _get_array(buf, base_offs, ib_mad_f + field, val);
-}
-
-void mad_decode_field(uint8_t *buf, int field, void *val);
-void mad_encode_field(uint8_t *buf, int field, void *val);
-void * mad_encode(void *buf, ib_rpc_t *rpc, ib_dr_path_t *drpath, void *data);
-uint64_t mad_trid(void);
-int mad_build_pkt(void *umad, ib_rpc_t *rpc, ib_portid_t *dport, ib_rmpp_hdr_t *rmpp, void *data);
-
-/* register.c */
-int mad_register_port_client(int port_id, int mgmt, uint8_t rmpp_version);
-int mad_register_client(int mgmt, uint8_t rmpp_version);
-int mad_register_server(int mgmt, uint8_t rmpp_version,
- long method_mask[16/sizeof(long)],
- uint32_t class_oui);
-int mad_class_agent(int mgmt);
-int mad_agent_class(int agent);
-
-/* serv.c */
-int mad_send(ib_rpc_t *rpc, ib_portid_t *dport, ib_rmpp_hdr_t *rmpp,
- void *data);
-void * mad_receive(void *umad, int timeout);
-int mad_respond(void *umad, ib_portid_t *portid, uint32_t rstatus);
-void * mad_alloc(void);
-void mad_free(void *umad);
-
-/* vendor.c */
-uint8_t *ib_vendor_call(void *data, ib_portid_t *portid,
- ib_vendor_call_t *call);
-
-static inline int
-mad_is_vendor_range1(int mgmt)
-{
- return mgmt >= 0x9 && mgmt <= 0xf;
-}
-
-static inline int
-mad_is_vendor_range2(int mgmt)
-{
- return mgmt >= 0x30 && mgmt <= 0x4f;
-}
-
-/* rpc.c */
-int madrpc_portid(void);
-int madrpc_set_retries(int retries);
-int madrpc_set_timeout(int timeout);
-void * madrpc(ib_rpc_t *rpc, ib_portid_t *dport, void *payload, void *rcvdata);
-void * madrpc_rmpp(ib_rpc_t *rpc, ib_portid_t *dport, ib_rmpp_hdr_t *rmpp,
- void *data);
-void madrpc_init(char *dev_name, int dev_port, int *mgmt_classes,
- int num_classes);
-void madrpc_save_mad(void *madbuf, int len);
-void madrpc_lock(void);
-void madrpc_unlock(void);
-void madrpc_show_errors(int set);
-
-void * mad_rpc_open_port(char *dev_name, int dev_port, int *mgmt_classes,
- int num_classes);
-void mad_rpc_close_port(void *ibmad_port);
-void * mad_rpc(const void *ibmad_port, ib_rpc_t *rpc, ib_portid_t *dport,
- void *payload, void *rcvdata);
-void * mad_rpc_rmpp(const void *ibmad_port, ib_rpc_t *rpc, ib_portid_t *dport,
- ib_rmpp_hdr_t *rmpp, void *data);
-
-/* smp.c */
-uint8_t * smp_query(void *buf, ib_portid_t *id, unsigned attrid, unsigned mod,
- unsigned timeout);
-uint8_t * smp_set(void *buf, ib_portid_t *id, unsigned attrid, unsigned mod,
- unsigned timeout);
-uint8_t * smp_query_via(void *buf, ib_portid_t *id, unsigned attrid,
- unsigned mod, unsigned timeout, const void *srcport);
-uint8_t * smp_set_via(void *buf, ib_portid_t *id, unsigned attrid, unsigned mod,
- unsigned timeout, const void *srcport);
-
-inline static uint8_t *
-safe_smp_query(void *rcvbuf, ib_portid_t *portid, unsigned attrid, unsigned mod,
- unsigned timeout)
-{
- uint8_t *p;
-
- madrpc_lock();
- p = smp_query(rcvbuf, portid, attrid, mod, timeout);
- madrpc_unlock();
-
- return p;
-}
-
-inline static uint8_t *
-safe_smp_set(void *rcvbuf, ib_portid_t *portid, unsigned attrid, unsigned mod,
- unsigned timeout)
-{
- uint8_t *p;
-
- madrpc_lock();
- p = smp_set(rcvbuf, portid, attrid, mod, timeout);
- madrpc_unlock();
-
- return p;
-}
-
-/* sa.c */
-uint8_t * sa_call(void *rcvbuf, ib_portid_t *portid, ib_sa_call_t *sa,
- unsigned timeout);
-uint8_t * sa_rpc_call(const void *ibmad_port, void *rcvbuf, ib_portid_t *portid,
- ib_sa_call_t *sa, unsigned timeout);
-int ib_path_query(ibmad_gid_t srcgid, ibmad_gid_t destgid, ib_portid_t *sm_id,
- void *buf); /* returns lid */
-int ib_path_query_via(const void *srcport, ibmad_gid_t srcgid,
- ibmad_gid_t destgid, ib_portid_t *sm_id, void *buf);
-
-inline static uint8_t *
-safe_sa_call(void *rcvbuf, ib_portid_t *portid, ib_sa_call_t *sa,
- unsigned timeout)
-{
- uint8_t *p;
-
- madrpc_lock();
- p = sa_call(rcvbuf, portid, sa, timeout);
- madrpc_unlock();
-
- return p;
-}
-
-/* resolve.c */
-int ib_resolve_smlid(ib_portid_t *sm_id, int timeout);
-int ib_resolve_guid(ib_portid_t *portid, uint64_t *guid,
- ib_portid_t *sm_id, int timeout);
-int ib_resolve_portid_str(ib_portid_t *portid, char *addr_str,
- int dest_type, ib_portid_t *sm_id);
-int ib_resolve_self(ib_portid_t *portid, int *portnum, ibmad_gid_t *gid);
-
-int ib_resolve_smlid_via(ib_portid_t *sm_id, int timeout,
- const void *srcport);
-int ib_resolve_guid_via(ib_portid_t *portid, uint64_t *guid,
- ib_portid_t *sm_id, int timeout,
- const void *srcport);
-int ib_resolve_portid_str_via(ib_portid_t *portid, char *addr_str,
- int dest_type, ib_portid_t *sm_id,
- const void *srcport);
-int ib_resolve_self_via(ib_portid_t *portid, int *portnum, ibmad_gid_t *gid,
- const void *srcport);
-
-/* gs.c */
-uint8_t *perf_classportinfo_query(void *rcvbuf, ib_portid_t *dest, int port,
- unsigned timeout);
-uint8_t *port_performance_query(void *rcvbuf, ib_portid_t *dest, int port,
- unsigned timeout);
-uint8_t *port_performance_reset(void *rcvbuf, ib_portid_t *dest, int port,
- unsigned mask, unsigned timeout);
-uint8_t *port_performance_ext_query(void *rcvbuf, ib_portid_t *dest, int port,
- unsigned timeout);
-uint8_t *port_performance_ext_reset(void *rcvbuf, ib_portid_t *dest, int port,
- unsigned mask, unsigned timeout);
-uint8_t *port_samples_control_query(void *rcvbuf, ib_portid_t *dest, int port,
- unsigned timeout);
-uint8_t *port_samples_result_query(void *rcvbuf, ib_portid_t *dest, int port,
- unsigned timeout);
-
-uint8_t *perf_classportinfo_query_via(void *rcvbuf, ib_portid_t *dest, int port,
- unsigned timeout, const void *srcport);
-uint8_t *port_performance_query_via(void *rcvbuf, ib_portid_t *dest, int port,
- unsigned timeout, const void *srcport);
-uint8_t *port_performance_reset_via(void *rcvbuf, ib_portid_t *dest, int port,
- unsigned mask, unsigned timeout, const void *srcport);
-uint8_t *port_performance_ext_query_via(void *rcvbuf, ib_portid_t *dest, int port,
- unsigned timeout, const void *srcport);
-uint8_t *port_performance_ext_reset_via(void *rcvbuf, ib_portid_t *dest, int port,
- unsigned mask, unsigned timeout, const void *srcport);
-uint8_t *port_samples_control_query_via(void *rcvbuf, ib_portid_t *dest, int port,
- unsigned timeout, const void *srcport);
-uint8_t *port_samples_result_query_via(void *rcvbuf, ib_portid_t *dest, int port,
- unsigned timeout, const void *srcport);
-/* dump.c */
-ib_mad_dump_fn
- mad_dump_int, mad_dump_uint, mad_dump_hex, mad_dump_rhex,
- mad_dump_bitfield, mad_dump_array, mad_dump_string,
- mad_dump_linkwidth, mad_dump_linkwidthsup, mad_dump_linkwidthen,
- mad_dump_linkdowndefstate,
- mad_dump_linkspeed, mad_dump_linkspeedsup, mad_dump_linkspeeden,
- mad_dump_portstate, mad_dump_portstates,
- mad_dump_physportstate, mad_dump_portcapmask,
- mad_dump_mtu, mad_dump_vlcap, mad_dump_opervls,
- mad_dump_node_type,
- mad_dump_sltovl, mad_dump_vlarbitration,
- mad_dump_nodedesc, mad_dump_nodeinfo, mad_dump_portinfo, mad_dump_switchinfo,
- mad_dump_perfcounters, mad_dump_perfcounters_ext;
-
-int _mad_dump(ib_mad_dump_fn *fn, char *name, void *val, int valsz);
-char * _mad_dump_field(ib_field_t *f, char *name, char *buf, int bufsz,
- void *val);
-int _mad_print_field(ib_field_t *f, char *name, void *val, int valsz);
-char * _mad_dump_val(ib_field_t *f, char *buf, int bufsz, void *val);
-
-static inline int
-mad_print_field(int field, char *name, void *val)
-{
- if (field <= IB_NO_FIELD || field >= IB_FIELD_LAST_)
- return -1;
- return _mad_print_field(ib_mad_f + field, name, val, 0);
-}
-
-static inline char *
-mad_dump_field(int field, char *buf, int bufsz, void *val)
-{
- if (field <= IB_NO_FIELD || field >= IB_FIELD_LAST_)
- return 0;
- return _mad_dump_field(ib_mad_f + field, 0, buf, bufsz, val);
-}
-
-static inline char *
-mad_dump_val(int field, char *buf, int bufsz, void *val)
-{
- if (field <= IB_NO_FIELD || field >= IB_FIELD_LAST_)
- return 0;
- return _mad_dump_val(ib_mad_f + field, buf, bufsz, val);
-}
-
-extern int ibdebug;
-
-END_C_DECLS
-
-#endif /* _MAD_H_ */
diff --git a/contrib/ofed/management/libibmad/libibmad.spec.in b/contrib/ofed/management/libibmad/libibmad.spec.in
deleted file mode 100644
index 5fd10f6..0000000
--- a/contrib/ofed/management/libibmad/libibmad.spec.in
+++ /dev/null
@@ -1,73 +0,0 @@
-
-%define RELEASE @RELEASE@
-%define rel %{?CUSTOM_RELEASE} %{!?CUSTOM_RELEASE:%RELEASE}
-
-Summary: OpenFabrics Alliance InfiniBand MAD library
-Name: libibmad
-Version: @VERSION@
-Release: %rel%{?dist}
-License: GPLv2 or BSD
-Group: System Environment/Libraries
-BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
-Source: http://www.openfabrics.org/downloads/management/@TARBALL@
-Url: http://openfabrics.org/
-BuildRequires: libibumad-devel, libtool
-Requires(post): /sbin/ldconfig
-Requires(postun): /sbin/ldconfig
-
-%description
-libibmad provides low layer IB functions for use by the IB diagnostic
-and management programs. These include MAD, SA, SMP, and other basic
-IB functions.
-
-%package devel
-Summary: Development files for the libibmad library
-Group: System Environment/Libraries
-Requires: %{name} = %{version}-%{release} libibumad-devel
-Requires(post): /sbin/ldconfig
-Requires(postun): /sbin/ldconfig
-
-%description devel
-Development files for the libibmad library.
-
-%package static
-Summary: Static version of the libibmad library
-Group: System Environment/Libraries
-Requires: %{name} = %{version}-%{release}
-
-%description static
-Static version of the libibmad library
-
-%prep
-%setup -q
-
-%build
-%configure
-make %{?_smp_mflags}
-
-%install
-make DESTDIR=${RPM_BUILD_ROOT} install
-# remove unpackaged files from the buildroot
-rm -f $RPM_BUILD_ROOT%{_libdir}/*.la
-
-%clean
-rm -rf $RPM_BUILD_ROOT
-
-%post -p /sbin/ldconfig
-%postun -p /sbin/ldconfig
-%post devel -p /sbin/ldconfig
-%postun devel -p /sbin/ldconfig
-
-%files
-%defattr(-,root,root)
-%{_libdir}/libibmad*.so.*
-%doc AUTHORS COPYING ChangeLog
-
-%files devel
-%defattr(-,root,root)
-%{_libdir}/libibmad.so
-%{_includedir}/infiniband/*.h
-
-%files static
-%defattr(-,root,root)
-%{_libdir}/libibmad.a
diff --git a/contrib/ofed/management/libibmad/libibmad.ver b/contrib/ofed/management/libibmad/libibmad.ver
deleted file mode 100644
index 51f2b71..0000000
--- a/contrib/ofed/management/libibmad/libibmad.ver
+++ /dev/null
@@ -1,9 +0,0 @@
-# In this file we track the current API version
-# of the IB mad interface (and libraries)
-# The version is built of the following
-# tree numbers:
-# API_REV:RUNNING_REV:AGE
-# API_REV - advance on any added API
-# RUNNING_REV - advance any change to the vendor files
-# AGE - number of backward versions the API still supports
-LIBVERSION=4:0:3
diff --git a/contrib/ofed/management/libibmad/src/dump.c b/contrib/ofed/management/libibmad/src/dump.c
deleted file mode 100644
index 052127f..0000000
--- a/contrib/ofed/management/libibmad/src/dump.c
+++ /dev/null
@@ -1,782 +0,0 @@
-/*
- * Copyright (c) 2004-2008 Voltaire Inc. All rights reserved.
- * Copyright (c) 2007 Xsigo Systems Inc. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- */
-
-#if HAVE_CONFIG_H
-# include <config.h>
-#endif /* HAVE_CONFIG_H */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <string.h>
-#include <inttypes.h>
-#include <netinet/in.h>
-
-#include <mad.h>
-#include <infiniband/common.h>
-
-void
-mad_dump_int(char *buf, int bufsz, void *val, int valsz)
-{
- switch (valsz) {
- case 1:
- snprintf(buf, bufsz, "%d", *(uint8_t *)val);
- break;
- case 2:
- snprintf(buf, bufsz, "%d", *(uint16_t *)val);
- break;
- case 3:
- case 4:
- snprintf(buf, bufsz, "%d", *(uint32_t *)val);
- break;
- case 5:
- case 6:
- case 7:
- case 8:
- snprintf(buf, bufsz, "%" PRIu64, *(uint64_t *)val);
- break;
- default:
- IBWARN("bad int sz %d", valsz);
- buf[0] = 0;
- }
-}
-
-void
-mad_dump_uint(char *buf, int bufsz, void *val, int valsz)
-{
- switch (valsz) {
- case 1:
- snprintf(buf, bufsz, "%u", *(uint8_t *)val);
- break;
- case 2:
- snprintf(buf, bufsz, "%u", *(uint16_t *)val);
- break;
- case 3:
- case 4:
- snprintf(buf, bufsz, "%u", *(uint32_t *)val);
- break;
- case 5:
- case 6:
- case 7:
- case 8:
- snprintf(buf, bufsz, "%" PRIu64, *(uint64_t *)val);
- break;
- default:
- IBWARN("bad int sz %u", valsz);
- buf[0] = 0;
- }
-}
-
-void
-mad_dump_hex(char *buf, int bufsz, void *val, int valsz)
-{
- switch (valsz) {
- case 1:
- snprintf(buf, bufsz, "0x%02x", *(uint8_t *)val);
- break;
- case 2:
- snprintf(buf, bufsz, "0x%04x", *(uint16_t *)val);
- break;
- case 3:
- snprintf(buf, bufsz, "0x%06x", *(uint32_t *)val & 0xffffff);
- break;
- case 4:
- snprintf(buf, bufsz, "0x%08x", *(uint32_t *)val);
- break;
- case 5:
- snprintf(buf, bufsz, "0x%010" PRIx64, *(uint64_t *)val & (uint64_t) 0xffffffffffllu);
- break;
- case 6:
- snprintf(buf, bufsz, "0x%012" PRIx64, *(uint64_t *)val & (uint64_t) 0xffffffffffffllu);
- break;
- case 7:
- snprintf(buf, bufsz, "0x%014" PRIx64, *(uint64_t *)val & (uint64_t) 0xffffffffffffffllu);
- break;
- case 8:
- snprintf(buf, bufsz, "0x%016" PRIx64, *(uint64_t *)val);
- break;
- default:
- IBWARN("bad int sz %d", valsz);
- buf[0] = 0;
- }
-}
-
-void
-mad_dump_rhex(char *buf, int bufsz, void *val, int valsz)
-{
- switch (valsz) {
- case 1:
- snprintf(buf, bufsz, "%02x", *(uint8_t *)val);
- break;
- case 2:
- snprintf(buf, bufsz, "%04x", *(uint16_t *)val);
- break;
- case 3:
- snprintf(buf, bufsz, "%06x", *(uint32_t *)val & 0xffffff);
- break;
- case 4:
- snprintf(buf, bufsz, "%08x", *(uint32_t *)val);
- break;
- case 5:
- snprintf(buf, bufsz, "%010" PRIx64, *(uint64_t *)val & (uint64_t) 0xffffffffffllu);
- break;
- case 6:
- snprintf(buf, bufsz, "%012" PRIx64, *(uint64_t *)val & (uint64_t) 0xffffffffffffllu);
- break;
- case 7:
- snprintf(buf, bufsz, "%014" PRIx64, *(uint64_t *)val & (uint64_t) 0xffffffffffffffllu);
- break;
- case 8:
- snprintf(buf, bufsz, "%016" PRIx64, *(uint64_t *)val);
- break;
- default:
- IBWARN("bad int sz %d", valsz);
- buf[0] = 0;
- }
-}
-
-void
-mad_dump_linkwidth(char *buf, int bufsz, void *val, int valsz)
-{
- int width = *(int *)val;
-
- switch (width) {
- case 1:
- snprintf(buf, bufsz, "1X");
- break;
- case 2:
- snprintf(buf, bufsz, "4X");
- break;
- case 4:
- snprintf(buf, bufsz, "8X");
- break;
- case 8:
- snprintf(buf, bufsz, "12X");
- break;
- default:
- IBWARN("bad width %d", width);
- buf[0] = 0;
- }
-}
-
-static void
-dump_linkwidth(char *buf, int bufsz, int width)
-{
- int n = 0;
-
- if (width & 0x1)
- n += snprintf(buf + n, bufsz - n, "1X or ");
- if (n < bufsz && (width & 0x2))
- n += snprintf(buf + n, bufsz - n, "4X or ");
- if (n < bufsz && (width & 0x4))
- n += snprintf(buf + n, bufsz - n, "8X or ");
- if (n < bufsz && (width & 0x8))
- n += snprintf(buf + n, bufsz - n, "12X or ");
-
- if (n >= bufsz)
- return;
- else if (width == 0 || (width >> 4))
- snprintf(buf + n, bufsz - n, "undefined (%d)", width);
- else if (bufsz > 3)
- buf[n-4] = '\0';
-}
-
-void
-mad_dump_linkwidthsup(char *buf, int bufsz, void *val, int valsz)
-{
- int width = *(int *)val;
-
- dump_linkwidth(buf, bufsz, width);
-
- switch(width) {
- case 1:
- case 3:
- case 7:
- case 11:
- case 15:
- break;
-
- default:
- if (!(width >> 4))
- snprintf(buf + strlen(buf), bufsz - strlen(buf),
- " (IBA extension)");
- break;
- }
-}
-
-void
-mad_dump_linkwidthen(char *buf, int bufsz, void *val, int valsz)
-{
- int width = *(int *)val;
-
- dump_linkwidth(buf, bufsz, width);
-}
-
-void
-mad_dump_linkspeed(char *buf, int bufsz, void *val, int valsz)
-{
- int speed = *(int *)val;
-
- switch (speed) {
- case 1:
- snprintf(buf, bufsz, "2.5 Gbps");
- break;
- case 2:
- snprintf(buf, bufsz, "5.0 Gbps");
- break;
- case 4:
- snprintf(buf, bufsz, "10.0 Gbps");
- break;
- default:
- snprintf(buf, bufsz, "undefined (%d)", speed);
- break;
- }
-}
-
-static void
-dump_linkspeed(char *buf, int bufsz, int speed)
-{
- int n = 0;
-
- if (speed & 0x1)
- n += snprintf(buf + n, bufsz - n, "2.5 Gbps or ");
- if (n < bufsz && (speed & 0x2))
- n += snprintf(buf + n, bufsz - n, "5.0 Gbps or ");
- if (n < bufsz && (speed & 0x4))
- n += snprintf(buf + n, bufsz - n, "10.0 Gbps or ");
-
- if (n >= bufsz)
- return;
- else if (speed == 0 || (speed >> 3)) {
- n += snprintf(buf + n, bufsz - n, "undefined (%d)", speed);
- if (n >= bufsz)
- return;
- } else if (bufsz > 3) {
- buf[n-4] = '\0';
- n -= 4;
- }
-
- switch (speed) {
- case 1:
- case 3:
- case 5:
- case 7:
- break;
- default:
- if (!(speed >> 3))
- snprintf(buf + n, bufsz - n, " (IBA extension)");
- break;
- }
-}
-
-void
-mad_dump_linkspeedsup(char *buf, int bufsz, void *val, int valsz)
-{
- int speed = *(int *)val;
-
- dump_linkspeed(buf, bufsz, speed);
-}
-
-void
-mad_dump_linkspeeden(char *buf, int bufsz, void *val, int valsz)
-{
- int speed = *(int *)val;
-
- dump_linkspeed(buf, bufsz, speed);
-}
-
-void
-mad_dump_portstate(char *buf, int bufsz, void *val, int valsz)
-{
- int state = *(int *)val;
-
- switch (state) {
- case 0:
- snprintf(buf, bufsz, "NoChange");
- break;
- case 1:
- snprintf(buf, bufsz, "Down");
- break;
- case 2:
- snprintf(buf, bufsz, "Initialize");
- break;
- case 3:
- snprintf(buf, bufsz, "Armed");
- break;
- case 4:
- snprintf(buf, bufsz, "Active");
- break;
- default:
- snprintf(buf, bufsz, "?(%d)", state);
- }
-}
-
-void
-mad_dump_linkdowndefstate(char *buf, int bufsz, void *val, int valsz)
-{
- int state = *(int *)val;
-
- switch(state) {
- case 0:
- snprintf(buf, bufsz, "NoChange");
- break;
- case 1:
- snprintf(buf, bufsz, "Sleep");
- break;
- case 2:
- snprintf(buf, bufsz, "Polling");
- break;
- default:
- snprintf(buf, bufsz, "?(%d)", state);
- break;
- }
-}
-
-void
-mad_dump_physportstate(char *buf, int bufsz, void *val, int valsz)
-{
- int state = *(int *)val;
-
- switch (state) {
- case 0:
- snprintf(buf, bufsz, "NoChange");
- break;
- case 1:
- snprintf(buf, bufsz, "Sleep");
- break;
- case 2:
- snprintf(buf, bufsz, "Polling");
- break;
- case 3:
- snprintf(buf, bufsz, "Disabled");
- break;
- case 4:
- snprintf(buf, bufsz, "PortConfigurationTraining");
- break;
- case 5:
- snprintf(buf, bufsz, "LinkUp");
- break;
- case 6:
- snprintf(buf, bufsz, "LinkErrorRecovery");
- break;
- case 7:
- snprintf(buf, bufsz, "PhyTest");
- break;
- default:
- snprintf(buf, bufsz, "?(%d)", state);
- }
-}
-
-void
-mad_dump_mtu(char *buf, int bufsz, void *val, int valsz)
-{
- int mtu = *(int *)val;
-
- switch (mtu) {
- case 1:
- snprintf(buf, bufsz, "256");
- break;
- case 2:
- snprintf(buf, bufsz, "512");
- break;
- case 3:
- snprintf(buf, bufsz, "1024");
- break;
- case 4:
- snprintf(buf, bufsz, "2048");
- break;
- case 5:
- snprintf(buf, bufsz, "4096");
- break;
- default:
- snprintf(buf, bufsz, "?(%d)", mtu);
- buf[0] = 0;
- }
-}
-
-void
-mad_dump_vlcap(char *buf, int bufsz, void *val, int valsz)
-{
- int vlcap = *(int *)val;
-
- switch (vlcap) {
- case 1:
- snprintf(buf, bufsz, "VL0");
- break;
- case 2:
- snprintf(buf, bufsz, "VL0-1");
- break;
- case 3:
- snprintf(buf, bufsz, "VL0-3");
- break;
- case 4:
- snprintf(buf, bufsz, "VL0-7");
- break;
- case 5:
- snprintf(buf, bufsz, "VL0-14");
- break;
- default:
- snprintf(buf, bufsz, "?(%d)", vlcap);
- }
-}
-
-void
-mad_dump_opervls(char *buf, int bufsz, void *val, int valsz)
-{
- int opervls = *(int *)val;
-
- switch (opervls) {
- case 0:
- snprintf(buf, bufsz, "No change");
- break;
- case 1:
- snprintf(buf, bufsz, "VL0");
- break;
- case 2:
- snprintf(buf, bufsz, "VL0-1");
- break;
- case 3:
- snprintf(buf, bufsz, "VL0-3");
- break;
- case 4:
- snprintf(buf, bufsz, "VL0-7");
- break;
- case 5:
- snprintf(buf, bufsz, "VL0-14");
- break;
- default:
- snprintf(buf, bufsz, "?(%d)", opervls);
- }
-}
-
-void
-mad_dump_portcapmask(char *buf, int bufsz, void *val, int valsz)
-{
- unsigned mask = *(unsigned *)val;
- char *s = buf;
-
- s += sprintf(s, "0x%x\n", mask);
- if (mask & (1 << 1))
- s += sprintf(s, "\t\t\t\tIsSM\n");
- if (mask & (1 << 2))
- s += sprintf(s, "\t\t\t\tIsNoticeSupported\n");
- if (mask & (1 << 3))
- s += sprintf(s, "\t\t\t\tIsTrapSupported\n");
- if (mask & (1 << 5))
- s += sprintf(s, "\t\t\t\tIsAutomaticMigrationSupported\n");
- if (mask & (1 << 6))
- s += sprintf(s, "\t\t\t\tIsSLMappingSupported\n");
- if (mask & (1 << 7))
- s += sprintf(s, "\t\t\t\tIsMKeyNVRAM\n");
- if (mask & (1 << 8))
- s += sprintf(s, "\t\t\t\tIsPKeyNVRAM\n");
- if (mask & (1 << 9))
- s += sprintf(s, "\t\t\t\tIsLedInfoSupported\n");
- if (mask & (1 << 10))
- s += sprintf(s, "\t\t\t\tIsSMdisabled\n");
- if (mask & (1 << 11))
- s += sprintf(s, "\t\t\t\tIsSystemImageGUIDsupported\n");
- if (mask & (1 << 12))
- s += sprintf(s, "\t\t\t\tIsPkeySwitchExternalPortTrapSupported\n");
- if (mask & (1 << 16))
- s += sprintf(s, "\t\t\t\tIsCommunicatonManagementSupported\n");
- if (mask & (1 << 17))
- s += sprintf(s, "\t\t\t\tIsSNMPTunnelingSupported\n");
- if (mask & (1 << 18))
- s += sprintf(s, "\t\t\t\tIsReinitSupported\n");
- if (mask & (1 << 19))
- s += sprintf(s, "\t\t\t\tIsDeviceManagementSupported\n");
- if (mask & (1 << 20))
- s += sprintf(s, "\t\t\t\tIsVendorClassSupported\n");
- if (mask & (1 << 21))
- s += sprintf(s, "\t\t\t\tIsDRNoticeSupported\n");
- if (mask & (1 << 22))
- s += sprintf(s, "\t\t\t\tIsCapabilityMaskNoticeSupported\n");
- if (mask & (1 << 23))
- s += sprintf(s, "\t\t\t\tIsBootManagementSupported\n");
- if (mask & (1 << 24))
- s += sprintf(s, "\t\t\t\tIsLinkRoundTripLatencySupported\n");
- if (mask & (1 << 25))
- s += sprintf(s, "\t\t\t\tIsClientRegistrationSupported\n");
- if (mask & (1 << 26))
- s += sprintf(s, "\t\t\t\tIsOtherLocalChangesNoticeSupported\n");
- if (mask & (1 << 27))
- s += sprintf(s, "\t\t\t\tIsLinkSpeedWidthPairsTableSupported\n");
-
- if (s != buf)
- *(--s) = 0;
-}
-
-void
-mad_dump_bitfield(char *buf, int bufsz, void *val, int valsz)
-{
- snprintf(buf, bufsz, "0x%x", *(uint32_t *)val);
-}
-
-void
-mad_dump_array(char *buf, int bufsz, void *val, int valsz)
-{
- uint8_t *p = val, *e;
- char *s = buf;
-
- if (bufsz < valsz*2)
- valsz = bufsz/2;
-
- for (p = val, e = p + valsz; p < e; p++, s += 2)
- sprintf(s, "%02x", *p);
-}
-
-void
-mad_dump_string(char *buf, int bufsz, void *val, int valsz)
-{
- if (bufsz < valsz)
- valsz = bufsz;
-
- snprintf(buf, valsz, "'%s'", (char *)val);
-}
-
-void
-mad_dump_node_type(char *buf, int bufsz, void *val, int valsz)
-{
- int nodetype = *(int*)val;
-
- switch (nodetype) {
- case 1:
- snprintf(buf, bufsz, "Channel Adapter");
- break;
- case 2:
- snprintf(buf, bufsz, "Switch");
- break;
- case 3:
- snprintf(buf, bufsz, "Router");
- break;
- default:
- snprintf(buf, bufsz, "?(%d)?", nodetype);
- break;
- }
-}
-
-#define IB_MAX_NUM_VLS 16
-#define IB_MAX_NUM_VLS_TO_U8 ((IB_MAX_NUM_VLS)/2)
-
-typedef struct _ib_slvl_table {
- uint8_t vl_by_sl_num[IB_MAX_NUM_VLS_TO_U8];
-} ib_slvl_table_t;
-
-static inline void
-ib_slvl_get_i(ib_slvl_table_t *tbl, int i, uint8_t *vl)
-{
- *vl = (tbl->vl_by_sl_num[i >> 1] >> ((!(i&1)) << 2)) & 0xf;
-}
-
-#define IB_NUM_VL_ARB_ELEMENTS_IN_BLOCK 32
-
-typedef struct _ib_vl_arb_table {
- struct {
- uint8_t res_vl;
- uint8_t weight;
- } vl_entry[IB_NUM_VL_ARB_ELEMENTS_IN_BLOCK];
-} __attribute__((packed)) ib_vl_arb_table_t;
-
-static inline void
-ib_vl_arb_get_vl(uint8_t res_vl, uint8_t *const vl )
-{
- *vl = res_vl & 0x0F;
-}
-
-void
-mad_dump_sltovl(char *buf, int bufsz, void *val, int valsz)
-{
- ib_slvl_table_t* p_slvl_tbl = val;
- uint8_t vl;
- int i, n = 0;
- n = snprintf(buf, bufsz, "|");
- for (i = 0; i < 16; i++) {
- ib_slvl_get_i(p_slvl_tbl, i, &vl);
- n += snprintf(buf + n, bufsz - n, "%2u|", vl);
- if (n >= bufsz)
- break;
- }
- snprintf(buf + n, bufsz - n, "\n");
-}
-
-void
-mad_dump_vlarbitration(char *buf, int bufsz, void *val, int num)
-{
- ib_vl_arb_table_t* p_vla_tbl = val;
- unsigned i, n;
- uint8_t vl;
-
- num /= sizeof(p_vla_tbl->vl_entry[0]);
-
- n = snprintf(buf, bufsz, "\nVL : |");
- if (n >= bufsz)
- return;
- for (i = 0; i < num; i++) {
- ib_vl_arb_get_vl(p_vla_tbl->vl_entry[i].res_vl, &vl);
- n += snprintf(buf + n, bufsz - n, "0x%-2X|", vl);
- if (n >= bufsz)
- return;
- }
-
- n += snprintf(buf + n, bufsz - n, "\nWEIGHT: |");
- if (n >= bufsz)
- return;
- for (i = 0; i < num; i++) {
- n += snprintf(buf + n, bufsz - n, "0x%-2X|",
- p_vla_tbl->vl_entry[i].weight);
- if (n >= bufsz)
- return;
- }
-
- snprintf(buf + n, bufsz - n, "\n");
-}
-
-static int
-_dump_fields(char *buf, int bufsz, void *data, int start, int end)
-{
- char val[64];
- char *s = buf;
- int n, field;
-
- for (field = start; field < end && bufsz > 0; field++) {
- mad_decode_field(data, field, val);
- if (!mad_dump_field(field, s, bufsz, val))
- return -1;
- n = strlen(s);
- s += n;
- *s++ = '\n';
- *s = 0;
- n++;
- bufsz -= n;
- }
-
- return s - buf;
-}
-
-void
-mad_dump_nodedesc(char *buf, int bufsz, void *val, int valsz)
-{
- strncpy(buf, val, bufsz);
-
- if (valsz < bufsz)
- buf[valsz] = 0;
-}
-
-void
-mad_dump_nodeinfo(char *buf, int bufsz, void *val, int valsz)
-{
- _dump_fields(buf, bufsz, val, IB_NODE_FIRST_F, IB_NODE_LAST_F);
-}
-
-void
-mad_dump_portinfo(char *buf, int bufsz, void *val, int valsz)
-{
- _dump_fields(buf, bufsz, val, IB_PORT_FIRST_F, IB_PORT_LAST_F);
-}
-
-void
-mad_dump_portstates(char *buf, int bufsz, void *val, int valsz)
-{
- _dump_fields(buf, bufsz, val, IB_PORT_STATE_F, IB_PORT_LINK_DOWN_DEF_F);
-}
-
-void
-mad_dump_switchinfo(char *buf, int bufsz, void *val, int valsz)
-{
- _dump_fields(buf, bufsz, val, IB_SW_FIRST_F, IB_SW_LAST_F);
-}
-
-void
-mad_dump_perfcounters(char *buf, int bufsz, void *val, int valsz)
-{
- _dump_fields(buf, bufsz, val, IB_PC_FIRST_F, IB_PC_LAST_F);
-}
-
-void
-mad_dump_perfcounters_ext(char *buf, int bufsz, void *val, int valsz)
-{
- _dump_fields(buf, bufsz, val, IB_PC_EXT_FIRST_F, IB_PC_EXT_LAST_F);
-}
-
-/************************/
-
-char *
-_mad_dump_val(ib_field_t *f, char *buf, int bufsz, void *val)
-{
- f->def_dump_fn(buf, bufsz, val, ALIGN(f->bitlen, 8) / 8);
- buf[bufsz - 1] = 0;
-
- return buf;
-}
-
-char *
-_mad_dump_field(ib_field_t *f, char *name, char *buf, int bufsz, void *val)
-{
- char dots[128];
- int l, n;
-
- if (bufsz <= 32)
- return 0; /* buf too small */
-
- if (!name)
- name = f->name;
-
- l = strlen(name);
- if (l < 32) {
- memset(dots, '.', 32 - l);
- dots[32 - l] = 0;
- }
-
- n = snprintf(buf, bufsz, "%s:%s", name, dots);
- _mad_dump_val(f, buf + n, bufsz - n, val);
- buf[bufsz - 1] = 0;
-
- return buf;
-}
-
-int
-_mad_dump(ib_mad_dump_fn *fn, char *name, void *val, int valsz)
-{
- ib_field_t f = { .def_dump_fn = fn, .bitlen = valsz * 8};
- char buf[512];
-
- return printf("%s\n", _mad_dump_field(&f, name, buf, sizeof buf, val));
-}
-
-int
-_mad_print_field(ib_field_t *f, char *name, void *val, int valsz)
-{
- return _mad_dump(f->def_dump_fn, name ? name : f->name, val, valsz ? valsz : ALIGN(f->bitlen, 8) / 8);
-}
diff --git a/contrib/ofed/management/libibmad/src/fields.c b/contrib/ofed/management/libibmad/src/fields.c
deleted file mode 100644
index 6942e85..0000000
--- a/contrib/ofed/management/libibmad/src/fields.c
+++ /dev/null
@@ -1,463 +0,0 @@
-/*
- * Copyright (c) 2004-2007 Voltaire Inc. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- */
-
-#if HAVE_CONFIG_H
-# include <config.h>
-#endif /* HAVE_CONFIG_H */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <string.h>
-
-#include <mad.h>
-#include <infiniband/common.h>
-
-/*
- * BITSOFFS and BE_OFFS are required due the fact that the bit offsets are inconsistently
- * encoded in the IB spec - IB headers are encoded such that the bit offsets
- * are in big endian convention (BE_OFFS), while the SMI/GSI queries data fields bit
- * offsets are specified using real bit offset (?!)
- * The following macros normalize everything to big endian offsets.
- */
-#define BITSOFFS(o, w) (((o) & ~31) | ((32 - ((o) & 31) - (w)))), (w)
-#define BE_OFFS(o, w) (o), (w)
-#define BE_TO_BITSOFFS(o, w) (((o) & ~31) | ((32 - ((o) & 31) - (w))))
-
-ib_field_t ib_mad_f [] = {
- [0] {0, 0}, /* IB_NO_FIELD - reserved as invalid */
-
- [IB_GID_PREFIX_F] {0, 64, "GidPrefix", mad_dump_rhex},
- [IB_GID_GUID_F] {64, 64, "GidGuid", mad_dump_rhex},
-
- /*
- * MAD: common MAD fields (IB spec 13.4.2)
- * SMP: Subnet Management packets - lid routed (IB spec 14.2.1.1)
- * DSMP: Subnet Management packets - direct route (IB spec 14.2.1.2)
- * SA: Subnet Administration packets (IB spec 15.2.1.1)
- */
-
- /* first MAD word (0-3 bytes) */
- [IB_MAD_METHOD_F] {BE_OFFS(0, 7), "MadMethod", mad_dump_hex}, /* TODO: add dumper */
- [IB_MAD_RESPONSE_F] {BE_OFFS(7, 1), "MadIsResponse", mad_dump_uint}, /* TODO: add dumper */
- [IB_MAD_CLASSVER_F] {BE_OFFS(8, 8), "MadClassVersion", mad_dump_uint},
- [IB_MAD_MGMTCLASS_F] {BE_OFFS(16, 8), "MadMgmtClass", mad_dump_uint}, /* TODO: add dumper */
- [IB_MAD_BASEVER_F] {BE_OFFS(24, 8), "MadBaseVersion", mad_dump_uint},
-
- /* second MAD word (4-7 bytes) */
- [IB_MAD_STATUS_F] {BE_OFFS(48, 16), "MadStatus", mad_dump_hex}, /* TODO: add dumper */
-
- /* DR SMP only */
- [IB_DRSMP_HOPCNT_F] {BE_OFFS(32, 8), "DrSmpHopCnt", mad_dump_uint},
- [IB_DRSMP_HOPPTR_F] {BE_OFFS(40, 8), "DrSmpHopPtr", mad_dump_uint},
- [IB_DRSMP_STATUS_F] {BE_OFFS(48, 15), "DrSmpStatus", mad_dump_hex}, /* TODO: add dumper */
- [IB_DRSMP_DIRECTION_F] {BE_OFFS(63, 1), "DrSmpDirection", mad_dump_uint}, /* TODO: add dumper */
-
- /* words 3,4,5,6 (8-23 bytes) */
- [IB_MAD_TRID_F] {64, 64, "MadTRID", mad_dump_hex},
- [IB_MAD_ATTRID_F] {BE_OFFS(144, 16), "MadAttr", mad_dump_hex}, /* TODO: add dumper */
- [IB_MAD_ATTRMOD_F] {160, 32, "MadModifier", mad_dump_hex}, /* TODO: add dumper */
-
- /* word 7,8 (24-31 bytes) */
- [IB_MAD_MKEY_F] {196, 64, "MadMkey", mad_dump_hex},
-
- /* word 9 (32-37 bytes) */
- [IB_DRSMP_DRDLID_F] {BE_OFFS(256, 16), "DrSmpDLID", mad_dump_hex},
- [IB_DRSMP_DRSLID_F] {BE_OFFS(272, 16), "DrSmpSLID", mad_dump_hex},
-
- /* word 12 (44-47 bytes) */
- [IB_SA_ATTROFFS_F] {BE_OFFS(46*8, 16), "SaAttrOffs", mad_dump_uint},
-
- /* word 13,14 (48-55 bytes) */
- [IB_SA_COMPMASK_F] {48*8, 64, "SaCompMask", mad_dump_hex},
-
- /* word 13,14 (56-255 bytes) */
- [IB_SA_DATA_F] {56*8, (256-56)*8, "SaData", mad_dump_hex},
-
- [IB_DRSMP_PATH_F] {1024, 512, "DrSmpPath", mad_dump_hex},
- [IB_DRSMP_RPATH_F] {1536, 512, "DrSmpRetPath", mad_dump_hex},
-
- [IB_GS_DATA_F] {64*8, (256-64) * 8, "GsData", mad_dump_hex},
-
- /*
- * PortInfo fields:
- */
- [IB_PORT_MKEY_F] {0, 64, "Mkey", mad_dump_hex},
- [IB_PORT_GID_PREFIX_F] {64, 64, "GidPrefix", mad_dump_hex},
- [IB_PORT_LID_F] {BITSOFFS(128, 16), "Lid", mad_dump_hex},
- [IB_PORT_SMLID_F] {BITSOFFS(144, 16), "SMLid", mad_dump_hex},
- [IB_PORT_CAPMASK_F] {160, 32, "CapMask", mad_dump_portcapmask},
- [IB_PORT_DIAG_F] {BITSOFFS(192, 16), "DiagCode", mad_dump_hex},
- [IB_PORT_MKEY_LEASE_F] {BITSOFFS(208, 16), "MkeyLeasePeriod", mad_dump_uint},
- [IB_PORT_LOCAL_PORT_F] {BITSOFFS(224, 8), "LocalPort", mad_dump_uint},
- [IB_PORT_LINK_WIDTH_ENABLED_F] {BITSOFFS(232, 8), "LinkWidthEnabled", mad_dump_linkwidthen},
- [IB_PORT_LINK_WIDTH_SUPPORTED_F] {BITSOFFS(240, 8), "LinkWidthSupported", mad_dump_linkwidthsup},
- [IB_PORT_LINK_WIDTH_ACTIVE_F] {BITSOFFS(248, 8), "LinkWidthActive", mad_dump_linkwidth},
- [IB_PORT_LINK_SPEED_SUPPORTED_F] {BITSOFFS(256, 4), "LinkSpeedSupported", mad_dump_linkspeedsup},
- [IB_PORT_STATE_F] {BITSOFFS(260, 4), "LinkState", mad_dump_portstate},
- [IB_PORT_PHYS_STATE_F] {BITSOFFS(264, 4), "PhysLinkState", mad_dump_physportstate},
- [IB_PORT_LINK_DOWN_DEF_F] {BITSOFFS(268, 4), "LinkDownDefState", mad_dump_linkdowndefstate},
- [IB_PORT_MKEY_PROT_BITS_F] {BITSOFFS(272, 2), "ProtectBits", mad_dump_uint},
- [IB_PORT_LMC_F] {BITSOFFS(277, 3), "LMC", mad_dump_uint},
- [IB_PORT_LINK_SPEED_ACTIVE_F] {BITSOFFS(280, 4), "LinkSpeedActive", mad_dump_linkspeed},
- [IB_PORT_LINK_SPEED_ENABLED_F] {BITSOFFS(284, 4), "LinkSpeedEnabled", mad_dump_linkspeeden},
- [IB_PORT_NEIGHBOR_MTU_F] {BITSOFFS(288, 4), "NeighborMTU", mad_dump_mtu},
- [IB_PORT_SMSL_F] {BITSOFFS(292, 4), "SMSL", mad_dump_uint},
- [IB_PORT_VL_CAP_F] {BITSOFFS(296, 4), "VLCap", mad_dump_vlcap},
- [IB_PORT_INIT_TYPE_F] {BITSOFFS(300, 4), "InitType", mad_dump_hex},
- [IB_PORT_VL_HIGH_LIMIT_F] {BITSOFFS(304, 8), "VLHighLimit", mad_dump_uint},
- [IB_PORT_VL_ARBITRATION_HIGH_CAP_F] {BITSOFFS(312, 8), "VLArbHighCap", mad_dump_uint},
- [IB_PORT_VL_ARBITRATION_LOW_CAP_F] {BITSOFFS(320, 8), "VLArbLowCap", mad_dump_uint},
-
- [IB_PORT_INIT_TYPE_REPLY_F] {BITSOFFS(328, 4), "InitReply", mad_dump_hex},
- [IB_PORT_MTU_CAP_F] {BITSOFFS(332, 4), "MtuCap", mad_dump_mtu},
- [IB_PORT_VL_STALL_COUNT_F] {BITSOFFS(336, 3), "VLStallCount", mad_dump_uint},
- [IB_PORT_HOQ_LIFE_F] {BITSOFFS(339, 5), "HoqLife", mad_dump_uint},
- [IB_PORT_OPER_VLS_F] {BITSOFFS(344, 4), "OperVLs", mad_dump_opervls},
- [IB_PORT_PART_EN_INB_F] {BITSOFFS(348, 1), "PartEnforceInb", mad_dump_uint},
- [IB_PORT_PART_EN_OUTB_F] {BITSOFFS(349, 1), "PartEnforceOutb", mad_dump_uint},
- [IB_PORT_FILTER_RAW_INB_F] {BITSOFFS(350, 1), "FilterRawInb", mad_dump_uint},
- [IB_PORT_FILTER_RAW_OUTB_F] {BITSOFFS(351, 1), "FilterRawOutb", mad_dump_uint},
- [IB_PORT_MKEY_VIOL_F] {BITSOFFS(352, 16), "MkeyViolations", mad_dump_uint},
- [IB_PORT_PKEY_VIOL_F] {BITSOFFS(368, 16), "PkeyViolations", mad_dump_uint},
- [IB_PORT_QKEY_VIOL_F] {BITSOFFS(384, 16), "QkeyViolations", mad_dump_uint},
- [IB_PORT_GUID_CAP_F] {BITSOFFS(400, 8), "GuidCap", mad_dump_uint},
- [IB_PORT_CLIENT_REREG_F] {BITSOFFS(408, 1), "ClientReregister", mad_dump_uint},
- [IB_PORT_SUBN_TIMEOUT_F] {BITSOFFS(411, 5), "SubnetTimeout", mad_dump_uint},
- [IB_PORT_RESP_TIME_VAL_F] {BITSOFFS(419, 5), "RespTimeVal", mad_dump_uint},
- [IB_PORT_LOCAL_PHYS_ERR_F] {BITSOFFS(424, 4), "LocalPhysErr", mad_dump_uint},
- [IB_PORT_OVERRUN_ERR_F] {BITSOFFS(428, 4), "OverrunErr", mad_dump_uint},
- [IB_PORT_MAX_CREDIT_HINT_F] {BITSOFFS(432, 16), "MaxCreditHint", mad_dump_uint},
- [IB_PORT_LINK_ROUND_TRIP_F] {BITSOFFS(456, 24), "RoundTrip", mad_dump_uint},
-
- /*
- * NodeInfo fields:
- */
- [IB_NODE_BASE_VERS_F] {BITSOFFS(0,8), "BaseVers", mad_dump_uint},
- [IB_NODE_CLASS_VERS_F] {BITSOFFS(8,8), "ClassVers", mad_dump_uint},
- [IB_NODE_TYPE_F] {BITSOFFS(16,8), "NodeType", mad_dump_node_type},
- [IB_NODE_NPORTS_F] {BITSOFFS(24,8), "NumPorts", mad_dump_uint},
- [IB_NODE_SYSTEM_GUID_F] {32, 64, "SystemGuid", mad_dump_hex},
- [IB_NODE_GUID_F] {96, 64, "Guid", mad_dump_hex},
- [IB_NODE_PORT_GUID_F] {160, 64, "PortGuid", mad_dump_hex},
- [IB_NODE_PARTITION_CAP_F] {BITSOFFS(224,16), "PartCap", mad_dump_uint},
- [IB_NODE_DEVID_F] {BITSOFFS(240,16), "DevId", mad_dump_hex},
- [IB_NODE_REVISION_F] {256, 32, "Revision", mad_dump_hex},
- [IB_NODE_LOCAL_PORT_F] {BITSOFFS(288,8), "LocalPort", mad_dump_uint},
- [IB_NODE_VENDORID_F] {BITSOFFS(296,24), "VendorId", mad_dump_hex},
-
- /*
- * SwitchInfo fields:
- */
- [IB_SW_LINEAR_FDB_CAP_F] {BITSOFFS(0, 16), "LinearFdbCap", mad_dump_uint},
- [IB_SW_RANDOM_FDB_CAP_F] {BITSOFFS(16, 16), "RandomFdbCap", mad_dump_uint},
- [IB_SW_MCAST_FDB_CAP_F] {BITSOFFS(32, 16), "McastFdbCap", mad_dump_uint},
- [IB_SW_LINEAR_FDB_TOP_F] {BITSOFFS(48, 16), "LinearFdbTop", mad_dump_uint},
- [IB_SW_DEF_PORT_F] {BITSOFFS(64, 8), "DefPort", mad_dump_uint},
- [IB_SW_DEF_MCAST_PRIM_F] {BITSOFFS(72, 8), "DefMcastPrimPort", mad_dump_uint},
- [IB_SW_DEF_MCAST_NOT_PRIM_F] {BITSOFFS(80, 8), "DefMcastNotPrimPort", mad_dump_uint},
- [IB_SW_LIFE_TIME_F] {BITSOFFS(88, 5), "LifeTime", mad_dump_uint},
- [IB_SW_STATE_CHANGE_F] {BITSOFFS(93, 1), "StateChange", mad_dump_uint},
- [IB_SW_LIDS_PER_PORT_F] {BITSOFFS(96,16), "LidsPerPort", mad_dump_uint},
- [IB_SW_PARTITION_ENFORCE_CAP_F] {BITSOFFS(112, 16), "PartEnforceCap", mad_dump_uint},
- [IB_SW_PARTITION_ENF_INB_F] {BITSOFFS(128, 1), "InboundPartEnf", mad_dump_uint},
- [IB_SW_PARTITION_ENF_OUTB_F] {BITSOFFS(129, 1), "OutboundPartEnf", mad_dump_uint},
- [IB_SW_FILTER_RAW_INB_F] {BITSOFFS(130, 1), "FilterRawInbound", mad_dump_uint},
- [IB_SW_FILTER_RAW_OUTB_F] {BITSOFFS(131, 1), "FilterRawOutbound", mad_dump_uint},
- [IB_SW_ENHANCED_PORT0_F] {BITSOFFS(132, 1), "EnhancedPort0", mad_dump_uint},
-
- /*
- * SwitchLinearForwardingTable fields:
- */
- [IB_LINEAR_FORW_TBL_F] {0, 512, "LinearForwTbl", mad_dump_array},
-
- /*
- * SwitchMulticastForwardingTable fields:
- */
- [IB_MULTICAST_FORW_TBL_F] {0, 512, "MulticastForwTbl", mad_dump_array},
-
- /*
- * Notice/Trap fields
- */
- [IB_NOTICE_IS_GENERIC_F] {BITSOFFS(0, 1), "NoticeIsGeneric", mad_dump_uint},
- [IB_NOTICE_TYPE_F] {BITSOFFS(1, 7), "NoticeType", mad_dump_uint},
- [IB_NOTICE_PRODUCER_F] {BITSOFFS(8, 24), "NoticeProducerType", mad_dump_node_type},
- [IB_NOTICE_TRAP_NUMBER_F] {BITSOFFS(32, 16), "NoticeTrapNumber", mad_dump_uint},
- [IB_NOTICE_ISSUER_LID_F] {BITSOFFS(48, 16), "NoticeIssuerLID", mad_dump_uint},
- [IB_NOTICE_TOGGLE_F] {BITSOFFS(64, 1), "NoticeToggle", mad_dump_uint},
- [IB_NOTICE_COUNT_F] {BITSOFFS(65, 15), "NoticeCount", mad_dump_uint},
- [IB_NOTICE_DATA_DETAILS_F] {80, 432, "NoticeDataDetails", mad_dump_array},
- [IB_NOTICE_DATA_LID_F] {BITSOFFS(80, 16), "NoticeDataLID", mad_dump_uint},
- [IB_NOTICE_DATA_144_LID_F] {BITSOFFS(96, 16), "NoticeDataTrap144LID", mad_dump_uint},
- [IB_NOTICE_DATA_144_CAPMASK_F] {BITSOFFS(128, 32), "NoticeDataTrap144CapMask", mad_dump_uint},
-
- /*
- * NodeDescription fields:
- */
- [IB_NODE_DESC_F] {0, 64*8, "NodeDesc", mad_dump_string},
-
- /*
- * Port counters
- */
- [IB_PC_PORT_SELECT_F] {BITSOFFS(8, 8), "PortSelect", mad_dump_uint},
- [IB_PC_COUNTER_SELECT_F] {BITSOFFS(16, 16), "CounterSelect", mad_dump_hex},
- [IB_PC_ERR_SYM_F] {BITSOFFS(32, 16), "SymbolErrors", mad_dump_uint},
- [IB_PC_LINK_RECOVERS_F] {BITSOFFS(48, 8), "LinkRecovers", mad_dump_uint},
- [IB_PC_LINK_DOWNED_F] {BITSOFFS(56, 8), "LinkDowned", mad_dump_uint},
- [IB_PC_ERR_RCV_F] {BITSOFFS(64, 16), "RcvErrors", mad_dump_uint},
- [IB_PC_ERR_PHYSRCV_F] {BITSOFFS(80, 16), "RcvRemotePhysErrors", mad_dump_uint},
- [IB_PC_ERR_SWITCH_REL_F] {BITSOFFS(96, 16), "RcvSwRelayErrors", mad_dump_uint},
- [IB_PC_XMT_DISCARDS_F] {BITSOFFS(112, 16), "XmtDiscards", mad_dump_uint},
- [IB_PC_ERR_XMTCONSTR_F] {BITSOFFS(128, 8), "XmtConstraintErrors", mad_dump_uint},
- [IB_PC_ERR_RCVCONSTR_F] {BITSOFFS(136, 8), "RcvConstraintErrors", mad_dump_uint},
- [IB_PC_ERR_LOCALINTEG_F] {BITSOFFS(152, 4), "LinkIntegrityErrors", mad_dump_uint},
- [IB_PC_ERR_EXCESS_OVR_F] {BITSOFFS(156, 4), "ExcBufOverrunErrors", mad_dump_uint},
- [IB_PC_VL15_DROPPED_F] {BITSOFFS(176, 16), "VL15Dropped", mad_dump_uint},
- [IB_PC_XMT_BYTES_F] {192, 32, "XmtData", mad_dump_uint},
- [IB_PC_RCV_BYTES_F] {224, 32, "RcvData", mad_dump_uint},
- [IB_PC_XMT_PKTS_F] {256, 32, "XmtPkts", mad_dump_uint},
- [IB_PC_RCV_PKTS_F] {288, 32, "RcvPkts", mad_dump_uint},
-
- /*
- * SMInfo
- */
- [IB_SMINFO_GUID_F] {0, 64, "SmInfoGuid", mad_dump_hex},
- [IB_SMINFO_KEY_F] {64, 64, "SmInfoKey", mad_dump_hex},
- [IB_SMINFO_ACT_F] {128, 32, "SmActivity", mad_dump_uint},
- [IB_SMINFO_PRIO_F] {BITSOFFS(160, 4), "SmPriority", mad_dump_uint},
- [IB_SMINFO_STATE_F] {BITSOFFS(164, 4), "SmState", mad_dump_uint},
-
- /*
- * SA RMPP
- */
- [IB_SA_RMPP_VERS_F] {BE_OFFS(24*8+24, 8), "RmppVers", mad_dump_uint},
- [IB_SA_RMPP_TYPE_F] {BE_OFFS(24*8+16, 8), "RmppType", mad_dump_uint},
- [IB_SA_RMPP_RESP_F] {BE_OFFS(24*8+11, 5), "RmppResp", mad_dump_uint},
- [IB_SA_RMPP_FLAGS_F] {BE_OFFS(24*8+8, 3), "RmppFlags", mad_dump_hex},
- [IB_SA_RMPP_STATUS_F] {BE_OFFS(24*8+0, 8), "RmppStatus", mad_dump_hex},
-
- /* data1 */
- [IB_SA_RMPP_D1_F] {28*8, 32, "RmppData1", mad_dump_hex},
- [IB_SA_RMPP_SEGNUM_F] {28*8, 32, "RmppSegNum", mad_dump_uint},
- /* data2 */
- [IB_SA_RMPP_D2_F] {32*8, 32, "RmppData2", mad_dump_hex},
- [IB_SA_RMPP_LEN_F] {32*8, 32, "RmppPayload", mad_dump_uint},
- [IB_SA_RMPP_NEWWIN_F] {32*8, 32, "RmppNewWin", mad_dump_uint},
-
- /*
- * SA Path rec
- */
- [IB_SA_PR_DGID_F] {64, 128, "PathRecDGid", mad_dump_array},
- [IB_SA_PR_SGID_F] {192, 128, "PathRecSGid", mad_dump_array},
- [IB_SA_PR_DLID_F] {BITSOFFS(320,16), "PathRecDLid", mad_dump_hex},
- [IB_SA_PR_SLID_F] {BITSOFFS(336,16), "PathRecSLid", mad_dump_hex},
- [IB_SA_PR_NPATH_F] {BITSOFFS(393,7), "PathRecNumPath", mad_dump_uint},
-
- /*
- * SA Get Multi Path
- */
- [IB_SA_MP_NPATH_F] {BITSOFFS(41,7), "MultiPathNumPath", mad_dump_uint},
- [IB_SA_MP_NSRC_F] {BITSOFFS(120,8), "MultiPathNumSrc", mad_dump_uint},
- [IB_SA_MP_NDEST_F] {BITSOFFS(128,8), "MultiPathNumDest", mad_dump_uint},
- [IB_SA_MP_GID0_F] {192, 128, "MultiPathGid", mad_dump_array},
-
- /*
- * MC Member rec
- */
- [IB_SA_MCM_MGID_F] {0, 128, "McastMemMGid", mad_dump_array},
- [IB_SA_MCM_PORTGID_F] {128, 128, "McastMemPortGid", mad_dump_array},
- [IB_SA_MCM_QKEY_F] {256, 32, "McastMemQkey", mad_dump_hex},
- [IB_SA_MCM_MLID_F] {BITSOFFS(288, 16), "McastMemMLid", mad_dump_hex},
- [IB_SA_MCM_MTU_F] {BITSOFFS(306, 6), "McastMemMTU", mad_dump_uint},
- [IB_SA_MCM_TCLASS_F] {BITSOFFS(312, 8), "McastMemTClass", mad_dump_uint},
- [IB_SA_MCM_PKEY_F] {BITSOFFS(320, 16), "McastMemPkey", mad_dump_uint},
- [IB_SA_MCM_RATE_F] {BITSOFFS(338, 6), "McastMemRate", mad_dump_uint},
- [IB_SA_MCM_SL_F] {BITSOFFS(352, 4), "McastMemSL", mad_dump_uint},
- [IB_SA_MCM_FLOW_LABEL_F] {BITSOFFS(356, 20), "McastMemFlowLbl", mad_dump_uint},
- [IB_SA_MCM_JOIN_STATE_F] {BITSOFFS(388, 4), "McastMemJoinState", mad_dump_uint},
- [IB_SA_MCM_PROXY_JOIN_F] {BITSOFFS(392, 1), "McastMemProxyJoin", mad_dump_uint},
-
- /*
- * Service record
- */
- [IB_SA_SR_ID_F] {0, 64, "ServRecID", mad_dump_hex},
- [IB_SA_SR_GID_F] {64, 128, "ServRecGid", mad_dump_array},
- [IB_SA_SR_PKEY_F] {BITSOFFS(192, 16), "ServRecPkey", mad_dump_hex},
- [IB_SA_SR_LEASE_F] {224, 32, "ServRecLease", mad_dump_hex},
- [IB_SA_SR_KEY_F] {256, 128, "ServRecKey", mad_dump_hex},
- [IB_SA_SR_NAME_F] {384, 512, "ServRecName", mad_dump_string},
- [IB_SA_SR_DATA_F] {896, 512, "ServRecData", mad_dump_array}, /* ATS for example */
-
- /*
- * ATS SM record - within SA_SR_DATA
- */
- [IB_ATS_SM_NODE_ADDR_F] {12*8, 32, "ATSNodeAddr", mad_dump_hex},
- [IB_ATS_SM_MAGIC_KEY_F] {BITSOFFS(16*8, 16), "ATSMagicKey", mad_dump_hex},
- [IB_ATS_SM_NODE_TYPE_F] {BITSOFFS(18*8, 16), "ATSNodeType", mad_dump_hex},
- [IB_ATS_SM_NODE_NAME_F] {32*8, 32*8, "ATSNodeName", mad_dump_string},
-
- /*
- * SLTOVL MAPPING TABLE
- */
- [IB_SLTOVL_MAPPING_TABLE_F] {0, 64, "SLToVLMap", mad_dump_hex},
-
- /*
- * VL ARBITRATION TABLE
- */
- [IB_VL_ARBITRATION_TABLE_F] {0, 512, "VLArbTbl", mad_dump_array},
-
- /*
- * IB vendor classes range 2
- */
- [IB_VEND2_OUI_F] {BE_OFFS(36*8, 24), "OUI", mad_dump_array},
- [IB_VEND2_DATA_F] {40*8, (256-40)*8, "Vendor2Data", mad_dump_array},
-
- /*
- * Extended port counters
- */
- [IB_PC_EXT_PORT_SELECT_F] {BITSOFFS(8, 8), "PortSelect", mad_dump_uint},
- [IB_PC_EXT_COUNTER_SELECT_F] {BITSOFFS(16, 16), "CounterSelect", mad_dump_hex},
- [IB_PC_EXT_XMT_BYTES_F] {64, 64, "PortXmitData", mad_dump_uint},
- [IB_PC_EXT_RCV_BYTES_F] {128, 64, "PortRcvData", mad_dump_uint},
- [IB_PC_EXT_XMT_PKTS_F] {192, 64, "PortXmitPkts", mad_dump_uint},
- [IB_PC_EXT_RCV_PKTS_F] {256, 64, "PortRcvPkts", mad_dump_uint},
- [IB_PC_EXT_XMT_UPKTS_F] {320, 64, "PortUnicastXmitPkts", mad_dump_uint},
- [IB_PC_EXT_RCV_UPKTS_F] {384, 64, "PortUnicastRcvPkts", mad_dump_uint},
- [IB_PC_EXT_XMT_MPKTS_F] {448, 64, "PortMulticastXmitPkts", mad_dump_uint},
- [IB_PC_EXT_RCV_MPKTS_F] {512, 64, "PortMulticastRcvPkts", mad_dump_uint},
-
- /*
- * GUIDInfo fields
- */
- [IB_GUID_GUID0_F] {0, 64, "GUID0", mad_dump_hex},
-
-};
-
-void
-_set_field64(void *buf, int base_offs, ib_field_t *f, uint64_t val)
-{
- uint64_t nval;
-
- nval = htonll(val);
- memcpy((char *)buf + base_offs + f->bitoffs / 8, &nval, sizeof(uint64_t));
-}
-
-uint64_t
-_get_field64(void *buf, int base_offs, ib_field_t *f)
-{
- uint64_t val;
- memcpy(&val, ((char *)buf + base_offs + f->bitoffs / 8), sizeof(uint64_t));
- return ntohll(val);
-}
-
-void
-_set_field(void *buf, int base_offs, ib_field_t *f, uint32_t val)
-{
- int prebits = (8 - (f->bitoffs & 7)) & 7;
- int postbits = (f->bitoffs + f->bitlen) & 7;
- int bytelen = f->bitlen / 8;
- unsigned idx = base_offs + f->bitoffs / 8;
- char *p = (char *)buf;
-
- if (!bytelen && (f->bitoffs & 7) + f->bitlen < 8) {
- p[3^idx] &= ~((((1 << f->bitlen) - 1)) << (f->bitoffs & 7));
- p[3^idx] |= (val & ((1 << f->bitlen) - 1)) << (f->bitoffs & 7);
- return;
- }
-
- if (prebits) { /* val lsb in byte msb */
- p[3^idx] &= (1 << (8 - prebits)) - 1;
- p[3^idx++] |= (val & ((1 << prebits) - 1)) << (8 - prebits);
- val >>= prebits;
- }
-
- /* BIG endian byte order */
- for (; bytelen--; val >>= 8)
- p[3^idx++] = val & 0xff;
-
- if (postbits) { /* val msb in byte lsb */
- p[3^idx] &= ~((1 << postbits) - 1);
- p[3^idx] |= val;
- }
-}
-
-uint32_t
-_get_field(void *buf, int base_offs, ib_field_t *f)
-{
- int prebits = (8 - (f->bitoffs & 7)) & 7;
- int postbits = (f->bitoffs + f->bitlen) & 7;
- int bytelen = f->bitlen / 8;
- unsigned idx = base_offs + f->bitoffs / 8;
- uint8_t *p = (uint8_t *)buf;
- uint32_t val = 0, v = 0, i;
-
- if (!bytelen && (f->bitoffs & 7) + f->bitlen < 8)
- return (p[3^idx] >> (f->bitoffs & 7)) & ((1 << f->bitlen) - 1);
-
- if (prebits) /* val lsb from byte msb */
- v = p[3^idx++] >> (8 - prebits);
-
- if (postbits) { /* val msb from byte lsb */
- i = base_offs + (f->bitoffs + f->bitlen) / 8;
- val = (p[3^i] & ((1 << postbits) - 1));
- }
-
- /* BIG endian byte order */
- for (idx += bytelen - 1; bytelen--; idx--)
- val = (val << 8) | p[3^idx];
-
- return (val << prebits) | v;
-}
-
-/* field must be byte aligned */
-void
-_set_array(void *buf, int base_offs, ib_field_t *f, void *val)
-{
- int bitoffs = f->bitoffs;
-
- if (f->bitlen < 32)
- bitoffs = BE_TO_BITSOFFS(bitoffs, f->bitlen);
-
- memcpy((uint8_t *)buf + base_offs + bitoffs / 8, val, f->bitlen / 8);
-}
-
-void
-_get_array(void *buf, int base_offs, ib_field_t *f, void *val)
-{
- int bitoffs = f->bitoffs;
-
- if (f->bitlen < 32)
- bitoffs = BE_TO_BITSOFFS(bitoffs, f->bitlen);
-
- memcpy(val, (uint8_t *)buf + base_offs + bitoffs / 8, f->bitlen / 8);
-}
diff --git a/contrib/ofed/management/libibmad/src/gs.c b/contrib/ofed/management/libibmad/src/gs.c
deleted file mode 100644
index 89c927e..0000000
--- a/contrib/ofed/management/libibmad/src/gs.c
+++ /dev/null
@@ -1,241 +0,0 @@
-/*
- * Copyright (c) 2004-2007 Voltaire Inc. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- */
-
-#if HAVE_CONFIG_H
-# include <config.h>
-#endif /* HAVE_CONFIG_H */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <string.h>
-#include <pthread.h>
-#include <sys/time.h>
-
-#include <infiniband/umad.h>
-#include "mad.h"
-
-#undef DEBUG
-#define DEBUG if (ibdebug) IBWARN
-
-static uint8_t *
-pma_query_via(void *rcvbuf, ib_portid_t *dest, int port,
- unsigned timeout, unsigned id, const void *srcport)
-{
- ib_rpc_t rpc = {0};
- int lid = dest->lid;
-
- DEBUG("lid %d port %d", lid, port);
-
- if (lid == -1) {
- IBWARN("only lid routed is supported");
- return 0;
- }
-
- rpc.mgtclass = IB_PERFORMANCE_CLASS;
- rpc.method = IB_MAD_METHOD_GET;
- rpc.attr.id = id;
-
- /* Same for attribute IDs */
- mad_set_field(rcvbuf, 0, IB_PC_PORT_SELECT_F, port);
- rpc.attr.mod = 0;
- rpc.timeout = timeout;
- rpc.datasz = IB_PC_DATA_SZ;
- rpc.dataoffs = IB_PC_DATA_OFFS;
-
- dest->qp = 1;
- if (!dest->qkey)
- dest->qkey = IB_DEFAULT_QP1_QKEY;
-
- if (srcport) {
- return mad_rpc(srcport, &rpc, dest, rcvbuf, rcvbuf);
- } else {
- return madrpc(&rpc, dest, rcvbuf, rcvbuf);
- }
-}
-
-uint8_t *
-pma_query(void *rcvbuf, ib_portid_t *dest, int port, unsigned timeout, unsigned id)
-{
- return pma_query_via(rcvbuf, dest, port, timeout, id, NULL);
-}
-
-uint8_t *
-perf_classportinfo_query_via(void *rcvbuf, ib_portid_t *dest, int port,
- unsigned timeout, const void *srcport)
-{
- return pma_query_via(rcvbuf, dest, port, timeout, CLASS_PORT_INFO,
- srcport);
-}
-
-uint8_t *
-perf_classportinfo_query(void *rcvbuf, ib_portid_t *dest, int port, unsigned timeout)
-{
- return pma_query(rcvbuf, dest, port, timeout, CLASS_PORT_INFO);
-}
-
-uint8_t *
-port_performance_query_via(void *rcvbuf, ib_portid_t *dest, int port,
- unsigned timeout, const void *srcport)
-{
- return pma_query_via(rcvbuf, dest, port, timeout,
- IB_GSI_PORT_COUNTERS, srcport);
-}
-
-uint8_t *
-port_performance_query(void *rcvbuf, ib_portid_t *dest, int port, unsigned timeout)
-{
- return pma_query(rcvbuf, dest, port, timeout, IB_GSI_PORT_COUNTERS);
-}
-
-static uint8_t *
-performance_reset_via(void *rcvbuf, ib_portid_t *dest, int port, unsigned mask,
- unsigned timeout, unsigned id, const void *srcport)
-{
- ib_rpc_t rpc = {0};
- int lid = dest->lid;
-
- DEBUG("lid %d port %d mask 0x%x", lid, port, mask);
-
- if (lid == -1) {
- IBWARN("only lid routed is supported");
- return 0;
- }
-
- if (!mask)
- mask = ~0;
-
- rpc.mgtclass = IB_PERFORMANCE_CLASS;
- rpc.method = IB_MAD_METHOD_SET;
- rpc.attr.id = id;
-
- memset(rcvbuf, 0, IB_MAD_SIZE);
-
- /* Same for attribute IDs */
- mad_set_field(rcvbuf, 0, IB_PC_PORT_SELECT_F, port);
- mad_set_field(rcvbuf, 0, IB_PC_COUNTER_SELECT_F, mask);
- rpc.attr.mod = 0;
- rpc.timeout = timeout;
- rpc.datasz = IB_PC_DATA_SZ;
- rpc.dataoffs = IB_PC_DATA_OFFS;
- dest->qp = 1;
- if (!dest->qkey)
- dest->qkey = IB_DEFAULT_QP1_QKEY;
-
- if (srcport) {
- return mad_rpc(srcport, &rpc, dest, rcvbuf, rcvbuf);
- } else {
- return madrpc(&rpc, dest, rcvbuf, rcvbuf);
- }
-}
-
-static uint8_t *
-performance_reset(void *rcvbuf, ib_portid_t *dest, int port, unsigned mask,
- unsigned timeout, unsigned id)
-{
- return performance_reset_via(rcvbuf, dest, port, mask, timeout,
- id, NULL);
-}
-
-uint8_t *
-port_performance_reset_via(void *rcvbuf, ib_portid_t *dest, int port,
- unsigned mask, unsigned timeout, const void *srcport)
-{
- return performance_reset_via(rcvbuf, dest, port, mask, timeout,
- IB_GSI_PORT_COUNTERS, srcport);
-}
-
-uint8_t *
-port_performance_reset(void *rcvbuf, ib_portid_t *dest, int port, unsigned mask,
- unsigned timeout)
-{
- return performance_reset(rcvbuf, dest, port, mask, timeout, IB_GSI_PORT_COUNTERS);
-}
-
-uint8_t *
-port_performance_ext_query_via(void *rcvbuf, ib_portid_t *dest, int port,
- unsigned timeout, const void *srcport)
-{
- return pma_query_via(rcvbuf, dest, port, timeout,
- IB_GSI_PORT_COUNTERS_EXT, srcport);
-}
-
-uint8_t *
-port_performance_ext_query(void *rcvbuf, ib_portid_t *dest, int port, unsigned timeout)
-{
- return pma_query(rcvbuf, dest, port, timeout, IB_GSI_PORT_COUNTERS_EXT);
-}
-
-uint8_t *
-port_performance_ext_reset_via(void *rcvbuf, ib_portid_t *dest, int port,
- unsigned mask, unsigned timeout,
- const void *srcport)
-{
- return performance_reset_via(rcvbuf, dest, port, mask, timeout,
- IB_GSI_PORT_COUNTERS_EXT, srcport);
-}
-
-uint8_t *
-port_performance_ext_reset(void *rcvbuf, ib_portid_t *dest, int port, unsigned mask,
- unsigned timeout)
-{
- return performance_reset(rcvbuf, dest, port, mask, timeout, IB_GSI_PORT_COUNTERS_EXT);
-}
-
-uint8_t *
-port_samples_control_query_via(void *rcvbuf, ib_portid_t *dest, int port,
- unsigned timeout, const void *srcport)
-{
- return pma_query_via(rcvbuf, dest, port, timeout,
- IB_GSI_PORT_SAMPLES_CONTROL, srcport);
-}
-
-uint8_t *
-port_samples_control_query(void *rcvbuf, ib_portid_t *dest, int port, unsigned timeout)
-{
- return pma_query(rcvbuf, dest, port, timeout, IB_GSI_PORT_SAMPLES_CONTROL);
-}
-
-uint8_t *
-port_samples_result_query_via(void *rcvbuf, ib_portid_t *dest, int port,
- unsigned timeout, const void *srcport)
-{
- return pma_query_via(rcvbuf, dest, port, timeout,
- IB_GSI_PORT_SAMPLES_RESULT, srcport);
-}
-
-uint8_t *
-port_samples_result_query(void *rcvbuf, ib_portid_t *dest, int port, unsigned timeout)
-{
- return pma_query(rcvbuf, dest, port, timeout, IB_GSI_PORT_SAMPLES_RESULT);
-}
diff --git a/contrib/ofed/management/libibmad/src/libibmad.map b/contrib/ofed/management/libibmad/src/libibmad.map
deleted file mode 100644
index f26d28d..0000000
--- a/contrib/ofed/management/libibmad/src/libibmad.map
+++ /dev/null
@@ -1,110 +0,0 @@
-IBMAD_1.3 {
- global:
- _mad_dump;
- _mad_dump_field;
- _mad_dump_val;
- _mad_print_field;
- mad_dump_array;
- mad_dump_bitfield;
- mad_dump_hex;
- mad_dump_int;
- mad_dump_linkdowndefstate;
- mad_dump_linkspeed;
- mad_dump_linkspeeden;
- mad_dump_linkspeedsup;
- mad_dump_linkwidth;
- mad_dump_linkwidthen;
- mad_dump_linkwidthsup;
- mad_dump_mtu;
- mad_dump_node_type;
- mad_dump_nodedesc;
- mad_dump_nodeinfo;
- mad_dump_opervls;
- mad_dump_perfcounters;
- mad_dump_perfcounters_ext;
- mad_dump_physportstate;
- mad_dump_portcapmask;
- mad_dump_portinfo;
- mad_dump_portstates;
- mad_dump_portstate;
- mad_dump_rhex;
- mad_dump_sltovl;
- mad_dump_string;
- mad_dump_switchinfo;
- mad_dump_uint;
- mad_dump_vlarbitration;
- mad_dump_vlcap;
- _get_array;
- _get_field;
- _get_field64;
- _set_array;
- _set_field;
- _set_field64;
- ib_mad_f;
- perf_classportinfo_query;
- port_performance_query;
- port_performance_reset;
- port_performance_ext_query;
- port_performance_ext_reset;
- port_samples_control_query;
- port_samples_result_query;
- mad_build_pkt;
- mad_decode_field;
- mad_encode;
- mad_encode_field;
- mad_trid;
- portid2portnum;
- portid2str;
- str2drpath;
- drpath2str;
- mad_agent_class;
- mad_class_agent;
- mad_register_client;
- mad_register_server;
- ib_resolve_guid;
- ib_resolve_portid_str;
- ib_resolve_self;
- ib_resolve_smlid;
- ibdebug;
- mad_rpc_open_port;
- mad_rpc_close_port;
- mad_rpc;
- mad_rpc_rmpp;
- madrpc;
- madrpc_def_timeout;
- madrpc_init;
- madrpc_lock;
- madrpc_portid;
- madrpc_rmpp;
- madrpc_save_mad;
- madrpc_set_retries;
- madrpc_set_timeout;
- madrpc_show_errors;
- madrpc_unlock;
- ib_path_query;
- sa_call;
- sa_rpc_call;
- mad_alloc;
- mad_free;
- mad_receive;
- mad_respond;
- mad_send;
- smp_query;
- smp_set;
- ib_vendor_call;
- smp_query_via;
- smp_set_via;
- ib_path_query_via;
- ib_resolve_smlid_via;
- ib_resolve_guid_via;
- ib_resolve_portid_str_via;
- ib_resolve_self_via;
- perf_classportinfo_query_via;
- port_performance_query_via;
- port_performance_reset_via;
- port_performance_ext_query_via;
- port_performance_ext_reset_via;
- port_samples_control_query_via;
- port_samples_result_query_via;
- local: *;
-};
diff --git a/contrib/ofed/management/libibmad/src/mad.c b/contrib/ofed/management/libibmad/src/mad.c
deleted file mode 100644
index 1367ecd..0000000
--- a/contrib/ofed/management/libibmad/src/mad.c
+++ /dev/null
@@ -1,214 +0,0 @@
-/*
- * Copyright (c) 2004-2007 Voltaire Inc. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- */
-
-#if HAVE_CONFIG_H
-# include <config.h>
-#endif /* HAVE_CONFIG_H */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <string.h>
-#include <pthread.h>
-#include <sys/time.h>
-
-#include <infiniband/common.h>
-#include <infiniband/umad.h>
-#include <mad.h>
-
-#undef DEBUG
-#define DEBUG if (ibdebug) IBWARN
-
-void
-mad_decode_field(uint8_t *buf, int field, void *val)
-{
- ib_field_t *f = ib_mad_f + field;
-
- if (!field) {
- *(int *)val = *(int *)buf;
- return;
- }
- if (f->bitlen <= 32) {
- *(uint32_t *)val = _get_field(buf, 0, f);
- return;
- }
- if (f->bitlen == 64) {
- *(uint64_t *)val = _get_field64(buf, 0, f);
- return;
- }
- _get_array(buf, 0, f, val);
-}
-
-void
-mad_encode_field(uint8_t *buf, int field, void *val)
-{
- ib_field_t *f = ib_mad_f + field;
-
- if (!field) {
- *(int *)buf = *(int *)val;
- return;
- }
- if (f->bitlen <= 32) {
- _set_field(buf, 0, f, *(uint32_t *)val);
- return;
- }
- if (f->bitlen == 64) {
- _set_field64(buf, 0, f, *(uint64_t *)val);
- return;
- }
- _set_array(buf, 0, f, val);
-}
-
-uint64_t
-mad_trid(void)
-{
- static uint64_t base;
- static uint64_t trid;
- uint64_t next;
-
- if (!base) {
- srandom(time(0)*getpid());
- base = random();
- trid = random();
- }
- next = ++trid | (base << 32);
- return next;
-}
-
-void *
-mad_encode(void *buf, ib_rpc_t *rpc, ib_dr_path_t *drpath, void *data)
-{
- int is_resp = rpc->method & IB_MAD_RESPONSE;
-
- /* first word */
- mad_set_field(buf, 0, IB_MAD_METHOD_F, rpc->method);
- mad_set_field(buf, 0, IB_MAD_RESPONSE_F, is_resp ? 1 : 0);
- mad_set_field(buf, 0, IB_MAD_CLASSVER_F, rpc->mgtclass == IB_SA_CLASS ? 2 : 1);
- mad_set_field(buf, 0, IB_MAD_MGMTCLASS_F, rpc->mgtclass);
- mad_set_field(buf, 0, IB_MAD_BASEVER_F, 1);
-
- /* second word */
- if (rpc->mgtclass == IB_SMI_DIRECT_CLASS) {
- if (!drpath) {
- IBWARN("encoding dr mad without drpath (null)");
- return 0;
- }
- mad_set_field(buf, 0, IB_DRSMP_HOPCNT_F, drpath->cnt);
- mad_set_field(buf, 0, IB_DRSMP_HOPPTR_F, is_resp ? drpath->cnt + 1 : 0x0);
- mad_set_field(buf, 0, IB_DRSMP_STATUS_F, rpc->rstatus);
- mad_set_field(buf, 0, IB_DRSMP_DIRECTION_F, is_resp ? 1 : 0); /* out */
- } else
- mad_set_field(buf, 0, IB_MAD_STATUS_F, rpc->rstatus);
-
- /* words 3,4,5,6 */
- if (!rpc->trid)
- rpc->trid = mad_trid();
-
- mad_set_field64(buf, 0, IB_MAD_TRID_F, rpc->trid);
- mad_set_field(buf, 0, IB_MAD_ATTRID_F, rpc->attr.id);
- mad_set_field(buf, 0, IB_MAD_ATTRMOD_F, rpc->attr.mod);
-
- /* words 7,8 */
- mad_set_field(buf, 0, IB_MAD_MKEY_F, rpc->mkey >> 32);
- mad_set_field(buf, 4, IB_MAD_MKEY_F, rpc->mkey & 0xffffffff);
-
- if (rpc->mgtclass == IB_SMI_DIRECT_CLASS) {
- /* word 9 */
- mad_set_field(buf, 0, IB_DRSMP_DRDLID_F, drpath->drdlid ? drpath->drdlid : 0xffff);
- mad_set_field(buf, 0, IB_DRSMP_DRSLID_F, drpath->drslid ? drpath->drslid : 0xffff);
-
- /* bytes 128 - 256 - by default should be zero due to memset*/
- if (is_resp)
- mad_set_array(buf, 0, IB_DRSMP_RPATH_F, drpath->p);
- else
- mad_set_array(buf, 0, IB_DRSMP_PATH_F, drpath->p);
- }
-
- if (rpc->mgtclass == IB_SA_CLASS)
- mad_set_field64(buf, 0, IB_SA_COMPMASK_F, rpc->mask);
-
- if (data)
- memcpy((char *)buf + rpc->dataoffs, data, rpc->datasz);
-
- /* vendor mads range 2 */
- if (mad_is_vendor_range2(rpc->mgtclass))
- mad_set_field(buf, 0, IB_VEND2_OUI_F, rpc->oui);
-
- return (uint8_t *)buf + IB_MAD_SIZE;
-}
-
-int
-mad_build_pkt(void *umad, ib_rpc_t *rpc, ib_portid_t *dport,
- ib_rmpp_hdr_t *rmpp, void *data)
-{
- uint8_t *p, *mad;
- int lid_routed = rpc->mgtclass != IB_SMI_DIRECT_CLASS;
- int is_smi = (rpc->mgtclass == IB_SMI_CLASS ||
- rpc->mgtclass == IB_SMI_DIRECT_CLASS);
- struct ib_mad_addr addr;
-
- if (!is_smi)
- umad_set_addr(umad, dport->lid, dport->qp, dport->sl, dport->qkey);
- else if (lid_routed)
- umad_set_addr(umad, dport->lid, dport->qp, 0, 0);
- else if ((dport->drpath.drslid != 0xffff) && (dport->lid > 0))
- umad_set_addr(umad, dport->lid, 0, 0, 0);
- else
- umad_set_addr(umad, 0xffff, 0, 0, 0);
-
- if (dport->grh_present && !is_smi) {
- addr.grh_present = 1;
- memcpy(addr.gid, dport->gid, 16);
- addr.hop_limit = 0xff;
- addr.traffic_class = 0;
- addr.flow_label = 0;
- umad_set_grh(umad, &addr);
- } else
- umad_set_grh(umad, 0);
- umad_set_pkey(umad, is_smi ? 0 : dport->pkey_idx);
-
- mad = umad_get_mad(umad);
- p = mad_encode(mad, rpc, lid_routed ? 0 : &dport->drpath, data);
-
- if (!is_smi && rmpp) {
- mad_set_field(mad, 0, IB_SA_RMPP_VERS_F, 1);
- mad_set_field(mad, 0, IB_SA_RMPP_TYPE_F, rmpp->type);
- mad_set_field(mad, 0, IB_SA_RMPP_RESP_F, 0x3f);
- mad_set_field(mad, 0, IB_SA_RMPP_FLAGS_F, rmpp->flags);
- mad_set_field(mad, 0, IB_SA_RMPP_STATUS_F, rmpp->status);
- mad_set_field(mad, 0, IB_SA_RMPP_D1_F, rmpp->d1.u);
- mad_set_field(mad, 0, IB_SA_RMPP_D2_F, rmpp->d2.u);
- }
-
- return p - mad;
-}
diff --git a/contrib/ofed/management/libibmad/src/portid.c b/contrib/ofed/management/libibmad/src/portid.c
deleted file mode 100644
index 24a555b..0000000
--- a/contrib/ofed/management/libibmad/src/portid.c
+++ /dev/null
@@ -1,126 +0,0 @@
-/*
- * Copyright (c) 2004-2008 Voltaire Inc. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- */
-
-#if HAVE_CONFIG_H
-# include <config.h>
-#endif /* HAVE_CONFIG_H */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <pthread.h>
-#include <sys/time.h>
-#include <string.h>
-#include <inttypes.h>
-#include <arpa/inet.h>
-
-#include <mad.h>
-#include <infiniband/common.h>
-
-#undef DEBUG
-#define DEBUG if (ibdebug) IBWARN
-
-int
-portid2portnum(ib_portid_t *portid)
-{
- if (portid->lid > 0)
- return -1;
-
- if (portid->drpath.cnt == 0)
- return 0;
-
- return portid->drpath.p[(portid->drpath.cnt-1)];
-}
-
-char *
-portid2str(ib_portid_t *portid)
-{
- static char buf[1024] = "local";
- int n = 0;
-
- if (portid->lid > 0) {
- n += sprintf(buf + n, "Lid %d", portid->lid);
- if (portid->grh_present) {
- char gid[sizeof "ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff"];
- if (inet_ntop(AF_INET6, portid->gid, gid, sizeof(gid)))
- n += sprintf(buf + n, " Gid %s", gid);
- }
- if (portid->drpath.cnt)
- n += sprintf(buf + n, " ");
- else
- return buf;
- }
- n += sprintf(buf + n, "DR path ");
- drpath2str(&(portid->drpath), buf + n, sizeof(buf) - n);
-
- return buf;
-}
-
-int
-str2drpath(ib_dr_path_t *path, char *routepath, int drslid, int drdlid)
-{
- char *s, *str = routepath;
-
- path->cnt = -1;
-
- DEBUG("DR str: %s", routepath);
- while (str && *str) {
- if ((s = strchr(str, ',')))
- *s = 0;
- path->p[++path->cnt] = atoi(str);
- if (!s)
- break;
- str = s+1;
- }
-
- path->drdlid = drdlid ? drdlid : 0xffff;
- path->drslid = drslid ? drslid : 0xffff;
-
- return path->cnt;
-}
-
-char *
-drpath2str(ib_dr_path_t *path, char *dstr, size_t dstr_size)
-{
- int i = 0;
- int rc = snprintf(dstr, dstr_size, "slid %d; dlid %d; %d",
- path->drslid, path->drdlid, path->p[0]);
- if (rc >= dstr_size)
- return dstr;
- for (i = 1; i <= path->cnt; i++) {
- rc += snprintf(dstr+rc, dstr_size-rc, ",%d", path->p[i]);
- if (rc >= dstr_size)
- break;
- }
- return (dstr);
-}
diff --git a/contrib/ofed/management/libibmad/src/register.c b/contrib/ofed/management/libibmad/src/register.c
deleted file mode 100644
index a33acd8..0000000
--- a/contrib/ofed/management/libibmad/src/register.c
+++ /dev/null
@@ -1,202 +0,0 @@
-/*
- * Copyright (c) 2004,2005 Voltaire Inc. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- */
-
-#if HAVE_CONFIG_H
-# include <config.h>
-#endif /* HAVE_CONFIG_H */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <pthread.h>
-#include <sys/time.h>
-#include <string.h>
-#include <errno.h>
-
-#include <infiniband/umad.h>
-#include "mad.h"
-
-#undef DEBUG
-#define DEBUG if (ibdebug) IBWARN
-
-#define MAX_CLASS 256
-#define MAX_AGENTS 256
-
-static int class_agent[MAX_CLASS];
-static int agent_class[MAX_AGENTS];
-
-static int
-register_agent(int agent, int mclass)
-{
- static int initialized;
-
- if (!initialized) {
- initialized++;
- memset(class_agent, 0xff, sizeof class_agent);
- memset(agent_class, 0xff, sizeof agent_class);
- }
-
- if (mclass < 0 || mclass >= MAX_CLASS ||
- agent < 0 || agent >= MAX_AGENTS) {
- DEBUG("bad mgmt class %d or agent %d", mclass, agent);
- return -1;
- }
-
- class_agent[mclass] = agent;
- agent_class[agent] = mclass;
-
- return 0;
-}
-
-static int
-mgmt_class_vers(int mgmt_class)
-{
- if ((mgmt_class >= IB_VENDOR_RANGE1_START_CLASS &&
- mgmt_class <= IB_VENDOR_RANGE1_END_CLASS) ||
- (mgmt_class >= IB_VENDOR_RANGE2_START_CLASS &&
- mgmt_class <= IB_VENDOR_RANGE2_END_CLASS))
- return 1;
-
- switch(mgmt_class) {
- case IB_SMI_CLASS:
- case IB_SMI_DIRECT_CLASS:
- return 1;
- case IB_SA_CLASS:
- return 2;
- case IB_PERFORMANCE_CLASS:
- return 1;
- case IB_DEVICE_MGMT_CLASS:
- return 1;
- case IB_CC_CLASS:
- return 2;
- }
-
- return 0;
-}
-
-int
-mad_class_agent(int mgmt)
-{
- if (mgmt < 1 || mgmt > MAX_CLASS)
- return -1;
- return class_agent[mgmt];
-}
-
-int
-mad_agent_class(int agent)
-{
- if (agent < 1 || agent > MAX_AGENTS)
- return -1;
- return agent_class[agent];
-}
-
-int
-mad_register_port_client(int port_id, int mgmt, uint8_t rmpp_version)
-{
- int vers, agent;
-
- if ((vers = mgmt_class_vers(mgmt)) <= 0) {
- DEBUG("Unknown class %d mgmt_class", mgmt);
- return -1;
- }
- if ((agent = umad_register(port_id, mgmt,
- vers, rmpp_version, 0)) < 0) {
- DEBUG("Can't register agent for class %d", mgmt);
- return -1;
- }
-
- if (mgmt < 0 || mgmt >= MAX_CLASS || agent >= MAX_AGENTS) {
- DEBUG("bad mgmt class %d or agent %d", mgmt, agent);
- return -1;
- }
-
- return agent;
-}
-
-int
-mad_register_client(int mgmt, uint8_t rmpp_version)
-{
- int agent;
-
- agent = mad_register_port_client(madrpc_portid(), mgmt, rmpp_version);
- if (agent < 0)
- return agent;
-
- return register_agent(agent, mgmt);
-}
-
-int
-mad_register_server(int mgmt, uint8_t rmpp_version,
- long method_mask[], uint32_t class_oui)
-{
- long class_method_mask[16/sizeof(long)];
- uint8_t oui[3];
- int agent, vers, mad_portid;
-
- if (method_mask)
- memcpy(class_method_mask, method_mask, sizeof class_method_mask);
- else
- memset(class_method_mask, 0xff, sizeof(class_method_mask));
-
- if ((mad_portid = madrpc_portid()) < 0)
- return -1;
-
- if (class_agent[mgmt] >= 0) {
- DEBUG("Class 0x%x already registered", mgmt);
- return -1;
- }
- if ((vers = mgmt_class_vers(mgmt)) <= 0) {
- DEBUG("Unknown class 0x%x mgmt_class", mgmt);
- return -1;
- }
- if (mgmt >= IB_VENDOR_RANGE2_START_CLASS &&
- mgmt <= IB_VENDOR_RANGE2_END_CLASS) {
- oui[0] = (class_oui >> 16) & 0xff;
- oui[1] = (class_oui >> 8) & 0xff;
- oui[2] = class_oui & 0xff;
- if ((agent = umad_register_oui(mad_portid, mgmt, rmpp_version,
- oui, class_method_mask)) < 0) {
- DEBUG("Can't register agent for class %d", mgmt);
- return -1;
- }
- } else if ((agent = umad_register(mad_portid, mgmt, vers, rmpp_version,
- class_method_mask)) < 0) {
- DEBUG("Can't register agent for class %d", mgmt);
- return -1;
- }
-
- if (register_agent(agent, mgmt) < 0)
- return -1;
-
- return agent;
-}
diff --git a/contrib/ofed/management/libibmad/src/resolve.c b/contrib/ofed/management/libibmad/src/resolve.c
deleted file mode 100644
index 25062f6..0000000
--- a/contrib/ofed/management/libibmad/src/resolve.c
+++ /dev/null
@@ -1,186 +0,0 @@
-/*
- * Copyright (c) 2004-2006 Voltaire Inc. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- */
-
-#if HAVE_CONFIG_H
-# include <config.h>
-#endif /* HAVE_CONFIG_H */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <pthread.h>
-#include <string.h>
-#include <sys/time.h>
-
-#include <infiniband/common.h>
-#include <infiniband/umad.h>
-#include <mad.h>
-
-#undef DEBUG
-#define DEBUG if (ibdebug) IBWARN
-
-int
-ib_resolve_smlid_via(ib_portid_t *sm_id, int timeout, const void *srcport)
-{
- ib_portid_t self = {0};
- uint8_t portinfo[64];
- int lid;
-
- memset(sm_id, 0, sizeof(*sm_id));
-
- if (!smp_query_via(portinfo, &self, IB_ATTR_PORT_INFO,
- 0, 0, srcport))
- return -1;
-
- mad_decode_field(portinfo, IB_PORT_SMLID_F, &lid);
-
- return ib_portid_set(sm_id, lid, 0, 0);
-}
-
-int
-ib_resolve_smlid(ib_portid_t *sm_id, int timeout)
-{
- return ib_resolve_smlid_via(sm_id, timeout, NULL);
-}
-
-int
-ib_resolve_guid_via(ib_portid_t *portid, uint64_t *guid, ib_portid_t *sm_id, int timeout, const void *srcport)
-{
- ib_portid_t sm_portid;
- char buf[IB_SA_DATA_SIZE] = {0};
-
- if (!sm_id) {
- sm_id = &sm_portid;
- if (ib_resolve_smlid_via(sm_id, timeout, srcport) < 0)
- return -1;
- }
- if (*(uint64_t*)&portid->gid == 0)
- mad_set_field64(portid->gid, 0, IB_GID_PREFIX_F, IB_DEFAULT_SUBN_PREFIX);
- if (guid)
- mad_set_field64(portid->gid, 0, IB_GID_GUID_F, *guid);
-
- if ((portid->lid = ib_path_query_via(srcport, portid->gid, portid->gid, sm_id, buf)) < 0)
- return -1;
-
- return 0;
-}
-
-int
-ib_resolve_portid_str_via(ib_portid_t *portid, char *addr_str, int dest_type, ib_portid_t *sm_id, const void *srcport)
-{
- uint64_t guid;
- int lid;
- char *routepath;
- ib_portid_t selfportid = {0};
- int selfport = 0;
-
- switch (dest_type) {
- case IB_DEST_LID:
- lid = strtol(addr_str, 0, 0);
- if (!IB_LID_VALID(lid))
- return -1;
- return ib_portid_set(portid, lid, 0, 0);
-
- case IB_DEST_DRPATH:
- if (str2drpath(&portid->drpath, addr_str, 0, 0) < 0)
- return -1;
- return 0;
-
- case IB_DEST_GUID:
- if (!(guid = strtoull(addr_str, 0, 0)))
- return -1;
-
- /* keep guid in portid? */
- return ib_resolve_guid_via(portid, &guid, sm_id, 0, srcport);
-
- case IB_DEST_DRSLID:
- lid = strtol(addr_str, &routepath, 0);
- routepath++;
- if (!IB_LID_VALID(lid))
- return -1;
- ib_portid_set(portid, lid, 0, 0);
-
- /* handle DR parsing and set DrSLID to local lid */
- if (ib_resolve_self_via(&selfportid, &selfport, 0, srcport) < 0)
- return -1;
- if (str2drpath(&portid->drpath, routepath, selfportid.lid, 0) < 0)
- return -1;
- return 0;
-
- default:
- IBWARN("bad dest_type %d", dest_type);
- }
-
- return -1;
-}
-
-int
-ib_resolve_portid_str(ib_portid_t *portid, char *addr_str, int dest_type, ib_portid_t *sm_id)
-{
- return ib_resolve_portid_str_via(portid, addr_str, dest_type,
- sm_id, NULL);
-}
-
-int
-ib_resolve_self_via(ib_portid_t *portid, int *portnum, ibmad_gid_t *gid,
- const void *srcport)
-{
- ib_portid_t self = {0};
- uint8_t portinfo[64];
- uint8_t nodeinfo[64];
- uint64_t guid, prefix;
-
- if (!smp_query_via(nodeinfo, &self, IB_ATTR_NODE_INFO, 0, 0, srcport))
- return -1;
-
- if (!smp_query_via(portinfo, &self, IB_ATTR_PORT_INFO, 0, 0, srcport))
- return -1;
-
- mad_decode_field(portinfo, IB_PORT_LID_F, &portid->lid);
- mad_decode_field(portinfo, IB_PORT_GID_PREFIX_F, &prefix);
- mad_decode_field(nodeinfo, IB_NODE_PORT_GUID_F, &guid);
-
- if (portnum)
- mad_decode_field(nodeinfo, IB_NODE_LOCAL_PORT_F, portnum);
- if (gid) {
- mad_encode_field(*gid, IB_GID_PREFIX_F, &prefix);
- mad_encode_field(*gid, IB_GID_GUID_F, &guid);
- }
- return 0;
-}
-
-int
-ib_resolve_self(ib_portid_t *portid, int *portnum, ibmad_gid_t *gid)
-{
- return ib_resolve_self_via (portid, portnum, gid, NULL);
-}
diff --git a/contrib/ofed/management/libibmad/src/rpc.c b/contrib/ofed/management/libibmad/src/rpc.c
deleted file mode 100644
index f27c5af..0000000
--- a/contrib/ofed/management/libibmad/src/rpc.c
+++ /dev/null
@@ -1,402 +0,0 @@
-/*
- * Copyright (c) 2004-2006 Voltaire Inc. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- */
-
-#if HAVE_CONFIG_H
-# include <config.h>
-#endif /* HAVE_CONFIG_H */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <pthread.h>
-#include <sys/time.h>
-#include <string.h>
-#include <errno.h>
-
-#include <infiniband/umad.h>
-#include "mad.h"
-
-#define MAX_CLASS 256
-
-struct ibmad_port {
- int port_id; /* file descriptor returned by umad_open() */
- int class_agents[MAX_CLASS]; /* class2agent mapper */
-};
-
-int ibdebug;
-
-static int mad_portid = -1;
-static int iberrs;
-
-static int madrpc_retries = MAD_DEF_RETRIES;
-static int def_madrpc_timeout = MAD_DEF_TIMEOUT_MS;
-static void *save_mad;
-static int save_mad_len = 256;
-
-#undef DEBUG
-#define DEBUG if (ibdebug) IBWARN
-#define ERRS if (iberrs || ibdebug) IBWARN
-
-#define MAD_TID(mad) (*((uint64_t *)((char *)(mad) + 8)))
-
-void
-madrpc_show_errors(int set)
-{
- iberrs = set;
-}
-
-void
-madrpc_save_mad(void *madbuf, int len)
-{
- save_mad = madbuf;
- save_mad_len = len;
-}
-
-int
-madrpc_set_retries(int retries)
-{
- if (retries > 0)
- madrpc_retries = retries;
- return madrpc_retries;
-}
-
-int
-madrpc_set_timeout(int timeout)
-{
- def_madrpc_timeout = timeout;
- return 0;
-}
-
-int
-madrpc_def_timeout(void)
-{
- return def_madrpc_timeout;
-}
-
-int
-madrpc_portid(void)
-{
- return mad_portid;
-}
-
-static int
-_do_madrpc(int port_id, void *sndbuf, void *rcvbuf, int agentid, int len,
- int timeout)
-{
- uint32_t trid; /* only low 32 bits */
- int retries;
- int length, status;
-
- if (!timeout)
- timeout = def_madrpc_timeout;
-
- if (ibdebug > 1) {
- IBWARN(">>> sending: len %d pktsz %zu", len, umad_size() + len);
- xdump(stderr, "send buf\n", sndbuf, umad_size() + len);
- }
-
- if (save_mad) {
- memcpy(save_mad, umad_get_mad(sndbuf),
- save_mad_len < len ? save_mad_len : len);
- save_mad = 0;
- }
-
- trid = mad_get_field64(umad_get_mad(sndbuf), 0, IB_MAD_TRID_F);
-
- for (retries = 0; retries < madrpc_retries; retries++) {
- if (retries) {
- ERRS("retry %d (timeout %d ms)", retries, timeout);
- }
-
- length = len;
- if (umad_send(port_id, agentid, sndbuf, length, timeout, 0) < 0) {
- IBWARN("send failed; %s", strerror(errno));
- return -1;
- }
-
- /* Use same timeout on receive side just in case */
- /* send packet is lost somewhere. */
- do {
- if (umad_recv(port_id, rcvbuf, &length, timeout) < 0) {
- IBWARN("recv failed: %s", strerror(errno));
- return -1;
- }
-
- if (ibdebug > 1) {
- IBWARN("rcv buf:");
- xdump(stderr, "rcv buf\n", umad_get_mad(rcvbuf), IB_MAD_SIZE);
- }
- } while ((uint32_t)mad_get_field64(umad_get_mad(rcvbuf), 0, IB_MAD_TRID_F) != trid);
-
- status = umad_status(rcvbuf);
- if (!status)
- return length; /* done */
- if (status == ENOMEM)
- return length;
- }
-
- ERRS("timeout after %d retries, %d ms", retries, timeout * retries);
- return -1;
-}
-
-void *
-mad_rpc(const void *port_id, ib_rpc_t *rpc, ib_portid_t *dport, void *payload,
- void *rcvdata)
-{
- const struct ibmad_port *p = port_id;
- int status, len;
- uint8_t sndbuf[1024], rcvbuf[1024], *mad;
-
- len = 0;
- memset(sndbuf, 0, umad_size() + IB_MAD_SIZE);
-
- if ((len = mad_build_pkt(sndbuf, rpc, dport, 0, payload)) < 0)
- return 0;
-
- if ((len = _do_madrpc(p->port_id, sndbuf, rcvbuf,
- p->class_agents[rpc->mgtclass],
- len, rpc->timeout)) < 0) {
- IBWARN("_do_madrpc failed; dport (%s)", portid2str(dport));
- return 0;
- }
-
- mad = umad_get_mad(rcvbuf);
-
- if ((status = mad_get_field(mad, 0, IB_DRSMP_STATUS_F)) != 0) {
- ERRS("MAD completed with error status 0x%x; dport (%s)",
- status, portid2str(dport));
- return 0;
- }
-
- if (ibdebug) {
- IBWARN("data offs %d sz %d", rpc->dataoffs, rpc->datasz);
- xdump(stderr, "mad data\n", mad + rpc->dataoffs, rpc->datasz);
- }
-
- if (rcvdata)
- memcpy(rcvdata, mad + rpc->dataoffs, rpc->datasz);
-
- return rcvdata;
-}
-
-void *
-mad_rpc_rmpp(const void *port_id, ib_rpc_t *rpc, ib_portid_t *dport,
- ib_rmpp_hdr_t *rmpp, void *data)
-{
- const struct ibmad_port *p = port_id;
- int status, len;
- uint8_t sndbuf[1024], rcvbuf[1024], *mad;
-
- memset(sndbuf, 0, umad_size() + IB_MAD_SIZE);
-
- DEBUG("rmpp %p data %p", rmpp, data);
-
- if ((len = mad_build_pkt(sndbuf, rpc, dport, rmpp, data)) < 0)
- return 0;
-
- if ((len = _do_madrpc(p->port_id, sndbuf, rcvbuf,
- p->class_agents[rpc->mgtclass],
- len, rpc->timeout)) < 0) {
- IBWARN("_do_madrpc failed; dport (%s)", portid2str(dport));
- return 0;
- }
-
- mad = umad_get_mad(rcvbuf);
-
- if ((status = mad_get_field(mad, 0, IB_MAD_STATUS_F)) != 0) {
- ERRS("MAD completed with error status 0x%x; dport (%s)",
- status, portid2str(dport));
- return 0;
- }
-
- if (ibdebug) {
- IBWARN("data offs %d sz %d", rpc->dataoffs, rpc->datasz);
- xdump(stderr, "rmpp mad data\n", mad + rpc->dataoffs,
- rpc->datasz);
- }
-
- if (rmpp) {
- rmpp->flags = mad_get_field(mad, 0, IB_SA_RMPP_FLAGS_F);
- if ((rmpp->flags & 0x3) &&
- mad_get_field(mad, 0, IB_SA_RMPP_VERS_F) != 1) {
- IBWARN("bad rmpp version");
- return 0;
- }
- rmpp->type = mad_get_field(mad, 0, IB_SA_RMPP_TYPE_F);
- rmpp->status = mad_get_field(mad, 0, IB_SA_RMPP_STATUS_F);
- DEBUG("rmpp type %d status %d", rmpp->type, rmpp->status);
- rmpp->d1.u = mad_get_field(mad, 0, IB_SA_RMPP_D1_F);
- rmpp->d2.u = mad_get_field(mad, 0, IB_SA_RMPP_D2_F);
- }
-
- if (data)
- memcpy(data, mad + rpc->dataoffs, rpc->datasz);
-
- rpc->recsz = mad_get_field(mad, 0, IB_SA_ATTROFFS_F);
-
- return data;
-}
-
-void *
-madrpc(ib_rpc_t *rpc, ib_portid_t *dport, void *payload, void *rcvdata)
-{
- struct ibmad_port port;
-
- port.port_id = mad_portid;
- port.class_agents[rpc->mgtclass] = mad_class_agent(rpc->mgtclass);
- return mad_rpc(&port, rpc, dport, payload, rcvdata);
-}
-
-void *
-madrpc_rmpp(ib_rpc_t *rpc, ib_portid_t *dport, ib_rmpp_hdr_t *rmpp, void *data)
-{
- struct ibmad_port port;
-
- port.port_id = mad_portid;
- port.class_agents[rpc->mgtclass] = mad_class_agent(rpc->mgtclass);
- return mad_rpc_rmpp(&port, rpc, dport, rmpp, data);
-}
-
-static pthread_mutex_t rpclock = PTHREAD_MUTEX_INITIALIZER;
-
-void
-madrpc_lock(void)
-{
- pthread_mutex_lock(&rpclock);
-}
-
-void
-madrpc_unlock(void)
-{
- pthread_mutex_unlock(&rpclock);
-}
-
-void
-madrpc_init(char *dev_name, int dev_port, int *mgmt_classes, int num_classes)
-{
- if (umad_init() < 0)
- IBPANIC("can't init UMAD library");
-
- if ((mad_portid = umad_open_port(dev_name, dev_port)) < 0)
- IBPANIC("can't open UMAD port (%s:%d)", dev_name, dev_port);
-
- if (num_classes >= MAX_CLASS)
- IBPANIC("too many classes %d requested", num_classes);
-
- while (num_classes--) {
- int rmpp_version = 0;
- int mgmt = *mgmt_classes++;
-
- if (mgmt == IB_SA_CLASS)
- rmpp_version = 1;
- if (mad_register_client(mgmt, rmpp_version) < 0)
- IBPANIC("client_register for mgmt class %d failed", mgmt);
- }
-}
-
-void *
-mad_rpc_open_port(char *dev_name, int dev_port,
- int *mgmt_classes, int num_classes)
-{
- struct ibmad_port *p;
- int port_id;
-
- if (num_classes >= MAX_CLASS) {
- IBWARN("too many classes %d requested", num_classes);
- errno = EINVAL;
- return NULL;
- }
-
- if (umad_init() < 0) {
- IBWARN("can't init UMAD library");
- errno = ENODEV;
- return NULL;
- }
-
- p = malloc(sizeof(*p));
- if (!p) {
- errno = ENOMEM;
- return NULL;
- }
- memset(p, 0, sizeof(*p));
-
- if ((port_id = umad_open_port(dev_name, dev_port)) < 0) {
- IBWARN("can't open UMAD port (%s:%d)", dev_name, dev_port);
- if (!errno)
- errno = EIO;
- free(p);
- return NULL;
- }
-
- while (num_classes--) {
- int rmpp_version = 0;
- int mgmt = *mgmt_classes++;
- int agent;
-
- if (mgmt == IB_SA_CLASS)
- rmpp_version = 1;
- if (mgmt < 0 || mgmt >= MAX_CLASS ||
- (agent = mad_register_port_client(port_id, mgmt,
- rmpp_version)) < 0) {
- IBWARN("client_register for mgmt %d failed", mgmt);
- if(!errno)
- errno = EINVAL;
- umad_close_port(port_id);
- free(p);
- return NULL;
- }
- p->class_agents[mgmt] = agent;
- }
-
- p->port_id = port_id;
- return p;
-}
-
-void
-mad_rpc_close_port(void *port_id)
-{
- struct ibmad_port *p = port_id;
-
- umad_close_port(p->port_id);
- free(p);
-}
-
-uint8_t *
-sa_call(void *rcvbuf, ib_portid_t *portid, ib_sa_call_t *sa, unsigned timeout)
-{
- struct ibmad_port port;
-
- port.port_id = mad_portid;
- port.class_agents[IB_SA_CLASS] = mad_class_agent(IB_SA_CLASS);
- return sa_rpc_call(&port, rcvbuf, portid, sa, timeout);
-}
diff --git a/contrib/ofed/management/libibmad/src/sa.c b/contrib/ofed/management/libibmad/src/sa.c
deleted file mode 100644
index 2e092ec..0000000
--- a/contrib/ofed/management/libibmad/src/sa.c
+++ /dev/null
@@ -1,152 +0,0 @@
-/*
- * Copyright (c) 2004-2007 Voltaire Inc. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- */
-
-#if HAVE_CONFIG_H
-# include <config.h>
-#endif /* HAVE_CONFIG_H */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <pthread.h>
-#include <string.h>
-#include <sys/time.h>
-
-#include <mad.h>
-#include <infiniband/common.h>
-
-#undef DEBUG
-#define DEBUG if (ibdebug) IBWARN
-
-uint8_t *
-sa_rpc_call(const void *ibmad_port, void *rcvbuf, ib_portid_t *portid,
- ib_sa_call_t *sa, unsigned timeout)
-{
- ib_rpc_t rpc = {0};
- uint8_t *p;
-
- DEBUG("attr 0x%x mod 0x%x route %s", sa->attrid, sa->mod,
- portid2str(portid));
-
- if (portid->lid <= 0) {
- IBWARN("only lid routes are supported");
- return 0;
- }
-
- rpc.mgtclass = IB_SA_CLASS;
- rpc.method = sa->method;
- rpc.attr.id = sa->attrid;
- rpc.attr.mod = sa->mod;
- rpc.mask = sa->mask;
- rpc.timeout = timeout;
- rpc.datasz = IB_SA_DATA_SIZE;
- rpc.dataoffs = IB_SA_DATA_OFFS;
- rpc.trid = sa->trid;
-
- portid->qp = 1;
- if (!portid->qkey)
- portid->qkey = IB_DEFAULT_QP1_QKEY;
-
- p = mad_rpc_rmpp(ibmad_port, &rpc, portid, 0/*&sa->rmpp*/, rcvbuf); /* TODO: RMPP */
-
- sa->recsz = rpc.recsz;
-
- return p;
-}
-
-/* PathRecord */
-#define IB_PR_COMPMASK_DGID (1ull<<2)
-#define IB_PR_COMPMASK_SGID (1ull<<3)
-#define IB_PR_COMPMASK_DLID (1ull<<4)
-#define IB_PR_COMPMASK_SLID (1ull<<5)
-#define IB_PR_COMPMASK_RAWTRAFIC (1ull<<6)
-#define IB_PR_COMPMASK_RESV0 (1ull<<7)
-#define IB_PR_COMPMASK_FLOWLABEL (1ull<<8)
-#define IB_PR_COMPMASK_HOPLIMIT (1ull<<9)
-#define IB_PR_COMPMASK_TCLASS (1ull<<10)
-#define IB_PR_COMPMASK_REVERSIBLE (1ull<<11)
-#define IB_PR_COMPMASK_NUMBPATH (1ull<<12)
-#define IB_PR_COMPMASK_PKEY (1ull<<13)
-#define IB_PR_COMPMASK_RESV1 (1ull<<14)
-#define IB_PR_COMPMASK_SL (1ull<<15)
-#define IB_PR_COMPMASK_MTUSELEC (1ull<<16)
-#define IB_PR_COMPMASK_MTU (1ull<<17)
-#define IB_PR_COMPMASK_RATESELEC (1ull<<18)
-#define IB_PR_COMPMASK_RATE (1ull<<19)
-#define IB_PR_COMPMASK_PKTLIFETIMESELEC (1ull<<20)
-#define IB_PR_COMPMASK_PKTLIFETIME (1ull<<21)
-#define IB_PR_COMPMASK_PREFERENCE (1ull<<22)
-
-#define IB_PR_DEF_MASK (IB_PR_COMPMASK_DGID |\
- IB_PR_COMPMASK_SGID |\
- IB_PR_COMPMASK_NUMBPATH)
-
-int
-ib_path_query_via(const void *srcport, ibmad_gid_t srcgid, ibmad_gid_t destgid, ib_portid_t *sm_id, void *buf)
-{
- int npath;
- ib_sa_call_t sa = {0};
- uint8_t *p;
- int dlid;
-
- npath = 1; /* only MAD_METHOD_GET is supported */
- memset(&sa, 0, sizeof sa);
- sa.method = IB_MAD_METHOD_GET;
- sa.attrid = IB_SA_ATTR_PATHRECORD;
- sa.mask = IB_PR_DEF_MASK;
- sa.trid = mad_trid();
-
- memset(buf, 0, IB_SA_PR_RECSZ);
-
- mad_encode_field(buf, IB_SA_PR_NPATH_F, &npath);
- mad_encode_field(buf, IB_SA_PR_DGID_F, destgid);
- mad_encode_field(buf, IB_SA_PR_SGID_F, srcgid);
-
- if (srcport) {
- p = sa_rpc_call (srcport, buf, sm_id, &sa, 0);
- } else {
- p = safe_sa_call(buf, sm_id, &sa, 0);
- }
- if (!p) {
- IBWARN("sa call path_query failed");
- return -1;
- }
-
- mad_decode_field(p, IB_SA_PR_DLID_F, &dlid);
- return dlid;
-}
-int
-ib_path_query(ibmad_gid_t srcgid, ibmad_gid_t destgid, ib_portid_t *sm_id, void *buf)
-{
- return ib_path_query_via (NULL, srcgid, destgid, sm_id, buf);
-}
diff --git a/contrib/ofed/management/libibmad/src/serv.c b/contrib/ofed/management/libibmad/src/serv.c
deleted file mode 100644
index 9b20cb6..0000000
--- a/contrib/ofed/management/libibmad/src/serv.c
+++ /dev/null
@@ -1,183 +0,0 @@
-/*
- * Copyright (c) 2004,2005 Voltaire Inc. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- */
-
-#if HAVE_CONFIG_H
-# include <config.h>
-#endif /* HAVE_CONFIG_H */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <pthread.h>
-#include <sys/time.h>
-#include <string.h>
-#include <netinet/in.h>
-
-#include <infiniband/common.h>
-#include <infiniband/umad.h>
-#include <mad.h>
-
-#undef DEBUG
-#define DEBUG if (ibdebug) IBWARN
-
-int
-mad_send(ib_rpc_t *rpc, ib_portid_t *dport, ib_rmpp_hdr_t *rmpp, void *data)
-{
- uint8_t pktbuf[1024];
- void *umad = pktbuf;
-
- memset(pktbuf, 0, umad_size());
-
- DEBUG("rmpp %p data %p", rmpp, data);
-
- if (mad_build_pkt(umad, rpc, dport, rmpp, data) < 0)
- return 0;
-
- if (ibdebug) {
- IBWARN("data offs %d sz %d", rpc->dataoffs, rpc->datasz);
- xdump(stderr, "mad send data\n",
- (char *)umad_get_mad(umad) + rpc->dataoffs, rpc->datasz);
- }
-
- if (umad_send(madrpc_portid(), mad_class_agent(rpc->mgtclass),
- umad, IB_MAD_SIZE, rpc->timeout, 0) < 0) {
- IBWARN("send failed; %m");
- return -1;
- }
-
- return 0;
-}
-
-int
-mad_respond(void *umad, ib_portid_t *portid, uint32_t rstatus)
-{
- uint8_t *mad = umad_get_mad(umad);
- ib_mad_addr_t *mad_addr;
- ib_rpc_t rpc = {0};
- ib_portid_t rport;
- int is_smi;
-
- if (!portid) {
- if (!(mad_addr = umad_get_mad_addr(umad)))
- return -1;
-
- memset(&rport, 0, sizeof(rport));
-
- rport.lid = ntohs(mad_addr->lid);
- rport.qp = ntohl(mad_addr->qpn);
- rport.qkey = ntohl(mad_addr->qkey);
- rport.sl = mad_addr->sl;
-
- portid = &rport;
- }
-
- DEBUG("dest %s", portid2str(portid));
-
- rpc.mgtclass = mad_get_field(mad, 0, IB_MAD_MGMTCLASS_F);
-
- rpc.method = mad_get_field(mad, 0, IB_MAD_METHOD_F);
- if (rpc.method == IB_MAD_METHOD_SET)
- rpc.method = IB_MAD_METHOD_GET;
- if (rpc.method != IB_MAD_METHOD_SEND)
- rpc.method |= IB_MAD_RESPONSE;
-
- rpc.attr.id = mad_get_field(mad, 0, IB_MAD_ATTRID_F);
- rpc.attr.mod = mad_get_field(mad, 0, IB_MAD_ATTRMOD_F);
- if (rpc.mgtclass == IB_SA_CLASS)
- rpc.recsz = mad_get_field(mad, 0, IB_SA_ATTROFFS_F);
- if (mad_is_vendor_range2(rpc.mgtclass))
- rpc.oui = mad_get_field(mad, 0, IB_VEND2_OUI_F);
-
- rpc.trid = mad_get_field64(mad, 0, IB_MAD_TRID_F);
-
- /* cleared by default: timeout, datasz, dataoffs, mkey, mask */
-
- is_smi = rpc.mgtclass == IB_SMI_CLASS ||
- rpc.mgtclass == IB_SMI_DIRECT_CLASS;
-
- if (is_smi)
- portid->qp = 0;
- else if (!portid->qp)
- portid->qp = 1;
-
- if (!portid->qkey && portid->qp == 1)
- portid->qkey = IB_DEFAULT_QP1_QKEY;
-
- DEBUG("qp 0x%x class 0x%x method %d attr 0x%x mod 0x%x datasz %d off %d qkey %x",
- portid->qp, rpc.mgtclass, rpc.method, rpc.attr.id, rpc.attr.mod,
- rpc.datasz, rpc.dataoffs, portid->qkey);
-
- if (mad_build_pkt(umad, &rpc, portid, 0, 0) < 0)
- return -1;
-
- if (ibdebug > 1)
- xdump(stderr, "mad respond pkt\n", mad, IB_MAD_SIZE);
-
- if (umad_send(madrpc_portid(), mad_class_agent(rpc.mgtclass), umad,
- IB_MAD_SIZE, rpc.timeout, 0) < 0) {
- DEBUG("send failed; %m");
- return -1;
- }
-
- return 0;
-}
-
-void *
-mad_receive(void *umad, int timeout)
-{
- void *mad = umad ? umad : umad_alloc(1, umad_size() + IB_MAD_SIZE);
- int agent;
- int length = IB_MAD_SIZE;
-
- if ((agent = umad_recv(madrpc_portid(), mad,
- &length, timeout)) < 0) {
- if (!umad)
- umad_free(mad);
- DEBUG("recv failed: %m");
- return 0;
- }
-
- return mad;
-}
-
-void *
-mad_alloc(void)
-{
- return umad_alloc(1, umad_size() + IB_MAD_SIZE);
-}
-
-void
-mad_free(void *umad)
-{
- umad_free(umad);
-}
diff --git a/contrib/ofed/management/libibmad/src/smp.c b/contrib/ofed/management/libibmad/src/smp.c
deleted file mode 100644
index 2c2bde2..0000000
--- a/contrib/ofed/management/libibmad/src/smp.c
+++ /dev/null
@@ -1,123 +0,0 @@
-/*
- * Copyright (c) 2004-2007 Voltaire Inc. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- */
-
-#if HAVE_CONFIG_H
-# include <config.h>
-#endif /* HAVE_CONFIG_H */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <string.h>
-#include <pthread.h>
-#include <sys/time.h>
-
-#include <mad.h>
-#include <infiniband/common.h>
-
-#undef DEBUG
-#define DEBUG if (ibdebug) IBWARN
-
-uint8_t *
-smp_set_via(void *data, ib_portid_t *portid, unsigned attrid, unsigned mod, unsigned timeout, const void *srcport)
-{
- ib_rpc_t rpc = {0};
-
- DEBUG("attr 0x%x mod 0x%x route %s", attrid, mod, portid2str(portid));
- if ((portid->lid <= 0) ||
- (portid->drpath.drslid == 0xffff) ||
- (portid->drpath.drdlid == 0xffff))
- rpc.mgtclass = IB_SMI_DIRECT_CLASS; /* direct SMI */
- else
- rpc.mgtclass = IB_SMI_CLASS; /* Lid routed SMI */
-
- rpc.method = IB_MAD_METHOD_SET;
- rpc.attr.id = attrid;
- rpc.attr.mod = mod;
- rpc.timeout = timeout;
- rpc.datasz = IB_SMP_DATA_SIZE;
- rpc.dataoffs = IB_SMP_DATA_OFFS;
-
- portid->sl = 0;
- portid->qp = 0;
-
- if (srcport) {
- return mad_rpc(srcport, &rpc, portid, data, data);
- } else {
- return madrpc(&rpc, portid, data, data);
- }
-}
-
-uint8_t *
-smp_set(void *data, ib_portid_t *portid, unsigned attrid, unsigned mod, unsigned timeout)
-{
- return smp_set_via(data, portid, attrid, mod, timeout, NULL);
-}
-
-uint8_t *
-smp_query_via(void *rcvbuf, ib_portid_t *portid, unsigned attrid, unsigned mod,
- unsigned timeout, const void *srcport)
-{
- ib_rpc_t rpc = {0};
-
- DEBUG("attr 0x%x mod 0x%x route %s", attrid, mod, portid2str(portid));
- rpc.method = IB_MAD_METHOD_GET;
- rpc.attr.id = attrid;
- rpc.attr.mod = mod;
- rpc.timeout = timeout;
- rpc.datasz = IB_SMP_DATA_SIZE;
- rpc.dataoffs = IB_SMP_DATA_OFFS;
-
- if ((portid->lid <= 0) ||
- (portid->drpath.drslid == 0xffff) ||
- (portid->drpath.drdlid == 0xffff))
- rpc.mgtclass = IB_SMI_DIRECT_CLASS; /* direct SMI */
- else
- rpc.mgtclass = IB_SMI_CLASS; /* Lid routed SMI */
-
- portid->sl = 0;
- portid->qp = 0;
-
- if (srcport) {
- return mad_rpc(srcport, &rpc, portid, 0, rcvbuf);
- } else {
- return madrpc(&rpc, portid, 0, rcvbuf);
- }
-}
-
-uint8_t *
-smp_query(void *rcvbuf, ib_portid_t *portid, unsigned attrid, unsigned mod,
- unsigned timeout)
-{
- return smp_query_via(rcvbuf, portid, attrid, mod, timeout, NULL);
-}
diff --git a/contrib/ofed/management/libibmad/src/vendor.c b/contrib/ofed/management/libibmad/src/vendor.c
deleted file mode 100644
index 468e2d3..0000000
--- a/contrib/ofed/management/libibmad/src/vendor.c
+++ /dev/null
@@ -1,99 +0,0 @@
-/*
- * Copyright (c) 2004,2005 Voltaire Inc. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- */
-
-#if HAVE_CONFIG_H
-# include <config.h>
-#endif /* HAVE_CONFIG_H */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <string.h>
-#include <pthread.h>
-#include <sys/time.h>
-
-#include <mad.h>
-#include <infiniband/common.h>
-
-#undef DEBUG
-#define DEBUG if (ibdebug) IBWARN
-
-static inline int
-response_expected(int method)
-{
- return method == IB_MAD_METHOD_GET ||
- method == IB_MAD_METHOD_SET ||
- method == IB_MAD_METHOD_TRAP;
-}
-
-uint8_t *
-ib_vendor_call(void *data, ib_portid_t *portid, ib_vendor_call_t *call)
-{
- ib_rpc_t rpc = {0};
- int range1 = 0, resp_expected;
-
- DEBUG("route %s data %p", portid2str(portid), data);
- if (portid->lid <= 0)
- return 0; /* no direct SMI */
-
- if (!(range1 = mad_is_vendor_range1(call->mgmt_class)) &&
- !(mad_is_vendor_range2(call->mgmt_class)))
- return 0;
-
- resp_expected = response_expected(call->method);
-
- rpc.mgtclass = call->mgmt_class;
-
- rpc.method = call->method;
- rpc.attr.id = call->attrid;
- rpc.attr.mod = call->mod;
- rpc.timeout = resp_expected ? call->timeout : 0;
- rpc.datasz = range1 ? IB_VENDOR_RANGE1_DATA_SIZE : IB_VENDOR_RANGE2_DATA_SIZE;
- rpc.dataoffs = range1 ? IB_VENDOR_RANGE1_DATA_OFFS : IB_VENDOR_RANGE2_DATA_OFFS;
-
- if (!range1)
- rpc.oui = call->oui;
-
- DEBUG("class 0x%x method 0x%x attr 0x%x mod 0x%x datasz %d off %d res_ex %d",
- rpc.mgtclass, rpc.method, rpc.attr.id, rpc.attr.mod,
- rpc.datasz, rpc.dataoffs, resp_expected);
-
- portid->qp = 1;
- if (!portid->qkey)
- portid->qkey = IB_DEFAULT_QP1_QKEY;
-
- if (resp_expected)
- return madrpc_rmpp(&rpc, portid, 0, data); /* FIXME: no RMPP for now */
-
- return mad_send(&rpc, portid, 0, data) < 0 ? 0 : data; /* FIXME: no RMPP for now */
-}
diff --git a/contrib/ofed/management/libibumad/AUTHORS b/contrib/ofed/management/libibumad/AUTHORS
deleted file mode 100644
index d09c13f..0000000
--- a/contrib/ofed/management/libibumad/AUTHORS
+++ /dev/null
@@ -1,3 +0,0 @@
-Shahar Frank <shahar@voltaire.com>
-Hal Rosenstock <halr@voltaire.com>
-Sasha Khapyorsky <sashak@voltaire.com>
diff --git a/contrib/ofed/management/libibumad/COPYING b/contrib/ofed/management/libibumad/COPYING
deleted file mode 100644
index 1b1ca1d..0000000
--- a/contrib/ofed/management/libibumad/COPYING
+++ /dev/null
@@ -1,384 +0,0 @@
-This software with the exception of OpenSM is available to you
-under a choice of one of two licenses. You may chose to be
-licensed under the terms of the the OpenIB.org BSD license or
-the GNU General Public License (GPL) Version 2, both included
-below.
-
-OpenSM is licensed under either GNU General Public License (GPL)
-Version 2, or Intel BSD + Patent license. See OpenSM for the
-specific language for the latter licensing terms.
-
-
-Copyright (c) 2004-2008 Voltaire, Inc. All rights reserved.
-
-==================================================================
-
- OpenIB.org BSD license
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions
-are met:
-
- * Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
-
- * Redistributions in binary form must reproduce the above
- copyright notice, this list of conditions and the following
- disclaimer in the documentation and/or other materials provided
- with the distribution.
-
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
-FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
-COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
-INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
-BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
-LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
-CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
-ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-POSSIBILITY OF SUCH DAMAGE.
-
-==================================================================
-
- GNU GENERAL PUBLIC LICENSE
- Version 2, June 1991
-
- Copyright (C) 1989, 1991 Free Software Foundation, Inc.
- 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- Everyone is permitted to copy and distribute verbatim copies
- of this license document, but changing it is not allowed.
-
- Preamble
-
- The licenses for most software are designed to take away your
-freedom to share and change it. By contrast, the GNU General Public
-License is intended to guarantee your freedom to share and change free
-software--to make sure the software is free for all its users. This
-General Public License applies to most of the Free Software
-Foundation's software and to any other program whose authors commit to
-using it. (Some other Free Software Foundation software is covered by
-the GNU Library General Public License instead.) You can apply it to
-your programs, too.
-
- When we speak of free software, we are referring to freedom, not
-price. Our General Public Licenses are designed to make sure that you
-have the freedom to distribute copies of free software (and charge for
-this service if you wish), that you receive source code or can get it
-if you want it, that you can change the software or use pieces of it
-in new free programs; and that you know you can do these things.
-
- To protect your rights, we need to make restrictions that forbid
-anyone to deny you these rights or to ask you to surrender the rights.
-These restrictions translate to certain responsibilities for you if you
-distribute copies of the software, or if you modify it.
-
- For example, if you distribute copies of such a program, whether
-gratis or for a fee, you must give the recipients all the rights that
-you have. You must make sure that they, too, receive or can get the
-source code. And you must show them these terms so they know their
-rights.
-
- We protect your rights with two steps: (1) copyright the software, and
-(2) offer you this license which gives you legal permission to copy,
-distribute and/or modify the software.
-
- Also, for each author's protection and ours, we want to make certain
-that everyone understands that there is no warranty for this free
-software. If the software is modified by someone else and passed on, we
-want its recipients to know that what they have is not the original, so
-that any problems introduced by others will not reflect on the original
-authors' reputations.
-
- Finally, any free program is threatened constantly by software
-patents. We wish to avoid the danger that redistributors of a free
-program will individually obtain patent licenses, in effect making the
-program proprietary. To prevent this, we have made it clear that any
-patent must be licensed for everyone's free use or not licensed at all.
-
- The precise terms and conditions for copying, distribution and
-modification follow.
-
- GNU GENERAL PUBLIC LICENSE
- TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
-
- 0. This License applies to any program or other work which contains
-a notice placed by the copyright holder saying it may be distributed
-under the terms of this General Public License. The "Program", below,
-refers to any such program or work, and a "work based on the Program"
-means either the Program or any derivative work under copyright law:
-that is to say, a work containing the Program or a portion of it,
-either verbatim or with modifications and/or translated into another
-language. (Hereinafter, translation is included without limitation in
-the term "modification".) Each licensee is addressed as "you".
-
-Activities other than copying, distribution and modification are not
-covered by this License; they are outside its scope. The act of
-running the Program is not restricted, and the output from the Program
-is covered only if its contents constitute a work based on the
-Program (independent of having been made by running the Program).
-Whether that is true depends on what the Program does.
-
- 1. You may copy and distribute verbatim copies of the Program's
-source code as you receive it, in any medium, provided that you
-conspicuously and appropriately publish on each copy an appropriate
-copyright notice and disclaimer of warranty; keep intact all the
-notices that refer to this License and to the absence of any warranty;
-and give any other recipients of the Program a copy of this License
-along with the Program.
-
-You may charge a fee for the physical act of transferring a copy, and
-you may at your option offer warranty protection in exchange for a fee.
-
- 2. You may modify your copy or copies of the Program or any portion
-of it, thus forming a work based on the Program, and copy and
-distribute such modifications or work under the terms of Section 1
-above, provided that you also meet all of these conditions:
-
- a) You must cause the modified files to carry prominent notices
- stating that you changed the files and the date of any change.
-
- b) You must cause any work that you distribute or publish, that in
- whole or in part contains or is derived from the Program or any
- part thereof, to be licensed as a whole at no charge to all third
- parties under the terms of this License.
-
- c) If the modified program normally reads commands interactively
- when run, you must cause it, when started running for such
- interactive use in the most ordinary way, to print or display an
- announcement including an appropriate copyright notice and a
- notice that there is no warranty (or else, saying that you provide
- a warranty) and that users may redistribute the program under
- these conditions, and telling the user how to view a copy of this
- License. (Exception: if the Program itself is interactive but
- does not normally print such an announcement, your work based on
- the Program is not required to print an announcement.)
-
-These requirements apply to the modified work as a whole. If
-identifiable sections of that work are not derived from the Program,
-and can be reasonably considered independent and separate works in
-themselves, then this License, and its terms, do not apply to those
-sections when you distribute them as separate works. But when you
-distribute the same sections as part of a whole which is a work based
-on the Program, the distribution of the whole must be on the terms of
-this License, whose permissions for other licensees extend to the
-entire whole, and thus to each and every part regardless of who wrote it.
-
-Thus, it is not the intent of this section to claim rights or contest
-your rights to work written entirely by you; rather, the intent is to
-exercise the right to control the distribution of derivative or
-collective works based on the Program.
-
-In addition, mere aggregation of another work not based on the Program
-with the Program (or with a work based on the Program) on a volume of
-a storage or distribution medium does not bring the other work under
-the scope of this License.
-
- 3. You may copy and distribute the Program (or a work based on it,
-under Section 2) in object code or executable form under the terms of
-Sections 1 and 2 above provided that you also do one of the following:
-
- a) Accompany it with the complete corresponding machine-readable
- source code, which must be distributed under the terms of Sections
- 1 and 2 above on a medium customarily used for software interchange; or,
-
- b) Accompany it with a written offer, valid for at least three
- years, to give any third party, for a charge no more than your
- cost of physically performing source distribution, a complete
- machine-readable copy of the corresponding source code, to be
- distributed under the terms of Sections 1 and 2 above on a medium
- customarily used for software interchange; or,
-
- c) Accompany it with the information you received as to the offer
- to distribute corresponding source code. (This alternative is
- allowed only for noncommercial distribution and only if you
- received the program in object code or executable form with such
- an offer, in accord with Subsection b above.)
-
-The source code for a work means the preferred form of the work for
-making modifications to it. For an executable work, complete source
-code means all the source code for all modules it contains, plus any
-associated interface definition files, plus the scripts used to
-control compilation and installation of the executable. However, as a
-special exception, the source code distributed need not include
-anything that is normally distributed (in either source or binary
-form) with the major components (compiler, kernel, and so on) of the
-operating system on which the executable runs, unless that component
-itself accompanies the executable.
-
-If distribution of executable or object code is made by offering
-access to copy from a designated place, then offering equivalent
-access to copy the source code from the same place counts as
-distribution of the source code, even though third parties are not
-compelled to copy the source along with the object code.
-
- 4. You may not copy, modify, sublicense, or distribute the Program
-except as expressly provided under this License. Any attempt
-otherwise to copy, modify, sublicense or distribute the Program is
-void, and will automatically terminate your rights under this License.
-However, parties who have received copies, or rights, from you under
-this License will not have their licenses terminated so long as such
-parties remain in full compliance.
-
- 5. You are not required to accept this License, since you have not
-signed it. However, nothing else grants you permission to modify or
-distribute the Program or its derivative works. These actions are
-prohibited by law if you do not accept this License. Therefore, by
-modifying or distributing the Program (or any work based on the
-Program), you indicate your acceptance of this License to do so, and
-all its terms and conditions for copying, distributing or modifying
-the Program or works based on it.
-
- 6. Each time you redistribute the Program (or any work based on the
-Program), the recipient automatically receives a license from the
-original licensor to copy, distribute or modify the Program subject to
-these terms and conditions. You may not impose any further
-restrictions on the recipients' exercise of the rights granted herein.
-You are not responsible for enforcing compliance by third parties to
-this License.
-
- 7. If, as a consequence of a court judgment or allegation of patent
-infringement or for any other reason (not limited to patent issues),
-conditions are imposed on you (whether by court order, agreement or
-otherwise) that contradict the conditions of this License, they do not
-excuse you from the conditions of this License. If you cannot
-distribute so as to satisfy simultaneously your obligations under this
-License and any other pertinent obligations, then as a consequence you
-may not distribute the Program at all. For example, if a patent
-license would not permit royalty-free redistribution of the Program by
-all those who receive copies directly or indirectly through you, then
-the only way you could satisfy both it and this License would be to
-refrain entirely from distribution of the Program.
-
-If any portion of this section is held invalid or unenforceable under
-any particular circumstance, the balance of the section is intended to
-apply and the section as a whole is intended to apply in other
-circumstances.
-
-It is not the purpose of this section to induce you to infringe any
-patents or other property right claims or to contest validity of any
-such claims; this section has the sole purpose of protecting the
-integrity of the free software distribution system, which is
-implemented by public license practices. Many people have made
-generous contributions to the wide range of software distributed
-through that system in reliance on consistent application of that
-system; it is up to the author/donor to decide if he or she is willing
-to distribute software through any other system and a licensee cannot
-impose that choice.
-
-This section is intended to make thoroughly clear what is believed to
-be a consequence of the rest of this License.
-
- 8. If the distribution and/or use of the Program is restricted in
-certain countries either by patents or by copyrighted interfaces, the
-original copyright holder who places the Program under this License
-may add an explicit geographical distribution limitation excluding
-those countries, so that distribution is permitted only in or among
-countries not thus excluded. In such case, this License incorporates
-the limitation as if written in the body of this License.
-
- 9. The Free Software Foundation may publish revised and/or new versions
-of the General Public License from time to time. Such new versions will
-be similar in spirit to the present version, but may differ in detail to
-address new problems or concerns.
-
-Each version is given a distinguishing version number. If the Program
-specifies a version number of this License which applies to it and "any
-later version", you have the option of following the terms and conditions
-either of that version or of any later version published by the Free
-Software Foundation. If the Program does not specify a version number of
-this License, you may choose any version ever published by the Free Software
-Foundation.
-
- 10. If you wish to incorporate parts of the Program into other free
-programs whose distribution conditions are different, write to the author
-to ask for permission. For software which is copyrighted by the Free
-Software Foundation, write to the Free Software Foundation; we sometimes
-make exceptions for this. Our decision will be guided by the two goals
-of preserving the free status of all derivatives of our free software and
-of promoting the sharing and reuse of software generally.
-
- NO WARRANTY
-
- 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
-FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
-OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
-PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
-OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
-MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
-TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
-PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
-REPAIR OR CORRECTION.
-
- 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
-WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
-REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
-INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
-OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
-TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
-YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
-PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
-POSSIBILITY OF SUCH DAMAGES.
-
- END OF TERMS AND CONDITIONS
-
- How to Apply These Terms to Your New Programs
-
- If you develop a new program, and you want it to be of the greatest
-possible use to the public, the best way to achieve this is to make it
-free software which everyone can redistribute and change under these terms.
-
- To do so, attach the following notices to the program. It is safest
-to attach them to the start of each source file to most effectively
-convey the exclusion of warranty; and each file should have at least
-the "copyright" line and a pointer to where the full notice is found.
-
- <one line to give the program's name and a brief idea of what it does.>
- Copyright (C) <year> <name of author>
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program 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 this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-
-Also add information on how to contact you by electronic and paper mail.
-
-If the program is interactive, make it output a short notice like this
-when it starts in an interactive mode:
-
- Gnomovision version 69, Copyright (C) year name of author
- Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
- This is free software, and you are welcome to redistribute it
- under certain conditions; type `show c' for details.
-
-The hypothetical commands `show w' and `show c' should show the appropriate
-parts of the General Public License. Of course, the commands you use may
-be called something other than `show w' and `show c'; they could even be
-mouse-clicks or menu items--whatever suits your program.
-
-You should also get your employer (if you work as a programmer) or your
-school, if any, to sign a "copyright disclaimer" for the program, if
-necessary. Here is a sample; alter the names:
-
- Yoyodyne, Inc., hereby disclaims all copyright interest in the program
- `Gnomovision' (which makes passes at compilers) written by James Hacker.
-
- <signature of Ty Coon>, 1 April 1989
- Ty Coon, President of Vice
-
-This General Public License does not permit incorporating your program into
-proprietary programs. If your program is a subroutine library, you may
-consider it more useful to permit linking proprietary applications with the
-library. If this is what you want to do, use the GNU Library General
-Public License instead of this License.
diff --git a/contrib/ofed/management/libibumad/ChangeLog b/contrib/ofed/management/libibumad/ChangeLog
deleted file mode 100644
index f394ef8..0000000
--- a/contrib/ofed/management/libibumad/ChangeLog
+++ /dev/null
@@ -1,94 +0,0 @@
-2007-07-10 Hal Rosenstock <halr@voltaire.com>
-
- * Release version 1.1.2
-
- * Makefile.am: Add man/umad_set_pkey.3 into install
-
- * man/umad_set_pkey.3: Clarify that umad_set_pkey takes
- pkey_index rather than pkey
-
-2007-07-10 Sean Hefty <sean.hefty@intel.com>
-
- * include/infiniband/umad.h: Clarify that umad_set_pkey()
- takes a pkey index, and not the pkey itself
-
-2007-06-26 Hal Rosenstock <halr@voltaire.com>
-
- * src/umad.c: Change uint to unsigned for strict ANSI
-
-2007-06-26 Michael S. Tsirkin <mst@dev.mellanox.co.il>
-
- * include/infiniband/umad.h: Change uint to unsigned
- for strict ANSI
-
-2007-05-24 Hal Rosenstock <halr@voltaire.com>
-
- * man/umad_set_grh.3, man/umad_set_grh_net.3: Some more
- changes based on comments from Dotan Barak
-
-2007-05-23 Ira K. Weiny <weiny2@llnl.gov>
-
- * libibumad.spec.in: Add man pages
-
-2007-05-21 Hal Rosenstock <halr@voltaire.com>
-
- * man/umad_set_addr.3, man/umad_set_addr_net.3,
- man/umad_set_grh.3, man/umad_set_grh_net.3:
- Add "SEE ALSO" section
-
- * man: More changes based on additional comments from Dotan Barak
-
-2007-05-17 Hal Rosenstock <halr@voltaire.com>
-
- * Makefile.am: No longer install man/umad_set_pkey.3
-
- * man: Man page updates based on comments from Dotan Barak
-
-2007-05-11 Hal Rosenstock <halr@voltaire.com>
-
- * Release version 1.1.1.
-
- * Makefile.am: Added man pages support
-
- * man: Add initial version of libibumad man pages
-
-2007-04-24 Roland Dreier <rolandd@cisco.com>
-
- * src/umad.c: In umad_open_port, fix declaration of
- return value from dev_to_umad_id
-
-2007-04-24 Hal Rosenstock <halr@voltaire.com>
-
- * src/umad,c: In get_ca, handle drivers which do not
- support SYS_CA_HW_VERS or SYS_CA_TYPE
-
-2007-03-29 Hal Rosenstock <halr@voltaire.com>
-
- * Release version 1.1.0.
-
-2007-03-22 Hal Rosenstock <halr@voltaire.com>
-
- * src/umad.c: Implement GRH support in umad_set_grh
-
-2007-03-11 Dotan Barak <dotanb@mellanox.co.il>
-
- * src/umad.c: In umad_get_ca_portguids, add release_ca call
- in error flow to prevent resource leak
-
-2007-01-25 Hal Rosenstock <halr@voltaire.com>
-
- * Release version 1.0.2.
-
-2006-11-20 Sasha Khapyorsky <sashak@voltaire.com>
-
- * src/umad.c: Fix various uses of printf() style functions
-
-2006-10-31 Sasha Khapyorsky <sashak@voltaire.com>
-
- * src/umad.c (umad_set_addr_net): Fix endian used in
- TRACE macro
-
-2006-09-28 Sasha Khapyorsky <sashak@voltaire.com>
-
- * src/umad.c (umad_open_port): Show open()'s errno string
-
diff --git a/contrib/ofed/management/libibumad/Makefile.am b/contrib/ofed/management/libibumad/Makefile.am
deleted file mode 100644
index 1e3e6fd..0000000
--- a/contrib/ofed/management/libibumad/Makefile.am
+++ /dev/null
@@ -1,56 +0,0 @@
-
-SUBDIRS = .
-
-INCLUDES = -I$(srcdir)/include/infiniband -I$(includedir)
-
-man_MANS = man/umad_debug.3 man/umad_get_ca.3 \
- man/umad_get_ca_portguids.3 man/umad_get_cas_names.3 \
- man/umad_get_mad.3 man/umad_get_port.3 man/umad_init.3 \
- man/umad_open_port.3 man/umad_close_port.3 man/umad_size.3 \
- man/umad_status.3 man/umad_alloc.3 man/umad_free.3 \
- man/umad_dump.3 man/umad_addr_dump.3 man/umad_get_fd.3 \
- man/umad_get_mad.3 man/umad_get_mad_addr.3 \
- man/umad_set_grh_net.3 man/umad_set_grh.3 \
- man/umad_set_addr_net.3 man/umad_set_addr.3 man/umad_set_pkey.3 \
- man/umad_get_pkey.3 \
- man/umad_register.3 man/umad_register_oui.3 man/umad_unregister.3 \
- man/umad_send.3 man/umad_recv.3 man/umad_poll.3 \
- man/umad_get_issm_path.3
-
-lib_LTLIBRARIES = libibumad.la
-
-libibumad_la_CFLAGS = -Wall
-
-if HAVE_LD_VERSION_SCRIPT
-libibumad_version_script = -Wl,--version-script=$(srcdir)/src/libibumad.map
-else
-libibumad_version_script =
-endif
-
-libibumad_la_SOURCES = src/umad.c
-libibumad_la_LDFLAGS = -version-info $(ibumad_api_version) \
- -export-dynamic $(libibumad_version_script)
-libibumad_la_DEPENDENCIES = $(srcdir)/src/libibumad.map
-
-libibumadincludedir = $(includedir)/infiniband
-
-libibumadinclude_HEADERS = $(srcdir)/include/infiniband/umad.h
-
-EXTRA_DIST = $(srcdir)/include/infiniband/umad.h \
- libibumad.spec.in libibumad.spec \
- $(srcdir)/src/libibumad.map libibumad.ver \
- $(man_MANS) autogen.sh
-
-dist-hook:
- if [ -x $(top_srcdir)/../gen_chlog.sh ] ; then \
- $(top_srcdir)/../gen_chlog.sh $(PACKAGE) > $(distdir)/ChangeLog ; \
- fi
-
-install-data-hook:
- cd $(DESTDIR)$(mandir)/man3 && \
- $(RM) umad_done.3 && \
- $(RM) umad_release_ca.3 && \
- $(RM) umad_release_port.3 && \
- $(LN_S) umad_init.3 umad_done.3 && \
- $(LN_S) umad_get_ca.3 umad_release_ca.3 && \
- $(LN_S) umad_get_port.3 umad_release_port.3
diff --git a/contrib/ofed/management/libibumad/autogen.sh b/contrib/ofed/management/libibumad/autogen.sh
deleted file mode 100755
index 4827884..0000000
--- a/contrib/ofed/management/libibumad/autogen.sh
+++ /dev/null
@@ -1,11 +0,0 @@
-#! /bin/sh
-
-# create config dir if not exist
-test -d config || mkdir config
-
-set -x
-aclocal -I config
-libtoolize --force --copy
-autoheader
-automake --foreign --add-missing --copy
-autoconf
diff --git a/contrib/ofed/management/libibumad/configure.in b/contrib/ofed/management/libibumad/configure.in
deleted file mode 100644
index ad3afcd..0000000
--- a/contrib/ofed/management/libibumad/configure.in
+++ /dev/null
@@ -1,90 +0,0 @@
-dnl Process this file with autoconf to produce a configure script.
-
-AC_PREREQ(2.57)
-AC_INIT(libibumad, 1.3.0, general@lists.openfabrics.org)
-AC_CONFIG_SRCDIR([src/umad.c])
-AC_CONFIG_AUX_DIR(config)
-AM_CONFIG_HEADER(config.h)
-AM_INIT_AUTOMAKE
-
-AC_SUBST(RELEASE, ${RELEASE:-unknown})
-AC_SUBST(TARBALL, ${TARBALL:-${PACKAGE}-${VERSION}.tar.gz})
-
-dnl the library version info is available in the file: libibumad.ver
-ibumad_api_version=`grep LIBVERSION $srcdir/libibumad.ver | sed 's/LIBVERSION=//'`
-if test -z $ibumad_api_version; then
- ibumad_api_version=1:0:0
-fi
-AC_SUBST(ibumad_api_version)
-
-AC_ARG_ENABLE(libcheck, [ --disable-libcheck do not test for presence of ib libraries],
-[ if test x$enableval = xno ; then
- disable_libcheck=yes
- fi
-])
-
-AC_ARG_WITH([valgrind],
- AC_HELP_STRING([--with-valgrind],
- [Enable Valgrind annotations (small runtime overhead, default NO)]))
-if test x$with_valgrind = x || test x$with_valgrind = xno; then
- want_valgrind=no
- AC_DEFINE([NVALGRIND], 1, [Define to 1 to disable Valgrind annotations.])
-else
- want_valgrind=yes
- if test -d $with_valgrind; then
- CPPFLAGS="$CPPFLAGS -I$with_valgrind/include"
- fi
-fi
-
-dnl Checks for programs
-AC_PROG_CC
-AC_PROG_CPP
-AC_PROG_INSTALL
-AC_PROG_LN_S
-AC_PROG_MAKE_SET
-AM_PROG_LIBTOOL
-
-if test "$disable_libcheck" != "yes"
-then
-dnl Checks for libraries
-AC_CHECK_LIB(ibcommon, sys_read_string, [],
- AC_MSG_ERROR([sys_read_string() not found. libibumad requires libibcommon.]))
-fi
-
-dnl Checks for header files.
-AC_HEADER_DIRENT
-AC_HEADER_STDC
-AC_CHECK_HEADERS([fcntl.h netinet/in.h stdlib.h string.h sys/ioctl.h unistd.h])
-if test "$disable_libcheck" != "yes"
-then
-AC_CHECK_HEADER(infiniband/common.h, [],
- AC_MSG_ERROR([<infiniband/common.h> not found. libibumad requires libibcommon.])
-)
-fi
-
-dnl Checks for library functions
-AC_PROG_GCC_TRADITIONAL
-AC_FUNC_MALLOC
-AC_CHECK_FUNCS([memset])
-
-dnl Checks for typedefs, structures, and compiler characteristics.
-AC_C_INLINE
-
-AC_CHECK_HEADER(valgrind/memcheck.h,
- [AC_DEFINE(HAVE_VALGRIND_MEMCHECK_H, 1,
- [Define to 1 if you have the <valgrind/memcheck.h> header file.])],
- [if test $want_valgrind = yes; then
- AC_MSG_ERROR([Valgrind memcheck support requested, but <valgrind/memcheck.h> not found.])
- fi])
-
-AC_CACHE_CHECK(whether ld accepts --version-script, ac_cv_version_script,
- if test -n "`$LD --help < /dev/null 2>/dev/null | grep version-script`"; then
- ac_cv_version_script=yes
- else
- ac_cv_version_script=no
- fi)
-
-AM_CONDITIONAL(HAVE_LD_VERSION_SCRIPT, test "$ac_cv_version_script" = "yes")
-
-AC_CONFIG_FILES([Makefile libibumad.spec])
-AC_OUTPUT
diff --git a/contrib/ofed/management/libibumad/include/infiniband/umad.h b/contrib/ofed/management/libibumad/include/infiniband/umad.h
deleted file mode 100644
index cc5bef5..0000000
--- a/contrib/ofed/management/libibumad/include/infiniband/umad.h
+++ /dev/null
@@ -1,211 +0,0 @@
-/*
- * Copyright (c) 2004-2008 Voltaire Inc. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- */
-#ifndef _UMAD_H
-#define _UMAD_H
-
-#include <stdint.h>
-#include <infiniband/common.h>
-
-#ifdef __cplusplus
-# define BEGIN_C_DECLS extern "C" {
-# define END_C_DECLS }
-#else /* !__cplusplus */
-# define BEGIN_C_DECLS
-# define END_C_DECLS
-#endif /* __cplusplus */
-
-BEGIN_C_DECLS
-
-#define UMAD_MAX_DEVICES 20
-#define UMAD_ANY_PORT 0
-
-typedef struct ib_mad_addr {
- uint32_t qpn;
- uint32_t qkey;
- uint16_t lid;
- uint8_t sl;
- uint8_t path_bits;
- uint8_t grh_present;
- uint8_t gid_index;
- uint8_t hop_limit;
- uint8_t traffic_class;
- uint8_t gid[16];
- uint32_t flow_label;
- uint16_t pkey_index;
- uint8_t reserved[6];
-} ib_mad_addr_t;
-
-typedef struct ib_user_mad {
- uint32_t agent_id;
- uint32_t status;
- uint32_t timeout_ms;
- uint32_t retries;
- uint32_t length;
- ib_mad_addr_t addr;
- uint8_t data[0];
-} ib_user_mad_t;
-
-#define IB_UMAD_ABI_VERSION 5
-#define IB_UMAD_ABI_DIR "/sys/class/infiniband_mad"
-#define IB_UMAD_ABI_FILE "abi_version"
-
-#define IB_IOCTL_MAGIC 0x1b
-
-#define IB_USER_MAD_REGISTER_AGENT _IO(IB_IOCTL_MAGIC, 1)
-#define IB_USER_MAD_UNREGISTER_AGENT _IO(IB_IOCTL_MAGIC, 2)
-#define IB_USER_MAD_ENABLE_PKEY _IO(IB_IOCTL_MAGIC, 3)
-
-#define UMAD_CA_NAME_LEN 20
-#define UMAD_CA_MAX_PORTS 10 /* 0 - 9 */
-#define UMAD_CA_MAX_AGENTS 32
-
-#define SYS_INFINIBAND "/sys/class/infiniband"
-
-#define SYS_INFINIBAND_MAD "/sys/class/infiniband_mad"
-#define SYS_IB_MAD_PORT "port"
-#define SYS_IB_MAD_DEV "ibdev"
-
-#define UMAD_MAX_PORTS 64
-
-#define UMAD_DEV_DIR "/dev"
-
-#define SYS_CA_PORTS_DIR "ports"
-
-#define SYS_NODE_TYPE "node_type"
-#define SYS_CA_FW_VERS "fw_ver"
-#define SYS_CA_HW_VERS "hw_rev"
-#define SYS_CA_TYPE "hca_type"
-#define SYS_CA_NODE_GUID "node_guid"
-#define SYS_CA_SYS_GUID "sys_image_guid"
-
-#define SYS_PORT_LMC "lid_mask_count"
-#define SYS_PORT_SMLID "sm_lid"
-#define SYS_PORT_SMSL "sm_sl"
-#define SYS_PORT_LID "lid"
-#define SYS_PORT_STATE "state"
-#define SYS_PORT_PHY_STATE "phys_state"
-#define SYS_PORT_CAPMASK "cap_mask"
-#define SYS_PORT_RATE "rate"
-#define SYS_PORT_GUID "port_guid"
-#define SYS_PORT_GID "gids/0"
-
-typedef struct umad_port {
- char ca_name[UMAD_CA_NAME_LEN];
- int portnum;
- unsigned base_lid;
- unsigned lmc;
- unsigned sm_lid;
- unsigned sm_sl;
- unsigned state;
- unsigned phys_state;
- unsigned rate;
- uint64_t capmask;
- uint64_t gid_prefix;
- uint64_t port_guid;
- unsigned pkeys_size;
- uint16_t *pkeys;
-} umad_port_t;
-
-typedef struct umad_ca {
- char ca_name[UMAD_CA_NAME_LEN];
- unsigned node_type;
- int numports;
- char fw_ver[20];
- char ca_type[40];
- char hw_ver[20];
- uint64_t node_guid;
- uint64_t system_guid;
- umad_port_t *ports[UMAD_CA_MAX_PORTS];
-} umad_ca_t;
-
-int umad_init(void);
-int umad_done(void);
-
-int umad_get_cas_names(char cas[][UMAD_CA_NAME_LEN], int max);
-int umad_get_ca_portguids(char *ca_name, uint64_t *portguids, int max);
-
-int umad_get_ca(char *ca_name, umad_ca_t *ca);
-int umad_release_ca(umad_ca_t *ca);
-int umad_get_port(char *ca_name, int portnum, umad_port_t *port);
-int umad_release_port(umad_port_t *port);
-
-int umad_get_issm_path(char *ca_name, int portnum, char path[], int max);
-
-int umad_open_port(char *ca_name, int portnum);
-int umad_close_port(int portid);
-
-void * umad_get_mad(void *umad);
-size_t umad_size(void);
-int umad_status(void *umad);
-
-ib_mad_addr_t *umad_get_mad_addr(void *umad);
-int umad_set_grh_net(void *umad, void *mad_addr);
-int umad_set_grh(void *umad, void *mad_addr);
-int umad_set_addr_net(void *umad, int dlid, int dqp, int sl, int qkey);
-int umad_set_addr(void *umad, int dlid, int dqp, int sl, int qkey);
-int umad_set_pkey(void *umad, int pkey_index);
-int umad_get_pkey(void *umad);
-
-int umad_send(int portid, int agentid, void *umad, int length,
- int timeout_ms, int retries);
-int umad_recv(int portid, void *umad, int *length, int timeout_ms);
-int umad_poll(int portid, int timeout_ms);
-int umad_get_fd(int portid);
-
-int umad_register(int portid, int mgmt_class, int mgmt_version,
- uint8_t rmpp_version, long method_mask[16/sizeof(long)]);
-int umad_register_oui(int portid, int mgmt_class, uint8_t rmpp_version,
- uint8_t oui[3], long method_mask[16/sizeof(long)]);
-int umad_unregister(int portid, int agentid);
-
-int umad_debug(int level);
-void umad_addr_dump(ib_mad_addr_t *addr);
-void umad_dump(void *umad);
-
-#include <stdlib.h>
-
-static inline void *
-umad_alloc(int num, size_t size) /* alloc array of umad buffers */
-{
- return calloc(num, size);
-}
-
-static inline void
-umad_free(void *umad)
-{
- free(umad);
-}
-
-END_C_DECLS
-
-#endif /* _UMAD_H */
diff --git a/contrib/ofed/management/libibumad/libibumad.spec.in b/contrib/ofed/management/libibumad/libibumad.spec.in
deleted file mode 100644
index 1b11d18..0000000
--- a/contrib/ofed/management/libibumad/libibumad.spec.in
+++ /dev/null
@@ -1,74 +0,0 @@
-
-%define RELEASE @RELEASE@
-%define rel %{?CUSTOM_RELEASE} %{!?CUSTOM_RELEASE:%RELEASE}
-
-Summary: OpenFabrics Alliance InfiniBand umad (user MAD) library
-Name: libibumad
-Version: @VERSION@
-Release: %rel%{?dist}
-License: GPLv2 or BSD
-Group: System Environment/Libraries
-BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
-Source: http://www.openfabrics.org/downloads/management/@TARBALL@
-Url: http://openfabrics.org
-Requires(post): /sbin/ldconfig
-Requires(postun): /sbin/ldconfig
-BuildRequires: libibcommon-devel, libtool
-
-%description
-libibumad provides the user MAD library functions which sit on top of
-the user MAD modules in the kernel. These are used by the IB diagnostic
-and management tools, including OpenSM.
-
-%package devel
-Summary: Development files for the libibumad library
-Group: System Environment/Libraries
-Requires: %{name} = %{version}-%{release} libibcommon-devel
-Requires(post): /sbin/ldconfig
-Requires(postun): /sbin/ldconfig
-
-%description devel
-Development files for the libibumad library.
-
-%package static
-Summary: Static version of the libibumad library
-Group: System Environment/Libraries
-Requires: %{name} = %{version}-%{release}
-
-%description static
-Static version of the libibumad library.
-
-%prep
-%setup -q
-
-%build
-%configure
-make %{?_smp_mflags}
-
-%install
-make DESTDIR=${RPM_BUILD_ROOT} install
-# remove unpackaged files from the buildroot
-rm -f $RPM_BUILD_ROOT%{_libdir}/*.la
-
-%clean
-rm -rf $RPM_BUILD_ROOT
-
-%post -p /sbin/ldconfig
-%postun -p /sbin/ldconfig
-%post devel -p /sbin/ldconfig
-%postun devel -p /sbin/ldconfig
-
-%files
-%defattr(-,root,root)
-%{_libdir}/libibumad*.so.*
-%{_mandir}/man3/*
-%doc AUTHORS COPYING ChangeLog
-
-%files devel
-%defattr(-,root,root)
-%{_libdir}/libibumad.so
-%{_includedir}/infiniband/*.h
-
-%files static
-%defattr(-,root,root)
-%{_libdir}/libibumad.a
diff --git a/contrib/ofed/management/libibumad/libibumad.ver b/contrib/ofed/management/libibumad/libibumad.ver
deleted file mode 100644
index 21cf1ed..0000000
--- a/contrib/ofed/management/libibumad/libibumad.ver
+++ /dev/null
@@ -1,9 +0,0 @@
-# In this file we track the current API version
-# of the IB umad interface (and libraries)
-# The version is built of the following
-# tree numbers:
-# API_REV:RUNNING_REV:AGE
-# API_REV - advance on any added API
-# RUNNING_REV - advance any change to the vendor files
-# AGE - number of backward versions the API still supports
-LIBVERSION=1:3:0
diff --git a/contrib/ofed/management/libibumad/man/umad_addr_dump.3 b/contrib/ofed/management/libibumad/man/umad_addr_dump.3
deleted file mode 100644
index 7f09214..0000000
--- a/contrib/ofed/management/libibumad/man/umad_addr_dump.3
+++ /dev/null
@@ -1,45 +0,0 @@
-.\" -*- nroff -*-
-.\"
-.TH UMAD_ADDR_DUMP 3 "May 21, 2007" "OpenIB" "OpenIB Programmer\'s Manual"
-.SH "NAME"
-umad_addr_dump \- dump addr structure to stderr
-.SH "SYNOPSIS"
-.nf
-.B #include <infiniband/umad.h>
-.sp
-.BI "void umad_addr_dump(ib_mad_addr_t " "*addr");
-.fi
-.SH "DESCRIPTION"
-.B umad_addr_dump()
-dumps the given
-.I addr\fR
-to stderr.
-The argument
-.I addr
-is an
-.I ib_mad_addr_t
-struct, as specified in <infiniband/umad.h>.
-.PP
-.nf
-typedef struct ib_mad_addr {
-.in +8
-uint32_t qpn;
-uint32_t qkey;
-uint16_t lid;
-uint8_t sl;
-uint8_t path_bits;
-uint8_t grh_present;
-uint8_t gid_index;
-uint8_t hop_limit;
-uint8_t traffic_class;
-uint8_t gid[16];
-uint32_t flow_label;
-.in -8
-} ib_mad_addr_t;
-.fi
-.SH "RETURN VALUE"
-.B umad_addr_dump()
-returns no value.
-.SH "AUTHOR"
-.TP
-Hal Rosenstock <halr@voltaire.com>
diff --git a/contrib/ofed/management/libibumad/man/umad_alloc.3 b/contrib/ofed/management/libibumad/man/umad_alloc.3
deleted file mode 100644
index 5c65f3e..0000000
--- a/contrib/ofed/management/libibumad/man/umad_alloc.3
+++ /dev/null
@@ -1,33 +0,0 @@
-.\" -*- nroff -*-
-.\"
-.TH UMAD_ALLOC 3 "May 21, 2007" "OpenIB" "OpenIB Programmer\'s Manual"
-.SH "NAME"
-umad_alloc \- allocate memory for umad buffers
-.SH "SYNOPSIS"
-.nf
-.B #include <infiniband/umad.h>
-.sp
-.BI "void * umad_alloc(int " "num" ", size_t " "size");
-.fi
-.SH "DESCRIPTION"
-.B umad_alloc()
-allocates memory for an array of
-.I num\fR
-umad buffers of
-.I size
-bytes\fR.
-Note that
-.I size\fR
-should include the
-.B umad_size()
-plus the length (MAD_BLOCK_SIZE for normal MADs or the length returned from
-.B umad_recv()
-for RMPP MADs).
-.SH "RETURN VALUE"
-.B umad_alloc()
-returns NULL if out of memory.
-.SH "SEE ALSO"
-.BR umad_free (3)
-.SH "AUTHOR"
-.TP
-Hal Rosenstock <halr@voltaire.com>
diff --git a/contrib/ofed/management/libibumad/man/umad_close_port.3 b/contrib/ofed/management/libibumad/man/umad_close_port.3
deleted file mode 100644
index 2c56d90..0000000
--- a/contrib/ofed/management/libibumad/man/umad_close_port.3
+++ /dev/null
@@ -1,26 +0,0 @@
-.\" -*- nroff -*-
-.\"
-.TH UMAD_OPEN_PORT 3 "May 11, 2007" "OpenIB" "OpenIB Programmer\'s Manual"
-.SH "NAME"
-umad_close_port \- close InfiniBand device port for umad access
-.SH "SYNOPSIS"
-.nf
-.B #include <infiniband/umad.h>
-.sp
-.BI "int umad_close_port(int " "portid" );
-.fi
-.SH "DESCRIPTION"
-.B umad_close_port()
-closes the port specified by the handle
-.I portid\fR.
-.SH "RETURN VALUE"
-.B umad_close_port()
-returns 0 on success, and a negative value on error.
--EINVAL is returned if the
-.I portid\fR
-is not a handle to a valid (open) port.
-.SH "SEE ALSO"
-.BR umad_open_port (3)
-.SH "AUTHOR"
-.TP
-Hal Rosenstock <halr@voltaire.com>
diff --git a/contrib/ofed/management/libibumad/man/umad_debug.3 b/contrib/ofed/management/libibumad/man/umad_debug.3
deleted file mode 100644
index b7da2b0..0000000
--- a/contrib/ofed/management/libibumad/man/umad_debug.3
+++ /dev/null
@@ -1,29 +0,0 @@
-.\" -*- nroff -*-
-.\"
-.TH UMAD_DEBUG 3 "May 21, 2007" "OpenIB" "OpenIB Programmer\'s Manual"
-.SH "NAME"
-umad_debug \- set debug level
-.SH "SYNOPSIS"
-.nf
-.B #include <infiniband/umad.h>
-.sp
-.BI "int umad_debug(int " "level" );
-.fi
-.SH "DESCRIPTION"
-.B umad_debug()
-sets the umad library internal debug level to
-.I level\fR.
-The following
-debug levels are supported: 0 - no debug (the default),
-1 - basic debug information, 2 - verbose debug information. Negative values are
-ignored in terms of set. Note that the current debug level can
-be queried by passing a negative value as
-.I level\fR.
-.SH "RETURN VALUE"
-.B umad_debug()
-returns the actual debug level.
-.SH "AUTHORS"
-.TP
-Hal Rosenstock <halr@voltaire.com>
-.TP
-Dotan Barak <dotanb@mellanox.co.il>
diff --git a/contrib/ofed/management/libibumad/man/umad_dump.3 b/contrib/ofed/management/libibumad/man/umad_dump.3
deleted file mode 100644
index 101a2e0..0000000
--- a/contrib/ofed/management/libibumad/man/umad_dump.3
+++ /dev/null
@@ -1,22 +0,0 @@
-.\" -*- nroff -*-
-.\"
-.TH UMAD_DUMP 3 "May 17, 2007" "OpenIB" "OpenIB Programmer\'s Manual"
-.SH "NAME"
-umad_dump \- dump umad buffer to stderr
-.SH "SYNOPSIS"
-.nf
-.B #include <infiniband/umad.h>
-.sp
-.BI "void umad_dump(void " "*umad");
-.fi
-.SH "DESCRIPTION"
-.B umad_dump()
-dumps the given
-.I umad\fR
-buffer to stderr.
-.SH "RETURN VALUE"
-.B umad_dump()
-returns no value.
-.SH "AUTHOR"
-.TP
-Hal Rosenstock <halr@voltaire.com>
diff --git a/contrib/ofed/management/libibumad/man/umad_free.3 b/contrib/ofed/management/libibumad/man/umad_free.3
deleted file mode 100644
index ac39794..0000000
--- a/contrib/ofed/management/libibumad/man/umad_free.3
+++ /dev/null
@@ -1,23 +0,0 @@
-.\" -*- nroff -*-
-.\"
-.TH UMAD_FREE 3 "May 17, 2007" "OpenIB" "OpenIB Programmer\'s Manual"
-.SH "NAME"
-umad_free \- frees memory of umad buffers
-.SH "SYNOPSIS"
-.nf
-.B #include <infiniband/umad.h>
-.sp
-.BI "void umad_free(void " "*umad");
-.fi
-.SH "DESCRIPTION"
-.B umad_free()
-frees memory previously allocated with
-.B umad_alloc()\fR.
-.SH "RETURN VALUE"
-.B umad_free()
-returns no value.
-.SH "SEE ALSO"
-.BR umad_alloc (3)
-.SH "AUTHOR"
-.TP
-Hal Rosenstock <halr@voltaire.com>
diff --git a/contrib/ofed/management/libibumad/man/umad_get_ca.3 b/contrib/ofed/management/libibumad/man/umad_get_ca.3
deleted file mode 100644
index 2f5fd1a..0000000
--- a/contrib/ofed/management/libibumad/man/umad_get_ca.3
+++ /dev/null
@@ -1,65 +0,0 @@
-.\" -*- nroff -*-
-.\"
-.TH UMAD_GET_CA 3 "May 21, 2007" "OpenIB" "OpenIB Programmer\'s Manual"
-.SH "NAME"
-umad_get_ca, umad_release_ca \- get and release InfiniBand device port attributes
-.SH "SYNOPSIS"
-.nf
-.B #include <infiniband/umad.h>
-.sp
-.BI "int umad_get_ca(char " "*ca_name" ", umad_ca_t " "*ca" );
-.nl
-.BI "int umad_release_ca(umad_ca_t " "*ca" );
-.fi
-.SH "DESCRIPTION"
-.B umad_get_ca()
-gets the attributes of the InfiniBand device
-.I ca_name\fR.
-It fills
-the
-.I ca
-structure with the device attributes specified by
-the
-.I ca_name
-or with the default device attributes if
-.I ca_name
-is NULL.
-.B umad_release_ca()
-should be called before the
-.I ca
-structure is deallocated.
-The argument
-.I ca
-is an
-.I umad_ca_t
-struct, as specified in <infiniband/umad.h>.
-.PP
-.nf
-typedef struct umad_ca {
-.in +8
-char ca_name[UMAD_CA_NAME_LEN]; /* Name of the device */
-uint node_type; /* Type of the device */
-int numports; /* Number of physical ports */
-char fw_ver[20]; /* FW version */
-char ca_type[40]; /* CA type (e.g. MT23108, etc.) */
-char hw_ver[20]; /* Hardware version */
-uint64_t node_guid; /* Node GUID */
-uint64_t system_guid; /* System image GUID */
-umad_port_t *ports[UMAD_CA_MAX_PORTS]; /* Array of device port properties */
-.in -8
-} umad_ca_t;
-.fi
-.PP
-.B umad_release_ca()
-releases the resources that were allocated in the function
-.B umad_get_ca()\fR.
-.SH "RETURN VALUE"
-.B umad_get_ca()
-and
-.B umad_release_ca()
-return 0 on success, and a negative value on error.
-.SH "AUTHORS"
-.TP
-Hal Rosenstock <halr@voltaire.com>
-.TP
-Dotan Barak <dotanb@mellanox.co.il>
diff --git a/contrib/ofed/management/libibumad/man/umad_get_ca_portguids.3 b/contrib/ofed/management/libibumad/man/umad_get_ca_portguids.3
deleted file mode 100644
index 3512649..0000000
--- a/contrib/ofed/management/libibumad/man/umad_get_ca_portguids.3
+++ /dev/null
@@ -1,39 +0,0 @@
-.\" -*- nroff -*-
-.\"
-.TH UMAD_GET_CA_PORTGUIDS 3 "May 11, 2007" "OpenIB" "OpenIB Programmer\'s Manual"
-.SH "NAME"
-umad_get_ca_portguids \- get the InfiniBand device ports GUIDs
-.SH "SYNOPSIS"
-.nf
-.B #include <infiniband/umad.h>
-.sp
-.BI "int umad_get_ca_portguids(char " "*ca_name" ", uint64_t " "*portguids" ", int " "max" );
-.fi
-.SH "DESCRIPTION"
-.B umad_get_ca_portguids()
-fills the
-.I portguids\fR
-array with up to
-.I max
-port GUIDs belonging the specified IB device
-.I ca_name
-, or to the default IB device if
-.I ca_name
-is NULL.
-The argument
-.I portguids
-is an array of
-.I max
-uint64_t entries.
-.SH "RETURN VALUE"
-On success,
-.B umad_get_ca_portguids()
-returns a non-negative value equal to the number of port GUIDs actually filled.
-On failure, a negative value is returned.
-.SH "SEE ALSO"
-.BR umad_get_cas_names (3)
-.SH "AUTHORS"
-.TP
-Hal Rosenstock <halr@voltaire.com>
-.TP
-Dotan Barak <dotanb@mellanox.co.il>
diff --git a/contrib/ofed/management/libibumad/man/umad_get_cas_names.3 b/contrib/ofed/management/libibumad/man/umad_get_cas_names.3
deleted file mode 100644
index 85e76f8..0000000
--- a/contrib/ofed/management/libibumad/man/umad_get_cas_names.3
+++ /dev/null
@@ -1,37 +0,0 @@
-.\" -*- nroff -*-
-.\"
-.TH UMAD_GET_CAS_NAMES 3 "May 21, 2007" "OpenIB" "OpenIB Programmer\'s Manual"
-.SH "NAME"
-umad_get_cas_names \- get list of available InfiniBand device names
-.SH "SYNOPSIS"
-.nf
-.B #include <infiniband/umad.h>
-.sp
-.BI "int umad_get_cas_names(char " "cas[][UMAD_CA_NAME_LEN]" ", int " "max" );
-.fi
-.SH "DESCRIPTION"
-.B umad_get_cas_names()
-fills the
-.I cas
-array with up to
-.I max
-local IB devices (CAs) names.
-The argument
-.I cas
-is a character array with
-.I max
-entries, each with
-.B UMAD_CA_NAME_LEN
-characters.
-.SH "RETURN VALUE"
-.B umad_get_cas_names()
-returns a non-negative value equal to the number of entries filled,
-or \-1 on errors.
-.SH "SEE ALSO"
-.BR umad_get_ca_portguids (3),
-.BR umad_open_port (3)
-.SH "AUTHORS"
-.TP
-Hal Rosenstock <halr@voltaire.com>
-.TP
-Dotan Barak <dotanb@mellanox.co.il>
diff --git a/contrib/ofed/management/libibumad/man/umad_get_fd.3 b/contrib/ofed/management/libibumad/man/umad_get_fd.3
deleted file mode 100644
index 49aa839..0000000
--- a/contrib/ofed/management/libibumad/man/umad_get_fd.3
+++ /dev/null
@@ -1,25 +0,0 @@
-.\" -*- nroff -*-
-.\"
-.TH UMAD_GET_FD 3 "May 17, 2007" "OpenIB" "OpenIB Programmer\'s Manual"
-.SH "NAME"
-umad_get_fd \- get the umad fd for the requested port
-.SH "SYNOPSIS"
-.nf
-.B #include <infiniband/umad.h>
-.sp
-.BI "int umad_get_fd(int " "portid" );
-.fi
-.SH "DESCRIPTION"
-.B umad_get_fd()
-returns the umad fd for the port specified by
-.I portid\fR.
-.SH "RETURN VALUE"
-.B umad_get_fd()
-returns the fd for the
-.I portid\fR
-requested or -EINVAL if
-.I portid\fR
-is invalid.
-.SH "AUTHOR"
-.TP
-Hal Rosenstock <halr@voltaire.com>
diff --git a/contrib/ofed/management/libibumad/man/umad_get_issm_path.3 b/contrib/ofed/management/libibumad/man/umad_get_issm_path.3
deleted file mode 100644
index ac538c9..0000000
--- a/contrib/ofed/management/libibumad/man/umad_get_issm_path.3
+++ /dev/null
@@ -1,38 +0,0 @@
-.\" -*- nroff -*-
-.\"
-.TH UMAD_GET_ISSM_PATH 3 "Oct 18, 2007" "OpenIB" "OpenIB Programmer\'s Manual"
-.SH "NAME"
-umad_get_issm_path \- get path of issm device
-.SH "SYNOPSIS"
-.nf
-.B #include <infiniband/umad.h>
-.sp
-.BI "int umad_get_issm_path(char " "*ca_name" ", int " "portnum", char *path, int max);
-.fi
-.SH "DESCRIPTION"
-.B umad_get_issm_path()
-resolves path to issm device (which used for setting/clearing PortInfo:CapMask IsSM bit) for
-.I portnum
-of the IB device
-.I ca_name
-, it stores resolved path in
-.I path
-array which cannot exceed
-.I max
-bytes in length (including NULL terminator).
-.fi
-Opening issm device sets PortInfo:CapMask IsSM bit and closing clears it.
-.fi
-.SH "RETURN VALUE"
-.B umad_open_port()
-returns 0 on success and a negative value on error as follows:
- -ENODEV IB device can\'t be resolved
- -EINVAL port is not valid (bad
-.I portnum\fR
-or no umad device)
-.SH "SEE ALSO"
-.BR umad_open_port (3),
-.BR umad_get_port (3)
-.SH "AUTHOR"
-.TP
-Sasha Khapyorsky <sashak@voltaire.com>
diff --git a/contrib/ofed/management/libibumad/man/umad_get_mad.3 b/contrib/ofed/management/libibumad/man/umad_get_mad.3
deleted file mode 100644
index 78c59ac..0000000
--- a/contrib/ofed/management/libibumad/man/umad_get_mad.3
+++ /dev/null
@@ -1,24 +0,0 @@
-.\" -*- nroff -*-
-.\"
-.TH UMAD_GET_MAD 3 "May 21, 2007" "OpenIB" "OpenIB Programmer\'s Manual"
-.SH "NAME"
-umad_get_mad \- get the MAD pointer of a umad buffer
-.SH "SYNOPSIS"
-.nf
-.B #include <infiniband/umad.h>
-.sp
-.BI "void * umad_get_mad(void " "*umad");
-.fi
-.SH "DESCRIPTION"
-.B umad_get_mad()
-returns a pointer to the MAD contained within the
-.I umad\fR
-buffer.
-.SH "RETURN VALUE"
-.B umad_get_mad()
-returns a pointer to the MAD contained within the supplied
-.I umad\fR
-buffer.
-.SH "AUTHOR"
-.TP
-Hal Rosenstock <halr@voltaire.com>
diff --git a/contrib/ofed/management/libibumad/man/umad_get_mad_addr.3 b/contrib/ofed/management/libibumad/man/umad_get_mad_addr.3
deleted file mode 100644
index 5da86c2..0000000
--- a/contrib/ofed/management/libibumad/man/umad_get_mad_addr.3
+++ /dev/null
@@ -1,42 +0,0 @@
-.\" -*- nroff -*-
-.\"
-.TH UMAD_GET_MAD_ADDR 3 "May 21, 2007" "OpenIB" "OpenIB Programmer\'s Manual"
-.SH "NAME"
-umad_get_mad_addr \- get the address of the ib_mad_addr from a umad buffer
-.SH "SYNOPSIS"
-.nf
-.B #include <infiniband/umad.h>
-.sp
-.BI "ib_mad_addr_t * umad_get_mad_addr(void " "*umad");
-.fi
-.SH "DESCRIPTION"
-.B umad_get_mad_addr()
-returns a pointer to the ib_mad_addr struct within the specified
-.I umad\fR
-buffer.
-.SH "RETURN VALUE"
-The return value
-is a pointer to an
-.I ib_mad_addr_t
-struct, as specified in <infiniband/umad.h>.
-.PP
-.nf
-typedef struct ib_mad_addr {
-.in +8
-uint32_t qpn;
-uint32_t qkey;
-uint16_t lid;
-uint8_t sl;
-uint8_t path_bits;
-uint8_t grh_present;
-uint8_t gid_index;
-uint8_t hop_limit;
-uint8_t traffic_class;
-uint8_t gid[16];
-uint32_t flow_label;
-.in -8
-} ib_mad_addr_t;
-.fi
-.SH "AUTHOR"
-.TP
-Hal Rosenstock <halr@voltaire.com>
diff --git a/contrib/ofed/management/libibumad/man/umad_get_pkey.3 b/contrib/ofed/management/libibumad/man/umad_get_pkey.3
deleted file mode 100644
index a03c0a6..0000000
--- a/contrib/ofed/management/libibumad/man/umad_get_pkey.3
+++ /dev/null
@@ -1,23 +0,0 @@
-.\" -*- nroff -*-
-.\"
-.TH UMAD_GET_PKEY 3 "Jan 15, 2008" "OpenIB" "OpenIB Programmer\'s Manual"
-.SH "NAME"
-umad_get_pkey \- get pkey index from umad buffer
-.SH "SYNOPSIS"
-.nf
-.B #include <infiniband/umad.h>
-.sp
-.BI "int umad_get_pkey(void " "*umad");
-.fi
-.SH "DESCRIPTION"
-.B umad_get_pkey()
-gets the pkey index from the specified
-.I umad\fR
-buffer.
-.SH "RETURN VALUE"
-.B umad_get_pkey()
-returns value of pkey index (or zero if pkey index is not supported by
-user_mad interface).
-.SH "AUTHOR"
-.TP
-Sasha Khapyorsky <sashak@voltaire.com>
diff --git a/contrib/ofed/management/libibumad/man/umad_get_port.3 b/contrib/ofed/management/libibumad/man/umad_get_port.3
deleted file mode 100644
index 863afa7..0000000
--- a/contrib/ofed/management/libibumad/man/umad_get_port.3
+++ /dev/null
@@ -1,82 +0,0 @@
-.\" -*- nroff -*-
-.\"
-.TH UMAD_GET_PORT 3 "May 21, 2007" "OpenIB" "OpenIB Programmer\'s Manual"
-.SH "NAME"
-umad_get_port, umad_release_port \- open and close an InfiniBand port
-.SH "SYNOPSIS"
-.nf
-.B #include <infiniband/umad.h>
-.sp
-.BI "int umad_get_port(char " "*ca_name" ", int " "portnum" ", umad_port_t " "*port" );
-.nl
-.BI "int umad_release_port(umad_port_t " "*port" );
-.fi
-.SH "DESCRIPTION"
-.B umad_get_port()
-fills the
-.I port
-structure with the IB port attributes specified by
-.I ca_name
-and
-.I portnum
-, or the default port if
-.I ca_name
-is NULL and
-.I portnum
-is zero. If only one of
-.I ca_name
-and
-.I portnum
-are specified, the other is used as a filter.
-For example, passing a NULL
-.I ca_name
-and 2 for the
-.I portnum
-means get a port from any of the local IB devices, as long as it is
-the second port.
-Note that the library may use some reference scheme to support port caching
-therefore
-.B umad_release_port()
-should be called before the
-.I port
-structure can be deallocated.
-The argument
-.I port
-is an
-.B umad_port_t
-struct, as specified in <infiniband/umad.h>.
-.PP
-.nf
-typedef struct umad_port {
-.in +8
-char ca_name[UMAD_CA_NAME_LEN]; /* Name of the device */
-int portnum; /* Physical port number */
-uint base_lid; /* Base port LID */
-uint lmc; /* LMC of LID */
-uint sm_lid; /* SM LID */
-uint sm_sl; /* SM service level */
-uint state; /* Logical port state */
-uint phys_state; /* Physical port state */
-uint rate; /* Port link bit rate */
-uint64_t capmask; /* Port capabilities */
-uint64_t gid_prefix; /* Gid prefix of this port */
-uint64_t port_guid; /* GUID of this port */
-.in -8
-} umad_port_t;
-.fi
-.PP
-.B umad_release_port()
-releases the resources that were allocated by the
-.B umad_get_port()
-function for the specified IB
-.I port\fR.
-.SH "RETURN VALUE"
-.B umad_get_port()
-and
-.B umad_release_port()
-return 0 on success, and a negative value on error.
-.SH "AUTHORS"
-.TP
-Hal Rosenstock <halr@voltaire.com>
-.TP
-Dotan Barak <dotanb@mellanox.co.il>
diff --git a/contrib/ofed/management/libibumad/man/umad_init.3 b/contrib/ofed/management/libibumad/man/umad_init.3
deleted file mode 100644
index a810877..0000000
--- a/contrib/ofed/management/libibumad/man/umad_init.3
+++ /dev/null
@@ -1,39 +0,0 @@
-.\" -*- nroff -*-
-.\"
-.TH UMAD_INIT 3 "May 21, 2007" "OpenIB" "OpenIB Programmer\'s Manual"
-.SH "NAME"
-umad_init, umad_done \- perform library initialization and finalization
-.SH "SYNOPSIS"
-.nf
-.B #include <infiniband/umad.h>
-.sp
-.BI "int umad_init(void);
-.nl
-.BI "int umad_done(void);
-.fi
-.SH "DESCRIPTION"
-.B umad_init()
-initializes the umad library for use. Must be called before any
-other call to this library.
-.PP
-.B umad_done()
-finalizes the use of the umad library.
-.SH "RETURN VALUE"
-.B umad_init()
-and
-.B umad_done()
-return 0 on success, and \-1 on error.
-Error is returned from
-.B umad_init()
-if infiniband umad
-can\'t be opened, or the abi version doesn\'t match.
-There are no errors currently returned by
-.B umad_done().
-.SH "NOTES"
-If an error occurs during the library initialization, no further use of the
-umad library should be attempted.
-.SH "AUTHORS"
-.TP
-Hal Rosenstock <halr@voltaire.com>
-.TP
-Dotan Barak <dotanb@mellanox.co.il>
diff --git a/contrib/ofed/management/libibumad/man/umad_open_port.3 b/contrib/ofed/management/libibumad/man/umad_open_port.3
deleted file mode 100644
index 53f2946..0000000
--- a/contrib/ofed/management/libibumad/man/umad_open_port.3
+++ /dev/null
@@ -1,37 +0,0 @@
-.\" -*- nroff -*-
-.\"
-.TH UMAD_OPEN_PORT 3 "May 21, 2007" "OpenIB" "OpenIB Programmer\'s Manual"
-.SH "NAME"
-umad_open_port \- open InfiniBand device port for umad access
-.SH "SYNOPSIS"
-.nf
-.B #include <infiniband/umad.h>
-.sp
-.BI "int umad_open_port(char " "*ca_name" ", int " "portnum" );
-.fi
-.SH "DESCRIPTION"
-.B umad_open_port()
-opens the port
-.I portnum
-of the IB device
-.I ca_name
-for umad access. The port is selected by the library if not all parameters
-are provided (see
-.B umad_get_port()
-for details).
-.fi
-.SH "RETURN VALUE"
-.B umad_open_port()
-returns 0 or an unique positive value of umad device descriptor on success, and a negative value on error as follows:
- -ENODEV IB device can\'t be resolved
- -EINVAL port is not valid (bad
-.I portnum\fR
-or no umad device)
- -EIO umad device for this port can\'t be opened
-.SH "SEE ALSO"
-.BR umad_close_port (3),
-.BR umad_get_cas_names (3),
-.BR umad_get_port (3)
-.SH "AUTHOR"
-.TP
-Hal Rosenstock <halr@voltaire.com>
diff --git a/contrib/ofed/management/libibumad/man/umad_poll.3 b/contrib/ofed/management/libibumad/man/umad_poll.3
deleted file mode 100644
index 93f9425..0000000
--- a/contrib/ofed/management/libibumad/man/umad_poll.3
+++ /dev/null
@@ -1,40 +0,0 @@
-.\" -*- nroff -*-
-.\"
-.TH UMAD_POLL 3 "October 23, 2007" "OpenIB" "OpenIB Programmer\'s Manual"
-.SH "NAME"
-umad_poll \- poll umad
-.SH "SYNOPSIS"
-.nf
-.B #include <infiniband/umad.h>
-.sp
-.BI "int umad_poll(int " "portid" ", int " "timeout_ms");
-.fi
-.SH "DESCRIPTION"
-.B umad_poll()
-waits up to
-.I timeout_ms\fR
-milliseconds for a packet to be received from the port specified by
-.I portid\fR.
-Once a packet is ready to be read, the function
-returns 0. After that the packet can be read using
-.B umad_recv().
-Otherwise, \-ETIMEDOUT is returned. Note that successfully polling a port
-does not guarantee that the subsequent
-.B umad_recv()
-will be non blocking when several threads are using
-the same port. Instead, use a
-.I timeout_ms\fR
-parameter of zero to
-.B umad_recv()
-to ensure a non-blocking read.
-.SH "RETURN VALUE"
-.B umad_poll()
-returns 0 on success, and a negative value on error as follows:
- -EINVAL invalid port handle or agentid
- -ETIMEDOUT poll operation timed out
- -EIO poll operation failed
-.SH "SEE ALSO"
-.BR umad_recv (3)
-.SH "AUTHOR"
-.TP
-Hal Rosenstock <halr@voltaire.com>
diff --git a/contrib/ofed/management/libibumad/man/umad_recv.3 b/contrib/ofed/management/libibumad/man/umad_recv.3
deleted file mode 100644
index e1b2985..0000000
--- a/contrib/ofed/management/libibumad/man/umad_recv.3
+++ /dev/null
@@ -1,40 +0,0 @@
-.\" -*- nroff -*-
-.\"
-.TH UMAD_RECV 3 "May 11, 2007" "OpenIB" "OpenIB Programmer\'s Manual"
-.SH "NAME"
-umad_recv \- receive umad
-.SH "SYNOPSIS"
-.nf
-.B #include <infiniband/umad.h>
-.sp
-.BI "int umad_recv(int " "portid" ", void " "*umad" ", int " "*length" ", int " "timeout_ms");
-.fi
-.SH "DESCRIPTION"
-.B umad_recv()
-waits up to
-.I timeout_ms\fR
-milliseconds for a packet to be received from the port specified by
-.I portid\fR.
-The packet is copied to the
-.I umad\fR
-buffer if there is sufficient room and the received
-.I length\fR is indicated.
-If the buffer is not large enough, the size of the umad
-buffer needed is returned in
-.I length\fR.
-A negative
-.I timeout_ms\fR
-makes the function block until a packet is received. A
-.I timeout_ms\fR
-parameter of zero indicates a non blocking read.
-.SH "RETURN VALUE"
-.B umad_recv()
-returns non negative receiving agentid on success, and a negative value on error as follows:
- -EINVAL invalid port handle or agentid
- -EIO receive operation failed
- -EWOULDBLOCK non blocking read can't be fulfilled
-.SH "SEE ALSO"
-.BR umad_poll (3)
-.SH "AUTHOR"
-.TP
-Hal Rosenstock <halr@voltaire.com>
diff --git a/contrib/ofed/management/libibumad/man/umad_register.3 b/contrib/ofed/management/libibumad/man/umad_register.3
deleted file mode 100644
index 7f11b51..0000000
--- a/contrib/ofed/management/libibumad/man/umad_register.3
+++ /dev/null
@@ -1,36 +0,0 @@
-.\" -*- nroff -*-
-.\"
-.TH UMAD_REGISTER 3 "May 11, 2007" "OpenIB" "OpenIB Programmer\'s Manual"
-.SH "NAME"
-umad_register \- register the specified management class and version for port
-.SH "SYNOPSIS"
-.nf
-.B #include <infiniband/umad.h>
-.sp
-.BI "int umad_register(int " "portid" ", int " "mgmt_class" ", int " "mgmt_version" " , uint8_t " "rmpp_version" ", uint32_t " "method_mask[4]");
-.fi
-.SH "DESCRIPTION"
-.B umad_register()
-registers the specified management class, management version,
-and whether RMPP is being used for the port specified by the
-.I portid\fR
-parameter. If
-.I method_mask\fR
-array is provided, the caller is registered as a replier (server) for the
-methods having their corresponding bit on in the
-.I method_mask\fR.
-If
-.I method_mask\fR
-is NULL, the caller is registered as a MAD client, meaning that it can
-only receive replies on MADs that it sent (solicited MADs).
-.SH "RETURN VALUE"
-.B umad_register()
-returns non-negative agent id number on success, and a negative value on error as follows:
- -EINVAL invalid port handle
- -EPERM registration failed
-.SH "SEE ALSO"
-.BR umad_register_oui(3),
-.BR umad_unregister (3)
-.SH "AUTHOR"
-.TP
-Hal Rosenstock <halr@voltaire.com>
diff --git a/contrib/ofed/management/libibumad/man/umad_register_oui.3 b/contrib/ofed/management/libibumad/man/umad_register_oui.3
deleted file mode 100644
index 4e8171c..0000000
--- a/contrib/ofed/management/libibumad/man/umad_register_oui.3
+++ /dev/null
@@ -1,37 +0,0 @@
-.\" -*- nroff -*-
-.\"
-.TH UMAD_REGISTER_OUI 3 "May 17, 2007" "OpenIB" "OpenIB Programmer\'s Manual"
-.SH "NAME"
-umad_register_oui \- register the specified class in vendor range 2 for port
-.SH "SYNOPSIS"
-.nf
-.B #include <infiniband/umad.h>
-.sp
-.BI "int umad_register_oui(int " "portid" ", int " "mgmt_class" ", uint8_t " "rmpp_version" ", uint8_t " "oui[3]" ", uint32_t " "method_mask[4]");
-.fi
-.SH "DESCRIPTION"
-.B umad_register_oui()
-registers the specified class in vendor range 2, the specified
-.I oui\fR,
-and whether RMPP is being used for the port specified by the
-.I portid\fR
-handle. If
-.I method_mask\fR
-array is provided, the caller is registered as a replier (server) for the
-methods having their corresponding bit on in the
-.I method_mask\fR.
-If
-.I method_mask\fR
-is NULL, the caller is registered as a MAD client, meaning that it can
-only receive replies on MADs that it sent (solicited MADs).
-.SH "RETURN VALUE"
-.B umad_register()
-returns non-negative agent id number on success, and a negative value on error as follows:
- -EINVAL invalid port handle or class is not in the vendor class 2 range
- -EPERM registration failed
-.SH "SEE ALSO"
-.BR umad_register (3),
-.BR umad_unregister (3)
-.SH "AUTHOR"
-.TP
-Hal Rosenstock <halr@voltaire.com>
diff --git a/contrib/ofed/management/libibumad/man/umad_send.3 b/contrib/ofed/management/libibumad/man/umad_send.3
deleted file mode 100644
index 2d84f57..0000000
--- a/contrib/ofed/management/libibumad/man/umad_send.3
+++ /dev/null
@@ -1,37 +0,0 @@
-.\" -*- nroff -*-
-.\"
-.TH UMAD_SEND 3 "May 11, 2007" "OpenIB" "OpenIB Programmer\'s Manual"
-.SH "NAME"
-umad_send \- send umad
-.SH "SYNOPSIS"
-.nf
-.B #include <infiniband/umad.h>
-.sp
-.BI "int umad_send(int " "portid" ", int " "agentid" ", void " "*umad" ", int " "timeout_ms" ", int " "retries");
-.fi
-.SH "DESCRIPTION"
-.B umad_send()
-sends the specified
-.I umad\fR
-buffer from the port specified by
-.I portid\fR,
-and using the agent specified by
-.I agentid\fR.
-.I timeout_ms\fR
-controls the solicited MADs behavior as follows:
-zero value means not solicited. Positive value makes kernel indicate timeout
-in milliseconds. If reply is not received within the specified value, the
-original buffer is returned in the read channel with the status field set (to
-non zero). Negative
-.I timeout_ms\fR
-makes kernel wait forever for the reply.
-.I retries\fR
-indicates the number of times the MAD will be retried before giving up.
-.SH "RETURN VALUE"
-.B umad_send()
-returns 0 on success, and a negative value on error as follows:
- -EINVAL invalid port handle or agentid
- -EIO send operation failed
-.SH "AUTHOR"
-.TP
-Hal Rosenstock <halr@voltaire.com>
diff --git a/contrib/ofed/management/libibumad/man/umad_set_addr.3 b/contrib/ofed/management/libibumad/man/umad_set_addr.3
deleted file mode 100644
index 82f8190..0000000
--- a/contrib/ofed/management/libibumad/man/umad_set_addr.3
+++ /dev/null
@@ -1,33 +0,0 @@
-.\" -*- nroff -*-
-.\"
-.TH UMAD_SET_ADDR 3 "May 17, 2007" "OpenIB" "OpenIB Programmer\'s Manual"
-.SH "NAME"
-umad_set_addr \- set MAD address fields within umad buffer using host ordering
-.SH "SYNOPSIS"
-.nf
-.B #include <infiniband/umad.h>
-.sp
-.BI "int umad_set_addr(void " "*umad" ", int " "dlid" ", int " "dqp" ", int " "sl" ", int " "qkey");
-.fi
-.SH "DESCRIPTION"
-.B umad_set_addr()
-sets the MAD address fields within the specified
-.I umad\fR
-buffer using the provided host ordered fields.
-.I dlid\fR
-is the destination LID.
-.I dqp\fR
-is the destination QP (queue pair).
-.I sl\fR
-is the SL (service level).
-.I qkey\fR
-is the Q_Key (queue key).
-.SH "RETURN VALUE"
-.B umad_set_addr()
-returns 0 on success, and a negative value on errors. Currently, there
-are no errors indicated.
-.SH "SEE ALSO"
-.BR umad_set_addr_net (3)
-.SH "AUTHOR"
-.TP
-Hal Rosenstock <halr@voltaire.com>
diff --git a/contrib/ofed/management/libibumad/man/umad_set_addr_net.3 b/contrib/ofed/management/libibumad/man/umad_set_addr_net.3
deleted file mode 100644
index 1f409c2..0000000
--- a/contrib/ofed/management/libibumad/man/umad_set_addr_net.3
+++ /dev/null
@@ -1,33 +0,0 @@
-.\" -*- nroff -*-
-.\"
-.TH UMAD_SET_ADDR_NET 3 "May 21, 2007" "OpenIB" "OpenIB Programmer\'s Manual"
-.SH "NAME"
-umad_set_addr_net \- set MAD address fields within umad buffer using network ordering
-.SH "SYNOPSIS"
-.nf
-.B #include <infiniband/umad.h>
-.sp
-.BI "int umad_set_addr_net(void " "*umad" ", int " "dlid" ", int " "dqp" ", int " "sl" ", int " "qkey");
-.fi
-.SH "DESCRIPTION"
-.B umad_set_addr_net()
-sets the MAD address fields within the specified
-.I umad\fR
-buffer using the provided network ordered fields.
-.I dlid\fR
-is the destination LID.
-.I dqp\fR
-is the destination QP (queue pair).
-.I sl\fR
-is the SL (service level).
-.I qkey\fR
-is the Q_Key (queue key).
-.SH "RETURN VALUE"
-.B umad_set_addr_net()
-returns 0 on success, and a negative value on errors. Currently, there
-are no errors indicated.
-.SH "SEE ALSO"
-.BR umad_set_addr (3)
-.SH "AUTHOR"
-.TP
-Hal Rosenstock <halr@voltaire.com>
diff --git a/contrib/ofed/management/libibumad/man/umad_set_grh.3 b/contrib/ofed/management/libibumad/man/umad_set_grh.3
deleted file mode 100644
index 17fe73b..0000000
--- a/contrib/ofed/management/libibumad/man/umad_set_grh.3
+++ /dev/null
@@ -1,75 +0,0 @@
-.\" -*- nroff -*-
-.\"
-.TH UMAD_SET_GRH 3 "May 24, 2007" "OpenIB" "OpenIB Programmer\'s Manual"
-.SH "NAME"
-umad_set_grh \- set GRH fields within umad buffer using host ordering
-.SH "SYNOPSIS"
-.nf
-.B #include <infiniband/umad.h>
-.sp
-.BI "int umad_set_grh(void " "*umad" ", void " "*mad_addr");
-.fi
-.SH "DESCRIPTION"
-.B umad_set_grh()
-sets the GRH fields (grh_present, gid, hop_limit, traffic_class, flow_label)
-within the specified
-.I umad\fR
-buffer based on the
-.I mad_addr\fR
-supplied. The provided
-.I mad_addr\fR
-fields are expected to be in host order.
-If the
-.I mad_addr\fR
-pointer supplied is NULL, no GRH is set.
-The argument
-.I mad_addr
-is a pointer to an
-.I ib_mad_addr_t
-struct, as specified in
-.I <infiniband/umad.h>.
-The argument
-.I umad
-is a pointer to an
-.I ib_user_mad_t
-struct, as specified in
-.I <infiniband/umad.h>.
-.PP
-.nf
-typedef struct ib_mad_addr {
-.in +8
-uint32_t qpn;
-uint32_t qkey;
-uint16_t lid;
-uint8_t sl;
-uint8_t path_bits;
-uint8_t grh_present;
-uint8_t gid_index;
-uint8_t hop_limit;
-uint8_t traffic_class;
-uint8_t gid[16];
-uint32_t flow_label;
-.in -8
-} ib_mad_addr_t;
-.PP
-typedef struct ib_user_mad {
-.in +8
-uint32_t agent_id;
-uint32_t status;
-uint32_t timeout_ms;
-uint32_t retries;
-uint32_t length;
-ib_mad_addr_t addr;
-uint8_t data[0];
-.in -8
-} ib_user_mad_t;
-.fi
-.SH "RETURN VALUE"
-.B umad_set_grh()
-returns 0 on success, and a negative value on errors. Currently, there
-are no errors indicated.
-.SH "SEE ALSO"
-.BR umad_set_grh_net (3)
-.SH "AUTHOR"
-.TP
-Hal Rosenstock <halr@voltaire.com>
diff --git a/contrib/ofed/management/libibumad/man/umad_set_grh_net.3 b/contrib/ofed/management/libibumad/man/umad_set_grh_net.3
deleted file mode 100644
index 8425b3f..0000000
--- a/contrib/ofed/management/libibumad/man/umad_set_grh_net.3
+++ /dev/null
@@ -1,76 +0,0 @@
-.\" -*- nroff -*-
-.\"
-.TH UMAD_SET_GRH_NET 3 "May 24, 2007" "OpenIB" "OpenIB Programmer\'s Manual"
-.SH "NAME"
-umad_set_grh_net \- set GRH fields within umad buffer using network ordering
-.SH "SYNOPSIS"
-.nf
-.B #include <infiniband/umad.h>
-.sp
-.BI "int umad_set_grh_net(void " "*umad" ", void " "*mad_addr");
-.fi
-.SH "DESCRIPTION"
-.B umad_set_grh_net()
-sets the GRH fields (grh_present, gid, hop_limit, traffic_class, flow_label)
-within the specified
-.I umad\fR
-buffer based on the
-.I mad_addr\fR
-supplied. The provided
-.I mad_addr\fR
-fields are expected to be in network order.
-If the
-.I mad_addr\fR
-pointer supplied is NULL, no GRH is set.
-The argument
-.I mad_addr
-is a pointer to an
-.I ib_mad_addr_t
-struct, as specified in <infiniband/umad.h>.
-The argument
-.I umad
-is a pointer to an
-.I ib_user_mad_t
-struct, as specified in
-.I <infiniband/umad.h>.
-.PP
-.nf
-typedef struct ib_mad_addr {
-.in +8
-uint32_t qpn;
-uint32_t qkey;
-uint16_t lid;
-uint8_t sl;
-uint8_t path_bits;
-uint8_t grh_present;
-uint8_t gid_index;
-uint8_t hop_limit;
-uint8_t traffic_class;
-uint8_t gid[16];
-uint32_t flow_label;
-.in -8
-} ib_mad_addr_t;
-.PP
-typedef struct ib_user_mad {
-.in +8
-uint32_t agent_id;
-uint32_t status;
-uint32_t timeout_ms;
-uint32_t retries;
-uint32_t length;
-ib_mad_addr_t addr;
-uint8_t data[0];
-.in -8
-} ib_user_mad_t;
-.fi
-.SH "RETURN VALUE"
-.B umad_set_grh_net()
-returns 0 on success, and a negative value on errors. Currently, there
-are no errors indicated.
-.SH "KNOWN BUGS"
-Not implemented.
-.SH "SEE ALSO"
-.BR umad_set_grh (3)
-.SH "AUTHOR"
-.TP
-Hal Rosenstock <halr@voltaire.com>
diff --git a/contrib/ofed/management/libibumad/man/umad_set_pkey.3 b/contrib/ofed/management/libibumad/man/umad_set_pkey.3
deleted file mode 100644
index d6b8606..0000000
--- a/contrib/ofed/management/libibumad/man/umad_set_pkey.3
+++ /dev/null
@@ -1,22 +0,0 @@
-.\" -*- nroff -*-
-.\"
-.TH UMAD_SET_PKEY 3 "June 20, 2007" "OpenIB" "OpenIB Programmer\'s Manual"
-.SH "NAME"
-umad_set_pkey \- set pkey index within umad buffer
-.SH "SYNOPSIS"
-.nf
-.B #include <infiniband/umad.h>
-.sp
-.BI "int umad_set_pkey(void " "*umad" ", int " "pkey_index");
-.fi
-.SH "DESCRIPTION"
-.B umad_set_pkey()
-sets the pkey index within the specified
-.I umad\fR
-buffer.
-.SH "RETURN VALUE"
-.B umad_set_pkey()
-returns 0 on success, and a negative value on an error.
-.SH "AUTHOR"
-.TP
-Hal Rosenstock <halr@voltaire.com>
diff --git a/contrib/ofed/management/libibumad/man/umad_size.3 b/contrib/ofed/management/libibumad/man/umad_size.3
deleted file mode 100644
index db861ef..0000000
--- a/contrib/ofed/management/libibumad/man/umad_size.3
+++ /dev/null
@@ -1,20 +0,0 @@
-.\" -*- nroff -*-
-.\"
-.TH UMAD_SIZE 3 "May 21, 2007" "OpenIB" "OpenIB Programmer\'s Manual"
-.SH "NAME"
-umad_size \- get the size of umad buffer
-.SH "SYNOPSIS"
-.nf
-.B #include <infiniband/umad.h>
-.sp
-.BI "size_t umad_size(void);
-.fi
-.SH "DESCRIPTION"
-.B umad_size()
-returns the size of umad buffer (in bytes).
-.SH "RETURN VALUE"
-.B umad_size()
-returns the size of umad buffer (in bytes).
-.SH "AUTHOR"
-.TP
-Hal Rosenstock <halr@voltaire.com>
diff --git a/contrib/ofed/management/libibumad/man/umad_status.3 b/contrib/ofed/management/libibumad/man/umad_status.3
deleted file mode 100644
index 3978b84..0000000
--- a/contrib/ofed/management/libibumad/man/umad_status.3
+++ /dev/null
@@ -1,26 +0,0 @@
-.\" -*- nroff -*-
-.\"
-.TH UMAD_STATUS 3 "May 17, 2007" "OpenIB" "OpenIB Programmer\'s Manual"
-.SH "NAME"
-umad_status \- get the status of a umad buffer
-.SH "SYNOPSIS"
-.nf
-.B #include <infiniband/umad.h>
-.sp
-.BI "int umad_status(void " "*umad" );
-.fi
-.SH "DESCRIPTION"
-.B umad_status()
-get the internal
-.I umad\fR
-status field.
-.SH "RETURN VALUE"
-After a packet is received,
-.B umad_status()
-returns 0 on a successful receive, or a non zero status.
-ETIMEDOUT means that the packet had
-a send-timeout indication. In this case, the transaction ID will be
-set to the TID of the original request.
-.SH "AUTHOR"
-.TP
-Hal Rosenstock <halr@voltaire.com>
diff --git a/contrib/ofed/management/libibumad/man/umad_unregister.3 b/contrib/ofed/management/libibumad/man/umad_unregister.3
deleted file mode 100644
index 472afec..0000000
--- a/contrib/ofed/management/libibumad/man/umad_unregister.3
+++ /dev/null
@@ -1,30 +0,0 @@
-.\" -*- nroff -*-
-.\"
-.TH UMAD_UNREGISTER 3 "May 21, 2007" "OpenIB" "OpenIB Programmer\'s Manual"
-.SH "NAME"
-umad_unregister \- unregister umad agent
-.SH "SYNOPSIS"
-.nf
-.B #include <infiniband/umad.h>
-.sp
-.BI "int umad_unregister(int " "portid" ", int " "agentid");
-.fi
-.SH "DESCRIPTION"
-.B umad_unregister()
-unregisters the specified
-.I agentid\fR
-previously registered using
-.B umad_register()
-or
-.B umad_register_oui()\fR.
-.SH "RETURN VALUE"
-.B umad_unregister()
-returns 0 on success and negative value on error as follows:
- -EINVAL invalid port handle or agentid
- * (kernel error codes)
-.SH "SEE ALSO"
-.BR umad_register (3),
-.BR umad_register_oui (3)
-.SH "AUTHOR"
-.TP
-Hal Rosenstock <halr@voltaire.com>
diff --git a/contrib/ofed/management/libibumad/src/libibumad.map b/contrib/ofed/management/libibumad/src/libibumad.map
deleted file mode 100644
index 0154b7f..0000000
--- a/contrib/ofed/management/libibumad/src/libibumad.map
+++ /dev/null
@@ -1,34 +0,0 @@
-IBUMAD_1.0 {
- global:
- umad_init;
- umad_done;
- umad_get_cas_names;
- umad_get_ca_portguids;
- umad_open_port;
- umad_get_ca;
- umad_release_ca;
- umad_get_port;
- umad_release_port;
- umad_close_port;
- umad_get_mad;
- umad_get_issm_path;
- umad_size;
- umad_set_grh;
- umad_set_pkey;
- umad_get_pkey;
- umad_set_addr;
- umad_set_addr_net;
- umad_send;
- umad_recv;
- umad_poll;
- umad_get_fd;
- umad_register;
- umad_register_oui;
- umad_unregister;
- umad_status;
- umad_get_mad_addr;
- umad_debug;
- umad_addr_dump;
- umad_dump;
- local: *;
-};
diff --git a/contrib/ofed/management/libibumad/src/umad.c b/contrib/ofed/management/libibumad/src/umad.c
deleted file mode 100644
index 00fcff6..0000000
--- a/contrib/ofed/management/libibumad/src/umad.c
+++ /dev/null
@@ -1,1036 +0,0 @@
-/*
- * Copyright (c) 2004-2008 Voltaire Inc. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- */
-
-#if HAVE_CONFIG_H
-# include <config.h>
-#endif /* HAVE_CONFIG_H */
-
-#include <sys/poll.h>
-#include <unistd.h>
-#include <string.h>
-#include <errno.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <sys/ioctl.h>
-#include <netinet/in.h>
-#include <dirent.h>
-#include <stdlib.h>
-#include <ctype.h>
-
-#include "umad.h"
-
-#define IB_OPENIB_OUI (0x001405)
-
-#ifdef HAVE_VALGRIND_MEMCHECK_H
-
-# include <valgrind/memcheck.h>
-
-# ifndef VALGRIND_MAKE_MEM_DEFINED
-# warning "Valgrind support requested, but VALGRIND_MAKE_MEM_DEFINED not available"
-# endif
-
-#endif /* HAVE_VALGRIND_MEMCHECK_H */
-
-#ifndef VALGRIND_MAKE_MEM_DEFINED
-# define VALGRIND_MAKE_MEM_DEFINED(addr,len)
-#endif
-
-typedef struct ib_user_mad_reg_req {
- uint32_t id;
- uint32_t method_mask[4];
- uint8_t qpn;
- uint8_t mgmt_class;
- uint8_t mgmt_class_version;
- uint8_t oui[3];
- uint8_t rmpp_version;
-} ib_user_mad_reg_req_t;
-
-#define TRACE if (umaddebug) IBWARN
-#define DEBUG if (umaddebug) IBWARN
-
-int umaddebug = 0;
-
-#define UMAD_DEV_FILE_SZ 256
-
-static char *def_ca_name = "mthca0";
-static int def_ca_port = 1;
-
-static unsigned abi_version;
-static unsigned new_user_mad_api;
-
-/*************************************
- * Port
- */
-static int
-find_cached_ca(char *ca_name, umad_ca_t *ca)
-{
- return 0; /* caching not implemented yet */
-}
-
-static int
-put_ca(umad_ca_t *ca)
-{
- return 0; /* caching not implemented yet */
-}
-
-static int
-release_port(umad_port_t *port)
-{
- free(port->pkeys);
- port->pkeys = NULL;
- port->pkeys_size = 0;
- return 0;
-}
-
-static int check_for_digit_name(const struct dirent *dent)
-{
- const char *p = dent->d_name;
- while (*p && isdigit(*p))
- p++;
- return *p ? 0 : 1;
-}
-
-static int
-get_port(char *ca_name, char *dir, int portnum, umad_port_t *port)
-{
- char port_dir[256];
- uint8_t gid[16];
- struct dirent **namelist = NULL;
- int i, len, ret = 0;
-
- strncpy(port->ca_name, ca_name, sizeof port->ca_name - 1);
- port->portnum = portnum;
- port->pkeys = NULL;
-
- len = snprintf(port_dir, sizeof(port_dir), "%s/%d", dir, portnum);
- if (len < 0 || len > sizeof(port_dir))
- goto clean;
-
- if (sys_read_uint(port_dir, SYS_PORT_LMC, &port->lmc) < 0)
- goto clean;
- if (sys_read_uint(port_dir, SYS_PORT_SMLID, &port->sm_lid) < 0)
- goto clean;
- if (sys_read_uint(port_dir, SYS_PORT_SMSL, &port->sm_sl) < 0)
- goto clean;
- if (sys_read_uint(port_dir, SYS_PORT_LID, &port->base_lid) < 0)
- goto clean;
- if (sys_read_uint(port_dir, SYS_PORT_STATE, &port->state) < 0)
- goto clean;
- if (sys_read_uint(port_dir, SYS_PORT_PHY_STATE, &port->phys_state) < 0)
- goto clean;
- if (sys_read_uint(port_dir, SYS_PORT_RATE, &port->rate) < 0)
- goto clean;
- if (sys_read_uint64(port_dir, SYS_PORT_CAPMASK, &port->capmask) < 0)
- goto clean;
-
- port->capmask = htonl(port->capmask);
-
- if (sys_read_gid(port_dir, SYS_PORT_GID, gid) < 0)
- goto clean;
-
- memcpy(&port->gid_prefix, gid, sizeof port->gid_prefix);
- memcpy(&port->port_guid, gid + 8, sizeof port->port_guid);
-
- snprintf(port_dir + len, sizeof(port_dir) - len, "/pkeys");
- ret = sys_scandir(port_dir, &namelist, check_for_digit_name, NULL);
- if (ret <= 0) {
- IBWARN("no pkeys found for %s:%u (at dir %s)...",
- port->ca_name, port->portnum, port_dir);
- goto clean;
- }
- port->pkeys = calloc(ret, sizeof(port->pkeys[0]));
- if (!port->pkeys) {
- IBWARN("get_port: calloc failed: %s", strerror(errno));
- goto clean;
- }
- for (i = 0; i < ret ; i++) {
- unsigned idx, val;
- idx = strtoul(namelist[i]->d_name, NULL, 0);
- sys_read_uint(port_dir, namelist[i]->d_name, &val);
- port->pkeys[idx] = val;
- free(namelist[i]);
- }
- port->pkeys_size = ret;
- free(namelist);
- namelist = NULL;
- port_dir[len] = '\0';
-
- /* FIXME: handle gids */
-
- return 0;
-
-clean:
- if (namelist) {
- for (i = 0; i < ret ; i++)
- free(namelist[i]);
- free(namelist);
- }
- if (port->pkeys)
- free(port->pkeys);
- return -EIO;
-}
-
-static int
-release_ca(umad_ca_t *ca)
-{
- int i;
-
- for (i = 0; i <= ca->numports; i++) {
- if (!ca->ports[i])
- continue;
- release_port(ca->ports[i]);
- free(ca->ports[i]);
- ca->ports[i] = 0;
- }
- return 0;
-}
-
-/*
- * if *port > 0, check ca[port] state. Otherwise set *port to
- * the first port that is active, and if such is not found, to
- * the first port that is link up and if none are linkup, then
- * the first port that is not disabled. Otherwise return -1.
- */
-static int
-resolve_ca_port(char *ca_name, int *port)
-{
- umad_ca_t ca;
- int active = -1, up = -1;
- int i;
-
- TRACE("checking ca '%s'", ca_name);
-
- if (umad_get_ca(ca_name, &ca) < 0)
- return -1;
-
- if (ca.node_type == 2) {
- *port = 0; /* switch sma port 0 */
- return 1;
- }
-
- if (*port > 0) { /* check only the port the user wants */
- if (*port > ca.numports)
- return -1;
- if (!ca.ports[*port])
- return -1;
- if (ca.ports[*port]->state == 4)
- return 1;
- if (ca.ports[*port]->phys_state != 3)
- return 0;
- return -1;
- }
-
- for (i = 0; i <= ca.numports; i++) {
- DEBUG("checking port %d", i);
- if (!ca.ports[i])
- continue;
- if (up < 0 && ca.ports[i]->phys_state == 5)
- up = *port = i;
- if (ca.ports[i]->state == 4) {
- active = *port = i;
- DEBUG("found active port %d", i);
- break;
- }
- }
-
- if (active == -1 && up == -1) { /* no active or linkup port found */
- for (i = 0; i <= ca.numports; i++) {
- DEBUG("checking port %d", i);
- if (!ca.ports[i])
- continue;
- if (ca.ports[i]->phys_state != 3) {
- up = *port = i;
- break;
- }
- }
- }
-
- release_ca(&ca);
-
- if (active >= 0)
- return 1;
- if (up >= 0)
- return 0;
- return -1;
-}
-
-static char *
-resolve_ca_name(char *ca_name, int *best_port)
-{
- static char names[UMAD_MAX_DEVICES][UMAD_CA_NAME_LEN];
- int phys_found = -1, port_found = 0, port, port_type;
- int caidx, n;
-
- if (ca_name && (!best_port || *best_port))
- return ca_name;
-
- if (ca_name) {
- if (resolve_ca_port(ca_name, best_port) < 0)
- return 0;
- return ca_name;
- }
-
- /* Get the list of CA names */
- if ((n = umad_get_cas_names((void *)names, 20)) < 0)
- return 0;
-
- /* Find the first existing CA with an active port */
- for (caidx = 0; caidx < n; caidx++) {
- TRACE("checking ca '%s'", names[caidx]);
-
- port = best_port ? *best_port : 0;
- if ((port_type = resolve_ca_port(names[caidx], &port)) < 0)
- continue;
-
- DEBUG("found ca %s with port %d type %d",
- names[caidx], port, port_type);
-
- if (port_type > 0) {
- if (best_port)
- *best_port = port;
- DEBUG("found ca %s with active port %d",
- names[caidx], port);
- return (char *)(names + caidx);
- }
-
- if (phys_found == -1) {
- phys_found = caidx;
- port_found = port;
- }
- }
-
- DEBUG("phys found %d on %s port %d",
- phys_found, phys_found >=0 ? names[phys_found] : 0, port_found);
- if (phys_found >= 0) {
- if (best_port)
- *best_port = port_found;
- return names[phys_found];
- }
-
- if (best_port)
- *best_port = def_ca_port;
- return def_ca_name;
-}
-
-static int
-get_ca(char *ca_name, umad_ca_t *ca)
-{
-#ifdef __linux__
- DIR *dir;
-#endif
- char dir_name[256];
- struct dirent **namelist;
- int r, i, ret;
- int portnum;
-
- strncpy(ca->ca_name, ca_name, sizeof ca->ca_name);
-
- snprintf(dir_name, sizeof(dir_name), "%s/%s", SYS_INFINIBAND,
- ca->ca_name);
-
- if ((r = sys_read_uint(dir_name, SYS_NODE_TYPE, &ca->node_type)) < 0)
- return r;
- if (sys_read_string(dir_name, SYS_CA_FW_VERS, ca->fw_ver,
- sizeof ca->fw_ver) < 0)
- ca->fw_ver[0] = '\0';
- if (sys_read_string(dir_name, SYS_CA_HW_VERS, ca->hw_ver,
- sizeof ca->hw_ver) < 0)
- ca->hw_ver[0] = '\0';
- if ((r = sys_read_string(dir_name, SYS_CA_TYPE, ca->ca_type,
- sizeof ca->ca_type)) < 0)
- ca->ca_type[0] = '\0';
- if ((r = sys_read_guid(dir_name, SYS_CA_NODE_GUID, &ca->node_guid)) < 0)
- return r;
- if ((r = sys_read_guid(dir_name, SYS_CA_SYS_GUID, &ca->system_guid)) < 0)
- return r;
-
- snprintf(dir_name, sizeof(dir_name), "%s/%s/%s",
- SYS_INFINIBAND, ca->ca_name, SYS_CA_PORTS_DIR);
-
-#ifdef __linux__
- if (!(dir = opendir(dir_name)))
- return -ENOENT;
-#endif
-
- if ((r = sys_scandir(dir_name, &namelist, 0, alphasort)) < 0) {
- ret = errno < 0 ? errno : -EIO;
- goto error;
- }
-
- ret = 0;
- ca->numports = 0;
- memset(ca->ports, 0, sizeof ca->ports);
- for (i = 0; i < r; i++) {
- portnum = 0;
- if (!strcmp(".", namelist[i]->d_name) ||
- !strcmp("..", namelist[i]->d_name))
- continue;
- if (strcmp("0", namelist[i]->d_name) &&
- ((portnum = atoi(namelist[i]->d_name)) <= 0 ||
- portnum >= UMAD_CA_MAX_PORTS)) {
- ret = -EIO;
- goto clean;
- }
- if (!(ca->ports[portnum] = calloc(1, sizeof(*ca->ports[portnum])))) {
- ret = -ENOMEM;
- goto clean;
- }
- if (get_port(ca_name, dir_name, portnum, ca->ports[portnum]) < 0) {
- free(ca->ports[portnum]);
- ca->ports[portnum] = NULL;
- ret = -EIO;
- goto clean;
- }
- if (ca->numports < portnum)
- ca->numports = portnum;
- }
-
- for (i = 0; i < r; i++)
- free(namelist[i]);
- free(namelist);
-
-#ifdef __linux__
- closedir(dir);
-#endif
- put_ca(ca);
- return 0;
-
-clean:
- for (i = 0; i < r; i++)
- free(namelist[i]);
- free(namelist);
-error:
-#ifdef __linux__
- closedir(dir);
-#endif
- release_ca(ca);
-
- return ret;
-}
-
-static int
-umad_id_to_dev(int umad_id, char *dev, unsigned *port)
-{
- char path[256];
- int r;
-
- snprintf(path, sizeof(path), SYS_INFINIBAND_MAD "/umad%d", umad_id);
-
- if ((r = sys_read_string(path, SYS_IB_MAD_DEV, dev, UMAD_CA_NAME_LEN)) < 0)
- return r;
-
- if ((r = sys_read_uint(path, SYS_IB_MAD_PORT, port)) < 0)
- return r;
-
- return 0;
-}
-
-static int
-dev_to_umad_id(char *dev, unsigned port)
-{
- char umad_dev[UMAD_CA_NAME_LEN];
- unsigned umad_port;
- int id;
-
- for (id = 0; id < UMAD_MAX_PORTS; id++) {
- if (umad_id_to_dev(id, umad_dev, &umad_port) < 0)
- continue;
- if (strncmp(dev, umad_dev, UMAD_CA_NAME_LEN))
- continue;
- if (port != umad_port)
- continue;
-
- DEBUG("mapped %s %d to %d", dev, port, id);
- return id;
- }
-
- return -1; /* not found */
-}
-
-/*******************************
- * Public interface
- */
-
-int
-umad_init(void)
-{
- TRACE("umad_init");
- if (sys_read_uint(IB_UMAD_ABI_DIR, IB_UMAD_ABI_FILE, &abi_version) < 0) {
- IBWARN("can't read ABI version from %s/%s (%m): is ib_umad module loaded?",
- IB_UMAD_ABI_DIR, IB_UMAD_ABI_FILE);
- return -1;
- }
- if (abi_version < IB_UMAD_ABI_VERSION) {
- IBWARN("wrong ABI version: %s/%s is %d but library minimal ABI is %d",
- IB_UMAD_ABI_DIR, IB_UMAD_ABI_FILE, abi_version, IB_UMAD_ABI_VERSION);
- return -1;
- }
- return 0;
-}
-
-int
-umad_done(void)
-{
- TRACE("umad_done");
- /* FIXME - verify that all ports are closed */
- return 0;
-}
-
-static unsigned is_ib_type(char *ca_name)
-{
- char dir_name[256];
- unsigned type;
-
- snprintf(dir_name, sizeof(dir_name), "%s/%s", SYS_INFINIBAND, ca_name);
-
- if (sys_read_uint(dir_name, SYS_NODE_TYPE, &type) < 0)
- return 0;
-
- return type >= 1 && type <= 3 ? 1 : 0;
-}
-
-int
-umad_get_cas_names(char cas[][UMAD_CA_NAME_LEN], int max)
-{
- struct dirent **namelist;
- int n, i, j = 0;
-
- TRACE("max %d", max);
-
- n = sys_scandir(SYS_INFINIBAND, &namelist, NULL, alphasort);
- if (n > 0) {
- for (i = 0; i < n; i++) {
- if (strcmp(namelist[i]->d_name, ".") &&
- strcmp(namelist[i]->d_name, "..")) {
- if (j < max && is_ib_type(namelist[i]->d_name))
- strncpy(cas[j++], namelist[i]->d_name,
- UMAD_CA_NAME_LEN);
- }
- free(namelist[i]);
- }
- DEBUG("return %d cas", j);
- } else {
- /* Is this still needed ? */
- strncpy((char *)cas, def_ca_name, UMAD_CA_NAME_LEN);
- DEBUG("return 1 ca");
- j = 1;
- }
- if (n >= 0)
- free(namelist);
- return j;
-}
-
-int
-umad_get_ca_portguids(char *ca_name, uint64_t *portguids, int max)
-{
- umad_ca_t ca;
- int ports = 0, i;
-
- TRACE("ca name %s max port guids %d", ca_name, max);
- if (!(ca_name = resolve_ca_name(ca_name, 0)))
- return -ENODEV;
-
- if (umad_get_ca(ca_name, &ca) < 0)
- return -1;
-
- if (portguids) {
- if (ca.numports + 1 > max) {
- release_ca(&ca);
- return -ENOMEM;
- }
-
- for (i = 0; i <= ca.numports; i++)
- portguids[ports++] = ca.ports[i] ? ca.ports[i]->port_guid : 0;
- }
-
- release_ca(&ca);
- DEBUG("%s: %d ports", ca_name, ports);
-
- return ports;
-}
-
-int
-umad_get_issm_path(char *ca_name, int portnum, char path[], int max)
-{
- int umad_id;
-
- TRACE("ca %s port %d", ca_name, portnum);
-
- if (!(ca_name = resolve_ca_name(ca_name, &portnum)))
- return -ENODEV;
-
- if ((umad_id = dev_to_umad_id(ca_name, portnum)) < 0)
- return -EINVAL;
-
- snprintf(path, max, "%s/issm%u", UMAD_DEV_DIR , umad_id);
-
- return 0;
-}
-
-int
-umad_open_port(char *ca_name, int portnum)
-{
- char dev_file[UMAD_DEV_FILE_SZ];
- int umad_id, fd;
-
- TRACE("ca %s port %d", ca_name, portnum);
-
- if (!(ca_name = resolve_ca_name(ca_name, &portnum)))
- return -ENODEV;
-
- DEBUG("opening %s port %d", ca_name, portnum);
-
- if ((umad_id = dev_to_umad_id(ca_name, portnum)) < 0)
- return -EINVAL;
-
- snprintf(dev_file, sizeof(dev_file), "%s/umad%d",
- UMAD_DEV_DIR , umad_id);
-
- if ((fd = open(dev_file, O_RDWR|O_NONBLOCK)) < 0) {
- DEBUG("open %s failed: %s", dev_file, strerror(errno));
- return -EIO;
- }
-
- if (abi_version > 5 || !ioctl(fd, IB_USER_MAD_ENABLE_PKEY, NULL))
- new_user_mad_api = 1;
- else
- new_user_mad_api = 0;
-
- DEBUG("opened %s fd %d portid %d", dev_file, fd, umad_id);
- return fd;
-}
-
-int
-umad_get_ca(char *ca_name, umad_ca_t *ca)
-{
- int r;
-
- TRACE("ca_name %s", ca_name);
- if (!(ca_name = resolve_ca_name(ca_name, 0)))
- return -ENODEV;
-
- if (find_cached_ca(ca_name, ca) > 0)
- return 0;
-
- if ((r = get_ca(ca_name, ca)) < 0)
- return r;
-
- DEBUG("opened %s", ca_name);
- return 0;
-}
-
-int
-umad_release_ca(umad_ca_t *ca)
-{
- int r;
-
- TRACE("ca_name %s", ca->ca_name);
- if (!ca)
- return -ENODEV;
-
- if ((r = release_ca(ca)) < 0)
- return r;
-
- DEBUG("releasing %s", ca->ca_name);
- return 0;
-}
-
-int
-umad_get_port(char *ca_name, int portnum, umad_port_t *port)
-{
- char dir_name[256];
-
- TRACE("ca_name %s portnum %d", ca_name, portnum);
-
- if (!(ca_name = resolve_ca_name(ca_name, &portnum)))
- return -ENODEV;
-
- snprintf(dir_name, sizeof(dir_name), "%s/%s/%s",
- SYS_INFINIBAND, ca_name, SYS_CA_PORTS_DIR);
-
- return get_port(ca_name, dir_name, portnum, port);
-}
-
-int
-umad_release_port(umad_port_t *port)
-{
- int r;
-
- TRACE("port %s:%d", port->ca_name, port->portnum);
- if (!port)
- return -ENODEV;
-
- if ((r = release_port(port)) < 0)
- return r;
-
- DEBUG("releasing %s:%d", port->ca_name, port->portnum);
- return 0;
-}
-
-int
-umad_close_port(int fd)
-{
- close(fd);
- DEBUG("closed fd %d", fd);
- return 0;
-}
-
-void *
-umad_get_mad(void *umad)
-{
- return new_user_mad_api ? ((struct ib_user_mad *)umad)->data :
- (void *)&((struct ib_user_mad *)umad)->addr.pkey_index;
-}
-
-size_t
-umad_size(void)
-{
- return new_user_mad_api ? sizeof (struct ib_user_mad) :
- sizeof(struct ib_user_mad) - 8;
-}
-
-int
-umad_set_grh(void *umad, void *mad_addr)
-{
- struct ib_user_mad *mad = umad;
- struct ib_mad_addr *addr = mad_addr;
-
- if (mad_addr) {
- mad->addr.grh_present = 1;
- memcpy(mad->addr.gid, addr->gid, 16);
- mad->addr.flow_label = htonl(addr->flow_label);
- mad->addr.hop_limit = addr->hop_limit;
- mad->addr.traffic_class = addr->traffic_class;
- } else
- mad->addr.grh_present = 0;
- return 0;
-}
-
-int
-umad_set_pkey(void *umad, int pkey_index)
-{
- struct ib_user_mad *mad = umad;
-
- if (new_user_mad_api)
- mad->addr.pkey_index = pkey_index;
-
- return 0;
-}
-
-int
-umad_get_pkey(void *umad)
-{
- struct ib_user_mad *mad = umad;
-
- if (new_user_mad_api)
- return mad->addr.pkey_index;
-
- return 0;
-}
-
-int
-umad_set_addr(void *umad, int dlid, int dqp, int sl, int qkey)
-{
- struct ib_user_mad *mad = umad;
-
- TRACE("umad %p dlid %d dqp %d sl %d, qkey %x",
- umad, dlid, dqp, sl, qkey);
- mad->addr.qpn = htonl(dqp);
- mad->addr.lid = htons(dlid);
- mad->addr.qkey = htonl(qkey);
- mad->addr.sl = sl;
-
- return 0;
-}
-
-int
-umad_set_addr_net(void *umad, int dlid, int dqp, int sl, int qkey)
-{
- struct ib_user_mad *mad = umad;
-
- TRACE("umad %p dlid %d dqp %d sl %d qkey %x",
- umad, ntohs(dlid), ntohl(dqp), sl, ntohl(qkey));
- mad->addr.qpn = dqp;
- mad->addr.lid = dlid;
- mad->addr.qkey = qkey;
- mad->addr.sl = sl;
-
- return 0;
-}
-
-int
-umad_send(int fd, int agentid, void *umad, int length,
- int timeout_ms, int retries)
-{
- struct ib_user_mad *mad = umad;
- int n;
-
- TRACE("fd %d agentid %d umad %p timeout %u",
- fd, agentid, umad, timeout_ms);
- errno = 0;
-
- mad->timeout_ms = timeout_ms;
- mad->retries = retries;
- mad->agent_id = agentid;
-
- if (umaddebug > 1)
- umad_dump(mad);
-
- n = write(fd, mad, length + umad_size());
- if (n == length + umad_size())
- return 0;
-
- DEBUG("write returned %d != sizeof umad %zu + length %d (%m)",
- n, umad_size(), length);
- if (!errno)
- errno = EIO;
- return -EIO;
-}
-
-static int
-dev_poll(int fd, int timeout_ms)
-{
- struct pollfd ufds;
- int n;
-
- ufds.fd = fd;
- ufds.events = POLLIN;
-
- if ((n = poll(&ufds, 1, timeout_ms)) == 1)
- return 0;
-
- if (n == 0)
- return -ETIMEDOUT;
-
- return -EIO;
-}
-
-int
-umad_recv(int fd, void *umad, int *length, int timeout_ms)
-{
- struct ib_user_mad *mad = umad;
- int n;
-
- errno = 0;
- TRACE("fd %d umad %p timeout %u", fd, umad, timeout_ms);
-
- if (!umad || !length) {
- errno = EINVAL;
- return -EINVAL;
- }
-
- if (timeout_ms && (n = dev_poll(fd, timeout_ms)) < 0) {
- if (!errno)
- errno = -n;
- return n;
- }
-
- n = read(fd, umad, umad_size() + *length);
-
- VALGRIND_MAKE_MEM_DEFINED(umad, umad_size() + *length);
-
- if ((n >= 0) && (n <= umad_size() + *length)) {
- DEBUG("mad received by agent %d length %d", mad->agent_id, n);
- if (n > umad_size())
- *length = n - umad_size();
- else
- *length = 0;
- return mad->agent_id;
- }
-
- if (n == -EWOULDBLOCK) {
- if (!errno)
- errno = EWOULDBLOCK;
- return n;
- }
-
- DEBUG("read returned %zu > sizeof umad %zu + length %d (%m)",
- mad->length - umad_size(), umad_size(), *length);
-
- *length = mad->length - umad_size();
- if (!errno)
- errno = EIO;
- return -errno;
-}
-
-int
-umad_poll(int fd, int timeout_ms)
-{
- TRACE("fd %d timeout %u", fd, timeout_ms);
- return dev_poll(fd, timeout_ms);
-}
-
-int
-umad_get_fd(int fd)
-{
- TRACE("fd %d", fd);
- return fd;
-}
-
-int
-umad_register_oui(int fd, int mgmt_class, uint8_t rmpp_version,
- uint8_t oui[3], long method_mask[])
-{
- struct ib_user_mad_reg_req req;
-
- TRACE("fd %d mgmt_class %u rmpp_version %d oui 0x%x%x%x method_mask %p",
- fd, mgmt_class, (int)rmpp_version, (int)oui[0], (int)oui[1],
- (int)oui[2], method_mask);
-
- if (mgmt_class < 0x30 || mgmt_class > 0x4f) {
- DEBUG("mgmt class %d not in vendor range 2", mgmt_class);
- return -EINVAL;
- }
-
- req.qpn = 1;
- req.mgmt_class = mgmt_class;
- req.mgmt_class_version = 1;
- memcpy(req.oui, oui, sizeof req.oui);
- req.rmpp_version = rmpp_version;
-
- if (method_mask)
- memcpy(req.method_mask, method_mask, sizeof req.method_mask);
- else
- memset(req.method_mask, 0, sizeof req.method_mask);
-
- VALGRIND_MAKE_MEM_DEFINED(&req, sizeof req);
-
- if (!ioctl(fd, IB_USER_MAD_REGISTER_AGENT, (void *)&req)) {
- DEBUG("fd %d registered to use agent %d qp %d class 0x%x oui %p",
- fd, req.id, req.qpn, req.mgmt_class, oui);
- return req.id; /* return agentid */
- }
-
- DEBUG("fd %d registering qp %d class 0x%x version %d oui %p failed: %m",
- fd, req.qpn, req.mgmt_class, req.mgmt_class_version, oui);
- return -EPERM;
-}
-
-int
-umad_register(int fd, int mgmt_class, int mgmt_version,
- uint8_t rmpp_version, long method_mask[])
-{
- struct ib_user_mad_reg_req req;
- uint32_t oui = htonl(IB_OPENIB_OUI);
- int qp;
-
- TRACE("fd %d mgmt_class %u mgmt_version %u rmpp_version %d method_mask %p",
- fd, mgmt_class, mgmt_version, rmpp_version, method_mask);
-
- req.qpn = qp = (mgmt_class == 0x1 || mgmt_class == 0x81) ? 0 : 1;
- req.mgmt_class = mgmt_class;
- req.mgmt_class_version = mgmt_version;
- req.rmpp_version = rmpp_version;
-
- if (method_mask)
- memcpy(req.method_mask, method_mask, sizeof req.method_mask);
- else
- memset(req.method_mask, 0, sizeof req.method_mask);
-
- memcpy(&req.oui, (char *)&oui + 1, sizeof req.oui);
-
- VALGRIND_MAKE_MEM_DEFINED(&req, sizeof req);
-
- if (!ioctl(fd, IB_USER_MAD_REGISTER_AGENT, (void *)&req)) {
- DEBUG("fd %d registered to use agent %d qp %d",
- fd, req.id, qp);
- return req.id; /* return agentid */
- }
-
- DEBUG("fd %d registering qp %d class 0x%x version %d failed: %m",
- fd, qp, mgmt_class, mgmt_version);
- return -EPERM;
-}
-
-int
-umad_unregister(int fd, int agentid)
-{
- TRACE("fd %d unregistering agent %d", fd, agentid);
- return ioctl(fd, IB_USER_MAD_UNREGISTER_AGENT, &agentid);
-}
-
-int
-umad_status(void *umad)
-{
- struct ib_user_mad *mad = umad;
-
- return mad->status;
-}
-
-ib_mad_addr_t *
-umad_get_mad_addr(void *umad)
-{
- struct ib_user_mad *mad = umad;
-
- return &mad->addr;
-}
-
-int
-umad_debug(int level)
-{
- if (level >= 0)
- umaddebug = level;
- return umaddebug;
-}
-
-void
-umad_addr_dump(ib_mad_addr_t *addr)
-{
-#define HEX(x) ((x) < 10 ? '0' + (x) : 'a' + ((x) -10))
- char gid_str[64];
- int i;
-
- for (i = 0; i < sizeof addr->gid; i++) {
- gid_str[i*2] = HEX(addr->gid[i] >> 4);
- gid_str[i*2+1] = HEX(addr->gid[i] & 0xf);
- }
- gid_str[i*2] = 0;
- IBWARN("qpn %d qkey 0x%x lid 0x%x sl %d\n"
- "grh_present %d gid_index %d hop_limit %d traffic_class %d flow_label 0x%x pkey_index 0x%x\n"
- "Gid 0x%s",
- ntohl(addr->qpn), ntohl(addr->qkey), ntohs(addr->lid), addr->sl,
- addr->grh_present, (int)addr->gid_index, (int)addr->hop_limit,
- (int)addr->traffic_class, addr->flow_label, addr->pkey_index,
- gid_str);
-}
-
-void
-umad_dump(void *umad)
-{
- struct ib_user_mad * mad = umad;
-
- IBWARN("agent id %d status %x timeout %d",
- mad->agent_id, mad->status, mad->timeout_ms);
- umad_addr_dump(&mad->addr);
-}
diff --git a/contrib/ofed/management/make.dist b/contrib/ofed/management/make.dist
deleted file mode 100755
index b5b587c..0000000
--- a/contrib/ofed/management/make.dist
+++ /dev/null
@@ -1,144 +0,0 @@
-#!/bin/bash
-
-TMPDIR=`pwd`/dist
-if [ ! -d $TMPDIR ]; then mkdir $TMPDIR; fi
-
-usage() {
-echo "$0 daily | release [ signed | <key-id> ]"
-echo
-echo " You must specify either release or daily in order for this script"
-echo "to make tarballs. If this is a daily release, the tarballs will"
-echo "be named <component>-git.tar.gz and will overwrite existing tarballs."
-echo "If this is a release build, then the tarball will be named"
-echo "<component>-<version>.tar.gz and must be a new file. In addition,"
-echo "the script will add a new set of symbolic tags to the git repo"
-echo "that correspond to the <component>-<version> of each tarball."
-echo
-echo " If the TARGETS environment variable is not NULL, then it is taken"
-echo "as the list of components in the management tree that should be"
-echo "included in this release. If it's NULL, then do all the components."
-echo
-echo " If the script detects that the tag on any component already exists,"
-echo "it will abort the release and prompt you to update the version on"
-echo "the already tagged component. This enforces the proper behavior of"
-echo "treating any released tarball as set in stone so that in the future"
-echo "you will always be able to get to any given release tarball by"
-echo "checking out the git tag and know with certainty that it is the same"
-echo "code as released before even if you no longer have the same tarball"
-echo "around."
-echo
-echo " As part of this process, the script will parse the <target>.spec.in"
-echo "file and output a <target>.spec file. Since this script isn't smart"
-echo "enough to deal with other random changes that should have their own"
-echo "checkin the script will refuse to run if the current repo state is not"
-echo "clean."
-echo
-echo " NOTE: the script has no clue if you are tagging on the right branch,"
-echo "it will however show you the git branch output so you can confirm it"
-echo "is on the right branch before proceeding with the release."
-echo
-echo " In addition to just tagging the git repo, whenever creating a release"
-echo "there is an optional argument of either signed or a hex gpg key-id."
-echo "If you do not pass an argument to release, then the tag will be a"
-echo "simple git annotated tag. If you pass signed as the argument, the"
-echo "git tag operation will use your default signing key to sign the tag."
-echo "Or you can pass an actual gpg key id in hex format and git will sign"
-echo "the tag with that key."
-echo
-}
-
-if [ -z "$1" ]; then usage; exit 1; fi
-
-if [ "$1" != "daily" -a "$1" != "release" ]; then usage; exit 1; fi
-
-if [ -z "$TARGETS" ]; then
- TARGETS="libibcommon libibumad libibmad opensm infiniband-diags"
-fi
-
-# Is the repo clean?
-git diff-index --quiet HEAD -- $package > /dev/null 2>&1
-if [ $? -ne 0 ]; then
- echo "Git tree is dirty. Please commit or undo any changes before proceeding."
- exit 4
-fi
-
-# make sure we are on the right branch
-git branch
-echo -n "Is the active branch the right one to tag this release on [y/N]? "
-read answer
-if [ "$answer" = y -o "$answer" = Y ]; then
- echo "Proceeding..."
-else
- echo "Please check out the right branch and run make.dist again"
- exit 0
-fi
-
-for target in $TARGETS; do
- VERSION=`grep "AC_INIT.*$target" $target/configure.in | cut -f 2 -d ',' | sed -e 's/ //g'`
- if [ "$1" = "release" ]; then
- # Check versions to make sure that we can proceed
- if [ -f $TMPDIR/$target-$VERSION.tar.gz ]; then
- echo "Target $target-$VERSION.tar.gz already exists, please update the version on"
- echo "component $target"
- exit 2
- fi
- if [ ! -z "`git tag -l $target-$VERSION`" ]; then
- echo "A git tag already exists for $target-$VERSION. Please change the version"
- echo "of $target so a tag replacement won't occur."
- exit 3
- fi
-# On a real release, this resets the daily release starting point, on the
-# assumption that any new daily builds will have a version number that is
-# incrementally higher than the last officially released tarball.
- RELEASE=1
- echo $RELEASE > $TMPDIR/$target.release
-
- if [ ! -z "$2" ]; then
- if [ $2 = "signed" ]; then
- git tag -s -m "Auto tag by make.dist on release tarball creation" $target-$VERSION
- else
- git tag -u "$2" -m "Auto tag by make.dist on release tarball creation" $target-$VERSION
- fi
- elif [ $1 = "release" ]; then
- git tag -a -m "Auto tag by make.dist on release tarball creation" $target-$VERSION
- fi
- elif [ "$1" = "daily" ]; then
- DATE=`date +%Y%m%d`
- git_rev=`./gen_ver.sh $target | sed -e 's/^'$VERSION'_//'`
- if [ "$git_rev" = "$VERSION" ] ; then
- VERSION=${VERSION}_${DATE}
- else
- VERSION=${VERSION}_${DATE}_${git_rev}
- fi
- if [ -f $TMPDIR/$target.gitrev ]; then
- old_rev=`cat $TMPDIR/$target.gitrev`
- fi
- echo $git_rev > $TMPDIR/$target.gitrev
- if [ "$old_rev" = "$git_rev" ] ; then
- echo "No daily build is needed for '$target' ($git_rev)"
- continue
- fi
- if [ -f $TMPDIR/$target.release ]; then
- RELEASE=`cat $TMPDIR/$target.release`
- RELEASE=`expr $RELEASE + 1`
- else
- RELEASE=1
- fi
- echo $RELEASE > $TMPDIR/$target.release
- RELEASE=0.${RELEASE}
- cat $target/configure.in \
- | sed -e '/AC_INIT/s/'$target', .*,/'$target', '$VERSION',/' \
- > configure.in.new
- diff $target/configure.in configure.in.new > /dev/null \
- || cat configure.in.new > $target/configure.in
- fi
-
- TARBALL=$target-$VERSION.tar.gz
-
- echo "Creating $TMPDIR/$TARBALL"
- ( export RELEASE=$RELEASE && export TARBALL=$TARBALL &&
- cd $target && ./autogen.sh && ./configure &&
- make dist && mv $target-$VERSION.tar.gz $TMPDIR/$TARBALL ) ||
- exit $?
- git checkout $target/configure.in
-done
diff --git a/contrib/ofed/management/opensm/AUTHORS b/contrib/ofed/management/opensm/AUTHORS
deleted file mode 100644
index 0106a07..0000000
--- a/contrib/ofed/management/opensm/AUTHORS
+++ /dev/null
@@ -1,9 +0,0 @@
-
-By the chronological order of involvement:
-Steve King, Intel
-Anil Keshavamurthy, Intel
-Eitan Zahavi, Mellanox Technologies, eitan@mellanox.co.il
-Yael Kalka, Mellanox Technologies, yael@mellanox.co.il
-Shahar Frank, Voltaire
-Hal Rosenstock, Voltaire, halr@voltaire.com
-Sasha Khapyorsky, Voltaire, sashak@voltaire.com
diff --git a/contrib/ofed/management/opensm/COPYING b/contrib/ofed/management/opensm/COPYING
deleted file mode 100644
index 07e5ab0..0000000
--- a/contrib/ofed/management/opensm/COPYING
+++ /dev/null
@@ -1,32 +0,0 @@
- Copyright (c) 2004-2008 Voltaire, Inc. All rights reserved.
- Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved.
- Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
-
- This software is available to you under a choice of one of two
- licenses. You may choose to be licensed under the terms of the GNU
- General Public License (GPL) Version 2, available from the file
- COPYING in the main directory of this source tree, or the
- OpenIB.org BSD license below:
-
- Redistribution and use in source and binary forms, with or
- without modification, are permitted provided that the following
- conditions are met:
-
- - Redistributions of source code must retain the above
- copyright notice, this list of conditions and the following
- disclaimer.
-
- - Redistributions in binary form must reproduce the above
- copyright notice, this list of conditions and the following
- disclaimer in the documentation and/or other materials
- provided with the distribution.
-
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- SOFTWARE.
-
diff --git a/contrib/ofed/management/opensm/ChangeLog b/contrib/ofed/management/opensm/ChangeLog
deleted file mode 100644
index cb67d2b..0000000
--- a/contrib/ofed/management/opensm/ChangeLog
+++ /dev/null
@@ -1,14 +0,0 @@
-2005-09-12 Hal Rosenstock <halr@voltaire.com>
-
- * Improved SA MCMemberRecord error messages
-
-2005-08-22 Yael Kalka <yael@mellanox.co.il>
-
- * Merge of OpenSM 1.8.0 previously available only on Gen1
-
-2005-08-14 Eitan Zahavi <eitan@mellanox.co.il>
-
- * Provided a top level auto tools project so there is no need to
- cd into each of the sub directories and do:
- ./autogen.sh && configure && make && make install
-
diff --git a/contrib/ofed/management/opensm/INSTALL b/contrib/ofed/management/opensm/INSTALL
deleted file mode 100644
index 095b1eb..0000000
--- a/contrib/ofed/management/opensm/INSTALL
+++ /dev/null
@@ -1,231 +0,0 @@
-Installation Instructions
-*************************
-
-Copyright (C) 1994, 1995, 1996, 1999, 2000, 2001, 2002, 2004 Free
-Software Foundation, Inc.
-
-This file is free documentation; the Free Software Foundation gives
-unlimited permission to copy, distribute and modify it.
-
-Basic Installation
-==================
-
-These are generic installation instructions.
-
- The `configure' shell script attempts to guess correct values for
-various system-dependent variables used during compilation. It uses
-those values to create a `Makefile' in each directory of the package.
-It may also create one or more `.h' files containing system-dependent
-definitions. Finally, it creates a shell script `config.status' that
-you can run in the future to recreate the current configuration, and a
-file `config.log' containing compiler output (useful mainly for
-debugging `configure').
-
- It can also use an optional file (typically called `config.cache'
-and enabled with `--cache-file=config.cache' or simply `-C') that saves
-the results of its tests to speed up reconfiguring. (Caching is
-disabled by default to prevent problems with accidental use of stale
-cache files.)
-
- If you need to do unusual things to compile the package, please try
-to figure out how `configure' could check whether to do them, and mail
-diffs or instructions to the address given in the `README' so they can
-be considered for the next release. If you are using the cache, and at
-some point `config.cache' contains results you don't want to keep, you
-may remove or edit it.
-
- The file `configure.ac' (or `configure.in') is used to create
-`configure' by a program called `autoconf'. You only need
-`configure.ac' if you want to change it or regenerate `configure' using
-a newer version of `autoconf'.
-
-The simplest way to compile this package is:
-
- 1. `cd' to the directory containing the package's source code and type
- `./configure' to configure the package for your system. If you're
- using `csh' on an old version of System V, you might need to type
- `sh ./configure' instead to prevent `csh' from trying to execute
- `configure' itself.
-
- Running `configure' takes awhile. While running, it prints some
- messages telling which features it is checking for.
-
- 2. Type `make' to compile the package.
-
- 3. Optionally, type `make check' to run any self-tests that come with
- the package.
-
- 4. Type `make install' to install the programs and any data files and
- documentation.
-
- 5. You can remove the program binaries and object files from the
- source code directory by typing `make clean'. To also remove the
- files that `configure' created (so you can compile the package for
- a different kind of computer), type `make distclean'. There is
- also a `make maintainer-clean' target, but that is intended mainly
- for the package's developers. If you use it, you may have to get
- all sorts of other programs in order to regenerate files that came
- with the distribution.
-
-Compilers and Options
-=====================
-
-Some systems require unusual options for compilation or linking that the
-`configure' script does not know about. Run `./configure --help' for
-details on some of the pertinent environment variables.
-
- You can give `configure' initial values for configuration parameters
-by setting variables in the command line or in the environment. Here
-is an example:
-
- ./configure CC=c89 CFLAGS=-O2 LIBS=-lposix
-
- *Note Defining Variables::, for more details.
-
-Compiling For Multiple Architectures
-====================================
-
-You can compile the package for more than one kind of computer at the
-same time, by placing the object files for each architecture in their
-own directory. To do this, you must use a version of `make' that
-supports the `VPATH' variable, such as GNU `make'. `cd' to the
-directory where you want the object files and executables to go and run
-the `configure' script. `configure' automatically checks for the
-source code in the directory that `configure' is in and in `..'.
-
- If you have to use a `make' that does not support the `VPATH'
-variable, you have to compile the package for one architecture at a
-time in the source code directory. After you have installed the
-package for one architecture, use `make distclean' before reconfiguring
-for another architecture.
-
-Installation Names
-==================
-
-By default, `make install' will install the package's files in
-`/usr/local/bin', `/usr/local/man', etc. You can specify an
-installation prefix other than `/usr/local' by giving `configure' the
-option `--prefix=PREFIX'.
-
- You can specify separate installation prefixes for
-architecture-specific files and architecture-independent files. If you
-give `configure' the option `--exec-prefix=PREFIX', the package will
-use PREFIX as the prefix for installing programs and libraries.
-Documentation and other data files will still use the regular prefix.
-
- In addition, if you use an unusual directory layout you can give
-options like `--bindir=DIR' to specify different values for particular
-kinds of files. Run `configure --help' for a list of the directories
-you can set and what kinds of files go in them.
-
- If the package supports it, you can cause programs to be installed
-with an extra prefix or suffix on their names by giving `configure' the
-option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'.
-
-Optional Features
-=================
-
-Some packages pay attention to `--enable-FEATURE' options to
-`configure', where FEATURE indicates an optional part of the package.
-They may also pay attention to `--with-PACKAGE' options, where PACKAGE
-is something like `gnu-as' or `x' (for the X Window System). The
-`README' should mention any `--enable-' and `--with-' options that the
-package recognizes.
-
- For packages that use the X Window System, `configure' can usually
-find the X include and library files automatically, but if it doesn't,
-you can use the `configure' options `--x-includes=DIR' and
-`--x-libraries=DIR' to specify their locations.
-
-Specifying the System Type
-==========================
-
-There may be some features `configure' cannot figure out automatically,
-but needs to determine by the type of machine the package will run on.
-Usually, assuming the package is built to be run on the _same_
-architectures, `configure' can figure that out, but if it prints a
-message saying it cannot guess the machine type, give it the
-`--build=TYPE' option. TYPE can either be a short name for the system
-type, such as `sun4', or a canonical name which has the form:
-
- CPU-COMPANY-SYSTEM
-
-where SYSTEM can have one of these forms:
-
- OS KERNEL-OS
-
- See the file `config.sub' for the possible values of each field. If
-`config.sub' isn't included in this package, then this package doesn't
-need to know the machine type.
-
- If you are _building_ compiler tools for cross-compiling, you should
-use the `--target=TYPE' option to select the type of system they will
-produce code for.
-
- If you want to _use_ a cross compiler, that generates code for a
-platform different from the build platform, you should specify the
-"host" platform (i.e., that on which the generated programs will
-eventually be run) with `--host=TYPE'.
-
-Sharing Defaults
-================
-
-If you want to set default values for `configure' scripts to share, you
-can create a site shell script called `config.site' that gives default
-values for variables like `CC', `cache_file', and `prefix'.
-`configure' looks for `PREFIX/share/config.site' if it exists, then
-`PREFIX/etc/config.site' if it exists. Or, you can set the
-`CONFIG_SITE' environment variable to the location of the site script.
-A warning: not all `configure' scripts look for a site script.
-
-Defining Variables
-==================
-
-Variables not defined in a site shell script can be set in the
-environment passed to `configure'. However, some packages may run
-configure again during the build, and the customized values of these
-variables may be lost. In order to avoid this problem, you should set
-them in the `configure' command line, using `VAR=value'. For example:
-
- ./configure CC=/usr/local2/bin/gcc
-
-will cause the specified gcc to be used as the C compiler (unless it is
-overridden in the site shell script).
-
-`configure' Invocation
-======================
-
-`configure' recognizes the following options to control how it operates.
-
-`--help'
-`-h'
- Print a summary of the options to `configure', and exit.
-
-`--version'
-`-V'
- Print the version of Autoconf used to generate the `configure'
- script, and exit.
-
-`--cache-file=FILE'
- Enable the cache: use and save the results of the tests in FILE,
- traditionally `config.cache'. FILE defaults to `/dev/null' to
- disable caching.
-
-`--config-cache'
-`-C'
- Alias for `--cache-file=config.cache'.
-
-`--quiet'
-`--silent'
-`-q'
- Do not print messages saying which checks are being made. To
- suppress all normal output, redirect it to `/dev/null' (any error
- messages will still be shown).
-
-`--srcdir=DIR'
- Look for the package's source code in directory DIR. Usually
- `configure' can determine that directory automatically.
-
-`configure' also accepts some other, not widely useful, options. Run
-`configure --help' for more details.
-
diff --git a/contrib/ofed/management/opensm/Makefile.am b/contrib/ofed/management/opensm/Makefile.am
deleted file mode 100644
index 2287edd..0000000
--- a/contrib/ofed/management/opensm/Makefile.am
+++ /dev/null
@@ -1,32 +0,0 @@
-
-# note that order matters: make the libs first then use them
-SUBDIRS = complib libvendor opensm osmtest include $(DEFAULT_EVENT_PLUGIN)
-DIST_SUBDIRS = complib libvendor opensm osmtest include osmeventplugin
-
-ACLOCAL_AMFLAGS = -I config
-
-# we should provide a hint for other apps about the build mode of this project
-install-exec-hook:
- mkdir -p $(DESTDIR)/$(includedir)
-if DEBUG
- echo "define osm_build_type \"debug\"" > $(DESTDIR)/$(includedir)/infiniband/opensm/osm_build_id.h
-else
- echo "define osm_build_type \"free\"" > $(DESTDIR)/$(includedir)/infiniband/opensm/osm_build_id.h
-endif
- $(top_srcdir)/config/install-sh -m 755 -d $(DESTDIR)/$(sysconfdir)/init.d
- cp $(top_builddir)/scripts/opensm.init $(DESTDIR)/$(sysconfdir)/init.d/opensmd
- chmod 755 $(DESTDIR)/$(sysconfdir)/init.d/opensmd
-
-
-man_MANS = man/opensm.8 man/osmtest.8
-
-various_scripts = $(wildcard scripts/*)
-docs = doc/performance-manager-HOWTO.txt doc/QoS_management_in_OpenSM.txt \
- doc/opensm_release_notes-3.2.txt
-
-EXTRA_DIST = autogen.sh opensm.spec $(various_scripts) $(man_MANS) $(docs)
-
-dist-hook: $(EXTRA_DIST)
- if [ -x $(top_srcdir)/../gen_chlog.sh ] ; then \
- cd $(top_srcdir)/.. ; ./gen_chlog.sh $(PACKAGE) > $(distdir)/ChangeLog ; cd - ; \
- fi
diff --git a/contrib/ofed/management/opensm/NEWS b/contrib/ofed/management/opensm/NEWS
deleted file mode 100644
index 8887552..0000000
--- a/contrib/ofed/management/opensm/NEWS
+++ /dev/null
@@ -1,2 +0,0 @@
-
-This file will hold news about the OpenSM project.
diff --git a/contrib/ofed/management/opensm/README b/contrib/ofed/management/opensm/README
deleted file mode 100644
index 40556ba..0000000
--- a/contrib/ofed/management/opensm/README
+++ /dev/null
@@ -1,25 +0,0 @@
-OpenSM README:
---------------
-
-OpenSM provides an implementation for an InfiniBand Subnet Manager and
-Administrator. Such a software entity is required to run for in order
-to initialize the InfiniBand hardware (at least one per each
-InfiniBand subnet).
-
-The full list of OpenSM features is described in the user manual
-provided in the doc sub directory.
-
-The installation of OpenSM includes:
-
-sbin/
- opensm - the SM/SA executable
- osmtest - a test program for the SM/SA
-lib/
- libosmcomp.{a,so} - component library with generic services and containers
- libopensm.{a,so} - opensm services for logs and mad buffer pool
- libosmvendor.{a,so} - interface to the user mad service of the driver
-include/
- iba/ib_types.h - IBA types header file
- complib/ - component library includes
- vendor/ - vendor library includes
- opensm/ - public opensm library includes
diff --git a/contrib/ofed/management/opensm/autogen.sh b/contrib/ofed/management/opensm/autogen.sh
deleted file mode 100755
index fee8800..0000000
--- a/contrib/ofed/management/opensm/autogen.sh
+++ /dev/null
@@ -1,57 +0,0 @@
-#!/bin/bash
-
-# We change dir since the later utilities assume to work in the project dir
-cd ${0%*/*}
-
-# make sure autoconf is up-to-date
-ac_ver=`autoconf --version | head -n 1 | awk '{print $NF}'`
-ac_maj=`echo $ac_ver|sed 's/\..*//'`
-ac_min=`echo $ac_ver|sed 's/.*\.//'`
-if [[ $ac_maj -lt 2 ]]; then
- echo Min autoconf version is 2.57
- exit 1
-elif [[ $ac_maj -eq 2 && $ac_min -lt 57 ]]; then
- echo Min autoconf version is 2.57
- exit 1
-fi
-
-# make sure automake is up-to-date
-am_ver=`automake --version | head -n 1 | awk '{print $NF}'`
-am_maj=`echo $am_ver|sed 's/\..*//'`
-am_min=`echo $am_ver|sed 's/[^\.]*\.\([^\.]*\)\.*.*/\1/'`
-am_sub=`echo $am_ver|sed 's/[^\.]*\.[^\.]*\.*//'`
-if [[ $am_maj -lt 1 ]]; then
- echo Min automake version is 1.6.3
- exit 1
-elif [[ $am_maj -eq 1 && $am_min -lt 6 ]]; then
- echo "automake version is too old:$am_maj.$am_min.$am_sub < required 1.6.3"
- exit 1
-elif [[ $am_maj -eq 1 && $am_min -eq 6 && $am_sub -lt 3 ]]; then
- echo "automake version is too old:$am_maj.$am_min.$am_sub < required 1.6.3"
- exit 1
-fi
-
-# make sure libtool is up-to-date
-lt_ver=`libtool --version | head -n 1 | awk '{print $4}'`
-lt_maj=`echo $lt_ver|sed 's/\..*//'`
-lt_min=`echo $lt_ver|sed 's/[^\.]*\.\([^\.]*\)\.*.*/\1/'`
-lt_sub=`echo $lt_ver|sed 's/[^\.]*\.[^\.]*\.*//'`
-if [[ $lt_maj -lt 1 ]]; then
- echo Min libtool version is 1.4.2
- exit 1
-elif [[ $lt_maj -eq 1 && $lt_min -lt 4 ]]; then
- echo "libtool version is too old:$lt_maj.$lt_min.$lt_sub < required 1.4.2"
- exit 1
-elif [[ $lt_maj -eq 1 && $lt_min -eq 4 && $lt_sub -lt 2 ]]; then
- echo "libtool version is too old:$lt_maj.$lt_min.$lt_sub < required 1.4.2"
- exit 1
-fi
-
-# cleanup
-find . \( -name Makefile.in -o -name aclocal.m4 -o -name autom4te.cache -o -name configure -o -name aclocal.m4 \) -exec \rm -rf {} \; -prune
-
-aclocal -I config && \
-libtoolize --force --copy && \
-autoheader && \
-automake --foreign --add-missing --copy && \
-autoconf
diff --git a/contrib/ofed/management/opensm/complib/ChangeLog b/contrib/ofed/management/opensm/complib/ChangeLog
deleted file mode 100644
index 2b13147..0000000
--- a/contrib/ofed/management/opensm/complib/ChangeLog
+++ /dev/null
@@ -1,96 +0,0 @@
-2007-07=11 Hal Rosenstock <halr@voltaire.com>
-
- * configure.in: to version 2.2.1
-
-2007-06-25 Hal Rosenstock <halr@voltaire.com>
-
- * cl_event_wheel.c: Fix some typos in printfs when
- __CL_EVENT_WHEEL_TEST__ defined
-
-2007-06-20 Hal Rosenstock <halr@voltaire.com>
-
- * libosmcomp.map: Add get_next map functions as global
-
-2007-06-20 Todd Rimmer <todd.rimmer@qlogic.com>
-
- * include/complib/cl_map.h, include/complib/cl_qmap.h,
- include/complib/cl_fleximap.h, cl_map.c:
- Add get_next functions to the various maps
-
- * include/complib/cl_fleximap.h: In cl_fmap_remove_all, make
- sure the count field is properly maintained.
-
-2007-06-19 Todd Rimmer <todd.rimmer@qlogic.com>
-
- * include/complib/cl_qmap.h: In cl_qmap_remove_all, make
- sure the count field is properly maintained.
-
-2007-06-19 Hal Rosenstock <halr@voltaire.com>
-
- * include/complib/cl_threadpool.h: Eliminate compile warning
- with cl_threadpool.c introduced by previous change
-
-2007-06-13 Sasha Khapyorsky <sashak@voltaire.com>
-
- * include/complib/cl_threadpool.h, complib/cl_threadpool.c,
- complib/cl_dispatcher.c, complib/libosmcomp.map: Thread
- pool rework
-
-2007-06-13 Hal Rosenstock <halr@voltaire.com>
-
- * configure.in: Bump to version 2.2.0
-
- * libosmcomp.ver, libosmcomp.map: Update version info for
- previous API removals
-
- * include/complib/cl_memory.h, include/complib/cl_memtrack.h,
- complib/cl_memory.c, complib/cl_memtrack.c, include/Makefile.am:
- Remove deprecated memory allocation related routines
-
-2007-06-13 Yevgeny Kliteynik <kliteyn@dev.mellanox.co.il>
-
- * include/complib/cl_perf.h, include/complib/cl_async_proc.h,
- complib/cl_perf.c, complib/cl_async_proc.c, Makefile.am,
- libosmcomp.map: Remove unused cl_perf and cl_async_proc
-
-2007-05-09 Hal Rosenstock <halr@voltaire.com>
-
- * configure.in: Bump to version 2.1.2
-
-2007-03-29 Hal Rosenstock <halr@voltaire.com>
-
- * configure.in: Bump to version 2.1.1
-
-2007-01-08 Sasha Khapyorsky <sashak@voltaire.com>
-
- * cl_log.c: SIGUSR1 fixes
-
-2007-01-08 Ira Weiny <weiny2@llnl.gov>
-
- * cl_log.c: Add SIGUSR1 handling to reopen osm.log
-
-2006-10-31 Hal Rosenstock <halr@voltaire.com>
-
- * configure.in: Bumped to version version 2.1.0
-
-2006-09-05 Sasha Khapyorsky <sashak@voltaire.com>
-
- * cl_event_wheel.c: Changes to support new osm_log
- initializer osm_log_init_v2()
-
-2006-08-29 Sasha Khapyorsky <sashak@voltaire.com>
-
- * cl_event_wheel.c: Support option to limit size of OpenSM
- log file
-
-2006-07-20 Sasha Khapyorsky <sashak@voltaire.com>
-
- * cl_pool.c: Fix memory corruption in cl_qcpool_init
-
-2006-07-19 Hal Rosenstock <halr@voltaire.com>
-
- * Makefile.am: Eliminate deprecated warnings
-
-2006-06-11 Hal Rosenstock <halr@voltaire.com>
-
- * configure.in: Released version 1.2.1 (OFED 1.1)
diff --git a/contrib/ofed/management/opensm/complib/Makefile.am b/contrib/ofed/management/opensm/complib/Makefile.am
deleted file mode 100644
index 6f2f203..0000000
--- a/contrib/ofed/management/opensm/complib/Makefile.am
+++ /dev/null
@@ -1,81 +0,0 @@
-
-INCLUDES = -I$(srcdir)/../include
-
-lib_LTLIBRARIES = libosmcomp.la
-
-if DEBUG
-DBGFLAGS = -ggdb -D_DEBUG_
-else
-DBGFLAGS = -g
-endif
-
-libosmcomp_la_CFLAGS = -Wall $(DBGFLAGS) -D_XOPEN_SOURCE=600 -D_BSD_SOURCE=1
-
-if HAVE_LD_VERSION_SCRIPT
- libosmcomp_version_script = -Wl,--version-script=$(srcdir)/libosmcomp.map
-else
- libosmcomp_version_script =
-endif
-
-complib_api_version=$(shell grep LIBVERSION= $(srcdir)/libosmcomp.ver | sed 's/LIBVERSION=//')
-
-libosmcomp_la_SOURCES = cl_complib.c cl_dispatcher.c \
- cl_event.c cl_event_wheel.c \
- cl_list.c cl_log.c cl_map.c \
- cl_pool.c cl_ptr_vector.c \
- cl_spinlock.c cl_statustext.c \
- cl_thread.c cl_threadpool.c \
- cl_timer.c cl_vector.c \
- ib_statustext.c \
- cl_nodenamemap.c
-
-libosmcomp_la_LDFLAGS = -version-info $(complib_api_version) \
- -export-dynamic $(libosmcomp_version_script)
-libosmcomp_la_DEPENDENCIES = $(srcdir)/libosmcomp.map
-
-libosmcompincludedir = $(includedir)/infiniband/complib
-
-libosmcompinclude_HEADERS = $(srcdir)/../include/complib/cl_atomic.h \
- $(srcdir)/../include/complib/cl_atomic_osd.h \
- $(srcdir)/../include/complib/cl_byteswap.h \
- $(srcdir)/../include/complib/cl_byteswap_osd.h \
- $(srcdir)/../include/complib/cl_comppool.h \
- $(srcdir)/../include/complib/cl_debug.h \
- $(srcdir)/../include/complib/cl_debug_osd.h \
- $(srcdir)/../include/complib/cl_dispatcher.h \
- $(srcdir)/../include/complib/cl_event.h \
- $(srcdir)/../include/complib/cl_event_wheel.h \
- $(srcdir)/../include/complib/cl_event_osd.h \
- $(srcdir)/../include/complib/cl_fleximap.h \
- $(srcdir)/../include/complib/cl_list.h \
- $(srcdir)/../include/complib/cl_log.h \
- $(srcdir)/../include/complib/cl_map.h \
- $(srcdir)/../include/complib/cl_math.h \
- $(srcdir)/../include/complib/cl_nodenamemap.h \
- $(srcdir)/../include/complib/cl_packoff.h \
- $(srcdir)/../include/complib/cl_packon.h \
- $(srcdir)/../include/complib/cl_passivelock.h \
- $(srcdir)/../include/complib/cl_pool.h \
- $(srcdir)/../include/complib/cl_ptr_vector.h \
- $(srcdir)/../include/complib/cl_qcomppool.h \
- $(srcdir)/../include/complib/cl_qlist.h \
- $(srcdir)/../include/complib/cl_qmap.h \
- $(srcdir)/../include/complib/cl_qpool.h \
- $(srcdir)/../include/complib/cl_spinlock.h \
- $(srcdir)/../include/complib/cl_spinlock_osd.h \
- $(srcdir)/../include/complib/cl_thread.h \
- $(srcdir)/../include/complib/cl_thread_osd.h \
- $(srcdir)/../include/complib/cl_threadpool.h \
- $(srcdir)/../include/complib/cl_timer.h \
- $(srcdir)/../include/complib/cl_timer_osd.h \
- $(srcdir)/../include/complib/cl_types.h \
- $(srcdir)/../include/complib/cl_types_osd.h \
- $(srcdir)/../include/complib/cl_threadpool.h \
- $(srcdir)/../include/complib/cl_timer.h \
- $(srcdir)/../include/complib/cl_timer_osd.h \
- $(srcdir)/../include/complib/cl_types.h \
- $(srcdir)/../include/complib/cl_types_osd.h \
- $(srcdir)/../include/complib/cl_vector.h
-
-# headers are distributed as part of the include dir
-EXTRA_DIST = $(srcdir)/libosmcomp.map $(srcdir)/libosmcomp.ver
diff --git a/contrib/ofed/management/opensm/complib/cl_complib.c b/contrib/ofed/management/opensm/complib/cl_complib.c
deleted file mode 100644
index 2449d9d..0000000
--- a/contrib/ofed/management/opensm/complib/cl_complib.c
+++ /dev/null
@@ -1,92 +0,0 @@
-/*
- * Copyright (c) 2004-2006 Voltaire, Inc. All rights reserved.
- * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved.
- * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- */
-
-#if HAVE_CONFIG_H
-# include <config.h>
-#endif /* HAVE_CONFIG_H */
-
-#include <complib/cl_types.h>
-#include <complib/cl_debug.h>
-#include <complib/cl_spinlock.h>
-
-#include <stdio.h>
-#include <unistd.h>
-#include <stdlib.h>
-
-/*
- * Prototypes
- */
-
-extern
- cl_status_t __cl_timer_prov_create(void);
-
-extern
-void __cl_timer_prov_destroy(void);
-
-cl_spinlock_t cl_atomic_spinlock;
-
-void complib_init(void)
-{
- cl_status_t status = CL_SUCCESS;
-
- status = cl_spinlock_init(&cl_atomic_spinlock);
- if (status != CL_SUCCESS)
- goto _error;
-
- status = __cl_timer_prov_create();
- if (status != CL_SUCCESS)
- goto _error;
- return;
-
-_error:
- cl_msg_out("__init: failed to create complib (%s)\n",
- CL_STATUS_MSG(status));
- exit(1);
-}
-
-void complib_exit(void)
-{
- __cl_timer_prov_destroy();
- cl_spinlock_destroy(&cl_atomic_spinlock);
-}
-
-boolean_t cl_is_debug(void)
-{
-#if defined( _DEBUG_ )
- return TRUE;
-#else
- return FALSE;
-#endif /* defined( _DEBUG_ ) */
-}
diff --git a/contrib/ofed/management/opensm/complib/cl_dispatcher.c b/contrib/ofed/management/opensm/complib/cl_dispatcher.c
deleted file mode 100644
index b0a0a76..0000000
--- a/contrib/ofed/management/opensm/complib/cl_dispatcher.c
+++ /dev/null
@@ -1,377 +0,0 @@
-/*
- * Copyright (c) 2004-2006 Voltaire, Inc. All rights reserved.
- * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved.
- * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- */
-
-/*
- * Abstract:
- * Implementation of Dispatcher abstraction.
- *
- */
-
-#if HAVE_CONFIG_H
-# include <config.h>
-#endif /* HAVE_CONFIG_H */
-
-#include <stdlib.h>
-#include <complib/cl_dispatcher.h>
-#include <complib/cl_thread.h>
-#include <complib/cl_timer.h>
-
-/* give some guidance when we build our cl_pool of messages */
-#define CL_DISP_INITIAL_MSG_COUNT 256
-#define CL_DISP_MSG_GROW_SIZE 64
-
-/* give some guidance when we build our cl_pool of registration elements */
-#define CL_DISP_INITIAL_REG_COUNT 16
-#define CL_DISP_REG_GROW_SIZE 16
-
-/********************************************************************
- __cl_disp_worker
-
- Description:
- This function takes messages off the FIFO and calls Processmsg()
- This function executes as passive level.
-
- Inputs:
- p_disp - Pointer to Dispatcher object
-
- Outputs:
- None
-
- Returns:
- None
-********************************************************************/
-void __cl_disp_worker(IN void *context)
-{
- cl_disp_msg_t *p_msg;
- cl_dispatcher_t *p_disp = (cl_dispatcher_t *) context;
-
- cl_spinlock_acquire(&p_disp->lock);
-
- /* Process the FIFO until we drain it dry. */
- while (cl_qlist_count(&p_disp->msg_fifo)) {
- /* Pop the message at the head from the FIFO. */
- p_msg =
- (cl_disp_msg_t *) cl_qlist_remove_head(&p_disp->msg_fifo);
-
- /* we track the tim ethe last message spent in the queue */
- p_disp->last_msg_queue_time_us =
- cl_get_time_stamp() - p_msg->in_time;
-
- /*
- * Release the spinlock while the message is processed.
- * The user's callback may reenter the dispatcher
- * and cause the lock to be reaquired.
- */
- cl_spinlock_release(&p_disp->lock);
- p_msg->p_dest_reg->pfn_rcv_callback((void *)p_msg->p_dest_reg->
- context,
- (void *)p_msg->p_data);
-
- cl_atomic_dec(&p_msg->p_dest_reg->ref_cnt);
-
- /* The client has seen the data. Notify the sender as appropriate. */
- if (p_msg->pfn_xmt_callback) {
- p_msg->pfn_xmt_callback((void *)p_msg->context,
- (void *)p_msg->p_data);
- cl_atomic_dec(&p_msg->p_src_reg->ref_cnt);
- }
-
- /* Grab the lock for the next iteration through the list. */
- cl_spinlock_acquire(&p_disp->lock);
-
- /* Return this message to the pool. */
- cl_qpool_put(&p_disp->msg_pool, (cl_pool_item_t *) p_msg);
- }
-
- cl_spinlock_release(&p_disp->lock);
-}
-
-/********************************************************************
- ********************************************************************/
-void cl_disp_construct(IN cl_dispatcher_t * const p_disp)
-{
- CL_ASSERT(p_disp);
-
- cl_qlist_init(&p_disp->reg_list);
- cl_ptr_vector_construct(&p_disp->reg_vec);
- cl_qlist_init(&p_disp->msg_fifo);
- cl_spinlock_construct(&p_disp->lock);
- cl_qpool_construct(&p_disp->msg_pool);
-}
-
-/********************************************************************
- ********************************************************************/
-void cl_disp_shutdown(IN cl_dispatcher_t * const p_disp)
-{
- CL_ASSERT(p_disp);
-
- /* Stop the thread pool. */
- cl_thread_pool_destroy(&p_disp->worker_threads);
-
- /* Process all outstanding callbacks. */
- __cl_disp_worker(p_disp);
-
- /* Free all registration info. */
- while (!cl_is_qlist_empty(&p_disp->reg_list))
- free(cl_qlist_remove_head(&p_disp->reg_list));
-}
-
-/********************************************************************
- ********************************************************************/
-void cl_disp_destroy(IN cl_dispatcher_t * const p_disp)
-{
- CL_ASSERT(p_disp);
-
- cl_spinlock_destroy(&p_disp->lock);
- /* Destroy the message pool */
- cl_qpool_destroy(&p_disp->msg_pool);
- /* Destroy the pointer vector of registrants. */
- cl_ptr_vector_destroy(&p_disp->reg_vec);
-}
-
-/********************************************************************
- ********************************************************************/
-cl_status_t
-cl_disp_init(IN cl_dispatcher_t * const p_disp,
- IN const uint32_t thread_count, IN const char *const name)
-{
- cl_status_t status;
-
- CL_ASSERT(p_disp);
-
- cl_disp_construct(p_disp);
-
- status = cl_spinlock_init(&p_disp->lock);
- if (status != CL_SUCCESS) {
- cl_disp_destroy(p_disp);
- return (status);
- }
-
- /* Specify no upper limit to the number of messages in the pool */
- status = cl_qpool_init(&p_disp->msg_pool, CL_DISP_INITIAL_MSG_COUNT,
- 0, CL_DISP_MSG_GROW_SIZE, sizeof(cl_disp_msg_t),
- NULL, NULL, NULL);
- if (status != CL_SUCCESS) {
- cl_disp_destroy(p_disp);
- return (status);
- }
-
- status = cl_ptr_vector_init(&p_disp->reg_vec, CL_DISP_INITIAL_REG_COUNT,
- CL_DISP_REG_GROW_SIZE);
- if (status != CL_SUCCESS) {
- cl_disp_destroy(p_disp);
- return (status);
- }
-
- status = cl_thread_pool_init(&p_disp->worker_threads, thread_count,
- __cl_disp_worker, p_disp, name);
- if (status != CL_SUCCESS)
- cl_disp_destroy(p_disp);
-
- return (status);
-}
-
-/********************************************************************
- ********************************************************************/
-cl_disp_reg_handle_t
-cl_disp_register(IN cl_dispatcher_t * const p_disp,
- IN const cl_disp_msgid_t msg_id,
- IN cl_pfn_msgrcv_cb_t pfn_callback OPTIONAL,
- IN const void *const context OPTIONAL)
-{
- cl_disp_reg_info_t *p_reg;
- cl_status_t status;
-
- CL_ASSERT(p_disp);
-
- /* Check that the requested registrant ID is available. */
- cl_spinlock_acquire(&p_disp->lock);
- if ((msg_id != CL_DISP_MSGID_NONE) &&
- (msg_id < cl_ptr_vector_get_size(&p_disp->reg_vec)) &&
- (cl_ptr_vector_get(&p_disp->reg_vec, msg_id))) {
- cl_spinlock_release(&p_disp->lock);
- return (NULL);
- }
-
- /* Get a registration info from the pool. */
- p_reg = (cl_disp_reg_info_t *) malloc(sizeof(cl_disp_reg_info_t));
- if (!p_reg) {
- cl_spinlock_release(&p_disp->lock);
- return (NULL);
- } else {
- memset(p_reg, 0, sizeof(cl_disp_reg_info_t));
- }
-
- p_reg->p_disp = p_disp;
- p_reg->ref_cnt = 0;
- p_reg->pfn_rcv_callback = pfn_callback;
- p_reg->context = context;
- p_reg->msg_id = msg_id;
-
- /* Insert the registration in the list. */
- cl_qlist_insert_tail(&p_disp->reg_list, (cl_list_item_t *) p_reg);
-
- /* Set the array entry to the registrant. */
- /* The ptr_vector grow automatically as necessary. */
- if (msg_id != CL_DISP_MSGID_NONE) {
- status = cl_ptr_vector_set(&p_disp->reg_vec, msg_id, p_reg);
- if (status != CL_SUCCESS) {
- free(p_reg);
- cl_spinlock_release(&p_disp->lock);
- return (NULL);
- }
- }
-
- cl_spinlock_release(&p_disp->lock);
-
- return (p_reg);
-}
-
-/********************************************************************
- ********************************************************************/
-void cl_disp_unregister(IN const cl_disp_reg_handle_t handle)
-{
- cl_disp_reg_info_t *p_reg;
- cl_dispatcher_t *p_disp;
-
- if (handle == CL_DISP_INVALID_HANDLE)
- return;
-
- p_reg = (cl_disp_reg_info_t *) handle;
- p_disp = p_reg->p_disp;
- CL_ASSERT(p_disp);
-
- cl_spinlock_acquire(&p_disp->lock);
- /*
- * Clear the registrant vector entry. This will cause any further
- * post calls to fail.
- */
- if (p_reg->msg_id != CL_DISP_MSGID_NONE) {
- CL_ASSERT(p_reg->msg_id <
- cl_ptr_vector_get_size(&p_disp->reg_vec));
- cl_ptr_vector_set(&p_disp->reg_vec, p_reg->msg_id, NULL);
- }
- cl_spinlock_release(&p_disp->lock);
-
- while (p_reg->ref_cnt > 0)
- cl_thread_suspend(1);
-
- cl_spinlock_acquire(&p_disp->lock);
- /* Remove the registrant from the list. */
- cl_qlist_remove_item(&p_disp->reg_list, (cl_list_item_t *) p_reg);
- /* Return the registration info to the pool */
- free(p_reg);
-
- cl_spinlock_release(&p_disp->lock);
-}
-
-/********************************************************************
- ********************************************************************/
-cl_status_t
-cl_disp_post(IN const cl_disp_reg_handle_t handle,
- IN const cl_disp_msgid_t msg_id,
- IN const void *const p_data,
- IN cl_pfn_msgdone_cb_t pfn_callback OPTIONAL,
- IN const void *const context OPTIONAL)
-{
- cl_disp_reg_info_t *p_src_reg = (cl_disp_reg_info_t *) handle;
- cl_disp_reg_info_t *p_dest_reg;
- cl_dispatcher_t *p_disp;
- cl_disp_msg_t *p_msg;
-
- p_disp = handle->p_disp;
- CL_ASSERT(p_disp);
- CL_ASSERT(msg_id != CL_DISP_MSGID_NONE);
-
- cl_spinlock_acquire(&p_disp->lock);
- /* Check that the recipient exists. */
- p_dest_reg = cl_ptr_vector_get(&p_disp->reg_vec, msg_id);
- if (!p_dest_reg) {
- cl_spinlock_release(&p_disp->lock);
- return (CL_NOT_FOUND);
- }
-
- /* Get a free message from the pool. */
- p_msg = (cl_disp_msg_t *) cl_qpool_get(&p_disp->msg_pool);
- if (!p_msg) {
- cl_spinlock_release(&p_disp->lock);
- return (CL_INSUFFICIENT_MEMORY);
- }
-
- /* Initialize the message */
- p_msg->p_src_reg = p_src_reg;
- p_msg->p_dest_reg = p_dest_reg;
- p_msg->p_data = p_data;
- p_msg->pfn_xmt_callback = pfn_callback;
- p_msg->context = context;
- p_msg->in_time = cl_get_time_stamp();
-
- /*
- * Increment the sender's reference count if they request a completion
- * notification.
- */
- if (pfn_callback)
- cl_atomic_inc(&p_src_reg->ref_cnt);
-
- /* Increment the recipient's reference count. */
- cl_atomic_inc(&p_dest_reg->ref_cnt);
-
- /* Queue the message in the FIFO. */
- cl_qlist_insert_tail(&p_disp->msg_fifo, (cl_list_item_t *) p_msg);
- cl_spinlock_release(&p_disp->lock);
-
- /* Signal the thread pool that there is work to be done. */
- cl_thread_pool_signal(&p_disp->worker_threads);
- return (CL_SUCCESS);
-}
-
-void
-cl_disp_get_queue_status(IN const cl_disp_reg_handle_t handle,
- OUT uint32_t * p_num_queued_msgs,
- OUT uint64_t * p_last_msg_queue_time_ms)
-{
- cl_dispatcher_t *p_disp = ((cl_disp_reg_info_t *) handle)->p_disp;
-
- cl_spinlock_acquire(&p_disp->lock);
-
- if (p_last_msg_queue_time_ms)
- *p_last_msg_queue_time_ms =
- p_disp->last_msg_queue_time_us / 1000;
-
- if (p_num_queued_msgs)
- *p_num_queued_msgs = cl_qlist_count(&p_disp->msg_fifo);
-
- cl_spinlock_release(&p_disp->lock);
-}
diff --git a/contrib/ofed/management/opensm/complib/cl_event.c b/contrib/ofed/management/opensm/complib/cl_event.c
deleted file mode 100644
index d14b2f4..0000000
--- a/contrib/ofed/management/opensm/complib/cl_event.c
+++ /dev/null
@@ -1,175 +0,0 @@
-/*
- * Copyright (c) 2004, 2005 Voltaire, Inc. All rights reserved.
- * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved.
- * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- */
-
-#if HAVE_CONFIG_H
-# include <config.h>
-#endif /* HAVE_CONFIG_H */
-
-#include <complib/cl_event.h>
-#include <complib/cl_debug.h>
-#include <sys/time.h>
-#include <sys/errno.h>
-
-void cl_event_construct(IN cl_event_t * p_event)
-{
- CL_ASSERT(p_event);
-
- p_event->state = CL_UNINITIALIZED;
-}
-
-cl_status_t
-cl_event_init(IN cl_event_t * const p_event, IN const boolean_t manual_reset)
-{
- CL_ASSERT(p_event);
-
- cl_event_construct(p_event);
-
- pthread_cond_init(&p_event->condvar, NULL);
- pthread_mutex_init(&p_event->mutex, NULL);
- p_event->signaled = FALSE;
- p_event->manual_reset = manual_reset;
- p_event->state = CL_INITIALIZED;
-
- return (CL_SUCCESS);
-}
-
-void cl_event_destroy(IN cl_event_t * const p_event)
-{
- CL_ASSERT(cl_is_state_valid(p_event->state));
-
- /* Destroy only if the event was constructed */
- if (p_event->state == CL_INITIALIZED) {
- pthread_cond_broadcast(&p_event->condvar);
- pthread_cond_destroy(&p_event->condvar);
- pthread_mutex_destroy(&p_event->mutex);
- }
-
- p_event->state = CL_UNINITIALIZED;
-}
-
-cl_status_t cl_event_signal(IN cl_event_t * const p_event)
-{
- /* Make sure that the event was started */
- CL_ASSERT(p_event->state == CL_INITIALIZED);
-
- pthread_mutex_lock(&p_event->mutex);
- p_event->signaled = TRUE;
- /* Wake up one or all depending on whether the event is auto-resetting. */
- if (p_event->manual_reset)
- pthread_cond_broadcast(&p_event->condvar);
- else
- pthread_cond_signal(&p_event->condvar);
-
- pthread_mutex_unlock(&p_event->mutex);
-
- return (CL_SUCCESS);
-}
-
-cl_status_t cl_event_reset(IN cl_event_t * const p_event)
-{
- /* Make sure that the event was started */
- CL_ASSERT(p_event->state == CL_INITIALIZED);
-
- pthread_mutex_lock(&p_event->mutex);
- p_event->signaled = FALSE;
- pthread_mutex_unlock(&p_event->mutex);
-
- return (CL_SUCCESS);
-}
-
-cl_status_t
-cl_event_wait_on(IN cl_event_t * const p_event,
- IN const uint32_t wait_us, IN const boolean_t interruptible)
-{
- cl_status_t status;
- int wait_ret;
- struct timespec timeout;
- struct timeval curtime;
-
- /* Make sure that the event was Started */
- CL_ASSERT(p_event->state == CL_INITIALIZED);
-
- pthread_mutex_lock(&p_event->mutex);
-
- /* Return immediately if the event is signalled. */
- if (p_event->signaled) {
- if (!p_event->manual_reset)
- p_event->signaled = FALSE;
-
- pthread_mutex_unlock(&p_event->mutex);
- return (CL_SUCCESS);
- }
-
- /* If just testing the state, return CL_TIMEOUT. */
- if (wait_us == 0) {
- pthread_mutex_unlock(&p_event->mutex);
- return (CL_TIMEOUT);
- }
-
- if (wait_us == EVENT_NO_TIMEOUT) {
- /* Wait for condition variable to be signaled or broadcast. */
- if (pthread_cond_wait
- (&p_event->condvar, &p_event->mutex))
- status = CL_NOT_DONE;
- else
- status = CL_SUCCESS;
- } else {
- /* Get the current time */
- if (gettimeofday(&curtime, NULL) == 0) {
- timeout.tv_sec = curtime.tv_sec + (wait_us / 1000000);
- timeout.tv_nsec =
- (curtime.tv_usec + (wait_us % 1000000)) * 1000;
-
- wait_ret = pthread_cond_timedwait(&p_event->condvar,
- &p_event->mutex,
- &timeout);
- if (wait_ret == 0)
- status =
- (p_event->
- signaled ? CL_SUCCESS : CL_NOT_DONE);
- else if (wait_ret == ETIMEDOUT)
- status = CL_TIMEOUT;
- else
- status = CL_NOT_DONE;
- } else {
- status = CL_ERROR;
- }
- }
- if (!p_event->manual_reset)
- p_event->signaled = FALSE;
-
- pthread_mutex_unlock(&p_event->mutex);
- return (status);
-}
diff --git a/contrib/ofed/management/opensm/complib/cl_event_wheel.c b/contrib/ofed/management/opensm/complib/cl_event_wheel.c
deleted file mode 100644
index ca06882..0000000
--- a/contrib/ofed/management/opensm/complib/cl_event_wheel.c
+++ /dev/null
@@ -1,573 +0,0 @@
-/*
- * Copyright (c) 2004-2007 Voltaire, Inc. All rights reserved.
- * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved.
- * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- */
-
-#if HAVE_CONFIG_H
-# include <config.h>
-#endif /* HAVE_CONFIG_H */
-
-#include <math.h>
-#include <stdlib.h>
-#include <complib/cl_event_wheel.h>
-#include <complib/cl_debug.h>
-
-#define CL_DBG(fmt, arg...)
-
-static cl_status_t
-__event_will_age_before(IN const cl_list_item_t * const p_list_item,
- IN void *context)
-{
- uint64_t aging_time = *((uint64_t *) context);
- cl_event_wheel_reg_info_t *p_event;
-
- p_event =
- PARENT_STRUCT(p_list_item, cl_event_wheel_reg_info_t, list_item);
-
- if (p_event->aging_time < aging_time)
- return CL_SUCCESS;
- else
- return CL_NOT_FOUND;
-}
-
-static void __cl_event_wheel_callback(IN void *context)
-{
- cl_event_wheel_t *p_event_wheel = (cl_event_wheel_t *) context;
- cl_list_item_t *p_list_item, *p_prev_event_list_item;
- cl_list_item_t *p_list_next_item;
- cl_event_wheel_reg_info_t *p_event;
- uint64_t current_time;
- uint64_t next_aging_time;
- uint32_t new_timeout;
- cl_status_t cl_status;
-
- /* might be during closing ... */
- if (p_event_wheel->closing)
- return;
-
- current_time = cl_get_time_stamp();
-
- if (NULL != p_event_wheel->p_external_lock)
-
- /* Take care of the order of acquiring locks to avoid the deadlock!
- * The external lock goes first.
- */
- cl_spinlock_acquire(p_event_wheel->p_external_lock);
-
- cl_spinlock_acquire(&p_event_wheel->lock);
-
- p_list_item = cl_qlist_head(&p_event_wheel->events_wheel);
- if (p_list_item == cl_qlist_end(&p_event_wheel->events_wheel))
- /* the list is empty - nothing to do */
- goto Exit;
-
- /* we found such an item. get the p_event */
- p_event =
- PARENT_STRUCT(p_list_item, cl_event_wheel_reg_info_t, list_item);
-
- while (p_event->aging_time <= current_time) {
- /* this object has aged - invoke it's callback */
- if (p_event->pfn_aged_callback)
- next_aging_time =
- p_event->pfn_aged_callback(p_event->key,
- p_event->num_regs,
- p_event->context);
- else
- next_aging_time = 0;
-
- /* point to the next object in the wheel */
- p_list_next_item = cl_qlist_next(p_list_item);
-
- /* We need to retire the event if the next aging time passed */
- if (next_aging_time < current_time) {
- /* remove it from the map */
- cl_qmap_remove_item(&p_event_wheel->events_map,
- &(p_event->map_item));
-
- /* pop p_event from the wheel */
- cl_qlist_remove_head(&p_event_wheel->events_wheel);
-
- /* delete the event info object - allocated by cl_event_wheel_reg */
- free(p_event);
- } else {
- /* update the required aging time */
- p_event->aging_time = next_aging_time;
- p_event->num_regs++;
-
- /* do not remove from the map - but remove from the list head and
- place in the correct position */
-
- /* pop p_event from the wheel */
- cl_qlist_remove_head(&p_event_wheel->events_wheel);
-
- /* find the event that ages just before */
- p_prev_event_list_item =
- cl_qlist_find_from_tail(&p_event_wheel->
- events_wheel,
- __event_will_age_before,
- &p_event->aging_time);
-
- /* insert just after */
- cl_qlist_insert_next(&p_event_wheel->events_wheel,
- p_prev_event_list_item,
- &p_event->list_item);
-
- /* as we have modified the list - restart from first item: */
- p_list_next_item =
- cl_qlist_head(&p_event_wheel->events_wheel);
- }
-
- /* advance to next event */
- p_list_item = p_list_next_item;
- if (p_list_item == cl_qlist_end(&p_event_wheel->events_wheel))
- /* the list is empty - nothing to do */
- break;
-
- /* get the p_event */
- p_event =
- PARENT_STRUCT(p_list_item, cl_event_wheel_reg_info_t,
- list_item);
- }
-
- /* We need to restart the timer only if the list is not empty now */
- if (p_list_item != cl_qlist_end(&p_event_wheel->events_wheel)) {
- /* get the p_event */
- p_event =
- PARENT_STRUCT(p_list_item, cl_event_wheel_reg_info_t,
- list_item);
-
- /* start the timer to the timeout [msec] */
- new_timeout =
- (uint32_t) (((p_event->aging_time - current_time) / 1000) +
- 0.5);
- CL_DBG("__cl_event_wheel_callback: Restart timer in: "
- "%u [msec]\n", new_timeout);
- cl_status = cl_timer_start(&p_event_wheel->timer, new_timeout);
- if (cl_status != CL_SUCCESS) {
- CL_DBG("__cl_event_wheel_callback : ERR 6100: "
- "Failed to start timer\n");
- }
- }
-
- /* release the lock */
-Exit:
- cl_spinlock_release(&p_event_wheel->lock);
- if (NULL != p_event_wheel->p_external_lock)
- cl_spinlock_release(p_event_wheel->p_external_lock);
-}
-
-/*
- * Construct and Initialize
- */
-void cl_event_wheel_construct(IN cl_event_wheel_t * const p_event_wheel)
-{
- cl_spinlock_construct(&(p_event_wheel->lock));
- cl_timer_construct(&(p_event_wheel->timer));
-}
-
-cl_status_t
-cl_event_wheel_init(IN cl_event_wheel_t * const p_event_wheel)
-{
- cl_status_t cl_status = CL_SUCCESS;
-
- /* initialize */
- p_event_wheel->p_external_lock = NULL;
- p_event_wheel->closing = FALSE;
- cl_status = cl_spinlock_init(&(p_event_wheel->lock));
- if (cl_status != CL_SUCCESS)
- return cl_status;
- cl_qlist_init(&p_event_wheel->events_wheel);
- cl_qmap_init(&p_event_wheel->events_map);
-
- /* init the timer with timeout */
- cl_status = cl_timer_init(&p_event_wheel->timer, __cl_event_wheel_callback, p_event_wheel); /* cb context */
-
- return cl_status;
-}
-
-cl_status_t
-cl_event_wheel_init_ex(IN cl_event_wheel_t * const p_event_wheel,
- IN cl_spinlock_t * p_external_lock)
-{
- cl_status_t cl_status;
-
- cl_status = cl_event_wheel_init(p_event_wheel);
- if (CL_SUCCESS != cl_status)
- return cl_status;
-
- p_event_wheel->p_external_lock = p_external_lock;
- return cl_status;
-}
-
-void cl_event_wheel_dump(IN cl_event_wheel_t * const p_event_wheel)
-{
- cl_list_item_t *p_list_item;
- cl_event_wheel_reg_info_t *p_event;
-
- p_list_item = cl_qlist_head(&p_event_wheel->events_wheel);
-
- while (p_list_item != cl_qlist_end(&p_event_wheel->events_wheel)) {
- p_event =
- PARENT_STRUCT(p_list_item, cl_event_wheel_reg_info_t,
- list_item);
- CL_DBG("cl_event_wheel_dump: Found event key:<0x%"
- PRIx64 ">, aging time:%" PRIu64 "\n",
- p_event->key, p_event->aging_time);
- p_list_item = cl_qlist_next(p_list_item);
- }
-}
-
-void cl_event_wheel_destroy(IN cl_event_wheel_t * const p_event_wheel)
-{
- cl_list_item_t *p_list_item;
- cl_map_item_t *p_map_item;
- cl_event_wheel_reg_info_t *p_event;
-
- /* we need to get a lock */
- cl_spinlock_acquire(&p_event_wheel->lock);
-
- cl_event_wheel_dump(p_event_wheel);
-
- /* go over all the items in the list and remove them */
- p_list_item = cl_qlist_remove_head(&p_event_wheel->events_wheel);
- while (p_list_item != cl_qlist_end(&p_event_wheel->events_wheel)) {
- p_event =
- PARENT_STRUCT(p_list_item, cl_event_wheel_reg_info_t,
- list_item);
-
- CL_DBG("cl_event_wheel_destroy: Found outstanding event"
- " key:<0x%" PRIx64 ">\n", p_event->key);
-
- /* remove it from the map */
- p_map_item = &(p_event->map_item);
- cl_qmap_remove_item(&p_event_wheel->events_map, p_map_item);
- free(p_event); /* allocated by cl_event_wheel_reg */
- p_list_item =
- cl_qlist_remove_head(&p_event_wheel->events_wheel);
- }
-
- /* destroy the timer */
- cl_timer_destroy(&p_event_wheel->timer);
-
- /* destroy the lock (this should be done without releasing - we don't want
- any other run to grab the lock at this point. */
- cl_spinlock_release(&p_event_wheel->lock);
- cl_spinlock_destroy(&(p_event_wheel->lock));
-}
-
-cl_status_t
-cl_event_wheel_reg(IN cl_event_wheel_t * const p_event_wheel,
- IN const uint64_t key,
- IN const uint64_t aging_time_usec,
- IN cl_pfn_event_aged_cb_t pfn_callback,
- IN void *const context)
-{
- cl_event_wheel_reg_info_t *p_event;
- uint64_t timeout;
- uint32_t to;
- cl_status_t cl_status = CL_SUCCESS;
- cl_list_item_t *prev_event_list_item;
- cl_map_item_t *p_map_item;
-
- /* Get the lock on the manager */
- cl_spinlock_acquire(&(p_event_wheel->lock));
-
- cl_event_wheel_dump(p_event_wheel);
-
- /* Make sure such a key does not exists */
- p_map_item = cl_qmap_get(&p_event_wheel->events_map, key);
- if (p_map_item != cl_qmap_end(&p_event_wheel->events_map)) {
- CL_DBG("cl_event_wheel_reg: Already exists key:0x%"
- PRIx64 "\n", key);
-
- /* already there - remove it from the list as it is getting a new time */
- p_event =
- PARENT_STRUCT(p_map_item, cl_event_wheel_reg_info_t,
- map_item);
-
- /* remove the item from the qlist */
- cl_qlist_remove_item(&p_event_wheel->events_wheel,
- &p_event->list_item);
- /* and the qmap */
- cl_qmap_remove_item(&p_event_wheel->events_map,
- &p_event->map_item);
- } else {
- /* make a new one */
- p_event = (cl_event_wheel_reg_info_t *)
- malloc(sizeof(cl_event_wheel_reg_info_t));
- p_event->num_regs = 0;
- }
-
- p_event->key = key;
- p_event->aging_time = aging_time_usec;
- p_event->pfn_aged_callback = pfn_callback;
- p_event->context = context;
- p_event->num_regs++;
-
- CL_DBG("cl_event_wheel_reg: Registering event key:0x%" PRIx64
- " aging in %u [msec]\n", p_event->key,
- (uint32_t) ((p_event->aging_time -
- cl_get_time_stamp()) / 1000));
-
- /* If the list is empty - need to start the timer */
- if (cl_is_qlist_empty(&p_event_wheel->events_wheel)) {
- /* Edward Bortnikov 03/29/2003
- * ++TBD Consider moving the timer manipulation behind the list manipulation.
- */
-
- /* calculate the new timeout */
- timeout =
- (p_event->aging_time - cl_get_time_stamp() + 500) / 1000;
-
- /* stop the timer if it is running */
-
- /* Edward Bortnikov 03/29/2003
- * Don't call cl_timer_stop() because it spins forever.
- * cl_timer_start() will invoke cl_timer_stop() by itself.
- *
- * The problematic scenario is when __cl_event_wheel_callback()
- * is in race condition with this code. It sets timer.in_timer_cb
- * to TRUE and then blocks on p_event_wheel->lock. Following this,
- * the call to cl_timer_stop() hangs. Following this, the whole system
- * enters into a deadlock.
- *
- * cl_timer_stop(&p_event_wheel->timer);
- */
-
- /* The timeout for the cl_timer_start should be given as uint32_t.
- if there is an overflow - warn about it. */
- to = (uint32_t) timeout;
- if (timeout > (uint32_t) timeout) {
- to = 0xffffffff; /* max 32 bit timer */
- CL_DBG("cl_event_wheel_reg: timeout requested is "
- "too large. Using timeout: %u\n", to);
- }
-
- /* start the timer to the timeout [msec] */
- cl_status = cl_timer_start(&p_event_wheel->timer, to);
- if (cl_status != CL_SUCCESS) {
- CL_DBG("cl_event_wheel_reg : ERR 6103: "
- "Failed to start timer\n");
- goto Exit;
- }
- }
-
- /* insert the object to the qlist and the qmap */
-
- /* BUT WE MUST INSERT IT IN A SORTED MANNER */
- prev_event_list_item =
- cl_qlist_find_from_tail(&p_event_wheel->events_wheel,
- __event_will_age_before,
- &p_event->aging_time);
-
- cl_qlist_insert_next(&p_event_wheel->events_wheel,
- prev_event_list_item, &p_event->list_item);
-
- cl_qmap_insert(&p_event_wheel->events_map, key, &(p_event->map_item));
-
-Exit:
- cl_spinlock_release(&p_event_wheel->lock);
-
- return cl_status;
-}
-
-void
-cl_event_wheel_unreg(IN cl_event_wheel_t * const p_event_wheel, IN uint64_t key)
-{
- cl_event_wheel_reg_info_t *p_event;
- cl_map_item_t *p_map_item;
-
- CL_DBG("cl_event_wheel_unreg: " "Removing key:0x%" PRIx64 "\n", key);
-
- cl_spinlock_acquire(&p_event_wheel->lock);
- p_map_item = cl_qmap_get(&p_event_wheel->events_map, key);
- if (p_map_item != cl_qmap_end(&p_event_wheel->events_map)) {
- /* we found such an item. */
- p_event =
- PARENT_STRUCT(p_map_item, cl_event_wheel_reg_info_t,
- map_item);
-
- /* remove the item from the qlist */
- cl_qlist_remove_item(&p_event_wheel->events_wheel,
- &(p_event->list_item));
- /* remove the item from the qmap */
- cl_qmap_remove_item(&p_event_wheel->events_map,
- &(p_event->map_item));
-
- CL_DBG("cl_event_wheel_unreg: Removed key:0x%" PRIx64 "\n",
- key);
-
- /* free the item */
- free(p_event);
- } else {
- CL_DBG("cl_event_wheel_unreg: did not find key:0x%" PRIx64
- "\n", key);
- }
-
- cl_spinlock_release(&p_event_wheel->lock);
-}
-
-uint32_t
-cl_event_wheel_num_regs(IN cl_event_wheel_t * const p_event_wheel,
- IN uint64_t key)
-{
-
- cl_event_wheel_reg_info_t *p_event;
- cl_map_item_t *p_map_item;
- uint32_t num_regs = 0;
-
- /* try to find the key in the map */
- CL_DBG("cl_event_wheel_num_regs: Looking for key:0x%"
- PRIx64 "\n", key);
-
- cl_spinlock_acquire(&p_event_wheel->lock);
- p_map_item = cl_qmap_get(&p_event_wheel->events_map, key);
- if (p_map_item != cl_qmap_end(&p_event_wheel->events_map)) {
- /* ok so we can simply return it's num_regs */
- p_event =
- PARENT_STRUCT(p_map_item, cl_event_wheel_reg_info_t,
- map_item);
- num_regs = p_event->num_regs;
- }
-
- cl_spinlock_release(&p_event_wheel->lock);
- return (num_regs);
-}
-
-#ifdef __CL_EVENT_WHEEL_TEST__
-
-/* Dump out the complete state of the event wheel */
-void __cl_event_wheel_dump(IN cl_event_wheel_t * const p_event_wheel)
-{
- cl_list_item_t *p_list_item;
- cl_map_item_t *p_map_item;
- cl_event_wheel_reg_info_t *p_event;
-
- printf("************** Event Wheel Dump ***********************\n");
- printf("Event Wheel List has %u items:\n",
- cl_qlist_count(&p_event_wheel->events_wheel));
-
- p_list_item = cl_qlist_head(&p_event_wheel->events_wheel);
- while (p_list_item != cl_qlist_end(&p_event_wheel->events_wheel)) {
- p_event =
- PARENT_STRUCT(p_list_item, cl_event_wheel_reg_info_t,
- list_item);
- printf("Event key:0x%" PRIx64 " Context:%s NumRegs:%u\n",
- p_event->key, (char *)p_event->context,
- p_event->num_regs);
-
- /* next */
- p_list_item = cl_qlist_next(p_list_item);
- }
-
- printf("Event Map has %u items:\n",
- cl_qmap_count(&p_event_wheel->events_map));
-
- p_map_item = cl_qmap_head(&p_event_wheel->events_map);
- while (p_map_item != cl_qmap_end(&p_event_wheel->events_map)) {
- p_event =
- PARENT_STRUCT(p_map_item, cl_event_wheel_reg_info_t,
- map_item);
- printf("Event key:0x%" PRIx64 " Context:%s NumRegs:%u\n",
- p_event->key, (char *)p_event->context,
- p_event->num_regs);
-
- /* next */
- p_map_item = cl_qmap_next(p_map_item);
- }
-
-}
-
-/* The callback for aging event */
-/* We assume we pass a text context */
-void __test_event_aging(uint64_t key, void *context)
-{
- printf("*****************************************************\n");
- printf("Aged key: 0x%" PRIx64 " Context:%s\n", key, (char *)context);
-}
-
-int main()
-{
- cl_event_wheel_t event_wheel;
- /* uint64_t key; */
-
- /* construct */
- cl_event_wheel_construct(&event_wheel);
-
- /* init */
- cl_event_wheel_init(&event_wheel);
-
- /* Start Playing */
- cl_event_wheel_reg(&event_wheel, 1, /* key */
- cl_get_time_stamp() + 3000000, /* 3 sec lifetime */
- __test_event_aging, /* cb */
- "The first Aging Event");
-
- cl_event_wheel_reg(&event_wheel, 2, /* key */
- cl_get_time_stamp() + 3000000, /* 3 sec lifetime */
- __test_event_aging, /* cb */
- "The Second Aging Event");
-
- cl_event_wheel_reg(&event_wheel, 3, /* key */
- cl_get_time_stamp() + 3500000, /* 3 sec lifetime */
- __test_event_aging, /* cb */
- "The Third Aging Event");
-
- __cl_event_wheel_dump(&event_wheel);
-
- sleep(2);
- cl_event_wheel_reg(&event_wheel, 2, /* key */
- cl_get_time_stamp() + 8000000, /* 3 sec lifetime */
- __test_event_aging, /* cb */
- "The Second Aging Event Moved");
-
- __cl_event_wheel_dump(&event_wheel);
-
- sleep(1);
- /* remove the third event */
- cl_event_wheel_unreg(&event_wheel, 3); /* key */
-
- /* get the number of registrations for the keys */
- printf("Event 1 Registered: %u\n",
- cl_event_wheel_num_regs(&event_wheel, 1));
- printf("Event 2 Registered: %u\n",
- cl_event_wheel_num_regs(&event_wheel, 2));
-
- sleep(5);
- /* destroy */
- cl_event_wheel_destroy(&event_wheel);
-
- return (0);
-}
-
-#endif /* __CL_EVENT_WHEEL_TEST__ */
diff --git a/contrib/ofed/management/opensm/complib/cl_list.c b/contrib/ofed/management/opensm/complib/cl_list.c
deleted file mode 100644
index 8129c61..0000000
--- a/contrib/ofed/management/opensm/complib/cl_list.c
+++ /dev/null
@@ -1,581 +0,0 @@
-/*
- * Copyright (c) 2004, 2005 Voltaire, Inc. All rights reserved.
- * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved.
- * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- */
-
-/*
- * Abstract:
- * Implementation of quick list, and list.
- *
- */
-
-#if HAVE_CONFIG_H
-# include <config.h>
-#endif /* HAVE_CONFIG_H */
-
-#include <complib/cl_qlist.h>
-#include <complib/cl_list.h>
-
-#define FREE_ITEM_GROW_SIZE 10
-
-/******************************************************************************
-*******************************************************************************
-************** ************
-************** IMPLEMENTATION OF QUICK LIST ************
-************** ************
-*******************************************************************************
-******************************************************************************/
-void
-cl_qlist_insert_array_head(IN cl_qlist_t * const p_list,
- IN cl_list_item_t * const p_array,
- IN uint32_t item_count, IN const uint32_t item_size)
-{
- cl_list_item_t *p_item;
-
- CL_ASSERT(p_list);
- CL_ASSERT(p_list->state == CL_INITIALIZED);
- CL_ASSERT(p_array);
- CL_ASSERT(item_size >= sizeof(cl_list_item_t));
- CL_ASSERT(item_count);
-
- /*
- * To add items from the array to the list in the same order as
- * the elements appear in the array, we add them starting with
- * the last one first. Locate the last item.
- */
- p_item = (cl_list_item_t *) ((uint8_t *) p_array +
- (item_size * (item_count - 1)));
-
- /* Continue to add all items to the list. */
- while (item_count--) {
- cl_qlist_insert_head(p_list, p_item);
-
- /* Get the next object to add to the list. */
- p_item = (cl_list_item_t *) ((uint8_t *) p_item - item_size);
- }
-}
-
-void
-cl_qlist_insert_array_tail(IN cl_qlist_t * const p_list,
- IN cl_list_item_t * const p_array,
- IN uint32_t item_count, IN const uint32_t item_size)
-{
- cl_list_item_t *p_item;
-
- CL_ASSERT(p_list);
- CL_ASSERT(p_list->state == CL_INITIALIZED);
- CL_ASSERT(p_array);
- CL_ASSERT(item_size >= sizeof(cl_list_item_t));
- CL_ASSERT(item_count);
-
- /* Set the first item to add to the list. */
- p_item = p_array;
-
- /* Continue to add all items to the list. */
- while (item_count--) {
- cl_qlist_insert_tail(p_list, p_item);
-
- /* Get the next object to add to the list. */
- p_item = (cl_list_item_t *) ((uint8_t *) p_item + item_size);
- }
-}
-
-void
-cl_qlist_insert_list_head(IN cl_qlist_t * const p_dest_list,
- IN cl_qlist_t * const p_src_list)
-{
-#if defined( _DEBUG_ )
- cl_list_item_t *p_item;
-#endif
-
- CL_ASSERT(p_dest_list);
- CL_ASSERT(p_src_list);
- CL_ASSERT(p_dest_list->state == CL_INITIALIZED);
- CL_ASSERT(p_src_list->state == CL_INITIALIZED);
-
- /*
- * Is the src list empty?
- * We must have this check here for code below to work.
- */
- if (cl_is_qlist_empty(p_src_list))
- return;
-
-#if defined( _DEBUG_ )
- /* Check that all items in the source list belong there. */
- p_item = cl_qlist_head(p_src_list);
- while (p_item != cl_qlist_end(p_src_list)) {
- /* All list items in the source list must point to it. */
- CL_ASSERT(p_item->p_list == p_src_list);
- /* Point them all to the destination list. */
- p_item->p_list = p_dest_list;
- p_item = cl_qlist_next(p_item);
- }
-#endif
-
- /* Chain the destination list to the tail of the source list. */
- cl_qlist_tail(p_src_list)->p_next = cl_qlist_head(p_dest_list);
- cl_qlist_head(p_dest_list)->p_prev = cl_qlist_tail(p_src_list);
-
- /*
- * Update the head of the destination list to the head of
- * the source list.
- */
- p_dest_list->end.p_next = cl_qlist_head(p_src_list);
- cl_qlist_head(p_src_list)->p_prev = &p_dest_list->end;
-
- /*
- * Update the count of the destination to reflect the source items having
- * been added.
- */
- p_dest_list->count += p_src_list->count;
-
- /* Update source list to reflect being empty. */
- __cl_qlist_reset(p_src_list);
-}
-
-void
-cl_qlist_insert_list_tail(IN cl_qlist_t * const p_dest_list,
- IN cl_qlist_t * const p_src_list)
-{
-#if defined( _DEBUG_ )
- cl_list_item_t *p_item;
-#endif
-
- CL_ASSERT(p_dest_list);
- CL_ASSERT(p_src_list);
- CL_ASSERT(p_dest_list->state == CL_INITIALIZED);
- CL_ASSERT(p_src_list->state == CL_INITIALIZED);
-
- /*
- * Is the src list empty?
- * We must have this check here for code below to work.
- */
- if (cl_is_qlist_empty(p_src_list))
- return;
-
-#if defined( _DEBUG_ )
- /* Check that all items in the source list belong there. */
- p_item = cl_qlist_head(p_src_list);
- while (p_item != cl_qlist_end(p_src_list)) {
- /* All list items in the source list must point to it. */
- CL_ASSERT(p_item->p_list == p_src_list);
- /* Point them all to the destination list. */
- p_item->p_list = p_dest_list;
- p_item = cl_qlist_next(p_item);
- }
-#endif
-
- /* Chain the source list to the tail of the destination list. */
- cl_qlist_tail(p_dest_list)->p_next = cl_qlist_head(p_src_list);
- cl_qlist_head(p_src_list)->p_prev = cl_qlist_tail(p_dest_list);
-
- /*
- * Update the tail of the destination list to the tail of
- * the source list.
- */
- p_dest_list->end.p_prev = cl_qlist_tail(p_src_list);
- cl_qlist_tail(p_src_list)->p_next = &p_dest_list->end;
-
- /*
- * Update the count of the destination to reflect the source items having
- * been added.
- */
- p_dest_list->count += p_src_list->count;
-
- /* Update source list to reflect being empty. */
- __cl_qlist_reset(p_src_list);
-}
-
-boolean_t
-cl_is_item_in_qlist(IN const cl_qlist_t * const p_list,
- IN const cl_list_item_t * const p_list_item)
-{
- const cl_list_item_t *p_temp;
-
- CL_ASSERT(p_list);
- CL_ASSERT(p_list_item);
- CL_ASSERT(p_list->state == CL_INITIALIZED);
-
- /* Traverse looking for a match */
- p_temp = cl_qlist_head(p_list);
- while (p_temp != cl_qlist_end(p_list)) {
- if (p_temp == p_list_item) {
- CL_ASSERT(p_list_item->p_list == p_list);
- return (TRUE);
- }
-
- p_temp = cl_qlist_next(p_temp);
- }
-
- return (FALSE);
-}
-
-cl_list_item_t *cl_qlist_find_next(IN const cl_qlist_t * const p_list,
- IN const cl_list_item_t * const p_list_item,
- IN cl_pfn_qlist_find_t pfn_func,
- IN const void *const context)
-{
- cl_list_item_t *p_found_item;
-
- CL_ASSERT(p_list);
- CL_ASSERT(p_list->state == CL_INITIALIZED);
- CL_ASSERT(p_list_item);
- CL_ASSERT(p_list_item->p_list == p_list);
- CL_ASSERT(pfn_func);
-
- p_found_item = cl_qlist_next(p_list_item);
-
- /* The user provided a compare function */
- while (p_found_item != cl_qlist_end(p_list)) {
- CL_ASSERT(p_found_item->p_list == p_list);
-
- if (pfn_func(p_found_item, (void *)context) == CL_SUCCESS)
- break;
-
- p_found_item = cl_qlist_next(p_found_item);
- }
-
- /* No match */
- return (p_found_item);
-}
-
-cl_list_item_t *cl_qlist_find_prev(IN const cl_qlist_t * const p_list,
- IN const cl_list_item_t * const p_list_item,
- IN cl_pfn_qlist_find_t pfn_func,
- IN const void *const context)
-{
- cl_list_item_t *p_found_item;
-
- CL_ASSERT(p_list);
- CL_ASSERT(p_list->state == CL_INITIALIZED);
- CL_ASSERT(p_list_item);
- CL_ASSERT(p_list_item->p_list == p_list);
- CL_ASSERT(pfn_func);
-
- p_found_item = cl_qlist_prev(p_list_item);
-
- /* The user provided a compare function */
- while (p_found_item != cl_qlist_end(p_list)) {
- CL_ASSERT(p_found_item->p_list == p_list);
-
- if (pfn_func(p_found_item, (void *)context) == CL_SUCCESS)
- break;
-
- p_found_item = cl_qlist_prev(p_found_item);
- }
-
- /* No match */
- return (p_found_item);
-}
-
-void
-cl_qlist_apply_func(IN const cl_qlist_t * const p_list,
- IN cl_pfn_qlist_apply_t pfn_func,
- IN const void *const context)
-{
- cl_list_item_t *p_list_item;
-
- /* Note that context can have any arbitrary value. */
- CL_ASSERT(p_list);
- CL_ASSERT(p_list->state == CL_INITIALIZED);
- CL_ASSERT(pfn_func);
-
- p_list_item = cl_qlist_head(p_list);
- while (p_list_item != cl_qlist_end(p_list)) {
- pfn_func(p_list_item, (void *)context);
- p_list_item = cl_qlist_next(p_list_item);
- }
-}
-
-void
-cl_qlist_move_items(IN cl_qlist_t * const p_src_list,
- IN cl_qlist_t * const p_dest_list,
- IN cl_pfn_qlist_find_t pfn_func,
- IN const void *const context)
-{
- cl_list_item_t *p_current_item, *p_next;
-
- CL_ASSERT(p_src_list);
- CL_ASSERT(p_dest_list);
- CL_ASSERT(p_src_list->state == CL_INITIALIZED);
- CL_ASSERT(p_dest_list->state == CL_INITIALIZED);
- CL_ASSERT(pfn_func);
-
- p_current_item = cl_qlist_head(p_src_list);
-
- while (p_current_item != cl_qlist_end(p_src_list)) {
- /* Before we do anything, get a pointer to the next item. */
- p_next = cl_qlist_next(p_current_item);
-
- if (pfn_func(p_current_item, (void *)context) == CL_SUCCESS) {
- /* Move the item from one list to the other. */
- cl_qlist_remove_item(p_src_list, p_current_item);
- cl_qlist_insert_tail(p_dest_list, p_current_item);
- }
- p_current_item = p_next;
- }
-}
-
-/******************************************************************************
-*******************************************************************************
-************** ************
-************** IMPLEMENTATION OF LIST ************
-************** ************
-*******************************************************************************
-******************************************************************************/
-void cl_list_construct(IN cl_list_t * const p_list)
-{
- CL_ASSERT(p_list);
-
- cl_qpool_construct(&p_list->list_item_pool);
-}
-
-cl_status_t cl_list_init(IN cl_list_t * const p_list, IN const size_t min_items)
-{
- uint32_t grow_size;
-
- CL_ASSERT(p_list);
- cl_qlist_init(&p_list->list);
-
- /*
- * We will grow by min_items/8 items at a time, with a minimum of
- * FREE_ITEM_GROW_SIZE.
- */
- grow_size = (uint32_t) min_items >> 3;
- if (grow_size < FREE_ITEM_GROW_SIZE)
- grow_size = FREE_ITEM_GROW_SIZE;
-
- /* Initialize the pool of list items. */
- return (cl_qpool_init(&p_list->list_item_pool, min_items, 0, grow_size,
- sizeof(cl_pool_obj_t), NULL, NULL, NULL));
-}
-
-void cl_list_destroy(IN cl_list_t * const p_list)
-{
- CL_ASSERT(p_list);
-
- cl_qpool_destroy(&p_list->list_item_pool);
-}
-
-static cl_status_t
-cl_list_find_cb(IN const cl_list_item_t * const p_list_item,
- IN void *const context)
-{
- CL_ASSERT(p_list_item);
-
- if (cl_list_obj(p_list_item) == context)
- return (CL_SUCCESS);
-
- return (CL_NOT_FOUND);
-}
-
-cl_status_t
-cl_list_remove_object(IN cl_list_t * const p_list,
- IN const void *const p_object)
-{
- cl_list_item_t *p_list_item;
-
- CL_ASSERT(p_list);
- CL_ASSERT(cl_is_qpool_inited(&p_list->list_item_pool));
-
- /* find the item in question */
- p_list_item =
- cl_qlist_find_from_head(&p_list->list, cl_list_find_cb, p_object);
- if (p_list_item != cl_qlist_end(&p_list->list)) {
- /* remove this item */
- cl_qlist_remove_item(&p_list->list, p_list_item);
- cl_qpool_put(&p_list->list_item_pool,
- (cl_pool_item_t *) p_list_item);
- return (CL_SUCCESS);
- }
- return (CL_NOT_FOUND);
-}
-
-boolean_t
-cl_is_object_in_list(IN const cl_list_t * const p_list,
- IN const void *const p_object)
-{
- CL_ASSERT(p_list);
- CL_ASSERT(cl_is_qpool_inited(&p_list->list_item_pool));
-
- return (cl_qlist_find_from_head
- (&p_list->list, cl_list_find_cb, p_object)
- != cl_qlist_end(&p_list->list));
-}
-
-cl_status_t
-cl_list_insert_array_head(IN cl_list_t * const p_list,
- IN const void *const p_array,
- IN uint32_t item_count, IN const uint32_t item_size)
-{
- cl_status_t status;
- void *p_object;
-
- CL_ASSERT(p_list);
- CL_ASSERT(cl_is_qpool_inited(&p_list->list_item_pool));
- CL_ASSERT(p_array);
- CL_ASSERT(item_size);
- CL_ASSERT(item_count);
-
- /*
- * To add items from the array to the list in the same order as
- * the elements appear in the array, we add them starting with
- * the last one first. Locate the last item.
- */
- p_object = ((uint8_t *) p_array + (item_size * (item_count - 1)));
-
- /* Continue to add all items to the list. */
- while (item_count--) {
- status = cl_list_insert_head(p_list, p_object);
- if (status != CL_SUCCESS) {
- /* Remove all items that have been inserted. */
- while (item_count++ < item_count)
- cl_list_remove_head(p_list);
- return (status);
- }
-
- /* Get the next object to add to the list. */
- p_object = ((uint8_t *) p_object - item_size);
- }
-
- return (CL_SUCCESS);
-}
-
-cl_status_t
-cl_list_insert_array_tail(IN cl_list_t * const p_list,
- IN const void *const p_array,
- IN uint32_t item_count, IN const uint32_t item_size)
-{
- cl_status_t status;
- void *p_object;
-
- CL_ASSERT(p_list);
- CL_ASSERT(cl_is_qpool_inited(&p_list->list_item_pool));
- CL_ASSERT(p_array);
- CL_ASSERT(item_size);
- CL_ASSERT(item_count);
-
- /* Set the first item to add to the list. */
- p_object = (void *)p_array;
-
- /* Continue to add all items to the list. */
- while (item_count--) {
- status = cl_list_insert_tail(p_list, p_object);
- if (status != CL_SUCCESS) {
- /* Remove all items that have been inserted. */
- while (item_count++ < item_count)
- cl_list_remove_tail(p_list);
- return (status);
- }
-
- /* Get the next object to add to the list. */
- p_object = ((uint8_t *) p_object + item_size);
- }
-
- return (CL_SUCCESS);
-}
-
-cl_list_iterator_t
-cl_list_find_from_head(IN const cl_list_t * const p_list,
- IN cl_pfn_list_find_t pfn_func,
- IN const void *const context)
-{
- cl_status_t status;
- cl_list_iterator_t itor;
-
- /* Note that context can have any arbitrary value. */
- CL_ASSERT(p_list);
- CL_ASSERT(cl_is_qpool_inited(&p_list->list_item_pool));
- CL_ASSERT(pfn_func);
-
- itor = cl_list_head(p_list);
-
- while (itor != cl_list_end(p_list)) {
- status = pfn_func(cl_list_obj(itor), (void *)context);
- if (status == CL_SUCCESS)
- break;
-
- itor = cl_list_next(itor);
- }
-
- /* no match */
- return (itor);
-}
-
-cl_list_iterator_t
-cl_list_find_from_tail(IN const cl_list_t * const p_list,
- IN cl_pfn_list_find_t pfn_func,
- IN const void *const context)
-{
- cl_status_t status;
- cl_list_iterator_t itor;
-
- /* Note that context can have any arbitrary value. */
- CL_ASSERT(p_list);
- CL_ASSERT(cl_is_qpool_inited(&p_list->list_item_pool));
- CL_ASSERT(pfn_func);
-
- itor = cl_list_tail(p_list);
-
- while (itor != cl_list_end(p_list)) {
- status = pfn_func(cl_list_obj(itor), (void *)context);
- if (status == CL_SUCCESS)
- break;
-
- itor = cl_list_prev(itor);
- }
-
- /* no match */
- return (itor);
-}
-
-void
-cl_list_apply_func(IN const cl_list_t * const p_list,
- IN cl_pfn_list_apply_t pfn_func,
- IN const void *const context)
-{
- cl_list_iterator_t itor;
-
- /* Note that context can have any arbitrary value. */
- CL_ASSERT(p_list);
- CL_ASSERT(cl_is_qpool_inited(&p_list->list_item_pool));
- CL_ASSERT(pfn_func);
-
- itor = cl_list_head(p_list);
-
- while (itor != cl_list_end(p_list)) {
- pfn_func(cl_list_obj(itor), (void *)context);
-
- itor = cl_list_next(itor);
- }
-}
diff --git a/contrib/ofed/management/opensm/complib/cl_log.c b/contrib/ofed/management/opensm/complib/cl_log.c
deleted file mode 100644
index a2a1372..0000000
--- a/contrib/ofed/management/opensm/complib/cl_log.c
+++ /dev/null
@@ -1,118 +0,0 @@
-/*
- * Copyright (c) 2004, 2005 Voltaire, Inc. All rights reserved.
- * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved.
- * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- */
-
-#ifdef __WIN__
-#pragma warning(disable : 4996)
-#endif
-
-#if HAVE_CONFIG_H
-# include <config.h>
-#endif /* HAVE_CONFIG_H */
-
-#include <complib/cl_log.h>
-#include <complib/cl_debug.h>
-#include <syslog.h>
-
-/* Maximum number of bytes that can be logged. */
-#define CL_MAX_LOG_DATA (256)
-
-/*
- * Size of the character buffer to allow logging the above
- * number of bytes. A space is added after every DWORD, and
- * a new line is added after 8 DWORDS (for a line length less than 80).
- */
-#define CL_LOG_DATA_SIZE (CL_MAX_LOG_DATA + (CL_MAX_LOG_DATA/4))
-
-void
-cl_log_event(IN const char *const name,
- IN const cl_log_type_t type,
- IN const char *const message,
- IN const void *const p_data OPTIONAL, IN const uint32_t data_len)
-{
- int priority, i;
- char data[CL_LOG_DATA_SIZE];
- char *p_buf;
- uint8_t *p_int_data = (uint8_t *) p_data;
-
- CL_ASSERT(name);
- CL_ASSERT(message);
-
- openlog(name, LOG_NDELAY | LOG_PID, LOG_USER);
- switch (type) {
- case CL_LOG_ERROR:
- priority = LOG_ERR;
- break;
-
- case CL_LOG_WARN:
- priority = LOG_WARNING;
- break;
-
- case CL_LOG_INFO:
- default:
- priority = LOG_INFO;
- break;
- }
-
- if (p_data) {
- CL_ASSERT(data_len);
- if (data_len < CL_MAX_LOG_DATA) {
- p_buf = data;
- /* Format the data into ASCII. */
- for (i = 0; i < data_len; i++) {
- sprintf(p_buf, "%02x", *p_int_data++);
- p_buf += 2;
-
- /* Add line break after 8 DWORDS. */
- if (i % 32) {
- sprintf(p_buf++, "\n");
- continue;
- }
-
- /* Add a space between DWORDS. */
- if (i % 4)
- sprintf(p_buf++, " ");
- }
- syslog(priority, "%s data:\n%s\n", message, p_buf);
- } else {
- /* The data portion is too large to log. */
- cl_msg_out
- ("cl_log() - WARNING: data too large to log.\n");
- syslog(priority, "%s\n", message);
- }
- } else {
- syslog(priority, "%s\n", message);
- }
- closelog();
-}
diff --git a/contrib/ofed/management/opensm/complib/cl_map.c b/contrib/ofed/management/opensm/complib/cl_map.c
deleted file mode 100644
index c0e44be..0000000
--- a/contrib/ofed/management/opensm/complib/cl_map.c
+++ /dev/null
@@ -1,1636 +0,0 @@
-/*
- * Copyright (c) 2004-2006 Voltaire, Inc. All rights reserved.
- * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved.
- * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- */
-
-/*
- * Abstract:
- * Implementation of quick map, a binary tree where the caller always
- * provides all necessary storage.
- *
- */
-
-/*****************************************************************************
-*
-* Map
-*
-* Map is an associative array. By providing a key, the caller can retrieve
-* an object from the map. All objects in the map have an associated key,
-* as specified by the caller when the object was inserted into the map.
-* In addition to random access, the caller can traverse the map much like
-* a linked list, either forwards from the first object or backwards from
-* the last object. The objects in the map are always traversed in
-* order since the nodes are stored sorted.
-*
-* This implementation of Map uses a red black tree verified against
-* Cormen-Leiserson-Rivest text, McGraw-Hill Edition, fourteenth
-* printing, 1994.
-*
-*****************************************************************************/
-
-#if HAVE_CONFIG_H
-# include <config.h>
-#endif /* HAVE_CONFIG_H */
-
-#include <string.h>
-#include <complib/cl_qmap.h>
-#include <complib/cl_map.h>
-#include <complib/cl_fleximap.h>
-
-/******************************************************************************
-*******************************************************************************
-************** ************
-************** IMPLEMENTATION OF QUICK MAP ************
-************** ************
-*******************************************************************************
-******************************************************************************/
-
-/*
- * Get the root.
- */
-static inline cl_map_item_t *__cl_map_root(IN const cl_qmap_t * const p_map)
-{
- CL_ASSERT(p_map);
- return (p_map->root.p_left);
-}
-
-/*
- * Returns whether a given item is on the left of its parent.
- */
-static boolean_t __cl_map_is_left_child(IN const cl_map_item_t * const p_item)
-{
- CL_ASSERT(p_item);
- CL_ASSERT(p_item->p_up);
- CL_ASSERT(p_item->p_up != p_item);
-
- return (p_item->p_up->p_left == p_item);
-}
-
-/*
- * Retrieve the pointer to the parent's pointer to an item.
- */
-static cl_map_item_t **__cl_map_get_parent_ptr_to_item(IN cl_map_item_t *
- const p_item)
-{
- CL_ASSERT(p_item);
- CL_ASSERT(p_item->p_up);
- CL_ASSERT(p_item->p_up != p_item);
-
- if (__cl_map_is_left_child(p_item))
- return (&p_item->p_up->p_left);
-
- CL_ASSERT(p_item->p_up->p_right == p_item);
- return (&p_item->p_up->p_right);
-}
-
-/*
- * Rotate a node to the left. This rotation affects the least number of links
- * between nodes and brings the level of C up by one while increasing the depth
- * of A one. Note that the links to/from W, X, Y, and Z are not affected.
- *
- * R R
- * | |
- * A C
- * / \ / \
- * W C A Z
- * / \ / \
- * B Z W B
- * / \ / \
- * X Y X Y
- */
-static void
-__cl_map_rot_left(IN cl_qmap_t * const p_map, IN cl_map_item_t * const p_item)
-{
- cl_map_item_t **pp_root;
-
- CL_ASSERT(p_map);
- CL_ASSERT(p_item);
- CL_ASSERT(p_item->p_right != &p_map->nil);
-
- pp_root = __cl_map_get_parent_ptr_to_item(p_item);
-
- /* Point R to C instead of A. */
- *pp_root = p_item->p_right;
- /* Set C's parent to R. */
- (*pp_root)->p_up = p_item->p_up;
-
- /* Set A's right to B */
- p_item->p_right = (*pp_root)->p_left;
- /*
- * Set B's parent to A. We trap for B being NIL since the
- * caller may depend on NIL not changing.
- */
- if ((*pp_root)->p_left != &p_map->nil)
- (*pp_root)->p_left->p_up = p_item;
-
- /* Set C's left to A. */
- (*pp_root)->p_left = p_item;
- /* Set A's parent to C. */
- p_item->p_up = *pp_root;
-}
-
-/*
- * Rotate a node to the right. This rotation affects the least number of links
- * between nodes and brings the level of A up by one while increasing the depth
- * of C one. Note that the links to/from W, X, Y, and Z are not affected.
- *
- * R R
- * | |
- * C A
- * / \ / \
- * A Z W C
- * / \ / \
- * W B B Z
- * / \ / \
- * X Y X Y
- */
-static void
-__cl_map_rot_right(IN cl_qmap_t * const p_map, IN cl_map_item_t * const p_item)
-{
- cl_map_item_t **pp_root;
-
- CL_ASSERT(p_map);
- CL_ASSERT(p_item);
- CL_ASSERT(p_item->p_left != &p_map->nil);
-
- /* Point R to A instead of C. */
- pp_root = __cl_map_get_parent_ptr_to_item(p_item);
- (*pp_root) = p_item->p_left;
- /* Set A's parent to R. */
- (*pp_root)->p_up = p_item->p_up;
-
- /* Set C's left to B */
- p_item->p_left = (*pp_root)->p_right;
- /*
- * Set B's parent to C. We trap for B being NIL since the
- * caller may depend on NIL not changing.
- */
- if ((*pp_root)->p_right != &p_map->nil)
- (*pp_root)->p_right->p_up = p_item;
-
- /* Set A's right to C. */
- (*pp_root)->p_right = p_item;
- /* Set C's parent to A. */
- p_item->p_up = *pp_root;
-}
-
-void cl_qmap_init(IN cl_qmap_t * const p_map)
-{
- CL_ASSERT(p_map);
-
- memset(p_map, 0, sizeof(cl_qmap_t));
-
- /* special setup for the root node */
- p_map->root.p_up = &p_map->root;
- p_map->root.p_left = &p_map->nil;
- p_map->root.p_right = &p_map->nil;
- p_map->root.color = CL_MAP_BLACK;
-
- /* Setup the node used as terminator for all leaves. */
- p_map->nil.p_up = &p_map->nil;
- p_map->nil.p_left = &p_map->nil;
- p_map->nil.p_right = &p_map->nil;
- p_map->nil.color = CL_MAP_BLACK;
-
- p_map->state = CL_INITIALIZED;
-
- cl_qmap_remove_all(p_map);
-}
-
-cl_map_item_t *cl_qmap_get(IN const cl_qmap_t * const p_map,
- IN const uint64_t key)
-{
- cl_map_item_t *p_item;
-
- CL_ASSERT(p_map);
- CL_ASSERT(p_map->state == CL_INITIALIZED);
-
- p_item = __cl_map_root(p_map);
-
- while (p_item != &p_map->nil) {
- if (key == p_item->key)
- break; /* just right */
-
- if (key < p_item->key)
- p_item = p_item->p_left; /* too small */
- else
- p_item = p_item->p_right; /* too big */
- }
-
- return (p_item);
-}
-
-cl_map_item_t *cl_qmap_get_next(IN const cl_qmap_t * const p_map,
- IN const uint64_t key)
-{
- cl_map_item_t *p_item;
- cl_map_item_t *p_item_found;
-
- CL_ASSERT(p_map);
- CL_ASSERT(p_map->state == CL_INITIALIZED);
-
- p_item = __cl_map_root(p_map);
- p_item_found = (cl_map_item_t *) & p_map->nil;
-
- while (p_item != &p_map->nil) {
- if (key < p_item->key) {
- p_item_found = p_item;
- p_item = p_item->p_left;
- } else {
- p_item = p_item->p_right;
- }
- }
-
- return (p_item_found);
-}
-
-void
-cl_qmap_apply_func(IN const cl_qmap_t * const p_map,
- IN cl_pfn_qmap_apply_t pfn_func,
- IN const void *const context)
-{
- cl_map_item_t *p_map_item;
-
- /* Note that context can have any arbitrary value. */
- CL_ASSERT(p_map);
- CL_ASSERT(p_map->state == CL_INITIALIZED);
- CL_ASSERT(pfn_func);
-
- p_map_item = cl_qmap_head(p_map);
- while (p_map_item != cl_qmap_end(p_map)) {
- pfn_func(p_map_item, (void *)context);
- p_map_item = cl_qmap_next(p_map_item);
- }
-}
-
-/*
- * Balance a tree starting at a given item back to the root.
- */
-static void
-__cl_map_ins_bal(IN cl_qmap_t * const p_map, IN cl_map_item_t * p_item)
-{
- cl_map_item_t *p_grand_uncle;
-
- CL_ASSERT(p_map);
- CL_ASSERT(p_item);
- CL_ASSERT(p_item != &p_map->root);
-
- while (p_item->p_up->color == CL_MAP_RED) {
- if (__cl_map_is_left_child(p_item->p_up)) {
- p_grand_uncle = p_item->p_up->p_up->p_right;
- CL_ASSERT(p_grand_uncle);
- if (p_grand_uncle->color == CL_MAP_RED) {
- p_grand_uncle->color = CL_MAP_BLACK;
- p_item->p_up->color = CL_MAP_BLACK;
- p_item->p_up->p_up->color = CL_MAP_RED;
- p_item = p_item->p_up->p_up;
- continue;
- }
-
- if (!__cl_map_is_left_child(p_item)) {
- p_item = p_item->p_up;
- __cl_map_rot_left(p_map, p_item);
- }
- p_item->p_up->color = CL_MAP_BLACK;
- p_item->p_up->p_up->color = CL_MAP_RED;
- __cl_map_rot_right(p_map, p_item->p_up->p_up);
- } else {
- p_grand_uncle = p_item->p_up->p_up->p_left;
- CL_ASSERT(p_grand_uncle);
- if (p_grand_uncle->color == CL_MAP_RED) {
- p_grand_uncle->color = CL_MAP_BLACK;
- p_item->p_up->color = CL_MAP_BLACK;
- p_item->p_up->p_up->color = CL_MAP_RED;
- p_item = p_item->p_up->p_up;
- continue;
- }
-
- if (__cl_map_is_left_child(p_item)) {
- p_item = p_item->p_up;
- __cl_map_rot_right(p_map, p_item);
- }
- p_item->p_up->color = CL_MAP_BLACK;
- p_item->p_up->p_up->color = CL_MAP_RED;
- __cl_map_rot_left(p_map, p_item->p_up->p_up);
- }
- }
-}
-
-cl_map_item_t *cl_qmap_insert(IN cl_qmap_t * const p_map,
- IN const uint64_t key,
- IN cl_map_item_t * const p_item)
-{
- cl_map_item_t *p_insert_at, *p_comp_item;
-
- CL_ASSERT(p_map);
- CL_ASSERT(p_map->state == CL_INITIALIZED);
- CL_ASSERT(p_item);
- CL_ASSERT(p_map->root.p_up == &p_map->root);
- CL_ASSERT(p_map->root.color != CL_MAP_RED);
- CL_ASSERT(p_map->nil.color != CL_MAP_RED);
-
- p_item->p_left = &p_map->nil;
- p_item->p_right = &p_map->nil;
- p_item->key = key;
- p_item->color = CL_MAP_RED;
-
- /* Find the insertion location. */
- p_insert_at = &p_map->root;
- p_comp_item = __cl_map_root(p_map);
-
- while (p_comp_item != &p_map->nil) {
- p_insert_at = p_comp_item;
-
- if (key == p_insert_at->key)
- return (p_insert_at);
-
- /* Traverse the tree until the correct insertion point is found. */
- if (key < p_insert_at->key)
- p_comp_item = p_insert_at->p_left;
- else
- p_comp_item = p_insert_at->p_right;
- }
-
- CL_ASSERT(p_insert_at != &p_map->nil);
- CL_ASSERT(p_comp_item == &p_map->nil);
- /* Insert the item. */
- if (p_insert_at == &p_map->root) {
- p_insert_at->p_left = p_item;
- /*
- * Primitive insert places the new item in front of
- * the existing item.
- */
- __cl_primitive_insert(&p_map->nil.pool_item.list_item,
- &p_item->pool_item.list_item);
- } else if (key < p_insert_at->key) {
- p_insert_at->p_left = p_item;
- /*
- * Primitive insert places the new item in front of
- * the existing item.
- */
- __cl_primitive_insert(&p_insert_at->pool_item.list_item,
- &p_item->pool_item.list_item);
- } else {
- p_insert_at->p_right = p_item;
- /*
- * Primitive insert places the new item in front of
- * the existing item.
- */
- __cl_primitive_insert(p_insert_at->pool_item.list_item.p_next,
- &p_item->pool_item.list_item);
- }
- /* Increase the count. */
- p_map->count++;
-
- p_item->p_up = p_insert_at;
-
- /*
- * We have added depth to this section of the tree.
- * Rebalance as necessary as we retrace our path through the tree
- * and update colors.
- */
- __cl_map_ins_bal(p_map, p_item);
-
- __cl_map_root(p_map)->color = CL_MAP_BLACK;
-
- /*
- * Note that it is not necessary to re-color the nil node black because all
- * red color assignments are made via the p_up pointer, and nil is never
- * set as the value of a p_up pointer.
- */
-
-#ifdef _DEBUG_
- /* Set the pointer to the map in the map item for consistency checking. */
- p_item->p_map = p_map;
-#endif
-
- return (p_item);
-}
-
-static void
-__cl_map_del_bal(IN cl_qmap_t * const p_map, IN cl_map_item_t * p_item)
-{
- cl_map_item_t *p_uncle;
-
- while ((p_item->color != CL_MAP_RED) && (p_item->p_up != &p_map->root)) {
- if (__cl_map_is_left_child(p_item)) {
- p_uncle = p_item->p_up->p_right;
-
- if (p_uncle->color == CL_MAP_RED) {
- p_uncle->color = CL_MAP_BLACK;
- p_item->p_up->color = CL_MAP_RED;
- __cl_map_rot_left(p_map, p_item->p_up);
- p_uncle = p_item->p_up->p_right;
- }
-
- if (p_uncle->p_right->color != CL_MAP_RED) {
- if (p_uncle->p_left->color != CL_MAP_RED) {
- p_uncle->color = CL_MAP_RED;
- p_item = p_item->p_up;
- continue;
- }
-
- p_uncle->p_left->color = CL_MAP_BLACK;
- p_uncle->color = CL_MAP_RED;
- __cl_map_rot_right(p_map, p_uncle);
- p_uncle = p_item->p_up->p_right;
- }
- p_uncle->color = p_item->p_up->color;
- p_item->p_up->color = CL_MAP_BLACK;
- p_uncle->p_right->color = CL_MAP_BLACK;
- __cl_map_rot_left(p_map, p_item->p_up);
- break;
- } else {
- p_uncle = p_item->p_up->p_left;
-
- if (p_uncle->color == CL_MAP_RED) {
- p_uncle->color = CL_MAP_BLACK;
- p_item->p_up->color = CL_MAP_RED;
- __cl_map_rot_right(p_map, p_item->p_up);
- p_uncle = p_item->p_up->p_left;
- }
-
- if (p_uncle->p_left->color != CL_MAP_RED) {
- if (p_uncle->p_right->color != CL_MAP_RED) {
- p_uncle->color = CL_MAP_RED;
- p_item = p_item->p_up;
- continue;
- }
-
- p_uncle->p_right->color = CL_MAP_BLACK;
- p_uncle->color = CL_MAP_RED;
- __cl_map_rot_left(p_map, p_uncle);
- p_uncle = p_item->p_up->p_left;
- }
- p_uncle->color = p_item->p_up->color;
- p_item->p_up->color = CL_MAP_BLACK;
- p_uncle->p_left->color = CL_MAP_BLACK;
- __cl_map_rot_right(p_map, p_item->p_up);
- break;
- }
- }
- p_item->color = CL_MAP_BLACK;
-}
-
-void
-cl_qmap_remove_item(IN cl_qmap_t * const p_map, IN cl_map_item_t * const p_item)
-{
- cl_map_item_t *p_child, *p_del_item;
-
- CL_ASSERT(p_map);
- CL_ASSERT(p_map->state == CL_INITIALIZED);
- CL_ASSERT(p_item);
-
- if (p_item == cl_qmap_end(p_map))
- return;
-
- /* must be checked after comparing to cl_qmap_end, since
- the end is not a valid item. */
- CL_ASSERT(p_item->p_map == p_map);
-
- if ((p_item->p_right == &p_map->nil) || (p_item->p_left == &p_map->nil)) {
- /* The item being removed has children on at most on side. */
- p_del_item = p_item;
- } else {
- /*
- * The item being removed has children on both side.
- * We select the item that will replace it. After removing
- * the substitute item and rebalancing, the tree will have the
- * correct topology. Exchanging the substitute for the item
- * will finalize the removal.
- */
- p_del_item = cl_qmap_next(p_item);
- CL_ASSERT(p_del_item != &p_map->nil);
- }
-
- /* Remove the item from the list. */
- __cl_primitive_remove(&p_item->pool_item.list_item);
- /* Decrement the item count. */
- p_map->count--;
-
- /* Get the pointer to the new root's child, if any. */
- if (p_del_item->p_left != &p_map->nil)
- p_child = p_del_item->p_left;
- else
- p_child = p_del_item->p_right;
-
- /*
- * This assignment may modify the parent pointer of the nil node.
- * This is inconsequential.
- */
- p_child->p_up = p_del_item->p_up;
- (*__cl_map_get_parent_ptr_to_item(p_del_item)) = p_child;
-
- if (p_del_item->color != CL_MAP_RED)
- __cl_map_del_bal(p_map, p_child);
-
- /*
- * Note that the splicing done below does not need to occur before
- * the tree is balanced, since the actual topology changes are made by the
- * preceding code. The topology is preserved by the color assignment made
- * below (reader should be reminded that p_del_item == p_item in some cases).
- */
- if (p_del_item != p_item) {
- /*
- * Finalize the removal of the specified item by exchanging it with
- * the substitute which we removed above.
- */
- p_del_item->p_up = p_item->p_up;
- p_del_item->p_left = p_item->p_left;
- p_del_item->p_right = p_item->p_right;
- (*__cl_map_get_parent_ptr_to_item(p_item)) = p_del_item;
- p_item->p_right->p_up = p_del_item;
- p_item->p_left->p_up = p_del_item;
- p_del_item->color = p_item->color;
- }
-
- CL_ASSERT(p_map->nil.color != CL_MAP_RED);
-
-#ifdef _DEBUG_
- /* Clear the pointer to the map since the item has been removed. */
- p_item->p_map = NULL;
-#endif
-}
-
-cl_map_item_t *cl_qmap_remove(IN cl_qmap_t * const p_map, IN const uint64_t key)
-{
- cl_map_item_t *p_item;
-
- CL_ASSERT(p_map);
- CL_ASSERT(p_map->state == CL_INITIALIZED);
-
- /* Seek the node with the specified key */
- p_item = cl_qmap_get(p_map, key);
-
- cl_qmap_remove_item(p_map, p_item);
-
- return (p_item);
-}
-
-void
-cl_qmap_merge(OUT cl_qmap_t * const p_dest_map,
- IN OUT cl_qmap_t * const p_src_map)
-{
- cl_map_item_t *p_item, *p_item2, *p_next;
-
- CL_ASSERT(p_dest_map);
- CL_ASSERT(p_src_map);
-
- p_item = cl_qmap_head(p_src_map);
-
- while (p_item != cl_qmap_end(p_src_map)) {
- p_next = cl_qmap_next(p_item);
-
- /* Remove the item from its current map. */
- cl_qmap_remove_item(p_src_map, p_item);
- /* Insert the item into the destination map. */
- p_item2 =
- cl_qmap_insert(p_dest_map, cl_qmap_key(p_item), p_item);
- /* Check that the item was successfully inserted. */
- if (p_item2 != p_item) {
- /* Put the item in back in the source map. */
- p_item2 =
- cl_qmap_insert(p_src_map, cl_qmap_key(p_item),
- p_item);
- CL_ASSERT(p_item2 == p_item);
- }
- p_item = p_next;
- }
-}
-
-static void
-__cl_qmap_delta_move(IN OUT cl_qmap_t * const p_dest,
- IN OUT cl_qmap_t * const p_src,
- IN OUT cl_map_item_t ** const pp_item)
-{
- cl_map_item_t *p_temp, *p_next;
-
- /*
- * Get the next item so that we can ensure that pp_item points to
- * a valid item upon return from the function.
- */
- p_next = cl_qmap_next(*pp_item);
- /* Move the old item from its current map the the old map. */
- cl_qmap_remove_item(p_src, *pp_item);
- p_temp = cl_qmap_insert(p_dest, cl_qmap_key(*pp_item), *pp_item);
- /* We should never have duplicates. */
- CL_ASSERT(p_temp == *pp_item);
- /* Point pp_item to a valid item in the source map. */
- (*pp_item) = p_next;
-}
-
-void
-cl_qmap_delta(IN OUT cl_qmap_t * const p_map1,
- IN OUT cl_qmap_t * const p_map2,
- OUT cl_qmap_t * const p_new, OUT cl_qmap_t * const p_old)
-{
- cl_map_item_t *p_item1, *p_item2;
- uint64_t key1, key2;
-
- CL_ASSERT(p_map1);
- CL_ASSERT(p_map2);
- CL_ASSERT(p_new);
- CL_ASSERT(p_old);
- CL_ASSERT(cl_is_qmap_empty(p_new));
- CL_ASSERT(cl_is_qmap_empty(p_old));
-
- p_item1 = cl_qmap_head(p_map1);
- p_item2 = cl_qmap_head(p_map2);
-
- while (p_item1 != cl_qmap_end(p_map1) && p_item2 != cl_qmap_end(p_map2)) {
- key1 = cl_qmap_key(p_item1);
- key2 = cl_qmap_key(p_item2);
- if (key1 < key2) {
- /* We found an old item. */
- __cl_qmap_delta_move(p_old, p_map1, &p_item1);
- } else if (key1 > key2) {
- /* We found a new item. */
- __cl_qmap_delta_move(p_new, p_map2, &p_item2);
- } else {
- /* Move both forward since they have the same key. */
- p_item1 = cl_qmap_next(p_item1);
- p_item2 = cl_qmap_next(p_item2);
- }
- }
-
- /* Process the remainder if the end of either source map was reached. */
- while (p_item2 != cl_qmap_end(p_map2))
- __cl_qmap_delta_move(p_new, p_map2, &p_item2);
-
- while (p_item1 != cl_qmap_end(p_map1))
- __cl_qmap_delta_move(p_old, p_map1, &p_item1);
-}
-
-/******************************************************************************
-*******************************************************************************
-************** ************
-************** IMPLEMENTATION OF MAP ************
-************** ************
-*******************************************************************************
-******************************************************************************/
-
-#define MAP_GROW_SIZE 32
-
-void cl_map_construct(IN cl_map_t * const p_map)
-{
- CL_ASSERT(p_map);
-
- cl_qpool_construct(&p_map->pool);
-}
-
-cl_status_t cl_map_init(IN cl_map_t * const p_map, IN const uint32_t min_items)
-{
- uint32_t grow_size;
-
- CL_ASSERT(p_map);
-
- cl_qmap_init(&p_map->qmap);
-
- /*
- * We will grow by min_items/8 items at a time, with a minimum of
- * MAP_GROW_SIZE.
- */
- grow_size = min_items >> 3;
- if (grow_size < MAP_GROW_SIZE)
- grow_size = MAP_GROW_SIZE;
-
- return (cl_qpool_init(&p_map->pool, min_items, 0, grow_size,
- sizeof(cl_map_obj_t), NULL, NULL, NULL));
-}
-
-void cl_map_destroy(IN cl_map_t * const p_map)
-{
- CL_ASSERT(p_map);
-
- cl_qpool_destroy(&p_map->pool);
-}
-
-void *cl_map_insert(IN cl_map_t * const p_map,
- IN const uint64_t key, IN const void *const p_object)
-{
- cl_map_obj_t *p_map_obj, *p_obj_at_key;
-
- CL_ASSERT(p_map);
-
- p_map_obj = (cl_map_obj_t *) cl_qpool_get(&p_map->pool);
-
- if (!p_map_obj)
- return (NULL);
-
- cl_qmap_set_obj(p_map_obj, p_object);
-
- p_obj_at_key =
- (cl_map_obj_t *) cl_qmap_insert(&p_map->qmap, key,
- &p_map_obj->item);
-
- /* Return the item to the pool if insertion failed. */
- if (p_obj_at_key != p_map_obj)
- cl_qpool_put(&p_map->pool, &p_map_obj->item.pool_item);
-
- return (cl_qmap_obj(p_obj_at_key));
-}
-
-void *cl_map_get(IN const cl_map_t * const p_map, IN const uint64_t key)
-{
- cl_map_item_t *p_item;
-
- CL_ASSERT(p_map);
-
- p_item = cl_qmap_get(&p_map->qmap, key);
-
- if (p_item == cl_qmap_end(&p_map->qmap))
- return (NULL);
-
- return (cl_qmap_obj(PARENT_STRUCT(p_item, cl_map_obj_t, item)));
-}
-
-void *cl_map_get_next(IN const cl_map_t * const p_map, IN const uint64_t key)
-{
- cl_map_item_t *p_item;
-
- CL_ASSERT(p_map);
-
- p_item = cl_qmap_get_next(&p_map->qmap, key);
-
- if (p_item == cl_qmap_end(&p_map->qmap))
- return (NULL);
-
- return (cl_qmap_obj(PARENT_STRUCT(p_item, cl_map_obj_t, item)));
-}
-
-void
-cl_map_remove_item(IN cl_map_t * const p_map, IN const cl_map_iterator_t itor)
-{
- CL_ASSERT(itor->p_map == &p_map->qmap);
-
- if (itor == cl_map_end(p_map))
- return;
-
- cl_qmap_remove_item(&p_map->qmap, (cl_map_item_t *) itor);
- cl_qpool_put(&p_map->pool, &((cl_map_item_t *) itor)->pool_item);
-}
-
-void *cl_map_remove(IN cl_map_t * const p_map, IN const uint64_t key)
-{
- cl_map_item_t *p_item;
- void *p_obj;
-
- CL_ASSERT(p_map);
-
- p_item = cl_qmap_remove(&p_map->qmap, key);
-
- if (p_item == cl_qmap_end(&p_map->qmap))
- return (NULL);
-
- p_obj = cl_qmap_obj((cl_map_obj_t *) p_item);
- cl_qpool_put(&p_map->pool, &p_item->pool_item);
-
- return (p_obj);
-}
-
-void cl_map_remove_all(IN cl_map_t * const p_map)
-{
- cl_map_item_t *p_item;
-
- CL_ASSERT(p_map);
-
- /* Return all map items to the pool. */
- while (!cl_is_qmap_empty(&p_map->qmap)) {
- p_item = cl_qmap_head(&p_map->qmap);
- cl_qmap_remove_item(&p_map->qmap, p_item);
- cl_qpool_put(&p_map->pool, &p_item->pool_item);
-
- if (!cl_is_qmap_empty(&p_map->qmap)) {
- p_item = cl_qmap_tail(&p_map->qmap);
- cl_qmap_remove_item(&p_map->qmap, p_item);
- cl_qpool_put(&p_map->pool, &p_item->pool_item);
- }
- }
-}
-
-cl_status_t
-cl_map_merge(OUT cl_map_t * const p_dest_map, IN OUT cl_map_t * const p_src_map)
-{
- cl_status_t status = CL_SUCCESS;
- cl_map_iterator_t itor, next;
- uint64_t key;
- void *p_obj, *p_obj2;
-
- CL_ASSERT(p_dest_map);
- CL_ASSERT(p_src_map);
-
- itor = cl_map_head(p_src_map);
- while (itor != cl_map_end(p_src_map)) {
- next = cl_map_next(itor);
-
- p_obj = cl_map_obj(itor);
- key = cl_map_key(itor);
-
- cl_map_remove_item(p_src_map, itor);
-
- /* Insert the object into the destination map. */
- p_obj2 = cl_map_insert(p_dest_map, key, p_obj);
- /* Trap for failure. */
- if (p_obj != p_obj2) {
- if (!p_obj2)
- status = CL_INSUFFICIENT_MEMORY;
- /* Put the object back in the source map. This must succeed. */
- p_obj2 = cl_map_insert(p_src_map, key, p_obj);
- CL_ASSERT(p_obj == p_obj2);
- /* If the failure was due to insufficient memory, return. */
- if (status != CL_SUCCESS)
- return (status);
- }
- itor = next;
- }
-
- return (CL_SUCCESS);
-}
-
-static void
-__cl_map_revert(IN OUT cl_map_t * const p_map1,
- IN OUT cl_map_t * const p_map2,
- IN OUT cl_map_t * const p_new, IN OUT cl_map_t * const p_old)
-{
- cl_status_t status;
-
- /* Restore the initial state. */
- status = cl_map_merge(p_map1, p_old);
- CL_ASSERT(status == CL_SUCCESS);
- status = cl_map_merge(p_map2, p_new);
- CL_ASSERT(status == CL_SUCCESS);
-}
-
-static cl_status_t
-__cl_map_delta_move(OUT cl_map_t * const p_dest,
- IN OUT cl_map_t * const p_src,
- IN OUT cl_map_iterator_t * const p_itor)
-{
- cl_map_iterator_t next;
- void *p_obj, *p_obj2;
- uint64_t key;
-
- /* Get a valid iterator so we can continue the loop. */
- next = cl_map_next(*p_itor);
- /* Get the pointer to the object for insertion. */
- p_obj = cl_map_obj(*p_itor);
- /* Get the key for the object. */
- key = cl_map_key(*p_itor);
- /* Move the object. */
- cl_map_remove_item(p_src, *p_itor);
- p_obj2 = cl_map_insert(p_dest, key, p_obj);
- /* Check for failure. We should never get a duplicate. */
- if (!p_obj2) {
- p_obj2 = cl_map_insert(p_src, key, p_obj);
- CL_ASSERT(p_obj2 == p_obj);
- return (CL_INSUFFICIENT_MEMORY);
- }
-
- /* We should never get a duplicate */
- CL_ASSERT(p_obj == p_obj2);
- /* Update the iterator so that it is valid. */
- (*p_itor) = next;
-
- return (CL_SUCCESS);
-}
-
-cl_status_t
-cl_map_delta(IN OUT cl_map_t * const p_map1,
- IN OUT cl_map_t * const p_map2,
- OUT cl_map_t * const p_new, OUT cl_map_t * const p_old)
-{
- cl_map_iterator_t itor1, itor2;
- uint64_t key1, key2;
- cl_status_t status;
-
- CL_ASSERT(p_map1);
- CL_ASSERT(p_map2);
- CL_ASSERT(p_new);
- CL_ASSERT(p_old);
- CL_ASSERT(cl_is_map_empty(p_new));
- CL_ASSERT(cl_is_map_empty(p_old));
-
- itor1 = cl_map_head(p_map1);
- itor2 = cl_map_head(p_map2);
-
- /*
- * Note that the check is for the end, since duplicate items will remain
- * in their respective maps.
- */
- while (itor1 != cl_map_end(p_map1) && itor2 != cl_map_end(p_map2)) {
- key1 = cl_map_key(itor1);
- key2 = cl_map_key(itor2);
- if (key1 < key2) {
- status = __cl_map_delta_move(p_old, p_map1, &itor1);
- /* Check for failure. */
- if (status != CL_SUCCESS) {
- /* Restore the initial state. */
- __cl_map_revert(p_map1, p_map2, p_new, p_old);
- /* Return the failure status. */
- return (status);
- }
- } else if (key1 > key2) {
- status = __cl_map_delta_move(p_new, p_map2, &itor2);
- if (status != CL_SUCCESS) {
- /* Restore the initial state. */
- __cl_map_revert(p_map1, p_map2, p_new, p_old);
- /* Return the failure status. */
- return (status);
- }
- } else {
- /* Move both forward since they have the same key. */
- itor1 = cl_map_next(itor1);
- itor2 = cl_map_next(itor2);
- }
- }
-
- /* Process the remainder if either source map is empty. */
- while (itor2 != cl_map_end(p_map2)) {
- status = __cl_map_delta_move(p_new, p_map2, &itor2);
- if (status != CL_SUCCESS) {
- /* Restore the initial state. */
- __cl_map_revert(p_map1, p_map2, p_new, p_old);
- /* Return the failure status. */
- return (status);
- }
- }
-
- while (itor1 != cl_map_end(p_map1)) {
- status = __cl_map_delta_move(p_old, p_map1, &itor1);
- if (status != CL_SUCCESS) {
- /* Restore the initial state. */
- __cl_map_revert(p_map1, p_map2, p_new, p_old);
- /* Return the failure status. */
- return (status);
- }
- }
-
- return (CL_SUCCESS);
-}
-
-/******************************************************************************
-*******************************************************************************
-************** ************
-************** IMPLEMENTATION OF FLEXI MAP ************
-************** ************
-*******************************************************************************
-******************************************************************************/
-
-/*
- * Get the root.
- */
-static inline cl_fmap_item_t *__cl_fmap_root(IN const cl_fmap_t * const p_map)
-{
- CL_ASSERT(p_map);
- return (p_map->root.p_left);
-}
-
-/*
- * Returns whether a given item is on the left of its parent.
- */
-static boolean_t __cl_fmap_is_left_child(IN const cl_fmap_item_t * const p_item)
-{
- CL_ASSERT(p_item);
- CL_ASSERT(p_item->p_up);
- CL_ASSERT(p_item->p_up != p_item);
-
- return (p_item->p_up->p_left == p_item);
-}
-
-/*
- * Retrieve the pointer to the parent's pointer to an item.
- */
-static cl_fmap_item_t **__cl_fmap_get_parent_ptr_to_item(IN cl_fmap_item_t *
- const p_item)
-{
- CL_ASSERT(p_item);
- CL_ASSERT(p_item->p_up);
- CL_ASSERT(p_item->p_up != p_item);
-
- if (__cl_fmap_is_left_child(p_item))
- return (&p_item->p_up->p_left);
-
- CL_ASSERT(p_item->p_up->p_right == p_item);
- return (&p_item->p_up->p_right);
-}
-
-/*
- * Rotate a node to the left. This rotation affects the least number of links
- * between nodes and brings the level of C up by one while increasing the depth
- * of A one. Note that the links to/from W, X, Y, and Z are not affected.
- *
- * R R
- * | |
- * A C
- * / \ / \
- * W C A Z
- * / \ / \
- * B Z W B
- * / \ / \
- * X Y X Y
- */
-static void
-__cl_fmap_rot_left(IN cl_fmap_t * const p_map, IN cl_fmap_item_t * const p_item)
-{
- cl_fmap_item_t **pp_root;
-
- CL_ASSERT(p_map);
- CL_ASSERT(p_item);
- CL_ASSERT(p_item->p_right != &p_map->nil);
-
- pp_root = __cl_fmap_get_parent_ptr_to_item(p_item);
-
- /* Point R to C instead of A. */
- *pp_root = p_item->p_right;
- /* Set C's parent to R. */
- (*pp_root)->p_up = p_item->p_up;
-
- /* Set A's right to B */
- p_item->p_right = (*pp_root)->p_left;
- /*
- * Set B's parent to A. We trap for B being NIL since the
- * caller may depend on NIL not changing.
- */
- if ((*pp_root)->p_left != &p_map->nil)
- (*pp_root)->p_left->p_up = p_item;
-
- /* Set C's left to A. */
- (*pp_root)->p_left = p_item;
- /* Set A's parent to C. */
- p_item->p_up = *pp_root;
-}
-
-/*
- * Rotate a node to the right. This rotation affects the least number of links
- * between nodes and brings the level of A up by one while increasing the depth
- * of C one. Note that the links to/from W, X, Y, and Z are not affected.
- *
- * R R
- * | |
- * C A
- * / \ / \
- * A Z W C
- * / \ / \
- * W B B Z
- * / \ / \
- * X Y X Y
- */
-static void
-__cl_fmap_rot_right(IN cl_fmap_t * const p_map,
- IN cl_fmap_item_t * const p_item)
-{
- cl_fmap_item_t **pp_root;
-
- CL_ASSERT(p_map);
- CL_ASSERT(p_item);
- CL_ASSERT(p_item->p_left != &p_map->nil);
-
- /* Point R to A instead of C. */
- pp_root = __cl_fmap_get_parent_ptr_to_item(p_item);
- (*pp_root) = p_item->p_left;
- /* Set A's parent to R. */
- (*pp_root)->p_up = p_item->p_up;
-
- /* Set C's left to B */
- p_item->p_left = (*pp_root)->p_right;
- /*
- * Set B's parent to C. We trap for B being NIL since the
- * caller may depend on NIL not changing.
- */
- if ((*pp_root)->p_right != &p_map->nil)
- (*pp_root)->p_right->p_up = p_item;
-
- /* Set A's right to C. */
- (*pp_root)->p_right = p_item;
- /* Set C's parent to A. */
- p_item->p_up = *pp_root;
-}
-
-void cl_fmap_init(IN cl_fmap_t * const p_map, IN cl_pfn_fmap_cmp_t pfn_compare)
-{
- CL_ASSERT(p_map);
- CL_ASSERT(pfn_compare);
-
- memset(p_map, 0, sizeof(cl_fmap_t));
-
- /* special setup for the root node */
- p_map->root.p_up = &p_map->root;
- p_map->root.p_left = &p_map->nil;
- p_map->root.p_right = &p_map->nil;
- p_map->root.color = CL_MAP_BLACK;
-
- /* Setup the node used as terminator for all leaves. */
- p_map->nil.p_up = &p_map->nil;
- p_map->nil.p_left = &p_map->nil;
- p_map->nil.p_right = &p_map->nil;
- p_map->nil.color = CL_MAP_BLACK;
-
- /* Store the compare function pointer. */
- p_map->pfn_compare = pfn_compare;
-
- p_map->state = CL_INITIALIZED;
-
- cl_fmap_remove_all(p_map);
-}
-
-cl_fmap_item_t *cl_fmap_get(IN const cl_fmap_t * const p_map,
- IN const void *const p_key)
-{
- cl_fmap_item_t *p_item;
- intn_t cmp;
-
- CL_ASSERT(p_map);
- CL_ASSERT(p_map->state == CL_INITIALIZED);
-
- p_item = __cl_fmap_root(p_map);
-
- while (p_item != &p_map->nil) {
- cmp = p_map->pfn_compare(p_key, p_item->p_key);
-
- if (!cmp)
- break; /* just right */
-
- if (cmp < 0)
- p_item = p_item->p_left; /* too small */
- else
- p_item = p_item->p_right; /* too big */
- }
-
- return (p_item);
-}
-
-cl_fmap_item_t *cl_fmap_get_next(IN const cl_fmap_t * const p_map,
- IN const void *const p_key)
-{
- cl_fmap_item_t *p_item;
- cl_fmap_item_t *p_item_found;
- intn_t cmp;
-
- CL_ASSERT(p_map);
- CL_ASSERT(p_map->state == CL_INITIALIZED);
-
- p_item = __cl_fmap_root(p_map);
- p_item_found = (cl_fmap_item_t *) & p_map->nil;
-
- while (p_item != &p_map->nil) {
- cmp = p_map->pfn_compare(p_key, p_item->p_key);
-
- if (cmp < 0) {
- p_item_found = p_item;
- p_item = p_item->p_left; /* too small */
- } else {
- p_item = p_item->p_right; /* too big or match */
- }
- }
-
- return (p_item_found);
-}
-
-void
-cl_fmap_apply_func(IN const cl_fmap_t * const p_map,
- IN cl_pfn_fmap_apply_t pfn_func,
- IN const void *const context)
-{
- cl_fmap_item_t *p_fmap_item;
-
- /* Note that context can have any arbitrary value. */
- CL_ASSERT(p_map);
- CL_ASSERT(p_map->state == CL_INITIALIZED);
- CL_ASSERT(pfn_func);
-
- p_fmap_item = cl_fmap_head(p_map);
- while (p_fmap_item != cl_fmap_end(p_map)) {
- pfn_func(p_fmap_item, (void *)context);
- p_fmap_item = cl_fmap_next(p_fmap_item);
- }
-}
-
-/*
- * Balance a tree starting at a given item back to the root.
- */
-static void
-__cl_fmap_ins_bal(IN cl_fmap_t * const p_map, IN cl_fmap_item_t * p_item)
-{
- cl_fmap_item_t *p_grand_uncle;
-
- CL_ASSERT(p_map);
- CL_ASSERT(p_item);
- CL_ASSERT(p_item != &p_map->root);
-
- while (p_item->p_up->color == CL_MAP_RED) {
- if (__cl_fmap_is_left_child(p_item->p_up)) {
- p_grand_uncle = p_item->p_up->p_up->p_right;
- CL_ASSERT(p_grand_uncle);
- if (p_grand_uncle->color == CL_MAP_RED) {
- p_grand_uncle->color = CL_MAP_BLACK;
- p_item->p_up->color = CL_MAP_BLACK;
- p_item->p_up->p_up->color = CL_MAP_RED;
- p_item = p_item->p_up->p_up;
- continue;
- }
-
- if (!__cl_fmap_is_left_child(p_item)) {
- p_item = p_item->p_up;
- __cl_fmap_rot_left(p_map, p_item);
- }
- p_item->p_up->color = CL_MAP_BLACK;
- p_item->p_up->p_up->color = CL_MAP_RED;
- __cl_fmap_rot_right(p_map, p_item->p_up->p_up);
- } else {
- p_grand_uncle = p_item->p_up->p_up->p_left;
- CL_ASSERT(p_grand_uncle);
- if (p_grand_uncle->color == CL_MAP_RED) {
- p_grand_uncle->color = CL_MAP_BLACK;
- p_item->p_up->color = CL_MAP_BLACK;
- p_item->p_up->p_up->color = CL_MAP_RED;
- p_item = p_item->p_up->p_up;
- continue;
- }
-
- if (__cl_fmap_is_left_child(p_item)) {
- p_item = p_item->p_up;
- __cl_fmap_rot_right(p_map, p_item);
- }
- p_item->p_up->color = CL_MAP_BLACK;
- p_item->p_up->p_up->color = CL_MAP_RED;
- __cl_fmap_rot_left(p_map, p_item->p_up->p_up);
- }
- }
-}
-
-cl_fmap_item_t *cl_fmap_insert(IN cl_fmap_t * const p_map,
- IN const void *const p_key,
- IN cl_fmap_item_t * const p_item)
-{
- cl_fmap_item_t *p_insert_at, *p_comp_item;
- intn_t cmp = 0;
-
- CL_ASSERT(p_map);
- CL_ASSERT(p_map->state == CL_INITIALIZED);
- CL_ASSERT(p_item);
- CL_ASSERT(p_map->root.p_up == &p_map->root);
- CL_ASSERT(p_map->root.color != CL_MAP_RED);
- CL_ASSERT(p_map->nil.color != CL_MAP_RED);
-
- p_item->p_left = &p_map->nil;
- p_item->p_right = &p_map->nil;
- p_item->p_key = p_key;
- p_item->color = CL_MAP_RED;
-
- /* Find the insertion location. */
- p_insert_at = &p_map->root;
- p_comp_item = __cl_fmap_root(p_map);
-
- while (p_comp_item != &p_map->nil) {
- p_insert_at = p_comp_item;
-
- cmp = p_map->pfn_compare(p_key, p_insert_at->p_key);
-
- if (!cmp)
- return (p_insert_at);
-
- /* Traverse the tree until the correct insertion point is found. */
- if (cmp < 0)
- p_comp_item = p_insert_at->p_left;
- else
- p_comp_item = p_insert_at->p_right;
- }
-
- CL_ASSERT(p_insert_at != &p_map->nil);
- CL_ASSERT(p_comp_item == &p_map->nil);
- /* Insert the item. */
- if (p_insert_at == &p_map->root) {
- p_insert_at->p_left = p_item;
- /*
- * Primitive insert places the new item in front of
- * the existing item.
- */
- __cl_primitive_insert(&p_map->nil.pool_item.list_item,
- &p_item->pool_item.list_item);
- } else if (cmp < 0) {
- p_insert_at->p_left = p_item;
- /*
- * Primitive insert places the new item in front of
- * the existing item.
- */
- __cl_primitive_insert(&p_insert_at->pool_item.list_item,
- &p_item->pool_item.list_item);
- } else {
- p_insert_at->p_right = p_item;
- /*
- * Primitive insert places the new item in front of
- * the existing item.
- */
- __cl_primitive_insert(p_insert_at->pool_item.list_item.p_next,
- &p_item->pool_item.list_item);
- }
- /* Increase the count. */
- p_map->count++;
-
- p_item->p_up = p_insert_at;
-
- /*
- * We have added depth to this section of the tree.
- * Rebalance as necessary as we retrace our path through the tree
- * and update colors.
- */
- __cl_fmap_ins_bal(p_map, p_item);
-
- __cl_fmap_root(p_map)->color = CL_MAP_BLACK;
-
- /*
- * Note that it is not necessary to re-color the nil node black because all
- * red color assignments are made via the p_up pointer, and nil is never
- * set as the value of a p_up pointer.
- */
-
-#ifdef _DEBUG_
- /* Set the pointer to the map in the map item for consistency checking. */
- p_item->p_map = p_map;
-#endif
-
- return (p_item);
-}
-
-static void
-__cl_fmap_del_bal(IN cl_fmap_t * const p_map, IN cl_fmap_item_t * p_item)
-{
- cl_fmap_item_t *p_uncle;
-
- while ((p_item->color != CL_MAP_RED) && (p_item->p_up != &p_map->root)) {
- if (__cl_fmap_is_left_child(p_item)) {
- p_uncle = p_item->p_up->p_right;
-
- if (p_uncle->color == CL_MAP_RED) {
- p_uncle->color = CL_MAP_BLACK;
- p_item->p_up->color = CL_MAP_RED;
- __cl_fmap_rot_left(p_map, p_item->p_up);
- p_uncle = p_item->p_up->p_right;
- }
-
- if (p_uncle->p_right->color != CL_MAP_RED) {
- if (p_uncle->p_left->color != CL_MAP_RED) {
- p_uncle->color = CL_MAP_RED;
- p_item = p_item->p_up;
- continue;
- }
-
- p_uncle->p_left->color = CL_MAP_BLACK;
- p_uncle->color = CL_MAP_RED;
- __cl_fmap_rot_right(p_map, p_uncle);
- p_uncle = p_item->p_up->p_right;
- }
- p_uncle->color = p_item->p_up->color;
- p_item->p_up->color = CL_MAP_BLACK;
- p_uncle->p_right->color = CL_MAP_BLACK;
- __cl_fmap_rot_left(p_map, p_item->p_up);
- break;
- } else {
- p_uncle = p_item->p_up->p_left;
-
- if (p_uncle->color == CL_MAP_RED) {
- p_uncle->color = CL_MAP_BLACK;
- p_item->p_up->color = CL_MAP_RED;
- __cl_fmap_rot_right(p_map, p_item->p_up);
- p_uncle = p_item->p_up->p_left;
- }
-
- if (p_uncle->p_left->color != CL_MAP_RED) {
- if (p_uncle->p_right->color != CL_MAP_RED) {
- p_uncle->color = CL_MAP_RED;
- p_item = p_item->p_up;
- continue;
- }
-
- p_uncle->p_right->color = CL_MAP_BLACK;
- p_uncle->color = CL_MAP_RED;
- __cl_fmap_rot_left(p_map, p_uncle);
- p_uncle = p_item->p_up->p_left;
- }
- p_uncle->color = p_item->p_up->color;
- p_item->p_up->color = CL_MAP_BLACK;
- p_uncle->p_left->color = CL_MAP_BLACK;
- __cl_fmap_rot_right(p_map, p_item->p_up);
- break;
- }
- }
- p_item->color = CL_MAP_BLACK;
-}
-
-void
-cl_fmap_remove_item(IN cl_fmap_t * const p_map,
- IN cl_fmap_item_t * const p_item)
-{
- cl_fmap_item_t *p_child, *p_del_item;
-
- CL_ASSERT(p_map);
- CL_ASSERT(p_map->state == CL_INITIALIZED);
- CL_ASSERT(p_item);
- CL_ASSERT(p_item->p_map == p_map);
-
- if (p_item == cl_fmap_end(p_map))
- return;
-
- if ((p_item->p_right == &p_map->nil) || (p_item->p_left == &p_map->nil)) {
- /* The item being removed has children on at most on side. */
- p_del_item = p_item;
- } else {
- /*
- * The item being removed has children on both side.
- * We select the item that will replace it. After removing
- * the substitute item and rebalancing, the tree will have the
- * correct topology. Exchanging the substitute for the item
- * will finalize the removal.
- */
- p_del_item = cl_fmap_next(p_item);
- CL_ASSERT(p_del_item != &p_map->nil);
- }
-
- /* Remove the item from the list. */
- __cl_primitive_remove(&p_item->pool_item.list_item);
- /* Decrement the item count. */
- p_map->count--;
-
- /* Get the pointer to the new root's child, if any. */
- if (p_del_item->p_left != &p_map->nil)
- p_child = p_del_item->p_left;
- else
- p_child = p_del_item->p_right;
-
- /*
- * This assignment may modify the parent pointer of the nil node.
- * This is inconsequential.
- */
- p_child->p_up = p_del_item->p_up;
- (*__cl_fmap_get_parent_ptr_to_item(p_del_item)) = p_child;
-
- if (p_del_item->color != CL_MAP_RED)
- __cl_fmap_del_bal(p_map, p_child);
-
- /*
- * Note that the splicing done below does not need to occur before
- * the tree is balanced, since the actual topology changes are made by the
- * preceding code. The topology is preserved by the color assignment made
- * below (reader should be reminded that p_del_item == p_item in some cases).
- */
- if (p_del_item != p_item) {
- /*
- * Finalize the removal of the specified item by exchanging it with
- * the substitute which we removed above.
- */
- p_del_item->p_up = p_item->p_up;
- p_del_item->p_left = p_item->p_left;
- p_del_item->p_right = p_item->p_right;
- (*__cl_fmap_get_parent_ptr_to_item(p_item)) = p_del_item;
- p_item->p_right->p_up = p_del_item;
- p_item->p_left->p_up = p_del_item;
- p_del_item->color = p_item->color;
- }
-
- CL_ASSERT(p_map->nil.color != CL_MAP_RED);
-
-#ifdef _DEBUG_
- /* Clear the pointer to the map since the item has been removed. */
- p_item->p_map = NULL;
-#endif
-}
-
-cl_fmap_item_t *cl_fmap_remove(IN cl_fmap_t * const p_map,
- IN const void *const p_key)
-{
- cl_fmap_item_t *p_item;
-
- CL_ASSERT(p_map);
- CL_ASSERT(p_map->state == CL_INITIALIZED);
-
- /* Seek the node with the specified key */
- p_item = cl_fmap_get(p_map, p_key);
-
- cl_fmap_remove_item(p_map, p_item);
-
- return (p_item);
-}
-
-void
-cl_fmap_merge(OUT cl_fmap_t * const p_dest_map,
- IN OUT cl_fmap_t * const p_src_map)
-{
- cl_fmap_item_t *p_item, *p_item2, *p_next;
-
- CL_ASSERT(p_dest_map);
- CL_ASSERT(p_src_map);
-
- p_item = cl_fmap_head(p_src_map);
-
- while (p_item != cl_fmap_end(p_src_map)) {
- p_next = cl_fmap_next(p_item);
-
- /* Remove the item from its current map. */
- cl_fmap_remove_item(p_src_map, p_item);
- /* Insert the item into the destination map. */
- p_item2 =
- cl_fmap_insert(p_dest_map, cl_fmap_key(p_item), p_item);
- /* Check that the item was successfully inserted. */
- if (p_item2 != p_item) {
- /* Put the item in back in the source map. */
- p_item2 =
- cl_fmap_insert(p_src_map, cl_fmap_key(p_item),
- p_item);
- CL_ASSERT(p_item2 == p_item);
- }
- p_item = p_next;
- }
-}
-
-static void
-__cl_fmap_delta_move(IN OUT cl_fmap_t * const p_dest,
- IN OUT cl_fmap_t * const p_src,
- IN OUT cl_fmap_item_t ** const pp_item)
-{
- cl_fmap_item_t *p_temp, *p_next;
-
- /*
- * Get the next item so that we can ensure that pp_item points to
- * a valid item upon return from the function.
- */
- p_next = cl_fmap_next(*pp_item);
- /* Move the old item from its current map the the old map. */
- cl_fmap_remove_item(p_src, *pp_item);
- p_temp = cl_fmap_insert(p_dest, cl_fmap_key(*pp_item), *pp_item);
- /* We should never have duplicates. */
- CL_ASSERT(p_temp == *pp_item);
- /* Point pp_item to a valid item in the source map. */
- (*pp_item) = p_next;
-}
-
-void
-cl_fmap_delta(IN OUT cl_fmap_t * const p_map1,
- IN OUT cl_fmap_t * const p_map2,
- OUT cl_fmap_t * const p_new, OUT cl_fmap_t * const p_old)
-{
- cl_fmap_item_t *p_item1, *p_item2;
- intn_t cmp;
-
- CL_ASSERT(p_map1);
- CL_ASSERT(p_map2);
- CL_ASSERT(p_new);
- CL_ASSERT(p_old);
- CL_ASSERT(cl_is_fmap_empty(p_new));
- CL_ASSERT(cl_is_fmap_empty(p_old));
-
- p_item1 = cl_fmap_head(p_map1);
- p_item2 = cl_fmap_head(p_map2);
-
- while (p_item1 != cl_fmap_end(p_map1) && p_item2 != cl_fmap_end(p_map2)) {
- cmp = p_map1->pfn_compare(cl_fmap_key(p_item1),
- cl_fmap_key(p_item2));
- if (cmp < 0) {
- /* We found an old item. */
- __cl_fmap_delta_move(p_old, p_map1, &p_item1);
- } else if (cmp > 0) {
- /* We found a new item. */
- __cl_fmap_delta_move(p_new, p_map2, &p_item2);
- } else {
- /* Move both forward since they have the same key. */
- p_item1 = cl_fmap_next(p_item1);
- p_item2 = cl_fmap_next(p_item2);
- }
- }
-
- /* Process the remainder if the end of either source map was reached. */
- while (p_item2 != cl_fmap_end(p_map2))
- __cl_fmap_delta_move(p_new, p_map2, &p_item2);
-
- while (p_item1 != cl_fmap_end(p_map1))
- __cl_fmap_delta_move(p_old, p_map1, &p_item1);
-}
diff --git a/contrib/ofed/management/opensm/complib/cl_nodenamemap.c b/contrib/ofed/management/opensm/complib/cl_nodenamemap.c
deleted file mode 100644
index 4c6e8a4..0000000
--- a/contrib/ofed/management/opensm/complib/cl_nodenamemap.c
+++ /dev/null
@@ -1,194 +0,0 @@
-/*
- * Copyright (c) 2008 Voltaire, Inc. All rights reserved.
- * Copyright (c) 2007 Lawrence Livermore National Lab
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- */
-
-#define _GNU_SOURCE
-#include <stdio.h>
-#include <errno.h>
-#include <string.h>
-#include <stdlib.h>
-#include <stdarg.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <unistd.h>
-#include <ctype.h>
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <complib/cl_nodenamemap.h>
-
-static int map_name(void *cxt, uint64_t guid, char *p)
-{
- cl_qmap_t *map = cxt;
- name_map_item_t *item;
-
- p = strtok(p, "\"#");
- if (!p)
- return 0;
-
- item = malloc(sizeof(*item));
- if (!item)
- return -1;
- item->guid = guid;
- item->name = strdup(p);
- cl_qmap_insert(map, item->guid, (cl_map_item_t *)item);
- return 0;
-}
-
-nn_map_t *
-open_node_name_map(char *node_name_map)
-{
- nn_map_t *map;
-
- if (!node_name_map) {
-#ifdef HAVE_DEFAULT_NODENAME_MAP
- struct stat buf;
- node_name_map = HAVE_DEFAULT_NODENAME_MAP;
- if (stat(node_name_map, &buf))
- return NULL;
-#else
- return NULL;
-#endif /* HAVE_DEFAULT_NODENAME_MAP */
- }
-
- map = malloc(sizeof(*map));
- if (!map)
- return NULL;
- cl_qmap_init(map);
-
- if (parse_node_map(node_name_map, map_name, map)) {
- fprintf(stderr,
- "WARNING failed to open node name map \"%s\" (%s)\n",
- node_name_map, strerror(errno));
- close_node_name_map(map);
- return NULL;
- }
-
- return map;
-}
-
-void
-close_node_name_map(nn_map_t *map)
-{
- name_map_item_t *item = NULL;
-
- if (!map)
- return;
-
- item = (name_map_item_t *)cl_qmap_head(map);
- while (item != (name_map_item_t *)cl_qmap_end(map)) {
- item = (name_map_item_t *)cl_qmap_remove(map, item->guid);
- free(item->name);
- free(item);
- item = (name_map_item_t *)cl_qmap_head(map);
- }
- free(map);
-}
-
-char *
-remap_node_name(nn_map_t *map, uint64_t target_guid, char *nodedesc)
-{
- char *rc = NULL;
- name_map_item_t *item = NULL;
-
- if (!map)
- goto done;
-
- item = (name_map_item_t *)cl_qmap_get(map, target_guid);
- if (item != (name_map_item_t *)cl_qmap_end(map))
- rc = strdup(item->name);
-
-done:
- if (rc == NULL)
- rc = strdup(clean_nodedesc(nodedesc));
- return (rc);
-}
-
-char *
-clean_nodedesc(char *nodedesc)
-{
- int i = 0;
-
- nodedesc[63] = '\0';
- while (nodedesc[i]) {
- if (!isprint(nodedesc[i]))
- nodedesc[i] = ' ';
- i++;
- }
-
- return (nodedesc);
-}
-
-int parse_node_map(const char *file_name,
- int (*create)(void *, uint64_t, char *), void *cxt)
-{
- char line[256];
- FILE *f;
-
- if (!(f = fopen(file_name, "r")))
- return -1;
-
- while (fgets(line, sizeof(line), f)) {
- uint64_t guid;
- char *p, *e;
-
- p = line;
- while (isspace(*p))
- p++;
- if (*p == '\0' || *p == '\n' || *p == '#')
- continue;
-
- guid = strtoull(p, &e, 0);
- if (e == p || (!isspace(*e) && *e != '#' && *e != '\0')) {
- fclose(f);
- return -1;
- }
-
- p = e;
- while (isspace(*p))
- p++;
-
- e = strpbrk(p, "\n");
- if (e)
- *e = '\0';
-
- if (create(cxt, guid, p)) {
- fclose(f);
- return -1;
- }
- }
-
- fclose(f);
- return 0;
-}
diff --git a/contrib/ofed/management/opensm/complib/cl_pool.c b/contrib/ofed/management/opensm/complib/cl_pool.c
deleted file mode 100644
index 0790304..0000000
--- a/contrib/ofed/management/opensm/complib/cl_pool.c
+++ /dev/null
@@ -1,671 +0,0 @@
-/*
- * Copyright (c) 2004-2006 Voltaire, Inc. All rights reserved.
- * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved.
- * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- */
-
-/*
- * Abstract:
- * Implementation of the grow pools. The grow pools manage a pool of objects.
- * The pools can grow to meet demand, limited only by system memory.
- *
- */
-
-#if HAVE_CONFIG_H
-# include <config.h>
-#endif /* HAVE_CONFIG_H */
-
-#include <stdlib.h>
-#include <string.h>
-#include <complib/cl_qcomppool.h>
-#include <complib/cl_comppool.h>
-#include <complib/cl_qpool.h>
-#include <complib/cl_pool.h>
-#include <complib/cl_math.h>
-
-/*
- * IMPLEMENTATION OF QUICK COMPOSITE POOL
- */
-void cl_qcpool_construct(IN cl_qcpool_t * const p_pool)
-{
- CL_ASSERT(p_pool);
-
- memset(p_pool, 0, sizeof(cl_qcpool_t));
-
- p_pool->state = CL_UNINITIALIZED;
-}
-
-cl_status_t
-cl_qcpool_init(IN cl_qcpool_t * const p_pool,
- IN const size_t min_size,
- IN const size_t max_size,
- IN const size_t grow_size,
- IN const size_t * const component_sizes,
- IN const uint32_t num_components,
- IN cl_pfn_qcpool_init_t pfn_initializer OPTIONAL,
- IN cl_pfn_qcpool_dtor_t pfn_destructor OPTIONAL,
- IN const void *const context)
-{
- cl_status_t status;
- uint32_t i;
-
- CL_ASSERT(p_pool);
- /* Must have a minimum of 1 component. */
- CL_ASSERT(num_components);
- /* A component size array is required. */
- CL_ASSERT(component_sizes);
- /*
- * If no initializer is provided, the first component must be large
- * enough to hold a pool item.
- */
- CL_ASSERT(pfn_initializer ||
- (component_sizes[0] >= sizeof(cl_pool_item_t)));
-
- cl_qcpool_construct(p_pool);
-
- if (num_components > 1 && !pfn_initializer)
- return (CL_INVALID_SETTING);
-
- if (max_size && max_size < min_size)
- return (CL_INVALID_SETTING);
-
- /*
- * Allocate the array of component sizes and component pointers all
- * in one allocation.
- */
- p_pool->component_sizes = (size_t *) malloc((sizeof(size_t) +
- sizeof(void *)) *
- num_components);
-
- if (!p_pool->component_sizes)
- return (CL_INSUFFICIENT_MEMORY);
- else
- memset(p_pool->component_sizes, 0,
- (sizeof(size_t) + sizeof(void *)) * num_components);
-
- /* Calculate the pointer to the array of pointers, used for callbacks. */
- p_pool->p_components =
- (void **)(p_pool->component_sizes + num_components);
-
- /* Copy the user's sizes into our array for future use. */
- memcpy(p_pool->component_sizes, component_sizes,
- sizeof(component_sizes[0]) * num_components);
-
- /* Store the number of components per object. */
- p_pool->num_components = num_components;
-
- /* Round up and store the size of the components. */
- for (i = 0; i < num_components; i++) {
- /*
- * We roundup each component size so that all components
- * are aligned on a natural boundary.
- */
- p_pool->component_sizes[i] =
- ROUNDUP(p_pool->component_sizes[i], sizeof(uintn_t));
- }
-
- p_pool->max_objects = max_size ? max_size : ~(size_t) 0;
- p_pool->grow_size = grow_size;
-
- /* Store callback function pointers. */
- p_pool->pfn_init = pfn_initializer; /* may be NULL */
- p_pool->pfn_dtor = pfn_destructor; /* may be NULL */
- p_pool->context = context;
-
- cl_qlist_init(&p_pool->alloc_list);
-
- cl_qlist_init(&p_pool->free_list);
-
- /*
- * We are now initialized. We change the initialized flag before
- * growing since the grow function asserts that we are initialized.
- */
- p_pool->state = CL_INITIALIZED;
-
- /* Allocate the minimum number of objects as requested. */
- if (!min_size)
- return (CL_SUCCESS);
-
- status = cl_qcpool_grow(p_pool, min_size);
- /* Trap for error and cleanup if necessary. */
- if (status != CL_SUCCESS)
- cl_qcpool_destroy(p_pool);
-
- return (status);
-}
-
-void cl_qcpool_destroy(IN cl_qcpool_t * const p_pool)
-{
- /* CL_ASSERT that a non-NULL pointer was provided. */
- CL_ASSERT(p_pool);
- /* CL_ASSERT that we are in a valid state (not uninitialized memory). */
- CL_ASSERT(cl_is_state_valid(p_pool->state));
-
- if (p_pool->state == CL_INITIALIZED) {
- /*
- * Assert if the user hasn't put everything back in the pool
- * before destroying it
- * if they haven't, then most likely they are still using memory
- * that will be freed, and the destructor will not be called!
- */
-#ifdef _DEBUG_
- /* but we do not want "free" version to assert on this one */
- CL_ASSERT(cl_qcpool_count(p_pool) == p_pool->num_objects);
-#endif
- /* call the user's destructor for each object in the pool */
- if (p_pool->pfn_dtor) {
- while (!cl_is_qlist_empty(&p_pool->free_list)) {
- p_pool->pfn_dtor((cl_pool_item_t *)
- cl_qlist_remove_head(&p_pool->
- free_list),
- (void *)p_pool->context);
- }
- } else {
- cl_qlist_remove_all(&p_pool->free_list);
- }
-
- /* Free all allocated memory blocks. */
- while (!cl_is_qlist_empty(&p_pool->alloc_list))
- free(cl_qlist_remove_head(&p_pool->alloc_list));
-
- if (p_pool->component_sizes) {
- free(p_pool->component_sizes);
- p_pool->component_sizes = NULL;
- }
- }
-
- p_pool->state = CL_UNINITIALIZED;
-}
-
-cl_status_t cl_qcpool_grow(IN cl_qcpool_t * const p_pool, IN size_t obj_count)
-{
- cl_status_t status = CL_SUCCESS;
- uint8_t *p_objects;
- cl_pool_item_t *p_pool_item;
- uint32_t i;
- size_t obj_size;
-
- CL_ASSERT(p_pool);
- CL_ASSERT(p_pool->state == CL_INITIALIZED);
- CL_ASSERT(obj_count);
-
- /* Validate that growth is possible. */
- if (p_pool->num_objects == p_pool->max_objects)
- return (CL_INSUFFICIENT_MEMORY);
-
- /* Cap the growth to the desired maximum. */
- if (obj_count > (p_pool->max_objects - p_pool->num_objects))
- obj_count = p_pool->max_objects - p_pool->num_objects;
-
- /* Calculate the size of an object. */
- obj_size = 0;
- for (i = 0; i < p_pool->num_components; i++)
- obj_size += p_pool->component_sizes[i];
-
- /* Allocate the buffer for the new objects. */
- p_objects = (uint8_t *)
- malloc(sizeof(cl_list_item_t) + (obj_size * obj_count));
-
- /* Make sure the allocation succeeded. */
- if (!p_objects)
- return (CL_INSUFFICIENT_MEMORY);
- else
- memset(p_objects, 0,
- sizeof(cl_list_item_t) + (obj_size * obj_count));
-
- /* Insert the allocation in our list. */
- cl_qlist_insert_tail(&p_pool->alloc_list, (cl_list_item_t *) p_objects);
- p_objects += sizeof(cl_list_item_t);
-
- /* initialize the new elements and add them to the free list */
- while (obj_count--) {
- /* Setup the array of components for the current object. */
- p_pool->p_components[0] = p_objects;
- for (i = 1; i < p_pool->num_components; i++) {
- /* Calculate the pointer to the next component. */
- p_pool->p_components[i] =
- (uint8_t *) p_pool->p_components[i - 1] +
- p_pool->component_sizes[i - 1];
- }
-
- /*
- * call the user's initializer
- * this can fail!
- */
- if (p_pool->pfn_init) {
- p_pool_item = NULL;
- status = p_pool->pfn_init(p_pool->p_components,
- p_pool->num_components,
- (void *)p_pool->context,
- &p_pool_item);
- if (status != CL_SUCCESS) {
- /*
- * User initialization failed
- * we may have only grown the pool by some partial amount
- * Invoke the destructor for the object that failed
- * initialization.
- */
- if (p_pool->pfn_dtor)
- p_pool->pfn_dtor(p_pool_item,
- (void *)p_pool->
- context);
-
- /* Return the user's status. */
- return (status);
- }
- CL_ASSERT(p_pool_item);
- } else {
- /*
- * If no initializer is provided, assume that the pool item
- * is stored at the beginning of the first component.
- */
- p_pool_item =
- (cl_pool_item_t *) p_pool->p_components[0];
- }
-
-#ifdef _DEBUG_
- /*
- * Set the pool item's pool pointer to this pool so that we can
- * check that items get returned to the correct pool.
- */
- p_pool_item->p_pool = p_pool;
-#endif
-
- /* Insert the new item in the free list, traping for failure. */
- cl_qlist_insert_head(&p_pool->free_list,
- &p_pool_item->list_item);
-
- p_pool->num_objects++;
-
- /* move the pointer to the next item */
- p_objects += obj_size;
- }
-
- return (status);
-}
-
-cl_pool_item_t *cl_qcpool_get(IN cl_qcpool_t * const p_pool)
-{
- cl_list_item_t *p_list_item;
-
- CL_ASSERT(p_pool);
- CL_ASSERT(p_pool->state == CL_INITIALIZED);
-
- if (cl_is_qlist_empty(&p_pool->free_list)) {
- /*
- * No object is available.
- * Return NULL if the user does not want automatic growth.
- */
- if (!p_pool->grow_size)
- return (NULL);
-
- /* We ran out of elements. Get more */
- cl_qcpool_grow(p_pool, p_pool->grow_size);
- /*
- * We may not have gotten everything we wanted but we might have
- * gotten something.
- */
- if (cl_is_qlist_empty(&p_pool->free_list))
- return (NULL);
- }
-
- p_list_item = cl_qlist_remove_head(&p_pool->free_list);
- /* OK, at this point we have an object */
- CL_ASSERT(p_list_item != cl_qlist_end(&p_pool->free_list));
- return ((cl_pool_item_t *) p_list_item);
-}
-
-cl_pool_item_t *cl_qcpool_get_tail(IN cl_qcpool_t * const p_pool)
-{
- cl_list_item_t *p_list_item;
-
- CL_ASSERT(p_pool);
- CL_ASSERT(p_pool->state == CL_INITIALIZED);
-
- if (cl_is_qlist_empty(&p_pool->free_list)) {
- /*
- * No object is available.
- * Return NULL if the user does not want automatic growth.
- */
- if (!p_pool->grow_size)
- return (NULL);
-
- /* We ran out of elements. Get more */
- cl_qcpool_grow(p_pool, p_pool->grow_size);
- /*
- * We may not have gotten everything we wanted but we might have
- * gotten something.
- */
- if (cl_is_qlist_empty(&p_pool->free_list))
- return (NULL);
- }
-
- p_list_item = cl_qlist_remove_tail(&p_pool->free_list);
- /* OK, at this point we have an object */
- CL_ASSERT(p_list_item != cl_qlist_end(&p_pool->free_list));
- return ((cl_pool_item_t *) p_list_item);
-}
-
-/*
- * IMPLEMENTATION OF QUICK GROW POOL
- */
-
-/*
- * Callback to translate quick composite to quick grow pool
- * initializer callback.
- */
-static cl_status_t
-__cl_qpool_init_cb(IN void **const p_comp_array,
- IN const uint32_t num_components,
- IN void *const context,
- OUT cl_pool_item_t ** const pp_pool_item)
-{
- cl_qpool_t *p_pool = (cl_qpool_t *) context;
-
- CL_ASSERT(p_pool);
- CL_ASSERT(p_pool->pfn_init);
- CL_ASSERT(num_components == 1);
-
- UNUSED_PARAM(num_components);
-
- return (p_pool->pfn_init(p_comp_array[0], (void *)p_pool->context,
- pp_pool_item));
-}
-
-/*
- * Callback to translate quick composite to quick grow pool
- * destructor callback.
- */
-static void
-__cl_qpool_dtor_cb(IN const cl_pool_item_t * const p_pool_item,
- IN void *const context)
-{
- cl_qpool_t *p_pool = (cl_qpool_t *) context;
-
- CL_ASSERT(p_pool);
- CL_ASSERT(p_pool->pfn_dtor);
-
- p_pool->pfn_dtor(p_pool_item, (void *)p_pool->context);
-}
-
-void cl_qpool_construct(IN cl_qpool_t * const p_pool)
-{
- memset(p_pool, 0, sizeof(cl_qpool_t));
-
- cl_qcpool_construct(&p_pool->qcpool);
-}
-
-cl_status_t
-cl_qpool_init(IN cl_qpool_t * const p_pool,
- IN const size_t min_size,
- IN const size_t max_size,
- IN const size_t grow_size,
- IN const size_t object_size,
- IN cl_pfn_qpool_init_t pfn_initializer OPTIONAL,
- IN cl_pfn_qpool_dtor_t pfn_destructor OPTIONAL,
- IN const void *const context)
-{
- cl_status_t status;
-
- CL_ASSERT(p_pool);
-
- p_pool->pfn_init = pfn_initializer; /* may be NULL */
- p_pool->pfn_dtor = pfn_destructor; /* may be NULL */
- p_pool->context = context;
-
- status = cl_qcpool_init(&p_pool->qcpool, min_size, max_size, grow_size,
- &object_size, 1,
- pfn_initializer ? __cl_qpool_init_cb : NULL,
- pfn_destructor ? __cl_qpool_dtor_cb : NULL,
- p_pool);
-
- return (status);
-}
-
-/*
- * IMPLEMENTATION OF COMPOSITE POOL
- */
-
-/*
- * Callback to translate quick composite to compsite pool
- * initializer callback.
- */
-static cl_status_t
-__cl_cpool_init_cb(IN void **const p_comp_array,
- IN const uint32_t num_components,
- IN void *const context,
- OUT cl_pool_item_t ** const pp_pool_item)
-{
- cl_cpool_t *p_pool = (cl_cpool_t *) context;
- cl_pool_obj_t *p_pool_obj;
- cl_status_t status = CL_SUCCESS;
-
- CL_ASSERT(p_pool);
-
- /*
- * Set our pointer to the list item, which is stored at the beginning of
- * the first component.
- */
- p_pool_obj = (cl_pool_obj_t *) p_comp_array[0];
- /* Set the pool item pointer for the caller. */
- *pp_pool_item = &p_pool_obj->pool_item;
-
- /* Calculate the pointer to the user's first component. */
- p_comp_array[0] = ((uint8_t *) p_comp_array[0]) + sizeof(cl_pool_obj_t);
-
- /*
- * Set the object pointer in the pool object to point to the first of the
- * user's components.
- */
- p_pool_obj->p_object = p_comp_array[0];
-
- /* Invoke the user's constructor callback. */
- if (p_pool->pfn_init) {
- status = p_pool->pfn_init(p_comp_array, num_components,
- (void *)p_pool->context);
- }
-
- return (status);
-}
-
-/*
- * Callback to translate quick composite to composite pool
- * destructor callback.
- */
-static void
-__cl_cpool_dtor_cb(IN const cl_pool_item_t * const p_pool_item,
- IN void *const context)
-{
- cl_cpool_t *p_pool = (cl_cpool_t *) context;
-
- CL_ASSERT(p_pool);
- CL_ASSERT(p_pool->pfn_dtor);
- CL_ASSERT(((cl_pool_obj_t *) p_pool_item)->p_object);
-
- /* Invoke the user's destructor callback. */
- p_pool->pfn_dtor((void *)((cl_pool_obj_t *) p_pool_item)->p_object,
- (void *)p_pool->context);
-}
-
-void cl_cpool_construct(IN cl_cpool_t * const p_pool)
-{
- CL_ASSERT(p_pool);
-
- memset(p_pool, 0, sizeof(cl_cpool_t));
-
- cl_qcpool_construct(&p_pool->qcpool);
-}
-
-cl_status_t
-cl_cpool_init(IN cl_cpool_t * const p_pool,
- IN const size_t min_size,
- IN const size_t max_size,
- IN const size_t grow_size,
- IN size_t * const component_sizes,
- IN const uint32_t num_components,
- IN cl_pfn_cpool_init_t pfn_initializer OPTIONAL,
- IN cl_pfn_cpool_dtor_t pfn_destructor OPTIONAL,
- IN const void *const context)
-{
- cl_status_t status;
-
- CL_ASSERT(p_pool);
- CL_ASSERT(num_components);
- CL_ASSERT(component_sizes);
-
- /* Add the size of the pool object to the first component. */
- component_sizes[0] += sizeof(cl_pool_obj_t);
-
- /* Store callback function pointers. */
- p_pool->pfn_init = pfn_initializer; /* may be NULL */
- p_pool->pfn_dtor = pfn_destructor; /* may be NULL */
- p_pool->context = context;
-
- status = cl_qcpool_init(&p_pool->qcpool, min_size, max_size, grow_size,
- component_sizes, num_components,
- __cl_cpool_init_cb,
- pfn_destructor ? __cl_cpool_dtor_cb : NULL,
- p_pool);
-
- /* Restore the original value of the first component. */
- component_sizes[0] -= sizeof(cl_pool_obj_t);
-
- return (status);
-}
-
-/*
- * IMPLEMENTATION OF GROW POOL
- */
-
-/*
- * Callback to translate quick composite to grow pool constructor callback.
- */
-static cl_status_t
-__cl_pool_init_cb(IN void **const pp_obj,
- IN const uint32_t count,
- IN void *const context,
- OUT cl_pool_item_t ** const pp_pool_item)
-{
- cl_pool_t *p_pool = (cl_pool_t *) context;
- cl_pool_obj_t *p_pool_obj;
- cl_status_t status = CL_SUCCESS;
-
- CL_ASSERT(p_pool);
- CL_ASSERT(pp_obj);
- CL_ASSERT(count == 1);
-
- UNUSED_PARAM(count);
-
- /*
- * Set our pointer to the list item, which is stored at the beginning of
- * the first component.
- */
- p_pool_obj = (cl_pool_obj_t *) * pp_obj;
- *pp_pool_item = &p_pool_obj->pool_item;
-
- /* Calculate the pointer to the user's first component. */
- *pp_obj = ((uint8_t *) * pp_obj) + sizeof(cl_pool_obj_t);
-
- /*
- * Set the object pointer in the pool item to point to the first of the
- * user's components.
- */
- p_pool_obj->p_object = *pp_obj;
-
- /* Invoke the user's constructor callback. */
- if (p_pool->pfn_init)
- status = p_pool->pfn_init(*pp_obj, (void *)p_pool->context);
-
- return (status);
-}
-
-/*
- * Callback to translate quick composite to grow pool destructor callback.
- */
-static void
-__cl_pool_dtor_cb(IN const cl_pool_item_t * const p_pool_item,
- IN void *const context)
-{
- cl_pool_t *p_pool = (cl_pool_t *) context;
-
- CL_ASSERT(p_pool);
- CL_ASSERT(p_pool->pfn_dtor);
- CL_ASSERT(((cl_pool_obj_t *) p_pool_item)->p_object);
-
- /* Invoke the user's destructor callback. */
- p_pool->pfn_dtor((void *)((cl_pool_obj_t *) p_pool_item)->p_object,
- (void *)p_pool->context);
-}
-
-void cl_pool_construct(IN cl_pool_t * const p_pool)
-{
- CL_ASSERT(p_pool);
-
- memset(p_pool, 0, sizeof(cl_pool_t));
-
- cl_qcpool_construct(&p_pool->qcpool);
-}
-
-cl_status_t
-cl_pool_init(IN cl_pool_t * const p_pool,
- IN const size_t min_size,
- IN const size_t max_size,
- IN const size_t grow_size,
- IN const size_t object_size,
- IN cl_pfn_pool_init_t pfn_initializer OPTIONAL,
- IN cl_pfn_pool_dtor_t pfn_destructor OPTIONAL,
- IN const void *const context)
-{
- cl_status_t status;
- size_t total_size;
-
- CL_ASSERT(p_pool);
-
- /* Add the size of the list item to the first component. */
- total_size = object_size + sizeof(cl_pool_obj_t);
-
- /* Store callback function pointers. */
- p_pool->pfn_init = pfn_initializer; /* may be NULL */
- p_pool->pfn_dtor = pfn_destructor; /* may be NULL */
- p_pool->context = context;
-
- /*
- * We need an initializer in all cases for quick composite pool, since
- * the user pointer must be manipulated to hide the prefixed cl_pool_obj_t.
- */
- status = cl_qcpool_init(&p_pool->qcpool, min_size, max_size, grow_size,
- &total_size, 1, __cl_pool_init_cb,
- pfn_destructor ? __cl_pool_dtor_cb : NULL,
- p_pool);
-
- return (status);
-}
diff --git a/contrib/ofed/management/opensm/complib/cl_ptr_vector.c b/contrib/ofed/management/opensm/complib/cl_ptr_vector.c
deleted file mode 100644
index c34316e..0000000
--- a/contrib/ofed/management/opensm/complib/cl_ptr_vector.c
+++ /dev/null
@@ -1,319 +0,0 @@
-/*
- * Copyright (c) 2004-2006 Voltaire, Inc. All rights reserved.
- * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved.
- * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- */
-
-/*
- * Abstract:
- * This file contains ivector and isvector implementations.
- *
- */
-
-#if HAVE_CONFIG_H
-# include <config.h>
-#endif /* HAVE_CONFIG_H */
-
-#include <stdlib.h>
-#include <string.h>
-#include <complib/cl_ptr_vector.h>
-
-void cl_ptr_vector_construct(IN cl_ptr_vector_t * const p_vector)
-{
- CL_ASSERT(p_vector);
-
- memset(p_vector, 0, sizeof(cl_ptr_vector_t));
-
- p_vector->state = CL_UNINITIALIZED;
-}
-
-cl_status_t
-cl_ptr_vector_init(IN cl_ptr_vector_t * const p_vector,
- IN const size_t min_size, IN const size_t grow_size)
-{
- cl_status_t status = CL_SUCCESS;
-
- CL_ASSERT(p_vector);
-
- cl_ptr_vector_construct(p_vector);
-
- p_vector->grow_size = grow_size;
-
- /*
- * Set the state to initialized so that the call to set_size
- * doesn't assert.
- */
- p_vector->state = CL_INITIALIZED;
-
- /* get the storage needed by the user */
- if (min_size) {
- status = cl_ptr_vector_set_size(p_vector, min_size);
- if (status != CL_SUCCESS)
- cl_ptr_vector_destroy(p_vector);
- }
-
- return (status);
-}
-
-void cl_ptr_vector_destroy(IN cl_ptr_vector_t * const p_vector)
-{
- CL_ASSERT(p_vector);
- CL_ASSERT(cl_is_state_valid(p_vector->state));
-
- /* Call the user's destructor for each element in the array. */
- if (p_vector->state == CL_INITIALIZED) {
- /* Destroy the page vector. */
- if (p_vector->p_ptr_array) {
- free((void *)p_vector->p_ptr_array);
- p_vector->p_ptr_array = NULL;
- }
- }
-
- p_vector->state = CL_UNINITIALIZED;
-}
-
-cl_status_t
-cl_ptr_vector_at(IN const cl_ptr_vector_t * const p_vector,
- IN const size_t index, OUT void **const p_element)
-{
- CL_ASSERT(p_vector);
- CL_ASSERT(p_vector->state == CL_INITIALIZED);
-
- /* Range check */
- if (index >= p_vector->size)
- return (CL_INVALID_PARAMETER);
-
- *p_element = cl_ptr_vector_get(p_vector, index);
- return (CL_SUCCESS);
-}
-
-cl_status_t
-cl_ptr_vector_set(IN cl_ptr_vector_t * const p_vector,
- IN const size_t index, IN const void *const element)
-{
- cl_status_t status;
-
- CL_ASSERT(p_vector);
- CL_ASSERT(p_vector->state == CL_INITIALIZED);
-
- /* Determine if the vector has room for this element. */
- if (index >= p_vector->size) {
- /* Resize to accomodate the given index. */
- status = cl_ptr_vector_set_size(p_vector, index + 1);
-
- /* Check for failure on or before the given index. */
- if ((status != CL_SUCCESS) && (p_vector->size < index))
- return (status);
- }
-
- /* At this point, the array is guaranteed to be big enough */
- p_vector->p_ptr_array[index] = element;
-
- return (CL_SUCCESS);
-}
-
-void *cl_ptr_vector_remove(IN cl_ptr_vector_t * const p_vector,
- IN const size_t index)
-{
- size_t src;
- const void *element;
-
- CL_ASSERT(p_vector);
- CL_ASSERT(p_vector->state == CL_INITIALIZED);
- CL_ASSERT(p_vector->size > index);
-
- /* Store a copy of the element to return. */
- element = p_vector->p_ptr_array[index];
- /* Shift all items above the removed item down. */
- if (index < --p_vector->size) {
- for (src = index; src < p_vector->size; src++)
- p_vector->p_ptr_array[src] =
- p_vector->p_ptr_array[src + 1];
- }
- /* Clear the entry for the element just outside of the new upper bound. */
- p_vector->p_ptr_array[p_vector->size] = NULL;
-
- return ((void *)element);
-}
-
-cl_status_t
-cl_ptr_vector_set_capacity(IN cl_ptr_vector_t * const p_vector,
- IN const size_t new_capacity)
-{
- void *p_new_ptr_array;
-
- CL_ASSERT(p_vector);
- CL_ASSERT(p_vector->state == CL_INITIALIZED);
-
- /* Do we have to do anything here? */
- if (new_capacity <= p_vector->capacity) {
- /* Nope */
- return (CL_SUCCESS);
- }
-
- /* Allocate our pointer array. */
- p_new_ptr_array = malloc(new_capacity * sizeof(void *));
- if (!p_new_ptr_array)
- return (CL_INSUFFICIENT_MEMORY);
- else
- memset(p_new_ptr_array, 0, new_capacity * sizeof(void *));
-
- if (p_vector->p_ptr_array) {
- /* Copy the old pointer array into the new. */
- memcpy(p_new_ptr_array, p_vector->p_ptr_array,
- p_vector->capacity * sizeof(void *));
-
- /* Free the old pointer array. */
- free((void *)p_vector->p_ptr_array);
- }
-
- /* Set the new array. */
- p_vector->p_ptr_array = p_new_ptr_array;
-
- /* Update the vector with the new capactity. */
- p_vector->capacity = new_capacity;
-
- return (CL_SUCCESS);
-}
-
-cl_status_t
-cl_ptr_vector_set_size(IN cl_ptr_vector_t * const p_vector,
- IN const size_t size)
-{
- cl_status_t status;
- size_t new_capacity;
-
- CL_ASSERT(p_vector);
- CL_ASSERT(p_vector->state == CL_INITIALIZED);
-
- /* Check to see if the requested size is the same as the existing size. */
- if (size == p_vector->size)
- return (CL_SUCCESS);
-
- /* Determine if the vector has room for this element. */
- if (size >= p_vector->capacity) {
- if (!p_vector->grow_size)
- return (CL_INSUFFICIENT_MEMORY);
-
- /* Calculate the new capacity, taking into account the grow size. */
- new_capacity = size;
- if (size % p_vector->grow_size) {
- /* Round up to nearest grow_size boundary. */
- new_capacity += p_vector->grow_size -
- (size % p_vector->grow_size);
- }
-
- status = cl_ptr_vector_set_capacity(p_vector, new_capacity);
- if (status != CL_SUCCESS)
- return (status);
- }
-
- p_vector->size = size;
- return (CL_SUCCESS);
-}
-
-cl_status_t
-cl_ptr_vector_set_min_size(IN cl_ptr_vector_t * const p_vector,
- IN const size_t min_size)
-{
- CL_ASSERT(p_vector);
- CL_ASSERT(p_vector->state == CL_INITIALIZED);
-
- if (min_size > p_vector->size) {
- /* We have to resize the array */
- return (cl_ptr_vector_set_size(p_vector, min_size));
- }
-
- /* We didn't have to do anything */
- return (CL_SUCCESS);
-}
-
-void
-cl_ptr_vector_apply_func(IN const cl_ptr_vector_t * const p_vector,
- IN cl_pfn_ptr_vec_apply_t pfn_callback,
- IN const void *const context)
-{
- size_t i;
-
- CL_ASSERT(p_vector);
- CL_ASSERT(p_vector->state == CL_INITIALIZED);
- CL_ASSERT(pfn_callback);
-
- for (i = 0; i < p_vector->size; i++)
- pfn_callback(i, (void *)p_vector->p_ptr_array[i],
- (void *)context);
-}
-
-size_t
-cl_ptr_vector_find_from_start(IN const cl_ptr_vector_t * const p_vector,
- IN cl_pfn_ptr_vec_find_t pfn_callback,
- IN const void *const context)
-{
- size_t i;
-
- CL_ASSERT(p_vector);
- CL_ASSERT(p_vector->state == CL_INITIALIZED);
- CL_ASSERT(pfn_callback);
-
- for (i = 0; i < p_vector->size; i++) {
- /* Invoke the callback */
- if (pfn_callback(i, (void *)p_vector->p_ptr_array[i],
- (void *)context) == CL_SUCCESS) {
- break;
- }
- }
- return (i);
-}
-
-size_t
-cl_ptr_vector_find_from_end(IN const cl_ptr_vector_t * const p_vector,
- IN cl_pfn_ptr_vec_find_t pfn_callback,
- IN const void *const context)
-{
- size_t i;
-
- CL_ASSERT(p_vector);
- CL_ASSERT(p_vector->state == CL_INITIALIZED);
- CL_ASSERT(pfn_callback);
-
- i = p_vector->size;
-
- while (i) {
- /* Invoke the callback for the current element. */
- if (pfn_callback(i, (void *)p_vector->p_ptr_array[--i],
- (void *)context) == CL_SUCCESS) {
- return (i);
- }
- }
-
- return (p_vector->size);
-}
diff --git a/contrib/ofed/management/opensm/complib/cl_thread.c b/contrib/ofed/management/opensm/complib/cl_thread.c
deleted file mode 100644
index 38a68f8..0000000
--- a/contrib/ofed/management/opensm/complib/cl_thread.c
+++ /dev/null
@@ -1,140 +0,0 @@
-/*
- * Copyright (c) 2004, 2005 Voltaire, Inc. All rights reserved.
- * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved.
- * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- */
-
-#if HAVE_CONFIG_H
-# include <config.h>
-#endif /* HAVE_CONFIG_H */
-
-#include <stdio.h>
-#include <unistd.h>
-#include <complib/cl_thread.h>
-
-/*
- * Internal function to run a new user mode thread.
- * This function is always run as a result of creation a new user mode thread.
- * Its main job is to synchronize the creation and running of the new thread.
- */
-static void *__cl_thread_wrapper(void *arg)
-{
- cl_thread_t *p_thread = (cl_thread_t *) arg;
-
- CL_ASSERT(p_thread);
- CL_ASSERT(p_thread->pfn_callback);
-
- p_thread->pfn_callback((void *)p_thread->context);
-
- return (NULL);
-}
-
-void cl_thread_construct(IN cl_thread_t * const p_thread)
-{
- CL_ASSERT(p_thread);
-
- p_thread->osd.state = CL_UNINITIALIZED;
-}
-
-cl_status_t
-cl_thread_init(IN cl_thread_t * const p_thread,
- IN cl_pfn_thread_callback_t pfn_callback,
- IN const void *const context, IN const char *const name)
-{
- int ret;
-
- CL_ASSERT(p_thread);
-
- cl_thread_construct(p_thread);
-
- /* Initialize the thread structure */
- p_thread->pfn_callback = pfn_callback;
- p_thread->context = context;
-
- ret = pthread_create(&p_thread->osd.id, NULL,
- __cl_thread_wrapper, (void *)p_thread);
-
- if (ret != 0) /* pthread_create returns a "0" for success */
- return (CL_ERROR);
-
- p_thread->osd.state = CL_INITIALIZED;
-
- return (CL_SUCCESS);
-}
-
-void cl_thread_destroy(IN cl_thread_t * const p_thread)
-{
- CL_ASSERT(p_thread);
- CL_ASSERT(cl_is_state_valid(p_thread->osd.state));
-
- if (p_thread->osd.state == CL_INITIALIZED)
- pthread_join(p_thread->osd.id, NULL);
-
- p_thread->osd.state = CL_UNINITIALIZED;
-}
-
-void cl_thread_suspend(IN const uint32_t pause_ms)
-{
- /* Convert to micro seconds */
- usleep(pause_ms * 1000);
-}
-
-void cl_thread_stall(IN const uint32_t pause_us)
-{
- /*
- * Not quite a busy wait, but Linux is lacking in terms of high
- * resolution time stamp information in user mode.
- */
- usleep(pause_us);
-}
-
-int cl_proc_count(void)
-{
- uint32_t ret;
-
- ret = sysconf(_SC_NPROCESSORS_ONLN);
- if (!ret)
- return 1; /* Workaround for PPC where get_nprocs() returns 0 */
-
- return ret;
-}
-
-boolean_t cl_is_current_thread(IN const cl_thread_t * const p_thread)
-{
- pthread_t current;
-
- CL_ASSERT(p_thread);
- CL_ASSERT(p_thread->osd.state == CL_INITIALIZED);
-
- current = pthread_self();
- return (pthread_equal(current, p_thread->osd.id));
-}
diff --git a/contrib/ofed/management/opensm/complib/cl_threadpool.c b/contrib/ofed/management/opensm/complib/cl_threadpool.c
deleted file mode 100644
index 3f6c0a4..0000000
--- a/contrib/ofed/management/opensm/complib/cl_threadpool.c
+++ /dev/null
@@ -1,148 +0,0 @@
-/*
- * Copyright (c) 2004-2007 Voltaire, Inc. All rights reserved.
- * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved.
- * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- */
-
-/*
- * Abstract:
- * Implementation of thread pool.
- *
- */
-
-#if HAVE_CONFIG_H
-# include <config.h>
-#endif /* HAVE_CONFIG_H */
-
-#include <stdlib.h>
-#include <string.h>
-#include <pthread.h>
-#include <complib/cl_threadpool.h>
-
-static void cleanup_mutex(void *arg)
-{
- pthread_mutex_unlock(&((cl_thread_pool_t *) arg)->mutex);
-}
-
-static void *thread_pool_routine(void *context)
-{
- cl_thread_pool_t *p_thread_pool = (cl_thread_pool_t *) context;
-
- do {
- pthread_mutex_lock(&p_thread_pool->mutex);
- pthread_cleanup_push(cleanup_mutex, p_thread_pool);
- while (!p_thread_pool->events)
- pthread_cond_wait(&p_thread_pool->cond,
- &p_thread_pool->mutex);
- p_thread_pool->events--;
- pthread_cleanup_pop(1);
- /* The event has been signalled. Invoke the callback. */
- (*p_thread_pool->pfn_callback) (p_thread_pool->context);
- } while (1);
-
- return NULL;
-}
-
-cl_status_t
-cl_thread_pool_init(IN cl_thread_pool_t * const p_thread_pool,
- IN unsigned count,
- IN void (*pfn_callback) (void *),
- IN void *context, IN const char *const name)
-{
- int i;
-
- CL_ASSERT(p_thread_pool);
- CL_ASSERT(pfn_callback);
-
- memset(p_thread_pool, 0, sizeof(*p_thread_pool));
-
- if (!count)
- count = cl_proc_count();
-
- pthread_mutex_init(&p_thread_pool->mutex, NULL);
- pthread_cond_init(&p_thread_pool->cond, NULL);
-
- p_thread_pool->events = 0;
-
- p_thread_pool->pfn_callback = pfn_callback;
- p_thread_pool->context = context;
-
- p_thread_pool->tid = calloc(count, sizeof(*p_thread_pool->tid));
- if (!p_thread_pool->tid) {
- cl_thread_pool_destroy(p_thread_pool);
- return CL_INSUFFICIENT_MEMORY;
- }
-
- p_thread_pool->running_count = count;
-
- for (i = 0; i < count; i++) {
- if (pthread_create(&p_thread_pool->tid[i], NULL,
- thread_pool_routine, p_thread_pool) < 0) {
- cl_thread_pool_destroy(p_thread_pool);
- return CL_INSUFFICIENT_RESOURCES;
- }
- }
-
- return (CL_SUCCESS);
-}
-
-void cl_thread_pool_destroy(IN cl_thread_pool_t * const p_thread_pool)
-{
- int i;
-
- CL_ASSERT(p_thread_pool);
-
- for (i = 0; i < p_thread_pool->running_count; i++)
- if (p_thread_pool->tid[i])
- pthread_cancel(p_thread_pool->tid[i]);
-
- for (i = 0; i < p_thread_pool->running_count; i++)
- if (p_thread_pool->tid[i])
- pthread_join(p_thread_pool->tid[i], NULL);
-
- p_thread_pool->running_count = 0;
- pthread_cond_destroy(&p_thread_pool->cond);
- pthread_mutex_destroy(&p_thread_pool->mutex);
-
- p_thread_pool->events = 0;
-}
-
-cl_status_t cl_thread_pool_signal(IN cl_thread_pool_t * const p_thread_pool)
-{
- int ret;
- CL_ASSERT(p_thread_pool);
- pthread_mutex_lock(&p_thread_pool->mutex);
- p_thread_pool->events++;
- ret = pthread_cond_signal(&p_thread_pool->cond);
- pthread_mutex_unlock(&p_thread_pool->mutex);
- return ret;
-}
diff --git a/contrib/ofed/management/opensm/complib/cl_timer.c b/contrib/ofed/management/opensm/complib/cl_timer.c
deleted file mode 100644
index 41b669f..0000000
--- a/contrib/ofed/management/opensm/complib/cl_timer.c
+++ /dev/null
@@ -1,446 +0,0 @@
-/*
- * Copyright (c) 2004-2006 Voltaire, Inc. All rights reserved.
- * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved.
- * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- */
-
-/*
- * Abstract:
- * Abstraction of Timer create, destroy functions.
- *
- */
-
-#if HAVE_CONFIG_H
-# include <config.h>
-#endif /* HAVE_CONFIG_H */
-
-#include <stdlib.h>
-#include <string.h>
-#include <complib/cl_timer.h>
-#include <sys/time.h>
-#include <sys/errno.h>
-#include <stdio.h>
-
-/* Timer provider (emulates timers in user mode). */
-typedef struct _cl_timer_prov {
- pthread_t thread;
- pthread_mutex_t mutex;
- pthread_cond_t cond;
- cl_qlist_t queue;
-
- boolean_t exit;
-
-} cl_timer_prov_t;
-
-/* Global timer provider. */
-static cl_timer_prov_t *gp_timer_prov = NULL;
-
-static void *__cl_timer_prov_cb(IN void *const context);
-
-/*
- * Creates the process global timer provider. Must be called by the shared
- * object framework to solve all serialization issues.
- */
-cl_status_t __cl_timer_prov_create(void)
-{
- CL_ASSERT(gp_timer_prov == NULL);
-
- gp_timer_prov = malloc(sizeof(cl_timer_prov_t));
- if (!gp_timer_prov)
- return (CL_INSUFFICIENT_MEMORY);
- else
- memset(gp_timer_prov, 0, sizeof(cl_timer_prov_t));
-
- cl_qlist_init(&gp_timer_prov->queue);
-
- pthread_mutex_init(&gp_timer_prov->mutex, NULL);
- pthread_cond_init(&gp_timer_prov->cond, NULL);
-
- if (pthread_create(&gp_timer_prov->thread, NULL,
- __cl_timer_prov_cb, NULL)) {
- __cl_timer_prov_destroy();
- return (CL_ERROR);
- }
-
- return (CL_SUCCESS);
-}
-
-void __cl_timer_prov_destroy(void)
-{
- pthread_t tid;
-
- if (!gp_timer_prov)
- return;
-
- tid = gp_timer_prov->thread;
- pthread_mutex_lock(&gp_timer_prov->mutex);
- gp_timer_prov->exit = TRUE;
- pthread_cond_broadcast(&gp_timer_prov->cond);
- pthread_mutex_unlock(&gp_timer_prov->mutex);
- pthread_join(tid, NULL);
-
- /* Destroy the mutex and condition variable. */
- pthread_mutex_destroy(&gp_timer_prov->mutex);
- pthread_cond_destroy(&gp_timer_prov->cond);
-
- /* Free the memory and reset the global pointer. */
- free(gp_timer_prov);
- gp_timer_prov = NULL;
-}
-
-/*
- * This is the internal work function executed by the timer's thread.
- */
-static void *__cl_timer_prov_cb(IN void *const context)
-{
- int ret;
- cl_timer_t *p_timer;
-
- pthread_mutex_lock(&gp_timer_prov->mutex);
- while (!gp_timer_prov->exit) {
- if (cl_is_qlist_empty(&gp_timer_prov->queue)) {
- /* Wait until we exit or a timer is queued. */
- /* cond wait does:
- * pthread_cond_wait atomically unlocks the mutex (as per
- * pthread_unlock_mutex) and waits for the condition variable
- * cond to be signaled. The thread execution is suspended and
- * does not consume any CPU time until the condition variable is
- * signaled. The mutex must be locked by the calling thread on
- * entrance to pthread_cond_wait. Before RETURNING TO THE
- * CALLING THREAD, PTHREAD_COND_WAIT RE-ACQUIRES MUTEX (as per
- * pthread_lock_mutex).
- */
- ret = pthread_cond_wait(&gp_timer_prov->cond,
- &gp_timer_prov->mutex);
- } else {
- /*
- * The timer elements are on the queue in expiration order.
- * Get the first in the list to determine how long to wait.
- */
-
- p_timer =
- (cl_timer_t *) cl_qlist_head(&gp_timer_prov->queue);
- ret =
- pthread_cond_timedwait(&gp_timer_prov->cond,
- &gp_timer_prov->mutex,
- &p_timer->timeout);
-
- /*
- Sleep again on every event other than timeout and invalid
- Note: EINVAL means that we got behind. This can occur when
- we are very busy...
- */
- if (ret != ETIMEDOUT && ret != EINVAL)
- continue;
-
- /*
- * The timer expired. Check the state in case it was cancelled
- * after it expired but before we got a chance to invoke the
- * callback.
- */
- if (p_timer->timer_state != CL_TIMER_QUEUED)
- continue;
-
- /*
- * Mark the timer as running to synchronize with its
- * cancelation since we can't hold the mutex during the
- * callback.
- */
- p_timer->timer_state = CL_TIMER_RUNNING;
-
- /* Remove the item from the timer queue. */
- cl_qlist_remove_item(&gp_timer_prov->queue,
- &p_timer->list_item);
- pthread_mutex_unlock(&gp_timer_prov->mutex);
- /* Invoke the callback. */
- p_timer->pfn_callback((void *)p_timer->context);
-
- /* Acquire the mutex again. */
- pthread_mutex_lock(&gp_timer_prov->mutex);
- /*
- * Only set the state to idle if the timer has not been accessed
- * from the callback
- */
- if (p_timer->timer_state == CL_TIMER_RUNNING)
- p_timer->timer_state = CL_TIMER_IDLE;
-
- /*
- * Signal any thread trying to manipulate the timer
- * that expired.
- */
- pthread_cond_signal(&p_timer->cond);
- }
- }
- gp_timer_prov->thread = 0;
- pthread_mutex_unlock(&gp_timer_prov->mutex);
- pthread_exit(NULL);
-}
-
-/* Timer implementation. */
-void cl_timer_construct(IN cl_timer_t * const p_timer)
-{
- memset(p_timer, 0, sizeof(cl_timer_t));
- p_timer->state = CL_UNINITIALIZED;
-}
-
-cl_status_t
-cl_timer_init(IN cl_timer_t * const p_timer,
- IN cl_pfn_timer_callback_t pfn_callback,
- IN const void *const context)
-{
- CL_ASSERT(p_timer);
- CL_ASSERT(pfn_callback);
-
- cl_timer_construct(p_timer);
-
- if (!gp_timer_prov)
- return (CL_ERROR);
-
- /* Store timer parameters. */
- p_timer->pfn_callback = pfn_callback;
- p_timer->context = context;
-
- /* Mark the timer as idle. */
- p_timer->timer_state = CL_TIMER_IDLE;
-
- /* Create the condition variable that is used when cancelling a timer. */
- pthread_cond_init(&p_timer->cond, NULL);
-
- p_timer->state = CL_INITIALIZED;
-
- return (CL_SUCCESS);
-}
-
-void cl_timer_destroy(IN cl_timer_t * const p_timer)
-{
- CL_ASSERT(p_timer);
- CL_ASSERT(cl_is_state_valid(p_timer->state));
-
- if (p_timer->state == CL_INITIALIZED)
- cl_timer_stop(p_timer);
-
- p_timer->state = CL_UNINITIALIZED;
-
- /* is it possible we have some threads waiting on the cond now? */
- pthread_cond_broadcast(&p_timer->cond);
- pthread_cond_destroy(&p_timer->cond);
-
-}
-
-/*
- * Return TRUE if timeout value 1 is earlier than timeout value 2.
- */
-static __inline boolean_t
-__cl_timer_is_earlier(IN struct timespec *p_timeout1,
- IN struct timespec *p_timeout2)
-{
- return ((p_timeout1->tv_sec < p_timeout2->tv_sec) ||
- ((p_timeout1->tv_sec == p_timeout2->tv_sec) &&
- (p_timeout1->tv_nsec < p_timeout2->tv_nsec)));
-}
-
-/*
- * Search for a timer with an earlier timeout than the one provided by
- * the context. Both the list item and the context are pointers to
- * a cl_timer_t structure with valid timeouts.
- */
-static cl_status_t
-__cl_timer_find(IN const cl_list_item_t * const p_list_item,
- IN void *const context)
-{
- cl_timer_t *p_in_list;
- cl_timer_t *p_new;
-
- CL_ASSERT(p_list_item);
- CL_ASSERT(context);
-
- p_in_list = (cl_timer_t *) p_list_item;
- p_new = (cl_timer_t *) context;
-
- CL_ASSERT(p_in_list->state == CL_INITIALIZED);
- CL_ASSERT(p_new->state == CL_INITIALIZED);
-
- CL_ASSERT(p_in_list->timer_state == CL_TIMER_QUEUED);
-
- if (__cl_timer_is_earlier(&p_in_list->timeout, &p_new->timeout))
- return (CL_SUCCESS);
-
- return (CL_NOT_FOUND);
-}
-
-cl_status_t
-cl_timer_start(IN cl_timer_t * const p_timer, IN const uint32_t time_ms)
-{
- struct timeval curtime;
- cl_list_item_t *p_list_item;
- uint32_t delta_time = time_ms;
-
- CL_ASSERT(p_timer);
- CL_ASSERT(p_timer->state == CL_INITIALIZED);
-
- pthread_mutex_lock(&gp_timer_prov->mutex);
- /* Signal the timer provider thread to wake up. */
- pthread_cond_signal(&gp_timer_prov->cond);
-
- /* Remove the timer from the queue if currently queued. */
- if (p_timer->timer_state == CL_TIMER_QUEUED)
- cl_qlist_remove_item(&gp_timer_prov->queue,
- &p_timer->list_item);
-
- /* Get the current time */
-#ifndef timerclear
-#define timerclear(tvp) (tvp)->tv_sec = (time_t)0, (tvp)->tv_usec = 0L
-#endif
- timerclear(&curtime);
- gettimeofday(&curtime, NULL);
-
- /* do not do 0 wait ! */
- /* if (delta_time < 1000.0) {delta_time = 1000;} */
-
- /* Calculate the timeout. */
- p_timer->timeout.tv_sec = curtime.tv_sec + (delta_time / 1000);
- p_timer->timeout.tv_nsec =
- (curtime.tv_usec + ((delta_time % 1000) * 1000)) * 1000;
-
- /* Add the timer to the queue. */
- if (cl_is_qlist_empty(&gp_timer_prov->queue)) {
- /* The timer list is empty. Add to the head. */
- cl_qlist_insert_head(&gp_timer_prov->queue,
- &p_timer->list_item);
- } else {
- /* Find the correct insertion place in the list for the timer. */
- p_list_item = cl_qlist_find_from_tail(&gp_timer_prov->queue,
- __cl_timer_find, p_timer);
-
- /* Insert the timer. */
- cl_qlist_insert_next(&gp_timer_prov->queue, p_list_item,
- &p_timer->list_item);
- }
- /* Set the state. */
- p_timer->timer_state = CL_TIMER_QUEUED;
- pthread_mutex_unlock(&gp_timer_prov->mutex);
-
- return (CL_SUCCESS);
-}
-
-void cl_timer_stop(IN cl_timer_t * const p_timer)
-{
- CL_ASSERT(p_timer);
- CL_ASSERT(p_timer->state == CL_INITIALIZED);
-
- pthread_mutex_lock(&gp_timer_prov->mutex);
- switch (p_timer->timer_state) {
- case CL_TIMER_RUNNING:
- /* Wait for the callback to complete. */
- pthread_cond_wait(&p_timer->cond, &gp_timer_prov->mutex);
- /* Timer could have been queued while we were waiting. */
- if (p_timer->timer_state != CL_TIMER_QUEUED)
- break;
-
- case CL_TIMER_QUEUED:
- /* Change the state of the timer. */
- p_timer->timer_state = CL_TIMER_IDLE;
- /* Remove the timer from the queue. */
- cl_qlist_remove_item(&gp_timer_prov->queue,
- &p_timer->list_item);
- /*
- * Signal the timer provider thread to move onto the
- * next timer in the queue.
- */
- pthread_cond_signal(&gp_timer_prov->cond);
- break;
-
- case CL_TIMER_IDLE:
- break;
- }
- pthread_mutex_unlock(&gp_timer_prov->mutex);
-}
-
-cl_status_t
-cl_timer_trim(IN cl_timer_t * const p_timer, IN const uint32_t time_ms)
-{
- struct timeval curtime;
- struct timespec newtime;
- cl_status_t status;
-
- CL_ASSERT(p_timer);
- CL_ASSERT(p_timer->state == CL_INITIALIZED);
-
- pthread_mutex_lock(&gp_timer_prov->mutex);
-
- /* Get the current time */
- timerclear(&curtime);
- gettimeofday(&curtime, NULL);
-
- /* Calculate the timeout. */
- newtime.tv_sec = curtime.tv_sec + (time_ms / 1000);
- newtime.tv_nsec = (curtime.tv_usec + ((time_ms % 1000) * 1000)) * 1000;
-
- if (p_timer->timer_state == CL_TIMER_QUEUED) {
- /* If the old time is earlier, do not trim it. Just return. */
- if (__cl_timer_is_earlier(&p_timer->timeout, &newtime)) {
- pthread_mutex_unlock(&gp_timer_prov->mutex);
- return (CL_SUCCESS);
- }
- }
-
- /* Reset the timer to the new timeout value. */
-
- pthread_mutex_unlock(&gp_timer_prov->mutex);
- status = cl_timer_start(p_timer, time_ms);
-
- return (status);
-}
-
-uint64_t cl_get_time_stamp(void)
-{
- uint64_t tstamp;
- struct timeval tv;
-
- timerclear(&tv);
- gettimeofday(&tv, NULL);
-
- /* Convert the time of day into a microsecond timestamp. */
- tstamp = ((uint64_t) tv.tv_sec * 1000000) + (uint64_t) tv.tv_usec;
-
- return (tstamp);
-}
-
-uint32_t cl_get_time_stamp_sec(void)
-{
- struct timeval tv;
-
- timerclear(&tv);
- gettimeofday(&tv, NULL);
-
- return (tv.tv_sec);
-}
diff --git a/contrib/ofed/management/opensm/complib/cl_vector.c b/contrib/ofed/management/opensm/complib/cl_vector.c
deleted file mode 100644
index d9bcf34..0000000
--- a/contrib/ofed/management/opensm/complib/cl_vector.c
+++ /dev/null
@@ -1,561 +0,0 @@
-/*
- * Copyright (c) 2004-2006 Voltaire, Inc. All rights reserved.
- * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved.
- * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- */
-
-/*
- * Abstract:
- * This file contains ivector and isvector implementations.
- *
- */
-
-#if HAVE_CONFIG_H
-# include <config.h>
-#endif /* HAVE_CONFIG_H */
-
-#include <stdlib.h>
-#include <string.h>
-#include <complib/cl_vector.h>
-
-/*
- * Define the maximum size for array pages in an cl_vector_t.
- * This size is in objects, not bytes.
- */
-#define SVEC_MAX_PAGE_SIZE 0x1000
-
-/*
- * cl_vector_copy_general
- *
- * Description:
- * copy operator used when size of the user object doesn't fit one of the
- * other optimized copy functions.
- *
- * Inputs:
- * p_src - source for copy
- *
- * Outputs:
- * p_dest - destination for copy
- *
- * Returns:
- * None
- *
- */
-static void
-cl_vector_copy_general(OUT void *const p_dest,
- IN const void *const p_src, IN const size_t size)
-{
- memcpy(p_dest, p_src, size);
-}
-
-/*
- * cl_vector_copy8
- *
- * Description:
- * copy operator used when the user structure is only 8 bits long.
- *
- * Inputs:
- * p_src - source for copy
- *
- * Outputs:
- * p_dest - destination for copy
- *
- * Returns:
- * None
- *
- */
-static void
-cl_vector_copy8(OUT void *const p_dest,
- IN const void *const p_src, IN const size_t size)
-{
- CL_ASSERT(size == sizeof(uint8_t));
- UNUSED_PARAM(size);
-
- *(uint8_t *) p_dest = *(uint8_t *) p_src;
-}
-
-/*
- * cl_vector_copy16
- *
- * Description:
- * copy operator used when the user structure is only 16 bits long.
- *
- * Inputs:
- * p_src - source for copy
- *
- * Outputs:
- * p_dest - destination for copy
- *
- * Returns:
- * None
- *
- */
-void
-cl_vector_copy16(OUT void *const p_dest,
- IN const void *const p_src, IN const size_t size)
-{
- CL_ASSERT(size == sizeof(uint16_t));
- UNUSED_PARAM(size);
-
- *(uint16_t *) p_dest = *(uint16_t *) p_src;
-}
-
-/*
- * cl_vector_copy32
- *
- * Description:
- * copy operator used when the user structure is only 32 bits long.
- *
- * Inputs:
- * p_src - source for copy
- *
- * Outputs:
- * p_dest - destination for copy
- *
- * Returns:
- * None
- *
- */
-void
-cl_vector_copy32(OUT void *const p_dest,
- IN const void *const p_src, IN const size_t size)
-{
- CL_ASSERT(size == sizeof(uint32_t));
- UNUSED_PARAM(size);
-
- *(uint32_t *) p_dest = *(uint32_t *) p_src;
-}
-
-/*
- * cl_vector_copy64
- *
- * Description:
- * copy operator used when the user structure is only 64 bits long.
- *
- * Inputs:
- * p_src - source for copy
- *
- * Outputs:
- * p_dest - destination for copy
- *
- * Returns:
- * None
- *
- */
-void
-cl_vector_copy64(OUT void *const p_dest,
- IN const void *const p_src, IN const size_t size)
-{
- CL_ASSERT(size == sizeof(uint64_t));
- UNUSED_PARAM(size);
-
- *(uint64_t *) p_dest = *(uint64_t *) p_src;
-}
-
-void cl_vector_construct(IN cl_vector_t * const p_vector)
-{
- CL_ASSERT(p_vector);
-
- memset(p_vector, 0, sizeof(cl_vector_t));
-
- p_vector->state = CL_UNINITIALIZED;
-}
-
-cl_status_t
-cl_vector_init(IN cl_vector_t * const p_vector,
- IN const size_t min_size,
- IN const size_t grow_size,
- IN const size_t element_size,
- IN cl_pfn_vec_init_t pfn_init OPTIONAL,
- IN cl_pfn_vec_dtor_t pfn_dtor OPTIONAL,
- IN const void *const context)
-{
- cl_status_t status = CL_SUCCESS;
-
- CL_ASSERT(p_vector);
- CL_ASSERT(element_size);
-
- cl_vector_construct(p_vector);
-
- p_vector->grow_size = grow_size;
- p_vector->element_size = element_size;
- p_vector->pfn_init = pfn_init;
- p_vector->pfn_dtor = pfn_dtor;
- p_vector->context = context;
-
- /*
- * Try to choose a smart copy operator
- * someday, we could simply let the users pass one in
- */
- switch (element_size) {
- case sizeof(uint8_t):
- p_vector->pfn_copy = cl_vector_copy8;
- break;
-
- case sizeof(uint16_t):
- p_vector->pfn_copy = cl_vector_copy16;
- break;
-
- case sizeof(uint32_t):
- p_vector->pfn_copy = cl_vector_copy32;
- break;
-
- case sizeof(uint64_t):
- p_vector->pfn_copy = cl_vector_copy64;
- break;
-
- default:
- p_vector->pfn_copy = cl_vector_copy_general;
- break;
- }
-
- /*
- * Set the state to initialized so that the call to set_size
- * doesn't assert.
- */
- p_vector->state = CL_INITIALIZED;
-
- /* Initialize the allocation list */
- cl_qlist_init(&p_vector->alloc_list);
-
- /* get the storage needed by the user */
- if (min_size) {
- status = cl_vector_set_size(p_vector, min_size);
- if (status != CL_SUCCESS)
- cl_vector_destroy(p_vector);
- }
-
- return (status);
-}
-
-void cl_vector_destroy(IN cl_vector_t * const p_vector)
-{
- size_t i;
- void *p_element;
-
- CL_ASSERT(p_vector);
- CL_ASSERT(cl_is_state_valid(p_vector->state));
-
- /* Call the user's destructor for each element in the array. */
- if (p_vector->state == CL_INITIALIZED) {
- if (p_vector->pfn_dtor) {
- for (i = 0; i < p_vector->size; i++) {
- p_element = p_vector->p_ptr_array[i];
- /* Sanity check! */
- CL_ASSERT(p_element);
- p_vector->pfn_dtor(p_element,
- (void *)p_vector->context);
- }
- }
-
- /* Deallocate the pages */
- while (!cl_is_qlist_empty(&p_vector->alloc_list))
- free(cl_qlist_remove_head(&p_vector->alloc_list));
-
- /* Destroy the page vector. */
- if (p_vector->p_ptr_array) {
- free(p_vector->p_ptr_array);
- p_vector->p_ptr_array = NULL;
- }
- }
-
- p_vector->state = CL_UNINITIALIZED;
-}
-
-cl_status_t
-cl_vector_at(IN const cl_vector_t * const p_vector,
- IN const size_t index, OUT void *const p_element)
-{
- CL_ASSERT(p_vector);
- CL_ASSERT(p_vector->state == CL_INITIALIZED);
-
- /* Range check */
- if (index >= p_vector->size)
- return (CL_INVALID_PARAMETER);
-
- cl_vector_get(p_vector, index, p_element);
- return (CL_SUCCESS);
-}
-
-cl_status_t
-cl_vector_set(IN cl_vector_t * const p_vector,
- IN const size_t index, IN void *const p_element)
-{
- cl_status_t status;
- void *p_dest;
-
- CL_ASSERT(p_vector);
- CL_ASSERT(p_vector->state == CL_INITIALIZED);
- CL_ASSERT(p_element);
-
- /* Determine if the vector has room for this element. */
- if (index >= p_vector->size) {
- /* Resize to accomodate the given index. */
- status = cl_vector_set_size(p_vector, index + 1);
-
- /* Check for failure on or before the given index. */
- if ((status != CL_SUCCESS) && (p_vector->size < index))
- return (status);
- }
-
- /* At this point, the array is guaranteed to be big enough */
- p_dest = cl_vector_get_ptr(p_vector, index);
- /* Sanity check! */
- CL_ASSERT(p_dest);
-
- /* Copy the data into the array */
- p_vector->pfn_copy(p_dest, p_element, p_vector->element_size);
-
- return (CL_SUCCESS);
-}
-
-cl_status_t
-cl_vector_set_capacity(IN cl_vector_t * const p_vector,
- IN const size_t new_capacity)
-{
- size_t new_elements;
- size_t alloc_size;
- size_t i;
- cl_list_item_t *p_buf;
- void *p_new_ptr_array;
-
- CL_ASSERT(p_vector);
- CL_ASSERT(p_vector->state == CL_INITIALIZED);
-
- /* Do we have to do anything here? */
- if (new_capacity <= p_vector->capacity) {
- /* Nope */
- return (CL_SUCCESS);
- }
-
- /* Allocate our pointer array. */
- p_new_ptr_array = malloc(new_capacity * sizeof(void *));
- if (!p_new_ptr_array)
- return (CL_INSUFFICIENT_MEMORY);
- else
- memset(p_new_ptr_array, 0, new_capacity * sizeof(void *));
-
- if (p_vector->p_ptr_array) {
- /* Copy the old pointer array into the new. */
- memcpy(p_new_ptr_array, p_vector->p_ptr_array,
- p_vector->capacity * sizeof(void *));
-
- /* Free the old pointer array. */
- free(p_vector->p_ptr_array);
- }
-
- /* Set the new array. */
- p_vector->p_ptr_array = p_new_ptr_array;
-
- /*
- * We have to add capacity to the array. Determine how many
- * elements to add.
- */
- new_elements = new_capacity - p_vector->capacity;
- /* Determine the allocation size for the new array elements. */
- alloc_size = new_elements * p_vector->element_size;
-
- p_buf = (cl_list_item_t *) malloc(alloc_size + sizeof(cl_list_item_t));
- if (!p_buf)
- return (CL_INSUFFICIENT_MEMORY);
- else
- memset(p_buf, 0, alloc_size + sizeof(cl_list_item_t));
-
- cl_qlist_insert_tail(&p_vector->alloc_list, p_buf);
- /* Advance the buffer pointer past the list item. */
- p_buf++;
-
- for (i = p_vector->capacity; i < new_capacity; i++) {
- p_vector->p_ptr_array[i] = p_buf;
- /* Move the buffer pointer to the next element. */
- p_buf = (void *)(((uint8_t *) p_buf) + p_vector->element_size);
- }
-
- /* Update the vector with the new capactity. */
- p_vector->capacity = new_capacity;
-
- return (CL_SUCCESS);
-}
-
-cl_status_t
-cl_vector_set_size(IN cl_vector_t * const p_vector, IN const size_t size)
-{
- cl_status_t status;
- size_t new_capacity;
- size_t index;
- void *p_element;
-
- CL_ASSERT(p_vector);
- CL_ASSERT(p_vector->state == CL_INITIALIZED);
-
- /* Check to see if the requested size is the same as the existing size. */
- if (size == p_vector->size)
- return (CL_SUCCESS);
-
- /* Determine if the vector has room for this element. */
- if (size >= p_vector->capacity) {
- if (!p_vector->grow_size)
- return (CL_INSUFFICIENT_MEMORY);
-
- /* Calculate the new capacity, taking into account the grow size. */
- new_capacity = size;
- if (size % p_vector->grow_size) {
- /* Round up to nearest grow_size boundary. */
- new_capacity += p_vector->grow_size -
- (size % p_vector->grow_size);
- }
-
- status = cl_vector_set_capacity(p_vector, new_capacity);
- if (status != CL_SUCCESS)
- return (status);
- }
-
- /* Are we growing the array and need to invoke an initializer callback? */
- if (size > p_vector->size && p_vector->pfn_init) {
- for (index = p_vector->size; index < size; index++) {
- /* Get a pointer to this element */
- p_element = cl_vector_get_ptr(p_vector, index);
-
- /* Call the user's initializer and trap failures. */
- status =
- p_vector->pfn_init(p_element,
- (void *)p_vector->context);
- if (status != CL_SUCCESS) {
- /* Call the destructor for this object */
- if (p_vector->pfn_dtor)
- p_vector->pfn_dtor(p_element,
- (void *)p_vector->
- context);
-
- /* Return the failure status to the caller. */
- return (status);
- }
-
- /* The array just grew by one element */
- p_vector->size++;
- }
- } else if (p_vector->pfn_dtor) {
- /* The array is shrinking and there is a destructor to invoke. */
- for (index = size; index < p_vector->size; index++) {
- /* compute the address of the new elements */
- p_element = cl_vector_get_ptr(p_vector, index);
- /* call the user's destructor */
- p_vector->pfn_dtor(p_element,
- (void *)p_vector->context);
- }
- }
-
- p_vector->size = size;
- return (CL_SUCCESS);
-}
-
-cl_status_t
-cl_vector_set_min_size(IN cl_vector_t * const p_vector,
- IN const size_t min_size)
-{
- CL_ASSERT(p_vector);
- CL_ASSERT(p_vector->state == CL_INITIALIZED);
-
- if (min_size > p_vector->size) {
- /* We have to resize the array */
- return (cl_vector_set_size(p_vector, min_size));
- }
-
- /* We didn't have to do anything */
- return (CL_SUCCESS);
-}
-
-void
-cl_vector_apply_func(IN const cl_vector_t * const p_vector,
- IN cl_pfn_vec_apply_t pfn_callback,
- IN const void *const context)
-{
- size_t i;
- void *p_element;
-
- CL_ASSERT(p_vector);
- CL_ASSERT(p_vector->state == CL_INITIALIZED);
- CL_ASSERT(pfn_callback);
-
- for (i = 0; i < p_vector->size; i++) {
- p_element = cl_vector_get_ptr(p_vector, i);
- pfn_callback(i, p_element, (void *)context);
- }
-}
-
-size_t
-cl_vector_find_from_start(IN const cl_vector_t * const p_vector,
- IN cl_pfn_vec_find_t pfn_callback,
- IN const void *const context)
-{
- size_t i;
- void *p_element;
-
- CL_ASSERT(p_vector);
- CL_ASSERT(p_vector->state == CL_INITIALIZED);
- CL_ASSERT(pfn_callback);
-
- for (i = 0; i < p_vector->size; i++) {
- p_element = cl_vector_get_ptr(p_vector, i);
- /* Invoke the callback */
- if (pfn_callback(i, p_element, (void *)context) == CL_SUCCESS)
- break;
- }
- return (i);
-}
-
-size_t
-cl_vector_find_from_end(IN const cl_vector_t * const p_vector,
- IN cl_pfn_vec_find_t pfn_callback,
- IN const void *const context)
-{
- size_t i;
- void *p_element;
-
- CL_ASSERT(p_vector);
- CL_ASSERT(p_vector->state == CL_INITIALIZED);
- CL_ASSERT(pfn_callback);
-
- i = p_vector->size;
-
- while (i) {
- /* Get a pointer to the element in the array. */
- p_element = cl_vector_get_ptr(p_vector, --i);
- CL_ASSERT(p_element);
-
- /* Invoke the callback for the current element. */
- if (pfn_callback(i, p_element, (void *)context) == CL_SUCCESS)
- return (i);
- }
-
- return (p_vector->size);
-}
diff --git a/contrib/ofed/management/opensm/complib/libosmcomp.map b/contrib/ofed/management/opensm/complib/libosmcomp.map
deleted file mode 100644
index 788eb2a..0000000
--- a/contrib/ofed/management/opensm/complib/libosmcomp.map
+++ /dev/null
@@ -1,154 +0,0 @@
-OSMCOMP_2.3 {
- global:
- complib_init;
- complib_exit;
- cl_is_debug;
- cl_disp_construct;
- cl_disp_init;
- cl_disp_destroy;
- cl_disp_register;
- cl_disp_unregister;
- cl_disp_post;
- cl_disp_shutdown;
- cl_disp_get_queue_status;
- cl_event_construct;
- cl_event_init;
- cl_event_destroy;
- cl_event_signal;
- cl_event_reset;
- cl_event_wait_on;
- cl_event_wheel_construct;
- cl_event_wheel_init;
- cl_event_wheel_init_ex;
- cl_event_wheel_destroy;
- cl_event_wheel_dump;
- cl_event_wheel_reg;
- cl_event_wheel_unreg;
- cl_event_wheel_num_regs;
- cl_qlist_insert_array_head;
- cl_qlist_insert_array_tail;
- cl_qlist_insert_list_head;
- cl_qlist_insert_list_tail;
- cl_is_item_in_qlist;
- cl_qlist_find_next;
- cl_qlist_find_prev;
- cl_qlist_apply_func;
- cl_qlist_move_items;
- cl_list_construct;
- cl_list_init;
- cl_list_destroy;
- cl_list_remove_object;
- cl_is_object_in_list;
- cl_list_insert_array_head;
- cl_list_insert_array_tail;
- cl_list_find_from_head;
- cl_list_find_from_tail;
- cl_list_apply_func;
- cl_log_event;
- cl_qmap_init;
- cl_qmap_get;
- cl_qmap_get_next;
- cl_qmap_apply_func;
- cl_qmap_insert;
- cl_qmap_remove_item;
- cl_qmap_remove;
- cl_qmap_merge;
- cl_qmap_delta;
- cl_map_construct;
- cl_map_init;
- cl_map_destroy;
- cl_map_insert;
- cl_map_get;
- cl_map_get_next;
- cl_map_remove_item;
- cl_map_remove;
- cl_map_remove_all;
- cl_map_merge;
- cl_map_delta;
- cl_fmap_init;
- cl_fmap_get;
- cl_fmap_get_next;
- cl_fmap_apply_func;
- cl_fmap_insert;
- cl_fmap_remove_item;
- cl_fmap_remove;
- cl_fmap_merge;
- cl_fmap_delta;
- cl_qcpool_construct;
- cl_qcpool_init;
- cl_qcpool_destroy;
- cl_qcpool_grow;
- cl_qcpool_get;
- cl_qcpool_get_tail;
- cl_qpool_construct;
- cl_qpool_init;
- cl_cpool_construct;
- cl_cpool_init;
- cl_pool_construct;
- cl_pool_init;
- cl_ptr_vector_construct;
- cl_ptr_vector_init;
- cl_ptr_vector_destroy;
- cl_ptr_vector_at;
- cl_ptr_vector_set;
- cl_ptr_vector_remove;
- cl_ptr_vector_set_capacity;
- cl_ptr_vector_set_size;
- cl_ptr_vector_set_min_size;
- cl_ptr_vector_apply_func;
- cl_ptr_vector_find_from_start;
- cl_ptr_vector_find_from_end;
- cl_spinlock_construct;
- cl_spinlock_init;
- cl_spinlock_destroy;
- cl_spinlock_acquire;
- cl_spinlock_release;
- cl_status_text;
- cl_thread_construct;
- cl_thread_init;
- cl_thread_destroy;
- cl_thread_suspend;
- cl_thread_stall;
- cl_proc_count;
- cl_is_current_thread;
- cl_thread_pool_construct;
- cl_thread_pool_init;
- cl_thread_pool_destroy;
- cl_thread_pool_signal;
- __cl_timer_prov_create;
- __cl_timer_prov_destroy;
- cl_timer_construct;
- cl_timer_init;
- cl_timer_destroy;
- cl_timer_start;
- cl_timer_stop;
- cl_timer_trim;
- cl_get_time_stamp;
- cl_get_time_stamp_sec;
- cl_vector_copy_general;
- cl_vector_copy16;
- cl_vector_copy32;
- cl_vector_copy64;
- cl_vector_construct;
- cl_vector_init;
- cl_vector_destroy;
- cl_vector_at;
- cl_vector_set;
- cl_vector_set_capacity;
- cl_vector_set_size;
- cl_vector_set_min_size;
- cl_vector_apply_func;
- cl_vector_find_from_start;
- cl_vector_find_from_end;
- cl_atomic_spinlock;
- cl_atomic_dec;
- ib_error_str;
- ib_async_event_str;
- ib_wc_status_str;
- open_node_name_map;
- close_node_name_map;
- parse_node_map;
- remap_node_name;
- clean_nodedesc;
- local: *;
-};
diff --git a/contrib/ofed/management/opensm/complib/libosmcomp.ver b/contrib/ofed/management/opensm/complib/libosmcomp.ver
deleted file mode 100644
index f076585..0000000
--- a/contrib/ofed/management/opensm/complib/libosmcomp.ver
+++ /dev/null
@@ -1,9 +0,0 @@
-# In this file we track the current API version
-# of the complib library interface
-# The version is built of the following
-# tree numbers:
-# API_REV:RUNNING_REV:AGE
-# API_REV - advance on any added API
-# RUNNING_REV - advance any change to the vendor files
-# AGE - number of backward versions the API still supports
-LIBVERSION=2:4:0
diff --git a/contrib/ofed/management/opensm/config/osmvsel.m4 b/contrib/ofed/management/opensm/config/osmvsel.m4
deleted file mode 100644
index c7798cc..0000000
--- a/contrib/ofed/management/opensm/config/osmvsel.m4
+++ /dev/null
@@ -1,259 +0,0 @@
-
-dnl osmvsel.m4: an autoconf for OpenSM Vendor Selection option
-dnl
-dnl To use this macro, just do OPENIB_APP_OSMV_SEL.
-dnl the new configure option --with-osmv will be defined.
-dnl current supported values are: openib(default),sim,gen1
-dnl The following variables are defined:
-dnl OSMV_LDADD - LDADD additional libs for linking the vendor lib
-AC_DEFUN([OPENIB_APP_OSMV_SEL], [
-# --- BEGIN OPENIB_APP_OSMV_SEL ---
-
-dnl Define a way for the user to provide the osm vendor type
-AC_ARG_WITH(osmv,
- AC_HELP_STRING([--with-osmv=<type>],
- [define the osm vendor type to build]),
-AC_MSG_NOTICE(Using OSM Vendor Type:$with_osmv),
-with_osmv="openib")
-
-dnl Define a way for the user to provide the path to the ibumad installation
-AC_ARG_WITH(umad-prefix,
- AC_HELP_STRING([--with-umad-prefix=<dir>],
- [define the dir used as prefix for ibumad installation]),
-AC_MSG_NOTICE(Using ibumad installation prefix:$with_umad_prefix),
-with_umad_prefix="")
-
-dnl Define a way for the user to provide the path to the ibumad includes
-AC_ARG_WITH(umad-includes,
- AC_HELP_STRING([--with-umad-includes=<dir>],
- [define the dir where ibumad includes are installed]),
-AC_MSG_NOTICE(Using ibumad includes from:$with_umad_includes),
-with_umad_includes="")
-
-if test x$with_umad_includes = x; then
- if test x$with_umad_prefix != x; then
- with_umad_includes=$with_umad_prefix/include
- fi
-fi
-
-dnl Define a way for the user to provide the path to the ibumad libs
-AC_ARG_WITH(umad-libs,
- AC_HELP_STRING([--with-umad-libs=<dir>],
- [define the dir where ibumad libs are installed]),
-AC_MSG_NOTICE(Using ibumad libs from:$with_umad_libs),
-with_umad_libs="")
-
-if test x$with_umad_libs = x; then
- if test x$with_umad_prefix != x; then
-dnl Should we use lib64 or lib
- if test "$(uname -m)" = "x86_64" -o "$(uname -m)" = "ppc64"; then
- with_umad_libs=$with_umad_prefix/lib64
- else
- with_umad_libs=$with_umad_prefix/lib
- fi
- fi
-fi
-
-dnl Define a way for the user to provide the path to the simulator installation
-AC_ARG_WITH(sim,
- AC_HELP_STRING([--with-sim=<dir>],
- [define the simulator prefix for building sim vendor (default /usr)]),
-AC_MSG_NOTICE(Using Simulator from:$with_sim),
-with_sim="/usr")
-
-dnl based on the with_osmv we can try the vendor flag
-if test $with_osmv = "openib"; then
- AC_DEFINE(OSM_VENDOR_INTF_OPENIB, 1, [Define as 1 for OpenIB vendor])
- OSMV_INCLUDES="-I\$(srcdir)/../include -I\$(srcdir)/../../libibcommon/include -I\$(srcdir)/../../libibumad/include -I\$(includedir)"
- OSMV_LDADD="-L\$(abs_srcdir)/../../libibumad/.libs -L\$(abs_srcdir)/../../libibcommon/.libs -L\$(libdir) -libumad -libcommon"
-
- if test "x$with_umad_libs" != "x"; then
- OSMV_LDADD="-L$with_umad_libs $OSMV_LDADD"
- fi
-
- if test "x$with_umad_includes" != "x"; then
- OSMV_INCLUDES="-I$with_umad_includes $OSMV_INCLUDES"
- fi
- AC_DEFINE(DUAL_SIDED_RMPP, 1, [Define as 1 if you want Dual Sided RMPP Support])
-elif test $with_osmv = "sim" ; then
- AC_DEFINE(OSM_VENDOR_INTF_SIM, 1, [Define as 1 for sim vendor])
- OSMV_INCLUDES="-I$with_sim/include -I\$(srcdir)/../include"
- OSMV_LDADD="-L$with_sim/lib -libmscli"
-elif test $with_osmv = "gen1"; then
- AC_DEFINE(OSM_VENDOR_INTF_TS, 1, [Define as 1 for ts vendor])
-
- if test -z $MTHOME; then
- MTHOME=/usr/local/ibgd/driver/infinihost
- fi
-
- OSMV_INCLUDES="-I$MTHOME/include -I\$(srcdir)/../include"
-
- dnl we need to find the TS includes somewhere...
- osmv_found=0
- if test -z $TSHOME; then
- osmv_dir=`uname -r|sed 's/-smp//'`
- osmv_dir_smp=`uname -r`
- for d in /usr/src/linux-$osmv_dir /usr/src/linux-$osmv_dir_smp /lib/modules/$osmv_dir/build /lib/modules/$osmv_dir_smp/build/; do
- if test -f $d/drivers/infiniband/include/ts_ib_useraccess.h; then
- OSMV_INCLUDES="$OSMV_INCLUDES -I$d/drivers/infiniband/include"
- osmv_found=1
- fi
- done
- else
- if test -f $TSHOME/ts_ib_useraccess.h; then
- OSMV_INCLUDES="$OSMV_INCLUDES -I$TSHOME"
- osmv_found=1
- fi
- fi
- if test $osmv_found = 0; then
- AC_MSG_ERROR([Fail to find gen1 include files dir])
- fi
- OSMV_LDADD="-L/usr/local/ibgd/driver/infinihost/lib -lvapi -lmosal -lmtl_common -lmpga"
-elif test $with_osmv = "vapi"; then
- AC_DEFINE(OSM_VENDOR_INTF_MTL, 1, [Define as 1 for vapi vendor])
- OSMV_INCLUDES="-I/usr/mellanox/include -I/usr/include -I\$(srcdir)/../include"
- OSMV_LDADD="-L/usr/lib -L/usr/mellanox/lib -lib_mgt -lvapi -lmosal -lmtl_common -lmpga"
-else
- AC_MSG_ERROR([Invalid Vendor Type provided:$with_osmv should be either openib,sim,gen1])
-fi
-
-AM_CONDITIONAL(OSMV_VAPI, test $with_osmv = "vapi")
-AM_CONDITIONAL(OSMV_GEN1, test $with_osmv = "gen1")
-AM_CONDITIONAL(OSMV_SIM, test $with_osmv = "sim")
-AM_CONDITIONAL(OSMV_OPENIB, test $with_osmv = "openib")
-AC_DEFINE(VENDOR_RMPP_SUPPORT, 1, [Define as 1 if you want Vendor RMPP Support])
-
-AC_SUBST(OSMV_LDADD)
-AC_SUBST(OSMV_INCLUDES)
-
-# --- END OPENIB_APP_OSMV_SEL ---
-]) dnl OPENIB_APP_OSMV_SEL
-
-dnl Check for the vendor lib dependency
-AC_DEFUN([OPENIB_APP_OSMV_CHECK_LIB], [
-# --- BEGIN OPENIB_APP_OSMV_CHECK_LIB ---
-if test "$disable_libcheck" != "yes"; then
-
- dnl based on the with_osmv we can try the vendor flag
- if test $with_osmv = "openib"; then
- LDADD="$LDADD $OSMV_LDADD"
- AC_CHECK_LIB(ibumad, umad_init, [],
- AC_MSG_ERROR([umad_init() not found. libosmvendor of type openib requires libibumad.]))
- elif test $with_osmv = "sim" ; then
- LDFLAGS="$LDFLAGS -L$with_sim/lib"
- AC_CHECK_FILE([$with_sim/lib/libibmscli.a], [],
- AC_MSG_ERROR([ibms_bind() not found. libosmvendor of type sim requires libibmscli.]))
- elif test $with_osmv = "gen1"; then
- LDFLAGS="$LDFLAGS -L$MTHOME/lib -L$MTHOME/lib64 -lmosal -lmtl_common -lmpga"
- AC_CHECK_LIB(vapi, vipul_init, [],
- AC_MSG_ERROR([vipul_init() not found. libosmvendor of type gen1 requires libvapi.]))
- elif test $with_osmv != "vapi"; then
- AC_MSG_ERROR([OSM Vendor Type not defined: please make sure OPENIB_APP_OSMV SEL is run before CHECK_LIB])
- fi
-fi
-# --- END OPENIB_APP_OSMV_CHECK_LIB ---
-]) dnl OPENIB_APP_OSMV_CHECK_LIB
-
-dnl Check for the vendor lib dependency
-AC_DEFUN([OPENIB_APP_OSMV_CHECK_HEADER], [
-# --- BEGIN OPENIB_APP_OSMV_CHECK_HEADER ---
-
-dnl we might be required to ignore this check
-if test "$disable_libcheck" != "yes"; then
- if test $with_osmv = "openib"; then
- osmv_headers=infiniband/umad.h
- elif test $with_osmv = "sim" ; then
- osmv_headers=ibmgtsim/ibms_client_api.h
- elif test $with_osmv = "gen1"; then
- osmv_headers=
- elif test $with_osmv = "vapi"; then
- osmv_headers=vapi.h
- else
- AC_MSG_ERROR([OSM Vendor Type not defined: please make sure OPENIB_APP_OSMV SEL is run before CHECK_HEADER])
- fi
- if test "x$osmv_headers" != "x"; then
- AC_CHECK_HEADERS($osmv_headers)
- fi
-fi
-# --- END OPENIB_APP_OSMV_CHECK_HEADER ---
-]) dnl OPENIB_APP_OSMV_CHECK_HEADER
-
-dnl Check if they want the socket console
-AC_DEFUN([OPENIB_OSM_CONSOLE_SOCKET_SEL], [
-# --- BEGIN OPENIB_OSM_CONSOLE_SOCKET_SEL ---
-
-dnl Console over a socket connection
-AC_ARG_ENABLE(console-socket,
-[ --enable-console-socket Enable a console socket, requires tcp_wrappers (default no)],
-[case $enableval in
- yes) console_socket=yes ;;
- no) console_socket=no ;;
- esac],
- console_socket=no)
-if test $console_socket = yes; then
- AC_CHECK_LIB(wrap, request_init, [],
- AC_MSG_ERROR([request_init() not found. console-socket requires libwrap.]))
- AC_DEFINE(ENABLE_OSM_CONSOLE_SOCKET,
- 1,
- [Define as 1 if you want to enable a console on a socket connection])
-fi
-# --- END OPENIB_OSM_CONSOLE_SOCKET_SEL ---
-]) dnl OPENIB_OSM_CONSOLE_SOCKET_SEL
-
-dnl Check if they want the PerfMgr
-AC_DEFUN([OPENIB_OSM_PERF_MGR_SEL], [
-# --- BEGIN OPENIB_OSM_PERF_MGR_SEL ---
-
-dnl enable the perf-mgr
-AC_ARG_ENABLE(perf-mgr,
-[ --enable-perf-mgr Enable the performance manager (default no)],
- [case $enableval in
- yes) perf_mgr=yes ;;
- no) perf_mgr=no ;;
- esac],
- perf_mgr=no)
-AC_ARG_ENABLE(perf-mgr-profile,
-[ --enable-perf-mgr-profile Enable the performance manager profiling (default no)],
- [case $enableval in
- yes) perf_mgr_profile=yes ;;
- no) perf_mgr_profile=no ;;
- esac],
- perf_mgr_profile=no)
-if test $perf_mgr = yes; then
- AC_DEFINE(ENABLE_OSM_PERF_MGR,
- 1,
- [Define as 1 if you want to enable the performance manager])
- if test $perf_mgr_profile = yes; then
- AC_DEFINE(ENABLE_OSM_PERF_MGR_PROFILE,
- 1,
- [Define as 1 if you want to enable the performance manager profiling code])
- fi
-fi
-# --- END OPENIB_OSM_PERF_MGR_SEL ---
-]) dnl OPENIB_OSM_PERF_MGR_SEL
-
-
-dnl Check if they want the event plugin
-AC_DEFUN([OPENIB_OSM_DEFAULT_EVENT_PLUGIN_SEL], [
-# --- BEGIN OPENIB_OSM_DEFAULT_EVENT_PLUGIN_SEL ---
-
-dnl enable the default-event-plugin
-AC_ARG_ENABLE(default-event-plugin,
-[ --enable-default-event-plugin Enable a default event plugin "osmeventplugin" (default no)],
- [case $enableval in
- yes) default_event_plugin=yes ;;
- no) default_event_plugin=no ;;
- esac],
- default_event_plugin=no)
-if test $default_event_plugin = yes; then
- AC_DEFINE(ENABLE_OSM_DEFAULT_EVENT_PLUGIN,
- 1,
- [Define as 1 if you want to enable the event plugin])
- DEFAULT_EVENT_PLUGIN=osmeventplugin
-else
- DEFAULT_EVENT_PLUGIN=
-fi
-AC_SUBST([DEFAULT_EVENT_PLUGIN])
-
-# --- END OPENIB_OSM_DEFAULT_EVENT_PLUGIN_SEL ---
-]) dnl OPENIB_OSM_DEFAULT_EVENT_PLUGIN_SEL
diff --git a/contrib/ofed/management/opensm/configure.in b/contrib/ofed/management/opensm/configure.in
deleted file mode 100644
index 4479031..0000000
--- a/contrib/ofed/management/opensm/configure.in
+++ /dev/null
@@ -1,232 +0,0 @@
-dnl Process this file with autoconf to produce a configure script.
-
-AC_PREREQ(2.57)
-AC_INIT(opensm, 3.3.0, general@lists.openfabrics.org)
-AC_CONFIG_SRCDIR([opensm/osm_opensm.c])
-AC_CONFIG_AUX_DIR(config)
-AC_CONFIG_HEADERS(include/config.h include/opensm/osm_config.h)
-AM_INIT_AUTOMAKE
-
-AC_SUBST(RELEASE, ${RELEASE:-unknown})
-AC_SUBST(TARBALL, ${TARBALL:-${PACKAGE}-${VERSION}.tar.gz})
-
-dnl NOTE: AC_DEFINE's and AC_DEFINE_UNQUOTED's which are used in header files
-dnl MUST have a corresponding entry in include/opensm/osm_config.h.in to
-dnl ensure plugin compatibility.
-AC_DEFINE(_OSM_CONFIG_H_, 1, mark config.h inclusion)
-
-dnl Defines the Language
-AC_LANG_C
-
-dnl Required for cases make defines a MAKE=make ??? Why
-AC_PROG_MAKE_SET
-AC_PROG_CC
-AC_PROG_LIBTOOL
-AC_PROG_INSTALL
-AC_PROG_LN_S
-AC_PROG_MAKE_SET
-AC_PROG_YACC
-AC_PROG_LEX
-
-AC_CHECK_PROGS(_YACC_,$YACC,none)
-if test "$_YACC_" = "none"
-then
- AC_MSG_ERROR([No bison/byacc/yacc found.])
-fi
-
-AC_CHECK_PROGS(_LEX_,$LEX,none)
-if test "$_LEX_" = "none"
-then
- AC_MSG_ERROR([No flex/lex found.])
-fi
-
-dnl Checks for libraries
-AC_CHECK_LIB(pthread, pthread_mutex_init, [],
- AC_MSG_ERROR([pthread_mutex_init() not found. libosmcomp requires libpthread.]))
-AC_CHECK_LIB(dl, dlopen, [],
- AC_MSG_ERROR([dlopen() not found. OpenSM requires libdl.]))
-
-dnl Checks for typedefs, structures, and compiler characteristics.
-AC_C_CONST
-AC_C_INLINE
-AC_TYPE_PID_T
-AC_TYPE_SIZE_T
-AC_HEADER_TIME
-AC_STRUCT_TM
-AC_C_VOLATILE
-
-dnl We use --version-script with ld if possible
-AC_CACHE_CHECK(whether ld accepts --version-script, ac_cv_version_script,
-if test -n "`$LD --help < /dev/null 2>/dev/null | grep version-script`"; then
- ac_cv_version_script=yes
-else
- ac_cv_version_script=no
-fi)
-AM_CONDITIONAL(HAVE_LD_VERSION_SCRIPT, test "$ac_cv_version_script" = "yes")
-
-dnl Define an input config option to control debug compile
-AC_ARG_ENABLE(debug, [ --enable-debug Turn on debugging],
-[case "${enableval}" in
- yes) debug=true ;;
- no) debug=false ;;
- *) AC_MSG_ERROR(bad value ${enableval} for --enable-debug) ;;
-esac],debug=false)
-if test x$debug = xtrue ; then
- AC_DEFINE(OSM_DEBUG, 1, [ define 1 if OpenSM build is in a debug mode ])
-fi
-AM_CONDITIONAL(DEBUG, test x$debug = xtrue)
-
-AC_ARG_ENABLE(libcheck, [ --disable-libcheck do not test for presence of ib libraries],
-[if test x$enableval = xno ; then
- disable_libcheck=yes
-fi])
-
-dnl check if they want the socket console
-OPENIB_OSM_CONSOLE_SOCKET_SEL
-
-dnl select performance manager or not
-OPENIB_OSM_PERF_MGR_SEL
-
-dnl resolve <sysconfdir> config dir.
-conf_dir_tmp1="`eval echo ${sysconfdir} | sed 's/^NONE/$ac_default_prefix/'`"
-SYS_CONFIG_DIR="`eval echo $conf_dir_tmp1`"
-
-dnl Check for a different subdir for the config files.
-OPENSM_CONFIG_SUB_DIR=opensm
-AC_MSG_CHECKING(for --with-opensm-conf-sub-dir)
-AC_ARG_WITH(opensm-conf-sub-dir,
- AC_HELP_STRING([--with-opensm-conf-sub-dir=dir],
- [define a directory name for opensm's conf files <sysconfdir>/<dir> (default "opensm")]),
- [ case "$withval" in
- no)
- ;;
- *)
- OPENSM_CONFIG_SUB_DIR=$withval
- ;;
- esac ]
-)
-dnl this needs to be configured for rpmbuilds separate from the full path
-dnl "OPENSM_CONFIG_DIR"
-AC_SUBST(OPENSM_CONFIG_SUB_DIR)
-
-OPENSM_CONFIG_DIR=$SYS_CONFIG_DIR/$OPENSM_CONFIG_SUB_DIR
-AC_MSG_RESULT($OPENSM_CONFIG_DIR)
-AC_DEFINE_UNQUOTED(OPENSM_CONFIG_DIR,
- ["$OPENSM_CONFIG_DIR"],
- [Define OpenSM config directory])
-AC_SUBST(OPENSM_CONFIG_DIR)
-
-dnl Check for a different default OpenSm config file
-OPENSM_CONFIG_FILE=opensm.conf
-AC_MSG_CHECKING(for --with-opensm-conf-file )
-AC_ARG_WITH(opensm-conf-file,
- AC_HELP_STRING([--with-opensm-conf-file=file],
- [define a default OpenSM config file (default opensm.conf)]),
- [ case "$withval" in
- no)
- ;;
- *)
- OPENSM_CONFIG_FILE=$withval
- ;;
- esac ]
-)
-AC_MSG_RESULT(${OPENSM_CONFIG_FILE})
-AC_DEFINE_UNQUOTED(HAVE_DEFAULT_OPENSM_CONFIG_FILE,
- ["$OPENSM_CONFIG_DIR/$OPENSM_CONFIG_FILE"],
- [Define a default OpenSM config file])
-AC_SUBST(OPENSM_CONFIG_FILE)
-
-dnl Check for a different default node name map file
-NODENAMEMAPFILE=ib-node-name-map
-AC_MSG_CHECKING(for --with-node-name-map )
-AC_ARG_WITH(node-name-map,
- AC_HELP_STRING([--with-node-name-map=file],
- [define a default node name map file (default ib-node-name-map)]),
- [ case "$withval" in
- no)
- ;;
- *)
- NODENAMEMAPFILE=$withval
- ;;
- esac ]
-)
-AC_MSG_RESULT($NODENAMEMAPFILE)
-AC_DEFINE_UNQUOTED(HAVE_DEFAULT_NODENAME_MAP,
- ["$OPENSM_CONFIG_DIR/$NODENAMEMAPFILE"],
- [Define a default node name map file])
-AC_SUBST(NODENAMEMAPFILE)
-
-dnl Check for a different partition conf file
-PARTITION_CONFIG_FILE=partitions.conf
-AC_MSG_CHECKING(for --with-partitions-conf)
-AC_ARG_WITH(partitions-conf,
- AC_HELP_STRING([--with-partitions-conf=file],
- [define a partitions config file (default partitions.conf)]),
- [ case "$withval" in
- no)
- ;;
- *)
- PARTITION_CONFIG_FILE=$withval
- ;;
- esac ]
-)
-AC_MSG_RESULT($PARTITION_CONFIG_FILE)
-AC_DEFINE_UNQUOTED(HAVE_DEFAULT_PARTITION_CONFIG_FILE,
- ["$OPENSM_CONFIG_DIR/$PARTITION_CONFIG_FILE"],
- [Define a Partition config file])
-AC_SUBST(PARTITION_CONFIG_FILE)
-
-dnl Check for a different QOS policy file
-QOS_POLICY_FILE=qos-policy.conf
-AC_MSG_CHECKING(for --with-qos-policy-conf)
-AC_ARG_WITH(qos-policy-conf,
- AC_HELP_STRING([--with-qos-policy-conf=file],
- [define a QOS policy config file (default qos-policy.conf)]),
- [ case "$withval" in
- no)
- ;;
- *)
- QOS_POLICY_FILE=$withval
- ;;
- esac ]
-)
-AC_MSG_RESULT($QOS_POLICY_FILE)
-AC_DEFINE_UNQUOTED(HAVE_DEFAULT_QOS_POLICY_FILE,
- ["$OPENSM_CONFIG_DIR/$QOS_POLICY_FILE"],
- [Define a QOS policy config file])
-AC_SUBST(QOS_POLICY_FILE)
-
-dnl Check for a different prefix-routes file
-PREFIX_ROUTES_FILE=prefix-routes.conf
-AC_MSG_CHECKING(for --with-prefix-routes-conf)
-AC_ARG_WITH(prefix-routes-conf,
- AC_HELP_STRING([--with-prefix-routes-conf=file],
- [define a Prefix Routes config file (default is prefix-routes.conf)]),
- [ case "$withval" in
- no)
- ;;
- *)
- PREFIX_ROUTES_FILE=$withval
- ;;
- esac ]
-)
-AC_MSG_RESULT($PREFIX_ROUTES_FILE)
-AC_DEFINE_UNQUOTED(HAVE_DEFAULT_PREFIX_ROUTES_FILE,
- ["$OPENSM_CONFIG_DIR/$PREFIX_ROUTES_FILE"],
- [Define a Prefix Routes config file])
-AC_SUBST(PREFIX_ROUTES_FILE)
-
-dnl select example event plugin or not
-OPENIB_OSM_DEFAULT_EVENT_PLUGIN_SEL
-
-dnl Provide user option to select vendor
-OPENIB_APP_OSMV_SEL
-
-dnl Checks for headers and libraries
-OPENIB_APP_OSMV_CHECK_HEADER
-OPENIB_APP_OSMV_CHECK_LIB
-
-AC_CONFIG_FILES([man/opensm.8 scripts/opensm.init scripts/redhat-opensm.init scripts/sldd.sh])
-
-dnl Create the following Makefiles
-AC_OUTPUT([include/opensm/osm_version.h Makefile include/Makefile complib/Makefile libvendor/Makefile opensm/Makefile osmeventplugin/Makefile osmtest/Makefile opensm.spec])
diff --git a/contrib/ofed/management/opensm/doc/OpenSM_PKey_Mgr.txt b/contrib/ofed/management/opensm/doc/OpenSM_PKey_Mgr.txt
deleted file mode 100644
index 31d4c83..0000000
--- a/contrib/ofed/management/opensm/doc/OpenSM_PKey_Mgr.txt
+++ /dev/null
@@ -1,78 +0,0 @@
-OpenSM Partition Management
----------------------------
-
-Roadmap:
-Phase 1 - provide partition management at the EndPort (HCA, Router and Switch
- Port 0) level with no routing affects.
-Phase 2 - routing engine should take partitions into account.
-
-Phase 1 functionality:
-
-Supported Policy:
-
-1. EndPort partition groups are to be defined by listing the
- PortGUIDs as full and limited members.
-
-2. Each partition group might be assigned an explicit P_Key (only the 15
- LSB bits are valid) or the SM should assign it randomly.
-
-3. A flag should control the generation of IPoIB broadcast group for
- that partition. Extra optional MGIDs can be provided to be setup (on
- top of the IPoIB broadcast group).
-
-4. A global flag "Disconnect Unconfigured EndPorts": If TRUE prevents
- EndPorts that are not explicitly defined as part of any partition
- (thus "unconfigured") to communicate with any other EndPort. Otherwise, it
- will let these EndPorts send packets to all other EndPorts.
-
-Functionality:
-
-1. The policy should be updated:
- - during SM bringup
- - after kill -HUP
- - through SNMP (once it is supported)
-
-2. Partition tables will be updated on full sweep (new port/trap etc).
- As a first step, the policy feasibility should be
- verified. Feasibility could be limited by the EndPorts supports for
- number of partitions, etc. Unrealizable policy should be reported
- and extra rules ignored after providing error messages.
-
-3. Each EndPort will be assigned P_Keys as follows:
-
- a. Default partition group limited membership as defined by rule #4 below.
- (only the SM port will get 0xffff).
-
- b. P_Keys for all partition groups it is part of as defined in
- the policy.
-
- c. P_Key update will preserve index for the existing P_Keys on the
- port. If port has limited resources that will require reuse of,
- on index a message will be provided and some of the settings will be
- ommitted. P_Key indexes will not change under any circumstances.
-
-4. Each Switch Leaf Port (a switch port that is connected to an
- EndPort) should be configured according to the same rules that
- apply to the EndPort connected to that switch port.
- This actually enables unauthorized port isolation (with future
- usage of M_Key and ProtectBits).
-
-5. Policy entries matching a non EndPort will be flagged as
- erroneous in the log file and ignored.
-
-6. At the end of the P_Key setting phase, a check for successful
- setting should be made.
- Errors should be clearly logged and cause a new sweep.
-
-7. Each partition that is marked to support IPoIB should define a
- broadcast MGRP. If the partition does not support IPoIB, it should
- define a dummy MGRP with parameters blocking IPoIB drivers from
- registering to it.
-
-Phase 2 functionality:
-
-The partition policy should be considered during the routing such that
-links are associated with particular partition or a set of
-partitions. Policy should be enhanced to provide hints for how to do
-that (correlating to QoS too). The exact algorithm is TBD.
-
diff --git a/contrib/ofed/management/opensm/doc/OpenSM_RN.pdf b/contrib/ofed/management/opensm/doc/OpenSM_RN.pdf
deleted file mode 100644
index 700924f..0000000
--- a/contrib/ofed/management/opensm/doc/OpenSM_RN.pdf
+++ /dev/null
Binary files differ
diff --git a/contrib/ofed/management/opensm/doc/OpenSM_UM.pdf b/contrib/ofed/management/opensm/doc/OpenSM_UM.pdf
deleted file mode 100644
index ae32826..0000000
--- a/contrib/ofed/management/opensm/doc/OpenSM_UM.pdf
+++ /dev/null
Binary files differ
diff --git a/contrib/ofed/management/opensm/doc/QoS_management_in_OpenSM.txt b/contrib/ofed/management/opensm/doc/QoS_management_in_OpenSM.txt
deleted file mode 100644
index 8c9915f..0000000
--- a/contrib/ofed/management/opensm/doc/QoS_management_in_OpenSM.txt
+++ /dev/null
@@ -1,492 +0,0 @@
-
- QoS Management in OpenSM
-
-==============================================================================
- Table of contents
-==============================================================================
-
-1. Overview
-2. Full QoS Policy File
-3. Simplified QoS Policy Definition
-4. Policy File Syntax Guidelines
-5. Examples of Full Policy File
-6. Simplified QoS Policy - Details and Examples
-7. SL2VL Mapping and VL Arbitration
-
-
-==============================================================================
- 1. Overview
-==============================================================================
-
-When QoS in OpenSM is enabled (-Q or --qos), OpenSM looks for QoS Policy file.
-The default name of OpenSM QoS policy file is
-/usr/local/etc/opensm/qos-policy.conf. The default may be changed by using -Y
-or --qos_policy_file option with OpenSM.
-
-During fabric initialization and at every heavy sweep OpenSM parses the QoS
-policy file, applies its settings to the discovered fabric elements, and
-enforces the provided policy on client requests. The overall flow for such
-requests is:
- - The request is matched against the defined matching rules such that the
- QoS Level definition is found.
- - Given the QoS Level, path(s) search is performed with the given
- restrictions imposed by that level.
-
-There are two ways to define QoS policy:
- - Full policy, where the policy file syntax provides an administrator
- various ways to match PathRecord/MultiPathRecord (PR/MPR) request and
- enforce various QoS constraints on the requested PR/MPR
- - Simplified QoS policy definition, where an administrator would be able to
- match PR/MPR requests by various ULPs and applications running on top of
- these ULPs.
-
-While the full policy syntax is very flexible, in many cases the simplified
-policy definition would be sufficient.
-
-
-==============================================================================
- 2. Full QoS Policy File
-==============================================================================
-
-QoS policy file has the following sections:
-
-I) Port Groups (denoted by port-groups).
-This section defines zero or more port groups that can be referred later by
-matching rules (see below). Port group lists ports by:
- - Port GUID
- - Port name, which is a combination of NodeDescription and IB port number
- - PKey, which means that all the ports in the subnet that belong to
- partition with a given PKey belong to this port group
- - Partition name, which means that all the ports in the subnet that belong
- to partition with a given name belong to this port group
- - Node type, where possible node types are: CA, SWITCH, ROUTER, ALL, and
- SELF (SM's port).
-
-II) QoS Setup (denoted by qos-setup).
-This section describes how to set up SL2VL and VL Arbitration tables on
-various nodes in the fabric.
-However, this is not supported in OpenSM currently.
-SL2VL and VLArb tables should be configured in the OpenSM options file
-(default location - /usr/local/etc/opensm/opensm.conf).
-
-III) QoS Levels (denoted by qos-levels).
-Each QoS Level defines Service Level (SL) and a few optional fields:
- - MTU limit
- - Rate limit
- - PKey
- - Packet lifetime
-When path(s) search is performed, it is done with regards to restriction that
-these QoS Level parameters impose.
-One QoS level that is mandatory to define is a DEFAULT QoS level. It is
-applied to a PR/MPR query that does not match any existing match rule.
-Similar to any other QoS Level, it can also be explicitly referred by any
-match rule.
-
-IV) QoS Matching Rules (denoted by qos-match-rules).
-Each PathRecord/MultiPathRecord query that OpenSM receives is matched against
-the set of matching rules. Rules are scanned in order of appearance in the QoS
-policy file such as the first match takes precedence.
-Each rule has a name of QoS level that will be applied to the matching query.
-A default QoS level is applied to a query that did not match any rule.
-Queries can be matched by:
- - Source port group (whether a source port is a member of a specified group)
- - Destination port group (same as above, only for destination port)
- - PKey
- - QoS class
- - Service ID
-To match a certain matching rule, PR/MPR query has to match ALL the rule's
-criteria. However, not all the fields of the PR/MPR query have to appear in
-the matching rule.
-For instance, if the rule has a single criterion - Service ID, it will match
-any query that has this Service ID, disregarding rest of the query fields.
-However, if a certain query has only Service ID (which means that this is the
-only bit in the PR/MPR component mask that is on), it will not match any rule
-that has other matching criteria besides Service ID.
-
-
-==============================================================================
- 3. Simplified QoS Policy Definition
-==============================================================================
-
-Simplified QoS policy definition comprises of a single section denoted by
-qos-ulps. Similar to the full QoS policy, it has a list of match rules and
-their QoS Level, but in this case a match rule has only one criterion - its
-goal is to match a certain ULP (or a certain application on top of this ULP)
-PR/MPR request, and QoS Level has only one constraint - Service Level (SL).
-The simplified policy section may appear in the policy file in combine with
-the full policy, or as a stand-alone policy definition.
-See more details and list of match rule criteria below.
-
-
-==============================================================================
- 4. Policy File Syntax Guidelines
-==============================================================================
-
-- Empty lines are ignored.
-- Leading and trailing blanks, as well as empty lines, are ignored, so
- the indentation in the example is just for better readability.
-- Comments are started with the pound sign (#) and terminated by EOL.
-- Any keyword should be the first non-blank in the line, unless it's a
- comment.
-- Keywords that denote section/subsection start have matching closing
- keywords.
-- Having a QoS Level named "DEFAULT" is a must - it is applied to PR/MPR
- requests that didn't match any of the matching rules.
-- Any section/subsection of the policy file is optional.
-
-
-==============================================================================
- 5. Examples of Full Policy File
-==============================================================================
-
-As mentioned earlier, any section of the policy file is optional, and
-the only mandatory part of the policy file is a default QoS Level.
-Here's an example of the shortest policy file:
-
- qos-levels
- qos-level
- name: DEFAULT
- sl: 0
- end-qos-level
- end-qos-levels
-
-Port groups section is missing because there are no match rules, which means
-that port groups are not referred anywhere, and there is no need defining
-them. And since this policy file doesn't have any matching rules, PR/MPR query
-won't match any rule, and OpenSM will enforce default QoS level.
-Essentially, the above example is equivalent to not having QoS policy file
-at all.
-
-The following example shows all the possible options and keywords in the
-policy file and their syntax:
-
- #
- # See the comments in the following example.
- # They explain different keywords and their meaning.
- #
- port-groups
-
- port-group # using port GUIDs
- name: Storage
- # "use" is just a description that is used for logging
- # Other than that, it is just a comment
- use: SRP Targets
- port-guid: 0x10000000000001, 0x10000000000005-0x1000000000FFFA
- port-guid: 0x1000000000FFFF
- end-port-group
-
- port-group
- name: Virtual Servers
- # The syntax of the port name is as follows:
- # "node_description/Pnum".
- # node_description is compared to the NodeDescription of the node,
- # and "Pnum" is a port number on that node.
- port-name: vs1 HCA-1/P1, vs2 HCA-1/P1
- end-port-group
-
- # using partitions defined in the partition policy
- port-group
- name: Partitions
- partition: Part1
- pkey: 0x1234
- end-port-group
-
- # using node types: CA, ROUTER, SWITCH, SELF (for node that runs SM)
- # or ALL (for all the nodes in the subnet)
- port-group
- name: CAs and SM
- node-type: CA, SELF
- end-port-group
-
- end-port-groups
-
- qos-setup
- # This section of the policy file describes how to set up SL2VL and VL
- # Arbitration tables on various nodes in the fabric.
- # However, this is not supported in OpenSM currently - the section is
- # parsed and ignored. SL2VL and VLArb tables should be configured in the
- # OpenSM options file (by default - /usr/local/etc/opensm/opensm.conf).
- end-qos-setup
-
- qos-levels
-
- # Having a QoS Level named "DEFAULT" is a must - it is applied to
- # PR/MPR requests that didn't match any of the matching rules.
- qos-level
- name: DEFAULT
- use: default QoS Level
- sl: 0
- end-qos-level
-
- # the whole set: SL, MTU-Limit, Rate-Limit, PKey, Packet Lifetime
- qos-level
- name: WholeSet
- sl: 1
- mtu-limit: 4
- rate-limit: 5
- pkey: 0x1234
- packet-life: 8
- end-qos-level
-
- end-qos-levels
-
- # Match rules are scanned in order of their apperance in the policy file.
- # First matched rule takes precedence.
- qos-match-rules
-
- # matching by single criteria: QoS class
- qos-match-rule
- use: by QoS class
- qos-class: 7-9,11
- # Name of qos-level to apply to the matching PR/MPR
- qos-level-name: WholeSet
- end-qos-match-rule
-
- # show matching by destination group and service id
- qos-match-rule
- use: Storage targets
- destination: Storage
- service-id: 0x10000000000001, 0x10000000000008-0x10000000000FFF
- qos-level-name: WholeSet
- end-qos-match-rule
-
- qos-match-rule
- source: Storage
- use: match by source group only
- qos-level-name: DEFAULT
- end-qos-match-rule
-
- qos-match-rule
- use: match by all parameters
- qos-class: 7-9,11
- source: Virtual Servers
- destination: Storage
- service-id: 0x0000000000010000-0x000000000001FFFF
- pkey: 0x0F00-0x0FFF
- qos-level-name: WholeSet
- end-qos-match-rule
-
- end-qos-match-rules
-
-
-==============================================================================
- 6. Simplified QoS Policy - Details and Examples
-==============================================================================
-
-Simplified QoS policy match rules are tailored for matching ULPs (or some
-application on top of a ULP) PR/MPR requests. This section has a list of
-per-ULP (or per-application) match rules and the SL that should be enforced
-on the matched PR/MPR query.
-
-Match rules include:
- - Default match rule that is applied to PR/MPR query that didn't match any
- of the other match rules
- - SDP
- - SDP application with a specific target TCP/IP port range
- - SRP with a specific target IB port GUID
- - RDS
- - iSER
- - iSER application with a specific target TCP/IP port range
- - IPoIB with a default PKey
- - IPoIB with a specific PKey
- - any ULP/application with a specific Service ID in the PR/MPR query
- - any ULP/application with a specific PKey in the PR/MPR query
- - any ULP/application with a specific target IB port GUID in the PR/MPR query
-
-Since any section of the policy file is optional, as long as basic rules of
-the file are kept (such as no referring to nonexisting port group, having
-default QoS Level, etc), the simplified policy section (qos-ulps) can serve
-as a complete QoS policy file.
-The shortest policy file in this case would be as follows:
-
- qos-ulps
- default : 0 #default SL
- end-qos-ulps
-
-It is equivalent to the previous example of the shortest policy file, and it
-is also equivalent to not having policy file at all.
-
-Below is an example of simplified QoS policy with all the possible keywords:
-
- qos-ulps
- default : 0 # default SL
- sdp, port-num 30000 : 0 # SL for application running on top
- # of SDP when a destination
- # TCP/IPport is 30000
- sdp, port-num 10000-20000 : 0
- sdp : 1 # default SL for any other
- # application running on top of SDP
- rds : 2 # SL for RDS traffic
- iser, port-num 900 : 0 # SL for iSER with a specific target
- # port
- iser : 3 # default SL for iSER
- ipoib, pkey 0x0001 : 0 # SL for IPoIB on partition with
- # pkey 0x0001
- ipoib : 4 # default IPoIB partition,
- # pkey=0x7FFF
- any, service-id 0x6234 : 6 # match any PR/MPR query with a
- # specific Service ID
- any, pkey 0x0ABC : 6 # match any PR/MPR query with a
- # specific PKey
- srp, target-port-guid 0x1234 : 5 # SRP when SRP Target is located on
- # a specified IB port GUID
- any, target-port-guid 0x0ABC-0xFFFFF : 6 # match any PR/MPR query with
- # a specific target port GUID
- end-qos-ulps
-
-
-Similar to the full policy definition, matching of PR/MPR queries is done in
-order of appearance in the QoS policy file such as the first match takes
-precedence, except for the "default" rule, which is applied only if the query
-didn't match any other rule.
-
-All other sections of the QoS policy file take precedence over the qos-ulps
-section. That is, if a policy file has both qos-match-rules and qos-ulps
-sections, then any query is matched first against the rules in the
-qos-match-rules section, and only if there was no match, the query is matched
-against the rules in qos-ulps section.
-
-Note that some of these match rules may overlap, so in order to use the
-simplified QoS definition effectively, it is important to understand how each
-of the ULPs is matched:
-
-6.1 IPoIB
-IPoIB query is matched by PKey. Default PKey for IPoIB partition is 0x7fff, so
-the following three match rules are equivalent:
-
- ipoib : <SL>
- ipoib, pkey 0x7fff : <SL>
- any, pkey 0x7fff : <SL>
-
-6.2 SDP
-SDP PR query is matched by Service ID. The Service-ID for SDP is
-0x000000000001PPPP, where PPPP are 4 hex digits holding the remote TCP/IP Port
-Number to connect to. The following two match rules are equivalent:
-
- sdp : <SL>
- any, service-id 0x0000000000010000-0x000000000001ffff : <SL>
-
-6.3 RDS
-Similar to SDP, RDS PR query is matched by Service ID. The Service ID for RDS
-is 0x000000000106PPPP, where PPPP are 4 hex digits holding the remote TCP/IP
-Port Number to connect to. Default port number for RDS is 0x48CA, which makes
-a default Service-ID 0x00000000010648CA. The following two match rules are
-equivalent:
-
- rds : <SL>
- any, service-id 0x00000000010648CA : <SL>
-
-6.4 iSER
-Similar to RDS, iSER query is matched by Service ID, where the the Service ID
-is also 0x000000000106PPPP. Default port number for iSER is 0x0CBC, which makes
-a default Service-ID 0x0000000001060CBC. The following two match rules are
-equivalent:
-
- iser : <SL>
- any, service-id 0x0000000001060CBC : <SL>
-
-6.5 SRP
-Service ID for SRP varies from storage vendor to vendor, thus SRP query is
-matched by the target IB port GUID. The following two match rules are
-equivalent:
-
- srp, target-port-guid 0x1234 : <SL>
- any, target-port-guid 0x1234 : <SL>
-
-Note that any of the above ULPs might contain target port GUID in the PR
-query, so in order for these queries not to be recognized by the QoS manager
-as SRP, the SRP match rule (or any match rule that refers to the target port
-guid only) should be placed at the end of the qos-ulps match rules.
-
-6.6 MPI
-SL for MPI is manually configured by MPI admin. OpenSM is not forcing any SL
-on the MPI traffic, and that's why it is the only ULP that did not appear in
-the qos-ulps section.
-
-
-==============================================================================
- 7. SL2VL Mapping and VL Arbitration
-==============================================================================
-
-OpenSM cached options file has a set of QoS related configuration parameters,
-that are used to configure SL2VL mapping and VL arbitration on IB ports.
-These parameters are:
- - Max VLs: the maximum number of VLs that will be on the subnet.
- - High limit: the limit of High Priority component of VL Arbitration
- table (IBA 7.6.9).
- - VLArb low table: Low priority VL Arbitration table (IBA 7.6.9) template.
- - VLArb high table: High priority VL Arbitration table (IBA 7.6.9) template.
- - SL2VL: SL2VL Mapping table (IBA 7.6.6) template. It is a list of VLs
- corresponding to SLs 0-15 (Note that VL15 used here means drop this SL).
-
-There are separate QoS configuration parameters sets for various target types:
-CAs, routers, switch external ports, and switch's enhanced port 0. The names
-of such parameters are prefixed by "qos_<type>_" string. Here is a full list
-of the currently supported sets:
-
- qos_ca_ - QoS configuration parameters set for CAs.
- qos_rtr_ - parameters set for routers.
- qos_sw0_ - parameters set for switches' port 0.
- qos_swe_ - parameters set for switches' external ports.
-
-Here's the example of typical default values for CAs and switches' external
-ports (hard-coded in OpenSM initialization):
-
- qos_ca_max_vls 15
- qos_ca_high_limit 0
- qos_ca_vlarb_high 0:4,1:0,2:0,3:0,4:0,5:0,6:0,7:0,8:0,9:0,10:0,11:0,12:0,13:0,14:0
- qos_ca_vlarb_low 0:0,1:4,2:4,3:4,4:4,5:4,6:4,7:4,8:4,9:4,10:4,11:4,12:4,13:4,14:4
- qos_ca_sl2vl 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,7
-
- qos_swe_max_vls 15
- qos_swe_high_limit 0
- qos_swe_vlarb_high 0:4,1:0,2:0,3:0,4:0,5:0,6:0,7:0,8:0,9:0,10:0,11:0,12:0,13:0,14:0
- qos_swe_vlarb_low 0:0,1:4,2:4,3:4,4:4,5:4,6:4,7:4,8:4,9:4,10:4,11:4,12:4,13:4,14:4
- qos_swe_sl2vl 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,7
-
-VL arbitration tables (both high and low) are lists of VL/Weight pairs.
-Each list entry contains a VL number (values from 0-14), and a weighting value
-(values 0-255), indicating the number of 64 byte units (credits) which may be
-transmitted from that VL when its turn in the arbitration occurs. A weight
-of 0 indicates that this entry should be skipped. If a list entry is
-programmed for VL15 or for a VL that is not supported or is not currently
-configured by the port, the port may either skip that entry or send from any
-supported VL for that entry.
-
-Note, that the same VLs may be listed multiple times in the High or Low
-priority arbitration tables, and, further, it can be listed in both tables.
-
-The limit of high-priority VLArb table (qos_<type>_high_limit) indicates the
-number of high-priority packets that can be transmitted without an opportunity
-to send a low-priority packet. Specifically, the number of bytes that can be
-sent is high_limit times 4K bytes.
-
-A high_limit value of 255 indicates that the byte limit is unbounded.
-Note: if the 255 value is used, the low priority VLs may be starved.
-A value of 0 indicates that only a single packet from the high-priority table
-may be sent before an opportunity is given to the low-priority table.
-
-Keep in mind that ports usually transmit packets of size equal to MTU.
-For instance, for 4KB MTU a single packet will require 64 credits, so in order
-to achieve effective VL arbitration for packets of 4KB MTU, the weighting
-values for each VL should be multiples of 64.
-
-Below is an example of SL2VL and VL Arbitration configuration on subnet:
-
- qos_ca_max_vls 15
- qos_ca_high_limit 6
- qos_ca_vlarb_high 0:4
- qos_ca_vlarb_low 0:0,1:64,2:128,3:192,4:0,5:64,6:64,7:64
- qos_ca_sl2vl 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,7
-
- qos_swe_max_vls 15
- qos_swe_high_limit 6
- qos_swe_vlarb_high 0:4
- qos_swe_vlarb_low 0:0,1:64,2:128,3:192,4:0,5:64,6:64,7:64
- qos_swe_sl2vl 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,7
-
-In this example, there are 8 VLs configured on subnet: VL0 to VL7. VL0 is
-defined as a high priority VL, and it is limited to 6 x 4KB = 24KB in a single
-transmission burst. Such configuration would suilt VL that needs low latency
-and uses small MTU when transmitting packets. Rest of VLs are defined as low
-priority VLs with different weights, while VL4 is effectively turned off.
diff --git a/contrib/ofed/management/opensm/doc/current-routing.txt b/contrib/ofed/management/opensm/doc/current-routing.txt
deleted file mode 100644
index af008bc..0000000
--- a/contrib/ofed/management/opensm/doc/current-routing.txt
+++ /dev/null
@@ -1,346 +0,0 @@
-Current OpenSM Routing
-7/9/07
-
-OpenSM offers five routing engines:
-
-1. Min Hop Algorithm - based on the minimum hops to each node where the
-path length is optimized.
-
-2. UPDN Unicast routing algorithm - also based on the minimum hops to each
-node, but it is constrained to ranking rules. This algorithm should be chosen
-if the subnet is not a pure Fat Tree, and deadlock may occur due to a
-loop in the subnet.
-
-3. Fat-tree Unicast routing algorithm - this algorithm optimizes routing
-of fat-trees for congestion-free "shift" communication pattern.
-It should be chosen if a subnet is a symmetrical fat-tree.
-Similar to UPDN routing, Fat-tree routing is credit-loop-free.
-
-4. LASH unicast routing algorithm - uses Infiniband virtual layers
-(SL) to provide deadlock-free shortest-path routing while also
-distributing the paths between layers. LASH is an alternative
-deadlock-free topology-agnostic routing algorithm to the non-minimal
-UPDN algorithm avoiding the use of a potentially congested root node.
-
-5. DOR Unicast routing algorithm - based on the Min Hop algorithm, but
-avoids port equalization except for redundant links between the same
-two switches. This provides deadlock free routes for hypercubes when
-the fabric is cabled as a hypercube and for meshes when cabled as a
-mesh (see details below).
-
-OpenSM provides an optional unicast routing cache (enabled by -A or
---ucast_cache options). When enabled, unicast routing cache prevents
-routing recalculation (which is a heavy task in a large cluster) when
-there was no topology change detected during the heavy sweep, or when
-the topology change does not require new routing calculation, e.g. when
-one or more CAs/RTRs/leaf switches going down, or one or more of these
-nodes coming back after being down.
-A very common case that is handled by the unicast routing cache is host
-reboot, which otherwise would cause two full routing recalculations: one
-when the host goes down, and the other when the host comes back online.
-
-OpenSM also supports a file method which can load routes from a table. See
-modular-routing.txt for more information on this.
-
-The basic routing algorithm is comprised of two stages:
-1. MinHop matrix calculation
- How many hops are required to get from each port to each LID ?
- The algorithm to fill these tables is different if you run standard
-(min hop) or Up/Down.
- For standard routing, a "relaxation" algorithm is used to propagate
-min hop from every destination LID through neighbor switches
- For Up/Down routing, a BFS from every target is used. The BFS tracks link
-direction (up or down) and avoid steps that will perform up after a down
-step was used.
-
-2. Once MinHop matrices exist, each switch is visited and for each target LID,
-a decision is made as to what port should be used to get to that LID.
- This step is common to standard and Up/Down routing. Each port has a
-counter counting the number of target LIDs going through it.
- When there are multiple alternative ports with same MinHop to a LID,
-the one with less previously assigned ports is selected.
- If LMC > 0, more checks are added: Within each group of LIDs assigned to
-same target port,
- a. use only ports which have same MinHop
- b. first prefer the ones that go to different systemImageGuid (then
-the previous LID of the same LMC group)
- c. if none - prefer those which go through another NodeGuid
- d. fall back to the number of paths method (if all go to same node).
-
-
-Effect of Topology Changes
-
-OpenSM will preserve existing routing in any case where there is no change in
-the fabric switches unless the -r (--reassign_lids) option is specified.
-
--r
---reassign_lids
- This option causes OpenSM to reassign LIDs to all
- end nodes. Specifying -r on a running subnet
- may disrupt subnet traffic.
- Without -r, OpenSM attempts to preserve existing
- LID assignments resolving multiple use of same LID.
-
-If a link is added or removed, OpenSM does not recalculate
-the routes that do not have to change. A route has to change
-if the port is no longer UP or no longer the MinHop. When routing changes
-are performed, the same algorithm for balancing the routes is invoked.
-
-In the case of using the file based routing, any topology changes are
-currently ignored The 'file' routing engine just loads the LFTs from the file
-specified, with no reaction to real topology. Obviously, this will not be able
-to recheck LIDs (by GUID) for disconnected nodes, and LFTs for non-existent
-switches will be skipped. Multicast is not affected by 'file' routing engine
-(this uses min hop tables).
-
-
-Min Hop Algorithm
------------------
-
-The Min Hop algorithm is invoked by default if no routing algorithm is
-specified. It can also be invoked by specifying '-R minhop'.
-
-The Min Hop algorithm is divided into two stages: computation of
-min-hop tables on every switch and LFT output port assignment. Link
-subscription is also equalized with the ability to override based on
-port GUID. The latter is supplied by:
-
--i <equalize-ignore-guids-file>
--ignore-guids <equalize-ignore-guids-file>
- This option provides the means to define a set of ports
- (by guids) that will be ignored by the link load
- equalization algorithm.
-
-LMC awareness routes based on (remote) system or switch basis.
-
-
-UPDN Routing Algorithm
-----------------------
-
-Purpose of UPDN Algorithm
-
-The UPDN algorithm is designed to prevent deadlocks from occurring in loops
-of the subnet. A loop-deadlock is a situation in which it is no longer
-possible to send data between any two hosts connected through the loop. As
-such, the UPDN routing algorithm should be used if the subnet is not a pure
-Fat Tree, and one of its loops may experience a deadlock (due, for example,
-to high pressure).
-
-The UPDN algorithm is based on the following main stages:
-
-1. Auto-detect root nodes - based on the CA hop length from any switch in
-the subnet, a statistical histogram is built for each switch (hop num vs
-number of occurrences). If the histogram reflects a specific column (higher
-than others) for a certain node, then it is marked as a root node. Since
-the algorithm is statistical, it may not find any root nodes. The list of
-the root nodes found by this auto-detect stage is used by the ranking
-process stage.
-
- Note 1: The user can override the node list manually.
- Note 2: If this stage cannot find any root nodes, and the user did not
- specify a guid list file, OpenSM defaults back to the Min Hop
- routing algorithm.
-
-2. Ranking process - All root switch nodes (found in stage 1) are assigned
-a rank of 0. Using the BFS algorithm, the rest of the switch nodes in the
-subnet are ranked incrementally. This ranking aids in the process of enforcing
-rules that ensure loop-free paths.
-
-3. Min Hop Table setting - after ranking is done, a BFS algorithm is run from
-each (CA or switch) node in the subnet. During the BFS process, the FDB table
-of each switch node traversed by BFS is updated, in reference to the starting
-node, based on the ranking rules and guid values.
-
-At the end of the process, the updated FDB tables ensure loop-free paths
-through the subnet.
-
-Note: Up/Down routing does not allow LID routing communication between
-switches that are located inside spine "switch systems".
-The reason is that there is no way to allow a LID route between them
-that does not break the Up/Down rule.
-One ramification of this is that you cannot run SM on switches other
-than the leaf switches of the fabric.
-
-
-UPDN Algorithm Usage
-
-Activation through OpenSM
-
-Use '-R updn' option (instead of old '-u') to activate the UPDN algorithm.
-Use `-a <guid_list_file>' for adding an UPDN guid file that contains the
-root nodes for ranking.
-If the `-a' option is not used, OpenSM uses its auto-detect root nodes
-algorithm.
-
-Notes on the guid list file:
-1. A valid guid file specifies one guid in each line. Lines with an invalid
-format will be discarded.
-2. The user should specify the root switch guids. However, it is also
-possible to specify CA guids; OpenSM will use the guid of the switch (if
-it exists) that connects the CA to the subnet as a root node.
-
-
-To learn more about deadlock-free routing, see the article
-"Deadlock Free Message Routing in Multiprocessor Interconnection Networks"
-by William J Dally and Charles L Seitz (1985).
-
-
-Fat-tree Routing Algorithm
---------------------------
-
-Purpose:
-
-The fat-tree algorithm optimizes routing for "shift" communication pattern.
-It should be chosen if a subnet is a symmetrical or almost symmetrical
-fat-tree of various types.
-It supports not just K-ary-N-Trees, by handling for non-constant K,
-cases where not all leafs (CAs) are present, any Constant
-Bisectional Ratio (CBB) ratio. As in UPDN, fat-tree also prevents
-credit-loop-deadlocks.
-
-If the root guid file is not provided ('-a' or '--root_guid_file' options),
-the topology has to be pure fat-tree that complies with the following rules:
- - Tree rank should be between two and eight (inclusively)
- - Switches of the same rank should have the same number
- of UP-going port groups*, unless they are root switches,
- in which case the shouldn't have UP-going ports at all.
- - Switches of the same rank should have the same number
- of DOWN-going port groups, unless they are leaf switches.
- - Switches of the same rank should have the same number
- of ports in each UP-going port group.
- - Switches of the same rank should have the same number
- of ports in each DOWN-going port group.
- - All the CAs have to be at the same tree level (rank).
-
-If the root guid file is provided, the topology doesn't have to be pure
-fat-tree, and it should only comply with the following rules:
- - Tree rank should be between two and eight (inclusively)
- - All the Compute Nodes** have to be at the same tree level (rank).
- Note that non-compute node CAs are allowed here to be at different
- tree ranks.
-
-* ports that are connected to the same remote switch are referenced as
-'port group'.
-** list of compute nodes (CNs) can be specified by '-u' or '--cn_guid_file'
-OpenSM options.
-
-Note that although fat-tree algorithm supports trees with non-integer CBB
-ratio, the routing will not be as balanced as in case of integer CBB ratio.
-In addition to this, although the algorithm allows leaf switches to have any
-number of CAs, the closer the tree is to be fully populated, the more effective
-the "shift" communication pattern will be.
-In general, even if the root list is provided, the closer the topology to a
-pure and symmetrical fat-tree, the more optimal the routing will be.
-
-The algorithm also dumps compute node ordering file (opensm-ftree-ca-order.dump)
-in the same directory where the OpenSM log resides. This ordering file provides
-the CN order that may be used to create efficient communication pattern, that
-will match the routing tables.
-
-
-Usage:
-
-Activation through OpenSM
-
-Use '-R ftree' option to activate the fat-tree algorithm.
-
-Note: LMC > 0 is not supported by fat-tree routing. If this is
-specified, the default routing algorithm is invoked instead.
-
-
-LASH Routing Algorithm
-----------------------
-
-LASH is an acronym for LAyered SHortest Path Routing. It is a
-deterministic shortest path routing algorithm that enables topology
-agnostic deadlock-free routing within communication networks.
-
-When computing the routing function, LASH analyzes the network
-topology for the shortest-path routes between all pairs of sources /
-destinations and groups these paths into virtual layers in such a way
-as to avoid deadlock.
-
-Note LASH analyzes routes and ensures deadlock freedom between switch
-pairs. The link from HCA between and switch does not need virtual
-layers as deadlock will not arise between switch and HCA.
-
-In more detail, the algorithm works as follows:
-
-1) LASH determines the shortest-path between all pairs of source /
-destination switches. Note, LASH ensures the same SL is used for all
-SRC/DST - DST/SRC pairs and there is no guarantee that the return
-path for a given DST/SRC will be the reverse of the route SRC/DST.
-
-2) LASH then begins an SL assignment process where a route is assigned
-to a layer (SL) if the addition of that route does not cause deadlock
-within that layer. This is achieved by maintaining and analysing a
-channel dependency graph for each layer. Once the potential addition
-of a path could lead to deadlock, LASH opens a new layer and continues
-the process.
-
-3) Once this stage has been completed, it is highly likely that the
-first layers processed will contain more paths than the latter ones.
-To better balance the use of layers, LASH moves paths from one layer
-to another so that the number of paths in each layer averages out.
-
-Note, the implementation of LASH in opensm attempts to use as few layers
-as possible. This number can be less than the number of actual layers
-available.
-
-In general LASH is a very flexible algorithm. It can, for example,
-reduce to Dimension Order Routing in certain topologies, it is topology
-agnostic and fares well in the face of faults.
-
-It has been shown that for both regular and irregular topologies, LASH
-outperforms Up/Down. The reason for this is that LASH distributes the
-traffic more evenly through a network, avoiding the bottleneck issues
-related to a root node and always routes shortest-path.
-
-The algorithm was developed by Simula Research Laboratory.
-
-To learn more about LASH and the flexibility behind it, the requirement
-for layers, performance comparisons to other algorithms, see the
-following articles:
-
-"Layered Routing in Irregular Networks", Lysne et al, IEEE
-Transactions on Parallel and Distributed Systems, VOL.16, No12,
-December 2005.
-
-"Routing for the ASI Fabric Manager", Solheim et al. IEEE
-Communications Magazine, Vol.44, No.7, July 2006.
-
-"Layered Shortest Path (LASH) Routing in Irregular System Area
-Networks", Skeie et al. IEEE Computer Society Communication
-Architecture for Clusters 2002.
-
-
-Use '-R lash -Q ' option to activate the LASH algorithm.
-
-Note: QoS support has to be turned on in order that SL/VL mappings are
-used.
-
-Note: LMC > 0 is not supported by the LASH routing. If this is
-specified, the default routing algorithm is invoked instead.
-
-
-DOR Routing Algorithm
----------------------
-
-The Dimension Order Routing algorithm is based on the Min Hop
-algorithm and so uses shortest paths. Instead of spreading traffic
-out across different paths with the same shortest distance, it chooses
-among the available shortest paths based on an ordering of dimensions.
-Each port must be consistently cabled to represent a hypercube
-dimension or a mesh dimension. Paths are grown from a destination
-back to a source using the lowest dimension (port) of available paths
-at each step. This provides the ordering necessary to avoid deadlock.
-When there are multiple links between any two switches, they still
-represent only one dimension and traffic is balanced across them
-unless port equalization is turned off. In the case of hypercubes,
-the same port must be used throughout the fabric to represent the
-hypercube dimension and match on both ends of the cable. In the case
-of meshes, the dimension should consistently use the same pair of
-ports, one port on one end of the cable, and the other port on the
-other end, continuing along the mesh dimension.
-
-Use '-R dor' option to activate the DOR algorithm.
diff --git a/contrib/ofed/management/opensm/doc/modular-routing.txt b/contrib/ofed/management/opensm/doc/modular-routing.txt
deleted file mode 100644
index 3f2174b..0000000
--- a/contrib/ofed/management/opensm/doc/modular-routing.txt
+++ /dev/null
@@ -1,77 +0,0 @@
-Modular Routine Engine
-
-Modular routing engine structure has been added to allow
-for ease of "plugging" new routing modules.
-
-Currently, only unicast callbacks are supported. Multicast
-can be added later.
-
-One of existing routing modules is up-down "updn", which may
-be activated with '-R updn' option (instead of old '-u').
-
-General usage is:
-$ opensm -R 'module-name'
-
-There is also a trivial routing module which is able
-to load LFT tables from a file.
-
-Main features:
-
-- this will load switch LFTs and/or LID matrices (min hops tables)
-- this will load switch LFTs according to the path entries introduced in
- the file
-- no additional checks will be performed (such as "is port connected", etc.)
-- in case when fabric LIDs were changed this will try to reconstruct LFTs
- correctly if endport GUIDs are represented in the file (in order
- to disable this GUIDs may be removed from the file or zeroed)
-
-The file format is compatible with output of 'ibroute' util and for
-whole fabric may be generated with script like this:
-
- for sw_lid in `ibswitches | awk '{print $NF}'` ; do
- ibroute $sw_lid
- done > /path/to/lfts_file
-
-, or using DR paths:
-
- for sw_dr in `ibnetdiscover -v \
- | sed -ne '/^DR path .* switch /s/^DR path \[\(.*\)\].*$/\1/p' \
- | sed -e 's/\]\[/,/g' \
- | sort -u` ; do
- ibroute -D ${sw_dr}
- done > /path/to/lfts_file
-
-This script is dump_lfts.sh
-
-In order to activate new module use:
-
- opensm -R file -U /path/to/lfts_file
-
-If the lfts_file is not found or is in error, the default routing
-algorithm is utilized.
-
-The ability to dump switch lid matrices (aka min hops tables) to file and
-later to load these is also supported.
-
-The usage is similar to unicast forwarding tables loading from a lfts
-file (introduced by 'file' routing engine), but new lid matrix file
-name should be specified by -M or --lid_matrix_file option. For example:
-
- opensm -R file -M ./opensm-lid-matrix.dump
-
-The dump file is named 'opensm-lid-matrix.dump' and will be generated in
-standard opensm dump directory (/var/log by default) when
-OSM_LOG_ROUTING logging flag is set.
-
-When routing engine 'file' is activated, but the lfts file is not specified
-or cannot be opened, the default lid matrix algorithm will be used.
-
-There is also a switch forwarding tables dumper which generates
-a file compatible with dump_lfts.sh output. This file can be used
-as input for forwarding tables loading by 'file' routing engine.
-Both or one of options -U and -M can be specified together with '-R file'.
-
-NOTE: ibroute has been updated (for switch management ports) to support this.
-Also, lmc was added to switch management ports. ibroute needs to be r7855 or
-later from the trunk.
-
diff --git a/contrib/ofed/management/opensm/doc/opensm-coding-style.txt b/contrib/ofed/management/opensm/doc/opensm-coding-style.txt
deleted file mode 100644
index 379042c..0000000
--- a/contrib/ofed/management/opensm/doc/opensm-coding-style.txt
+++ /dev/null
@@ -1,34 +0,0 @@
-This short (hopefully) memo is about to define the coding style
-recommended for OpenSM development.
-
-The goal of this is to make OpenSM code base to be standard in terms of
-the rest of OpenIB management software, OpenIB projects and Linux in
-general. And in this way to make OpenSM more developer friendly and to
-involve more open source programmers to be part of OpenSM development
-process.
-
-The goal of this is not to provide long and boring list of coding style
-paradigms, but rather to define general coding style concept and to
-suggest a way for such a concept to be implemented in the existing
-OpenSM code base.
-
-The OpenSM project is an OpenIB and Linux centric project, so we think
-it is reasonable to use the coding style most popular with OpenIB
-projects (linux/Documentation/CodingStyle) as the starting point rather
-than reinventing one more coding style rule-set.
-
-Some things from there in short: tab character for indentation and space
-character for alignment, K&R style braces, short local and meanful
-global names, please no confused Hungary style, short functions. And of
-course to be reasonable about all above.
-
-
-Some ideas about existing OpenSM code improvements in terms of the
-Coding style:
-
-* When writing new code, please try to follow the new Coding style.
-* Coding style improvement patches are desired and accepted, but please
- try to not mix coding style improvement with functional and other
- changes in one patch.
-* When you are going to improve coding style for existing code, please
- try to do it for entire file(s).
diff --git a/contrib/ofed/management/opensm/doc/opensm_release_notes-3.1.10.txt b/contrib/ofed/management/opensm/doc/opensm_release_notes-3.1.10.txt
deleted file mode 100644
index 2b6253d..0000000
--- a/contrib/ofed/management/opensm/doc/opensm_release_notes-3.1.10.txt
+++ /dev/null
@@ -1,492 +0,0 @@
- OpenSM Release Notes 3.1.10
- =============================
-
-Version: OpenFabrics Enterprise Distribution (OFED) 1.3
-Repo: git://git.openfabrics.org/~ofed_1_3/management.git (release)
- git://git.openfabrics.org/~sashak/management.git (development)
-Date: February 2008
-
-1 Overview
-----------
-This document describes the contents of the OpenSM OFED 1.3 release.
-OpenSM is an InfiniBand compliant Subnet Manager and Administration,
-and runs on top of OpenIB. The OpenSM version for this release
-is openib-3.1.10
-
-This document includes the following sections:
-1 This Overview section (describing new features and software
- dependencies)
-2 Known Issues And Limitations
-3 Unsupported IB compliance statements
-4 Major Bug Fixes
-5 Main Verification Flows
-6 Qualified software stacks and devices
-
-1.1 Major New Features
-
-* QoS manager (experimental)
- This QoS manager implementation is in accordance with IBA QoS Annex.
- Highly configurable QoS Policy is parsed from OpenSM QoS policy file.
- Valid QoS parameters will be reported in SA PathRecord and
- MultiPathRecord. In addition simple QoS levels per ULPs configuration
- is supported too.
-
-* Performance Manager
- When enabled it collects a fabric port counters and able to log it or
- to pass to external program via event plugin interface. It handles
- counters overflow, supports LID/QP redirection and is able to work
- when OpenSM is in master, standby, and inactive states.
-
-* Dimension Order routing (DOR) algorithm
- DOR Unicast routing algorithm - based on the Min Hop algorithm, but
- avoids port equalization except for redundant links between the
- same two switches. This provides deadlock free routes for hypercubes
- when the fabric is cabled as a hypercube and for meshes when cabled
- as a mesh (see details in OpenSM man page).
-
-* Routing improvements
- Speedup the current routing algorithms default MinHops, Up/Down and
- LASH and lid matrix generation. Fat Tree routing engine is able to work
- with not pure fat free topology.
-
-* Multiple IB routers support
- OpenSM now able to keep configurable subnet prefix to router table.
- SA will report path to this routers when SA PathRecord was issued with
- non-local DGID.
-
-* Node map
- This is possible to name nodes in this config file. Those names will be
- used for logging and by QoS configuration.
-
-* PKey index support
- Proper support for PKey index in GSI queries.
-
-* Incremental LFTs, PKey, SL2VL, and VLarbitration table updates
- OpenSM will only fetch those tables in first heavy sweep and then
- will maintain this internally.
-
-* Fast port and switch detector
- When port and/or switch was externally reset and it was fast so sweep
- doesn't find this device as disconnected OpenSM will detect this by
- changed port states and handle accordingly.
-
-* Duplicated GUIDs/port moving detector
- OpenSM will be able to detect port moving during a fabric discovery
- and will not report duplicated GUIDs in this case.
-
-* Multicast rerouting speedup
- Now OpenSM will calculate and setup multicast forwarding tables for
- all altered multicast groups and not for each one.
-
-* Event plugin API
- OpenSM allows to load dynamically various plugin modules.
-
-* Many generic improvements
-
-1.2 Minor New Features:
-
-* Daemon mode can be activated with -B option.
-
-* Support multiple scopes for IPoIB multicast groups in partition config.
-
-* Loopback connection handling
- Loopback connection is not interpreted as duplicated GUID anymore.
-
-* Connect root nodes option for Up/Down routing engine.
- When this option is specified Up/Down will create routing paths between
- its root nodes.
-
-* Dump and log filenames changed from osm* to opensm*.
-
-* Support loopback console
- Socket console with only local access.
-
-* Configurable config directory (the default value is /etc/opensm) and
- configurable default values of OpenSM config filenames.
-
-* Add option for force SDR link speed
- Add option to opensm.opts to force link speed. Currently, only forcing
- to SDR link speed is supported. This option is not supported as a
- command line option.
-
-* Better packaging
- Building and RPM packaging were improved and simplified.
-
-* Handle "babbling" ports
- When a babbling port (port which causes a frequent trap generation) is
- detected, OpenSM will disable the port which should terminate the trap
- storm.
-
-1.3 Library API Changes
-
- None
-
-1.4 Software Dependencies
-
-OpenSM depends on the installation of either OFED 1.3, OFED 1.2, OFED 1.1,
-OFED 1.0, OpenIB gen2 (e.g. IBG2 distribution), OpenIB gen1 (e.g. IBGD
-distribution), or Mellanox VAPI stacks. The qualified driver versions
-are provided in Table 2, "Qualified IB Stacks".
-
-Also building of QoS manager policy file parser requires flex, and either
-bison or byacc installed.
-
-1.5 Supported Devices Firmware
-
-The main task of OpenSM is to initialize InfiniBand devices. The
-qualified devices and their corresponding firmware versions
-are listed in Table 3.
-
-2 Known Issues And Limitations
-------------------------------
-
-* No Service / Key associations:
- There is no way to manage Service access by Keys.
-
-* No SM to SM SMDB synchronization:
- Puts the burden of re-registering services, multicast groups, and
- inform-info on the client application (or IB access layer core).
-
-3 Unsupported IB Compliance Statements
---------------------------------------
-The following section lists all the IB compliance statements which
-OpenSM does not support. Please refer to the IB specification for detailed
-information regarding each compliance statement.
-
-* C14-22 (Authentication):
- M_Key M_KeyProtectBits and M_KeyLeasePeriod shall be set in one
- SubnSet method. As a work-around, an OpenSM option is provided for
- defining the protect bits.
-
-* C14-67 (Authentication):
- On SubnGet(SMInfo) and SubnSet(SMInfo) - if M_Key is not zero then
- the SM shall generate a SubnGetResp if the M_Key matches, or
- silently drop the packet if M_Key does not match.
-
-* C15-0.1.23.4 (Authentication):
- InformInfoRecords shall always be provided with the QPN set to 0,
- except for the case of a trusted request, in which case the actual
- subscriber QPN shall be returned.
-
-* o13-17.1.2 (Event-FWD):
- If no permission to forward, the subscription should be removed and
- no further forwarding should occur.
-
-* C14-24.1.1.5 and C14-62.1.1.22 (Initialization):
- GUIDInfo - SM should enable assigning Port GUIDInfo.
-
-* C14-44 (Initialization):
- If the SM discovers that it is missing an M_Key to update CA/RT/SW,
- it should notify the higher level.
-
-* C14-62.1.1.12 (Initialization):
- PortInfo:M_Key - Set the M_Key to a node based random value.
-
-* C14-62.1.1.13 (Initialization):
- PortInfo:P_KeyProtectBits - set according to an optional policy.
-
-* C14-62.1.1.24 (Initialization):
- SwitchInfo:DefaultPort - should be configured for random FDB.
-
-* C14-62.1.1.32 (Initialization):
- RandomForwardingTable should be configured.
-
-* o15-0.1.12 (Multicast):
- If the JoinState is SendOnlyNonMember = 1 (only), then the endport
- should join as sender only.
-
-* o15-0.1.8 (Multicast):
- If a request for creating an MCG with fields that cannot be met,
- return ERR_REQ_INVALID (currently ignores SL and FlowLabelTClass).
-
-* C15-0.1.8.6 (SA-Query):
- Respond to SubnAdmGetTraceTable - this is an optional attribute.
-
-* C15-0.1.13 Services:
- Reject ServiceRecord create, modify or delete if the given
- ServiceP_Key does not match the one included in the ServiceGID port
- and the port that sent the request.
-
-* C15-0.1.14 (Services):
- Provide means to associate service name and ServiceKeys.
-
-4 Major Bug Fixes
------------------
-
-The following is a list of bugs that were fixed. Note that other less critical
-or visible bugs were also fixed.
-
-* osm_ucast_ftree.c: do load-leveling of non-CN routes
-
-* osm_ucast_ftree.c: ignore port 0 and loopbacks on switches
-
-* lash: fix possible segfault in osm_get_lash_sl()
-
-* osm_ucast_ftree.c: fixing coredump in fat-tree routing
-
-* osm_sa_slvl_record: fix overflow crash
-
-* Break multicast rerouting requests processing when heavy sweep is
- scheduled.
-
-* updn: report fallback properly
-
-* Fix incorrect identification of routing engine used
-
-* Don't zero base LID when invalid value is received
-
-* lash: fix wrong allocation size
-
-* Fixing broken logic in 'process world' part of LinkRecord processing
-
-* Fix lmc_mask bit order in osm_sa_link_record.c
-
-* Adding missing comparison by to_lid/from_lid in LinkRecord processing
-
-* Broken logic when scanning subnet for PIR request
-
-* No interactive games in daemon mode
-
-* Fixing memory leak in node description
-
-* Fix PortInfo update issues for switch port 0
-
-* Changed method_mask type in user_mad interface in accordance with
- kernel ABI
-
-* Use umad_get_issm_path() in osm_vendor_set_sm()
-
-* Report message fix
-
-* Uninitialized variables usage fix
-
-* osm_ucast_ftree.c: Possible NULL ptr seg fault
-
-* osm_mcast_mgr.c: Possible NULL ptr seg fault
-
-* TrapRepress was failing for mkey != 0
-
-* IB_PR_COMPMASK was used in MPR
-
-* Set hop limit when creating ipoib multicast groups
-
-* Fix outstanding mad counters tracking on the error paths.
-
-* Report new ports before handover mastership
-
-* Fix opvls and neighbormtu when remote port invalid.
-
-* Bug in coding trying to set vl_arb_high_limit when PortInfo.base_lid
- was still zero.
-
-* Protect SMInfo response against port moving issue.
-
-5 Main Verification Flows
--------------------------
-
-OpenSM verification is run using the following activities:
-* osmtest - a stand-alone program
-* ibmgtsim (IB management simulator) based - a set of flows that
- simulate clusters, inject errors and verify OpenSM capability to
- respond and bring up the network correctly.
-* small cluster regression testing - where the SM is used on back to
- back or single switch configurations. The regression includes
- multiple OpenSM dedicated tests.
-* cluster testing - when we run OpenSM to setup a large cluster, perform
- hand-off, reboots and reconnects, verify routing correctness and SA
- responsiveness at the ULP level (IPoIB and SDP).
-
-5.1 osmtest
-
-osmtest is an automated verification tool used for OpenSM
-testing. Its verification flows are described by list below.
-
-* Inventory File: Obtain and verify all port info, node info, link and path
- records parameters.
-
-* Service Record:
- - Register new service
- - Register another service (with a lease period)
- - Register another service (with service p_key set to zero)
- - Get all services by name
- - Delete the first service
- - Delete the third service
- - Added bad flows of get/delete non valid service
- - Add / Get same service with different data
- - Add / Get / Delete by different component mask values (services
- by Name & Key / Name & Data / Name & Id / Id only )
-
-* Multicast Member Record:
- - Query of existing Groups (IPoIB)
- - BAD Join with insufficient comp mask (o15.0.1.3)
- - Create given MGID=0 (o15.0.1.4)
- - Create given MGID=0xFF12A01C,FE800000,00000000,12345678 (o15.0.1.4)
- - Create BAD MGID=0xFA. (o15.0.1.6)
- - Create BAD MGID=0xFF12A01B w/ link-local not set (o15.0.1.6)
- - New MGID with invalid join state (o15.0.1.9)
- - Retry of existing MGID - See JoinState update (o15.0.1.11)
- - BAD RATE when connecting to existing MGID (o15.0.1.13)
- - Partial JoinState delete request - removing FullMember (o15.0.1.14)
- - Full Delete of a group (o15.0.1.14)
- - Verify Delete by trying to Join deleted group (o15.0.1.14)
- - BAD Delete of IPoIB membership (no prev join) (o15.0.1.15)
-
-* GUIDInfo Record:
- - All GUIDInfoRecords in subnet are obtained
-
-* MultiPathRecord:
- - Perform some compliant and noncompliant MultiPathRecord requests
- - Validation is via status in responses and IB analyzer
-
-* PKeyTableRecord:
- - Perform some compliant and noncompliant PKeyTableRecord queries
- - Validation is via status in responses and IB analyzer
-
-* LinearForwardingTableRecord:
- - Perform some compliant and noncompliant LinearForwardingTableRecord queries
- - Validation is via status in responses and IB analyzer
-
-* Event Forwarding: Register for trap forwarding using reports
- - Send a trap and wait for report
- - Unregister non-existing
-
-* Trap 64/65 Flow: Register to Trap 64-65, create traps (by
- disconnecting/connecting ports) and wait for report, then unregister.
-
-* Stress Test: send PortInfoRecord queries, both single and RMPP and
- check for the rate of responses as well as their validity.
-
-
-5.2 IB Management Simulator OpenSM Test Flows:
-
-The simulator provides ability to simulate the SM handling of virtual
-topologies that are not limited to actual lab equipment availability.
-OpenSM was simulated to bring up clusters of up to 10,000 nodes. Daily
-regressions use smaller (16 and 128 nodes clusters).
-
-The following test flows are run on the IB management simulator:
-
-* Stability:
- Up to 12 links from the fabric are randomly selected to drop packets
- at drop rates up to 90%. The SM is required to succeed in bringing the
- fabric up. The resulting routing is verified to be correct as well.
-
-* LID Manager:
- Using LMC = 2 the fabric is initialized with LIDs. Faults such as
- zero LID, Duplicated LID, non-aligned (to LMC) LIDs are
- randomly assigned to various nodes and other errors are randomly
- output to the guid2lid cache file. The SM sweep is run 5 times and
- after each iteration a complete verification is made to ensure that all
- LIDs that could possibly be maintained are kept, as well as that all nodes
- were assigned a legal LID range.
-
-* Multicast Routing:
- Nodes randomly join the 0xc000 group and eventually the
- resulting routing is verified for completeness and adherence to
- Up/Down routing rules.
-
-* osmtest:
- The complete osmtest flow as described in the previous table is run on
- the simulated fabrics.
-
-* Stress Test:
- This flow merges fabric, LID and stability issues with continuous
- PathRecord, ServiceRecord and Multicast Join/Leave activity to
- stress the SM/SA during continuous sweeps. InformInfo Set/Delete/Get
- were added to the test such both existing and non existing nodes
- perform them in random order.
-
-5.3 OpenSM Regression
-
-Using a back-to-back or single switch connection, the following set of
-tests is run nightly on the stacks described in table 2. The included
-tests are:
-
-* Stress Testing: Flood the SA with queries from multiple channel
- adapters to check the robustness of the entire stack up to the SA.
-
-* Dynamic Changes: Dynamic Topology changes, through randomly
- dropping SMP packets, used to test OpenSM adaptation to an unstable
- network & verify DB correctness.
-
-* Trap Injection: This flow injects traps to the SM and verifies that it
- handles them gracefully.
-
-* SA Query Test: This test exhaustively checks the SA responses to all
- possible single component mask. To do that the test examines the
- entire set of records the SA can provide, classifies them by their
- field values and then selects every field (using component mask and a
- value) and verifies that the response matches the expected set of records.
- A random selection using multiple component mask bits is also performed.
-
-5.4 Cluster testing:
-
-Cluster testing is usually run before a distribution release. It
-involves real hardware setups of 16 to 32 nodes (or more if a beta site
-is available). Each test is validated by running all-to-all ping through the IB
-interface. The test procedure includes:
-
-* Cluster bringup
-
-* Hand-off between 2 or 3 SM's while performing:
- - Node reboots
- - Switch power cycles (disconnecting the SM's)
-
-* Unresponsive port detection and recovery
-
-* osmtest from multiple nodes
-
-* Trap injection and recovery
-
-
-6 Qualification
-----------------
-
-Table 2 - Qualified IB Stacks
-=============================
-
-Stack | Version
------------------------------------------|--------------------------
-OFED | 1.3
-OFED | 1.2
-OFED | 1.1
-OFED | 1.0
-OpenIB Gen2 (IBG2 distribution) | 1.0
-OpenIB Gen1 (IBGD distribution) | 1.8.0
-VAPI (Mellanox InfiniBand HCA Driver) | 3.2 and later
-
-Table 3 - Qualified Devices and Corresponding Firmware
-======================================================
-
-Mellanox
-Device | FW versions
-------------------------------------|-------------------------------
-InfiniScale | fw-43132 5.2.000 (and later)
-InfiniScale III | fw-47396 0.5.000 (and later)
-InfiniHost | fw-23108 3.5.000 (and later)
-InfiniHost III Lx | fw-25204 1.2.000 (and later)
-InfiniHost III Ex (InfiniHost Mode) | fw-25208 4.8.200 (and later)
-InfiniHost III Ex (MemFree Mode) | fw-25218 5.3.000 (and later)
-ConnectX IB | fw-25408 2.3.000 (and later)
-
-QLogic/PathScale
-Device | Note
---------|-----------------------------------------------------------
-iPath | QHT6040 (PathScale InfiniPath HT-460)
-iPath | QHT6140 (PathScale InfiniPath HT-465)
-iPath | QLE6140 (PathScale InfiniPath PE-880)
-iPath | QLE7240
-iPath | QLE7280
-
-Note 1: OpenSM does not run on an IBM Galaxy (eHCA) as it does not expose
-QP0 and QP1. However, it does support it as a device on the subnet.
-
-Note 2: QoS firmware and Mellanox devices
-
-HCAs: QoS supported by ConnectX. The current FW release
-doesn't support QoS. QoS-enabled FW release (2_5_000) is
-planned for May. If someone wishes to get QoS-enabled FW
-before the official release, they should contact Mellanox FAE.
-
-Switches: QoS supported by InfiniScale III
-Any InfiniScale III FW that is supported by OpenSM supports QoS.
diff --git a/contrib/ofed/management/opensm/doc/opensm_release_notes-3.1.11.txt b/contrib/ofed/management/opensm/doc/opensm_release_notes-3.1.11.txt
deleted file mode 100644
index 5d8366c..0000000
--- a/contrib/ofed/management/opensm/doc/opensm_release_notes-3.1.11.txt
+++ /dev/null
@@ -1,492 +0,0 @@
- OpenSM Release Notes 3.1.11
- =============================
-
-Version: OpenFabrics Enterprise Distribution (OFED) 1.3
-Repo: git://git.openfabrics.org/~ofed_1_3/management.git (release)
- git://git.openfabrics.org/~sashak/management.git (development)
-Date: May 2008
-
-1 Overview
-----------
-This document describes the contents of the OpenSM OFED 1.3 release.
-OpenSM is an InfiniBand compliant Subnet Manager and Administration,
-and runs on top of OpenIB. The OpenSM version for this release
-is openib-3.1.11
-
-This document includes the following sections:
-1 This Overview section (describing new features and software
- dependencies)
-2 Known Issues And Limitations
-3 Unsupported IB compliance statements
-4 Major Bug Fixes
-5 Main Verification Flows
-6 Qualified software stacks and devices
-
-1.1 Major New Features
-
-* QoS manager (experimental)
- This QoS manager implementation is in accordance with IBA QoS Annex.
- Highly configurable QoS Policy is parsed from OpenSM QoS policy file.
- Valid QoS parameters will be reported in SA PathRecord and
- MultiPathRecord. In addition simple QoS levels per ULPs configuration
- is supported too.
-
-* Performance Manager
- When enabled it collects a fabric port counters and able to log it or
- to pass to external program via event plugin interface. It handles
- counters overflow, supports LID/QP redirection and is able to work
- when OpenSM is in master, standby, and inactive states.
-
-* Dimension Order routing (DOR) algorithm
- DOR Unicast routing algorithm - based on the Min Hop algorithm, but
- avoids port equalization except for redundant links between the
- same two switches. This provides deadlock free routes for hypercubes
- when the fabric is cabled as a hypercube and for meshes when cabled
- as a mesh (see details in OpenSM man page).
-
-* Routing improvements
- Speedup the current routing algorithms default MinHops, Up/Down and
- LASH and lid matrix generation. Fat Tree routing engine is able to work
- with not pure fat free topology.
-
-* Multiple IB routers support
- OpenSM now able to keep configurable subnet prefix to router table.
- SA will report path to this routers when SA PathRecord was issued with
- non-local DGID.
-
-* Node map
- This is possible to name nodes in this config file. Those names will be
- used for logging and by QoS configuration.
-
-* PKey index support
- Proper support for PKey index in GSI queries.
-
-* Incremental LFTs, PKey, SL2VL, and VLarbitration table updates
- OpenSM will only fetch those tables in first heavy sweep and then
- will maintain this internally.
-
-* Fast port and switch detector
- When port and/or switch was externally reset and it was fast so sweep
- doesn't find this device as disconnected OpenSM will detect this by
- changed port states and handle accordingly.
-
-* Duplicated GUIDs/port moving detector
- OpenSM will be able to detect port moving during a fabric discovery
- and will not report duplicated GUIDs in this case.
-
-* Multicast rerouting speedup
- Now OpenSM will calculate and setup multicast forwarding tables for
- all altered multicast groups and not for each one.
-
-* Event plugin API
- OpenSM allows to load dynamically various plugin modules.
-
-* Many generic improvements
-
-1.2 Minor New Features:
-
-* Daemon mode can be activated with -B option.
-
-* Support multiple scopes for IPoIB multicast groups in partition config.
-
-* Loopback connection handling
- Loopback connection is not interpreted as duplicated GUID anymore.
-
-* Connect root nodes option for Up/Down routing engine.
- When this option is specified Up/Down will create routing paths between
- its root nodes.
-
-* Dump and log filenames changed from osm* to opensm*.
-
-* Support loopback console
- Socket console with only local access.
-
-* Configurable config directory (the default value is /etc/opensm) and
- configurable default values of OpenSM config filenames.
-
-* Add option for force SDR link speed
- Add option to opensm.opts to force link speed. Currently, only forcing
- to SDR link speed is supported. This option is not supported as a
- command line option.
-
-* Better packaging
- Building and RPM packaging were improved and simplified.
-
-* Handle "babbling" ports
- When a babbling port (port which causes a frequent trap generation) is
- detected, OpenSM will disable the port which should terminate the trap
- storm.
-
-1.3 Library API Changes
-
- None
-
-1.4 Software Dependencies
-
-OpenSM depends on the installation of either OFED 1.3, OFED 1.2, OFED 1.1,
-OFED 1.0, OpenIB gen2 (e.g. IBG2 distribution), OpenIB gen1 (e.g. IBGD
-distribution), or Mellanox VAPI stacks. The qualified driver versions
-are provided in Table 2, "Qualified IB Stacks".
-
-Also building of QoS manager policy file parser requires flex, and either
-bison or byacc installed.
-
-1.5 Supported Devices Firmware
-
-The main task of OpenSM is to initialize InfiniBand devices. The
-qualified devices and their corresponding firmware versions
-are listed in Table 3.
-
-2 Known Issues And Limitations
-------------------------------
-
-* No Service / Key associations:
- There is no way to manage Service access by Keys.
-
-* No SM to SM SMDB synchronization:
- Puts the burden of re-registering services, multicast groups, and
- inform-info on the client application (or IB access layer core).
-
-3 Unsupported IB Compliance Statements
---------------------------------------
-The following section lists all the IB compliance statements which
-OpenSM does not support. Please refer to the IB specification for detailed
-information regarding each compliance statement.
-
-* C14-22 (Authentication):
- M_Key M_KeyProtectBits and M_KeyLeasePeriod shall be set in one
- SubnSet method. As a work-around, an OpenSM option is provided for
- defining the protect bits.
-
-* C14-67 (Authentication):
- On SubnGet(SMInfo) and SubnSet(SMInfo) - if M_Key is not zero then
- the SM shall generate a SubnGetResp if the M_Key matches, or
- silently drop the packet if M_Key does not match.
-
-* C15-0.1.23.4 (Authentication):
- InformInfoRecords shall always be provided with the QPN set to 0,
- except for the case of a trusted request, in which case the actual
- subscriber QPN shall be returned.
-
-* o13-17.1.2 (Event-FWD):
- If no permission to forward, the subscription should be removed and
- no further forwarding should occur.
-
-* C14-24.1.1.5 and C14-62.1.1.22 (Initialization):
- GUIDInfo - SM should enable assigning Port GUIDInfo.
-
-* C14-44 (Initialization):
- If the SM discovers that it is missing an M_Key to update CA/RT/SW,
- it should notify the higher level.
-
-* C14-62.1.1.12 (Initialization):
- PortInfo:M_Key - Set the M_Key to a node based random value.
-
-* C14-62.1.1.13 (Initialization):
- PortInfo:P_KeyProtectBits - set according to an optional policy.
-
-* C14-62.1.1.24 (Initialization):
- SwitchInfo:DefaultPort - should be configured for random FDB.
-
-* C14-62.1.1.32 (Initialization):
- RandomForwardingTable should be configured.
-
-* o15-0.1.12 (Multicast):
- If the JoinState is SendOnlyNonMember = 1 (only), then the endport
- should join as sender only.
-
-* o15-0.1.8 (Multicast):
- If a request for creating an MCG with fields that cannot be met,
- return ERR_REQ_INVALID (currently ignores SL and FlowLabelTClass).
-
-* C15-0.1.8.6 (SA-Query):
- Respond to SubnAdmGetTraceTable - this is an optional attribute.
-
-* C15-0.1.13 Services:
- Reject ServiceRecord create, modify or delete if the given
- ServiceP_Key does not match the one included in the ServiceGID port
- and the port that sent the request.
-
-* C15-0.1.14 (Services):
- Provide means to associate service name and ServiceKeys.
-
-4 Major Bug Fixes
------------------
-
-The following is a list of bugs that were fixed. Note that other less critical
-or visible bugs were also fixed.
-
-* osm_ucast_ftree.c: do load-leveling of non-CN routes
-
-* osm_ucast_ftree.c: ignore port 0 and loopbacks on switches
-
-* lash: fix possible segfault in osm_get_lash_sl()
-
-* osm_ucast_ftree.c: fixing coredump in fat-tree routing
-
-* osm_sa_slvl_record: fix overflow crash
-
-* Break multicast rerouting requests processing when heavy sweep is
- scheduled.
-
-* updn: report fallback properly
-
-* Fix incorrect identification of routing engine used
-
-* Don't zero base LID when invalid value is received
-
-* lash: fix wrong allocation size
-
-* Fixing broken logic in 'process world' part of LinkRecord processing
-
-* Fix lmc_mask bit order in osm_sa_link_record.c
-
-* Adding missing comparison by to_lid/from_lid in LinkRecord processing
-
-* Broken logic when scanning subnet for PIR request
-
-* No interactive games in daemon mode
-
-* Fixing memory leak in node description
-
-* Fix PortInfo update issues for switch port 0
-
-* Changed method_mask type in user_mad interface in accordance with
- kernel ABI
-
-* Use umad_get_issm_path() in osm_vendor_set_sm()
-
-* Report message fix
-
-* Uninitialized variables usage fix
-
-* osm_ucast_ftree.c: Possible NULL ptr seg fault
-
-* osm_mcast_mgr.c: Possible NULL ptr seg fault
-
-* TrapRepress was failing for mkey != 0
-
-* IB_PR_COMPMASK was used in MPR
-
-* Set hop limit when creating ipoib multicast groups
-
-* Fix outstanding mad counters tracking on the error paths.
-
-* Report new ports before handover mastership
-
-* Fix opvls and neighbormtu when remote port invalid.
-
-* Bug in coding trying to set vl_arb_high_limit when PortInfo.base_lid
- was still zero.
-
-* Protect SMInfo response against port moving issue.
-
-5 Main Verification Flows
--------------------------
-
-OpenSM verification is run using the following activities:
-* osmtest - a stand-alone program
-* ibmgtsim (IB management simulator) based - a set of flows that
- simulate clusters, inject errors and verify OpenSM capability to
- respond and bring up the network correctly.
-* small cluster regression testing - where the SM is used on back to
- back or single switch configurations. The regression includes
- multiple OpenSM dedicated tests.
-* cluster testing - when we run OpenSM to setup a large cluster, perform
- hand-off, reboots and reconnects, verify routing correctness and SA
- responsiveness at the ULP level (IPoIB and SDP).
-
-5.1 osmtest
-
-osmtest is an automated verification tool used for OpenSM
-testing. Its verification flows are described by list below.
-
-* Inventory File: Obtain and verify all port info, node info, link and path
- records parameters.
-
-* Service Record:
- - Register new service
- - Register another service (with a lease period)
- - Register another service (with service p_key set to zero)
- - Get all services by name
- - Delete the first service
- - Delete the third service
- - Added bad flows of get/delete non valid service
- - Add / Get same service with different data
- - Add / Get / Delete by different component mask values (services
- by Name & Key / Name & Data / Name & Id / Id only )
-
-* Multicast Member Record:
- - Query of existing Groups (IPoIB)
- - BAD Join with insufficient comp mask (o15.0.1.3)
- - Create given MGID=0 (o15.0.1.4)
- - Create given MGID=0xFF12A01C,FE800000,00000000,12345678 (o15.0.1.4)
- - Create BAD MGID=0xFA. (o15.0.1.6)
- - Create BAD MGID=0xFF12A01B w/ link-local not set (o15.0.1.6)
- - New MGID with invalid join state (o15.0.1.9)
- - Retry of existing MGID - See JoinState update (o15.0.1.11)
- - BAD RATE when connecting to existing MGID (o15.0.1.13)
- - Partial JoinState delete request - removing FullMember (o15.0.1.14)
- - Full Delete of a group (o15.0.1.14)
- - Verify Delete by trying to Join deleted group (o15.0.1.14)
- - BAD Delete of IPoIB membership (no prev join) (o15.0.1.15)
-
-* GUIDInfo Record:
- - All GUIDInfoRecords in subnet are obtained
-
-* MultiPathRecord:
- - Perform some compliant and noncompliant MultiPathRecord requests
- - Validation is via status in responses and IB analyzer
-
-* PKeyTableRecord:
- - Perform some compliant and noncompliant PKeyTableRecord queries
- - Validation is via status in responses and IB analyzer
-
-* LinearForwardingTableRecord:
- - Perform some compliant and noncompliant LinearForwardingTableRecord queries
- - Validation is via status in responses and IB analyzer
-
-* Event Forwarding: Register for trap forwarding using reports
- - Send a trap and wait for report
- - Unregister non-existing
-
-* Trap 64/65 Flow: Register to Trap 64-65, create traps (by
- disconnecting/connecting ports) and wait for report, then unregister.
-
-* Stress Test: send PortInfoRecord queries, both single and RMPP and
- check for the rate of responses as well as their validity.
-
-
-5.2 IB Management Simulator OpenSM Test Flows:
-
-The simulator provides ability to simulate the SM handling of virtual
-topologies that are not limited to actual lab equipment availability.
-OpenSM was simulated to bring up clusters of up to 10,000 nodes. Daily
-regressions use smaller (16 and 128 nodes clusters).
-
-The following test flows are run on the IB management simulator:
-
-* Stability:
- Up to 12 links from the fabric are randomly selected to drop packets
- at drop rates up to 90%. The SM is required to succeed in bringing the
- fabric up. The resulting routing is verified to be correct as well.
-
-* LID Manager:
- Using LMC = 2 the fabric is initialized with LIDs. Faults such as
- zero LID, Duplicated LID, non-aligned (to LMC) LIDs are
- randomly assigned to various nodes and other errors are randomly
- output to the guid2lid cache file. The SM sweep is run 5 times and
- after each iteration a complete verification is made to ensure that all
- LIDs that could possibly be maintained are kept, as well as that all nodes
- were assigned a legal LID range.
-
-* Multicast Routing:
- Nodes randomly join the 0xc000 group and eventually the
- resulting routing is verified for completeness and adherence to
- Up/Down routing rules.
-
-* osmtest:
- The complete osmtest flow as described in the previous table is run on
- the simulated fabrics.
-
-* Stress Test:
- This flow merges fabric, LID and stability issues with continuous
- PathRecord, ServiceRecord and Multicast Join/Leave activity to
- stress the SM/SA during continuous sweeps. InformInfo Set/Delete/Get
- were added to the test such both existing and non existing nodes
- perform them in random order.
-
-5.3 OpenSM Regression
-
-Using a back-to-back or single switch connection, the following set of
-tests is run nightly on the stacks described in table 2. The included
-tests are:
-
-* Stress Testing: Flood the SA with queries from multiple channel
- adapters to check the robustness of the entire stack up to the SA.
-
-* Dynamic Changes: Dynamic Topology changes, through randomly
- dropping SMP packets, used to test OpenSM adaptation to an unstable
- network & verify DB correctness.
-
-* Trap Injection: This flow injects traps to the SM and verifies that it
- handles them gracefully.
-
-* SA Query Test: This test exhaustively checks the SA responses to all
- possible single component mask. To do that the test examines the
- entire set of records the SA can provide, classifies them by their
- field values and then selects every field (using component mask and a
- value) and verifies that the response matches the expected set of records.
- A random selection using multiple component mask bits is also performed.
-
-5.4 Cluster testing:
-
-Cluster testing is usually run before a distribution release. It
-involves real hardware setups of 16 to 32 nodes (or more if a beta site
-is available). Each test is validated by running all-to-all ping through the IB
-interface. The test procedure includes:
-
-* Cluster bringup
-
-* Hand-off between 2 or 3 SM's while performing:
- - Node reboots
- - Switch power cycles (disconnecting the SM's)
-
-* Unresponsive port detection and recovery
-
-* osmtest from multiple nodes
-
-* Trap injection and recovery
-
-
-6 Qualification
-----------------
-
-Table 2 - Qualified IB Stacks
-=============================
-
-Stack | Version
------------------------------------------|--------------------------
-OFED | 1.3
-OFED | 1.2
-OFED | 1.1
-OFED | 1.0
-OpenIB Gen2 (IBG2 distribution) | 1.0
-OpenIB Gen1 (IBGD distribution) | 1.8.0
-VAPI (Mellanox InfiniBand HCA Driver) | 3.2 and later
-
-Table 3 - Qualified Devices and Corresponding Firmware
-======================================================
-
-Mellanox
-Device | FW versions
-------------------------------------|-------------------------------
-InfiniScale | fw-43132 5.2.000 (and later)
-InfiniScale III | fw-47396 0.5.000 (and later)
-InfiniHost | fw-23108 3.5.000 (and later)
-InfiniHost III Lx | fw-25204 1.2.000 (and later)
-InfiniHost III Ex (InfiniHost Mode) | fw-25208 4.8.200 (and later)
-InfiniHost III Ex (MemFree Mode) | fw-25218 5.3.000 (and later)
-ConnectX IB | fw-25408 2.3.000 (and later)
-
-QLogic/PathScale
-Device | Note
---------|-----------------------------------------------------------
-iPath | QHT6040 (PathScale InfiniPath HT-460)
-iPath | QHT6140 (PathScale InfiniPath HT-465)
-iPath | QLE6140 (PathScale InfiniPath PE-880)
-iPath | QLE7240
-iPath | QLE7280
-
-Note 1: OpenSM does not run on an IBM Galaxy (eHCA) as it does not expose
-QP0 and QP1. However, it does support it as a device on the subnet.
-
-Note 2: QoS firmware and Mellanox devices
-
-HCAs: QoS supported by ConnectX. The current FW release
-doesn't support QoS. QoS-enabled FW release (2_5_000) is
-planned for May. If someone wishes to get QoS-enabled FW
-before the official release, they should contact Mellanox FAE.
-
-Switches: QoS supported by InfiniScale III
-Any InfiniScale III FW that is supported by OpenSM supports QoS.
diff --git a/contrib/ofed/management/opensm/doc/opensm_release_notes-3.2.txt b/contrib/ofed/management/opensm/doc/opensm_release_notes-3.2.txt
deleted file mode 100644
index 3356e95..0000000
--- a/contrib/ofed/management/opensm/doc/opensm_release_notes-3.2.txt
+++ /dev/null
@@ -1,618 +0,0 @@
- OpenSM Release Notes 3.2
- =============================
-
-Version: OpenSM 3.2.x
-Repo: git://git.openfabrics.org/~sashak/management.git
-Date: Dec 2008
-
-1 Overview
-----------
-This document describes the contents of the OpenSM 3.2 release.
-OpenSM is an InfiniBand compliant Subnet Manager and Administration,
-and runs on top of OpenIB. The OpenSM version for this release
-is opensm-3.2.5
-
-This document includes the following sections:
-1 This Overview section (describing new features and software
- dependencies)
-2 Known Issues And Limitations
-3 Unsupported IB compliance statements
-4 Bug Fixes
-5 Main Verification Flows
-6 Qualified Software Stacks and Devices
-
-1.1 Major New Features
-
-* Cached Routing
- OpenSM provides an optional unicast routing cache (enabled by '-A' or
- '--ucast_cache' options). When enabled, unicast routing cache prevents
- routing recalculation (which is a heavy task in a large cluster) when
- there was no topology change detected during the heavy sweep, or when
- the topology change does not require new routing calculation, e.g. when
- one or more CAs/RTRs/leaf switches going down, or one or more of these
- nodes coming back after being down.
-
-* Routing Chaining
- Routing chaining is the ability to configure the order in which routing
- algorithms are applied in opensm, i.e. '-R ftree,updn,minhop' - try
- using ftree routing. If ftree fails, try updn. If updn fails, try
- minhop.
-
-* IPv6 Solicited Node Multicast addresses consolidation
- When this mode is used (enabled with --consolidate_ipv6_snm_req option)
- OpenSM will map all IPv6 Solicited Node Multicast address join requests
- into a single Multicast group with address ff10:601b::1:ff00:0. In this
- way limited MLID space is saved. This IBA noncompliant feature is very
- useful with large (~> 1024 nodes) clusters.
-
-* OpenSM sweep state machine rework
- Huge and buggy OpenSM sweep state machine was fully rewritten in safer
- and more effective synchronous manner.
-
-* Multi lid routing balancing for updn/minhop routing algorithms
- When LMC > 0 is used OpenSM will ensure to generate routing paths via
- different switches and when possible chassis.
-
-* Preserve base lid routes when LMC > 0
- When LMC > 0 is used OpenSM will preserve routing paths for base lids
- as it would be with LMC = 0. In this way traffic on each LID level is
- not affected by LMC changes.
-
-* Ordered routing paths balancing
- This adds ability to predefine the port order in which routing paths
- balancing is performed by OpenSM. Helps to improve performance
- dramatically (40-50%) for applications with known communication
- pattern. Activated with --guid_routing_order_file command line option.
-
-* Unified OpenSM configuration
- Now there is "conventional" config file instead of hidden option cache
- file (opensm.opts). OpenSM will find this in a default place (consult
- man page for exact value) or the file name can be specified with '-F'
- command line option. Also there is an option ('-c') to generate config
- file template.
-
-* Query remote SMs during light sweep
- Master OpenSM will query remote standby SMs periodically to catch its
- possible state changes and react accordingly (as required by IBA spec).
-
-* Predefined port ids for Up/Down algorithm
- This is useful as Up/Down fine tuning tool - the algorithm will use
- predefined port IDs instead of GUIDs for its decision about direction.
- Activated with --ids_guid_file command line option.
-
-* Improved plugin API version 2.
- Now OpenSM will provide to plugins the access to all data structures.
- This make it possible to implement powerful multi purpose plugins. All
- OpenSM header files are installed now and specific configuration/build
- options are exported via generated osm_config.h header file.
-
-* Many code improvements, optimizations and cleanups
-
-* Automatic daily snapshots generation.
- This is is not a "feature", but simplifies the access to recent OpenSM
- bits.
-
-1.2 Minor New Features:
-
-* Cleanup cl_qlock_pool memory allocator - speedup memory allocations
-
-* Support for configurable (via OSM_UMAD_MAX_PENDING environment variable)
- size of pending MADs pool.
-
-* Set packet life time to subnet timeout option rather than default
-
-* Enforce routing paths rebalancing on switch reconnection
-
-* In Up/Down routing algorithm compare GUID values in host byte order
-
-* Add 'switchbalance' and 'lidbalance' commands for OpenSM console
-
-* Respond to new trap 144 node description update flag
-
-* Add '--connect_roots' command line options. This preserves connectivity
- between root nodes in Up/Down routing algorithm
-
-* Setting SL in the IPoIB MCast groups in accordance with QoS policy
-
-* Dump auto detected root node guids in Up/Down routing algorithm
-
-* Unify OpenSM dumpers code
-
-* Unify various guid files parsers - add generic nodenamemap style parser
-
-* When root node guids were provided in file update the list on each
- Up/Down run
-
-* During ./configure show values of configuration dirs and files
-
-* Make prefix routes config file name configurable
-
-* Add a Performance Manager HOWTO to the docs and the dist
-
-* Support separate SA and SM keys as clarified in IBA 1.2.1
-
-* Remove AM_MAINTAINER_MODE in ./configure
-
-* Make vendor type OSM_VENDOR_INTF_OPENIB (libibumad) to be default
-
-* Build osm_perfmgr_db.* content only when PerfMgr is enabled.
-
-* Move PerfMgr event_db_dump_file to common OpenSM dump dir
-
-* Allow space separated strings as values in OpenSM config
-
-* Support for multiple event plugins
-
-* Add '--version' command line option
-
-* Add '--create-config <file-name>' command line option
-
-* Speedup and simplify logging code
-
-* Speedup multicast processing in SA DB
-
-* In log messages convert unicast LIDs from hex to decimal format and
- GIDs from hex to IPv6 address format
-
-* Handle all possible ports in "ignore-guids" file
-
-* Add 'reroute' console command
-
-* Remove many install-exec-hook from Makefiles
-
-* Some cleanups in LASH routing algorithm code
-
-* In Makefiles remove -rpath and explicit -lpthread, -ldl from LDFLAGS
- (move to configurator)
-
-* Install all OpenSM header files
-
-* Improve locking in SM Info receiver
-
-* Add new OSM_EVENT_ID_SUBNET_UP event for plugins
-
-* Redo lex and yacc files generation in conventional way
-
-* Add a missing Node Description check on light sweep.
-
-* Move vendor specific compilation defines from command to generated
- config.h file
-
-* Provide useful error message when log file opening fails
-
-* Add generated osm_config.h file with OpenSM specific defines
-
-* Display port number in decimal in log messages
-
-* Replace osm_vendor_select.h by generated osm_config.h
-
-* Unify options listing in OpenSM usage message
-
-* LFT buffers handling simplification
-
-* Add 'dump_conf' console command
-
-* OpenSM performs sweep on SIGCONT (coming out of suspend).
-
-* When our SM is in Standby state and its priority is increased
- (via console command), notify master SM by sending Trap 144.
-
-* When entering standby state (after discovery) notify master SM
- with Trap 144.
-
-* support more PortInfo:CapabilityMask bits
-
-* When babbling port policy is on disable the port with the least hop
- count.
-
-1.3 Library API Changes
-
- None
-
-1.4 Software Dependencies
-
-OpenSM depends on the installation of either OFED 1.x, OpenIB gen2 (e.g.
-IBG2 distribution), OpenIB gen1 (e.g. IBGD distribution), or Mellanox
-VAPI stacks. The qualified driver versions are provided in Table 2,
-"Qualified IB Stacks".
-
-Also, building of QoS manager policy file parser requires flex, and either
-bison or byacc installed.
-
-1.5 Supported Devices Firmware
-
-The main task of OpenSM is to initialize InfiniBand devices. The
-qualified devices and their corresponding firmware versions
-are listed in Table 3.
-
-2 Known Issues And Limitations
-------------------------------
-
-* No Service / Key associations:
- There is no way to manage Service access by Keys.
-
-* No SM to SM SMDB synchronization:
- Puts the burden of re-registering services, multicast groups, and
- inform-info on the client application (or IB access layer core).
-
-3 Unsupported IB Compliance Statements
---------------------------------------
-The following section lists all the IB compliance statements which
-OpenSM does not support. Please refer to the IB specification for detailed
-information regarding each compliance statement.
-
-* C14-22 (Authentication):
- M_Key M_KeyProtectBits and M_KeyLeasePeriod shall be set in one
- SubnSet method. As a work-around, an OpenSM option is provided for
- defining the protect bits.
-
-* C14-67 (Authentication):
- On SubnGet(SMInfo) and SubnSet(SMInfo) - if M_Key is not zero then
- the SM shall generate a SubnGetResp if the M_Key matches, or
- silently drop the packet if M_Key does not match.
-
-* C15-0.1.23.4 (Authentication):
- InformInfoRecords shall always be provided with the QPN set to 0,
- except for the case of a trusted request, in which case the actual
- subscriber QPN shall be returned.
-
-* o13-17.1.2 (Event-FWD):
- If no permission to forward, the subscription should be removed and
- no further forwarding should occur.
-
-* C14-24.1.1.5 and C14-62.1.1.22 (Initialization):
- GUIDInfo - SM should enable assigning Port GUIDInfo.
-
-* C14-44 (Initialization):
- If the SM discovers that it is missing an M_Key to update CA/RT/SW,
- it should notify the higher level.
-
-* C14-62.1.1.12 (Initialization):
- PortInfo:M_Key - Set the M_Key to a node based random value.
-
-* C14-62.1.1.13 (Initialization):
- PortInfo:P_KeyProtectBits - set according to an optional policy.
-
-* C14-62.1.1.24 (Initialization):
- SwitchInfo:DefaultPort - should be configured for random FDB.
-
-* C14-62.1.1.32 (Initialization):
- RandomForwardingTable should be configured.
-
-* o15-0.1.12 (Multicast):
- If the JoinState is SendOnlyNonMember = 1 (only), then the endport
- should join as sender only.
-
-* o15-0.1.8 (Multicast):
- If a request for creating an MCG with fields that cannot be met,
- return ERR_REQ_INVALID (currently ignores SL and FlowLabelTClass).
-
-* C15-0.1.8.6 (SA-Query):
- Respond to SubnAdmGetTraceTable - this is an optional attribute.
-
-* C15-0.1.13 Services:
- Reject ServiceRecord create, modify or delete if the given
- ServiceP_Key does not match the one included in the ServiceGID port
- and the port that sent the request.
-
-* C15-0.1.14 (Services):
- Provide means to associate service name and ServiceKeys.
-
-4 Bug Fixes
------------
-
-4.1 Major Bug Fixes
-
-* Set SA attribute offset to 0 when no records are returned
-
-* Send trap 64 only after new ports are in ACTIVE state.
-
-* Fix in sending client reregistration bit
-
-* Fix default OpenSM SM (and SA) Key byte order
-
-* Fix in sending Multicast groups creation/deletion notification (Traps
- 66,67)
-
-* Don't startup automatically on SuSE based systems
-
-4.2 Other Bug Fixes
-
-* opensm/osm_console.c: fix seg fault when running "portstatus ca" in
- the console
-
-* opensm: fix potential core dumps where osm_node_get_physp_ptr can
- return NULL
-
-* opensm/osm_mcast_mgr: limit spanning tree creation recursion to value
- of max hops (64)
-
-* opensm: switch LFTs incremental update fix
-
-* opensm/osm_state_mgr.c: fix segmentation fault
-
-* opensm: eliminate some potential NULL pointer dereferences
-
-* opensm/osm_console.c: fix guid parsing
-
-* opensm: fix off by 1 issue with max_lid and max_multicat_lid_ho
-
-* opensm: fix potentially wrong port_guid initialization
-
-* opensm/configure.in: fix wrong HAVE_DEFAULT_OPENSM_CONFIG_FILE define
- generation
-
-* opensm: fix snprintf() usage
-
-* opensm/osm_sa_lft_record: validate LFT block number
-
-* opensm/osm_sa_lft_record: pass block parameter in host byte order
-
-* opensm/include/Makefile.am: don't duplicate header files in EXTRA_DIST
-
-* opensm/osm_sa_class_port_info.c: fix over bound array access
-
-* osmtest/osmt_service.c: fix over bound array access
-
-* osmtest: fix qpn encoding in osmtest_informinfo_request()
-
-* opensm/osm_vendor_mlx_sa.c: handling attribute offset of 0
-
-* opensm: fix segfault corner case when osm_console_init fails
-
-* opensm/console: close console socket on cleanup path
-
-* opensm/osm_ucast_lash: fix buffer overflow
-
-* opensm: fix broken IPv6 SNM consolidation code
-
-* opensm/osm_sa_lft_record.c: fix block number encoding byte order
-
-* opensm/osm_sa: fix memory leak in SA responder
-
-* opensm/osm_mcast_mgr: fix memory leak
-
-* opensm: fix qos config parsing bugs
-
-* opensm/osm_mcast_tbl.c: fix sending invalid MF block due to max mlid
- overflow
-
-* opensm: log_max_size config parameter in MB
-
-* opensm/osm_ucast_lash: fix extra memory allocations
-
-* opensm: fix race in main OpenSM flow
-
-* opensm/ftree: fix GUID check against cn_guid_file
-
-* opensm/ftree: save FLT buffers memory allocations
-
-* opensm/osm_sa_link_record.c: prevent potential endless recursion
-
-* opensm: remove SM from sm_guid_tbl when IsSM port capability flag is
- not set
-
-* opensm: fix QoS config bug
-
-* opensm: don't reassign zeroed params from config file
-
-* Other less critical or visible bugs were also fixed.
-
-5 Main Verification Flows
--------------------------
-
-OpenSM verification is run using the following activities:
-* osmtest - a stand-alone program
-* ibmgtsim (IB management simulator) based - a set of flows that
- simulate clusters, inject errors and verify OpenSM capability to
- respond and bring up the network correctly.
-* small cluster regression testing - where the SM is used on back to
- back or single switch configurations. The regression includes
- multiple OpenSM dedicated tests.
-* cluster testing - when we run OpenSM to setup a large cluster, perform
- hand-off, reboots and reconnects, verify routing correctness and SA
- responsiveness at the ULP level (IPoIB and SDP).
-
-5.1 osmtest
-
-osmtest is an automated verification tool used for OpenSM
-testing. Its verification flows are described by list below.
-
-* Inventory File: Obtain and verify all port info, node info, link and path
- records parameters.
-
-* Service Record:
- - Register new service
- - Register another service (with a lease period)
- - Register another service (with service p_key set to zero)
- - Get all services by name
- - Delete the first service
- - Delete the third service
- - Added bad flows of get/delete non valid service
- - Add / Get same service with different data
- - Add / Get / Delete by different component mask values (services
- by Name & Key / Name & Data / Name & Id / Id only )
-
-* Multicast Member Record:
- - Query of existing Groups (IPoIB)
- - BAD Join with insufficient comp mask (o15.0.1.3)
- - Create given MGID=0 (o15.0.1.4)
- - Create given MGID=0xFF12A01C,FE800000,00000000,12345678 (o15.0.1.4)
- - Create BAD MGID=0xFA. (o15.0.1.6)
- - Create BAD MGID=0xFF12A01B w/ link-local not set (o15.0.1.6)
- - New MGID with invalid join state (o15.0.1.9)
- - Retry of existing MGID - See JoinState update (o15.0.1.11)
- - BAD RATE when connecting to existing MGID (o15.0.1.13)
- - Partial JoinState delete request - removing FullMember (o15.0.1.14)
- - Full Delete of a group (o15.0.1.14)
- - Verify Delete by trying to Join deleted group (o15.0.1.14)
- - BAD Delete of IPoIB membership (no prev join) (o15.0.1.15)
-
-* GUIDInfo Record:
- - All GUIDInfoRecords in subnet are obtained
-
-* MultiPathRecord:
- - Perform some compliant and noncompliant MultiPathRecord requests
- - Validation is via status in responses and IB analyzer
-
-* PKeyTableRecord:
- - Perform some compliant and noncompliant PKeyTableRecord queries
- - Validation is via status in responses and IB analyzer
-
-* LinearForwardingTableRecord:
- - Perform some compliant and noncompliant LinearForwardingTableRecord queries
- - Validation is via status in responses and IB analyzer
-
-* Event Forwarding: Register for trap forwarding using reports
- - Send a trap and wait for report
- - Unregister non-existing
-
-* Trap 64/65 Flow: Register to Trap 64-65, create traps (by
- disconnecting/connecting ports) and wait for report, then unregister.
-
-* Stress Test: send PortInfoRecord queries, both single and RMPP and
- check for the rate of responses as well as their validity.
-
-
-5.2 IB Management Simulator OpenSM Test Flows:
-
-The simulator provides ability to simulate the SM handling of virtual
-topologies that are not limited to actual lab equipment availability.
-OpenSM was simulated to bring up clusters of up to 10,000 nodes. Daily
-regressions use smaller (16 and 128 nodes clusters).
-
-The following test flows are run on the IB management simulator:
-
-* Stability:
- Up to 12 links from the fabric are randomly selected to drop packets
- at drop rates up to 90%. The SM is required to succeed in bringing the
- fabric up. The resulting routing is verified to be correct as well.
-
-* LID Manager:
- Using LMC = 2 the fabric is initialized with LIDs. Faults such as
- zero LID, Duplicated LID, non-aligned (to LMC) LIDs are
- randomly assigned to various nodes and other errors are randomly
- output to the guid2lid cache file. The SM sweep is run 5 times and
- after each iteration a complete verification is made to ensure that all
- LIDs that could possibly be maintained are kept, as well as that all nodes
- were assigned a legal LID range.
-
-* Multicast Routing:
- Nodes randomly join the 0xc000 group and eventually the
- resulting routing is verified for completeness and adherence to
- Up/Down routing rules.
-
-* osmtest:
- The complete osmtest flow as described in the previous table is run on
- the simulated fabrics.
-
-* Stress Test:
- This flow merges fabric, LID and stability issues with continuous
- PathRecord, ServiceRecord and Multicast Join/Leave activity to
- stress the SM/SA during continuous sweeps. InformInfo Set/Delete/Get
- were added to the test such both existing and non existing nodes
- perform them in random order.
-
-5.3 OpenSM Regression
-
-Using a back-to-back or single switch connection, the following set of
-tests is run nightly on the stacks described in table 2. The included
-tests are:
-
-* Stress Testing: Flood the SA with queries from multiple channel
- adapters to check the robustness of the entire stack up to the SA.
-
-* Dynamic Changes: Dynamic Topology changes, through randomly
- dropping SMP packets, used to test OpenSM adaptation to an unstable
- network & verify DB correctness.
-
-* Trap Injection: This flow injects traps to the SM and verifies that it
- handles them gracefully.
-
-* SA Query Test: This test exhaustively checks the SA responses to all
- possible single component mask. To do that the test examines the
- entire set of records the SA can provide, classifies them by their
- field values and then selects every field (using component mask and a
- value) and verifies that the response matches the expected set of records.
- A random selection using multiple component mask bits is also performed.
-
-5.4 Cluster testing:
-
-Cluster testing is usually run before a distribution release. It
-involves real hardware setups of 16 to 32 nodes (or more if a beta site
-is available). Each test is validated by running all-to-all ping through the IB
-interface. The test procedure includes:
-
-* Cluster bringup
-
-* Hand-off between 2 or 3 SM's while performing:
- - Node reboots
- - Switch power cycles (disconnecting the SM's)
-
-* Unresponsive port detection and recovery
-
-* osmtest from multiple nodes
-
-* Trap injection and recovery
-
-
-6 Qualified Software Stacks and Devices
----------------------------------------
-
-OpenSM Compatibility
---------------------
-Note that OpenSM version 3.2.1 and earlier used a value of 1 in host
-byte order for the default SM_Key, so there is a compatibility issue
-with these earlier versions of OpenSM when the 3.2.2 or later version
-is running on a little endian machine. This affects SM handover as well
-as SA queries (saquery tool in infiniband-diags).
-
-
-Table 2 - Qualified IB Stacks
-=============================
-
-Stack | Version
------------------------------------------|--------------------------
-OFED | 1.4
-OFED | 1.3
-OFED | 1.2
-OFED | 1.1
-OFED | 1.0
-OpenIB Gen2 (IBG2 distribution) | 1.0
-OpenIB Gen1 (IBGD distribution) | 1.8.0
-VAPI (Mellanox InfiniBand HCA Driver) | 3.2 and later
-
-Table 3 - Qualified Devices and Corresponding Firmware
-======================================================
-
-Mellanox
-Device | FW versions
-------------------------------------|-------------------------------
-InfiniScale | fw-43132 5.2.000 (and later)
-InfiniScale III | fw-47396 0.5.000 (and later)
-InfiniScale IV | fw-48436 7.1.000 (and later)
-InfiniHost | fw-23108 3.5.000 (and later)
-InfiniHost III Lx | fw-25204 1.2.000 (and later)
-InfiniHost III Ex (InfiniHost Mode) | fw-25208 4.8.200 (and later)
-InfiniHost III Ex (MemFree Mode) | fw-25218 5.3.000 (and later)
-ConnectX IB | fw-25408 2.3.000 (and later)
-
-QLogic/PathScale
-Device | Note
---------|-----------------------------------------------------------
-iPath | QHT6040 (PathScale InfiniPath HT-460)
-iPath | QHT6140 (PathScale InfiniPath HT-465)
-iPath | QLE6140 (PathScale InfiniPath PE-880)
-iPath | QLE7240
-iPath | QLE7280
-
-Note 1: OpenSM does not run on an IBM Galaxy (eHCA) as it does not expose
-QP0 and QP1. However, it does support it as a device on the subnet.
-
-Note 2: QoS firmware and Mellanox devices
-
-HCAs: QoS supported by ConnectX. QoS-enabled FW release is 2_5_000 and
-later.
-
-Switches: QoS supported by InfiniScale III
-Any InfiniScale III FW that is supported by OpenSM supports QoS.
diff --git a/contrib/ofed/management/opensm/doc/opensm_release_notes_ibg2-2.0.1.txt b/contrib/ofed/management/opensm/doc/opensm_release_notes_ibg2-2.0.1.txt
deleted file mode 100644
index ea1f6a9..0000000
--- a/contrib/ofed/management/opensm/doc/opensm_release_notes_ibg2-2.0.1.txt
+++ /dev/null
@@ -1,456 +0,0 @@
- OpenSM Release Notes
- ======================
-
-Release: IBG2
-Repo: https://openib.org/svn/trunk/contrib/mellanox/gen2/src/userspace/management/osm
-Version: 4956
-Date: Jan 2006
-
-1 Overview
-----------
-This document describes the contents of the OpenSM IBG2 release.
-OpenSM is an InfiniBand compliant Subnet Manager and Administrator,
-and runs on top of OpenIB.
-
-This document includes the following sections:
-1 This Overview section (describing new features and software
- dependencies)
-2 Known Issues And Limitations
-3 Unsupported IB compliancy statements
-4 Major Bug Fixes
-5 Main Verification Flows
-6 Qualified software stacks and devices
-
-1.1 New Features
-
-* New libs created during installation: libopensm - contains interface
- to the logging and mads pool machanism. libosmcomp - contains
- interface to the complib utilities. libosmvendor - contains
- interface to sending/receiving MADs through the SMI or GSI over the
- IBG2 driver.
-
-* Change building mechanism to use autotools.
-
-* Change directory stucturing of the OpenSM code according to libs:
- osm/libvendor - for vendor specific files. osm/complib - for complib
- specific files. osm/opensm - for opensm core files. osm/include
-
-* Semi-static LID assignment: OpenSM uses a cache file for storing all
- LID assignments such that, even after a reboot, the LIDs do not
- change. The static LID assignment is built on top of a new
- "persistancy" layer that abstracts that actual database from its
- usage. The implemented database is based on files stored under
- /var/cache/osm (this location can be overriden via the environment
- variable OSM_CACHE_DIR). Other implementations can use LDAP for
- example. Note that a standby SM ignores its previously assigned LIDs
- when it becomes the master, and the previous master LID settings are
- used.
-
-* Irresponsive Port Handling: A port that does not respond to SM
- queries will be queried upon future light or heavy sweeps, and if
- then it responds, it will be setup immediately. Previously such a
- port was queried only upon a heavy sweep.
-
-* Leaf Switch Port HOQ: A different maximal head of queue life time is
- assigned to switch ports connected to HCAs such that a bad chipset
- or defective hardware will not cause back presure on the fabric.
-
-* OSM_TMP_DIR: This is a new environment variable controlling the
- directory where subnet.lst, osm.fdbs and osm.mcfdbs files are
- created. The deafult is still /tmp.
-
-* Configuration Options cache file: OpenSM was enhanced to provide a
- means to modify all its internal configuration options, including
- the ones that oreviously were only available under osmsh. The new
- file is located under the cache directory and is named
- opensm.opts. To automatically create this file OpenSM supports a new
- flag: `-c'. The file is generated with the current set of options
- used by OpenSM.
-
-* Previously, under extreme load conditions, when OpenSM got
- overloaded with SA queries during which the incoming messages queue
- also grew, delays were incurred in message response-time beyond the
- expected. This new version of OpenSM has been enhanced such that,
- under such a case, incoming new SA queries are returned with a
- RESOURCE_BUSY status (per the InfiniBand Architecture
- Specification).
-
-* Kill -HUP: If the OpenSM process (ps -efww |grep opensm.bin) gets a
- SIGHUP (sent by kill -HUP), it will start a heavy sweep as if a trap
- was received or a change in topology was observed by the SM.
-
-1.2 Software Dependencies
-
-OpenSM depends on the installation of either OpenIB gen2 (e.g. IBG2
-distribution), OpenIB gen1 (r.g. IBGD distribution) or Mellanox VAPI
-stacks. The qualified driver versions are provided in Table 2,
-"Qualified IB Stacks".
-
-1.4 Supported Devices Firmware
-
-The main task of OpenSM is to initialize InfiniBand devices. The
-qualified devices and their corresponding firmware versions
-listed in Table 3.
-
-2 Known Issues And Limitations
-------------------------------
-
-* No Partition/Pkey policy support:
- OpenSM does not provide means to set poartitions.
-
-* IB "trusted" concept is unsupported:
- Queries that should be classified according to the trustworthiness of
- their sources will not be handled correctly.
-
-* No Service / Key associations:
- There is no way to manage Service access by Keys.
-
-* No SM to SM SMDB synchronization:
- Puts the burden of re-registering services, multicast groups, and
- inform-info on the client application (or IB access layer core).
-
-* NPTL problem under Red Hat 9.0, Red Hat AS 3.0:
- There are some bugs (pthread conditional wait missing events)
- with thread handling when using the dynamic Native POSIX Thread
- Library (/lib/tls) of Red Hat 9.0 & Red Hat AS 3.0 OSs. To overcome
- that, OpenSM installation places wrapper scripts named opensm and
- osmtest in the /usr/bin directory, which preload the standard libc
- and libptherad before invoking the executables. If using the osm
- package, a similar workaround is possible by putting the LD_PRELOAD
- setting in .tclshrc file, for example: set env (LD_PRELOAD)
- "/lib/libc.so.6:/lib/libpthread.so.0"
-
-* InformInfo failure over IBMGT:
- OpenSM might not respect a valid InformInfo unsubscribe request when
- running over Mellanox's IBMGT user level MAD interface (not on
- IBGD). This will be fixed in the next release.
-
-* No "port down" event handling:
- Changing the switch port through which OpenSM connects to the IB
- fabric may cause wrong operation. Please restart OpenSM whenever
- such a connectivity change is made.
-
-3 Unsupported IB Compliancy Statements
---------------------------------------
-The following section lists all the IB compliancy statements which
-OpenSM does not support. Please refer to IB specification for detailed
-information on each compliancy statement.
-
-* C14-22 (Authentication):
- M_Key M_KeyProtectBits and M_KeyLeasePeriod shall be set in one
- SubnSet method. As a work-around, an OpenSM option is provided for
- defining the protect bits.
-
-* C14-67 (Authentication):
- On SubnGet(SMInfo) and SubnSet(SMInfo) - if M_Key is not zero then
- the SM shall generate a SubnGetResp if the M_Key is matching or
- silently drop the packet if M_Key is not matching.
-
-* C15-0.1.23.1 (Authentication):
- PortInfoRecords shall always be provided with the M_Key component
- set to 0, except in the case of a trusted request, in which case the
- actual M_Key component contents shall be provided.
-
-* C15-0.1.23.2 (Authentication):
- P_KeyTableRecords and ServiceAssociationRecords shall only be
- provided in responses to trusted requests.
-
-* C15-0.1.23.4 (Authentication):
- InformInfoRecords shall always be provided with the QPN set to
- 0, except for the case of a trusted request, in which case the actual
- subscriber QPN shall be returned.
-
-* o13-17.1.2 (Event-FWD):
- If no permission to forward, the subscription should be removed and
- no further forwarding should occur.
-
-* C14-37.1.2 (Handover):
- Priority should be kept in non-volatile memory.
-
-* C14-38.1.1 (Handover):
- Support AttributeModifier values in SubnSet(SMInfo). If the state
- transition requested is invalid - return with status code 7.
-
-* C14-24.1.1.5 and C14-62.1.1.22 (Initialization):
- GUIDInfo - SM should enable assigning Port GUIDInfo.
-
-* C14-44 (Initialization):
- If the SM discovers that it is missing an M_Key to update CA/RT/SW,
- it should notify the higher level.
-
-* C14-62.1.1.11 (Initialization):
- PortInfo:VLHighLimit should match the configured VLArb on the port.
-
-* C14-62.1.1.12 (Initialization):
- PortInfo:M_Key - Set the M_Key to a node based random value.
-
-* C14-62.1.1.13 (Initialization):
- PortInfo:P_KeyProtectBits - set according to an optional policy.
-
-* C14-62.1.1.24 (Initialization):
- SwitchInfo:DefaultPort - should be configured for random FDB.
-
-* C14-62.1.1.32 (Initialization):
- RandomForwardingTable should be configured.
-
-* o15-0.1.12 (Multicast):
- If the JoinState is SendOnlyNonMember = 1 (only), then the endport
- should join as sender only.
-
-* o15-0.1.13 (Multicast):
- If a Join request using unrealistic parameters is received, return
- ERR_REQ_INVALID.
-
-* o15-0.1.8 (Multicast):
- If a request for creating an MCG with fields that cannot be met,
- return ERR_REQ_INVALID (currently ignoring SL and FlowLabelTclass).
-
-* C15-0.1.11 (SA-Query):
- Query response should use only base LIDs (as the feature has not
- been qualified yet).
-
-* C15-0.1.19 (SA-Query):
- Respond to SubnGetMulti(MultiPathRec)
-
-* C15-0.1.8.6 (SA-Query):
- Respond to SubnAdmGetTraceTable - this is an optional attribute.
-
-* C15-0.1.8.7 (SA-Query):
- SubnAdmGetMulti SubnAdmGetMultiResp - Only in case of a MultiPath.
-
-* C15-X.Y.Z.W (SA-Query):
- SubAdmGet/GetTable GUIDInfo - support GUIDInfo setting/retrieval.
-
-* C15-0.1.13 Services:
- Reject ServiceRecord create, modify or delete if the given
- ServiceP_Key does not match the one included in the ServiceGID port
- and the port that sent the request.
-
-* C15-0.1.14 (Services):
- Provide means to associate service name and ServiceKeys.
-
-4 Major Bug Fixes
------------------
-
-The following list of bugs were fixed. Note that other less critical
-or visible bugs were also fixed.
-
-* PortInfo query was not matching on several fields. These fields
- were added to teh comparison function.
-
-* OpenSM would crash during exit flow if run with "-o" flag A fix to
- the complib global timer destruction sequence solves this problem.
-
-* OpenSM does not complete the sweep if the driver fails to send a MAD
- Counting the number of outstanding MADs the SM waits for response
- for was enhanced to take this acse into acount
-
-* OpenSM was not compliant to the spec statement: C14.62.1.1 Table 183
- p870 l34: ".., the SM shall ensure that one of the P_KeyTable
- entries in every node contains either the value 0xFFFF (the default
- P_Key, full membership) or the value 0x7FFF (the default P_Key,
- partial membership)." OpenSM sets the PKey table with an entry of
- 0xffff in case there is no such entry or 0x7fff entries on that
- port. Switch ports are ignored.
-
-* If the SA is queried with IB_PIR_COMPMASK_BASELID and base_lid of 0,
- the SA was incorrectly returning all the ports. Fix: do not ignore base
- lid of 0 as a query criteria.
-
-* When provided a PathRecord query with num_paths = 0 the SM should
- assuem num_paths = 1. Fix: in the PathRecord query code.
-
-* PathRecord query returned a deleted multicast groups info. Fix:
- Added a check for multicast group state to avoid such cases.
-
-* LinkRecord query provided wrong results. Fix: in query code.
-
-* PathRecord did not honor PacketLifeTime component. Fix: Added the
- check for packet lifetime matching.
-
-* Multicast and other registration hapenning all the time on the
- cluster. Fix: OpenSM was sending false "client-re-registration"
- messages (in PortInfo).
-
-* On some heavy load cases OpenSM would consume 100% CPU time. Fix: an
- endless loop in timer implementation that would happen under rare
- heavy CPU load cases.
-
-* OpenSM hangs during LID assignment phase. Fix: Some condition that
- cause that was fixed.
-
-* OpenSM core dump in the middle of sweep. Fix: A memory range
- overflow write was found by valgrind and fix.
-
-* OpenSM core dump as result fo PathRecord query with no results. Fix:
- A memory free on non allocated memory was fixed.
-
-* OpenSM sweep algorithm confused by a timing race. Fix: A significant
- race conditionin the SM sweep algorithm was found and fixed.
-
-* OpenSM deadlock due to out of order SMINfo and NodeInfo MAD
- received. Fix: A fix in lock ordering resolves this issue.
-
-* TrapRepress sent even if not a master. Fix: in trap receiver.
-
-5 Main Verification Flows
--------------------------
-
-OpenSM verification is run using the following activities:
-* osmtest - a standalone program
-* ibmgtsim (IB management simulator) based - a set of flows that
- simulate clusters, inject errors and verify OpenSM capability to
- respond and bring up the network correctly.
-* small cluster regression testing - where the SM is used on back to
- back or single switch configuration. The regression includes
- multiple OpenSM dedicated tests
-* cluster testing - when we run OpenSM to setup large cluster, perform
- handoff, reboots and reconnects, verify routing correctness and SA
- responsiveness at teh ULP level (IPoIB and SDP)
-
-5.1 osmtest
-
-OsmTest is the main automated verification tool used for OpenSM
-testing. Its verification flows are described by list below.
-
-* Inventory File: Obtain and verify all port info, node info, and path
- records parameters.
-
-* Service Record:
- - Register new service
- - Register another service (with a lease period)
- - Register another service (with service p_key set to zero)
- - Get all services by name
- - Delete the first service
- - Delete the third service.
- - Added bad flows of get/delete non valid service
- - Add / Get same service with different data
- - Add / Get / Delete by different component mask values (services
- by Name & Key / Name & Data / Name & Id / Id only )
-
-* Multicast Member Record:
- - Query of existing Groups (IPoIB)
- - BAD Join with insufficient comp mask (o15.0.1.3)
- - Create given MGID=0 (o15.0.1.4)
- - Create given MGID=0xFF12A01C,FE800000,00000000,12345678 (o15.0.1.4)
- - Create BAD MGID=0xFA. (o15.0.1.6)
- - Create BAD MGID=0xFF12A01B w/ link-local not set (o15.0.1.6)
- - New MGID with invalid join state (o15.0.1.9)
- - Retry of existing MGID - See JoinState update (o15.0.1.11)
- - BAD RATE when connecting to existing MGID (o15.0.1.13)
- - Partial JoinState delete request - removing FullMember (o15.0.1.14)
- - Full Delete of a group (o15.0.1.14)
- - Verify Delete by trying to Join deleted group (o15.0.1.14)
- - BAD Delete of IPoIB membership (no prev join) (o15.0.1.15)
-
-* Event Forwarding: Register for trap forwarding using reports
- - Send a trap and wait for report
- - Unregister non-existing
-
-* Trap 64/65 Flow: Register to Trap 64-65, create traps (by
- disconnect/connect ports) and wait for report, then unregister.
-
-* Stress Test: send PortInfoRecord queries both single and RMPP and
- check for the rate of responses as well as their validity.
-
-5.2 IB Management Simulator OpenSM Test Flows:
-
-The simulator provides ability to simulate the SM handling of virtual
-topologies that are not limitted to actual lab equipment availability.
-OpenSM was simulated to bring up clusters of up to 10,000 nodes. Daily
-regressions use smaller (16 and 128 nodes clusters).
-
-The following test flows are running on the IB management simulator:
-
-* Stability:
- Up to 12 links from the fabric are randomly selected to drop packets
- at drop rates up to 90%. The SM is required to succeed bringing the
- fabric up. The reulting routing is verified to be correct too.
-
-* LID Manager:
- Using LMC = 2 the fabric is being initialized with LIDs. Faults like
- zero LID, Duplicated LID, non-aligned (to LMC) LIDs are being
- randomly assigned to various nodes and other errors are randomly
- output to the guid2lid cache file. The SM sweep is run 5 times and
- after each iteration a complete verification is made to ensure all
- LIDs that could possibly be maintained are kept, as well as all nodes
- were assigned a legal LID range.
-
-* Multicast Routing:
- Nodes are randomly joining the 0xc000 group and eventually the
- resulting routing is verified for completness and adherance to
- Up/Down routing rules.
-
-* OsmTest:
- The complete osmtest flow as desribed in previous table is run on
- the simulated fabrics.
-
-5.3 OpenSM Regression
-
-Using a back to back or single switch connection the following set of
-tests are run nightly on the stacks described in table 2. The included
-tests are:
-
-* Stress Testing: Flood the SA with queries from multiple channel
- adapters to check the robustness of the entire stack up to the SA.
-
-* Dynamic Changes: Dynamic Topology changes, through randomlly
- droping SMP packets used to test OpenSM adaptation to unstable
- network & verify DB correctness.
-
-* Trap Injection: This flow injects traps to the SM and verify it does
- handle them gracefully.
-
-* SA Query Test: This test exhoustivly checks the SA responses to all
- possible single component mask. To do that the test examine the
- entire set of records the SA can provide, classify them by their
- field values and then select every field (using component mask and a
- value) and verify the response matches the expected set of records.
- A random selection using multiple component mask bits is also performed.
-
-5.4 Cluster testing:
-
-Cluster testing is usually run before a distribution release. It
-involves real hardware setup of 16 to 32 nodes (or more if beta site
-is available). Each test is validated by running all-to-all ping through IB
-interface. The test procedure includes:
-
-* Cluster bringup
-
-* Handoff between 2 or 3 SM's while performing
- - Node reboots
- - Switch power cycles (disconneting the SM's)
-
-* Irresponsive port detection and recovery
-
-* osmtest from multiple nodes
-
-* Trap injection and recovery
-
-
-6 Qualification
-----------------
-
-Table 2 - Qualified IB Stacks
-=============================
-
-Stack | Version
-----------------------------------------|--------------------------
-VAPI (Mellanox Infininband HCA Driver) | 3.2 and later
-OpenIB Gen1 (IBGD distribution) | 1.8.0
-OpenIB Gen2 (IBG2 distribution) | 1.0
-
-Table 3 - Qualified Devices and Corresponding Firmware
-======================================================
-
-Device | FW versions
---------|-----------------------------------------------------------
-MT43132 | InfiniScale - fw-43132 5.2.0 (and later)
-MT47396 | InfiniScale III - fw-47396 0.5.0 (and later)
-MT23108 | InfiniHost - fw-23108 3.3.2
-MT25204 | InfiniHost III Lx - fw-25204 1.0.1
-MT25208 | InfiniHost III Ex (InfiniHost Mode) - fw-25208 4.6.2 (and later)
-MT25208 | InfiniHost III Ex (MemFree Mode) - fw-25218 5.0.1 (and later)
-
-Other vendors HCAs not yet verified but eHCA is known to be discovered and configured
-correctly.
diff --git a/contrib/ofed/management/opensm/doc/opensm_release_notes_openib-1.2.1.txt b/contrib/ofed/management/opensm/doc/opensm_release_notes_openib-1.2.1.txt
deleted file mode 100644
index 02caaf8..0000000
--- a/contrib/ofed/management/opensm/doc/opensm_release_notes_openib-1.2.1.txt
+++ /dev/null
@@ -1,460 +0,0 @@
- OpenSM Release Notes
- ======================
-
-Version: OpenFabric Enterprise Distribution (OFED) 1.0
-Repo: https://openib.org/svn/gen2/branches/1.0/src/userspace/management/osm
-Version: 7992
-Date: Jun 2006
-
-1 Overview
-----------
-This document describes the contents of the OpenSM OFED 1.0 release.
-OpenSM is an InfiniBand compliant Subnet Manager and Administrator,
-and runs on top of OpenIB. The OpenSM version for this release
-is openib-1.2.1
-
-This document includes the following sections:
-1 This Overview section (describing new features and software
- dependencies)
-2 Known Issues And Limitations
-3 Unsupported IB compliance statements
-4 Major Bug Fixes
-5 Main Verification Flows
-6 Qualified software stacks and devices
-
-1.1 New Features
-
-* SA GuidInfoRecord support
-
-* Default for maxsmps changed:
- Control the number of SMP sent in parallel and thus shorten the
- fabric initialization time.
-
-* osmtest/osmt_slvl_vl_arb.c:
- Output file name changed from vl_arbs.txt to qos.txt
-
-* Support new IBTA Errata IsPortInfoCapMaskMatchSupported:
- This new capability of the SA enables matching of individual port
- capability bits dramatically reducing the query size for agents like
- the SRP initiator query for finding SRP targets.
-
-* Honor guid2lid when coming out of standby:
- This change adds an option to the opensm that forces it to honor the
- guid2lid file given when it comes out of Standby state. Currently,
- when opensm comes out of Standby state, it ignores the guid2lid file
- it read, and honors only the lids defined on the ports themselves.
-
-* Add guid to opensm opts
- This enables the port on which to run the SM to be defined through
- the configuration file as well as through the command line.
-
-* PPC support:
- No PPC QA was performed.
-
-1.2 Software Dependencies
-
-OpenSM depends on the installation of either OFED 1.0,
-OpenIB gen2 (e.g. IBG2 distribution), OpenIB gen1 (e.g. IBGD
-distribution) or Mellanox VAPI stacks. The qualified driver versions
-are provided in Table 2, "Qualified IB Stacks".
-
-1.4 Supported Devices Firmware
-
-The main task of OpenSM is to initialize InfiniBand devices. The
-qualified devices and their corresponding firmware versions
-are listed in Table 3.
-
-2 Known Issues And Limitations
-------------------------------
-
-* No Partition/Pkey policy support:
- OpenSM does not provide means to set partitions.
-
-* No Service / Key associations:
- There is no way to manage Service access by Keys.
-
-* No SM to SM SMDB synchronization:
- Puts the burden of re-registering services, multicast groups, and
- inform-info on the client application (or IB access layer core).
-
-* No "port down" event handling:
- Changing the switch port through which OpenSM connects to the IB
- fabric may cause incorrect operation. Please restart OpenSM whenever
- such a connectivity change is made.
-
-* Changing connections during SM operation:
- Under some conditions the SM can get confused by a change in
- cabling (moving a cable from one switch port to the other) and
- momentarily see this as having the same GUID appear connected
- to two different IB ports. Under some conditions, when the SM fails to
- get the corresponding change event it might mistakenly report this case
- as a "duplicated GUID" case and abort. It is advisable to double-check
- the syslog after each such change in connectivity and restart
- OpenSM if it has exited.
-
-* No QoS support:
- No SL2VL and VLArbitration setting is performed by the SM.
-
-3 Unsupported IB Compliance Statements
---------------------------------------
-The following section lists all the IB compliance statements which
-OpenSM does not support. Please refer to the IB specification for detailed
-information regarding each compliance statement.
-
-* C14-22 (Authentication):
- M_Key M_KeyProtectBits and M_KeyLeasePeriod shall be set in one
- SubnSet method. As a work-around, an OpenSM option is provided for
- defining the protect bits.
-
-* C14-67 (Authentication):
- On SubnGet(SMInfo) and SubnSet(SMInfo) - if M_Key is not zero then
- the SM shall generate a SubnGetResp if the M_Key matches, or
- silently drop the packet if M_Key does not match.
-
-* C15-0.1.23.4 (Authentication):
- InformInfoRecords shall always be provided with the QPN set to 0,
- except for the case of a trusted request, in which case the actual
- subscriber QPN shall be returned.
-
-* o13-17.1.2 (Event-FWD):
- If no permission to forward, the subscription should be removed and
- no further forwarding should occur.
-
-* C14-37.1.2 (Handover):
- Priority should be kept in non-volatile memory.
-
-* C14-24.1.1.5 and C14-62.1.1.22 (Initialization):
- GUIDInfo - SM should enable assigning Port GUIDInfo.
-
-* C14-44 (Initialization):
- If the SM discovers that it is missing an M_Key to update CA/RT/SW,
- it should notify the higher level.
-
-* C14-62.1.1.11 (Initialization):
- PortInfo:VLHighLimit should match the configured VLArb on the port.
-
-* C14-62.1.1.12 (Initialization):
- PortInfo:M_Key - Set the M_Key to a node based random value.
-
-* C14-62.1.1.13 (Initialization):
- PortInfo:P_KeyProtectBits - set according to an optional policy.
-
-* C14-62.1.1.24 (Initialization):
- SwitchInfo:DefaultPort - should be configured for random FDB.
-
-* C14-62.1.1.32 (Initialization):
- RandomForwardingTable should be configured.
-
-* o15-0.1.12 (Multicast):
- If the JoinState is SendOnlyNonMember = 1 (only), then the endport
- should join as sender only.
-
-* o15-0.1.13 (Multicast):
- If a Join request using unrealistic parameters is received, return
- ERR_REQ_INVALID.
-
-* o15-0.1.8 (Multicast):
- If a request for creating an MCG with fields that cannot be met,
- return ERR_REQ_INVALID (currently ignoring SL and FlowLabelTclass).
-
-* C15-0.1.11 (SA-Query):
- Query response should use only base LIDs (as the feature has not
- been qualified yet).
-
-* C15-0.1.19 (SA-Query):
- Respond to SubnGetMulti(MultiPathRec)
-
-* C15-0.1.8.6 (SA-Query):
- Respond to SubnAdmGetTraceTable - this is an optional attribute.
-
-* C15-0.1.8.7 (SA-Query):
- SubnAdmGetMulti SubnAdmGetMultiResp - Only in case of a MultiPath.
-
-* C15-0.1.13 Services:
- Reject ServiceRecord create, modify or delete if the given
- ServiceP_Key does not match the one included in the ServiceGID port
- and the port that sent the request.
-
-* C15-0.1.14 (Services):
- Provide means to associate service name and ServiceKeys.
-
-4 Major Bug Fixes
------------------
-
-The following is a list of bugs that were fixed. Note that other less critical
-or visible bugs were also fixed.
-
-* Eliminate error on active -> active port state transition
- SM may transition port from armed to active but in the meantime, due
- to passing a data packet with active enable set, the port may
- already have transitioned to active. Active -> active port state
- transition is indicated as an error but it isn't really an error so
- don't indicate error in the osm log.
-
-* Routing not set for the first LID in the last LFT block:
- Fix: osm_switch.c: In osm_switch_get_fwd_tbl_block last block calculation
-
-* Corrupted guid2lid file causes OpenSM exit
- Fix: exit only if exit_on_fatal option is set (the default)
-
-* OpenSM was causing Client-Re-Registration continuously:
- The SM was storing the response PortInfo.ClientReRegstration
- bit and using it during next Set(PortInfo). Fix: clear the bit on
- receive.
-
-* Multicast Query Selectors MTU, rate, and PacketLifeTime were not exact
-
-* Try not to recognize port change as duplicated GUID
- This fix solves the issue of a port move during heavy sweep
- being recognized as a duplicated guid. Fix: If the SM sees what
- seems to be a duplicated guid, but it also received an indication
- for immediately forcing another heavy sweep (for example, as a
- result of receiving trap 128) then it shouldn't issue a duplicated
- guid error (and possibly exit), but should just ignore this and
- continue. This means that only if the SM recognizes such a
- duplication in a stable subnet that it'll issue the error (and
- possibly exit).
-
-* Set PKey table on switch ports not supporting it:
- OpenSM attempts to set pkey table entries on external switch ports
- even if the switch declares a PartitionEnforcementCap of zero. The
- consequence is ERR 4108. Fix: Observe PartitionEnforcementCap of zero.
-
-* Incorrect MCMemberRecord Get/GetTable in trusted mode:
- This change fixes the retrieval of the MCMember records according to
- Errata MGTWG3280. This fix provide means to obtain all the group
- members by issuing a trusted GetTable query.
-
-* Trusted MCMemberRecord query was not recognized as trusted:
- Trust is checked by comparing the request SM_Key field to the SM
- SM_Key. The bug was in looking up the SM_Key from the response not
- the request.
-
-* Port left in down state after setting MTU or OpVLs on its neighbor:
- In case of a difference between the MTU of two ports, only the port
- with the higher MTU was set to down. Its remote port was written in
- the DB as in the ACTIVE state although its real status was INIT.
- Because of this, the SM didn't try to move the remote port to
- ACTIVE.
-
-* Atomic counters used throughout the code were broken:
- A new implementation has been provided.
-
-* MC Group creation with "less than" MTU ignores the requester MTU:
- When requesting to create an MC group with MTU(rate) selector 1
- (meaning less than rate specified), the MC group is created with
- MTU(rate) requested - 1. This is without checking the MTU(rate) of
- the port requesting the creation of the multicast group. This means
- that if, for example, port with MTU=2 sends a request for MC group
- creation with MTU selector=1 and MTU=5, Opensm will try to create a
- MC group with MTU=4, and fail, since the port capabilities are not
- realizable. Fix: creation of the MC group with MTU(rate) also takes
- into account the MTU(rate) of the port requesting the creation.
-
-* MC Group join does not validate that the joining port's capabilities
- match those of the MC. Fix: Add verification of endport physical
- capability to join MC group.
-
-* ClientReRegistration not sent to ports discovered after first sweep:
- PortInfo sent with ClientReRegistration bit turned on only during
- the first sweep after becoming Master. This doesn't cover all cases
- where ClientReRegistration should be turned on. Fix: turn on this
- bit also on new ports it discovers (in cases of subnet merging, for
- example).
-
-* segfault during a report on deleted multicast group:
- osm_mcast_mgr.c, executing the line of code:
- osm_mgrp_send_delete_notice( p_mgr->p_subn, p_mgr->p_log, p_mgrp );
- caused segmentation fault since the handle p_mgrp was already
- deleted while the function was called. Fix: inserted the line above
- into the protected section.
-
-* segfault in osm_get_gid_by_mad_addr:
- The affected flows are ports and multicast joins.
-
-* segfault in LID manager:
- Handle NULL p_rem_physp can validly be NULL when the remote SMA is
- not responding (but physical link is up).
-
-* segfault in Up/Down routing engine
-
-
-5 Main Verification Flows
--------------------------
-
-OpenSM verification is run using the following activities:
-* osmtest - a stand-alone program
-* ibmgtsim (IB management simulator) based - a set of flows that
- simulate clusters, inject errors and verify OpenSM capability to
- respond and bring up the network correctly.
-* small cluster regression testing - where the SM is used on back to
- back or single switch configurations. The regression includes
- multiple OpenSM dedicated tests.
-* cluster testing - when we run OpenSM to setup a large cluster, perform
- hand-off, reboots and reconnects, verify routing correctness and SA
- responsiveness at the ULP level (IPoIB and SDP).
-
-5.1 osmtest
-
-osmtest is an automated verification tool used for OpenSM
-testing. Its verification flows are described by list below.
-
-* Inventory File: Obtain and verify all port info, node info, and path
- records parameters.
-
-* Service Record:
- - Register new service
- - Register another service (with a lease period)
- - Register another service (with service p_key set to zero)
- - Get all services by name
- - Delete the first service
- - Delete the third service.
- - Added bad flows of get/delete non valid service
- - Add / Get same service with different data
- - Add / Get / Delete by different component mask values (services
- by Name & Key / Name & Data / Name & Id / Id only )
-
-* Multicast Member Record:
- - Query of existing Groups (IPoIB)
- - BAD Join with insufficient comp mask (o15.0.1.3)
- - Create given MGID=0 (o15.0.1.4)
- - Create given MGID=0xFF12A01C,FE800000,00000000,12345678 (o15.0.1.4)
- - Create BAD MGID=0xFA. (o15.0.1.6)
- - Create BAD MGID=0xFF12A01B w/ link-local not set (o15.0.1.6)
- - New MGID with invalid join state (o15.0.1.9)
- - Retry of existing MGID - See JoinState update (o15.0.1.11)
- - BAD RATE when connecting to existing MGID (o15.0.1.13)
- - Partial JoinState delete request - removing FullMember (o15.0.1.14)
- - Full Delete of a group (o15.0.1.14)
- - Verify Delete by trying to Join deleted group (o15.0.1.14)
- - BAD Delete of IPoIB membership (no prev join) (o15.0.1.15)
-
-* GUIDInfo Record:
- - All GUIDInfoRecords in subnet are obtained
-
-* Event Forwarding: Register for trap forwarding using reports
- - Send a trap and wait for report
- - Unregister non-existing
-
-* Trap 64/65 Flow: Register to Trap 64-65, create traps (by
- disconnecting/connecting ports) and wait for report, then unregister.
-
-* Stress Test: send PortInfoRecord queries, both single and RMPP and
- check for the rate of responses as well as their validity.
-
-
-5.2 IB Management Simulator OpenSM Test Flows:
-
-The simulator provides ability to simulate the SM handling of virtual
-topologies that are not limited to actual lab equipment availability.
-OpenSM was simulated to bring up clusters of up to 10,000 nodes. Daily
-regressions use smaller (16 and 128 nodes clusters).
-
-The following test flows are run on the IB management simulator:
-
-* Stability:
- Up to 12 links from the fabric are randomly selected to drop packets
- at drop rates up to 90%. The SM is required to succeed in bringing the
- fabric up. The resulting routing is verified to be correct, too.
-
-* LID Manager:
- Using LMC = 2 the fabric is initialized with LIDs. Faults such as
- zero LID, Duplicated LID, non-aligned (to LMC) LIDs are
- randomly assigned to various nodes and other errors are randomly
- output to the guid2lid cache file. The SM sweep is run 5 times and
- after each iteration a complete verification is made to ensure that all
- LIDs that could possibly be maintained are kept, as well as that all nodes
- were assigned a legal LID range.
-
-* Multicast Routing:
- Nodes randomly join the 0xc000 group and eventually the
- resulting routing is verified for completeness and adherence to
- Up/Down routing rules.
-
-* osmtest:
- The complete osmtest flow as described in the previous table is run on
- the simulated fabrics.
-
-* Stress Test:
- This flow merges fabric, LID and stability issues with continuous
- PathRecord, ServiceRecord and Multicast Join/Leave activity to
- stress the SM/SA during continuous sweeps.
-
-5.3 OpenSM Regression
-
-Using a back-to-back or single switch connection, the following set of
-tests is run nightly on the stacks described in table 2. The included
-tests are:
-
-* Stress Testing: Flood the SA with queries from multiple channel
- adapters to check the robustness of the entire stack up to the SA.
-
-* Dynamic Changes: Dynamic Topology changes, through randomly
- dropping SMP packets, used to test OpenSM adaptation to an unstable
- network & verify DB correctness.
-
-* Trap Injection: This flow injects traps to the SM and verifies that it
- handles them gracefully.
-
-* SA Query Test: This test exhaustively checks the SA responses to all
- possible single component mask. To do that the test examines the
- entire set of records the SA can provide, classifies them by their
- field values and then selects every field (using component mask and a
- value) and verifies that the response matches the expected set of records.
- A random selection using multiple component mask bits is also performed.
-
-5.4 Cluster testing:
-
-Cluster testing is usually run before a distribution release. It
-involves real hardware setups of 16 to 32 nodes (or more if a beta site
-is available). Each test is validated by running all-to-all ping through the IB
-interface. The test procedure includes:
-
-* Cluster bringup
-
-* Hand-off between 2 or 3 SM's while performing
- - Node reboots
- - Switch power cycles (disconnecting the SM's)
-
-* Unresponsive port detection and recovery
-
-* osmtest from multiple nodes
-
-* Trap injection and recovery
-
-
-6 Qualification
-----------------
-
-Table 2 - Qualified IB Stacks
-=============================
-
-Stack | Version
------------------------------------------|--------------------------
-OFED | 1.0
-OpenIB Gen2 (IBG2 distribution) | 1.0
-OpenIB Gen1 (IBGD distribution) | 1.8.0
-VAPI (Mellanox InfiniBand HCA Driver) | 3.2 and later
-
-Table 3 - Qualified Devices and Corresponding Firmware
-======================================================
-
-Mellanox
-Device | FW versions
---------|-----------------------------------------------------------
-MT43132 | InfiniScale - fw-43132 5.2.0 (and later)
-MT47396 | InfiniScale III - fw-47396 0.5.0 (and later)
-MT23108 | InfiniHost - fw-23108 3.3.2
-MT25204 | InfiniHost III Lx - fw-25204 1.0.1
-MT25208 | InfiniHost III Ex (InfiniHost Mode) - fw-25208 4.6.2 (and later)
-MT25208 | InfiniHost III Ex (MemFree Mode) - fw-25218 5.0.1 (and later)
-
-QLogic/PathScale
-Device | Note
---------|-----------------------------------------------------------
-iPath | QHT6040 (PathScale InfiniPath HT-460)
-iPath | QHT6140 (PathScale InfiniPath HT-465)
-iPath | QLE6140 (PathScale InfiniPath PE-880)
-
-Note: OpenSM does not run on an IBM Galaxy (eHCA) as it does not expose
-QP0 and QP1. However, it does support it as a device on the subnet.
diff --git a/contrib/ofed/management/opensm/doc/opensm_release_notes_openib-2.0.5.txt b/contrib/ofed/management/opensm/doc/opensm_release_notes_openib-2.0.5.txt
deleted file mode 100644
index 51bd21c..0000000
--- a/contrib/ofed/management/opensm/doc/opensm_release_notes_openib-2.0.5.txt
+++ /dev/null
@@ -1,486 +0,0 @@
- OpenSM Release Notes 2.0.5
- ============================
-
-Version: OpenFabrics Enterprise Distribution (OFED) 1.1
-Repo: https://openib.org/svn/gen2/branches/1.1/src/userspace/management/osm
-Version: 9535 (openib-2.0.5)
-Date: October 2006
-
-1 Overview
-----------
-This document describes the contents of the OpenSM OFED 1.1 release.
-OpenSM is an InfiniBand compliant Subnet Manager and Administration,
-and runs on top of OpenIB. The OpenSM version for this release
-is openib-2.0.5
-
-This document includes the following sections:
-1 This Overview section (describing new features and software
- dependencies)
-2 Known Issues And Limitations
-3 Unsupported IB compliance statements
-4 Major Bug Fixes
-5 Main Verification Flows
-6 Qualified software stacks and devices
-
-1.1 Major New Features
-
-* Partition manager:
- The partition manager provides a means to setup multiple partitions
- by providing a partition policy file. For details please read the
- doc/partition-config.txt or the opensm man page.
-
-* Basic QoS Manager:
- Provides a uniform configuration of the entire fabric with values defined
- in the OpenSM options file. The options support different settings for
- CAs, Switches, and Routers. Note that this is disabled by default and
- using -Q enables QoS fabric setup.
-
-* Loading pre-routes from a file:
- A new routing module enables loading pre-routes from a file.
- To use this option you should use the command line options:
- "-R file --U <your routing file>" or
- "--routing_engine file --ucast_file <your routing file>"
- For more information refer to the file doc/modular-routing.txt
- or the opensm man page.
-
-* SA MultiPathRecord support:
- The SA can now handle requests for multiple PathRecords in one query.
- This includes methods SA GetMulti/GetMultiResp and dual sided RMPP.
-
-* PPC64 is now QAed and supported
-
-* Support LMC > 0 for Switch Enhanced Port 0:
- Allows enhanced switch port 0 (ESP0) to have a non zero
- LMC. Use the configured subnet wide LMC for this. Modifications were
- necessary to the LID assignment and routing to support this.
- Also, added an option to the configuration to use LMC configured for
- subnet for enhanced switch port 0 or set it to 0 even if a non zero
- LMC is configured for the subnet. The default is currently the
- latter option. The new configuration option is: lmc_esp0
-
-1.2 Minor New Features:
-
-* IPoIB broadcast group configuration:
- It is now possible to control the IPoIB broadcast group parameters
- (MTU, rate, SL) through the partitions configuration file.
-
-* Limiting OpenSM log file size:
- By providing the command line option: "-L <size in MB>" or
- "--log_limit <size in MB>" the user can limit the generated log
- file size. When specified, the log file will be truncated upon reaching
- this limit.
-
-* Favor 1K MTU for Tavor (MT23108) HCA
- In cases where a PathRecord or MultiPathRecord is queried and the
- requestor does not specify the MTU or does specify it in a way
- that allows for MTU to be 1K and one of the path ends in a Tavor,
- limit the MTU to 1K max.
-
-* Man pages:
- Added opensm.8 and osmtest.8
-
-* Leaf VL stall count control:
- A new parameter (leaf_vl_stall_count) for controlling the number of
- sequential packets dropped on a switch port driving a HCA/TCA/Router
- that cause the port to enter the VLStalled state was added to the
- options file.
-
-* SM Polling/Handover defaults changed
- The default SMInfo polling retries was decreased from 18 to 4
- which reduces the default handover time from 3 min to 40 seconds.
-
-1.3 Library API Changes
-
-* cl_mem* APIs deprecated in complib:
- These functions are now considered as deprecated and should be
- replaced by direct calls to malloc, free, memset, etc.
-
-* osm_log_init_v2 API added in libopensm:
- Supports providing the new option for log file truncation.
-
-1.4 Software Dependencies
-
-OpenSM depends on the installation of either OFED 1.1, OFED 1.0,
-OpenIB gen2 (e.g. IBG2 distribution), OpenIB gen1 (e.g. IBGD
-distribution), or Mellanox VAPI stacks. The qualified driver versions
-are provided in Table 2, "Qualified IB Stacks".
-
-1.5 Supported Devices Firmware
-
-The main task of OpenSM is to initialize InfiniBand devices. The
-qualified devices and their corresponding firmware versions
-are listed in Table 3.
-
-2 Known Issues And Limitations
-------------------------------
-
-* No Service / Key associations:
- There is no way to manage Service access by Keys.
-
-* No SM to SM SMDB synchronization:
- Puts the burden of re-registering services, multicast groups, and
- inform-info on the client application (or IB access layer core).
-
-* No "port down" event handling:
- Changing the switch port through which OpenSM connects to the IB
- fabric may cause incorrect operation. Please restart OpenSM whenever
- such a connectivity change is made.
-
-* Changing connections during SM operation:
- Under some conditions the SM can get confused by a change in
- cabling (moving a cable from one switch port to the other) and
- momentarily see this as having the same GUID appear connected
- to two different IB ports. Under some conditions, when the SM fails to
- get the corresponding change event it might mistakenly report this case
- as a "duplicated GUID" case and abort. It is advisable to double-check
- the syslog after each such change in connectivity and restart
- OpenSM if it has exited.
-
-3 Unsupported IB Compliance Statements
---------------------------------------
-The following section lists all the IB compliance statements which
-OpenSM does not support. Please refer to the IB specification for detailed
-information regarding each compliance statement.
-
-* C14-22 (Authentication):
- M_Key M_KeyProtectBits and M_KeyLeasePeriod shall be set in one
- SubnSet method. As a work-around, an OpenSM option is provided for
- defining the protect bits.
-
-* C14-67 (Authentication):
- On SubnGet(SMInfo) and SubnSet(SMInfo) - if M_Key is not zero then
- the SM shall generate a SubnGetResp if the M_Key matches, or
- silently drop the packet if M_Key does not match.
-
-* C15-0.1.23.4 (Authentication):
- InformInfoRecords shall always be provided with the QPN set to 0,
- except for the case of a trusted request, in which case the actual
- subscriber QPN shall be returned.
-
-* o13-17.1.2 (Event-FWD):
- If no permission to forward, the subscription should be removed and
- no further forwarding should occur.
-
-* C14-24.1.1.5 and C14-62.1.1.22 (Initialization):
- GUIDInfo - SM should enable assigning Port GUIDInfo.
-
-* C14-44 (Initialization):
- If the SM discovers that it is missing an M_Key to update CA/RT/SW,
- it should notify the higher level.
-
-* C14-62.1.1.12 (Initialization):
- PortInfo:M_Key - Set the M_Key to a node based random value.
-
-* C14-62.1.1.13 (Initialization):
- PortInfo:P_KeyProtectBits - set according to an optional policy.
-
-* C14-62.1.1.24 (Initialization):
- SwitchInfo:DefaultPort - should be configured for random FDB.
-
-* C14-62.1.1.32 (Initialization):
- RandomForwardingTable should be configured.
-
-* o15-0.1.12 (Multicast):
- If the JoinState is SendOnlyNonMember = 1 (only), then the endport
- should join as sender only.
-
-* o15-0.1.8 (Multicast):
- If a request for creating an MCG with fields that cannot be met,
- return ERR_REQ_INVALID (currently ignores SL and FlowLabelTClass).
-
-* C15-0.1.8.6 (SA-Query):
- Respond to SubnAdmGetTraceTable - this is an optional attribute.
-
-* C15-0.1.13 Services:
- Reject ServiceRecord create, modify or delete if the given
- ServiceP_Key does not match the one included in the ServiceGID port
- and the port that sent the request.
-
-* C15-0.1.14 (Services):
- Provide means to associate service name and ServiceKeys.
-
-4 Major Bug Fixes
------------------
-
-The following is a list of bugs that were fixed. Note that other less critical
-or visible bugs were also fixed.
-
-* "Broken" fabric (duplicated port GUIDs) handling improved
- Replace assert with a real check to handle invalid physical port
- in osm_node_info_rcv.c which could occur on a broken fabric
-
-* SA client synchronous request failed but status returned was IB_SUCCESS
- even if there was no response.
- There was a missing setting of the status in the synchronous case.
-
-* Memory leak fixes:
- 1. In libvendor/osm_vendor_ibumad.c:osm_vendor_get_all_port_attr
- 2. In libvendor/osm_vendor_ibumad_sa.c:__osmv_sa_mad_rcv_cb
- 3. On receiving SMInfo SA request from a node that does not share a
- partition, the response mad was allocated but never free'd
- as it was never sent.
-
-* Set(InformInfo) OpenSM Deadlock:
- When receiving a request with unknown LID
-
-* PathRecord to inconsistent multicast destination:
- Fix the return error when multicast destination is not consistently
- indicated.
-
-* Remove double calculation of reversible path
- In osm_sa_path_record.c:__osm_pr_rcv_get_lid_pair_path a PathRecord
- query used to double check if the path is reversible
-
-* Some PathRecord log messages use "net order":
- Fix GUID net to host conversion in some osm_log messages
-
-* DR/LID routed SMPs direction bit handling:
- osm_resp.c:osm_resp_make_resp_smp, set direction bit only if direct
- routed class. This bug caused two issues:
- 1. Get/Set responses always had direction bit set.
- 2. Trap represses never had direction bit set.
- The direction bit needs setting in direct routed responses and it
- doesn't exist in LID routed responses.
- osm_sm_mad_ctrl.c: did not detect the "direction bit" correctly.
-
-* OpenSM crash due to transaction lookup (interop with Cisco stack)
- When a wire TID that maps to internal TID of zero (after applying
- mask) was received the lookup of the transaction was successful.
- The stale transaction pointed to "free'd" memory.
-
-* Better handling for Path/MultiPath requests for raw traffic
-
-* Wrong ProducerType provided in Notice Reports:
- When formating an SM generated report, the ProducerType was using
- CL_NTOH32 which can not be used to format a 24bit network order number.
-
-* OpenSM break on PPC64
- complib: Fixed memory corruption in cl_pool.c:cl_qcpool_init. This
- affected big endian 64-bit architectures only.
-
-* Illegal Set(InformInfo) was wrongly successful in updating the SMDB
- osm_sa_informinfo.c: In osm_infr_rcv_process_set_method, if sending
- error, don't call osm_infr_rcv_process_set_method
-
-* RMPP queries of InformInfoRecord fail
- ib_types.h: Pad ib_inform_info_record_t to be modulo 8 in size so
- that attribute offset is calculated properly
-
-* Returning "invalid request" rather than "unsupported method/attribute"
- In these cases, a noncompliant response was being provided.
-
-* Noncompliant response for SubnAdmGet(PortInfoRecord) with no match
- osm_pir_rcv_process, now returns "SA no records error" for SubnAdmGet
- with 0 records found
-
-* Noncompliant non base LID returned by some queries:
- The following attributes used to return the request LID rather than
- its base LID in responses: PKeyTableRecord, GUIDInfoRecord,
- SLtoVLMappingTableRecord, VLArbitrationTableRecord, LinkRecord
-
-* Noncompliant SubnAdmGet and SubnAdmGetTable:
- Mixing of error codes in case of no records or multiple records
- fixed for the attributes:
- LinearForwardingTableRecord, GUIDInfoRecord,
- VLArbitrationTableRecord, LinkRecord, PathRecord
-
-* segfault in InformInfo flows
- Under stress concurrent Set/Delete/Get flows. Fixed by adding
- missing lock.
-
-* SA queries containing LID out if range did not return ERR_REQ_INVALID
-
-5 Main Verification Flows
--------------------------
-
-OpenSM verification is run using the following activities:
-* osmtest - a stand-alone program
-* ibmgtsim (IB management simulator) based - a set of flows that
- simulate clusters, inject errors and verify OpenSM capability to
- respond and bring up the network correctly.
-* small cluster regression testing - where the SM is used on back to
- back or single switch configurations. The regression includes
- multiple OpenSM dedicated tests.
-* cluster testing - when we run OpenSM to setup a large cluster, perform
- hand-off, reboots and reconnects, verify routing correctness and SA
- responsiveness at the ULP level (IPoIB and SDP).
-
-5.1 osmtest
-
-osmtest is an automated verification tool used for OpenSM
-testing. Its verification flows are described by list below.
-
-* Inventory File: Obtain and verify all port info, node info, link and path
- records parameters.
-
-* Service Record:
- - Register new service
- - Register another service (with a lease period)
- - Register another service (with service p_key set to zero)
- - Get all services by name
- - Delete the first service
- - Delete the third service
- - Added bad flows of get/delete non valid service
- - Add / Get same service with different data
- - Add / Get / Delete by different component mask values (services
- by Name & Key / Name & Data / Name & Id / Id only )
-
-* Multicast Member Record:
- - Query of existing Groups (IPoIB)
- - BAD Join with insufficient comp mask (o15.0.1.3)
- - Create given MGID=0 (o15.0.1.4)
- - Create given MGID=0xFF12A01C,FE800000,00000000,12345678 (o15.0.1.4)
- - Create BAD MGID=0xFA. (o15.0.1.6)
- - Create BAD MGID=0xFF12A01B w/ link-local not set (o15.0.1.6)
- - New MGID with invalid join state (o15.0.1.9)
- - Retry of existing MGID - See JoinState update (o15.0.1.11)
- - BAD RATE when connecting to existing MGID (o15.0.1.13)
- - Partial JoinState delete request - removing FullMember (o15.0.1.14)
- - Full Delete of a group (o15.0.1.14)
- - Verify Delete by trying to Join deleted group (o15.0.1.14)
- - BAD Delete of IPoIB membership (no prev join) (o15.0.1.15)
-
-* GUIDInfo Record:
- - All GUIDInfoRecords in subnet are obtained
-
-* MultiPathRecord:
- - Perform some compliant and noncompliant MultiPathRecord requests
- - Validation is via status in responses and IB analyzer
-
-* PKeyTableRecord:
- - Perform some compliant and noncompliant PKeyTableRecord queries
- - Validation is via status in responses and IB analyzer
-
-* LinearForwardingTableRecord:
- - Perform some compliant and noncompliant LinearForwardingTableRecord queries
- - Validation is via status in responses and IB analyzer
-
-* Event Forwarding: Register for trap forwarding using reports
- - Send a trap and wait for report
- - Unregister non-existing
-
-* Trap 64/65 Flow: Register to Trap 64-65, create traps (by
- disconnecting/connecting ports) and wait for report, then unregister.
-
-* Stress Test: send PortInfoRecord queries, both single and RMPP and
- check for the rate of responses as well as their validity.
-
-
-5.2 IB Management Simulator OpenSM Test Flows:
-
-The simulator provides ability to simulate the SM handling of virtual
-topologies that are not limited to actual lab equipment availability.
-OpenSM was simulated to bring up clusters of up to 10,000 nodes. Daily
-regressions use smaller (16 and 128 nodes clusters).
-
-The following test flows are run on the IB management simulator:
-
-* Stability:
- Up to 12 links from the fabric are randomly selected to drop packets
- at drop rates up to 90%. The SM is required to succeed in bringing the
- fabric up. The resulting routing is verified to be correct as well.
-
-* LID Manager:
- Using LMC = 2 the fabric is initialized with LIDs. Faults such as
- zero LID, Duplicated LID, non-aligned (to LMC) LIDs are
- randomly assigned to various nodes and other errors are randomly
- output to the guid2lid cache file. The SM sweep is run 5 times and
- after each iteration a complete verification is made to ensure that all
- LIDs that could possibly be maintained are kept, as well as that all nodes
- were assigned a legal LID range.
-
-* Multicast Routing:
- Nodes randomly join the 0xc000 group and eventually the
- resulting routing is verified for completeness and adherence to
- Up/Down routing rules.
-
-* osmtest:
- The complete osmtest flow as described in the previous table is run on
- the simulated fabrics.
-
-* Stress Test:
- This flow merges fabric, LID and stability issues with continuous
- PathRecord, ServiceRecord and Multicast Join/Leave activity to
- stress the SM/SA during continuous sweeps. InformInfo Set/Delete/Get
- were added to the test such both existing and non existing nodes
- perform them in random order.
-
-5.3 OpenSM Regression
-
-Using a back-to-back or single switch connection, the following set of
-tests is run nightly on the stacks described in table 2. The included
-tests are:
-
-* Stress Testing: Flood the SA with queries from multiple channel
- adapters to check the robustness of the entire stack up to the SA.
-
-* Dynamic Changes: Dynamic Topology changes, through randomly
- dropping SMP packets, used to test OpenSM adaptation to an unstable
- network & verify DB correctness.
-
-* Trap Injection: This flow injects traps to the SM and verifies that it
- handles them gracefully.
-
-* SA Query Test: This test exhaustively checks the SA responses to all
- possible single component mask. To do that the test examines the
- entire set of records the SA can provide, classifies them by their
- field values and then selects every field (using component mask and a
- value) and verifies that the response matches the expected set of records.
- A random selection using multiple component mask bits is also performed.
-
-5.4 Cluster testing:
-
-Cluster testing is usually run before a distribution release. It
-involves real hardware setups of 16 to 32 nodes (or more if a beta site
-is available). Each test is validated by running all-to-all ping through the IB
-interface. The test procedure includes:
-
-* Cluster bringup
-
-* Hand-off between 2 or 3 SM's while performing:
- - Node reboots
- - Switch power cycles (disconnecting the SM's)
-
-* Unresponsive port detection and recovery
-
-* osmtest from multiple nodes
-
-* Trap injection and recovery
-
-
-6 Qualification
-----------------
-
-Table 2 - Qualified IB Stacks
-=============================
-
-Stack | Version
------------------------------------------|--------------------------
-OFED | 1.1
-OFED | 1.0
-OpenIB Gen2 (IBG2 distribution) | 1.0
-OpenIB Gen1 (IBGD distribution) | 1.8.0
-VAPI (Mellanox InfiniBand HCA Driver) | 3.2 and later
-
-Table 3 - Qualified Devices and Corresponding Firmware
-======================================================
-
-Mellanox
-Device | FW versions
---------|-----------------------------------------------------------
-MT43132 | InfiniScale - fw-43132 5.2.0 (and later)
-MT47396 | InfiniScale III - fw-47396 0.5.0 (and later)
-MT23108 | InfiniHost - fw-23108 3.3.2 (and later)
-MT25204 | InfiniHost III Lx - fw-25204 1.0.1i (and later)
-MT25208 | InfiniHost III Ex (InfiniHost Mode) - fw-25208 4.6.2 (and later)
-MT25208 | InfiniHost III Ex (MemFree Mode) - fw-25218 5.0.1 (and later)
-
-QLogic/PathScale
-Device | Note
---------|-----------------------------------------------------------
-iPath | QHT6040 (PathScale InfiniPath HT-460)
-iPath | QHT6140 (PathScale InfiniPath HT-465)
-iPath | QLE6140 (PathScale InfiniPath PE-880)
-
-Note: OpenSM does not run on an IBM Galaxy (eHCA) as it does not expose
-QP0 and QP1. However, it does support it as a device on the subnet.
diff --git a/contrib/ofed/management/opensm/doc/opensm_release_notes_openib-3.0.13.txt b/contrib/ofed/management/opensm/doc/opensm_release_notes_openib-3.0.13.txt
deleted file mode 100644
index b48f148..0000000
--- a/contrib/ofed/management/opensm/doc/opensm_release_notes_openib-3.0.13.txt
+++ /dev/null
@@ -1,535 +0,0 @@
- OpenSM Release Notes 3.0.13
- =============================
-
-Version: OpenFabrics Enterprise Distribution (OFED) 1.2
-Repo: git://git.openfabrics.org/~ofed_1_2/management.git (release)
- git://git.openfabrics.org/~halr/management.git (development)
-Date: June 2007
-
-1 Overview
-----------
-This document describes the contents of the OpenSM OFED 1.2 release.
-OpenSM is an InfiniBand compliant Subnet Manager and Administration,
-and runs on top of OpenIB. The OpenSM version for this release
-is openib-3.0.13
-
-This document includes the following sections:
-1 This Overview section (describing new features and software
- dependencies)
-2 Known Issues And Limitations
-3 Unsupported IB compliance statements
-4 Major Bug Fixes
-5 Main Verification Flows
-6 Qualified software stacks and devices
-
-1.1 Major New Features
-
-* Routing improvements
- Two additional routing algorithms have been added in addition to
- performance improvements to the existing routing algorithms. The
- two new routing algorithms are FAT tree and LASH. See the
- opensm man page for additional details.
-
-* SA Optional Record support now "virtually" complete
- Includes SA InformInfo improvements and InformInfoRecord support in
- addition to support for the remaining SA optional records
- (MulticastForwardingTableRecord, SwitchInfoRecord). Also, SMInfoRecord
- support was improved to include all SMs found.
-
-* SA database dump/restore
- OpenSM now includes the ability to dump and restore the SA database.
- This allows for all SA registrations (multicast, services, and events)
- to be saved and restored later.
-
- In verbose mode, OpenSM will dump SA DB (existing multicast groups,
- services and InformInfo) into dump file which named "opensm-sa.dump"
- and located under standard OpenSM dump directory (/var/log by default).
-
- If option -S is specified and SA DB dump file name is provided, OpenSM
- will try to restore SA database from this file. And if restore is
- successful, OpenSM won't ask for client reregistration at subnet bring-up.
-
-* Modular routing for multicast
- In conjunction was SA database dump/restore, there is the ability to
- dump and load switch lid matrices (min hops tables) which are used
- for multicast route calculation.
-
-* IB router enablement
- OpenSM now supports router ports properly (in terms of PortInfo handling).
- There is also some experimental support for IB routers which is enabled
- via the ROUTER_EXP compile flag. This support includes SA PathRecord and
- MCMemberRecord support for off subnet GIDs.
-
-* Socket support added to console
- OpenSM console now supports remote in addition to local access.
- Remote access is currently via telnet.
-
-1.2 Minor New Features:
-
-* Change output format of DR path from hex to decimal port numbers
-
-* Log rotation
- The OpenSM log can now be rotated while OpenSM is running (without
- stopping and restarting OpenSM). This is accomplished via SIGUSR1.
-
-* Support scope for IPoIB multicast groups in partition config
-
-* Dump filename changed from subnet.lst to osm-subnet.lst
- Default temp directory for non Windows platforms was previously changed
- from /tmp to /var/log.
-
-* Add option for force SDR link speed
- Add option to opensm.opts to force link speed. Currently, only forcing
- to SDR link speed is supported. This option is not supported as a
- command line option.
-
-1.3 Library API Changes
-
- None
-
-1.4 Software Dependencies
-
-OpenSM depends on the installation of either OFED 1.2, OFED 1.1,
-OFED 1.0, OpenIB gen2 (e.g. IBG2 distribution), OpenIB gen1 (e.g. IBGD
-distribution), or Mellanox VAPI stacks. The qualified driver versions
-are provided in Table 2, "Qualified IB Stacks".
-
-1.5 Supported Devices Firmware
-
-The main task of OpenSM is to initialize InfiniBand devices. The
-qualified devices and their corresponding firmware versions
-are listed in Table 3.
-
-2 Known Issues And Limitations
-------------------------------
-
-* No Service / Key associations:
- There is no way to manage Service access by Keys.
-
-* No SM to SM SMDB synchronization:
- Puts the burden of re-registering services, multicast groups, and
- inform-info on the client application (or IB access layer core).
-
-* No "port down" event handling:
- Changing the switch port through which OpenSM connects to the IB
- fabric may cause incorrect operation. Please restart OpenSM whenever
- such a connectivity change is made.
-
-* Changing connections during SM operation:
- Under some conditions the SM can get confused by a change in
- cabling (moving a cable from one switch port to the other) and
- momentarily see this as having the same GUID appear connected
- to two different IB ports. Under some conditions, when the SM fails to
- get the corresponding change event it might mistakenly report this case
- as a "duplicated GUID" case and abort. It is advisable to double-check
- the syslog after each such change in connectivity and restart
- OpenSM if it has exited. The same error ("duplicated GUID") will
- also appear with a loopback plug.
-
-3 Unsupported IB Compliance Statements
---------------------------------------
-The following section lists all the IB compliance statements which
-OpenSM does not support. Please refer to the IB specification for detailed
-information regarding each compliance statement.
-
-* C14-22 (Authentication):
- M_Key M_KeyProtectBits and M_KeyLeasePeriod shall be set in one
- SubnSet method. As a work-around, an OpenSM option is provided for
- defining the protect bits.
-
-* C14-67 (Authentication):
- On SubnGet(SMInfo) and SubnSet(SMInfo) - if M_Key is not zero then
- the SM shall generate a SubnGetResp if the M_Key matches, or
- silently drop the packet if M_Key does not match.
-
-* C15-0.1.23.4 (Authentication):
- InformInfoRecords shall always be provided with the QPN set to 0,
- except for the case of a trusted request, in which case the actual
- subscriber QPN shall be returned.
-
-* o13-17.1.2 (Event-FWD):
- If no permission to forward, the subscription should be removed and
- no further forwarding should occur.
-
-* C14-24.1.1.5 and C14-62.1.1.22 (Initialization):
- GUIDInfo - SM should enable assigning Port GUIDInfo.
-
-* C14-44 (Initialization):
- If the SM discovers that it is missing an M_Key to update CA/RT/SW,
- it should notify the higher level.
-
-* C14-62.1.1.12 (Initialization):
- PortInfo:M_Key - Set the M_Key to a node based random value.
-
-* C14-62.1.1.13 (Initialization):
- PortInfo:P_KeyProtectBits - set according to an optional policy.
-
-* C14-62.1.1.24 (Initialization):
- SwitchInfo:DefaultPort - should be configured for random FDB.
-
-* C14-62.1.1.32 (Initialization):
- RandomForwardingTable should be configured.
-
-* o15-0.1.12 (Multicast):
- If the JoinState is SendOnlyNonMember = 1 (only), then the endport
- should join as sender only.
-
-* o15-0.1.8 (Multicast):
- If a request for creating an MCG with fields that cannot be met,
- return ERR_REQ_INVALID (currently ignores SL and FlowLabelTClass).
-
-* C15-0.1.8.6 (SA-Query):
- Respond to SubnAdmGetTraceTable - this is an optional attribute.
-
-* C15-0.1.13 Services:
- Reject ServiceRecord create, modify or delete if the given
- ServiceP_Key does not match the one included in the ServiceGID port
- and the port that sent the request.
-
-* C15-0.1.14 (Services):
- Provide means to associate service name and ServiceKeys.
-
-4 Major Bug Fixes
------------------
-
-The following is a list of bugs that were fixed. Note that other less critical
-or visible bugs were also fixed.
-
-* osm_sminfo_rcv.c: Add SMInfo self query check. OpenSM can query
- itself for SMInfo occassionally due to port moving during subnet
- discovery process. Don't create remote SM entry in this case to
- prevent deadlocks.
-
-* osm_ucast_updn.c: Two similar bugs in up/down routing fixed.
- 8-bit integers were used as indexes when scanning subnet, which
- in one case caused OpenSM to crash when ranking "path" is longer
- than 256 switches, and in the other case, caused OpenSM to go into
- an infinite loop when fabric has more than 256 roots.
-
-* osm_sm_state_mgr.c: In __osm_sm_state_mgr_send_master_sm_info_req,
- handle master GUID port not found properly
-
-* osm_sa_multipath_record.c: In __osm_mpr_rcv_get_path_parms, return
- IB_NOT_FOUND rather than IB_ERROR when can't route to LID from switch
-
-* osm_sa_path_record.c: In __osm_pr_rcv_get_path_parms, return IB_NOT_FOUND
- rather than IB_ERROR when can't route to LID from switch
-
-* osm_vendor_ibumad.c: In osm_vendor_set_sm, set issmfd to
- -1 on open error
-
-* osm_vendor_ibumad: Termination crash fix
- When OpenSM is terminated umad_receiver thread still running even after
- the structures are destroyed and freed, this causes to random (but easily
- reproducible) crashes. The reason is that osm_vendor_delete() does not
- care about thread termination. This patch adds the receiver thread
- cancellation (by using pthread_cancel() and pthread_join()) and cares to
- keep have all mutexes unlocked upon termination. There is also minor
- termination code consolidation - osm_vendor_port_close() function.
-
-* osm_port_profile.h: Fix reinsertion issue in osm_port_prof_set_ignored_port
-
-* osm_matrix.h: Fix segfault with up/down and root nodes file
-
-* osm_sa_path_record.c: In osm_pr_rcv_process, fix endian of hop_limit
-
-* osm_vendor_ibumad.c: Close umad port in osm_vendor_delete
-
-* osm_sa_(multipath path)_record.c: Fix MultiPathRecord/PathRecord issues
- with using MTU/rate/PktLife explicitly ignoring selectors
-
- OpenSM just uses the resulting path MTU/rate/pkt-life and fail the
- query even though the selector might be allowing for selecting an
- appropriate value.
-
- After this fix, the following results are obtained for a case of
- path allowing maximal 2K MTU.
-
-In standard mode:
-------------------------------------------------------------
-MTU greater than ... 256 (0x01) -> equal to ....... 2K
-MTU less than ...... 256 (0x41) -> NO PATHS
-MTU equal to ....... 256 (0x81) -> equal to ....... 256
-MTU largest possible 256 (0xc1) -> equal to ....... 2K
-MTU greater than ... 512 (0x02) -> equal to ....... 2K
-MTU less than ...... 512 (0x42) -> equal to ....... 256
-MTU equal to ....... 512 (0x82) -> equal to ....... 512
-MTU largest possible 512 (0xc2) -> equal to ....... 2K
-MTU greater than ... 1K (0x03) -> equal to ....... 2K
-MTU less than ...... 1K (0x43) -> equal to ....... 512
-MTU equal to ....... 1K (0x83) -> equal to ....... 1K
-MTU largest possible 1K (0xc3) -> equal to ....... 2K
-MTU greater than ... 2K (0x04) -> NO PATHS
-MTU less than ...... 2K (0x44) -> equal to ....... 1K
-MTU equal to ....... 2K (0x84) -> equal to ....... 2K
-MTU largest possible 2K (0xc4) -> equal to ....... 2K
-MTU greater than ... 4K (0x05) -> NO PATHS
-MTU less than ...... 4K (0x45) -> equal to ....... 2K
-MTU equal to ....... 4K (0x85) -> NO PATHS
-MTU largest possible 4K (0xc5) -> equal to ....... 2K
-============================================================
-
-With enable_quirks (when one of the ends is a Tavor device):
-------------------------------------------------------------
-MTU greater than ... 256 (0x01) -> equal to ....... 1K
-MTU less than ...... 256 (0x41) -> NO PATHS
-MTU equal to ....... 256 (0x81) -> equal to ....... 256
-MTU largest possible 256 (0xc1) -> equal to ....... 2K
-MTU greater than ... 512 (0x02) -> equal to ....... 1K
-MTU less than ...... 512 (0x42) -> equal to ....... 256
-MTU equal to ....... 512 (0x82) -> equal to ....... 512
-MTU largest possible 512 (0xc2) -> equal to ....... 2K
-MTU greater than ... 1K (0x03) -> NO PATHS
-MTU less than ...... 1K (0x43) -> equal to ....... 512
-MTU equal to ....... 1K (0x83) -> equal to ....... 1K
-MTU largest possible 1K (0xc3) -> equal to ....... 2K
-MTU greater than ... 2K (0x04) -> NO PATHS
-MTU less than ...... 2K (0x44) -> equal to ....... 1K
-MTU equal to ....... 2K (0x84) -> equal to ....... 2K
-MTU largest possible 2K (0xc4) -> equal to ....... 2K
-MTU greater than ... 4K (0x05) -> NO PATHS
-MTU less than ...... 4K (0x45) -> equal to ....... 1K
-MTU equal to ....... 4K (0x85) -> NO PATHS
-MTU largest possible 4K (0xc5) -> equal to ....... 2K
-============================================================
-
-* osm_pkey_rcv.c: rwlock double release fix
- When the port is removed from subnet, but previously requested pkey
- table block is received after this - the lock will be released twice.
- This leads to deadlocks later when other MAD processor will try to
- acquire the same lock.
-
-* osm_sa_informinfo.c: Fix InformInfoRecord searches
-
-* Better SA MCMemberRecord leave locking
- Hold locked multicast group leave request (MCMember Record) processing.
- This prevents kind of race with multicast group join request where
- those requests can be reordered during processing.
-
-* osm_sa_informinfo.c: Conformance changes for subscribe component
-
-* osm_sa_path_record.c: Handle LID 0 as error
-
-* Fix comparing InformInfo records
- 1. The received InformInfo struct was modified before dumping it.
- 2. The function that compares InformInfo structures was just
- comparing the whole memory allocated for it, including reserved
- fields. Fixed to compare more selectively.
-
- As for QPN, from the IB spec, table 119 InformInfo:
- QPN : Ignored except when subscribe=0 (an unsubscribe
- request). Queue pair to which Report()s were sent as
- a result of a corresponding subscription. If no
- subscription for this Report() with this QPN exists,
- the request to unsubscribe performs no action and
- produces GetResp() with status indicating an invalid
- field value.
-
-* osm_trap_rcv.c: Reduce repeated trap messages so log doesn't fill
- so quickly
-
-* osm_helper.c: Fix stack smashing detected problem in osm_dump_service_record
-
-* Fix permission on db files directory
- When creating directory for db files (guid2lid) storing create it with
- reasonable permissions (current 777 decimal = octal 01411) and don't do
- it world writable.
-
-* Fix node_desc.description as string usages
-
-5 Main Verification Flows
--------------------------
-
-OpenSM verification is run using the following activities:
-* osmtest - a stand-alone program
-* ibmgtsim (IB management simulator) based - a set of flows that
- simulate clusters, inject errors and verify OpenSM capability to
- respond and bring up the network correctly.
-* small cluster regression testing - where the SM is used on back to
- back or single switch configurations. The regression includes
- multiple OpenSM dedicated tests.
-* cluster testing - when we run OpenSM to setup a large cluster, perform
- hand-off, reboots and reconnects, verify routing correctness and SA
- responsiveness at the ULP level (IPoIB and SDP).
-
-5.1 osmtest
-
-osmtest is an automated verification tool used for OpenSM
-testing. Its verification flows are described by list below.
-
-* Inventory File: Obtain and verify all port info, node info, link and path
- records parameters.
-
-* Service Record:
- - Register new service
- - Register another service (with a lease period)
- - Register another service (with service p_key set to zero)
- - Get all services by name
- - Delete the first service
- - Delete the third service
- - Added bad flows of get/delete non valid service
- - Add / Get same service with different data
- - Add / Get / Delete by different component mask values (services
- by Name & Key / Name & Data / Name & Id / Id only )
-
-* Multicast Member Record:
- - Query of existing Groups (IPoIB)
- - BAD Join with insufficient comp mask (o15.0.1.3)
- - Create given MGID=0 (o15.0.1.4)
- - Create given MGID=0xFF12A01C,FE800000,00000000,12345678 (o15.0.1.4)
- - Create BAD MGID=0xFA. (o15.0.1.6)
- - Create BAD MGID=0xFF12A01B w/ link-local not set (o15.0.1.6)
- - New MGID with invalid join state (o15.0.1.9)
- - Retry of existing MGID - See JoinState update (o15.0.1.11)
- - BAD RATE when connecting to existing MGID (o15.0.1.13)
- - Partial JoinState delete request - removing FullMember (o15.0.1.14)
- - Full Delete of a group (o15.0.1.14)
- - Verify Delete by trying to Join deleted group (o15.0.1.14)
- - BAD Delete of IPoIB membership (no prev join) (o15.0.1.15)
-
-* GUIDInfo Record:
- - All GUIDInfoRecords in subnet are obtained
-
-* MultiPathRecord:
- - Perform some compliant and noncompliant MultiPathRecord requests
- - Validation is via status in responses and IB analyzer
-
-* PKeyTableRecord:
- - Perform some compliant and noncompliant PKeyTableRecord queries
- - Validation is via status in responses and IB analyzer
-
-* LinearForwardingTableRecord:
- - Perform some compliant and noncompliant LinearForwardingTableRecord queries
- - Validation is via status in responses and IB analyzer
-
-* Event Forwarding: Register for trap forwarding using reports
- - Send a trap and wait for report
- - Unregister non-existing
-
-* Trap 64/65 Flow: Register to Trap 64-65, create traps (by
- disconnecting/connecting ports) and wait for report, then unregister.
-
-* Stress Test: send PortInfoRecord queries, both single and RMPP and
- check for the rate of responses as well as their validity.
-
-
-5.2 IB Management Simulator OpenSM Test Flows:
-
-The simulator provides ability to simulate the SM handling of virtual
-topologies that are not limited to actual lab equipment availability.
-OpenSM was simulated to bring up clusters of up to 10,000 nodes. Daily
-regressions use smaller (16 and 128 nodes clusters).
-
-The following test flows are run on the IB management simulator:
-
-* Stability:
- Up to 12 links from the fabric are randomly selected to drop packets
- at drop rates up to 90%. The SM is required to succeed in bringing the
- fabric up. The resulting routing is verified to be correct as well.
-
-* LID Manager:
- Using LMC = 2 the fabric is initialized with LIDs. Faults such as
- zero LID, Duplicated LID, non-aligned (to LMC) LIDs are
- randomly assigned to various nodes and other errors are randomly
- output to the guid2lid cache file. The SM sweep is run 5 times and
- after each iteration a complete verification is made to ensure that all
- LIDs that could possibly be maintained are kept, as well as that all nodes
- were assigned a legal LID range.
-
-* Multicast Routing:
- Nodes randomly join the 0xc000 group and eventually the
- resulting routing is verified for completeness and adherence to
- Up/Down routing rules.
-
-* osmtest:
- The complete osmtest flow as described in the previous table is run on
- the simulated fabrics.
-
-* Stress Test:
- This flow merges fabric, LID and stability issues with continuous
- PathRecord, ServiceRecord and Multicast Join/Leave activity to
- stress the SM/SA during continuous sweeps. InformInfo Set/Delete/Get
- were added to the test such both existing and non existing nodes
- perform them in random order.
-
-5.3 OpenSM Regression
-
-Using a back-to-back or single switch connection, the following set of
-tests is run nightly on the stacks described in table 2. The included
-tests are:
-
-* Stress Testing: Flood the SA with queries from multiple channel
- adapters to check the robustness of the entire stack up to the SA.
-
-* Dynamic Changes: Dynamic Topology changes, through randomly
- dropping SMP packets, used to test OpenSM adaptation to an unstable
- network & verify DB correctness.
-
-* Trap Injection: This flow injects traps to the SM and verifies that it
- handles them gracefully.
-
-* SA Query Test: This test exhaustively checks the SA responses to all
- possible single component mask. To do that the test examines the
- entire set of records the SA can provide, classifies them by their
- field values and then selects every field (using component mask and a
- value) and verifies that the response matches the expected set of records.
- A random selection using multiple component mask bits is also performed.
-
-5.4 Cluster testing:
-
-Cluster testing is usually run before a distribution release. It
-involves real hardware setups of 16 to 32 nodes (or more if a beta site
-is available). Each test is validated by running all-to-all ping through the IB
-interface. The test procedure includes:
-
-* Cluster bringup
-
-* Hand-off between 2 or 3 SM's while performing:
- - Node reboots
- - Switch power cycles (disconnecting the SM's)
-
-* Unresponsive port detection and recovery
-
-* osmtest from multiple nodes
-
-* Trap injection and recovery
-
-
-6 Qualification
-----------------
-
-Table 2 - Qualified IB Stacks
-=============================
-
-Stack | Version
------------------------------------------|--------------------------
-OFED | 1.2
-OFED | 1.1
-OFED | 1.0
-OpenIB Gen2 (IBG2 distribution) | 1.0
-OpenIB Gen1 (IBGD distribution) | 1.8.0
-VAPI (Mellanox InfiniBand HCA Driver) | 3.2 and later
-
-Table 3 - Qualified Devices and Corresponding Firmware
-======================================================
-
-Mellanox
-Device | FW versions
---------|-----------------------------------------------------------
-MT43132 | InfiniScale - fw-43132 5.2.0 (and later)
-MT47396 | InfiniScale III - fw-47396 0.5.0 (and later)
-MT23108 | InfiniHost - fw-23108 3.3.2 (and later)
-MT25204 | InfiniHost III Lx - fw-25204 1.0.1i (and later)
-MT25208 | InfiniHost III Ex (InfiniHost Mode) - fw-25208 4.6.2 (and later)
-MT25208 | InfiniHost III Ex (MemFree Mode) - fw-25218 5.0.1 (and later)
-
-QLogic/PathScale
-Device | Note
---------|-----------------------------------------------------------
-iPath | QHT6040 (PathScale InfiniPath HT-460)
-iPath | QHT6140 (PathScale InfiniPath HT-465)
-iPath | QLE6140 (PathScale InfiniPath PE-880)
-
-Note: OpenSM does not run on an IBM Galaxy (eHCA) as it does not expose
-QP0 and QP1. However, it does support it as a device on the subnet.
-
diff --git a/contrib/ofed/management/opensm/doc/partition-config.txt b/contrib/ofed/management/opensm/doc/partition-config.txt
deleted file mode 100644
index 602cc66..0000000
--- a/contrib/ofed/management/opensm/doc/partition-config.txt
+++ /dev/null
@@ -1,110 +0,0 @@
-OpenSM Partition configuration
-===============================
-
-The default name of OpenSM partitions configuration file is
-'/etc/opensm/partitions.conf'. The default may be changed by
-using --Pconfig (-P) option with OpenSM.
-
-The default partition will be created by OpenSM unconditionally even
-when partition configuration file does not exist or cannot be accessed.
-
-The default partition has P_Key value 0x7fff. OpenSM's port will have
-full membership in default partition. All other end ports will have
-partial membership.
-
-
-File Format
-===========
-
-Comments:
---------
-
-Line content followed after '#' character is comment and ignored by
-parser.
-
-
-General file format:
--------------------
-
-<Partition Definition>:<PortGUIDs list> ;
-
-
-Partition Definition:
---------------------
-
-[PartitionName][=PKey][,flag[=value]]
-
-PartitionName - string, to be used with logging. When omitted
- empty string will be used.
-PKey - P_Key value for this partition. Only low 15 bits will
- be used. When omitted will be autogenerated.
-flag - used to indicate IPoIB capability of this partition.
-
-Currently recognized flags are:
-
-ipoib - indicates that this partition may be used for IPoIB, as
- result IPoIB capable MC group will be created.
-rate=<val> - specifies rate for this IPoIB MC group (default is 3 (10GBps))
-mtu=<val> - specifies MTU for this IPoIB MC group (default is 4 (2048))
-sl=<val> - specifies SL for this IPoIB MC group (default is 0)
-scope=<val> - specifies scope for this IPoIB MC group (default is 2 (link
-local))
-
-Note that values for 'rate', 'mtu'. and 'scope' should be specified as defined
-in the IBTA specification (for example mtu=4 for 2048).
-
-
-PortGUIDs list:
---------------
-
-[PortGUID[=full|=limited]] [,PortGUID[=full|=limited]] [,PortGUID] ...
-
-PortGUID - GUID of partition member EndPort. Hexadecimal numbers
- should start from 0x, decimal numbers are accepted too.
-full or - indicates full or limited membership for this port. When
- limited omitted (or unrecognized) limited membership is assumed.
-
-There are two useful keywords for PortGUID definition:
-
-- 'ALL' means all end ports in this subnet.
-- 'SELF' means subnet manager's port.
-
-Empty list means no ports in this partition.
-
-
-Notes:
------
-
-White spaces are permitted between delimiters ('=', ',',':',';').
-
-The Line can be wrapped after ':' followed after Partition Definition and
-between.
-
-PartitionName does not need to be unique, PKey does need to be unique.
-If PKey is repeated then those partition configurations will be merged
-and first PartitionName will be used (see also next note).
-
-It is possible to split partition configuration in more than one
-definition, but then PKey should be explicitly specified (otherwise
-different PKey values will be generated for those definitions).
-
-
-Examples:
---------
-
-Default=0x7fff : ALL, SELF=full ;
-
-NewPartition , ipoib : 0x123456=full, 0x3456789034=limi, 0x2134af2306 ;
-
-YetAnotherOne = 0x300 : SELF=full ;
-YetAnotherOne = 0x300 : ALL=limited ;
-
-
-Note:
-----
-
-The following rule is equivalent to how OpenSM used to run prior to the
-partition manager:
-
-Default=0x7fff,ipoib:ALL=full;
-
diff --git a/contrib/ofed/management/opensm/doc/perf-manager-arch.txt b/contrib/ofed/management/opensm/doc/perf-manager-arch.txt
deleted file mode 100644
index f908ccf..0000000
--- a/contrib/ofed/management/opensm/doc/perf-manager-arch.txt
+++ /dev/null
@@ -1,181 +0,0 @@
-Performance Manager
-2/12/07
-
-This document will describe an architecture and a phased plan
-for an OpenFabrics OpenIB performance manager.
-
-Currently, there is no open source performance manager, only
-a perfquery diagnostic tool which some have scripted into a
-"poor man's" performance manager.
-
-The primary responsibilities of the performance manager are to:
-1. Monitor subnet topology
-2. Based on subnet topology, monitor performance and error counters.
- Also, possible counters related to congestion.
-3. Perform data reduction (various calculations (rates, histograms, etc.))
- on counters obtained
-4. Log performance data and indicate "interesting" related events
-
-
-Performance Manager Components
-1. Determine subnet topology
- Performance manager can determine the subnet topology by subscribing
- for GID in and out of service events. Upon receipt of a GID in service
- event, use GID to query SA for corresponding LID by using SubnAdmGet
- NodeRecord with PortGUID specified. It would utilize the LID and NumPorts
- returned and add this to the monitoring list. Note that the monitoring
- list can be extended to be distributed with the manager "balancing" the
- assignments of new GIDs to the set of known monitors. For GID out of
- service events, the GID is removed from the monitoring list.
-
-2. Monitoring
- Counters to be monitored include performance counters (data octets and
- packets both receive and transmit) and error counters. These are all in
- the mandatory PortCounters attribute. Future support will include the
- optional 64 bit counters, PortExtendedCounters (as this is only known
- to be supported on one IB device currently). Also, one congestion
- counter (PortXmitWait) will also be monitored (on switch ports) initially.
-
- Polling rather than sampling will be used as the monitoring technique. The
- polling rate configurable from 1-65535 seconds (default TBD)
- Note that with 32 bit counters, on 4x SDR links, byte counts can max out in
- 16 seconds and on 4x DDR links in 8 seconds. The polling rate needs to
- deal with this is accurate byte and packet rates are desired. Since IB
- counters are sticky, the counters need to be reset when they get "close"
- to max'ing out. This will result in some inaccuracy. When counters are
- reset, the time of the reset will be tracked in the monitor and will be
- queryable. Note that when the 64 bit counters are supported more generally,
- the polling rate can be reduced.
-
- The performance manager will support parallel queries. The level of
- parallelism is configurable with a default of 64 queries outstanding
- at one time.
-
- Configuration and dynamic adjustment of any performance manager "knobs"
- will be supported.
-
- Also, there will be a console interface to obtain performance data.
- It will be able to reset counters, report on specific nodes or
- node types of interest (CAs only, switches only, all, ...). The
- specifics are TBD.
-
-3. Data Reduction
- For errors, rate rather than raw value will be calculated. Error
- event is only indicated when rate exceeds a threshold.
- For packet and byte counters, small changes will be aggregated
- and only significant changes are updated.
- Aggregated histograms (per node, all nodes (this is TBD))) for each
- counter will be provided. Actual counters will also be written to files.
- NodeGUID will be used to identify node. File formats are TBD. One
- format to be supported might be CSV.
-
-4. Logging
- "Interesting" events determined by the performance manager will be
- logged as well as the performance data itself. Significant events
- will be logged to syslog. There are some interesting scalability
- issues relative to logging especially for the distributed model.
-
- Events will be based on rates which are configured as thresholds.
- There will be configurable thresholds for the error counters with
- reasonable defaults. Correlation of PerfManager and SM events is
- interesting but not a mandatory requirement.
-
-
-Performance Manager Scalability
-Clearly as the polling rate goes up, the number of nodes which can be
-monitored from a single performance management node decreases. There is
-some evidence that a single dedicated management node may not be able to
-monitor the largest clusters at a rapid rate.
-
-There are numerous PerfManager models which can be supported:
-1. Integrated as thread(s) with OpenSM (run only when SM is master)
-2. Standby SM
-3. Standalone PerfManager (not running with master or standby SM)
-4. Distributed PerfManager (most scalable approach)
-
-Note that these models are in order of implementation complexity and
-hence "schedule".
-
-The simplest model is to run the PerfManager with the master SM. This has
-the least scalability but is the simplest model. Note that in this model
-the topology can be obtained without the GID in and out of service events
-but this is needed for any of the other models to be supported.
-
-The next model is to run the PerfManager with a standby SM. Standbys are not
-doing much currently (polling the master) so there is much idle CPU.
-The downside of this approach is that if the standby takes over as master,
-the PerfManager would need to be moved (or is becomes model 1).
-
-A totally separate standlone PerfManager would allow for a deployment
-model which eliminates the downside of model 2 (standby SM). It could
-still be built in a similar manner with model 2 with unneeded functions
-(SM and SA) not included. The advantage of this model is that it could
-be more readily usable with a vendor specific SM (switch based or otherwise).
-Vendor specific SMs usually come with a built-in performance manager and
-this assumes that there would be a way to disable that performance manager.
-Model 2 can act like model 3 if a disable SM feature is supported in OpenSM
-(command line/console). This will take the SM to not active.
-
-The most scalable model is a distributed PerfManager. One approach to
-distribution is a hierarchial model where there is a PerfManager at the
-top level with a number of PerfMonitors which are responsible for some
-portion of the subnet.
-
-The separation of PerfManager from OpenSM brings up the following additional
-issues:
-1. What communication is needed between OpenSM and the PerfManager ?
-2. Integration of interesting events with OpenSM log
-(Does performance manager assume OpenSM ? Does it need to work with vendor
-SMs ?)
-
-Hierarchial distribution brings up some additional issues:
-1. How is the hierarchy determined ?
-2. How do the PerfManager and PerfMonitors find each other ?
-3. How is the subnet divided amongst the PerfMonitors
-4. Communication amongst the PerfManager and the PerfMonitors
-(including communication failures)
-
-In terms of inter manager communication, there seem to be several
-choices:
-1. Use vendor specific MADs (which can be RMPP'd) and build on top of
-this
-2. Use RC QP communication and build on top of this
-3. Use IPoIB which is much more powerful as sockets can then be utilized
-
-RC QP communication improves on the lower performance of the vendor
-specific MAD approach but is not as powerful as the socket based approach.
-
-The only downside of IPoIB is that it requires multicast to be functioning.
-It seems reasonable to require IPoIB across the management nodes. This
-can either be a separate IPoIB subnet or a shared one with other endnodes
-on the subnet. (If this communication is built on top of sockets, it
-can be any IP subnet amongst the manager nodes).
-
-The first implementation phase will address models 1-3. Model 3 is optional
-as it is similar to models 1 and 2 and may be not be needed.
-
-Model 4 will be addressed in a subsequent implementation phase (and a future
-version of this document). Model 4 can be built on the basis of models 1 and
-2 where some SM, not necessarily master, is the PerfManager and the rest are
-PerfMonitors.
-
-
-Performance Manager Partition Membership
-Note that as the performance manager needs to talk via GSI to the PMAs
-in all the end nodes and GSI utilizes PKey sharing, partition membership
-if invoked must account for this.
-
-The most straightforward deployment of the performance manager is
-to have it be a member of the full default partition (P_Key 0xFFFF).
-
-
-Performance Manager Redundancy
-TBD (future version of this document)
-
-
-Congestion Management
-TBD (future version of this document)
-
-
-QoS Management
-TBD (future version of this document)
diff --git a/contrib/ofed/management/opensm/doc/performance-manager-HOWTO.txt b/contrib/ofed/management/opensm/doc/performance-manager-HOWTO.txt
deleted file mode 100644
index 0b35e5f..0000000
--- a/contrib/ofed/management/opensm/doc/performance-manager-HOWTO.txt
+++ /dev/null
@@ -1,153 +0,0 @@
-OpenSM Performance manager HOWTO
-================================
-
-Introduction
-============
-
-OpenSM now includes a performance manager which collects Port counters from
-the subnet and stores them internally in OpenSM.
-
-Some of the features of the performance manager are:
-
- 1) Collect port data and error counters per v1.2 spec and store in
- 64bit internal counts.
- 2) Automatic reset of counters when they reach approximatly 3/4 full.
- (While not guarenteeing that counts will not be missed this does
- keep counts incrementing as best as possible given the current
- hardware limitations.)
- 3) Basic warnings in the OpenSM log on "critical" errors like symbol
- errors.
- 4) Automatically detects "outside" resets of counters and adjusts to
- continue collecting data.
- 5) Can be run when OpenSM is in standby or inactive states.
-
-Known issues are:
-
- 1) Data counters will be lost on high data rate links. Sweeping the
- fabric fast enough for a DDR link is not practical.
- 2) Default partition support only.
-
-
-Setup and Usage
-===============
-
-Using the Performance Manager consists of 3 steps:
-
- 1) compiling in support for the perfmgr (Optionally: the console
- socket as well)
- 2) enabling the perfmgr and console in opensm.conf
- 3) retrieving data which has been collected.
- 3a) using console to "dump data"
- 3b) using a plugin module to store the data to your own
- "database"
-
-Step 1: Compile in support for the Performance Manager
-------------------------------------------------------
-
-Because of the performance manager's experimental status, it is not enabled at
-compile time by default. (This will hopefully soon change as more people use
-it and confirm that it does not break things... ;-) The configure option is
-"--enable-perf-mgr".
-
-At this time it is really best to enable the console socket option as well.
-OpenSM can be run in an "interactive" mode. But with the console socket option
-turned on one can also make a connection to a running OpenSM. The console
-option is "--enable-console-socket". This option requires the use of
-tcp_wrappers to ensure security. Please be aware of your configuration for
-tcp_wrappers as the commands presented in the console can affect the operation
-of your subnet.
-
-The following configure line includes turning on the performance manager as
-well as the console:
-
- ./configure --enable-perf-mgr --enable-console-socket
-
-
-Step 2: Enable the perfmgr and console in opensm.conf
------------------------------------------------------
-
-Turning the Perfmorance Manager on is pretty easy, set the following options in
-the opensm.conf config file. (Default location is
-/usr/local/etc/opensm/opensm.conf)
-
- # Turn it all on.
- perfmgr TRUE
-
- # sweep time in seconds
- perfmgr_sweep_time_s 180
-
- # Dump file to dump the events to
- event_db_dump_file /var/log/opensm_port_counters.log
-
-Also enable the console socket and configure the port for it to listen to if
-desired.
-
- # console [off|local|socket]
- console socket
-
- # Telnet port for console (default 10000)
- console_port 10000
-
-As noted above you also need to set up tcp_wrappers to prevent unauthorized
-users from connecting to the console.[*]
-
- [*] As an alternate you can use the loopback mode but I noticed when
- writing this (OpenSM v3.1.10; OFED 1.3) that there are some bugs in
- specifying the loopback mode in the opensm.conf file. Look for this to
- be fixed in newer versions.
-
- [**] Also you could use "local" but this is only useful if you run
- OpenSM in the foreground of a terminal. As OpenSM is usually started
- as a daemon I left this out as an option.
-
-Step 3: retrieve data which has been collected
-----------------------------------------------
-
-Step 3a: Using console dump function
-------------------------------------
-
-The console command "perfmgr dump_counters" will dump counters to the file
-specified in the opensm.conf file. In the example above
-"/var/log/opensm_port_counters.log"
-
-Example output is below:
-
-<snip>
-"SW1 wopr ISR9024D (MLX4 FW)" 0x8f10400411f56 port 1 (Since Mon May 12 13:27:14 2008)
- symbol_err_cnt : 0
- link_err_recover : 0
- link_downed : 0
- rcv_err : 0
- rcv_rem_phys_err : 0
- rcv_switch_relay_err : 2
- xmit_discards : 0
- xmit_constraint_err : 0
- rcv_constraint_err : 0
- link_integrity_err : 0
- buf_overrun_err : 0
- vl15_dropped : 0
- xmit_data : 470435
- rcv_data : 405956
- xmit_pkts : 8954
- rcv_pkts : 6900
- unicast_xmit_pkts : 0
- unicast_rcv_pkts : 0
- multicast_xmit_pkts : 0
- multicast_rcv_pkts : 0
-</snip>
-
-
-Step 3b: Using a plugin module
-------------------------------
-
-If you want a more automated method of retrieving the data OpenSM provides a
-plugin interface to extend OpenSM. The header file is osm_event_plugin.h.
-The functions you register with this interface will be called when data is
-collected. You can then use that data as appropriate.
-
-An example plugin can be configured at compile time using the
-"--enable-default-event-plugin" option on the configure line. This plugin is
-very simple. It logs "events" recieved from the performance manager to a log
-file. I don't recomend using this directly but rather use it as a templat to
-create your own plugin.
-
diff --git a/contrib/ofed/management/opensm/doc/qos-config.txt b/contrib/ofed/management/opensm/doc/qos-config.txt
deleted file mode 100644
index ac7312f..0000000
--- a/contrib/ofed/management/opensm/doc/qos-config.txt
+++ /dev/null
@@ -1,44 +0,0 @@
-Trivial low level QoS configuration proposition
-===============================================
-
-Basically there is a set of QoS related low-level configuration parameters.
-All these parameter names are prefixed by "qos_" string. Here is a full
-list of these parameters:
-
- qos_max_vls - The maximum number of VLs that will be on the subnet
- qos_high_limit - The limit of High Priority component of VL Arbitration
- table (IBA 7.6.9)
- qos_vlarb_low - Low priority VL Arbitration table (IBA 7.6.9) template
- qos_vlarb_high - High priority VL Arbitration table (IBA 7.6.9) template
- Both VL arbitration templates are pairs of VL and weight
- qos_sl2vl - SL2VL Mapping table (IBA 7.6.6) template. It is a list
- of VLs corresponding to SLs 0-15 (Note the VL15 used
- here means drop this SL)
-
-Typical default values (hard-coded in OpenSM initialization) are:
-
- qos_max_vls 15
- qos_high_limit 0
- qos_vlarb_low 0:0,1:4,2:4,3:4,4:4,5:4,6:4,7:4,8:4,9:4,10:4,11:4,12:4,13:4,14:4
- qos_vlarb_high 0:4,1:0,2:0,3:0,4:0,5:0,6:0,7:0,8:0,9:0,10:0,11:0,12:0,13:0,14:0
- qos_sl2vl 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,7
-
-The syntax is compatible with rest of OpenSM configuration options and
-values may be stored in OpenSM config file (cached options file).
-
-In addition to the above, we may define separate QoS configuration
-parameters sets for various target types. As targets, we currently support
-CAs, routers, switch external ports, and switch's enhanced port 0. The
-names of such specialized parameters are prefixed by "qos_<type>_"
-string. Here is a full list of the currently supported sets:
-
- qos_ca_ - QoS configuration parameters set for CAs.
- qos_rtr_ - parameters set for routers.
- qos_sw0_ - parameters set for switches' port 0.
- qos_swe_ - parameters set for switches' external ports.
-
-Examples:
-
- qos_sw0_max_vls 2
- qos_ca_sl2vl 0,1,2,3,5,5,5,12,12,0,
- qos_swe_high_limit 0
diff --git a/contrib/ofed/management/opensm/doc/todo b/contrib/ofed/management/opensm/doc/todo
deleted file mode 100644
index bbb9698..0000000
--- a/contrib/ofed/management/opensm/doc/todo
+++ /dev/null
@@ -1,27 +0,0 @@
-# OSM List of todo, open issues, and futures:
-
-1 041228 - Handle local events (local lid change, port state change, etc.)
-2 041228 - SM port fail over to next port upon request ?
-3 050912 - Handle busy status in SA client API/implementation
-4 050912 - Handle o15-0.1.13 (SA ServiceRecord) as well as updates
- to osmtest for this
-5 051207 - Client reregistration is indicated before SA is
- ready to accept subscriptions
-6 060109 - Use LID routing for light sweep to guarantee trap
- delivery path to the SM.
-7 061201 - Finer grained locking ?
-8 061201 - Mapping multiple MGIDs on single MLID when characteristics
- match (PKey, etc.)
-9 070329 - Add ssh support into remote socket/console support
-10 070329 - Add authentication for (at least remote) console
-11 070413 - Add dynamic rate adjustment for multicast groups
-
-
-Futures
-
-LID partitioning ?
-Advanced failover
-Management
-Regression tests and automation
-Additional pathing algorithms
-
diff --git a/contrib/ofed/management/opensm/include/Makefile.am b/contrib/ofed/management/opensm/include/Makefile.am
deleted file mode 100644
index 1df1abc..0000000
--- a/contrib/ofed/management/opensm/include/Makefile.am
+++ /dev/null
@@ -1,33 +0,0 @@
-
-SUBDIRS = .
-
-nobase_pkginclude_HEADERS = iba/ib_types.h iba/ib_cm_types.h
-
-EXTRA_DIST = \
- $(srcdir)/iba/ib_types.h \
- $(srcdir)/iba/ib_cm_types.h \
- $(srcdir)/vendor/osm_vendor_mlx_transport_anafa.h \
- $(srcdir)/vendor/osm_vendor_mlx.h \
- $(srcdir)/vendor/osm_vendor_mlx_sender.h \
- $(srcdir)/vendor/osm_vendor_ibumad.h \
- $(srcdir)/vendor/osm_vendor_mlx_defs.h \
- $(srcdir)/vendor/osm_vendor_mtl_transaction_mgr.h \
- $(srcdir)/vendor/osm_vendor_mlx_sar.h \
- $(srcdir)/vendor/osm_vendor_mlx_dispatcher.h \
- $(srcdir)/vendor/osm_vendor_umadt.h \
- $(srcdir)/vendor/osm_vendor_mlx_svc.h \
- $(srcdir)/vendor/osm_vendor_mlx_hca.h \
- $(srcdir)/vendor/osm_vendor_mlx_rmpp_ctx.h \
- $(srcdir)/vendor/osm_vendor_mlx_transport.h \
- $(srcdir)/vendor/osm_vendor_mlx_inout.h \
- $(srcdir)/vendor/osm_vendor_mtl_hca_guid.h \
- $(srcdir)/vendor/osm_vendor_test.h \
- $(srcdir)/vendor/osm_vendor_ts.h \
- $(srcdir)/vendor/osm_vendor_mlx_txn.h \
- $(srcdir)/vendor/osm_vendor_al.h \
- $(srcdir)/vendor/osm_vendor_mtl.h \
- $(srcdir)/vendor/osm_ts_useraccess.h \
- $(srcdir)/vendor/osm_umadt.h \
- $(srcdir)/vendor/osm_mtl_bind.h
-
-pkgincludedir = $(includedir)/infiniband
diff --git a/contrib/ofed/management/opensm/include/complib/cl_atomic.h b/contrib/ofed/management/opensm/include/complib/cl_atomic.h
deleted file mode 100644
index 92620ee..0000000
--- a/contrib/ofed/management/opensm/include/complib/cl_atomic.h
+++ /dev/null
@@ -1,196 +0,0 @@
-/*
- * Copyright (c) 2004-2006 Voltaire, Inc. All rights reserved.
- * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved.
- * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- */
-
-/*
- * Abstract:
- * Declaration of atomic manipulation functions.
- */
-
-#ifndef _CL_ATOMIC_H_
-#define _CL_ATOMIC_H_
-
-#include <complib/cl_atomic_osd.h>
-
-#ifdef __cplusplus
-# define BEGIN_C_DECLS extern "C" {
-# define END_C_DECLS }
-#else /* !__cplusplus */
-# define BEGIN_C_DECLS
-# define END_C_DECLS
-#endif /* __cplusplus */
-
-BEGIN_C_DECLS
-/****h* Component Library/Atomic Operations
-* NAME
-* Atomic Operations
-*
-* DESCRIPTION
-* The Atomic Operations functions allow callers to operate on
-* 32-bit signed integers in an atomic fashion.
-*********/
-/****f* Component Library: Atomic Operations/cl_atomic_inc
-* NAME
-* cl_atomic_inc
-*
-* DESCRIPTION
-* The cl_atomic_inc function atomically increments a 32-bit signed
-* integer and returns the incremented value.
-*
-* SYNOPSIS
-*/
-int32_t cl_atomic_inc(IN atomic32_t * const p_value);
-/*
-* PARAMETERS
-* p_value
-* [in] Pointer to a 32-bit integer to increment.
-*
-* RETURN VALUE
-* Returns the incremented value pointed to by p_value.
-*
-* NOTES
-* The provided value is incremented and its value returned in one atomic
-* operation.
-*
-* cl_atomic_inc maintains data consistency without requiring additional
-* synchronization mechanisms in multi-threaded environments.
-*
-* SEE ALSO
-* Atomic Operations, cl_atomic_dec, cl_atomic_add, cl_atomic_sub,
-* cl_atomic_xchg, cl_atomic_comp_xchg
-*********/
-
-/****f* Component Library: Atomic Operations/cl_atomic_dec
-* NAME
-* cl_atomic_dec
-*
-* DESCRIPTION
-* The cl_atomic_dec function atomically decrements a 32-bit signed
-* integer and returns the decremented value.
-*
-* SYNOPSIS
-*/
-int32_t cl_atomic_dec(IN atomic32_t * const p_value);
-/*
-* PARAMETERS
-* p_value
-* [in] Pointer to a 32-bit integer to decrement.
-*
-* RETURN VALUE
-* Returns the decremented value pointed to by p_value.
-*
-* NOTES
-* The provided value is decremented and its value returned in one atomic
-* operation.
-*
-* cl_atomic_dec maintains data consistency without requiring additional
-* synchronization mechanisms in multi-threaded environments.
-*
-* SEE ALSO
-* Atomic Operations, cl_atomic_inc, cl_atomic_add, cl_atomic_sub,
-* cl_atomic_xchg, cl_atomic_comp_xchg
-*********/
-
-/****f* Component Library: Atomic Operations/cl_atomic_add
-* NAME
-* cl_atomic_add
-*
-* DESCRIPTION
-* The cl_atomic_add function atomically adds a value to a
-* 32-bit signed integer and returns the resulting value.
-*
-* SYNOPSIS
-*/
-int32_t
-cl_atomic_add(IN atomic32_t * const p_value, IN const int32_t increment);
-/*
-* PARAMETERS
-* p_value
-* [in] Pointer to a 32-bit integer that will be added to.
-*
-* increment
-* [in] Value by which to increment the integer pointed to by p_value.
-*
-* RETURN VALUE
-* Returns the value pointed to by p_value after the addition.
-*
-* NOTES
-* The provided increment is added to the value and the result returned in
-* one atomic operation.
-*
-* cl_atomic_add maintains data consistency without requiring additional
-* synchronization mechanisms in multi-threaded environments.
-*
-* SEE ALSO
-* Atomic Operations, cl_atomic_inc, cl_atomic_dec, cl_atomic_sub,
-* cl_atomic_xchg, cl_atomic_comp_xchg
-*********/
-
-/****f* Component Library: Atomic Operations/cl_atomic_sub
-* NAME
-* cl_atomic_sub
-*
-* DESCRIPTION
-* The cl_atomic_sub function atomically subtracts a value from a
-* 32-bit signed integer and returns the resulting value.
-*
-* SYNOPSIS
-*/
-int32_t
-cl_atomic_sub(IN atomic32_t * const p_value, IN const int32_t decrement);
-/*
-* PARAMETERS
-* p_value
-* [in] Pointer to a 32-bit integer that will be subtracted from.
-*
-* decrement
-* [in] Value by which to decrement the integer pointed to by p_value.
-*
-* RETURN VALUE
-* Returns the value pointed to by p_value after the subtraction.
-*
-* NOTES
-* The provided decrement is subtracted from the value and the result
-* returned in one atomic operation.
-*
-* cl_atomic_sub maintains data consistency without requiring additional
-* synchronization mechanisms in multi-threaded environments.
-*
-* SEE ALSO
-* Atomic Operations, cl_atomic_inc, cl_atomic_dec, cl_atomic_add,
-* cl_atomic_xchg, cl_atomic_comp_xchg
-*********/
-
-END_C_DECLS
-#endif /* _CL_ATOMIC_H_ */
diff --git a/contrib/ofed/management/opensm/include/complib/cl_atomic_osd.h b/contrib/ofed/management/opensm/include/complib/cl_atomic_osd.h
deleted file mode 100644
index ac14f8a..0000000
--- a/contrib/ofed/management/opensm/include/complib/cl_atomic_osd.h
+++ /dev/null
@@ -1,104 +0,0 @@
-/*
- * Copyright (c) 2004-2006 Voltaire, Inc. All rights reserved.
- * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved.
- * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- */
-
-/*
- * Abstract:
- * Implementation specific header files for atomic operations.
- */
-
-#ifndef _CL_ATOMIC_OSD_H_
-#define _CL_ATOMIC_OSD_H_
-
-#include <complib/cl_types.h>
-#include <complib/cl_spinlock.h>
-
-#ifdef __cplusplus
-# define BEGIN_C_DECLS extern "C" {
-# define END_C_DECLS }
-#else /* !__cplusplus */
-# define BEGIN_C_DECLS
-# define END_C_DECLS
-#endif /* __cplusplus */
-
-BEGIN_C_DECLS extern cl_spinlock_t cl_atomic_spinlock;
-
-static inline int32_t cl_atomic_inc(IN atomic32_t * const p_value)
-{
- int32_t new_val;
-
- cl_spinlock_acquire(&cl_atomic_spinlock);
- new_val = *p_value + 1;
- *p_value = new_val;
- cl_spinlock_release(&cl_atomic_spinlock);
- return (new_val);
-}
-
-static inline int32_t cl_atomic_dec(IN atomic32_t * const p_value)
-{
- int32_t new_val;
-
- cl_spinlock_acquire(&cl_atomic_spinlock);
- new_val = *p_value - 1;
- *p_value = new_val;
- cl_spinlock_release(&cl_atomic_spinlock);
- return (new_val);
-}
-
-static inline int32_t
-cl_atomic_add(IN atomic32_t * const p_value, IN const int32_t increment)
-{
- int32_t new_val;
-
- cl_spinlock_acquire(&cl_atomic_spinlock);
- new_val = *p_value + increment;
- *p_value = new_val;
- cl_spinlock_release(&cl_atomic_spinlock);
- return (new_val);
-}
-
-static inline int32_t
-cl_atomic_sub(IN atomic32_t * const p_value, IN const int32_t decrement)
-{
- int32_t new_val;
-
- cl_spinlock_acquire(&cl_atomic_spinlock);
- new_val = *p_value + decrement;
- *p_value = new_val;
- cl_spinlock_release(&cl_atomic_spinlock);
- return (new_val);
-}
-
-END_C_DECLS
-#endif /* _CL_ATOMIC_OSD_H_ */
diff --git a/contrib/ofed/management/opensm/include/complib/cl_byteswap.h b/contrib/ofed/management/opensm/include/complib/cl_byteswap.h
deleted file mode 100644
index ca144e3..0000000
--- a/contrib/ofed/management/opensm/include/complib/cl_byteswap.h
+++ /dev/null
@@ -1,525 +0,0 @@
-/*
- * Copyright (c) 2004-2006 Voltaire, Inc. All rights reserved.
- * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved.
- * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- */
-
-/*
- * Abstract:
- * provides byteswapping utilities. Basic functions are obtained from
- * platform specific implementations from byteswap_osd.h.
- */
-
-#ifndef _CL_BYTESWAP_H_
-#define _CL_BYTESWAP_H_
-
-#include <string.h>
-#include <complib/cl_byteswap_osd.h>
-
-#ifdef __cplusplus
-# define BEGIN_C_DECLS extern "C" {
-# define END_C_DECLS }
-#else /* !__cplusplus */
-# define BEGIN_C_DECLS
-# define END_C_DECLS
-#endif /* __cplusplus */
-
-BEGIN_C_DECLS
-/****h* Component Library/Byte Swapping
-* NAME
-* Byte Swapping
-*
-* DESCRIPTION
-* The byte swapping functions and macros allow swapping bytes from network
-* byte order to host byte order.
-*
-* All data transmitted between systems should be in network byte order.
-* In order to utilize such data, it must be converted to host byte order
-* before use.
-*
-* SEE ALSO
-* Functions:
-* cl_ntoh16, cl_hton16, cl_ntoh32, cl_hton32, cl_ntoh64, cl_hton64,
-* cl_ntoh
-*
-* Macros:
-* CL_NTOH16, CL_HTON16, CL_NTOH32, CL_HTON32, CL_NTOH64, CL_HTON64
-*********/
-/*
- * The byteswap_osd.h provides the following macros.
- * __LITTLE_ENDIAN
- * __BIG_ENDIAN
- * __BYTE_ORDER
- *
- * If the platform provides byte swapping functions, byteswap_osd.h also
- * provides the following macros.
- * ntoh16, hton16
- * ntoh32, hton32
- * ntoh64, hton64
- */
-
-#ifndef __BYTE_ORDER
-#error "__BYTE_ORDER macro undefined. Missing in endian.h?"
-#endif
-#if __BYTE_ORDER == __LITTLE_ENDIAN
-#define CPU_LE 1
-#define CPU_BE 0
-#else
-#define CPU_LE 0
-#define CPU_BE 1
-#endif
-/****d* Component Library: Byte Swapping/CL_NTOH16
-* NAME
-* CL_NTOH16
-*
-* DESCRIPTION
-* The CL_NTOH16 macro converts a 16-bit value from network byte order to
-* host byte order. The CL_NTOH16 macro will cause constant values to be
-* swapped by the pre-processor. For variables, CL_NTOH16 is less efficient
-* than the cl_ntoh16 function.
-*
-* SYNOPSIS
-* CL_NTOH16( val );
-*
-* PARAMETERS
-* val
-* [in] 16-bit value to swap from network byte order to host byte order.
-*
-* RESULT
-* Value of val converted to host byte order.
-*
-* NOTES
-* This macro is analogous to CL_HTON16.
-*
-* SEE ALSO
-* Byte Swapping, CL_HTON16, CL_NTOH32, CL_NTOH64,
-* cl_ntoh16, cl_ntoh32, cl_ntoh64, cl_ntoh
-*********/
-/****d* Component Library: Byte Swapping/CL_HTON16
-* NAME
-* CL_HTON16
-*
-* DESCRIPTION
-* The CL_HTON16 macro converts a 16-bit value from host byte order to
-* network byte order. The CL_HTON16 macro will cause constant values to be
-* swapped by the pre-processor. For variables, CL_HTON16 is less efficient
-* than the cl_hton16 function.
-*
-* SYNOPSIS
-* CL_HTON16( val );
-*
-* PARAMETERS
-* val
-* [in] 16-bit value to swap from host byte order to network byte order.
-*
-* RESULT
-* Value of val converted to network byte order.
-*
-* NOTES
-* This macro is analogous to CL_NTOH16.
-*
-* SEE ALSO
-* Byte Swapping, CL_NTOH16, CL_HTON32, CL_HTON64,
-* cl_hton16, cl_hton32, cl_hton64, cl_ntoh
-*********/
-#if CPU_LE
-#define CL_NTOH16( x ) (uint16_t)( \
- (((uint16_t)(x) & 0x00FF) << 8) | \
- (((uint16_t)(x) & 0xFF00) >> 8) )
-#else
-#define CL_NTOH16( x ) (x)
-#endif
-#define CL_HTON16 CL_NTOH16
-/****f* Component Library: Byte Swapping/cl_ntoh16
-* NAME
-* cl_ntoh16
-*
-* DESCRIPTION
-* The cl_ntoh16 function converts a 16-bit value from network byte order to
-* host byte order.
-*
-* SYNOPSIS
-* uint16_t
-* cl_ntoh16(
-* IN const uint16_t val );
-*
-* PARAMETERS
-* val
-* [in] Value to swap from network byte order to host byte order.
-*
-* RETURN VALUE
-* Value of val converted to host byte order.
-*
-* NOTES
-* This function is analogous to cl_hton16.
-*
-* SEE ALSO
-* Byte Swapping, cl_hton16, cl_ntoh32, cl_ntoh64, cl_ntoh
-*********/
-/****f* Component Library: Byte Swapping/cl_hton16
-* NAME
-* cl_hton16
-*
-* DESCRIPTION
-* The cl_hton16 function converts a 16-bit value from host byte order to
-* network byte order.
-*
-* SYNOPSIS
-* uint16_t
-* cl_hton16(
-* IN const uint16_t val );
-*
-* PARAMETERS
-* val
-* [in] Value to swap from host byte order to network byte order .
-*
-* RETURN VALUE
-* Value of val converted to network byte order.
-*
-* NOTES
-* This function is analogous to cl_ntoh16.
-*
-* SEE ALSO
-* Byte Swapping, cl_ntoh16, cl_hton32, cl_hton64, cl_ntoh
-*********/
-#ifndef cl_ntoh16
-#define cl_ntoh16 CL_NTOH16
-#define cl_hton16 CL_HTON16
-#endif
-/****d* Component Library: Byte Swapping/CL_NTOH32
-* NAME
-* CL_NTOH32
-*
-* DESCRIPTION
-* The CL_NTOH32 macro converts a 32-bit value from network byte order to
-* host byte order. The CL_NTOH32 macro will cause constant values to be
-* swapped by the pre-processor. For variables, CL_NTOH32 is less efficient
-* than the cl_ntoh32 function.
-*
-* SYNOPSIS
-* CL_NTOH32( val );
-*
-* PARAMETERS
-* val
-* [in] 32-bit value to swap from network byte order to host byte order.
-*
-* RESULT
-* Value of val converted to host byte order.
-*
-* NOTES
-* This macro is analogous to CL_HTON32.
-*
-* SEE ALSO
-* Byte Swapping, CL_HTON32, CL_NTOH16, CL_NTOH64,
-* cl_ntoh16, cl_ntoh32, cl_ntoh64, cl_ntoh
-*********/
-/****d* Component Library: Byte Swapping/CL_HTON32
-* NAME
-* CL_HTON32
-*
-* DESCRIPTION
-* The CL_HTON32 macro converts a 32-bit value from host byte order to
-* network byte order. The CL_HTON32 macro will cause constant values to be
-* swapped by the pre-processor. For variables, CL_HTON32 is less efficient
-* than the cl_hton32 function.
-*
-* SYNOPSIS
-* CL_HTON32( val );
-*
-* PARAMETERS
-* val
-* [in] 32-bit value to swap from host byte order to network byte order.
-*
-* RESULT
-* Value of val converted to network byte order.
-*
-* NOTES
-* This macro is analogous to CL_NTOH32.
-*
-* SEE ALSO
-* Byte Swapping, CL_NTOH32, CL_HTON16, CL_HTON64,
-* cl_hton16, cl_hton32, cl_hton64, cl_ntoh
-*********/
-#if CPU_LE
-#define CL_NTOH32( x ) (uint32_t)( \
- (((uint32_t)(x) & 0x000000FF) << 24) | \
- (((uint32_t)(x) & 0x0000FF00) << 8) | \
- (((uint32_t)(x) & 0x00FF0000) >> 8) | \
- (((uint32_t)(x) & 0xFF000000) >> 24) )
-#else
-#define CL_NTOH32( x ) (x)
-#endif
-#define CL_HTON32 CL_NTOH32
-/****f* Component Library: Byte Swapping/cl_ntoh32
-* NAME
-* cl_ntoh32
-*
-* DESCRIPTION
-* The cl_ntoh32 function converts a 32-bit value from network byte order to
-* host byte order.
-*
-* SYNOPSIS
-* uint32_t
-* cl_ntoh32(
-* IN const uint32_t val );
-*
-* PARAMETERS
-* val
-* [in] Value to swap from network byte order to host byte order.
-*
-* RETURN VALUE
-* Value of val converted in host byte order.
-*
-* NOTES
-* This function is analogous to cl_hton32.
-*
-* SEE ALSO
-* Byte Swapping, cl_hton32, cl_ntoh16, cl_ntoh64, cl_ntoh
-*********/
-/****f* Component Library: Byte Swapping/cl_hton32
-* NAME
-* cl_hton32
-*
-* DESCRIPTION
-* The cl_hton32 function converts a 32-bit value from host byte order to
-* network byte order.
-*
-* SYNOPSIS
-* uint32_t
-* cl_hton32(
-* IN const uint32_t val );
-*
-* PARAMETERS
-* val
-* [in] Value to swap from host byte order to network byte order .
-*
-* RETURN VALUE
-* Value of val converted to network byte order.
-*
-* NOTES
-* This function is analogous to cl_ntoh32.
-*
-* SEE ALSO
-* Byte Swapping, cl_ntoh32, cl_hton16, cl_hton64, cl_ntoh
-*********/
-#ifndef cl_ntoh32
-#define cl_ntoh32 CL_NTOH32
-#define cl_hton32 CL_HTON32
-#endif
-/****d* Component Library: Byte Swapping/CL_NTOH64
-* NAME
-* CL_NTOH64
-*
-* DESCRIPTION
-* The CL_NTOH64 macro converts a 64-bit value from network byte order to
-* host byte order. The CL_NTOH64 macro will cause constant values to be
-* swapped by the pre-processor. For variables, CL_NTOH64 is less efficient
-* than the cl_ntoh64 function.
-*
-* SYNOPSIS
-* CL_NTOH64( val );
-*
-* PARAMETERS
-* val
-* [in] 64-bit value to swap from network byte order to host byte order.
-*
-* RESULT
-* Value of val converted to host byte order.
-*
-* NOTES
-* This macro is analogous to CL_HTON64.
-*
-* SEE ALSO
-* Byte Swapping, CL_HTON64, CL_NTOH16, CL_NTOH32,
-* cl_ntoh16, cl_ntoh32, cl_ntoh64, cl_ntoh
-*********/
-/****d* Component Library: Byte Swapping/CL_HTON64
-* NAME
-* CL_HTON64
-*
-* DESCRIPTION
-* The CL_HTON64 macro converts a 64-bit value from host byte order to
-* network byte order. The CL_HTON64 macro will cause constant values to be
-* swapped by the pre-processor. For variables, CL_HTON64 is less efficient
-* than the cl_hton64 function.
-*
-* SYNOPSIS
-* CL_HTON64( val );
-*
-* PARAMETERS
-* val
-* [in] 64-bit value to swap from host byte order to network byte order.
-*
-* RESULT
-* Value of val converted to network byte order.
-*
-* NOTES
-* This macro is analogous to CL_NTOH64.
-*
-* SEE ALSO
-* Byte Swapping, CL_NTOH64, CL_HTON16, CL_HTON32,
-* cl_hton16, cl_hton32, cl_hton64, cl_ntoh
-*********/
-#if CPU_LE
-#define CL_NTOH64( x ) (uint64_t)( \
- (((uint64_t)(x) & 0x00000000000000FFULL) << 56) | \
- (((uint64_t)(x) & 0x000000000000FF00ULL) << 40) | \
- (((uint64_t)(x) & 0x0000000000FF0000ULL) << 24) | \
- (((uint64_t)(x) & 0x00000000FF000000ULL) << 8 ) | \
- (((uint64_t)(x) & 0x000000FF00000000ULL) >> 8 ) | \
- (((uint64_t)(x) & 0x0000FF0000000000ULL) >> 24) | \
- (((uint64_t)(x) & 0x00FF000000000000ULL) >> 40) | \
- (((uint64_t)(x) & 0xFF00000000000000ULL) >> 56) )
-#else
-#define CL_NTOH64( x ) (x)
-#endif
-#define CL_HTON64 CL_NTOH64
-/****f* Component Library: Byte Swapping/cl_ntoh64
-* NAME
-* cl_ntoh64
-*
-* DESCRIPTION
-* The cl_ntoh64 function converts a 64-bit value from network byte order to
-* host byte order.
-*
-* SYNOPSIS
-* uint64_t
-* cl_ntoh64(
-* IN const uint64_t val );
-*
-* PARAMETERS
-* val
-* [in] Value to swap from network byte order to host byte order.
-*
-* RETURN VALUE
-* Value of val converted in host byte order.
-*
-* NOTES
-* This function is analogous to cl_hton64.
-*
-* SEE ALSO
-* Byte Swapping, cl_hton64, cl_ntoh16, cl_ntoh32, cl_ntoh
-*********/
-/****f* Component Library: Byte Swapping/cl_hton64
-* NAME
-* cl_hton64
-*
-* DESCRIPTION
-* The cl_hton64 function converts a 64-bit value from host byte order to
-* network byte order.
-*
-* SYNOPSIS
-* uint64_t
-* cl_hton64(
-* IN const uint64_t val );
-*
-* PARAMETERS
-* val
-* [in] Value to swap from host byte order to network byte order .
-*
-* RETURN VALUE
-* Value of val converted to network byte order.
-*
-* NOTES
-* This function is analogous to cl_ntoh64.
-*
-* SEE ALSO
-* Byte Swapping, cl_ntoh64, cl_hton16, cl_hton32, cl_ntoh
-*********/
-#ifndef cl_ntoh64
-#define cl_ntoh64 CL_NTOH64
-#define cl_hton64 CL_HTON64
-#endif
-/****f* Component Library: Byte Swapping/cl_ntoh
-* NAME
-* cl_ntoh
-*
-* DESCRIPTION
-* The cl_ntoh function converts a value from network byte order to
-* host byte order.
-*
-* SYNOPSIS
-*/
-static inline void
-cl_ntoh(OUT char *const p_dest,
- IN const char *const p_src, IN const uint8_t size)
-{
-#if CPU_LE
- uint8_t i;
- char temp;
-
- if (p_src == p_dest) {
- /* Swap in place if source and destination are the same. */
- for (i = 0; i < size / 2; i++) {
- temp = p_dest[i];
- p_dest[i] = p_src[size - 1 - i];
- p_dest[size - 1 - i] = temp;
- }
- } else {
- for (i = 0; i < size; i++)
- p_dest[i] = p_src[size - 1 - i];
- }
-#else
- /*
- * If the source and destination are not the same, copy the source to
- * the destination.
- */
- if (p_src != p_dest)
- memcpy(p_dest, p_src, size);
-#endif
-}
-
-/*
-* PARAMETERS
-* p_dest
-* [in] Pointer to a byte array to contain the converted value of p_src.
-*
-* p_src
-* [in] Pointer to a byte array to be converted from network byte
-* ordering.
-*
-* size
-* [in] Number of bytes to swap.p_dest
-*
-* RETURN VALUE
-* This function does not return a value.
-*
-* NOTES
-* cl_ntoh can perform in place swapping if both p_src and p_dest point to
-* the same buffer.
-*
-* SEE ALSO
-* Byte Swapping, cl_ntoh16, cl_ntoh32, cl_ntoh64
-*********/
-
-END_C_DECLS
-#endif /* _CL_BYTESWAP_H_ */
diff --git a/contrib/ofed/management/opensm/include/complib/cl_byteswap_osd.h b/contrib/ofed/management/opensm/include/complib/cl_byteswap_osd.h
deleted file mode 100644
index 72ff40e..0000000
--- a/contrib/ofed/management/opensm/include/complib/cl_byteswap_osd.h
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- * Copyright (c) 2004, 2005 Voltaire, Inc. All rights reserved.
- * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved.
- * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- */
-
-/*
- * Abstract:
- * Provides common macros for dealing with byte swapping issues.
- */
-
-#ifndef _CL_BYTESWAP_OSD_H_
-#define _CL_BYTESWAP_OSD_H_
-
-/*
- * This provides defines __LITTLE_ENDIAN, __BIG_ENDIAN and __BYTE_ORDER
- */
-#include <endian.h>
-#include <byteswap.h>
-
-#ifdef __cplusplus
-# define BEGIN_C_DECLS extern "C" {
-# define END_C_DECLS }
-#else /* !__cplusplus */
-# define BEGIN_C_DECLS
-# define END_C_DECLS
-#endif /* __cplusplus */
-
-BEGIN_C_DECLS
-#if __BYTE_ORDER == __LITTLE_ENDIAN
-#define cl_ntoh16(x) bswap_16(x)
-#define cl_hton16(x) bswap_16(x)
-#define cl_ntoh32(x) bswap_32(x)
-#define cl_hton32(x) bswap_32(x)
-#define cl_ntoh64(x) (uint64_t)bswap_64(x)
-#define cl_hton64(x) (uint64_t)bswap_64(x)
-#else /* Big Endian */
-#define cl_ntoh16(x) (x)
-#define cl_hton16(x) (x)
-#define cl_ntoh32(x) (x)
-#define cl_hton32(x) (x)
-#define cl_ntoh64(x) (x)
-#define cl_hton64(x) (x)
-#endif
-END_C_DECLS
-#endif /* _CL_BYTESWAP_OSD_H_ */
diff --git a/contrib/ofed/management/opensm/include/complib/cl_event_wheel.h b/contrib/ofed/management/opensm/include/complib/cl_event_wheel.h
deleted file mode 100644
index ac02242..0000000
--- a/contrib/ofed/management/opensm/include/complib/cl_event_wheel.h
+++ /dev/null
@@ -1,457 +0,0 @@
-/*
- * Copyright (c) 2004, 2005 Voltaire, Inc. All rights reserved.
- * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved.
- * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- */
-
-/*
- * Abstract:
- * Declaration of event wheel abstraction.
- */
-
-#ifndef _CL_EVENT_WHEEL_H_
-#define _CL_EVENT_WHEEL_H_
-
-#include <complib/cl_atomic.h>
-#include <complib/cl_qlist.h>
-#include <complib/cl_qmap.h>
-#include <complib/cl_timer.h>
-#include <complib/cl_spinlock.h>
-
-#ifdef __cplusplus
-# define BEGIN_C_DECLS extern "C" {
-# define END_C_DECLS }
-#else /* !__cplusplus */
-# define BEGIN_C_DECLS
-# define END_C_DECLS
-#endif /* __cplusplus */
-
-BEGIN_C_DECLS
-/****h* Component Library/Event_Wheel
-* NAME
-* Event_Wheel
-*
-* DESCRIPTION
-* The Event_Wheel provides a facility for registering delayed events
-* and getting called once they timeout.
-*
-* The Event_Wheel functions operate on a cl_event_wheel_t structure
-* which should be treated as opaque and should be manipulated
-* only through the provided functions.
-*
-* SEE ALSO
-* Structures:
-* cl_event_wheel_t
-*
-* Initialization/Destruction:
-* cl_event_wheel_construct, cl_event_wheel_init, cl_event_wheel_destroy
-*
-* Manipulation:
-* cl_event_wheel_reg, cl_event_wheel_unreg
-*
-*********/
-/****f* Component Library: Event_Wheel/cl_pfn_event_aged_cb_t
-* NAME
-* cl_pfn_event_aged_cb_t
-*
-* DESCRIPTION
-* This typedef defines the prototype for client functions invoked
-* by the Event_Wheel. The Event_Wheel calls the corresponding
-* client function when the specific item has aged.
-*
-* SYNOPSIS
-*/
-typedef uint64_t
- (*cl_pfn_event_aged_cb_t) (IN uint64_t key,
- IN uint32_t num_regs, IN void *context);
-/*
-* PARAMETERS
-* key
-* [in] The key used for registering the item in the call to
-* cl_event_wheel_reg
-*
-* num_regs
-* [in] The number of times this event was registered (pushed in time).
-*
-* context
-* [in] Client specific context specified in a call to
-* cl_event_wheel_reg
-*
-* RETURN VALUE
-* This function returns the abosolute time the event should fire in [usec].
-* If lower then current time means the event should be unregistered
-* immediatly.
-*
-* NOTES
-* This typedef provides a function prototype reference for
-* the function provided by Event_Wheel clients as a parameter
-* to the cl_event_wheel_reg function.
-*
-* SEE ALSO
-* Event_Wheel, cl_event_wheel_reg
-*********/
-
-/****s* Component Library: Event_Wheel/cl_event_wheel_t
-* NAME
-* cl_event_wheel_t
-*
-* DESCRIPTION
-* Event_Wheel structure.
-*
-* The Event_Wheel is thread safe.
-*
-* The cl_event_wheel_t structure should be treated as opaque and should
-* be manipulated only through the provided functions.
-*
-* SYNOPSIS
-*/
-typedef struct _cl_event_wheel {
- cl_spinlock_t lock;
- cl_spinlock_t *p_external_lock;
-
- cl_qmap_t events_map;
- boolean_t closing;
- cl_qlist_t events_wheel;
- cl_timer_t timer;
-} cl_event_wheel_t;
-/*
-* FIELDS
-* lock
-* Spinlock to guard internal structures.
-*
-* p_external_lock
-* Reference to external spinlock to guard internal structures
-* if the event wheel is part of a larger object protected by its own lock
-*
-* events_map
-* A Map holding all registered event items by their key.
-*
-* closing
-* A flag indicating the event wheel is closing. This means that
-* callbacks that are called when closing == TRUE should just be ignored.
-*
-* events_wheel
-* A list of the events sorted by expiration time.
-*
-* timer
-* The timer scheduling event time propagation.
-*
-* SEE ALSO
-* Event_Wheel
-*********/
-
-/****s* Component Library: Event_Wheel/cl_event_wheel_reg_info_t
-* NAME
-* cl_event_wheel_reg_info_t
-*
-* DESCRIPTION
-* Defines the event_wheel registration object structure.
-*
-* The cl_event_wheel_reg_info_t structure is for internal use by the
-* Event_Wheel only.
-*
-* SYNOPSIS
-*/
-typedef struct _cl_event_wheel_reg_info {
- cl_map_item_t map_item;
- cl_list_item_t list_item;
- uint64_t key;
- cl_pfn_event_aged_cb_t pfn_aged_callback;
- uint64_t aging_time;
- uint32_t num_regs;
- void *context;
- cl_event_wheel_t *p_event_wheel;
-} cl_event_wheel_reg_info_t;
-/*
-* FIELDS
-* map_item
-* The map item of this event
-*
-* list_item
-* The sorted by aging time list item
-*
-* key
-* The key by which one can find the event
-*
-* pfn_aged_callback
-* The clients Event-Aged callback
-*
-* aging_time
-* The delta time [msec] for which the event should age.
-*
-* num_regs
-* The number of times the same event (key) was registered
-*
-* context
-* Client's context for event-aged callback.
-*
-* p_event_wheel
-* Pointer to this event wheel object
-*
-* SEE ALSO
-*********/
-
-/****f* Component Library: Event_Wheel/cl_event_wheel_construct
-* NAME
-* cl_event_wheel_construct
-*
-* DESCRIPTION
-* This function constructs a Event_Wheel object.
-*
-* SYNOPSIS
-*/
-void cl_event_wheel_construct(IN cl_event_wheel_t * const p_event_wheel);
-/*
-* PARAMETERS
-* p_event_wheel
-* [in] Pointer to a Event_Wheel.
-*
-* RETURN VALUE
-* This function does not return a value.
-*
-* NOTES
-* Allows calling cl_event_wheel_init and cl_event_wheel_destroy.
-*
-* SEE ALSO
-* Event_Wheel, cl_event_wheel_init, cl_event_wheel_destroy
-*********/
-
-/****f* Component Library: Event_Wheel/cl_event_wheel_init
-* NAME
-* cl_event_wheel_init
-*
-* DESCRIPTION
-* This function initializes a Event_Wheel object.
-*
-* SYNOPSIS
-*/
-cl_status_t
-cl_event_wheel_init(IN cl_event_wheel_t * const p_event_wheel);
-
-/*
-* PARAMETERS
-* p_event_wheel
-* [in] Pointer to a Event_Wheel.
-*
-* RETURN VALUE
-* CL_SUCCESS if the operation is successful.
-*
-* SEE ALSO
-* Event_Wheel, cl_event_wheel_destoy, cl_event_wheel_reg, cl_event_wheel_unreg
-*
-*********/
-
-/****f* Component Library: Event_Wheel/cl_event_wheel_init
-* NAME
-* cl_event_wheel_init
-*
-* DESCRIPTION
-* This function initializes a Event_Wheel object.
-*
-* SYNOPSIS
-*/
-cl_status_t
-cl_event_wheel_init_ex(IN cl_event_wheel_t * const p_event_wheel,
- IN cl_spinlock_t * p_external_lock);
-
-/*
-* PARAMETERS
-* p_event_wheel
-* [in] Pointer to a Event_Wheel.
-*
-* p_external_lock
-* [in] Reference to external spinlock to guard internal structures
-* if the event wheel is part of a larger object protected by its own lock
-*
-* RETURN VALUE
-* CL_SUCCESS if the operation is successful.
-*
-* SEE ALSO
-* Event_Wheel, cl_event_wheel_destoy, cl_event_wheel_reg, cl_event_wheel_unreg
-*
-*********/
-
-/****f* Component Library: Event_Wheel/cl_event_wheel_destroy
-* NAME
-* cl_event_wheel_destroy
-*
-* DESCRIPTION
-* This function destroys a Event_Wheel object.
-*
-* SYNOPSIS
-*/
-void cl_event_wheel_destroy(IN cl_event_wheel_t * const p_event_wheel);
-/*
-* PARAMETERS
-* p_event_wheel
-* [in] Pointer to a Event_Wheel.
-*
-* RETURN VALUE
-* This function does not return a value.
-*
-* NOTES
-* This function does not returns until all client callback functions
-* been successfully finished.
-*
-* SEE ALSO
-* Event_Wheel, cl_event_wheel_construct, cl_event_wheel_init
-*********/
-
-/****f* Component Library: Event_Wheel/cl_event_wheel_dump
-* NAME
-* cl_event_wheel_dump
-*
-* DESCRIPTION
-* This function dumps the details of an Event_Whell object.
-*
-* SYNOPSIS
-*/
-void cl_event_wheel_dump(IN cl_event_wheel_t * const p_event_wheel);
-/*
-* PARAMETERS
-* p_event_wheel
-* [in] Pointer to a Event_Wheel.
-*
-* RETURN VALUE
-* This function does not return a value.
-*
-* NOTES
-* Note that this function should be called inside a lock of the event wheel!
-* It doesn't aquire the lock by itself.
-*
-* SEE ALSO
-* Event_Wheel, cl_event_wheel_construct, cl_event_wheel_init
-*********/
-
-/****f* Component Library: Event_Wheel/cl_event_wheel_reg
-* NAME
-* cl_event_wheel_reg
-*
-* DESCRIPTION
-* This function registers a client with a Event_Wheel object.
-*
-* SYNOPSIS
-*/
-cl_status_t
-cl_event_wheel_reg(IN cl_event_wheel_t * const p_event_wheel,
- IN const uint64_t key,
- IN const uint64_t aging_time_usec,
- IN cl_pfn_event_aged_cb_t pfn_callback,
- IN void *const context);
-/*
-* PARAMETERS
-* p_event_wheel
-* [in] Pointer to a Event_Wheel.
-*
-* key
-* [in] The specifc Key by which events are registered.
-*
-* aging_time_usec
-* [in] The absolute time this event should age in usec
-*
-* pfn_callback
-* [in] Event Aging callback. The Event_Wheel calls this
-* function after the time the event has registed for has come.
-*
-* context
-* [in] Client context value passed to the cl_pfn_event_aged_cb_t
-* function.
-*
-* RETURN VALUE
-* On success a Event_Wheel CL_SUCCESS or CL_ERROR otherwise.
-*
-* SEE ALSO
-* Event_Wheel, cl_event_wheel_unreg
-*********/
-
-/****f* Component Library: Event_Wheel/cl_event_wheel_unreg
-* NAME
-* cl_event_wheel_unreg
-*
-* DESCRIPTION
-* This function unregisters a client event from a Event_Wheel.
-*
-* SYNOPSIS
-*/
-void
-cl_event_wheel_unreg(IN cl_event_wheel_t * const p_event_wheel,
- IN uint64_t key);
-/*
-* PARAMETERS
-* p_event_wheel
-* [in] Pointer to a Event_Wheel.
-*
-* key
-* [in] The key used for registering the event
-*
-* RETURN VALUE
-* This function does not return a value.
-*
-* NOTES
-* After the event has aged it is automatically removed from
-* the event wheel. So it should only be invoked when the need arises
-* to remove existing events before they age.
-*
-* SEE ALSO
-* Event_Wheel, cl_event_wheel_reg
-*********/
-
-/****f* Component Library: Event_Wheel/cl_event_wheel_num_regs
-* NAME
-* cl_event_wheel_num_regs
-*
-* DESCRIPTION
-* This function returns the number of times an event was registered.
-*
-* SYNOPSIS
-*/
-uint32_t
-cl_event_wheel_num_regs(IN cl_event_wheel_t * const p_event_wheel,
- IN uint64_t key);
-/*
-* PARAMETERS
-* p_event_wheel
-* [in] Pointer to a Event_Wheel.
-*
-* key
-* [in] The key used for registering the event
-*
-* RETURN VALUE
-* The number of times the event was registered.
-* 0 if never registered or eventually aged.
-*
-* SEE ALSO
-* Event_Wheel, cl_event_wheel_reg, cl_event_wheel_unreg
-*********/
-
-END_C_DECLS
-#endif /* !defined(_CL_EVENT_WHEEL_H_) */
diff --git a/contrib/ofed/management/opensm/include/complib/cl_fleximap.h b/contrib/ofed/management/opensm/include/complib/cl_fleximap.h
deleted file mode 100644
index 0af8766..0000000
--- a/contrib/ofed/management/opensm/include/complib/cl_fleximap.h
+++ /dev/null
@@ -1,907 +0,0 @@
-/*
- * Copyright (c) 2004, 2005 Voltaire, Inc. All rights reserved.
- * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved.
- * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- */
-
-/*
- * Abstract:
- * Declaration of flexi map, a binary tree where the caller always provides
- * all necessary storage.
- */
-
-#ifndef _CL_FLEXIMAP_H_
-#define _CL_FLEXIMAP_H_
-
-#include <complib/cl_qmap.h>
-
-#ifdef __cplusplus
-# define BEGIN_C_DECLS extern "C" {
-# define END_C_DECLS }
-#else /* !__cplusplus */
-# define BEGIN_C_DECLS
-# define END_C_DECLS
-#endif /* __cplusplus */
-
-BEGIN_C_DECLS
-/****h* Component Library/Flexi Map
-* NAME
-* Flexi Map
-*
-* DESCRIPTION
-* Flexi map implements a binary tree that stores user provided cl_fmap_item_t
-* structures. Each item stored in a flexi map has a unique user defined
-* key (duplicates are not allowed). Flexi map provides the ability to
-* efficiently search for an item given a key. Flexi map allows user
-* defined keys of any size. Storage for keys and a comparison function
-* are provided by users to allow flexi map to store items with arbitrary
-* key values.
-*
-* Flexi map does not allocate any memory, and can therefore not fail
-* any operations due to insufficient memory. Flexi map can thus be useful
-* in minimizing the error paths in code.
-*
-* Flexi map is not thread safe, and users must provide serialization when
-* adding and removing items from the map.
-*
-* The flexi map functions operate on a cl_fmap_t structure which should
-* be treated as opaque and should be manipulated only through the provided
-* functions.
-*
-* SEE ALSO
-* Structures:
-* cl_fmap_t, cl_fmap_item_t
-*
-* Callbacks:
-* cl_pfn_fmap_apply_t
-*
-* Item Manipulation:
-* cl_fmap_key
-*
-* Initialization:
-* cl_fmap_init
-*
-* Iteration:
-* cl_fmap_end, cl_fmap_head, cl_fmap_tail, cl_fmap_next, cl_fmap_prev
-*
-* Manipulation:
-* cl_fmap_insert, cl_fmap_get, cl_fmap_remove_item, cl_fmap_remove,
-* cl_fmap_remove_all, cl_fmap_merge, cl_fmap_delta, cl_fmap_get_next
-*
-* Search:
-* cl_fmap_apply_func
-*
-* Attributes:
-* cl_fmap_count, cl_is_fmap_empty,
-*********/
-/****s* Component Library: Flexi Map/cl_fmap_item_t
-* NAME
-* cl_fmap_item_t
-*
-* DESCRIPTION
-* The cl_fmap_item_t structure is used by maps to store objects.
-*
-* The cl_fmap_item_t structure should be treated as opaque and should
-* be manipulated only through the provided functions.
-*
-* SYNOPSIS
-*/
-typedef struct _cl_fmap_item {
- /* Must be first to allow casting. */
- cl_pool_item_t pool_item;
- struct _cl_fmap_item *p_left;
- struct _cl_fmap_item *p_right;
- struct _cl_fmap_item *p_up;
- cl_map_color_t color;
- const void *p_key;
-#ifdef _DEBUG_
- struct _cl_fmap *p_map;
-#endif
-} cl_fmap_item_t;
-/*
-* FIELDS
-* pool_item
-* Used to store the item in a doubly linked list, allowing more
-* efficient map traversal.
-*
-* p_left
-* Pointer to the map item that is a child to the left of the node.
-*
-* p_right
-* Pointer to the map item that is a child to the right of the node.
-*
-* p_up
-* Pointer to the map item that is the parent of the node.
-*
-* p_nil
-* Pointer to the map's NIL item, used as a terminator for leaves.
-* The NIL sentinel is in the cl_fmap_t structure.
-*
-* color
-* Indicates whether a node is red or black in the map.
-*
-* p_key
-* Pointer to the value that uniquely represents a node in a map. This
-* pointer is set by calling cl_fmap_insert and can be retrieved by
-* calling cl_fmap_key.
-*
-* NOTES
-* None of the fields of this structure should be manipulated by users, as
-* they are crititcal to the proper operation of the map in which they
-* are stored.
-*
-* To allow storing items in either a quick list, a quick pool, or a flexi
-* map, the map implementation guarantees that the map item can be safely
-* cast to a pool item used for storing an object in a quick pool, or cast
-* to a list item used for storing an object in a quick list. This removes
-* the need to embed a flexi map item, a list item, and a pool item in
-* objects that need to be stored in a quick list, a quick pool, and a
-* flexi map.
-*
-* SEE ALSO
-* Flexi Map, cl_fmap_insert, cl_fmap_key, cl_pool_item_t, cl_list_item_t
-*********/
-
-/****d* Component Library: Flexi Map/cl_pfn_fmap_cmp_t
-* NAME
-* cl_pfn_fmap_cmp_t
-*
-* DESCRIPTION
-* The cl_pfn_fmap_cmp_t function type defines the prototype for functions
-* used to compare item keys in a flexi map.
-*
-* SYNOPSIS
-*/
-typedef intn_t
- (*cl_pfn_fmap_cmp_t) (IN const void *const p_key1,
- IN const void *const p_key2);
-/*
-* PARAMETERS
-* p_key1
-* [in] Pointer to the first of two keys to compare.
-*
-* p_key2
-* [in] Pointer to the second of two keys to compare.
-*
-* RETURN VALUE
-* Returns 0 if the keys match.
-* Returns less than 0 if *p_key1 is less than *p_key2.
-* Returns greater than 0 if *p_key1 is greater than *p_key2.
-*
-* NOTES
-* This function type is provided as function prototype reference for the
-* function provided by users as a parameter to the cl_fmap_init function.
-*
-* SEE ALSO
-* Flexi Map, cl_fmap_init
-*********/
-
-/****s* Component Library: Flexi Map/cl_fmap_t
-* NAME
-* cl_fmap_t
-*
-* DESCRIPTION
-* Flexi map structure.
-*
-* The cl_fmap_t structure should be treated as opaque and should
-* be manipulated only through the provided functions.
-*
-* SYNOPSIS
-*/
-typedef struct _cl_fmap {
- cl_fmap_item_t root;
- cl_fmap_item_t nil;
- cl_state_t state;
- size_t count;
- cl_pfn_fmap_cmp_t pfn_compare;
-} cl_fmap_t;
-/*
-* PARAMETERS
-* root
-* Map item that serves as root of the map. The root is set up to
-* always have itself as parent. The left pointer is set to point
-* to the item at the root.
-*
-* nil
-* Map item that serves as terminator for all leaves, as well as
-* providing the list item used as quick list for storing map items
-* in a list for faster traversal.
-*
-* state
-* State of the map, used to verify that operations are permitted.
-*
-* count
-* Number of items in the map.
-*
-* pfn_compare
-* Pointer to a compare function to invoke to compare the keys of
-* items in the map.
-*
-* SEE ALSO
-* Flexi Map, cl_pfn_fmap_cmp_t
-*********/
-
-/****d* Component Library: Flexi Map/cl_pfn_fmap_apply_t
-* NAME
-* cl_pfn_fmap_apply_t
-*
-* DESCRIPTION
-* The cl_pfn_fmap_apply_t function type defines the prototype for
-* functions used to iterate items in a flexi map.
-*
-* SYNOPSIS
-*/
-typedef void
- (*cl_pfn_fmap_apply_t) (IN cl_fmap_item_t * const p_map_item,
- IN void *context);
-/*
-* PARAMETERS
-* p_map_item
-* [in] Pointer to a cl_fmap_item_t structure.
-*
-* context
-* [in] Value passed to the callback function.
-*
-* RETURN VALUE
-* This function does not return a value.
-*
-* NOTES
-* This function type is provided as function prototype reference for the
-* function provided by users as a parameter to the cl_fmap_apply_func
-* function.
-*
-* SEE ALSO
-* Flexi Map, cl_fmap_apply_func
-*********/
-
-/****f* Component Library: Flexi Map/cl_fmap_count
-* NAME
-* cl_fmap_count
-*
-* DESCRIPTION
-* The cl_fmap_count function returns the number of items stored
-* in a flexi map.
-*
-* SYNOPSIS
-*/
-static inline size_t cl_fmap_count(IN const cl_fmap_t * const p_map)
-{
- CL_ASSERT(p_map);
- CL_ASSERT(p_map->state == CL_INITIALIZED);
- return (p_map->count);
-}
-
-/*
-* PARAMETERS
-* p_map
-* [in] Pointer to a cl_fmap_t structure whose item count to return.
-*
-* RETURN VALUE
-* Returns the number of items stored in the map.
-*
-* SEE ALSO
-* Flexi Map, cl_is_fmap_empty
-*********/
-
-/****f* Component Library: Flexi Map/cl_is_fmap_empty
-* NAME
-* cl_is_fmap_empty
-*
-* DESCRIPTION
-* The cl_is_fmap_empty function returns whether a flexi map is empty.
-*
-* SYNOPSIS
-*/
-static inline boolean_t cl_is_fmap_empty(IN const cl_fmap_t * const p_map)
-{
- CL_ASSERT(p_map);
- CL_ASSERT(p_map->state == CL_INITIALIZED);
-
- return (p_map->count == 0);
-}
-
-/*
-* PARAMETERS
-* p_map
-* [in] Pointer to a cl_fmap_t structure to test for emptiness.
-*
-* RETURN VALUES
-* TRUE if the flexi map is empty.
-*
-* FALSE otherwise.
-*
-* SEE ALSO
-* Flexi Map, cl_fmap_count, cl_fmap_remove_all
-*********/
-
-/****f* Component Library: Flexi Map/cl_fmap_key
-* NAME
-* cl_fmap_key
-*
-* DESCRIPTION
-* The cl_fmap_key function retrieves the key value of a map item.
-*
-* SYNOPSIS
-*/
-static inline const void *cl_fmap_key(IN const cl_fmap_item_t * const p_item)
-{
- CL_ASSERT(p_item);
- return (p_item->p_key);
-}
-
-/*
-* PARAMETERS
-* p_item
-* [in] Pointer to a map item whose key value to return.
-*
-* RETURN VALUE
-* Returns the a pointer to the key value for the specified map item.
-* The key value should not be modified to insure proper flexi map operation.
-*
-* NOTES
-* The key value is set in a call to cl_fmap_insert.
-*
-* SEE ALSO
-* Flexi Map, cl_fmap_insert
-*********/
-
-/****f* Component Library: Flexi Map/cl_fmap_init
-* NAME
-* cl_fmap_init
-*
-* DESCRIPTION
-* The cl_fmap_init function initialized a flexi map for use.
-*
-* SYNOPSIS
-*/
-void cl_fmap_init(IN cl_fmap_t * const p_map, IN cl_pfn_fmap_cmp_t pfn_compare);
-/*
-* PARAMETERS
-* p_map
-* [in] Pointer to a cl_fmap_t structure to initialize.
-*
-* pfn_compare
-* [in] Pointer to the compare function used to compare keys.
-* See the cl_pfn_fmap_cmp_t function type declaration for details
-* about the callback function.
-*
-* RETURN VALUES
-* This function does not return a value.
-*
-* NOTES
-* Allows calling flexi map manipulation functions.
-*
-* SEE ALSO
-* Flexi Map, cl_fmap_insert, cl_fmap_remove
-*********/
-
-/****f* Component Library: Flexi Map/cl_fmap_end
-* NAME
-* cl_fmap_end
-*
-* DESCRIPTION
-* The cl_fmap_end function returns the end of a flexi map.
-*
-* SYNOPSIS
-*/
-static inline const cl_fmap_item_t *cl_fmap_end(IN const cl_fmap_t *
- const p_map)
-{
- CL_ASSERT(p_map);
- CL_ASSERT(p_map->state == CL_INITIALIZED);
- /* Nil is the end of the map. */
- return (&p_map->nil);
-}
-
-/*
-* PARAMETERS
-* p_map
-* [in] Pointer to a cl_fmap_t structure whose end to return.
-*
-* RETURN VALUE
-* Pointer to the end of the map.
-*
-* NOTES
-* cl_fmap_end is useful for determining the validity of map items returned
-* by cl_fmap_head, cl_fmap_tail, cl_fmap_next, or cl_fmap_prev. If the
-* map item pointer returned by any of these functions compares to the end,
-* the end of the map was encoutered.
-* When using cl_fmap_head or cl_fmap_tail, this condition indicates that
-* the map is empty.
-*
-* SEE ALSO
-* Flexi Map, cl_fmap_head, cl_fmap_tail, cl_fmap_next, cl_fmap_prev
-*********/
-
-/****f* Component Library: Flexi Map/cl_fmap_head
-* NAME
-* cl_fmap_head
-*
-* DESCRIPTION
-* The cl_fmap_head function returns the map item with the lowest key
-* value stored in a flexi map.
-*
-* SYNOPSIS
-*/
-static inline cl_fmap_item_t *cl_fmap_head(IN const cl_fmap_t * const p_map)
-{
- CL_ASSERT(p_map);
- CL_ASSERT(p_map->state == CL_INITIALIZED);
- return ((cl_fmap_item_t *) p_map->nil.pool_item.list_item.p_next);
-}
-
-/*
-* PARAMETERS
-* p_map
-* [in] Pointer to a cl_fmap_t structure whose item with the lowest key
-* is returned.
-*
-* RETURN VALUES
-* Pointer to the map item with the lowest key in the flexi map.
-*
-* Pointer to the map end if the flexi map was empty.
-*
-* NOTES
-* cl_fmap_head does not remove the item from the map.
-*
-* SEE ALSO
-* Flexi Map, cl_fmap_tail, cl_fmap_next, cl_fmap_prev, cl_fmap_end,
-* cl_fmap_item_t
-*********/
-
-/****f* Component Library: Flexi Map/cl_fmap_tail
-* NAME
-* cl_fmap_tail
-*
-* DESCRIPTION
-* The cl_fmap_tail function returns the map item with the highest key
-* value stored in a flexi map.
-*
-* SYNOPSIS
-*/
-static inline cl_fmap_item_t *cl_fmap_tail(IN const cl_fmap_t * const p_map)
-{
- CL_ASSERT(p_map);
- CL_ASSERT(p_map->state == CL_INITIALIZED);
- return ((cl_fmap_item_t *) p_map->nil.pool_item.list_item.p_prev);
-}
-
-/*
-* PARAMETERS
-* p_map
-* [in] Pointer to a cl_fmap_t structure whose item with the highest key
-* is returned.
-*
-* RETURN VALUES
-* Pointer to the map item with the highest key in the flexi map.
-*
-* Pointer to the map end if the flexi map was empty.
-*
-* NOTES
-* cl_fmap_end does not remove the item from the map.
-*
-* SEE ALSO
-* Flexi Map, cl_fmap_head, cl_fmap_next, cl_fmap_prev, cl_fmap_end,
-* cl_fmap_item_t
-*********/
-
-/****f* Component Library: Flexi Map/cl_fmap_next
-* NAME
-* cl_fmap_next
-*
-* DESCRIPTION
-* The cl_fmap_next function returns the map item with the next higher
-* key value than a specified map item.
-*
-* SYNOPSIS
-*/
-static inline cl_fmap_item_t *cl_fmap_next(IN const cl_fmap_item_t *
- const p_item)
-{
- CL_ASSERT(p_item);
- return ((cl_fmap_item_t *) p_item->pool_item.list_item.p_next);
-}
-
-/*
-* PARAMETERS
-* p_item
-* [in] Pointer to a map item whose successor to return.
-*
-* RETURN VALUES
-* Pointer to the map item with the next higher key value in a flexi map.
-*
-* Pointer to the map end if the specified item was the last item in
-* the flexi map.
-*
-* SEE ALSO
-* Flexi Map, cl_fmap_head, cl_fmap_tail, cl_fmap_prev, cl_fmap_end,
-* cl_fmap_item_t
-*********/
-
-/****f* Component Library: Flexi Map/cl_fmap_prev
-* NAME
-* cl_fmap_prev
-*
-* DESCRIPTION
-* The cl_fmap_prev function returns the map item with the next lower
-* key value than a precified map item.
-*
-* SYNOPSIS
-*/
-static inline cl_fmap_item_t *cl_fmap_prev(IN const cl_fmap_item_t *
- const p_item)
-{
- CL_ASSERT(p_item);
- return ((cl_fmap_item_t *) p_item->pool_item.list_item.p_prev);
-}
-
-/*
-* PARAMETERS
-* p_item
-* [in] Pointer to a map item whose predecessor to return.
-*
-* RETURN VALUES
-* Pointer to the map item with the next lower key value in a flexi map.
-*
-* Pointer to the map end if the specifid item was the first item in
-* the flexi map.
-*
-* SEE ALSO
-* Flexi Map, cl_fmap_head, cl_fmap_tail, cl_fmap_next, cl_fmap_end,
-* cl_fmap_item_t
-*********/
-
-/****f* Component Library: Flexi Map/cl_fmap_insert
-* NAME
-* cl_fmap_insert
-*
-* DESCRIPTION
-* The cl_fmap_insert function inserts a map item into a flexi map.
-*
-* SYNOPSIS
-*/
-cl_fmap_item_t *cl_fmap_insert(IN cl_fmap_t * const p_map,
- IN const void *const p_key,
- IN cl_fmap_item_t * const p_item);
-/*
-* PARAMETERS
-* p_map
-* [in] Pointer to a cl_fmap_t structure into which to add the item.
-*
-* p_key
-* [in] Pointer to the key value to assign to the item. Storage
-* for the key must be persistant, as only the pointer is stored.
-* Users are responsible for maintaining the validity of key
-* pointers while they are in use.
-*
-* p_item
-* [in] Pointer to a cl_fmap_item_t stucture to insert into the flexi map.
-*
-* RETURN VALUE
-* Pointer to the item in the map with the specified key. If insertion
-* was successful, this is the pointer to the item. If an item with the
-* specified key already exists in the map, the pointer to that item is
-* returned.
-*
-* NOTES
-* Insertion operations may cause the flexi map to rebalance.
-*
-* SEE ALSO
-* Flexi Map, cl_fmap_remove, cl_fmap_item_t
-*********/
-
-/****f* Component Library: Flexi Map/cl_fmap_get
-* NAME
-* cl_fmap_get
-*
-* DESCRIPTION
-* The cl_fmap_get function returns the map item associated with a key.
-*
-* SYNOPSIS
-*/
-cl_fmap_item_t *cl_fmap_get(IN const cl_fmap_t * const p_map,
- IN const void *const p_key);
-/*
-* PARAMETERS
-* p_map
-* [in] Pointer to a cl_fmap_t structure from which to retrieve the
-* item with the specified key.
-*
-* p_key
-* [in] Pointer to a key value used to search for the desired map item.
-*
-* RETURN VALUES
-* Pointer to the map item with the desired key value.
-*
-* Pointer to the map end if there was no item with the desired key value
-* stored in the flexi map.
-*
-* NOTES
-* cl_fmap_get does not remove the item from the flexi map.
-*
-* SEE ALSO
-* Flexi Map, cl_fmap_remove, cl_fmap_get_next
-*********/
-
-/****f* Component Library: Flexi Map/cl_fmap_get_next
-* NAME
-* cl_fmap_get_next
-*
-* DESCRIPTION
-* The cl_fmap_get_next function returns the first map item associated with a
-* key > the key specified.
-*
-* SYNOPSIS
-*/
-cl_fmap_item_t *cl_fmap_get_next(IN const cl_fmap_t * const p_map,
- IN const void *const p_key);
-/*
-* PARAMETERS
-* p_map
-* [in] Pointer to a cl_fmap_t structure from which to retrieve the
-* item with the specified key.
-*
-* p_key
-* [in] Pointer to a key value used to search for the desired map item.
-*
-* RETURN VALUES
-* Pointer to the first map item with a key > the desired key value.
-*
-* Pointer to the map end if there was no item with a key > the desired key
-* value stored in the flexi map.
-*
-* NOTES
-* cl_fmap_get_next does not remove the item from the flexi map.
-*
-* SEE ALSO
-* Flexi Map, cl_fmap_remove, cl_fmap_get
-*********/
-
-/****f* Component Library: Flexi Map/cl_fmap_remove_item
-* NAME
-* cl_fmap_remove_item
-*
-* DESCRIPTION
-* The cl_fmap_remove_item function removes the specified map item
-* from a flexi map.
-*
-* SYNOPSIS
-*/
-void
-cl_fmap_remove_item(IN cl_fmap_t * const p_map,
- IN cl_fmap_item_t * const p_item);
-/*
-* PARAMETERS
-* p_item
-* [in] Pointer to a map item to remove from its flexi map.
-*
-* RETURN VALUES
-* This function does not return a value.
-*
-* In a debug build, cl_fmap_remove_item asserts that the item being
-* removed es in the specified map.
-*
-* NOTES
-* Removes the map item pointed to by p_item from its flexi map.
-*
-* SEE ALSO
-* Flexi Map, cl_fmap_remove, cl_fmap_remove_all, cl_fmap_insert
-*********/
-
-/****f* Component Library: Flexi Map/cl_fmap_remove
-* NAME
-* cl_fmap_remove
-*
-* DESCRIPTION
-* The cl_fmap_remove function removes the map item with the specified key
-* from a flexi map.
-*
-* SYNOPSIS
-*/
-cl_fmap_item_t *cl_fmap_remove(IN cl_fmap_t * const p_map,
- IN const void *const p_key);
-/*
-* PARAMETERS
-* p_map
-* [in] Pointer to a cl_fmap_t structure from which to remove the
-* item with the specified key.
-*
-* p_key
-* [in] Pointer to the key value used to search for the map item
-* to remove.
-*
-* RETURN VALUES
-* Pointer to the removed map item if it was found.
-*
-* Pointer to the map end if no item with the specified key exists in the
-* flexi map.
-*
-* SEE ALSO
-* Flexi Map, cl_fmap_remove_item, cl_fmap_remove_all, cl_fmap_insert
-*********/
-
-/****f* Component Library: Flexi Map/cl_fmap_remove_all
-* NAME
-* cl_fmap_remove_all
-*
-* DESCRIPTION
-* The cl_fmap_remove_all function removes all items in a flexi map,
-* leaving it empty.
-*
-* SYNOPSIS
-*/
-static inline void cl_fmap_remove_all(IN cl_fmap_t * const p_map)
-{
- CL_ASSERT(p_map);
- CL_ASSERT(p_map->state == CL_INITIALIZED);
-
- p_map->root.p_left = &p_map->nil;
- p_map->nil.pool_item.list_item.p_next = &p_map->nil.pool_item.list_item;
- p_map->nil.pool_item.list_item.p_prev = &p_map->nil.pool_item.list_item;
- p_map->count = 0;
-}
-
-/*
-* PARAMETERS
-* p_map
-* [in] Pointer to a cl_fmap_t structure to empty.
-*
-* RETURN VALUES
-* This function does not return a value.
-*
-* SEE ALSO
-* Flexi Map, cl_fmap_remove, cl_fmap_remove_item
-*********/
-
-/****f* Component Library: Flexi Map/cl_fmap_merge
-* NAME
-* cl_fmap_merge
-*
-* DESCRIPTION
-* The cl_fmap_merge function moves all items from one map to another,
-* excluding duplicates.
-*
-* SYNOPSIS
-*/
-void
-cl_fmap_merge(OUT cl_fmap_t * const p_dest_map,
- IN OUT cl_fmap_t * const p_src_map);
-/*
-* PARAMETERS
-* p_dest_map
-* [out] Pointer to a cl_fmap_t structure to which items should be added.
-*
-* p_src_map
-* [in/out] Pointer to a cl_fmap_t structure whose items to add
-* to p_dest_map.
-*
-* RETURN VALUES
-* This function does not return a value.
-*
-* NOTES
-* Items are evaluated based on their keys only.
-*
-* Upon return from cl_fmap_merge, the flexi map referenced by p_src_map
-* contains all duplicate items.
-*
-* SEE ALSO
-* Flexi Map, cl_fmap_delta
-*********/
-
-/****f* Component Library: Flexi Map/cl_fmap_delta
-* NAME
-* cl_fmap_delta
-*
-* DESCRIPTION
-* The cl_fmap_delta function computes the differences between two maps.
-*
-* SYNOPSIS
-*/
-void
-cl_fmap_delta(IN OUT cl_fmap_t * const p_map1,
- IN OUT cl_fmap_t * const p_map2,
- OUT cl_fmap_t * const p_new, OUT cl_fmap_t * const p_old);
-/*
-* PARAMETERS
-* p_map1
-* [in/out] Pointer to the first of two cl_fmap_t structures whose
-* differences to compute.
-*
-* p_map2
-* [in/out] Pointer to the second of two cl_fmap_t structures whose
-* differences to compute.
-*
-* p_new
-* [out] Pointer to an empty cl_fmap_t structure that contains the
-* items unique to p_map2 upon return from the function.
-*
-* p_old
-* [out] Pointer to an empty cl_fmap_t structure that contains the
-* items unique to p_map1 upon return from the function.
-*
-* RETURN VALUES
-* This function does not return a value.
-*
-* NOTES
-* Items are evaluated based on their keys. Items that exist in both
-* p_map1 and p_map2 remain in their respective maps. Items that
-* exist only p_map1 are moved to p_old. Likewise, items that exist only
-* in p_map2 are moved to p_new. This function can be useful in evaluating
-* changes between two maps.
-*
-* Both maps pointed to by p_new and p_old must be empty on input. This
-* requirement removes the possibility of failures.
-*
-* SEE ALSO
-* Flexi Map, cl_fmap_merge
-*********/
-
-/****f* Component Library: Flexi Map/cl_fmap_apply_func
-* NAME
-* cl_fmap_apply_func
-*
-* DESCRIPTION
-* The cl_fmap_apply_func function executes a specified function
-* for every item stored in a flexi map.
-*
-* SYNOPSIS
-*/
-void
-cl_fmap_apply_func(IN const cl_fmap_t * const p_map,
- IN cl_pfn_fmap_apply_t pfn_func,
- IN const void *const context);
-/*
-* PARAMETERS
-* p_map
-* [in] Pointer to a cl_fmap_t structure.
-*
-* pfn_func
-* [in] Function invoked for every item in the flexi map.
-* See the cl_pfn_fmap_apply_t function type declaration for
-* details about the callback function.
-*
-* context
-* [in] Value to pass to the callback functions to provide context.
-*
-* RETURN VALUE
-* This function does not return a value.
-*
-* NOTES
-* The function provided must not perform any map operations, as these
-* would corrupt the flexi map.
-*
-* SEE ALSO
-* Flexi Map, cl_pfn_fmap_apply_t
-*********/
-
-END_C_DECLS
-#endif /* _CL_FLEXIMAP_H_ */
diff --git a/contrib/ofed/management/opensm/include/complib/cl_nodenamemap.h b/contrib/ofed/management/opensm/include/complib/cl_nodenamemap.h
deleted file mode 100644
index 9b2ada4..0000000
--- a/contrib/ofed/management/opensm/include/complib/cl_nodenamemap.h
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * Copyright (c) 2008 Voltaire, Inc. All rights reserved.
- * Copyright (c) 2007 Lawrence Livermore National Lab
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- */
-
-#ifndef _CL_NODE_NAME_MAP_H_
-#define _CL_NODE_NAME_MAP_H_
-
-#include <stdio.h>
-#include <stdint.h>
-#include <complib/cl_qmap.h>
-
-/* NOTE: this may modify the parameter "nodedesc". */
-char *clean_nodedesc(char *nodedesc);
-
-typedef struct _name_map_item {
- cl_map_item_t item;
- uint64_t guid;
- char *name;
-} name_map_item_t;
-
-typedef cl_qmap_t nn_map_t;
-
-/**
- * Node name map interface.
- * It is OK to pass NULL for the node_name_map[_fp] parameters.
- */
-nn_map_t *open_node_name_map(char *node_name_map);
-void close_node_name_map(nn_map_t *map);
-char *remap_node_name(nn_map_t *map, uint64_t target_guid,
- char *nodedesc);
- /* NOTE: parameter "nodedesc" may be modified here. */
-int parse_node_map(const char *file_name,
- int (*create)(void *, uint64_t, char *), void *cxt);
-
-#endif /* _CL_NODE_NAME_MAP_H_ */
diff --git a/contrib/ofed/management/opensm/include/complib/cl_packon.h b/contrib/ofed/management/opensm/include/complib/cl_packon.h
deleted file mode 100644
index ffc8e11..0000000
--- a/contrib/ofed/management/opensm/include/complib/cl_packon.h
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- * Copyright (c) 2004, 2005 Voltaire, Inc. All rights reserved.
- * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved.
- * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- */
-
-/*
- * Abstract:
- * Turns on byte packing, which is necessary for passing information from
- * system to system over a network to ensure no padding by the compiler has
- * taken place.
- */
-
-/****h* Component Library/Structure Packing
-* NAME
-* Structure Packing
-*
-* DESCRIPTION
-* The structure packing header files allow packing structures on byte
-* boundaries.
-*
-* Structure packing should be used whenever a structure is transmitted
-* between systems, as different platforms pad structures differently if
-* they are not packed. Packing a structure that is not transmitted between
-* systems can be detrimental to performance, as fields in the structure may
-* not align properly for some platforms. Care must be taken when creating
-* packed structures that the alignment rules for all platforms are followed.
-*
-* To pack a structure, include ipackon.h before defining the structure, and
-* include ipackoff.h after the structure definition. Multiple structures
-* can be packed between the two include statements if desired.
-*
-* The structure definition itself must use the PACK_SUFFIX keyword.
-*
-* EXAMPLE
-* #include <complib/ipackon.h>
-*
-* typedef _my_struct_t
-* {
-* uint64 large;
-* uint32 medium;
-* uint16 small;
-*
-* } PACK_SUFFIX my_struct_t;
-* #include <complib/ipackoff.h>
-*********/
-
-#ifndef PACK_SUFFIX
-#define PACK_SUFFIX __attribute__((packed))
-#endif
-
-#ifdef _MSC_VER
-#pragma pack (push, 1)
-#endif
diff --git a/contrib/ofed/management/opensm/include/complib/cl_passivelock.h b/contrib/ofed/management/opensm/include/complib/cl_passivelock.h
deleted file mode 100644
index bafd339..0000000
--- a/contrib/ofed/management/opensm/include/complib/cl_passivelock.h
+++ /dev/null
@@ -1,323 +0,0 @@
-/*
- * Copyright (c) 2004, 2005 Voltaire, Inc. All rights reserved.
- * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved.
- * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- */
-
-/*
- * Abstract:
- * This file contains the passive lock, which synchronizes passive threads.
- * The passive lock allows multiple readers to access a resource
- * simultaneously, exclusive from a single thread allowed writing.
- * Several writer threads are allowed - but only one can write at a given time
- */
-
-#ifndef _CL_PASSIVE_LOCK_H_
-#define _CL_PASSIVE_LOCK_H_
-#include <complib/cl_types.h>
-#include <pthread.h>
-
-#ifdef __cplusplus
-# define BEGIN_C_DECLS extern "C" {
-# define END_C_DECLS }
-#else /* !__cplusplus */
-# define BEGIN_C_DECLS
-# define END_C_DECLS
-#endif /* __cplusplus */
-
-BEGIN_C_DECLS
-/****h* Component Library/Passive Lock
-* NAME
-* Passive Lock
-*
-* DESCRIPTION
-* The Passive Lock provides synchronization between multiple threads that
-* are sharing the lock with a single thread holding the lock exclusively.
-*
-* Passive lock works exclusively between threads and cannot be used in
-* situations where the caller cannot be put into a waiting state.
-*
-* The passive lock functions operate a cl_plock_t structure which should
-* be treated as opaque and should be manipulated only through the provided
-* functions.
-*
-* SEE ALSO
-* Structures:
-* cl_plock_t
-*
-* Initialization:
-* cl_plock_construct, cl_plock_init, cl_plock_destroy
-*
-* Manipulation
-* cl_plock_acquire, cl_plock_excl_acquire, cl_plock_release
-*********/
-/****s* Component Library: Passive Lock/cl_plock_t
-* NAME
-* cl_plock_t
-*
-* DESCRIPTION
-* Passive Lock structure.
-*
-* The cl_plock_t structure should be treated as opaque and should
-* be manipulated only through the provided functions.
-*
-* SYNOPSIS
-*/
-typedef struct _cl_plock {
- pthread_rwlock_t lock;
- cl_state_t state;
-} cl_plock_t;
-/*
-* FIELDS
-* lock
-* Pthread RWLOCK object
-*
-* state
-* Records the current state of the lock, such as initialized,
-* destroying, etc.
-*
-* SEE ALSO
-* Passive Lock
-*********/
-
-/****f* Component Library: Passive Lock/cl_plock_construct
-* NAME
-* cl_plock_construct
-*
-* DESCRIPTION
-* The cl_plock_construct function initializes the state of a
-* passive lock.
-*
-* SYNOPSIS
-*/
-static inline void cl_plock_construct(IN cl_plock_t * const p_lock)
-{
- CL_ASSERT(p_lock);
-
- p_lock->state = CL_UNINITIALIZED;
-}
-
-/*
-* PARAMETERS
-* p_lock
-* [in] Pointer to a cl_plock_t structure whose state to initialize.
-*
-* RETURN VALUE
-* This function does not return a value.
-*
-* NOTES
-* Allows calling cl_plock_destroy without first calling cl_plock_init.
-*
-* Calling cl_plock_construct is a prerequisite to calling any other
-* passive lock function except cl_plock_init.
-*
-* SEE ALSO
-* Passive Lock, cl_plock_init, cl_plock_destroy
-*********/
-
-/****f* Component Library: Passive Lock/cl_plock_destroy
-* NAME
-* cl_plock_destroy
-*
-* DESCRIPTION
-* The cl_plock_destroy function performs any necessary cleanup
-* of a passive lock.
-*
-* SYNOPSIS
-*/
-static inline void cl_plock_destroy(IN cl_plock_t * const p_lock)
-{
- CL_ASSERT(p_lock);
- p_lock->state = CL_DESTROYING;
- pthread_rwlock_destroy(&p_lock->lock);
- p_lock->state = CL_DESTROYED;
-}
-
-/*
-* PARAMETERS
-* p_lock
-* [in] Pointer to a cl_plock_t structure whose state to initialize.
-*
-* RETURN VALUE
-* This function does not return a value.
-*
-* NOTES
-* cl_plock_destroy performs any necessary cleanup of the specified
-* passive lock.
-*
-* This function must only be called if cl_plock_construct or
-* cl_plock_init has been called. The passive lock must not be held
-* when calling this function.
-*
-* SEE ALSO
-* Passive Lock, cl_plock_construct, cl_plock_init
-*********/
-
-/****f* Component Library: Passive Lock/cl_plock_init
-* NAME
-* cl_plock_init
-*
-* DESCRIPTION
-* The cl_plock_init function initializes a passive lock.
-*
-* SYNOPSIS
-*/
-static inline cl_status_t cl_plock_init(IN cl_plock_t * const p_lock)
-{
- cl_status_t status;
-
- CL_ASSERT(p_lock);
- status = (cl_status_t) pthread_rwlock_init(&p_lock->lock, NULL);
- if (status)
- return CL_ERROR;
- p_lock->state = CL_INITIALIZED;
- return (CL_SUCCESS);
-}
-
-/*
-* PARAMETERS
-* p_lock
-* [in] Pointer to a cl_plock_t structure to initialize.
-*
-* RETURN VALUES
-* CL_SUCCESS if the passive lock was initialized successfully.
-*
-* CL_ERROR otherwise.
-*
-* NOTES
-* Allows calling cl_plock_acquire, cl_plock_release,
-* cl_plock_excl_acquire
-*
-* SEE ALSO
-* Passive Lock, cl_plock_construct, cl_plock_destroy,
-* cl_plock_excl_acquire, cl_plock_acquire, cl_plock_release
-*********/
-
-/****f* Component Library: Passive Lock/cl_plock_acquire
-* NAME
-* cl_plock_acquire
-*
-* DESCRIPTION
-* The cl_plock_acquire function acquires a passive lock for
-* shared access.
-*
-* SYNOPSIS
-*/
-static inline void cl_plock_acquire(IN cl_plock_t * const p_lock)
-{
- cl_status_t status;
- CL_ASSERT(p_lock);
- CL_ASSERT(p_lock->state == CL_INITIALIZED);
-
- status = (cl_status_t) pthread_rwlock_rdlock(&p_lock->lock);
- CL_ASSERT(status == 0);
-}
-
-/*
-* PARAMETERS
-* p_lock
-* [in] Pointer to a cl_plock_t structure to acquire.
-*
-* RETURN VALUE
-* This function does not return a value.
-*
-* SEE ALSO
-* Passive Lock, cl_plock_release, cl_plock_excl_acquire
-*********/
-
-/****f* Component Library: Passive Lock/cl_plock_excl_acquire
-* NAME
-* cl_plock_excl_acquire
-*
-* DESCRIPTION
-* The cl_plock_excl_acquire function acquires exclusive access
-* to a passive lock.
-*
-* SYNOPSIS
-*/
-static inline void cl_plock_excl_acquire(IN cl_plock_t * const p_lock)
-{
- cl_status_t status;
-
- CL_ASSERT(p_lock);
- CL_ASSERT(p_lock->state == CL_INITIALIZED);
-
- status = (cl_status_t) pthread_rwlock_wrlock(&p_lock->lock);
- CL_ASSERT(status == 0);
-}
-
-/*
-* PARAMETERS
-* p_lock
-* [in] Pointer to a cl_plock_t structure to acquire exclusively.
-*
-* RETURN VALUE
-* This function does not return a value.
-*
-* SEE ALSO
-* Passive Lock, cl_plock_release, cl_plock_acquire
-*********/
-
-/****f* Component Library: Passive Lock/cl_plock_release
-* NAME
-* cl_plock_release
-*
-* DESCRIPTION
-* The cl_plock_release function releases a passive lock from
-* shared or exclusive access.
-*
-* SYNOPSIS
-*/
-static inline void cl_plock_release(IN cl_plock_t * const p_lock)
-{
- cl_status_t status;
- CL_ASSERT(p_lock);
- CL_ASSERT(p_lock->state == CL_INITIALIZED);
-
- status = (cl_status_t) pthread_rwlock_unlock(&p_lock->lock);
- CL_ASSERT(status == 0);
-}
-
-/*
-* PARAMETERS
-* p_lock
-* [in] Pointer to a cl_plock_t structure to release.
-*
-* RETURN VALUE
-* This function does not return a value.
-*
-* SEE ALSO
-* Passive Lock, cl_plock_acquire, cl_plock_excl_acquire
-*********/
-
-END_C_DECLS
-#endif /* _CL_PASSIVE_LOCK_H_ */
diff --git a/contrib/ofed/management/opensm/include/complib/cl_ptr_vector.h b/contrib/ofed/management/opensm/include/complib/cl_ptr_vector.h
deleted file mode 100644
index d4af0fe..0000000
--- a/contrib/ofed/management/opensm/include/complib/cl_ptr_vector.h
+++ /dev/null
@@ -1,825 +0,0 @@
-/*
- * Copyright (c) 2004, 2005 Voltaire, Inc. All rights reserved.
- * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved.
- * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- */
-
-/*
- * Abstract:
- * This file contains pointer vector definitions. Pointer Vector provides
- * dynmically resizable array functionality.
- */
-
-#ifndef _CL_PTR_VECTOR_H_
-#define _CL_PTR_VECTOR_H_
-
-#include <complib/cl_types.h>
-
-#ifdef __cplusplus
-# define BEGIN_C_DECLS extern "C" {
-# define END_C_DECLS }
-#else /* !__cplusplus */
-# define BEGIN_C_DECLS
-# define END_C_DECLS
-#endif /* __cplusplus */
-
-BEGIN_C_DECLS
-/****h* Component Library/Pointer Vector
-* NAME
-* Pointer Vector
-*
-* DESCRIPTION
-* The Pointer Vector is a self-sizing array of pointers. Like a traditonal
-* array, a pointer vector allows efficient constant time access to elements
-* with a specified index. A pointer vector grows transparently as the
-* user adds elements to the array.
-*
-* The cl_pointer vector_t structure should be treated as opaque and should be
-* manipulated only through the provided functions.
-*
-* SEE ALSO
-* Structures:
-* cl_ptr_vector_t
-*
-* Callbacks:
-* cl_pfn_ptr_vec_apply_t, cl_pfn_ptr_vec_find_t
-*
-* Item Manipulation:
-* cl_ptr_vector_set, cl_ptr_vector_obj
-*
-* Initialization:
-* cl_ptr_vector_construct, cl_ptr_vector_init, cl_ptr_vector_destroy
-*
-* Manipulation:
-* cl_ptr_vector_get_capacity, cl_ptr_vector_set_capacity,
-* cl_ptr_vector_get_size, cl_ptr_vector_set_size, cl_ptr_vector_set_min_size
-* cl_ptr_vector_get_ptr, cl_ptr_vector_get, cl_ptr_vector_at, cl_ptr_vector_set
-*
-* Search:
-* cl_ptr_vector_find_from_start, cl_ptr_vector_find_from_end
-* cl_ptr_vector_apply_func
-*********/
-/****d* Component Library: Pointer Vector/cl_pfn_ptr_vec_apply_t
-* NAME
-* cl_pfn_ptr_vec_apply_t
-*
-* DESCRIPTION
-* The cl_pfn_ptr_vec_apply_t function type defines the prototype for
-* functions used to iterate elements in a pointer vector.
-*
-* SYNOPSIS
-*/
-typedef void
- (*cl_pfn_ptr_vec_apply_t) (IN const size_t index,
- IN void *const element, IN void *context);
-/*
-* PARAMETERS
-* index
-* [in] Index of the element.
-*
-* p_element
-* [in] Pointer to an element at the specified index in the pointer vector.
-*
-* context
-* [in] Context provided in a call to cl_ptr_vector_apply_func.
-*
-* RETURN VALUE
-* This function does not return a value.
-*
-* NOTES
-* This function type is provided as function prototype reference for
-* the function passed by users as a parameter to the cl_ptr_vector_apply_func
-* function.
-*
-* SEE ALSO
-* Pointer Vector, cl_ptr_vector_apply_func
-*********/
-
-/****d* Component Library: Pointer Vector/cl_pfn_ptr_vec_find_t
-* NAME
-* cl_pfn_ptr_vec_find_t
-*
-* DESCRIPTION
-* The cl_pfn_ptr_vec_find_t function type defines the prototype for
-* functions used to find elements in a pointer vector.
-*
-* SYNOPSIS
-*/
-typedef cl_status_t
- (*cl_pfn_ptr_vec_find_t) (IN const size_t index,
- IN const void *const element, IN void *context);
-/*
-* PARAMETERS
-* index
-* [in] Index of the element.
-*
-* p_element
-* [in] Pointer to an element at the specified index in the
-* pointer vector.
-*
-* context
-* [in] Context provided in a call to cl_ptr_vector_find_from_start or
-* cl_ptr_vector_find_from_end.
-*
-* RETURN VALUES
-* Return CL_SUCCESS if the element was found. This stops pointer vector
-* iteration.
-*
-* CL_NOT_FOUND to continue the pointer vector iteration.
-*
-* NOTES
-* This function type is provided as function prototype reference for the
-* function provided by users as a parameter to the
-* cl_ptr_vector_find_from_start and cl_ptr_vector_find_from_end functions.
-*
-* SEE ALSO
-* Pointer Vector, cl_ptr_vector_find_from_start, cl_ptr_vector_find_from_end
-*********/
-
-/****s* Component Library: Pointer Vector/cl_ptr_vector_t
-* NAME
-* cl_ptr_vector_t
-*
-* DESCRIPTION
-* Pointer Vector structure.
-*
-* The cl_ptr_vector_t structure should be treated as opaque and should be
-* manipulated only through the provided functions.
-*
-* SYNOPSIS
-*/
-typedef struct _cl_ptr_vector {
- size_t size;
- size_t grow_size;
- size_t capacity;
- const void **p_ptr_array;
- cl_state_t state;
-} cl_ptr_vector_t;
-/*
-* FIELDS
-* size
-* Number of elements successfully initialized in the pointer vector.
-*
-* grow_size
-* Number of elements to allocate when growing.
-*
-* capacity
-* total # of elements allocated.
-*
-* alloc_list
-* List of allocations.
-*
-* p_ptr_array
-* Internal array of pointers to elements.
-*
-* state
-* State of the pointer vector.
-*
-* SEE ALSO
-* Pointer Vector
-*********/
-
-/****f* Component Library: Pointer Vector/cl_ptr_vector_construct
-* NAME
-* cl_ptr_vector_construct
-*
-* DESCRIPTION
-* The cl_ptr_vector_construct function constructs a pointer vector.
-*
-* SYNOPSIS
-*/
-void cl_ptr_vector_construct(IN cl_ptr_vector_t * const p_vector);
-/*
-* PARAMETERS
-* p_vector
-* [in] Pointer to a cl_ptr_vector_t structure to construct.
-*
-* RETURN VALUE
-* This function does not return a value.
-*
-* NOTES
-* Allows calling cl_ptr_vector_destroy without first calling
-* cl_ptr_vector_init.
-*
-* Calling cl_ptr_vector_construct is a prerequisite to calling any other
-* pointer vector function except cl_ptr_vector_init.
-*
-* SEE ALSO
-* Pointer Vector, cl_ptr_vector_init, cl_ptr_vector_destroy
-*********/
-
-/****f* Component Library: Pointer Vector/cl_ptr_vector_init
-* NAME
-* cl_ptr_vector_init
-*
-* DESCRIPTION
-* The cl_ptr_vector_init function initializes a pointer vector for use.
-*
-* SYNOPSIS
-*/
-cl_status_t
-cl_ptr_vector_init(IN cl_ptr_vector_t * const p_vector,
- IN const size_t min_size, IN const size_t grow_size);
-/*
-* PARAMETERS
-* p_vector
-* [in] Pointer to a cl_ptr_vector_t structure to inititalize.
-*
-* initial_size
-* [in] Initial number of elements.
-*
-* grow_size
-* [in] Number of elements to allocate when incrementally growing
-* the pointer vector. A value of zero disables automatic growth.
-*
-* RETURN VALUES
-* CL_SUCCESS if the pointer vector was initialized successfully.
-*
-* CL_INSUFFICIENT_MEMORY if the initialization failed.
-*
-* SEE ALSO
-* Pointer Vector, cl_ptr_vector_construct, cl_ptr_vector_destroy,
-* cl_ptr_vector_set, cl_ptr_vector_get, cl_ptr_vector_at
-*********/
-
-/****f* Component Library: Pointer Vector/cl_ptr_vector_destroy
-* NAME
-* cl_ptr_vector_destroy
-*
-* DESCRIPTION
-* The cl_ptr_vector_destroy function destroys a pointer vector.
-*
-* SYNOPSIS
-*/
-void cl_ptr_vector_destroy(IN cl_ptr_vector_t * const p_vector);
-/*
-* PARAMETERS
-* p_vector
-* [in] Pointer to a cl_ptr_vector_t structure to destroy.
-*
-* RETURN VALUE
-* This function does not return a value.
-*
-* NOTES
-* cl_ptr_vector_destroy frees all memory allocated for the pointer vector.
-*
-* This function should only be called after a call to cl_ptr_vector_construct
-* or cl_ptr_vector_init.
-*
-* SEE ALSO
-* Pointer Vector, cl_ptr_vector_construct, cl_ptr_vector_init
-*********/
-
-/****f* Component Library: Pointer Vector/cl_ptr_vector_get_capacity
-* NAME
-* cl_ptr_vector_get_capacity
-*
-* DESCRIPTION
-* The cl_ptr_vector_get_capacity function returns the capacity of
-* a pointer vector.
-*
-* SYNOPSIS
-*/
-static inline size_t
-cl_ptr_vector_get_capacity(IN const cl_ptr_vector_t * const p_vector)
-{
- CL_ASSERT(p_vector);
- CL_ASSERT(p_vector->state == CL_INITIALIZED);
-
- return (p_vector->capacity);
-}
-
-/*
-* PARAMETERS
-* p_vector
-* [in] Pointer to a cl_ptr_vector_t structure whose capacity to return.
-*
-* RETURN VALUE
-* Capacity, in elements, of the pointer vector.
-*
-* NOTES
-* The capacity is the number of elements that the pointer vector can store,
-* and can be greater than the number of elements stored. To get the number
-* of elements stored in the pointer vector, use cl_ptr_vector_get_size.
-*
-* SEE ALSO
-* Pointer Vector, cl_ptr_vector_set_capacity, cl_ptr_vector_get_size
-*********/
-
-/****f* Component Library: Pointer Vector/cl_ptr_vector_get_size
-* NAME
-* cl_ptr_vector_get_size
-*
-* DESCRIPTION
-* The cl_ptr_vector_get_size function returns the size of a pointer vector.
-*
-* SYNOPSIS
-*/
-static inline uint32_t
-cl_ptr_vector_get_size(IN const cl_ptr_vector_t * const p_vector)
-{
- CL_ASSERT(p_vector);
- CL_ASSERT(p_vector->state == CL_INITIALIZED);
- return ((uint32_t) p_vector->size);
-
-}
-
-/*
-* PARAMETERS
-* p_vector
-* [in] Pointer to a cl_ptr_vector_t structure whose size to return.
-*
-* RETURN VALUE
-* Size, in elements, of the pointer vector.
-*
-* SEE ALSO
-* Pointer Vector, cl_ptr_vector_set_size, cl_ptr_vector_get_capacity
-*********/
-
-/****f* Component Library: Pointer Vector/cl_ptr_vector_get
-* NAME
-* cl_ptr_vector_get
-*
-* DESCRIPTION
-* The cl_ptr_vector_get function returns the pointer stored in a
-* pointer vector at a specified index.
-*
-* SYNOPSIS
-*/
-static inline void *cl_ptr_vector_get(IN const cl_ptr_vector_t * const p_vector,
- IN const size_t index)
-{
- CL_ASSERT(p_vector);
- CL_ASSERT(p_vector->state == CL_INITIALIZED);
- CL_ASSERT(p_vector->size > index);
-
- return ((void *)p_vector->p_ptr_array[index]);
-}
-
-/*
-* PARAMETERS
-* p_vector
-* [in] Pointer to a cl_ptr_vector_t structure from which to get an
-* element.
-*
-* index
-* [in] Index of the element.
-*
-* RETURN VALUE
-* Value of the pointer stored at the specified index.
-*
-* NOTES
-* cl_ptr_vector_get provides constant access times regardless of the index.
-*
-* cl_ptr_vector_get does not perform boundary checking. Callers are
-* responsible for providing an index that is within the range of the pointer
-* vector.
-*
-* SEE ALSO
-* Pointer Vector, cl_ptr_vector_at, cl_ptr_vector_set, cl_ptr_vector_get_size
-*********/
-
-/****f* Component Library: Pointer Vector/cl_ptr_vector_at
-* NAME
-* cl_ptr_vector_at
-*
-* DESCRIPTION
-* The cl_ptr_vector_at function copies an element stored in a pointer
-* vector at a specified index, performing boundary checks.
-*
-* SYNOPSIS
-*/
-cl_status_t
-cl_ptr_vector_at(IN const cl_ptr_vector_t * const p_vector,
- IN const size_t index, OUT void **const p_element);
-/*
-* PARAMETERS
-* p_vector
-* [in] Pointer to a cl_ptr_vector_t structure from which to get a copy of
-* an element.
-*
-* index
-* [in] Index of the element.
-*
-* p_element
-* [out] Pointer to storage for the pointer element. Contains a copy of
-* the desired pointer upon successful completion of the call.
-*
-* RETURN VALUES
-* CL_SUCCESS if an element was found at the specified index.
-*
-* CL_INVALID_SETTING if the index was out of range.
-*
-* NOTES
-* cl_ptr_vector_at provides constant time access regardless of
-* the index, and performs boundary checking on the pointer vector.
-*
-* Upon success, the p_element parameter contains a copy of the
-* desired element.
-*
-* SEE ALSO
-* Pointer Vector, cl_ptr_vector_get
-*********/
-
-/****f* Component Library: Pointer Vector/cl_ptr_vector_set
-* NAME
-* cl_ptr_vector_set
-*
-* DESCRIPTION
-* The cl_ptr_vector_set function sets the element at the specified index.
-*
-* SYNOPSIS
-*/
-cl_status_t
-cl_ptr_vector_set(IN cl_ptr_vector_t * const p_vector,
- IN const size_t index, IN const void *const element);
-/*
-* PARAMETERS
-* p_vector
-* [in] Pointer to a cl_ptr_vector_t structure into which to store
-* an element.
-*
-* index
-* [in] Index of the element.
-*
-* element
-* [in] Pointer to store in the pointer vector.
-*
-* RETURN VALUES
-* CL_SUCCESS if the element was successfully set.
-*
-* CL_INSUFFICIENT_MEMORY if the pointer vector could not be resized to
-* accommodate the new element.
-*
-* NOTES
-* cl_ptr_vector_set grows the pointer vector as needed to accommodate
-* the new element, unless the grow_size parameter passed into the
-* cl_ptr_vector_init function was zero.
-*
-* SEE ALSO
-* Pointer Vector, cl_ptr_vector_get
-*********/
-
-/****f* Component Library: Pointer Vector/cl_ptr_vector_insert
-* NAME
-* cl_ptr_vector_insert
-*
-* DESCRIPTION
-* The cl_ptr_vector_insert function inserts an element into a pointer vector.
-*
-* SYNOPSIS
-*/
-static inline cl_status_t
-cl_ptr_vector_insert(IN cl_ptr_vector_t * const p_vector,
- IN const void *const element,
- OUT size_t * const p_index OPTIONAL)
-{
- cl_status_t status;
-
- CL_ASSERT(p_vector);
- CL_ASSERT(p_vector->state == CL_INITIALIZED);
-
- status = cl_ptr_vector_set(p_vector, p_vector->size, element);
- if (status == CL_SUCCESS && p_index)
- *p_index = p_vector->size - 1;
-
- return (status);
-}
-
-/*
-* PARAMETERS
-* p_vector
-* [in] Pointer to a cl_ptr_vector_t structure into which to store
-* an element.
-*
-* element
-* [in] Pointer to store in the pointer vector.
-*
-* p_index
-* [out] Pointer to the index of the element. Valid only if
-* insertion was successful.
-*
-* RETURN VALUES
-* CL_SUCCESS if the element was successfully inserted.
-*
-* CL_INSUFFICIENT_MEMORY if the pointer vector could not be resized to
-* accommodate the new element.
-*
-* NOTES
-* cl_ptr_vector_insert places the new element at the end of
-* the pointer vector.
-*
-* cl_ptr_vector_insert grows the pointer vector as needed to accommodate
-* the new element, unless the grow_size parameter passed into the
-* cl_ptr_vector_init function was zero.
-*
-* SEE ALSO
-* Pointer Vector, cl_ptr_vector_remove, cl_ptr_vector_set
-*********/
-
-/****f* Component Library: Pointer Vector/cl_ptr_vector_remove
-* NAME
-* cl_ptr_vector_remove
-*
-* DESCRIPTION
-* The cl_ptr_vector_remove function removes and returns the pointer stored
-* in a pointer vector at a specified index. Items beyond the removed item
-* are shifted down and the size of the pointer vector is decremented.
-*
-* SYNOPSIS
-*/
-void *cl_ptr_vector_remove(IN cl_ptr_vector_t * const p_vector,
- IN const size_t index);
-/*
-* PARAMETERS
-* p_vector
-* [in] Pointer to a cl_ptr_vector_t structure from which to get an
-* element.
-*
-* index
-* [in] Index of the element.
-*
-* RETURN VALUE
-* Value of the pointer stored at the specified index.
-*
-* NOTES
-* cl_ptr_vector_get does not perform boundary checking. Callers are
-* responsible for providing an index that is within the range of the pointer
-* vector.
-*
-* SEE ALSO
-* Pointer Vector, cl_ptr_vector_insert, cl_ptr_vector_get_size
-*********/
-
-/****f* Component Library: Pointer Vector/cl_ptr_vector_set_capacity
-* NAME
-* cl_ptr_vector_set_capacity
-*
-* DESCRIPTION
-* The cl_ptr_vector_set_capacity function reserves memory in a
-* pointer vector for a specified number of pointers.
-*
-* SYNOPSIS
-*/
-cl_status_t
-cl_ptr_vector_set_capacity(IN cl_ptr_vector_t * const p_vector,
- IN const size_t new_capacity);
-/*
-* PARAMETERS
-* p_vector
-* [in] Pointer to a cl_ptr_vector_t structure whose capacity to set.
-*
-* new_capacity
-* [in] Total number of elements for which the pointer vector should
-* allocate memory.
-*
-* RETURN VALUES
-* CL_SUCCESS if the capacity was successfully set.
-*
-* CL_INSUFFICIENT_MEMORY if there was not enough memory to satisfy the
-* operation. The pointer vector is left unchanged.
-*
-* NOTES
-* cl_ptr_vector_set_capacity increases the capacity of the pointer vector.
-* It does not change the size of the pointer vector. If the requested
-* capacity is less than the current capacity, the pointer vector is left
-* unchanged.
-*
-* SEE ALSO
-* Pointer Vector, cl_ptr_vector_get_capacity, cl_ptr_vector_set_size,
-* cl_ptr_vector_set_min_size
-*********/
-
-/****f* Component Library: Pointer Vector/cl_ptr_vector_set_size
-* NAME
-* cl_ptr_vector_set_size
-*
-* DESCRIPTION
-* The cl_ptr_vector_set_size function resizes a pointer vector, either
-* increasing or decreasing its size.
-*
-* SYNOPSIS
-*/
-cl_status_t
-cl_ptr_vector_set_size(IN cl_ptr_vector_t * const p_vector,
- IN const size_t size);
-/*
-* PARAMETERS
-* p_vector
-* [in] Pointer to a cl_ptr_vector_t structure whose size to set.
-*
-* size
-* [in] Number of elements desired in the pointer vector.
-*
-* RETURN VALUES
-* CL_SUCCESS if the size of the pointer vector was set successfully.
-*
-* CL_INSUFFICIENT_MEMORY if there was not enough memory to complete the
-* operation. The pointer vector is left unchanged.
-*
-* NOTES
-* cl_ptr_vector_set_size sets the pointer vector to the specified size.
-* If size is smaller than the current size of the pointer vector, the size
-* is reduced.
-*
-* This function can only fail if size is larger than the current capacity.
-*
-* SEE ALSO
-* Pointer Vector, cl_ptr_vector_get_size, cl_ptr_vector_set_min_size,
-* cl_ptr_vector_set_capacity
-*********/
-
-/****f* Component Library: Pointer Vector/cl_ptr_vector_set_min_size
-* NAME
-* cl_ptr_vector_set_min_size
-*
-* DESCRIPTION
-* The cl_ptr_vector_set_min_size function resizes a pointer vector to a
-* specified size if the pointer vector is smaller than the specified size.
-*
-* SYNOPSIS
-*/
-cl_status_t
-cl_ptr_vector_set_min_size(IN cl_ptr_vector_t * const p_vector,
- IN const size_t min_size);
-/*
-* PARAMETERS
-* p_vector
-* [in] Pointer to a cl_ptr_vector_t structure whose minimum size to set.
-*
-* min_size
-* [in] Minimum number of elements that the pointer vector should contain.
-*
-* RETURN VALUES
-* CL_SUCCESS if the pointer vector size is greater than or equal to min_size.
-* This could indicate that the pointer vector's capacity was increased to
-* min_size or that the pointer vector was already of sufficient size.
-*
-* CL_INSUFFICIENT_MEMORY if there was not enough memory to resize the
-* pointer vector. The pointer vector is left unchanged.
-*
-* NOTES
-* If min_size is smaller than the current size of the pointer vector,
-* the pointer vector is unchanged. The pointer vector is unchanged if the
-* size could not be changed due to insufficient memory being available to
-* perform the operation.
-*
-* SEE ALSO
-* Pointer Vector, cl_ptr_vector_get_size, cl_ptr_vector_set_size,
-* cl_ptr_vector_set_capacity
-*********/
-
-/****f* Component Library: Pointer Vector/cl_ptr_vector_apply_func
-* NAME
-* cl_ptr_vector_apply_func
-*
-* DESCRIPTION
-* The cl_ptr_vector_apply_func function invokes a specified function for
-* every element in a pointer vector.
-*
-* SYNOPSIS
-*/
-void
-cl_ptr_vector_apply_func(IN const cl_ptr_vector_t * const p_vector,
- IN cl_pfn_ptr_vec_apply_t pfn_callback,
- IN const void *const context);
-/*
-* PARAMETERS
-* p_vector
-* [in] Pointer to a cl_ptr_vector_t structure whose elements to iterate.
-*
-* pfn_callback
-* [in] Function invoked for every element in the array.
-* See the cl_pfn_ptr_vec_apply_t function type declaration for details
-* about the callback function.
-*
-* context
-* [in] Value to pass to the callback function.
-*
-* RETURN VALUE
-* This function does not return a value.
-*
-* NOTES
-* cl_ptr_vector_apply_func invokes the specified function for every element
-* in the pointer vector, starting from the beginning of the pointer vector.
-*
-* SEE ALSO
-* Pointer Vector, cl_ptr_vector_find_from_start, cl_ptr_vector_find_from_end,
-* cl_pfn_ptr_vec_apply_t
-*********/
-
-/****f* Component Library: Pointer Vector/cl_ptr_vector_find_from_start
-* NAME
-* cl_ptr_vector_find_from_start
-*
-* DESCRIPTION
-* The cl_ptr_vector_find_from_start function uses a specified function to
-* search for elements in a pointer vector starting from the lowest index.
-*
-* SYNOPSIS
-*/
-size_t
-cl_ptr_vector_find_from_start(IN const cl_ptr_vector_t * const p_vector,
- IN cl_pfn_ptr_vec_find_t pfn_callback,
- IN const void *const context);
-/*
-* PARAMETERS
-* p_vector
-* [in] Pointer to a cl_ptr_vector_t structure to inititalize.
-*
-* pfn_callback
-* [in] Function invoked to determine if a match was found.
-* See the cl_pfn_ptr_vec_find_t function type declaration for details
-* about the callback function.
-*
-* context
-* [in] Value to pass to the callback function.
-*
-* RETURN VALUES
-* Index of the element, if found.
-*
-* Size of the pointer vector if the element was not found.
-*
-* NOTES
-* cl_ptr_vector_find_from_start does not remove the found element from
-* the pointer vector. The index of the element is returned when the function
-* provided by the pfn_callback parameter returns CL_SUCCESS.
-*
-* SEE ALSO
-* Pointer Vector, cl_ptr_vector_find_from_end, cl_ptr_vector_apply_func,
-* cl_pfn_ptr_vec_find_t
-*********/
-
-/****f* Component Library: Pointer Vector/cl_ptr_vector_find_from_end
-* NAME
-* cl_ptr_vector_find_from_end
-*
-* DESCRIPTION
-* The cl_ptr_vector_find_from_end function uses a specified function to
-* search for elements in a pointer vector starting from the highest index.
-*
-* SYNOPSIS
-*/
-size_t
-cl_ptr_vector_find_from_end(IN const cl_ptr_vector_t * const p_vector,
- IN cl_pfn_ptr_vec_find_t pfn_callback,
- IN const void *const context);
-/*
-* PARAMETERS
-* p_vector
-* [in] Pointer to a cl_ptr_vector_t structure to inititalize.
-*
-* pfn_callback
-* [in] Function invoked to determine if a match was found.
-* See the cl_pfn_ptr_vec_find_t function type declaration for details
-* about the callback function.
-*
-* context
-* [in] Value to pass to the callback function.
-*
-* RETURN VALUES
-* Index of the element, if found.
-*
-* Size of the pointer vector if the element was not found.
-*
-* NOTES
-* cl_ptr_vector_find_from_end does not remove the found element from
-* the pointer vector. The index of the element is returned when the function
-* provided by the pfn_callback parameter returns CL_SUCCESS.
-*
-* SEE ALSO
-* Pointer Vector, cl_ptr_vector_find_from_start, cl_ptr_vector_apply_func,
-* cl_pfn_ptr_vec_find_t
-*********/
-
-END_C_DECLS
-#endif /* _CL_PTR_VECTOR_H_ */
diff --git a/contrib/ofed/management/opensm/include/complib/cl_spinlock.h b/contrib/ofed/management/opensm/include/complib/cl_spinlock.h
deleted file mode 100644
index 1a04b56..0000000
--- a/contrib/ofed/management/opensm/include/complib/cl_spinlock.h
+++ /dev/null
@@ -1,272 +0,0 @@
-/*
- * Copyright (c) 2004, 2005 Voltaire, Inc. All rights reserved.
- * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved.
- * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- */
-
-/*
- * Abstract:
- * Declaration of spin lock object.
- */
-
-#ifndef _CL_SPINLOCK_H_
-#define _CL_SPINLOCK_H_
-
-#include <complib/cl_spinlock_osd.h>
-
-#ifdef __cplusplus
-# define BEGIN_C_DECLS extern "C" {
-# define END_C_DECLS }
-#else /* !__cplusplus */
-# define BEGIN_C_DECLS
-# define END_C_DECLS
-#endif /* __cplusplus */
-
-BEGIN_C_DECLS
-/****h* Public/Spinlock
-* NAME
-* Spinlock
-*
-* DESCRIPTION
-* Spinlock provides synchronization between threads for exclusive access to
-* a resource.
-*
-* The spinlock functions manipulate a cl_spinlock_t structure which should
-* be treated as opaque and should be manipulated only through the provided
-* functions.
-*
-* SEE ALSO
-* Structures:
-* cl_spinlock_t
-*
-* Initialization:
-* cl_spinlock_construct, cl_spinlock_init, cl_spinlock_destroy
-*
-* Manipulation
-* cl_spinlock_acquire, cl_spinlock_release
-* cl_spinlock_acquire_irq, cl_spinlock_release_irq
-*********/
-/****f* Component Library: Spinlock/cl_spinlock_construct
-* NAME
-* cl_spinlock_construct
-*
-* DESCRIPTION
-* The cl_spinlock_construct function initializes the state of a
-* spin lock.
-*
-* SYNOPSIS
-*/
-void cl_spinlock_construct(IN cl_spinlock_t * const p_spinlock);
-/*
-* PARAMETERS
-* p_spin_lock
-* [in] Pointer to a spin lock structure whose state to initialize.
-*
-* RETURN VALUE
-* This function does not return a value.
-*
-* NOTES
-* Allows calling cl_spinlock_destroy without first calling
-* cl_spinlock_init.
-*
-* Calling cl_spinlock_construct is a prerequisite to calling any other
-* spin lock function except cl_spinlock_init.
-*
-* SEE ALSO
-* Spinlock, cl_spinlock_init, cl_spinlock_destroy
-*********/
-
-/****f* Component Library: Spinlock/cl_spinlock_init
-* NAME
-* cl_spinlock_init
-*
-* DESCRIPTION
-* The cl_spinlock_init function initializes a spin lock for use.
-*
-* SYNOPSIS
-*/
-cl_status_t cl_spinlock_init(IN cl_spinlock_t * const p_spinlock);
-/*
-* PARAMETERS
-* p_spin_lock
-* [in] Pointer to a spin lock structure to initialize.
-*
-* RETURN VALUES
-* CL_SUCCESS if initialization succeeded.
-*
-* CL_ERROR if initialization failed. Callers should call
-* cl_spinlock_destroy to clean up any resources allocated during
-* initialization.
-*
-* NOTES
-* Initialize the spin lock structure. Allows calling cl_spinlock_aquire
-* and cl_spinlock_release.
-*
-* SEE ALSO
-* Spinlock, cl_spinlock_construct, cl_spinlock_destroy,
-* cl_spinlock_acquire, cl_spinlock_acquire_irq,
-* cl_spinlock_release, cl_spinlock_release
-* cl_spinlock_release_irq, cl_spinlock_release_irq
-*********/
-
-/****f* Component Library: Spinlock/cl_spinlock_destroy
-* NAME
-* cl_spinlock_destroy
-*
-* DESCRIPTION
-* The cl_spinlock_destroy function performs all necessary cleanup of a
-* spin lock.
-*
-* SYNOPSIS
-*/
-void cl_spinlock_destroy(IN cl_spinlock_t * const p_spinlock);
-/*
-* PARAMETERS
-* p_spin_lock
-* [in] Pointer to a spin lock structure to destroy.
-*
-* RETURN VALUE
-* This function does not return a value.
-*
-* NOTES
-* Performs any necessary cleanup of a spin lock. This function must only
-* be called if either cl_spinlock_construct or cl_spinlock_init has been
-* called.
-*
-* SEE ALSO
-* Spinlock, cl_spinlock_construct, cl_spinlock_init
-*********/
-
-/****f* Component Library: Spinlock/cl_spinlock_acquire
-* NAME
-* cl_spinlock_acquire
-*
-* DESCRIPTION
-* The cl_spinlock_acquire function acquires a spin lock.
-* This version of lock does not prevent an interrupt from
-* occuring on the processor on which the code is being
-* executed. To protect from an interrupt level resource
-* use the cl_spinlock_acquire_irq function.
-*
-* SYNOPSIS
-*/
-void cl_spinlock_acquire(IN cl_spinlock_t * const p_spinlock);
-/*
-* PARAMETERS
-* p_spin_lock
-* [in] Pointer to a spin lock structure to acquire.
-*
-* RETURN VALUE
-* This function does not return a value.
-*
-* SEE ALSO
-* Spinlock, cl_spinlock_acquire_irq, cl_spinlock_release
-* cl_spinlock_release_irq
-*********/
-
-/****f* Component Library: Spinlock/cl_spinlock_acquire_irq
-* NAME
-* cl_spinlock_acquire_irq
-*
-* DESCRIPTION
-* The cl_spinlock_acquire_irq function acquires a spin lock and protects
-* the current processor from taking interrupts. If you need to protect
-* a variable from an interrupt resource, use this version to acquire
-* a lock.
-*
-* SYNOPSIS
-*/
-void cl_spinlock_acquire_irq(IN cl_spinlock_t * const p_spinlock);
-/*
-* PARAMETERS
-* p_spin_lock
-* [in] Pointer to a spin lock structure to acquire.
-*
-* RETURN VALUE
-* This function does not return a value.
-*
-* SEE ALSO
-* Spinlock, cl_spinlock_release_irq
-*********/
-
-/****f* Component Library: Spinlock/cl_spinlock_release
-* NAME
-* cl_spinlock_release
-*
-* DESCRIPTION
-* The cl_spinlock_release function releases a spin lock object.
-*
-* SYNOPSIS
-*/
-void cl_spinlock_release(IN cl_spinlock_t * const p_spinlock);
-/*
-* PARAMETERS
-* p_spin_lock
-* [in] Pointer to a spin lock structure to release.
-*
-* RETURN VALUE
-* This function does not return a value.
-*
-* NOTES
-* Releases a spin lock after a call to cl_spinlock_acquire.
-*
-* SEE ALSO
-* Spinlock, cl_spinlock_acquire
-*********/
-
-/****f* Component Library: Spinlock/cl_spinlock_release_irq
-* NAME
-* cl_spinlock_release_irq
-*
-* DESCRIPTION
-* The cl_spinlock_release_irq function releases a spin lock object.
-*
-* SYNOPSIS
-*/
-void cl_spinlock_release_irq(IN cl_spinlock_t * const p_spinlock);
-/*
-* PARAMETERS
-* p_spin_lock
-* [in] Pointer to a spin lock structure to release.
-*
-* RETURN VALUE
-* This function does not return a value.
-*
-* NOTES
-* Releases a spin lock after a call to cl_spinlock_acquire.
-*
-* SEE ALSO
-* Spinlock, cl_spinlock_acquire_irq
-*********/
-
-END_C_DECLS
-#endif /* _CL_SPINLOCK_H_ */
diff --git a/contrib/ofed/management/opensm/include/complib/cl_threadpool.h b/contrib/ofed/management/opensm/include/complib/cl_threadpool.h
deleted file mode 100644
index e9b2c78..0000000
--- a/contrib/ofed/management/opensm/include/complib/cl_threadpool.h
+++ /dev/null
@@ -1,248 +0,0 @@
-/*
- * Copyright (c) 2004-2007 Voltaire, Inc. All rights reserved.
- * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved.
- * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- */
-
-/*
- * Abstract:
- * Declaration of thread pool.
- */
-
-#ifndef _CL_THREAD_POOL_H_
-#define _CL_THREAD_POOL_H_
-
-#include <pthread.h>
-#include <complib/cl_types.h>
-#include <complib/cl_thread.h>
-
-#ifdef __cplusplus
-# define BEGIN_C_DECLS extern "C" {
-# define END_C_DECLS }
-#else /* !__cplusplus */
-# define BEGIN_C_DECLS
-# define END_C_DECLS
-#endif /* __cplusplus */
-
-BEGIN_C_DECLS
-/****h* Component Library/Thread Pool
-* NAME
-* Thread Pool
-*
-* DESCRIPTION
-* The Thread Pool manages a user specified number of threads.
-*
-* Each thread in the thread pool waits for a user initiated signal before
-* invoking a user specified callback function. All threads in the thread
-* pool invoke the same callback function.
-*
-* The thread pool functions operate on a cl_thread_pool_t structure which
-* should be treated as opaque, and should be manipulated only through the
-* provided functions.
-*
-* SEE ALSO
-* Structures:
-* cl_thread_pool_t
-*
-* Initialization:
-* cl_thread_pool_construct, cl_thread_pool_init, cl_thread_pool_destroy
-*
-* Manipulation
-* cl_thread_pool_signal
-*********/
-/****s* Component Library: Thread Pool/cl_thread_pool_t
-* NAME
-* cl_thread_pool_t
-*
-* DESCRIPTION
-* Thread pool structure.
-*
-* The cl_thread_pool_t structure should be treated as opaque, and should be
-* manipulated only through the provided functions.
-*
-* SYNOPSIS
-*/
-typedef struct _cl_thread_pool {
- void (*pfn_callback) (void *);
- void *context;
- unsigned running_count;
- unsigned events;
- pthread_cond_t cond;
- pthread_mutex_t mutex;
- pthread_t *tid;
-} cl_thread_pool_t;
-/*
-* FIELDS
-* pfn_callback
-* Callback function for the thread to invoke.
-*
-* context
-* Context to pass to the thread callback function.
-*
-* running_count
-* Number of threads running.
-*
-* events
-* events counter
-*
-* mutex
-* mutex for cond variable protection
-*
-* cond
-* conditional variable to signal an event to thread
-*
-* tid
-* array of allocated thread ids.
-*
-* SEE ALSO
-* Thread Pool
-*********/
-
-/****f* Component Library: Thread Pool/cl_thread_pool_init
-* NAME
-* cl_thread_pool_init
-*
-* DESCRIPTION
-* The cl_thread_pool_init function creates the threads to be
-* managed by a thread pool.
-*
-* SYNOPSIS
-*/
-cl_status_t
-cl_thread_pool_init(IN cl_thread_pool_t * const p_thread_pool,
- IN unsigned count,
- IN void (*pfn_callback) (void *),
- IN void *context, IN const char *const name);
-/*
-* PARAMETERS
-* p_thread_pool
-* [in] Pointer to a thread pool structure to initialize.
-*
-* thread_count
-* [in] Number of threads to be managed by the thread pool.
-*
-* pfn_callback
-* [in] Address of a function to be invoked by a thread.
-* See the cl_pfn_thread_callback_t function type definition for
-* details about the callback function.
-*
-* context
-* [in] Value to pass to the callback function.
-*
-* name
-* [in] Name to associate with the threads. The name may be up to 16
-* characters, including a terminating null character. All threads
-* created in the pool have the same name.
-*
-* RETURN VALUES
-* CL_SUCCESS if the thread pool creation succeeded.
-*
-* CL_INSUFFICIENT_MEMORY if there was not enough memory to inititalize
-* the thread pool.
-*
-* CL_ERROR if the threads could not be created.
-*
-* NOTES
-* cl_thread_pool_init creates and starts the specified number of threads.
-* If thread_count is zero, the thread pool creates as many threads as there
-* are processors in the system.
-*
-* SEE ALSO
-* Thread Pool, cl_thread_pool_construct, cl_thread_pool_destroy,
-* cl_thread_pool_signal, cl_pfn_thread_callback_t
-*********/
-
-/****f* Component Library: Thread Pool/cl_thread_pool_destroy
-* NAME
-* cl_thread_pool_destroy
-*
-* DESCRIPTION
-* The cl_thread_pool_destroy function performs any necessary cleanup
-* for a thread pool.
-*
-* SYNOPSIS
-*/
-void cl_thread_pool_destroy(IN cl_thread_pool_t * const p_thread_pool);
-/*
-* PARAMETERS
-* p_thread_pool
-* [in] Pointer to a thread pool structure to destroy.
-*
-* RETURN VALUE
-* This function does not return a value.
-*
-* NOTES
-* This function blocks until all threads exit, and must therefore not
-* be called from any of the thread pool's threads. Because of its blocking
-* nature, callers of cl_thread_pool_destroy must ensure that entering a wait
-* state is valid from the calling thread context.
-*
-* This function should only be called after a call to
-* cl_thread_pool_construct or cl_thread_pool_init.
-*
-* SEE ALSO
-* Thread Pool, cl_thread_pool_construct, cl_thread_pool_init
-*********/
-
-/****f* Component Library: Thread Pool/cl_thread_pool_signal
-* NAME
-* cl_thread_pool_signal
-*
-* DESCRIPTION
-* The cl_thread_pool_signal function signals a single thread of
-* the thread pool to invoke the thread pool's callback function.
-*
-* SYNOPSIS
-*/
-cl_status_t cl_thread_pool_signal(IN cl_thread_pool_t * const p_thread_pool);
-/*
-* PARAMETERS
-* p_thread_pool
-* [in] Pointer to a thread pool structure to signal.
-*
-* RETURN VALUES
-* CL_SUCCESS if the thread pool was successfully signalled.
-*
-* CL_ERROR otherwise.
-*
-* NOTES
-* Each call to this function wakes up at most one waiting thread in
-* the thread pool.
-*
-* If all threads are running, cl_thread_pool_signal has no effect.
-*
-* SEE ALSO
-* Thread Pool
-*********/
-
-END_C_DECLS
-#endif /* _CL_THREAD_POOL_H_ */
diff --git a/contrib/ofed/management/opensm/include/complib/cl_types.h b/contrib/ofed/management/opensm/include/complib/cl_types.h
deleted file mode 100644
index 848b9d9..0000000
--- a/contrib/ofed/management/opensm/include/complib/cl_types.h
+++ /dev/null
@@ -1,472 +0,0 @@
-/*
- * Copyright (c) 2004, 2005 Voltaire, Inc. All rights reserved.
- * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved.
- * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- */
-
-/*
- * Abstract:
- * Defines standard return codes, keywords, macros, and debug levels.
- */
-
-#ifdef __WIN__
-#pragma warning(disable : 4996)
-#endif
-
-#ifndef _CL_TYPES_H_
-#define _CL_TYPES_H_
-
-#ifdef __cplusplus
-# define BEGIN_C_DECLS extern "C" {
-# define END_C_DECLS }
-#else /* !__cplusplus */
-# define BEGIN_C_DECLS
-# define END_C_DECLS
-#endif /* __cplusplus */
-
-BEGIN_C_DECLS
-#include <complib/cl_types_osd.h>
-#include <stddef.h>
-typedef uint16_t net16_t;
-typedef uint32_t net32_t;
-typedef uint64_t net64_t;
-
-#ifndef __WORDSIZE
-#ifdef __LP64__
-#define __WORDSIZE 64
-#else
-#define __WORDSIZE 32
-#endif
-#endif
-
-/* explicit cast of void* to uint32_t */
-#ifndef ASSERT_VOIDP2UINTN
-#if __WORDSIZE == 64
-#define ASSERT_VOIDP2UINTN(var) \
- CL_ASSERT( (intptr_t)var <= 0xffffffffffffffffL )
-#else /* __WORDSIZE == 64 */
-#if __WORDSIZE == 32
- /* need to cast carefully to avoid the warining of un-needed check */
-#define ASSERT_VOIDP2UINTN(var) \
- CL_ASSERT( (intptr_t)var <= 0x100000000ULL )
-#else /* __WORDSIZE == 32 */
-#error "Need to know WORDSIZE to tell how to cast to unsigned long int"
-#endif /* __WORDSIZE == 32 */
-#endif /* __WORDSIZE == 64 */
-#endif
-
-/* explicit casting of void* to long */
-#ifndef CAST_P2LONG
-#define CAST_P2LONG(var) ((intptr_t)(var))
-#endif
-
-/****d* Component Library: Pointer Manipulation/offsetof
-* NAME
-* offsetof
-*
-* DESCRIPTION
-* The offsetof macro returns the offset of a member within a structure.
-*
-* SYNOPSIS
-* uintn_t
-* offsetof(
-* IN TYPE,
-* IN MEMBER );
-*
-* PARAMETERS
-* TYPE
-* [in] Name of the structure containing the specified member.
-*
-* MEMBER
-* [in] Name of the member whose offset in the specified structure
-* is to be returned.
-*
-* RETURN VALUE
-* Number of bytes from the beginning of the structure to the
-* specified member.
-*
-* SEE ALSO
-* PARENT_STRUCT
-*********/
-#ifndef offsetof
-#define offsetof(TYPE, MEMBER) ((uintn_t) &((TYPE *)0)->MEMBER)
-#endif
-
-/****d* Component Library: Pointer Manipulation/PARENT_STRUCT
-* NAME
-* PARENT_STRUCT
-*
-* DESCRIPTION
-* The PARENT_STRUCT macro returns a pointer to a structure
-* given a name and pointer to one of its members.
-*
-* SYNOPSIS
-* PARENT_TYPE*
-* PARENT_STRUCT(
-* IN void* const p_member,
-* IN PARENT_TYPE,
-* IN MEMBER_NAME );
-*
-* PARAMETERS
-* p_member
-* [in] Pointer to the MEMBER_NAME member of a PARENT_TYPE structure.
-*
-* PARENT_TYPE
-* [in] Name of the structure containing the specified member.
-*
-* MEMBER_NAME
-* [in] Name of the member whose address is passed in the p_member
-* parameter.
-*
-* RETURN VALUE
-* Pointer to a structure of type PARENT_TYPE whose MEMBER_NAME member is
-* located at p_member.
-*
-* SEE ALSO
-* offsetof
-*********/
-#define PARENT_STRUCT(p_member, PARENT_TYPE, MEMBER_NAME) \
- ((PARENT_TYPE*)((uint8_t*)(p_member) - offsetof(PARENT_TYPE, MEMBER_NAME)))
-
-/****d* Component Library/Parameter Keywords
-* NAME
-* Parameter Keywords
-*
-* DESCRIPTION
-* The Parameter Keywords can be used to clarify the usage of function
-* parameters to users.
-*
-* VALUES
-* IN
-* Designates that the parameter is used as input to a function.
-*
-* OUT
-* Designates that the parameter's value will be set by the function.
-*
-* OPTIONAL
-* Designates that the parameter is optional, and may be NULL.
-* The OPTIONAL keyword, if used, follows the parameter name.
-*
-* EXAMPLE
-* // Function declaration.
-* void*
-* my_func(
-* IN void* const p_param1,
-* OUT void** const p_handle OPTIONAL );
-*
-* NOTES
-* Multiple keywords can apply to a single parameter. The IN and OUT
-* keywords precede the parameter type. The OPTIONAL
-* keyword, if used, follows the parameter name.
-*********/
-#ifndef IN
-#define IN /* Function input parameter */
-#endif
-#ifndef OUT
-#define OUT /* Function output parameter */
-#endif
-#ifndef OPTIONAL
-#define OPTIONAL /* Optional function parameter - NULL if not used */
-#endif
-
-/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%% Function Returns And Completion Codes %%
-%% %%
-%% The text for any addition to this enumerated type must be added to the %%
-%% string array defined in <cl_statustext.c>. %%
-%% %%
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
-
-/****d* Component Library/Data Types
-* NAME
-* Data Types
-*
-* DESCRIPTION
-* The component library provides and uses explicitly sized types.
-*
-* VALUES
-* char
-* 8-bit, defined by compiler.
-*
-* void
-* 0-bit, defined by compiler.
-*
-* int8_t
-* 8-bit signed integer.
-*
-* uint8_t
-* 8-bit unsigned integer.
-*
-* int16_t
-* 16-bit signed integer.
-*
-* uint16_t
-* 16-bit unsigned integer.
-*
-* net16_t
-* 16-bit network byte order value.
-*
-* int32_t
-* 32-bit signed integer.
-*
-* uint32_t
-* 32-bit unsigned integer.
-*
-* net32_t
-* 32-bit network byte order value.
-*
-* int64_t
-* 64-bit signed integer.
-*
-* uint64_t
-* 64-bit unsigned integer.
-*
-* net64_t
-* 64-bit network byte order value.
-*
-* intn_t
-* Signed natural sized integer. 32-bit on a 32-bit platform, 64-bit on
-* a 64-bit platform.
-*
-* uintn_t
-* Unsigned natural sized integer. 32-bit on a 32-bit platform, 64-bit on
-* a 64-bit platform.
-*
-* boolean_t
-* integral sized. Set to TRUE or FALSE and used in logical expressions.
-*
-* NOTES
-* Pointer types are not defined as these provide no value and can potentially
-* lead to naming confusion.
-*********/
-
-/****d* Component Library: Data Types/cl_status_t
-* NAME
-* cl_status_t
-*
-* DESCRIPTION
-* The cl_status_t return types are used by the component library to
-* provide detailed function return values.
-*
-* SYNOPSIS
-*/
-typedef enum _cl_status {
- CL_SUCCESS = 0,
- CL_ERROR,
- CL_INVALID_STATE,
- CL_INVALID_OPERATION,
- CL_INVALID_SETTING,
- CL_INVALID_PARAMETER,
- CL_INSUFFICIENT_RESOURCES,
- CL_INSUFFICIENT_MEMORY,
- CL_INVALID_PERMISSION,
- CL_COMPLETED,
- CL_NOT_DONE,
- CL_PENDING,
- CL_TIMEOUT,
- CL_CANCELED,
- CL_REJECT,
- CL_OVERRUN,
- CL_NOT_FOUND,
- CL_UNAVAILABLE,
- CL_BUSY,
- CL_DISCONNECT,
- CL_DUPLICATE,
-
- CL_STATUS_COUNT /* should be the last value */
-} cl_status_t;
-/*
-* SEE ALSO
-* Data Types, CL_STATUS_MSG
-*********/
-
-/* Status values above converted to text for easier printing. */
-extern const char *cl_status_text[];
-
-#ifndef cl_panic
-/****f* Component Library: Error Trapping/cl_panic
-* NAME
-* cl_panic
-*
-* DESCRIPTION
-* Halts execution of the current process. Halts the system if called in
-* from the kernel.
-*
-* SYNOPSIS
-*/
-void cl_panic(IN const char *const message, IN ...);
-/*
-* PARAMETERS
-* message
-* [in] ANSI string formatted identically as for a call to the standard C
-* function printf describing the cause for the panic.
-*
-* ...
-* [in] Extra parameters for string formatting, as defined for the
-* standard C function printf.
-*
-* RETURN VALUE
-* This function does not return.
-*
-* NOTES
-* The formatting of the message string is the same as for printf
-*
-* cl_panic sends the message to the current message logging target.
-*********/
-#endif /* cl_panic */
-
-/****d* Component Library: Data Types/CL_STATUS_MSG
-* NAME
-* CL_STATUS_MSG
-*
-* DESCRIPTION
-* The CL_STATUS_MSG macro returns a textual representation of
-* an cl_status_t code.
-*
-* SYNOPSIS
-* const char*
-* CL_STATUS_MSG(
-* IN cl_status_t errcode );
-*
-* PARAMETERS
-* errcode
-* [in] cl_status_t code for which to return a text representation.
-*
-* RETURN VALUE
-* Pointer to a string containing a textual representation of the errcode
-* parameter.
-*
-* NOTES
-* This function performs boundary checking on the cl_status_t value,
-* masking off the upper 24-bits. If the value is out of bounds, the string
-* "invalid status code" is returned.
-*
-* SEE ALSO
-* cl_status_t
-*********/
-#define CL_STATUS_MSG( errcode ) \
- ((errcode < CL_STATUS_COUNT)?cl_status_text[errcode]:"invalid status code")
-
-#if !defined( FALSE )
-#define FALSE 0
-#endif /* !defined( FALSE ) */
-
-#if !defined( TRUE )
-#define TRUE (!FALSE)
-#endif /* !defined( TRUE ) */
-
-/****d* Component Library: Unreferenced Parameters/UNUSED_PARAM
-* NAME
-* UNUSED_PARAM
-*
-* DESCRIPTION
-* The UNUSED_PARAM macro can be used to eliminates compiler warnings related
-* to intentionally unused formal parameters in function implementations.
-*
-* SYNOPSIS
-* UNUSED_PARAM( P )
-*
-* EXAMPLE
-* void my_func( int32_t value )
-* {
-* UNUSED_PARAM( value );
-* }
-*********/
-
-/****d* Component Library/Object States
-* NAME
-* Object States
-*
-* DESCRIPTION
-* The object states enumerated type defines the valid states of components.
-*
-* SYNOPSIS
-*/
-typedef enum _cl_state {
- CL_UNINITIALIZED = 1,
- CL_INITIALIZED,
- CL_DESTROYING,
- CL_DESTROYED
-} cl_state_t;
-/*
-* VALUES
-* CL_UNINITIALIZED
-* Indicates that initialization was not invoked successfully.
-*
-* CL_INITIALIZED
-* Indicates initialization was successful.
-*
-* CL_DESTROYING
-* Indicates that the object is undergoing destruction.
-*
-* CL_DESTROYED
-* Indicates that the object's destructor has already been called. Most
-* objects set their final state to CL_DESTROYED before freeing the
-* memory associated with the object.
-*********/
-
-/****d* Component Library: Object States/cl_is_state_valid
-* NAME
-* cl_is_state_valid
-*
-* DESCRIPTION
-* The cl_is_state_valid function returns whether a state has a valid value.
-*
-* SYNOPSIS
-*/
-static inline boolean_t cl_is_state_valid(IN const cl_state_t state)
-{
- return ((state == CL_UNINITIALIZED) || (state == CL_INITIALIZED) ||
- (state == CL_DESTROYING) || (state == CL_DESTROYED));
-}
-
-/*
-* PARAMETERS
-* state
-* State whose value to validate.
-*
-* RETURN VALUES
-* TRUE if the specified state has a valid value.
-*
-* FALSE otherwise.
-*
-* NOTES
-* This function is used in debug builds to check for valid states. If an
-* uninitialized object is passed, the memory for the state may cause the
-* state to have an invalid value.
-*
-* SEE ALSO
-* Object States
-*********/
-
-END_C_DECLS
-#endif /* _DATA_TYPES_H_ */
diff --git a/contrib/ofed/management/opensm/include/complib/cl_types_osd.h b/contrib/ofed/management/opensm/include/complib/cl_types_osd.h
deleted file mode 100644
index d12aa4c..0000000
--- a/contrib/ofed/management/opensm/include/complib/cl_types_osd.h
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
- * Copyright (c) 2004-2006 Voltaire, Inc. All rights reserved.
- * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved.
- * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- */
-
-/*
- * Abstract:
- * Defines sized datatypes for Linux User mode
- * exported sizes are int8_t, uint8_t, int16_t, uint16_t, int32_t, uint32_t
- * int64_t, uint64_t. uintn_t is a polymorphic type, size is native size and
- * also size of the pointer.
- */
-
-#ifndef _CL_TYPES_OSD_H_
-#define _CL_TYPES_OSD_H_
-
-#ifdef __cplusplus
-# define BEGIN_C_DECLS extern "C" {
-# define END_C_DECLS }
-#else /* !__cplusplus */
-# define BEGIN_C_DECLS
-# define END_C_DECLS
-#endif /* __cplusplus */
-
-BEGIN_C_DECLS
-#if defined (_DEBUG_)
-#ifdef __IA64__
-#define cl_break() asm(" break 0")
-#else /* __IA64__ */
-#define cl_break() asm(" int $3")
-#endif /* __IA64__ */
-#else /* _DEBUG_ */
-#define cl_break
-#endif
-#include <inttypes.h>
-#include <assert.h>
-#include <string.h>
-#if defined (_DEBUG_)
-#define CL_ASSERT assert
-#else /* _DEBUG_ */
-#define CL_ASSERT( __exp__ )
-#endif /* _DEBUG_ */
-/*
- * Types not explicitly defined are native to the platform.
- */
-typedef unsigned long uintn_t;
-typedef long intn_t;
-typedef int boolean_t;
-typedef volatile int32_t atomic32_t;
-
-#ifndef NULL
-#define NULL (void*)0
-#endif
-
-#define UNUSED_PARAM( P )
-
-END_C_DECLS
-#endif /* _CL_TYPES_OSD_H_ */
diff --git a/contrib/ofed/management/opensm/include/complib/cl_vector.h b/contrib/ofed/management/opensm/include/complib/cl_vector.h
deleted file mode 100644
index 11c45f8..0000000
--- a/contrib/ofed/management/opensm/include/complib/cl_vector.h
+++ /dev/null
@@ -1,945 +0,0 @@
-/*
- * Copyright (c) 2004, 2005 Voltaire, Inc. All rights reserved.
- * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved.
- * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- */
-
-/*
- * Abstract:
- * This file contains vector definitions. Vector provides dynmically
- * resizable array functionality. Objects in a Vector are not relocated
- * when the array is resized.
- */
-
-#ifndef _CL_VECTOR_H_
-#define _CL_VECTOR_H_
-
-#include <complib/cl_qlist.h>
-
-#ifdef __cplusplus
-# define BEGIN_C_DECLS extern "C" {
-# define END_C_DECLS }
-#else /* !__cplusplus */
-# define BEGIN_C_DECLS
-# define END_C_DECLS
-#endif /* __cplusplus */
-
-BEGIN_C_DECLS
-/****h* Component Library/Vector
-* NAME
-* Vector
-*
-* DESCRIPTION
-* The Vector is a self-sizing array. Like a traditonal array, a vector
-* allows efficient constant time access to elements with a specified index.
-* A vector grows transparently as the user adds elements to the array.
-*
-* As the vector grows in size, it does not relocate existing elements in
-* memory. This allows using pointers to elements stored in a Vector.
-*
-* Users can supply an initializer functions that allow a vector to ensure
-* that new items added to the vector are properly initialized. A vector
-* calls the initializer function on a per object basis when growing the
-* array. The initializer is optional.
-*
-* The initializer function can fail, and returns a cl_status_t. The vector
-* will call the destructor function, if provided, for an element that
-* failed initialization. If an initializer fails, a vector does not call
-* the initializer for objects in the remainder of the new memory allocation.
-*
-* The cl_vector_t structure should be treated as opaque and should be
-* manipulated only through the provided functions.
-*
-* SEE ALSO
-* Structures:
-* cl_vector_t
-*
-* Callbacks:
-* cl_pfn_vec_init_t, cl_pfn_vec_dtor_t, cl_pfn_vec_apply_t,
-* cl_pfn_vec_find_t
-*
-* Item Manipulation:
-* cl_vector_set_obj, cl_vector_obj
-*
-* Initialization:
-* cl_vector_construct, cl_vector_init, cl_vector_destroy
-*
-* Manipulation:
-* cl_vector_get_capacity, cl_vector_set_capacity,
-* cl_vector_get_size, cl_vector_set_size, cl_vector_set_min_size
-* cl_vector_get_ptr, cl_vector_get, cl_vector_at, cl_vector_set
-*
-* Search:
-* cl_vector_find_from_start, cl_vector_find_from_end
-* cl_vector_apply_func
-*********/
-/****d* Component Library: Vector/cl_pfn_vec_init_t
-* NAME
-* cl_pfn_vec_init_t
-*
-* DESCRIPTION
-* The cl_pfn_vec_init_t function type defines the prototype for functions
-* used as initializer for elements being allocated by a vector.
-*
-* SYNOPSIS
-*/
-typedef cl_status_t
- (*cl_pfn_vec_init_t) (IN void *const p_element, IN void *context);
-/*
-* PARAMETERS
-* p_element
-* [in] Pointer to an element being added to a vector.
-*
-* context
-* [in] Context provided in a call to cl_vector_init.
-*
-* RETURN VALUES
-* Return CL_SUCCESS to indicate that the element was initialized successfully.
-*
-* Other cl_status_t values will be returned by the cl_vector_init,
-* cl_vector_set_size, and cl_vector_set_min_size functions.
-*
-* In situations where the vector's size needs to grows in order to satisfy
-* a call to cl_vector_set, a non-successful status returned by the
-* initializer callback causes the growth to stop.
-*
-* NOTES
-* This function type is provided as function prototype reference for
-* the initializer function provided by users as an optional parameter to
-* the cl_vector_init function.
-*
-* SEE ALSO
-* Vector, cl_vector_init
-*********/
-
-/****d* Component Library: Vector/cl_pfn_vec_dtor_t
-* NAME
-* cl_pfn_vec_dtor_t
-*
-* DESCRIPTION
-* The cl_pfn_vec_dtor_t function type defines the prototype for functions
-* used as destructor for elements being deallocated from a vector.
-*
-* SYNOPSIS
-*/
-typedef void
- (*cl_pfn_vec_dtor_t) (IN void *const p_element, IN void *context);
-/*
-* PARAMETERS
-* p_element
-* [in] Pointer to an element being deallocated from a vector.
-*
-* context
-* [in] Context provided in a call to cl_vector_init.
-*
-* RETURN VALUE
-* This function does not return a value.
-*
-* NOTES
-* This function type is provided as function prototype reference for
-* the destructor function provided by users as an optional parameter to
-* the cl_vector_init function.
-*
-* SEE ALSO
-* Vector, cl_vector_init
-*********/
-
-/****d* Component Library: Vector/cl_pfn_vec_apply_t
-* NAME
-* cl_pfn_vec_apply_t
-*
-* DESCRIPTION
-* The cl_pfn_vec_apply_t function type defines the prototype for functions
-* used to iterate elements in a vector.
-*
-* SYNOPSIS
-*/
-typedef void
- (*cl_pfn_vec_apply_t) (IN const size_t index,
- IN void *const p_element, IN void *context);
-/*
-* PARAMETERS
-* index
-* [in] Index of the element.
-*
-* p_element
-* [in] Pointer to an element at the specified index in the vector.
-*
-* context
-* [in] Context provided in a call to cl_vector_apply_func.
-*
-* RETURN VALUE
-* This function does not return a value.
-*
-* NOTES
-* This function type is provided as function prototype reference for
-* the function passed by users as a parameter to the cl_vector_apply_func
-* function.
-*
-* SEE ALSO
-* Vector, cl_vector_apply_func
-*********/
-
-/****d* Component Library: Vector/cl_pfn_vec_find_t
-* NAME
-* cl_pfn_vec_find_t
-*
-* DESCRIPTION
-* The cl_pfn_vec_find_t function type defines the prototype for functions
-* used to find elements in a vector.
-*
-* SYNOPSIS
-*/
-typedef cl_status_t
- (*cl_pfn_vec_find_t) (IN const size_t index,
- IN const void *const p_element, IN void *context);
-/*
-* PARAMETERS
-* index
-* [in] Index of the element.
-*
-* p_element
-* [in] Pointer to an element at the specified index in the vector.
-*
-* context
-* [in] Context provided in a call to cl_vector_find_from_start or
-* cl_vector_find_from_end.
-*
-* RETURN VALUES
-* Return CL_SUCCESS if the element was found. This stops vector iteration.
-*
-* CL_NOT_FOUND to continue the vector iteration.
-*
-* NOTES
-* This function type is provided as function prototype reference for the
-* function provided by users as a parameter to the cl_vector_find_from_start
-* and cl_vector_find_from_end functions.
-*
-* SEE ALSO
-* Vector, cl_vector_find_from_start, cl_vector_find_from_end
-*********/
-
-/****i* Component Library: Vector/cl_pfn_vec_copy_t
-* NAME
-* cl_pfn_vec_copy_t
-*
-* DESCRIPTION
-* The cl_pfn_vec_copy_t function type defines the prototype for functions
-* used to copy elements in a vector.
-*
-* SYNOPSIS
-*/
-typedef void
- (*cl_pfn_vec_copy_t) (IN void *const p_dest,
- IN const void *const p_src, IN const size_t size);
-/*
-* PARAMETERS
-* p_dest
-* [in] Pointer to the destination buffer into which to copy p_src.
-*
-* p_src
-* [in] Pointer to the destination buffer from which to copy.
-*
-* size
-* [in] Number of bytes to copy.
-*
-* RETURN VALUE
-* This function does not return a value.
-*
-* SEE ALSO
-* Vector
-*********/
-
-/****s* Component Library: Vector/cl_vector_t
-* NAME
-* cl_vector_t
-*
-* DESCRIPTION
-* Vector structure.
-*
-* The cl_vector_t structure should be treated as opaque and should be
-* manipulated only through the provided functions.
-*
-* SYNOPSIS
-*/
-typedef struct _cl_vector {
- size_t size;
- size_t grow_size;
- size_t capacity;
- size_t element_size;
- cl_pfn_vec_init_t pfn_init;
- cl_pfn_vec_dtor_t pfn_dtor;
- cl_pfn_vec_copy_t pfn_copy;
- const void *context;
- cl_qlist_t alloc_list;
- void **p_ptr_array;
- cl_state_t state;
-} cl_vector_t;
-/*
-* FIELDS
-* size
-* Number of elements successfully initialized in the vector.
-*
-* grow_size
-* Number of elements to allocate when growing.
-*
-* capacity
-* total # of elements allocated.
-*
-* element_size
-* Size of each element.
-*
-* pfn_init
-* User supplied element initializer.
-*
-* pfn_dtor
-* User supplied element destructor.
-*
-* pfn_copy
-* Copy operator.
-*
-* context
-* User context for callbacks.
-*
-* alloc_list
-* List of allocations.
-*
-* p_ptr_array
-* Internal array of pointers to elements.
-*
-* state
-* State of the vector.
-*
-* SEE ALSO
-* Vector
-*********/
-
-/****f* Component Library: Vector/cl_vector_construct
-* NAME
-* cl_vector_construct
-*
-* DESCRIPTION
-* The cl_vector_construct function constructs a vector.
-*
-* SYNOPSIS
-*/
-void cl_vector_construct(IN cl_vector_t * const p_vector);
-/*
-* PARAMETERS
-* p_vector
-* [in] Pointer to a cl_vector_t structure to construct.
-*
-* RETURN VALUE
-* This function does not return a value.
-*
-* NOTES
-* Allows calling cl_vector_destroy without first calling cl_vector_init.
-*
-* Calling cl_vector_construct is a prerequisite to calling any other
-* vector function except cl_vector_init.
-*
-* SEE ALSO
-* Vector, cl_vector_init, cl_vector_destroy
-*********/
-
-/****f* Component Library: Vector/cl_vector_init
-* NAME
-* cl_vector_init
-*
-* DESCRIPTION
-* The cl_vector_init function initializes a vector for use.
-*
-* SYNOPSIS
-*/
-cl_status_t
-cl_vector_init(IN cl_vector_t * const p_vector,
- IN const size_t min_size,
- IN const size_t grow_size,
- IN const size_t element_size,
- IN cl_pfn_vec_init_t pfn_init OPTIONAL,
- IN cl_pfn_vec_dtor_t pfn_dtor OPTIONAL,
- IN const void *const context);
-/*
-* PARAMETERS
-* p_vector
-* [in] Pointer to a cl_vector_t structure to inititalize.
-*
-* initial_size
-* [in] Initial number of elements.
-*
-* grow_size
-* [in] Number of elements to allocate when incrementally growing
-* the vector. A value of zero disables automatic growth.
-*
-* element_size
-* [in] Size of each element.
-*
-* pfn_init
-* [in] Initializer callback to invoke for every new element.
-* See the cl_pfn_vec_init_t function type declaration for details about
-* the callback function.
-*
-* pfn_dtor
-* [in] Destructor callback to invoke for elements being deallocated.
-* See the cl_pfn_vec_dtor_t function type declaration for details about
-* the callback function.
-*
-* context
-* [in] Value to pass to the callback functions to provide context.
-*
-* RETURN VALUES
-* CL_SUCCESS if the vector was initialized successfully.
-*
-* CL_INSUFFICIENT_MEMORY if the initialization failed.
-*
-* cl_status_t value returned by optional initializer function specified by
-* the pfn_init parameter.
-*
-* NOTES
-* The constructor and initializer functions, if any, are invoked for every
-* new element in the array.
-*
-* SEE ALSO
-* Vector, cl_vector_construct, cl_vector_destroy, cl_vector_set,
-* cl_vector_get, cl_vector_get_ptr, cl_vector_at
-*********/
-
-/****f* Component Library: Vector/cl_vector_destroy
-* NAME
-* cl_vector_destroy
-*
-* DESCRIPTION
-* The cl_vector_destroy function destroys a vector.
-*
-* SYNOPSIS
-*/
-void cl_vector_destroy(IN cl_vector_t * const p_vector);
-/*
-* PARAMETERS
-* p_vector
-* [in] Pointer to a cl_vector_t structure to destroy.
-*
-* RETURN VALUE
-* This function does not return a value.
-*
-* NOTES
-* cl_vector_destroy frees all memory allocated for the vector. The vector
-* is left initialized to a zero capacity and size.
-*
-* This function should only be called after a call to cl_vector_construct
-* or cl_vector_init.
-*
-* SEE ALSO
-* Vector, cl_vector_construct, cl_vector_init
-*********/
-
-/****f* Component Library: Vector/cl_vector_get_capacity
-* NAME
-* cl_vector_get_capacity
-*
-* DESCRIPTION
-* The cl_vector_get_capacity function returns the capacity of a vector.
-*
-* SYNOPSIS
-*/
-static inline size_t
-cl_vector_get_capacity(IN const cl_vector_t * const p_vector)
-{
- CL_ASSERT(p_vector);
- CL_ASSERT(p_vector->state == CL_INITIALIZED);
-
- return (p_vector->capacity);
-}
-
-/*
-* PARAMETERS
-* p_vector
-* [in] Pointer to a cl_vector_t structure whose capacity to return.
-*
-* RETURN VALUE
-* Capacity, in elements, of the vector.
-*
-* NOTES
-* The capacity is the number of elements that the vector can store, and
-* can be greater than the number of elements stored. To get the number of
-* elements stored in the vector, use cl_vector_get_size.
-*
-* SEE ALSO
-* Vector, cl_vector_set_capacity, cl_vector_get_size
-*********/
-
-/****f* Component Library: Vector/cl_vector_get_size
-* NAME
-* cl_vector_get_size
-*
-* DESCRIPTION
-* The cl_vector_get_size function returns the size of a vector.
-*
-* SYNOPSIS
-*/
-static inline size_t cl_vector_get_size(IN const cl_vector_t * const p_vector)
-{
- CL_ASSERT(p_vector);
- CL_ASSERT(p_vector->state == CL_INITIALIZED);
-
- return (p_vector->size);
-}
-
-/*
-* PARAMETERS
-* p_vector
-* [in] Pointer to a cl_vector_t structure whose size to return.
-*
-* RETURN VALUE
-* Size, in elements, of the vector.
-*
-* SEE ALSO
-* Vector, cl_vector_set_size, cl_vector_get_capacity
-*********/
-
-/****f* Component Library: Vector/cl_vector_get_ptr
-* NAME
-* cl_vector_get_ptr
-*
-* DESCRIPTION
-* The cl_vector_get_ptr function returns a pointer to an element
-* stored in a vector at a specified index.
-*
-* SYNOPSIS
-*/
-static inline void *cl_vector_get_ptr(IN const cl_vector_t * const p_vector,
- IN const size_t index)
-{
- CL_ASSERT(p_vector);
- CL_ASSERT(p_vector->state == CL_INITIALIZED);
-
- return (p_vector->p_ptr_array[index]);
-}
-
-/*
-* PARAMETERS
-* p_vector
-* [in] Pointer to a cl_vector_t structure from which to get a
-* pointer to an element.
-*
-* index
-* [in] Index of the element.
-*
-* RETURN VALUE
-* Pointer to the element stored at specified index.
-*
-* NOTES
-* cl_vector_get_ptr provides constant access times regardless of the index.
-*
-* cl_vector_get_ptr does not perform boundary checking. Callers are
-* responsible for providing an index that is within the range of the vector.
-*
-* SEE ALSO
-* Vector, cl_vector_get, cl_vector_at, cl_vector_set, cl_vector_get_size
-*********/
-
-/****f* Component Library: Vector/cl_vector_get
-* NAME
-* cl_vector_get
-*
-* DESCRIPTION
-* The cl_vector_get function copies an element stored in a vector at a
-* specified index.
-*
-* SYNOPSIS
-*/
-static inline void
-cl_vector_get(IN const cl_vector_t * const p_vector,
- IN const size_t index, OUT void *const p_element)
-{
- void *p_src;
-
- CL_ASSERT(p_vector);
- CL_ASSERT(p_vector->state == CL_INITIALIZED);
- CL_ASSERT(p_element);
-
- /* Get a pointer to the element. */
- p_src = cl_vector_get_ptr(p_vector, index);
- p_vector->pfn_copy(p_src, p_element, p_vector->element_size);
-}
-
-/*
-* PARAMETERS
-* p_vector
-* [in] Pointer to a cl_vector_t structure from which to get a copy of
-* an element.
-*
-* index
-* [in] Index of the element.
-*
-* p_element
-* [out] Pointer to storage for the element. Contains a copy of the
-* desired element upon successful completion of the call.
-*
-* RETURN VALUE
-* This function does not return a value.
-*
-* NOTES
-* cl_vector_get provides constant time access regardless of the index.
-*
-* cl_vector_get does not perform boundary checking on the vector, and
-* callers are responsible for providing an index that is within the range
-* of the vector. To access elements after performing boundary checks,
-* use cl_vector_at.
-*
-* The p_element parameter contains a copy of the desired element upon
-* return from this function.
-*
-* SEE ALSO
-* Vector, cl_vector_get_ptr, cl_vector_at
-*********/
-
-/****f* Component Library: Vector/cl_vector_at
-* NAME
-* cl_vector_at
-*
-* DESCRIPTION
-* The cl_vector_at function copies an element stored in a vector at a
-* specified index, performing boundary checks.
-*
-* SYNOPSIS
-*/
-cl_status_t
-cl_vector_at(IN const cl_vector_t * const p_vector,
- IN const size_t index, OUT void *const p_element);
-/*
-* PARAMETERS
-* p_vector
-* [in] Pointer to a cl_vector_t structure from which to get a copy of
-* an element.
-*
-* index
-* [in] Index of the element.
-*
-* p_element
-* [out] Pointer to storage for the element. Contains a copy of the
-* desired element upon successful completion of the call.
-*
-* RETURN VALUES
-* CL_SUCCESS if an element was found at the specified index.
-*
-* CL_INVALID_SETTING if the index was out of range.
-*
-* NOTES
-* cl_vector_at provides constant time access regardless of the index, and
-* performs boundary checking on the vector.
-*
-* Upon success, the p_element parameter contains a copy of the desired element.
-*
-* SEE ALSO
-* Vector, cl_vector_get, cl_vector_get_ptr
-*********/
-
-/****f* Component Library: Vector/cl_vector_set
-* NAME
-* cl_vector_set
-*
-* DESCRIPTION
-* The cl_vector_set function sets the element at the specified index.
-*
-* SYNOPSIS
-*/
-cl_status_t
-cl_vector_set(IN cl_vector_t * const p_vector,
- IN const size_t index, IN void *const p_element);
-/*
-* PARAMETERS
-* p_vector
-* [in] Pointer to a cl_vector_t structure into which to store
-* an element.
-*
-* index
-* [in] Index of the element.
-*
-* p_element
-* [in] Pointer to an element to store in the vector.
-*
-* RETURN VALUES
-* CL_SUCCESS if the element was successfully set.
-*
-* CL_INSUFFICIENT_MEMORY if the vector could not be resized to accommodate
-* the new element.
-*
-* NOTES
-* cl_vector_set grows the vector as needed to accommodate the new element,
-* unless the grow_size parameter passed into the cl_vector_init function
-* was zero.
-*
-* SEE ALSO
-* Vector, cl_vector_get
-*********/
-
-/****f* Component Library: Vector/cl_vector_set_capacity
-* NAME
-* cl_vector_set_capacity
-*
-* DESCRIPTION
-* The cl_vector_set_capacity function reserves memory in a vector for a
-* specified number of elements.
-*
-* SYNOPSIS
-*/
-cl_status_t
-cl_vector_set_capacity(IN cl_vector_t * const p_vector,
- IN const size_t new_capacity);
-/*
-* PARAMETERS
-* p_vector
-* [in] Pointer to a cl_vector_t structure whose capacity to set.
-*
-* new_capacity
-* [in] Total number of elements for which the vector should
-* allocate memory.
-*
-* RETURN VALUES
-* CL_SUCCESS if the capacity was successfully set.
-*
-* CL_INSUFFICIENT_MEMORY if there was not enough memory to satisfy the
-* operation. The vector is left unchanged.
-*
-* NOTES
-* cl_vector_set_capacity increases the capacity of the vector. It does
-* not change the size of the vector. If the requested capacity is less
-* than the current capacity, the vector is left unchanged.
-*
-* SEE ALSO
-* Vector, cl_vector_get_capacity, cl_vector_set_size,
-* cl_vector_set_min_size
-*********/
-
-/****f* Component Library: Vector/cl_vector_set_size
-* NAME
-* cl_vector_set_size
-*
-* DESCRIPTION
-* The cl_vector_set_size function resizes a vector, either increasing or
-* decreasing its size.
-*
-* SYNOPSIS
-*/
-cl_status_t
-cl_vector_set_size(IN cl_vector_t * const p_vector, IN const size_t size);
-/*
-* PARAMETERS
-* p_vector
-* [in] Pointer to a cl_vector_t structure whose size to set.
-*
-* size
-* [in] Number of elements desired in the vector.
-*
-* RETURN VALUES
-* CL_SUCCESS if the size of the vector was set successfully.
-*
-* CL_INSUFFICIENT_MEMORY if there was not enough memory to complete the
-* operation. The vector is left unchanged.
-*
-* NOTES
-* cl_vector_set_size sets the vector to the specified size. If size is
-* smaller than the current size of the vector, the size is reduced.
-* The destructor function, if any, will be invoked for all elements that
-* are above size. Likewise, the constructor and initializer, if any, will
-* be invoked for all new elements.
-*
-* This function can only fail if size is larger than the current capacity.
-*
-* SEE ALSO
-* Vector, cl_vector_get_size, cl_vector_set_min_size,
-* cl_vector_set_capacity
-*********/
-
-/****f* Component Library: Vector/cl_vector_set_min_size
-* NAME
-* cl_vector_set_min_size
-*
-* DESCRIPTION
-* The cl_vector_set_min_size function resizes a vector to a specified size
-* if the vector is smaller than the specified size.
-*
-* SYNOPSIS
-*/
-cl_status_t
-cl_vector_set_min_size(IN cl_vector_t * const p_vector,
- IN const size_t min_size);
-/*
-* PARAMETERS
-* p_vector
-* [in] Pointer to a cl_vector_t structure whose minimum size to set.
-*
-* min_size
-* [in] Minimum number of elements that the vector should contain.
-*
-* RETURN VALUES
-* CL_SUCCESS if the vector size is greater than or equal to min_size. This
-* could indicate that the vector's capacity was increased to min_size or
-* that the vector was already of sufficient size.
-*
-* CL_INSUFFICIENT_MEMORY if there was not enough memory to resize the vector.
-* The vector is left unchanged.
-*
-* NOTES
-* If min_size is smaller than the current size of the vector, the vector is
-* unchanged. The vector is unchanged if the size could not be changed due
-* to insufficient memory being available to perform the operation.
-*
-* SEE ALSO
-* Vector, cl_vector_get_size, cl_vector_set_size, cl_vector_set_capacity
-*********/
-
-/****f* Component Library: Vector/cl_vector_apply_func
-* NAME
-* cl_vector_apply_func
-*
-* DESCRIPTION
-* The cl_vector_apply_func function invokes a specified function for every
-* element in a vector.
-*
-* SYNOPSIS
-*/
-void
-cl_vector_apply_func(IN const cl_vector_t * const p_vector,
- IN cl_pfn_vec_apply_t pfn_callback,
- IN const void *const context);
-/*
-* PARAMETERS
-* p_vector
-* [in] Pointer to a cl_vector_t structure whose elements to iterate.
-*
-* pfn_callback
-* [in] Function invoked for every element in the array.
-* See the cl_pfn_vec_apply_t function type declaration for details
-* about the callback function.
-*
-* context
-* [in] Value to pass to the callback function.
-*
-* RETURN VALUE
-* This function does not return a value.
-*
-* NOTES
-* cl_vector_apply_func invokes the specified function for every element
-* in the vector, starting from the beginning of the vector.
-*
-* SEE ALSO
-* Vector, cl_vector_find_from_start, cl_vector_find_from_end,
-* cl_pfn_vec_apply_t
-*********/
-
-/****f* Component Library: Vector/cl_vector_find_from_start
-* NAME
-* cl_vector_find_from_start
-*
-* DESCRIPTION
-* The cl_vector_find_from_start function uses a specified function to
-* search for elements in a vector starting from the lowest index.
-*
-* SYNOPSIS
-*/
-size_t
-cl_vector_find_from_start(IN const cl_vector_t * const p_vector,
- IN cl_pfn_vec_find_t pfn_callback,
- IN const void *const context);
-/*
-* PARAMETERS
-* p_vector
-* [in] Pointer to a cl_vector_t structure to inititalize.
-*
-* pfn_callback
-* [in] Function invoked to determine if a match was found.
-* See the cl_pfn_vec_find_t function type declaration for details
-* about the callback function.
-*
-* context
-* [in] Value to pass to the callback function.
-*
-* RETURN VALUES
-* Index of the element, if found.
-*
-* Size of the vector if the element was not found.
-*
-* NOTES
-* cl_vector_find_from_start does not remove the found element from
-* the vector. The index of the element is returned when the function
-* provided by the pfn_callback parameter returns CL_SUCCESS.
-*
-* SEE ALSO
-* Vector, cl_vector_find_from_end, cl_vector_apply_func, cl_pfn_vec_find_t
-*********/
-
-/****f* Component Library: Vector/cl_vector_find_from_end
-* NAME
-* cl_vector_find_from_end
-*
-* DESCRIPTION
-* The cl_vector_find_from_end function uses a specified function to search
-* for elements in a vector starting from the highest index.
-*
-* SYNOPSIS
-*/
-size_t
-cl_vector_find_from_end(IN const cl_vector_t * const p_vector,
- IN cl_pfn_vec_find_t pfn_callback,
- IN const void *const context);
-/*
-* PARAMETERS
-* p_vector
-* [in] Pointer to a cl_vector_t structure to inititalize.
-*
-* pfn_callback
-* [in] Function invoked to determine if a match was found.
-* See the cl_pfn_vec_find_t function type declaration for details
-* about the callback function.
-*
-* context
-* [in] Value to pass to the callback function.
-*
-* RETURN VALUES
-* Index of the element, if found.
-*
-* Size of the vector if the element was not found.
-*
-* NOTES
-* cl_vector_find_from_end does not remove the found element from
-* the vector. The index of the element is returned when the function
-* provided by the pfn_callback parameter returns CL_SUCCESS.
-*
-* SEE ALSO
-* Vector, cl_vector_find_from_start, cl_vector_apply_func,
-* cl_pfn_vec_find_t
-*********/
-
-END_C_DECLS
-#endif /* _CL_VECTOR_H_ */
diff --git a/contrib/ofed/management/opensm/include/iba/ib_cm_types.h b/contrib/ofed/management/opensm/include/iba/ib_cm_types.h
deleted file mode 100644
index c1fbfaf..0000000
--- a/contrib/ofed/management/opensm/include/iba/ib_cm_types.h
+++ /dev/null
@@ -1,203 +0,0 @@
-/*
- * Copyright (c) 2004-2007 Voltaire, Inc. All rights reserved.
- * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved.
- * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- */
-
-#if !defined(__IB_CM_TYPES_H__)
-#define __IB_CM_TYPES_H__
-
-#ifndef WIN32
-
-#include <iba/ib_types.h>
-
-#ifdef __cplusplus
-# define BEGIN_C_DECLS extern "C" {
-# define END_C_DECLS }
-#else /* !__cplusplus */
-# define BEGIN_C_DECLS
-# define END_C_DECLS
-#endif /* __cplusplus */
-
-BEGIN_C_DECLS
-/*
- * Defines known Communication management class versions
- */
-#define IB_MCLASS_CM_VER_2 2
-#define IB_MCLASS_CM_VER_1 1
-/*
- * Defines the size of user available data in communication management MADs
- */
-#define IB_REQ_PDATA_SIZE_VER2 92
-#define IB_MRA_PDATA_SIZE_VER2 222
-#define IB_REJ_PDATA_SIZE_VER2 148
-#define IB_REP_PDATA_SIZE_VER2 196
-#define IB_RTU_PDATA_SIZE_VER2 224
-#define IB_LAP_PDATA_SIZE_VER2 168
-#define IB_APR_PDATA_SIZE_VER2 148
-#define IB_DREQ_PDATA_SIZE_VER2 220
-#define IB_DREP_PDATA_SIZE_VER2 224
-#define IB_SIDR_REQ_PDATA_SIZE_VER2 216
-#define IB_SIDR_REP_PDATA_SIZE_VER2 136
-#define IB_REQ_PDATA_SIZE_VER1 92
-#define IB_MRA_PDATA_SIZE_VER1 222
-#define IB_REJ_PDATA_SIZE_VER1 148
-#define IB_REP_PDATA_SIZE_VER1 204
-#define IB_RTU_PDATA_SIZE_VER1 224
-#define IB_LAP_PDATA_SIZE_VER1 168
-#define IB_APR_PDATA_SIZE_VER1 151
-#define IB_DREQ_PDATA_SIZE_VER1 220
-#define IB_DREP_PDATA_SIZE_VER1 224
-#define IB_SIDR_REQ_PDATA_SIZE_VER1 216
-#define IB_SIDR_REP_PDATA_SIZE_VER1 140
-#define IB_ARI_SIZE 72 // redefine
-#define IB_APR_INFO_SIZE 72
-/****d* Access Layer/ib_rej_status_t
-* NAME
-* ib_rej_status_t
-*
-* DESCRIPTION
-* Rejection reasons.
-*
-* SYNOPSIS
-*/
-typedef ib_net16_t ib_rej_status_t;
-/*
-* SEE ALSO
-* ib_cm_rej, ib_cm_rej_rec_t
-*
-* SOURCE
-*/
-#define IB_REJ_INSUF_QP CL_HTON16(1)
-#define IB_REJ_INSUF_EEC CL_HTON16(2)
-#define IB_REJ_INSUF_RESOURCES CL_HTON16(3)
-#define IB_REJ_TIMEOUT CL_HTON16(4)
-#define IB_REJ_UNSUPPORTED CL_HTON16(5)
-#define IB_REJ_INVALID_COMM_ID CL_HTON16(6)
-#define IB_REJ_INVALID_COMM_INSTANCE CL_HTON16(7)
-#define IB_REJ_INVALID_SID CL_HTON16(8)
-#define IB_REJ_INVALID_XPORT CL_HTON16(9)
-#define IB_REJ_STALE_CONN CL_HTON16(10)
-#define IB_REJ_RDC_NOT_EXIST CL_HTON16(11)
-#define IB_REJ_INVALID_GID CL_HTON16(12)
-#define IB_REJ_INVALID_LID CL_HTON16(13)
-#define IB_REJ_INVALID_SL CL_HTON16(14)
-#define IB_REJ_INVALID_TRAFFIC_CLASS CL_HTON16(15)
-#define IB_REJ_INVALID_HOP_LIMIT CL_HTON16(16)
-#define IB_REJ_INVALID_PKT_RATE CL_HTON16(17)
-#define IB_REJ_INVALID_ALT_GID CL_HTON16(18)
-#define IB_REJ_INVALID_ALT_LID CL_HTON16(19)
-#define IB_REJ_INVALID_ALT_SL CL_HTON16(20)
-#define IB_REJ_INVALID_ALT_TRAFFIC_CLASS CL_HTON16(21)
-#define IB_REJ_INVALID_ALT_HOP_LIMIT CL_HTON16(22)
-#define IB_REJ_INVALID_ALT_PKT_RATE CL_HTON16(23)
-#define IB_REJ_PORT_REDIRECT CL_HTON16(24)
-#define IB_REJ_INVALID_MTU CL_HTON16(26)
-#define IB_REJ_INSUFFICIENT_RESP_RES CL_HTON16(27)
-#define IB_REJ_USER_DEFINED CL_HTON16(28)
-#define IB_REJ_INVALID_RNR_RETRY CL_HTON16(29)
-#define IB_REJ_DUPLICATE_LOCAL_COMM_ID CL_HTON16(30)
-#define IB_REJ_INVALID_CLASS_VER CL_HTON16(31)
-#define IB_REJ_INVALID_FLOW_LBL CL_HTON16(32)
-#define IB_REJ_INVALID_ALT_FLOW_LBL CL_HTON16(33)
-
-#define IB_REJ_SERVICE_HANDOFF CL_HTON16(65535)
-/******/
-
-/****d* Access Layer/ib_apr_status_t
-* NAME
-* ib_apr_status_t
-*
-* DESCRIPTION
-* Automatic path migration status information.
-*
-* SYNOPSIS
-*/
-typedef uint8_t ib_apr_status_t;
-/*
-* SEE ALSO
-* ib_cm_apr, ib_cm_apr_rec_t
-*
-* SOURCE
- */
-#define IB_AP_SUCCESS 0
-#define IB_AP_INVALID_COMM_ID 1
-#define IB_AP_UNSUPPORTED 2
-#define IB_AP_REJECT 3
-#define IB_AP_REDIRECT 4
-#define IB_AP_IS_CURRENT 5
-#define IB_AP_INVALID_QPN_EECN 6
-#define IB_AP_INVALID_LID 7
-#define IB_AP_INVALID_GID 8
-#define IB_AP_INVALID_FLOW_LBL 9
-#define IB_AP_INVALID_TCLASS 10
-#define IB_AP_INVALID_HOP_LIMIT 11
-#define IB_AP_INVALID_PKT_RATE 12
-#define IB_AP_INVALID_SL 13
-/******/
-
-/****d* Access Layer/ib_cm_cap_mask_t
-* NAME
-* ib_cm_cap_mask_t
-*
-* DESCRIPTION
-* Capability mask values in ClassPortInfo.
-*
-* SYNOPSIS
-*/
-#define IB_CM_RELIABLE_CONN_CAPABLE CL_HTON16(9)
-#define IB_CM_RELIABLE_DGRM_CAPABLE CL_HTON16(10)
-#define IB_CM_RDGRM_CAPABLE CL_HTON16(11)
-#define IB_CM_UNRELIABLE_CONN_CAPABLE CL_HTON16(12)
-#define IB_CM_SIDR_CAPABLE CL_HTON16(13)
-/*
-* SEE ALSO
-* ib_cm_rep, ib_class_port_info_t
-*
-* SOURCE
-*
-*******/
-
-/*
- * Service ID resolution status
- */
-typedef uint16_t ib_sidr_status_t;
-#define IB_SIDR_SUCCESS 0
-#define IB_SIDR_UNSUPPORTED 1
-#define IB_SIDR_REJECT 2
-#define IB_SIDR_NO_QP 3
-#define IB_SIDR_REDIRECT 4
-#define IB_SIDR_UNSUPPORTED_VER 5
-
-END_C_DECLS
-#endif /* ndef WIN32 */
-#endif /* __IB_CM_TYPES_H__ */
diff --git a/contrib/ofed/management/opensm/include/iba/ib_types.h b/contrib/ofed/management/opensm/include/iba/ib_types.h
deleted file mode 100644
index 0f9d110..0000000
--- a/contrib/ofed/management/opensm/include/iba/ib_types.h
+++ /dev/null
@@ -1,10720 +0,0 @@
-/*
- * Copyright (c) 2004-2008 Voltaire, Inc. All rights reserved.
- * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved.
- * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- */
-
-#if !defined(__IB_TYPES_H__)
-#define __IB_TYPES_H__
-
-#include <string.h>
-#include <complib/cl_types.h>
-#include <complib/cl_byteswap.h>
-
-#ifdef __cplusplus
-# define BEGIN_C_DECLS extern "C" {
-# define END_C_DECLS }
-#else /* !__cplusplus */
-# define BEGIN_C_DECLS
-# define END_C_DECLS
-#endif /* __cplusplus */
-
-BEGIN_C_DECLS
-#if defined( WIN32 ) || defined( _WIN64 )
-#if defined( EXPORT_AL_SYMBOLS )
-#define OSM_EXPORT __declspec(dllexport)
-#else
-#define OSM_EXPORT __declspec(dllimport)
-#endif
-#define OSM_API __stdcall
-#define OSM_CDECL __cdecl
-#else
-#define OSM_EXPORT extern
-#define OSM_API
-#define OSM_CDECL
-#define __ptr64
-#endif
-/****h* IBA Base/Constants
-* NAME
-* Constants
-*
-* DESCRIPTION
-* The following constants are used throughout the IBA code base.
-*
-* Definitions are from the InfiniBand Architecture Specification v1.2
-*
-*********/
-/****d* IBA Base: Constants/MAD_BLOCK_SIZE
-* NAME
-* MAD_BLOCK_SIZE
-*
-* DESCRIPTION
-* Size of a non-RMPP MAD datagram.
-*
-* SOURCE
-*/
-#define MAD_BLOCK_SIZE 256
-/**********/
-/****d* IBA Base: Constants/MAD_RMPP_HDR_SIZE
-* NAME
-* MAD_RMPP_HDR_SIZE
-*
-* DESCRIPTION
-* Size of an RMPP header, including the common MAD header.
-*
-* SOURCE
-*/
-#define MAD_RMPP_HDR_SIZE 36
-/**********/
-/****d* IBA Base: Constants/MAD_RMPP_DATA_SIZE
-* NAME
-* MAD_RMPP_DATA_SIZE
-*
-* DESCRIPTION
-* Size of an RMPP transaction data section.
-*
-* SOURCE
-*/
-#define MAD_RMPP_DATA_SIZE (MAD_BLOCK_SIZE - MAD_RMPP_HDR_SIZE)
-/**********/
-/****d* IBA Base: Constants/MAD_BLOCK_GRH_SIZE
-* NAME
-* MAD_BLOCK_GRH_SIZE
-*
-* DESCRIPTION
-* Size of a MAD datagram, including the GRH.
-*
-* SOURCE
-*/
-#define MAD_BLOCK_GRH_SIZE 296
-/**********/
-/****d* IBA Base: Constants/IB_LID_PERMISSIVE
-* NAME
-* IB_LID_PERMISSIVE
-*
-* DESCRIPTION
-* Permissive LID
-*
-* SOURCE
-*/
-#define IB_LID_PERMISSIVE 0xFFFF
-/**********/
-/****d* IBA Base: Constants/IB_DEFAULT_PKEY
-* NAME
-* IB_DEFAULT_PKEY
-*
-* DESCRIPTION
-* P_Key value for the default partition.
-*
-* SOURCE
-*/
-#define IB_DEFAULT_PKEY 0xFFFF
-/**********/
-/****d* IBA Base: Constants/IB_QP1_WELL_KNOWN_Q_KEY
-* NAME
-* IB_QP1_WELL_KNOWN_Q_KEY
-*
-* DESCRIPTION
-* Well-known Q_Key for QP1 privileged mode access (15.4.2).
-*
-* SOURCE
-*/
-#define IB_QP1_WELL_KNOWN_Q_KEY CL_HTON32(0x80010000)
-/*********/
-#define IB_QP0 0
-#define IB_QP1 CL_HTON32(1)
-#define IB_QP_PRIVILEGED_Q_KEY CL_HTON32(0x80000000)
-/****d* IBA Base: Constants/IB_LID_UCAST_START
-* NAME
-* IB_LID_UCAST_START
-*
-* DESCRIPTION
-* Lowest valid unicast LID value.
-*
-* SOURCE
-*/
-#define IB_LID_UCAST_START_HO 0x0001
-#define IB_LID_UCAST_START (CL_HTON16(IB_LID_UCAST_START_HO))
-/**********/
-/****d* IBA Base: Constants/IB_LID_UCAST_END
-* NAME
-* IB_LID_UCAST_END
-*
-* DESCRIPTION
-* Highest valid unicast LID value.
-*
-* SOURCE
-*/
-#define IB_LID_UCAST_END_HO 0xBFFF
-#define IB_LID_UCAST_END (CL_HTON16(IB_LID_UCAST_END_HO))
-/**********/
-/****d* IBA Base: Constants/IB_LID_MCAST_START
-* NAME
-* IB_LID_MCAST_START
-*
-* DESCRIPTION
-* Lowest valid multicast LID value.
-*
-* SOURCE
-*/
-#define IB_LID_MCAST_START_HO 0xC000
-#define IB_LID_MCAST_START (CL_HTON16(IB_LID_MCAST_START_HO))
-/**********/
-/****d* IBA Base: Constants/IB_LID_MCAST_END
-* NAME
-* IB_LID_MCAST_END
-*
-* DESCRIPTION
-* Highest valid multicast LID value.
-*
-* SOURCE
-*/
-#define IB_LID_MCAST_END_HO 0xFFFE
-#define IB_LID_MCAST_END (CL_HTON16(IB_LID_MCAST_END_HO))
-/**********/
-/****d* IBA Base: Constants/IB_DEFAULT_SUBNET_PREFIX
-* NAME
-* IB_DEFAULT_SUBNET_PREFIX
-*
-* DESCRIPTION
-* Default subnet GID prefix.
-*
-* SOURCE
-*/
-#define IB_DEFAULT_SUBNET_PREFIX (CL_HTON64(0xFE80000000000000ULL))
-/**********/
-/****d* IBA Base: Constants/IB_NODE_NUM_PORTS_MAX
-* NAME
-* IB_NODE_NUM_PORTS_MAX
-*
-* DESCRIPTION
-* Maximum number of ports in a single node (14.2.5.7).
-* SOURCE
-*/
-#define IB_NODE_NUM_PORTS_MAX 0xFE
-/**********/
-/****d* IBA Base: Constants/IB_INVALID_PORT_NUM
-* NAME
-* IB_INVALID_PORT_NUM
-*
-* DESCRIPTION
-* Value used to indicate an invalid port number (14.2.5.10).
-*
-* SOURCE
-*/
-#define IB_INVALID_PORT_NUM 0xFF
-/*********/
-/****d* IBA Base: Constants/IB_SUBNET_PATH_HOPS_MAX
-* NAME
-* IB_SUBNET_PATH_HOPS_MAX
-*
-* DESCRIPTION
-* Maximum number of directed route switch hops in a subnet (14.2.1.2).
-*
-* SOURCE
-*/
-#define IB_SUBNET_PATH_HOPS_MAX 64
-/*********/
-/****d* IBA Base: Constants/IB_HOPLIMIT_MAX
-* NAME
-* IB_HOPLIMIT_MAX
-*
-* DESCRIPTION
-* Maximum number of router hops allowed.
-*
-* SOURCE
-*/
-#define IB_HOPLIMIT_MAX 255
-/*********/
-/****d* IBA Base: Constants/IB_MC_SCOPE_*
-* NAME
-* IB_MC_SCOPE_*
-*
-* DESCRIPTION
-* Scope component definitions from IBA 1.2 (Table 3 p. 146)
-*/
-#define IB_MC_SCOPE_LINK_LOCAL 0x2
-#define IB_MC_SCOPE_SITE_LOCAL 0x5
-#define IB_MC_SCOPE_ORG_LOCAL 0x8
-#define IB_MC_SCOPE_GLOBAL 0xE
-/*********/
-/****d* IBA Base: Constants/IB_PKEY_MAX_BLOCKS
-* NAME
-* IB_PKEY_MAX_BLOCKS
-*
-* DESCRIPTION
-* Maximum number of PKEY blocks (14.2.5.7).
-*
-* SOURCE
-*/
-#define IB_PKEY_MAX_BLOCKS 2048
-/*********/
-/****d* IBA Base: Constants/IB_MCAST_MAX_BLOCK_ID
-* NAME
-* IB_MCAST_MAX_BLOCK_ID
-*
-* DESCRIPTION
-* Maximum number of Multicast port mask blocks
-*
-* SOURCE
-*/
-#define IB_MCAST_MAX_BLOCK_ID 511
-/*********/
-/****d* IBA Base: Constants/IB_MCAST_BLOCK_ID_MASK_HO
-* NAME
-* IB_MCAST_BLOCK_ID_MASK_HO
-*
-* DESCRIPTION
-* Mask (host order) to recover the Multicast block ID.
-*
-* SOURCE
-*/
-#define IB_MCAST_BLOCK_ID_MASK_HO 0x000001FF
-/*********/
-/****d* IBA Base: Constants/IB_MCAST_BLOCK_SIZE
-* NAME
-* IB_MCAST_BLOCK_SIZE
-*
-* DESCRIPTION
-* Number of port mask entries in a multicast forwarding table block.
-*
-* SOURCE
-*/
-#define IB_MCAST_BLOCK_SIZE 32
-/*********/
-/****d* IBA Base: Constants/IB_MCAST_MASK_SIZE
-* NAME
-* IB_MCAST_MASK_SIZE
-*
-* DESCRIPTION
-* Number of port mask bits in each entry in the multicast forwarding table.
-*
-* SOURCE
-*/
-#define IB_MCAST_MASK_SIZE 16
-/*********/
-/****d* IBA Base: Constants/IB_MCAST_POSITION_MASK_HO
-* NAME
-* IB_MCAST_POSITION_MASK_HO
-*
-* DESCRIPTION
-* Mask (host order) to recover the multicast block position.
-*
-* SOURCE
-*/
-#define IB_MCAST_POSITION_MASK_HO 0xF0000000
-/*********/
-/****d* IBA Base: Constants/IB_MCAST_POSITION_MAX
-* NAME
-* IB_MCAST_POSITION_MAX
-*
-* DESCRIPTION
-* Maximum value for the multicast block position.
-*
-* SOURCE
-*/
-#define IB_MCAST_POSITION_MAX 0xF
-/*********/
-/****d* IBA Base: Constants/IB_MCAST_POSITION_SHIFT
-* NAME
-* IB_MCAST_POSITION_SHIFT
-*
-* DESCRIPTION
-* Shift value to normalize the multicast block position value.
-*
-* SOURCE
-*/
-#define IB_MCAST_POSITION_SHIFT 28
-/*********/
-/****d* IBA Base: Constants/IB_PKEY_ENTRIES_MAX
-* NAME
-* IB_PKEY_ENTRIES_MAX
-*
-* DESCRIPTION
-* Maximum number of PKEY entries per port (14.2.5.7).
-*
-* SOURCE
-*/
-#define IB_PKEY_ENTRIES_MAX (IB_PKEY_MAX_BLOCKS * IB_NUM_PKEY_ELEMENTS_IN_BLOCK)
-/*********/
-/****d* IBA Base: Constants/IB_PKEY_BASE_MASK
-* NAME
-* IB_PKEY_BASE_MASK
-*
-* DESCRIPTION
-* Masks for the base P_Key value given a P_Key Entry.
-*
-* SOURCE
-*/
-#define IB_PKEY_BASE_MASK (CL_HTON16(0x7FFF))
-/*********/
-/****d* IBA Base: Constants/IB_PKEY_TYPE_MASK
-* NAME
-* IB_PKEY_TYPE_MASK
-*
-* DESCRIPTION
-* Masks for the P_Key membership type given a P_Key Entry.
-*
-* SOURCE
-*/
-#define IB_PKEY_TYPE_MASK (CL_HTON16(0x8000))
-/*********/
-/****d* IBA Base: Constants/IB_DEFAULT_PARTIAL_PKEY
-* NAME
-* IB_DEFAULT_PARTIAL_PKEY
-*
-* DESCRIPTION
-* 0x7FFF in network order
-*
-* SOURCE
-*/
-#define IB_DEFAULT_PARTIAL_PKEY (CL_HTON16(0x7FFF))
-/**********/
-/****d* IBA Base: Constants/IB_MCLASS_SUBN_LID
-* NAME
-* IB_MCLASS_SUBN_LID
-*
-* DESCRIPTION
-* Subnet Management Class, Subnet Manager LID routed (13.4.4)
-*
-* SOURCE
-*/
-#define IB_MCLASS_SUBN_LID 0x01
-/**********/
-/****d* IBA Base: Constants/IB_MCLASS_SUBN_DIR
-* NAME
-* IB_MCLASS_SUBN_DIR
-*
-* DESCRIPTION
-* Subnet Management Class, Subnet Manager directed route (13.4.4)
-*
-* SOURCE
-*/
-#define IB_MCLASS_SUBN_DIR 0x81
-/**********/
-/****d* IBA Base: Constants/IB_MCLASS_SUBN_ADM
-* NAME
-* IB_MCLASS_SUBN_ADM
-*
-* DESCRIPTION
-* Management Class, Subnet Administration (13.4.4)
-*
-* SOURCE
-*/
-#define IB_MCLASS_SUBN_ADM 0x03
-/**********/
-/****d* IBA Base: Constants/IB_MCLASS_PERF
-* NAME
-* IB_MCLASS_PERF
-*
-* DESCRIPTION
-* Management Class, Performance Management (13.4.4)
-*
-* SOURCE
-*/
-#define IB_MCLASS_PERF 0x04
-/**********/
-/****d* IBA Base: Constants/IB_MCLASS_BM
-* NAME
-* IB_MCLASS_BM
-*
-* DESCRIPTION
-* Management Class, Baseboard Management (13.4.4)
-*
-* SOURCE
-*/
-#define IB_MCLASS_BM 0x05
-/**********/
-/****d* IBA Base: Constants/IB_MCLASS_DEV_MGMT
-* NAME
-* IB_MCLASS_DEV_MGMT
-*
-* DESCRIPTION
-* Management Class, Device Management (13.4.4)
-*
-* SOURCE
-*/
-#define IB_MCLASS_DEV_MGMT 0x06
-/**********/
-/****d* IBA Base: Constants/IB_MCLASS_COMM_MGMT
-* NAME
-* IB_MCLASS_COMM_MGMT
-*
-* DESCRIPTION
-* Management Class, Communication Management (13.4.4)
-*
-* SOURCE
-*/
-#define IB_MCLASS_COMM_MGMT 0x07
-/**********/
-/****d* IBA Base: Constants/IB_MCLASS_SNMP
-* NAME
-* IB_MCLASS_SNMP
-*
-* DESCRIPTION
-* Management Class, SNMP Tunneling (13.4.4)
-*
-* SOURCE
-*/
-#define IB_MCLASS_SNMP 0x08
-/**********/
-/****d* IBA Base: Constants/IB_MCLASS_VENDOR_LOW_RANGE_MIN
-* NAME
-* IB_MCLASS_VENDOR_LOW_RANGE_MIN
-*
-* DESCRIPTION
-* Management Class, Vendor Specific Low Range Start
-*
-* SOURCE
-*/
-#define IB_MCLASS_VENDOR_LOW_RANGE_MIN 0x09
-/**********/
-/****d* IBA Base: Constants/IB_MCLASS_VENDOR_LOW_RANGE_MAX
-* NAME
-* IB_MCLASS_VENDOR_LOW_RANGE_MAX
-*
-* DESCRIPTION
-* Management Class, Vendor Specific Low Range End
-*
-* SOURCE
-*/
-#define IB_MCLASS_VENDOR_LOW_RANGE_MAX 0x0f
-/**********/
-/****d* IBA Base: Constants/IB_MCLASS_DEV_ADM
-* NAME
-* IB_MCLASS_DEV_ADM
-*
-* DESCRIPTION
-* Management Class, Device Administration
-*
-* SOURCE
-*/
-#define IB_MCLASS_DEV_ADM 0x10
-/**********/
-/****d* IBA Base: Constants/IB_MCLASS_BIS
-* NAME
-* IB_MCLASS_BIS
-*
-* DESCRIPTION
-* Management Class, BIS
-*
-* SOURCE
-*/
-#define IB_MCLASS_BIS 0x12
-/**********/
-/****d* IBA Base: Constants/IB_MCLASS_VENDOR_HIGH_RANGE_MIN
-* NAME
-* IB_MCLASS_VENDOR_HIGH_RANGE_MIN
-*
-* DESCRIPTION
-* Management Class, Vendor Specific High Range Start
-*
-* SOURCE
-*/
-#define IB_MCLASS_VENDOR_HIGH_RANGE_MIN 0x30
-/**********/
-/****d* IBA Base: Constants/IB_MCLASS_VENDOR_HIGH_RANGE_MAX
-* NAME
-* IB_MCLASS_VENDOR_HIGH_RANGE_MAX
-*
-* DESCRIPTION
-* Management Class, Vendor Specific High Range End
-*
-* SOURCE
-*/
-#define IB_MCLASS_VENDOR_HIGH_RANGE_MAX 0x4f
-/**********/
-/****f* IBA Base: Types/ib_class_is_vendor_specific_low
-* NAME
-* ib_class_is_vendor_specific_low
-*
-* DESCRIPTION
-* Indicates if the Class Code if a vendor specific class from
-* the low range
-*
-* SYNOPSIS
-*/
-static inline boolean_t OSM_API
-ib_class_is_vendor_specific_low(IN const uint8_t class_code)
-{
- return ((class_code >= IB_MCLASS_VENDOR_LOW_RANGE_MIN) &&
- (class_code <= IB_MCLASS_VENDOR_LOW_RANGE_MAX));
-}
-
-/*
-* PARAMETERS
-* class_code
-* [in] The Management Datagram Class Code
-*
-* RETURN VALUE
-* TRUE if the class is in the Low range of Vendor Specific MADs
-* FALSE otherwise.
-*
-* NOTES
-*
-* SEE ALSO
-* IB_MCLASS_VENDOR_LOW_RANGE_MIN, IB_MCLASS_VENDOR_LOW_RANGE_MAX
-*********/
-
-/****f* IBA Base: Types/ib_class_is_vendor_specific_high
-* NAME
-* ib_class_is_vendor_specific_high
-*
-* DESCRIPTION
-* Indicates if the Class Code if a vendor specific class from
-* the high range
-*
-* SYNOPSIS
-*/
-static inline boolean_t OSM_API
-ib_class_is_vendor_specific_high(IN const uint8_t class_code)
-{
- return ((class_code >= IB_MCLASS_VENDOR_HIGH_RANGE_MIN) &&
- (class_code <= IB_MCLASS_VENDOR_HIGH_RANGE_MAX));
-}
-
-/*
-* PARAMETERS
-* class_code
-* [in] The Management Datagram Class Code
-*
-* RETURN VALUE
-* TRUE if the class is in the High range of Vendor Specific MADs
-* FALSE otherwise.
-*
-* NOTES
-*
-* SEE ALSO
-* IB_MCLASS_VENDOR_HIGH_RANGE_MIN, IB_MCLASS_VENDOR_HIGH_RANGE_MAX
-*********/
-
-/****f* IBA Base: Types/ib_class_is_vendor_specific
-* NAME
-* ib_class_is_vendor_specific
-*
-* DESCRIPTION
-* Indicates if the Class Code if a vendor specific class
-*
-* SYNOPSIS
-*/
-static inline boolean_t OSM_API
-ib_class_is_vendor_specific(IN const uint8_t class_code)
-{
- return (ib_class_is_vendor_specific_low(class_code) ||
- ib_class_is_vendor_specific_high(class_code));
-}
-
-/*
-* PARAMETERS
-* class_code
-* [in] The Management Datagram Class Code
-*
-* RETURN VALUE
-* TRUE if the class is a Vendor Specific MAD
-* FALSE otherwise.
-*
-* NOTES
-*
-* SEE ALSO
-* ib_class_is_vendor_specific_low, ib_class_is_vendor_specific_high
-*********/
-
-/****f* IBA Base: Types/ib_class_is_rmpp
-* NAME
-* ib_class_is_rmpp
-*
-* DESCRIPTION
-* Indicates if the Class Code supports RMPP
-*
-* SYNOPSIS
-*/
-static inline boolean_t OSM_API ib_class_is_rmpp(IN const uint8_t class_code)
-{
- return ((class_code == IB_MCLASS_SUBN_ADM) ||
- (class_code == IB_MCLASS_DEV_MGMT) ||
- (class_code == IB_MCLASS_DEV_ADM) ||
- (class_code == IB_MCLASS_BIS) ||
- ib_class_is_vendor_specific_high(class_code));
-}
-
-/*
-* PARAMETERS
-* class_code
-* [in] The Management Datagram Class Code
-*
-* RETURN VALUE
-* TRUE if the class supports RMPP
-* FALSE otherwise.
-*
-* NOTES
-*
-*********/
-
-/*
- * MAD methods
- */
-
-/****d* IBA Base: Constants/IB_MAX_METHOD
-* NAME
-* IB_MAX_METHOD
-*
-* DESCRIPTION
-* Total number of methods available to a class, not including the R-bit.
-*
-* SOURCE
-*/
-#define IB_MAX_METHODS 128
-/**********/
-
-/****d* IBA Base: Constants/IB_MAD_METHOD_RESP_MASK
-* NAME
-* IB_MAD_METHOD_RESP_MASK
-*
-* DESCRIPTION
-* Response mask to extract 'R' bit from the method field. (13.4.5)
-*
-* SOURCE
-*/
-#define IB_MAD_METHOD_RESP_MASK 0x80
-/**********/
-
-/****d* IBA Base: Constants/IB_MAD_METHOD_GET
-* NAME
-* IB_MAD_METHOD_GET
-*
-* DESCRIPTION
-* Get() Method (13.4.5)
-*
-* SOURCE
-*/
-#define IB_MAD_METHOD_GET 0x01
-/**********/
-
-/****d* IBA Base: Constants/IB_MAD_METHOD_SET
-* NAME
-* IB_MAD_METHOD_SET
-*
-* DESCRIPTION
-* Set() Method (13.4.5)
-*
-* SOURCE
-*/
-#define IB_MAD_METHOD_SET 0x02
-/**********/
-
-/****d* IBA Base: Constants/IB_MAD_METHOD_GET_RESP
-* NAME
-* IB_MAD_METHOD_GET_RESP
-*
-* DESCRIPTION
-* GetResp() Method (13.4.5)
-*
-* SOURCE
-*/
-#define IB_MAD_METHOD_GET_RESP 0x81
-/**********/
-
-#define IB_MAD_METHOD_DELETE 0x15
-
-/****d* IBA Base: Constants/IB_MAD_METHOD_GETTABLE
-* NAME
-* IB_MAD_METHOD_GETTABLE
-*
-* DESCRIPTION
-* SubnAdmGetTable() Method (15.2.2)
-*
-* SOURCE
-*/
-#define IB_MAD_METHOD_GETTABLE 0x12
-/**********/
-
-/****d* IBA Base: Constants/IB_MAD_METHOD_GETTABLE_RESP
-* NAME
-* IB_MAD_METHOD_GETTABLE_RESP
-*
-* DESCRIPTION
-* SubnAdmGetTableResp() Method (15.2.2)
-*
-* SOURCE
-*/
-#define IB_MAD_METHOD_GETTABLE_RESP 0x92
-
-/**********/
-
-#define IB_MAD_METHOD_GETTRACETABLE 0x13
-#define IB_MAD_METHOD_GETMULTI 0x14
-#define IB_MAD_METHOD_GETMULTI_RESP 0x94
-
-/****d* IBA Base: Constants/IB_MAD_METHOD_SEND
-* NAME
-* IB_MAD_METHOD_SEND
-*
-* DESCRIPTION
-* Send() Method (13.4.5)
-*
-* SOURCE
-*/
-#define IB_MAD_METHOD_SEND 0x03
-/**********/
-
-/****d* IBA Base: Constants/IB_MAD_METHOD_TRAP
-* NAME
-* IB_MAD_METHOD_TRAP
-*
-* DESCRIPTION
-* Trap() Method (13.4.5)
-*
-* SOURCE
-*/
-#define IB_MAD_METHOD_TRAP 0x05
-/**********/
-
-/****d* IBA Base: Constants/IB_MAD_METHOD_REPORT
-* NAME
-* IB_MAD_METHOD_REPORT
-*
-* DESCRIPTION
-* Report() Method (13.4.5)
-*
-* SOURCE
-*/
-#define IB_MAD_METHOD_REPORT 0x06
-/**********/
-
-/****d* IBA Base: Constants/IB_MAD_METHOD_REPORT_RESP
-* NAME
-* IB_MAD_METHOD_REPORT_RESP
-*
-* DESCRIPTION
-* ReportResp() Method (13.4.5)
-*
-* SOURCE
-*/
-#define IB_MAD_METHOD_REPORT_RESP 0x86
-/**********/
-
-/****d* IBA Base: Constants/IB_MAD_METHOD_TRAP_REPRESS
-* NAME
-* IB_MAD_METHOD_TRAP_REPRESS
-*
-* DESCRIPTION
-* TrapRepress() Method (13.4.5)
-*
-* SOURCE
-*/
-#define IB_MAD_METHOD_TRAP_REPRESS 0x07
-/**********/
-
-/****d* IBA Base: Constants/IB_MAD_STATUS_BUSY
-* NAME
-* IB_MAD_STATUS_BUSY
-*
-* DESCRIPTION
-* Temporarily busy, MAD discarded (13.4.7)
-*
-* SOURCE
-*/
-#define IB_MAD_STATUS_BUSY (CL_HTON16(0x0001))
-/**********/
-
-/****d* IBA Base: Constants/IB_MAD_STATUS_REDIRECT
-* NAME
-* IB_MAD_STATUS_REDIRECT
-*
-* DESCRIPTION
-* QP Redirection required (13.4.7)
-*
-* SOURCE
-*/
-#define IB_MAD_STATUS_REDIRECT (CL_HTON16(0x0002))
-/**********/
-
-/****d* IBA Base: Constants/IB_MAD_STATUS_UNSUP_CLASS_VER
-* NAME
-* IB_MAD_STATUS_UNSUP_CLASS_VER
-*
-* DESCRIPTION
-* Unsupported class version (13.4.7)
-*
-* SOURCE
-*/
-#define IB_MAD_STATUS_UNSUP_CLASS_VER (CL_HTON16(0x0004))
-/**********/
-
-/****d* IBA Base: Constants/IB_MAD_STATUS_UNSUP_METHOD
-* NAME
-* IB_MAD_STATUS_UNSUP_METHOD
-*
-* DESCRIPTION
-* Unsupported method (13.4.7)
-*
-* SOURCE
-*/
-#define IB_MAD_STATUS_UNSUP_METHOD (CL_HTON16(0x0008))
-/**********/
-
-/****d* IBA Base: Constants/IB_MAD_STATUS_UNSUP_METHOD_ATTR
-* NAME
-* IB_MAD_STATUS_UNSUP_METHOD_ATTR
-*
-* DESCRIPTION
-* Unsupported method/attribute combination (13.4.7)
-*
-* SOURCE
-*/
-#define IB_MAD_STATUS_UNSUP_METHOD_ATTR (CL_HTON16(0x000C))
-/**********/
-
-/****d* IBA Base: Constants/IB_MAD_STATUS_INVALID_FIELD
-* NAME
-* IB_MAD_STATUS_INVALID_FIELD
-*
-* DESCRIPTION
-* Attribute contains one or more invalid fields (13.4.7)
-*
-* SOURCE
-*/
-#define IB_MAD_STATUS_INVALID_FIELD (CL_HTON16(0x001C))
-/**********/
-
-#define IB_MAD_STATUS_CLASS_MASK (CL_HTON16(0xFF00))
-
-#define IB_SA_MAD_STATUS_SUCCESS (CL_HTON16(0x0000))
-#define IB_SA_MAD_STATUS_NO_RESOURCES (CL_HTON16(0x0100))
-#define IB_SA_MAD_STATUS_REQ_INVALID (CL_HTON16(0x0200))
-#define IB_SA_MAD_STATUS_NO_RECORDS (CL_HTON16(0x0300))
-#define IB_SA_MAD_STATUS_TOO_MANY_RECORDS (CL_HTON16(0x0400))
-#define IB_SA_MAD_STATUS_INVALID_GID (CL_HTON16(0x0500))
-#define IB_SA_MAD_STATUS_INSUF_COMPS (CL_HTON16(0x0600))
-#define IB_SA_MAD_STATUS_DENIED (CL_HTON16(0x0700))
-#define IB_SA_MAD_STATUS_PRIO_SUGGESTED (CL_HTON16(0x0800))
-
-#define IB_DM_MAD_STATUS_NO_IOC_RESP (CL_HTON16(0x0100))
-#define IB_DM_MAD_STATUS_NO_SVC_ENTRIES (CL_HTON16(0x0200))
-#define IB_DM_MAD_STATUS_IOC_FAILURE (CL_HTON16(0x8000))
-
-/****d* IBA Base: Constants/IB_MAD_ATTR_CLASS_PORT_INFO
-* NAME
-* IB_MAD_ATTR_CLASS_PORT_INFO
-*
-* DESCRIPTION
-* ClassPortInfo attribute (13.4.8)
-*
-* SOURCE
-*/
-#define IB_MAD_ATTR_CLASS_PORT_INFO (CL_HTON16(0x0001))
-/**********/
-
-/****d* IBA Base: Constants/IB_MAD_ATTR_NOTICE
-* NAME
-* IB_MAD_ATTR_NOTICE
-*
-* DESCRIPTION
-* Notice attribute (13.4.8)
-*
-* SOURCE
-*/
-#define IB_MAD_ATTR_NOTICE (CL_HTON16(0x0002))
-/**********/
-
-/****d* IBA Base: Constants/IB_MAD_ATTR_INFORM_INFO
-* NAME
-* IB_MAD_ATTR_INFORM_INFO
-*
-* DESCRIPTION
-* InformInfo attribute (13.4.8)
-*
-* SOURCE
-*/
-#define IB_MAD_ATTR_INFORM_INFO (CL_HTON16(0x0003))
-/**********/
-
-/****d* IBA Base: Constants/IB_MAD_ATTR_NODE_DESC
-* NAME
-* IB_MAD_ATTR_NODE_DESC
-*
-* DESCRIPTION
-* NodeDescription attribute (14.2.5)
-*
-* SOURCE
-*/
-#define IB_MAD_ATTR_NODE_DESC (CL_HTON16(0x0010))
-
-/****d* IBA Base: Constants/IB_MAD_ATTR_PORT_SMPL_CTRL
-* NAME
-* IB_MAD_ATTR_PORT_SMPL_CTRL
-*
-* DESCRIPTION
-* PortSamplesControl attribute (16.1.3)
-*
-* SOURCE
-*/
-#define IB_MAD_ATTR_PORT_SMPL_CTRL (CL_HTON16(0x0010))
-/**********/
-
-/****d* IBA Base: Constants/IB_MAD_ATTR_NODE_INFO
-* NAME
-* IB_MAD_ATTR_NODE_INFO
-*
-* DESCRIPTION
-* NodeInfo attribute (14.2.5)
-*
-* SOURCE
-*/
-#define IB_MAD_ATTR_NODE_INFO (CL_HTON16(0x0011))
-/**********/
-
-/****d* IBA Base: Constants/IB_MAD_ATTR_PORT_SMPL_RSLT
-* NAME
-* IB_MAD_ATTR_PORT_SMPL_RSLT
-*
-* DESCRIPTION
-* PortSamplesResult attribute (16.1.3)
-*
-* SOURCE
-*/
-#define IB_MAD_ATTR_PORT_SMPL_RSLT (CL_HTON16(0x0011))
-/**********/
-
-/****d* IBA Base: Constants/IB_MAD_ATTR_SWITCH_INFO
-* NAME
-* IB_MAD_ATTR_SWITCH_INFO
-*
-* DESCRIPTION
-* SwitchInfo attribute (14.2.5)
-*
-* SOURCE
-*/
-#define IB_MAD_ATTR_SWITCH_INFO (CL_HTON16(0x0012))
-/**********/
-
-/****d* IBA Base: Constants/IB_MAD_ATTR_PORT_CNTRS
-* NAME
-* IB_MAD_ATTR_PORT_CNTRS
-*
-* DESCRIPTION
-* PortCounters attribute (16.1.3)
-*
-* SOURCE
-*/
-#define IB_MAD_ATTR_PORT_CNTRS (CL_HTON16(0x0012))
-/**********/
-
-/****d* IBA Base: Constants/IB_MAD_ATTR_GUID_INFO
-* NAME
-* IB_MAD_ATTR_GUID_INFO
-*
-* DESCRIPTION
-* GUIDInfo attribute (14.2.5)
-*
-* SOURCE
-*/
-#define IB_MAD_ATTR_GUID_INFO (CL_HTON16(0x0014))
-/**********/
-
-/****d* IBA Base: Constants/IB_MAD_ATTR_PORT_INFO
-* NAME
-* IB_MAD_ATTR_PORT_INFO
-*
-* DESCRIPTION
-* PortInfo attribute (14.2.5)
-*
-* SOURCE
-*/
-#define IB_MAD_ATTR_PORT_INFO (CL_HTON16(0x0015))
-/**********/
-
-/****d* IBA Base: Constants/IB_MAD_ATTR_P_KEY_TABLE
-* NAME
-* IB_MAD_ATTR_P_KEY_TABLE
-*
-* DESCRIPTION
-* PartitionTable attribute (14.2.5)
-*
-* SOURCE
-*/
-#define IB_MAD_ATTR_P_KEY_TABLE (CL_HTON16(0x0016))
-/**********/
-
-/****d* IBA Base: Constants/IB_MAD_ATTR_SLVL_TABLE
-* NAME
-* IB_MAD_ATTR_SLVL_TABLE
-*
-* DESCRIPTION
-* SL VL Mapping Table attribute (14.2.5)
-*
-* SOURCE
-*/
-#define IB_MAD_ATTR_SLVL_TABLE (CL_HTON16(0x0017))
-/**********/
-
-/****d* IBA Base: Constants/IB_MAD_ATTR_VL_ARBITRATION
-* NAME
-* IB_MAD_ATTR_VL_ARBITRATION
-*
-* DESCRIPTION
-* VL Arbitration Table attribute (14.2.5)
-*
-* SOURCE
-*/
-#define IB_MAD_ATTR_VL_ARBITRATION (CL_HTON16(0x0018))
-/**********/
-
-/****d* IBA Base: Constants/IB_MAD_ATTR_LIN_FWD_TBL
-* NAME
-* IB_MAD_ATTR_LIN_FWD_TBL
-*
-* DESCRIPTION
-* Switch linear forwarding table
-*
-* SOURCE
-*/
-#define IB_MAD_ATTR_LIN_FWD_TBL (CL_HTON16(0x0019))
-/**********/
-
-/****d* IBA Base: Constants/IB_MAD_ATTR_RND_FWD_TBL
-* NAME
-* IB_MAD_ATTR_RND_FWD_TBL
-*
-* DESCRIPTION
-* Switch random forwarding table
-*
-* SOURCE
-*/
-#define IB_MAD_ATTR_RND_FWD_TBL (CL_HTON16(0x001A))
-/**********/
-
-/****d* IBA Base: Constants/IB_MAD_ATTR_MCAST_FWD_TBL
-* NAME
-* IB_MAD_ATTR_MCAST_FWD_TBL
-*
-* DESCRIPTION
-* Switch multicast forwarding table
-*
-* SOURCE
-*/
-#define IB_MAD_ATTR_MCAST_FWD_TBL (CL_HTON16(0x001B))
-/**********/
-
-/****d* IBA Base: Constants/IB_MAD_ATTR_NODE_RECORD
-* NAME
-* IB_MAD_ATTR_NODE_RECORD
-*
-* DESCRIPTION
-* NodeRecord attribute (15.2.5)
-*
-* SOURCE
-*/
-#define IB_MAD_ATTR_NODE_RECORD (CL_HTON16(0x0011))
-/**********/
-
-/****d* IBA Base: Constants/IB_MAD_ATTR_PORTINFO_RECORD
-* NAME
-* IB_MAD_ATTR_PORTINFO_RECORD
-*
-* DESCRIPTION
-* PortInfoRecord attribute (15.2.5)
-*
-* SOURCE
-*/
-#define IB_MAD_ATTR_PORTINFO_RECORD (CL_HTON16(0x0012))
-/**********/
-
-/****d* IBA Base: Constants/IB_MAD_ATTR_SWITCH_INFO_RECORD
-* NAME
-* IB_MAD_ATTR_SWITCH_INFO_RECORD
-*
-* DESCRIPTION
-* SwitchInfoRecord attribute (15.2.5)
-*
-* SOURCE
-*/
-#define IB_MAD_ATTR_SWITCH_INFO_RECORD (CL_HTON16(0x0014))
-/**********/
-
-/****d* IBA Base: Constants/IB_MAD_ATTR_LINK_RECORD
-* NAME
-* IB_MAD_ATTR_LINK_RECORD
-*
-* DESCRIPTION
-* LinkRecord attribute (15.2.5)
-*
-* SOURCE
-*/
-#define IB_MAD_ATTR_LINK_RECORD (CL_HTON16(0x0020))
-/**********/
-
-/****d* IBA Base: Constants/IB_MAD_ATTR_SM_INFO
-* NAME
-* IB_MAD_ATTR_SM_INFO
-*
-* DESCRIPTION
-* SMInfo attribute (14.2.5)
-*
-* SOURCE
-*/
-#define IB_MAD_ATTR_SM_INFO (CL_HTON16(0x0020))
-/**********/
-
-/****d* IBA Base: Constants/IB_MAD_ATTR_SMINFO_RECORD
-* NAME
-* IB_MAD_ATTR_SMINFO_RECORD
-*
-* DESCRIPTION
-* SMInfoRecord attribute (15.2.5)
-*
-* SOURCE
-*/
-#define IB_MAD_ATTR_SMINFO_RECORD (CL_HTON16(0x0018))
-/**********/
-
-/****d* IBA Base: Constants/IB_MAD_ATTR_GUIDINFO_RECORD
-* NAME
-* IB_MAD_ATTR_GUIDINFO_RECORD
-*
-* DESCRIPTION
-* GuidInfoRecord attribute (15.2.5)
-*
-* SOURCE
-*/
-#define IB_MAD_ATTR_GUIDINFO_RECORD (CL_HTON16(0x0030))
-/**********/
-
-/****d* IBA Base: Constants/IB_MAD_ATTR_VENDOR_DIAG
-* NAME
-* IB_MAD_ATTR_VENDOR_DIAG
-*
-* DESCRIPTION
-* VendorDiag attribute (14.2.5)
-*
-* SOURCE
-*/
-#define IB_MAD_ATTR_VENDOR_DIAG (CL_HTON16(0x0030))
-/**********/
-
-/****d* IBA Base: Constants/IB_MAD_ATTR_LED_INFO
-* NAME
-* IB_MAD_ATTR_LED_INFO
-*
-* DESCRIPTION
-* LedInfo attribute (14.2.5)
-*
-* SOURCE
-*/
-#define IB_MAD_ATTR_LED_INFO (CL_HTON16(0x0031))
-/**********/
-
-/****d* IBA Base: Constants/IB_MAD_ATTR_SERVICE_RECORD
-* NAME
-* IB_MAD_ATTR_SERVICE_RECORD
-*
-* DESCRIPTION
-* ServiceRecord attribute (15.2.5)
-*
-* SOURCE
-*/
-#define IB_MAD_ATTR_SERVICE_RECORD (CL_HTON16(0x0031))
-/**********/
-
-/****d* IBA Base: Constants/IB_MAD_ATTR_LFT_RECORD
-* NAME
-* IB_MAD_ATTR_LFT_RECORD
-*
-* DESCRIPTION
-* LinearForwardingTableRecord attribute (15.2.5.6)
-*
-* SOURCE
-*/
-#define IB_MAD_ATTR_LFT_RECORD (CL_HTON16(0x0015))
-/**********/
-
-/****d* IBA Base: Constants/IB_MAD_ATTR_MFT_RECORD
-* NAME
-* IB_MAD_ATTR_MFT_RECORD
-*
-* DESCRIPTION
-* MulticastForwardingTableRecord attribute (15.2.5.8)
-*
-* SOURCE
-*/
-#define IB_MAD_ATTR_MFT_RECORD (CL_HTON16(0x0017))
-/**********/
-
-/****d* IBA Base: Constants/IB_MAD_ATTR_PKEYTBL_RECORD
-* NAME
-* IB_MAD_ATTR_PKEYTBL_RECORD
-*
-* DESCRIPTION
-* PKEY Table Record attribute (15.2.5)
-*
-* SOURCE
-*/
-#define IB_MAD_ATTR_PKEY_TBL_RECORD (CL_HTON16(0x0033))
-/**********/
-
-/****d* IBA Base: Constants/IB_MAD_ATTR_PATH_RECORD
-* NAME
-* IB_MAD_ATTR_PATH_RECORD
-*
-* DESCRIPTION
-* PathRecord attribute (15.2.5)
-*
-* SOURCE
-*/
-#define IB_MAD_ATTR_PATH_RECORD (CL_HTON16(0x0035))
-/**********/
-
-/****d* IBA Base: Constants/IB_MAD_ATTR_VLARB_RECORD
-* NAME
-* IB_MAD_ATTR_VLARB_RECORD
-*
-* DESCRIPTION
-* VL Arbitration Table Record attribute (15.2.5)
-*
-* SOURCE
-*/
-#define IB_MAD_ATTR_VLARB_RECORD (CL_HTON16(0x0036))
-/**********/
-
-/****d* IBA Base: Constants/IB_MAD_ATTR_SLVL_RECORD
-* NAME
-* IB_MAD_ATTR_SLVL_RECORD
-*
-* DESCRIPTION
-* SLtoVL Mapping Table Record attribute (15.2.5)
-*
-* SOURCE
-*/
-#define IB_MAD_ATTR_SLVL_RECORD (CL_HTON16(0x0013))
-/**********/
-
-/****d* IBA Base: Constants/IB_MAD_ATTR_MCMEMBER_RECORD
-* NAME
-* IB_MAD_ATTR_MCMEMBER_RECORD
-*
-* DESCRIPTION
-* MCMemberRecord attribute (15.2.5)
-*
-* SOURCE
-*/
-#define IB_MAD_ATTR_MCMEMBER_RECORD (CL_HTON16(0x0038))
-/**********/
-
-/****d* IBA Base: Constants/IB_MAD_ATTR_TRACE_RECORD
-* NAME
-* IB_MAD_ATTR_TRACE_RECORD
-*
-* DESCRIPTION
-* TraceRecord attribute (15.2.5)
-*
-* SOURCE
-*/
-#define IB_MAD_ATTR_TRACE_RECORD (CL_HTON16(0x0039))
-/**********/
-
-/****d* IBA Base: Constants/IB_MAD_ATTR_MULTIPATH_RECORD
-* NAME
-* IB_MAD_ATTR_MULTIPATH_RECORD
-*
-* DESCRIPTION
-* MultiPathRecord attribute (15.2.5)
-*
-* SOURCE
-*/
-#define IB_MAD_ATTR_MULTIPATH_RECORD (CL_HTON16(0x003A))
-/**********/
-
-/****d* IBA Base: Constants/IB_MAD_ATTR_SVC_ASSOCIATION_RECORD
-* NAME
-* IB_MAD_ATTR_SVC_ASSOCIATION_RECORD
-*
-* DESCRIPTION
-* Service Association Record attribute (15.2.5)
-*
-* SOURCE
-*/
-#define IB_MAD_ATTR_SVC_ASSOCIATION_RECORD (CL_HTON16(0x003B))
-/**********/
-
-/****d* IBA Base: Constants/IB_MAD_ATTR_INFORM_INFO_RECORD
-* NAME
-* IB_MAD_ATTR_INFORM_INFO_RECORD
-*
-* DESCRIPTION
-* InformInfo Record attribute (15.2.5)
-*
-* SOURCE
-*/
-#define IB_MAD_ATTR_INFORM_INFO_RECORD (CL_HTON16(0x00F3))
-
-/****d* IBA Base: Constants/IB_MAD_ATTR_IO_UNIT_INFO
-* NAME
-* IB_MAD_ATTR_IO_UNIT_INFO
-*
-* DESCRIPTION
-* IOUnitInfo attribute (16.3.3)
-*
-* SOURCE
-*/
-#define IB_MAD_ATTR_IO_UNIT_INFO (CL_HTON16(0x0010))
-/**********/
-
-/****d* IBA Base: Constants/IB_MAD_ATTR_IO_CONTROLLER_PROFILE
-* NAME
-* IB_MAD_ATTR_IO_CONTROLLER_PROFILE
-*
-* DESCRIPTION
-* IOControllerProfile attribute (16.3.3)
-*
-* SOURCE
-*/
-#define IB_MAD_ATTR_IO_CONTROLLER_PROFILE (CL_HTON16(0x0011))
-/**********/
-
-/****d* IBA Base: Constants/IB_MAD_ATTR_SERVICE_ENTRIES
-* NAME
-* IB_MAD_ATTR_SERVICE_ENTRIES
-*
-* DESCRIPTION
-* ServiceEntries attribute (16.3.3)
-*
-* SOURCE
-*/
-#define IB_MAD_ATTR_SERVICE_ENTRIES (CL_HTON16(0x0012))
-/**********/
-
-/****d* IBA Base: Constants/IB_MAD_ATTR_DIAGNOSTIC_TIMEOUT
-* NAME
-* IB_MAD_ATTR_DIAGNOSTIC_TIMEOUT
-*
-* DESCRIPTION
-* DiagnosticTimeout attribute (16.3.3)
-*
-* SOURCE
-*/
-#define IB_MAD_ATTR_DIAGNOSTIC_TIMEOUT (CL_HTON16(0x0020))
-/**********/
-
-/****d* IBA Base: Constants/IB_MAD_ATTR_PREPARE_TO_TEST
-* NAME
-* IB_MAD_ATTR_PREPARE_TO_TEST
-*
-* DESCRIPTION
-* PrepareToTest attribute (16.3.3)
-*
-* SOURCE
-*/
-#define IB_MAD_ATTR_PREPARE_TO_TEST (CL_HTON16(0x0021))
-/**********/
-
-/****d* IBA Base: Constants/IB_MAD_ATTR_TEST_DEVICE_ONCE
-* NAME
-* IB_MAD_ATTR_TEST_DEVICE_ONCE
-*
-* DESCRIPTION
-* TestDeviceOnce attribute (16.3.3)
-*
-* SOURCE
-*/
-#define IB_MAD_ATTR_TEST_DEVICE_ONCE (CL_HTON16(0x0022))
-/**********/
-
-/****d* IBA Base: Constants/IB_MAD_ATTR_TEST_DEVICE_LOOP
-* NAME
-* IB_MAD_ATTR_TEST_DEVICE_LOOP
-*
-* DESCRIPTION
-* TestDeviceLoop attribute (16.3.3)
-*
-* SOURCE
-*/
-#define IB_MAD_ATTR_TEST_DEVICE_LOOP (CL_HTON16(0x0023))
-/**********/
-
-/****d* IBA Base: Constants/IB_MAD_ATTR_DIAG_CODE
-* NAME
-* IB_MAD_ATTR_DIAG_CODE
-*
-* DESCRIPTION
-* DiagCode attribute (16.3.3)
-*
-* SOURCE
-*/
-#define IB_MAD_ATTR_DIAG_CODE (CL_HTON16(0x0024))
-/**********/
-
-/****d* IBA Base: Constants/IB_MAD_ATTR_SVC_ASSOCIATION_RECORD
-* NAME
-* IB_MAD_ATTR_SVC_ASSOCIATION_RECORD
-*
-* DESCRIPTION
-* Service Association Record attribute (15.2.5)
-*
-* SOURCE
-*/
-#define IB_MAD_ATTR_SVC_ASSOCIATION_RECORD (CL_HTON16(0x003B))
-/**********/
-
-/****d* IBA Base: Constants/IB_NODE_TYPE_CA
-* NAME
-* IB_NODE_TYPE_CA
-*
-* DESCRIPTION
-* Encoded generic node type used in MAD attributes (13.4.8.2)
-*
-* SOURCE
-*/
-#define IB_NODE_TYPE_CA 0x01
-/**********/
-
-/****d* IBA Base: Constants/IB_NODE_TYPE_SWITCH
-* NAME
-* IB_NODE_TYPE_SWITCH
-*
-* DESCRIPTION
-* Encoded generic node type used in MAD attributes (13.4.8.2)
-*
-* SOURCE
-*/
-#define IB_NODE_TYPE_SWITCH 0x02
-/**********/
-
-/****d* IBA Base: Constants/IB_NODE_TYPE_ROUTER
-* NAME
-* IB_NODE_TYPE_ROUTER
-*
-* DESCRIPTION
-* Encoded generic node type used in MAD attributes (13.4.8.2)
-*
-* SOURCE
-*/
-#define IB_NODE_TYPE_ROUTER 0x03
-/**********/
-
-/****d* IBA Base: Constants/IB_NOTICE_PRODUCER_TYPE_CA
-* NAME
-* IB_NOTICE_PRODUCER_TYPE_CA
-*
-* DESCRIPTION
-* Encoded generic producer type used in Notice attribute (13.4.8.2)
-*
-* SOURCE
-*/
-#define IB_NOTICE_PRODUCER_TYPE_CA (CL_HTON32(0x000001))
-/**********/
-
-/****d* IBA Base: Constants/IB_NOTICE_PRODUCER_TYPE_SWITCH
-* NAME
-* IB_NOTICE_PRODUCER_TYPE_SWITCH
-*
-* DESCRIPTION
-* Encoded generic producer type used in Notice attribute (13.4.8.2)
-*
-* SOURCE
-*/
-#define IB_NOTICE_PRODUCER_TYPE_SWITCH (CL_HTON32(0x000002))
-/**********/
-
-/****d* IBA Base: Constants/IB_NOTICE_PRODUCER_TYPE_ROUTER
-* NAME
-* IB_NOTICE_PRODUCER_TYPE_ROUTER
-*
-* DESCRIPTION
-* Encoded generic producer type used in Notice attribute (13.4.8.2)
-*
-* SOURCE
-*/
-#define IB_NOTICE_PRODUCER_TYPE_ROUTER (CL_HTON32(0x000003))
-/**********/
-
-/****d* IBA Base: Constants/IB_NOTICE_PRODUCER_TYPE_CLASS_MGR
-* NAME
-* IB_NOTICE_PRODUCER_TYPE_CLASS_MGR
-*
-* DESCRIPTION
-* Encoded generic producer type used in Notice attribute (13.4.8.2)
-*
-* SOURCE
-*/
-#define IB_NOTICE_PRODUCER_TYPE_CLASS_MGR (CL_HTON32(0x000004))
-/**********/
-
-/****d* IBA Base: Constants/IB_MTU_LEN_TYPE
-* NAME
-* IB_MTU_LEN_TYPE
-*
-* DESCRIPTION
-* Encoded path MTU.
-* 1: 256
-* 2: 512
-* 3: 1024
-* 4: 2048
-* 5: 4096
-* others: reserved
-*
-* SOURCE
-*/
-#define IB_MTU_LEN_256 1
-#define IB_MTU_LEN_512 2
-#define IB_MTU_LEN_1024 3
-#define IB_MTU_LEN_2048 4
-#define IB_MTU_LEN_4096 5
-
-#define IB_MIN_MTU IB_MTU_LEN_256
-#define IB_MAX_MTU IB_MTU_LEN_4096
-
-/**********/
-
-/****d* IBA Base: Constants/IB_PATH_SELECTOR_TYPE
-* NAME
-* IB_PATH_SELECTOR_TYPE
-*
-* DESCRIPTION
-* Path selector.
-* 0: greater than specified
-* 1: less than specified
-* 2: exactly the specified
-* 3: largest available
-*
-* SOURCE
-*/
-#define IB_PATH_SELECTOR_GREATER_THAN 0
-#define IB_PATH_SELECTOR_LESS_THAN 1
-#define IB_PATH_SELECTOR_EXACTLY 2
-#define IB_PATH_SELECTOR_LARGEST 3
-/**********/
-
-/****d* IBA Base: Constants/IB_SMINFO_STATE_NOTACTIVE
-* NAME
-* IB_SMINFO_STATE_NOTACTIVE
-*
-* DESCRIPTION
-* Encoded state value used in the SMInfo attribute.
-*
-* SOURCE
-*/
-#define IB_SMINFO_STATE_NOTACTIVE 0
-/**********/
-
-/****d* IBA Base: Constants/IB_SMINFO_STATE_DISCOVERING
-* NAME
-* IB_SMINFO_STATE_DISCOVERING
-*
-* DESCRIPTION
-* Encoded state value used in the SMInfo attribute.
-*
-* SOURCE
-*/
-#define IB_SMINFO_STATE_DISCOVERING 1
-/**********/
-
-/****d* IBA Base: Constants/IB_SMINFO_STATE_STANDBY
-* NAME
-* IB_SMINFO_STATE_STANDBY
-*
-* DESCRIPTION
-* Encoded state value used in the SMInfo attribute.
-*
-* SOURCE
-*/
-#define IB_SMINFO_STATE_STANDBY 2
-/**********/
-
-/****d* IBA Base: Constants/IB_SMINFO_STATE_MASTER
-* NAME
-* IB_SMINFO_STATE_MASTER
-*
-* DESCRIPTION
-* Encoded state value used in the SMInfo attribute.
-*
-* SOURCE
-*/
-#define IB_SMINFO_STATE_MASTER 3
-/**********/
-
-/****d* IBA Base: Constants/IB_PATH_REC_SL_MASK
-* NAME
-* IB_PATH_REC_SL_MASK
-*
-* DESCRIPTION
-* Mask for the sl field for path record
-*
-* SOURCE
-*/
-#define IB_PATH_REC_SL_MASK 0x000F
-
-/****d* IBA Base: Constants/IB_MULTIPATH_REC_SL_MASK
-* NAME
-* IB_MILTIPATH_REC_SL_MASK
-*
-* DESCRIPTION
-* Mask for the sl field for MultiPath record
-*
-* SOURCE
-*/
-#define IB_MULTIPATH_REC_SL_MASK 0x000F
-
-/****d* IBA Base: Constants/IB_PATH_REC_QOS_CLASS_MASK
-* NAME
-* IB_PATH_REC_QOS_CLASS_MASK
-*
-* DESCRIPTION
-* Mask for the QoS class field for path record
-*
-* SOURCE
-*/
-#define IB_PATH_REC_QOS_CLASS_MASK 0xFFF0
-
-/****d* IBA Base: Constants/IB_MULTIPATH_REC_QOS_CLASS_MASK
-* NAME
-* IB_MULTIPATH_REC_QOS_CLASS_MASK
-*
-* DESCRIPTION
-* Mask for the QoS class field for MultiPath record
-*
-* SOURCE
-*/
-#define IB_MULTIPATH_REC_QOS_CLASS_MASK 0xFFF0
-
-/****d* IBA Base: Constants/IB_PATH_REC_SELECTOR_MASK
-* NAME
-* IB_PATH_REC_SELECTOR_MASK
-*
-* DESCRIPTION
-* Mask for the selector field for path record MTU, rate,
-* and packet lifetime.
-*
-* SOURCE
-*/
-#define IB_PATH_REC_SELECTOR_MASK 0xC0
-
-/****d* IBA Base: Constants/IB_MULTIPATH_REC_SELECTOR_MASK
-* NAME
-* IB_MULTIPATH_REC_SELECTOR_MASK
-*
-* DESCRIPTION
-* Mask for the selector field for multipath record MTU, rate,
-* and packet lifetime.
-*
-* SOURCE
-*/
-#define IB_MULTIPATH_REC_SELECTOR_MASK 0xC0
-/**********/
-
-/****d* IBA Base: Constants/IB_PATH_REC_BASE_MASK
-* NAME
-* IB_PATH_REC_BASE_MASK
-*
-* DESCRIPTION
-* Mask for the base value field for path record MTU, rate,
-* and packet lifetime.
-*
-* SOURCE
-*/
-#define IB_PATH_REC_BASE_MASK 0x3F
-/**********/
-
-/****d* IBA Base: Constants/IB_MULTIPATH_REC_BASE_MASK
-* NAME
-* IB_MULTIPATH_REC_BASE_MASK
-*
-* DESCRIPTION
-* Mask for the base value field for multipath record MTU, rate,
-* and packet lifetime.
-*
-* SOURCE
-*/
-#define IB_MULTIPATH_REC_BASE_MASK 0x3F
-/**********/
-
-/****h* IBA Base/Type Definitions
-* NAME
-* Type Definitions
-*
-* DESCRIPTION
-* Definitions are from the InfiniBand Architecture Specification v1.2
-*
-*********/
-
-/****d* IBA Base: Types/ib_net16_t
-* NAME
-* ib_net16_t
-*
-* DESCRIPTION
-* Defines the network ordered type for 16-bit values.
-*
-* SOURCE
-*/
-typedef uint16_t ib_net16_t;
-/**********/
-
-/****d* IBA Base: Types/ib_net32_t
-* NAME
-* ib_net32_t
-*
-* DESCRIPTION
-* Defines the network ordered type for 32-bit values.
-*
-* SOURCE
-*/
-typedef uint32_t ib_net32_t;
-/**********/
-
-/****d* IBA Base: Types/ib_net64_t
-* NAME
-* ib_net64_t
-*
-* DESCRIPTION
-* Defines the network ordered type for 64-bit values.
-*
-* SOURCE
-*/
-typedef uint64_t ib_net64_t;
-/**********/
-
-/****d* IBA Base: Types/ib_gid_prefix_t
-* NAME
-* ib_gid_prefix_t
-*
-* DESCRIPTION
-*
-* SOURCE
-*/
-typedef ib_net64_t ib_gid_prefix_t;
-/**********/
-
-/****d* IBA Base: Constants/ib_link_states_t
-* NAME
-* ib_link_states_t
-*
-* DESCRIPTION
-* Defines the link states of a port.
-*
-* SOURCE
-*/
-#define IB_LINK_NO_CHANGE 0
-#define IB_LINK_DOWN 1
-#define IB_LINK_INIT 2
-#define IB_LINK_ARMED 3
-#define IB_LINK_ACTIVE 4
-#define IB_LINK_ACT_DEFER 5
-/**********/
-
-static const char *const __ib_node_type_str[] = {
- "UNKNOWN",
- "Channel Adapter",
- "Switch",
- "Router"
-};
-
-/****f* IBA Base: Types/ib_get_node_type_str
-* NAME
-* ib_get_node_type_str
-*
-* DESCRIPTION
-* Returns a string for the specified node type.
-* 14.2.5.3 NodeInfo
-*
-* SYNOPSIS
-*/
-static inline const char *OSM_API ib_get_node_type_str(IN uint8_t node_type)
-{
- if (node_type > IB_NODE_TYPE_ROUTER)
- node_type = 0;
- return (__ib_node_type_str[node_type]);
-}
-
-/*
-* PARAMETERS
-* node_type
-* [in] Encoded node type as returned in the NodeInfo attribute.
-
-* RETURN VALUES
-* Pointer to the node type string.
-*
-* NOTES
-*
-* SEE ALSO
-* ib_node_info_t
-*********/
-
-static const char *const __ib_producer_type_str[] = {
- "UNKNOWN",
- "Channel Adapter",
- "Switch",
- "Router",
- "Class Manager"
-};
-
-/****f* IBA Base: Types/ib_get_producer_type_str
-* NAME
-* ib_get_producer_type_str
-*
-* DESCRIPTION
-* Returns a string for the specified producer type
-* 13.4.8.2 Notice
-* 13.4.8.3 InformInfo
-*
-* SYNOPSIS
-*/
-static inline const char *OSM_API
-ib_get_producer_type_str(IN ib_net32_t producer_type)
-{
- if (cl_ntoh32(producer_type) >
- CL_NTOH32(IB_NOTICE_PRODUCER_TYPE_CLASS_MGR))
- producer_type = 0;
- return (__ib_producer_type_str[cl_ntoh32(producer_type)]);
-}
-
-/*
-* PARAMETERS
-* producer_type
-* [in] Encoded producer type from the Notice attribute
-
-* RETURN VALUES
-* Pointer to the producer type string.
-*
-* NOTES
-*
-* SEE ALSO
-* ib_notice_get_prod_type
-*********/
-
-static const char *const __ib_port_state_str[] = {
- "No State Change (NOP)",
- "DOWN",
- "INIT",
- "ARMED",
- "ACTIVE",
- "ACTDEFER",
- "UNKNOWN"
-};
-
-/****f* IBA Base: Types/ib_get_port_state_str
-* NAME
-* ib_get_port_state_str
-*
-* DESCRIPTION
-* Returns a string for the specified port state.
-*
-* SYNOPSIS
-*/
-static inline const char *OSM_API ib_get_port_state_str(IN uint8_t port_state)
-{
- if (port_state > IB_LINK_ACTIVE)
- port_state = IB_LINK_ACTIVE + 1;
- return (__ib_port_state_str[port_state]);
-}
-
-/*
-* PARAMETERS
-* port_state
-* [in] Encoded port state as returned in the PortInfo attribute.
-
-* RETURN VALUES
-* Pointer to the port state string.
-*
-* NOTES
-*
-* SEE ALSO
-* ib_port_info_t
-*********/
-
-/****f* IBA Base: Types/ib_get_port_state_from_str
-* NAME
-* ib_get_port_state_from_str
-*
-* DESCRIPTION
-* Returns a string for the specified port state.
-*
-* SYNOPSIS
-*/
-static inline uint8_t OSM_API
-ib_get_port_state_from_str(IN char *p_port_state_str)
-{
- if (!strncmp(p_port_state_str, "No State Change (NOP)", 12))
- return (0);
- else if (!strncmp(p_port_state_str, "DOWN", 4))
- return (1);
- else if (!strncmp(p_port_state_str, "INIT", 4))
- return (2);
- else if (!strncmp(p_port_state_str, "ARMED", 5))
- return (3);
- else if (!strncmp(p_port_state_str, "ACTIVE", 6))
- return (4);
- else if (!strncmp(p_port_state_str, "ACTDEFER", 8))
- return (5);
- return (6);
-}
-
-/*
-* PARAMETERS
-* p_port_state_str
-* [in] A string matching one returned by ib_get_port_state_str
-*
-* RETURN VALUES
-* The appropriate code.
-*
-* NOTES
-*
-* SEE ALSO
-* ib_port_info_t
-*********/
-
-/****d* IBA Base: Constants/Join States
-* NAME
-* Join States
-*
-* DESCRIPTION
-* Defines the join state flags for multicast group management.
-*
-* SOURCE
-*/
-#define IB_JOIN_STATE_FULL 1
-#define IB_JOIN_STATE_NON 2
-#define IB_JOIN_STATE_SEND_ONLY 4
-/**********/
-
-/****f* IBA Base: Types/ib_pkey_get_base
-* NAME
-* ib_pkey_get_base
-*
-* DESCRIPTION
-* Returns the base P_Key value with the membership bit stripped.
-*
-* SYNOPSIS
-*/
-static inline ib_net16_t OSM_API ib_pkey_get_base(IN const ib_net16_t pkey)
-{
- return ((ib_net16_t) (pkey & IB_PKEY_BASE_MASK));
-}
-
-/*
-* PARAMETERS
-* pkey
-* [in] P_Key value
-*
-* RETURN VALUE
-* Returns the base P_Key value with the membership bit stripped.
-*
-* NOTES
-*
-* SEE ALSO
-*********/
-
-/****f* IBA Base: Types/ib_pkey_is_full_member
-* NAME
-* ib_pkey_is_full_member
-*
-* DESCRIPTION
-* Indicates if the port is a full member of the parition.
-*
-* SYNOPSIS
-*/
-static inline boolean_t OSM_API ib_pkey_is_full_member(IN const ib_net16_t pkey)
-{
- return ((pkey & IB_PKEY_TYPE_MASK) == IB_PKEY_TYPE_MASK);
-}
-
-/*
-* PARAMETERS
-* pkey
-* [in] P_Key value
-*
-* RETURN VALUE
-* TRUE if the port is a full member of the partition.
-* FALSE otherwise.
-*
-* NOTES
-*
-* SEE ALSO
-* ib_pkey_get_base, ib_net16_t
-*********/
-
-/****f* IBA Base: Types/ib_pkey_is_invalid
-* NAME
-* ib_pkey_is_invalid
-*
-* DESCRIPTION
-* Returns TRUE if the given P_Key is an invalid P_Key
-* C10-116: the CI shall regard a P_Key as invalid if its low-order
-* 15 bits are all zero...
-*
-* SYNOPSIS
-*/
-static inline boolean_t OSM_API ib_pkey_is_invalid(IN const ib_net16_t pkey)
-{
- if (ib_pkey_get_base(pkey) == 0x0000)
- return TRUE;
-
- return FALSE;
-}
-
-/*
-* PARAMETERS
-* pkey
-* [in] P_Key value
-*
-* RETURN VALUE
-* Returns the base P_Key value with the membership bit stripped.
-*
-* NOTES
-*
-* SEE ALSO
-*********/
-
-/****d* IBA Base: Types/ib_gid_t
-* NAME
-* ib_gid_t
-*
-* DESCRIPTION
-*
-* SYNOPSIS
-*/
-#include <complib/cl_packon.h>
-typedef union _ib_gid {
- uint8_t raw[16];
- struct _ib_gid_unicast {
- ib_gid_prefix_t prefix;
- ib_net64_t interface_id;
-
- } PACK_SUFFIX unicast;
-
- struct _ib_gid_multicast {
- uint8_t header[2];
- uint8_t raw_group_id[14];
-
- } PACK_SUFFIX multicast;
-
-} PACK_SUFFIX ib_gid_t;
-#include <complib/cl_packoff.h>
-/*
-* FIELDS
-* raw
-* GID represented as an unformated byte array.
-*
-* unicast
-* Typical unicast representation with subnet prefix and
-* port GUID.
-*
-* multicast
-* Representation for multicast use.
-*
-* SEE ALSO
-*********/
-
-/****f* IBA Base: Types/ib_gid_is_multicast
-* NAME
-* ib_gid_is_multicast
-*
-* DESCRIPTION
-* Returns a boolean indicating whether a GID is a multicast GID.
-*
-* SYNOPSIS
-*/
-static inline boolean_t OSM_API ib_gid_is_multicast(IN const ib_gid_t * p_gid)
-{
- return (p_gid->raw[0] == 0xFF);
-}
-
-/****f* IBA Base: Types/ib_gid_get_scope
-* NAME
-* ib_gid_get_scope
-*
-* DESCRIPTION
-* Returns scope of (assumed) multicast GID.
-*
-* SYNOPSIS
-*/
-static inline uint8_t OSM_API ib_mgid_get_scope(IN const ib_gid_t * p_gid)
-{
- return (p_gid->raw[1] & 0x0F);
-}
-
-/****f* IBA Base: Types/ib_gid_set_scope
-* NAME
-* ib_gid_set_scope
-*
-* DESCRIPTION
-* Sets scope of (assumed) multicast GID.
-*
-* SYNOPSIS
-*/
-static inline void OSM_API
-ib_mgid_set_scope(IN ib_gid_t * const p_gid, IN const uint8_t scope)
-{
- p_gid->raw[1] &= 0xF0;
- p_gid->raw[1] |= scope & 0x0F;
-}
-
-/****f* IBA Base: Types/ib_gid_set_default
-* NAME
-* ib_gid_set_default
-*
-* DESCRIPTION
-* Sets a GID to the default value.
-*
-* SYNOPSIS
-*/
-static inline void OSM_API
-ib_gid_set_default(IN ib_gid_t * const p_gid, IN const ib_net64_t interface_id)
-{
- p_gid->unicast.prefix = IB_DEFAULT_SUBNET_PREFIX;
- p_gid->unicast.interface_id = interface_id;
-}
-
-/*
-* PARAMETERS
-* p_gid
-* [in] Pointer to the GID object.
-*
-* interface_id
-* [in] Manufacturer assigned EUI64 value of a port.
-*
-* RETURN VALUES
-* None.
-*
-* NOTES
-*
-* SEE ALSO
-* ib_gid_t
-*********/
-
-/****f* IBA Base: Types/ib_gid_get_subnet_prefix
-* NAME
-* ib_gid_get_subnet_prefix
-*
-* DESCRIPTION
-* Gets the subnet prefix from a GID.
-*
-* SYNOPSIS
-*/
-static inline ib_net64_t OSM_API
-ib_gid_get_subnet_prefix(IN const ib_gid_t * const p_gid)
-{
- return (p_gid->unicast.prefix);
-}
-
-/*
-* PARAMETERS
-* p_gid
-* [in] Pointer to the GID object.
-*
-* RETURN VALUES
-* 64-bit subnet prefix value.
-*
-* NOTES
-*
-* SEE ALSO
-* ib_gid_t
-*********/
-
-/****f* IBA Base: Types/ib_gid_is_link_local
-* NAME
-* ib_gid_is_link_local
-*
-* DESCRIPTION
-* Returns TRUE if the unicast GID scoping indicates link local,
-* FALSE otherwise.
-*
-* SYNOPSIS
-*/
-static inline boolean_t OSM_API
-ib_gid_is_link_local(IN const ib_gid_t * const p_gid)
-{
- return ((ib_gid_get_subnet_prefix(p_gid) &
- CL_HTON64(0xFFC0000000000000ULL)) == IB_DEFAULT_SUBNET_PREFIX);
-}
-
-/*
-* PARAMETERS
-* p_gid
-* [in] Pointer to the GID object.
-*
-* RETURN VALUES
-* Returns TRUE if the unicast GID scoping indicates link local,
-* FALSE otherwise.
-*
-* NOTES
-*
-* SEE ALSO
-* ib_gid_t
-*********/
-
-/****f* IBA Base: Types/ib_gid_is_site_local
-* NAME
-* ib_gid_is_site_local
-*
-* DESCRIPTION
-* Returns TRUE if the unicast GID scoping indicates site local,
-* FALSE otherwise.
-*
-* SYNOPSIS
-*/
-static inline boolean_t OSM_API
-ib_gid_is_site_local(IN const ib_gid_t * const p_gid)
-{
- return ((ib_gid_get_subnet_prefix(p_gid) &
- CL_HTON64(0xFFFFFFFFFFFF0000ULL)) ==
- CL_HTON64(0xFEC0000000000000ULL));
-}
-
-/*
-* PARAMETERS
-* p_gid
-* [in] Pointer to the GID object.
-*
-* RETURN VALUES
-* Returns TRUE if the unicast GID scoping indicates site local,
-* FALSE otherwise.
-*
-* NOTES
-*
-* SEE ALSO
-* ib_gid_t
-*********/
-
-/****f* IBA Base: Types/ib_gid_get_guid
-* NAME
-* ib_gid_get_guid
-*
-* DESCRIPTION
-* Gets the guid from a GID.
-*
-* SYNOPSIS
-*/
-static inline ib_net64_t OSM_API
-ib_gid_get_guid(IN const ib_gid_t * const p_gid)
-{
- return (p_gid->unicast.interface_id);
-}
-
-/*
-* PARAMETERS
-* p_gid
-* [in] Pointer to the GID object.
-*
-* RETURN VALUES
-* 64-bit GUID value.
-*
-* NOTES
-*
-* SEE ALSO
-* ib_gid_t
-*********/
-
-/****s* IBA Base: Types/ib_path_rec_t
-* NAME
-* ib_path_rec_t
-*
-* DESCRIPTION
-* Path records encapsulate the properties of a given
-* route between two end-points on a subnet.
-*
-* SYNOPSIS
-*/
-#include <complib/cl_packon.h>
-typedef struct _ib_path_rec {
- ib_net64_t service_id;
- ib_gid_t dgid;
- ib_gid_t sgid;
- ib_net16_t dlid;
- ib_net16_t slid;
- ib_net32_t hop_flow_raw;
- uint8_t tclass;
- uint8_t num_path;
- ib_net16_t pkey;
- ib_net16_t qos_class_sl;
- uint8_t mtu;
- uint8_t rate;
- uint8_t pkt_life;
- uint8_t preference;
- uint8_t resv2[6];
-
-} PACK_SUFFIX ib_path_rec_t;
-#include <complib/cl_packoff.h>
-/*
-* FIELDS
-* service_id
-* Service ID for QoS.
-*
-* dgid
-* GID of destination port.
-*
-* sgid
-* GID of source port.
-*
-* dlid
-* LID of destination port.
-*
-* slid
-* LID of source port.
-*
-* hop_flow_raw
-* Global routing parameters: hop count, flow label and raw bit.
-*
-* tclass
-* Another global routing parameter.
-*
-* num_path
-* Reversible path - 1 bit to say if path is reversible.
-* num_path [6:0] In queries, maximum number of paths to return.
-* In responses, undefined.
-*
-* pkey
-* Partition key (P_Key) to use on this path.
-*
-* qos_class_sl
-* QoS class and service level to use on this path.
-*
-* mtu
-* MTU and MTU selector fields to use on this path
-*
-* rate
-* Rate and rate selector fields to use on this path.
-*
-* pkt_life
-* Packet lifetime
-*
-* preference
-* Indicates the relative merit of this path versus other path
-* records returned from the SA. Lower numbers are better.
-*
-* resv2
-* Reserved bytes.
-* SEE ALSO
-*********/
-
-/* Path Record Component Masks */
-#define IB_PR_COMPMASK_SERVICEID_MSB (CL_HTON64(((uint64_t)1)<<0))
-#define IB_PR_COMPMASK_SERVICEID_LSB (CL_HTON64(((uint64_t)1)<<1))
-#define IB_PR_COMPMASK_DGID (CL_HTON64(((uint64_t)1)<<2))
-#define IB_PR_COMPMASK_SGID (CL_HTON64(((uint64_t)1)<<3))
-#define IB_PR_COMPMASK_DLID (CL_HTON64(((uint64_t)1)<<4))
-#define IB_PR_COMPMASK_SLID (CL_HTON64(((uint64_t)1)<<5))
-#define IB_PR_COMPMASK_RAWTRAFFIC (CL_HTON64(((uint64_t)1)<<6))
-#define IB_PR_COMPMASK_RESV0 (CL_HTON64(((uint64_t)1)<<7))
-#define IB_PR_COMPMASK_FLOWLABEL (CL_HTON64(((uint64_t)1)<<8))
-#define IB_PR_COMPMASK_HOPLIMIT (CL_HTON64(((uint64_t)1)<<9))
-#define IB_PR_COMPMASK_TCLASS (CL_HTON64(((uint64_t)1)<<10))
-#define IB_PR_COMPMASK_REVERSIBLE (CL_HTON64(((uint64_t)1)<<11))
-#define IB_PR_COMPMASK_NUMBPATH (CL_HTON64(((uint64_t)1)<<12))
-#define IB_PR_COMPMASK_PKEY (CL_HTON64(((uint64_t)1)<<13))
-#define IB_PR_COMPMASK_QOS_CLASS (CL_HTON64(((uint64_t)1)<<14))
-#define IB_PR_COMPMASK_SL (CL_HTON64(((uint64_t)1)<<15))
-#define IB_PR_COMPMASK_MTUSELEC (CL_HTON64(((uint64_t)1)<<16))
-#define IB_PR_COMPMASK_MTU (CL_HTON64(((uint64_t)1)<<17))
-#define IB_PR_COMPMASK_RATESELEC (CL_HTON64(((uint64_t)1)<<18))
-#define IB_PR_COMPMASK_RATE (CL_HTON64(((uint64_t)1)<<19))
-#define IB_PR_COMPMASK_PKTLIFETIMESELEC (CL_HTON64(((uint64_t)1)<<20))
-#define IB_PR_COMPMASK_PKTLIFETIME (CL_HTON64(((uint64_t)1)<<21))
-
-/* Link Record Component Masks */
-#define IB_LR_COMPMASK_FROM_LID (CL_HTON64(((uint64_t)1)<<0))
-#define IB_LR_COMPMASK_FROM_PORT (CL_HTON64(((uint64_t)1)<<1))
-#define IB_LR_COMPMASK_TO_PORT (CL_HTON64(((uint64_t)1)<<2))
-#define IB_LR_COMPMASK_TO_LID (CL_HTON64(((uint64_t)1)<<3))
-
-/* VL Arbitration Record Masks */
-#define IB_VLA_COMPMASK_LID (CL_HTON64(((uint64_t)1)<<0))
-#define IB_VLA_COMPMASK_OUT_PORT (CL_HTON64(((uint64_t)1)<<1))
-#define IB_VLA_COMPMASK_BLOCK (CL_HTON64(((uint64_t)1)<<2))
-
-/* SLtoVL Mapping Record Masks */
-#define IB_SLVL_COMPMASK_LID (CL_HTON64(((uint64_t)1)<<0))
-#define IB_SLVL_COMPMASK_IN_PORT (CL_HTON64(((uint64_t)1)<<1))
-#define IB_SLVL_COMPMASK_OUT_PORT (CL_HTON64(((uint64_t)1)<<2))
-
-/* P_Key Table Record Masks */
-#define IB_PKEY_COMPMASK_LID (CL_HTON64(((uint64_t)1)<<0))
-#define IB_PKEY_COMPMASK_BLOCK (CL_HTON64(((uint64_t)1)<<1))
-#define IB_PKEY_COMPMASK_PORT (CL_HTON64(((uint64_t)1)<<2))
-
-/* Switch Info Record Masks */
-#define IB_SWIR_COMPMASK_LID (CL_HTON64(((uint64_t)1)<<0))
-#define IB_SWIR_COMPMASK_RESERVED1 (CL_HTON64(((uint64_t)1)<<1))
-
-/* LFT Record Masks */
-#define IB_LFTR_COMPMASK_LID (CL_HTON64(((uint64_t)1)<<0))
-#define IB_LFTR_COMPMASK_BLOCK (CL_HTON64(((uint64_t)1)<<1))
-
-/* MFT Record Masks */
-#define IB_MFTR_COMPMASK_LID (CL_HTON64(((uint64_t)1)<<0))
-#define IB_MFTR_COMPMASK_POSITION (CL_HTON64(((uint64_t)1)<<1))
-#define IB_MFTR_COMPMASK_RESERVED1 (CL_HTON64(((uint64_t)1)<<2))
-#define IB_MFTR_COMPMASK_BLOCK (CL_HTON64(((uint64_t)1)<<3))
-#define IB_MFTR_COMPMASK_RESERVED2 (CL_HTON64(((uint64_t)1)<<4))
-
-/* NodeInfo Record Masks */
-#define IB_NR_COMPMASK_LID (CL_HTON64(((uint64_t)1)<<0))
-#define IB_NR_COMPMASK_RESERVED1 (CL_HTON64(((uint64_t)1)<<1))
-#define IB_NR_COMPMASK_BASEVERSION (CL_HTON64(((uint64_t)1)<<2))
-#define IB_NR_COMPMASK_CLASSVERSION (CL_HTON64(((uint64_t)1)<<3))
-#define IB_NR_COMPMASK_NODETYPE (CL_HTON64(((uint64_t)1)<<4))
-#define IB_NR_COMPMASK_NUMPORTS (CL_HTON64(((uint64_t)1)<<5))
-#define IB_NR_COMPMASK_SYSIMAGEGUID (CL_HTON64(((uint64_t)1)<<6))
-#define IB_NR_COMPMASK_NODEGUID (CL_HTON64(((uint64_t)1)<<7))
-#define IB_NR_COMPMASK_PORTGUID (CL_HTON64(((uint64_t)1)<<8))
-#define IB_NR_COMPMASK_PARTCAP (CL_HTON64(((uint64_t)1)<<9))
-#define IB_NR_COMPMASK_DEVID (CL_HTON64(((uint64_t)1)<<10))
-#define IB_NR_COMPMASK_REV (CL_HTON64(((uint64_t)1)<<11))
-#define IB_NR_COMPMASK_PORTNUM (CL_HTON64(((uint64_t)1)<<12))
-#define IB_NR_COMPMASK_VENDID (CL_HTON64(((uint64_t)1)<<13))
-#define IB_NR_COMPMASK_NODEDESC (CL_HTON64(((uint64_t)1)<<14))
-
-/* Service Record Component Masks Sec 15.2.5.14 Ver 1.1*/
-#define IB_SR_COMPMASK_SID (CL_HTON64(((uint64_t)1)<<0))
-#define IB_SR_COMPMASK_SGID (CL_HTON64(((uint64_t)1)<<1))
-#define IB_SR_COMPMASK_SPKEY (CL_HTON64(((uint64_t)1)<<2))
-#define IB_SR_COMPMASK_RES1 (CL_HTON64(((uint64_t)1)<<3))
-#define IB_SR_COMPMASK_SLEASE (CL_HTON64(((uint64_t)1)<<4))
-#define IB_SR_COMPMASK_SKEY (CL_HTON64(((uint64_t)1)<<5))
-#define IB_SR_COMPMASK_SNAME (CL_HTON64(((uint64_t)1)<<6))
-#define IB_SR_COMPMASK_SDATA8_0 (CL_HTON64(((uint64_t)1)<<7))
-#define IB_SR_COMPMASK_SDATA8_1 (CL_HTON64(((uint64_t)1)<<8))
-#define IB_SR_COMPMASK_SDATA8_2 (CL_HTON64(((uint64_t)1)<<9))
-#define IB_SR_COMPMASK_SDATA8_3 (CL_HTON64(((uint64_t)1)<<10))
-#define IB_SR_COMPMASK_SDATA8_4 (CL_HTON64(((uint64_t)1)<<11))
-#define IB_SR_COMPMASK_SDATA8_5 (CL_HTON64(((uint64_t)1)<<12))
-#define IB_SR_COMPMASK_SDATA8_6 (CL_HTON64(((uint64_t)1)<<13))
-#define IB_SR_COMPMASK_SDATA8_7 (CL_HTON64(((uint64_t)1)<<14))
-#define IB_SR_COMPMASK_SDATA8_8 (CL_HTON64(((uint64_t)1)<<15))
-#define IB_SR_COMPMASK_SDATA8_9 (CL_HTON64(((uint64_t)1)<<16))
-#define IB_SR_COMPMASK_SDATA8_10 (CL_HTON64(((uint64_t)1)<<17))
-#define IB_SR_COMPMASK_SDATA8_11 (CL_HTON64(((uint64_t)1)<<18))
-#define IB_SR_COMPMASK_SDATA8_12 (CL_HTON64(((uint64_t)1)<<19))
-#define IB_SR_COMPMASK_SDATA8_13 (CL_HTON64(((uint64_t)1)<<20))
-#define IB_SR_COMPMASK_SDATA8_14 (CL_HTON64(((uint64_t)1)<<21))
-#define IB_SR_COMPMASK_SDATA8_15 (CL_HTON64(((uint64_t)1)<<22))
-#define IB_SR_COMPMASK_SDATA16_0 (CL_HTON64(((uint64_t)1)<<23))
-#define IB_SR_COMPMASK_SDATA16_1 (CL_HTON64(((uint64_t)1)<<24))
-#define IB_SR_COMPMASK_SDATA16_2 (CL_HTON64(((uint64_t)1)<<25))
-#define IB_SR_COMPMASK_SDATA16_3 (CL_HTON64(((uint64_t)1)<<26))
-#define IB_SR_COMPMASK_SDATA16_4 (CL_HTON64(((uint64_t)1)<<27))
-#define IB_SR_COMPMASK_SDATA16_5 (CL_HTON64(((uint64_t)1)<<28))
-#define IB_SR_COMPMASK_SDATA16_6 (CL_HTON64(((uint64_t)1)<<29))
-#define IB_SR_COMPMASK_SDATA16_7 (CL_HTON64(((uint64_t)1)<<30))
-#define IB_SR_COMPMASK_SDATA32_0 (CL_HTON64(((uint64_t)1)<<31))
-#define IB_SR_COMPMASK_SDATA32_1 (CL_HTON64(((uint64_t)1)<<32))
-#define IB_SR_COMPMASK_SDATA32_2 (CL_HTON64(((uint64_t)1)<<33))
-#define IB_SR_COMPMASK_SDATA32_3 (CL_HTON64(((uint64_t)1)<<34))
-#define IB_SR_COMPMASK_SDATA64_0 (CL_HTON64(((uint64_t)1)<<35))
-#define IB_SR_COMPMASK_SDATA64_1 (CL_HTON64(((uint64_t)1)<<36))
-
-/* Port Info Record Component Masks */
-#define IB_PIR_COMPMASK_LID (CL_HTON64(((uint64_t)1)<<0))
-#define IB_PIR_COMPMASK_PORTNUM (CL_HTON64(((uint64_t)1)<<1))
-#define IB_PIR_COMPMASK_RESV1 (CL_HTON64(((uint64_t)1)<<2))
-#define IB_PIR_COMPMASK_MKEY (CL_HTON64(((uint64_t)1)<<3))
-#define IB_PIR_COMPMASK_GIDPRE (CL_HTON64(((uint64_t)1)<<4))
-#define IB_PIR_COMPMASK_BASELID (CL_HTON64(((uint64_t)1)<<5))
-#define IB_PIR_COMPMASK_SMLID (CL_HTON64(((uint64_t)1)<<6))
-#define IB_PIR_COMPMASK_CAPMASK (CL_HTON64(((uint64_t)1)<<7))
-#define IB_PIR_COMPMASK_DIAGCODE (CL_HTON64(((uint64_t)1)<<8))
-#define IB_PIR_COMPMASK_MKEYLEASEPRD (CL_HTON64(((uint64_t)1)<<9))
-#define IB_PIR_COMPMASK_LOCALPORTNUM (CL_HTON64(((uint64_t)1)<<10))
-#define IB_PIR_COMPMASK_LINKWIDTHENABLED (CL_HTON64(((uint64_t)1)<<11))
-#define IB_PIR_COMPMASK_LNKWIDTHSUPPORT (CL_HTON64(((uint64_t)1)<<12))
-#define IB_PIR_COMPMASK_LNKWIDTHACTIVE (CL_HTON64(((uint64_t)1)<<13))
-#define IB_PIR_COMPMASK_LNKSPEEDSUPPORT (CL_HTON64(((uint64_t)1)<<14))
-#define IB_PIR_COMPMASK_PORTSTATE (CL_HTON64(((uint64_t)1)<<15))
-#define IB_PIR_COMPMASK_PORTPHYSTATE (CL_HTON64(((uint64_t)1)<<16))
-#define IB_PIR_COMPMASK_LINKDWNDFLTSTATE (CL_HTON64(((uint64_t)1)<<17))
-#define IB_PIR_COMPMASK_MKEYPROTBITS (CL_HTON64(((uint64_t)1)<<18))
-#define IB_PIR_COMPMASK_RESV2 (CL_HTON64(((uint64_t)1)<<19))
-#define IB_PIR_COMPMASK_LMC (CL_HTON64(((uint64_t)1)<<20))
-#define IB_PIR_COMPMASK_LINKSPEEDACTIVE (CL_HTON64(((uint64_t)1)<<21))
-#define IB_PIR_COMPMASK_LINKSPEEDENABLE (CL_HTON64(((uint64_t)1)<<22))
-#define IB_PIR_COMPMASK_NEIGHBORMTU (CL_HTON64(((uint64_t)1)<<23))
-#define IB_PIR_COMPMASK_MASTERSMSL (CL_HTON64(((uint64_t)1)<<24))
-#define IB_PIR_COMPMASK_VLCAP (CL_HTON64(((uint64_t)1)<<25))
-#define IB_PIR_COMPMASK_INITTYPE (CL_HTON64(((uint64_t)1)<<26))
-#define IB_PIR_COMPMASK_VLHIGHLIMIT (CL_HTON64(((uint64_t)1)<<27))
-#define IB_PIR_COMPMASK_VLARBHIGHCAP (CL_HTON64(((uint64_t)1)<<28))
-#define IB_PIR_COMPMASK_VLARBLOWCAP (CL_HTON64(((uint64_t)1)<<29))
-#define IB_PIR_COMPMASK_INITTYPEREPLY (CL_HTON64(((uint64_t)1)<<30))
-#define IB_PIR_COMPMASK_MTUCAP (CL_HTON64(((uint64_t)1)<<31))
-#define IB_PIR_COMPMASK_VLSTALLCNT (CL_HTON64(((uint64_t)1)<<32))
-#define IB_PIR_COMPMASK_HOQLIFE (CL_HTON64(((uint64_t)1)<<33))
-#define IB_PIR_COMPMASK_OPVLS (CL_HTON64(((uint64_t)1)<<34))
-#define IB_PIR_COMPMASK_PARENFIN (CL_HTON64(((uint64_t)1)<<35))
-#define IB_PIR_COMPMASK_PARENFOUT (CL_HTON64(((uint64_t)1)<<36))
-#define IB_PIR_COMPMASK_FILTERRAWIN (CL_HTON64(((uint64_t)1)<<37))
-#define IB_PIR_COMPMASK_FILTERRAWOUT (CL_HTON64(((uint64_t)1)<<38))
-#define IB_PIR_COMPMASK_MKEYVIO (CL_HTON64(((uint64_t)1)<<39))
-#define IB_PIR_COMPMASK_PKEYVIO (CL_HTON64(((uint64_t)1)<<40))
-#define IB_PIR_COMPMASK_QKEYVIO (CL_HTON64(((uint64_t)1)<<41))
-#define IB_PIR_COMPMASK_GUIDCAP (CL_HTON64(((uint64_t)1)<<42))
-#define IB_PIR_COMPMASK_RESV3 (CL_HTON64(((uint64_t)1)<<43))
-#define IB_PIR_COMPMASK_SUBNTO (CL_HTON64(((uint64_t)1)<<44))
-#define IB_PIR_COMPMASK_RESV4 (CL_HTON64(((uint64_t)1)<<45))
-#define IB_PIR_COMPMASK_RESPTIME (CL_HTON64(((uint64_t)1)<<46))
-#define IB_PIR_COMPMASK_LOCALPHYERR (CL_HTON64(((uint64_t)1)<<47))
-#define IB_PIR_COMPMASK_OVERRUNERR (CL_HTON64(((uint64_t)1)<<48))
-
-/* Multicast Member Record Component Masks */
-#define IB_MCR_COMPMASK_GID (CL_HTON64(((uint64_t)1)<<0))
-#define IB_MCR_COMPMASK_MGID (CL_HTON64(((uint64_t)1)<<0))
-#define IB_MCR_COMPMASK_PORT_GID (CL_HTON64(((uint64_t)1)<<1))
-#define IB_MCR_COMPMASK_QKEY (CL_HTON64(((uint64_t)1)<<2))
-#define IB_MCR_COMPMASK_MLID (CL_HTON64(((uint64_t)1)<<3))
-#define IB_MCR_COMPMASK_MTU_SEL (CL_HTON64(((uint64_t)1)<<4))
-#define IB_MCR_COMPMASK_MTU (CL_HTON64(((uint64_t)1)<<5))
-#define IB_MCR_COMPMASK_TCLASS (CL_HTON64(((uint64_t)1)<<6))
-#define IB_MCR_COMPMASK_PKEY (CL_HTON64(((uint64_t)1)<<7))
-#define IB_MCR_COMPMASK_RATE_SEL (CL_HTON64(((uint64_t)1)<<8))
-#define IB_MCR_COMPMASK_RATE (CL_HTON64(((uint64_t)1)<<9))
-#define IB_MCR_COMPMASK_LIFE_SEL (CL_HTON64(((uint64_t)1)<<10))
-#define IB_MCR_COMPMASK_LIFE (CL_HTON64(((uint64_t)1)<<11))
-#define IB_MCR_COMPMASK_SL (CL_HTON64(((uint64_t)1)<<12))
-#define IB_MCR_COMPMASK_FLOW (CL_HTON64(((uint64_t)1)<<13))
-#define IB_MCR_COMPMASK_HOP (CL_HTON64(((uint64_t)1)<<14))
-#define IB_MCR_COMPMASK_SCOPE (CL_HTON64(((uint64_t)1)<<15))
-#define IB_MCR_COMPMASK_JOIN_STATE (CL_HTON64(((uint64_t)1)<<16))
-#define IB_MCR_COMPMASK_PROXY (CL_HTON64(((uint64_t)1)<<17))
-
-/* GUID Info Record Component Masks */
-#define IB_GIR_COMPMASK_LID (CL_HTON64(((uint64_t)1)<<0))
-#define IB_GIR_COMPMASK_BLOCKNUM (CL_HTON64(((uint64_t)1)<<1))
-#define IB_GIR_COMPMASK_RESV1 (CL_HTON64(((uint64_t)1)<<2))
-#define IB_GIR_COMPMASK_RESV2 (CL_HTON64(((uint64_t)1)<<3))
-#define IB_GIR_COMPMASK_GID0 (CL_HTON64(((uint64_t)1)<<4))
-#define IB_GIR_COMPMASK_GID1 (CL_HTON64(((uint64_t)1)<<5))
-#define IB_GIR_COMPMASK_GID2 (CL_HTON64(((uint64_t)1)<<6))
-#define IB_GIR_COMPMASK_GID3 (CL_HTON64(((uint64_t)1)<<7))
-#define IB_GIR_COMPMASK_GID4 (CL_HTON64(((uint64_t)1)<<8))
-#define IB_GIR_COMPMASK_GID5 (CL_HTON64(((uint64_t)1)<<9))
-#define IB_GIR_COMPMASK_GID6 (CL_HTON64(((uint64_t)1)<<10))
-#define IB_GIR_COMPMASK_GID7 (CL_HTON64(((uint64_t)1)<<11))
-
-/* MultiPath Record Component Masks */
-#define IB_MPR_COMPMASK_RAWTRAFFIC (CL_HTON64(((uint64_t)1)<<0))
-#define IB_MPR_COMPMASK_RESV0 (CL_HTON64(((uint64_t)1)<<1))
-#define IB_MPR_COMPMASK_FLOWLABEL (CL_HTON64(((uint64_t)1)<<2))
-#define IB_MPR_COMPMASK_HOPLIMIT (CL_HTON64(((uint64_t)1)<<3))
-#define IB_MPR_COMPMASK_TCLASS (CL_HTON64(((uint64_t)1)<<4))
-#define IB_MPR_COMPMASK_REVERSIBLE (CL_HTON64(((uint64_t)1)<<5))
-#define IB_MPR_COMPMASK_NUMBPATH (CL_HTON64(((uint64_t)1)<<6))
-#define IB_MPR_COMPMASK_PKEY (CL_HTON64(((uint64_t)1)<<7))
-#define IB_MPR_COMPMASK_QOS_CLASS (CL_HTON64(((uint64_t)1)<<8))
-#define IB_MPR_COMPMASK_SL (CL_HTON64(((uint64_t)1)<<9))
-#define IB_MPR_COMPMASK_MTUSELEC (CL_HTON64(((uint64_t)1)<<10))
-#define IB_MPR_COMPMASK_MTU (CL_HTON64(((uint64_t)1)<<11))
-#define IB_MPR_COMPMASK_RATESELEC (CL_HTON64(((uint64_t)1)<<12))
-#define IB_MPR_COMPMASK_RATE (CL_HTON64(((uint64_t)1)<<13))
-#define IB_MPR_COMPMASK_PKTLIFETIMESELEC (CL_HTON64(((uint64_t)1)<<14))
-#define IB_MPR_COMPMASK_PKTLIFETIME (CL_HTON64(((uint64_t)1)<<15))
-#define IB_MPR_COMPMASK_SERVICEID_MSB (CL_HTON64(((uint64_t)1)<<16))
-#define IB_MPR_COMPMASK_INDEPSELEC (CL_HTON64(((uint64_t)1)<<17))
-#define IB_MPR_COMPMASK_RESV3 (CL_HTON64(((uint64_t)1)<<18))
-#define IB_MPR_COMPMASK_SGIDCOUNT (CL_HTON64(((uint64_t)1)<<19))
-#define IB_MPR_COMPMASK_DGIDCOUNT (CL_HTON64(((uint64_t)1)<<20))
-#define IB_MPR_COMPMASK_SERVICEID_LSB (CL_HTON64(((uint64_t)1)<<21))
-
-/* SMInfo Record Component Masks */
-#define IB_SMIR_COMPMASK_LID (CL_HTON64(((uint64_t)1)<<0))
-#define IB_SMIR_COMPMASK_RESV0 (CL_HTON64(((uint64_t)1)<<1))
-#define IB_SMIR_COMPMASK_GUID (CL_HTON64(((uint64_t)1)<<2))
-#define IB_SMIR_COMPMASK_SMKEY (CL_HTON64(((uint64_t)1)<<3))
-#define IB_SMIR_COMPMASK_ACTCOUNT (CL_HTON64(((uint64_t)1)<<4))
-#define IB_SMIR_COMPMASK_PRIORITY (CL_HTON64(((uint64_t)1)<<5))
-#define IB_SMIR_COMPMASK_SMSTATE (CL_HTON64(((uint64_t)1)<<6))
-
-/* InformInfo Record Component Masks */
-#define IB_IIR_COMPMASK_SUBSCRIBERGID (CL_HTON64(((uint64_t)1)<<0))
-#define IB_IIR_COMPMASK_ENUM (CL_HTON64(((uint64_t)1)<<1))
-#define IB_IIR_COMPMASK_RESV0 (CL_HTON64(((uint64_t)1)<<2))
-#define IB_IIR_COMPMASK_GID (CL_HTON64(((uint64_t)1)<<3))
-#define IB_IIR_COMPMASK_LIDRANGEBEGIN (CL_HTON64(((uint64_t)1)<<4))
-#define IB_IIR_COMPMASK_LIDRANGEEND (CL_HTON64(((uint64_t)1)<<5))
-#define IB_IIR_COMPMASK_RESV1 (CL_HTON64(((uint64_t)1)<<6))
-#define IB_IIR_COMPMASK_ISGENERIC (CL_HTON64(((uint64_t)1)<<7))
-#define IB_IIR_COMPMASK_SUBSCRIBE (CL_HTON64(((uint64_t)1)<<8))
-#define IB_IIR_COMPMASK_TYPE (CL_HTON64(((uint64_t)1)<<9))
-#define IB_IIR_COMPMASK_TRAPNUMB (CL_HTON64(((uint64_t)1)<<10))
-#define IB_IIR_COMPMASK_DEVICEID (CL_HTON64(((uint64_t)1)<<10))
-#define IB_IIR_COMPMASK_QPN (CL_HTON64(((uint64_t)1)<<11))
-#define IB_IIR_COMPMASK_RESV2 (CL_HTON64(((uint64_t)1)<<12))
-#define IB_IIR_COMPMASK_RESPTIME (CL_HTON64(((uint64_t)1)<<13))
-#define IB_IIR_COMPMASK_RESV3 (CL_HTON64(((uint64_t)1)<<14))
-#define IB_IIR_COMPMASK_PRODTYPE (CL_HTON64(((uint64_t)1)<<15))
-#define IB_IIR_COMPMASK_VENDID (CL_HTON64(((uint64_t)1)<<15))
-
-/****f* IBA Base: Types/ib_path_rec_init_local
-* NAME
-* ib_path_rec_init_local
-*
-* DESCRIPTION
-* Initializes a subnet local path record.
-*
-* SYNOPSIS
-*/
-static inline void OSM_API
-ib_path_rec_init_local(IN ib_path_rec_t * const p_rec,
- IN ib_gid_t * const p_dgid,
- IN ib_gid_t * const p_sgid,
- IN ib_net16_t dlid,
- IN ib_net16_t slid,
- IN uint8_t num_path,
- IN ib_net16_t pkey,
- IN uint8_t sl,
- IN uint16_t qos_class,
- IN uint8_t mtu_selector,
- IN uint8_t mtu,
- IN uint8_t rate_selector,
- IN uint8_t rate,
- IN uint8_t pkt_life_selector,
- IN uint8_t pkt_life, IN uint8_t preference)
-{
- p_rec->dgid = *p_dgid;
- p_rec->sgid = *p_sgid;
- p_rec->dlid = dlid;
- p_rec->slid = slid;
- p_rec->num_path = num_path;
- p_rec->pkey = pkey;
- p_rec->qos_class_sl = cl_hton16((sl & IB_PATH_REC_SL_MASK) |
- (qos_class << 4));
- p_rec->mtu = (uint8_t) ((mtu & IB_PATH_REC_BASE_MASK) |
- (uint8_t) (mtu_selector << 6));
- p_rec->rate = (uint8_t) ((rate & IB_PATH_REC_BASE_MASK) |
- (uint8_t) (rate_selector << 6));
- p_rec->pkt_life = (uint8_t) ((pkt_life & IB_PATH_REC_BASE_MASK) |
- (uint8_t) (pkt_life_selector << 6));
- p_rec->preference = preference;
-
- /* Clear global routing fields for local path records */
- p_rec->hop_flow_raw = 0;
- p_rec->tclass = 0;
- p_rec->service_id = 0;
-
- *((uint32_t *) p_rec->resv2) = 0;
- *((uint16_t *) p_rec->resv2 + 2) = 0;
-}
-
-/*
-* PARAMETERS
-* p_rec
-* [in] Pointer to the path record object.
-*
-* dgid
-* [in] GID of destination port.
-*
-* sgid
-* [in] GID of source port.
-*
-* dlid
-* [in] LID of destination port.
-*
-* slid
-* [in] LID of source port.
-*
-* num_path
-* [in] Reversible path - 1 bit to say if path is reversible.
-* num_path [6:0] In queries, maximum number of paths to return.
-* In responses, undefined.
-*
-* pkey
-* [in] Partition key (P_Key) to use on this path.
-*
-* qos_class
-* [in] QoS class to use on this path. Lower 12-bits are valid.
-*
-* sl
-* [in] Service level to use on this path. Lower 4-bits are valid.
-*
-* mtu_selector
-* [in] Encoded MTU selector value to use on this path
-*
-* mtu
-* [in] Encoded MTU to use on this path
-*
-* rate_selector
-* [in] Encoded rate selector value to use on this path.
-*
-* rate
-* [in] Encoded rate to use on this path.
-*
-* pkt_life_selector
-* [in] Encoded Packet selector value lifetime for this path.
-*
-* pkt_life
-* [in] Encoded Packet lifetime for this path.
-*
-* preference
-* [in] Indicates the relative merit of this path versus other path
-* records returned from the SA. Lower numbers are better.
-*
-* RETURN VALUES
-* None.
-*
-* NOTES
-*
-* SEE ALSO
-* ib_gid_t
-*********/
-
-/****f* IBA Base: Types/ib_path_rec_num_path
-* NAME
-* ib_path_rec_num_path
-*
-* DESCRIPTION
-* Get max number of paths to return.
-*
-* SYNOPSIS
-*/
-static inline uint8_t OSM_API
-ib_path_rec_num_path(IN const ib_path_rec_t * const p_rec)
-{
- return (p_rec->num_path & 0x7F);
-}
-
-/*
-* PARAMETERS
-* p_rec
-* [in] Pointer to the path record object.
-*
-* RETURN VALUES
-* Maximum number of paths to return for each unique SGID_DGID combination.
-*
-* NOTES
-*
-* SEE ALSO
-* ib_path_rec_t
-*********/
-
-/****f* IBA Base: Types/ib_path_rec_set_sl
-* NAME
-* ib_path_rec_set_sl
-*
-* DESCRIPTION
-* Set path service level.
-*
-* SYNOPSIS
-*/
-static inline void OSM_API
-ib_path_rec_set_sl(IN ib_path_rec_t * const p_rec, IN const uint8_t sl)
-{
- p_rec->qos_class_sl =
- (p_rec->qos_class_sl & CL_HTON16(IB_PATH_REC_QOS_CLASS_MASK)) |
- cl_hton16(sl & IB_PATH_REC_SL_MASK);
-}
-
-/*
-* PARAMETERS
-* p_rec
-* [in] Pointer to the path record object.
-*
-* sl
-* [in] Service level to set.
-*
-* RETURN VALUES
-* None
-*
-* NOTES
-*
-* SEE ALSO
-* ib_path_rec_t
-*********/
-
-/****f* IBA Base: Types/ib_path_rec_sl
-* NAME
-* ib_path_rec_sl
-*
-* DESCRIPTION
-* Get path service level.
-*
-* SYNOPSIS
-*/
-static inline uint8_t OSM_API
-ib_path_rec_sl(IN const ib_path_rec_t * const p_rec)
-{
- return (uint8_t)(cl_ntoh16(p_rec->qos_class_sl) & IB_PATH_REC_SL_MASK);
-}
-
-/*
-* PARAMETERS
-* p_rec
-* [in] Pointer to the path record object.
-*
-* RETURN VALUES
-* SL.
-*
-* NOTES
-*
-* SEE ALSO
-* ib_path_rec_t
-*********/
-
-/****f* IBA Base: Types/ib_path_rec_set_qos_class
-* NAME
-* ib_path_rec_set_qos_class
-*
-* DESCRIPTION
-* Set path QoS class.
-*
-* SYNOPSIS
-*/
-static inline void OSM_API
-ib_path_rec_set_qos_class(IN ib_path_rec_t * const p_rec,
- IN const uint16_t qos_class)
-{
- p_rec->qos_class_sl =
- (p_rec->qos_class_sl & CL_HTON16(IB_PATH_REC_SL_MASK)) |
- cl_hton16(qos_class << 4);
-}
-
-/*
-* PARAMETERS
-* p_rec
-* [in] Pointer to the path record object.
-*
-* qos_class
-* [in] QoS class to set.
-*
-* RETURN VALUES
-* None
-*
-* NOTES
-*
-* SEE ALSO
-* ib_path_rec_t
-*********/
-
-/****f* IBA Base: Types/ib_path_rec_qos_class
-* NAME
-* ib_path_rec_qos_class
-*
-* DESCRIPTION
-* Get QoS class.
-*
-* SYNOPSIS
-*/
-static inline uint16_t OSM_API
-ib_path_rec_qos_class(IN const ib_path_rec_t * const p_rec)
-{
- return (cl_ntoh16(p_rec->qos_class_sl) >> 4);
-}
-
-/*
-* PARAMETERS
-* p_rec
-* [in] Pointer to the path record object.
-*
-* RETURN VALUES
-* QoS class of the path record.
-*
-* NOTES
-*
-* SEE ALSO
-* ib_path_rec_t
-*********/
-
-/****f* IBA Base: Types/ib_path_rec_mtu
-* NAME
-* ib_path_rec_mtu
-*
-* DESCRIPTION
-* Get encoded path MTU.
-*
-* SYNOPSIS
-*/
-static inline uint8_t OSM_API
-ib_path_rec_mtu(IN const ib_path_rec_t * const p_rec)
-{
- return ((uint8_t) (p_rec->mtu & IB_PATH_REC_BASE_MASK));
-}
-
-/*
-* PARAMETERS
-* p_rec
-* [in] Pointer to the path record object.
-*
-* RETURN VALUES
-* Encoded path MTU.
-* 1: 256
-* 2: 512
-* 3: 1024
-* 4: 2048
-* 5: 4096
-* others: reserved
-*
-* NOTES
-*
-* SEE ALSO
-* ib_path_rec_t
-*********/
-
-/****f* IBA Base: Types/ib_path_rec_mtu_sel
-* NAME
-* ib_path_rec_mtu_sel
-*
-* DESCRIPTION
-* Get encoded path MTU selector.
-*
-* SYNOPSIS
-*/
-static inline uint8_t OSM_API
-ib_path_rec_mtu_sel(IN const ib_path_rec_t * const p_rec)
-{
- return ((uint8_t) ((p_rec->mtu & IB_PATH_REC_SELECTOR_MASK) >> 6));
-}
-
-/*
-* PARAMETERS
-* p_rec
-* [in] Pointer to the path record object.
-*
-* RETURN VALUES
-* Encoded path MTU selector value (for queries).
-* 0: greater than MTU specified
-* 1: less than MTU specified
-* 2: exactly the MTU specified
-* 3: largest MTU available
-*
-* NOTES
-*
-* SEE ALSO
-* ib_path_rec_t
-*********/
-
-/****f* IBA Base: Types/ib_path_rec_rate
-* NAME
-* ib_path_rec_rate
-*
-* DESCRIPTION
-* Get encoded path rate.
-*
-* SYNOPSIS
-*/
-static inline uint8_t OSM_API
-ib_path_rec_rate(IN const ib_path_rec_t * const p_rec)
-{
- return ((uint8_t) (p_rec->rate & IB_PATH_REC_BASE_MASK));
-}
-
-/*
-* PARAMETERS
-* p_rec
-* [in] Pointer to the path record object.
-*
-* RETURN VALUES
-* Encoded path rate.
-* 2: 2.5 Gb/sec.
-* 3: 10 Gb/sec.
-* 4: 30 Gb/sec.
-* 5: 5 Gb/sec.
-* 6: 20 Gb/sec.
-* 7: 40 Gb/sec.
-* 8: 60 Gb/sec.
-* 9: 80 Gb/sec.
-* 10: 120 Gb/sec.
-* others: reserved
-*
-* NOTES
-*
-* SEE ALSO
-* ib_path_rec_t
-*********/
-
-/****f* IBA Base: Types/ib_path_rec_rate_sel
-* NAME
-* ib_path_rec_rate_sel
-*
-* DESCRIPTION
-* Get encoded path rate selector.
-*
-* SYNOPSIS
-*/
-static inline uint8_t OSM_API
-ib_path_rec_rate_sel(IN const ib_path_rec_t * const p_rec)
-{
- return ((uint8_t) ((p_rec->rate & IB_PATH_REC_SELECTOR_MASK) >> 6));
-}
-
-/*
-* PARAMETERS
-* p_rec
-* [in] Pointer to the path record object.
-*
-* RETURN VALUES
-* Encoded path rate selector value (for queries).
-* 0: greater than rate specified
-* 1: less than rate specified
-* 2: exactly the rate specified
-* 3: largest rate available
-*
-* NOTES
-*
-* SEE ALSO
-* ib_path_rec_t
-*********/
-
-/****f* IBA Base: Types/ib_path_rec_pkt_life
-* NAME
-* ib_path_rec_pkt_life
-*
-* DESCRIPTION
-* Get encoded path pkt_life.
-*
-* SYNOPSIS
-*/
-static inline uint8_t OSM_API
-ib_path_rec_pkt_life(IN const ib_path_rec_t * const p_rec)
-{
- return ((uint8_t) (p_rec->pkt_life & IB_PATH_REC_BASE_MASK));
-}
-
-/*
-* PARAMETERS
-* p_rec
-* [in] Pointer to the path record object.
-*
-* RETURN VALUES
-* Encoded path pkt_life = 4.096 usec * 2 ** PacketLifeTime.
-*
-* NOTES
-*
-* SEE ALSO
-* ib_path_rec_t
-*********/
-
-/****f* IBA Base: Types/ib_path_rec_pkt_life_sel
-* NAME
-* ib_path_rec_pkt_life_sel
-*
-* DESCRIPTION
-* Get encoded path pkt_lifetime selector.
-*
-* SYNOPSIS
-*/
-static inline uint8_t OSM_API
-ib_path_rec_pkt_life_sel(IN const ib_path_rec_t * const p_rec)
-{
- return ((uint8_t) ((p_rec->pkt_life & IB_PATH_REC_SELECTOR_MASK) >> 6));
-}
-
-/*
-* PARAMETERS
-* p_rec
-* [in] Pointer to the path record object.
-*
-* RETURN VALUES
-* Encoded path pkt_lifetime selector value (for queries).
-* 0: greater than rate specified
-* 1: less than rate specified
-* 2: exactly the rate specified
-* 3: smallest packet lifetime available
-*
-* NOTES
-*
-* SEE ALSO
-* ib_path_rec_t
-*********/
-
-/****f* IBA Base: Types/ib_path_rec_flow_lbl
-* NAME
-* ib_path_rec_flow_lbl
-*
-* DESCRIPTION
-* Get flow label.
-*
-* SYNOPSIS
-*/
-static inline uint32_t OSM_API
-ib_path_rec_flow_lbl(IN const ib_path_rec_t * const p_rec)
-{
- return (((cl_ntoh32(p_rec->hop_flow_raw) >> 8) & 0x000FFFFF));
-}
-
-/*
-* PARAMETERS
-* p_rec
-* [in] Pointer to the path record object.
-*
-* RETURN VALUES
-* Flow label of the path record.
-*
-* NOTES
-*
-* SEE ALSO
-* ib_path_rec_t
-*********/
-
-/****f* IBA Base: Types/ib_path_rec_hop_limit
-* NAME
-* ib_path_rec_hop_limit
-*
-* DESCRIPTION
-* Get hop limit.
-*
-* SYNOPSIS
-*/
-static inline uint8_t OSM_API
-ib_path_rec_hop_limit(IN const ib_path_rec_t * const p_rec)
-{
- return ((uint8_t) (cl_ntoh32(p_rec->hop_flow_raw) & 0x000000FF));
-}
-
-/*
-* PARAMETERS
-* p_rec
-* [in] Pointer to the path record object.
-*
-* RETURN VALUES
-* Hop limit of the path record.
-*
-* NOTES
-*
-* SEE ALSO
-* ib_path_rec_t
-*********/
-
-/****s* IBA Base: Constants/IB_CLASS_CAP_TRAP
-* NAME
-* IB_CLASS_CAP_TRAP
-*
-* DESCRIPTION
-* ClassPortInfo CapabilityMask bits. This bit will be set
-* if the class supports Trap() MADs (13.4.8.1).
-*
-* SEE ALSO
-* ib_class_port_info_t, IB_CLASS_CAP_GETSET
-*
-* SOURCE
-*/
-#define IB_CLASS_CAP_TRAP 0x0001
-/*********/
-
-/****s* IBA Base: Constants/IB_CLASS_CAP_GETSET
-* NAME
-* IB_CLASS_CAP_GETSET
-*
-* DESCRIPTION
-* ClassPortInfo CapabilityMask bits. This bit will be set
-* if the class supports Get(Notice) and Set(Notice) MADs (13.4.8.1).
-*
-* SEE ALSO
-* ib_class_port_info_t, IB_CLASS_CAP_TRAP
-*
-* SOURCE
-*/
-#define IB_CLASS_CAP_GETSET 0x0002
-/*********/
-
-/****s* IBA Base: Constants/IB_CLASS_RESP_TIME_MASK
-* NAME
-* IB_CLASS_RESP_TIME_MASK
-*
-* DESCRIPTION
-* Mask bits to extract the reponse time value from the
-* resp_time_val field of ib_class_port_info_t.
-*
-* SEE ALSO
-* ib_class_port_info_t
-*
-* SOURCE
-*/
-#define IB_CLASS_RESP_TIME_MASK 0x1F
-/*********/
-
-/****s* IBA Base: Types/ib_class_port_info_t
-* NAME
-* ib_class_port_info_t
-*
-* DESCRIPTION
-* IBA defined ClassPortInfo attribute (13.4.8.1)
-* route between two end-points on a subnet.
-*
-* SYNOPSIS
-*/
-#include <complib/cl_packon.h>
-typedef struct _ib_class_port_info {
- uint8_t base_ver;
- uint8_t class_ver;
- ib_net16_t cap_mask;
- ib_net32_t cap_mask2_resp_time;
- ib_gid_t redir_gid;
- ib_net32_t redir_tc_sl_fl;
- ib_net16_t redir_lid;
- ib_net16_t redir_pkey;
- ib_net32_t redir_qp;
- ib_net32_t redir_qkey;
- ib_gid_t trap_gid;
- ib_net32_t trap_tc_sl_fl;
- ib_net16_t trap_lid;
- ib_net16_t trap_pkey;
- ib_net32_t trap_hop_qp;
- ib_net32_t trap_qkey;
-
-} PACK_SUFFIX ib_class_port_info_t;
-#include <complib/cl_packoff.h>
-/*
-* FIELDS
-* base_ver
-* Maximum supported MAD Base Version.
-*
-* class_ver
-* Maximum supported management class version.
-*
-* cap_mask
-* Supported capabilities of this management class.
-*
-* cap_mask2_resp_time
-* Maximum expected response time and additional
-* supported capabilities of this management class.
-*
-* redr_gid
-* GID to use for redirection, or zero
-*
-* recdir_tc_sl_fl
-* Traffic class, service level and flow label the requester
-* should use if the service is redirected.
-*
-* redir_lid
-* LID used for redirection, or zero
-*
-* redir_pkey
-* P_Key used for redirection
-*
-* redir_qp
-* QP number used for redirection
-*
-* redir_qkey
-* Q_Key associated with the redirected QP. This shall be the
-* well known Q_Key value.
-*
-* trap_gid
-* GID value used for trap messages from this service.
-*
-* trap_tc_sl_fl
-* Traffic class, service level and flow label used for
-* trap messages originated by this service.
-*
-* trap_lid
-* LID used for trap messages, or zero
-*
-* trap_pkey
-* P_Key used for trap messages
-*
-* trap_hop_qp
-* Hop limit (upper 8 bits) and QP number used for trap messages
-*
-* trap_qkey
-* Q_Key associated with the trap messages QP.
-*
-* SEE ALSO
-* IB_CLASS_CAP_GETSET, IB_CLASS_CAP_TRAP
-*
-*********/
-
-/****f* IBA Base: Types/ib_class_set_resp_time_val
-* NAME
-* ib_class_set_resp_time_val
-*
-* DESCRIPTION
-* Set maximum expected response time.
-*
-* SYNOPSIS
-*/
-static inline void OSM_API
-ib_class_set_resp_time_val(IN ib_class_port_info_t * const p_cpi,
- IN const uint8_t val)
-{
- p_cpi->cap_mask2_resp_time =
- (p_cpi->cap_mask2_resp_time & CL_HTON32(~IB_CLASS_RESP_TIME_MASK)) |
- cl_hton32(val & IB_CLASS_RESP_TIME_MASK);
-}
-
-/*
-* PARAMETERS
-* p_cpi
-* [in] Pointer to the class port info object.
-*
-* val
-* [in] Response time value to set.
-*
-* RETURN VALUES
-* None
-*
-* NOTES
-*
-* SEE ALSO
-* ib_class_port_info_t
-*********/
-
-/****f* IBA Base: Types/ib_class_resp_time_val
-* NAME
-* ib_class_resp_time_val
-*
-* DESCRIPTION
-* Get response time value.
-*
-* SYNOPSIS
-*/
-static inline uint8_t OSM_API
-ib_class_resp_time_val(IN ib_class_port_info_t * const p_cpi)
-{
- return (uint8_t)(cl_ntoh32(p_cpi->cap_mask2_resp_time) &
- IB_CLASS_RESP_TIME_MASK);
-}
-
-/*
-* PARAMETERS
-* p_cpi
-* [in] Pointer to the class port info object.
-*
-* RETURN VALUES
-* Response time value.
-*
-* NOTES
-*
-* SEE ALSO
-* ib_class_port_info_t
-*********/
-
-/****f* IBA Base: Types/ib_class_set_cap_mask2
-* NAME
-* ib_class_set_cap_mask2
-*
-* DESCRIPTION
-* Set ClassPortInfo:CapabilityMask2.
-*
-* SYNOPSIS
-*/
-static inline void OSM_API
-ib_class_set_cap_mask2(IN ib_class_port_info_t * const p_cpi,
- IN const uint32_t cap_mask2)
-{
- p_cpi->cap_mask2_resp_time = (p_cpi->cap_mask2_resp_time &
- CL_HTON32(IB_CLASS_RESP_TIME_MASK)) |
- cl_hton32(cap_mask2 << 5);
-}
-
-/*
-* PARAMETERS
-* p_cpi
-* [in] Pointer to the class port info object.
-*
-* cap_mask2
-* [in] CapabilityMask2 value to set.
-*
-* RETURN VALUES
-* None
-*
-* NOTES
-*
-* SEE ALSO
-* ib_class_port_info_t
-*********/
-
-/****f* IBA Base: Types/ib_class_cap_mask2
-* NAME
-* ib_class_cap_mask2
-*
-* DESCRIPTION
-* Get ClassPortInfo:CapabilityMask2.
-*
-* SYNOPSIS
-*/
-static inline uint32_t OSM_API
-ib_class_cap_mask2(IN const ib_class_port_info_t * const p_cpi)
-{
- return (cl_ntoh32(p_cpi->cap_mask2_resp_time) >> 5);
-}
-
-/*
-* PARAMETERS
-* p_cpi
-* [in] Pointer to the class port info object.
-*
-* RETURN VALUES
-* CapabilityMask2 of the ClassPortInfo.
-*
-* NOTES
-*
-* SEE ALSO
-* ib_class_port_info_t
-*********/
-
-/****s* IBA Base: Types/ib_sm_info_t
-* NAME
-* ib_sm_info_t
-*
-* DESCRIPTION
-* SMInfo structure (14.2.5.13).
-*
-* SYNOPSIS
-*/
-#include <complib/cl_packon.h>
-typedef struct _ib_sm_info {
- ib_net64_t guid;
- ib_net64_t sm_key;
- ib_net32_t act_count;
- uint8_t pri_state;
-
-} PACK_SUFFIX ib_sm_info_t;
-#include <complib/cl_packoff.h>
-/*
-* FIELDS
-* guid
-* Port GUID for this SM.
-*
-* sm_key
-* SM_Key of this SM.
-*
-* act_count
-* Activity counter used as a heartbeat.
-*
-* pri_state
-* Priority and State information
-*
-* SEE ALSO
-*********/
-
-/****f* IBA Base: Types/ib_sminfo_get_priority
-* NAME
-* ib_sminfo_get_priority
-*
-* DESCRIPTION
-* Returns the priority value.
-*
-* SYNOPSIS
-*/
-static inline uint8_t OSM_API
-ib_sminfo_get_priority(IN const ib_sm_info_t * const p_smi)
-{
- return ((uint8_t) ((p_smi->pri_state & 0xF0) >> 4));
-}
-
-/*
-* PARAMETERS
-* p_smi
-* [in] Pointer to the SMInfo Attribute.
-*
-* RETURN VALUES
-* Returns the priority value.
-*
-* NOTES
-*
-* SEE ALSO
-*********/
-
-/****f* IBA Base: Types/ib_sminfo_get_state
-* NAME
-* ib_sminfo_get_state
-*
-* DESCRIPTION
-* Returns the state value.
-*
-* SYNOPSIS
-*/
-static inline uint8_t OSM_API
-ib_sminfo_get_state(IN const ib_sm_info_t * const p_smi)
-{
- return ((uint8_t) (p_smi->pri_state & 0x0F));
-}
-
-/*
-* PARAMETERS
-* p_smi
-* [in] Pointer to the SMInfo Attribute.
-*
-* RETURN VALUES
-* Returns the state value.
-*
-* NOTES
-*
-* SEE ALSO
-*********/
-
-/****s* IBA Base: Types/ib_mad_t
-* NAME
-* ib_mad_t
-*
-* DESCRIPTION
-* IBA defined MAD header (13.4.3)
-*
-* SYNOPSIS
-*/
-#include <complib/cl_packon.h>
-typedef struct _ib_mad {
- uint8_t base_ver;
- uint8_t mgmt_class;
- uint8_t class_ver;
- uint8_t method;
- ib_net16_t status;
- ib_net16_t class_spec;
- ib_net64_t trans_id;
- ib_net16_t attr_id;
- ib_net16_t resv;
- ib_net32_t attr_mod;
-} PACK_SUFFIX ib_mad_t;
-#include <complib/cl_packoff.h>
-/*
-* FIELDS
-* base_ver
-* MAD base format.
-*
-* mgmt_class
-* Class of operation.
-*
-* class_ver
-* Version of MAD class-specific format.
-*
-* method
-* Method to perform, including 'R' bit.
-*
-* status
-* Status of operation.
-*
-* class_spec
-* Reserved for subnet management.
-*
-* trans_id
-* Transaction ID.
-*
-* attr_id
-* Attribute ID.
-*
-* resv
-* Reserved field.
-*
-* attr_mod
-* Attribute modifier.
-*
-* SEE ALSO
-*********/
-
-/****s* IBA Base: Types/ib_rmpp_mad_t
-* NAME
-* ib_rmpp_mad_t
-*
-* DESCRIPTION
-* IBA defined MAD RMPP header (13.6.2.1)
-*
-* SYNOPSIS
-*/
-#include <complib/cl_packon.h>
-typedef struct _ib_rmpp_mad {
- ib_mad_t common_hdr;
-
- uint8_t rmpp_version;
- uint8_t rmpp_type;
- uint8_t rmpp_flags;
- uint8_t rmpp_status;
-
- ib_net32_t seg_num;
- ib_net32_t paylen_newwin;
-
-} PACK_SUFFIX ib_rmpp_mad_t;
-#include <complib/cl_packoff.h>
-/*
-* SEE ALSO
-* ib_mad_t
-*********/
-
-/****f* IBA Base: Types/ib_mad_init_new
-* NAME
-* ib_mad_init_new
-*
-* DESCRIPTION
-* Initializes a MAD common header.
-*
-* SYNOPSIS
-*/
-static inline void OSM_API
-ib_mad_init_new(IN ib_mad_t * const p_mad,
- IN const uint8_t mgmt_class,
- IN const uint8_t class_ver,
- IN const uint8_t method,
- IN const ib_net64_t trans_id,
- IN const ib_net16_t attr_id, IN const ib_net32_t attr_mod)
-{
- CL_ASSERT(p_mad);
- p_mad->base_ver = 1;
- p_mad->mgmt_class = mgmt_class;
- p_mad->class_ver = class_ver;
- p_mad->method = method;
- p_mad->status = 0;
- p_mad->class_spec = 0;
- p_mad->trans_id = trans_id;
- p_mad->attr_id = attr_id;
- p_mad->resv = 0;
- p_mad->attr_mod = attr_mod;
-}
-
-/*
-* PARAMETERS
-* p_mad
-* [in] Pointer to the MAD common header.
-*
-* mgmt_class
-* [in] Class of operation.
-*
-* class_ver
-* [in] Version of MAD class-specific format.
-*
-* method
-* [in] Method to perform, including 'R' bit.
-*
-* trans_Id
-* [in] Transaction ID.
-*
-* attr_id
-* [in] Attribute ID.
-*
-* attr_mod
-* [in] Attribute modifier.
-*
-* RETURN VALUES
-* None.
-*
-* NOTES
-*
-* SEE ALSO
-* ib_mad_t
-*********/
-
-/****f* IBA Base: Types/ib_mad_init_response
-* NAME
-* ib_mad_init_response
-*
-* DESCRIPTION
-* Initializes a MAD common header as a response.
-*
-* SYNOPSIS
-*/
-static inline void OSM_API
-ib_mad_init_response(IN const ib_mad_t * const p_req_mad,
- IN ib_mad_t * const p_mad, IN const ib_net16_t status)
-{
- CL_ASSERT(p_req_mad);
- CL_ASSERT(p_mad);
- *p_mad = *p_req_mad;
- p_mad->status = status;
- if (p_mad->method == IB_MAD_METHOD_SET)
- p_mad->method = IB_MAD_METHOD_GET;
- p_mad->method |= IB_MAD_METHOD_RESP_MASK;
-}
-
-/*
-* PARAMETERS
-* p_req_mad
-* [in] Pointer to the MAD common header in the original request MAD.
-*
-* p_mad
-* [in] Pointer to the MAD common header to initialize.
-*
-* status
-* [in] MAD Status value to return;
-*
-* RETURN VALUES
-* None.
-*
-* NOTES
-* p_req_mad and p_mad may point to the same MAD.
-*
-* SEE ALSO
-* ib_mad_t
-*********/
-
-/****f* IBA Base: Types/ib_mad_is_response
-* NAME
-* ib_mad_is_response
-*
-* DESCRIPTION
-* Returns TRUE if the MAD is a response ('R' bit set),
-* FALSE otherwise.
-*
-* SYNOPSIS
-*/
-static inline boolean_t OSM_API
-ib_mad_is_response(IN const ib_mad_t * const p_mad)
-{
- CL_ASSERT(p_mad);
- return ((p_mad->method & IB_MAD_METHOD_RESP_MASK) ==
- IB_MAD_METHOD_RESP_MASK);
-}
-
-/*
-* PARAMETERS
-* p_mad
-* [in] Pointer to the MAD.
-*
-* RETURN VALUES
-* Returns TRUE if the MAD is a response ('R' bit set),
-* FALSE otherwise.
-*
-* NOTES
-*
-* SEE ALSO
-* ib_mad_t
-*********/
-
-#define IB_RMPP_TYPE_DATA 1
-#define IB_RMPP_TYPE_ACK 2
-#define IB_RMPP_TYPE_STOP 3
-#define IB_RMPP_TYPE_ABORT 4
-
-#define IB_RMPP_NO_RESP_TIME 0x1F
-#define IB_RMPP_FLAG_ACTIVE 0x01
-#define IB_RMPP_FLAG_FIRST 0x02
-#define IB_RMPP_FLAG_LAST 0x04
-
-#define IB_RMPP_STATUS_SUCCESS 0
-#define IB_RMPP_STATUS_RESX 1 /* resources exhausted */
-#define IB_RMPP_STATUS_T2L 118 /* time too long */
-#define IB_RMPP_STATUS_BAD_LEN 119 /* incon. last and payload len */
-#define IB_RMPP_STATUS_BAD_SEG 120 /* incon. first and segment no */
-#define IB_RMPP_STATUS_BADT 121 /* bad rmpp type */
-#define IB_RMPP_STATUS_W2S 122 /* newwindowlast too small */
-#define IB_RMPP_STATUS_S2B 123 /* segment no too big */
-#define IB_RMPP_STATUS_BAD_STATUS 124 /* illegal status */
-#define IB_RMPP_STATUS_UNV 125 /* unsupported version */
-#define IB_RMPP_STATUS_TMR 126 /* too many retries */
-#define IB_RMPP_STATUS_UNSPEC 127 /* unspecified */
-
-/****f* IBA Base: Types/ib_rmpp_is_flag_set
-* NAME
-* ib_rmpp_is_flag_set
-*
-* DESCRIPTION
-* Returns TRUE if the MAD has the given RMPP flag set.
-*
-* SYNOPSIS
-*/
-static inline boolean_t OSM_API
-ib_rmpp_is_flag_set(IN const ib_rmpp_mad_t * const p_rmpp_mad,
- IN const uint8_t flag)
-{
- CL_ASSERT(p_rmpp_mad);
- return ((p_rmpp_mad->rmpp_flags & flag) == flag);
-}
-
-/*
-* PARAMETERS
-* ib_rmpp_mad_t
-* [in] Pointer to a MAD with an RMPP header.
-*
-* flag
-* [in] The RMPP flag being examined.
-*
-* RETURN VALUES
-* Returns TRUE if the MAD has the given RMPP flag set.
-*
-* NOTES
-*
-* SEE ALSO
-* ib_mad_t, ib_rmpp_mad_t
-*********/
-
-static inline void OSM_API
-ib_rmpp_set_resp_time(IN ib_rmpp_mad_t * const p_rmpp_mad,
- IN const uint8_t resp_time)
-{
- CL_ASSERT(p_rmpp_mad);
- p_rmpp_mad->rmpp_flags |= (resp_time << 3);
-}
-
-static inline uint8_t OSM_API
-ib_rmpp_get_resp_time(IN const ib_rmpp_mad_t * const p_rmpp_mad)
-{
- CL_ASSERT(p_rmpp_mad);
- return ((uint8_t) (p_rmpp_mad->rmpp_flags >> 3));
-}
-
-/****d* IBA Base: Constants/IB_SMP_DIRECTION
-* NAME
-* IB_SMP_DIRECTION
-*
-* DESCRIPTION
-* The Direction bit for directed route SMPs.
-*
-* SOURCE
-*/
-#define IB_SMP_DIRECTION_HO 0x8000
-#define IB_SMP_DIRECTION (CL_HTON16(IB_SMP_DIRECTION_HO))
-/**********/
-
-/****d* IBA Base: Constants/IB_SMP_STATUS_MASK
-* NAME
-* IB_SMP_STATUS_MASK
-*
-* DESCRIPTION
-* Mask value for extracting status from a directed route SMP.
-*
-* SOURCE
-*/
-#define IB_SMP_STATUS_MASK_HO 0x7FFF
-#define IB_SMP_STATUS_MASK (CL_HTON16(IB_SMP_STATUS_MASK_HO))
-/**********/
-
-/****s* IBA Base: Types/ib_smp_t
-* NAME
-* ib_smp_t
-*
-* DESCRIPTION
-* IBA defined SMP. (14.2.1.2)
-*
-* SYNOPSIS
-*/
-#define IB_SMP_DATA_SIZE 64
-#include <complib/cl_packon.h>
-typedef struct _ib_smp {
- uint8_t base_ver;
- uint8_t mgmt_class;
- uint8_t class_ver;
- uint8_t method;
- ib_net16_t status;
- uint8_t hop_ptr;
- uint8_t hop_count;
- ib_net64_t trans_id;
- ib_net16_t attr_id;
- ib_net16_t resv;
- ib_net32_t attr_mod;
- ib_net64_t m_key;
- ib_net16_t dr_slid;
- ib_net16_t dr_dlid;
- uint32_t resv1[7];
- uint8_t data[IB_SMP_DATA_SIZE];
- uint8_t initial_path[IB_SUBNET_PATH_HOPS_MAX];
- uint8_t return_path[IB_SUBNET_PATH_HOPS_MAX];
-
-} PACK_SUFFIX ib_smp_t;
-#include <complib/cl_packoff.h>
-/*
-* FIELDS
-* base_ver
-* MAD base format.
-*
-* mgmt_class
-* Class of operation.
-*
-* class_ver
-* Version of MAD class-specific format.
-*
-* method
-* Method to perform, including 'R' bit.
-*
-* status
-* Status of operation.
-*
-* hop_ptr
-* Hop pointer for directed route MADs.
-*
-* hop_count
-* Hop count for directed route MADs.
-*
-* trans_Id
-* Transaction ID.
-*
-* attr_id
-* Attribute ID.
-*
-* resv
-* Reserved field.
-*
-* attr_mod
-* Attribute modifier.
-*
-* m_key
-* Management key value.
-*
-* dr_slid
-* Directed route source LID.
-*
-* dr_dlid
-* Directed route destination LID.
-*
-* resv0
-* Reserved for 64 byte alignment.
-*
-* data
-* MAD data payload.
-*
-* initial_path
-* Outbound port list.
-*
-* return_path
-* Inbound port list.
-*
-* SEE ALSO
-*********/
-
-/****f* IBA Base: Types/ib_smp_get_status
-* NAME
-* ib_smp_get_status
-*
-* DESCRIPTION
-* Returns the SMP status value in network order.
-*
-* SYNOPSIS
-*/
-static inline ib_net16_t OSM_API
-ib_smp_get_status(IN const ib_smp_t * const p_smp)
-{
- return ((ib_net16_t) (p_smp->status & IB_SMP_STATUS_MASK));
-}
-
-/*
-* PARAMETERS
-* p_smp
-* [in] Pointer to the SMP packet.
-*
-* RETURN VALUES
-* Returns the SMP status value in network order.
-*
-* NOTES
-*
-* SEE ALSO
-* ib_smp_t
-*********/
-
-/****f* IBA Base: Types/ib_smp_is_response
-* NAME
-* ib_smp_is_response
-*
-* DESCRIPTION
-* Returns TRUE if the SMP is a response MAD, FALSE otherwise.
-*
-* SYNOPSIS
-*/
-static inline boolean_t OSM_API
-ib_smp_is_response(IN const ib_smp_t * const p_smp)
-{
- return (ib_mad_is_response((const ib_mad_t *)p_smp));
-}
-
-/*
-* PARAMETERS
-* p_smp
-* [in] Pointer to the SMP packet.
-*
-* RETURN VALUES
-* Returns TRUE if the SMP is a response MAD, FALSE otherwise.
-*
-* NOTES
-*
-* SEE ALSO
-* ib_smp_t
-*********/
-
-/****f* IBA Base: Types/ib_smp_is_d
-* NAME
-* ib_smp_is_d
-*
-* DESCRIPTION
-* Returns TRUE if the SMP 'D' (direction) bit is set.
-*
-* SYNOPSIS
-*/
-static inline boolean_t OSM_API ib_smp_is_d(IN const ib_smp_t * const p_smp)
-{
- return ((p_smp->status & IB_SMP_DIRECTION) == IB_SMP_DIRECTION);
-}
-
-/*
-* PARAMETERS
-* p_smp
-* [in] Pointer to the SMP packet.
-*
-* RETURN VALUES
-* Returns TRUE if the SMP 'D' (direction) bit is set.
-*
-* NOTES
-*
-* SEE ALSO
-* ib_smp_t
-*********/
-
-/****f* IBA Base: Types/ib_smp_init_new
-* NAME
-* ib_smp_init_new
-*
-* DESCRIPTION
-* Initializes a MAD common header.
-*
-* TODO
-* This is too big for inlining, but leave it here for now
-* since there is not yet another convient spot.
-*
-* SYNOPSIS
-*/
-static inline void OSM_API
-ib_smp_init_new(IN ib_smp_t * const p_smp,
- IN const uint8_t method,
- IN const ib_net64_t trans_id,
- IN const ib_net16_t attr_id,
- IN const ib_net32_t attr_mod,
- IN const uint8_t hop_count,
- IN const ib_net64_t m_key,
- IN const uint8_t * path_out,
- IN const ib_net16_t dr_slid, IN const ib_net16_t dr_dlid)
-{
- CL_ASSERT(p_smp);
- CL_ASSERT(hop_count < IB_SUBNET_PATH_HOPS_MAX);
- p_smp->base_ver = 1;
- p_smp->mgmt_class = IB_MCLASS_SUBN_DIR;
- p_smp->class_ver = 1;
- p_smp->method = method;
- p_smp->status = 0;
- p_smp->hop_ptr = 0;
- p_smp->hop_count = hop_count;
- p_smp->trans_id = trans_id;
- p_smp->attr_id = attr_id;
- p_smp->resv = 0;
- p_smp->attr_mod = attr_mod;
- p_smp->m_key = m_key;
- p_smp->dr_slid = dr_slid;
- p_smp->dr_dlid = dr_dlid;
-
- memset(p_smp->resv1, 0,
- sizeof(p_smp->resv1) +
- sizeof(p_smp->data) +
- sizeof(p_smp->initial_path) + sizeof(p_smp->return_path));
-
- /* copy the path */
- memcpy(&p_smp->initial_path, path_out, sizeof(p_smp->initial_path));
-}
-
-/*
-* PARAMETERS
-* p_smp
-* [in] Pointer to the SMP packet.
-*
-* method
-* [in] Method to perform, including 'R' bit.
-*
-* trans_Id
-* [in] Transaction ID.
-*
-* attr_id
-* [in] Attribute ID.
-*
-* attr_mod
-* [in] Attribute modifier.
-*
-* hop_count
-* [in] Number of hops in the path.
-*
-* m_key
-* [in] Management key for this SMP.
-*
-* path_out
-* [in] Port array for outbound path.
-*
-*
-* RETURN VALUES
-* None.
-*
-* NOTES
-* Payload area is initialized to zero.
-*
-*
-* SEE ALSO
-* ib_mad_t
-*********/
-
-/****f* IBA Base: Types/ib_smp_get_payload_ptr
-* NAME
-* ib_smp_get_payload_ptr
-*
-* DESCRIPTION
-* Gets a pointer to the SMP payload area.
-*
-* SYNOPSIS
-*/
-static inline void *OSM_API
-ib_smp_get_payload_ptr(IN const ib_smp_t * const p_smp)
-{
- return ((void *)p_smp->data);
-}
-
-/*
-* PARAMETERS
-* p_smp
-* [in] Pointer to the SMP packet.
-*
-* RETURN VALUES
-* Pointer to SMP payload area.
-*
-* NOTES
-*
-* SEE ALSO
-* ib_mad_t
-*********/
-
-/****s* IBA Base: Types/ib_node_info_t
-* NAME
-* ib_node_info_t
-*
-* DESCRIPTION
-* IBA defined NodeInfo. (14.2.5.3)
-*
-* SYNOPSIS
-*/
-#include <complib/cl_packon.h>
-typedef struct _ib_node_info {
- uint8_t base_version;
- uint8_t class_version;
- uint8_t node_type;
- uint8_t num_ports;
- ib_net64_t sys_guid;
- ib_net64_t node_guid;
- ib_net64_t port_guid;
- ib_net16_t partition_cap;
- ib_net16_t device_id;
- ib_net32_t revision;
- ib_net32_t port_num_vendor_id;
-
-} PACK_SUFFIX ib_node_info_t;
-#include <complib/cl_packoff.h>
-/************/
-
-/****s* IBA Base: Types/ib_sa_mad_t
-* NAME
-* ib_sa_mad_t
-*
-* DESCRIPTION
-* IBA defined SA MAD format. (15.2.1)
-*
-* SYNOPSIS
-*/
-#define IB_SA_DATA_SIZE 200
-
-#include <complib/cl_packon.h>
-typedef struct _ib_sa_mad {
- uint8_t base_ver;
- uint8_t mgmt_class;
- uint8_t class_ver;
- uint8_t method;
- ib_net16_t status;
- ib_net16_t resv;
- ib_net64_t trans_id;
- ib_net16_t attr_id;
- ib_net16_t resv1;
- ib_net32_t attr_mod;
-
- uint8_t rmpp_version;
- uint8_t rmpp_type;
- uint8_t rmpp_flags;
- uint8_t rmpp_status;
-
- ib_net32_t seg_num;
- ib_net32_t paylen_newwin;
-
- ib_net64_t sm_key;
-
- ib_net16_t attr_offset;
- ib_net16_t resv3;
-
- ib_net64_t comp_mask;
-
- uint8_t data[IB_SA_DATA_SIZE];
-} PACK_SUFFIX ib_sa_mad_t;
-#include <complib/cl_packoff.h>
-/**********/
-#define IB_SA_MAD_HDR_SIZE (sizeof(ib_sa_mad_t) - IB_SA_DATA_SIZE)
-
-static inline uint32_t OSM_API ib_get_attr_size(IN const ib_net16_t attr_offset)
-{
- return (((uint32_t) cl_ntoh16(attr_offset)) << 3);
-}
-
-static inline ib_net16_t OSM_API ib_get_attr_offset(IN const uint32_t attr_size)
-{
- return (cl_hton16((uint16_t) (attr_size >> 3)));
-}
-
-/****f* IBA Base: Types/ib_sa_mad_get_payload_ptr
-* NAME
-* ib_sa_mad_get_payload_ptr
-*
-* DESCRIPTION
-* Gets a pointer to the SA MAD's payload area.
-*
-* SYNOPSIS
-*/
-static inline void *OSM_API
-ib_sa_mad_get_payload_ptr(IN const ib_sa_mad_t * const p_sa_mad)
-{
- return ((void *)p_sa_mad->data);
-}
-
-/*
-* PARAMETERS
-* p_sa_mad
-* [in] Pointer to the SA MAD packet.
-*
-* RETURN VALUES
-* Pointer to SA MAD payload area.
-*
-* NOTES
-*
-* SEE ALSO
-* ib_mad_t
-*********/
-
-#define IB_NODE_INFO_PORT_NUM_MASK (CL_HTON32(0xFF000000))
-#define IB_NODE_INFO_VEND_ID_MASK (CL_HTON32(0x00FFFFFF))
-#if CPU_LE
-#define IB_NODE_INFO_PORT_NUM_SHIFT 0
-#else
-#define IB_NODE_INFO_PORT_NUM_SHIFT 24
-#endif
-
-/****f* IBA Base: Types/ib_node_info_get_local_port_num
-* NAME
-* ib_node_info_get_local_port_num
-*
-* DESCRIPTION
-* Gets a the local port number from the NodeInfo attribute.
-*
-* SYNOPSIS
-*/
-static inline uint8_t OSM_API
-ib_node_info_get_local_port_num(IN const ib_node_info_t * const p_ni)
-{
- return ((uint8_t) ((p_ni->port_num_vendor_id &
- IB_NODE_INFO_PORT_NUM_MASK)
- >> IB_NODE_INFO_PORT_NUM_SHIFT));
-}
-
-/*
-* PARAMETERS
-* p_ni
-* [in] Pointer to a NodeInfo attribute.
-*
-* RETURN VALUES
-* Local port number that returned the attribute.
-*
-* NOTES
-*
-* SEE ALSO
-* ib_node_info_t
-*********/
-
-/****f* IBA Base: Types/ib_node_info_get_vendor_id
-* NAME
-* ib_node_info_get_vendor_id
-*
-* DESCRIPTION
-* Gets the VendorID from the NodeInfo attribute.
-*
-* SYNOPSIS
-*/
-static inline ib_net32_t OSM_API
-ib_node_info_get_vendor_id(IN const ib_node_info_t * const p_ni)
-{
- return ((ib_net32_t) (p_ni->port_num_vendor_id &
- IB_NODE_INFO_VEND_ID_MASK));
-}
-
-/*
-* PARAMETERS
-* p_ni
-* [in] Pointer to a NodeInfo attribute.
-*
-* RETURN VALUES
-* VendorID that returned the attribute.
-*
-* NOTES
-*
-* SEE ALSO
-* ib_node_info_t
-*********/
-
-#define IB_NODE_DESCRIPTION_SIZE 64
-
-#include <complib/cl_packon.h>
-typedef struct _ib_node_desc {
- // Node String is an array of UTF-8 character that
- // describes the node in text format
- // Note that this string is NOT NULL TERMINATED!
- uint8_t description[IB_NODE_DESCRIPTION_SIZE];
-
-} PACK_SUFFIX ib_node_desc_t;
-#include <complib/cl_packoff.h>
-
-#include <complib/cl_packon.h>
-typedef struct _ib_node_record_t {
- ib_net16_t lid;
- ib_net16_t resv;
- ib_node_info_t node_info;
- ib_node_desc_t node_desc;
- uint8_t pad[4];
-
-} PACK_SUFFIX ib_node_record_t;
-#include <complib/cl_packoff.h>
-
-/****s* IBA Base: Types/ib_port_info_t
-* NAME
-* ib_port_info_t
-*
-* DESCRIPTION
-* IBA defined PortInfo. (14.2.5.6)
-*
-* SYNOPSIS
-*/
-#include <complib/cl_packon.h>
-typedef struct _ib_port_info {
- ib_net64_t m_key;
- ib_net64_t subnet_prefix;
- ib_net16_t base_lid;
- ib_net16_t master_sm_base_lid;
- ib_net32_t capability_mask;
- ib_net16_t diag_code;
- ib_net16_t m_key_lease_period;
- uint8_t local_port_num;
- uint8_t link_width_enabled;
- uint8_t link_width_supported;
- uint8_t link_width_active;
- uint8_t state_info1; /* LinkSpeedSupported and PortState */
- uint8_t state_info2; /* PortPhysState and LinkDownDefaultState */
- uint8_t mkey_lmc;
- uint8_t link_speed; /* LinkSpeedEnabled and LinkSpeedActive */
- uint8_t mtu_smsl;
- uint8_t vl_cap; /* VLCap and InitType */
- uint8_t vl_high_limit;
- uint8_t vl_arb_high_cap;
- uint8_t vl_arb_low_cap;
- uint8_t mtu_cap;
- uint8_t vl_stall_life;
- uint8_t vl_enforce;
- ib_net16_t m_key_violations;
- ib_net16_t p_key_violations;
- ib_net16_t q_key_violations;
- uint8_t guid_cap;
- uint8_t subnet_timeout; /* cli_rereg(1b), resrv(
- 2b), timeout(5b) */
- uint8_t resp_time_value;
- uint8_t error_threshold;
-
-} PACK_SUFFIX ib_port_info_t;
-#include <complib/cl_packoff.h>
-/************/
-
-#define IB_PORT_STATE_MASK 0x0F
-#define IB_PORT_LMC_MASK 0x07
-#define IB_PORT_LMC_MAX 0x07
-#define IB_PORT_MPB_MASK 0xC0
-#define IB_PORT_MPB_SHIFT 6
-#define IB_PORT_LINK_SPEED_SHIFT 4
-#define IB_PORT_LINK_SPEED_SUPPORTED_MASK 0xF0
-#define IB_PORT_LINK_SPEED_ACTIVE_MASK 0xF0
-#define IB_PORT_LINK_SPEED_ENABLED_MASK 0x0F
-#define IB_PORT_PHYS_STATE_MASK 0xF0
-#define IB_PORT_PHYS_STATE_SHIFT 4
-#define IB_PORT_PHYS_STATE_NO_CHANGE 0
-#define IB_PORT_PHYS_STATE_SLEEP 1
-#define IB_PORT_PHYS_STATE_POLLING 2
-#define IB_PORT_PHYS_STATE_DISABLED 3
-#define IB_PORT_PHYS_STATE_PORTCONFTRAIN 4
-#define IB_PORT_PHYS_STATE_LINKUP 5
-#define IB_PORT_PHYS_STATE_LINKERRRECOVER 6
-#define IB_PORT_PHYS_STATE_PHYTEST 7
-#define IB_PORT_LNKDWNDFTSTATE_MASK 0x0F
-
-#define IB_PORT_CAP_RESV0 (CL_HTON32(0x00000001))
-#define IB_PORT_CAP_IS_SM (CL_HTON32(0x00000002))
-#define IB_PORT_CAP_HAS_NOTICE (CL_HTON32(0x00000004))
-#define IB_PORT_CAP_HAS_TRAP (CL_HTON32(0x00000008))
-#define IB_PORT_CAP_HAS_IPD (CL_HTON32(0x00000010))
-#define IB_PORT_CAP_HAS_AUTO_MIG (CL_HTON32(0x00000020))
-#define IB_PORT_CAP_HAS_SL_MAP (CL_HTON32(0x00000040))
-#define IB_PORT_CAP_HAS_NV_MKEY (CL_HTON32(0x00000080))
-#define IB_PORT_CAP_HAS_NV_PKEY (CL_HTON32(0x00000100))
-#define IB_PORT_CAP_HAS_LED_INFO (CL_HTON32(0x00000200))
-#define IB_PORT_CAP_SM_DISAB (CL_HTON32(0x00000400))
-#define IB_PORT_CAP_HAS_SYS_IMG_GUID (CL_HTON32(0x00000800))
-#define IB_PORT_CAP_HAS_PKEY_SW_EXT_PORT_TRAP (CL_HTON32(0x00001000))
-#define IB_PORT_CAP_RESV13 (CL_HTON32(0x00002000))
-#define IB_PORT_CAP_RESV14 (CL_HTON32(0x00004000))
-#define IB_PORT_CAP_RESV15 (CL_HTON32(0x00008000))
-#define IB_PORT_CAP_HAS_COM_MGT (CL_HTON32(0x00010000))
-#define IB_PORT_CAP_HAS_SNMP (CL_HTON32(0x00020000))
-#define IB_PORT_CAP_REINIT (CL_HTON32(0x00040000))
-#define IB_PORT_CAP_HAS_DEV_MGT (CL_HTON32(0x00080000))
-#define IB_PORT_CAP_HAS_VEND_CLS (CL_HTON32(0x00100000))
-#define IB_PORT_CAP_HAS_DR_NTC (CL_HTON32(0x00200000))
-#define IB_PORT_CAP_HAS_CAP_NTC (CL_HTON32(0x00400000))
-#define IB_PORT_CAP_HAS_BM (CL_HTON32(0x00800000))
-#define IB_PORT_CAP_HAS_LINK_RT_LATENCY (CL_HTON32(0x01000000))
-#define IB_PORT_CAP_HAS_CLIENT_REREG (CL_HTON32(0x02000000))
-#define IB_PORT_CAP_HAS_OTHER_LOCAL_CHANGES_NTC (CL_HTON32(0x04000000))
-#define IB_PORT_CAP_HAS_LINK_SPEED_WIDTH_PAIRS_TBL (CL_HTON32(0x08000000))
-#define IB_PORT_CAP_RESV28 (CL_HTON32(0x10000000))
-#define IB_PORT_CAP_RESV29 (CL_HTON32(0x20000000))
-#define IB_PORT_CAP_RESV30 (CL_HTON32(0x40000000))
-#define IB_PORT_CAP_RESV31 (CL_HTON32(0x80000000))
-
-/****f* IBA Base: Types/ib_port_info_get_port_state
-* NAME
-* ib_port_info_get_port_state
-*
-* DESCRIPTION
-* Returns the port state.
-*
-* SYNOPSIS
-*/
-static inline uint8_t OSM_API
-ib_port_info_get_port_state(IN const ib_port_info_t * const p_pi)
-{
- return ((uint8_t) (p_pi->state_info1 & IB_PORT_STATE_MASK));
-}
-
-/*
-* PARAMETERS
-* p_pi
-* [in] Pointer to a PortInfo attribute.
-*
-* RETURN VALUES
-* Port state.
-*
-* NOTES
-*
-* SEE ALSO
-*********/
-
-/****f* IBA Base: Types/ib_port_info_set_port_state
-* NAME
-* ib_port_info_set_port_state
-*
-* DESCRIPTION
-* Sets the port state.
-*
-* SYNOPSIS
-*/
-static inline void OSM_API
-ib_port_info_set_port_state(IN ib_port_info_t * const p_pi,
- IN const uint8_t port_state)
-{
- p_pi->state_info1 = (uint8_t) ((p_pi->state_info1 & 0xF0) | port_state);
-}
-
-/*
-* PARAMETERS
-* p_pi
-* [in] Pointer to a PortInfo attribute.
-*
-* port_state
-* [in] Port state value to set.
-*
-* RETURN VALUES
-* None.
-*
-* NOTES
-*
-* SEE ALSO
-*********/
-
-/****f* IBA Base: Types/ib_port_info_get_vl_cap
-* NAME
-* ib_port_info_get_vl_cap
-*
-* DESCRIPTION
-* Gets the VL Capability of a port.
-*
-* SYNOPSIS
-*/
-static inline uint8_t OSM_API
-ib_port_info_get_vl_cap(IN const ib_port_info_t * const p_pi)
-{
- return ((p_pi->vl_cap >> 4) & 0x0F);
-}
-
-/*
-* PARAMETERS
-* p_pi
-* [in] Pointer to a PortInfo attribute.
-*
-* RETURN VALUES
-* VL_CAP field
-*
-* NOTES
-*
-* SEE ALSO
-*********/
-
-/****f* IBA Base: Types/ib_port_info_get_init_type
-* NAME
-* ib_port_info_get_init_type
-*
-* DESCRIPTION
-* Gets the init type of a port.
-*
-* SYNOPSIS
-*/
-static inline uint8_t OSM_API
-ib_port_info_get_init_type(IN const ib_port_info_t * const p_pi)
-{
- return (uint8_t) (p_pi->vl_cap & 0x0F);
-}
-
-/*
-* PARAMETERS
-* p_pi
-* [in] Pointer to a PortInfo attribute.
-*
-* RETURN VALUES
-* InitType field
-*
-* NOTES
-*
-* SEE ALSO
-*********/
-
-/****f* IBA Base: Types/ib_port_info_get_op_vls
-* NAME
-* ib_port_info_get_op_vls
-*
-* DESCRIPTION
-* Gets the operational VLs on a port.
-*
-* SYNOPSIS
-*/
-static inline uint8_t OSM_API
-ib_port_info_get_op_vls(IN const ib_port_info_t * const p_pi)
-{
- return ((p_pi->vl_enforce >> 4) & 0x0F);
-}
-
-/*
-* PARAMETERS
-* p_pi
-* [in] Pointer to a PortInfo attribute.
-*
-* RETURN VALUES
-* OP_VLS field
-*
-* NOTES
-*
-* SEE ALSO
-*********/
-
-/****f* IBA Base: Types/ib_port_info_set_op_vls
-* NAME
-* ib_port_info_set_op_vls
-*
-* DESCRIPTION
-* Sets the operational VLs on a port.
-*
-* SYNOPSIS
-*/
-static inline void OSM_API
-ib_port_info_set_op_vls(IN ib_port_info_t * const p_pi, IN const uint8_t op_vls)
-{
- p_pi->vl_enforce =
- (uint8_t) ((p_pi->vl_enforce & 0x0F) | (op_vls << 4));
-}
-
-/*
-* PARAMETERS
-* p_pi
-* [in] Pointer to a PortInfo attribute.
-*
-* op_vls
-* [in] Encoded operation VLs value.
-*
-* RETURN VALUES
-* None.
-*
-* NOTES
-*
-* SEE ALSO
-*********/
-
-/****f* IBA Base: Types/ib_port_info_set_state_no_change
-* NAME
-* ib_port_info_set_state_no_change
-*
-* DESCRIPTION
-* Sets the port state fields to the value for "no change".
-*
-* SYNOPSIS
-*/
-static inline void OSM_API
-ib_port_info_set_state_no_change(IN ib_port_info_t * const p_pi)
-{
- ib_port_info_set_port_state(p_pi, IB_LINK_NO_CHANGE);
- p_pi->state_info2 = 0;
-}
-
-/*
-* PARAMETERS
-* p_pi
-* [in] Pointer to a PortInfo attribute.
-*
-* RETURN VALUES
-* None.
-*
-* NOTES
-*
-* SEE ALSO
-*********/
-
-/****f* IBA Base: Types/ib_port_info_get_link_speed_sup
-* NAME
-* ib_port_info_get_link_speed_sup
-*
-* DESCRIPTION
-* Returns the encoded value for the link speed supported.
-*
-* SYNOPSIS
-*/
-static inline uint8_t OSM_API
-ib_port_info_get_link_speed_sup(IN const ib_port_info_t * const p_pi)
-{
- return ((uint8_t) ((p_pi->state_info1 &
- IB_PORT_LINK_SPEED_SUPPORTED_MASK) >>
- IB_PORT_LINK_SPEED_SHIFT));
-}
-
-/*
-* PARAMETERS
-* p_pi
-* [in] Pointer to a PortInfo attribute.
-*
-* RETURN VALUES
-* Returns the encoded value for the link speed supported.
-*
-* NOTES
-*
-* SEE ALSO
-*********/
-
-/****f* IBA Base: Types/ib_port_info_set_link_speed_sup
-* NAME
-* ib_port_info_set_link_speed_sup
-*
-* DESCRIPTION
-* Given an integer of the supported link speed supported.
-* Set the appropriate bits in state_info1
-*
-* SYNOPSIS
-*/
-static inline void OSM_API
-ib_port_info_set_link_speed_sup(IN uint8_t const speed,
- IN ib_port_info_t * p_pi)
-{
- p_pi->state_info1 =
- (~IB_PORT_LINK_SPEED_SUPPORTED_MASK & p_pi->state_info1) |
- (IB_PORT_LINK_SPEED_SUPPORTED_MASK &
- (speed << IB_PORT_LINK_SPEED_SHIFT));
-}
-
-/*
-* PARAMETERS
-* speed
-* [in] Supported Speeds Code.
-*
-* p_pi
-* [in] Pointer to a PortInfo attribute.
-*
-* RETURN VALUES
-* This function does not return a value.
-*
-* NOTES
-*
-* SEE ALSO
-*********/
-
-/****f* IBA Base: Types/ib_port_info_get_port_phys_state
-* NAME
-* ib_port_info_get_port_phys_state
-*
-* DESCRIPTION
-* Returns the encoded value for the port physical state.
-*
-* SYNOPSIS
-*/
-static inline uint8_t OSM_API
-ib_port_info_get_port_phys_state(IN const ib_port_info_t * const p_pi)
-{
- return ((uint8_t) ((p_pi->state_info2 &
- IB_PORT_PHYS_STATE_MASK) >>
- IB_PORT_PHYS_STATE_SHIFT));
-}
-
-/*
-* PARAMETERS
-* p_pi
-* [in] Pointer to a PortInfo attribute.
-*
-* RETURN VALUES
-* Returns the encoded value for the port physical state.
-*
-* NOTES
-*
-* SEE ALSO
-*********/
-
-/****f* IBA Base: Types/ib_port_info_set_port_phys_state
-* NAME
-* ib_port_info_set_port_phys_state
-*
-* DESCRIPTION
-* Given an integer of the port physical state,
-* Set the appropriate bits in state_info2
-*
-* SYNOPSIS
-*/
-static inline void OSM_API
-ib_port_info_set_port_phys_state(IN uint8_t const phys_state,
- IN ib_port_info_t * p_pi)
-{
- p_pi->state_info2 =
- (~IB_PORT_PHYS_STATE_MASK & p_pi->state_info2) |
- (IB_PORT_PHYS_STATE_MASK &
- (phys_state << IB_PORT_PHYS_STATE_SHIFT));
-}
-
-/*
-* PARAMETERS
-* phys_state
-* [in] port physical state.
-*
-* p_pi
-* [in] Pointer to a PortInfo attribute.
-*
-* RETURN VALUES
-* This function does not return a value.
-*
-* NOTES
-*
-* SEE ALSO
-*********/
-
-/****f* IBA Base: Types/ib_port_info_get_link_down_def_state
-* NAME
-* ib_port_info_get_link_down_def_state
-*
-* DESCRIPTION
-* Returns the link down default state.
-*
-* SYNOPSIS
-*/
-static inline uint8_t OSM_API
-ib_port_info_get_link_down_def_state(IN const ib_port_info_t * const p_pi)
-{
- return ((uint8_t) (p_pi->state_info2 & IB_PORT_LNKDWNDFTSTATE_MASK));
-}
-
-/*
-* PARAMETERS
-* p_pi
-* [in] Pointer to a PortInfo attribute.
-*
-* RETURN VALUES
-* link down default state of the port.
-*
-* NOTES
-*
-* SEE ALSO
-*********/
-
-/****f* IBA Base: Types/ib_port_info_set_link_down_def_state
-* NAME
-* ib_port_info_set_link_down_def_state
-*
-* DESCRIPTION
-* Sets the link down default state of the port.
-*
-* SYNOPSIS
-*/
-static inline void OSM_API
-ib_port_info_set_link_down_def_state(IN ib_port_info_t * const p_pi,
- IN const uint8_t link_dwn_state)
-{
- p_pi->state_info2 =
- (uint8_t) ((p_pi->state_info2 & 0xF0) | link_dwn_state);
-}
-
-/*
-* PARAMETERS
-* p_pi
-* [in] Pointer to a PortInfo attribute.
-*
-* link_dwn_state
-* [in] Link down default state of the port.
-*
-* RETURN VALUES
-* None.
-*
-* NOTES
-*
-* SEE ALSO
-*********/
-
-/****f* IBA Base: Types/ib_port_info_get_link_speed_active
-* NAME
-* ib_port_info_get_link_speed_active
-*
-* DESCRIPTION
-* Returns the Link Speed Active value assigned to this port.
-*
-* SYNOPSIS
-*/
-static inline uint8_t OSM_API
-ib_port_info_get_link_speed_active(IN const ib_port_info_t * const p_pi)
-{
- return ((uint8_t) ((p_pi->link_speed &
- IB_PORT_LINK_SPEED_ACTIVE_MASK) >>
- IB_PORT_LINK_SPEED_SHIFT));
-}
-
-/*
-* PARAMETERS
-* p_pi
-* [in] Pointer to a PortInfo attribute.
-*
-* RETURN VALUES
-* Returns the link speed active value assigned to this port.
-*
-* NOTES
-*
-* SEE ALSO
-*********/
-
-#define IB_LINK_WIDTH_ACTIVE_1X 1
-#define IB_LINK_WIDTH_ACTIVE_4X 2
-#define IB_LINK_WIDTH_ACTIVE_8X 4
-#define IB_LINK_WIDTH_ACTIVE_12X 8
-#define IB_LINK_SPEED_ACTIVE_2_5 1
-#define IB_LINK_SPEED_ACTIVE_5 2
-#define IB_LINK_SPEED_ACTIVE_10 4
-
-/* following v1 ver1.2 p901 */
-#define IB_PATH_RECORD_RATE_2_5_GBS 2
-#define IB_PATH_RECORD_RATE_10_GBS 3
-#define IB_PATH_RECORD_RATE_30_GBS 4
-#define IB_PATH_RECORD_RATE_5_GBS 5
-#define IB_PATH_RECORD_RATE_20_GBS 6
-#define IB_PATH_RECORD_RATE_40_GBS 7
-#define IB_PATH_RECORD_RATE_60_GBS 8
-#define IB_PATH_RECORD_RATE_80_GBS 9
-#define IB_PATH_RECORD_RATE_120_GBS 10
-
-#define IB_MIN_RATE IB_PATH_RECORD_RATE_2_5_GBS
-#define IB_MAX_RATE IB_PATH_RECORD_RATE_120_GBS
-
-/****f* IBA Base: Types/ib_port_info_compute_rate
-* NAME
-* ib_port_info_compute_rate
-*
-* DESCRIPTION
-* Returns the encoded value for the path rate.
-*
-* SYNOPSIS
-*/
-static inline uint8_t OSM_API
-ib_port_info_compute_rate(IN const ib_port_info_t * const p_pi)
-{
- uint8_t rate = 0;
-
- switch (ib_port_info_get_link_speed_active(p_pi)) {
- case IB_LINK_SPEED_ACTIVE_2_5:
- switch (p_pi->link_width_active) {
- case IB_LINK_WIDTH_ACTIVE_1X:
- rate = IB_PATH_RECORD_RATE_2_5_GBS;
- break;
-
- case IB_LINK_WIDTH_ACTIVE_4X:
- rate = IB_PATH_RECORD_RATE_10_GBS;
- break;
-
- case IB_LINK_WIDTH_ACTIVE_8X:
- rate = IB_PATH_RECORD_RATE_20_GBS;
- break;
-
- case IB_LINK_WIDTH_ACTIVE_12X:
- rate = IB_PATH_RECORD_RATE_30_GBS;
- break;
-
- default:
- rate = IB_PATH_RECORD_RATE_2_5_GBS;
- break;
- }
- break;
- case IB_LINK_SPEED_ACTIVE_5:
- switch (p_pi->link_width_active) {
- case IB_LINK_WIDTH_ACTIVE_1X:
- rate = IB_PATH_RECORD_RATE_5_GBS;
- break;
-
- case IB_LINK_WIDTH_ACTIVE_4X:
- rate = IB_PATH_RECORD_RATE_20_GBS;
- break;
-
- case IB_LINK_WIDTH_ACTIVE_8X:
- rate = IB_PATH_RECORD_RATE_40_GBS;
- break;
-
- case IB_LINK_WIDTH_ACTIVE_12X:
- rate = IB_PATH_RECORD_RATE_60_GBS;
- break;
-
- default:
- rate = IB_PATH_RECORD_RATE_5_GBS;
- break;
- }
- break;
- case IB_LINK_SPEED_ACTIVE_10:
- switch (p_pi->link_width_active) {
- case IB_LINK_WIDTH_ACTIVE_1X:
- rate = IB_PATH_RECORD_RATE_10_GBS;
- break;
-
- case IB_LINK_WIDTH_ACTIVE_4X:
- rate = IB_PATH_RECORD_RATE_40_GBS;
- break;
-
- case IB_LINK_WIDTH_ACTIVE_8X:
- rate = IB_PATH_RECORD_RATE_80_GBS;
- break;
-
- case IB_LINK_WIDTH_ACTIVE_12X:
- rate = IB_PATH_RECORD_RATE_120_GBS;
- break;
-
- default:
- rate = IB_PATH_RECORD_RATE_10_GBS;
- break;
- }
- break;
- default:
- rate = IB_PATH_RECORD_RATE_2_5_GBS;
- break;
- }
-
- return rate;
-}
-
-/*
-* PARAMETERS
-* p_pi
-* [in] Pointer to a PortInfo attribute.
-*
-* RETURN VALUES
-* Returns the encoded value for the link speed supported.
-*
-* NOTES
-*
-* SEE ALSO
-*********/
-
-/****f* IBA Base: Types/ib_path_get_ipd
-* NAME
-* ib_path_get_ipd
-*
-* DESCRIPTION
-* Returns the encoded value for the inter packet delay.
-*
-* SYNOPSIS
-*/
-static inline uint8_t OSM_API
-ib_path_get_ipd(IN uint8_t local_link_width_supported, IN uint8_t path_rec_rate)
-{
- uint8_t ipd = 0;
-
- switch (local_link_width_supported) {
- /* link_width_supported = 1: 1x */
- case 1:
- break;
-
- /* link_width_supported = 3: 1x or 4x */
- case 3:
- switch (path_rec_rate & 0x3F) {
- case IB_PATH_RECORD_RATE_2_5_GBS:
- ipd = 3;
- break;
- default:
- break;
- }
- break;
-
- /* link_width_supported = 11: 1x or 4x or 12x */
- case 11:
- switch (path_rec_rate & 0x3F) {
- case IB_PATH_RECORD_RATE_2_5_GBS:
- ipd = 11;
- break;
- case IB_PATH_RECORD_RATE_10_GBS:
- ipd = 2;
- break;
- default:
- break;
- }
- break;
-
- default:
- break;
- }
-
- return ipd;
-}
-
-/*
-* PARAMETERS
-* local_link_width_supported
-* [in] link with supported for this port
-*
-* path_rec_rate
-* [in] rate field of the path record
-*
-* RETURN VALUES
-* Returns the ipd
-*
-* NOTES
-*
-* SEE ALSO
-*********/
-
-/****f* IBA Base: Types/ib_port_info_get_mtu_cap
-* NAME
-* ib_port_info_get_mtu_cap
-*
-* DESCRIPTION
-* Returns the encoded value for the maximum MTU supported by this port.
-*
-* SYNOPSIS
-*/
-static inline uint8_t OSM_API
-ib_port_info_get_mtu_cap(IN const ib_port_info_t * const p_pi)
-{
- return ((uint8_t) (p_pi->mtu_cap & 0x0F));
-}
-
-/*
-* PARAMETERS
-* p_pi
-* [in] Pointer to a PortInfo attribute.
-*
-* RETURN VALUES
-* Returns the encooded value for the maximum MTU supported by this port.
-*
-* NOTES
-*
-* SEE ALSO
-*********/
-
-/****f* IBA Base: Types/ib_port_info_get_neighbor_mtu
-* NAME
-* ib_port_info_get_neighbor_mtu
-*
-* DESCRIPTION
-* Returns the encoded value for the neighbor MTU supported by this port.
-*
-* SYNOPSIS
-*/
-static inline uint8_t OSM_API
-ib_port_info_get_neighbor_mtu(IN const ib_port_info_t * const p_pi)
-{
- return ((uint8_t) ((p_pi->mtu_smsl & 0xF0) >> 4));
-}
-
-/*
-* PARAMETERS
-* p_pi
-* [in] Pointer to a PortInfo attribute.
-*
-* RETURN VALUES
-* Returns the encoded value for the neighbor MTU at this port.
-*
-* NOTES
-*
-* SEE ALSO
-*********/
-
-/****f* IBA Base: Types/ib_port_info_set_neighbor_mtu
-* NAME
-* ib_port_info_set_neighbor_mtu
-*
-* DESCRIPTION
-* Sets the Neighbor MTU value in the PortInfo attribute.
-*
-* SYNOPSIS
-*/
-static inline void OSM_API
-ib_port_info_set_neighbor_mtu(IN ib_port_info_t * const p_pi,
- IN const uint8_t mtu)
-{
- CL_ASSERT(mtu <= 5);
- CL_ASSERT(mtu != 0);
- p_pi->mtu_smsl = (uint8_t) ((p_pi->mtu_smsl & 0x0F) | (mtu << 4));
-}
-
-/*
-* PARAMETERS
-* p_pi
-* [in] Pointer to a PortInfo attribute.
-*
-* mtu
-* [in] Encoded MTU value to set
-*
-* RETURN VALUES
-* None.
-*
-* NOTES
-*
-* SEE ALSO
-*********/
-
-/****f* IBA Base: Types/ib_port_info_get_master_smsl
-* NAME
-* ib_port_info_get_master_smsl
-*
-* DESCRIPTION
-* Returns the encoded value for the Master SMSL at this port.
-*
-* SYNOPSIS
-*/
-static inline uint8_t OSM_API
-ib_port_info_get_master_smsl(IN const ib_port_info_t * const p_pi)
-{
- return (uint8_t) (p_pi->mtu_smsl & 0x0F);
-}
-
-/*
-* PARAMETERS
-* p_pi
-* [in] Pointer to a PortInfo attribute.
-*
-* RETURN VALUES
-* Returns the encoded value for the Master SMSL at this port.
-*
-* NOTES
-*
-* SEE ALSO
-*********/
-
-/****f* IBA Base: Types/ib_port_info_set_master_smsl
-* NAME
-* ib_port_info_set_master_smsl
-*
-* DESCRIPTION
-* Sets the Master SMSL value in the PortInfo attribute.
-*
-* SYNOPSIS
-*/
-static inline void OSM_API
-ib_port_info_set_master_smsl(IN ib_port_info_t * const p_pi,
- IN const uint8_t smsl)
-{
- p_pi->mtu_smsl = (uint8_t) ((p_pi->mtu_smsl & 0xF0) | smsl);
-}
-
-/*
-* PARAMETERS
-* p_pi
-* [in] Pointer to a PortInfo attribute.
-*
-* mtu
-* [in] Encoded Master SMSL value to set
-*
-* RETURN VALUES
-* None.
-*
-* NOTES
-*
-* SEE ALSO
-*********/
-
-/****f* IBA Base: Types/ib_port_info_set_timeout
-* NAME
-* ib_port_info_set_timeout
-*
-* DESCRIPTION
-* Sets the encoded subnet timeout value in the PortInfo attribute.
-*
-* SYNOPSIS
-*/
-static inline void OSM_API
-ib_port_info_set_timeout(IN ib_port_info_t * const p_pi,
- IN const uint8_t timeout)
-{
- CL_ASSERT(timeout <= 0x1F);
- p_pi->subnet_timeout =
- (uint8_t) ((p_pi->subnet_timeout & 0x80) | (timeout & 0x1F));
-}
-
-/*
-* PARAMETERS
-* p_pi
-* [in] Pointer to a PortInfo attribute.
-*
-* timeout
-* [in] Encoded timeout value to set
-*
-* RETURN VALUES
-* None.
-*
-* NOTES
-*
-* SEE ALSO
-*********/
-
-/****f* IBA Base: Types/ib_port_info_set_client_rereg
-* NAME
-* ib_port_info_set_client_rereg
-*
-* DESCRIPTION
-* Sets the encoded client reregistration bit value in the PortInfo attribute.
-*
-* SYNOPSIS
-*/
-static inline void OSM_API
-ib_port_info_set_client_rereg(IN ib_port_info_t * const p_pi,
- IN const uint8_t client_rereg)
-{
- CL_ASSERT(client_rereg <= 0x1);
- p_pi->subnet_timeout =
- (uint8_t) ((p_pi->
- subnet_timeout & 0x1F) | ((client_rereg << 7) & 0x80));
-}
-
-/*
-* PARAMETERS
-* p_pi
-* [in] Pointer to a PortInfo attribute.
-*
-* client_rereg
-* [in] Client reregistration value to set (either 1 or 0).
-*
-* RETURN VALUES
-* None.
-*
-* NOTES
-*
-* SEE ALSO
-*********/
-
-/****f* IBA Base: Types/ib_port_info_get_timeout
-* NAME
-* ib_port_info_get_timeout
-*
-* DESCRIPTION
-* Gets the encoded subnet timeout value in the PortInfo attribute.
-*
-* SYNOPSIS
-*/
-static inline uint8_t OSM_API
-ib_port_info_get_timeout(IN ib_port_info_t const *p_pi)
-{
- return (p_pi->subnet_timeout & 0x1F);
-}
-
-/*
-* PARAMETERS
-* p_pi
-* [in] Pointer to a PortInfo attribute.
-*
-* RETURN VALUES
-* The encoded timeout value
-*
-* NOTES
-*
-* SEE ALSO
-*********/
-
-/****f* IBA Base: Types/ib_port_info_get_client_rereg
-* NAME
-* ib_port_info_get_client_rereg
-*
-* DESCRIPTION
-* Gets the encoded client reregistration bit value in the PortInfo attribute.
-*
-* SYNOPSIS
-*/
-static inline uint8_t OSM_API
-ib_port_info_get_client_rereg(IN ib_port_info_t const *p_pi)
-{
- return ((p_pi->subnet_timeout & 0x80) >> 7);
-}
-
-/*
-* PARAMETERS
-* p_pi
-* [in] Pointer to a PortInfo attribute.
-*
-* RETURN VALUES
-* Client reregistration value (either 1 or 0).
-*
-* NOTES
-*
-* SEE ALSO
-*********/
-
-/****f* IBA Base: Types/ib_port_info_set_hoq_lifetime
-* NAME
-* ib_port_info_set_hoq_lifetime
-*
-* DESCRIPTION
-* Sets the Head of Queue Lifetime for which a packet can live in the head
-* of VL queue
-*
-* SYNOPSIS
-*/
-static inline void OSM_API
-ib_port_info_set_hoq_lifetime(IN ib_port_info_t * const p_pi,
- IN const uint8_t hoq_life)
-{
- p_pi->vl_stall_life = (uint8_t) ((hoq_life & 0x1f) |
- (p_pi->vl_stall_life & 0xe0));
-}
-
-/*
-* PARAMETERS
-* p_pi
-* [in] Pointer to a PortInfo attribute.
-*
-* hoq_life
-* [in] Encoded lifetime value to set
-*
-* RETURN VALUES
-* None.
-*
-* NOTES
-*
-* SEE ALSO
-*********/
-
-/****f* IBA Base: Types/ib_port_info_get_hoq_lifetime
-* NAME
-* ib_port_info_get_hoq_lifetime
-*
-* DESCRIPTION
-* Gets the Head of Queue Lifetime for which a packet can live in the head
-* of VL queue
-*
-* SYNOPSIS
-*/
-static inline uint8_t OSM_API
-ib_port_info_get_hoq_lifetime(IN const ib_port_info_t * const p_pi)
-{
- return ((uint8_t) (p_pi->vl_stall_life & 0x1f));
-}
-
-/*
-* PARAMETERS
-* p_pi
-* [in] Pointer to a PortInfo attribute.
-*
-* RETURN VALUES
-* Encoded lifetime value
-*
-* NOTES
-*
-* SEE ALSO
-*********/
-
-/****f* IBA Base: Types/ib_port_info_set_vl_stall_count
-* NAME
-* ib_port_info_set_vl_stall_count
-*
-* DESCRIPTION
-* Sets the VL Stall Count which define the number of contiguous
-* HLL (hoq) drops that will put the VL into stalled mode.
-*
-* SYNOPSIS
-*/
-static inline void OSM_API
-ib_port_info_set_vl_stall_count(IN ib_port_info_t * const p_pi,
- IN const uint8_t vl_stall_count)
-{
- p_pi->vl_stall_life = (uint8_t) ((p_pi->vl_stall_life & 0x1f) |
- ((vl_stall_count << 5) & 0xe0));
-}
-
-/*
-* PARAMETERS
-* p_pi
-* [in] Pointer to a PortInfo attribute.
-*
-* vl_stall_count
-* [in] value to set
-*
-* RETURN VALUES
-* None.
-*
-* NOTES
-*
-* SEE ALSO
-*********/
-
-/****f* IBA Base: Types/ib_port_info_get_vl_stall_count
-* NAME
-* ib_port_info_get_vl_stall_count
-*
-* DESCRIPTION
-* Gets the VL Stall Count which define the number of contiguous
-* HLL (hoq) drops that will put the VL into stalled mode
-*
-* SYNOPSIS
-*/
-static inline uint8_t OSM_API
-ib_port_info_get_vl_stall_count(IN const ib_port_info_t * const p_pi)
-{
- return ((uint8_t) (p_pi->vl_stall_life & 0xe0) >> 5);
-}
-
-/*
-* PARAMETERS
-* p_pi
-* [in] Pointer to a PortInfo attribute.
-*
-* RETURN VALUES
-* vl stall count
-*
-* NOTES
-*
-* SEE ALSO
-*********/
-
-/****f* IBA Base: Types/ib_port_info_get_lmc
-* NAME
-* ib_port_info_get_lmc
-*
-* DESCRIPTION
-* Returns the LMC value assigned to this port.
-*
-* SYNOPSIS
-*/
-static inline uint8_t OSM_API
-ib_port_info_get_lmc(IN const ib_port_info_t * const p_pi)
-{
- return ((uint8_t) (p_pi->mkey_lmc & IB_PORT_LMC_MASK));
-}
-
-/*
-* PARAMETERS
-* p_pi
-* [in] Pointer to a PortInfo attribute.
-*
-* RETURN VALUES
-* Returns the LMC value assigned to this port.
-*
-* NOTES
-*
-* SEE ALSO
-*********/
-
-/****f* IBA Base: Types/ib_port_info_set_lmc
-* NAME
-* ib_port_info_set_lmc
-*
-* DESCRIPTION
-* Sets the LMC value in the PortInfo attribute.
-*
-* SYNOPSIS
-*/
-static inline void OSM_API
-ib_port_info_set_lmc(IN ib_port_info_t * const p_pi, IN const uint8_t lmc)
-{
- CL_ASSERT(lmc <= IB_PORT_LMC_MAX);
- p_pi->mkey_lmc = (uint8_t) ((p_pi->mkey_lmc & 0xF8) | lmc);
-}
-
-/*
-* PARAMETERS
-* p_pi
-* [in] Pointer to a PortInfo attribute.
-*
-* lmc
-* [in] LMC value to set, must be less than 7.
-*
-* RETURN VALUES
-* None.
-*
-* NOTES
-*
-* SEE ALSO
-*********/
-
-/****f* IBA Base: Types/ib_port_info_get_link_speed_enabled
-* NAME
-* ib_port_info_get_link_speed_enabled
-*
-* DESCRIPTION
-* Returns the link speed enabled value assigned to this port.
-*
-* SYNOPSIS
-*/
-static inline uint8_t OSM_API
-ib_port_info_get_link_speed_enabled(IN const ib_port_info_t * const p_pi)
-{
- return ((uint8_t) (p_pi->link_speed & IB_PORT_LINK_SPEED_ENABLED_MASK));
-}
-
-/*
-* PARAMETERS
-* p_pi
-* [in] Pointer to a PortInfo attribute.
-*
-* RETURN VALUES
-* Port state.
-*
-* NOTES
-*
-* SEE ALSO
-*********/
-
-/****f* IBA Base: Types/ib_port_info_set_link_speed_enabled
-* NAME
-* ib_port_info_set_link_speed_enabled
-*
-* DESCRIPTION
-* Sets the link speed enabled value in the PortInfo attribute.
-*
-* SYNOPSIS
-*/
-static inline void OSM_API
-ib_port_info_set_link_speed_enabled(IN ib_port_info_t * const p_pi,
- IN const uint8_t link_speed_enabled)
-{
- p_pi->link_speed =
- (uint8_t) ((p_pi->link_speed & 0xF0) | link_speed_enabled);
-}
-
-/*
-* PARAMETERS
-* p_pi
-* [in] Pointer to a PortInfo attribute.
-*
-* link_speed_enabled
-* [in] link speed enabled value to set.
-*
-* RETURN VALUES
-* None.
-*
-* NOTES
-*
-* SEE ALSO
-*********/
-
-/****f* IBA Base: Types/ib_port_info_get_mpb
-* NAME
-* ib_port_info_get_mpb
-*
-* DESCRIPTION
-* Returns the M_Key protect bits assigned to this port.
-*
-* SYNOPSIS
-*/
-static inline uint8_t OSM_API
-ib_port_info_get_mpb(IN const ib_port_info_t * const p_pi)
-{
- return ((uint8_t) ((p_pi->mkey_lmc & IB_PORT_MPB_MASK) >>
- IB_PORT_MPB_SHIFT));
-}
-
-/*
-* PARAMETERS
-* p_ni
-* [in] Pointer to a PortInfo attribute.
-*
-* RETURN VALUES
-* Returns the M_Key protect bits assigned to this port.
-*
-* NOTES
-*
-* SEE ALSO
-*********/
-
-/****f* IBA Base: Types/ib_port_info_set_mpb
-* NAME
-* ib_port_info_set_mpb
-*
-* DESCRIPTION
-* Set the M_Key protect bits of this port.
-*
-* SYNOPSIS
-*/
-static inline void OSM_API
-ib_port_info_set_mpb(IN ib_port_info_t * p_pi, IN uint8_t mpb)
-{
- p_pi->mkey_lmc =
- (~IB_PORT_MPB_MASK & p_pi->mkey_lmc) |
- (IB_PORT_MPB_MASK & (mpb << IB_PORT_MPB_SHIFT));
-}
-
-/*
-* PARAMETERS
-* mpb
-* [in] M_Key protect bits
-* p_ni
-* [in] Pointer to a PortInfo attribute.
-*
-* RETURN VALUES
-*
-* NOTES
-*
-* SEE ALSO
-*********/
-
-/****f* IBA Base: Types/ib_port_info_get_local_phy_err_thd
-* NAME
-* ib_port_info_get_local_phy_err_thd
-*
-* DESCRIPTION
-* Returns the Phy Link Threshold
-*
-* SYNOPSIS
-*/
-static inline uint8_t OSM_API
-ib_port_info_get_local_phy_err_thd(IN const ib_port_info_t * const p_pi)
-{
- return (uint8_t) ((p_pi->error_threshold & 0xF0) >> 4);
-}
-
-/*
-* PARAMETERS
-* p_pi
-* [in] Pointer to a PortInfo attribute.
-*
-* RETURN VALUES
-* Returns the Phy Link error threshold assigned to this port.
-*
-* NOTES
-*
-* SEE ALSO
-*********/
-
-/****f* IBA Base: Types/ib_port_info_get_overrun_err_thd
-* NAME
-* ib_port_info_get_local_overrun_err_thd
-*
-* DESCRIPTION
-* Returns the Credits Overrun Errors Threshold
-*
-* SYNOPSIS
-*/
-static inline uint8_t OSM_API
-ib_port_info_get_overrun_err_thd(IN const ib_port_info_t * const p_pi)
-{
- return (uint8_t) (p_pi->error_threshold & 0x0F);
-}
-
-/*
-* PARAMETERS
-* p_pi
-* [in] Pointer to a PortInfo attribute.
-*
-* RETURN VALUES
-* Returns the Credits Overrun errors threshold assigned to this port.
-*
-* NOTES
-*
-* SEE ALSO
-*********/
-
-/****f* IBA Base: Types/ib_port_info_set_phy_and_overrun_err_thd
-* NAME
-* ib_port_info_set_phy_and_overrun_err_thd
-*
-* DESCRIPTION
-* Sets the Phy Link and Credits Overrun Errors Threshold
-*
-* SYNOPSIS
-*/
-static inline void OSM_API
-ib_port_info_set_phy_and_overrun_err_thd(IN ib_port_info_t * const p_pi,
- IN uint8_t phy_threshold,
- IN uint8_t overrun_threshold)
-{
- p_pi->error_threshold =
- (uint8_t) (((phy_threshold & 0x0F) << 4) |
- (overrun_threshold & 0x0F));
-}
-
-/*
-* PARAMETERS
-* p_pi
-* [in] Pointer to a PortInfo attribute.
-*
-* phy_threshold
-* [in] Physical Link Errors Threshold above which Trap 129 is generated
-*
-* overrun_threshold
-* [in] Credits overrun Errors Threshold above which Trap 129 is generated
-*
-* RETURN VALUES
-* None.
-*
-* NOTES
-*
-* SEE ALSO
-*********/
-
-typedef uint8_t ib_svc_name_t[64];
-
-#include <complib/cl_packon.h>
-typedef struct _ib_service_record {
- ib_net64_t service_id;
- ib_gid_t service_gid;
- ib_net16_t service_pkey;
- ib_net16_t resv;
- ib_net32_t service_lease;
- uint8_t service_key[16];
- ib_svc_name_t service_name;
- uint8_t service_data8[16];
- ib_net16_t service_data16[8];
- ib_net32_t service_data32[4];
- ib_net64_t service_data64[2];
-
-} PACK_SUFFIX ib_service_record_t;
-#include <complib/cl_packoff.h>
-
-#include <complib/cl_packon.h>
-typedef struct _ib_portinfo_record {
- ib_net16_t lid;
- uint8_t port_num;
- uint8_t resv;
- ib_port_info_t port_info;
- uint8_t pad[6];
-
-} PACK_SUFFIX ib_portinfo_record_t;
-#include <complib/cl_packoff.h>
-
-#include <complib/cl_packon.h>
-typedef struct _ib_link_record {
- ib_net16_t from_lid;
- uint8_t from_port_num;
- uint8_t to_port_num;
- ib_net16_t to_lid;
- uint8_t pad[2];
-
-} PACK_SUFFIX ib_link_record_t;
-#include <complib/cl_packoff.h>
-
-#include <complib/cl_packon.h>
-typedef struct _ib_sminfo_record {
- ib_net16_t lid;
- uint16_t resv0;
- ib_sm_info_t sm_info;
- uint8_t pad[7];
-
-} PACK_SUFFIX ib_sminfo_record_t;
-#include <complib/cl_packoff.h>
-
-/****s* IBA Base: Types/ib_lft_record_t
-* NAME
-* ib_lft_record_t
-*
-* DESCRIPTION
-* IBA defined LinearForwardingTableRecord (15.2.5.6)
-*
-* SYNOPSIS
-*/
-#include <complib/cl_packon.h>
-typedef struct _ib_lft_record {
- ib_net16_t lid;
- ib_net16_t block_num;
- uint32_t resv0;
- uint8_t lft[64];
-} PACK_SUFFIX ib_lft_record_t;
-#include <complib/cl_packoff.h>
-/************/
-
-/****s* IBA Base: Types/ib_mft_record_t
-* NAME
-* ib_mft_record_t
-*
-* DESCRIPTION
-* IBA defined MulticastForwardingTableRecord (15.2.5.8)
-*
-* SYNOPSIS
-*/
-#include <complib/cl_packon.h>
-typedef struct _ib_mft_record {
- ib_net16_t lid;
- ib_net16_t position_block_num;
- uint32_t resv0;
- ib_net16_t mft[IB_MCAST_BLOCK_SIZE];
-} PACK_SUFFIX ib_mft_record_t;
-#include <complib/cl_packoff.h>
-/************/
-
-/****s* IBA Base: Types/ib_switch_info_t
-* NAME
-* ib_switch_info_t
-*
-* DESCRIPTION
-* IBA defined SwitchInfo. (14.2.5.4)
-*
-* SYNOPSIS
-*/
-#include <complib/cl_packon.h>
-typedef struct _ib_switch_info {
- ib_net16_t lin_cap;
- ib_net16_t rand_cap;
- ib_net16_t mcast_cap;
- ib_net16_t lin_top;
- uint8_t def_port;
- uint8_t def_mcast_pri_port;
- uint8_t def_mcast_not_port;
- uint8_t life_state;
- ib_net16_t lids_per_port;
- ib_net16_t enforce_cap;
- uint8_t flags;
-
-} PACK_SUFFIX ib_switch_info_t;
-#include <complib/cl_packoff.h>
-/************/
-
-#include <complib/cl_packon.h>
-typedef struct _ib_switch_info_record {
- ib_net16_t lid;
- uint16_t resv0;
- ib_switch_info_t switch_info;
- uint8_t pad[3];
-
-} PACK_SUFFIX ib_switch_info_record_t;
-#include <complib/cl_packoff.h>
-
-#define IB_SWITCH_PSC 0x04
-
-/****f* IBA Base: Types/ib_switch_info_get_state_change
-* NAME
-* ib_switch_info_get_state_change
-*
-* DESCRIPTION
-* Returns the value of the state change flag.
-*
-* SYNOPSIS
-*/
-static inline boolean_t OSM_API
-ib_switch_info_get_state_change(IN const ib_switch_info_t * const p_si)
-{
- return ((p_si->life_state & IB_SWITCH_PSC) == IB_SWITCH_PSC);
-}
-
-/*
-* PARAMETERS
-* p_si
-* [in] Pointer to a SwitchInfo attribute.
-*
-* RETURN VALUES
-* Returns the value of the state change flag.
-*
-* NOTES
-*
-* SEE ALSO
-*********/
-
-/****f* IBA Base: Types/ib_switch_info_clear_state_change
-* NAME
-* ib_switch_info_clear_state_change
-*
-* DESCRIPTION
-* Clears the switch's state change bit.
-*
-* SYNOPSIS
-*/
-static inline void OSM_API
-ib_switch_info_clear_state_change(IN ib_switch_info_t * const p_si)
-{
- p_si->life_state = (uint8_t) (p_si->life_state & 0xFB);
-}
-
-/*
-* PARAMETERS
-* p_ni
-* [in] Pointer to a PortInfo attribute.
-*
-* RETURN VALUES
-* Returns the LMC value assigned to this port.
-*
-* NOTES
-*
-* SEE ALSO
-*********/
-
-/****f* IBA Base: Types/ib_switch_info_is_enhanced_port0
-* NAME
-* ib_switch_info_is_enhanced_port0
-*
-* DESCRIPTION
-* Returns TRUE if the enhancedPort0 bit is on (meaning the switch
-* port zero supports enhanced functions).
-* Returns FALSE otherwise.
-*
-* SYNOPSIS
-*/
-static inline boolean_t OSM_API
-ib_switch_info_is_enhanced_port0(IN const ib_switch_info_t * const p_si)
-{
- return ((p_si->flags & 0x08) == 0x08);
-}
-
-/*
-* PARAMETERS
-* p_si
-* [in] Pointer to a SwitchInfo attribute.
-*
-* RETURN VALUES
-* Returns TRUE if the switch supports enhanced port 0. FALSE otherwise.
-*
-* NOTES
-*
-* SEE ALSO
-*********/
-
-/****s* IBA Base: Types/ib_guid_info_t
-* NAME
-* ib_guid_info_t
-*
-* DESCRIPTION
-* IBA defined GuidInfo. (14.2.5.5)
-*
-* SYNOPSIS
-*/
-#define GUID_TABLE_MAX_ENTRIES 8
-
-#include <complib/cl_packon.h>
-typedef struct _ib_guid_info {
- ib_net64_t guid[GUID_TABLE_MAX_ENTRIES];
-
-} PACK_SUFFIX ib_guid_info_t;
-#include <complib/cl_packoff.h>
-/************/
-
-#include <complib/cl_packon.h>
-typedef struct _ib_guidinfo_record {
- ib_net16_t lid;
- uint8_t block_num;
- uint8_t resv;
- uint32_t reserved;
- ib_guid_info_t guid_info;
-} PACK_SUFFIX ib_guidinfo_record_t;
-#include <complib/cl_packoff.h>
-
-#define IB_MULTIPATH_MAX_GIDS 11 /* Support max that can fit into first MAD (for now) */
-
-#include <complib/cl_packon.h>
-typedef struct _ib_multipath_rec_t {
- ib_net32_t hop_flow_raw;
- uint8_t tclass;
- uint8_t num_path;
- ib_net16_t pkey;
- ib_net16_t qos_class_sl;
- uint8_t mtu;
- uint8_t rate;
- uint8_t pkt_life;
- uint8_t service_id_8msb;
- uint8_t independence; /* formerly resv2 */
- uint8_t sgid_count;
- uint8_t dgid_count;
- uint8_t service_id_56lsb[7];
- ib_gid_t gids[IB_MULTIPATH_MAX_GIDS];
-} PACK_SUFFIX ib_multipath_rec_t;
-#include <complib/cl_packoff.h>
-/*
-* FIELDS
-* hop_flow_raw
-* Global routing parameters: hop count, flow label and raw bit.
-*
-* tclass
-* Another global routing parameter.
-*
-* num_path
-* Reversible path - 1 bit to say if path is reversible.
-* num_path [6:0] In queries, maximum number of paths to return.
-* In responses, undefined.
-*
-* pkey
-* Partition key (P_Key) to use on this path.
-*
-* qos_class_sl
-* QoS class and service level to use on this path.
-*
-* mtu
-* MTU and MTU selector fields to use on this path
-* rate
-* Rate and rate selector fields to use on this path.
-*
-* pkt_life
-* Packet lifetime
-*
-* service_id_8msb
-* 8 most significant bits of Service ID
-*
-* service_id_56lsb
-* 56 least significant bits of Service ID
-*
-* preference
-* Indicates the relative merit of this path versus other path
-* records returned from the SA. Lower numbers are better.
-*
-* SEE ALSO
-*********/
-
-/****f* IBA Base: Types/ib_multipath_rec_num_path
-* NAME
-* ib_multipath_rec_num_path
-*
-* DESCRIPTION
-* Get max number of paths to return.
-*
-* SYNOPSIS
-*/
-static inline uint8_t OSM_API
-ib_multipath_rec_num_path(IN const ib_multipath_rec_t * const p_rec)
-{
- return (p_rec->num_path & 0x7F);
-}
-
-/*
-* PARAMETERS
-* p_rec
-* [in] Pointer to the multipath record object.
-*
-* RETURN VALUES
-* Maximum number of paths to return for each unique SGID_DGID combination.
-*
-* NOTES
-*
-* SEE ALSO
-* ib_multipath_rec_t
-*********/
-
-/****f* IBA Base: Types/ib_multipath_rec_set_sl
-* NAME
-* ib_multipath_rec_set_sl
-*
-* DESCRIPTION
-* Set path service level.
-*
-* SYNOPSIS
-*/
-static inline void OSM_API
-ib_multipath_rec_set_sl(
- IN ib_multipath_rec_t* const p_rec,
- IN const uint8_t sl )
-{
- p_rec->qos_class_sl =
- (p_rec->qos_class_sl & CL_HTON16(IB_MULTIPATH_REC_QOS_CLASS_MASK)) |
- cl_hton16(sl & IB_MULTIPATH_REC_SL_MASK);
-}
-/*
-* PARAMETERS
-* p_rec
-* [in] Pointer to the MultiPath record object.
-*
-* sl
-* [in] Service level to set.
-*
-* RETURN VALUES
-* None
-*
-* NOTES
-*
-* SEE ALSO
-* ib_multipath_rec_t
-*********/
-
-/****f* IBA Base: Types/ib_multipath_rec_sl
-* NAME
-* ib_multipath_rec_sl
-*
-* DESCRIPTION
-* Get multipath service level.
-*
-* SYNOPSIS
-*/
-static inline uint8_t OSM_API
-ib_multipath_rec_sl(IN const ib_multipath_rec_t * const p_rec)
-{
- return ((uint8_t) ((cl_ntoh16(p_rec->qos_class_sl)) & IB_MULTIPATH_REC_SL_MASK));
-}
-
-/*
-* PARAMETERS
-* p_rec
-* [in] Pointer to the multipath record object.
-*
-* RETURN VALUES
-* SL.
-*
-* NOTES
-*
-* SEE ALSO
-* ib_multipath_rec_t
-*********/
-
-/****f* IBA Base: Types/ib_multipath_rec_set_qos_class
-* NAME
-* ib_multipath_rec_set_qos_class
-*
-* DESCRIPTION
-* Set path QoS class.
-*
-* SYNOPSIS
-*/
-static inline void OSM_API
-ib_multipath_rec_set_qos_class(
- IN ib_multipath_rec_t* const p_rec,
- IN const uint16_t qos_class )
-{
- p_rec->qos_class_sl =
- (p_rec->qos_class_sl & CL_HTON16(IB_MULTIPATH_REC_SL_MASK)) |
- cl_hton16(qos_class << 4);
-}
-/*
-* PARAMETERS
-* p_rec
-* [in] Pointer to the MultiPath record object.
-*
-* qos_class
-* [in] QoS class to set.
-*
-* RETURN VALUES
-* None
-*
-* NOTES
-*
-* SEE ALSO
-* ib_multipath_rec_t
-*********/
-
-/****f* IBA Base: Types/ib_multipath_rec_qos_class
-* NAME
-* ib_multipath_rec_qos_class
-*
-* DESCRIPTION
-* Get QoS class.
-*
-* SYNOPSIS
-*/
-static inline uint16_t OSM_API
-ib_multipath_rec_qos_class(
- IN const ib_multipath_rec_t* const p_rec )
-{
- return (cl_ntoh16( p_rec->qos_class_sl ) >> 4);
-}
-/*
-* PARAMETERS
-* p_rec
-* [in] Pointer to the MultiPath record object.
-*
-* RETURN VALUES
-* QoS class of the MultiPath record.
-*
-* NOTES
-*
-* SEE ALSO
-* ib_multipath_rec_t
-*********/
-
-/****f* IBA Base: Types/ib_multipath_rec_mtu
-* NAME
-* ib_multipath_rec_mtu
-*
-* DESCRIPTION
-* Get encoded path MTU.
-*
-* SYNOPSIS
-*/
-static inline uint8_t OSM_API
-ib_multipath_rec_mtu(IN const ib_multipath_rec_t * const p_rec)
-{
- return ((uint8_t) (p_rec->mtu & IB_MULTIPATH_REC_BASE_MASK));
-}
-
-/*
-* PARAMETERS
-* p_rec
-* [in] Pointer to the multipath record object.
-*
-* RETURN VALUES
-* Encoded path MTU.
-* 1: 256
-* 2: 512
-* 3: 1024
-* 4: 2048
-* 5: 4096
-* others: reserved
-*
-* NOTES
-*
-* SEE ALSO
-* ib_multipath_rec_t
-*********/
-
-/****f* IBA Base: Types/ib_multipath_rec_mtu_sel
-* NAME
-* ib_multipath_rec_mtu_sel
-*
-* DESCRIPTION
-* Get encoded multipath MTU selector.
-*
-* SYNOPSIS
-*/
-static inline uint8_t OSM_API
-ib_multipath_rec_mtu_sel(IN const ib_multipath_rec_t * const p_rec)
-{
- return ((uint8_t) ((p_rec->mtu & IB_MULTIPATH_REC_SELECTOR_MASK) >> 6));
-}
-
-/*
-* PARAMETERS
-* p_rec
-* [in] Pointer to the multipath record object.
-*
-* RETURN VALUES
-* Encoded path MTU selector value (for queries).
-* 0: greater than MTU specified
-* 1: less than MTU specified
-* 2: exactly the MTU specified
-* 3: largest MTU available
-*
-* NOTES
-*
-* SEE ALSO
-* ib_multipath_rec_t
-*********/
-
-/****f* IBA Base: Types/ib_multipath_rec_rate
-* NAME
-* ib_multipath_rec_rate
-*
-* DESCRIPTION
-* Get encoded multipath rate.
-*
-* SYNOPSIS
-*/
-static inline uint8_t OSM_API
-ib_multipath_rec_rate(IN const ib_multipath_rec_t * const p_rec)
-{
- return ((uint8_t) (p_rec->rate & IB_MULTIPATH_REC_BASE_MASK));
-}
-
-/*
-* PARAMETERS
-* p_rec
-* [in] Pointer to the multipath record object.
-*
-* RETURN VALUES
-* Encoded multipath rate.
-* 2: 2.5 Gb/sec.
-* 3: 10 Gb/sec.
-* 4: 30 Gb/sec.
-* others: reserved
-*
-* NOTES
-*
-* SEE ALSO
-* ib_multipath_rec_t
-*********/
-
-/****f* IBA Base: Types/ib_multipath_rec_rate_sel
-* NAME
-* ib_multipath_rec_rate_sel
-*
-* DESCRIPTION
-* Get encoded multipath rate selector.
-*
-* SYNOPSIS
-*/
-static inline uint8_t OSM_API
-ib_multipath_rec_rate_sel(IN const ib_multipath_rec_t * const p_rec)
-{
- return ((uint8_t)
- ((p_rec->rate & IB_MULTIPATH_REC_SELECTOR_MASK) >> 6));
-}
-
-/*
-* PARAMETERS
-* p_rec
-* [in] Pointer to the multipath record object.
-*
-* RETURN VALUES
-* Encoded path rate selector value (for queries).
-* 0: greater than rate specified
-* 1: less than rate specified
-* 2: exactly the rate specified
-* 3: largest rate available
-*
-* NOTES
-*
-* SEE ALSO
-* ib_multipath_rec_t
-*********/
-
-/****f* IBA Base: Types/ib_multipath_rec_pkt_life
-* NAME
-* ib_multipath_rec_pkt_life
-*
-* DESCRIPTION
-* Get encoded multipath pkt_life.
-*
-* SYNOPSIS
-*/
-static inline uint8_t OSM_API
-ib_multipath_rec_pkt_life(IN const ib_multipath_rec_t * const p_rec)
-{
- return ((uint8_t) (p_rec->pkt_life & IB_MULTIPATH_REC_BASE_MASK));
-}
-
-/*
-* PARAMETERS
-* p_rec
-* [in] Pointer to the multipath record object.
-*
-* RETURN VALUES
-* Encoded multipath pkt_life = 4.096 usec * 2 ** PacketLifeTime.
-*
-* NOTES
-*
-* SEE ALSO
-* ib_multipath_rec_t
-*********/
-
-/****f* IBA Base: Types/ib_multipath_rec_pkt_life_sel
-* NAME
-* ib_multipath_rec_pkt_life_sel
-*
-* DESCRIPTION
-* Get encoded multipath pkt_lifetime selector.
-*
-* SYNOPSIS
-*/
-static inline uint8_t OSM_API
-ib_multipath_rec_pkt_life_sel(IN const ib_multipath_rec_t * const p_rec)
-{
- return ((uint8_t)
- ((p_rec->pkt_life & IB_MULTIPATH_REC_SELECTOR_MASK) >> 6));
-}
-
-/*
-* PARAMETERS
-* p_rec
-* [in] Pointer to the multipath record object.
-*
-* RETURN VALUES
-* Encoded path pkt_lifetime selector value (for queries).
-* 0: greater than rate specified
-* 1: less than rate specified
-* 2: exactly the rate specified
-* 3: smallest packet lifetime available
-*
-* NOTES
-*
-* SEE ALSO
-* ib_multipath_rec_t
-*********/
-
-/****f* IBA Base: Types/ib_multipath_rec_service_id
-* NAME
-* ib_multipath_rec_service_id
-*
-* DESCRIPTION
-* Get multipath service id.
-*
-* SYNOPSIS
-*/
-static inline ib_net64_t OSM_API
-ib_multipath_rec_service_id(IN const ib_multipath_rec_t * const p_rec)
-{
- union {
- ib_net64_t sid;
- uint8_t sid_arr[8];
- } sid_union;
- sid_union.sid_arr[0] = p_rec->service_id_8msb;
- memcpy(&sid_union.sid_arr[1], p_rec->service_id_56lsb, 7);
- return sid_union.sid;
-}
-
-/*
-* PARAMETERS
-* p_rec
-* [in] Pointer to the multipath record object.
-*
-* RETURN VALUES
-* Service ID
-*
-* NOTES
-*
-* SEE ALSO
-* ib_multipath_rec_t
-*********/
-
-#define IB_NUM_PKEY_ELEMENTS_IN_BLOCK 32
-/****s* IBA Base: Types/ib_pkey_table_t
-* NAME
-* ib_pkey_table_t
-*
-* DESCRIPTION
-* IBA defined PKey table. (14.2.5.7)
-*
-* SYNOPSIS
-*/
-
-#include <complib/cl_packon.h>
-typedef struct _ib_pkey_table {
- ib_net16_t pkey_entry[IB_NUM_PKEY_ELEMENTS_IN_BLOCK];
-
-} PACK_SUFFIX ib_pkey_table_t;
-#include <complib/cl_packoff.h>
-/************/
-
-/****s* IBA Base: Types/ib_pkey_table_record_t
-* NAME
-* ib_pkey_table_record_t
-*
-* DESCRIPTION
-* IBA defined P_Key Table Record for SA Query. (15.2.5.11)
-*
-* SYNOPSIS
-*/
-#include <complib/cl_packon.h>
-typedef struct _ib_pkey_table_record {
- ib_net16_t lid; // for CA: lid of port, for switch lid of port 0
- uint16_t block_num;
- uint8_t port_num; // for switch: port number, for CA: reserved
- uint8_t reserved1;
- uint16_t reserved2;
- ib_pkey_table_t pkey_tbl;
-
-} PACK_SUFFIX ib_pkey_table_record_t;
-#include <complib/cl_packoff.h>
-/************/
-
-#define IB_DROP_VL 15
-#define IB_MAX_NUM_VLS 16
-/****s* IBA Base: Types/ib_slvl_table_t
-* NAME
-* ib_slvl_table_t
-*
-* DESCRIPTION
-* IBA defined SL2VL Mapping Table Attribute. (14.2.5.8)
-*
-* SYNOPSIS
-*/
-#include <complib/cl_packon.h>
-typedef struct _ib_slvl_table {
- uint8_t raw_vl_by_sl[IB_MAX_NUM_VLS / 2];
-} PACK_SUFFIX ib_slvl_table_t;
-#include <complib/cl_packoff.h>
-/************/
-
-/****s* IBA Base: Types/ib_slvl_table_record_t
-* NAME
-* ib_slvl_table_record_t
-*
-* DESCRIPTION
-* IBA defined SL to VL Mapping Table Record for SA Query. (15.2.5.4)
-*
-* SYNOPSIS
-*/
-#include <complib/cl_packon.h>
-typedef struct _ib_slvl_table_record {
- ib_net16_t lid; // for CA: lid of port, for switch lid of port 0
- uint8_t in_port_num; // reserved for CAs
- uint8_t out_port_num; // reserved for CAs
- uint32_t resv;
- ib_slvl_table_t slvl_tbl;
-
-} PACK_SUFFIX ib_slvl_table_record_t;
-#include <complib/cl_packoff.h>
-/************/
-
-/****f* IBA Base: Types/ib_slvl_table_set
-* NAME
-* ib_slvl_table_set
-*
-* DESCRIPTION
-* Set slvl table entry.
-*
-* SYNOPSIS
-*/
-static inline void OSM_API
-ib_slvl_table_set(IN ib_slvl_table_t * p_slvl_tbl,
- IN uint8_t sl_index, IN uint8_t vl)
-{
- uint8_t idx = sl_index / 2;
- CL_ASSERT(vl <= 15);
- CL_ASSERT(sl_index <= 15);
-
- if (sl_index % 2) {
- /* this is an odd sl. Need to update the ls bits */
- p_slvl_tbl->raw_vl_by_sl[idx] =
- (p_slvl_tbl->raw_vl_by_sl[idx] & 0xF0) | vl;
- } else {
- /* this is an even sl. Need to update the ms bits */
- p_slvl_tbl->raw_vl_by_sl[idx] =
- (vl << 4) | (p_slvl_tbl->raw_vl_by_sl[idx] & 0x0F);
- }
-}
-
-/*
-* PARAMETERS
-* p_slvl_tbl
-* [in] pointer to ib_slvl_table_t object.
-*
-* sl_index
-* [in] the sl index in the table to be updated.
-*
-* vl
-* [in] the vl value to update for that sl.
-*
-* RETURN VALUES
-* None
-*
-* NOTES
-*
-* SEE ALSO
-* ib_slvl_table_t
-*********/
-
-/****f* IBA Base: Types/ib_slvl_table_get
-* NAME
-* ib_slvl_table_get
-*
-* DESCRIPTION
-* Get slvl table entry.
-*
-* SYNOPSIS
-*/
-static inline uint8_t OSM_API
-ib_slvl_table_get(IN const ib_slvl_table_t * p_slvl_tbl, IN uint8_t sl_index)
-{
- uint8_t idx = sl_index / 2;
- CL_ASSERT(sl_index <= 15);
-
- if (sl_index % 2) {
- /* this is an odd sl. Need to return the ls bits. */
- return (p_slvl_tbl->raw_vl_by_sl[idx] & 0x0F);
- } else {
- /* this is an even sl. Need to return the ms bits. */
- return ((p_slvl_tbl->raw_vl_by_sl[idx] & 0xF0) >> 4);
- }
-}
-
-/*
-* PARAMETERS
-* p_slvl_tbl
-* [in] pointer to ib_slvl_table_t object.
-*
-* sl_index
-* [in] the sl index in the table whose value should be returned.
-*
-* RETURN VALUES
-* vl for the requested sl_index.
-*
-* NOTES
-*
-* SEE ALSO
-* ib_slvl_table_t
-*********/
-
-/****s* IBA Base: Types/ib_vl_arb_element_t
-* NAME
-* ib_vl_arb_element_t
-*
-* DESCRIPTION
-* IBA defined VL Arbitration Table Element. (14.2.5.9)
-*
-* SYNOPSIS
-*/
-#include <complib/cl_packon.h>
-typedef struct _ib_vl_arb_element {
- uint8_t vl;
- uint8_t weight;
-} PACK_SUFFIX ib_vl_arb_element_t;
-#include <complib/cl_packoff.h>
-/************/
-
-#define IB_NUM_VL_ARB_ELEMENTS_IN_BLOCK 32
-
-/****s* IBA Base: Types/ib_vl_arb_table_t
-* NAME
-* ib_vl_arb_table_t
-*
-* DESCRIPTION
-* IBA defined VL Arbitration Table. (14.2.5.9)
-*
-* SYNOPSIS
-*/
-#include <complib/cl_packon.h>
-typedef struct _ib_vl_arb_table {
- ib_vl_arb_element_t vl_entry[IB_NUM_VL_ARB_ELEMENTS_IN_BLOCK];
-} PACK_SUFFIX ib_vl_arb_table_t;
-#include <complib/cl_packoff.h>
-/************/
-
-/****s* IBA Base: Types/ib_vl_arb_table_record_t
-* NAME
-* ib_vl_arb_table_record_t
-*
-* DESCRIPTION
-* IBA defined VL Arbitration Table Record for SA Query. (15.2.5.9)
-*
-* SYNOPSIS
-*/
-#include <complib/cl_packon.h>
-typedef struct _ib_vl_arb_table_record {
- ib_net16_t lid; // for CA: lid of port, for switch lid of port 0
- uint8_t port_num;
- uint8_t block_num;
- uint32_t reserved;
- ib_vl_arb_table_t vl_arb_tbl;
-} PACK_SUFFIX ib_vl_arb_table_record_t;
-#include <complib/cl_packoff.h>
-/************/
-
-/*
- * Global route header information received with unreliable datagram messages
- */
-#include <complib/cl_packon.h>
-typedef struct _ib_grh {
- ib_net32_t ver_class_flow;
- ib_net16_t resv1;
- uint8_t resv2;
- uint8_t hop_limit;
- ib_gid_t src_gid;
- ib_gid_t dest_gid;
-} PACK_SUFFIX ib_grh_t;
-#include <complib/cl_packoff.h>
-
-/****f* IBA Base: Types/ib_grh_get_ver_class_flow
-* NAME
-* ib_grh_get_ver_class_flow
-*
-* DESCRIPTION
-* Get encoded version, traffic class and flow label in grh
-*
-* SYNOPSIS
-*/
-static inline void OSM_API
-ib_grh_get_ver_class_flow(IN const ib_net32_t ver_class_flow,
- OUT uint8_t * const p_ver,
- OUT uint8_t * const p_tclass,
- OUT uint32_t * const p_flow_lbl)
-{
- ib_net32_t tmp_ver_class_flow;
-
- if (p_ver)
- *p_ver = (uint8_t) (ver_class_flow & 0x0f);
-
- tmp_ver_class_flow = ver_class_flow >> 4;
-
- if (p_tclass)
- *p_tclass = (uint8_t) (tmp_ver_class_flow & 0xff);
-
- tmp_ver_class_flow = tmp_ver_class_flow >> 8;
-
- if (p_flow_lbl)
- *p_flow_lbl = tmp_ver_class_flow & 0xfffff;
-}
-
-/*
-* PARAMETERS
-* ver_class_flow
-* [in] the version, traffic class and flow label info.
-*
-* RETURN VALUES
-* p_ver
-* [out] pointer to the version info.
-*
-* p_tclass
-* [out] pointer to the traffic class info.
-*
-* p_flow_lbl
-* [out] pointer to the flow label info
-*
-* NOTES
-*
-* SEE ALSO
-* ib_grh_t
-*********/
-
-/****f* IBA Base: Types/ib_grh_set_ver_class_flow
-* NAME
-* ib_grh_set_ver_class_flow
-*
-* DESCRIPTION
-* Set encoded version, traffic class and flow label in grh
-*
-* SYNOPSIS
-*/
-static inline ib_net32_t OSM_API
-ib_grh_set_ver_class_flow(IN const uint8_t ver,
- IN const uint8_t tclass, IN const uint32_t flow_lbl)
-{
- ib_net32_t ver_class_flow;
-
- ver_class_flow = flow_lbl;
- ver_class_flow = ver_class_flow << 8;
- ver_class_flow = ver_class_flow | tclass;
- ver_class_flow = ver_class_flow << 4;
- ver_class_flow = ver_class_flow | ver;
- return (ver_class_flow);
-}
-
-/*
-* PARAMETERS
-* ver
-* [in] the version info.
-*
-* tclass
-* [in] the traffic class info.
-*
-* flow_lbl
-* [in] the flow label info
-*
-* RETURN VALUES
-* ver_class_flow
-* [out] the version, traffic class and flow label info.
-*
-* NOTES
-*
-* SEE ALSO
-* ib_grh_t
-*********/
-
-/****s* IBA Base: Types/ib_member_rec_t
-* NAME
-* ib_member_rec_t
-*
-* DESCRIPTION
-* Multicast member record, used to create, join, and leave multicast
-* groups.
-*
-* SYNOPSIS
-*/
-#include <complib/cl_packon.h>
-typedef struct _ib_member_rec {
- ib_gid_t mgid;
- ib_gid_t port_gid;
- ib_net32_t qkey;
- ib_net16_t mlid;
- uint8_t mtu;
- uint8_t tclass;
- ib_net16_t pkey;
- uint8_t rate;
- uint8_t pkt_life;
- ib_net32_t sl_flow_hop;
- uint8_t scope_state;
- uint8_t proxy_join:1;
- uint8_t reserved[2];
- uint8_t pad[4];
-
-} PACK_SUFFIX ib_member_rec_t;
-#include <complib/cl_packoff.h>
-/*
-* FIELDS
-* mgid
-* Multicast GID address for this multicast group.
-*
-* port_gid
-* Valid GID of the endpoint joining this multicast group.
-*
-* qkey
-* Q_Key to be sued by this multicast group.
-*
-* mlid
-* Multicast LID for this multicast group.
-*
-* mtu
-* MTU and MTU selector fields to use on this path
-*
-* tclass
-* Another global routing parameter.
-*
-* pkey
-* Partition key (P_Key) to use for this member.
-*
-* rate
-* Rate and rate selector fields to use on this path.
-*
-* pkt_life
-* Packet lifetime
-*
-* sl_flow_hop
-* Global routing parameters: service level, hop count, and flow label.
-*
-* scope_state
-* MGID scope and JoinState of multicast request.
-*
-* proxy_join
-* Enables others in the Partition to proxy add/remove from the group
-*
-* SEE ALSO
-*********/
-
-/****f* IBA Base: Types/ib_member_get_sl_flow_hop
-* NAME
-* ib_member_get_sl_flow_hop
-*
-* DESCRIPTION
-* Get encoded sl, flow label, and hop limit
-*
-* SYNOPSIS
-*/
-static inline void OSM_API
-ib_member_get_sl_flow_hop(IN const ib_net32_t sl_flow_hop,
- OUT uint8_t * const p_sl,
- OUT uint32_t * const p_flow_lbl,
- OUT uint8_t * const p_hop)
-{
- uint32_t tmp;
-
- tmp = cl_ntoh32(sl_flow_hop);
- if (p_hop)
- *p_hop = (uint8_t) tmp;
- tmp >>= 8;
-
- if (p_flow_lbl)
- *p_flow_lbl = (uint32_t) (tmp & 0xfffff);
- tmp >>= 20;
-
- if (p_sl)
- *p_sl = (uint8_t) tmp;
-}
-
-/*
-* PARAMETERS
-* sl_flow_hop
-* [in] the sl, flow label, and hop limit of MC Group
-*
-* RETURN VALUES
-* p_sl
-* [out] pointer to the service level
-*
-* p_flow_lbl
-* [out] pointer to the flow label info
-*
-* p_hop
-* [out] pointer to the hop count limit.
-*
-* NOTES
-*
-* SEE ALSO
-* ib_member_rec_t
-*********/
-
-/****f* IBA Base: Types/ib_member_set_sl_flow_hop
-* NAME
-* ib_member_set_sl_flow_hop
-*
-* DESCRIPTION
-* Set encoded sl, flow label, and hop limit
-*
-* SYNOPSIS
-*/
-static inline ib_net32_t OSM_API
-ib_member_set_sl_flow_hop(IN const uint8_t sl,
- IN const uint32_t flow_label,
- IN const uint8_t hop_limit)
-{
- uint32_t tmp;
-
- tmp = (sl << 28) | ((flow_label & 0xfffff) << 8) | hop_limit;
- return cl_hton32(tmp);
-}
-
-/*
-* PARAMETERS
-* sl
-* [in] the service level.
-*
-* flow_lbl
-* [in] the flow label info
-*
-* hop_limit
-* [in] the hop limit.
-*
-* RETURN VALUES
-* sl_flow_hop
-* [out] the encoded sl, flow label, and hop limit
-*
-* NOTES
-*
-* SEE ALSO
-* ib_member_rec_t
-*********/
-
-/****f* IBA Base: Types/ib_member_get_scope_state
-* NAME
-* ib_member_get_scope_state
-*
-* DESCRIPTION
-* Get encoded MGID scope and JoinState
-*
-* SYNOPSIS
-*/
-static inline void OSM_API
-ib_member_get_scope_state(IN const uint8_t scope_state,
- OUT uint8_t * const p_scope,
- OUT uint8_t * const p_state)
-{
- uint8_t tmp_scope_state;
-
- if (p_state)
- *p_state = (uint8_t) (scope_state & 0x0f);
-
- tmp_scope_state = scope_state >> 4;
-
- if (p_scope)
- *p_scope = (uint8_t) (tmp_scope_state & 0x0f);
-
-}
-
-/*
-* PARAMETERS
-* scope_state
-* [in] the scope and state
-*
-* RETURN VALUES
-* p_scope
-* [out] pointer to the MGID scope
-*
-* p_state
-* [out] pointer to the join state
-*
-* NOTES
-*
-* SEE ALSO
-* ib_member_rec_t
-*********/
-
-/****f* IBA Base: Types/ib_member_set_scope_state
-* NAME
-* ib_member_set_scope_state
-*
-* DESCRIPTION
-* Set encoded version, MGID scope and JoinState
-*
-* SYNOPSIS
-*/
-static inline uint8_t OSM_API
-ib_member_set_scope_state(IN const uint8_t scope, IN const uint8_t state)
-{
- uint8_t scope_state;
-
- scope_state = scope;
- scope_state = scope_state << 4;
- scope_state = scope_state | state;
- return (scope_state);
-}
-
-/*
-* PARAMETERS
-* scope
-* [in] the MGID scope
-*
-* state
-* [in] the JoinState
-*
-* RETURN VALUES
-* scope_state
-* [out] the encoded one
-*
-* NOTES
-*
-* SEE ALSO
-* ib_member_rec_t
-*********/
-
-/****f* IBA Base: Types/ib_member_set_join_state
-* NAME
-* ib_member_set_join_state
-*
-* DESCRIPTION
-* Set JoinState
-*
-* SYNOPSIS
-*/
-static inline void OSM_API
-ib_member_set_join_state(IN OUT ib_member_rec_t * p_mc_rec,
- IN const uint8_t state)
-{
- /* keep the scope as it is */
- p_mc_rec->scope_state = (p_mc_rec->scope_state & 0xF0) | (0x0f & state);
-}
-
-/*
-* PARAMETERS
-* p_mc_rec
-* [in] pointer to the member record
-*
-* state
-* [in] the JoinState
-*
-* RETURN VALUES
-* NONE
-*
-* NOTES
-*
-* SEE ALSO
-* ib_member_rec_t
-*********/
-
-/*
- * Join State Codes:
- */
-#define IB_MC_REC_STATE_FULL_MEMBER 0x01
-#define IB_MC_REC_STATE_NON_MEMBER 0x02
-#define IB_MC_REC_STATE_SEND_ONLY_NON_MEMBER 0x04
-
-/*
- * Generic MAD notice types
- */
-#define IB_NOTICE_TYPE_FATAL 0x00
-#define IB_NOTICE_TYPE_URGENT 0x01
-#define IB_NOTICE_TYPE_SECURITY 0x02
-#define IB_NOTICE_TYPE_SUBN_MGMT 0x03
-#define IB_NOTICE_TYPE_INFO 0x04
-#define IB_NOTICE_TYPE_EMPTY 0x7F
-
-#include <complib/cl_packon.h>
-typedef struct _ib_mad_notice_attr // Total Size calc Accumulated
-{
- uint8_t generic_type; // 1 1
-
- union _notice_g_or_v {
- struct _notice_generic // 5 6
- {
- uint8_t prod_type_msb;
- ib_net16_t prod_type_lsb;
- ib_net16_t trap_num;
- } PACK_SUFFIX generic;
-
- struct _notice_vend {
- uint8_t vend_id_msb;
- ib_net16_t vend_id_lsb;
- ib_net16_t dev_id;
- } PACK_SUFFIX vend;
- } g_or_v;
-
- ib_net16_t issuer_lid; // 2 8
- ib_net16_t toggle_count; // 2 10
-
- union _data_details // 54 64
- {
- struct _raw_data {
- uint8_t details[54];
- } PACK_SUFFIX raw_data;
-
- struct _ntc_64_67 {
- uint8_t res[6];
- ib_gid_t gid; // the Node or Multicast Group that came in/out
- } PACK_SUFFIX ntc_64_67;
-
- struct _ntc_128 {
- ib_net16_t sw_lid; // the sw lid of which link state changed
- } PACK_SUFFIX ntc_128;
-
- struct _ntc_129_131 {
- ib_net16_t pad;
- ib_net16_t lid; // lid and port number of the violation
- uint8_t port_num;
- } PACK_SUFFIX ntc_129_131;
-
- struct _ntc_144 {
- ib_net16_t pad1;
- ib_net16_t lid; // lid where change occured
- uint8_t pad2; // reserved
- uint8_t local_changes; // 7b reserved 1b local changes
- ib_net32_t new_cap_mask; // new capability mask
- ib_net16_t change_flgs; // 13b reserved 3b change flags
- } PACK_SUFFIX ntc_144;
-
- struct _ntc_145 {
- ib_net16_t pad1;
- ib_net16_t lid; // lid where sys guid changed
- ib_net16_t pad2;
- ib_net64_t new_sys_guid; // new system image guid
- } PACK_SUFFIX ntc_145;
-
- struct _ntc_256 { // total: 54
- ib_net16_t pad1; // 2
- ib_net16_t lid; // 2
- ib_net16_t dr_slid; // 2
- uint8_t method; // 1
- uint8_t pad2; // 1
- ib_net16_t attr_id; // 2
- ib_net32_t attr_mod; // 4
- ib_net64_t mkey; // 8
- uint8_t pad3; // 1
- uint8_t dr_trunc_hop; // 1
- uint8_t dr_rtn_path[30]; // 30
- } PACK_SUFFIX ntc_256;
-
- struct _ntc_257_258 // violation of p/q_key // 49
- {
- ib_net16_t pad1; // 2
- ib_net16_t lid1; // 2
- ib_net16_t lid2; // 2
- ib_net32_t key; // 2
- uint8_t sl; // 1
- ib_net32_t qp1; // 4
- ib_net32_t qp2; // 4
- ib_gid_t gid1; // 16
- ib_gid_t gid2; // 16
- } PACK_SUFFIX ntc_257_258;
-
- struct _ntc_259 // pkey violation from switch 51
- {
- ib_net16_t data_valid; // 2
- ib_net16_t lid1; // 2
- ib_net16_t lid2; // 2
- ib_net16_t pkey; // 2
- ib_net32_t sl_qp1; // 4b sl, 4b pad, 24b qp1
- ib_net32_t qp2; // 8b pad, 24b qp2
- ib_gid_t gid1; // 16
- ib_gid_t gid2; // 16
- ib_net16_t sw_lid; // 2
- uint8_t port_no; // 1
- } PACK_SUFFIX ntc_259;
-
- } data_details;
-
- ib_gid_t issuer_gid; // 16 80
-
-} PACK_SUFFIX ib_mad_notice_attr_t;
-#include <complib/cl_packoff.h>
-
-/**
- * Trap 259 masks
- */
-#define TRAP_259_MASK_SL (CL_HTON32(0xF0000000))
-#define TRAP_259_MASK_QP (CL_HTON32(0x00FFFFFF))
-
-/**
- * Trap 144 masks
- */
-#define TRAP_144_MASK_OTHER_LOCAL_CHANGES 0x01
-#define TRAP_144_MASK_SM_PRIORITY_CHANGE (CL_HTON16(0x0008))
-#define TRAP_144_MASK_LINK_SPEED_ENABLE_CHANGE (CL_HTON16(0x0004))
-#define TRAP_144_MASK_LINK_WIDTH_ENABLE_CHANGE (CL_HTON16(0x0002))
-#define TRAP_144_MASK_NODE_DESCRIPTION_CHANGE (CL_HTON16(0x0001))
-
-/****f* IBA Base: Types/ib_notice_is_generic
-* NAME
-* ib_notice_is_generic
-*
-* DESCRIPTION
-* Check if the notice is generic
-*
-* SYNOPSIS
-*/
-static inline boolean_t OSM_API
-ib_notice_is_generic(IN const ib_mad_notice_attr_t * p_ntc)
-{
- return (p_ntc->generic_type & 0x80);
-}
-
-/*
-* PARAMETERS
-* p_ntc
-* [in] Pointer to the notice MAD attribute
-*
-* RETURN VALUES
-* TRUE if mad is generic
-*
-* SEE ALSO
-* ib_mad_notice_attr_t
-*********/
-
-/****f* IBA Base: Types/ib_notice_get_type
-* NAME
-* ib_notice_get_type
-*
-* DESCRIPTION
-* Get the notice type
-*
-* SYNOPSIS
-*/
-static inline uint8_t OSM_API
-ib_notice_get_type(IN const ib_mad_notice_attr_t * p_ntc)
-{
- return p_ntc->generic_type & 0x7f;
-}
-
-/*
-* PARAMETERS
-* p_ntc
-* [in] Pointer to the notice MAD attribute
-*
-* RETURN VALUES
-* TRUE if mad is generic
-*
-* SEE ALSO
-* ib_mad_notice_attr_t
-*********/
-
-/****f* IBA Base: Types/ib_notice_get_prod_type
-* NAME
-* ib_notice_get_prod_type
-*
-* DESCRIPTION
-* Get the notice Producer Type of Generic Notice
-*
-* SYNOPSIS
-*/
-static inline ib_net32_t OSM_API
-ib_notice_get_prod_type(IN const ib_mad_notice_attr_t * p_ntc)
-{
- uint32_t pt;
-
- pt = cl_ntoh16(p_ntc->g_or_v.generic.prod_type_lsb) |
- (p_ntc->g_or_v.generic.prod_type_msb << 16);
- return cl_hton32(pt);
-}
-
-/*
-* PARAMETERS
-* p_ntc
-* [in] Pointer to the notice MAD attribute
-*
-* RETURN VALUES
-* The producer type
-*
-* SEE ALSO
-* ib_mad_notice_attr_t
-*********/
-
-/****f* IBA Base: Types/ib_notice_set_prod_type
-* NAME
-* ib_notice_set_prod_type
-*
-* DESCRIPTION
-* Set the notice Producer Type of Generic Notice
-*
-* SYNOPSIS
-*/
-static inline void OSM_API
-ib_notice_set_prod_type(IN ib_mad_notice_attr_t * p_ntc,
- IN ib_net32_t prod_type_val)
-{
- uint32_t ptv = cl_ntoh32(prod_type_val);
- p_ntc->g_or_v.generic.prod_type_lsb =
- cl_hton16((uint16_t) (ptv & 0x0000ffff));
- p_ntc->g_or_v.generic.prod_type_msb =
- (uint8_t) ((ptv & 0x00ff0000) >> 16);
-}
-
-/*
-* PARAMETERS
-* p_ntc
-* [in] Pointer to the notice MAD attribute
-*
-* prod_type
-* [in] The producer Type code
-*
-* RETURN VALUES
-* None
-*
-* SEE ALSO
-* ib_mad_notice_attr_t
-*********/
-
-/****f* IBA Base: Types/ib_notice_set_prod_type_ho
-* NAME
-* ib_notice_set_prod_type_ho
-*
-* DESCRIPTION
-* Set the notice Producer Type of Generic Notice given Host Order
-*
-* SYNOPSIS
-*/
-static inline void OSM_API
-ib_notice_set_prod_type_ho(IN ib_mad_notice_attr_t * p_ntc,
- IN uint32_t prod_type_val_ho)
-{
- p_ntc->g_or_v.generic.prod_type_lsb =
- cl_hton16((uint16_t) (prod_type_val_ho & 0x0000ffff));
- p_ntc->g_or_v.generic.prod_type_msb =
- (uint8_t) ((prod_type_val_ho & 0x00ff0000) >> 16);
-}
-
-/*
-* PARAMETERS
-* p_ntc
-* [in] Pointer to the notice MAD attribute
-*
-* prod_type
-* [in] The producer Type code in host order
-*
-* RETURN VALUES
-* None
-*
-* SEE ALSO
-* ib_mad_notice_attr_t
-*********/
-
-/****f* IBA Base: Types/ib_notice_get_vend_id
-* NAME
-* ib_notice_get_vend_id
-*
-* DESCRIPTION
-* Get the Vendor Id of Vendor type Notice
-*
-* SYNOPSIS
-*/
-static inline ib_net32_t OSM_API
-ib_notice_get_vend_id(IN const ib_mad_notice_attr_t * p_ntc)
-{
- uint32_t vi;
-
- vi = cl_ntoh16(p_ntc->g_or_v.vend.vend_id_lsb) |
- (p_ntc->g_or_v.vend.vend_id_msb << 16);
- return cl_hton32(vi);
-}
-
-/*
-* PARAMETERS
-* p_ntc
-* [in] Pointer to the notice MAD attribute
-*
-* RETURN VALUES
-* The Vendor Id of Vendor type Notice
-*
-* SEE ALSO
-* ib_mad_notice_attr_t
-*********/
-
-/****f* IBA Base: Types/ib_notice_set_vend_id
-* NAME
-* ib_notice_set_vend_id
-*
-* DESCRIPTION
-* Set the notice Producer Type of Generic Notice
-*
-* SYNOPSIS
-*/
-static inline void OSM_API
-ib_notice_set_vend_id(IN ib_mad_notice_attr_t * p_ntc, IN ib_net32_t vend_id)
-{
- uint32_t vi = cl_ntoh32(vend_id);
- p_ntc->g_or_v.vend.vend_id_lsb =
- cl_hton16((uint16_t) (vi & 0x0000ffff));
- p_ntc->g_or_v.vend.vend_id_msb = (uint8_t) ((vi & 0x00ff0000) >> 16);
-}
-
-/*
-* PARAMETERS
-* p_ntc
-* [in] Pointer to the notice MAD attribute
-*
-* vend_id
-* [in] The producer Type code
-*
-* RETURN VALUES
-* None
-*
-* SEE ALSO
-* ib_mad_notice_attr_t
-*********/
-
-/****f* IBA Base: Types/ib_notice_set_vend_id_ho
-* NAME
-* ib_notice_set_vend_id_ho
-*
-* DESCRIPTION
-* Set the notice Producer Type of Generic Notice given a host order value
-*
-* SYNOPSIS
-*/
-static inline void OSM_API
-ib_notice_set_vend_id_ho(IN ib_mad_notice_attr_t * p_ntc,
- IN uint32_t vend_id_ho)
-{
- p_ntc->g_or_v.vend.vend_id_lsb =
- cl_hton16((uint16_t) (vend_id_ho & 0x0000ffff));
- p_ntc->g_or_v.vend.vend_id_msb =
- (uint8_t) ((vend_id_ho & 0x00ff0000) >> 16);
-}
-
-/*
-* PARAMETERS
-* p_ntc
-* [in] Pointer to the notice MAD attribute
-*
-* vend_id_ho
-* [in] The producer Type code in host order
-*
-* RETURN VALUES
-* None
-*
-* SEE ALSO
-* ib_mad_notice_attr_t
-*********/
-
-#include <complib/cl_packon.h>
-typedef struct _ib_inform_info {
- ib_gid_t gid;
- ib_net16_t lid_range_begin;
- ib_net16_t lid_range_end;
- ib_net16_t reserved1;
- uint8_t is_generic;
- uint8_t subscribe;
- ib_net16_t trap_type;
- union _inform_g_or_v {
- struct _inform_generic {
- ib_net16_t trap_num;
- ib_net32_t qpn_resp_time_val;
- uint8_t reserved2;
- uint8_t node_type_msb;
- ib_net16_t node_type_lsb;
- } PACK_SUFFIX generic;
-
- struct _inform_vend {
- ib_net16_t dev_id;
- ib_net32_t qpn_resp_time_val;
- uint8_t reserved2;
- uint8_t vendor_id_msb;
- ib_net16_t vendor_id_lsb;
- } PACK_SUFFIX vend;
-
- } PACK_SUFFIX g_or_v;
-
-} PACK_SUFFIX ib_inform_info_t;
-#include <complib/cl_packoff.h>
-
-/****f* IBA Base: Types/ib_inform_info_get_qpn_resp_time
-* NAME
-* ib_inform_info_get_qpn_resp_time
-*
-* DESCRIPTION
-* Get QPN of the inform info
-*
-* SYNOPSIS
-*/
-static inline void OSM_API
-ib_inform_info_get_qpn_resp_time(IN const ib_net32_t qpn_resp_time_val,
- OUT ib_net32_t * const p_qpn,
- OUT uint8_t * const p_resp_time_val)
-{
- uint32_t tmp = cl_ntoh32(qpn_resp_time_val);
-
- if (p_qpn)
- *p_qpn = cl_hton32((tmp & 0xffffff00) >> 8);
-
- if (p_resp_time_val)
- *p_resp_time_val = (uint8_t) (tmp & 0x0000001f);
-}
-
-/*
-* PARAMETERS
-* qpn_resp_time_val
-* [in] the qpn and resp time val from the mad
-*
-* RETURN VALUES
-* p_qpn
-* [out] pointer to the qpn
-*
-* p_state
-* [out] pointer to the resp time val
-*
-* NOTES
-*
-* SEE ALSO
-* ib_inform_info_t
-*********/
-
-/****f* IBA Base: Types/ib_inform_info_set_qpn
-* NAME
-* ib_inform_info_set_qpn
-*
-* DESCRIPTION
-* Set the QPN of the inform info
-*
-* SYNOPSIS
-*/
-static inline void OSM_API
-ib_inform_info_set_qpn(IN ib_inform_info_t * p_ii, IN ib_net32_t const qpn)
-{
- uint32_t tmp = cl_ntoh32(p_ii->g_or_v.generic.qpn_resp_time_val);
-
- p_ii->g_or_v.generic.qpn_resp_time_val =
- cl_hton32((tmp & 0x000000ff) | ((cl_ntoh32(qpn) << 8) & 0xffffff00)
- );
-}
-
-/*
-* PARAMETERS
-*
-* NOTES
-*
-* SEE ALSO
-* ib_inform_info_t
-*********/
-
-/****f* IBA Base: Types/ib_inform_info_get_prod_type
-* NAME
-* ib_inform_info_get_prod_type
-*
-* DESCRIPTION
-* Get Producer Type of the Inform Info
-* 13.4.8.3 InformInfo
-*
-* SYNOPSIS
-*/
-static inline ib_net32_t OSM_API
-ib_inform_info_get_prod_type(IN const ib_inform_info_t * p_inf)
-{
- uint32_t nt;
-
- nt = cl_ntoh16(p_inf->g_or_v.generic.node_type_lsb) |
- (p_inf->g_or_v.generic.node_type_msb << 16);
- return cl_hton32(nt);
-}
-
-/*
-* PARAMETERS
-* p_inf
-* [in] pointer to an inform info
-*
-* RETURN VALUES
-* The producer type
-*
-* NOTES
-*
-* SEE ALSO
-* ib_inform_info_t
-*********/
-
-/****f* IBA Base: Types/ib_inform_info_get_vend_id
-* NAME
-* ib_inform_info_get_vend_id
-*
-* DESCRIPTION
-* Get Node Type of the Inform Info
-*
-* SYNOPSIS
-*/
-static inline ib_net32_t OSM_API
-ib_inform_info_get_vend_id(IN const ib_inform_info_t * p_inf)
-{
- uint32_t vi;
-
- vi = cl_ntoh16(p_inf->g_or_v.vend.vendor_id_lsb) |
- (p_inf->g_or_v.vend.vendor_id_msb << 16);
- return cl_hton32(vi);
-}
-
-/*
-* PARAMETERS
-* p_inf
-* [in] pointer to an inform info
-*
-* RETURN VALUES
-* The node type
-*
-* NOTES
-*
-* SEE ALSO
-* ib_inform_info_t
-*********/
-
-/****s* IBA Base: Types/ib_inform_info_record_t
-* NAME
-* ib_inform_info_record_t
-*
-* DESCRIPTION
-* IBA defined InformInfo Record. (15.2.5.12)
-*
-* SYNOPSIS
-*/
-#include <complib/cl_packon.h>
-typedef struct _ib_inform_info_record {
- ib_gid_t subscriber_gid;
- ib_net16_t subscriber_enum;
- uint8_t reserved[6];
- ib_inform_info_t inform_info;
- uint8_t pad[4];
-} PACK_SUFFIX ib_inform_info_record_t;
-#include <complib/cl_packoff.h>
-
-/****s* IBA Base: Types/ib_perfmgt_mad_t
-* NAME
-* ib_perfmgt_mad_t
-*
-* DESCRIPTION
-* IBA defined Perf Management MAD (16.3.1)
-*
-* SYNOPSIS
-*/
-#include <complib/cl_packon.h>
-typedef struct _ib_perfmgt_mad {
- ib_mad_t header;
- uint8_t resv[40];
-
-#define IB_PM_DATA_SIZE 192
- uint8_t data[IB_PM_DATA_SIZE];
-
-} PACK_SUFFIX ib_perfmgt_mad_t;
-#include <complib/cl_packoff.h>
-/*
-* FIELDS
-* header
-* Common MAD header.
-*
-* resv
-* Reserved.
-*
-* data
-* Performance Management payload. The structure and content of this field
-* depends upon the method, attr_id, and attr_mod fields in the header.
-*
-* SEE ALSO
-* ib_mad_t
-*********/
-
-/****s* IBA Base: Types/ib_port_counters
-* NAME
-* ib_port_counters_t
-*
-* DESCRIPTION
-* IBA defined PortCounters Attribute. (16.1.3.5)
-*
-* SYNOPSIS
-*/
-#include <complib/cl_packon.h>
-typedef struct _ib_port_counters {
- uint8_t reserved;
- uint8_t port_select;
- ib_net16_t counter_select;
- ib_net16_t symbol_err_cnt;
- uint8_t link_err_recover;
- uint8_t link_downed;
- ib_net16_t rcv_err;
- ib_net16_t rcv_rem_phys_err;
- ib_net16_t rcv_switch_relay_err;
- ib_net16_t xmit_discards;
- uint8_t xmit_constraint_err;
- uint8_t rcv_constraint_err;
- uint8_t res1;
- uint8_t link_int_buffer_overrun;
- ib_net16_t res2;
- ib_net16_t vl15_dropped;
- ib_net32_t xmit_data;
- ib_net32_t rcv_data;
- ib_net32_t xmit_pkts;
- ib_net32_t rcv_pkts;
-} PACK_SUFFIX ib_port_counters_t;
-#include <complib/cl_packoff.h>
-
-#define PC_LINK_INT(integ_buf_over) ((integ_buf_over & 0xF0) >> 4)
-#define PC_BUF_OVERRUN(integ_buf_over) (integ_buf_over & 0x0F)
-
-/****s* IBA Base: Types/ib_port_counters_ext
-* NAME
-* ib_port_counters_ext_t
-*
-* DESCRIPTION
-* IBA defined PortCounters Extended Attribute. (16.1.4.11)
-*
-* SYNOPSIS
-*/
-#include <complib/cl_packon.h>
-typedef struct _ib_port_counters_ext {
- uint8_t reserved;
- uint8_t port_select;
- ib_net16_t counter_select;
- ib_net32_t reserved2;
- ib_net64_t xmit_data;
- ib_net64_t rcv_data;
- ib_net64_t xmit_pkts;
- ib_net64_t rcv_pkts;
- ib_net64_t unicast_xmit_pkts;
- ib_net64_t unicast_rcv_pkts;
- ib_net64_t multicast_xmit_pkts;
- ib_net64_t multicast_rcv_pkts;
-} PACK_SUFFIX ib_port_counters_ext_t;
-#include <complib/cl_packoff.h>
-
-/****s* IBA Base: Types/ib_port_samples_control
-* NAME
-* ib_port_samples_control_t
-*
-* DESCRIPTION
-* IBA defined PortSamplesControl Attribute. (16.1.3.2)
-*
-* SYNOPSIS
-*/
-#include <complib/cl_packon.h>
-typedef struct _ib_port_samples_control {
- uint8_t op_code;
- uint8_t port_select;
- uint8_t tick;
- uint8_t counter_width; /* 5 bits res : 3bits counter_width */
- ib_net32_t counter_mask; /* 2 bits res : 3 bits counter_mask : 27 bits counter_masks_1to9 */
- ib_net16_t counter_mask_10to14; /* 1 bits res : 15 bits counter_masks_10to14 */
- uint8_t sample_mech;
- uint8_t sample_status; /* 6 bits res : 2 bits sample_status */
- ib_net64_t option_mask;
- ib_net64_t vendor_mask;
- ib_net32_t sample_start;
- ib_net32_t sample_interval;
- ib_net16_t tag;
- ib_net16_t counter_select0;
- ib_net16_t counter_select1;
- ib_net16_t counter_select2;
- ib_net16_t counter_select3;
- ib_net16_t counter_select4;
- ib_net16_t counter_select5;
- ib_net16_t counter_select6;
- ib_net16_t counter_select7;
- ib_net16_t counter_select8;
- ib_net16_t counter_select9;
- ib_net16_t counter_select10;
- ib_net16_t counter_select11;
- ib_net16_t counter_select12;
- ib_net16_t counter_select13;
- ib_net16_t counter_select14;
-} PACK_SUFFIX ib_port_samples_control_t;
-#include <complib/cl_packoff.h>
-
-/****d* IBA Base: Types/CounterSelect values
-* NAME
-* Counter select values
-*
-* DESCRIPTION
-* Mandatory counter select values (16.1.3.3)
-*
-* SYNOPSIS
-*/
-#define IB_CS_PORT_XMIT_DATA (CL_HTON16(0x0001))
-#define IB_CS_PORT_RCV_DATA (CL_HTON16(0x0002))
-#define IB_CS_PORT_XMIT_PKTS (CL_HTON16(0x0003))
-#define IB_CS_PORT_RCV_PKTS (CL_HTON16(0x0004))
-#define IB_CS_PORT_XMIT_WAIT (CL_HTON16(0x0005))
-
-/****s* IBA Base: Types/ib_port_samples_result
-* NAME
-* ib_port_samples_result_t
-*
-* DESCRIPTION
-* IBA defined PortSamplesControl Attribute. (16.1.3.2)
-*
-* SYNOPSIS
-*/
-#include <complib/cl_packon.h>
-typedef struct _ib_port_samples_result {
- ib_net16_t tag;
- ib_net16_t sample_status; /* 14 bits res : 2 bits sample_status */
- ib_net32_t counter0;
- ib_net32_t counter1;
- ib_net32_t counter2;
- ib_net32_t counter3;
- ib_net32_t counter4;
- ib_net32_t counter5;
- ib_net32_t counter6;
- ib_net32_t counter7;
- ib_net32_t counter8;
- ib_net32_t counter9;
- ib_net32_t counter10;
- ib_net32_t counter11;
- ib_net32_t counter12;
- ib_net32_t counter13;
- ib_net32_t counter14;
-} PACK_SUFFIX ib_port_samples_result_t;
-#include <complib/cl_packoff.h>
-
-/****d* IBA Base: Types/DM_SVC_NAME
-* NAME
-* DM_SVC_NAME
-*
-* DESCRIPTION
-* IBA defined Device Management service name (16.3)
-*
-* SYNOPSIS
-*/
-#define DM_SVC_NAME "DeviceManager.IBTA"
-/*
-* SEE ALSO
-*********/
-
-/****s* IBA Base: Types/ib_dm_mad_t
-* NAME
-* ib_dm_mad_t
-*
-* DESCRIPTION
-* IBA defined Device Management MAD (16.3.1)
-*
-* SYNOPSIS
-*/
-#include <complib/cl_packon.h>
-typedef struct _ib_dm_mad {
- ib_mad_t header;
- uint8_t resv[40];
-
-#define IB_DM_DATA_SIZE 192
- uint8_t data[IB_DM_DATA_SIZE];
-
-} PACK_SUFFIX ib_dm_mad_t;
-#include <complib/cl_packoff.h>
-/*
-* FIELDS
-* header
-* Common MAD header.
-*
-* resv
-* Reserved.
-*
-* data
-* Device Management payload. The structure and content of this field
-* depend upon the method, attr_id, and attr_mod fields in the header.
-*
-* SEE ALSO
-* ib_mad_t
-*********/
-
-/****s* IBA Base: Types/ib_iou_info_t
-* NAME
-* ib_iou_info_t
-*
-* DESCRIPTION
-* IBA defined IO Unit information structure (16.3.3.3)
-*
-* SYNOPSIS
-*/
-#include <complib/cl_packon.h>
-typedef struct _ib_iou_info {
- ib_net16_t change_id;
- uint8_t max_controllers;
- uint8_t diag_rom;
-
-#define IB_DM_CTRL_LIST_SIZE 128
-
- uint8_t controller_list[IB_DM_CTRL_LIST_SIZE];
-#define IOC_NOT_INSTALLED 0x0
-#define IOC_INSTALLED 0x1
-// Reserved values 0x02-0xE
-#define SLOT_DOES_NOT_EXIST 0xF
-
-} PACK_SUFFIX ib_iou_info_t;
-#include <complib/cl_packoff.h>
-/*
-* FIELDS
-* change_id
-* Value incremented, with rollover, by any change to the controller_list.
-*
-* max_controllers
-* Number of slots in controller_list.
-*
-* diag_rom
-* A byte containing two fields: DiagDeviceID and OptionROM.
-* These fields may be read using the ib_iou_info_diag_dev_id
-* and ib_iou_info_option_rom functions.
-*
-* controller_list
-* A series of 4-bit nibbles, with each nibble representing a slot
-* in the IO Unit. Individual nibbles may be read using the
-* ioc_at_slot function.
-*
-* SEE ALSO
-* ib_dm_mad_t, ib_iou_info_diag_dev_id, ib_iou_info_option_rom, ioc_at_slot
-*********/
-
-/****f* IBA Base: Types/ib_iou_info_diag_dev_id
-* NAME
-* ib_iou_info_diag_dev_id
-*
-* DESCRIPTION
-* Returns the DiagDeviceID.
-*
-* SYNOPSIS
-*/
-static inline uint8_t OSM_API
-ib_iou_info_diag_dev_id(IN const ib_iou_info_t * const p_iou_info)
-{
- return ((uint8_t) (p_iou_info->diag_rom >> 6 & 1));
-}
-
-/*
-* PARAMETERS
-* p_iou_info
-* [in] Pointer to the IO Unit information structure.
-*
-* RETURN VALUES
-* DiagDeviceID field of the IO Unit information.
-*
-* NOTES
-*
-* SEE ALSO
-* ib_iou_info_t
-*********/
-
-/****f* IBA Base: Types/ib_iou_info_option_rom
-* NAME
-* ib_iou_info_option_rom
-*
-* DESCRIPTION
-* Returns the OptionROM.
-*
-* SYNOPSIS
-*/
-static inline uint8_t OSM_API
-ib_iou_info_option_rom(IN const ib_iou_info_t * const p_iou_info)
-{
- return ((uint8_t) (p_iou_info->diag_rom >> 7));
-}
-
-/*
-* PARAMETERS
-* p_iou_info
-* [in] Pointer to the IO Unit information structure.
-*
-* RETURN VALUES
-* OptionROM field of the IO Unit information.
-*
-* NOTES
-*
-* SEE ALSO
-* ib_iou_info_t
-*********/
-
-/****f* IBA Base: Types/ioc_at_slot
-* NAME
-* ioc_at_slot
-*
-* DESCRIPTION
-* Returns the IOC value at the specified slot.
-*
-* SYNOPSIS
-*/
-static inline uint8_t OSM_API
-ioc_at_slot(IN const ib_iou_info_t * const p_iou_info, IN uint8_t slot)
-{
- if (slot >= IB_DM_CTRL_LIST_SIZE)
- return SLOT_DOES_NOT_EXIST;
- else
- return (int8_t)
- ((slot % 2) ?
- ((p_iou_info->controller_list[slot / 2] & 0xf0) >> 4) :
- (p_iou_info->controller_list[slot / 2] & 0x0f));
-}
-
-/*
-* PARAMETERS
-* p_iou_info
-* [in] Pointer to the IO Unit information structure.
-*
-* slot
-* [in] Pointer to the IO Unit information structure.
-*
-* RETURN VALUES
-* OptionROM field of the IO Unit information.
-*
-* NOTES
-*
-* SEE ALSO
-* ib_iou_info_t
-*********/
-
-/****s* IBA Base: Types/ib_ioc_profile_t
-* NAME
-* ib_ioc_profile_t
-*
-* DESCRIPTION
-* IBA defined IO Controller profile structure (16.3.3.4)
-*
-* SYNOPSIS
-*/
-#include <complib/cl_packon.h>
-typedef struct _ib_ioc_profile {
- ib_net64_t ioc_guid;
-
- ib_net32_t vend_id;
-
- ib_net32_t dev_id;
- ib_net16_t dev_ver;
- ib_net16_t resv2;
-
- ib_net32_t subsys_vend_id;
- ib_net32_t subsys_id;
-
- ib_net16_t io_class;
- ib_net16_t io_subclass;
- ib_net16_t protocol;
- ib_net16_t protocol_ver;
-
- ib_net32_t resv3;
- ib_net16_t send_msg_depth;
- uint8_t resv4;
- uint8_t rdma_read_depth;
- ib_net32_t send_msg_size;
- ib_net32_t rdma_size;
-
- uint8_t ctrl_ops_cap;
-#define CTRL_OPS_CAP_ST 0x01
-#define CTRL_OPS_CAP_SF 0x02
-#define CTRL_OPS_CAP_RT 0x04
-#define CTRL_OPS_CAP_RF 0x08
-#define CTRL_OPS_CAP_WT 0x10
-#define CTRL_OPS_CAP_WF 0x20
-#define CTRL_OPS_CAP_AT 0x40
-#define CTRL_OPS_CAP_AF 0x80
-
- uint8_t resv5;
-
- uint8_t num_svc_entries;
-#define MAX_NUM_SVC_ENTRIES 0xff
-
- uint8_t resv6[9];
-
-#define CTRL_ID_STRING_LEN 64
- char id_string[CTRL_ID_STRING_LEN];
-
-} PACK_SUFFIX ib_ioc_profile_t;
-#include <complib/cl_packoff.h>
-/*
-* FIELDS
-* ioc_guid
-* An EUI-64 GUID used to uniquely identify the IO controller.
-*
-* vend_id
-* IO controller vendor ID, IEEE format.
-*
-* dev_id
-* A number assigned by the vendor to identify the type of controller.
-*
-* dev_ver
-* A number assigned by the vendor to identify the divice version.
-*
-* subsys_vend_id
-* ID of the vendor of the enclosure, if any, in which the IO controller
-* resides in IEEE format; otherwise zero.
-*
-* subsys_id
-* A number identifying the subsystem where the controller resides.
-*
-* io_class
-* 0x0000 - 0xfffe = reserved for IO classes encompased by InfiniBand
-* Architecture. 0xffff = Vendor specific.
-*
-* io_subclass
-* 0x0000 - 0xfffe = reserved for IO subclasses encompased by InfiniBand
-* Architecture. 0xffff = Vendor specific. This shall be set to 0xfff
-* if the io_class component is 0xffff.
-*
-* protocol
-* 0x0000 - 0xfffe = reserved for IO subclasses encompased by InfiniBand
-* Architecture. 0xffff = Vendor specific. This shall be set to 0xfff
-* if the io_class component is 0xffff.
-*
-* protocol_ver
-* Protocol specific.
-*
-* send_msg_depth
-* Maximum depth of the send message queue.
-*
-* rdma_read_depth
-* Maximum depth of the per-channel RDMA read queue.
-*
-* send_msg_size
-* Maximum size of send messages.
-*
-* ctrl_ops_cap
-* Supported operation types of this IO controller. A bit set to one
-* for affirmation of supported capability.
-*
-* num_svc_entries
-* Number of entries in the service entries table.
-*
-* id_string
-* UTF-8 encoded string for identifying the controller to an operator.
-*
-* SEE ALSO
-* ib_dm_mad_t
-*********/
-
-static inline uint32_t OSM_API
-ib_ioc_profile_get_vend_id(IN const ib_ioc_profile_t * const p_ioc_profile)
-{
- return (cl_ntoh32(p_ioc_profile->vend_id) >> 8);
-}
-
-static inline void OSM_API
-ib_ioc_profile_set_vend_id(IN ib_ioc_profile_t * const p_ioc_profile,
- IN const uint32_t vend_id)
-{
- p_ioc_profile->vend_id = (cl_hton32(vend_id) << 8);
-}
-
-/****s* IBA Base: Types/ib_svc_entry_t
-* NAME
-* ib_svc_entry_t
-*
-* DESCRIPTION
-* IBA defined IO Controller service entry structure (16.3.3.5)
-*
-* SYNOPSIS
-*/
-#include <complib/cl_packon.h>
-typedef struct _ib_svc_entry {
-#define MAX_SVC_ENTRY_NAME_LEN 40
- char name[MAX_SVC_ENTRY_NAME_LEN];
-
- ib_net64_t id;
-
-} PACK_SUFFIX ib_svc_entry_t;
-#include <complib/cl_packoff.h>
-/*
-* FIELDS
-* name
-* UTF-8 encoded, null-terminated name of the service.
-*
-* id
-* An identifier of the associated Service.
-*
-* SEE ALSO
-* ib_svc_entries_t
-*********/
-
-/****s* IBA Base: Types/ib_svc_entries_t
-* NAME
-* ib_svc_entries_t
-*
-* DESCRIPTION
-* IBA defined IO Controller service entry array (16.3.3.5)
-*
-* SYNOPSIS
-*/
-#include <complib/cl_packon.h>
-typedef struct _ib_svc_entries {
-#define SVC_ENTRY_COUNT 4
- ib_svc_entry_t service_entry[SVC_ENTRY_COUNT];
-
-} PACK_SUFFIX ib_svc_entries_t;
-#include <complib/cl_packoff.h>
-/*
-* FIELDS
-* service_entry
-* An array of IO controller service entries.
-*
-* SEE ALSO
-* ib_dm_mad_t, ib_svc_entry_t
-*********/
-
-static inline void OSM_API
-ib_dm_get_slot_lo_hi(IN const ib_net32_t slot_lo_hi,
- OUT uint8_t * const p_slot,
- OUT uint8_t * const p_lo, OUT uint8_t * const p_hi)
-{
- ib_net32_t tmp_slot_lo_hi = CL_NTOH32(slot_lo_hi);
-
- if (p_slot)
- *p_slot = (uint8_t) ((tmp_slot_lo_hi >> 16) & 0x0f);
-
- if (p_hi)
- *p_hi = (uint8_t) ((tmp_slot_lo_hi >> 8) & 0xff);
-
- if (p_lo)
- *p_lo = (uint8_t) ((tmp_slot_lo_hi >> 0) & 0xff);
-}
-
-/*
- * IBA defined information describing an I/O controller
- */
-#include <complib/cl_packon.h>
-typedef struct _ib_ioc_info {
- ib_net64_t module_guid;
- ib_net64_t iou_guid;
- ib_ioc_profile_t ioc_profile;
- ib_net64_t access_key;
- uint16_t initiators_conf;
- uint8_t resv[38];
-
-} PACK_SUFFIX ib_ioc_info_t;
-#include <complib/cl_packoff.h>
-
-/*
- * The following definitions are shared between the Access Layer and VPD
- */
-typedef struct _ib_ca *__ptr64 ib_ca_handle_t;
-typedef struct _ib_pd *__ptr64 ib_pd_handle_t;
-typedef struct _ib_rdd *__ptr64 ib_rdd_handle_t;
-typedef struct _ib_mr *__ptr64 ib_mr_handle_t;
-typedef struct _ib_mw *__ptr64 ib_mw_handle_t;
-typedef struct _ib_qp *__ptr64 ib_qp_handle_t;
-typedef struct _ib_eec *__ptr64 ib_eec_handle_t;
-typedef struct _ib_cq *__ptr64 ib_cq_handle_t;
-typedef struct _ib_av *__ptr64 ib_av_handle_t;
-typedef struct _ib_mcast *__ptr64 ib_mcast_handle_t;
-
-/* Currently for windows branch, use the extended version of ib special verbs struct
- in order to be compliant with Infinicon ib_types; later we'll change it to support
- OpenSM ib_types.h */
-
-#ifndef WIN32
-/****d* Access Layer/ib_api_status_t
-* NAME
-* ib_api_status_t
-*
-* DESCRIPTION
-* Function return codes indicating the success or failure of an API call.
-* Note that success is indicated by the return value IB_SUCCESS, which
-* is always zero.
-*
-* NOTES
-* IB_VERBS_PROCESSING_DONE is used by UVP library to terminate a verbs call
-* in the pre-ioctl step itself.
-*
-* SYNOPSIS
-*/
-typedef enum _ib_api_status_t {
- IB_SUCCESS,
- IB_INSUFFICIENT_RESOURCES,
- IB_INSUFFICIENT_MEMORY,
- IB_INVALID_PARAMETER,
- IB_INVALID_SETTING,
- IB_NOT_FOUND,
- IB_TIMEOUT,
- IB_CANCELED,
- IB_INTERRUPTED,
- IB_INVALID_PERMISSION,
- IB_UNSUPPORTED,
- IB_OVERFLOW,
- IB_MAX_MCAST_QPS_REACHED,
- IB_INVALID_QP_STATE,
- IB_INVALID_EEC_STATE,
- IB_INVALID_APM_STATE,
- IB_INVALID_PORT_STATE,
- IB_INVALID_STATE,
- IB_RESOURCE_BUSY,
- IB_INVALID_PKEY,
- IB_INVALID_LKEY,
- IB_INVALID_RKEY,
- IB_INVALID_MAX_WRS,
- IB_INVALID_MAX_SGE,
- IB_INVALID_CQ_SIZE,
- IB_INVALID_SERVICE_TYPE,
- IB_INVALID_GID,
- IB_INVALID_LID,
- IB_INVALID_GUID,
- IB_INVALID_CA_HANDLE,
- IB_INVALID_AV_HANDLE,
- IB_INVALID_CQ_HANDLE,
- IB_INVALID_EEC_HANDLE,
- IB_INVALID_QP_HANDLE,
- IB_INVALID_PD_HANDLE,
- IB_INVALID_MR_HANDLE,
- IB_INVALID_MW_HANDLE,
- IB_INVALID_RDD_HANDLE,
- IB_INVALID_MCAST_HANDLE,
- IB_INVALID_CALLBACK,
- IB_INVALID_AL_HANDLE, /* InfiniBand Access Layer */
- IB_INVALID_HANDLE, /* InfiniBand Access Layer */
- IB_ERROR, /* InfiniBand Access Layer */
- IB_REMOTE_ERROR, /* Infiniband Access Layer */
- IB_VERBS_PROCESSING_DONE, /* See Notes above */
- IB_INVALID_WR_TYPE,
- IB_QP_IN_TIMEWAIT,
- IB_EE_IN_TIMEWAIT,
- IB_INVALID_PORT,
- IB_NOT_DONE,
- IB_UNKNOWN_ERROR /* ALWAYS LAST ENUM VALUE! */
-} ib_api_status_t;
-/*****/
-
-OSM_EXPORT const char *ib_error_str[];
-
-/****f* IBA Base: Types/ib_get_err_str
-* NAME
-* ib_get_err_str
-*
-* DESCRIPTION
-* Returns a string for the specified status value.
-*
-* SYNOPSIS
-*/
-static inline const char *OSM_API ib_get_err_str(IN ib_api_status_t status)
-{
- if (status > IB_UNKNOWN_ERROR)
- status = IB_UNKNOWN_ERROR;
- return (ib_error_str[status]);
-}
-
-/*
-* PARAMETERS
-* status
-* [in] status value
-*
-* RETURN VALUES
-* Pointer to the status description string.
-*
-* NOTES
-*
-* SEE ALSO
-*********/
-
-/****d* Verbs/ib_async_event_t
-* NAME
-* ib_async_event_t -- Async event types
-*
-* DESCRIPTION
-* This type indicates the reason the async callback was called.
-* The context in the ib_event_rec_t indicates the resource context
-* that associated with the callback. For example, for IB_AE_CQ_ERROR
-* the context provided during the ib_create_cq is returned in the event.
-*
-* SYNOPSIS
-*/
-typedef enum _ib_async_event_t {
- IB_AE_SQ_ERROR = 1,
- IB_AE_SQ_DRAINED,
- IB_AE_RQ_ERROR,
- IB_AE_CQ_ERROR,
- IB_AE_QP_FATAL,
- IB_AE_QP_COMM,
- IB_AE_QP_APM,
- IB_AE_EEC_FATAL,
- IB_AE_EEC_COMM,
- IB_AE_EEC_APM,
- IB_AE_LOCAL_FATAL,
- IB_AE_PKEY_TRAP,
- IB_AE_QKEY_TRAP,
- IB_AE_MKEY_TRAP,
- IB_AE_PORT_TRAP,
- IB_AE_SYSIMG_GUID_TRAP,
- IB_AE_BUF_OVERRUN,
- IB_AE_LINK_INTEGRITY,
- IB_AE_FLOW_CTRL_ERROR,
- IB_AE_BKEY_TRAP,
- IB_AE_QP_APM_ERROR,
- IB_AE_EEC_APM_ERROR,
- IB_AE_WQ_REQ_ERROR,
- IB_AE_WQ_ACCESS_ERROR,
- IB_AE_PORT_ACTIVE,
- IB_AE_PORT_DOWN,
- IB_AE_UNKNOWN /* ALWAYS LAST ENUM VALUE */
-} ib_async_event_t;
-/*
-* VALUES
-* IB_AE_SQ_ERROR
-* An error occurred when accessing the send queue of the QP or EEC.
-* This event is optional.
-*
-* IB_AE_SQ_DRAINED
-* The send queue of the specified QP has completed the outstanding
-* messages in progress when the state change was requested and, if
-* applicable, has received all acknowledgements for those messages.
-*
-* IB_AE_RQ_ERROR
-* An error occurred when accessing the receive queue of the QP or EEC.
-* This event is optional.
-*
-* IB_AE_CQ_ERROR
-* An error occurred when writing an entry to the CQ.
-*
-* IB_AE_QP_FATAL
-* A catastrophic error occurred while accessing or processing the
-* work queue that prevents reporting of completions.
-*
-* IB_AE_QP_COMM
-* The first packet has arrived for the receive work queue where the
-* QP is still in the RTR state.
-*
-* IB_AE_QP_APM
-* If alternate path migration is supported, this event indicates that
-* the QP connection has migrated to the alternate path.
-*
-* IB_AE_EEC_FATAL
-* If reliable datagram service is supported, this event indicates that
-* a catastrophic error occurred while accessing or processing the EEC
-* that prevents reporting of completions.
-*
-* IB_AE_EEC_COMM
-* If reliable datagram service is supported, this event indicates that
-* the first packet has arrived for the receive work queue where the
-* EEC is still in the RTR state.
-*
-* IB_AE_EEC_APM
-* If reliable datagram service and alternate path migration is supported,
-* this event indicates that the EEC connection has migrated to the
-* alternate path.
-*
-* IB_AE_LOCAL_FATAL
-* A catastrophic HCA error occurred which cannot be attributed to any
-* resource; behavior is indeterminate.
-*
-* IB_AE_PKEY_TRAP
-* A PKEY violation was detected. This event is optional.
-*
-* IB_AE_QKEY_TRAP
-* A QKEY violation was detected. This event is optional.
-*
-* IB_AE_MKEY_TRAP
-* An MKEY violation was detected. This event is optional.
-*
-* IB_AE_PORT_TRAP
-* A port capability change was detected. This event is optional.
-*
-* IB_AE_SYSIMG_GUID_TRAP
-* If the system image GUID is supported, this event indicates that the
-* system image GUID of this HCA has been changed. This event is
-* optional.
-*
-* IB_AE_BUF_OVERRUN
-* The number of consecutive flow control update periods with at least
-* one overrun error in each period has exceeded the threshold specified
-* in the port info attributes. This event is optional.
-*
-* IB_AE_LINK_INTEGRITY
-* The detection of excessively frequent local physical errors has
-* exceeded the threshold specified in the port info attributes. This
-* event is optional.
-*
-* IB_AE_FLOW_CTRL_ERROR
-* An HCA watchdog timer monitoring the arrival of flow control updates
-* has expired without receiving an update. This event is optional.
-*
-* IB_AE_BKEY_TRAP
-* An BKEY violation was detected. This event is optional.
-*
-* IB_AE_QP_APM_ERROR
-* If alternate path migration is supported, this event indicates that
-* an incoming path migration request to this QP was not accepted.
-*
-* IB_AE_EEC_APM_ERROR
-* If reliable datagram service and alternate path migration is supported,
-* this event indicates that an incoming path migration request to this
-* EEC was not accepted.
-*
-* IB_AE_WQ_REQ_ERROR
-* An OpCode violation was detected at the responder.
-*
-* IB_AE_WQ_ACCESS_ERROR
-* An access violation was detected at the responder.
-*
-* IB_AE_PORT_ACTIVE
-* If the port active event is supported, this event is generated
-* when the link becomes active: IB_LINK_ACTIVE.
-*
-* IB_AE_PORT_DOWN
-* The link is declared unavailable: IB_LINK_INIT, IB_LINK_ARMED,
-* IB_LINK_DOWN.
-*
-* IB_AE_UNKNOWN
-* An unknown error occurred which cannot be attributed to any
-* resource; behavior is indeterminate.
-*
-*****/
-
-OSM_EXPORT const char *ib_async_event_str[];
-
-/****f* IBA Base: Types/ib_get_async_event_str
-* NAME
-* ib_get_async_event_str
-*
-* DESCRIPTION
-* Returns a string for the specified asynchronous event.
-*
-* SYNOPSIS
-*/
-static inline const char *OSM_API
-ib_get_async_event_str(IN ib_async_event_t event)
-{
- if (event > IB_AE_UNKNOWN)
- event = IB_AE_UNKNOWN;
- return (ib_async_event_str[event]);
-}
-
-/*
-* PARAMETERS
-* event
-* [in] event value
-*
-* RETURN VALUES
-* Pointer to the asynchronous event description string.
-*
-* NOTES
-*
-* SEE ALSO
-*********/
-
-/****s* Verbs/ib_event_rec_t
-* NAME
-* ib_event_rec_t -- Async event notification record
-*
-* DESCRIPTION
-* When an async event callback is made, this structure is passed to indicate
-* the type of event, the source of event that caused it, and the context
-* associated with this event.
-*
-* context -- Context of the resource that caused the event.
-* -- ca_context if this is a port/adapter event.
-* -- qp_context if the source is a QP event
-* -- cq_context if the source is a CQ event.
-* -- ee_context if the source is an EE event.
-*
-* SYNOPSIS
-*/
-typedef struct _ib_event_rec {
- void *context;
- ib_async_event_t type;
-
- /* HCA vendor specific event information. */
- uint64_t vendor_specific;
-
- /* The following structures are valid only for trap types. */
- union _trap {
- struct {
- uint16_t lid;
- ib_net64_t port_guid;
- uint8_t port_num;
-
- /*
- * The following structure is valid only for
- * P_KEY, Q_KEY, and M_KEY violation traps.
- */
- struct {
- uint8_t sl;
- uint16_t src_lid;
- uint16_t dest_lid;
- union _key {
- uint16_t pkey;
- uint32_t qkey;
- uint64_t mkey;
- } key;
- uint32_t src_qp;
- uint32_t dest_qp;
- ib_gid_t src_gid;
- ib_gid_t dest_gid;
-
- } violation;
-
- } info;
-
- ib_net64_t sysimg_guid;
-
- } trap;
-
-} ib_event_rec_t;
-/*******/
-
-/****d* Access Layer/ib_atomic_t
-* NAME
-* ib_atomic_t
-*
-* DESCRIPTION
-* Indicates atomicity levels supported by an adapter.
-*
-* SYNOPSIS
-*/
-typedef enum _ib_atomic_t {
- IB_ATOMIC_NONE,
- IB_ATOMIC_LOCAL,
- IB_ATOMIC_GLOBAL
-} ib_atomic_t;
-/*
-* VALUES
-* IB_ATOMIC_NONE
-* Atomic operations not supported.
-*
-* IB_ATOMIC_LOCAL
-* Atomic operations guaranteed between QPs of a single CA.
-*
-* IB_ATOMIC_GLOBAL
-* Atomic operations are guaranteed between CA and any other entity
-* in the system.
-*****/
-
-/****s* Access Layer/ib_port_cap_t
-* NAME
-* ib_port_cap_t
-*
-* DESCRIPTION
-* Indicates which management agents are currently available on the specified
-* port.
-*
-* SYNOPSIS
-*/
-typedef struct _ib_port_cap {
- boolean_t cm;
- boolean_t snmp;
- boolean_t dev_mgmt;
- boolean_t vend;
- boolean_t sm;
- boolean_t sm_disable;
- boolean_t qkey_ctr;
- boolean_t pkey_ctr;
- boolean_t notice;
- boolean_t trap;
- boolean_t apm;
- boolean_t slmap;
- boolean_t pkey_nvram;
- boolean_t mkey_nvram;
- boolean_t sysguid;
- boolean_t dr_notice;
- boolean_t boot_mgmt;
- boolean_t capm_notice;
- boolean_t reinit;
- boolean_t ledinfo;
- boolean_t port_active;
-
-} ib_port_cap_t;
-/*****/
-
-/****d* Access Layer/ib_init_type_t
-* NAME
-* ib_init_type_t
-*
-* DESCRIPTION
-* If supported by the HCA, the type of initialization requested by
-* this port before SM moves it to the active or armed state. If the
-* SM implements reinitialization, it shall set these bits to indicate
-* the type of initialization performed prior to activating the port.
-* Otherwise, these bits shall be set to 0.
-*
-* SYNOPSIS
-*/
-typedef uint8_t ib_init_type_t;
-#define IB_INIT_TYPE_NO_LOAD 0x01
-#define IB_INIT_TYPE_PRESERVE_CONTENT 0x02
-#define IB_INIT_TYPE_PRESERVE_PRESENCE 0x04
-#define IB_INIT_TYPE_DO_NOT_RESUSCITATE 0x08
-/*****/
-
-/****s* Access Layer/ib_port_attr_mod_t
-* NAME
-* ib_port_attr_mod_t
-*
-* DESCRIPTION
-* Port attributes that may be modified.
-*
-* SYNOPSIS
-*/
-typedef struct _ib_port_attr_mod {
- ib_port_cap_t cap;
- uint16_t pkey_ctr;
- uint16_t qkey_ctr;
-
- ib_init_type_t init_type;
- ib_net64_t system_image_guid;
-
-} ib_port_attr_mod_t;
-/*
-* SEE ALSO
-* ib_port_cap_t
-*****/
-
-/****s* Access Layer/ib_port_attr_t
-* NAME
-* ib_port_attr_t
-*
-* DESCRIPTION
-* Information about a port on a given channel adapter.
-*
-* SYNOPSIS
-*/
-typedef struct _ib_port_attr {
- ib_net64_t port_guid;
- uint8_t port_num;
- uint8_t mtu;
- uint64_t max_msg_size;
- ib_net16_t lid;
- uint8_t lmc;
-
- /*
- * LinkWidthSupported as defined in PortInfo. Required to calculate
- * inter-packet delay (a.k.a. static rate).
- */
- uint8_t link_width_supported;
-
- uint16_t max_vls;
-
- ib_net16_t sm_lid;
- uint8_t sm_sl;
- uint8_t link_state;
-
- ib_init_type_t init_type_reply; /* Optional */
-
- /*
- * subnet_timeout:
- * The maximum expected subnet propagation delay to reach any port on
- * the subnet. This value also determines the rate at which traps can
- * be generated from this node.
- *
- * timeout = 4.096 microseconds * 2^subnet_timeout
- */
- uint8_t subnet_timeout;
-
- ib_port_cap_t cap;
- uint16_t pkey_ctr;
- uint16_t qkey_ctr;
-
- uint16_t num_gids;
- uint16_t num_pkeys;
- /*
- * Pointers at the end of the structure to allow doing a simple
- * memory comparison of contents up to the first pointer.
- */
- ib_gid_t *p_gid_table;
- ib_net16_t *p_pkey_table;
-
-} ib_port_attr_t;
-/*
-* SEE ALSO
-* uint8_t, ib_port_cap_t, ib_link_states_t
-*****/
-
-/****s* Access Layer/ib_ca_attr_t
-* NAME
-* ib_ca_attr_t
-*
-* DESCRIPTION
-* Information about a channel adapter.
-*
-* SYNOPSIS
-*/
-typedef struct _ib_ca_attr {
- ib_net64_t ca_guid;
-
- uint32_t vend_id;
- uint16_t dev_id;
- uint16_t revision;
- uint64_t fw_ver;
-
- /*
- * Total size of the ca attributes in bytes
- */
- uint32_t size;
- uint32_t max_qps;
- uint32_t max_wrs;
-
- uint32_t max_sges;
- uint32_t max_rd_sges;
-
- uint32_t max_cqs;
- uint32_t max_cqes;
-
- uint32_t max_pds;
-
- uint32_t init_regions;
- uint64_t init_region_size;
-
- uint32_t init_windows;
- uint32_t max_addr_handles;
-
- uint32_t max_partitions;
-
- ib_atomic_t atomicity;
-
- uint8_t max_qp_resp_res;
- uint8_t max_eec_resp_res;
- uint8_t max_resp_res;
-
- uint8_t max_qp_init_depth;
- uint8_t max_eec_init_depth;
-
- uint32_t max_eecs;
- uint32_t max_rdds;
-
- uint32_t max_ipv6_qps;
- uint32_t max_ether_qps;
-
- uint32_t max_mcast_grps;
- uint32_t max_mcast_qps;
- uint32_t max_qps_per_mcast_grp;
- uint32_t max_fmr;
- uint32_t max_map_per_fmr;
-
- /*
- * local_ack_delay:
- * Specifies the maximum time interval between the local CA receiving
- * a message and the transmission of the associated ACK or NAK.
- *
- * timeout = 4.096 microseconds * 2^local_ack_delay
- */
- uint8_t local_ack_delay;
-
- boolean_t bad_pkey_ctr_support;
- boolean_t bad_qkey_ctr_support;
- boolean_t raw_mcast_support;
- boolean_t apm_support;
- boolean_t av_port_check;
- boolean_t change_primary_port;
- boolean_t modify_wr_depth;
- boolean_t current_qp_state_support;
- boolean_t shutdown_port_capability;
- boolean_t init_type_support;
- boolean_t port_active_event_support;
- boolean_t system_image_guid_support;
- boolean_t hw_agents;
-
- ib_net64_t system_image_guid;
-
- uint32_t num_page_sizes;
- uint8_t num_ports;
-
- uint32_t *p_page_size;
- ib_port_attr_t *p_port_attr;
-
-} ib_ca_attr_t;
-/*
-* FIELDS
-* ca_guid
-* GUID for this adapter.
-*
-* vend_id
-* IEEE vendor ID for this adapter
-*
-* dev_id
-* Device ID of this adapter. (typically from PCI device ID)
-*
-* revision
-* Revision ID of this adapter
-*
-* fw_ver
-* Device Firmware version.
-*
-* size
-* Total size in bytes for the HCA attributes. This size includes total
-* size required for all the variable members of the structure. If a
-* vendor requires to pass vendor specific fields beyond this structure,
-* the HCA vendor can choose to report a larger size. If a vendor is
-* reporting extended vendor specific features, they should also provide
-* appropriate access functions to aid with the required interpretation.
-*
-* max_qps
-* Maximum number of QP's supported by this HCA.
-*
-* max_wrs
-* Maximum number of work requests supported by this HCA.
-*
-* max_sges
-* Maximum number of scatter gather elements supported per work request.
-*
-* max_rd_sges
-* Maximum number of scatter gather elements supported for READ work
-* requests for a Reliable Datagram QP. This value must be zero if RD
-* service is not supported.
-*
-* max_cqs
-* Maximum number of Completion Queues supported.
-*
-* max_cqes
-* Maximum number of CQ elements supported per CQ.
-*
-* max_pds
-* Maximum number of protection domains supported.
-*
-* init_regions
-* Initial number of memory regions supported. These are only informative
-* values. HCA vendors can extended and grow these limits on demand.
-*
-* init_region_size
-* Initial limit on the size of the registered memory region.
-*
-* init_windows
-* Initial number of window entries supported.
-*
-* max_addr_handles
-* Maximum number of address handles supported.
-*
-* max_partitions
-* Maximum number of partitions supported.
-*
-* atomicity
-* Indicates level of atomic operations supported by this HCA.
-*
-* max_qp_resp_res
-* max_eec_resp_res
-* Maximum limit on number of responder resources for incoming RDMA
-* operations, on QPs and EEC's respectively.
-*
-* max_resp_res
-* Maximum number of responder resources per HCA, with this HCA used as
-* the target.
-*
-* max_qp_init_depth
-* max_eec_init_depth
-* Maximimum initiator depth per QP or EEC for initiating RDMA reads and
-* atomic operations.
-*
-* max_eecs
-* Maximimum number of EEC's supported by the HCA.
-*
-* max_rdds
-* Maximum number of Reliable datagram domains supported.
-*
-* max_ipv6_qps
-* max_ether_qps
-* Maximum number of IPV6 and raw ether QP's supported by this HCA.
-*
-* max_mcast_grps
-* Maximum number of multicast groups supported.
-*
-* max_mcast_qps
-* Maximum number of QP's that can support multicast operations.
-*
-* max_qps_per_mcast_grp
-* Maximum number of multicast QP's per multicast group.
-*
-* local_ack_delay
-* Specifies the maximum time interval between the local CA receiving
-* a message and the transmission of the associated ACK or NAK.
-* timeout = 4.096 microseconds * 2^local_ack_delay
-*
-* bad_pkey_ctr_support
-* bad_qkey_ctr_support
-* Indicates support for the bad pkey and qkey counters.
-*
-* raw_mcast_support
-* Indicates support for raw packet multicast.
-*
-* apm_support
-* Indicates support for Automatic Path Migration.
-*
-* av_port_check
-* Indicates ability to check port number in address handles.
-*
-* change_primary_port
-* Indicates ability to change primary port for a QP or EEC during a
-* SQD->RTS transition.
-*
-* modify_wr_depth
-* Indicates ability to modify QP depth during a modify QP operation.
-* Check the verb specification for permitted states.
-*
-* current_qp_state_support
-* Indicates ability of the HCA to support the current QP state modifier
-* during a modify QP operation.
-*
-* shutdown_port_capability
-* Shutdown port capability support indicator.
-*
-* init_type_support
-* Indicates init_type_reply and ability to set init_type is supported.
-*
-* port_active_event_support
-* Port active event support indicator.
-*
-* system_image_guid_support
-* System image GUID support indicator.
-*
-* hw_agents
-* Indicates SMA is implemented in HW.
-*
-* system_image_guid
-* Optional system image GUID. This field is valid only if the
-* system_image_guid_support flag is set.
-*
-* num_page_sizes
-* Indicates support for different page sizes supported by the HCA.
-* The variable size array can be obtained from p_page_size.
-*
-* num_ports
-* Number of physical ports supported on this HCA.
-*
-* p_page_size
-* Array holding different page size supported.
-*
-* p_port_attr
-* Array holding port attributes.
-*
-* NOTES
-* This structure contains the attributes of a channel adapter. Users must
-* call ib_copy_ca_attr to copy the contents of this structure to a new
-* memory region.
-*
-* SEE ALSO
-* ib_port_attr_t, ib_atomic_t, ib_copy_ca_attr
-*****/
-
-/****f* Access layer/ib_copy_ca_attr
-* NAME
-* ib_copy_ca_attr
-*
-* DESCRIPTION
-* Copies CA attributes.
-*
-* SYNOPSIS
-*/
-ib_ca_attr_t *ib_copy_ca_attr(IN ib_ca_attr_t * const p_dest,
- IN const ib_ca_attr_t * const p_src);
-/*
-* PARAMETERS
-* p_dest
-* Pointer to the buffer that is the destination of the copy.
-*
-* p_src
-* Pointer to the CA attributes to copy.
-*
-* RETURN VALUE
-* Pointer to the copied CA attributes.
-*
-* NOTES
-* The buffer pointed to by the p_dest parameter must be at least the size
-* specified in the size field of the buffer pointed to by p_src.
-*
-* SEE ALSO
-* ib_ca_attr_t, ib_dup_ca_attr, ib_free_ca_attr
-*****/
-
-/****s* Access Layer/ib_av_attr_t
-* NAME
-* ib_av_attr_t
-*
-* DESCRIPTION
-* IBA address vector.
-*
-* SYNOPSIS
-*/
-typedef struct _ib_av_attr {
- uint8_t port_num;
-
- uint8_t sl;
- ib_net16_t dlid;
-
- boolean_t grh_valid;
- ib_grh_t grh;
- uint8_t static_rate;
- uint8_t path_bits;
-
- struct _av_conn {
- uint8_t path_mtu;
- uint8_t local_ack_timeout;
- uint8_t seq_err_retry_cnt;
- uint8_t rnr_retry_cnt;
-
- } conn;
-
-} ib_av_attr_t;
-/*
-* SEE ALSO
-* ib_gid_t
-*****/
-
-/****d* Access Layer/ib_qp_type_t
-* NAME
-* ib_qp_type_t
-*
-* DESCRIPTION
-* Indicates the type of queue pair being created.
-*
-* SYNOPSIS
-*/
-typedef enum _ib_qp_type {
- IB_QPT_RELIABLE_CONN = 0, /* Matches CM REQ transport type */
- IB_QPT_UNRELIABLE_CONN = 1, /* Matches CM REQ transport type */
- IB_QPT_RELIABLE_DGRM = 2, /* Matches CM REQ transport type */
- IB_QPT_UNRELIABLE_DGRM,
- IB_QPT_QP0,
- IB_QPT_QP1,
- IB_QPT_RAW_IPV6,
- IB_QPT_RAW_ETHER,
- IB_QPT_MAD, /* InfiniBand Access Layer */
- IB_QPT_QP0_ALIAS, /* InfiniBand Access Layer */
- IB_QPT_QP1_ALIAS /* InfiniBand Access Layer */
-} ib_qp_type_t;
-/*
-* VALUES
-* IB_QPT_RELIABLE_CONN
-* Reliable, connected queue pair.
-*
-* IB_QPT_UNRELIABLE_CONN
-* Unreliable, connected queue pair.
-*
-* IB_QPT_RELIABLE_DGRM
-* Reliable, datagram queue pair.
-*
-* IB_QPT_UNRELIABLE_DGRM
-* Unreliable, datagram queue pair.
-*
-* IB_QPT_QP0
-* Queue pair 0.
-*
-* IB_QPT_QP1
-* Queue pair 1.
-*
-* IB_QPT_RAW_DGRM
-* Raw datagram queue pair.
-*
-* IB_QPT_RAW_IPV6
-* Raw IP version 6 queue pair.
-*
-* IB_QPT_RAW_ETHER
-* Raw Ethernet queue pair.
-*
-* IB_QPT_MAD
-* Unreliable, datagram queue pair that will send and receive management
-* datagrams with assistance from the access layer.
-*
-* IB_QPT_QP0_ALIAS
-* Alias to queue pair 0. Aliased QPs can only be created on an aliased
-* protection domain.
-*
-* IB_QPT_QP1_ALIAS
-* Alias to queue pair 1. Aliased QPs can only be created on an aliased
-* protection domain.
-*****/
-
-/****d* Access Layer/ib_access_t
-* NAME
-* ib_access_t
-*
-* DESCRIPTION
-* Indicates the type of access is permitted on resources such as QPs,
-* memory regions and memory windows.
-*
-* SYNOPSIS
-*/
-typedef uint32_t ib_access_t;
-#define IB_AC_RDMA_READ 0x00000001
-#define IB_AC_RDMA_WRITE 0x00000002
-#define IB_AC_ATOMIC 0x00000004
-#define IB_AC_LOCAL_WRITE 0x00000008
-#define IB_AC_MW_BIND 0x00000010
-/*
-* NOTES
-* Users may combine access rights using a bit-wise or operation to specify
-* additional access. For example: IB_AC_RDMA_READ | IB_AC_RDMA_WRITE grants
-* RDMA read and write access.
-*****/
-
-/****d* Access Layer/ib_qp_state_t
-* NAME
-* ib_qp_state_t
-*
-* DESCRIPTION
-* Indicates or sets the state of a queue pair. The current state of a queue
-* pair is returned through the ib_qp_query call and set via the
-* ib_qp_modify call.
-*
-* SYNOPSIS
-*/
-typedef uint32_t ib_qp_state_t;
-#define IB_QPS_RESET 0x00000001
-#define IB_QPS_INIT 0x00000002
-#define IB_QPS_RTR 0x00000004
-#define IB_QPS_RTS 0x00000008
-#define IB_QPS_SQD 0x00000010
-#define IB_QPS_SQD_DRAINING 0x00000030
-#define IB_QPS_SQD_DRAINED 0x00000050
-#define IB_QPS_SQERR 0x00000080
-#define IB_QPS_ERROR 0x00000100
-#define IB_QPS_TIME_WAIT 0xDEAD0000 /* InfiniBand Access Layer */
-/*****/
-
-/****d* Access Layer/ib_apm_state_t
-* NAME
-* ib_apm_state_t
-*
-* DESCRIPTION
-* The current automatic path migration state of a queue pair
-*
-* SYNOPSIS
-*/
-typedef enum _ib_apm_state {
- IB_APM_MIGRATED = 1,
- IB_APM_REARM,
- IB_APM_ARMED
-} ib_apm_state_t;
-/*****/
-
-/****s* Access Layer/ib_qp_create_t
-* NAME
-* ib_qp_create_t
-*
-* DESCRIPTION
-* Attributes used to initialize a queue pair at creation time.
-*
-* SYNOPSIS
-*/
-typedef struct _ib_qp_create {
- ib_qp_type_t qp_type;
-
- ib_rdd_handle_t h_rdd;
-
- uint32_t sq_depth;
- uint32_t rq_depth;
- uint32_t sq_sge;
- uint32_t rq_sge;
-
- ib_cq_handle_t h_sq_cq;
- ib_cq_handle_t h_rq_cq;
-
- boolean_t sq_signaled;
-
-} ib_qp_create_t;
-/*
-* FIELDS
-* type
-* Specifies the type of queue pair to create.
-*
-* h_rdd
-* A handle to a reliable datagram domain to associate with the queue
-* pair. This field is ignored if the queue pair is not a reliable
-* datagram type queue pair.
-*
-* sq_depth
-* Indicates the requested maximum number of work requests that may be
-* outstanding on the queue pair's send queue. This value must be less
-* than or equal to the maximum reported by the channel adapter associated
-* with the queue pair.
-*
-* rq_depth
-* Indicates the requested maximum number of work requests that may be
-* outstanding on the queue pair's receive queue. This value must be less
-* than or equal to the maximum reported by the channel adapter associated
-* with the queue pair.
-*
-* sq_sge
-* Indicates the maximum number scatter-gather elements that may be
-* given in a send work request. This value must be less
-* than or equal to the maximum reported by the channel adapter associated
-* with the queue pair.
-*
-* rq_sge
-* Indicates the maximum number scatter-gather elements that may be
-* given in a receive work request. This value must be less
-* than or equal to the maximum reported by the channel adapter associated
-* with the queue pair.
-*
-* h_sq_cq
-* A handle to the completion queue that will be used to report send work
-* request completions. This handle must be NULL if the type is
-* IB_QPT_MAD, IB_QPT_QP0_ALIAS, or IB_QPT_QP1_ALIAS.
-*
-* h_rq_cq
-* A handle to the completion queue that will be used to report receive
-* work request completions. This handle must be NULL if the type is
-* IB_QPT_MAD, IB_QPT_QP0_ALIAS, or IB_QPT_QP1_ALIAS.
-*
-* sq_signaled
-* A flag that is used to indicate whether the queue pair will signal
-* an event upon completion of a send work request. If set to
-* TRUE, send work requests will always generate a completion
-* event. If set to FALSE, a completion event will only be
-* generated if the send_opt field of the send work request has the
-* IB_SEND_OPT_SIGNALED flag set.
-*
-* SEE ALSO
-* ib_qp_type_t, ib_qp_attr_t
-*****/
-
-/****s* Access Layer/ib_qp_attr_t
-* NAME
-* ib_qp_attr_t
-*
-* DESCRIPTION
-* Queue pair attributes returned through ib_query_qp.
-*
-* SYNOPSIS
-*/
-typedef struct _ib_qp_attr {
- ib_pd_handle_t h_pd;
- ib_qp_type_t qp_type;
- ib_access_t access_ctrl;
- uint16_t pkey_index;
-
- uint32_t sq_depth;
- uint32_t rq_depth;
- uint32_t sq_sge;
- uint32_t rq_sge;
- uint8_t init_depth;
- uint8_t resp_res;
-
- ib_cq_handle_t h_sq_cq;
- ib_cq_handle_t h_rq_cq;
- ib_rdd_handle_t h_rdd;
-
- boolean_t sq_signaled;
-
- ib_qp_state_t state;
- ib_net32_t num;
- ib_net32_t dest_num;
- ib_net32_t qkey;
-
- ib_net32_t sq_psn;
- ib_net32_t rq_psn;
-
- uint8_t primary_port;
- uint8_t alternate_port;
- ib_av_attr_t primary_av;
- ib_av_attr_t alternate_av;
- ib_apm_state_t apm_state;
-
-} ib_qp_attr_t;
-/*
-* FIELDS
-* h_pd
-* This is a handle to a protection domain associated with the queue
-* pair, or NULL if the queue pair is type IB_QPT_RELIABLE_DGRM.
-*
-* NOTES
-* Other fields are defined by the Infiniband specification.
-*
-* SEE ALSO
-* ib_qp_type_t, ib_access_t, ib_qp_state_t, ib_av_attr_t, ib_apm_state_t
-*****/
-
-/****d* Access Layer/ib_qp_opts_t
-* NAME
-* ib_qp_opts_t
-*
-* DESCRIPTION
-* Optional fields supplied in the modify QP operation.
-*
-* SYNOPSIS
-*/
-typedef uint32_t ib_qp_opts_t;
-#define IB_MOD_QP_ALTERNATE_AV 0x00000001
-#define IB_MOD_QP_PKEY 0x00000002
-#define IB_MOD_QP_APM_STATE 0x00000004
-#define IB_MOD_QP_PRIMARY_AV 0x00000008
-#define IB_MOD_QP_RNR_NAK_TIMEOUT 0x00000010
-#define IB_MOD_QP_RESP_RES 0x00000020
-#define IB_MOD_QP_INIT_DEPTH 0x00000040
-#define IB_MOD_QP_PRIMARY_PORT 0x00000080
-#define IB_MOD_QP_ACCESS_CTRL 0x00000100
-#define IB_MOD_QP_QKEY 0x00000200
-#define IB_MOD_QP_SQ_DEPTH 0x00000400
-#define IB_MOD_QP_RQ_DEPTH 0x00000800
-#define IB_MOD_QP_CURRENT_STATE 0x00001000
-#define IB_MOD_QP_RETRY_CNT 0x00002000
-#define IB_MOD_QP_LOCAL_ACK_TIMEOUT 0x00004000
-#define IB_MOD_QP_RNR_RETRY_CNT 0x00008000
-/*
-* SEE ALSO
-* ib_qp_mod_t
-*****/
-
-/****s* Access Layer/ib_qp_mod_t
-* NAME
-* ib_qp_mod_t
-*
-* DESCRIPTION
-* Information needed to change the state of a queue pair through the
-* ib_modify_qp call.
-*
-* SYNOPSIS
-*/
-typedef struct _ib_qp_mod {
- ib_qp_state_t req_state;
-
- union _qp_state {
- struct _qp_reset {
- /*
- * Time, in milliseconds, that the QP needs to spend in
- * the time wait state before being reused.
- */
- uint32_t timewait;
-
- } reset;
-
- struct _qp_init {
- ib_qp_opts_t opts;
- uint8_t primary_port;
- ib_net32_t qkey;
- uint16_t pkey_index;
- ib_access_t access_ctrl;
-
- } init;
-
- struct _qp_rtr {
- ib_net32_t rq_psn;
- ib_net32_t dest_qp;
- ib_av_attr_t primary_av;
- uint8_t resp_res;
-
- ib_qp_opts_t opts;
- ib_av_attr_t alternate_av;
- ib_net32_t qkey;
- uint16_t pkey_index;
- ib_access_t access_ctrl;
- uint32_t sq_depth;
- uint32_t rq_depth;
- uint8_t rnr_nak_timeout;
-
- } rtr;
-
- struct _qp_rts {
- ib_net32_t sq_psn;
- uint8_t retry_cnt;
- uint8_t rnr_retry_cnt;
- uint8_t rnr_nak_timeout;
- uint8_t local_ack_timeout;
- uint8_t init_depth;
-
- ib_qp_opts_t opts;
- ib_qp_state_t current_state;
- ib_net32_t qkey;
- ib_access_t access_ctrl;
- uint8_t resp_res;
-
- ib_av_attr_t primary_av;
- ib_av_attr_t alternate_av;
-
- uint32_t sq_depth;
- uint32_t rq_depth;
-
- ib_apm_state_t apm_state;
- uint8_t primary_port;
- uint16_t pkey_index;
-
- } rts;
-
- struct _qp_sqd {
- boolean_t sqd_event;
-
- } sqd;
-
- } state;
-
-} ib_qp_mod_t;
-/*
-* SEE ALSO
-* ib_qp_state_t, ib_access_t, ib_av_attr_t, ib_apm_state_t
-*****/
-
-/****s* Access Layer/ib_eec_attr_t
-* NAME
-* ib_eec_attr_t
-*
-* DESCRIPTION
-* Information about an end-to-end context.
-*
-* SYNOPSIS
-*/
-typedef struct _ib_eec_attr {
- ib_qp_state_t state;
- ib_rdd_handle_t h_rdd;
- ib_net32_t local_eecn;
-
- ib_net32_t sq_psn;
- ib_net32_t rq_psn;
- uint8_t primary_port;
- uint16_t pkey_index;
- uint32_t resp_res;
- ib_net32_t remote_eecn;
- uint32_t init_depth;
- uint32_t dest_num; // ??? What is this?
- ib_av_attr_t primary_av;
- ib_av_attr_t alternate_av;
- ib_apm_state_t apm_state;
-
-} ib_eec_attr_t;
-/*
-* SEE ALSO
-* ib_qp_state_t, ib_av_attr_t, ib_apm_state_t
-*****/
-
-/****d* Access Layer/ib_eec_opts_t
-* NAME
-* ib_eec_opts_t
-*
-* DESCRIPTION
-* Optional fields supplied in the modify EEC operation.
-*
-* SYNOPSIS
-*/
-typedef uint32_t ib_eec_opts_t;
-#define IB_MOD_EEC_ALTERNATE_AV 0x00000001
-#define IB_MOD_EEC_PKEY 0x00000002
-#define IB_MOD_EEC_APM_STATE 0x00000004
-#define IB_MOD_EEC_PRIMARY_AV 0x00000008
-#define IB_MOD_EEC_RNR 0x00000010
-#define IB_MOD_EEC_RESP_RES 0x00000020
-#define IB_MOD_EEC_OUTSTANDING 0x00000040
-#define IB_MOD_EEC_PRIMARY_PORT 0x00000080
-/*
-* NOTES
-*
-*
-*****/
-
-/****s* Access Layer/ib_eec_mod_t
-* NAME
-* ib_eec_mod_t
-*
-* DESCRIPTION
-* Information needed to change the state of an end-to-end context through
-* the ib_modify_eec function.
-*
-* SYNOPSIS
-*/
-typedef struct _ib_eec_mod {
- ib_qp_state_t req_state;
-
- union _eec_state {
- struct _eec_init {
- uint8_t primary_port;
- uint16_t pkey_index;
-
- } init;
-
- struct _eec_rtr {
- ib_net32_t rq_psn;
- ib_net32_t remote_eecn;
- ib_av_attr_t primary_av;
- uint8_t resp_res;
-
- ib_eec_opts_t opts;
- ib_av_attr_t alternate_av;
- uint16_t pkey_index;
-
- } rtr;
-
- struct _eec_rts {
- ib_net32_t sq_psn;
- uint8_t retry_cnt;
- uint8_t rnr_retry_cnt;
- uint8_t local_ack_timeout;
- uint8_t init_depth;
-
- ib_eec_opts_t opts;
- ib_av_attr_t alternate_av;
- ib_apm_state_t apm_state;
-
- ib_av_attr_t primary_av;
- uint16_t pkey_index;
- uint8_t primary_port;
-
- } rts;
-
- struct _eec_sqd {
- boolean_t sqd_event;
-
- } sqd;
-
- } state;
-
-} ib_eec_mod_t;
-/*
-* SEE ALSO
-* ib_qp_state_t, ib_av_attr_t, ib_apm_state_t
-*****/
-
-/****d* Access Layer/ib_wr_type_t
-* NAME
-* ib_wr_type_t
-*
-* DESCRIPTION
-* Identifies the type of work request posted to a queue pair.
-*
-* SYNOPSIS
-*/
-typedef enum _ib_wr_type_t {
- WR_SEND = 1,
- WR_RDMA_WRITE,
- WR_RDMA_READ,
- WR_COMPARE_SWAP,
- WR_FETCH_ADD
-} ib_wr_type_t;
-/*****/
-
-/****s* Access Layer/ib_local_ds_t
-* NAME
-* ib_local_ds_t
-*
-* DESCRIPTION
-* Local data segment information referenced by send and receive work
-* requests. This is used to specify local data buffers used as part of a
-* work request.
-*
-* SYNOPSIS
-*/
-typedef struct _ib_local_ds {
- void *vaddr;
- uint32_t length;
- uint32_t lkey;
-
-} ib_local_ds_t;
-/*****/
-
-/****d* Access Layer/ib_send_opt_t
-* NAME
-* ib_send_opt_t
-*
-* DESCRIPTION
-* Optional flags used when posting send work requests. These flags
-* indicate specific processing for the send operation.
-*
-* SYNOPSIS
-*/
-typedef uint32_t ib_send_opt_t;
-#define IB_SEND_OPT_IMMEDIATE 0x00000001
-#define IB_SEND_OPT_FENCE 0x00000002
-#define IB_SEND_OPT_SIGNALED 0x00000004
-#define IB_SEND_OPT_SOLICITED 0x00000008
-#define IB_SEND_OPT_INLINE 0x00000010
-#define IB_SEND_OPT_LOCAL 0x00000020
-#define IB_SEND_OPT_VEND_MASK 0xFFFF0000
-/*
-* VALUES
-* The following flags determine the behavior of a work request when
-* posted to the send side.
-*
-* IB_SEND_OPT_IMMEDIATE
-* Send immediate data with the given request.
-*
-* IB_SEND_OPT_FENCE
-* The operation is fenced. Complete all pending send operations
-* before processing this request.
-*
-* IB_SEND_OPT_SIGNALED
-* If the queue pair is configured for signaled completion, then
-* generate a completion queue entry when this request completes.
-*
-* IB_SEND_OPT_SOLICITED
-* Set the solicited bit on the last packet of this request.
-*
-* IB_SEND_OPT_INLINE
-* Indicates that the requested send data should be copied into a VPD
-* owned data buffer. This flag permits the user to issue send operations
-* without first needing to register the buffer(s) associated with the
-* send operation. Verb providers that support this operation may place
-* vendor specific restrictions on the size of send operation that may
-* be performed as inline.
-*
-*
-* IB_SEND_OPT_LOCAL
-* Indicates that a sent MAD request should be given to the local VPD for
-* processing. MADs sent using this option are not placed on the wire.
-* This send option is only valid for MAD send operations.
-*
-*
-* IB_SEND_OPT_VEND_MASK
-* This mask indicates bits reserved in the send options that may be used
-* by the verbs provider to indicate vendor specific options. Bits set
-* in this area of the send options are ignored by the Access Layer, but
-* may have specific meaning to the underlying VPD.
-*
-*****/
-
-/****s* Access Layer/ib_send_wr_t
-* NAME
-* ib_send_wr_t
-*
-* DESCRIPTION
-* Information used to submit a work request to the send queue of a queue
-* pair.
-*
-* SYNOPSIS
-*/
-typedef struct _ib_send_wr {
- struct _ib_send_wr *p_next;
- uint64_t wr_id;
- ib_wr_type_t wr_type;
- ib_send_opt_t send_opt;
- uint32_t num_ds;
- ib_local_ds_t *ds_array;
- ib_net32_t immediate_data;
-
- union _send_dgrm {
- struct _send_ud {
- ib_net32_t remote_qp;
- ib_net32_t remote_qkey;
- ib_av_handle_t h_av;
-
- } ud;
-
- struct _send_rd {
- ib_net32_t remote_qp;
- ib_net32_t remote_qkey;
- ib_net32_t eecn;
-
- } rd;
-
- struct _send_raw_ether {
- ib_net16_t dest_lid;
- uint8_t path_bits;
- uint8_t sl;
- uint8_t max_static_rate;
- ib_net16_t ether_type;
-
- } raw_ether;
-
- struct _send_raw_ipv6 {
- ib_net16_t dest_lid;
- uint8_t path_bits;
- uint8_t sl;
- uint8_t max_static_rate;
-
- } raw_ipv6;
-
- } dgrm;
-
- struct _send_remote_ops {
- uint64_t vaddr;
- uint32_t rkey;
-
- ib_net64_t atomic1;
- ib_net64_t atomic2;
-
- } remote_ops;
-
-} ib_send_wr_t;
-/*
-* FIELDS
-* p_next
-* A pointer used to chain work requests together. This permits multiple
-* work requests to be posted to a queue pair through a single function
-* call. This value is set to NULL to mark the end of the chain.
-*
-* wr_id
-* A 64-bit work request identifier that is returned to the consumer
-* as part of the work completion.
-*
-* wr_type
-* The type of work request being submitted to the send queue.
-*
-* send_opt
-* Optional send control parameters.
-*
-* num_ds
-* Number of local data segments specified by this work request.
-*
-* ds_array
-* A reference to an array of local data segments used by the send
-* operation.
-*
-* immediate_data
-* 32-bit field sent as part of a message send or RDMA write operation.
-* This field is only valid if the send_opt flag IB_SEND_OPT_IMMEDIATE
-* has been set.
-*
-* dgrm.ud.remote_qp
-* Identifies the destination queue pair of an unreliable datagram send
-* operation.
-*
-* dgrm.ud.remote_qkey
-* The qkey for the destination queue pair.
-*
-* dgrm.ud.h_av
-* An address vector that specifies the path information used to route
-* the outbound datagram to the destination queue pair.
-*
-* dgrm.rd.remote_qp
-* Identifies the destination queue pair of a reliable datagram send
-* operation.
-*
-* dgrm.rd.remote_qkey
-* The qkey for the destination queue pair.
-*
-* dgrm.rd.eecn
-* The local end-to-end context number to use with the reliable datagram
-* send operation.
-*
-* dgrm.raw_ether.dest_lid
-* The destination LID that will receive this raw ether send.
-*
-* dgrm.raw_ether.path_bits
-* path bits...
-*
-* dgrm.raw_ether.sl
-* service level...
-*
-* dgrm.raw_ether.max_static_rate
-* static rate...
-*
-* dgrm.raw_ether.ether_type
-* ether type...
-*
-* dgrm.raw_ipv6.dest_lid
-* The destination LID that will receive this raw ether send.
-*
-* dgrm.raw_ipv6.path_bits
-* path bits...
-*
-* dgrm.raw_ipv6.sl
-* service level...
-*
-* dgrm.raw_ipv6.max_static_rate
-* static rate...
-*
-* remote_ops.vaddr
-* The registered virtual memory address of the remote memory to access
-* with an RDMA or atomic operation.
-*
-* remote_ops.rkey
-* The rkey associated with the specified remote vaddr. This data must
-* be presented exactly as obtained from the remote node. No swapping
-* of data must be performed.
-*
-* atomic1
-* The first operand for an atomic operation.
-*
-* atomic2
-* The second operand for an atomic operation.
-*
-* NOTES
-* The format of data sent over the fabric is user-defined and is considered
-* opaque to the access layer. The sole exception to this are MADs posted
-* to a MAD QP service. MADs are expected to match the format defined by
-* the Infiniband specification and must be in network-byte order when posted
-* to the MAD QP service.
-*
-* SEE ALSO
-* ib_wr_type_t, ib_local_ds_t, ib_send_opt_t
-*****/
-
-/****s* Access Layer/ib_recv_wr_t
-* NAME
-* ib_recv_wr_t
-*
-* DESCRIPTION
-* Information used to submit a work request to the receive queue of a queue
-* pair.
-*
-* SYNOPSIS
-*/
-typedef struct _ib_recv_wr {
- struct _ib_recv_wr *p_next;
- uint64_t wr_id;
- uint32_t num_ds;
- ib_local_ds_t *ds_array;
-} ib_recv_wr_t;
-/*
-* FIELDS
-* p_next
-* A pointer used to chain work requests together. This permits multiple
-* work requests to be posted to a queue pair through a single function
-* call. This value is set to NULL to mark the end of the chain.
-*
-* wr_id
-* A 64-bit work request identifier that is returned to the consumer
-* as part of the work completion.
-*
-* num_ds
-* Number of local data segments specified by this work request.
-*
-* ds_array
-* A reference to an array of local data segments used by the send
-* operation.
-*
-* SEE ALSO
-* ib_local_ds_t
-*****/
-
-/****s* Access Layer/ib_bind_wr_t
-* NAME
-* ib_bind_wr_t
-*
-* DESCRIPTION
-* Information used to submit a memory window bind work request to the send
-* queue of a queue pair.
-*
-* SYNOPSIS
-*/
-typedef struct _ib_bind_wr {
- uint64_t wr_id;
- ib_send_opt_t send_opt;
-
- ib_mr_handle_t h_mr;
- ib_access_t access_ctrl;
- uint32_t current_rkey;
-
- ib_local_ds_t local_ds;
-
-} ib_bind_wr_t;
-/*
-* FIELDS
-* wr_id
-* A 64-bit work request identifier that is returned to the consumer
-* as part of the work completion.
-*
-* send_opt
-* Optional send control parameters.
-*
-* h_mr
-* Handle to the memory region to which this window is being bound.
-*
-* access_ctrl
-* Access rights for this memory window.
-*
-* current_rkey
-* The current rkey assigned to this window for remote access.
-*
-* local_ds
-* A reference to a local data segment used by the bind operation.
-*
-* SEE ALSO
-* ib_send_opt_t, ib_access_t, ib_local_ds_t
-*****/
-
-/****d* Access Layer/ib_wc_status_t
-* NAME
-* ib_wc_status_t
-*
-* DESCRIPTION
-* Indicates the status of a completed work request. These VALUES are
-* returned to the user when retrieving completions. Note that success is
-* identified as IB_WCS_SUCCESS, which is always zero.
-*
-* SYNOPSIS
-*/
-typedef enum _ib_wc_status_t {
- IB_WCS_SUCCESS,
- IB_WCS_LOCAL_LEN_ERR,
- IB_WCS_LOCAL_OP_ERR,
- IB_WCS_LOCAL_EEC_OP_ERR,
- IB_WCS_LOCAL_PROTECTION_ERR,
- IB_WCS_WR_FLUSHED_ERR,
- IB_WCS_MEM_WINDOW_BIND_ERR,
- IB_WCS_REM_ACCESS_ERR,
- IB_WCS_REM_OP_ERR,
- IB_WCS_RNR_RETRY_ERR,
- IB_WCS_TIMEOUT_RETRY_ERR,
- IB_WCS_REM_INVALID_REQ_ERR,
- IB_WCS_REM_INVALID_RD_REQ_ERR,
- IB_WCS_INVALID_EECN,
- IB_WCS_INVALID_EEC_STATE,
- IB_WCS_UNMATCHED_RESPONSE, /* InfiniBand Access Layer */
- IB_WCS_CANCELED, /* InfiniBand Access Layer */
- IB_WCS_UNKNOWN /* Must be last. */
-} ib_wc_status_t;
-/*
-* VALUES
-* IB_WCS_SUCCESS
-* Work request completed successfully.
-*
-* IB_WCS_MAD
-* The completed work request was associated with a managmenet datagram
-* that requires post processing. The MAD will be returned to the user
-* through a callback once all post processing has completed.
-*
-* IB_WCS_LOCAL_LEN_ERR
-* Generated for a work request posted to the send queue when the
-* total of the data segment lengths exceeds the message length of the
-* channel. Generated for a work request posted to the receive queue when
-* the total of the data segment lengths is too small for a
-* valid incoming message.
-*
-* IB_WCS_LOCAL_OP_ERR
-* An internal QP consistency error was generated while processing this
-* work request. This may indicate that the QP was in an incorrect state
-* for the requested operation.
-*
-* IB_WCS_LOCAL_EEC_OP_ERR
-* An internal EEC consistency error was generated while processing
-* this work request. This may indicate that the EEC was in an incorrect
-* state for the requested operation.
-*
-* IB_WCS_LOCAL_PROTECTION_ERR
-* The data segments of the locally posted work request did not refer to
-* a valid memory region. The memory may not have been properly
-* registered for the requested operation.
-*
-* IB_WCS_WR_FLUSHED_ERR
-* The work request was flushed from the QP before being completed.
-*
-* IB_WCS_MEM_WINDOW_BIND_ERR
-* A memory window bind operation failed due to insufficient access
-* rights.
-*
-* IB_WCS_REM_ACCESS_ERR,
-* A protection error was detected at the remote node for a RDMA or atomic
-* operation.
-*
-* IB_WCS_REM_OP_ERR,
-* The operation could not be successfully completed at the remote node.
-* This may indicate that the remote QP was in an invalid state or
-* contained an invalid work request.
-*
-* IB_WCS_RNR_RETRY_ERR,
-* The RNR retry count was exceeded while trying to send this message.
-*
-* IB_WCS_TIMEOUT_RETRY_ERR
-* The local transport timeout counter expired while trying to send this
-* message.
-*
-* IB_WCS_REM_INVALID_REQ_ERR,
-* The remote node detected an invalid message on the channel. This error
-* is usually a result of one of the following:
-* - The operation was not supported on receive queue.
-* - There was insufficient buffers to receive a new RDMA request.
-* - There was insufficient buffers to receive a new atomic operation.
-* - An RDMA request was larger than 2^31 bytes.
-*
-* IB_WCS_REM_INVALID_RD_REQ_ERR,
-* Responder detected an invalid RD message. This may be the result of an
-* invalid qkey or an RDD mismatch.
-*
-* IB_WCS_INVALID_EECN
-* An invalid EE context number was detected.
-*
-* IB_WCS_INVALID_EEC_STATE
-* The EEC was in an invalid state for the specified request.
-*
-* IB_WCS_UNMATCHED_RESPONSE
-* A response MAD was received for which there was no matching send. The
-* send operation may have been canceled by the user or may have timed
-* out.
-*
-* IB_WCS_CANCELED
-* The completed work request was canceled by the user.
-*****/
-
-OSM_EXPORT const char *ib_wc_status_str[];
-
-/****f* IBA Base: Types/ib_get_wc_status_str
-* NAME
-* ib_get_wc_status_str
-*
-* DESCRIPTION
-* Returns a string for the specified work completion status.
-*
-* SYNOPSIS
-*/
-static inline const char *OSM_API
-ib_get_wc_status_str(IN ib_wc_status_t wc_status)
-{
- if (wc_status > IB_WCS_UNKNOWN)
- wc_status = IB_WCS_UNKNOWN;
- return (ib_wc_status_str[wc_status]);
-}
-
-/*
-* PARAMETERS
-* wc_status
-* [in] work completion status value
-*
-* RETURN VALUES
-* Pointer to the work completion status description string.
-*
-* NOTES
-*
-* SEE ALSO
-*********/
-
-/****d* Access Layer/ib_wc_type_t
-* NAME
-* ib_wc_type_t
-*
-* DESCRIPTION
-* Indicates the type of work completion.
-*
-* SYNOPSIS
-*/
-typedef enum _ib_wc_type_t {
- IB_WC_SEND,
- IB_WC_RDMA_WRITE,
- IB_WC_RECV,
- IB_WC_RDMA_READ,
- IB_WC_MW_BIND,
- IB_WC_FETCH_ADD,
- IB_WC_COMPARE_SWAP,
- IB_WC_RECV_RDMA_WRITE
-} ib_wc_type_t;
-/*****/
-
-/****d* Access Layer/ib_recv_opt_t
-* NAME
-* ib_recv_opt_t
-*
-* DESCRIPTION
-* Indicates optional fields valid in a receive work completion.
-*
-* SYNOPSIS
-*/
-typedef uint32_t ib_recv_opt_t;
-#define IB_RECV_OPT_IMMEDIATE 0x00000001
-#define IB_RECV_OPT_FORWARD 0x00000002
-#define IB_RECV_OPT_GRH_VALID 0x00000004
-#define IB_RECV_OPT_VEND_MASK 0xFFFF0000
-/*
-* VALUES
-* IB_RECV_OPT_IMMEDIATE
-* Indicates that immediate data is valid for this work completion.
-*
-* IB_RECV_OPT_FORWARD
-* Indicates that the received trap should be forwarded to the SM.
-*
-* IB_RECV_OPT_GRH_VALID
-* Indicates presence of the global route header. When set, the
-* first 40 bytes received are the GRH.
-*
-* IB_RECV_OPT_VEND_MASK
-* This mask indicates bits reserved in the receive options that may be
-* used by the verbs provider to indicate vendor specific options. Bits
-* set in this area of the receive options are ignored by the Access Layer,
-* but may have specific meaning to the underlying VPD.
-*****/
-
-/****s* Access Layer/ib_wc_t
-* NAME
-* ib_wc_t
-*
-* DESCRIPTION
-* Work completion information.
-*
-* SYNOPSIS
-*/
-typedef struct _ib_wc {
- struct _ib_wc *p_next;
- uint64_t wr_id;
- ib_wc_type_t wc_type;
-
- uint32_t length;
- ib_wc_status_t status;
- uint64_t vendor_specific;
-
- union _wc_recv {
- struct _wc_conn {
- ib_recv_opt_t recv_opt;
- ib_net32_t immediate_data;
-
- } conn;
-
- struct _wc_ud {
- ib_recv_opt_t recv_opt;
- ib_net32_t immediate_data;
- ib_net32_t remote_qp;
- uint16_t pkey_index;
- ib_net16_t remote_lid;
- uint8_t remote_sl;
- uint8_t path_bits;
-
- } ud;
-
- struct _wc_rd {
- ib_net32_t remote_eecn;
- ib_net32_t remote_qp;
- ib_net16_t remote_lid;
- uint8_t remote_sl;
- uint32_t free_cnt;
-
- } rd;
-
- struct _wc_raw_ipv6 {
- ib_net16_t remote_lid;
- uint8_t remote_sl;
- uint8_t path_bits;
-
- } raw_ipv6;
-
- struct _wc_raw_ether {
- ib_net16_t remote_lid;
- uint8_t remote_sl;
- uint8_t path_bits;
- ib_net16_t ether_type;
-
- } raw_ether;
-
- } recv;
-
-} ib_wc_t;
-/*
-* FIELDS
-* p_next
-* A pointer used to chain work completions. This permits multiple
-* work completions to be retrieved from a completion queue through a
-* single function call. This value is set to NULL to mark the end of
-* the chain.
-*
-* wr_id
-* The 64-bit work request identifier that was specified when posting the
-* work request.
-*
-* wc_type
-* Indicates the type of work completion.
-*
-*
-* length
-* The total length of the data sent or received with the work request.
-*
-* status
-* The result of the work request.
-*
-* vendor_specific
-* HCA vendor specific information returned as part of the completion.
-*
-* recv.conn.recv_opt
-* Indicates optional fields valid as part of a work request that
-* completed on a connected (reliable or unreliable) queue pair.
-*
-* recv.conn.immediate_data
-* 32-bit field received as part of an inbound message on a connected
-* queue pair. This field is only valid if the recv_opt flag
-* IB_RECV_OPT_IMMEDIATE has been set.
-*
-* recv.ud.recv_opt
-* Indicates optional fields valid as part of a work request that
-* completed on an unreliable datagram queue pair.
-*
-* recv.ud.immediate_data
-* 32-bit field received as part of an inbound message on a unreliable
-* datagram queue pair. This field is only valid if the recv_opt flag
-* IB_RECV_OPT_IMMEDIATE has been set.
-*
-* recv.ud.remote_qp
-* Identifies the source queue pair of a received datagram.
-*
-* recv.ud.pkey_index
-* The pkey index for the source queue pair. This is valid only for
-* GSI type QP's.
-*
-* recv.ud.remote_lid
-* The source LID of the received datagram.
-*
-* recv.ud.remote_sl
-* The service level used by the source of the received datagram.
-*
-* recv.ud.path_bits
-* path bits...
-*
-* recv.rd.remote_eecn
-* The remote end-to-end context number that sent the received message.
-*
-* recv.rd.remote_qp
-* Identifies the source queue pair of a received message.
-*
-* recv.rd.remote_lid
-* The source LID of the received message.
-*
-* recv.rd.remote_sl
-* The service level used by the source of the received message.
-*
-* recv.rd.free_cnt
-* The number of available entries in the completion queue. Reliable
-* datagrams may complete out of order, so this field may be used to
-* determine the number of additional completions that may occur.
-*
-* recv.raw_ipv6.remote_lid
-* The source LID of the received message.
-*
-* recv.raw_ipv6.remote_sl
-* The service level used by the source of the received message.
-*
-* recv.raw_ipv6.path_bits
-* path bits...
-*
-* recv.raw_ether.remote_lid
-* The source LID of the received message.
-*
-* recv.raw_ether.remote_sl
-* The service level used by the source of the received message.
-*
-* recv.raw_ether.path_bits
-* path bits...
-*
-* recv.raw_ether.ether_type
-* ether type...
-* NOTES
-* When the work request completes with error, the only values that the
-* consumer can depend on are the wr_id field, and the status of the
-* operation.
-*
-* If the consumer is using the same CQ for completions from more than
-* one type of QP (i.e Reliable Connected, Datagram etc), then the consumer
-* must have additional information to decide what fields of the union are
-* valid.
-* SEE ALSO
-* ib_wc_type_t, ib_qp_type_t, ib_wc_status_t, ib_recv_opt_t
-*****/
-
-/****s* Access Layer/ib_mr_create_t
-* NAME
-* ib_mr_create_t
-*
-* DESCRIPTION
-* Information required to create a registered memory region.
-*
-* SYNOPSIS
-*/
-typedef struct _ib_mr_create {
- void *vaddr;
- uint64_t length;
- ib_access_t access_ctrl;
-} ib_mr_create_t;
-/*
-* FIELDS
-* vaddr
-* Starting virtual address of the region being registered.
-*
-* length
-* Length of the buffer to register.
-*
-* access_ctrl
-* Access rights of the registered region.
-*
-* SEE ALSO
-* ib_access_t
-*****/
-
-/****s* Access Layer/ib_phys_create_t
-* NAME
-* ib_phys_create_t
-*
-* DESCRIPTION
-* Information required to create a physical memory region.
-*
-* SYNOPSIS
-*/
-typedef struct _ib_phys_create {
- uint64_t length;
- uint32_t num_bufs;
- uint64_t *buf_array;
- uint32_t buf_offset;
- uint32_t page_size;
- ib_access_t access_ctrl;
-} ib_phys_create_t;
-/*
-* length
-* The length of the memory region in bytes.
-*
-* num_bufs
-* Number of buffers listed in the specified buffer array.
-*
-* buf_array
-* An array of physical buffers to be registered as a single memory
-* region.
-*
-* buf_offset
-* The offset into the first physical page of the specified memory
-* region to start the virtual address.
-*
-* page_size
-* The physical page size of the memory being registered.
-*
-* access_ctrl
-* Access rights of the registered region.
-*
-* SEE ALSO
-* ib_access_t
-*****/
-
-/****s* Access Layer/ib_mr_attr_t
-* NAME
-* ib_mr_attr_t
-*
-* DESCRIPTION
-* Attributes of a registered memory region.
-*
-* SYNOPSIS
-*/
-typedef struct _ib_mr_attr {
- ib_pd_handle_t h_pd;
- void *local_lb;
- void *local_ub;
- void *remote_lb;
- void *remote_ub;
- ib_access_t access_ctrl;
- uint32_t lkey;
- uint32_t rkey;
-} ib_mr_attr_t;
-/*
-* DESCRIPTION
-* h_pd
-* Handle to the protection domain for this memory region.
-*
-* local_lb
-* The virtual address of the lower bound of protection for local
-* memory access.
-*
-* local_ub
-* The virtual address of the upper bound of protection for local
-* memory access.
-*
-* remote_lb
-* The virtual address of the lower bound of protection for remote
-* memory access.
-*
-* remote_ub
-* The virtual address of the upper bound of protection for remote
-* memory access.
-*
-* access_ctrl
-* Access rights for the specified memory region.
-*
-* lkey
-* The lkey associated with this memory region.
-*
-* rkey
-* The rkey associated with this memory region.
-*
-* NOTES
-* The remote_lb, remote_ub, and rkey are only valid if remote memory access
-* is enabled for this memory region.
-*
-* SEE ALSO
-* ib_access_t
-*****/
-
-/****d* Access Layer/ib_ca_mod_t
-* NAME
-* ib_ca_mod_t -- Modify port attributes and error counters
-*
-* DESCRIPTION
-* Specifies modifications to the port attributes of a channel adapter.
-*
-* SYNOPSIS
-*/
-typedef uint32_t ib_ca_mod_t;
-#define IB_CA_MOD_IS_CM_SUPPORTED 0x00000001
-#define IB_CA_MOD_IS_SNMP_SUPPORTED 0x00000002
-#define IB_CA_MOD_IS_DEV_MGMT_SUPPORTED 0x00000004
-#define IB_CA_MOD_IS_VEND_SUPPORTED 0x00000008
-#define IB_CA_MOD_IS_SM 0x00000010
-#define IB_CA_MOD_IS_SM_DISABLED 0x00000020
-#define IB_CA_MOD_QKEY_CTR 0x00000040
-#define IB_CA_MOD_PKEY_CTR 0x00000080
-#define IB_CA_MOD_IS_NOTICE_SUPPORTED 0x00000100
-#define IB_CA_MOD_IS_TRAP_SUPPORTED 0x00000200
-#define IB_CA_MOD_IS_APM_SUPPORTED 0x00000400
-#define IB_CA_MOD_IS_SLMAP_SUPPORTED 0x00000800
-#define IB_CA_MOD_IS_PKEY_NVRAM_SUPPORTED 0x00001000
-#define IB_CA_MOD_IS_MKEY_NVRAM_SUPPORTED 0x00002000
-#define IB_CA_MOD_IS_SYSGUID_SUPPORTED 0x00004000
-#define IB_CA_MOD_IS_DR_NOTICE_SUPPORTED 0x00008000
-#define IB_CA_MOD_IS_BOOT_MGMT_SUPPORTED 0x00010000
-#define IB_CA_MOD_IS_CAPM_NOTICE_SUPPORTED 0x00020000
-#define IB_CA_MOD_IS_REINIT_SUPORTED 0x00040000
-#define IB_CA_MOD_IS_LEDINFO_SUPPORTED 0x00080000
-#define IB_CA_MOD_SHUTDOWN_PORT 0x00100000
-#define IB_CA_MOD_INIT_TYPE_VALUE 0x00200000
-#define IB_CA_MOD_SYSTEM_IMAGE_GUID 0x00400000
-/*
-* VALUES
-* IB_CA_MOD_IS_CM_SUPPORTED
-* Indicates if there is a communication manager accessible through
-* the port.
-*
-* IB_CA_MOD_IS_SNMP_SUPPORTED
-* Indicates if there is an SNMP agent accessible through the port.
-*
-* IB_CA_MOD_IS_DEV_MGMT_SUPPORTED
-* Indicates if there is a device management agent accessible
-* through the port.
-*
-* IB_CA_MOD_IS_VEND_SUPPORTED
-* Indicates if there is a vendor supported agent accessible
-* through the port.
-*
-* IB_CA_MOD_IS_SM
-* Indicates if there is a subnet manager accessible through
-* the port.
-*
-* IB_CA_MOD_IS_SM_DISABLED
-* Indicates if the port has been disabled for configuration by the
-* subnet manager.
-*
-* IB_CA_MOD_QKEY_CTR
-* Used to reset the qkey violation counter associated with the
-* port.
-*
-* IB_CA_MOD_PKEY_CTR
-* Used to reset the pkey violation counter associated with the
-* port.
-*
-* IB_CA_MOD_IS_NOTICE_SUPPORTED
-* Indicates that this CA supports ability to generate Notices for
-* Port State changes. (only applicable to switches)
-*
-* IB_CA_MOD_IS_TRAP_SUPPORTED
-* Indicates that this management port supports ability to generate
-* trap messages. (only applicable to switches)
-*
-* IB_CA_MOD_IS_APM_SUPPORTED
-* Indicates that this port is capable of performing Automatic
-* Path Migration.
-*
-* IB_CA_MOD_IS_SLMAP_SUPPORTED
-* Indicates this port supports SLMAP capability.
-*
-* IB_CA_MOD_IS_PKEY_NVRAM_SUPPORTED
-* Indicates that PKEY is supported in NVRAM
-*
-* IB_CA_MOD_IS_MKEY_NVRAM_SUPPORTED
-* Indicates that MKEY is supported in NVRAM
-*
-* IB_CA_MOD_IS_SYSGUID_SUPPORTED
-* Indicates System Image GUID support.
-*
-* IB_CA_MOD_IS_DR_NOTICE_SUPPORTED
-* Indicate support for generating Direct Routed Notices
-*
-* IB_CA_MOD_IS_BOOT_MGMT_SUPPORTED
-* Indicates support for Boot Management
-*
-* IB_CA_MOD_IS_CAPM_NOTICE_SUPPORTED
-* Indicates capability to generate notices for changes to CAPMASK
-*
-* IB_CA_MOD_IS_REINIT_SUPORTED
-* Indicates type of node init supported. Refer to Chapter 14 for
-* Initialization actions.
-*
-* IB_CA_MOD_IS_LEDINFO_SUPPORTED
-* Indicates support for LED info.
-*
-* IB_CA_MOD_SHUTDOWN_PORT
-* Used to modify the port active indicator.
-*
-* IB_CA_MOD_INIT_TYPE_VALUE
-* Used to modify the init_type value for the port.
-*
-* IB_CA_MOD_SYSTEM_IMAGE_GUID
-* Used to modify the system image GUID for the port.
-*****/
-
-/****d* Access Layer/ib_mr_mod_t
-* NAME
-* ib_mr_mod_t
-*
-* DESCRIPTION
-* Mask used to specify which attributes of a registered memory region are
-* being modified.
-*
-* SYNOPSIS
-*/
-typedef uint32_t ib_mr_mod_t;
-#define IB_MR_MOD_ADDR 0x00000001
-#define IB_MR_MOD_PD 0x00000002
-#define IB_MR_MOD_ACCESS 0x00000004
-/*
-* PARAMETERS
-* IB_MEM_MOD_ADDR
-* The address of the memory region is being modified.
-*
-* IB_MEM_MOD_PD
-* The protection domain associated with the memory region is being
-* modified.
-*
-* IB_MEM_MOD_ACCESS
-* The access rights the memory region are being modified.
-*****/
-
-/****d* IBA Base: Constants/IB_SMINFO_ATTR_MOD_HANDOVER
-* NAME
-* IB_SMINFO_ATTR_MOD_HANDOVER
-*
-* DESCRIPTION
-* Encoded attribute modifier value used on SubnSet(SMInfo) SMPs.
-*
-* SOURCE
-*/
-#define IB_SMINFO_ATTR_MOD_HANDOVER (CL_HTON32(0x000001))
-/**********/
-
-/****d* IBA Base: Constants/IB_SMINFO_ATTR_MOD_ACKNOWLEDGE
-* NAME
-* IB_SMINFO_ATTR_MOD_ACKNOWLEDGE
-*
-* DESCRIPTION
-* Encoded attribute modifier value used on SubnSet(SMInfo) SMPs.
-*
-* SOURCE
-*/
-#define IB_SMINFO_ATTR_MOD_ACKNOWLEDGE (CL_HTON32(0x000002))
-/**********/
-
-/****d* IBA Base: Constants/IB_SMINFO_ATTR_MOD_DISABLE
-* NAME
-* IB_SMINFO_ATTR_MOD_DISABLE
-*
-* DESCRIPTION
-* Encoded attribute modifier value used on SubnSet(SMInfo) SMPs.
-*
-* SOURCE
-*/
-#define IB_SMINFO_ATTR_MOD_DISABLE (CL_HTON32(0x000003))
-/**********/
-
-/****d* IBA Base: Constants/IB_SMINFO_ATTR_MOD_STANDBY
-* NAME
-* IB_SMINFO_ATTR_MOD_STANDBY
-*
-* DESCRIPTION
-* Encoded attribute modifier value used on SubnSet(SMInfo) SMPs.
-*
-* SOURCE
-*/
-#define IB_SMINFO_ATTR_MOD_STANDBY (CL_HTON32(0x000004))
-/**********/
-
-/****d* IBA Base: Constants/IB_SMINFO_ATTR_MOD_DISCOVER
-* NAME
-* IB_SMINFO_ATTR_MOD_DISCOVER
-*
-* DESCRIPTION
-* Encoded attribute modifier value used on SubnSet(SMInfo) SMPs.
-*
-* SOURCE
-*/
-#define IB_SMINFO_ATTR_MOD_DISCOVER (CL_HTON32(0x000005))
-/**********/
-
-/****s* Access Layer/ib_ci_op_t
-* NAME
-* ib_ci_op_t
-*
-* DESCRIPTION
-* A structure used for vendor specific CA interface communication.
-*
-* SYNOPSIS
-*/
-typedef struct _ib_ci_op {
- IN uint32_t command;
- IN OUT void *p_buf OPTIONAL;
- IN uint32_t buf_size;
- IN OUT uint32_t num_bytes_ret;
- IN OUT int32_t status;
-
-} ib_ci_op_t;
-/*
-* FIELDS
-* command
-* A command code that is understood by the verbs provider.
-*
-* p_buf
-* A reference to a buffer containing vendor specific data. The verbs
-* provider must not access pointers in the p_buf between user-mode and
-* kernel-mode. Any pointers embedded in the p_buf are invalidated by
-* the user-mode/kernel-mode transition.
-*
-* buf_size
-* The size of the buffer in bytes.
-*
-* num_bytes_ret
-* The size in bytes of the vendor specific data returned in the buffer.
-* This field is set by the verbs provider. The verbs provider should
-* verify that the buffer size is sufficient to hold the data being
-* returned.
-*
-* status
-* The completion status from the verbs provider. This field should be
-* initialize to indicate an error to allow detection and cleanup in
-* case a communication error occurs between user-mode and kernel-mode.
-*
-* NOTES
-* This structure is provided to allow the exchange of vendor specific
-* data between the originator and the verbs provider. Users of this
-* structure are expected to know the format of data in the p_buf based
-* on the structure command field or the usage context.
-*****/
-
-END_C_DECLS
-#endif /* ndef WIN32 */
-#if defined( __WIN__ )
-#include <iba/ib_types_extended.h>
-#endif
-#endif /* __IB_TYPES_H__ */
diff --git a/contrib/ofed/management/opensm/include/opensm/osm_attrib_req.h b/contrib/ofed/management/opensm/include/opensm/osm_attrib_req.h
deleted file mode 100644
index e79073b..0000000
--- a/contrib/ofed/management/opensm/include/opensm/osm_attrib_req.h
+++ /dev/null
@@ -1,108 +0,0 @@
-/*
- * Copyright (c) 2004, 2005 Voltaire, Inc. All rights reserved.
- * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved.
- * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- */
-
-#ifndef _OSM_ATTRIB_REQ_H_
-#define _OSM_ATTRIB_REQ_H_
-
-#include <opensm/osm_path.h>
-
-#ifdef __cplusplus
-# define BEGIN_C_DECLS extern "C" {
-# define END_C_DECLS }
-#else /* !__cplusplus */
-# define BEGIN_C_DECLS
-# define END_C_DECLS
-#endif /* __cplusplus */
-
-BEGIN_C_DECLS
-/*
- * Abstract:
- * Declaration of the attribute request object. This object
- * encapsulates information needed by the generic request controller
- * to request an attribute from a node.
- * These objects are part of the OpenSM family of objects.
- */
-/****h* OpenSM/Attribute Request
-* NAME
-* Attribute Request
-*
-* DESCRIPTION
-* The Attribute Request structure encapsulates
-* encapsulates information needed by the generic request controller
-* to request an attribute from a node.
-*
-* This structure allows direct access to member variables.
-*
-* AUTHOR
-* Steve King, Intel
-*
-*********/
-/****s* OpenSM: Attribute Request/osm_attrib_req_t
-* NAME
-* osm_attrib_req_t
-*
-* DESCRIPTION
-* Attribute request structure.
-*
-* This structure allows direct access to member variables.
-*
-* SYNOPSIS
-*/
-typedef struct osm_attrib_req {
- uint16_t attrib_id;
- uint32_t attrib_mod;
- osm_madw_context_t context;
- osm_dr_path_t path;
- cl_disp_msgid_t err_msg;
-} osm_attrib_req_t;
-/*
-* FIELDS
-* attrib_id
-* Attribute ID for this request.
-*
-* attrib_mod
-* Attribute modifier for this request.
-*
-* context
-* Context to insert in outbound mad wrapper context.
-*
-* path
-* The directed route path to the node.
-*
-* SEE ALSO
-*********/
-
-END_C_DECLS
-#endif /* _OSM_ATTRIB_REQ_H_ */
diff --git a/contrib/ofed/management/opensm/include/opensm/osm_base.h b/contrib/ofed/management/opensm/include/opensm/osm_base.h
deleted file mode 100644
index 54df41e..0000000
--- a/contrib/ofed/management/opensm/include/opensm/osm_base.h
+++ /dev/null
@@ -1,898 +0,0 @@
-/*
- * Copyright (c) 2004-2008 Voltaire, Inc. All rights reserved.
- * Copyright (c) 2002-2006 Mellanox Technologies LTD. All rights reserved.
- * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- */
-
-/*
- * Abstract:
- * Basic OpenSM definitions and structures.
- * This object represents an OpenSM "base class".
- * This object is part of the OpenSM family of objects.
- */
-
-#ifndef _OSM_BASE_H_
-#define _OSM_BASE_H_
-
-#if HAVE_CONFIG_H
-# include <config.h>
-#endif /* HAVE_CONFIG_H */
-
-#ifdef __WIN__
-#include <vendor/winosm_common.h>
-#define OSM_CDECL __cdecl
-#else
-#define OSM_CDECL
-#endif
-
-#include <complib/cl_types.h>
-
-#ifdef __cplusplus
-# define BEGIN_C_DECLS extern "C" {
-# define END_C_DECLS }
-#else /* !__cplusplus */
-# define BEGIN_C_DECLS
-# define END_C_DECLS
-#endif /* __cplusplus */
-
-BEGIN_C_DECLS
-/****h* OpenSM/Constants
-* NAME
-* Constants
-*
-* DESCRIPTION
-* The following constants are used throughout the OpenSM.
-*
-* AUTHOR
-* Steve King, Intel
-*
-*********/
-/****h* OpenSM/Base
-* NAME
-* Base
-*
-* DESCRIPTION
-* The Base object encapsulates basic information needed by the
-* OpenSM to manage objects. Each OpenSM object includes the
-* Base object as the first member.
-*
-* This object should be treated as opaque and should be
-* manipulated only through the provided functions.
-*
-* AUTHOR
-* Steve King, Intel
-*
-*********/
-/****s* OpenSM: Base/OSM_DEFAULT_M_KEY
-* NAME
-* OSM_DEFAULT_M_KEY
-*
-* DESCRIPTION
-* Managment key value used by the OpenSM.
-*
-* SYNOPSIS
-*/
-#define OSM_DEFAULT_M_KEY 0
-/********/
-/****s* OpenSM: Base/OSM_DEFAULT_SM_KEY
-* NAME
-* OSM_DEFAULT_SM_KEY
-*
-* DESCRIPTION
-* Subnet Manager key value used by the OpenSM.
-*
-* SYNOPSIS
-*/
-#define OSM_DEFAULT_SM_KEY CL_HTON64(1)
-/********/
-/****s* OpenSM: Base/OSM_DEFAULT_SA_KEY
-* NAME
-* OSM_DEFAULT_SA_KEY
-*
-* DESCRIPTION
-* Subnet Adminstration key value.
-*
-* SYNOPSIS
-*/
-#define OSM_DEFAULT_SA_KEY OSM_DEFAULT_SM_KEY
-/********/
-/****s* OpenSM: Base/OSM_DEFAULT_LMC
-* NAME
-* OSM_DEFAULT_LMC
-*
-* DESCRIPTION
-* Default LMC value used by the OpenSM.
-*
-* SYNOPSIS
-*/
-#define OSM_DEFAULT_LMC 0
-/********/
-/****s* OpenSM: Base/OSM_DEFAULT_MAX_OP_VLS
-* NAME
-* OSM_DEFAULT_MAX_OP_VLS
-*
-* DESCRIPTION
-* Default Maximal Operational VLs to be initialized on
-* the link ports PortInfo by the OpenSM.
-* Default value provides backward compatibility.
-*
-* SYNOPSIS
-*/
-#define OSM_DEFAULT_MAX_OP_VLS 5
-/********/
-/****s* OpenSM: Base/OSM_DEFAULT_SL
-* NAME
-* OSM_DEFAULT_SL
-*
-* DESCRIPTION
-* Default SL value used by the OpenSM.
-*
-* SYNOPSIS
-*/
-#define OSM_DEFAULT_SL 0
-/********/
-/****s* OpenSM: Base/OSM_DEFAULT_SM_PRIORITY
-* NAME
-* OSM_DEFAULT_SM_PRIORITY
-*
-* DESCRIPTION
-* Default SM priority value used by the OpenSM,
-* as defined in the SMInfo attribute. 0 is the lowest priority.
-*
-* SYNOPSIS
-*/
-#define OSM_DEFAULT_SM_PRIORITY 0
-/********/
-/****d* OpenSM: Base/OSM_DEFAULT_TMP_DIR
-* NAME
-* OSM_DEFAULT_TMP_DIR
-*
-* DESCRIPTION
-* Specifies the default temporary directory for the log file,
-* osm-subnet.lst, and other log files.
-*
-* SYNOPSIS
-*/
-#ifdef __WIN__
-#define OSM_DEFAULT_TMP_DIR GetOsmTempPath()
-#else
-#define OSM_DEFAULT_TMP_DIR "/var/log/"
-#endif
-/***********/
-/****d* OpenSM: Base/OSM_DEFAULT_CACHE_DIR
-* NAME
-* OSM_DEFAULT_CACHE_DIR
-*
-* DESCRIPTION
-* Specifies the default cache directory for the db files.
-* Note that the directory must appear with "/" ("\\" for windows) at the end.
-*
-* SYNOPSIS
-*/
-#ifdef __WIN__
-#define OSM_DEFAULT_CACHE_DIR GetOsmCachePath()
-#else
-#define OSM_DEFAULT_CACHE_DIR "/var/cache/opensm/"
-#endif
-/***********/
-/****d* OpenSM: Base/OSM_DEFAULT_LOG_FILE
-* NAME
-* OSM_DEFAULT_LOG_FILE
-*
-* DESCRIPTION
-* Specifies the default log file name
-*
-* SYNOPSIS
-*/
-#ifdef __WIN__
-#define OSM_DEFAULT_LOG_FILE strcat(GetOsmTempPath(), "osm.log")
-#else
-#define OSM_DEFAULT_LOG_FILE "/var/log/opensm.log"
-#endif
-/***********/
-
-/****d* OpenSM: Base/OSM_DEFAULT_CONFIG_FILE
-* NAME
-* OSM_DEFAULT_CONFIG_FILE
-*
-* DESCRIPTION
-* Specifies the default OpenSM config file name
-*
-* SYNOPSIS
-*/
-#ifdef __WIN__
-#define OSM_DEFAULT_CONFIG_FILE strcat(GetOsmCachePath(), "opensm.conf")
-#elif defined(HAVE_DEFAULT_OPENSM_CONFIG_FILE)
-#define OSM_DEFAULT_CONFIG_FILE HAVE_DEFAULT_OPENSM_CONFIG_FILE
-#elif defined (OPENSM_CONFIG_DIR)
-#define OSM_DEFAULT_CONFIG_FILE OPENSM_CONFIG_DIR "/opensm.conf"
-#else
-#define OSM_DEFAULT_CONFIG_FILE "/etc/opensm/opensm.conf"
-#endif /* __WIN__ */
-/***********/
-
-/****d* OpenSM: Base/OSM_DEFAULT_PARTITION_CONFIG_FILE
-* NAME
-* OSM_DEFAULT_PARTITION_CONFIG_FILE
-*
-* DESCRIPTION
-* Specifies the default partition config file name
-*
-* SYNOPSIS
-*/
-#ifdef __WIN__
-#define OSM_DEFAULT_PARTITION_CONFIG_FILE strcat(GetOsmCachePath(), "osm-partitions.conf")
-#elif defined(HAVE_DEFAULT_PARTITION_CONFIG_FILE)
-#define OSM_DEFAULT_PARTITION_CONFIG_FILE HAVE_DEFAULT_PARTITION_CONFIG_FILE
-#elif defined(OPENSM_CONFIG_DIR)
-#define OSM_DEFAULT_PARTITION_CONFIG_FILE OPENSM_CONFIG_DIR "/partitions.conf"
-#else
-#define OSM_DEFAULT_PARTITION_CONFIG_FILE "/etc/opensm/partitions.conf"
-#endif /* __WIN__ */
-/***********/
-
-/****d* OpenSM: Base/OSM_DEFAULT_QOS_POLICY_FILE
-* NAME
-* OSM_DEFAULT_QOS_POLICY_FILE
-*
-* DESCRIPTION
-* Specifies the default QoS policy file name
-*
-* SYNOPSIS
-*/
-#ifdef __WIN__
-#define OSM_DEFAULT_QOS_POLICY_FILE strcat(GetOsmCachePath(), "osm-qos-policy.conf")
-#elif defined(HAVE_DEFAULT_QOS_POLICY_FILE)
-#define OSM_DEFAULT_QOS_POLICY_FILE HAVE_DEFAULT_QOS_POLICY_FILE
-#elif defined(OPENSM_CONFIG_DIR)
-#define OSM_DEFAULT_QOS_POLICY_FILE OPENSM_CONFIG_DIR "/qos-policy.conf"
-#else
-#define OSM_DEFAULT_QOS_POLICY_FILE "/etc/opensm/qos-policy.conf"
-#endif /* __WIN__ */
-/***********/
-
-/****d* OpenSM: Base/OSM_DEFAULT_PREFIX_ROUTES_FILE
-* NAME
-* OSM_DEFAULT_PREFIX_ROUTES_FILE
-*
-* DESCRIPTION
-* Specifies the default prefix routes file name
-*
-* SYNOPSIS
-*/
-#ifdef __WIN__
-#define OSM_DEFAULT_PREFIX_ROUTES_FILE strcat(GetOsmCachePath(), "osm-prefix-routes.conf")
-#elif defined(HAVE_DEFAULT_PREFIX_ROUTES_FILE)
-#define OSM_DEFAULT_PREFIX_ROUTES_FILE HAVE_DEFAULT_PREFIX_ROUTES_FILE
-#elif defined(OPENSM_CONFIG_DIR)
-#define OSM_DEFAULT_PREFIX_ROUTES_FILE OPENSM_CONFIG_DIR "/prefix-routes.conf"
-#else
-#define OSM_DEFAULT_PREFIX_ROUTES_FILE "/etc/opensm/prefix-routes.conf"
-#endif
-/***********/
-
-/****d* OpenSM: Base/OSM_DEFAULT_SWEEP_INTERVAL_SECS
-* NAME
-* OSM_DEFAULT_SWEEP_INTERVAL_SECS
-*
-* DESCRIPTION
-* Specifies the default number of seconds between subnet sweeps.
-*
-* SYNOPSIS
-*/
-#define OSM_DEFAULT_SWEEP_INTERVAL_SECS 10
-/***********/
-/****d* OpenSM: Base/OSM_DEFAULT_TRANS_TIMEOUT_MILLISEC
-* NAME
-* OSM_DEFAULT_TRANS_TIMEOUT_MILLISEC
-*
-* DESCRIPTION
-* Specifies the default transaction timeout in milliseconds.
-*
-* SYNOPSIS
-*/
-#define OSM_DEFAULT_TRANS_TIMEOUT_MILLISEC 200
-/***********/
-/****d* OpenSM: Base/OSM_DEFAULT_SUBNET_TIMEOUT
-* NAME
-* OSM_DEFAULT_SUBNET_TIMEOUT
-*
-* DESCRIPTION
-* Specifies the default subnet timeout.
-* timeout time = 4us * 2^timeout.
-* We use here ~1sec.
-*
-* SYNOPSIS
-*/
-#define OSM_DEFAULT_SUBNET_TIMEOUT 0x12
-/***********/
-/****d* OpenSM: Base/OSM_DEFAULT_SWITCH_PACKET_LIFE
-* NAME
-* OSM_DEFAULT_SWITCH_PACKET_LIFE
-*
-* DESCRIPTION
-* Specifies the default max life time for a pcket on the switch.
-* timeout time = 4us * 2^timeout.
-* We use here the value of ~1sec
-* A Value > 19dec disables this mechanism.
-*
-* SYNOPSIS
-*/
-#define OSM_DEFAULT_SWITCH_PACKET_LIFE 0x12
-/***********/
-/****d* OpenSM: Base/OSM_DEFAULT_HEAD_OF_QUEUE_LIFE
-* NAME
-* OSM_DEFAULT_HEAD_OF_QUEUE_LIFE
-*
-* DESCRIPTION
-* Sets the time a packet can live in the head of the VL Queue
-* We use here the value of ~1sec
-* A Value > 19dec disables this mechanism.
-*
-* SYNOPSIS
-*/
-#define OSM_DEFAULT_HEAD_OF_QUEUE_LIFE 0x12
-/***********/
-/****d* OpenSM: Base/OSM_DEFAULT_LEAF_HEAD_OF_QUEUE_LIFE
-* NAME
-* OSM_DEFAULT_LEAF_HEAD_OF_QUEUE_LIFE
-*
-* DESCRIPTION
-* Sets the time a packet can live in the head of the VL Queue
-* of a port that drives a CA port.
-* We use here the value of ~256msec
-*
-* SYNOPSIS
-*/
-#define OSM_DEFAULT_LEAF_HEAD_OF_QUEUE_LIFE 0x10
-/***********/
-/****d* OpenSM: Base/OSM_DEFAULT_VL_STALL_COUNT
-* NAME
-* OSM_DEFAULT_LEAF_VL_COUNT
-*
-* DESCRIPTION
-* Sets the number of consecutive head of queue life time drops that
-* puts the VL into stalled state. In stalled state, the port is supposed
-* to drop everything for 8*(head of queue lifetime)
-*
-* SYNOPSIS
-*/
-#define OSM_DEFAULT_VL_STALL_COUNT 0x7
-/***********/
-/****d* OpenSM: Base/OSM_DEFAULT_LEAF_VL_STALL_COUNT
-* NAME
-* OSM_DEFAULT_LEAF_VL_STALL_COUNT
-*
-* DESCRIPTION
-* Sets the number of consecutive head of queue life time drops that
-* puts the VL into stalled state. In stalled state, the port is supposed
-* to drop everything for 8*(head of queue lifetime). This value is for
-* switch ports driving a CA port.
-*
-* SYNOPSIS
-*/
-#define OSM_DEFAULT_LEAF_VL_STALL_COUNT 0x7
-/***********/
-/****d* OpenSM: Base/OSM_DEFAULT_TRAP_SUPRESSION_TIMEOUT
-* NAME
-* OSM_DEFAULT_TRAP_SUPRESSION_TIMEOUT
-*
-* DESCRIPTION
-* Specifies the default timeout for ignoring same trap.
-* timeout time = 5000000us
-* We use here ~5sec.
-*
-* SYNOPSIS
-*/
-#define OSM_DEFAULT_TRAP_SUPRESSION_TIMEOUT 5000000
-/***********/
-/****d* OpenSM: Base/OSM_DEFAULT_UNHEALTHY_TIMEOUT
-* NAME
-* OSM_DEFAULT_UNHEALTHY_TIMEOUT
-*
-* DESCRIPTION
-* Specifies the default timeout for setting port as unhealthy.
-* timeout time = 60000000us
-* We use here ~60sec.
-*
-* SYNOPSIS
-*/
-#define OSM_DEFAULT_UNHEALTHY_TIMEOUT 60000000
-/***********/
-/****d* OpenSM: Base/OSM_DEFAULT_ERROR_THRESHOLD
-* NAME
-* OSM_DEFAULT_ERROR_THRESHOLD
-*
-* DESCRIPTION
-* Specifies default link error threshold to be set by SubnSet(PortInfo).
-*
-* SYNOPSIS
-*/
-#define OSM_DEFAULT_ERROR_THRESHOLD 0x08
-/***********/
-/****d* OpenSM: Base/OSM_DEFAULT_SMP_MAX_ON_WIRE
-* NAME
-* OSM_DEFAULT_SMP_MAX_ON_WIRE
-*
-* DESCRIPTION
-* Specifies the default number of VL15 SMP MADs allowed on
-* the wire at any one time.
-*
-* SYNOPSIS
-*/
-#define OSM_DEFAULT_SMP_MAX_ON_WIRE 4
-/***********/
-/****d* OpenSM: Base/OSM_SM_DEFAULT_QP0_RCV_SIZE
-* NAME
-* OSM_SM_DEFAULT_QP0_RCV_SIZE
-*
-* DESCRIPTION
-* Specifies the default size (in MADs) of the QP0 receive queue
-*
-* SYNOPSIS
-*/
-#define OSM_SM_DEFAULT_QP0_RCV_SIZE 256
-/***********/
-/****d* OpenSM: Base/OSM_SM_DEFAULT_QP0_SEND_SIZE
-* NAME
-* OSM_SM_DEFAULT_QP0_SEND_SIZE
-*
-* DESCRIPTION
-* Specifies the default size (in MADs) of the QP0 send queue
-*
-* SYNOPSIS
-*/
-#define OSM_SM_DEFAULT_QP0_SEND_SIZE 256
-/***********/
-/****d* OpenSM: Base/OSM_SM_DEFAULT_QP1_RCV_SIZE
-* NAME
-* OSM_SM_DEFAULT_QP1_RCV_SIZE
-*
-* DESCRIPTION
-* Specifies the default size (in MADs) of the QP1 receive queue
-*
-* SYNOPSIS
-*/
-#define OSM_SM_DEFAULT_QP1_RCV_SIZE 256
-/***********/
-/****d* OpenSM: Base/OSM_SM_DEFAULT_QP1_SEND_SIZE
-* NAME
-* OSM_SM_DEFAULT_QP1_SEND_SIZE
-*
-* DESCRIPTION
-* Specifies the default size (in MADs) of the QP1 send queue
-*
-* SYNOPSIS
-*/
-#define OSM_SM_DEFAULT_QP1_SEND_SIZE 256
-/****d* OpenSM: Base/OSM_PM_DEFAULT_QP1_RCV_SIZE
-* NAME
-* OSM_PM_DEFAULT_QP1_RCV_SIZE
-*
-* DESCRIPTION
-* Specifies the default size (in MADs) of the QP1 receive queue
-*
-* SYNOPSIS
-*/
-#define OSM_PM_DEFAULT_QP1_RCV_SIZE 256
-/***********/
-/****d* OpenSM: Base/OSM_PM_DEFAULT_QP1_SEND_SIZE
-* NAME
-* OSM_PM_DEFAULT_QP1_SEND_SIZE
-*
-* DESCRIPTION
-* Specifies the default size (in MADs) of the QP1 send queue
-*
-* SYNOPSIS
-*/
-#define OSM_PM_DEFAULT_QP1_SEND_SIZE 256
-/****d* OpenSM: Base/OSM_SM_DEFAULT_POLLING_TIMEOUT_MILLISECS
-* NAME
-* OSM_SM_DEFAULT_POLLING_TIMEOUT_MILLISECS
-*
-* DESCRIPTION
-* Specifies the polling timeout (in miliseconds) - the timeout
-* between one poll to another.
-*
-* SYNOPSIS
-*/
-#define OSM_SM_DEFAULT_POLLING_TIMEOUT_MILLISECS 10000
-/**********/
-/****d* OpenSM: Base/OSM_SM_DEFAULT_POLLING_RETRY_NUMBER
-* NAME
-* OSM_SM_DEFAULT_POLLING_RETRY_NUMBER
-*
-* DESCRIPTION
-* Specifies the number of polling retries before the SM goes back
-* to DISCOVERY stage. So the default total time for handoff is 40 sec.
-*
-* SYNOPSIS
-*/
-#define OSM_SM_DEFAULT_POLLING_RETRY_NUMBER 4
-/**********/
-/****d* OpenSM: MC Member Record Receiver/OSM_DEFAULT_MGRP_MTU
-* Name
-* OSM_DEFAULT_MGRP_MTU
-*
-* DESCRIPTION
-* Default MTU used for new MGRP creation (2048 bytes)
-* Note it includes the MTUSelector which is set to "Greater Than"
-*
-* SYNOPSIS
-*/
-#define OSM_DEFAULT_MGRP_MTU 0x04
-/***********/
-/****d* OpenSM: MC Member Record Receiver/OSM_DEFAULT_MGRP_RATE
-* Name
-* OSM_DEFAULT_MGRP_RATE
-*
-* DESCRIPTION
-* Default RATE used for new MGRP creation (10Gb/sec)
-* Note it includes the RateSelector which is set to "Greater Than"
-*
-* SYNOPSIS
-*/
-#define OSM_DEFAULT_MGRP_RATE 0x03
-/***********/
-/****d* OpenSM: MC Member Record Receiver/OSM_DEFAULT_MGRP_SCOPE
-* Name
-* OSM_DEFAULT_MGRP_SCOPE
-*
-* DESCRIPTION
-* Default SCOPE used for new MGRP creation (link local)
-*
-* SYNOPSIS
-*/
-#define OSM_DEFAULT_MGRP_SCOPE IB_MC_SCOPE_LINK_LOCAL
-/***********/
-/****d* OpenSM: Base/OSM_DEFAULT_QOS_MAX_VLS
- * Name
- * OSM_DEFAULT_QOS_MAX_VLS
- *
- * DESCRIPTION
- * Default Maximum VLs used by the OpenSM.
- *
- * SYNOPSIS
- */
-#define OSM_DEFAULT_QOS_MAX_VLS 15
-/***********/
-/****d* OpenSM: Base/OSM_DEFAULT_QOS_HIGH_LIMIT
- * Name
- * OSM_DEFAULT_QOS_HIGH_LIMIT
- *
- * DESCRIPTION
- * Default Limit of High Priority in VL Arbitration used by OpenSM.
- *
- * SYNOPSIS
- */
-#define OSM_DEFAULT_QOS_HIGH_LIMIT 0
-/***********/
-/****d* OpenSM: Base/OSM_DEFAULT_QOS_VLARB_HIGH
- * Name
- * OSM_DEFAULT_QOS_VLARB_HIGH
- *
- * DESCRIPTION
- * Default High Priority VL Arbitration table used by the OpenSM.
- *
- * SYNOPSIS
- */
-#define OSM_DEFAULT_QOS_VLARB_HIGH "0:4,1:0,2:0,3:0,4:0,5:0,6:0,7:0,8:0,9:0,10:0,11:0,12:0,13:0,14:0"
-/***********/
-/****d* OpenSM: Base/OSM_DEFAULT_QOS_VLARB_LOW
- * Name
- * OSM_DEFAULT_QOS_VLARB_LOW
- *
- * DESCRIPTION
- * Default Low Priority VL Arbitration table used by the OpenSM.
- *
- * SYNOPSIS
- */
-#define OSM_DEFAULT_QOS_VLARB_LOW "0:0,1:4,2:4,3:4,4:4,5:4,6:4,7:4,8:4,9:4,10:4,11:4,12:4,13:4,14:4"
-/***********/
-/****d* OpenSM: Base/OSM_DEFAULT_QOS_SL2VL
- * Name
- * OSM_DEFAULT_QOS_SL2VL
- *
- * DESCRIPTION
- * Default QoS SL2VL Mapping Table used by the OpenSM.
- *
- * SYNOPSIS
- */
-#define OSM_DEFAULT_QOS_SL2VL "0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,7"
-/***********/
-/****d* OpenSM: Base/OSM_NO_PATH
-* NAME
-* OSM_NO_PATH
-*
-* DESCRIPTION
-* Value indicating there is no path to the given LID.
-*
-* SYNOPSIS
-*/
-#define OSM_NO_PATH 0xFF
-/**********/
-/****d* OpenSM: Base/OSM_NODE_DESC_UNKNOWN
-* NAME
-* OSM_NODE_DESC_UNKNOWN
-*
-* DESCRIPTION
-* Value indicating the Node Description is not set and is "unknown"
-*
-* SYNOPSIS
-*/
-#define OSM_NODE_DESC_UNKNOWN "<unknown>"
-/**********/
-/****d* OpenSM: Base/osm_thread_state_t
-* NAME
-* osm_thread_state_t
-*
-* DESCRIPTION
-* Enumerates the possible states of worker threads, such
-* as the subnet sweeper.
-*
-* SYNOPSIS
-*/
-typedef enum _osm_thread_state {
- OSM_THREAD_STATE_NONE = 0,
- OSM_THREAD_STATE_INIT,
- OSM_THREAD_STATE_RUN,
- OSM_THREAD_STATE_EXIT
-} osm_thread_state_t;
-/***********/
-
-/*
- * OSM_CAP are from Table 117 and C15-0.1.7 Table 186
- */
-
-/****d* OpenSM: Base/OSM_CAP_IS_TRAP_SUP
-* Name
-* OSM_CAP_IS_SUBN_TRAP_SUP
-*
-* DESCRIPTION
-* Management class generates Trap() MADs
-*
-* SYNOPSIS
-*/
-#define OSM_CAP_IS_SUBN_TRAP_SUP (1 << 0)
-/***********/
-
-/****d* OpenSM: Base/OSM_CAP_IS_GET_SET_NOTICE_SUP
-* Name
-* OSM_CAP_IS_GET_SET_NOTICE_SUP
-*
-* DESCRIPTION
-* Management class supports Get/Set(Notice)
-*
-* SYNOPSIS
-*/
-#define OSM_CAP_IS_SUBN_GET_SET_NOTICE_SUP (1 << 1)
-/***********/
-
-/****d* OpenSM: Base/OSM_CAP_IS_SUBN_OPT_RECS_SUP
-* Name
-* OSM_CAP_IS_SUBN_OPT_RECS_SUP
-*
-* DESCRIPTION
-* Support all optional attributes except:
-* MCMemberRecord, TraceRecord, MultiPathRecord
-*
-* SYNOPSIS
-*/
-#define OSM_CAP_IS_SUBN_OPT_RECS_SUP (1 << 8)
-/***********/
-
-/****d* OpenSM: Base/OSM_CAP_IS_UD_MCAST_SUP
-* Name
-* OSM_CAP_IS_UD_MCAST_SUP
-*
-* DESCRIPTION
-* Multicast is supported
-*
-* SYNOPSIS
-*/
-#define OSM_CAP_IS_UD_MCAST_SUP (1 << 9)
-/***********/
-
-/****d* OpenSM: Base/OSM_CAP_IS_MULTIPATH_SUP
-* Name
-* OSM_CAP_IS_MULTIPATH_SUP
-*
-* DESCRIPTION
-* MultiPathRecord and TraceRecord are supported
-*
-* SYNOPSIS
-*/
-#define OSM_CAP_IS_MULTIPATH_SUP (1 << 10)
-/***********/
-
-/****d* OpenSM: Base/OSM_CAP_IS_REINIT_SUP
-* Name
-* OSM_CAP_IS_REINIT_SUP
-*
-* DESCRIPTION
-* SM/SA supports re-initialization supported
-*
-* SYNOPSIS
-*/
-#define OSM_CAP_IS_REINIT_SUP (1 << 11)
-/***********/
-
-/****d* OpenSM: Base/OSM_CAP_IS_PORT_INFO_CAPMASK_MATCH_SUPPORTED
-* Name
-* OSM_CAP_IS_PORT_INFO_CAPMASK_MATCH_SUPPORTED
-*
-* DESCRIPTION
-* SM/SA supports enhanced SA PortInfoRecord searches per 1.2 Errata:
-* ClassPortInfo:CapabilityMask.IsPortInfoCapMaskMatchSupported is 1,
-* then the AttributeModifier of the SubnAdmGet() and SubnAdmGetTable()
-* methods affects the matching behavior on the PortInfo:CapabilityMask
-* component. If the high-order bit (bit 31) of the AttributeModifier
-* is set to 1, matching on the CapabilityMask component will not be an
-* exact bitwise match as described in <ref to 15.4.4>. Instead,
-* matching will only be performed on those bits which are set to 1 in
-* the PortInfo:CapabilityMask embedded in the query.
-*
-* SYNOPSIS
-*/
-#define OSM_CAP_IS_PORT_INFO_CAPMASK_MATCH_SUPPORTED (1 << 13)
-/***********/
-
-/****d* OpenSM: Base/OSM_CAP2_IS_QOS_SUPPORTED
-* Name
-* OSM_CAP2_IS_QOS_SUPPORTED
-*
-* DESCRIPTION
-* QoS is supported
-*
-* SYNOPSIS
-*/
-#define OSM_CAP2_IS_QOS_SUPPORTED (1 << 1)
-/***********/
-
-/****d* OpenSM: Base/osm_signal_t
-* NAME
-* osm_signal_t
-*
-* DESCRIPTION
-* Enumerates the possible signal codes used by the OSM managers
-* This cannot be an enum type, since conversion to and from
-* integral types is necessary when passing signals through
-* the dispatcher.
-*
-* SYNOPSIS
-*/
-#define OSM_SIGNAL_NONE 0
-#define OSM_SIGNAL_SWEEP 1
-#define OSM_SIGNAL_IDLE_TIME_PROCESS_REQUEST 2
-#define OSM_SIGNAL_PERFMGR_SWEEP 3
-#define OSM_SIGNAL_MAX 3
-
-/* status values for sweep managers - can be removed later */
-#define OSM_SIGNAL_DONE 16
-#define OSM_SIGNAL_DONE_PENDING 17
-
-typedef unsigned int osm_signal_t;
-/***********/
-
-/****d* OpenSM: Base/osm_sm_signal_t
-* NAME
-* osm_sm_signal_t
-*
-* DESCRIPTION
-* Enumerates the possible signals used by the OSM_SM_MGR
-*
-* SYNOPSIS
-*/
-typedef enum _osm_sm_signal {
- OSM_SM_SIGNAL_NONE = 0,
- OSM_SM_SIGNAL_DISCOVERY_COMPLETED,
- OSM_SM_SIGNAL_POLLING_TIMEOUT,
- OSM_SM_SIGNAL_DISCOVER,
- OSM_SM_SIGNAL_DISABLE,
- OSM_SM_SIGNAL_HANDOVER,
- OSM_SM_SIGNAL_HANDOVER_SENT,
- OSM_SM_SIGNAL_ACKNOWLEDGE,
- OSM_SM_SIGNAL_STANDBY,
- OSM_SM_SIGNAL_MASTER_OR_HIGHER_SM_DETECTED,
- OSM_SM_SIGNAL_WAIT_FOR_HANDOVER,
- OSM_SM_SIGNAL_MAX
-} osm_sm_signal_t;
-/***********/
-
-/****d* OpenSM/osm_mcast_req_type_t
-* NAME
-* osm_mcast_req_type_t
-*
-* DESCRIPTION
-* Enumerates the possible signals used by the OSM_MCAST_REQUEST
-*
-* SYNOPSIS
-*/
-typedef enum _osm_mcast_req_type {
- OSM_MCAST_REQ_TYPE_CREATE,
- OSM_MCAST_REQ_TYPE_JOIN,
- OSM_MCAST_REQ_TYPE_LEAVE,
- OSM_MCAST_REQ_TYPE_SUBNET_CHANGE
-} osm_mcast_req_type_t;
-/***********/
-
-/****s* OpenSM: Base/MAX_GUID_FILE_LINE_LENGTH
-* NAME
-* MAX_GUID_FILE_LINE_LENGTH
-*
-* DESCRIPTION
-* The maximum line number when reading guid file
-*
-* SYNOPSIS
-*/
-#define MAX_GUID_FILE_LINE_LENGTH 120
-/**********/
-
-/****s* OpenSM: Base/VendorOUIs
-* NAME
-* VendorOUIs
-*
-* DESCRIPTION
-* Known device vendor ID and GUID OUIs
-*
-* SYNOPSIS
-*/
-#define OSM_VENDOR_ID_INTEL 0x00D0B7
-#define OSM_VENDOR_ID_MELLANOX 0x0002C9
-#define OSM_VENDOR_ID_REDSWITCH 0x000617
-#define OSM_VENDOR_ID_SILVERSTORM 0x00066A
-#define OSM_VENDOR_ID_TOPSPIN 0x0005AD
-#define OSM_VENDOR_ID_FUJITSU 0x00E000
-#define OSM_VENDOR_ID_FUJITSU2 0x000B5D
-#define OSM_VENDOR_ID_VOLTAIRE 0x0008F1
-#define OSM_VENDOR_ID_YOTTAYOTTA 0x000453
-#define OSM_VENDOR_ID_PATHSCALE 0x001175
-#define OSM_VENDOR_ID_IBM 0x000255
-#define OSM_VENDOR_ID_DIVERGENET 0x00084E
-#define OSM_VENDOR_ID_FLEXTRONICS 0x000B8C
-#define OSM_VENDOR_ID_AGILENT 0x0030D3
-#define OSM_VENDOR_ID_OBSIDIAN 0x001777
-#define OSM_VENDOR_ID_BAYMICRO 0x000BC1
-#define OSM_VENDOR_ID_LSILOGIC 0x00A0B8
-#define OSM_VENDOR_ID_DDN 0x0001FF
-#define OSM_VENDOR_ID_PANTA 0x001393
-#define OSM_VENDOR_ID_HP 0x001708
-#define OSM_VENDOR_ID_RIOWORKS 0x005045
-#define OSM_VENDOR_ID_SUN 0x0003BA
-#define OSM_VENDOR_ID_3LEAFNTWKS 0x0016A1
-#define OSM_VENDOR_ID_XSIGO 0x001397
-#define OSM_VENDOR_ID_HP2 0x0018FE
-
-/**********/
-
-END_C_DECLS
-#endif /* _OSM_BASE_H_ */
diff --git a/contrib/ofed/management/opensm/include/opensm/osm_config.h b/contrib/ofed/management/opensm/include/opensm/osm_config.h
deleted file mode 100644
index 8ecaa79..0000000
--- a/contrib/ofed/management/opensm/include/opensm/osm_config.h
+++ /dev/null
@@ -1,65 +0,0 @@
-/* include/opensm/osm_config.h. Generated from osm_config.h.in by configure. */
-/* include/osm_config.h.in
- *
- * Defines various OpenSM configuration parameters to be used by various
- * plugins and third party tools.
- *
- * NOTE: Defines used in header files MUST be included here to ensure plugin
- * compatibility.
- */
-
-#ifndef _OSM_CONFIG_H_
-#define _OSM_CONFIG_H_ 1
-
-/* define 1 if OpenSM build is in a debug mode */
-/* #undef OSM_DEBUG */
-
-/* Define as 1 if you want Dual Sided RMPP Support */
-#define DUAL_SIDED_RMPP 1
-
-/* Define as 1 if you want to enable a console on a socket connection */
-/* #undef ENABLE_OSM_CONSOLE_SOCKET */
-
-/* Define as 1 if you want to enable the event plugin */
-/* #undef ENABLE_OSM_DEFAULT_EVENT_PLUGIN */
-
-/* Define as 1 if you want to enable the performance manager */
-/* #undef ENABLE_OSM_PERF_MGR */
-
-/* Define as 1 if you want to enable the performance manager profiling code */
-/* #undef ENABLE_OSM_PERF_MGR_PROFILE */
-
-/* Define a default node name map file */
-#define HAVE_DEFAULT_NODENAME_MAP "/usr/local/etc/opensm/ib-node-name-map"
-
-/* Define a default OpenSM config file */
-#define HAVE_DEFAULT_OPENSM_CONFIG_FILE "/usr/local/etc/opensm/opensm.conf"
-
-/* Define a Partition config file */
-#define HAVE_DEFAULT_PARTITION_CONFIG_FILE "/usr/local/etc/opensm/partitions.conf"
-
-/* Define a Prefix Routes config file */
-#define HAVE_DEFAULT_PREFIX_ROUTES_FILE "/usr/local/etc/opensm/prefix-routes.conf"
-
-/* Define a QOS policy config file */
-#define HAVE_DEFAULT_QOS_POLICY_FILE "/usr/local/etc/opensm/qos-policy.conf"
-
-/* Define OpenSM config directory */
-#define OPENSM_CONFIG_DIR "/usr/local/etc/opensm"
-
-/* Define as 1 for vapi vendor */
-/* #undef OSM_VENDOR_INTF_MTL */
-
-/* Define as 1 for OpenIB vendor */
-#define OSM_VENDOR_INTF_OPENIB 1
-
-/* Define as 1 for sim vendor */
-/* #undef OSM_VENDOR_INTF_SIM */
-
-/* Define as 1 for ts vendor */
-/* #undef OSM_VENDOR_INTF_TS */
-
-/* Define as 1 if you want Vendor RMPP Support */
-#define VENDOR_RMPP_SUPPORT 1
-
-#endif /* _OSM_CONFIG_H_ */
diff --git a/contrib/ofed/management/opensm/include/opensm/osm_config.h.in b/contrib/ofed/management/opensm/include/opensm/osm_config.h.in
deleted file mode 100644
index b12006f..0000000
--- a/contrib/ofed/management/opensm/include/opensm/osm_config.h.in
+++ /dev/null
@@ -1,64 +0,0 @@
-/* include/osm_config.h.in
- *
- * Defines various OpenSM configuration parameters to be used by various
- * plugins and third party tools.
- *
- * NOTE: Defines used in header files MUST be included here to ensure plugin
- * compatibility.
- */
-
-#ifndef _OSM_CONFIG_H_
-#define _OSM_CONFIG_H_
-
-/* define 1 if OpenSM build is in a debug mode */
-#undef OSM_DEBUG
-
-/* Define as 1 if you want Dual Sided RMPP Support */
-#undef DUAL_SIDED_RMPP
-
-/* Define as 1 if you want to enable a console on a socket connection */
-#undef ENABLE_OSM_CONSOLE_SOCKET
-
-/* Define as 1 if you want to enable the event plugin */
-#undef ENABLE_OSM_DEFAULT_EVENT_PLUGIN
-
-/* Define as 1 if you want to enable the performance manager */
-#undef ENABLE_OSM_PERF_MGR
-
-/* Define as 1 if you want to enable the performance manager profiling code */
-#undef ENABLE_OSM_PERF_MGR_PROFILE
-
-/* Define a default node name map file */
-#undef HAVE_DEFAULT_NODENAME_MAP
-
-/* Define a default OpenSM config file */
-#undef HAVE_DEFAULT_OPENSM_CONFIG_FILE
-
-/* Define a Partition config file */
-#undef HAVE_DEFAULT_PARTITION_CONFIG_FILE
-
-/* Define a Prefix Routes config file */
-#undef HAVE_DEFAULT_PREFIX_ROUTES_FILE
-
-/* Define a QOS policy config file */
-#undef HAVE_DEFAULT_QOS_POLICY_FILE
-
-/* Define OpenSM config directory */
-#undef OPENSM_CONFIG_DIR
-
-/* Define as 1 for vapi vendor */
-#undef OSM_VENDOR_INTF_MTL
-
-/* Define as 1 for OpenIB vendor */
-#undef OSM_VENDOR_INTF_OPENIB
-
-/* Define as 1 for sim vendor */
-#undef OSM_VENDOR_INTF_SIM
-
-/* Define as 1 for ts vendor */
-#undef OSM_VENDOR_INTF_TS
-
-/* Define as 1 if you want Vendor RMPP Support */
-#undef VENDOR_RMPP_SUPPORT
-
-#endif /* _OSM_CONFIG_H_ */
diff --git a/contrib/ofed/management/opensm/include/opensm/osm_console.h b/contrib/ofed/management/opensm/include/opensm/osm_console.h
deleted file mode 100644
index 3ea8fa5..0000000
--- a/contrib/ofed/management/opensm/include/opensm/osm_console.h
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * Copyright (c) 2005-2007 Voltaire, Inc. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- */
-
-#ifndef _OSM_CONSOLE_H_
-#define _OSM_CONSOLE_H_
-
-#include <opensm/osm_opensm.h>
-
-#ifdef __cplusplus
-# define BEGIN_C_DECLS extern "C" {
-# define END_C_DECLS }
-#else /* !__cplusplus */
-# define BEGIN_C_DECLS
-# define END_C_DECLS
-#endif /* __cplusplus */
-
-BEGIN_C_DECLS
-// TODO replace p_osm
-void osm_console(osm_opensm_t * p_osm);
-END_C_DECLS
-#endif /* _OSM_CONSOLE_H_ */
diff --git a/contrib/ofed/management/opensm/include/opensm/osm_console_io.h b/contrib/ofed/management/opensm/include/opensm/osm_console_io.h
deleted file mode 100644
index 5fe233d..0000000
--- a/contrib/ofed/management/opensm/include/opensm/osm_console_io.h
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
- * Copyright (c) 2005-2007 Voltaire, Inc. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- */
-/*
- * Abstract:
- * Declaration of osm_console_t.
- * This object represents the OpenSM Console object.
- * This object is part of the OpenSM family of objects.
- */
-
-#ifndef _OSM_CONSOLE_IO_H_
-#define _OSM_CONSOLE_IO_H_
-
-#include <opensm/osm_subnet.h>
-#include <opensm/osm_log.h>
-
-#define OSM_DISABLE_CONSOLE "off"
-#define OSM_LOCAL_CONSOLE "local"
-#define OSM_REMOTE_CONSOLE "socket"
-#define OSM_LOOPBACK_CONSOLE "loopback"
-#define OSM_CONSOLE_NAME "OSM Console"
-
-#define OSM_DEFAULT_CONSOLE OSM_DISABLE_CONSOLE
-#define OSM_DEFAULT_CONSOLE_PORT 10000
-#define OSM_DAEMON_NAME "opensm"
-
-#define OSM_COMMAND_PROMPT "$ "
-
-#ifdef __cplusplus
-# define BEGIN_C_DECLS extern "C" {
-# define END_C_DECLS }
-#else /* !__cplusplus */
-# define BEGIN_C_DECLS
-# define END_C_DECLS
-#endif /* __cplusplus */
-
-BEGIN_C_DECLS
-typedef struct osm_console {
- int socket;
- int in_fd;
- int out_fd;
- int authorized;
- FILE *in;
- FILE *out;
- char client_type[32];
- char client_ip[64];
- char client_hn[128];
-} osm_console_t;
-
-void osm_console_prompt(FILE * out);
-int osm_console_init(osm_subn_opt_t * opt, osm_console_t * p_oct, osm_log_t * p_log);
-void osm_console_exit(osm_console_t * p_oct, osm_log_t * p_log);
-int is_console_enabled(osm_subn_opt_t *p_opt);
-
-#ifdef ENABLE_OSM_CONSOLE_SOCKET
-int cio_open(osm_console_t * p_oct, int new_fd, osm_log_t * p_log);
-int is_authorized(osm_console_t * p_oct);
-#endif
-
-END_C_DECLS
-#endif /* _OSM_CONSOLE_IO_H_ */
diff --git a/contrib/ofed/management/opensm/include/opensm/osm_db.h b/contrib/ofed/management/opensm/include/opensm/osm_db.h
deleted file mode 100644
index 56bae31..0000000
--- a/contrib/ofed/management/opensm/include/opensm/osm_db.h
+++ /dev/null
@@ -1,427 +0,0 @@
-/*
- * Copyright (c) 2004, 2005 Voltaire, Inc. All rights reserved.
- * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved.
- * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- */
-
-#ifndef _OSM_DB_H_
-#define _OSM_DB_H_
-
-/*
- * Abstract:
- * Declaration of the DB interface.
- */
-
-#include <complib/cl_list.h>
-#include <complib/cl_spinlock.h>
-#include <opensm/osm_log.h>
-
-#ifdef __cplusplus
-# define BEGIN_C_DECLS extern "C" {
-# define END_C_DECLS }
-#else /* !__cplusplus */
-# define BEGIN_C_DECLS
-# define END_C_DECLS
-#endif /* __cplusplus */
-
-BEGIN_C_DECLS
-/****h* OpenSM/Database
-* NAME
-* Database
-*
-* DESCRIPTION
-* The OpenSM database interface provide the means to restore persistent
-* data, query, modify, delete and eventually commit it back to the
-* persistent media.
-*
-* The interface is defined such that it can is not "data dependent":
-* All keys and data items are texts.
-*
-* The DB implementation should be thread safe, thus callers do not need to
-* provide serialization.
-*
-* This object should be treated as opaque and should be
-* manipulated only through the provided functions.
-*
-* AUTHOR
-* Eitan Zahavi, Mellanox Technologies LTD
-*
-*********/
-/****s* OpenSM: Database/osm_db_domain_t
-* NAME
-* osm_db_domain_t
-*
-* DESCRIPTION
-* A domain of the database. Can be viewed as a database table.
-*
-* The osm_db_domain_t object should be treated as opaque and should
-* be manipulated only through the provided functions.
-*
-* SYNOPSIS
-*/
-typedef struct osm_db_domain {
- struct osm_db *p_db;
- void *p_domain_imp;
-} osm_db_domain_t;
-/*
-* FIELDS
-* p_db
-* Pointer to the parent database object.
-*
-* p_domain_imp
-* Pointer to the db implementation object
-*
-* SEE ALSO
-* osm_db_t
-*********/
-
-/****s* OpenSM: Database/osm_db_t
-* NAME
-* osm_db_t
-*
-* DESCRIPTION
-* The main database object.
-*
-* The osm_db_t object should be treated as opaque and should
-* be manipulated only through the provided functions.
-*
-* SYNOPSIS
-*/
-typedef struct osm_db {
- void *p_db_imp;
- osm_log_t *p_log;
- cl_list_t domains;
-} osm_db_t;
-/*
-* FIELDS
-* p_db_imp
-* Pointer to the database implementation object
-*
-* p_log
-* Pointer to the OSM logging facility
-*
-* domains
-* List of initialize domains
-*
-* SEE ALSO
-*********/
-
-/****f* OpenSM: Database/osm_db_construct
-* NAME
-* osm_db_construct
-*
-* DESCRIPTION
-* Construct a database.
-*
-* SYNOPSIS
-*/
-void osm_db_construct(IN osm_db_t * const p_db);
-/*
-* PARAMETERS
-* p_db
-* [in] Pointer to the database object to construct
-*
-* RETURN VALUES
-* NONE
-*
-* SEE ALSO
-* Database, osm_db_init, osm_db_destroy
-*********/
-
-/****f* OpenSM: Database/osm_db_destroy
-* NAME
-* osm_db_destroy
-*
-* DESCRIPTION
-* Destroys the osm_db_t structure.
-*
-* SYNOPSIS
-*/
-void osm_db_destroy(IN osm_db_t * const p_db);
-/*
-* PARAMETERS
-* p_db
-* [in] Pointer to osm_db_t structure to destroy
-*
-* SEE ALSO
-* Database, osm_db_construct, osm_db_init
-*********/
-
-/****f* OpenSM: Database/osm_db_init
-* NAME
-* osm_db_init
-*
-* DESCRIPTION
-* Initializes the osm_db_t structure.
-*
-* SYNOPSIS
-*/
-int osm_db_init(IN osm_db_t * const p_db, IN osm_log_t * p_log);
-/*
-* PARAMETERS
-*
-* p_db
-* [in] Pointer to the database object to initialize
-*
-* p_log
-* [in] Pointer to the OSM logging facility
-*
-* RETURN VALUES
-* 0 on success 1 otherwise
-*
-* SEE ALSO
-* Database, osm_db_construct, osm_db_destroy
-*********/
-
-/****f* OpenSM: Database/osm_db_domain_init
-* NAME
-* osm_db_domain_init
-*
-* DESCRIPTION
-* Initializes the osm_db_domain_t structure.
-*
-* SYNOPSIS
-*/
-osm_db_domain_t *osm_db_domain_init(IN osm_db_t * const p_db,
- IN char *domain_name);
-/*
-* PARAMETERS
-*
-* p_db
-* [in] Pointer to the database object to initialize
-*
-* domain_name
-* [in] a char array with the domain name.
-*
-* RETURN VALUES
-* pointer to the new domain object or NULL if failed.
-*
-* SEE ALSO
-* Database, osm_db_construct, osm_db_destroy
-*********/
-
-/****f* OpenSM: Database/osm_db_restore
-* NAME
-* osm_db_restore
-*
-* DESCRIPTION
-* Reads the entire domain from persistent storage - overrides all
-* existing cached data (if any).
-*
-* SYNOPSIS
-*/
-int osm_db_restore(IN osm_db_domain_t * p_domain);
-/*
-* PARAMETERS
-*
-* p_domain
-* [in] Pointer to the database domain object to restore
-* from persistent db
-*
-* RETURN VALUES
-* 0 if successful 1 otherwize
-*
-* SEE ALSO
-* Database, osm_db_domain_init, osm_db_clear, osm_db_store,
-* osm_db_keys, osm_db_lookup, osm_db_update, osm_db_delete
-*********/
-
-/****f* OpenSM: Database/osm_db_clear
-* NAME
-* osm_db_clear
-*
-* DESCRIPTION
-* Clears the entire domain values from/in the cache
-*
-* SYNOPSIS
-*/
-int osm_db_clear(IN osm_db_domain_t * p_domain);
-/*
-* PARAMETERS
-*
-* p_domain
-* [in] Pointer to the database domain object to clear
-*
-* RETURN VALUES
-* 0 if successful 1 otherwize
-*
-* SEE ALSO
-* Database, osm_db_domain_init, osm_db_restore, osm_db_store,
-* osm_db_keys, osm_db_lookup, osm_db_update, osm_db_delete
-*********/
-
-/****f* OpenSM: Database/osm_db_store
-* NAME
-* osm_db_store
-*
-* DESCRIPTION
-* Store the domain cache back to the database (commit)
-*
-* SYNOPSIS
-*/
-int osm_db_store(IN osm_db_domain_t * p_domain);
-/*
-* PARAMETERS
-*
-* p_domain
-* [in] Pointer to the database domain object to restore from
-* persistent db
-*
-* RETURN VALUES
-* 0 if successful 1 otherwize
-*
-* SEE ALSO
-* Database, osm_db_domain_init, osm_db_restore, osm_db_clear,
-* osm_db_keys, osm_db_lookup, osm_db_update, osm_db_delete
-*********/
-
-/****f* OpenSM: Database/osm_db_keys
-* NAME
-* osm_db_keys
-*
-* DESCRIPTION
-* Retrive all keys of the domain
-*
-* SYNOPSIS
-*/
-int osm_db_keys(IN osm_db_domain_t * p_domain, OUT cl_list_t * p_key_list);
-/*
-* PARAMETERS
-*
-* p_domain
-* [in] Pointer to the database domain object
-*
-* p_key_list
-* [out] List of key values. It should be PRE constructed and initialized.
-*
-* RETURN VALUES
-* 0 if successful 1 otherwize
-*
-* NOTE: the caller needs to free and destruct the list,
-* the keys returned are intrnal to the hash and should NOT be free'ed
-*
-* SEE ALSO
-* Database, osm_db_domain_init, osm_db_restore, osm_db_clear, osm_db_store,
-* osm_db_lookup, osm_db_update, osm_db_delete
-*********/
-
-/****f* OpenSM: Database/osm_db_lookup
-* NAME
-* osm_db_lookup
-*
-* DESCRIPTION
-* Lookup an entry in the domain by the given key
-*
-* SYNOPSIS
-*/
-/* lookup value by key */
-char *osm_db_lookup(IN osm_db_domain_t * p_domain, IN char *const p_key);
-/*
-* PARAMETERS
-*
-* p_domain
-* [in] Pointer to the database domain object
-*
-* key
-* [in] The key to look for
-*
-* RETURN VALUES
-* the value as char * or NULL if not found
-*
-* SEE ALSO
-* Database, osm_db_domain_init, osm_db_restore, osm_db_clear, osm_db_store,
-* osm_db_keys, osm_db_update, osm_db_delete
-*********/
-
-/****f* OpenSM: Database/osm_db_update
-* NAME
-* osm_db_update
-*
-* DESCRIPTION
-* Set the value of the given key
-*
-* SYNOPSIS
-*/
-int
-osm_db_update(IN osm_db_domain_t * p_domain,
- IN char *const p_key, IN char *const p_val);
-/*
-* PARAMETERS
-*
-* p_domain
-* [in] Pointer to the database domain object
-*
-* p_key
-* [in] The key to update
-*
-* p_val
-* [in] The value to update
-*
-* RETURN VALUES
-* 0 on success
-*
-* NOTE: the value will be duplicated so can be free'ed
-*
-* SEE ALSO
-* Database, osm_db_domain_init, osm_db_restore, osm_db_clear, osm_db_store,
-* osm_db_keys, osm_db_lookup, osm_db_delete
-*********/
-
-/****f* OpenSM: Database/osm_db_delete
-* NAME
-* osm_db_delete
-*
-* DESCRIPTION
-* Delete an entry by the given key
-*
-* SYNOPSIS
-*/
-int osm_db_delete(IN osm_db_domain_t * p_domain, IN char *const p_key);
-/*
-* PARAMETERS
-*
-* p_domain
-* [in] Pointer to the database domain object
-*
-* p_key
-* [in] The key to look for
-*
-* RETURN VALUES
-* 0 on success
-*
-* SEE ALSO
-* Database, osm_db_domain_init, osm_db_restore, osm_db_clear, osm_db_store,
-* osm_db_keys, osm_db_lookup, osm_db_update
-*********/
-
-END_C_DECLS
-#endif /* _OSM_DB_H_ */
diff --git a/contrib/ofed/management/opensm/include/opensm/osm_db_pack.h b/contrib/ofed/management/opensm/include/opensm/osm_db_pack.h
deleted file mode 100644
index 83861a6..0000000
--- a/contrib/ofed/management/opensm/include/opensm/osm_db_pack.h
+++ /dev/null
@@ -1,243 +0,0 @@
-/*
- * Copyright (c) 2004, 2005 Voltaire, Inc. All rights reserved.
- * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved.
- * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- */
-
-/****h* OpenSM/DB-Pack
-* NAME
-* Database Types
-*
-* DESCRIPTION
-* This module provides packing and unpacking of the database
-* storage into specific types.
-*
-* The following domains/conversions are supported:
-* guid2lid - key is a guid and data is a lid.
-*
-* AUTHOR
-* Eitan Zahavi, Mellanox Technologies LTD
-*
-*********/
-
-#ifndef _OSM_DB_PACK_H_
-#define _OSM_DB_PACK_H_
-
-#include <opensm/osm_db.h>
-
-#ifdef __cplusplus
-# define BEGIN_C_DECLS extern "C" {
-# define END_C_DECLS }
-#else /* !__cplusplus */
-# define BEGIN_C_DECLS
-# define END_C_DECLS
-#endif /* __cplusplus */
-
-BEGIN_C_DECLS
-/****f* OpenSM: DB-Pack/osm_db_guid2lid_init
-* NAME
-* osm_db_guid2lid_init
-*
-* DESCRIPTION
-* Initialize a domain for the guid2lid table
-*
-* SYNOPSIS
-*/
-static inline osm_db_domain_t *osm_db_guid2lid_init(IN osm_db_t * const p_db)
-{
- return (osm_db_domain_init(p_db, "guid2lid"));
-}
-
-/*
-* PARAMETERS
-* p_db
-* [in] Pointer to the database object to construct
-*
-* RETURN VALUES
-* The pointer to the new allocated domain object or NULL.
-*
-* NOTE: DB domains are destroyed by the osm_db_destroy
-*
-* SEE ALSO
-* Database, osm_db_init, osm_db_destroy
-*********/
-
-/****f* OpenSM: DB-Pack/osm_db_guid2lid_init
-* NAME
-* osm_db_guid2lid_init
-*
-* DESCRIPTION
-* Initialize a domain for the guid2lid table
-*
-* SYNOPSIS
-*/
-typedef struct osm_db_guid_elem {
- cl_list_item_t item;
- uint64_t guid;
-} osm_db_guid_elem_t;
-/*
-* FIELDS
-* item
-* required for list manipulations
-*
-* guid
-*
-************/
-
-/****f* OpenSM: DB-Pack/osm_db_guid2lid_guids
-* NAME
-* osm_db_guid2lid_guids
-*
-* DESCRIPTION
-* Provides back a list of guid elements.
-*
-* SYNOPSIS
-*/
-int
-osm_db_guid2lid_guids(IN osm_db_domain_t * const p_g2l,
- OUT cl_qlist_t * p_guid_list);
-/*
-* PARAMETERS
-* p_g2l
-* [in] Pointer to the guid2lid domain
-*
-* p_guid_list
-* [out] A quick list of guid elements of type osm_db_guid_elem_t
-*
-* RETURN VALUES
-* 0 if successful
-*
-* NOTE: the output qlist should be initialized and each item freed
-* by the caller, then destroyed.
-*
-* SEE ALSO
-* osm_db_guid2lid_init, osm_db_guid2lid_guids, osm_db_guid2lid_get
-* osm_db_guid2lid_set, osm_db_guid2lid_delete
-*********/
-
-/****f* OpenSM: DB-Pack/osm_db_guid2lid_get
-* NAME
-* osm_db_guid2lid_get
-*
-* DESCRIPTION
-* Get a lid range by given guid.
-*
-* SYNOPSIS
-*/
-int
-osm_db_guid2lid_get(IN osm_db_domain_t * const p_g2l,
- IN uint64_t guid,
- OUT uint16_t * p_min_lid, OUT uint16_t * p_max_lid);
-/*
-* PARAMETERS
-* p_g2l
-* [in] Pointer to the guid2lid domain
-*
-* guid
-* [in] The guid to look for
-*
-* p_min_lid
-* [out] Pointer to the resulting min lid in host order.
-*
-* p_max_lid
-* [out] Pointer to the resulting max lid in host order.
-*
-* RETURN VALUES
-* 0 if successful. The lid will be set to 0 if not found.
-*
-* SEE ALSO
-* osm_db_guid2lid_init, osm_db_guid2lid_guids
-* osm_db_guid2lid_set, osm_db_guid2lid_delete
-*********/
-
-/****f* OpenSM: DB-Pack/osm_db_guid2lid_set
-* NAME
-* osm_db_guid2lid_set
-*
-* DESCRIPTION
-* Set a lid range for the given guid.
-*
-* SYNOPSIS
-*/
-int
-osm_db_guid2lid_set(IN osm_db_domain_t * const p_g2l,
- IN uint64_t guid, IN uint16_t min_lid, IN uint16_t max_lid);
-/*
-* PARAMETERS
-* p_g2l
-* [in] Pointer to the guid2lid domain
-*
-* guid
-* [in] The guid to look for
-*
-* min_lid
-* [in] The min lid value to set
-*
-* max_lid
-* [in] The max lid value to set
-*
-* RETURN VALUES
-* 0 if successful
-*
-* SEE ALSO
-* osm_db_guid2lid_init, osm_db_guid2lid_guids
-* osm_db_guid2lid_get, osm_db_guid2lid_delete
-*********/
-
-/****f* OpenSM: DB-Pack/osm_db_guid2lid_delete
-* NAME
-* osm_db_guid2lid_delete
-*
-* DESCRIPTION
-* Delete the entry by the given guid
-*
-* SYNOPSIS
-*/
-int osm_db_guid2lid_delete(IN osm_db_domain_t * const p_g2l, IN uint64_t guid);
-/*
-* PARAMETERS
-* p_g2l
-* [in] Pointer to the guid2lid domain
-*
-* guid
-* [in] The guid to look for
-*
-* RETURN VALUES
-* 0 if successful otherwise 1
-*
-* SEE ALSO
-* osm_db_guid2lid_init, osm_db_guid2lid_guids
-* osm_db_guid2lid_get, osm_db_guid2lid_set
-*********/
-
-END_C_DECLS
-#endif /* _OSM_DB_PACK_H_ */
diff --git a/contrib/ofed/management/opensm/include/opensm/osm_event_plugin.h b/contrib/ofed/management/opensm/include/opensm/osm_event_plugin.h
deleted file mode 100644
index 0922c65..0000000
--- a/contrib/ofed/management/opensm/include/opensm/osm_event_plugin.h
+++ /dev/null
@@ -1,192 +0,0 @@
-/*
- * Copyright (c) 2008 Voltaire, Inc. All rights reserved.
- * Copyright (c) 2007 The Regents of the University of California.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- */
-
-#ifndef _OSM_EVENT_PLUGIN_H_
-#define _OSM_EVENT_PLUGIN_H_
-
-#include <time.h>
-#include <iba/ib_types.h>
-#include <complib/cl_qlist.h>
-#include <opensm/osm_config.h>
-
-#ifdef __cplusplus
-# define BEGIN_C_DECLS extern "C" {
-# define END_C_DECLS }
-#else /* !__cplusplus */
-# define BEGIN_C_DECLS
-# define END_C_DECLS
-#endif /* __cplusplus */
-
-BEGIN_C_DECLS
-/****h* OpenSM Event plugin interface
-* DESCRIPTION
-* Database interface to record subnet events
-*
-* Implementations of this object _MUST_ be thread safe.
-*
-* AUTHOR
-* Ira Weiny, LLNL
-*
-*********/
-
-#define OSM_EPI_NODE_NAME_LEN (128)
-
-struct osm_opensm;
-/** =========================================================================
- * Event types
- */
-typedef enum {
- OSM_EVENT_ID_PORT_ERRORS = 0,
- OSM_EVENT_ID_PORT_DATA_COUNTERS,
- OSM_EVENT_ID_PORT_SELECT,
- OSM_EVENT_ID_TRAP,
- OSM_EVENT_ID_SUBNET_UP,
- OSM_EVENT_ID_MAX
-} osm_epi_event_id_t;
-
-typedef struct osm_epi_port_id {
- uint64_t node_guid;
- uint8_t port_num;
- char node_name[OSM_EPI_NODE_NAME_LEN];
-} osm_epi_port_id_t;
-
-/** =========================================================================
- * Port error event
- * OSM_EVENT_ID_PORT_COUNTER
- * This is a difference from the last reading. NOT an absolute reading.
- */
-typedef struct osm_epi_pe_event {
- osm_epi_port_id_t port_id;
- uint64_t symbol_err_cnt;
- uint64_t link_err_recover;
- uint64_t link_downed;
- uint64_t rcv_err;
- uint64_t rcv_rem_phys_err;
- uint64_t rcv_switch_relay_err;
- uint64_t xmit_discards;
- uint64_t xmit_constraint_err;
- uint64_t rcv_constraint_err;
- uint64_t link_integrity;
- uint64_t buffer_overrun;
- uint64_t vl15_dropped;
- time_t time_diff_s;
-} osm_epi_pe_event_t;
-
-/** =========================================================================
- * Port data counter event
- * This is a difference from the last reading. NOT an absolute reading.
- */
-typedef struct osm_epi_dc_event {
- osm_epi_port_id_t port_id;
- uint64_t xmit_data;
- uint64_t rcv_data;
- uint64_t xmit_pkts;
- uint64_t rcv_pkts;
- uint64_t unicast_xmit_pkts;
- uint64_t unicast_rcv_pkts;
- uint64_t multicast_xmit_pkts;
- uint64_t multicast_rcv_pkts;
- time_t time_diff_s;
-} osm_epi_dc_event_t;
-
-/** =========================================================================
- * Port select event
- * This is a difference from the last reading. NOT an absolute reading.
- */
-typedef struct osm_api_ps_event {
- osm_epi_port_id_t port_id;
- uint64_t xmit_wait;
- time_t time_diff_s;
-} osm_epi_ps_event_t;
-
-/** =========================================================================
- * Trap events
- */
-typedef struct osm_epi_trap_event {
- osm_epi_port_id_t port_id;
- uint8_t type;
- uint32_t prod_type;
- uint16_t trap_num;
- uint16_t issuer_lid;
- time_t time;
-} osm_epi_trap_event_t;
-
-/** =========================================================================
- * Plugin creators should allocate an object of this type
- * (named OSM_EVENT_PLUGIN_IMPL_NAME)
- * The version should be set to OSM_EVENT_PLUGIN_INTERFACE_VER
- */
-#define OSM_EVENT_PLUGIN_IMPL_NAME "osm_event_plugin"
-#define OSM_ORIG_EVENT_PLUGIN_INTERFACE_VER 1
-#define OSM_EVENT_PLUGIN_INTERFACE_VER 2
-typedef struct osm_event_plugin {
- const char *osm_version;
- void *(*create) (struct osm_opensm *osm);
- void (*delete) (void *plugin_data);
- void (*report) (void *plugin_data,
- osm_epi_event_id_t event_id, void *event_data);
-} osm_event_plugin_t;
-
-/** =========================================================================
- * The plugin structure should be considered opaque
- */
-typedef struct osm_epi_plugin {
- cl_list_item_t list;
- void *handle;
- osm_event_plugin_t *impl;
- void *plugin_data;
- char *plugin_name;
-} osm_epi_plugin_t;
-
-/**
- * functions
- */
-osm_epi_plugin_t *osm_epi_construct(struct osm_opensm *osm, char *plugin_name);
-void osm_epi_destroy(osm_epi_plugin_t * plugin);
-
-/** =========================================================================
- * Helper functions
- */
-static inline void
-osm_epi_create_port_id(osm_epi_port_id_t * port_id, uint64_t node_guid,
- uint8_t port_num, char *node_name)
-{
- port_id->node_guid = node_guid;
- port_id->port_num = port_num;
- strncpy(port_id->node_name, node_name, OSM_EPI_NODE_NAME_LEN);
- port_id->node_name[OSM_EPI_NODE_NAME_LEN - 1] = '\0';
-}
-
-END_C_DECLS
-#endif /* _OSM_EVENT_PLUGIN_H_ */
diff --git a/contrib/ofed/management/opensm/include/opensm/osm_helper.h b/contrib/ofed/management/opensm/include/opensm/osm_helper.h
deleted file mode 100644
index 9222853..0000000
--- a/contrib/ofed/management/opensm/include/opensm/osm_helper.h
+++ /dev/null
@@ -1,550 +0,0 @@
-/*
- * Copyright (c) 2004-2008 Voltaire, Inc. All rights reserved.
- * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved.
- * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- */
-
-#ifndef _OSM_HELPER_H_
-#define _OSM_HELPER_H_
-
-#include <iba/ib_types.h>
-#include <complib/cl_dispatcher.h>
-#include <opensm/osm_base.h>
-#include <opensm/osm_log.h>
-#include <opensm/osm_msgdef.h>
-#include <opensm/osm_path.h>
-
-#ifdef __cplusplus
-# define BEGIN_C_DECLS extern "C" {
-# define END_C_DECLS }
-#else /* !__cplusplus */
-# define BEGIN_C_DECLS
-# define END_C_DECLS
-#endif /* __cplusplus */
-
-BEGIN_C_DECLS
-/*
- * Abstract:
- * Declaration of helpful functions.
- */
-/****f* OpenSM: Helper/ib_get_sa_method_str
- * NAME
- * ib_get_sa_method_str
- *
- * DESCRIPTION
- * Returns a string for the specified SA Method value.
- *
- * SYNOPSIS
- */
-const char *ib_get_sa_method_str(IN uint8_t method);
-/*
- * PARAMETERS
- * method
- * [in] Network order METHOD ID value.
- *
- * RETURN VALUES
- * Pointer to the method string.
- *
- * NOTES
- *
- * SEE ALSO
- *********/
-
-/****f* OpenSM: Helper/ib_get_sm_method_str
-* NAME
-* ib_get_sm_method_str
-*
-* DESCRIPTION
-* Returns a string for the specified SM Method value.
-*
-* SYNOPSIS
-*/
-const char *ib_get_sm_method_str(IN uint8_t method);
-/*
-* PARAMETERS
-* method
-* [in] Network order METHOD ID value.
-*
-* RETURN VALUES
-* Pointer to the method string.
-*
-* NOTES
-*
-* SEE ALSO
-*********/
-
-/****f* OpenSM: Helper/ib_get_sm_attr_str
-* NAME
-* ib_get_sm_attr_str
-*
-* DESCRIPTION
-* Returns a string for the specified SM attribute value.
-*
-* SYNOPSIS
-*/
-const char *ib_get_sm_attr_str(IN ib_net16_t attr);
-/*
-* PARAMETERS
-* attr
-* [in] Network order attribute ID value.
-*
-* RETURN VALUES
-* Pointer to the attribute string.
-*
-* NOTES
-*
-* SEE ALSO
-*********/
-
-/****f* OpenSM: Helper/ib_get_sa_attr_str
-* NAME
-* ib_get_sa_attr_str
-*
-* DESCRIPTION
-* Returns a string for the specified SA attribute value.
-*
-* SYNOPSIS
-*/
-const char *ib_get_sa_attr_str(IN ib_net16_t attr);
-/*
-* PARAMETERS
-* attr
-* [in] Network order attribute ID value.
-*
-* RETURN VALUES
-* Pointer to the attribute string.
-*
-* NOTES
-*
-* SEE ALSO
-*********/
-
-/****f* OpenSM: Helper/ib_get_trap_str
-* NAME
-* ib_get_trap_str
-*
-* DESCRIPTION
-* Returns a name for the specified trap.
-*
-* SYNOPSIS
-*/
-const char *ib_get_trap_str(uint16_t trap_num);
-/*
-* PARAMETERS
-* trap_num
-* [in] Network order trap number.
-*
-* RETURN VALUES
-* Name of the trap.
-*
-*********/
-
-/****f* OpenSM: Helper/osm_dump_port_info
-* NAME
-* osm_dump_port_info
-*
-* DESCRIPTION
-* Dumps the PortInfo attribute to the log.
-*
-* SYNOPSIS
-*/
-void osm_dump_port_info(IN osm_log_t * const p_log,
- IN const ib_net64_t node_guid,
- IN const ib_net64_t port_guid,
- IN const uint8_t port_num,
- IN const ib_port_info_t * const p_pi,
- IN const osm_log_level_t log_level);
-/*
-* PARAMETERS
-* p_log
-* [in] Pointer to the osm_log_t object
-*
-* node_guid
-* [in] Node GUID that owns this port.
-*
-* port_guid
-* [in] Port GUID for this port.
-*
-* port_num
-* [in] Port number for this port.
-*
-* p_pi
-* [in] Pointer to the PortInfo attribute
-*
-* log_level
-* [in] Log verbosity level with which to dump the data.
-*
-* RETURN VALUES
-* None.
-*
-* NOTES
-*
-* SEE ALSO
-*********/
-
-void
-osm_dump_path_record(IN osm_log_t * const p_log,
- IN const ib_path_rec_t * const p_pr,
- IN const osm_log_level_t log_level);
-
-void
-osm_dump_multipath_record(IN osm_log_t * const p_log,
- IN const ib_multipath_rec_t * const p_mpr,
- IN const osm_log_level_t log_level);
-
-void
-osm_dump_node_record(IN osm_log_t * const p_log,
- IN const ib_node_record_t * const p_nr,
- IN const osm_log_level_t log_level);
-
-void
-osm_dump_mc_record(IN osm_log_t * const p_log,
- IN const ib_member_rec_t * const p_mcmr,
- IN const osm_log_level_t log_level);
-
-void
-osm_dump_link_record(IN osm_log_t * const p_log,
- IN const ib_link_record_t * const p_lr,
- IN const osm_log_level_t log_level);
-
-void
-osm_dump_service_record(IN osm_log_t * const p_log,
- IN const ib_service_record_t * const p_sr,
- IN const osm_log_level_t log_level);
-
-void
-osm_dump_portinfo_record(IN osm_log_t * const p_log,
- IN const ib_portinfo_record_t * const p_pir,
- IN const osm_log_level_t log_level);
-
-void
-osm_dump_guidinfo_record(IN osm_log_t * const p_log,
- IN const ib_guidinfo_record_t * const p_gir,
- IN const osm_log_level_t log_level);
-
-void
-osm_dump_inform_info(IN osm_log_t * const p_log,
- IN const ib_inform_info_t * const p_ii,
- IN const osm_log_level_t log_level);
-
-void
-osm_dump_inform_info_record(IN osm_log_t * const p_log,
- IN const ib_inform_info_record_t * const p_iir,
- IN const osm_log_level_t log_level);
-
-void
-osm_dump_switch_info_record(IN osm_log_t * const p_log,
- IN const ib_switch_info_record_t * const p_sir,
- IN const osm_log_level_t log_level);
-
-void
-osm_dump_sm_info_record(IN osm_log_t * const p_log,
- IN const ib_sminfo_record_t * const p_smir,
- IN const osm_log_level_t log_level);
-
-void
-osm_dump_pkey_block(IN osm_log_t * const p_log,
- IN uint64_t port_guid,
- IN uint16_t block_num,
- IN uint8_t port_num,
- IN const ib_pkey_table_t * const p_pkey_tbl,
- IN const osm_log_level_t log_level);
-
-void
-osm_dump_slvl_map_table(IN osm_log_t * const p_log,
- IN uint64_t port_guid,
- IN uint8_t in_port_num,
- IN uint8_t out_port_num,
- IN const ib_slvl_table_t * const p_slvl_tbl,
- IN const osm_log_level_t log_level);
-
-void
-osm_dump_vl_arb_table(IN osm_log_t * const p_log,
- IN uint64_t port_guid,
- IN uint8_t block_num,
- IN uint8_t port_num,
- IN const ib_vl_arb_table_t * const p_vla_tbl,
- IN const osm_log_level_t log_level);
-
-/****f* OpenSM: Helper/osm_dump_port_info
-* NAME
-* osm_dump_port_info
-*
-* DESCRIPTION
-* Dumps the PortInfo attribute to the log.
-*
-* SYNOPSIS
-*/
-void osm_dump_node_info(IN osm_log_t * const p_log,
- IN const ib_node_info_t * const p_ni,
- IN const osm_log_level_t log_level);
-/*
-* PARAMETERS
-* p_log
-* [in] Pointer to the osm_log_t object
-*
-* p_ni
-* [in] Pointer to the NodeInfo attribute
-*
-* log_level
-* [in] Log verbosity level with which to dump the data.
-*
-* RETURN VALUES
-* None.
-*
-* NOTES
-*
-* SEE ALSO
-*********/
-
-/****f* OpenSM: Helper/osm_dump_sm_info
-* NAME
-* osm_dump_sm_info
-*
-* DESCRIPTION
-* Dumps the SMInfo attribute to the log.
-*
-* SYNOPSIS
-*/
-void
-osm_dump_sm_info(IN osm_log_t * const p_log,
- IN const ib_sm_info_t * const p_smi,
- IN const osm_log_level_t log_level);
-/*
-* PARAMETERS
-* p_log
-* [in] Pointer to the osm_log_t object
-*
-* p_smi
-* [in] Pointer to the SMInfo attribute
-*
-* log_level
-* [in] Log verbosity level with which to dump the data.
-*
-* RETURN VALUES
-* None.
-*
-* NOTES
-*
-* SEE ALSO
-*********/
-
-/****f* OpenSM: Helper/osm_dump_switch_info
-* NAME
-* osm_dump_switch_info
-*
-* DESCRIPTION
-* Dumps the SwitchInfo attribute to the log.
-*
-* SYNOPSIS
-*/
-void
-osm_dump_switch_info(IN osm_log_t * const p_log,
- IN const ib_switch_info_t * const p_si,
- IN const osm_log_level_t log_level);
-/*
-* PARAMETERS
-* p_log
-* [in] Pointer to the osm_log_t object
-*
-* p_si
-* [in] Pointer to the SwitchInfo attribute
-*
-* log_level
-* [in] Log verbosity level with which to dump the data.
-*
-* RETURN VALUES
-* None.
-*
-* NOTES
-*
-* SEE ALSO
-*********/
-
-/****f* OpenSM: Helper/osm_dump_notice
-* NAME
-* osm_dump_notice
-*
-* DESCRIPTION
-* Dumps the Notice attribute to the log.
-*
-* SYNOPSIS
-*/
-void
-osm_dump_notice(IN osm_log_t * const p_log,
- IN const ib_mad_notice_attr_t * p_ntci,
- IN const osm_log_level_t log_level);
-/*
-* PARAMETERS
-* p_log
-* [in] Pointer to the osm_log_t object
-*
-* p_ntci
-* [in] Pointer to the Notice attribute
-*
-* log_level
-* [in] Log verbosity level with which to dump the data.
-*
-* RETURN VALUES
-* None.
-*
-* NOTES
-*
-* SEE ALSO
-*********/
-
-/****f* IBA Base: Types/osm_get_disp_msg_str
-* NAME
-* osm_get_disp_msg_str
-*
-* DESCRIPTION
-* Returns a string for the specified Dispatcher message.
-*
-* SYNOPSIS
-*/
-const char *osm_get_disp_msg_str(IN cl_disp_msgid_t msg);
-/*
-* PARAMETERS
-* msg
-* [in] Dispatcher message ID value.
-*
-* RETURN VALUES
-* Pointer to the message discription string.
-*
-* NOTES
-*
-* SEE ALSO
-*********/
-
-void osm_dump_dr_path(IN osm_log_t * const p_log,
- IN const osm_dr_path_t * const p_path,
- IN const osm_log_level_t level);
-
-void osm_dump_smp_dr_path(IN osm_log_t * const p_log,
- IN const ib_smp_t * const p_smp,
- IN const osm_log_level_t level);
-
-void osm_dump_dr_smp(IN osm_log_t * const p_log,
- IN const ib_smp_t * const p_smp,
- IN const osm_log_level_t level);
-
-void osm_dump_sa_mad(IN osm_log_t * const p_log,
- IN const ib_sa_mad_t * const p_smp,
- IN const osm_log_level_t level);
-
-/****f* IBA Base: Types/osm_get_sm_signal_str
-* NAME
-* osm_get_sm_signal_str
-*
-* DESCRIPTION
-* Returns a string for the specified SM state.
-*
-* SYNOPSIS
-*/
-const char *osm_get_sm_signal_str(IN osm_signal_t signal);
-/*
-* PARAMETERS
-* state
-* [in] Signal value
-*
-* RETURN VALUES
-* Pointer to the signal discription string.
-*
-* NOTES
-*
-* SEE ALSO
-*********/
-
-const char *osm_get_port_state_str_fixed_width(IN uint8_t port_state);
-
-const char *osm_get_node_type_str_fixed_width(IN uint8_t node_type);
-
-const char *osm_get_manufacturer_str(IN uint64_t const guid_ho);
-
-const char *osm_get_mtu_str(IN uint8_t const mtu);
-
-const char *osm_get_lwa_str(IN uint8_t const lwa);
-
-const char *osm_get_mtu_str(IN uint8_t const mtu);
-
-const char *osm_get_lwa_str(IN uint8_t const lwa);
-
-const char *osm_get_lsa_str(IN uint8_t const lsa);
-
-/****f* IBA Base: Types/osm_get_sm_mgr_signal_str
-* NAME
-* osm_get_sm_mgr_signal_str
-*
-* DESCRIPTION
-* Returns a string for the specified SM manager signal.
-*
-* SYNOPSIS
-*/
-const char *osm_get_sm_mgr_signal_str(IN osm_sm_signal_t signal);
-/*
-* PARAMETERS
-* signal
-* [in] SM manager signal
-*
-* RETURN VALUES
-* Pointer to the signal discription string.
-*
-* NOTES
-*
-* SEE ALSO
-*********/
-
-/****f* IBA Base: Types/osm_get_sm_mgr_state_str
-* NAME
-* osm_get_sm_mgr_state_str
-*
-* DESCRIPTION
-* Returns a string for the specified SM manager state.
-*
-* SYNOPSIS
-*/
-const char *osm_get_sm_mgr_state_str(IN uint16_t state);
-/*
-* PARAMETERS
-* state
-* [in] SM manager state
-*
-* RETURN VALUES
-* Pointer to the state discription string.
-*
-* NOTES
-*
-* SEE ALSO
-*********/
-
-END_C_DECLS
-#endif /* _OSM_HELPER_H_ */
diff --git a/contrib/ofed/management/opensm/include/opensm/osm_inform.h b/contrib/ofed/management/opensm/include/opensm/osm_inform.h
deleted file mode 100644
index 1528642..0000000
--- a/contrib/ofed/management/opensm/include/opensm/osm_inform.h
+++ /dev/null
@@ -1,238 +0,0 @@
-/*
- * Copyright (c) 2004-2008 Voltaire, Inc. All rights reserved.
- * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved.
- * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- */
-
-/*
- * Abstract:
- * Declaration of osm_inform_rec_t.
- * This object represents an IBA Inform Record.
- * This object is part of the OpenSM family of objects.
- *
- * Author:
- * Eitan Zahavi, Mellanox
- */
-
-#ifndef _OSM_INFR_H_
-#define _OSM_INFR_H_
-
-#include <iba/ib_types.h>
-#include <complib/cl_qmap.h>
-#include <complib/cl_spinlock.h>
-#include <opensm/osm_subnet.h>
-#include <opensm/osm_madw.h>
-#include <opensm/osm_log.h>
-#include <opensm/osm_sa.h>
-
-#ifdef __cplusplus
-# define BEGIN_C_DECLS extern "C" {
-# define END_C_DECLS }
-#else /* !__cplusplus */
-# define BEGIN_C_DECLS
-# define END_C_DECLS
-#endif /* __cplusplus */
-
-BEGIN_C_DECLS
-/****h* OpenSM/Inform Record
-* NAME
-* Inform Record
-*
-* DESCRIPTION
-* The Inform record encapsulates the information needed by the
-* SA to manage InformInfo registrations and sending Reports(Notice)
-* when SM receives Traps for registered LIDs.
-*
-* The inform records is not thread safe, thus callers must provide
-* serialization.
-*
-* This object should be treated as opaque and should be
-* manipulated only through the provided functions.
-*
-* AUTHOR
-* Eitan Zahavi, Mellanox
-*
-*********/
-/****s* OpenSM: Inform Record/osm_infr_t
-* NAME
-* osm_infr_t
-*
-* DESCRIPTION
-* Inform Record structure.
-*
-* The osm_infr_t object should be treated as opaque and should
-* be manipulated only through the provided functions.
-*
-* SYNOPSIS
-*/
-typedef struct osm_infr {
- cl_list_item_t list_item;
- osm_bind_handle_t h_bind;
- osm_sa_t *sa;
- osm_mad_addr_t report_addr;
- ib_inform_info_record_t inform_record;
-} osm_infr_t;
-/*
-* FIELDS
-* list_item
-* List Item for qlist linkage. Must be first element!!
-*
-* h_bind
-* A handle of lower level mad srvc
-*
-* sa
-* A pointer to osm_sa object
-*
-* report_addr
-* Report address
-*
-* inform_record
-* The Inform Info Record
-*
-* SEE ALSO
-*********/
-
-/****f* OpenSM: Inform Record/osm_infr_new
-* NAME
-* osm_infr_new
-*
-* DESCRIPTION
-* Allocates and initializes a Inform Record for use.
-*
-* SYNOPSIS
-*/
-osm_infr_t *osm_infr_new(IN const osm_infr_t * p_infr_rec);
-/*
-* PARAMETERS
-* p_inf_rec
-* [in] Pointer to IB Inform Record
-*
-* RETURN VALUES
-* pointer to osm_infr_t structure.
-*
-* NOTES
-* Allows calling other inform record methods.
-*
-* SEE ALSO
-* Inform Record, osm_infr_delete
-*********/
-
-/****f* OpenSM: Inform Record/osm_infr_delete
-* NAME
-* osm_infr_delete
-*
-* DESCRIPTION
-* Destroys and deallocates the osm_infr_t structure.
-*
-* SYNOPSIS
-*/
-void osm_infr_delete(IN osm_infr_t * const p_infr);
-/*
-* PARAMETERS
-* p_infr
-* [in] Pointer to osm_infr_t structure
-*
-* SEE ALSO
-* Inform Record, osm_infr_new
-*********/
-
-/****f* OpenSM: Inform Record/osm_infr_get_by_rec
-* NAME
-* osm_infr_get_by_rec
-*
-* DESCRIPTION
-* Find a matching osm_infr_t in the subnet DB by inform_info_record
-*
-* SYNOPSIS
-*/
-osm_infr_t *osm_infr_get_by_rec(IN osm_subn_t const *p_subn,
- IN osm_log_t * p_log,
- IN osm_infr_t * const p_infr_rec);
-/*
-* PARAMETERS
-* p_subn
-* [in] Pointer to the subnet object
-*
-* p_log
-* [in] Pointer to the log object
-*
-* p_inf_rec
-* [in] Pointer to an inform_info record
-*
-* RETURN
-* The matching osm_infr_t
-* SEE ALSO
-* Inform Record, osm_infr_new, osm_infr_delete
-*********/
-
-void
-osm_infr_insert_to_db(IN osm_subn_t * p_subn,
- IN osm_log_t * p_log, IN osm_infr_t * p_infr);
-
-void
-osm_infr_remove_from_db(IN osm_subn_t * p_subn,
- IN osm_log_t * p_log, IN osm_infr_t * p_infr);
-
-/****f* OpenSM: Inform Record/osm_report_notice
-* NAME
-* osm_report_notice
-*
-* DESCRIPTION
-* Once a Trap was received by the osm_trap_rcv, or a Trap sourced in
-* the SM was sent (Traps 64-67) this routine is called with a copy of
-* the notice data.
-* Given a notice attribute - compare and see if it matches the InformInfo
-* Element and if it does - call the Report(Notice) for the
-* target QP registered by the address stored in the InformInfo element
-*
-* SYNOPSIS
-*/
-ib_api_status_t
-osm_report_notice(IN osm_log_t * const p_log,
- IN osm_subn_t * p_subn, IN ib_mad_notice_attr_t * p_ntc);
-/*
-* PARAMETERS
-* p_rcv
-* [in] Pointer to the trap receiver
-*
-* p_ntc
-* [in] Pointer to a copy of the incoming trap notice attribute.
-*
-* RETURN
-* IB_SUCCESS on good completion
-*
-* SEE ALSO
-* Inform Record, osm_trap_rcv
-*********/
-
-END_C_DECLS
-#endif /* _OSM_INFR_H_ */
diff --git a/contrib/ofed/management/opensm/include/opensm/osm_lid_mgr.h b/contrib/ofed/management/opensm/include/opensm/osm_lid_mgr.h
deleted file mode 100644
index 714ba41..0000000
--- a/contrib/ofed/management/opensm/include/opensm/osm_lid_mgr.h
+++ /dev/null
@@ -1,289 +0,0 @@
-/*
- * Copyright (c) 2004-2008 Voltaire, Inc. All rights reserved.
- * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved.
- * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- */
-
-/*
- * Abstract:
- * Declaration of osm_lid_mgr_t.
- * This object represents the LID Manager object.
- * This object is part of the OpenSM family of objects.
- */
-
-#ifndef _OSM_LID_MGR_H_
-#define _OSM_LID_MGR_H_
-
-#include <complib/cl_passivelock.h>
-#include <opensm/osm_base.h>
-#include <opensm/osm_madw.h>
-#include <opensm/osm_subnet.h>
-#include <opensm/osm_db.h>
-#include <opensm/osm_log.h>
-
-#ifdef __cplusplus
-# define BEGIN_C_DECLS extern "C" {
-# define END_C_DECLS }
-#else /* !__cplusplus */
-# define BEGIN_C_DECLS
-# define END_C_DECLS
-#endif /* __cplusplus */
-
-BEGIN_C_DECLS
-#define OSM_LID_MGR_LIST_SIZE_MIN 256
-/****h* OpenSM/LID Manager
-* NAME
-* LID Manager
-*
-* DESCRIPTION
-* The LID Manager object encapsulates the information
-* needed to control LID assignments on the subnet.
-*
-* The LID Manager object is thread safe.
-*
-* This object should be treated as opaque and should be
-* manipulated only through the provided functions.
-*
-* AUTHOR
-* Steve King, Intel
-*
-*********/
-struct osm_sm;
-/****s* OpenSM: LID Manager/osm_lid_mgr_t
-* NAME
-* osm_lid_mgr_t
-*
-* DESCRIPTION
-* LID Manager structure.
-*
-* This object should be treated as opaque and should
-* be manipulated only through the provided functions.
-*
-* SYNOPSIS
-*/
-typedef struct osm_lid_mgr {
- struct osm_sm *sm;
- osm_subn_t *p_subn;
- osm_db_t *p_db;
- osm_log_t *p_log;
- cl_plock_t *p_lock;
- boolean_t send_set_reqs;
- osm_db_domain_t *p_g2l;
- cl_ptr_vector_t used_lids;
- cl_qlist_t free_ranges;
-} osm_lid_mgr_t;
-/*
-* FIELDS
-* sm
-* Pointer to the SM object.
-*
-* p_subn
-* Pointer to the Subnet object for this subnet.
-*
-* p_db
-* Pointer to the database (persistency) object
-*
-* p_log
-* Pointer to the log object.
-*
-* p_lock
-* Pointer to the serializing lock.
-*
-* send_set_reqs
-* Boolean to indicate whether any set requests sent.
-*
-* p_g2l
-* Pointer to the database domain storing guid to lid mapping.
-*
-* used_lids
-* A vector the maps from the lid to its guid. keeps track of
-* existing and non existing mapping of guid->lid
-*
-* free_ranges
-* A list of available free lid ranges. The list is initialized
-* by the code that initializes the lid assignment and is consumed
-* by the procedure that finds a free range. It holds elements of
-* type osm_lid_mgr_range_t
-*
-* SEE ALSO
-* LID Manager object
-*********/
-
-/****f* OpenSM: LID Manager/osm_lid_mgr_construct
-* NAME
-* osm_lid_mgr_construct
-*
-* DESCRIPTION
-* This function constructs a LID Manager object.
-*
-* SYNOPSIS
-*/
-void osm_lid_mgr_construct(IN osm_lid_mgr_t * const p_mgr);
-/*
-* PARAMETERS
-* p_mgr
-* [in] Pointer to a LID Manager object to construct.
-*
-* RETURN VALUE
-* This function does not return a value.
-*
-* NOTES
-* Allows osm_lid_mgr_destroy
-*
-* Calling osm_lid_mgr_construct is a prerequisite to calling any other
-* method except osm_lid_mgr_init.
-*
-* SEE ALSO
-* LID Manager object, osm_lid_mgr_init,
-* osm_lid_mgr_destroy
-*********/
-
-/****f* OpenSM: LID Manager/osm_lid_mgr_destroy
-* NAME
-* osm_lid_mgr_destroy
-*
-* DESCRIPTION
-* The osm_lid_mgr_destroy function destroys the object, releasing
-* all resources.
-*
-* SYNOPSIS
-*/
-void osm_lid_mgr_destroy(IN osm_lid_mgr_t * const p_mgr);
-/*
-* PARAMETERS
-* p_mgr
-* [in] Pointer to the object to destroy.
-*
-* RETURN VALUE
-* This function does not return a value.
-*
-* NOTES
-* Performs any necessary cleanup of the specified
-* LID Manager object.
-* Further operations should not be attempted on the destroyed object.
-* This function should only be called after a call to
-* osm_lid_mgr_construct or osm_lid_mgr_init.
-*
-* SEE ALSO
-* LID Manager object, osm_lid_mgr_construct,
-* osm_lid_mgr_init
-*********/
-
-/****f* OpenSM: LID Manager/osm_lid_mgr_init
-* NAME
-* osm_lid_mgr_init
-*
-* DESCRIPTION
-* The osm_lid_mgr_init function initializes a
-* LID Manager object for use.
-*
-* SYNOPSIS
-*/
-ib_api_status_t
-osm_lid_mgr_init(IN osm_lid_mgr_t * const p_mgr, IN struct osm_sm * sm);
-/*
-* PARAMETERS
-* p_mgr
-* [in] Pointer to an osm_lid_mgr_t object to initialize.
-*
-* sm
-* [in] Pointer to the SM object for this subnet.
-*
-* RETURN VALUES
-* CL_SUCCESS if the LID Manager object was initialized
-* successfully.
-*
-* NOTES
-* Allows calling other LID Manager methods.
-*
-* SEE ALSO
-* LID Manager object, osm_lid_mgr_construct,
-* osm_lid_mgr_destroy
-*********/
-
-/****f* OpenSM: LID Manager/osm_lid_mgr_process_sm
-* NAME
-* osm_lid_mgr_process_sm
-*
-* DESCRIPTION
-* Configures the SM's port with its designated LID values.
-*
-* SYNOPSIS
-*/
-osm_signal_t osm_lid_mgr_process_sm(IN osm_lid_mgr_t * const p_mgr);
-/*
-* PARAMETERS
-* p_mgr
-* [in] Pointer to an osm_lid_mgr_t object.
-*
-* RETURN VALUES
-* Returns the appropriate signal to the caller:
-* OSM_SIGNAL_DONE - operation is complete
-* OSM_SIGNAL_DONE_PENDING - local operations are complete, but
-* transactions are still pending on the wire.
-*
-* NOTES
-*
-* SEE ALSO
-* LID Manager
-*********/
-
-/****f* OpenSM: LID Manager/osm_lid_mgr_process_subnet
-* NAME
-* osm_lid_mgr_process_subnet
-*
-* DESCRIPTION
-* Configures subnet ports (except the SM port itself) with their
-* designated LID values.
-*
-* SYNOPSIS
-*/
-osm_signal_t osm_lid_mgr_process_subnet(IN osm_lid_mgr_t * const p_mgr);
-/*
-* PARAMETERS
-* p_mgr
-* [in] Pointer to an osm_lid_mgr_t object.
-*
-* RETURN VALUES
-* Returns the appropriate signal to the caller:
-* OSM_SIGNAL_DONE - operation is complete
-* OSM_SIGNAL_DONE_PENDING - local operations are complete, but
-* transactions are still pending on the wire.
-*
-* NOTES
-*
-* SEE ALSO
-* LID Manager
-*********/
-
-END_C_DECLS
-#endif /* _OSM_LID_MGR_H_ */
diff --git a/contrib/ofed/management/opensm/include/opensm/osm_log.h b/contrib/ofed/management/opensm/include/opensm/osm_log.h
deleted file mode 100644
index 20999d9..0000000
--- a/contrib/ofed/management/opensm/include/opensm/osm_log.h
+++ /dev/null
@@ -1,482 +0,0 @@
-/*
- * Copyright (c) 2004-2008 Voltaire, Inc. All rights reserved.
- * Copyright (c) 2002-2006 Mellanox Technologies LTD. All rights reserved.
- * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- */
-
-/*
- * Abstract:
- * Declaration of osm_log_t.
- * This object represents the log file.
- * This object is part of the OpenSM family of objects.
- */
-
-#ifndef _OSM_LOG_H_
-#define _OSM_LOG_H_
-
-#ifndef __WIN__
-#include <syslog.h>
-#endif
-#include <complib/cl_spinlock.h>
-#include <opensm/osm_base.h>
-#include <iba/ib_types.h>
-#include <stdio.h>
-
-#ifdef __GNUC__
-#define STRICT_OSM_LOG_FORMAT __attribute__((format(printf, 3, 4)))
-#else
-#define STRICT_OSM_LOG_FORMAT
-#endif
-
-#ifdef __cplusplus
-# define BEGIN_C_DECLS extern "C" {
-# define END_C_DECLS }
-#else /* !__cplusplus */
-# define BEGIN_C_DECLS
-# define END_C_DECLS
-#endif /* __cplusplus */
-
-BEGIN_C_DECLS
-#define LOG_ENTRY_SIZE_MAX 4096
-#define BUF_SIZE LOG_ENTRY_SIZE_MAX
-#define __func__ __FUNCTION__
-#define OSM_LOG_ENTER( OSM_LOG_PTR ) \
- osm_log( OSM_LOG_PTR, OSM_LOG_FUNCS, \
- "%s: [\n", __func__);
-#define OSM_LOG_EXIT( OSM_LOG_PTR ) \
- osm_log( OSM_LOG_PTR, OSM_LOG_FUNCS, \
- "%s: ]\n", __func__);
-/****h* OpenSM/Log
-* NAME
-* Log
-*
-* DESCRIPTION
-*
-* AUTHOR
-*
-*********/
-typedef uint8_t osm_log_level_t;
-
-#define OSM_LOG_NONE 0x00
-#define OSM_LOG_ERROR 0x01
-#define OSM_LOG_INFO 0x02
-#define OSM_LOG_VERBOSE 0x04
-#define OSM_LOG_DEBUG 0x08
-#define OSM_LOG_FUNCS 0x10
-#define OSM_LOG_FRAMES 0x20
-#define OSM_LOG_ROUTING 0x40
-#define OSM_LOG_ALL 0x7f
-#define OSM_LOG_SYS 0x80
-
-/*
- DEFAULT - turn on ERROR and INFO only
-*/
-#define OSM_LOG_DEFAULT_LEVEL OSM_LOG_ERROR | OSM_LOG_INFO
-
-/****s* OpenSM: MAD Wrapper/osm_log_t
-* NAME
-* osm_log_t
-*
-* DESCRIPTION
-*
-* SYNOPSIS
-*/
-typedef struct osm_log {
- osm_log_level_t level;
- cl_spinlock_t lock;
- unsigned long count;
- unsigned long max_size;
- boolean_t flush;
- FILE *out_port;
- boolean_t accum_log_file;
- boolean_t daemon;
- char *log_file_name;
-} osm_log_t;
-/*********/
-
-/****f* OpenSM: Log/osm_log_construct
-* NAME
-* osm_log_construct
-*
-* DESCRIPTION
-* This function constructs a Log object.
-*
-* SYNOPSIS
-*/
-static inline void osm_log_construct(IN osm_log_t * const p_log)
-{
- cl_spinlock_construct(&p_log->lock);
-}
-
-/*
-* PARAMETERS
-* p_log
-* [in] Pointer to a Log object to construct.
-*
-* RETURN VALUE
-* This function does not return a value.
-*
-* NOTES
-* Allows calling osm_log_init, osm_log_init_v2, osm_log_destroy
-*
-* Calling osm_log_construct is a prerequisite to calling any other
-* method except osm_log_init or osm_log_init_v2.
-*
-* SEE ALSO
-* Log object, osm_log_init, osm_log_init_v2,
-* osm_log_destroy
-*********/
-
-/****f* OpenSM: Log/osm_log_destroy
-* NAME
-* osm_log_destroy
-*
-* DESCRIPTION
-* The osm_log_destroy function destroys the object, releasing
-* all resources.
-*
-* SYNOPSIS
-*/
-static inline void osm_log_destroy(IN osm_log_t * const p_log)
-{
- cl_spinlock_destroy(&p_log->lock);
- if (p_log->out_port != stdout) {
- fclose(p_log->out_port);
- p_log->out_port = stdout;
- }
- closelog();
-}
-
-/*
-* PARAMETERS
-* p_log
-* [in] Pointer to the object to destroy.
-*
-* RETURN VALUE
-* This function does not return a value.
-*
-* NOTES
-* Performs any necessary cleanup of the specified
-* Log object.
-* Further operations should not be attempted on the destroyed object.
-* This function should only be called after a call to
-* osm_log_construct, osm_log_init, or osm_log_init_v2.
-*
-* SEE ALSO
-* Log object, osm_log_construct,
-* osm_log_init, osm_log_init_v2
-*********/
-
-/****f* OpenSM: Log/osm_log_init_v2
-* NAME
-* osm_log_init_v2
-*
-* DESCRIPTION
-* The osm_log_init_v2 function initializes a
-* Log object for use.
-*
-* SYNOPSIS
-*/
-ib_api_status_t
-osm_log_init_v2(IN osm_log_t * const p_log,
- IN const boolean_t flush,
- IN const uint8_t log_flags,
- IN const char *log_file,
- IN const unsigned long max_size,
- IN const boolean_t accum_log_file);
-/*
-* PARAMETERS
-* p_log
-* [in] Pointer to the log object.
-*
-* flush
-* [in] Set to TRUE directs the log to flush all log messages
-* immediately. This severely degrades log performance,
-* and is normally used for debugging only.
-*
-* log_flags
-* [in] The log verbosity level to be used.
-*
-* log_file
-* [in] if not NULL defines the name of the log file. Otherwise
-* it is stdout.
-*
-* RETURN VALUES
-* CL_SUCCESS if the Log object was initialized
-* successfully.
-*
-* NOTES
-* Allows calling other Log methods.
-*
-* SEE ALSO
-* Log object, osm_log_construct,
-* osm_log_destroy
-*********/
-
-/****f* OpenSM: Log/osm_log_reopen_file
-* NAME
-* osm_log_reopen_file
-*
-* DESCRIPTION
-* The osm_log_reopen_file function reopens the log file
-*
-* SYNOPSIS
-*/
-int osm_log_reopen_file(osm_log_t * p_log);
-/*
-* PARAMETERS
-* p_log
-* [in] Pointer to the log object.
-*
-* RETURN VALUES
-* 0 on success or nonzero value otherwise.
-*********/
-
-/****f* OpenSM: Log/osm_log_init
-* NAME
-* osm_log_init
-*
-* DESCRIPTION
-* The osm_log_init function initializes a
-* Log object for use. It is a wrapper for osm_log_init_v2().
-*
-* SYNOPSIS
-*/
-ib_api_status_t
-osm_log_init(IN osm_log_t * const p_log,
- IN const boolean_t flush,
- IN const uint8_t log_flags,
- IN const char *log_file, IN const boolean_t accum_log_file);
-/*
- * Same as osm_log_init_v2() but without max_size parameter
- */
-
-void
-osm_log(IN osm_log_t * const p_log,
- IN const osm_log_level_t verbosity,
- IN const char *p_str, ...) STRICT_OSM_LOG_FORMAT;
-
-/****f* OpenSM: Log/osm_log_get_level
-* NAME
-* osm_log_get_level
-*
-* DESCRIPTION
-* Returns the current log level.
-*
-* SYNOPSIS
-*/
-static inline osm_log_level_t
-osm_log_get_level(IN const osm_log_t * const p_log)
-{
- return (p_log->level);
-}
-
-/*
-* PARAMETERS
-* p_log
-* [in] Pointer to the log object.
-*
-* RETURN VALUES
-* Returns the current log level.
-*
-* NOTES
-*
-* SEE ALSO
-* Log object, osm_log_construct,
-* osm_log_destroy
-*********/
-
-/****f* OpenSM: Log/osm_log_set_level
-* NAME
-* osm_log_set_level
-*
-* DESCRIPTION
-* Sets the current log level.
-*
-* SYNOPSIS
-*/
-static inline void
-osm_log_set_level(IN osm_log_t * const p_log, IN const osm_log_level_t level)
-{
- p_log->level = level;
- osm_log(p_log, OSM_LOG_ALL, "Setting log level to: 0x%02x\n", level);
-}
-
-/*
-* PARAMETERS
-* p_log
-* [in] Pointer to the log object.
-*
-* level
-* [in] New level to set.
-*
-* RETURN VALUES
-* Returns the current log level.
-*
-* NOTES
-*
-* SEE ALSO
-* Log object, osm_log_construct,
-* osm_log_destroy
-*********/
-
-/****f* OpenSM: Log/osm_log_is_active
-* NAME
-* osm_log_is_active
-*
-* DESCRIPTION
-* Returns TRUE if the specified log level would be logged.
-* FALSE otherwise.
-*
-* SYNOPSIS
-*/
-static inline boolean_t
-osm_log_is_active(IN const osm_log_t * const p_log,
- IN const osm_log_level_t level)
-{
- return ((p_log->level & level) != 0);
-}
-
-/*
-* PARAMETERS
-* p_log
-* [in] Pointer to the log object.
-*
-* level
-* [in] Level to check.
-*
-* RETURN VALUES
-* Returns TRUE if the specified log level would be logged.
-* FALSE otherwise.
-*
-* NOTES
-*
-* SEE ALSO
-* Log object, osm_log_construct,
-* osm_log_destroy
-*********/
-
-extern void osm_log_msg_box(osm_log_t *log, osm_log_level_t level,
- const char *func_name, const char *msg);
-extern void osm_log_raw(IN osm_log_t * const p_log,
- IN const osm_log_level_t verbosity, IN const char *p_buf);
-
-#define OSM_LOG(log, level, fmt, arg...) do { \
- if (osm_log_is_active(log, (level))) \
- osm_log(log, level, "%s: " fmt, __func__, ##arg); \
- } while (0)
-
-#define OSM_LOG_MSG_BOX(log, level, msg) \
- osm_log_msg_box(log, level, __func__, msg)
-
-#define DBG_CL_LOCK 0
-
-#define CL_PLOCK_EXCL_ACQUIRE( __exp__ ) \
-{ \
- if (DBG_CL_LOCK) \
- printf("cl_plock_excl_acquire: Acquiring %p file %s, line %d\n", \
- __exp__,__FILE__, __LINE__); \
- cl_plock_excl_acquire( __exp__ ); \
- if (DBG_CL_LOCK) \
- printf("cl_plock_excl_acquire: Acquired %p file %s, line %d\n", \
- __exp__,__FILE__, __LINE__); \
-}
-
-#define CL_PLOCK_ACQUIRE( __exp__ ) \
-{ \
- if (DBG_CL_LOCK) \
- printf("cl_plock_acquire: Acquiring %p file %s, line %d\n", \
- __exp__,__FILE__, __LINE__); \
- cl_plock_acquire( __exp__ ); \
- if (DBG_CL_LOCK) \
- printf("cl_plock_acquire: Acquired %p file %s, line %d\n", \
- __exp__,__FILE__, __LINE__); \
-}
-
-#define CL_PLOCK_RELEASE( __exp__ ) \
-{ \
- if (DBG_CL_LOCK) \
- printf("cl_plock_release: Releasing %p file %s, line %d\n", \
- __exp__,__FILE__, __LINE__); \
- cl_plock_release( __exp__ ); \
- if (DBG_CL_LOCK) \
- printf("cl_plock_release: Released %p file %s, line %d\n", \
- __exp__,__FILE__, __LINE__); \
-}
-
-#define DBG_CL_SPINLOCK 0
-#define CL_SPINLOCK_RELEASE( __exp__ ) \
-{ \
- if (DBG_CL_SPINLOCK) \
- printf("cl_spinlock_release: Releasing %p file %s, line %d\n", \
- __exp__,__FILE__, __LINE__); \
- cl_spinlock_release( __exp__ ); \
- if (DBG_CL_SPINLOCK) \
- printf("cl_spinlock_release: Released %p file %s, line %d\n", \
- __exp__,__FILE__, __LINE__); \
-}
-
-#define CL_SPINLOCK_ACQUIRE( __exp__ ) \
-{ \
- if (DBG_CL_SPINLOCK) \
- printf("cl_spinlock_acquire: Acquiring %p file %s, line %d\n", \
- __exp__,__FILE__, __LINE__); \
- cl_spinlock_acquire( __exp__ ); \
- if (DBG_CL_SPINLOCK) \
- printf("cl_spinlock_acquire: Acquired %p file %s, line %d\n", \
- __exp__,__FILE__, __LINE__); \
-}
-
-/****f* OpenSM: Helper/osm_is_debug
-* NAME
-* osm_is_debug
-*
-* DESCRIPTION
-* The osm_is_debug function returns TRUE if the opensm was compiled
-* in debug mode, and FALSE otherwise.
-*
-* SYNOPSIS
-*/
-boolean_t osm_is_debug(void);
-/*
-* PARAMETERS
-* None
-*
-* RETURN VALUE
-* TRUE if compiled in debug version. FALSE otherwise.
-*
-* NOTES
-*
-*********/
-
-END_C_DECLS
-#endif /* _OSM_LOG_H_ */
diff --git a/contrib/ofed/management/opensm/include/opensm/osm_mad_pool.h b/contrib/ofed/management/opensm/include/opensm/osm_mad_pool.h
deleted file mode 100644
index 0aa5b46..0000000
--- a/contrib/ofed/management/opensm/include/opensm/osm_mad_pool.h
+++ /dev/null
@@ -1,372 +0,0 @@
-/*
- * Copyright (c) 2004-2008 Voltaire, Inc. All rights reserved.
- * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved.
- * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- */
-
-/*
- * Abstract:
- * Declaration of osm_mad_pool_t.
- * This object represents a pool of management datagram (MAD) objects.
- * This object is part of the OpenSM family of objects.
- */
-
-#ifndef _OSM_MAD_POOL_H_
-#define _OSM_MAD_POOL_H_
-
-#include <iba/ib_types.h>
-#include <complib/cl_atomic.h>
-#include <opensm/osm_base.h>
-#include <opensm/osm_madw.h>
-#include <vendor/osm_vendor.h>
-
-#ifdef __cplusplus
-# define BEGIN_C_DECLS extern "C" {
-# define END_C_DECLS }
-#else /* !__cplusplus */
-# define BEGIN_C_DECLS
-# define END_C_DECLS
-#endif /* __cplusplus */
-
-BEGIN_C_DECLS
-/****h* OpenSM/MAD Pool
-* NAME
-* MAD Pool
-*
-* DESCRIPTION
-* The MAD Pool encapsulates the information needed by the
-* OpenSM to manage a pool of MAD objects. The OpenSM allocates
-* one MAD Pool per IBA subnet.
-*
-* The MAD Pool is thread safe.
-*
-* This object should be treated as opaque and should be
-* manipulated only through the provided functions.
-*
-* AUTHOR
-* Steve King, Intel
-*
-*********/
-/****s* OpenSM: MAD Pool/osm_mad_pool_t
-* NAME
-* osm_mad_pool_t
-*
-* DESCRIPTION
-* MAD Pool structure.
-*
-* This object should be treated as opaque and should
-* be manipulated only through the provided functions.
-*
-* SYNOPSIS
-*/
-typedef struct osm_mad_pool {
- atomic32_t mads_out;
-} osm_mad_pool_t;
-/*
-* FIELDS
-* mads_out
-* Running total of the number of MADs outstanding.
-*
-* SEE ALSO
-* MAD Pool
-*********/
-
-/****f* OpenSM: MAD Pool/osm_mad_pool_construct
-* NAME
-* osm_mad_pool_construct
-*
-* DESCRIPTION
-* This function constructs a MAD Pool.
-*
-* SYNOPSIS
-*/
-void osm_mad_pool_construct(IN osm_mad_pool_t * const p_pool);
-/*
-* PARAMETERS
-* p_pool
-* [in] Pointer to a MAD Pool to construct.
-*
-* RETURN VALUE
-* This function does not return a value.
-*
-* NOTES
-* Allows calling osm_mad_pool_init, osm_mad_pool_destroy
-*
-* Calling osm_mad_pool_construct is a prerequisite to calling any other
-* method except osm_mad_pool_init.
-*
-* SEE ALSO
-* MAD Pool, osm_mad_pool_init, osm_mad_pool_destroy
-*********/
-
-/****f* OpenSM: MAD Pool/osm_mad_pool_destroy
-* NAME
-* osm_mad_pool_destroy
-*
-* DESCRIPTION
-* The osm_mad_pool_destroy function destroys a node, releasing
-* all resources.
-*
-* SYNOPSIS
-*/
-void osm_mad_pool_destroy(IN osm_mad_pool_t * const p_pool);
-/*
-* PARAMETERS
-* p_pool
-* [in] Pointer to a MAD Pool to destroy.
-*
-* RETURN VALUE
-* This function does not return a value.
-*
-* NOTES
-* Performs any necessary cleanup of the specified MAD Pool.
-* Further operations should not be attempted on the destroyed object.
-* This function should only be called after a call to osm_mad_pool_construct or
-* osm_mad_pool_init.
-*
-* SEE ALSO
-* MAD Pool, osm_mad_pool_construct, osm_mad_pool_init
-*********/
-
-/****f* OpenSM: MAD Pool/osm_mad_pool_init
-* NAME
-* osm_mad_pool_init
-*
-* DESCRIPTION
-* The osm_mad_pool_init function initializes a MAD Pool for use.
-*
-* SYNOPSIS
-*/
-ib_api_status_t osm_mad_pool_init(IN osm_mad_pool_t * const p_pool);
-/*
-* PARAMETERS
-* p_pool
-* [in] Pointer to an osm_mad_pool_t object to initialize.
-*
-* RETURN VALUES
-* CL_SUCCESS if the MAD Pool was initialized successfully.
-*
-* NOTES
-* Allows calling other MAD Pool methods.
-*
-* SEE ALSO
-* MAD Pool, osm_mad_pool_construct, osm_mad_pool_destroy
-*********/
-
-/****f* OpenSM: MAD Pool/osm_mad_pool_get
-* NAME
-* osm_mad_pool_get
-*
-* DESCRIPTION
-* Gets a MAD wrapper and wire MAD from the pool.
-*
-* SYNOPSIS
-*/
-osm_madw_t *osm_mad_pool_get(IN osm_mad_pool_t * const p_pool,
- IN osm_bind_handle_t h_bind,
- IN const uint32_t total_size,
- IN const osm_mad_addr_t * const p_mad_addr);
-/*
-* PARAMETERS
-* p_pool
-* [in] Pointer to an osm_mad_pool_t object.
-*
-* h_bind
-* [in] Handle returned from osm_vendor_bind() call to the
-* port over which this mad will be sent.
-*
-* total_size
-* [in] Total size, including MAD header of the requested MAD.
-*
-* p_mad_addr
-* [in] Pointer to the MAD address structure. This parameter
-* may be NULL for directed route MADs.
-*
-* RETURN VALUES
-* Returns a pointer to a MAD wrapper containing the MAD.
-* A return value of NULL means no MADs are available.
-*
-* NOTES
-* The MAD must eventually be returned to the pool with a call to
-* osm_mad_pool_put.
-*
-* The osm_mad_pool_construct or osm_mad_pool_init must be called before
-* using this function.
-*
-* SEE ALSO
-* MAD Pool, osm_mad_pool_put
-*********/
-
-/****f* OpenSM: MAD Pool/osm_mad_pool_put
-* NAME
-* osm_mad_pool_put
-*
-* DESCRIPTION
-* Returns a MAD to the pool.
-*
-* SYNOPSIS
-*/
-void osm_mad_pool_put(IN osm_mad_pool_t * const p_pool,
- IN osm_madw_t * const p_madw);
-/*
-* PARAMETERS
-* p_pool
-* [in] Pointer to an osm_mad_pool_t object.
-*
-* p_madw
-* [in] Pointer to a MAD Wrapper for a MAD that was previously
-* retrieved from the pool.
-*
-* RETURN VALUES
-* This function does not return a value.
-*
-* NOTES
-* The osm_mad_pool_construct or osm_mad_pool_init must be called before
-* using this function.
-*
-* SEE ALSO
-* MAD Pool, osm_mad_pool_get
-*********/
-
-/****f* OpenSM: MAD Pool/osm_mad_pool_get_wrapper
-* NAME
-* osm_mad_pool_get_wrapper
-*
-* DESCRIPTION
-* Gets a only MAD wrapper from the pool (no wire MAD).
-*
-* SYNOPSIS
-*/
-osm_madw_t *osm_mad_pool_get_wrapper(IN osm_mad_pool_t * const p_pool,
- IN osm_bind_handle_t h_bind,
- IN const uint32_t total_size,
- IN const ib_mad_t * const p_mad,
- IN const osm_mad_addr_t *
- const p_mad_addr);
-/*
-* PARAMETERS
-* p_pool
-* [in] Pointer to an osm_mad_pool_t object.
-*
-* h_bind
-* [in] Handle returned from osm_vendor_bind() call to the
-* port for which this mad wrapper will be used.
-*
-* total_size
-* [in] Total size, including MAD header of the MAD that will
-* be attached to this wrapper.
-*
-* p_mad
-* [in] Pointer to the MAD to attach to this wrapper.
-*
-* p_mad_addr
-* [in] Pointer to the MAD address structure. This parameter
-* may be NULL for directed route MADs.
-*
-* RETURN VALUES
-* Returns a pointer to a MAD wrapper.
-* A return value of NULL means no MAD wrappers are available.
-*
-* NOTES
-* The MAD must eventually be returned to the pool with a call to
-* osm_mad_pool_put.
-*
-* The osm_mad_pool_construct or osm_mad_pool_init must be called before
-* using this function.
-*
-* SEE ALSO
-* MAD Pool, osm_mad_pool_put
-*********/
-
-/****f* OpenSM: MAD Pool/osm_mad_pool_get_wrapper_raw
-* NAME
-* osm_mad_pool_get_wrapper_raw
-*
-* DESCRIPTION
-* Gets a only an uninitialized MAD wrapper from the pool (no wire MAD).
-*
-* SYNOPSIS
-*/
-osm_madw_t *osm_mad_pool_get_wrapper_raw(IN osm_mad_pool_t * const p_pool);
-/*
-* PARAMETERS
-* p_pool
-* [in] Pointer to an osm_mad_pool_t object.
-*
-* RETURN VALUES
-* Returns a pointer to a MAD wrapper.
-* A return value of NULL means no MAD wrappers are available.
-*
-* NOTES
-* The MAD must eventually be returned to the pool with a call to
-* osm_mad_pool_put.
-*
-* The osm_mad_pool_construct or osm_mad_pool_init must be called before
-* using this function.
-*
-* SEE ALSO
-* MAD Pool, osm_mad_pool_put
-*********/
-
-/****f* OpenSM: MAD Pool/osm_mad_pool_get_outstanding
-* NAME
-* osm_mad_pool_get_count
-*
-* DESCRIPTION
-* Returns the running count of MADs currently outstanding from the pool.
-*
-* SYNOPSIS
-*/
-static inline uint32_t
-osm_mad_pool_get_outstanding(IN const osm_mad_pool_t * const p_pool)
-{
- return (p_pool->mads_out);
-}
-
-/*
-* PARAMETERS
-* p_pool
-* [in] Pointer to an osm_mad_pool_t object.
-*
-* RETURN VALUES
-* Returns the running count of MADs currently outstanding from the pool.
-*
-* NOTES
-* The osm_mad_pool_construct or osm_mad_pool_init must be called before
-* using this function.
-*
-* SEE ALSO
-* MAD Pool, osm_mad_pool_get
-*********/
-
-END_C_DECLS
-#endif /* _OSM_MAD_POOL_H_ */
diff --git a/contrib/ofed/management/opensm/include/opensm/osm_madw.h b/contrib/ofed/management/opensm/include/opensm/osm_madw.h
deleted file mode 100644
index f47142d..0000000
--- a/contrib/ofed/management/opensm/include/opensm/osm_madw.h
+++ /dev/null
@@ -1,1115 +0,0 @@
-/*
- * Copyright (c) 2004-2008 Voltaire, Inc. All rights reserved.
- * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved.
- * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- */
-
-/*
- * Abstract:
- * Declaration of osm_mad_wrapper_t.
- * This object represents the context wrapper for OpenSM MAD processing.
- * This object is part of the OpenSM family of objects.
- */
-
-#ifndef _OSM_MADW_H_
-#define _OSM_MADW_H_
-
-#include <string.h>
-#include <iba/ib_types.h>
-#include <complib/cl_qlist.h>
-#include <complib/cl_dispatcher.h>
-#include <opensm/osm_base.h>
-#include <vendor/osm_vendor.h>
-
-#ifdef __cplusplus
-# define BEGIN_C_DECLS extern "C" {
-# define END_C_DECLS }
-#else /* !__cplusplus */
-# define BEGIN_C_DECLS
-# define END_C_DECLS
-#endif /* __cplusplus */
-
-BEGIN_C_DECLS
-/****s* OpenSM: MAD Wrapper/osm_bind_info_t
-* NAME
-* osm_bind_info_t
-*
-* DESCRIPTION
-*
-* SYNOPSIS
-*/
-typedef struct osm_bind_info {
- ib_net64_t port_guid;
- uint8_t mad_class;
- uint8_t class_version;
- boolean_t is_responder;
- boolean_t is_trap_processor;
- boolean_t is_report_processor;
- uint32_t send_q_size;
- uint32_t recv_q_size;
-} osm_bind_info_t;
-/*
-* FIELDS
-* portguid
-* PortGuid of local port
-*
-* mad_class
-* Mgmt Class ID
-*
-* class_version
-* Mgmt Class version
-*
-* is_responder
-* True if this is a GSI Agent
-*
-* is_trap_processor
-* True if GSI Trap msgs are handled
-*
-* is_report_processor
-* True if GSI Report msgs are handled
-*
-* send_q_size
-* SendQueueSize
-*
-* recv_q_size
-* Receive Queue Size
-*
-* SEE ALSO
-*********/
-
-/****h* OpenSM/MAD Wrapper
-* NAME
-* MAD Wrapper
-*
-* DESCRIPTION
-* The MAD Wrapper object encapsulates the information needed by the
-* OpenSM to manage individual MADs. The OpenSM allocates one MAD Wrapper
-* per MAD.
-*
-* The MAD Wrapper is not thread safe, thus callers must provide
-* serialization.
-*
-* This object should be treated as opaque and should be
-* manipulated only through the provided functions.
-*
-* AUTHOR
-* Steve King, Intel
-*
-*********/
-
-/****s* OpenSM: MAD Wrapper/osm_ni_context_t
-* NAME
-* osm_ni_context_t
-*
-* DESCRIPTION
-* Context needed by recipient of NodeInfo attribute.
-*
-* SYNOPSIS
-*/
-typedef struct osm_ni_context {
- ib_net64_t node_guid;
- uint8_t port_num;
- ib_net64_t dup_node_guid;
- uint8_t dup_port_num;
- unsigned dup_count;
-} osm_ni_context_t;
-/*
-* FIELDS
-* p_node
-* Pointer to the node thru which we got to this node.
-*
-* p_sw
-* Pointer to the switch object (if any) of the switch
-* thru which we got to this node.
-*
-* port_num
-* Port number on the node or switch thru which we got
-* to this node.
-*
-* SEE ALSO
-*********/
-
-/****s* OpenSM: MAD Wrapper/osm_pi_context_t
-* NAME
-* osm_pi_context_t
-*
-* DESCRIPTION
-* Context needed by recipient of PortInfo attribute.
-*
-* SYNOPSIS
-*/
-typedef struct osm_pi_context {
- ib_net64_t node_guid;
- ib_net64_t port_guid;
- boolean_t set_method;
- boolean_t light_sweep;
- boolean_t active_transition;
-} osm_pi_context_t;
-/*********/
-
-/****s* OpenSM: MAD Wrapper/osm_nd_context_t
-* NAME
-* osm_nd_context_t
-*
-* DESCRIPTION
-* Context needed by recipient of NodeDescription attribute.
-*
-* SYNOPSIS
-*/
-typedef struct osm_nd_context {
- ib_net64_t node_guid;
-} osm_nd_context_t;
-/*********/
-
-/****s* OpenSM: MAD Wrapper/osm_si_context_t
-* NAME
-* osm_si_context_t
-*
-* DESCRIPTION
-* Context needed by recipient of SwitchInfo attribute.
-*
-* SYNOPSIS
-*/
-typedef struct osm_si_context {
- ib_net64_t node_guid;
- boolean_t set_method;
- boolean_t light_sweep;
-} osm_si_context_t;
-/*********/
-
-/****s* OpenSM: MAD Wrapper/osm_lft_context_t
-* NAME
-* osm_lft_context_t
-*
-* DESCRIPTION
-* Context needed by recipient of LinearForwardingTable attribute.
-*
-* SYNOPSIS
-*/
-typedef struct osm_lft_context {
- ib_net64_t node_guid;
- boolean_t set_method;
-} osm_lft_context_t;
-/*********/
-
-/****s* OpenSM: MAD Wrapper/osm_mft_context_t
-* NAME
-* osm_mft_context_t
-*
-* DESCRIPTION
-* Context needed by recipient of MulticastForwardingTable attribute.
-*
-* SYNOPSIS
-*/
-typedef struct osm_mft_context {
- ib_net64_t node_guid;
- boolean_t set_method;
-} osm_mft_context_t;
-/*********/
-
-/****s* OpenSM: MAD Wrapper/osm_smi_context_t
-* NAME
-* osm_smi_context_t
-*
-* DESCRIPTION
-* Context needed by recipient of SMInfo attribute.
-*
-* SYNOPSIS
-*/
-typedef struct osm_smi_context {
- ib_net64_t port_guid;
- boolean_t set_method;
- boolean_t light_sweep;
-} osm_smi_context_t;
-/*********/
-
-/****s* OpenSM: MAD Wrapper/osm_pkey_context_t
-* NAME
-* osm_pkey_context_t
-*
-* DESCRIPTION
-* Context needed by recipient of P_Key attribute.
-*
-* SYNOPSIS
-*/
-typedef struct osm_pkey_context {
- ib_net64_t node_guid;
- ib_net64_t port_guid;
- boolean_t set_method;
-} osm_pkey_context_t;
-/*********/
-
-/****s* OpenSM: MAD Wrapper/osm_slvl_context_t
-* NAME
-* osm_slvl_context_t
-*
-* DESCRIPTION
-* Context needed by recipient of PortInfo attribute.
-*
-* SYNOPSIS
-*/
-typedef struct osm_slvl_context {
- ib_net64_t node_guid;
- ib_net64_t port_guid;
- boolean_t set_method;
-} osm_slvl_context_t;
-/*********/
-
-/****s* OpenSM: MAD Wrapper/osm_vla_context_t
-* NAME
-* osm_vla_context_t
-*
-* DESCRIPTION
-* Context needed by recipient of VL Arb attribute.
-*
-* SYNOPSIS
-*/
-typedef struct osm_vla_context {
- ib_net64_t node_guid;
- ib_net64_t port_guid;
- boolean_t set_method;
-} osm_vla_context_t;
-/*********/
-
-/****s* OpenSM: MAD Wrapper/osm_perfmgr_context_t
-* DESCRIPTION
-* Context for Performance manager queries
-*/
-typedef struct osm_perfmgr_context {
- uint64_t node_guid;
- uint16_t port;
- uint8_t mad_method; /* was this a get or a set */
-#if ENABLE_OSM_PERF_MGR_PROFILE
- struct timeval query_start;
-#endif
-} osm_perfmgr_context_t;
-/*********/
-
-#ifndef OSM_VENDOR_INTF_OPENIB
-/****s* OpenSM: MAD Wrapper/osm_arbitrary_context_t
-* NAME
-* osm_arbitrary_context_t
-*
-* DESCRIPTION
-* Context needed by arbitrary recipient.
-*
-* SYNOPSIS
-*/
-typedef struct osm_arbitrary_context {
- void *context1;
- void *context2;
-} osm_arbitrary_context_t;
-/*********/
-#endif
-
-/****s* OpenSM: MAD Wrapper/osm_madw_context_t
-* NAME
-* osm_madw_context_t
-*
-* DESCRIPTION
-* Context needed by recipients of MAD responses.
-*
-* SYNOPSIS
-*/
-typedef union _osm_madw_context {
- osm_ni_context_t ni_context;
- osm_pi_context_t pi_context;
- osm_nd_context_t nd_context;
- osm_si_context_t si_context;
- osm_lft_context_t lft_context;
- osm_mft_context_t mft_context;
- osm_smi_context_t smi_context;
- osm_slvl_context_t slvl_context;
- osm_pkey_context_t pkey_context;
- osm_vla_context_t vla_context;
- osm_perfmgr_context_t perfmgr_context;
-#ifndef OSM_VENDOR_INTF_OPENIB
- osm_arbitrary_context_t arb_context;
-#endif
-} osm_madw_context_t;
-/*********/
-
-/****s* OpenSM: MAD Wrapper/osm_mad_addr_t
-* NAME
-* osm_mad_addr_t
-*
-* DESCRIPTION
-*
-* SYNOPSIS
-*/
-typedef struct osm_mad_addr {
- ib_net16_t dest_lid;
- uint8_t path_bits;
- uint8_t static_rate;
- union addr_type {
- struct _smi {
- ib_net16_t source_lid;
- uint8_t port_num;
- } smi;
-
- struct _gsi {
- ib_net32_t remote_qp;
- ib_net32_t remote_qkey;
- uint16_t pkey_ix;
- uint8_t service_level;
- boolean_t global_route;
- ib_grh_t grh_info;
- } gsi;
- } addr_type;
-} osm_mad_addr_t;
-/*
-* FIELDS
-*
-* SEE ALSO
-*********/
-
-/****s* OpenSM: MAD Wrapper/osm_madw_t
-* NAME
-* osm_madw_t
-*
-* DESCRIPTION
-* Context needed for processing individual MADs
-*
-* SYNOPSIS
-*/
-typedef struct osm_madw {
- cl_list_item_t list_item;
- osm_bind_handle_t h_bind;
- osm_vend_wrap_t vend_wrap;
- osm_mad_addr_t mad_addr;
- osm_bind_info_t bind_info;
- osm_madw_context_t context;
- uint32_t mad_size;
- ib_api_status_t status;
- cl_disp_msgid_t fail_msg;
- boolean_t resp_expected;
- const ib_mad_t *p_mad;
-} osm_madw_t;
-/*
-* FIELDS
-* list_item
-* List linkage for lists. MUST BE FIRST MEMBER!
-*
-* h_bind
-* Bind handle for the port on which this MAD will be sent
-* or was received.
-*
-* vend_wrap
-* Transport vendor specific context. This structure is not
-* used outside MAD transport vendor specific code.
-*
-* context
-* Union of controller specific contexts needed for this MAD.
-* This structure allows controllers to indirectly communicate
-* with each other through the dispatcher.
-*
-* mad_size
-* Size of this MAD in bytes.
-*
-* status
-* Status of completed operation on the MAD.
-* CL_SUCCESS if the operation was successful.
-*
-* fail_msg
-* Dispatcher message with which to post this MAD on failure.
-* This value is set by the originator of the MAD.
-* If an operation on this MAD fails, for example due to a timeout,
-* then the transport layer will dispose of the MAD by sending
-* it through the Dispatcher with this message type. Presumably,
-* there is a controller listening for the failure message that can
-* properly clean up.
-*
-* resp_expected
-* TRUE if a response is expected to this MAD.
-* FALSE otherwise.
-*
-* p_mad
-* Pointer to the wire MAD. The MAD itself cannot be part of the
-* wrapper, since wire MADs typically reside in special memory
-* registered with the local HCA.
-*
-* SEE ALSO
-*********/
-
-/****f* OpenSM: MAD Wrapper/osm_madw_init
-* NAME
-* osm_madw_init
-*
-* DESCRIPTION
-* Initializes a MAD Wrapper object for use.
-*
-* SYNOPSIS
-*/
-static inline void
-osm_madw_init(IN osm_madw_t * const p_madw,
- IN osm_bind_handle_t h_bind,
- IN const uint32_t mad_size,
- IN const osm_mad_addr_t * const p_mad_addr)
-{
- memset(p_madw, 0, sizeof(*p_madw));
- p_madw->h_bind = h_bind;
- p_madw->fail_msg = CL_DISP_MSGID_NONE;
- p_madw->mad_size = mad_size;
- if (p_mad_addr)
- p_madw->mad_addr = *p_mad_addr;
- p_madw->resp_expected = FALSE;
-}
-
-/*
-* PARAMETERS
-* p_madw
-* [in] Pointer to an osm_madw_t object to initialize.
-*
-* h_bind
-* [in] Pointer to the wire MAD.
-*
-* p_mad_addr
-* [in] Pointer to the MAD address structure. This parameter may
-* be NULL for directed route MADs.
-*
-* RETURN VALUES
-* None.
-*
-* NOTES
-*
-* SEE ALSO
-*********/
-
-/****f* OpenSM: MAD Wrapper/osm_madw_get_smp_ptr
-* NAME
-* osm_madw_get_smp_ptr
-*
-* DESCRIPTION
-* Gets a pointer to the SMP in this MAD.
-*
-* SYNOPSIS
-*/
-static inline ib_smp_t *osm_madw_get_smp_ptr(IN const osm_madw_t * const p_madw)
-{
- return ((ib_smp_t *) p_madw->p_mad);
-}
-
-/*
-* PARAMETERS
-* p_madw
-* [in] Pointer to an osm_madw_t object to initialize.
-*
-* RETURN VALUES
-* Pointer to the start of the SMP MAD.
-*
-* NOTES
-*
-* SEE ALSO
-* MAD Wrapper object
-*********/
-
-/****f* OpenSM: MAD Wrapper/osm_madw_get_sa_mad_ptr
-* NAME
-* osm_madw_get_sa_mad_ptr
-*
-* DESCRIPTION
-* Gets a pointer to the SA MAD in this MAD wrapper.
-*
-* SYNOPSIS
-*/
-static inline ib_sa_mad_t *osm_madw_get_sa_mad_ptr(IN const osm_madw_t *
- const p_madw)
-{
- return ((ib_sa_mad_t *) p_madw->p_mad);
-}
-
-/*
-* PARAMETERS
-* p_madw
-* [in] Pointer to an osm_madw_t object.
-*
-* RETURN VALUES
-* Pointer to the start of the SA MAD.
-*
-* NOTES
-*
-* SEE ALSO
-* MAD Wrapper object
-*********/
-
-/****f* OpenSM: MAD Wrapper/osm_madw_get_perfmgt_mad_ptr
-* DESCRIPTION
-* Gets a pointer to the PerfMgt MAD in this MAD wrapper.
-*
-* SYNOPSIS
-*/
-static inline ib_perfmgt_mad_t *osm_madw_get_perfmgt_mad_ptr(IN const osm_madw_t
- * const p_madw)
-{
- return ((ib_perfmgt_mad_t *) p_madw->p_mad);
-}
-
-/*
-* PARAMETERS
-* p_madw
-* [in] Pointer to an osm_madw_t object.
-*
-* RETURN VALUES
-* Pointer to the start of the PerfMgt MAD.
-*
-* NOTES
-*
-* SEE ALSO
-* MAD Wrapper object
-*********/
-
-/****f* OpenSM: MAD Wrapper/osm_madw_get_ni_context_ptr
-* NAME
-* osm_madw_get_ni_context_ptr
-*
-* DESCRIPTION
-* Gets a pointer to the NodeInfo context in this MAD.
-*
-* SYNOPSIS
-*/
-static inline osm_ni_context_t *osm_madw_get_ni_context_ptr(IN const osm_madw_t
- * const p_madw)
-{
- return ((osm_ni_context_t *) & p_madw->context);
-}
-
-/*
-* PARAMETERS
-* p_madw
-* [in] Pointer to an osm_madw_t object.
-*
-* RETURN VALUES
-* Pointer to the start of the context structure.
-*
-* NOTES
-*
-* SEE ALSO
-*********/
-
-/****f* OpenSM: MAD Wrapper/osm_madw_get_pi_context_ptr
-* NAME
-* osm_madw_get_pi_context_ptr
-*
-* DESCRIPTION
-* Gets a pointer to the PortInfo context in this MAD.
-*
-* SYNOPSIS
-*/
-static inline osm_pi_context_t *osm_madw_get_pi_context_ptr(IN const osm_madw_t
- * const p_madw)
-{
- return ((osm_pi_context_t *) & p_madw->context);
-}
-
-/*
-* PARAMETERS
-* p_madw
-* [in] Pointer to an osm_madw_t object.
-*
-* RETURN VALUES
-* Pointer to the start of the context structure.
-*
-* NOTES
-*
-* SEE ALSO
-*********/
-
-/****f* OpenSM: MAD Wrapper/osm_madw_get_nd_context_ptr
-* NAME
-* osm_madw_get_nd_context_ptr
-*
-* DESCRIPTION
-* Gets a pointer to the NodeDescription context in this MAD.
-*
-* SYNOPSIS
-*/
-static inline osm_nd_context_t *osm_madw_get_nd_context_ptr(IN const osm_madw_t
- * const p_madw)
-{
- return ((osm_nd_context_t *) & p_madw->context);
-}
-
-/*
-* PARAMETERS
-* p_madw
-* [in] Pointer to an osm_madw_t object.
-*
-* RETURN VALUES
-* Pointer to the start of the context structure.
-*
-* NOTES
-*
-* SEE ALSO
-*********/
-
-/****f* OpenSM: MAD Wrapper/osm_madw_get_lft_context_ptr
-* NAME
-* osm_madw_get_lft_context_ptr
-*
-* DESCRIPTION
-* Gets a pointer to the LFT context in this MAD.
-*
-* SYNOPSIS
-*/
-static inline osm_lft_context_t *osm_madw_get_lft_context_ptr(IN const
- osm_madw_t *
- const p_madw)
-{
- return ((osm_lft_context_t *) & p_madw->context);
-}
-
-/*
-* PARAMETERS
-* p_madw
-* [in] Pointer to an osm_madw_t object.
-*
-* RETURN VALUES
-* Pointer to the start of the context structure.
-*
-* NOTES
-*
-* SEE ALSO
-*********/
-
-/****f* OpenSM: MAD Wrapper/osm_madw_get_mft_context_ptr
-* NAME
-* osm_madw_get_mft_context_ptr
-*
-* DESCRIPTION
-* Gets a pointer to the MFT context in this MAD.
-*
-* SYNOPSIS
-*/
-static inline osm_mft_context_t *osm_madw_get_mft_context_ptr(IN const
- osm_madw_t *
- const p_madw)
-{
- return ((osm_mft_context_t *) & p_madw->context);
-}
-
-/*
-* PARAMETERS
-* p_madw
-* [in] Pointer to an osm_madw_t object.
-*
-* RETURN VALUES
-* Pointer to the start of the context structure.
-*
-* NOTES
-*
-* SEE ALSO
-*********/
-
-/****f* OpenSM: MAD Wrapper/osm_madw_get_si_context_ptr
-* NAME
-* osm_madw_get_si_context_ptr
-*
-* DESCRIPTION
-* Gets a pointer to the SwitchInfo context in this MAD.
-*
-* SYNOPSIS
-*/
-static inline osm_si_context_t *osm_madw_get_si_context_ptr(IN const osm_madw_t
- * const p_madw)
-{
- return ((osm_si_context_t *) & p_madw->context);
-}
-
-/*
-* PARAMETERS
-* p_madw
-* [in] Pointer to an osm_madw_t object.
-*
-* RETURN VALUES
-* Pointer to the start of the context structure.
-*
-* NOTES
-*
-* SEE ALSO
-*********/
-
-/****f* OpenSM: MAD Wrapper/osm_madw_get_smi_context_ptr
-* NAME
-* osm_madw_get_smi_context_ptr
-*
-* DESCRIPTION
-* Gets a pointer to the SMInfo context in this MAD.
-*
-* SYNOPSIS
-*/
-static inline osm_smi_context_t *osm_madw_get_smi_context_ptr(IN const
- osm_madw_t *
- const p_madw)
-{
- return ((osm_smi_context_t *) & p_madw->context);
-}
-
-/*
-* PARAMETERS
-* p_madw
-* [in] Pointer to an osm_madw_t object.
-*
-* RETURN VALUES
-* Pointer to the start of the context structure.
-*
-* NOTES
-*
-* SEE ALSO
-*********/
-
-/****f* OpenSM: MAD Wrapper/osm_madw_get_pkey_context_ptr
-* NAME
-* osm_madw_get_pkey_context_ptr
-*
-* DESCRIPTION
-* Gets a pointer to the P_Key context in this MAD.
-*
-* SYNOPSIS
-*/
-static inline osm_pkey_context_t *osm_madw_get_pkey_context_ptr(IN const
- osm_madw_t *
- const p_madw)
-{
- return ((osm_pkey_context_t *) & p_madw->context);
-}
-
-/*
-* PARAMETERS
-* p_madw
-* [in] Pointer to an osm_madw_t object.
-*
-* RETURN VALUES
-* Pointer to the start of the context structure.
-*
-* NOTES
-*
-* SEE ALSO
-*********/
-
-/****f* OpenSM: MAD Wrapper/osm_madw_get_slvl_context_ptr
-* NAME
-* osm_madw_get_slvl_context_ptr
-*
-* DESCRIPTION
-* Gets a pointer to the PortInfo context in this MAD.
-*
-* SYNOPSIS
-*/
-static inline osm_slvl_context_t *osm_madw_get_slvl_context_ptr(IN const
- osm_madw_t *
- const p_madw)
-{
- return ((osm_slvl_context_t *) & p_madw->context);
-}
-
-/*
-* PARAMETERS
-* p_madw
-* [in] Pointer to an osm_madw_t object.
-*
-* RETURN VALUES
-* Pointer to the start of the context structure.
-*
-* NOTES
-*
-* SEE ALSO
-*********/
-
-/****f* OpenSM: MAD Wrapper/osm_madw_get_vla_context_ptr
-* NAME
-* osm_madw_get_vla_context_ptr
-*
-* DESCRIPTION
-* Gets a pointer to the Vl Arb context in this MAD.
-*
-* SYNOPSIS
-*/
-static inline osm_vla_context_t *osm_madw_get_vla_context_ptr(IN const
- osm_madw_t *
- const p_madw)
-{
- return ((osm_vla_context_t *) & p_madw->context);
-}
-
-/*
-* PARAMETERS
-* p_madw
-* [in] Pointer to an osm_madw_t object.
-*
-* RETURN VALUES
-* Pointer to the start of the context structure.
-*
-* NOTES
-*
-* SEE ALSO
-*********/
-
-#ifndef OSM_VENDOR_INTF_OPENIB
-/****f* OpenSM: MAD Wrapper/osm_madw_get_arbitrary_context_ptr
-* NAME
-* osm_madw_get_arbitrary_context_ptr
-*
-* DESCRIPTION
-* Gets a pointer to the arbitrary context in this MAD.
-*
-* SYNOPSIS
-*/
-static inline osm_arbitrary_context_t *osm_madw_get_arbitrary_context_ptr(IN
- const
- osm_madw_t
- *
- const
- p_madw)
-{
- return ((osm_arbitrary_context_t *) & p_madw->context);
-}
-
-/*
-* PARAMETERS
-* p_madw
-* [in] Pointer to an osm_madw_t object.
-*
-* RETURN VALUES
-* Pointer to the start of the context structure.
-*
-* NOTES
-*
-* SEE ALSO
-*********/
-#endif
-
-/****f* OpenSM: MAD Wrapper/osm_madw_get_vend_ptr
-* NAME
-* osm_madw_get_vend_ptr
-*
-* DESCRIPTION
-* Gets a pointer to the vendor specific MAD wrapper component.
-*
-* SYNOPSIS
-*/
-static inline osm_vend_wrap_t *osm_madw_get_vend_ptr(IN const osm_madw_t *
- const p_madw)
-{
- return ((osm_vend_wrap_t *) & p_madw->vend_wrap);
-}
-
-/*
-* PARAMETERS
-* p_madw
-* [in] Pointer to an osm_madw_t object.
-*
-* RETURN VALUES
-* Gets a pointer to the vendor specific MAD wrapper component.
-*
-* NOTES
-*
-* SEE ALSO
-*********/
-
-/****f* OpenSM: MAD Wrapper/osm_madw_get_vend_ptr
-* NAME
-* osm_madw_get_vend_ptr
-*
-* DESCRIPTION
-* Returns the bind handle associated with this MAD.
-*
-* SYNOPSIS
-*/
-static inline osm_bind_handle_t
-osm_madw_get_bind_handle(IN const osm_madw_t * const p_madw)
-{
- return ((osm_bind_handle_t) p_madw->h_bind);
-}
-
-/*
-* PARAMETERS
-* p_madw
-* [in] Pointer to an osm_madw_t object.
-*
-* RETURN VALUES
-* Returns the bind handle associated with this MAD.
-*
-* NOTES
-*
-* SEE ALSO
-*********/
-
-/****f* OpenSM: MAD Wrapper/osm_madw_get_mad_addr_ptr
-* NAME
-* osm_madw_get_mad_addr_ptr
-*
-* DESCRIPTION
-* Returns the mad address structure associated with this MAD.
-*
-* SYNOPSIS
-*/
-static inline osm_mad_addr_t *osm_madw_get_mad_addr_ptr(IN const osm_madw_t *
- const p_madw)
-{
- return ((osm_mad_addr_t *) & p_madw->mad_addr);
-}
-
-/*
-* PARAMETERS
-* p_madw
-* [in] Pointer to an osm_madw_t object.
-*
-* RETURN VALUES
-* Returns the mad address structure associated with this MAD.
-*
-* NOTES
-*
-* SEE ALSO
-*********/
-
-/****f* OpenSM: MAD Wrapper/osm_madw_get_mad_ptr
-* NAME
-* osm_madw_get_mad_ptr
-*
-* DESCRIPTION
-* Returns the mad address structure associated with this MAD.
-*
-* SYNOPSIS
-*/
-static inline ib_mad_t *osm_madw_get_mad_ptr(IN const osm_madw_t * const p_madw)
-{
- return ((ib_mad_t *) p_madw->p_mad);
-}
-
-/*
-* PARAMETERS
-* p_madw
-* [in] Pointer to an osm_madw_t object.
-*
-* RETURN VALUES
-* Returns the mad address structure associated with this MAD.
-*
-* NOTES
-*
-* SEE ALSO
-*********/
-
-/****f* OpenSM: MAD Wrapper/osm_madw_get_err_msg
-* NAME
-* osm_madw_get_err_msg
-*
-* DESCRIPTION
-* Returns the message with which to post this mad wrapper if
-* an error occurs during processing the mad.
-*
-* SYNOPSIS
-*/
-static inline cl_disp_msgid_t
-osm_madw_get_err_msg(IN const osm_madw_t * const p_madw)
-{
- return ((cl_disp_msgid_t) p_madw->fail_msg);
-}
-
-/*
-* PARAMETERS
-* p_madw
-* [in] Pointer to an osm_madw_t object.
-*
-* RETURN VALUES
-* Returns the message with which to post this mad wrapper if
-* an error occurs during processing the mad.
-*
-* NOTES
-*
-* SEE ALSO
-*********/
-
-/****f* OpenSM: MAD Wrapper/osm_madw_set_mad
-* NAME
-* osm_madw_set_mad
-*
-* DESCRIPTION
-* Associates a wire MAD with this MAD Wrapper object.
-*
-* SYNOPSIS
-*/
-static inline void
-osm_madw_set_mad(IN osm_madw_t * const p_madw, IN const ib_mad_t * const p_mad)
-{
- p_madw->p_mad = p_mad;
-}
-
-/*
-* PARAMETERS
-* p_madw
-* [in] Pointer to an osm_madw_t object.
-*
-* p_mad
-* [in] Pointer to the wire MAD to attach to this wrapper.
-*
-* RETURN VALUES
-* None.
-*
-* NOTES
-*
-* SEE ALSO
-*********/
-
-/****f* OpenSM: MAD Wrapper/osm_madw_copy_context
-* NAME
-* osm_madw_copy_context
-*
-* DESCRIPTION
-* Copies the controller context from one MAD Wrapper to another.
-*
-* SYNOPSIS
-*/
-static inline void
-osm_madw_copy_context(IN osm_madw_t * const p_dest,
- IN const osm_madw_t * const p_src)
-{
- p_dest->context = p_src->context;
-}
-
-/*
-* PARAMETERS
-* p_dest
-* [in] Pointer to the destination osm_madw_t object.
-*
-* p_src
-* [in] Pointer to the source osm_madw_t object.
-*
-* RETURN VALUES
-* None.
-*
-* NOTES
-*
-* SEE ALSO
-*********/
-
-END_C_DECLS
-#endif /* _OSM_MADW_H_ */
diff --git a/contrib/ofed/management/opensm/include/opensm/osm_mcast_tbl.h b/contrib/ofed/management/opensm/include/opensm/osm_mcast_tbl.h
deleted file mode 100644
index 15b95cf..0000000
--- a/contrib/ofed/management/opensm/include/opensm/osm_mcast_tbl.h
+++ /dev/null
@@ -1,461 +0,0 @@
-/*
- * Copyright (c) 2004, 2005 Voltaire, Inc. All rights reserved.
- * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved.
- * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- */
-
-/*
- * Abstract:
- * Declaration of osm_mcast_tbl_t.
- * This object represents a multicast forwarding table.
- * This object is part of the OpenSM family of objects.
- */
-
-#ifndef _OSM_MCAST_TBL_H_
-#define _OSM_MCAST_TBL_H_
-
-#include <iba/ib_types.h>
-#include <complib/cl_qmap.h>
-#include <opensm/osm_base.h>
-
-#ifdef __cplusplus
-# define BEGIN_C_DECLS extern "C" {
-# define END_C_DECLS }
-#else /* !__cplusplus */
-# define BEGIN_C_DECLS
-# define END_C_DECLS
-#endif /* __cplusplus */
-
-BEGIN_C_DECLS
-/****s* OpenSM: Forwarding Table/osm_mcast_tbl_t
-* NAME
-* osm_mcast_tbl_t
-*
-* DESCRIPTION
-* Multicast Forwarding Table structure.
-*
-* Callers may directly access this object.
-*
-* SYNOPSIS
-*/
-typedef struct osm_mcast_fwdbl {
- uint8_t num_ports;
- uint8_t max_position;
- uint16_t max_block;
- int16_t max_block_in_use;
- uint16_t num_entries;
- uint16_t max_mlid_ho;
- uint16_t(*p_mask_tbl)[][IB_MCAST_POSITION_MAX];
-} osm_mcast_tbl_t;
-/*
-* FIELDS
-* num_ports
-* The number of ports in the port mask. This value
-* is the same as the number of ports on the switch
-*
-* max_position
-* Maximum bit mask position for this table. This value
-* is computed from the number of ports on the switch.
-*
-* max_block
-* Maximum block number supported in the table. This value
-* is approximately the number of MLID entries divided by the
-* number of MLIDs per block
-*
-* num_entries
-* Number of entries in the table (aka number of MLIDs supported).
-*
-* max_mlid_ho
-* Maximum MLID value (host order).
-*
-* pp_mask_tbl
-* Pointer to a two dimensional array of port_masks for this switch.
-* The first dimension is MLID, the second dimension is mask position.
-* This pointer is null for switches that do not support multicast.
-*
-* SEE ALSO
-*********/
-
-/****f* OpenSM: Forwarding Table/osm_mcast_tbl_init
-* NAME
-* osm_mcast_tbl_init
-*
-* DESCRIPTION
-* This function initializes a Multicast Forwarding Table object.
-*
-* SYNOPSIS
-*/
-ib_api_status_t
-osm_mcast_tbl_init(IN osm_mcast_tbl_t * const p_tbl,
- IN uint8_t const num_ports, IN uint16_t const capacity);
-/*
-* PARAMETERS
-* num_ports
-* [in] Number of ports in the switch owning this table.
-*
-* capacity
-* [in] The number of MLID entries (starting at 0xC000) supported
-* by this switch.
-*
-* RETURN VALUE
-* IB_SUCCESS on success.
-*
-* NOTES
-*
-* SEE ALSO
-*********/
-
-/****f* OpenSM: Forwarding Table/osm_mcast_tbl_delete
-* NAME
-* osm_mcast_tbl_delete
-*
-* DESCRIPTION
-* This destroys and deallocates a Multicast Forwarding Table object.
-*
-* SYNOPSIS
-*/
-void osm_mcast_tbl_delete(IN osm_mcast_tbl_t ** const pp_tbl);
-/*
-* PARAMETERS
-* pp_tbl
-* [in] Pointer a Pointer to the Multicast Forwarding Table object.
-*
-* RETURN VALUE
-* On success, returns a pointer to a new Multicast Forwarding Table object
-* of the specified size.
-* NULL otherwise.
-*
-* NOTES
-*
-* SEE ALSO
-*********/
-
-/****f* OpenSM: Forwarding Table/osm_mcast_tbl_destroy
-* NAME
-* osm_mcast_tbl_destroy
-*
-* DESCRIPTION
-* This destroys and deallocates a Multicast Forwarding Table object.
-*
-* SYNOPSIS
-*/
-void osm_mcast_tbl_destroy(IN osm_mcast_tbl_t * const p_tbl);
-/*
-* PARAMETERS
-* p_tbl
-* [in] Pointer to the Multicast Forwarding Table object.
-*
-* RETURN VALUE
-* None
-*
-* NOTES
-*
-* SEE ALSO
-*********/
-
-/****f* OpenSM: Forwarding Table/osm_mcast_tbl_set
-* NAME
-* osm_mcast_tbl_set
-*
-* DESCRIPTION
-* Adds the port to the multicast group.
-*
-* SYNOPSIS
-*/
-void
-osm_mcast_tbl_set(IN osm_mcast_tbl_t * const p_tbl,
- IN const uint16_t mlid_ho, IN const uint8_t port_num);
-/*
-* PARAMETERS
-* p_tbl
-* [in] Pointer to the Multicast Forwarding Table object.
-*
-* mlid_ho
-* [in] MLID value (host order) for which to set the route.
-*
-* port_num
-* [in] Port to add to the multicast group.
-*
-* RETURN VALUE
-* None.
-*
-* NOTES
-*
-* SEE ALSO
-*********/
-
-/****f* OpenSM: Forwarding Table/osm_mcast_tbl_clear_mlid
-* NAME
-* osm_mcast_tbl_clear_mlid
-*
-* DESCRIPTION
-* Removes all multicast paths for the specified MLID.
-*
-* SYNOPSIS
-*/
-void
-osm_mcast_tbl_clear_mlid(IN osm_mcast_tbl_t * const p_tbl,
- IN const uint16_t mlid_ho);
-/*
-* PARAMETERS
-* p_tbl
-* [in] Pointer to the Multicast Forwarding Table object.
-*
-* mlid_ho
-* [in] MLID value (host order) for which to clear.
-*
-* RETURN VALUE
-* None.
-*
-* NOTES
-*
-* SEE ALSO
-*********/
-
-/****f* OpenSM: Forwarding Table/osm_mcast_tbl_is_port
-* NAME
-* osm_mcast_tbl_is_port
-*
-* DESCRIPTION
-* Returns TRUE if the port is in the multicast group.
-*
-* SYNOPSIS
-*/
-boolean_t
-osm_mcast_tbl_is_port(IN const osm_mcast_tbl_t * const p_tbl,
- IN const uint16_t mlid_ho, IN const uint8_t port_num);
-/*
-* PARAMETERS
-* p_tbl
-* [in] Pointer to the Multicast Forwarding Table object.
-*
-* mlid_ho
-* [in] MLID value (host order).
-*
-* port_num
-* [in] Port number on the switch
-*
-* RETURN VALUE
-* Returns the port that routes the specified LID.
-*
-* NOTES
-*
-* SEE ALSO
-*********/
-
-/****f* OpenSM: Forwarding Table/osm_mcast_tbl_is_any_port
-* NAME
-* osm_mcast_tbl_is_any_port
-*
-* DESCRIPTION
-* Returns TRUE if any port is in the multicast group.
-*
-* SYNOPSIS
-*/
-boolean_t
-osm_mcast_tbl_is_any_port(IN const osm_mcast_tbl_t * const p_tbl,
- IN const uint16_t mlid_ho);
-/*
-* PARAMETERS
-* p_tbl
-* [in] Pointer to the Multicast Forwarding Table object.
-*
-* mlid_ho
-* [in] MLID value (host order).
-*
-* RETURN VALUE
-* Returns TRUE if any port is in the multicast group.
-*
-* NOTES
-*
-* SEE ALSO
-*********/
-
-/****f* OpenSM: Forwarding Table/osm_mcast_tbl_set_block
-* NAME
-* osm_mcast_tbl_set_block
-*
-* DESCRIPTION
-* Copies the specified block into the Multicast Forwarding Table.
-*
-* SYNOPSIS
-*/
-ib_api_status_t
-osm_mcast_tbl_set_block(IN osm_mcast_tbl_t * const p_tbl,
- IN const ib_net16_t * const p_block,
- IN const int16_t block_num, IN const uint8_t position);
-/*
-* PARAMETERS
-* p_tbl
-* [in] Pointer to the Multicast Forwarding Table object.
-*
-* p_block
-* [in] Pointer to the Forwarding Table block.
-*
-* block_num
-* [in] Block number of this block.
-*
-* RETURN VALUE
-* None.
-*
-* NOTES
-*
-* SEE ALSO
-*********/
-
-/****f* OpenSM: Forwarding Table/osm_mcast_get_tbl_block
-* NAME
-* osm_mcast_get_tbl_block
-*
-* DESCRIPTION
-* Retrieve a multicast forwarding table block.
-*
-* SYNOPSIS
-*/
-boolean_t
-osm_mcast_tbl_get_block(IN osm_mcast_tbl_t * const p_tbl,
- IN const int16_t block_num,
- IN const uint8_t position,
- OUT ib_net16_t * const p_block);
-/*
-* PARAMETERS
-* p_tbl
-* [in] Pointer to an osm_mcast_tbl_t object.
-*
-* p_block
-* [in] Pointer to the Forwarding Table block.
-*
-* block_num
-* [in] Block number of this block.
-*
-* p_block
-* [out] Pointer to the 32 entry array to store the
-* forwarding table clock specified by block_id.
-*
-* RETURN VALUES
-* Returns true if there are more blocks necessary to
-* configure all the MLIDs reachable from this switch.
-* FALSE otherwise.
-*
-* NOTES
-*
-* SEE ALSO
-*********/
-
-/****f* OpenSM: Forwarding Table/osm_mcast_tbl_get_max_block
-* NAME
-* osm_mcast_tbl_get_max_block
-*
-* DESCRIPTION
-* Returns the maximum block ID in this table.
-*
-* SYNOPSIS
-*/
-static inline uint16_t
-osm_mcast_tbl_get_max_block(IN osm_mcast_tbl_t * const p_tbl)
-{
- return (p_tbl->max_block);
-}
-
-/*
-* PARAMETERS
-* p_tbl
-* [in] Pointer to an osm_mcast_tbl_t object.
-*
-* RETURN VALUES
-* Returns the maximum block ID in this table.
-*
-* NOTES
-*
-* SEE ALSO
-*********/
-
-/****f* OpenSM: Forwarding Table/osm_mcast_tbl_get_max_block_in_use
-* NAME
-* osm_mcast_tbl_get_max_block_in_use
-*
-* DESCRIPTION
-* Returns the maximum block ID in use in this table.
-* A value of -1 indicates no blocks are in use.
-*
-* SYNOPSIS
-*/
-static inline int16_t
-osm_mcast_tbl_get_max_block_in_use(IN osm_mcast_tbl_t * const p_tbl)
-{
- return (p_tbl->max_block_in_use);
-}
-
-/*
-* PARAMETERS
-* p_tbl
-* [in] Pointer to an osm_mcast_tbl_t object.
-*
-* RETURN VALUES
-* Returns the maximum block ID in use in this table.
-* A value of -1 indicates no blocks are in use.
-*
-* NOTES
-*
-* SEE ALSO
-*********/
-
-/****f* OpenSM: Forwarding Table/osm_mcast_tbl_get_max_position
-* NAME
-* osm_mcast_tbl_get_max_position
-*
-* DESCRIPTION
-* Returns the maximum position in this table.
-*
-* SYNOPSIS
-*/
-static inline uint8_t
-osm_mcast_tbl_get_max_position(IN osm_mcast_tbl_t * const p_tbl)
-{
- return (p_tbl->max_position);
-}
-
-/*
-* PARAMETERS
-* p_tbl
-* [in] Pointer to an osm_mcast_tbl_t object.
-*
-* RETURN VALUES
-* Returns the maximum position in this table.
-*
-* NOTES
-*
-* SEE ALSO
-*********/
-
-END_C_DECLS
-#endif /* _OSM_MCAST_TBL_H_ */
diff --git a/contrib/ofed/management/opensm/include/opensm/osm_mcm_info.h b/contrib/ofed/management/opensm/include/opensm/osm_mcm_info.h
deleted file mode 100644
index dec607f..0000000
--- a/contrib/ofed/management/opensm/include/opensm/osm_mcm_info.h
+++ /dev/null
@@ -1,136 +0,0 @@
-/*
- * Copyright (c) 2004-2007 Voltaire, Inc. All rights reserved.
- * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved.
- * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- */
-
-/*
- * Abstract:
- * Declaration of osm_mcm_info_t.
- * This object represents a Multicast Forwarding Information object.
- * This object is part of the OpenSM family of objects.
- */
-
-#ifndef _OSM_MCM_INFO_H_
-#define _OSM_MCM_INFO_H_
-
-#include <string.h>
-#include <iba/ib_types.h>
-#include <complib/cl_qlist.h>
-#include <opensm/osm_base.h>
-
-#ifdef __cplusplus
-# define BEGIN_C_DECLS extern "C" {
-# define END_C_DECLS }
-#else /* !__cplusplus */
-# define BEGIN_C_DECLS
-# define END_C_DECLS
-#endif /* __cplusplus */
-
-BEGIN_C_DECLS
-/****s* OpenSM: Multicast Member Info/osm_mcm_info_t
-* NAME
-* osm_mcm_info_t
-*
-* DESCRIPTION
-* Multicast Membership Info object.
-* This object contains information about a node's membership
-* in a particular multicast group.
-*
-* This object should be treated as opaque and should
-* be manipulated only through the provided functions.
-*
-* SYNOPSIS
-*/
-typedef struct osm_mcm_info {
- cl_list_item_t list_item;
- ib_net16_t mlid;
-} osm_mcm_info_t;
-/*
-* FIELDS
-* list_item
-* Linkage structure for cl_qlist. MUST BE FIRST MEMBER!
-*
-* mlid
-* MLID of this multicast group.
-*
-* SEE ALSO
-*********/
-
-/****f* OpenSM: Multicast Member Info/osm_mcm_info_new
-* NAME
-* osm_mcm_info_new
-*
-* DESCRIPTION
-* Returns an initialized a Multicast Member Info object for use.
-*
-* SYNOPSIS
-*/
-osm_mcm_info_t *osm_mcm_info_new(IN const ib_net16_t mlid);
-/*
-* PARAMETERS
-* mlid
-* [in] MLID value for this multicast group.
-*
-* RETURN VALUES
-* Pointer to an initialized tree node.
-*
-* NOTES
-*
-* SEE ALSO
-*********/
-
-/****f* OpenSM: Multicast Member Info/osm_mcm_info_delete
-* NAME
-* osm_mcm_info_delete
-*
-* DESCRIPTION
-* Destroys and deallocates the specified object.
-*
-* SYNOPSIS
-*/
-void osm_mcm_info_delete(IN osm_mcm_info_t * const p_mcm);
-/*
-* PARAMETERS
-* p_mcm
-* Pointer to the object to destroy.
-*
-* RETURN VALUES
-* None.
-*
-* NOTES
-*
-* SEE ALSO
-*********/
-
-END_C_DECLS
-#endif /* _OSM_MCM_INFO_H_ */
diff --git a/contrib/ofed/management/opensm/include/opensm/osm_mcm_port.h b/contrib/ofed/management/opensm/include/opensm/osm_mcm_port.h
deleted file mode 100644
index c2b18de..0000000
--- a/contrib/ofed/management/opensm/include/opensm/osm_mcm_port.h
+++ /dev/null
@@ -1,158 +0,0 @@
-/*
- * Copyright (c) 2004-2007 Voltaire, Inc. All rights reserved.
- * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved.
- * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- */
-
-/*
- * Abstract:
- * Declaration of osm_mcm_port_t.
- * This object represents the membership of a port in a multicast group.
- * This object is part of the OpenSM family of objects.
- */
-
-#ifndef _OSM_MCM_PORT_H_
-#define _OSM_MCM_PORT_H_
-
-#include <iba/ib_types.h>
-#include <complib/cl_qmap.h>
-#include <opensm/osm_base.h>
-
-#ifdef __cplusplus
-# define BEGIN_C_DECLS extern "C" {
-# define END_C_DECLS }
-#else /* !__cplusplus */
-# define BEGIN_C_DECLS
-# define END_C_DECLS
-#endif /* __cplusplus */
-
-BEGIN_C_DECLS
-/****s* OpenSM: MCM Port Object/osm_mcm_port_t
-* NAME
-* osm_mcm_port_t
-*
-* DESCRIPTION
-* This object represents a particular port as a member of a
-* multicast group.
-*
-* This object should be treated as opaque and should
-* be manipulated only through the provided functions.
-*
-* SYNOPSIS
-*/
-typedef struct osm_mcm_port {
- cl_map_item_t map_item;
- ib_gid_t port_gid;
- uint8_t scope_state;
- boolean_t proxy_join;
-} osm_mcm_port_t;
-/*
-* FIELDS
-* map_item
-* Map Item for qmap linkage. Must be first element!!
-*
-* port_gid
-* GID of the member port.
-*
-* scope_state
-* ???
-*
-* proxy_join
-* If FALSE - Join was performed by the endport identified
-* by PortGID. If TRUE - Join was performed on behalf of
-* the endport identified by PortGID by another port within
-* the same partition.
-*
-* SEE ALSO
-* MCM Port Object
-*********/
-
-/****f* OpenSM: MCM Port Object/osm_mcm_port_new
-* NAME
-* osm_mcm_port_new
-*
-* DESCRIPTION
-* The osm_mcm_port_new function allocates and initializes a
-* MCM Port Object for use.
-*
-* SYNOPSIS
-*/
-osm_mcm_port_t *osm_mcm_port_new(IN const ib_gid_t * const p_port_gid,
- IN const uint8_t scope_state,
- IN const boolean_t proxy_join);
-/*
-* PARAMETERS
-* p_port_gid
-* [in] Pointer to the GID of the port to add to the multicast group.
-*
-* scope_state
-* [in] scope state of the join request
-*
-* proxy_join
-* [in] proxy_join state analyzed from the request
-*
-* RETURN VALUES
-* Pointer to the allocated and initialized MCM Port object.
-*
-* NOTES
-*
-* SEE ALSO
-* MCM Port Object, osm_mcm_port_delete,
-*********/
-
-/****f* OpenSM: MCM Port Object/osm_mcm_port_delete
-* NAME
-* osm_mcm_port_delete
-*
-* DESCRIPTION
-* The osm_mcm_port_delete function destroys and dellallocates an
-* MCM Port Object, releasing all resources.
-*
-* SYNOPSIS
-*/
-void osm_mcm_port_delete(IN osm_mcm_port_t * const p_mcm);
-/*
-* PARAMETERS
-* p_mcm
-* [in] Pointer to a MCM Port Object to delete.
-*
-* RETURN VALUE
-* This function does not return a value.
-*
-* NOTES
-*
-* SEE ALSO
-* MCM Port Object, osm_mcm_port_new
-*********/
-
-END_C_DECLS
-#endif /* _OSM_MCM_PORT_H_ */
diff --git a/contrib/ofed/management/opensm/include/opensm/osm_msgdef.h b/contrib/ofed/management/opensm/include/opensm/osm_msgdef.h
deleted file mode 100644
index dbf3e53..0000000
--- a/contrib/ofed/management/opensm/include/opensm/osm_msgdef.h
+++ /dev/null
@@ -1,167 +0,0 @@
-/*
- * Copyright (c) 2004-2006 Voltaire, Inc. All rights reserved.
- * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved.
- * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- */
-
-/*
- * Abstract:
- * Declaration of Dispatcher message values.
- */
-
-#ifndef _OSM_MSGDEF_H_
-#define _OSM_MSGDEF_H_
-
-#ifdef __cplusplus
-# define BEGIN_C_DECLS extern "C" {
-# define END_C_DECLS }
-#else /* !__cplusplus */
-# define BEGIN_C_DECLS
-# define END_C_DECLS
-#endif /* __cplusplus */
-
-BEGIN_C_DECLS
-/****h* OpenSM/Dispatcher Messages
-* NAME
-* Dispatcher Messages
-*
-* DESCRIPTION
-* These constants define the messages sent between OpenSM controllers
-* attached to the Dispatcher.
-*
-* Each message description contains the following information:
-* Sent by: which controller(s) send this message
-* Received by: which controller receives this message
-* Delivery notice: Indicates if the sender requires confirmation
-* that the message has been delivered. Typically a "yes" here
-* means that some resources associated with sending the
-* message must be freed.
-*
-* AUTHOR
-* Steve King, Intel
-*
-*********/
-/****s* OpenSM: Dispatcher Messages/OSM_MSG_MAD_NODE_INFO
-* NAME
-* OSM_MSG_MAD_NODE_INFO
-*
-* DESCRIPTION
-* Message for received NodeInfo MADs.
-*
-* NOTES
-* Sent by: osm_mad_ctrl_t
-* Received by: osm_ni_rcv_ctrl_t
-* Delivery notice: yes
-*
-*
-***********/
-/****s* OpenSM: Dispatcher Messages/OSM_MSG_MAD_PORT_INFO
-* NAME
-* OSM_MSG_MAD_PORT_INFO
-*
-* DESCRIPTION
-* Message for received PortInfo MADs.
-*
-* NOTES
-* Sent by: osm_mad_ctrl_t
-* Received by: osm_pi_rcv_ctrl_t
-* Delivery notice: yes
-*
-*
-***********/
-/****s* OpenSM: Dispatcher Messages/OSM_MSG_MAD_SWITCH_INFO
-* NAME
-* OSM_MSG_MAD_SWITCH_INFO
-*
-* DESCRIPTION
-* Message for received SwitchInfo MADs.
-*
-* NOTES
-* Sent by: osm_mad_ctrl_t
-* Received by: osm_si_rcv_ctrl_t
-* Delivery notice: yes
-*
-***********/
-/****s* OpenSM: Dispatcher Messages/OSM_MSG_MAD_NODE_DESC
-* NAME
-* OSM_MSG_MAD_NODE_DESC
-*
-* DESCRIPTION
-* Message for received NodeDescription MADs.
-*
-* NOTES
-* Sent by: osm_mad_ctrl_t
-* Received by: osm_nd_rcv_ctrl_t
-* Delivery notice: yes
-*
-* SOURCE
-***********/
-enum {
- OSM_MSG_NONE = 0,
- OSM_MSG_MAD_NODE_INFO,
- OSM_MSG_MAD_PORT_INFO,
- OSM_MSG_MAD_SWITCH_INFO,
- OSM_MSG_MAD_NODE_DESC,
- OSM_MSG_MAD_NODE_RECORD,
- OSM_MSG_MAD_PORTINFO_RECORD,
- OSM_MSG_MAD_SERVICE_RECORD,
- OSM_MSG_MAD_PATH_RECORD,
- OSM_MSG_MAD_MCMEMBER_RECORD,
- OSM_MSG_MAD_LINK_RECORD,
- OSM_MSG_MAD_SMINFO_RECORD,
- OSM_MSG_MAD_CLASS_PORT_INFO,
- OSM_MSG_MAD_INFORM_INFO,
- OSM_MSG_MAD_LFT_RECORD,
- OSM_MSG_MAD_LFT,
- OSM_MSG_MAD_SM_INFO,
- OSM_MSG_MAD_NOTICE,
- OSM_MSG_LIGHT_SWEEP_FAIL,
- OSM_MSG_MAD_MFT,
- OSM_MSG_MAD_PKEY_TBL_RECORD,
- OSM_MSG_MAD_VL_ARB_RECORD,
- OSM_MSG_MAD_SLVL_TBL_RECORD,
- OSM_MSG_MAD_PKEY,
- OSM_MSG_MAD_VL_ARB,
- OSM_MSG_MAD_SLVL,
- OSM_MSG_MAD_GUIDINFO_RECORD,
- OSM_MSG_MAD_INFORM_INFO_RECORD,
- OSM_MSG_MAD_SWITCH_INFO_RECORD,
- OSM_MSG_MAD_MFT_RECORD,
-#if defined (VENDOR_RMPP_SUPPORT) && defined (DUAL_SIDED_RMPP)
- OSM_MSG_MAD_MULTIPATH_RECORD,
-#endif
- OSM_MSG_MAD_PORT_COUNTERS,
- OSM_MSG_MAX
-};
-
-END_C_DECLS
-#endif /* _OSM_MSGDEF_H_ */
diff --git a/contrib/ofed/management/opensm/include/opensm/osm_mtree.h b/contrib/ofed/management/opensm/include/opensm/osm_mtree.h
deleted file mode 100644
index ef696da..0000000
--- a/contrib/ofed/management/opensm/include/opensm/osm_mtree.h
+++ /dev/null
@@ -1,274 +0,0 @@
-/*
- * Copyright (c) 2004-2006 Voltaire, Inc. All rights reserved.
- * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved.
- * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- */
-
-/*
- * Abstract:
- * Declaration of osm_mtree_t.
- * This object represents multicast spanning tree.
- * This object is part of the OpenSM family of objects.
- */
-
-#ifndef _OSM_MTREE_H_
-#define _OSM_MTREE_H_
-
-#include <iba/ib_types.h>
-#include <complib/cl_qmap.h>
-#include <opensm/osm_base.h>
-#include <opensm/osm_switch.h>
-
-#ifdef __cplusplus
-# define BEGIN_C_DECLS extern "C" {
-# define END_C_DECLS }
-#else /* !__cplusplus */
-# define BEGIN_C_DECLS
-# define END_C_DECLS
-#endif /* __cplusplus */
-
-BEGIN_C_DECLS
-#define OSM_MTREE_LEAF ((void*)-1)
-/****h* OpenSM/Multicast Tree
-* NAME
-* Multicast Tree
-*
-* DESCRIPTION
-* The Multicast Tree object encapsulates the information needed by the
-* OpenSM to manage multicast fabric routes. It is a tree structure
-* in which each node in the tree represents a switch, and may have a
-* varying number of children.
-*
-* Multicast trees do not contain loops.
-*
-* The Multicast Tree is not thread safe, thus callers must provide
-* serialization.
-*
-* This object should be treated as opaque and should be
-* manipulated only through the provided functions.
-*
-* AUTHOR
-* Steve King, Intel
-*
-*********/
-/****s* OpenSM: Multicast Tree/osm_mtree_node_t
-* NAME
-* osm_mtree_node_t
-*
-* DESCRIPTION
-* The MTree Node object encapsulates the information needed by the
-* OpenSM for a particular switch in the multicast tree.
-*
-* The MTree Node object is not thread safe, thus callers must provide
-* serialization.
-*
-* This object should be treated as opaque and should be
-* manipulated only through the provided functions.
-*
-* SYNOPSIS
-*/
-typedef struct osm_mtree_node {
- cl_map_item_t map_item;
- osm_switch_t *p_sw;
- uint8_t max_children;
- struct osm_mtree_node *p_up;
- struct osm_mtree_node *child_array[1];
-} osm_mtree_node_t;
-/*
-* FIELDS
-* map_item
-* Linkage for quick map. MUST BE FIRST ELEMENT!!!
-*
-* p_sw
-* Pointer to the switch represented by this tree node.
-*
-* max_children
-* Maximum number of child nodes of this node. Equal to the
-* the number of ports on the switch if the switch supports
-* multicast. Equal to 1 (default route) if the switch does
-* not support multicast.
-*
-* p_up
-* Pointer to the parent of this node. If this pointer is
-* NULL, the node is at the root of the tree.
-*
-* child_array
-* Array (indexed by port number) of pointers to the
-* child osm_mtree_node_t objects of this tree node, if any.
-*
-* SEE ALSO
-*********/
-
-/****f* OpenSM: Multicast Tree/osm_mtree_node_new
-* NAME
-* osm_mtree_node_new
-*
-* DESCRIPTION
-* Returns an initialized a Multicast Tree object for use.
-*
-* SYNOPSIS
-*/
-osm_mtree_node_t *osm_mtree_node_new(IN const osm_switch_t * const p_sw);
-/*
-* PARAMETERS
-* p_sw
-* [in] Pointer to the switch represented by this node.
-*
-* RETURN VALUES
-* Pointer to an initialized tree node.
-*
-* NOTES
-*
-* SEE ALSO
-*********/
-
-/****f* OpenSM: Multicast Tree/osm_mtree_destroy
-* NAME
-* osm_mtree_destroy
-*
-* DESCRIPTION
-* Destroys a Multicast Tree object given by the p_mtn
-*
-* SYNOPSIS
-*/
-void osm_mtree_destroy(IN osm_mtree_node_t * p_mtn);
-/*
-* PARAMETERS
-* p_mtn
-* [in] Pointer to an osm_mtree_node_t object to destroy.
-*
-* RETURN VALUES
-* None.
-*
-* NOTES
-*
-* SEE ALSO
-*********/
-
-/****f* OpenSM: Multicast Tree/osm_mtree_node_get_max_children
-* NAME
-* osm_mtree_node_get_max_children
-*
-* DESCRIPTION
-* Returns the number maximum number of children of this node.
-* The return value is 1 greater than the highest valid port
-* number on the switch.
-*
-*
-* SYNOPSIS
-*/
-static inline uint8_t
-osm_mtree_node_get_max_children(IN const osm_mtree_node_t * const p_mtn)
-{
- return (p_mtn->max_children);
-}
-/*
-* PARAMETERS
-* p_mtn
-* [in] Pointer to the multicast tree node.
-*
-* RETURN VALUES
-* See description.
-*
-* NOTES
-*
-* SEE ALSO
-*********/
-
-/****f* OpenSM: Multicast Tree/osm_mtree_node_get_child
-* NAME
-* osm_mtree_node_get_child
-*
-* DESCRIPTION
-* Returns the specified child node of this node.
-*
-* SYNOPSIS
-*/
-static inline osm_mtree_node_t *osm_mtree_node_get_child(IN const
- osm_mtree_node_t *
- const p_mtn,
- IN const uint8_t child)
-{
- CL_ASSERT(child < p_mtn->max_children);
- return (p_mtn->child_array[child]);
-}
-/*
-* PARAMETERS
-* p_mtn
-* [in] Pointer to the multicast tree node.
-*
-* child
-* [in] Index of the child to retrieve.
-*
-* RETURN VALUES
-* Returns the specified child node of this node.
-*
-*
-* NOTES
-*
-* SEE ALSO
-*********/
-
-/****f* OpenSM: Multicast Tree/osm_mtree_node_get_switch_ptr
-* NAME
-* osm_mtree_node_get_switch_ptr
-*
-* DESCRIPTION
-* Returns a pointer to the switch object represented by this tree node.
-*
-* SYNOPSIS
-*/
-static inline osm_switch_t *osm_mtree_node_get_switch_ptr(IN const
- osm_mtree_node_t *
- const p_mtn)
-{
- return (p_mtn->p_sw);
-}
-/*
-* PARAMETERS
-* p_mtn
-* [in] Pointer to the multicast tree node.
-*
-* child
-* [in] Index of the child to retrieve.
-*
-* RETURN VALUES
-* Returns a pointer to the switch object represented by this tree node.
-*
-*
-* NOTES
-*
-* SEE ALSO
-*********/
-
-END_C_DECLS
-#endif /* _OSM_MTREE_H_ */
diff --git a/contrib/ofed/management/opensm/include/opensm/osm_multicast.h b/contrib/ofed/management/opensm/include/opensm/osm_multicast.h
deleted file mode 100644
index bd219d1..0000000
--- a/contrib/ofed/management/opensm/include/opensm/osm_multicast.h
+++ /dev/null
@@ -1,503 +0,0 @@
-/*
- * Copyright (c) 2004-2008 Voltaire, Inc. All rights reserved.
- * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved.
- * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- */
-
-/*
- * Abstract:
- * Declaration of osm_mgrp_t.
- * This object represents an IBA Multicast Group.
- * This object is part of the OpenSM family of objects.
- */
-
-#ifndef _OSM_MULTICAST_H_
-#define _OSM_MULTICAST_H_
-
-#include <iba/ib_types.h>
-#include <complib/cl_qmap.h>
-#include <complib/cl_qlist.h>
-#include <complib/cl_spinlock.h>
-#include <opensm/osm_base.h>
-#include <opensm/osm_mtree.h>
-#include <opensm/osm_mcm_port.h>
-#include <opensm/osm_subnet.h>
-#include <opensm/osm_log.h>
-
-#ifdef __cplusplus
-# define BEGIN_C_DECLS extern "C" {
-# define END_C_DECLS }
-#else /* !__cplusplus */
-# define BEGIN_C_DECLS
-# define END_C_DECLS
-#endif /* __cplusplus */
-
-BEGIN_C_DECLS
-/****h* OpenSM/Multicast Group
-* NAME
-* Multicast Group
-*
-* DESCRIPTION
-* The Multicast Group encapsulates the information needed by the
-* OpenSM to manage Multicast Groups. The OpenSM allocates one
-* Multicast Group object per Multicast Group in the IBA subnet.
-*
-* The Multicast Group is not thread safe, thus callers must provide
-* serialization.
-*
-* This object should be treated as opaque and should be
-* manipulated only through the provided functions.
-*
-* AUTHOR
-* Steve King, Intel
-*
-*********/
-/****s* OpenSM: Multicast Group/osm_mcast_mgr_ctxt_t
-* NAME
-* osm_mcast_mgr_ctxt_t
-*
-* DESCRIPTION
-* Struct for passing context arguments to the multicast manager.
-*
-* The osm_mcast_mgr_ctxt_t object should be treated as opaque and should
-* be manipulated only through the provided functions.
-*
-* SYNOPSIS
-*/
-typedef struct osm_mcast_mgr_ctxt {
- cl_list_item_t list_item;
- ib_net16_t mlid;
- osm_mcast_req_type_t req_type;
- ib_net64_t port_guid;
-} osm_mcast_mgr_ctxt_t;
-/*
-* FIELDS
-*
-* mlid
-* The network ordered LID of this Multicast Group
-* (must be >= 0xC000).
-*
-* req_type
-* The type of the request that caused this call
-* (multicast create/join/leave).
-*
-* port_guid
-* The port guid of the port that is being added/removed from
-* the multicast group due to this call.
-*
-* SEE ALSO
-*********/
-
-/****s* OpenSM: Multicast Group/osm_mgrp_t
-* NAME
-* osm_mgrp_t
-*
-* DESCRIPTION
-* Multicast Group structure.
-*
-* The osm_mgrp_t object should be treated as opaque and should
-* be manipulated only through the provided functions.
-*
-* SYNOPSIS
-*/
-typedef struct osm_mgrp {
- cl_map_item_t map_item;
- ib_net16_t mlid;
- osm_mtree_node_t *p_root;
- cl_qmap_t mcm_port_tbl;
- ib_member_rec_t mcmember_rec;
- boolean_t well_known;
- boolean_t to_be_deleted;
- uint32_t last_change_id;
- uint32_t last_tree_id;
- unsigned full_members;
-} osm_mgrp_t;
-/*
-* FIELDS
-* map_item
-* Map Item for qmap linkage. Must be first element!!
-*
-* mlid
-* The network ordered LID of this Multicast Group (must be
-* >= 0xC000).
-*
-* p_root
-* Pointer to the root "tree node" in the single spanning tree
-* for this multicast group. The nodes of the tree represent
-* switches. Member ports are not represented in the tree.
-*
-* mcm_port_tbl
-* Table (sorted by port GUID) of osm_mcm_port_t objects
-* representing the member ports of this multicast group.
-*
-* mcmember_rec
-* Holds the parameters of the Multicast Group.
-*
-* well_known
-* Indicates that this is the wellknown multicast group which
-* is created during the initialization of SM/SA and will be
-* present even if there are no ports for this group
-*
-* to_be_deleted
-* Since groups are deleted only after re-route we need to
-* track the fact the group is about to be deleted so we can
-* track the fact a new join is actually a create request.
-*
-* last_change_id
-* a counter for the number of changes applied to the group.
-* This counter shuold be incremented on any modification
-* to the group: joining or leaving of ports.
-*
-* last_tree_id
-* the last change id used for building the current tree.
-*
-* SEE ALSO
-*********/
-
-/****f* OpenSM: Vendor API/osm_mgrp_func_t
-* NAME
-* osm_mgrp_func_t
-*
-* DESCRIPTION
-* Callback for the osm_mgrp_apply_func function.
-* The callback function must not modify the tree linkage.
-*
-* SYNOPSIS
-*/
-typedef void (*osm_mgrp_func_t) (IN const osm_mgrp_t * const p_mgrp,
- IN const osm_mtree_node_t * const p_mtn,
- IN void *context);
-/*
-* PARAMETERS
-* p_mgrp
-* [in] Pointer to the multicast group object.
-*
-* p_mtn
-* [in] Pointer to the multicast tree node.
-*
-* context
-* [in] User context.
-*
-* RETURN VALUES
-* None.
-*
-* NOTES
-*
-* SEE ALSO
-*********/
-
-/****f* OpenSM: Multicast Group/osm_mgrp_new
-* NAME
-* osm_mgrp_new
-*
-* DESCRIPTION
-* Allocates and initializes a Multicast Group for use.
-*
-* SYNOPSIS
-*/
-osm_mgrp_t *osm_mgrp_new(IN const ib_net16_t mlid);
-/*
-* PARAMETERS
-* mlid
-* [in] Multicast LID for this multicast group.
-*
-* RETURN VALUES
-* IB_SUCCESS if initialization was successful.
-*
-* NOTES
-* Allows calling other Multicast Group methods.
-*
-* SEE ALSO
-* Multicast Group, osm_mgrp_delete
-*********/
-
-/****f* OpenSM: Multicast Group/osm_mgrp_delete
-* NAME
-* osm_mgrp_delete
-*
-* DESCRIPTION
-* Destroys and deallocates a Multicast Group.
-*
-* SYNOPSIS
-*/
-void osm_mgrp_delete(IN osm_mgrp_t * const p_mgrp);
-/*
-* PARAMETERS
-* p_mgrp
-* [in] Pointer to an osm_mgrp_t object.
-*
-* RETURN VALUES
-* None.
-*
-* NOTES
-*
-* SEE ALSO
-* Multicast Group, osm_mgrp_new
-*********/
-
-/****f* OpenSM: Multicast Group/osm_mgrp_is_guid
-* NAME
-* osm_mgrp_is_guid
-*
-* DESCRIPTION
-* Indicates if the specified port GUID is a member of the Multicast Group.
-*
-* SYNOPSIS
-*/
-static inline boolean_t
-osm_mgrp_is_guid(IN const osm_mgrp_t * const p_mgrp,
- IN const ib_net64_t port_guid)
-{
- return (cl_qmap_get(&p_mgrp->mcm_port_tbl, port_guid) !=
- cl_qmap_end(&p_mgrp->mcm_port_tbl));
-}
-
-/*
-* PARAMETERS
-* p_mgrp
-* [in] Pointer to an osm_mgrp_t object.
-*
-* port_guid
-* [in] Port GUID.
-*
-* RETURN VALUES
-* TRUE if the port GUID is a member of the group,
-* FALSE otherwise.
-*
-* NOTES
-*
-* SEE ALSO
-* Multicast Group
-*********/
-
-/****f* OpenSM: Multicast Group/osm_mgrp_is_empty
-* NAME
-* osm_mgrp_is_empty
-*
-* DESCRIPTION
-* Indicates if the multicast group has any member ports.
-*
-* SYNOPSIS
-*/
-static inline boolean_t osm_mgrp_is_empty(IN const osm_mgrp_t * const p_mgrp)
-{
- return (cl_qmap_count(&p_mgrp->mcm_port_tbl) == 0);
-}
-
-/*
-* PARAMETERS
-* p_mgrp
-* [in] Pointer to an osm_mgrp_t object.
-*
-* RETURN VALUES
-* TRUE if there are no ports in the multicast group.
-* FALSE otherwise.
-*
-* NOTES
-*
-* SEE ALSO
-* Multicast Group
-*********/
-
-/****f* OpenSM: Multicast Group/osm_mgrp_get_mlid
-* NAME
-* osm_mgrp_get_mlid
-*
-* DESCRIPTION
-* The osm_mgrp_get_mlid function returns the multicast LID of this group.
-*
-* SYNOPSIS
-*/
-static inline ib_net16_t osm_mgrp_get_mlid(IN const osm_mgrp_t * const p_mgrp)
-{
- return (p_mgrp->mlid);
-}
-
-/*
-* PARAMETERS
-* p_mgrp
-* [in] Pointer to an osm_mgrp_t object.
-*
-* RETURN VALUES
-* MLID of the Multicast Group.
-*
-* NOTES
-*
-* SEE ALSO
-* Multicast Group
-*********/
-
-/****f* OpenSM: Multicast Group/osm_mgrp_add_port
-* NAME
-* osm_mgrp_add_port
-*
-* DESCRIPTION
-* Adds a port to the multicast group.
-*
-* SYNOPSIS
-*/
-osm_mcm_port_t *osm_mgrp_add_port(osm_subn_t *subn, osm_log_t *log,
- IN osm_mgrp_t * const p_mgrp,
- IN const ib_gid_t * const p_port_gid,
- IN const uint8_t join_state,
- IN boolean_t proxy_join);
-/*
-* PARAMETERS
-* p_mgrp
-* [in] Pointer to an osm_mgrp_t object to initialize.
-*
-* p_port_gid
-* [in] Pointer to the GID of the port to add to the multicast group.
-*
-* join_state
-* [in] The join state for this port in the group.
-*
-* RETURN VALUES
-* IB_SUCCESS
-* IB_INSUFFICIENT_MEMORY
-*
-* NOTES
-*
-* SEE ALSO
-*********/
-
-/****f* OpenSM: Multicast Group/osm_mgrp_is_port_present
-* NAME
-* osm_mgrp_is_port_present
-*
-* DESCRIPTION
-* checks a port from the multicast group.
-*
-* SYNOPSIS
-*/
-
-boolean_t
-osm_mgrp_is_port_present(IN const osm_mgrp_t * const p_mgrp,
- IN const ib_net64_t port_guid,
- OUT osm_mcm_port_t ** const pp_mcm_port);
-/*
-* PARAMETERS
-* p_mgrp
-* [in] Pointer to an osm_mgrp_t object.
-*
-* port_guid
-* [in] Port guid of the departing port.
-*
-* pp_mcm_port
-* [out] Pointer to a pointer to osm_mcm_port_t
-* Updated to the member on success or NULLed
-*
-* RETURN VALUES
-* TRUE if port present
-* FALSE if port is not present.
-*
-* NOTES
-*
-* SEE ALSO
-*********/
-
-/****f* OpenSM: Multicast Group/osm_mgrp_remove_port
-* NAME
-* osm_mgrp_remove_port
-*
-* DESCRIPTION
-* Removes a port from the multicast group.
-*
-* SYNOPSIS
-*/
-void
-osm_mgrp_delete_port(IN osm_subn_t * const p_subn,
- IN osm_log_t * const p_log,
- IN osm_mgrp_t * const p_mgrp,
- IN const ib_net64_t port_guid);
-/*
-* PARAMETERS
-*
-* p_subn
-* [in] Pointer to the subnet object
-*
-* p_log
-* [in] The log object pointer
-*
-* p_mgrp
-* [in] Pointer to an osm_mgrp_t object.
-*
-* port_guid
-* [in] Port guid of the departing port.
-*
-* RETURN VALUES
-* None.
-*
-* NOTES
-*
-* SEE ALSO
-*********/
-
-int osm_mgrp_remove_port(osm_subn_t *subn, osm_log_t *log, osm_mgrp_t *mgrp,
- osm_mcm_port_t *mcm, uint8_t join_state);
-
-/****f* OpenSM: Multicast Group/osm_mgrp_apply_func
-* NAME
-* osm_mgrp_apply_func
-*
-* DESCRIPTION
-* Calls the specified function for each element in the tree.
-* Elements are passed to the callback function in no particular order.
-*
-* SYNOPSIS
-*/
-void
-osm_mgrp_apply_func(const osm_mgrp_t * const p_mgrp,
- osm_mgrp_func_t p_func, void *context);
-/*
-* PARAMETERS
-* p_mgrp
-* [in] Pointer to an osm_mgrp_t object.
-*
-* p_func
-* [in] Pointer to the users callback function.
-*
-* context
-* [in] User context passed to the callback function.
-*
-*
-* RETURN VALUES
-* None.
-*
-* NOTES
-*
-* SEE ALSO
-* Multicast Group
-*********/
-
-END_C_DECLS
-#endif /* _OSM_MULTICAST_H_ */
diff --git a/contrib/ofed/management/opensm/include/opensm/osm_node.h b/contrib/ofed/management/opensm/include/opensm/osm_node.h
deleted file mode 100644
index 50b3598..0000000
--- a/contrib/ofed/management/opensm/include/opensm/osm_node.h
+++ /dev/null
@@ -1,679 +0,0 @@
-/*
- * Copyright (c) 2004-2008 Voltaire, Inc. All rights reserved.
- * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved.
- * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- */
-
-/*
- * Abstract:
- * Declaration of osm_node_t.
- * This object represents an IBA node.
- * This object is part of the OpenSM family of objects.
- */
-
-#ifndef _OSM_NODE_H_
-#define _OSM_NODE_H_
-
-#include <complib/cl_qmap.h>
-#include <iba/ib_types.h>
-#include <opensm/osm_base.h>
-#include <opensm/osm_port.h>
-#include <opensm/osm_path.h>
-#include <opensm/osm_madw.h>
-
-#ifdef __cplusplus
-# define BEGIN_C_DECLS extern "C" {
-# define END_C_DECLS }
-#else /* !__cplusplus */
-# define BEGIN_C_DECLS
-# define END_C_DECLS
-#endif /* __cplusplus */
-
-BEGIN_C_DECLS
-
-struct osm_switch;
-
-/****h* OpenSM/Node
-* NAME
-* Node
-*
-* DESCRIPTION
-* The Node object encapsulates the information needed by the
-* OpenSM to manage nodes. The OpenSM allocates one Node object
-* per node in the IBA subnet.
-*
-* The Node object is not thread safe, thus callers must provide
-* serialization.
-*
-* This object should be treated as opaque and should be
-* manipulated only through the provided functions.
-*
-* AUTHOR
-* Steve King, Intel
-*
-*********/
-
-/****s* OpenSM: Node/osm_node_t
-* NAME
-* osm_node_t
-*
-* DESCRIPTION
-* Node structure.
-*
-* This object should be treated as opaque and should
-* be manipulated only through the provided functions.
-*
-* SYNOPSIS
-*/
-typedef struct osm_node {
- cl_map_item_t map_item;
- struct osm_switch *sw;
- ib_node_info_t node_info;
- ib_node_desc_t node_desc;
- uint32_t discovery_count;
- uint32_t physp_tbl_size;
- char *print_desc;
- osm_physp_t physp_table[1];
-} osm_node_t;
-/*
-* FIELDS
-* map_item
-* Linkage structure for cl_qmap. MUST BE FIRST MEMBER!
-*
-* sw
-* For switch node contains pointer to appropriate osm_switch
-* structure. NULL for non-switch nodes. Can be used for fast
-* access to switch object and for simple node type detection
-*
-* node_info
-* The IBA defined NodeInfo data for this node.
-*
-* node_desc
-* The IBA defined NodeDescription data for this node.
-*
-* discovery_count
-* The number of times this node has been discovered
-* during the current fabric sweep. This number is reset
-* to zero at the start of a sweep.
-*
-* phsyp_tbl_size
-* The size of the physp_table array. This value is one greater
-* than the number of ports in the node, since port numbers
-* start with 1 for some bizzare reason.
-*
-* print_desc
-* A printable version of the node description.
-*
-* phsyp_table
-* Array of physical port objects belonging to this node.
-* Index is contiguous by local port number.
-* For switches, port 0 is the always the management port (14.2.5.6).
-* MUST BE LAST MEMBER! - Since it grows !!!!
-*
-* SEE ALSO
-* Node object
-*********/
-
-/****f* OpenSM: Node/osm_node_delete
-* NAME
-* osm_node_delete
-*
-* DESCRIPTION
-* The osm_node_delete function destroys a node, releasing
-* all resources.
-*
-* SYNOPSIS
-*/
-void osm_node_delete(IN OUT osm_node_t ** const p_node);
-/*
-* PARAMETERS
-* p_node
-* [in][out] Pointer to a Pointer a Node object to destroy.
-* On return, the pointer to set to NULL.
-*
-* RETURN VALUE
-* This function does not return a value.
-*
-* NOTES
-* Performs any necessary cleanup of the specified Node object.
-* This function should only be called after a call to osm_node_new.
-*
-* SEE ALSO
-* Node object, osm_node_new
-*********/
-
-/****f* OpenSM: Node/osm_node_new
-* NAME
-* osm_node_new
-*
-* DESCRIPTION
-* The osm_node_new function initializes a Node object for use.
-*
-* SYNOPSIS
-*/
-osm_node_t *osm_node_new(IN const osm_madw_t * const p_madw);
-/*
-* PARAMETERS
-* p_madw
-* [in] Pointer to a osm_madw_t object containing a mad with
-* the node's NodeInfo attribute. The caller may discard the
-* osm_madw_t structure after calling osm_node_new.
-*
-* RETURN VALUES
-* On success, a pointer to the new initialized osm_node_t structure.
-* NULL otherwise.
-*
-* NOTES
-*
-* SEE ALSO
-* Node object
-*********/
-
-/****f* OpenSM: Node/osm_node_get_physp_ptr
-* NAME
-* osm_node_get_physp_ptr
-*
-* DESCRIPTION
-* Returns a pointer to the physical port object at the
-* specified local port number.
-*
-* SYNOPSIS
-*/
-static inline osm_physp_t *osm_node_get_physp_ptr(IN osm_node_t * const p_node,
- IN const uint32_t port_num)
-{
-
- CL_ASSERT(port_num < p_node->physp_tbl_size);
- return osm_physp_is_valid(&p_node->physp_table[port_num]) ?
- &p_node->physp_table[port_num] : NULL;
-}
-
-/*
-* PARAMETERS
-* p_node
-* [in] Pointer to an osm_node_t object.
-*
-* port_num
-* [in] Local port number.
-*
-* RETURN VALUES
-* Returns a pointer to the physical port object at the
-* specified local port number.
-* A return value of zero means the port number was out of range.
-*
-* NOTES
-*
-* SEE ALSO
-* Node object
-*********/
-
-/****f* OpenSM: Node/osm_node_get_type
-* NAME
-* osm_node_get_type
-*
-* DESCRIPTION
-* Returns the type of this node.
-*
-* SYNOPSIS
-*/
-static inline uint8_t osm_node_get_type(IN const osm_node_t * const p_node)
-{
- return (p_node->node_info.node_type);
-}
-
-/*
-* PARAMETERS
-* p_node
-* [in] Pointer to an osm_node_t object.
-*
-* RETURN VALUES
-* Returns the IBA defined type of this node.
-*
-* NOTES
-*
-* SEE ALSO
-* Node object
-*********/
-
-/****f* OpenSM: Node/osm_node_get_num_physp
-* NAME
-* osm_node_get_num_physp
-*
-* DESCRIPTION
-* Returns the type of this node.
-*
-* SYNOPSIS
-*/
-static inline uint8_t osm_node_get_num_physp(IN const osm_node_t * const p_node)
-{
- return ((uint8_t) p_node->physp_tbl_size);
-}
-
-/*
-* PARAMETERS
-* p_node
-* [in] Pointer to an osm_node_t object.
-*
-* RETURN VALUES
-* Returns the IBA defined type of this node.
-*
-* NOTES
-*
-* SEE ALSO
-* Node object
-*********/
-
-/****f* OpenSM: Node/osm_node_get_remote_node
-* NAME
-* osm_node_get_remote_node
-*
-* DESCRIPTION
-* Returns a pointer to the node on the other end of the
-* specified port.
-* Returns NULL if no remote node exists.
-*
-* SYNOPSIS
-*/
-osm_node_t *osm_node_get_remote_node(IN osm_node_t * const p_node,
- IN const uint8_t port_num,
- OUT uint8_t * p_remote_port_num);
-/*
-* PARAMETERS
-* p_node
-* [in] Pointer to an osm_node_t object.
-*
-* port_num
-* [in] Port number in p_node through which to get the remote node.
-*
-* p_remote_port_num
-* [out] Port number in the remote's node through which this
-* link exists. The caller may specify NULL for this pointer
-* if the port number isn't needed.
-*
-* RETURN VALUES
-* Returns a pointer to the node on the other end of the
-* specified port.
-* Returns NULL if no remote node exists.
-*
-* NOTES
-*
-* SEE ALSO
-* Node object
-*********/
-
-/****f* OpenSM: Node/osm_node_get_base_lid
-* NAME
-* osm_node_get_base_lid
-*
-* DESCRIPTION
-* Returns the LID value of the specified port on this node.
-*
-* SYNOPSIS
-*/
-static inline ib_net16_t
-osm_node_get_base_lid(IN const osm_node_t * const p_node,
- IN const uint32_t port_num)
-{
- CL_ASSERT(port_num < p_node->physp_tbl_size);
- return (osm_physp_get_base_lid(&p_node->physp_table[port_num]));
-}
-
-/*
-* PARAMETERS
-* p_node
-* [in] Pointer to an osm_node_t object.
-*
-* port_num
-* [in] Local port number.
-*
-* RETURN VALUES
-* Returns a pointer to the physical port object at the
-* specified local port number.
-* A return value of zero means the port number was out of range.
-*
-* NOTES
-*
-* SEE ALSO
-* Node object
-*********/
-
-/****f* OpenSM: Node/osm_node_get_remote_base_lid
-* NAME
-* osm_node_get_remote_base_lid
-*
-* DESCRIPTION
-* Returns the base LID value of the port on the other side
-* of the wire from the specified port on this node.
-*
-* SYNOPSIS
-*/
-ib_net16_t
-osm_node_get_remote_base_lid(IN osm_node_t * const p_node,
- IN const uint32_t port_num);
-/*
-* PARAMETERS
-* p_node
-* [in] Pointer to an osm_node_t object.
-*
-* port_num
-* [in] Local port number.
-*
-* RETURN VALUES
-* Returns a pointer to the physical port object at the
-* specified local port number.
-* A return value of zero means the port number was out of range.
-*
-* NOTES
-*
-* SEE ALSO
-* Node object
-*********/
-
-/****f* OpenSM: Node/osm_node_get_lmc
-* NAME
-* osm_node_get_lmc
-*
-* DESCRIPTION
-* Returns the LMC value of the specified port on this node.
-*
-* SYNOPSIS
-*/
-static inline uint8_t
-osm_node_get_lmc(IN const osm_node_t * const p_node, IN const uint32_t port_num)
-{
- CL_ASSERT(port_num < p_node->physp_tbl_size);
- return (osm_physp_get_lmc(&p_node->physp_table[port_num]));
-}
-
-/*
-* PARAMETERS
-* p_node
-* [in] Pointer to an osm_node_t object.
-*
-* port_num
-* [in] Local port number.
-*
-* RETURN VALUES
-* Returns the LMC value of the specified port on this node.
-*
-* NOTES
-*
-* SEE ALSO
-* Node object
-*********/
-
-/****f* OpenSM: Node/osm_node_init_physp
-* NAME
-* osm_node_init_physp
-*
-* DESCRIPTION
-* Initializes a physical port for the given node.
-*
-* SYNOPSIS
-*/
-void
-osm_node_init_physp(IN osm_node_t * const p_node,
- IN const osm_madw_t * const p_madw);
-/*
-* PARAMETERS
-* p_node
-* [in] Pointer to an osm_node_t object.
-*
-* p_madw
-* [in] Pointer to a osm_madw_t object containing a mad with
-* the node's NodeInfo attribute as discovered through the
-* Physical Port to add to the node. The caller may discard the
-* osm_madw_t structure after calling osm_node_new.
-*
-* RETURN VALUES
-* None.
-*
-* NOTES
-*
-* SEE ALSO
-* Node object, Physical Port object.
-*********/
-
-/****f* OpenSM: Node/osm_node_get_node_guid
-* NAME
-* osm_node_get_node_guid
-*
-* DESCRIPTION
-* Returns the node GUID of this node.
-*
-* SYNOPSIS
-*/
-static inline ib_net64_t
-osm_node_get_node_guid(IN const osm_node_t * const p_node)
-{
- return (p_node->node_info.node_guid);
-}
-
-/*
-* PARAMETERS
-* p_node
-* [in] Pointer to an osm_node_t object.
-*
-* RETURN VALUES
-* Returns the node GUID of this node.
-*
-* NOTES
-*
-* SEE ALSO
-* Node object
-*********/
-
-/****f* OpenSM: Node/osm_node_link
-* NAME
-* osm_node_link
-*
-* DESCRIPTION
-* Logically connects a node to another node through the specified port.
-*
-* SYNOPSIS
-*/
-void
-osm_node_link(IN osm_node_t * const p_node,
- IN const uint8_t port_num,
- IN osm_node_t * const p_remote_node,
- IN const uint8_t remote_port_num);
-/*
-* PARAMETERS
-* p_node
-* [in] Pointer to an osm_node_t object.
-*
-* port_num
-* [in] Port number in p_node through which to create the link.
-*
-* p_remote_node
-* [in] Pointer to the remote port object.
-*
-* remote_port_num
-* [in] Port number in the remote's node through which to
-* create this link.
-*
-* RETURN VALUES
-* None.
-*
-* NOTES
-*
-* SEE ALSO
-* Node object
-*********/
-
-/****f* OpenSM: Node/osm_node_unlink
-* NAME
-* osm_node_unlink
-*
-* DESCRIPTION
-* Logically disconnects a node from another node through
-* the specified port.
-*
-* SYNOPSIS
-*/
-void
-osm_node_unlink(IN osm_node_t * const p_node,
- IN const uint8_t port_num,
- IN osm_node_t * const p_remote_node,
- IN const uint8_t remote_port_num);
-/*
-* PARAMETERS
-* p_node
-* [in] Pointer to an osm_node_t object.
-*
-* port_num
-* [in] Port number in p_node through which to unlink.
-*
-* p_remote_node
-* [in] Pointer to the remote port object.
-*
-* remote_port_num
-* [in] Port number in the remote's node through which to unlink.
-*
-* RETURN VALUES
-* None.
-*
-* NOTES
-*
-* SEE ALSO
-* Node object
-*********/
-
-/****f* OpenSM: Node/osm_node_link_exists
-* NAME
-* osm_node_link_exists
-*
-* DESCRIPTION
-* Return TRUE if a link exists between the specified nodes on
-* the specified ports.
-* Returns FALSE otherwise.
-*
-* SYNOPSIS
-*/
-boolean_t
-osm_node_link_exists(IN osm_node_t * const p_node,
- IN const uint8_t port_num,
- IN osm_node_t * const p_remote_node,
- IN const uint8_t remote_port_num);
-/*
-* PARAMETERS
-* p_node
-* [in] Pointer to an osm_node_t object.
-*
-* port_num
-* [in] Port number in p_node through which to check the link.
-*
-* p_remote_node
-* [in] Pointer to the remote port object.
-*
-* remote_port_num
-* [in] Port number in the remote's node through which to
-* check this link.
-*
-* RETURN VALUES
-* Return TRUE if a link exists between the specified nodes on
-* the specified ports.
-* Returns FALSE otherwise.
-*
-* NOTES
-*
-* SEE ALSO
-* Node object
-*********/
-
-/****f* OpenSM: Node/osm_node_has_any_link
-* NAME
-* osm_node_has_any_link
-*
-* DESCRIPTION
-* Return TRUE if a any link exists from the specified nodes on
-* the specified port.
-* Returns FALSE otherwise.
-*
-* SYNOPSIS
-*/
-boolean_t
-osm_node_has_any_link(IN osm_node_t * const p_node, IN const uint8_t port_num);
-/*
-* PARAMETERS
-* p_node
-* [in] Pointer to an osm_node_t object.
-*
-* port_num
-* [in] Port number in p_node through which to check the link.
-*
-* RETURN VALUES
-* Return TRUE if a any link exists from the specified nodes on
-* the specified port.
-* Returns FALSE otherwise.
-*
-* NOTES
-*
-* SEE ALSO
-* Node object
-*********/
-
-/****f* OpenSM: Node/osm_node_link_has_valid_ports
-* NAME
-* osm_node_link_has_valid_ports
-*
-* DESCRIPTION
-* Return TRUE if both ports in the link are valid (initialized).
-* Returns FALSE otherwise.
-*
-* SYNOPSIS
-*/
-boolean_t
-osm_node_link_has_valid_ports(IN osm_node_t * const p_node,
- IN const uint8_t port_num,
- IN osm_node_t * const p_remote_node,
- IN const uint8_t remote_port_num);
-/*
-* PARAMETERS
-* p_node
-* [in] Pointer to an osm_node_t object.
-*
-* port_num
-* [in] Port number in p_node through which to check the link.
-*
-* RETURN VALUES
-* Return TRUE if both ports in the link are valid (initialized).
-* Returns FALSE otherwise.
-*
-* NOTES
-*
-* SEE ALSO
-* Node object
-*********/
-
-END_C_DECLS
-#endif /* _OSM_NODE_H_ */
diff --git a/contrib/ofed/management/opensm/include/opensm/osm_opensm.h b/contrib/ofed/management/opensm/include/opensm/osm_opensm.h
deleted file mode 100644
index c121be4..0000000
--- a/contrib/ofed/management/opensm/include/opensm/osm_opensm.h
+++ /dev/null
@@ -1,527 +0,0 @@
-/*
- * Copyright (c) 2004-2008 Voltaire, Inc. All rights reserved.
- * Copyright (c) 2002-2006 Mellanox Technologies LTD. All rights reserved.
- * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- */
-
-/*
- * Abstract:
- * Declaration of osm_opensm_t.
- * This object represents the OpenSM super object.
- * This object is part of the OpenSM family of objects.
- */
-
-#ifndef _OSM_OPENSM_H_
-#define _OSM_OPENSM_H_
-
-#include <stdio.h>
-#include <complib/cl_qlist.h>
-#include <complib/cl_dispatcher.h>
-#include <complib/cl_passivelock.h>
-#include <complib/cl_atomic.h>
-#include <complib/cl_nodenamemap.h>
-#include <opensm/osm_console_io.h>
-#include <opensm/osm_stats.h>
-#include <opensm/osm_log.h>
-#include <opensm/osm_sm.h>
-#include <opensm/osm_sa.h>
-#include <opensm/osm_perfmgr.h>
-#include <opensm/osm_event_plugin.h>
-#include <opensm/osm_db.h>
-#include <opensm/osm_subnet.h>
-#include <opensm/osm_mad_pool.h>
-#include <opensm/osm_vl15intf.h>
-
-#ifdef __cplusplus
-# define BEGIN_C_DECLS extern "C" {
-# define END_C_DECLS }
-#else /* !__cplusplus */
-# define BEGIN_C_DECLS
-# define END_C_DECLS
-#endif /* __cplusplus */
-
-BEGIN_C_DECLS
-/****h* OpenSM/OpenSM
-* NAME
-* OpenSM
-*
-* DESCRIPTION
-* The OpenSM object encapsulates the information needed by the
-* OpenSM to govern itself. The OpenSM is one OpenSM object.
-*
-* The OpenSM object is thread safe.
-*
-* This object should be treated as opaque and should
-* be manipulated only through the provided functions.
-*
-* AUTHOR
-* Steve King, Intel
-*
-*********/
-/****d* OpenSM: OpenSM/osm_routing_engine_type_t
-* NAME
-* osm_routing_engine_type_t
-*
-* DESCRIPTION
-* Enumerates the possible routing engines that
-* could be used to route a subnet.
-*
-* SYNOPSIS
-*/
-typedef enum _osm_routing_engine_type {
- OSM_ROUTING_ENGINE_TYPE_NONE = 0,
- OSM_ROUTING_ENGINE_TYPE_MINHOP,
- OSM_ROUTING_ENGINE_TYPE_UPDN,
- OSM_ROUTING_ENGINE_TYPE_FILE,
- OSM_ROUTING_ENGINE_TYPE_FTREE,
- OSM_ROUTING_ENGINE_TYPE_LASH,
- OSM_ROUTING_ENGINE_TYPE_DOR,
- OSM_ROUTING_ENGINE_TYPE_UNKNOWN
-} osm_routing_engine_type_t;
-/***********/
-
-/****s* OpenSM: OpenSM/osm_routing_engine
-* NAME
-* struct osm_routing_engine
-*
-* DESCRIPTION
-* OpenSM routing engine module definition.
-* NOTES
-* routing engine structure - multicast callbacks may be
-* added later.
-*/
-struct osm_routing_engine {
- const char *name;
- void *context;
- int (*build_lid_matrices) (void *context);
- int (*ucast_build_fwd_tables) (void *context);
- void (*ucast_dump_tables) (void *context);
- void (*delete) (void *context);
- struct osm_routing_engine *next;
-};
-/*
-* FIELDS
-* name
-* The routing engine name (will be used in logs).
-*
-* context
-* The routing engine context. Will be passed as parameter
-* to the callback functions.
-*
-* build_lid_matrices
-* The callback for lid matrices generation.
-*
-* ucast_build_fwd_tables
-* The callback for unicast forwarding table generation.
-*
-* ucast_dump_tables
-* The callback for dumping unicast routing tables.
-*
-* delete
-* The delete method, may be used for routing engine
-* internals cleanup.
-*
-* next
-* Pointer to next routing engine in the list.
-*/
-
-/****s* OpenSM: OpenSM/osm_opensm_t
-* NAME
-* osm_opensm_t
-*
-* DESCRIPTION
-* OpenSM structure.
-*
-* This object should be treated as opaque and should
-* be manipulated only through the provided functions.
-*
-* SYNOPSIS
-*/
-typedef struct osm_opensm {
- const char *osm_version;
- osm_subn_t subn;
- osm_sm_t sm;
- osm_sa_t sa;
-#ifdef ENABLE_OSM_PERF_MGR
- osm_perfmgr_t perfmgr;
-#endif /* ENABLE_OSM_PERF_MGR */
- cl_qlist_t plugin_list;
- osm_db_t db;
- osm_mad_pool_t mad_pool;
- osm_vendor_t *p_vendor;
- osm_vl15_t vl15;
- osm_log_t log;
- cl_dispatcher_t disp;
- cl_plock_t lock;
- struct osm_routing_engine *routing_engine_list;
- osm_routing_engine_type_t routing_engine_used;
- osm_stats_t stats;
- osm_console_t console;
- nn_map_t *node_name_map;
-} osm_opensm_t;
-/*
-* FIELDS
-* osm_version
-* OpenSM version (as generated in osm_version.h)
-*
-* subn
-* Subnet object for this subnet.
-*
-* sm
-* The Subnet Manager (SM) object for this subnet.
-*
-* sa
-* The Subnet Administration (SA) object for this subnet.
-*
-* db
-* Persistant storage of some data required between sessions.
-*
-* mad_pool
-* Pool of Management Datagram (MAD) objects.
-*
-* p_vendor
-* Pointer to the Vendor specific adapter for various
-* transport interfaces, such as UMADT, AL, etc. The
-* particular interface is set at compile time.
-*
-* vl15
-* The VL15 interface.
-*
-* log
-* Log facility used by all OpenSM components.
-*
-* disp
-* Central dispatcher containing the OpenSM worker threads.
-*
-* lock
-* Shared lock guarding most OpenSM structures.
-*
-* routing_engine_list
-* List of routing engines that should be tried for use.
-*
-* routing_engine_used
-* Indicates which routing engine was used to route a subnet.
-*
-* stats
-* Open SM statistics block
-*
-* SEE ALSO
-*********/
-
-/****f* OpenSM: OpenSM/osm_opensm_construct
-* NAME
-* osm_opensm_construct
-*
-* DESCRIPTION
-* This function constructs an OpenSM object.
-*
-* SYNOPSIS
-*/
-void osm_opensm_construct(IN osm_opensm_t * const p_osm);
-/*
-* PARAMETERS
-* p_osm
-* [in] Pointer to a OpenSM object to construct.
-*
-* RETURN VALUE
-* This function does not return a value.
-*
-* NOTES
-* Allows calling osm_opensm_init, osm_opensm_destroy
-*
-* Calling osm_opensm_construct is a prerequisite to calling any other
-* method except osm_opensm_init.
-*
-* SEE ALSO
-* SM object, osm_opensm_init, osm_opensm_destroy
-*********/
-
-/****f* OpenSM: OpenSM/osm_opensm_destroy
-* NAME
-* osm_opensm_destroy
-*
-* DESCRIPTION
-* The osm_opensm_destroy function destroys an SM, releasing
-* all resources.
-*
-* SYNOPSIS
-*/
-void osm_opensm_destroy(IN osm_opensm_t * const p_osm);
-/*
-* PARAMETERS
-* p_osm
-* [in] Pointer to a OpenSM object to destroy.
-*
-* RETURN VALUE
-* This function does not return a value.
-*
-* NOTES
-* Performs any necessary cleanup of the specified OpenSM object.
-* Further operations should not be attempted on the destroyed object.
-* This function should only be called after a call to osm_opensm_construct or
-* osm_opensm_init.
-*
-* SEE ALSO
-* SM object, osm_opensm_construct, osm_opensm_init
-*********/
-
-/****f* OpenSM: OpenSM/osm_opensm_init
-* NAME
-* osm_opensm_init
-*
-* DESCRIPTION
-* The osm_opensm_init function initializes a OpenSM object for use.
-*
-* SYNOPSIS
-*/
-ib_api_status_t
-osm_opensm_init(IN osm_opensm_t * const p_osm,
- IN const osm_subn_opt_t * const p_opt);
-/*
-* PARAMETERS
-* p_osm
-* [in] Pointer to an osm_opensm_t object to initialize.
-*
-* p_opt
-* [in] Pointer to the subnet options structure.
-*
-* RETURN VALUES
-* IB_SUCCESS if the OpenSM object was initialized successfully.
-*
-* NOTES
-* Allows calling other OpenSM methods.
-*
-* SEE ALSO
-* SM object, osm_opensm_construct, osm_opensm_destroy
-*********/
-
-/****f* OpenSM: OpenSM/osm_opensm_sweep
-* NAME
-* osm_opensm_sweep
-*
-* DESCRIPTION
-* Initiates a subnet sweep.
-*
-* SYNOPSIS
-*/
-static inline void osm_opensm_sweep(IN osm_opensm_t * const p_osm)
-{
- osm_sm_sweep(&p_osm->sm);
-}
-
-/*
-* PARAMETERS
-* p_osm
-* [in] Pointer to an osm_opensm_t object on which to
-* initiate a sweep.
-*
-* RETURN VALUES
-* None
-*
-* NOTES
-* If the OpenSM object is not bound to a port, this function
-* does nothing.
-*
-* SEE ALSO
-*********/
-
-/****f* OpenSM: OpenSM/osm_opensm_set_log_flags
-* NAME
-* osm_opensm_set_log_flags
-*
-* DESCRIPTION
-* Sets the log level.
-*
-* SYNOPSIS
-*/
-static inline void
-osm_opensm_set_log_flags(IN osm_opensm_t * const p_osm,
- IN const osm_log_level_t log_flags)
-{
- osm_log_set_level(&p_osm->log, log_flags);
-}
-
-/*
-* PARAMETERS
-* p_osm
-* [in] Pointer to an osm_opensm_t object.
-*
-* log_flags
-* [in] Log level flags to set.
-*
-* RETURN VALUES
-* None
-*
-* NOTES
-*
-* SEE ALSO
-*********/
-
-/****f* OpenSM: OpenSM/osm_opensm_bind
-* NAME
-* osm_opensm_bind
-*
-* DESCRIPTION
-* Binds the opensm object to a port guid.
-*
-* SYNOPSIS
-*/
-ib_api_status_t
-osm_opensm_bind(IN osm_opensm_t * const p_osm, IN const ib_net64_t guid);
-/*
-* PARAMETERS
-* p_osm
-* [in] Pointer to an osm_opensm_t object to bind.
-*
-* guid
-* [in] Local port GUID with which to bind.
-*
-* RETURN VALUES
-* None
-*
-* NOTES
-* A given opensm object can only be bound to one port at a time.
-*
-* SEE ALSO
-*********/
-
-/****f* OpenSM: OpenSM/osm_opensm_wait_for_subnet_up
-* NAME
-* osm_opensm_wait_for_subnet_up
-*
-* DESCRIPTION
-* Blocks the calling thread until the subnet is up.
-*
-* SYNOPSIS
-*/
-static inline cl_status_t
-osm_opensm_wait_for_subnet_up(IN osm_opensm_t * const p_osm,
- IN uint32_t const wait_us,
- IN boolean_t const interruptible)
-{
- return (osm_sm_wait_for_subnet_up(&p_osm->sm, wait_us, interruptible));
-}
-
-/*
-* PARAMETERS
-* p_osm
-* [in] Pointer to an osm_opensm_t object.
-*
-* wait_us
-* [in] Number of microseconds to wait.
-*
-* interruptible
-* [in] Indicates whether the wait operation can be interrupted
-* by external signals.
-*
-* RETURN VALUES
-* CL_SUCCESS if the wait operation succeeded in response to the event
-* being set.
-*
-* CL_TIMEOUT if the specified time period elapses.
-*
-* CL_NOT_DONE if the wait was interrupted by an external signal.
-*
-* CL_ERROR if the wait operation failed.
-*
-* NOTES
-*
-* SEE ALSO
-*********/
-
-/****f* OpenSM: OpenSM/osm_routing_engine_type_str
-* NAME
-* osm_routing_engine_type_str
-*
-* DESCRIPTION
-* Returns a string for the specified routing engine type.
-*
-* SYNOPSIS
-*/
-const char *osm_routing_engine_type_str(IN osm_routing_engine_type_t type);
-/*
-* PARAMETERS
-* type
-* [in] routing engine type.
-*
-* RETURN VALUES
-* Pointer to routing engine name.
-*
-* NOTES
-*
-* SEE ALSO
-*********/
-
-/****f* OpenSM: OpenSM/osm_routing_engine_type
-* NAME
-* osm_routing_engine_type
-*
-* DESCRIPTION
-* Returns a routing engine type specified routing engine name string.
-*
-* SYNOPSIS
-*/
-osm_routing_engine_type_t osm_routing_engine_type(IN const char *str);
-/*
-* PARAMETERS
-* str
-* [in] routing engine name string.
-*
-* RETURN VALUES
-* Routing engine type.
-*
-* NOTES
-*
-* SEE ALSO
-*********/
-
-void osm_opensm_report_event(osm_opensm_t *osm, osm_epi_event_id_t event_id,
- void *event_data);
-
-/* dump helpers */
-void osm_dump_mcast_routes(osm_opensm_t * osm);
-void osm_dump_all(osm_opensm_t * osm);
-void osm_dump_qmap_to_file(osm_opensm_t * p_osm, const char *file_name,
- cl_qmap_t * map,
- void (*func) (cl_map_item_t *, FILE *, void *),
- void *cxt);
-
-/****v* OpenSM/osm_exit_flag
-*/
-extern volatile unsigned int osm_exit_flag;
-/*
-* DESCRIPTION
-* Set to one to cause all threads to leave
-*********/
-
-END_C_DECLS
-#endif /* _OSM_OPENSM_H_ */
diff --git a/contrib/ofed/management/opensm/include/opensm/osm_partition.h b/contrib/ofed/management/opensm/include/opensm/osm_partition.h
deleted file mode 100644
index 38acdc9..0000000
--- a/contrib/ofed/management/opensm/include/opensm/osm_partition.h
+++ /dev/null
@@ -1,273 +0,0 @@
-/*
- * Copyright (c) 2004-2006 Voltaire, Inc. All rights reserved.
- * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved.
- * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- */
-
-/*
- * Abstract:
- * Declaration of osm_prtn_t.
- * This object represents an IBA Partition.
- * This object is part of the OpenSM family of objects.
- */
-
-#ifndef _OSM_PARTITION_H_
-#define _OSM_PARTITION_H_
-
-#include <iba/ib_types.h>
-#include <complib/cl_qmap.h>
-#include <complib/cl_map.h>
-#include <opensm/osm_log.h>
-#include <opensm/osm_subnet.h>
-
-#ifdef __cplusplus
-# define BEGIN_C_DECLS extern "C" {
-# define END_C_DECLS }
-#else /* !__cplusplus */
-# define BEGIN_C_DECLS
-# define END_C_DECLS
-#endif /* __cplusplus */
-
-BEGIN_C_DECLS
-/****h* OpenSM/Partition
-* NAME
-* Partition
-*
-* DESCRIPTION
-* The Partition object encapsulates the information needed by the
-* OpenSM to manage Partitions. The OpenSM allocates one Partition
-* object per Partition in the IBA subnet.
-*
-* The Partition is not thread safe, thus callers must provide
-* serialization.
-*
-* This object should be treated as opaque and should be
-* manipulated only through the provided functions.
-*
-* AUTHOR
-* Steve King, Intel
-*
-*********/
-/****s* OpenSM: Partition/osm_prtn_t
-* NAME
-* osm_prtn_t
-*
-* DESCRIPTION
-* Partition structure.
-*
-* The osm_prtn_t object should be treated as opaque and should
-* be manipulated only through the provided functions.
-*
-* SYNOPSIS
-*/
-typedef struct osm_prtn {
- cl_map_item_t map_item;
- ib_net16_t pkey;
- ib_net16_t mlid;
- uint8_t sl;
- cl_map_t full_guid_tbl;
- cl_map_t part_guid_tbl;
- char name[32];
-} osm_prtn_t;
-/*
-* FIELDS
-* map_item
-* Linkage structure for cl_qmap. MUST BE FIRST MEMBER!
-*
-* pkey
-* The IBA defined P_KEY of this Partition.
-*
-* mlid
-* The network ordered LID of the well known Multicast Group
-* that was created for this partition.
-*
-* sl
-* The Service Level (SL) associated with this Partiton.
-*
-* full_guid_tbl
-* Container of pointers to all Port objects in the Partition
-* with full membership, indexed by port GUID.
-*
-* part_guid_tbl
-* Container of pointers to all Port objects in the Partition
-* with limited membership, indexed by port GUID.
-*
-* name
-* Name of the Partition as specified in partition
-* configuration.
-*
-* SEE ALSO
-* Partition
-*********/
-
-/****f* OpenSM: Partition/osm_prtn_delete
-* NAME
-* osm_prtn_delete
-*
-* DESCRIPTION
-* This function destroys and deallocates a Partition object.
-*
-* SYNOPSIS
-*/
-void osm_prtn_delete(IN OUT osm_prtn_t ** const pp_prtn);
-/*
-* PARAMETERS
-* pp_prtn
-* [in][out] Pointer to a pointer to a Partition object to
-* delete. On return, this pointer is NULL.
-*
-* RETURN VALUE
-* This function does not return a value.
-*
-* NOTES
-* Performs any necessary cleanup of the specified Partition object.
-*
-* SEE ALSO
-* Partition, osm_prtn_new
-*********/
-
-/****f* OpenSM: Partition/osm_prtn_new
-* NAME
-* osm_prtn_new
-*
-* DESCRIPTION
-* This function allocates and initializes a Partition object.
-*
-* SYNOPSIS
-*/
-osm_prtn_t *osm_prtn_new(IN const char *name, IN const uint16_t pkey);
-/*
-* PARAMETERS
-* name
-* [in] Partition name string
-*
-* pkey
-* [in] Partition P_Key value
-*
-* RETURN VALUE
-* Pointer to the initialize Partition object.
-*
-* NOTES
-* Allows calling other partition methods.
-*
-* SEE ALSO
-* Partition
-*********/
-
-/****f* OpenSM: Partition/osm_prtn_is_guid
-* NAME
-* osm_prtn_is_guid
-*
-* DESCRIPTION
-* Indicates if a port is a member of the partition.
-*
-* SYNOPSIS
-*/
-static inline boolean_t osm_prtn_is_guid(IN const osm_prtn_t * const p_prtn,
- IN const ib_net64_t guid)
-{
- return (cl_map_get(&p_prtn->full_guid_tbl, guid) != NULL) ||
- (cl_map_get(&p_prtn->part_guid_tbl, guid) != NULL);
-}
-
-/*
-* PARAMETERS
-* p_prtn
-* [in] Pointer to an osm_prtn_t object.
-*
-* guid
-* [in] Port GUID.
-*
-* RETURN VALUES
-* TRUE if the specified port GUID is a member of the partition,
-* FALSE otherwise.
-*
-* NOTES
-*
-* SEE ALSO
-*********/
-
-/****f* OpenSM: Partition/osm_prtn_make_partitions
-* NAME
-* osm_prtn_make_partitions
-*
-* DESCRIPTION
-* Makes all partitions in subnet.
-*
-* SYNOPSIS
-*/
-ib_api_status_t osm_prtn_make_partitions(IN osm_log_t * const p_log,
- IN osm_subn_t * const p_subn);
-/*
-* PARAMETERS
-* p_log
-* [in] Pointer to a log object.
-*
-* p_subn
-* [in] Pointer to subnet object.
-*
-* RETURN VALUES
-* IB_SUCCESS value on success.
-*
-* NOTES
-*
-* SEE ALSO
-*********/
-
-/****f* OpenSM: Partition/osm_prtn_find_by_name
-* NAME
-* osm_prtn_find_by_name
-*
-* DESCRIPTION
-* Fides partition by name.
-*
-* SYNOPSIS
-*/
-osm_prtn_t *osm_prtn_find_by_name(IN osm_subn_t * p_subn, IN const char *name);
-/*
-* PARAMETERS
-* p_subn
-* [in] Pointer to a subnet object.
-*
-* name
-* [in] Required partition name.
-*
-* RETURN VALUES
-* Pointer to the partition object on success.
-*
-* NOTES
-*
-* SEE ALSO
-*********/
-
-END_C_DECLS
-#endif /* _OSM_PARTITION_H_ */
diff --git a/contrib/ofed/management/opensm/include/opensm/osm_path.h b/contrib/ofed/management/opensm/include/opensm/osm_path.h
deleted file mode 100644
index 8d65d2c..0000000
--- a/contrib/ofed/management/opensm/include/opensm/osm_path.h
+++ /dev/null
@@ -1,250 +0,0 @@
-/*
- * Copyright (c) 2004-2006 Voltaire, Inc. All rights reserved.
- * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved.
- * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- */
-
-#ifndef _OSM_PATH_H_
-#define _OSM_PATH_H_
-
-#include <string.h>
-#include <opensm/osm_base.h>
-#include <vendor/osm_vendor_api.h>
-
-#ifdef __cplusplus
-# define BEGIN_C_DECLS extern "C" {
-# define END_C_DECLS }
-#else /* !__cplusplus */
-# define BEGIN_C_DECLS
-# define END_C_DECLS
-#endif /* __cplusplus */
-
-BEGIN_C_DECLS
-/*
- * Abstract:
- * Declaration of path related objects.
- * These objects are part of the OpenSM family of objects.
- */
-/****h* OpenSM/DR Path
-* NAME
-* DR Path
-*
-* DESCRIPTION
-* The DR Path structure encapsulates a directed route through the subnet.
-*
-* This structure allows direct access to member variables.
-*
-* AUTHOR
-* Steve King, Intel
-*
-*********/
-/****s* OpenSM: DR Path/osm_dr_path_t
-* NAME
-* osm_dr_path_t
-*
-* DESCRIPTION
-* Directed Route structure.
-*
-* This structure allows direct access to member variables.
-*
-* SYNOPSIS
-*/
-typedef struct osm_dr_path {
- osm_bind_handle_t h_bind;
- uint8_t hop_count;
- uint8_t path[IB_SUBNET_PATH_HOPS_MAX];
-} osm_dr_path_t;
-/*
-* FIELDS
-* h_bind
-* Bind handle for port to which this path applies.
-*
-* hop_count
-* The number of hops in this path.
-*
-* path
-* The array of port numbers that comprise this path.
-*
-* SEE ALSO
-* DR Path structure
-*********/
-/****f* OpenSM: DR Path/osm_dr_path_construct
-* NAME
-* osm_dr_path_construct
-*
-* DESCRIPTION
-* This function constructs a directed route path object.
-*
-* SYNOPSIS
-*/
-static inline void osm_dr_path_construct(IN osm_dr_path_t * const p_path)
-{
- /* The first location in the path array is reserved. */
- memset(p_path, 0, sizeof(*p_path));
- p_path->h_bind = OSM_BIND_INVALID_HANDLE;
-}
-
-/*
-* PARAMETERS
-* p_path
-* [in] Pointer to a directed route path object to initialize.
-*
-* h_bind
-* [in] Bind handle for the port on which this path applies.
-*
-* hop_count
-* [in] Hop count needed to reach this node.
-*
-* path
-* [in] Directed route path to reach this node.
-*
-* RETURN VALUE
-* None.
-*
-* NOTES
-*
-* SEE ALSO
-*********/
-
-/****f* OpenSM: DR Path/osm_dr_path_init
-* NAME
-* osm_dr_path_init
-*
-* DESCRIPTION
-* This function initializes a directed route path object.
-*
-* SYNOPSIS
-*/
-static inline void
-osm_dr_path_init(IN osm_dr_path_t * const p_path,
- IN const osm_bind_handle_t h_bind,
- IN const uint8_t hop_count,
- IN const uint8_t path[IB_SUBNET_PATH_HOPS_MAX])
-{
- /* The first location in the path array is reserved. */
- CL_ASSERT(path[0] == 0);
- CL_ASSERT(hop_count < IB_SUBNET_PATH_HOPS_MAX);
- p_path->h_bind = h_bind;
- p_path->hop_count = hop_count;
- memcpy(p_path->path, path, IB_SUBNET_PATH_HOPS_MAX);
-}
-
-/*
-* PARAMETERS
-* p_path
-* [in] Pointer to a directed route path object to initialize.
-*
-* h_bind
-* [in] Bind handle for the port on which this path applies.
-*
-* hop_count
-* [in] Hop count needed to reach this node.
-*
-* path
-* [in] Directed route path to reach this node.
-*
-* RETURN VALUE
-* None.
-*
-* NOTES
-*
-* SEE ALSO
-*********/
-/****f* OpenSM: DR Path/osm_dr_path_extend
-* NAME
-* osm_dr_path_extend
-*
-* DESCRIPTION
-* Adds a new hop to a path.
-*
-* SYNOPSIS
-*/
-static inline void
-osm_dr_path_extend(IN osm_dr_path_t * const p_path, IN const uint8_t port_num)
-{
- p_path->hop_count++;
- CL_ASSERT(p_path->hop_count < IB_SUBNET_PATH_HOPS_MAX);
- /*
- Location 0 in the path array is reserved per IB spec.
- */
- p_path->path[p_path->hop_count] = port_num;
-}
-
-/*
-* PARAMETERS
-* p_path
-* [in] Pointer to a directed route path object to initialize.
-*
-* port_num
-* [in] Additional port to add to the DR path.
-*
-* RETURN VALUE
-* None.
-*
-* NOTES
-*
-* SEE ALSO
-*********/
-
-/****f* OpenSM: DR Path/osm_dr_path_get_bind_handle
-* NAME
-* osm_dr_path_get_bind_handle
-*
-* DESCRIPTION
-* Gets the bind handle from a path.
-*
-* SYNOPSIS
-*/
-static inline osm_bind_handle_t
-osm_dr_path_get_bind_handle(IN const osm_dr_path_t * const p_path)
-{
- return (p_path->h_bind);
-}
-
-/*
-* PARAMETERS
-* p_path
-* [in] Pointer to a directed route path object to initialize.
-*
-* port_num
-* [in] Additional port to add to the DR path.
-*
-* RETURN VALUE
-* None.
-*
-* NOTES
-*
-* SEE ALSO
-*********/
-
-END_C_DECLS
-#endif /* _OSM_PATH_H_ */
diff --git a/contrib/ofed/management/opensm/include/opensm/osm_perfmgr.h b/contrib/ofed/management/opensm/include/opensm/osm_perfmgr.h
deleted file mode 100644
index d48d2ee..0000000
--- a/contrib/ofed/management/opensm/include/opensm/osm_perfmgr.h
+++ /dev/null
@@ -1,250 +0,0 @@
-/*
- * Copyright (c) 2007 The Regents of the University of California.
- * Copyright (c) 2007-2008 Voltaire, Inc. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- */
-
-#ifndef _OSM_PERFMGR_H_
-#define _OSM_PERFMGR_H_
-
-#if HAVE_CONFIG_H
-# include <config.h>
-#endif /* HAVE_CONFIG_H */
-
-#ifdef ENABLE_OSM_PERF_MGR
-
-#include <iba/ib_types.h>
-#include <complib/cl_passivelock.h>
-#include <complib/cl_event.h>
-#include <complib/cl_timer.h>
-#include <opensm/osm_subnet.h>
-#include <opensm/osm_log.h>
-#include <opensm/osm_perfmgr_db.h>
-#include <opensm/osm_sm.h>
-#include <opensm/osm_base.h>
-#include <opensm/osm_event_plugin.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif /* __cplusplus */
-
-/****h* OpenSM/PerfMgr
-* NAME
-* PerfMgr
-*
-* DESCRIPTION
-* Performance manager thread which takes care of polling the fabric for
-* Port counters values.
-*
-* The PerfMgr object is thread safe.
-*
-* AUTHOR
-* Ira Weiny, LLNL
-*
-*********/
-
-#define OSM_PERFMGR_DEFAULT_SWEEP_TIME_S 180
-#define OSM_PERFMGR_DEFAULT_DUMP_FILE "opensm_port_counters.log"
-#define OSM_PERFMGR_DEFAULT_MAX_OUTSTANDING_QUERIES 500
-
-/****s* OpenSM: PerfMgr/osm_perfmgr_state_t */
-typedef enum {
- PERFMGR_STATE_DISABLE,
- PERFMGR_STATE_ENABLED,
- PERFMGR_STATE_NO_DB
-} osm_perfmgr_state_t;
-
-/****s* OpenSM: PerfMgr/osm_perfmgr_sweep_state_t */
-typedef enum {
- PERFMGR_SWEEP_SLEEP,
- PERFMGR_SWEEP_ACTIVE,
- PERFMGR_SWEEP_SUSPENDED
-} osm_perfmgr_sweep_state_t;
-
-/* Redirection information */
-typedef struct redir {
- ib_net16_t redir_lid;
- ib_net32_t redir_qp;
-} redir_t;
-
-/* Node to store information about which nodes we are monitoring */
-typedef struct _monitored_node {
- cl_map_item_t map_item;
- struct _monitored_node *next;
- uint64_t guid;
- char *name;
- uint32_t redir_tbl_size;
- redir_t redir_port[1]; /* redirection on a per port basis */
-} __monitored_node_t;
-
-struct osm_opensm;
-/****s* OpenSM: PerfMgr/osm_perfmgr_t
-* This object should be treated as opaque and should
-* be manipulated only through the provided functions.
-*/
-typedef struct osm_perfmgr {
- cl_event_t sig_sweep;
- cl_timer_t sweep_timer;
- struct osm_opensm *osm;
- osm_subn_t *subn;
- osm_sm_t *sm;
- cl_plock_t *lock;
- osm_log_t *log;
- osm_mad_pool_t *mad_pool;
- atomic32_t trans_id;
- osm_vendor_t *vendor;
- osm_bind_handle_t bind_handle;
- cl_disp_reg_handle_t pc_disp_h;
- osm_perfmgr_state_t state;
- osm_perfmgr_sweep_state_t sweep_state;
- uint16_t sweep_time_s;
- perfmgr_db_t *db;
- atomic32_t outstanding_queries; /* this along with sig_query */
- cl_event_t sig_query; /* will throttle our querys */
- uint32_t max_outstanding_queries;
- cl_qmap_t monitored_map; /* map the nodes we are tracking */
- __monitored_node_t *remove_list;
-} osm_perfmgr_t;
-/*
-* FIELDS
-* subn
-* Subnet object for this subnet.
-*
-* log
-* Pointer to the log object.
-*
-* mad_pool
-* Pointer to the MAD pool.
-*
-* mad_ctrl
-* Mad Controller
-*********/
-
-/****f* OpenSM: Creation Functions */
-void osm_perfmgr_shutdown(osm_perfmgr_t * const p_perfmgr);
-void osm_perfmgr_destroy(osm_perfmgr_t * const p_perfmgr);
-
-/****f* OpenSM: Inline accessor functions */
-inline static void osm_perfmgr_set_state(osm_perfmgr_t * p_perfmgr,
- osm_perfmgr_state_t state)
-{
- p_perfmgr->state = state;
- if (state == PERFMGR_STATE_ENABLED)
- osm_sm_signal(p_perfmgr->sm, OSM_SIGNAL_PERFMGR_SWEEP);
-}
-
-inline static osm_perfmgr_state_t osm_perfmgr_get_state(osm_perfmgr_t
- * p_perfmgr)
-{
- return (p_perfmgr->state);
-}
-
-inline static char *osm_perfmgr_get_state_str(osm_perfmgr_t * p_perfmgr)
-{
- switch (p_perfmgr->state) {
- case PERFMGR_STATE_DISABLE:
- return ("Disabled");
- break;
- case PERFMGR_STATE_ENABLED:
- return ("Enabled");
- break;
- case PERFMGR_STATE_NO_DB:
- return ("No Database");
- break;
- }
- return ("UNKNOWN");
-}
-
-inline static char *osm_perfmgr_get_sweep_state_str(osm_perfmgr_t * perfmgr)
-{
- switch (perfmgr->sweep_state) {
- case PERFMGR_SWEEP_SLEEP:
- return ("Sleeping");
- break;
- case PERFMGR_SWEEP_ACTIVE:
- return ("Active");
- break;
- case PERFMGR_SWEEP_SUSPENDED:
- return ("Suspended");
- break;
- }
- return ("UNKNOWN");
-}
-
-inline static void osm_perfmgr_set_sweep_time_s(osm_perfmgr_t * p_perfmgr,
- uint16_t time_s)
-{
- p_perfmgr->sweep_time_s = time_s;
- osm_sm_signal(p_perfmgr->sm, OSM_SIGNAL_PERFMGR_SWEEP);
-}
-
-inline static uint16_t osm_perfmgr_get_sweep_time_s(osm_perfmgr_t * p_perfmgr)
-{
- return (p_perfmgr->sweep_time_s);
-}
-
-void osm_perfmgr_clear_counters(osm_perfmgr_t * p_perfmgr);
-void osm_perfmgr_dump_counters(osm_perfmgr_t * p_perfmgr,
- perfmgr_db_dump_t dump_type);
-void osm_perfmgr_print_counters(osm_perfmgr_t *pm, char *nodename,
- FILE *fp);
-
-ib_api_status_t osm_perfmgr_bind(osm_perfmgr_t * const p_perfmgr,
- const ib_net64_t port_guid);
-
-void osm_perfmgr_process(osm_perfmgr_t * pm);
-
-/****f* OpenSM: PerfMgr/osm_perfmgr_init */
-ib_api_status_t osm_perfmgr_init(osm_perfmgr_t * const perfmgr,
- struct osm_opensm *osm,
- const osm_subn_opt_t * const p_opt);
-/*
-* PARAMETERS
-* perfmgr
-* [in] Pointer to an osm_perfmgr_t object to initialize.
-*
-* osm
-* [in] Pointer to the OpenSM object.
-*
-* p_opt
-* [in] Starting options
-*
-* RETURN VALUES
-* IB_SUCCESS if the PerfMgr object was initialized successfully.
-*********/
-
-#ifdef __cplusplus
-}
-#endif /* __cplusplus */
-
-#endif /* ENABLE_OSM_PERF_MGR */
-
-#endif /* _OSM_PERFMGR_H_ */
diff --git a/contrib/ofed/management/opensm/include/opensm/osm_perfmgr_db.h b/contrib/ofed/management/opensm/include/opensm/osm_perfmgr_db.h
deleted file mode 100644
index c28d5bb..0000000
--- a/contrib/ofed/management/opensm/include/opensm/osm_perfmgr_db.h
+++ /dev/null
@@ -1,209 +0,0 @@
-/*
- * Copyright (c) 2008 Voltaire, Inc. All rights reserved.
- * Copyright (c) 2007 The Regents of the University of California.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- */
-
-#ifndef _PERFMGR_EVENT_DB_H_
-#define _PERFMGR_EVENT_DB_H_
-
-#ifdef ENABLE_OSM_PERF_MGR
-
-#include <stdio.h>
-#include <time.h>
-#include <iba/ib_types.h>
-#include <complib/cl_qmap.h>
-#include <complib/cl_passivelock.h>
-
-#ifdef __cplusplus
-# define BEGIN_C_DECLS extern "C" {
-# define END_C_DECLS }
-#else /* !__cplusplus */
-# define BEGIN_C_DECLS
-# define END_C_DECLS
-#endif /* __cplusplus */
-
-BEGIN_C_DECLS
-
-struct osm_perfmgr;
-/****h* OpenSM/PerfMgr Event Database
-* DESCRIPTION
-* Database interface to record subnet events
-*
-* Implementations of this object _MUST_ be thread safe.
-*
-* AUTHOR
-* Ira Weiny, LLNL
-*
-*********/
-typedef enum {
- PERFMGR_EVENT_DB_SUCCESS = 0,
- PERFMGR_EVENT_DB_FAIL,
- PERFMGR_EVENT_DB_NOMEM,
- PERFMGR_EVENT_DB_GUIDNOTFOUND,
- PERFMGR_EVENT_DB_PORTNOTFOUND,
- PERFMGR_EVENT_DB_NOT_IMPL
-} perfmgr_db_err_t;
-
-/** =========================================================================
- * Port error reading
- */
-typedef struct {
- uint64_t symbol_err_cnt;
- uint64_t link_err_recover;
- uint64_t link_downed;
- uint64_t rcv_err;
- uint64_t rcv_rem_phys_err;
- uint64_t rcv_switch_relay_err;
- uint64_t xmit_discards;
- uint64_t xmit_constraint_err;
- uint64_t rcv_constraint_err;
- uint64_t link_integrity;
- uint64_t buffer_overrun;
- uint64_t vl15_dropped;
- time_t time;
-} perfmgr_db_err_reading_t;
-
-/** =========================================================================
- * Port data count reading
- */
-typedef struct {
- uint64_t xmit_data; /* can be used for std or extended */
- uint64_t rcv_data; /* can be used for std or extended */
- uint64_t xmit_pkts; /* can be used for std or extended */
- uint64_t rcv_pkts; /* can be used for std or extended */
- uint64_t unicast_xmit_pkts;
- uint64_t unicast_rcv_pkts;
- uint64_t multicast_xmit_pkts;
- uint64_t multicast_rcv_pkts;
- time_t time;
-} perfmgr_db_data_cnt_reading_t;
-
-/** =========================================================================
- * Port select errors
- */
-typedef struct {
- uint64_t xmit_wait;
- time_t time;
-} perfmgr_db_ps_reading_t;
-
-/** =========================================================================
- * Dump output options
- */
-typedef enum {
- PERFMGR_EVENT_DB_DUMP_HR = 0, /* Human readable */
- PERFMGR_EVENT_DB_DUMP_MR /* Machine readable */
-} perfmgr_db_dump_t;
-
-/** =========================================================================
- * Port counter object.
- * Store all the port counters for a single port.
- */
-typedef struct _db_port {
- perfmgr_db_err_reading_t err_total;
- perfmgr_db_err_reading_t err_previous;
- perfmgr_db_data_cnt_reading_t dc_total;
- perfmgr_db_data_cnt_reading_t dc_previous;
- time_t last_reset;
-} _db_port_t;
-
-/** =========================================================================
- * group port counters for ports into the nodes
- */
-#define NODE_NAME_SIZE (IB_NODE_DESCRIPTION_SIZE << 1)
-typedef struct _db_node {
- cl_map_item_t map_item; /* must be first */
- uint64_t node_guid;
- _db_port_t *ports;
- uint8_t num_ports;
- char node_name[NODE_NAME_SIZE];
-} _db_node_t;
-
-/** =========================================================================
- * all nodes in the system.
- */
-typedef struct _db {
- cl_qmap_t pc_data; /* stores type (_db_node_t *) */
- cl_plock_t lock;
- struct osm_perfmgr *perfmgr;
-} perfmgr_db_t;
-
-/**
- * functions
- */
-perfmgr_db_t *perfmgr_db_construct(struct osm_perfmgr *perfmgr);
-void perfmgr_db_destroy(perfmgr_db_t * db);
-
-perfmgr_db_err_t perfmgr_db_create_entry(perfmgr_db_t * db, uint64_t guid,
- uint8_t num_ports, char *node_name);
-
-perfmgr_db_err_t perfmgr_db_add_err_reading(perfmgr_db_t * db, uint64_t guid,
- uint8_t port,
- perfmgr_db_err_reading_t * reading);
-perfmgr_db_err_t perfmgr_db_get_prev_err(perfmgr_db_t * db, uint64_t guid,
- uint8_t port,
- perfmgr_db_err_reading_t * reading);
-perfmgr_db_err_t perfmgr_db_clear_prev_err(perfmgr_db_t * db, uint64_t guid,
- uint8_t port);
-
-perfmgr_db_err_t perfmgr_db_add_dc_reading(perfmgr_db_t * db, uint64_t guid,
- uint8_t port,
- perfmgr_db_data_cnt_reading_t *
- reading);
-perfmgr_db_err_t perfmgr_db_get_prev_dc(perfmgr_db_t * db, uint64_t guid,
- uint8_t port,
- perfmgr_db_data_cnt_reading_t *
- reading);
-perfmgr_db_err_t perfmgr_db_clear_prev_dc(perfmgr_db_t * db, uint64_t guid,
- uint8_t port);
-
-void perfmgr_db_clear_counters(perfmgr_db_t * db);
-perfmgr_db_err_t perfmgr_db_dump(perfmgr_db_t * db, char *file,
- perfmgr_db_dump_t dump_type);
-void perfmgr_db_print_by_name(perfmgr_db_t * db, char *nodename, FILE *fp);
-void perfmgr_db_print_by_guid(perfmgr_db_t * db, uint64_t guid, FILE *fp);
-
-/** =========================================================================
- * helper functions to fill in the various db objects from wire objects
- */
-
-void perfmgr_db_fill_err_read(ib_port_counters_t * wire_read,
- perfmgr_db_err_reading_t * reading);
-void perfmgr_db_fill_data_cnt_read_pc(ib_port_counters_t * wire_read,
- perfmgr_db_data_cnt_reading_t * reading);
-void perfmgr_db_fill_data_cnt_read_epc(ib_port_counters_ext_t * wire_read,
- perfmgr_db_data_cnt_reading_t * reading);
-
-END_C_DECLS
-
-#endif /* ENABLE_OSM_PERF_MGR */
-
-#endif /* _PERFMGR_PM_DB_H_ */
diff --git a/contrib/ofed/management/opensm/include/opensm/osm_pkey.h b/contrib/ofed/management/opensm/include/opensm/osm_pkey.h
deleted file mode 100644
index 94b7207..0000000
--- a/contrib/ofed/management/opensm/include/opensm/osm_pkey.h
+++ /dev/null
@@ -1,636 +0,0 @@
-/*
- * Copyright (c) 2004-2008 Voltaire, Inc. All rights reserved.
- * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved.
- * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- */
-
-#ifndef _OSM_PKEY_H_
-#define _OSM_PKEY_H_
-
-#include <iba/ib_types.h>
-#include <complib/cl_dispatcher.h>
-#include <complib/cl_map.h>
-#include <opensm/osm_base.h>
-#include <opensm/osm_log.h>
-#include <opensm/osm_msgdef.h>
-
-#ifdef __cplusplus
-# define BEGIN_C_DECLS extern "C" {
-# define END_C_DECLS }
-#else /* !__cplusplus */
-# define BEGIN_C_DECLS
-# define END_C_DECLS
-#endif /* __cplusplus */
-
-BEGIN_C_DECLS
-/*
- Forward references.
-*/
-struct osm_physp;
-struct osm_port;
-struct osm_subn;
-struct osm_node;
-struct osm_physp;
-
-/*
- * Abstract:
- * Declaration of pkey manipulation functions.
- */
-
-/****s* OpenSM: osm_pkey_tbl_t
-* NAME
-* osm_pkey_tbl_t
-*
-* DESCRIPTION
-* This object represents a pkey table. The need for a special object
-* is required to optimize search performance of a PKey in the IB standard
-* non sorted table.
-*
-* The osm_pkey_tbl_t object should be treated as opaque and should
-* be manipulated only through the provided functions.
-*
-* SYNOPSIS
-*/
-typedef struct osm_pkeybl {
- cl_ptr_vector_t blocks;
- cl_ptr_vector_t new_blocks;
- cl_map_t keys;
- cl_qlist_t pending;
- uint16_t used_blocks;
- uint16_t max_blocks;
-} osm_pkey_tbl_t;
-/*
-* FIELDS
-* blocks
-* The IBA defined blocks of pkey values, updated from the subnet
-*
-* new_blocks
-* The blocks of pkey values, will be used for updates by SM
-*
-* keys
-* A set holding all keys
-*
-* pending
-* A list of osm_pending_pkey structs that is temporarily set by
-* the pkey mgr and used during pkey mgr algorithm only
-*
-* used_blocks
-* Tracks the number of blocks having non-zero pkeys
-*
-* max_blocks
-* The maximal number of blocks this partition table might hold
-* this value is based on node_info (for port 0 or CA) or
-* switch_info updated on receiving the node_info or switch_info
-* GetResp
-*
-* NOTES
-* 'blocks' vector should be used to store pkey values obtained from
-* the port and SM pkey manager should not change it directly, for this
-* purpose 'new_blocks' should be used.
-*
-* The only pkey values stored in 'blocks' vector will be mapped with
-* 'keys' map
-*
-*********/
-
-/****s* OpenSM: osm_pending_pkey_t
-* NAME
-* osm_pending_pkey_t
-*
-* DESCRIPTION
-* This objects stores temporary information on pkeys, their target block,
-* and index during the pkey manager operation
-*
-* SYNOPSIS
-*/
-typedef struct osm_pending_pkey {
- cl_list_item_t list_item;
- uint16_t pkey;
- uint16_t block;
- uint8_t index;
- boolean_t is_new;
-} osm_pending_pkey_t;
-/*
-* FIELDS
-* pkey
-* The actual P_Key
-*
-* block
-* The block index based on the previous table extracted from the
-* device
-*
-* index
-* The index of the pkey within the block
-*
-* is_new
-* TRUE for new P_Keys such that the block and index are invalid
-* in that case
-*
-*********/
-
-/****f* OpenSM: osm_pkey_tbl_construct
-* NAME
-* osm_pkey_tbl_construct
-*
-* DESCRIPTION
-* Constructs the PKey table object
-*
-* SYNOPSIS
-*/
-void osm_pkey_tbl_construct(IN osm_pkey_tbl_t * p_pkey_tbl);
-/*
-* p_pkey_tbl
-* [in] Pointer to osm_pkey_tbl_t object.
-*
-* NOTES
-*
-*********/
-
-/****f* OpenSM: osm_pkey_tbl_init
-* NAME
-* osm_pkey_tbl_init
-*
-* DESCRIPTION
-* Inits the PKey table object
-*
-* SYNOPSIS
-*/
-ib_api_status_t osm_pkey_tbl_init(IN osm_pkey_tbl_t * p_pkey_tbl);
-/*
-* p_pkey_tbl
-* [in] Pointer to osm_pkey_tbl_t object.
-*
-* NOTES
-*
-*********/
-
-/****f* OpenSM: osm_pkey_tbl_destroy
-* NAME
-* osm_pkey_tbl_destroy
-*
-* DESCRIPTION
-* Destroys the PKey table object
-*
-* SYNOPSIS
-*/
-void osm_pkey_tbl_destroy(IN osm_pkey_tbl_t * p_pkey_tbl);
-/*
-* p_pkey_tbl
-* [in] Pointer to osm_pkey_tbl_t object.
-*
-* NOTES
-*
-*********/
-
-/****f* OpenSM: osm_pkey_get_num_blocks
-* NAME
-* osm_pkey_get_num_blocks
-*
-* DESCRIPTION
-* Obtain the number of blocks in IB PKey table
-*
-* SYNOPSIS
-*/
-static inline uint16_t
-osm_pkey_tbl_get_num_blocks(IN const osm_pkey_tbl_t * p_pkey_tbl)
-{
- return ((uint16_t) (cl_ptr_vector_get_size(&p_pkey_tbl->blocks)));
-}
-
-/*
-* p_pkey_tbl
-* [in] Pointer to osm_pkey_tbl_t object.
-*
-* RETURN VALUES
-* The IB pkey table of that pkey table element
-*
-* NOTES
-*
-*********/
-
-/****f* OpenSM: osm_pkey_tbl_block_get
-* NAME
-* osm_pkey_tbl_block_get
-*
-* DESCRIPTION
-* Obtain the pointer to the IB PKey table block stored in the object
-*
-* SYNOPSIS
-*/
-static inline ib_pkey_table_t *osm_pkey_tbl_block_get(const osm_pkey_tbl_t *
- p_pkey_tbl,
- uint16_t block)
-{
- return ((block < cl_ptr_vector_get_size(&p_pkey_tbl->blocks)) ?
- cl_ptr_vector_get(&p_pkey_tbl->blocks, block) : NULL);
-};
-
-/*
-* p_pkey_tbl
-* [in] Pointer to osm_pkey_tbl_t object.
-*
-* block
-* [in] The lock number to get
-*
-* RETURN VALUES
-* The IB pkey table of that pkey table element
-*
-* NOTES
-*
-*********/
-
-/****f* OpenSM: osm_pkey_tbl_new_block_get
-* NAME
-* osm_pkey_tbl_new_block_get
-*
-* DESCRIPTION
-* The same as above but for new block
-*
-* SYNOPSIS
-*/
-static inline ib_pkey_table_t *osm_pkey_tbl_new_block_get(const osm_pkey_tbl_t *
- p_pkey_tbl,
- uint16_t block)
-{
- return (block < cl_ptr_vector_get_size(&p_pkey_tbl->new_blocks)) ?
- cl_ptr_vector_get(&p_pkey_tbl->new_blocks, block) : NULL;
-};
-
-/****f* OpenSM: osm_pkey_tbl_set_new_entry
-* NAME
-* osm_pkey_tbl_set_new_entry
-*
-* DESCRIPTION
-* Stores the given pkey in the "new" blocks array and update
-* the "map" to show that on the "old" blocks
-*
-* SYNOPSIS
-*/
-ib_api_status_t
-osm_pkey_tbl_set_new_entry(IN osm_pkey_tbl_t * p_pkey_tbl,
- IN uint16_t block_idx,
- IN uint8_t pkey_idx, IN uint16_t pkey);
-/*
-* p_pkey_tbl
-* [in] Pointer to the PKey table
-*
-* block_idx
-* [in] The block index to use
-*
-* pkey_idx
-* [in] The index within the block
-*
-* pkey
-* [in] PKey to store
-*
-* RETURN VALUES
-* IB_SUCCESS if OK
-* IB_ERROR if failed
-*
-*********/
-
-/****f* OpenSM: osm_pkey_find_next_free_entry
-* NAME
-* osm_pkey_find_next_free_entry
-*
-* DESCRIPTION
-* Find the next free entry in the PKey table starting at the given
-* index and block number. The user should increment pkey_idx before
-* next call
-* Inspect the "new" blocks array for empty space.
-*
-* SYNOPSIS
-*/
-boolean_t
-osm_pkey_find_next_free_entry(IN osm_pkey_tbl_t * p_pkey_tbl,
- OUT uint16_t * p_block_idx,
- OUT uint8_t * p_pkey_idx);
-/*
-* p_pkey_tbl
-* [in] Pointer to the PKey table
-*
-* p_block_idx
-* [out] The block index to use
-*
-* p_pkey_idx
-* [out] The index within the block to use
-*
-* RETURN VALUES
-* TRUE if found
-* FALSE if did not find
-*
-*********/
-
-/****f* OpenSM: osm_pkey_tbl_init_new_blocks
-* NAME
-* osm_pkey_tbl_init_new_blocks
-*
-* DESCRIPTION
-* Initializes new_blocks vector content (allocate and clear)
-*
-* SYNOPSIS
-*/
-void osm_pkey_tbl_init_new_blocks(const osm_pkey_tbl_t * p_pkey_tbl);
-/*
-* p_pkey_tbl
-* [in] Pointer to osm_pkey_tbl_t object.
-*
-* NOTES
-*
-*********/
-
-/****f* OpenSM: osm_pkey_tbl_get_block_and_idx
-* NAME
-* osm_pkey_tbl_get_block_and_idx
-*
-* DESCRIPTION
-* Set the block index and pkey index the given
-* pkey is found in. Return IB_NOT_FOUND if could
-* not find it, IB_SUCCESS if OK
-*
-* SYNOPSIS
-*/
-ib_api_status_t
-osm_pkey_tbl_get_block_and_idx(IN osm_pkey_tbl_t * p_pkey_tbl,
- IN uint16_t * p_pkey,
- OUT uint16_t * block_idx,
- OUT uint8_t * pkey_index);
-/*
-* p_pkey_tbl
-* [in] Pointer to osm_pkey_tbl_t object.
-*
-* p_pkey
-* [in] Pointer to the P_Key entry searched
-*
-* p_block_idx
-* [out] Pointer to the block index to be updated
-*
-* p_pkey_idx
-* [out] Pointer to the pkey index (in the block) to be updated
-*
-* NOTES
-*
-*********/
-
-/****f* OpenSM: osm_pkey_tbl_set
-* NAME
-* osm_pkey_tbl_set
-*
-* DESCRIPTION
-* Set the PKey table block provided in the PKey object.
-*
-* SYNOPSIS
-*/
-ib_api_status_t
-osm_pkey_tbl_set(IN osm_pkey_tbl_t * p_pkey_tbl,
- IN uint16_t block, IN ib_pkey_table_t * p_tbl);
-/*
-* p_pkey_tbl
-* [in] Pointer to osm_pkey_tbl_t object.
-*
-* block
-* [in] The block number to set
-*
-* p_tbl
-* [in] The IB PKey block to copy to the object
-*
-* RETURN VALUES
-* IB_SUCCESS or IB_ERROR
-*
-* NOTES
-*
-*********/
-
-/****f* OpenSM: osm_physp_share_this_pkey
-* NAME
-* osm_physp_share_this_pkey
-*
-* DESCRIPTION
-* Checks if the given physical ports share the specified pkey.
-*
-* SYNOPSIS
-*/
-boolean_t osm_physp_share_this_pkey(IN const struct osm_physp *const p_physp1,
- IN const struct osm_physp *const p_physp2,
- IN const ib_net16_t pkey);
-/*
-* PARAMETERS
-*
-* p_physp1
-* [in] Pointer to an osm_physp_t object.
-*
-* p_physp2
-* [in] Pointer to an osm_physp_t object.
-*
-* pkey
-* [in] value of P_Key to check.
-*
-* RETURN VALUES
-* Returns TRUE if the two ports are matching.
-* FALSE otherwise.
-*
-* NOTES
-*
-*********/
-
-/****f* OpenSM: osm_physp_find_common_pkey
-* NAME
-* osm_physp_find_common_pkey
-*
-* DESCRIPTION
-* Returns first matching P_Key values for specified physical ports.
-*
-* SYNOPSIS
-*/
-ib_net16_t osm_physp_find_common_pkey(IN const struct osm_physp *const
- p_physp1,
- IN const struct osm_physp *const
- p_physp2);
-/*
-* PARAMETERS
-*
-* p_physp1
-* [in] Pointer to an osm_physp_t object.
-*
-* p_physp2
-* [in] Pointer to an osm_physp_t object.
-*
-* RETURN VALUES
-* Returns value of first shared P_Key or INVALID P_Key (0x0) if not
-* found.
-*
-* NOTES
-*
-*********/
-
-/****f* OpenSM: osm_physp_share_pkey
-* NAME
-* osm_physp_share_pkey
-*
-* DESCRIPTION
-* Checks if the given physical ports share a pkey.
-* The meaning P_Key matching:
-* 10.9.3 :
-* In the following, let M_P_Key(Message P_Key) be the P_Key in the incoming
-* packet and E_P_Key(Endnode P_Key) be the P_Key it is being compared against
-* in the packet's destination endnode.
-*
-* If:
-* * neither M_P_Key nor E_P_Key are the invalid P_Key
-* * and the low-order 15 bits of the M_P_Key match the low order 15
-* bits of the E_P_Key
-* * and the high order bit(membership type) of both the M_P_Key and
-* E_P_Key are not both 0 (i.e., both are not Limited members of
-* the partition)
-*
-* then the P_Keys are said to match.
-*
-* SYNOPSIS
-*/
-boolean_t osm_physp_share_pkey(IN osm_log_t * p_log,
- IN const struct osm_physp *const p_physp_1,
- IN const struct osm_physp *const p_physp_2);
-
-/*
-* PARAMETERS
-* p_log
-* [in] Pointer to a log object.
-*
-* p_physp_1
-* [in] Pointer to an osm_physp_t object.
-*
-* p_physp_2
-* [in] Pointer to an osm_physp_t object.
-*
-* RETURN VALUES
-* Returns TRUE if the 2 physical ports are matching.
-* FALSE otherwise.
-*
-* NOTES
-*
-*********/
-
-/****f* OpenSM: osm_port_share_pkey
-* NAME
-* osm_port_share_pkey
-*
-* DESCRIPTION
-* Checks if the given ports (on their default physical port) share a pkey.
-* The meaning P_Key matching:
-* 10.9.3 :
-* In the following, let M_P_Key(Message P_Key) be the P_Key in the incoming
-* packet and E_P_Key(Endnode P_Key) be the P_Key it is being compared against
-* in the packet's destination endnode.
-*
-* If:
-* * neither M_P_Key nor E_P_Key are the invalid P_Key
-* * and the low-order 15 bits of the M_P_Key match the low order 15
-* bits of the E_P_Key
-* * and the high order bit(membership type) of both the M_P_Key and
-* E_P_Key are not both 0 (i.e., both are not Limited members of
-* the partition)
-*
-* then the P_Keys are said to match.
-*
-* SYNOPSIS
-*/
-boolean_t osm_port_share_pkey(IN osm_log_t * p_log,
- IN const struct osm_port *const p_port_1,
- IN const struct osm_port *const p_port_2);
-
-/*
-* PARAMETERS
-* p_log
-* [in] Pointer to a log object.
-*
-* p_port_1
-* [in] Pointer to an osm_port_t object.
-*
-* p_port_2
-* [in] Pointer to an osm_port_t object.
-*
-* RETURN VALUES
-* Returns TRUE if the 2 ports are matching.
-* FALSE otherwise.
-*
-* NOTES
-*
-*********/
-
-/****f* OpenSM: osm_physp_has_pkey
-* NAME
-* osm_physp_has_pkey
-*
-* DESCRIPTION
-* Checks if the given lids and port_numbers share a pkey.
-* The meaning P_Key matching:
-* 10.9.3 :
-* In the following, let M_P_Key(Message P_Key) be the P_Key in the incoming
-* packet and E_P_Key(Endnode P_Key) be the P_Key it is being compared against
-* in the packet's destination endnode.
-*
-* If:
-* * neither M_P_Key nor E_P_Key are the invalid P_Key
-* * and the low-order 15 bits of the M_P_Key match the low order 15
-* bits of the E_P_Key
-* * and the high order bit(membership type) of both the M_P_Key and
-* E_P_Key are not both 0 (i.e., both are not Limited members of
-* the partition)
-*
-* then the P_Keys are said to match.
-*
-* SYNOPSIS
-*/
-boolean_t osm_physp_has_pkey(IN osm_log_t * p_log,
- IN const ib_net16_t pkey,
- IN const struct osm_physp *const p_physp);
-
-/*
-* PARAMETERS
-* p_log
-* [in] Pointer to a log object.
-*
-* pkey
-* [in] pkey number to look for.
-*
-* p_physp
-* [in] Pointer to osm_physp_t object.
-*
-* RETURN VALUES
-* Returns TRUE if the p_physp has the pkey given. False otherwise.
-*
-* NOTES
-*
-*********/
-
-END_C_DECLS
-#endif /* _OSM_PKEY_H_ */
diff --git a/contrib/ofed/management/opensm/include/opensm/osm_pkey_mgr.h b/contrib/ofed/management/opensm/include/opensm/osm_pkey_mgr.h
deleted file mode 100644
index 91587bd..0000000
--- a/contrib/ofed/management/opensm/include/opensm/osm_pkey_mgr.h
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * Copyright (c) 2006 Voltaire, Inc. All rights reserved.
- * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- */
-
-/*
- * Abstract:
- * Prototype for osm_pkey_mgr_process() function
- * This is part of the OpenSM family of objects.
- */
-
-#ifndef _OSM_PKEY_MGR_H_
-#define _OSM_PKEY_MGR_H_
-
-#include <opensm/osm_base.h>
-#include <opensm/osm_opensm.h>
-
-#ifdef __cplusplus
-# define BEGIN_C_DECLS extern "C" {
-# define END_C_DECLS }
-#else /* !__cplusplus */
-# define BEGIN_C_DECLS
-# define END_C_DECLS
-#endif /* __cplusplus */
-
-BEGIN_C_DECLS
-/****f* OpenSM: P_Key Manager/osm_pkey_mgr_process
-* NAME
-* osm_pkey_mgr_process
-*
-* DESCRIPTION
-* This function enforces the pkey rules on the SM DB.
-*
-* SYNOPSIS
-*/
-osm_signal_t osm_pkey_mgr_process(IN osm_opensm_t * p_osm);
-/*
-* PARAMETERS
-* p_osm
-* [in] Pointer to an osm_opensm_t object.
-*
-* RETURN VALUES
-* None
-*
-* NOTES
-*
-* SEE ALSO
-*********/
-
-END_C_DECLS
-#endif /* _OSM_PKEY_MGR_H_ */
diff --git a/contrib/ofed/management/opensm/include/opensm/osm_port.h b/contrib/ofed/management/opensm/include/opensm/osm_port.h
deleted file mode 100644
index 3dda541..0000000
--- a/contrib/ofed/management/opensm/include/opensm/osm_port.h
+++ /dev/null
@@ -1,1591 +0,0 @@
-/*
- * Copyright (c) 2004-2008 Voltaire, Inc. All rights reserved.
- * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved.
- * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- */
-
-/*
- * Abstract:
- * Declaration of port related objects.
- * These objects comprise an IBA port.
- * These objects are part of the OpenSM family of objects.
- */
-
-#ifndef _OSM_PORT_H_
-#define _OSM_PORT_H_
-
-#include <complib/cl_qmap.h>
-#include <iba/ib_types.h>
-#include <opensm/osm_base.h>
-#include <opensm/osm_subnet.h>
-#include <opensm/osm_madw.h>
-#include <opensm/osm_path.h>
-#include <opensm/osm_pkey.h>
-
-#ifdef __cplusplus
-# define BEGIN_C_DECLS extern "C" {
-# define END_C_DECLS }
-#else /* !__cplusplus */
-# define BEGIN_C_DECLS
-# define END_C_DECLS
-#endif /* __cplusplus */
-
-BEGIN_C_DECLS
-/*
- Forward references.
-*/
-struct osm_port;
-struct osm_node;
-
-/****h* OpenSM/Physical Port
-* NAME
-* Physical Port
-*
-* DESCRIPTION
-* The Physical Port object encapsulates the information needed by the
-* OpenSM to manage physical ports. The OpenSM allocates one Physical Port
-* per physical port in the IBA subnet.
-*
-* In a switch, one multiple Physical Port objects share the same port GUID.
-* In an end-point, Physical Ports do not share GUID values.
-*
-* The Physical Port is not thread safe, thus callers must provide
-* serialization.
-*
-* These objects should be treated as opaque and should be
-* manipulated only through the provided functions.
-*
-* AUTHOR
-* Steve King, Intel
-*
-*********/
-
-/****s* OpenSM: Physical Port/osm_physp_t
-* NAME
-* osm_physp_t
-*
-* DESCRIPTION
-* This object represents a physical port on a switch, router or end-point.
-*
-* The osm_physp_t object should be treated as opaque and should
-* be manipulated only through the provided functions.
-*
-* SYNOPSIS
-*/
-typedef struct osm_physp {
- ib_port_info_t port_info;
- ib_net64_t port_guid;
- uint8_t port_num;
- struct osm_node *p_node;
- struct osm_physp *p_remote_physp;
- boolean_t healthy;
- uint8_t vl_high_limit;
- unsigned need_update;
- unsigned is_prof_ignored;
- osm_dr_path_t dr_path;
- osm_pkey_tbl_t pkeys;
- ib_vl_arb_table_t vl_arb[4];
- cl_ptr_vector_t slvl_by_port;
-} osm_physp_t;
-/*
-* FIELDS
-* port_info
-* The IBA defined PortInfo data for this port.
-*
-* port_guid
-* Port GUID value of this port. For switches,
-* all ports share the same GUID value.
-*
-* port_num
-* The port number of this port. The PortInfo also
-* contains a port_number, but that number is not
-* the port number of this port, but rather the number
-* of the port that received the SMP during discovery.
-* Therefore, we must keep a separate record for this
-* port's port number.
-*
-* p_node
-* Pointer to the parent Node object of this Physical Port.
-*
-* p_remote_physp
-* Pointer to the Physical Port on the other side of the wire.
-* If this pointer is NULL no link exists at this port.
-*
-* healthy
-* Tracks the health of the port. Normally should be TRUE but
-* might change as a result of incoming traps indicating the port
-* healthy is questionable.
-*
-* vl_high_limit
-* PortInfo:VLHighLimit value which installed by QoS manager
-* and should be uploaded to port's PortInfo
-*
-* need_update
-* When set indicates that port was probably reset and port
-* related tables (PKey, SL2VL, VLArb) require refreshing.
-*
-* is_prof_ignored
-* When set indicates that switch port will be ignored by
-* the link load equalization algorithm.
-*
-* dr_path
-* The directed route path to this port.
-*
-* pkeys
-* osm_pkey_tbl_t object holding the port PKeys.
-*
-* vl_arb[]
-* Each Physical Port has 4 sections of VL Arbitration table.
-*
-* slvl_by_port
-* A vector of pointers to the sl2vl tables (ordered by input port).
-* Switches have an entry for every other input port (inc SMA=0).
-* On CAs only one per port.
-*
-* SEE ALSO
-* Port
-*********/
-
-/****f* OpenSM: Physical Port/osm_physp_construct
-* NAME
-* osm_physp_construct
-*
-* DESCRIPTION
-* Constructs a Physical Port.
-*
-* SYNOPSIS
-*/
-void osm_physp_construct(IN osm_physp_t * const p_physp);
-/*
-* PARAMETERS
-* p_physp
-* [in] Pointer to an osm_physp_t object to initialize.
-*
-* RETURN VALUES
-* This function does not return a value.
-*
-* NOTES
-*
-* SEE ALSO
-* Port, Physical Port
-*********/
-
-/****f* OpenSM: Physical Port/osm_physp_init
-* NAME
-* osm_physp_init
-*
-* DESCRIPTION
-* Initializes a Physical Port for use.
-*
-* SYNOPSIS
-*/
-void
-osm_physp_init(IN osm_physp_t * const p_physp,
- IN const ib_net64_t port_guid,
- IN const uint8_t port_num,
- IN const struct osm_node *const p_node,
- IN const osm_bind_handle_t h_bind,
- IN const uint8_t hop_count,
- IN const uint8_t * const p_initial_path);
-/*
-* PARAMETERS
-* p_physp
-* [in] Pointer to an osm_physp_t object to initialize.
-*
-* port_guid
-* [in] GUID value of this port. Switch ports all share
-* the same value.
-* Caller should use 0 if the guid is unknown.
-*
-* port_num
-* [in] The port number of this port.
-*
-* p_node
-* [in] Pointer to the parent Node object of this Physical Port.
-*
-* h_bind
-* [in] Bind handle on which this port is accessed.
-* Caller should use OSM_INVALID_BIND_HANDLE if the bind
-* handle to this port is unknown.
-*
-* hop_count
-* [in] Directed route hop count to reach this port.
-* Caller should use 0 if the hop count is unknown.
-*
-* p_initial_path
-* [in] Pointer to the directed route path to reach this node.
-* Caller should use NULL if the path is unknown.
-*
-* RETURN VALUES
-* This function does not return a value.
-*
-* NOTES
-*
-* SEE ALSO
-* Port, Physical Port
-*********/
-
-/****f* OpenSM: Port/void osm_physp_destroy
-* NAME
-* osm_physp_destroy
-*
-* DESCRIPTION
-* This function destroys a Port object.
-*
-* SYNOPSIS
-*/
-void osm_physp_destroy(IN osm_physp_t * const p_physp);
-/*
-* PARAMETERS
-* p_port
-* [in] Pointer to a PhysPort object to destroy.
-*
-* RETURN VALUE
-* This function does not return a value.
-*
-* NOTES
-* Performs any necessary cleanup of the specified PhysPort object.
-* Further operations should not be attempted on the destroyed object.
-* This function should only be called after a call to osm_physp_construct or
-* osm_physp_init.
-*
-* SEE ALSO
-* Port
-*********/
-
-/****f* OpenSM: Physical Port/osm_physp_is_valid
-* NAME
-* osm_physp_is_valid
-*
-* DESCRIPTION
-* Returns TRUE if the Physical Port has been successfully initialized.
-* FALSE otherwise.
-*
-* SYNOPSIS
-*/
-static inline boolean_t osm_physp_is_valid(IN const osm_physp_t * const p_physp)
-{
- CL_ASSERT(p_physp);
- return (p_physp->port_guid != 0);
-}
-
-/*
-* PARAMETERS
-* p_physp
-* [in] Pointer to an osm_physp_t object.
-*
-* RETURN VALUES
-* Returns TRUE if the Physical Port has been successfully initialized.
-* FALSE otherwise.
-*
-* NOTES
-*
-* SEE ALSO
-* Port, Physical Port
-*********/
-
-/****f* OpenSM: Physical Port/osm_physp_is_healthy
-* NAME
-* osm_physp_is_healthy
-*
-* DESCRIPTION
-* Returns TRUE if the Physical Port has been maked as healthy
-* FALSE otherwise.
-*
-* SYNOPSIS
-*/
-static inline boolean_t
-osm_physp_is_healthy(IN const osm_physp_t * const p_physp)
-{
- CL_ASSERT(p_physp);
- return (p_physp->healthy);
-}
-
-/*
-* PARAMETERS
-* p_physp
-* [in] Pointer to an osm_physp_t object.
-*
-* RETURN VALUES
-* Returns TRUE if the Physical Port has been maked as healthy
-* FALSE otherwise.
-* All physical ports are initialized as "healthy" but may be marked
-* otherwise if a received trap claims otherwise.
-*
-* NOTES
-*
-* SEE ALSO
-* Port, Physical Port
-*********/
-
-/****f* OpenSM: Physical Port/osm_link_is_healthy
-* NAME
-* osm_link_is_healthy
-*
-* DESCRIPTION
-* Returns TRUE if the link given by the physical port is health,
-* and FALSE otherwise. Link is healthy if both its physical ports are
-* healthy
-*
-* SYNOPSIS
-*/
-boolean_t osm_link_is_healthy(IN const osm_physp_t * const p_physp);
-/*
-* PARAMETERS
-* p_physp
-* [in] Pointer to an osm_physp_t object.
-*
-* RETURN VALUES
-* TRUE if both physical ports on the link are healthy, and FALSE otherwise.
-* All physical ports are initialized as "healthy" but may be marked
-* otherwise if a received trap claiming otherwise.
-*
-* NOTES
-*
-* SEE ALSO
-* Port, Physical Port
-*********/
-
-/****f* OpenSM: Physical Port/osm_physp_set_health
-* NAME
-* osm_physp_set_health
-*
-* DESCRIPTION
-* Sets the port health flag. TRUE means the port is healthy and
-* should be used for packet routing. FALSE means it should be avoided.
-*
-* SYNOPSIS
-*/
-static inline void
-osm_physp_set_health(IN osm_physp_t * const p_physp, IN boolean_t is_healthy)
-{
- CL_ASSERT(p_physp);
- p_physp->healthy = is_healthy;
-}
-
-/*
-* PARAMETERS
-* p_physp
-* [in] Pointer to an osm_physp_t object.
-*
-* is_healthy
-* [in] The health value to be assigned to the port.
-* TRUE if the Physical Port should been maked as healthy
-* FALSE otherwise.
-*
-* RETURN VALUES
-* NONE
-*
-* NOTES
-*
-* SEE ALSO
-* Port, Physical Port
-*********/
-
-/****f* OpenSM: Physical Port/osm_physp_set_port_info
-* NAME
-* osm_physp_set_port_info
-*
-* DESCRIPTION
-* Copies the PortInfo attribute into the Physical Port object
-* based on the PortState.
-*
-* SYNOPSIS
-*/
-static inline void
-osm_physp_set_port_info(IN osm_physp_t * const p_physp,
- IN const ib_port_info_t * const p_pi)
-{
- CL_ASSERT(p_pi);
- CL_ASSERT(osm_physp_is_valid(p_physp));
-
- if (ib_port_info_get_port_state(p_pi) == IB_LINK_DOWN) {
- /* If PortState is down, only copy PortState */
- /* and PortPhysicalState per C14-24-2.1 */
- ib_port_info_set_port_state(&p_physp->port_info, IB_LINK_DOWN);
- ib_port_info_set_port_phys_state
- (ib_port_info_get_port_phys_state(p_pi),
- &p_physp->port_info);
- } else {
- p_physp->port_info = *p_pi;
- }
-}
-
-/*
-* PARAMETERS
-* p_physp
-* [in] Pointer to an osm_physp_t object.
-*
-* p_pi
-* [in] Pointer to the IBA defined PortInfo at this port number.
-*
-* RETURN VALUES
-* This function does not return a value.
-*
-* NOTES
-*
-* SEE ALSO
-* Port, Physical Port
-*********/
-
-/****f* OpenSM: Physical Port/osm_physp_set_pkey_tbl
-* NAME
-* osm_physp_set_pkey_tbl
-*
-* DESCRIPTION
-* Copies the P_Key table into the Physical Port object.
-*
-* SYNOPSIS
-*/
-void
-osm_physp_set_pkey_tbl(IN osm_log_t * p_log,
- IN const osm_subn_t * p_subn,
- IN osm_physp_t * const p_physp,
- IN ib_pkey_table_t * p_pkey_tbl, IN uint16_t block_num);
-/*
-* PARAMETERS
-* p_log
-* [in] Pointer to a log object.
-*
-* p_subn
-* [in] Pointer to the subnet data structure.
-*
-* p_physp
-* [in] Pointer to an osm_physp_t object.
-*
-* p_pkey_tbl
-* [in] Pointer to the IBA defined P_Key table for this port
-* number.
-*
-* block_num
-* [in] The part of the P_Key table as defined in the IBA
-* (valid values 0-2047, and is further limited by the
-* partitionCap).
-*
-* RETURN VALUES
-* This function does not return a value.
-*
-* NOTES
-*
-* SEE ALSO
-* Port, Physical Port
-*********/
-
-/****f* OpenSM: Physical Port/osm_physp_get_pkey_tbl
-* NAME
-* osm_physp_get_pkey_tbl
-*
-* DESCRIPTION
-* Returns a pointer to the P_Key table object of the Physical Port object.
-*
-* SYNOPSIS
-*/
-static inline const osm_pkey_tbl_t *osm_physp_get_pkey_tbl(IN const osm_physp_t
- * const p_physp)
-{
- CL_ASSERT(osm_physp_is_valid(p_physp));
- /*
- (14.2.5.7) - the block number valid values are 0-2047, and are
- further limited by the size of the P_Key table specified by the
- PartitionCap on the node.
- */
- return (&p_physp->pkeys);
-};
-
-/*
-* PARAMETERS
-* p_physp
-* [in] Pointer to an osm_physp_t object.
-*
-* RETURN VALUES
-* The pointer to the P_Key table object.
-*
-* NOTES
-*
-* SEE ALSO
-* Port, Physical Port
-*********/
-
-/****f* OpenSM: Physical Port/osm_physp_set_slvl_tbl
-* NAME
-* osm_physp_set_slvl_tbl
-*
-* DESCRIPTION
-* Copies the SLtoVL attribute into the Physical Port object.
-*
-* SYNOPSIS
-*/
-static inline void
-osm_physp_set_slvl_tbl(IN osm_physp_t * const p_physp,
- IN ib_slvl_table_t * p_slvl_tbl, IN uint8_t in_port_num)
-{
- ib_slvl_table_t *p_tbl;
-
- CL_ASSERT(p_slvl_tbl);
- CL_ASSERT(osm_physp_is_valid(p_physp));
- p_tbl = cl_ptr_vector_get(&p_physp->slvl_by_port, in_port_num);
- *p_tbl = *p_slvl_tbl;
-}
-
-/*
-* PARAMETERS
-* p_physp
-* [in] Pointer to an osm_physp_t object.
-*
-* p_slvl_tbl
-* [in] Pointer to the IBA defined SLtoVL map table for this
-* port number.
-*
-* in_port_num
-* [in] Input Port Number for this SLtoVL.
-*
-* RETURN VALUES
-* This function does not return a value.
-*
-* NOTES
-*
-* SEE ALSO
-* Port, Physical Port
-*********/
-
-/****f* OpenSM: Physical Port/osm_physp_get_slvl_tbl
-* NAME
-* osm_physp_get_slvl_tbl
-*
-* DESCRIPTION
-* Returns a pointer to the SLtoVL attribute of the Physical Port object.
-*
-* SYNOPSIS
-*/
-static inline ib_slvl_table_t *osm_physp_get_slvl_tbl(IN const osm_physp_t *
- const p_physp,
- IN uint8_t in_port_num)
-{
- ib_slvl_table_t *p_tbl;
-
- CL_ASSERT(osm_physp_is_valid(p_physp));
- p_tbl = cl_ptr_vector_get(&p_physp->slvl_by_port, in_port_num);
- return (p_tbl);
-}
-
-/*
-* PARAMETERS
-* p_physp
-* [in] Pointer to an osm_physp_t object.
-*
-* in_port_num
-* [in] Input Port Number for this SLtoVL.
-*
-* RETURN VALUES
-* The pointer to the slvl table
-*
-* NOTES
-*
-* SEE ALSO
-* Port, Physical Port
-*********/
-
-/****f* OpenSM: Physical Port/osm_physp_set_vla_tbl
-* NAME
-* osm_physp_set_vla_tbl
-*
-* DESCRIPTION
-* Copies the VL Arbitration attribute into the Physical Port object.
-*
-* SYNOPSIS
-*/
-static inline void
-osm_physp_set_vla_tbl(IN osm_physp_t * const p_physp,
- IN ib_vl_arb_table_t * p_vla_tbl, IN uint8_t block_num)
-{
- CL_ASSERT(p_vla_tbl);
- CL_ASSERT(osm_physp_is_valid(p_physp));
- CL_ASSERT((1 <= block_num) && (block_num <= 4));
- p_physp->vl_arb[block_num - 1] = *p_vla_tbl;
-}
-
-/*
-* PARAMETERS
-* p_physp
-* [in] Pointer to an osm_physp_t object.
-*
-* p_vla_tbl
-* [in] Pointer to the IBA defined VL Arbitration table for this
-* port number.
-*
-* block_num
-* [in] The part of the VL arbitration as defined in the IBA
-* (valid values 1-4)
-*
-* RETURN VALUES
-* This function does not return a value.
-*
-* NOTES
-*
-* SEE ALSO
-* Port, Physical Port
-*********/
-
-/****f* OpenSM: Physical Port/osm_physp_get_vla_tbl
-* NAME
-* osm_physp_get_vla_tbl
-*
-* DESCRIPTION
-* Returns a pointer to the VL Arbitration table of the Physical Port object.
-*
-* SYNOPSIS
-*/
-static inline ib_vl_arb_table_t *osm_physp_get_vla_tbl(IN osm_physp_t *
- const p_physp,
- IN uint8_t block_num)
-{
- CL_ASSERT(osm_physp_is_valid(p_physp));
- CL_ASSERT((1 <= block_num) && (block_num <= 4));
- return (&(p_physp->vl_arb[block_num - 1]));
-}
-
-/*
-* PARAMETERS
-* p_physp
-* [in] Pointer to an osm_physp_t object.
-*
-* block_num
-* [in] The part of the VL arbitration as defined in the IBA
-* (valid values 1-4)
-*
-* RETURN VALUES
-* The pointer to the VL Arbitration table
-*
-* NOTES
-*
-* SEE ALSO
-* Port, Physical Port
-*********/
-
-/****f* OpenSM: Physical Port/osm_physp_get_remote
-* NAME
-* osm_physp_get_remote
-*
-* DESCRIPTION
-* Returns a pointer to the Physical Port on the other side the wire.
-*
-* SYNOPSIS
-*/
-static inline osm_physp_t *osm_physp_get_remote(IN const osm_physp_t *
- const p_physp)
-{
- CL_ASSERT(osm_physp_is_valid(p_physp));
- return (p_physp->p_remote_physp);
-}
-
-/*
-* PARAMETERS
-* p_physp
-* [in] Pointer to an osm_physp_t object.
-*
-* RETURN VALUES
-* Returns a pointer to the Physical Port on the other side of
-* the wire. A return value of NULL means there is no link at this port.
-*
-* NOTES
-*
-* SEE ALSO
-* Port, Physical Port
-*********/
-
-/****f* OpenSM: Physical Port/osm_physp_get_port_guid
-* NAME
-* osm_physp_get_port_guid
-*
-* DESCRIPTION
-* Returns the port guid of this physical port.
-*
-* SYNOPSIS
-*/
-static inline ib_net64_t
-osm_physp_get_port_guid(IN const osm_physp_t * const p_physp)
-{
- CL_ASSERT(osm_physp_is_valid(p_physp));
- return (p_physp->port_guid);
-}
-
-/*
-* PARAMETERS
-* p_physp
-* [in] Pointer to an osm_physp_t object.
-*
-* RETURN VALUES
-* Returns the port guid of this physical port.
-*
-* NOTES
-*
-* SEE ALSO
-* Port, Physical Port
-*********/
-
-/****f* OpenSM: Physical Port/osm_physp_get_subnet_prefix
-* NAME
-* osm_physp_get_subnet_prefix
-*
-* DESCRIPTION
-* Returns the subnet prefix for this physical port.
-*
-* SYNOPSIS
-*/
-static inline ib_net64_t
-osm_physp_get_subnet_prefix(IN const osm_physp_t * const p_physp)
-{
- CL_ASSERT(osm_physp_is_valid(p_physp));
- return (p_physp->port_info.subnet_prefix);
-}
-
-/*
-* PARAMETERS
-* p_physp
-* [in] Pointer to an osm_physp_t object.
-*
-* RETURN VALUES
-* Returns the subnet prefix for this physical port.
-*
-* NOTES
-*
-* SEE ALSO
-* Port, Physical Port
-*********/
-
-/****f* OpenSM: Physical Port/osm_physp_link_exists
-* NAME
-* osm_physp_link_exists
-*
-* DESCRIPTION
-* Returns TRUE if the Physical Port has a link to the specified port.
-* FALSE otherwise.
-*
-* SYNOPSIS
-*/
-static inline boolean_t
-osm_physp_link_exists(IN const osm_physp_t * const p_physp,
- IN const osm_physp_t * const p_remote_physp)
-{
- CL_ASSERT(p_physp);
- CL_ASSERT(osm_physp_is_valid(p_physp));
- CL_ASSERT(p_remote_physp);
- CL_ASSERT(osm_physp_is_valid(p_remote_physp));
- return ((p_physp->p_remote_physp == p_remote_physp) &&
- (p_remote_physp->p_remote_physp == p_physp));
-}
-
-/*
-* PARAMETERS
-* p_physp
-* [in] Pointer to an osm_physp_t object.
-*
-* p_remote_physp
-* [in] Pointer to an osm_physp_t object.
-*
-* RETURN VALUES
-* Returns TRUE if the Physical Port has a link to another port.
-* FALSE otherwise.
-*
-* NOTES
-*
-* SEE ALSO
-* Port, Physical Port
-*********/
-
-/****f* OpenSM: Physical Port/osm_physp_link
-* NAME
-* osm_physp_link
-*
-* DESCRIPTION
-* Sets the pointers to the Physical Ports on the other side the wire.
-*
-* SYNOPSIS
-*/
-static inline void
-osm_physp_link(IN osm_physp_t * const p_physp,
- IN osm_physp_t * const p_remote_physp)
-{
- CL_ASSERT(p_physp);
- CL_ASSERT(p_remote_physp);
- p_physp->p_remote_physp = p_remote_physp;
- p_remote_physp->p_remote_physp = p_physp;
-}
-
-/*
-* PARAMETERS
-* p_physp
-* [in] Pointer to an osm_physp_t object to link.
-*
-* p_remote_physp
-* [in] Pointer to the adjacent osm_physp_t object to link.
-*
-* RETURN VALUES
-* None.
-*
-* NOTES
-*
-* SEE ALSO
-* Port, Physical Port
-*********/
-
-/****f* OpenSM: Physical Port/osm_physp_unlink
-* NAME
-* osm_physp_unlink
-*
-* DESCRIPTION
-* Clears the pointers to the Physical Port on the other side the wire.
-*
-* SYNOPSIS
-*/
-static inline void
-osm_physp_unlink(IN osm_physp_t * const p_physp,
- IN osm_physp_t * const p_remote_physp)
-{
- CL_ASSERT(p_physp);
- CL_ASSERT(p_remote_physp);
- CL_ASSERT(osm_physp_link_exists(p_physp, p_remote_physp));
- p_physp->p_remote_physp = NULL;
- p_remote_physp->p_remote_physp = NULL;
-}
-
-/*
-* PARAMETERS
-* p_physp
-* [in] Pointer to an osm_physp_t object to link.
-*
-* p_remote_physp
-* [in] Pointer to the adjacent osm_physp_t object to link.
-*
-* RETURN VALUES
-* None.
-*
-* NOTES
-*
-* SEE ALSO
-* Port, Physical Port
-*********/
-
-/****f* OpenSM: Physical Port/osm_physp_has_any_link
-* NAME
-* osm_physp_has_any_link
-*
-* DESCRIPTION
-* Returns TRUE if the Physical Port has a link to another port.
-* FALSE otherwise.
-*
-* SYNOPSIS
-*/
-static inline boolean_t
-osm_physp_has_any_link(IN const osm_physp_t * const p_physp)
-{
- CL_ASSERT(p_physp);
- if (osm_physp_is_valid(p_physp))
- return (p_physp->p_remote_physp != NULL);
- else
- return (FALSE);
-}
-
-/*
-* PARAMETERS
-* p_physp
-* [in] Pointer to an osm_physp_t object.
-*
-* RETURN VALUES
-* Returns TRUE if the Physical Port has a link to another port.
-* FALSE otherwise.
-*
-* NOTES
-*
-* SEE ALSO
-* Port, Physical Port
-*********/
-
-/****f* OpenSM: Physical Port/osm_physp_get_port_num
-* NAME
-* osm_physp_get_port_num
-*
-* DESCRIPTION
-* Returns the local port number of this Physical Port.
-*
-* SYNOPSIS
-*/
-static inline uint8_t
-osm_physp_get_port_num(IN const osm_physp_t * const p_physp)
-{
- CL_ASSERT(p_physp);
- CL_ASSERT(osm_physp_is_valid(p_physp));
- return (p_physp->port_num);
-}
-
-/*
-* PARAMETERS
-* p_physp
-* [in] Pointer to an osm_physp_t object.
-*
-* RETURN VALUES
-* Returns the local port number of this Physical Port.
-*
-* NOTES
-*
-* SEE ALSO
-*********/
-
-/****f* OpenSM: Physical Port/osm_physp_get_node_ptr
-* NAME
-* osm_physp_get_node_ptr
-*
-* DESCRIPTION
-* Returns a pointer to the parent Node object for this port.
-*
-* SYNOPSIS
-*/
-static inline struct osm_node *osm_physp_get_node_ptr(IN const osm_physp_t *
- const p_physp)
-{
- CL_ASSERT(p_physp);
- CL_ASSERT(osm_physp_is_valid(p_physp));
- return ((struct osm_node *)p_physp->p_node);
-}
-
-/*
-* PARAMETERS
-* p_physp
-* [in] Pointer to an osm_physp_t object.
-*
-* RETURN VALUES
-* Returns a pointer to the parent Node object for this port.
-*
-* NOTES
-*
-* SEE ALSO
-*********/
-
-/****f* OpenSM: Physical Port/osm_physp_get_port_state
-* NAME
-* osm_physp_get_port_state
-*
-* DESCRIPTION
-* Returns the port state of this Physical Port.
-*
-* SYNOPSIS
-*/
-static inline uint8_t
-osm_physp_get_port_state(IN const osm_physp_t * const p_physp)
-{
- CL_ASSERT(p_physp);
- CL_ASSERT(osm_physp_is_valid(p_physp));
- return (ib_port_info_get_port_state(&p_physp->port_info));
-}
-
-/*
-* PARAMETERS
-* p_physp
-* [in] Pointer to an osm_physp_t object.
-*
-* RETURN VALUES
-* Returns the local port number of this Physical Port.
-*
-* NOTES
-*
-* SEE ALSO
-*********/
-
-/****f* OpenSM: Physical Port/osm_physp_get_base_lid
-* NAME
-* osm_physp_get_base_lid
-*
-* DESCRIPTION
-* Returns the base lid of this Physical Port.
-*
-* SYNOPSIS
-*/
-static inline ib_net16_t
-osm_physp_get_base_lid(IN const osm_physp_t * const p_physp)
-{
- CL_ASSERT(p_physp);
- CL_ASSERT(osm_physp_is_valid(p_physp));
- return (p_physp->port_info.base_lid);
-}
-
-/*
-* PARAMETERS
-* p_physp
-* [in] Pointer to an osm_physp_t object.
-*
-* RETURN VALUES
-* Returns the base lid of this Physical Port.
-*
-* NOTES
-*
-* SEE ALSO
-*********/
-
-/****f* OpenSM: Physical Port/osm_physp_get_lmc
-* NAME
-* osm_physp_get_lmc
-*
-* DESCRIPTION
-* Returns the LMC value of this Physical Port.
-*
-* SYNOPSIS
-*/
-static inline uint8_t osm_physp_get_lmc(IN const osm_physp_t * const p_physp)
-{
- CL_ASSERT(p_physp);
- CL_ASSERT(osm_physp_is_valid(p_physp));
- return (ib_port_info_get_lmc(&p_physp->port_info));
-}
-
-/*
-* PARAMETERS
-* p_physp
-* [in] Pointer to an osm_physp_t object.
-*
-* RETURN VALUES
-* Returns the LMC value of this Physical Port.
-*
-* NOTES
-*
-* SEE ALSO
-*********/
-
-/****f* OpenSM: Physical Port/osm_physp_get_dr_path_ptr
-* NAME
-* osm_physp_get_dr_path_ptr
-*
-* DESCRIPTION
-* Returns a pointer to the directed route path for this port.
-*
-* SYNOPSIS
-*/
-static inline osm_dr_path_t *osm_physp_get_dr_path_ptr(IN const osm_physp_t *
- const p_physp)
-{
- CL_ASSERT(p_physp);
- CL_ASSERT(osm_physp_is_valid(p_physp));
- return ((osm_dr_path_t *) & p_physp->dr_path);
-}
-
-/*
-* PARAMETERS
-* p_physp
-* [in] Pointer to a Physical Port object.
-*
-* RETURN VALUES
-* Returns a pointer to the directed route path for this port.
-*
-* NOTES
-*
-* SEE ALSO
-* Physical Port object
-*********/
-
-/****h* OpenSM/Port
-* NAME
-* Port
-*
-* DESCRIPTION
-* The Port object encapsulates the information needed by the
-* OpenSM to manage ports. The OpenSM allocates one Port object
-* per port in the IBA subnet.
-*
-* Each Port object is associated with a single port GUID. A Port object
-* contains 1 or more Physical Port objects. An end point node has
-* one Physical Port per Port. A switch node has more than
-* one Physical Port per Port.
-*
-* The Port object is not thread safe, thus callers must provide
-* serialization.
-*
-* These objects should be treated as opaque and should be
-* manipulated only through the provided functions.
-*
-* AUTHOR
-* Steve King, Intel
-*
-*********/
-
-/****s* OpenSM: Port/osm_port_t
-* NAME
-* osm_port_t
-*
-* DESCRIPTION
-* This object represents a logical port on a switch, router or end-point.
-*
-* The osm_port_t object should be treated as opaque and should
-* be manipulated only through the provided functions.
-*
-* SYNOPSIS
-*/
-typedef struct osm_port {
- cl_map_item_t map_item;
- cl_list_item_t list_item;
- struct osm_node *p_node;
- ib_net64_t guid;
- uint32_t discovery_count;
- unsigned is_new;
- osm_physp_t *p_physp;
- cl_qlist_t mcm_list;
- int flag;
- void *priv;
-} osm_port_t;
-/*
-* FIELDS
-* map_item
-* Linkage structure for cl_qmap. MUST BE FIRST MEMBER!
-*
-* list_item
-* Linkage structure for cl_qlist. Used by ucast mgr during LFT calculation.
-*
-* p_node
-* Points to the Node object that owns this port.
-*
-* guid
-* Manufacturer assigned GUID for this port.
-*
-* discovery_count
-* The number of times this port has been discovered
-* during the current fabric sweep. This number is reset
-* to zero at the start of a sweep.
-*
-* p_physp
-* The pointer to physical port used when physical
-* characteristics contained in the Physical Port are needed.
-*
-* mcm_list
-* Multicast member list
-*
-* flag
-* Utility flag for port management
-*
-* SEE ALSO
-* Port, Physical Port, Physical Port Table
-*********/
-
-/****f* OpenSM: Port/osm_port_delete
-* NAME
-* osm_port_delete
-*
-* DESCRIPTION
-* This function destroys and deallocates a Port object.
-*
-* SYNOPSIS
-*/
-void osm_port_delete(IN OUT osm_port_t ** const pp_port);
-/*
-* PARAMETERS
-* pp_port
-* [in][out] Pointer to a pointer to a Port object to delete.
-* On return, this pointer is NULL.
-*
-* RETURN VALUE
-* This function does not return a value.
-*
-* NOTES
-* Performs any necessary cleanup of the specified Port object.
-*
-* SEE ALSO
-* Port
-*********/
-
-/****f* OpenSM: Port/osm_port_new
-* NAME
-* osm_port_new
-*
-* DESCRIPTION
-* This function allocates and initializes a Port object.
-*
-* SYNOPSIS
-*/
-osm_port_t *osm_port_new(IN const ib_node_info_t * p_ni,
- IN struct osm_node *const p_parent_node);
-/*
-* PARAMETERS
-* p_ni
-* [in] Pointer to the NodeInfo attribute relavent for this port.
-*
-* p_parent_node
-* [in] Pointer to the initialized parent osm_node_t object
-* that owns this port.
-*
-* RETURN VALUE
-* Pointer to the initialize Port object.
-*
-* NOTES
-* Allows calling other port methods.
-*
-* SEE ALSO
-* Port
-*********/
-
-/****f* OpenSM: Port/osm_port_get_base_lid
-* NAME
-* osm_port_get_base_lid
-*
-* DESCRIPTION
-* Gets the base LID of a port.
-*
-* SYNOPSIS
-*/
-static inline ib_net16_t
-osm_port_get_base_lid(IN const osm_port_t * const p_port)
-{
- CL_ASSERT(p_port->p_physp && osm_physp_is_valid(p_port->p_physp));
- return (osm_physp_get_base_lid(p_port->p_physp));
-}
-
-/*
-* PARAMETERS
-* p_port
-* [in] Pointer to a Port object.
-*
-* RETURN VALUE
-* Base LID of the port.
-* If the return value is 0, then this port has no assigned LID.
-*
-* NOTES
-*
-* SEE ALSO
-* Port
-*********/
-
-/****f* OpenSM: Port/osm_port_get_lmc
-* NAME
-* osm_port_get_lmc
-*
-* DESCRIPTION
-* Gets the LMC value of a port.
-*
-* SYNOPSIS
-*/
-static inline uint8_t osm_port_get_lmc(IN const osm_port_t * const p_port)
-{
- CL_ASSERT(p_port->p_physp && osm_physp_is_valid(p_port->p_physp));
- return (osm_physp_get_lmc(p_port->p_physp));
-}
-
-/*
-* PARAMETERS
-* p_port
-* [in] Pointer to a Port object.
-*
-* RETURN VALUE
-* Gets the LMC value of a port.
-*
-* NOTES
-*
-* SEE ALSO
-* Port
-*********/
-
-/****f* OpenSM: Port/osm_port_get_guid
-* NAME
-* osm_port_get_guid
-*
-* DESCRIPTION
-* Gets the GUID of a port.
-*
-* SYNOPSIS
-*/
-static inline ib_net64_t osm_port_get_guid(IN const osm_port_t * const p_port)
-{
- return (p_port->guid);
-}
-
-/*
-* PARAMETERS
-* p_port
-* [in] Pointer to a Port object.
-*
-* RETURN VALUE
-* Manufacturer assigned GUID of the port.
-*
-* NOTES
-*
-* SEE ALSO
-* Port
-*********/
-
-/****f* OpenSM: Port/osm_port_get_lid_range_ho
-* NAME
-* osm_port_get_lid_range_ho
-*
-* DESCRIPTION
-* Returns the HOST ORDER lid min and max values for this port,
-* based on the lmc value.
-*
-* SYNOPSIS
-*/
-void
-osm_port_get_lid_range_ho(IN const osm_port_t * const p_port,
- OUT uint16_t * const p_min_lid,
- OUT uint16_t * const p_max_lid);
-/*
-* PARAMETERS
-* p_port
-* [in] Pointer to a Port object.
-*
-* p_min_lid
-* [out] Pointer to the minimum LID value occupied by this port.
-*
-* p_max_lid
-* [out] Pointer to the maximum LID value occupied by this port.
-*
-* RETURN VALUE
-* None.
-*
-* NOTES
-*
-* SEE ALSO
-* Port
-*********/
-
-/****f* OpenSM: Port/osm_get_port_by_base_lid
-* NAME
-* osm_get_port_by_base_lid
-*
-* DESCRIPTION
-* Returns a status on whether a Port was able to be
-* determined based on the LID supplied and if so, return the Port.
-*
-* SYNOPSIS
-*/
-ib_api_status_t
-osm_get_port_by_base_lid(IN const osm_subn_t * const p_subn,
- IN const ib_net16_t lid,
- IN OUT const osm_port_t ** const pp_port);
-/*
-* PARAMETERS
-* p_subn
-* [in] Pointer to the subnet data structure.
-*
-* lid
-* [in] LID requested.
-*
-* pp_port
-* [in][out] Pointer to pointer to Port object.
-*
-* RETURN VALUES
-* IB_SUCCESS
-* IB_NOT_FOUND
-*
-* NOTES
-*
-* SEE ALSO
-* Port
-*********/
-
-/****f* OpenSM: Port/osm_port_add_mgrp
-* NAME
-* osm_port_add_mgrp
-*
-* DESCRIPTION
-* Logically connects a port to a multicast group.
-*
-* SYNOPSIS
-*/
-ib_api_status_t
-osm_port_add_mgrp(IN osm_port_t * const p_port, IN const ib_net16_t mlid);
-/*
-* PARAMETERS
-* p_port
-* [in] Pointer to an osm_port_t object.
-*
-* mlid
-* [in] MLID of the multicast group.
-*
-* RETURN VALUES
-* IB_SUCCESS
-* IB_INSUFFICIENT_MEMORY
-*
-* NOTES
-*
-* SEE ALSO
-* Port object
-*********/
-
-/****f* OpenSM: Port/osm_port_remove_mgrp
-* NAME
-* osm_port_remove_mgrp
-*
-* DESCRIPTION
-* Logically disconnects a port from a multicast group.
-*
-* SYNOPSIS
-*/
-void
-osm_port_remove_mgrp(IN osm_port_t * const p_port, IN const ib_net16_t mlid);
-/*
-* PARAMETERS
-* p_port
-* [in] Pointer to an osm_port_t object.
-*
-* mlid
-* [in] MLID of the multicast group.
-*
-* RETURN VALUES
-* None.
-*
-* NOTES
-*
-* SEE ALSO
-* Port object
-*********/
-
-/****f* OpenSM: Port/osm_port_remove_all_mgrp
-* NAME
-* osm_port_remove_all_mgrp
-*
-* DESCRIPTION
-* Logically disconnects a port from all its multicast groups.
-*
-* SYNOPSIS
-*/
-void osm_port_remove_all_mgrp(IN osm_port_t * const p_port);
-/*
-* PARAMETERS
-* p_port
-* [in] Pointer to an osm_port_t object.
-*
-* RETURN VALUES
-* None.
-*
-* NOTES
-*
-* SEE ALSO
-* Port object
-*********/
-
-/****f* OpenSM: Physical Port/osm_physp_calc_link_mtu
-* NAME
-* osm_physp_calc_link_mtu
-*
-* DESCRIPTION
-* Calculate the Port MTU based on current and remote
-* physical ports MTU CAP values.
-*
-* SYNOPSIS
-*/
-uint8_t
-osm_physp_calc_link_mtu(IN osm_log_t * p_log, IN const osm_physp_t * p_physp);
-/*
-* PARAMETERS
-* p_log
-* [in] Pointer to a log object.
-*
-* p_physp
-* [in] Pointer to an osm_physp_t object.
-*
-* RETURN VALUES
-* The MTU of the link to be used.
-*
-* NOTES
-*
-* SEE ALSO
-* PhysPort object
-*********/
-
-/****f* OpenSM: Physical Port/osm_physp_calc_link_op_vls
-* NAME
-* osm_physp_calc_link_op_vls
-*
-* DESCRIPTION
-* Calculate the Port OP_VLS based on current and remote
-* physical ports VL CAP values. Allowing user option for a max limit.
-*
-* SYNOPSIS
-*/
-uint8_t
-osm_physp_calc_link_op_vls(IN osm_log_t * p_log,
- IN const osm_subn_t * p_subn,
- IN const osm_physp_t * p_physp);
-/*
-* PARAMETERS
-* p_log
-* [in] Pointer to a log object.
-*
-* p_subn
-* [in] Pointer to the subnet object for accessing of the options.
-*
-* p_physp
-* [in] Pointer to an osm_physp_t object.
-*
-* RETURN VALUES
-* The OP_VLS of the link to be used.
-*
-* NOTES
-*
-* SEE ALSO
-* PhysPort object
-*********/
-
-/****f* OpenSM: Physical Port/osm_physp_replace_dr_path_with_alternate_dr_path
-* NAME
-* osm_physp_replace_dr_path_with_alternate_dr_path
-*
-* DESCRIPTION
-* Replace the direct route path for the given phys port with an
-* alternate path going through forien set of phys port.
-*
-* SYNOPSIS
-*/
-void
-osm_physp_replace_dr_path_with_alternate_dr_path(IN osm_log_t * p_log,
- IN osm_subn_t const *p_subn,
- IN osm_physp_t const *p_physp,
- IN osm_bind_handle_t * h_bind);
-/*
-* PARAMETERS
-* p_log
-* [in] Pointer to a log object.
-*
-* p_subn
-* [in] Pointer to the subnet object for accessing of the options.
-*
-* p_physp
-* [in] Pointer to an osm_physp_t object.
-*
-* h_bind
-* [in] Pointer to osm_bind_handle_t object.
-*
-* RETURN VALUES
-* NONE
-*
-* NOTES
-*
-* SEE ALSO
-* PhysPort object
-*********/
-
-END_C_DECLS
-#endif /* _OSM_PORT_H_ */
diff --git a/contrib/ofed/management/opensm/include/opensm/osm_port_profile.h b/contrib/ofed/management/opensm/include/opensm/osm_port_profile.h
deleted file mode 100644
index fd227190..0000000
--- a/contrib/ofed/management/opensm/include/opensm/osm_port_profile.h
+++ /dev/null
@@ -1,207 +0,0 @@
-/*
- * Copyright (c) 2004-2008 Voltaire, Inc. All rights reserved.
- * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved.
- * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
- * Copyright (c) 2008 Xsigo Systems Inc. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- */
-
-/*
- * Abstract:
- * Declaration of Switch/osm_port_profile_t.
- * This object represents a port profile for an IBA switch.
- * This object is part of the OpenSM family of objects.
- */
-
-#ifndef _OSM_PORT_PROFILE_H_
-#define _OSM_PORT_PROFILE_H_
-
-#include <string.h>
-#include <iba/ib_types.h>
-#include <opensm/osm_base.h>
-#include <opensm/osm_madw.h>
-#include <opensm/osm_subnet.h>
-#include <opensm/osm_node.h>
-#include <opensm/osm_port.h>
-#include <opensm/osm_mcast_tbl.h>
-
-#ifdef __cplusplus
-# define BEGIN_C_DECLS extern "C" {
-# define END_C_DECLS }
-#else /* !__cplusplus */
-# define BEGIN_C_DECLS
-# define END_C_DECLS
-#endif /* __cplusplus */
-
-BEGIN_C_DECLS
-/****h* OpenSM/Port Profile
-* NAME
-* Port Profile
-*
-* DESCRIPTION
-* The Port Profile object contains profiling information for
-* each Physical Port on a switch. The profile information
-* may be used to optimize path selection.
-*
-* AUTHOR
-* Steve King, Intel
-*
-*********/
-/****s* OpenSM: Switch/osm_port_profile_t
-* NAME
-* osm_port_profile_t
-*
-* DESCRIPTION
-* The Port Profile object contains profiling information for
-* each Physical Port on the switch. The profile information
-* may be used to optimize path selection.
-*
-* This object should be treated as opaque and should be
-* be manipulated only through the provided functions.
-*
-* SYNOPSIS
-*/
-typedef struct osm_port_profile {
- uint32_t num_paths;
-} osm_port_profile_t;
-/*
-* FIELDS
-* num_paths
-* The number of paths using this port.
-*
-* SEE ALSO
-*********/
-
-/****s* OpenSM: Switch/osm_port_mask_t
-* NAME
-* osm_port_mask_t
-*
-* DESCRIPTION
-* The Port Mask object contains a port numbered bit mask
-* for whether the port should be ignored by the link load
-* equalization algorithm.
-*
-* SYNOPSIS
-*/
-typedef long osm_port_mask_t[32 / sizeof(long)];
-/*
-* FIELDS
-* osm_port_mask_t
-* Bit mask by port number
-*
-* SEE ALSO
-*********/
-
-/****f* OpenSM: Port Profile/osm_port_prof_construct
-* NAME
-* osm_port_prof_construct
-*
-* DESCRIPTION
-*
-*
-* SYNOPSIS
-*/
-static inline void osm_port_prof_construct(IN osm_port_profile_t * const p_prof)
-{
- CL_ASSERT(p_prof);
- memset(p_prof, 0, sizeof(*p_prof));
-}
-/*
-* PARAMETERS
-* p_prof
-* [in] Pointer to the Port Profile object to construct.
-*
-* RETURN VALUE
-* None.
-*
-* NOTES
-*
-* SEE ALSO
-*********/
-
-/****f* OpenSM: Port Profile/osm_port_prof_path_count_inc
-* NAME
-* osm_port_prof_path_count_inc
-*
-* DESCRIPTION
-* Increments the count of the number of paths going through this port.
-*
-*
-* SYNOPSIS
-*/
-static inline void
-osm_port_prof_path_count_inc(IN osm_port_profile_t * const p_prof)
-{
- CL_ASSERT(p_prof);
- p_prof->num_paths++;
-}
-/*
-* PARAMETERS
-* p_prof
-* [in] Pointer to the Port Profile object.
-*
-* RETURN VALUE
-* None.
-*
-* NOTES
-*
-* SEE ALSO
-*********/
-
-/****f* OpenSM: Port Profile/osm_port_prof_path_count_get
-* NAME
-* osm_port_prof_path_count_get
-*
-* DESCRIPTION
-* Returns the count of the number of paths going through this port.
-*
-* SYNOPSIS
-*/
-static inline uint32_t
-osm_port_prof_path_count_get(IN const osm_port_profile_t * const p_prof)
-{
- return (p_prof->num_paths);
-}
-/*
-* PARAMETERS
-* p_prof
-* [in] Pointer to the Port Profile object.
-*
-* RETURN VALUE
-* None.
-*
-* NOTES
-*
-* SEE ALSO
-*********/
-
-END_C_DECLS
-#endif /* _OSM_PORT_PROFILE_H_ */
diff --git a/contrib/ofed/management/opensm/include/opensm/osm_qos_policy.h b/contrib/ofed/management/opensm/include/opensm/osm_qos_policy.h
deleted file mode 100644
index c38624b..0000000
--- a/contrib/ofed/management/opensm/include/opensm/osm_qos_policy.h
+++ /dev/null
@@ -1,204 +0,0 @@
-/*
- * Copyright (c) 2004-2007 Voltaire, Inc. All rights reserved.
- * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved.
- * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- */
-
-/*
- * Abstract:
- * Declaration of OSM QoS Policy data types and functions.
- *
- * Author:
- * Yevgeny Kliteynik, Mellanox
- */
-
-#ifndef OSM_QOS_POLICY_H
-#define OSM_QOS_POLICY_H
-
-#include <iba/ib_types.h>
-#include <complib/cl_list.h>
-#include <opensm/st.h>
-#include <opensm/osm_port.h>
-#include <opensm/osm_partition.h>
-
-#define YYSTYPE char *
-#define OSM_QOS_POLICY_MAX_PORTS_ON_SWITCH 128
-#define OSM_QOS_POLICY_DEFAULT_LEVEL_NAME "default"
-
-#define OSM_QOS_POLICY_ULP_SDP_SERVICE_ID 0x0000000000010000ULL
-#define OSM_QOS_POLICY_ULP_RDS_SERVICE_ID 0x0000000001060000ULL
-#define OSM_QOS_POLICY_ULP_RDS_PORT 0x48CA
-#define OSM_QOS_POLICY_ULP_ISER_SERVICE_ID 0x0000000001060000ULL
-#define OSM_QOS_POLICY_ULP_ISER_PORT 0x0CBC
-
-#define OSM_QOS_POLICY_NODE_TYPE_CA (((uint8_t)1)<<IB_NODE_TYPE_CA)
-#define OSM_QOS_POLICY_NODE_TYPE_SWITCH (((uint8_t)1)<<IB_NODE_TYPE_SWITCH)
-#define OSM_QOS_POLICY_NODE_TYPE_ROUTER (((uint8_t)1)<<IB_NODE_TYPE_ROUTER)
-
-/***************************************************/
-
-typedef struct osm_qos_port {
- cl_map_item_t map_item;
- osm_physp_t * p_physp;
-} osm_qos_port_t;
-
-typedef struct osm_qos_port_group {
- char *name; /* single string (this port group name) */
- char *use; /* single string (description) */
- uint8_t node_types; /* node types bitmask */
- cl_qmap_t port_map;
-} osm_qos_port_group_t;
-
-/***************************************************/
-
-typedef struct osm_qos_vlarb_scope {
- cl_list_t group_list; /* list of group names (strings) */
- cl_list_t across_list; /* list of 'across' group names (strings) */
- cl_list_t vlarb_high_list; /* list of num pairs (n:m,...), 32-bit values */
- cl_list_t vlarb_low_list; /* list of num pairs (n:m,...), 32-bit values */
- uint32_t vl_high_limit; /* single integer */
- boolean_t vl_high_limit_set;
-} osm_qos_vlarb_scope_t;
-
-/***************************************************/
-
-typedef struct osm_qos_sl2vl_scope {
- cl_list_t group_list; /* list of strings (port group names) */
- boolean_t from[OSM_QOS_POLICY_MAX_PORTS_ON_SWITCH];
- boolean_t to[OSM_QOS_POLICY_MAX_PORTS_ON_SWITCH];
- cl_list_t across_from_list; /* list of strings (port group names) */
- cl_list_t across_to_list; /* list of strings (port group names) */
- uint8_t sl2vl_table[16]; /* array of sl2vl values */
- boolean_t sl2vl_table_set;
-} osm_qos_sl2vl_scope_t;
-
-/***************************************************/
-
-typedef struct osm_qos_level {
- char *use;
- char *name;
- uint8_t sl;
- boolean_t sl_set;
- uint8_t mtu_limit;
- boolean_t mtu_limit_set;
- uint8_t rate_limit;
- boolean_t rate_limit_set;
- uint8_t pkt_life;
- boolean_t pkt_life_set;
- uint64_t **path_bits_range_arr; /* array of bit ranges (real values are 32bits) */
- unsigned path_bits_range_len; /* num of bit ranges in the array */
- uint64_t **pkey_range_arr; /* array of PKey ranges (real values are 16bits) */
- unsigned pkey_range_len;
-} osm_qos_level_t;
-
-
-/***************************************************/
-
-typedef struct osm_qos_match_rule {
- char *use;
- cl_list_t source_list; /* list of strings */
- cl_list_t source_group_list; /* list of pointers to relevant port-group */
- cl_list_t destination_list; /* list of strings */
- cl_list_t destination_group_list; /* list of pointers to relevant port-group */
- char *qos_level_name;
- osm_qos_level_t *p_qos_level;
- uint64_t **service_id_range_arr; /* array of SID ranges (64-bit values) */
- unsigned service_id_range_len;
- uint64_t **qos_class_range_arr; /* array of QoS Class ranges (real values are 16bits) */
- unsigned qos_class_range_len;
- uint64_t **pkey_range_arr; /* array of PKey ranges (real values are 16bits) */
- unsigned pkey_range_len;
-} osm_qos_match_rule_t;
-
-/***************************************************/
-
-typedef struct osm_qos_policy {
- cl_list_t port_groups; /* list of osm_qos_port_group_t */
- cl_list_t sl2vl_tables; /* list of osm_qos_sl2vl_scope_t */
- cl_list_t vlarb_tables; /* list of osm_qos_vlarb_scope_t */
- cl_list_t qos_levels; /* list of osm_qos_level_t */
- cl_list_t qos_match_rules; /* list of osm_qos_match_rule_t */
- osm_qos_level_t *p_default_qos_level; /* default QoS level */
- osm_subn_t *p_subn; /* osm subnet object */
- st_table * p_node_hash; /* node by name hash */
-} osm_qos_policy_t;
-
-/***************************************************/
-
-osm_qos_port_t *osm_qos_policy_port_create(osm_physp_t * p_physp);
-osm_qos_port_group_t * osm_qos_policy_port_group_create();
-void osm_qos_policy_port_group_destroy(osm_qos_port_group_t * p_port_group);
-
-osm_qos_vlarb_scope_t * osm_qos_policy_vlarb_scope_create();
-void osm_qos_policy_vlarb_scope_destroy(osm_qos_vlarb_scope_t * p_vlarb_scope);
-
-osm_qos_sl2vl_scope_t * osm_qos_policy_sl2vl_scope_create();
-void osm_qos_policy_sl2vl_scope_destroy(osm_qos_sl2vl_scope_t * p_sl2vl_scope);
-
-osm_qos_level_t * osm_qos_policy_qos_level_create();
-void osm_qos_policy_qos_level_destroy(osm_qos_level_t * p_qos_level);
-
-boolean_t osm_qos_level_has_pkey(IN const osm_qos_level_t * p_qos_level,
- IN ib_net16_t pkey);
-
-ib_net16_t osm_qos_level_get_shared_pkey(IN const osm_qos_level_t * p_qos_level,
- IN const osm_physp_t * p_src_physp,
- IN const osm_physp_t * p_dest_physp);
-
-osm_qos_match_rule_t * osm_qos_policy_match_rule_create();
-void osm_qos_policy_match_rule_destroy(osm_qos_match_rule_t * p_match_rule);
-
-osm_qos_policy_t * osm_qos_policy_create(osm_subn_t * p_subn);
-void osm_qos_policy_destroy(osm_qos_policy_t * p_qos_policy);
-int osm_qos_policy_validate(osm_qos_policy_t * p_qos_policy, osm_log_t * p_log);
-
-osm_qos_level_t * osm_qos_policy_get_qos_level_by_pr(
- IN const osm_qos_policy_t * p_qos_policy,
- IN const ib_path_rec_t * p_pr,
- IN const osm_physp_t * p_src_physp,
- IN const osm_physp_t * p_dest_physp,
- IN ib_net64_t comp_mask);
-
-osm_qos_level_t * osm_qos_policy_get_qos_level_by_mpr(
- IN const osm_qos_policy_t * p_qos_policy,
- IN const ib_multipath_rec_t * p_mpr,
- IN const osm_physp_t * p_src_physp,
- IN const osm_physp_t * p_dest_physp,
- IN ib_net64_t comp_mask);
-
-/***************************************************/
-
-int osm_qos_parse_policy_file(IN osm_subn_t * const p_subn);
-
-/***************************************************/
-
-#endif /* ifndef OSM_QOS_POLICY_H */
diff --git a/contrib/ofed/management/opensm/include/opensm/osm_remote_sm.h b/contrib/ofed/management/opensm/include/opensm/osm_remote_sm.h
deleted file mode 100644
index 4cc980b..0000000
--- a/contrib/ofed/management/opensm/include/opensm/osm_remote_sm.h
+++ /dev/null
@@ -1,198 +0,0 @@
-/*
- * Copyright (c) 2004-2006 Voltaire, Inc. All rights reserved.
- * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved.
- * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- */
-
-/*
- * Abstract:
- * Declaration of osm_sm_t, osm_remote_sm_t.
- * This object represents an IBA subnet.
- * This object is part of the OpenSM family of objects.
- */
-
-#ifndef _OSM_REMOTE_SM_H_
-#define _OSM_REMOTE_SM_H_
-
-#include <iba/ib_types.h>
-#include <opensm/osm_base.h>
-#include <opensm/osm_port.h>
-
-#ifdef __cplusplus
-# define BEGIN_C_DECLS extern "C" {
-# define END_C_DECLS }
-#else /* !__cplusplus */
-# define BEGIN_C_DECLS
-# define END_C_DECLS
-#endif /* __cplusplus */
-
-BEGIN_C_DECLS
-/****h* OpenSM/Remote SM
-* NAME
-* Remote SM
-*
-* DESCRIPTION
-* The Remote SM object encapsulates the information tracked for
-* other SM ports on the subnet.
-*
-* The Remote SM object is thread safe.
-*
-* This object should be treated as opaque and should
-* be manipulated only through the provided functions.
-*
-* AUTHOR
-* Steve King, Intel
-*
-*********/
-/****s* OpenSM: Remote SM/osm_remote_sm_t
-* NAME
-* osm_remote_sm_t
-*
-* DESCRIPTION
-* Remote Subnet Manager structure.
-*
-* This object should be treated as opaque and should
-* be manipulated only through the provided functions.
-*
-* SYNOPSIS
-*/
-typedef struct osm_remote_sm {
- cl_map_item_t map_item;
- const osm_port_t *p_port;
- ib_sm_info_t smi;
-} osm_remote_sm_t;
-/*
-* FIELDS
-* map_item
-* Linkage for the cl_qmap container. MUST BE FIRST ELEMENT!!
-* p_port
-* Pointer to the port object for this SM.
-*
-* smi
-* The SMInfo attribute for this SM.
-*
-* SEE ALSO
-*********/
-
-/****f* OpenSM: SM/osm_remote_sm_construct
-* NAME
-* osm_remote_sm_construct
-*
-* DESCRIPTION
-* This function constructs an Remote SM object.
-*
-* SYNOPSIS
-*/
-void osm_remote_sm_construct(IN osm_remote_sm_t * const p_sm);
-/*
-* PARAMETERS
-* p_sm
-* [in] Pointer to an Remote SM object to construct.
-*
-* RETURN VALUE
-* This function does not return a value.
-*
-* NOTES
-* Allows calling osm_remote_sm_init, osm_remote_sm_destroy
-*
-* Calling osm_remote_sm_construct is a prerequisite to calling any other
-* method except osm_remote_sm_init.
-*
-* SEE ALSO
-* SM object, osm_remote_sm_init, osm_remote_sm_destroy
-*********/
-
-/****f* OpenSM: SM/osm_remote_sm_destroy
-* NAME
-* osm_remote_sm_destroy
-*
-* DESCRIPTION
-* The osm_remote_sm_destroy function destroys an SM, releasing
-* all resources.
-*
-* SYNOPSIS
-*/
-void osm_remote_sm_destroy(IN osm_remote_sm_t * const p_sm);
-/*
-* PARAMETERS
-* p_sm
-* [in] Pointer to an Remote SM object to destroy.
-*
-* RETURN VALUE
-* This function does not return a value.
-*
-* NOTES
-* Performs any necessary cleanup of the specified Remote SM object.
-* Further operations should not be attempted on the destroyed object.
-* This function should only be called after a call to
-* osm_remote_sm_construct or osm_remote_sm_init.
-*
-* SEE ALSO
-* Remote SM object, osm_remote_sm_construct, osm_remote_sm_init
-*********/
-
-/****f* OpenSM: SM/osm_remote_sm_init
-* NAME
-* osm_remote_sm_init
-*
-* DESCRIPTION
-* The osm_remote_sm_init function initializes an Remote SM object for use.
-*
-* SYNOPSIS
-*/
-void
-osm_remote_sm_init(IN osm_remote_sm_t * const p_sm,
- IN const osm_port_t * const p_port,
- IN const ib_sm_info_t * const p_smi);
-/*
-* PARAMETERS
-* p_sm
-* [in] Pointer to an osm_remote_sm_t object to initialize.
-*
-* p_port
-* [in] Pointer to the Remote SM's port object.
-*
-* p_smi
-* [in] Pointer to the SMInfo attribute for this SM.
-*
-* RETURN VALUES
-* This function does not return a value.
-*
-* NOTES
-* Allows calling other Remote SM methods.
-*
-* SEE ALSO
-* Remote SM object, osm_remote_sm_construct, osm_remote_sm_destroy
-*********/
-
-END_C_DECLS
-#endif /* _OSM_REMOTE_SM_H_ */
diff --git a/contrib/ofed/management/opensm/include/opensm/osm_router.h b/contrib/ofed/management/opensm/include/opensm/osm_router.h
deleted file mode 100644
index 4901aca..0000000
--- a/contrib/ofed/management/opensm/include/opensm/osm_router.h
+++ /dev/null
@@ -1,217 +0,0 @@
-/*
- * Copyright (c) 2004-2007 Voltaire, Inc. All rights reserved.
- * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved.
- * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- */
-
-/*
- * Abstract:
- * Declaration of osm_router_t.
- * This object represents an IBA router.
- * This object is part of the OpenSM family of objects.
- */
-
-#ifndef _OSM_ROUTER_H_
-#define _OSM_ROUTER_H_
-
-#include <iba/ib_types.h>
-#include <opensm/osm_base.h>
-#include <opensm/osm_madw.h>
-#include <opensm/osm_node.h>
-#include <opensm/osm_port.h>
-#include <opensm/osm_mcast_tbl.h>
-#include <opensm/osm_port_profile.h>
-
-#ifdef __cplusplus
-# define BEGIN_C_DECLS extern "C" {
-# define END_C_DECLS }
-#else /* !__cplusplus */
-# define BEGIN_C_DECLS
-# define END_C_DECLS
-#endif /* __cplusplus */
-
-BEGIN_C_DECLS
-/****h* OpenSM/Router
-* NAME
-* Router
-*
-* DESCRIPTION
-* The Router object encapsulates the information needed by the
-* OpenSM to manage routers. The OpenSM allocates one router object
-* per router in the IBA subnet.
-*
-* The Router object is not thread safe, thus callers must provide
-* serialization.
-*
-* This object should be treated as opaque and should be
-* manipulated only through the provided functions.
-*
-* AUTHOR
-* Hal Rosenstock, Voltaire
-*
-*********/
-/****s* OpenSM: Router/osm_router_t
-* NAME
-* osm_router_t
-*
-* DESCRIPTION
-* Router structure.
-*
-* This object should be treated as opaque and should
-* be manipulated only through the provided functions.
-*
-* SYNOPSIS
-*/
-typedef struct osm_router {
- cl_map_item_t map_item;
- osm_port_t *p_port;
-} osm_router_t;
-/*
-* FIELDS
-* map_item
-* Linkage structure for cl_qmap. MUST BE FIRST MEMBER!
-*
-* p_port
-* Pointer to the Port object for this router.
-*
-* SEE ALSO
-* Router object
-*********/
-
-/****f* OpenSM: Router/osm_router_delete
-* NAME
-* osm_router_delete
-*
-* DESCRIPTION
-* Destroys and deallocates the object.
-*
-* SYNOPSIS
-*/
-void osm_router_delete(IN OUT osm_router_t ** const pp_rtr);
-/*
-* PARAMETERS
-* p_rtr
-* [in] Pointer to the object to destroy.
-*
-* RETURN VALUE
-* None.
-*
-* NOTES
-*
-* SEE ALSO
-* Router object, osm_router_new
-*********/
-
-/****f* OpenSM: Router/osm_router_new
-* NAME
-* osm_router_new
-*
-* DESCRIPTION
-* The osm_router_new function initializes a Router object for use.
-*
-* SYNOPSIS
-*/
-osm_router_t *osm_router_new(IN osm_port_t * const p_port);
-/*
-* PARAMETERS
-* p_node
-* [in] Pointer to the node object of this router
-*
-* RETURN VALUES
-* Pointer to the new initialized router object.
-*
-* NOTES
-*
-* SEE ALSO
-* Router object, osm_router_new
-*********/
-
-/****f* OpenSM: Router/osm_router_get_port_ptr
-* NAME
-* osm_router_get_port_ptr
-*
-* DESCRIPTION
-* Returns a pointer to the Port object for this router.
-*
-* SYNOPSIS
-*/
-static inline osm_port_t *osm_router_get_port_ptr(IN const osm_router_t *
- const p_rtr)
-{
- return (p_rtr->p_port);
-}
-
-/*
-* PARAMETERS
-* p_rtr
-* [in] Pointer to an osm_router_t object.
-*
-* RETURN VALUES
-* Returns a pointer to the Port object for this router.
-*
-* NOTES
-*
-* SEE ALSO
-* Router object
-*********/
-
-/****f* OpenSM: Router/osm_router_get_node_ptr
-* NAME
-* osm_router_get_node_ptr
-*
-* DESCRIPTION
-* Returns a pointer to the Node object for this router.
-*
-* SYNOPSIS
-*/
-static inline osm_node_t *osm_router_get_node_ptr(IN const osm_router_t *
- const p_rtr)
-{
- return (p_rtr->p_port->p_node);
-}
-
-/*
-* PARAMETERS
-* p_rtr
-* [in] Pointer to an osm_router_t object.
-*
-* RETURN VALUES
-* Returns a pointer to the Node object for this router.
-*
-* NOTES
-*
-* SEE ALSO
-* Router object
-*********/
-
-END_C_DECLS
-#endif /* _OSM_ROUTER_H_ */
diff --git a/contrib/ofed/management/opensm/include/opensm/osm_sa.h b/contrib/ofed/management/opensm/include/opensm/osm_sa.h
deleted file mode 100644
index 5a0ae9f..0000000
--- a/contrib/ofed/management/opensm/include/opensm/osm_sa.h
+++ /dev/null
@@ -1,496 +0,0 @@
-/*
- * Copyright (c) 2004-2008 Voltaire, Inc. All rights reserved.
- * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved.
- * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- */
-
-/*
- * Abstract:
- * Declaration of osm_sa_t.
- * This object represents an IBA subnet.
- * This object is part of the OpenSM family of objects.
- */
-
-#ifndef _OSM_SA_H_
-#define _OSM_SA_H_
-
-#include <iba/ib_types.h>
-#include <complib/cl_passivelock.h>
-#include <complib/cl_event.h>
-#include <complib/cl_thread.h>
-#include <complib/cl_timer.h>
-#include <complib/cl_dispatcher.h>
-#include <opensm/osm_stats.h>
-#include <opensm/osm_subnet.h>
-#include <vendor/osm_vendor_api.h>
-#include <opensm/osm_mad_pool.h>
-#include <opensm/osm_log.h>
-#include <opensm/osm_sa_mad_ctrl.h>
-#include <opensm/osm_sm.h>
-#include <opensm/osm_multicast.h>
-
-#ifdef __cplusplus
-# define BEGIN_C_DECLS extern "C" {
-# define END_C_DECLS }
-#else /* !__cplusplus */
-# define BEGIN_C_DECLS
-# define END_C_DECLS
-#endif /* __cplusplus */
-
-BEGIN_C_DECLS
-/****h* OpenSM/SA
-* NAME
-* SA
-*
-* DESCRIPTION
-* The SA object encapsulates the information needed by the
-* OpenSM to instantiate a subnet administrator. The OpenSM allocates
-* one SA object per subnet manager.
-*
-* The SA object is thread safe.
-*
-* This object should be treated as opaque and should
-* be manipulated only through the provided functions.
-*
-* AUTHOR
-* Ranjit Pandit, Intel
-* Anil Keshavamurthy, Intel
-*
-*********/
-/****d* OpenSM: SA/osm_sa_state_t
-* NAME
-* osm_sa_state_t
-*
-* DESCRIPTION
-* Enumerates the possible states of SA object.
-*
-* SYNOPSIS
-*/
-typedef enum _osm_sa_state {
- OSM_SA_STATE_INIT = 0,
- OSM_SA_STATE_READY
-} osm_sa_state_t;
-/***********/
-
-/****s* OpenSM: SM/osm_sa_t
-* NAME
-* osm_sa_t
-*
-* DESCRIPTION
-* Subnet Administration structure.
-*
-* This object should be treated as opaque and should
-* be manipulated only through the provided functions.
-*
-* SYNOPSIS
-*/
-typedef struct osm_sa {
- osm_sa_state_t state;
- osm_sm_t *sm;
- osm_subn_t *p_subn;
- osm_vendor_t *p_vendor;
- osm_log_t *p_log;
- osm_mad_pool_t *p_mad_pool;
- cl_dispatcher_t *p_disp;
- cl_plock_t *p_lock;
- atomic32_t sa_trans_id;
- osm_sa_mad_ctrl_t mad_ctrl;
- cl_timer_t sr_timer;
- cl_disp_reg_handle_t cpi_disp_h;
- cl_disp_reg_handle_t nr_disp_h;
- cl_disp_reg_handle_t pir_disp_h;
- cl_disp_reg_handle_t gir_disp_h;
- cl_disp_reg_handle_t lr_disp_h;
- cl_disp_reg_handle_t pr_disp_h;
- cl_disp_reg_handle_t smir_disp_h;
- cl_disp_reg_handle_t mcmr_disp_h;
- cl_disp_reg_handle_t sr_disp_h;
-#if defined (VENDOR_RMPP_SUPPORT) && defined (DUAL_SIDED_RMPP)
- cl_disp_reg_handle_t mpr_disp_h;
-#endif
- cl_disp_reg_handle_t infr_disp_h;
- cl_disp_reg_handle_t infir_disp_h;
- cl_disp_reg_handle_t vlarb_disp_h;
- cl_disp_reg_handle_t slvl_disp_h;
- cl_disp_reg_handle_t pkey_disp_h;
- cl_disp_reg_handle_t lft_disp_h;
- cl_disp_reg_handle_t sir_disp_h;
- cl_disp_reg_handle_t mft_disp_h;
-} osm_sa_t;
-/*
-* FIELDS
-* state
-* State of this SA object
-*
-* sm
-* Pointer to the Subnet Manager object.
-*
-* p_subn
-* Pointer to the Subnet object for this subnet.
-*
-* p_vendor
-* Pointer to the vendor specific interfaces object.
-*
-* p_log
-* Pointer to the log object.
-*
-* p_mad_pool
-* Pointer to the MAD pool.
-*
-* p_disp
-* Pointer to dispatcher
-*
-* p_lock
-* Pointer to Lock for serialization
-*
-* sa_trans_id
-* Transaction ID
-*
-* mad_ctrl
-* Mad Controller
-*
-* SEE ALSO
-* SM object
-*********/
-
-/****f* OpenSM: SA/osm_sa_construct
-* NAME
-* osm_sa_construct
-*
-* DESCRIPTION
-* This function constructs an SA object.
-*
-* SYNOPSIS
-*/
-void osm_sa_construct(IN osm_sa_t * const p_sa);
-/*
-* PARAMETERS
-* p_sa
-* [in] Pointer to a SA object to construct.
-*
-* RETURN VALUE
-* This function does not return a value.
-*
-* NOTES
-* Allows calling osm_sa_destroy.
-*
-* Calling osm_sa_construct is a prerequisite to calling any other
-* method except osm_sa_init.
-*
-* SEE ALSO
-* SA object, osm_sa_init, osm_sa_destroy
-*********/
-
-/****f* OpenSM: SA/osm_sa_shutdown
-* NAME
-* osm_sa_shutdown
-*
-* DESCRIPTION
-* The osm_sa_shutdown function shutdowns an SA, unregistering from all
-* dispatcher messages and unbinding the QP1 mad service
-*
-* SYNOPSIS
-*/
-void osm_sa_shutdown(IN osm_sa_t * const p_sa);
-/*
-* PARAMETERS
-* p_sa
-* [in] Pointer to a SA object to shutdown.
-*
-* RETURN VALUE
-* This function does not return a value.
-*
-* SEE ALSO
-* SA object, osm_sa_construct, osm_sa_init
-*********/
-
-/****f* OpenSM: SA/osm_sa_destroy
-* NAME
-* osm_sa_destroy
-*
-* DESCRIPTION
-* The osm_sa_destroy function destroys an SA, releasing
-* all resources.
-*
-* SYNOPSIS
-*/
-void osm_sa_destroy(IN osm_sa_t * const p_sa);
-/*
-* PARAMETERS
-* p_sa
-* [in] Pointer to a SA object to destroy.
-*
-* RETURN VALUE
-* This function does not return a value.
-*
-* NOTES
-* Performs any necessary cleanup of the specified SA object.
-* Further operations should not be attempted on the destroyed object.
-* This function should only be called after a call to osm_sa_construct or
-* osm_sa_init.
-*
-* SEE ALSO
-* SA object, osm_sa_construct, osm_sa_init
-*********/
-
-/****f* OpenSM: SA/osm_sa_init
-* NAME
-* osm_sa_init
-*
-* DESCRIPTION
-* The osm_sa_init function initializes a SA object for use.
-*
-* SYNOPSIS
-*/
-ib_api_status_t osm_sa_init(IN osm_sm_t * const p_sm,
- IN osm_sa_t * const p_sa,
- IN osm_subn_t * const p_subn,
- IN osm_vendor_t * const p_vendor,
- IN osm_mad_pool_t * const p_mad_pool,
- IN osm_log_t * const p_log,
- IN osm_stats_t * const p_stats,
- IN cl_dispatcher_t * const p_disp,
- IN cl_plock_t * const p_lock);
-/*
-* PARAMETERS
-* p_sa
-* [in] Pointer to an osm_sa_t object to initialize.
-*
-* p_subn
-* [in] Pointer to the Subnet object for this subnet.
-*
-* p_vendor
-* [in] Pointer to the vendor specific interfaces object.
-*
-* p_mad_pool
-* [in] Pointer to the MAD pool.
-*
-* p_log
-* [in] Pointer to the log object.
-*
-* p_stats
-* [in] Pointer to the statistics object.
-*
-* p_disp
-* [in] Pointer to the OpenSM central Dispatcher.
-*
-* p_lock
-* [in] Pointer to the OpenSM serializing lock.
-*
-* RETURN VALUES
-* CL_SUCCESS if the SA object was initialized successfully.
-*
-* NOTES
-* Allows calling other SA methods.
-*
-* SEE ALSO
-* SA object, osm_sa_construct, osm_sa_destroy
-*********/
-
-/****f* OpenSM: SA/osm_sa_bind
-* NAME
-* osm_sa_bind
-*
-* DESCRIPTION
-* Binds the SA object to a port guid.
-*
-* SYNOPSIS
-*/
-ib_api_status_t
-osm_sa_bind(IN osm_sa_t * const p_sa, IN const ib_net64_t port_guid);
-/*
-* PARAMETERS
-* p_sa
-* [in] Pointer to an osm_sa_t object to bind.
-*
-* port_guid
-* [in] Local port GUID with which to bind.
-*
-*
-* RETURN VALUES
-* None
-*
-* NOTES
-* A given SA object can only be bound to one port at a time.
-*
-* SEE ALSO
-*********/
-
-/****f* OpenSM: SA/osm_sa_send
-* NAME
-* osm_sa_send
-*
-* DESCRIPTION
-* Sends SA MAD via osm_vendor_send and maintains the QP1 sent statistic
-*
-* SYNOPSIS
-*/
-ib_api_status_t osm_sa_send(osm_sa_t *sa, IN osm_madw_t * const p_madw,
- IN boolean_t const resp_expected);
-
-/****f* IBA Base: Types/osm_sa_send_error
-* NAME
-* osm_sa_send_error
-*
-* DESCRIPTION
-* Sends a generic SA response with the specified error status.
-* The payload is simply replicated from the request MAD.
-*
-* SYNOPSIS
-*/
-void osm_sa_send_error(IN osm_sa_t * sa, IN const osm_madw_t * const p_madw,
- IN const ib_net16_t sa_status);
-/*
-* PARAMETERS
-* sa
-* [in] Pointer to an osm_sa_t object.
-*
-* p_madw
-* [in] Original MAD to which the response must be sent.
-*
-* sa_status
-* [in] Status to send in the response.
-*
-* RETURN VALUES
-* None.
-*
-* SEE ALSO
-* SA object
-*********/
-
-/****f* OpenSM: SA/osm_sa_respond
-* NAME
-* osm_sa_respond
-*
-* DESCRIPTION
-* Sends SA MAD response
-*/
-void osm_sa_respond(osm_sa_t *sa, osm_madw_t *madw, size_t attr_size,
- cl_qlist_t *list);
-/*
-* PARAMETERS
-* sa
-* [in] Pointer to an osm_sa_t object.
-*
-* p_madw
-* [in] Original MAD to which the response must be sent.
-*
-* attr_size
-* [in] Size of this SA attribute.
-*
-* list
-* [in] List of attribute to respond - it will be freed after
-* sending.
-*
-* RETURN VALUES
-* None.
-*
-* SEE ALSO
-* SA object
-*********/
-
-struct osm_opensm;
-/****f* OpenSM: SA/osm_sa_db_file_dump
-* NAME
-* osm_sa_db_file_dump
-*
-* DESCRIPTION
-* Dumps the SA DB to the dump file.
-*
-* SYNOPSIS
-*/
-int osm_sa_db_file_dump(struct osm_opensm *p_osm);
-/*
-* PARAMETERS
-* p_osm
-* [in] Pointer to an osm_opensm_t object.
-*
-* RETURN VALUES
-* None
-*
-*********/
-
-/****f* OpenSM: SA/osm_sa_db_file_load
-* NAME
-* osm_sa_db_file_load
-*
-* DESCRIPTION
-* Loads SA DB from the file.
-*
-* SYNOPSIS
-*/
-int osm_sa_db_file_load(struct osm_opensm *p_osm);
-/*
-* PARAMETERS
-* p_osm
-* [in] Pointer to an osm_opensm_t object.
-*
-* RETURN VALUES
-* 0 on success, other value on failure.
-*
-*********/
-
-/****f* OpenSM: MC Member Record Receiver/osm_mcmr_rcv_find_or_create_new_mgrp
-* NAME
-* osm_mcmr_rcv_find_or_create_new_mgrp
-*
-* DESCRIPTION
-* Create new Multicast group
-*
-* SYNOPSIS
-*/
-
-ib_api_status_t
-osm_mcmr_rcv_find_or_create_new_mgrp(IN osm_sa_t * sa,
- IN uint64_t comp_mask,
- IN ib_member_rec_t *
- const p_recvd_mcmember_rec,
- OUT osm_mgrp_t ** pp_mgrp);
-/*
-* PARAMETERS
-* p_sa
-* [in] Pointer to an osm_sa_t object.
-* p_recvd_mcmember_rec
-* [in] Received Multicast member record
-*
-* pp_mgrp
-* [out] pointer the osm_mgrp_t object
-*
-* RETURN VALUES
-* IB_SUCCESS, IB_ERROR
-*
-*********/
-
-osm_mgrp_t *osm_get_mgrp_by_mgid(IN osm_sa_t * sa, IN ib_gid_t * p_mgid);
-
-END_C_DECLS
-#endif /* _OSM_SA_H_ */
diff --git a/contrib/ofed/management/opensm/include/opensm/osm_sa_mad_ctrl.h b/contrib/ofed/management/opensm/include/opensm/osm_sa_mad_ctrl.h
deleted file mode 100644
index cc2ac53..0000000
--- a/contrib/ofed/management/opensm/include/opensm/osm_sa_mad_ctrl.h
+++ /dev/null
@@ -1,338 +0,0 @@
-/*
- * Copyright (c) 2004-2008 Voltaire, Inc. All rights reserved.
- * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved.
- * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- */
-
-/*
- * Abstract:
- * Declaration of osm_sa_mad_ctrl_t.
- * This object represents a controller that receives the IBA SA
- * attributes from a node.
- * This object is part of the OpenSM family of objects.
- */
-
-#ifndef _OSM_SA_MAD_CTRL_H_
-#define _OSM_SA_MAD_CTRL_H_
-
-#include <complib/cl_dispatcher.h>
-#include <opensm/osm_stats.h>
-#include <opensm/osm_subnet.h>
-#include <opensm/osm_madw.h>
-#include <opensm/osm_mad_pool.h>
-#include <opensm/osm_log.h>
-
-#ifdef __cplusplus
-# define BEGIN_C_DECLS extern "C" {
-# define END_C_DECLS }
-#else /* !__cplusplus */
-# define BEGIN_C_DECLS
-# define END_C_DECLS
-#endif /* __cplusplus */
-
-BEGIN_C_DECLS
-/****h* OpenSM/SA MAD Controller
-* NAME
-* SA MAD Controller
-*
-* DESCRIPTION
-* The SA MAD Controller object encapsulates
-* the information needed to receive MADs from the transport layer.
-*
-* The SA MAD Controller object is thread safe.
-*
-* This object should be treated as opaque and should be
-* manipulated only through the provided functions.
-*
-* AUTHOR
-* Ranjit Pandit, Intel
-*
-*********/
-
-struct osm_sa;
-/****s* OpenSM: SA MAD Controller/osm_sa_mad_ctrl_t
-* NAME
-* osm_sa_mad_ctrl_t
-*
-* DESCRIPTION
-* SA MAD Controller structure.
-*
-* This object should be treated as opaque and should
-* be manipulated only through the provided functions.
-*
-* SYNOPSIS
-*/
-typedef struct osm_sa_mad_ctrl {
- struct osm_sa *sa;
- osm_log_t *p_log;
- osm_mad_pool_t *p_mad_pool;
- osm_vendor_t *p_vendor;
- osm_bind_handle_t h_bind;
- cl_dispatcher_t *p_disp;
- cl_disp_reg_handle_t h_disp;
- osm_stats_t *p_stats;
- osm_subn_t *p_subn;
-} osm_sa_mad_ctrl_t;
-/*
-* FIELDS
-* sa
-* Pointer to the SA object.
-*
-* p_log
-* Pointer to the log object.
-*
-* p_mad_pool
-* Pointer to the MAD pool.
-*
-* p_vendor
-* Pointer to the vendor specific interfaces object.
-*
-* h_bind
-* Bind handle returned by the transport layer.
-*
-* p_disp
-* Pointer to the Dispatcher.
-*
-* h_disp
-* Handle returned from dispatcher registration.
-*
-* p_stats
-* Pointer to the OpenSM statistics block.
-*
-* SEE ALSO
-* SA MAD Controller object
-* SA MADr object
-*********/
-
-/****f* OpenSM: SA MAD Controller/osm_sa_mad_ctrl_construct
-* NAME
-* osm_sa_mad_ctrl_construct
-*
-* DESCRIPTION
-* This function constructs a SA MAD Controller object.
-*
-* SYNOPSIS
-*/
-void osm_sa_mad_ctrl_construct(IN osm_sa_mad_ctrl_t * const p_ctrl);
-/*
-* PARAMETERS
-* p_ctrl
-* [in] Pointer to a SA MAD Controller
-* object to construct.
-*
-* RETURN VALUE
-* This function does not return a value.
-*
-* NOTES
-* Allows calling osm_sa_mad_ctrl_init, and osm_sa_mad_ctrl_destroy.
-*
-* Calling osm_sa_mad_ctrl_construct is a prerequisite to calling any other
-* method except osm_sa_mad_ctrl_init.
-*
-* SEE ALSO
-* SA MAD Controller object, osm_sa_mad_ctrl_init,
-* osm_sa_mad_ctrl_destroy
-*********/
-
-/****f* OpenSM: SA MAD Controller/osm_sa_mad_ctrl_destroy
-* NAME
-* osm_sa_mad_ctrl_destroy
-*
-* DESCRIPTION
-* The osm_sa_mad_ctrl_destroy function destroys the object, releasing
-* all resources.
-*
-* SYNOPSIS
-*/
-void osm_sa_mad_ctrl_destroy(IN osm_sa_mad_ctrl_t * const p_ctrl);
-/*
-* PARAMETERS
-* p_ctrl
-* [in] Pointer to the object to destroy.
-*
-* RETURN VALUE
-* This function does not return a value.
-*
-* NOTES
-* Performs any necessary cleanup of the specified
-* SA MAD Controller object.
-* Further operations should not be attempted on the destroyed object.
-* This function should only be called after a call to
-* osm_sa_mad_ctrl_construct or osm_sa_mad_ctrl_init.
-*
-* SEE ALSO
-* SA MAD Controller object, osm_sa_mad_ctrl_construct,
-* osm_sa_mad_ctrl_init
-*********/
-
-/****f* OpenSM: SA MAD Controller/osm_sa_mad_ctrl_init
-* NAME
-* osm_sa_mad_ctrl_init
-*
-* DESCRIPTION
-* The osm_sa_mad_ctrl_init function initializes a
-* SA MAD Controller object for use.
-*
-* SYNOPSIS
-*/
-ib_api_status_t osm_sa_mad_ctrl_init(IN osm_sa_mad_ctrl_t * const p_ctrl,
- IN struct osm_sa * sa,
- IN osm_mad_pool_t * const p_mad_pool,
- IN osm_vendor_t * const p_vendor,
- IN osm_subn_t * const p_subn,
- IN osm_log_t * const p_log,
- IN osm_stats_t * const p_stats,
- IN cl_dispatcher_t * const p_disp);
-/*
-* PARAMETERS
-* p_ctrl
-* [in] Pointer to an osm_sa_mad_ctrl_t object to initialize.
-*
-* sa
-* [in] Pointer to the SA object.
-*
-* p_mad_pool
-* [in] Pointer to the MAD pool.
-*
-* p_vendor
-* [in] Pointer to the vendor specific interfaces object.
-*
-* p_log
-* [in] Pointer to the log object.
-*
-* p_stats
-* [in] Pointer to the OpenSM stastics block.
-*
-* p_disp
-* [in] Pointer to the OpenSM central Dispatcher.
-*
-* RETURN VALUES
-* IB_SUCCESS if the SA MAD Controller object was initialized
-* successfully.
-*
-* NOTES
-* Allows calling other SA MAD Controller methods.
-*
-* SEE ALSO
-* SA MAD Controller object, osm_sa_mad_ctrl_construct,
-* osm_sa_mad_ctrl_destroy
-*********/
-
-/****f* OpenSM: SA/osm_sa_mad_ctrl_bind
-* NAME
-* osm_sa_mad_ctrl_bind
-*
-* DESCRIPTION
-* Binds the SA MAD Controller object to a port guid.
-*
-* SYNOPSIS
-*/
-ib_api_status_t
-osm_sa_mad_ctrl_bind(IN osm_sa_mad_ctrl_t * const p_ctrl,
- IN const ib_net64_t port_guid);
-/*
-* PARAMETERS
-* p_ctrl
-* [in] Pointer to an osm_sa_mad_ctrl_t object to initialize.
-*
-* port_guid
-* [in] Local port GUID with which to bind.
-*
-*
-* RETURN VALUES
-* None
-*
-* NOTES
-* A given SA MAD Controller object can only be bound to one
-* port at a time.
-*
-* SEE ALSO
-*********/
-
-/****f* OpenSM: SA/osm_sa_mad_ctrl_unbind
-* NAME
-* osm_sa_mad_ctrl_unbind
-*
-* DESCRIPTION
-* Un-Binds the SA MAD Controller object from the IB port
-*
-* SYNOPSIS
-*/
-ib_api_status_t osm_sa_mad_ctrl_unbind(IN osm_sa_mad_ctrl_t * const p_ctrl);
-/*
-* PARAMETERS
-* p_ctrl
-* [in] Pointer to an osm_sa_mad_ctrl_t object to initialize.
-*
-* RETURN VALUES
-* None
-*
-* NOTES
-* A given SA MAD Controller should be previously bound to IB
-* port.
-*
-* SEE ALSO
-*********/
-
-/****f* OpenSM: SA/osm_sa_mad_ctrl_get_bind_handle
-* NAME
-* osm_sa_mad_ctrl_get_bind_handle
-*
-* DESCRIPTION
-* Returns the bind handle.
-*
-* SYNOPSIS
-*/
-static inline osm_bind_handle_t
-osm_sa_mad_ctrl_get_bind_handle(IN const osm_sa_mad_ctrl_t * const p_ctrl)
-{
- return (p_ctrl->h_bind);
-}
-
-/*
-* PARAMETERS
-* p_ctrl
-* [in] Pointer to an osm_sa_mad_ctrl_t object.
-*
-* RETURN VALUES
-* Returns the bind handle, which may be OSM_BIND_INVALID_HANDLE
-* if no port has been bound.
-*
-* NOTES
-* A given SA MAD Controller object can only be bound to one
-* port at a time.
-*
-* SEE ALSO
-*********/
-
-END_C_DECLS
-#endif /* _OSM_SA_MAD_CTRL_H_ */
diff --git a/contrib/ofed/management/opensm/include/opensm/osm_service.h b/contrib/ofed/management/opensm/include/opensm/osm_service.h
deleted file mode 100644
index 1d97a68..0000000
--- a/contrib/ofed/management/opensm/include/opensm/osm_service.h
+++ /dev/null
@@ -1,194 +0,0 @@
-/*
- * Copyright (c) 2004-2007 Voltaire, Inc. All rights reserved.
- * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved.
- * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- */
-
-#ifndef _OSM_SVCR_H_
-#define _OSM_SVCR_H_
-
-/*
- * Abstract:
- * Declaration of osm_service_rec_t.
- * This object represents an IBA Service Record.
- * This object is part of the OpenSM family of objects.
- */
-
-#include <iba/ib_types.h>
-#include <complib/cl_qmap.h>
-#include <complib/cl_spinlock.h>
-#include <opensm/osm_subnet.h>
-#include <opensm/osm_log.h>
-
-#ifdef __cplusplus
-# define BEGIN_C_DECLS extern "C" {
-# define END_C_DECLS }
-#else /* !__cplusplus */
-# define BEGIN_C_DECLS
-# define END_C_DECLS
-#endif /* __cplusplus */
-
-BEGIN_C_DECLS
-/****h* OpenSM/Service Record
-* NAME
-* Service Record
-*
-* DESCRIPTION
-* The service record encapsulates the information needed by the
-* SA to manage service registrations.
-*
-* The service records is not thread safe, thus callers must provide
-* serialization.
-*
-* This object should be treated as opaque and should be
-* manipulated only through the provided functions.
-*
-* AUTHOR
-* Anil S Keshavamurthy, Intel
-*
-*********/
-/****s* OpenSM: Service Record/osm_svcr_t
-* NAME
-* osm_svcr_t
-*
-* DESCRIPTION
-* Service Record structure.
-*
-* The osm_svcr_t object should be treated as opaque and should
-* be manipulated only through the provided functions.
-*
-* SYNOPSIS
-*/
-typedef struct osm_svcr {
- cl_list_item_t list_item;
- ib_service_record_t service_record;
- uint32_t modified_time;
- uint32_t lease_period;
-} osm_svcr_t;
-/*
-* FIELDS
-* map_item
-* Map Item for qmap linkage. Must be first element!!
-*
-* svc_rec
-* IB Service record structure
-*
-* modified_time
-* Last modified time of this record in milliseconds
-*
-* lease_period
-* Remaining lease period for this record
-*
-*
-* SEE ALSO
-*********/
-
-/****f* OpenSM: Service Record/osm_svcr_new
-* NAME
-* osm_svcr_new
-*
-* DESCRIPTION
-* Allocates and initializes a Service Record for use.
-*
-* SYNOPSIS
-*/
-osm_svcr_t *osm_svcr_new(IN const ib_service_record_t * p_svc_rec);
-/*
-* PARAMETERS
-* p_svc_rec
-* [in] Pointer to IB Service Record
-*
-* RETURN VALUES
-* pointer to osm_svcr_t structure.
-*
-* NOTES
-* Allows calling other service record methods.
-*
-* SEE ALSO
-* Service Record, osm_svcr_delete
-*********/
-
-/****f* OpenSM: Service Record/osm_svcr_init
-* NAME
-* osm_svcr_init
-*
-* DESCRIPTION
-* Initializes the osm_svcr_t structure.
-*
-* SYNOPSIS
-*/
-void
-osm_svcr_init(IN osm_svcr_t * const p_svcr,
- IN const ib_service_record_t * p_svc_rec);
-/*
-* PARAMETERS
-* p_svc_rec
-* [in] Pointer to osm_svcr_t structure
-* p_svc_rec
-* [in] Pointer to the ib_service_record_t
-*
-* SEE ALSO
-* Service Record
-*********/
-
-/****f* OpenSM: Service Record/osm_svcr_delete
-* NAME
-* osm_svcr_delete
-*
-* DESCRIPTION
-* Deallocates the osm_svcr_t structure.
-*
-* SYNOPSIS
-*/
-void osm_svcr_delete(IN osm_svcr_t * const p_svcr);
-/*
-* PARAMETERS
-* p_svc_rec
-* [in] Pointer to osm_svcr_t structure
-*
-* SEE ALSO
-* Service Record, osm_svcr_new
-*********/
-
-osm_svcr_t *osm_svcr_get_by_rid(IN osm_subn_t const *p_subn,
- IN osm_log_t * p_log,
- IN ib_service_record_t * const p_svc_rec);
-
-void
-osm_svcr_insert_to_db(IN osm_subn_t * p_subn,
- IN osm_log_t * p_log, IN osm_svcr_t * p_svcr);
-void
-osm_svcr_remove_from_db(IN osm_subn_t * p_subn,
- IN osm_log_t * p_log, IN osm_svcr_t * p_svcr);
-
-END_C_DECLS
-#endif /* _OSM_SVCR_H_ */
diff --git a/contrib/ofed/management/opensm/include/opensm/osm_sm.h b/contrib/ofed/management/opensm/include/opensm/osm_sm.h
deleted file mode 100644
index ebe3dc3..0000000
--- a/contrib/ofed/management/opensm/include/opensm/osm_sm.h
+++ /dev/null
@@ -1,798 +0,0 @@
-/*
- * Copyright (c) 2004-2008 Voltaire, Inc. All rights reserved.
- * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved.
- * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- */
-
-/*
- * Abstract:
- * Declaration of osm_sm_t.
- * This object represents an IBA subnet.
- * This object is part of the OpenSM family of objects.
- */
-
-#ifndef _OSM_SM_H_
-#define _OSM_SM_H_
-
-#include <iba/ib_types.h>
-#include <complib/cl_passivelock.h>
-#include <complib/cl_event.h>
-#include <complib/cl_thread.h>
-#include <complib/cl_dispatcher.h>
-#include <complib/cl_event_wheel.h>
-#include <vendor/osm_vendor_api.h>
-#include <opensm/osm_stats.h>
-#include <opensm/osm_subnet.h>
-#include <opensm/osm_vl15intf.h>
-#include <opensm/osm_mad_pool.h>
-#include <opensm/osm_log.h>
-#include <opensm/osm_sm_mad_ctrl.h>
-#include <opensm/osm_lid_mgr.h>
-#include <opensm/osm_ucast_mgr.h>
-#include <opensm/osm_port.h>
-#include <opensm/osm_db.h>
-#include <opensm/osm_remote_sm.h>
-
-#ifdef __cplusplus
-# define BEGIN_C_DECLS extern "C" {
-# define END_C_DECLS }
-#else /* !__cplusplus */
-# define BEGIN_C_DECLS
-# define END_C_DECLS
-#endif /* __cplusplus */
-
-BEGIN_C_DECLS
-/****h* OpenSM/SM
-* NAME
-* SM
-*
-* DESCRIPTION
-* The SM object encapsulates the information needed by the
-* OpenSM to instantiate a subnet manager. The OpenSM allocates
-* one SM object per subnet manager.
-*
-* The SM object is thread safe.
-*
-* This object should be treated as opaque and should
-* be manipulated only through the provided functions.
-*
-* AUTHOR
-* Steve King, Intel
-*
-*********/
-/****s* OpenSM: SM/osm_sm_t
-* NAME
-* osm_sm_t
-*
-* DESCRIPTION
-* Subnet Manager structure.
-*
-* This object should be treated as opaque and should
-* be manipulated only through the provided functions.
-*
-* SYNOPSIS
-*/
-typedef struct osm_sm {
- osm_thread_state_t thread_state;
- unsigned signal_mask;
- cl_spinlock_t signal_lock;
- cl_spinlock_t state_lock;
- cl_event_t signal_event;
- cl_event_t subnet_up_event;
- cl_timer_t sweep_timer;
- cl_timer_t polling_timer;
- cl_event_wheel_t trap_aging_tracker;
- cl_thread_t sweeper;
- unsigned master_sm_found;
- uint32_t retry_number;
- ib_net64_t master_sm_guid;
- osm_remote_sm_t *p_polling_sm;
- osm_subn_t *p_subn;
- osm_db_t *p_db;
- osm_vendor_t *p_vendor;
- osm_log_t *p_log;
- osm_mad_pool_t *p_mad_pool;
- osm_vl15_t *p_vl15;
- cl_dispatcher_t *p_disp;
- cl_plock_t *p_lock;
- atomic32_t sm_trans_id;
- cl_spinlock_t mgrp_lock;
- cl_qlist_t mgrp_list;
- osm_sm_mad_ctrl_t mad_ctrl;
- osm_lid_mgr_t lid_mgr;
- osm_ucast_mgr_t ucast_mgr;
- cl_disp_reg_handle_t sweep_fail_disp_h;
- cl_disp_reg_handle_t ni_disp_h;
- cl_disp_reg_handle_t pi_disp_h;
- cl_disp_reg_handle_t nd_disp_h;
- cl_disp_reg_handle_t si_disp_h;
- cl_disp_reg_handle_t lft_disp_h;
- cl_disp_reg_handle_t mft_disp_h;
- cl_disp_reg_handle_t sm_info_disp_h;
- cl_disp_reg_handle_t trap_disp_h;
- cl_disp_reg_handle_t slvl_disp_h;
- cl_disp_reg_handle_t vla_disp_h;
- cl_disp_reg_handle_t pkey_disp_h;
-} osm_sm_t;
-/*
-* FIELDS
-* p_subn
-* Pointer to the Subnet object for this subnet.
-*
-* p_db
-* Pointer to the database (persistency) object
-*
-* p_vendor
-* Pointer to the vendor specific interfaces object.
-*
-* p_log
-* Pointer to the log object.
-*
-* p_mad_pool
-* Pointer to the MAD pool.
-*
-* p_vl15
-* Pointer to the VL15 interface.
-*
-* mad_ctrl
-* MAD Controller.
-*
-* p_disp
-* Pointer to the Dispatcher.
-*
-* p_lock
-* Pointer to the serializing lock.
-*
-* SEE ALSO
-* SM object
-*********/
-
-/****f* OpenSM: SM/osm_sm_construct
-* NAME
-* osm_sm_construct
-*
-* DESCRIPTION
-* This function constructs an SM object.
-*
-* SYNOPSIS
-*/
-void osm_sm_construct(IN osm_sm_t * const p_sm);
-/*
-* PARAMETERS
-* p_sm
-* [in] Pointer to a SM object to construct.
-*
-* RETURN VALUE
-* This function does not return a value.
-*
-* NOTES
-* Allows calling osm_sm_init, osm_sm_destroy
-*
-* Calling osm_sm_construct is a prerequisite to calling any other
-* method except osm_sm_init.
-*
-* SEE ALSO
-* SM object, osm_sm_init, osm_sm_destroy
-*********/
-
-/****f* OpenSM: SM/osm_sm_shutdown
-* NAME
-* osm_sm_shutdown
-*
-* DESCRIPTION
-* The osm_sm_shutdown function shutdowns an SM, stopping the sweeper
-* and unregistering all messages from the dispatcher
-*
-* SYNOPSIS
-*/
-void osm_sm_shutdown(IN osm_sm_t * const p_sm);
-/*
-* PARAMETERS
-* p_sm
-* [in] Pointer to a SM object to shutdown.
-*
-* RETURN VALUE
-* This function does not return a value.
-*
-* SEE ALSO
-* SM object, osm_sm_construct, osm_sm_init
-*********/
-
-/****f* OpenSM: SM/osm_sm_destroy
-* NAME
-* osm_sm_destroy
-*
-* DESCRIPTION
-* The osm_sm_destroy function destroys an SM, releasing
-* all resources.
-*
-* SYNOPSIS
-*/
-void osm_sm_destroy(IN osm_sm_t * const p_sm);
-/*
-* PARAMETERS
-* p_sm
-* [in] Pointer to a SM object to destroy.
-*
-* RETURN VALUE
-* This function does not return a value.
-*
-* NOTES
-* Performs any necessary cleanup of the specified SM object.
-* Further operations should not be attempted on the destroyed object.
-* This function should only be called after a call to osm_sm_construct or
-* osm_sm_init.
-*
-* SEE ALSO
-* SM object, osm_sm_construct, osm_sm_init
-*********/
-
-/****f* OpenSM: SM/osm_sm_init
-* NAME
-* osm_sm_init
-*
-* DESCRIPTION
-* The osm_sm_init function initializes a SM object for use.
-*
-* SYNOPSIS
-*/
-ib_api_status_t
-osm_sm_init(IN osm_sm_t * const p_sm,
- IN osm_subn_t * const p_subn,
- IN osm_db_t * const p_db,
- IN osm_vendor_t * const p_vendor,
- IN osm_mad_pool_t * const p_mad_pool,
- IN osm_vl15_t * const p_vl15,
- IN osm_log_t * const p_log,
- IN osm_stats_t * const p_stats,
- IN cl_dispatcher_t * const p_disp, IN cl_plock_t * const p_lock);
-/*
-* PARAMETERS
-* p_sm
-* [in] Pointer to an osm_sm_t object to initialize.
-*
-* p_subn
-* [in] Pointer to the Subnet object for this subnet.
-*
-* p_vendor
-* [in] Pointer to the vendor specific interfaces object.
-*
-* p_mad_pool
-* [in] Pointer to the MAD pool.
-*
-* p_vl15
-* [in] Pointer to the VL15 interface.
-*
-* p_log
-* [in] Pointer to the log object.
-*
-* p_stats
-* [in] Pointer to the statistics object.
-*
-* p_disp
-* [in] Pointer to the OpenSM central Dispatcher.
-*
-* p_lock
-* [in] Pointer to the OpenSM serializing lock.
-*
-* RETURN VALUES
-* IB_SUCCESS if the SM object was initialized successfully.
-*
-* NOTES
-* Allows calling other SM methods.
-*
-* SEE ALSO
-* SM object, osm_sm_construct, osm_sm_destroy
-*********/
-
-/****f* OpenSM: SM/osm_sm_signal
-* NAME
-* osm_sm_signal
-*
-* DESCRIPTION
-* Signal event to SM
-*
-* SYNOPSIS
-*/
-void osm_sm_signal(IN osm_sm_t * const p_sm, osm_signal_t signal);
-/*
-* PARAMETERS
-* p_sm
-* [in] Pointer to an osm_sm_t object.
-*
-* signal
-* [in] sm signal number.
-*
-* NOTES
-*
-* SEE ALSO
-* SM object
-*********/
-
-/****f* OpenSM: SM/osm_sm_sweep
-* NAME
-* osm_sm_sweep
-*
-* DESCRIPTION
-* Initiates a subnet sweep.
-*
-* SYNOPSIS
-*/
-void osm_sm_sweep(IN osm_sm_t * const p_sm);
-/*
-* PARAMETERS
-* p_sm
-* [in] Pointer to an osm_sm_t object.
-*
-* RETURN VALUES
-* IB_SUCCESS if the sweep completed successfully.
-*
-* NOTES
-*
-* SEE ALSO
-* SM object
-*********/
-
-/****f* OpenSM: SM/osm_sm_bind
-* NAME
-* osm_sm_bind
-*
-* DESCRIPTION
-* Binds the sm object to a port guid.
-*
-* SYNOPSIS
-*/
-ib_api_status_t
-osm_sm_bind(IN osm_sm_t * const p_sm, IN const ib_net64_t port_guid);
-/*
-* PARAMETERS
-* p_sm
-* [in] Pointer to an osm_sm_t object to bind.
-*
-* port_guid
-* [in] Local port GUID with which to bind.
-*
-*
-* RETURN VALUES
-* None
-*
-* NOTES
-* A given SM object can only be bound to one port at a time.
-*
-* SEE ALSO
-*********/
-
-/****f* OpenSM: SM/osm_req_get
-* NAME
-* osm_req_get
-*
-* DESCRIPTION
-* Starts the process to transmit a directed route request for
-* the attribute.
-*
-* SYNOPSIS
-*/
-ib_api_status_t
-osm_req_get(IN osm_sm_t * sm,
- IN const osm_dr_path_t * const p_path,
- IN const uint16_t attr_id,
- IN const uint32_t attr_mod,
- IN const cl_disp_msgid_t err_msg,
- IN const osm_madw_context_t * const p_context);
-/*
-* PARAMETERS
-* sm
-* [in] Pointer to an osm_sm_t object.
-*
-* p_path
-* [in] Pointer to the directed route path to the node
-* from which to retrieve the attribute.
-*
-* attr_id
-* [in] Attribute ID to request.
-*
-* attr_mod
-* [in] Attribute modifier for this request.
-*
-* err_msg
-* [in] Message id with which to post this MAD if an error occurs.
-*
-* p_context
-* [in] Mad wrapper context structure to be copied into the wrapper
-* context, and thus visible to the recipient of the response.
-*
-* RETURN VALUES
-* IB_SUCCESS if the request was successful.
-*
-* NOTES
-* This function asynchronously requests the specified attribute.
-* The response from the node will be routed through the Dispatcher
-* to the appropriate receive controller object.
-*********/
-/****f* OpenSM: SM/osm_req_set
-* NAME
-* osm_req_set
-*
-* DESCRIPTION
-* Starts the process to transmit a directed route Set() request.
-*
-* SYNOPSIS
-*/
-ib_api_status_t
-osm_req_set(IN osm_sm_t * sm,
- IN const osm_dr_path_t * const p_path,
- IN const uint8_t * const p_payload,
- IN const size_t payload_size,
- IN const uint16_t attr_id,
- IN const uint32_t attr_mod,
- IN const cl_disp_msgid_t err_msg,
- IN const osm_madw_context_t * const p_context);
-/*
-* PARAMETERS
-* sm
-* [in] Pointer to an osm_sm_t object.
-*
-* p_path
-* [in] Pointer to the directed route path of the recipient.
-*
-* p_payload
-* [in] Pointer to the SMP payload to send.
-*
-* payload_size
-* [in] The size of the payload to be copied to the SMP data field.
-*
-* attr_id
-* [in] Attribute ID to request.
-*
-* attr_mod
-* [in] Attribute modifier for this request.
-*
-* err_msg
-* [in] Message id with which to post this MAD if an error occurs.
-*
-* p_context
-* [in] Mad wrapper context structure to be copied into the wrapper
-* context, and thus visible to the recipient of the response.
-*
-* RETURN VALUES
-* IB_SUCCESS if the request was successful.
-*
-* NOTES
-* This function asynchronously requests the specified attribute.
-* The response from the node will be routed through the Dispatcher
-* to the appropriate receive controller object.
-*********/
-/****f* OpenSM: SM/osm_resp_send
-* NAME
-* osm_resp_send
-*
-* DESCRIPTION
-* Starts the process to transmit a directed route response.
-*
-* SYNOPSIS
-*/
-ib_api_status_t
-osm_resp_send(IN osm_sm_t * sm,
- IN const osm_madw_t * const p_req_madw,
- IN const ib_net16_t status, IN const uint8_t * const p_payload);
-/*
-* PARAMETERS
-* p_resp
-* [in] Pointer to an osm_resp_t object.
-*
-* p_madw
-* [in] Pointer to the MAD Wrapper object for the requesting MAD
-* to which this response is generated.
-*
-* status
-* [in] Status for this response.
-*
-* p_payload
-* [in] Pointer to the payload of the response MAD.
-*
-* RETURN VALUES
-* IB_SUCCESS if the response was successful.
-*
-*********/
-
-/****f* OpenSM: SM/osm_sm_mcgrp_join
-* NAME
-* osm_sm_mcgrp_join
-*
-* DESCRIPTION
-* Adds a port to the multicast group. Creates the multicast group
-* if necessary.
-*
-* This function is called by the SA.
-*
-* SYNOPSIS
-*/
-ib_api_status_t
-osm_sm_mcgrp_join(IN osm_sm_t * const p_sm,
- IN const ib_net16_t mlid,
- IN const ib_net64_t port_guid,
- IN osm_mcast_req_type_t req_type);
-/*
-* PARAMETERS
-* p_sm
-* [in] Pointer to an osm_sm_t object.
-*
-* mlid
-* [in] Multicast LID
-*
-* port_guid
-* [in] Port GUID to add to the group.
-*
-* req_type
-* [in] Type of the MC request that caused this join
-* (MC create/join).
-*
-* RETURN VALUES
-* None
-*
-* NOTES
-*
-* SEE ALSO
-*********/
-
-/****f* OpenSM: SM/osm_sm_mcgrp_leave
-* NAME
-* osm_sm_mcgrp_leave
-*
-* DESCRIPTION
-* Removes a port from the multicast group.
-*
-* This function is called by the SA.
-*
-* SYNOPSIS
-*/
-ib_api_status_t
-osm_sm_mcgrp_leave(IN osm_sm_t * const p_sm,
- IN const ib_net16_t mlid, IN const ib_net64_t port_guid);
-/*
-* PARAMETERS
-* p_sm
-* [in] Pointer to an osm_sm_t object.
-*
-* mlid
-* [in] Multicast LID
-*
-* port_guid
-* [in] Port GUID to remove from the group.
-*
-* RETURN VALUES
-* None
-*
-* NOTES
-*
-* SEE ALSO
-*********/
-
-/****f* OpenSM: OpenSM/osm_sm_wait_for_subnet_up
-* NAME
-* osm_sm_wait_for_subnet_up
-*
-* DESCRIPTION
-* Blocks the calling thread until the subnet is up.
-*
-* SYNOPSIS
-*/
-static inline cl_status_t
-osm_sm_wait_for_subnet_up(IN osm_sm_t * const p_sm,
- IN uint32_t const wait_us,
- IN boolean_t const interruptible)
-{
- return (cl_event_wait_on(&p_sm->subnet_up_event,
- wait_us, interruptible));
-}
-
-/*
-* PARAMETERS
-* p_sm
-* [in] Pointer to an osm_sm_t object.
-*
-* wait_us
-* [in] Number of microseconds to wait.
-*
-* interruptible
-* [in] Indicates whether the wait operation can be interrupted
-* by external signals.
-*
-* RETURN VALUES
-* CL_SUCCESS if the wait operation succeeded in response to the event
-* being set.
-*
-* CL_TIMEOUT if the specified time period elapses.
-*
-* CL_NOT_DONE if the wait was interrupted by an external signal.
-*
-* CL_ERROR if the wait operation failed.
-*
-* NOTES
-*
-* SEE ALSO
-*********/
-
-/****f* OpenSM: State Manager/osm_sm_is_greater_than
-* NAME
-* osm_sm_is_greater_than
-*
-* DESCRIPTION
-* Compares two SM's (14.4.1.2)
-*
-* SYNOPSIS
-*/
-static inline boolean_t
-osm_sm_is_greater_than(IN const uint8_t l_priority,
- IN const ib_net64_t l_guid,
- IN const uint8_t r_priority, IN const ib_net64_t r_guid)
-{
- return (l_priority > r_priority
- || (l_priority == r_priority
- && cl_ntoh64(l_guid) < cl_ntoh64(r_guid)));
-}
-
-/*
-* PARAMETERS
-* l_priority
-* [in] Priority of the SM on the "left"
-*
-* l_guid
-* [in] GUID of the SM on the "left"
-*
-* r_priority
-* [in] Priority of the SM on the "right"
-*
-* r_guid
-* [in] GUID of the SM on the "right"
-*
-* RETURN VALUES
-* Return TRUE if an sm with l_priority and l_guid is higher than an sm
-* with r_priority and r_guid, return FALSE otherwise.
-*
-* NOTES
-*
-* SEE ALSO
-* State Manager
-*********/
-
-/****f* OpenSM: SM State Manager/osm_sm_state_mgr_process
-* NAME
-* osm_sm_state_mgr_process
-*
-* DESCRIPTION
-* Processes and maintains the states of the SM.
-*
-* SYNOPSIS
-*/
-ib_api_status_t osm_sm_state_mgr_process(IN osm_sm_t *sm,
- IN osm_sm_signal_t signal);
-/*
-* PARAMETERS
-* sm
-* [in] Pointer to an osm_sm_t object.
-*
-* signal
-* [in] Signal to the state SM engine.
-*
-* RETURN VALUES
-* None.
-*
-* NOTES
-*
-* SEE ALSO
-* State Manager
-*********/
-
-/****f* OpenSM: SM State Manager/osm_sm_state_mgr_signal_master_is_alive
-* NAME
-* osm_sm_state_mgr_signal_master_is_alive
-*
-* DESCRIPTION
-* Signals that the remote Master SM is alive.
-* Need to clear the retry_number variable.
-*
-* SYNOPSIS
-*/
-void osm_sm_state_mgr_signal_master_is_alive(IN osm_sm_t *sm);
-/*
-* PARAMETERS
-* sm
-* [in] Pointer to an osm_sm_t object.
-*
-* RETURN VALUES
-* None.
-*
-* NOTES
-*
-* SEE ALSO
-* State Manager
-*********/
-
-/****f* OpenSM: SM State Manager/osm_sm_state_mgr_check_legality
-* NAME
-* osm_sm_state_mgr_check_legality
-*
-* DESCRIPTION
-* Checks the legality of the signal received, according to the
-* current state of the SM state machine.
-*
-* SYNOPSIS
-*/
-ib_api_status_t osm_sm_state_mgr_check_legality(IN osm_sm_t *sm,
- IN osm_sm_signal_t signal);
-/*
-* PARAMETERS
-* sm
-* [in] Pointer to an osm_sm_t object.
-*
-* signal
-* [in] Signal to the state SM engine.
-*
-* RETURN VALUES
-* None.
-*
-* NOTES
-*
-* SEE ALSO
-* State Manager
-*********/
-
-void osm_report_sm_state(osm_sm_t *sm);
-
-/****f* OpenSM: SM State Manager/osm_send_trap144
-* NAME
-* osm_send_trap144
-*
-* DESCRIPTION
-* Send trap 144 to the master SM.
-*
-* SYNOPSIS
-*/
-int osm_send_trap144(osm_sm_t *sm, ib_net16_t local);
-/*
-* PARAMETERS
-* sm
-* [in] Pointer to an osm_sm_t object.
-*
-* local
-* [in] OtherLocalChanges mask in network byte order.
-*
-* RETURN VALUES
-* 0 on success, non-zero value otherwise.
-*
-*********/
-
-void osm_set_sm_priority(osm_sm_t *sm, uint8_t priority);
-
-END_C_DECLS
-#endif /* _OSM_SM_H_ */
diff --git a/contrib/ofed/management/opensm/include/opensm/osm_sm_mad_ctrl.h b/contrib/ofed/management/opensm/include/opensm/osm_sm_mad_ctrl.h
deleted file mode 100644
index 1c41168..0000000
--- a/contrib/ofed/management/opensm/include/opensm/osm_sm_mad_ctrl.h
+++ /dev/null
@@ -1,323 +0,0 @@
-/*
- * Copyright (c) 2004, 2005 Voltaire, Inc. All rights reserved.
- * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved.
- * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- */
-
-/*
- * Abstract:
- * Declaration of osm_sm_mad_ctrl_t.
- * This object represents a controller that receives the IBA NodeInfo
- * attribute from a node.
- * This object is part of the OpenSM family of objects.
- */
-
-#ifndef _OSM_SM_MAD_CTRL_H_
-#define _OSM_SM_MAD_CTRL_H_
-
-#include <complib/cl_passivelock.h>
-#include <complib/cl_dispatcher.h>
-#include <opensm/osm_base.h>
-#include <opensm/osm_stats.h>
-#include <opensm/osm_madw.h>
-#include <opensm/osm_mad_pool.h>
-#include <opensm/osm_subnet.h>
-#include <opensm/osm_log.h>
-#include <opensm/osm_vl15intf.h>
-
-#ifdef __cplusplus
-# define BEGIN_C_DECLS extern "C" {
-# define END_C_DECLS }
-#else /* !__cplusplus */
-# define BEGIN_C_DECLS
-# define END_C_DECLS
-#endif /* __cplusplus */
-
-BEGIN_C_DECLS
-/****h* OpenSM/SM MAD Controller
-* NAME
-* SM MAD Controller
-*
-* DESCRIPTION
-* The SM MAD Controller object encapsulates
-* the information needed to receive MADs from the transport layer.
-*
-* The SM MAD Controller object is thread safe.
-*
-* This object should be treated as opaque and should be
-* manipulated only through the provided functions.
-*
-* AUTHOR
-* Steve King, Intel
-*
-*********/
-/****s* OpenSM: SM MAD Controller/osm_sm_mad_ctrl_t
-* NAME
-* osm_sm_mad_ctrl_t
-*
-* DESCRIPTION
-* SM MAD Controller structure.
-*
-* This object should be treated as opaque and should
-* be manipulated only through the provided functions.
-*
-* SYNOPSIS
-*/
-typedef struct osm_sm_mad_ctrl {
- osm_log_t *p_log;
- osm_subn_t *p_subn;
- osm_mad_pool_t *p_mad_pool;
- osm_vl15_t *p_vl15;
- osm_vendor_t *p_vendor;
- osm_bind_handle_t h_bind;
- cl_plock_t *p_lock;
- cl_dispatcher_t *p_disp;
- cl_disp_reg_handle_t h_disp;
- osm_stats_t *p_stats;
-} osm_sm_mad_ctrl_t;
-/*
-* FIELDS
-* p_log
-* Pointer to the log object.
-*
-* p_subn
-* Pointer to the subnet object.
-*
-* p_mad_pool
-* Pointer to the MAD pool.
-*
-* p_vendor
-* Pointer to the vendor specific interfaces object.
-*
-* h_bind
-* Bind handle returned by the transport layer.
-*
-* p_lock
-* Pointer to the serializing lock.
-*
-* p_disp
-* Pointer to the Dispatcher.
-*
-* h_disp
-* Handle returned from dispatcher registration.
-*
-* p_stats
-* Pointer to the OpenSM statistics block.
-*
-* SEE ALSO
-* SM MAD Controller object
-* SM MADr object
-*********/
-
-/****f* OpenSM: SM MAD Controller/osm_sm_mad_ctrl_construct
-* NAME
-* osm_sm_mad_ctrl_construct
-*
-* DESCRIPTION
-* This function constructs a SM MAD Controller object.
-*
-* SYNOPSIS
-*/
-void osm_sm_mad_ctrl_construct(IN osm_sm_mad_ctrl_t * const p_ctrl);
-/*
-* PARAMETERS
-* p_ctrl
-* [in] Pointer to a SM MAD Controller
-* object to construct.
-*
-* RETURN VALUE
-* This function does not return a value.
-*
-* NOTES
-* Allows calling osm_sm_mad_ctrl_init, and osm_sm_mad_ctrl_destroy.
-*
-* Calling osm_sm_mad_ctrl_construct is a prerequisite to calling any other
-* method except osm_sm_mad_ctrl_init.
-*
-* SEE ALSO
-* SM MAD Controller object, osm_sm_mad_ctrl_init,
-* osm_sm_mad_ctrl_destroy
-*********/
-
-/****f* OpenSM: SM MAD Controller/osm_sm_mad_ctrl_destroy
-* NAME
-* osm_sm_mad_ctrl_destroy
-*
-* DESCRIPTION
-* The osm_sm_mad_ctrl_destroy function destroys the object, releasing
-* all resources.
-*
-* SYNOPSIS
-*/
-void osm_sm_mad_ctrl_destroy(IN osm_sm_mad_ctrl_t * const p_ctrl);
-/*
-* PARAMETERS
-* p_ctrl
-* [in] Pointer to the object to destroy.
-*
-* RETURN VALUE
-* This function does not return a value.
-*
-* NOTES
-* Performs any necessary cleanup of the specified
-* SM MAD Controller object.
-* Further operations should not be attempted on the destroyed object.
-* This function should only be called after a call to
-* osm_sm_mad_ctrl_construct or osm_sm_mad_ctrl_init.
-*
-* SEE ALSO
-* SM MAD Controller object, osm_sm_mad_ctrl_construct,
-* osm_sm_mad_ctrl_init
-*********/
-
-/****f* OpenSM: SM MAD Controller/osm_sm_mad_ctrl_init
-* NAME
-* osm_sm_mad_ctrl_init
-*
-* DESCRIPTION
-* The osm_sm_mad_ctrl_init function initializes a
-* SM MAD Controller object for use.
-*
-* SYNOPSIS
-*/
-ib_api_status_t
-osm_sm_mad_ctrl_init(IN osm_sm_mad_ctrl_t * const p_ctrl,
- IN osm_subn_t * const p_subn,
- IN osm_mad_pool_t * const p_mad_pool,
- IN osm_vl15_t * const p_vl15,
- IN osm_vendor_t * const p_vendor,
- IN osm_log_t * const p_log,
- IN osm_stats_t * const p_stats,
- IN cl_plock_t * const p_lock,
- IN cl_dispatcher_t * const p_disp);
-/*
-* PARAMETERS
-* p_ctrl
-* [in] Pointer to an osm_sm_mad_ctrl_t object to initialize.
-*
-* p_mad_pool
-* [in] Pointer to the MAD pool.
-*
-* p_vl15
-* [in] Pointer to the VL15 interface object.
-*
-* p_vendor
-* [in] Pointer to the vendor specific interfaces object.
-*
-* p_log
-* [in] Pointer to the log object.
-*
-* p_stats
-* [in] Pointer to the OpenSM stastics block.
-*
-* p_lock
-* [in] Pointer to the OpenSM serializing lock.
-*
-* p_disp
-* [in] Pointer to the OpenSM central Dispatcher.
-*
-* RETURN VALUES
-* IB_SUCCESS if the SM MAD Controller object was initialized
-* successfully.
-*
-* NOTES
-* Allows calling other SM MAD Controller methods.
-*
-* SEE ALSO
-* SM MAD Controller object, osm_sm_mad_ctrl_construct,
-* osm_sm_mad_ctrl_destroy
-*********/
-
-/****f* OpenSM: SM/osm_sm_mad_ctrl_bind
-* NAME
-* osm_sm_mad_ctrl_bind
-*
-* DESCRIPTION
-* Binds the SM MAD Controller object to a port guid.
-*
-* SYNOPSIS
-*/
-ib_api_status_t
-osm_sm_mad_ctrl_bind(IN osm_sm_mad_ctrl_t * const p_ctrl,
- IN const ib_net64_t port_guid);
-/*
-* PARAMETERS
-* p_ctrl
-* [in] Pointer to an osm_sm_mad_ctrl_t object to initialize.
-*
-* port_guid
-* [in] Local port GUID with which to bind.
-*
-*
-* RETURN VALUES
-* None
-*
-* NOTES
-* A given SM MAD Controller object can only be bound to one
-* port at a time.
-*
-* SEE ALSO
-*********/
-
-/****f* OpenSM: SM/osm_sm_mad_ctrl_get_bind_handle
-* NAME
-* osm_sm_mad_ctrl_get_bind_handle
-*
-* DESCRIPTION
-* Returns the bind handle.
-*
-* SYNOPSIS
-*/
-static inline osm_bind_handle_t
-osm_sm_mad_ctrl_get_bind_handle(IN const osm_sm_mad_ctrl_t * const p_ctrl)
-{
- return (p_ctrl->h_bind);
-}
-
-/*
-* PARAMETERS
-* p_ctrl
-* [in] Pointer to an osm_sm_mad_ctrl_t object.
-*
-* RETURN VALUES
-* Returns the bind handle, which may be OSM_BIND_INVALID_HANDLE
-* if no port has been bound.
-*
-* NOTES
-* A given SM MAD Controller object can only be bound to one
-* port at a time.
-*
-* SEE ALSO
-*********/
-
-END_C_DECLS
-#endif /* _OSM_SM_MAD_CTRL_H_ */
diff --git a/contrib/ofed/management/opensm/include/opensm/osm_subnet.h b/contrib/ofed/management/opensm/include/opensm/osm_subnet.h
deleted file mode 100644
index d97d5f4..0000000
--- a/contrib/ofed/management/opensm/include/opensm/osm_subnet.h
+++ /dev/null
@@ -1,1106 +0,0 @@
-/*
- * Copyright (c) 2004-2008 Voltaire, Inc. All rights reserved.
- * Copyright (c) 2002-2008 Mellanox Technologies LTD. All rights reserved.
- * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
- * Copyright (c) 2008 Xsigo Systems Inc. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- */
-
-/*
- * Abstract:
- * Declaration of osm_subn_t.
- * This object represents an IBA subnet.
- * This object is part of the OpenSM family of objects.
- */
-
-#ifndef _OSM_SUBNET_H_
-#define _OSM_SUBNET_H_
-
-#include <iba/ib_types.h>
-#include <complib/cl_qmap.h>
-#include <complib/cl_map.h>
-#include <complib/cl_ptr_vector.h>
-#include <complib/cl_list.h>
-#include <opensm/osm_base.h>
-#include <opensm/osm_prefix_route.h>
-#include <stdio.h>
-
-#ifdef __cplusplus
-# define BEGIN_C_DECLS extern "C" {
-# define END_C_DECLS }
-#else /* !__cplusplus */
-# define BEGIN_C_DECLS
-# define END_C_DECLS
-#endif /* __cplusplus */
-
-BEGIN_C_DECLS
-#define OSM_SUBNET_VECTOR_MIN_SIZE 0
-#define OSM_SUBNET_VECTOR_GROW_SIZE 1
-#define OSM_SUBNET_VECTOR_CAPACITY 256
-struct osm_opensm;
-struct osm_qos_policy;
-
-/****h* OpenSM/Subnet
-* NAME
-* Subnet
-*
-* DESCRIPTION
-* The Subnet object encapsulates the information needed by the
-* OpenSM to manage a subnet. The OpenSM allocates one Subnet object
-* per IBA subnet.
-*
-* The Subnet object is not thread safe, thus callers must provide
-* serialization.
-*
-* This object is essentially a container for the various components
-* of a subnet. Callers may directly access the member variables.
-*
-* AUTHOR
-* Steve King, Intel
-*
-*********/
-
-/****s* OpenSM: Subnet/osm_qos_options_t
-* NAME
-* osm_qos_options_t
-*
-* DESCRIPTION
-* Subnet QoS options structure. This structure contains the various
-* QoS specific configuration parameters for the subnet.
-*
-* SYNOPSIS
-*/
-typedef struct osm_qos_options {
- unsigned max_vls;
- int high_limit;
- char *vlarb_high;
- char *vlarb_low;
- char *sl2vl;
-} osm_qos_options_t;
-/*
-* FIELDS
-*
-* max_vls
-* The number of maximum VLs on the Subnet (0 == use default)
-*
-* high_limit
-* The limit of High Priority component of VL Arbitration
-* table (IBA 7.6.9) (-1 == use default)
-*
-* vlarb_high
-* High priority VL Arbitration table template. (NULL == use default)
-*
-* vlarb_low
-* Low priority VL Arbitration table template. (NULL == use default)
-*
-* sl2vl
-* SL2VL Mapping table (IBA 7.6.6) template. (NULL == use default)
-*
-*********/
-
-/****s* OpenSM: Subnet/osm_subn_opt_t
-* NAME
-* osm_subn_opt_t
-*
-* DESCRIPTION
-* Subnet options structure. This structure contains the various
-* site specific configuration parameters for the subnet.
-*
-* SYNOPSIS
-*/
-typedef struct osm_subn_opt {
- char *config_file;
- ib_net64_t guid;
- ib_net64_t m_key;
- ib_net64_t sm_key;
- ib_net64_t sa_key;
- ib_net64_t subnet_prefix;
- ib_net16_t m_key_lease_period;
- uint32_t sweep_interval;
- uint32_t max_wire_smps;
- uint32_t transaction_timeout;
- uint8_t sm_priority;
- uint8_t lmc;
- boolean_t lmc_esp0;
- uint8_t max_op_vls;
- uint8_t force_link_speed;
- boolean_t reassign_lids;
- boolean_t ignore_other_sm;
- boolean_t single_thread;
- boolean_t disable_multicast;
- boolean_t force_log_flush;
- uint8_t subnet_timeout;
- uint8_t packet_life_time;
- uint8_t vl_stall_count;
- uint8_t leaf_vl_stall_count;
- uint8_t head_of_queue_lifetime;
- uint8_t leaf_head_of_queue_lifetime;
- uint8_t local_phy_errors_threshold;
- uint8_t overrun_errors_threshold;
- uint32_t sminfo_polling_timeout;
- uint32_t polling_retry_number;
- uint32_t max_msg_fifo_timeout;
- boolean_t force_heavy_sweep;
- uint8_t log_flags;
- char *dump_files_dir;
- char *log_file;
- unsigned long log_max_size;
- char *partition_config_file;
- boolean_t no_partition_enforcement;
- boolean_t qos;
- char *qos_policy_file;
- boolean_t accum_log_file;
- char *console;
- uint16_t console_port;
- char *port_prof_ignore_file;
- boolean_t port_profile_switch_nodes;
- boolean_t sweep_on_trap;
- char *routing_engine_names;
- boolean_t use_ucast_cache;
- boolean_t connect_roots;
- char *lid_matrix_dump_file;
- char *lfts_file;
- char *root_guid_file;
- char *cn_guid_file;
- char *ids_guid_file;
- char *guid_routing_order_file;
- char *sa_db_file;
- boolean_t exit_on_fatal;
- boolean_t honor_guid2lid_file;
- boolean_t daemon;
- boolean_t sm_inactive;
- boolean_t babbling_port_policy;
- osm_qos_options_t qos_options;
- osm_qos_options_t qos_ca_options;
- osm_qos_options_t qos_sw0_options;
- osm_qos_options_t qos_swe_options;
- osm_qos_options_t qos_rtr_options;
- boolean_t enable_quirks;
- boolean_t no_clients_rereg;
-#ifdef ENABLE_OSM_PERF_MGR
- boolean_t perfmgr;
- boolean_t perfmgr_redir;
- uint16_t perfmgr_sweep_time_s;
- uint32_t perfmgr_max_outstanding_queries;
- char *event_db_dump_file;
-#endif /* ENABLE_OSM_PERF_MGR */
- char *event_plugin_name;
- char *node_name_map_name;
- char *prefix_routes_file;
- boolean_t consolidate_ipv6_snm_req;
-} osm_subn_opt_t;
-/*
-* FIELDS
-*
-* config_file
-* The name of the config file.
-*
-* guid
-* The port guid that the SM is binding to.
-*
-* m_key
-* M_Key value sent to all ports qualifying all Set(PortInfo).
-*
-* sm_key
-* SM_Key value of the SM used for SM authentication.
-*
-* sa_key
-* SM_Key value to qualify rcv SA queries as "trusted".
-*
-* subnet_prefix
-* Subnet prefix used on this subnet.
-*
-* m_key_lease_period
-* The lease period used for the M_Key on this subnet.
-*
-* sweep_interval
-* The number of seconds between subnet sweeps. A value of 0
-* disables sweeping.
-*
-* max_wire_smps
-* The maximum number of SMPs sent in parallel. Default is 4.
-*
-* transaction_timeout
-* The maximum time in milliseconds allowed for a transaction
-* to complete. Default is 200.
-*
-* sm_priority
-* The priority of this SM as specified by the user. This
-* value is made available in the SMInfo attribute.
-*
-* lmc
-* The LMC value used on this subnet.
-*
-* lmc_esp0
-* Whether LMC value used on subnet should be used for
-* enhanced switch port 0 or not. If TRUE, it is used.
-* Otherwise (the default), LMC is set to 0 for ESP0.
-*
-* max_op_vls
-* Limit the maximal operational VLs. default is 1.
-*
-* reassign_lids
-* If TRUE cause all lids to be re-assigend.
-* Otherwise (the default),
-* OpenSM always tries to preserve as LIDs as much as possible.
-*
-* ignore_other_sm_option
-* This flag is TRUE if other SMs on the subnet should be ignored.
-*
-* disable_multicast
-* This flag is TRUE if OpenSM should disable multicast support.
-*
-* max_msg_fifo_timeout
-* The maximal time a message can stay in the incoming message
-* queue. If there is more than one message in the queue and the
-* last message stayed in the queue more than this value the SA
-* request will be immediately returned with a BUSY status.
-*
-* subnet_timeout
-* The subnet_timeout that will be set for all the ports in the
-* design SubnSet(PortInfo.vl_stall_life))
-*
-* vl_stall_count
-* The number of sequential packets dropped that cause the port
-* to enter the VLStalled state.
-*
-* leaf_vl_stall_count
-* The number of sequential packets dropped that cause the port
-* to enter the VLStalled state. This is for switch ports driving
-* a CA or router port.
-*
-* head_of_queue_lifetime
-* The maximal time a packet can live at the head of a VL queue
-* on any port not driving a CA or router port.
-*
-* leaf_head_of_queue_lifetime
-* The maximal time a packet can live at the head of a VL queue
-* on switch ports driving a CA or router.
-*
-* local_phy_errors_threshold
-* Threshold of local phy errors for sending Trap 129
-*
-* overrun_errors_threshold
-* Threshold of credits overrun errors for sending Trap 129
-*
-* sminfo_polling_timeout
-* Specifies the polling timeout (in milliseconds) - the timeout
-* between one poll to another.
-*
-* packet_life_time
-* The maximal time a packet can stay in a switch.
-* The value is send to all switches as
-* SubnSet(SwitchInfo.life_state)
-*
-* dump_files_dir
-* The directory to be used for opensm-subnet.lst, opensm.fdbs,
-* opensm.mcfdbs, and default log file (the latter for Windows,
-* not Linux).
-*
-* log_file
-* Name of the log file (or NULL) for stdout.
-*
-* log_max_size
-* This option defines maximal log file size in MB. When
-* specified the log file will be truncated upon reaching
-* this limit.
-*
-* qos
-* Boolean that specifies whether the OpenSM QoS functionality
-* should be off or on.
-*
-* qos_policy_file
-* Name of the QoS policy file.
-*
-* accum_log_file
-* If TRUE (default) - the log file will be accumulated.
-* If FALSE - the log file will be erased before starting
-* current opensm run.
-*
-* port_prof_ignore_file
-* Name of file with port guids to be ignored by port profiling.
-*
-* port_profile_switch_nodes
-* If TRUE will count the number of switch nodes routed through
-* the link. If FALSE - only CA/RT nodes are counted.
-*
-* sweep_on_trap
-* Received traps will initiate a new sweep.
-*
-* routing_engine_names
-* Name of routing engine(s) to use.
-*
-* connect_roots
-* The option which will enforce root to root connectivity with
-* up/down routing engine (even if this violates "pure" deadlock
-* free up/down algorithm)
-*
-* use_ucast_cache
-* When TRUE enables unicast routing cache.
-*
-* lid_matrix_dump_file
-* Name of the lid matrix dump file from where switch
-* lid matrices (min hops tables) will be loaded
-*
-* lfts_file
-* Name of the unicast LFTs routing file from where switch
-* forwarding tables will be loaded
-*
-* root_guid_file
-* Name of the file that contains list of root guids that
-* will be used by fat-tree or up/dn routing (provided by User)
-*
-* cn_guid_file
-* Name of the file that contains list of compute node guids that
-* will be used by fat-tree routing (provided by User)
-*
-* ids_guid_file
-* Name of the file that contains list of ids which should be
-* used by Up/Down algorithm instead of node GUIDs
-*
-* guid_routing_order_file
-* Name of the file that contains list of guids for routing order
-* that will be used by minhop and up/dn routing (provided by User).
-*
-* sa_db_file
-* Name of the SA database file.
-*
-* exit_on_fatal
-* If TRUE (default) - SM will exit on fatal subnet initialization
-* issues.
-* If FALSE - SM will not exit.
-* Fatal initialization issues:
-* a. SM recognizes 2 different nodes with the same guid, or
-* 12x link with lane reversal badly configured.
-*
-* honor_guid2lid_file
-* Always honor the guid2lid file if it exists and is valid. This
-* means that the file will be honored when SM is coming out of
-* STANDBY. By default this is FALSE.
-*
-* daemon
-* OpenSM will run in daemon mode.
-*
-* sm_inactive
-* OpenSM will start with SM in not active state.
-*
-* babbling_port_policy
-* OpenSM will enforce its "babbling" port policy.
-*
-* perfmgr
-* Enable or disable the performance manager
-*
-* perfmgr_redir
-* Enable or disable the saving of redirection by PerfMgr
-*
-* perfmgr_sweep_time_s
-* Define the period (in seconds) of PerfMgr sweeps
-*
-* event_db_dump_file
-* File to dump the event database to
-*
-* event_db_plugin
-* Specify the name of the event plugin
-*
-* qos_options
-* Default set of QoS options
-*
-* qos_ca_options
-* QoS options for CA ports
-*
-* qos_sw0_options
-* QoS options for switches' port 0
-*
-* qos_swe_options
-* QoS options for switches' external ports
-*
-* qos_rtr_options
-* QoS options for router ports
-*
-* enable_quirks
-* Enable high risk new features and not fully qualified
-* hardware specific work arounds
-*
-* no_clients_rereg
-* When TRUE disables clients reregistration request.
-*
-* SEE ALSO
-* Subnet object
-*********/
-
-/****s* OpenSM: Subnet/osm_subn_t
-* NAME
-* osm_subn_t
-*
-* DESCRIPTION
-* Subnet structure. Callers may directly access member components,
-* after grabbing a lock.
-*
-* TO DO
-* This structure should probably be volatile.
-*
-* SYNOPSIS
-*/
-typedef struct osm_subn {
- struct osm_opensm *p_osm;
- cl_qmap_t sw_guid_tbl;
- cl_qmap_t node_guid_tbl;
- cl_qmap_t port_guid_tbl;
- cl_qmap_t rtr_guid_tbl;
- cl_qlist_t prefix_routes_list;
- cl_qmap_t prtn_pkey_tbl;
- cl_qmap_t sm_guid_tbl;
- cl_qlist_t sa_sr_list;
- cl_qlist_t sa_infr_list;
- cl_ptr_vector_t port_lid_tbl;
- ib_net16_t master_sm_base_lid;
- ib_net16_t sm_base_lid;
- ib_net64_t sm_port_guid;
- uint8_t sm_state;
- osm_subn_opt_t opt;
- struct osm_qos_policy *p_qos_policy;
- uint16_t max_ucast_lid_ho;
- uint16_t max_mcast_lid_ho;
- uint8_t min_ca_mtu;
- uint8_t min_ca_rate;
- boolean_t ignore_existing_lfts;
- boolean_t subnet_initialization_error;
- boolean_t force_heavy_sweep;
- boolean_t force_reroute;
- boolean_t in_sweep_hop_0;
- boolean_t first_time_master_sweep;
- boolean_t coming_out_of_standby;
- unsigned need_update;
- void *mgroups[IB_LID_MCAST_END_HO - IB_LID_MCAST_START_HO + 1];
-} osm_subn_t;
-/*
-* FIELDS
-* sw_guid_tbl
-* Container of pointers to all Switch objects in the subent.
-* Indexed by node GUID.
-*
-* node_guid_tbl
-* Container of pointers to all Node objects in the subent.
-* Indexed by node GUID.
-*
-* port_guid_tbl
-* Container of pointers to all Port objects in the subent.
-* Indexed by port GUID - network order!
-*
-* rtr_guid_tbl
-* Container of pointers to all Router objects in the subent.
-* Indexed by node GUID.
-*
-* prtn_pkey_tbl
-* Container of pointers to all Partition objects in the subnet.
-* Indexed by P_KEY.
-*
-* sm_guid_tbl
-* Container of pointers to SM objects representing other SMs
-* on the subnet.
-*
-* port_lid_tbl
-* Container of pointers to all Port objects in the subent.
-* Indexed by port LID.
-*
-* master_sm_base_lid
-* The base LID owned by the subnet's master SM.
-*
-* sm_base_lid
-* The base LID of the local port where the SM is.
-*
-* sm_port_guid
-* This SM's own port GUID.
-*
-* sm_state
-* The high-level state of the SM. This value is made available
-* in the SMInfo attribute.
-*
-* opt
-* Subnet options structure contains site specific configuration.
-*
-* p_qos_policy
-* Subnet QoS policy structure.
-*
-* max_ucast_lid_ho
-* The minimal max unicast lid reported by all switches
-*
-* max_mcast_lid_ho
-* The minimal max multicast lid reported by all switches
-*
-* min_ca_mtu
-* The minimal MTU reported by all CAs ports on the subnet
-*
-* min_ca_rate
-* The minimal rate reported by all CA ports on the subnet
-*
-* ignore_existing_lfts
-* This flag is a dynamic flag to instruct the LFT assignment to
-* ignore existing legal LFT settings.
-* The value will be set according to :
-* - Any change to the list of switches will set it to high
-* - Coming out of STANDBY it will be cleared (other SM worked)
-* - Set to FALSE upon end of all lft assignments.
-*
-* subnet_initalization_error
-* Similar to the force_heavy_sweep flag. If TRUE - means that
-* we had errors during initialization (due to SubnSet requests
-* that failed). We want to declare the subnet as unhealthy, and
-* force another heavy sweep.
-*
-* force_heavy_sweep
-* If TRUE - we want to force a heavy sweep. This can be done
-* either due to receiving of trap - meaning there is some change
-* on the subnet, or we received a handover from a remote sm.
-* In this case we want to sweep and reconfigure the entire
-* subnet. This will cause another heavy sweep to occure when
-* the current sweep is done.
-*
-* force_reroute
-* If TRUE - we want to force switches in the fabric to be
-* rerouted.
-*
-* in_sweep_hop_0
-* When in_sweep_hop_0 flag is set to TRUE - this means we are
-* in sweep_hop_0 - meaning we do not want to continue beyond
-* the current node.
-* This is relevant for the case of SM on switch, since in the
-* switch info we need to signal somehow not to continue
-* the sweeping.
-*
-* first_time_master_sweep
-* This flag is used for the PortInfo setting. On the first
-* sweep as master (meaning after moving from Standby|Discovering
-* state), the SM must send a PortInfoSet to all ports. After
-* that - we want to minimize the number of PortInfoSet requests
-* sent, and to send only requests that change the value from
-* what is updated in the port (or send a first request if this
-* is a new port). We will set this flag to TRUE when entering
-* the master state, and set it back to FALSE at the end of the
-* drop manager. This is done since at the end of the drop manager
-* we have updated all the ports that are reachable, and from now
-* on these are the only ports we have data of. We don't want
-* to send extra set requests to these ports anymore.
-*
-* coming_out_of_standby
-* TRUE on the first sweep after the SM was in standby.
-* Used for nulling any cache of LID and Routing.
-* The flag is set true if the SM state was standby and now
-* changed to MASTER it is reset at the end of the sweep.
-*
-* need_update
-* This flag should be on during first non-master heavy
-* (including pre-master discovery stage)
-*
-* mgroups
-* Array of pointers to all Multicast Group objects in the subnet.
-* Indexed by MLID offset from base MLID.
-*
-* SEE ALSO
-* Subnet object
-*********/
-
-/****f* OpenSM: Subnet/osm_subn_construct
-* NAME
-* osm_subn_construct
-*
-* DESCRIPTION
-* This function constructs a Subnet object.
-*
-* SYNOPSIS
-*/
-void osm_subn_construct(IN osm_subn_t * const p_subn);
-/*
-* PARAMETERS
-* p_subn
-* [in] Pointer to a Subnet object to construct.
-*
-* RETURN VALUE
-* This function does not return a value.
-*
-* NOTES
-* Allows calling osm_subn_init, and osm_subn_destroy.
-*
-* Calling osm_subn_construct is a prerequisite to calling any other
-* method except osm_subn_init.
-*
-* SEE ALSO
-* Subnet object, osm_subn_init, osm_subn_destroy
-*********/
-
-/****f* OpenSM: Subnet/osm_subn_destroy
-* NAME
-* osm_subn_destroy
-*
-* DESCRIPTION
-* The osm_subn_destroy function destroys a subnet, releasing
-* all resources.
-*
-* SYNOPSIS
-*/
-void osm_subn_destroy(IN osm_subn_t * const p_subn);
-/*
-* PARAMETERS
-* p_subn
-* [in] Pointer to a Subnet object to destroy.
-*
-* RETURN VALUE
-* This function does not return a value.
-*
-* NOTES
-* Performs any necessary cleanup of the specified Subnet object.
-* Further operations should not be attempted on the destroyed object.
-* This function should only be called after a call to osm_subn_construct
-* or osm_subn_init.
-*
-* SEE ALSO
-* Subnet object, osm_subn_construct, osm_subn_init
-*********/
-
-/****f* OpenSM: Subnet/osm_subn_init
-* NAME
-* osm_subn_init
-*
-* DESCRIPTION
-* The osm_subn_init function initializes a Subnet object for use.
-*
-* SYNOPSIS
-*/
-ib_api_status_t
-osm_subn_init(IN osm_subn_t * const p_subn,
- IN struct osm_opensm *const p_osm,
- IN const osm_subn_opt_t * const p_opt);
-/*
-* PARAMETERS
-* p_subn
-* [in] Pointer to an osm_subn_t object to initialize.
-*
-* p_opt
-* [in] Pointer to the subnet options structure.
-*
-* RETURN VALUES
-* IB_SUCCESS if the Subnet object was initialized successfully.
-*
-* NOTES
-* Allows calling other Subnet methods.
-*
-* SEE ALSO
-* Subnet object, osm_subn_construct, osm_subn_destroy
-*********/
-
-/*
- Forward references.
-*/
-struct osm_mad_addr;
-struct osm_log;
-struct osm_switch;
-struct osm_physp;
-struct osm_port;
-struct osm_mgrp;
-
-/****f* OpenSM: Helper/osm_get_gid_by_mad_addr
-* NAME
-* osm_get_gid_by_mad_addr
-*
-* DESCRIPTION
-* Looks for the requester gid in the mad address.
-*
-* Note: This code is not thread safe. Need to grab the lock before
-* calling it.
-*
-* SYNOPSIS
-*/
-ib_api_status_t
-osm_get_gid_by_mad_addr(IN struct osm_log *p_log,
- IN const osm_subn_t * p_subn,
- IN const struct osm_mad_addr *p_mad_addr,
- OUT ib_gid_t * p_gid);
-/*
-* PARAMETERS
-* p_log
-* [in] Pointer to a log object.
-*
-* p_subn
-* [in] Pointer to subnet object.
-*
-* p_mad_addr
-* [in] Pointer to mad address object.
-*
-* p_gid
-* [out] Pointer to the GID structure to fill in.
-*
-* RETURN VALUES
-* IB_SUCCESS if able to find the GID by address given.
-*
-* NOTES
-*
-* SEE ALSO
-*********/
-
-/****f* OpenSM: Helper/osm_get_physp_by_mad_addr
-* NAME
-* osm_get_physp_by_mad_addr
-*
-* DESCRIPTION
-* Looks for the requester physical port in the mad address.
-*
-* Note: This code is not thread safe. Need to grab the lock before
-* calling it.
-*
-* SYNOPSIS
-*/
-struct osm_physp *osm_get_physp_by_mad_addr(IN struct osm_log *p_log,
- IN const osm_subn_t * p_subn,
- IN struct osm_mad_addr
- *p_mad_addr);
-/*
-* PARAMETERS
-* p_log
-* [in] Pointer to a log object.
-*
-* p_subn
-* [in] Pointer to subnet object.
-*
-* p_mad_addr
-* [in] Pointer to mad address object.
-*
-* RETURN VALUES
-* Pointer to requester physical port object if found. Null otherwise.
-*
-* NOTES
-*
-* SEE ALSO
-*********/
-
-/****f* OpenSM: Helper/osm_get_port_by_mad_addr
-* NAME
-* osm_get_port_by_mad_addr
-*
-* DESCRIPTION
-* Looks for the requester port in the mad address.
-*
-* Note: This code is not thread safe. Need to grab the lock before
-* calling it.
-*
-* SYNOPSIS
-*/
-struct osm_port *osm_get_port_by_mad_addr(IN struct osm_log *p_log,
- IN const osm_subn_t * p_subn,
- IN struct osm_mad_addr *p_mad_addr);
-/*
-* PARAMETERS
-* p_log
-* [in] Pointer to a log object.
-*
-* p_subn
-* [in] Pointer to subnet object.
-*
-* p_mad_addr
-* [in] Pointer to mad address object.
-*
-* RETURN VALUES
-* Pointer to requester port object if found. Null otherwise.
-*
-* NOTES
-*
-* SEE ALSO
-*********/
-
-/****f* OpenSM: Subnet/osm_get_switch_by_guid
-* NAME
-* osm_get_switch_by_guid
-*
-* DESCRIPTION
-* Looks for the given switch guid in the subnet table of switches by guid.
-* NOTE: this code is not thread safe. Need to grab the lock before
-* calling it.
-*
-* SYNOPSIS
-*/
-struct osm_switch *osm_get_switch_by_guid(IN const osm_subn_t * p_subn,
- IN uint64_t guid);
-/*
-* PARAMETERS
-* p_subn
-* [in] Pointer to an osm_subn_t object
-*
-* guid
-* [in] The node guid in host order
-*
-* RETURN VALUES
-* The switch structure pointer if found. NULL otherwise.
-*
-* SEE ALSO
-* Subnet object, osm_subn_construct, osm_subn_destroy,
-* osm_switch_t
-*********/
-
-/****f* OpenSM: Subnet/osm_get_node_by_guid
-* NAME
-* osm_get_node_by_guid
-*
-* DESCRIPTION
-* The looks for the given node giud in the subnet table of nodes by guid.
-* NOTE: this code is not thread safe. Need to grab the lock before
-* calling it.
-*
-* SYNOPSIS
-*/
-struct osm_node *osm_get_node_by_guid(IN osm_subn_t const *p_subn,
- IN uint64_t guid);
-/*
-* PARAMETERS
-* p_subn
-* [in] Pointer to an osm_subn_t object
-*
-* guid
-* [in] The node guid in host order
-*
-* RETURN VALUES
-* The node structure pointer if found. NULL otherwise.
-*
-* SEE ALSO
-* Subnet object, osm_subn_construct, osm_subn_destroy,
-* osm_node_t
-*********/
-
-/****f* OpenSM: Subnet/osm_get_port_by_guid
-* NAME
-* osm_get_port_by_guid
-*
-* DESCRIPTION
-* The looks for the given port guid in the subnet table of ports by guid.
-* NOTE: this code is not thread safe. Need to grab the lock before
-* calling it.
-*
-* SYNOPSIS
-*/
-struct osm_port *osm_get_port_by_guid(IN osm_subn_t const *p_subn,
- IN ib_net64_t guid);
-/*
-* PARAMETERS
-* p_subn
-* [in] Pointer to an osm_subn_t object
-*
-* guid
-* [in] The port guid in network order
-*
-* RETURN VALUES
-* The port structure pointer if found. NULL otherwise.
-*
-* SEE ALSO
-* Subnet object, osm_subn_construct, osm_subn_destroy,
-* osm_port_t
-*********/
-
-/****f* OpenSM: Subnet/osm_get_mgrp_by_mlid
-* NAME
-* osm_get_mgrp_by_mlid
-*
-* DESCRIPTION
-* The looks for the given multicast group in the subnet table by mlid.
-* NOTE: this code is not thread safe. Need to grab the lock before
-* calling it.
-*
-* SYNOPSIS
-*/
-static inline
-struct osm_mgrp *osm_get_mgrp_by_mlid(osm_subn_t const *p_subn, ib_net16_t mlid)
-{
- return p_subn->mgroups[cl_ntoh16(mlid) - IB_LID_MCAST_START_HO];
-}
-/*
-* PARAMETERS
-* p_subn
-* [in] Pointer to an osm_subn_t object
-*
-* mlid
-* [in] The multicast group mlid in network order
-*
-* RETURN VALUES
-* The multicast group structure pointer if found. NULL otherwise.
-*********/
-
-/****f* OpenSM: Helper/osm_get_physp_by_mad_addr
-* NAME
-* osm_get_physp_by_mad_addr
-*
-* DESCRIPTION
-* Looks for the requester physical port in the mad address.
-*
-* Note: This code is not thread safe. Need to grab the lock before
-* calling it.
-*
-* SYNOPSIS
-*/
-struct osm_physp *osm_get_physp_by_mad_addr(IN struct osm_log *p_log,
- IN const osm_subn_t * p_subn,
- IN struct osm_mad_addr
- *p_mad_addr);
-/*
-* PARAMETERS
-* p_log
-* [in] Pointer to a log object.
-*
-* p_subn
-* [in] Pointer to subnet object.
-*
-* p_mad_addr
-* [in] Pointer to mad address object.
-*
-* RETURN VALUES
-* Pointer to requester physical port object if found. Null otherwise.
-*
-* NOTES
-*
-* SEE ALSO
-*********/
-
-/****f* OpenSM: Subnet/osm_subn_set_default_opt
-* NAME
-* osm_subn_set_default_opt
-*
-* DESCRIPTION
-* The osm_subn_set_default_opt function sets the default options.
-*
-* SYNOPSIS
-*/
-void osm_subn_set_default_opt(IN osm_subn_opt_t * const p_opt);
-/*
-* PARAMETERS
-*
-* p_opt
-* [in] Pointer to the subnet options structure.
-*
-* RETURN VALUES
-* None
-*
-* NOTES
-*
-* SEE ALSO
-* Subnet object, osm_subn_construct, osm_subn_destroy
-*********/
-
-/****f* OpenSM: Subnet/osm_subn_parse_conf_file
-* NAME
-* osm_subn_parse_conf_file
-*
-* DESCRIPTION
-* The osm_subn_parse_conf_file function parses the configuration file
-* and sets the defaults accordingly.
-*
-* SYNOPSIS
-*/
-int osm_subn_parse_conf_file(char *conf_file, osm_subn_opt_t * const p_opt);
-/*
-* PARAMETERS
-*
-* p_opt
-* [in] Pointer to the subnet options structure.
-*
-* RETURN VALUES
-* 0 on success, positive value if file doesn't exist,
-* negative value otherwise
-*********/
-
-/****f* OpenSM: Subnet/osm_subn_rescan_conf_files
-* NAME
-* osm_subn_rescan_conf_files
-*
-* DESCRIPTION
-* The osm_subn_rescan_conf_files function parses the configuration
-* files and update selected subnet options
-*
-* SYNOPSIS
-*/
-int osm_subn_rescan_conf_files(IN osm_subn_t * const p_subn);
-/*
-* PARAMETERS
-*
-* p_subn
-* [in] Pointer to the subnet structure.
-*
-* RETURN VALUES
-* 0 on success, positive value if file doesn't exist,
-* negative value otherwise
-*
-*********/
-
-/****f* OpenSM: Subnet/osm_subn_output_conf
-* NAME
-* osm_subn_output_conf
-*
-* DESCRIPTION
-* Output configuration info
-*
-* SYNOPSIS
-*/
-int osm_subn_output_conf(FILE *out, IN osm_subn_opt_t * const p_opt);
-/*
-* PARAMETERS
-*
-* out
-* [in] File stream to output to.
-*
-* p_opt
-* [in] Pointer to the subnet options structure.
-*
-* RETURN VALUES
-* 0 on success, negative value otherwise
-*********/
-
-/****f* OpenSM: Subnet/osm_subn_write_conf_file
-* NAME
-* osm_subn_write_conf_file
-*
-* DESCRIPTION
-* Write the configuration file into the cache
-*
-* SYNOPSIS
-*/
-int osm_subn_write_conf_file(char *file_name, IN osm_subn_opt_t * const p_opt);
-/*
-* PARAMETERS
-*
-* p_opt
-* [in] Pointer to the subnet options structure.
-*
-* RETURN VALUES
-* 0 on success, negative value otherwise
-*
-* NOTES
-* Assumes the conf file is part of the cache dir which defaults to
-* OSM_DEFAULT_CACHE_DIR or OSM_CACHE_DIR the name is opensm.opts
-*********/
-int osm_subn_verify_config(osm_subn_opt_t * const p_opt);
-
-END_C_DECLS
-#endif /* _OSM_SUBNET_H_ */
diff --git a/contrib/ofed/management/opensm/include/opensm/osm_switch.h b/contrib/ofed/management/opensm/include/opensm/osm_switch.h
deleted file mode 100644
index dbc22e5..0000000
--- a/contrib/ofed/management/opensm/include/opensm/osm_switch.h
+++ /dev/null
@@ -1,1152 +0,0 @@
-/*
- * Copyright (c) 2004-2008 Voltaire, Inc. All rights reserved.
- * Copyright (c) 2002-2008 Mellanox Technologies LTD. All rights reserved.
- * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- */
-
-/*
- * Abstract:
- * Declaration of osm_switch_t.
- * This object represents an IBA switch.
- * This object is part of the OpenSM family of objects.
- */
-
-#ifndef _OSM_SWITCH_H_
-#define _OSM_SWITCH_H_
-
-#include <iba/ib_types.h>
-#include <opensm/osm_base.h>
-#include <opensm/osm_madw.h>
-#include <opensm/osm_node.h>
-#include <opensm/osm_port.h>
-#include <opensm/osm_mcast_tbl.h>
-#include <opensm/osm_port_profile.h>
-
-#ifdef __cplusplus
-# define BEGIN_C_DECLS extern "C" {
-# define END_C_DECLS }
-#else /* !__cplusplus */
-# define BEGIN_C_DECLS
-# define END_C_DECLS
-#endif /* __cplusplus */
-
-BEGIN_C_DECLS
-/****h* OpenSM/Switch
-* NAME
-* Switch
-*
-* DESCRIPTION
-* The Switch object encapsulates the information needed by the
-* OpenSM to manage switches. The OpenSM allocates one switch object
-* per switch in the IBA subnet.
-*
-* The Switch object is not thread safe, thus callers must provide
-* serialization.
-*
-* This object should be treated as opaque and should be
-* manipulated only through the provided functions.
-*
-* AUTHOR
-* Steve King, Intel
-*
-*********/
-/****s* OpenSM: Switch/osm_switch_t
-* NAME
-* osm_switch_t
-*
-* DESCRIPTION
-* Switch structure.
-*
-* This object should be treated as opaque and should
-* be manipulated only through the provided functions.
-*
-* SYNOPSIS
-*/
-typedef struct osm_switch {
- cl_map_item_t map_item;
- osm_node_t *p_node;
- ib_switch_info_t switch_info;
- uint16_t max_lid_ho;
- uint8_t num_ports;
- uint16_t num_hops;
- uint8_t **hops;
- osm_port_profile_t *p_prof;
- uint8_t *lft;
- uint8_t *new_lft;
- osm_mcast_tbl_t mcast_tbl;
- uint32_t discovery_count;
- unsigned need_update;
- void *priv;
-} osm_switch_t;
-/*
-* FIELDS
-* map_item
-* Linkage structure for cl_qmap. MUST BE FIRST MEMBER!
-*
-* p_node
-* Pointer to the Node object for this switch.
-*
-* switch_info
-* IBA defined SwitchInfo structure for this switch.
-*
-* max_lid_ho
-* Max LID that is accessible from this switch.
-*
-* num_ports
-* Number of ports for this switch.
-*
-* num_hops
-* Size of hops table for this switch.
-*
-* hops
-* LID Matrix for this switch containing the hop count
-* to every LID from every port.
-*
-* p_prof
-* Pointer to array of Port Profile objects for this switch.
-*
-* lft
-* This switch's linear forwarding table.
-*
-* new_lft
-* This switch's linear forwarding table, as was
-* calculated by the last routing engine execution.
-*
-* mcast_tbl
-* Multicast forwarding table for this switch.
-*
-* discovery_count
-* The number of times this switch has been discovered
-* during the current fabric sweep. This number is reset
-* to zero at the start of a sweep.
-*
-* need_update
-* When set indicates that switch was probably reset, so
-* fwd tables and rest cached data should be flushed
-*
-* SEE ALSO
-* Switch object
-*********/
-
-/****s* OpenSM: Switch/struct osm_remote_guids_count
-* NAME
-* struct osm_remote_guids_count
-*
-* DESCRIPTION
-* Stores array of pointers to remote node and the numbers of
-* times a switch has forwarded to it.
-*
-* SYNOPSIS
-*/
-struct osm_remote_guids_count {
- unsigned count;
- struct osm_remote_node {
- osm_node_t *node;
- unsigned forwarded_to;
- } guids[0];
-};
-/*
-* FIELDS
-* count
-* A number of used entries in array.
-*
-* node
-* A pointer to node.
-*
-* forwarded_to
-* A count of lids forwarded to this node.
-*********/
-
-/****f* OpenSM: Switch/osm_switch_delete
-* NAME
-* osm_switch_delete
-*
-* DESCRIPTION
-* Destroys and deallocates the object.
-*
-* SYNOPSIS
-*/
-void osm_switch_delete(IN OUT osm_switch_t ** const pp_sw);
-/*
-* PARAMETERS
-* p_sw
-* [in] Pointer to the object to destroy.
-*
-* RETURN VALUE
-* None.
-*
-* NOTES
-*
-* SEE ALSO
-* Switch object, osm_switch_new
-*********/
-
-/****f* OpenSM: Switch/osm_switch_new
-* NAME
-* osm_switch_new
-*
-* DESCRIPTION
-* The osm_switch_new function initializes a Switch object for use.
-*
-* SYNOPSIS
-*/
-osm_switch_t *osm_switch_new(IN osm_node_t * const p_node,
- IN const osm_madw_t * const p_madw);
-/*
-* PARAMETERS
-* p_node
-* [in] Pointer to the node object of this switch
-*
-* p_madw
-* [in] Pointer to the MAD Wrapper containing the switch's
-* SwitchInfo attribute.
-*
-* RETURN VALUES
-* Pointer to the new initialized switch object.
-*
-* NOTES
-*
-* SEE ALSO
-* Switch object, osm_switch_delete
-*********/
-
-/****f* OpenSM: Switch/osm_switch_get_hop_count
-* NAME
-* osm_switch_get_hop_count
-*
-* DESCRIPTION
-* Returns the hop count at the specified LID/Port intersection.
-*
-* SYNOPSIS
-*/
-static inline uint8_t
-osm_switch_get_hop_count(IN const osm_switch_t * const p_sw,
- IN const uint16_t lid_ho, IN const uint8_t port_num)
-{
- return (lid_ho > p_sw->max_lid_ho || !p_sw->hops[lid_ho]) ?
- OSM_NO_PATH : p_sw->hops[lid_ho][port_num];
-}
-/*
-* PARAMETERS
-* p_sw
-* [in] Pointer to a Switch object.
-*
-* lid_ho
-* [in] LID value (host order) for which to return the hop count
-*
-* port_num
-* [in] Port number in the switch
-*
-* RETURN VALUES
-* Returns the hop count at the specified LID/Port intersection.
-*
-* NOTES
-*
-* SEE ALSO
-*********/
-
-/****f* OpenSM: Switch/osm_switch_set_hops
-* NAME
-* osm_switch_set_hops
-*
-* DESCRIPTION
-* Sets the hop count at the specified LID/Port intersection.
-*
-* SYNOPSIS
-*/
-cl_status_t
-osm_switch_set_hops(IN osm_switch_t * const p_sw,
- IN const uint16_t lid_ho,
- IN const uint8_t port_num, IN const uint8_t num_hops);
-/*
-* PARAMETERS
-* p_sw
-* [in] Pointer to a Switch object.
-*
-* lid_ho
-* [in] LID value (host order) for which to set the count.
-*
-* port_num
-* [in] port number for which to set the count.
-*
-* num_hops
-* [in] value to assign to this entry.
-*
-* RETURN VALUES
-* Returns the hop count at the specified LID/Port intersection.
-*
-* NOTES
-*
-* SEE ALSO
-*********/
-
-/****f* OpenSM: Switch/osm_switch_clear_hops
-* NAME
-* osm_switch_clear_hops
-*
-* DESCRIPTION
-* Cleanup existing hops tables (lid matrix)
-*
-* SYNOPSIS
-*/
-void osm_switch_clear_hops(IN osm_switch_t * p_sw);
-/*
-* PARAMETERS
-* p_sw
-* [in] Pointer to a Switch object.
-*
-* NOTES
-*
-* SEE ALSO
-*********/
-
-/****f* OpenSM: Switch/osm_switch_get_least_hops
-* NAME
-* osm_switch_get_least_hops
-*
-* DESCRIPTION
-* Returns the number of hops in the short path to this lid from
-* any port on the switch.
-*
-* SYNOPSIS
-*/
-static inline uint8_t
-osm_switch_get_least_hops(IN const osm_switch_t * const p_sw,
- IN const uint16_t lid_ho)
-{
- return (lid_ho > p_sw->max_lid_ho || !p_sw->hops[lid_ho]) ?
- OSM_NO_PATH : p_sw->hops[lid_ho][0];
-}
-/*
-* PARAMETERS
-* p_sw
-* [in] Pointer to an osm_switch_t object.
-*
-* lid_ho
-* [in] LID (host order) for which to retrieve the shortest hop count.
-*
-* RETURN VALUES
-* Returns the number of hops in the short path to this lid from
-* any port on the switch.
-*
-* NOTES
-*
-* SEE ALSO
-* Switch object
-*********/
-
-/****f* OpenSM: Switch/osm_switch_get_port_least_hops
-* NAME
-* osm_switch_get_port_least_hops
-*
-* DESCRIPTION
-* Returns the number of hops in the short path to this port from
-* any port on the switch.
-*
-* SYNOPSIS
-*/
-uint8_t
-osm_switch_get_port_least_hops(IN const osm_switch_t * const p_sw,
- IN const osm_port_t * p_port);
-/*
-* PARAMETERS
-* p_sw
-* [in] Pointer to an osm_switch_t object.
-*
-* p_port
-* [in] Pointer to an osm_port_t object for which to
-* retrieve the shortest hop count.
-*
-* RETURN VALUES
-* Returns the number of hops in the short path to this lid from
-* any port on the switch.
-*
-* NOTES
-*
-* SEE ALSO
-* Switch object
-*********/
-
-/****f* OpenSM: Switch/osm_switch_get_port_by_lid
-* NAME
-* osm_switch_get_port_by_lid
-*
-* DESCRIPTION
-* Returns the switch port number on which the specified LID is routed.
-*
-* SYNOPSIS
-*/
-static inline uint8_t
-osm_switch_get_port_by_lid(IN const osm_switch_t * const p_sw,
- IN const uint16_t lid_ho)
-{
- if (lid_ho == 0 || lid_ho > IB_LID_UCAST_END_HO)
- return OSM_NO_PATH;
- return p_sw->lft[lid_ho];
-}
-/*
-* PARAMETERS
-* p_sw
-* [in] Pointer to an osm_switch_t object.
-*
-* lid_ho
-* [in] LID (host order) for which to retrieve the shortest hop count.
-*
-* RETURN VALUES
-* Returns the switch port on which the specified LID is routed.
-*
-* NOTES
-*
-* SEE ALSO
-* Switch object
-*********/
-
-/****f* OpenSM: Switch/osm_switch_get_physp_ptr
-* NAME
-* osm_switch_get_physp_ptr
-*
-* DESCRIPTION
-* Gets the Physical Port Object at the specified port number.
-*
-* SYNOPSIS
-*/
-osm_physp_t *osm_switch_get_physp_ptr(IN const osm_switch_t * const p_sw,
- IN const uint32_t port_num);
-/*
-* PARAMETERS
-* p_sw
-* [in] Pointer to an osm_switch_t object.
-*
-* port_num
-* [in] Port number for which to retrieve the Physical Port Object.
-*
-* RETURN VALUES
-* Returns a pointer to the Physical Port Object object at the specified
-* port number.
-* A return value of zero means the port number was out of range.
-*
-*
-* NOTES
-*
-* SEE ALSO
-* Switch object
-*********/
-
-/****f* OpenSM: Switch/osm_switch_get_route_by_lid
-* NAME
-* osm_switch_get_route_by_lid
-*
-* DESCRIPTION
-* Gets the physical port object that routes the specified LID.
-*
-* SYNOPSIS
-*/
-static inline osm_physp_t *osm_switch_get_route_by_lid(IN const osm_switch_t *
- const p_sw,
- IN const ib_net16_t lid)
-{
- uint8_t port_num;
-
- CL_ASSERT(p_sw);
- CL_ASSERT(lid);
-
- port_num = osm_switch_get_port_by_lid(p_sw, cl_ntoh16(lid));
-
- /*
- In order to avoid holes in the subnet (usually happens when
- running UPDN algorithm), i.e. cases where port is
- unreachable through a switch (we put an OSM_NO_PATH value at
- the port entry, we do not assert on unreachable lid entries
- at the fwd table but return NULL
- */
- if (port_num != OSM_NO_PATH)
- return (osm_node_get_physp_ptr(p_sw->p_node, port_num));
- else
- return NULL;
-}
-/*
-* PARAMETERS
-* p_sw
-* [in] Pointer to an osm_switch_t object.
-*
-* lid
-* [in] LID for which to find a route. This must be a unicast
-* LID value < 0xC000.
-*
-* RETURN VALUES
-* Returns a pointer to the Physical Port Object object that
-* routes the specified LID. A return value of zero means
-* there is no route for the lid through this switch.
-* The lid value must be a unicast LID.
-*
-* NOTES
-*
-* SEE ALSO
-* Switch object
-*********/
-
-/****f* OpenSM: Switch/osm_switch_sp0_is_lmc_capable
-* NAME
-* osm_switch_sp0_is_lmc_capable
-*
-* DESCRIPTION
-* Returns whether switch port 0 (SP0) can support LMC
-*
-*/
-static inline unsigned
-osm_switch_sp0_is_lmc_capable(IN const osm_switch_t * const p_sw,
- IN osm_subn_t * p_subn)
-{
- return (p_subn->opt.lmc_esp0 &&
- ib_switch_info_is_enhanced_port0(&p_sw->switch_info)) ? 1 : 0;
-}
-/*
-* PARAMETERS
-* p_sw
-* [in] Pointer to an osm_switch_t object.
-*
-* p_subn
-* [in] Pointer to an osm_subn_t object.
-*
-* RETURN VALUES
-* TRUE if SP0 is enhanced and globally enabled. FALSE otherwise.
-*
-* NOTES
-* This is workaround function, it takes into account user defined
-* p_subn->opt.lmc_esp0 parameter.
-*
-* SEE ALSO
-*********/
-
-/****f* OpenSM: Switch/osm_switch_get_max_block_id_in_use
-* NAME
-* osm_switch_get_max_block_id_in_use
-*
-* DESCRIPTION
-* Returns the maximum block ID (host order) of this switch that
-* is used for unicast routing.
-*
-* SYNOPSIS
-*/
-static inline uint16_t
-osm_switch_get_max_block_id_in_use(IN const osm_switch_t * const p_sw)
-{
- return cl_ntoh16(p_sw->switch_info.lin_top) / IB_SMP_DATA_SIZE;
-}
-/*
-* PARAMETERS
-* p_sw
-* [in] Pointer to an osm_switch_t object.
-*
-* RETURN VALUES
-* Returns the maximum block ID (host order) of this switch.
-*
-* NOTES
-*
-* SEE ALSO
-* Switch object
-*********/
-
-/****f* OpenSM: Switch/osm_switch_get_lft_block
-* NAME
-* osm_switch_get_lft_block
-*
-* DESCRIPTION
-* Retrieve a linear forwarding table block.
-*
-* SYNOPSIS
-*/
-boolean_t
-osm_switch_get_lft_block(IN const osm_switch_t * const p_sw,
- IN const uint16_t block_id,
- OUT uint8_t * const p_block);
-/*
-* PARAMETERS
-* p_sw
-* [in] Pointer to an osm_switch_t object.
-*
-* block_ID
-* [in] The block_id to retrieve.
-*
-* p_block
-* [out] Pointer to the 64 byte array to store the
-* forwarding table clock specified by block_id.
-*
-* RETURN VALUES
-* Returns true if there are more blocks necessary to
-* configure all the LIDs reachable from this switch.
-* FALSE otherwise.
-*
-* NOTES
-*
-* SEE ALSO
-*********/
-
-/****f* OpenSM: Switch/osm_switch_supports_mcast
-* NAME
-* osm_switch_supports_mcast
-*
-* DESCRIPTION
-* Indicates if a switch supports multicast.
-*
-* SYNOPSIS
-*/
-static inline boolean_t
-osm_switch_supports_mcast(IN const osm_switch_t * const p_sw)
-{
- return (p_sw->switch_info.mcast_cap != 0);
-}
-/*
-* PARAMETERS
-* p_sw
-* [in] Pointer to an osm_switch_t object.
-*
-* RETURN VALUES
-* Returns TRUE if the switch supports multicast.
-* FALSE otherwise.
-*
-* NOTES
-*
-* SEE ALSO
-*********/
-
-/****f* OpenSM: Switch/osm_switch_set_switch_info
-* NAME
-* osm_switch_set_switch_info
-*
-* DESCRIPTION
-* Updates the switch info attribute of this switch.
-*
-* SYNOPSIS
-*/
-static inline void
-osm_switch_set_switch_info(IN osm_switch_t * const p_sw,
- IN const ib_switch_info_t * const p_si)
-{
- CL_ASSERT(p_sw);
- CL_ASSERT(p_si);
- p_sw->switch_info = *p_si;
-}
-/*
-* PARAMETERS
-* p_sw
-* [in] Pointer to a Switch object.
-*
-* p_si
-* [in] Pointer to the SwitchInfo attribute for this switch.
-*
-* RETURN VALUES
-* None.
-*
-* NOTES
-*
-* SEE ALSO
-*********/
-
-/****f* OpenSM: Switch/osm_switch_count_path
-* NAME
-* osm_switch_count_path
-*
-* DESCRIPTION
-* Counts this path in port profile.
-*
-* SYNOPSIS
-*/
-static inline void
-osm_switch_count_path(IN osm_switch_t * const p_sw, IN const uint8_t port)
-{
- osm_port_prof_path_count_inc(&p_sw->p_prof[port]);
-}
-/*
-* PARAMETERS
-* p_sw
-* [in] Pointer to the switch object.
-*
-* port
-* [in] Port to count path.
-*
-* RETURN VALUE
-* None.
-*
-* NOTES
-*
-* SEE ALSO
-*********/
-
-/****f* OpenSM: Switch/osm_switch_set_lft_block
-* NAME
-* osm_switch_set_lft_block
-*
-* DESCRIPTION
-* Copies in the specified block into
-* the switch's Linear Forwarding Table.
-*
-* SYNOPSIS
-*/
-static inline ib_api_status_t
-osm_switch_set_lft_block(IN osm_switch_t * const p_sw,
- IN const uint8_t * const p_block,
- IN const uint32_t block_num)
-{
- uint16_t lid_start =
- (uint16_t) (block_num * IB_SMP_DATA_SIZE);
- CL_ASSERT(p_sw);
-
- if (lid_start + IB_SMP_DATA_SIZE > IB_LID_UCAST_END_HO)
- return IB_INVALID_PARAMETER;
-
- memcpy(&p_sw->lft[lid_start], p_block, IB_SMP_DATA_SIZE);
- return IB_SUCCESS;
-}
-/*
-* PARAMETERS
-* p_sw
-* [in] Pointer to the switch object.
-*
-* p_block
-* [in] Pointer to the forwarding table block.
-*
-* block_num
-* [in] Block number for this block
-*
-* RETURN VALUE
-* None.
-*
-* NOTES
-*
-* SEE ALSO
-*********/
-
-/****f* OpenSM: Switch/osm_switch_set_mft_block
-* NAME
-* osm_switch_set_mft_block
-*
-* DESCRIPTION
-* Sets a block of multicast port masks into the multicast table.
-*
-* SYNOPSIS
-*/
-static inline ib_api_status_t
-osm_switch_set_mft_block(IN osm_switch_t * const p_sw,
- IN const ib_net16_t * const p_block,
- IN const uint16_t block_num, IN const uint8_t position)
-{
- CL_ASSERT(p_sw);
- return (osm_mcast_tbl_set_block(&p_sw->mcast_tbl, p_block,
- block_num, position));
-}
-/*
-* PARAMETERS
-* p_sw
-* [in] Pointer to the switch object.
-*
-* p_block
-* [in] Pointer to the block of port masks to set.
-*
-* block_num
-* [in] Block number (0-511) to set.
-*
-* position
-* [in] Port mask position (0-15) to set.
-*
-* RETURN VALUE
-* IB_SUCCESS on success.
-*
-* NOTES
-*
-* SEE ALSO
-*********/
-
-/****f* OpenSM: Switch/osm_switch_get_mft_block
-* NAME
-* osm_switch_get_mft_block
-*
-* DESCRIPTION
-* Retrieve a block of multicast port masks from the multicast table.
-*
-* SYNOPSIS
-*/
-static inline boolean_t
-osm_switch_get_mft_block(IN osm_switch_t * const p_sw,
- IN const uint16_t block_num,
- IN const uint8_t position,
- OUT ib_net16_t * const p_block)
-{
- CL_ASSERT(p_sw);
- return (osm_mcast_tbl_get_block(&p_sw->mcast_tbl,
- block_num, position, p_block));
-}
-/*
-* PARAMETERS
-* p_sw
-* [in] Pointer to the switch object.
-*
-* block_num
-* [in] Block number (0-511) to set.
-*
-* position
-* [in] Port mask position (0-15) to set.
-*
-* p_block
-* [out] Pointer to the block of port masks stored.
-*
-* RETURN VALUES
-* Returns true if there are more blocks necessary to
-* configure all the MLIDs reachable from this switch.
-* FALSE otherwise.
-*
-* NOTES
-*
-* SEE ALSO
-*********/
-
-/****f* OpenSM: Switch/osm_switch_get_mft_max_block
-* NAME
-* osm_switch_get_mft_max_block
-*
-* DESCRIPTION
-* Get the max_block from the associated multicast table.
-*
-* SYNOPSIS
-*/
-static inline uint16_t
-osm_switch_get_mft_max_block(IN osm_switch_t * const p_sw)
-{
- CL_ASSERT(p_sw);
- return (osm_mcast_tbl_get_max_block(&p_sw->mcast_tbl));
-}
-/*
-* PARAMETERS
-* p_sw
-* [in] Pointer to the switch object.
-*
-* RETURN VALUE
-*/
-
-/****f* OpenSM: Switch/osm_switch_get_mft_max_block_in_use
-* NAME
-* osm_switch_get_mft_max_block_in_use
-*
-* DESCRIPTION
-* Get the max_block_in_use from the associated multicast table.
-*
-* SYNOPSIS
-*/
-static inline int16_t
-osm_switch_get_mft_max_block_in_use(IN osm_switch_t * const p_sw)
-{
- CL_ASSERT(p_sw);
- return (osm_mcast_tbl_get_max_block_in_use(&p_sw->mcast_tbl));
-}
-/*
-* PARAMETERS
-* p_sw
-* [in] Pointer to the switch object.
-*
-* RETURN VALUES
-* Returns the maximum block ID in use in this switch's mcast table.
-* A value of -1 indicates no blocks are in use.
-*
-* NOTES
-*
-* SEE ALSO
-*/
-
-/****f* OpenSM: Switch/osm_switch_get_mft_max_position
-* NAME
-* osm_switch_get_mft_max_position
-*
-* DESCRIPTION
-* Get the max_position from the associated multicast table.
-*
-* SYNOPSIS
-*/
-static inline uint8_t
-osm_switch_get_mft_max_position(IN osm_switch_t * const p_sw)
-{
- CL_ASSERT(p_sw);
- return (osm_mcast_tbl_get_max_position(&p_sw->mcast_tbl));
-}
-/*
-* PARAMETERS
-* p_sw
-* [in] Pointer to the switch object.
-*
-* RETURN VALUE
-*/
-
-/****f* OpenSM: Switch/osm_switch_recommend_path
-* NAME
-* osm_switch_recommend_path
-*
-* DESCRIPTION
-* Returns the recommended port on which to route this LID.
-* In cases where LMC > 0, the remote side system and node
-* used for the routing are tracked in the provided arrays
-* (and counts) such that other lid for the same port will
-* try and avoid going through the same remote system/node.
-*
-* SYNOPSIS
-*/
-uint8_t
-osm_switch_recommend_path(IN const osm_switch_t * const p_sw,
- IN osm_port_t * p_port,
- IN const uint16_t lid_ho,
- IN unsigned start_from,
- IN const boolean_t ignore_existing,
- IN const boolean_t dor);
-/*
-* PARAMETERS
-* p_sw
-* [in] Pointer to the switch object.
-*
-* p_port
-* [in] Pointer to the port object for which to get a path
-* advisory.
-*
-* lid_ho
-* [in] LID value (host order) for which to get a path advisory.
-*
-* start_from
-* [in] Port number from where to start balance counting.
-*
-* ignore_existing
-* [in] Set to cause the switch to choose the optimal route
-* regardless of existing paths.
-* If false, the switch will choose an existing route if one
-* exists, otherwise will choose the optimal route.
-*
-* dor
-* [in] If TRUE, Dimension Order Routing will be done.
-*
-* RETURN VALUE
-* Returns the recommended port on which to route this LID.
-*
-* NOTES
-*
-* SEE ALSO
-*********/
-
-/****f* OpenSM: Switch/osm_switch_recommend_mcast_path
-* NAME
-* osm_switch_recommend_mcast_path
-*
-* DESCRIPTION
-* Returns the recommended port on which to route this LID.
-*
-* SYNOPSIS
-*/
-uint8_t
-osm_switch_recommend_mcast_path(IN osm_switch_t * const p_sw,
- IN osm_port_t * p_port,
- IN const uint16_t mlid_ho,
- IN const boolean_t ignore_existing);
-/*
-* PARAMETERS
-* p_sw
-* [in] Pointer to the switch object.
-*
-* p_port
-* [in] Pointer to the port object for which to get
-* the multicast path.
-*
-* mlid_ho
-* [in] MLID for the multicast group in question.
-*
-* ignore_existing
-* [in] Set to cause the switch to choose the optimal route
-* regardless of existing paths.
-* If false, the switch will choose an existing route if one exists,
-* otherwise will choose the optimal route.
-*
-* RETURN VALUE
-* Returns the recommended port on which to route this LID.
-*
-* NOTES
-*
-* SEE ALSO
-*********/
-
-/****f* OpenSM: Switch/osm_switch_get_mcast_fwd_tbl_size
-* NAME
-* osm_switch_get_mcast_fwd_tbl_size
-*
-* DESCRIPTION
-* Returns the number of entries available in the multicast forwarding table.
-*
-* SYNOPSIS
-*/
-static inline uint16_t
-osm_switch_get_mcast_fwd_tbl_size(IN const osm_switch_t * const p_sw)
-{
- return (cl_ntoh16(p_sw->switch_info.mcast_cap));
-}
-/*
-* PARAMETERS
-* p_sw
-* [in] Pointer to the switch.
-*
-* RETURN VALUE
-* Returns the number of entries available in the multicast forwarding table.
-*
-* NOTES
-*
-* SEE ALSO
-*********/
-
-/****f* OpenSM: Switch/osm_switch_path_count_get
-* NAME
-* osm_switch_path_count_get
-*
-* DESCRIPTION
-* Returns the count of the number of paths going through this port.
-*
-* SYNOPSIS
-*/
-static inline uint32_t
-osm_switch_path_count_get(IN const osm_switch_t * const p_sw,
- IN const uint8_t port_num)
-{
- return (osm_port_prof_path_count_get(&p_sw->p_prof[port_num]));
-}
-/*
-* PARAMETERS
-* p_sw
-* [in] Pointer to the Switch object.
-*
-* port_num
-* [in] Port number for which to get path count.
-*
-* RETURN VALUE
-* Returns the count of the number of paths going through this port.
-*
-* NOTES
-*
-* SEE ALSO
-*********/
-
-/****f* OpenSM: Switch/osm_switch_prepare_path_rebuild
-* NAME
-* osm_switch_prepare_path_rebuild
-*
-* DESCRIPTION
-* Prepares a switch to rebuild pathing information.
-*
-* SYNOPSIS
-*/
-int
-osm_switch_prepare_path_rebuild(IN osm_switch_t * p_sw, IN uint16_t max_lids);
-/*
-* PARAMETERS
-* p_sw
-* [in] Pointer to the Switch object.
-*
-* max_lids
-* [in] Max number of lids in the subnet.
-*
-* RETURN VALUE
-* Returns zero on success, or negative value if an error occurred.
-*
-* NOTES
-*
-* SEE ALSO
-*********/
-
-/****f* OpenSM: Switch/osm_switch_get_mcast_tbl_ptr
-* NAME
-* osm_switch_get_mcast_tbl_ptr
-*
-* DESCRIPTION
-* Returns a pointer to the switch's multicast table.
-*
-* SYNOPSIS
-*/
-static inline osm_mcast_tbl_t *osm_switch_get_mcast_tbl_ptr(IN const
- osm_switch_t *
- const p_sw)
-{
- return ((osm_mcast_tbl_t *) & p_sw->mcast_tbl);
-}
-/*
-* PARAMETERS
-* p_sw
-* [in] Pointer to the switch.
-*
-* RETURN VALUE
-* Returns a pointer to the switch's multicast table.
-*
-* NOTES
-*
-* SEE ALSO
-*********/
-
-/****f* OpenSM: Switch/osm_switch_is_in_mcast_tree
-* NAME
-* osm_switch_is_in_mcast_tree
-*
-* DESCRIPTION
-* Returns true if this switch already belongs in the tree for the specified
-* multicast group.
-*
-* SYNOPSIS
-*/
-static inline boolean_t
-osm_switch_is_in_mcast_tree(IN const osm_switch_t * const p_sw,
- IN const uint16_t mlid_ho)
-{
- const osm_mcast_tbl_t *p_tbl;
-
- p_tbl = &p_sw->mcast_tbl;
- if (p_tbl)
- return (osm_mcast_tbl_is_any_port(&p_sw->mcast_tbl, mlid_ho));
- else
- return (FALSE);
-}
-/*
-* PARAMETERS
-* p_sw
-* [in] Pointer to the switch.
-*
-* mlid_ho
-* [in] MLID (host order) of the multicast tree to check.
-*
-* RETURN VALUE
-* Returns true if this switch already belongs in the tree for the specified
-* multicast group.
-*
-* NOTES
-*
-* SEE ALSO
-*********/
-
-END_C_DECLS
-#endif /* _OSM_SWITCH_H_ */
diff --git a/contrib/ofed/management/opensm/include/opensm/osm_ucast_cache.h b/contrib/ofed/management/opensm/include/opensm/osm_ucast_cache.h
deleted file mode 100644
index 11335c7..0000000
--- a/contrib/ofed/management/opensm/include/opensm/osm_ucast_cache.h
+++ /dev/null
@@ -1,240 +0,0 @@
-/*
- * Copyright (c) 2008 Mellanox Technologies LTD. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- */
-
-/*
- * Abstract:
- * Header file that describes Unicast Cache functions.
- *
- * Environment:
- * Linux User Mode
- *
- * $Revision: 1.4 $
- */
-
-#ifndef _OSM_UCAST_CACHE_H_
-#define _OSM_UCAST_CACHE_H_
-
-#include <iba/ib_types.h>
-#include <complib/cl_qmap.h>
-#include <opensm/osm_switch.h>
-
-#ifdef __cplusplus
-# define BEGIN_C_DECLS extern "C" {
-# define END_C_DECLS }
-#else /* !__cplusplus */
-# define BEGIN_C_DECLS
-# define END_C_DECLS
-#endif /* __cplusplus */
-
-BEGIN_C_DECLS
-
-struct osm_ucast_mgr;
-
-/****h* OpenSM/Unicast Manager/Unicast Cache
-* NAME
-* Unicast Cache
-*
-* DESCRIPTION
-* The Unicast Cache object encapsulates the information
-* needed to cache and write unicast routing of the subnet.
-*
-* The Unicast Cache object is NOT thread safe.
-*
-* This object should be treated as opaque and should be
-* manipulated only through the provided functions.
-*
-* AUTHOR
-* Yevgeny Kliteynik, Mellanox
-*
-*********/
-
-/****f* OpenSM: Unicast Cache/osm_ucast_cache_invalidate
-* NAME
-* osm_ucast_cache_invalidate
-*
-* DESCRIPTION
-* The osm_ucast_cache_invalidate function purges the
-* unicast cache and marks the cache as invalid.
-*
-* SYNOPSIS
-*/
-void osm_ucast_cache_invalidate(struct osm_ucast_mgr *p_mgr);
-/*
-* PARAMETERS
-* p_mgr
-* [in] Pointer to the ucast mgr object.
-*
-* RETURN VALUE
-* This function does not return any value.
-*
-* NOTES
-*
-* SEE ALSO
-* Unicast Manager object
-*********/
-
-/****f* OpenSM: Unicast Cache/osm_ucast_cache_check_new_link
-* NAME
-* osm_ucast_cache_check_new_link
-*
-* DESCRIPTION
-* The osm_ucast_cache_check_new_link checks whether
-* the newly discovered link still allows us to use
-* cached unicast routing.
-*
-* SYNOPSIS
-*/
-void osm_ucast_cache_check_new_link(struct osm_ucast_mgr *p_mgr,
- osm_node_t * p_node_1, uint8_t port_num_1,
- osm_node_t * p_node_2, uint8_t port_num_2);
-/*
-* PARAMETERS
-* p_mgr
-* [in] Pointer to the unicast manager object.
-*
-* physp1
-* [in] Pointer to the first physical port of the link.
-*
-* physp2
-* [in] Pointer to the second physical port of the link.
-*
-* RETURN VALUE
-* This function does not return any value.
-*
-* NOTES
-* The function checks whether the link was previously
-* cached/dropped or is this a completely new link.
-* If it decides that the new link makes cached routing
-* invalid, the cache is purged and marked as invalid.
-*
-* SEE ALSO
-* Unicast Cache object
-*********/
-
-/****f* OpenSM: Unicast Cache/osm_ucast_cache_add_link
-* NAME
-* osm_ucast_cache_add_link
-*
-* DESCRIPTION
-* The osm_ucast_cache_add_link adds link to the cache.
-*
-* SYNOPSIS
-*/
-void osm_ucast_cache_add_link(struct osm_ucast_mgr *p_mgr,
- osm_physp_t * physp1, osm_physp_t * physp2);
-/*
-* PARAMETERS
-* p_mgr
-* [in] Pointer to the unicast manager object.
-*
-* physp1
-* [in] Pointer to the first physical port of the link.
-*
-* physp2
-* [in] Pointer to the second physical port of the link.
-*
-* RETURN VALUE
-* This function does not return any value.
-*
-* NOTES
-* Since the cache operates with ports and not links,
-* the function adds two port entries (both sides of the
-* link) to the cache.
-* If it decides that the dropped link makes cached routing
-* invalid, the cache is purged and marked as invalid.
-*
-* SEE ALSO
-* Unicast Manager object
-*********/
-
-/****f* OpenSM: Unicast Cache/osm_ucast_cache_add_node
-* NAME
-* osm_ucast_cache_add_node
-*
-* DESCRIPTION
-* The osm_ucast_cache_add_node adds node and all
-* its links to the cache.
-*
-* SYNOPSIS
-*/
-void osm_ucast_cache_add_node(struct osm_ucast_mgr *p_mgr, osm_node_t * p_node);
-/*
-* PARAMETERS
-* p_mgr
-* [in] Pointer to the unicast manager object.
-*
-* p_node
-* [in] Pointer to the node object that should be cached.
-*
-* RETURN VALUE
-* This function does not return any value.
-*
-* NOTES
-* If the function decides that the dropped node makes cached
-* routing invalid, the cache is purged and marked as invalid.
-*
-* SEE ALSO
-* Unicast Manager object
-*********/
-
-/****f* OpenSM: Unicast Cache/osm_ucast_cache_process
-* NAME
-* osm_ucast_cache_process
-*
-* DESCRIPTION
-* The osm_ucast_cache_process function writes the
-* cached unicast routing on the subnet switches.
-*
-* SYNOPSIS
-*/
-int osm_ucast_cache_process(struct osm_ucast_mgr *p_mgr);
-/*
-* PARAMETERS
-* p_mgr
-* [in] Pointer to the unicast manager object.
-*
-* RETURN VALUE
-* This function returns zero on sucess and non-zero
-* value otherwise.
-*
-* NOTES
-* Iterates through all the subnet switches and writes
-* the LFTs that were calculated during the last routing
-* engine execution to the switches.
-*
-* SEE ALSO
-* Unicast Manager object
-*********/
-
-END_C_DECLS
-#endif /* _OSM_UCAST_CACHE_H_ */
diff --git a/contrib/ofed/management/opensm/include/opensm/osm_ucast_mgr.h b/contrib/ofed/management/opensm/include/opensm/osm_ucast_mgr.h
deleted file mode 100644
index a040476..0000000
--- a/contrib/ofed/management/opensm/include/opensm/osm_ucast_mgr.h
+++ /dev/null
@@ -1,308 +0,0 @@
-/*
- * Copyright (c) 2004-2008 Voltaire, Inc. All rights reserved.
- * Copyright (c) 2002-2008 Mellanox Technologies LTD. All rights reserved.
- * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- */
-
-/*
- * Abstract:
- * Declaration of osm_ucast_mgr_t.
- * This object represents the Unicast Manager object.
- * This object is part of the OpenSM family of objects.
- */
-
-#ifndef _OSM_UCAST_MGR_H_
-#define _OSM_UCAST_MGR_H_
-
-#include <complib/cl_passivelock.h>
-#include <complib/cl_qlist.h>
-#include <opensm/osm_madw.h>
-#include <opensm/osm_subnet.h>
-#include <opensm/osm_switch.h>
-#include <opensm/osm_log.h>
-#include <opensm/osm_ucast_cache.h>
-
-#ifdef __cplusplus
-# define BEGIN_C_DECLS extern "C" {
-# define END_C_DECLS }
-#else /* !__cplusplus */
-# define BEGIN_C_DECLS
-# define END_C_DECLS
-#endif /* __cplusplus */
-
-BEGIN_C_DECLS
-/****h* OpenSM/Unicast Manager
-* NAME
-* Unicast Manager
-*
-* DESCRIPTION
-* The Unicast Manager object encapsulates the information
-* needed to control unicast LID forwarding on the subnet.
-*
-* The Unicast Manager object is thread safe.
-*
-* This object should be treated as opaque and should be
-* manipulated only through the provided functions.
-*
-* AUTHOR
-* Steve King, Intel
-*
-*********/
-struct osm_sm;
-/****s* OpenSM: Unicast Manager/osm_ucast_mgr_t
-* NAME
-* osm_ucast_mgr_t
-*
-* DESCRIPTION
-* Unicast Manager structure.
-*
-* This object should be treated as opaque and should
-* be manipulated only through the provided functions.
-*
-* SYNOPSIS
-*/
-typedef struct osm_ucast_mgr {
- struct osm_sm *sm;
- osm_subn_t *p_subn;
- osm_log_t *p_log;
- cl_plock_t *p_lock;
- cl_qlist_t port_order_list;
- boolean_t is_dor;
- boolean_t some_hop_count_set;
- cl_qmap_t cache_sw_tbl;
- boolean_t cache_valid;
-} osm_ucast_mgr_t;
-/*
-* FIELDS
-* sm
-* Pointer to the SM object.
-*
-* p_subn
-* Pointer to the Subnet object for this subnet.
-*
-* p_log
-* Pointer to the log object.
-*
-* p_lock
-* Pointer to the serializing lock.
-*
-* is_dor
-* Dimension Order Routing (DOR) will be done
-*
-* port_order_list
-* List of ports ordered for routing.
-*
-* any_change
-* Initialized to FALSE at the beginning of the algorithm,
-* set to TRUE by osm_ucast_mgr_set_fwd_table() if any mad
-* was sent.
-*
-* some_hop_count_set
-* Initialized to FALSE at the beginning of each the min hop
-* tables calculation iteration cycle, set to TRUE to indicate
-* that some hop count changes were done.
-*
-* cache_sw_tbl
-* Cached switches table.
-*
-* cache_valid
-* TRUE if the unicast cache is valid.
-*
-* SEE ALSO
-* Unicast Manager object
-*********/
-
-/****f* OpenSM: Unicast Manager/osm_ucast_mgr_construct
-* NAME
-* osm_ucast_mgr_construct
-*
-* DESCRIPTION
-* This function constructs a Unicast Manager object.
-*
-* SYNOPSIS
-*/
-void osm_ucast_mgr_construct(IN osm_ucast_mgr_t * const p_mgr);
-/*
-* PARAMETERS
-* p_mgr
-* [in] Pointer to a Unicast Manager object to construct.
-*
-* RETURN VALUE
-* This function does not return a value.
-*
-* NOTES
-* Allows osm_ucast_mgr_destroy
-*
-* Calling osm_ucast_mgr_construct is a prerequisite to calling any other
-* method except osm_ucast_mgr_init.
-*
-* SEE ALSO
-* Unicast Manager object, osm_ucast_mgr_init,
-* osm_ucast_mgr_destroy
-*********/
-
-/****f* OpenSM: Unicast Manager/osm_ucast_mgr_destroy
-* NAME
-* osm_ucast_mgr_destroy
-*
-* DESCRIPTION
-* The osm_ucast_mgr_destroy function destroys the object, releasing
-* all resources.
-*
-* SYNOPSIS
-*/
-void osm_ucast_mgr_destroy(IN osm_ucast_mgr_t * const p_mgr);
-/*
-* PARAMETERS
-* p_mgr
-* [in] Pointer to the object to destroy.
-*
-* RETURN VALUE
-* This function does not return a value.
-*
-* NOTES
-* Performs any necessary cleanup of the specified
-* Unicast Manager object.
-* Further operations should not be attempted on the destroyed object.
-* This function should only be called after a call to
-* osm_ucast_mgr_construct or osm_ucast_mgr_init.
-*
-* SEE ALSO
-* Unicast Manager object, osm_ucast_mgr_construct,
-* osm_ucast_mgr_init
-*********/
-
-/****f* OpenSM: Unicast Manager/osm_ucast_mgr_init
-* NAME
-* osm_ucast_mgr_init
-*
-* DESCRIPTION
-* The osm_ucast_mgr_init function initializes a
-* Unicast Manager object for use.
-*
-* SYNOPSIS
-*/
-ib_api_status_t
-osm_ucast_mgr_init(IN osm_ucast_mgr_t * const p_mgr, IN struct osm_sm * sm);
-/*
-* PARAMETERS
-* p_mgr
-* [in] Pointer to an osm_ucast_mgr_t object to initialize.
-*
-* sm
-* [in] Pointer to the SM object.
-*
-* RETURN VALUES
-* IB_SUCCESS if the Unicast Manager object was initialized
-* successfully.
-*
-* NOTES
-* Allows calling other Unicast Manager methods.
-*
-* SEE ALSO
-* Unicast Manager object, osm_ucast_mgr_construct,
-* osm_ucast_mgr_destroy
-*********/
-
-/****f* OpenSM: Unicast Manager/osm_ucast_mgr_set_fwd_table
-* NAME
-* osm_ucast_mgr_set_fwd_table
-*
-* DESCRIPTION
-* Setup forwarding table for the switch (from prepared new_lft).
-*
-* SYNOPSIS
-*/
-int osm_ucast_mgr_set_fwd_table(IN osm_ucast_mgr_t * const p_mgr,
- IN osm_switch_t * const p_sw);
-/*
-* PARAMETERS
-* p_mgr
-* [in] Pointer to an osm_ucast_mgr_t object.
-*
-* p_mgr
-* [in] Pointer to an osm_switch_t object.
-*
-* SEE ALSO
-* Unicast Manager
-*********/
-
-/****f* OpenSM: Unicast Manager/osm_ucast_mgr_build_lid_matrices
-* NAME
-* osm_ucast_mgr_build_lid_matrices
-*
-* DESCRIPTION
-* Build switches's lid matrices.
-*
-* SYNOPSIS
-*/
-int osm_ucast_mgr_build_lid_matrices(IN osm_ucast_mgr_t * const p_mgr);
-/*
-* PARAMETERS
-* p_mgr
-* [in] Pointer to an osm_ucast_mgr_t object.
-*
-* NOTES
-* This function processes the subnet, configuring switches'
-* min hops tables (aka lid matrices).
-*
-* SEE ALSO
-* Unicast Manager
-*********/
-
-/****f* OpenSM: Unicast Manager/osm_ucast_mgr_process
-* NAME
-* osm_ucast_mgr_process
-*
-* DESCRIPTION
-* Process and configure the subnet's unicast forwarding tables.
-*
-* SYNOPSIS
-*/
-int osm_ucast_mgr_process(IN osm_ucast_mgr_t * const p_mgr);
-/*
-* PARAMETERS
-* p_mgr
-* [in] Pointer to an osm_ucast_mgr_t object.
-*
-* RETURN VALUES
-* Returns zero on success and negative value on failure.
-*
-* NOTES
-* This function processes the subnet, configuring switch
-* unicast forwarding tables.
-*
-* SEE ALSO
-* Unicast Manager, Node Info Response Controller
-*********/
-END_C_DECLS
-#endif /* _OSM_UCAST_MGR_H_ */
diff --git a/contrib/ofed/management/opensm/include/opensm/osm_version.h b/contrib/ofed/management/opensm/include/opensm/osm_version.h
deleted file mode 100644
index 697e2fd..0000000
--- a/contrib/ofed/management/opensm/include/opensm/osm_version.h
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * Copyright (c) 2004-2008 Voltaire, Inc. All rights reserved.
- * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved.
- * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- */
-
-#ifndef _OSM_VERSION_H_
-#define _OSM_VERSION_H_
-
-/****s* OpenSM: Base/OSM_VERSION
-* NAME
-* OSM_VERSION
-*
-* DESCRIPTION
-* The version string for OpenSM
-*
-* SYNOPSIS
-*/
-#define OSM_VERSION "OpenSM 3.3.1"
-/********/
-
-#endif /* _OSM_VERSION_H_ */
diff --git a/contrib/ofed/management/opensm/include/opensm/osm_version.h.in b/contrib/ofed/management/opensm/include/opensm/osm_version.h.in
deleted file mode 100644
index d783245..0000000
--- a/contrib/ofed/management/opensm/include/opensm/osm_version.h.in
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * Copyright (c) 2004-2008 Voltaire, Inc. All rights reserved.
- * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved.
- * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- */
-
-#ifndef _OSM_VERSION_H_
-#define _OSM_VERSION_H_
-
-/****s* OpenSM: Base/OSM_VERSION
-* NAME
-* OSM_VERSION
-*
-* DESCRIPTION
-* The version string for OpenSM
-*
-* SYNOPSIS
-*/
-#define OSM_VERSION "OpenSM @VERSION@"
-/********/
-
-#endif /* _OSM_VERSION_H_ */
diff --git a/contrib/ofed/management/opensm/include/opensm/osm_vl15intf.h b/contrib/ofed/management/opensm/include/opensm/osm_vl15intf.h
deleted file mode 100644
index 028eec0..0000000
--- a/contrib/ofed/management/opensm/include/opensm/osm_vl15intf.h
+++ /dev/null
@@ -1,367 +0,0 @@
-/*
- * Copyright (c) 2004, 2005 Voltaire, Inc. All rights reserved.
- * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved.
- * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- */
-
-/*
- * Abstract:
- * Declaration of osm_vl15_t.
- * This object represents an IBA subnet.
- * This object is part of the OpenSM family of objects.
- */
-
-#ifndef _OSM_VL15INTF_H_
-#define _OSM_VL15INTF_H_
-
-#include <iba/ib_types.h>
-#include <complib/cl_spinlock.h>
-#include <complib/cl_event.h>
-#include <complib/cl_thread.h>
-#include <complib/cl_qlist.h>
-#include <opensm/osm_stats.h>
-#include <opensm/osm_log.h>
-#include <opensm/osm_madw.h>
-#include <opensm/osm_mad_pool.h>
-#include <vendor/osm_vendor_api.h>
-
-#ifdef __cplusplus
-# define BEGIN_C_DECLS extern "C" {
-# define END_C_DECLS }
-#else /* !__cplusplus */
-# define BEGIN_C_DECLS
-# define END_C_DECLS
-#endif /* __cplusplus */
-
-BEGIN_C_DECLS
-/****h* OpenSM/VL15
-* NAME
-* VL15
-*
-* DESCRIPTION
-* The VL15 object encapsulates the information needed by the
-* OpenSM to instantiate the VL15 interface. The OpenSM allocates
-* one VL15 object per subnet.
-*
-* The VL15 object transmits MADs to the wire at a throttled rate,
-* so as to not overload the VL15 buffering of subnet components.
-* OpenSM modules may post VL15 MADs to the VL15 interface as fast
-* as possible.
-*
-* The VL15 object is thread safe.
-*
-* This object should be treated as opaque and should
-* be manipulated only through the provided functions.
-*
-* AUTHOR
-* Steve King, Intel
-*
-*********/
-/****d* OpenSM: SM/osm_vl15_state_t
-* NAME
-* osm_vl15_state_t
-*
-* DESCRIPTION
-* Enumerates the possible states of SM object.
-*
-* SYNOPSIS
-*/
-typedef enum _osm_vl15_state {
- OSM_VL15_STATE_INIT = 0,
- OSM_VL15_STATE_READY
-} osm_vl15_state_t;
-/***********/
-
-/****s* OpenSM: VL15/osm_vl15_t
-* NAME
-* osm_vl15_t
-*
-* DESCRIPTION
-* VL15 structure.
-*
-* This object should be treated as opaque and should
-* be manipulated only through the provided functions.
-*
-* SYNOPSIS
-*/
-typedef struct osm_vl15 {
- osm_thread_state_t thread_state;
- osm_vl15_state_t state;
- uint32_t max_wire_smps;
- cl_event_t signal;
- cl_thread_t poller;
- cl_qlist_t rfifo;
- cl_qlist_t ufifo;
- cl_spinlock_t lock;
- osm_vendor_t *p_vend;
- osm_log_t *p_log;
- osm_stats_t *p_stats;
-} osm_vl15_t;
-/*
-* FIELDS
-* thread_state
-* Tracks the thread state of the poller thread.
-*
-* state
-* Tracks the state of the VL15 interface itself.
-*
-* max_wire_smps
-* Maximum number of VL15 MADs allowed on the wire at one time.
-*
-* signal
-* Event on which the poller sleeps.
-*
-* rfifo
-* First-in First-out queue for outbound VL15 MADs for which
-* a response is expected, aka the "response fifo"
-*
-* ufifo
-* First-in First-out queue for outbound VL15 MADs for which
-* no response is expected, aka the "unicast fifo".
-*
-* poller
-* Worker thread pool that services the fifo to transmit VL15 MADs
-*
-* lock
-* Spinlock guarding the FIFO.
-*
-* p_vend
-* Pointer to the vendor transport object.
-*
-* p_log
-* Pointer to the log object.
-*
-* p_stats
-* Pointer to the OpenSM statistics block.
-*
-* SEE ALSO
-* VL15 object
-*********/
-
-/****f* OpenSM: VL15/osm_vl15_construct
-* NAME
-* osm_vl15_construct
-*
-* DESCRIPTION
-* This function constructs an VL15 object.
-*
-* SYNOPSIS
-*/
-void osm_vl15_construct(IN osm_vl15_t * const p_vl15);
-/*
-* PARAMETERS
-* p_vl15
-* [in] Pointer to a VL15 object to construct.
-*
-* RETURN VALUE
-* This function does not return a value.
-*
-* NOTES
-* Allows calling osm_vl15_destroy.
-*
-* Calling osm_vl15_construct is a prerequisite to calling any other
-* method except osm_vl15_init.
-*
-* SEE ALSO
-* VL15 object, osm_vl15_init, osm_vl15_destroy
-*********/
-
-/****f* OpenSM: VL15/osm_vl15_destroy
-* NAME
-* osm_vl15_destroy
-*
-* DESCRIPTION
-* The osm_vl15_destroy function destroys the object, releasing
-* all resources.
-*
-* SYNOPSIS
-*/
-void
-osm_vl15_destroy(IN osm_vl15_t * const p_vl15, IN struct osm_mad_pool *p_pool);
-/*
-* PARAMETERS
-* p_vl15
-* [in] Pointer to a VL15 object to destroy.
-*
-* p_pool
-* [in] The pointer to the mad pool to return outstanding mads to
-*
-* RETURN VALUE
-* This function does not return a value.
-*
-* NOTES
-* Performs any necessary cleanup of the specified VL15 object.
-* Further operations should not be attempted on the destroyed object.
-* This function should only be called after a call to osm_vl15_construct or
-* osm_vl15_init.
-*
-* SEE ALSO
-* VL15 object, osm_vl15_construct, osm_vl15_init
-*********/
-
-/*
- Initialization.
- Rate specifies the minimum number of microseconds between transmissions
- on VL15.
-*/
-/****f* OpenSM: VL15/osm_vl15_init
-* NAME
-* osm_vl15_init
-*
-* DESCRIPTION
-* The osm_vl15_init function initializes a VL15 object for use.
-*
-* SYNOPSIS
-*/
-ib_api_status_t
-osm_vl15_init(IN osm_vl15_t * const p_vl15,
- IN osm_vendor_t * const p_vend,
- IN osm_log_t * const p_log,
- IN osm_stats_t * const p_stats,
- IN const int32_t max_wire_smps);
-/*
-* PARAMETERS
-* p_vl15
-* [in] Pointer to an osm_vl15_t object to initialize.
-*
-* p_vend
-* [in] Pointer to the vendor transport object.
-*
-* p_log
-* [in] Pointer to the log object.
-*
-* p_stats
-* [in] Pointer to the OpenSM stastics block.
-*
-* max_wire_smps
-* [in] Maximum number of MADs allowed on the wire at one time.
-*
-* RETURN VALUES
-* IB_SUCCESS if the VL15 object was initialized successfully.
-*
-* NOTES
-* Allows calling other VL15 methods.
-*
-* SEE ALSO
-* VL15 object, osm_vl15_construct, osm_vl15_destroy
-*********/
-
-/****f* OpenSM: VL15/osm_vl15_post
-* NAME
-* osm_vl15_post
-*
-* DESCRIPTION
-* Posts a MAD to the VL15 interface for transmission.
-*
-* SYNOPSIS
-*/
-void osm_vl15_post(IN osm_vl15_t * const p_vl15, IN osm_madw_t * const p_madw);
-/*
-* PARAMETERS
-* p_vl15
-* [in] Pointer to an osm_vl15_t object.
-*
-* p_madw
-* [in] Pointer to a MAD wrapper structure containing the MAD.
-*
-* RETURN VALUES
-* This function does not return a value.
-*
-* NOTES
-* The osm_vl15_construct or osm_vl15_init must be called before using
-* this function.
-*
-* SEE ALSO
-* VL15 object, osm_vl15_construct, osm_vl15_init
-*********/
-
-/****f* OpenSM: VL15/osm_vl15_poll
-* NAME
-* osm_vl15_poll
-*
-* DESCRIPTION
-* Causes the VL15 Interface to consider sending another QP0 MAD.
-*
-* SYNOPSIS
-*/
-void osm_vl15_poll(IN osm_vl15_t * const p_vl);
-/*
-* PARAMETERS
-* p_vl15
-* [in] Pointer to an osm_vl15_t object.
-*
-* RETURN VALUES
-* None.
-*
-* NOTES
-* This function signals the VL15 that it may be possible to send
-* a SMP. This function checks three criteria before sending a SMP:
-* 1) The VL15 worker is IDLE
-* 2) There are no QP0 SMPs currently outstanding
-* 3) There is something on the VL15 FIFO to send
-*
-* SEE ALSO
-* VL15 object, osm_vl15_construct, osm_vl15_init
-*********/
-
-/****f* OpenSM: VL15/osm_vl15_shutdown
-* NAME
-* osm_vl15_shutdown
-*
-* DESCRIPTION
-* Cleanup all outstanding MADs on both fifo's.
-* This is required to return all outstanding MAD resources.
-*
-* SYNOPSIS
-*/
-void
-osm_vl15_shutdown(IN osm_vl15_t * const p_vl,
- IN osm_mad_pool_t * const p_mad_pool);
-/*
-* PARAMETERS
-* p_vl15
-* [in] Pointer to an osm_vl15_t object.
-*
-* p_mad_pool
-* [in] The MAD pool owning the mads.
-*
-* RETURN VALUES
-* None.
-*
-* NOTES
-*
-* SEE ALSO
-* VL15 object, osm_vl15_construct, osm_vl15_init
-*********/
-
-END_C_DECLS
-#endif /* _OSM_VL15INTF_H_ */
diff --git a/contrib/ofed/management/opensm/include/opensm/st.h b/contrib/ofed/management/opensm/include/opensm/st.h
deleted file mode 100644
index 30cc308..0000000
--- a/contrib/ofed/management/opensm/include/opensm/st.h
+++ /dev/null
@@ -1,102 +0,0 @@
-/*
- * Copyright (c) 2004-2006 Voltaire, Inc. All rights reserved.
- * Copyright (c) 2002-2006 Mellanox Technologies LTD. All rights reserved.
- * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- */
-
-/* @(#) st.h 5.1 89/12/14 */
-
-#ifndef ST_INCLUDED
-#define ST_INCLUDED
-
-#include <stdlib.h>
-
-#ifdef __cplusplus
-# define BEGIN_C_DECLS extern "C" {
-# define END_C_DECLS }
-#else /* !__cplusplus */
-# define BEGIN_C_DECLS
-# define END_C_DECLS
-#endif /* __cplusplus */
-
-BEGIN_C_DECLS
-#define st_ptr_t unsigned long
-typedef st_ptr_t st_data_t;
-
-#define ST_DATA_T_DEFINED
-
-typedef struct st_table st_table;
-
-struct st_hash_type {
- int (*compare) (void *, void *);
- st_ptr_t(*hash) (void *);
-};
-
-struct st_table {
- struct st_hash_type *type;
- int num_bins;
- int num_entries;
- struct st_table_entry **bins;
-};
-
-#define st_is_member(table,key) st_lookup(table,key,(st_data_t *)0)
-
-enum st_retval { ST_CONTINUE, ST_STOP, ST_DELETE };
-
-st_table *st_init_table(struct st_hash_type *);
-st_table *st_init_table_with_size(struct st_hash_type *, size_t);
-st_table *st_init_numtable(void);
-st_table *st_init_numtable_with_size(size_t);
-st_table *st_init_strtable(void);
-st_table *st_init_strtable_with_size(size_t);
-int st_delete(st_table *, st_data_t *, st_data_t *);
-int st_delete_safe(st_table *, st_data_t *, st_data_t *, st_data_t);
-int st_insert(st_table *, st_data_t, st_data_t);
-int st_lookup(st_table *, st_data_t, st_data_t *);
-void st_foreach(st_table *,
- int (*)(st_data_t key, st_data_t val, st_data_t arg),
- st_data_t);
-void st_add_direct(st_table *, st_data_t, st_data_t);
-void st_free_table(st_table *);
-void st_cleanup_safe(st_table *, st_data_t);
-st_table *st_copy(st_table *);
-
-#define ST_NUMCMP ((int (*)()) 0)
-#define ST_NUMHASH ((int (*)()) -2)
-
-#define st_numcmp ST_NUMCMP
-#define st_numhash ST_NUMHASH
-
-/* int st_strhash(void); */
-
-END_C_DECLS
-#endif /* ST_INCLUDED */
diff --git a/contrib/ofed/management/opensm/include/vendor/osm_vendor.h b/contrib/ofed/management/opensm/include/vendor/osm_vendor.h
deleted file mode 100644
index 3cde781..0000000
--- a/contrib/ofed/management/opensm/include/vendor/osm_vendor.h
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * Copyright (c) 2004, 2005 Voltaire, Inc. All rights reserved.
- * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved.
- * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- */
-
-/*
- * Abstract:
- * Include file used by OpenSM to pull in the correct vendor file.
- */
-
-/*
- this is the generic include file which includes
- the proper vendor specific file
-*/
-#include <opensm/osm_config.h>
-
-#if defined( OSM_VENDOR_INTF_TEST )
-#include <vendor/osm_vendor_test.h>
-#elif defined( OSM_VENDOR_INTF_UMADT )
-#include <vendor/osm_vendor_umadt.h>
-#elif defined( OSM_VENDOR_INTF_MTL )
-/* HACK - I do not know how to prevent complib from loading kernel H files */
-#undef __init
-#include <vendor/osm_vendor_mlx.h>
-#elif defined( OSM_VENDOR_INTF_TS )
-#undef __init
-#include <vendor/osm_vendor_mlx.h>
-#elif defined( OSM_VENDOR_INTF_ANAFA )
-#undef __init
-#include <vendor/osm_vendor_mlx.h>
-#elif defined( OSM_VENDOR_INTF_SIM )
-#undef __init
-#include <vendor/osm_vendor_mlx.h>
-#elif defined( OSM_VENDOR_INTF_OPENIB )
-#include <vendor/osm_vendor_ibumad.h>
-#elif defined( OSM_VENDOR_INTF_AL )
-#include <vendor/osm_vendor_al.h>
-#else
-#error No MAD Interface selected!
-#error Choose an interface in osm_config.h
-#endif
diff --git a/contrib/ofed/management/opensm/include/vendor/osm_vendor_api.h b/contrib/ofed/management/opensm/include/vendor/osm_vendor_api.h
deleted file mode 100644
index 70eb6cc..0000000
--- a/contrib/ofed/management/opensm/include/vendor/osm_vendor_api.h
+++ /dev/null
@@ -1,487 +0,0 @@
-/*
- * Copyright (c) 2004, 2005 Voltaire, Inc. All rights reserved.
- * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved.
- * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- */
-
-/*
- * Abstract:
- * Specification of the OpenSM transport API. This API is OpenSM's view
- * of the Infiniband transport.
- */
-
-#ifndef _OSM_VENDOR_API_H_
-#define _OSM_VENDOR_API_H_
-
-#include <opensm/osm_madw.h>
-#include <opensm/osm_mad_pool.h>
-#include <vendor/osm_vendor.h>
-
-#ifdef __cplusplus
-# define BEGIN_C_DECLS extern "C" {
-# define END_C_DECLS }
-#else /* !__cplusplus */
-# define BEGIN_C_DECLS
-# define END_C_DECLS
-#endif /* __cplusplus */
-
-BEGIN_C_DECLS
-/****s* OpenSM Vendor API/osm_vend_mad_recv_callback_t
-* NAME
-* osm_vend_mad_recv_callback_t
-*
-* DESCRIPTION
-* Function prototype for the vendor MAD receive callback.
-* The vendor layer calls this function for MAD receives.
-*
-* SYNOPSIS
-*/
-typedef void (*osm_vend_mad_recv_callback_t) (IN osm_madw_t * p_madw,
- IN void *bind_context,
- IN osm_madw_t * p_req_madw);
-/*
-* PARAMETERS
-* p_madw
-* [in] The received MAD wrapper.
-*
-* bind_context
-* [in] User context supplied during the bind call.
-*
-* p_req_madw
-* [in] Pointer to the request mad wrapper that generated this response.
-* If the inbound MAD is not a response, this field is NULL.
-*
-* RETURN VALUES
-* None.
-*
-* NOTES
-*
-* SEE ALSO
-*********/
-
-/****s* OpenSM Vendor API/osm_vend_mad_send_err_callback_t
-* NAME
-* osm_vend_mad_send_err_callback_t
-*
-* DESCRIPTION
-* Function prototype for the vendor send failure callback.
-* The vendor layer calls this function when MADs expecting
-* a response are completed in error, most likely due to a
-* timeout.
-*
-* SYNOPSIS
-*/
-typedef void (*osm_vend_mad_send_err_callback_t) (IN void *bind_context,
- IN osm_madw_t * p_madw);
-/*
-* PARAMETERS
-* bind_context
-* [in] User context supplied during the bind call.
-*
-* p_madw
-* [in] Pointer to the request mad that failed.
-*
-* RETURN VALUES
-* None.
-*
-* NOTES
-* The vendor layer does not call this function (or any other)
-* for MADs that were not expecting a response.
-*
-* SEE ALSO
-*********/
-
-/****f* OpenSM Vendor API/osm_vendor_new
-* NAME
-* osm_vendor_new
-*
-* DESCRIPTION
-* Allocates and initializes a new osm_vendor_t object.
-* OpenSM calls this function before any other in the vendor API.
-* This object is passed as a parameter to all other vendor functions.
-*
-* SYNOPSIS
-*/
-osm_vendor_t *osm_vendor_new(IN osm_log_t * const p_log,
- IN const uint32_t timeout);
-/*
-* PARAMETERS
-* p_log
-* [in] Pointer to the log object to use.
-*
-* timeout
-* [in] transaction timeout
-*
-* RETURN VALUES
-* Returns a pointer to the vendor object.
-*
-* NOTES
-*
-* SEE ALSO
-*********/
-
-/****s* OpenSM Vendor API/osm_vendor_delete
-* NAME
-* osm_vendor_delete
-*
-* DESCRIPTION
-* Dealocate the vendor object.
-*
-* SYNOPSIS
-*/
-void osm_vendor_delete(IN osm_vendor_t ** const pp_vend);
-/*
-* PARAMETERS
-* pp_vend
-* [in/out] pointer to pointer to vendor objcet to be deleted
-*
-* RETURN VALUES
-* None
-*
-* NOTES
-*
-* SEE ALSO
-*********/
-
-/****f* OpenSM Vendor API/osm_vendor_get_ports
-* NAME
-* osm_vendor_get_ports
-*
-* DESCRIPTION
-* Returns an array of available port attribute structures.
-*
-* SYNOPSIS
-*/
-ib_api_status_t
-osm_vendor_get_all_port_attr(IN osm_vendor_t * const p_vend,
- IN ib_port_attr_t * const p_attr_array,
- IN uint32_t * const p_num_ports);
-/*
-* PARAMETERS
-* p_vend
-* [in] Pointer to the vendor object to initialize.
-*
-* p_attr_array
-* [in/out] Pointer to pre-allocated array of port attributes.
-* If it is NULL - then the command only updates the p_num_ports,
-* and return IB_INSUFFICIENT_MEMORY.
-*
-* p_num_ports
-* [in/out] Pointer to a variable to hold the total number of ports
-* available on the local machine..
-*
-* RETURN VALUES
-* IB_SUCCESS on success.
-* IB_INSUFFICIENT_MEMORY if the attribute array was not large enough.
-* The number of attributes needed is returned in num_guids.
-*
-* NOTES
-*
-* SEE ALSO
-*********/
-
-/****f* OpenSM Vendor API/osm_vendor_init
-* NAME
-* osm_vendor_init
-*
-* DESCRIPTION
-* The osm_vendor_init function initializes the vendor transport layer.
-*
-* SYNOPSIS
-*/
-ib_api_status_t
-osm_vendor_init(IN osm_vendor_t * const p_vend,
- IN osm_log_t * const p_log, IN const uint32_t timeout);
-/*
-* PARAMETERS
-* p_vend
-* [in] Pointer to the vendor object to initialize.
-*
-* p_log
-* [in] Pointer to OpenSM's log object. Vendor code may
-* use the log object to send messages to OpenSM's log.
-*
-* timeout
-* [in] Transaction timeout value in milliseconds.
-* A value of 0 disables timeouts.
-*
-* RETURN VALUE
-*
-* NOTES
-*
-* SEE ALSO
-*********/
-
-/****f* OpenSM Vendor API/osm_vendor_bind
-* NAME
-* osm_vendor_bind
-*
-* DESCRIPTION
-* The osm_vendor_bind function registers with the vendor transport layer
-* per Mad Class per PortGuid for mad transport capability.
-*
-* SYNOPSIS
-*/
-osm_bind_handle_t
-osm_vendor_bind(IN osm_vendor_t * const p_vend,
- IN osm_bind_info_t * const p_bind_info,
- IN osm_mad_pool_t * const p_mad_pool,
- IN osm_vend_mad_recv_callback_t mad_recv_callback,
- IN osm_vend_mad_send_err_callback_t send_err_callback,
- IN void *context);
-/*
-* PARAMETERS
-* p_vend
-* [in] pointer to the vendor object
-*
-* p_osm_bind_info
-* [in] pointer to a struct defining the type of bind to perform.
-*
-* p_mad_pool
-* [in] pointer to a mad wrappers pool to be used for allocating
-* mad wrappers on send and receive.
-*
-* mad_recv_callback
-* [in] the callback function to be invoked on mad receive.
-*
-* send_err_callback
-* [in] the callback function to be invoked on mad transaction errors.
-*
-* context
-* [in] the context to be provided to the callbacks as bind_ctx.
-*
-* RETURN VALUE
-* On success, a valid bind handle.
-* OSM_BIND_INVALID_HANDLE otherwise.
-*
-* NOTES
-*
-* SEE ALSO
-*********/
-
-/****f* OpenSM Vendor API/osm_vendor_unbind
-* NAME
-* osm_vendor_unbind
-*
-* DESCRIPTION
-* Unbind the given bind handle (obtained by osm_vendor_bind).
-*
-* SYNOPSIS
-*/
-void osm_vendor_unbind(IN osm_bind_handle_t h_bind);
-/*
-* PARAMETERS
-* h_bind
-* [in] the bind handle to release.
-*
-* RETURN VALUE
-* NONE.
-*
-* NOTES
-*
-* SEE ALSO
-*********/
-
-/****f* OpenSM Vendor API/osm_vendor_get
-* NAME
-* osm_vendor_get
-*
-* DESCRIPTION
-* Obtain a mad wrapper holding actual mad buffer to be sent via
-* the transport.
-*
-* SYNOPSIS
-*/
-ib_mad_t *osm_vendor_get(IN osm_bind_handle_t h_bind,
- IN const uint32_t mad_size,
- IN osm_vend_wrap_t * const p_vend_wrap);
-/*
-* PARAMETERS
-* h_bind
-* [in] the bind handle obtained by calling osm_vendor_bind
-*
-* mad_size
-* [in] the actual mad size required
-*
-* p_vend_wrap
-* [out] the returned mad vendor wrapper
-*
-* RETURN VALUE
-* IB_SUCCESS on succesful completion.
-*
-* NOTES
-*
-* SEE ALSO
-*********/
-
-/****f* OpenSM Vendor API/osm_vendor_send
-* NAME
-* osm_vendor_send
-*
-* DESCRIPTION
-*
-* SYNOPSIS
-*/
-ib_api_status_t
-osm_vendor_send(IN osm_bind_handle_t h_bind,
- IN osm_madw_t * const p_madw, IN boolean_t const resp_expected);
-/*
-* PARAMETERS
-* h_bind
-* [in] the bind handle obtained by calling osm_vendor_bind
-*
-* p_madw
-* [in] pointer to the Mad Wrapper structure for the MAD to be sent.
-*
-* resp_expected
-* [in] boolean value declaring the mad as a request (expecting a response).
-*
-* RETURN VALUE
-* IB_SUCCESS on succesful completion.
-*
-* NOTES
-* 1. Only mads that expect a response are tracked for transaction competion.
-* 2. A mad that does not expect a response is being put back immediatly after
-* being sent.
-*
-* SEE ALSO
-*********/
-
-/****f* OpenSM Vendor API/osm_vendor_put
-* NAME
-* osm_vendor_put
-*
-* DESCRIPTION
-* Return a mad vendor wrapper to the mad pool. It also means that the
-* mad buffer is returned to the transport.
-*
-* SYNOPSIS
-*/
-void
-osm_vendor_put(IN osm_bind_handle_t h_bind,
- IN osm_vend_wrap_t * const p_vend_wrap);
-/*
-* PARAMETERS
-* h_bind
-* [in] the bind handle obtained by calling osm_vendor_bind
-*
-* p_vend_wrap
-* [in] pointer to the mad vendor wrapper to put back into the pool.
-*
-* RETURN VALUE
-* None.
-*
-* NOTES
-*
-* SEE ALSO
-*********/
-
-/****i* OpenSM Vendor API/osm_vendor_local_lid_change
-* NAME
-* osm_vendor_local_lid_change
-*
-* DESCRIPTION
-* Notifies the vendor transport layer that the local address
-* has changed. This allows the vendor layer to perform housekeeping
-* functions such as address vector updates.
-*
-* SYNOPSIS
-*/
-ib_api_status_t osm_vendor_local_lid_change(IN osm_bind_handle_t h_bind);
-/*
-* PARAMETERS
-* h_bind
-* [in] the bind handle obtained by calling osm_vendor_bind
-*
-* RETURN VALUE
-*
-* NOTES
-*
-* SEE ALSO
-*********/
-
-/****f* OpenSM Vendor API/osm_vendor_set_sm
-* NAME
-* osm_vendor_set_sm
-*
-* DESCRIPTION
-* Modifies the port info for the bound port to set the "IS_SM" bit
-* according to the value given (TRUE or FALSE).
-*
-* SYNOPSIS
-*/
-void osm_vendor_set_sm(IN osm_bind_handle_t h_bind, IN boolean_t is_sm_val);
-/*
-* PARAMETERS
-* h_bind
-* [in] bind handle for this port.
-*
-* is_sm_val
-* [in] If TRUE - will set the is_sm to TRUE, if FALSE - will set the
-* the is_sm to FALSE.
-*
-* RETURN VALUE
-* None.
-*
-* NOTES
-*
-* SEE ALSO
-*********/
-
-/****f* OpenSM Vendor API/osm_vendor_set_debug
-* NAME
-* osm_vendor_set_debug
-*
-* DESCRIPTION
-* Modifies the vendor specific debug level.
-*
-* SYNOPSIS
-*/
-void osm_vendor_set_debug(IN osm_vendor_t * const p_vend, IN int32_t level);
-/*
-* PARAMETERS
-* p_vend
-* [in] vendor handle.
-*
-* level
-* [in] vendor specific debug level.
-*
-* RETURN VALUE
-* None.
-*
-* NOTES
-*
-* SEE ALSO
-*********/
-
-END_C_DECLS
-#endif /* _OSM_VENDOR_API_H_ */
diff --git a/contrib/ofed/management/opensm/include/vendor/osm_vendor_ibumad.h b/contrib/ofed/management/opensm/include/vendor/osm_vendor_ibumad.h
deleted file mode 100644
index 3a3f070..0000000
--- a/contrib/ofed/management/opensm/include/vendor/osm_vendor_ibumad.h
+++ /dev/null
@@ -1,181 +0,0 @@
-/*
- * Copyright (c) 2004-2007 Voltaire, Inc. All rights reserved.
- * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved.
- * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- */
-
-#ifndef _OSM_VENDOR_UMAD_H_
-#define _OSM_VENDOR_UMAD_H_
-
-#include <iba/ib_types.h>
-#include <complib/cl_qlist.h>
-#include <opensm/osm_base.h>
-#include <opensm/osm_log.h>
-
-#include <infiniband/common.h>
-#include <infiniband/umad.h>
-
-#ifdef __cplusplus
-# define BEGIN_C_DECLS extern "C" {
-# define END_C_DECLS }
-#else /* !__cplusplus */
-# define BEGIN_C_DECLS
-# define END_C_DECLS
-#endif /* __cplusplus */
-
-BEGIN_C_DECLS
-/****h* OpenSM/Vendor Access Layer (UMAD)
-* NAME
-* Vendor UMAD
-*
-* DESCRIPTION
-* This file is the vendor specific file for the UMAD Infiniband API.
-*
-* AUTHOR
-*
-*
-*********/
-#define OSM_DEFAULT_RETRY_COUNT 3
-#define OSM_UMAD_MAX_CAS 32
-#define OSM_UMAD_MAX_PORTS_PER_CA 2
-/****s* OpenSM: Vendor UMAD/osm_ca_info_t
-* NAME
-* osm_ca_info_t
-*
-* DESCRIPTION
-* Structure containing information about local Channle Adapters.
-*
-* SYNOPSIS
-*/
-typedef struct _osm_ca_info {
- ib_net64_t guid;
- size_t attr_size;
- ib_ca_attr_t *p_attr;
-} osm_ca_info_t;
-/*
-* FIELDS
-* guid
-* Node GUID of the local CA.
-*
-* attr_size
-* Size of the CA attributes for this CA.
-*
-* p_attr
-* Pointer to dynamicly allocated CA Attribute structure.
-*
-* SEE ALSO
-*********/
-
-/****f* OpenSM: CA Info/osm_ca_info_get_num_ports
-* NAME
-* osm_ca_info_get_num_ports
-*
-* DESCRIPTION
-* Returns the number of ports owned by this CA.
-*
-* SYNOPSIS
-*/
-static inline uint8_t
-osm_ca_info_get_num_ports(IN const osm_ca_info_t * const p_ca_info)
-{
- return (p_ca_info->p_attr->num_ports);
-}
-
-/*
-* PARAMETERS
-* p_ca_info
-* [in] Pointer to a CA Info object.
-*
-* RETURN VUMADUE
-* Returns the number of ports owned by this CA.
-*
-* NOTES
-*
-* SEE ALSO
-*********/
-
-/****s* OpenSM: Vendor UMAD/osm_bind_handle_t
-* NAME
-* osm_bind_handle_t
-*
-* DESCRIPTION
-* handle returned by the vendor transport bind call.
-*
-* SYNOPSIS
-*/
-typedef void *osm_bind_handle_t;
-/***********/
-
-typedef struct _umad_match {
- ib_net64_t tid;
- void *v;
- uint32_t version;
-} umad_match_t;
-
-#define DEFAULT_OSM_UMAD_MAX_PENDING 1000
-
-typedef struct vendor_match_tbl {
- uint32_t last_version;
- int max;
- umad_match_t *tbl;
-} vendor_match_tbl_t;
-
-typedef struct _osm_vendor {
- osm_log_t *p_log;
- uint32_t ca_count;
- osm_ca_info_t *p_ca_info;
- uint32_t timeout;
- int max_retries;
- osm_bind_handle_t agents[UMAD_CA_MAX_AGENTS];
- char ca_names[OSM_UMAD_MAX_CAS][UMAD_CA_NAME_LEN];
- vendor_match_tbl_t mtbl;
- umad_port_t umad_port;
- pthread_mutex_t cb_mutex;
- pthread_mutex_t match_tbl_mutex;
- int umad_port_id;
- void *receiver;
- int issmfd;
- char issm_path[256];
-} osm_vendor_t;
-
-#define OSM_BIND_INVALID_HANDLE 0
-
-typedef struct _osm_vend_wrap {
- int agent;
- int size;
- int retries;
- void *umad;
- osm_bind_handle_t h_bind;
-} osm_vend_wrap_t;
-
-END_C_DECLS
-#endif /* _OSM_VENDOR_UMAD_H_ */
diff --git a/contrib/ofed/management/opensm/include/vendor/osm_vendor_mlx.h b/contrib/ofed/management/opensm/include/vendor/osm_vendor_mlx.h
deleted file mode 100644
index 106e0b4..0000000
--- a/contrib/ofed/management/opensm/include/vendor/osm_vendor_mlx.h
+++ /dev/null
@@ -1,96 +0,0 @@
-/*
- * Copyright (c) 2004, 2005 Voltaire, Inc. All rights reserved.
- * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved.
- * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- */
-
-#ifndef _OSMV_H_
-#define _OSMV_H_
-
-#include <sys/types.h>
-#include <opensm/osm_log.h>
-#include <complib/cl_qlist.h>
-
-#ifdef __cplusplus
-# define BEGIN_C_DECLS extern "C" {
-# define END_C_DECLS }
-#else /* !__cplusplus */
-# define BEGIN_C_DECLS
-# define END_C_DECLS
-#endif /* __cplusplus */
-
-BEGIN_C_DECLS
-/*
- Forward reference
-*/
-struct _osm_pkt_randomizer;
-
-/* The structure behind the OSM Vendor handle */
-
-typedef struct _osm_vendor {
-
- /* for holding common transport info - useful at ibmgt transport */
- void *p_transport_info;
-
- osm_log_t *p_log;
-
- /* Uniform timeout for every ACK/single MAD */
- uint32_t resp_timeout;
-
- /* Uniform timeout for every rmpp transaction */
- uint32_t ttime_timeout;
-
- /* All the bind handles associated with the vendor */
- cl_qlist_t bind_handles;
-
- /* run randomizer flag */
- boolean_t run_randomizer;
-
- /* Packet Randomizer object */
- struct _osm_pkt_randomizer *p_pkt_randomizer;
-
-} osm_vendor_t;
-
-/* Repeating the definitions in osm_vendor_api.h */
-
-typedef void *osm_bind_handle_t;
-
-typedef struct _osm_vend_wrap {
- ib_mad_t *p_mad;
-} osm_vend_wrap_t;
-
-#ifndef OSM_BIND_INVALID_HANDLE
-#define OSM_BIND_INVALID_HANDLE NULL
-#endif
-
-END_C_DECLS
-#endif
diff --git a/contrib/ofed/management/opensm/include/vendor/osm_vendor_mlx_defs.h b/contrib/ofed/management/opensm/include/vendor/osm_vendor_mlx_defs.h
deleted file mode 100644
index d4c2c30..0000000
--- a/contrib/ofed/management/opensm/include/vendor/osm_vendor_mlx_defs.h
+++ /dev/null
@@ -1,103 +0,0 @@
-/*
- * Copyright (c) 2004, 2005 Voltaire, Inc. All rights reserved.
- * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved.
- * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- */
-
-#ifndef _OSMV_DEFS_H_
-#define _OSMV_DEFS_H_
-
-#include <vendor/osm_vendor_mlx_inout.h>
-#include <opensm/osm_log.h>
-#include <vendor/osm_vendor_api.h>
-#include <vendor/osm_vendor_mlx_txn.h>
-
-#ifdef __cplusplus
-# define BEGIN_C_DECLS extern "C" {
-# define END_C_DECLS }
-#else /* !__cplusplus */
-# define BEGIN_C_DECLS
-# define END_C_DECLS
-#endif /* __cplusplus */
-
-BEGIN_C_DECLS
-/* The maximum number of outstanding MADs an RMPP sender can transmit */
-#define OSMV_RMPP_RECV_WIN 16
-/* The maximum number of retransmissions of the same MAD */
-#define OSMV_MAX_RETRANSMIT 3
-/* Transaction Timeout = OSMV_TXN_TIMEOUT_FACTOR * Response Timeout */
-#define OSMV_TXN_TIMEOUT_FACTOR 128
-/************/
-/****s* OSM Vendor: Types/osmv_bind_obj_t
-* NAME
-* osmv_bind_obj_t
-*
-* DESCRIPTION
-* The object managing a single bind context.
-* The bind handle is a direct pointer to it.
-*
-* SYNOPSIS
-*/
-typedef struct _osmv_bind_obj {
- /* Used to signal when the struct is being destroyed */
- struct _osmv_bind_obj *magic_ptr;
-
- osm_vendor_t /*const */ * p_vendor;
-
- uint32_t hca_hndl;
- uint32_t port_num;
-
- /* Atomic access protector */
- cl_spinlock_t lock;
-
- /* is_closing == TRUE --> the handle is being unbound */
- boolean_t is_closing;
-
- /* Event callbacks */
- osm_vend_mad_recv_callback_t recv_cb;
- osm_vend_mad_send_err_callback_t send_err_cb;
- /* ... and their context */
- void *cb_context;
-
- /* A pool to manage MAD wrappers */
- osm_mad_pool_t *p_osm_pool;
-
- /* each subvendor implements its own transport mgr */
- void *p_transp_mgr;
-
- /* The transaction DB */
- osmv_txn_mgr_t txn_mgr;
-
-} osmv_bind_obj_t;
-
-END_C_DECLS
-#endif /* _OSMV_DEFS_H_ */
diff --git a/contrib/ofed/management/opensm/include/vendor/osm_vendor_mlx_svc.h b/contrib/ofed/management/opensm/include/vendor/osm_vendor_mlx_svc.h
deleted file mode 100644
index f23a77d..0000000
--- a/contrib/ofed/management/opensm/include/vendor/osm_vendor_mlx_svc.h
+++ /dev/null
@@ -1,201 +0,0 @@
-/*
- * Copyright (c) 2004, 2005 Voltaire, Inc. All rights reserved.
- * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved.
- * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- */
-
-#ifndef _OSMV_SVC_H_
-#define _OSMV_SVC_H_
-
-#include <stdlib.h>
-#include <string.h>
-#include <iba/ib_types.h>
-#include <vendor/osm_vendor_mlx_defs.h>
-
-#ifdef __cplusplus
-# define BEGIN_C_DECLS extern "C" {
-# define END_C_DECLS }
-#else /* !__cplusplus */
-# define BEGIN_C_DECLS
-# define END_C_DECLS
-#endif /* __cplusplus */
-
-BEGIN_C_DECLS
-inline static boolean_t osmv_mad_is_response(IN const ib_mad_t * p_mad)
-{
- return (ib_mad_is_response(p_mad) ||
- (p_mad->method == IB_MAD_METHOD_TRAP_REPRESS));
-}
-
-inline static uint8_t osmv_invert_method(IN uint8_t req_method)
-{
- switch (req_method) {
- case IB_MAD_METHOD_GET_RESP:
- /* Not a 1-1 mapping! */
- return IB_MAD_METHOD_GET;
-
- case IB_MAD_METHOD_GET:
- return IB_MAD_METHOD_GET_RESP;
-
- case IB_MAD_METHOD_SET:
- return IB_MAD_METHOD_GET_RESP;
-
- case IB_MAD_METHOD_GETTABLE_RESP:
- return IB_MAD_METHOD_GETTABLE;
-
- case IB_MAD_METHOD_GETTABLE:
- return IB_MAD_METHOD_GETTABLE_RESP;
-
- case IB_MAD_METHOD_GETMULTI_RESP:
- /* Not a 1-1 mapping! */
- return IB_MAD_METHOD_GETMULTI;
-
- case IB_MAD_METHOD_GETTRACETABLE:
- case IB_MAD_METHOD_GETMULTI:
- return IB_MAD_METHOD_GETMULTI_RESP;
-
- case IB_MAD_METHOD_TRAP:
- return IB_MAD_METHOD_TRAP_REPRESS;
-
- case IB_MAD_METHOD_TRAP_REPRESS:
- return IB_MAD_METHOD_TRAP;
-
- case IB_MAD_METHOD_REPORT:
- return IB_MAD_METHOD_REPORT_RESP;
-
- case IB_MAD_METHOD_REPORT_RESP:
- return IB_MAD_METHOD_REPORT;
-
- /* IB_MAD_METHOD_SEND does not have a response */
- case IB_MAD_METHOD_SEND:
- return IB_MAD_METHOD_SEND;
-
- default:
- CL_ASSERT(FALSE);
- }
-
- return 0; /* Just make the compiler happy */
-}
-
-inline static boolean_t osmv_mad_is_rmpp(IN const ib_mad_t * p_mad)
-{
- uint8_t rmpp_flags;
- CL_ASSERT(NULL != p_mad);
-
- rmpp_flags = ((ib_rmpp_mad_t *) p_mad)->rmpp_flags;
- /* HACK - JUST SA and DevMgt for now - need to add BIS and DevAdm */
- if ((p_mad->mgmt_class != IB_MCLASS_SUBN_ADM) &&
- (p_mad->mgmt_class != IB_MCLASS_DEV_MGMT))
- return (0);
- return (0 != (rmpp_flags & IB_RMPP_FLAG_ACTIVE));
-}
-
-inline static boolean_t osmv_mad_is_multi_resp(IN const ib_mad_t * p_mad)
-{
- CL_ASSERT(NULL != p_mad);
- return (IB_MAD_METHOD_GETMULTI == p_mad->method
- || IB_MAD_METHOD_GETTRACETABLE == p_mad->method);
-}
-
-inline static boolean_t osmv_mad_is_sa(IN const ib_mad_t * p_mad)
-{
- CL_ASSERT(NULL != p_mad);
- return (IB_MCLASS_SUBN_ADM == p_mad->mgmt_class);
-}
-
-inline static boolean_t osmv_rmpp_is_abort_stop(IN const ib_mad_t * p_mad)
-{
- uint8_t rmpp_type;
- CL_ASSERT(p_mad);
-
- rmpp_type = ((ib_rmpp_mad_t *) p_mad)->rmpp_type;
- return (IB_RMPP_TYPE_STOP == rmpp_type
- || IB_RMPP_TYPE_ABORT == rmpp_type);
-}
-
-inline static boolean_t osmv_rmpp_is_data(IN const ib_mad_t * p_mad)
-{
- CL_ASSERT(p_mad);
- return (IB_RMPP_TYPE_DATA == ((ib_rmpp_mad_t *) p_mad)->rmpp_type);
-}
-
-inline static boolean_t osmv_rmpp_is_ack(IN const ib_mad_t * p_mad)
-{
- CL_ASSERT(p_mad);
- return (IB_RMPP_TYPE_ACK == ((ib_rmpp_mad_t *) p_mad)->rmpp_type);
-}
-
-inline static boolean_t osmv_rmpp_is_first(IN const ib_mad_t * p_mad)
-{
- uint8_t rmpp_flags;
- CL_ASSERT(NULL != p_mad);
-
- rmpp_flags = ((ib_rmpp_mad_t *) p_mad)->rmpp_flags;
- return (0 != (IB_RMPP_FLAG_FIRST & rmpp_flags));
-}
-
-inline static boolean_t osmv_rmpp_is_last(IN const ib_mad_t * p_mad)
-{
- uint8_t rmpp_flags;
- CL_ASSERT(NULL != p_mad);
-
- rmpp_flags = ((ib_rmpp_mad_t *) p_mad)->rmpp_flags;
- return (0 != (IB_RMPP_FLAG_LAST & rmpp_flags));
-}
-
-inline static uint8_t *osmv_mad_copy(IN const ib_mad_t * p_mad)
-{
- uint8_t *p_copy;
-
- CL_ASSERT(p_mad);
- p_copy = malloc(MAD_BLOCK_SIZE);
-
- if (NULL != p_copy) {
- memset(p_copy, 0, MAD_BLOCK_SIZE);
- memcpy(p_copy, p_mad, MAD_BLOCK_SIZE);
- }
-
- return p_copy;
-}
-
-/* Should be passed externally from the Makefile */
-/* #define OSMV_RANDOM_DROP 1 */
-#define OSMV_DROP_RATE 0.3
-
-inline static boolean_t osmv_random_drop(void)
-{
- srand(1); /* Pick a new base */
- return (rand() / (double)RAND_MAX < OSMV_DROP_RATE);
-}
-
-END_C_DECLS
-#endif /* _OSMV_SVC_H_ */
diff --git a/contrib/ofed/management/opensm/include/vendor/osm_vendor_sa_api.h b/contrib/ofed/management/opensm/include/vendor/osm_vendor_sa_api.h
deleted file mode 100644
index 4a4eeaf..0000000
--- a/contrib/ofed/management/opensm/include/vendor/osm_vendor_sa_api.h
+++ /dev/null
@@ -1,866 +0,0 @@
-/*
- * Copyright (c) 2004-2006 Voltaire, Inc. All rights reserved.
- * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved.
- * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- */
-
-/*
- * Abstract:
- * Specification of the OpenSM SA Client API. This API uses the basic osm
- * vendor API to provide SA Client interface.
- */
-
-#ifndef _OSM_VENDOR_SA_API_H_
-#define _OSM_VENDOR_SA_API_H_
-
-#include <iba/ib_types.h>
-
-#ifdef __cplusplus
-# define BEGIN_C_DECLS extern "C" {
-# define END_C_DECLS }
-#else /* !__cplusplus */
-# define BEGIN_C_DECLS
-# define END_C_DECLS
-#endif /* __cplusplus */
-
-BEGIN_C_DECLS
-/****d* OpenSM Vendor SA Client/osmv_flags_t
-* NAME
-* osmv_flags_t
-*
-* DESCRIPTION
-* Access layer flags used to direct the operation of various calls.
-*
-* SYNOPSIS
-*/
-typedef uint32_t osmv_flags_t;
-#define OSM_SA_FLAGS_SYNC 0x00000001
-/*
-* VALUES
-* OSM_SA_FLAGS_SYNC
-* Indicates that the given operation should be performed synchronously.
-* The call will block until it completes. Callbacks will still be
-* invoked.
-*
-* SEE ALSO
-* osmv_query_sa
-*****/
-
-/****d* OpenSM Vendor SA Client/osmv_query_type_t
-* NAME
-* osmv_query_type_t
-*
-* DESCRIPTION
-* Abstracted queries supported by the access layer.
-*
-* SYNOPSIS
-*/
-typedef enum _osmv_query_type {
- OSMV_QUERY_USER_DEFINED,
-
- OSMV_QUERY_ALL_SVC_RECS,
- OSMV_QUERY_SVC_REC_BY_NAME,
- OSMV_QUERY_SVC_REC_BY_ID,
-
- OSMV_QUERY_CLASS_PORT_INFO,
-
- OSMV_QUERY_NODE_REC_BY_NODE_GUID,
- OSMV_QUERY_PORT_REC_BY_LID,
- OSMV_QUERY_PORT_REC_BY_LID_AND_NUM,
-
- OSMV_QUERY_VLARB_BY_LID_PORT_BLOCK,
- OSMV_QUERY_SLVL_BY_LID_AND_PORTS,
-
- OSMV_QUERY_PATH_REC_BY_PORT_GUIDS,
- OSMV_QUERY_PATH_REC_BY_GIDS,
- OSMV_QUERY_PATH_REC_BY_LIDS,
-
- OSMV_QUERY_UD_MULTICAST_SET,
- OSMV_QUERY_UD_MULTICAST_DELETE,
-
- OSMV_QUERY_MULTIPATH_REC,
-
-} osmv_query_type_t;
-/*
-* VALUES
-* OSMV_QUERY_USER_DEFINED
-* Query the SA based on user-defined input. Queries of this type
-* should reference an osmv_user_query_t structure as input to the
-* query.
-*
-* OSMV_QUERY_SVC_REC_BY_NAME
-* Query for service records based on the service name. Queries of
-* this type should reference an ib_svc_name_t structure as input
-* to the query.
-*
-* OSMV_QUERY_SVC_REC_BY_ID
-* Query for service records based on the service ID. Queries of
-* this type should reference an ib_net64_t value that indicates
-* the ID of the service being requested.
-*
-* OSMV_QUERY_NODE_REC_BY_NODE_GUID
-* Query for node information based on the node's GUID. Queries of
-* this type should reference an ib_net64_t value that indicates
-* the GUID of the node being requested.
-*
-* OSMV_QUERY_PORT_REC_BY_LID
-* Query for port information based on the port's base LID. Queries
-* of this type should reference an ib_net16_t value that indicates
-* the base LID of the port being requested.
-*
-* OSMV_QUERY_PORT_REC_BY_LID_AND_NUM
-* Query for port information based on the port's LID and port num.
-* Queries of this type should reference an osmv_user_query_t
-* structure as input to the query. The port num and lid should
-* be provided by it.
-*
-* OSMV_QUERY_PATH_REC_BY_PORT_GUIDS
-* Query for path records between the specified pair of port GUIDs.
-* Queries of this type should reference an osmv_guid_pair_t
-* structure that indicates the GUIDs of the path being requested.
-*
-* OSMV_QUERY_PATH_REC_BY_GIDS
-* Query for path records between the specified pair of port GIDs.
-* Queries of this type should reference an osmv_gid_pair_t
-* structure that indicates the GIDs of the path being requested.
-*
-* OSMV_QUERY_PATH_REC_BY_LIDS
-* Query for path records between the specified pair of port LIDs.
-* Queries of this type should reference an osmv_lid_pair_t
-* structure that indicates the LIDs of the path being requested.
-*
-* NOTES
-* This enum is used to define abstracted queries provided by the access
-* layer. Users may issue queries not listed here by sending MADs directly
-* to subnet administration or a class manager. These queries are
-* intended to represent those most often used by clients.
-*
-* SEE ALSO
-* osmv_query, osmv_query_req_t, osmv_user_query_t, osmv_gid_pair_t,
-* osmv_lid_pair_t osmv_guid_pair_t
-*****/
-
-/****s* OpenSM Vendor SA Client/osmv_user_query_t
-* NAME
-* osmv_user_query_t
-*
-* DESCRIPTION
-* User-defined query information.
-*
-* SYNOPSIS
-*/
-typedef struct _osmv_user_query {
- uint8_t method;
- ib_net16_t attr_id;
- ib_net16_t attr_offset;
- ib_net32_t attr_mod;
- ib_net64_t comp_mask;
- void *p_attr;
-} osmv_user_query_t;
-/*
-* FIELDS
-*
-* method
-* Method to be used
-*
-* attr_id
-* Attribute identifier of query data.
-*
-* attr_offset
-* Size of the query attribute, in 8-byte words. Users can set
-* this value by passing in the sizeof( attribute ) into the
-* ib_get_attr_offset() routine.
-*
-* attr_mod
-* Attribute modifier for query request.
-*
-* comp_mask
-* Indicates the attribute components that are specified for the
-* query.
-*
-* p_attr
-* References the attribute structure used as input into the query.
-* This field is ignored if comp_mask is set to 0.
-*
-* NOTES
-* This structure is used to describe a user-defined query. The attribute
-* ID, attribute offset, component mask, and attribute structure must match
-* those defined by the IBA specification. Users should refer to chapter
-* 15 of the IBA specification for additional details.
-*
-* SEE ALSO
-* osmv_query_type_t, ib_get_attr_offset, ib_get_attr_size, osmv_query_sa
-*****/
-
-/****s* OpenSM Vendor SA Client/osmv_gid_pair_t
-* NAME
-* osmv_gid_pair_t
-*
-* DESCRIPTION
-* Source and destination GIDs.
-*
-* SYNOPSIS
-*/
-typedef struct _osmv_gid_pair {
- ib_gid_t src_gid;
- ib_gid_t dest_gid;
-} osmv_gid_pair_t;
-/*
-* FIELDS
-* src_gid
-* Source GID of a path.
-*
-* dest_gid
-* Destination GID of a path.
-*
-* NOTES
-* This structure is used to describe the endpoints of a path.
-*
-* SEE ALSO
-* ib_gid_t
-*****/
-
-/****s* OpenSM Vendor SA Client/osmv_lid_pair_t
-* NAME
-* osmv_lid_pair_t
-*
-* DESCRIPTION
-* Source and destination LIDs.
-*
-* SYNOPSIS
-*/
-typedef struct _osmv_lid_pair {
- ib_net16_t src_lid;
- ib_net16_t dest_lid;
-} osmv_lid_pair_t;
-/*
-* FIELDS
-* src_lid
-* Source LID of a path.
-*
-* dest_lid
-* Destination LID of a path.
-*
-* NOTES
-* This structure is used to describe the endpoints of a path.
-*****/
-
-/****s* OpenSM Vendor SA Client/osmv_guid_pair_t
-* NAME
-* osmv_guid_pair_t
-*
-* DESCRIPTION
-* Source and destination GUIDs. These may be port or channel adapter
-* GUIDs, depending on the context in which this structure is used.
-*
-* SYNOPSIS
-*/
-typedef struct _osmv_guid_pair {
- ib_net64_t src_guid;
- ib_net64_t dest_guid;
-} osmv_guid_pair_t;
-/*
-* FIELDS
-* src_guid
-* Source GUID of a path.
-*
-* dest_guid
-* Destination GUID of a path.
-*
-* NOTES
-* This structure is used to describe the endpoints of a path. The given
-* GUID pair may belong to either ports or channel adapters.
-*
-* SEE ALSO
-* ib_guid_t
-*****/
-
-/****s* OpenSM Vendor SA Client/osmv_multipath_req_t
-* NAME
-* osmv_multipath_req_t
-*
-* DESCRIPTION
-* Fields from which to generate a MultiPathRecord request.
-*
-* SYNOPSIS
-*/
-typedef struct _osmv_multipath_req_t {
- ib_net64_t comp_mask;
- uint16_t pkey;
- boolean_t reversible;
- uint8_t num_path;
- uint8_t sl;
- uint8_t independence;
- uint8_t sgid_count;
- uint8_t dgid_count;
- ib_gid_t gids[IB_MULTIPATH_MAX_GIDS];
-} osmv_multipath_req_t;
-/*
-* FIELDS
-*
-* NOTES
-* This structure is used to describe a multipath request.
-*
-* SEE ALSO
-*****/
-
-/****s* OpenSM Vendor SA Client/osmv_query_res_t
-* NAME
-* osmv_query_res_t
-*
-* DESCRIPTION
-* Contains the results of a subnet administration query.
-*
-* SYNOPSIS
-*/
-typedef struct _osmv_query_res {
- const void *query_context;
- ib_api_status_t status;
- osmv_query_type_t query_type;
- uint32_t result_cnt;
- osm_madw_t *p_result_madw;
-} osmv_query_res_t;
-/*
-* FIELDS
-* query_context
-* User-defined context information associated with the query
-* through the osm_vendor_query_sa call.
-*
-* status
-* Indicates the success of the query operation.
-*
-* query_type
-* Indicates the type of query for which the results are being
-* returned. This matches the query_type specified through the
-* osm_vendor_query_sa call.
-*
-* result_cnt
-* The number of result structures that were returned by the query.
-*
-* p_result_madw
-* For queries returning IB_SUCCESS or IB_REMOTE_ERROR, this
-* references the MAD wrapper returned by subnet administration
-* containing the list of results or the returned error code.
-*
-* NOTES
-* A query result structure is returned to a client through their
-* osmv_pfn_query_cb_t routine to notify them of the results of a subnet
-* administration query. If the query was successful or received an error
-* from subnet administration, p_result_madw will reference a MAD wrapper
-* containing the results. The MAD referenced by p_result_madw is owned by
-* the user and remains available even after their callback returns. Users
-* must call osm_mad_pool_put() to return the MAD wrapper back to the
-* mad pool when they are done accessing the results.
-*
-* To retrieve individual result structures from the p_result_madw, users
-* may call osmv_get_query_result().
-*
-* SEE ALSO
-* osmv_query_sa, osmv_pfn_query_cb_t, ib_api_status_t,
-* osmv_query_status_t, osmv_query_type_t,
-* osmv_get_query_result
-*****/
-
-/****f* OpenSM Vendor SA Client/osmv_get_query_result
-* NAME
-* osmv_get_query_result
-*
-* DESCRIPTION
-* Retrieves a result structure from a MADW returned by a call to
-* osmv_query_sa().
-*
-* SYNOPSIS
-*/
-static inline void *osmv_get_query_result(IN osm_madw_t * p_result_madw,
- IN uint32_t result_index)
-{
- ib_sa_mad_t *p_sa_mad;
-
- CL_ASSERT(p_result_madw);
- p_sa_mad = (ib_sa_mad_t *) osm_madw_get_mad_ptr(p_result_madw);
- CL_ASSERT(p_sa_mad);
- CL_ASSERT(ib_get_attr_size(p_sa_mad->attr_offset) * (result_index + 1) +
- IB_SA_MAD_HDR_SIZE <= p_result_madw->mad_size);
-
- return (p_sa_mad->data +
- (ib_get_attr_size(p_sa_mad->attr_offset) * result_index));
-}
-
-/*
-* PARAMETERS
-* p_result_madw
-* [in] This is a reference to the MAD returned as a result of the
-* query.
-*
-* result_index
-* [in] A zero-based index indicating which result to return.
-*
-* NOTES
-* This call returns a pointer to the start of a result structure from a
-* call to osmv_query_sa(). The type of result structure must be known to
-* the user either through the user's context or the query_type returned as
-* part of the osmv_query_res_t structure.
-*
-* SEE ALSO
-* osmv_query_res_t, osm_madw_t
-*****/
-
-/****f* OpenSM Vendor SA Client/osmv_get_query_path_rec
-* NAME
-* osmv_get_query_path_rec
-*
-* DESCRIPTION
-* Retrieves a path record result from a MAD returned by a call to
-* osmv_query_sa().
-*
-* SYNOPSIS
-*/
-static inline ib_path_rec_t *osmv_get_query_path_rec(IN osm_madw_t *
- p_result_madw,
- IN uint32_t result_index)
-{
- ib_sa_mad_t *p_sa_mad;
-
- CL_ASSERT(p_result_madw);
- p_sa_mad = (ib_sa_mad_t *) osm_madw_get_mad_ptr(p_result_madw);
- CL_ASSERT(p_sa_mad && p_sa_mad->attr_id == IB_MAD_ATTR_PATH_RECORD);
-
- return ((ib_path_rec_t *)
- osmv_get_query_result(p_result_madw, result_index));
-}
-
-/*
-* PARAMETERS
-* p_result_madw
-* [in] This is a reference to the MAD returned as a result of the
-* query.
-*
-* result_index
-* [in] A zero-based index indicating which result to return.
-*
-* NOTES
-* This call returns a pointer to the start of a path record result from
-* a call to osmv_query_sa().
-*
-* SEE ALSO
-* osmv_query_res_t, osm_madw_t, osmv_get_query_result, ib_path_rec_t
-*****/
-
-/****f* OpenSM Vendor SA Client/osmv_get_query_portinfo_rec
-* NAME
-* osmv_get_query_portinfo_rec
-*
-* DESCRIPTION
-* Retrieves a port info record result from a MAD returned by a call to
-* osmv_query_sa().
-*
-* SYNOPSIS
-*/
-static inline ib_portinfo_record_t *osmv_get_query_portinfo_rec(IN osm_madw_t *
- p_result_madw,
- IN uint32_t
- result_index)
-{
- ib_sa_mad_t *p_sa_mad;
-
- CL_ASSERT(p_result_madw);
- p_sa_mad = (ib_sa_mad_t *) osm_madw_get_mad_ptr(p_result_madw);
- CL_ASSERT(p_sa_mad && p_sa_mad->attr_id == IB_MAD_ATTR_PORTINFO_RECORD);
-
- return ((ib_portinfo_record_t *) osmv_get_query_result(p_result_madw,
- result_index));
-}
-
-/*
-* PARAMETERS
-* p_result_madw
-* [in] This is a reference to the MAD returned as a result of the
-* query.
-*
-* result_index
-* [in] A zero-based index indicating which result to return.
-*
-* NOTES
-* This call returns a pointer to the start of a port info record result
-* from a call to osmv_query_sa().
-*
-* SEE ALSO
-* osmv_query_res_t, osm_madw_t, osmv_get_query_result, ib_portinfo_record_t
-*****/
-
-/****f* OpenSM Vendor SA Client/osmv_get_query_node_rec
-* NAME
-* osmv_get_query_node_rec
-*
-* DESCRIPTION
-* Retrieves a node record result from a MAD returned by a call to
-* osmv_query_sa().
-*
-* SYNOPSIS
-*/
-static inline ib_node_record_t *osmv_get_query_node_rec(IN osm_madw_t *
- p_result_madw,
- IN uint32_t
- result_index)
-{
- ib_sa_mad_t *p_sa_mad;
-
- CL_ASSERT(p_result_madw);
- p_sa_mad = (ib_sa_mad_t *) osm_madw_get_mad_ptr(p_result_madw);
- CL_ASSERT(p_sa_mad && p_sa_mad->attr_id == IB_MAD_ATTR_NODE_RECORD);
-
- return ((ib_node_record_t *) osmv_get_query_result(p_result_madw,
- result_index));
-}
-
-/*
-* PARAMETERS
-* p_result_madw
-* [in] This is a reference to the MAD returned as a result of the
-* query.
-*
-* result_index
-* [in] A zero-based index indicating which result to return.
-*
-* NOTES
-* This call returns a pointer to the start of a node record result from
-* a call to osmv_query_sa().
-*
-* SEE ALSO
-* osmv_query_res_t, osm_madw_t, osmv_get_query_result, ib_node_record_t
-*****/
-
-/****f* OpenSM Vendor SA Client/osmv_get_query_svc_rec
-* NAME
-* osmv_get_query_svc_rec
-*
-* DESCRIPTION
-* Retrieves a service record result from a MAD returned by a call to
-* osmv_query_sa().
-*
-* SYNOPSIS
-*/
-static inline ib_service_record_t *osmv_get_query_svc_rec(IN osm_madw_t *
- p_result_madw,
- IN uint32_t
- result_index)
-{
- ib_sa_mad_t *p_sa_mad;
-
- CL_ASSERT(p_result_madw);
- p_sa_mad = (ib_sa_mad_t *) osm_madw_get_mad_ptr(p_result_madw);
- CL_ASSERT(p_sa_mad && p_sa_mad->attr_id == IB_MAD_ATTR_SERVICE_RECORD);
-
- return ((ib_service_record_t *) osmv_get_query_result(p_result_madw,
- result_index));
-}
-
-/*
-* PARAMETERS
-* p_result_madw
-* [in] This is a reference to the MAD returned as a result of the
-* query.
-*
-* result_index
-* [in] A zero-based index indicating which result to return.
-*
-* NOTES
-* This call returns a pointer to the start of a service record result from
-* a call to osmv_query_sa().
-*
-* SEE ALSO
-* osmv_query_res_t, osm_madw_t, osmv_get_query_result, ib_service_record_t
-*****/
-
-/****f* OpenSM Vendor SA Client/osmv_get_query_mc_rec
-* NAME
-* osmv_get_query_mc_rec
-*
-* DESCRIPTION
-* Retrieves a multicast record result from a MAD returned by a call to
-* osmv_query_sa().
-*
-* SYNOPSIS
-*/
-static inline ib_member_rec_t *osmv_get_query_mc_rec(IN osm_madw_t *
- p_result_madw,
- IN uint32_t result_index)
-{
- ib_sa_mad_t *p_sa_mad;
-
- CL_ASSERT(p_result_madw);
- p_sa_mad = (ib_sa_mad_t *) osm_madw_get_mad_ptr(p_result_madw);
- CL_ASSERT(p_sa_mad && p_sa_mad->attr_id == IB_MAD_ATTR_MCMEMBER_RECORD);
-
- return ((ib_member_rec_t *) osmv_get_query_result(p_result_madw,
- result_index));
-}
-
-/*
-* PARAMETERS
-* p_result_madw
-* [in] This is a reference to the MAD returned as a result of the
-* query.
-*
-* result_index
-* [in] A zero-based index indicating which result to return.
-*
-* NOTES
-* This call returns a pointer to the start of a service record result from
-* a call to osmv_query_sa().
-*
-* SEE ALSO
-* osmv_query_res_t, osm_madw_t, osmv_get_query_result, ib_member_rec_t
-*****/
-
-/****f* OpenSM Vendor SA Client/osmv_get_query_inform_info_rec
-* NAME
-* osmv_get_query_inform_info_rec
-*
-* DESCRIPTION
-* Retrieves an InformInfo record result from a MAD returned by
-* a call to osmv_query_sa().
-*
-* SYNOPSIS
-*/
-static inline ib_inform_info_record_t *osmv_get_query_inform_info_rec(IN
- osm_madw_t
- *
- p_result_madw,
- IN
- uint32_t
- result_index)
-{
- ib_sa_mad_t *p_sa_mad;
-
- CL_ASSERT(p_result_madw);
- p_sa_mad = (ib_sa_mad_t *) osm_madw_get_mad_ptr(p_result_madw);
- CL_ASSERT(p_sa_mad
- && p_sa_mad->attr_id == IB_MAD_ATTR_INFORM_INFO_RECORD);
-
- return ((ib_inform_info_record_t *) osmv_get_query_result(p_result_madw,
- result_index));
-}
-
-/*
-* PARAMETERS
-* p_result_madw
-* [in] This is a reference to the MAD returned as a result of the
-* query.
-*
-* result_index
-* [in] A zero-based index indicating which result to return.
-*
-* NOTES
-* This call returns a pointer to the start of a service record result from
-* a call to osmv_query_sa().
-*
-* SEE ALSO
-* osmv_query_res_t, osm_madw_t, osmv_get_query_result, ib_inform_info_record_t
-*****/
-
-/****f* OpenSM Vendor SA Client/osmv_pfn_query_cb_t
-* NAME
-* osmv_pfn_query_cb_t
-*
-* DESCRIPTION
-* User-defined callback invoked on completion of subnet administration
-* query.
-*
-* SYNOPSIS
-*/
-typedef void
- (*osmv_pfn_query_cb_t) (IN osmv_query_res_t * p_query_res);
-/*
-* PARAMETERS
-* p_query_res
-* [in] This is a reference to a structure containing the result of
-* the query.
-*
-* NOTES
-* This routine is invoked to notify a client of the result of a subnet
-* administration query. The p_query_rec parameter references the result
-* of the query and, in the case of a successful query, any information
-* returned by subnet administration.
-*
-* In the kernel, this callback is usually invoked using a tasklet,
-* dependent on the implementation of the underlying verbs provider driver.
-*
-* SEE ALSO
-* osmv_query_res_t
-*****/
-
-/****s* OpenSM Vendor SA Client/osmv_query_req_t
-* NAME
-* osmv_query_req_t
-*
-* DESCRIPTION
-* Information used to request an access layer provided query of subnet
-* administration.
-*
-* SYNOPSIS
-*/
-typedef struct _osmv_query_req {
- osmv_query_type_t query_type;
- const void *p_query_input;
- ib_net64_t sm_key;
-
- uint32_t timeout_ms;
- uint32_t retry_cnt;
- osmv_flags_t flags;
-
- const void *query_context;
- osmv_pfn_query_cb_t pfn_query_cb;
-} osmv_query_req_t;
-/*
-* FIELDS
-* query_type
-* Indicates the type of query that the access layer should
-* perform.
-*
-* p_query_input
-* A pointer to the input for the query. The data referenced by
-* this structure is dependent on the type of query being requested
-* and is determined by the specified query_type.
-*
-* sm_key
-* The M_Key to be provided with the SA MAD for authentication.
-* Normally 0 is used.
-*
-* timeout_ms
-* Specifies the number of milliseconds to wait for a response for
-* this query until retrying or timing out the request.
-*
-* retry_cnt
-* Specifies the number of times that the query will be retried
-* before failing the request.
-*
-* flags
-* Used to describe the mode of operation. Set to IB_FLAGS_SYNC to
-* process the called routine synchronously.
-*
-* query_context
-* User-defined context information associated with this query.
-* The context data is returned to the user as a part of their
-* query callback.
-*
-* pfn_query_cb
-* A user-defined callback that is invoked upon completion of the
-* query.
-*
-* NOTES
-* This structure is used when requesting an osm vendor provided query
-* of subnet administration. Clients specify the type of query through
-* the query_type field. Based on the type of query, the p_query_input
-* field is set to reference the appropriate data structure.
-*
-* The information referenced by the p_query_input field is one of the
-* following:
-*
-* -- a NULL terminated service name
-* -- a service id
-* -- a single GUID
-* -- a pair of GUIDs specified through an osmv_guid_pair_t structure
-* -- a pair of GIDs specified through an osmv_gid_pair_t structure
-*
-* SEE ALSO
-* osmv_query_type_t, osmv_pfn_query_cb_t, osmv_guid_pair_t,
-* osmv_gid_pair_t
-*****/
-
-/****f* OpenSM Vendor SA Client/osmv_bind_sa
-* NAME
-* osmv_bind_sa
-*
-* DESCRIPTION
-* Bind to the SA service and return a handle to be used for later
-* queries.
-*
-*
-* SYNOPSIS
-*/
-osm_bind_handle_t
-osmv_bind_sa(IN osm_vendor_t * const p_vend,
- IN osm_mad_pool_t * const p_mad_pool, IN ib_net64_t port_guid);
-/*
-* PARAMETERS
-* p_vend
-* [in] an osm_vendor object to work with
-*
-* p_mad_pool
-* [in] mad pool to obtain madw from
-*
-* port_guid
-* [in] the port guid to attach to.
-*
-* RETURN VALUE
-* Bind handle to be used for later SA queries or OSM_BIND_INVALID_HANDLE
-*
-* NOTES
-*
-* SEE ALSO
-* osmv_query_sa
-*********/
-
-/****f* OpenSM Vendor SA Client/osmv_query_sa
-* NAME
-* osmv_query_sa
-*
-* DESCRIPTION
-* Query the SA given an SA query request (similar to IBAL ib_query).
-*
-* SYNOPSIS
-*/
-ib_api_status_t
-osmv_query_sa(IN osm_bind_handle_t h_bind,
- IN const osmv_query_req_t * const p_query_req);
-/*
-* PARAMETERS
-* h_bind
-* [in] bind handle for this port. Should be previously
-* obtained by calling osmv_bind_sa
-*
-* p_query_req
-* [in] an SA query request structure.
-*
-* RETURN VALUE
-* IB_SUCCESS if completed successfuly (or in ASYNC mode
-* if the request was sent).
-*
-* NOTES
-*
-* SEE ALSO
-* osmv_bind_sa
-*********/
-
-END_C_DECLS
-#endif /* _OSM_VENDOR_SA_API_H_ */
diff --git a/contrib/ofed/management/opensm/libvendor/ChangeLog b/contrib/ofed/management/opensm/libvendor/ChangeLog
deleted file mode 100644
index c9648ec..0000000
--- a/contrib/ofed/management/opensm/libvendor/ChangeLog
+++ /dev/null
@@ -1,64 +0,0 @@
-2007-07-11 Hal Rosenstock <halr@voltaire.com>
-
- * configure.in: Bump version to 2.2.1
-
-2007-07-10 Sean Hefty <sean.hefty@intel.com>
-
- * osm_vendor_ibumad.c: Use pkey index, rather than pkey
- on umad_set_pkey call. Using index 0 for now.
-
-2007-05-07 Hal Rosenstock <halr@voltaire.com>
-
- * osm_vendor_ibumad.(h c): Remove support for issmdisabled
-
-2007-03-29 Hal Rosenstock <halr@voltaire.com>
-
- * configure.in: Bump version to 2.2.0
-
-2007-03-27 Hal Rosenstock <halr@voltaire.com>
-
- * osm_vendor_ibumad.(h c): Add support for issmdisabled
-
-2007-03-13 Hal Rosenstock <halr@voltaire.com>
-
- * osm_vendor_ibumad.c: In osm_vendor_set_sm, set issmfd to
- -1 on open error
-
-2007-03-12 Hal Rosenstock <halr@voltaire.com>
-
- * osm_vendor_ibumad.c: In umad_receiver, display DR path of
- sent MAD when it times out. In osm_vendor_send, simplify redundant
- code. Cosmetic change to osm_log message in osm_vendor_bind.
-
-2007-02-20 Hal Rosenstock <halr@voltaire.com>
-
- * configure.in: Bump version to 2.1.1
-
-2007-02-20 Sasha Khapyorsky <sashak@voltaire.com>
-
- * osm_vendor_ibumad.(h c): Fix termination crash associated
- with umad_receiver thread termination.
-
- * osm_vendor_mlx_sa.c, osm_vendor_mlx_sim.c: Changes for
- compilation failures detected during ibutils/ibmgtsim building
-
-2007=01-10 Sasha Khapyorsky <sashak@voltaire.com>
-
- * osm_vendor_ibumad.c: Close umad port in
- osm_vendor_delete so same process can reinitialize
- and resuse vendor layer.
-
-2006-10-12 Hal Rosenstock <halr@voltaire.com>
-
- * osm_vendor_ibumad.c (umad_receiver): Fix endian of LID
- displayed in send timeout error message.
-
-2006-10-10 Hal Rosenstock <halr@voltaire.com>
-
- * osm_vendor_ibumad.c: Print errors to stderr rather than
- stdout.
-
-2006-09-28 Eitan Zahavi <eitan@mellanox.co.il>
-
- * osm_vendor_mlx_sa.c: Missing status on timeout SA query.
-
diff --git a/contrib/ofed/management/opensm/libvendor/Makefile.am b/contrib/ofed/management/opensm/libvendor/Makefile.am
deleted file mode 100644
index 22f7a08..0000000
--- a/contrib/ofed/management/opensm/libvendor/Makefile.am
+++ /dev/null
@@ -1,86 +0,0 @@
-
-SUBDIRS = .
-
-if DEBUG
-DBGFLAGS = -ggdb -D_DEBUG_
-else
-DBGFLAGS = -g
-endif
-
-INCLUDES = $(OSMV_INCLUDES)
-
-lib_LTLIBRARIES = libosmvendor.la
-
-libosmvendor_la_CFLAGS = -Wall $(DBGFLAGS)
-
-if HAVE_LD_VERSION_SCRIPT
- libosmvendor_version_script = -Wl,--version-script=$(srcdir)/libosmvendor.map
-else
- libosmvendor_version_script =
-endif
-
-osmvendor_api_version=$(shell grep LIBVERSION= $(srcdir)/libosmvendor.ver | sed 's/LIBVERSION=//')
-
-COMM_HDRS= $(srcdir)/../include/vendor/osm_vendor_api.h \
- $(srcdir)/../include/vendor/osm_vendor.h \
- $(srcdir)/../include/vendor/osm_vendor_sa_api.h
-
-if OSMV_OPENIB
-libosmvendor_la_SOURCES = osm_vendor_ibumad.c \
- osm_vendor_ibumad_sa.c
-HDRS =$(COMM_HDRS) $(srcdir)/../include/vendor/osm_vendor_ibumad.h
-endif
-if OSMV_SIM
-libosmvendor_la_SOURCES = osm_vendor_mlx.c \
- osm_vendor_mlx_sim.c \
- osm_vendor_mlx_hca_sim.c \
- osm_vendor_mlx_dispatcher.c \
- osm_vendor_mlx_rmpp_ctx.c \
- osm_vendor_mlx_sar.c \
- osm_vendor_mlx_sender.c \
- osm_vendor_mlx_txn.c \
- osm_vendor_mlx_sa.c \
- osm_pkt_randomizer.c
-HDRS =$(COMM_HDRS) $(srcdir)/../include/vendor/osm_vendor_mlx.h \
- $(srcdir)/../include/vendor/osm_pkt_randomizer.h
-endif
-if OSMV_GEN1
-libosmvendor_la_SOURCES = osm_vendor_mlx.c \
- osm_pkt_randomizer.c \
- osm_vendor_mlx_hca.c \
- osm_vendor_mlx_dispatcher.c \
- osm_vendor_mlx_rmpp_ctx.c \
- osm_vendor_mlx_sar.c \
- osm_vendor_mlx_sender.c \
- osm_vendor_mlx_ts.c \
- osm_vendor_mlx_txn.c \
- osm_vendor_mlx_sa.c
-HDRS =$(COMM_HDRS) $(srcdir)/../include/vendor/osm_vendor_mlx.h \
- $(srcdir)/../include/vendor/osm_pkt_randomizer.h
-endif
-if OSMV_VAPI
-libosmvendor_la_SOURCES = osm_vendor_mlx.c \
- osm_pkt_randomizer.c \
- osm_vendor_mlx_hca.c \
- osm_vendor_mlx_dispatcher.c \
- osm_vendor_mlx_rmpp_ctx.c \
- osm_vendor_mlx_sar.c \
- osm_vendor_mlx_sender.c \
- osm_vendor_mlx_ibmgt.c \
- osm_vendor_mlx_txn.c \
- osm_vendor_mlx_sa.c
-HDRS =$(COMM_HDRS) $(srcdir)/../include/vendor/osm_vendor_mlx.h \
- $(srcdir)/../include/vendor/osm_pkt_randomizer.h
-endif
-
-libosmvendor_la_LIBADD = -L../complib -losmcomp
-libosmvendor_la_LDFLAGS = -version-info $(osmvendor_api_version) \
- -export-dynamic $(libosmvendor_version_script)
-libosmvendor_la_DEPENDENCIES = $(srcdir)/libosmvendor.map
-
-libosmvendorincludedir = $(includedir)/infiniband/vendor
-
-libosmvendorinclude_HEADERS = $(HDRS)
-
-# headers are distributed as part of the include dir
-EXTRA_DIST = $(srcdir)/libosmvendor.map $(srcdir)/libosmvendor.ver
diff --git a/contrib/ofed/management/opensm/libvendor/libosmvendor.ver b/contrib/ofed/management/opensm/libvendor/libosmvendor.ver
deleted file mode 100644
index 0c3a85b..0000000
--- a/contrib/ofed/management/opensm/libvendor/libosmvendor.ver
+++ /dev/null
@@ -1,9 +0,0 @@
-# In this file we track the current API version
-# of the vendor interface (and libraries)
-# The version is built of the following
-# tree numbers:
-# API_REV:RUNNING_REV:AGE
-# API_REV - advance on any added API
-# RUNNING_REV - advance any change to the vendor files
-# AGE - number of backward versions the API still supports
-LIBVERSION=2:0:0
diff --git a/contrib/ofed/management/opensm/libvendor/osm_pkt_randomizer.c b/contrib/ofed/management/opensm/libvendor/osm_pkt_randomizer.c
deleted file mode 100644
index 3e77b56..0000000
--- a/contrib/ofed/management/opensm/libvendor/osm_pkt_randomizer.c
+++ /dev/null
@@ -1,329 +0,0 @@
-/*
- * Copyright (c) 2004-2008 Voltaire, Inc. All rights reserved.
- * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved.
- * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- */
-
-/*
- * Abstract:
- * Implementation of osm_pkt_randomizer_t.
- *
- */
-
-#if HAVE_CONFIG_H
-# include <config.h>
-#endif /* HAVE_CONFIG_H */
-
-#include <vendor/osm_pkt_randomizer.h>
-#include <stdlib.h>
-#include <string.h>
-
-#ifndef WIN32
-#include <sys/time.h>
-#include <unistd.h>
-#endif
-
-/**********************************************************************
- * Return TRUE if the path is in a fault path, and FALSE otherwise.
- * By in a fault path the meaning is that there is a path in the fault
- * paths that the given path includes it.
- * E.g: if there is a fault path: 0,1,4
- * For the given path: 0,1,4,7 the return value will be TRUE, also for
- * the given path: 0,1,4 the return value will be TRUE, but for
- * the given paths: 0,1 or 0,3,1,4 - the return value will be FALSE.
- **********************************************************************/
-boolean_t
-__osm_pkt_randomizer_is_path_in_fault_paths(IN osm_log_t * p_log,
- IN osm_dr_path_t * p_dr_path,
- IN osm_pkt_randomizer_t *
- p_pkt_rand)
-{
- boolean_t res = FALSE, found_path;
- osm_dr_path_t *p_found_dr_path;
- uint8_t ind1, ind2;
-
- OSM_LOG_ENTER(p_log);
-
- for (ind1 = 0; ind1 < p_pkt_rand->num_paths_initialized; ind1++) {
- found_path = TRUE;
- p_found_dr_path = &(p_pkt_rand->fault_dr_paths[ind1]);
- /* if the hop count of the found path is greater than the
- hop count of the input path - then it is not part of it.
- Check the next path. */
- if (p_found_dr_path->hop_count > p_dr_path->hop_count)
- continue;
-
- /* go over all the ports in the found path and see if they match
- the ports in the input path */
- for (ind2 = 0; ind2 <= p_found_dr_path->hop_count; ind2++)
- if (p_found_dr_path->path[ind2] !=
- p_dr_path->path[ind2])
- found_path = FALSE;
-
- /* If found_path is TRUE then there is a full match of the path */
- if (found_path == TRUE) {
- OSM_LOG(p_log, OSM_LOG_VERBOSE,
- "Given path is in a fault path\n");
- res = TRUE;
- break;
- }
- }
-
- OSM_LOG_EXIT(p_log);
- return res;
-}
-
-/**********************************************************************
- * For a given dr_path - return TRUE if the path should be dropped,
- * return FALSE otherwise.
- * The check uses random criteria in order to determine whether or not
- * the path should be dropped.
- * First - if not all paths are initialized, it randomally chooses if
- * to use this path as a fault path or not.
- * Second - if the path is in the fault paths (meaning - it is equal
- * to or includes one of the fault paths) - then it randomally chooses
- * if to drop it or not.
- **********************************************************************/
-boolean_t
-__osm_pkt_randomizer_process_path(IN osm_log_t * p_log,
- IN osm_pkt_randomizer_t * p_pkt_rand,
- IN osm_dr_path_t * p_dr_path)
-{
- boolean_t res = FALSE;
- static boolean_t rand_value_init = FALSE;
- static int rand_value;
- boolean_t in_fault_paths;
- uint8_t i;
- char buf[BUF_SIZE];
- char line[BUF_SIZE];
-
- OSM_LOG_ENTER(p_log);
-
- if (rand_value_init == FALSE) {
- int seed;
-#ifdef WIN32
- SYSTEMTIME st;
-#else
- struct timeval tv;
- struct timezone tz;
-#endif /* WIN32 */
-
- /* initiate the rand_value according to timeofday */
- rand_value_init = TRUE;
-
-#ifdef WIN32
- GetLocalTime(&st);
- seed = st.wMilliseconds;
-#else
- gettimeofday(&tv, &tz);
- seed = tv.tv_usec;
-#endif /* WIN32 */
-
- srand(seed);
- }
-
- /* If the hop_count is 1 - then this is a mad down to our local port - don't drop it */
- if (p_dr_path->hop_count <= 1)
- goto Exit;
-
- rand_value = rand();
-
- sprintf(buf, "Path: ");
- /* update the dr_path into the buf */
- for (i = 0; i <= p_dr_path->hop_count; i++) {
- sprintf(line, "[%X]", p_dr_path->path[i]);
- strcat(buf, line);
- }
-
- /* Check if the path given is in one of the fault paths */
- in_fault_paths =
- __osm_pkt_randomizer_is_path_in_fault_paths(p_log, p_dr_path,
- p_pkt_rand);
-
- /* Check if all paths are initialized */
- if (p_pkt_rand->num_paths_initialized <
- p_pkt_rand->osm_pkt_num_unstable_links) {
- /* Not all packets are initialized. */
- if (in_fault_paths == FALSE) {
- /* the path is not in the false paths. Check using the rand value
- if to update it there or not. */
- if (rand_value %
- (p_pkt_rand->osm_pkt_unstable_link_rate) == 0) {
- OSM_LOG(p_log, OSM_LOG_VERBOSE,
- "%s added to the fault_dr_paths list\n"
- "\t\t\t rand_value:%u, unstable_link_rate:%u \n",
- buf, rand_value,
- p_pkt_rand->osm_pkt_unstable_link_rate);
-
- /* update the path in the fault paths */
- memcpy(&
- (p_pkt_rand->
- fault_dr_paths[p_pkt_rand->
- num_paths_initialized]),
- p_dr_path, sizeof(osm_dr_path_t));
- p_pkt_rand->num_paths_initialized++;
- in_fault_paths = TRUE;
- }
- }
- }
-
- if (in_fault_paths == FALSE) {
- /* If in_fault_paths is FALSE - just ignore the path */
- OSM_LOG(p_log, OSM_LOG_VERBOSE, "%s not in fault paths\n", buf);
- goto Exit;
- }
-
- /* The path is in the fault paths. Need to choose (randomally if to drop it
- or not. */
- rand_value = rand();
-
- if (rand_value % (p_pkt_rand->osm_pkt_drop_rate) == 0) {
- /* drop the current packet */
- res = TRUE;
- OSM_LOG(p_log, OSM_LOG_VERBOSE, "Dropping path:%s\n", buf);
- }
-
-Exit:
- OSM_LOG_EXIT(p_log);
- return res;
-}
-
-/**********************************************************************
- **********************************************************************/
-boolean_t
-osm_pkt_randomizer_mad_drop(IN osm_log_t * p_log,
- IN osm_pkt_randomizer_t * p_pkt_randomizer,
- IN const ib_mad_t * p_mad)
-{
- const ib_smp_t *p_smp;
- boolean_t res = FALSE;
- osm_dr_path_t dr_path;
-
- OSM_LOG_ENTER(p_log);
-
- p_smp = (ib_smp_t *) p_mad;
-
- if (p_smp->mgmt_class != IB_MCLASS_SUBN_DIR)
- /* This is a lid route mad. Don't drop it */
- goto Exit;
-
- osm_dr_path_init(&dr_path, 0, /* The h_bind is not really important for us to save */
- p_smp->hop_count, p_smp->initial_path);
-
- if (__osm_pkt_randomizer_process_path
- (p_log, p_pkt_randomizer, &dr_path)) {
- /* the mad should be dropped o */
- OSM_LOG(p_log, OSM_LOG_VERBOSE,
- "mad TID: 0x%" PRIx64 " is being dropped\n",
- cl_ntoh64(p_smp->trans_id));
- res = TRUE;
- }
-
-Exit:
- OSM_LOG_EXIT(p_log);
- return res;
-}
-
-/**********************************************************************
- **********************************************************************/
-ib_api_status_t
-osm_pkt_randomizer_init(IN OUT osm_pkt_randomizer_t ** pp_pkt_randomizer,
- IN osm_log_t * p_log)
-{
- uint8_t tmp;
- ib_api_status_t res = IB_SUCCESS;
-
- OSM_LOG_ENTER(p_log);
-
- *pp_pkt_randomizer = malloc(sizeof(osm_pkt_randomizer_t));
- if (*pp_pkt_randomizer == NULL) {
- res = IB_INSUFFICIENT_MEMORY;
- goto Exit;
- }
- memset(*pp_pkt_randomizer, 0, sizeof(osm_pkt_randomizer_t));
- (*pp_pkt_randomizer)->num_paths_initialized = 0;
-
- tmp = atol(getenv("OSM_PKT_DROP_RATE"));
- (*pp_pkt_randomizer)->osm_pkt_drop_rate = tmp;
-
- if (getenv("OSM_PKT_NUM_UNSTABLE_LINKS") != NULL
- && (tmp = atol(getenv("OSM_PKT_NUM_UNSTABLE_LINKS"))) > 0)
- (*pp_pkt_randomizer)->osm_pkt_num_unstable_links = tmp;
- else
- (*pp_pkt_randomizer)->osm_pkt_num_unstable_links = 1;
-
- if (getenv("OSM_PKT_UNSTABLE_LINK_RATE") != NULL
- && (tmp = atol(getenv("OSM_PKT_UNSTABLE_LINK_RATE"))) > 0)
- (*pp_pkt_randomizer)->osm_pkt_unstable_link_rate = tmp;
- else
- (*pp_pkt_randomizer)->osm_pkt_unstable_link_rate = 20;
-
- OSM_LOG(p_log, OSM_LOG_VERBOSE, "Using OSM_PKT_DROP_RATE=%u \n"
- "\t\t\t\t OSM_PKT_NUM_UNSTABLE_LINKS=%u \n"
- "\t\t\t\t OSM_PKT_UNSTABLE_LINK_RATE=%u \n",
- (*pp_pkt_randomizer)->osm_pkt_drop_rate,
- (*pp_pkt_randomizer)->osm_pkt_num_unstable_links,
- (*pp_pkt_randomizer)->osm_pkt_unstable_link_rate);
-
- /* allocate the fault_dr_paths variable */
- /* It is the number of the paths that will be saved as fault = osm_pkt_num_unstable_links */
- (*pp_pkt_randomizer)->fault_dr_paths = malloc(sizeof(osm_dr_path_t) *
- (*pp_pkt_randomizer)->
- osm_pkt_num_unstable_links);
- if ((*pp_pkt_randomizer)->fault_dr_paths == NULL) {
- res = IB_INSUFFICIENT_MEMORY;
- goto Exit;
- }
-
- memset((*pp_pkt_randomizer)->fault_dr_paths, 0,
- sizeof(osm_dr_path_t) *
- (*pp_pkt_randomizer)->osm_pkt_num_unstable_links);
-
-Exit:
- OSM_LOG_EXIT(p_log);
- return (res);
-}
-
-/**********************************************************************
- **********************************************************************/
-void
-osm_pkt_randomizer_destroy(IN OUT osm_pkt_randomizer_t ** pp_pkt_randomizer,
- IN osm_log_t * p_log)
-{
- OSM_LOG_ENTER(p_log);
-
- if (*pp_pkt_randomizer != NULL) {
- free((*pp_pkt_randomizer)->fault_dr_paths);
- free(*pp_pkt_randomizer);
- }
- OSM_LOG_EXIT(p_log);
-}
diff --git a/contrib/ofed/management/opensm/libvendor/osm_vendor_al.c b/contrib/ofed/management/opensm/libvendor/osm_vendor_al.c
deleted file mode 100644
index d5d78c9..0000000
--- a/contrib/ofed/management/opensm/libvendor/osm_vendor_al.c
+++ /dev/null
@@ -1,1320 +0,0 @@
-/*
- * Copyright (c) 2004-2008 Voltaire, Inc. All rights reserved.
- * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved.
- * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- */
-
-/*
- * Abstract:
- * Implementation of osm_req_t.
- * This object represents the generic attribute requester.
- * This object is part of the opensm family of objects.
- *
- */
-
-/*
- Next available error code: 0x300
-*/
-
-#if HAVE_CONFIG_H
-# include <config.h>
-#endif /* HAVE_CONFIG_H */
-
-#ifdef OSM_VENDOR_INTF_AL
-
-#include <stdlib.h>
-#include <string.h>
-#include <complib/cl_qlist.h>
-#include <complib/cl_thread.h>
-#include <complib/cl_math.h>
-#include <complib/cl_debug.h>
-#include <iba/ib_types.h>
-#include <opensm/osm_madw.h>
-#include <opensm/osm_log.h>
-#include <opensm/osm_mad_pool.h>
-#include <vendor/osm_vendor_api.h>
-
-/****s* OpenSM: Vendor AL/osm_al_bind_info_t
- * NAME
- * osm_al_bind_info_t
- *
- * DESCRIPTION
- * Structure containing bind information.
- *
- * SYNOPSIS
- */
-typedef struct _osm_al_bind_info {
- osm_vendor_t *p_vend;
- void *client_context;
- ib_qp_handle_t h_qp;
- ib_mad_svc_handle_t h_svc;
- uint8_t port_num;
- ib_pool_key_t pool_key;
- osm_vend_mad_recv_callback_t rcv_callback;
- osm_vend_mad_send_err_callback_t send_err_callback;
- osm_mad_pool_t *p_osm_pool;
- ib_av_handle_t h_dr_av;
-
-} osm_al_bind_info_t;
-/*
- * FIELDS
- * p_vend
- * Pointer to the vendor object.
- *
- * client_context
- * User's context passed during osm_bind
- *
- * h_qp
- * Handle the QP for this bind.
- *
- * h_qp_svc
- * Handle the QP mad service for this bind.
- *
- * port_num
- * Port number (within the HCA) of the bound port.
- *
- * pool_key
- * Pool key returned by all for this QP.
- *
- * h_dr_av
- * Address vector handle used for all directed route SMPs.
- *
- * SEE ALSO
- *********/
-
-/**********************************************************************
- **********************************************************************/
-inline static ib_api_status_t
-__osm_al_convert_wcs(IN ib_wc_status_t const wc_status)
-{
- switch (wc_status) {
- case IB_WCS_SUCCESS:
- return (IB_SUCCESS);
-
- case IB_WCS_TIMEOUT_RETRY_ERR:
- return (IB_TIMEOUT);
-
- default:
- return (IB_ERROR);
- }
-}
-
-/**********************************************************************
- **********************************************************************/
-static void __osm_al_ca_err_callback(IN ib_async_event_rec_t * p_async_rec)
-{
- osm_vendor_t *p_vend = (osm_vendor_t *) p_async_rec->context;
- OSM_LOG_ENTER(p_vend->p_log);
-
- osm_log(p_vend->p_log, OSM_LOG_ERROR,
- "__osm_al_ca_err_callback: ERR 3B01: "
- "Event on channel adapter (%s).\n",
- ib_get_async_event_str(p_async_rec->code));
-
- OSM_LOG_EXIT(p_vend->p_log);
-}
-
-/**********************************************************************
- **********************************************************************/
-static void __osm_al_ca_destroy_callback(IN void *context)
-{
- osm_al_bind_info_t *p_bind = (osm_al_bind_info_t *) context;
- osm_vendor_t *p_vend = p_bind->p_vend;
- OSM_LOG_ENTER(p_vend->p_log);
-
- osm_log(p_vend->p_log, OSM_LOG_INFO,
- "__osm_al_ca_destroy_callback: "
- "Closing local channel adapter.\n");
-
- OSM_LOG_EXIT(p_vend->p_log);
-}
-
-/**********************************************************************
- **********************************************************************/
-static void __osm_al_err_callback(IN ib_async_event_rec_t * p_async_rec)
-{
- osm_al_bind_info_t *p_bind =
- (osm_al_bind_info_t *) p_async_rec->context;
- osm_vendor_t *p_vend = p_bind->p_vend;
- OSM_LOG_ENTER(p_vend->p_log);
-
- osm_log(p_vend->p_log, OSM_LOG_ERROR,
- "__osm_al_err_callback: ERR 3B02: "
- "Error on QP (%s).\n",
- ib_get_async_event_str(p_async_rec->code));
-
- OSM_LOG_EXIT(p_vend->p_log);
-}
-
-/**********************************************************************
- **********************************************************************/
-static void
-__osm_al_send_callback(IN void *mad_svc_context, IN ib_mad_element_t * p_elem)
-{
- osm_al_bind_info_t *const p_bind =
- (osm_al_bind_info_t *) mad_svc_context;
- osm_vendor_t *const p_vend = p_bind->p_vend;
- osm_madw_t *const p_madw = (osm_madw_t *) p_elem->context1;
- osm_vend_wrap_t *const p_vw = osm_madw_get_vend_ptr(p_madw);
- ib_mad_t *p_mad;
-
- OSM_LOG_ENTER(p_vend->p_log);
-
- CL_ASSERT(p_vw);
- CL_ASSERT(p_vw->h_av);
-
- /*
- Destroy the address vector as necessary.
- */
- if (p_vw->h_av != p_bind->h_dr_av) {
- if (osm_log_is_active(p_vend->p_log, OSM_LOG_DEBUG)) {
- osm_log(p_vend->p_log, OSM_LOG_DEBUG,
- "__osm_al_send_callback: "
- "Destroying av handle %p.\n", p_vw->h_av);
- }
-
- ib_destroy_av(p_vw->h_av);
- }
-
- p_mad = ib_get_mad_buf(p_elem);
-
- if (p_elem->resp_expected) {
- /*
- If the send was unsuccessful, notify the user
- for MADs that were expecting a response.
- A NULL mad wrapper parameter is the user's clue
- that the transaction turned sour.
-
- Otherwise, do nothing for successful sends when a
- reponse is expected. The mad will be returned to the
- pool later.
- */
- p_madw->status = __osm_al_convert_wcs(p_elem->status);
- if (p_elem->status != IB_WCS_SUCCESS) {
- osm_log(p_vend->p_log, OSM_LOG_DEBUG,
- "__osm_al_send_callback: "
- "MAD completed with work queue error: %s.\n",
- ib_get_wc_status_str(p_elem->status));
- /*
- Return any wrappers to the pool that may have been
- pre-emptively allocated to handle a receive.
- */
- if (p_vw->p_resp_madw) {
- osm_mad_pool_put(p_bind->p_osm_pool,
- p_vw->p_resp_madw);
- p_vw->p_resp_madw = NULL;
- }
-
- p_bind->send_err_callback(p_bind->client_context,
- p_madw);
- }
- } else {
- osm_log(p_vend->p_log, OSM_LOG_DEBUG,
- "__osm_al_send_callback: "
- "Returning MAD to pool, TID = 0x%" PRIx64 ".\n",
- cl_ntoh64(p_mad->trans_id));
- osm_mad_pool_put(p_bind->p_osm_pool, p_madw);
- goto Exit;
- }
-
-Exit:
- OSM_LOG_EXIT(p_vend->p_log);
-}
-
-/**********************************************************************
- **********************************************************************/
-static void
-__osm_al_rcv_callback(IN void *mad_svc_context, IN ib_mad_element_t * p_elem)
-{
- osm_al_bind_info_t *const p_bind =
- (osm_al_bind_info_t *) mad_svc_context;
- osm_vendor_t *const p_vend = p_bind->p_vend;
- osm_madw_t *p_old_madw;
- osm_madw_t *p_new_madw;
- osm_vend_wrap_t *p_old_vw;
- osm_vend_wrap_t *p_new_vw;
- ib_mad_t *p_new_mad;
- osm_mad_addr_t mad_addr;
-
- OSM_LOG_ENTER(p_vend->p_log);
-
- CL_ASSERT(p_elem->context1 == NULL);
- CL_ASSERT(p_elem->context2 == NULL);
-
- p_new_mad = ib_get_mad_buf(p_elem);
-
- /*
- In preperation for initializing the new mad wrapper,
- Initialize the mad_addr structure for the received wire MAD.
- */
- mad_addr.dest_lid = p_elem->remote_lid;
- mad_addr.path_bits = p_elem->path_bits;
-
- /* TO DO - figure out which #define to use for the 2.5 Gb rate... */
- mad_addr.static_rate = 0;
-
- if (p_new_mad->mgmt_class == IB_MCLASS_SUBN_LID ||
- p_new_mad->mgmt_class == IB_MCLASS_SUBN_DIR) {
- mad_addr.addr_type.smi.source_lid = p_elem->remote_lid;
- } else {
- mad_addr.addr_type.gsi.remote_qp = p_elem->remote_qp;
- mad_addr.addr_type.gsi.remote_qkey = p_elem->remote_qkey;
- mad_addr.addr_type.gsi.pkey_ix = p_elem->pkey_index;
- mad_addr.addr_type.gsi.service_level = p_elem->remote_sl;
- mad_addr.addr_type.gsi.global_route = FALSE;
- }
-
- /*
- If this MAD is a response to a previous request,
- then grab our pre-allocated MAD wrapper.
- Otherwise, allocate a new MAD wrapper.
- */
- if (ib_mad_is_response(p_new_mad)) {
- CL_ASSERT(p_elem->send_context1 != NULL);
- CL_ASSERT(p_elem->send_context2 == NULL);
-
- p_old_madw = (osm_madw_t *) p_elem->send_context1;
- p_old_vw = osm_madw_get_vend_ptr(p_old_madw);
- p_new_madw = p_old_vw->p_resp_madw;
-
- CL_ASSERT(p_new_madw);
-
- osm_madw_init(p_new_madw, p_bind, p_elem->size, &mad_addr);
- osm_madw_set_mad(p_new_madw, p_new_mad);
- } else {
- CL_ASSERT(p_elem->send_context1 == NULL);
- CL_ASSERT(p_elem->send_context2 == NULL);
-
- p_new_madw = osm_mad_pool_get_wrapper(p_bind->p_osm_pool,
- p_bind, p_elem->size,
- p_new_mad, &mad_addr);
- }
-
- CL_ASSERT(p_new_madw);
- p_new_vw = osm_madw_get_vend_ptr(p_new_madw);
-
- p_new_vw->h_bind = p_bind;
- p_new_vw->size = p_elem->size;
- p_new_vw->p_elem = p_elem;
- p_new_vw->h_av = 0;
- p_new_vw->p_resp_madw = NULL;
-
- osm_log(p_vend->p_log, OSM_LOG_DEBUG,
- "__osm_al_rcv_callback: "
- "Calling receive callback function %p.\n",
- p_bind->rcv_callback);
-
- p_bind->rcv_callback(p_new_madw, p_bind->client_context,
- p_elem->send_context1);
-
- OSM_LOG_EXIT(p_vend->p_log);
-}
-
-/**********************************************************************
- **********************************************************************/
-ib_api_status_t
-osm_vendor_init(IN osm_vendor_t * const p_vend,
- IN osm_log_t * const p_log, IN const uint32_t timeout)
-{
- ib_api_status_t status;
- OSM_LOG_ENTER(p_log);
-
- p_vend->p_log = p_log;
-
- /*
- Open our instance of AL.
- */
- status = ib_open_al(&p_vend->h_al);
- if (status != IB_SUCCESS) {
- osm_log(p_vend->p_log, OSM_LOG_ERROR,
- "osm_vendor_init: ERR 3B03: "
- "Error opening AL (%s).\n", ib_get_err_str(status));
-
- goto Exit;
- }
-
- p_vend->timeout = timeout;
-
-Exit:
- OSM_LOG_EXIT(p_log);
- return (status);
-}
-
-/**********************************************************************
- **********************************************************************/
-osm_vendor_t *osm_vendor_new(IN osm_log_t * const p_log,
- IN const uint32_t timeout)
-{
- ib_api_status_t status;
- osm_vendor_t *p_vend;
-
- OSM_LOG_ENTER(p_log);
-
- p_vend = malloc(sizeof(*p_vend));
- if (p_vend == NULL) {
- osm_log(p_vend->p_log, OSM_LOG_ERROR,
- "osm_vendor_new: ERR 3B04: "
- "Unable to allocate vendor object.\n");
- goto Exit;
- }
-
- memset(p_vend, 0, sizeof(*p_vend));
-
- status = osm_vendor_init(p_vend, p_log, timeout);
- if (status != IB_SUCCESS) {
- free(p_vend);
- p_vend = NULL;
- }
-
-Exit:
- OSM_LOG_EXIT(p_log);
- return (p_vend);
-}
-
-/**********************************************************************
- **********************************************************************/
-void osm_vendor_delete(IN osm_vendor_t ** const pp_vend)
-{
- /* TO DO - fill this in */
- ib_close_al((*pp_vend)->h_al);
- free(*pp_vend);
- *pp_vend = NULL;
-}
-
-/**********************************************************************
- **********************************************************************/
-static ib_api_status_t
-__osm_ca_info_init(IN osm_vendor_t * const p_vend,
- IN osm_ca_info_t * const p_ca_info,
- IN const ib_net64_t ca_guid)
-{
- ib_api_status_t status;
-
- OSM_LOG_ENTER(p_vend->p_log);
-
- p_ca_info->guid = ca_guid;
-
- if (osm_log_is_active(p_vend->p_log, OSM_LOG_VERBOSE)) {
- osm_log(p_vend->p_log, OSM_LOG_VERBOSE,
- "__osm_ca_info_init: "
- "Querying CA 0x%" PRIx64 ".\n", cl_ntoh64(ca_guid));
- }
-
- status = ib_query_ca_by_guid(p_vend->h_al, ca_guid, NULL,
- &p_ca_info->attr_size);
- if ((status != IB_INSUFFICIENT_MEMORY) && (status != IB_SUCCESS)) {
- osm_log(p_vend->p_log, OSM_LOG_ERROR,
- "__osm_ca_info_init: ERR 3B05: "
- "Unexpected status getting CA attributes (%s).\n",
- ib_get_err_str(status));
- goto Exit;
- }
-
- CL_ASSERT(p_ca_info->attr_size);
-
- p_ca_info->p_attr = malloc(p_ca_info->attr_size);
- if (p_ca_info->p_attr == NULL) {
- osm_log(p_vend->p_log, OSM_LOG_ERROR,
- "__osm_ca_info_init: ERR 3B06: "
- "Unable to allocate attribute storage.\n");
- goto Exit;
- }
-
- status = ib_query_ca_by_guid(p_vend->h_al, ca_guid, p_ca_info->p_attr,
- &p_ca_info->attr_size);
- if (status != IB_SUCCESS) {
- osm_log(p_vend->p_log, OSM_LOG_ERROR,
- "__osm_ca_info_init: ERR 3B07: "
- "Unexpected status getting CA attributes (%s).\n",
- ib_get_err_str(status));
- goto Exit;
- }
-
-Exit:
- OSM_LOG_EXIT(p_vend->p_log);
- return (status);
-}
-
-/**********************************************************************
- **********************************************************************/
-void
-osm_ca_info_destroy(IN osm_vendor_t * const p_vend,
- IN osm_ca_info_t * const p_ca_info)
-{
- OSM_LOG_ENTER(p_vend->p_log);
-
- if (p_ca_info->p_attr)
- free(p_ca_info->p_attr);
-
- free(p_ca_info);
-
- OSM_LOG_EXIT(p_vend->p_log);
-}
-
-/**********************************************************************
- **********************************************************************/
-osm_ca_info_t *osm_ca_info_new(IN osm_vendor_t * const p_vend,
- IN const ib_net64_t ca_guid)
-{
- ib_api_status_t status;
- osm_ca_info_t *p_ca_info;
-
- OSM_LOG_ENTER(p_vend->p_log);
-
- CL_ASSERT(ca_guid);
-
- p_ca_info = malloc(sizeof(*p_ca_info));
- if (p_ca_info == NULL)
- goto Exit;
-
- memset(p_ca_info, 0, sizeof(*p_ca_info));
-
- status = __osm_ca_info_init(p_vend, p_ca_info, ca_guid);
- if (status != IB_SUCCESS) {
- osm_ca_info_destroy(p_vend, p_ca_info);
- p_ca_info = NULL;
- goto Exit;
- }
-
-Exit:
- OSM_LOG_EXIT(p_vend->p_log);
- return (p_ca_info);
-}
-
-/**********************************************************************
- **********************************************************************/
-static ib_api_status_t
-__osm_vendor_get_ca_guids(IN osm_vendor_t * const p_vend,
- IN ib_net64_t ** const p_guids,
- IN uintn_t * const p_num_guids)
-{
- ib_api_status_t status;
-
- OSM_LOG_ENTER(p_vend->p_log);
-
- CL_ASSERT(p_guids);
- CL_ASSERT(p_num_guids);
-
- status = ib_get_ca_guids(p_vend->h_al, NULL, p_num_guids);
- if ((status != IB_INSUFFICIENT_MEMORY) && (status != IB_SUCCESS)) {
- osm_log(p_vend->p_log, OSM_LOG_ERROR,
- "__osm_vendor_get_ca_guids: ERR 3B08: "
- "Unexpected status getting CA GUID array (%s).\n",
- ib_get_err_str(status));
- goto Exit;
- }
-
- if (*p_num_guids == 0) {
- osm_log(p_vend->p_log, OSM_LOG_ERROR,
- "__osm_vendor_get_ca_guids: ERR 3B09: "
- "No available channel adapters.\n");
- status = IB_INSUFFICIENT_RESOURCES;
- goto Exit;
- }
-
- *p_guids = malloc(*p_num_guids * sizeof(**p_guids));
- if (*p_guids == NULL) {
- osm_log(p_vend->p_log, OSM_LOG_ERROR,
- "__osm_vendor_get_ca_guids: ERR 3B10: "
- "Unable to allocate CA GUID array.\n");
- goto Exit;
- }
-
- status = ib_get_ca_guids(p_vend->h_al, *p_guids, p_num_guids);
- CL_ASSERT(*p_num_guids);
-
- if (osm_log_is_active(p_vend->p_log, OSM_LOG_VERBOSE)) {
- osm_log(p_vend->p_log, OSM_LOG_VERBOSE,
- "__osm_vendor_get_ca_guids: "
- "Detected %u local channel adapters.\n", *p_num_guids);
- }
-
-Exit:
- OSM_LOG_EXIT(p_vend->p_log);
- return (status);
-}
-
-/****f* OpenSM: CA Info/osm_ca_info_get_pi_ptr
- * NAME
- * osm_ca_info_get_pi_ptr
- *
- * DESCRIPTION
- * Returns a pointer to the port attribute of the specified port
- * owned by this CA.
- *
- * SYNOPSIS
- */
-static ib_port_attr_t *__osm_ca_info_get_port_attr_ptr(IN const osm_ca_info_t *
- const p_ca_info,
- IN const uint8_t index)
-{
- return (&p_ca_info->p_attr->p_port_attr[index]);
-}
-
-/*
- * PARAMETERS
- * p_ca_info
- * [in] Pointer to a CA Info object.
- *
- * index
- * [in] Port "index" for which to retrieve the port attribute.
- * The index is the offset into the ca's internal array
- * of port attributes.
- *
- * RETURN VALUE
- * Returns a pointer to the port attribute of the specified port
- * owned by this CA.
- *
- * NOTES
- *
- * SEE ALSO
- *********/
-
-/**********************************************************************
- **********************************************************************/
-ib_api_status_t
-osm_vendor_get_all_port_attr(IN osm_vendor_t * const p_vend,
- IN ib_port_attr_t * const p_attr_array,
- IN uint32_t * const p_num_ports)
-{
- ib_api_status_t status;
-
- uint32_t ca;
- uintn_t ca_count;
- uint32_t port_count = 0;
- uint8_t port_num;
- uint32_t total_ports = 0;
- ib_net64_t *p_ca_guid = NULL;
- osm_ca_info_t *p_ca_info;
-
- OSM_LOG_ENTER(p_vend->p_log);
-
- CL_ASSERT(p_vend);
- CL_ASSERT(p_vend->p_ca_info == NULL);
-
- /*
- 1) Determine the number of CA's
- 2) Allocate an array big enough to hold the ca info objects.
- 3) Call again to retrieve the guids.
- */
- status = __osm_vendor_get_ca_guids(p_vend, &p_ca_guid, &ca_count);
-
- p_vend->p_ca_info = malloc(ca_count * sizeof(*p_vend->p_ca_info));
- if (p_vend->p_ca_info == NULL) {
- osm_log(p_vend->p_log, OSM_LOG_ERROR,
- "osm_vendor_get_all_port_attr: ERR 3B11: "
- "Unable to allocate CA information array.\n");
- goto Exit;
- }
-
- memset(p_vend->p_ca_info, 0, ca_count * sizeof(*p_vend->p_ca_info));
- p_vend->ca_count = ca_count;
-
- /*
- For each CA, retrieve the port info attributes
- */
- for (ca = 0; ca < ca_count; ca++) {
- p_ca_info = &p_vend->p_ca_info[ca];
-
- status = __osm_ca_info_init(p_vend, p_ca_info, p_ca_guid[ca]);
-
- if (status != IB_SUCCESS) {
- osm_log(p_vend->p_log, OSM_LOG_ERROR,
- "osm_vendor_get_all_port_attr: ERR 3B12: "
- "Unable to initialize CA Info object (%s).\n",
- ib_get_err_str(status));
- }
-
- total_ports += osm_ca_info_get_num_ports(p_ca_info);
- }
-
- /*
- If the user supplied enough storage, return the port guids,
- otherwise, return the appropriate error.
- */
- if (*p_num_ports >= total_ports) {
- for (ca = 0; ca < ca_count; ca++) {
- uint32_t num_ports;
-
- p_ca_info = &p_vend->p_ca_info[ca];
-
- num_ports = osm_ca_info_get_num_ports(p_ca_info);
-
- for (port_num = 0; port_num < num_ports; port_num++) {
- p_attr_array[port_count] =
- *__osm_ca_info_get_port_attr_ptr(p_ca_info,
- port_num);
- port_count++;
- }
- }
- } else {
- status = IB_INSUFFICIENT_MEMORY;
- }
-
- *p_num_ports = total_ports;
-
-Exit:
- if (p_ca_guid)
- free(p_ca_guid);
-
- OSM_LOG_EXIT(p_vend->p_log);
- return (status);
-}
-
-/**********************************************************************
- **********************************************************************/
-ib_net64_t
-osm_vendor_get_ca_guid(IN osm_vendor_t * const p_vend,
- IN const ib_net64_t port_guid)
-{
- uint8_t index;
- uint8_t num_ports;
- uint32_t num_guids = 0;
- osm_ca_info_t *p_ca_info;
- uint32_t ca;
-
- OSM_LOG_ENTER(p_vend->p_log);
-
- CL_ASSERT(port_guid);
- /*
- First, locate the HCA that owns this port.
- */
- if (p_vend->p_ca_info == NULL) {
- /*
- Initialize the osm_ca_info_t array which allows
- us to match port GUID to CA.
- */
- osm_vendor_get_all_port_attr(p_vend, NULL, &num_guids);
- }
-
- CL_ASSERT(p_vend->p_ca_info);
- CL_ASSERT(p_vend->ca_count);
-
- for (ca = 0; ca < p_vend->ca_count; ca++) {
- p_ca_info = &p_vend->p_ca_info[ca];
-
- num_ports = osm_ca_info_get_num_ports(p_ca_info);
- CL_ASSERT(num_ports);
-
- for (index = 0; index < num_ports; index++) {
- if (port_guid ==
- osm_ca_info_get_port_guid(p_ca_info, index)) {
- OSM_LOG_EXIT(p_vend->p_log);
- return (osm_ca_info_get_ca_guid(p_ca_info));
- }
- }
- }
-
- /*
- No local CA owns this guid!
- */
- osm_log(p_vend->p_log, OSM_LOG_ERROR,
- "osm_vendor_get_ca_guid: ERR 3B13: "
- "Unable to determine CA guid.\n");
-
- OSM_LOG_EXIT(p_vend->p_log);
- return (0);
-}
-
-/**********************************************************************
- **********************************************************************/
-uint8_t
-osm_vendor_get_port_num(IN osm_vendor_t * const p_vend,
- IN const ib_net64_t port_guid)
-{
- uint8_t index;
- uint8_t num_ports;
- uint32_t num_guids = 0;
- osm_ca_info_t *p_ca_info;
- uint32_t ca;
-
- OSM_LOG_ENTER(p_vend->p_log);
-
- CL_ASSERT(port_guid);
- /*
- First, locate the HCA that owns this port.
- */
- if (p_vend->p_ca_info == NULL) {
- /*
- Initialize the osm_ca_info_t array which allows
- us to match port GUID to CA.
- */
- osm_vendor_get_all_port_attr(p_vend, NULL, &num_guids);
- }
-
- CL_ASSERT(p_vend->p_ca_info);
- CL_ASSERT(p_vend->ca_count);
-
- for (ca = 0; ca < p_vend->ca_count; ca++) {
- p_ca_info = &p_vend->p_ca_info[ca];
-
- num_ports = osm_ca_info_get_num_ports(p_ca_info);
- CL_ASSERT(num_ports);
-
- for (index = 0; index < num_ports; index++) {
- if (port_guid ==
- osm_ca_info_get_port_guid(p_ca_info, index)) {
- OSM_LOG_EXIT(p_vend->p_log);
- return (osm_ca_info_get_port_num
- (p_ca_info, index));
- }
- }
- }
-
- /*
- No local CA owns this guid!
- */
- osm_log(p_vend->p_log, OSM_LOG_ERROR,
- "osm_vendor_get_port_num: ERR 3B30: "
- "Unable to determine CA guid.\n");
-
- OSM_LOG_EXIT(p_vend->p_log);
- return (0);
-}
-
-/**********************************************************************
- **********************************************************************/
-static ib_api_status_t
-__osm_vendor_open_ca(IN osm_vendor_t * const p_vend,
- IN const ib_net64_t port_guid)
-{
- ib_net64_t ca_guid;
- ib_api_status_t status;
-
- OSM_LOG_ENTER(p_vend->p_log);
-
- ca_guid = osm_vendor_get_ca_guid(p_vend, port_guid);
- if (ca_guid == 0) {
- osm_log(p_vend->p_log, OSM_LOG_ERROR,
- "__osm_vendor_open_ca: ERR 3B31: "
- "Bad port GUID value 0x%" PRIx64 ".\n",
- cl_ntoh64(port_guid));
- status = IB_ERROR;
- goto Exit;
- }
-
- osm_log(p_vend->p_log, OSM_LOG_VERBOSE,
- "__osm_vendor_open_ca: "
- "Opening HCA 0x%" PRIx64 ".\n", cl_ntoh64(ca_guid));
-
- status = ib_open_ca(p_vend->h_al,
- ca_guid,
- __osm_al_ca_err_callback, p_vend, &p_vend->h_ca);
-
- if (status != IB_SUCCESS) {
- osm_log(p_vend->p_log, OSM_LOG_ERROR,
- "__osm_vendor_open_ca: ERR 3B15: "
- "Unable to open CA (%s).\n", ib_get_err_str(status));
- goto Exit;
- }
-
- CL_ASSERT(p_vend->h_ca);
-
- status = ib_alloc_pd(p_vend->h_ca, IB_PDT_ALIAS, p_vend, &p_vend->h_pd);
-
- if (status != IB_SUCCESS) {
- ib_close_ca(p_vend->h_ca, __osm_al_ca_destroy_callback);
- osm_log(p_vend->p_log, OSM_LOG_ERROR,
- "__osm_vendor_open_ca: ERR 3B16: "
- "Unable to allocate protection domain (%s).\n",
- ib_get_err_str(status));
- goto Exit;
- }
-
- CL_ASSERT(p_vend->h_pd);
-
-Exit:
- OSM_LOG_EXIT(p_vend->p_log);
- return (status);
-}
-
-/**********************************************************************
- **********************************************************************/
-static void
-__osm_vendor_init_av(IN const osm_al_bind_info_t * p_bind,
- IN ib_av_attr_t * p_av)
-{
- memset(p_av, 0, sizeof(*p_av));
- p_av->port_num = p_bind->port_num;
- p_av->dlid = IB_LID_PERMISSIVE;
-}
-
-/**********************************************************************
- **********************************************************************/
-osm_bind_handle_t
-osm_vendor_bind(IN osm_vendor_t * const p_vend,
- IN osm_bind_info_t * const p_user_bind,
- IN osm_mad_pool_t * const p_mad_pool,
- IN osm_vend_mad_recv_callback_t mad_recv_callback,
- IN osm_vend_mad_send_err_callback_t send_err_callback,
- IN void *context)
-{
- ib_net64_t port_guid;
- osm_al_bind_info_t *p_bind = 0;
- ib_api_status_t status;
- ib_qp_create_t qp_create;
- ib_mad_svc_t mad_svc;
- ib_av_attr_t av;
-
- OSM_LOG_ENTER(p_vend->p_log);
-
- CL_ASSERT(p_user_bind);
- CL_ASSERT(p_mad_pool);
- CL_ASSERT(mad_recv_callback);
- CL_ASSERT(send_err_callback);
-
- port_guid = p_user_bind->port_guid;
-
- osm_log(p_vend->p_log, OSM_LOG_INFO,
- "osm_vendor_bind: "
- "Binding to port 0x%" PRIx64 ".\n", cl_ntoh64(port_guid));
-
- if (p_vend->h_ca == 0) {
- osm_log(p_vend->p_log, OSM_LOG_DEBUG,
- "osm_vendor_bind: "
- "Opening CA that owns port 0x%" PRIx64 ".\n",
- port_guid);
-
- status = __osm_vendor_open_ca(p_vend, port_guid);
- if (status != IB_SUCCESS) {
- osm_log(p_vend->p_log, OSM_LOG_ERROR,
- "osm_vendor_bind: ERR 3B17: "
- "Unable to Open CA (%s).\n",
- ib_get_err_str(status));
- goto Exit;
- }
- }
-
- p_bind = malloc(sizeof(*p_bind));
- if (p_bind == NULL) {
- osm_log(p_vend->p_log, OSM_LOG_ERROR,
- "osm_vendor_bind: ERR 3B18: "
- "Unable to allocate internal bind object.\n");
- goto Exit;
- }
-
- memset(p_bind, 0, sizeof(*p_bind));
- p_bind->p_vend = p_vend;
- p_bind->client_context = context;
- p_bind->port_num = osm_vendor_get_port_num(p_vend, port_guid);
- p_bind->rcv_callback = mad_recv_callback;
- p_bind->send_err_callback = send_err_callback;
- p_bind->p_osm_pool = p_mad_pool;
-
- CL_ASSERT(p_bind->port_num);
-
- /*
- Get the proper QP.
- */
- memset(&qp_create, 0, sizeof(qp_create));
-
- switch (p_user_bind->mad_class) {
- case IB_MCLASS_SUBN_LID:
- case IB_MCLASS_SUBN_DIR:
- qp_create.qp_type = IB_QPT_QP0_ALIAS;
- break;
-
- case IB_MCLASS_SUBN_ADM:
- default:
- qp_create.qp_type = IB_QPT_QP1_ALIAS;
- break;
- }
-
- qp_create.sq_depth = p_user_bind->send_q_size;
- qp_create.rq_depth = p_user_bind->recv_q_size;
- qp_create.sq_sge = OSM_AL_SQ_SGE;
- qp_create.rq_sge = OSM_AL_RQ_SGE;
-
- status = ib_get_spl_qp(p_vend->h_pd,
- port_guid,
- &qp_create,
- p_bind,
- __osm_al_err_callback,
- &p_bind->pool_key, &p_bind->h_qp);
-
- if (status != IB_SUCCESS) {
- free(p_bind);
- osm_log(p_vend->p_log, OSM_LOG_ERROR,
- "osm_vendor_bind: ERR 3B19: "
- "Unable to get QP handle (%s).\n",
- ib_get_err_str(status));
- goto Exit;
- }
-
- CL_ASSERT(p_bind->h_qp);
- CL_ASSERT(p_bind->pool_key);
-
- memset(&mad_svc, 0, sizeof(mad_svc));
-
- mad_svc.mad_svc_context = p_bind;
- mad_svc.pfn_mad_send_cb = __osm_al_send_callback;
- mad_svc.pfn_mad_recv_cb = __osm_al_rcv_callback;
- mad_svc.mgmt_class = p_user_bind->mad_class;
- mad_svc.mgmt_version = p_user_bind->class_version;
- mad_svc.support_unsol = p_user_bind->is_responder;
- mad_svc.method_array[IB_MAD_METHOD_GET] = TRUE;
- mad_svc.method_array[IB_MAD_METHOD_SET] = TRUE;
- mad_svc.method_array[IB_MAD_METHOD_DELETE] = TRUE;
- mad_svc.method_array[IB_MAD_METHOD_TRAP] = TRUE;
- mad_svc.method_array[IB_MAD_METHOD_GETTABLE] = TRUE;
-
- status = ib_reg_mad_svc(p_bind->h_qp, &mad_svc, &p_bind->h_svc);
-
- if (status != IB_SUCCESS) {
- free(p_bind);
- osm_log(p_vend->p_log, OSM_LOG_ERROR,
- "osm_vendor_bind: ERR 3B21: "
- "Unable to register QP0 MAD service (%s).\n",
- ib_get_err_str(status));
- goto Exit;
- }
-
- __osm_vendor_init_av(p_bind, &av);
-
- status = ib_create_av(p_vend->h_pd, &av, &p_bind->h_dr_av);
- if (status != IB_SUCCESS) {
- osm_log(p_vend->p_log, OSM_LOG_ERROR,
- "osm_vendor_bind: ERR 3B22: "
- "Unable to create address vector (%s).\n",
- ib_get_err_str(status));
-
- goto Exit;
- }
-
- if (osm_log_is_active(p_vend->p_log, OSM_LOG_DEBUG)) {
- osm_log(p_vend->p_log, OSM_LOG_DEBUG,
- "osm_vendor_bind: "
- "Allocating av handle %p.\n", p_bind->h_dr_av);
- }
-
-Exit:
- OSM_LOG_EXIT(p_vend->p_log);
- return ((osm_bind_handle_t) p_bind);
-}
-
-/**********************************************************************
- **********************************************************************/
-ib_mad_t *osm_vendor_get(IN osm_bind_handle_t h_bind,
- IN const uint32_t mad_size,
- IN osm_vend_wrap_t * const p_vw)
-{
- ib_mad_t *p_mad;
- osm_al_bind_info_t *p_bind = (osm_al_bind_info_t *) h_bind;
- osm_vendor_t *p_vend = p_bind->p_vend;
- ib_api_status_t status;
-
- OSM_LOG_ENTER(p_vend->p_log);
-
- CL_ASSERT(p_vw);
-
- p_vw->size = mad_size;
- p_vw->h_bind = h_bind;
-
- /*
- Retrieve a MAD element from the pool and give the user direct
- access to its buffer.
- */
- status = ib_get_mad(p_bind->pool_key, mad_size, &p_vw->p_elem);
- if (status != IB_SUCCESS) {
- osm_log(p_vend->p_log, OSM_LOG_ERROR,
- "osm_vendor_get: ERR 3B25: "
- "Unable to acquire MAD (%s).\n",
- ib_get_err_str(status));
-
- p_mad = NULL;
- goto Exit;
- }
-
- CL_ASSERT(p_vw->p_elem);
- p_mad = ib_get_mad_buf(p_vw->p_elem);
-
- if (osm_log_get_level(p_vend->p_log) >= OSM_LOG_DEBUG) {
- osm_log(p_vend->p_log, OSM_LOG_DEBUG,
- "osm_vendor_get: "
- "Acquired MAD %p, size = %u.\n", p_mad, mad_size);
- }
-
-Exit:
- OSM_LOG_EXIT(p_vend->p_log);
- return (p_mad);
-}
-
-/**********************************************************************
- **********************************************************************/
-void
-osm_vendor_put(IN osm_bind_handle_t h_bind, IN osm_vend_wrap_t * const p_vw)
-{
- osm_al_bind_info_t *p_bind = (osm_al_bind_info_t *) h_bind;
- osm_vendor_t *p_vend = p_bind->p_vend;
- ib_api_status_t status;
-
- OSM_LOG_ENTER(p_vend->p_log);
-
- CL_ASSERT(p_vw);
- CL_ASSERT(p_vw->p_elem);
- CL_ASSERT(p_vw->h_bind == h_bind);
-
- if (osm_log_get_level(p_vend->p_log) >= OSM_LOG_DEBUG) {
- osm_log(p_vend->p_log, OSM_LOG_DEBUG,
- "osm_vendor_put: "
- "Retiring MAD %p.\n", ib_get_mad_buf(p_vw->p_elem));
- }
-
- status = ib_put_mad(p_vw->p_elem);
- if (status != IB_SUCCESS) {
- osm_log(p_vend->p_log, OSM_LOG_ERROR,
- "osm_vendor_put: ERR 3B26: "
- "Unable to retire MAD (%s).\n", ib_get_err_str(status));
- }
-
- OSM_LOG_EXIT(p_vend->p_log);
-}
-
-/**********************************************************************
- **********************************************************************/
-ib_api_status_t
-osm_vendor_send(IN osm_bind_handle_t h_bind,
- IN osm_madw_t * const p_madw, IN boolean_t const resp_expected)
-{
- osm_al_bind_info_t *const p_bind = h_bind;
- osm_vendor_t *const p_vend = p_bind->p_vend;
- osm_vend_wrap_t *const p_vw = osm_madw_get_vend_ptr(p_madw);
- osm_mad_addr_t *const p_mad_addr = osm_madw_get_mad_addr_ptr(p_madw);
- ib_mad_t *const p_mad = osm_madw_get_mad_ptr(p_madw);
- ib_api_status_t status;
- ib_mad_element_t *p_elem;
- ib_av_attr_t av;
-
- OSM_LOG_ENTER(p_vend->p_log);
-
- CL_ASSERT(p_vw->h_bind == h_bind);
- CL_ASSERT(p_vw->p_elem);
-
- p_elem = p_vw->p_elem;
-
- /*
- If a response is expected to this MAD, then preallocate
- a mad wrapper to contain the wire MAD received in the
- response. Allocating a wrapper here allows for easier
- failure paths than after we already received the wire mad.
- */
- if (resp_expected) {
- p_vw->p_resp_madw =
- osm_mad_pool_get_wrapper_raw(p_bind->p_osm_pool);
- if (p_vw->p_resp_madw == NULL) {
- osm_log(p_vend->p_log, OSM_LOG_ERROR,
- "osm_vendor_send: ERR 3B27: "
- "Unable to allocate MAD wrapper.\n");
- status = IB_INSUFFICIENT_RESOURCES;
- goto Exit;
- }
- } else
- p_vw->p_resp_madw = NULL;
-
- /*
- For all sends other than directed route SM MADs,
- acquire an address vector for the destination.
- */
- if (p_mad->mgmt_class != IB_MCLASS_SUBN_DIR) {
- memset(&av, 0, sizeof(av));
- av.port_num = p_bind->port_num;
- av.dlid = p_mad_addr->dest_lid;
- av.static_rate = p_mad_addr->static_rate;
- av.path_bits = p_mad_addr->path_bits;
-
- if ((p_mad->mgmt_class != IB_MCLASS_SUBN_LID) &&
- (p_mad->mgmt_class != IB_MCLASS_SUBN_DIR)) {
- av.sl = p_mad_addr->addr_type.gsi.service_level;
-
- if (p_mad_addr->addr_type.gsi.global_route) {
- av.grh_valid = TRUE;
- /* ANIL */
- /* av.grh = p_mad_addr->addr_type.gsi.grh_info; */
- }
- }
-
- if (osm_log_is_active(p_vend->p_log, OSM_LOG_DEBUG)) {
- osm_log(p_vend->p_log, OSM_LOG_DEBUG,
- "osm_vendor_send: "
- "av.port_num 0x%X, "
- "av.dlid 0x%X, "
- "av.static_rate %d, "
- "av.path_bits %d.\n",
- av.port_num, cl_ntoh16(av.dlid),
- av.static_rate, av.path_bits);
- }
-
- status = ib_create_av(p_vend->h_pd, &av, &p_vw->h_av);
- if (status != IB_SUCCESS) {
- osm_log(p_vend->p_log, OSM_LOG_ERROR,
- "osm_vendor_send: ERR 3B28: "
- "Unable to create address vector (%s).\n",
- ib_get_err_str(status));
-
- if (p_vw->p_resp_madw)
- osm_mad_pool_put(p_bind->p_osm_pool,
- p_vw->p_resp_madw);
- goto Exit;
- }
-
- if (osm_log_is_active(p_vend->p_log, OSM_LOG_DEBUG)) {
- osm_log(p_vend->p_log, OSM_LOG_DEBUG,
- "osm_vendor_send: "
- "Allocating av handle %p.\n", p_vw->h_av);
- }
- } else {
- p_vw->h_av = p_bind->h_dr_av;
- }
-
- p_elem->h_av = p_vw->h_av;
-
- p_elem->context1 = p_madw;
- p_elem->context2 = NULL;
-
- p_elem->immediate_data = 0;
- p_elem->p_grh = NULL;
- p_elem->resp_expected = resp_expected;
- p_elem->retry_cnt = OSM_DEFAULT_RETRY_COUNT;
-
- p_elem->send_opt = IB_SEND_OPT_SIGNALED;
- p_elem->timeout_ms = p_vend->timeout;
-
- /* Completion information. */
- p_elem->status = 0; /* Not trusting AL */
-
- if ((p_mad->mgmt_class == IB_MCLASS_SUBN_LID) ||
- (p_mad->mgmt_class == IB_MCLASS_SUBN_DIR)) {
- p_elem->remote_qp = 0;
- p_elem->remote_qkey = 0;
- } else {
- p_elem->remote_qp = p_mad_addr->addr_type.gsi.remote_qp;
- p_elem->remote_qkey = p_mad_addr->addr_type.gsi.remote_qkey;
- osm_log(p_vend->p_log, OSM_LOG_DEBUG,
- "osm_vendor_send: "
- "remote qp = 0x%X, remote qkey = 0x%X.\n",
- cl_ntoh32(p_elem->remote_qp),
- cl_ntoh32(p_elem->remote_qkey));
- }
-
- status = ib_send_mad(p_bind->h_svc, p_elem, NULL);
- if (status != IB_SUCCESS) {
- osm_log(p_vend->p_log, OSM_LOG_ERROR,
- "osm_vendor_send: ERR 3B29: "
- "Send failed (%s).\n", ib_get_err_str(status));
- if (p_vw->p_resp_madw)
- osm_mad_pool_put(p_bind->p_osm_pool, p_vw->p_resp_madw);
- goto Exit;
- }
-
-Exit:
- OSM_LOG_EXIT(p_vend->p_log);
- return (status);
-}
-
-/**********************************************************************
- **********************************************************************/
-ib_api_status_t osm_vendor_local_lid_change(IN osm_bind_handle_t h_bind)
-{
- osm_al_bind_info_t *p_bind = (osm_al_bind_info_t *) h_bind;
- osm_vendor_t *p_vend = p_bind->p_vend;
- ib_av_attr_t av;
- ib_api_status_t status;
-
- OSM_LOG_ENTER(p_vend->p_log);
-
- /*
- The only thing we need to do is refresh the directed
- route address vector.
- */
- __osm_vendor_init_av(p_bind, &av);
-
- status = ib_destroy_av(p_bind->h_dr_av);
- if (status != IB_SUCCESS) {
- osm_log(p_vend->p_log, OSM_LOG_ERROR,
- "osm_vendor_local_lid_change: ERR 3B32: "
- "Unable to destroy address vector (%s).\n",
- ib_get_err_str(status));
-
- goto Exit;
- }
-
- status = ib_create_av(p_vend->h_pd, &av, &p_bind->h_dr_av);
- if (status != IB_SUCCESS) {
- osm_log(p_vend->p_log, OSM_LOG_ERROR,
- "osm_vendor_local_lid_change: ERR 3B33: "
- "Unable to create address vector (%s).\n",
- ib_get_err_str(status));
-
- goto Exit;
- }
-
-Exit:
- OSM_LOG_EXIT(p_vend->p_log);
- return (status);
-}
-
-/**********************************************************************
- **********************************************************************/
-void osm_vendor_set_sm(IN osm_bind_handle_t h_bind, IN boolean_t is_sm_val)
-{
- osm_al_bind_info_t *p_bind = (osm_al_bind_info_t *) h_bind;
- osm_vendor_t *p_vend = p_bind->p_vend;
- ib_api_status_t status;
- ib_port_attr_mod_t attr_mod;
-
- OSM_LOG_ENTER(p_vend->p_log);
-
- memset(&attr_mod, 0, sizeof(attr_mod));
-
- attr_mod.cap.sm = is_sm_val;
-
- status = ib_modify_ca(p_vend->h_ca, p_bind->port_num,
- IB_CA_MOD_IS_SM, &attr_mod);
-
- if (status != IB_SUCCESS) {
- osm_log(p_vend->p_log, OSM_LOG_ERROR,
- "osm_vendor_set_sm: ERR 3B34: "
- "Unable set 'IS_SM' bit to:%u in port attributes (%s).\n",
- is_sm_val, ib_get_err_str(status));
- }
-
- OSM_LOG_EXIT(p_vend->p_log);
-}
-
-/**********************************************************************
- **********************************************************************/
-void osm_vendor_set_debug(IN osm_vendor_t * const p_vend, IN int32_t level)
-{
-
-}
-
-#endif /* OSM_VENDOR_INTF_AL */
diff --git a/contrib/ofed/management/opensm/libvendor/osm_vendor_ibumad.c b/contrib/ofed/management/opensm/libvendor/osm_vendor_ibumad.c
deleted file mode 100644
index 734a860..0000000
--- a/contrib/ofed/management/opensm/libvendor/osm_vendor_ibumad.c
+++ /dev/null
@@ -1,1154 +0,0 @@
-/*
- * Copyright (c) 2004-2008 Voltaire, Inc. All rights reserved.
- * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved.
- * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- */
-
-/*
- * Abstract:
- * Implementation of osm_vendor_t (for umad).
- * This object represents the OpenIB vendor layer.
- * This object is part of the opensm family of objects.
- *
- * Environment:
- * Linux User Mode
- *
- */
-
-#if HAVE_CONFIG_H
-# include <config.h>
-#endif /* HAVE_CONFIG_H */
-
-#ifdef OSM_VENDOR_INTF_OPENIB
-
-#include <unistd.h>
-#include <stdlib.h>
-#include <fcntl.h>
-#include <errno.h>
-
-#include <iba/ib_types.h>
-#include <complib/cl_qlist.h>
-#include <complib/cl_math.h>
-#include <complib/cl_debug.h>
-#include <opensm/osm_madw.h>
-#include <opensm/osm_log.h>
-#include <opensm/osm_mad_pool.h>
-#include <opensm/osm_helper.h>
-#include <vendor/osm_vendor_api.h>
-
-/****s* OpenSM: Vendor UMAD/osm_umad_bind_info_t
- * NAME
- * osm_umad_bind_info_t
- *
- * DESCRIPTION
- * Structure containing bind information.
- *
- * SYNOPSIS
- */
-typedef struct _osm_umad_bind_info {
- osm_vendor_t *p_vend;
- void *client_context;
- osm_mad_pool_t *p_mad_pool;
- osm_vend_mad_recv_callback_t mad_recv_callback;
- osm_vend_mad_send_err_callback_t send_err_callback;
- ib_net64_t port_guid;
- int port_id;
- int agent_id;
- int agent_id1; /* SMI requires two agents */
-} osm_umad_bind_info_t;
-
-typedef struct _umad_receiver {
- pthread_t tid;
- osm_vendor_t *p_vend;
- osm_log_t *p_log;
-} umad_receiver_t;
-
-static void osm_vendor_close_port(osm_vendor_t * const p_vend);
-
-static void clear_madw(osm_vendor_t * p_vend)
-{
- umad_match_t *m, *e, *old_m;
- ib_net64_t old_tid;
-
- OSM_LOG_ENTER(p_vend->p_log);
- pthread_mutex_lock(&p_vend->match_tbl_mutex);
- for (m = p_vend->mtbl.tbl, e = m + p_vend->mtbl.max; m < e; m++) {
- if (m->tid) {
- old_m = m;
- old_tid = m->tid;
- m->tid = 0;
- osm_mad_pool_put(((osm_umad_bind_info_t
- *) ((osm_madw_t *) m->v)->h_bind)->
- p_mad_pool, m->v);
- pthread_mutex_unlock(&p_vend->match_tbl_mutex);
- OSM_LOG(p_vend->p_log, OSM_LOG_ERROR, "ERR 5401: "
- "evicting entry %p (tid was 0x%" PRIx64 ")\n",
- old_m, old_tid);
- goto Exit;
- }
- }
- pthread_mutex_unlock(&p_vend->match_tbl_mutex);
-
-Exit:
- OSM_LOG_EXIT(p_vend->p_log);
-}
-
-static osm_madw_t *get_madw(osm_vendor_t * p_vend, ib_net64_t * tid)
-{
- umad_match_t *m, *e;
- ib_net64_t mtid = (*tid & CL_HTON64(0x00000000ffffffffllu));
- osm_madw_t *res;
-
- /*
- * Since mtid == 0 is the empty key, we should not
- * waste time looking for it
- */
- if (mtid == 0)
- return 0;
-
- pthread_mutex_lock(&p_vend->match_tbl_mutex);
- for (m = p_vend->mtbl.tbl, e = m + p_vend->mtbl.max; m < e; m++) {
- if (m->tid == mtid) {
- m->tid = 0;
- *tid = mtid;
- res = m->v;
- pthread_mutex_unlock(&p_vend->match_tbl_mutex);
- return res;
- }
- }
-
- pthread_mutex_unlock(&p_vend->match_tbl_mutex);
- return 0;
-}
-
-static void
-put_madw(osm_vendor_t * p_vend, osm_madw_t * p_madw, ib_net64_t tid)
-{
- umad_match_t *m, *e, *old_lru, *lru = 0;
- osm_madw_t *p_req_madw;
- osm_umad_bind_info_t *p_bind;
- ib_net64_t old_tid;
- uint32_t oldest = ~0;
-
- pthread_mutex_lock(&p_vend->match_tbl_mutex);
- for (m = p_vend->mtbl.tbl, e = m + p_vend->mtbl.max; m < e; m++) {
- if (m->tid == 0) {
- m->tid = tid;
- m->v = p_madw;
- m->version =
- cl_atomic_inc((atomic32_t *) & p_vend->mtbl.
- last_version);
- pthread_mutex_unlock(&p_vend->match_tbl_mutex);
- return;
- }
- if (oldest > m->version) {
- oldest = m->version;
- lru = m;
- }
- }
-
- old_lru = lru;
- old_tid = lru->tid;
- p_req_madw = old_lru->v;
- p_bind = p_req_madw->h_bind;
- p_req_madw->status = IB_CANCELED;
- pthread_mutex_lock(&p_vend->cb_mutex);
- (*p_bind->send_err_callback) (p_bind->client_context, p_req_madw);
- pthread_mutex_unlock(&p_vend->cb_mutex);
- lru->tid = tid;
- lru->v = p_madw;
- lru->version =
- cl_atomic_inc((atomic32_t *) & p_vend->mtbl.last_version);
- pthread_mutex_unlock(&p_vend->match_tbl_mutex);
- OSM_LOG(p_vend->p_log, OSM_LOG_ERROR, "ERR 5402: "
- "evicting entry %p (tid was 0x%" PRIx64 ")\n", old_lru,
- cl_ntoh64(old_tid));
-}
-
-static void
-ib_mad_addr_conv(ib_user_mad_t * umad, osm_mad_addr_t * osm_mad_addr,
- int is_smi)
-{
- ib_mad_addr_t *ib_mad_addr = umad_get_mad_addr(umad);
- osm_mad_addr->dest_lid = ib_mad_addr->lid;
- osm_mad_addr->path_bits = ib_mad_addr->path_bits;
- osm_mad_addr->static_rate = 0;
-
- if (is_smi) {
- osm_mad_addr->addr_type.smi.source_lid = osm_mad_addr->dest_lid;
- osm_mad_addr->addr_type.smi.port_num = 255; /* not used */
- return;
- }
-
- osm_mad_addr->addr_type.gsi.remote_qp = ib_mad_addr->qpn;
- osm_mad_addr->addr_type.gsi.remote_qkey = ib_mad_addr->qkey;
- osm_mad_addr->addr_type.gsi.pkey_ix = umad_get_pkey(umad);
- osm_mad_addr->addr_type.gsi.service_level = ib_mad_addr->sl;
- osm_mad_addr->addr_type.gsi.global_route = 0; /* FIXME: handle GRH */
- memset(&osm_mad_addr->addr_type.gsi.grh_info, 0,
- sizeof osm_mad_addr->addr_type.gsi.grh_info);
-}
-
-static void *swap_mad_bufs(osm_madw_t * p_madw, void *umad)
-{
- void *old;
-
- old = p_madw->vend_wrap.umad;
- p_madw->vend_wrap.umad = umad;
- p_madw->p_mad = umad_get_mad(umad);
-
- return old;
-}
-
-static void unlock_mutex(void *arg)
-{
- pthread_mutex_unlock(arg);
-}
-
-static void *umad_receiver(void *p_ptr)
-{
- umad_receiver_t *const p_ur = (umad_receiver_t *) p_ptr;
- osm_vendor_t *p_vend = p_ur->p_vend;
- osm_umad_bind_info_t *p_bind;
- ib_mad_addr_t *ib_mad_addr;
- osm_mad_addr_t osm_addr;
- osm_madw_t *p_madw, *p_req_madw;
- ib_mad_t *mad;
- void *umad = 0;
- int mad_agent, length;
-
- OSM_LOG_ENTER(p_ur->p_log);
-
- for (;;) {
- if (!umad &&
- !(umad = umad_alloc(1, umad_size() + MAD_BLOCK_SIZE))) {
- OSM_LOG(p_ur->p_log, OSM_LOG_ERROR, "ERR 5403: "
- "can't alloc MAD sized umad\n");
- break;
- }
-
- length = MAD_BLOCK_SIZE;
- if ((mad_agent = umad_recv(p_vend->umad_port_id, umad,
- &length, -1)) < 0) {
- if (length <= MAD_BLOCK_SIZE) {
- OSM_LOG(p_ur->p_log, OSM_LOG_ERROR, "ERR 5404: "
- "recv error on MAD sized umad (%m)\n");
- continue;
- } else {
- umad_free(umad);
- /* Need a larger buffer for RMPP */
- umad = umad_alloc(1, umad_size() + length);
- if (!umad) {
- OSM_LOG(p_ur->p_log, OSM_LOG_ERROR,
- "ERR 5405: "
- "can't alloc umad length %d\n",
- length);
- continue;
- }
-
- if ((mad_agent = umad_recv(p_vend->umad_port_id,
- umad, &length,
- -1)) < 0) {
- OSM_LOG(p_ur->p_log, OSM_LOG_ERROR,
- "ERR 5406: "
- "recv error on umad length %d (%m)\n",
- length);
- continue;
- }
- }
- }
-
- if (mad_agent >= UMAD_CA_MAX_AGENTS ||
- !(p_bind = p_vend->agents[mad_agent])) {
- OSM_LOG(p_ur->p_log, OSM_LOG_ERROR, "ERR 5407: "
- "invalid mad agent %d - dropping\n", mad_agent);
- continue;
- }
-
- mad = (ib_mad_t *) umad_get_mad(umad);
- ib_mad_addr = umad_get_mad_addr(umad);
-
- ib_mad_addr_conv(umad, &osm_addr,
- mad->mgmt_class == IB_MCLASS_SUBN_LID ||
- mad->mgmt_class == IB_MCLASS_SUBN_DIR);
-
- if (!(p_madw = osm_mad_pool_get(p_bind->p_mad_pool,
- (osm_bind_handle_t) p_bind,
- MAX(length, MAD_BLOCK_SIZE),
- &osm_addr))) {
- OSM_LOG(p_vend->p_log, OSM_LOG_ERROR, "ERR 5408: "
- "request for a new madw failed -- dropping packet\n");
- continue;
- }
-
- /* Need to fix up MAD size if short RMPP packet */
- if (length < MAD_BLOCK_SIZE)
- p_madw->mad_size = length;
-
- /*
- * Avoid copying by swapping mad buf pointers.
- * Do not use umad after this line of code.
- */
- umad = swap_mad_bufs(p_madw, umad);
-
- /* if status != 0 then we are handling recv timeout on send */
- if (umad_status(p_madw->vend_wrap.umad)) {
- OSM_LOG(p_vend->p_log, OSM_LOG_ERROR, "ERR 5409: "
- "send completed with error"
- " (method=0x%X attr=0x%X trans_id=0x%" PRIx64
- ") -- dropping\n",
- mad->method, cl_ntoh16(mad->attr_id),
- cl_ntoh64(mad->trans_id));
- if (mad->mgmt_class != IB_MCLASS_SUBN_DIR) {
- /* LID routed */
- OSM_LOG(p_vend->p_log, OSM_LOG_ERROR,
- "ERR 5410: class 0x%x LID 0x%x\n",
- mad->mgmt_class,
- cl_ntoh16(ib_mad_addr->lid));
- } else {
- ib_smp_t *smp;
-
- /* Direct routed SMP */
- smp = (ib_smp_t *) mad;
- OSM_LOG(p_vend->p_log, OSM_LOG_ERROR,
- "ERR 5411: DR SMP Hop Ptr: 0x%X\n",
- smp->hop_ptr);
- osm_dump_smp_dr_path(p_vend->p_log, smp,
- OSM_LOG_ERROR);
- }
-
- if (!(p_req_madw = get_madw(p_vend, &mad->trans_id))) {
- OSM_LOG(p_vend->p_log, OSM_LOG_ERROR,
- "ERR 5412: "
- "Failed to obtain request madw for timed out MAD"
- "(method=0x%X attr=0x%X tid=0x%"PRIx64") -- dropping\n",
- mad->method, cl_ntoh16(mad->attr_id),
- cl_ntoh64(mad->trans_id));
- } else {
- p_req_madw->status = IB_TIMEOUT;
- /* cb frees req_madw */
- pthread_mutex_lock(&p_vend->cb_mutex);
- pthread_cleanup_push(unlock_mutex,
- &p_vend->cb_mutex);
- (*p_bind->send_err_callback) (p_bind->
- client_context,
- p_req_madw);
- pthread_cleanup_pop(1);
- }
-
- osm_mad_pool_put(p_bind->p_mad_pool, p_madw);
- continue;
- }
-
- p_req_madw = 0;
- if (ib_mad_is_response(mad) &&
- !(p_req_madw = get_madw(p_vend, &mad->trans_id))) {
- OSM_LOG(p_vend->p_log, OSM_LOG_ERROR, "ERR 5413: "
- "Failed to obtain request madw for received MAD"
- "(method=0x%X attr=0x%X tid=0x%"PRIx64") -- dropping\n",
- mad->method, cl_ntoh16((mad)->attr_id),
- cl_ntoh64(mad->trans_id));
- osm_mad_pool_put(p_bind->p_mad_pool, p_madw);
- continue;
- }
-#ifndef VENDOR_RMPP_SUPPORT
- if ((mad->mgmt_class != IB_MCLASS_SUBN_DIR) &&
- (mad->mgmt_class != IB_MCLASS_SUBN_LID) &&
- (ib_rmpp_is_flag_set((ib_rmpp_mad_t *) mad,
- IB_RMPP_FLAG_ACTIVE))) {
- OSM_LOG(p_vend->p_log, OSM_LOG_ERROR, "ERR 5414: "
- "class 0x%x method 0x%x RMPP version %d type "
- "%d flags 0x%x received -- dropping\n",
- mad->mgmt_class, mad->method,
- ((ib_rmpp_mad_t *) mad)->rmpp_version,
- ((ib_rmpp_mad_t *) mad)->rmpp_type,
- ((ib_rmpp_mad_t *) mad)->rmpp_flags);
- osm_mad_pool_put(p_bind->p_mad_pool, p_madw);
- continue;
- }
-#endif
-
- /* call the CB */
- pthread_mutex_lock(&p_vend->cb_mutex);
- pthread_cleanup_push(unlock_mutex, &p_vend->cb_mutex);
- (*p_bind->mad_recv_callback) (p_madw, p_bind->client_context,
- p_req_madw);
- pthread_cleanup_pop(1);
- }
-
- OSM_LOG_EXIT(p_vend->p_log);
- return NULL;
-}
-
-static int umad_receiver_start(osm_vendor_t * p_vend)
-{
- umad_receiver_t *p_ur = p_vend->receiver;
-
- p_ur->p_vend = p_vend;
- p_ur->p_log = p_vend->p_log;
-
- if (pthread_create(&p_ur->tid, NULL, umad_receiver, p_ur) < 0)
- return -1;
-
- return 0;
-}
-
-static void umad_receiver_stop(umad_receiver_t * p_ur)
-{
- pthread_cancel(p_ur->tid);
- pthread_join(p_ur->tid, NULL);
- p_ur->tid = 0;
- p_ur->p_vend = NULL;
- p_ur->p_log = NULL;
-}
-
-/**********************************************************************
- **********************************************************************/
-ib_api_status_t
-osm_vendor_init(IN osm_vendor_t * const p_vend,
- IN osm_log_t * const p_log, IN const uint32_t timeout)
-{
- char *max = NULL;
- int r, n_cas;
-
- OSM_LOG_ENTER(p_log);
-
- p_vend->p_log = p_log;
- p_vend->timeout = timeout;
- p_vend->max_retries = OSM_DEFAULT_RETRY_COUNT;
- pthread_mutex_init(&p_vend->cb_mutex, NULL);
- pthread_mutex_init(&p_vend->match_tbl_mutex, NULL);
- p_vend->umad_port_id = -1;
- p_vend->issmfd = -1;
-
- /*
- * Open our instance of UMAD.
- */
- if ((r = umad_init()) < 0) {
- OSM_LOG(p_vend->p_log, OSM_LOG_ERROR,
- "ERR 5415: Error opening UMAD\n");
- }
-
- if ((n_cas = umad_get_cas_names(p_vend->ca_names,
- OSM_UMAD_MAX_CAS)) < 0) {
- OSM_LOG(p_vend->p_log, OSM_LOG_ERROR,
- "ERR 5416: umad_get_cas_names failed\n");
- r = n_cas;
- goto Exit;
- }
-
- p_vend->ca_count = n_cas;
- p_vend->mtbl.max = DEFAULT_OSM_UMAD_MAX_PENDING;
-
- if ((max = getenv("OSM_UMAD_MAX_PENDING")) != NULL) {
- int tmp = strtol(max, NULL, 0);
- if (tmp > 0)
- p_vend->mtbl.max = tmp;
- else
- OSM_LOG(p_vend->p_log, OSM_LOG_ERROR, "Error:"
- "OSM_UMAD_MAX_PENDING=%d is invalid",
- tmp);
- }
-
- OSM_LOG(p_vend->p_log, OSM_LOG_INFO, "%d pending umads specified\n",
- p_vend->mtbl.max);
-
- p_vend->mtbl.tbl = calloc(p_vend->mtbl.max, sizeof(*(p_vend->mtbl.tbl)));
- if (!p_vend->mtbl.tbl) {
- OSM_LOG(p_vend->p_log, OSM_LOG_ERROR, "Error:"
- "failed to allocate vendor match table\n");
- r = IB_INSUFFICIENT_MEMORY;
- goto Exit;
- }
-
-Exit:
- OSM_LOG_EXIT(p_log);
- return (r);
-}
-
-/**********************************************************************
- **********************************************************************/
-osm_vendor_t *osm_vendor_new(IN osm_log_t * const p_log,
- IN const uint32_t timeout)
-{
- osm_vendor_t *p_vend = NULL;
-
- OSM_LOG_ENTER(p_log);
-
- if (!timeout) {
- OSM_LOG(p_log, OSM_LOG_ERROR, "ERR 5433: "
- "transaction timeout cannot be 0\n");
- goto Exit;
- }
-
- p_vend = malloc(sizeof(*p_vend));
- if (p_vend == NULL) {
- OSM_LOG(p_log, OSM_LOG_ERROR, "ERR 5417: "
- "Unable to allocate vendor object\n");
- goto Exit;
- }
-
- memset(p_vend, 0, sizeof(*p_vend));
-
- if (osm_vendor_init(p_vend, p_log, timeout) < 0) {
- free(p_vend);
- p_vend = NULL;
- }
-
-Exit:
- OSM_LOG_EXIT(p_log);
- return (p_vend);
-}
-
-/**********************************************************************
- **********************************************************************/
-void osm_vendor_delete(IN osm_vendor_t ** const pp_vend)
-{
- osm_vendor_close_port(*pp_vend);
-
- clear_madw(*pp_vend);
- /* make sure all ports are closed */
- umad_done();
-
- pthread_mutex_destroy(&(*pp_vend)->cb_mutex);
- pthread_mutex_destroy(&(*pp_vend)->match_tbl_mutex);
- free((*pp_vend)->mtbl.tbl);
- free(*pp_vend);
- *pp_vend = NULL;
-}
-
-/**********************************************************************
- **********************************************************************/
-ib_api_status_t
-osm_vendor_get_all_port_attr(IN osm_vendor_t * const p_vend,
- IN ib_port_attr_t * const p_attr_array,
- IN uint32_t * const p_num_ports)
-{
- umad_ca_t ca;
- ib_port_attr_t *attr = p_attr_array;
- unsigned done = 0;
- int r, i, j;
-
- OSM_LOG_ENTER(p_vend->p_log);
-
- CL_ASSERT(p_vend && p_num_ports);
-
- if (!*p_num_ports) {
- r = IB_INVALID_PARAMETER;
- OSM_LOG(p_vend->p_log, OSM_LOG_ERROR, "ERR 5418: "
- "Ports in should be > 0\n");
- goto Exit;
- }
-
- if (!p_attr_array) {
- r = IB_INSUFFICIENT_MEMORY;
- *p_num_ports = 0;
- goto Exit;
- }
-
- for (i = 0; i < p_vend->ca_count && !done; i++) {
- /*
- * For each CA, retrieve the port guids
- */
- if (umad_get_ca(p_vend->ca_names[i], &ca) == 0) {
- if (ca.node_type < 1 || ca.node_type > 3)
- continue;
- for (j = 0; j <= ca.numports; j++) {
- if (!ca.ports[j])
- continue;
- attr->port_guid = ca.ports[j]->port_guid;
- attr->lid = ca.ports[j]->base_lid;
- attr->port_num = ca.ports[j]->portnum;
- attr->sm_lid = ca.ports[j]->sm_lid;
- attr->link_state = ca.ports[j]->state;
- attr++;
- if (attr - p_attr_array > *p_num_ports) {
- done = 1;
- break;
- }
- }
- umad_release_ca(&ca);
- }
- }
-
- *p_num_ports = attr - p_attr_array;
- r = 0;
-
-Exit:
- OSM_LOG_EXIT(p_vend->p_log);
- return r;
-}
-
-/**********************************************************************
- **********************************************************************/
-static int
-osm_vendor_open_port(IN osm_vendor_t * const p_vend,
- IN const ib_net64_t port_guid)
-{
- ib_net64_t portguids[OSM_UMAD_MAX_PORTS_PER_CA + 1];
- umad_ca_t umad_ca;
- int i = 0, umad_port_id = -1;
- char *name;
- int ca, r;
-
- CL_ASSERT(p_vend);
-
- OSM_LOG_ENTER(p_vend->p_log);
-
- if (p_vend->umad_port_id >= 0) {
- umad_port_id = p_vend->umad_port_id;
- goto Exit;
- }
-
- if (!port_guid) {
- name = NULL;
- i = 0;
- goto _found;
- }
-
- for (ca = 0; ca < p_vend->ca_count; ca++) {
- if ((r = umad_get_ca_portguids(p_vend->ca_names[ca],
- portguids,
- OSM_UMAD_MAX_CAS)) < 0) {
- OSM_LOG(p_vend->p_log, OSM_LOG_ERROR, "ERR 5421: "
- "Unable to get CA %s port guids (%s)\n",
- p_vend->ca_names[ca], strerror(r));
- goto Exit;
- }
- for (i = 0; i < r; i++)
- if (port_guid == portguids[i]) {
- name = p_vend->ca_names[ca];
- goto _found;
- }
- }
-
- /*
- * No local CA owns this guid!
- */
- OSM_LOG(p_vend->p_log, OSM_LOG_ERROR, "ERR 5422: "
- "Unable to find requested CA guid 0x%" PRIx64 "\n",
- cl_ntoh64(port_guid));
- goto Exit;
-
-_found:
- /* Validate that node is an IB node type (not iWARP) */
- if (umad_get_ca(name, &umad_ca) < 0) {
- OSM_LOG(p_vend->p_log, OSM_LOG_ERROR, "ERR 542A: "
- "umad_get_ca() failed\n");
- goto Exit;
- }
-
- if (umad_ca.node_type < 1 || umad_ca.node_type > 3) {
- OSM_LOG(p_vend->p_log, OSM_LOG_ERROR, "ERR 542D: "
- "Type %d of node \'%s\' is not an IB node type\n",
- umad_ca.node_type, umad_ca.ca_name);
- fprintf(stderr,
- "Type %d of node \'%s\' is not an IB node type\n",
- umad_ca.node_type, umad_ca.ca_name);
- umad_release_ca(&umad_ca);
- goto Exit;
- }
- umad_release_ca(&umad_ca);
-
- /* Port found, try to open it */
- if (umad_get_port(name, i, &p_vend->umad_port) < 0) {
- OSM_LOG(p_vend->p_log, OSM_LOG_ERROR, "ERR 542B: "
- "umad_get_port() failed\n");
- goto Exit;
- }
-
- if ((umad_port_id = umad_open_port(p_vend->umad_port.ca_name,
- p_vend->umad_port.portnum)) < 0) {
- OSM_LOG(p_vend->p_log, OSM_LOG_ERROR, "ERR 542C: "
- "umad_open_port() failed\n");
- goto Exit;
- }
-
- p_vend->umad_port_id = umad_port_id;
-
- /* start receiver thread */
- if (!(p_vend->receiver = calloc(1, sizeof(umad_receiver_t)))) {
- OSM_LOG(p_vend->p_log, OSM_LOG_ERROR, "ERR 5423: "
- "Unable to alloc receiver struct\n");
- umad_close_port(umad_port_id);
- umad_release_port(&p_vend->umad_port);
- p_vend->umad_port.port_guid = 0;
- p_vend->umad_port_id = umad_port_id = -1;
- goto Exit;
- }
- if (umad_receiver_start(p_vend) != 0) {
- OSM_LOG(p_vend->p_log, OSM_LOG_ERROR, "ERR 5420: "
- "umad_receiver_init failed\n");
- umad_close_port(umad_port_id);
- umad_release_port(&p_vend->umad_port);
- p_vend->umad_port.port_guid = 0;
- p_vend->umad_port_id = umad_port_id = -1;
- }
-
-Exit:
- OSM_LOG_EXIT(p_vend->p_log);
- return umad_port_id;
-}
-
-static void osm_vendor_close_port(osm_vendor_t * const p_vend)
-{
- umad_receiver_t *p_ur;
- int i;
-
- p_ur = p_vend->receiver;
- p_vend->receiver = NULL;
- if (p_ur) {
- umad_receiver_stop(p_ur);
- free(p_ur);
- }
-
- if (p_vend->umad_port_id >= 0) {
- for (i = 0; i < UMAD_CA_MAX_AGENTS; i++)
- if (p_vend->agents[i])
- umad_unregister(p_vend->umad_port_id, i);
- umad_close_port(p_vend->umad_port_id);
- umad_release_port(&p_vend->umad_port);
- p_vend->umad_port.port_guid = 0;
- p_vend->umad_port_id = -1;
- }
-}
-
-static int set_bit(int nr, void *method_mask)
-{
- long mask, *addr = method_mask;
- int retval;
-
- addr += nr / (8 * sizeof(long));
- mask = 1L << (nr % (8 * sizeof(long)));
- retval = (mask & *addr) != 0;
- *addr |= mask;
- return retval;
-}
-
-/**********************************************************************
- **********************************************************************/
-osm_bind_handle_t
-osm_vendor_bind(IN osm_vendor_t * const p_vend,
- IN osm_bind_info_t * const p_user_bind,
- IN osm_mad_pool_t * const p_mad_pool,
- IN osm_vend_mad_recv_callback_t mad_recv_callback,
- IN osm_vend_mad_send_err_callback_t send_err_callback,
- IN void *context)
-{
- ib_net64_t port_guid;
- osm_umad_bind_info_t *p_bind = 0;
- long method_mask[16 / sizeof(long)];
- int umad_port_id;
- uint8_t rmpp_version;
-
- OSM_LOG_ENTER(p_vend->p_log);
-
- CL_ASSERT(p_user_bind);
- CL_ASSERT(p_mad_pool);
- CL_ASSERT(mad_recv_callback);
- CL_ASSERT(send_err_callback);
-
- port_guid = p_user_bind->port_guid;
-
- OSM_LOG(p_vend->p_log, OSM_LOG_INFO,
- "Binding to port 0x%" PRIx64 "\n", cl_ntoh64(port_guid));
-
- if ((umad_port_id = osm_vendor_open_port(p_vend, port_guid)) < 0) {
- OSM_LOG(p_vend->p_log, OSM_LOG_ERROR, "ERR 5424: "
- "Unable to open port 0x%" PRIx64 "\n",
- cl_ntoh64(port_guid));
- goto Exit;
- }
-
- if (umad_get_issm_path(p_vend->umad_port.ca_name,
- p_vend->umad_port.portnum,
- p_vend->issm_path,
- sizeof(p_vend->issm_path)) < 0) {
- OSM_LOG(p_vend->p_log, OSM_LOG_ERROR, "ERR 542E: "
- "Cannot resolve issm path for port %s:%u\n",
- p_vend->umad_port.ca_name, p_vend->umad_port.portnum);
- goto Exit;
- }
-
- if (!(p_bind = malloc(sizeof(*p_bind)))) {
- OSM_LOG(p_vend->p_log, OSM_LOG_ERROR, "ERR 5425: "
- "Unable to allocate internal bind object\n");
- goto Exit;
- }
-
- memset(p_bind, 0, sizeof(*p_bind));
- p_bind->p_vend = p_vend;
- p_bind->port_id = umad_port_id;
- p_bind->client_context = context;
- p_bind->mad_recv_callback = mad_recv_callback;
- p_bind->send_err_callback = send_err_callback;
- p_bind->p_mad_pool = p_mad_pool;
- p_bind->port_guid = port_guid;
-
- memset(method_mask, 0, sizeof method_mask);
- if (p_user_bind->is_responder) {
- set_bit(IB_MAD_METHOD_GET, &method_mask);
- set_bit(IB_MAD_METHOD_SET, &method_mask);
- if (p_user_bind->mad_class == IB_MCLASS_SUBN_ADM) {
- set_bit(IB_MAD_METHOD_GETTABLE, &method_mask);
- set_bit(IB_MAD_METHOD_DELETE, &method_mask);
-#ifdef DUAL_SIDED_RMPP
- set_bit(IB_MAD_METHOD_GETMULTI, &method_mask);
-#endif
- /* Add in IB_MAD_METHOD_GETTRACETABLE */
- /* when supported by OpenSM */
- }
- }
- if (p_user_bind->is_report_processor)
- set_bit(IB_MAD_METHOD_REPORT, &method_mask);
- if (p_user_bind->is_trap_processor) {
- set_bit(IB_MAD_METHOD_TRAP, &method_mask);
- set_bit(IB_MAD_METHOD_TRAP_REPRESS, &method_mask);
- }
-#ifndef VENDOR_RMPP_SUPPORT
- rmpp_version = 0;
-#else
- /* If SA class, set rmpp_version */
- if (p_user_bind->mad_class == IB_MCLASS_SUBN_ADM)
- rmpp_version = 1;
- else
- rmpp_version = 0;
-#endif
-
- if ((p_bind->agent_id = umad_register(p_vend->umad_port_id,
- p_user_bind->mad_class,
- p_user_bind->class_version,
- rmpp_version, method_mask)) < 0) {
- OSM_LOG(p_vend->p_log, OSM_LOG_ERROR, "ERR 5426: "
- "Unable to register class %u version %u\n",
- p_user_bind->mad_class, p_user_bind->class_version);
- free(p_bind);
- p_bind = 0;
- goto Exit;
- }
-
- if (p_bind->agent_id >= UMAD_CA_MAX_AGENTS ||
- p_vend->agents[p_bind->agent_id]) {
- OSM_LOG(p_vend->p_log, OSM_LOG_ERROR, "ERR 5427: "
- "bad agent id %u or duplicate agent for class %u vers %u\n",
- p_bind->agent_id, p_user_bind->mad_class,
- p_user_bind->class_version);
- free(p_bind);
- p_bind = 0;
- goto Exit;
- }
-
- p_vend->agents[p_bind->agent_id] = p_bind;
-
- /* If Subn Directed Route class, register Subn LID routed class */
- if (p_user_bind->mad_class == IB_MCLASS_SUBN_DIR) {
- if ((p_bind->agent_id1 = umad_register(p_vend->umad_port_id,
- IB_MCLASS_SUBN_LID,
- p_user_bind->
- class_version, 0,
- method_mask)) < 0) {
- OSM_LOG(p_vend->p_log, OSM_LOG_ERROR, "ERR 5428: "
- "Unable to register class 1 version %u\n",
- p_user_bind->class_version);
- free(p_bind);
- p_bind = 0;
- goto Exit;
- }
-
- if (p_bind->agent_id1 >= UMAD_CA_MAX_AGENTS ||
- p_vend->agents[p_bind->agent_id1]) {
- OSM_LOG(p_vend->p_log, OSM_LOG_ERROR, "ERR 5429: "
- "bad agent id %u or duplicate agent for class 1 vers %u\n",
- p_bind->agent_id1, p_user_bind->class_version);
- free(p_bind);
- p_bind = 0;
- goto Exit;
- }
-
- p_vend->agents[p_bind->agent_id1] = p_bind;
- }
-
-Exit:
- OSM_LOG_EXIT(p_vend->p_log);
- return ((osm_bind_handle_t) p_bind);
-}
-
-/**********************************************************************
- **********************************************************************/
-static void
-__osm_vendor_recv_dummy_cb(IN osm_madw_t * p_madw,
- IN void *bind_context, IN osm_madw_t * p_req_madw)
-{
-#ifdef _DEBUG_
- fprintf(stderr,
- "__osm_vendor_recv_dummy_cb: Ignoring received MAD after osm_vendor_unbind\n");
-#endif
-}
-
-/**********************************************************************
- **********************************************************************/
-static void
-__osm_vendor_send_err_dummy_cb(IN void *bind_context,
- IN osm_madw_t * p_req_madw)
-{
-#ifdef _DEBUG_
- fprintf(stderr,
- "__osm_vendor_send_err_dummy_cb: Ignoring send error after osm_vendor_unbind\n");
-#endif
-}
-
-/**********************************************************************
- **********************************************************************/
-void osm_vendor_unbind(IN osm_bind_handle_t h_bind)
-{
- osm_umad_bind_info_t *p_bind = (osm_umad_bind_info_t *) h_bind;
- osm_vendor_t *p_vend = p_bind->p_vend;
-
- OSM_LOG_ENTER(p_vend->p_log);
-
- pthread_mutex_lock(&p_vend->cb_mutex);
- p_bind->mad_recv_callback = __osm_vendor_recv_dummy_cb;
- p_bind->send_err_callback = __osm_vendor_send_err_dummy_cb;
- pthread_mutex_unlock(&p_vend->cb_mutex);
-
- OSM_LOG_EXIT(p_vend->p_log);
-}
-
-/**********************************************************************
- **********************************************************************/
-ib_mad_t *osm_vendor_get(IN osm_bind_handle_t h_bind,
- IN const uint32_t mad_size,
- IN osm_vend_wrap_t * const p_vw)
-{
- osm_umad_bind_info_t *p_bind = (osm_umad_bind_info_t *) h_bind;
- osm_vendor_t *p_vend = p_bind->p_vend;
-
- OSM_LOG_ENTER(p_vend->p_log);
-
- OSM_LOG(p_vend->p_log, OSM_LOG_DEBUG,
- "Acquiring UMAD for p_madw = %p, size = %u\n", p_vw, mad_size);
- CL_ASSERT(p_vw);
- p_vw->size = mad_size;
- p_vw->umad = umad_alloc(1, mad_size + umad_size());
-
- /* track locally */
- p_vw->h_bind = h_bind;
-
- OSM_LOG(p_vend->p_log, OSM_LOG_DEBUG,
- "Acquired UMAD %p, size = %u\n", p_vw->umad, p_vw->size);
-
- OSM_LOG_EXIT(p_vend->p_log);
- return umad_get_mad(p_vw->umad);
-}
-
-/**********************************************************************
- **********************************************************************/
-void
-osm_vendor_put(IN osm_bind_handle_t h_bind, IN osm_vend_wrap_t * const p_vw)
-{
- osm_umad_bind_info_t *p_bind = (osm_umad_bind_info_t *) h_bind;
- osm_vendor_t *p_vend = p_bind->p_vend;
- osm_madw_t *p_madw;
-
- OSM_LOG_ENTER(p_vend->p_log);
-
- CL_ASSERT(p_vw);
-
- OSM_LOG(p_vend->p_log, OSM_LOG_DEBUG, "Retiring UMAD %p\n", p_vw->umad);
-
- /*
- * We moved the removal of the transaction to immediately after
- * it was looked up.
- */
-
- /* free the mad but the wrapper is part of the madw object */
- umad_free(p_vw->umad);
- p_vw->umad = 0;
- p_madw = PARENT_STRUCT(p_vw, osm_madw_t, vend_wrap);
- p_madw->p_mad = NULL;
-
- OSM_LOG_EXIT(p_vend->p_log);
-}
-
-/**********************************************************************
- **********************************************************************/
-ib_api_status_t
-osm_vendor_send(IN osm_bind_handle_t h_bind,
- IN osm_madw_t * const p_madw, IN boolean_t const resp_expected)
-{
- osm_umad_bind_info_t *const p_bind = h_bind;
- osm_vendor_t *const p_vend = p_bind->p_vend;
- osm_vend_wrap_t *const p_vw = osm_madw_get_vend_ptr(p_madw);
- osm_mad_addr_t *const p_mad_addr = osm_madw_get_mad_addr_ptr(p_madw);
- ib_mad_t *const p_mad = osm_madw_get_mad_ptr(p_madw);
- ib_sa_mad_t *const p_sa = (ib_sa_mad_t *) p_mad;
- int ret = -1;
- int is_rmpp = 0;
- uint32_t sent_mad_size;
-#ifndef VENDOR_RMPP_SUPPORT
- uint32_t paylen = 0;
-#endif
-
- OSM_LOG_ENTER(p_vend->p_log);
-
- CL_ASSERT(p_vw->h_bind == h_bind);
- CL_ASSERT(p_mad == umad_get_mad(p_vw->umad));
-
- if (p_mad->mgmt_class == IB_MCLASS_SUBN_DIR) {
- umad_set_addr_net(p_vw->umad, 0xffff, 0, 0, 0);
- umad_set_grh(p_vw->umad, 0);
- goto Resp;
- }
- if (p_mad->mgmt_class == IB_MCLASS_SUBN_LID) {
- umad_set_addr_net(p_vw->umad, p_mad_addr->dest_lid, 0, 0, 0);
- umad_set_grh(p_vw->umad, 0);
- goto Resp;
- }
- /* GSI classes */
- umad_set_addr_net(p_vw->umad, p_mad_addr->dest_lid,
- p_mad_addr->addr_type.gsi.remote_qp,
- p_mad_addr->addr_type.gsi.service_level,
- IB_QP1_WELL_KNOWN_Q_KEY);
- umad_set_grh(p_vw->umad, 0); /* FIXME: GRH support */
- umad_set_pkey(p_vw->umad, p_mad_addr->addr_type.gsi.pkey_ix);
- if (ib_class_is_rmpp(p_mad->mgmt_class)) { /* RMPP GSI classes FIXME: no GRH */
- if (!ib_rmpp_is_flag_set((ib_rmpp_mad_t *) p_sa,
- IB_RMPP_FLAG_ACTIVE)) {
- /* Clear RMPP header when RMPP not ACTIVE */
- p_sa->rmpp_version = 0;
- p_sa->rmpp_type = 0;
- p_sa->rmpp_flags = 0;
- p_sa->rmpp_status = 0;
-#ifdef VENDOR_RMPP_SUPPORT
- } else
- is_rmpp = 1;
- OSM_LOG(p_vend->p_log, OSM_LOG_VERBOSE, "RMPP %d length %d\n",
- ib_rmpp_is_flag_set((ib_rmpp_mad_t *) p_sa,
- IB_RMPP_FLAG_ACTIVE),
- p_madw->mad_size);
-#else
- } else {
- p_sa->rmpp_version = 1;
- p_sa->seg_num = cl_ntoh32(1); /* first DATA is seg 1 */
- p_sa->rmpp_flags |= (uint8_t) 0x70; /* RRespTime of 14 (high 5 bits) */
- p_sa->rmpp_status = 0;
- paylen = p_madw->mad_size - IB_SA_MAD_HDR_SIZE;
- paylen += (IB_SA_MAD_HDR_SIZE - MAD_RMPP_HDR_SIZE);
- p_sa->paylen_newwin = cl_ntoh32(paylen);
- }
-#endif
- }
-
-Resp:
- if (resp_expected)
- put_madw(p_vend, p_madw, p_mad->trans_id);
-
-#ifdef VENDOR_RMPP_SUPPORT
- sent_mad_size = p_madw->mad_size;
-#else
- sent_mad_size = is_rmpp ? p_madw->mad_size - IB_SA_MAD_HDR_SIZE :
- p_madw->mad_size;
-#endif
- if ((ret = umad_send(p_bind->port_id, p_bind->agent_id, p_vw->umad,
- sent_mad_size,
- resp_expected ? p_vend->timeout : 0,
- p_vend->max_retries)) < 0) {
- OSM_LOG(p_vend->p_log, OSM_LOG_ERROR, "ERR 5430: "
- "Send p_madw = %p of size %d failed %d (%m)\n",
- p_madw, sent_mad_size, ret);
- if (resp_expected) {
- get_madw(p_vend, &p_mad->trans_id); /* remove from aging table */
- p_madw->status = IB_ERROR;
- pthread_mutex_lock(&p_vend->cb_mutex);
- (*p_bind->send_err_callback) (p_bind->client_context, p_madw); /* cb frees madw */
- pthread_mutex_unlock(&p_vend->cb_mutex);
- } else
- osm_mad_pool_put(p_bind->p_mad_pool, p_madw);
- goto Exit;
- }
-
- if (!resp_expected)
- osm_mad_pool_put(p_bind->p_mad_pool, p_madw);
-
- OSM_LOG(p_vend->p_log, OSM_LOG_DEBUG, "Completed sending %s p_madw = %p\n",
- resp_expected ? "request" : "response or unsolicited", p_madw);
-Exit:
- OSM_LOG_EXIT(p_vend->p_log);
- return (ret);
-}
-
-/**********************************************************************
- **********************************************************************/
-ib_api_status_t osm_vendor_local_lid_change(IN osm_bind_handle_t h_bind)
-{
- osm_umad_bind_info_t *p_bind = (osm_umad_bind_info_t *) h_bind;
- osm_vendor_t *p_vend = p_bind->p_vend;
-
- OSM_LOG_ENTER(p_vend->p_log);
- ;
- OSM_LOG_EXIT(p_vend->p_log);
- return (0);
-}
-
-/**********************************************************************
- **********************************************************************/
-void osm_vendor_set_sm(IN osm_bind_handle_t h_bind, IN boolean_t is_sm_val)
-{
- osm_umad_bind_info_t *p_bind = (osm_umad_bind_info_t *) h_bind;
- osm_vendor_t *p_vend = p_bind->p_vend;
-
- OSM_LOG_ENTER(p_vend->p_log);
- if (TRUE == is_sm_val) {
- p_vend->issmfd = open(p_vend->issm_path, O_NONBLOCK);
- if (p_vend->issmfd < 0) {
- OSM_LOG(p_vend->p_log, OSM_LOG_ERROR, "ERR 5431: "
- "setting IS_SM capmask: cannot open file "
- "\'%s\': %s\n",
- p_vend->issm_path, strerror(errno));
- p_vend->issmfd = -1;
- }
- } else if (p_vend->issmfd != -1) {
- if (0 != close(p_vend->issmfd))
- OSM_LOG(p_vend->p_log, OSM_LOG_ERROR, "ERR 5432: "
- "clearing IS_SM capmask: cannot close: %s\n",
- strerror(errno));
- p_vend->issmfd = -1;
- }
- OSM_LOG_EXIT(p_vend->p_log);
-}
-
-void osm_vendor_set_debug(IN osm_vendor_t * const p_vend, IN int32_t level)
-{
- umad_debug(level);
-}
-
-#endif /* OSM_VENDOR_INTF_OPENIB */
diff --git a/contrib/ofed/management/opensm/libvendor/osm_vendor_ibumad_sa.c b/contrib/ofed/management/opensm/libvendor/osm_vendor_ibumad_sa.c
deleted file mode 100644
index 800b308..0000000
--- a/contrib/ofed/management/opensm/libvendor/osm_vendor_ibumad_sa.c
+++ /dev/null
@@ -1,736 +0,0 @@
-/*
- * Copyright (c) 2004-2008 Voltaire, Inc. All rights reserved.
- * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved.
- * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- */
-
-#if HAVE_CONFIG_H
-# include <config.h>
-#endif /* HAVE_CONFIG_H */
-
-#include <stdlib.h>
-#include <string.h>
-#include <sys/time.h>
-#include <vendor/osm_vendor_api.h>
-#include <vendor/osm_vendor_sa_api.h>
-#include <complib/cl_event.h>
-
-/*****************************************************************************
- *****************************************************************************/
-
-/* this struct is the internal rep of the bind handle */
-typedef struct _osmv_sa_bind_info {
- osm_bind_handle_t h_bind;
- osm_log_t *p_log;
- osm_vendor_t *p_vendor;
- osm_mad_pool_t *p_mad_pool;
- cl_event_t sync_event;
- time_t last_lids_update_sec;
-} osmv_sa_bind_info_t;
-
-/*****************************************************************************
- *****************************************************************************/
-
-/*
- Call back on new mad received:
-
- We basically only need to set the context of the query.
- Or report an error.
-
- A pointer to the actual context of the request (a copy of the oriignal
- request structure) is attached as the p_madw->context.ni_context.node_guid
-*/
-static void
-__osmv_sa_mad_rcv_cb(IN osm_madw_t * p_madw,
- IN void *bind_context, IN osm_madw_t * p_req_madw)
-{
- osmv_sa_bind_info_t *p_bind = (osmv_sa_bind_info_t *) bind_context;
- osmv_query_req_t *p_query_req_copy = NULL;
- osmv_query_res_t query_res;
- ib_sa_mad_t *p_sa_mad;
- ib_net16_t mad_status;
-
- OSM_LOG_ENTER(p_bind->p_log);
-
- if (!p_req_madw) {
- OSM_LOG(p_bind->p_log, OSM_LOG_DEBUG,
- "Ignoring a non-response mad\n");
- osm_mad_pool_put(p_bind->p_mad_pool, p_madw);
- goto Exit;
- }
-
- /* obtain the sent context since we store it during send in the ni_ctx */
- p_query_req_copy =
- (osmv_query_req_t *) (long *)(long)(p_req_madw->context.ni_context.
- node_guid);
-
- /* provide the context of the original request in the result */
- query_res.query_context = p_query_req_copy->query_context;
-
- /* provide the resulting madw */
- query_res.p_result_madw = p_madw;
-
- /* update the req fields */
- p_sa_mad = (ib_sa_mad_t *) p_madw->p_mad;
-
- /* if we got a remote error track it in the status */
- mad_status = (ib_net16_t) (p_sa_mad->status & IB_SMP_STATUS_MASK);
- if (mad_status != IB_SUCCESS) {
- OSM_LOG(p_bind->p_log, OSM_LOG_ERROR, "ERR 5501: "
- "Remote error:0x%04X\n", cl_ntoh16(mad_status));
- query_res.status = IB_REMOTE_ERROR;
- } else
- query_res.status = IB_SUCCESS;
-
- /* what if we have got back an empty mad ? */
- if (!p_madw->mad_size) {
- OSM_LOG(p_bind->p_log, OSM_LOG_ERROR, "ERR 5502: "
- "Got an empty mad\n");
- query_res.status = IB_ERROR;
- }
-
- if (IB_SUCCESS == mad_status) {
-
- /* if we are in not in a method response of an rmpp nature we must get only 1 */
- /* HACK: in the future we might need to be smarter for other methods... */
- if (p_sa_mad->method != IB_MAD_METHOD_GETTABLE_RESP) {
- query_res.result_cnt = 1;
- } else {
-#ifndef VENDOR_RMPP_SUPPORT
- if (mad_status != IB_SUCCESS)
- query_res.result_cnt = 0;
- else
- query_res.result_cnt = 1;
-#else
- if (ib_get_attr_size(p_sa_mad->attr_offset)) {
- /* we used the offset value to calculate the
- number of records in here */
- query_res.result_cnt = (uintn_t)
- ((p_madw->mad_size - IB_SA_MAD_HDR_SIZE) /
- ib_get_attr_size(p_sa_mad->attr_offset));
- OSM_LOG(p_bind->p_log, OSM_LOG_DEBUG,
- "Count = %u = %zu / %u (%zu)\n",
- query_res.result_cnt,
- p_madw->mad_size - IB_SA_MAD_HDR_SIZE,
- ib_get_attr_size(p_sa_mad->attr_offset),
- (p_madw->mad_size -
- IB_SA_MAD_HDR_SIZE) %
- ib_get_attr_size(p_sa_mad->attr_offset));
- } else
- query_res.result_cnt = 0;
-#endif
- }
- }
-
- query_res.query_type = p_query_req_copy->query_type;
-
- p_query_req_copy->pfn_query_cb(&query_res);
-
- if ((p_query_req_copy->flags & OSM_SA_FLAGS_SYNC) == OSM_SA_FLAGS_SYNC)
- cl_event_signal(&p_bind->sync_event);
-
-Exit:
-
- /* free the copied query request if found */
- if (p_query_req_copy)
- free(p_query_req_copy);
-
- /* put back the request madw */
- if (p_req_madw)
- osm_mad_pool_put(p_bind->p_mad_pool, p_req_madw);
-
- OSM_LOG_EXIT(p_bind->p_log);
-}
-
-/*****************************************************************************
- ****************************************************************************/
-/*
- Send Error Callback:
-
- Only report the error and get rid of the mad wrapper
-*/
-static void __osmv_sa_mad_err_cb(IN void *bind_context, IN osm_madw_t * p_madw)
-{
- osmv_sa_bind_info_t *p_bind = (osmv_sa_bind_info_t *) bind_context;
- osmv_query_req_t *p_query_req_copy = NULL;
- osmv_query_res_t query_res;
-
- OSM_LOG_ENTER(p_bind->p_log);
-
- /* Obtain the sent context etc */
- p_query_req_copy =
- (osmv_query_req_t *) (long *)(long)(p_madw->context.ni_context.
- node_guid);
-
- /* provide the context of the original request in the result */
- query_res.query_context = p_query_req_copy->query_context;
-
- query_res.p_result_madw = p_madw;
-
- query_res.status = IB_TIMEOUT;
- query_res.result_cnt = 0;
-
- query_res.query_type = p_query_req_copy->query_type;
-
- p_query_req_copy->pfn_query_cb(&query_res);
-
- if ((p_query_req_copy->flags & OSM_SA_FLAGS_SYNC) == OSM_SA_FLAGS_SYNC)
- cl_event_signal(&p_bind->sync_event);
-
- if (p_query_req_copy)
- free(p_query_req_copy);
- OSM_LOG_EXIT(p_bind->p_log);
-}
-
-/*****************************************************************************
- Update lids of vendor umad_port.
- *****************************************************************************/
-static ib_api_status_t update_umad_port(osm_vendor_t * p_vend)
-{
- umad_port_t port;
- if (umad_get_port(p_vend->umad_port.ca_name,
- p_vend->umad_port.portnum, &port) < 0)
- return IB_ERROR;
- p_vend->umad_port.base_lid = port.base_lid;
- p_vend->umad_port.sm_lid = port.sm_lid;
- umad_release_port(&port);
- return IB_SUCCESS;
-}
-
-/*****************************************************************************
- *****************************************************************************/
-osm_bind_handle_t
-osmv_bind_sa(IN osm_vendor_t * const p_vend,
- IN osm_mad_pool_t * const p_mad_pool, IN ib_net64_t port_guid)
-{
- osm_bind_info_t bind_info;
- osm_log_t *p_log = p_vend->p_log;
- osmv_sa_bind_info_t *p_sa_bind_info;
- cl_status_t cl_status;
-
- OSM_LOG_ENTER(p_log);
-
- OSM_LOG(p_log, OSM_LOG_DEBUG,
- "Binding to port 0x%" PRIx64 "\n", cl_ntoh64(port_guid));
-
- bind_info.port_guid = port_guid;
- bind_info.mad_class = IB_MCLASS_SUBN_ADM;
- bind_info.class_version = 2;
- bind_info.is_responder = FALSE;
- bind_info.is_trap_processor = FALSE;
- bind_info.is_report_processor = FALSE;
- bind_info.send_q_size = OSM_SM_DEFAULT_QP1_RCV_SIZE;
- bind_info.recv_q_size = OSM_SM_DEFAULT_QP1_SEND_SIZE;
-
- /* allocate the new sa bind info */
- p_sa_bind_info =
- (osmv_sa_bind_info_t *) malloc(sizeof(osmv_sa_bind_info_t));
- if (!p_sa_bind_info) {
- OSM_LOG(p_log, OSM_LOG_ERROR, "ERR 5505: "
- "Failed to allocate new bind structure\n");
- p_sa_bind_info = OSM_BIND_INVALID_HANDLE;
- goto Exit;
- }
-
- /* store some important context */
- p_sa_bind_info->p_log = p_log;
- p_sa_bind_info->p_mad_pool = p_mad_pool;
- p_sa_bind_info->p_vendor = p_vend;
-
- /* Bind to the lower level */
- p_sa_bind_info->h_bind = osm_vendor_bind(p_vend, &bind_info, p_mad_pool, __osmv_sa_mad_rcv_cb, __osmv_sa_mad_err_cb, p_sa_bind_info); /* context provided to CBs */
-
- if (p_sa_bind_info->h_bind == OSM_BIND_INVALID_HANDLE) {
- free(p_sa_bind_info);
- p_sa_bind_info = OSM_BIND_INVALID_HANDLE;
- OSM_LOG(p_log, OSM_LOG_ERROR, "ERR 5506: "
- "Failed to bind to vendor GSI\n");
- goto Exit;
- }
-
- /* update time umad_port is initilized now */
- p_sa_bind_info->last_lids_update_sec = time(NULL);
-
- /* initialize the sync_event */
- cl_event_construct(&p_sa_bind_info->sync_event);
- cl_status = cl_event_init(&p_sa_bind_info->sync_event, TRUE);
- if (cl_status != CL_SUCCESS) {
- OSM_LOG(p_log, OSM_LOG_ERROR, "ERR 5508: "
- "cl_init_event failed: %s\n", ib_get_err_str(cl_status));
- free(p_sa_bind_info);
- p_sa_bind_info = OSM_BIND_INVALID_HANDLE;
- }
-
-Exit:
- OSM_LOG_EXIT(p_log);
- return (p_sa_bind_info);
-}
-
-/*****************************************************************************
- *****************************************************************************/
-
-/****t* OSM Vendor SA Client/osmv_sa_mad_data
- * NAME
- * osmv_sa_mad_data
- *
- * DESCRIPTION
- * Extra fields required to perform a mad query
- * This struct is passed to the actual send method
- *
- * SYNOPSIS
- */
-typedef struct _osmv_sa_mad_data {
- /* MAD data. */
- uint8_t method;
- ib_net16_t attr_id;
- ib_net16_t attr_offset;
- ib_net32_t attr_mod;
- ib_net64_t comp_mask;
- void *p_attr;
-} osmv_sa_mad_data_t;
-/*
- * method
- * The method of the mad to be sent
- *
- * attr_id
- * Attribute ID
- *
- * attr_offset
- * Offset as defined by RMPP
- *
- * attr_mod
- * Attribute modifier
- *
- * comp_mask
- * The component mask of the query
- *
- * p_attr
- * A pointer to the record of the attribute to be sent.
- *
- *****/
-
-/*****************************************************************************
- *****************************************************************************/
-/* Send a MAD out on the GSI interface */
-static ib_api_status_t
-__osmv_send_sa_req(IN osmv_sa_bind_info_t * p_bind,
- IN const osmv_sa_mad_data_t * const p_sa_mad_data,
- IN const osmv_query_req_t * const p_query_req)
-{
- ib_api_status_t status;
- ib_mad_t *p_mad_hdr;
- ib_sa_mad_t *p_sa_mad;
- osm_madw_t *p_madw;
- osm_log_t *p_log = p_bind->p_log;
- static atomic32_t trans_id;
- boolean_t sync;
- osmv_query_req_t *p_query_req_copy;
-
- OSM_LOG_ENTER(p_log);
-
- /*
- since the sm_lid might change we obtain it every send
- (actually it is cached in the bind object and refreshed
- every 30sec by this proc)
- */
- if (time(NULL) > p_bind->last_lids_update_sec + 30) {
- status = update_umad_port(p_bind->p_vendor);
- if (status != IB_SUCCESS) {
- OSM_LOG(p_log, OSM_LOG_ERROR, "ERR 5509: "
- "Failed to obtain the SM lid\n");
- goto Exit;
- }
- p_bind->last_lids_update_sec = time(NULL);
- }
-
- /* Get a MAD wrapper for the send */
- p_madw = osm_mad_pool_get(p_bind->p_mad_pool,
- p_bind->h_bind, MAD_BLOCK_SIZE, NULL);
-
- if (p_madw == NULL) {
- OSM_LOG(p_log, OSM_LOG_ERROR, "ERR 5510: "
- "Unable to acquire MAD\n");
- status = IB_INSUFFICIENT_RESOURCES;
- goto Exit;
- }
-
- /* Initialize the Sent MAD: */
-
- /* Initialize the MAD buffer for the send operation. */
- p_mad_hdr = osm_madw_get_mad_ptr(p_madw);
- p_sa_mad = osm_madw_get_sa_mad_ptr(p_madw);
-
- /* Get a new transaction Id */
- cl_atomic_inc(&trans_id);
-
- /* Cleanup the MAD from any residue */
- memset(p_sa_mad, 0, MAD_BLOCK_SIZE);
-
- /* Initialize the standard MAD header. */
- ib_mad_init_new(p_mad_hdr, /* mad pointer */
- IB_MCLASS_SUBN_ADM, /* class */
- (uint8_t) 2, /* version */
- p_sa_mad_data->method, /* method */
- cl_hton64((uint64_t) trans_id), /* tid */
- p_sa_mad_data->attr_id, /* attr id */
- p_sa_mad_data->attr_mod /* attr mod */);
-
- /* Set the query information. */
- p_sa_mad->sm_key = p_query_req->sm_key;
- p_sa_mad->attr_offset = 0;
- p_sa_mad->comp_mask = p_sa_mad_data->comp_mask;
-#ifdef DUAL_SIDED_RMPP
- if (p_sa_mad->method == IB_MAD_METHOD_GETMULTI)
- p_sa_mad->rmpp_flags = IB_RMPP_FLAG_ACTIVE;
-#endif
- if (p_sa_mad->comp_mask) {
- memcpy(p_sa_mad->data, p_sa_mad_data->p_attr,
- ib_get_attr_size(p_sa_mad_data->attr_offset));
- }
-
- /*
- Provide the address to send to
- */
- p_madw->mad_addr.dest_lid =
- cl_hton16(p_bind->p_vendor->umad_port.sm_lid);
- p_madw->mad_addr.addr_type.smi.source_lid =
- cl_hton16(p_bind->p_vendor->umad_port.base_lid);
- p_madw->mad_addr.addr_type.gsi.remote_qp = CL_HTON32(1);
- p_madw->resp_expected = TRUE;
- p_madw->fail_msg = CL_DISP_MSGID_NONE;
-
- /*
- Provide MAD context such that the call back will know what to do.
- We have to keep the entire request structure so we know the CB.
- Since we can not rely on the client to keep it around until
- the response - we duplicate it and will later dispose it (in CB).
- To store on the MADW we cast it into what opensm has:
- p_madw->context.ni_context.node_guid
- */
- p_query_req_copy = malloc(sizeof(*p_query_req_copy));
- *p_query_req_copy = *p_query_req;
- p_madw->context.ni_context.node_guid =
- (ib_net64_t) (long)p_query_req_copy;
-
- /* we can support async as well as sync calls */
- sync = ((p_query_req->flags & OSM_SA_FLAGS_SYNC) == OSM_SA_FLAGS_SYNC);
-
- /* send the mad asynchronously */
- status = osm_vendor_send(osm_madw_get_bind_handle(p_madw),
- p_madw, p_madw->resp_expected);
-
- /* if synchronous - wait on the event */
- if (sync) {
- OSM_LOG(p_log, OSM_LOG_DEBUG, "Waiting for async event\n");
- cl_event_wait_on(&p_bind->sync_event, EVENT_NO_TIMEOUT, FALSE);
- cl_event_reset(&p_bind->sync_event);
- status = p_madw->status;
- }
-
-Exit:
- OSM_LOG_EXIT(p_log);
- return status;
-}
-
-/*****************************************************************************
- *****************************************************************************/
-/*
- * Query the SA based on the user's request.
- */
-ib_api_status_t
-osmv_query_sa(IN osm_bind_handle_t h_bind,
- IN const osmv_query_req_t * const p_query_req)
-{
- osmv_sa_bind_info_t *p_bind = (osmv_sa_bind_info_t *) h_bind;
- osmv_sa_mad_data_t sa_mad_data;
- osmv_user_query_t *p_user_query;
- ib_service_record_t svc_rec;
- ib_node_record_t node_rec;
- ib_portinfo_record_t port_info;
- ib_path_rec_t path_rec;
-#ifdef DUAL_SIDED_RMPP
- ib_multipath_rec_t multipath_rec;
- osmv_multipath_req_t *p_mpr_req;
- int i, j;
-#endif
- ib_class_port_info_t class_port_info;
- osm_log_t *p_log = p_bind->p_log;
- ib_api_status_t status;
-
- OSM_LOG_ENTER(p_log);
-
- /* Set the request information. */
- sa_mad_data.method = IB_MAD_METHOD_GETTABLE;
- sa_mad_data.attr_mod = 0;
-
- /* Set the MAD attributes and component mask correctly. */
- switch (p_query_req->query_type) {
-
- case OSMV_QUERY_USER_DEFINED:
- OSM_LOG(p_log, OSM_LOG_DEBUG, "DBG:001 USER_DEFINED\n");
- p_user_query = (osmv_user_query_t *) p_query_req->p_query_input;
- if (p_user_query->method)
- sa_mad_data.method = p_user_query->method;
- sa_mad_data.attr_offset = p_user_query->attr_offset;
- sa_mad_data.attr_id = p_user_query->attr_id;
- sa_mad_data.attr_mod = p_user_query->attr_mod;
- sa_mad_data.comp_mask = p_user_query->comp_mask;
- sa_mad_data.p_attr = p_user_query->p_attr;
- break;
-
- case OSMV_QUERY_ALL_SVC_RECS:
- OSM_LOG(p_log, OSM_LOG_DEBUG, "DBG:001 SVC_REC_BY_NAME\n");
- sa_mad_data.attr_id = IB_MAD_ATTR_SERVICE_RECORD;
- sa_mad_data.attr_offset =
- ib_get_attr_offset(sizeof(ib_service_record_t));
- sa_mad_data.comp_mask = 0;
- sa_mad_data.p_attr = &svc_rec;
- break;
-
- case OSMV_QUERY_SVC_REC_BY_NAME:
- OSM_LOG(p_log, OSM_LOG_DEBUG, "DBG:001 SVC_REC_BY_NAME\n");
- sa_mad_data.method = IB_MAD_METHOD_GET;
- sa_mad_data.attr_id = IB_MAD_ATTR_SERVICE_RECORD;
- sa_mad_data.comp_mask = IB_SR_COMPMASK_SNAME;
- sa_mad_data.attr_offset =
- ib_get_attr_offset(sizeof(ib_service_record_t));
- sa_mad_data.p_attr = &svc_rec;
- memcpy(svc_rec.service_name, p_query_req->p_query_input,
- sizeof(ib_svc_name_t));
- break;
-
- case OSMV_QUERY_SVC_REC_BY_ID:
- OSM_LOG(p_log, OSM_LOG_DEBUG, "DBG:001 SVC_REC_BY_ID\n");
- sa_mad_data.attr_id = IB_MAD_ATTR_SERVICE_RECORD;
- sa_mad_data.comp_mask = IB_SR_COMPMASK_SID;
- sa_mad_data.attr_offset =
- ib_get_attr_offset(sizeof(ib_service_record_t));
- sa_mad_data.p_attr = &svc_rec;
- svc_rec.service_id =
- *(ib_net64_t *) (p_query_req->p_query_input);
- break;
-
- case OSMV_QUERY_CLASS_PORT_INFO:
- OSM_LOG(p_log, OSM_LOG_DEBUG, "DBG:001 CLASS_PORT_INFO\n");
- sa_mad_data.method = IB_MAD_METHOD_GET;
- sa_mad_data.attr_id = IB_MAD_ATTR_CLASS_PORT_INFO;
- sa_mad_data.attr_offset =
- ib_get_attr_offset(sizeof(ib_class_port_info_t));
- sa_mad_data.comp_mask = 0;
- sa_mad_data.p_attr = &class_port_info;
- break;
-
- case OSMV_QUERY_NODE_REC_BY_NODE_GUID:
- OSM_LOG(p_log, OSM_LOG_DEBUG, "DBG:001 NODE_REC_BY_NODE_GUID\n");
- sa_mad_data.attr_id = IB_MAD_ATTR_NODE_RECORD;
- sa_mad_data.attr_offset =
- ib_get_attr_offset(sizeof(ib_node_record_t));
- sa_mad_data.comp_mask = IB_NR_COMPMASK_NODEGUID;
- sa_mad_data.p_attr = &node_rec;
- node_rec.node_info.node_guid =
- *(ib_net64_t *) (p_query_req->p_query_input);
- break;
-
- case OSMV_QUERY_PORT_REC_BY_LID:
- OSM_LOG(p_log, OSM_LOG_DEBUG, "DBG:001 PORT_REC_BY_LID\n");
- sa_mad_data.attr_id = IB_MAD_ATTR_PORTINFO_RECORD;
- sa_mad_data.attr_offset =
- ib_get_attr_offset(sizeof(ib_portinfo_record_t));
- sa_mad_data.comp_mask = IB_PIR_COMPMASK_LID;
- sa_mad_data.p_attr = &port_info;
- port_info.lid = *(ib_net16_t *) (p_query_req->p_query_input);
- break;
-
- case OSMV_QUERY_PORT_REC_BY_LID_AND_NUM:
- sa_mad_data.method = IB_MAD_METHOD_GET;
- p_user_query = (osmv_user_query_t *) p_query_req->p_query_input;
- OSM_LOG(p_log, OSM_LOG_DEBUG, "DBG:001 PORT_REC_BY_LID_AND_NUM\n");
- sa_mad_data.attr_id = IB_MAD_ATTR_PORTINFO_RECORD;
- sa_mad_data.attr_offset =
- ib_get_attr_offset(sizeof(ib_portinfo_record_t));
- sa_mad_data.comp_mask =
- IB_PIR_COMPMASK_LID | IB_PIR_COMPMASK_PORTNUM;
- sa_mad_data.p_attr = p_user_query->p_attr;
- break;
-
- case OSMV_QUERY_VLARB_BY_LID_PORT_BLOCK:
- sa_mad_data.method = IB_MAD_METHOD_GET;
- p_user_query = (osmv_user_query_t *) p_query_req->p_query_input;
- OSM_LOG(p_log, OSM_LOG_DEBUG, "DBG:001 OSMV_QUERY_VLARB_BY_LID_PORT_BLOCK\n");
- sa_mad_data.attr_id = IB_MAD_ATTR_VLARB_RECORD;
- sa_mad_data.attr_offset =
- ib_get_attr_offset(sizeof(ib_vl_arb_table_record_t));
- sa_mad_data.comp_mask =
- IB_VLA_COMPMASK_LID | IB_VLA_COMPMASK_OUT_PORT |
- IB_VLA_COMPMASK_BLOCK;
- sa_mad_data.p_attr = p_user_query->p_attr;
- break;
-
- case OSMV_QUERY_SLVL_BY_LID_AND_PORTS:
- sa_mad_data.method = IB_MAD_METHOD_GET;
- p_user_query = (osmv_user_query_t *) p_query_req->p_query_input;
- OSM_LOG(p_log, OSM_LOG_DEBUG, "DBG:001 OSMV_QUERY_VLARB_BY_LID_PORT_BLOCK\n");
- sa_mad_data.attr_id = IB_MAD_ATTR_SLVL_RECORD;
- sa_mad_data.attr_offset =
- ib_get_attr_offset(sizeof(ib_slvl_table_record_t));
- sa_mad_data.comp_mask =
- IB_SLVL_COMPMASK_LID | IB_SLVL_COMPMASK_OUT_PORT |
- IB_SLVL_COMPMASK_IN_PORT;
- sa_mad_data.p_attr = p_user_query->p_attr;
- break;
-
- case OSMV_QUERY_PATH_REC_BY_PORT_GUIDS:
- OSM_LOG(p_log, OSM_LOG_DEBUG, "DBG:001 PATH_REC_BY_PORT_GUIDS\n");
- memset(&path_rec, 0, sizeof(ib_path_rec_t));
- sa_mad_data.attr_id = IB_MAD_ATTR_PATH_RECORD;
- sa_mad_data.attr_offset =
- ib_get_attr_offset(sizeof(ib_path_rec_t));
- sa_mad_data.comp_mask =
- (IB_PR_COMPMASK_DGID | IB_PR_COMPMASK_SGID);
- sa_mad_data.p_attr = &path_rec;
- ib_gid_set_default(&path_rec.dgid,
- ((osmv_guid_pair_t *) (p_query_req->
- p_query_input))->
- dest_guid);
- ib_gid_set_default(&path_rec.sgid,
- ((osmv_guid_pair_t *) (p_query_req->
- p_query_input))->
- src_guid);
- break;
-
- case OSMV_QUERY_PATH_REC_BY_GIDS:
- OSM_LOG(p_log, OSM_LOG_DEBUG, "DBG:001 PATH_REC_BY_GIDS\n");
- memset(&path_rec, 0, sizeof(ib_path_rec_t));
- sa_mad_data.attr_id = IB_MAD_ATTR_PATH_RECORD;
- sa_mad_data.attr_offset =
- ib_get_attr_offset(sizeof(ib_path_rec_t));
- sa_mad_data.comp_mask =
- (IB_PR_COMPMASK_DGID | IB_PR_COMPMASK_SGID);
- sa_mad_data.p_attr = &path_rec;
- memcpy(&path_rec.dgid,
- &((osmv_gid_pair_t *) (p_query_req->p_query_input))->
- dest_gid, sizeof(ib_gid_t));
- memcpy(&path_rec.sgid,
- &((osmv_gid_pair_t *) (p_query_req->p_query_input))->
- src_gid, sizeof(ib_gid_t));
- break;
-
- case OSMV_QUERY_PATH_REC_BY_LIDS:
- OSM_LOG(p_log, OSM_LOG_DEBUG, "DBG:001 PATH_REC_BY_LIDS\n");
- memset(&path_rec, 0, sizeof(ib_path_rec_t));
- sa_mad_data.method = IB_MAD_METHOD_GET;
- sa_mad_data.attr_id = IB_MAD_ATTR_PATH_RECORD;
- sa_mad_data.attr_offset =
- ib_get_attr_offset(sizeof(ib_path_rec_t));
- sa_mad_data.comp_mask =
- (IB_PR_COMPMASK_DLID | IB_PR_COMPMASK_SLID);
- sa_mad_data.p_attr = &path_rec;
- path_rec.dlid =
- ((osmv_lid_pair_t *) (p_query_req->p_query_input))->
- dest_lid;
- path_rec.slid =
- ((osmv_lid_pair_t *) (p_query_req->p_query_input))->src_lid;
- break;
-
- case OSMV_QUERY_UD_MULTICAST_SET:
- sa_mad_data.method = IB_MAD_METHOD_SET;
- p_user_query = (osmv_user_query_t *) p_query_req->p_query_input;
- OSM_LOG(p_log, OSM_LOG_DEBUG, "DBG:001 OSMV_QUERY_UD_MULTICAST_SET\n");
- sa_mad_data.attr_id = IB_MAD_ATTR_MCMEMBER_RECORD;
- sa_mad_data.attr_offset =
- ib_get_attr_offset(sizeof(ib_member_rec_t));
- sa_mad_data.comp_mask = p_user_query->comp_mask;
- sa_mad_data.p_attr = p_user_query->p_attr;
- break;
-
- case OSMV_QUERY_UD_MULTICAST_DELETE:
- sa_mad_data.method = IB_MAD_METHOD_DELETE;
- p_user_query = (osmv_user_query_t *) p_query_req->p_query_input;
- OSM_LOG(p_log, OSM_LOG_DEBUG, "DBG:001 OSMV_QUERY_UD_MULTICAST_DELETE\n");
- sa_mad_data.attr_id = IB_MAD_ATTR_MCMEMBER_RECORD;
- sa_mad_data.attr_offset =
- ib_get_attr_offset(sizeof(ib_member_rec_t));
- sa_mad_data.comp_mask = p_user_query->comp_mask;
- sa_mad_data.p_attr = p_user_query->p_attr;
- break;
-
-#ifdef DUAL_SIDED_RMPP
- case OSMV_QUERY_MULTIPATH_REC:
- OSM_LOG(p_log, OSM_LOG_DEBUG, "DBG:001 MULTIPATH_REC\n");
- /* Validate sgid/dgid counts against SA client limit */
- p_mpr_req = (osmv_multipath_req_t *) p_query_req->p_query_input;
- if (p_mpr_req->sgid_count + p_mpr_req->dgid_count >
- IB_MULTIPATH_MAX_GIDS) {
- OSM_LOG(p_log, OSM_LOG_ERROR, "DBG:001 MULTIPATH_REC "
- "SGID count %d DGID count %d max count %d\n",
- p_mpr_req->sgid_count, p_mpr_req->dgid_count,
- IB_MULTIPATH_MAX_GIDS);
- CL_ASSERT(0);
- return IB_ERROR;
- }
- memset(&multipath_rec, 0, sizeof(ib_multipath_rec_t));
- sa_mad_data.method = IB_MAD_METHOD_GETMULTI;
- sa_mad_data.attr_id = IB_MAD_ATTR_MULTIPATH_RECORD;
- sa_mad_data.attr_offset =
- ib_get_attr_offset(sizeof(ib_multipath_rec_t));
- sa_mad_data.p_attr = &multipath_rec;
- sa_mad_data.comp_mask = p_mpr_req->comp_mask;
- multipath_rec.num_path = p_mpr_req->num_path;
- if (p_mpr_req->reversible)
- multipath_rec.num_path |= 0x80;
- else
- multipath_rec.num_path &= ~0x80;
- multipath_rec.pkey = p_mpr_req->pkey;
- ib_multipath_rec_set_sl(&multipath_rec, p_mpr_req->sl);
- ib_multipath_rec_set_qos_class(&multipath_rec, 0);
- multipath_rec.independence = p_mpr_req->independence;
- multipath_rec.sgid_count = p_mpr_req->sgid_count;
- multipath_rec.dgid_count = p_mpr_req->dgid_count;
- j = 0;
- for (i = 0; i < p_mpr_req->sgid_count; i++, j++)
- multipath_rec.gids[j] = p_mpr_req->gids[j];
- for (i = 0; i < p_mpr_req->dgid_count; i++, j++)
- multipath_rec.gids[j] = p_mpr_req->gids[j];
- break;
-#endif
-
- default:
- OSM_LOG(p_log, OSM_LOG_ERROR, "DBG:001 UNKNOWN\n");
- CL_ASSERT(0);
- return IB_ERROR;
- }
-
- status = __osmv_send_sa_req(h_bind, &sa_mad_data, p_query_req);
-
- OSM_LOG_EXIT(p_log);
- return status;
-}
diff --git a/contrib/ofed/management/opensm/libvendor/osm_vendor_mlx.c b/contrib/ofed/management/opensm/libvendor/osm_vendor_mlx.c
deleted file mode 100644
index 683f56d..0000000
--- a/contrib/ofed/management/opensm/libvendor/osm_vendor_mlx.c
+++ /dev/null
@@ -1,770 +0,0 @@
-/*
- * Copyright (c) 2004-2006 Voltaire, Inc. All rights reserved.
- * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved.
- * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- */
-
-#if HAVE_CONFIG_H
-# include <config.h>
-#endif /* HAVE_CONFIG_H */
-
-#include <stdlib.h>
-#include <string.h>
-#include <vendor/osm_vendor_mlx.h>
-#include <vendor/osm_vendor_mlx_transport.h>
-#include <vendor/osm_vendor_mlx_svc.h>
-#include <vendor/osm_vendor_mlx_sender.h>
-#include <vendor/osm_vendor_mlx_hca.h>
-#include <vendor/osm_pkt_randomizer.h>
-
-/**
- * FORWARD REFERENCES
- */
-static ib_api_status_t
-__osmv_get_send_txn(IN osm_bind_handle_t h_bind,
- IN osm_madw_t * const p_madw,
- IN boolean_t is_rmpp,
- IN boolean_t resp_expected, OUT osmv_txn_ctx_t ** pp_txn);
-
-static void __osm_vendor_internal_unbind(osm_bind_handle_t h_bind);
-
-/*
- * NAME osm_vendor_new
- *
- * DESCRIPTION Create and Initialize the osm_vendor_t Object
- */
-
-osm_vendor_t *osm_vendor_new(IN osm_log_t * const p_log,
- IN const uint32_t timeout)
-{
- ib_api_status_t status;
- osm_vendor_t *p_vend;
-
- OSM_LOG_ENTER(p_log);
-
- CL_ASSERT(p_log);
-
- p_vend = malloc(sizeof(*p_vend));
- if (p_vend != NULL) {
- memset(p_vend, 0, sizeof(*p_vend));
-
- status = osm_vendor_init(p_vend, p_log, timeout);
- if (status != IB_SUCCESS) {
- osm_vendor_delete(&p_vend);
- }
- } else {
- osm_log(p_vend->p_log, OSM_LOG_ERROR,
- "osm_vendor_new: ERR 7301: "
- "Fail to allocate vendor object.\n");
- }
-
- OSM_LOG_EXIT(p_log);
- return (p_vend);
-}
-
-/*
- * NAME osm_vendor_delete
- *
- * DESCRIPTION Delete all the binds behind the vendor + free the vendor object
- */
-
-void osm_vendor_delete(IN osm_vendor_t ** const pp_vend)
-{
- cl_list_item_t *p_item;
- cl_list_obj_t *p_obj;
- osm_bind_handle_t bind_h;
- osm_log_t *p_log;
-
- OSM_LOG_ENTER((*pp_vend)->p_log);
- p_log = (*pp_vend)->p_log;
-
- /* go over the bind handles , unbind them and remove from list */
- p_item = cl_qlist_remove_head(&((*pp_vend)->bind_handles));
- while (p_item != cl_qlist_end(&((*pp_vend)->bind_handles))) {
-
- p_obj = PARENT_STRUCT(p_item, cl_list_obj_t, list_item);
- bind_h = (osm_bind_handle_t *) cl_qlist_obj(p_obj);
- osm_log(p_log, OSM_LOG_DEBUG,
- "osm_vendor_delete: unbinding bind_h:%p \n", bind_h);
-
- __osm_vendor_internal_unbind(bind_h);
-
- free(p_obj);
- /*removing from list */
- p_item = cl_qlist_remove_head(&((*pp_vend)->bind_handles));
- }
-
- if (NULL != ((*pp_vend)->p_transport_info)) {
- free((*pp_vend)->p_transport_info);
- (*pp_vend)->p_transport_info = NULL;
- }
-
- /* remove the packet randomizer object */
- if ((*pp_vend)->run_randomizer == TRUE)
- osm_pkt_randomizer_destroy(&((*pp_vend)->p_pkt_randomizer),
- p_log);
-
- free(*pp_vend);
- *pp_vend = NULL;
-
- OSM_LOG_EXIT(p_log);
-}
-
-/*
- * NAME osm_vendor_init
- *
- * DESCRIPTION Initialize the vendor object
- */
-
-ib_api_status_t
-osm_vendor_init(IN osm_vendor_t * const p_vend,
- IN osm_log_t * const p_log, IN const uint32_t timeout)
-{
- ib_api_status_t status = IB_SUCCESS;
-
- OSM_LOG_ENTER(p_log);
-
- p_vend->p_transport_info = NULL;
- p_vend->p_log = p_log;
- p_vend->resp_timeout = timeout;
- p_vend->ttime_timeout = timeout * OSMV_TXN_TIMEOUT_FACTOR;
-
- cl_qlist_init(&p_vend->bind_handles);
-
- /* update the run_randomizer flag */
- if (getenv("OSM_PKT_DROP_RATE") != NULL
- && atol(getenv("OSM_PKT_DROP_RATE")) != 0) {
- /* if the OSM_PKT_DROP_RATE global variable is defined to a non-zero value -
- then the randomizer should be called.
- Need to create the packet randomizer object */
- p_vend->run_randomizer = TRUE;
- status =
- osm_pkt_randomizer_init(&(p_vend->p_pkt_randomizer), p_log);
- if (status != IB_SUCCESS)
- return status;
- } else {
- p_vend->run_randomizer = FALSE;
- p_vend->p_pkt_randomizer = NULL;
- }
-
- OSM_LOG_EXIT(p_log);
- return (IB_SUCCESS);
-}
-
-/*
- * NAME osm_vendor_bind
- *
- * DESCRIPTION Create a new bind object under the vendor object
- */
-
-osm_bind_handle_t
-osm_vendor_bind(IN osm_vendor_t * const p_vend,
- IN osm_bind_info_t * const p_bind_info,
- IN osm_mad_pool_t * const p_mad_pool,
- IN osm_vend_mad_recv_callback_t mad_recv_callback,
- IN osm_vend_mad_send_err_callback_t send_err_callback,
- IN void *context)
-{
- osmv_bind_obj_t *p_bo;
- ib_api_status_t status;
- char hca_id[32];
- cl_status_t cl_st;
- cl_list_obj_t *p_obj;
- uint8_t hca_index;
-
- if (NULL == p_vend || NULL == p_bind_info || NULL == p_mad_pool
- || NULL == mad_recv_callback || NULL == send_err_callback) {
- osm_log(p_vend->p_log, OSM_LOG_ERROR,
- "osm_vendor_bind: ERR 7302: "
- "NULL parameter passed in: p_vend=%p p_bind_info=%p p_mad_pool=%p recv_cb=%p send_err_cb=%p\n",
- p_vend, p_bind_info, p_mad_pool, mad_recv_callback,
- send_err_callback);
-
- return OSM_BIND_INVALID_HANDLE;
- }
-
- p_bo = malloc(sizeof(osmv_bind_obj_t));
- if (NULL == p_bo) {
- osm_log(p_vend->p_log, OSM_LOG_ERROR,
- "osm_vendor_bind: ERR 7303: could not allocate the bind object\n");
- return OSM_BIND_INVALID_HANDLE;
- }
-
- memset(p_bo, 0, sizeof(osmv_bind_obj_t));
- p_bo->p_vendor = p_vend;
- p_bo->recv_cb = mad_recv_callback;
- p_bo->send_err_cb = send_err_callback;
- p_bo->cb_context = context;
- p_bo->p_osm_pool = p_mad_pool;
-
- /* obtain the hca name and port num from the guid */
- osm_log(p_bo->p_vendor->p_log, OSM_LOG_DEBUG,
- "osm_vendor_bind: "
- "Finding CA and Port that owns port guid 0x%" PRIx64 ".\n",
- cl_ntoh64(p_bind_info->port_guid));
-
- status = osm_vendor_get_guid_ca_and_port(p_bo->p_vendor,
- p_bind_info->port_guid,
- &(p_bo->hca_hndl),
- hca_id,
- &hca_index, &(p_bo->port_num));
- if (status != IB_SUCCESS) {
- osm_log(p_bo->p_vendor->p_log, OSM_LOG_ERROR,
- "osm_vendor_bind: ERR 7304: "
- "Fail to find port number of port guid:0x%016" PRIx64
- "\n", p_bind_info->port_guid);
- free(p_bo);
- return OSM_BIND_INVALID_HANDLE;
- }
-
- /* Initialize the magic_ptr to the pointer of the p_bo info.
- This will be used to signal when the object is being destroyed, so no
- real action will be done then. */
- p_bo->magic_ptr = p_bo;
-
- p_bo->is_closing = FALSE;
-
- cl_spinlock_construct(&(p_bo->lock));
- cl_st = cl_spinlock_init(&(p_bo->lock));
- if (cl_st != CL_SUCCESS) {
- osm_log(p_bo->p_vendor->p_log, OSM_LOG_ERROR,
- "osm_vendor_bind: ERR 7305: "
- "could not initialize the spinlock ...\n");
- free(p_bo);
- return OSM_BIND_INVALID_HANDLE;
- }
-
- osm_log(p_bo->p_vendor->p_log, OSM_LOG_DEBUG,
- "osm_vendor_bind: osmv_txnmgr_init ... \n");
- if (osmv_txnmgr_init(&p_bo->txn_mgr, p_vend->p_log, &(p_bo->lock)) !=
- IB_SUCCESS) {
- osm_log(p_bo->p_vendor->p_log, OSM_LOG_ERROR,
- "osm_vendor_bind: ERR 7306: "
- "osmv_txnmgr_init failed \n");
- cl_spinlock_destroy(&p_bo->lock);
- free(p_bo);
- return OSM_BIND_INVALID_HANDLE;
- }
-
- /* Do the real job! (Transport-dependent) */
- if (IB_SUCCESS !=
- osmv_transport_init(p_bind_info, hca_id, hca_index, p_bo)) {
- osm_log(p_bo->p_vendor->p_log, OSM_LOG_ERROR,
- "osm_vendor_bind: ERR 7307: "
- "osmv_transport_init failed \n");
- osmv_txnmgr_done((osm_bind_handle_t) p_bo);
- cl_spinlock_destroy(&p_bo->lock);
- free(p_bo);
- return OSM_BIND_INVALID_HANDLE;
- }
-
- /* insert bind handle into db */
- p_obj = malloc(sizeof(cl_list_obj_t));
- if (NULL == p_obj) {
-
- osm_log(p_bo->p_vendor->p_log, OSM_LOG_ERROR,
- "osm_vendor_bind: ERR 7308: "
- "osm_vendor_bind: could not allocate the list object\n");
-
- osmv_transport_done(p_bo->p_transp_mgr);
- osmv_txnmgr_done((osm_bind_handle_t) p_bo);
- cl_spinlock_destroy(&p_bo->lock);
- free(p_bo);
- return OSM_BIND_INVALID_HANDLE;
- }
- memset(p_obj, 0, sizeof(cl_list_obj_t));
- cl_qlist_set_obj(p_obj, p_bo);
-
- cl_qlist_insert_head(&p_vend->bind_handles, &p_obj->list_item);
-
- return (osm_bind_handle_t) p_bo;
-}
-
-/*
- * NAME osm_vendor_unbind
- *
- * DESCRIPTION Destroy the bind object and remove it from the vendor's list
- */
-
-void osm_vendor_unbind(IN osm_bind_handle_t h_bind)
-{
- osmv_bind_obj_t *p_bo = (osmv_bind_obj_t *) h_bind;
- osm_log_t *p_log = p_bo->p_vendor->p_log;
- cl_list_obj_t *p_obj = NULL;
- cl_list_item_t *p_item, *p_item_tmp;
- cl_qlist_t *const p_bh_list =
- (cl_qlist_t * const)&p_bo->p_vendor->bind_handles;
-
- OSM_LOG_ENTER(p_log);
-
- /* go over all the items in the list and remove the specific item */
- p_item = cl_qlist_head(p_bh_list);
- while (p_item != cl_qlist_end(p_bh_list)) {
- p_obj = PARENT_STRUCT(p_item, cl_list_obj_t, list_item);
- if (cl_qlist_obj(p_obj) == h_bind) {
- break;
- }
- p_item_tmp = cl_qlist_next(p_item);
- p_item = p_item_tmp;
- }
-
- CL_ASSERT(p_item != cl_qlist_end(p_bh_list));
-
- cl_qlist_remove_item(p_bh_list, p_item);
- if (p_obj)
- free(p_obj);
-
- if (h_bind != 0) {
- __osm_vendor_internal_unbind(h_bind);
- }
-
- OSM_LOG_EXIT(p_log);
-}
-
-/*
- * NAME osm_vendor_get
- *
- * DESCRIPTION Allocate the space for a new MAD
- */
-
-ib_mad_t *osm_vendor_get(IN osm_bind_handle_t h_bind,
- IN const uint32_t mad_size,
- IN osm_vend_wrap_t * const p_vw)
-{
- ib_mad_t *p_mad;
- osmv_bind_obj_t *p_bo = (osmv_bind_obj_t *) h_bind;
- osm_vendor_t const *p_vend = p_bo->p_vendor;
- uint32_t act_mad_size;
-
- OSM_LOG_ENTER(p_vend->p_log);
-
- CL_ASSERT(p_vw);
-
- if (mad_size < MAD_BLOCK_SIZE) {
- /* Stupid, but the applications want that! */
- act_mad_size = MAD_BLOCK_SIZE;
- } else {
- act_mad_size = mad_size;
- }
-
- /* allocate it */
- p_mad = (ib_mad_t *) malloc(act_mad_size);
- if (p_mad == NULL) {
- osm_log(p_vend->p_log, OSM_LOG_ERROR,
- "osm_vendor_get: ERR 7309: "
- "Error Obtaining MAD buffer.\n");
- goto Exit;
- }
-
- memset(p_mad, 0, act_mad_size);
-
- if (osm_log_get_level(p_vend->p_log) >= OSM_LOG_DEBUG) {
- osm_log(p_vend->p_log, OSM_LOG_DEBUG,
- "osm_vendor_get: "
- "Allocated MAD %p, size = %u.\n", p_mad, act_mad_size);
- }
- p_vw->p_mad = p_mad;
-
-Exit:
- OSM_LOG_EXIT(p_vend->p_log);
- return (p_mad);
-}
-
-/*
- * NAME osm_vendor_send
- *
- * DESCRIPTION Send a MAD buffer (RMPP or simple send).
- *
- * Semantics:
- * (1) The RMPP send completes when every segment
- * is acknowledged (synchronous)
- * (2) The simple send completes when the send completion
- * is received (asynchronous)
- */
-
-ib_api_status_t
-osm_vendor_send(IN osm_bind_handle_t h_bind,
- IN osm_madw_t * const p_madw, IN boolean_t const resp_expected)
-{
- ib_api_status_t ret = IB_SUCCESS;
- osmv_bind_obj_t *p_bo = (osmv_bind_obj_t *) h_bind;
- boolean_t is_rmpp = FALSE, is_rmpp_ds = FALSE;
- osmv_txn_ctx_t *p_txn = NULL;
- ib_mad_t *p_mad;
- osm_log_t *p_log = p_bo->p_vendor->p_log;
- osm_mad_pool_t *p_mad_pool = p_bo->p_osm_pool;
- OSM_LOG_ENTER(p_log);
-
- if (NULL == h_bind || NULL == p_madw ||
- NULL == (p_mad = osm_madw_get_mad_ptr(p_madw)) ||
- NULL == osm_madw_get_mad_addr_ptr(p_madw)) {
-
- return IB_INVALID_PARAMETER;
- }
-
- is_rmpp = (p_madw->mad_size > MAD_BLOCK_SIZE
- || osmv_mad_is_rmpp(p_mad));
- /* is this rmpp double sided? This means we expect a response that can be
- an rmpp or not */
- is_rmpp_ds = (TRUE == is_rmpp && TRUE == resp_expected);
-
- /* Make our operations with the send context atomic */
- osmv_txn_lock(p_bo);
-
- if (TRUE == p_bo->is_closing) {
-
- osm_log(p_log, OSM_LOG_ERROR,
- "osm_vendor_send: ERR 7310: "
- "The handle %p is being unbound, cannot send.\n",
- h_bind);
- ret = IB_INTERRUPTED;
- /* When closing p_bo could be detroyed or is going to , thus could not refer to it */
- goto send_done;
- }
-
- if (TRUE == resp_expected || TRUE == is_rmpp) {
-
- /* We must run under a transaction framework.
- * Get the transaction object (old or new) */
- ret = __osmv_get_send_txn(h_bind, p_madw, is_rmpp,
- resp_expected, &p_txn);
- if (IB_SUCCESS != ret) {
- goto send_done;
- }
- }
-
- if (TRUE == is_rmpp) {
- /* Do the job - RMPP!
- * The call returns as all the packets are ACK'ed/upon error
- * The txn lock will be released each time the function sleeps
- * and re-acquired when it wakes up
- */
- ret = osmv_rmpp_send_madw(h_bind, p_madw, p_txn, is_rmpp_ds);
- } else {
-
- /* Do the job - single MAD!
- * The call returns as soon as the MAD is put on the wire
- */
- ret = osmv_simple_send_madw(h_bind, p_madw, p_txn, FALSE);
- }
-
- if (IB_SUCCESS == ret) {
-
- if ((TRUE == is_rmpp) && (FALSE == is_rmpp_ds)) {
- /* For double-sided sends, the txn continues to live */
- osmv_txn_done(h_bind, osmv_txn_get_key(p_txn),
- FALSE /*not in callback */ );
- }
-
- if (FALSE == resp_expected) {
- osm_mad_pool_put(p_mad_pool, p_madw);
- }
- } else if (IB_INTERRUPTED != ret) {
- if (NULL != p_txn) {
- osmv_txn_done(h_bind, osmv_txn_get_key(p_txn),
- FALSE /*not in callback */ );
- }
-
- osm_log(p_log, OSM_LOG_ERROR,
- "osm_vendor_send: ERR 7311: failed to send MADW %p\n",
- p_madw);
-
- if (TRUE == resp_expected) {
- /* Change the status on the p_madw */
- p_madw->status = ret;
- /* Only the requester expects the error callback */
- p_bo->send_err_cb(p_bo->cb_context, p_madw);
- } else {
- /* put back the mad - it is useless ... */
- osm_mad_pool_put(p_mad_pool, p_madw);
- }
- } else { /* the transaction was aborted due to p_bo exit */
-
- osm_mad_pool_put(p_mad_pool, p_madw);
- goto aborted;
- }
-send_done:
-
- osmv_txn_unlock(p_bo);
-aborted:
- OSM_LOG_EXIT(p_log);
- return ret;
-}
-
-/*
- * NAME osm_vendor_put
- *
- * DESCRIPTION Free the MAD's memory
- */
-
-void
-osm_vendor_put(IN osm_bind_handle_t h_bind, IN osm_vend_wrap_t * const p_vw)
-{
-
- osmv_bind_obj_t *p_bo = (osmv_bind_obj_t *) h_bind;
- osm_vendor_t const *p_vend = p_bo->p_vendor;
-
- if (p_bo->is_closing != TRUE) {
- OSM_LOG_ENTER(p_vend->p_log);
-
- CL_ASSERT(p_vw);
- CL_ASSERT(p_vw->p_mad);
-
- if (osm_log_get_level(p_vend->p_log) >= OSM_LOG_DEBUG) {
- osm_log(p_vend->p_log, OSM_LOG_DEBUG,
- "osm_vendor_put: " "Retiring MAD %p.\n",
- p_vw->p_mad);
- }
-
- free(p_vw->p_mad);
- p_vw->p_mad = NULL;
-
- OSM_LOG_EXIT(p_vend->p_log);
- }
-}
-
-/*
- * NAME osm_vendor_local_lid_change
- *
- * DESCRIPTION Notifies the vendor transport layer that the local address
- * has changed. This allows the vendor layer to perform
- * housekeeping functions such as address vector updates.
- */
-
-ib_api_status_t osm_vendor_local_lid_change(IN osm_bind_handle_t h_bind)
-{
- osm_vendor_t const *p_vend = ((osmv_bind_obj_t *) h_bind)->p_vendor;
- OSM_LOG_ENTER(p_vend->p_log);
-
- osm_log(p_vend->p_log, OSM_LOG_DEBUG,
- "osm_vendor_local_lid_change: " "Change of LID.\n");
-
- OSM_LOG_EXIT(p_vend->p_log);
-
- return (IB_SUCCESS);
-
-}
-
-/*
- * NAME osm_vendor_set_sm
- *
- * DESCRIPTION Modifies the port info for the bound port to set the "IS_SM" bit
- * according to the value given (TRUE or FALSE).
- */
-#if !(defined(OSM_VENDOR_INTF_TS_NO_VAPI) || defined(OSM_VENDOR_INTF_SIM) || defined(OSM_VENDOR_INTF_TS))
-void osm_vendor_set_sm(IN osm_bind_handle_t h_bind, IN boolean_t is_sm_val)
-{
- osmv_bind_obj_t *p_bo = (osmv_bind_obj_t *) h_bind;
- osm_vendor_t const *p_vend = p_bo->p_vendor;
- VAPI_ret_t status;
- VAPI_hca_attr_t attr_mod;
- VAPI_hca_attr_mask_t attr_mask;
-
- OSM_LOG_ENTER(p_vend->p_log);
-
- memset(&attr_mod, 0, sizeof(attr_mod));
- memset(&attr_mask, 0, sizeof(attr_mask));
-
- attr_mod.is_sm = is_sm_val;
- attr_mask = HCA_ATTR_IS_SM;
-
- status =
- VAPI_modify_hca_attr(p_bo->hca_hndl, p_bo->port_num, &attr_mod,
- &attr_mask);
- if (status != VAPI_OK) {
- osm_log(p_vend->p_log, OSM_LOG_ERROR,
- "osm_vendor_set_sm: ERR 7312: "
- "Unable set 'IS_SM' bit to:%u in port attributes (%d).\n",
- is_sm_val, status);
- }
-
- OSM_LOG_EXIT(p_vend->p_log);
-}
-
-#endif
-
-/*
- * NAME __osm_vendor_internal_unbind
- *
- * DESCRIPTION Destroying a bind:
- * (1) Wait for the completion of the sends in flight
- * (2) Destroy the associated data structures
- */
-
-static void __osm_vendor_internal_unbind(osm_bind_handle_t h_bind)
-{
- osmv_bind_obj_t *p_bo = (osmv_bind_obj_t *) h_bind;
- osm_log_t *p_log = p_bo->p_vendor->p_log;
-
- OSM_LOG_ENTER(p_log);
-
- /* "notifying" all that from now on no new sends can be done */
- p_bo->txn_mgr.p_event_wheel->closing = TRUE;
-
- osmv_txn_lock(p_bo);
-
- /*
- the is_closing is set under lock we we know we only need to
- check for it after obtaining the lock
- */
- p_bo->is_closing = TRUE;
-
- /* notifying all sleeping rmpp sends to exit */
- osmv_txn_abort_rmpp_txns(h_bind);
-
- /* unlock the bo to allow for any residual mads to be dispatched */
- osmv_txn_unlock(p_bo);
- osm_log(p_log, OSM_LOG_DEBUG,
- "__osm_vendor_internal_unbind: destroying transport mgr.. \n");
- /* wait for the receiver thread to exit */
- osmv_transport_done(h_bind);
-
- /* lock to avoid any collissions while we cleanup the structs */
- osmv_txn_lock(p_bo);
- osm_log(p_log, OSM_LOG_DEBUG,
- "__osm_vendor_internal_unbind: destroying txn mgr.. \n");
- osmv_txnmgr_done(h_bind);
- osm_log(p_log, OSM_LOG_DEBUG,
- "__osm_vendor_internal_unbind: destroying bind lock.. \n");
- osmv_txn_unlock(p_bo);
-
- /*
- we intentionally let the p_bo and its lock leak -
- as we did not implement a way to track active bind handles provided to
- the client - and the client might use them
-
- cl_spinlock_destroy(&p_bo->lock);
- free(p_bo);
- */
-
- OSM_LOG_EXIT(p_log);
-}
-
-/*
- * NAME __osmv_get_send_txn
- *
- * DESCRIPTION Return a transaction object that corresponds to this MAD.
- * Optionally, create it, if the new request (query) is sent or received.
- */
-
-static ib_api_status_t
-__osmv_get_send_txn(IN osm_bind_handle_t h_bind,
- IN osm_madw_t * const p_madw,
- IN boolean_t is_rmpp,
- IN boolean_t resp_expected, OUT osmv_txn_ctx_t ** pp_txn)
-{
- ib_api_status_t ret;
- uint64_t tid, key;
- osmv_bind_obj_t *p_bo = (osmv_bind_obj_t *) h_bind;
- ib_mad_t *p_mad = osm_madw_get_mad_ptr(p_madw);
-
- OSM_LOG_ENTER(p_bo->p_vendor->p_log);
- CL_ASSERT(NULL != pp_txn);
-
- key = tid = cl_ntoh64(p_mad->trans_id);
- if (TRUE == resp_expected) {
- /* Create a unique identifier at the requester side */
- key = osmv_txn_uniq_key(tid);
- }
-
- /* We must run under a transaction framework */
- ret = osmv_txn_lookup(h_bind, key, pp_txn);
- if (IB_NOT_FOUND == ret) {
- /* Generally, we start a new transaction */
- ret = osmv_txn_init(h_bind, tid, key, pp_txn);
- if (IB_SUCCESS != ret) {
- osm_log(p_bo->p_vendor->p_log, OSM_LOG_ERROR,
- "__osmv_get_send_txn: ERR 7313: "
- "The transaction id=0x%llX failed to init.\n",
- tid);
- goto get_send_txn_done;
- }
- } else {
- CL_ASSERT(NULL != *pp_txn);
- /* The transaction context exists.
- * This is legal only if I am going to return an
- * (RMPP?) reply to an RMPP request sent by the other part
- * (double-sided RMPP transfer)
- */
- if (FALSE == is_rmpp
- || FALSE == osmv_txn_is_rmpp_init_by_peer(*pp_txn)) {
- osm_log(p_bo->p_vendor->p_log, OSM_LOG_ERROR,
- "__osmv_get_send_txn: ERR 7314: "
- "The transaction id=0x%llX is not unique. Send failed.\n",
- tid);
-
- ret = IB_INVALID_SETTING;
- goto get_send_txn_done;
- }
-
- if (TRUE == resp_expected) {
- osm_log(p_bo->p_vendor->p_log, OSM_LOG_ERROR,
- "__osmv_get_send_txn: ERR 7315: "
- "The transaction id=%llX can't expect a response. Send failed.\n",
- tid);
-
- ret = IB_INVALID_PARAMETER;
- goto get_send_txn_done;
- }
- }
-
- if (TRUE == is_rmpp) {
- ret = osmv_txn_init_rmpp_sender(h_bind, *pp_txn, p_madw);
- if (IB_SUCCESS != ret) {
- osm_log(p_bo->p_vendor->p_log, OSM_LOG_ERROR,
- "__osmv_get_send_txn: ERR 7316: "
- "The transaction id=%llX failed to init the rmpp mad. Send failed.\n",
- tid);
- osmv_txn_done(h_bind, tid, FALSE);
- goto get_send_txn_done;
- }
- }
-
- /* Save a reference to the MAD in the txn context
- * We'll need to match it in two cases:
- * (1) When the response is returned, if I am the requester
- * (2) In RMPP retransmissions
- */
- osmv_txn_set_madw(*pp_txn, p_madw);
-
-get_send_txn_done:
- OSM_LOG_EXIT(p_bo->p_vendor->p_log);
-
- return ret;
-}
-
-/**********************************************************************
- **********************************************************************/
-void osm_vendor_set_debug(IN osm_vendor_t * const p_vend, IN int32_t level)
-{
-
-}
diff --git a/contrib/ofed/management/opensm/libvendor/osm_vendor_mlx_anafa.c b/contrib/ofed/management/opensm/libvendor/osm_vendor_mlx_anafa.c
deleted file mode 100644
index bb04530..0000000
--- a/contrib/ofed/management/opensm/libvendor/osm_vendor_mlx_anafa.c
+++ /dev/null
@@ -1,753 +0,0 @@
-/*
- * Copyright (c) 2004-2006 Voltaire, Inc. All rights reserved.
- * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved.
- * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- */
-
-#if HAVE_CONFIG_H
-# include <config.h>
-#endif /* HAVE_CONFIG_H */
-
-#include <sys/ioctl.h>
-#include <stdlib.h>
-#include <stddef.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <errno.h>
-
-#include <vendor/osm_vendor_mlx.h>
-#include <vendor/osm_vendor_mlx_transport.h>
-#include <vendor/osm_vendor_mlx_transport_anafa.h>
-#include <vendor/osm_vendor_mlx_svc.h>
-#include <vendor/osm_vendor_mlx_sender.h>
-#include <vendor/osm_pkt_randomizer.h>
-#include <vendor/osm_ts_useraccess.h>
-
-/**
- * FORWARD REFERENCES
- */
-static ib_api_status_t
-__osmv_get_send_txn(IN osm_bind_handle_t h_bind,
- IN osm_madw_t * const p_madw,
- IN boolean_t is_rmpp,
- IN boolean_t resp_expected, OUT osmv_txn_ctx_t ** pp_txn);
-
-static void __osm_vendor_internal_unbind(osm_bind_handle_t h_bind);
-
-/*
- * NAME osm_vendor_new
- *
- * DESCRIPTION Create and Initialize the osm_vendor_t Object
- */
-
-osm_vendor_t *osm_vendor_new(IN osm_log_t * const p_log,
- IN const uint32_t timeout)
-{
- ib_api_status_t status;
- osm_vendor_t *p_vend;
-
- OSM_LOG_ENTER(p_log);
-
- CL_ASSERT(p_log);
-
- p_vend = malloc(sizeof(*p_vend));
- if (p_vend != NULL) {
- memset(p_vend, 0, sizeof(*p_vend));
- status = osm_vendor_init(p_vend, p_log, timeout);
- if (status != IB_SUCCESS) {
- osm_vendor_delete(&p_vend);
- }
- } else {
- osm_log(p_vend->p_log, OSM_LOG_ERROR,
- "osm_vendor_new: ERR 7401: "
- "Fail to allocate vendor object.\n");
- }
-
- OSM_LOG_EXIT(p_log);
- return (p_vend);
-}
-
-/*
- * NAME osm_vendor_delete
- *
- * DESCRIPTION Delete all the binds behind the vendor + free the vendor object
- */
-
-void osm_vendor_delete(IN osm_vendor_t ** const pp_vend)
-{
- cl_list_item_t *p_item;
- cl_list_obj_t *p_obj;
- osm_bind_handle_t bind_h;
- osm_log_t *p_log;
-
- OSM_LOG_ENTER((*pp_vend)->p_log);
- p_log = (*pp_vend)->p_log;
-
- /* go over the bind handles , unbind them and remove from list */
- /* Note that if we reached here due to problem in the init, then
- the bind_handles list is not initialized yet */
- if ((*pp_vend)->bind_handles.state == CL_INITIALIZED) {
- p_item = cl_qlist_remove_head(&((*pp_vend)->bind_handles));
- while (p_item != cl_qlist_end(&((*pp_vend)->bind_handles))) {
-
- p_obj = PARENT_STRUCT(p_item, cl_list_obj_t, list_item);
- bind_h = (osm_bind_handle_t *) cl_qlist_obj(p_obj);
- osm_log(p_log, OSM_LOG_DEBUG,
- "osm_vendor_delete: unbinding bind_h:%p \n",
- bind_h);
-
- __osm_vendor_internal_unbind(bind_h);
-
- free(p_obj);
- /* removing from list */
- p_item =
- cl_qlist_remove_head(&((*pp_vend)->bind_handles));
- }
- }
-
- if (NULL != ((*pp_vend)->p_transport_info)) {
- free((*pp_vend)->p_transport_info);
- (*pp_vend)->p_transport_info = NULL;
- }
-
- /* remove the packet randomizer object */
- if ((*pp_vend)->run_randomizer == TRUE)
- osm_pkt_randomizer_destroy(&((*pp_vend)->p_pkt_randomizer),
- p_log);
-
- free(*pp_vend);
- *pp_vend = NULL;
-
- OSM_LOG_EXIT(p_log);
-}
-
-/*
- * NAME osm_vendor_init
- *
- * DESCRIPTION Initialize the vendor object
- */
-
-ib_api_status_t
-osm_vendor_init(IN osm_vendor_t * const p_vend,
- IN osm_log_t * const p_log, IN const uint32_t timeout)
-{
- ib_api_status_t status = IB_SUCCESS;
- char device_file[16];
- int device_fd;
-
- OSM_LOG_ENTER(p_log);
-
- p_vend->p_log = p_log;
- p_vend->resp_timeout = timeout;
- p_vend->ttime_timeout = timeout * OSMV_TXN_TIMEOUT_FACTOR;
-
- p_vend->p_transport_info = (osmv_TOPSPIN_ANAFA_transport_info_t *)
- malloc(sizeof(osmv_TOPSPIN_ANAFA_transport_info_t));
- if (!p_vend->p_transport_info) {
- return IB_ERROR;
- }
-
- memset(p_vend->p_transport_info, 0,
- sizeof(osmv_TOPSPIN_ANAFA_transport_info_t));
-
- /* update the run_randomizer flag */
- if (getenv("OSM_PKT_DROP_RATE") != NULL
- && atol(getenv("OSM_PKT_DROP_RATE")) != 0) {
- /* if the OSM_PKT_DROP_RATE global variable is defined
- to a non-zero value -
- then the randomizer should be called.
- Need to create the packet randomizer object */
- p_vend->run_randomizer = TRUE;
- status =
- osm_pkt_randomizer_init(&(p_vend->p_pkt_randomizer), p_log);
- if (status != IB_SUCCESS)
- return status;
- } else {
- p_vend->run_randomizer = FALSE;
- p_vend->p_pkt_randomizer = NULL;
- }
-
- /* open TopSpin file device */
- sprintf(device_file, "/dev/ts_ua0");
- device_fd = open("/dev/ts_ua0", O_RDWR);
- if (device_fd < 0) {
- fprintf(stderr, "Fatal: Fail to open the file:%s(%d)\n",
- device_file, errno);
- return IB_ERROR;
- }
-
- ((osmv_TOPSPIN_ANAFA_transport_info_t *) p_vend->p_transport_info)->
- device_fd = device_fd;
-
- cl_qlist_init(&p_vend->bind_handles);
-
- OSM_LOG_EXIT(p_log);
- return (IB_SUCCESS);
-}
-
-/*
- * NAME osm_vendor_bind
- *
- * DESCRIPTION Create a new bind object under the vendor object
- */
-
-osm_bind_handle_t
-osm_vendor_bind(IN osm_vendor_t * const p_vend,
- IN osm_bind_info_t * const p_bind_info,
- IN osm_mad_pool_t * const p_mad_pool,
- IN osm_vend_mad_recv_callback_t mad_recv_callback,
- IN osm_vend_mad_send_err_callback_t send_err_callback,
- IN void *context)
-{
- osmv_bind_obj_t *p_bo;
- cl_status_t cl_st;
- cl_list_obj_t *p_obj;
- uint8_t hca_idx = 0;
-
- if (NULL == p_vend || NULL == p_bind_info || NULL == p_mad_pool
- || NULL == mad_recv_callback || NULL == send_err_callback) {
- osm_log(p_bo->p_vendor->p_log, OSM_LOG_ERROR,
- "osm_vendor_bind: ERR 7402: "
- "NULL parameter passed in: p_vend=%p p_bind_info=%p p_mad_pool=%p recv_cb=%p send_err_cb=%p\n",
- p_vend, p_bind_info, p_mad_pool, mad_recv_callback,
- send_err_callback);
-
- return OSM_BIND_INVALID_HANDLE;
- }
-
- p_bo = malloc(sizeof(osmv_bind_obj_t));
- if (NULL == p_bo) {
- osm_log(p_bo->p_vendor->p_log, OSM_LOG_ERROR,
- "osm_vendor_bind: ERR 7403: "
- "could not allocate the bind object\n");
- return OSM_BIND_INVALID_HANDLE;
- }
-
- memset(p_bo, 0, sizeof(osmv_bind_obj_t));
- p_bo->p_vendor = p_vend;
- p_bo->recv_cb = mad_recv_callback;
- p_bo->send_err_cb = send_err_callback;
- p_bo->cb_context = context;
- p_bo->p_osm_pool = p_mad_pool;
- p_bo->port_num = 1; /* anafa2 has one port */
- p_bo->hca_hndl = 0; /* only one ca on anafa system */
-
- /* obtain the hca name and port num from the guid */
- osm_log(p_bo->p_vendor->p_log, OSM_LOG_DEBUG,
- "osm_vendor_bind: "
- "Finding CA and Port that owns port guid 0x%" PRIx64 ".\n",
- cl_ntoh64(p_bind_info->port_guid));
-
- p_bo->is_closing = FALSE;
- cl_spinlock_construct(&(p_bo->lock));
- cl_st = cl_spinlock_init(&(p_bo->lock));
- if (cl_st != CL_SUCCESS) {
- osm_log(p_bo->p_vendor->p_log, OSM_LOG_ERROR,
- "osm_vendor_bind: ERR 7405: "
- "could not initialize the spinlock ...\n");
- free(p_bo);
- return OSM_BIND_INVALID_HANDLE;
- }
-
- osm_log(p_bo->p_vendor->p_log, OSM_LOG_DEBUG,
- "osm_vendor_bind: osmv_txnmgr_init ... \n");
- if (osmv_txnmgr_init(&p_bo->txn_mgr, p_vend->p_log, &(p_bo->lock)) !=
- IB_SUCCESS) {
- osm_log(p_bo->p_vendor->p_log, OSM_LOG_ERROR,
- "osm_vendor_bind: ERR 7406: "
- "osmv_txnmgr_init failed \n");
- cl_spinlock_destroy(&p_bo->lock);
- free(p_bo);
- return OSM_BIND_INVALID_HANDLE;
- }
-
- /* Do the real job! (Transport-dependent) */
- if (IB_SUCCESS !=
- osmv_transport_init(p_bind_info, OSMV_ANAFA_ID, hca_idx, p_bo)) {
- osm_log(p_bo->p_vendor->p_log, OSM_LOG_ERROR,
- "osm_vendor_bind: ERR 7407: "
- "osmv_transport_init failed \n");
- osmv_txnmgr_done((osm_bind_handle_t) p_bo);
- cl_spinlock_destroy(&p_bo->lock);
- free(p_bo);
- return OSM_BIND_INVALID_HANDLE;
- }
-
- /* insert bind handle into db */
- p_obj = malloc(sizeof(cl_list_obj_t));
- if (NULL == p_obj) {
-
- osm_log(p_bo->p_vendor->p_log, OSM_LOG_ERROR,
- "osm_vendor_bind: ERR 7408: "
- "osm_vendor_bind: could not allocate the list object\n");
-
- osmv_transport_done(p_bo->p_transp_mgr);
- osmv_txnmgr_done((osm_bind_handle_t) p_bo);
- cl_spinlock_destroy(&p_bo->lock);
- free(p_bo);
- return OSM_BIND_INVALID_HANDLE;
- }
- if (p_obj)
- memset(p_obj, 0, sizeof(cl_list_obj_t));
- cl_qlist_set_obj(p_obj, p_bo);
-
- cl_qlist_insert_head(&p_vend->bind_handles, &p_obj->list_item);
-
- return (osm_bind_handle_t) p_bo;
-}
-
-/*
- * NAME osm_vendor_unbind
- *
- * DESCRIPTION Destroy the bind object and remove it from the vendor's list
- */
-
-void osm_vendor_unbind(IN osm_bind_handle_t h_bind)
-{
- osmv_bind_obj_t *p_bo = (osmv_bind_obj_t *) h_bind;
- osm_log_t *p_log = p_bo->p_vendor->p_log;
- cl_list_obj_t *p_obj;
- cl_list_item_t *p_item, *p_item_tmp;
- cl_qlist_t *const p_bh_list =
- (cl_qlist_t * const)&p_bo->p_vendor->bind_handles;
-
- OSM_LOG_ENTER(p_log);
-
- /* go over all the items in the list and remove the specific item */
- p_item = cl_qlist_head(&p_bo->p_vendor->bind_handles);
- while (p_item != cl_qlist_end(&p_bo->p_vendor->bind_handles)) {
- p_obj = PARENT_STRUCT(p_item, cl_list_obj_t, list_item);
- if (cl_qlist_obj(p_obj) == h_bind) {
- break;
- }
- p_item_tmp = cl_qlist_next(p_item);
- p_item = p_item_tmp;
- }
-
- CL_ASSERT(p_item != cl_qlist_end(p_bh_list));
-
- cl_qlist_remove_item(p_bh_list, p_item);
- free(p_obj);
-
- __osm_vendor_internal_unbind(h_bind);
-
- OSM_LOG_EXIT(p_bo->p_vendor->p_log);
-}
-
-/*
- * NAME osm_vendor_get
- *
- * DESCRIPTION Allocate the space for a new MAD
- */
-
-ib_mad_t *osm_vendor_get(IN osm_bind_handle_t h_bind,
- IN const uint32_t mad_size,
- IN osm_vend_wrap_t * const p_vw)
-{
- ib_mad_t *p_mad;
- osmv_bind_obj_t *p_bo = (osmv_bind_obj_t *) h_bind;
- osm_vendor_t const *p_vend = p_bo->p_vendor;
- uint32_t act_mad_size;
-
- OSM_LOG_ENTER(p_vend->p_log);
-
- CL_ASSERT(p_vw);
-
- if (mad_size < MAD_BLOCK_SIZE) {
- /* Stupid, but the applications want that! */
- act_mad_size = MAD_BLOCK_SIZE;
- } else {
- act_mad_size = mad_size;
- }
-
- /* allocate it */
- p_mad = (ib_mad_t *) malloc(act_mad_size);
- if (p_mad == NULL) {
- osm_log(p_vend->p_log, OSM_LOG_ERROR,
- "osm_vendor_get: ERR 7409: "
- "Error Obtaining MAD buffer.\n");
- goto Exit;
- }
-
- memset(p_mad, 0, act_mad_size);
-
- if (osm_log_get_level(p_vend->p_log) >= OSM_LOG_DEBUG) {
- osm_log(p_vend->p_log, OSM_LOG_DEBUG,
- "osm_vendor_get: "
- "Allocated MAD %p, size = %u.\n", p_mad, act_mad_size);
- }
- p_vw->p_mad = p_mad;
-
-Exit:
- OSM_LOG_EXIT(p_vend->p_log);
- return (p_mad);
-}
-
-/*
- * NAME osm_vendor_send
- *
- * DESCRIPTION Send a MAD buffer (RMPP or simple send).
- *
- * Semantics:
- * (1) The RMPP send completes when every segment
- * is acknowledged (synchronous)
- * (2) The simple send completes when the send completion
- * is received (asynchronous)
- */
-
-ib_api_status_t
-osm_vendor_send(IN osm_bind_handle_t h_bind,
- IN osm_madw_t * const p_madw, IN boolean_t const resp_expected)
-{
- ib_api_status_t ret = IB_SUCCESS;
- osmv_bind_obj_t *p_bo = (osmv_bind_obj_t *) h_bind;
- boolean_t is_rmpp = FALSE, is_rmpp_ds = FALSE;
- osmv_txn_ctx_t *p_txn = NULL;
- ib_mad_t *p_mad;
-
- OSM_LOG_ENTER(p_bo->p_vendor->p_log);
-
- if (NULL == h_bind || NULL == p_madw ||
- NULL == (p_mad = osm_madw_get_mad_ptr(p_madw)) ||
- NULL == osm_madw_get_mad_addr_ptr(p_madw)) {
-
- return IB_INVALID_PARAMETER;
- }
-
- is_rmpp = (p_madw->mad_size > MAD_BLOCK_SIZE
- || osmv_mad_is_rmpp(p_mad));
- is_rmpp_ds = (TRUE == is_rmpp && TRUE == resp_expected);
-
- /* Make our operations with the send context atomic */
- osmv_txn_lock(p_bo);
-
- if (TRUE == p_bo->is_closing) {
- osm_log(p_bo->p_vendor->p_log, OSM_LOG_ERROR,
- "osm_vendor_send: ERR 7410: "
- "The handle %p is being unbound, cannot send.\n",
- h_bind);
- ret = IB_INTERRUPTED;
- goto send_done;
- }
-
- if (TRUE == resp_expected || TRUE == is_rmpp) {
-
- /* We must run under a transaction framework.
- * Get the transaction object (old or new) */
- ret = __osmv_get_send_txn(h_bind, p_madw, is_rmpp,
- resp_expected, &p_txn);
- if (IB_SUCCESS != ret) {
- goto send_done;
- }
- }
-
- if (TRUE == is_rmpp) {
- /* Do the job - RMPP!
- * The call returns as all the packets are ACK'ed/upon error
- * The txn lock will be released each time the function sleeps
- * and re-acquired when it wakes up
- */
- ret = osmv_rmpp_send_madw(h_bind, p_madw, p_txn, is_rmpp_ds);
- } else {
-
- /* Do the job - single MAD!
- * The call returns as soon as the MAD is put on the wire
- */
- ret = osmv_simple_send_madw(h_bind, p_madw, p_txn, FALSE); /* anafa2 */
- }
-
- if (IB_SUCCESS == ret) {
-
- if ((TRUE == is_rmpp) && (FALSE == is_rmpp_ds)) {
- /* For double-sided sends, the txn continues to live */
- osmv_txn_done(h_bind, osmv_txn_get_key(p_txn),
- FALSE /*not in callback */ );
- }
-
- if (FALSE == resp_expected) {
- osm_mad_pool_put(p_bo->p_osm_pool, p_madw);
- }
- } else {
- if (NULL != p_txn) {
- osmv_txn_done(h_bind, osmv_txn_get_key(p_txn),
- FALSE /*not in callback */ );
- }
-
- osm_log(p_bo->p_vendor->p_log, OSM_LOG_ERROR,
- "osm_vendor_send: ERR 7411: failed to send MADW %p\n",
- p_madw);
-
- if (TRUE == resp_expected) {
- /* Change the status on the p_madw */
- p_madw->status = ret;
- /* Only the requester expects the error callback */
- p_bo->send_err_cb(p_bo->cb_context, p_madw);
- } else {
- /* put back the mad - it is useless ... */
- osm_mad_pool_put(p_bo->p_osm_pool, p_madw);
- }
- }
-
-send_done:
-
- osmv_txn_unlock(p_bo);
-
- OSM_LOG_EXIT(p_bo->p_vendor->p_log);
- return ret;
-}
-
-/*
- * NAME osm_vendor_put
- *
- * DESCRIPTION Free the MAD's memory
- */
-
-void
-osm_vendor_put(IN osm_bind_handle_t h_bind, IN osm_vend_wrap_t * const p_vw)
-{
-
- osmv_bind_obj_t *p_bo = (osmv_bind_obj_t *) h_bind;
- osm_vendor_t const *p_vend = p_bo->p_vendor;
-
- OSM_LOG_ENTER(p_vend->p_log);
-
- CL_ASSERT(p_vw);
- CL_ASSERT(p_vw->p_mad);
-
- if (osm_log_get_level(p_vend->p_log) >= OSM_LOG_DEBUG) {
- osm_log(p_vend->p_log, OSM_LOG_DEBUG,
- "osm_vendor_put: " "Retiring MAD %p.\n", p_vw->p_mad);
- }
-
- free(p_vw->p_mad);
- p_vw->p_mad = NULL;
-
- OSM_LOG_EXIT(p_vend->p_log);
-}
-
-/*
- * NAME osm_vendor_local_lid_change
- *
- * DESCRIPTION Notifies the vendor transport layer that the local address
- * has changed. This allows the vendor layer to perform
- * housekeeping functions such as address vector updates.
- */
-
-ib_api_status_t osm_vendor_local_lid_change(IN osm_bind_handle_t h_bind)
-{
- osm_vendor_t const *p_vend = ((osmv_bind_obj_t *) h_bind)->p_vendor;
- OSM_LOG_ENTER(p_vend->p_log);
-
- osm_log(p_vend->p_log, OSM_LOG_DEBUG,
- "osm_vendor_local_lid_change: " "Change of LID.\n");
-
- OSM_LOG_EXIT(p_vend->p_log);
-
- return (IB_SUCCESS);
-
-}
-
-/*
- * NAME osm_vendor_set_sm
- *
- * DESCRIPTION Modifies the port info for the bound port to set the "IS_SM" bit.
- */
-
-void osm_vendor_set_sm(IN osm_bind_handle_t h_bind, IN boolean_t is_sm_val)
-{
- osmv_bind_obj_t *p_bo = (osmv_bind_obj_t *) h_bind;
- osm_vendor_t const *p_vend = p_bo->p_vendor;
- osmv_TOPSPIN_ANAFA_transport_mgr_t *p_mgr;
- int ioctl_ret;
- osm_ts_set_port_info_ioctl port_info;
-
- OSM_LOG_ENTER(p_vend->p_log);
-
- port_info.port = 0; /* anafa has only 1 port */
- port_info.port_info.valid_fields = IB_PORT_IS_SM;
- port_info.port_info.is_sm = is_sm_val;
-
- p_mgr = (osmv_TOPSPIN_ANAFA_transport_mgr_t *) p_bo->p_transp_mgr;
- ioctl_ret = ioctl(p_mgr->device_fd, TS_IB_IOCSPORTINFO, &port_info);
-
- if (ioctl_ret < 0) {
- osm_log(p_vend->p_log, OSM_LOG_ERROR,
- "osm_vendor_set_sm: ERR 7412: "
- "Unable set 'IS_SM' bit to:%u in port attributes (%d). errno=%d\n",
- is_sm_val, ioctl_ret, errno);
- }
-
- OSM_LOG_EXIT(p_vend->p_log);
-}
-
-/*
- * NAME __osm_vendor_internal_unbind
- *
- * DESCRIPTION Destroying a bind:
- * (1) Wait for the completion of the sends in flight
- * (2) Destroy the associated data structures
- */
-
-static void __osm_vendor_internal_unbind(osm_bind_handle_t h_bind)
-{
- osmv_bind_obj_t *p_bo = (osmv_bind_obj_t *) h_bind;
- osm_log_t *p_log = p_bo->p_vendor->p_log;
-
- OSM_LOG_ENTER(p_log);
-
- /* "notifying" all that from now on no new sends can be done */
- p_bo->txn_mgr.p_event_wheel->closing = TRUE;
-
- osmv_txn_lock(p_bo);
- p_bo->is_closing = TRUE;
-
- /* notifying all sleeping rmpp sends to exit */
- osmv_txn_abort_rmpp_txns(h_bind);
-
- /* frees all data in bind handle */
- osm_log(p_log, OSM_LOG_DEBUG,
- "__osm_vendor_internal_unbind: destroying transport mgr.. \n");
- osmv_txn_unlock(p_bo);
-
- osmv_transport_done(h_bind);
- osm_log(p_log, OSM_LOG_DEBUG,
- "__osm_vendor_internal_unbind: destroying txn mgr.. \n");
- osmv_txn_lock(p_bo);
- osmv_txnmgr_done(h_bind);
- osm_log(p_log, OSM_LOG_DEBUG,
- "__osm_vendor_internal_unbind: destroying bind lock.. \n");
-
- osmv_txn_unlock(p_bo);
- /*
- we intentionally let the p_bo and its lock leak -
- as we did not implement a way to track active bind handles provided to
- the client - and the client might use them
-
- cl_spinlock_destroy(&p_bo->lock);
- free(p_bo);
- */
-
- OSM_LOG_EXIT(p_log);
-}
-
-/*
- * NAME __osmv_get_send_txn
- *
- * DESCRIPTION Return a transaction object that corresponds to this MAD.
- * Optionally, create it, if the new request (query) is sent or received.
- */
-
-static ib_api_status_t
-__osmv_get_send_txn(IN osm_bind_handle_t h_bind,
- IN osm_madw_t * const p_madw,
- IN boolean_t is_rmpp,
- IN boolean_t resp_expected, OUT osmv_txn_ctx_t ** pp_txn)
-{
- ib_api_status_t ret;
- uint64_t tid, key;
- osmv_bind_obj_t *p_bo = (osmv_bind_obj_t *) h_bind;
- ib_mad_t *p_mad = osm_madw_get_mad_ptr(p_madw);
-
- OSM_LOG_ENTER(p_bo->p_vendor->p_log);
- CL_ASSERT(NULL != pp_txn);
-
- key = tid = cl_ntoh64(p_mad->trans_id);
- if (TRUE == resp_expected) {
- /* Create a unique identifier at the requester side */
- key = osmv_txn_uniq_key(tid);
- }
-
- /* We must run under a transaction framework */
- ret = osmv_txn_lookup(h_bind, key, pp_txn);
- if (IB_NOT_FOUND == ret) {
- /* Generally, we start a new transaction */
- ret = osmv_txn_init(h_bind, tid, key, pp_txn);
- if (IB_SUCCESS != ret) {
- goto get_send_txn_done;
- }
- } else {
- CL_ASSERT(NULL != *pp_txn);
- /* The transaction context exists.
- * This is legal only if I am going to return an
- * (RMPP?) reply to an RMPP request sent by the other part
- * (double-sided RMPP transfer)
- */
- if (FALSE == is_rmpp
- || FALSE == osmv_txn_is_rmpp_init_by_peer(*pp_txn)) {
- osm_log(p_bo->p_vendor->p_log, OSM_LOG_ERROR,
- "__osmv_get_send_txn: ERR 7413: "
- "The transaction id=0x%llX is not unique. Send failed.\n",
- tid);
-
- ret = IB_INVALID_SETTING;
- goto get_send_txn_done;
- }
-
- if (TRUE == resp_expected) {
- osm_log(p_bo->p_vendor->p_log, OSM_LOG_ERROR,
- "__osmv_get_send_txn: ERR 7414: "
- "The transaction id=%llX can\'t expect a response. Send failed.\n",
- tid);
-
- ret = IB_INVALID_PARAMETER;
- goto get_send_txn_done;
- }
- }
-
- if (TRUE == is_rmpp) {
- ret = osmv_txn_init_rmpp_sender(h_bind, *pp_txn, p_madw);
- if (IB_SUCCESS != ret) {
- osmv_txn_done(h_bind, tid, FALSE);
- goto get_send_txn_done;
- }
- }
-
- /* Save a reference to the MAD in the txn context
- * We'll need to match it in two cases:
- * (1) When the response is returned, if I am the requester
- * (2) In RMPP retransmissions
- */
- osmv_txn_set_madw(*pp_txn, p_madw);
-
-get_send_txn_done:
- OSM_LOG_EXIT(p_bo->p_vendor->p_log);
-
- return ret;
-}
-
-/**********************************************************************
- **********************************************************************/
-void osm_vendor_set_debug(IN osm_vendor_t * const p_vend, IN int32_t level)
-{
-
-}
diff --git a/contrib/ofed/management/opensm/libvendor/osm_vendor_mlx_dispatcher.c b/contrib/ofed/management/opensm/libvendor/osm_vendor_mlx_dispatcher.c
deleted file mode 100644
index d476382..0000000
--- a/contrib/ofed/management/opensm/libvendor/osm_vendor_mlx_dispatcher.c
+++ /dev/null
@@ -1,710 +0,0 @@
-/*
- * Copyright (c) 2004-2006 Voltaire, Inc. All rights reserved.
- * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved.
- * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- */
-
-#if HAVE_CONFIG_H
-# include <config.h>
-#endif /* HAVE_CONFIG_H */
-
-#include <string.h>
-#include <vendor/osm_vendor_mlx.h>
-#include <vendor/osm_vendor_mlx_defs.h>
-#include <vendor/osm_vendor_mlx_svc.h>
-#include <vendor/osm_vendor_mlx_transport.h>
-#include <vendor/osm_vendor_mlx_sender.h>
-#include <vendor/osm_pkt_randomizer.h>
-
-typedef enum _osmv_disp_route {
-
- OSMV_ROUTE_DROP,
- OSMV_ROUTE_SIMPLE,
- OSMV_ROUTE_RMPP,
-
-} osmv_disp_route_t;
-
-/**
- * FORWARD REFERENCES TO PRIVATE FUNCTIONS
- */
-
-static osmv_disp_route_t
-__osmv_dispatch_route(IN osm_bind_handle_t h_bind,
- IN const ib_mad_t * p_mad, OUT osmv_txn_ctx_t ** pp_txn);
-
-static void
-__osmv_dispatch_simple_mad(IN osm_bind_handle_t h_bind,
- IN const ib_mad_t * p_mad,
- IN osmv_txn_ctx_t * p_txn,
- IN const osm_mad_addr_t * p_mad_addr);
-
-static void
-__osmv_dispatch_rmpp_mad(IN osm_bind_handle_t h_bind,
- IN const ib_mad_t * p_mad,
- IN osmv_txn_ctx_t * p_txn,
- IN const osm_mad_addr_t * p_mad_addr);
-
-static void
-__osmv_dispatch_rmpp_snd(IN osm_bind_handle_t h_bind,
- IN const ib_mad_t * p_mad,
- IN osmv_txn_ctx_t * p_txn,
- IN const osm_mad_addr_t * p_mad_addr);
-
-static ib_api_status_t
-__osmv_dispatch_rmpp_rcv(IN osm_bind_handle_t h_bind,
- IN const ib_mad_t * p_mad,
- IN osmv_txn_ctx_t * p_txn,
- IN const osm_mad_addr_t * p_mad_addr);
-
-static ib_api_status_t
-__osmv_dispatch_accept_seg(IN osm_bind_handle_t h_bind,
- IN osmv_txn_ctx_t * p_txn,
- IN const ib_mad_t * p_mad);
-static void
-__osmv_dispatch_send_ack(IN osm_bind_handle_t h_bind,
- IN const ib_mad_t * p_req_mad,
- IN osmv_txn_ctx_t * p_txn,
- IN const osm_mad_addr_t * p_mad_addr);
-
-/*
- * NAME
- * osmv_dispatch_mad
- *
- * DESCRIPTION
- * Lower-level MAD dispatcher.
- * Implements a switch between the following MAD consumers:
- * (1) Non-RMPP consumer (DATA)
- * (2) RMPP receiver (DATA/ABORT/STOP)
- * (3) RMPP sender (ACK/ABORT/STOP)
- *
- * PARAMETERS
- * h_bind The bind handle
- * p_mad_buf The 256 byte buffer of individual MAD
- * p_mad_addr The MAD originator's address
- */
-
-ib_api_status_t
-osmv_dispatch_mad(IN osm_bind_handle_t h_bind,
- IN const void *p_mad_buf,
- IN const osm_mad_addr_t * p_mad_addr)
-{
- ib_api_status_t ret = IB_SUCCESS;
- const ib_mad_t *p_mad = (ib_mad_t *) p_mad_buf;
- osmv_bind_obj_t *p_bo = (osmv_bind_obj_t *) h_bind;
- osmv_txn_ctx_t *p_txn = NULL;
- osm_log_t *p_log = p_bo->p_vendor->p_log;
-
- OSM_LOG_ENTER(p_bo->p_vendor->p_log);
-
- CL_ASSERT(NULL != h_bind && NULL != p_mad && NULL != p_mad_addr);
-
- osmv_txn_lock(p_bo);
-
- if (TRUE == p_bo->is_closing) {
-
- osm_log(p_bo->p_vendor->p_log, OSM_LOG_DEBUG,
- "The bind handle %p is being closed. "
- "The MAD will not be dispatched.\n", p_bo);
-
- ret = IB_INTERRUPTED;
- goto dispatch_mad_done;
- }
-
- /*
- Add call for packet drop randomizer.
- This is a testing feature. If run_randomizer flag is set to TRUE,
- the randomizer will be called, and randomally will drop
- a packet. This is used for simulating unstable fabric.
- */
- if (p_bo->p_vendor->run_randomizer == TRUE) {
- /* Try the randomizer */
- if (osm_pkt_randomizer_mad_drop(p_bo->p_vendor->p_log,
- p_bo->p_vendor->
- p_pkt_randomizer,
- p_mad) == TRUE) {
- osm_log(p_bo->p_vendor->p_log, OSM_LOG_DEBUG,
- "The MAD will not be dispatched.\n");
- goto dispatch_mad_done;
- }
- }
-
- switch (__osmv_dispatch_route(h_bind, p_mad, &p_txn)) {
-
- case OSMV_ROUTE_DROP:
- break; /* Do nothing */
-
- case OSMV_ROUTE_SIMPLE:
- __osmv_dispatch_simple_mad(h_bind, p_mad, p_txn, p_mad_addr);
- break;
-
- case OSMV_ROUTE_RMPP:
- __osmv_dispatch_rmpp_mad(h_bind, p_mad, p_txn, p_mad_addr);
- break;
-
- default:
- CL_ASSERT(FALSE);
- }
-
-dispatch_mad_done:
- osmv_txn_unlock(p_bo);
-
- OSM_LOG_EXIT(p_log);
- return ret;
-}
-
-/*
- * NAME __osmv_dispatch_route()
- *
- * DESCRIPTION Decide which way to handle the received MAD: simple txn/RMPP/drop
- */
-
-static osmv_disp_route_t
-__osmv_dispatch_route(IN osm_bind_handle_t h_bind,
- IN const ib_mad_t * p_mad, OUT osmv_txn_ctx_t ** pp_txn)
-{
- ib_api_status_t ret;
- osmv_bind_obj_t *p_bo = (osmv_bind_obj_t *) h_bind;
- boolean_t is_resp = osmv_mad_is_response(p_mad);
- boolean_t is_txn;
- uint64_t key = cl_ntoh64(p_mad->trans_id);
-
- CL_ASSERT(NULL != pp_txn);
-
- ret = osmv_txn_lookup(h_bind, key, pp_txn);
- is_txn = (IB_SUCCESS == ret);
-
- if (FALSE == is_txn && TRUE == is_resp) {
- osm_log(p_bo->p_vendor->p_log, OSM_LOG_DEBUG,
- "Received a response to a non-started/aged-out transaction (tid=0x%llX). "
- "Dropping the MAD.\n", key);
- return OSMV_ROUTE_DROP;
- }
-
- if (TRUE == osmv_mad_is_rmpp(p_mad)) {
- /* An RMPP transaction. The filtering is more delicate there */
- return OSMV_ROUTE_RMPP;
- }
-
- if (TRUE == is_txn && FALSE == is_resp) {
- /* Does this MAD try to start a transaction with duplicate tid? */
- osm_log(p_bo->p_vendor->p_log, OSM_LOG_DEBUG,
- "Duplicate TID 0x%llX received (not a response). "
- "Dropping the MAD.\n", key);
-
- return OSMV_ROUTE_DROP;
- }
-
- return OSMV_ROUTE_SIMPLE;
-}
-
-/*
- * NAME __osmv_dispatch_simple_mad()
- *
- * DESCRIPTION Handle a MAD that is part of non-RMPP transfer
- */
-
-static void
-__osmv_dispatch_simple_mad(IN osm_bind_handle_t h_bind,
- IN const ib_mad_t * p_mad,
- IN osmv_txn_ctx_t * p_txn,
- IN const osm_mad_addr_t * p_mad_addr)
-{
- osm_madw_t *p_madw;
- ib_mad_t *p_mad_buf;
- osm_madw_t *p_req_madw = NULL;
- osmv_bind_obj_t *p_bo = (osmv_bind_obj_t *) h_bind;
-
- OSM_LOG_ENTER(p_bo->p_vendor->p_log);
-
- /* Build the MAD wrapper to be returned to the user.
- * The actual storage for the MAD is allocated there.
- */
- p_madw =
- osm_mad_pool_get(p_bo->p_osm_pool, h_bind, MAD_BLOCK_SIZE,
- p_mad_addr);
-
- if (NULL == p_madw) {
- osm_log(p_bo->p_vendor->p_log, OSM_LOG_ERROR,
- "__osmv_dispatch_simple_mad: ERR 6501: "
- "Out Of Memory - could not allocate a buffer of size %d\n",
- MAD_BLOCK_SIZE);
-
- goto dispatch_simple_mad_done;
- }
-
- p_mad_buf = osm_madw_get_mad_ptr(p_madw);
- /* Copy the payload to the MAD buffer */
- memcpy((void *)p_mad_buf, (void *)p_mad, MAD_BLOCK_SIZE);
-
- if (NULL != p_txn) {
- /* This is a RESPONSE MAD. Pair it with the REQUEST MAD, pass upstream */
- p_req_madw = p_txn->p_madw;
- CL_ASSERT(NULL != p_req_madw);
-
- p_mad_buf->trans_id = cl_hton64(osmv_txn_get_tid(p_txn));
- osm_log(p_bo->p_vendor->p_log, OSM_LOG_DEBUG,
- "Restoring the original TID to 0x%llX\n",
- cl_ntoh64(p_mad_buf->trans_id));
-
- /* Reply matched, transaction complete */
- osmv_txn_done(h_bind, osmv_txn_get_key(p_txn), FALSE);
- } else {
- /* This is a REQUEST MAD. Don't create a context, pass upstream */
- }
-
- /* Do the job ! */
- p_bo->recv_cb(p_madw, p_bo->cb_context, p_req_madw);
-
-dispatch_simple_mad_done:
- OSM_LOG_EXIT(p_bo->p_vendor->p_log);
-}
-
-/*
- * NAME __osmv_dispatch_rmpp_mad()
- *
- * DESCRIPTION Handle a MAD that is part of RMPP transfer
- */
-
-static void
-__osmv_dispatch_rmpp_mad(IN osm_bind_handle_t h_bind,
- IN const ib_mad_t * p_mad,
- IN osmv_txn_ctx_t * p_txn,
- IN const osm_mad_addr_t * p_mad_addr)
-{
- ib_api_status_t status = IB_SUCCESS;
- uint64_t key = cl_ntoh64(p_mad->trans_id);
- boolean_t is_init_by_peer = FALSE;
- osmv_bind_obj_t *p_bo = (osmv_bind_obj_t *) h_bind;
- osm_madw_t *p_madw;
-
- OSM_LOG_ENTER(p_bo->p_vendor->p_log);
-
- if (NULL == p_txn) {
- if (FALSE == osmv_rmpp_is_data(p_mad)
- || FALSE == osmv_rmpp_is_first(p_mad)) {
- osm_log(p_bo->p_vendor->p_log, OSM_LOG_DEBUG,
- "The MAD does not match any transaction "
- "and does not start a sender-initiated RMPP transfer.\n");
- goto dispatch_rmpp_mad_done;
- }
-
- /* IB Spec 13.6.2.2. This is a Sender Initiated Transfer.
- My peer is the requester and RMPP Sender. I am the RMPP Receiver.
- */
- status = osmv_txn_init(h_bind, /*tid==key */ key, key, &p_txn);
- if (IB_SUCCESS != status) {
- goto dispatch_rmpp_mad_done;
- }
-
- is_init_by_peer = TRUE;
- osm_log(p_bo->p_vendor->p_log, OSM_LOG_DEBUG,
- "A new sender-initiated transfer (TID=0x%llX) started\n",
- key);
- }
-
- if (OSMV_TXN_RMPP_NONE == osmv_txn_get_rmpp_state(p_txn)) {
- /* Case 1: Fall through from above.
- * Case 2: When the transaction was initiated by me
- * (a single request MAD), there was an uncertainty
- * whether the reply will be RMPP. Now it's resolved,
- * since the reply is RMPP!
- */
- status =
- osmv_txn_init_rmpp_receiver(h_bind, p_txn, is_init_by_peer);
- if (IB_SUCCESS != status) {
- goto dispatch_rmpp_mad_done;
- }
- }
-
- switch (osmv_txn_get_rmpp_state(p_txn)) {
-
- case OSMV_TXN_RMPP_RECEIVER:
- status =
- __osmv_dispatch_rmpp_rcv(h_bind, p_mad, p_txn, p_mad_addr);
- if (IB_SUCCESS != status) {
- if (FALSE == osmv_txn_is_rmpp_init_by_peer(p_txn)) {
- /* This is a requester, still waiting for the reply. Apply the callback */
- /* update the status of the p_madw */
- p_madw = osmv_txn_get_madw(p_txn);
- p_madw->status = status;
- p_bo->send_err_cb(p_bo->cb_context, p_madw);
- }
-
- /* ABORT/STOP/LOCAL ERROR */
- osmv_txn_done(h_bind, osmv_txn_get_key(p_txn), FALSE);
- }
- break;
-
- case OSMV_TXN_RMPP_SENDER:
- __osmv_dispatch_rmpp_snd(h_bind, p_mad, p_txn, p_mad_addr);
- /* If an error happens here, it's the sender thread to cleanup the txn */
- break;
-
- default:
- CL_ASSERT(FALSE);
- }
-
-dispatch_rmpp_mad_done:
- OSM_LOG_EXIT(p_bo->p_vendor->p_log);
-}
-
-/*
- * NAME __osmv_dispatch_rmpp_snd()
- *
- * DESCRIPTION MAD handling by an RMPP sender (ACK/ABORT/STOP)
- */
-
-static void
-__osmv_dispatch_rmpp_snd(IN osm_bind_handle_t h_bind,
- IN const ib_mad_t * p_mad,
- IN osmv_txn_ctx_t * p_txn,
- IN const osm_mad_addr_t * p_mad_addr)
-{
- osmv_rmpp_send_ctx_t *p_send_ctx = osmv_txn_get_rmpp_send_ctx(p_txn);
-
- uint32_t old_wl = p_send_ctx->window_last;
- uint32_t total_segs = osmv_rmpp_send_ctx_get_num_segs(p_send_ctx);
- uint32_t seg_num = cl_ntoh32(((ib_rmpp_mad_t *) p_mad)->seg_num);
- uint32_t new_wl = cl_ntoh32(((ib_rmpp_mad_t *) p_mad)->paylen_newwin);
- osmv_bind_obj_t *p_bo = (osmv_bind_obj_t *) h_bind;
-
- OSM_LOG_ENTER(p_bo->p_vendor->p_log);
-
- if (TRUE == osmv_rmpp_is_abort_stop(p_mad)) {
-
- osm_log(p_bo->p_vendor->p_log, OSM_LOG_ERROR,
- "__osmv_dispatch_rmpp_snd: ERR 6502: "
- "The remote side sent an ABORT/STOP indication.\n");
- osmv_rmpp_snd_error(p_send_ctx, IB_REMOTE_ERROR);
- goto dispatch_rmpp_snd_done;
- }
-
- if (FALSE == osmv_rmpp_is_ack(p_mad)) {
-
- osm_log(p_bo->p_vendor->p_log, OSM_LOG_DEBUG,
- "Not supposed to receive DATA packets --> dropping the MAD\n");
- goto dispatch_rmpp_snd_done;
- }
-
- /* Continue processing the ACK */
- if (seg_num > old_wl) {
-
- osm_log(p_bo->p_vendor->p_log, OSM_LOG_ERROR,
- "__osmv_dispatch_rmpp_snd: ERR 6503: "
- "ACK received for a non-sent segment %d\n", seg_num);
-
- osmv_rmpp_send_nak(h_bind, p_mad, p_mad_addr,
- IB_RMPP_TYPE_ABORT, IB_RMPP_STATUS_S2B);
-
- osmv_rmpp_snd_error(p_send_ctx, IB_REMOTE_ERROR);
- goto dispatch_rmpp_snd_done;
- }
-
- osm_log(p_bo->p_vendor->p_log, OSM_LOG_DEBUG,
- "__osmv_dispatch_rmpp_snd: "
- "New WL = %u Old WL = %u Total Segs = %u\n",
- new_wl, old_wl, total_segs);
-
- if (new_wl < old_wl) {
- osm_log(p_bo->p_vendor->p_log, OSM_LOG_ERROR,
- "__osmv_dispatch_rmpp_snd: ERR 6508: "
- "The receiver requests a smaller WL (%d) than before (%d)\n",
- new_wl, old_wl);
-
- osmv_rmpp_send_nak(h_bind, p_mad, p_mad_addr,
- IB_RMPP_TYPE_ABORT, IB_RMPP_STATUS_W2S);
-
- osmv_rmpp_snd_error(p_send_ctx, IB_REMOTE_ERROR);
- goto dispatch_rmpp_snd_done;
- }
-
- /* Update the sender's window, and optionally wake up the sender thread
- * Note! A single ACK can acknowledge a whole range of segments: [WF..SEG_NUM]
- */
- osm_log(p_bo->p_vendor->p_log, OSM_LOG_DEBUG,
- "ACK for seg_num #%d accepted.\n", seg_num);
-
- if (seg_num == old_wl) {
-
- osm_log(p_bo->p_vendor->p_log, OSM_LOG_DEBUG,
- "The send window [%d:%d] is totally acknowledged.\n",
- p_send_ctx->window_first, old_wl);
-
- p_send_ctx->window_first = seg_num + 1;
- p_send_ctx->window_last =
- (new_wl < total_segs) ? new_wl : total_segs;
-
- /* Remove the response timeout event for the window */
- osmv_txn_remove_timeout_ev(h_bind, osmv_txn_get_key(p_txn));
-
- /* Wake up the sending thread */
- cl_event_signal(&p_send_ctx->event);
- }
-
-dispatch_rmpp_snd_done:
- OSM_LOG_EXIT(p_bo->p_vendor->p_log);
-}
-
-/*
- * NAME __osmv_dispatch_rmpp_rcv()
- *
- * DESCRIPTION MAD handling by an RMPP receiver (DATA/ABORT/STOP)
- */
-
-static ib_api_status_t
-__osmv_dispatch_rmpp_rcv(IN osm_bind_handle_t h_bind,
- IN const ib_mad_t * p_mad,
- IN osmv_txn_ctx_t * p_txn,
- IN const osm_mad_addr_t * p_mad_addr)
-{
- ib_api_status_t status = IB_SUCCESS;
- osmv_rmpp_recv_ctx_t *p_recv_ctx = osmv_txn_get_rmpp_recv_ctx(p_txn);
- osmv_bind_obj_t *p_bo = (osmv_bind_obj_t *) h_bind;
- boolean_t is_last1 = FALSE, is_last2 = FALSE;
- osm_madw_t *p_new_madw = NULL, *p_req_madw = NULL;
- ib_mad_t *p_mad_buf;
- uint32_t size = 0;
- uint64_t key = osmv_txn_get_key(p_txn);
- uint64_t tid = osmv_txn_get_tid(p_txn);
-
- OSM_LOG_ENTER(p_bo->p_vendor->p_log);
-
- if (TRUE == osmv_rmpp_is_ack(p_mad)) {
- osm_log(p_bo->p_vendor->p_log, OSM_LOG_DEBUG,
- "Not supposed to receive ACK's --> dropping the MAD\n");
-
- goto dispatch_rmpp_rcv_done;
- }
-
- if (TRUE == osmv_rmpp_is_abort_stop(p_mad)) {
- osm_log(p_bo->p_vendor->p_log, OSM_LOG_DEBUG,
- "__osmv_dispatch_rmpp_rcv: ERR 6504: "
- "The Remote Side stopped sending\n");
-
- status = IB_REMOTE_ERROR;
- goto dispatch_rmpp_rcv_done;
- }
-
- status = __osmv_dispatch_accept_seg(h_bind, p_txn, p_mad);
- switch (status) {
-
- case IB_SUCCESS:
-
- /* Check wheter this is the legal last MAD */
- /* Criteria #1: the received MAD is marked last */
- is_last1 = osmv_rmpp_is_last(p_mad);
-
- /* Criteria #2: the total accumulated length hits the advertised one */
- is_last2 = is_last1;
-
- size = osmv_rmpp_recv_ctx_get_byte_num_from_first(p_recv_ctx);
- if (size > 0) {
- is_last2 =
- (osmv_rmpp_recv_ctx_get_cur_byte_num(p_recv_ctx) >=
- size);
- }
-
- if (is_last1 != is_last2) {
-
- osmv_rmpp_send_nak(h_bind, p_mad, p_mad_addr,
- IB_RMPP_TYPE_ABORT,
- IB_RMPP_STATUS_BAD_LEN);
-
- status = IB_ERROR;
- goto dispatch_rmpp_rcv_done;
- }
-
- /* TBD Consider an optimization - sending an ACK
- * only for the last segment in the window
- */
- __osmv_dispatch_send_ack(h_bind, p_mad, p_txn, p_mad_addr);
- break;
-
- case IB_INSUFFICIENT_RESOURCES:
- /* An out-of-order segment received. Send the ACK anyway */
- __osmv_dispatch_send_ack(h_bind, p_mad, p_txn, p_mad_addr);
- status = IB_SUCCESS;
- goto dispatch_rmpp_rcv_done;
-
- case IB_INSUFFICIENT_MEMORY:
- osmv_rmpp_send_nak(h_bind, p_mad, p_mad_addr,
- IB_RMPP_TYPE_STOP, IB_RMPP_STATUS_RESX);
- goto dispatch_rmpp_rcv_done;
-
- default:
- /* Illegal return code */
- CL_ASSERT(FALSE);
- }
-
- if (TRUE != is_last1) {
- osm_log(p_bo->p_vendor->p_log, OSM_LOG_DEBUG,
- "RMPP MADW assembly continues, TID=0x%llX\n", tid);
- goto dispatch_rmpp_rcv_done;
- }
-
- /* This is the last packet. */
- if (0 == size) {
- /* The total size was not advertised in the first packet */
- size = osmv_rmpp_recv_ctx_get_byte_num_from_last(p_recv_ctx);
- }
-
- /*
- NOTE: the received mad might not be >= 256 bytes.
- some MADs might contain several SA records but still be
- less then a full MAD.
- We have to use RMPP to send them over since on a regular
- "simple" MAD there is no way to know how many records were sent
- */
-
- /* Build the MAD wrapper to be returned to the user.
- * The actual storage for the MAD is allocated there.
- */
- p_new_madw =
- osm_mad_pool_get(p_bo->p_osm_pool, h_bind, size, p_mad_addr);
- if (NULL == p_new_madw) {
- osm_log(p_bo->p_vendor->p_log, OSM_LOG_ERROR,
- "__osmv_dispatch_rmpp_rcv: ERR 6506: "
- "Out Of Memory - could not allocate %d bytes for the MADW\n",
- size);
-
- status = IB_INSUFFICIENT_MEMORY;
- goto dispatch_rmpp_rcv_done;
- }
-
- p_req_madw = osmv_txn_get_madw(p_txn);
- p_mad_buf = osm_madw_get_mad_ptr(p_new_madw);
- status = osmv_rmpp_recv_ctx_reassemble_arbt_mad(p_recv_ctx, size,
- (uint8_t *) p_mad_buf);
- if (IB_SUCCESS != status) {
- osm_log(p_bo->p_vendor->p_log, OSM_LOG_ERROR,
- "__osmv_dispatch_rmpp_rcv: ERR 6507: "
- "Internal error - could not reassemble the result MAD\n");
- goto dispatch_rmpp_rcv_done; /* What can happen here? */
- }
-
- /* The MAD is assembled, we are about to apply the callback.
- * Delete the transaction context, unless the transaction is double sided */
- if (FALSE == osmv_txn_is_rmpp_init_by_peer(p_txn)
- || FALSE == osmv_mad_is_multi_resp(p_mad)) {
-
- osmv_txn_done(h_bind, key, FALSE);
- }
-
- osm_log(p_bo->p_vendor->p_log, OSM_LOG_DEBUG,
- "RMPP MADW %p assembly complete, TID=0x%llX\n", p_new_madw,
- tid);
-
- p_mad_buf->trans_id = cl_hton64(tid);
- osm_log(p_bo->p_vendor->p_log, OSM_LOG_DEBUG,
- "Restoring the original TID to 0x%llX\n",
- cl_ntoh64(p_mad_buf->trans_id));
-
- /* Finally, do the job! */
- p_bo->recv_cb(p_new_madw, p_bo->cb_context, p_req_madw);
-
-dispatch_rmpp_rcv_done:
- OSM_LOG_EXIT(p_bo->p_vendor->p_log);
- return status;
-}
-
-/*
- * NAME __osmv_dispatch_accept_seg()
- *
- * DESCRIPTION Store a DATA segment at the RMPP receiver side,
- * if one is received in order.
- */
-
-static ib_api_status_t
-__osmv_dispatch_accept_seg(IN osm_bind_handle_t h_bind,
- IN osmv_txn_ctx_t * p_txn, IN const ib_mad_t * p_mad)
-{
- ib_api_status_t ret = IB_SUCCESS;
- uint32_t seg_num = cl_ntoh32(((ib_rmpp_mad_t *) p_mad)->seg_num);
- osmv_rmpp_recv_ctx_t *p_recv_ctx = osmv_txn_get_rmpp_recv_ctx(p_txn);
- osmv_bind_obj_t *p_bo = (osmv_bind_obj_t *) h_bind;
- uint64_t tid = osmv_txn_get_tid(p_txn);
-
- OSM_LOG_ENTER(p_bo->p_vendor->p_log);
-
- if (seg_num != p_recv_ctx->expected_seg) {
- osm_log(p_bo->p_vendor->p_log, OSM_LOG_DEBUG,
- "TID 0x%llX: can't accept this segment (%d) - "
- "this is a Go-Back-N implementation\n", tid, seg_num);
- return IB_INSUFFICIENT_RESOURCES;
- }
-
- /* Store the packet's copy in the reassembly list.
- * Promote the expected segment counter.
- */
- ret = osmv_rmpp_recv_ctx_store_mad_seg(p_recv_ctx, (uint8_t *) p_mad);
- if (IB_SUCCESS != ret) {
- return ret;
- }
-
- osm_log(p_bo->p_vendor->p_log, OSM_LOG_DEBUG,
- "TID 0x%llX: segment %d accepted\n", tid, seg_num);
- p_recv_ctx->expected_seg = seg_num + 1;
-
- OSM_LOG_EXIT(p_bo->p_vendor->p_log);
- return IB_SUCCESS;
-}
-
-/*
- * NAME __osmv_dispatch_send_ack()
- *
- * DESCRIPTION
- *
- * ISSUES
- * Consider sending the ACK from an async thread
- * if problems with the receiving side processing arise.
- */
-
-static void
-__osmv_dispatch_send_ack(IN osm_bind_handle_t h_bind,
- IN const ib_mad_t * p_req_mad,
- IN osmv_txn_ctx_t * p_txn,
- IN const osm_mad_addr_t * p_mad_addr)
-{
- osmv_rmpp_recv_ctx_t *p_recv_ctx = osmv_txn_get_rmpp_recv_ctx(p_txn);
-
- /* ACK the segment # that was accepted */
- uint32_t seg_num = cl_ntoh32(((ib_rmpp_mad_t *) p_req_mad)->seg_num);
-
- /* NOTE! The receiver can publish the New Window Last (NWL) value
- * that is greater than the total number of segments to be sent.
- * It's the sender's responsibility to compute the correct number
- * of segments to send in the next burst.
- */
- uint32_t nwl = p_recv_ctx->expected_seg + OSMV_RMPP_RECV_WIN - 1;
-
- osmv_rmpp_send_ack(h_bind, p_req_mad, seg_num, nwl, p_mad_addr);
-}
diff --git a/contrib/ofed/management/opensm/libvendor/osm_vendor_mlx_hca.c b/contrib/ofed/management/opensm/libvendor/osm_vendor_mlx_hca.c
deleted file mode 100644
index e98e272..0000000
--- a/contrib/ofed/management/opensm/libvendor/osm_vendor_mlx_hca.c
+++ /dev/null
@@ -1,524 +0,0 @@
-/*
- * Copyright (c) 2004-2006 Voltaire, Inc. All rights reserved.
- * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved.
- * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- */
-
-#if HAVE_CONFIG_H
-# include <config.h>
-#endif /* HAVE_CONFIG_H */
-
-#include <stdlib.h>
-#include <string.h>
-#if defined(OSM_VENDOR_INTF_MTL) | defined(OSM_VENDOR_INTF_TS)
-#undef IN
-#undef OUT
-#include <vapi_types.h>
-#include <evapi.h>
-#include <vendor/osm_vendor_api.h>
-#include <opensm/osm_log.h>
-#include <stdlib.h>
-#include <stdio.h>
-
-/********************************************************************************
- *
- * Provide the functionality for selecting an HCA Port and Obtaining it's guid.
- *
- ********************************************************************************/
-
-typedef struct _osm_ca_info {
- ib_net64_t guid;
- size_t attr_size;
- ib_ca_attr_t *p_attr;
-} osm_ca_info_t;
-
-/**********************************************************************
- * Convert the given GID to GUID by copy of it's upper 8 bytes
- **********************************************************************/
-ib_api_status_t
-__osm_vendor_gid_to_guid(IN u_int8_t * gid, OUT VAPI_gid_t * guid)
-{
- memcpy(guid, gid + 8, 8);
- return (IB_SUCCESS);
-}
-
-/**********************************************************************
- * Returns a pointer to the port attribute of the specified port
- * owned by this CA.
- ************************************************************************/
-static ib_port_attr_t *__osm_ca_info_get_port_attr_ptr(IN const osm_ca_info_t *
- const p_ca_info,
- IN const uint8_t index)
-{
- return (&p_ca_info->p_attr->p_port_attr[index]);
-}
-
-/********************************************************************************
- * get the CA names available on the system
- * NOTE: user of this function needs to deallocate p_hca_ids after usage.
- ********************************************************************************/
-static ib_api_status_t
-__osm_vendor_get_ca_ids(IN osm_vendor_t * const p_vend,
- IN VAPI_hca_id_t ** const p_hca_ids,
- IN uint32_t * const p_num_guids)
-{
- ib_api_status_t status;
- VAPI_ret_t vapi_res;
-
- OSM_LOG_ENTER(p_vend->p_log);
-
- CL_ASSERT(p_hca_ids);
- CL_ASSERT(p_num_guids);
-
- /* first call is just to get the number */
- vapi_res = EVAPI_list_hcas(0, p_num_guids, NULL);
-
- /* fail ? */
- if (vapi_res == VAPI_EINVAL_PARAM) {
- osm_log(p_vend->p_log, OSM_LOG_ERROR,
- "__osm_vendor_get_ca_ids: ERR 3D08: : "
- "Bad parameter in calling: EVAPI_list_hcas. (%d)\n",
- vapi_res);
- status = IB_ERROR;
- goto Exit;
- }
-
- /* NO HCA ? */
- if (*p_num_guids == 0) {
- osm_log(p_vend->p_log, OSM_LOG_ERROR,
- "__osm_vendor_get_ca_ids: ERR 3D09: "
- "No available channel adapters.\n");
- status = IB_INSUFFICIENT_RESOURCES;
- goto Exit;
- }
-
- /* allocate and really call - user of this function needs to deallocate it */
- *p_hca_ids =
- (VAPI_hca_id_t *) malloc(*p_num_guids * sizeof(VAPI_hca_id_t));
-
- /* now call it really */
- vapi_res = EVAPI_list_hcas(*p_num_guids, p_num_guids, *p_hca_ids);
-
- /* too many ? */
- if (vapi_res == VAPI_EAGAIN) {
- osm_log(p_vend->p_log, OSM_LOG_ERROR,
- "__osm_vendor_get_ca_ids: ERR 3D10: "
- "More CA GUIDs than allocated array (%d).\n",
- *p_num_guids);
- status = IB_ERROR;
- goto Exit;
- }
-
- /* fail ? */
- if (vapi_res != VAPI_OK) {
- osm_log(p_vend->p_log, OSM_LOG_ERROR,
- "__osm_vendor_get_ca_ids: ERR 3D11: : "
- "Bad parameter in calling: EVAPI_list_hcas.\n");
- status = IB_ERROR;
- goto Exit;
- }
-
- if (osm_log_is_active(p_vend->p_log, OSM_LOG_DEBUG)) {
- osm_log(p_vend->p_log, OSM_LOG_DEBUG,
- "__osm_vendor_get_ca_ids: "
- "Detected %u local channel adapters.\n", *p_num_guids);
- }
-
- status = IB_SUCCESS;
-
-Exit:
- OSM_LOG_EXIT(p_vend->p_log);
- return (status);
-}
-
-/**********************************************************************
- * Initialize an Info Struct for the Given HCA by its Id
- **********************************************************************/
-static ib_api_status_t
-__osm_ca_info_init(IN osm_vendor_t * const p_vend,
- IN VAPI_hca_id_t ca_id, OUT osm_ca_info_t * const p_ca_info)
-{
- ib_api_status_t status = IB_ERROR;
- VAPI_ret_t vapi_res;
- VAPI_hca_hndl_t hca_hndl;
- VAPI_hca_vendor_t hca_vendor;
- VAPI_hca_cap_t hca_cap;
- VAPI_hca_port_t hca_port;
- uint8_t port_num;
- IB_gid_t *p_port_gid;
- uint16_t maxNumGids;
-
- OSM_LOG_ENTER(p_vend->p_log);
-
- /* get the HCA handle */
- vapi_res = EVAPI_get_hca_hndl(ca_id, &hca_hndl);
- if (vapi_res != VAPI_OK) {
- osm_log(p_vend->p_log, OSM_LOG_ERROR,
- "__osm_ca_info_init: ERR 3D05: "
- "Fail to get HCA handle (%u).\n", vapi_res);
- goto Exit;
- }
-
- if (osm_log_is_active(p_vend->p_log, OSM_LOG_DEBUG)) {
- osm_log(p_vend->p_log, OSM_LOG_DEBUG,
- "__osm_ca_info_init: " "Querying CA %s.\n", ca_id);
- }
-
- /* query and get the HCA capability */
- vapi_res = VAPI_query_hca_cap(hca_hndl, &hca_vendor, &hca_cap);
- if (vapi_res != VAPI_OK) {
- osm_log(p_vend->p_log, OSM_LOG_ERROR,
- "__osm_ca_info_init: ERR 3D06: "
- "Fail to get HCA Capabilities (%u).\n", vapi_res);
- goto Exit;
- }
-
- /* get the guid of the HCA */
- memcpy(&(p_ca_info->guid), hca_cap.node_guid, 8 * sizeof(u_int8_t));
- p_ca_info->attr_size = 1;
- p_ca_info->p_attr = (ib_ca_attr_t *) malloc(sizeof(ib_ca_attr_t));
- memcpy(&(p_ca_info->p_attr->ca_guid), hca_cap.node_guid,
- 8 * sizeof(u_int8_t));
-
- /* now obtain the attributes of the ports */
- p_ca_info->p_attr->num_ports = hca_cap.phys_port_num;
- p_ca_info->p_attr->p_port_attr =
- (ib_port_attr_t *) malloc(hca_cap.phys_port_num *
- sizeof(ib_port_attr_t));
-
- for (port_num = 0; port_num < p_ca_info->p_attr->num_ports; port_num++) {
-
- /* query the port attributes */
- vapi_res =
- VAPI_query_hca_port_prop(hca_hndl, port_num + 1, &hca_port);
- if (vapi_res != VAPI_OK) {
- osm_log(p_vend->p_log, OSM_LOG_ERROR,
- "__osm_ca_info_init: ERR 3D07: "
- "Fail to get HCA Port Attributes (%d).\n",
- vapi_res);
- goto Exit;
- }
-
- /* first call to know the size of the gid table */
- vapi_res =
- VAPI_query_hca_gid_tbl(hca_hndl, port_num + 1, 0,
- &maxNumGids, NULL);
- p_port_gid = (IB_gid_t *) malloc(maxNumGids * sizeof(IB_gid_t));
-
- vapi_res =
- VAPI_query_hca_gid_tbl(hca_hndl, port_num + 1, maxNumGids,
- &maxNumGids, p_port_gid);
- if (vapi_res != VAPI_OK) {
- osm_log(p_vend->p_log, OSM_LOG_ERROR,
- "__osm_ca_info_init: ERR 3D12: "
- "Fail to get HCA Port GID (%d).\n", vapi_res);
- goto Exit;
- }
-
- __osm_vendor_gid_to_guid(p_port_gid[0],
- (IB_gid_t *) & p_ca_info->p_attr->
- p_port_attr[port_num].port_guid);
- p_ca_info->p_attr->p_port_attr[port_num].lid = hca_port.lid;
- p_ca_info->p_attr->p_port_attr[port_num].link_state =
- hca_port.state;
- p_ca_info->p_attr->p_port_attr[port_num].sm_lid =
- hca_port.sm_lid;
-
- free(p_port_gid);
- }
-
- status = IB_SUCCESS;
-Exit:
- OSM_LOG_EXIT(p_vend->p_log);
- return (status);
-}
-
-/**********************************************************************
- **********************************************************************/
-void
-osm_ca_info_destroy(IN osm_vendor_t * const p_vend,
- IN osm_ca_info_t * const p_ca_info, IN uint8_t num_ca)
-{
- osm_ca_info_t *p_ca;
- uint8_t i;
-
- OSM_LOG_ENTER(p_vend->p_log);
-
- for (i = 0; i < num_ca; i++) {
- p_ca = &p_ca_info[i];
-
- if (NULL != p_ca->p_attr) {
- if (0 != p_ca->p_attr->num_ports) {
- free(p_ca->p_attr->p_port_attr);
- }
-
- free(p_ca->p_attr);
- }
- }
-
- free(p_ca_info);
-
- OSM_LOG_EXIT(p_vend->p_log);
-}
-
-/**********************************************************************
- * Fill in the array of port_attr with all available ports on ALL the
- * avilable CAs on this machine.
- * ALSO -
- * Update the vendor object list of ca_info structs
- **********************************************************************/
-ib_api_status_t
-osm_vendor_get_all_port_attr(IN osm_vendor_t * const p_vend,
- IN ib_port_attr_t * const p_attr_array,
- IN uint32_t * const p_num_ports)
-{
- ib_api_status_t status;
-
- uint32_t ca;
- uint32_t ca_count = 0;
- uint32_t port_count = 0;
- uint8_t port_num;
- uint32_t total_ports = 0;
- VAPI_hca_id_t *p_ca_ids = NULL;
- osm_ca_info_t *p_ca_infos = NULL;
- uint32_t attr_array_sz = *p_num_ports;
-
- OSM_LOG_ENTER(p_vend->p_log);
-
- CL_ASSERT(p_vend);
-
- /* determine the number of CA's */
- status = __osm_vendor_get_ca_ids(p_vend, &p_ca_ids, &ca_count);
- if (status != IB_SUCCESS) {
- osm_log(p_vend->p_log, OSM_LOG_ERROR,
- "osm_vendor_get_all_port_attr: ERR 3D13: "
- "Fail to get CA Ids.\n");
- goto Exit;
- }
-
- /* Allocate an array big enough to hold the ca info objects */
- p_ca_infos = malloc(ca_count * sizeof(osm_ca_info_t));
- if (p_ca_infos == NULL) {
- osm_log(p_vend->p_log, OSM_LOG_ERROR,
- "osm_vendor_get_all_port_attr: ERR 3D14: "
- "Unable to allocate CA information array.\n");
- goto Exit;
- }
-
- memset(p_ca_infos, 0, ca_count * sizeof(osm_ca_info_t));
-
- /*
- * For each CA, retrieve the CA info attributes
- */
- for (ca = 0; ca < ca_count; ca++) {
- status =
- __osm_ca_info_init(p_vend, p_ca_ids[ca], &p_ca_infos[ca]);
- if (status != IB_SUCCESS) {
- osm_log(p_vend->p_log, OSM_LOG_ERROR,
- "osm_vendor_get_all_port_attr: ERR 3D15: "
- "Unable to initialize CA Info object (%s).\n",
- ib_get_err_str(status));
- goto Exit;
- }
- total_ports += p_ca_infos[ca].p_attr->num_ports;
- }
-
- *p_num_ports = total_ports;
- osm_log(p_vend->p_log, OSM_LOG_DEBUG,
- "osm_vendor_get_all_port_attr: total ports:%u \n", total_ports);
-
- /*
- * If the user supplied enough storage, return the port guids,
- * otherwise, return the appropriate error.
- */
- if (attr_array_sz >= total_ports) {
- for (ca = 0; ca < ca_count; ca++) {
- uint32_t num_ports;
-
- num_ports = p_ca_infos[ca].p_attr->num_ports;
-
- for (port_num = 0; port_num < num_ports; port_num++) {
- p_attr_array[port_count] =
- *__osm_ca_info_get_port_attr_ptr(&p_ca_infos
- [ca],
- port_num);
- port_count++;
- }
- }
- } else {
- status = IB_INSUFFICIENT_MEMORY;
- goto Exit;
- }
-
- status = IB_SUCCESS;
-
-Exit:
- if (p_ca_ids)
- free(p_ca_ids);
-
- if (p_ca_infos) {
- osm_ca_info_destroy(p_vend, p_ca_infos, ca_count);
- }
-
- OSM_LOG_EXIT(p_vend->p_log);
- return (status);
-}
-
-/**********************************************************************
- * Given the vendor obj and a guid
- * return the ca id and port number that have that guid
- **********************************************************************/
-
-ib_api_status_t
-osm_vendor_get_guid_ca_and_port(IN osm_vendor_t * const p_vend,
- IN ib_net64_t const guid,
- OUT VAPI_hca_hndl_t * p_hca_hndl,
- OUT VAPI_hca_id_t * p_hca_id,
- OUT uint8_t * p_hca_idx,
- OUT uint32_t * p_port_num)
-{
-
- ib_api_status_t status;
- VAPI_hca_id_t *p_ca_ids = NULL;
- VAPI_ret_t vapi_res;
- VAPI_hca_hndl_t hca_hndl;
- VAPI_hca_vendor_t hca_vendor;
- VAPI_hca_cap_t hca_cap;
- IB_gid_t *p_port_gid = NULL;
- uint16_t maxNumGids;
- ib_net64_t port_guid;
- uint32_t ca, portIdx, ca_count;
-
- OSM_LOG_ENTER(p_vend->p_log);
-
- CL_ASSERT(p_vend);
-
- /*
- * 1) Determine the number of CA's
- * 2) Allocate an array big enough to hold the ca info objects.
- * 3) Call again to retrieve the guids.
- */
- status = __osm_vendor_get_ca_ids(p_vend, &p_ca_ids, &ca_count);
- if (status != IB_SUCCESS) {
- osm_log(p_vend->p_log, OSM_LOG_ERROR,
- "osm_vendor_get_guid_ca_and_port: ERR 3D16: "
- "Fail to get CA Ids.\n");
- goto Exit;
- }
-
- /*
- * For each CA, retrieve the CA info attributes
- */
- for (ca = 0; ca < ca_count; ca++) {
- /* get the HCA handle */
- vapi_res = EVAPI_get_hca_hndl(p_ca_ids[ca], &hca_hndl);
- if (vapi_res != VAPI_OK) {
- osm_log(p_vend->p_log, OSM_LOG_ERROR,
- "osm_vendor_get_guid_ca_and_port: ERR 3D17: "
- "Fail to get HCA handle (%u).\n", vapi_res);
- goto Exit;
- }
-
- /* get the CA attributes - to know how many ports it has: */
- if (osm_log_is_active(p_vend->p_log, OSM_LOG_DEBUG)) {
- osm_log(p_vend->p_log, OSM_LOG_DEBUG,
- "osm_vendor_get_guid_ca_and_port: "
- "Querying CA %s.\n", p_ca_ids[ca]);
- }
-
- /* query and get the HCA capability */
- vapi_res = VAPI_query_hca_cap(hca_hndl, &hca_vendor, &hca_cap);
- if (vapi_res != VAPI_OK) {
- osm_log(p_vend->p_log, OSM_LOG_ERROR,
- "osm_vendor_get_guid_ca_and_port: ERR 3D18: "
- "Fail to get HCA Capabilities (%u).\n",
- vapi_res);
- goto Exit;
- }
-
- /* go over all ports - to obtail their guids */
- for (portIdx = 0; portIdx < hca_cap.phys_port_num; portIdx++) {
- vapi_res =
- VAPI_query_hca_gid_tbl(hca_hndl, portIdx + 1, 0,
- &maxNumGids, NULL);
- p_port_gid =
- (IB_gid_t *) malloc(maxNumGids * sizeof(IB_gid_t));
-
- /* get the port guid */
- vapi_res =
- VAPI_query_hca_gid_tbl(hca_hndl, portIdx + 1,
- maxNumGids, &maxNumGids,
- p_port_gid);
- if (vapi_res != VAPI_OK) {
- osm_log(p_vend->p_log, OSM_LOG_ERROR,
- "osm_vendor_get_guid_ca_and_port: ERR 3D19: "
- "Fail to get HCA Port GID (%d).\n",
- vapi_res);
- goto Exit;
- }
-
- /* convert to SF style */
- __osm_vendor_gid_to_guid(p_port_gid[0],
- (VAPI_gid_t *) & port_guid);
-
- /* finally did we find it ? */
- if (port_guid == guid) {
- *p_hca_hndl = hca_hndl;
- memcpy(p_hca_id, p_ca_ids[ca],
- sizeof(VAPI_hca_id_t));
- *p_hca_idx = ca;
- *p_port_num = portIdx + 1;
- status = IB_SUCCESS;
- goto Exit;
- }
-
- free(p_port_gid);
- p_port_gid = NULL;
- } /* ALL PORTS */
- } /* all HCAs */
-
- osm_log(p_vend->p_log, OSM_LOG_ERROR,
- "osm_vendor_get_guid_ca_and_port: ERR 3D20: "
- "Fail to find HCA and Port for Port Guid 0x%" PRIx64 "\n",
- cl_ntoh64(guid));
- status = IB_INVALID_GUID;
-
-Exit:
- if (p_ca_ids != NULL)
- free(p_ca_ids);
- if (p_port_gid != NULL)
- free(p_port_gid);
- OSM_LOG_EXIT(p_vend->p_log);
- return (status);
-}
-
-#endif
diff --git a/contrib/ofed/management/opensm/libvendor/osm_vendor_mlx_hca_anafa.c b/contrib/ofed/management/opensm/libvendor/osm_vendor_mlx_hca_anafa.c
deleted file mode 100644
index 81506e4..0000000
--- a/contrib/ofed/management/opensm/libvendor/osm_vendor_mlx_hca_anafa.c
+++ /dev/null
@@ -1,194 +0,0 @@
-/*
- * Copyright (c) 2004-2006 Voltaire, Inc. All rights reserved.
- * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved.
- * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- */
-
-#if HAVE_CONFIG_H
-# include <config.h>
-#endif /* HAVE_CONFIG_H */
-
-#if defined(OSM_VENDOR_INTF_ANAFA)
-#undef IN
-#undef OUT
-
-#include <stdlib.h>
-#include <stddef.h>
-#include <string.h>
-
-#include <vendor/osm_vendor_api.h>
-#include <opensm/osm_log.h>
-#include <sys/ioctl.h>
-
-#include <vendor/osm_vendor_mlx_transport_anafa.h>
-#include <vendor/osm_ts_useraccess.h>
-
-/********************************************************************************
- *
- * Provide the functionality for selecting an HCA Port and Obtaining it's guid.
- *
- ********************************************************************************/
-
-typedef struct _osm_ca_info {
- /* ib_net64_t guid; ?? */
- /* size_t attr_size; ?? */
- ib_ca_attr_t attr;
-} osm_ca_info_t;
-
-/**********************************************************************
- * Convert the given GID to GUID by copy of it's upper 8 bytes
- **********************************************************************/
-ib_api_status_t
-__osm_vendor_gid_to_guid(IN tTS_IB_GID gid, OUT ib_net64_t * p_guid)
-{
- memcpy(p_guid, gid + 8, 8);
- return (IB_SUCCESS);
-}
-
-/**********************************************************************
- * Initialize an Info Struct for the Given HCA by its Id
- **********************************************************************/
-static ib_api_status_t
-__osm_ca_info_init(IN osm_vendor_t * const p_vend,
- OUT osm_ca_info_t * const p_ca_info)
-{
- ib_api_status_t status = IB_ERROR;
- int ioctl_ret = 0;
- osmv_TOPSPIN_ANAFA_transport_info_t *p_tpot_info =
- p_vend->p_transport_info;
- osm_ts_gid_entry_ioctl gid_ioctl;
- osm_ts_get_port_info_ioctl port_info;
- struct ib_get_dev_info_ioctl dev_info;
-
- OSM_LOG_ENTER(p_vend->p_log);
-
- /* query HCA guid */
- ioctl_ret = ioctl(p_tpot_info->device_fd, TS_IB_IOCGDEVINFO, &dev_info);
- if (ioctl_ret != 0) {
- osm_log(p_vend->p_log, OSM_LOG_ERROR,
- "__osm_ca_info_init: ERR 7001: "
- "Fail to get HCA Capabilities (%d).\n", ioctl_ret);
- goto Exit;
- }
-
- memcpy(&(p_ca_info->attr.ca_guid), dev_info.dev_info.node_guid,
- 8 * sizeof(uint8_t));
-
-/* now obtain the attributes of the ports - on our case port 1*/
-
- p_ca_info->attr.num_ports = 1;
- p_ca_info->attr.p_port_attr =
- (ib_port_attr_t *) malloc(1 * sizeof(ib_port_attr_t));
-
- port_info.port = 1;
- ioctl_ret =
- ioctl(p_tpot_info->device_fd, TS_IB_IOCGPORTINFO, &port_info);
- if (ioctl_ret) {
- osm_log(p_vend->p_log, OSM_LOG_ERROR,
- "__osm_ca_info_init: ERR 7002: "
- "Fail to get HCA Port Attributes (%d).\n", ioctl_ret);
- goto Exit;
- }
-
- gid_ioctl.port = 1;
- gid_ioctl.index = 0;
- ioctl_ret =
- ioctl(p_tpot_info->device_fd, TS_IB_IOCGGIDENTRY, &gid_ioctl);
- if (ioctl_ret) {
- osm_log(p_vend->p_log, OSM_LOG_ERROR,
- "__osm_ca_info_init: ERR 7003: "
- "Fail to get HCA Port GID (%d).\n", ioctl_ret);
- goto Exit;
- }
-
- __osm_vendor_gid_to_guid(gid_ioctl.gid_entry,
- &(p_ca_info->attr.p_port_attr[0].port_guid));
- p_ca_info->attr.p_port_attr[0].lid = port_info.port_info.lid;
- p_ca_info->attr.p_port_attr[0].link_state =
- port_info.port_info.port_state;
- p_ca_info->attr.p_port_attr[0].sm_lid = port_info.port_info.sm_lid;
-
- status = IB_SUCCESS;
-Exit:
- OSM_LOG_EXIT(p_vend->p_log);
- return (status);
-}
-
-/**********************************************************************
- **********************************************************************/
-/**********************************************************************
- * Fill in port_attr
- * ALSO -
- * Update the vendor object list of ca_info structs
- **********************************************************************/
-ib_api_status_t
-osm_vendor_get_all_port_attr(IN osm_vendor_t * const p_vend,
- IN ib_port_attr_t * const p_attr_array,
- IN uint32_t * const p_num_ports)
-{
- ib_api_status_t status;
- osm_ca_info_t ca_info;
- uint32_t attr_array_sz = *p_num_ports;
-
- OSM_LOG_ENTER(p_vend->p_log);
- CL_ASSERT(p_vend);
-
- /* anafa has one port - the user didnt supply enough storage space */
- if (attr_array_sz < 1) {
- status = IB_INSUFFICIENT_MEMORY;
- goto Exit;
- }
-
- /*
- * retrieve the CA info attributes
- */
- status = __osm_ca_info_init(p_vend, &ca_info);
- if (status != IB_SUCCESS) {
- osm_log(p_vend->p_log, OSM_LOG_ERROR,
- "osm_vendor_get_all_port_attr: ERR 7004: "
- "Unable to initialize CA Info object (%s).\n",
- ib_get_err_str(status));
- goto Exit;
- }
-
- *p_num_ports = 1;
-
- p_attr_array[0] = ca_info.attr.p_port_attr[0]; /* anafa has only one port */
- status = IB_SUCCESS;
-
-Exit:
-
- OSM_LOG_EXIT(p_vend->p_log);
- return (status);
-}
-
-#endif
diff --git a/contrib/ofed/management/opensm/libvendor/osm_vendor_mlx_hca_pfs.c b/contrib/ofed/management/opensm/libvendor/osm_vendor_mlx_hca_pfs.c
deleted file mode 100644
index 512b7bf..0000000
--- a/contrib/ofed/management/opensm/libvendor/osm_vendor_mlx_hca_pfs.c
+++ /dev/null
@@ -1,751 +0,0 @@
-/*
- * Copyright (c) 2004-2006 Voltaire, Inc. All rights reserved.
- * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved.
- * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- */
-
-#if HAVE_CONFIG_H
-# include <config.h>
-#endif /* HAVE_CONFIG_H */
-
-#if defined(OSM_VENDOR_INTF_MTL) | defined(OSM_VENDOR_INTF_TS)
-#undef IN
-#undef OUT
-#include <vendor/osm_vendor_api.h>
-#include <opensm/osm_log.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include <sys/types.h>
-#include <dirent.h>
-#include <stdio.h>
-#include <sys/stat.h>
-#include <stdint.h>
-#include <fcntl.h>
-
-/********************************************************************************
- *
- * Provides the functionality for selecting an HCA Port and Obtaining it's guid.
- * This version is based on /proc/infiniband file system. So it is limited to
- * The gen1 of openib.org stack.
- *
- ********************************************************************************/
-
-typedef struct _osm_ca_info {
- ib_net64_t guid;
- size_t attr_size;
- ib_ca_attr_t *p_attr;
-
-} osm_ca_info_t;
-
-/**********************************************************************
- * Returns a pointer to the port attribute of the specified port
- * owned by this CA.
- ************************************************************************/
-static ib_port_attr_t *__osm_ca_info_get_port_attr_ptr(IN const osm_ca_info_t *
- const p_ca_info,
- IN const uint8_t index)
-{
- return (&p_ca_info->p_attr->p_port_attr[index]);
-}
-
-/**********************************************************************
- * Obtain the number of local CAs by scanning /proc/infiniband/core
- **********************************************************************/
-int __hca_pfs_get_num_cas()
-{
- int num_cas = 0;
- DIR *dp;
- struct dirent *ep;
-
- dp = opendir("/proc/infiniband/core");
- if (dp != NULL) {
- while ((ep = readdir(dp))) {
- /* CAs are directories with the format ca[1-9][0-9]* */
- if ((ep->d_type == DT_DIR)
- && !strncmp(ep->d_name, "ca", 2)) {
- num_cas++;
- }
- }
- closedir(dp);
- }
- return num_cas;
-}
-
-/*
- name: InfiniHost0
- provider: tavor
- node GUID: 0002:c900:0120:3470
- ports: 2
- vendor ID: 0x2c9
- device ID: 0x5a44
- HW revision: 0xa1
- FW revision: 0x300020080
-*/
-typedef struct _pfs_ca_info {
- char name[32];
- char provider[32];
- uint64_t guid;
- uint8_t num_ports;
- uint32_t vend_id;
- uint16_t dev_id;
- uint16_t rev_id;
- uint64_t fw_rev;
-} pfs_ca_info_t;
-
-/**********************************************************************
- * Parse the CA Info file available in /proc/infiniband/core/caN/info
- **********************************************************************/
-static ib_api_status_t
-__parse_ca_info_file(IN osm_vendor_t * const p_vend,
- IN uint32_t idx, OUT pfs_ca_info_t * pfs_ca_info)
-{
- ib_api_status_t status = IB_ERROR;
- int info_file;
- char file_name[256];
- char file_buffer[3200];
- char *p_ch;
- int g1, g2, g3, g4;
- int num_ports;
- uint32_t len;
-
- OSM_LOG_ENTER(p_vend->p_log);
-
- osm_log(p_vend->p_log, OSM_LOG_DEBUG,
- "__parse_ca_info_file: " "Querying CA %d.\n", idx);
-
- /* we use the proc file system so we must be able to open the info file .. */
- sprintf(file_name, "/proc/infiniband/core/ca%d/info", idx);
- info_file = open(file_name, O_RDONLY);
- if (!info_file) {
- osm_log(p_vend->p_log, OSM_LOG_ERROR,
- "__parse_ca_info_file: ERR 5205: "
- "Fail to open HCA:%d info file:(%s).\n", idx,
- file_name);
- goto Exit;
- }
-
- /* read in the file */
- len = read(info_file, file_buffer, 3200);
- close(info_file);
- file_buffer[len] = '\0';
-
- /*
- parse the file ...
- name: InfiniHost0
- provider: tavor
- node GUID: 0002:c900:0120:3470
- ports: 2
- vendor ID: 0x2c9
- device ID: 0x5a44
- HW revision: 0xa1
- FW revision: 0x300020080
- */
- if (!(p_ch = strstr(file_buffer, "name:"))) {
- osm_log(p_vend->p_log, OSM_LOG_ERROR,
- "__parse_ca_info_file: ERR 5206: "
- "Fail to obtain HCA name. In info file:(%s).\n",
- file_buffer);
- goto Exit;
- }
- if (sscanf(p_ch, "name: %s", pfs_ca_info->name) != 1) {
- osm_log(p_vend->p_log, OSM_LOG_ERROR,
- "__parse_ca_info_file: ERR 5207: "
- "Fail to parse name in info file:(%s).\n", p_ch);
- goto Exit;
- }
-
- /* get the guid of the HCA */
- if (!(p_ch = strstr(file_buffer, "node GUID:"))) {
- osm_log(p_vend->p_log, OSM_LOG_ERROR,
- "__parse_ca_info_file: ERR 5208: "
- "Fail to obtain GUID in info file:(%s).\n",
- file_buffer);
- goto Exit;
- }
- if (sscanf(p_ch, "node GUID: %x:%x:%x:%x", &g1, &g2, &g3, &g4) != 4) {
- osm_log(p_vend->p_log, OSM_LOG_ERROR,
- "__parse_ca_info_file: ERR 5209: "
- "Fail to parse GUID in info file:(%s).\n", p_ch);
- goto Exit;
- }
- pfs_ca_info->guid = (uint64_t) g1 << 48 | (uint64_t) g1 << 32
- | (uint64_t) g1 << 16 | (uint64_t) g3;
-
- /* obtain number of ports */
- if (!(p_ch = strstr(file_buffer, "ports:"))) {
- osm_log(p_vend->p_log, OSM_LOG_ERROR,
- "__parse_ca_info_file: ERR 5210: "
- "Fail to obtain number of ports in info file:(%s).\n",
- file_buffer);
- goto Exit;
- }
- if (sscanf(p_ch, "ports: %d", &num_ports) != 1) {
- osm_log(p_vend->p_log, OSM_LOG_ERROR,
- "__parse_ca_info_file: ERR 5211: "
- "Fail to parse num ports in info file:(%s).\n", p_ch);
- goto Exit;
- }
- pfs_ca_info->num_ports = num_ports;
-
- osm_log(p_vend->p_log, OSM_LOG_DEBUG,
- "__parse_ca_info_file: "
- "CA1 = name:%s guid:0x%016llx ports:%d\n",
- pfs_ca_info->name, pfs_ca_info->guid, pfs_ca_info->num_ports);
-
- status = IB_SUCCESS;
-Exit:
- OSM_LOG_EXIT(p_vend->p_log);
- return status;
-}
-
-/*
- state: ACTIVE
- LID: 0x0001
- LMC: 0x0000
- SM LID: 0x0001
- SM SL: 0x0000
- Capabilities: IsSM
- IsTrapSupported
- IsAutomaticMigrationSupported
- IsSLMappingSupported
- IsLEDInfoSupported
- IsSystemImageGUIDSupported
- IsVendorClassSupported
- IsCapabilityMaskNoticeSupported
-*/
-typedef struct _pfs_port_info {
- uint8_t state;
- uint16_t lid;
- uint8_t lmc;
- uint16_t sm_lid;
- uint8_t sm_sl;
-} pfs_port_info_t;
-
-/**********************************************************************
- * Parse the Port Info file available in /proc/infiniband/core/caN/portM/info
- * Port num is 1..N
- **********************************************************************/
-static ib_api_status_t
-__parse_port_info_file(IN osm_vendor_t * const p_vend,
- IN uint32_t hca_idx,
- IN uint8_t port_num, OUT pfs_port_info_t * pfs_port_info)
-{
- ib_api_status_t status = IB_ERROR;
- int info_file;
- char file_name[256];
- char file_buffer[3200];
- char state[12];
- char *p_ch;
- int lid, sm_lid, lmc, sm_sl;
- uint32_t len;
-
- OSM_LOG_ENTER(p_vend->p_log);
-
- osm_log(p_vend->p_log, OSM_LOG_DEBUG,
- "__parse_port_info_file: "
- "Parsing Proc File System Port Info CA %d Port %d.\n", hca_idx,
- port_num);
-
- /* we use the proc file system so we must be able to open the info file .. */
- sprintf(file_name, "/proc/infiniband/core/ca%d/port%d/info", hca_idx,
- port_num);
- info_file = open(file_name, O_RDONLY);
- if (!info_file) {
- osm_log(p_vend->p_log, OSM_LOG_ERROR,
- "__parse_port_info_file: ERR 5212: "
- "Fail to open HCA:%d Port:%d info file:(%s).\n",
- hca_idx, port_num, file_name);
- goto Exit;
- }
-
- /* read in the file */
- len = read(info_file, file_buffer, 3200);
- close(info_file);
- file_buffer[len] = '\0';
-
- /*
- parse the file ...
- state: ACTIVE
- LID: 0x0001
- LMC: 0x0000
- SM LID: 0x0001
- SM SL: 0x0000
- ...
- */
- if (!(p_ch = strstr(file_buffer, "state:"))) {
- osm_log(p_vend->p_log, OSM_LOG_ERROR,
- "__parse_port_info_file: ERR 5213: "
- "Fail to obtain port state. In info file:(%s).\n",
- file_buffer);
- goto Exit;
- }
- if (sscanf(p_ch, "state: %s", state) != 1) {
- osm_log(p_vend->p_log, OSM_LOG_ERROR,
- "__parse_port_info_file: ERR 5214: "
- "Fail to parse state from info file:(%s).\n", p_ch);
- goto Exit;
- }
-
- if (!strcmp(state, "ACTIVE"))
- pfs_port_info->state = IB_LINK_ACTIVE;
- else if (!strcmp(state, "DOWN"))
- pfs_port_info->state = IB_LINK_DOWN;
- else if (!strcmp(state, "INIT"))
- pfs_port_info->state = IB_LINK_INIT;
- else if (!strcmp(state, "ARMED"))
- pfs_port_info->state = IB_LINK_ARMED;
- else
- pfs_port_info->state = 0;
-
- /* get lid */
- if (!(p_ch = strstr(file_buffer, "LID:"))) {
- osm_log(p_vend->p_log, OSM_LOG_ERROR,
- "__parse_port_info_file: ERR 5215: "
- "Fail to obtain port lid. In info file:(%s).\n",
- file_buffer);
- goto Exit;
- }
- if (sscanf(p_ch, "LID: %x", &lid) != 1) {
- osm_log(p_vend->p_log, OSM_LOG_ERROR,
- "__parse_port_info_file: ERR 5216: "
- "Fail to parse lid from info file:(%s).\n", p_ch);
- goto Exit;
- }
- pfs_port_info->lid = lid;
- /* get LMC */
- if (!(p_ch = strstr(file_buffer, "LMC:"))) {
- osm_log(p_vend->p_log, OSM_LOG_ERROR,
- "__parse_port_info_file: ERR 5217: "
- "Fail to obtain port LMC. In info file:(%s).\n",
- file_buffer);
- goto Exit;
- }
- if (sscanf(p_ch, "LMC: %x", &lmc) != 1) {
- osm_log(p_vend->p_log, OSM_LOG_ERROR,
- "__parse_port_info_file: ERR 5218: "
- "Fail to parse LMC from info file:(%s).\n", p_ch);
- goto Exit;
- }
- pfs_port_info->lmc = lmc;
-
- /* get SM LID */
- if (!(p_ch = strstr(file_buffer, "SM LID:"))) {
- osm_log(p_vend->p_log, OSM_LOG_ERROR,
- "__parse_port_info_file: ERR 5219: "
- "Fail to obtain port SM LID. In info file:(%s).\n",
- file_buffer);
- goto Exit;
- }
- if (sscanf(p_ch, "SM LID: %x", &sm_lid) != 1) {
- osm_log(p_vend->p_log, OSM_LOG_ERROR,
- "__parse_port_info_file: ERR 5220: "
- "Fail to parse SM LID from info file:(%s).\n", p_ch);
- goto Exit;
- }
- pfs_port_info->sm_lid = sm_lid;
-
- /* get SM LID */
- if (!(p_ch = strstr(file_buffer, "SM SL:"))) {
- osm_log(p_vend->p_log, OSM_LOG_ERROR,
- "__parse_port_info_file: ERR 5221: "
- "Fail to obtain port SM SL. In info file:(%s).\n",
- file_buffer);
- goto Exit;
- }
- if (sscanf(p_ch, "SM SL: %x", &sm_sl) != 1) {
- osm_log(p_vend->p_log, OSM_LOG_ERROR,
- "__parse_port_info_file: ERR 5222: "
- "Fail to parse SM SL from info file:(%s).\n", p_ch);
- goto Exit;
- }
- pfs_port_info->sm_sl = sm_sl;
- osm_log(p_vend->p_log, OSM_LOG_DEBUG,
- "__parse_port_info_file: "
- "Obtained Port:%d = state:%d, lid:0x%04X, lmc:%d, sm_lid:0x%04X, sm_sl:%d\n",
- port_num, pfs_port_info->state, pfs_port_info->lid,
- pfs_port_info->lmc, pfs_port_info->sm_lid,
- pfs_port_info->sm_sl);
-
- status = IB_SUCCESS;
-Exit:
- OSM_LOG_EXIT(p_vend->p_log);
- return status;
-}
-
-/**********************************************************************
- * Parse the port guid_tbl file to obtain the port guid.
- * File format is:
- * [ 0] fe80:0000:0000:0000:0002:c900:0120:3472
- **********************************************************************/
-static ib_api_status_t
-__get_port_guid_from_port_gid_tbl(IN osm_vendor_t * const p_vend,
- IN uint32_t hca_idx,
- IN uint8_t port_num, OUT uint64_t * port_guid)
-{
- ib_api_status_t status = IB_ERROR;
- int info_file;
- char file_name[256];
- char file_buffer[3200];
- char *p_ch;
- int g[8];
- uint32_t len;
-
- OSM_LOG_ENTER(p_vend->p_log);
-
- osm_log(p_vend->p_log, OSM_LOG_DEBUG,
- "__get_port_guid_from_port_gid_tbl: "
- "Parsing Proc File System Port Guid Table CA %d Port %d.\n",
- hca_idx, port_num);
-
- /* we use the proc file system so we must be able to open the info file .. */
- sprintf(file_name, "/proc/infiniband/core/ca%d/port%d/gid_table",
- hca_idx, port_num);
- info_file = open(file_name, O_RDONLY);
- if (!info_file) {
- osm_log(p_vend->p_log, OSM_LOG_ERROR,
- "__get_port_guid_from_port_gid_tbl: ERR 5223: "
- "Fail to open HCA:%d Port:%d gid_table file:(%s).\n",
- hca_idx, port_num, file_name);
- goto Exit;
- }
-
- /* read in the file */
- len = read(info_file, file_buffer, 3200);
- close(info_file);
- file_buffer[len] = '\0';
-
- /*
- parse the file ...
- [ 0] fe80:0000:0000:0000:0002:c900:0120:3472
- ...
- */
- if (!(p_ch = strstr(file_buffer, "[ 0]"))) {
- osm_log(p_vend->p_log, OSM_LOG_ERROR,
- "__get_port_guid_from_port_gid_tbl: ERR 5224: "
- "Fail to obtain first gid index. In gid_table file:(%s).\n",
- file_buffer);
- goto Exit;
- }
- if (sscanf(p_ch + 6, "%x:%x:%x:%x:%x:%x:%x:%x",
- &g[7], &g[6], &g[5], &g[4], &g[3], &g[2], &g[1], &g[0]) != 8)
- {
- osm_log(p_vend->p_log, OSM_LOG_ERROR,
- "__get_port_guid_from_port_gid_tbl: ERR 5225: "
- "Fail to parse gid from gid_table file:(%s).\n", p_ch);
- goto Exit;
- }
-
- *port_guid =
- (uint64_t) g[3] << 48 | (uint64_t) g[2] << 32 | (uint64_t) g[1] <<
- 16 | g[0];
- status = IB_SUCCESS;
-Exit:
- OSM_LOG_EXIT(p_vend->p_log);
- return status;
-}
-
-/**********************************************************************
- * Initialize an Info Struct for the Given HCA by its index 1..N
- **********************************************************************/
-static ib_api_status_t
-__osm_ca_info_init(IN osm_vendor_t * const p_vend,
- IN uint32_t const idx, OUT osm_ca_info_t * const p_ca_info)
-{
- ib_api_status_t status = IB_ERROR;
- uint8_t port_num;
- uint64_t port_guid;
-
- pfs_ca_info_t pfs_ca_info;
-
- OSM_LOG_ENTER(p_vend->p_log);
-
- /* parse the CA info file */
- if (__parse_ca_info_file(p_vend, idx, &pfs_ca_info) != IB_SUCCESS)
- goto Exit;
-
- p_ca_info->guid = cl_hton64(pfs_ca_info.guid);
-
- /* set size of attributes and allocate them */
- p_ca_info->attr_size = 1;
- p_ca_info->p_attr = (ib_ca_attr_t *) malloc(sizeof(ib_ca_attr_t));
-
- p_ca_info->p_attr->ca_guid = p_ca_info->guid;
- p_ca_info->p_attr->num_ports = pfs_ca_info.num_ports;
-
- /* now obtain the attributes of the ports */
- p_ca_info->p_attr->p_port_attr =
- (ib_port_attr_t *) malloc(pfs_ca_info.num_ports *
- sizeof(ib_port_attr_t));
-
- /* get all the ports info */
- for (port_num = 1; port_num <= pfs_ca_info.num_ports; port_num++) {
- pfs_port_info_t pfs_port_info;
- /* query the port attributes */
- if (__parse_port_info_file
- (p_vend, idx, port_num, &pfs_port_info)) {
- osm_log(p_vend->p_log, OSM_LOG_ERROR,
- "__osm_ca_info_init: ERR 5226: "
- "Fail to get HCA:%d Port:%d Attributes.\n", idx,
- port_num);
- goto Exit;
- }
-
- /* HACK: the lids should have been converted to network but the rest of the code
- is wrong and provdes them as is (host order) - so we stick with it. */
- p_ca_info->p_attr->p_port_attr[port_num - 1].lid =
- pfs_port_info.lid;
- p_ca_info->p_attr->p_port_attr[port_num - 1].link_state =
- pfs_port_info.state;
- p_ca_info->p_attr->p_port_attr[port_num - 1].sm_lid =
- pfs_port_info.sm_lid;
-
- /* get the port guid */
- if (__get_port_guid_from_port_gid_tbl
- (p_vend, idx, port_num, &port_guid)) {
- osm_log(p_vend->p_log, OSM_LOG_ERROR,
- "__osm_ca_info_init: ERR 5227: "
- "Fail to get HCA:%d Port:%d Guid.\n", idx,
- port_num);
- goto Exit;
- }
- p_ca_info->p_attr->p_port_attr[port_num - 1].port_guid =
- cl_hton64(port_guid);
- }
-
- status = IB_SUCCESS;
-Exit:
- OSM_LOG_EXIT(p_vend->p_log);
- return (status);
-}
-
-/**********************************************************************
- **********************************************************************/
-void
-osm_ca_info_destroy(IN osm_vendor_t * const p_vend,
- IN osm_ca_info_t * const p_ca_info, IN uint8_t num_ca)
-{
- osm_ca_info_t *p_ca;
- uint8_t i;
-
- OSM_LOG_ENTER(p_vend->p_log);
-
- for (i = 0; i < num_ca; i++) {
- p_ca = &p_ca_info[i];
-
- if (NULL != p_ca->p_attr) {
- if (0 != p_ca->p_attr->num_ports) {
- free(p_ca->p_attr->p_port_attr);
- }
-
- free(p_ca->p_attr);
- }
- }
-
- free(p_ca_info);
-
- OSM_LOG_EXIT(p_vend->p_log);
-}
-
-/**********************************************************************
- * Fill in the array of port_attr with all available ports on ALL the
- * avilable CAs on this machine.
- **********************************************************************/
-ib_api_status_t
-osm_vendor_get_all_port_attr(IN osm_vendor_t * const p_vend,
- IN ib_port_attr_t * const p_attr_array,
- IN uint32_t * const p_num_ports)
-{
- ib_api_status_t status = IB_SUCCESS;
-
- uint32_t caIdx;
- uint32_t ca_count = 0;
- uint32_t port_count = 0;
- uint8_t port_num;
- uint32_t total_ports = 0;
- osm_ca_info_t *p_ca_infos = NULL;
- uint32_t attr_array_sz = *p_num_ports;
-
- OSM_LOG_ENTER(p_vend->p_log);
-
- CL_ASSERT(p_vend);
-
- /* determine the number of CA's */
- ca_count = __hca_pfs_get_num_cas();
- if (!ca_count) {
- osm_log(p_vend->p_log, OSM_LOG_ERROR,
- "osm_vendor_get_all_port_attr: ERR 5228: "
- "Fail to get Any CA Ids.\n");
- goto Exit;
- }
-
- /* Allocate an array big enough to hold the ca info objects */
- p_ca_infos = malloc(ca_count * sizeof(osm_ca_info_t));
- if (p_ca_infos == NULL) {
- osm_log(p_vend->p_log, OSM_LOG_ERROR,
- "osm_vendor_get_all_port_attr: ERR 5229: "
- "Unable to allocate CA information array.\n");
- goto Exit;
- }
-
- memset(p_ca_infos, 0, ca_count * sizeof(osm_ca_info_t));
-
- /*
- * For each CA, retrieve the CA info attributes
- */
- for (caIdx = 1; caIdx <= ca_count; caIdx++) {
- status =
- __osm_ca_info_init(p_vend, caIdx, &p_ca_infos[caIdx - 1]);
- if (status != IB_SUCCESS) {
- osm_log(p_vend->p_log, OSM_LOG_ERROR,
- "osm_vendor_get_all_port_attr: ERR 5230: "
- "Unable to initialize CA Info object (%s).\n",
- ib_get_err_str(status));
- goto Exit;
- }
- total_ports += p_ca_infos[caIdx - 1].p_attr->num_ports;
- }
-
- *p_num_ports = total_ports;
- osm_log(p_vend->p_log, OSM_LOG_DEBUG,
- "osm_vendor_get_all_port_attr: total ports:%u \n", total_ports);
-
- /*
- * If the user supplied enough storage, return the port guids,
- * otherwise, return the appropriate error.
- */
- if (attr_array_sz >= total_ports) {
- for (caIdx = 1; caIdx <= ca_count; caIdx++) {
- uint32_t num_ports;
-
- num_ports = p_ca_infos[caIdx - 1].p_attr->num_ports;
-
- for (port_num = 0; port_num < num_ports; port_num++) {
- p_attr_array[port_count] =
- *__osm_ca_info_get_port_attr_ptr(&p_ca_infos
- [caIdx -
- 1],
- port_num);
- port_count++;
- }
- }
- } else {
- status = IB_INSUFFICIENT_MEMORY;
- goto Exit;
- }
-
- status = IB_SUCCESS;
-
-Exit:
- if (p_ca_infos) {
- osm_ca_info_destroy(p_vend, p_ca_infos, ca_count);
- }
-
- OSM_LOG_EXIT(p_vend->p_log);
- return (status);
-}
-
-/**********************************************************************
- * Given the vendor obj and a port guid
- * return the ca id and port number that have that guid
- **********************************************************************/
-
-ib_api_status_t
-osm_vendor_get_guid_ca_and_port(IN osm_vendor_t * const p_vend,
- IN ib_net64_t const guid,
- OUT uint32_t * p_hca_hndl,
- OUT char *p_hca_id,
- OUT uint8_t * p_hca_idx,
- OUT uint32_t * p_port_num)
-{
- uint32_t caIdx;
- uint32_t ca_count = 0;
- uint8_t port_num;
- ib_api_status_t status = IB_ERROR;
-
- OSM_LOG_ENTER(p_vend->p_log);
-
- CL_ASSERT(p_vend);
-
- /* determine the number of CA's */
- ca_count = __hca_pfs_get_num_cas();
- if (!ca_count) {
- osm_log(p_vend->p_log, OSM_LOG_ERROR,
- "osm_vendor_get_guid_ca_and_port: ERR 5231: "
- "Fail to get Any CA Ids.\n");
- goto Exit;
- }
-
- /*
- * For each CA, retrieve the CA info attributes
- */
- for (caIdx = 1; caIdx <= ca_count; caIdx++) {
- pfs_ca_info_t pfs_ca_info;
- if (__parse_ca_info_file(p_vend, caIdx, &pfs_ca_info) ==
- IB_SUCCESS) {
- /* get all the ports info */
- for (port_num = 1; port_num <= pfs_ca_info.num_ports;
- port_num++) {
- uint64_t port_guid;
- if (!__get_port_guid_from_port_gid_tbl
- (p_vend, caIdx, port_num, &port_guid)) {
- if (cl_hton64(port_guid) == guid) {
- osm_log(p_vend->p_log,
- OSM_LOG_DEBUG,
- "osm_vendor_get_guid_ca_and_port: "
- "Found Matching guid on HCA:%d Port:%d.\n",
- caIdx, port_num);
- strcpy(p_hca_id,
- pfs_ca_info.name);
- *p_port_num = port_num;
- *p_hca_idx = caIdx - 1;
- *p_hca_hndl = 0;
- status = IB_SUCCESS;
- goto Exit;
- }
- }
- }
- }
- }
-
- osm_log(p_vend->p_log, OSM_LOG_ERROR,
- "osm_vendor_get_guid_ca_and_port: ERR 5232: "
- "Fail to find HCA and Port for Port Guid 0x%" PRIx64 "\n",
- cl_ntoh64(guid));
- status = IB_INVALID_GUID;
-
-Exit:
-
- OSM_LOG_EXIT(p_vend->p_log);
- return (status);
-}
-
-#endif
diff --git a/contrib/ofed/management/opensm/libvendor/osm_vendor_mlx_hca_sim.c b/contrib/ofed/management/opensm/libvendor/osm_vendor_mlx_hca_sim.c
deleted file mode 100644
index b6c0193..0000000
--- a/contrib/ofed/management/opensm/libvendor/osm_vendor_mlx_hca_sim.c
+++ /dev/null
@@ -1,864 +0,0 @@
-/*
- * Copyright (c) 2004-2006 Voltaire, Inc. All rights reserved.
- * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved.
- * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- */
-
-#if HAVE_CONFIG_H
-# include <config.h>
-#endif /* HAVE_CONFIG_H */
-
-#if defined(OSM_VENDOR_INTF_SIM)
-#undef IN
-#undef OUT
-
-#include <unistd.h>
-#include <vendor/osm_vendor_api.h>
-#include <opensm/osm_log.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include <sys/types.h>
-#include <dirent.h>
-#include <stdlib.h>
-#include <sys/stat.h>
-#include <stdint.h>
-#include <fcntl.h>
-
-/******************************************************************************
-*
-* Provides the functionality for selecting an HCA Port and Obtaining it's guid.
-* This version is based on $IBMGTSIM_DIR/$IBMGTSIM_NODE file system.
-* This is a mimic of the OpenIB gen1 file system
-*
-******************************************************************************/
-
-char *__get_simulator_dir(void)
-{
- static char *ibmgtSimDir = NULL;
- static char *defaultIbmgtSimDir = "/tmp/ibmgtsim";
- static char *ibmgtSimNode = NULL;
- static char dirName[1024];
-
- /* we use the first pointer to know if we were here */
- if (ibmgtSimDir == NULL) {
- /* obtain the simulator directory */
- ibmgtSimDir = getenv("IBMGTSIM_DIR");
- if (ibmgtSimDir == NULL) {
- printf
- ("-W- Environment variable: IBMGTSIM_DIR does not exist.\n");
- printf
- (" Please create one used by the simulator.\n");
- printf(" Using /tmp/ibmgtsim as default.\n");
- ibmgtSimDir = defaultIbmgtSimDir;
- }
-
- /* obtain the node name we simulate */
- ibmgtSimNode = getenv("IBMGTSIM_NODE");
- if (ibmgtSimNode == NULL) {
- printf
- ("-W- Environment variable: IBMGTSIM_NODE does not exist.\n");
- printf
- (" This variable should be the name of the node you wish to simulate.\n");
- printf(" Using H-1 as default.\n");
- ibmgtSimNode = "H-1";
- }
- sprintf(dirName, "%s/%s", ibmgtSimDir, ibmgtSimNode);
- }
-
- return dirName;
-}
-
-typedef struct _osm_ca_info {
- ib_net64_t guid;
- size_t attr_size;
- ib_ca_attr_t *p_attr;
-
-} osm_ca_info_t;
-
-/**********************************************************************
- * Returns a pointer to the port attribute of the specified port
- * owned by this CA.
- ************************************************************************/
-static ib_port_attr_t *__osm_ca_info_get_port_attr_ptr(IN const osm_ca_info_t *
- const p_ca_info,
- IN const uint8_t index)
-{
- return (&p_ca_info->p_attr->p_port_attr[index]);
-}
-
-/**********************************************************************
- * Obtain the number of local CAs by scanning /proc/infiniband/core
- **********************************************************************/
-int __hca_sim_get_num_cas(void)
-{
- int num_cas = 0;
- DIR *dp;
- struct dirent *ep;
-
- dp = opendir(__get_simulator_dir());
-
- if (dp != NULL) {
- while ((ep = readdir(dp))) {
- /* CAs are directories with the format ca[1-9][0-9]* */
- /* if ((ep->d_type == DT_DIR) && !strncmp(ep->d_name, "ca", 2)) */
- if (!strncmp(ep->d_name, "ca", 2)) {
- num_cas++;
- }
- }
- closedir(dp);
- } else {
- printf("__hca_sim_get_num_cas: ERROR : ail to open dir %s\n",
- __get_simulator_dir());
- exit(1);
- }
-
- if (!num_cas)
- exit(1);
- return num_cas;
-}
-
-/*
- name: InfiniHost0
- provider: tavor
- node GUID: 0002:c900:0120:3470
- ports: 2
- vendor ID: 0x2c9
- device ID: 0x5a44
- HW revision: 0xa1
- FW revision: 0x300020080
-*/
-typedef struct _sim_ca_info {
- char name[32];
- char provider[32];
- uint64_t guid;
- uint8_t num_ports;
- uint32_t vend_id;
- uint16_t dev_id;
- uint16_t rev_id;
- uint64_t fw_rev;
-} sim_ca_info_t;
-
-/**********************************************************************
- * Parse the CA Info file available in ibmgtSimDir/caN/info
- **********************************************************************/
-static ib_api_status_t
-__parse_ca_info_file(IN osm_vendor_t * const p_vend,
- IN uint32_t idx, OUT sim_ca_info_t * sim_ca_info)
-{
- ib_api_status_t status = IB_ERROR;
- int info_file;
- char file_name[256];
- char file_buffer[3200];
- char *p_ch;
- int g1, g2, g3, g4;
- int num_ports;
- uint32_t len;
-
- OSM_LOG_ENTER(p_vend->p_log);
-
- osm_log(p_vend->p_log, OSM_LOG_DEBUG,
- "__parse_ca_info_file: " "Querying CA %d.\n", idx);
-
- /* we use the proc file system so we must be able to open the info file .. */
- sprintf(file_name, "%s/ca%d/info", __get_simulator_dir(), idx);
- info_file = open(file_name, O_RDONLY);
- if (!info_file) {
- osm_log(p_vend->p_log, OSM_LOG_ERROR,
- "__parse_ca_info_file: ERR 5105: "
- "Fail to open HCA:%d info file:(%s).\n", idx,
- file_name);
- goto Exit;
- }
-
- /* read in the file */
- len = read(info_file, file_buffer, 3200);
- close(info_file);
- file_buffer[len] = '\0';
-
- /*
- parse the file ...
- name: InfiniHost0
- provider: tavor
- node GUID: 0002:c900:0120:3470
- ports: 2
- vendor ID: 0x2c9
- device ID: 0x5a44
- HW revision: 0xa1
- FW revision: 0x300020080
- */
- if (!(p_ch = strstr(file_buffer, "name:"))) {
- osm_log(p_vend->p_log, OSM_LOG_ERROR,
- "__parse_ca_info_file: ERR 5106: "
- "Fail to obtain HCA name. In info file:(%s).\n",
- file_buffer);
- goto Exit;
- }
- if (sscanf(p_ch, "name: %s", sim_ca_info->name) != 1) {
- osm_log(p_vend->p_log, OSM_LOG_ERROR,
- "__parse_ca_info_file: ERR 5107: "
- "Fail to parse name in info file:(%s).\n", p_ch);
- goto Exit;
- }
-
- /* get the guid of the HCA */
- if (!(p_ch = strstr(file_buffer, "node GUID:"))) {
- osm_log(p_vend->p_log, OSM_LOG_ERROR,
- "__parse_ca_info_file: ERR 5108: "
- "Fail to obtain GUID in info file:(%s).\n",
- file_buffer);
- goto Exit;
- }
- if (sscanf(p_ch, "node GUID: %x:%x:%x:%x", &g1, &g2, &g3, &g4) != 4) {
- osm_log(p_vend->p_log, OSM_LOG_ERROR,
- "__parse_ca_info_file: ERR 5109: "
- "Fail to parse GUID in info file:(%s).\n", p_ch);
- goto Exit;
- }
- sim_ca_info->guid = (uint64_t) g1 << 48 | (uint64_t) g1 << 32
- | (uint64_t) g1 << 16 | (uint64_t) g3;
-
- /* obtain number of ports */
- if (!(p_ch = strstr(file_buffer, "ports:"))) {
- osm_log(p_vend->p_log, OSM_LOG_ERROR,
- "__parse_ca_info_file: ERR 5110: "
- "Fail to obtain number of ports in info file:(%s).\n",
- file_buffer);
- goto Exit;
- }
- if (sscanf(p_ch, "ports: %d", &num_ports) != 1) {
- osm_log(p_vend->p_log, OSM_LOG_ERROR,
- "__parse_ca_info_file: ERR 5111: "
- "Fail to parse num ports in info file:(%s).\n", p_ch);
- goto Exit;
- }
- sim_ca_info->num_ports = num_ports;
-
- osm_log(p_vend->p_log, OSM_LOG_DEBUG,
- "__parse_ca_info_file: "
- "CA1 = name:%s guid:0x%016llx ports:%d\n",
- sim_ca_info->name, sim_ca_info->guid, sim_ca_info->num_ports);
-
- status = IB_SUCCESS;
-Exit:
- OSM_LOG_EXIT(p_vend->p_log);
- return status;
-}
-
-/*
- state: ACTIVE
- LID: 0x0001
- LMC: 0x0000
- SM LID: 0x0001
- SM SL: 0x0000
- Capabilities: IsSM
- IsTrapSupported
- IsAutomaticMigrationSupported
- IsSLMappingSupported
- IsLEDInfoSupported
- IsSystemImageGUIDSupported
- IsVendorClassSupported
- IsCapabilityMaskNoticeSupported
-*/
-typedef struct _sim_port_info {
- uint8_t state;
- uint16_t lid;
- uint8_t lmc;
- uint16_t sm_lid;
- uint8_t sm_sl;
-} sim_port_info_t;
-
-/**********************************************************************
- * Parse the Port Info file available in ibmgtSimDir/caN/portM/info
- * Port num is 1..N
- **********************************************************************/
-static ib_api_status_t
-__parse_port_info_file(IN osm_vendor_t * const p_vend,
- IN uint32_t hca_idx,
- IN uint8_t port_num, OUT sim_port_info_t * sim_port_info)
-{
- ib_api_status_t status = IB_ERROR;
- int info_file;
- char file_name[256];
- char file_buffer[3200];
- char state[12];
- char *p_ch;
- int lid, sm_lid, lmc, sm_sl;
- uint32_t len;
-
- OSM_LOG_ENTER(p_vend->p_log);
-
- osm_log(p_vend->p_log, OSM_LOG_DEBUG,
- "__parse_port_info_file: "
- "Parsing Proc File System Port Info CA %d Port %d.\n", hca_idx,
- port_num);
-
- /* we use the proc file system so we must be able to open the info file .. */
- sprintf(file_name, "%s/ca%d/port%d/info", __get_simulator_dir(),
- hca_idx, port_num);
- info_file = open(file_name, O_RDONLY);
- if (!info_file) {
- osm_log(p_vend->p_log, OSM_LOG_ERROR,
- "__parse_port_info_file: ERR 5112: "
- "Fail to open HCA:%d Port:%d info file:(%s).\n",
- hca_idx, port_num, file_name);
- goto Exit;
- }
-
- /* read in the file */
- len = read(info_file, file_buffer, 3200);
- close(info_file);
- file_buffer[len] = '\0';
-
- /*
- parse the file ...
- state: ACTIVE
- LID: 0x0001
- LMC: 0x0000
- SM LID: 0x0001
- SM SL: 0x0000
- ...
- */
- if (!(p_ch = strstr(file_buffer, "state:"))) {
- osm_log(p_vend->p_log, OSM_LOG_ERROR,
- "__parse_port_info_file: ERR 5113: "
- "Fail to obtain port state. In info file:(%s).\n",
- file_buffer);
- goto Exit;
- }
- if (sscanf(p_ch, "state: %s", state) != 1) {
- osm_log(p_vend->p_log, OSM_LOG_ERROR,
- "__parse_port_info_file: ERR 5114: "
- "Fail to parse state from info file:(%s).\n", p_ch);
- goto Exit;
- }
-
- if (!strcmp(state, "ACTIVE"))
- sim_port_info->state = IB_LINK_ACTIVE;
- else if (!strcmp(state, "DOWN"))
- sim_port_info->state = IB_LINK_DOWN;
- else if (!strcmp(state, "INIT"))
- sim_port_info->state = IB_LINK_INIT;
- else if (!strcmp(state, "ARMED"))
- sim_port_info->state = IB_LINK_ARMED;
- else
- sim_port_info->state = 0;
-
- /* get lid */
- if (!(p_ch = strstr(file_buffer, "LID:"))) {
- osm_log(p_vend->p_log, OSM_LOG_ERROR,
- "__parse_port_info_file: ERR 5115: "
- "Fail to obtain port lid. In info file:(%s).\n",
- file_buffer);
- goto Exit;
- }
- if (sscanf(p_ch, "LID: %x", &lid) != 1) {
- osm_log(p_vend->p_log, OSM_LOG_ERROR,
- "__parse_port_info_file: ERR 5116: "
- "Fail to parse lid from info file:(%s).\n", p_ch);
- goto Exit;
- }
- sim_port_info->lid = lid;
- /* get LMC */
- if (!(p_ch = strstr(file_buffer, "LMC:"))) {
- osm_log(p_vend->p_log, OSM_LOG_ERROR,
- "__parse_port_info_file: ERR 5117: "
- "Fail to obtain port LMC. In info file:(%s).\n",
- file_buffer);
- goto Exit;
- }
- if (sscanf(p_ch, "LMC: %x", &lmc) != 1) {
- osm_log(p_vend->p_log, OSM_LOG_ERROR,
- "__parse_port_info_file: ERR 5118: "
- "Fail to parse LMC from info file:(%s).\n", p_ch);
- goto Exit;
- }
- sim_port_info->lmc = lmc;
-
- /* get SM LID */
- if (!(p_ch = strstr(file_buffer, "SM LID:"))) {
- osm_log(p_vend->p_log, OSM_LOG_ERROR,
- "__parse_port_info_file: ERR 5119: "
- "Fail to obtain port SM LID. In info file:(%s).\n",
- file_buffer);
- goto Exit;
- }
- if (sscanf(p_ch, "SM LID: %x", &sm_lid) != 1) {
- osm_log(p_vend->p_log, OSM_LOG_ERROR,
- "__parse_port_info_file: ERR 5120: "
- "Fail to parse SM LID from info file:(%s).\n", p_ch);
- goto Exit;
- }
- sim_port_info->sm_lid = sm_lid;
-
- /* get SM LID */
- if (!(p_ch = strstr(file_buffer, "SM SL:"))) {
- osm_log(p_vend->p_log, OSM_LOG_ERROR,
- "__parse_port_info_file: ERR 5121: "
- "Fail to obtain port SM SL. In info file:(%s).\n",
- file_buffer);
- goto Exit;
- }
- if (sscanf(p_ch, "SM SL: %x", &sm_sl) != 1) {
- osm_log(p_vend->p_log, OSM_LOG_ERROR,
- "__parse_port_info_file: ERR 5122: "
- "Fail to parse SM SL from info file:(%s).\n", p_ch);
- goto Exit;
- }
- sim_port_info->sm_sl = sm_sl;
- osm_log(p_vend->p_log, OSM_LOG_DEBUG,
- "__parse_port_info_file: "
- "Obtained Port:%d = state:%d, lid:0x%04X, lmc:%d, sm_lid:0x%04X, sm_sl:%d\n",
- port_num, sim_port_info->state, sim_port_info->lid,
- sim_port_info->lmc, sim_port_info->sm_lid,
- sim_port_info->sm_sl);
-
- status = IB_SUCCESS;
-Exit:
- OSM_LOG_EXIT(p_vend->p_log);
- return status;
-}
-
-/**********************************************************************
- * Parse the port guid_tbl file to obtain the port guid.
- * File format is:
- * [ 0] fe80:0000:0000:0000:0002:c900:0120:3472
- **********************************************************************/
-static ib_api_status_t
-__get_port_guid_from_port_gid_tbl(IN osm_vendor_t * const p_vend,
- IN uint32_t hca_idx,
- IN uint8_t port_num, OUT uint64_t * port_guid)
-{
- ib_api_status_t status = IB_ERROR;
- int info_file;
- char file_name[256];
- char file_buffer[3200];
- char *p_ch;
- int g[8];
- uint32_t len;
-
- OSM_LOG_ENTER(p_vend->p_log);
-
- osm_log(p_vend->p_log, OSM_LOG_DEBUG,
- "__get_port_guid_from_port_gid_tbl: "
- "Parsing Proc File System Port Guid Table CA %d Port %d.\n",
- hca_idx, port_num);
-
- /* we use the proc file system so we must be able to open the info file .. */
- sprintf(file_name, "%s/ca%d/port%d/gid_table",
- __get_simulator_dir(), hca_idx, port_num);
- info_file = open(file_name, O_RDONLY);
- if (!info_file) {
- osm_log(p_vend->p_log, OSM_LOG_ERROR,
- "__get_port_guid_from_port_gid_tbl: ERR 5123: "
- "Fail to open HCA:%d Port:%d gid_table file:(%s).\n",
- hca_idx, port_num, file_name);
- goto Exit;
- }
-
- /* read in the file */
- len = read(info_file, file_buffer, 3200);
- close(info_file);
- file_buffer[len] = '\0';
-
- /*
- parse the file ...
- [ 0] fe80:0000:0000:0000:0002:c900:0120:3472
- ...
- */
- if (!(p_ch = strstr(file_buffer, "[ 0]"))) {
- osm_log(p_vend->p_log, OSM_LOG_ERROR,
- "__get_port_guid_from_port_gid_tbl: ERR 5124: "
- "Fail to obtain first gid index. In gid_table file:(%s).\n",
- file_buffer);
- goto Exit;
- }
- if (sscanf(p_ch + 6, "%x:%x:%x:%x:%x:%x:%x:%x",
- &g[7], &g[6], &g[5], &g[4], &g[3], &g[2], &g[1], &g[0]) != 8)
- {
- osm_log(p_vend->p_log, OSM_LOG_ERROR,
- "__get_port_guid_from_port_gid_tbl: ERR 5125: "
- "Fail to parse gid from gid_table file:(%s).\n", p_ch);
- goto Exit;
- }
-
- *port_guid =
- (uint64_t) g[3] << 48 | (uint64_t) g[2] << 32 | (uint64_t) g[1] <<
- 16 | g[0];
- status = IB_SUCCESS;
-Exit:
- OSM_LOG_EXIT(p_vend->p_log);
- return status;
-}
-
-/**********************************************************************
- * Initialize an Info Struct for the Given HCA by its index 1..N
- **********************************************************************/
-static ib_api_status_t
-__osm_ca_info_init(IN osm_vendor_t * const p_vend,
- IN uint32_t const idx, OUT osm_ca_info_t * const p_ca_info)
-{
- ib_api_status_t status = IB_ERROR;
- uint8_t port_num;
- uint64_t port_guid;
-
- sim_ca_info_t sim_ca_info;
-
- OSM_LOG_ENTER(p_vend->p_log);
-
- /* parse the CA info file */
- if (__parse_ca_info_file(p_vend, idx, &sim_ca_info) != IB_SUCCESS)
- goto Exit;
-
- p_ca_info->guid = cl_hton64(sim_ca_info.guid);
-
- /* set size of attributes and allocate them */
- p_ca_info->attr_size = 1;
- p_ca_info->p_attr = (ib_ca_attr_t *) malloc(sizeof(ib_ca_attr_t));
-
- p_ca_info->p_attr->ca_guid = p_ca_info->guid;
- p_ca_info->p_attr->num_ports = sim_ca_info.num_ports;
-
- /* now obtain the attributes of the ports */
- p_ca_info->p_attr->p_port_attr =
- (ib_port_attr_t *) malloc(sim_ca_info.num_ports *
- sizeof(ib_port_attr_t));
-
- /* get all the ports info */
- for (port_num = 1; port_num <= sim_ca_info.num_ports; port_num++) {
- sim_port_info_t sim_port_info;
- /* query the port attributes */
- if (__parse_port_info_file
- (p_vend, idx, port_num, &sim_port_info)) {
- osm_log(p_vend->p_log, OSM_LOG_ERROR,
- "__osm_ca_info_init: ERR 5126: "
- "Fail to get HCA:%d Port:%d Attributes.\n", idx,
- port_num);
- goto Exit;
- }
-
- /* HACK: the lids should have been converted to network but the rest of the code
- is wrong and provdes them as is (host order) - so we stick with it. */
- p_ca_info->p_attr->p_port_attr[port_num - 1].lid =
- sim_port_info.lid;
- p_ca_info->p_attr->p_port_attr[port_num - 1].link_state =
- sim_port_info.state;
- p_ca_info->p_attr->p_port_attr[port_num - 1].sm_lid =
- sim_port_info.sm_lid;
-
- /* get the port guid */
- if (__get_port_guid_from_port_gid_tbl
- (p_vend, idx, port_num, &port_guid)) {
- osm_log(p_vend->p_log, OSM_LOG_ERROR,
- "__osm_ca_info_init: ERR 5127: "
- "Fail to get HCA:%d Port:%d Guid.\n", idx,
- port_num);
- goto Exit;
- }
- p_ca_info->p_attr->p_port_attr[port_num - 1].port_guid =
- cl_hton64(port_guid);
- }
-
- status = IB_SUCCESS;
-Exit:
- OSM_LOG_EXIT(p_vend->p_log);
- return (status);
-}
-
-/**********************************************************************
- **********************************************************************/
-void
-osm_ca_info_destroy(IN osm_vendor_t * const p_vend,
- IN osm_ca_info_t * const p_ca_info, IN uint8_t num_ca)
-{
- osm_ca_info_t *p_ca;
- uint8_t i;
-
- OSM_LOG_ENTER(p_vend->p_log);
-
- for (i = 0; i < num_ca; i++) {
- p_ca = &p_ca_info[i];
-
- if (NULL != p_ca->p_attr) {
- if (0 != p_ca->p_attr->num_ports) {
- free(p_ca->p_attr->p_port_attr);
- }
-
- free(p_ca->p_attr);
- }
- }
-
- free(p_ca_info);
-
- OSM_LOG_EXIT(p_vend->p_log);
-}
-
-/**********************************************************************
- * Fill in the array of port_attr with all available ports on ALL the
- * avilable CAs on this machine.
- **********************************************************************/
-ib_api_status_t
-osm_vendor_get_all_port_attr(IN osm_vendor_t * const p_vend,
- IN ib_port_attr_t * const p_attr_array,
- IN uint32_t * const p_num_ports)
-{
- ib_api_status_t status = IB_SUCCESS;
-
- uint32_t caIdx;
- uint32_t ca_count = 0;
- uint32_t port_count = 0;
- uint8_t port_num;
- uint32_t total_ports = 0;
- osm_ca_info_t *p_ca_infos = NULL;
- uint32_t attr_array_sz = *p_num_ports;
-
- OSM_LOG_ENTER(p_vend->p_log);
-
- CL_ASSERT(p_vend);
-
- /* determine the number of CA's */
- ca_count = __hca_sim_get_num_cas();
- if (!ca_count) {
- osm_log(p_vend->p_log, OSM_LOG_ERROR,
- "osm_vendor_get_all_port_attr: ERR 5128: "
- "Fail to get Any CA Ids.\n");
- goto Exit;
- }
-
- /* Allocate an array big enough to hold the ca info objects */
- p_ca_infos = malloc(ca_count * sizeof(osm_ca_info_t));
- if (p_ca_infos == NULL) {
- osm_log(p_vend->p_log, OSM_LOG_ERROR,
- "osm_vendor_get_all_port_attr: ERR 5129: "
- "Unable to allocate CA information array.\n");
- goto Exit;
- }
-
- memset(p_ca_infos, 0, ca_count * sizeof(osm_ca_info_t));
-
- /*
- * For each CA, retrieve the CA info attributes
- */
- for (caIdx = 1; caIdx <= ca_count; caIdx++) {
- status =
- __osm_ca_info_init(p_vend, caIdx, &p_ca_infos[caIdx - 1]);
- if (status != IB_SUCCESS) {
- osm_log(p_vend->p_log, OSM_LOG_ERROR,
- "osm_vendor_get_all_port_attr: ERR 5130: "
- "Unable to initialize CA Info object (%s).\n",
- ib_get_err_str(status));
- goto Exit;
- }
- total_ports += p_ca_infos[caIdx - 1].p_attr->num_ports;
- }
-
- *p_num_ports = total_ports;
- osm_log(p_vend->p_log, OSM_LOG_DEBUG,
- "osm_vendor_get_all_port_attr: total ports:%u \n", total_ports);
-
- /*
- * If the user supplied enough storage, return the port guids,
- * otherwise, return the appropriate error.
- */
- if (attr_array_sz >= total_ports) {
- for (caIdx = 1; caIdx <= ca_count; caIdx++) {
- uint32_t num_ports;
-
- num_ports = p_ca_infos[caIdx - 1].p_attr->num_ports;
-
- for (port_num = 0; port_num < num_ports; port_num++) {
- p_attr_array[port_count] =
- *__osm_ca_info_get_port_attr_ptr(&p_ca_infos
- [caIdx -
- 1],
- port_num);
- port_count++;
- }
- }
- } else {
- status = IB_INSUFFICIENT_MEMORY;
- goto Exit;
- }
-
- status = IB_SUCCESS;
-
-Exit:
- if (p_ca_infos) {
- osm_ca_info_destroy(p_vend, p_ca_infos, ca_count);
- }
-
- OSM_LOG_EXIT(p_vend->p_log);
- return (status);
-}
-
-/**********************************************************************
- * Given the vendor obj and a port guid
- * return the ca id and port number that have that guid
- **********************************************************************/
-
-ib_api_status_t
-osm_vendor_get_guid_ca_and_port(IN osm_vendor_t * const p_vend,
- IN ib_net64_t const guid,
- OUT uint32_t * p_hca_hndl,
- OUT char *p_hca_id,
- OUT uint8_t * p_hca_idx,
- OUT uint32_t * p_port_num)
-{
- uint32_t caIdx;
- uint32_t ca_count = 0;
- uint8_t port_num;
- ib_api_status_t status = IB_ERROR;
-
- OSM_LOG_ENTER(p_vend->p_log);
-
- CL_ASSERT(p_vend);
-
- /* determine the number of CA's */
- ca_count = __hca_sim_get_num_cas();
- if (!ca_count) {
- osm_log(p_vend->p_log, OSM_LOG_ERROR,
- "osm_vendor_get_guid_ca_and_port: ERR 5131: "
- "Fail to get Any CA Ids.\n");
- goto Exit;
- }
-
- /*
- * For each CA, retrieve the CA info attributes
- */
- for (caIdx = 1; caIdx <= ca_count; caIdx++) {
- sim_ca_info_t sim_ca_info;
- if (__parse_ca_info_file(p_vend, caIdx, &sim_ca_info) ==
- IB_SUCCESS) {
- /* get all the ports info */
- for (port_num = 1; port_num <= sim_ca_info.num_ports;
- port_num++) {
- uint64_t port_guid;
- if (!__get_port_guid_from_port_gid_tbl
- (p_vend, caIdx, port_num, &port_guid)) {
- if (cl_hton64(port_guid) == guid) {
- osm_log(p_vend->p_log,
- OSM_LOG_DEBUG,
- "osm_vendor_get_guid_ca_and_port: "
- "Found Matching guid on HCA:%d Port:%d.\n",
- caIdx, port_num);
- strcpy(p_hca_id,
- sim_ca_info.name);
- *p_port_num = port_num;
- *p_hca_idx = caIdx - 1;
- *p_hca_hndl = 0;
- status = IB_SUCCESS;
- goto Exit;
- }
- }
- }
- }
- }
-
- osm_log(p_vend->p_log, OSM_LOG_ERROR,
- "osm_vendor_get_guid_ca_and_port: ERR 5132: "
- "Fail to find HCA and Port for Port Guid 0x%" PRIx64 "\n",
- cl_ntoh64(guid));
- status = IB_INVALID_GUID;
-
-Exit:
-
- OSM_LOG_EXIT(p_vend->p_log);
- return (status);
-}
-
-/**********************************************************************
- * Given the vendor obj HCA ID and Port Num
- * update the given port guid if found. Return 0 on success.
- **********************************************************************/
-
-ib_api_status_t
-osm_vendor_get_guid_by_ca_and_port(IN osm_vendor_t * const p_vend,
- IN char *hca_id,
- IN uint32_t port_num,
- OUT uint64_t * p_port_guid)
-{
- uint32_t caIdx;
- uint32_t ca_count = 0;
- ib_api_status_t status = IB_ERROR;
-
- OSM_LOG_ENTER(p_vend->p_log);
-
- CL_ASSERT(p_vend);
-
- /* determine the number of CA's */
- ca_count = __hca_sim_get_num_cas();
- if (!ca_count) {
- osm_log(p_vend->p_log, OSM_LOG_ERROR,
- "osm_vendor_get_guid_by_ca_and_port: ERR 5133: "
- "Fail to get Any CA Ids.\n");
- goto Exit;
- }
-
- /*
- * For each CA, retrieve the CA info attributes
- */
- for (caIdx = 1; caIdx <= ca_count; caIdx++) {
- sim_ca_info_t sim_ca_info;
- if (__parse_ca_info_file(p_vend, caIdx, &sim_ca_info) ==
- IB_SUCCESS) {
- /* if not identical by id - go to next one */
- if (strcmp(sim_ca_info.name, hca_id))
- continue;
-
- if ((port_num < 1)
- || (port_num > sim_ca_info.num_ports)) {
- return 1;
- }
-
- if (!__get_port_guid_from_port_gid_tbl
- (p_vend, caIdx, port_num, p_port_guid)) {
- osm_log(p_vend->p_log, OSM_LOG_DEBUG,
- "osm_vendor_get_guid_by_ca_and_port: "
- "Found Matching guid on HCA:%d Port:%d.\n",
- caIdx, port_num);
- status = IB_SUCCESS;
- goto Exit;
- }
- }
- }
-
- osm_log(p_vend->p_log, OSM_LOG_ERROR,
- "osm_vendor_get_guid_by_ca_and_port: ERR 5134: "
- "Fail to find HCA:%s\n", hca_id);
- status = IB_INVALID_GUID;
-
-Exit:
-
- OSM_LOG_EXIT(p_vend->p_log);
- return (status);
-}
-
-#endif
diff --git a/contrib/ofed/management/opensm/libvendor/osm_vendor_mlx_rmpp_ctx.c b/contrib/ofed/management/opensm/libvendor/osm_vendor_mlx_rmpp_ctx.c
deleted file mode 100644
index bbd42c3..0000000
--- a/contrib/ofed/management/opensm/libvendor/osm_vendor_mlx_rmpp_ctx.c
+++ /dev/null
@@ -1,361 +0,0 @@
-/*
- * Copyright (c) 2004-2006 Voltaire, Inc. All rights reserved.
- * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved.
- * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- */
-
-#if HAVE_CONFIG_H
-# include <config.h>
-#endif /* HAVE_CONFIG_H */
-
-#include <stdlib.h>
-#include <string.h>
-#include <iba/ib_types.h>
-#include <complib/cl_qlist.h>
-
-#include <vendor/osm_vendor_mlx_rmpp_ctx.h>
-#include <vendor/osm_vendor_mlx_svc.h>
-
-ib_api_status_t
-osmv_rmpp_send_ctx_init(osmv_rmpp_send_ctx_t * p_ctx, void *p_arbt_mad,
- uint32_t mad_sz, osm_log_t * p_log)
-{
- ib_api_status_t st = IB_SUCCESS;
- cl_status_t cl_st;
-
- CL_ASSERT(p_ctx);
- if (NULL == p_arbt_mad) {
- return IB_INVALID_PARAMETER;
- }
-
- if (osmv_mad_is_sa((ib_mad_t *) p_arbt_mad)) {
- p_ctx->is_sa_mad = TRUE;
- } else
- p_ctx->is_sa_mad = FALSE;
-
- p_ctx->mad_sz = mad_sz;
-
- cl_event_construct(&p_ctx->event);
- cl_st = cl_event_init(&p_ctx->event, FALSE);
- if (cl_st != CL_SUCCESS) {
- return IB_ERROR;
- }
-
- st = osmv_rmpp_sar_init(&p_ctx->sar, p_arbt_mad, p_ctx->mad_sz,
- p_ctx->is_sa_mad);
- if (st == IB_SUCCESS) {
- p_ctx->window_first = 1;
- p_ctx->window_last = 1;
- }
-
- p_ctx->p_log = p_log;
- return st;
-}
-
-void osmv_rmpp_send_ctx_done(IN osmv_rmpp_send_ctx_t * p_ctx)
-{
- CL_ASSERT(p_ctx);
- cl_event_destroy(&p_ctx->event);
- osmv_rmpp_sar_done(&p_ctx->sar);
- free(p_ctx);
-}
-
-uint32_t osmv_rmpp_send_ctx_get_num_segs(IN osmv_rmpp_send_ctx_t * p_send_ctx)
-{
- uint32_t data_len, data_sz, num;
-
- CL_ASSERT(p_send_ctx);
-
- if (p_send_ctx->is_sa_mad) {
- data_len = p_send_ctx->mad_sz - IB_SA_MAD_HDR_SIZE;
- data_sz = IB_SA_DATA_SIZE;
- } else {
- data_len = p_send_ctx->mad_sz - MAD_RMPP_HDR_SIZE;
- data_sz = MAD_RMPP_DATA_SIZE;
- }
-
- num = data_len / data_sz;
- if (0 == data_len || (data_len % data_sz) > 0) {
- num++;
- }
-
- return num;
-}
-
-ib_api_status_t
-osmv_rmpp_send_ctx_get_seg(IN osmv_rmpp_send_ctx_t * p_send_ctx,
- IN uint32_t seg_idx,
- IN uint32_t resp_timeout, OUT void *p_buf)
-{
- ib_api_status_t st = IB_SUCCESS;
- uint32_t num_segs, paylen = 0;
- ib_rmpp_mad_t *p_rmpp_mad;
-
- OSM_LOG_ENTER(p_send_ctx->p_log);
- CL_ASSERT(p_send_ctx);
-
- st = osmv_rmpp_sar_get_mad_seg(&p_send_ctx->sar, seg_idx, p_buf);
- if (st != IB_SUCCESS) {
- goto Exit;
- }
-
- p_rmpp_mad = (ib_rmpp_mad_t *) p_buf;
- /* Set the relevant bits in the RMPP hdr */
- p_rmpp_mad->rmpp_status = IB_RMPP_STATUS_SUCCESS;
- p_rmpp_mad->rmpp_flags |= IB_RMPP_FLAG_ACTIVE;
- p_rmpp_mad->rmpp_flags |= resp_timeout << 3;
-
- num_segs = osmv_rmpp_send_ctx_get_num_segs(p_send_ctx);
-
- if (1 == seg_idx) {
- p_rmpp_mad->rmpp_flags |= IB_RMPP_FLAG_FIRST;
-
- /* This is the first segment -
- the reported paylen is the total amount of data.
- */
- if (p_send_ctx->is_sa_mad) {
- /* sa mad hdr sz */
- paylen = p_send_ctx->mad_sz - IB_SA_MAD_HDR_SIZE;
- paylen +=
- num_segs * (IB_SA_MAD_HDR_SIZE - MAD_RMPP_HDR_SIZE);
- } else {
- /* mad hdr sz */
- paylen = p_send_ctx->mad_sz - MAD_RMPP_HDR_SIZE;
- }
- }
-
- if (seg_idx == num_segs) {
- p_rmpp_mad->rmpp_flags |= IB_RMPP_FLAG_LAST;
-
- /*
- This is the last segment -
- the reported paylen is only the amount of data left on this segment.
- */
- if (p_send_ctx->is_sa_mad) {
- paylen = p_send_ctx->mad_sz - IB_SA_MAD_HDR_SIZE;
- paylen -= (num_segs - 1) * IB_SA_DATA_SIZE;
- paylen += (IB_SA_MAD_HDR_SIZE - MAD_RMPP_HDR_SIZE);
- } else {
- paylen = p_send_ctx->mad_sz - MAD_RMPP_HDR_SIZE;
- paylen -=
- (num_segs - 1) * (MAD_BLOCK_SIZE -
- MAD_RMPP_HDR_SIZE);
- }
- }
-
- p_rmpp_mad->rmpp_type = IB_RMPP_TYPE_DATA;
- p_rmpp_mad->rmpp_version = 1;
- p_rmpp_mad->paylen_newwin = cl_ntoh32(paylen);
- p_rmpp_mad->seg_num = cl_ntoh32(seg_idx);
-
-Exit:
- OSM_LOG_EXIT(p_send_ctx->p_log);
- return st;
-}
-
-ib_api_status_t
-osmv_rmpp_recv_ctx_init(osmv_rmpp_recv_ctx_t * p_ctx, osm_log_t * p_log)
-{
- ib_api_status_t st = IB_SUCCESS;
-
- CL_ASSERT(p_ctx);
-
- p_ctx->is_sa_mad = FALSE;
-
- p_ctx->p_rbuf = malloc(sizeof(cl_qlist_t));
- if (p_ctx->p_rbuf) {
- memset(p_ctx->p_rbuf, 0, sizeof(cl_qlist_t));
- cl_qlist_init(p_ctx->p_rbuf);
- p_ctx->expected_seg = 1;
- } else
- st = IB_INSUFFICIENT_MEMORY;
-
- p_ctx->p_log = p_log;
-
- return st;
-}
-
-void osmv_rmpp_recv_ctx_done(IN osmv_rmpp_recv_ctx_t * p_ctx)
-{
- cl_list_item_t *p_list_item;
- cl_list_obj_t *p_obj;
-
- CL_ASSERT(p_ctx);
-
- /* go over all the items in the list and remove them */
- p_list_item = cl_qlist_remove_head(p_ctx->p_rbuf);
- while (p_list_item != cl_qlist_end(p_ctx->p_rbuf)) {
-
- p_obj = PARENT_STRUCT(p_list_item, cl_list_obj_t, list_item);
-
- free(cl_qlist_obj(p_obj));
- free(p_obj);
-
- p_list_item = cl_qlist_remove_head(p_ctx->p_rbuf);
- }
-
- osmv_rmpp_sar_done(&p_ctx->sar);
-
- free(p_ctx->p_rbuf);
- free(p_ctx);
-}
-
-ib_api_status_t
-osmv_rmpp_recv_ctx_store_mad_seg(IN osmv_rmpp_recv_ctx_t * p_recv_ctx,
- IN void *p_mad)
-{
- cl_list_obj_t *p_obj = NULL;
- void *p_list_mad;
-
- OSM_LOG_ENTER(p_recv_ctx->p_log);
-
- CL_ASSERT(p_recv_ctx);
- p_list_mad = malloc(MAD_BLOCK_SIZE);
- if (NULL == p_list_mad) {
- return IB_INSUFFICIENT_MEMORY;
- }
- memset(p_list_mad, 0, MAD_BLOCK_SIZE);
- memcpy(p_list_mad, p_mad, MAD_BLOCK_SIZE);
-
- p_obj = malloc(sizeof(cl_list_obj_t));
- if (NULL == p_obj) {
- free(p_list_mad);
- return IB_INSUFFICIENT_MEMORY;
- }
- memset(p_obj, 0, sizeof(cl_list_obj_t));
- cl_qlist_set_obj(p_obj, p_list_mad);
-
- cl_qlist_insert_tail(p_recv_ctx->p_rbuf, &p_obj->list_item);
-
- if (osmv_mad_is_sa((ib_mad_t *) p_mad)) {
- p_recv_ctx->is_sa_mad = TRUE;
- }
-
- return IB_SUCCESS;
-
-}
-
-uint32_t
-osmv_rmpp_recv_ctx_get_cur_byte_num(IN osmv_rmpp_recv_ctx_t * p_recv_ctx)
-{
- uint32_t num_segs;
-
- num_segs = cl_qlist_count(p_recv_ctx->p_rbuf);
- if (p_recv_ctx->is_sa_mad)
- return ((num_segs * IB_SA_DATA_SIZE) + IB_SA_MAD_HDR_SIZE);
- else
- return ((num_segs * MAD_RMPP_DATA_SIZE) + MAD_RMPP_HDR_SIZE);
-}
-
-uint32_t
-osmv_rmpp_recv_ctx_get_byte_num_from_first(IN osmv_rmpp_recv_ctx_t * p_recv_ctx)
-{
- cl_list_item_t *p_item;
- cl_list_obj_t *p_obj;
- void *p_list_mad;
- uint32_t num_bytes, num_segs;
-
- p_item = cl_qlist_head(p_recv_ctx->p_rbuf);
- p_obj = PARENT_STRUCT(p_item, cl_list_obj_t, list_item);
- p_list_mad = cl_qlist_obj(p_obj);
-
- /* mad data sz */
- num_bytes = cl_ntoh32(((ib_rmpp_mad_t *) p_list_mad)->paylen_newwin);
- if (0 != num_bytes) {
- if (p_recv_ctx->is_sa_mad) {
- /* sa mad hdr sz */
- num_segs = cl_qlist_count(p_recv_ctx->p_rbuf);
- num_bytes -=
- num_segs * (IB_SA_MAD_HDR_SIZE - MAD_RMPP_HDR_SIZE);
- num_bytes += IB_SA_MAD_HDR_SIZE;
- } else {
- /* mad hdr sz */
- num_bytes += MAD_RMPP_HDR_SIZE;
- }
- }
-
- return num_bytes;
-}
-
-uint32_t
-osmv_rmpp_recv_ctx_get_byte_num_from_last(IN osmv_rmpp_recv_ctx_t * p_recv_ctx)
-{
- cl_list_item_t *p_item;
- cl_list_obj_t *p_obj;
- void *p_list_mad;
- uint32_t num_bytes, num_segs;
-
- p_item = cl_qlist_tail(p_recv_ctx->p_rbuf);
- p_obj = PARENT_STRUCT(p_item, cl_list_obj_t, list_item);
- p_list_mad = cl_qlist_obj(p_obj);
-
- /* mad data sz */
- num_segs = cl_qlist_count(p_recv_ctx->p_rbuf);
- num_bytes = cl_ntoh32(((ib_rmpp_mad_t *) p_list_mad)->paylen_newwin);
-
- if (0 != num_bytes) {
- if (p_recv_ctx->is_sa_mad) {
- /* sa mad hdr sz */
- num_bytes += MAD_RMPP_HDR_SIZE;
- num_bytes += (num_segs - 1) * IB_SA_DATA_SIZE;
- } else {
- /* mad hdr sz */
- num_bytes += MAD_RMPP_HDR_SIZE;
- num_bytes += (num_segs - 1) * MAD_RMPP_DATA_SIZE;
- }
- }
-
- return num_bytes;
-}
-
-/* assuming that the last rmpp pkt arrived so that data member: total_bytes has the right value */
-ib_api_status_t
-osmv_rmpp_recv_ctx_reassemble_arbt_mad(IN osmv_rmpp_recv_ctx_t * p_recv_ctx,
- IN uint32_t size, IN void *p_arbt_mad)
-{
- ib_api_status_t st = IB_SUCCESS;
-
- CL_ASSERT(p_recv_ctx);
-
- st = osmv_rmpp_sar_init(&p_recv_ctx->sar, p_arbt_mad, size,
- p_recv_ctx->is_sa_mad);
- if (st != IB_SUCCESS) {
- return st;
- }
-
- st = osmv_rmpp_sar_reassemble_arbt_mad(&p_recv_ctx->sar,
- p_recv_ctx->p_rbuf);
-
- osmv_rmpp_sar_done(&p_recv_ctx->sar);
-
- return st;
-}
diff --git a/contrib/ofed/management/opensm/libvendor/osm_vendor_mlx_sa.c b/contrib/ofed/management/opensm/libvendor/osm_vendor_mlx_sa.c
deleted file mode 100644
index 0257f32..0000000
--- a/contrib/ofed/management/opensm/libvendor/osm_vendor_mlx_sa.c
+++ /dev/null
@@ -1,834 +0,0 @@
-/*
- * Copyright (c) 2004-2008 Voltaire, Inc. All rights reserved.
- * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved.
- * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- */
-
-#if HAVE_CONFIG_H
-# include <config.h>
-#endif /* HAVE_CONFIG_H */
-
-#include <stdlib.h>
-#include <string.h>
-#include <complib/cl_debug.h>
-#include <complib/cl_timer.h>
-#include <complib/cl_event.h>
-#include <vendor/osm_vendor_api.h>
-#include <vendor/osm_vendor_sa_api.h>
-
-/*****************************************************************************
- *****************************************************************************/
-
-/* this struct is the internal rep of the bind handle */
-typedef struct _osmv_sa_bind_info {
- osm_bind_handle_t h_bind;
- osm_log_t *p_log;
- osm_vendor_t *p_vendor;
- osm_mad_pool_t *p_mad_pool;
- uint64_t port_guid;
- cl_event_t sync_event;
- uint64_t last_lids_update_sec;
- uint16_t lid;
- uint16_t sm_lid;
-} osmv_sa_bind_info_t;
-
-/*****************************************************************************
- *****************************************************************************/
-
-/*
- Call back on new mad received:
-
- We basically only need to set the context of the query.
- Or report an error.
-
- A pointer to the actual context of the request (a copy of the oriignal
- request structure) is attached as the p_madw->context.ni_context.node_guid
-*/
-void
-__osmv_sa_mad_rcv_cb(IN osm_madw_t * p_madw,
- IN void *bind_context, IN osm_madw_t * p_req_madw)
-{
- osmv_sa_bind_info_t *p_bind = (osmv_sa_bind_info_t *) bind_context;
- osmv_query_req_t *p_query_req_copy = NULL;
- osmv_query_res_t query_res;
- ib_sa_mad_t *p_sa_mad;
- ib_net16_t mad_status;
-
- OSM_LOG_ENTER(p_bind->p_log);
-
- if (!p_req_madw) {
- osm_log(p_bind->p_log, OSM_LOG_DEBUG,
- "__osmv_sa_mad_rcv_cb: "
- "Ignoring a non-response mad\n");
- osm_mad_pool_put(p_bind->p_mad_pool, p_madw);
- goto Exit;
- }
-
- /* obtain the sent context */
- p_query_req_copy =
- (osmv_query_req_t *) (p_req_madw->context.arb_context.context1);
-
- /* provide the context of the original request in the result */
- query_res.query_context = p_query_req_copy->query_context;
-
- /* provide the resulting madw */
- query_res.p_result_madw = p_madw;
-
- /* update the req fields */
- p_sa_mad = (ib_sa_mad_t *) p_madw->p_mad;
-
- /* if we got a remote error track it in the status */
- mad_status = (ib_net16_t) (p_sa_mad->status & IB_SMP_STATUS_MASK);
- if (mad_status != IB_SUCCESS) {
- osm_log(p_bind->p_log, OSM_LOG_ERROR,
- "__osmv_sa_mad_rcv_cb: ERR 0501: "
- "Remote error:0x%04X .\n", mad_status);
- query_res.status = IB_REMOTE_ERROR;
- } else {
- query_res.status = IB_SUCCESS;
- }
-
- /* what if we have got back an empty mad ? */
- if (!p_madw->mad_size) {
- osm_log(p_bind->p_log, OSM_LOG_ERROR,
- "__osmv_sa_mad_rcv_cb: ERR 0502: "
- "Got an empty mad.\n");
- query_res.status = IB_ERROR;
- }
-
- if (IB_SUCCESS == mad_status) {
-
- /* if we are in not in a method response of an rmpp nature we must get only 1 */
- /* HACK: in the future we might need to be smarter for other methods... */
- if (p_sa_mad->method != IB_MAD_METHOD_GETTABLE_RESP) {
- query_res.result_cnt = 1;
- } else {
-#ifndef VENDOR_RMPP_SUPPORT
- if (mad_status != IB_SUCCESS)
- query_res.result_cnt = 0;
- else
- query_res.result_cnt = 1;
-#else
- /* we used the offset value to calculate the number of
- records in here */
- if (ib_get_attr_size(p_sa_mad->attr_offset) == 0) {
- query_res.result_cnt = 0;
- osm_log(p_bind->p_log, OSM_LOG_DEBUG,
- "__osmv_sa_mad_rcv_cb: Count = 0\n");
- }
- else {
- query_res.result_cnt = (uintn_t)
- ((p_madw->mad_size - IB_SA_MAD_HDR_SIZE) /
- ib_get_attr_size(p_sa_mad->attr_offset));
- osm_log(p_bind->p_log, OSM_LOG_DEBUG,
- "__osmv_sa_mad_rcv_cb: "
- "Count = %u = %zu / %u (%zu)\n",
- query_res.result_cnt,
- p_madw->mad_size - IB_SA_MAD_HDR_SIZE,
- ib_get_attr_size(p_sa_mad->attr_offset),
- (p_madw->mad_size - IB_SA_MAD_HDR_SIZE) %
- ib_get_attr_size(p_sa_mad->attr_offset));
- }
-#endif
- }
- }
-
- query_res.query_type = p_query_req_copy->query_type;
-
- p_query_req_copy->pfn_query_cb(&query_res);
-
- if ((p_query_req_copy->flags & OSM_SA_FLAGS_SYNC) == OSM_SA_FLAGS_SYNC)
- cl_event_signal(&p_bind->sync_event);
-
-Exit:
-
- /* free the copied query request if found */
- if (p_query_req_copy)
- free(p_query_req_copy);
-
- /* put back the request madw */
- if (p_req_madw)
- osm_mad_pool_put(p_bind->p_mad_pool, p_req_madw);
-
- OSM_LOG_EXIT(p_bind->p_log);
-}
-
-/*****************************************************************************
- ****************************************************************************/
-/*
- Send Error Callback:
-
- Only report the error and get rid of the mad wrapper
-*/
-void __osmv_sa_mad_err_cb(IN void *bind_context, IN osm_madw_t * p_madw)
-{
- osmv_sa_bind_info_t *p_bind = (osmv_sa_bind_info_t *) bind_context;
- osmv_query_req_t *p_query_req_copy = NULL;
- osmv_query_res_t query_res;
-
- OSM_LOG_ENTER(p_bind->p_log);
-
- /* Obtain the sent context etc */
- p_query_req_copy =
- (osmv_query_req_t *) (p_madw->context.arb_context.context1);
-
- /* provide the context of the original request in the result */
- query_res.query_context = p_query_req_copy->query_context;
-
- query_res.p_result_madw = p_madw;
-
- query_res.status = IB_TIMEOUT;
- query_res.result_cnt = 0;
- query_res.p_result_madw->status = IB_TIMEOUT;
- p_madw->status = IB_TIMEOUT;
- query_res.query_type = p_query_req_copy->query_type;
-
- p_query_req_copy->pfn_query_cb(&query_res);
-
- if ((p_query_req_copy->flags & OSM_SA_FLAGS_SYNC) == OSM_SA_FLAGS_SYNC)
- cl_event_signal(&p_bind->sync_event);
-
- if (p_query_req_copy)
- free(p_query_req_copy);
- OSM_LOG_EXIT(p_bind->p_log);
-}
-
-/*****************************************************************************
- This routine needs to be invoked on every send - since the SM LID and Local
- lid might change. To do that without any major perfoermance impact we cache
- the results and time they were obtained. Refresh only twice a minute.
- To avoid the need to use statics and risk a race - we require the refresh time
- to be stored in the context of the results. Also this coveres cases were
- we query for multiple guids.
- *****************************************************************************/
-ib_api_status_t
-__osmv_get_lid_and_sm_lid_by_port_guid(IN osm_vendor_t * const p_vend,
- IN ib_net64_t port_guid,
- IN OUT uint64_t * p_lids_update_time_sec,
- OUT uint16_t * lid,
- OUT uint16_t * sm_lid)
-{
-
- ib_api_status_t status;
- ib_port_attr_t *p_attr_array;
- uint32_t num_ports;
- uint32_t port_num;
-
- OSM_LOG_ENTER(p_vend->p_log);
-
- /* use prevous values if current time is close enough to previous query */
- if (cl_get_time_stamp_sec() <= *p_lids_update_time_sec + 30) {
- osm_log(p_vend->p_log, OSM_LOG_DEBUG,
- "__osmv_get_lid_and_sm_lid_by_port_guid: "
- "Using previously stored lid:0x%04x sm_lid:0x%04x\n",
- *lid, *sm_lid);
- status = IB_SUCCESS;
- goto Exit;
- }
-
- /* obtain the number of available ports */
- num_ports = 0;
- status = osm_vendor_get_all_port_attr(p_vend, NULL, &num_ports);
- if (status != IB_INSUFFICIENT_MEMORY) {
- osm_log(p_vend->p_log, OSM_LOG_ERROR,
- "__osmv_get_lid_and_sm_lid_by_port_guid: ERR 0503: "
- "expected to get the IB_INSUFFICIENT_MEMORY but got: %s\n",
- ib_get_err_str(status)
- );
- status = IB_ERROR;
- goto Exit;
- }
-
- osm_log(p_vend->p_log, OSM_LOG_DEBUG,
- "__osmv_get_lid_and_sm_lid_by_port_guid: "
- "Found total of %u ports. Looking for guid:0x%016" PRIx64 "\n",
- num_ports, cl_ntoh64(port_guid)
- );
-
- /* allocate the attributes */
- p_attr_array =
- (ib_port_attr_t *) malloc(sizeof(ib_port_attr_t) * num_ports);
-
- /* obtain the attributes */
- status = osm_vendor_get_all_port_attr(p_vend, p_attr_array, &num_ports);
- if (status != IB_SUCCESS) {
- osm_log(p_vend->p_log, OSM_LOG_ERROR,
- "__osmv_get_lid_and_sm_lid_by_port_guid: ERR 0504: "
- "Fail to get port attributes (error: %s)\n",
- ib_get_err_str(status)
- );
- free(p_attr_array);
- goto Exit;
- }
-
- status = IB_ERROR;
- /* find the port requested in the list */
- for (port_num = 0; (port_num < num_ports) && (status == IB_ERROR);
- port_num++) {
- if (p_attr_array[port_num].port_guid == port_guid) {
- *lid = p_attr_array[port_num].lid;
- *sm_lid = p_attr_array[port_num].sm_lid;
- *p_lids_update_time_sec = cl_get_time_stamp_sec();
- status = IB_SUCCESS;
- osm_log(p_vend->p_log, OSM_LOG_DEBUG,
- "__osmv_get_lid_and_sm_lid_by_port_guid: "
- "Found guid:0x%016" PRIx64 " with idx:%d\n",
- cl_ntoh64(port_guid), port_num);
- }
- }
-
- free(p_attr_array);
-
-Exit:
- OSM_LOG_EXIT(p_vend->p_log);
- return (status);
-}
-
-/*****************************************************************************
- *****************************************************************************/
-osm_bind_handle_t
-osmv_bind_sa(IN osm_vendor_t * const p_vend,
- IN osm_mad_pool_t * const p_mad_pool, IN ib_net64_t port_guid)
-{
- osm_bind_info_t bind_info;
- osm_log_t *p_log = p_vend->p_log;
- ib_api_status_t status = IB_SUCCESS;
- osmv_sa_bind_info_t *p_sa_bind_info;
- cl_status_t cl_status;
-
- OSM_LOG_ENTER(p_log);
-
- osm_log(p_log, OSM_LOG_DEBUG,
- "osmv_bind_sa: "
- "Binding to port 0x%" PRIx64 ".\n", cl_ntoh64(port_guid));
-
- bind_info.port_guid = port_guid;
- bind_info.mad_class = IB_MCLASS_SUBN_ADM;
- bind_info.class_version = 2;
- bind_info.is_responder = TRUE;
- bind_info.is_trap_processor = FALSE;
- bind_info.is_report_processor = TRUE;
- bind_info.send_q_size = 256;
- bind_info.recv_q_size = 256;
-
- /* allocate the new sa bind info */
- p_sa_bind_info =
- (osmv_sa_bind_info_t *) malloc(sizeof(osmv_sa_bind_info_t));
- if (!p_sa_bind_info) {
- osm_log(p_log, OSM_LOG_ERROR,
- "osmv_bind_sa: ERR 0505: "
- "Fail to allocate new bidn structure\n");
- p_sa_bind_info = OSM_BIND_INVALID_HANDLE;
- goto Exit;
- }
-
- /* store some important context */
- p_sa_bind_info->p_log = p_log;
- p_sa_bind_info->port_guid = port_guid;
- p_sa_bind_info->p_mad_pool = p_mad_pool;
- p_sa_bind_info->p_vendor = p_vend;
- p_sa_bind_info->last_lids_update_sec = 0;
-
- /* Bind to the lower level */
- p_sa_bind_info->h_bind = osm_vendor_bind(p_vend, &bind_info, p_mad_pool, __osmv_sa_mad_rcv_cb, __osmv_sa_mad_err_cb, p_sa_bind_info); /* context provided to CBs */
-
- if (p_sa_bind_info->h_bind == OSM_BIND_INVALID_HANDLE) {
- free(p_sa_bind_info);
- p_sa_bind_info = OSM_BIND_INVALID_HANDLE;
- osm_log(p_log, OSM_LOG_ERROR,
- "osmv_bind_sa: ERR 0506: "
- "Fail to bind to vendor SMI.\n");
- goto Exit;
- }
-
- /* obtain the sm_lid from the vendor */
- status =
- __osmv_get_lid_and_sm_lid_by_port_guid(p_vend, port_guid,
- &p_sa_bind_info->
- last_lids_update_sec,
- &p_sa_bind_info->lid,
- &p_sa_bind_info->sm_lid);
- if (status != IB_SUCCESS) {
- free(p_sa_bind_info);
- p_sa_bind_info = OSM_BIND_INVALID_HANDLE;
- osm_log(p_log, OSM_LOG_ERROR,
- "osmv_bind_sa: ERR 0507: "
- "Fail to obtain the sm lid.\n");
- goto Exit;
- }
-
- /* initialize the sync_event */
- cl_event_construct(&p_sa_bind_info->sync_event);
- cl_status = cl_event_init(&p_sa_bind_info->sync_event, TRUE);
- if (cl_status != CL_SUCCESS) {
- osm_log(p_log, OSM_LOG_ERROR,
- "osmv_bind_sa: ERR 0508: "
- "cl_init_event failed: %s\n", ib_get_err_str(cl_status)
- );
- free(p_sa_bind_info);
- p_sa_bind_info = OSM_BIND_INVALID_HANDLE;
- }
-
-Exit:
- OSM_LOG_EXIT(p_log);
- return (p_sa_bind_info);
-}
-
-/*****************************************************************************
- *****************************************************************************/
-
-/****t* OSM Vendor SA Client/osmv_sa_mad_data
- * NAME
- * osmv_sa_mad_data
- *
- * DESCRIPTION
- * Extra fields required to perform a mad query
- * This struct is passed to the actual send method
- *
- * SYNOPSIS
- */
-typedef struct _osmv_sa_mad_data {
- /* MAD data. */
- uint8_t method;
- ib_net16_t attr_id;
- ib_net16_t attr_offset;
- ib_net32_t attr_mod;
- ib_net64_t comp_mask;
- void *p_attr;
-} osmv_sa_mad_data_t;
-/*
- * method
- * The method of the mad to be sent
- *
- * attr_id
- * Attribute ID
- *
- * attr_offset
- * Offset as defined by RMPP
- *
- * attr_mod
- * Attribute modifier
- *
- * comp_mask
- * The component mask of the query
- *
- * p_attr
- * A pointer to the record of the attribute to be sent.
- *
- *****/
-
-/*****************************************************************************
- *****************************************************************************/
-/* Send a MAD out on the GSI interface */
-ib_api_status_t
-__osmv_send_sa_req(IN osmv_sa_bind_info_t * p_bind,
- IN const osmv_sa_mad_data_t * const p_sa_mad_data,
- IN const osmv_query_req_t * const p_query_req)
-{
- ib_api_status_t status;
- ib_mad_t *p_mad_hdr;
- ib_sa_mad_t *p_sa_mad;
- osm_madw_t *p_madw;
- osm_log_t *p_log = p_bind->p_log;
- static atomic32_t trans_id;
- boolean_t sync;
- osmv_query_req_t *p_query_req_copy;
-
- OSM_LOG_ENTER(p_log);
-
- /*
- since the sm_lid might change we obtain it every send
- (actually it is cached in the bind object and refreshed
- every 30sec by this proc )
- */
- status =
- __osmv_get_lid_and_sm_lid_by_port_guid(p_bind->p_vendor,
- p_bind->port_guid,
- &p_bind->
- last_lids_update_sec,
- &p_bind->lid,
- &p_bind->sm_lid);
- if (status != IB_SUCCESS) {
- osm_log(p_log, OSM_LOG_ERROR,
- "__osmv_send_sa_req: ERR 0509: "
- "Fail to obtain the sm lid.\n");
- goto Exit;
- }
-
- /* Get a MAD wrapper for the send */
- p_madw = osm_mad_pool_get(p_bind->p_mad_pool,
- p_bind->h_bind, MAD_BLOCK_SIZE, NULL);
-
- if (p_madw == NULL) {
- osm_log(p_log, OSM_LOG_ERROR,
- "__osmv_send_sa_req: ERR 0510: "
- "Unable to acquire MAD.\n");
- status = IB_INSUFFICIENT_RESOURCES;
- goto Exit;
- }
-
- /* Initialize the Sent MAD: */
-
- /* Initialize the MAD buffer for the send operation. */
- p_mad_hdr = osm_madw_get_mad_ptr(p_madw);
- p_sa_mad = osm_madw_get_sa_mad_ptr(p_madw);
-
- /* Get a new transaction Id */
- cl_atomic_inc(&trans_id);
-
- /* Cleanup the MAD from any residue */
- memset(p_sa_mad, 0, MAD_BLOCK_SIZE);
-
- /* Initialize the standard MAD header. */
- ib_mad_init_new(p_mad_hdr, /* mad pointer */
- IB_MCLASS_SUBN_ADM, /* class */
- (uint8_t) 2, /* version */
- p_sa_mad_data->method, /* method */
- cl_hton64((uint64_t) trans_id), /* tid */
- p_sa_mad_data->attr_id, /* attr id */
- p_sa_mad_data->attr_mod /* attr mod */
- );
-
- /* Set the query information. */
- p_sa_mad->sm_key = p_query_req->sm_key;
- p_sa_mad->attr_offset = 0;
- p_sa_mad->comp_mask = p_sa_mad_data->comp_mask;
- if (p_sa_mad->comp_mask) {
- memcpy(p_sa_mad->data, p_sa_mad_data->p_attr,
- ib_get_attr_size(p_sa_mad_data->attr_offset));
- }
-
- /*
- Provide the address to send to
- */
- /* Patch to handle IBAL - host order , where it should take destination lid in network order */
-#ifdef OSM_VENDOR_INTF_AL
- p_madw->mad_addr.dest_lid = p_bind->sm_lid;
-#else
- p_madw->mad_addr.dest_lid = cl_hton16(p_bind->sm_lid);
-#endif
- p_madw->mad_addr.addr_type.smi.source_lid = cl_hton16(p_bind->lid);
- p_madw->mad_addr.addr_type.gsi.remote_qp = CL_HTON32(1);
- p_madw->mad_addr.addr_type.gsi.remote_qkey = IB_QP1_WELL_KNOWN_Q_KEY;
- p_madw->mad_addr.addr_type.gsi.pkey_ix = 0;
- p_madw->resp_expected = TRUE;
- p_madw->fail_msg = CL_DISP_MSGID_NONE;
-
- /*
- Provide MAD context such that the call back will know what to do.
- We have to keep the entire request structure so we know the CB.
- Since we can not rely on the client to keep it arroud until
- the response - we duplicate it and will later dispose it (in CB).
- To store on the MADW we cast it into what opensm has:
- p_madw->context.arb_context.context1
- */
- p_query_req_copy = malloc(sizeof(*p_query_req_copy));
- *p_query_req_copy = *p_query_req;
- p_madw->context.arb_context.context1 = p_query_req_copy;
-
- /* we can support async as well as sync calls */
- sync = ((p_query_req->flags & OSM_SA_FLAGS_SYNC) == OSM_SA_FLAGS_SYNC);
-
- /* send the mad asynchronously */
- status = osm_vendor_send(osm_madw_get_bind_handle(p_madw),
- p_madw, p_madw->resp_expected);
-
- /* if synchronous - wait on the event */
- if (sync) {
- osm_log(p_log, OSM_LOG_DEBUG,
- "__osmv_send_sa_req: " "Waiting for async event.\n");
- cl_event_wait_on(&p_bind->sync_event, EVENT_NO_TIMEOUT, FALSE);
- cl_event_reset(&p_bind->sync_event);
- status = p_madw->status;
- }
-
-Exit:
- OSM_LOG_EXIT(p_log);
- return status;
-}
-
-/*****************************************************************************
- *****************************************************************************/
-/*
- * Query the SA based on the user's request.
- */
-ib_api_status_t
-osmv_query_sa(IN osm_bind_handle_t h_bind,
- IN const osmv_query_req_t * const p_query_req)
-{
- osmv_sa_bind_info_t *p_bind = (osmv_sa_bind_info_t *) h_bind;
- osmv_sa_mad_data_t sa_mad_data;
- osmv_user_query_t *p_user_query;
- ib_service_record_t svc_rec;
- ib_node_record_t node_rec;
- ib_portinfo_record_t port_info;
- ib_path_rec_t path_rec;
- ib_class_port_info_t class_port_info;
- osm_log_t *p_log = p_bind->p_log;
- ib_api_status_t status;
-
- OSM_LOG_ENTER(p_log);
-
- /* Set the request information. */
- sa_mad_data.method = IB_MAD_METHOD_GETTABLE;
- sa_mad_data.attr_mod = 0;
-
- /* Set the MAD attributes and component mask correctly. */
- switch (p_query_req->query_type) {
-
- case OSMV_QUERY_USER_DEFINED:
- osm_log(p_log, OSM_LOG_DEBUG,
- "osmv_query_sa DBG:001 %s", "USER_DEFINED\n");
- p_user_query = (osmv_user_query_t *) p_query_req->p_query_input;
- if (p_user_query->method)
- sa_mad_data.method = p_user_query->method;
- sa_mad_data.attr_offset = p_user_query->attr_offset;
- sa_mad_data.attr_id = p_user_query->attr_id;
- sa_mad_data.attr_mod = p_user_query->attr_mod;
- sa_mad_data.comp_mask = p_user_query->comp_mask;
- sa_mad_data.p_attr = p_user_query->p_attr;
- break;
-
- case OSMV_QUERY_ALL_SVC_RECS:
- osm_log(p_log, OSM_LOG_DEBUG,
- "osmv_query_sa DBG:001 %s", "SVC_REC_BY_NAME\n");
- sa_mad_data.method = IB_MAD_METHOD_GETTABLE;
- sa_mad_data.attr_id = IB_MAD_ATTR_SERVICE_RECORD;
- sa_mad_data.attr_offset =
- ib_get_attr_offset(sizeof(ib_service_record_t));
- sa_mad_data.comp_mask = 0;
- sa_mad_data.p_attr = &svc_rec;
- break;
-
- case OSMV_QUERY_SVC_REC_BY_NAME:
- osm_log(p_log, OSM_LOG_DEBUG,
- "osmv_query_sa DBG:001 %s", "SVC_REC_BY_NAME\n");
- sa_mad_data.method = IB_MAD_METHOD_GET;
- sa_mad_data.attr_id = IB_MAD_ATTR_SERVICE_RECORD;
- sa_mad_data.comp_mask = IB_SR_COMPMASK_SNAME;
- sa_mad_data.attr_offset =
- ib_get_attr_offset(sizeof(ib_service_record_t));
- sa_mad_data.p_attr = &svc_rec;
- memcpy(svc_rec.service_name, p_query_req->p_query_input,
- sizeof(ib_svc_name_t));
- break;
-
- case OSMV_QUERY_SVC_REC_BY_ID:
- osm_log(p_log, OSM_LOG_DEBUG,
- "osmv_query_sa DBG:001 %s", "SVC_REC_BY_ID\n");
- sa_mad_data.attr_id = IB_MAD_ATTR_SERVICE_RECORD;
- sa_mad_data.comp_mask = IB_SR_COMPMASK_SID;
- sa_mad_data.attr_offset =
- ib_get_attr_offset(sizeof(ib_service_record_t));
- sa_mad_data.p_attr = &svc_rec;
- svc_rec.service_id =
- *(ib_net64_t *) (p_query_req->p_query_input);
- break;
-
- case OSMV_QUERY_CLASS_PORT_INFO:
- osm_log(p_log, OSM_LOG_DEBUG,
- "osmv_query_sa DBG:001 %s", "CLASS_PORT_INFO\n");
- sa_mad_data.method = IB_MAD_METHOD_GET;
- sa_mad_data.attr_id = IB_MAD_ATTR_CLASS_PORT_INFO;
- sa_mad_data.attr_offset =
- ib_get_attr_offset(sizeof(ib_class_port_info_t));
- sa_mad_data.comp_mask = 0;
- sa_mad_data.p_attr = &class_port_info;
-
- break;
-
- case OSMV_QUERY_NODE_REC_BY_NODE_GUID:
- osm_log(p_log, OSM_LOG_DEBUG,
- "osmv_query_sa DBG:001 %s", "NODE_REC_BY_NODE_GUID\n");
- sa_mad_data.method = IB_MAD_METHOD_GETTABLE;
- sa_mad_data.attr_id = IB_MAD_ATTR_NODE_RECORD;
- sa_mad_data.attr_offset =
- ib_get_attr_offset(sizeof(ib_node_record_t));
- sa_mad_data.comp_mask = IB_NR_COMPMASK_NODEGUID;
- sa_mad_data.p_attr = &node_rec;
- node_rec.node_info.node_guid =
- *(ib_net64_t *) (p_query_req->p_query_input);
-
- break;
-
- case OSMV_QUERY_PORT_REC_BY_LID:
- osm_log(p_log, OSM_LOG_DEBUG,
- "osmv_query_sa DBG:001 %s", "PORT_REC_BY_LID\n");
- sa_mad_data.attr_id = IB_MAD_ATTR_PORTINFO_RECORD;
- sa_mad_data.attr_offset =
- ib_get_attr_offset(sizeof(ib_portinfo_record_t));
- sa_mad_data.comp_mask = IB_PIR_COMPMASK_LID;
- sa_mad_data.p_attr = &port_info;
- port_info.lid = *(ib_net16_t *) (p_query_req->p_query_input);
- break;
-
- case OSMV_QUERY_PORT_REC_BY_LID_AND_NUM:
- sa_mad_data.method = IB_MAD_METHOD_GET;
- p_user_query = (osmv_user_query_t *) p_query_req->p_query_input;
- osm_log(p_log, OSM_LOG_DEBUG,
- "osmv_query_sa DBG:001 %s",
- "PORT_REC_BY_LID_AND_NUM\n");
- sa_mad_data.attr_id = IB_MAD_ATTR_PORTINFO_RECORD;
- sa_mad_data.attr_offset =
- ib_get_attr_offset(sizeof(ib_portinfo_record_t));
- sa_mad_data.comp_mask =
- IB_PIR_COMPMASK_LID | IB_PIR_COMPMASK_PORTNUM;
- sa_mad_data.p_attr = p_user_query->p_attr;
- break;
-
- case OSMV_QUERY_VLARB_BY_LID_PORT_BLOCK:
- sa_mad_data.method = IB_MAD_METHOD_GET;
- p_user_query = (osmv_user_query_t *) p_query_req->p_query_input;
- osm_log(p_log, OSM_LOG_DEBUG,
- "osmv_query_sa DBG:001 %s",
- "OSMV_QUERY_VLARB_BY_LID_PORT_BLOCK\n");
- sa_mad_data.attr_id = IB_MAD_ATTR_VLARB_RECORD;
- sa_mad_data.attr_offset =
- ib_get_attr_offset(sizeof(ib_vl_arb_table_record_t));
- sa_mad_data.comp_mask =
- IB_VLA_COMPMASK_LID | IB_VLA_COMPMASK_OUT_PORT |
- IB_VLA_COMPMASK_BLOCK;
- sa_mad_data.p_attr = p_user_query->p_attr;
- break;
-
- case OSMV_QUERY_SLVL_BY_LID_AND_PORTS:
- sa_mad_data.method = IB_MAD_METHOD_GET;
- p_user_query = (osmv_user_query_t *) p_query_req->p_query_input;
- osm_log(p_log, OSM_LOG_DEBUG,
- "osmv_query_sa DBG:001 %s",
- "OSMV_QUERY_VLARB_BY_LID_PORT_BLOCK\n");
- sa_mad_data.attr_id = IB_MAD_ATTR_SLVL_RECORD;
- sa_mad_data.attr_offset =
- ib_get_attr_offset(sizeof(ib_slvl_table_record_t));
- sa_mad_data.comp_mask =
- IB_SLVL_COMPMASK_LID | IB_SLVL_COMPMASK_OUT_PORT |
- IB_SLVL_COMPMASK_IN_PORT;
- sa_mad_data.p_attr = p_user_query->p_attr;
- break;
-
- case OSMV_QUERY_PATH_REC_BY_PORT_GUIDS:
- osm_log(p_log, OSM_LOG_DEBUG,
- "osmv_query_sa DBG:001 %s", "PATH_REC_BY_PORT_GUIDS\n");
- memset(&path_rec, 0, sizeof(ib_path_rec_t));
- sa_mad_data.attr_id = IB_MAD_ATTR_PATH_RECORD;
- sa_mad_data.attr_offset =
- ib_get_attr_offset(sizeof(ib_path_rec_t));
- sa_mad_data.comp_mask =
- (IB_PR_COMPMASK_DGID | IB_PR_COMPMASK_SGID);
- sa_mad_data.p_attr = &path_rec;
- ib_gid_set_default(&path_rec.dgid,
- ((osmv_guid_pair_t *) (p_query_req->
- p_query_input))->
- dest_guid);
- ib_gid_set_default(&path_rec.sgid,
- ((osmv_guid_pair_t *) (p_query_req->
- p_query_input))->
- src_guid);
- break;
-
- case OSMV_QUERY_PATH_REC_BY_GIDS:
- osm_log(p_log, OSM_LOG_DEBUG,
- "osmv_query_sa DBG:001 %s", "PATH_REC_BY_GIDS\n");
- memset(&path_rec, 0, sizeof(ib_path_rec_t));
- sa_mad_data.attr_id = IB_MAD_ATTR_PATH_RECORD;
- sa_mad_data.attr_offset =
- ib_get_attr_offset(sizeof(ib_path_rec_t));
- sa_mad_data.comp_mask =
- (IB_PR_COMPMASK_DGID | IB_PR_COMPMASK_SGID);
- sa_mad_data.p_attr = &path_rec;
- memcpy(&path_rec.dgid,
- &((osmv_gid_pair_t *) (p_query_req->p_query_input))->
- dest_gid, sizeof(ib_gid_t));
- memcpy(&path_rec.sgid,
- &((osmv_gid_pair_t *) (p_query_req->p_query_input))->
- src_gid, sizeof(ib_gid_t));
- break;
-
- case OSMV_QUERY_PATH_REC_BY_LIDS:
- osm_log(p_log, OSM_LOG_DEBUG,
- "osmv_query_sa DBG:001 %s", "PATH_REC_BY_LIDS\n");
- memset(&path_rec, 0, sizeof(ib_path_rec_t));
- sa_mad_data.method = IB_MAD_METHOD_GET;
- sa_mad_data.attr_id = IB_MAD_ATTR_PATH_RECORD;
- sa_mad_data.attr_offset =
- ib_get_attr_offset(sizeof(ib_path_rec_t));
- sa_mad_data.comp_mask =
- (IB_PR_COMPMASK_DLID | IB_PR_COMPMASK_SLID);
- sa_mad_data.p_attr = &path_rec;
- path_rec.dlid =
- ((osmv_lid_pair_t *) (p_query_req->p_query_input))->
- dest_lid;
- path_rec.slid =
- ((osmv_lid_pair_t *) (p_query_req->p_query_input))->src_lid;
- break;
-
- case OSMV_QUERY_UD_MULTICAST_SET:
- sa_mad_data.method = IB_MAD_METHOD_SET;
- p_user_query = (osmv_user_query_t *) p_query_req->p_query_input;
- osm_log(p_log, OSM_LOG_DEBUG,
- "osmv_query_sa DBG:001 %s",
- "OSMV_QUERY_UD_MULTICAST_SET\n");
- sa_mad_data.attr_id = IB_MAD_ATTR_MCMEMBER_RECORD;
- sa_mad_data.attr_offset =
- ib_get_attr_offset(sizeof(ib_member_rec_t));
- sa_mad_data.comp_mask = p_user_query->comp_mask;
- sa_mad_data.p_attr = p_user_query->p_attr;
- break;
-
- case OSMV_QUERY_UD_MULTICAST_DELETE:
- sa_mad_data.method = IB_MAD_METHOD_DELETE;
- p_user_query = (osmv_user_query_t *) p_query_req->p_query_input;
- osm_log(p_log, OSM_LOG_DEBUG,
- "osmv_query_sa DBG:001 %s",
- "OSMV_QUERY_UD_MULTICAST_DELETE\n");
- sa_mad_data.attr_id = IB_MAD_ATTR_MCMEMBER_RECORD;
- sa_mad_data.attr_offset =
- ib_get_attr_offset(sizeof(ib_member_rec_t));
- sa_mad_data.comp_mask = p_user_query->comp_mask;
- sa_mad_data.p_attr = p_user_query->p_attr;
- break;
-
- default:
- osm_log(p_log, OSM_LOG_ERROR,
- "osmv_query_sa DBG:001 %s", "UNKNOWN\n");
- CL_ASSERT(0);
- return IB_ERROR;
- }
-
- status = __osmv_send_sa_req(h_bind, &sa_mad_data, p_query_req);
-
- OSM_LOG_EXIT(p_log);
- return status;
-}
-
-/*****************************************************************************
- *****************************************************************************/
diff --git a/contrib/ofed/management/opensm/libvendor/osm_vendor_mlx_sender.c b/contrib/ofed/management/opensm/libvendor/osm_vendor_mlx_sender.c
deleted file mode 100644
index a0bdef8..0000000
--- a/contrib/ofed/management/opensm/libvendor/osm_vendor_mlx_sender.c
+++ /dev/null
@@ -1,390 +0,0 @@
-/*
- * Copyright (c) 2004-2006 Voltaire, Inc. All rights reserved.
- * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved.
- * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- */
-
-#if HAVE_CONFIG_H
-# include <config.h>
-#endif /* HAVE_CONFIG_H */
-
-#include <string.h>
-#include <vendor/osm_vendor_mlx_sender.h>
-#include <vendor/osm_vendor_mlx_transport.h>
-#include <vendor/osm_vendor_mlx_svc.h>
-#include <vendor/osm_pkt_randomizer.h>
-
-static ib_api_status_t
-__osmv_rmpp_send_segment(IN osm_bind_handle_t h_bind,
- IN osmv_txn_ctx_t * p_txn, IN uint32_t seg_num);
-
-/****d* OSM Vendor/osmv_simple_send_madw
- * NAME
- * osmv_simple_send_madw
- *
- * DESCRIPTION
- * Send a single MAD (256 bytes).
- *
- * If this MAD requires a response, set the timeout event.
- * The function call returns when the MAD's send completion is received.
- *
- */
-
-ib_api_status_t
-osmv_simple_send_madw(IN osm_bind_handle_t h_bind,
- IN osm_madw_t * const p_madw,
- IN osmv_txn_ctx_t * p_txn, IN boolean_t is_retry)
-{
- ib_api_status_t ret;
- osmv_bind_obj_t *p_bo = (osmv_bind_obj_t *) h_bind;
- osm_mad_addr_t *p_mad_addr = osm_madw_get_mad_addr_ptr(p_madw);
- uint8_t mad_buf[MAD_BLOCK_SIZE];
- ib_mad_t *p_mad = (ib_mad_t *) mad_buf;
- uint64_t key = 0;
-
- OSM_LOG_ENTER(p_bo->p_vendor->p_log);
-
- CL_ASSERT(p_madw->mad_size <= MAD_BLOCK_SIZE);
-
- memset(p_mad, 0, MAD_BLOCK_SIZE);
- memcpy(p_mad, osm_madw_get_mad_ptr(p_madw), p_madw->mad_size);
-
- if (NULL != p_txn) {
- /* Push a fake txn id to the MAD */
- key = osmv_txn_get_key(p_txn);
- p_mad->trans_id = cl_hton64(key);
- }
-
- /*
- Add call for packet drop randomizer.
- This is a testing feature. If run_randomizer flag is set to TRUE,
- the randomizer will be called, and randomally will drop
- a packet. This is used for simulating unstable fabric.
- */
- if (p_bo->p_vendor->run_randomizer == TRUE) {
- /* Try the randomizer */
- if (osm_pkt_randomizer_mad_drop(p_bo->p_vendor->p_log,
- p_bo->p_vendor->
- p_pkt_randomizer,
- p_mad) == TRUE) {
- osm_log(p_bo->p_vendor->p_log, OSM_LOG_DEBUG,
- "The MAD will not be sent. \n");
- ret = IB_SUCCESS;
- } else {
- ret =
- osmv_transport_mad_send(h_bind, p_mad, p_mad_addr);
- }
- } else {
- ret = osmv_transport_mad_send(h_bind, p_mad, p_mad_addr);
- }
-
- if ((IB_SUCCESS == ret) && (NULL != p_txn) && (!is_retry)) {
- /* Set the timeout for receiving the response MAD */
- ret = osmv_txn_set_timeout_ev(h_bind, key,
- p_bo->p_vendor->resp_timeout);
- }
-
- OSM_LOG_EXIT(p_bo->p_vendor->p_log);
- return ret;
-}
-
-/***** OSM Vendor/osmv_rmpp_send_madw
- * NAME
- * osmv_rmpp_send_madw
- *
- * DESCRIPTION
- * Send a single message (MAD wrapper of arbitrary length).
- * Follow the RMPP semantics
- * (segmentation, send window, timeouts etc).
- *
- * The function call returns either when the whole message
- * has been acknowledged, or upon error.
- *
- * ASSUMPTIONS
- * The RMPP sender context is set up
- */
-
-ib_api_status_t
-osmv_rmpp_send_madw(IN osm_bind_handle_t h_bind,
- IN osm_madw_t * const p_madw,
- IN osmv_txn_ctx_t * p_txn, IN boolean_t is_rmpp_ds)
-{
- ib_api_status_t ret = IB_SUCCESS;
- uint32_t i, total_segs;
-
- osmv_rmpp_send_ctx_t *p_send_ctx = osmv_txn_get_rmpp_send_ctx(p_txn);
- osmv_bind_obj_t *p_bo = (osmv_bind_obj_t *) h_bind;
-
- OSM_LOG_ENTER(p_bo->p_vendor->p_log);
-
- total_segs = osmv_rmpp_send_ctx_get_num_segs(p_send_ctx);
- CL_ASSERT(total_segs >= 1);
-
- /* In the double-sided transfer, wait for ACK 0 */
-
- for (;;) {
-
- if (p_send_ctx->window_first > total_segs) {
-
- /* Every segment is acknowledged */
- break;
- }
-
- /* Send the next burst. */
- for (i = p_send_ctx->window_first; i <= p_send_ctx->window_last;
- i++) {
-
- /* Send a segment and setup a timeout timer */
- ret = __osmv_rmpp_send_segment(h_bind, p_txn, i);
- if (IB_SUCCESS != ret) {
- goto send_done;
- }
- }
-
- /* Set the Response Timeout for the ACK on the last DATA segment */
- ret = osmv_txn_set_timeout_ev(h_bind, osmv_txn_get_key(p_txn),
- p_bo->p_vendor->resp_timeout);
- if (IB_SUCCESS != ret) {
- goto send_done;
- }
-
- /* Going to sleep. Let the others access the transaction DB */
- osmv_txn_unlock(p_bo);
-
- osm_log(p_bo->p_vendor->p_log, OSM_LOG_DEBUG,
- "RMPP Sender thread (madw=%p) going to sleep ...\n",
- p_madw);
-
- /* Await the next event to happen */
- cl_event_wait_on(&p_send_ctx->event,
- EVENT_NO_TIMEOUT, TRUE /* interruptible */ );
-
- /* Got a signal from the MAD dispatcher/timeout handler */
- osm_log(p_bo->p_vendor->p_log, OSM_LOG_DEBUG,
- "RMPP Sender thread (madw=%p) waking up on a signal ...\n",
- p_madw);
-
- /* Let's see what changed... Make this atomic - re-acquire the lock. */
- osmv_txn_lock(p_bo);
-
- if (TRUE == p_bo->is_closing) {
- osm_log(p_bo->p_vendor->p_log, OSM_LOG_ERROR,
- "osmv_rmpp_send_madw: ERR 6601: "
- "The bind handle %p is being closed. "
- "Stopping the RMPP Send of MADW %p\n",
- h_bind, p_madw);
-
- ret = IB_TIMEOUT;
- return IB_INTERRUPTED;
- }
-
- /* STOP? ABORT? TIMEOUT? */
- if (IB_SUCCESS != p_send_ctx->status) {
- osm_log(p_bo->p_vendor->p_log, OSM_LOG_ERROR,
- "osmv_rmpp_send_madw: ERR 6602: "
- "An error (%s) happened during the RMPP send of %p. Bailing out.\n",
- ib_get_err_str(p_send_ctx->status), p_madw);
- ret = p_send_ctx->status;
- goto send_done;
- }
- }
-
- if (TRUE == is_rmpp_ds) {
- osm_log(p_bo->p_vendor->p_log, OSM_LOG_DEBUG,
- "Double-sided RMPP - switching to be the receiver.\n");
-
- ret = osmv_txn_init_rmpp_receiver(h_bind, p_txn, FALSE
- /*Send was initiated by me */
- );
-
- if (IB_SUCCESS == ret) {
- /* Send ACK on the 0 segment */
- ret = __osmv_rmpp_send_segment(h_bind, p_txn, 0);
- }
- }
-
-send_done:
- OSM_LOG_EXIT(p_bo->p_vendor->p_log);
- return ret;
-}
-
-/*
- * NAME osmv_rmpp_send_ack
- *
- * DESCRIPTION
- *
- */
-
-ib_api_status_t
-osmv_rmpp_send_ack(IN osm_bind_handle_t h_bind,
- IN const ib_mad_t * p_req_mad,
- IN uint32_t seg_num,
- IN uint32_t nwl, IN const osm_mad_addr_t * p_mad_addr)
-{
- uint8_t resp_mad[MAD_BLOCK_SIZE];
- ib_rmpp_mad_t *p_resp_mad = (ib_rmpp_mad_t *) resp_mad;
-
-#ifdef OSMV_RANDOM_DROP
- if (TRUE == osmv_random_drop()) {
- osm_log(((osmv_bind_obj_t *) h_bind)->p_vendor->p_log,
- OSM_LOG_DEBUG,
- "Error injection - dropping the RMPP ACK\n");
- return IB_SUCCESS;
- }
-#endif
-
- memcpy(p_resp_mad, p_req_mad, MAD_BLOCK_SIZE);
-
- p_resp_mad->common_hdr.method = osmv_invert_method(p_req_mad->method);
- p_resp_mad->rmpp_type = IB_RMPP_TYPE_ACK;
- p_resp_mad->seg_num = cl_hton32(seg_num);
- p_resp_mad->paylen_newwin = cl_hton32(nwl);
- p_resp_mad->rmpp_flags = IB_RMPP_FLAG_ACTIVE;
-
- return osmv_transport_mad_send(h_bind, p_resp_mad, p_mad_addr);
-}
-
-/*
- * NAME osmv_rmpp_send_nak
- *
- * DESCRIPTION Send the RMPP ABORT or STOP packet
- */
-
-ib_api_status_t
-osmv_rmpp_send_nak(IN osm_bind_handle_t h_bind,
- IN const ib_mad_t * p_req_mad,
- IN const osm_mad_addr_t * p_mad_addr,
- IN uint8_t nak_type, IN uint8_t status)
-{
- uint8_t resp_mad[MAD_BLOCK_SIZE];
- ib_rmpp_mad_t *p_resp_mad = (ib_rmpp_mad_t *) resp_mad;
-
- memcpy(p_resp_mad, p_req_mad, MAD_BLOCK_SIZE);
-
- p_resp_mad->common_hdr.method = osmv_invert_method(p_req_mad->method);
- p_resp_mad->rmpp_type = nak_type;
- p_resp_mad->rmpp_status = status;
-
- return osmv_transport_mad_send(h_bind, p_resp_mad, p_mad_addr);
-}
-
-/*
- * NAME __osmv_rmpp_send_segment
- *
- * DESCRIPTION Build a MAD for a specific segment and send it
- */
-
-static ib_api_status_t
-__osmv_rmpp_send_segment(IN osm_bind_handle_t h_bind,
- IN osmv_txn_ctx_t * p_txn, IN uint32_t seg_num)
-{
- ib_api_status_t ret;
- osmv_rmpp_send_ctx_t *p_send_ctx;
- uint8_t mad_buf[MAD_BLOCK_SIZE];
- ib_mad_t *p_mad = (ib_mad_t *) mad_buf;
- osmv_bind_obj_t *p_bo = (osmv_bind_obj_t *) h_bind;
- osm_mad_addr_t *p_mad_addr =
- osm_madw_get_mad_addr_ptr(osmv_txn_get_madw(p_txn));
- uint32_t timeout = p_bo->p_vendor->resp_timeout;
- uint64_t key;
-
- OSM_LOG_ENTER(p_bo->p_vendor->p_log);
-
-#ifdef OSMV_RANDOM_DROP
- if (TRUE == osmv_random_drop()) {
-
- osm_log(p_bo->p_vendor->p_log, OSM_LOG_DEBUG,
- "Error injection - simulating the RMPP segment drop\n");
- return IB_SUCCESS;
- }
-#endif
-
- p_send_ctx = osmv_txn_get_rmpp_send_ctx(p_txn);
- key = osmv_txn_get_key(p_txn);
-
- if (0 != seg_num) {
- ret =
- osmv_rmpp_send_ctx_get_seg(p_send_ctx, seg_num, timeout,
- p_mad);
- CL_ASSERT(IB_SUCCESS == ret);
-
- /* Put the segment to the wire ! */
- p_mad->trans_id = cl_hton64(key);
-
- osm_log(p_bo->p_vendor->p_log, OSM_LOG_DEBUG,
- "Sending RMPP segment #%d, on-wire TID=0x%llX\n",
- seg_num, p_mad->trans_id);
-
- /*
- Add call for packet drop randomizer.
- This is a testing feature. If run_randomizer flag is set to TRUE,
- the randomizer will be called, and randomally will drop
- a packet. This is used for simulating unstable fabric.
- */
- if (p_bo->p_vendor->run_randomizer == TRUE) {
- /* Try the randomizer */
- if (osm_pkt_randomizer_mad_drop(p_bo->p_vendor->p_log,
- p_bo->p_vendor->
- p_pkt_randomizer,
- p_mad) == TRUE) {
- osm_log(p_bo->p_vendor->p_log, OSM_LOG_DEBUG,
- "The MAD will not be sent. \n");
- ret = IB_SUCCESS;
- } else {
- ret =
- osmv_transport_mad_send((osm_bind_handle_t)
- p_bo, p_mad,
- p_mad_addr);
- }
- } else {
- ret =
- osmv_transport_mad_send((osm_bind_handle_t) p_bo,
- p_mad, p_mad_addr);
- }
- } else {
- /* This is an ACK for double-sided handshake. Give it a special treatment. */
-
- /* It doesn't really matter which data to put. Only the header matters. */
- ret = osmv_rmpp_send_ctx_get_seg(p_send_ctx, 1, timeout, p_mad);
- CL_ASSERT(IB_SUCCESS == ret);
-
- p_mad->trans_id = cl_hton64(key);
- ret =
- osmv_rmpp_send_ack((osm_bind_handle_t) p_bo, p_mad,
- 0 /* segnum */ ,
- OSMV_RMPP_RECV_WIN /* NWL */ ,
- p_mad_addr);
- }
-
- OSM_LOG_EXIT(p_bo->p_vendor->p_log);
- return ret;
-}
diff --git a/contrib/ofed/management/opensm/libvendor/osm_vendor_mlx_txn.c b/contrib/ofed/management/opensm/libvendor/osm_vendor_mlx_txn.c
deleted file mode 100644
index a2da75a..0000000
--- a/contrib/ofed/management/opensm/libvendor/osm_vendor_mlx_txn.c
+++ /dev/null
@@ -1,675 +0,0 @@
-/*
- * Copyright (c) 2004-2006 Voltaire, Inc. All rights reserved.
- * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved.
- * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- */
-
-#if HAVE_CONFIG_H
-# include <config.h>
-#endif /* HAVE_CONFIG_H */
-
-#include <stdlib.h>
-
-#include <vendor/osm_vendor_mlx.h>
-#include <vendor/osm_vendor_mlx_defs.h>
-#include <vendor/osm_vendor_mlx_txn.h>
-#include <vendor/osm_vendor_mlx_svc.h>
-#include <vendor/osm_vendor_mlx_sender.h>
-
-static ib_api_status_t
-__osmv_txnmgr_lookup(IN osmv_txn_mgr_t * p_tx_mgr,
- IN uint64_t key, OUT osmv_txn_ctx_t ** pp_txn);
-
-static ib_api_status_t
-__osmv_txnmgr_insert_txn(IN osmv_txn_mgr_t * p_tx_mgr,
- IN osmv_txn_ctx_t * p_txn, IN uint64_t key);
-
-static ib_api_status_t
-__osmv_txnmgr_remove_txn(IN osmv_txn_mgr_t * p_tx_mgr,
- IN uint64_t key, OUT osmv_txn_ctx_t ** pp_txn);
-
-static void __osmv_txn_all_done(osm_bind_handle_t h_bind);
-
-static uint64_t
-__osmv_txn_timeout_cb(IN uint64_t key,
- IN uint32_t num_regs, IN void *cb_context);
-
-ib_api_status_t
-osmv_txn_init(IN osm_bind_handle_t h_bind,
- IN uint64_t tid, IN uint64_t key, OUT osmv_txn_ctx_t ** pp_txn)
-{
- ib_api_status_t st;
- osmv_txn_ctx_t *p_txn;
- osmv_bind_obj_t *p_bo = (osmv_bind_obj_t *) h_bind;
-
- OSM_LOG_ENTER(p_bo->p_vendor->p_log);
-
- CL_ASSERT(NULL != h_bind && NULL != pp_txn);
-
- osm_log(p_bo->p_vendor->p_log, OSM_LOG_DEBUG,
- "Starting transaction 0x%llX (key=0x%llX)\n", tid, key);
-
- p_txn = malloc(sizeof(osmv_txn_ctx_t));
- if (!p_txn) {
- return IB_INSUFFICIENT_MEMORY;
- }
-
- memset(p_txn, 0, sizeof(osmv_txn_ctx_t));
- p_txn->p_log = p_bo->txn_mgr.p_log;
- p_txn->tid = tid;
- p_txn->key = key;
- p_txn->p_madw = NULL;
- p_txn->rmpp_txfr.rmpp_state = OSMV_TXN_RMPP_NONE;
-
- /* insert into transaction manager DB */
- st = __osmv_txnmgr_insert_txn(&p_bo->txn_mgr, p_txn, key);
- if (IB_SUCCESS != st) {
- osm_log(p_bo->p_vendor->p_log, OSM_LOG_ERROR,
- "osmv_txn_init: ERR 6703: "
- "Failed to insert to transaction 0x%llX (key=0x%llX) to manager DB\n",
- tid, key);
- goto insert_txn_failed;
- }
-
- *pp_txn = p_txn;
- OSM_LOG_EXIT(p_bo->p_vendor->p_log);
- return IB_SUCCESS;
-
-insert_txn_failed:
- free(p_txn);
-
- OSM_LOG_EXIT(p_bo->p_vendor->p_log);
- return st;
-}
-
-ib_api_status_t
-osmv_txn_init_rmpp_sender(IN osm_bind_handle_t h_bind,
- IN osmv_txn_ctx_t * p_txn, IN osm_madw_t * p_madw)
-{
- ib_api_status_t st;
-
- CL_ASSERT(p_txn);
-
- /* Double-Sided RMPP Direction Switch */
- osmv_txn_remove_timeout_ev(h_bind, osmv_txn_get_key(p_txn));
-
- p_txn->rmpp_txfr.rmpp_state = OSMV_TXN_RMPP_SENDER;
- p_txn->rmpp_txfr.p_rmpp_send_ctx = malloc(sizeof(osmv_rmpp_send_ctx_t));
-
- if (!p_txn->rmpp_txfr.p_rmpp_send_ctx) {
- return IB_INSUFFICIENT_MEMORY;
- }
-
- memset(p_txn->rmpp_txfr.p_rmpp_send_ctx, 0,
- sizeof(osmv_rmpp_send_ctx_t));
-
- st = osmv_rmpp_send_ctx_init(p_txn->rmpp_txfr.p_rmpp_send_ctx,
- (void *)p_madw->p_mad,
- p_madw->mad_size, p_txn->p_log);
- return st;
-}
-
-ib_api_status_t
-osmv_txn_init_rmpp_receiver(IN osm_bind_handle_t h_bind,
- IN osmv_txn_ctx_t * p_txn,
- IN boolean_t is_init_by_peer)
-{
- ib_api_status_t st;
- osmv_bind_obj_t *p_bo = (osmv_bind_obj_t *) h_bind;
- uint64_t key = osmv_txn_get_key(p_txn);
-
- CL_ASSERT(p_txn);
-
- /* Double-Sided RMPP Direction Switch */
- osmv_txn_remove_timeout_ev(h_bind, key);
-
- /* Set the Transaction Timeout value */
- st = osmv_txn_set_timeout_ev(h_bind, key,
- p_bo->p_vendor->ttime_timeout);
- if (IB_SUCCESS != st) {
-
- return st;
- }
-
- p_txn->rmpp_txfr.rmpp_state = OSMV_TXN_RMPP_RECEIVER;
- p_txn->rmpp_txfr.is_rmpp_init_by_peer = is_init_by_peer;
-
- p_txn->rmpp_txfr.p_rmpp_recv_ctx = malloc(sizeof(osmv_rmpp_recv_ctx_t));
-
- if (!p_txn->rmpp_txfr.p_rmpp_recv_ctx) {
-
- osmv_txn_remove_timeout_ev(h_bind, key);
- return IB_INSUFFICIENT_MEMORY;
- }
-
- memset(p_txn->rmpp_txfr.p_rmpp_recv_ctx, 0,
- sizeof(osmv_rmpp_recv_ctx_t));
-
- st = osmv_rmpp_recv_ctx_init(p_txn->rmpp_txfr.p_rmpp_recv_ctx,
- p_txn->p_log);
-
- return st;
-}
-
-/*
- * NAME
- * osmv_txn_set_timeout_ev
- *
- * DESCRIPTION
- *
- * SEE ALSO
- *
- */
-ib_api_status_t
-osmv_txn_set_timeout_ev(IN osm_bind_handle_t h_bind,
- IN uint64_t key, IN uint64_t msec)
-{
- osmv_bind_obj_t *p_bo = (osmv_bind_obj_t *) h_bind;
- cl_event_wheel_t *p_event_wheel = p_bo->txn_mgr.p_event_wheel;
- cl_status_t status;
-
- status = cl_event_wheel_reg(p_event_wheel, key, cl_get_time_stamp() + 1000 * msec, /* TTL */
- __osmv_txn_timeout_cb,
- p_bo /* The context */ );
-
- return (ib_api_status_t) status;
-}
-
-/*
- * NAME
- * osmv_txn_remove_timeout_ev
- *
- * DESCRIPTION
-
- * SEE ALSO
- *
- */
-void osmv_txn_remove_timeout_ev(IN osm_bind_handle_t h_bind, IN uint64_t key)
-{
- cl_event_wheel_t *p_event_wheel =
- ((osmv_bind_obj_t *) h_bind)->txn_mgr.p_event_wheel;
- cl_event_wheel_unreg(p_event_wheel, key);
-}
-
-void
-osmv_txn_done(IN osm_bind_handle_t h_bind,
- IN uint64_t key, IN boolean_t is_in_cb)
-{
- osmv_txn_ctx_t *p_ctx;
- osmv_bind_obj_t *const p_bo = (osmv_bind_obj_t *) h_bind;
-
- OSM_LOG_ENTER(p_bo->p_vendor->p_log);
-
- CL_ASSERT(h_bind);
-
- /* Cancel the (single) timeout possibly outstanding for this txn
- * Don't do this if you are in the callback context, for 2 reasons:
- * (1) The event wheel will remove the context itself.
- * (2) If we try to, there is a deadlock in the event wheel
- */
- if (FALSE == is_in_cb) {
- osmv_txn_remove_timeout_ev(h_bind, key);
- }
-
- /* Remove from DB */
- if (IB_NOT_FOUND ==
- __osmv_txnmgr_remove_txn(&p_bo->txn_mgr, key, &p_ctx)) {
- return;
- }
-
- /* Destroy the transaction's RMPP contexts
- * (can be more than one in the case of double sided transfer)
- */
-
- if (p_ctx->rmpp_txfr.p_rmpp_send_ctx) {
- osmv_rmpp_send_ctx_done(p_ctx->rmpp_txfr.p_rmpp_send_ctx);
- }
-
- if (p_ctx->rmpp_txfr.p_rmpp_recv_ctx) {
- osmv_rmpp_recv_ctx_done(p_ctx->rmpp_txfr.p_rmpp_recv_ctx);
- }
-
- free(p_ctx);
-
- OSM_LOG_EXIT(p_bo->p_vendor->p_log);
-}
-
-ib_api_status_t
-osmv_txn_lookup(IN osm_bind_handle_t h_bind,
- IN uint64_t key, OUT osmv_txn_ctx_t ** pp_txn)
-{
- return __osmv_txnmgr_lookup(&(((osmv_bind_obj_t *) h_bind)->txn_mgr),
- key, pp_txn);
-}
-
-void osmv_txn_abort_rmpp_txns(osm_bind_handle_t h_bind)
-{
- osmv_bind_obj_t *p_bo = (osmv_bind_obj_t *) h_bind;
- cl_map_item_t *p_item;
- cl_map_obj_t *p_obj;
- osmv_txn_ctx_t *p_txn;
- osmv_rmpp_send_ctx_t *p_send_ctx;
- cl_qmap_t *p_map = p_bo->txn_mgr.p_txn_map;
-
- OSM_LOG_ENTER(p_bo->p_vendor->p_log);
-
- while (FALSE == cl_is_qmap_empty(p_map)) {
-
- p_item = cl_qmap_head(p_map);
- p_obj = PARENT_STRUCT(p_item, cl_map_obj_t, item);
- p_txn = (osmv_txn_ctx_t *) cl_qmap_obj(p_obj);
- p_send_ctx = osmv_txn_get_rmpp_send_ctx(p_txn);
-
- if (NULL != p_send_ctx) {
-
- p_send_ctx->status = IB_INTERRUPTED;
-
- /* Wake up the sender thread to let it break out */
- cl_event_signal(&p_send_ctx->event);
- }
-
- cl_qmap_remove_item(p_map, p_item);
- }
-
- OSM_LOG_EXIT(p_bo->p_vendor->p_log);
-}
-
-ib_api_status_t
-osmv_txnmgr_init(IN osmv_txn_mgr_t * p_tx_mgr,
- IN osm_log_t * p_log, IN cl_spinlock_t * p_lock)
-{
- cl_status_t cl_st = CL_SUCCESS;
-
- p_tx_mgr->p_event_wheel = malloc(sizeof(cl_event_wheel_t));
- if (!p_tx_mgr->p_event_wheel) {
- return IB_INSUFFICIENT_MEMORY;
- }
-
- memset(p_tx_mgr->p_event_wheel, 0, sizeof(cl_event_wheel_t));
-
- cl_event_wheel_construct(p_tx_mgr->p_event_wheel);
-
- /* NOTE! We are using an extended constructor.
- * We tell the Event Wheel run in a non-protected manner in the reg/unreg calls,
- * and acquire an external lock in the asynchronous callback.
- */
- cl_st = cl_event_wheel_init_ex(p_tx_mgr->p_event_wheel, p_lock);
- if (cl_st != CL_SUCCESS) {
- free(p_tx_mgr->p_event_wheel);
- return (ib_api_status_t) cl_st;
- }
-
- p_tx_mgr->p_txn_map = malloc(sizeof(cl_qmap_t));
- if (!p_tx_mgr->p_txn_map) {
- cl_event_wheel_destroy(p_tx_mgr->p_event_wheel);
- free(p_tx_mgr->p_event_wheel);
- return IB_INSUFFICIENT_MEMORY;
- }
-
- memset(p_tx_mgr->p_txn_map, 0, sizeof(cl_qmap_t));
-
- cl_qmap_init(p_tx_mgr->p_txn_map);
- p_tx_mgr->p_log = p_log;
-
- return cl_st;
-}
-
-void osmv_txnmgr_done(IN osm_bind_handle_t h_bind)
-{
- osmv_bind_obj_t *p_bo = (osmv_bind_obj_t *) h_bind;
-
- __osmv_txn_all_done(h_bind);
- free(p_bo->txn_mgr.p_txn_map);
-
- cl_event_wheel_destroy(p_bo->txn_mgr.p_event_wheel);
- free(p_bo->txn_mgr.p_event_wheel);
-}
-
-ib_api_status_t
-__osmv_txnmgr_lookup(IN osmv_txn_mgr_t * p_tx_mgr,
- IN uint64_t key, OUT osmv_txn_ctx_t ** pp_txn)
-{
- ib_api_status_t status = IB_SUCCESS;
- cl_map_item_t *p_item;
- cl_map_obj_t *p_obj;
-
- uint64_t tmp_key;
-
- OSM_LOG_ENTER(p_tx_mgr->p_log);
-
- CL_ASSERT(p_tx_mgr);
- CL_ASSERT(pp_txn);
-
- osm_log(p_tx_mgr->p_log, OSM_LOG_DEBUG,
- "__osmv_txnmgr_lookup: "
- "Looking for key: 0x%llX in map ptr:%p\n", key,
- p_tx_mgr->p_txn_map);
-
- p_item = cl_qmap_head(p_tx_mgr->p_txn_map);
- while (p_item != cl_qmap_end(p_tx_mgr->p_txn_map)) {
- tmp_key = cl_qmap_key(p_item);
- osm_log(p_tx_mgr->p_log, OSM_LOG_DEBUG,
- "__osmv_txnmgr_lookup: "
- "Found key 0x%llX \n", tmp_key);
- p_item = cl_qmap_next(p_item);
- }
-
- p_item = cl_qmap_get(p_tx_mgr->p_txn_map, key);
- if (cl_qmap_end(p_tx_mgr->p_txn_map) == p_item) {
- status = IB_NOT_FOUND;
- } else {
- p_obj = PARENT_STRUCT(p_item, cl_map_obj_t, item);
- *pp_txn = cl_qmap_obj(p_obj);
- }
-
- OSM_LOG_EXIT(p_tx_mgr->p_log);
- return status;
-}
-
-ib_api_status_t
-__osmv_txnmgr_insert_txn(IN osmv_txn_mgr_t * p_tx_mgr,
- IN osmv_txn_ctx_t * p_txn, IN uint64_t key)
-{
- cl_map_obj_t *p_obj = NULL;
- cl_map_item_t *p_item;
- uint64_t tmp_key;
-
- CL_ASSERT(p_tx_mgr);
- CL_ASSERT(p_txn);
-
- key = osmv_txn_get_key(p_txn);
- p_obj = malloc(sizeof(cl_map_obj_t));
- if (NULL == p_obj)
- return IB_INSUFFICIENT_MEMORY;
-
- osm_log(p_tx_mgr->p_log, OSM_LOG_DEBUG,
- "__osmv_txnmgr_insert_txn: "
- "Inserting key: 0x%llX to map ptr:%p\n", key,
- p_tx_mgr->p_txn_map);
-
- memset(p_obj, 0, sizeof(cl_map_obj_t));
-
- cl_qmap_set_obj(p_obj, p_txn);
- /* assuming lookup with this key was made and the result was IB_NOT_FOUND */
- cl_qmap_insert(p_tx_mgr->p_txn_map, key, &p_obj->item);
-
- p_item = cl_qmap_head(p_tx_mgr->p_txn_map);
- while (p_item != cl_qmap_end(p_tx_mgr->p_txn_map)) {
- tmp_key = cl_qmap_key(p_item);
- osm_log(p_tx_mgr->p_log, OSM_LOG_DEBUG,
- "__osmv_txnmgr_insert_txn: "
- "Found key 0x%llX \n", tmp_key);
- p_item = cl_qmap_next(p_item);
- }
-
- return IB_SUCCESS;
-}
-
-ib_api_status_t
-__osmv_txnmgr_remove_txn(IN osmv_txn_mgr_t * p_tx_mgr,
- IN uint64_t key, OUT osmv_txn_ctx_t ** pp_txn)
-{
- cl_map_obj_t *p_obj;
- cl_map_item_t *p_item;
-
- OSM_LOG_ENTER(p_tx_mgr->p_log);
-
- CL_ASSERT(p_tx_mgr);
- CL_ASSERT(pp_txn);
-
- p_item = cl_qmap_remove(p_tx_mgr->p_txn_map, key);
-
- if (p_item == cl_qmap_end(p_tx_mgr->p_txn_map)) {
-
- osm_log(p_tx_mgr->p_log, OSM_LOG_ERROR,
- "__osmv_txnmgr_remove_txn: ERR 6701: "
- "Could not remove the transaction 0x%llX - "
- "something is really wrong!\n", key);
- OSM_LOG_EXIT(p_tx_mgr->p_log);
- return IB_NOT_FOUND;
- }
-
- p_obj = PARENT_STRUCT(p_item, cl_map_obj_t, item);
- *pp_txn = cl_qmap_obj(p_obj);
-
- free(p_obj);
-
- OSM_LOG_EXIT(p_tx_mgr->p_log);
- return IB_SUCCESS;
-}
-
-void __osmv_txn_all_done(osm_bind_handle_t h_bind)
-{
- osmv_bind_obj_t *p_bo = (osmv_bind_obj_t *) h_bind;
- cl_map_item_t *p_item;
- cl_map_obj_t *p_obj;
- osmv_txn_ctx_t *p_txn;
-
- OSM_LOG_ENTER(p_bo->p_vendor->p_log);
-
- p_item = cl_qmap_head(p_bo->txn_mgr.p_txn_map);
- while (p_item != cl_qmap_end(p_bo->txn_mgr.p_txn_map)) {
-
- p_obj = PARENT_STRUCT(p_item, cl_map_obj_t, item);
- p_txn = (osmv_txn_ctx_t *) cl_qmap_obj(p_obj);
- osmv_txn_done(h_bind, osmv_txn_get_key(p_txn), FALSE);
- free(p_obj);
- /* assuming osmv_txn_done has removed the txn from the map */
- p_item = cl_qmap_head(p_bo->txn_mgr.p_txn_map);
- }
-
- OSM_LOG_EXIT(p_bo->p_vendor->p_log);
-}
-
-/******************************************************************************/
-
-void osmv_txn_lock(IN osm_bind_handle_t h_bind)
-{
- osmv_bind_obj_t *p_bo = (osmv_bind_obj_t *) h_bind;
-
- osm_log(p_bo->p_vendor->p_log, OSM_LOG_DEBUG,
- "--> Acquiring lock %p on bind handle %p\n", &p_bo->lock, p_bo);
-
- cl_spinlock_acquire(&p_bo->lock);
-
- osm_log(p_bo->p_vendor->p_log, OSM_LOG_DEBUG,
- "--> Acquired lock %p on bind handle %p\n", &p_bo->lock, p_bo);
-}
-
-void osmv_txn_unlock(IN osm_bind_handle_t h_bind)
-{
- osmv_bind_obj_t *p_bo = (osmv_bind_obj_t *) h_bind;
- cl_spinlock_t *p_lock = &p_bo->lock;
- osm_log_t *p_log = p_bo->p_vendor->p_log;
-
- osm_log(p_log, OSM_LOG_DEBUG,
- "<-- Releasing lock %p on bind handle %p\n", p_lock, p_bo);
-
- cl_spinlock_release(&p_bo->lock);
-
- /* We'll use the saved ptrs, since now the p_bo can be destroyed already */
- osm_log(p_log, OSM_LOG_DEBUG,
- "<-- Released lock %p on bind handle %p\n", p_lock, p_bo);
-
-}
-
-static uint64_t
-__osmv_txn_timeout_cb(IN uint64_t key,
- IN uint32_t num_regs, IN void *cb_context)
-{
- osmv_bind_obj_t *p_bo = (osmv_bind_obj_t *) cb_context;
- uint64_t ret = 0;
- osmv_txn_ctx_t *p_txn;
- osmv_rmpp_send_ctx_t *p_send_ctx;
- osm_madw_t *p_madw = NULL;
- ib_mad_t *p_mad;
- osm_mad_addr_t *p_mad_addr;
- boolean_t invoke_err_cb = FALSE;
-
- OSM_LOG_ENTER(p_bo->p_vendor->p_log);
-
- /* Don't try to acquire a lock on the Bind Object -
- * it's taken by the mechanism that drives the timeout based events!
- * (Recall the special constructor that the Event Wheel is applied with)
- */
- if (p_bo->is_closing) {
- goto txn_done;
- }
-
- ret = osmv_txn_lookup(p_bo, key, &p_txn);
- if (IB_NOT_FOUND == ret) {
- /* Prevent a race - the transaction is already destroyed */
- goto txn_done;
- }
-
- p_madw = p_txn->p_madw;
-
- switch (osmv_txn_get_rmpp_state(p_txn)) {
-
- case OSMV_TXN_RMPP_NONE:
- if (num_regs <= OSMV_MAX_RETRANSMIT) {
- /* We still did not exceed the limit of retransmissions.
- * Set the next timeout's value.
- */
- osm_log(p_bo->p_vendor->p_log, OSM_LOG_DEBUG,
- "__osmv_txn_timeout_cb: "
- "The transaction request (tid=0x%llX) timed out %d times. "
- "Retrying the send.\n",
- osmv_txn_get_tid(p_txn), num_regs);
-
- /* resend this mad */
- ret = osmv_simple_send_madw((osm_bind_handle_t *) p_bo,
- p_madw, p_txn, TRUE);
- if (ret != IB_SUCCESS) {
- osm_log(p_bo->p_vendor->p_log, OSM_LOG_ERROR,
- "__osmv_txn_timeout_cb: "
- "Fail to send retry for transaction request (tid=0x%llX).\n",
- osmv_txn_get_tid(p_txn));
-
- osmv_txn_done((osm_bind_handle_t) p_bo, key,
- TRUE /*in timeout callback */ );
-
- /* This is a requester. Always apply the callback */
- invoke_err_cb = TRUE;
- } else {
- uint64_t next_timeout_ms;
- next_timeout_ms =
- p_bo->p_vendor->resp_timeout * (num_regs +
- 1) *
- (num_regs + 1);
- /* when do we need to timeout again */
- ret =
- cl_get_time_stamp() +
- (uint64_t) (1000 * next_timeout_ms);
-
- osm_log(p_bo->p_vendor->p_log, OSM_LOG_DEBUG,
- "__osmv_txn_timeout_cb: "
- "Retry request timout in : %lu [msec].\n",
- next_timeout_ms);
- }
- } else {
- osm_log(p_bo->p_vendor->p_log, OSM_LOG_ERROR,
- "__osmv_txn_timeout_cb: ERR 6702: "
- "The transaction request (tid=0x%llX) timed out (after %d retries). "
- "Invoking the error callback.\n",
- osmv_txn_get_tid(p_txn), num_regs);
-
- osmv_txn_done((osm_bind_handle_t) p_bo, key,
- TRUE /*in timeout callback */ );
-
- /* This is a requester. Always apply the callback */
- invoke_err_cb = TRUE;
- }
- break;
-
- case OSMV_TXN_RMPP_SENDER:
- osm_log(p_bo->p_vendor->p_log, OSM_LOG_DEBUG,
- "RMPP sender (tid=0x%llX) did not receive ACK "
- "on every segment in the current send window.\n",
- osmv_txn_get_tid(p_txn));
-
- p_send_ctx = osmv_txn_get_rmpp_send_ctx(p_txn);
- if (num_regs <= OSMV_MAX_RETRANSMIT) {
- /* We still did not exceed the limit of retransmissions.
- * Set the next timeout's value.
- */
- ret =
- cl_get_time_stamp() +
- 1000 * p_bo->p_vendor->resp_timeout;
- } else {
- p_send_ctx->status = IB_TIMEOUT;
-
- p_mad = osm_madw_get_mad_ptr(p_madw);
- p_mad_addr = osm_madw_get_mad_addr_ptr(p_madw);
-
- /* Send an ABORT to the other side */
- osmv_rmpp_send_nak((osm_bind_handle_t) p_bo, p_mad,
- p_mad_addr, IB_RMPP_TYPE_ABORT,
- IB_RMPP_STATUS_T2L);
- }
-
- /* Wake the RMPP sender thread up */
- cl_event_signal(&p_send_ctx->event);
- break;
-
- case OSMV_TXN_RMPP_RECEIVER:
- osm_log(p_bo->p_vendor->p_log, OSM_LOG_DEBUG,
- "Transaction timeout on an RMPP receiver (tid=0x%llX). "
- "Dropping the transaction.\n", osmv_txn_get_tid(p_txn));
-
- osmv_txn_done((osm_bind_handle_t) p_bo, key,
- TRUE /*in timeout callback */ );
-
- if (FALSE == osmv_txn_is_rmpp_init_by_peer(p_txn)) {
- /* This is a requester, still waiting for the reply. Apply the callback */
- invoke_err_cb = TRUE;
- }
-
- break;
-
- default:
- CL_ASSERT(FALSE);
- }
-
- if (TRUE == invoke_err_cb) {
- CL_ASSERT(NULL != p_madw);
- /* update the status in the p_madw */
- p_madw->status = IB_TIMEOUT;
- p_bo->send_err_cb(p_bo->cb_context, p_madw);
- /* no re-registration */
- ret = 0;
- }
-
-txn_done:
- OSM_LOG_EXIT(p_bo->p_vendor->p_log);
- return ret;
-}
diff --git a/contrib/ofed/management/opensm/libvendor/osm_vendor_mtl.c b/contrib/ofed/management/opensm/libvendor/osm_vendor_mtl.c
deleted file mode 100644
index 5fb05ef..0000000
--- a/contrib/ofed/management/opensm/libvendor/osm_vendor_mtl.c
+++ /dev/null
@@ -1,1105 +0,0 @@
-/*
- * Copyright (c) 2004-2008 Voltaire, Inc. All rights reserved.
- * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved.
- * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- */
-
-#if HAVE_CONFIG_H
-# include <config.h>
-#endif /* HAVE_CONFIG_H */
-
-#ifdef OSM_VENDOR_INTF_MTL
-
-#include <stdlib.h>
-#include <string.h>
-#include <opensm/osm_helper.h>
-#include <opensm/osm_log.h>
-/* HACK - I do not know how to prevent complib from loading kernel H files */
-#undef __init
-#include <vendor/osm_vendor_mtl.h>
-#include <vendor/osm_vendor_api.h>
-#include <opensm/osm_subnet.h>
-#include <opensm/osm_opensm.h>
-#include <vendor/osm_vendor_mtl_transaction_mgr.h>
-#include <vendor/osm_mtl_bind.h>
-
-/*
- Since a race can accure on requests. Meaning - a response is received before
- the send_callback is called - we will save both the madw_p and the fact
- whether or not it is a response. A race can occure only on requests that did
- not fail, and then the madw_p will be put back in the pool before the callback.
-*/
-uint64_t __osm_set_wrid_by_p_madw(IN osm_madw_t * p_madw)
-{
- uint64_t wrid = 0;
-
- CL_ASSERT(p_madw->p_mad);
-
- memcpy(&wrid, &p_madw, sizeof(osm_madw_t *));
- wrid = (wrid << 1) |
- ib_mad_is_response(p_madw->p_mad) |
- (p_madw->p_mad->method == IB_MAD_METHOD_TRAP_REPRESS);
- return wrid;
-}
-
-void
-__osm_set_p_madw_and_resp_by_wrid(IN uint64_t wrid,
- OUT uint8_t * is_resp,
- OUT osm_madw_t ** pp_madw)
-{
- *is_resp = wrid & 0x0000000000000001;
- wrid = wrid >> 1;
- memcpy(pp_madw, &wrid, sizeof(osm_madw_t *));
-}
-
-/**********************************************************************
- * IB_MGT to OSM ADDRESS VECTOR
- **********************************************************************/
-void
-__osm_mtl_conv_ibmgt_rcv_desc_to_osm_addr(IN osm_vendor_t * const p_vend,
- IN IB_MGT_mad_rcv_desc_t * p_rcv_desc,
- IN uint8_t is_smi,
- OUT osm_mad_addr_t * p_mad_addr)
-{
- /* p_mad_addr->dest_lid = p_osm->subn.sm_base_lid; - for resp we use the dest lid ... */
- p_mad_addr->dest_lid = cl_hton16(p_rcv_desc->remote_lid);
- p_mad_addr->static_rate = 0; /* HACK - we do not know the rate ! */
- p_mad_addr->path_bits = p_rcv_desc->local_path_bits;
- if (is_smi) {
- /* SMI */
- p_mad_addr->addr_type.smi.source_lid =
- cl_hton16(p_rcv_desc->remote_lid);
- p_mad_addr->addr_type.smi.port_num = 99; /* HACK - if used - should fail */
- } else {
- /* GSI */
- /* seems to me there is a IBMGT bug reversing the QPN ... */
- /* Does IBMGT supposed to provide the QPN is network or HOST ? */
- p_mad_addr->addr_type.gsi.remote_qp = cl_hton32(p_rcv_desc->qp);
-
- p_mad_addr->addr_type.gsi.remote_qkey = IB_QP1_WELL_KNOWN_Q_KEY;
- /* we do have the p_mad_addr->pkey_ix but how to get the PKey by index ? */
- /* the only way seems to be to use VAPI_query_hca_pkey_tbl and obtain */
- /* the full PKey table - than go by the index. */
- /* since this does not seem reasonable to me I simply use the default */
- /* There is a TAVOR limitation that only one P_KEY is supported per */
- /* QP - so QP1 must use IB_DEFAULT_PKEY */
- p_mad_addr->addr_type.gsi.pkey_ix = 0;
- p_mad_addr->addr_type.gsi.service_level = p_rcv_desc->sl;
-
- p_mad_addr->addr_type.gsi.global_route = p_rcv_desc->grh_flag;
- /* copy the GRH data if relevant */
- if (p_mad_addr->addr_type.gsi.global_route) {
- p_mad_addr->addr_type.gsi.grh_info.ver_class_flow =
- ib_grh_set_ver_class_flow(p_rcv_desc->grh.
- IP_version,
- p_rcv_desc->grh.
- traffic_class,
- p_rcv_desc->grh.
- flow_label);
- p_mad_addr->addr_type.gsi.grh_info.hop_limit =
- p_rcv_desc->grh.hop_limit;
- memcpy(&p_mad_addr->addr_type.gsi.grh_info.src_gid.raw,
- &p_rcv_desc->grh.sgid, sizeof(ib_net64_t));
- memcpy(&p_mad_addr->addr_type.gsi.grh_info.dest_gid.raw,
- p_rcv_desc->grh.dgid, sizeof(ib_net64_t));
- }
- }
-}
-
-/**********************************************************************
- * OSM ADDR VECTOR TO IB_MGT
- **********************************************************************/
-void
-__osm_mtl_conv_osm_addr_to_ibmgt_addr(IN osm_mad_addr_t * p_mad_addr,
- IN uint8_t is_smi, OUT IB_ud_av_t * p_av)
-{
-
- /* For global destination or Multicast address: */
- u_int8_t ver;
-
- memset(p_av, 0, sizeof(IB_ud_av_t));
-
- p_av->src_path_bits = p_mad_addr->path_bits;
- p_av->static_rate = p_mad_addr->static_rate;
- p_av->dlid = cl_ntoh16(p_mad_addr->dest_lid);
-
- if (is_smi) {
- p_av->sl = 0; /* Just to note we use 0 here. */
- } else {
- p_av->sl = p_mad_addr->addr_type.gsi.service_level;
- p_av->grh_flag = p_mad_addr->addr_type.gsi.global_route;
-
- if (p_mad_addr->addr_type.gsi.global_route) {
- ib_grh_get_ver_class_flow(p_mad_addr->addr_type.gsi.
- grh_info.ver_class_flow, &ver,
- &p_av->traffic_class,
- &p_av->flow_label);
- p_av->hop_limit =
- p_mad_addr->addr_type.gsi.grh_info.hop_limit;
- p_av->sgid_index = 0; /* we always use source GID 0 */
- memcpy(&p_av->dgid,
- &p_mad_addr->addr_type.gsi.grh_info.dest_gid.raw,
- sizeof(ib_net64_t));
-
- }
- }
-}
-
-/**********************************************************************
- **********************************************************************/
-void __osm_vendor_clear_sm(IN osm_bind_handle_t h_bind)
-{
- osm_mtl_bind_info_t *p_bind = (osm_mtl_bind_info_t *) h_bind;
- osm_vendor_t *p_vend = p_bind->p_vend;
- VAPI_ret_t status;
- VAPI_hca_attr_t attr_mod;
- VAPI_hca_attr_mask_t attr_mask;
-
- OSM_LOG_ENTER(p_vend->p_log);
-
- memset(&attr_mod, 0, sizeof(attr_mod));
- memset(&attr_mask, 0, sizeof(attr_mask));
-
- attr_mod.is_sm = FALSE;
- attr_mask = HCA_ATTR_IS_SM;
-
- status =
- VAPI_modify_hca_attr(p_bind->hca_hndl, p_bind->port_num, &attr_mod,
- &attr_mask);
- if (status != VAPI_OK) {
- osm_log(p_vend->p_log, OSM_LOG_ERROR,
- "__osm_vendor_clear_sm: ERR 3C21: "
- "Unable set 'IS_SM' bit in port attributes (%d).\n",
- status);
- }
-
- OSM_LOG_EXIT(p_vend->p_log);
-}
-
-/**********************************************************************
- * ANY CONSTRUCTION OF THE osm_vendor_t OBJECT
- **********************************************************************/
-void osm_vendor_construct(IN osm_vendor_t * const p_vend)
-{
- memset(p_vend, 0, sizeof(*p_vend));
-}
-
-/**********************************************************************
- * DEALOCATE osm_vendor_t
- **********************************************************************/
-void osm_vendor_destroy(IN osm_vendor_t * const p_vend)
-{
- osm_vendor_mgt_bind_t *vendor_mgt_bind_p;
- IB_MGT_ret_t mgt_ret;
- OSM_LOG_ENTER(p_vend->p_log);
-
- if (p_vend->h_al != NULL) {
- vendor_mgt_bind_p = (osm_vendor_mgt_bind_t *) p_vend->h_al;
- if (vendor_mgt_bind_p->gsi_init) {
-
- /* un register the class */
- /* HACK WE ASSUME WE ONLY GOT SA CLASS REGISTERD ON GSI !!! */
- mgt_ret =
- IB_MGT_unbind_gsi_class(vendor_mgt_bind_p->
- gsi_mads_hdl,
- IB_MCLASS_SUBN_ADM);
- if (mgt_ret != IB_MGT_OK) {
- osm_log(p_vend->p_log, OSM_LOG_ERROR,
- "osm_vendor_destroy: ERR 3C03: "
- "Fail to unbind the SA class.\n");
- }
-
- /* un bind the handle */
- if (IB_MGT_release_handle
- (vendor_mgt_bind_p->gsi_mads_hdl) != IB_MGT_OK) {
- osm_log(p_vend->p_log, OSM_LOG_ERROR,
- "osm_vendor_destroy: ERR 3C02: "
- "Fail to unbind the SA GSI handle.\n");
- }
- osm_log(p_vend->p_log, OSM_LOG_DEBUG,
- "osm_vendor_destroy: DBG 1002: "
- "Unbind the GSI handles.\n");
- }
- if (vendor_mgt_bind_p->smi_init) {
- /* first - clear the IS_SM in the capability mask */
- __osm_vendor_clear_sm((osm_bind_handle_t)
- (vendor_mgt_bind_p->smi_p_bind));
-
- /* un register the class */
- mgt_ret =
- IB_MGT_unbind_sm(vendor_mgt_bind_p->smi_mads_hdl);
- if (mgt_ret != IB_MGT_OK) {
- osm_log(p_vend->p_log, OSM_LOG_ERROR,
- "osm_vendor_destroy: ERR 3C04: "
- "Fail to unbind the SM class.\n");
- }
-
- /* un bind the handle */
- if (IB_MGT_release_handle
- (vendor_mgt_bind_p->smi_mads_hdl) != IB_MGT_OK) {
- osm_log(p_vend->p_log, OSM_LOG_ERROR,
- "osm_vendor_destroy: ERR 3C05: "
- "Fail to unbind the SMI handle.\n");
- }
- osm_log(p_vend->p_log, OSM_LOG_DEBUG,
- "osm_vendor_destroy: DBG 1003: "
- "Unbind the SMI handles.\n");
-
- }
- }
- osm_transaction_mgr_destroy(p_vend);
- /* __osm_mtl_destroy_tid_mad_map( p_vend ); */
- OSM_LOG_EXIT(p_vend->p_log);
-}
-
-/**********************************************************************
-DEALLOCATE A POINTER TO osm_vendor_t
-**********************************************************************/
-void osm_vendor_delete(IN osm_vendor_t ** const pp_vend)
-{
- CL_ASSERT(pp_vend);
-
- osm_vendor_destroy(*pp_vend);
- free(*pp_vend);
- *pp_vend = NULL;
-}
-
-/**********************************************************************
- * This proc actuall binds the handle to the lower level.
- *
- * We might have here as a result a casting of our struct to the ib_al_handle_t
- *
- * Q: Do we need 2 of those - one for MSI and one for GSI ?
- * A: Yes! We should be able to do the SA too. So we need a struct!
- *
- **********************************************************************/
-
-ib_api_status_t
-osm_vendor_init(IN osm_vendor_t * const p_vend,
- IN osm_log_t * const p_log, IN const uint32_t timeout)
-{
- osm_vendor_mgt_bind_t *ib_mgt_hdl_p;
- ib_api_status_t status = IB_SUCCESS;
-
- OSM_LOG_ENTER(p_log);
-
- p_vend->p_log = p_log;
-
- /*
- * HACK: We need no handle. Assuming the driver is up.
- */
- ib_mgt_hdl_p = (osm_vendor_mgt_bind_t *)
- malloc(sizeof(osm_vendor_mgt_bind_t));
- if (ib_mgt_hdl_p == NULL) {
- osm_log(p_vend->p_log, OSM_LOG_ERROR,
- "osm_vendor_init: ERR 3C06: "
- "Fail to allocate vendor mgt handle.\n");
- goto Exit;
- }
-
- ib_mgt_hdl_p->smi_init = FALSE;
- ib_mgt_hdl_p->gsi_init = FALSE;
- /* cast it into the ib_al_handle_t h_al */
- p_vend->h_al = (ib_al_handle_t) ib_mgt_hdl_p;
- p_vend->p_transaction_mgr = NULL;
- osm_transaction_mgr_init(p_vend);
- /* p_vend->madw_by_tid_map_p = NULL; */
- /* __osm_mtl_init_tid_mad_map( p_vend ); */
- p_vend->timeout = timeout;
-
-Exit:
- OSM_LOG_EXIT(p_log);
- return (status);
-}
-
-/**********************************************************************
- * Create and Initialize osm_vendor_t Object
- **********************************************************************/
-osm_vendor_t *osm_vendor_new(IN osm_log_t * const p_log,
- IN const uint32_t timeout)
-{
- ib_api_status_t status;
- osm_vendor_t *p_vend;
-
- OSM_LOG_ENTER(p_log);
-
- CL_ASSERT(p_log);
-
- p_vend = malloc(sizeof(*p_vend));
- if (p_vend != NULL) {
- memset(p_vend, 0, sizeof(*p_vend));
- status = osm_vendor_init(p_vend, p_log, timeout);
- if (status != IB_SUCCESS) {
- osm_vendor_delete(&p_vend);
- }
- } else {
- osm_log(p_vend->p_log, OSM_LOG_ERROR,
- "osm_vendor_new: ERR 3C07: "
- "Fail to allocate vendor object.\n");
- }
-
- OSM_LOG_EXIT(p_log);
- return (p_vend);
-}
-
-/**********************************************************************
- * IB_MGT RCV callback
- *
- **********************************************************************/
-void
-__osm_mtl_rcv_callback(IN IB_MGT_mad_hndl_t mad_hndl,
- IN void *private_ctx_p,
- IN void *payload_p,
- IN IB_MGT_mad_rcv_desc_t * rcv_remote_info_p)
-{
- IB_MGT_ret_t status;
- osm_mtl_bind_info_t *bind_info_p = private_ctx_p;
- osm_madw_t *req_madw_p = NULL;
- osm_madw_t *madw_p;
- osm_vend_wrap_t *p_new_vw;
- osm_mad_addr_t mad_addr;
- ib_mad_t *mad_buf_p;
- osm_log_t *const p_log = bind_info_p->p_vend->p_log;
-
- OSM_LOG_ENTER(p_log);
-
- /* if it is a response MAD we mustbe able to get the request */
- if (ib_mad_is_response((ib_mad_t *) payload_p)) {
- /* can we find a matching madw by this payload TID */
- status =
- osm_transaction_mgr_get_madw_for_tid(bind_info_p->p_vend,
- (ib_mad_t *) payload_p,
- &req_madw_p);
- if (status != IB_MGT_OK) {
- osm_log(p_log, OSM_LOG_ERROR,
- "__osm_mtl_rcv_callback: ERR 3C08: "
- "Error obtaining request madw by TID (%d).\n",
- status);
- req_madw_p = NULL;
- }
-
- if (req_madw_p == NULL) {
- osm_log(p_log, OSM_LOG_ERROR,
- "__osm_mtl_rcv_callback: ERR 3C09: "
- "Fail to obtain request madw for received MAD.(method=%X attr=%X) Aborting CB.\n",
- ((ib_mad_t *) payload_p)->method,
- cl_ntoh16(((ib_mad_t *) payload_p)->attr_id)
-
- );
- goto Exit;
- }
- }
-
- /* do we have a request ??? */
- if (req_madw_p == NULL) {
-
- /* first arrange an address */
- __osm_mtl_conv_ibmgt_rcv_desc_to_osm_addr(bind_info_p->p_vend,
- rcv_remote_info_p,
- (((ib_mad_t *)
- payload_p)->
- mgmt_class ==
- IB_MCLASS_SUBN_LID)
- || (((ib_mad_t *)
- payload_p)->
- mgmt_class ==
- IB_MCLASS_SUBN_DIR),
- &mad_addr);
-
- osm_log(p_log, OSM_LOG_ERROR,
- "__osm_mtl_rcv_callback: : "
- "Received MAD from QP:%X.\n",
- cl_ntoh32(mad_addr.addr_type.gsi.remote_qp)
- );
-
- /* if not - get new osm_madw and arrange it. */
- /* create the new madw in the pool */
- madw_p = osm_mad_pool_get(bind_info_p->p_osm_pool,
- (osm_bind_handle_t) bind_info_p,
- MAD_BLOCK_SIZE, &mad_addr);
- if (madw_p == NULL) {
- osm_log(p_log, OSM_LOG_ERROR,
- "__osm_mtl_rcv_callback: ERR 3C10: "
- "Error request for a new madw.\n");
- goto Exit;
- }
- /* HACK: we cust to avoid the const ??? */
- mad_buf_p = (void *)madw_p->p_mad;
- } else {
- /* we have the madw defined during the send and stored in the vend_wrap */
- /* we need to make sure the wrapper is correctly init there */
- CL_ASSERT(req_madw_p->vend_wrap.p_resp_madw != 0);
- madw_p = req_madw_p->vend_wrap.p_resp_madw;
-
- /* HACK: we do not Support RMPP */
- CL_ASSERT(madw_p->h_bind);
- mad_buf_p =
- osm_vendor_get(madw_p->h_bind, MAD_BLOCK_SIZE,
- &madw_p->vend_wrap);
-
- if (mad_buf_p == NULL) {
- osm_log(p_log, OSM_LOG_ERROR,
- "__osm_mtl_rcv_callback: ERR 3C11: "
- "Unable to acquire wire MAD.\n");
-
- goto Exit;
- }
-
- /*
- Finally, attach the wire MAD to this wrapper.
- */
- osm_madw_set_mad(madw_p, mad_buf_p);
-
- /* also we need to handle the size of the mad since we did not init ... */
- madw_p->mad_size = MAD_BLOCK_SIZE;
- }
-
- /* init some fields of the vendor wrapper */
- p_new_vw = osm_madw_get_vend_ptr(madw_p);
- p_new_vw->h_bind = bind_info_p;
- p_new_vw->size = MAD_BLOCK_SIZE;
- p_new_vw->p_resp_madw = NULL;
- p_new_vw->mad_buf_p = mad_buf_p;
-
- /* HACK: We do not support RMPP in receiving MADS */
- memcpy(p_new_vw->mad_buf_p, payload_p, MAD_BLOCK_SIZE);
-
- /* attach the buffer to the wrapper */
- madw_p->p_mad = mad_buf_p;
-
- /* we can also make sure we marked the size and bind on the returned madw */
- madw_p->h_bind = p_new_vw->h_bind;
-
- /* call the CB */
- (*bind_info_p->rcv_callback) (madw_p, bind_info_p->client_context,
- req_madw_p);
-
-Exit:
- OSM_LOG_EXIT(p_log);
-}
-
-/**********************************************************************
- * IB_MGT Send callback : invoked after each send
- *
- **********************************************************************/
-void
-__osm_mtl_send_callback(IN IB_MGT_mad_hndl_t mad_hndl,
- IN u_int64_t wrid,
- IN IB_comp_status_t status, IN void *private_ctx_p)
-{
- osm_madw_t *madw_p;
- osm_mtl_bind_info_t *bind_info_p =
- (osm_mtl_bind_info_t *) private_ctx_p;
- osm_log_t *const p_log = bind_info_p->p_vend->p_log;
- osm_vend_wrap_t *p_vw;
- uint8_t is_resp;
-
- OSM_LOG_ENTER(p_log);
-
- /* obtain the madp from the wrid */
- __osm_set_p_madw_and_resp_by_wrid(wrid, &is_resp, &madw_p);
-
- osm_log(p_log, OSM_LOG_DEBUG,
- "__osm_mtl_send_callback: INFO 1008: "
- "Handling Send of MADW:%p Is Resp:%d.\n", madw_p, is_resp);
-
- /* we need to handle requests and responses differently */
- if (is_resp) {
- if (status != IB_COMP_SUCCESS) {
- osm_log(p_log, OSM_LOG_ERROR,
- "__osm_mtl_send_callback: ERR 3C12: "
- "Error Sending Response MADW:%p.\n", madw_p);
- } else {
- osm_log(p_log, OSM_LOG_DEBUG,
- "__osm_mtl_send_callback: DBG 1008: "
- "Completed Sending Response MADW:%p.\n",
- madw_p);
- }
-
- /* if we are a response - we need to clean it up */
- osm_mad_pool_put(bind_info_p->p_osm_pool, madw_p);
- } else {
-
- /* this call back is invoked on completion of send - error or not */
- if (status != IB_COMP_SUCCESS) {
-
- osm_log(p_log, OSM_LOG_ERROR,
- "__osm_mtl_send_callback: ERR 3C13: "
- "Received an Error from IB_MGT Send (%d).\n",
- status);
-
- p_vw = osm_madw_get_vend_ptr(madw_p);
- CL_ASSERT(p_vw);
-
- /*
- Return any wrappers to the pool that may have been
- pre-emptively allocated to handle a receive.
- */
- if (p_vw->p_resp_madw) {
- osm_mad_pool_put(bind_info_p->p_osm_pool,
- p_vw->p_resp_madw);
- p_vw->p_resp_madw = NULL;
- }
-
- /* invoke the CB */
- (*bind_info_p->send_err_callback) (bind_info_p->
- client_context,
- madw_p);
- } else {
- /* successful request send - do nothing - the response will need the
- out mad */
- osm_log(p_log, OSM_LOG_DEBUG,
- "__osm_mtl_send_callback: DBG 1008: "
- "Completed Sending Request MADW:%p.\n", madw_p);
- }
- }
-
- OSM_LOG_EXIT(p_log);
-}
-
-/**********************************************************************
- * BINDs a callback (rcv and send error) for a given class and method
- * defined by the given: osm_bind_info_t
- **********************************************************************/
-osm_bind_handle_t
-osm_vendor_bind(IN osm_vendor_t * const p_vend,
- IN osm_bind_info_t * const p_user_bind,
- IN osm_mad_pool_t * const p_mad_pool,
- IN osm_vend_mad_recv_callback_t mad_recv_callback,
- IN osm_vend_mad_send_err_callback_t send_err_callback,
- IN void *context)
-{
- ib_net64_t port_guid;
- osm_mtl_bind_info_t *p_bind = NULL;
- VAPI_hca_hndl_t hca_hndl;
- VAPI_hca_id_t hca_id;
- IB_MGT_mad_type_t mad_type;
- uint32_t port_num;
- osm_vendor_mgt_bind_t *ib_mgt_hdl_p;
- IB_MGT_ret_t mgt_ret;
-
- OSM_LOG_ENTER(p_vend->p_log);
-
- CL_ASSERT(p_user_bind);
- CL_ASSERT(p_mad_pool);
- CL_ASSERT(mad_recv_callback);
- CL_ASSERT(send_err_callback);
-
- /* cast back the AL handle to vendor mgt bind */
- ib_mgt_hdl_p = (osm_vendor_mgt_bind_t *) p_vend->h_al;
-
- port_guid = p_user_bind->port_guid;
-
- osm_log(p_vend->p_log, OSM_LOG_INFO,
- "osm_vendor_bind: "
- "Binding to port 0x%" PRIx64 ".\n", cl_ntoh64(port_guid));
-
- /* obtain the hca name and port num from the guid */
- osm_log(p_vend->p_log, OSM_LOG_DEBUG,
- "osm_vendor_bind: "
- "Finding CA and Port that owns port guid 0x%" PRIx64 ".\n",
- port_guid);
-
- mgt_ret =
- osm_vendor_get_guid_ca_and_port(p_vend, port_guid, &hca_hndl,
- &hca_id, &port_num);
- if (mgt_ret != IB_MGT_OK) {
- osm_log(p_vend->p_log, OSM_LOG_ERROR,
- "osm_vendor_bind: ERR 3C14: "
- "Unable to obtain CA and port (%d).\n");
- goto Exit;
- }
-
- /* create the bind object tracking this binding */
- p_bind = (osm_mtl_bind_info_t *) malloc(sizeof(osm_mtl_bind_info_t));
- memset(p_bind, 0, sizeof(osm_mtl_bind_info_t));
- if (p_bind == NULL) {
- osm_log(p_vend->p_log, OSM_LOG_ERROR,
- "osm_vendor_bind: ERR 3C15: "
- "Unable to allocate internal bind object.\n");
- goto Exit;
- }
-
- /* track this bind request info */
- memcpy(p_bind->hca_id, hca_id, sizeof(VAPI_hca_id_t));
- p_bind->port_num = port_num;
- p_bind->p_vend = p_vend;
- p_bind->client_context = context;
- p_bind->rcv_callback = mad_recv_callback;
- p_bind->send_err_callback = send_err_callback;
- p_bind->p_osm_pool = p_mad_pool;
-
- CL_ASSERT(p_bind->port_num);
-
- /*
- * Get the proper CLASS
- */
-
- switch (p_user_bind->mad_class) {
- case IB_MCLASS_SUBN_LID:
- case IB_MCLASS_SUBN_DIR:
- mad_type = IB_MGT_SMI;
- break;
-
- case IB_MCLASS_SUBN_ADM:
- default:
- mad_type = IB_MGT_GSI;
- break;
- }
-
- /* we split here - based on the type of MADS GSI / SMI */
- /* HACK: we only support one class registration per SMI/GSI !!! */
- if (mad_type == IB_MGT_SMI) {
- /*
- * SMI CASE
- */
-
- /* we do not need to bind the handle if already available */
- if (ib_mgt_hdl_p->smi_init == FALSE) {
-
- /* First we have to reg and get the handle for the mad */
- osm_log(p_vend->p_log, OSM_LOG_ERROR,
- "osm_vendor_bind: "
- "Binding to IB_MGT SMI of %s port %u\n", hca_id,
- port_num);
-
- mgt_ret =
- IB_MGT_get_handle(hca_id, port_num, IB_MGT_SMI,
- &(ib_mgt_hdl_p->smi_mads_hdl));
- if (IB_MGT_OK != mgt_ret) {
- free(p_bind);
- p_bind = NULL;
- osm_log(p_vend->p_log, OSM_LOG_ERROR,
- "osm_vendor_bind: ERR 3C16: "
- "Error obtaining IB_MGT handle to SMI.\n");
- goto Exit;
- }
-
- /* bind it */
- mgt_ret = IB_MGT_bind_sm(ib_mgt_hdl_p->smi_mads_hdl);
- if (IB_MGT_OK != mgt_ret) {
- free(p_bind);
- p_bind = NULL;
- osm_log(p_vend->p_log, OSM_LOG_ERROR,
- "osm_vendor_bind: ERR 3C17: "
- "Error binding IB_MGT handle to SM.\n");
- goto Exit;
- }
-
- ib_mgt_hdl_p->smi_init = TRUE;
-
- }
-
- /* attach to this bind info */
- p_bind->mad_hndl = ib_mgt_hdl_p->smi_mads_hdl;
- ib_mgt_hdl_p->smi_p_bind = p_bind;
-
- /* now register the callback */
- mgt_ret = IB_MGT_reg_cb(p_bind->mad_hndl,
- &__osm_mtl_rcv_callback,
- p_bind,
- &__osm_mtl_send_callback,
- p_bind,
- IB_MGT_RCV_CB_MASK |
- IB_MGT_SEND_CB_MASK);
-
- } else {
- /*
- * GSI CASE
- */
-
- if (ib_mgt_hdl_p->gsi_init == FALSE) {
- osm_log(p_vend->p_log, OSM_LOG_ERROR,
- "osm_vendor_bind: " "Binding to IB_MGT GSI\n");
-
- /* First we have to reg and get the handle for the mad */
- mgt_ret =
- IB_MGT_get_handle(hca_id, port_num, IB_MGT_GSI,
- &(ib_mgt_hdl_p->gsi_mads_hdl));
- if (IB_MGT_OK != mgt_ret) {
- free(p_bind);
- p_bind = NULL;
- osm_log(p_vend->p_log, OSM_LOG_ERROR,
- "osm_vendor_bind: ERR 3C20: "
- "Error obtaining IB_MGT handle to GSI.\n");
- goto Exit;
- }
-
- /* bind it */
- mgt_ret =
- IB_MGT_bind_gsi_class(ib_mgt_hdl_p->gsi_mads_hdl,
- p_user_bind->mad_class);
- if (IB_MGT_OK != mgt_ret) {
- free(p_bind);
- p_bind = NULL;
- osm_log(p_vend->p_log, OSM_LOG_ERROR,
- "osm_vendor_bind: ERR 3C22: "
- "Error binding IB_MGT handle to GSI.\n");
- goto Exit;
- }
-
- ib_mgt_hdl_p->gsi_init = TRUE;
-
- /* attach to this bind info */
- p_bind->mad_hndl = ib_mgt_hdl_p->gsi_mads_hdl;
-
- /* now register the callback */
- mgt_ret = IB_MGT_reg_cb(p_bind->mad_hndl,
- &__osm_mtl_rcv_callback,
- p_bind,
- &__osm_mtl_send_callback,
- p_bind,
- IB_MGT_RCV_CB_MASK |
- IB_MGT_SEND_CB_MASK);
-
- } else {
- /* we can use the existing handle */
- p_bind->mad_hndl = ib_mgt_hdl_p->gsi_mads_hdl;
- mgt_ret = IB_MGT_OK;
- }
-
- }
-
- if (IB_MGT_OK != mgt_ret) {
- free(p_bind);
- p_bind = NULL;
- osm_log(p_vend->p_log, OSM_LOG_ERROR,
- "osm_vendor_bind: ERR 3C23: "
- "Error binding IB_MGT CB (%d).\n", mgt_ret);
- goto Exit;
- }
-
- /* HACK: Do we need to initialize an address vector ???? */
-
-Exit:
- OSM_LOG_EXIT(p_vend->p_log);
- return ((osm_bind_handle_t) p_bind);
-}
-
-/**********************************************************************
-Get a mad from the lower level.
-The osm_vend_wrap_t is a wrapper used to connect the mad to the response.
-**********************************************************************/
-ib_mad_t *osm_vendor_get(IN osm_bind_handle_t h_bind,
- IN const uint32_t mad_size,
- IN osm_vend_wrap_t * const p_vw)
-{
- ib_mad_t *mad_p;
- osm_mtl_bind_info_t *p_bind = (osm_mtl_bind_info_t *) h_bind;
- osm_vendor_t *p_vend = p_bind->p_vend;
-
- OSM_LOG_ENTER(p_vend->p_log);
-
- CL_ASSERT(p_vw);
- /* HACK: We know we can not send through IB_MGT */
- CL_ASSERT(mad_size <= MAD_BLOCK_SIZE);
-
- /* IB_MGT assumes it is 256 - we must follow */
- p_vw->size = MAD_BLOCK_SIZE;
-
- /* allocate it */
- mad_p = (ib_mad_t *) malloc(p_vw->size);
- if (mad_p == NULL) {
- osm_log(p_vend->p_log, OSM_LOG_ERROR,
- "osm_vendor_get: ERR 3C24: "
- "Error Obtaining MAD buffer.\n");
- goto Exit;
- }
-
- memset(mad_p, 0, p_vw->size);
-
- /* track locally */
- p_vw->mad_buf_p = mad_p;
- p_vw->h_bind = h_bind;
- p_vw->p_resp_madw = NULL;
-
- if (osm_log_get_level(p_vend->p_log) >= OSM_LOG_DEBUG) {
- osm_log(p_vend->p_log, OSM_LOG_DEBUG,
- "osm_vendor_get: "
- "Acquired MAD %p, size = %u.\n", mad_p, p_vw->size);
- }
-
-Exit:
- OSM_LOG_EXIT(p_vend->p_log);
- return (mad_p);
-}
-
-/**********************************************************************
- * Return a MAD by providing it's wrapper object.
- **********************************************************************/
-void
-osm_vendor_put(IN osm_bind_handle_t h_bind, IN osm_vend_wrap_t * const p_vw)
-{
- osm_mtl_bind_info_t *p_bind = (osm_mtl_bind_info_t *) h_bind;
- osm_vendor_t *p_vend = p_bind->p_vend;
- osm_madw_t *p_madw;
-
- OSM_LOG_ENTER(p_vend->p_log);
-
- CL_ASSERT(p_vw);
- CL_ASSERT(p_vw->mad_buf_p);
-
- if (osm_log_get_level(p_vend->p_log) >= OSM_LOG_DEBUG) {
- osm_log(p_vend->p_log, OSM_LOG_DEBUG,
- "osm_vendor_put: " "Retiring MAD %p.\n",
- p_vw->mad_buf_p);
- }
-
- /*
- * We moved the removal of the transaction to immediatly after
- * it was looked up.
- */
-
- /* free the mad but the wrapper is part of the madw object */
- free(p_vw->mad_buf_p);
- p_vw->mad_buf_p = NULL;
- p_madw = PARENT_STRUCT(p_vw, osm_madw_t, vend_wrap);
- p_madw->p_mad = NULL;
-
- OSM_LOG_EXIT(p_vend->p_log);
-}
-
-/**********************************************************************
-Actually Send a MAD
-
-This is for internal use by osm_vendor_send and the transaction mgr
-retry too.
-**********************************************************************/
-ib_api_status_t
-osm_mtl_send_mad(IN osm_mtl_bind_info_t * p_bind, IN osm_madw_t * const p_madw)
-{
- osm_vendor_t *const p_vend = p_bind->p_vend;
- osm_vend_wrap_t *const p_vw = osm_madw_get_vend_ptr(p_madw);
- osm_mad_addr_t *const p_mad_addr = osm_madw_get_mad_addr_ptr(p_madw);
- ib_mad_t *const p_mad = osm_madw_get_mad_ptr(p_madw);
- ib_api_status_t status;
- IB_MGT_ret_t mgt_res;
- IB_ud_av_t av;
- uint64_t wrid;
- uint32_t qpn;
-
- OSM_LOG_ENTER(p_vend->p_log);
-
- /*
- * For all sends other than directed route SM MADs,
- * acquire an address vector for the destination.
- */
- if (p_mad->mgmt_class != IB_MCLASS_SUBN_DIR) {
- __osm_mtl_conv_osm_addr_to_ibmgt_addr(p_mad_addr,
- p_mad->mgmt_class ==
- IB_MCLASS_SUBN_LID, &av);
- } else {
- /* is a directed route - we need to construct a permissive address */
- memset(&av, 0, sizeof(av));
- /* we do not need port number since it is part of the mad_hndl */
- av.dlid = IB_LID_PERMISSIVE;
- }
-
- wrid = __osm_set_wrid_by_p_madw(p_madw);
-
- /* send it */
- if ((p_mad->mgmt_class == IB_MCLASS_SUBN_DIR) ||
- (p_mad->mgmt_class == IB_MCLASS_SUBN_LID)) {
-
- /* SMI CASE */
- if (osm_log_is_active(p_vend->p_log, OSM_LOG_DEBUG)) {
- osm_log(p_vend->p_log, OSM_LOG_DEBUG,
- "osm_mtl_send_mad: "
- "av.dlid 0x%X, "
- "av.static_rate %d, "
- "av.path_bits %d.\n",
- cl_ntoh16(av.dlid), av.static_rate,
- av.src_path_bits);
- }
-
- mgt_res = IB_MGT_send_mad(p_bind->mad_hndl, p_mad, /* actual payload */
- &av, /* address vector */
- wrid, /* casting the mad wrapper pointer for err cb */
- p_vend->timeout);
-
- } else {
- /* GSI CASE - Support Remote QP */
- if (osm_log_is_active(p_vend->p_log, OSM_LOG_DEBUG)) {
- osm_log(p_vend->p_log, OSM_LOG_DEBUG,
- "osm_mtl_send_mad: "
- "av.dlid 0x%X, av.static_rate %d, "
- "av.path_bits %d, remote qp: 0x%06X \n",
- av.dlid,
- av.static_rate,
- av.src_path_bits,
- cl_ntoh32(p_mad_addr->addr_type.gsi.remote_qp)
- );
- }
-
- /* IBMGT have a bug sending to a QP not 1 -
- the QPN must be in network order except when it qpn 1 ... */
- qpn = cl_ntoh32(p_mad_addr->addr_type.gsi.remote_qp);
-
- mgt_res = IB_MGT_send_mad_to_qp(p_bind->mad_hndl, p_mad, /* actual payload */
- &av, /* address vector */
- wrid, /* casting the mad wrapper pointer for err cb */
- p_vend->timeout, qpn);
- }
-
- if (mgt_res != IB_MGT_OK) {
- osm_log(p_vend->p_log, OSM_LOG_ERROR,
- "osm_mtl_send_mad: ERR 3C26: "
- "Error sending mad (%d).\n", mgt_res);
- if (p_vw->p_resp_madw)
- osm_mad_pool_put(p_bind->p_osm_pool, p_vw->p_resp_madw);
- status = IB_ERROR;
- goto Exit;
- }
-
- status = IB_SUCCESS;
-
-Exit:
- OSM_LOG_EXIT(p_vend->p_log);
- return (status);
-}
-
-/**********************************************************************
-Send a MAD through.
-
-What is unclear to me is the need for the setting of all the MAD Wrapper
-fields. Seems like the OSM uses these values during it's processing...
-**********************************************************************/
-ib_api_status_t
-osm_vendor_send(IN osm_bind_handle_t h_bind,
- IN osm_madw_t * const p_madw, IN boolean_t const resp_expected)
-{
- osm_mtl_bind_info_t *const p_bind = (osm_mtl_bind_info_t *) h_bind;
- osm_vendor_t *const p_vend = p_bind->p_vend;
- osm_vend_wrap_t *const p_vw = osm_madw_get_vend_ptr(p_madw);
- ib_api_status_t status;
-
- OSM_LOG_ENTER(p_vend->p_log);
-
- /*
- * If a response is expected to this MAD, then preallocate
- * a mad wrapper to contain the wire MAD received in the
- * response. Allocating a wrapper here allows for easier
- * failure paths than after we already received the wire mad.
- */
- if (resp_expected == TRUE) {
- /* we track it in the vendor wrapper */
- p_vw->p_resp_madw =
- osm_mad_pool_get_wrapper_raw(p_bind->p_osm_pool);
- if (p_vw->p_resp_madw == NULL) {
- osm_log(p_vend->p_log, OSM_LOG_ERROR,
- "osm_vendor_send: ERR 3C27: "
- "Unable to allocate MAD wrapper.\n");
- status = IB_INSUFFICIENT_RESOURCES;
- goto Exit;
- }
-
- /* put some minimal info on that wrapper */
- ((osm_madw_t *) (p_vw->p_resp_madw))->h_bind = h_bind;
-
- /* we also want to track it in the TID based map */
- status = osm_transaction_mgr_insert_madw((osm_bind_handle_t)
- p_bind, p_madw);
- if (status != IB_SUCCESS) {
- osm_log(p_vend->p_log, OSM_LOG_ERROR,
- "osm_vendor_send: ERR 3C25: "
- "Error inserting request madw by TID (%d).\n",
- status);
- }
-
- } else
- p_vw->p_resp_madw = NULL;
-
- /* do the actual send */
- status = osm_mtl_send_mad(p_bind, p_madw);
-
-Exit:
- OSM_LOG_EXIT(p_vend->p_log);
- return (status);
-}
-
-/**********************************************************************
- * the idea here is to change the content of the bind such that it
- * will hold the local address used for sending directed route by the SMA.
- **********************************************************************/
-ib_api_status_t osm_vendor_local_lid_change(IN osm_bind_handle_t h_bind)
-{
- osm_vendor_t *p_vend = ((osm_mtl_bind_info_t *) h_bind)->p_vend;
-
- OSM_LOG_ENTER(p_vend->p_log);
-
- osm_log(p_vend->p_log, OSM_LOG_DEBUG,
- "osm_vendor_local_lid_change: DEBUG 2202: " "Change of LID.\n");
-
- OSM_LOG_EXIT(p_vend->p_log);
-
- return (IB_SUCCESS);
-}
-
-/**********************************************************************
- **********************************************************************/
-void osm_vendor_set_sm(IN osm_bind_handle_t h_bind, IN boolean_t is_sm_val)
-{
- osm_mtl_bind_info_t *p_bind = (osm_mtl_bind_info_t *) h_bind;
- osm_vendor_t *p_vend = p_bind->p_vend;
- VAPI_ret_t status;
- VAPI_hca_attr_t attr_mod;
- VAPI_hca_attr_mask_t attr_mask;
-
- OSM_LOG_ENTER(p_vend->p_log);
-
- memset(&attr_mod, 0, sizeof(attr_mod));
- memset(&attr_mask, 0, sizeof(attr_mask));
-
- attr_mod.is_sm = is_sm_val;
- attr_mask = HCA_ATTR_IS_SM;
-
- status =
- VAPI_modify_hca_attr(p_bind->hca_hndl, p_bind->port_num, &attr_mod,
- &attr_mask);
- if (status != VAPI_OK) {
- osm_log(p_vend->p_log, OSM_LOG_ERROR,
- "osm_vendor_set_sm: ERR 3C28: "
- "Unable set 'IS_SM' bit to:%u in port attributes (%d).\n",
- is_sm_val, status);
- }
-
- OSM_LOG_EXIT(p_vend->p_log);
-}
-
-/**********************************************************************
- **********************************************************************/
-void osm_vendor_set_debug(IN osm_vendor_t * const p_vend, IN int32_t level)
-{
-
-}
-
-#endif /* OSM_VENDOR_INTF_TEST */
diff --git a/contrib/ofed/management/opensm/libvendor/osm_vendor_mtl_hca_guid.c b/contrib/ofed/management/opensm/libvendor/osm_vendor_mtl_hca_guid.c
deleted file mode 100644
index d78af31..0000000
--- a/contrib/ofed/management/opensm/libvendor/osm_vendor_mtl_hca_guid.c
+++ /dev/null
@@ -1,635 +0,0 @@
-/*
- * Copyright (c) 2004-2006 Voltaire, Inc. All rights reserved.
- * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved.
- * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- */
-
-#if HAVE_CONFIG_H
-# include <config.h>
-#endif /* HAVE_CONFIG_H */
-
-#if defined(OSM_VENDOR_INTF_MTL) | defined(OSM_VENDOR_INTF_TS)
-#undef IN
-#undef OUT
-#include <stdlib.h>
-#include <vapi_types.h>
-#include <evapi.h>
-#include <vendor/osm_vendor_api.h>
-#include <opensm/osm_log.h>
-#include <stdio.h>
-
-/********************************************************************************
- *
- * Provide the functionality for selecting an HCA Port and Obtaining it's guid.
- *
- ********************************************************************************/
-
-/**********************************************************************
- * Convert the given GID to GUID by copy of it's upper 8 bytes
- *
- *
- **********************************************************************/
-
-ib_api_status_t
-__osm_vendor_gid_to_guid(IN u_int8_t * gid, OUT VAPI_gid_t * guid)
-{
- memcpy(guid, gid + 8, 8);
- return (IB_SUCCESS);
-}
-
-/****f* OpenSM: CA Info/osm_ca_info_get_pi_ptr
- * NAME
- * osm_ca_info_get_pi_ptr
- *
- * DESCRIPTION
- * Returns a pointer to the port attribute of the specified port
- * owned by this CA.
- *
- * SYNOPSIS
- */
-static ib_port_attr_t *__osm_ca_info_get_port_attr_ptr(IN const osm_ca_info_t *
- const p_ca_info,
- IN const uint8_t index)
-{
- return (&p_ca_info->p_attr->p_port_attr[index]);
-}
-
-/*
- * PARAMETERS
- * p_ca_info
- * [in] Pointer to a CA Info object.
- *
- * index
- * [in] Port "index" for which to retrieve the port attribute.
- * The index is the offset into the ca's internal array
- * of port attributes.
- *
- * RETURN VALUE
- * Returns a pointer to the port attribute of the specified port
- * owned by this CA.
- *
- * NOTES
- *
- * SEE ALSO
- *********/
-
-/********************************************************************************
- * get the CA names ava`ilable on the system
- * NOTE: user of this function needs to deallocate p_hca_ids after usage.
- ********************************************************************************/
-static ib_api_status_t
-__osm_vendor_get_ca_ids(IN osm_vendor_t * const p_vend,
- IN VAPI_hca_id_t ** const p_hca_ids,
- IN uint32_t * const p_num_guids)
-{
- ib_api_status_t status;
- VAPI_ret_t vapi_res;
-
- OSM_LOG_ENTER(p_vend->p_log);
-
- CL_ASSERT(p_hca_ids);
- CL_ASSERT(p_num_guids);
-
- /* first call is just to get the number */
- vapi_res = EVAPI_list_hcas(0, p_num_guids, NULL);
-
- /* fail ? */
- if (vapi_res == VAPI_EINVAL_PARAM) {
- osm_log(p_vend->p_log, OSM_LOG_ERROR,
- "__osm_vendor_get_ca_ids: ERR 7101: "
- "Bad parameter in calling: EVAPI_list_hcas. (%d)\n",
- vapi_res);
- status = IB_ERROR;
- goto Exit;
- }
-
- /* NO HCA ? */
- if (*p_num_guids == 0) {
- osm_log(p_vend->p_log, OSM_LOG_ERROR,
- "__osm_vendor_get_ca_ids: ERR 7102: "
- "No available channel adapters.\n");
- status = IB_INSUFFICIENT_RESOURCES;
- goto Exit;
- }
-
- /* allocate and really call - user of this function needs to deallocate it */
- *p_hca_ids =
- (VAPI_hca_id_t *) malloc(*p_num_guids * sizeof(VAPI_hca_id_t));
-
- /* now call it really */
- vapi_res = EVAPI_list_hcas(*p_num_guids, p_num_guids, *p_hca_ids);
-
- /* too many ? */
- if (vapi_res == VAPI_EAGAIN) {
- osm_log(p_vend->p_log, OSM_LOG_ERROR,
- "__osm_vendor_get_ca_ids: ERR 7103: "
- "More CA GUIDs than allocated array (%d).\n",
- *p_num_guids);
- status = IB_ERROR;
- goto Exit;
- }
-
- /* fail ? */
- if (vapi_res != VAPI_OK) {
- osm_log(p_vend->p_log, OSM_LOG_ERROR,
- "__osm_vendor_get_ca_ids: ERR 7104: "
- "Bad parameter in calling: EVAPI_list_hcas.\n");
- status = IB_ERROR;
- goto Exit;
- }
-
- if (osm_log_is_active(p_vend->p_log, OSM_LOG_DEBUG)) {
- osm_log(p_vend->p_log, OSM_LOG_DEBUG,
- "__osm_vendor_get_ca_ids: "
- "Detected %u local channel adapters.\n", *p_num_guids);
- }
-
- status = IB_SUCCESS;
-
-Exit:
- OSM_LOG_EXIT(p_vend->p_log);
- return (status);
-}
-
-/**********************************************************************
- * Initialize an Info Struct for the Given HCA by its Id
- **********************************************************************/
-static ib_api_status_t
-__osm_ca_info_init(IN osm_vendor_t * const p_vend,
- IN VAPI_hca_id_t ca_id, OUT osm_ca_info_t * const p_ca_info)
-{
- ib_api_status_t status = IB_ERROR;
- VAPI_ret_t vapi_res;
- VAPI_hca_hndl_t hca_hndl;
- VAPI_hca_vendor_t hca_vendor;
- VAPI_hca_cap_t hca_cap;
- VAPI_hca_port_t hca_port;
- uint8_t port_num;
- IB_gid_t *p_port_gid;
- uint16_t maxNumGids;
-
- OSM_LOG_ENTER(p_vend->p_log);
-
- /* get the HCA handle */
- vapi_res = EVAPI_get_hca_hndl(ca_id, &hca_hndl);
- if (vapi_res != VAPI_OK) {
- osm_log(p_vend->p_log, OSM_LOG_ERROR,
- "__osm_ca_info_init: ERR 7105: "
- "Fail to get HCA handle (%u).\n", vapi_res);
- goto Exit;
- }
-
- if (osm_log_is_active(p_vend->p_log, OSM_LOG_DEBUG)) {
- osm_log(p_vend->p_log, OSM_LOG_DEBUG,
- "__osm_ca_info_init: " "Querying CA %s.\n", ca_id);
- }
-
- /* query and get the HCA capability */
- vapi_res = VAPI_query_hca_cap(hca_hndl, &hca_vendor, &hca_cap);
- if (vapi_res != VAPI_OK) {
- osm_log(p_vend->p_log, OSM_LOG_ERROR,
- "__osm_ca_info_init: ERR 7106: "
- "Fail to get HCA Capabilities (%u).\n", vapi_res);
- goto Exit;
- }
-
- /* get the guid of the HCA */
- memcpy(&(p_ca_info->guid), hca_cap.node_guid, 8 * sizeof(u_int8_t));
- p_ca_info->attr_size = 1;
- p_ca_info->p_attr = (ib_ca_attr_t *) malloc(sizeof(ib_ca_attr_t));
- memcpy(&(p_ca_info->p_attr->ca_guid), hca_cap.node_guid,
- 8 * sizeof(u_int8_t));
-
- /* now obtain the attributes of the ports */
- p_ca_info->p_attr->num_ports = hca_cap.phys_port_num;
- p_ca_info->p_attr->p_port_attr =
- (ib_port_attr_t *) malloc(hca_cap.phys_port_num *
- sizeof(ib_port_attr_t));
-
- for (port_num = 0; port_num < p_ca_info->p_attr->num_ports; port_num++) {
-
- /* query the port attributes */
- vapi_res =
- VAPI_query_hca_port_prop(hca_hndl, port_num + 1, &hca_port);
- if (vapi_res != VAPI_OK) {
- osm_log(p_vend->p_log, OSM_LOG_ERROR,
- "__osm_ca_info_init: ERR 7107: "
- "Fail to get HCA Port Attributes (%d).\n",
- vapi_res);
- goto Exit;
- }
-
- /* first call to know the size of the gid table */
- vapi_res =
- VAPI_query_hca_gid_tbl(hca_hndl, port_num + 1, 0,
- &maxNumGids, NULL);
- p_port_gid = (IB_gid_t *) malloc(maxNumGids * sizeof(IB_gid_t));
-
- vapi_res =
- VAPI_query_hca_gid_tbl(hca_hndl, port_num + 1, maxNumGids,
- &maxNumGids, p_port_gid);
- if (vapi_res != VAPI_OK) {
- osm_log(p_vend->p_log, OSM_LOG_ERROR,
- "__osm_ca_info_init: ERR 7108: "
- "Fail to get HCA Port GID (%d).\n", vapi_res);
- goto Exit;
- }
-
- __osm_vendor_gid_to_guid(p_port_gid[0],
- (IB_gid_t *) & p_ca_info->p_attr->
- p_port_attr[port_num].port_guid);
- p_ca_info->p_attr->p_port_attr[port_num].lid = hca_port.lid;
- p_ca_info->p_attr->p_port_attr[port_num].link_state =
- hca_port.state;
- p_ca_info->p_attr->p_port_attr[port_num].sm_lid =
- hca_port.sm_lid;
-
- free(p_port_gid);
- }
-
- status = IB_SUCCESS;
-Exit:
- OSM_LOG_EXIT(p_vend->p_log);
- return (status);
-}
-
-/**********************************************************************
- **********************************************************************/
-void
-osm_ca_info_destroy(IN osm_vendor_t * const p_vend,
- IN osm_ca_info_t * const p_ca_info)
-{
- OSM_LOG_ENTER(p_vend->p_log);
-
- if (p_ca_info->p_attr) {
- if (p_ca_info->p_attr->num_ports) {
- free(p_ca_info->p_attr->p_port_attr);
- }
- free(p_ca_info->p_attr);
- }
-
- free(p_ca_info);
-
- OSM_LOG_EXIT(p_vend->p_log);
-}
-
-/**********************************************************************
- * Fill in the array of port_attr with all available ports on ALL the
- * avilable CAs on this machine.
- * ALSO -
- * UPDATE THE VENDOR OBJECT LIST OF CA_INFO STRUCTS
- **********************************************************************/
-ib_api_status_t
-osm_vendor_get_all_port_attr(IN osm_vendor_t * const p_vend,
- IN ib_port_attr_t * const p_attr_array,
- IN uint32_t * const p_num_ports)
-{
- ib_api_status_t status;
-
- uint32_t ca;
- uint32_t ca_count;
- uint32_t port_count = 0;
- uint8_t port_num;
- uint32_t total_ports = 0;
- VAPI_hca_id_t *p_ca_ids = NULL;
- osm_ca_info_t *p_ca_info;
-
- OSM_LOG_ENTER(p_vend->p_log);
-
- CL_ASSERT(p_vend);
-
- /*
- * 1) Determine the number of CA's
- * 2) Allocate an array big enough to hold the ca info objects.
- * 3) Call again to retrieve the guids.
- */
- status = __osm_vendor_get_ca_ids(p_vend, &p_ca_ids, &ca_count);
- if (status != IB_SUCCESS) {
- osm_log(p_vend->p_log, OSM_LOG_ERROR,
- "osm_vendor_get_all_port_attr: ERR 7109: "
- "Fail to get CA Ids.\n");
- goto Exit;
- }
-
- /* we keep track of all the CAs in this info array */
- p_vend->p_ca_info = malloc(ca_count * sizeof(*p_vend->p_ca_info));
- if (p_vend->p_ca_info == NULL) {
- osm_log(p_vend->p_log, OSM_LOG_ERROR,
- "osm_vendor_get_all_port_attr: ERR 7110: "
- "Unable to allocate CA information array.\n");
- goto Exit;
- }
-
- memset(p_vend->p_ca_info, 0, ca_count * sizeof(*p_vend->p_ca_info));
- p_vend->ca_count = ca_count;
-
- /*
- * For each CA, retrieve the CA info attributes
- */
- for (ca = 0; ca < ca_count; ca++) {
- p_ca_info = &p_vend->p_ca_info[ca];
-
- status = __osm_ca_info_init(p_vend, p_ca_ids[ca], p_ca_info);
-
- if (status != IB_SUCCESS) {
- osm_log(p_vend->p_log, OSM_LOG_ERROR,
- "osm_vendor_get_all_port_attr: ERR 7111: "
- "Unable to initialize CA Info object (%s).\n",
- ib_get_err_str(status));
- }
-
- total_ports += osm_ca_info_get_num_ports(p_ca_info);
-
- osm_log(p_vend->p_log, OSM_LOG_DEBUG,
- "osm_vendor_get_all_port_attr: "
- "osm_vendor_get_all_port_attr: %u got %u ports total:%u\n",
- ca, osm_ca_info_get_num_ports(p_ca_info), total_ports);
-
- }
-
- /*
- * If the user supplied enough storage, return the port guids,
- * otherwise, return the appropriate error.
- */
- if (*p_num_ports >= total_ports) {
- for (ca = 0; ca < ca_count; ca++) {
- uint32_t num_ports;
-
- p_ca_info = &p_vend->p_ca_info[ca];
-
- num_ports = osm_ca_info_get_num_ports(p_ca_info);
-
- for (port_num = 0; port_num < num_ports; port_num++) {
- p_attr_array[port_count] =
- *__osm_ca_info_get_port_attr_ptr(p_ca_info,
- port_num);
- port_count++;
- }
- }
- } else {
- status = IB_INSUFFICIENT_MEMORY;
- goto Exit;
- }
-
- status = IB_SUCCESS;
-
-Exit:
- *p_num_ports = total_ports;
-
- if (p_ca_ids)
- free(p_ca_ids);
-
- OSM_LOG_EXIT(p_vend->p_log);
- return (status);
-}
-
-/**********************************************************************
- * Given the vendor obj and a guid
- * return the ca id and port number that have that guid
- **********************************************************************/
-
-ib_api_status_t
-osm_vendor_get_guid_ca_and_port(IN osm_vendor_t * const p_vend,
- IN ib_net64_t const guid,
- OUT VAPI_hca_hndl_t * p_hca_hndl,
- OUT VAPI_hca_id_t * p_hca_id,
- OUT uint32_t * p_port_num)
-{
-
- ib_api_status_t status;
- VAPI_hca_id_t *p_ca_ids = NULL;
- VAPI_ret_t vapi_res;
- VAPI_hca_hndl_t hca_hndl;
- VAPI_hca_vendor_t hca_vendor;
- VAPI_hca_cap_t hca_cap;
- IB_gid_t *p_port_gid = NULL;
- uint16_t maxNumGids;
- ib_net64_t port_guid;
- uint32_t ca, portIdx, ca_count;
-
- OSM_LOG_ENTER(p_vend->p_log);
-
- CL_ASSERT(p_vend);
-
- /*
- * 1) Determine the number of CA's
- * 2) Allocate an array big enough to hold the ca info objects.
- * 3) Call again to retrieve the guids.
- */
- status = __osm_vendor_get_ca_ids(p_vend, &p_ca_ids, &ca_count);
- if (status != IB_SUCCESS) {
- osm_log(p_vend->p_log, OSM_LOG_ERROR,
- "osm_vendor_get_guid_ca_and_port: ERR 7112: "
- "Fail to get CA Ids.\n");
- goto Exit;
- }
-
- /*
- * For each CA, retrieve the CA info attributes
- */
- for (ca = 0; ca < ca_count; ca++) {
- /* get the HCA handle */
- vapi_res = EVAPI_get_hca_hndl(p_ca_ids[ca], &hca_hndl);
- if (vapi_res != VAPI_OK) {
- osm_log(p_vend->p_log, OSM_LOG_ERROR,
- "osm_vendor_get_guid_ca_and_port: ERR 7113: "
- "Fail to get HCA handle (%u).\n", vapi_res);
- goto Exit;
- }
-
- /* get the CA attributes - to know how many ports it has: */
- if (osm_log_is_active(p_vend->p_log, OSM_LOG_DEBUG)) {
- osm_log(p_vend->p_log, OSM_LOG_DEBUG,
- "osm_vendor_get_guid_ca_and_port: "
- "Querying CA %s.\n", p_ca_ids[ca]);
- }
-
- /* query and get the HCA capability */
- vapi_res = VAPI_query_hca_cap(hca_hndl, &hca_vendor, &hca_cap);
- if (vapi_res != VAPI_OK) {
- osm_log(p_vend->p_log, OSM_LOG_ERROR,
- "osm_vendor_get_guid_ca_and_port: ERR 7114: "
- "Fail to get HCA Capabilities (%u).\n",
- vapi_res);
- goto Exit;
- }
-
- /* go over all ports - to obtail their guids */
- for (portIdx = 0; portIdx < hca_cap.phys_port_num; portIdx++) {
- vapi_res =
- VAPI_query_hca_gid_tbl(hca_hndl, portIdx + 1, 0,
- &maxNumGids, NULL);
- p_port_gid =
- (IB_gid_t *) malloc(maxNumGids * sizeof(IB_gid_t));
-
- /* get the port guid */
- vapi_res =
- VAPI_query_hca_gid_tbl(hca_hndl, portIdx + 1,
- maxNumGids, &maxNumGids,
- p_port_gid);
- if (vapi_res != VAPI_OK) {
- osm_log(p_vend->p_log, OSM_LOG_ERROR,
- "osm_vendor_get_guid_ca_and_port: ERR 7115: "
- "Fail to get HCA Port GID (%d).\n",
- vapi_res);
- goto Exit;
- }
-
- /* convert to SF style */
- __osm_vendor_gid_to_guid(p_port_gid[0],
- (VAPI_gid_t *) & port_guid);
-
- /* finally did we find it ? */
- if (port_guid == guid) {
- *p_hca_hndl = hca_hndl;
- memcpy(p_hca_id, p_ca_ids[ca],
- sizeof(VAPI_hca_id_t));
- *p_port_num = portIdx + 1;
- status = IB_SUCCESS;
- goto Exit;
- }
-
- free(p_port_gid);
- p_port_gid = NULL;
- } /* ALL PORTS */
- } /* all HCAs */
-
- osm_log(p_vend->p_log, OSM_LOG_ERROR,
- "osm_vendor_get_guid_ca_and_port: ERR 7116: "
- "Fail to find HCA and Port for Port Guid 0x%" PRIx64 "\n",
- cl_ntoh64(guid));
- status = IB_INVALID_GUID;
-
-Exit:
- if (p_ca_ids != NULL)
- free(p_ca_ids);
- if (p_port_gid != NULL)
- free(p_port_gid);
- OSM_LOG_EXIT(p_vend->p_log);
- return (status);
-}
-
-#ifdef __TEST_HCA_GUID__
-
-#define GUID_ARRAY_SIZE 64
-
-#include <stdio.h>
-
-/**********************************************************************
- **********************************************************************/
-ib_net64_t get_port_guid()
-{
- uint32_t i;
- uint32_t choice = 0;
- boolean_t done_flag = FALSE;
- ib_api_status_t status;
- uint32_t num_ports = GUID_ARRAY_SIZE;
- ib_port_attr_t attr_array[GUID_ARRAY_SIZE];
- VAPI_hca_id_t ca_id;
- uint32_t portNum;
- osm_vendor_t vend;
- osm_vendor_t *p_vend;
- osm_log_t *p_osm_log, tlog;
-
- p_osm_log = &tlog;
-
- status = osm_log_init(p_osm_log, FALSE);
- if (status != IB_SUCCESS)
- return (status);
-
- osm_log(p_osm_log, OSM_LOG_FUNCS, "get_port_guid: [\n");
-
- p_vend = &vend;
- p_vend->p_log = p_osm_log;
-
- /*
- * Call the transport layer for a list of local port
- * GUID values.
- */
- status = osm_vendor_get_all_port_attr(p_vend, attr_array, &num_ports);
- if (status != IB_SUCCESS) {
- printf("\nError from osm_opensm_init (%x)\n", status);
- return (0);
- }
-
- if (num_ports == 0) {
- printf("\nNo local ports detected!\n");
- return (0);
- }
-
- while (done_flag == FALSE) {
- printf("\nChoose a local port number with which to bind:\n\n");
- for (i = 0; i < num_ports; i++) {
- /*
- * Print the index + 1 since by convention, port numbers
- * start with 1 on host channel adapters.
- */
-
- printf("\t%u: GUID = 0x%8" PRIx64
- ", lid = 0x%04X, state = %s\n", i + 1,
- cl_ntoh64(attr_array[i].port_guid),
- cl_ntoh16(attr_array[i].lid),
- ib_get_port_state_str(attr_array[i].link_state));
- }
-
- printf("\nEnter choice (1-%u): ", i);
- fflush(stdout);
- scanf("%u", &choice);
- if (choice > num_ports)
- printf("\nError: Lame choice!\n");
- else
- done_flag = TRUE;
- }
-
- status =
- osm_vendor_get_guid_ca_and_port(p_vend,
- attr_array[choice - 1].port_guid,
- &ca_id, &portNum);
- if (status != IB_SUCCESS) {
- printf("Error obtaining back the HCA and Port\n");
- return (0);
- }
-
- printf("Selected: CA:%s Port:%d\n", ca_id, portNum);
-
- return (attr_array[choice - 1].port_guid);
-}
-
-int main(int argc, char **argv)
-{
- get_port_guid();
- return (0);
-}
-
-#endif
-
-#endif
diff --git a/contrib/ofed/management/opensm/libvendor/osm_vendor_mtl_transaction_mgr.c b/contrib/ofed/management/opensm/libvendor/osm_vendor_mtl_transaction_mgr.c
deleted file mode 100644
index 6e8afb0..0000000
--- a/contrib/ofed/management/opensm/libvendor/osm_vendor_mtl_transaction_mgr.c
+++ /dev/null
@@ -1,546 +0,0 @@
-/*
- * Copyright (c) 2004-2006 Voltaire, Inc. All rights reserved.
- * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved.
- * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- */
-
-#if HAVE_CONFIG_H
-# include <config.h>
-#endif /* HAVE_CONFIG_H */
-
-#include <math.h>
-#include <stdlib.h>
-#include <opensm/osm_helper.h>
-#include <opensm/osm_log.h>
-#include <vendor/osm_vendor.h>
-#include <vendor/osm_vendor_api.h>
-#include <opensm/osm_mad_pool.h>
-
-#if defined(OSM_VENDOR_INTF_MTL) | defined(OSM_VENDOR_INTF_TS)
-
-#include <vendor/osm_vendor_mtl_transaction_mgr.h>
-#ifdef OSM_VENDOR_INTF_MTL
-#include <vendor/osm_mtl_bind.h>
-#endif
-
-/* this is the callback function of the timer */
-void __osm_transaction_mgr_callback(IN void *context)
-{
- osm_transaction_mgr_t *trans_mgr_p;
- osm_vendor_t *p_vend = (osm_vendor_t *) context;
- cl_list_item_t *p_list_item;
- cl_list_item_t *p_list_next_item;
- osm_madw_req_t *osm_madw_req_p;
- uint64_t current_time; /* [usec] */
- uint32_t new_timeout; /* [msec] */
- cl_status_t cl_status;
- ib_mad_t *p_mad;
-#ifdef OSM_VENDOR_INTF_MTL
- osm_mtl_bind_info_t *p_bind;
-#else
- osm_ts_bind_info_t *p_bind;
-#endif
- cl_list_t tmp_madw_p_list; /* this list will include all the madw_p that should be removed. */
- cl_list_t retry_madw_p_list; /* this list will include all the madw_p that were retried and need to be removed. */
- osm_madw_t *madw_p;
-
- OSM_LOG_ENTER(p_vend->p_log);
-
- trans_mgr_p = (osm_transaction_mgr_t *) p_vend->p_transaction_mgr;
-
- /* initialize the tmp_madw_p_list */
- cl_list_construct(&tmp_madw_p_list);
- cl_status = cl_list_init(&tmp_madw_p_list, 50);
- if (cl_status != CL_SUCCESS) {
- osm_log(p_vend->p_log, OSM_LOG_ERROR,
- "__osm_transaction_mgr_callback : ERROR 1000: "
- "Failed to create tmp_madw_p_list\n");
- }
-
- cl_list_construct(&retry_madw_p_list);
- cl_status = cl_list_init(&retry_madw_p_list, 50);
- if (cl_status != CL_SUCCESS) {
- osm_log(p_vend->p_log, OSM_LOG_ERROR,
- "__osm_transaction_mgr_callback : ERROR 1000: "
- "Failed to create retry_madw_p_list\n");
- }
-
- current_time = cl_get_time_stamp();
- cl_spinlock_acquire(&(trans_mgr_p->transaction_mgr_lock));
- p_list_item = cl_qlist_head(trans_mgr_p->madw_reqs_list_p);
- if (p_list_item == cl_qlist_end(trans_mgr_p->madw_reqs_list_p)) {
- /* the list is empty - nothing to do */
- cl_spinlock_release(&trans_mgr_p->transaction_mgr_lock);
- osm_log(p_vend->p_log, OSM_LOG_DEBUG,
- "__osm_transaction_mgr_callback : Nothing to do\n");
- goto Exit;
- }
-
- /* non empty list: */
-
- /* get the osm_madw_req_p */
- osm_madw_req_p = PARENT_STRUCT(p_list_item, osm_madw_req_t, list_item);
-
- while (osm_madw_req_p->waking_time <= current_time) {
- /* this object was supposed to have gotten a response */
- /* we need to decide if we need to retry or done with it. */
- if (osm_madw_req_p->retry_cnt > 0) {
- /* add to the list of the retrys : */
- cl_list_insert_tail(&retry_madw_p_list, osm_madw_req_p);
-
- /* update wakeup time and retry count */
- osm_madw_req_p->waking_time =
- p_vend->timeout * 1000 + cl_get_time_stamp();
- osm_madw_req_p->retry_cnt--;
-
- /* make sure we will get some timer call if not earlier */
- osm_log(p_vend->p_log, OSM_LOG_DEBUG,
- "__osm_transaction_mgr_callback : Timer restart:%u\n",
- p_vend->timeout);
-
- cl_status =
- cl_timer_start(&trans_mgr_p->madw_list_timer,
- p_vend->timeout);
-
- /* go to the next object and check if it also needs to be removed - didn't receive response */
- /* we need to do it before we move current item to the end of the list */
- p_list_next_item = cl_qlist_next(p_list_item);
-
- /* remove from the head */
- cl_qlist_remove_item(trans_mgr_p->madw_reqs_list_p,
- &(osm_madw_req_p->list_item));
-
- /* insert the object to the qlist and the qmap */
- cl_qlist_insert_tail(trans_mgr_p->madw_reqs_list_p,
- &(osm_madw_req_p->list_item));
-
- } else {
- /* go to the next object and check if it also needs to be removed - didn't receive response */
- p_list_next_item = cl_qlist_next(p_list_item);
-
- /* remove from the head */
- cl_qlist_remove_item(trans_mgr_p->madw_reqs_list_p,
- &(osm_madw_req_p->list_item));
-
- /* add it to the tmp_madw_p_list to be removed */
- cl_list_insert_tail(&tmp_madw_p_list,
- osm_madw_req_p->p_madw);
- osm_log(p_vend->p_log, OSM_LOG_DEBUG,
- "__osm_transaction_mgr_callback : Found failed transaction madw: %p\n",
- osm_madw_req_p->p_madw);
- }
-
- /* Advance */
- p_list_item = p_list_next_item;
- if (p_list_item == cl_qlist_end(trans_mgr_p->madw_reqs_list_p)) {
- /* the list is empty - nothing to do */
- break;
- }
-
- /* get the osm_madw_req_p */
- osm_madw_req_p =
- PARENT_STRUCT(p_list_item, osm_madw_req_t, list_item);
- }
-
- /* look at the current p_list_item. If it is not the end item - then we need to */
- /* re-start the timer */
- if (p_list_item != cl_qlist_end(trans_mgr_p->madw_reqs_list_p)) {
- /* get the osm_madw_req_p */
- osm_madw_req_p =
- PARENT_STRUCT(p_list_item, osm_madw_req_t, list_item);
-
- /* we have the object that still didn't get response - re-start the timer */
- /* start the timer to the timeout (in miliseconds) */
- new_timeout =
- (osm_madw_req_p->waking_time - cl_get_time_stamp()) / 1000 +
- 1;
- cl_status =
- cl_timer_start(&trans_mgr_p->madw_list_timer, new_timeout);
- osm_log(p_vend->p_log, OSM_LOG_DEBUG,
- "__osm_transaction_mgr_callback : Timer restart:%u\n",
- new_timeout);
-
- if (cl_status != CL_SUCCESS) {
- osm_log(p_vend->p_log, OSM_LOG_ERROR,
- "__osm_transaction_mgr_callback : ERROR 1000: "
- "Failed to start timer\n");
- }
- }
- /* if not empty - retry on retry list: */
- if (!cl_is_list_empty(&retry_madw_p_list)) {
-
- /* remove all elements that were retried: */
- osm_madw_req_p =
- (osm_madw_req_t
- *) (cl_list_remove_head(&retry_madw_p_list));
- while (osm_madw_req_p != NULL) {
-
- /* resend: */
- osm_log(p_vend->p_log, OSM_LOG_DEBUG,
- "__osm_transaction_mgr_callback : "
- "Retry %d of madw %p\n",
- OSM_DEFAULT_RETRY_COUNT -
- osm_madw_req_p->retry_cnt,
- osm_madw_req_p->p_madw);
-
- /* actually send it */
-#ifdef OSM_VENDOR_INTF_MTL
- osm_mtl_send_mad((osm_mtl_bind_info_t *)
- osm_madw_req_p->p_bind,
- osm_madw_req_p->p_madw);
-#else
- ib_api_status_t
- osm_ts_send_mad(osm_ts_bind_info_t * p_bind,
- osm_madw_t * const p_madw);
- osm_ts_send_mad((osm_ts_bind_info_t *) osm_madw_req_p->
- p_bind, osm_madw_req_p->p_madw);
-#endif
- /* next one */
- osm_madw_req_p =
- (osm_madw_req_t
- *) (cl_list_remove_head(&retry_madw_p_list));
- }
- }
-
- /* if the tmp_madw_p_list has elements - need to call the send_err_callback */
- madw_p = (osm_madw_t *) (cl_list_remove_head(&tmp_madw_p_list));
- while (madw_p != NULL) {
- /* need to remove it from pool */
-
- /* obtain the madw_p stored as the wrid in the send call */
- p_mad = osm_madw_get_mad_ptr(madw_p);
- p_bind = madw_p->h_bind;
- /*
- Return any wrappers to the pool that may have been
- pre-emptively allocated to handle a receive.
- */
- if (madw_p->vend_wrap.p_resp_madw) {
-#ifdef OSM_VENDOR_INTF_MTL
- osm_mad_pool_put(p_bind->p_osm_pool,
- madw_p->vend_wrap.p_resp_madw);
-#else
- osm_mad_pool_put(p_bind->p_osm_pool,
- madw_p->vend_wrap.p_resp_madw);
-#endif
- madw_p->vend_wrap.p_resp_madw = NULL;
- }
-
- /* invoke the CB */
- (*(osm_vend_mad_send_err_callback_t)
- (p_bind->send_err_callback)) (p_bind->client_context, madw_p);
- madw_p = (osm_madw_t *) (cl_list_remove_head(&tmp_madw_p_list));
- }
-
-Exit:
- OSM_LOG_EXIT(p_vend->p_log);
-
-}
-
-/*
- * Construct and Initialize
- */
-
-void osm_transaction_mgr_init(IN osm_vendor_t * const p_vend)
-{
- cl_status_t cl_status;
- osm_transaction_mgr_t *trans_mgr_p;
- OSM_LOG_ENTER(p_vend->p_log);
-
- CL_ASSERT(p_vend->p_transaction_mgr == NULL);
-
- (osm_transaction_mgr_t *) p_vend->p_transaction_mgr =
- (osm_transaction_mgr_t *) malloc(sizeof(osm_transaction_mgr_t));
-
- trans_mgr_p = (osm_transaction_mgr_t *) p_vend->p_transaction_mgr;
-
- /* construct lock object */
- cl_spinlock_construct(&(trans_mgr_p->transaction_mgr_lock));
- CL_ASSERT(cl_spinlock_init(&(trans_mgr_p->transaction_mgr_lock)) ==
- CL_SUCCESS);
-
- /* initialize the qlist */
- trans_mgr_p->madw_reqs_list_p =
- (cl_qlist_t *) malloc(sizeof(cl_qlist_t));
- cl_qlist_init(trans_mgr_p->madw_reqs_list_p);
-
- /* initialize the qmap */
- trans_mgr_p->madw_by_tid_map_p =
- (cl_qmap_t *) malloc(sizeof(cl_qmap_t));
- cl_qmap_init(trans_mgr_p->madw_by_tid_map_p);
-
- /* create the timer used by the madw_req_list */
- cl_timer_construct(&(trans_mgr_p->madw_list_timer));
-
- /* init the timer with timeout. */
- cl_status = cl_timer_init(&trans_mgr_p->madw_list_timer,
- __osm_transaction_mgr_callback, p_vend);
-
- if (cl_status != CL_SUCCESS) {
- osm_log(p_vend->p_log, OSM_LOG_ERROR,
- "osm_transaction_mgr_init : ERROR 1000: "
- "Failed to initialize madw_reqs_list timer\n");
- }
- OSM_LOG_EXIT(p_vend->p_log);
-}
-
-void osm_transaction_mgr_destroy(IN osm_vendor_t * const p_vend)
-{
- osm_transaction_mgr_t *trans_mgr_p;
- cl_list_item_t *p_list_item;
- cl_map_item_t *p_map_item;
- osm_madw_req_t *osm_madw_req_p;
-
- OSM_LOG_ENTER(p_vend->p_log);
-
- trans_mgr_p = (osm_transaction_mgr_t *) p_vend->p_transaction_mgr;
-
- if (p_vend->p_transaction_mgr != NULL) {
- /* we need to get a lock */
- cl_spinlock_acquire(&trans_mgr_p->transaction_mgr_lock);
-
- /* go over all the items in the list and remove them */
- p_list_item =
- cl_qlist_remove_head(trans_mgr_p->madw_reqs_list_p);
- while (p_list_item !=
- cl_qlist_end(trans_mgr_p->madw_reqs_list_p)) {
- osm_madw_req_p = (osm_madw_req_t *) p_list_item;
-
- if (osm_madw_req_p->p_madw->p_mad)
- osm_log(p_vend->p_log, OSM_LOG_DEBUG,
- "osm_transaction_mgr_destroy: "
- "Found outstanding MADW:%p TID:<0x%"
- PRIx64 ">.\n", osm_madw_req_p->p_madw,
- osm_madw_req_p->p_madw->p_mad->
- trans_id);
- else
- osm_log(p_vend->p_log, OSM_LOG_DEBUG,
- "osm_transaction_mgr_destroy: "
- "Found outstanding MADW:%p TID:UNDEFINED.\n",
- osm_madw_req_p->p_madw);
-
- /* each item - remove it from the map */
- p_map_item = &(osm_madw_req_p->map_item);
- cl_qmap_remove_item(trans_mgr_p->madw_by_tid_map_p,
- p_map_item);
- /* free the item */
- free(osm_madw_req_p);
- p_list_item =
- cl_qlist_remove_head(trans_mgr_p->madw_reqs_list_p);
- }
- /* free the qlist and qmap */
- free(trans_mgr_p->madw_reqs_list_p);
- free(trans_mgr_p->madw_by_tid_map_p);
- /* reliease and destroy the lock */
- cl_spinlock_release(&trans_mgr_p->transaction_mgr_lock);
- cl_spinlock_destroy(&(trans_mgr_p->transaction_mgr_lock));
- /* destroy the timer */
- cl_timer_trim(&trans_mgr_p->madw_list_timer, 1);
- cl_timer_destroy(&trans_mgr_p->madw_list_timer);
- /* free the transaction_manager object */
- free(trans_mgr_p);
- trans_mgr_p = NULL;
- }
-
- OSM_LOG_EXIT(p_vend->p_log);
-}
-
-ib_api_status_t
-osm_transaction_mgr_insert_madw(IN osm_bind_handle_t * const p_bind,
- IN osm_madw_t * p_madw)
-{
-#ifdef OSM_VENDOR_INTF_MTL
- osm_vendor_t *const p_vend = ((osm_mtl_bind_info_t *) p_bind)->p_vend;
-#else
- osm_vendor_t *const p_vend = ((osm_ts_bind_info_t *) p_bind)->p_vend;
-#endif
- osm_transaction_mgr_t *trans_mgr_p;
- osm_madw_req_t *osm_madw_req_p;
- uint64_t timeout;
- uint64_t waking_time;
- cl_status_t cl_status;
- uint64_t key;
- const ib_mad_t *mad_p = p_madw->p_mad;
-
- OSM_LOG_ENTER(p_vend->p_log);
-
- CL_ASSERT(mad_p);
-
- trans_mgr_p = (osm_transaction_mgr_t *) p_vend->p_transaction_mgr;
-
- timeout = (uint64_t) (p_vend->timeout) * 1000; /* change the miliseconds value of timeout to microseconds. */
- waking_time = timeout + cl_get_time_stamp();
-
- osm_madw_req_p = (osm_madw_req_t *) malloc(sizeof(osm_madw_req_t));
-
- osm_madw_req_p->p_madw = p_madw;
- osm_madw_req_p->waking_time = waking_time;
- osm_madw_req_p->retry_cnt = OSM_DEFAULT_RETRY_COUNT;
- osm_madw_req_p->p_bind = p_bind;
-
- osm_log(p_vend->p_log, OSM_LOG_DEBUG,
- "osm_transaction_mgr_insert_madw: "
- "Inserting MADW:%p with waking_time: <0x%" PRIx64 "> TID:<0x%"
- PRIx64 ">.\n", p_madw, waking_time, p_madw->p_mad->trans_id);
-
- /* Get the lock on the manager */
- cl_spinlock_acquire(&(trans_mgr_p->transaction_mgr_lock));
- /* If the list is empty - need to start the timer with timer of timeout (in miliseconds) */
- if (cl_is_qlist_empty(trans_mgr_p->madw_reqs_list_p)) {
- /* stop the timer if it is running */
- cl_timer_stop(&trans_mgr_p->madw_list_timer);
-
- /* start the timer to the timeout (in miliseconds) */
- cl_status = cl_timer_start(&trans_mgr_p->madw_list_timer,
- p_vend->timeout);
- if (cl_status != CL_SUCCESS) {
- osm_log(p_vend->p_log, OSM_LOG_ERROR,
- "osm_transaction_mgr_insert_madw : ERROR 1000: "
- "Failed to start timer\n");
- }
- }
-
- /* insert the object to the qlist and the qmap */
- cl_qlist_insert_tail(trans_mgr_p->madw_reqs_list_p,
- &(osm_madw_req_p->list_item));
- /* get the key */
- key = (uint64_t) mad_p->trans_id;
- cl_qmap_insert(trans_mgr_p->madw_by_tid_map_p, key,
- &(osm_madw_req_p->map_item));
- cl_spinlock_release(&trans_mgr_p->transaction_mgr_lock);
-
- OSM_LOG_EXIT(p_vend->p_log);
-
- return (IB_SUCCESS);
-}
-
-ib_api_status_t
-osm_transaction_mgr_erase_madw(IN osm_vendor_t * const p_vend,
- IN ib_mad_t * p_mad)
-{
- osm_transaction_mgr_t *trans_mgr_p;
- osm_madw_req_t *osm_madw_req_p;
- uint64_t key;
- cl_map_item_t *p_map_item;
- OSM_LOG_ENTER(p_vend->p_log);
-
- trans_mgr_p = (osm_transaction_mgr_t *) p_vend->p_transaction_mgr;
-
- key = (uint64_t) p_mad->trans_id;
- osm_log(p_vend->p_log, OSM_LOG_DEBUG,
- "osm_transaction_mgr_erase_madw: "
- "Removing TID:<0x%" PRIx64 ">.\n", p_mad->trans_id);
-
- cl_spinlock_acquire(&trans_mgr_p->transaction_mgr_lock);
- p_map_item = cl_qmap_get(trans_mgr_p->madw_by_tid_map_p, key);
- if (p_map_item != cl_qmap_end(trans_mgr_p->madw_by_tid_map_p)) {
- /* we found such an item. */
- /* get the osm_madw_req_p */
- osm_madw_req_p =
- PARENT_STRUCT(p_map_item, osm_madw_req_t, map_item);
-
- /* remove the item from the qlist */
- cl_qlist_remove_item(trans_mgr_p->madw_reqs_list_p,
- &(osm_madw_req_p->list_item));
- /* remove the item from the qmap */
- cl_qmap_remove_item(trans_mgr_p->madw_by_tid_map_p,
- &(osm_madw_req_p->map_item));
-
- osm_log(p_vend->p_log, OSM_LOG_DEBUG,
- "osm_transaction_mgr_erase_madw: "
- "Removed TID:<0x%" PRIx64 ">.\n", p_mad->trans_id);
-
- /* free the item */
- free(osm_madw_req_p);
- } else {
- osm_log(p_vend->p_log, OSM_LOG_DEBUG,
- "osm_transaction_mgr_erase_madw: "
- "osm_transaction_mgr_erase_madw:<0x%" PRIx64
- "> NOT FOUND.\n", p_mad->trans_id);
- }
- cl_spinlock_release(&trans_mgr_p->transaction_mgr_lock);
- OSM_LOG_EXIT(p_vend->p_log);
-
- return (IB_SUCCESS);
-}
-
-ib_api_status_t
-osm_transaction_mgr_get_madw_for_tid(IN osm_vendor_t * const p_vend,
- IN ib_mad_t * const p_mad,
- OUT osm_madw_t ** req_madw_p)
-{
- osm_transaction_mgr_t *trans_mgr_p;
- osm_madw_req_t *osm_madw_req_p;
- cl_map_item_t *p_map_item;
- uint64_t key;
- OSM_LOG_ENTER(p_vend->p_log);
-
- trans_mgr_p = (osm_transaction_mgr_t *) p_vend->p_transaction_mgr;
-
- *req_madw_p = NULL;
-
- osm_log(p_vend->p_log, OSM_LOG_DEBUG,
- "osm_transaction_mgr_get_madw_for_tid: "
- "Looking for TID:<0x%" PRIx64 ">.\n", p_mad->trans_id);
-
- key = (uint64_t) p_mad->trans_id;
- cl_spinlock_acquire(&(trans_mgr_p->transaction_mgr_lock));
- p_map_item = cl_qmap_get(trans_mgr_p->madw_by_tid_map_p, key);
- if (p_map_item != cl_qmap_end(trans_mgr_p->madw_by_tid_map_p)) {
- /* we found such an item. */
- /* get the osm_madw_req_p */
- osm_madw_req_p =
- PARENT_STRUCT(p_map_item, osm_madw_req_t, map_item);
-
- /* Since the Transaction was looked up and provided for */
- /* processing we retire it */
- cl_qlist_remove_item(trans_mgr_p->madw_reqs_list_p,
- &(osm_madw_req_p->list_item));
- /* remove the item from the qmap */
- cl_qmap_remove_item(trans_mgr_p->madw_by_tid_map_p,
- &(osm_madw_req_p->map_item));
-
- osm_log(p_vend->p_log, OSM_LOG_DEBUG,
- "osm_transaction_mgr_get_madw_for_tid: "
- "Removed TID:<0x%" PRIx64 ">.\n", p_mad->trans_id);
-
- *req_madw_p = osm_madw_req_p->p_madw;
- }
-
- cl_spinlock_release(&(trans_mgr_p->transaction_mgr_lock));
- osm_log(p_vend->p_log, OSM_LOG_DEBUG,
- "osm_transaction_mgr_get_madw_for_tid: "
- "Got MADW:%p.\n", *req_madw_p);
- OSM_LOG_EXIT(p_vend->p_log);
- return (IB_SUCCESS);
-}
-
-#endif
diff --git a/contrib/ofed/management/opensm/libvendor/osm_vendor_test.c b/contrib/ofed/management/opensm/libvendor/osm_vendor_test.c
deleted file mode 100644
index 67fc0e2..0000000
--- a/contrib/ofed/management/opensm/libvendor/osm_vendor_test.c
+++ /dev/null
@@ -1,282 +0,0 @@
-/*
- * Copyright (c) 2004-2006 Voltaire, Inc. All rights reserved.
- * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved.
- * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- */
-
-/*
- * Abstract:
- * Implementation of vendor specific transport interface.
- * This is the "Test" vendor which allows compilation and some
- * testing without a real vendor interface.
- * These objects are part of the opensm family of objects.
- *
- */
-
-#if HAVE_CONFIG_H
-# include <config.h>
-#endif /* HAVE_CONFIG_H */
-
-#ifdef OSM_VENDOR_INTF_TEST
-
-#include <stdlib.h>
-#include <string.h>
-#include <opensm/osm_log.h>
-#include <vendor/osm_vendor_test.h>
-#include <vendor/osm_vendor_api.h>
-
-/**********************************************************************
- **********************************************************************/
-void osm_vendor_construct(IN osm_vendor_t * const p_vend)
-{
- memset(p_vend, 0, sizeof(*p_vend));
-}
-
-/**********************************************************************
- **********************************************************************/
-void osm_vendor_destroy(IN osm_vendor_t * const p_vend)
-{
- UNUSED_PARAM(p_vend);
-}
-
-/**********************************************************************
- **********************************************************************/
-void osm_vendor_delete(IN osm_vendor_t ** const pp_vend)
-{
- CL_ASSERT(pp_vend);
-
- osm_vendor_destroy(*pp_vend);
- free(*pp_vend);
- *pp_vend = NULL;
-}
-
-/**********************************************************************
- **********************************************************************/
-ib_api_status_t
-osm_vendor_init(IN osm_vendor_t * const p_vend,
- IN osm_log_t * const p_log, IN const uint32_t timeout)
-{
- OSM_LOG_ENTER(p_log);
-
- CL_ASSERT(p_vend);
- CL_ASSERT(p_log);
-
- p_vend->p_log = p_log;
- p_vend->timeout = timeout;
- OSM_LOG_EXIT(p_log);
- return (IB_SUCCESS);
-}
-
-/**********************************************************************
- **********************************************************************/
-osm_vendor_t *osm_vendor_new(IN osm_log_t * const p_log,
- IN const uint32_t timeout)
-{
- ib_api_status_t status;
- osm_vendor_t *p_vend;
- OSM_LOG_ENTER(p_log);
-
- CL_ASSERT(p_log);
-
- p_vend = malloc(sizeof(*p_vend));
- if (p_vend != NULL) {
- memset(p_vend, 0, sizeof(*p_vend));
-
- status = osm_vendor_init(p_vend, p_log, timeout);
- if (status != IB_SUCCESS) {
- osm_vendor_delete(&p_vend);
- }
- }
-
- OSM_LOG_EXIT(p_log);
- return (p_vend);
-}
-
-/**********************************************************************
- **********************************************************************/
-ib_mad_t *osm_vendor_get(IN osm_bind_handle_t h_bind,
- IN const uint32_t size,
- IN osm_vend_wrap_t * const p_vend_wrap)
-{
- osm_vendor_t *p_vend;
- ib_mad_t *p_mad;
- OSM_LOG_ENTER(h_bind->p_vend->p_log);
-
- UNUSED_PARAM(p_vend_wrap);
-
- p_vend = h_bind->p_vend;
-
- /*
- Simply malloc the MAD off the heap.
- */
- p_mad = (ib_mad_t *) malloc(size);
-
- osm_log(p_vend->p_log, OSM_LOG_VERBOSE,
- "osm_vendor_get: " "MAD %p.\n", p_mad);
-
- if (p_mad)
- memset(p_mad, 0, size);
-
- OSM_LOG_EXIT(p_vend->p_log);
- return (p_mad);
-}
-
-/**********************************************************************
- **********************************************************************/
-void
-osm_vendor_put(IN osm_bind_handle_t h_bind,
- IN osm_vend_wrap_t * const p_vend_wrap,
- IN ib_mad_t * const p_mad)
-{
- osm_vendor_t *p_vend;
-
- OSM_LOG_ENTER(h_bind->p_vend->p_log);
-
- UNUSED_PARAM(p_vend_wrap);
-
- p_vend = h_bind->p_vend;
-
- osm_log(p_vend->p_log, OSM_LOG_VERBOSE,
- "osm_vendor_put: " "MAD %p.\n", p_mad);
-
- /*
- Return the MAD to the heap.
- */
- free(p_mad);
-
- OSM_LOG_EXIT(p_vend->p_log);
-}
-
-/**********************************************************************
- **********************************************************************/
-ib_api_status_t
-osm_vendor_send(IN osm_bind_handle_t h_bind,
- IN osm_vend_wrap_t * const p_vend_wrap,
- IN osm_mad_addr_t * const p_mad_addr,
- IN ib_mad_t * const p_mad,
- IN void *transaction_context, IN boolean_t const resp_expected)
-{
- osm_vendor_t *p_vend = h_bind->p_vend;
-
- OSM_LOG_ENTER(p_vend->p_log);
-
- UNUSED_PARAM(p_vend_wrap);
- UNUSED_PARAM(p_mad_addr);
- UNUSED_PARAM(transaction_context);
- UNUSED_PARAM(resp_expected);
-
- osm_log(p_vend->p_log, OSM_LOG_VERBOSE,
- "osm_vendor_send: " "MAD %p.\n", p_mad);
-
- OSM_LOG_EXIT(p_vend->p_log);
- return (IB_SUCCESS);
-}
-
-/**********************************************************************
- **********************************************************************/
-osm_bind_handle_t
-osm_vendor_bind(IN osm_vendor_t * const p_vend,
- IN osm_bind_info_t * const p_bind_info,
- IN osm_mad_pool_t * const p_mad_pool,
- IN osm_vend_mad_recv_callback_t mad_recv_callback,
- IN void *context)
-{
- osm_bind_handle_t h_bind;
-
- OSM_LOG_ENTER(p_vend->p_log);
-
- CL_ASSERT(p_vend);
- CL_ASSERT(p_bind_info);
- CL_ASSERT(p_mad_pool);
- CL_ASSERT(mad_recv_callback);
- CL_ASSERT(context);
-
- UNUSED_PARAM(p_vend);
- UNUSED_PARAM(p_mad_pool);
- UNUSED_PARAM(mad_recv_callback);
- UNUSED_PARAM(context);
-
- h_bind = (osm_bind_handle_t) malloc(sizeof(*h_bind));
- if (h_bind != NULL) {
- memset(h_bind, 0, sizeof(*h_bind));
- h_bind->p_vend = p_vend;
- h_bind->port_guid = p_bind_info->port_guid;
- h_bind->mad_class = p_bind_info->mad_class;
- h_bind->class_version = p_bind_info->class_version;
- h_bind->is_responder = p_bind_info->is_responder;
- h_bind->is_trap_processor = p_bind_info->is_trap_processor;
- h_bind->is_report_processor = p_bind_info->is_report_processor;
- h_bind->send_q_size = p_bind_info->send_q_size;
- h_bind->recv_q_size = p_bind_info->recv_q_size;
- }
-
- OSM_LOG_EXIT(p_vend->p_log);
- return (h_bind);
-}
-
-/**********************************************************************
- **********************************************************************/
-ib_api_status_t
-osm_vendor_get_ports(IN osm_vendor_t * const p_vend,
- IN ib_net64_t * const p_guids,
- IN uint32_t * const num_guids)
-{
- OSM_LOG_ENTER(p_vend->p_log);
-
- *p_guids = CL_NTOH64(0x0000000000001234);
- *num_guids = 1;
-
- OSM_LOG_EXIT(p_vend->p_log);
- return (IB_SUCCESS);
-}
-
-/**********************************************************************
- **********************************************************************/
-ib_api_status_t osm_vendor_local_lid_change(IN osm_bind_handle_t h_bind)
-{
- osm_vendor_t *p_vend = h_bind->p_vend;
-
- OSM_LOG_ENTER(p_vend->p_log);
-
- OSM_LOG_EXIT(p_vend->p_log);
-
- return (IB_SUCCESS);
-}
-
-/**********************************************************************
- **********************************************************************/
-void osm_vendor_set_debug(IN osm_vendor_t * const p_vend, IN int32_t level)
-{
-
-}
-
-#endif /* OSM_VENDOR_INTF_TEST */
diff --git a/contrib/ofed/management/opensm/libvendor/osm_vendor_ts.c b/contrib/ofed/management/opensm/libvendor/osm_vendor_ts.c
deleted file mode 100644
index 710d06f..0000000
--- a/contrib/ofed/management/opensm/libvendor/osm_vendor_ts.c
+++ /dev/null
@@ -1,904 +0,0 @@
-/*
- * Copyright (c) 2004-2008 Voltaire, Inc. All rights reserved.
- * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved.
- * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- */
-
-#undef __init
-#if HAVE_CONFIG_H
-# include <config.h>
-#endif /* HAVE_CONFIG_H */
-
-#include <stdlib.h>
-#include <string.h>
-#include <vendor/osm_vendor_ts.h>
-#include <vendor/osm_vendor_api.h>
-#include <vendor/osm_ts_useraccess.h>
-#include <opensm/osm_subnet.h>
-#include <opensm/osm_opensm.h>
-
-/*
- Since a race can accure on requests. Meaning - a response is received before
- the send_callback is called - we will save both the madw_p and the fact
- whether or not it is a response. A race can occure only on requests that did
- not fail, and then the madw_p will be put back in the pool before the
- callback.
-*/
-uint64_t __osm_set_wrid_by_p_madw(IN osm_madw_t * p_madw)
-{
- uint64_t wrid = 0;
-
- CL_ASSERT(p_madw->p_mad);
-
- memcpy(&wrid, &p_madw, sizeof(osm_madw_t *));
- wrid = (wrid << 1) |
- ib_mad_is_response(p_madw->p_mad) |
- (p_madw->p_mad->method == IB_MAD_METHOD_TRAP_REPRESS);
- return wrid;
-}
-
-void
-__osm_set_p_madw_and_resp_by_wrid(IN uint64_t wrid,
- OUT uint8_t * is_resp,
- OUT osm_madw_t ** pp_madw)
-{
- *is_resp = wrid & 0x0000000000000001;
- wrid = wrid >> 1;
- memcpy(pp_madw, &wrid, sizeof(osm_madw_t *));
-}
-
-/**********************************************************************
- * TS MAD to OSM ADDRESS VECTOR
- **********************************************************************/
-void
-__osm_ts_conv_mad_rcv_desc_to_osm_addr(IN osm_vendor_t * const p_vend,
- IN struct ib_mad *p_mad,
- IN uint8_t is_smi,
- OUT osm_mad_addr_t * p_mad_addr)
-{
- p_mad_addr->dest_lid = cl_hton16(p_mad->slid);
- p_mad_addr->static_rate = 0; /* HACK - we do not know the rate ! */
- p_mad_addr->path_bits = 0; /* HACK - no way to know in TS */
- if (is_smi) {
- /* SMI */
- p_mad_addr->addr_type.smi.source_lid = cl_hton16(p_mad->slid);
- p_mad_addr->addr_type.smi.port_num = p_mad->port;
- } else {
- /* GSI */
- p_mad_addr->addr_type.gsi.remote_qp = p_mad->sqpn;
- p_mad_addr->addr_type.gsi.remote_qkey = IB_QP1_WELL_KNOWN_Q_KEY;
- p_mad_addr->addr_type.gsi.pkey_ix = p_mad->pkey_index;
- p_mad_addr->addr_type.gsi.service_level = 0; /* HACK no way to know */
-
- p_mad_addr->addr_type.gsi.global_route = FALSE; /* HACK no way to know */
- /* copy the GRH data if relevant */
- /*
- if (p_mad_addr->addr_type.gsi.global_route)
- {
- p_mad_addr->addr_type.gsi.grh_info.ver_class_flow =
- ib_grh_set_ver_class_flow(p_rcv_desc->grh.IP_version,
- p_rcv_desc->grh.traffic_class,
- p_rcv_desc->grh.flow_label);
- p_mad_addr->addr_type.gsi.grh_info.hop_limit = p_rcv_desc->grh.hop_limit;
- memcpy(&p_mad_addr->addr_type.gsi.grh_info.src_gid.raw,
- &p_rcv_desc->grh.sgid, sizeof(ib_net64_t));
- memcpy(&p_mad_addr->addr_type.gsi.grh_info.dest_gid.raw,
- p_rcv_desc->grh.dgid, sizeof(ib_net64_t));
- }
- */
- }
-}
-
-/**********************************************************************
- * OSM ADDR VECTOR TO TS MAD:
- **********************************************************************/
-void
-__osm_ts_conv_osm_addr_to_ts_addr(IN osm_mad_addr_t * p_mad_addr,
- IN uint8_t is_smi, OUT struct ib_mad *p_mad)
-{
-
- /* For global destination or Multicast address: */
- p_mad->dlid = cl_ntoh16(p_mad_addr->dest_lid);
- p_mad->sl = 0;
- if (is_smi) {
- p_mad->sqpn = 0;
- p_mad->dqpn = 0;
- } else {
- p_mad->sqpn = 1;
- p_mad->dqpn = p_mad_addr->addr_type.gsi.remote_qp;
- }
-}
-
-/**********************************************************************
- **********************************************************************/
-void __osm_vendor_clear_sm(IN osm_bind_handle_t h_bind)
-{
- osm_ts_bind_info_t *p_bind = (osm_ts_bind_info_t *) h_bind;
- osm_vendor_t *p_vend = p_bind->p_vend;
- VAPI_ret_t status;
- VAPI_hca_attr_t attr_mod;
- VAPI_hca_attr_mask_t attr_mask;
-
- OSM_LOG_ENTER(p_vend->p_log);
-
- memset(&attr_mod, 0, sizeof(attr_mod));
- memset(&attr_mask, 0, sizeof(attr_mask));
-
- attr_mod.is_sm = FALSE;
- attr_mask = HCA_ATTR_IS_SM;
-
- status =
- VAPI_modify_hca_attr(p_bind->hca_hndl, p_bind->port_num, &attr_mod,
- &attr_mask);
- if (status != VAPI_OK) {
- osm_log(p_vend->p_log, OSM_LOG_ERROR,
- "__osm_vendor_clear_sm: ERR 5021: "
- "Unable set 'IS_SM' bit in port attributes (%d).\n",
- status);
- }
-
- OSM_LOG_EXIT(p_vend->p_log);
-}
-
-/**********************************************************************
- * ANY CONSTRUCTION OF THE osm_vendor_t OBJECT
- **********************************************************************/
-void osm_vendor_construct(IN osm_vendor_t * const p_vend)
-{
- memset(p_vend, 0, sizeof(*p_vend));
- cl_thread_construct(&(p_vend->smi_bind.poller));
- cl_thread_construct(&(p_vend->gsi_bind.poller));
-}
-
-/**********************************************************************
- * DEALOCATE osm_vendor_t
- **********************************************************************/
-void osm_vendor_destroy(IN osm_vendor_t * const p_vend)
-{
- OSM_LOG_ENTER(p_vend->p_log);
- osm_transaction_mgr_destroy(p_vend);
-
- /* Destroy the poller threads */
- /* HACK: can you destroy an un-initialized thread ? */
- pthread_cancel(p_vend->smi_bind.poller.osd.id);
- pthread_cancel(p_vend->gsi_bind.poller.osd.id);
- cl_thread_destroy(&(p_vend->smi_bind.poller));
- cl_thread_destroy(&(p_vend->gsi_bind.poller));
- OSM_LOG_EXIT(p_vend->p_log);
-}
-
-/**********************************************************************
-DEALLOCATE A POINTER TO osm_vendor_t
-**********************************************************************/
-void osm_vendor_delete(IN osm_vendor_t ** const pp_vend)
-{
- CL_ASSERT(pp_vend);
-
- osm_vendor_destroy(*pp_vend);
- free(*pp_vend);
- *pp_vend = NULL;
-}
-
-/**********************************************************************
- Initializes the vendor:
-**********************************************************************/
-
-ib_api_status_t
-osm_vendor_init(IN osm_vendor_t * const p_vend,
- IN osm_log_t * const p_log, IN const uint32_t timeout)
-{
- ib_api_status_t status = IB_SUCCESS;
-
- OSM_LOG_ENTER(p_log);
-
- p_vend->p_log = p_log;
- p_vend->p_transaction_mgr = NULL;
- osm_transaction_mgr_init(p_vend);
- p_vend->timeout = timeout;
-
- /* we use the file handle to track the binding */
- p_vend->smi_bind.ul_dev_fd = -1;
- p_vend->gsi_bind.ul_dev_fd = -1;
-
- OSM_LOG_EXIT(p_log);
- return (status);
-}
-
-/**********************************************************************
- * Create and Initialize osm_vendor_t Object
- **********************************************************************/
-osm_vendor_t *osm_vendor_new(IN osm_log_t * const p_log,
- IN const uint32_t timeout)
-{
- ib_api_status_t status;
- osm_vendor_t *p_vend;
-
- OSM_LOG_ENTER(p_log);
-
- CL_ASSERT(p_log);
-
- p_vend = malloc(sizeof(*p_vend));
- if (p_vend != NULL) {
- memset(p_vend, 0, sizeof(*p_vend));
-
- status = osm_vendor_init(p_vend, p_log, timeout);
- if (status != IB_SUCCESS) {
- osm_vendor_delete(&p_vend);
- }
- } else {
- osm_log(p_vend->p_log, OSM_LOG_ERROR,
- "osm_vendor_new: ERR 5007: "
- "Fail to allocate vendor object.\n");
- }
-
- OSM_LOG_EXIT(p_log);
- return (p_vend);
-}
-
-/**********************************************************************
- * TS RCV Thread callback
- * HACK: - we need to make this support arbitrary size mads.
- **********************************************************************/
-void
-__osm_ts_rcv_callback(IN osm_ts_bind_info_t * p_bind,
- IN osm_mad_addr_t * p_mad_addr,
- IN uint32_t mad_size, IN void *p_mad)
-{
- ib_api_status_t status;
- osm_madw_t *p_req_madw = NULL;
- osm_madw_t *p_madw;
- osm_vend_wrap_t *p_new_vw;
- ib_mad_t *p_mad_buf;
- osm_log_t *const p_log = p_bind->p_vend->p_log;
-
- OSM_LOG_ENTER(p_log);
-
- /* if it is a response MAD we mustbe able to get the request */
- if (ib_mad_is_response((ib_mad_t *) p_mad)) {
- /* can we find a matching madw by this payload TID */
- status =
- osm_transaction_mgr_get_madw_for_tid(p_bind->p_vend,
- (ib_mad_t *) p_mad,
- &p_req_madw);
- if (status != IB_SUCCESS) {
- osm_log(p_log, OSM_LOG_ERROR,
- "__osm_ts_rcv_callback: ERR 5008: "
- "Error obtaining request madw by TID (%d).\n",
- status);
- p_req_madw = NULL;
- }
-
- if (p_req_madw == NULL) {
- osm_log(p_log, OSM_LOG_ERROR,
- "__osm_ts_rcv_callback: ERR 5009: "
- "Fail to obtain request madw for receined MAD. Aborting CB.\n");
- goto Exit;
- }
- }
-
- /* do we have a request ??? */
- if (p_req_madw == NULL) {
-
- /* if not - get new osm_madw and arrange it. */
- /* create the new madw in the pool */
- p_madw = osm_mad_pool_get(p_bind->p_osm_pool,
- (osm_bind_handle_t) p_bind,
- mad_size, p_mad_addr);
- if (p_madw == NULL) {
- osm_log(p_log, OSM_LOG_ERROR,
- "__osm_ts_rcv_callback: ERR 5010: "
- "Error request for a new madw.\n");
- goto Exit;
- }
- /* HACK: we cust to avoid the const ??? */
- p_mad_buf = (void *)p_madw->p_mad;
- } else {
- /* we have the madw defined during the send and stored in the vend_wrap */
- /* we need to make sure the wrapper is correctly init there */
- CL_ASSERT(p_req_madw->vend_wrap.p_resp_madw != 0);
- p_madw = p_req_madw->vend_wrap.p_resp_madw;
-
- CL_ASSERT(p_madw->h_bind);
- p_mad_buf =
- osm_vendor_get(p_madw->h_bind, mad_size,
- &p_madw->vend_wrap);
-
- if (p_mad_buf == NULL) {
- osm_log(p_log, OSM_LOG_ERROR,
- "__osm_ts_rcv_callback: ERR 5011: "
- "Unable to acquire wire MAD.\n");
-
- goto Exit;
- }
-
- /*
- Finally, attach the wire MAD to this wrapper.
- */
- osm_madw_set_mad(p_madw, p_mad_buf);
- }
-
- /* init some fields of the vendor wrapper */
- p_new_vw = osm_madw_get_vend_ptr(p_madw);
- p_new_vw->h_bind = p_bind;
- p_new_vw->size = mad_size;
- p_new_vw->p_resp_madw = NULL;
- p_new_vw->p_mad_buf = p_mad_buf;
-
- memcpy(p_new_vw->p_mad_buf, p_mad, mad_size);
-
- /* attach the buffer to the wrapper */
- p_madw->p_mad = p_mad_buf;
-
- /* we can also make sure we marked the size and bind on the returned madw */
- p_madw->h_bind = p_new_vw->h_bind;
-
- /* call the CB */
- (*(osm_vend_mad_recv_callback_t) p_bind->rcv_callback)
- (p_madw, p_bind->client_context, p_req_madw);
-
-Exit:
- OSM_LOG_EXIT(p_log);
-}
-
-/**********************************************************************
- * TS Send callback : invoked after each send
- *
- **********************************************************************/
-void
-__osm_ts_send_callback(IN osm_ts_bind_info_t * bind_info_p,
- IN boolean_t is_resp,
- IN osm_madw_t * madw_p, IN IB_comp_status_t status)
-{
- osm_log_t *const p_log = bind_info_p->p_vend->p_log;
- osm_vend_wrap_t *p_vw;
-
- OSM_LOG_ENTER(p_log);
-
- osm_log(p_log, OSM_LOG_DEBUG,
- "__osm_ts_send_callback: INFO 1008: "
- "Handling Send of MADW:%p Is Resp:%d.\n", madw_p, is_resp);
-
- /* we need to handle requests and responses differently */
- if (is_resp) {
- if (status != IB_COMP_SUCCESS) {
- osm_log(p_log, OSM_LOG_ERROR,
- "__osm_ts_send_callback: ERR 5012: "
- "Error Sending Response MADW:%p.\n", madw_p);
- } else {
- osm_log(p_log, OSM_LOG_DEBUG,
- "__osm_ts_send_callback: DBG 1008: "
- "Completed Sending Response MADW:%p.\n",
- madw_p);
- }
-
- /* if we are a response - we need to clean it up */
- osm_mad_pool_put(bind_info_p->p_osm_pool, madw_p);
- } else {
-
- /* this call back is invoked on completion of send - error or not */
- if (status != IB_COMP_SUCCESS) {
-
- osm_log(p_log, OSM_LOG_ERROR,
- "__osm_ts_send_callback: ERR 5013: "
- "Received an Error from IB_MGT Send (%d).\n",
- status);
-
- p_vw = osm_madw_get_vend_ptr(madw_p);
- CL_ASSERT(p_vw);
-
- /*
- Return any wrappers to the pool that may have been
- pre-emptively allocated to handle a receive.
- */
- if (p_vw->p_resp_madw) {
- osm_mad_pool_put(bind_info_p->p_osm_pool,
- p_vw->p_resp_madw);
- p_vw->p_resp_madw = NULL;
- }
-
- /* invoke the CB */
- (*(osm_vend_mad_send_err_callback_t) bind_info_p->
- send_err_callback)
- (bind_info_p->client_context, madw_p);
- } else {
- /* successful request send - do nothing - the response will need the
- out mad */
- osm_log(p_log, OSM_LOG_DEBUG,
- "__osm_ts_send_callback: DBG 1008: "
- "Completed Sending Request MADW:%p.\n", madw_p);
- }
- }
-
- OSM_LOG_EXIT(p_log);
-}
-
-/**********************************************************************
- * Poller thread:
- * Always receive 256byte mads from the devcie file
- **********************************************************************/
-void __osm_vendor_ts_poller(IN void *p_ptr)
-{
- int ts_ret_code;
- struct ib_mad mad;
- osm_mad_addr_t mad_addr;
- osm_ts_bind_info_t *const p_bind = (osm_ts_bind_info_t *) p_ptr;
-
- OSM_LOG_ENTER(p_bind->p_vend->p_log);
- /* we set the type of cancelation for this thread */
- pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, NULL);
-
- while (1) {
- /* we read one mad at a time and pass it to the read callback function */
- ts_ret_code = read(p_bind->ul_dev_fd, &mad, sizeof(mad));
- if (ts_ret_code != sizeof(mad)) {
- osm_log(p_bind->p_vend->p_log, OSM_LOG_ERROR,
- "__osm_vendor_ts_poller: ERR 5003: "
- "error with read, bytes = %d, errno = %d\n",
- ts_ret_code, errno);
- } else {
- osm_log(p_bind->p_vend->p_log, OSM_LOG_DEBUG,
- "__osm_vendor_ts_poller: "
- "MAD QPN:%d SLID:0x%04x class:0x%02x "
- "__osm_vendor_ts_poller:0x%02x attr:0x%04x status:0x%04x "
- "__osm_vendor_ts_poller:0x%016" PRIx64 "\n",
- cl_ntoh32(mad.dqpn),
- cl_ntoh16(mad.slid),
- mad.mgmt_class,
- mad.r_method,
- cl_ntoh16(mad.attribute_id),
- cl_ntoh16(mad.status),
- cl_ntoh64(mad.transaction_id));
-
- /* first arrange an address */
- __osm_ts_conv_mad_rcv_desc_to_osm_addr(p_bind->p_vend,
- &mad,
- (((ib_mad_t *) &
- mad)->
- mgmt_class ==
- IB_MCLASS_SUBN_LID)
- ||
- (((ib_mad_t *) &
- mad)->
- mgmt_class ==
- IB_MCLASS_SUBN_DIR),
- &mad_addr);
-
- /* call the receiver callback */
- /* HACK: this should be replaced with a call to the RMPP Assembly ... */
- __osm_ts_rcv_callback(p_bind, &mad_addr, 256, &mad);
- }
- }
-
- OSM_LOG_EXIT(p_bind->p_vend->p_log);
-}
-
-/**********************************************************************
- * BINDs a callback (rcv and send error) for a given class and method
- * defined by the given: osm_bind_info_t
- **********************************************************************/
-osm_bind_handle_t
-osm_vendor_bind(IN osm_vendor_t * const p_vend,
- IN osm_bind_info_t * const p_user_bind,
- IN osm_mad_pool_t * const p_mad_pool,
- IN osm_vend_mad_recv_callback_t mad_recv_callback,
- IN osm_vend_mad_send_err_callback_t send_err_callback,
- IN void *context)
-{
- ib_net64_t port_guid;
- osm_ts_bind_info_t *p_bind = NULL;
- VAPI_hca_hndl_t hca_hndl;
- VAPI_hca_id_t hca_id;
- uint32_t port_num;
- ib_api_status_t status;
- int device_fd;
- char device_file[16];
- osm_ts_user_mad_filter filter;
- int ts_ioctl_ret;
- int qpn;
-
- OSM_LOG_ENTER(p_vend->p_log);
-
- CL_ASSERT(p_mad_pool);
-
- port_guid = p_user_bind->port_guid;
-
- osm_log(p_vend->p_log, OSM_LOG_INFO,
- "osm_vendor_bind: "
- "Binding to port 0x%" PRIx64 ".\n", cl_ntoh64(port_guid));
-
- switch (p_user_bind->mad_class) {
- case IB_MCLASS_SUBN_LID:
- case IB_MCLASS_SUBN_DIR:
- p_bind = &(p_vend->smi_bind);
- qpn = 0;
- break;
-
- case IB_MCLASS_SUBN_ADM:
- default:
- p_bind = &(p_vend->gsi_bind);
- qpn = 1;
- break;
- }
-
- /* Make sure we did not previously opened the file */
- if (p_bind->ul_dev_fd >= 0) {
- osm_log(p_vend->p_log, OSM_LOG_ERROR,
- "osm_vendor_bind: ERR 5004: "
- "Already binded to port %u\n", p_bind->port_num);
- goto Exit;
- }
-
- /*
- We need to figure out what is the TS file name to attach to.
- I guess it is following the index of the port in the table of
- ports.
- */
-
- /* obtain the hca name and port num from the guid */
- osm_log(p_vend->p_log, OSM_LOG_DEBUG,
- "osm_vendor_bind: "
- "Finding CA and Port that owns port guid 0x%" PRIx64 ".\n",
- cl_ntoh64(port_guid));
- status =
- osm_vendor_get_guid_ca_and_port(p_vend, port_guid, &hca_hndl,
- &hca_id, &port_num);
- if (status != IB_SUCCESS) {
- osm_log(p_vend->p_log, OSM_LOG_ERROR,
- "osm_vendor_bind: ERR 5005: "
- "Fail to find port number of port guid:0x%016" PRIx64
- "\n", port_guid);
- goto Exit;
- }
-
- /* the file name is just /dev/ts_ua0: */
- strcpy(device_file, "/dev/ts_ua0");
-
- osm_log(p_vend->p_log, OSM_LOG_ERROR,
- "osm_vendor_bind: " "Opening TS UL dev file:%s\n", device_file);
-
- /* Open the file ... */
- device_fd = open(device_file, O_RDWR);
- if (device_fd < 0) {
- osm_log(p_vend->p_log, OSM_LOG_ERROR,
- "osm_vendor_bind: ERR 5006: "
- "Fail to open TS UL dev file:%s\n", device_file);
- goto Exit;
- }
-
- /* track this bind request info */
- p_bind->ul_dev_fd = device_fd;
- p_bind->port_num = port_num;
- p_bind->p_vend = p_vend;
- p_bind->client_context = context;
- p_bind->rcv_callback = mad_recv_callback;
- p_bind->send_err_callback = send_err_callback;
- p_bind->p_osm_pool = p_mad_pool;
- p_bind->hca_hndl = hca_hndl;
-
- /*
- * Create the MAD filter on this file handle.
- */
- filter.port = port_num;
-
- filter.qpn = qpn;
- filter.mgmt_class = p_user_bind->mad_class;
- filter.direction = TS_IB_MAD_DIRECTION_IN;
- filter.mask =
- TS_IB_MAD_FILTER_DIRECTION |
- TS_IB_MAD_FILTER_PORT |
- TS_IB_MAD_FILTER_QPN | TS_IB_MAD_FILTER_MGMT_CLASS;
-
- ts_ioctl_ret = ioctl(device_fd, TS_IB_IOCSMADFILTADD, &filter);
- if (ts_ioctl_ret < 0) {
- osm_log(p_vend->p_log, OSM_LOG_ERROR,
- "osm_vendor_bind: ERR 5014: "
- "Fail to register MAD filter with err:%u\n",
- ts_ioctl_ret);
- goto Exit;
- }
-
- /* Initialize the listener thread for this port */
- status = cl_thread_init(&p_bind->poller,
- __osm_vendor_ts_poller, p_bind,
- "osm ts poller");
- if (status != IB_SUCCESS)
- goto Exit;
-
-Exit:
- OSM_LOG_EXIT(p_vend->p_log);
- return ((osm_bind_handle_t) p_bind);
-}
-
-/**********************************************************************
-Get a mad from the lower level.
-The osm_vend_wrap_t is a wrapper used to connect the mad to the response.
-**********************************************************************/
-ib_mad_t *osm_vendor_get(IN osm_bind_handle_t h_bind,
- IN const uint32_t mad_size,
- IN osm_vend_wrap_t * const p_vw)
-{
- ib_mad_t *p_mad;
- osm_ts_bind_info_t *p_bind = (osm_ts_bind_info_t *) h_bind;
- osm_vendor_t *p_vend = p_bind->p_vend;
-
- OSM_LOG_ENTER(p_vend->p_log);
-
- CL_ASSERT(p_vw);
-
- p_vw->size = mad_size;
-
- /* allocate it */
- p_mad = (ib_mad_t *) malloc(p_vw->size);
- if (p_mad == NULL) {
- osm_log(p_vend->p_log, OSM_LOG_ERROR,
- "osm_vendor_get: ERR 5022: "
- "Error Obtaining MAD buffer.\n");
- goto Exit;
- }
-
- memset(p_mad, 0, p_vw->size);
-
- /* track locally */
- p_vw->p_mad_buf = p_mad;
- p_vw->h_bind = h_bind;
- p_vw->p_resp_madw = NULL;
-
- if (osm_log_get_level(p_vend->p_log) >= OSM_LOG_DEBUG) {
- osm_log(p_vend->p_log, OSM_LOG_DEBUG,
- "osm_vendor_get: "
- "Acquired MAD %p, size = %u.\n", p_mad, p_vw->size);
- }
-
-Exit:
- OSM_LOG_EXIT(p_vend->p_log);
- return (p_mad);
-}
-
-/**********************************************************************
- * Return a MAD by providing it's wrapper object.
- **********************************************************************/
-void
-osm_vendor_put(IN osm_bind_handle_t h_bind, IN osm_vend_wrap_t * const p_vw)
-{
- osm_ts_bind_info_t *p_bind = (osm_ts_bind_info_t *) h_bind;
- osm_vendor_t *p_vend = p_bind->p_vend;
- osm_madw_t *p_madw;
-
- OSM_LOG_ENTER(p_vend->p_log);
-
- CL_ASSERT(p_vw);
- CL_ASSERT(p_vw->p_mad_buf);
-
- if (osm_log_get_level(p_vend->p_log) >= OSM_LOG_DEBUG) {
- osm_log(p_vend->p_log, OSM_LOG_DEBUG,
- "osm_vendor_put: " "Retiring MAD %p.\n",
- p_vw->p_mad_buf);
- }
-
- /*
- * We moved the removal of the transaction to immediatly after
- * it was looked up.
- */
-
- /* free the mad but the wrapper is part of the madw object */
- free(p_vw->p_mad_buf);
- p_vw->p_mad_buf = NULL;
- p_madw = PARENT_STRUCT(p_vw, osm_madw_t, vend_wrap);
- p_madw->p_mad = NULL;
-
- OSM_LOG_EXIT(p_vend->p_log);
-}
-
-/**********************************************************************
-Actually Send a MAD
-
-MADs are buffers of type: struct ib_mad - so they are limited by size.
-This is for internal use by osm_vendor_send and the transaction mgr
-retry too.
-**********************************************************************/
-ib_api_status_t
-osm_ts_send_mad(IN osm_ts_bind_info_t * p_bind, IN osm_madw_t * const p_madw)
-{
- osm_vendor_t *const p_vend = p_bind->p_vend;
- osm_mad_addr_t *const p_mad_addr = osm_madw_get_mad_addr_ptr(p_madw);
- ib_mad_t *const p_mad = osm_madw_get_mad_ptr(p_madw);
- struct ib_mad ts_mad;
- int ret;
- ib_api_status_t status;
-
- OSM_LOG_ENTER(p_vend->p_log);
-
- /*
- * Copy the MAD over to the sent mad
- */
- memcpy(&ts_mad, p_mad, 256);
-
- /*
- * For all sends other than directed route SM MADs,
- * acquire an address vector for the destination.
- */
- if (p_mad->mgmt_class != IB_MCLASS_SUBN_DIR) {
- __osm_ts_conv_osm_addr_to_ts_addr(p_mad_addr,
- p_mad->mgmt_class ==
- IB_MCLASS_SUBN_LID, &ts_mad);
- } else {
- /* is a directed route - we need to construct a permissive address */
- /* we do not need port number since it is part of the mad_hndl */
- ts_mad.dlid = IB_LID_PERMISSIVE;
- ts_mad.slid = IB_LID_PERMISSIVE;
- }
- if ((p_mad->mgmt_class == IB_MCLASS_SUBN_DIR) ||
- (p_mad->mgmt_class == IB_MCLASS_SUBN_LID)) {
- ts_mad.sqpn = 0;
- ts_mad.dqpn = 0;
- } else {
- ts_mad.sqpn = 1;
- ts_mad.dqpn = 1;
- }
- ts_mad.port = p_bind->port_num;
-
- /* send it */
- ret = write(p_bind->ul_dev_fd, &ts_mad, sizeof(ts_mad));
-
- if (ret != sizeof(ts_mad)) {
- osm_log(p_vend->p_log, OSM_LOG_ERROR,
- "osm_ts_send_mad: ERR 5026: "
- "Error sending mad (%d).\n", ret);
- status = IB_ERROR;
- goto Exit;
- }
-
- status = IB_SUCCESS;
-
-Exit:
- OSM_LOG_EXIT(p_vend->p_log);
- return (status);
-}
-
-/**********************************************************************
-Send a MAD through.
-
-What is unclear to me is the need for the setting of all the MAD Wrapper
-fields. Seems like the OSM uses these values during it's processing...
-**********************************************************************/
-ib_api_status_t
-osm_vendor_send(IN osm_bind_handle_t h_bind,
- IN osm_madw_t * const p_madw, IN boolean_t const resp_expected)
-{
- osm_ts_bind_info_t *p_bind = (osm_ts_bind_info_t *) h_bind;
- osm_vendor_t *const p_vend = p_bind->p_vend;
- osm_vend_wrap_t *const p_vw = osm_madw_get_vend_ptr(p_madw);
- ib_api_status_t status;
-
- OSM_LOG_ENTER(p_vend->p_log);
-
- /*
- * If a response is expected to this MAD, then preallocate
- * a mad wrapper to contain the wire MAD received in the
- * response. Allocating a wrapper here allows for easier
- * failure paths than after we already received the wire mad.
- */
- if (resp_expected == TRUE) {
- /* we track it in the vendor wrapper */
- p_vw->p_resp_madw =
- osm_mad_pool_get_wrapper_raw(p_bind->p_osm_pool);
- if (p_vw->p_resp_madw == NULL) {
- osm_log(p_vend->p_log, OSM_LOG_ERROR,
- "osm_vendor_send: ERR 5024: "
- "Unable to allocate MAD wrapper.\n");
- status = IB_INSUFFICIENT_RESOURCES;
- goto Exit;
- }
-
- /* put some minimal info on that wrapper */
- ((osm_madw_t *) (p_vw->p_resp_madw))->h_bind = h_bind;
-
- /* we also want to track it in the TID based map */
- status = osm_transaction_mgr_insert_madw((osm_bind_handle_t *)
- p_bind, p_madw);
- if (status != IB_SUCCESS) {
- osm_log(p_vend->p_log, OSM_LOG_ERROR,
- "osm_vendor_send: ERR 5025: "
- "Error inserting request madw by TID (%d).\n",
- status);
- }
- } else
- p_vw->p_resp_madw = NULL;
-
- /* do the actual send */
- /* HACK: to be replaced by call to RMPP Segmentation */
- status = osm_ts_send_mad(p_bind, p_madw);
-
- /* we do not get an asycn callback so call it ourselves */
- /* this will handle all cleanup if neccessary */
- __osm_ts_send_callback(p_bind, !resp_expected, p_madw, status);
-
-Exit:
- OSM_LOG_EXIT(p_vend->p_log);
- return (status);
-}
-
-/**********************************************************************
- * the idea here is to change the content of the bind such that it
- * will hold the local address used for sending directed route by the SMA.
- **********************************************************************/
-ib_api_status_t osm_vendor_local_lid_change(IN osm_bind_handle_t h_bind)
-{
- osm_vendor_t *p_vend = ((osm_ts_bind_info_t *) h_bind)->p_vend;
-
- OSM_LOG_ENTER(p_vend->p_log);
-
- osm_log(p_vend->p_log, OSM_LOG_DEBUG,
- "osm_vendor_local_lid_change: DEBUG 2202: " "Change of LID.\n");
-
- OSM_LOG_EXIT(p_vend->p_log);
-
- return (IB_SUCCESS);
-}
-
-/**********************************************************************
- **********************************************************************/
-void osm_vendor_set_sm(IN osm_bind_handle_t h_bind, IN boolean_t is_sm_val)
-{
- osm_ts_bind_info_t *p_bind = (osm_ts_bind_info_t *) h_bind;
- osm_vendor_t *p_vend = p_bind->p_vend;
- VAPI_ret_t status;
- VAPI_hca_attr_t attr_mod;
- VAPI_hca_attr_mask_t attr_mask;
-
- OSM_LOG_ENTER(p_vend->p_log);
-
- memset(&attr_mod, 0, sizeof(attr_mod));
- memset(&attr_mask, 0, sizeof(attr_mask));
-
- attr_mod.is_sm = is_sm_val;
- attr_mask = HCA_ATTR_IS_SM;
-
- status =
- VAPI_modify_hca_attr(p_bind->hca_hndl, p_bind->port_num, &attr_mod,
- &attr_mask);
- if (status != VAPI_OK) {
- osm_log(p_vend->p_log, OSM_LOG_ERROR,
- "osm_vendor_set_sm: ERR 5027: "
- "Unable set 'IS_SM' bit to:%u in port attributes (%d).\n",
- is_sm_val, status);
- }
-
- OSM_LOG_EXIT(p_vend->p_log);
-}
-
-/**********************************************************************
- **********************************************************************/
-void osm_vendor_set_debug(IN osm_vendor_t * const p_vend, IN int32_t level)
-{
-
-}
diff --git a/contrib/ofed/management/opensm/libvendor/osm_vendor_umadt.c b/contrib/ofed/management/opensm/libvendor/osm_vendor_umadt.c
deleted file mode 100644
index 82932dd..0000000
--- a/contrib/ofed/management/opensm/libvendor/osm_vendor_umadt.c
+++ /dev/null
@@ -1,1117 +0,0 @@
-/*
- * Copyright (c) 2004-2008 Voltaire, Inc. All rights reserved.
- * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved.
- * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- */
-
-/*
- * Abstract:
- * Implementation of osm_req_t.
- * This object represents the generic attribute requester.
- * This object is part of the opensm family of objects.
- *
- */
-
-/*
- Next available error code: 0x300
-*/
-
-#if HAVE_CONFIG_H
-# include <config.h>
-#endif /* HAVE_CONFIG_H */
-
-#ifdef OSM_VENDOR_INTF_UMADT
-
-#include <stdlib.h>
-#include <stdio.h>
-#include <dlfcn.h>
-#include <string.h>
-
-#include <complib/cl_qlist.h>
-#include <complib/cl_thread.h>
-#include <complib/cl_timer.h>
-#include <iba/ib_types.h>
-#include <opensm/osm_madw.h>
-#include <opensm/osm_log.h>
-#include <opensm/osm_mad_pool.h>
-
-#include <vendor/osm_vendor_umadt.h>
-#include <vendor/osm_umadt.h>
-
-/* GEN1 includes */
-#include "umadt_so.h"
-#include "ibt.h"
-#include "statustext.h"
-
-/* //////////////////////////////////////////////////////////////////////// */
-/* //////////////////////////////////////////////////////////////////////// */
-/* //////////////////////////////////////////////////////////////////////// */
-/* //////////////////////////////////////////////////////////////////////// */
-/* //////////////////////////////////////////////////////////////////////// */
-/* */
-/* VENDOR_MAD_INTF */
-/* */
-/* //////////////////////////////////////////////////////////////////////// */
-/* //////////////////////////////////////////////////////////////////////// */
-/* //////////////////////////////////////////////////////////////////////// */
-/* //////////////////////////////////////////////////////////////////////// */
-/* //////////////////////////////////////////////////////////////////////// */
-
-/* //////////////////// */
-/* Globals // */
-/* //////////////////// */
-typedef struct _ib_sa_mad_vM3 {
- uint8_t base_ver;
- uint8_t mgmt_class;
- uint8_t class_ver;
- uint8_t method;
- ib_net16_t status;
- ib_net16_t resv;
- ib_net64_t trans_id;
- ib_net16_t attr_id;
- ib_net16_t resv1;
- ib_net32_t attr_mod;
- ib_net64_t resv2;
- ib_net64_t sm_key;
-
- ib_net32_t seg_num;
- ib_net32_t payload_len;
- uint8_t frag_flag;
- uint8_t edit_mod;
- ib_net16_t window;
- ib_net16_t attr_offset;
- ib_net16_t resv3;
-
- ib_net64_t comp_mask;
-
- uint8_t data[IB_SA_DATA_SIZE];
-} ib_sa_mad_t_vM3;
-#define DEFAULT_TIMER_INTERVAL_MSEC 500 /* 500msec timer interval */
-
-void __mad_recv_processor(void *context);
-
-boolean_t __valid_mad_handle(IN mad_bind_info_t * p_mad_bind_info);
-
-cl_status_t
-__match_tid_context(const cl_list_item_t * const p_list_item, void *context);
-void __osm_vendor_timer_callback(IN void *context);
-
-osm_vendor_t *osm_vendor_new(IN osm_log_t * const p_log,
- IN const uint32_t timeout)
-{
- ib_api_status_t status;
- umadt_obj_t *p_umadt_obj;
-
- OSM_LOG_ENTER(p_log);
-
- p_umadt_obj = malloc(sizeof(umadt_obj_t));
- if (p_umadt_obj) {
- memset(p_umadt_obj, 0, sizeof(umadt_obj_t));
-
- status = osm_vendor_init((osm_vendor_t *) p_umadt_obj, p_log,
- timeout);
- if (status != IB_SUCCESS) {
- osm_vendor_delete((osm_vendor_t **) & p_umadt_obj);
- }
- } else {
- printf
- ("osm_vendor_construct: ERROR! Unable to create Umadt object!\n");
- }
-
- OSM_LOG_EXIT(p_log);
-
- return ((osm_vendor_t *) p_umadt_obj);
-}
-
-void osm_vendor_delete(IN osm_vendor_t ** const pp_vend)
-{
- umadt_obj_t *p_umadt_obj = (umadt_obj_t *) * pp_vend;
- cl_list_item_t *p_list_item;
- uint32_t count, i;
- mad_bind_info_t *p_mad_bind_info;
-
- OSM_LOG_ENTER(p_umadt_obj->p_log);
-
- cl_spinlock_acquire(&p_umadt_obj->register_lock);
- p_mad_bind_info =
- (mad_bind_info_t *) cl_qlist_head(&p_umadt_obj->register_list);
- count = cl_qlist_count(&p_umadt_obj->register_list);
- cl_spinlock_release(&p_umadt_obj->register_lock);
- for (i = 0; i < count; i++) {
- cl_spinlock_acquire(&p_umadt_obj->register_lock);
- p_list_item = cl_qlist_next(&p_mad_bind_info->list_item);
- cl_spinlock_release(&p_umadt_obj->register_lock);
- /* Unbind this handle */
- /* osm_vendor_ubind also removesd the item from the list */
- /* osm_vendor_unbind takes the list lock so release it here */
- osm_vendor_unbind((osm_bind_handle_t) p_mad_bind_info);
- p_mad_bind_info = (mad_bind_info_t *) p_list_item;
- }
- dlclose(p_umadt_obj->umadt_handle);
- free(p_umadt_obj);
- *pp_vend = NULL;
-
- OSM_LOG_EXIT(p_umadt_obj->p_log);
-}
-
-/* //////////////////////////////////////////////////////////////////////// */
-/* See VendorAbstractMadIntf.h for info */
-/* //////////////////////////////////////////////////////////////////////// */
-/* */
-ib_api_status_t
-osm_vendor_init(IN osm_vendor_t * const p_vend,
- IN osm_log_t * const p_log, IN const uint32_t timeout)
-{
- FSTATUS Status;
- PUMADT_GET_INTERFACE uMadtGetInterface;
- char *error;
- umadt_obj_t *p_umadt_obj = (umadt_obj_t *) p_vend;
-
- OSM_LOG_ENTER(p_log);
-
- p_umadt_obj->p_log = p_log;
- p_umadt_obj->timeout = timeout;
-
- p_umadt_obj->umadt_handle = dlopen("libibt.so", RTLD_NOW);
-
- if (!p_umadt_obj->umadt_handle) {
- printf("Could not load libibt.so <%s>\n", dlerror());
- return IB_ERROR;
- }
- uMadtGetInterface =
- dlsym(p_umadt_obj->umadt_handle, "uMadtGetInterface");
- if ((error = dlerror()) != NULL) {
- printf("Could not resolve symbol uMadtGetInterface ERROR<%s>\n",
- error);
- return IB_ERROR;
- }
-
- Status = (*uMadtGetInterface) (&p_umadt_obj->uMadtInterface);
- if (Status != FSUCCESS) {
- printf(" Error in getting uMADT interface ERROR<%d>\n", Status);
- return IB_ERROR;
- }
-
- /* Initialize the register list and register list lock */
- cl_qlist_init(&p_umadt_obj->register_list);
-
- cl_spinlock_construct(&p_umadt_obj->register_lock);
- CL_ASSERT(cl_spinlock_init(&p_umadt_obj->register_lock) == CL_SUCCESS);
- p_umadt_obj->init_done = TRUE;
- printf("*****SUCCESS*****\n");
-
- OSM_LOG_EXIT(p_log);
- return IB_SUCCESS;
-
-}
-
-/* //////////////////////////////////////////////////////////////////////// */
-/* See VendorAbstractMadIntf.h for info */
-/* //////////////////////////////////////////////////////////////////////// */
-ib_api_status_t
-osm_vendor_get_ports(IN osm_vendor_t * const p_vend,
- IN ib_net64_t * const p_guids,
- IN uint32_t * const p_num_guids)
-{
- char *error = NULL;
- PIBT_GET_INTERFACE pfnIbtGetInterface;
- PIBT_INIT pfnIbtInitFunc;
-
- FSTATUS Status;
- uint32_t caCount, caGuidCount;
- IB_CA_ATTRIBUTES caAttributes;
- IB_HANDLE caHandle;
- uint32_t i;
- IB_PORT_ATTRIBUTES *pPortAttributesList;
- EUI64 CaGuidArray[8];
- void *context;
- uint64_t *p_port_guid;
- uint32_t free_guids;
-
- umadt_obj_t *p_umadt_obj = (umadt_obj_t *) p_vend;
-
- OSM_LOG_ENTER(p_umadt_obj->p_log);
-
- CL_ASSERT(p_guids);
- CL_ASSERT(p_num_guids);
-
- pfnIbtInitFunc =
- (PIBT_INIT) dlsym(p_umadt_obj->umadt_handle, "IbtInit");
-
- if (!pfnIbtInitFunc) {
- printf("Error getting IbtInit function address.\n");
- return IB_ERROR;
- }
-
- (*pfnIbtInitFunc) ();
-
- pfnIbtGetInterface =
- (PIBT_GET_INTERFACE) dlsym(p_umadt_obj->umadt_handle,
- "IbtGetInterface");
-
- if (!pfnIbtGetInterface || (error = dlerror()) != NULL) {
- printf("Error getting IbtGetInterface function address.<%s>\n",
- error);
- return FALSE;
- }
- (*pfnIbtGetInterface) (&p_umadt_obj->IbtInterface);
-
- caGuidCount = 8;
- Status =
- p_umadt_obj->IbtInterface.GetCaGuidArray(&caGuidCount,
- &CaGuidArray[0]);
-
- if ((Status != FSUCCESS) || (caGuidCount == 0)) {
- return FALSE;
- }
-
- free_guids = *p_num_guids;
- p_port_guid = p_guids;
-
- /* query each ca & copy its info into callers buffer */
- for (caCount = 0; caCount < caGuidCount; caCount++) {
- memset(&caAttributes, 0, sizeof(IB_CA_ATTRIBUTES));
-
- /* Open the CA */
- Status = p_umadt_obj->IbtInterface.Vpi.OpenCA(CaGuidArray[caCount], NULL, /* CACompletionCallback */
- NULL, /* AsyncEventCallback */
- NULL, &caHandle);
- if (Status != FSUCCESS) {
- return IB_ERROR;
- }
-
- Status = p_umadt_obj->IbtInterface.Vpi.QueryCA(caHandle,
- &caAttributes,
- &context);
-
- if (Status != FSUCCESS) {
- p_umadt_obj->IbtInterface.Vpi.CloseCA(caHandle);
- return IB_ERROR;
- }
-
- if (caAttributes.Ports > free_guids) {
- *p_num_guids = 0;
- memset(p_guids, 0, (*p_num_guids) * sizeof(uint64_t));
- return IB_INSUFFICIENT_MEMORY;
- }
-
- pPortAttributesList =
- (IB_PORT_ATTRIBUTES *) malloc(caAttributes.
- PortAttributesListSize);
-
- if (pPortAttributesList == NULL) {
- p_umadt_obj->IbtInterface.Vpi.CloseCA(caHandle);
- *p_num_guids = 0;
- memset(p_guids, 0, (*p_num_guids) * sizeof(uint64_t));
- return IB_INSUFFICIENT_MEMORY;
- }
-
- memset(pPortAttributesList, 0,
- caAttributes.PortAttributesListSize);
-
- caAttributes.PortAttributesList = pPortAttributesList;
-
- Status = p_umadt_obj->IbtInterface.Vpi.QueryCA(caHandle,
- &caAttributes,
- &context);
-
- if (Status != FSUCCESS) {
- p_umadt_obj->IbtInterface.Vpi.CloseCA(caHandle);
- *p_num_guids = 0;
- memset(p_guids, 0, (*p_num_guids) * sizeof(uint64_t));
- return IB_ERROR;
- }
-
- pPortAttributesList = caAttributes.PortAttributesList;
-
- for (i = 0; i < caAttributes.Ports; i++) {
- *(p_port_guid) =
- cl_hton64((uint64_t) pPortAttributesList->GUID);
- pPortAttributesList = pPortAttributesList->Next;
- p_port_guid++;
- }
- free(caAttributes.PortAttributesList);
- p_umadt_obj->IbtInterface.Vpi.CloseCA(caHandle);
-
- free_guids = free_guids - caAttributes.Ports;
-
- }
- *p_num_guids = *p_num_guids - free_guids;
- return IB_SUCCESS;
-}
-
-/* //////////////////////////////////////////////////////////////////////// */
-/* See VendorAbstractMadIntf.h for info */
-/* //////////////////////////////////////////////////////////////////////// */
-ib_mad_t *osm_vendor_get(IN osm_bind_handle_t h_bind,
- IN const uint32_t mad_size,
- IN osm_vend_wrap_t * p_vend_wrap)
-{
- /* FSTATUS Status; */
- /* uint32_t mad_count = 0; */
- /* MadtStruct *p_madt_struct; */
- mad_bind_info_t *p_mad_bind_info = (mad_bind_info_t *) h_bind;
- umadt_obj_t *p_umadt_obj = p_mad_bind_info->p_umadt_obj;
- ib_mad_t *p_mad;
- OSM_LOG_ENTER(p_umadt_obj->p_log);
-
- CL_ASSERT(h_bind);
-
- p_umadt_obj = p_mad_bind_info->p_umadt_obj;
-
- /* Sanity check */
- CL_ASSERT(p_umadt_obj->init_done);
- CL_ASSERT(p_vend_wrap);
- CL_ASSERT(__valid_mad_handle(p_mad_bind_info));
-
-#if 0
- mad_count = 1;
- Status =
- p_umadt_obj->uMadtInterface.uMadtGetSendMad(p_mad_bind_info->
- umadt_handle,
- &mad_count,
- &p_madt_struct);
-
- if (Status != FSUCCESS || p_madt_struct == NULL) {
- p_vend_wrap->p_madt_struct = NULL;
- return NULL;
- }
- p_vend_wrap->p_madt_struct = p_madt_struct;
- p_vend_wrap->direction = SEND;
- return ((ib_mad_t *) & p_madt_struct->IBMad);
-#endif /* 0 */
- p_mad = (ib_mad_t *) malloc(mad_size);
- if (!p_mad) {
- p_vend_wrap->p_madt_struct = NULL;
- return NULL;
- }
-
- memset(p_mad, 0, mad_size);
-
- p_vend_wrap->p_madt_struct = NULL;
- p_vend_wrap->direction = SEND;
- p_vend_wrap->size = mad_size;
- return (p_mad);
-
-}
-
-/* //////////////////////////////////////////////////////////////////////// */
-/* See VendorAbstractMadIntf.h for info */
-/* //////////////////////////////////////////////////////////////////////// */
-void
-osm_vendor_put(IN osm_bind_handle_t h_bind,
- IN osm_vend_wrap_t * const p_vend_wrap,
- IN ib_mad_t * const p_mad)
-{
-
- FSTATUS Status;
-
- mad_bind_info_t *p_mad_bind_info;
- umadt_obj_t *p_umadt_obj;
-
- /* */
- /* Validate the vendor mad transport handle */
- /* */
- CL_ASSERT(h_bind);
- p_mad_bind_info = (mad_bind_info_t *) h_bind;
- p_umadt_obj = p_mad_bind_info->p_umadt_obj;
-
- /* sanity check */
- CL_ASSERT(p_umadt_obj->init_done);
- CL_ASSERT(h_bind);
- CL_ASSERT(__valid_mad_handle(p_mad_bind_info));
- CL_ASSERT(p_vend_wrap);
- /* CL_ASSERT( (ib_mad_t*)&p_vend_wrap->p_madt_struct->IBMad == p_mad ); */
-
- /* Release the MAD based on the direction of the MAD */
- if (p_vend_wrap->direction == SEND) {
- /* */
- /* For a send the PostSend released the MAD with Umadt. Simply dealloacte the */
- /* local memory that was allocated on the osm_vendor_get() call. */
- /* */
- free(p_mad);
-#if 0
- Status =
- p_umadt_obj->uMadtInterface.
- uMadtReleaseSendMad(p_mad_bind_info->umadt_handle,
- p_vend_wrap->p_madt_struct);
- if (Status != FSUCCESS) {
- /* printf("uMadtReleaseSendMad: Status = <%d>\n", Status); */
- return;
- }
-#endif
- } else if (p_vend_wrap->direction == RECEIVE) {
- CL_ASSERT((ib_mad_t *) & p_vend_wrap->p_madt_struct->IBMad ==
- p_mad);
- Status =
- p_umadt_obj->uMadtInterface.
- uMadtReleaseRecvMad(p_mad_bind_info->umadt_handle,
- p_vend_wrap->p_madt_struct);
- if (Status != FSUCCESS) {
- /* printf("uMadtReleaseRecvMad Status=<%d>\n", Status); */
- return;
- }
- } else {
- return;
- }
- return;
-}
-
-/* //////////////////////////////////////////////////////////////////////// */
-/* See VendorAbstractMadIntf.h for info */
-/* //////////////////////////////////////////////////////////////////////// */
-ib_api_status_t
-osm_vendor_send(IN osm_bind_handle_t h_bind,
- IN osm_vend_wrap_t * const p_vend_wrap,
- IN osm_mad_addr_t * const p_mad_addr,
- IN ib_mad_t * const p_mad,
- IN void *transaction_context, IN boolean_t const resp_expected)
-{
- FSTATUS Status;
-
- MadAddrStruct destAddr = { 0 };
-
- mad_bind_info_t *p_mad_bind_info;
- trans_context_t *p_trans_context;
-
- umadt_obj_t *p_umadt_obj = NULL;
-
- uint32_t mad_count = 0;
- MadtStruct *p_madt_struct = NULL;
- uint32_t i;
- uint32_t num_mads = 0;
- uint32_t seg_num = 0;
- uint8_t *p_frag_data = NULL;
- ib_sa_mad_t_vM3 *p_sa_mad = NULL;
-
- CL_ASSERT(h_bind);
- p_mad_bind_info = (mad_bind_info_t *) h_bind;
- p_umadt_obj = p_mad_bind_info->p_umadt_obj;
-
- /* sanity check */
- CL_ASSERT(p_umadt_obj);
- CL_ASSERT(p_umadt_obj->init_done);
- CL_ASSERT(__valid_mad_handle(p_mad_bind_info));
- CL_ASSERT(p_vend_wrap);
- CL_ASSERT(p_mad_addr);
- CL_ASSERT(p_mad);
- /* CL_ASSERT( (ib_mad_t*)&p_vend_wrap->p_madt_struct->IBMad == p_mad ); */
-
- /* */
- /* based on the class, fill out the address info */
- /* */
- destAddr.DestLid = p_mad_addr->dest_lid;
- destAddr.PathBits = p_mad_addr->path_bits;
- destAddr.StaticRate = p_mad_addr->static_rate;
-
- if (p_mad_bind_info->umadt_reg_class.ClassId == IB_MCLASS_SUBN_LID ||
- p_mad_bind_info->umadt_reg_class.ClassId == IB_MCLASS_SUBN_DIR) {
- CL_ASSERT(p_mad_addr->addr_type.smi.source_lid);
- destAddr.AddrType.Smi.SourceLid =
- p_mad_addr->addr_type.smi.source_lid;
- } else {
- destAddr.AddrType.Gsi.RemoteQpNumber =
- p_mad_addr->addr_type.gsi.remote_qp;
- destAddr.AddrType.Gsi.RemoteQkey =
- p_mad_addr->addr_type.gsi.remote_qkey;
- destAddr.AddrType.Gsi.PKey = OSM_DEFAULT_PKEY;
- destAddr.AddrType.Gsi.ServiceLevel =
- p_mad_addr->addr_type.gsi.service_level;
- destAddr.AddrType.Gsi.GlobalRoute =
- p_mad_addr->addr_type.gsi.global_route;
- /* destAddr.AddrType.Gsi.GRHInfo = p_mad_addr->addr_type.gsi.grh_info; */
- }
- p_mad->trans_id = cl_ntoh64(p_mad->trans_id) << 24;
-
- /* */
- /* Create a transaction context for this send and save the TID and client context. */
- /* */
-
- if (resp_expected) {
- p_trans_context = malloc(sizeof(trans_context_t));
- CL_ASSERT(p_trans_context);
-
- memset(p_trans_context, 0, sizeof(trans_context_t));
- p_trans_context->trans_id = p_mad->trans_id;
- p_trans_context->context = transaction_context;
- p_trans_context->sent_time = cl_get_time_stamp();
-
- cl_spinlock_acquire(&p_mad_bind_info->trans_ctxt_lock);
- cl_qlist_insert_tail(&p_mad_bind_info->trans_ctxt_list,
- &p_trans_context->list_item);
- cl_spinlock_release(&p_mad_bind_info->trans_ctxt_lock);
- }
-
- if (p_mad_bind_info->umadt_reg_class.ClassId == IB_MCLASS_SUBN_LID ||
- p_mad_bind_info->umadt_reg_class.ClassId == IB_MCLASS_SUBN_DIR) {
- /* Get one mad from uMadt */
- mad_count = 1;
- Status =
- p_umadt_obj->uMadtInterface.
- uMadtGetSendMad(p_mad_bind_info->umadt_handle, &mad_count,
- &p_madt_struct);
-
- if (Status != FSUCCESS || p_madt_struct == NULL) {
- return IB_ERROR;
- }
-
- /* No Segmentation required */
- memcpy(&p_madt_struct->IBMad, p_mad, MAD_BLOCK_SIZE);
-
- /* Post the MAD */
-
- Status =
- p_umadt_obj->uMadtInterface.uMadtPostSend(p_mad_bind_info->
- umadt_handle,
- p_madt_struct,
- &destAddr);
- if (Status != FSUCCESS) {
- printf("uMadtPostSendMad: Status = <%d>\n", Status);
- return IB_ERROR;
- }
-
- /* Release send MAD */
- Status =
- p_umadt_obj->uMadtInterface.
- uMadtReleaseSendMad(p_mad_bind_info->umadt_handle,
- p_madt_struct);
- if (Status != FSUCCESS) {
- printf("uMadtReleaseSendMad: Status = <%d>\n", Status);
- return IB_ERROR;
- }
- } else {
-
- /* */
- /* Segment the MAD, get the required send mads from uMadt and post the MADs. */
- /* */
- uint32_t payload_len;
-
- payload_len =
- cl_ntoh32(((ib_sa_mad_t_vM3 *) p_mad)->payload_len);
- num_mads = payload_len / IB_SA_DATA_SIZE;
- if (payload_len % IB_SA_DATA_SIZE != 0) {
- num_mads++; /* Get one additional mad for the remainder */
- }
- for (i = 0; i < num_mads; i++) {
- /* Get one mad from uMadt */
- mad_count = 1;
- Status =
- p_umadt_obj->uMadtInterface.
- uMadtGetSendMad(p_mad_bind_info->umadt_handle,
- &mad_count, &p_madt_struct);
-
- if (Status != FSUCCESS || p_madt_struct == NULL) {
- return IB_ERROR;
- }
- /* Copy client MAD into uMadt's MAD. */
- if (i == 0) { /* First Packet */
- /* Since this is the first MAD, copy the entire MAD_SIZE */
- memcpy(&p_madt_struct->IBMad, p_mad,
- MAD_BLOCK_SIZE);
-
- p_frag_data =
- (uint8_t *) p_mad + MAD_BLOCK_SIZE;
-
- p_sa_mad =
- (ib_sa_mad_t_vM3 *) & p_madt_struct->IBMad;
- if (num_mads == 1) { /* Only one Packet */
- p_sa_mad->seg_num = 0;
- p_sa_mad->frag_flag = 5; /* Set bit 0 for first pkt and b4 for last pkt */
- /* the payload length gets copied with the mad header above */
- } else { /* More than one packet in this response */
-
- seg_num = 1;
- p_sa_mad->seg_num =
- cl_ntoh32(seg_num++);
- p_sa_mad->frag_flag = 1; /* Set bit 0 for first pkt */
- /* the payload length gets copied with the mad header above */
- }
-
- } else if (i < num_mads - 1) { /* Not last packet */
- /* First copy only the header */
- memcpy(&p_madt_struct->IBMad, p_mad,
- IB_SA_MAD_HDR_SIZE);
- /* Set the relevant fields in the SA_MAD_HEADER */
- p_sa_mad =
- (ib_sa_mad_t_vM3 *) & p_madt_struct->IBMad;
- p_sa_mad->payload_len =
- cl_ntoh32(IB_SA_DATA_SIZE);
- p_sa_mad->seg_num = cl_ntoh32(seg_num++);
- p_sa_mad->frag_flag = 0;
- /* Now copy the fragmented data */
- memcpy(((uint8_t *) & p_madt_struct->IBMad) +
- IB_SA_MAD_HDR_SIZE, p_frag_data,
- IB_SA_DATA_SIZE);
- p_frag_data = p_frag_data + IB_SA_DATA_SIZE;
-
- } else if (i == num_mads - 1) { /* Last packet */
- /* First copy only the header */
- memcpy(&p_madt_struct->IBMad, p_mad,
- IB_SA_MAD_HDR_SIZE);
- /* Set the relevant fields in the SA_MAD_HEADER */
- p_sa_mad =
- (ib_sa_mad_t_vM3 *) & p_madt_struct->IBMad;
- p_sa_mad->seg_num = cl_ntoh32(seg_num++);
- p_sa_mad->frag_flag = 4; /* Set Bit 2 for last pkt */
- p_sa_mad->payload_len =
- cl_ntoh32(cl_ntoh32
- (((ib_sa_mad_t_vM3 *) p_mad)->
- payload_len) % IB_SA_DATA_SIZE);
- /* Now copy the fragmented data */
- memcpy((((uint8_t *) & p_madt_struct->IBMad)) +
- IB_SA_MAD_HDR_SIZE, p_frag_data,
- cl_ntoh32(p_sa_mad->payload_len));
- p_frag_data = p_frag_data + IB_SA_DATA_SIZE;
-
- }
- /* Post the MAD */
- Status =
- p_umadt_obj->uMadtInterface.
- uMadtPostSend(p_mad_bind_info->umadt_handle,
- p_madt_struct, &destAddr);
- if (Status != FSUCCESS) {
- printf("uMadtPostSendMad: Status = <%d>\n",
- Status);
- return IB_ERROR;
- }
-
- /* Release send MAD */
- Status =
- p_umadt_obj->uMadtInterface.
- uMadtReleaseSendMad(p_mad_bind_info->umadt_handle,
- p_madt_struct);
- if (Status != FSUCCESS) {
- printf("uMadtReleaseSendMad: Status = <%d>\n",
- Status);
- return IB_ERROR;
- }
- }
- }
- return (IB_SUCCESS);
-}
-
-/* //////////////////////////////////////////////////////////////////////// */
-/* See VendorAbstractMadIntf.h for info */
-/* //////////////////////////////////////////////////////////////////////// */
-
-osm_bind_handle_t
-osm_vendor_bind(IN osm_vendor_t * const p_vend,
- IN osm_bind_info_t * const p_osm_bind_info,
- IN osm_mad_pool_t * const p_mad_pool,
- IN osm_vend_mad_recv_callback_t mad_recv_callback,
- IN void *context)
-{
- cl_status_t cl_status;
- FSTATUS Status; /* GEN1 Status for Umadt */
-
- mad_bind_info_t *p_mad_bind_info;
- RegisterClassStruct *p_umadt_reg_class;
-
- umadt_obj_t *p_umadt_obj;
- OSM_LOG_ENTER(((umadt_obj_t *) p_vend)->p_log);
-
- CL_ASSERT(p_vend);
-
- p_umadt_obj = (umadt_obj_t *) p_vend;
-
- /* Sanity check */
- CL_ASSERT(p_umadt_obj->init_done);
- CL_ASSERT(p_osm_bind_info);
- CL_ASSERT(p_mad_pool);
- CL_ASSERT(mad_recv_callback);
-
- /* Allocate memory for registering the handle. */
- p_mad_bind_info = (mad_bind_info_t *) malloc(sizeof(*p_mad_bind_info));
- if (p_mad_bind_info) {
- memset(p_mad_bind_info, 0, sizeof(*p_mad_bind_info));
- p_umadt_reg_class = &p_mad_bind_info->umadt_reg_class;
- }
- p_umadt_reg_class->PortGuid = cl_ntoh64(p_osm_bind_info->port_guid);
- p_umadt_reg_class->ClassId = p_osm_bind_info->mad_class;
- p_umadt_reg_class->ClassVersion = p_osm_bind_info->class_version;
- p_umadt_reg_class->isResponder = p_osm_bind_info->is_responder;
- p_umadt_reg_class->isTrapProcessor = p_osm_bind_info->is_trap_processor;
- p_umadt_reg_class->isReportProcessor =
- p_osm_bind_info->is_report_processor;
- p_umadt_reg_class->SendQueueSize = p_osm_bind_info->send_q_size;
- p_umadt_reg_class->RecvQueueSize = p_osm_bind_info->recv_q_size;
- p_umadt_reg_class->NotifySendCompletion = TRUE;
-
- p_mad_bind_info->p_umadt_obj = p_umadt_obj;
- p_mad_bind_info->p_mad_pool = p_mad_pool;
- p_mad_bind_info->mad_recv_callback = mad_recv_callback;
- p_mad_bind_info->client_context = context;
-
- /* register with Umadt for MAD interface */
- Status = p_umadt_obj->uMadtInterface.uMadtRegister(p_umadt_reg_class,
- &p_mad_bind_info->
- umadt_handle);
- if (Status != FSUCCESS) {
- free(p_mad_bind_info);
- OSM_LOG_EXIT(p_umadt_obj->p_log);
- return (OSM_BIND_INVALID_HANDLE);
- }
- CL_ASSERT(p_mad_bind_info->umadt_handle);
- /* */
- /* Start a worker thread to process receives. */
- /* */
- cl_thread_construct(&p_mad_bind_info->recv_processor_thread);
- cl_status = cl_thread_init(&p_mad_bind_info->recv_processor_thread,
- __mad_recv_processor,
- (void *)p_mad_bind_info, "mad_recv_worker");
- CL_ASSERT(cl_status == CL_SUCCESS);
-
- cl_qlist_init(&p_mad_bind_info->trans_ctxt_list);
- cl_spinlock_construct(&p_mad_bind_info->trans_ctxt_lock);
- cl_spinlock_init(&p_mad_bind_info->trans_ctxt_lock);
- cl_spinlock_construct(&p_mad_bind_info->timeout_list_lock);
- cl_spinlock_init(&p_mad_bind_info->timeout_list_lock);
-
- cl_status = cl_timer_init(&p_mad_bind_info->timeout_timer,
- __osm_vendor_timer_callback,
- (void *)p_mad_bind_info);
- CL_ASSERT(cl_status == CL_SUCCESS);
- cl_qlist_init(&p_mad_bind_info->timeout_list);
- /* */
- /* Insert the mad_reg_struct in list and return pointer to it as the handle */
- /* */
- cl_spinlock_acquire(&p_umadt_obj->register_lock);
-
- cl_qlist_insert_head(&p_umadt_obj->register_list,
- &p_mad_bind_info->list_item);
-
- cl_spinlock_release(&p_umadt_obj->register_lock);
-
- /*
- A timeout value of 0 means disable timeouts.
- */
- if (p_umadt_obj->timeout) {
- cl_timer_start(&p_mad_bind_info->timeout_timer,
- DEFAULT_TIMER_INTERVAL_MSEC);
- }
-
- OSM_LOG_EXIT(p_umadt_obj->p_log);
- return ((osm_bind_handle_t) p_mad_bind_info);
-}
-
-/**********************************************************************
- **********************************************************************/
-void osm_vendor_unbind(IN osm_bind_handle_t h_bind)
-{
- mad_bind_info_t *p_mad_bind_info;
- umadt_obj_t *p_umadt_obj;
- cl_list_item_t *p_list_item, *p_next_list_item;
-
- CL_ASSERT(h_bind);
- p_mad_bind_info = (mad_bind_info_t *) h_bind;
- p_umadt_obj = p_mad_bind_info->p_umadt_obj;
-
- /* sanity check */
- CL_ASSERT(p_umadt_obj);
- CL_ASSERT(p_umadt_obj->init_done);
- CL_ASSERT(__valid_mad_handle(p_mad_bind_info));
-
- p_umadt_obj->uMadtInterface.uMadtDestroy(&p_mad_bind_info->
- umadt_handle);
- cl_timer_destroy(&p_mad_bind_info->timeout_timer);
- cl_thread_destroy(&p_mad_bind_info->recv_processor_thread);
-
- cl_spinlock_acquire(&p_mad_bind_info->trans_ctxt_lock);
- p_list_item = cl_qlist_head(&p_mad_bind_info->trans_ctxt_list);
- while (p_list_item != cl_qlist_end(&p_mad_bind_info->trans_ctxt_list)) {
- p_next_list_item = cl_qlist_next(p_list_item);
- cl_qlist_remove_item(&p_mad_bind_info->trans_ctxt_list,
- p_list_item);
- free(p_list_item);
- p_list_item = p_next_list_item;
- }
- cl_spinlock_release(&p_mad_bind_info->trans_ctxt_lock);
-
- cl_spinlock_acquire(&p_mad_bind_info->timeout_list_lock);
- p_list_item = cl_qlist_head(&p_mad_bind_info->timeout_list);
- while (p_list_item != cl_qlist_end(&p_mad_bind_info->timeout_list)) {
- p_next_list_item = cl_qlist_next(p_list_item);
- cl_qlist_remove_item(&p_mad_bind_info->timeout_list,
- p_list_item);
- free(p_list_item);
- p_list_item = p_next_list_item;
- }
- cl_spinlock_release(&p_mad_bind_info->timeout_list_lock);
-
- free(p_mad_bind_info);
-}
-
-/**********************************************************************
- **********************************************************************/
-void __mad_recv_processor(IN void *context)
-{
- mad_bind_info_t *p_mad_bind_info = (mad_bind_info_t *) context;
- umadt_obj_t *p_umadt_obj;
- osm_madw_t *p_osm_madw = NULL;
- osm_vend_wrap_t *p_vend_wrap = NULL;
- osm_mad_addr_t osm_mad_addr = { 0 };
- cl_list_item_t *p_list_item;
- void *transaction_context;
-
- FSTATUS Status;
- MadtStruct *pRecvMad = NULL;
- MadWorkCompletion *pRecvCmp = NULL;
-
- CL_ASSERT(context);
-
- p_mad_bind_info = (mad_bind_info_t *) context;
- p_umadt_obj = p_mad_bind_info->p_umadt_obj;
- /* PollFor a completion */
- /* if FNOTFOND, then wait for a completion then again poll and return the MAD */
- while (1) {
- Status =
- p_umadt_obj->uMadtInterface.
- uMadtPollForRecvCompletion(p_mad_bind_info->umadt_handle,
- &pRecvMad, &pRecvCmp);
- if (Status != FSUCCESS) {
- if (Status == FNOT_FOUND) {
- /* Wait for a completion */
- Status = p_umadt_obj->uMadtInterface.uMadtWaitForAnyCompletion(p_mad_bind_info->umadt_handle, RECV_COMPLETION, 0x5000); /* 5 sec timeout */
-
- if (Status == FTIMEOUT) {
- continue;
- }
- CL_ASSERT(Status == FSUCCESS);
-
- Status =
- p_umadt_obj->uMadtInterface.
- uMadtPollForRecvCompletion(p_mad_bind_info->
- umadt_handle,
- &pRecvMad,
- &pRecvCmp);
- if (Status != FSUCCESS) {
- printf
- (" mad_recv_worker: Error in PollForRecv returning <%x>\n",
- Status);
- CL_ASSERT(0);
- }
- } else {
- printf
- ("uMadtPollForRecvCompletion Status=<%x>\n",
- Status);
- CL_ASSERT(0);
- }
- }
- CL_ASSERT(pRecvMad);
- CL_ASSERT(pRecvCmp);
-
- if (((ib_sa_mad_t_vM3 *) (&pRecvMad->IBMad))->frag_flag & 0x20) {
- /* Ignore the ACK packet */
- Status =
- p_umadt_obj->uMadtInterface.
- uMadtReleaseRecvMad(p_mad_bind_info->umadt_handle,
- pRecvMad);
- continue;
- }
- /* */
- /* Extract the return address to pass it on to the client */
- /* */
- osm_mad_addr.dest_lid = pRecvCmp->AddressInfo.DestLid;
- osm_mad_addr.path_bits = pRecvCmp->AddressInfo.PathBits;
- osm_mad_addr.static_rate = pRecvCmp->AddressInfo.StaticRate;
-
- if (p_mad_bind_info->umadt_reg_class.ClassId ==
- IB_MCLASS_SUBN_LID
- || p_mad_bind_info->umadt_reg_class.ClassId ==
- IB_MCLASS_SUBN_DIR) {
- osm_mad_addr.addr_type.smi.source_lid =
- pRecvCmp->AddressInfo.AddrType.Smi.SourceLid;
- /* osm_mad_addr.addr_type.smi.port_num = pRecvCmp->AddressInfo.AddrType.Smi.PortNumber; */
- } else {
- osm_mad_addr.addr_type.gsi.remote_qp =
- pRecvCmp->AddressInfo.AddrType.Gsi.RemoteQpNumber;
- osm_mad_addr.addr_type.gsi.remote_qkey =
- pRecvCmp->AddressInfo.AddrType.Gsi.RemoteQkey;
- osm_mad_addr.addr_type.gsi.pkey_ix = 0;
- osm_mad_addr.addr_type.gsi.service_level =
- pRecvCmp->AddressInfo.AddrType.Gsi.ServiceLevel;
- osm_mad_addr.addr_type.gsi.global_route =
- pRecvCmp->AddressInfo.AddrType.Gsi.GlobalRoute;
- /* osm_mad_addr.addr_type.gsi.grh_info = pRecvCmp->AddressInfo.AddrType.Gsi.GRHInfo; */
- }
- p_osm_madw =
- osm_mad_pool_get_wrapper(p_mad_bind_info->p_mad_pool,
- p_mad_bind_info, MAD_BLOCK_SIZE,
- (ib_mad_t *) & pRecvMad->IBMad,
- &osm_mad_addr);
- CL_ASSERT(p_osm_madw);
- p_vend_wrap = osm_madw_get_vend_ptr(p_osm_madw);
- CL_ASSERT(p_vend_wrap);
- p_vend_wrap->p_madt_struct = pRecvMad;
- p_vend_wrap->direction = RECEIVE;
-
- osm_log(p_mad_bind_info->p_umadt_obj->p_log, OSM_LOG_DEBUG,
- "__mad_recv_processor: "
- "Received data p_osm_madw[0x%p].\n", p_osm_madw);
-
- /* */
- /* Do TID Processing. */
- /* */
- /* If R bit is set swap the TID */
-
- cl_spinlock_acquire(&p_mad_bind_info->trans_ctxt_lock);
- p_list_item =
- cl_qlist_find_from_head(&p_mad_bind_info->trans_ctxt_list,
- __match_tid_context,
- &p_osm_madw->p_mad->trans_id);
-
- if (p_list_item ==
- cl_qlist_end(&p_mad_bind_info->trans_ctxt_list)) {
- transaction_context = NULL;
- } else {
- transaction_context =
- ((trans_context_t *) p_list_item)->context;
- cl_qlist_remove_item(&p_mad_bind_info->trans_ctxt_list,
- p_list_item);
- free(p_list_item);
- }
- cl_spinlock_release(&p_mad_bind_info->trans_ctxt_lock);
- ((ib_mad_t *) p_osm_madw->p_mad)->trans_id =
- cl_ntoh64(p_osm_madw->p_mad->trans_id >> 24);
- osm_log(p_mad_bind_info->p_umadt_obj->p_log, OSM_LOG_DEBUG,
- "__mad_recv_processor: "
- "Received data p_osm_madw [0x%p]" "\n\t\t\t\tTID[0x%"
- PRIx64 ", context[%p]. \n", p_osm_madw,
- ((ib_mad_t *) p_osm_madw->p_mad)->trans_id,
- transaction_context);
-
- (*(p_mad_bind_info->mad_recv_callback)) (p_osm_madw,
- p_mad_bind_info->
- client_context,
- transaction_context);
-
- }
-}
-
-/**********************************************************************
- **********************************************************************/
-
-cl_status_t
-__match_tid_context(const cl_list_item_t * const p_list_item, void *context)
-{
- if (((trans_context_t *) p_list_item)->trans_id ==
- *((uint64_t *) context))
- return CL_SUCCESS;
- return CL_NOT_FOUND;
-}
-
-/**********************************************************************
- **********************************************************************/
-
-boolean_t __valid_mad_handle(IN mad_bind_info_t * p_mad_bind_info)
-{
-
- umadt_obj_t *p_umadt_obj;
-
- p_umadt_obj = p_mad_bind_info->p_umadt_obj;
-
- cl_spinlock_acquire(&p_umadt_obj->register_lock);
- if (!cl_is_item_in_qlist(&p_umadt_obj->register_list,
- &p_mad_bind_info->list_item)) {
- cl_spinlock_release(&p_umadt_obj->register_lock);
- return FALSE;
- }
- cl_spinlock_release(&p_umadt_obj->register_lock);
- return TRUE;
-}
-
-void __osm_vendor_timer_callback(IN void *context)
-{
- uint64_t current_time;
- mad_bind_info_t *p_mad_bind_info;
- umadt_obj_t *p_umadt_obj;
- uint32_t timeout;
-
- cl_list_item_t *p_list_item, *p_next_list_item;
-
- CL_ASSERT(context);
-
- p_mad_bind_info = (mad_bind_info_t *) context;
- p_umadt_obj = p_mad_bind_info->p_umadt_obj;
- timeout = p_umadt_obj->timeout * 1000;
-
- current_time = cl_get_time_stamp();
-
- cl_spinlock_acquire(&p_mad_bind_info->trans_ctxt_lock);
-
- p_list_item = cl_qlist_head(&p_mad_bind_info->trans_ctxt_list);
- while (p_list_item != cl_qlist_end(&p_mad_bind_info->trans_ctxt_list)) {
-
- p_next_list_item = cl_qlist_next(p_list_item);
-
- /* DEFAULT_PKT_TIMEOUT is in milli seconds */
- if (current_time - ((trans_context_t *) p_list_item)->sent_time
- > timeout) {
- /* Add this transaction to the timeout_list */
- cl_qlist_remove_item(&p_mad_bind_info->trans_ctxt_list,
- p_list_item);
- cl_qlist_insert_tail(&p_mad_bind_info->timeout_list,
- p_list_item);
- }
-
- p_list_item = p_next_list_item;
- }
-
- cl_spinlock_release(&p_mad_bind_info->trans_ctxt_lock);
-
- p_list_item = cl_qlist_head(&p_mad_bind_info->timeout_list);
- while (p_list_item != cl_qlist_end(&p_mad_bind_info->timeout_list)) {
- osm_log(p_mad_bind_info->p_umadt_obj->p_log, OSM_LOG_DEBUG,
- "__osm_vendor_timer_callback: "
- "Timing out transaction context [0x%p].\n",
- ((trans_context_t *) p_list_item)->context);
-
- (*(p_mad_bind_info->mad_recv_callback)) (NULL,
- p_mad_bind_info->
- client_context,
- ((trans_context_t *)
- p_list_item)->
- context);
-
- p_next_list_item = cl_qlist_next(p_list_item);
- cl_qlist_remove_item(&p_mad_bind_info->timeout_list,
- p_list_item);
- free(p_list_item);
- p_list_item = p_next_list_item;
- }
-
- cl_timer_start(&p_mad_bind_info->timeout_timer,
- DEFAULT_TIMER_INTERVAL_MSEC);
-
-}
-
-#endif /* OSM_VENDOR_INTF_UMADT */
diff --git a/contrib/ofed/management/opensm/man/opensm.8 b/contrib/ofed/management/opensm/man/opensm.8
deleted file mode 100644
index 3000eaf..0000000
--- a/contrib/ofed/management/opensm/man/opensm.8
+++ /dev/null
@@ -1,1012 +0,0 @@
-.TH OPENSM 8 "June 13, 2008" "OpenIB" "OpenIB Management"
-
-.SH NAME
-opensm \- InfiniBand subnet manager and administration (SM/SA)
-
-.SH SYNOPSIS
-.B opensm
-[\-\-version]]
-[\-F | \-\-config <file_name>]
-[\-c(reate-config) <file_name>]
-[\-g(uid) <GUID in hex>]
-[\-l(mc) <LMC>]
-[\-p(riority) <PRIORITY>]
-[\-smkey <SM_Key>]
-[\-r(eassign_lids)]
-[\-R <engine name(s)> | \-\-routing_engine <engine name(s)>]
-[\-A | \-\-ucast_cache]
-[\-z | \-\-connect_roots]
-[\-M <file name> | \-\-lid_matrix_file <file name>]
-[\-U <file name> | \-\-lfts_file <file name>]
-[\-S | \-\-sadb_file <file name>]
-[\-a | \-\-root_guid_file <path to file>]
-[\-u | \-\-cn_guid_file <path to file>]
-[\-X | \-\-guid_routing_order_file <path to file>]
-[\-m | \-\-ids_guid_file <path to file>]
-[\-o(nce)]
-[\-s(weep) <interval>]
-[\-t(imeout) <milliseconds>]
-[\-maxsmps <number>]
-[\-console [off | local | socket | loopback]]
-[\-console-port <port>]
-[\-i(gnore-guids) <equalize-ignore-guids-file>]
-[\-f <log file path> | \-\-log_file <log file path> ]
-[\-L | \-\-log_limit <size in MB>] [\-e(rase_log_file)]
-[\-P(config) <partition config file> ]
-[\-N | \-\-no_part_enforce]
-[\-Q | \-\-qos [\-Y | \-\-qos_policy_file <file name>]]
-[\-y | \-\-stay_on_fatal]
-[\-B | \-\-daemon]
-[\-I | \-\-inactive]
-[\-\-perfmgr]
-[\-\-perfmgr_sweep_time_s <seconds>]
-[\-\-prefix_routes_file <path>]
-[\-\-consolidate_ipv6_snm_req]
-[\-v(erbose)] [\-V] [\-D <flags>] [\-d(ebug) <number>]
-[\-h(elp)] [\-?]
-
-.SH DESCRIPTION
-.PP
-opensm is an InfiniBand compliant Subnet Manager and Administration,
-and runs on top of OpenIB.
-
-opensm provides an implementation of an InfiniBand Subnet Manager and
-Administration. Such a software entity is required to run for in order
-to initialize the InfiniBand hardware (at least one per each
-InfiniBand subnet).
-
-opensm also now contains an experimental version of a performance
-manager as well.
-
-opensm defaults were designed to meet the common case usage on clusters with up to a few hundred nodes. Thus, in this default mode, opensm will scan the IB
-fabric, initialize it, and sweep occasionally for changes.
-
-opensm attaches to a specific IB port on the local machine and configures only
-the fabric connected to it. (If the local machine has other IB ports,
-opensm will ignore the fabrics connected to those other ports). If no port is
-specified, it will select the first "best" available port.
-
-opensm can present the available ports and prompt for a port number to
-attach to.
-
-By default, the run is logged to two files: /var/log/messages and /var/log/opensm.log.
-The first file will register only general major events, whereas the second
-will include details of reported errors. All errors reported in this second
-file should be treated as indicators of IB fabric health issues.
-(Note that when a fatal and non-recoverable error occurs, opensm will exit.)
-Both log files should include the message "SUBNET UP" if opensm was able to
-setup the subnet correctly.
-
-.SH OPTIONS
-
-.PP
-.TP
-\fB\-\-version\fR
-Prints OpenSM version and exits.
-.TP
-\fB\-F\fR, \fB\-\-config\fR <config file>
-The name of the OpenSM config file. When not specified
-\fB\% @OPENSM_CONFIG_DIR@/@OPENSM_CONFIG_FILE@\fP will be used (if exists).
-.TP
-\fB\-c\fR, \fB\-\-create-config\fR <file name>
-OpenSM will dump its configuration to the specified file and exit.
-This is a way to generate OpenSM configuration file template.
-.TP
-\fB\-g\fR, \fB\-\-guid\fR <GUID in hex>
-This option specifies the local port GUID value
-with which OpenSM should bind. OpenSM may be
-bound to 1 port at a time.
-If GUID given is 0, OpenSM displays a list
-of possible port GUIDs and waits for user input.
-Without -g, OpenSM tries to use the default port.
-.TP
-\fB\-l\fR, \fB\-\-lmc\fR <LMC value>
-This option specifies the subnet's LMC value.
-The number of LIDs assigned to each port is 2^LMC.
-The LMC value must be in the range 0-7.
-LMC values > 0 allow multiple paths between ports.
-LMC values > 0 should only be used if the subnet
-topology actually provides multiple paths between
-ports, i.e. multiple interconnects between switches.
-Without -l, OpenSM defaults to LMC = 0, which allows
-one path between any two ports.
-.TP
-\fB\-p\fR, \fB\-\-priority\fR <Priority value>
-This option specifies the SM\'s PRIORITY.
-This will effect the handover cases, where master
-is chosen by priority and GUID. Range goes from 0
-(default and lowest priority) to 15 (highest).
-.TP
-\fB\-smkey\fR <SM_Key value>
-This option specifies the SM\'s SM_Key (64 bits).
-This will effect SM authentication.
-Note that OpenSM version 3.2.1 and below used the default value '1'
-in a host byte order, it is fixed now but you may need this option to
-interoperate with old OpenSM running on a little endian machine.
-.TP
-\fB\-r\fR, \fB\-\-reassign_lids\fR
-This option causes OpenSM to reassign LIDs to all
-end nodes. Specifying -r on a running subnet
-may disrupt subnet traffic.
-Without -r, OpenSM attempts to preserve existing
-LID assignments resolving multiple use of same LID.
-.TP
-\fB\-R\fR, \fB\-\-routing_engine\fR <Routing engine names>
-This option chooses routing engine(s) to use instead of Min Hop
-algorithm (default). Multiple routing engines can be specified
-separated by commas so that specific ordering of routing algorithms
-will be tried if earlier routing engines fail.
-Supported engines: minhop, updn, file, ftree, lash, dor
-.TP
-\fB\-A\fR, \fB\-\-ucast_cache\fR
-This option enables unicast routing cache and prevents routing
-recalculation (which is a heavy task in a large cluster) when
-there was no topology change detected during the heavy sweep, or
-when the topology change does not require new routing calculation,
-e.g. when one or more CAs/RTRs/leaf switches going down, or one or
-more of these nodes coming back after being down.
-A very common case that is handled by the unicast routing cache
-is host reboot, which otherwise would cause two full routing
-recalculations: one when the host goes down, and the other when
-the host comes back online.
-.TP
-\fB\-z\fR, \fB\-\-connect_roots\fR
-This option enforces a routing engine (currently up/down
-only) to make connectivity between root switches and in
-this way to be fully IBA complaint. In many cases this can
-violate "pure" deadlock free algorithm, so use it carefully.
-.TP
-\fB\-M\fR, \fB\-\-lid_matrix_file\fR <file name>
-This option specifies the name of the lid matrix dump file
-from where switch lid matrices (min hops tables will be
-loaded.
-.TP
-\fB\-U\fR, \fB\-\-lfts_file\fR <file name>
-This option specifies the name of the LFTs file
-from where switch forwarding tables will be loaded.
-.TP
-\fB\-S\fR, \fB\-\-sadb_file\fR <file name>
-This option specifies the name of the SA DB dump file
-from where SA database will be loaded.
-.TP
-\fB\-a\fR, \fB\-\-root_guid_file\fR <file name>
-Set the root nodes for the Up/Down or Fat-Tree routing
-algorithm to the guids provided in the given file (one to a line).
-.TP
-\fB\-u\fR, \fB\-\-cn_guid_file\fR <file name>
-Set the compute nodes for the Fat-Tree routing algorithm
-to the guids provided in the given file (one to a line).
-.TP
-\fB\-m\fR, \fB\-\-ids_guid_file\fR <file name>
-Name of the map file with set of the IDs which will be used
-by Up/Down routing algorithm instead of node GUIDs
-(format: <guid> <id> per line).
-.TP
-\fB\-X\fR, \fB\-\-guid_routing_order_file\fR <file name>
-Set the order port guids will be routed for the MinHop
-and Up/Down routing algorithms to the guids provided in the
-given file (one to a line).
-.TP
-\fB\-o\fR, \fB\-\-once\fR
-This option causes OpenSM to configure the subnet
-once, then exit. Ports remain in the ACTIVE state.
-.TP
-\fB\-s\fR, \fB\-\-sweep\fR <interval value>
-This option specifies the number of seconds between
-subnet sweeps. Specifying -s 0 disables sweeping.
-Without -s, OpenSM defaults to a sweep interval of
-10 seconds.
-.TP
-\fB\-t\fR, \fB\-\-timeout\fR <value>
-This option specifies the time in milliseconds
-used for transaction timeouts.
-Specifying -t 0 disables timeouts.
-Without -t, OpenSM defaults to a timeout value of
-200 milliseconds.
-.TP
-\fB\-maxsmps\fR <number>
-This option specifies the number of VL15 SMP MADs
-allowed on the wire at any one time.
-Specifying -maxsmps 0 allows unlimited outstanding
-SMPs.
-Without -maxsmps, OpenSM defaults to a maximum of
-4 outstanding SMPs.
-.TP
-\fB\-console [off | local | socket | loopback]\fR
-This option brings up the OpenSM console (default off).
-Note that the socket and loopback options will only be available
-if OpenSM was built with --enable-console-socket.
-.TP
-\fB\-console-port\fR <port>
-Specify an alternate telnet port for the socket console (default 10000).
-Note that this option only appears if OpenSM was built with
---enable-console-socket.
-.TP
-\fB\-i\fR, \fB\-ignore-guids\fR <equalize-ignore-guids-file>
-This option provides the means to define a set of ports
-(by node guid and port number) that will be ignored by the link load
-equalization algorithm.
-.TP
-\fB\-x\fR, \fB\-\-honor_guid2lid\fR
-This option forces OpenSM to honor the guid2lid file,
-when it comes out of Standby state, if such file exists
-under OSM_CACHE_DIR, and is valid.
-By default, this is FALSE.
-.TP
-\fB\-f\fR, \fB\-\-log_file\fR <file name>
-This option defines the log to be the given file.
-By default, the log goes to /var/log/opensm.log.
-For the log to go to standard output use -f stdout.
-.TP
-\fB\-L\fR, \fB\-\-log_limit\fR <size in MB>
-This option defines maximal log file size in MB. When
-specified the log file will be truncated upon reaching
-this limit.
-.TP
-\fB\-e\fR, \fB\-\-erase_log_file\fR
-This option will cause deletion of the log file
-(if it previously exists). By default, the log file
-is accumulative.
-.TP
-\fB\-P\fR, \fB\-\-Pconfig\fR <partition config file>
-This option defines the optional partition configuration file.
-The default name is \fB\%@OPENSM_CONFIG_DIR@/@PARTITION_CONFIG_FILE@\fP.
-.TP
-\fB\-\-prefix_routes_file\fR <file name>
-Prefix routes control how the SA responds to path record queries for
-off-subnet DGIDs. By default, the SA fails such queries. The
-.B PREFIX ROUTES
-section below describes the format of the configuration file.
-The default path is \fB\%@OPENSM_CONFIG_DIR@/prefix\-routes.conf\fP.
-.TP
-\fB\-Q\fR, \fB\-\-qos\fR
-This option enables QoS setup. It is disabled by default.
-.TP
-\fB\-Y\fR, \fB\-\-qos_policy_file\fR <file name>
-This option defines the optional QoS policy file. The default
-name is \fB\%@OPENSM_CONFIG_DIR@/@QOS_POLICY_FILE@\fP.
-.TP
-\fB\-N\fR, \fB\-\-no_part_enforce\fR
-This option disables partition enforcement on switch external ports.
-.TP
-\fB\-y\fR, \fB\-\-stay_on_fatal\fR
-This option will cause SM not to exit on fatal initialization
-issues: if SM discovers duplicated guids or a 12x link with
-lane reversal badly configured.
-By default, the SM will exit on these errors.
-.TP
-\fB\-B\fR, \fB\-\-daemon\fR
-Run in daemon mode - OpenSM will run in the background.
-.TP
-\fB\-I\fR, \fB\-\-inactive\fR
-Start SM in inactive rather than init SM state. This
-option can be used in conjunction with the perfmgr so as to
-run a standalone performance manager without SM/SA. However,
-this is NOT currently implemented in the performance manager.
-.TP
-\fB\-perfmgr\fR
-Enable the perfmgr. Only takes effect if --enable-perfmgr was specified at
-configure time.
-.TP
-\fB\-perfmgr_sweep_time_s\fR <seconds>
-Specify the sweep time for the performance manager in seconds
-(default is 180 seconds). Only takes
-effect if --enable-perfmgr was specified at configure time.
-.TP
-.BI --consolidate_ipv6_snm_req
-Consolidate IPv6 Solicited Node Multicast group join requests into one
-multicast group per MGID PKey.
-.TP
-\fB\-v\fR, \fB\-\-verbose\fR
-This option increases the log verbosity level.
-The -v option may be specified multiple times
-to further increase the verbosity level.
-See the -D option for more information about
-log verbosity.
-.TP
-\fB\-V\fR
-This option sets the maximum verbosity level and
-forces log flushing.
-The -V option is equivalent to \'-D 0xFF -d 2\'.
-See the -D option for more information about
-log verbosity.
-.TP
-\fB\-D\fR <value>
-This option sets the log verbosity level.
-A flags field must follow the -D option.
-A bit set/clear in the flags enables/disables a
-specific log level as follows:
-
- BIT LOG LEVEL ENABLED
- ---- -----------------
- 0x01 - ERROR (error messages)
- 0x02 - INFO (basic messages, low volume)
- 0x04 - VERBOSE (interesting stuff, moderate volume)
- 0x08 - DEBUG (diagnostic, high volume)
- 0x10 - FUNCS (function entry/exit, very high volume)
- 0x20 - FRAMES (dumps all SMP and GMP frames)
- 0x40 - ROUTING (dump FDB routing information)
- 0x80 - currently unused.
-
-Without -D, OpenSM defaults to ERROR + INFO (0x3).
-Specifying -D 0 disables all messages.
-Specifying -D 0xFF enables all messages (see -V).
-High verbosity levels may require increasing
-the transaction timeout with the -t option.
-.TP
-\fB\-d\fR, \fB\-\-debug\fR <value>
-This option specifies a debug option.
-These options are not normally needed.
-The number following -d selects the debug
-option to enable as follows:
-
- OPT Description
- --- -----------------
- -d0 - Ignore other SM nodes
- -d1 - Force single threaded dispatching
- -d2 - Force log flushing after each log message
- -d3 - Disable multicast support
-.TP
-\fB\-h\fR, \fB\-\-help\fR
-Display this usage info then exit.
-.TP
-\fB\-?\fR
-Display this usage info then exit.
-
-.SH ENVIRONMENT VARIABLES
-.PP
-The following environment variables control opensm behavior:
-
-OSM_TMP_DIR - controls the directory in which the temporary files generated by
-opensm are created. These files are: opensm-subnet.lst, opensm.fdbs, and
-opensm.mcfdbs. By default, this directory is /var/log.
-
-OSM_CACHE_DIR - opensm stores certain data to the disk such that subsequent
-runs are consistent. The default directory used is /var/cache/opensm.
-The following file is included in it:
-
- guid2lid - stores the LID range assigned to each GUID
-
-.SH NOTES
-.PP
-When opensm receives a HUP signal, it starts a new heavy sweep as if a trap was received or a topology change was found.
-.PP
-Also, SIGUSR1 can be used to trigger a reopen of /var/log/opensm.log for
-logrotate purposes.
-
-.SH PARTITION CONFIGURATION
-.PP
-The default name of OpenSM partitions configuration file is
-\fB\%@OPENSM_CONFIG_DIR@/@PARTITION_CONFIG_FILE@\fP. The default may be changed by using
---Pconfig (-P) option with OpenSM.
-
-The default partition will be created by OpenSM unconditionally even
-when partition configuration file does not exist or cannot be accessed.
-
-The default partition has P_Key value 0x7fff. OpenSM\'s port will have
-full membership in default partition. All other end ports will have
-partial membership.
-
-File Format
-
-Comments:
-
-Line content followed after \'#\' character is comment and ignored by
-parser.
-
-General file format:
-
-<Partition Definition>:<PortGUIDs list> ;
-
-Partition Definition:
-
-[PartitionName][=PKey][,flag[=value]][,defmember=full|limited]
-
- PartitionName - string, will be used with logging. When omitted
- empty string will be used.
- PKey - P_Key value for this partition. Only low 15 bits will
- be used. When omitted will be autogenerated.
- flag - used to indicate IPoIB capability of this partition.
- defmember=full|limited - specifies default membership for port guid
- list. Default is limited.
-
-Currently recognized flags are:
-
- ipoib - indicates that this partition may be used for IPoIB, as
- result IPoIB capable MC group will be created.
- rate=<val> - specifies rate for this IPoIB MC group
- (default is 3 (10GBps))
- mtu=<val> - specifies MTU for this IPoIB MC group
- (default is 4 (2048))
- sl=<val> - specifies SL for this IPoIB MC group
- (default is 0)
- scope=<val> - specifies scope for this IPoIB MC group
- (default is 2 (link local)). Multiple scope settings
- are permitted for a partition.
-
-Note that values for rate, mtu, and scope should be specified as
-defined in the IBTA specification (for example, mtu=4 for 2048).
-
-PortGUIDs list:
-
- PortGUID - GUID of partition member EndPort. Hexadecimal
- numbers should start from 0x, decimal numbers
- are accepted too.
- full or limited - indicates full or limited membership for this
- port. When omitted (or unrecognized) limited
- membership is assumed.
-
-There are two useful keywords for PortGUID definition:
-
- - 'ALL' means all end ports in this subnet.
- - 'SELF' means subnet manager's port.
-
-Empty list means no ports in this partition.
-
-Notes:
-
-White space is permitted between delimiters ('=', ',',':',';').
-
-The line can be wrapped after ':' followed after Partition Definition and
-between.
-
-PartitionName does not need to be unique, PKey does need to be unique.
-If PKey is repeated then those partition configurations will be merged
-and first PartitionName will be used (see also next note).
-
-It is possible to split partition configuration in more than one
-definition, but then PKey should be explicitly specified (otherwise
-different PKey values will be generated for those definitions).
-
-Examples:
-
- Default=0x7fff : ALL, SELF=full ;
-
- NewPartition , ipoib : 0x123456=full, 0x3456789034=limi, 0x2134af2306 ;
-
- YetAnotherOne = 0x300 : SELF=full ;
- YetAnotherOne = 0x300 : ALL=limited ;
-
- ShareIO = 0x80 , defmember=full : 0x123451, 0x123452;
- # 0x123453, 0x123454 will be limited
- ShareIO = 0x80 : 0x123453, 0x123454, 0x123455=full;
- # 0x123456, 0x123457 will be limited
- ShareIO = 0x80 : defmember=limited : 0x123456, 0x123457, 0x123458=full;
- ShareIO = 0x80 , defmember=full : 0x123459, 0x12345a;
- ShareIO = 0x80 , defmember=full : 0x12345b, 0x12345c=limited, 0x12345d;
-
-
-Note:
-
-The following rule is equivalent to how OpenSM used to run prior to the
-partition manager:
-
- Default=0x7fff,ipoib:ALL=full;
-
-.SH QOS CONFIGURATION
-.PP
-There are a set of QoS related low-level configuration parameters.
-All these parameter names are prefixed by "qos_" string. Here is a full
-list of these parameters:
-
- qos_max_vls - The maximum number of VLs that will be on the subnet
- qos_high_limit - The limit of High Priority component of VL
- Arbitration table (IBA 7.6.9)
- qos_vlarb_low - Low priority VL Arbitration table (IBA 7.6.9)
- template
- qos_vlarb_high - High priority VL Arbitration table (IBA 7.6.9)
- template
- Both VL arbitration templates are pairs of
- VL and weight
- qos_sl2vl - SL2VL Mapping table (IBA 7.6.6) template. It is
- a list of VLs corresponding to SLs 0-15 (Note
- that VL15 used here means drop this SL)
-
-Typical default values (hard-coded in OpenSM initialization) are:
-
- qos_max_vls 15
- qos_high_limit 0
- qos_vlarb_low 0:0,1:4,2:4,3:4,4:4,5:4,6:4,7:4,8:4,9:4,10:4,11:4,12:4,13:4,14:4
- qos_vlarb_high 0:4,1:0,2:0,3:0,4:0,5:0,6:0,7:0,8:0,9:0,10:0,11:0,12:0,13:0,14:0
- qos_sl2vl 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,7
-
-The syntax is compatible with rest of OpenSM configuration options and
-values may be stored in OpenSM config file (cached options file).
-
-In addition to the above, we may define separate QoS configuration
-parameters sets for various target types. As targets, we currently support
-CAs, routers, switch external ports, and switch's enhanced port 0. The
-names of such specialized parameters are prefixed by "qos_<type>_"
-string. Here is a full list of the currently supported sets:
-
- qos_ca_ - QoS configuration parameters set for CAs.
- qos_rtr_ - parameters set for routers.
- qos_sw0_ - parameters set for switches' port 0.
- qos_swe_ - parameters set for switches' external ports.
-
-Examples:
- qos_sw0_max_vls=2
- qos_ca_sl2vl=0,1,2,3,5,5,5,12,12,0,
- qos_swe_high_limit=0
-
-.SH PREFIX ROUTES
-.PP
-Prefix routes control how the SA responds to path record queries for
-off-subnet DGIDs. By default, the SA fails such queries.
-Note that IBA does not specify how the SA should obtain off-subnet path
-record information.
-The prefix routes configuration is meant as a stop-gap until the
-specification is completed.
-.PP
-Each line in the configuration file is a 64-bit prefix followed by a
-64-bit GUID, separated by white space.
-The GUID specifies the router port on the local subnet that will
-handle the prefix.
-Blank lines are ignored, as is anything between a \fB#\fP character
-and the end of the line.
-The prefix and GUID are both in hex, the leading 0x is optional.
-Either, or both, can be wild-carded by specifying an
-asterisk instead of an explicit prefix or GUID.
-.PP
-When responding to a path record query for an off-subnet DGID,
-opensm searches for the first prefix match in the configuration file.
-Therefore, the order of the lines in the configuration file is important:
-a wild-carded prefix at the beginning of the configuration file renders
-all subsequent lines useless.
-If there is no match, then opensm fails the query.
-It is legal to repeat prefixes in the configuration file,
-opensm will return the path to the first available matching router.
-A configuration file with a single line where both prefix and GUID
-are wild-carded means that a path record query specifying any
-off-subnet DGID should return a path to the first available router.
-This configuration yields the same behaviour formerly achieved by
-compiling opensm with -DROUTER_EXP.
-
-.SH ROUTING
-.PP
-OpenSM now offers five routing engines:
-
-1. Min Hop Algorithm - based on the minimum hops to each node where the
-path length is optimized.
-
-2. UPDN Unicast routing algorithm - also based on the minimum hops to each
-node, but it is constrained to ranking rules. This algorithm should be chosen
-if the subnet is not a pure Fat Tree, and deadlock may occur due to a
-loop in the subnet.
-
-3. Fat Tree Unicast routing algorithm - this algorithm optimizes routing
-for congestion-free "shift" communication pattern.
-It should be chosen if a subnet is a symmetrical or almost symmetrical
-fat-tree of various types, not just K-ary-N-Trees: non-constant K, not
-fully staffed, any Constant Bisectional Bandwidth (CBB) ratio.
-Similar to UPDN, Fat Tree routing is constrained to ranking rules.
-
-4. LASH unicast routing algorithm - uses Infiniband virtual layers
-(SL) to provide deadlock-free shortest-path routing while also
-distributing the paths between layers. LASH is an alternative
-deadlock-free topology-agnostic routing algorithm to the non-minimal
-UPDN algorithm avoiding the use of a potentially congested root node.
-
-5. DOR Unicast routing algorithm - based on the Min Hop algorithm, but
-avoids port equalization except for redundant links between the same
-two switches. This provides deadlock free routes for hypercubes when
-the fabric is cabled as a hypercube and for meshes when cabled as a
-mesh (see details below).
-
-OpenSM also supports a file method which
-can load routes from a table. See \'Modular Routing Engine\' for more
-information on this.
-
-The basic routing algorithm is comprised of two stages:
-
-1. MinHop matrix calculation
- How many hops are required to get from each port to each LID ?
- The algorithm to fill these tables is different if you run standard
-(min hop) or Up/Down.
- For standard routing, a "relaxation" algorithm is used to propagate
-min hop from every destination LID through neighbor switches
- For Up/Down routing, a BFS from every target is used. The BFS tracks link
-direction (up or down) and avoid steps that will perform up after a down
-step was used.
-
-2. Once MinHop matrices exist, each switch is visited and for each target LID a
-decision is made as to what port should be used to get to that LID.
- This step is common to standard and Up/Down routing. Each port has a
-counter counting the number of target LIDs going through it.
- When there are multiple alternative ports with same MinHop to a LID,
-the one with less previously assigned ports is selected.
- If LMC > 0, more checks are added: Within each group of LIDs assigned to
-same target port,
- a. use only ports which have same MinHop
- b. first prefer the ones that go to different systemImageGuid (then
-the previous LID of the same LMC group)
- c. if none - prefer those which go through another NodeGuid
- d. fall back to the number of paths method (if all go to same node).
-
-Effect of Topology Changes
-
-OpenSM will preserve existing routing in any case where there is no change in
-the fabric switches unless the -r (--reassign_lids) option is specified.
-
--r
-.br
---reassign_lids
- This option causes OpenSM to reassign LIDs to all
- end nodes. Specifying -r on a running subnet
- may disrupt subnet traffic.
- Without -r, OpenSM attempts to preserve existing
- LID assignments resolving multiple use of same LID.
-
-If a link is added or removed, OpenSM does not recalculate
-the routes that do not have to change. A route has to change
-if the port is no longer UP or no longer the MinHop. When routing changes
-are performed, the same algorithm for balancing the routes is invoked.
-
-In the case of using the file based routing, any topology changes are
-currently ignored The 'file' routing engine just loads the LFTs from the file
-specified, with no reaction to real topology. Obviously, this will not be able
-to recheck LIDs (by GUID) for disconnected nodes, and LFTs for non-existent
-switches will be skipped. Multicast is not affected by 'file' routing engine
-(this uses min hop tables).
-
-
-Min Hop Algorithm
-
-The Min Hop algorithm is invoked by default if no routing algorithm is
-specified. It can also be invoked by specifying '-R minhop'.
-
-The Min Hop algorithm is divided into two stages: computation of
-min-hop tables on every switch and LFT output port assignment. Link
-subscription is also equalized with the ability to override based on
-port GUID. The latter is supplied by:
-
--i <equalize-ignore-guids-file>
-.br
--ignore-guids <equalize-ignore-guids-file>
- This option provides the means to define a set of ports
- (by guid) that will be ignored by the link load
- equalization algorithm. Note that only endports (CA,
- switch port 0, and router ports) and not switch external
- ports are supported.
-
-LMC awareness routes based on (remote) system or switch basis.
-
-
-Purpose of UPDN Algorithm
-
-The UPDN algorithm is designed to prevent deadlocks from occurring in loops
-of the subnet. A loop-deadlock is a situation in which it is no longer
-possible to send data between any two hosts connected through the loop. As
-such, the UPDN routing algorithm should be used if the subnet is not a pure
-Fat Tree, and one of its loops may experience a deadlock (due, for example,
-to high pressure).
-
-The UPDN algorithm is based on the following main stages:
-
-1. Auto-detect root nodes - based on the CA hop length from any switch in
-the subnet, a statistical histogram is built for each switch (hop num vs
-number of occurrences). If the histogram reflects a specific column (higher
-than others) for a certain node, then it is marked as a root node. Since
-the algorithm is statistical, it may not find any root nodes. The list of
-the root nodes found by this auto-detect stage is used by the ranking
-process stage.
-
- Note 1: The user can override the node list manually.
- Note 2: If this stage cannot find any root nodes, and the user did
- not specify a guid list file, OpenSM defaults back to the
- Min Hop routing algorithm.
-
-2. Ranking process - All root switch nodes (found in stage 1) are assigned
-a rank of 0. Using the BFS algorithm, the rest of the switch nodes in the
-subnet are ranked incrementally. This ranking aids in the process of enforcing
-rules that ensure loop-free paths.
-
-3. Min Hop Table setting - after ranking is done, a BFS algorithm is run from
-each (CA or switch) node in the subnet. During the BFS process, the FDB table
-of each switch node traversed by BFS is updated, in reference to the starting
-node, based on the ranking rules and guid values.
-
-At the end of the process, the updated FDB tables ensure loop-free paths
-through the subnet.
-
-Note: Up/Down routing does not allow LID routing communication between
-switches that are located inside spine "switch systems".
-The reason is that there is no way to allow a LID route between them
-that does not break the Up/Down rule.
-One ramification of this is that you cannot run SM on switches other
-than the leaf switches of the fabric.
-
-
-UPDN Algorithm Usage
-
-Activation through OpenSM
-
-Use '-R updn' option (instead of old '-u') to activate the UPDN algorithm.
-Use '-a <root_guid_file>' for adding an UPDN guid file that contains the
-root nodes for ranking.
-If the `-a' option is not used, OpenSM uses its auto-detect root nodes
-algorithm.
-
-Notes on the guid list file:
-
-1. A valid guid file specifies one guid in each line. Lines with an invalid
-format will be discarded.
-.br
-2. The user should specify the root switch guids. However, it is also
-possible to specify CA guids; OpenSM will use the guid of the switch (if
-it exists) that connects the CA to the subnet as a root node.
-
-
-Fat-tree Routing Algorithm
-
-The fat-tree algorithm optimizes routing for "shift" communication pattern.
-It should be chosen if a subnet is a symmetrical or almost symmetrical
-fat-tree of various types.
-It supports not just K-ary-N-Trees, by handling for non-constant K,
-cases where not all leafs (CAs) are present, any CBB ratio.
-As in UPDN, fat-tree also prevents credit-loop-deadlocks.
-
-If the root guid file is not provided ('-a' or '--root_guid_file' options),
-the topology has to be pure fat-tree that complies with the following rules:
- - Tree rank should be between two and eight (inclusively)
- - Switches of the same rank should have the same number
- of UP-going port groups*, unless they are root switches,
- in which case the shouldn't have UP-going ports at all.
- - Switches of the same rank should have the same number
- of DOWN-going port groups, unless they are leaf switches.
- - Switches of the same rank should have the same number
- of ports in each UP-going port group.
- - Switches of the same rank should have the same number
- of ports in each DOWN-going port group.
- - All the CAs have to be at the same tree level (rank).
-
-If the root guid file is provided, the topology doesn't have to be pure
-fat-tree, and it should only comply with the following rules:
- - Tree rank should be between two and eight (inclusively)
- - All the Compute Nodes** have to be at the same tree level (rank).
- Note that non-compute node CAs are allowed here to be at different
- tree ranks.
-
-* ports that are connected to the same remote switch are referenced as
-\'port group\'.
-
-** list of compute nodes (CNs) can be specified by \'-u\' or \'--cn_guid_file\'
-OpenSM options.
-
-Topologies that do not comply cause a fallback to min hop routing.
-Note that this can also occur on link failures which cause the topology
-to no longer be "pure" fat-tree.
-
-Note that although fat-tree algorithm supports trees with non-integer CBB
-ratio, the routing will not be as balanced as in case of integer CBB ratio.
-In addition to this, although the algorithm allows leaf switches to have any
-number of CAs, the closer the tree is to be fully populated, the more
-effective the "shift" communication pattern will be.
-In general, even if the root list is provided, the closer the topology to a
-pure and symmetrical fat-tree, the more optimal the routing will be.
-
-The algorithm also dumps compute node ordering file (opensm-ftree-ca-order.dump)
-in the same directory where the OpenSM log resides. This ordering file provides
-the CN order that may be used to create efficient communication pattern, that
-will match the routing tables.
-
-Activation through OpenSM
-
-Use '-R ftree' option to activate the fat-tree algorithm.
-Use '-a <root_guid_file>' to provide root nodes for ranking. If the `-a' option
-is not used, routing algorithm will detect roots automatically.
-Use '-u <root_cn_file>' to provide the list of compute nodes. If the `-u' option
-is not used, all the CAs are considered as compute nodes.
-
-Note: LMC > 0 is not supported by fat-tree routing. If this is
-specified, the default routing algorithm is invoked instead.
-
-
-LASH Routing Algorithm
-
-LASH is an acronym for LAyered SHortest Path Routing. It is a
-deterministic shortest path routing algorithm that enables topology
-agnostic deadlock-free routing within communication networks.
-
-When computing the routing function, LASH analyzes the network
-topology for the shortest-path routes between all pairs of sources /
-destinations and groups these paths into virtual layers in such a way
-as to avoid deadlock.
-
-Note LASH analyzes routes and ensures deadlock freedom between switch
-pairs. The link from HCA between and switch does not need virtual
-layers as deadlock will not arise between switch and HCA.
-
-In more detail, the algorithm works as follows:
-
-1) LASH determines the shortest-path between all pairs of source /
-destination switches. Note, LASH ensures the same SL is used for all
-SRC/DST - DST/SRC pairs and there is no guarantee that the return
-path for a given DST/SRC will be the reverse of the route SRC/DST.
-
-2) LASH then begins an SL assignment process where a route is assigned
-to a layer (SL) if the addition of that route does not cause deadlock
-within that layer. This is achieved by maintaining and analysing a
-channel dependency graph for each layer. Once the potential addition
-of a path could lead to deadlock, LASH opens a new layer and continues
-the process.
-
-3) Once this stage has been completed, it is highly likely that the
-first layers processed will contain more paths than the latter ones.
-To better balance the use of layers, LASH moves paths from one layer
-to another so that the number of paths in each layer averages out.
-
-Note, the implementation of LASH in opensm attempts to use as few layers
-as possible. This number can be less than the number of actual layers
-available.
-
-In general LASH is a very flexible algorithm. It can, for example,
-reduce to Dimension Order Routing in certain topologies, it is topology
-agnostic and fares well in the face of faults.
-
-It has been shown that for both regular and irregular topologies, LASH
-outperforms Up/Down. The reason for this is that LASH distributes the
-traffic more evenly through a network, avoiding the bottleneck issues
-related to a root node and always routes shortest-path.
-
-The algorithm was developed by Simula Research Laboratory.
-
-
-Use '-R lash -Q ' option to activate the LASH algorithm.
-
-Note: QoS support has to be turned on in order that SL/VL mappings are
-used.
-
-Note: LMC > 0 is not supported by the LASH routing. If this is
-specified, the default routing algorithm is invoked instead.
-
-
-DOR Routing Algorithm
-
-The Dimension Order Routing algorithm is based on the Min Hop
-algorithm and so uses shortest paths. Instead of spreading traffic
-out across different paths with the same shortest distance, it chooses
-among the available shortest paths based on an ordering of dimensions.
-Each port must be consistently cabled to represent a hypercube
-dimension or a mesh dimension. Paths are grown from a destination
-back to a source using the lowest dimension (port) of available paths
-at each step. This provides the ordering necessary to avoid deadlock.
-When there are multiple links between any two switches, they still
-represent only one dimension and traffic is balanced across them
-unless port equalization is turned off. In the case of hypercubes,
-the same port must be used throughout the fabric to represent the
-hypercube dimension and match on both ends of the cable. In the case
-of meshes, the dimension should consistently use the same pair of
-ports, one port on one end of the cable, and the other port on the
-other end, continuing along the mesh dimension.
-
-Use '-R dor' option to activate the DOR algorithm.
-
-
-Routing References
-
-To learn more about deadlock-free routing, see the article
-"Deadlock Free Message Routing in Multiprocessor Interconnection Networks"
-by William J Dally and Charles L Seitz (1985).
-
-To learn more about the up/down algorithm, see the article
-"Effective Strategy to Compute Forwarding Tables for InfiniBand Networks"
-by Jose Carlos Sancho, Antonio Robles, and Jose Duato at the
-Universidad Politecnica de Valencia.
-
-To learn more about LASH and the flexibility behind it, the requirement
-for layers, performance comparisons to other algorithms, see the
-following articles:
-
-"Layered Routing in Irregular Networks", Lysne et al, IEEE
-Transactions on Parallel and Distributed Systems, VOL.16, No12,
-December 2005.
-
-"Routing for the ASI Fabric Manager", Solheim et al. IEEE
-Communications Magazine, Vol.44, No.7, July 2006.
-
-"Layered Shortest Path (LASH) Routing in Irregular System Area
-Networks", Skeie et al. IEEE Computer Society Communication
-Architecture for Clusters 2002.
-
-
-Modular Routine Engine
-
-Modular routing engine structure allows for the ease of
-"plugging" new routing modules.
-
-Currently, only unicast callbacks are supported. Multicast
-can be added later.
-
-One existing routing module is up-down "updn", which may be
-activated with '-R updn' option (instead of old '-u').
-
-General usage is:
-$ opensm -R 'module-name'
-
-There is also a trivial routing module which is able
-to load LFT tables from a file.
-
-Main features:
-
- - this will load switch LFTs and/or LID matrices (min hops tables)
- - this will load switch LFTs according to the path entries introduced
- in the file
- - no additional checks will be performed (such as "is port connected",
- etc.)
- - in case when fabric LIDs were changed this will try to reconstruct
- LFTs correctly if endport GUIDs are represented in the file
- (in order to disable this, GUIDs may be removed from the file
- or zeroed)
-
-The file format is compatible with output of 'ibroute' util and for
-whole fabric can be generated with dump_lfts.sh script.
-
-To activate file based routing module, use:
-
- opensm -R file -U /path/to/lfts_file
-
-If the lfts_file is not found or is in error, the default routing
-algorithm is utilized.
-
-The ability to dump switch lid matrices (aka min hops tables) to file and
-later to load these is also supported.
-
-The usage is similar to unicast forwarding tables loading from a lfts
-file (introduced by 'file' routing engine), but new lid matrix file
-name should be specified by -M or --lid_matrix_file option. For example:
-
- opensm -R file -M ./opensm-lid-matrix.dump
-
-The dump file is named \'opensm-lid-matrix.dump\' and will be generated
-in standard opensm dump directory (/var/log by default) when
-OSM_LOG_ROUTING logging flag is set.
-
-When routing engine 'file' is activated, but the lfts file is not specified
-or not cannot be open default lid matrix algorithm will be used.
-
-There is also a switch forwarding tables dumper which generates
-a file compatible with dump_lfts.sh output. This file can be used
-as input for forwarding tables loading by 'file' routing engine.
-Both or one of options -U and -M can be specified together with \'-R file\'.
-
-.SH FILES
-.TP
-.B @OPENSM_CONFIG_DIR@/@OPENSM_CONFIG_FILE@
-default OpenSM config file.
-
-.TP
-.B @OPENSM_CONFIG_DIR@/@NODENAMEMAPFILE@
-default node name map file. See ibnetdiscover for more information on format.
-
-.TP
-.B @OPENSM_CONFIG_DIR@/@PARTITION_CONFIG_FILE@
-default partition config file
-
-.TP
-.B @OPENSM_CONFIG_DIR@/@QOS_POLICY_FILE@
-default QOS policy config file
-
-.TP
-.B @OPENSM_CONFIG_DIR@/@PREFIX_ROUTES_FILE@
-default prefix routes file.
-
-.SH AUTHORS
-.TP
-Hal Rosenstock
-.RI < hal.rosenstock@gmail.com >
-.TP
-Sasha Khapyorsky
-.RI < sashak@voltaire.com >
-.TP
-Eitan Zahavi
-.RI < eitan@mellanox.co.il >
-.TP
-Yevgeny Kliteynik
-.RI < kliteyn@mellanox.co.il >
-.TP
-Thomas Sodring
-.RI < tsodring@simula.no >
-.TP
-Ira Weiny
-.RI < weiny2@llnl.gov >
diff --git a/contrib/ofed/management/opensm/man/opensm.8.in b/contrib/ofed/management/opensm/man/opensm.8.in
deleted file mode 100644
index 3000eaf..0000000
--- a/contrib/ofed/management/opensm/man/opensm.8.in
+++ /dev/null
@@ -1,1012 +0,0 @@
-.TH OPENSM 8 "June 13, 2008" "OpenIB" "OpenIB Management"
-
-.SH NAME
-opensm \- InfiniBand subnet manager and administration (SM/SA)
-
-.SH SYNOPSIS
-.B opensm
-[\-\-version]]
-[\-F | \-\-config <file_name>]
-[\-c(reate-config) <file_name>]
-[\-g(uid) <GUID in hex>]
-[\-l(mc) <LMC>]
-[\-p(riority) <PRIORITY>]
-[\-smkey <SM_Key>]
-[\-r(eassign_lids)]
-[\-R <engine name(s)> | \-\-routing_engine <engine name(s)>]
-[\-A | \-\-ucast_cache]
-[\-z | \-\-connect_roots]
-[\-M <file name> | \-\-lid_matrix_file <file name>]
-[\-U <file name> | \-\-lfts_file <file name>]
-[\-S | \-\-sadb_file <file name>]
-[\-a | \-\-root_guid_file <path to file>]
-[\-u | \-\-cn_guid_file <path to file>]
-[\-X | \-\-guid_routing_order_file <path to file>]
-[\-m | \-\-ids_guid_file <path to file>]
-[\-o(nce)]
-[\-s(weep) <interval>]
-[\-t(imeout) <milliseconds>]
-[\-maxsmps <number>]
-[\-console [off | local | socket | loopback]]
-[\-console-port <port>]
-[\-i(gnore-guids) <equalize-ignore-guids-file>]
-[\-f <log file path> | \-\-log_file <log file path> ]
-[\-L | \-\-log_limit <size in MB>] [\-e(rase_log_file)]
-[\-P(config) <partition config file> ]
-[\-N | \-\-no_part_enforce]
-[\-Q | \-\-qos [\-Y | \-\-qos_policy_file <file name>]]
-[\-y | \-\-stay_on_fatal]
-[\-B | \-\-daemon]
-[\-I | \-\-inactive]
-[\-\-perfmgr]
-[\-\-perfmgr_sweep_time_s <seconds>]
-[\-\-prefix_routes_file <path>]
-[\-\-consolidate_ipv6_snm_req]
-[\-v(erbose)] [\-V] [\-D <flags>] [\-d(ebug) <number>]
-[\-h(elp)] [\-?]
-
-.SH DESCRIPTION
-.PP
-opensm is an InfiniBand compliant Subnet Manager and Administration,
-and runs on top of OpenIB.
-
-opensm provides an implementation of an InfiniBand Subnet Manager and
-Administration. Such a software entity is required to run for in order
-to initialize the InfiniBand hardware (at least one per each
-InfiniBand subnet).
-
-opensm also now contains an experimental version of a performance
-manager as well.
-
-opensm defaults were designed to meet the common case usage on clusters with up to a few hundred nodes. Thus, in this default mode, opensm will scan the IB
-fabric, initialize it, and sweep occasionally for changes.
-
-opensm attaches to a specific IB port on the local machine and configures only
-the fabric connected to it. (If the local machine has other IB ports,
-opensm will ignore the fabrics connected to those other ports). If no port is
-specified, it will select the first "best" available port.
-
-opensm can present the available ports and prompt for a port number to
-attach to.
-
-By default, the run is logged to two files: /var/log/messages and /var/log/opensm.log.
-The first file will register only general major events, whereas the second
-will include details of reported errors. All errors reported in this second
-file should be treated as indicators of IB fabric health issues.
-(Note that when a fatal and non-recoverable error occurs, opensm will exit.)
-Both log files should include the message "SUBNET UP" if opensm was able to
-setup the subnet correctly.
-
-.SH OPTIONS
-
-.PP
-.TP
-\fB\-\-version\fR
-Prints OpenSM version and exits.
-.TP
-\fB\-F\fR, \fB\-\-config\fR <config file>
-The name of the OpenSM config file. When not specified
-\fB\% @OPENSM_CONFIG_DIR@/@OPENSM_CONFIG_FILE@\fP will be used (if exists).
-.TP
-\fB\-c\fR, \fB\-\-create-config\fR <file name>
-OpenSM will dump its configuration to the specified file and exit.
-This is a way to generate OpenSM configuration file template.
-.TP
-\fB\-g\fR, \fB\-\-guid\fR <GUID in hex>
-This option specifies the local port GUID value
-with which OpenSM should bind. OpenSM may be
-bound to 1 port at a time.
-If GUID given is 0, OpenSM displays a list
-of possible port GUIDs and waits for user input.
-Without -g, OpenSM tries to use the default port.
-.TP
-\fB\-l\fR, \fB\-\-lmc\fR <LMC value>
-This option specifies the subnet's LMC value.
-The number of LIDs assigned to each port is 2^LMC.
-The LMC value must be in the range 0-7.
-LMC values > 0 allow multiple paths between ports.
-LMC values > 0 should only be used if the subnet
-topology actually provides multiple paths between
-ports, i.e. multiple interconnects between switches.
-Without -l, OpenSM defaults to LMC = 0, which allows
-one path between any two ports.
-.TP
-\fB\-p\fR, \fB\-\-priority\fR <Priority value>
-This option specifies the SM\'s PRIORITY.
-This will effect the handover cases, where master
-is chosen by priority and GUID. Range goes from 0
-(default and lowest priority) to 15 (highest).
-.TP
-\fB\-smkey\fR <SM_Key value>
-This option specifies the SM\'s SM_Key (64 bits).
-This will effect SM authentication.
-Note that OpenSM version 3.2.1 and below used the default value '1'
-in a host byte order, it is fixed now but you may need this option to
-interoperate with old OpenSM running on a little endian machine.
-.TP
-\fB\-r\fR, \fB\-\-reassign_lids\fR
-This option causes OpenSM to reassign LIDs to all
-end nodes. Specifying -r on a running subnet
-may disrupt subnet traffic.
-Without -r, OpenSM attempts to preserve existing
-LID assignments resolving multiple use of same LID.
-.TP
-\fB\-R\fR, \fB\-\-routing_engine\fR <Routing engine names>
-This option chooses routing engine(s) to use instead of Min Hop
-algorithm (default). Multiple routing engines can be specified
-separated by commas so that specific ordering of routing algorithms
-will be tried if earlier routing engines fail.
-Supported engines: minhop, updn, file, ftree, lash, dor
-.TP
-\fB\-A\fR, \fB\-\-ucast_cache\fR
-This option enables unicast routing cache and prevents routing
-recalculation (which is a heavy task in a large cluster) when
-there was no topology change detected during the heavy sweep, or
-when the topology change does not require new routing calculation,
-e.g. when one or more CAs/RTRs/leaf switches going down, or one or
-more of these nodes coming back after being down.
-A very common case that is handled by the unicast routing cache
-is host reboot, which otherwise would cause two full routing
-recalculations: one when the host goes down, and the other when
-the host comes back online.
-.TP
-\fB\-z\fR, \fB\-\-connect_roots\fR
-This option enforces a routing engine (currently up/down
-only) to make connectivity between root switches and in
-this way to be fully IBA complaint. In many cases this can
-violate "pure" deadlock free algorithm, so use it carefully.
-.TP
-\fB\-M\fR, \fB\-\-lid_matrix_file\fR <file name>
-This option specifies the name of the lid matrix dump file
-from where switch lid matrices (min hops tables will be
-loaded.
-.TP
-\fB\-U\fR, \fB\-\-lfts_file\fR <file name>
-This option specifies the name of the LFTs file
-from where switch forwarding tables will be loaded.
-.TP
-\fB\-S\fR, \fB\-\-sadb_file\fR <file name>
-This option specifies the name of the SA DB dump file
-from where SA database will be loaded.
-.TP
-\fB\-a\fR, \fB\-\-root_guid_file\fR <file name>
-Set the root nodes for the Up/Down or Fat-Tree routing
-algorithm to the guids provided in the given file (one to a line).
-.TP
-\fB\-u\fR, \fB\-\-cn_guid_file\fR <file name>
-Set the compute nodes for the Fat-Tree routing algorithm
-to the guids provided in the given file (one to a line).
-.TP
-\fB\-m\fR, \fB\-\-ids_guid_file\fR <file name>
-Name of the map file with set of the IDs which will be used
-by Up/Down routing algorithm instead of node GUIDs
-(format: <guid> <id> per line).
-.TP
-\fB\-X\fR, \fB\-\-guid_routing_order_file\fR <file name>
-Set the order port guids will be routed for the MinHop
-and Up/Down routing algorithms to the guids provided in the
-given file (one to a line).
-.TP
-\fB\-o\fR, \fB\-\-once\fR
-This option causes OpenSM to configure the subnet
-once, then exit. Ports remain in the ACTIVE state.
-.TP
-\fB\-s\fR, \fB\-\-sweep\fR <interval value>
-This option specifies the number of seconds between
-subnet sweeps. Specifying -s 0 disables sweeping.
-Without -s, OpenSM defaults to a sweep interval of
-10 seconds.
-.TP
-\fB\-t\fR, \fB\-\-timeout\fR <value>
-This option specifies the time in milliseconds
-used for transaction timeouts.
-Specifying -t 0 disables timeouts.
-Without -t, OpenSM defaults to a timeout value of
-200 milliseconds.
-.TP
-\fB\-maxsmps\fR <number>
-This option specifies the number of VL15 SMP MADs
-allowed on the wire at any one time.
-Specifying -maxsmps 0 allows unlimited outstanding
-SMPs.
-Without -maxsmps, OpenSM defaults to a maximum of
-4 outstanding SMPs.
-.TP
-\fB\-console [off | local | socket | loopback]\fR
-This option brings up the OpenSM console (default off).
-Note that the socket and loopback options will only be available
-if OpenSM was built with --enable-console-socket.
-.TP
-\fB\-console-port\fR <port>
-Specify an alternate telnet port for the socket console (default 10000).
-Note that this option only appears if OpenSM was built with
---enable-console-socket.
-.TP
-\fB\-i\fR, \fB\-ignore-guids\fR <equalize-ignore-guids-file>
-This option provides the means to define a set of ports
-(by node guid and port number) that will be ignored by the link load
-equalization algorithm.
-.TP
-\fB\-x\fR, \fB\-\-honor_guid2lid\fR
-This option forces OpenSM to honor the guid2lid file,
-when it comes out of Standby state, if such file exists
-under OSM_CACHE_DIR, and is valid.
-By default, this is FALSE.
-.TP
-\fB\-f\fR, \fB\-\-log_file\fR <file name>
-This option defines the log to be the given file.
-By default, the log goes to /var/log/opensm.log.
-For the log to go to standard output use -f stdout.
-.TP
-\fB\-L\fR, \fB\-\-log_limit\fR <size in MB>
-This option defines maximal log file size in MB. When
-specified the log file will be truncated upon reaching
-this limit.
-.TP
-\fB\-e\fR, \fB\-\-erase_log_file\fR
-This option will cause deletion of the log file
-(if it previously exists). By default, the log file
-is accumulative.
-.TP
-\fB\-P\fR, \fB\-\-Pconfig\fR <partition config file>
-This option defines the optional partition configuration file.
-The default name is \fB\%@OPENSM_CONFIG_DIR@/@PARTITION_CONFIG_FILE@\fP.
-.TP
-\fB\-\-prefix_routes_file\fR <file name>
-Prefix routes control how the SA responds to path record queries for
-off-subnet DGIDs. By default, the SA fails such queries. The
-.B PREFIX ROUTES
-section below describes the format of the configuration file.
-The default path is \fB\%@OPENSM_CONFIG_DIR@/prefix\-routes.conf\fP.
-.TP
-\fB\-Q\fR, \fB\-\-qos\fR
-This option enables QoS setup. It is disabled by default.
-.TP
-\fB\-Y\fR, \fB\-\-qos_policy_file\fR <file name>
-This option defines the optional QoS policy file. The default
-name is \fB\%@OPENSM_CONFIG_DIR@/@QOS_POLICY_FILE@\fP.
-.TP
-\fB\-N\fR, \fB\-\-no_part_enforce\fR
-This option disables partition enforcement on switch external ports.
-.TP
-\fB\-y\fR, \fB\-\-stay_on_fatal\fR
-This option will cause SM not to exit on fatal initialization
-issues: if SM discovers duplicated guids or a 12x link with
-lane reversal badly configured.
-By default, the SM will exit on these errors.
-.TP
-\fB\-B\fR, \fB\-\-daemon\fR
-Run in daemon mode - OpenSM will run in the background.
-.TP
-\fB\-I\fR, \fB\-\-inactive\fR
-Start SM in inactive rather than init SM state. This
-option can be used in conjunction with the perfmgr so as to
-run a standalone performance manager without SM/SA. However,
-this is NOT currently implemented in the performance manager.
-.TP
-\fB\-perfmgr\fR
-Enable the perfmgr. Only takes effect if --enable-perfmgr was specified at
-configure time.
-.TP
-\fB\-perfmgr_sweep_time_s\fR <seconds>
-Specify the sweep time for the performance manager in seconds
-(default is 180 seconds). Only takes
-effect if --enable-perfmgr was specified at configure time.
-.TP
-.BI --consolidate_ipv6_snm_req
-Consolidate IPv6 Solicited Node Multicast group join requests into one
-multicast group per MGID PKey.
-.TP
-\fB\-v\fR, \fB\-\-verbose\fR
-This option increases the log verbosity level.
-The -v option may be specified multiple times
-to further increase the verbosity level.
-See the -D option for more information about
-log verbosity.
-.TP
-\fB\-V\fR
-This option sets the maximum verbosity level and
-forces log flushing.
-The -V option is equivalent to \'-D 0xFF -d 2\'.
-See the -D option for more information about
-log verbosity.
-.TP
-\fB\-D\fR <value>
-This option sets the log verbosity level.
-A flags field must follow the -D option.
-A bit set/clear in the flags enables/disables a
-specific log level as follows:
-
- BIT LOG LEVEL ENABLED
- ---- -----------------
- 0x01 - ERROR (error messages)
- 0x02 - INFO (basic messages, low volume)
- 0x04 - VERBOSE (interesting stuff, moderate volume)
- 0x08 - DEBUG (diagnostic, high volume)
- 0x10 - FUNCS (function entry/exit, very high volume)
- 0x20 - FRAMES (dumps all SMP and GMP frames)
- 0x40 - ROUTING (dump FDB routing information)
- 0x80 - currently unused.
-
-Without -D, OpenSM defaults to ERROR + INFO (0x3).
-Specifying -D 0 disables all messages.
-Specifying -D 0xFF enables all messages (see -V).
-High verbosity levels may require increasing
-the transaction timeout with the -t option.
-.TP
-\fB\-d\fR, \fB\-\-debug\fR <value>
-This option specifies a debug option.
-These options are not normally needed.
-The number following -d selects the debug
-option to enable as follows:
-
- OPT Description
- --- -----------------
- -d0 - Ignore other SM nodes
- -d1 - Force single threaded dispatching
- -d2 - Force log flushing after each log message
- -d3 - Disable multicast support
-.TP
-\fB\-h\fR, \fB\-\-help\fR
-Display this usage info then exit.
-.TP
-\fB\-?\fR
-Display this usage info then exit.
-
-.SH ENVIRONMENT VARIABLES
-.PP
-The following environment variables control opensm behavior:
-
-OSM_TMP_DIR - controls the directory in which the temporary files generated by
-opensm are created. These files are: opensm-subnet.lst, opensm.fdbs, and
-opensm.mcfdbs. By default, this directory is /var/log.
-
-OSM_CACHE_DIR - opensm stores certain data to the disk such that subsequent
-runs are consistent. The default directory used is /var/cache/opensm.
-The following file is included in it:
-
- guid2lid - stores the LID range assigned to each GUID
-
-.SH NOTES
-.PP
-When opensm receives a HUP signal, it starts a new heavy sweep as if a trap was received or a topology change was found.
-.PP
-Also, SIGUSR1 can be used to trigger a reopen of /var/log/opensm.log for
-logrotate purposes.
-
-.SH PARTITION CONFIGURATION
-.PP
-The default name of OpenSM partitions configuration file is
-\fB\%@OPENSM_CONFIG_DIR@/@PARTITION_CONFIG_FILE@\fP. The default may be changed by using
---Pconfig (-P) option with OpenSM.
-
-The default partition will be created by OpenSM unconditionally even
-when partition configuration file does not exist or cannot be accessed.
-
-The default partition has P_Key value 0x7fff. OpenSM\'s port will have
-full membership in default partition. All other end ports will have
-partial membership.
-
-File Format
-
-Comments:
-
-Line content followed after \'#\' character is comment and ignored by
-parser.
-
-General file format:
-
-<Partition Definition>:<PortGUIDs list> ;
-
-Partition Definition:
-
-[PartitionName][=PKey][,flag[=value]][,defmember=full|limited]
-
- PartitionName - string, will be used with logging. When omitted
- empty string will be used.
- PKey - P_Key value for this partition. Only low 15 bits will
- be used. When omitted will be autogenerated.
- flag - used to indicate IPoIB capability of this partition.
- defmember=full|limited - specifies default membership for port guid
- list. Default is limited.
-
-Currently recognized flags are:
-
- ipoib - indicates that this partition may be used for IPoIB, as
- result IPoIB capable MC group will be created.
- rate=<val> - specifies rate for this IPoIB MC group
- (default is 3 (10GBps))
- mtu=<val> - specifies MTU for this IPoIB MC group
- (default is 4 (2048))
- sl=<val> - specifies SL for this IPoIB MC group
- (default is 0)
- scope=<val> - specifies scope for this IPoIB MC group
- (default is 2 (link local)). Multiple scope settings
- are permitted for a partition.
-
-Note that values for rate, mtu, and scope should be specified as
-defined in the IBTA specification (for example, mtu=4 for 2048).
-
-PortGUIDs list:
-
- PortGUID - GUID of partition member EndPort. Hexadecimal
- numbers should start from 0x, decimal numbers
- are accepted too.
- full or limited - indicates full or limited membership for this
- port. When omitted (or unrecognized) limited
- membership is assumed.
-
-There are two useful keywords for PortGUID definition:
-
- - 'ALL' means all end ports in this subnet.
- - 'SELF' means subnet manager's port.
-
-Empty list means no ports in this partition.
-
-Notes:
-
-White space is permitted between delimiters ('=', ',',':',';').
-
-The line can be wrapped after ':' followed after Partition Definition and
-between.
-
-PartitionName does not need to be unique, PKey does need to be unique.
-If PKey is repeated then those partition configurations will be merged
-and first PartitionName will be used (see also next note).
-
-It is possible to split partition configuration in more than one
-definition, but then PKey should be explicitly specified (otherwise
-different PKey values will be generated for those definitions).
-
-Examples:
-
- Default=0x7fff : ALL, SELF=full ;
-
- NewPartition , ipoib : 0x123456=full, 0x3456789034=limi, 0x2134af2306 ;
-
- YetAnotherOne = 0x300 : SELF=full ;
- YetAnotherOne = 0x300 : ALL=limited ;
-
- ShareIO = 0x80 , defmember=full : 0x123451, 0x123452;
- # 0x123453, 0x123454 will be limited
- ShareIO = 0x80 : 0x123453, 0x123454, 0x123455=full;
- # 0x123456, 0x123457 will be limited
- ShareIO = 0x80 : defmember=limited : 0x123456, 0x123457, 0x123458=full;
- ShareIO = 0x80 , defmember=full : 0x123459, 0x12345a;
- ShareIO = 0x80 , defmember=full : 0x12345b, 0x12345c=limited, 0x12345d;
-
-
-Note:
-
-The following rule is equivalent to how OpenSM used to run prior to the
-partition manager:
-
- Default=0x7fff,ipoib:ALL=full;
-
-.SH QOS CONFIGURATION
-.PP
-There are a set of QoS related low-level configuration parameters.
-All these parameter names are prefixed by "qos_" string. Here is a full
-list of these parameters:
-
- qos_max_vls - The maximum number of VLs that will be on the subnet
- qos_high_limit - The limit of High Priority component of VL
- Arbitration table (IBA 7.6.9)
- qos_vlarb_low - Low priority VL Arbitration table (IBA 7.6.9)
- template
- qos_vlarb_high - High priority VL Arbitration table (IBA 7.6.9)
- template
- Both VL arbitration templates are pairs of
- VL and weight
- qos_sl2vl - SL2VL Mapping table (IBA 7.6.6) template. It is
- a list of VLs corresponding to SLs 0-15 (Note
- that VL15 used here means drop this SL)
-
-Typical default values (hard-coded in OpenSM initialization) are:
-
- qos_max_vls 15
- qos_high_limit 0
- qos_vlarb_low 0:0,1:4,2:4,3:4,4:4,5:4,6:4,7:4,8:4,9:4,10:4,11:4,12:4,13:4,14:4
- qos_vlarb_high 0:4,1:0,2:0,3:0,4:0,5:0,6:0,7:0,8:0,9:0,10:0,11:0,12:0,13:0,14:0
- qos_sl2vl 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,7
-
-The syntax is compatible with rest of OpenSM configuration options and
-values may be stored in OpenSM config file (cached options file).
-
-In addition to the above, we may define separate QoS configuration
-parameters sets for various target types. As targets, we currently support
-CAs, routers, switch external ports, and switch's enhanced port 0. The
-names of such specialized parameters are prefixed by "qos_<type>_"
-string. Here is a full list of the currently supported sets:
-
- qos_ca_ - QoS configuration parameters set for CAs.
- qos_rtr_ - parameters set for routers.
- qos_sw0_ - parameters set for switches' port 0.
- qos_swe_ - parameters set for switches' external ports.
-
-Examples:
- qos_sw0_max_vls=2
- qos_ca_sl2vl=0,1,2,3,5,5,5,12,12,0,
- qos_swe_high_limit=0
-
-.SH PREFIX ROUTES
-.PP
-Prefix routes control how the SA responds to path record queries for
-off-subnet DGIDs. By default, the SA fails such queries.
-Note that IBA does not specify how the SA should obtain off-subnet path
-record information.
-The prefix routes configuration is meant as a stop-gap until the
-specification is completed.
-.PP
-Each line in the configuration file is a 64-bit prefix followed by a
-64-bit GUID, separated by white space.
-The GUID specifies the router port on the local subnet that will
-handle the prefix.
-Blank lines are ignored, as is anything between a \fB#\fP character
-and the end of the line.
-The prefix and GUID are both in hex, the leading 0x is optional.
-Either, or both, can be wild-carded by specifying an
-asterisk instead of an explicit prefix or GUID.
-.PP
-When responding to a path record query for an off-subnet DGID,
-opensm searches for the first prefix match in the configuration file.
-Therefore, the order of the lines in the configuration file is important:
-a wild-carded prefix at the beginning of the configuration file renders
-all subsequent lines useless.
-If there is no match, then opensm fails the query.
-It is legal to repeat prefixes in the configuration file,
-opensm will return the path to the first available matching router.
-A configuration file with a single line where both prefix and GUID
-are wild-carded means that a path record query specifying any
-off-subnet DGID should return a path to the first available router.
-This configuration yields the same behaviour formerly achieved by
-compiling opensm with -DROUTER_EXP.
-
-.SH ROUTING
-.PP
-OpenSM now offers five routing engines:
-
-1. Min Hop Algorithm - based on the minimum hops to each node where the
-path length is optimized.
-
-2. UPDN Unicast routing algorithm - also based on the minimum hops to each
-node, but it is constrained to ranking rules. This algorithm should be chosen
-if the subnet is not a pure Fat Tree, and deadlock may occur due to a
-loop in the subnet.
-
-3. Fat Tree Unicast routing algorithm - this algorithm optimizes routing
-for congestion-free "shift" communication pattern.
-It should be chosen if a subnet is a symmetrical or almost symmetrical
-fat-tree of various types, not just K-ary-N-Trees: non-constant K, not
-fully staffed, any Constant Bisectional Bandwidth (CBB) ratio.
-Similar to UPDN, Fat Tree routing is constrained to ranking rules.
-
-4. LASH unicast routing algorithm - uses Infiniband virtual layers
-(SL) to provide deadlock-free shortest-path routing while also
-distributing the paths between layers. LASH is an alternative
-deadlock-free topology-agnostic routing algorithm to the non-minimal
-UPDN algorithm avoiding the use of a potentially congested root node.
-
-5. DOR Unicast routing algorithm - based on the Min Hop algorithm, but
-avoids port equalization except for redundant links between the same
-two switches. This provides deadlock free routes for hypercubes when
-the fabric is cabled as a hypercube and for meshes when cabled as a
-mesh (see details below).
-
-OpenSM also supports a file method which
-can load routes from a table. See \'Modular Routing Engine\' for more
-information on this.
-
-The basic routing algorithm is comprised of two stages:
-
-1. MinHop matrix calculation
- How many hops are required to get from each port to each LID ?
- The algorithm to fill these tables is different if you run standard
-(min hop) or Up/Down.
- For standard routing, a "relaxation" algorithm is used to propagate
-min hop from every destination LID through neighbor switches
- For Up/Down routing, a BFS from every target is used. The BFS tracks link
-direction (up or down) and avoid steps that will perform up after a down
-step was used.
-
-2. Once MinHop matrices exist, each switch is visited and for each target LID a
-decision is made as to what port should be used to get to that LID.
- This step is common to standard and Up/Down routing. Each port has a
-counter counting the number of target LIDs going through it.
- When there are multiple alternative ports with same MinHop to a LID,
-the one with less previously assigned ports is selected.
- If LMC > 0, more checks are added: Within each group of LIDs assigned to
-same target port,
- a. use only ports which have same MinHop
- b. first prefer the ones that go to different systemImageGuid (then
-the previous LID of the same LMC group)
- c. if none - prefer those which go through another NodeGuid
- d. fall back to the number of paths method (if all go to same node).
-
-Effect of Topology Changes
-
-OpenSM will preserve existing routing in any case where there is no change in
-the fabric switches unless the -r (--reassign_lids) option is specified.
-
--r
-.br
---reassign_lids
- This option causes OpenSM to reassign LIDs to all
- end nodes. Specifying -r on a running subnet
- may disrupt subnet traffic.
- Without -r, OpenSM attempts to preserve existing
- LID assignments resolving multiple use of same LID.
-
-If a link is added or removed, OpenSM does not recalculate
-the routes that do not have to change. A route has to change
-if the port is no longer UP or no longer the MinHop. When routing changes
-are performed, the same algorithm for balancing the routes is invoked.
-
-In the case of using the file based routing, any topology changes are
-currently ignored The 'file' routing engine just loads the LFTs from the file
-specified, with no reaction to real topology. Obviously, this will not be able
-to recheck LIDs (by GUID) for disconnected nodes, and LFTs for non-existent
-switches will be skipped. Multicast is not affected by 'file' routing engine
-(this uses min hop tables).
-
-
-Min Hop Algorithm
-
-The Min Hop algorithm is invoked by default if no routing algorithm is
-specified. It can also be invoked by specifying '-R minhop'.
-
-The Min Hop algorithm is divided into two stages: computation of
-min-hop tables on every switch and LFT output port assignment. Link
-subscription is also equalized with the ability to override based on
-port GUID. The latter is supplied by:
-
--i <equalize-ignore-guids-file>
-.br
--ignore-guids <equalize-ignore-guids-file>
- This option provides the means to define a set of ports
- (by guid) that will be ignored by the link load
- equalization algorithm. Note that only endports (CA,
- switch port 0, and router ports) and not switch external
- ports are supported.
-
-LMC awareness routes based on (remote) system or switch basis.
-
-
-Purpose of UPDN Algorithm
-
-The UPDN algorithm is designed to prevent deadlocks from occurring in loops
-of the subnet. A loop-deadlock is a situation in which it is no longer
-possible to send data between any two hosts connected through the loop. As
-such, the UPDN routing algorithm should be used if the subnet is not a pure
-Fat Tree, and one of its loops may experience a deadlock (due, for example,
-to high pressure).
-
-The UPDN algorithm is based on the following main stages:
-
-1. Auto-detect root nodes - based on the CA hop length from any switch in
-the subnet, a statistical histogram is built for each switch (hop num vs
-number of occurrences). If the histogram reflects a specific column (higher
-than others) for a certain node, then it is marked as a root node. Since
-the algorithm is statistical, it may not find any root nodes. The list of
-the root nodes found by this auto-detect stage is used by the ranking
-process stage.
-
- Note 1: The user can override the node list manually.
- Note 2: If this stage cannot find any root nodes, and the user did
- not specify a guid list file, OpenSM defaults back to the
- Min Hop routing algorithm.
-
-2. Ranking process - All root switch nodes (found in stage 1) are assigned
-a rank of 0. Using the BFS algorithm, the rest of the switch nodes in the
-subnet are ranked incrementally. This ranking aids in the process of enforcing
-rules that ensure loop-free paths.
-
-3. Min Hop Table setting - after ranking is done, a BFS algorithm is run from
-each (CA or switch) node in the subnet. During the BFS process, the FDB table
-of each switch node traversed by BFS is updated, in reference to the starting
-node, based on the ranking rules and guid values.
-
-At the end of the process, the updated FDB tables ensure loop-free paths
-through the subnet.
-
-Note: Up/Down routing does not allow LID routing communication between
-switches that are located inside spine "switch systems".
-The reason is that there is no way to allow a LID route between them
-that does not break the Up/Down rule.
-One ramification of this is that you cannot run SM on switches other
-than the leaf switches of the fabric.
-
-
-UPDN Algorithm Usage
-
-Activation through OpenSM
-
-Use '-R updn' option (instead of old '-u') to activate the UPDN algorithm.
-Use '-a <root_guid_file>' for adding an UPDN guid file that contains the
-root nodes for ranking.
-If the `-a' option is not used, OpenSM uses its auto-detect root nodes
-algorithm.
-
-Notes on the guid list file:
-
-1. A valid guid file specifies one guid in each line. Lines with an invalid
-format will be discarded.
-.br
-2. The user should specify the root switch guids. However, it is also
-possible to specify CA guids; OpenSM will use the guid of the switch (if
-it exists) that connects the CA to the subnet as a root node.
-
-
-Fat-tree Routing Algorithm
-
-The fat-tree algorithm optimizes routing for "shift" communication pattern.
-It should be chosen if a subnet is a symmetrical or almost symmetrical
-fat-tree of various types.
-It supports not just K-ary-N-Trees, by handling for non-constant K,
-cases where not all leafs (CAs) are present, any CBB ratio.
-As in UPDN, fat-tree also prevents credit-loop-deadlocks.
-
-If the root guid file is not provided ('-a' or '--root_guid_file' options),
-the topology has to be pure fat-tree that complies with the following rules:
- - Tree rank should be between two and eight (inclusively)
- - Switches of the same rank should have the same number
- of UP-going port groups*, unless they are root switches,
- in which case the shouldn't have UP-going ports at all.
- - Switches of the same rank should have the same number
- of DOWN-going port groups, unless they are leaf switches.
- - Switches of the same rank should have the same number
- of ports in each UP-going port group.
- - Switches of the same rank should have the same number
- of ports in each DOWN-going port group.
- - All the CAs have to be at the same tree level (rank).
-
-If the root guid file is provided, the topology doesn't have to be pure
-fat-tree, and it should only comply with the following rules:
- - Tree rank should be between two and eight (inclusively)
- - All the Compute Nodes** have to be at the same tree level (rank).
- Note that non-compute node CAs are allowed here to be at different
- tree ranks.
-
-* ports that are connected to the same remote switch are referenced as
-\'port group\'.
-
-** list of compute nodes (CNs) can be specified by \'-u\' or \'--cn_guid_file\'
-OpenSM options.
-
-Topologies that do not comply cause a fallback to min hop routing.
-Note that this can also occur on link failures which cause the topology
-to no longer be "pure" fat-tree.
-
-Note that although fat-tree algorithm supports trees with non-integer CBB
-ratio, the routing will not be as balanced as in case of integer CBB ratio.
-In addition to this, although the algorithm allows leaf switches to have any
-number of CAs, the closer the tree is to be fully populated, the more
-effective the "shift" communication pattern will be.
-In general, even if the root list is provided, the closer the topology to a
-pure and symmetrical fat-tree, the more optimal the routing will be.
-
-The algorithm also dumps compute node ordering file (opensm-ftree-ca-order.dump)
-in the same directory where the OpenSM log resides. This ordering file provides
-the CN order that may be used to create efficient communication pattern, that
-will match the routing tables.
-
-Activation through OpenSM
-
-Use '-R ftree' option to activate the fat-tree algorithm.
-Use '-a <root_guid_file>' to provide root nodes for ranking. If the `-a' option
-is not used, routing algorithm will detect roots automatically.
-Use '-u <root_cn_file>' to provide the list of compute nodes. If the `-u' option
-is not used, all the CAs are considered as compute nodes.
-
-Note: LMC > 0 is not supported by fat-tree routing. If this is
-specified, the default routing algorithm is invoked instead.
-
-
-LASH Routing Algorithm
-
-LASH is an acronym for LAyered SHortest Path Routing. It is a
-deterministic shortest path routing algorithm that enables topology
-agnostic deadlock-free routing within communication networks.
-
-When computing the routing function, LASH analyzes the network
-topology for the shortest-path routes between all pairs of sources /
-destinations and groups these paths into virtual layers in such a way
-as to avoid deadlock.
-
-Note LASH analyzes routes and ensures deadlock freedom between switch
-pairs. The link from HCA between and switch does not need virtual
-layers as deadlock will not arise between switch and HCA.
-
-In more detail, the algorithm works as follows:
-
-1) LASH determines the shortest-path between all pairs of source /
-destination switches. Note, LASH ensures the same SL is used for all
-SRC/DST - DST/SRC pairs and there is no guarantee that the return
-path for a given DST/SRC will be the reverse of the route SRC/DST.
-
-2) LASH then begins an SL assignment process where a route is assigned
-to a layer (SL) if the addition of that route does not cause deadlock
-within that layer. This is achieved by maintaining and analysing a
-channel dependency graph for each layer. Once the potential addition
-of a path could lead to deadlock, LASH opens a new layer and continues
-the process.
-
-3) Once this stage has been completed, it is highly likely that the
-first layers processed will contain more paths than the latter ones.
-To better balance the use of layers, LASH moves paths from one layer
-to another so that the number of paths in each layer averages out.
-
-Note, the implementation of LASH in opensm attempts to use as few layers
-as possible. This number can be less than the number of actual layers
-available.
-
-In general LASH is a very flexible algorithm. It can, for example,
-reduce to Dimension Order Routing in certain topologies, it is topology
-agnostic and fares well in the face of faults.
-
-It has been shown that for both regular and irregular topologies, LASH
-outperforms Up/Down. The reason for this is that LASH distributes the
-traffic more evenly through a network, avoiding the bottleneck issues
-related to a root node and always routes shortest-path.
-
-The algorithm was developed by Simula Research Laboratory.
-
-
-Use '-R lash -Q ' option to activate the LASH algorithm.
-
-Note: QoS support has to be turned on in order that SL/VL mappings are
-used.
-
-Note: LMC > 0 is not supported by the LASH routing. If this is
-specified, the default routing algorithm is invoked instead.
-
-
-DOR Routing Algorithm
-
-The Dimension Order Routing algorithm is based on the Min Hop
-algorithm and so uses shortest paths. Instead of spreading traffic
-out across different paths with the same shortest distance, it chooses
-among the available shortest paths based on an ordering of dimensions.
-Each port must be consistently cabled to represent a hypercube
-dimension or a mesh dimension. Paths are grown from a destination
-back to a source using the lowest dimension (port) of available paths
-at each step. This provides the ordering necessary to avoid deadlock.
-When there are multiple links between any two switches, they still
-represent only one dimension and traffic is balanced across them
-unless port equalization is turned off. In the case of hypercubes,
-the same port must be used throughout the fabric to represent the
-hypercube dimension and match on both ends of the cable. In the case
-of meshes, the dimension should consistently use the same pair of
-ports, one port on one end of the cable, and the other port on the
-other end, continuing along the mesh dimension.
-
-Use '-R dor' option to activate the DOR algorithm.
-
-
-Routing References
-
-To learn more about deadlock-free routing, see the article
-"Deadlock Free Message Routing in Multiprocessor Interconnection Networks"
-by William J Dally and Charles L Seitz (1985).
-
-To learn more about the up/down algorithm, see the article
-"Effective Strategy to Compute Forwarding Tables for InfiniBand Networks"
-by Jose Carlos Sancho, Antonio Robles, and Jose Duato at the
-Universidad Politecnica de Valencia.
-
-To learn more about LASH and the flexibility behind it, the requirement
-for layers, performance comparisons to other algorithms, see the
-following articles:
-
-"Layered Routing in Irregular Networks", Lysne et al, IEEE
-Transactions on Parallel and Distributed Systems, VOL.16, No12,
-December 2005.
-
-"Routing for the ASI Fabric Manager", Solheim et al. IEEE
-Communications Magazine, Vol.44, No.7, July 2006.
-
-"Layered Shortest Path (LASH) Routing in Irregular System Area
-Networks", Skeie et al. IEEE Computer Society Communication
-Architecture for Clusters 2002.
-
-
-Modular Routine Engine
-
-Modular routing engine structure allows for the ease of
-"plugging" new routing modules.
-
-Currently, only unicast callbacks are supported. Multicast
-can be added later.
-
-One existing routing module is up-down "updn", which may be
-activated with '-R updn' option (instead of old '-u').
-
-General usage is:
-$ opensm -R 'module-name'
-
-There is also a trivial routing module which is able
-to load LFT tables from a file.
-
-Main features:
-
- - this will load switch LFTs and/or LID matrices (min hops tables)
- - this will load switch LFTs according to the path entries introduced
- in the file
- - no additional checks will be performed (such as "is port connected",
- etc.)
- - in case when fabric LIDs were changed this will try to reconstruct
- LFTs correctly if endport GUIDs are represented in the file
- (in order to disable this, GUIDs may be removed from the file
- or zeroed)
-
-The file format is compatible with output of 'ibroute' util and for
-whole fabric can be generated with dump_lfts.sh script.
-
-To activate file based routing module, use:
-
- opensm -R file -U /path/to/lfts_file
-
-If the lfts_file is not found or is in error, the default routing
-algorithm is utilized.
-
-The ability to dump switch lid matrices (aka min hops tables) to file and
-later to load these is also supported.
-
-The usage is similar to unicast forwarding tables loading from a lfts
-file (introduced by 'file' routing engine), but new lid matrix file
-name should be specified by -M or --lid_matrix_file option. For example:
-
- opensm -R file -M ./opensm-lid-matrix.dump
-
-The dump file is named \'opensm-lid-matrix.dump\' and will be generated
-in standard opensm dump directory (/var/log by default) when
-OSM_LOG_ROUTING logging flag is set.
-
-When routing engine 'file' is activated, but the lfts file is not specified
-or not cannot be open default lid matrix algorithm will be used.
-
-There is also a switch forwarding tables dumper which generates
-a file compatible with dump_lfts.sh output. This file can be used
-as input for forwarding tables loading by 'file' routing engine.
-Both or one of options -U and -M can be specified together with \'-R file\'.
-
-.SH FILES
-.TP
-.B @OPENSM_CONFIG_DIR@/@OPENSM_CONFIG_FILE@
-default OpenSM config file.
-
-.TP
-.B @OPENSM_CONFIG_DIR@/@NODENAMEMAPFILE@
-default node name map file. See ibnetdiscover for more information on format.
-
-.TP
-.B @OPENSM_CONFIG_DIR@/@PARTITION_CONFIG_FILE@
-default partition config file
-
-.TP
-.B @OPENSM_CONFIG_DIR@/@QOS_POLICY_FILE@
-default QOS policy config file
-
-.TP
-.B @OPENSM_CONFIG_DIR@/@PREFIX_ROUTES_FILE@
-default prefix routes file.
-
-.SH AUTHORS
-.TP
-Hal Rosenstock
-.RI < hal.rosenstock@gmail.com >
-.TP
-Sasha Khapyorsky
-.RI < sashak@voltaire.com >
-.TP
-Eitan Zahavi
-.RI < eitan@mellanox.co.il >
-.TP
-Yevgeny Kliteynik
-.RI < kliteyn@mellanox.co.il >
-.TP
-Thomas Sodring
-.RI < tsodring@simula.no >
-.TP
-Ira Weiny
-.RI < weiny2@llnl.gov >
diff --git a/contrib/ofed/management/opensm/man/osmtest.8 b/contrib/ofed/management/opensm/man/osmtest.8
deleted file mode 100644
index c814b49..0000000
--- a/contrib/ofed/management/opensm/man/osmtest.8
+++ /dev/null
@@ -1,190 +0,0 @@
-.TH OSMTEST 8 "August 11, 2008" "OpenIB" "OpenIB Management"
-
-.SH NAME
-osmtest \- InfiniBand subnet manager and administration (SM/SA) test program
-
-.SH SYNOPSIS
-.B osmtest
-[\-f(low) <c|a|v|s|e|f|m|q|t>] [\-w(ait) <trap_wait_time>] [\-d(ebug) <number>]
-[\-m(ax_lid) <LID in hex>] [\-g(uid)[=]<GUID in hex>] [-p(ort)]
-[\-i(nventory) <filename>] [\-s(tress)] [\-M(ulticast_Mode)]
-[\-t(imeout) <milliseconds>] [\-l | \-\-log_file] [\-v] [\-vf <flags>]
-[\-h(elp)]
-
-.SH DESCRIPTION
-.PP
-osmtest is a test program to validate InfiniBand subnet manager and
-administration (SM/SA).
-
-Default is to run all flows with the exception of the QoS flow.
-
-osmtest provides a test suite for opensm.
-
-osmtest has the following capabilities and testing flows:
-
-It creates an inventory file of all available Nodes, Ports, and PathRecords,
-including all their fields.
-It verifies the existing inventory, with all the object fields, and matches it
-to a pre-saved one.
-A Multicast Compliancy test.
-An Event Forwarding test.
-A Service Record registration test.
-An RMPP stress test.
-A Small SA Queries stress test.
-
-It is recommended that after installing opensm, the user should run
-"osmtest -f c" to generate the inventory file, and
-immediately afterwards run "osmtest -f a" to test OpenSM.
-
-Another recommendation for osmtest usage is to create the inventory when the
-IB fabric is stable, and occasionally
-run "osmtest -v" to verify that nothing has changed.
-
-.SH OPTIONS
-
-.PP
-.TP
-\fB\-f\fR, \fB\-\-flow\fR
-This option directs osmtest to run a specific flow:
- FLOW DESCRIPTION
- c = create an inventory file with all nodes, ports and paths
- a = run all validation tests (expecting an input inventory)
- v = only validate the given inventory file
- s = run service registration, deregistration, and lease test
- e = run event forwarding test
- f = flood the SA with queries according to the stress mode
- m = multicast flow
- q = QoS info: dump VLArb and SLtoVL tables
- t = run trap 64/65 flow (this flow requires running of external tool)
- (default is all flows except QoS)
-.TP
-\fB\-w\fR, \fB\-\-wait\fR
-This option specifies the wait time for trap 64/65 in seconds
-It is used only when running -f t - the trap 64/65 flow
-(default to 10 sec)
-.TP
-\fB\-d\fR, \fB\-\-debug\fR
-This option specifies a debug option.
-These options are not normally needed.
-The number following -d selects the debug
-option to enable as follows:
-
- OPT Description
- --- -----------------
- -d0 - Ignore other SM nodes
- -d1 - Force single threaded dispatching
- -d2 - Force log flushing after each log message
- -d3 - Disable multicast support
-.TP
-\fB\-m\fR, \fB\-\-max_lid\fR
-This option specifies the maximal LID number to be searched
-for during inventory file build (default to 100)
-.TP
-\fB\-g\fR, \fB\-\-guid\fR
-This option specifies the local port GUID value
-with which OpenSM should bind. OpenSM may be
-bound to 1 port at a time.
-If GUID given is 0, OpenSM displays a list
-of possible port GUIDs and waits for user input.
-Without -g, OpenSM trys to use the default port.
-.TP
-\fB\-p\fR, \fB\-\-port\fR
-This option displays a menu of possible local port GUID values
-with which osmtest could bind
-.TP
-\fB\-i\fR, \fB\-\-inventory\fR
-This option specifies the name of the inventory file
-Normally, osmtest expects to find an inventory file,
-which osmtest uses to validate real-time information
-received from the SA during testing
-If -i is not specified, osmtest defaults to the file
-\'osmtest.dat\'
-See -c option for related information
-.TP
-\fB\-s\fR, \fB\-\-stress\fR
-This option runs the specified stress test instead
-of the normal test suite
-Stress test options are as follows:
-
- OPT Description
- --- -----------------
- -s1 - Single-MAD response SA queries
- -s2 - Multi-MAD (RMPP) response SA queries
- -s3 - Multi-MAD (RMPP) Path Record SA queries
-
-Without -s, stress testing is not performed
-.TP
-\fB\-M\fR, \fB\-\-Multicast_Mode\fR
-This option specify length of Multicast test:
-
- OPT Description
- --- -----------------
- -M1 - Short Multicast Flow (default) - single mode
- -M2 - Short Multicast Flow - multiple mode
- -M3 - Long Multicast Flow - single mode
- -M4 - Long Multicast Flow - multiple mode
-
-Single mode - Osmtest is tested alone, with no other
-apps that interact with OpenSM MC
-
-Multiple mode - Could be run with other apps using MC with
-OpenSM. Without -M, default flow testing is performed
-.TP
-\fB\-t\fR, \fB\-\-timeout\fR
-This option specifies the time in milliseconds
-used for transaction timeouts.
-Specifying -t 0 disables timeouts.
-Without -t, OpenSM defaults to a timeout value of
-200 milliseconds.
-.TP
-\fB\-l\fR, \fB\-\-log_file\fR
-This option defines the log to be the given file.
-By default the log goes to stdout.
-.TP
-\fB\-v\fR, \fB\-\-verbose\fR
-This option increases the log verbosity level.
-The -v option may be specified multiple times
-to further increase the verbosity level.
-See the -vf option for more information about.
-log verbosity.
-.TP
-\fB\-V\fR
-This option sets the maximum verbosity level and
-forces log flushing.
-The -V is equivalent to '-vf 0xFF -d 2'.
-See the -vf option for more information about.
-log verbosity.
-.TP
-\fB\-vf\fR
-This option sets the log verbosity level.
-A flags field must follow the -D option.
-A bit set/clear in the flags enables/disables a
-specific log level as follows:
-
- BIT LOG LEVEL ENABLED
- ---- -----------------
- 0x01 - ERROR (error messages)
- 0x02 - INFO (basic messages, low volume)
- 0x04 - VERBOSE (interesting stuff, moderate volume)
- 0x08 - DEBUG (diagnostic, high volume)
- 0x10 - FUNCS (function entry/exit, very high volume)
- 0x20 - FRAMES (dumps all SMP and GMP frames)
- 0x40 - ROUTING (dump FDB routing information)
- 0x80 - currently unused.
-
-Without -vf, osmtest defaults to ERROR + INFO (0x3)
-Specifying -vf 0 disables all messages
-Specifying -vf 0xFF enables all messages (see -V)
-High verbosity levels may require increasing
-the transaction timeout with the -t option
-.TP
-\fB\-h\fR, \fB\-\-help\fR
-Display this usage info then exit.
-
-.SH AUTHORS
-.TP
-Hal Rosenstock
-.RI < hal@xsigo.com >
-.TP
-Eitan Zahavi
-.RI < eitan@mellanox.co.il >
diff --git a/contrib/ofed/management/opensm/opensm.spec.in b/contrib/ofed/management/opensm/opensm.spec.in
deleted file mode 100644
index 9c23f47..0000000
--- a/contrib/ofed/management/opensm/opensm.spec.in
+++ /dev/null
@@ -1,146 +0,0 @@
-%define RELEASE @RELEASE@
-%define rel %{?CUSTOM_RELEASE} %{!?CUSTOM_RELEASE:%RELEASE}
-%if %{?_with_console_socket:1}%{!?_with_console_socket:0}
-%define _enable_console_socket --enable-console-socket
-%endif
-%if %{?_without_console_socket:1}%{!?_without_console_socket:0}
-%define _disable_console_socket --disable-console-socket
-%endif
-
-%if %{?_with_perf_mgr:1}%{!?_with_perf_mgr:0}
-%define _enable_perf_mgr --enable-perf-mgr
-%endif
-%if %{?_without_perf_mgr:1}%{!?_without_perf_mgr:0}
-%define _disable_perf_mgr --disable-perf-mgr
-%endif
-
-%if %{?_with_event_plugin:1}%{!?_with_event_plugin:0}
-%define _enable_event_plugin --enable-event-plugin
-%endif
-%if %{?_without_event_plugin:1}%{!?_without_event_plugin:0}
-%define _disable_event_plugin --disable-event-plugin
-%endif
-
-Summary: InfiniBand subnet manager and administration
-Name: opensm
-Version: @VERSION@
-Release: %rel%{?dist}
-License: GPLv2 or BSD
-Group: System Environment/Daemons
-URL: http://openfabrics.org/
-Source: http://www.openfabrics.org/downloads/management/@TARBALL@
-BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
-BuildRequires: libibumad-devel, libtool
-Requires: %{name}-libs = %{version}-%{release}, logrotate
-Requires(post): /sbin/service, /sbin/chkconfig
-Requires(preun): /sbin/chkconfig, /sbin/service
-
-%description
-OpenSM provides an implementation of an InfiniBand Subnet Manager and
-Administration. Such a software entity is required to run for in order
-to initialize the InfiniBand hardware (at least one per each
-InfiniBand subnet).
-
-%package libs
-Summary: Libraries from the opensm package
-Group: System Environment/Libraries
-Requires(post): /sbin/ldconfig
-Requires(postun): /sbin/ldconfig
-Obsoletes: libopensm, libosmcomp, libosmvendor
-
-%description libs
-Shared libraries that are part of the opensm package but are also used by
-other applications. If you don't need opensm itself installed, these
-libraries can be installed to satisfy dependencies of other applications.
-
-%package devel
-Summary: Development files for OpenSM
-Group: System Environment/Libraries
-Requires: %{name}-libs = %{version}-%{release} libibumad-devel
-Obsoletes: libopensm-devel, libosmcomp-devel, libosmvendor-devel
-
-%description devel
-Header files for OpenSM.
-
-%package static
-Summary: Static version of the opensm libraries
-Group: System Environment/Libraries
-Requires: %{name}-libs = %{version}-%{release} libibumad-devel
-
-%description static
-Static version of the opensm libraries
-
-%prep
-%setup -q
-
-%build
-%configure \
- %{?_enable_console_socket} \
- %{?_disable_console_socket} \
- %{?_enable_perf_mgr} \
- %{?_disable_perf_mgr} \
- %{?_enable_event_plugin} \
- %{?_disable_event_plugin}
-make %{?_smp_mflags}
-
-%install
-rm -rf $RPM_BUILD_ROOT
-make DESTDIR=$RPM_BUILD_ROOT install
-rm -f $RPM_BUILD_ROOT%{_libdir}/*.la
-etc=$RPM_BUILD_ROOT%{_sysconfdir}
-mkdir -p ${RPM_BUILD_ROOT}/var/cache/opensm
-if [ -f /etc/redhat-release -o -s /etc/redhat-release ]; then
- REDHAT="redhat-"
-else
- REDHAT=""
-fi
-mkdir -p $etc/{init.d,logrotate.d} $etc/@OPENSM_CONFIG_SUB_DIR@
-install -m 755 scripts/${REDHAT}opensm.init $etc/init.d/opensmd
-install -D -m 644 scripts/opensm.logrotate $etc/logrotate.d/opensm
-install -m 755 scripts/sldd.sh $RPM_BUILD_ROOT%{_sbindir}/sldd.sh
-
-%clean
-rm -rf $RPM_BUILD_ROOT
-
-%post
-if [ $1 = 1 ]; then
- /sbin/chkconfig --add opensmd
-else
- /sbin/service opensmd condrestart
-fi
-
-%preun
-if [ $1 = 0 ]; then
- /sbin/service opensmd stop
- /sbin/chkconfig --del opensmd
- rm -f /var/cache/opensm/*
-fi
-
-%post libs -p /sbin/ldconfig
-%postun libs -p /sbin/ldconfig
-
-%files
-%defattr(-,root,root,-)
-%{_sbindir}/opensm
-%{_sbindir}/osmtest
-%{_mandir}/man8/*
-%doc AUTHORS COPYING README doc/performance-manager-HOWTO.txt doc/QoS_management_in_OpenSM.txt doc/opensm_release_notes-3.2.txt
-%{_sysconfdir}/init.d/opensmd
-%{_sbindir}/sldd.sh
-%config(noreplace) %{_sysconfdir}/logrotate.d/opensm
-%dir /var/cache/opensm
-%dir %{_sysconfdir}/@OPENSM_CONFIG_SUB_DIR@
-
-%files libs
-%defattr(-,root,root,-)
-%{_libdir}/*.so.*
-
-%files devel
-%defattr(-,root,root,-)
-%{_includedir}/infiniband/*
-%{_libdir}/*.so
-
-%files static
-%defattr(-,root,root,-)
-%{_libdir}/*.a
-
diff --git a/contrib/ofed/management/opensm/opensm/ChangeLog b/contrib/ofed/management/opensm/opensm/ChangeLog
deleted file mode 100644
index 97eb67a..0000000
--- a/contrib/ofed/management/opensm/opensm/ChangeLog
+++ /dev/null
@@ -1,115 +0,0 @@
-2007-07-11 Hal Rosenstock <halr@voltaire.com>
-
- * configure.in: Bump to version 2.2.1
-
-2007-06-20 Hal Rosenstock <halr@voltaire.com>
-
- * osm_helper.c: Add 3LeafNetworks and Xsigo to osm_get_manufacturer_str
-
-2007-06-15 Sasha Khapyorsky <sashak@voltaire.com>
-
- * osm_helper.c: Fix PortInfo:CapMask printing when CapMask is 0
-
-2007-06-11 Sasha Khapyorsky <sashak@voltaire.com>
-
- * osm_helper.c: Remove OSM_SM_SIGNAL_MASTER_OR_HIGHER_SM_DETECTED
- from __osm_sm_mgr_signal_str
-
-2007-06-06 Sasha Khapyorsky <sashak@voltaire.com>
-
- * osm_helper.c: More optimally deal with manufacturer strings
-
-2007-06-06 Hal Rosenstock <halr@voltaire.com>
-
- * osm_helper.c: Add Sun to osm_get_manufacturer_str
-
-2007-06-04 Hal Rosenstock <halr@voltaire.com>
-
- * osm_helper.c: Add 8x to __osm_lwa_str_fixed_width
-
-2007-05-07 Sasha Khapyorsky <sashak@voltaire.com>
-
- * osm_helper.c: Remove repeated strlen() calls
-
-2007-04-27 Ira K. Weiny <weiny2@llnl.gov>
-
- * osm_helper.c: In osm_dump_notice, use ib_get_producer_type_str
- for printing producer type
-
-2007-04-26 Hal Rosenstock <halr@voltaire.com>
-
- * osm_helper.c: Clarify the proper usage of
- osm_get_node_type_str_fixed_width to take uint8_t rather
- than uint32_t for node_type argument
-
-2007-04-25 Yevgeny Kliteynik <kliteyn@dev.mellanox.co.il>
-
- * osm_helper.c: Fix problematic usage of sprintf() when
- source and destination strings overlap.
-
-2007-04-24 Albert L. Chu <chu11@llnl.gov>
-
- * osm_helper.c: In osm_get_node_type_str_fixed_width, fix
- both range limit and endian of node type check
-
-2007-03-29 Hal Rosenstock <halr@voltaire.com>
-
- * configure.in: Bump version to 2.2.0
-
-2007-03-21 Sasha Khapyorsky <sashak@voltaire.com>
-
- * osm_log.c: Changed to support daemon mode
-
-2007-03-01 Hal Rosenstock <halr@voltaire.com>
-
- * configure.in: Bump version to 2.1.2
-
- * osm_helper.c: Eliminate extraneous comma in __osm_disp_msg_ string
- for OSM_MSG_MAD_PORT_INFO
-
-2007-02-26 Sasha Khapyorsky <sashak@voltaire.com>
-
- * osm_log.c: Minor optimization to previous change to osm_log
- for also flushing on OSM_LOG_SYS
-
-2007-02-26 Yevgeny Kliteynik <kliteyn@dev.mellanox.co.il>
-
- * osm_log.c: In osm_log, flush log on OSM_LOG_SYS (as well
- as OSM_LOG_ERROR)
-
-2007-02-20 Hal Rosenstock <halr@voltaire.com>
-
- * configure.in: Bump version to 2.1.1
-
- * osm_helper.c: In osm_dbg_get_capabilities_str, only display
- Capability Mask if there are capabilities present
-
-2007-01-22 Hal Rosenstock <halr@voltaire.com>
-
- * osm_helper.c: Change DR path format from [%X] to %d,
-
-2007-01-08 Sasha Khapyorsky <sashak@voltaire.com>
-
- * osm_log.c: Add osm_log_reopen_file API
-
-2006-12-22 Hal Rosenstock <halr@voltaire.com>
-
- * osm_helper.c: Add osm_dump_switch_info_record API
-
-2006-11-03 Sasha Khapyorsky <sashak@voltaire.com>
-
- * osm_log.c: Add osm_log_printf API
-
-2006-10-30 Sasha Khapyorsky <sashak@voltaire.com>
-
- * osm_helper.c: Fix seg fault with strings which
- might not be null terminated
-
-2006-10-18 Yevgeny Kliteynik <kliteyn@dev.mellanox.co.il>
-
- * osm_log.c: Windows porting changes
-
-2006-09-19 Yevgeny Kliteynik <kliteyn@dev.mellanox.co.il>
-
- * osm_log.c: Windows porting changes
-
diff --git a/contrib/ofed/management/opensm/opensm/Makefile.am b/contrib/ofed/management/opensm/opensm/Makefile.am
deleted file mode 100644
index 66fbccc..0000000
--- a/contrib/ofed/management/opensm/opensm/Makefile.am
+++ /dev/null
@@ -1,131 +0,0 @@
-
-INCLUDES = $(OSMV_INCLUDES)
-
-AM_CFLAGS = -Wall $(DBGFLAGS) -D_XOPEN_SOURCE=600 -D_BSD_SOURCE=1
-
-lib_LTLIBRARIES = libopensm.la
-
-if DEBUG
-DBGFLAGS = -ggdb -D_DEBUG_
-else
-DBGFLAGS = -g
-endif
-
-if HAVE_LD_VERSION_SCRIPT
-libopensm_version_script = -Wl,--version-script=$(srcdir)/libopensm.map
-else
-libopensm_version_script =
-endif
-
-opensm_api_version=$(shell grep LIBVERSION= $(srcdir)/libopensm.ver | sed 's/LIBVERSION=//')
-
-libopensm_la_SOURCES = osm_log.c osm_mad_pool.c osm_helper.c
-libopensm_la_LDFLAGS = -version-info $(opensm_api_version) \
- -export-dynamic $(libopensm_version_script)
-libopensm_la_DEPENDENCIES = $(srcdir)/libopensm.map
-
-sbin_PROGRAMS = opensm
-opensm_DEPENDENCIES = libopensm.la
-opensm_SOURCES = main.c osm_console_io.c osm_console.c osm_db_files.c \
- osm_db_pack.c osm_drop_mgr.c \
- osm_inform.c osm_lid_mgr.c osm_lin_fwd_rcv.c \
- osm_link_mgr.c osm_mcast_fwd_rcv.c \
- osm_mcast_mgr.c osm_mcast_tbl.c osm_mcm_info.c \
- osm_mcm_port.c osm_mtree.c osm_multicast.c osm_node.c \
- osm_node_desc_rcv.c osm_node_info_rcv.c \
- osm_opensm.c osm_pkey.c osm_pkey_mgr.c osm_pkey_rcv.c \
- osm_port.c osm_port_info_rcv.c \
- osm_remote_sm.c osm_req.c \
- osm_resp.c osm_sa.c osm_sa_class_port_info.c \
- osm_sa_informinfo.c osm_sa_lft_record.c osm_sa_mft_record.c \
- osm_sa_link_record.c osm_sa_mad_ctrl.c \
- osm_sa_mcmember_record.c osm_sa_node_record.c \
- osm_sa_path_record.c osm_sa_pkey_record.c \
- osm_sa_portinfo_record.c osm_sa_guidinfo_record.c \
- osm_sa_multipath_record.c \
- osm_sa_service_record.c osm_sa_slvl_record.c \
- osm_sa_sminfo_record.c osm_sa_vlarb_record.c \
- osm_sa_sw_info_record.c osm_service.c \
- osm_slvl_map_rcv.c osm_sm.c osm_sminfo_rcv.c \
- osm_sm_mad_ctrl.c osm_sm_state_mgr.c osm_state_mgr.c \
- osm_subnet.c osm_sw_info_rcv.c osm_switch.c \
- osm_prtn.c osm_prtn_config.c osm_qos.c osm_router.c \
- osm_trap_rcv.c osm_ucast_mgr.c osm_ucast_updn.c \
- osm_ucast_lash.c osm_ucast_file.c osm_ucast_ftree.c \
- osm_vl15intf.c osm_vl_arb_rcv.c \
- st.c osm_perfmgr.c osm_perfmgr_db.c \
- osm_event_plugin.c osm_dump.c osm_ucast_cache.c \
- osm_qos_parser_y.y osm_qos_parser_l.l osm_qos_policy.c
-
-AM_YFLAGS:= -d
-
-# we need to be able to load libraries from local build subtree before make install
-# we always give precedence to local tree libs and then use the pre-installed ones.
-opensm_LDADD = -L../complib -losmcomp -L../libvendor -losmvendor -L. -lopensm $(OSMV_LDADD)
-
-opensmincludedir = $(includedir)/infiniband/opensm
-
-opensminclude_HEADERS = \
- $(srcdir)/../include/opensm/osm_attrib_req.h \
- $(srcdir)/../include/opensm/osm_base.h \
- $(srcdir)/../include/opensm/osm_console.h \
- $(srcdir)/../include/opensm/osm_console_io.h \
- $(srcdir)/../include/opensm/osm_db.h \
- $(srcdir)/../include/opensm/osm_db_pack.h \
- $(srcdir)/../include/opensm/osm_event_plugin.h \
- $(srcdir)/../include/opensm/osm_errors.h \
- $(srcdir)/../include/opensm/osm_helper.h \
- $(srcdir)/../include/opensm/osm_inform.h \
- $(srcdir)/../include/opensm/osm_lid_mgr.h \
- $(srcdir)/../include/opensm/osm_log.h \
- $(srcdir)/../include/opensm/osm_mad_pool.h \
- $(srcdir)/../include/opensm/osm_madw.h \
- $(srcdir)/../include/opensm/osm_mcast_tbl.h \
- $(srcdir)/../include/opensm/osm_mcm_info.h \
- $(srcdir)/../include/opensm/osm_mcm_port.h \
- $(srcdir)/../include/opensm/osm_mtree.h \
- $(srcdir)/../include/opensm/osm_multicast.h \
- $(srcdir)/../include/opensm/osm_msgdef.h \
- $(srcdir)/../include/opensm/osm_node.h \
- $(srcdir)/../include/opensm/osm_opensm.h \
- $(srcdir)/../include/opensm/osm_partition.h \
- $(srcdir)/../include/opensm/osm_path.h \
- $(srcdir)/../include/opensm/osm_perfmgr.h \
- $(srcdir)/../include/opensm/osm_perfmgr_db.h \
- $(srcdir)/../include/opensm/osm_pkey.h \
- $(srcdir)/../include/opensm/osm_port.h \
- $(srcdir)/../include/opensm/osm_port_profile.h \
- $(srcdir)/../include/opensm/osm_prefix_route.h \
- $(srcdir)/../include/opensm/osm_qos_policy.h \
- $(srcdir)/../include/opensm/osm_remote_sm.h \
- $(srcdir)/../include/opensm/osm_router.h \
- $(srcdir)/../include/opensm/osm_sa.h \
- $(srcdir)/../include/opensm/osm_sa_mad_ctrl.h \
- $(srcdir)/../include/opensm/osm_service.h \
- $(srcdir)/../include/opensm/osm_sm.h \
- $(srcdir)/../include/opensm/osm_sm_mad_ctrl.h \
- $(srcdir)/../include/opensm/st.h \
- $(srcdir)/../include/opensm/osm_stats.h \
- $(srcdir)/../include/opensm/osm_subnet.h \
- $(srcdir)/../include/opensm/osm_switch.h \
- $(srcdir)/../include/opensm/osm_ucast_mgr.h \
- $(srcdir)/../include/opensm/osm_ucast_cache.h \
- $(srcdir)/../include/opensm/osm_vl15intf.h \
- $(top_builddir)/include/opensm/osm_version.h \
- $(top_builddir)/include/opensm/osm_config.h
-
-BUILT_SOURCES = osm_version osm_qos_parser_y.h
-osm_version:
- if [ -x $(top_srcdir)/../gen_ver.sh ] ; then \
- ver_file=$(top_builddir)/include/opensm/osm_version.h ; \
- osm_ver=`cat $$ver_file | sed -ne '/#define OSM_VERSION /s/^.*\"OpenSM \(.*\)\"$$/\1/p'` ; \
- ver=`$(top_srcdir)/../gen_ver.sh $(PACKAGE)` ; \
- if [ $$ver != $$osm_ver ] ; then \
- cat $$ver_file | sed -e '/#define OSM_VERSION /s/\"OpenSM .*\"/\"OpenSM '$$ver'\"/' > tmp_new_version ; \
- cat tmp_new_version > $$ver_file && rm -f tmp_new_version ; \
- fi ; \
- fi
-
-# files distributed as part of the srcdir
-EXTRA_DIST = $(srcdir)/libopensm.map $(srcdir)/libopensm.ver \
- $(srcdir)/ChangeLog
diff --git a/contrib/ofed/management/opensm/opensm/libopensm.map b/contrib/ofed/management/opensm/opensm/libopensm.map
deleted file mode 100644
index 7cd2aba..0000000
--- a/contrib/ofed/management/opensm/opensm/libopensm.map
+++ /dev/null
@@ -1,59 +0,0 @@
-OPENSM_1.5 {
- global:
- osm_log;
- osm_log_msg_box;
- osm_is_debug;
- osm_log_init;
- osm_log_init_v2;
- osm_log_reopen_file;
- osm_mad_pool_construct;
- osm_mad_pool_destroy;
- osm_mad_pool_init;
- osm_mad_pool_get;
- osm_mad_pool_put;
- osm_mad_pool_get_wrapper;
- osm_mad_pool_get_wrapper_raw;
- ib_get_sa_method_str;
- ib_get_sm_method_str;
- ib_get_sm_attr_str;
- ib_get_sa_attr_str;
- ib_get_trap_str;
- osm_dump_port_info;
- osm_dump_portinfo_record;
- osm_dump_guidinfo_record;
- osm_dump_node_info;
- osm_dump_node_record;
- osm_dump_path_record;
- osm_dump_multipath_record;
- osm_dump_mc_record;
- osm_dump_service_record;
- osm_dump_inform_info;
- osm_dump_inform_info_record;
- osm_dump_link_record;
- osm_dump_switch_info;
- osm_dump_switch_info_record;
- osm_dump_pkey_table;
- osm_dump_slvl_map_table;
- osm_dump_vl_arb_table;
- osm_dump_sm_info;
- osm_dump_sm_info_record;
- osm_dump_notice;
- osm_dump_dr_smp;
- osm_dump_sa_mad;
- osm_dump_dr_path;
- osm_dump_smp_dr_path;
- osm_dump_pkey_block;
- osm_log_raw;
- osm_get_sm_state_str;
- osm_get_sm_signal_str;
- osm_get_disp_msg_str;
- osm_get_port_state_str_fixed_width;
- osm_get_node_type_str_fixed_width;
- osm_get_manufacturer_str;
- osm_get_mtu_str;
- osm_get_lwa_str;
- osm_get_lsa_str;
- osm_get_sm_mgr_signal_str;
- osm_get_sm_mgr_state_str;
- local: *;
-};
diff --git a/contrib/ofed/management/opensm/opensm/libopensm.ver b/contrib/ofed/management/opensm/opensm/libopensm.ver
deleted file mode 100644
index f552dd0..0000000
--- a/contrib/ofed/management/opensm/opensm/libopensm.ver
+++ /dev/null
@@ -1,9 +0,0 @@
-# In this file we track the current API version
-# of the opensm common interface (and libraries)
-# The version is built of the following
-# tree numbers:
-# API_REV:RUNNING_REV:AGE
-# API_REV - advance on any added API
-# RUNNING_REV - advance any change to the vendor files
-# AGE - number of backward versions the API still supports
-LIBVERSION=3:3:1
diff --git a/contrib/ofed/management/opensm/opensm/main.c b/contrib/ofed/management/opensm/opensm/main.c
deleted file mode 100644
index 999e92f..0000000
--- a/contrib/ofed/management/opensm/opensm/main.c
+++ /dev/null
@@ -1,1027 +0,0 @@
-/*
- * Copyright (c) 2004-2008 Voltaire, Inc. All rights reserved.
- * Copyright (c) 2002-2008 Mellanox Technologies LTD. All rights reserved.
- * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- */
-
-/*
- * Abstract:
- * Command line interface for opensm.
- */
-
-#if HAVE_CONFIG_H
-# include <config.h>
-#endif /* HAVE_CONFIG_H */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <getopt.h>
-#include <unistd.h>
-#include <signal.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <complib/cl_types.h>
-#include <complib/cl_debug.h>
-#include <vendor/osm_vendor_api.h>
-#include <opensm/osm_version.h>
-#include <opensm/osm_opensm.h>
-#include <opensm/osm_console.h>
-#include <opensm/osm_console_io.h>
-#include <opensm/osm_perfmgr.h>
-
-volatile unsigned int osm_exit_flag = 0;
-
-static volatile unsigned int osm_hup_flag = 0;
-static volatile unsigned int osm_usr1_flag = 0;
-
-#define GUID_ARRAY_SIZE 64
-#define INVALID_GUID (0xFFFFFFFFFFFFFFFFULL)
-
-static void mark_exit_flag(int signum)
-{
- if (!osm_exit_flag)
- printf("OpenSM: Got signal %d - exiting...\n", signum);
- osm_exit_flag = 1;
-}
-
-static void mark_hup_flag(int signum)
-{
- osm_hup_flag = 1;
-}
-
-static void mark_usr1_flag(int signum)
-{
- osm_usr1_flag = 1;
-}
-
-static sigset_t saved_sigset;
-
-static void block_signals()
-{
- sigset_t set;
-
- sigemptyset(&set);
- sigaddset(&set, SIGINT);
- sigaddset(&set, SIGTERM);
- sigaddset(&set, SIGHUP);
-#ifndef HAVE_OLD_LINUX_THREADS
- sigaddset(&set, SIGUSR1);
-#endif
- pthread_sigmask(SIG_SETMASK, &set, &saved_sigset);
-}
-
-static void setup_signals()
-{
- struct sigaction act;
-
- sigemptyset(&act.sa_mask);
- act.sa_handler = mark_exit_flag;
- act.sa_flags = 0;
- sigaction(SIGINT, &act, NULL);
- sigaction(SIGTERM, &act, NULL);
- act.sa_handler = mark_hup_flag;
- sigaction(SIGHUP, &act, NULL);
- sigaction(SIGCONT, &act, NULL);
-#ifndef HAVE_OLD_LINUX_THREADS
- act.sa_handler = mark_usr1_flag;
- sigaction(SIGUSR1, &act, NULL);
-#endif
- pthread_sigmask(SIG_SETMASK, &saved_sigset, NULL);
-}
-
-/**********************************************************************
- **********************************************************************/
-
-static void show_usage(void)
-{
- printf("\n------- OpenSM - Usage and options ----------------------\n");
- printf("Usage: opensm [options]\n");
- printf("Options:\n");
- printf("--version\n Prints OpenSM version and exits.\n\n");
- printf("--config, -F <file-name>\n"
- " The name of the OpenSM config file. When not specified\n"
- " " OSM_DEFAULT_CONFIG_FILE " will be used (if exists).\n\n");
- printf("--create-config, -c <file-name>\n"
- " OpenSM will dump its configuration to the specified file and exit.\n"
- " This is a way to generate OpenSM configuration file template.\n\n");
- printf("--guid, -g <GUID in hex>\n"
- " This option specifies the local port GUID value\n"
- " with which OpenSM should bind. OpenSM may be\n"
- " bound to 1 port at a time.\n"
- " If GUID given is 0, OpenSM displays a list\n"
- " of possible port GUIDs and waits for user input.\n"
- " Without -g, OpenSM tries to use the default port.\n\n");
- printf("--lmc, -l <LMC>\n"
- " This option specifies the subnet's LMC value.\n"
- " The number of LIDs assigned to each port is 2^LMC.\n"
- " The LMC value must be in the range 0-7.\n"
- " LMC values > 0 allow multiple paths between ports.\n"
- " LMC values > 0 should only be used if the subnet\n"
- " topology actually provides multiple paths between\n"
- " ports, i.e. multiple interconnects between switches.\n"
- " Without -l, OpenSM defaults to LMC = 0, which allows\n"
- " one path between any two ports.\n\n");
- printf("--priority, -p <PRIORITY>\n"
- " This option specifies the SM's PRIORITY.\n"
- " This will effect the handover cases, where master\n"
- " is chosen by priority and GUID. Range goes\n"
- " from 0 (lowest priority) to 15 (highest).\n\n");
- printf("--smkey, -k <SM_Key>\n"
- " This option specifies the SM's SM_Key (64 bits).\n"
- " This will effect SM authentication.\n"
- " Note that OpenSM version 3.2.1 and below used the\n"
- " default value '1' in a host byte order, it is fixed\n"
- " now but you may need this option to interoperate\n"
- " with old OpenSM running on a little endian machine.\n\n");
- printf("--reassign_lids, -r\n"
- " This option causes OpenSM to reassign LIDs to all\n"
- " end nodes. Specifying -r on a running subnet\n"
- " may disrupt subnet traffic.\n"
- " Without -r, OpenSM attempts to preserve existing\n"
- " LID assignments resolving multiple use of same LID.\n\n");
- printf("--routing_engine, -R <engine name>\n"
- " This option chooses routing engine(s) to use instead of default\n"
- " Min Hop algorithm. Multiple routing engines can be specified\n"
- " separated by commas so that specific ordering of routing\n"
- " algorithms will be tried if earlier routing engines fail.\n"
- " Supported engines: updn, file, ftree, lash, dor\n\n");
- printf("--connect_roots, -z\n"
- " This option enforces a routing engine (currently\n"
- " up/down only) to make connectivity between root switches\n"
- " and in this way be IBA compliant. In many cases,\n"
- " this can violate \"pure\" deadlock free algorithm, so\n"
- " use it carefully.\n\n");
- printf("--ucast_cache, -A\n"
- " This option enables unicast routing cache to prevent\n"
- " routing recalculation (which is a heavy task in a\n"
- " large cluster) when there was no topology change\n"
- " detected during the heavy sweep, or when the topology\n"
- " change does not require new routing calculation,\n"
- " e.g. in case of host reboot.\n"
- " This option becomes very handy when the cluster size\n"
- " is thousands of nodes.\n\n");
- printf("--lid_matrix_file, -M <file name>\n"
- " This option specifies the name of the lid matrix dump file\n"
- " from where switch lid matrices (min hops tables will be\n"
- " loaded.\n\n");
- printf("--lfts_file, -U <file name>\n"
- " This option specifies the name of the LFTs file\n"
- " from where switch forwarding tables will be loaded.\n\n");
- printf("--sadb_file, -S <file name>\n"
- " This option specifies the name of the SA DB dump file\n"
- " from where SA database will be loaded.\n\n");
- printf("--root_guid_file, -a <path to file>\n"
- " Set the root nodes for the Up/Down or Fat-Tree routing\n"
- " algorithm to the guids provided in the given file (one\n"
- " to a line)\n" "\n");
- printf("--cn_guid_file, -u <path to file>\n"
- " Set the compute nodes for the Fat-Tree routing algorithm\n"
- " to the guids provided in the given file (one to a line)\n\n");
- printf("--ids_guid_file, -m <path to file>\n"
- " Name of the map file with set of the IDs which will be used\n"
- " by Up/Down routing algorithm instead of node GUIDs\n"
- " (format: <guid> <id> per line)\n\n");
- printf("--guid_routing_order_file, -X <path to file>\n"
- " Set the order port guids will be routed for the MinHop\n"
- " and Up/Down routing algorithms to the guids provided in the\n"
- " given file (one to a line)\n\n");
- printf("--once, -o\n"
- " This option causes OpenSM to configure the subnet\n"
- " once, then exit. Ports remain in the ACTIVE state.\n\n");
- printf("--sweep, -s <interval>\n"
- " This option specifies the number of seconds between\n"
- " subnet sweeps. Specifying -s 0 disables sweeping.\n"
- " Without -s, OpenSM defaults to a sweep interval of\n"
- " 10 seconds.\n\n");
- printf("--timeout, -t <milliseconds>\n"
- " This option specifies the time in milliseconds\n"
- " used for transaction timeouts.\n"
- " Specifying -t 0 disables timeouts.\n"
- " Without -t, OpenSM defaults to a timeout value of\n"
- " 200 milliseconds.\n\n");
- printf("--maxsmps, -n <number>\n"
- " This option specifies the number of VL15 SMP MADs\n"
- " allowed on the wire at any one time.\n"
- " Specifying --maxsmps 0 allows unlimited outstanding\n"
- " SMPs.\n"
- " Without --maxsmps, OpenSM defaults to a maximum of\n"
- " 4 outstanding SMPs.\n\n");
- printf("--console, -q [off|local"
-#ifdef ENABLE_OSM_CONSOLE_SOCKET
- "|socket|loopback"
-#endif
- "]\n This option activates the OpenSM console (default off).\n\n");
-#ifdef ENABLE_OSM_CONSOLE_SOCKET
- printf("--console-port, -C <port>\n"
- " Specify an alternate telnet port for the console (default %d).\n\n",
- OSM_DEFAULT_CONSOLE_PORT);
-#endif
- printf("--ignore-guids, -i <equalize-ignore-guids-file>\n"
- " This option provides the means to define a set of ports\n"
- " (by guid) that will be ignored by the link load\n"
- " equalization algorithm.\n\n");
- printf("--honor_guid2lid, -x\n"
- " This option forces OpenSM to honor the guid2lid file,\n"
- " when it comes out of Standby state, if such file exists\n"
- " under OSM_CACHE_DIR, and is valid. By default, this is FALSE.\n\n");
- printf("--log_file, -f <log-file-name>\n"
- " This option defines the log to be the given file.\n"
- " By default, the log goes to /var/log/opensm.log.\n"
- " For the log to go to standard output use -f stdout.\n\n");
- printf("--log_limit, -L <size in MB>\n"
- " This option defines maximal log file size in MB. When\n"
- " specified the log file will be truncated upon reaching\n"
- " this limit.\n\n");
- printf("--erase_log_file, -e\n"
- " This option will cause deletion of the log file\n"
- " (if it previously exists). By default, the log file\n"
- " is accumulative.\n\n");
- printf("--Pconfig, -P <partition-config-file>\n"
- " This option defines the optional partition configuration file.\n"
- " The default name is \'"
- OSM_DEFAULT_PARTITION_CONFIG_FILE "\'.\n\n");
- printf("--no_part_enforce, -N\n"
- " This option disables partition enforcement on switch external ports.\n\n");
- printf("--qos, -Q\n" " This option enables QoS setup.\n\n");
- printf("--qos_policy_file, -Y <QoS-policy-file>\n"
- " This option defines the optional QoS policy file.\n"
- " The default name is \'" OSM_DEFAULT_QOS_POLICY_FILE
- "\'.\n\n");
- printf("--stay_on_fatal, -y\n"
- " This option will cause SM not to exit on fatal initialization\n"
- " issues: if SM discovers duplicated guids or 12x link with\n"
- " lane reversal badly configured.\n"
- " By default, the SM will exit on these errors.\n\n");
- printf("--daemon, -B\n"
- " Run in daemon mode - OpenSM will run in the background.\n\n");
- printf("--inactive, -I\n"
- " Start SM in inactive rather than normal init SM state.\n\n");
-#ifdef ENABLE_OSM_PERF_MGR
- printf("--perfmgr\n" " Start with PerfMgr enabled.\n\n");
- printf("--perfmgr_sweep_time_s <sec.>\n"
- " PerfMgr sweep interval in seconds.\n\n");
-#endif
- printf("--prefix_routes_file <path to file>\n"
- " This option specifies the prefix routes file.\n"
- " Prefix routes control how the SA responds to path record\n"
- " queries for off-subnet DGIDs. Default file is:\n"
- " " OSM_DEFAULT_PREFIX_ROUTES_FILE "\n\n");
- printf("--consolidate_ipv6_snm_req\n"
- " Consolidate IPv6 Solicited Node Multicast group joins\n"
- " into 1 IB multicast group.\n\n");
- printf("--verbose, -v\n"
- " This option increases the log verbosity level.\n"
- " The -v option may be specified multiple times\n"
- " to further increase the verbosity level.\n"
- " See the -D option for more information about\n"
- " log verbosity.\n\n");
- printf("--V, -V\n"
- " This option sets the maximum verbosity level and\n"
- " forces log flushing.\n"
- " The -V is equivalent to '-D 0xFF -d 2'.\n"
- " See the -D option for more information about\n"
- " log verbosity.\n\n");
- printf("--D, -D <flags>\n"
- " This option sets the log verbosity level.\n"
- " A flags field must follow the -D option.\n"
- " A bit set/clear in the flags enables/disables a\n"
- " specific log level as follows:\n"
- " BIT LOG LEVEL ENABLED\n"
- " ---- -----------------\n"
- " 0x01 - ERROR (error messages)\n"
- " 0x02 - INFO (basic messages, low volume)\n"
- " 0x04 - VERBOSE (interesting stuff, moderate volume)\n"
- " 0x08 - DEBUG (diagnostic, high volume)\n"
- " 0x10 - FUNCS (function entry/exit, very high volume)\n"
- " 0x20 - FRAMES (dumps all SMP and GMP frames)\n"
- " 0x40 - ROUTING (dump FDB routing information)\n"
- " 0x80 - currently unused.\n"
- " Without -D, OpenSM defaults to ERROR + INFO (0x3).\n"
- " Specifying -D 0 disables all messages.\n"
- " Specifying -D 0xFF enables all messages (see -V).\n"
- " High verbosity levels may require increasing\n"
- " the transaction timeout with the -t option.\n\n");
- printf("--debug, -d <number>\n"
- " This option specifies a debug option.\n"
- " These options are not normally needed.\n"
- " The number following -d selects the debug\n"
- " option to enable as follows:\n"
- " OPT Description\n"
- " --- -----------------\n"
- " -d0 - Ignore other SM nodes\n"
- " -d1 - Force single threaded dispatching\n"
- " -d2 - Force log flushing after each log message\n"
- " -d3 - Disable multicast support\n"
- " -d10 - Put OpenSM in testability mode\n"
- " Without -d, no debug options are enabled\n\n");
- printf("--help, -h, -?\n"
- " Display this usage info then exit.\n\n");
- fflush(stdout);
- exit(2);
-}
-
-/**********************************************************************
- **********************************************************************/
-static ib_net64_t get_port_guid(IN osm_opensm_t * p_osm, uint64_t port_guid)
-{
- ib_port_attr_t attr_array[GUID_ARRAY_SIZE];
- uint32_t num_ports = GUID_ARRAY_SIZE;
- char junk[128];
- uint32_t i, choice = 0;
- boolean_t done_flag = FALSE;
- ib_api_status_t status;
-
- /*
- Call the transport layer for a list of local port
- GUID values.
- */
- status =
- osm_vendor_get_all_port_attr(p_osm->p_vendor, attr_array,
- &num_ports);
- if (status != IB_SUCCESS) {
- printf("\nError from osm_vendor_get_all_port_attr (%x)\n",
- status);
- return (0);
- }
-
- /* if num_ports is 0 - return 0 */
- if (num_ports == 0) {
- printf("\nNo local ports detected!\n");
- return (0);
- }
- /* If num_ports is 1, then there is only one possible port to use.
- * Use it. */
- if (num_ports == 1) {
- printf("Using default GUID 0x%" PRIx64 "\n",
- cl_hton64(attr_array[0].port_guid));
- return (attr_array[0].port_guid);
- }
- /* If port_guid is 0 - use the first connected port */
- if (port_guid == 0) {
- for (i = 0; i < num_ports; i++)
- if (attr_array[i].link_state > IB_LINK_DOWN)
- break;
- if (i == num_ports)
- i = 0;
- printf("Using default GUID 0x%" PRIx64 "\n",
- cl_hton64(attr_array[i].port_guid));
- return (attr_array[i].port_guid);
- }
-
- if (p_osm->subn.opt.daemon)
- return 0;
-
- /* More than one possible port - list all ports and let the user
- * to choose. */
- while (done_flag == FALSE) {
- printf("\nChoose a local port number with which to bind:\n\n");
- for (i = 0; i < num_ports; i++)
- /* Print the index + 1 since by convention, port
- * numbers start with 1 on host channel adapters. */
- printf("\t%u: GUID 0x%" PRIx64
- ", lid %u, state %s\n", i + 1,
- cl_ntoh64(attr_array[i].port_guid),
- attr_array[i].lid,
- ib_get_port_state_str(attr_array[i].link_state));
- printf("\nEnter choice (1-%u): ", i);
- fflush(stdout);
- if (scanf("%u", &choice)) {
- if (choice > num_ports || choice < 1) {
- printf("\nError: Lame choice!\n");
- fflush(stdin);
- } else {
- choice--;
- done_flag = TRUE;
- }
- } else {
- /* get rid of the junk in the selection line */
- scanf("%s", junk);
- printf("\nError: Lame choice!\n");
- fflush(stdin);
- }
- }
- printf("Choice guid=0x%" PRIx64 "\n",
- cl_ntoh64(attr_array[choice].port_guid));
- return (attr_array[choice].port_guid);
-}
-
-/**********************************************************************
- **********************************************************************/
-
-static int daemonize(osm_opensm_t * osm)
-{
- pid_t pid;
- int fd;
-
- fd = open("/dev/null", O_WRONLY);
- if (fd < 0) {
- perror("open");
- return -1;
- }
-
- if ((pid = fork()) < 0) {
- perror("fork");
- exit(-1);
- } else if (pid > 0)
- exit(0);
-
- setsid();
-
- if ((pid = fork()) < 0) {
- perror("fork");
- exit(-1);
- } else if (pid > 0)
- exit(0);
-
- close(0);
- close(1);
- close(2);
-
- dup2(fd, 0);
- dup2(fd, 1);
- dup2(fd, 2);
-
- return 0;
-}
-
-/**********************************************************************
- **********************************************************************/
-int osm_manager_loop(osm_subn_opt_t * p_opt, osm_opensm_t * p_osm)
-{
- int console_init_flag = 0;
-
- if (is_console_enabled(p_opt)) {
- if (!osm_console_init(p_opt, &p_osm->console, &p_osm->log))
- console_init_flag = 1;
- }
-
- /*
- Sit here forever - dwell or do console i/o & cmds
- */
- while (!osm_exit_flag) {
- if (console_init_flag)
- osm_console(p_osm);
- else
- cl_thread_suspend(10000);
-
- if (osm_usr1_flag) {
- osm_usr1_flag = 0;
- osm_log_reopen_file(&(p_osm->log));
- }
- if (osm_hup_flag) {
- osm_hup_flag = 0;
- /* a HUP signal should only start a new heavy sweep */
- p_osm->subn.force_heavy_sweep = TRUE;
- osm_opensm_sweep(p_osm);
- }
- }
- if (is_console_enabled(p_opt))
- osm_console_exit(&p_osm->console, &p_osm->log);
- return 0;
-}
-
-/**********************************************************************
- **********************************************************************/
-int main(int argc, char *argv[])
-{
- osm_opensm_t osm;
- osm_subn_opt_t opt;
- ib_net64_t sm_key = 0;
- ib_api_status_t status;
- uint32_t temp, dbg_lvl;
- boolean_t run_once_flag = FALSE;
- int32_t vendor_debug = 0;
- uint32_t next_option;
- char *conf_template = NULL;
- uint32_t val;
- unsigned config_file_done = 0;
- const char *const short_option =
- "F:c:i:f:ed:D:g:l:L:s:t:a:u:m:X:R:zM:U:S:P:Y:ANBIQvVhoryxp:n:q:k:C:";
-
- /*
- In the array below, the 2nd parameter specifies the number
- of arguments as follows:
- 0: no arguments
- 1: argument
- 2: optional
- */
- const struct option long_option[] = {
- {"version", 0, NULL, 12},
- {"config", 1, NULL, 'F'},
- {"create-config", 1, NULL, 'c'},
- {"debug", 1, NULL, 'd'},
- {"guid", 1, NULL, 'g'},
- {"ignore_guids", 1, NULL, 'i'},
- {"lmc", 1, NULL, 'l'},
- {"sweep", 1, NULL, 's'},
- {"timeout", 1, NULL, 't'},
- {"verbose", 0, NULL, 'v'},
- {"D", 1, NULL, 'D'},
- {"log_file", 1, NULL, 'f'},
- {"log_limit", 1, NULL, 'L'},
- {"erase_log_file", 0, NULL, 'e'},
- {"Pconfig", 1, NULL, 'P'},
- {"no_part_enforce", 0, NULL, 'N'},
- {"qos", 0, NULL, 'Q'},
- {"qos_policy_file", 1, NULL, 'Y'},
- {"maxsmps", 1, NULL, 'n'},
- {"console", 1, NULL, 'q'},
- {"V", 0, NULL, 'V'},
- {"help", 0, NULL, 'h'},
- {"once", 0, NULL, 'o'},
- {"reassign_lids", 0, NULL, 'r'},
- {"priority", 1, NULL, 'p'},
- {"smkey", 1, NULL, 'k'},
- {"routing_engine", 1, NULL, 'R'},
- {"ucast_cache", 0, NULL, 'A'},
- {"connect_roots", 0, NULL, 'z'},
- {"lid_matrix_file", 1, NULL, 'M'},
- {"lfts_file", 1, NULL, 'U'},
- {"sadb_file", 1, NULL, 'S'},
- {"root_guid_file", 1, NULL, 'a'},
- {"cn_guid_file", 1, NULL, 'u'},
- {"ids_guid_file", 1, NULL, 'm'},
- {"guid_routing_order_file", 1, NULL, 'X'},
- {"stay_on_fatal", 0, NULL, 'y'},
- {"honor_guid2lid", 0, NULL, 'x'},
-#ifdef ENABLE_OSM_CONSOLE_SOCKET
- {"console-port", 1, NULL, 'C'},
-#endif
- {"daemon", 0, NULL, 'B'},
- {"inactive", 0, NULL, 'I'},
-#ifdef ENABLE_OSM_PERF_MGR
- {"perfmgr", 0, NULL, 1},
- {"perfmgr_sweep_time_s", 1, NULL, 2},
-#endif
- {"prefix_routes_file", 1, NULL, 3},
- {"consolidate_ipv6_snm_req", 0, NULL, 4},
- {NULL, 0, NULL, 0} /* Required at the end of the array */
- };
-
- /* Make sure that the opensm and complib were compiled using
- same modes (debug/free) */
- if (osm_is_debug() != cl_is_debug()) {
- fprintf(stderr,
- "ERROR: OpenSM and Complib were compiled using different modes\n");
- fprintf(stderr, "ERROR: OpenSM debug:%d Complib debug:%d \n",
- osm_is_debug(), cl_is_debug());
- exit(1);
- }
-#if defined (_DEBUG_) && defined (OSM_VENDOR_INTF_OPENIB)
- enable_stack_dump(1);
-#endif
-
- printf("-------------------------------------------------\n");
- printf("%s\n", OSM_VERSION);
-
- osm_subn_set_default_opt(&opt);
-
- if (osm_subn_parse_conf_file(OSM_DEFAULT_CONFIG_FILE, &opt) < 0)
- printf("\nosm_subn_parse_conf_file failed!\n");
-
- printf("Command Line Arguments:\n");
- do {
- next_option = getopt_long_only(argc, argv, short_option,
- long_option, NULL);
- switch (next_option) {
- case 12: /* --version - already printed above */
- exit(0);
- break;
- case 'F':
- if (config_file_done)
- break;
- printf("Reloading config from `%s`:\n", optarg);
- if (osm_subn_parse_conf_file(optarg, &opt)) {
- printf("cannot parse config file.\n");
- exit(1);
- }
- printf("Rescaning command line:\n");
- config_file_done = 1;
- optind = 0;
- break;
- case 'c':
- conf_template = optarg;
- printf(" Creating config file template \'%s\'.\n",
- conf_template);
- break;
- case 'o':
- /*
- Run once option.
- */
- run_once_flag = TRUE;
- printf(" Run Once\n");
- break;
-
- case 'r':
- /*
- Reassign LIDs subnet option.
- */
- opt.reassign_lids = TRUE;
- printf(" Reassign LIDs\n");
- break;
-
- case 'i':
- /*
- Specifies ignore guids file.
- */
- opt.port_prof_ignore_file = optarg;
- printf(" Ignore Guids File = %s\n",
- opt.port_prof_ignore_file);
- break;
-
- case 'g':
- /*
- Specifies port guid with which to bind.
- */
- opt.guid = cl_hton64(strtoull(optarg, NULL, 16));
- if (!opt.guid)
- /* If guid is 0 - need to display the
- * guid list */
- opt.guid = INVALID_GUID;
- else
- printf(" Guid <0x%" PRIx64 ">\n",
- cl_hton64(opt.guid));
- break;
-
- case 's':
- val = strtol(optarg, NULL, 0);
- /* Check that the number is not too large */
- if (((uint32_t) (val * 1000000)) / 1000000 != val)
- fprintf(stderr,
- "ERROR: sweep interval given is too large. Ignoring it.\n");
- else {
- opt.sweep_interval = val;
- printf(" sweep interval = %d\n",
- opt.sweep_interval);
- }
- break;
-
- case 't':
- opt.transaction_timeout = strtol(optarg, NULL, 0);
- printf(" Transaction timeout = %d\n",
- opt.transaction_timeout);
- break;
-
- case 'n':
- opt.max_wire_smps = strtol(optarg, NULL, 0);
- if (opt.max_wire_smps <= 0)
- opt.max_wire_smps = 0x7FFFFFFF;
- printf(" Max wire smp's = %d\n", opt.max_wire_smps);
- break;
-
- case 'q':
- /*
- * OpenSM interactive console
- */
- if (strcmp(optarg, OSM_DISABLE_CONSOLE) == 0
- || strcmp(optarg, OSM_LOCAL_CONSOLE) == 0
-#ifdef ENABLE_OSM_CONSOLE_SOCKET
- || strcmp(optarg, OSM_REMOTE_CONSOLE) == 0
- || strcmp(optarg, OSM_LOOPBACK_CONSOLE) == 0
-#endif
- )
- opt.console = optarg;
- else
- printf("-console %s option not understood\n",
- optarg);
- break;
-
-#ifdef ENABLE_OSM_CONSOLE_SOCKET
- case 'C':
- opt.console_port = strtol(optarg, NULL, 0);
- break;
-#endif
-
- case 'd':
- dbg_lvl = strtol(optarg, NULL, 0);
- printf(" d level = 0x%x\n", dbg_lvl);
- if (dbg_lvl == 0) {
- printf(" Debug mode: Ignore Other SMs\n");
- opt.ignore_other_sm = TRUE;
- } else if (dbg_lvl == 1) {
- printf(" Debug mode: Forcing Single Thread\n");
- opt.single_thread = TRUE;
- } else if (dbg_lvl == 2) {
- printf(" Debug mode: Force Log Flush\n");
- opt.force_log_flush = TRUE;
- } else if (dbg_lvl == 3) {
- printf
- (" Debug mode: Disable multicast support\n");
- opt.disable_multicast = TRUE;
- }
- /*
- * NOTE: Debug level 4 used to be used for memory
- * tracking but this is now deprecated
- */
- else if (dbg_lvl == 5)
- vendor_debug++;
- else
- printf(" OpenSM: Unknown debug option %d"
- " ignored\n", dbg_lvl);
- break;
-
- case 'l':
- temp = strtol(optarg, NULL, 0);
- if (temp > 7) {
- fprintf(stderr,
- "ERROR: LMC must be 7 or less.\n");
- return (-1);
- }
- opt.lmc = (uint8_t) temp;
- printf(" LMC = %d\n", temp);
- break;
-
- case 'D':
- opt.log_flags = strtol(optarg, NULL, 0);
- printf(" verbose option -D = 0x%x\n", opt.log_flags);
- break;
-
- case 'f':
- opt.log_file = optarg;
- break;
-
- case 'L':
- opt.log_max_size =
- strtoul(optarg, NULL, 0) * (1024 * 1024);
- printf(" Log file max size is %lu bytes\n",
- opt.log_max_size);
- break;
-
- case 'e':
- opt.accum_log_file = FALSE;
- printf(" Creating new log file\n");
- break;
-
- case 'P':
- opt.partition_config_file = optarg;
- break;
-
- case 'N':
- opt.no_partition_enforcement = TRUE;
- break;
-
- case 'Q':
- opt.qos = TRUE;
- break;
-
- case 'Y':
- opt.qos_policy_file = optarg;
- printf(" QoS policy file \'%s\'\n", optarg);
- break;
-
- case 'y':
- opt.exit_on_fatal = FALSE;
- printf(" Staying on fatal initialization errors\n");
- break;
-
- case 'v':
- opt.log_flags = (opt.log_flags << 1) | 1;
- printf(" Verbose option -v (log flags = 0x%X)\n",
- opt.log_flags);
- break;
-
- case 'V':
- opt.log_flags = 0xFF;
- opt.force_log_flush = TRUE;
- printf(" Big V selected\n");
- break;
-
- case 'p':
- temp = strtol(optarg, NULL, 0);
- if (0 > temp || 15 < temp) {
- fprintf(stderr,
- "ERROR: priority must be between 0 and 15\n");
- return (-1);
- }
- opt.sm_priority = (uint8_t) temp;
- printf(" Priority = %d\n", temp);
- break;
-
- case 'k':
- sm_key = cl_hton64(strtoull(optarg, NULL, 16));
- printf(" SM Key <0x%" PRIx64 ">\n", cl_hton64(sm_key));
- opt.sm_key = sm_key;
- break;
-
- case 'R':
- opt.routing_engine_names = optarg;
- printf(" Activate \'%s\' routing engine(s)\n", optarg);
- break;
-
- case 'z':
- opt.connect_roots = TRUE;
- printf(" Connect roots option is on\n");
- break;
-
- case 'A':
- opt.use_ucast_cache = TRUE;
- printf(" Unicast routing cache option is on\n");
- break;
-
- case 'M':
- opt.lid_matrix_dump_file = optarg;
- printf(" Lid matrix dump file is \'%s\'\n", optarg);
- break;
-
- case 'U':
- opt.lfts_file = optarg;
- printf(" LFTs file is \'%s\'\n", optarg);
- break;
-
- case 'S':
- opt.sa_db_file = optarg;
- printf(" SA DB file is \'%s\'\n", optarg);
- break;
-
- case 'a':
- /*
- Specifies root guids file
- */
- opt.root_guid_file = optarg;
- printf(" Root Guid File: %s\n", opt.root_guid_file);
- break;
-
- case 'u':
- /*
- Specifies compute node guids file
- */
- opt.cn_guid_file = optarg;
- printf(" Compute Node Guid File: %s\n",
- opt.cn_guid_file);
- break;
-
- case 'm':
- /* Specifies ids guid file */
- opt.ids_guid_file = optarg;
- printf(" IDs Guid File: %s\n", opt.ids_guid_file);
- break;
-
- case 'X':
- /* Specifies guid routing order file */
- opt.guid_routing_order_file = optarg;
- printf(" GUID Routing Order File: %s\n", opt.guid_routing_order_file);
- break;
-
- case 'x':
- opt.honor_guid2lid_file = TRUE;
- printf(" Honor guid2lid file, if possible\n");
- break;
-
- case 'B':
- opt.daemon = TRUE;
- printf(" Daemon mode\n");
- break;
-
- case 'I':
- opt.sm_inactive = TRUE;
- printf(" SM started in inactive state\n");
- break;
-
-#ifdef ENABLE_OSM_PERF_MGR
- case 1:
- opt.perfmgr = TRUE;
- break;
- case 2:
- opt.perfmgr_sweep_time_s = atoi(optarg);
- break;
-#endif /* ENABLE_OSM_PERF_MGR */
-
- case 3:
- opt.prefix_routes_file = optarg;
- break;
- case 4:
- opt.consolidate_ipv6_snm_req = TRUE;
- break;
- case 'h':
- case '?':
- case ':':
- show_usage();
- break;
-
- case -1:
- break; /* done with option */
- default: /* something wrong */
- abort();
- }
- }
- while (next_option != -1);
-
- if (opt.log_file != NULL)
- printf(" Log File: %s\n", opt.log_file);
- /* Done with options description */
- printf("-------------------------------------------------\n");
-
- if (conf_template) {
- status = osm_subn_write_conf_file(conf_template, &opt);
- if (status)
- printf("\nosm_subn_write_conf_file failed!\n");
- exit(status);
- }
-
- osm_subn_verify_config(&opt);
-
- if (vendor_debug)
- osm_vendor_set_debug(osm.p_vendor, vendor_debug);
-
- block_signals();
-
- if (opt.daemon)
- daemonize(&osm);
-
- complib_init();
-
- status = osm_opensm_init(&osm, &opt);
- if (status != IB_SUCCESS) {
- const char *err_str = ib_get_err_str(status);
- if (err_str == NULL)
- err_str = "Unknown Error Type";
- printf("\nError from osm_opensm_init: %s.\n", err_str);
- /* We will just exit, and not go to Exit, since we don't
- want the destroy to be called. */
- complib_exit();
- return (status);
- }
-
- /*
- If the user didn't specify a GUID on the command line,
- then get a port GUID value with which to bind.
- */
- if (opt.guid == 0 || cl_hton64(opt.guid) == CL_HTON64(INVALID_GUID))
- opt.guid = get_port_guid(&osm, opt.guid);
-
- status = osm_opensm_bind(&osm, opt.guid);
- if (status != IB_SUCCESS) {
- printf("\nError from osm_opensm_bind (0x%X)\n", status);
- printf
- ("Perhaps another instance of OpenSM is already running\n");
- goto Exit;
- }
-
- setup_signals();
-
- osm_opensm_sweep(&osm);
-
- if (run_once_flag == TRUE) {
- while (!osm_exit_flag) {
- status =
- osm_opensm_wait_for_subnet_up(&osm,
- osm.subn.opt.
- sweep_interval *
- 1000000, TRUE);
- if (!status)
- osm_exit_flag = 1;
- }
- } else {
- /*
- * Sit here until signaled to exit
- */
- osm_manager_loop(&opt, &osm);
- }
-
- if (osm.mad_pool.mads_out) {
- fprintf(stdout,
- "There are still %u MADs out. Forcing the exit of the OpenSM application...\n",
- osm.mad_pool.mads_out);
-#ifdef HAVE_LIBPTHREAD
- pthread_cond_signal(&osm.stats.cond);
-#else
- cl_event_signal(&osm.stats.event);
-#endif
- }
-
-Exit:
- osm_opensm_destroy(&osm);
- complib_exit();
-
- exit(0);
-}
diff --git a/contrib/ofed/management/opensm/opensm/osm_check b/contrib/ofed/management/opensm/opensm/osm_check
deleted file mode 100755
index 3f30c3c..0000000
--- a/contrib/ofed/management/opensm/opensm/osm_check
+++ /dev/null
@@ -1,282 +0,0 @@
-#!/usr/bin/perl -W
-#!/usr/bin/perl -W
-#
-#
-# Copyright (c) 2004, 2005 Voltaire, Inc. All rights reserved.
-# Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved.
-# Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
-#
-# This software is available to you under a choice of one of two
-# licenses. You may choose to be licensed under the terms of the GNU
-# General Public License (GPL) Version 2, available from the file
-# COPYING in the main directory of this source tree, or the
-# OpenIB.org BSD license below:
-#
-# Redistribution and use in source and binary forms, with or
-# without modification, are permitted provided that the following
-# conditions are met:
-#
-# - Redistributions of source code must retain the above
-# copyright notice, this list of conditions and the following
-# disclaimer.
-#
-# - Redistributions in binary form must reproduce the above
-# copyright notice, this list of conditions and the following
-# disclaimer in the documentation and/or other materials
-# provided with the distribution.
-#
-# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
-# BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
-# ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
-# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-# SOFTWARE.
-#
-#
-#
-# Abstract:
-# Perl script for simple source code error checking.
-#
-# Environment:
-# Linux User Mode
-#
-# $Revision: 1.4 $
-#
-#
-#
-# DESCRIPTION:
-#
-# This script performs some simple conformance checks on the
-# OpenSM source code. It does NOT attempt to act like a full
-# blown 'C' language parser, so it can be fooled. Something
-# is better than nothing. Running the 'osm_indent' script before
-# running this script will increase your chances of catching
-# problems.
-#
-#
-# The following checks are performed:
-# 1) Verify that the function name provided in a log statement
-# matches the name of the current function.
-#
-# 2) Verify that log statements are in the form that this script
-# can readily parse. Improvements to the regular expressions
-# might make this unnecessary.
-#
-# 3) Verify that lower two digits of the error codes used in log
-# statements are unique within that file.
-#
-# 4) Verify that upper two digits of the error codes used in log
-# statements are not used by any other module.
-#
-# USAGE:
-#
-# In the OpenSM source directory, type:
-# osm_check.pl *.c
-#
-
-# Do necessary upfront initialization
-$verbose = 0;
-$in_c_comment = 0;
-
-if( !exists $ARGV[0] )
-{
- print "ERROR: You must specify the files on which to operate, such as '*.c'\n";
- osm_check_usage();
- exit;
-}
-
-# loop through all the command line options
-do
-{
- $doing_params = 0;
-
- # First, look for command line options.
- if( $ARGV[0] =~ /-[v|V]/ )
- {
- $verbose += 1;
- shift;
- print "Verbose mode on, level = $verbose.\n";
- $doing_params = 1;
- }
-
- if( !exists $ARGV[0] )
- {
- print "ERROR: You must specify the files on which to operate, such as '*.c'\n";
- osm_check_usage();
- exit;
- }
-}while( $doing_params == 1 );
-
-LINE: while( <> )
-{
- # Skip C single line C style comments
- # This line must come before the multi-line C comment check!
- if( /\/\*.*\*\// )
- {
- $in_c_comment = 0;
- next LINE;
- }
-
- # skip multi-line C style comments
- if( /\/\*/ )
- {
- $in_c_comment = 1;
- next LINE;
- }
-
- # end skipping of multi-line C style comments
- if( /\*\// )
- {
- $in_c_comment = 0;
- next LINE;
- }
-
- # We're still in a C comment, so ignore input
- if( $in_c_comment == 1 )
- {
- next LINE;
- }
-
-
- # skip C++ style comment lines
- if( /^\s*\/\// )
- {
- next LINE;
- }
-
- # check for bad PRIx64 usage
- # It's a common mistake to forget the % before the PRIx64
- if( /[^%]\"\s*PRIx64/ )
- {
- print "No % sign before PRx64!!: $ARGV $.\n";
- }
-
- # This simple script doesn't handle checking PRIx64 usage
- # when PRIx64 starts the line. Just give a warning.
- if( /^\s*PRIx64/ )
- {
- print "Warning: PRIx64 at start of line. $ARGV $.\n";
- }
-
- # Attempt to locate function names.
- # Function names must start on the beginning of the line.
- if( /^(\w+)\s*\(/ )
- {
- $current_func = $1;
- if( $verbose == 1 )
- {
- print "Processing $ARGV: $current_func\n";
- }
- }
-
- # Attempt to find OSM_LOG_ENTER entries.
- # When found, verify that the function name provided matches
- # the actual function.
- if( /OSM_LOG_ENTER\s*\(\s*([\-\.\>\w]+)\s*,\s*(\w+)\s*\)/ )
- {
- $log_func = $2;
- if( $current_func ne $log_func )
- {
- printf "MISMATCH!! $ARGV $.: $current_func != $log_func\n";
- }
- }
-
- # Check for non-conforming log statements.
- # Log statements must not start the log string on the same line
- # as the osm_log function itself.
- # Watch out for the #include "osm_log.h" statement as a false positive.
- if( /osm_log\s*\(.*\"/ )
- {
- print "NON-CONFORMING LOG STATEMENT!! $ARGV $.\n";
- }
-
- # Attempt to find osm_log entries.
- if( /^\s*\"(\w+):/ )
- {
- $log_func = $1;
- if( $current_func ne $log_func )
- {
- print "MISMATCHED LOG FUNCTION!! $ARGV $.: $current_func != $log_func\n";
- }
- }
-
- # Error logging must look like 'ERR 1234:'
- # The upper two digits are error range assigned to that module.
- # The lower two digits are the error code itself.
- # Error codes are in hexadecimal.
- if( /ERR(\s+)([0-9a-fA-F]{2})([0-9a-fA-F]{2})(..)/ )
- {
- # Check if we already established the error prefix for this module
- $err_prefix = $module_err_prefixes{$ARGV};
- if( $err_prefix )
- {
- if( $err_prefix ne $2 )
- {
- print "BAD ERR RANGE IN LOG ENTRY!! $ARGV $.: $current_func\n";
- print "\tExpected $err_prefix but found $2\n";
- }
- }
- else
- {
- # Create a new prefix for this module.
- $module_err_prefixes{$ARGV} = $2;
- }
-
- $err_base = $module_err_bases{$3};
- if( $err_base )
- {
- print "DUPLICATE ERR NUMBER IN LOG ENTRY!! $ARGV $.: $current_func: $3\n";
- print "\tPrevious use on line $err_base.\n";
- }
- else
- {
- # Add this error code to the list used by this module
- # The data stored in the line number on which it is used.
- $module_err_bases{$3} = $.;
- if( $verbose > 1 )
- {
- print "Adding new error: $1$2 in $ARGV.\n";
- }
- }
-
- if( $4 ne ": " )
- {
- print "MALFORMED LOG STATEMENT!! NEEDS ': ' $ARGV $.\n";
- }
-
- if( $1 ne " " )
- {
- print "USE ONLY 1 SPACE AFTER ERR!! $ARGV $.\n";
- }
- }
-
- # verify expected use of sizeof() with pointers
- if( /sizeof\s*\(\s*[h|p]_/ )
- {
- print "SUSPICIOUS USE OF SIZEOF(), DO YOU NEED AN '*' $ARGV $.\n";
- }
-
-
-}
-continue
-{
- # reset the module base error index when we finished out
- # each source file.
- if( eof )
- {
- # reset the base error value, since each module can
- # repeat this range.
- %module_err_bases = ();
- # closing the file here resets the line number with each new file
- close ARGV;
- }
-}
-
-sub osm_check_usage
-{
- print "Usage:\n";
- print "osm_check.pl [-v|V] <file list>\n";
- print "[-v|V] - enable verbose mode.\n\n";
-}
diff --git a/contrib/ofed/management/opensm/opensm/osm_check_n_fix b/contrib/ofed/management/opensm/opensm/osm_check_n_fix
deleted file mode 100755
index 3a87cfd..0000000
--- a/contrib/ofed/management/opensm/opensm/osm_check_n_fix
+++ /dev/null
@@ -1,517 +0,0 @@
-eval '(exit $?0)' &&
- eval 'exec perl -S $0 ${1+"$@"}' &&
- eval 'exec perl -S $0 $argv:q'
- if 0;
-
-#!/usr/bin/perl -W
-#
-# Copyright (c) 2004, 2005 Voltaire, Inc. All rights reserved.
-# Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved.
-# Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
-#
-# This software is available to you under a choice of one of two
-# licenses. You may choose to be licensed under the terms of the GNU
-# General Public License (GPL) Version 2, available from the file
-# COPYING in the main directory of this source tree, or the
-# OpenIB.org BSD license below:
-#
-# Redistribution and use in source and binary forms, with or
-# without modification, are permitted provided that the following
-# conditions are met:
-#
-# - Redistributions of source code must retain the above
-# copyright notice, this list of conditions and the following
-# disclaimer.
-#
-# - Redistributions in binary form must reproduce the above
-# copyright notice, this list of conditions and the following
-# disclaimer in the documentation and/or other materials
-# provided with the distribution.
-#
-# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
-# BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
-# ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
-# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-# SOFTWARE.
-#
-#########################################################################
-#
-# Abstract:
-# Perl script for simple source code error checking and fixing
-#
-# Environment:
-# Linux User Mode
-#
-# Author:
-# Eitan Zahavi, Mellanox Technologies LTD Yokneam Israel.
-#
-# $Revision: 1.4 $
-#
-#
-#
-# DESCRIPTION:
-#
-# This script performs some simple conformance checks on the
-# OpenSM source code. It does NOT attempt to act like a full
-# blown 'C' language parser, so it can be fooled. Something
-# is better than nothing.
-#
-# The script starts by running the 'osm_indent' script on teh given files.
-#
-# We use an extra file for tracking error codes used by each file.
-# The name is osm_errors_codes.
-#
-# The following checks are performed:
-# 1) Verify that the function name provided in a log statement
-# matches the name of the current function.
-#
-# 2) Verify that log statements are in the form that this script
-# can readily parse. Improvements to the regular expressions
-# might make this unnecessary.
-#
-# 3) Verify that lower two digits of the error codes used in log
-# statements are unique within that file.
-#
-# 4) Verify that upper two digits of the error codes used in log
-# statements are not used by any other module.
-#
-# 5) Verify the lines do not have extra spaces.
-#
-# USAGE:
-#
-# In the OpenSM source directory, type:
-# osm_check_n_fix -f *.c
-#
-#########################################################################
-
-# Do necessary upfront initialization
-$verbose = 0;
-$in_c_comment = 0;
-$fix_mode = 0;
-$confirm_mode = 0;
-$re_assign_err_prefix = 0;
-
-if( !scalar(@ARGV) )
-{
- print "ERROR: You must specify the files on which to operate, such as '*.c'\n";
- osm_check_usage();
- exit;
-}
-
-# loop through all the command line options
-do
-{
- $doing_params = 0;
-
- # First, look for command line options.
- if( $ARGV[0] =~ /-[v|V]/ )
- {
- $verbose += 1;
- shift;
- print "Verbose mode on, level = $verbose.\n";
- $doing_params = 1;
- }
-
- if( $ARGV[0] =~ /(-f|--fix)/ )
- {
- $fix_mode += 1;
- shift;
- print "Fix mode on.\n";
- $doing_params = 1;
- }
-
- if( $ARGV[0] =~ /(-c|--confirm)/ )
- {
- $confirm_mode += 1;
- shift;
- print "Confirm mode on.\n";
- $doing_params = 1;
- }
-
- if( $ARGV[0] =~ /(-r|--re-assign-mod-err-prefix)/ )
- {
- $re_assign_err_prefix += 1;
- shift;
- print "Allow Re-Assignment of Module Err Prefixes.\n";
- $doing_params = 1;
- }
-
- if( !scalar(@ARGV))
- {
- print "ERROR: You must specify the files on which to operate, such as '*.c'\n";
- osm_check_usage();
- exit;
- }
-} while( $doing_params == 1 );
-
-# parse the osm_error_codes file and define:
-# module_by_prefix
-# module_err_prefixes
-# module_last_err_used
-if (open(ERRS, "<osm_error_codes")) {
- @ERR_DEFS = <ERRS>;
- close(ERRS);
- foreach $errDef (@ERR_DEFS) {
- # the format should be <file name> <err prefix> <last err>
- if ($errDef =~ m/^(\S+)\s+(\S+)\s+([0-9]+)$/) {
- ($file_name,$mod_prefix,$last_err) = ($1,$2,$3);
- if (defined($module_by_prefix{$mod_prefix})) {
- print "ERROR: Double module prefix:$mod_prefix on:$module_by_prefix($mod_prefix) and $file_name\n";
- exit 3;
- }
- $module_by_prefix{$mod_prefix} = $file_name;
- $module_err_prefixes{$file_name} = $mod_prefix;
- $module_last_err_used{$file_name} = $last_err;
- } else {
- print "ERROR: Fail to parse sm_error_codes: $errDef\n";
- exit 3;
- }
- }
-}
-
-# do a file by file read into memory so we can tweek it:
-foreach $file_name (@ARGV) {
- print "- $file_name ----------------------------------------------------\n";
- # first step is to run indent
- $res=`osm_indent $file_name`;
-
- open(INFILE, "<$file_name") || die("Fail to open $file_name");
- @LINES = <INFILE>;
- close(INFILE);
- $any_fix = 0;
- $needed_fixing = 0;
- $need_indentation = 0;
-
- LINE: for ($line_num = 0; $line_num <scalar(@LINES); $line_num++) {
- $line = $LINES[$line_num];
- $_ = $line;
-
- # Skip C single line C style comments
- # This line must come before the multi-line C comment check!
- if( /\/\*.*\*\// )
- {
- $in_c_comment = 0;
- next LINE;
- }
-
- # skip multi-line C style comments
- if( /\/\*/ )
- {
- $in_c_comment = 1;
- next LINE;
- }
-
- # end skipping of multi-line C style comments
- if( /\*\// )
- {
- $in_c_comment = 0;
- next LINE;
- }
-
- # We're still in a C comment, so ignore input
- if( $in_c_comment == 1 )
- {
- next LINE;
- }
-
-
- # Error on C++ style comment lines
- if( /\/\// )
- {
- print "C++ style comment on $file_name $line_num\n";
- $needed_fixing++;
- if ($fix_mode) {
- $line =~ s=\/\/(.*)$=/* \1 */=;
- if (confirm_change($line, $LINES[$line_num])) {
- $LINES[$line_num] = $line;
- $any_fix++;
- }
- $any_fix++;
- }
- }
-
- # check for lines with trailing spaces:
- if (/[ \t]+$/) {
- $needed_fixing++;
- if ($fix_mode) {
- $line =~ s/\s+$/\n/;
- if (confirm_change($line, $LINES[$line_num])) {
- $LINES[$line_num] = $line;
- $any_fix++;
- }
- $any_fix++;
- }
- }
-
- # check for bad PRIx64 usage
- # It's a common mistake to forget the % before the PRIx64
- if (/[^%0-9][0-9]*\"\s*PRIx64/ ) {
- $needed_fixing++;
- print "No % sign before PRx64!!: $file_name $line_num\n";
- if ($fix_mode) {
- $line =~ s/([0-9]*)\"\s*PRIx64/%$1\" PRIx64/;
- if (confirm_change($line, $LINES[$line_num])) {
- $LINES[$line_num] = $line;
- $any_fix++;
- }
- }
- }
-
- # This simple script doesn't handle checking PRIx64 usage
- # when PRIx64 starts the line. Just give a warning.
- if( /^\s*PRIx64/ )
- {
- $needed_fixing++;
- print "Warning: PRIx64 at start of line. $file_name $line_num\n";
-# if ($fix_mode) {
-# print "Fatal: can not auto fix\n";
-# exit 1;
-# }
- }
-
- # Attempt to locate function names.
- # Function names must start on the beginning of the line.
- if( /^(\w+)\s*\(/ )
- {
- $current_func = $1;
- if( $verbose == 1 )
- {
- print "Processing $file_name: $current_func\n";
- }
- }
-
- # Attempt to find OSM_LOG_ENTER entries.
- # When found, verify that the function name provided matches
- # the actual function.
- if( /OSM_LOG_ENTER\s*\(\s*([\-\.\>\w]+)\s*,\s*(\w+)\s*\)/ ) {
- $log_func = $2;
- if( $current_func ne $log_func ) {
- printf "MISMATCH!! $file_name $line_num: $current_func != $log_func\n";
- $needed_fixing++;
- if ($fix_mode) {
- $line =~
- s/OSM_LOG_ENTER\s*\(\s*([\-\.\>\w]+)\s*,\s*(\w+)\s*\)/OSM_LOG_ENTER( $1, $current_func )/;
- if (confirm_change($line, $LINES[$line_num])) {
- $LINES[$line_num] = $line;
- $any_fix++;
- }
- }
- }
- }
-
- # Check for non-conforming log statements.
- # Log statements must not start the log string on the same line
- # as the osm_log function itself.
- # Watch out for the #include "osm_log.h" statement as a false positive.
- if (/osm_log\s*\(.*OSM_.*\"/ ) {
- if (/Format Waved/) {
- print "Skipping log format waiver at $file_name $line_num\n";
- } else {
- print "NON-CONFORMING LOG STATEMENT!! $file_name $line_num\n";
- $needed_fixing++;
- if ($fix_mode) {
- print "Fatal: can not auto fix\n";
- exit 1;
- }
- }
- }
-
- # Attempt to find osm_log entries.
- if( /^\s*\"(\w+):/ )
- {
- $log_func = $1;
- if( $current_func ne $log_func )
- {
- print "MISMATCHED LOG FUNCTION!! $file_name $line_num: $current_func != $log_func\n";
- $needed_fixing++;
- if ($fix_mode) {
- $line =~
- s/^(\s*)\"(\w+):/$1\"$current_func:/;
- if (confirm_change($line, $LINES[$line_num])) {
- $LINES[$line_num] = $line;
- $any_fix++;
- }
- }
- }
- }
-
- # Error logging must look like 'ERR 1234:'
- # The upper two digits are error range assigned to that module.
- # The lower two digits are the error code itself.
- # Error codes are in hexadecimal.
- if( /ERR(\s+)([0-9a-fA-F]{2})([0-9a-fA-F]{2})(..)/ )
- {
- # track any error for this exp:
- $exp_err = 0;
-
- # the parsed prefix and err code:
- ($found_prefix,$found_code) = ($2,$3);
-
- # Check if we already established the error prefix for this module
- $err_prefix = $module_err_prefixes{$file_name};
-
- # err prefix is not available for this file
- if ( ! $err_prefix ) {
- # make sure no other file uses this prefix:
- if ($module_by_prefix{$found_prefix}) {
- # some other file uses that prefix:
-
- # two modes: either use a new one or abort
- if ($re_assign_err_prefix) {
- # scan the available module prefixes for an empty one:
- $found = 0;
- for ($new_prefix_idx = 1; $found == 0; $new_prefix_idx++) {
- $prefix = sprintf("%02X", $new_prefix_idx);
- if (!defined($module_by_prefix{$prefix})) {
- $module_err_prefixes{$file_name} = $prefix;
- $module_by_prefix{$prefix} = $file_name;
- $found = 1;
- }
- $exp_err = 1;
- }
- } else {
- print "Fatal: File $module_by_prefix{$2} already uses same prefix:$2 used by: $file_name (line=$line_num)\n";
- exit 1;
- }
- } else {
- # the prefix found is unused:
-
- # Create a new prefix for this module.
- $module_err_prefixes{$file_name} = $found_prefix;
- $module_by_prefix{$found_prefix} = $file_name;
- $err_prefix = $found_prefix;
- }
- } else {
- # we already have a prefix for this file
-
- if( $err_prefix ne $found_prefix )
- {
- $needed_fixing++;
- print "BAD ERR RANGE IN LOG ENTRY!! $file_name $line_num: $current_func\n";
- print "\tExpected $err_prefix but found $found_prefix\n";
- $exp_err = 1;
- }
- }
-
- # now check for code duplicates
- $err_base = $module_err_bases{$found_code};
- if( $err_base ) {
- $needed_fixing++;
- print "DUPLICATE ERR NUMBER IN LOG ENTRY!! $file_name $line_num: $current_func: $3\n";
- print "\tPrevious use on line $err_base.\n";
-
- # use the last error code for this module:
- $module_last_err_used{$file_name}++;
- $err_code = sprintf("%02X", $module_last_err_used{$file_name});
- print "\tUsing new err code:0x$err_code ($module_last_err_used{$file_name})\n";
- $module_err_bases{$err_code} = $line_num;
- $exp_err = 1;
- } else {
- # Add this error code to the list used by this module
- # The data stored in the line number on which it is used.
- $module_err_bases{$found_code} = $line_num;
- # track the last code used
- $err_code_num = eval("0x$found_code");
- if ($module_last_err_used{$file_name} < $err_code_num) {
- $module_last_err_used{$file_name} = $err_code_num;
- }
- $err_code = $found_code;
-
- if( $verbose > 1 ) {
- print "Adding new error: $err_prefix$found_code in $file_name.\n";
- }
- }
-
- if( $4 ne ": " ) {
- $needed_fixing++;
- print "MALFORMED LOG STATEMENT!! NEEDS ': ' $file_name $line_num\n";
- $exp_err = 1;
- }
-
- if( $1 ne " " )
- {
- $needed_fixing++;
- print "USE ONLY 1 SPACE AFTER ERR!! $file_name $line_num\n";
- $exp_err = 1;
- }
-
- if ($exp_err && $fix_mode) {
- $line =~
- s/ERR(\s+)([0-9a-fA-F]{2})([0-9a-fA-F]{2})([^\"]*\")/ERR ${err_prefix}$err_code: \" /;
- if (confirm_change($line, $LINES[$line_num])) {
- $LINES[$line_num] = $line;
- $any_fix++;
- }
- }
- }
-
- # verify expected use of sizeof() with pointers
- if( /sizeof\s*\(\s*[h|p]_[^-]+\)/ )
- {
- print "SUSPICIOUS USE OF SIZEOF(), DO YOU NEED AN '*' $file_name $line_num\n";
- $needed_fixing++;
- if ($fix_mode) {
- $line =~
- s/sizeof\s*\(\s*([h|p])_/sizeof \(*$1_/;
- if (confirm_change($line, $LINES[$line_num])) {
- $LINES[$line_num] = $line;
- $any_fix++;
- }
- }
- }
- }
-
- # reset the base error value, since each module can
- # repeat this range.
- %module_err_bases = ();
-
- # if any fix write out the fixed file:
- if ($any_fix) {
- open(OF,">$file_name.fix");
- print OF @LINES;
- close(OF);
- } elsif ($needed_fixing) {
- print "Found $needed_fixing Errors on file: $file_name\n";
- }
-}
-
-# write out the error codes.
-# module_by_prefix
-# module_err_prefixes
-# module_last_err_used
-open(ERRS,">osm_error_codes");
-foreach $fn (sort(keys(%module_err_prefixes))) {
- print ERRS "$fn $module_err_prefixes{$fn} $module_last_err_used{$fn}\n";
-}
-close(ERRS);
-
-sub osm_check_usage
-{
- print "Usage:\n";
- print "osm_check.pl [-v|V] [-f|--fix] [-c|--confirm] [-r|--re-assign-mod-err-prefix] <file list>\n";
- print "[-v|V] - enable verbose mode.\n";
- print "[-f|--fix] - enable auto fix mode.\n";
- print "[-c|--confirm] - enable manual confirmation mode.\n";
- print "[-r|--re-assign-mod-err-prefix] - enables re-assign error prefixes if the file does not have one.\n";
-}
-
-sub confirm_change {
- local ($line, $orig_line) = @_;
- if ($confirm_mode) {
- print "In Line:".($line_num + 1)."\n";
- print "From: ${orig_line}To: ${line}Ok [y] ?";
- $| = 1;
- $ans = <STDIN>;
- chomp $ans;
-
- if ($ans && $ans ne "y") {
- return 0;
- }
- } else {
- print "From: ${orig_line}To: ${line}";
- }
- return 1;
-}
diff --git a/contrib/ofed/management/opensm/opensm/osm_console.c b/contrib/ofed/management/opensm/opensm/osm_console.c
deleted file mode 100644
index 5c494a8..0000000
--- a/contrib/ofed/management/opensm/opensm/osm_console.c
+++ /dev/null
@@ -1,1330 +0,0 @@
-/*
- * Copyright (c) 2005-2008 Voltaire, Inc. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- */
-
-#if HAVE_CONFIG_H
-# include <config.h>
-#endif /* HAVE_CONFIG_H */
-
-#define _GNU_SOURCE /* for getline */
-#include <stdio.h>
-#include <stdlib.h>
-#include <sys/poll.h>
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <netdb.h>
-#ifdef ENABLE_OSM_CONSOLE_SOCKET
-#include <arpa/inet.h>
-#endif
-#include <unistd.h>
-#include <errno.h>
-#include <ctype.h>
-#include <sys/time.h>
-#include <opensm/osm_console.h>
-#include <complib/cl_passivelock.h>
-#include <opensm/osm_perfmgr.h>
-#include <opensm/osm_subnet.h>
-
-struct command {
- char *name;
- void (*help_function) (FILE * out, int detail);
- void (*parse_function) (char **p_last, osm_opensm_t * p_osm,
- FILE * out);
-};
-
-static struct {
- int on;
- int delay_s;
- time_t previous;
- void (*loop_function) (osm_opensm_t * p_osm, FILE * out);
-} loop_command = {
- .on = 0,
- .delay_s = 2,
- .loop_function = NULL,
-};
-
-static const struct command console_cmds[];
-
-static inline char *next_token(char **p_last)
-{
- return strtok_r(NULL, " \t\n\r", p_last);
-}
-
-static void help_command(FILE * out, int detail)
-{
- int i;
-
- fprintf(out, "Supported commands and syntax:\n");
- fprintf(out, "help [<command>]\n");
- /* skip help command */
- for (i = 1; console_cmds[i].name; i++)
- console_cmds[i].help_function(out, 0);
-}
-
-static void help_quit(FILE * out, int detail)
-{
- fprintf(out, "quit (not valid in local mode; use ctl-c)\n");
-}
-
-static void help_loglevel(FILE * out, int detail)
-{
- fprintf(out, "loglevel [<log-level>]\n");
- if (detail) {
- fprintf(out, " log-level is OR'ed from the following\n");
- fprintf(out, " OSM_LOG_NONE 0x%02X\n",
- OSM_LOG_NONE);
- fprintf(out, " OSM_LOG_ERROR 0x%02X\n",
- OSM_LOG_ERROR);
- fprintf(out, " OSM_LOG_INFO 0x%02X\n",
- OSM_LOG_INFO);
- fprintf(out, " OSM_LOG_VERBOSE 0x%02X\n",
- OSM_LOG_VERBOSE);
- fprintf(out, " OSM_LOG_DEBUG 0x%02X\n",
- OSM_LOG_DEBUG);
- fprintf(out, " OSM_LOG_FUNCS 0x%02X\n",
- OSM_LOG_FUNCS);
- fprintf(out, " OSM_LOG_FRAMES 0x%02X\n",
- OSM_LOG_FRAMES);
- fprintf(out, " OSM_LOG_ROUTING 0x%02X\n",
- OSM_LOG_ROUTING);
- fprintf(out, " OSM_LOG_SYS 0x%02X\n",
- OSM_LOG_SYS);
- fprintf(out, "\n");
- fprintf(out, " OSM_LOG_DEFAULT_LEVEL 0x%02X\n",
- OSM_LOG_DEFAULT_LEVEL);
- }
-}
-
-static void help_priority(FILE * out, int detail)
-{
- fprintf(out, "priority [<sm-priority>]\n");
-}
-
-static void help_resweep(FILE * out, int detail)
-{
- fprintf(out, "resweep [heavy|light]\n");
-}
-
-static void help_reroute(FILE * out, int detail)
-{
- fprintf(out, "reroute\n");
- if (detail) {
- fprintf(out, "reroute the fabric\n");
- }
-}
-
-static void help_status(FILE * out, int detail)
-{
- fprintf(out, "status [loop]\n");
- if (detail) {
- fprintf(out, " loop -- type \"q<ret>\" to quit\n");
- }
-}
-
-static void help_logflush(FILE * out, int detail)
-{
- fprintf(out, "logflush -- flush the opensm.log file\n");
-}
-
-static void help_querylid(FILE * out, int detail)
-{
- fprintf(out,
- "querylid lid -- print internal information about the lid specified\n");
-}
-
-static void help_portstatus(FILE * out, int detail)
-{
- fprintf(out, "portstatus [ca|switch|router]\n");
- if (detail) {
- fprintf(out, "summarize port status\n");
- fprintf(out,
- " [ca|switch|router] -- limit the results to the node type specified\n");
- }
-
-}
-
-static void help_switchbalance(FILE * out, int detail)
-{
- fprintf(out, "switchbalance [verbose] [guid]\n");
- if (detail) {
- fprintf(out, "output switch balancing information\n");
- fprintf(out,
- " [verbose] -- verbose output\n"
- " [guid] -- limit results to specified guid\n");
- }
-}
-
-static void help_lidbalance(FILE * out, int detail)
-{
- fprintf(out, "lidbalance [switchguid]\n");
- if (detail) {
- fprintf(out, "output lid balanced forwarding information\n");
- fprintf(out,
- " [switchguid] -- limit results to specified switch guid\n");
- }
-}
-
-static void help_dump_conf(FILE *out, int detail)
-{
- fprintf(out, "dump_conf\n");
- if (detail) {
- fprintf(out, "dump current opensm configuration\n");
- }
-}
-
-#ifdef ENABLE_OSM_PERF_MGR
-static void help_perfmgr(FILE * out, int detail)
-{
- fprintf(out,
- "perfmgr [enable|disable|clear_counters|dump_counters|sweep_time[seconds]]\n");
- if (detail) {
- fprintf(out,
- "perfmgr -- print the performance manager state\n");
- fprintf(out,
- " [enable|disable] -- change the perfmgr state\n");
- fprintf(out,
- " [sweep_time] -- change the perfmgr sweep time (requires [seconds] option)\n");
- fprintf(out,
- " [clear_counters] -- clear the counters stored\n");
- fprintf(out,
- " [dump_counters [mach]] -- dump the counters (optionally in [mach]ine readable format)\n");
- fprintf(out,
- " [print_counters <nodename|nodeguid>] -- print the counters for the specified node\n");
- }
-}
-#endif /* ENABLE_OSM_PERF_MGR */
-
-/* more help routines go here */
-
-static void help_parse(char **p_last, osm_opensm_t * p_osm, FILE * out)
-{
- char *p_cmd;
- int i, found = 0;
-
- p_cmd = next_token(p_last);
- if (!p_cmd)
- help_command(out, 0);
- else {
- for (i = 1; console_cmds[i].name; i++) {
- if (!strcmp(p_cmd, console_cmds[i].name)) {
- found = 1;
- console_cmds[i].help_function(out, 1);
- break;
- }
- }
- if (!found) {
- fprintf(out, "%s : Command not found\n\n", p_cmd);
- help_command(out, 0);
- }
- }
-}
-
-static void loglevel_parse(char **p_last, osm_opensm_t * p_osm, FILE * out)
-{
- char *p_cmd;
- int level;
-
- p_cmd = next_token(p_last);
- if (!p_cmd)
- fprintf(out, "Current log level is 0x%x\n",
- osm_log_get_level(&p_osm->log));
- else {
- /* Handle x, 0x, and decimal specification of log level */
- if (!strncmp(p_cmd, "x", 1)) {
- p_cmd++;
- level = strtoul(p_cmd, NULL, 16);
- } else {
- if (!strncmp(p_cmd, "0x", 2)) {
- p_cmd += 2;
- level = strtoul(p_cmd, NULL, 16);
- } else
- level = strtol(p_cmd, NULL, 10);
- }
- if ((level >= 0) && (level < 256)) {
- fprintf(out, "Setting log level to 0x%x\n", level);
- osm_log_set_level(&p_osm->log, level);
- } else
- fprintf(out, "Invalid log level 0x%x\n", level);
- }
-}
-
-static void priority_parse(char **p_last, osm_opensm_t * p_osm, FILE * out)
-{
- char *p_cmd;
- int priority;
-
- p_cmd = next_token(p_last);
- if (!p_cmd)
- fprintf(out, "Current sm-priority is %d\n",
- p_osm->subn.opt.sm_priority);
- else {
- priority = strtol(p_cmd, NULL, 0);
- if (0 > priority || 15 < priority)
- fprintf(out,
- "Invalid sm-priority %d; must be between 0 and 15\n",
- priority);
- else {
- fprintf(out, "Setting sm-priority to %d\n", priority);
- osm_set_sm_priority(&p_osm->sm, (uint8_t)priority);
- }
- }
-}
-
-static char *sm_state_str(int state)
-{
- switch (state) {
- case IB_SMINFO_STATE_DISCOVERING:
- return ("Discovering");
- case IB_SMINFO_STATE_STANDBY:
- return ("Standby");
- case IB_SMINFO_STATE_NOTACTIVE:
- return ("Not Active");
- case IB_SMINFO_STATE_MASTER:
- return ("Master");
- }
- return ("UNKNOWN");
-}
-
-static char *sa_state_str(osm_sa_state_t state)
-{
- switch (state) {
- case OSM_SA_STATE_INIT:
- return ("Init");
- case OSM_SA_STATE_READY:
- return ("Ready");
- }
- return ("UNKNOWN");
-}
-
-static void print_status(osm_opensm_t * p_osm, FILE * out)
-{
- cl_list_item_t *item;
-
- if (out) {
- cl_plock_acquire(&p_osm->lock);
- fprintf(out, " OpenSM Version : %s\n", p_osm->osm_version);
- fprintf(out, " SM State : %s\n",
- sm_state_str(p_osm->subn.sm_state));
- fprintf(out, " SA State : %s\n",
- sa_state_str(p_osm->sa.state));
- fprintf(out, " Routing Engine : %s\n",
- osm_routing_engine_type_str(p_osm->
- routing_engine_used));
-
- fprintf(out, " Loaded event plugins :");
- if (cl_qlist_head(&p_osm->plugin_list) ==
- cl_qlist_end(&p_osm->plugin_list)) {
- fprintf(out, " <none>");
- }
- for (item = cl_qlist_head(&p_osm->plugin_list);
- item != cl_qlist_end(&p_osm->plugin_list);
- item = cl_qlist_next(item))
- fprintf(out, " %s",
- ((osm_epi_plugin_t *)item)->plugin_name);
- fprintf(out, "\n");
-
-#ifdef ENABLE_OSM_PERF_MGR
- fprintf(out, "\n PerfMgr state/sweep state : %s/%s\n",
- osm_perfmgr_get_state_str(&(p_osm->perfmgr)),
- osm_perfmgr_get_sweep_state_str(&(p_osm->perfmgr)));
-#endif
- fprintf(out, "\n MAD stats\n"
- " ---------\n"
- " QP0 MADs outstanding : %d\n"
- " QP0 MADs outstanding (on wire) : %d\n"
- " QP0 MADs rcvd : %d\n"
- " QP0 MADs sent : %d\n"
- " QP0 unicasts sent : %d\n"
- " QP0 unknown MADs rcvd : %d\n"
- " SA MADs outstanding : %d\n"
- " SA MADs rcvd : %d\n"
- " SA MADs sent : %d\n"
- " SA unknown MADs rcvd : %d\n"
- " SA MADs ignored : %d\n",
- p_osm->stats.qp0_mads_outstanding,
- p_osm->stats.qp0_mads_outstanding_on_wire,
- p_osm->stats.qp0_mads_rcvd,
- p_osm->stats.qp0_mads_sent,
- p_osm->stats.qp0_unicasts_sent,
- p_osm->stats.qp0_mads_rcvd_unknown,
- p_osm->stats.sa_mads_outstanding,
- p_osm->stats.sa_mads_rcvd,
- p_osm->stats.sa_mads_sent,
- p_osm->stats.sa_mads_rcvd_unknown,
- p_osm->stats.sa_mads_ignored);
- fprintf(out, "\n Subnet flags\n"
- " ------------\n"
- " Ignore existing lfts : %d\n"
- " Subnet Init errors : %d\n"
- " In sweep hop 0 : %d\n"
- " First time master sweep : %d\n"
- " Coming out of standby : %d\n",
- p_osm->subn.ignore_existing_lfts,
- p_osm->subn.subnet_initialization_error,
- p_osm->subn.in_sweep_hop_0,
- p_osm->subn.first_time_master_sweep,
- p_osm->subn.coming_out_of_standby);
- fprintf(out, "\n");
- cl_plock_release(&p_osm->lock);
- }
-}
-
-static int loop_command_check_time(void)
-{
- time_t cur = time(NULL);
- if ((loop_command.previous + loop_command.delay_s) < cur) {
- loop_command.previous = cur;
- return (1);
- }
- return (0);
-}
-
-static void status_parse(char **p_last, osm_opensm_t * p_osm, FILE * out)
-{
- char *p_cmd;
-
- p_cmd = next_token(p_last);
- if (p_cmd) {
- if (strcmp(p_cmd, "loop") == 0) {
- fprintf(out, "Looping on status command...\n");
- fflush(out);
- loop_command.on = 1;
- loop_command.previous = time(NULL);
- loop_command.loop_function = print_status;
- } else {
- help_status(out, 1);
- return;
- }
- }
- print_status(p_osm, out);
-}
-
-static void resweep_parse(char **p_last, osm_opensm_t * p_osm, FILE * out)
-{
- char *p_cmd;
-
- p_cmd = next_token(p_last);
- if (!p_cmd ||
- (strcmp(p_cmd, "heavy") != 0 && strcmp(p_cmd, "light") != 0)) {
- fprintf(out, "Invalid resweep command\n");
- help_resweep(out, 1);
- } else {
- if (strcmp(p_cmd, "heavy") == 0)
- p_osm->subn.force_heavy_sweep = TRUE;
- osm_opensm_sweep(p_osm);
- }
-}
-
-static void reroute_parse(char **p_last, osm_opensm_t * p_osm, FILE * out)
-{
- p_osm->subn.force_reroute = TRUE;
- osm_opensm_sweep(p_osm);
-}
-
-static void logflush_parse(char **p_last, osm_opensm_t * p_osm, FILE * out)
-{
- fflush(p_osm->log.out_port);
-}
-
-static void querylid_parse(char **p_last, osm_opensm_t * p_osm, FILE * out)
-{
- int p = 0;
- uint16_t lid = 0;
- osm_port_t *p_port = NULL;
- char *p_cmd = next_token(p_last);
-
- if (!p_cmd) {
- fprintf(out, "no LID specified\n");
- help_querylid(out, 1);
- return;
- }
-
- lid = (uint16_t) strtoul(p_cmd, NULL, 0);
- cl_plock_acquire(&p_osm->lock);
- if (lid > cl_ptr_vector_get_capacity(&(p_osm->subn.port_lid_tbl)))
- goto invalid_lid;
- p_port = cl_ptr_vector_get(&(p_osm->subn.port_lid_tbl), lid);
- if (!p_port)
- goto invalid_lid;
-
- fprintf(out, "Query results for LID %u\n", lid);
- fprintf(out,
- " GUID : 0x%016" PRIx64 "\n"
- " Node Desc : %s\n"
- " Node Type : %s\n"
- " Num Ports : %d\n",
- cl_ntoh64(p_port->guid),
- p_port->p_node->print_desc,
- ib_get_node_type_str(osm_node_get_type(p_port->p_node)),
- p_port->p_node->node_info.num_ports);
-
- if (p_port->p_node->sw)
- p = 0;
- else
- p = 1;
- for ( /* see above */ ; p < p_port->p_node->physp_tbl_size; p++) {
- fprintf(out,
- " Port %d health : %s\n",
- p,
- p_port->p_node->physp_table[p].
- healthy ? "OK" : "ERROR");
- }
-
- cl_plock_release(&p_osm->lock);
- return;
-
-invalid_lid:
- cl_plock_release(&p_osm->lock);
- fprintf(out, "Invalid lid %d\n", lid);
- return;
-}
-
-/**
- * Data structures for the portstatus command
- */
-typedef struct _port_report {
- struct _port_report *next;
- uint64_t node_guid;
- uint8_t port_num;
- char print_desc[IB_NODE_DESCRIPTION_SIZE + 1];
-} port_report_t;
-
-static void
-__tag_port_report(port_report_t ** head, uint64_t node_guid,
- uint8_t port_num, char *print_desc)
-{
- port_report_t *rep = malloc(sizeof(*rep));
- if (!rep)
- return;
-
- rep->node_guid = node_guid;
- rep->port_num = port_num;
- memcpy(rep->print_desc, print_desc, IB_NODE_DESCRIPTION_SIZE + 1);
- rep->next = NULL;
- if (*head) {
- rep->next = *head;
- *head = rep;
- } else
- *head = rep;
-}
-
-static void __print_port_report(FILE * out, port_report_t * head)
-{
- port_report_t *item = head;
- while (item != NULL) {
- fprintf(out, " 0x%016" PRIx64 " %d (%s)\n",
- item->node_guid, item->port_num, item->print_desc);
- port_report_t *next = item->next;
- free(item);
- item = next;
- }
-}
-
-typedef struct {
- uint8_t node_type_lim; /* limit the results; 0 == ALL */
- uint64_t total_nodes;
- uint64_t total_ports;
- uint64_t ports_down;
- uint64_t ports_active;
- uint64_t ports_disabled;
- port_report_t *disabled_ports;
- uint64_t ports_1X;
- uint64_t ports_4X;
- uint64_t ports_8X;
- uint64_t ports_12X;
- uint64_t ports_unknown_width;
- uint64_t ports_reduced_width;
- port_report_t *reduced_width_ports;
- uint64_t ports_sdr;
- uint64_t ports_ddr;
- uint64_t ports_qdr;
- uint64_t ports_unknown_speed;
- uint64_t ports_reduced_speed;
- port_report_t *reduced_speed_ports;
-} fabric_stats_t;
-
-/**
- * iterator function to get portstatus on each node
- */
-static void __get_stats(cl_map_item_t * const p_map_item, void *context)
-{
- fabric_stats_t *fs = (fabric_stats_t *) context;
- osm_node_t *node = (osm_node_t *) p_map_item;
- uint8_t num_ports = osm_node_get_num_physp(node);
- uint8_t port = 0;
-
- /* Skip nodes we are not interested in */
- if (fs->node_type_lim != 0
- && fs->node_type_lim != node->node_info.node_type)
- return;
-
- fs->total_nodes++;
-
- for (port = 1; port < num_ports; port++) {
- osm_physp_t *phys = osm_node_get_physp_ptr(node, port);
- ib_port_info_t *pi = NULL;
- uint8_t active_speed = 0;
- uint8_t enabled_speed = 0;
- uint8_t active_width = 0;
- uint8_t enabled_width = 0;
- uint8_t port_state = 0;
- uint8_t port_phys_state = 0;
-
- if (!phys)
- continue;
-
- pi = &(phys->port_info);
- active_speed = ib_port_info_get_link_speed_active(pi);
- enabled_speed = ib_port_info_get_link_speed_enabled(pi);
- active_width = pi->link_width_active;
- enabled_width = pi->link_width_enabled;
- port_state = ib_port_info_get_port_state(pi);
- port_phys_state = ib_port_info_get_port_phys_state(pi);
-
- if ((enabled_width ^ active_width) > active_width) {
- __tag_port_report(&(fs->reduced_width_ports),
- cl_ntoh64(node->node_info.node_guid),
- port, node->print_desc);
- fs->ports_reduced_width++;
- }
-
- if ((enabled_speed ^ active_speed) > active_speed) {
- __tag_port_report(&(fs->reduced_speed_ports),
- cl_ntoh64(node->node_info.node_guid),
- port, node->print_desc);
- fs->ports_reduced_speed++;
- }
-
- switch (active_speed) {
- case IB_LINK_SPEED_ACTIVE_2_5:
- fs->ports_sdr++;
- break;
- case IB_LINK_SPEED_ACTIVE_5:
- fs->ports_ddr++;
- break;
- case IB_LINK_SPEED_ACTIVE_10:
- fs->ports_qdr++;
- break;
- default:
- fs->ports_unknown_speed++;
- break;
- }
- switch (active_width) {
- case IB_LINK_WIDTH_ACTIVE_1X:
- fs->ports_1X++;
- break;
- case IB_LINK_WIDTH_ACTIVE_4X:
- fs->ports_4X++;
- break;
- case IB_LINK_WIDTH_ACTIVE_8X:
- fs->ports_8X++;
- break;
- case IB_LINK_WIDTH_ACTIVE_12X:
- fs->ports_12X++;
- break;
- default:
- fs->ports_unknown_width++;
- break;
- }
- if (port_state == IB_LINK_DOWN)
- fs->ports_down++;
- else if (port_state == IB_LINK_ACTIVE)
- fs->ports_active++;
- if (port_phys_state == IB_PORT_PHYS_STATE_DISABLED) {
- __tag_port_report(&(fs->disabled_ports),
- cl_ntoh64(node->node_info.node_guid),
- port, node->print_desc);
- fs->ports_disabled++;
- }
-
- fs->total_ports++;
- }
-}
-
-static void portstatus_parse(char **p_last, osm_opensm_t * p_osm, FILE * out)
-{
- fabric_stats_t fs;
- struct timeval before, after;
- char *p_cmd;
-
- memset(&fs, 0, sizeof(fs));
-
- p_cmd = next_token(p_last);
- if (p_cmd) {
- if (strcmp(p_cmd, "ca") == 0) {
- fs.node_type_lim = IB_NODE_TYPE_CA;
- } else if (strcmp(p_cmd, "switch") == 0) {
- fs.node_type_lim = IB_NODE_TYPE_SWITCH;
- } else if (strcmp(p_cmd, "router") == 0) {
- fs.node_type_lim = IB_NODE_TYPE_ROUTER;
- } else {
- fprintf(out, "Node type not understood\n");
- help_portstatus(out, 1);
- return;
- }
- }
-
- gettimeofday(&before, NULL);
-
- /* for each node in the system gather the stats */
- cl_plock_acquire(&p_osm->lock);
- cl_qmap_apply_func(&(p_osm->subn.node_guid_tbl), __get_stats,
- (void *)&fs);
- cl_plock_release(&p_osm->lock);
-
- gettimeofday(&after, NULL);
-
- /* report the stats */
- fprintf(out, "\"%s\" port status:\n",
- fs.node_type_lim ? ib_get_node_type_str(fs.
- node_type_lim) : "ALL");
- fprintf(out,
- " %" PRIu64 " port(s) scanned on %" PRIu64
- " nodes in %lu us\n", fs.total_ports, fs.total_nodes,
- after.tv_usec - before.tv_usec);
-
- if (fs.ports_down)
- fprintf(out, " %" PRIu64 " down\n", fs.ports_down);
- if (fs.ports_active)
- fprintf(out, " %" PRIu64 " active\n", fs.ports_active);
- if (fs.ports_1X)
- fprintf(out, " %" PRIu64 " at 1X\n", fs.ports_1X);
- if (fs.ports_4X)
- fprintf(out, " %" PRIu64 " at 4X\n", fs.ports_4X);
- if (fs.ports_8X)
- fprintf(out, " %" PRIu64 " at 8X\n", fs.ports_8X);
- if (fs.ports_12X)
- fprintf(out, " %" PRIu64 " at 12X\n", fs.ports_12X);
-
- if (fs.ports_sdr)
- fprintf(out, " %" PRIu64 " at 2.5 Gbps\n", fs.ports_sdr);
- if (fs.ports_ddr)
- fprintf(out, " %" PRIu64 " at 5.0 Gbps\n", fs.ports_ddr);
- if (fs.ports_qdr)
- fprintf(out, " %" PRIu64 " at 10.0 Gbps\n", fs.ports_qdr);
-
- if (fs.ports_disabled + fs.ports_reduced_speed + fs.ports_reduced_width
- > 0) {
- fprintf(out, "\nPossible issues:\n");
- }
- if (fs.ports_disabled) {
- fprintf(out, " %" PRIu64 " disabled\n", fs.ports_disabled);
- __print_port_report(out, fs.disabled_ports);
- }
- if (fs.ports_reduced_speed) {
- fprintf(out, " %" PRIu64 " with reduced speed\n",
- fs.ports_reduced_speed);
- __print_port_report(out, fs.reduced_speed_ports);
- }
- if (fs.ports_reduced_width) {
- fprintf(out, " %" PRIu64 " with reduced width\n",
- fs.ports_reduced_width);
- __print_port_report(out, fs.reduced_width_ports);
- }
- fprintf(out, "\n");
-}
-
-static void switchbalance_check(osm_opensm_t * p_osm,
- osm_switch_t * p_sw, FILE * out, int verbose)
-{
- uint8_t port_num;
- uint8_t num_ports;
- const cl_qmap_t *p_port_tbl;
- osm_port_t *p_port;
- osm_physp_t *p_physp;
- osm_physp_t *p_rem_physp;
- osm_node_t *p_rem_node;
- uint32_t count[255]; /* max ports is a uint8_t */
- uint8_t output_ports[255];
- uint8_t output_ports_count = 0;
- uint32_t min_count = 0xFFFFFFFF;
- uint32_t max_count = 0;
- unsigned int i;
-
- memset(count, '\0', sizeof(uint32_t) * 255);
-
- /* Count port usage */
- p_port_tbl = &p_osm->subn.port_guid_tbl;
- for (p_port = (osm_port_t *) cl_qmap_head(p_port_tbl);
- p_port != (osm_port_t *) cl_qmap_end(p_port_tbl);
- p_port = (osm_port_t *) cl_qmap_next(&p_port->map_item)) {
- uint16_t min_lid_ho;
- uint16_t max_lid_ho;
- uint16_t lid_ho;
-
- /* Don't count switches in port usage */
- if (osm_node_get_type(p_port->p_node) == IB_NODE_TYPE_SWITCH)
- continue;
-
- osm_port_get_lid_range_ho(p_port, &min_lid_ho, &max_lid_ho);
-
- if (min_lid_ho == 0 || max_lid_ho == 0)
- continue;
-
- for (lid_ho = min_lid_ho; lid_ho <= max_lid_ho; lid_ho++) {
- port_num = osm_switch_get_port_by_lid(p_sw, lid_ho);
- if (port_num == OSM_NO_PATH)
- continue;
-
- count[port_num]++;
- }
- }
-
- num_ports = p_sw->num_ports;
- for (port_num = 1; port_num < num_ports; port_num++) {
- p_physp = osm_node_get_physp_ptr(p_sw->p_node, port_num);
-
- /* if port is down/unhealthy, don't consider it in
- * min/max calculations
- */
- if (!p_physp || !osm_physp_is_healthy(p_physp)
- || !osm_physp_get_remote(p_physp))
- continue;
-
- p_rem_physp = osm_physp_get_remote(p_physp);
- p_rem_node = osm_physp_get_node_ptr(p_rem_physp);
-
- /* If we are directly connected to a CA/router, its not really
- * up for balancing consideration.
- */
- if (osm_node_get_type(p_rem_node) != IB_NODE_TYPE_SWITCH)
- continue;
-
- output_ports[output_ports_count] = port_num;
- output_ports_count++;
-
- if (count[port_num] < min_count)
- min_count = count[port_num];
- if (count[port_num] > max_count)
- max_count = count[port_num];
- }
-
- if (verbose || ((max_count - min_count) > 1)) {
- if ((max_count - min_count) > 1)
- fprintf(out,
- "Unbalanced Switch: 0x%016" PRIx64 " (%s)\n",
- cl_ntoh64(p_sw->p_node->node_info.node_guid),
- p_sw->p_node->print_desc);
- else
- fprintf(out,
- "Switch: 0x%016" PRIx64 " (%s)\n",
- cl_ntoh64(p_sw->p_node->node_info.node_guid),
- p_sw->p_node->print_desc);
-
- for (i = 0; i < output_ports_count; i++) {
- fprintf(out,
- "Port %d: %d\n",
- output_ports[i], count[output_ports[i]]);
- }
- }
-}
-
-static void switchbalance_parse(char **p_last, osm_opensm_t * p_osm, FILE * out)
-{
- char *p_cmd;
- uint64_t guid = 0;
- osm_switch_t *p_sw;
- int verbose = 0;
-
- p_cmd = next_token(p_last);
- if (p_cmd) {
- char *p_end;
-
- if (strcmp(p_cmd, "verbose") == 0) {
- verbose++;
- p_cmd = next_token(p_last);
- }
-
- if (p_cmd) {
- guid = strtoull(p_cmd, &p_end, 0);
- if (!guid || *p_end != '\0') {
- fprintf(out, "Invalid guid specified\n");
- help_switchbalance(out, 1);
- return;
- }
- }
- }
-
- cl_plock_acquire(&p_osm->lock);
- if (guid) {
- p_sw = osm_get_switch_by_guid(&p_osm->subn, cl_hton64(guid));
- if (!p_sw) {
- fprintf(out, "guid not found\n");
- goto lock_exit;
- }
-
- switchbalance_check(p_osm, p_sw, out, verbose);
- } else {
- cl_qmap_t *p_sw_guid_tbl = &p_osm->subn.sw_guid_tbl;
- for (p_sw = (osm_switch_t *) cl_qmap_head(p_sw_guid_tbl);
- p_sw != (osm_switch_t *) cl_qmap_end(p_sw_guid_tbl);
- p_sw = (osm_switch_t *) cl_qmap_next(&p_sw->map_item))
- switchbalance_check(p_osm, p_sw, out, verbose);
- }
-lock_exit:
- cl_plock_release(&p_osm->lock);
- return;
-}
-
-static void lidbalance_check(osm_opensm_t * p_osm,
- osm_switch_t * p_sw, FILE * out)
-{
- uint8_t port_num;
- const cl_qmap_t *p_port_tbl;
- osm_port_t *p_port;
-
- p_port_tbl = &p_osm->subn.port_guid_tbl;
- for (p_port = (osm_port_t *) cl_qmap_head(p_port_tbl);
- p_port != (osm_port_t *) cl_qmap_end(p_port_tbl);
- p_port = (osm_port_t *) cl_qmap_next(&p_port->map_item)) {
- uint32_t port_count[255]; /* max ports is a uint8_t */
- osm_node_t *rem_node[255];
- uint32_t rem_node_count;
- uint32_t rem_count[255];
- osm_physp_t *p_physp;
- osm_physp_t *p_rem_physp;
- osm_node_t *p_rem_node;
- uint32_t port_min_count = 0xFFFFFFFF;
- uint32_t port_max_count = 0;
- uint32_t rem_min_count = 0xFFFFFFFF;
- uint32_t rem_max_count = 0;
- uint16_t min_lid_ho;
- uint16_t max_lid_ho;
- uint16_t lid_ho;
- uint8_t num_ports;
- unsigned int i;
-
- /* we only care about non-switches */
- if (osm_node_get_type(p_port->p_node) == IB_NODE_TYPE_SWITCH)
- continue;
-
- osm_port_get_lid_range_ho(p_port, &min_lid_ho, &max_lid_ho);
-
- if (min_lid_ho == 0 || max_lid_ho == 0)
- continue;
-
- memset(port_count, '\0', sizeof(uint32_t) * 255);
- memset(rem_node, '\0', sizeof(osm_node_t *) * 255);
- rem_node_count = 0;
- memset(rem_count, '\0', sizeof(uint32_t) * 255);
-
- for (lid_ho = min_lid_ho; lid_ho <= max_lid_ho; lid_ho++) {
- boolean_t rem_node_found = FALSE;
- unsigned int indx = 0;
-
- port_num = osm_switch_get_port_by_lid(p_sw, lid_ho);
- if (port_num == OSM_NO_PATH)
- continue;
-
- p_physp =
- osm_node_get_physp_ptr(p_sw->p_node, port_num);
-
- /* if port is down/unhealthy, can't calculate */
- if (!p_physp || !osm_physp_is_healthy(p_physp)
- || !osm_physp_get_remote(p_physp))
- continue;
-
- p_rem_physp = osm_physp_get_remote(p_physp);
- p_rem_node = osm_physp_get_node_ptr(p_rem_physp);
-
- /* determine if we've seen this remote node before.
- * If not, store it. If yes, update the counter
- */
- for (i = 0; i < rem_node_count; i++) {
- if (rem_node[i] == p_rem_node) {
- rem_node_found = TRUE;
- indx = i;
- break;
- }
- }
-
- if (!rem_node_found) {
- rem_node[rem_node_count] = p_rem_node;
- rem_count[rem_node_count]++;
- indx = rem_node_count;
- rem_node_count++;
- } else
- rem_count[indx]++;
-
- port_count[port_num]++;
- }
-
- if (!rem_node_count)
- continue;
-
- for (i = 0; i < rem_node_count; i++) {
- if (rem_count[i] < rem_min_count)
- rem_min_count = rem_count[i];
- if (rem_count[i] > rem_max_count)
- rem_max_count = rem_count[i];
- }
-
- num_ports = p_sw->num_ports;
- for (i = 0; i < num_ports; i++) {
- if (!port_count[i])
- continue;
- if (port_count[i] < port_min_count)
- port_min_count = port_count[i];
- if (port_count[i] > port_max_count)
- port_max_count = port_count[i];
- }
-
- /* Output if this CA/router is being forwarded an unbalanced number of
- * times to a destination.
- */
- if ((rem_max_count - rem_min_count) > 1) {
- fprintf(out,
- "Unbalanced Remote Forwarding: Switch 0x%016"
- PRIx64 " (%s): ",
- cl_ntoh64(p_sw->p_node->node_info.node_guid),
- p_sw->p_node->print_desc);
- if (osm_node_get_type(p_port->p_node) ==
- IB_NODE_TYPE_CA)
- fprintf(out, "CA");
- else if (osm_node_get_type(p_port->p_node) ==
- IB_NODE_TYPE_ROUTER)
- fprintf(out, "Router");
- fprintf(out, " 0x%016" PRIx64 " (%s): ",
- cl_ntoh64(p_port->p_node->node_info.node_guid),
- p_port->p_node->print_desc);
- for (i = 0; i < rem_node_count; i++) {
- fprintf(out,
- "Dest 0x%016" PRIx64 "(%s) - %u ",
- cl_ntoh64(rem_node[i]->node_info.
- node_guid),
- rem_node[i]->print_desc, rem_count[i]);
- }
- fprintf(out, "\n");
- }
-
- /* Output if this CA/router is being forwarded through a port
- * an unbalanced number of times.
- */
- if ((port_max_count - port_min_count) > 1) {
- fprintf(out,
- "Unbalanced Port Forwarding: Switch 0x%016"
- PRIx64 " (%s): ",
- cl_ntoh64(p_sw->p_node->node_info.node_guid),
- p_sw->p_node->print_desc);
- if (osm_node_get_type(p_port->p_node) ==
- IB_NODE_TYPE_CA)
- fprintf(out, "CA");
- else if (osm_node_get_type(p_port->p_node) ==
- IB_NODE_TYPE_ROUTER)
- fprintf(out, "Router");
- fprintf(out, " 0x%016" PRIx64 " (%s): ",
- cl_ntoh64(p_port->p_node->node_info.node_guid),
- p_port->p_node->print_desc);
- for (i = 0; i < num_ports; i++) {
- if (!port_count[i])
- continue;
- fprintf(out, "Port %u - %u: ", i,
- port_count[i]);
- }
- fprintf(out, "\n");
- }
- }
-}
-
-static void lidbalance_parse(char **p_last, osm_opensm_t * p_osm, FILE * out)
-{
- char *p_cmd;
- uint64_t guid = 0;
- osm_switch_t *p_sw;
-
- p_cmd = next_token(p_last);
- if (p_cmd) {
- char *p_end;
-
- guid = strtoull(p_cmd, &p_end, 0);
- if (!guid || *p_end != '\0') {
- fprintf(out, "Invalid switchguid specified\n");
- help_lidbalance(out, 1);
- return;
- }
- }
-
- cl_plock_acquire(&p_osm->lock);
- if (guid) {
- p_sw = osm_get_switch_by_guid(&p_osm->subn, cl_hton64(guid));
- if (!p_sw) {
- fprintf(out, "switchguid not found\n");
- goto lock_exit;
- }
- lidbalance_check(p_osm, p_sw, out);
- } else {
- cl_qmap_t *p_sw_guid_tbl = &p_osm->subn.sw_guid_tbl;
- for (p_sw = (osm_switch_t *) cl_qmap_head(p_sw_guid_tbl);
- p_sw != (osm_switch_t *) cl_qmap_end(p_sw_guid_tbl);
- p_sw = (osm_switch_t *) cl_qmap_next(&p_sw->map_item))
- lidbalance_check(p_osm, p_sw, out);
- }
-
-lock_exit:
- cl_plock_release(&p_osm->lock);
- return;
-}
-
-static void dump_conf_parse(char **p_last, osm_opensm_t * p_osm, FILE * out)
-{
- osm_subn_output_conf(out, &p_osm->subn.opt);
-}
-
-#ifdef ENABLE_OSM_PERF_MGR
-static void perfmgr_parse(char **p_last, osm_opensm_t * p_osm, FILE * out)
-{
- char *p_cmd;
-
- p_cmd = next_token(p_last);
- if (p_cmd) {
- if (strcmp(p_cmd, "enable") == 0) {
- osm_perfmgr_set_state(&(p_osm->perfmgr),
- PERFMGR_STATE_ENABLED);
- } else if (strcmp(p_cmd, "disable") == 0) {
- osm_perfmgr_set_state(&(p_osm->perfmgr),
- PERFMGR_STATE_DISABLE);
- } else if (strcmp(p_cmd, "clear_counters") == 0) {
- osm_perfmgr_clear_counters(&(p_osm->perfmgr));
- } else if (strcmp(p_cmd, "dump_counters") == 0) {
- p_cmd = next_token(p_last);
- if (p_cmd && (strcmp(p_cmd, "mach") == 0)) {
- osm_perfmgr_dump_counters(&(p_osm->perfmgr),
- PERFMGR_EVENT_DB_DUMP_MR);
- } else {
- osm_perfmgr_dump_counters(&(p_osm->perfmgr),
- PERFMGR_EVENT_DB_DUMP_HR);
- }
- } else if (strcmp(p_cmd, "print_counters") == 0) {
- p_cmd = next_token(p_last);
- if (p_cmd) {
- osm_perfmgr_print_counters(&(p_osm->perfmgr),
- p_cmd, out);
- } else {
- fprintf(out,
- "print_counters requires a node name to be specified\n");
- }
- } else if (strcmp(p_cmd, "sweep_time") == 0) {
- p_cmd = next_token(p_last);
- if (p_cmd) {
- uint16_t time_s = atoi(p_cmd);
- osm_perfmgr_set_sweep_time_s(&(p_osm->perfmgr),
- time_s);
- } else {
- fprintf(out,
- "sweep_time requires a time period (in seconds) to be specified\n");
- }
- } else {
- fprintf(out, "\"%s\" option not found\n", p_cmd);
- }
- } else {
- fprintf(out, "Performance Manager status:\n"
- "state : %s\n"
- "sweep state : %s\n"
- "sweep time : %us\n"
- "outstanding queries/max : %d/%u\n",
- osm_perfmgr_get_state_str(&(p_osm->perfmgr)),
- osm_perfmgr_get_sweep_state_str(&(p_osm->perfmgr)),
- osm_perfmgr_get_sweep_time_s(&(p_osm->perfmgr)),
- p_osm->perfmgr.outstanding_queries,
- p_osm->perfmgr.max_outstanding_queries);
- }
-}
-#endif /* ENABLE_OSM_PERF_MGR */
-
-static void quit_parse(char **p_last, osm_opensm_t * p_osm, FILE * out)
-{
- osm_console_exit(&p_osm->console, &p_osm->log);
-}
-
-static void help_version(FILE * out, int detail)
-{
- fprintf(out, "version -- print the OSM version\n");
-}
-
-static void version_parse(char **p_last, osm_opensm_t * p_osm, FILE * out)
-{
- fprintf(out, "%s build %s %s\n", p_osm->osm_version, __DATE__, __TIME__);
-}
-
-/* more parse routines go here */
-
-static const struct command console_cmds[] = {
- {"help", &help_command, &help_parse},
- {"quit", &help_quit, &quit_parse},
- {"loglevel", &help_loglevel, &loglevel_parse},
- {"priority", &help_priority, &priority_parse},
- {"resweep", &help_resweep, &resweep_parse},
- {"reroute", &help_reroute, &reroute_parse},
- {"status", &help_status, &status_parse},
- {"logflush", &help_logflush, &logflush_parse},
- {"querylid", &help_querylid, &querylid_parse},
- {"portstatus", &help_portstatus, &portstatus_parse},
- {"switchbalance", &help_switchbalance, &switchbalance_parse},
- {"lidbalance", &help_lidbalance, &lidbalance_parse},
- {"dump_conf", &help_dump_conf, &dump_conf_parse},
- {"version", &help_version, &version_parse},
-#ifdef ENABLE_OSM_PERF_MGR
- {"perfmgr", &help_perfmgr, &perfmgr_parse},
-#endif /* ENABLE_OSM_PERF_MGR */
- {NULL, NULL, NULL} /* end of array */
-};
-
-static void parse_cmd_line(char *line, osm_opensm_t * p_osm)
-{
- char *p_cmd, *p_last;
- int i, found = 0;
- FILE *out = p_osm->console.out;
-
- while (isspace(*line))
- line++;
- if (!*line)
- return;
-
- /* find first token which is the command */
- p_cmd = strtok_r(line, " \t\n\r", &p_last);
- if (p_cmd) {
- for (i = 0; console_cmds[i].name; i++) {
- if (loop_command.on) {
- if (!strcmp(p_cmd, "q")) {
- loop_command.on = 0;
- }
- found = 1;
- break;
- }
- if (!strcmp(p_cmd, console_cmds[i].name)) {
- found = 1;
- console_cmds[i].parse_function(&p_last, p_osm,
- out);
- break;
- }
- }
- if (!found) {
- fprintf(out, "%s : Command not found\n\n", p_cmd);
- help_command(out, 0);
- }
- } else {
- fprintf(out, "Error parsing command line: `%s'\n", line);
- }
- if (loop_command.on) {
- fprintf(out, "use \"q<ret>\" to quit loop\n");
- fflush(out);
- }
-}
-
-void osm_console(osm_opensm_t * p_osm)
-{
- struct pollfd pollfd[2];
- char *p_line;
- size_t len;
- ssize_t n;
- struct pollfd *fds;
- nfds_t nfds;
- osm_console_t *p_oct = &p_osm->console;
- osm_log_t *p_log = &p_osm->log;
-
- pollfd[0].fd = p_oct->socket;
- pollfd[0].events = POLLIN;
- pollfd[0].revents = 0;
-
- pollfd[1].fd = p_oct->in_fd;
- pollfd[1].events = POLLIN;
- pollfd[1].revents = 0;
-
- fds = p_oct->socket < 0 ? &pollfd[1] : pollfd;
- nfds = p_oct->socket < 0 || pollfd[1].fd < 0 ? 1 : 2;
-
- if (loop_command.on && loop_command_check_time() &&
- loop_command.loop_function) {
- if (p_oct->out) {
- loop_command.loop_function(p_osm, p_oct->out);
- fflush(p_oct->out);
- } else {
- loop_command.on = 0;
- }
- }
-
- if (poll(fds, nfds, 1000) <= 0)
- return;
-
-#ifdef ENABLE_OSM_CONSOLE_SOCKET
- if (pollfd[0].revents & POLLIN) {
- int new_fd = 0;
- struct sockaddr_in sin;
- socklen_t len = sizeof(sin);
- struct hostent *hent;
- if ((new_fd = accept(p_oct->socket, &sin, &len)) < 0) {
- OSM_LOG(p_log, OSM_LOG_ERROR,
- "ERR 4B04: Failed to accept console socket: %s\n",
- strerror(errno));
- p_oct->in_fd = -1;
- return;
- }
- if (inet_ntop
- (AF_INET, &sin.sin_addr, p_oct->client_ip,
- sizeof(p_oct->client_ip)) == NULL) {
- snprintf(p_oct->client_ip, 64, "STRING_UNKNOWN");
- }
- if ((hent = gethostbyaddr((const char *)&sin.sin_addr,
- sizeof(struct in_addr),
- AF_INET)) == NULL) {
- snprintf(p_oct->client_hn, 128, "STRING_UNKNOWN");
- } else {
- snprintf(p_oct->client_hn, 128, "%s", hent->h_name);
- }
- if (is_authorized(p_oct)) {
- cio_open(p_oct, new_fd, p_log);
- } else {
- OSM_LOG(p_log, OSM_LOG_ERROR,
- "ERR 4B05: Console connection denied: %s (%s)\n",
- p_oct->client_hn, p_oct->client_ip);
- close(new_fd);
- }
- return;
- }
-#endif
-
- if (pollfd[1].revents & POLLIN) {
- p_line = NULL;
- /* Get input line */
- n = getline(&p_line, &len, p_oct->in);
- if (n > 0) {
- /* Parse and act on input */
- parse_cmd_line(p_line, p_osm);
- if (!loop_command.on) {
- osm_console_prompt(p_oct->out);
- }
- } else
- osm_console_exit(p_oct, p_log);
- if (p_line)
- free(p_line);
- }
-}
diff --git a/contrib/ofed/management/opensm/opensm/osm_console_io.c b/contrib/ofed/management/opensm/opensm/osm_console_io.c
deleted file mode 100644
index 3d3ece4..0000000
--- a/contrib/ofed/management/opensm/opensm/osm_console_io.c
+++ /dev/null
@@ -1,254 +0,0 @@
-/*
- * Copyright (c) 2005-2007 Voltaire, Inc. All rights reserved.
- * Copyright (c) 2008 HNR Consulting. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- */
-
-/*
- * Abstract:
- * Provide a framework for the Console which decouples the connection
- * or I/O from the functionality, or commands.
- *
- * Extensible - allows a variety of connection methods independent of
- * the console commands.
- */
-
-#if HAVE_CONFIG_H
-# include <config.h>
-#endif /* HAVE_CONFIG_H */
-
-#define _GNU_SOURCE /* for getline */
-#ifdef ENABLE_OSM_CONSOLE_SOCKET
-#include <tcpd.h>
-#include <arpa/inet.h>
-#include <netinet/in.h>
-#include <sys/socket.h>
-#endif
-#include <unistd.h>
-#include <errno.h>
-#include <signal.h>
-#include <opensm/osm_console_io.h>
-
-static int is_local(char *str)
-{
- // convenience - checks if just stdin/stdout
- if (str)
- return (strcmp(str, OSM_LOCAL_CONSOLE) == 0);
- return 0;
-}
-
-static int is_loopback(char *str)
-{
- // convenience - checks if socket based connection
- if (str)
- return (strcmp(str, OSM_LOOPBACK_CONSOLE) == 0);
- return 0;
-}
-
-static int is_remote(char *str)
-{
- // convenience - checks if socket based connection
- if (str)
- return (strcmp(str, OSM_REMOTE_CONSOLE) == 0)
- || is_loopback(str);
- return 0;
-}
-
-int is_console_enabled(osm_subn_opt_t * p_opt)
-{
- // checks for a variety of types of consoles - default is off or 0
- if (p_opt)
- return (is_local(p_opt->console)
- || is_loopback(p_opt->console)
- || is_remote(p_opt->console));
- return 0;
-}
-
-
-#ifdef ENABLE_OSM_CONSOLE_SOCKET
-static int cio_close(osm_console_t * p_oct)
-{
- int rtnval = -1;
- if (p_oct && (p_oct->in_fd > 0)) {
- rtnval = close(p_oct->in_fd);
- p_oct->in_fd = -1;
- p_oct->out_fd = -1;
- p_oct->in = NULL;
- p_oct->out = NULL;
- }
- return rtnval;
-}
-#endif
-
-/* close the connection */
-static void osm_console_close(osm_console_t * p_oct, osm_log_t * p_log)
-{
-#ifdef ENABLE_OSM_CONSOLE_SOCKET
- if ((p_oct->socket > 0) && (p_oct->in_fd != -1)) {
- OSM_LOG(p_log, OSM_LOG_INFO,
- "Console connection closed: %s (%s)\n",
- p_oct->client_hn, p_oct->client_ip);
- cio_close(p_oct);
- }
- if (p_oct->socket > 0) {
- close(p_oct->socket);
- p_oct->socket = -1;
- }
-#endif
-}
-
-
-/**********************************************************************
- * Do authentication & authorization check
- **********************************************************************/
-#ifdef ENABLE_OSM_CONSOLE_SOCKET
-int is_authorized(osm_console_t * p_oct)
-{
- /* allowed to use the console? */
- p_oct->authorized = !is_remote(p_oct->client_type) ||
- hosts_ctl(OSM_DAEMON_NAME, p_oct->client_hn, p_oct->client_ip,
- "STRING_UNKNOWN");
- return p_oct->authorized;
-}
-#endif
-
-void osm_console_prompt(FILE * out)
-{
- if (out) {
- fprintf(out, "OpenSM %s", OSM_COMMAND_PROMPT);
- fflush(out);
- }
-}
-
-int osm_console_init(osm_subn_opt_t * opt, osm_console_t * p_oct, osm_log_t * p_log)
-{
- p_oct->socket = -1;
- strncpy(p_oct->client_type, opt->console, sizeof(p_oct->client_type));
-
- /* set up the file descriptors for the console */
- if (strcmp(opt->console, OSM_LOCAL_CONSOLE) == 0) {
- p_oct->in = stdin;
- p_oct->out = stdout;
- p_oct->in_fd = fileno(stdin);
- p_oct->out_fd = fileno(stdout);
-
- osm_console_prompt(p_oct->out);
-#ifdef ENABLE_OSM_CONSOLE_SOCKET
- } else if (strcmp(opt->console, OSM_REMOTE_CONSOLE) == 0
- || strcmp(opt->console, OSM_LOOPBACK_CONSOLE) == 0) {
- struct sockaddr_in sin;
- int optval = 1;
-
- if ((p_oct->socket = socket(AF_INET, SOCK_STREAM, 0)) < 0) {
- OSM_LOG(p_log, OSM_LOG_ERROR,
- "ERR 4B01: Failed to open console socket: %s\n",
- strerror(errno));
- return -1;
- }
- setsockopt(p_oct->socket, SOL_SOCKET, SO_REUSEADDR,
- &optval, sizeof(optval));
- sin.sin_family = AF_INET;
- sin.sin_port = htons(opt->console_port);
- if (strcmp(opt->console, OSM_REMOTE_CONSOLE) == 0)
- sin.sin_addr.s_addr = htonl(INADDR_ANY);
- else
- sin.sin_addr.s_addr = htonl(INADDR_LOOPBACK);
- if (bind(p_oct->socket, &sin, sizeof(sin)) < 0) {
- OSM_LOG(p_log, OSM_LOG_ERROR,
- "ERR 4B02: Failed to bind console socket: %s\n",
- strerror(errno));
- return -1;
- }
- if (listen(p_oct->socket, 1) < 0) {
- OSM_LOG(p_log, OSM_LOG_ERROR,
- "ERR 4B03: Failed to listen on socket: %s\n",
- strerror(errno));
- return -1;
- }
-
- signal(SIGPIPE, SIG_IGN); /* protect ourselves from closed pipes */
- p_oct->in = NULL;
- p_oct->out = NULL;
- p_oct->in_fd = -1;
- p_oct->out_fd = -1;
- OSM_LOG(p_log, OSM_LOG_INFO,
- "Console listening on port %d\n", opt->console_port);
-#endif
- }
-
- return 0;
-}
-
-/* clean up and release resources */
-void osm_console_exit(osm_console_t * p_oct, osm_log_t * p_log)
-{
- // clean up and release resources, currently just close the socket
- osm_console_close(p_oct, p_log);
-}
-
-#ifdef ENABLE_OSM_CONSOLE_SOCKET
-int cio_open(osm_console_t * p_oct, int new_fd, osm_log_t * p_log)
-{
- // returns zero if opened fine, -1 otherwise
- char *p_line;
- size_t len;
- ssize_t n;
-
- if (p_oct->in_fd >= 0) {
- FILE *file = fdopen(new_fd, "w+");
-
- fprintf(file, "OpenSM Console connection already in use\n"
- " kill other session (y/n)? ");
- fflush(file);
- p_line = NULL;
- n = getline(&p_line, &len, file);
- if (n > 0 && (p_line[0] == 'y' || p_line[0] == 'Y')) {
- osm_console_close(p_oct, p_log);
- } else {
- OSM_LOG(p_log, OSM_LOG_INFO,
- "Console connection aborted: %s (%s)\n",
- p_oct->client_hn, p_oct->client_ip);
- close(new_fd);
- return -1;
- }
- }
- p_oct->in_fd = new_fd;
- p_oct->out_fd = p_oct->in_fd;
- p_oct->in = fdopen(p_oct->in_fd, "w+");
- p_oct->out = p_oct->in;
- osm_console_prompt(p_oct->out);
- OSM_LOG(p_log, OSM_LOG_INFO,
- "Console connection accepted: %s (%s)\n",
- p_oct->client_hn, p_oct->client_ip);
-
- return (p_oct->in == NULL) ? -1 : 0;
-}
-#endif
diff --git a/contrib/ofed/management/opensm/opensm/osm_db_files.c b/contrib/ofed/management/opensm/opensm/osm_db_files.c
deleted file mode 100644
index 907b7c7..0000000
--- a/contrib/ofed/management/opensm/opensm/osm_db_files.c
+++ /dev/null
@@ -1,723 +0,0 @@
-/*
- * Copyright (c) 2004-2008 Voltaire, Inc. All rights reserved.
- * Copyright (c) 2002-2006 Mellanox Technologies LTD. All rights reserved.
- * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- */
-
-/*
- * Abstract:
- * Implementation of the osm_db interface using simple text files
- */
-
-#if HAVE_CONFIG_H
-# include <config.h>
-#endif /* HAVE_CONFIG_H */
-
-#include <sys/stat.h>
-#include <sys/types.h>
-#include <stdlib.h>
-#include <string.h>
-#include <opensm/st.h>
-#include <opensm/osm_db.h>
-
-/****d* Database/OSM_DB_MAX_LINE_LEN
- * NAME
- * OSM_DB_MAX_LINE_LEN
- *
- * DESCRIPTION
- * The Maximal line length allowed for the file
- *
- * SYNOPSIS
- */
-#define OSM_DB_MAX_LINE_LEN 1024
-/**********/
-
-/****d* Database/OSM_DB_MAX_GUID_LEN
- * NAME
- * OSM_DB_MAX_GUID_LEN
- *
- * DESCRIPTION
- * The Maximal word length allowed for the file (guid or lid)
- *
- * SYNOPSIS
- */
-#define OSM_DB_MAX_GUID_LEN 32
-/**********/
-
-/****s* OpenSM: Database/osm_db_domain_imp
- * NAME
- * osm_db_domain_imp
- *
- * DESCRIPTION
- * An implementation for domain of the database based on text files and
- * hash tables.
- *
- * SYNOPSIS
- */
-typedef struct osm_db_domain_imp {
- char *file_name;
- st_table *p_hash;
- cl_spinlock_t lock;
-} osm_db_domain_imp_t;
-/*
- * FIELDS
- *
- * SEE ALSO
- * osm_db_domain_t
- *********/
-
-/****s* OpenSM: Database/osm_db_imp_t
- * NAME
- * osm_db_imp_t
- *
- * DESCRIPTION
- * An implementation for file based database
- *
- * SYNOPSIS
- */
-typedef struct osm_db_imp {
- char *db_dir_name;
-} osm_db_imp_t;
-/*
- * FIELDS
- *
- * db_dir_name
- * The directory holding the database
- *
- * SEE ALSO
- * osm_db_t
- *********/
-
-/***************************************************************************
- ***************************************************************************/
-void osm_db_construct(IN osm_db_t * const p_db)
-{
- memset(p_db, 0, sizeof(osm_db_t));
- cl_list_construct(&p_db->domains);
-}
-
-/***************************************************************************
- ***************************************************************************/
-void osm_db_domain_destroy(IN osm_db_domain_t * const p_db_domain)
-{
- osm_db_domain_imp_t *p_domain_imp;
- p_domain_imp = (osm_db_domain_imp_t *) p_db_domain->p_domain_imp;
-
- osm_db_clear(p_db_domain);
-
- cl_spinlock_destroy(&p_domain_imp->lock);
-
- st_free_table(p_domain_imp->p_hash);
- free(p_domain_imp->file_name);
- free(p_domain_imp);
-}
-
-/***************************************************************************
- ***************************************************************************/
-void osm_db_destroy(IN osm_db_t * const p_db)
-{
- osm_db_domain_t *p_domain;
-
- while ((p_domain = cl_list_remove_head(&p_db->domains)) != NULL) {
- osm_db_domain_destroy(p_domain);
- free(p_domain);
- }
- cl_list_destroy(&p_db->domains);
- free(p_db->p_db_imp);
-}
-
-/***************************************************************************
- ***************************************************************************/
-int osm_db_init(IN osm_db_t * const p_db, IN osm_log_t * p_log)
-{
- osm_db_imp_t *p_db_imp;
- struct stat dstat;
-
- OSM_LOG_ENTER(p_log);
-
- p_db_imp = (osm_db_imp_t *) malloc(sizeof(osm_db_imp_t));
- CL_ASSERT(p_db_imp != NULL);
-
- p_db_imp->db_dir_name = getenv("OSM_CACHE_DIR");
- if (!p_db_imp->db_dir_name || !(*p_db_imp->db_dir_name))
- p_db_imp->db_dir_name = OSM_DEFAULT_CACHE_DIR;
-
- /* Create the directory if it doesn't exist */
- /* There is a difference in creating directory between windows and linux */
-#ifdef __WIN__
- /* Check if the directory exists. If not - create it. */
- CreateDirectory(p_db_imp->db_dir_name, NULL);
-#else /* __WIN__ */
- /* make sure the directory exists */
- if (lstat(p_db_imp->db_dir_name, &dstat)) {
- if (mkdir(p_db_imp->db_dir_name, 0755)) {
- OSM_LOG(p_log, OSM_LOG_ERROR, "ERR 6101: "
- "Failed to create the db directory:%s\n",
- p_db_imp->db_dir_name);
- OSM_LOG_EXIT(p_log);
- return 1;
- }
- }
-#endif
-
- p_db->p_log = p_log;
- p_db->p_db_imp = (void *)p_db_imp;
-
- cl_list_init(&p_db->domains, 5);
-
- OSM_LOG_EXIT(p_log);
-
- return 0;
-}
-
-/***************************************************************************
- ***************************************************************************/
-osm_db_domain_t *osm_db_domain_init(IN osm_db_t * const p_db,
- IN char *domain_name)
-{
- osm_db_domain_t *p_domain;
- osm_db_domain_imp_t *p_domain_imp;
- int dir_name_len;
- osm_log_t *p_log = p_db->p_log;
- FILE *p_file;
-
- OSM_LOG_ENTER(p_log);
-
- /* allocate a new domain object */
- p_domain = (osm_db_domain_t *) malloc(sizeof(osm_db_domain_t));
- CL_ASSERT(p_domain != NULL);
-
- p_domain_imp =
- (osm_db_domain_imp_t *) malloc(sizeof(osm_db_domain_imp_t));
- CL_ASSERT(p_domain_imp != NULL);
-
- dir_name_len = strlen(((osm_db_imp_t *) p_db->p_db_imp)->db_dir_name);
-
- /* set the domain file name */
- p_domain_imp->file_name =
- (char *)malloc(sizeof(char) * (dir_name_len) + strlen(domain_name) +
- 2);
- CL_ASSERT(p_domain_imp->file_name != NULL);
- strcpy(p_domain_imp->file_name,
- ((osm_db_imp_t *) p_db->p_db_imp)->db_dir_name);
- strcat(p_domain_imp->file_name, domain_name);
-
- /* make sure the file exists - or exit if not writable */
- p_file = fopen(p_domain_imp->file_name, "a+");
- if (!p_file) {
- OSM_LOG(p_log, OSM_LOG_ERROR, "ERR 6102: "
- "Failed to open the db file:%s\n",
- p_domain_imp->file_name);
- free(p_domain_imp);
- free(p_domain);
- p_domain = NULL;
- goto Exit;
- }
- fclose(p_file);
-
- /* initialize the hash table object */
- p_domain_imp->p_hash = st_init_strtable();
- CL_ASSERT(p_domain_imp->p_hash != NULL);
-
- p_domain->p_db = p_db;
- cl_list_insert_tail(&p_db->domains, p_domain);
- p_domain->p_domain_imp = p_domain_imp;
- cl_spinlock_construct(&p_domain_imp->lock);
- cl_spinlock_init(&p_domain_imp->lock);
-
-Exit:
- OSM_LOG_EXIT(p_log);
- return p_domain;
-}
-
-/***************************************************************************
- ***************************************************************************/
-int osm_db_restore(IN osm_db_domain_t * p_domain)
-{
-
- osm_log_t *p_log = p_domain->p_db->p_log;
- osm_db_domain_imp_t *p_domain_imp =
- (osm_db_domain_imp_t *) p_domain->p_domain_imp;
- FILE *p_file;
- int status;
- char sLine[OSM_DB_MAX_LINE_LEN];
- boolean_t before_key;
- char *p_first_word, *p_rest_of_line, *p_last;
- char *p_key = NULL;
- char *p_prev_val, *p_accum_val = NULL;
- char *endptr = NULL;
- unsigned int line_num;
-
- OSM_LOG_ENTER(p_log);
-
- /* take the lock on the domain */
- cl_spinlock_acquire(&p_domain_imp->lock);
-
- /* open the file - read mode */
- p_file = fopen(p_domain_imp->file_name, "r");
-
- if (!p_file) {
- OSM_LOG(p_log, OSM_LOG_ERROR, "ERR 6103: "
- "Failed to open the db file:%s\n",
- p_domain_imp->file_name);
- status = 1;
- goto Exit;
- }
-
- /* parse the file allocating new hash tables as required */
- /*
- states:
- before_key (0) -> in_key (1)
-
- before_key: if a word on the first byte - it is the key. state=in_key
- the rest of the line is start of the value.
- in_key: unless the line is empty - add it (with newlines) to the value.
- if empty: state=before_key
- */
- status = 0;
- before_key = TRUE;
- line_num = 0;
- /* if we got to EOF in the middle of a key we add a last newline */
- while ((fgets(sLine, OSM_DB_MAX_LINE_LEN, p_file) != NULL) ||
- ((before_key == FALSE) && strcpy(sLine, "\n"))
- ) {
- line_num++;
- if (before_key) {
- if ((sLine[0] != ' ') && (sLine[0] != '\t')
- && (sLine[0] != '\n')) {
- /* we got a new key */
- before_key = FALSE;
-
- /* handle the key */
- p_first_word =
- strtok_r(sLine, " \t\n", &p_last);
- if (!p_first_word) {
- OSM_LOG(p_log, OSM_LOG_ERROR, "ERR 6104: "
- "Failed to get key from line:%u : %s (file:%s)\n",
- line_num, sLine,
- p_domain_imp->file_name);
- status = 1;
- goto EndParsing;
- }
- if (strlen(p_first_word) > OSM_DB_MAX_GUID_LEN) {
- OSM_LOG(p_log, OSM_LOG_ERROR, "ERR 610A: "
- "Illegal key from line:%u : %s (file:%s)\n",
- line_num, sLine,
- p_domain_imp->file_name);
- status = 1;
- goto EndParsing;
- }
-
- p_key =
- (char *)malloc(sizeof(char) *
- (strlen(p_first_word) + 1));
- strcpy(p_key, p_first_word);
-
- p_rest_of_line = strtok_r(NULL, "\n", &p_last);
- if (p_rest_of_line != NULL) {
- p_accum_val =
- (char *)malloc(sizeof(char) *
- (strlen
- (p_rest_of_line) +
- 1));
- strcpy(p_accum_val, p_rest_of_line);
- } else {
- p_accum_val = (char *)malloc(2);
- strcpy(p_accum_val, "\0");
- }
- } else if (sLine[0] != '\n') {
- OSM_LOG(p_log, OSM_LOG_ERROR, "ERR 6105: "
- "How did we get here? line:%u : %s (file:%s)\n",
- line_num, sLine,
- p_domain_imp->file_name);
- status = 1;
- goto EndParsing;
- }
- } /* before key */
- else {
- /* we already have a key */
-
- if (sLine[0] == '\n') {
- /* got an end of key */
- before_key = TRUE;
-
- /* make sure the key was not previously used */
- if (st_lookup(p_domain_imp->p_hash,
- (st_data_t) p_key,
- (void *) & p_prev_val)) {
- OSM_LOG(p_log, OSM_LOG_ERROR, "ERR 6106: "
- "Key:%s already exists in:%s with value:%s."
- " Removing it\n",
- p_key,
- p_domain_imp->file_name,
- p_prev_val);
- } else {
- p_prev_val = NULL;
- }
-
- OSM_LOG(p_log, OSM_LOG_DEBUG,
- "Got key:%s value:%s\n", p_key,
- p_accum_val);
-
- /* check that the key is a number */
- if (!strtouq(p_key, &endptr, 0)
- && *endptr != '\0') {
- OSM_LOG(p_log, OSM_LOG_ERROR, "ERR 610B: "
- "Key:%s is invalid\n", p_key);
- } else {
- /* store our key and value */
- st_insert(p_domain_imp->p_hash,
- (st_data_t) p_key,
- (st_data_t) p_accum_val);
- }
- } else {
- /* accumulate into the value */
- p_prev_val = p_accum_val;
- p_accum_val =
- (char *)malloc(strlen(p_prev_val) +
- strlen(sLine) + 1);
- strcpy(p_accum_val, p_prev_val);
- free(p_prev_val);
- strcat(p_accum_val, sLine);
- }
- } /* in key */
- } /* while lines or last line */
-
-EndParsing:
- fclose(p_file);
-
-Exit:
- cl_spinlock_release(&p_domain_imp->lock);
- OSM_LOG_EXIT(p_log);
- return status;
-}
-
-/***************************************************************************
- ***************************************************************************/
-static int __osm_dump_tbl_entry(st_data_t key, st_data_t val, st_data_t arg)
-{
- FILE *p_file = (FILE *) arg;
- char *p_key = (char *)key;
- char *p_val = (char *)val;
-
- fprintf(p_file, "%s %s\n\n", p_key, p_val);
- return ST_CONTINUE;
-}
-
-int osm_db_store(IN osm_db_domain_t * p_domain)
-{
- osm_log_t *p_log = p_domain->p_db->p_log;
- osm_db_domain_imp_t *p_domain_imp;
- FILE *p_file;
- int status = 0;
- char *p_tmp_file_name;
-
- OSM_LOG_ENTER(p_log);
-
- p_domain_imp = (osm_db_domain_imp_t *) p_domain->p_domain_imp;
- p_tmp_file_name =
- (char *)malloc(sizeof(char) *
- (strlen(p_domain_imp->file_name) + 8));
- strcpy(p_tmp_file_name, p_domain_imp->file_name);
- strcat(p_tmp_file_name, ".tmp");
-
- cl_spinlock_acquire(&p_domain_imp->lock);
-
- /* open up the output file */
- p_file = fopen(p_tmp_file_name, "w");
- if (!p_file) {
- OSM_LOG(p_log, OSM_LOG_ERROR, "ERR 6107: "
- "Failed to open the db file:%s for writing\n",
- p_domain_imp->file_name);
- status = 1;
- goto Exit;
- }
-
- st_foreach(p_domain_imp->p_hash, __osm_dump_tbl_entry,
- (st_data_t) p_file);
- fclose(p_file);
-
- /* move the domain file */
- status = remove(p_domain_imp->file_name);
- if (status) {
- OSM_LOG(p_log, OSM_LOG_ERROR, "ERR 6109: "
- "Failed to remove file:%s (err:%u)\n",
- p_domain_imp->file_name, status);
- }
-
- status = rename(p_tmp_file_name, p_domain_imp->file_name);
- if (status) {
- OSM_LOG(p_log, OSM_LOG_ERROR, "ERR 6108: "
- "Failed to rename the db file to:%s (err:%u)\n",
- p_domain_imp->file_name, status);
- }
-Exit:
- cl_spinlock_release(&p_domain_imp->lock);
- free(p_tmp_file_name);
- OSM_LOG_EXIT(p_log);
- return status;
-}
-
-/***************************************************************************
- ***************************************************************************/
-/* simply de-allocate the key and the value and return the code
- that makes the st_foreach delete the entry */
-static int __osm_clear_tbl_entry(st_data_t key, st_data_t val, st_data_t arg)
-{
- free((char *)key);
- free((char *)val);
- return ST_DELETE;
-}
-
-int osm_db_clear(IN osm_db_domain_t * p_domain)
-{
- osm_db_domain_imp_t *p_domain_imp =
- (osm_db_domain_imp_t *) p_domain->p_domain_imp;
-
- cl_spinlock_acquire(&p_domain_imp->lock);
- st_foreach(p_domain_imp->p_hash, __osm_clear_tbl_entry,
- (st_data_t) NULL);
- cl_spinlock_release(&p_domain_imp->lock);
-
- return 0;
-}
-
-/***************************************************************************
- ***************************************************************************/
-static int __osm_get_key_of_tbl_entry(st_data_t key, st_data_t val,
- st_data_t arg)
-{
- cl_list_t *p_list = (cl_list_t *) arg;
- cl_list_insert_tail(p_list, (void *)key);
- return ST_CONTINUE;
-}
-
-int osm_db_keys(IN osm_db_domain_t * p_domain, OUT cl_list_t * p_key_list)
-{
- osm_db_domain_imp_t *p_domain_imp =
- (osm_db_domain_imp_t *) p_domain->p_domain_imp;
-
- cl_spinlock_acquire(&p_domain_imp->lock);
-
- st_foreach(p_domain_imp->p_hash,
- __osm_get_key_of_tbl_entry, (st_data_t) p_key_list);
-
- cl_spinlock_release(&p_domain_imp->lock);
-
- return 0;
-}
-
-/***************************************************************************
- ***************************************************************************/
-char *osm_db_lookup(IN osm_db_domain_t * p_domain, IN char *const p_key)
-{
- osm_db_domain_imp_t *p_domain_imp =
- (osm_db_domain_imp_t *) p_domain->p_domain_imp;
- char *p_val = NULL;
-
- cl_spinlock_acquire(&p_domain_imp->lock);
-
- if (!st_lookup
- (p_domain_imp->p_hash, (st_data_t) p_key, (void *) & p_val))
- p_val = NULL;
-
- cl_spinlock_release(&p_domain_imp->lock);
-
- return p_val;
-}
-
-/***************************************************************************
- ***************************************************************************/
-int
-osm_db_update(IN osm_db_domain_t * p_domain,
- IN char *const p_key, IN char *const p_val)
-{
- osm_log_t *p_log = p_domain->p_db->p_log;
- osm_db_domain_imp_t *p_domain_imp =
- (osm_db_domain_imp_t *) p_domain->p_domain_imp;
- char *p_prev_val = NULL;
- char *p_new_key;
- char *p_new_val;
-
- cl_spinlock_acquire(&p_domain_imp->lock);
-
- if (st_lookup(p_domain_imp->p_hash,
- (st_data_t) p_key, (void *) & p_prev_val)) {
- OSM_LOG(p_log, OSM_LOG_DEBUG,
- "Key:%s previously exists in:%s with value:%s\n",
- p_key, p_domain_imp->file_name, p_prev_val);
- p_new_key = p_key;
- } else {
- /* need to allocate the key */
- p_new_key = malloc(sizeof(char) * (strlen(p_key) + 1));
- strcpy(p_new_key, p_key);
- }
-
- /* need to arange a new copy of the value */
- p_new_val = malloc(sizeof(char) * (strlen(p_val) + 1));
- strcpy(p_new_val, p_val);
-
- st_insert(p_domain_imp->p_hash, (st_data_t) p_new_key,
- (st_data_t) p_new_val);
-
- if (p_prev_val)
- free(p_prev_val);
-
- cl_spinlock_release(&p_domain_imp->lock);
-
- return 0;
-}
-
-/***************************************************************************
- ***************************************************************************/
-int osm_db_delete(IN osm_db_domain_t * p_domain, IN char *const p_key)
-{
- osm_log_t *p_log = p_domain->p_db->p_log;
- osm_db_domain_imp_t *p_domain_imp =
- (osm_db_domain_imp_t *) p_domain->p_domain_imp;
- char *p_prev_val = NULL;
- int res;
-
- OSM_LOG_ENTER(p_log);
-
- cl_spinlock_acquire(&p_domain_imp->lock);
- if (st_delete(p_domain_imp->p_hash,
- (void *) & p_key, (void *) & p_prev_val)) {
- if (st_lookup(p_domain_imp->p_hash,
- (st_data_t) p_key, (void *) & p_prev_val)) {
- OSM_LOG(p_log, OSM_LOG_ERROR,
- "key:%s still exists in:%s with value:%s\n",
- p_key, p_domain_imp->file_name, p_prev_val);
- res = 1;
- } else {
- free(p_key);
- free(p_prev_val);
- res = 0;
- }
- } else {
- OSM_LOG(p_log, OSM_LOG_DEBUG,
- "fail to find key:%s. delete failed\n", p_key);
- res = 1;
- }
- cl_spinlock_release(&p_domain_imp->lock);
-
- OSM_LOG_EXIT(p_log);
- return res;
-}
-
-#ifdef TEST_OSMDB
-#include <stdlib.h>
-#include <math.h>
-
-int main(int argc, char **argv)
-{
- osm_db_t db;
- osm_log_t log;
- osm_db_domain_t *p_dbd;
- cl_list_t keys;
- cl_list_iterator_t kI;
- char *p_key;
- char *p_val;
- int i;
-
- cl_list_construct(&keys);
- cl_list_init(&keys, 10);
-
- osm_log_init_v2(&log, TRUE, 0xff, "/var/log/osm_db_test.log", 0, FALSE);
-
- osm_db_construct(&db);
- if (osm_db_init(&db, &log)) {
- printf("db init failed\n");
- exit(1);
- }
-
- p_dbd = osm_db_domain_init(&db, "lid_by_guid");
-
- if (osm_db_restore(p_dbd)) {
- printf("failed to restore\n");
- }
-
- if (osm_db_keys(p_dbd, &keys)) {
- printf("failed to get keys\n");
- } else {
- kI = cl_list_head(&keys);
- while (kI != cl_list_end(&keys)) {
- p_key = cl_list_obj(kI);
- kI = cl_list_next(kI);
-
- p_val = osm_db_lookup(p_dbd, p_key);
- printf("key = %s val = %s\n", p_key, p_val);
- }
- }
-
- cl_list_remove_all(&keys);
-
- /* randomly add and remove numbers */
- for (i = 0; i < 10; i++) {
- int k;
- float v;
- int is_add;
- char val_buf[16];
- char key_buf[16];
-
- k = floor(1.0 * rand() / RAND_MAX * 100);
- v = rand();
- sprintf(key_buf, "%u", k);
- sprintf(val_buf, "%u", v);
-
- is_add = (rand() < RAND_MAX / 2);
-
- if (is_add) {
- osm_db_update(p_dbd, key_buf, val_buf);
- } else {
- osm_db_delete(p_dbd, key_buf);
- }
- }
- if (osm_db_keys(p_dbd, &keys)) {
- printf("failed to get keys\n");
- } else {
- kI = cl_list_head(&keys);
- while (kI != cl_list_end(&keys)) {
- p_key = cl_list_obj(kI);
- kI = cl_list_next(kI);
-
- p_val = osm_db_lookup(p_dbd, p_key);
- printf("key = %s val = %s\n", p_key, p_val);
- }
- }
- if (osm_db_store(p_dbd))
- printf("failed to store\n");
-
- osm_db_destroy(&db);
- cl_list_destroy(&keys);
-}
-#endif
diff --git a/contrib/ofed/management/opensm/opensm/osm_db_pack.c b/contrib/ofed/management/opensm/opensm/osm_db_pack.c
deleted file mode 100644
index bf56169..0000000
--- a/contrib/ofed/management/opensm/opensm/osm_db_pack.c
+++ /dev/null
@@ -1,157 +0,0 @@
-/*
- * Copyright (c) 2004-2007 Voltaire, Inc. All rights reserved.
- * Copyright (c) 2002-2006 Mellanox Technologies LTD. All rights reserved.
- * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- */
-
-#if HAVE_CONFIG_H
-# include <config.h>
-#endif /* HAVE_CONFIG_H */
-
-#include <stdlib.h>
-#include <complib/cl_debug.h>
-#include <opensm/osm_db_pack.h>
-
-static inline void __osm_pack_guid(uint64_t guid, char *p_guid_str)
-{
- sprintf(p_guid_str, "0x%016" PRIx64, guid);
-}
-
-static inline uint64_t __osm_unpack_guid(char *p_guid_str)
-{
- return strtoull(p_guid_str, NULL, 0);
-}
-
-static inline void
-__osm_pack_lids(uint16_t min_lid, uint16_t max_lid, char *p_lid_str)
-{
- sprintf(p_lid_str, "0x%04x 0x%04x", min_lid, max_lid);
-}
-
-static inline int
-__osm_unpack_lids(IN char *p_lid_str,
- OUT uint16_t * p_min_lid, OUT uint16_t * p_max_lid)
-{
- unsigned long tmp;
- char *p_next;
- char *p_num;
- char lids_str[24];
-
- strncpy(lids_str, p_lid_str, 23);
- lids_str[23] = '\0';
- p_num = strtok_r(lids_str, " \t", &p_next);
- if (!p_num)
- return 1;
- tmp = strtoul(p_num, NULL, 0);
- CL_ASSERT(tmp < 0x10000);
- *p_min_lid = (uint16_t) tmp;
-
- p_num = strtok_r(NULL, " \t", &p_next);
- if (!p_num)
- return 1;
- tmp = strtoul(p_num, NULL, 0);
- CL_ASSERT(tmp < 0x10000);
- *p_max_lid = (uint16_t) tmp;
-
- return 0;
-}
-
-int
-osm_db_guid2lid_guids(IN osm_db_domain_t * const p_g2l,
- OUT cl_qlist_t * p_guid_list)
-{
- char *p_key;
- cl_list_t keys;
- osm_db_guid_elem_t *p_guid_elem;
-
- cl_list_construct(&keys);
- cl_list_init(&keys, 10);
-
- if (osm_db_keys(p_g2l, &keys))
- return 1;
-
- while ((p_key = cl_list_remove_head(&keys)) != NULL) {
- p_guid_elem =
- (osm_db_guid_elem_t *) malloc(sizeof(osm_db_guid_elem_t));
- CL_ASSERT(p_guid_elem != NULL);
-
- p_guid_elem->guid = __osm_unpack_guid(p_key);
- cl_qlist_insert_head(p_guid_list, &p_guid_elem->item);
- }
-
- cl_list_destroy(&keys);
- return 0;
-}
-
-int
-osm_db_guid2lid_get(IN osm_db_domain_t * const p_g2l,
- IN uint64_t guid,
- OUT uint16_t * p_min_lid, OUT uint16_t * p_max_lid)
-{
- char guid_str[20];
- char *p_lid_str;
- uint16_t min_lid, max_lid;
-
- __osm_pack_guid(guid, guid_str);
- p_lid_str = osm_db_lookup(p_g2l, guid_str);
- if (!p_lid_str)
- return 1;
- if (__osm_unpack_lids(p_lid_str, &min_lid, &max_lid))
- return 1;
-
- if (p_min_lid)
- *p_min_lid = min_lid;
- if (p_max_lid)
- *p_max_lid = max_lid;
-
- return 0;
-}
-
-int
-osm_db_guid2lid_set(IN osm_db_domain_t * const p_g2l,
- IN uint64_t guid, IN uint16_t min_lid, IN uint16_t max_lid)
-{
- char guid_str[20];
- char lid_str[16];
-
- __osm_pack_guid(guid, guid_str);
- __osm_pack_lids(min_lid, max_lid, lid_str);
-
- return (osm_db_update(p_g2l, guid_str, lid_str));
-}
-
-int osm_db_guid2lid_delete(IN osm_db_domain_t * const p_g2l, IN uint64_t guid)
-{
- char guid_str[20];
- __osm_pack_guid(guid, guid_str);
- return (osm_db_delete(p_g2l, guid_str));
-}
diff --git a/contrib/ofed/management/opensm/opensm/osm_drop_mgr.c b/contrib/ofed/management/opensm/opensm/osm_drop_mgr.c
deleted file mode 100644
index 215a155..0000000
--- a/contrib/ofed/management/opensm/opensm/osm_drop_mgr.c
+++ /dev/null
@@ -1,516 +0,0 @@
-/*
- * Copyright (c) 2004-2008 Voltaire, Inc. All rights reserved.
- * Copyright (c) 2002-2008 Mellanox Technologies LTD. All rights reserved.
- * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
- * Copyright (c) 2008 Xsigo Systems Inc. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- */
-
-/*
- * Abstract:
- * Implementation of osm_drop_mgr_t.
- * This object represents the Drop Manager object.
- * This object is part of the opensm family of objects.
- */
-
-#if HAVE_CONFIG_H
-# include <config.h>
-#endif /* HAVE_CONFIG_H */
-
-#include <stdlib.h>
-#include <string.h>
-#include <iba/ib_types.h>
-#include <complib/cl_qmap.h>
-#include <complib/cl_passivelock.h>
-#include <complib/cl_debug.h>
-#include <complib/cl_ptr_vector.h>
-#include <opensm/osm_sm.h>
-#include <opensm/osm_router.h>
-#include <opensm/osm_switch.h>
-#include <opensm/osm_node.h>
-#include <opensm/osm_helper.h>
-#include <opensm/osm_mcm_info.h>
-#include <opensm/osm_multicast.h>
-#include <opensm/osm_remote_sm.h>
-#include <opensm/osm_inform.h>
-#include <opensm/osm_ucast_mgr.h>
-
-/**********************************************************************
- **********************************************************************/
-static void
-__osm_drop_mgr_remove_router(osm_sm_t * sm, IN const ib_net64_t portguid)
-{
- osm_router_t *p_rtr;
- cl_qmap_t *p_rtr_guid_tbl;
-
- p_rtr_guid_tbl = &sm->p_subn->rtr_guid_tbl;
- p_rtr = (osm_router_t *) cl_qmap_remove(p_rtr_guid_tbl, portguid);
- if (p_rtr != (osm_router_t *) cl_qmap_end(p_rtr_guid_tbl)) {
- OSM_LOG(sm->p_log, OSM_LOG_VERBOSE,
- "Cleaned router for port guid 0x%016" PRIx64 "\n",
- cl_ntoh64(portguid));
- osm_router_delete(&p_rtr);
- }
-}
-
-/**********************************************************************
- **********************************************************************/
-static void drop_mgr_clean_physp(osm_sm_t * sm, IN osm_physp_t * p_physp)
-{
- osm_physp_t *p_remote_physp;
- osm_port_t *p_remote_port;
-
- p_remote_physp = osm_physp_get_remote(p_physp);
- if (p_remote_physp) {
- p_remote_port = osm_get_port_by_guid(sm->p_subn,
- p_remote_physp->port_guid);
-
- if (p_remote_port) {
- /* Let's check if this is a case of link that is lost (both ports
- weren't recognized), or a "hiccup" in the subnet - in which case
- the remote port was recognized, and its state is ACTIVE.
- If this is just a "hiccup" - force a heavy sweep in the next sweep.
- We don't want to lose that part of the subnet. */
- if (p_remote_port->discovery_count &&
- osm_physp_get_port_state(p_remote_physp) ==
- IB_LINK_ACTIVE) {
- OSM_LOG(sm->p_log, OSM_LOG_VERBOSE,
- "Forcing new heavy sweep. Remote "
- "port 0x%016" PRIx64 " port num: %u "
- "was recognized in ACTIVE state\n",
- cl_ntoh64(p_remote_physp->port_guid),
- p_remote_physp->port_num);
- sm->p_subn->force_heavy_sweep = TRUE;
- }
-
- /* If the remote node is ca or router - need to remove the remote port,
- since it is no longer reachable. This can be done if we reset the
- discovery count of the remote port. */
- if (!p_remote_physp->p_node->sw) {
- p_remote_port->discovery_count = 0;
- OSM_LOG(sm->p_log, OSM_LOG_DEBUG,
- "Resetting discovery count of node: "
- "0x%016" PRIx64 " port num:%u\n",
- cl_ntoh64(osm_node_get_node_guid
- (p_remote_physp->p_node)),
- p_remote_physp->port_num);
- }
- }
-
- OSM_LOG(sm->p_log, OSM_LOG_VERBOSE,
- "Unlinking local node 0x%016" PRIx64 ", port %u"
- "\n\t\t\t\tand remote node 0x%016" PRIx64
- ", port %u\n",
- cl_ntoh64(osm_node_get_node_guid(p_physp->p_node)),
- p_physp->port_num,
- cl_ntoh64(osm_node_get_node_guid
- (p_remote_physp->p_node)),
- p_remote_physp->port_num);
-
- if (sm->ucast_mgr.cache_valid)
- osm_ucast_cache_add_link(&sm->ucast_mgr,
- p_physp, p_remote_physp);
-
- osm_physp_unlink(p_physp, p_remote_physp);
-
- }
-
- OSM_LOG(sm->p_log, OSM_LOG_DEBUG,
- "Clearing node 0x%016" PRIx64 " physical port number %u\n",
- cl_ntoh64(osm_node_get_node_guid(p_physp->p_node)),
- p_physp->port_num);
-
- osm_physp_destroy(p_physp);
-}
-
-/**********************************************************************
- **********************************************************************/
-static void __osm_drop_mgr_remove_port(osm_sm_t * sm, IN osm_port_t * p_port)
-{
- ib_net64_t port_guid;
- osm_port_t *p_port_check;
- cl_qmap_t *p_sm_guid_tbl;
- osm_mcm_info_t *p_mcm;
- osm_mgrp_t *p_mgrp;
- cl_ptr_vector_t *p_port_lid_tbl;
- uint16_t min_lid_ho;
- uint16_t max_lid_ho;
- uint16_t lid_ho;
- osm_node_t *p_node;
- osm_remote_sm_t *p_sm;
- ib_gid_t port_gid;
- ib_mad_notice_attr_t notice;
- ib_api_status_t status;
-
- OSM_LOG_ENTER(sm->p_log);
-
- port_guid = osm_port_get_guid(p_port);
- OSM_LOG(sm->p_log, OSM_LOG_VERBOSE,
- "Unreachable port 0x%016" PRIx64 "\n", cl_ntoh64(port_guid));
-
- p_port_check =
- (osm_port_t *) cl_qmap_remove(&sm->p_subn->port_guid_tbl,
- port_guid);
- if (p_port_check != p_port) {
- OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR 0101: "
- "Port 0x%016" PRIx64 " not in guid table\n",
- cl_ntoh64(port_guid));
- goto Exit;
- }
-
- p_sm_guid_tbl = &sm->p_subn->sm_guid_tbl;
- p_sm = (osm_remote_sm_t *) cl_qmap_remove(p_sm_guid_tbl, port_guid);
- if (p_sm != (osm_remote_sm_t *) cl_qmap_end(p_sm_guid_tbl)) {
- /* need to remove this item */
- OSM_LOG(sm->p_log, OSM_LOG_VERBOSE,
- "Cleaned SM for port guid 0x%016" PRIx64 "\n",
- cl_ntoh64(port_guid));
-
- free(p_sm);
- }
-
- __osm_drop_mgr_remove_router(sm, port_guid);
-
- osm_port_get_lid_range_ho(p_port, &min_lid_ho, &max_lid_ho);
-
- OSM_LOG(sm->p_log, OSM_LOG_VERBOSE,
- "Clearing abandoned LID range [%u,%u]\n",
- min_lid_ho, max_lid_ho);
-
- p_port_lid_tbl = &sm->p_subn->port_lid_tbl;
- for (lid_ho = min_lid_ho; lid_ho <= max_lid_ho; lid_ho++)
- cl_ptr_vector_set(p_port_lid_tbl, lid_ho, NULL);
-
- drop_mgr_clean_physp(sm, p_port->p_physp);
-
- p_mcm = (osm_mcm_info_t *) cl_qlist_remove_head(&p_port->mcm_list);
- while (p_mcm != (osm_mcm_info_t *) cl_qlist_end(&p_port->mcm_list)) {
- p_mgrp = osm_get_mgrp_by_mlid(sm->p_subn, p_mcm->mlid);
- if (p_mgrp) {
- osm_mgrp_delete_port(sm->p_subn, sm->p_log,
- p_mgrp, p_port->guid);
- osm_mcm_info_delete((osm_mcm_info_t *) p_mcm);
- }
- p_mcm =
- (osm_mcm_info_t *) cl_qlist_remove_head(&p_port->mcm_list);
- }
-
- /* initialize the p_node - may need to get node_desc later */
- p_node = p_port->p_node;
-
- osm_port_delete(&p_port);
-
- /* issue a notice - trap 65 */
-
- /* details of the notice */
- notice.generic_type = 0x83; /* is generic subn mgt type */
- ib_notice_set_prod_type_ho(&notice, 4); /* A class manager generator */
- /* endport ceases to be reachable */
- notice.g_or_v.generic.trap_num = CL_HTON16(65);
- /* The sm_base_lid is saved in network order already. */
- notice.issuer_lid = sm->p_subn->sm_base_lid;
- /* following C14-72.1.2 and table 119 p725 */
- /* we need to provide the GID */
- port_gid.unicast.prefix = sm->p_subn->opt.subnet_prefix;
- port_gid.unicast.interface_id = port_guid;
- memcpy(&(notice.data_details.ntc_64_67.gid),
- &(port_gid), sizeof(ib_gid_t));
-
- /* According to page 653 - the issuer gid in this case of trap
- is the SM gid, since the SM is the initiator of this trap. */
- notice.issuer_gid.unicast.prefix = sm->p_subn->opt.subnet_prefix;
- notice.issuer_gid.unicast.interface_id = sm->p_subn->sm_port_guid;
-
- status = osm_report_notice(sm->p_log, sm->p_subn, &notice);
- if (status != IB_SUCCESS) {
- OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR 0103: "
- "Error sending trap reports (%s)\n",
- ib_get_err_str(status));
- goto Exit;
- }
-
- OSM_LOG(sm->p_log, OSM_LOG_INFO,
- "Removed port with GUID:0x%016" PRIx64
- " LID range [%u, %u] of node:%s\n",
- cl_ntoh64(port_gid.unicast.interface_id),
- min_lid_ho, max_lid_ho,
- p_node ? p_node->print_desc : "UNKNOWN");
-
-Exit:
- OSM_LOG_EXIT(sm->p_log);
-}
-
-/**********************************************************************
- **********************************************************************/
-static void __osm_drop_mgr_remove_switch(osm_sm_t * sm, IN osm_node_t * p_node)
-{
- osm_switch_t *p_sw;
- cl_qmap_t *p_sw_guid_tbl;
- ib_net64_t node_guid;
-
- OSM_LOG_ENTER(sm->p_log);
-
- node_guid = osm_node_get_node_guid(p_node);
- p_sw_guid_tbl = &sm->p_subn->sw_guid_tbl;
-
- p_sw = (osm_switch_t *) cl_qmap_remove(p_sw_guid_tbl, node_guid);
- if (p_sw == (osm_switch_t *) cl_qmap_end(p_sw_guid_tbl)) {
- OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR 0102: "
- "Node 0x%016" PRIx64 " not in switch table\n",
- cl_ntoh64(osm_node_get_node_guid(p_node)));
- } else {
- p_node->sw = NULL;
- osm_switch_delete(&p_sw);
- }
-
- OSM_LOG_EXIT(sm->p_log);
-}
-
-/**********************************************************************
- **********************************************************************/
-static boolean_t
-__osm_drop_mgr_process_node(osm_sm_t * sm, IN osm_node_t * p_node)
-{
- osm_physp_t *p_physp;
- osm_port_t *p_port;
- osm_node_t *p_node_check;
- uint32_t port_num;
- uint32_t max_ports;
- ib_net64_t port_guid;
- boolean_t return_val = FALSE;
-
- OSM_LOG_ENTER(sm->p_log);
-
- OSM_LOG(sm->p_log, OSM_LOG_VERBOSE,
- "Unreachable node 0x%016" PRIx64 "\n",
- cl_ntoh64(osm_node_get_node_guid(p_node)));
-
- if (sm->ucast_mgr.cache_valid)
- osm_ucast_cache_add_node(&sm->ucast_mgr, p_node);
-
- /*
- Delete all the logical and physical port objects
- associated with this node.
- */
- max_ports = osm_node_get_num_physp(p_node);
- for (port_num = 0; port_num < max_ports; port_num++) {
- p_physp = osm_node_get_physp_ptr(p_node, port_num);
- if (p_physp) {
- port_guid = osm_physp_get_port_guid(p_physp);
-
- p_port = osm_get_port_by_guid(sm->p_subn, port_guid);
-
- if (p_port)
- __osm_drop_mgr_remove_port(sm, p_port);
- else
- drop_mgr_clean_physp(sm, p_physp);
- }
- }
-
- return_val = TRUE;
-
- if (p_node->sw)
- __osm_drop_mgr_remove_switch(sm, p_node);
-
- p_node_check =
- (osm_node_t *) cl_qmap_remove(&sm->p_subn->node_guid_tbl,
- osm_node_get_node_guid(p_node));
- if (p_node_check != p_node) {
- OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR 0105: "
- "Node 0x%016" PRIx64 " not in guid table\n",
- cl_ntoh64(osm_node_get_node_guid(p_node)));
- }
-
- /* free memory allocated to node */
- osm_node_delete(&p_node);
-
- OSM_LOG_EXIT(sm->p_log);
- return (return_val);
-}
-
-/**********************************************************************
- **********************************************************************/
-static void __osm_drop_mgr_check_node(osm_sm_t * sm, IN osm_node_t * p_node)
-{
- ib_net64_t node_guid;
- osm_physp_t *p_physp;
- osm_port_t *p_port;
- ib_net64_t port_guid;
-
- OSM_LOG_ENTER(sm->p_log);
-
- node_guid = osm_node_get_node_guid(p_node);
-
- if (osm_node_get_type(p_node) != IB_NODE_TYPE_SWITCH) {
- OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR 0107: "
- "Node 0x%016" PRIx64 " is not a switch node\n",
- cl_ntoh64(node_guid));
- goto Exit;
- }
-
- /* Make sure we have a switch object for this node */
- if (!p_node->sw) {
- /* We do not have switch info for this node */
- OSM_LOG(sm->p_log, OSM_LOG_VERBOSE,
- "Node 0x%016" PRIx64 " no switch in table\n",
- cl_ntoh64(node_guid));
-
- __osm_drop_mgr_process_node(sm, p_node);
- goto Exit;
- }
-
- /* Make sure we have a port object for port zero */
- p_physp = osm_node_get_physp_ptr(p_node, 0);
- if (!p_physp) {
- OSM_LOG(sm->p_log, OSM_LOG_VERBOSE,
- "Node 0x%016" PRIx64 " no valid physical port 0\n",
- cl_ntoh64(node_guid));
-
- __osm_drop_mgr_process_node(sm, p_node);
- goto Exit;
- }
-
- port_guid = osm_physp_get_port_guid(p_physp);
-
- p_port = osm_get_port_by_guid(sm->p_subn, port_guid);
-
- if (!p_port) {
- OSM_LOG(sm->p_log, OSM_LOG_VERBOSE,
- "Node 0x%016" PRIx64 " has no port object\n",
- cl_ntoh64(node_guid));
-
- __osm_drop_mgr_process_node(sm, p_node);
- goto Exit;
- }
-
- if (p_port->discovery_count == 0) {
- OSM_LOG(sm->p_log, OSM_LOG_VERBOSE,
- "Node 0x%016" PRIx64 " port has discovery count zero\n",
- cl_ntoh64(node_guid));
-
- __osm_drop_mgr_process_node(sm, p_node);
- goto Exit;
- }
-
-Exit:
- OSM_LOG_EXIT(sm->p_log);
- return;
-}
-
-/**********************************************************************
- **********************************************************************/
-void osm_drop_mgr_process(osm_sm_t * sm)
-{
- cl_qmap_t *p_node_guid_tbl;
- cl_qmap_t *p_port_guid_tbl;
- osm_port_t *p_port;
- osm_port_t *p_next_port;
- osm_node_t *p_node;
- osm_node_t *p_next_node;
-
- CL_ASSERT(sm);
-
- OSM_LOG_ENTER(sm->p_log);
-
- p_node_guid_tbl = &sm->p_subn->node_guid_tbl;
- p_port_guid_tbl = &sm->p_subn->port_guid_tbl;
-
- CL_PLOCK_EXCL_ACQUIRE(sm->p_lock);
-
- p_next_node = (osm_node_t *) cl_qmap_head(p_node_guid_tbl);
- while (p_next_node != (osm_node_t *) cl_qmap_end(p_node_guid_tbl)) {
- p_node = p_next_node;
- p_next_node =
- (osm_node_t *) cl_qmap_next(&p_next_node->map_item);
-
- CL_ASSERT(cl_qmap_key(&p_node->map_item) ==
- osm_node_get_node_guid(p_node));
-
- OSM_LOG(sm->p_log, OSM_LOG_DEBUG,
- "Checking node 0x%016" PRIx64 "\n",
- cl_ntoh64(osm_node_get_node_guid(p_node)));
-
- /*
- Check if this node was discovered during the last sweep.
- If not, it is unreachable in the current subnet, and
- should therefore be removed from the subnet object.
- */
- if (p_node->discovery_count == 0)
- __osm_drop_mgr_process_node(sm, p_node);
- }
-
- /*
- Go over all the nodes. If the node is a switch - make sure
- there is also a switch record for it, and a portInfo record for
- port zero of of the node.
- If not - this means that there was some error in getting the data
- of this node. Drop the node.
- */
- p_next_node = (osm_node_t *) cl_qmap_head(p_node_guid_tbl);
- while (p_next_node != (osm_node_t *) cl_qmap_end(p_node_guid_tbl)) {
- p_node = p_next_node;
- p_next_node =
- (osm_node_t *) cl_qmap_next(&p_next_node->map_item);
-
- OSM_LOG(sm->p_log, OSM_LOG_DEBUG,
- "Checking full discovery of node 0x%016" PRIx64 "\n",
- cl_ntoh64(osm_node_get_node_guid(p_node)));
-
- if (osm_node_get_type(p_node) != IB_NODE_TYPE_SWITCH)
- continue;
-
- /* We are handling a switch node */
- __osm_drop_mgr_check_node(sm, p_node);
- }
-
- p_next_port = (osm_port_t *) cl_qmap_head(p_port_guid_tbl);
- while (p_next_port != (osm_port_t *) cl_qmap_end(p_port_guid_tbl)) {
- p_port = p_next_port;
- p_next_port =
- (osm_port_t *) cl_qmap_next(&p_next_port->map_item);
-
- CL_ASSERT(cl_qmap_key(&p_port->map_item) ==
- osm_port_get_guid(p_port));
-
- OSM_LOG(sm->p_log, OSM_LOG_DEBUG,
- "Checking port 0x%016" PRIx64 "\n",
- cl_ntoh64(osm_port_get_guid(p_port)));
-
- /*
- If the port is unreachable, remove it from the guid table.
- */
- if (p_port->discovery_count == 0)
- __osm_drop_mgr_remove_port(sm, p_port);
- }
-
- CL_PLOCK_RELEASE(sm->p_lock);
- OSM_LOG_EXIT(sm->p_log);
-}
diff --git a/contrib/ofed/management/opensm/opensm/osm_dump.c b/contrib/ofed/management/opensm/opensm/osm_dump.c
deleted file mode 100644
index 7e0ba47..0000000
--- a/contrib/ofed/management/opensm/opensm/osm_dump.c
+++ /dev/null
@@ -1,642 +0,0 @@
-/*
- * Copyright (c) 2004-2008 Voltaire, Inc. All rights reserved.
- * Copyright (c) 2002-2006 Mellanox Technologies LTD. All rights reserved.
- * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- */
-
-/*
- * Abstract:
- * Various OpenSM dumpers
- */
-
-#if HAVE_CONFIG_H
-# include <config.h>
-#endif /* HAVE_CONFIG_H */
-
-#include <unistd.h>
-#include <stdlib.h>
-#include <string.h>
-#include <errno.h>
-#include <iba/ib_types.h>
-#include <complib/cl_qmap.h>
-#include <complib/cl_debug.h>
-#include <opensm/osm_opensm.h>
-#include <opensm/osm_log.h>
-#include <opensm/osm_node.h>
-#include <opensm/osm_switch.h>
-#include <opensm/osm_helper.h>
-#include <opensm/osm_msgdef.h>
-#include <opensm/osm_opensm.h>
-
-static void dump_ucast_path_distribution(cl_map_item_t * p_map_item,
- FILE *file, void *cxt)
-{
- osm_node_t *p_node;
- osm_node_t *p_remote_node;
- uint8_t i;
- uint8_t num_ports;
- uint32_t num_paths;
- ib_net64_t remote_guid_ho;
- osm_switch_t *p_sw = (osm_switch_t *) p_map_item;
-
- p_node = p_sw->p_node;
- num_ports = p_sw->num_ports;
-
- fprintf(file, "dump_ucast_path_distribution: Switch 0x%" PRIx64 "\n"
- "Port : Path Count Through Port",
- cl_ntoh64(osm_node_get_node_guid(p_node)));
-
- for (i = 0; i < num_ports; i++) {
- num_paths = osm_switch_path_count_get(p_sw, i);
- fprintf(file, "\n %03u : %u", i, num_paths);
- if (i == 0) {
- fprintf(file, " (switch management port)");
- continue;
- }
-
- p_remote_node = osm_node_get_remote_node(p_node, i, NULL);
- if (p_remote_node == NULL)
- continue;
-
- remote_guid_ho =
- cl_ntoh64(osm_node_get_node_guid(p_remote_node));
-
- switch (osm_node_get_type(p_remote_node)) {
- case IB_NODE_TYPE_SWITCH:
- fprintf(file, " (link to switch");
- break;
- case IB_NODE_TYPE_ROUTER:
- fprintf(file, " (link to router");
- break;
- case IB_NODE_TYPE_CA:
- fprintf(file, " (link to CA");
- break;
- default:
- fprintf(file, " (link to unknown node type");
- break;
- }
-
- fprintf(file, " 0x%" PRIx64 ")", remote_guid_ho);
- }
-
- fprintf(file, "\n");
-}
-
-static void dump_ucast_routes(cl_map_item_t *p_map_item, FILE *file, void *cxt)
-{
- const osm_node_t *p_node;
- osm_port_t *p_port;
- uint8_t port_num;
- uint8_t num_hops;
- uint8_t best_hops;
- uint8_t best_port;
- uint16_t max_lid_ho;
- uint16_t lid_ho, base_lid;
- boolean_t direct_route_exists = FALSE;
- boolean_t dor;
- osm_switch_t *p_sw = (osm_switch_t *) p_map_item;
- osm_opensm_t *p_osm = cxt;
-
- p_node = p_sw->p_node;
-
- max_lid_ho = p_sw->max_lid_ho;
-
- fprintf(file, "__osm_ucast_mgr_dump_ucast_routes: "
- "Switch 0x%016" PRIx64 "\nLID : Port : Hops : Optimal\n",
- cl_ntoh64(osm_node_get_node_guid(p_node)));
-
- dor = (p_osm->routing_engine_used == OSM_ROUTING_ENGINE_TYPE_DOR);
-
- for (lid_ho = 1; lid_ho <= max_lid_ho; lid_ho++) {
- fprintf(file, "0x%04X : ", lid_ho);
-
- p_port = cl_ptr_vector_get(&p_osm->subn.port_lid_tbl, lid_ho);
- if (!p_port) {
- fprintf(file, "UNREACHABLE\n");
- continue;
- }
-
- port_num = osm_switch_get_port_by_lid(p_sw, lid_ho);
- if (port_num == OSM_NO_PATH) {
- /*
- This may occur if there are 'holes' in the existing
- LID assignments. Running SM with --reassign_lids
- will reassign and compress the LID range. The
- subnet should work fine either way.
- */
- fprintf(file, "UNREACHABLE\n");
- continue;
- }
- /*
- Switches can lie about which port routes a given
- lid due to a recent reconfiguration of the subnet.
- Therefore, ensure that the hop count is better than
- OSM_NO_PATH.
- */
- if (p_port->p_node->sw) {
- /* Target LID is switch.
- Get its base lid and check hop count for this base LID only. */
- base_lid = osm_node_get_base_lid(p_port->p_node, 0);
- base_lid = cl_ntoh16(base_lid);
- num_hops =
- osm_switch_get_hop_count(p_sw, base_lid, port_num);
- } else {
- /* Target LID is not switch (CA or router).
- Check if we have route to this target from current switch. */
- num_hops =
- osm_switch_get_hop_count(p_sw, lid_ho, port_num);
- if (num_hops != OSM_NO_PATH) {
- direct_route_exists = TRUE;
- base_lid = lid_ho;
- } else {
- osm_physp_t *p_physp = p_port->p_physp;
-
- if (!p_physp || !p_physp->p_remote_physp ||
- !p_physp->p_remote_physp->p_node->sw)
- num_hops = OSM_NO_PATH;
- else {
- base_lid =
- osm_node_get_base_lid(p_physp->
- p_remote_physp->
- p_node, 0);
- base_lid = cl_ntoh16(base_lid);
- num_hops =
- p_physp->p_remote_physp->p_node->
- sw ==
- p_sw ? 0 :
- osm_switch_get_hop_count(p_sw,
- base_lid,
- port_num);
- }
- }
- }
-
- if (num_hops == OSM_NO_PATH) {
- fprintf(file, "UNREACHABLE\n");
- continue;
- }
-
- best_hops = osm_switch_get_least_hops(p_sw, base_lid);
- if (!p_port->p_node->sw && !direct_route_exists) {
- best_hops++;
- num_hops++;
- }
-
- fprintf(file, "%03u : %02u : ", port_num, num_hops);
-
- if (best_hops == num_hops)
- fprintf(file, "yes");
- else {
- /* No LMC Optimization */
- best_port = osm_switch_recommend_path(p_sw, p_port,
- lid_ho, 1, TRUE,
- dor);
- fprintf(file, "No %u hop path possible via port %u!",
- best_hops, best_port);
- }
-
- fprintf(file, "\n");
- }
-}
-
-static void dump_mcast_routes(cl_map_item_t *p_map_item, FILE *file, void *cxt)
-{
- osm_switch_t *p_sw = (osm_switch_t *) p_map_item;
- osm_mcast_tbl_t *p_tbl;
- int16_t mlid_ho = 0;
- int16_t mlid_start_ho;
- uint8_t position = 0;
- int16_t block_num = 0;
- boolean_t first_mlid;
- boolean_t first_port;
- const osm_node_t *p_node;
- uint16_t i, j;
- uint16_t mask_entry;
- char sw_hdr[256];
- char mlid_hdr[32];
-
- p_node = p_sw->p_node;
-
- p_tbl = osm_switch_get_mcast_tbl_ptr(p_sw);
-
- sprintf(sw_hdr, "\nSwitch 0x%016" PRIx64 "\nLID : Out Port(s)\n",
- cl_ntoh64(osm_node_get_node_guid(p_node)));
- first_mlid = TRUE;
- while (block_num <= p_tbl->max_block_in_use) {
- mlid_start_ho = (uint16_t) (block_num * IB_MCAST_BLOCK_SIZE);
- for (i = 0; i < IB_MCAST_BLOCK_SIZE; i++) {
- mlid_ho = mlid_start_ho + i;
- position = 0;
- first_port = TRUE;
- sprintf(mlid_hdr, "0x%04X :",
- mlid_ho + IB_LID_MCAST_START_HO);
- while (position <= p_tbl->max_position) {
- mask_entry =
- cl_ntoh16((*p_tbl->
- p_mask_tbl)[mlid_ho][position]);
- if (mask_entry == 0) {
- position++;
- continue;
- }
- for (j = 0; j < 16; j++) {
- if ((1 << j) & mask_entry) {
- if (first_mlid) {
- fprintf(file, "%s",
- sw_hdr);
- first_mlid = FALSE;
- }
- if (first_port) {
- fprintf(file, "%s",
- mlid_hdr);
- first_port = FALSE;
- }
- fprintf(file, " 0x%03X ",
- j + (position * 16));
- }
- }
- position++;
- }
- if (first_port == FALSE)
- fprintf(file, "\n");
- }
- block_num++;
- }
-}
-
-static void dump_lid_matrix(cl_map_item_t *p_map_item, FILE *file, void *cxt)
-{
- osm_switch_t *p_sw = (osm_switch_t *) p_map_item;
- osm_opensm_t *p_osm = cxt;
- osm_node_t *p_node = p_sw->p_node;
- unsigned max_lid = p_sw->max_lid_ho;
- unsigned max_port = p_sw->num_ports;
- uint16_t lid;
- uint8_t port;
-
- fprintf(file, "Switch: guid 0x%016" PRIx64 "\n",
- cl_ntoh64(osm_node_get_node_guid(p_node)));
- for (lid = 1; lid <= max_lid; lid++) {
- osm_port_t *p_port;
- if (osm_switch_get_least_hops(p_sw, lid) == OSM_NO_PATH)
- continue;
- fprintf(file, "0x%04x:", lid);
- for (port = 0; port < max_port; port++)
- fprintf(file, " %02x",
- osm_switch_get_hop_count(p_sw, lid, port));
- p_port = cl_ptr_vector_get(&p_osm->subn.port_lid_tbl, lid);
- if (p_port)
- fprintf(file, " # portguid 0x016%" PRIx64,
- cl_ntoh64(osm_port_get_guid(p_port)));
- fprintf(file, "\n");
- }
-}
-
-static void dump_ucast_lfts(cl_map_item_t *p_map_item, FILE *file, void *cxt)
-{
- osm_switch_t *p_sw = (osm_switch_t *) p_map_item;
- osm_opensm_t *p_osm = cxt;
- osm_node_t *p_node = p_sw->p_node;
- unsigned max_lid = p_sw->max_lid_ho;
- unsigned max_port = p_sw->num_ports;
- uint16_t lid;
- uint8_t port;
-
- fprintf(file, "Unicast lids [0-%u] of switch Lid %u guid 0x%016"
- PRIx64 " (\'%s\'):\n",
- max_lid, cl_ntoh16(osm_node_get_base_lid(p_node, 0)),
- cl_ntoh64(osm_node_get_node_guid(p_node)), p_node->print_desc);
- for (lid = 0; lid <= max_lid; lid++) {
- osm_port_t *p_port;
- port = osm_switch_get_port_by_lid(p_sw, lid);
-
- if (port >= max_port)
- continue;
-
- fprintf(file, "0x%04x %03u # ", lid, port);
-
- p_port = cl_ptr_vector_get(&p_osm->subn.port_lid_tbl, lid);
- if (p_port) {
- p_node = p_port->p_node;
- fprintf(file, "%s portguid 0x%016" PRIx64 ": \'%s\'",
- ib_get_node_type_str(osm_node_get_type(p_node)),
- cl_ntoh64(osm_port_get_guid(p_port)),
- p_node->print_desc);
- } else
- fprintf(file, "unknown node and type");
- fprintf(file, "\n");
- }
- fprintf(file, "%u lids dumped\n", max_lid);
-}
-
-static void dump_topology_node(cl_map_item_t *p_map_item, FILE *file, void *cxt)
-{
- osm_node_t *p_node = (osm_node_t *) p_map_item;
- uint32_t cPort;
- osm_node_t *p_nbnode;
- osm_physp_t *p_physp, *p_default_physp, *p_rphysp;
- uint8_t link_speed_act;
-
- if (!p_node->node_info.num_ports)
- return;
-
- for (cPort = 1; cPort < osm_node_get_num_physp(p_node); cPort++) {
- uint8_t port_state;
-
- p_physp = osm_node_get_physp_ptr(p_node, cPort);
- if (!p_physp)
- continue;
-
- p_rphysp = p_physp->p_remote_physp;
- if (!p_rphysp)
- continue;
-
- CL_ASSERT(cPort == p_physp->port_num);
-
- if (p_node->node_info.node_type == IB_NODE_TYPE_SWITCH)
- p_default_physp = osm_node_get_physp_ptr(p_node, 0);
- else
- p_default_physp = p_physp;
-
- fprintf(file, "{ %s%s Ports:%02X SystemGUID:%016" PRIx64
- " NodeGUID:%016" PRIx64 " PortGUID:%016" PRIx64
- " VenID:%06X DevID:%04X Rev:%08X {%s} LID:%04X PN:%02X } ",
- p_node->node_info.node_type == IB_NODE_TYPE_SWITCH ?
- "SW" : p_node->node_info.node_type ==
- IB_NODE_TYPE_CA ? "CA" : p_node->node_info.node_type ==
- IB_NODE_TYPE_ROUTER ? "Rt" : "**",
- p_default_physp->port_info.base_lid ==
- p_default_physp->port_info.
- master_sm_base_lid ? "-SM" : "",
- p_node->node_info.num_ports,
- cl_ntoh64(p_node->node_info.sys_guid),
- cl_ntoh64(p_node->node_info.node_guid),
- cl_ntoh64(p_physp->port_guid),
- cl_ntoh32(ib_node_info_get_vendor_id
- (&p_node->node_info)),
- cl_ntoh16(p_node->node_info.device_id),
- cl_ntoh32(p_node->node_info.revision),
- p_node->print_desc,
- cl_ntoh16(p_default_physp->port_info.base_lid), cPort);
-
- p_nbnode = p_rphysp->p_node;
-
- if (p_nbnode->node_info.node_type == IB_NODE_TYPE_SWITCH)
- p_default_physp = osm_node_get_physp_ptr(p_nbnode, 0);
- else
- p_default_physp = p_rphysp;
-
- fprintf(file, "{ %s%s Ports:%02X SystemGUID:%016" PRIx64
- " NodeGUID:%016" PRIx64 " PortGUID:%016" PRIx64
- " VenID:%08X DevID:%04X Rev:%08X {%s} LID:%04X PN:%02X } ",
- p_nbnode->node_info.node_type == IB_NODE_TYPE_SWITCH ?
- "SW" : p_nbnode->node_info.node_type ==
- IB_NODE_TYPE_CA ? "CA" :
- p_nbnode->node_info.node_type == IB_NODE_TYPE_ROUTER ?
- "Rt" : "**",
- p_default_physp->port_info.base_lid ==
- p_default_physp->port_info.
- master_sm_base_lid ? "-SM" : "",
- p_nbnode->node_info.num_ports,
- cl_ntoh64(p_nbnode->node_info.sys_guid),
- cl_ntoh64(p_nbnode->node_info.node_guid),
- cl_ntoh64(p_rphysp->port_guid),
- cl_ntoh32(ib_node_info_get_vendor_id
- (&p_nbnode->node_info)),
- cl_ntoh32(p_nbnode->node_info.device_id),
- cl_ntoh32(p_nbnode->node_info.revision),
- p_nbnode->print_desc,
- cl_ntoh16(p_default_physp->port_info.base_lid),
- p_rphysp->port_num);
-
- port_state = ib_port_info_get_port_state(&p_physp->port_info);
- link_speed_act =
- ib_port_info_get_link_speed_active(&p_physp->port_info);
-
- fprintf(file, "PHY=%s LOG=%s SPD=%s\n",
- p_physp->port_info.link_width_active == 1 ? "1x" :
- p_physp->port_info.link_width_active == 2 ? "4x" :
- p_physp->port_info.link_width_active == 8 ? "12x" :
- "??",
- port_state == IB_LINK_ACTIVE ? "ACT" :
- port_state == IB_LINK_ARMED ? "ARM" :
- port_state == IB_LINK_INIT ? "INI" : "DWN",
- link_speed_act == 1 ? "2.5" :
- link_speed_act == 2 ? "5" :
- link_speed_act == 4 ? "10" : "??");
- }
-}
-
-static void print_node_report(cl_map_item_t *p_map_item, FILE *file, void *cxt)
-{
- osm_node_t *p_node = (osm_node_t *) p_map_item;
- osm_opensm_t *osm = cxt;
- const osm_physp_t *p_physp, *p_remote_physp;
- const ib_port_info_t *p_pi;
- uint8_t port_num;
- uint32_t num_ports;
- uint8_t node_type;
-
- node_type = osm_node_get_type(p_node);
-
- num_ports = osm_node_get_num_physp(p_node);
- port_num = node_type == IB_NODE_TYPE_SWITCH ? 0 : 1;
- for (; port_num < num_ports; port_num++) {
- p_physp = osm_node_get_physp_ptr(p_node, port_num);
- if (!p_physp)
- continue;
-
- fprintf(file, "%-11s : %s : %02X :",
- osm_get_manufacturer_str(cl_ntoh64
- (osm_node_get_node_guid
- (p_node))),
- osm_get_node_type_str_fixed_width(node_type), port_num);
-
- p_pi = &p_physp->port_info;
-
- /*
- * Port state is not defined for switch port 0
- */
- if (port_num == 0)
- fprintf(file, " :");
- else
- fprintf(file, " %s :",
- osm_get_port_state_str_fixed_width
- (ib_port_info_get_port_state(p_pi)));
-
- /*
- * LID values are only meaningful in select cases.
- */
- if (ib_port_info_get_port_state(p_pi) != IB_LINK_DOWN
- && ((node_type == IB_NODE_TYPE_SWITCH && port_num == 0)
- || node_type != IB_NODE_TYPE_SWITCH))
- fprintf(file, " %04X : %01X :",
- cl_ntoh16(p_pi->base_lid),
- ib_port_info_get_lmc(p_pi));
- else
- fprintf(file, " : :");
-
- if (port_num != 0)
- fprintf(file, " %s : %s : %s ",
- osm_get_mtu_str
- (ib_port_info_get_neighbor_mtu(p_pi)),
- osm_get_lwa_str(p_pi->link_width_active),
- osm_get_lsa_str
- (ib_port_info_get_link_speed_active(p_pi)));
- else
- fprintf(file, " : : ");
-
- if (osm_physp_get_port_guid(p_physp) == osm->subn.sm_port_guid)
- fprintf(file, "* %016" PRIx64 " *",
- cl_ntoh64(osm_physp_get_port_guid(p_physp)));
- else
- fprintf(file, ": %016" PRIx64 " :",
- cl_ntoh64(osm_physp_get_port_guid(p_physp)));
-
- if (port_num
- && (ib_port_info_get_port_state(p_pi) != IB_LINK_DOWN)) {
- p_remote_physp = osm_physp_get_remote(p_physp);
- if (p_remote_physp)
- fprintf(file, " %016" PRIx64 " (%02X)",
- cl_ntoh64(osm_physp_get_port_guid
- (p_remote_physp)),
- osm_physp_get_port_num(p_remote_physp));
- else
- fprintf(file, " UNKNOWN");
- }
-
- fprintf(file, "\n");
- }
-
- fprintf(file, "------------------------------------------------------"
- "------------------------------------------------\n");
-}
-
-/**********************************************************************
- **********************************************************************/
-struct dump_context {
- osm_opensm_t *p_osm;
- FILE *file;
- void (*func) (cl_map_item_t *, FILE *, void *);
- void *cxt;
-};
-
-static void dump_item(cl_map_item_t *item, void *cxt)
-{
- ((struct dump_context *)cxt)->func(item,
- ((struct dump_context *)cxt)->file,
- ((struct dump_context *)cxt)->cxt);
-}
-
-static void dump_qmap(FILE *file, cl_qmap_t *map,
- void (*func)(cl_map_item_t *, FILE *, void *), void *cxt)
-{
- struct dump_context dump_context;
-
- dump_context.file = file;
- dump_context.func = func;
- dump_context.cxt = cxt;
-
- cl_qmap_apply_func(map, dump_item, &dump_context);
-}
-
-void osm_dump_qmap_to_file(osm_opensm_t * p_osm, const char *file_name,
- cl_qmap_t * map,
- void (*func) (cl_map_item_t *, FILE *, void *),
- void *cxt)
-{
- char path[1024];
- FILE *file;
-
- snprintf(path, sizeof(path), "%s/%s",
- p_osm->subn.opt.dump_files_dir, file_name);
-
- file = fopen(path, "w");
- if (!file) {
- OSM_LOG(&p_osm->log, OSM_LOG_ERROR,
- "cannot create file \'%s\': %s\n",
- path, strerror(errno));
- return;
- }
-
- dump_qmap(file, map, func, cxt);
-
- fclose(file);
-}
-
-/**********************************************************************
- **********************************************************************/
-
-static void print_report(osm_opensm_t *osm, FILE *file)
-{
- fprintf(file, "\n==================================================="
- "====================================================\n"
- "Vendor : Ty : # : Sta : LID : LMC : MTU : LWA :"
- " LSA : Port GUID : Neighbor Port (Port #)\n");
- dump_qmap(stdout, &osm->subn.node_guid_tbl, print_node_report, osm);
-}
-
-void osm_dump_mcast_routes(osm_opensm_t * osm)
-{
- if (osm_log_is_active(&osm->log, OSM_LOG_ROUTING))
- /* multicast routes */
- osm_dump_qmap_to_file(osm, "opensm.mcfdbs",
- &osm->subn.sw_guid_tbl,
- dump_mcast_routes, osm);
-}
-
-void osm_dump_all(osm_opensm_t * osm)
-{
- if (osm_log_is_active(&osm->log, OSM_LOG_ROUTING)) {
- /* unicast routes */
- osm_dump_qmap_to_file(osm, "opensm-lid-matrix.dump",
- &osm->subn.sw_guid_tbl, dump_lid_matrix,
- osm);
- osm_dump_qmap_to_file(osm, "opensm-lfts.dump",
- &osm->subn.sw_guid_tbl, dump_ucast_lfts,
- osm);
- if (osm_log_is_active(&osm->log, OSM_LOG_DEBUG))
- dump_qmap(stdout, &osm->subn.sw_guid_tbl,
- dump_ucast_path_distribution, osm);
- osm_dump_qmap_to_file(osm, "opensm.fdbs",
- &osm->subn.sw_guid_tbl,
- dump_ucast_routes, osm);
- /* multicast routes */
- osm_dump_qmap_to_file(osm, "opensm.mcfdbs",
- &osm->subn.sw_guid_tbl,
- dump_mcast_routes, osm);
- }
- osm_dump_qmap_to_file(osm, "opensm-subnet.lst",
- &osm->subn.node_guid_tbl, dump_topology_node,
- osm);
- if (osm_log_is_active(&osm->log, OSM_LOG_VERBOSE))
- print_report(osm, stdout);
-}
diff --git a/contrib/ofed/management/opensm/opensm/osm_event_plugin.c b/contrib/ofed/management/opensm/opensm/osm_event_plugin.c
deleted file mode 100644
index b0dc549..0000000
--- a/contrib/ofed/management/opensm/opensm/osm_event_plugin.c
+++ /dev/null
@@ -1,150 +0,0 @@
-/*
- * Copyright (c) 2008 Voltaire, Inc. All rights reserved.
- * Copyright (c) 2007 The Regents of the University of California.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- */
-
-/****h* OpenSM Event plugin interface
-* DESCRIPTION
-* Database interface to record subnet events
-*
-* Implementations of this object _MUST_ be thread safe.
-*
-* AUTHOR
-* Ira Weiny, LLNL
-*
-*********/
-
-#if HAVE_CONFIG_H
-# include <config.h>
-#endif /* HAVE_CONFIG_H */
-
-#include <stdlib.h>
-#include <dlfcn.h>
-#include <opensm/osm_event_plugin.h>
-#include <opensm/osm_opensm.h>
-
-#if defined(PATH_MAX)
-#define OSM_PATH_MAX (PATH_MAX + 1)
-#elif defined (_POSIX_PATH_MAX)
-#define OSM_PATH_MAX (_POSIX_PATH_MAX + 1)
-#else
-#define OSM_PATH_MAX 256
-#endif
-
-/**
- * functions
- */
-osm_epi_plugin_t *osm_epi_construct(osm_opensm_t *osm, char *plugin_name)
-{
- char lib_name[OSM_PATH_MAX];
- struct old_if { unsigned ver; } *old_impl;
- osm_epi_plugin_t *rc = NULL;
-
- if (!plugin_name || !*plugin_name)
- return (NULL);
-
- /* find the plugin */
- snprintf(lib_name, OSM_PATH_MAX, "lib%s.so", plugin_name);
-
- rc = malloc(sizeof(*rc));
- if (!rc)
- return (NULL);
-
- rc->handle = dlopen(lib_name, RTLD_LAZY);
- if (!rc->handle) {
- OSM_LOG(&osm->log, OSM_LOG_ERROR,
- "Failed to open event plugin \"%s\" : \"%s\"\n",
- lib_name, dlerror());
- goto DLOPENFAIL;
- }
-
- rc->impl =
- (osm_event_plugin_t *) dlsym(rc->handle,
- OSM_EVENT_PLUGIN_IMPL_NAME);
- if (!rc->impl) {
- OSM_LOG(&osm->log, OSM_LOG_ERROR,
- "Failed to find \"%s\" symbol in \"%s\" : \"%s\"\n",
- OSM_EVENT_PLUGIN_IMPL_NAME, lib_name, dlerror());
- goto Exit;
- }
-
- /* check for old interface */
- old_impl = (struct old_if *) rc->impl;
- if (old_impl->ver == OSM_ORIG_EVENT_PLUGIN_INTERFACE_VER) {
- OSM_LOG(&osm->log, OSM_LOG_ERROR, "Error loading plugin: "
- "\'%s\' contains a depricated interface version %d\n"
- " Please recompile with the new interface.\n",
- plugin_name, old_impl->ver);
- goto Exit;
- }
-
- /* Check the version to make sure this module will work with us */
- if (strcmp(rc->impl->osm_version, osm->osm_version)) {
- OSM_LOG(&osm->log, OSM_LOG_ERROR, "Error loading plugin"
- " \'%s\': OpenSM version mismatch - plugin was built"
- " against %s version of OpenSM. Skip loading.\n",
- plugin_name, rc->impl->osm_version);
- goto Exit;
- }
-
- if (!rc->impl->create) {
- OSM_LOG(&osm->log, OSM_LOG_ERROR,
- "Error loading plugin \'%s\': no create() method.\n",
- plugin_name);
- goto Exit;
- }
-
- rc->plugin_data = rc->impl->create(osm);
-
- if (!rc->plugin_data)
- goto Exit;
-
- rc->plugin_name = strdup(plugin_name);
- return (rc);
-
-Exit:
- dlclose(rc->handle);
-DLOPENFAIL:
- free(rc);
- return (NULL);
-}
-
-void osm_epi_destroy(osm_epi_plugin_t * plugin)
-{
- if (plugin) {
- if (plugin->impl->delete)
- plugin->impl->delete(plugin->plugin_data);
- dlclose(plugin->handle);
- free(plugin->plugin_name);
- free(plugin);
- }
-}
diff --git a/contrib/ofed/management/opensm/opensm/osm_helper.c b/contrib/ofed/management/opensm/opensm/osm_helper.c
deleted file mode 100644
index 51fb894..0000000
--- a/contrib/ofed/management/opensm/opensm/osm_helper.c
+++ /dev/null
@@ -1,2334 +0,0 @@
-/*
- * Copyright (c) 2004-2008 Voltaire, Inc. All rights reserved.
- * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved.
- * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- */
-
-/*
- * Abstract:
- * Implementation of opensm helper functions.
- */
-
-#if HAVE_CONFIG_H
-# include <config.h>
-#endif /* HAVE_CONFIG_H */
-
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-#include <arpa/inet.h>
-#include <sys/socket.h>
-#include <complib/cl_debug.h>
-#include <iba/ib_types.h>
-#include <opensm/osm_helper.h>
-#include <opensm/osm_log.h>
-
-#define LINE_LENGTH 256
-
-#define ARR_SIZE(a) (sizeof(a)/sizeof((a)[0]))
-
-/* we use two tables - one for queries and one for responses */
-static const char *const __ib_sa_method_str[] = {
- "RESERVED", /* 0 */
- "SubnAdmGet", /* 1 */
- "SubnAdmSet", /* 2 */
- "RESERVED", /* 3 */
- "RESERVED", /* 4 */
- "RESERVED", /* 5 */
- "SubnAdmReport", /* 6 */
- "RESERVED", /* 7 */
- "RESERVED", /* 8 */
- "RESERVED", /* 9 */
- "RESERVED", /* A */
- "RESERVED", /* B */
- "RESERVED", /* C */
- "RESERVED", /* D */
- "RESERVED", /* E */
- "RESERVED", /* F */
- "RESERVED", /* 10 */
- "RESERVED", /* 11 */
- "SubnAdmGetTable", /* 12 */
- "SubnAdmGetTraceTable", /* 13 */
- "SubnAdmGetMulti", /* 14 */
- "SubnAdmDelete", /* 15 */
- "UNKNOWN" /* 16 */
-};
-
-static const char *const __ib_sa_resp_method_str[] = {
- "RESERVED", /* 80 */
- "SubnAdmGetResp", /* 81 */
- "RESERVED (SetResp?)", /* 82 */
- "RESERVED", /* 83 */
- "RESERVED", /* 84 */
- "RESERVED", /* 85 */
- "SubnAdmReportResp", /* 86 */
- "RESERVED", /* 87 */
- "RESERVED", /* 88 */
- "RESERVED", /* 89 */
- "RESERVED", /* 8A */
- "RESERVED", /* 8B */
- "RESERVED", /* 8C */
- "RESERVED", /* 8D */
- "RESERVED", /* 8E */
- "RESERVED", /* 8F */
- "RESERVED", /* 90 */
- "RESERVED", /* 91 */
- "SubnAdmGetTableResp", /* 92 */
- "RESERVED", /* 93 */
- "SubnAdmGetMultiResp", /* 94 */
- "SubnAdmDeleteResp", /* 95 */
- "UNKNOWN"
-};
-
-#define OSM_SA_METHOD_STR_UNKNOWN_VAL 0x16
-
-static const char *const __ib_sm_method_str[] = {
- "RESERVED0", /* 0 */
- "SubnGet", /* 1 */
- "SubnSet", /* 2 */
- "RESERVED3", /* 3 */
- "RESERVED4", /* 4 */
- "SubnTrap", /* 5 */
- "RESERVED6", /* 6 */
- "SubnTrapRepress", /* 7 */
- "RESERVED8", /* 8 */
- "RESERVED9", /* 9 */
- "RESERVEDA", /* A */
- "RESERVEDB", /* B */
- "RESERVEDC", /* C */
- "RESERVEDD", /* D */
- "RESERVEDE", /* E */
- "RESERVEDF", /* F */
- "RESERVED10", /* 10 */
- "SubnGetResp", /* 11 */
- "RESERVED12", /* 12 */
- "RESERVED13", /* 13 */
- "RESERVED14", /* 14 */
- "RESERVED15", /* 15 */
- "RESERVED16", /* 16 */
- "RESERVED17", /* 17 */
- "RESERVED18", /* 18 */
- "RESERVED19", /* 19 */
- "RESERVED1A", /* 1A */
- "RESERVED1B", /* 1B */
- "RESERVED1C", /* 1C */
- "RESERVED1D", /* 1D */
- "RESERVED1E", /* 1E */
- "RESERVED1F", /* 1F */
- "UNKNOWN" /* 20 */
-};
-
-#define OSM_SM_METHOD_STR_UNKNOWN_VAL 0x21
-
-static const char *const __ib_sm_attr_str[] = {
- "RESERVED", /* 0 */
- "ClassPortInfo", /* 1 */
- "Notice", /* 2 */
- "InformInfo", /* 3 */
- "RESERVED", /* 4 */
- "RESERVED", /* 5 */
- "RESERVED", /* 6 */
- "RESERVED", /* 7 */
- "RESERVED", /* 8 */
- "RESERVED", /* 9 */
- "RESERVED", /* A */
- "RESERVED", /* B */
- "RESERVED", /* C */
- "RESERVED", /* D */
- "RESERVED", /* E */
- "RESERVED", /* F */
- "NodeDescription", /* 10 */
- "NodeInfo", /* 11 */
- "SwitchInfo", /* 12 */
- "UNKNOWN", /* 13 */
- "GUIDInfo", /* 14 */
- "PortInfo", /* 15 */
- "P_KeyTable", /* 16 */
- "SLtoVLMappingTable", /* 17 */
- "VLArbitrationTable", /* 18 */
- "LinearForwardingTable", /* 19 */
- "RandomForwardingTable", /* 1A */
- "MulticastForwardingTable", /* 1B */
- "UNKNOWN", /* 1C */
- "UNKNOWN", /* 1D */
- "UNKNOWN", /* 1E */
- "UNKNOWN", /* 1F */
- "SMInfo", /* 20 */
- "UNKNOWN" /* 21 - always highest value */
-};
-
-#define OSM_SM_ATTR_STR_UNKNOWN_VAL 0x21
-
-static const char *const __ib_sa_attr_str[] = {
- "RESERVED", /* 0 */
- "ClassPortInfo", /* 1 */
- "Notice", /* 2 */
- "InformInfo", /* 3 */
- "RESERVED", /* 4 */
- "RESERVED", /* 5 */
- "RESERVED", /* 6 */
- "RESERVED", /* 7 */
- "RESERVED", /* 8 */
- "RESERVED", /* 9 */
- "RESERVED", /* A */
- "RESERVED", /* B */
- "RESERVED", /* C */
- "RESERVED", /* D */
- "RESERVED", /* E */
- "RESERVED", /* F */
- "RESERVED", /* 10 */
- "NodeRecord", /* 11 */
- "PortInfoRecord", /* 12 */
- "SLtoVLMappingTableRecord", /* 13 */
- "SwitchInfoRecord", /* 14 */
- "LinearForwardingTableRecord", /* 15 */
- "RandomForwardingTableRecord", /* 16 */
- "MulticastForwardingTableRecord", /* 17 */
- "SMInfoRecord", /* 18 */
- "RESERVED", /* 19 */
- "RandomForwardingTable", /* 1A */
- "MulticastForwardingTable", /* 1B */
- "UNKNOWN", /* 1C */
- "UNKNOWN", /* 1D */
- "UNKNOWN", /* 1E */
- "UNKNOWN", /* 1F */
- "LinkRecord", /* 20 */
- "UNKNOWN", /* 21 */
- "UNKNOWN", /* 22 */
- "UNKNOWN", /* 23 */
- "UNKNOWN", /* 24 */
- "UNKNOWN", /* 25 */
- "UNKNOWN", /* 26 */
- "UNKNOWN", /* 27 */
- "UNKNOWN", /* 28 */
- "UNKNOWN", /* 29 */
- "UNKNOWN", /* 2A */
- "UNKNOWN", /* 2B */
- "UNKNOWN", /* 2C */
- "UNKNOWN", /* 2D */
- "UNKNOWN", /* 2E */
- "UNKNOWN", /* 2F */
- "GuidInfoRecord", /* 30 */
- "ServiceRecord", /* 31 */
- "UNKNOWN", /* 32 */
- "P_KeyTableRecord", /* 33 */
- "UNKNOWN", /* 34 */
- "PathRecord", /* 35 */
- "VLArbitrationTableRecord", /* 36 */
- "UNKNOWN", /* 37 */
- "MCMemberRecord", /* 38 */
- "TraceRecord", /* 39 */
- "MultiPathRecord", /* 3A */
- "ServiceAssociationRecord", /* 3B */
- "UNKNOWN", /* 3C */
- "UNKNOWN", /* 3D */
- "UNKNOWN", /* 3E */
- "UNKNOWN", /* 3F */
- "UNKNOWN", /* 40 */
- "UNKNOWN", /* 41 */
- "UNKNOWN", /* 42 */
- "UNKNOWN", /* 43 */
- "UNKNOWN", /* 44 */
- "UNKNOWN", /* 45 */
- "UNKNOWN", /* 46 */
- "UNKNOWN", /* 47 */
- "UNKNOWN", /* 48 */
- "UNKNOWN", /* 49 */
- "UNKNOWN", /* 4A */
- "UNKNOWN", /* 4B */
- "UNKNOWN", /* 4C */
- "UNKNOWN", /* 4D */
- "UNKNOWN", /* 4E */
- "UNKNOWN", /* 4F */
- "UNKNOWN", /* 50 */
- "UNKNOWN", /* 51 */
- "UNKNOWN", /* 52 */
- "UNKNOWN", /* 53 */
- "UNKNOWN", /* 54 */
- "UNKNOWN", /* 55 */
- "UNKNOWN", /* 56 */
- "UNKNOWN", /* 57 */
- "UNKNOWN", /* 58 */
- "UNKNOWN", /* 59 */
- "UNKNOWN", /* 5A */
- "UNKNOWN", /* 5B */
- "UNKNOWN", /* 5C */
- "UNKNOWN", /* 5D */
- "UNKNOWN", /* 5E */
- "UNKNOWN", /* 5F */
- "UNKNOWN", /* 60 */
- "UNKNOWN", /* 61 */
- "UNKNOWN", /* 62 */
- "UNKNOWN", /* 63 */
- "UNKNOWN", /* 64 */
- "UNKNOWN", /* 65 */
- "UNKNOWN", /* 66 */
- "UNKNOWN", /* 67 */
- "UNKNOWN", /* 68 */
- "UNKNOWN", /* 69 */
- "UNKNOWN", /* 6A */
- "UNKNOWN", /* 6B */
- "UNKNOWN", /* 6C */
- "UNKNOWN", /* 6D */
- "UNKNOWN", /* 6E */
- "UNKNOWN", /* 6F */
- "UNKNOWN", /* 70 */
- "UNKNOWN", /* 71 */
- "UNKNOWN", /* 72 */
- "UNKNOWN", /* 73 */
- "UNKNOWN", /* 74 */
- "UNKNOWN", /* 75 */
- "UNKNOWN", /* 76 */
- "UNKNOWN", /* 77 */
- "UNKNOWN", /* 78 */
- "UNKNOWN", /* 79 */
- "UNKNOWN", /* 7A */
- "UNKNOWN", /* 7B */
- "UNKNOWN", /* 7C */
- "UNKNOWN", /* 7D */
- "UNKNOWN", /* 7E */
- "UNKNOWN", /* 7F */
- "UNKNOWN", /* 80 */
- "UNKNOWN", /* 81 */
- "UNKNOWN", /* 82 */
- "UNKNOWN", /* 83 */
- "UNKNOWN", /* 84 */
- "UNKNOWN", /* 85 */
- "UNKNOWN", /* 86 */
- "UNKNOWN", /* 87 */
- "UNKNOWN", /* 88 */
- "UNKNOWN", /* 89 */
- "UNKNOWN", /* 8A */
- "UNKNOWN", /* 8B */
- "UNKNOWN", /* 8C */
- "UNKNOWN", /* 8D */
- "UNKNOWN", /* 8E */
- "UNKNOWN", /* 8F */
- "UNKNOWN", /* 90 */
- "UNKNOWN", /* 91 */
- "UNKNOWN", /* 92 */
- "UNKNOWN", /* 93 */
- "UNKNOWN", /* 94 */
- "UNKNOWN", /* 95 */
- "UNKNOWN", /* 96 */
- "UNKNOWN", /* 97 */
- "UNKNOWN", /* 98 */
- "UNKNOWN", /* 99 */
- "UNKNOWN", /* 9A */
- "UNKNOWN", /* 9B */
- "UNKNOWN", /* 9C */
- "UNKNOWN", /* 9D */
- "UNKNOWN", /* 9E */
- "UNKNOWN", /* 9F */
- "UNKNOWN", /* A0 */
- "UNKNOWN", /* A1 */
- "UNKNOWN", /* A2 */
- "UNKNOWN", /* A3 */
- "UNKNOWN", /* A4 */
- "UNKNOWN", /* A5 */
- "UNKNOWN", /* A6 */
- "UNKNOWN", /* A7 */
- "UNKNOWN", /* A8 */
- "UNKNOWN", /* A9 */
- "UNKNOWN", /* AA */
- "UNKNOWN", /* AB */
- "UNKNOWN", /* AC */
- "UNKNOWN", /* AD */
- "UNKNOWN", /* AE */
- "UNKNOWN", /* AF */
- "UNKNOWN", /* B0 */
- "UNKNOWN", /* B1 */
- "UNKNOWN", /* B2 */
- "UNKNOWN", /* B3 */
- "UNKNOWN", /* B4 */
- "UNKNOWN", /* B5 */
- "UNKNOWN", /* B6 */
- "UNKNOWN", /* B7 */
- "UNKNOWN", /* B8 */
- "UNKNOWN", /* B9 */
- "UNKNOWN", /* BA */
- "UNKNOWN", /* BB */
- "UNKNOWN", /* BC */
- "UNKNOWN", /* BD */
- "UNKNOWN", /* BE */
- "UNKNOWN", /* BF */
- "UNKNOWN", /* C0 */
- "UNKNOWN", /* C1 */
- "UNKNOWN", /* C2 */
- "UNKNOWN", /* C3 */
- "UNKNOWN", /* C4 */
- "UNKNOWN", /* C5 */
- "UNKNOWN", /* C6 */
- "UNKNOWN", /* C7 */
- "UNKNOWN", /* C8 */
- "UNKNOWN", /* C9 */
- "UNKNOWN", /* CA */
- "UNKNOWN", /* CB */
- "UNKNOWN", /* CC */
- "UNKNOWN", /* CD */
- "UNKNOWN", /* CE */
- "UNKNOWN", /* CF */
- "UNKNOWN", /* D0 */
- "UNKNOWN", /* D1 */
- "UNKNOWN", /* D2 */
- "UNKNOWN", /* D3 */
- "UNKNOWN", /* D4 */
- "UNKNOWN", /* D5 */
- "UNKNOWN", /* D6 */
- "UNKNOWN", /* D7 */
- "UNKNOWN", /* D8 */
- "UNKNOWN", /* D9 */
- "UNKNOWN", /* DA */
- "UNKNOWN", /* DB */
- "UNKNOWN", /* DC */
- "UNKNOWN", /* DD */
- "UNKNOWN", /* DE */
- "UNKNOWN", /* DF */
- "UNKNOWN", /* E0 */
- "UNKNOWN", /* E1 */
- "UNKNOWN", /* E2 */
- "UNKNOWN", /* E3 */
- "UNKNOWN", /* E4 */
- "UNKNOWN", /* E5 */
- "UNKNOWN", /* E6 */
- "UNKNOWN", /* E7 */
- "UNKNOWN", /* E8 */
- "UNKNOWN", /* E9 */
- "UNKNOWN", /* EA */
- "UNKNOWN", /* EB */
- "UNKNOWN", /* EC */
- "UNKNOWN", /* ED */
- "UNKNOWN", /* EE */
- "UNKNOWN", /* EF */
- "UNKNOWN", /* F0 */
- "UNKNOWN", /* F1 */
- "UNKNOWN", /* F2 */
- "InformInfoRecord", /* F3 */
- "UNKNOWN" /* F4 - always highest value */
-};
-
-#define OSM_SA_ATTR_STR_UNKNOWN_VAL 0xF4
-
-/**********************************************************************
- **********************************************************************/
-const char *ib_get_sa_method_str(IN uint8_t method)
-{
- if (method & 0x80) {
- method = method & 0x7f;
- if (method >= OSM_SA_METHOD_STR_UNKNOWN_VAL)
- method = OSM_SA_METHOD_STR_UNKNOWN_VAL;
- /* it is a response - use the response table */
- return (__ib_sa_resp_method_str[method]);
- } else {
- if (method >= OSM_SA_METHOD_STR_UNKNOWN_VAL)
- method = OSM_SA_METHOD_STR_UNKNOWN_VAL;
- return (__ib_sa_method_str[method]);
- }
-}
-
-/**********************************************************************
- **********************************************************************/
-const char *ib_get_sm_method_str(IN uint8_t method)
-{
- if (method & 0x80)
- method = (method & 0x0F) | 0x10;
- if (method >= OSM_SM_METHOD_STR_UNKNOWN_VAL)
- method = OSM_SM_METHOD_STR_UNKNOWN_VAL;
- return (__ib_sm_method_str[method]);
-}
-
-/**********************************************************************
- **********************************************************************/
-const char *ib_get_sm_attr_str(IN ib_net16_t attr)
-{
- uint16_t host_attr;
- host_attr = cl_ntoh16(attr);
-
- if (host_attr >= OSM_SM_ATTR_STR_UNKNOWN_VAL)
- host_attr = OSM_SM_ATTR_STR_UNKNOWN_VAL;
-
- return (__ib_sm_attr_str[host_attr]);
-}
-
-/**********************************************************************
- **********************************************************************/
-const char *ib_get_sa_attr_str(IN ib_net16_t attr)
-{
- uint16_t host_attr;
- host_attr = cl_ntoh16(attr);
-
- if (host_attr >= OSM_SA_ATTR_STR_UNKNOWN_VAL)
- host_attr = OSM_SA_ATTR_STR_UNKNOWN_VAL;
-
- return (__ib_sa_attr_str[host_attr]);
-}
-
-/**********************************************************************
- **********************************************************************/
-const char *ib_get_trap_str(ib_net16_t trap_num)
-{
- switch(cl_ntoh16(trap_num))
- {
- case 64:
- return "GID in service";
- case 65:
- return "GID out of service";
- case 66:
- return "New mcast group created";
- case 67:
- return "Mcast group deleted";
- case 68:
- return "UnPath, Path no longer valid";
- case 69:
- return "RePath, Path recomputed";
- case 128:
- return "Link state change";
- case 129:
- return "Local Link integrity threshold reached";
- case 130:
- return "Excessive Buffer Overrun Threshold reached";
- case 131:
- return "Flow Control Update watchdog timer expired";
- case 144:
- return "CapabilityMask, NodeDescription, Link [Width|Speed] Enabled changed";
- case 145:
- return "System Image GUID changed";
- case 256:
- return "Bad M_Key";
- case 257:
- return "Bad P_Key";
- case 258:
- return "Bad Q_Key";
- case 259:
- return "Bad P_Key (switch external port)";
- default:
- break;
- }
- return "Unknown";
-}
-
-/**********************************************************************
- **********************************************************************/
-static ib_api_status_t
-dbg_do_line(IN char **pp_local,
- IN const uint32_t buf_size,
- IN const char *const p_prefix_str,
- IN const char *const p_new_str, IN uint32_t * const p_total_len)
-{
- char line[LINE_LENGTH];
- uint32_t len;
-
- sprintf(line, "%s%s", p_prefix_str, p_new_str);
- len = (uint32_t) strlen(line);
- *p_total_len += len;
- if (*p_total_len + sizeof('\0') > buf_size)
- return (IB_INSUFFICIENT_MEMORY);
-
- strcpy(*pp_local, line);
- *pp_local += len;
- return (IB_SUCCESS);
-}
-
-/**********************************************************************
- **********************************************************************/
-static void
-dbg_get_capabilities_str(IN char *p_buf,
- IN const uint32_t buf_size,
- IN const char *const p_prefix_str,
- IN const ib_port_info_t * const p_pi)
-{
- uint32_t total_len = 0;
- char *p_local = p_buf;
-
- strcpy(p_local, "Capability Mask:\n");
- p_local += strlen(p_local);
-
- if (p_pi->capability_mask & IB_PORT_CAP_RESV0) {
- if (dbg_do_line(&p_local, buf_size, p_prefix_str,
- "IB_PORT_CAP_RESV0\n",
- &total_len) != IB_SUCCESS)
- return;
- }
- if (p_pi->capability_mask & IB_PORT_CAP_IS_SM) {
- if (dbg_do_line(&p_local, buf_size, p_prefix_str,
- "IB_PORT_CAP_IS_SM\n",
- &total_len) != IB_SUCCESS)
- return;
- }
- if (p_pi->capability_mask & IB_PORT_CAP_HAS_NOTICE) {
- if (dbg_do_line(&p_local, buf_size, p_prefix_str,
- "IB_PORT_CAP_HAS_NOTICE\n",
- &total_len) != IB_SUCCESS)
- return;
- }
- if (p_pi->capability_mask & IB_PORT_CAP_HAS_TRAP) {
- if (dbg_do_line(&p_local, buf_size, p_prefix_str,
- "IB_PORT_CAP_HAS_TRAP\n",
- &total_len) != IB_SUCCESS)
- return;
- }
- if (p_pi->capability_mask & IB_PORT_CAP_HAS_IPD) {
- if (dbg_do_line(&p_local, buf_size, p_prefix_str,
- "IB_PORT_CAP_HAS_IPD\n",
- &total_len) != IB_SUCCESS)
- return;
- }
- if (p_pi->capability_mask & IB_PORT_CAP_HAS_AUTO_MIG) {
- if (dbg_do_line(&p_local, buf_size, p_prefix_str,
- "IB_PORT_CAP_HAS_AUTO_MIG\n",
- &total_len) != IB_SUCCESS)
- return;
- }
- if (p_pi->capability_mask & IB_PORT_CAP_HAS_SL_MAP) {
- if (dbg_do_line(&p_local, buf_size, p_prefix_str,
- "IB_PORT_CAP_HAS_SL_MAP\n",
- &total_len) != IB_SUCCESS)
- return;
- }
- if (p_pi->capability_mask & IB_PORT_CAP_HAS_NV_MKEY) {
- if (dbg_do_line(&p_local, buf_size, p_prefix_str,
- "IB_PORT_CAP_HAS_NV_MKEY\n",
- &total_len) != IB_SUCCESS)
- return;
- }
- if (p_pi->capability_mask & IB_PORT_CAP_HAS_NV_PKEY) {
- if (dbg_do_line(&p_local, buf_size, p_prefix_str,
- "IB_PORT_CAP_HAS_NV_PKEY\n",
- &total_len) != IB_SUCCESS)
- return;
- }
- if (p_pi->capability_mask & IB_PORT_CAP_HAS_LED_INFO) {
- if (dbg_do_line(&p_local, buf_size, p_prefix_str,
- "IB_PORT_CAP_HAS_LED_INFO\n",
- &total_len) != IB_SUCCESS)
- return;
- }
- if (p_pi->capability_mask & IB_PORT_CAP_SM_DISAB) {
- if (dbg_do_line(&p_local, buf_size, p_prefix_str,
- "IB_PORT_CAP_SM_DISAB\n",
- &total_len) != IB_SUCCESS)
- return;
- }
- if (p_pi->capability_mask & IB_PORT_CAP_HAS_SYS_IMG_GUID) {
- if (dbg_do_line(&p_local, buf_size, p_prefix_str,
- "IB_PORT_CAP_HAS_SYS_IMG_GUID\n",
- &total_len) != IB_SUCCESS)
- return;
- }
- if (p_pi->capability_mask & IB_PORT_CAP_HAS_PKEY_SW_EXT_PORT_TRAP) {
- if (dbg_do_line(&p_local, buf_size, p_prefix_str,
- "IB_PORT_CAP_PKEY_SW_EXT_PORT_TRAP\n",
- &total_len) != IB_SUCCESS)
- return;
- }
- if (p_pi->capability_mask & IB_PORT_CAP_RESV13) {
- if (dbg_do_line(&p_local, buf_size, p_prefix_str,
- "IB_PORT_CAP_RESV13\n",
- &total_len) != IB_SUCCESS)
- return;
- }
- if (p_pi->capability_mask & IB_PORT_CAP_RESV14) {
- if (dbg_do_line(&p_local, buf_size, p_prefix_str,
- "IB_PORT_CAP_RESV14\n",
- &total_len) != IB_SUCCESS)
- return;
- }
- if (p_pi->capability_mask & IB_PORT_CAP_RESV15) {
- if (dbg_do_line(&p_local, buf_size, p_prefix_str,
- "IB_PORT_CAP_RESV15\n",
- &total_len) != IB_SUCCESS)
- return;
- }
- if (p_pi->capability_mask & IB_PORT_CAP_HAS_COM_MGT) {
- if (dbg_do_line(&p_local, buf_size, p_prefix_str,
- "IB_PORT_CAP_HAS_COM_MGT\n",
- &total_len) != IB_SUCCESS)
- return;
- }
- if (p_pi->capability_mask & IB_PORT_CAP_HAS_SNMP) {
- if (dbg_do_line(&p_local, buf_size, p_prefix_str,
- "IB_PORT_CAP_HAS_SNMP\n",
- &total_len) != IB_SUCCESS)
- return;
- }
- if (p_pi->capability_mask & IB_PORT_CAP_REINIT) {
- if (dbg_do_line(&p_local, buf_size, p_prefix_str,
- "IB_PORT_CAP_REINIT\n",
- &total_len) != IB_SUCCESS)
- return;
- }
- if (p_pi->capability_mask & IB_PORT_CAP_HAS_DEV_MGT) {
- if (dbg_do_line(&p_local, buf_size, p_prefix_str,
- "IB_PORT_CAP_HAS_DEV_MGT\n",
- &total_len) != IB_SUCCESS)
- return;
- }
- if (p_pi->capability_mask & IB_PORT_CAP_HAS_VEND_CLS) {
- if (dbg_do_line(&p_local, buf_size, p_prefix_str,
- "IB_PORT_CAP_HAS_VEND_CLS\n",
- &total_len) != IB_SUCCESS)
- return;
- }
- if (p_pi->capability_mask & IB_PORT_CAP_HAS_DR_NTC) {
- if (dbg_do_line(&p_local, buf_size, p_prefix_str,
- "IB_PORT_CAP_HAS_DR_NTC\n",
- &total_len) != IB_SUCCESS)
- return;
- }
- if (p_pi->capability_mask & IB_PORT_CAP_HAS_CAP_NTC) {
- if (dbg_do_line(&p_local, buf_size, p_prefix_str,
- "IB_PORT_CAP_HAS_CAP_NTC\n",
- &total_len) != IB_SUCCESS)
- return;
- }
- if (p_pi->capability_mask & IB_PORT_CAP_HAS_BM) {
- if (dbg_do_line(&p_local, buf_size, p_prefix_str,
- "IB_PORT_CAP_HAS_BM\n",
- &total_len) != IB_SUCCESS)
- return;
- }
- if (p_pi->capability_mask & IB_PORT_CAP_HAS_LINK_RT_LATENCY) {
- if (dbg_do_line(&p_local, buf_size, p_prefix_str,
- "IB_PORT_CAP_HAS_LINK_RT_LATENCY\n",
- &total_len) != IB_SUCCESS)
- return;
- }
- if (p_pi->capability_mask & IB_PORT_CAP_HAS_CLIENT_REREG) {
- if (dbg_do_line(&p_local, buf_size, p_prefix_str,
- "IB_PORT_CAP_HAS_CLIENT_REREG\n",
- &total_len) != IB_SUCCESS)
- return;
- }
- if (p_pi->capability_mask & IB_PORT_CAP_HAS_OTHER_LOCAL_CHANGES_NTC) {
- if (dbg_do_line(&p_local, buf_size, p_prefix_str,
- "IB_PORT_CAP_HAS_OTHER_LOCAL_CHANGES_NTC\n",
- &total_len) != IB_SUCCESS)
- return;
- }
- if (p_pi->capability_mask & IB_PORT_CAP_HAS_LINK_SPEED_WIDTH_PAIRS_TBL) {
- if (dbg_do_line(&p_local, buf_size, p_prefix_str,
- "IB_PORT_CAP_HAS_LINK_SPEED_WIDTH_PAIRS_TBL\n",
- &total_len) != IB_SUCCESS)
- return;
- }
- if (p_pi->capability_mask & IB_PORT_CAP_RESV28) {
- if (dbg_do_line(&p_local, buf_size, p_prefix_str,
- "IB_PORT_CAP_RESV28\n",
- &total_len) != IB_SUCCESS)
- return;
- }
- if (p_pi->capability_mask & IB_PORT_CAP_RESV29) {
- if (dbg_do_line(&p_local, buf_size, p_prefix_str,
- "IB_PORT_CAP_RESV29\n",
- &total_len) != IB_SUCCESS)
- return;
- }
- if (p_pi->capability_mask & IB_PORT_CAP_RESV30) {
- if (dbg_do_line(&p_local, buf_size, p_prefix_str,
- "IB_PORT_CAP_RESV30\n",
- &total_len) != IB_SUCCESS)
- return;
- }
- if (p_pi->capability_mask & IB_PORT_CAP_RESV31) {
- if (dbg_do_line(&p_local, buf_size, p_prefix_str,
- "IB_PORT_CAP_RESV31\n",
- &total_len) != IB_SUCCESS)
- return;
- }
-}
-
-/**********************************************************************
- **********************************************************************/
-void
-osm_dump_port_info(IN osm_log_t * const p_log,
- IN const ib_net64_t node_guid,
- IN const ib_net64_t port_guid,
- IN const uint8_t port_num,
- IN const ib_port_info_t * const p_pi,
- IN const osm_log_level_t log_level)
-{
- if (osm_log_is_active(p_log, log_level)) {
- char buf[BUF_SIZE];
-
- osm_log(p_log, log_level,
- "PortInfo dump:\n"
- "\t\t\t\tport number.............%u\n"
- "\t\t\t\tnode_guid...............0x%016" PRIx64 "\n"
- "\t\t\t\tport_guid...............0x%016" PRIx64 "\n"
- "\t\t\t\tm_key...................0x%016" PRIx64 "\n"
- "\t\t\t\tsubnet_prefix...........0x%016" PRIx64 "\n"
- "\t\t\t\tbase_lid................%u\n"
- "\t\t\t\tmaster_sm_base_lid......%u\n"
- "\t\t\t\tcapability_mask.........0x%X\n"
- "\t\t\t\tdiag_code...............0x%X\n"
- "\t\t\t\tm_key_lease_period......0x%X\n"
- "\t\t\t\tlocal_port_num..........%u\n"
- "\t\t\t\tlink_width_enabled......0x%X\n"
- "\t\t\t\tlink_width_supported....0x%X\n"
- "\t\t\t\tlink_width_active.......0x%X\n"
- "\t\t\t\tlink_speed_supported....0x%X\n"
- "\t\t\t\tport_state..............%s\n"
- "\t\t\t\tstate_info2.............0x%X\n"
- "\t\t\t\tm_key_protect_bits......0x%X\n"
- "\t\t\t\tlmc.....................0x%X\n"
- "\t\t\t\tlink_speed..............0x%X\n"
- "\t\t\t\tmtu_smsl................0x%X\n"
- "\t\t\t\tvl_cap_init_type........0x%X\n"
- "\t\t\t\tvl_high_limit...........0x%X\n"
- "\t\t\t\tvl_arb_high_cap.........0x%X\n"
- "\t\t\t\tvl_arb_low_cap..........0x%X\n"
- "\t\t\t\tinit_rep_mtu_cap........0x%X\n"
- "\t\t\t\tvl_stall_life...........0x%X\n"
- "\t\t\t\tvl_enforce..............0x%X\n"
- "\t\t\t\tm_key_violations........0x%X\n"
- "\t\t\t\tp_key_violations........0x%X\n"
- "\t\t\t\tq_key_violations........0x%X\n"
- "\t\t\t\tguid_cap................0x%X\n"
- "\t\t\t\tclient_reregister.......0x%X\n"
- "\t\t\t\tsubnet_timeout..........0x%X\n"
- "\t\t\t\tresp_time_value.........0x%X\n"
- "\t\t\t\terror_threshold.........0x%X\n",
- port_num,
- cl_ntoh64(node_guid),
- cl_ntoh64(port_guid),
- cl_ntoh64(p_pi->m_key),
- cl_ntoh64(p_pi->subnet_prefix),
- cl_ntoh16(p_pi->base_lid),
- cl_ntoh16(p_pi->master_sm_base_lid),
- cl_ntoh32(p_pi->capability_mask),
- cl_ntoh16(p_pi->diag_code),
- cl_ntoh16(p_pi->m_key_lease_period),
- p_pi->local_port_num,
- p_pi->link_width_enabled,
- p_pi->link_width_supported,
- p_pi->link_width_active,
- ib_port_info_get_link_speed_sup(p_pi),
- ib_get_port_state_str(ib_port_info_get_port_state
- (p_pi)), p_pi->state_info2,
- ib_port_info_get_mpb(p_pi), ib_port_info_get_lmc(p_pi),
- p_pi->link_speed, p_pi->mtu_smsl, p_pi->vl_cap,
- p_pi->vl_high_limit, p_pi->vl_arb_high_cap,
- p_pi->vl_arb_low_cap, p_pi->mtu_cap,
- p_pi->vl_stall_life, p_pi->vl_enforce,
- cl_ntoh16(p_pi->m_key_violations),
- cl_ntoh16(p_pi->p_key_violations),
- cl_ntoh16(p_pi->q_key_violations), p_pi->guid_cap,
- ib_port_info_get_client_rereg(p_pi),
- ib_port_info_get_timeout(p_pi), p_pi->resp_time_value,
- p_pi->error_threshold);
-
- /* show the capabilities mask */
- if (p_pi->capability_mask) {
- dbg_get_capabilities_str(buf, BUF_SIZE, "\t\t\t\t",
- p_pi);
- osm_log(p_log, log_level, "%s", buf);
- }
- }
-}
-
-/**********************************************************************
- **********************************************************************/
-void
-osm_dump_portinfo_record(IN osm_log_t * const p_log,
- IN const ib_portinfo_record_t * const p_pir,
- IN const osm_log_level_t log_level)
-{
- if (osm_log_is_active(p_log, log_level)) {
- char buf[BUF_SIZE];
- const ib_port_info_t *const p_pi = &p_pir->port_info;
-
- osm_log(p_log, log_level,
- "PortInfo Record dump:\n"
- "\t\t\t\tRID\n"
- "\t\t\t\tEndPortLid..............%u\n"
- "\t\t\t\tPortNum.................0x%X\n"
- "\t\t\t\tReserved................0x%X\n"
- "\t\t\t\tPortInfo dump:\n"
- "\t\t\t\tm_key...................0x%016" PRIx64 "\n"
- "\t\t\t\tsubnet_prefix...........0x%016" PRIx64 "\n"
- "\t\t\t\tbase_lid................%u\n"
- "\t\t\t\tmaster_sm_base_lid......%u\n"
- "\t\t\t\tcapability_mask.........0x%X\n"
- "\t\t\t\tdiag_code...............0x%X\n"
- "\t\t\t\tm_key_lease_period......0x%X\n"
- "\t\t\t\tlocal_port_num..........%u\n"
- "\t\t\t\tlink_width_enabled......0x%X\n"
- "\t\t\t\tlink_width_supported....0x%X\n"
- "\t\t\t\tlink_width_active.......0x%X\n"
- "\t\t\t\tlink_speed_supported....0x%X\n"
- "\t\t\t\tport_state..............%s\n"
- "\t\t\t\tstate_info2.............0x%X\n"
- "\t\t\t\tm_key_protect_bits......0x%X\n"
- "\t\t\t\tlmc.....................0x%X\n"
- "\t\t\t\tlink_speed..............0x%X\n"
- "\t\t\t\tmtu_smsl................0x%X\n"
- "\t\t\t\tvl_cap_init_type........0x%X\n"
- "\t\t\t\tvl_high_limit...........0x%X\n"
- "\t\t\t\tvl_arb_high_cap.........0x%X\n"
- "\t\t\t\tvl_arb_low_cap..........0x%X\n"
- "\t\t\t\tinit_rep_mtu_cap........0x%X\n"
- "\t\t\t\tvl_stall_life...........0x%X\n"
- "\t\t\t\tvl_enforce..............0x%X\n"
- "\t\t\t\tm_key_violations........0x%X\n"
- "\t\t\t\tp_key_violations........0x%X\n"
- "\t\t\t\tq_key_violations........0x%X\n"
- "\t\t\t\tguid_cap................0x%X\n"
- "\t\t\t\tsubnet_timeout..........0x%X\n"
- "\t\t\t\tresp_time_value.........0x%X\n"
- "\t\t\t\terror_threshold.........0x%X\n",
- cl_ntoh16(p_pir->lid),
- p_pir->port_num,
- p_pir->resv,
- cl_ntoh64(p_pi->m_key),
- cl_ntoh64(p_pi->subnet_prefix),
- cl_ntoh16(p_pi->base_lid),
- cl_ntoh16(p_pi->master_sm_base_lid),
- cl_ntoh32(p_pi->capability_mask),
- cl_ntoh16(p_pi->diag_code),
- cl_ntoh16(p_pi->m_key_lease_period),
- p_pi->local_port_num,
- p_pi->link_width_enabled,
- p_pi->link_width_supported,
- p_pi->link_width_active,
- ib_port_info_get_link_speed_sup(p_pi),
- ib_get_port_state_str(ib_port_info_get_port_state
- (p_pi)), p_pi->state_info2,
- ib_port_info_get_mpb(p_pi), ib_port_info_get_lmc(p_pi),
- p_pi->link_speed, p_pi->mtu_smsl, p_pi->vl_cap,
- p_pi->vl_high_limit, p_pi->vl_arb_high_cap,
- p_pi->vl_arb_low_cap, p_pi->mtu_cap,
- p_pi->vl_stall_life, p_pi->vl_enforce,
- cl_ntoh16(p_pi->m_key_violations),
- cl_ntoh16(p_pi->p_key_violations),
- cl_ntoh16(p_pi->q_key_violations), p_pi->guid_cap,
- ib_port_info_get_timeout(p_pi), p_pi->resp_time_value,
- p_pi->error_threshold);
-
- /* show the capabilities mask */
- if (p_pi->capability_mask) {
- dbg_get_capabilities_str(buf, BUF_SIZE, "\t\t\t\t",
- p_pi);
- osm_log(p_log, log_level, "%s", buf);
- }
- }
-}
-
-/**********************************************************************
- **********************************************************************/
-void
-osm_dump_guidinfo_record(IN osm_log_t * const p_log,
- IN const ib_guidinfo_record_t * const p_gir,
- IN const osm_log_level_t log_level)
-{
- if (osm_log_is_active(p_log, log_level)) {
- const ib_guid_info_t *const p_gi = &p_gir->guid_info;
-
- osm_log(p_log, log_level,
- "GUIDInfo Record dump:\n"
- "\t\t\t\tRID\n"
- "\t\t\t\tLid.....................%u\n"
- "\t\t\t\tBlockNum................0x%X\n"
- "\t\t\t\tReserved................0x%X\n"
- "\t\t\t\tGUIDInfo dump:\n"
- "\t\t\t\tReserved................0x%X\n"
- "\t\t\t\tGUID 0..................0x%016" PRIx64 "\n"
- "\t\t\t\tGUID 1..................0x%016" PRIx64 "\n"
- "\t\t\t\tGUID 2..................0x%016" PRIx64 "\n"
- "\t\t\t\tGUID 3..................0x%016" PRIx64 "\n"
- "\t\t\t\tGUID 4..................0x%016" PRIx64 "\n"
- "\t\t\t\tGUID 5..................0x%016" PRIx64 "\n"
- "\t\t\t\tGUID 6..................0x%016" PRIx64 "\n"
- "\t\t\t\tGUID 7..................0x%016" PRIx64 "\n",
- cl_ntoh16(p_gir->lid),
- p_gir->block_num,
- p_gir->resv,
- cl_ntoh32(p_gir->reserved),
- cl_ntoh64(p_gi->guid[0]),
- cl_ntoh64(p_gi->guid[1]),
- cl_ntoh64(p_gi->guid[2]),
- cl_ntoh64(p_gi->guid[3]),
- cl_ntoh64(p_gi->guid[4]),
- cl_ntoh64(p_gi->guid[5]),
- cl_ntoh64(p_gi->guid[6]), cl_ntoh64(p_gi->guid[7]));
- }
-}
-
-/**********************************************************************
- **********************************************************************/
-void
-osm_dump_node_info(IN osm_log_t * const p_log,
- IN const ib_node_info_t * const p_ni,
- IN const osm_log_level_t log_level)
-{
- if (osm_log_is_active(p_log, log_level)) {
- osm_log(p_log, log_level,
- "NodeInfo dump:\n"
- "\t\t\t\tbase_version............0x%X\n"
- "\t\t\t\tclass_version...........0x%X\n"
- "\t\t\t\tnode_type...............%s\n"
- "\t\t\t\tnum_ports...............%u\n"
- "\t\t\t\tsys_guid................0x%016" PRIx64 "\n"
- "\t\t\t\tnode_guid...............0x%016" PRIx64 "\n"
- "\t\t\t\tport_guid...............0x%016" PRIx64 "\n"
- "\t\t\t\tpartition_cap...........0x%X\n"
- "\t\t\t\tdevice_id...............0x%X\n"
- "\t\t\t\trevision................0x%X\n"
- "\t\t\t\tport_num................%u\n"
- "\t\t\t\tvendor_id...............0x%X\n",
- p_ni->base_version,
- p_ni->class_version,
- ib_get_node_type_str(p_ni->node_type),
- p_ni->num_ports,
- cl_ntoh64(p_ni->sys_guid),
- cl_ntoh64(p_ni->node_guid),
- cl_ntoh64(p_ni->port_guid),
- cl_ntoh16(p_ni->partition_cap),
- cl_ntoh16(p_ni->device_id),
- cl_ntoh32(p_ni->revision),
- ib_node_info_get_local_port_num(p_ni),
- cl_ntoh32(ib_node_info_get_vendor_id(p_ni)));
- }
-}
-
-/**********************************************************************
- **********************************************************************/
-void
-osm_dump_node_record(IN osm_log_t * const p_log,
- IN const ib_node_record_t * const p_nr,
- IN const osm_log_level_t log_level)
-{
- if (osm_log_is_active(p_log, log_level)) {
- char desc[sizeof(p_nr->node_desc.description) + 1];
- const ib_node_info_t *const p_ni = &p_nr->node_info;
-
- memcpy(desc, p_nr->node_desc.description,
- sizeof(p_nr->node_desc.description));
- desc[sizeof(desc) - 1] = '\0';
- osm_log(p_log, log_level,
- "Node Record dump:\n"
- "\t\t\t\tRID\n"
- "\t\t\t\tLid.....................%u\n"
- "\t\t\t\tReserved................0x%X\n"
- "\t\t\t\tNodeInfo dump:\n"
- "\t\t\t\tbase_version............0x%X\n"
- "\t\t\t\tclass_version...........0x%X\n"
- "\t\t\t\tnode_type...............%s\n"
- "\t\t\t\tnum_ports...............%u\n"
- "\t\t\t\tsys_guid................0x%016" PRIx64 "\n"
- "\t\t\t\tnode_guid...............0x%016" PRIx64 "\n"
- "\t\t\t\tport_guid...............0x%016" PRIx64 "\n"
- "\t\t\t\tpartition_cap...........0x%X\n"
- "\t\t\t\tdevice_id...............0x%X\n"
- "\t\t\t\trevision................0x%X\n"
- "\t\t\t\tport_num................%u\n"
- "\t\t\t\tvendor_id...............0x%X\n"
- "\t\t\t\tNodeDescription\n"
- "\t\t\t\t%s\n",
- cl_ntoh16(p_nr->lid),
- cl_ntoh16(p_nr->resv),
- p_ni->base_version,
- p_ni->class_version,
- ib_get_node_type_str(p_ni->node_type),
- p_ni->num_ports,
- cl_ntoh64(p_ni->sys_guid),
- cl_ntoh64(p_ni->node_guid),
- cl_ntoh64(p_ni->port_guid),
- cl_ntoh16(p_ni->partition_cap),
- cl_ntoh16(p_ni->device_id),
- cl_ntoh32(p_ni->revision),
- ib_node_info_get_local_port_num(p_ni),
- cl_ntoh32(ib_node_info_get_vendor_id(p_ni)), desc);
- }
-}
-
-/**********************************************************************
- **********************************************************************/
-void
-osm_dump_path_record(IN osm_log_t * const p_log,
- IN const ib_path_rec_t * const p_pr,
- IN const osm_log_level_t log_level)
-{
- if (osm_log_is_active(p_log, log_level)) {
- osm_log(p_log, log_level,
- "PathRecord dump:\n"
- "\t\t\t\tservice_id..............0x%016" PRIx64 "\n"
- "\t\t\t\tdgid....................0x%016" PRIx64 " : "
- "0x%016" PRIx64 "\n"
- "\t\t\t\tsgid....................0x%016" PRIx64 " : "
- "0x%016" PRIx64 "\n"
- "\t\t\t\tdlid....................%u\n"
- "\t\t\t\tslid....................%u\n"
- "\t\t\t\thop_flow_raw............0x%X\n"
- "\t\t\t\ttclass..................0x%X\n"
- "\t\t\t\tnum_path_revers.........0x%X\n"
- "\t\t\t\tpkey....................0x%X\n"
- "\t\t\t\tqos_class...............0x%X\n"
- "\t\t\t\tsl......................0x%X\n"
- "\t\t\t\tmtu.....................0x%X\n"
- "\t\t\t\trate....................0x%X\n"
- "\t\t\t\tpkt_life................0x%X\n"
- "\t\t\t\tpreference..............0x%X\n"
- "\t\t\t\tresv2...................0x%X\n"
- "\t\t\t\tresv3...................0x%X\n",
- cl_ntoh64(p_pr->service_id),
- cl_ntoh64(p_pr->dgid.unicast.prefix),
- cl_ntoh64(p_pr->dgid.unicast.interface_id),
- cl_ntoh64(p_pr->sgid.unicast.prefix),
- cl_ntoh64(p_pr->sgid.unicast.interface_id),
- cl_ntoh16(p_pr->dlid),
- cl_ntoh16(p_pr->slid),
- cl_ntoh32(p_pr->hop_flow_raw),
- p_pr->tclass,
- p_pr->num_path,
- cl_ntoh16(p_pr->pkey),
- ib_path_rec_qos_class(p_pr),
- ib_path_rec_sl(p_pr),
- p_pr->mtu,
- p_pr->rate,
- p_pr->pkt_life,
- p_pr->preference,
- *(uint32_t *) & p_pr->resv2,
- *((uint16_t *) & p_pr->resv2 + 2));
- }
-}
-
-/**********************************************************************
- **********************************************************************/
-void
-osm_dump_multipath_record(IN osm_log_t * const p_log,
- IN const ib_multipath_rec_t * const p_mpr,
- IN const osm_log_level_t log_level)
-{
- if (osm_log_is_active(p_log, log_level)) {
- char buf_line[1024];
- ib_gid_t const *p_gid = p_mpr->gids;
- int i, n = 0;
-
- if (p_mpr->sgid_count) {
- for (i = 0; i < p_mpr->sgid_count; i++) {
- n += sprintf(buf_line + n,
- "\t\t\t\tsgid%02d.................."
- "0x%016" PRIx64 " : 0x%016" PRIx64
- "\n", i + 1,
- cl_ntoh64(p_gid->unicast.prefix),
- cl_ntoh64(p_gid->unicast.
- interface_id));
- p_gid++;
- }
- }
- if (p_mpr->dgid_count) {
- for (i = 0; i < p_mpr->dgid_count; i++) {
- n += sprintf(buf_line + n,
- "\t\t\t\tdgid%02d.................."
- "0x%016" PRIx64 " : 0x%016" PRIx64
- "\n", i + 1,
- cl_ntoh64(p_gid->unicast.prefix),
- cl_ntoh64(p_gid->unicast.
- interface_id));
- p_gid++;
- }
- }
- osm_log(p_log, log_level,
- "MultiPath Record dump:\n"
- "\t\t\t\thop_flow_raw............0x%X\n"
- "\t\t\t\ttclass..................0x%X\n"
- "\t\t\t\tnum_path_revers.........0x%X\n"
- "\t\t\t\tpkey....................0x%X\n"
- "\t\t\t\tqos_class...............0x%X\n"
- "\t\t\t\tsl......................0x%X\n"
- "\t\t\t\tmtu.....................0x%X\n"
- "\t\t\t\trate....................0x%X\n"
- "\t\t\t\tpkt_life................0x%X\n"
- "\t\t\t\tindependence............0x%X\n"
- "\t\t\t\tsgid_count..............0x%X\n"
- "\t\t\t\tdgid_count..............0x%X\n"
- "\t\t\t\tservice_id..............0x%016" PRIx64 "\n"
- "%s\n",
- cl_ntoh32(p_mpr->hop_flow_raw),
- p_mpr->tclass,
- p_mpr->num_path,
- cl_ntoh16(p_mpr->pkey),
- ib_multipath_rec_qos_class(p_mpr),
- ib_multipath_rec_sl(p_mpr),
- p_mpr->mtu,
- p_mpr->rate,
- p_mpr->pkt_life,
- p_mpr->independence,
- p_mpr->sgid_count, p_mpr->dgid_count,
- cl_ntoh64(ib_multipath_rec_service_id(p_mpr)),
- buf_line);
- }
-}
-
-/**********************************************************************
- **********************************************************************/
-void
-osm_dump_mc_record(IN osm_log_t * const p_log,
- IN const ib_member_rec_t * const p_mcmr,
- IN const osm_log_level_t log_level)
-{
- if (osm_log_is_active(p_log, log_level)) {
- char gid_str[INET6_ADDRSTRLEN];
- char gid_str2[INET6_ADDRSTRLEN];
- osm_log(p_log, log_level,
- "MCMember Record dump:\n"
- "\t\t\t\tMGID....................%s\n"
- "\t\t\t\tPortGid.................%s\n"
- "\t\t\t\tqkey....................0x%X\n"
- "\t\t\t\tmlid....................0x%X\n"
- "\t\t\t\tmtu.....................0x%X\n"
- "\t\t\t\tTClass..................0x%X\n"
- "\t\t\t\tpkey....................0x%X\n"
- "\t\t\t\trate....................0x%X\n"
- "\t\t\t\tpkt_life................0x%X\n"
- "\t\t\t\tSLFlowLabelHopLimit.....0x%X\n"
- "\t\t\t\tScopeState..............0x%X\n"
- "\t\t\t\tProxyJoin...............0x%X\n",
- inet_ntop(AF_INET6, p_mcmr->mgid.raw, gid_str,
- sizeof gid_str),
- inet_ntop(AF_INET6, p_mcmr->port_gid.raw, gid_str2,
- sizeof gid_str2),
- cl_ntoh32(p_mcmr->qkey),
- cl_ntoh16(p_mcmr->mlid),
- p_mcmr->mtu,
- p_mcmr->tclass,
- cl_ntoh16(p_mcmr->pkey),
- p_mcmr->rate,
- p_mcmr->pkt_life,
- cl_ntoh32(p_mcmr->sl_flow_hop),
- p_mcmr->scope_state, p_mcmr->proxy_join);
- }
-}
-
-/**********************************************************************
- **********************************************************************/
-void
-osm_dump_service_record(IN osm_log_t * const p_log,
- IN const ib_service_record_t * const p_sr,
- IN const osm_log_level_t log_level)
-{
- if (osm_log_is_active(p_log, log_level)) {
- char gid_str[INET6_ADDRSTRLEN];
- char buf_service_key[35];
- char buf_service_name[65];
-
- sprintf(buf_service_key,
- "0x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x",
- p_sr->service_key[0],
- p_sr->service_key[1],
- p_sr->service_key[2],
- p_sr->service_key[3],
- p_sr->service_key[4],
- p_sr->service_key[5],
- p_sr->service_key[6],
- p_sr->service_key[7],
- p_sr->service_key[8],
- p_sr->service_key[9],
- p_sr->service_key[10],
- p_sr->service_key[11],
- p_sr->service_key[12],
- p_sr->service_key[13],
- p_sr->service_key[14], p_sr->service_key[15]);
- strncpy(buf_service_name, (char *)p_sr->service_name, 64);
- buf_service_name[64] = '\0';
-
- osm_log(p_log, log_level,
- "Service Record dump:\n"
- "\t\t\t\tServiceID...............0x%016" PRIx64 "\n"
- "\t\t\t\tServiceGID..............%s\n"
- "\t\t\t\tServiceP_Key............0x%X\n"
- "\t\t\t\tServiceLease............0x%X\n"
- "\t\t\t\tServiceKey..............%s\n"
- "\t\t\t\tServiceName.............%s\n"
- "\t\t\t\tServiceData8.1..........0x%X\n"
- "\t\t\t\tServiceData8.2..........0x%X\n"
- "\t\t\t\tServiceData8.3..........0x%X\n"
- "\t\t\t\tServiceData8.4..........0x%X\n"
- "\t\t\t\tServiceData8.5..........0x%X\n"
- "\t\t\t\tServiceData8.6..........0x%X\n"
- "\t\t\t\tServiceData8.7..........0x%X\n"
- "\t\t\t\tServiceData8.8..........0x%X\n"
- "\t\t\t\tServiceData8.9..........0x%X\n"
- "\t\t\t\tServiceData8.10.........0x%X\n"
- "\t\t\t\tServiceData8.11.........0x%X\n"
- "\t\t\t\tServiceData8.12.........0x%X\n"
- "\t\t\t\tServiceData8.13.........0x%X\n"
- "\t\t\t\tServiceData8.14.........0x%X\n"
- "\t\t\t\tServiceData8.15.........0x%X\n"
- "\t\t\t\tServiceData8.16.........0x%X\n"
- "\t\t\t\tServiceData16.1.........0x%X\n"
- "\t\t\t\tServiceData16.2.........0x%X\n"
- "\t\t\t\tServiceData16.3.........0x%X\n"
- "\t\t\t\tServiceData16.4.........0x%X\n"
- "\t\t\t\tServiceData16.5.........0x%X\n"
- "\t\t\t\tServiceData16.6.........0x%X\n"
- "\t\t\t\tServiceData16.7.........0x%X\n"
- "\t\t\t\tServiceData16.8.........0x%X\n"
- "\t\t\t\tServiceData32.1.........0x%X\n"
- "\t\t\t\tServiceData32.2.........0x%X\n"
- "\t\t\t\tServiceData32.3.........0x%X\n"
- "\t\t\t\tServiceData32.4.........0x%X\n"
- "\t\t\t\tServiceData64.1.........0x%016" PRIx64 "\n"
- "\t\t\t\tServiceData64.2.........0x%016" PRIx64 "\n",
- cl_ntoh64(p_sr->service_id),
- inet_ntop(AF_INET6, p_sr->service_gid.raw, gid_str,
- sizeof gid_str),
- cl_ntoh16(p_sr->service_pkey),
- cl_ntoh32(p_sr->service_lease),
- buf_service_key,
- buf_service_name,
- p_sr->service_data8[0], p_sr->service_data8[1],
- p_sr->service_data8[2], p_sr->service_data8[3],
- p_sr->service_data8[4], p_sr->service_data8[5],
- p_sr->service_data8[6], p_sr->service_data8[7],
- p_sr->service_data8[8], p_sr->service_data8[9],
- p_sr->service_data8[10], p_sr->service_data8[11],
- p_sr->service_data8[12], p_sr->service_data8[13],
- p_sr->service_data8[14], p_sr->service_data8[15],
- cl_ntoh16(p_sr->service_data16[0]),
- cl_ntoh16(p_sr->service_data16[1]),
- cl_ntoh16(p_sr->service_data16[2]),
- cl_ntoh16(p_sr->service_data16[3]),
- cl_ntoh16(p_sr->service_data16[4]),
- cl_ntoh16(p_sr->service_data16[5]),
- cl_ntoh16(p_sr->service_data16[6]),
- cl_ntoh16(p_sr->service_data16[7]),
- cl_ntoh32(p_sr->service_data32[0]),
- cl_ntoh32(p_sr->service_data32[1]),
- cl_ntoh32(p_sr->service_data32[2]),
- cl_ntoh32(p_sr->service_data32[3]),
- cl_ntoh64(p_sr->service_data64[0]),
- cl_ntoh64(p_sr->service_data64[1]));
- }
-}
-
-/**********************************************************************
- **********************************************************************/
-void
-osm_dump_inform_info(IN osm_log_t * const p_log,
- IN const ib_inform_info_t * const p_ii,
- IN const osm_log_level_t log_level)
-{
- if (osm_log_is_active(p_log, log_level)) {
- uint32_t qpn;
- uint8_t resp_time_val;
-
- ib_inform_info_get_qpn_resp_time(p_ii->g_or_v.generic.
- qpn_resp_time_val, &qpn,
- &resp_time_val);
- if (p_ii->is_generic) {
- osm_log(p_log, log_level,
- "InformInfo dump:\n"
- "\t\t\t\tgid.....................0x%016" PRIx64
- " : 0x%016" PRIx64 "\n"
- "\t\t\t\tlid_range_begin.........%u\n"
- "\t\t\t\tlid_range_end...........%u\n"
- "\t\t\t\tis_generic..............0x%X\n"
- "\t\t\t\tsubscribe...............0x%X\n"
- "\t\t\t\ttrap_type...............0x%X\n"
- "\t\t\t\ttrap_num................%u\n"
- "\t\t\t\tqpn.....................0x%06X\n"
- "\t\t\t\tresp_time_val...........0x%X\n"
- "\t\t\t\tnode_type...............0x%06X\n" "",
- cl_ntoh64(p_ii->gid.unicast.prefix),
- cl_ntoh64(p_ii->gid.unicast.interface_id),
- cl_ntoh16(p_ii->lid_range_begin),
- cl_ntoh16(p_ii->lid_range_end),
- p_ii->is_generic, p_ii->subscribe,
- cl_ntoh16(p_ii->trap_type),
- cl_ntoh16(p_ii->g_or_v.generic.trap_num),
- cl_ntoh32(qpn), resp_time_val,
- cl_ntoh32(ib_inform_info_get_prod_type(p_ii)));
- } else {
- osm_log(p_log, log_level,
- "InformInfo dump:\n"
- "\t\t\t\tgid.....................0x%016" PRIx64
- " : 0x%016" PRIx64 "\n"
- "\t\t\t\tlid_range_begin.........%u\n"
- "\t\t\t\tlid_range_end...........%u\n"
- "\t\t\t\tis_generic..............0x%X\n"
- "\t\t\t\tsubscribe...............0x%X\n"
- "\t\t\t\ttrap_type...............0x%X\n"
- "\t\t\t\tdev_id..................0x%X\n"
- "\t\t\t\tqpn.....................0x%06X\n"
- "\t\t\t\tresp_time_val...........0x%X\n"
- "\t\t\t\tvendor_id...............0x%06X\n" "",
- cl_ntoh64(p_ii->gid.unicast.prefix),
- cl_ntoh64(p_ii->gid.unicast.interface_id),
- cl_ntoh16(p_ii->lid_range_begin),
- cl_ntoh16(p_ii->lid_range_end),
- p_ii->is_generic, p_ii->subscribe,
- cl_ntoh16(p_ii->trap_type),
- cl_ntoh16(p_ii->g_or_v.vend.dev_id),
- cl_ntoh32(qpn), resp_time_val,
- cl_ntoh32(ib_inform_info_get_prod_type(p_ii)));
- }
- }
-}
-
-/**********************************************************************
- **********************************************************************/
-void
-osm_dump_inform_info_record(IN osm_log_t * const p_log,
- IN const ib_inform_info_record_t * const p_iir,
- IN const osm_log_level_t log_level)
-{
- if (osm_log_is_active(p_log, log_level)) {
- char gid_str[INET6_ADDRSTRLEN];
- char gid_str2[INET6_ADDRSTRLEN];
- uint32_t qpn;
- uint8_t resp_time_val;
-
- ib_inform_info_get_qpn_resp_time(p_iir->inform_info.g_or_v.
- generic.qpn_resp_time_val,
- &qpn, &resp_time_val);
- if (p_iir->inform_info.is_generic) {
- osm_log(p_log, log_level,
- "InformInfo Record dump:\n"
- "\t\t\t\tRID\n"
- "\t\t\t\tSubscriberGID...........%s\n"
- "\t\t\t\tSubscriberEnum..........0x%X\n"
- "\t\t\t\tInformInfo dump:\n"
- "\t\t\t\tgid.....................%s\n"
- "\t\t\t\tlid_range_begin.........%u\n"
- "\t\t\t\tlid_range_end...........%u\n"
- "\t\t\t\tis_generic..............0x%X\n"
- "\t\t\t\tsubscribe...............0x%X\n"
- "\t\t\t\ttrap_type...............0x%X\n"
- "\t\t\t\ttrap_num................%u\n"
- "\t\t\t\tqpn.....................0x%06X\n"
- "\t\t\t\tresp_time_val...........0x%X\n"
- "\t\t\t\tnode_type...............0x%06X\n" "",
- inet_ntop(AF_INET6, p_iir->subscriber_gid.raw,
- gid_str, sizeof gid_str),
- cl_ntoh16(p_iir->subscriber_enum),
- inet_ntop(AF_INET6, p_iir->inform_info.gid.raw,
- gid_str2, sizeof gid_str2),
- cl_ntoh16(p_iir->inform_info.lid_range_begin),
- cl_ntoh16(p_iir->inform_info.lid_range_end),
- p_iir->inform_info.is_generic,
- p_iir->inform_info.subscribe,
- cl_ntoh16(p_iir->inform_info.trap_type),
- cl_ntoh16(p_iir->inform_info.g_or_v.generic.
- trap_num), cl_ntoh32(qpn),
- resp_time_val,
- cl_ntoh32(ib_inform_info_get_prod_type
- (&p_iir->inform_info)));
- } else {
- osm_log(p_log, log_level,
- "InformInfo Record dump:\n"
- "\t\t\t\tRID\n"
- "\t\t\t\tSubscriberGID...........%s\n"
- "\t\t\t\tSubscriberEnum..........0x%X\n"
- "\t\t\t\tInformInfo dump:\n"
- "\t\t\t\tgid.....................%s\n"
- "\t\t\t\tlid_range_begin.........%u\n"
- "\t\t\t\tlid_range_end...........%u\n"
- "\t\t\t\tis_generic..............0x%X\n"
- "\t\t\t\tsubscribe...............0x%X\n"
- "\t\t\t\ttrap_type...............0x%X\n"
- "\t\t\t\tdev_id..................0x%X\n"
- "\t\t\t\tqpn.....................0x%06X\n"
- "\t\t\t\tresp_time_val...........0x%X\n"
- "\t\t\t\tvendor_id...............0x%06X\n" "",
- inet_ntop(AF_INET6, p_iir->subscriber_gid.raw,
- gid_str, sizeof gid_str),
- cl_ntoh16(p_iir->subscriber_enum),
- inet_ntop(AF_INET6, p_iir->inform_info.gid.raw,
- gid_str2, sizeof gid_str2),
- cl_ntoh16(p_iir->inform_info.lid_range_begin),
- cl_ntoh16(p_iir->inform_info.lid_range_end),
- p_iir->inform_info.is_generic,
- p_iir->inform_info.subscribe,
- cl_ntoh16(p_iir->inform_info.trap_type),
- cl_ntoh16(p_iir->inform_info.g_or_v.vend.
- dev_id), cl_ntoh32(qpn),
- resp_time_val,
- cl_ntoh32(ib_inform_info_get_prod_type
- (&p_iir->inform_info)));
- }
- }
-}
-
-/**********************************************************************
- **********************************************************************/
-void
-osm_dump_link_record(IN osm_log_t * const p_log,
- IN const ib_link_record_t * const p_lr,
- IN const osm_log_level_t log_level)
-{
- if (osm_log_is_active(p_log, log_level)) {
- osm_log(p_log, log_level,
- "Link Record dump:\n"
- "\t\t\t\tfrom_lid................%u\n"
- "\t\t\t\tfrom_port_num...........%u\n"
- "\t\t\t\tto_port_num.............%u\n"
- "\t\t\t\tto_lid..................%u\n",
- cl_ntoh16(p_lr->from_lid),
- p_lr->from_port_num,
- p_lr->to_port_num, cl_ntoh16(p_lr->to_lid));
- }
-}
-
-/**********************************************************************
- **********************************************************************/
-void
-osm_dump_switch_info(IN osm_log_t * const p_log,
- IN const ib_switch_info_t * const p_si,
- IN const osm_log_level_t log_level)
-{
- if (osm_log_is_active(p_log, log_level)) {
- osm_log(p_log, OSM_LOG_VERBOSE,
- "SwitchInfo dump:\n"
- "\t\t\t\tlin_cap.................0x%X\n"
- "\t\t\t\trand_cap................0x%X\n"
- "\t\t\t\tmcast_cap...............0x%X\n"
- "\t\t\t\tlin_top.................0x%X\n"
- "\t\t\t\tdef_port................%u\n"
- "\t\t\t\tdef_mcast_pri_port......%u\n"
- "\t\t\t\tdef_mcast_not_port......%u\n"
- "\t\t\t\tlife_state..............0x%X\n"
- "\t\t\t\tlids_per_port...........%u\n"
- "\t\t\t\tpartition_enf_cap.......0x%X\n"
- "\t\t\t\tflags...................0x%X\n",
- cl_ntoh16(p_si->lin_cap),
- cl_ntoh16(p_si->rand_cap),
- cl_ntoh16(p_si->mcast_cap),
- cl_ntoh16(p_si->lin_top),
- p_si->def_port,
- p_si->def_mcast_pri_port,
- p_si->def_mcast_not_port,
- p_si->life_state,
- cl_ntoh16(p_si->lids_per_port),
- cl_ntoh16(p_si->enforce_cap), p_si->flags);
- }
-}
-
-/**********************************************************************
- **********************************************************************/
-void
-osm_dump_switch_info_record(IN osm_log_t * const p_log,
- IN const ib_switch_info_record_t * const p_sir,
- IN const osm_log_level_t log_level)
-{
- if (osm_log_is_active(p_log, log_level)) {
- osm_log(p_log, log_level,
- "SwitchInfo Record dump:\n"
- "\t\t\t\tRID\n"
- "\t\t\t\tlid.....................%u\n"
- "\t\t\t\tSwitchInfo dump:\n"
- "\t\t\t\tlin_cap.................0x%X\n"
- "\t\t\t\trand_cap................0x%X\n"
- "\t\t\t\tmcast_cap...............0x%X\n"
- "\t\t\t\tlin_top.................0x%X\n"
- "\t\t\t\tdef_port................%u\n"
- "\t\t\t\tdef_mcast_pri_port......%u\n"
- "\t\t\t\tdef_mcast_not_port......%u\n"
- "\t\t\t\tlife_state..............0x%X\n"
- "\t\t\t\tlids_per_port...........%u\n"
- "\t\t\t\tpartition_enf_cap.......0x%X\n"
- "\t\t\t\tflags...................0x%X\n",
- cl_ntoh16(p_sir->lid),
- cl_ntoh16(p_sir->switch_info.lin_cap),
- cl_ntoh16(p_sir->switch_info.rand_cap),
- cl_ntoh16(p_sir->switch_info.mcast_cap),
- cl_ntoh16(p_sir->switch_info.lin_top),
- p_sir->switch_info.def_port,
- p_sir->switch_info.def_mcast_pri_port,
- p_sir->switch_info.def_mcast_not_port,
- p_sir->switch_info.life_state,
- cl_ntoh16(p_sir->switch_info.lids_per_port),
- cl_ntoh16(p_sir->switch_info.enforce_cap),
- p_sir->switch_info.flags);
- }
-}
-
-/**********************************************************************
- **********************************************************************/
-void
-osm_dump_pkey_block(IN osm_log_t * const p_log,
- IN uint64_t port_guid,
- IN uint16_t block_num,
- IN uint8_t port_num,
- IN const ib_pkey_table_t * const p_pkey_tbl,
- IN const osm_log_level_t log_level)
-{
- if (osm_log_is_active(p_log, log_level)) {
- char buf_line[1024];
- int i, n;
-
- for (i = 0, n = 0; i < 32; i++)
- n += sprintf(buf_line + n, " 0x%04x |",
- cl_ntoh16(p_pkey_tbl->pkey_entry[i]));
-
- osm_log(p_log, log_level,
- "P_Key table dump:\n"
- "\t\t\tport_guid...........0x%016" PRIx64 "\n"
- "\t\t\tblock_num...........0x%X\n"
- "\t\t\tport_num............%u\n\tP_Key Table: %s\n",
- cl_ntoh64(port_guid), block_num, port_num, buf_line);
- }
-}
-
-/**********************************************************************
- **********************************************************************/
-void
-osm_dump_slvl_map_table(IN osm_log_t * const p_log,
- IN uint64_t port_guid,
- IN uint8_t in_port_num,
- IN uint8_t out_port_num,
- IN const ib_slvl_table_t * const p_slvl_tbl,
- IN const osm_log_level_t log_level)
-{
- if (osm_log_is_active(p_log, log_level)) {
- char buf_line1[1024], buf_line2[1024];
- int n;
- uint8_t i;
-
- for (i = 0, n = 0; i < 16; i++)
- n += sprintf(buf_line1 + n, " %-2u |", i);
- for (i = 0, n = 0; i < 16; i++)
- n += sprintf(buf_line2 + n, "0x%01X |",
- ib_slvl_table_get(p_slvl_tbl, i));
- osm_log(p_log, log_level,
- "SLtoVL dump:\n"
- "\t\t\tport_guid............0x%016" PRIx64 "\n"
- "\t\t\tin_port_num..........%u\n"
- "\t\t\tout_port_num.........%u\n\tSL: | %s\n\tVL: | %s\n",
- cl_ntoh64(port_guid),
- in_port_num, out_port_num, buf_line1, buf_line2);
- }
-}
-
-/**********************************************************************
- **********************************************************************/
-void
-osm_dump_vl_arb_table(IN osm_log_t * const p_log,
- IN uint64_t port_guid,
- IN uint8_t block_num,
- IN uint8_t port_num,
- IN const ib_vl_arb_table_t * const p_vla_tbl,
- IN const osm_log_level_t log_level)
-{
- if (osm_log_is_active(p_log, log_level)) {
- char buf_line1[1024], buf_line2[1024];
- int i, n;
-
- for (i = 0, n = 0; i < 32; i++)
- n += sprintf(buf_line1 + n, " 0x%01X |",
- p_vla_tbl->vl_entry[i].vl);
- for (i = 0, n = 0; i < 32; i++)
- n += sprintf(buf_line2 + n, " 0x%01X |",
- p_vla_tbl->vl_entry[i].weight);
- osm_log(p_log, log_level,
- "VLArb dump:\n" "\t\t\tport_guid...........0x%016"
- PRIx64 "\n" "\t\t\tblock_num...........0x%X\n"
- "\t\t\tport_num............%u\n\tVL : | %s\n\tWEIGHT:| %s\n",
- cl_ntoh64(port_guid), block_num, port_num, buf_line1,
- buf_line2);
- }
-}
-
-/**********************************************************************
- **********************************************************************/
-void
-osm_dump_sm_info(IN osm_log_t * const p_log,
- IN const ib_sm_info_t * const p_smi,
- IN const osm_log_level_t log_level)
-{
- if (osm_log_is_active(p_log, log_level)) {
- osm_log(p_log, OSM_LOG_DEBUG,
- "SMInfo dump:\n"
- "\t\t\t\tguid....................0x%016" PRIx64 "\n"
- "\t\t\t\tsm_key..................0x%016" PRIx64 "\n"
- "\t\t\t\tact_count...............%u\n"
- "\t\t\t\tpriority................%u\n"
- "\t\t\t\tsm_state................%u\n",
- cl_ntoh64(p_smi->guid),
- cl_ntoh64(p_smi->sm_key),
- cl_ntoh32(p_smi->act_count),
- ib_sminfo_get_priority(p_smi),
- ib_sminfo_get_state(p_smi));
- }
-}
-
-/**********************************************************************
- **********************************************************************/
-void
-osm_dump_sm_info_record(IN osm_log_t * const p_log,
- IN const ib_sminfo_record_t * const p_smir,
- IN const osm_log_level_t log_level)
-{
- if (osm_log_is_active(p_log, log_level)) {
- osm_log(p_log, OSM_LOG_DEBUG,
- "SMInfo Record dump:\n"
- "\t\t\t\tRID\n"
- "\t\t\t\tLid.....................%u\n"
- "\t\t\t\tReserved................0x%X\n"
- "\t\t\t\tSMInfo dump:\n"
- "\t\t\t\tguid....................0x%016" PRIx64 "\n"
- "\t\t\t\tsm_key..................0x%016" PRIx64 "\n"
- "\t\t\t\tact_count...............%u\n"
- "\t\t\t\tpriority................%u\n"
- "\t\t\t\tsm_state................%u\n",
- cl_ntoh16(p_smir->lid),
- cl_ntoh16(p_smir->resv0),
- cl_ntoh64(p_smir->sm_info.guid),
- cl_ntoh64(p_smir->sm_info.sm_key),
- cl_ntoh32(p_smir->sm_info.act_count),
- ib_sminfo_get_priority(&p_smir->sm_info),
- ib_sminfo_get_state(&p_smir->sm_info));
- }
-}
-
-/**********************************************************************
- **********************************************************************/
-void
-osm_dump_notice(IN osm_log_t * const p_log,
- IN const ib_mad_notice_attr_t * p_ntci,
- IN const osm_log_level_t log_level)
-{
- if (osm_log_is_active(p_log, log_level)) {
- if (ib_notice_is_generic(p_ntci)) {
- char buff[1024];
- buff[0] = '\0';
-
- /* immediate data based on the trap */
- switch (cl_ntoh16(p_ntci->g_or_v.generic.trap_num)) {
- case 64:
- case 65:
- case 66:
- case 67:
- sprintf(buff,
- "\t\t\t\tsrc_gid..................0x%016"
- PRIx64 ":0x%016" PRIx64 "\n",
- cl_ntoh64(p_ntci->data_details.
- ntc_64_67.gid.unicast.prefix),
- cl_ntoh64(p_ntci->data_details.
- ntc_64_67.gid.unicast.
- interface_id));
- break;
- case 128:
- sprintf(buff,
- "\t\t\t\tsw_lid...................%u\n",
- cl_ntoh16(p_ntci->data_details.ntc_128.
- sw_lid));
- break;
- case 129:
- case 130:
- case 131:
- sprintf(buff,
- "\t\t\t\tlid......................%u\n"
- "\t\t\t\tport_num.................%u\n",
- cl_ntoh16(p_ntci->data_details.
- ntc_129_131.lid),
- p_ntci->data_details.ntc_129_131.
- port_num);
- break;
- case 144:
- sprintf(buff,
- "\t\t\t\tlid......................%u\n"
- "\t\t\t\tnew_cap_mask.............0x%08x\n",
- cl_ntoh16(p_ntci->data_details.ntc_144.
- lid),
- cl_ntoh32(p_ntci->data_details.ntc_144.
- new_cap_mask));
- break;
- case 145:
- sprintf(buff,
- "\t\t\t\tlid......................%u\n"
- "\t\t\t\tnew_sys_guid.............0x%016"
- PRIx64 "\n",
- cl_ntoh16(p_ntci->data_details.ntc_145.
- lid),
- cl_ntoh64(p_ntci->data_details.ntc_145.
- new_sys_guid));
- break;
- }
-
- osm_log(p_log, log_level,
- "Generic Notice dump:\n"
- "\t\t\t\ttype.....................%u\n"
- "\t\t\t\tprod_type................%u (%s)\n"
- "\t\t\t\ttrap_num.................%u\n%s",
- ib_notice_get_type(p_ntci),
- cl_ntoh32(ib_notice_get_prod_type(p_ntci)),
- ib_get_producer_type_str(ib_notice_get_prod_type
- (p_ntci)),
- cl_ntoh16(p_ntci->g_or_v.generic.trap_num),
- buff);
- } else {
- osm_log(p_log, log_level,
- "Vendor Notice dump:\n"
- "\t\t\t\ttype.....................%u\n"
- "\t\t\t\tvendor...................%u\n"
- "\t\t\t\tdevice_id................%u\n",
- cl_ntoh16(ib_notice_get_type(p_ntci)),
- cl_ntoh32(ib_notice_get_vend_id(p_ntci)),
- cl_ntoh16(p_ntci->g_or_v.vend.dev_id));
- }
- }
-}
-
-/**********************************************************************
- **********************************************************************/
-void
-osm_dump_dr_smp(IN osm_log_t * const p_log,
- IN const ib_smp_t * const p_smp,
- IN const osm_log_level_t log_level)
-{
- if (osm_log_is_active(p_log, log_level)) {
- char buf[BUF_SIZE], line[BUF_SIZE];
- uint32_t i;
-
- sprintf(buf,
- "SMP dump:\n"
- "\t\t\t\tbase_ver................0x%X\n"
- "\t\t\t\tmgmt_class..............0x%X\n"
- "\t\t\t\tclass_ver...............0x%X\n"
- "\t\t\t\tmethod..................0x%X (%s)\n",
- p_smp->base_ver,
- p_smp->mgmt_class,
- p_smp->class_ver,
- p_smp->method, ib_get_sm_method_str(p_smp->method));
-
- if (p_smp->mgmt_class == IB_MCLASS_SUBN_DIR) {
- sprintf(line,
- "\t\t\t\tD bit...................0x%X\n"
- "\t\t\t\tstatus..................0x%X\n",
- ib_smp_is_d(p_smp), ib_smp_get_status(p_smp));
- } else {
- sprintf(line,
- "\t\t\t\tstatus..................0x%X\n",
- cl_ntoh16(p_smp->status));
- }
- strcat(buf, line);
-
- sprintf(line,
- "\t\t\t\thop_ptr.................0x%X\n"
- "\t\t\t\thop_count...............0x%X\n"
- "\t\t\t\ttrans_id................0x%" PRIx64 "\n"
- "\t\t\t\tattr_id.................0x%X (%s)\n"
- "\t\t\t\tresv....................0x%X\n"
- "\t\t\t\tattr_mod................0x%X\n"
- "\t\t\t\tm_key...................0x%016" PRIx64 "\n",
- p_smp->hop_ptr,
- p_smp->hop_count,
- cl_ntoh64(p_smp->trans_id),
- cl_ntoh16(p_smp->attr_id),
- ib_get_sm_attr_str(p_smp->attr_id),
- cl_ntoh16(p_smp->resv),
- cl_ntoh32(p_smp->attr_mod), cl_ntoh64(p_smp->m_key));
- strcat(buf, line);
-
- if (p_smp->mgmt_class == IB_MCLASS_SUBN_DIR) {
- sprintf(line,
- "\t\t\t\tdr_slid.................%u\n"
- "\t\t\t\tdr_dlid.................%u\n",
- cl_ntoh16(p_smp->dr_slid),
- cl_ntoh16(p_smp->dr_dlid));
- strcat(buf, line);
-
- strcat(buf, "\n\t\t\t\tInitial path: ");
-
- for (i = 0; i <= p_smp->hop_count; i++) {
- if (i == 0)
- sprintf(line, "%d",
- p_smp->initial_path[i]);
- else
- sprintf(line, ",%d",
- p_smp->initial_path[i]);
- strcat(buf, line);
- }
-
- strcat(buf, "\n\t\t\t\tReturn path: ");
-
- for (i = 0; i <= p_smp->hop_count; i++) {
- if (i == 0)
- sprintf(line, "%d",
- p_smp->return_path[i]);
- else
- sprintf(line, ",%d",
- p_smp->return_path[i]);
- strcat(buf, line);
- }
-
- strcat(buf, "\n\t\t\t\tReserved: ");
-
- for (i = 0; i < 7; i++) {
- sprintf(line, "[%0X]", p_smp->resv1[i]);
- strcat(buf, line);
- }
-
- strcat(buf, "\n");
-
- for (i = 0; i < 64; i += 16) {
- sprintf(line, "\n\t\t\t\t%02X %02X %02X %02X "
- "%02X %02X %02X %02X"
- " %02X %02X %02X %02X %02X %02X %02X %02X\n",
- p_smp->data[i],
- p_smp->data[i + 1],
- p_smp->data[i + 2],
- p_smp->data[i + 3],
- p_smp->data[i + 4],
- p_smp->data[i + 5],
- p_smp->data[i + 6],
- p_smp->data[i + 7],
- p_smp->data[i + 8],
- p_smp->data[i + 9],
- p_smp->data[i + 10],
- p_smp->data[i + 11],
- p_smp->data[i + 12],
- p_smp->data[i + 13],
- p_smp->data[i + 14],
- p_smp->data[i + 15]);
-
- strcat(buf, line);
- }
- } else {
- /* not a Direct Route so provide source and destination lids */
- strcat(buf, "\t\t\t\tMAD IS LID ROUTED\n");
- }
-
- osm_log(p_log, log_level, "%s\n", buf);
- }
-}
-
-/**********************************************************************
- **********************************************************************/
-void
-osm_dump_sa_mad(IN osm_log_t * const p_log,
- IN const ib_sa_mad_t * const p_mad,
- IN const osm_log_level_t log_level)
-{
- if (osm_log_is_active(p_log, log_level)) {
- char buf[BUF_SIZE];
-
- /* make sure the mad is valid */
- if (p_mad == NULL) {
- OSM_LOG(p_log, log_level, "NULL MAD POINTER\n");
- return;
- }
-
- sprintf(buf,
- "SA MAD dump:\n"
- "\t\t\t\tbase_ver................0x%X\n"
- "\t\t\t\tmgmt_class..............0x%X\n"
- "\t\t\t\tclass_ver...............0x%X\n"
- "\t\t\t\tmethod..................0x%X (%s)\n"
- "\t\t\t\tstatus..................0x%X\n"
- "\t\t\t\tresv....................0x%X\n"
- "\t\t\t\ttrans_id................0x%" PRIx64 "\n"
- "\t\t\t\tattr_id.................0x%X (%s)\n"
- "\t\t\t\tresv1...................0x%X\n"
- "\t\t\t\tattr_mod................0x%X\n"
- "\t\t\t\trmpp_version............0x%X\n"
- "\t\t\t\trmpp_type...............0x%X\n"
- "\t\t\t\trmpp_flags..............0x%X\n"
- "\t\t\t\trmpp_status.............0x%X\n"
- "\t\t\t\tseg_num.................0x%X\n"
- "\t\t\t\tpayload_len/new_win.....0x%X\n"
- "\t\t\t\tsm_key..................0x%016" PRIx64 "\n"
- "\t\t\t\tattr_offset.............0x%X\n"
- "\t\t\t\tresv2...................0x%X\n"
- "\t\t\t\tcomp_mask...............0x%016" PRIx64 "\n",
- p_mad->base_ver,
- p_mad->mgmt_class,
- p_mad->class_ver,
- p_mad->method, ib_get_sa_method_str(p_mad->method),
- cl_ntoh16(p_mad->status),
- cl_ntoh16(p_mad->resv),
- cl_ntoh64(p_mad->trans_id),
- cl_ntoh16(p_mad->attr_id),
- ib_get_sa_attr_str(p_mad->attr_id),
- cl_ntoh16(p_mad->resv1),
- cl_ntoh32(p_mad->attr_mod),
- p_mad->rmpp_version,
- p_mad->rmpp_type,
- p_mad->rmpp_flags,
- p_mad->rmpp_status,
- cl_ntoh32(p_mad->seg_num),
- cl_ntoh32(p_mad->paylen_newwin),
- cl_ntoh64(p_mad->sm_key),
- cl_ntoh16(p_mad->attr_offset),
- cl_ntoh16(p_mad->resv3), cl_ntoh64(p_mad->comp_mask));
-
- strcat(buf, "\n");
-
- osm_log(p_log, log_level, "%s\n", buf);
- }
-}
-
-/**********************************************************************
- **********************************************************************/
-void
-osm_dump_dr_path(IN osm_log_t * const p_log,
- IN const osm_dr_path_t * const p_path,
- IN const osm_log_level_t log_level)
-{
- if (osm_log_is_active(p_log, log_level)) {
- char buf[BUF_SIZE], line[BUF_SIZE];
- uint32_t i;
-
- sprintf(buf, "Directed Path Dump of %u hop path:"
- "\n\t\t\t\tPath = ", p_path->hop_count);
-
- for (i = 0; i <= p_path->hop_count; i++) {
- if (i == 0)
- sprintf(line, "%d", p_path->path[i]);
- else
- sprintf(line, ",%d", p_path->path[i]);
- strcat(buf, line);
- }
- osm_log(p_log, log_level, "%s\n", buf);
- }
-}
-
-/**********************************************************************
- **********************************************************************/
-void
-osm_dump_smp_dr_path(IN osm_log_t * const p_log,
- IN const ib_smp_t * const p_smp,
- IN const osm_log_level_t log_level)
-{
- if (osm_log_is_active(p_log, log_level)) {
- char buf[BUF_SIZE], line[BUF_SIZE];
- uint32_t i;
-
- sprintf(buf, "Received SMP on a %u hop path:"
- "\n\t\t\t\tInitial path = ", p_smp->hop_count);
-
- for (i = 0; i <= p_smp->hop_count; i++) {
- if (i == 0)
- sprintf(line, "%d", p_smp->initial_path[i]);
- else
- sprintf(line, ",%d", p_smp->initial_path[i]);
- strcat(buf, line);
- }
-
- strcat(buf, "\n\t\t\t\tReturn path = ");
-
- for (i = 0; i <= p_smp->hop_count; i++) {
- if (i == 0)
- sprintf(line, "%d", p_smp->return_path[i]);
- else
- sprintf(line, ",%d", p_smp->return_path[i]);
- strcat(buf, line);
- }
-
- osm_log(p_log, log_level, "%s\n", buf);
- }
-}
-
-static const char *const __osm_sm_signal_str[] = {
- "OSM_SIGNAL_NONE", /* 0 */
- "OSM_SIGNAL_SWEEP", /* 1 */
- "OSM_SIGNAL_IDLE_TIME_PROCESS_REQUEST", /* 2 */
- "OSM_SIGNAL_EXIT_STBY", /* 3 */
- "OSM_SIGNAL_PERFMGR_SWEEP", /* 4 */
- "UNKNOWN SIGNAL!!" /* 5 */
-};
-
-/**********************************************************************
- **********************************************************************/
-const char *osm_get_sm_signal_str(IN osm_signal_t signal)
-{
- if (signal > OSM_SIGNAL_MAX)
- signal = OSM_SIGNAL_MAX;
- return (__osm_sm_signal_str[signal]);
-}
-
-/**********************************************************************
- **********************************************************************/
-
-static const char *const __osm_disp_msg_str[] = {
- "OSM_MSG_NONE",
- "OSM_MSG_MAD_NODE_INFO",
- "OSM_MSG_MAD_PORT_INFO",
- "OSM_MSG_MAD_SWITCH_INFO",
- "OSM_MSG_MAD_NODE_DESC",
- "OSM_MSG_MAD_NODE_RECORD",
- "OSM_MSG_MAD_PORTINFO_RECORD",
- "OSM_MSG_MAD_SERVICE_RECORD",
- "OSM_MSG_MAD_PATH_RECORD",
- "OSM_MSG_MAD_MCMEMBER_RECORD",
- "OSM_MSG_MAD_LINK_RECORD",
- "OSM_MSG_MAD_SMINFO_RECORD",
- "OSM_MSG_MAD_CLASS_PORT_INFO",
- "OSM_MSG_MAD_INFORM_INFO",
- "OSM_MSG_MAD_LFT_RECORD",
- "OSM_MSG_MAD_LFT",
- "OSM_MSG_MAD_SM_INFO",
- "OSM_MSG_MAD_NOTICE",
- "OSM_MSG_LIGHT_SWEEP_FAIL",
- "OSM_MSG_MAD_MFT",
- "OSM_MSG_MAD_PKEY_TBL_RECORD",
- "OSM_MSG_MAD_VL_ARB_RECORD",
- "OSM_MSG_MAD_SLVL_TBL_RECORD",
- "OSM_MSG_MAD_PKEY",
- "OSM_MSG_MAD_VL_ARB",
- "OSM_MSG_MAD_SLVL",
- "OSM_MSG_MAD_GUIDINFO_RECORD",
- "OSM_MSG_MAD_INFORM_INFO_RECORD",
-#if defined (VENDOR_RMPP_SUPPORT) && defined (DUAL_SIDED_RMPP)
- "OSM_MSG_MAD_MULTIPATH_RECORD",
-#endif
- "UNKNOWN!!"
-};
-
-/**********************************************************************
- **********************************************************************/
-const char *osm_get_disp_msg_str(IN cl_disp_msgid_t msg)
-{
- if (msg > OSM_MSG_MAX)
- msg = OSM_MSG_MAX;
- return (__osm_disp_msg_str[msg]);
-}
-
-static const char *const __osm_port_state_str_fixed_width[] = {
- "NOC",
- "DWN",
- "INI",
- "ARM",
- "ACT",
- "???"
-};
-
-/**********************************************************************
- **********************************************************************/
-const char *osm_get_port_state_str_fixed_width(IN uint8_t port_state)
-{
- if (port_state > IB_LINK_ACTIVE)
- port_state = IB_LINK_ACTIVE + 1;
- return (__osm_port_state_str_fixed_width[port_state]);
-}
-
-static const char *const __osm_node_type_str_fixed_width[] = {
- "??",
- "CA",
- "SW",
- "RT",
-};
-
-/**********************************************************************
- **********************************************************************/
-const char *osm_get_node_type_str_fixed_width(IN uint8_t node_type)
-{
- if (node_type > IB_NODE_TYPE_ROUTER)
- node_type = 0;
- return (__osm_node_type_str_fixed_width[node_type]);
-}
-
-/**********************************************************************
- **********************************************************************/
-const char *osm_get_manufacturer_str(IN uint64_t const guid_ho)
-{
- /* note that the max vendor string length is 11 */
- static const char *intel_str = "Intel";
- static const char *mellanox_str = "Mellanox";
- static const char *redswitch_str = "Redswitch";
- static const char *silverstorm_str = "SilverStorm";
- static const char *topspin_str = "Topspin";
- static const char *fujitsu_str = "Fujitsu";
- static const char *voltaire_str = "Voltaire";
- static const char *yotta_str = "YottaYotta";
- static const char *pathscale_str = "PathScale";
- static const char *ibm_str = "IBM";
- static const char *divergenet_str = "DivergeNet";
- static const char *flextronics_str = "Flextronics";
- static const char *agilent_str = "Agilent";
- static const char *obsidian_str = "Obsidian";
- static const char *baymicro_str = "BayMicro";
- static const char *lsilogic_str = "LSILogic";
- static const char *ddn_str = "DataDirect";
- static const char *panta_str = "Panta";
- static const char *hp_str = "HP";
- static const char *rioworks_str = "Rioworks";
- static const char *sun_str = "Sun";
- static const char *leafntwks_str = "3LeafNtwks";
- static const char *xsigo_str = "Xsigo";
- static const char *unknown_str = "Unknown";
-
- switch ((uint32_t) (guid_ho >> (5 * 8))) {
- case OSM_VENDOR_ID_INTEL:
- return (intel_str);
- case OSM_VENDOR_ID_MELLANOX:
- return (mellanox_str);
- case OSM_VENDOR_ID_REDSWITCH:
- return (redswitch_str);
- case OSM_VENDOR_ID_SILVERSTORM:
- return (silverstorm_str);
- case OSM_VENDOR_ID_TOPSPIN:
- return (topspin_str);
- case OSM_VENDOR_ID_FUJITSU:
- case OSM_VENDOR_ID_FUJITSU2:
- return (fujitsu_str);
- case OSM_VENDOR_ID_VOLTAIRE:
- return (voltaire_str);
- case OSM_VENDOR_ID_YOTTAYOTTA:
- return (yotta_str);
- case OSM_VENDOR_ID_PATHSCALE:
- return (pathscale_str);
- case OSM_VENDOR_ID_IBM:
- return (ibm_str);
- case OSM_VENDOR_ID_DIVERGENET:
- return (divergenet_str);
- case OSM_VENDOR_ID_FLEXTRONICS:
- return (flextronics_str);
- case OSM_VENDOR_ID_AGILENT:
- return (agilent_str);
- case OSM_VENDOR_ID_OBSIDIAN:
- return (obsidian_str);
- case OSM_VENDOR_ID_BAYMICRO:
- return (baymicro_str);
- case OSM_VENDOR_ID_LSILOGIC:
- return (lsilogic_str);
- case OSM_VENDOR_ID_DDN:
- return (ddn_str);
- case OSM_VENDOR_ID_PANTA:
- return (panta_str);
- case OSM_VENDOR_ID_HP:
- case OSM_VENDOR_ID_HP2:
- return (hp_str);
- case OSM_VENDOR_ID_RIOWORKS:
- return (rioworks_str);
- case OSM_VENDOR_ID_SUN:
- return (sun_str);
- case OSM_VENDOR_ID_3LEAFNTWKS:
- return (leafntwks_str);
- case OSM_VENDOR_ID_XSIGO:
- return (xsigo_str);
- default:
- return (unknown_str);
- }
-}
-
-static const char *const __osm_mtu_str_fixed_width[] = {
- "??? ",
- "256 ",
- "512 ",
- "1024",
- "2048",
- "4096"
-};
-
-/**********************************************************************
- **********************************************************************/
-const char *osm_get_mtu_str(IN uint8_t const mtu)
-{
- if (mtu > IB_MTU_LEN_4096)
- return (__osm_mtu_str_fixed_width[0]);
- else
- return (__osm_mtu_str_fixed_width[mtu]);
-}
-
-static const char *const __osm_lwa_str_fixed_width[] = {
- "???",
- "1x ",
- "4x ",
- "???",
- "8x ",
- "???",
- "???",
- "???",
- "12x"
-};
-
-/**********************************************************************
- **********************************************************************/
-const char *osm_get_lwa_str(IN uint8_t const lwa)
-{
- if (lwa > 8)
- return (__osm_lwa_str_fixed_width[0]);
- else
- return (__osm_lwa_str_fixed_width[lwa]);
-}
-
-/**********************************************************************
- **********************************************************************/
-static const char *const __osm_lsa_str_fixed_width[] = {
- "???",
- "2.5",
- "5 ",
- "???",
- "10 "
-};
-
-const char *osm_get_lsa_str(IN uint8_t const lsa)
-{
- if (lsa > 4)
- return (__osm_lsa_str_fixed_width[0]);
- else
- return (__osm_lsa_str_fixed_width[lsa]);
-}
-
-/**********************************************************************
- **********************************************************************/
-
-static const char *const __osm_sm_mgr_signal_str[] = {
- "OSM_SM_SIGNAL_NONE", /* 0 */
- "OSM_SM_SIGNAL_DISCOVERY_COMPLETED", /* 2 */
- "OSM_SM_SIGNAL_POLLING_TIMEOUT", /* 3 */
- "OSM_SM_SIGNAL_DISCOVER", /* 4 */
- "OSM_SM_SIGNAL_DISABLE", /* 5 */
- "OSM_SM_SIGNAL_HANDOVER", /* 6 */
- "OSM_SM_SIGNAL_HANDOVER_SENT", /* 7 */
- "OSM_SM_SIGNAL_ACKNOWLEDGE", /* 8 */
- "OSM_SM_SIGNAL_STANDBY", /* 9 */
- "OSM_SM_SIGNAL_MASTER_OR_HIGHER_SM_DETECTED", /* 10 */
- "OSM_SM_SIGNAL_WAIT_FOR_HANDOVER", /* 11 */
- "UNKNOWN STATE!!" /* 12 */
-};
-
-/**********************************************************************
- **********************************************************************/
-const char *osm_get_sm_mgr_signal_str(IN osm_sm_signal_t signal)
-{
- if (signal > OSM_SM_SIGNAL_MAX)
- signal = OSM_SM_SIGNAL_MAX;
- return (__osm_sm_mgr_signal_str[signal]);
-}
-
-static const char *const __osm_sm_mgr_state_str[] = {
- "NOTACTIVE", /* 0 */
- "DISCOVERING", /* 1 */
- "STANDBY", /* 2 */
- "MASTER", /* 3 */
- "UNKNOWN STATE!!" /* 4 */
-};
-
-const char *osm_get_sm_mgr_state_str(IN uint16_t state)
-{
- return state < ARR_SIZE(__osm_sm_mgr_state_str) ?
- __osm_sm_mgr_state_str[state] :
- __osm_sm_mgr_state_str[ARR_SIZE(__osm_sm_mgr_state_str) - 1];
-}
diff --git a/contrib/ofed/management/opensm/opensm/osm_indent b/contrib/ofed/management/opensm/opensm/osm_indent
deleted file mode 100755
index 4da000f..0000000
--- a/contrib/ofed/management/opensm/opensm/osm_indent
+++ /dev/null
@@ -1,56 +0,0 @@
-#!/bin/bash
-#
-# Copyright (c) 2004-2007 Voltaire, Inc. All rights reserved.
-# Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved.
-# Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
-#
-# This software is available to you under a choice of one of two
-# licenses. You may choose to be licensed under the terms of the GNU
-# General Public License (GPL) Version 2, available from the file
-# COPYING in the main directory of this source tree, or the
-# OpenIB.org BSD license below:
-#
-# Redistribution and use in source and binary forms, with or
-# without modification, are permitted provided that the following
-# conditions are met:
-#
-# - Redistributions of source code must retain the above
-# copyright notice, this list of conditions and the following
-# disclaimer.
-#
-# - Redistributions in binary form must reproduce the above
-# copyright notice, this list of conditions and the following
-# disclaimer in the documentation and/or other materials
-# provided with the distribution.
-#
-# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
-# BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
-# ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
-# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-# SOFTWARE.
-#
-#########################################################################
-#
-# Abstract:
-# Indent script for source code formatting.
-#
-# Environment:
-# Linux User Mode
-#
-# This is the indent format used for OpenSM (similar to one used in
-# linux/scripts/Lindent).
-
-indent -npro -kr -i8 -ts8 -sob -l80 -ss -ncs "$@"
-
-# indent doesn't have an option for label indentation, so do it with sed
-for f in $@ ; do
- test -f $f || continue
- temp=`mktemp -t osm_indent.XXXXXXXX`
- cat $f \
- | sed -e 's/^ \([A-Za-z_]\+[A-Za-z_0-9]*:\)$/\1/' > $temp
- diff $f $temp > /dev/null || cat $temp > $f
- rm -f $temp
-done
diff --git a/contrib/ofed/management/opensm/opensm/osm_inform.c b/contrib/ofed/management/opensm/opensm/osm_inform.c
deleted file mode 100644
index 1331d75..0000000
--- a/contrib/ofed/management/opensm/opensm/osm_inform.c
+++ /dev/null
@@ -1,616 +0,0 @@
-/*
- * Copyright (c) 2004-2008 Voltaire, Inc. All rights reserved.
- * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved.
- * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- */
-
-/*
- * Abstract:
- * Implementation of inform record functions.
- */
-
-#if HAVE_CONFIG_H
-# include <config.h>
-#endif /* HAVE_CONFIG_H */
-
-#include <stdlib.h>
-#include <string.h>
-#include <arpa/inet.h>
-#include <complib/cl_debug.h>
-#include <opensm/osm_helper.h>
-#include <opensm/osm_inform.h>
-#include <vendor/osm_vendor_api.h>
-#include <opensm/osm_pkey.h>
-#include <opensm/osm_sa.h>
-#include <sys/socket.h>
-
-typedef struct osm_infr_match_ctxt {
- cl_list_t *p_remove_infr_list;
- ib_mad_notice_attr_t *p_ntc;
-} osm_infr_match_ctxt_t;
-
-/**********************************************************************
- **********************************************************************/
-void osm_infr_delete(IN osm_infr_t * const p_infr)
-{
- free(p_infr);
-}
-
-/**********************************************************************
- **********************************************************************/
-osm_infr_t *osm_infr_new(IN const osm_infr_t * p_infr_rec)
-{
- osm_infr_t *p_infr;
-
- CL_ASSERT(p_infr_rec);
-
- p_infr = (osm_infr_t *) malloc(sizeof(osm_infr_t));
- if (p_infr)
- memcpy(p_infr, p_infr_rec, sizeof(osm_infr_t));
-
- return (p_infr);
-}
-
-/**********************************************************************
- **********************************************************************/
-static void dump_all_informs(IN osm_subn_t const *p_subn, IN osm_log_t * p_log)
-{
- cl_list_item_t *p_list_item;
-
- if (!osm_log_is_active(p_log, OSM_LOG_DEBUG))
- return;
-
- p_list_item = cl_qlist_head(&p_subn->sa_infr_list);
- while (p_list_item != cl_qlist_end(&p_subn->sa_infr_list)) {
- osm_dump_inform_info(p_log,
- &((osm_infr_t *) p_list_item)->
- inform_record.inform_info, OSM_LOG_DEBUG);
- p_list_item = cl_qlist_next(p_list_item);
- }
-}
-
-/**********************************************************************
- * Match an infr by the InformInfo and Address vector
- **********************************************************************/
-static cl_status_t
-__match_inf_rec(IN const cl_list_item_t * const p_list_item, IN void *context)
-{
- osm_infr_t *p_infr_rec = (osm_infr_t *) context;
- osm_infr_t *p_infr = (osm_infr_t *) p_list_item;
- osm_log_t *p_log = p_infr_rec->sa->p_log;
- cl_status_t status = CL_NOT_FOUND;
- ib_gid_t all_zero_gid;
-
- OSM_LOG_ENTER(p_log);
-
- if (memcmp(&p_infr->report_addr, &p_infr_rec->report_addr,
- sizeof(p_infr_rec->report_addr))) {
- OSM_LOG(p_log, OSM_LOG_DEBUG, "Differ by Address\n");
- goto Exit;
- }
-
- memset(&all_zero_gid, 0, sizeof(ib_gid_t));
-
- /* if inform_info.gid is not zero, ignore lid range */
- if (!memcmp(&p_infr_rec->inform_record.inform_info.gid, &all_zero_gid,
- sizeof(p_infr_rec->inform_record.inform_info.gid))) {
- if (memcmp(&p_infr->inform_record.inform_info.gid,
- &p_infr_rec->inform_record.inform_info.gid,
- sizeof(p_infr->inform_record.inform_info.gid))) {
- OSM_LOG(p_log, OSM_LOG_DEBUG,
- "Differ by InformInfo.gid\n");
- goto Exit;
- }
- } else {
- if ((p_infr->inform_record.inform_info.lid_range_begin !=
- p_infr_rec->inform_record.inform_info.lid_range_begin) ||
- (p_infr->inform_record.inform_info.lid_range_end !=
- p_infr_rec->inform_record.inform_info.lid_range_end)) {
- OSM_LOG(p_log, OSM_LOG_DEBUG,
- "Differ by InformInfo.LIDRange\n");
- goto Exit;
- }
- }
-
- if (p_infr->inform_record.inform_info.trap_type !=
- p_infr_rec->inform_record.inform_info.trap_type) {
- OSM_LOG(p_log, OSM_LOG_DEBUG,
- "Differ by InformInfo.TrapType\n");
- goto Exit;
- }
-
- if (p_infr->inform_record.inform_info.is_generic !=
- p_infr_rec->inform_record.inform_info.is_generic) {
- OSM_LOG(p_log, OSM_LOG_DEBUG,
- "Differ by InformInfo.IsGeneric\n");
- goto Exit;
- }
-
- if (p_infr->inform_record.inform_info.is_generic) {
- if (p_infr->inform_record.inform_info.g_or_v.generic.trap_num !=
- p_infr_rec->inform_record.inform_info.g_or_v.generic.
- trap_num)
- OSM_LOG(p_log, OSM_LOG_DEBUG,
- "Differ by InformInfo.Generic.TrapNumber\n");
- else if (p_infr->inform_record.inform_info.g_or_v.generic.
- qpn_resp_time_val !=
- p_infr_rec->inform_record.inform_info.g_or_v.generic.
- qpn_resp_time_val)
- OSM_LOG(p_log, OSM_LOG_DEBUG,
- "Differ by InformInfo.Generic.QPNRespTimeVal\n");
- else if (p_infr->inform_record.inform_info.g_or_v.generic.
- node_type_msb !=
- p_infr_rec->inform_record.inform_info.g_or_v.generic.
- node_type_msb)
- OSM_LOG(p_log, OSM_LOG_DEBUG,
- "Differ by InformInfo.Generic.NodeTypeMSB\n");
- else if (p_infr->inform_record.inform_info.g_or_v.generic.
- node_type_lsb !=
- p_infr_rec->inform_record.inform_info.g_or_v.generic.
- node_type_lsb)
- OSM_LOG(p_log, OSM_LOG_DEBUG,
- "Differ by InformInfo.Generic.NodeTypeLSB\n");
- else
- status = CL_SUCCESS;
- } else {
- if (p_infr->inform_record.inform_info.g_or_v.vend.dev_id !=
- p_infr_rec->inform_record.inform_info.g_or_v.vend.dev_id)
- OSM_LOG(p_log, OSM_LOG_DEBUG,
- "Differ by InformInfo.Vendor.DeviceID\n");
- else if (p_infr->inform_record.inform_info.g_or_v.vend.
- qpn_resp_time_val !=
- p_infr_rec->inform_record.inform_info.g_or_v.vend.
- qpn_resp_time_val)
- OSM_LOG(p_log, OSM_LOG_DEBUG,
- "Differ by InformInfo.Vendor.QPNRespTimeVal\n");
- else if (p_infr->inform_record.inform_info.g_or_v.vend.
- vendor_id_msb !=
- p_infr_rec->inform_record.inform_info.g_or_v.vend.
- vendor_id_msb)
- OSM_LOG(p_log, OSM_LOG_DEBUG,
- "Differ by InformInfo.Vendor.VendorIdMSB\n");
- else if (p_infr->inform_record.inform_info.g_or_v.vend.
- vendor_id_lsb !=
- p_infr_rec->inform_record.inform_info.g_or_v.vend.
- vendor_id_lsb)
- OSM_LOG(p_log, OSM_LOG_DEBUG,
- "Differ by InformInfo.Vendor.VendorIdLSB\n");
- else
- status = CL_SUCCESS;
- }
-
-Exit:
- OSM_LOG_EXIT(p_log);
- return status;
-}
-
-/**********************************************************************
- **********************************************************************/
-osm_infr_t *osm_infr_get_by_rec(IN osm_subn_t const *p_subn,
- IN osm_log_t * p_log,
- IN osm_infr_t * const p_infr_rec)
-{
- cl_list_item_t *p_list_item;
-
- OSM_LOG_ENTER(p_log);
-
- dump_all_informs(p_subn, p_log);
-
- OSM_LOG(p_log, OSM_LOG_DEBUG, "Looking for Inform Record\n");
- osm_dump_inform_info(p_log, &(p_infr_rec->inform_record.inform_info),
- OSM_LOG_DEBUG);
- OSM_LOG(p_log, OSM_LOG_DEBUG, "InformInfo list size %d\n",
- cl_qlist_count(&p_subn->sa_infr_list));
-
- p_list_item = cl_qlist_find_from_head(&p_subn->sa_infr_list,
- __match_inf_rec, p_infr_rec);
-
- if (p_list_item == cl_qlist_end(&p_subn->sa_infr_list))
- p_list_item = NULL;
-
- OSM_LOG_EXIT(p_log);
- return (osm_infr_t *) p_list_item;
-}
-
-/**********************************************************************
- **********************************************************************/
-void
-osm_infr_insert_to_db(IN osm_subn_t * p_subn,
- IN osm_log_t * p_log, IN osm_infr_t * p_infr)
-{
- OSM_LOG_ENTER(p_log);
-
- OSM_LOG(p_log, OSM_LOG_DEBUG,
- "Inserting new InformInfo Record into Database\n");
- OSM_LOG(p_log, OSM_LOG_DEBUG, "Dump before insertion (size %d)\n",
- cl_qlist_count(&p_subn->sa_infr_list));
- dump_all_informs(p_subn, p_log);
-
-#if 0
- osm_dump_inform_info(p_log,
- &(p_infr->inform_record.inform_info),
- OSM_LOG_DEBUG);
-#endif
-
- cl_qlist_insert_head(&p_subn->sa_infr_list, &p_infr->list_item);
-
- OSM_LOG(p_log, OSM_LOG_DEBUG, "Dump after insertion (size %d)\n",
- cl_qlist_count(&p_subn->sa_infr_list));
- dump_all_informs(p_subn, p_log);
- OSM_LOG_EXIT(p_log);
-}
-
-/**********************************************************************
- **********************************************************************/
-void
-osm_infr_remove_from_db(IN osm_subn_t * p_subn,
- IN osm_log_t * p_log, IN osm_infr_t * p_infr)
-{
- char gid_str[INET6_ADDRSTRLEN];
- OSM_LOG_ENTER(p_log);
-
- OSM_LOG(p_log, OSM_LOG_DEBUG, "Removing InformInfo Subscribing GID:%s"
- " Enum:0x%X from Database\n",
- inet_ntop(AF_INET6, p_infr->inform_record.subscriber_gid.raw,
- gid_str, sizeof gid_str),
- p_infr->inform_record.subscriber_enum);
-
- osm_dump_inform_info(p_log, &(p_infr->inform_record.inform_info),
- OSM_LOG_DEBUG);
-
- cl_qlist_remove_item(&p_subn->sa_infr_list, &p_infr->list_item);
-
- osm_infr_delete(p_infr);
-
- OSM_LOG_EXIT(p_log);
-}
-
-/**********************************************************************
- * Send a report:
- * Given a target address to send to and the notice.
- * We need to send SubnAdmReport
- **********************************************************************/
-static ib_api_status_t __osm_send_report(IN osm_infr_t * p_infr_rec, /* the informinfo */
- IN ib_mad_notice_attr_t * p_ntc /* notice to send */
- )
-{
- osm_madw_t *p_report_madw;
- ib_mad_notice_attr_t *p_report_ntc;
- ib_mad_t *p_mad;
- ib_sa_mad_t *p_sa_mad;
- static atomic32_t trap_fwd_trans_id = 0x02DAB000;
- ib_api_status_t status = IB_SUCCESS;
- osm_log_t *p_log = p_infr_rec->sa->p_log;
-
- OSM_LOG_ENTER(p_log);
-
- /* HACK: who switches or uses the src and dest GIDs in the grh_info ?? */
-
- /* it is better to use LIDs since the GIDs might not be there for SMI traps */
- OSM_LOG(p_log, OSM_LOG_DEBUG, "Forwarding Notice Event from LID:%u"
- " to InformInfo LID: %u TID:0x%X\n",
- cl_ntoh16(p_ntc->issuer_lid),
- cl_ntoh16(p_infr_rec->report_addr.dest_lid), trap_fwd_trans_id);
-
- /* get the MAD to send */
- p_report_madw = osm_mad_pool_get(p_infr_rec->sa->p_mad_pool,
- p_infr_rec->h_bind, MAD_BLOCK_SIZE,
- &(p_infr_rec->report_addr));
-
- p_report_madw->resp_expected = TRUE;
-
- if (!p_report_madw) {
- OSM_LOG(p_log, OSM_LOG_ERROR, "ERR 0203"
- "osm_mad_pool_get failed\n");
- status = IB_ERROR;
- goto Exit;
- }
-
- /* advance trap trans id (cant simply ++ on some systems inside ntoh) */
- p_mad = osm_madw_get_mad_ptr(p_report_madw);
- ib_mad_init_new(p_mad, IB_MCLASS_SUBN_ADM, 2, IB_MAD_METHOD_REPORT,
- cl_hton64((uint64_t) cl_atomic_inc(&trap_fwd_trans_id)),
- IB_MAD_ATTR_NOTICE, 0);
-
- p_sa_mad = osm_madw_get_sa_mad_ptr(p_report_madw);
-
- p_report_ntc = (ib_mad_notice_attr_t *) & (p_sa_mad->data);
-
- /* copy the notice */
- *p_report_ntc = *p_ntc;
-
- /* The TRUE is for: response is expected */
- osm_sa_send(p_infr_rec->sa, p_report_madw, TRUE);
-
-Exit:
- OSM_LOG_EXIT(p_log);
- return (status);
-}
-
-/**********************************************************************
- * This routine compares a given Notice and a ListItem of InformInfo type.
- * PREREQUISITE:
- * The Notice.GID should be pre-filled with the trap generator GID
- **********************************************************************/
-static void
-__match_notice_to_inf_rec(IN cl_list_item_t * const p_list_item,
- IN void *context)
-{
- osm_infr_match_ctxt_t *p_infr_match = (osm_infr_match_ctxt_t *) context;
- ib_mad_notice_attr_t *p_ntc = p_infr_match->p_ntc;
- cl_list_t *p_infr_to_remove_list = p_infr_match->p_remove_infr_list;
- osm_infr_t *p_infr_rec = (osm_infr_t *) p_list_item;
- ib_inform_info_t *p_ii = &(p_infr_rec->inform_record.inform_info);
- cl_status_t status = CL_NOT_FOUND;
- osm_log_t *p_log = p_infr_rec->sa->p_log;
- osm_subn_t *p_subn = p_infr_rec->sa->p_subn;
- ib_gid_t source_gid;
- osm_port_t *p_src_port;
- osm_port_t *p_dest_port;
-
- OSM_LOG_ENTER(p_log);
-
- /* matching rules
- * InformInfo Notice
- * GID IssuerGID if non zero must match the trap
- * LIDRange IssuerLID apply only if GID=0
- * IsGeneric IsGeneric is compulsory and must match the trap
- * Type Type if not 0xFFFF must match
- * TrapNumber TrapNumber if not 0xFFFF must match
- * DeviceId DeviceID if not 0xFFFF must match
- * QPN dont care
- * ProducerType ProducerType match or 0xFFFFFF // EZ: actually my interpretation
- * VendorID VendorID match or 0xFFFFFF
- */
-
- /* GID IssuerGID if non zero must match the trap */
- if (p_ii->gid.unicast.prefix != 0
- || p_ii->gid.unicast.interface_id != 0) {
- /* match by GID */
- if (memcmp(&(p_ii->gid), &(p_ntc->issuer_gid),
- sizeof(ib_gid_t))) {
- OSM_LOG(p_log, OSM_LOG_DEBUG, "Mismatch by GID\n");
- goto Exit;
- }
- } else {
- /* LIDRange IssuerLID apply only if GID=0 */
- /* If lid_range_begin of the informInfo is 0xFFFF - then it should be ignored. */
- if (p_ii->lid_range_begin != 0xFFFF) {
- /* a real lid range is given - check it */
- if ((cl_hton16(p_ii->lid_range_begin) >
- cl_hton16(p_ntc->issuer_lid))
- || (cl_hton16(p_ntc->issuer_lid) >
- cl_hton16(p_ii->lid_range_end))) {
- OSM_LOG(p_log, OSM_LOG_DEBUG,
- "Mismatch by LID Range. Needed: %u <= %u <= %u\n",
- cl_hton16(p_ii->lid_range_begin),
- cl_hton16(p_ntc->issuer_lid),
- cl_hton16(p_ii->lid_range_end));
- goto Exit;
- }
- }
- }
-
- /* IsGeneric IsGeneric is compulsory and must match the trap */
- if ((p_ii->is_generic && !ib_notice_is_generic(p_ntc)) ||
- (!p_ii->is_generic && ib_notice_is_generic(p_ntc))) {
- OSM_LOG(p_log, OSM_LOG_DEBUG, "Mismatch by Generic/Vendor\n");
- goto Exit;
- }
-
- /* Type Type if not 0xFFFF must match */
- if ((p_ii->trap_type != 0xFFFF) &&
- (cl_ntoh16(p_ii->trap_type) != ib_notice_get_type(p_ntc))) {
- OSM_LOG(p_log, OSM_LOG_DEBUG, "Mismatch by Type\n");
- goto Exit;
- }
-
- /* based on generic type */
- if (p_ii->is_generic) {
- /* TrapNumber TrapNumber if not 0xFFFF must match */
- if ((p_ii->g_or_v.generic.trap_num != 0xFFFF) &&
- (p_ii->g_or_v.generic.trap_num !=
- p_ntc->g_or_v.generic.trap_num)) {
- OSM_LOG(p_log, OSM_LOG_DEBUG, "Mismatch by Trap Num\n");
- goto Exit;
- }
-
- /* ProducerType ProducerType match or 0xFFFFFF */
- if ((cl_ntoh32(ib_inform_info_get_prod_type(p_ii)) != 0xFFFFFF)
- && (ib_inform_info_get_prod_type(p_ii) !=
- ib_notice_get_prod_type(p_ntc))) {
- OSM_LOG(p_log, OSM_LOG_DEBUG,
- "Mismatch by Node Type: II=0x%06X (%s) Trap=0x%06X (%s)\n",
- cl_ntoh32(ib_inform_info_get_prod_type(p_ii)),
- ib_get_producer_type_str
- (ib_inform_info_get_prod_type(p_ii)),
- cl_ntoh32(ib_notice_get_prod_type(p_ntc)),
- ib_get_producer_type_str(ib_notice_get_prod_type
- (p_ntc)));
- goto Exit;
- }
- } else {
- /* DeviceId DeviceID if not 0xFFFF must match */
- if ((p_ii->g_or_v.vend.dev_id != 0xFFFF) &&
- (p_ii->g_or_v.vend.dev_id != p_ntc->g_or_v.vend.dev_id)) {
- OSM_LOG(p_log, OSM_LOG_DEBUG, "Mismatch by Dev Id\n");
- goto Exit;
- }
-
- /* VendorID VendorID match or 0xFFFFFF */
- if ((ib_inform_info_get_vend_id(p_ii) != CL_HTON32(0xFFFFFF)) &&
- (ib_inform_info_get_vend_id(p_ii) !=
- ib_notice_get_vend_id(p_ntc))) {
- OSM_LOG(p_log, OSM_LOG_DEBUG, "Mismatch by Vendor ID\n");
- goto Exit;
- }
- }
-
- /* Check if there is a pkey match. o13-17.1.1 */
- /* Check if the issuer of the trap is the SM. If it is, then the gid
- comparison should be done on the trap source (saved as the gid in the
- data details field).
- If the issuer gid is not the SM - then it is the guid of the trap
- source */
- if ((cl_ntoh64(p_ntc->issuer_gid.unicast.prefix) ==
- p_subn->opt.subnet_prefix)
- && (cl_ntoh64(p_ntc->issuer_gid.unicast.interface_id) ==
- p_subn->sm_port_guid))
- /* The issuer is the SM then this is trap 64-67 - compare the gid
- with the gid saved on the data details */
- source_gid = p_ntc->data_details.ntc_64_67.gid;
- else
- source_gid = p_ntc->issuer_gid;
-
- p_src_port =
- osm_get_port_by_guid(p_subn, source_gid.unicast.interface_id);
- if (!p_src_port) {
- OSM_LOG(p_log, OSM_LOG_INFO,
- "Cannot find source port with GUID:0x%016" PRIx64 "\n",
- cl_ntoh64(source_gid.unicast.interface_id));
- goto Exit;
- }
-
- p_dest_port =
- cl_ptr_vector_get(&p_subn->port_lid_tbl,
- cl_ntoh16(p_infr_rec->report_addr.dest_lid));
- if (!p_dest_port) {
- OSM_LOG(p_log, OSM_LOG_INFO,
- "Cannot find destination port with LID:%u\n",
- cl_ntoh16(p_infr_rec->report_addr.dest_lid));
- goto Exit;
- }
-
- if (osm_port_share_pkey(p_log, p_src_port, p_dest_port) == FALSE) {
- OSM_LOG(p_log, OSM_LOG_DEBUG, "Mismatch by Pkey\n");
- /* According to o13-17.1.2 - If this informInfo does not have
- lid_range_begin of 0xFFFF, then this informInfo request
- should be removed from database */
- if (p_ii->lid_range_begin != 0xFFFF) {
- OSM_LOG(p_log, OSM_LOG_VERBOSE,
- "Pkey mismatch on lid_range_begin != 0xFFFF. "
- "Need to remove this informInfo from db\n");
- /* add the informInfo record to the remove_infr list */
- cl_list_insert_tail(p_infr_to_remove_list, p_infr_rec);
- }
- goto Exit;
- }
-
- /* send the report to the address provided in the inform record */
- OSM_LOG(p_log, OSM_LOG_DEBUG, "MATCH! Sending Report...\n");
- __osm_send_report(p_infr_rec, p_ntc);
- status = CL_SUCCESS;
-
-Exit:
- OSM_LOG_EXIT(p_log);
-}
-
-/**********************************************************************
- * Once a Trap was received by osm_trap_rcv, or a Trap sourced by
- * the SM was sent (Traps 64-67), this routine is called with a copy of
- * the notice data.
- * Given a notice attribute - compare and see if it matches the InformInfo
- * element and if it does - call the Report(Notice) for the
- * target QP registered by the address stored in the InformInfo element
- **********************************************************************/
-ib_api_status_t
-osm_report_notice(IN osm_log_t * const p_log,
- IN osm_subn_t * p_subn, IN ib_mad_notice_attr_t * p_ntc)
-{
- char gid_str[INET6_ADDRSTRLEN];
- osm_infr_match_ctxt_t context;
- cl_list_t infr_to_remove_list;
- osm_infr_t *p_infr_rec;
- osm_infr_t *p_next_infr_rec;
-
- OSM_LOG_ENTER(p_log);
-
- /*
- * we must make sure we are ready for this...
- * note that the trap receivers might be initialized before
- * the osm_infr_init call is performed.
- */
- if (p_subn->sa_infr_list.state != CL_INITIALIZED) {
- OSM_LOG(p_log, OSM_LOG_DEBUG,
- "Ignoring Notice Reports since Inform List is not initialized yet!\n");
- return (IB_ERROR);
- }
-
- /* an official Event information log */
- if (ib_notice_is_generic(p_ntc))
- OSM_LOG(p_log, OSM_LOG_INFO,
- "Reporting Generic Notice type:%u num:%u (%s)"
- " from LID:%u GID:%s\n",
- ib_notice_get_type(p_ntc),
- cl_ntoh16(p_ntc->g_or_v.generic.trap_num),
- ib_get_trap_str(p_ntc->g_or_v.generic.trap_num),
- cl_ntoh16(p_ntc->issuer_lid),
- inet_ntop(AF_INET6, p_ntc->issuer_gid.raw, gid_str,
- sizeof gid_str));
- else
- OSM_LOG(p_log, OSM_LOG_INFO,
- "Reporting Vendor Notice type:%u vend:%u dev:%u"
- " from LID:%u GID:%s\n",
- ib_notice_get_type(p_ntc),
- cl_ntoh32(ib_notice_get_vend_id(p_ntc)),
- cl_ntoh16(p_ntc->g_or_v.vend.dev_id),
- cl_ntoh16(p_ntc->issuer_lid),
- inet_ntop(AF_INET6, p_ntc->issuer_gid.raw, gid_str,
- sizeof gid_str));
-
- /* Create a list that will hold all the infr records that should
- be removed due to violation. o13-17.1.2 */
- cl_list_construct(&infr_to_remove_list);
- cl_list_init(&infr_to_remove_list, 5);
- context.p_remove_infr_list = &infr_to_remove_list;
- context.p_ntc = p_ntc;
-
- /* go over all inform info available at the subnet */
- /* try match to the given notice and send if match */
- cl_qlist_apply_func(&(p_subn->sa_infr_list),
- __match_notice_to_inf_rec, &context);
-
- /* If we inserted items into the infr_to_remove_list - we need to
- remove them */
- p_infr_rec = (osm_infr_t *) cl_list_remove_head(&infr_to_remove_list);
- while (p_infr_rec != NULL) {
- p_next_infr_rec =
- (osm_infr_t *) cl_list_remove_head(&infr_to_remove_list);
- osm_infr_remove_from_db(p_subn, p_log, p_infr_rec);
- p_infr_rec = p_next_infr_rec;
- }
- cl_list_destroy(&infr_to_remove_list);
-
- OSM_LOG_EXIT(p_log);
-
- return (IB_SUCCESS);
-}
diff --git a/contrib/ofed/management/opensm/opensm/osm_lid_mgr.c b/contrib/ofed/management/opensm/opensm/osm_lid_mgr.c
deleted file mode 100644
index b74aba5..0000000
--- a/contrib/ofed/management/opensm/opensm/osm_lid_mgr.c
+++ /dev/null
@@ -1,1321 +0,0 @@
-/*
- * Copyright (c) 2004-2008 Voltaire, Inc. All rights reserved.
- * Copyright (c) 2002-2006 Mellanox Technologies LTD. All rights reserved.
- * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- */
-
-/*
- * Abstract:
- * Implementation of osm_lid_mgr_t.
- * This file implements the LID Manager object which is responsible for
- * assigning LIDs to all ports on the subnet.
- *
- * DATA STRUCTURES:
- * p_subn->port_lid_tbl : a vector pointing from lid to its port.
- * osm db guid2lid domain : a hash from guid to lid (min lid).
- * p_subn->port_guid_tbl : a map from guid to discovered port obj.
- *
- * ALGORITHM:
- *
- * 0. we define a function to obtain the correct port lid:
- * __osm_lid_mgr_get_port_lid( p_mgr, port, &min_lid ):
- * 0.1 if the port info lid matches the guid2lid return 0
- * 0.2 if the port info has a lid and that range is empty in
- * port_lid_tbl, return 0 and update the port_lid_tbl and
- * guid2lid
- * 0.3 else find an empty space in port_lid_tbl, update the
- * port_lid_tbl and guid2lid, return 1 to flag a change required.
- *
- * 1. During initialization:
- * 1.1 initialize the guid2lid database domain.
- * 1.2 if reassign_lid is not set:
- * 1.2.1 read the persistent data for the domain.
- * 1.2.2 validate no duplicate use of lids and lids are 2^(lmc-1)
- *
- * 2. During SM port lid assignment:
- * 2.1 if reassign_lids is set, make it 2^lmc
- * 2.2 cleanup all port_lid_tbl and re-fill it according to guid2lid
- * 2.3 call __osm_lid_mgr_get_port_lid the SM port
- * 2.4 set the port info
- *
- * 3. During all other ports lid assignment:
- * 3.1 go through all ports in the subnet
- * 3.1.1 call __osm_lid_mgr_get_port_min_lid
- * 3.1.2 if a change required send the port info
- * 3.2 if any change send the signal PENDING...
- *
- * 4. Store the guid2lid
- */
-
-#if HAVE_CONFIG_H
-# include <config.h>
-#endif /* HAVE_CONFIG_H */
-
-#include <stdlib.h>
-#include <string.h>
-#include <iba/ib_types.h>
-#include <complib/cl_qmap.h>
-#include <complib/cl_debug.h>
-#include <opensm/osm_lid_mgr.h>
-#include <opensm/osm_sm.h>
-#include <opensm/osm_log.h>
-#include <opensm/osm_node.h>
-#include <opensm/osm_switch.h>
-#include <opensm/osm_helper.h>
-#include <opensm/osm_msgdef.h>
-#include <vendor/osm_vendor_api.h>
-#include <opensm/osm_db_pack.h>
-
-/**********************************************************************
- lid range item of qlist
- **********************************************************************/
-typedef struct osm_lid_mgr_range {
- cl_list_item_t item;
- uint16_t min_lid;
- uint16_t max_lid;
-} osm_lid_mgr_range_t;
-
-/**********************************************************************
- **********************************************************************/
-void osm_lid_mgr_construct(IN osm_lid_mgr_t * const p_mgr)
-{
- memset(p_mgr, 0, sizeof(*p_mgr));
- cl_ptr_vector_construct(&p_mgr->used_lids);
-}
-
-/**********************************************************************
- **********************************************************************/
-void osm_lid_mgr_destroy(IN osm_lid_mgr_t * const p_mgr)
-{
- cl_list_item_t *p_item;
-
- OSM_LOG_ENTER(p_mgr->p_log);
-
- cl_ptr_vector_destroy(&p_mgr->used_lids);
- p_item = cl_qlist_remove_head(&p_mgr->free_ranges);
- while (p_item != cl_qlist_end(&p_mgr->free_ranges)) {
- free((osm_lid_mgr_range_t *) p_item);
- p_item = cl_qlist_remove_head(&p_mgr->free_ranges);
- }
- OSM_LOG_EXIT(p_mgr->p_log);
-}
-
-/**********************************************************************
-Validate the guid to lid data by making sure that under the current
-LMC we did not get duplicates. If we do flag them as errors and remove
-the entry.
-**********************************************************************/
-static void __osm_lid_mgr_validate_db(IN osm_lid_mgr_t * p_mgr)
-{
- cl_qlist_t guids;
- osm_db_guid_elem_t *p_item;
- uint16_t lid;
- uint16_t min_lid;
- uint16_t max_lid;
- uint16_t lmc_mask;
- boolean_t lids_ok;
-
- OSM_LOG_ENTER(p_mgr->p_log);
-
- if (p_mgr->p_subn->opt.lmc)
- lmc_mask = ~((1 << p_mgr->p_subn->opt.lmc) - 1);
- else
- lmc_mask = 0xffff;
-
- cl_qlist_init(&guids);
-
- if (osm_db_guid2lid_guids(p_mgr->p_g2l, &guids)) {
- OSM_LOG(p_mgr->p_log, OSM_LOG_ERROR, "ERR 0310: "
- "could not get guid list\n");
- goto Exit;
- }
-
- p_item = (osm_db_guid_elem_t *) cl_qlist_remove_head(&guids);
- while ((cl_list_item_t *) p_item != cl_qlist_end(&guids)) {
- if (osm_db_guid2lid_get
- (p_mgr->p_g2l, p_item->guid, &min_lid, &max_lid))
- OSM_LOG(p_mgr->p_log, OSM_LOG_ERROR, "ERR 0311: "
- "could not get lid for guid:0x%016" PRIx64 "\n",
- p_item->guid);
- else {
- lids_ok = TRUE;
-
- if ((min_lid > max_lid) || (min_lid == 0)
- || (p_item->guid == 0)
- || (max_lid > p_mgr->p_subn->max_ucast_lid_ho)) {
- OSM_LOG(p_mgr->p_log, OSM_LOG_ERROR, "ERR 0312: "
- "Illegal LID range [%u:%u] for "
- "guid:0x%016" PRIx64 "\n", min_lid,
- max_lid, p_item->guid);
- lids_ok = FALSE;
- } else if ((min_lid != max_lid)
- && ((min_lid & lmc_mask) != min_lid)) {
- /* check that if the lids define a range that is valid
- for the current LMC mask */
- OSM_LOG(p_mgr->p_log, OSM_LOG_ERROR, "ERR 0313: "
- "LID range [%u:%u] for guid:0x%016"
- PRIx64
- " is not aligned according to mask:0x%04x\n",
- min_lid, max_lid, p_item->guid,
- lmc_mask);
- lids_ok = FALSE;
- } else {
- /* check if the lids were not previously assigned */
- for (lid = min_lid; lid <= max_lid; lid++) {
- if ((cl_ptr_vector_get_size
- (&p_mgr->used_lids) > lid)
- &&
- (cl_ptr_vector_get
- (&p_mgr->used_lids, lid))) {
- OSM_LOG(p_mgr->p_log,
- OSM_LOG_ERROR, "ERR 0314: "
- "0x%04x for guid:0x%016"
- PRIx64
- " was previously used\n",
- lid, p_item->guid);
- lids_ok = FALSE;
- }
- }
- }
-
- if (!lids_ok) {
- if (osm_db_guid2lid_delete
- (p_mgr->p_g2l, p_item->guid))
- OSM_LOG(p_mgr->p_log, OSM_LOG_ERROR,
- "ERR 0315: "
- "failed to delete entry for "
- "guid:0x%016" PRIx64 "\n",
- p_item->guid);
- } else {
- /* mark it was visited */
- for (lid = min_lid; lid <= max_lid; lid++)
- cl_ptr_vector_set(&p_mgr->used_lids,
- lid, (void *)1);
- }
- } /* got a lid */
- free(p_item);
- p_item = (osm_db_guid_elem_t *) cl_qlist_remove_head(&guids);
- } /* all guids */
-Exit:
- OSM_LOG_EXIT(p_mgr->p_log);
-}
-
-/**********************************************************************
- **********************************************************************/
-ib_api_status_t
-osm_lid_mgr_init(IN osm_lid_mgr_t * const p_mgr, IN osm_sm_t *sm)
-{
- ib_api_status_t status = IB_SUCCESS;
-
- OSM_LOG_ENTER(sm->p_log);
-
- osm_lid_mgr_construct(p_mgr);
-
- p_mgr->sm = sm;
- p_mgr->p_log = sm->p_log;
- p_mgr->p_subn = sm->p_subn;
- p_mgr->p_db = sm->p_db;
- p_mgr->p_lock = sm->p_lock;
-
- /* we initialize and restore the db domain of guid to lid map */
- p_mgr->p_g2l = osm_db_domain_init(p_mgr->p_db, "/guid2lid");
- if (!p_mgr->p_g2l) {
- OSM_LOG(p_mgr->p_log, OSM_LOG_ERROR, "ERR 0316: "
- "Error initializing Guid-to-Lid persistent database\n");
- status = IB_ERROR;
- goto Exit;
- }
-
- cl_ptr_vector_init(&p_mgr->used_lids, 100, 40);
- cl_qlist_init(&p_mgr->free_ranges);
-
- /* we use the stored guid to lid table if not forced to reassign */
- if (!p_mgr->p_subn->opt.reassign_lids) {
- if (osm_db_restore(p_mgr->p_g2l)) {
-#ifndef __WIN__
- /*
- * When Windows is BSODing, it might corrupt files that
- * were previously opened for writing, even if the files
- * are closed, so we might see corrupted guid2lid file.
- */
- if (p_mgr->p_subn->opt.exit_on_fatal) {
- osm_log(p_mgr->p_log, OSM_LOG_SYS,
- "FATAL: Error restoring Guid-to-Lid "
- "persistent database\n");
- status = IB_ERROR;
- goto Exit;
- } else
-#endif
- OSM_LOG(p_mgr->p_log, OSM_LOG_ERROR,
- "ERR 0317: Error restoring Guid-to-Lid "
- "persistent database\n");
- }
-
- /* we need to make sure we did not get duplicates with
- current lmc */
- __osm_lid_mgr_validate_db(p_mgr);
- }
-
-Exit:
- OSM_LOG_EXIT(p_mgr->p_log);
- return (status);
-}
-
-static uint16_t __osm_trim_lid(IN uint16_t lid)
-{
- if ((lid > IB_LID_UCAST_END_HO) || (lid < IB_LID_UCAST_START_HO))
- return 0;
- return lid;
-}
-
-/**********************************************************************
- initialize the manager for a new sweep:
- scans the known persistent assignment and port_lid_tbl
- re-calculate all empty ranges.
- cleanup invalid port_lid_tbl entries
-**********************************************************************/
-static int __osm_lid_mgr_init_sweep(IN osm_lid_mgr_t * const p_mgr)
-{
- cl_ptr_vector_t *p_discovered_vec = &p_mgr->p_subn->port_lid_tbl;
- cl_ptr_vector_t *p_persistent_vec = &p_mgr->used_lids;
- uint16_t max_defined_lid;
- uint16_t max_persistent_lid;
- uint16_t max_discovered_lid;
- uint16_t lid;
- uint16_t disc_min_lid;
- uint16_t disc_max_lid;
- uint16_t db_min_lid;
- uint16_t db_max_lid;
- int status = 0;
- cl_list_item_t *p_item;
- boolean_t is_free;
- osm_lid_mgr_range_t *p_range = NULL;
- osm_port_t *p_port;
- cl_qmap_t *p_port_guid_tbl;
- uint8_t lmc_num_lids = (uint8_t) (1 << p_mgr->p_subn->opt.lmc);
- uint16_t lmc_mask;
- uint16_t req_lid, num_lids;
-
- OSM_LOG_ENTER(p_mgr->p_log);
-
- if (p_mgr->p_subn->opt.lmc)
- lmc_mask = ~((1 << p_mgr->p_subn->opt.lmc) - 1);
- else
- lmc_mask = 0xffff;
-
- /* if we came out of standby we need to discard any previous guid2lid
- info we might have.
- Do this only if the honor_guid2lid_file option is FALSE. If not, then
- need to honor this file. */
- if (p_mgr->p_subn->coming_out_of_standby == TRUE) {
- if (p_mgr->p_subn->opt.honor_guid2lid_file == FALSE) {
- OSM_LOG(p_mgr->p_log, OSM_LOG_DEBUG,
- "Ignore guid2lid file when coming out of standby\n");
- osm_db_clear(p_mgr->p_g2l);
- for (lid = 0;
- lid < cl_ptr_vector_get_size(&p_mgr->used_lids);
- lid++)
- cl_ptr_vector_set(p_persistent_vec, lid, NULL);
- } else {
- OSM_LOG(p_mgr->p_log, OSM_LOG_DEBUG,
- "Honor current guid2lid file when coming out "
- "of standby\n");
- osm_db_clear(p_mgr->p_g2l);
- if (osm_db_restore(p_mgr->p_g2l))
- OSM_LOG(p_mgr->p_log, OSM_LOG_ERROR, "ERR 0306: "
- "Error restoring Guid-to-Lid "
- "persistent database. Ignoring it\n");
- }
- }
-
- /* we need to cleanup the empty ranges list */
- p_item = cl_qlist_remove_head(&p_mgr->free_ranges);
- while (p_item != cl_qlist_end(&p_mgr->free_ranges)) {
- free((osm_lid_mgr_range_t *) p_item);
- p_item = cl_qlist_remove_head(&p_mgr->free_ranges);
- }
-
- /* first clean up the port_by_lid_tbl */
- for (lid = 0; lid < cl_ptr_vector_get_size(p_discovered_vec); lid++)
- cl_ptr_vector_set(p_discovered_vec, lid, NULL);
-
- /* we if are in the first sweep and in reassign lids mode
- we should ignore all the available info and simply define one
- huge empty range */
- if ((p_mgr->p_subn->first_time_master_sweep == TRUE) &&
- (p_mgr->p_subn->opt.reassign_lids == TRUE)) {
- OSM_LOG(p_mgr->p_log, OSM_LOG_DEBUG,
- "Skipping all lids as we are reassigning them\n");
- p_range =
- (osm_lid_mgr_range_t *) malloc(sizeof(osm_lid_mgr_range_t));
- if (p_range)
- p_range->min_lid = 1;
- goto AfterScanningLids;
- }
-
- /* go over all discovered ports and mark their entries */
- p_port_guid_tbl = &p_mgr->p_subn->port_guid_tbl;
-
- for (p_port = (osm_port_t *) cl_qmap_head(p_port_guid_tbl);
- p_port != (osm_port_t *) cl_qmap_end(p_port_guid_tbl);
- p_port = (osm_port_t *) cl_qmap_next(&p_port->map_item)) {
- osm_port_get_lid_range_ho(p_port, &disc_min_lid, &disc_max_lid);
- disc_min_lid = __osm_trim_lid(disc_min_lid);
- disc_max_lid = __osm_trim_lid(disc_max_lid);
- for (lid = disc_min_lid; lid <= disc_max_lid; lid++)
- cl_ptr_vector_set(p_discovered_vec, lid, p_port);
- /* make sure the guid2lid entry is valid. If not, clean it. */
- if (!osm_db_guid2lid_get(p_mgr->p_g2l,
- cl_ntoh64(osm_port_get_guid(p_port)),
- &db_min_lid, &db_max_lid)) {
- if (!p_port->p_node->sw ||
- osm_switch_sp0_is_lmc_capable(p_port->p_node->sw,
- p_mgr->p_subn))
- num_lids = lmc_num_lids;
- else
- num_lids = 1;
-
- if ((num_lids != 1) &&
- (((db_min_lid & lmc_mask) != db_min_lid) ||
- (db_max_lid - db_min_lid + 1 < num_lids))) {
- /* Not aligned, or not wide enough, then remove the entry */
- OSM_LOG(p_mgr->p_log, OSM_LOG_DEBUG,
- "Cleaning persistent entry for guid:"
- "0x%016" PRIx64 " illegal range:"
- "[0x%x:0x%x]\n",
- cl_ntoh64(osm_port_get_guid(p_port)),
- db_min_lid, db_max_lid);
- osm_db_guid2lid_delete(p_mgr->p_g2l,
- cl_ntoh64
- (osm_port_get_guid
- (p_port)));
- for (lid = db_min_lid; lid <= db_max_lid; lid++)
- cl_ptr_vector_set(p_persistent_vec, lid,
- NULL);
- }
- }
- }
-
- /*
- Our task is to find free lid ranges.
- A lid can be used if
- 1. a persistent assignment exists
- 2. the lid is used by a discovered port that does not have a persistent
- assignment.
-
- scan through all lid values of both the persistent table and
- discovered table.
- If the lid has an assigned port in the discovered table:
- * make sure the lid matches the persistent table, or
- * there is no other persistent assignment for that lid.
- * else cleanup the port_by_lid_tbl, mark this as empty range.
- Else if the lid does not have an entry in the persistent table
- mark it as free.
- */
-
- /* find the range of lids to scan */
- max_discovered_lid =
- (uint16_t) cl_ptr_vector_get_size(p_discovered_vec);
- max_persistent_lid =
- (uint16_t) cl_ptr_vector_get_size(p_persistent_vec);
-
- /* but the vectors have one extra entry for lid=0 */
- if (max_discovered_lid)
- max_discovered_lid--;
- if (max_persistent_lid)
- max_persistent_lid--;
-
- if (max_persistent_lid > max_discovered_lid)
- max_defined_lid = max_persistent_lid;
- else
- max_defined_lid = max_discovered_lid;
-
- for (lid = 1; lid <= max_defined_lid; lid++) {
- is_free = TRUE;
- /* first check to see if the lid is used by a persistent assignment */
- if ((lid <= max_persistent_lid)
- && cl_ptr_vector_get(p_persistent_vec, lid)) {
- OSM_LOG(p_mgr->p_log, OSM_LOG_DEBUG,
- "0x%04x is not free as its mapped by the "
- "persistent db\n", lid);
- is_free = FALSE;
- } else {
- /* check this is a discovered port */
- if (lid <= max_discovered_lid
- && (p_port = (osm_port_t *)
- cl_ptr_vector_get(p_discovered_vec, lid))) {
- /* we have a port. Now lets see if we can preserve its lid range. */
- /* For that, we need to make sure:
- 1. The port has a (legal) persistency entry. Then the local lid
- is free (we will use the persistency value).
- 2. Can the port keep its local assignment?
- a. Make sure the lid a aligned.
- b. Make sure all needed lids (for the lmc) are free according
- to persistency table.
- */
- /* qualify the guid of the port is not persistently mapped to
- another range */
- if (!osm_db_guid2lid_get(p_mgr->p_g2l,
- cl_ntoh64
- (osm_port_get_guid
- (p_port)),
- &db_min_lid,
- &db_max_lid)) {
- OSM_LOG(p_mgr->p_log, OSM_LOG_DEBUG,
- "0x%04x is free as it was "
- "discovered but mapped by the "
- "persistent db to [0x%04x:0x%04x]\n",
- lid, db_min_lid, db_max_lid);
- } else {
- /* can the port keep its assignment ? */
- /* get the lid range of that port, and the required number
- of lids we are about to assign to it */
- osm_port_get_lid_range_ho(p_port,
- &disc_min_lid,
- &disc_max_lid);
- if (!p_port->p_node->sw
- ||
- osm_switch_sp0_is_lmc_capable
- (p_port->p_node->sw,
- p_mgr->p_subn)) {
- disc_max_lid =
- disc_min_lid +
- lmc_num_lids - 1;
- num_lids = lmc_num_lids;
- } else
- num_lids = 1;
-
- /* Make sure the lid is aligned */
- if ((num_lids != 1)
- && ((disc_min_lid & lmc_mask) !=
- disc_min_lid)) {
- /* The lid cannot be used */
- OSM_LOG(p_mgr->p_log,
- OSM_LOG_DEBUG,
- "0x%04x is free as it was "
- "discovered but not aligned\n",
- lid);
- } else {
- /* check that all needed lids are not persistently mapped */
- is_free = FALSE;
- for (req_lid = disc_min_lid + 1;
- req_lid <= disc_max_lid;
- req_lid++) {
- if ((req_lid <=
- max_persistent_lid)
- &&
- cl_ptr_vector_get
- (p_persistent_vec,
- req_lid)) {
- OSM_LOG(p_mgr->
- p_log,
- OSM_LOG_DEBUG,
- "0x%04x is free as it was discovered "
- "but mapped\n",
- lid);
- is_free = TRUE;
- break;
- }
- }
-
- if (is_free == FALSE) {
- /* This port will use its local lid, and consume the entire required lid range.
- Thus we can skip that range. */
- /* If the disc_max_lid is greater then lid, we can skip right to it,
- since we've done all neccessary checks on the lids in between. */
- if (disc_max_lid > lid)
- lid =
- disc_max_lid;
- }
- }
- }
- }
- }
-
- if (is_free) {
- if (p_range)
- p_range->max_lid = lid;
- else {
- p_range = (osm_lid_mgr_range_t *)
- malloc(sizeof(osm_lid_mgr_range_t));
- if (p_range) {
- p_range->min_lid = lid;
- p_range->max_lid = lid;
- }
- }
- } else {
- /* this lid is used so we need to finalize the previous free range */
- if (p_range) {
- cl_qlist_insert_tail(&p_mgr->free_ranges,
- &p_range->item);
- OSM_LOG(p_mgr->p_log, OSM_LOG_DEBUG,
- "new free lid range [%u:%u]\n",
- p_range->min_lid, p_range->max_lid);
- p_range = NULL;
- }
- }
- }
-
-AfterScanningLids:
- /* after scanning all known lids we need to extend the last range
- to the max allowed lid */
- if (!p_range) {
- p_range =
- (osm_lid_mgr_range_t *) malloc(sizeof(osm_lid_mgr_range_t));
- /*
- The p_range can be NULL in one of 2 cases:
- 1. If max_defined_lid == 0. In this case, we want the
- entire range.
- 2. If all lids discovered in the loop where mapped. In this
- case, no free range exists and we want to define it after the
- last mapped lid.
- */
- if (p_range)
- p_range->min_lid = lid;
- }
- if (p_range) {
- p_range->max_lid = p_mgr->p_subn->max_ucast_lid_ho;
- cl_qlist_insert_tail(&p_mgr->free_ranges, &p_range->item);
- OSM_LOG(p_mgr->p_log, OSM_LOG_DEBUG,
- "final free lid range [%u:%u]\n",
- p_range->min_lid, p_range->max_lid);
- }
-
- OSM_LOG_EXIT(p_mgr->p_log);
- return status;
-}
-
-/**********************************************************************
- check if the given range of lids is free
-**********************************************************************/
-static boolean_t
-__osm_lid_mgr_is_range_not_persistent(IN osm_lid_mgr_t * const p_mgr,
- IN const uint16_t lid,
- IN const uint16_t num_lids)
-{
- uint16_t i;
- cl_status_t status;
- osm_port_t *p_port;
- const uint8_t start_lid = (uint8_t) (1 << p_mgr->p_subn->opt.lmc);
- const cl_ptr_vector_t *const p_tbl = &p_mgr->used_lids;
-
- if (lid < start_lid)
- return (FALSE);
-
- for (i = lid; i < lid + num_lids; i++) {
- status = cl_ptr_vector_at(p_tbl, i, (void *)&p_port);
- if (status == CL_SUCCESS) {
- if (p_port != NULL)
- return (FALSE);
- } else
- /*
- We are out of range in the array.
- Consider all further entries "free".
- */
- return (TRUE);
- }
-
- return (TRUE);
-}
-
-/**********************************************************************
-find a free lid range
-**********************************************************************/
-static void
-__osm_lid_mgr_find_free_lid_range(IN osm_lid_mgr_t * const p_mgr,
- IN const uint8_t num_lids,
- OUT uint16_t * const p_min_lid,
- OUT uint16_t * const p_max_lid)
-{
- uint16_t lid;
- cl_list_item_t *p_item;
- cl_list_item_t *p_next_item;
- osm_lid_mgr_range_t *p_range = NULL;
- uint8_t lmc_num_lids;
- uint16_t lmc_mask;
-
- OSM_LOG(p_mgr->p_log, OSM_LOG_DEBUG, "LMC = %u, number LIDs = %u\n",
- p_mgr->p_subn->opt.lmc, num_lids);
-
- lmc_num_lids = (1 << p_mgr->p_subn->opt.lmc);
- if (p_mgr->p_subn->opt.lmc)
- lmc_mask = ~((1 << p_mgr->p_subn->opt.lmc) - 1);
- else
- lmc_mask = 0xffff;
-
- /*
- Search the list of free lid ranges for a range which is big enough
- */
- p_item = cl_qlist_head(&p_mgr->free_ranges);
- while (p_item != cl_qlist_end(&p_mgr->free_ranges)) {
- p_next_item = cl_qlist_next(p_item);
- p_range = (osm_lid_mgr_range_t *) p_item;
-
- lid = p_range->min_lid;
-
- /* if we require more then one lid we must align to LMC */
- if (num_lids > 1) {
- if ((lid & lmc_mask) != lid)
- lid = (lid + lmc_num_lids) & lmc_mask;
- }
-
- /* but we can be out of the range */
- if (lid + num_lids - 1 <= p_range->max_lid) {
- /* ok let us use that range */
- if (lid + num_lids - 1 == p_range->max_lid)
- /* we consumed the entire range */
- cl_qlist_remove_item(&p_mgr->free_ranges,
- p_item);
- else
- /* only update the available range */
- p_range->min_lid = lid + num_lids;
-
- *p_min_lid = lid;
- *p_max_lid = (uint16_t) (lid + num_lids - 1);
- return;
- }
- p_item = p_next_item;
- }
-
- /*
- Couldn't find a free range of lids.
- */
- *p_min_lid = *p_max_lid = 0;
- /* if we run out of lids, give an error and abort! */
- OSM_LOG(p_mgr->p_log, OSM_LOG_ERROR, "ERR 0307: "
- "OPENSM RAN OUT OF LIDS!!!\n");
- CL_ASSERT(0);
-}
-
-/**********************************************************************
- **********************************************************************/
-static void
-__osm_lid_mgr_cleanup_discovered_port_lid_range(IN osm_lid_mgr_t * p_mgr,
- IN osm_port_t * p_port)
-{
- cl_ptr_vector_t *p_discovered_vec = &p_mgr->p_subn->port_lid_tbl;
- uint16_t lid, min_lid, max_lid;
- uint16_t max_tbl_lid =
- (uint16_t) (cl_ptr_vector_get_size(p_discovered_vec));
-
- osm_port_get_lid_range_ho(p_port, &min_lid, &max_lid);
- min_lid = __osm_trim_lid(min_lid);
- max_lid = __osm_trim_lid(max_lid);
- for (lid = min_lid; lid <= max_lid; lid++) {
- if ((lid < max_tbl_lid) &&
- (p_port ==
- (osm_port_t *) cl_ptr_vector_get(p_discovered_vec, lid)))
- cl_ptr_vector_set(p_discovered_vec, lid, NULL);
- }
-}
-
-/**********************************************************************
- 0.1 if the port info lid matches the guid2lid return 0
- 0.2 if the port info has a lid and that range is empty in
- port_lid_tbl, return 0 and update the port_lid_tbl and
- guid2lid
- 0.3 else find an empty space in port_lid_tbl, update the
- port_lid_tbl and guid2lid, return 1 to flag a change required.
-**********************************************************************/
-static int
-__osm_lid_mgr_get_port_lid(IN osm_lid_mgr_t * const p_mgr,
- IN osm_port_t * const p_port,
- OUT uint16_t * const p_min_lid,
- OUT uint16_t * const p_max_lid)
-{
- uint16_t lid, min_lid, max_lid;
- uint64_t guid;
- uint8_t num_lids = (1 << p_mgr->p_subn->opt.lmc);
- int lid_changed = 0;
- uint16_t lmc_mask;
-
- OSM_LOG_ENTER(p_mgr->p_log);
-
- if (p_mgr->p_subn->opt.lmc)
- lmc_mask = ~((1 << p_mgr->p_subn->opt.lmc) - 1);
- else
- lmc_mask = 0xffff;
-
- /* get the lid from the guid2lid */
- guid = cl_ntoh64(osm_port_get_guid(p_port));
-
- /* if the port is a base switch port 0 then we only need one lid */
- if (p_port->p_node->sw &&
- !osm_switch_sp0_is_lmc_capable(p_port->p_node->sw, p_mgr->p_subn))
- num_lids = 1;
-
- /* if the port matches the guid2lid */
- if (!osm_db_guid2lid_get(p_mgr->p_g2l, guid, &min_lid, &max_lid)) {
- *p_min_lid = min_lid;
- *p_max_lid = min_lid + num_lids - 1;
- if (min_lid == cl_ntoh16(osm_port_get_base_lid(p_port))) {
- OSM_LOG(p_mgr->p_log, OSM_LOG_DEBUG, "0x%016" PRIx64
- " matches its known lid:%u\n", guid, min_lid);
- goto Exit;
- } else {
- OSM_LOG(p_mgr->p_log, OSM_LOG_DEBUG,
- "0x%016" PRIx64 " with lid:%u "
- "does not match its known lid:%u\n",
- guid, cl_ntoh16(osm_port_get_base_lid(p_port)),
- min_lid);
- __osm_lid_mgr_cleanup_discovered_port_lid_range(p_mgr,
- p_port);
- /* we still need to send the setting to the target port */
- lid_changed = 1;
- goto Exit;
- }
- } else
- OSM_LOG(p_mgr->p_log, OSM_LOG_DEBUG,
- "0x%016" PRIx64 " has no persistent lid assigned\n",
- guid);
-
- /* if the port info carries a lid it must be lmc aligned and not mapped
- by the pesistent storage */
- min_lid = cl_ntoh16(osm_port_get_base_lid(p_port));
-
- /* we want to ignore the discovered lid if we are also on first sweep of
- reassign lids flow */
- if (min_lid &&
- !((p_mgr->p_subn->first_time_master_sweep == TRUE) &&
- (p_mgr->p_subn->opt.reassign_lids == TRUE))) {
- /* make sure lid is valid */
- if ((num_lids == 1) || ((min_lid & lmc_mask) == min_lid)) {
- /* is it free */
- if (__osm_lid_mgr_is_range_not_persistent
- (p_mgr, min_lid, num_lids)) {
- *p_min_lid = min_lid;
- *p_max_lid = min_lid + num_lids - 1;
- OSM_LOG(p_mgr->p_log, OSM_LOG_DEBUG,
- "0x%016" PRIx64
- " lid range:[%u-%u] is free\n",
- guid, *p_min_lid, *p_max_lid);
- goto NewLidSet;
- } else
- OSM_LOG(p_mgr->p_log, OSM_LOG_DEBUG,
- "0x%016" PRIx64 " existing lid "
- "range:[%u:%u] is not free\n",
- guid, min_lid, min_lid + num_lids - 1);
- } else
- OSM_LOG(p_mgr->p_log, OSM_LOG_DEBUG,
- "0x%016" PRIx64 " existing lid range:"
- "[%u:%u] is not lmc aligned\n",
- guid, min_lid, min_lid + num_lids - 1);
- }
-
- /* first cleanup the existing discovered lid range */
- __osm_lid_mgr_cleanup_discovered_port_lid_range(p_mgr, p_port);
-
- /* find an empty space */
- __osm_lid_mgr_find_free_lid_range(p_mgr, num_lids, p_min_lid,
- p_max_lid);
- OSM_LOG(p_mgr->p_log, OSM_LOG_DEBUG,
- "0x%016" PRIx64 " assigned a new lid range:[%u-%u]\n",
- guid, *p_min_lid, *p_max_lid);
- lid_changed = 1;
-
-NewLidSet:
- /* update the guid2lid db and used_lids */
- osm_db_guid2lid_set(p_mgr->p_g2l, guid, *p_min_lid, *p_max_lid);
- for (lid = *p_min_lid; lid <= *p_max_lid; lid++)
- cl_ptr_vector_set(&p_mgr->used_lids, lid, (void *)1);
-
-Exit:
- /* make sure the assigned lids are marked in port_lid_tbl */
- for (lid = *p_min_lid; lid <= *p_max_lid; lid++)
- cl_ptr_vector_set(&p_mgr->p_subn->port_lid_tbl, lid, p_port);
-
- OSM_LOG_EXIT(p_mgr->p_log);
- return lid_changed;
-}
-
-/**********************************************************************
- Set to INIT the remote port of the given physical port
- **********************************************************************/
-static void
-__osm_lid_mgr_set_remote_pi_state_to_init(IN osm_lid_mgr_t * const p_mgr,
- IN osm_physp_t * const p_physp)
-{
- osm_physp_t *p_rem_physp = osm_physp_get_remote(p_physp);
-
- if (p_rem_physp == NULL)
- return;
-
- /* but in some rare cases the remote side might be non responsive */
- ib_port_info_set_port_state(&p_rem_physp->port_info, IB_LINK_INIT);
-}
-
-/**********************************************************************
- **********************************************************************/
-static boolean_t
-__osm_lid_mgr_set_physp_pi(IN osm_lid_mgr_t * const p_mgr,
- IN osm_port_t * const p_port,
- IN osm_physp_t * const p_physp,
- IN ib_net16_t const lid)
-{
- uint8_t payload[IB_SMP_DATA_SIZE];
- ib_port_info_t *p_pi = (ib_port_info_t *) payload;
- const ib_port_info_t *p_old_pi;
- osm_madw_context_t context;
- osm_node_t *p_node;
- ib_api_status_t status;
- uint8_t mtu;
- uint8_t op_vls;
- uint8_t port_num;
- boolean_t send_set = FALSE;
-
- OSM_LOG_ENTER(p_mgr->p_log);
-
- /*
- Don't bother doing anything if this Physical Port is not valid.
- This allows simplified code in the caller.
- */
- if (!p_physp)
- goto Exit;
-
- port_num = osm_physp_get_port_num(p_physp);
- p_node = osm_physp_get_node_ptr(p_physp);
-
- if (osm_node_get_type(p_node) == IB_NODE_TYPE_SWITCH && port_num != 0) {
- /*
- Switch ports that are not numbered 0 should not be set
- with the following attributes as they are set later
- (during NO_CHANGE state in link mgr).
- */
- OSM_LOG(p_mgr->p_log, OSM_LOG_DEBUG,
- "Skipping switch port %u, GUID 0x%016" PRIx64 "\n",
- port_num, cl_ntoh64(osm_physp_get_port_guid(p_physp)));
- goto Exit;
- }
-
- p_old_pi = &p_physp->port_info;
-
- /*
- First, copy existing parameters from the PortInfo attribute we
- already have for this node.
-
- Second, update with default values that we know must be set for
- every Physical Port and the LID and set the neighbor MTU field
- appropriately.
-
- Third, send the SMP to this physical port.
- */
-
- memset(payload, 0, IB_SMP_DATA_SIZE);
- memcpy(payload, p_old_pi, sizeof(ib_port_info_t));
-
- /*
- Should never write back a value that is bigger then 3 in
- the PortPhysicalState field, so cannot simply copy!
-
- Actually we want to write there:
- port physical state - no change
- link down default state = polling
- port state - no change
- */
- p_pi->state_info2 = 0x02;
- ib_port_info_set_port_state(p_pi, IB_LINK_NO_CHANGE);
-
- if (ib_port_info_get_link_down_def_state(p_pi) !=
- ib_port_info_get_link_down_def_state(p_old_pi))
- send_set = TRUE;
-
- /* didn't get PortInfo before */
- if (!ib_port_info_get_port_state(p_old_pi))
- send_set = TRUE;
-
- p_pi->m_key = p_mgr->p_subn->opt.m_key;
- if (memcmp(&p_pi->m_key, &p_old_pi->m_key, sizeof(p_pi->m_key)))
- send_set = TRUE;
-
- p_pi->subnet_prefix = p_mgr->p_subn->opt.subnet_prefix;
- if (memcmp(&p_pi->subnet_prefix, &p_old_pi->subnet_prefix,
- sizeof(p_pi->subnet_prefix)))
- send_set = TRUE;
-
- p_pi->base_lid = lid;
- if (memcmp(&p_pi->base_lid, &p_old_pi->base_lid,
- sizeof(p_pi->base_lid)))
- send_set = TRUE;
-
- /* we are updating the ports with our local sm_base_lid */
- p_pi->master_sm_base_lid = p_mgr->p_subn->sm_base_lid;
- if (memcmp(&p_pi->master_sm_base_lid, &p_old_pi->master_sm_base_lid,
- sizeof(p_pi->master_sm_base_lid)))
- send_set = TRUE;
-
- p_pi->m_key_lease_period = p_mgr->p_subn->opt.m_key_lease_period;
- if (memcmp(&p_pi->m_key_lease_period, &p_old_pi->m_key_lease_period,
- sizeof(p_pi->m_key_lease_period)))
- send_set = TRUE;
-
- /*
- we want to set the timeout for both the switch port 0
- and the CA ports
- */
- ib_port_info_set_timeout(p_pi, p_mgr->p_subn->opt.subnet_timeout);
- if (ib_port_info_get_timeout(p_pi) !=
- ib_port_info_get_timeout(p_old_pi))
- send_set = TRUE;
-
- if (port_num != 0) {
- /*
- CAs don't have a port 0, and for switch port 0,
- the state bits are ignored.
- This is not the switch management port
- */
- p_pi->link_width_enabled = p_old_pi->link_width_supported;
- if (memcmp(&p_pi->link_width_enabled,
- &p_old_pi->link_width_enabled,
- sizeof(p_pi->link_width_enabled)))
- send_set = TRUE;
-
- /* M_KeyProtectBits are always zero */
- p_pi->mkey_lmc = p_mgr->p_subn->opt.lmc;
- if (memcmp(&p_pi->mkey_lmc, &p_old_pi->mkey_lmc,
- sizeof(p_pi->mkey_lmc)))
- send_set = TRUE;
-
- /* calc new op_vls and mtu */
- op_vls =
- osm_physp_calc_link_op_vls(p_mgr->p_log, p_mgr->p_subn,
- p_physp);
- mtu = osm_physp_calc_link_mtu(p_mgr->p_log, p_physp);
-
- ib_port_info_set_neighbor_mtu(p_pi, mtu);
-
- if (ib_port_info_get_neighbor_mtu(p_pi) !=
- ib_port_info_get_neighbor_mtu(p_old_pi))
- send_set = TRUE;
-
- ib_port_info_set_op_vls(p_pi, op_vls);
- if (ib_port_info_get_op_vls(p_pi) !=
- ib_port_info_get_op_vls(p_old_pi))
- send_set = TRUE;
-
- /*
- Several timeout mechanisms:
- */
- ib_port_info_set_phy_and_overrun_err_thd(p_pi,
- p_mgr->p_subn->opt.
- local_phy_errors_threshold,
- p_mgr->p_subn->opt.
- overrun_errors_threshold);
-
- if (memcmp(&p_pi->error_threshold, &p_old_pi->error_threshold,
- sizeof(p_pi->error_threshold)))
- send_set = TRUE;
-
- /*
- To reset the port state machine we can send
- PortInfo.State = DOWN. (see: 7.2.7 p171 lines:10-19)
- */
- if ((mtu != ib_port_info_get_neighbor_mtu(p_old_pi)) ||
- (op_vls != ib_port_info_get_op_vls(p_old_pi))) {
- OSM_LOG(p_mgr->p_log, OSM_LOG_DEBUG,
- "Sending Link Down to GUID 0x%016"
- PRIx64 " port %d due to op_vls or "
- "mtu change. MTU:%u,%u VL_CAP:%u,%u\n",
- cl_ntoh64(osm_physp_get_port_guid(p_physp)),
- port_num, mtu,
- ib_port_info_get_neighbor_mtu(p_old_pi),
- op_vls, ib_port_info_get_op_vls(p_old_pi));
-
- /*
- we need to make sure the internal DB will follow the
- fact that the remote port is also going through
- "down" state into "init"...
- */
- __osm_lid_mgr_set_remote_pi_state_to_init(p_mgr,
- p_physp);
-
- ib_port_info_set_port_state(p_pi, IB_LINK_DOWN);
- if (ib_port_info_get_port_state(p_pi) !=
- ib_port_info_get_port_state(p_old_pi))
- send_set = TRUE;
- }
- } else {
- /*
- For Port 0, NeighborMTU is relevant only for Enh. SP0.
- In this case, we'll set the MTU according to the mtu_cap
- */
- ib_port_info_set_neighbor_mtu(p_pi,
- ib_port_info_get_mtu_cap
- (p_old_pi));
- if (ib_port_info_get_neighbor_mtu(p_pi) !=
- ib_port_info_get_neighbor_mtu(p_old_pi))
- send_set = TRUE;
-
- OSM_LOG(p_mgr->p_log, OSM_LOG_DEBUG,
- "Updating neighbor_mtu on switch GUID 0x%016" PRIx64
- " port 0 to:%u\n",
- cl_ntoh64(osm_physp_get_port_guid(p_physp)),
- ib_port_info_get_neighbor_mtu(p_pi));
-
- /* Determine if enhanced switch port 0 and if so set LMC */
- if (osm_switch_sp0_is_lmc_capable(p_node->sw, p_mgr->p_subn)) {
- /* M_KeyProtectBits are always zero */
- p_pi->mkey_lmc = p_mgr->p_subn->opt.lmc;
- if (memcmp(&p_pi->mkey_lmc, &p_old_pi->mkey_lmc,
- sizeof(p_pi->mkey_lmc)))
- send_set = TRUE;
- }
- }
-
- context.pi_context.node_guid = osm_node_get_node_guid(p_node);
- context.pi_context.port_guid = osm_physp_get_port_guid(p_physp);
- context.pi_context.set_method = TRUE;
- context.pi_context.light_sweep = FALSE;
- context.pi_context.active_transition = FALSE;
-
- /*
- We need to set the cli_rereg bit when we are in first_time_master_sweep
- for ports supporting the ClientReregistration Vol1 (v1.2) p811 14.4.11
- Also, if this port was just now discovered, then we should also set
- the cli_rereg bit. We know that the port was just discovered if its
- is_new field is set.
- */
- if ((p_mgr->p_subn->first_time_master_sweep == TRUE || p_port->is_new)
- && !p_mgr->p_subn->opt.no_clients_rereg
- && (p_old_pi->capability_mask & IB_PORT_CAP_HAS_CLIENT_REREG)) {
- OSM_LOG(p_mgr->p_log, OSM_LOG_DEBUG,
- "Seting client rereg on %s, port %d\n",
- p_port->p_node->print_desc, p_port->p_physp->port_num);
- ib_port_info_set_client_rereg(p_pi, 1);
- send_set = TRUE;
- } else
- ib_port_info_set_client_rereg(p_pi, 0);
-
- /* We need to send the PortInfo Set request with the new sm_lid
- in the following cases:
- 1. There is a change in the values (send_set == TRUE)
- 2. first_time_master_sweep flag on the subnet is TRUE. This means the
- SM just became master, and it then needs to send a PortInfo Set to
- every port.
- */
- if (p_mgr->p_subn->first_time_master_sweep == TRUE)
- send_set = TRUE;
-
- if (send_set) {
- p_mgr->send_set_reqs = TRUE;
- status = osm_req_set(p_mgr->sm,
- osm_physp_get_dr_path_ptr(p_physp),
- payload,
- sizeof(payload),
- IB_MAD_ATTR_PORT_INFO,
- cl_hton32(osm_physp_get_port_num(p_physp)),
- CL_DISP_MSGID_NONE, &context);
- }
-
-Exit:
- OSM_LOG_EXIT(p_mgr->p_log);
- return send_set;
-}
-
-/**********************************************************************
- Processes our own node
- Lock must already be held.
-**********************************************************************/
-static boolean_t
-__osm_lid_mgr_process_our_sm_node(IN osm_lid_mgr_t * const p_mgr)
-{
- osm_port_t *p_port;
- uint16_t min_lid_ho;
- uint16_t max_lid_ho;
- boolean_t res = TRUE;
-
- OSM_LOG_ENTER(p_mgr->p_log);
-
- /*
- Acquire our own port object.
- */
- p_port =
- osm_get_port_by_guid(p_mgr->p_subn, p_mgr->p_subn->sm_port_guid);
- if (!p_port) {
- OSM_LOG(p_mgr->p_log, OSM_LOG_ERROR, "ERR 0308: "
- "Can't acquire SM's port object, GUID 0x%016" PRIx64
- "\n", cl_ntoh64(p_mgr->p_subn->sm_port_guid));
- res = FALSE;
- goto Exit;
- }
-
- /*
- Determine the LID this SM will use for its own port.
- Be careful. With an LMC > 0, the bottom of the LID range becomes
- unusable, since port hardware will mask off least significant bits,
- leaving a LID of 0 (invalid). Therefore, make sure that we always
- configure the SM with a LID that has non-zero bits, even after
- LMC masking by hardware.
- */
- __osm_lid_mgr_get_port_lid(p_mgr, p_port, &min_lid_ho, &max_lid_ho);
- OSM_LOG(p_mgr->p_log, OSM_LOG_DEBUG,
- "Current base LID is %u\n", min_lid_ho);
- /*
- Update subnet object.
- */
- p_mgr->p_subn->master_sm_base_lid = cl_hton16(min_lid_ho);
- p_mgr->p_subn->sm_base_lid = cl_hton16(min_lid_ho);
-
- OSM_LOG(p_mgr->p_log, OSM_LOG_VERBOSE,
- "Assigning SM's port 0x%016" PRIx64
- "\n\t\t\t\tto LID range [%u,%u]\n",
- cl_ntoh64(osm_port_get_guid(p_port)), min_lid_ho, max_lid_ho);
-
- /*
- Set the PortInfo the Physical Port associated with this Port.
- */
- __osm_lid_mgr_set_physp_pi(p_mgr, p_port, p_port->p_physp,
- cl_hton16(min_lid_ho));
-
-Exit:
- OSM_LOG_EXIT(p_mgr->p_log);
- return res;
-}
-
-/**********************************************************************
- **********************************************************************/
-osm_signal_t osm_lid_mgr_process_sm(IN osm_lid_mgr_t * const p_mgr)
-{
- osm_signal_t signal = OSM_SIGNAL_DONE_PENDING;
-
- OSM_LOG_ENTER(p_mgr->p_log);
-
- CL_ASSERT(p_mgr->p_subn->sm_port_guid);
-
- CL_PLOCK_EXCL_ACQUIRE(p_mgr->p_lock);
-
- /* initialize the port_lid_tbl and empty ranges list following the
- persistent db */
- __osm_lid_mgr_init_sweep(p_mgr);
-
- /* Set the send_set_reqs of the p_mgr to FALSE, and
- we'll see if any set requests were sent. If not -
- can signal OSM_SIGNAL_DONE */
- p_mgr->send_set_reqs = FALSE;
- if (__osm_lid_mgr_process_our_sm_node(p_mgr) == FALSE)
- /* The initialization failed */
- signal = OSM_SIGNAL_DONE;
-
- if (p_mgr->send_set_reqs == FALSE)
- signal = OSM_SIGNAL_DONE;
-
- CL_PLOCK_RELEASE(p_mgr->p_lock);
-
- OSM_LOG_EXIT(p_mgr->p_log);
- return (signal);
-}
-
-/**********************************************************************
- 1 go through all ports in the subnet.
- 1.1 call __osm_lid_mgr_get_port_min_lid
- 1.2 if a change is required send the port info
- 2 if any change send the signal PENDING...
-**********************************************************************/
-osm_signal_t osm_lid_mgr_process_subnet(IN osm_lid_mgr_t * const p_mgr)
-{
- osm_signal_t signal;
- cl_qmap_t *p_port_guid_tbl;
- osm_port_t *p_port;
- ib_net64_t port_guid;
- uint16_t min_lid_ho, max_lid_ho;
- int lid_changed;
-
- CL_ASSERT(p_mgr);
-
- OSM_LOG_ENTER(p_mgr->p_log);
-
- CL_PLOCK_EXCL_ACQUIRE(p_mgr->p_lock);
-
- CL_ASSERT(p_mgr->p_subn->sm_port_guid);
-
- /* Set the send_set_reqs of the p_mgr to FALSE, and
- we'll see if any set requests were sent. If not -
- can signal OSM_SIGNAL_DONE */
- p_mgr->send_set_reqs = FALSE;
-
- p_port_guid_tbl = &p_mgr->p_subn->port_guid_tbl;
-
- for (p_port = (osm_port_t *) cl_qmap_head(p_port_guid_tbl);
- p_port != (osm_port_t *) cl_qmap_end(p_port_guid_tbl);
- p_port = (osm_port_t *) cl_qmap_next(&p_port->map_item)) {
- port_guid = osm_port_get_guid(p_port);
-
- /*
- Our own port is a special case in that we want to
- assign a LID to ourselves first, since we have to
- advertise that LID value to the other ports.
-
- For that reason, our node is treated separately and
- we will not add it to any of these lists.
- */
- if (port_guid == p_mgr->p_subn->sm_port_guid) {
- OSM_LOG(p_mgr->p_log, OSM_LOG_DEBUG,
- "Skipping our own port 0x%016" PRIx64 "\n",
- cl_ntoh64(port_guid));
- continue;
- }
-
- /*
- get the port lid range - we need to send it on first active
- sweep or if there was a change (the result of
- __osm_lid_mgr_get_port_lid)
- */
- lid_changed =
- __osm_lid_mgr_get_port_lid(p_mgr, p_port, &min_lid_ho,
- &max_lid_ho);
-
- /* we can call the function to update the port info as it known
- to look for any field change and will only send an updated
- if required */
- OSM_LOG(p_mgr->p_log, OSM_LOG_VERBOSE,
- "Assigned port 0x%016" PRIx64
- ", LID [%u,%u]\n", cl_ntoh64(port_guid),
- min_lid_ho, max_lid_ho);
-
- /* the proc returns the fact it sent a set port info */
- if (__osm_lid_mgr_set_physp_pi
- (p_mgr, p_port, p_port->p_physp, cl_hton16(min_lid_ho)))
- p_mgr->send_set_reqs = TRUE;
- } /* all ports */
-
- /* store the guid to lid table in persistent db */
- osm_db_store(p_mgr->p_g2l);
-
- if (p_mgr->send_set_reqs == FALSE)
- signal = OSM_SIGNAL_DONE;
- else
- signal = OSM_SIGNAL_DONE_PENDING;
-
- CL_PLOCK_RELEASE(p_mgr->p_lock);
-
- OSM_LOG_EXIT(p_mgr->p_log);
- return (signal);
-}
diff --git a/contrib/ofed/management/opensm/opensm/osm_lin_fwd_rcv.c b/contrib/ofed/management/opensm/opensm/osm_lin_fwd_rcv.c
deleted file mode 100644
index c3d8633..0000000
--- a/contrib/ofed/management/opensm/opensm/osm_lin_fwd_rcv.c
+++ /dev/null
@@ -1,101 +0,0 @@
-/*
- * Copyright (c) 2004-2008 Voltaire, Inc. All rights reserved.
- * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved.
- * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- */
-
-/*
- * Abstract:
- * Implementation of osm_lft_rcv_t.
- * This object represents the NodeDescription Receiver object.
- * This object is part of the opensm family of objects.
- */
-
-#if HAVE_CONFIG_H
-# include <config.h>
-#endif /* HAVE_CONFIG_H */
-
-#include <string.h>
-#include <complib/cl_debug.h>
-#include <opensm/osm_switch.h>
-#include <opensm/osm_sm.h>
-
-/**********************************************************************
- **********************************************************************/
-void osm_lft_rcv_process(IN void *context, IN void *data)
-{
- osm_sm_t *sm = context;
- osm_madw_t *p_madw = data;
- ib_smp_t *p_smp;
- uint32_t block_num;
- osm_switch_t *p_sw;
- osm_lft_context_t *p_lft_context;
- uint8_t *p_block;
- ib_net64_t node_guid;
- ib_api_status_t status;
-
- CL_ASSERT(sm);
-
- OSM_LOG_ENTER(sm->p_log);
-
- CL_ASSERT(p_madw);
-
- p_smp = osm_madw_get_smp_ptr(p_madw);
- p_block = (uint8_t *) ib_smp_get_payload_ptr(p_smp);
- block_num = cl_ntoh32(p_smp->attr_mod);
-
- /*
- Acquire the switch object for this switch.
- */
- p_lft_context = osm_madw_get_lft_context_ptr(p_madw);
- node_guid = p_lft_context->node_guid;
-
- CL_PLOCK_EXCL_ACQUIRE(sm->p_lock);
- p_sw = osm_get_switch_by_guid(sm->p_subn, node_guid);
-
- if (!p_sw) {
- OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR 0401: "
- "LFT received for nonexistent node "
- "0x%" PRIx64 "\n", cl_ntoh64(node_guid));
- } else {
- status = osm_switch_set_lft_block(p_sw, p_block, block_num);
- if (status != IB_SUCCESS) {
- OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR 0402: "
- "Setting forwarding table block failed (%s)"
- "\n\t\t\t\tSwitch 0x%" PRIx64 "\n",
- ib_get_err_str(status), cl_ntoh64(node_guid));
- }
- }
-
- CL_PLOCK_RELEASE(sm->p_lock);
- OSM_LOG_EXIT(sm->p_log);
-}
diff --git a/contrib/ofed/management/opensm/opensm/osm_link_mgr.c b/contrib/ofed/management/opensm/opensm/osm_link_mgr.c
deleted file mode 100644
index 37e3e1b..0000000
--- a/contrib/ofed/management/opensm/opensm/osm_link_mgr.c
+++ /dev/null
@@ -1,416 +0,0 @@
-/*
- * Copyright (c) 2004-2008 Voltaire, Inc. All rights reserved.
- * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved.
- * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- */
-
-/*
- * Abstract:
- * Implementation of osm_link_mgr_t.
- * This file implements the Link Manager object.
- */
-
-#if HAVE_CONFIG_H
-# include <config.h>
-#endif /* HAVE_CONFIG_H */
-
-#include <string.h>
-#include <iba/ib_types.h>
-#include <complib/cl_debug.h>
-#include <opensm/osm_sm.h>
-#include <opensm/osm_node.h>
-#include <opensm/osm_switch.h>
-#include <opensm/osm_helper.h>
-#include <opensm/osm_msgdef.h>
-
-/**********************************************************************
- **********************************************************************/
-static boolean_t
-__osm_link_mgr_set_physp_pi(osm_sm_t * sm,
- IN osm_physp_t * const p_physp,
- IN uint8_t const port_state)
-{
- uint8_t payload[IB_SMP_DATA_SIZE];
- ib_port_info_t *const p_pi = (ib_port_info_t *) payload;
- const ib_port_info_t *p_old_pi;
- osm_madw_context_t context;
- osm_node_t *p_node;
- ib_api_status_t status;
- uint8_t port_num;
- uint8_t mtu;
- uint8_t op_vls;
- boolean_t esp0 = FALSE;
- boolean_t send_set = FALSE;
- osm_physp_t *p_remote_physp;
-
- OSM_LOG_ENTER(sm->p_log);
-
- p_node = osm_physp_get_node_ptr(p_physp);
-
- port_num = osm_physp_get_port_num(p_physp);
-
- if (port_num == 0) {
- /*
- CAs don't have a port 0, and for switch port 0,
- we need to check if this is enhanced or base port 0.
- For base port 0 the following parameters are not valid (p822, table 145).
- */
- if (!p_node->sw) {
- OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR 4201: "
- "Cannot find switch by guid: 0x%" PRIx64 "\n",
- cl_ntoh64(p_node->node_info.node_guid));
- goto Exit;
- }
-
- if (ib_switch_info_is_enhanced_port0(&p_node->sw->switch_info)
- == FALSE) {
- /* This means the switch doesn't support enhanced port 0.
- Can skip it. */
- OSM_LOG(sm->p_log, OSM_LOG_DEBUG,
- "Skipping port 0, GUID 0x%016" PRIx64 "\n",
- cl_ntoh64(osm_physp_get_port_guid(p_physp)));
- goto Exit;
- }
- esp0 = TRUE;
- }
-
- /*
- PAST THIS POINT WE ARE HANDLING EITHER A NON PORT 0 OR ENHANCED PORT 0
- */
-
- p_old_pi = &p_physp->port_info;
-
- memset(payload, 0, IB_SMP_DATA_SIZE);
- memcpy(payload, p_old_pi, sizeof(ib_port_info_t));
-
- /*
- Should never write back a value that is bigger then 3 in
- the PortPhysicalState field - so can not simply copy!
-
- Actually we want to write there:
- port physical state - no change,
- link down default state = polling
- port state - as requested.
- */
- p_pi->state_info2 = 0x02;
- ib_port_info_set_port_state(p_pi, port_state);
-
- if (ib_port_info_get_link_down_def_state(p_pi) !=
- ib_port_info_get_link_down_def_state(p_old_pi))
- send_set = TRUE;
-
- /* didn't get PortInfo before */
- if (!ib_port_info_get_port_state(p_old_pi))
- send_set = TRUE;
-
- /* we only change port fields if we do not change state */
- if (port_state == IB_LINK_NO_CHANGE) {
- /* The following fields are relevant only for CA port, router, or Enh. SP0 */
- if (osm_node_get_type(p_node) != IB_NODE_TYPE_SWITCH ||
- port_num == 0) {
- p_pi->m_key = sm->p_subn->opt.m_key;
- if (memcmp(&p_pi->m_key, &p_old_pi->m_key,
- sizeof(p_pi->m_key)))
- send_set = TRUE;
-
- p_pi->subnet_prefix = sm->p_subn->opt.subnet_prefix;
- if (memcmp(&p_pi->subnet_prefix,
- &p_old_pi->subnet_prefix,
- sizeof(p_pi->subnet_prefix)))
- send_set = TRUE;
-
- p_pi->base_lid = osm_physp_get_base_lid(p_physp);
- if (memcmp(&p_pi->base_lid, &p_old_pi->base_lid,
- sizeof(p_pi->base_lid)))
- send_set = TRUE;
-
- /* we are initializing the ports with our local sm_base_lid */
- p_pi->master_sm_base_lid = sm->p_subn->sm_base_lid;
- if (memcmp(&p_pi->master_sm_base_lid,
- &p_old_pi->master_sm_base_lid,
- sizeof(p_pi->master_sm_base_lid)))
- send_set = TRUE;
-
- p_pi->m_key_lease_period =
- sm->p_subn->opt.m_key_lease_period;
- if (memcmp(&p_pi->m_key_lease_period,
- &p_old_pi->m_key_lease_period,
- sizeof(p_pi->m_key_lease_period)))
- send_set = TRUE;
-
- if (esp0 == FALSE)
- p_pi->mkey_lmc = sm->p_subn->opt.lmc;
- else {
- if (sm->p_subn->opt.lmc_esp0)
- p_pi->mkey_lmc = sm->p_subn->opt.lmc;
- else
- p_pi->mkey_lmc = 0;
- }
- if (memcmp(&p_pi->mkey_lmc, &p_old_pi->mkey_lmc,
- sizeof(p_pi->mkey_lmc)))
- send_set = TRUE;
-
- ib_port_info_set_timeout(p_pi,
- sm->p_subn->opt.
- subnet_timeout);
- if (ib_port_info_get_timeout(p_pi) !=
- ib_port_info_get_timeout(p_old_pi))
- send_set = TRUE;
- }
-
- /*
- Several timeout mechanisms:
- */
- p_remote_physp = osm_physp_get_remote(p_physp);
- if (port_num != 0 && p_remote_physp) {
- if (osm_node_get_type(osm_physp_get_node_ptr(p_physp))
- == IB_NODE_TYPE_ROUTER) {
- ib_port_info_set_hoq_lifetime(p_pi,
- sm->p_subn->
- opt.
- leaf_head_of_queue_lifetime);
- } else
- if (osm_node_get_type
- (osm_physp_get_node_ptr(p_physp)) ==
- IB_NODE_TYPE_SWITCH) {
- /* Is remote end CA or router (a leaf port) ? */
- if (osm_node_get_type
- (osm_physp_get_node_ptr(p_remote_physp)) !=
- IB_NODE_TYPE_SWITCH) {
- ib_port_info_set_hoq_lifetime(p_pi,
- sm->
- p_subn->
- opt.
- leaf_head_of_queue_lifetime);
- ib_port_info_set_vl_stall_count(p_pi,
- sm->
- p_subn->
- opt.
- leaf_vl_stall_count);
- } else {
- ib_port_info_set_hoq_lifetime(p_pi,
- sm->
- p_subn->
- opt.
- head_of_queue_lifetime);
- ib_port_info_set_vl_stall_count(p_pi,
- sm->
- p_subn->
- opt.
- vl_stall_count);
- }
- }
- if (ib_port_info_get_hoq_lifetime(p_pi) !=
- ib_port_info_get_hoq_lifetime(p_old_pi) ||
- ib_port_info_get_vl_stall_count(p_pi) !=
- ib_port_info_get_vl_stall_count(p_old_pi))
- send_set = TRUE;
- }
-
- ib_port_info_set_phy_and_overrun_err_thd(p_pi,
- sm->p_subn->opt.
- local_phy_errors_threshold,
- sm->p_subn->opt.
- overrun_errors_threshold);
- if (memcmp(&p_pi->error_threshold, &p_old_pi->error_threshold,
- sizeof(p_pi->error_threshold)))
- send_set = TRUE;
-
- /*
- Set the easy common parameters for all port types,
- then determine the neighbor MTU.
- */
- p_pi->link_width_enabled = p_old_pi->link_width_supported;
- if (memcmp(&p_pi->link_width_enabled,
- &p_old_pi->link_width_enabled,
- sizeof(p_pi->link_width_enabled)))
- send_set = TRUE;
-
- if (sm->p_subn->opt.force_link_speed &&
- (sm->p_subn->opt.force_link_speed != 15 ||
- ib_port_info_get_link_speed_enabled(p_pi) !=
- ib_port_info_get_link_speed_sup(p_pi))) {
- ib_port_info_set_link_speed_enabled(p_pi,
- sm->p_subn->opt.
- force_link_speed);
- if (memcmp(&p_pi->link_speed, &p_old_pi->link_speed,
- sizeof(p_pi->link_speed)))
- send_set = TRUE;
- }
-
- /* calc new op_vls and mtu */
- op_vls =
- osm_physp_calc_link_op_vls(sm->p_log, sm->p_subn, p_physp);
- mtu = osm_physp_calc_link_mtu(sm->p_log, p_physp);
-
- ib_port_info_set_neighbor_mtu(p_pi, mtu);
- if (ib_port_info_get_neighbor_mtu(p_pi) !=
- ib_port_info_get_neighbor_mtu(p_old_pi))
- send_set = TRUE;
-
- ib_port_info_set_op_vls(p_pi, op_vls);
- if (ib_port_info_get_op_vls(p_pi) !=
- ib_port_info_get_op_vls(p_old_pi))
- send_set = TRUE;
-
- /* provide the vl_high_limit from the qos mgr */
- if (sm->p_subn->opt.qos &&
- p_physp->vl_high_limit != p_old_pi->vl_high_limit) {
- send_set = TRUE;
- p_pi->vl_high_limit = p_physp->vl_high_limit;
- }
- }
-
- if (port_state != IB_LINK_NO_CHANGE &&
- port_state != ib_port_info_get_port_state(p_old_pi)) {
- send_set = TRUE;
- if (port_state == IB_LINK_ACTIVE)
- context.pi_context.active_transition = TRUE;
- else
- context.pi_context.active_transition = FALSE;
- }
-
- context.pi_context.node_guid = osm_node_get_node_guid(p_node);
- context.pi_context.port_guid = osm_physp_get_port_guid(p_physp);
- context.pi_context.set_method = TRUE;
- context.pi_context.light_sweep = FALSE;
-
- /* We need to send the PortInfoSet request with the new sm_lid
- in the following cases:
- 1. There is a change in the values (send_set == TRUE)
- 2. This is a switch external port (so it wasn't handled yet by
- osm_lid_mgr) and first_time_master_sweep flag on the subnet is TRUE,
- which means the SM just became master, and it then needs to send at
- PortInfoSet to every port.
- */
- if (osm_node_get_type(p_node) == IB_NODE_TYPE_SWITCH && port_num
- && sm->p_subn->first_time_master_sweep == TRUE)
- send_set = TRUE;
-
- if (send_set)
- status = osm_req_set(sm, osm_physp_get_dr_path_ptr(p_physp),
- payload, sizeof(payload),
- IB_MAD_ATTR_PORT_INFO,
- cl_hton32(port_num),
- CL_DISP_MSGID_NONE, &context);
-
-Exit:
- OSM_LOG_EXIT(sm->p_log);
- return send_set;
-}
-
-/**********************************************************************
- **********************************************************************/
-static osm_signal_t
-__osm_link_mgr_process_node(osm_sm_t * sm,
- IN osm_node_t * const p_node,
- IN const uint8_t link_state)
-{
- uint32_t i;
- uint32_t num_physp;
- osm_physp_t *p_physp;
- uint8_t current_state;
- osm_signal_t signal = OSM_SIGNAL_DONE;
-
- OSM_LOG_ENTER(sm->p_log);
-
- OSM_LOG(sm->p_log, OSM_LOG_DEBUG,
- "Node 0x%" PRIx64 " going to %s\n",
- cl_ntoh64(osm_node_get_node_guid(p_node)),
- ib_get_port_state_str(link_state));
-
- /*
- Set the PortInfo for every Physical Port associated
- with this Port. Start iterating with port 1, since the linkstate
- is not applicable to the management port on switches.
- */
- num_physp = osm_node_get_num_physp(p_node);
- for (i = 0; i < num_physp; i++) {
- /*
- Don't bother doing anything if this Physical Port is not valid.
- or if the state of the port is already better then the
- specified state.
- */
- p_physp = osm_node_get_physp_ptr(p_node, (uint8_t) i);
- if (!p_physp)
- continue;
-
- current_state = osm_physp_get_port_state(p_physp);
- if (current_state == IB_LINK_DOWN)
- continue;
-
- /*
- Normally we only send state update if state is lower
- then required state. However, we need to send update if
- no state change required.
- */
- if (link_state != IB_LINK_NO_CHANGE &&
- link_state <= current_state)
- OSM_LOG(sm->p_log, OSM_LOG_DEBUG,
- "Physical port %u already %s. Skipping\n",
- p_physp->port_num,
- ib_get_port_state_str(current_state));
- else if (__osm_link_mgr_set_physp_pi(sm, p_physp, link_state))
- signal = OSM_SIGNAL_DONE_PENDING;
- }
-
- OSM_LOG_EXIT(sm->p_log);
- return (signal);
-}
-
-/**********************************************************************
- **********************************************************************/
-osm_signal_t osm_link_mgr_process(osm_sm_t * sm, IN const uint8_t link_state)
-{
- cl_qmap_t *p_node_guid_tbl;
- osm_node_t *p_node;
- osm_signal_t signal = OSM_SIGNAL_DONE;
-
- OSM_LOG_ENTER(sm->p_log);
-
- p_node_guid_tbl = &sm->p_subn->node_guid_tbl;
-
- CL_PLOCK_EXCL_ACQUIRE(sm->p_lock);
-
- for (p_node = (osm_node_t *) cl_qmap_head(p_node_guid_tbl);
- p_node != (osm_node_t *) cl_qmap_end(p_node_guid_tbl);
- p_node = (osm_node_t *) cl_qmap_next(&p_node->map_item)) {
- if (__osm_link_mgr_process_node(sm, p_node, link_state) ==
- OSM_SIGNAL_DONE_PENDING)
- signal = OSM_SIGNAL_DONE_PENDING;
- }
-
- CL_PLOCK_RELEASE(sm->p_lock);
-
- OSM_LOG_EXIT(sm->p_log);
- return (signal);
-}
diff --git a/contrib/ofed/management/opensm/opensm/osm_log.c b/contrib/ofed/management/opensm/opensm/osm_log.c
deleted file mode 100644
index 88633ab..0000000
--- a/contrib/ofed/management/opensm/opensm/osm_log.c
+++ /dev/null
@@ -1,337 +0,0 @@
-/*
- * Copyright (c) 2004-2008 Voltaire, Inc. All rights reserved.
- * Copyright (c) 2002-2006 Mellanox Technologies LTD. All rights reserved.
- * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- */
-
-/*
- * Abstract:
- * Implementation of osm_log_t.
- * This object represents the log file.
- * This object is part of the opensm family of objects.
- */
-
-#if HAVE_CONFIG_H
-# include <config.h>
-#endif /* HAVE_CONFIG_H */
-
-#include <opensm/osm_log.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include <stdarg.h>
-#include <fcntl.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <errno.h>
-
-static int log_exit_count = 0;
-
-#ifndef WIN32
-#include <sys/time.h>
-#include <unistd.h>
-#include <complib/cl_timer.h>
-
-static char *month_str[] = {
- "Jan",
- "Feb",
- "Mar",
- "Apr",
- "May",
- "Jun",
- "Jul",
- "Aug",
- "Sep",
- "Oct",
- "Nov",
- "Dec"
-};
-#else
-void OsmReportState(IN const char *p_str);
-#endif /* ndef WIN32 */
-
-#ifndef WIN32
-
-static void truncate_log_file(osm_log_t * const p_log)
-{
- int fd = fileno(p_log->out_port);
- if (ftruncate(fd, 0) < 0)
- fprintf(stderr, "truncate_log_file: cannot truncate: %s\n",
- strerror(errno));
- if (lseek(fd, 0, SEEK_SET) < 0)
- fprintf(stderr, "truncate_log_file: cannot rewind: %s\n",
- strerror(errno));
- p_log->count = 0;
-}
-
-#else /* Windows */
-
-static void truncate_log_file(osm_log_t * const p_log)
-{
- fprintf(stderr,
- "truncate_log_file: cannot truncate on windows system (yet)\n");
-}
-#endif /* ndef WIN32 */
-
-void osm_log(IN osm_log_t * const p_log,
- IN const osm_log_level_t verbosity, IN const char *p_str, ...)
-{
- char buffer[LOG_ENTRY_SIZE_MAX];
- va_list args;
- int ret;
-#ifdef WIN32
- SYSTEMTIME st;
- uint32_t pid = GetCurrentThreadId();
-#else
- pid_t pid = 0;
- time_t tim;
- struct tm result;
- uint64_t time_usecs;
- uint32_t usecs;
-#endif /* WIN32 */
-
- /* If this is a call to syslog - always print it */
- if (!(verbosity & (OSM_LOG_SYS | p_log->level)))
- return;
-
- va_start(args, p_str);
- vsprintf(buffer, p_str, args);
- va_end(args);
-
- /* this is a call to the syslog */
- if (verbosity & OSM_LOG_SYS) {
- syslog(LOG_INFO, "%s\n", buffer);
-
- /* SYSLOG should go to stdout too */
- if (p_log->out_port != stdout) {
- printf("%s\n", buffer);
- fflush(stdout);
- }
-#ifdef WIN32
- OsmReportState(buffer);
-#endif /* WIN32 */
- }
-
- /* regular log to default out_port */
- cl_spinlock_acquire(&p_log->lock);
-
- if (p_log->max_size && p_log->count > p_log->max_size) {
- /* truncate here */
- fprintf(stderr,
- "osm_log: log file exceeds the limit %lu. Truncating.\n",
- p_log->max_size);
- truncate_log_file(p_log);
- }
-#ifdef WIN32
- GetLocalTime(&st);
-_retry:
- ret =
- fprintf(p_log->out_port,
- "[%02d:%02d:%02d:%03d][%04X] 0x%02x -> %s",
- st.wHour, st.wMinute, st.wSecond, st.wMilliseconds,
- pid, verbosity, buffer);
-#else
- time_usecs = cl_get_time_stamp();
- tim = time_usecs / 1000000;
- usecs = time_usecs % 1000000;
- localtime_r(&tim, &result);
- pid = pthread_self();
-_retry:
- ret =
- fprintf(p_log->out_port,
- "%s %02d %02d:%02d:%02d %06d [%04X] 0x%02x -> %s",
- (result.tm_mon <
- 12 ? month_str[result.tm_mon] : "???"),
- result.tm_mday, result.tm_hour, result.tm_min,
- result.tm_sec, usecs, pid, verbosity, buffer);
-#endif
-
- /* flush log */
- if (ret > 0 &&
- (p_log->flush || (verbosity & (OSM_LOG_ERROR | OSM_LOG_SYS)))
- && fflush(p_log->out_port) < 0)
- ret = -1;
-
- if (ret >= 0) {
- log_exit_count = 0;
- p_log->count += ret;
- } else if (log_exit_count < 3) {
- log_exit_count++;
- if (errno == ENOSPC && p_log->max_size) {
- fprintf(stderr,
- "osm_log: write failed: %s. Truncating log file.\n",
- strerror(errno));
- truncate_log_file(p_log);
- goto _retry;
- }
- fprintf(stderr, "osm_log: write failed: %s\n", strerror(errno));
- }
-
- cl_spinlock_release(&p_log->lock);
-}
-
-void osm_log_raw(IN osm_log_t * const p_log,
- IN const osm_log_level_t verbosity, IN const char *p_buf)
-{
- if (p_log->level & verbosity) {
- cl_spinlock_acquire(&p_log->lock);
- printf("%s", p_buf);
- cl_spinlock_release(&p_log->lock);
-
- /*
- Flush log on errors too.
- */
- if (p_log->flush || (verbosity & OSM_LOG_ERROR))
- fflush(stdout);
- }
-}
-
-void osm_log_msg_box(IN osm_log_t * log, osm_log_level_t level,
- const char *func_name, const char *msg)
-{
-#define MSG_BOX_LENGTH 66
- char buf[MSG_BOX_LENGTH + 1];
- int i, n;
-
- if (!osm_log_is_active(log, level))
- return;
-
- n = (MSG_BOX_LENGTH - strlen(msg)) / 2 - 1;
- if (n < 0)
- n = 0;
- for (i = 0; i < n; i++)
- sprintf(buf + i, "*");
- n += snprintf(buf + n, sizeof(buf) - n, " %s ", msg);
- for (i = n; i < MSG_BOX_LENGTH; i++)
- buf[i] = '*';
- buf[i] = '\0';
-
- osm_log(log, level, "%s:\n\n\n"
- "*********************************************"
- "*********************\n%s\n"
- "*********************************************"
- "*********************\n\n\n", func_name, buf);
-}
-
-boolean_t osm_is_debug(void)
-{
-#if defined( _DEBUG_ )
- return TRUE;
-#else
- return FALSE;
-#endif /* defined( _DEBUG_ ) */
-}
-
-static int open_out_port(IN osm_log_t * p_log)
-{
- struct stat st;
-
- if (p_log->accum_log_file)
- p_log->out_port = fopen(p_log->log_file_name, "a+");
- else
- p_log->out_port = fopen(p_log->log_file_name, "w+");
-
- if (!p_log->out_port) {
- syslog(LOG_CRIT, "Cannot open file \'%s\' for %s: %s\n",
- p_log->log_file_name,
- p_log->accum_log_file ? "appending" : "writing",
- strerror(errno));
- fprintf(stderr, "Cannot open file \'%s\': %s\n",
- p_log->log_file_name, strerror(errno));
- return -1;
- }
-
- if (fstat(fileno(p_log->out_port), &st) == 0)
- p_log->count = st.st_size;
-
- syslog(LOG_NOTICE, "%s log file opened\n", p_log->log_file_name);
-
- if (p_log->daemon) {
- dup2(fileno(p_log->out_port), 0);
- dup2(fileno(p_log->out_port), 1);
- dup2(fileno(p_log->out_port), 2);
- }
-
- return 0;
-}
-
-int osm_log_reopen_file(osm_log_t * p_log)
-{
- int ret;
-
- if (p_log->out_port == stdout || p_log->out_port == stderr)
- return 0;
- cl_spinlock_acquire(&p_log->lock);
- fclose(p_log->out_port);
- ret = open_out_port(p_log);
- cl_spinlock_release(&p_log->lock);
- return ret;
-}
-
-ib_api_status_t osm_log_init_v2(IN osm_log_t * const p_log,
- IN const boolean_t flush,
- IN const uint8_t log_flags,
- IN const char *log_file,
- IN const unsigned long max_size,
- IN const boolean_t accum_log_file)
-{
- p_log->level = log_flags;
- p_log->flush = flush;
- p_log->count = 0;
- p_log->max_size = max_size;
- p_log->accum_log_file = accum_log_file;
- p_log->log_file_name = (char *)log_file;
-
- openlog("OpenSM", LOG_CONS | LOG_PID, LOG_USER);
-
- if (log_file == NULL || !strcmp(log_file, "-") ||
- !strcmp(log_file, "stdout"))
- p_log->out_port = stdout;
- else if (!strcmp(log_file, "stderr"))
- p_log->out_port = stderr;
- else if (open_out_port(p_log))
- return IB_ERROR;
-
- if (cl_spinlock_init(&p_log->lock) == CL_SUCCESS)
- return IB_SUCCESS;
- else
- return IB_ERROR;
-}
-
-ib_api_status_t osm_log_init(IN osm_log_t * const p_log,
- IN const boolean_t flush,
- IN const uint8_t log_flags,
- IN const char *log_file,
- IN const boolean_t accum_log_file)
-{
- return osm_log_init_v2(p_log, flush, log_flags, log_file, 0,
- accum_log_file);
-}
diff --git a/contrib/ofed/management/opensm/opensm/osm_mad_pool.c b/contrib/ofed/management/opensm/opensm/osm_mad_pool.c
deleted file mode 100644
index 56a2a6d..0000000
--- a/contrib/ofed/management/opensm/opensm/osm_mad_pool.c
+++ /dev/null
@@ -1,188 +0,0 @@
-/*
- * Copyright (c) 2004-2008 Voltaire, Inc. All rights reserved.
- * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved.
- * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- */
-
-/*
- * Abstract:
- * Implementation of osm_mad_pool_t.
- * This object represents a pool of management datagram (MAD) objects.
- * This object is part of the opensm family of objects.
- */
-
-#if HAVE_CONFIG_H
-# include <config.h>
-#endif /* HAVE_CONFIG_H */
-
-#include <stdlib.h>
-#include <string.h>
-#include <opensm/osm_mad_pool.h>
-#include <opensm/osm_madw.h>
-#include <vendor/osm_vendor_api.h>
-
-/**********************************************************************
- **********************************************************************/
-void osm_mad_pool_construct(IN osm_mad_pool_t * const p_pool)
-{
- CL_ASSERT(p_pool);
-
- memset(p_pool, 0, sizeof(*p_pool));
-}
-
-/**********************************************************************
- **********************************************************************/
-void osm_mad_pool_destroy(IN osm_mad_pool_t * const p_pool)
-{
- CL_ASSERT(p_pool);
-}
-
-/**********************************************************************
- **********************************************************************/
-ib_api_status_t osm_mad_pool_init(IN osm_mad_pool_t * const p_pool)
-{
- p_pool->mads_out = 0;
-
- return IB_SUCCESS;
-}
-
-/**********************************************************************
- **********************************************************************/
-osm_madw_t *osm_mad_pool_get(IN osm_mad_pool_t * const p_pool,
- IN osm_bind_handle_t h_bind,
- IN const uint32_t total_size,
- IN const osm_mad_addr_t * const p_mad_addr)
-{
- osm_madw_t *p_madw;
- ib_mad_t *p_mad;
-
- CL_ASSERT(h_bind != OSM_BIND_INVALID_HANDLE);
- CL_ASSERT(total_size);
-
- /*
- First, acquire a mad wrapper from the mad wrapper pool.
- */
- p_madw = malloc(sizeof(*p_madw));
- if (p_madw == NULL)
- goto Exit;
-
- osm_madw_init(p_madw, h_bind, total_size, p_mad_addr);
-
- /*
- Next, acquire a wire mad of the specified size.
- */
- p_mad = osm_vendor_get(h_bind, total_size, &p_madw->vend_wrap);
- if (p_mad == NULL) {
- /* Don't leak wrappers! */
- free(p_madw);
- p_madw = NULL;
- goto Exit;
- }
-
- cl_atomic_inc(&p_pool->mads_out);
- /*
- Finally, attach the wire MAD to this wrapper.
- */
- osm_madw_set_mad(p_madw, p_mad);
-
-Exit:
- return p_madw;
-}
-
-/**********************************************************************
- **********************************************************************/
-osm_madw_t *osm_mad_pool_get_wrapper(IN osm_mad_pool_t * const p_pool,
- IN osm_bind_handle_t h_bind,
- IN const uint32_t total_size,
- IN const ib_mad_t * const p_mad,
- IN const osm_mad_addr_t * const p_mad_addr)
-{
- osm_madw_t *p_madw;
-
- CL_ASSERT(h_bind != OSM_BIND_INVALID_HANDLE);
- CL_ASSERT(total_size);
- CL_ASSERT(p_mad);
-
- /*
- First, acquire a mad wrapper from the mad wrapper pool.
- */
- p_madw = malloc(sizeof(*p_madw));
- if (p_madw == NULL)
- goto Exit;
-
- /*
- Finally, initialize the wrapper object.
- */
- cl_atomic_inc(&p_pool->mads_out);
- osm_madw_init(p_madw, h_bind, total_size, p_mad_addr);
- osm_madw_set_mad(p_madw, p_mad);
-
-Exit:
- return (p_madw);
-}
-
-/**********************************************************************
- **********************************************************************/
-osm_madw_t *osm_mad_pool_get_wrapper_raw(IN osm_mad_pool_t * const p_pool)
-{
- osm_madw_t *p_madw;
-
- p_madw = malloc(sizeof(*p_madw));
- if (!p_madw)
- return NULL;
-
- osm_madw_init(p_madw, 0, 0, 0);
- osm_madw_set_mad(p_madw, 0);
- cl_atomic_inc(&p_pool->mads_out);
-
- return (p_madw);
-}
-
-/**********************************************************************
- **********************************************************************/
-void
-osm_mad_pool_put(IN osm_mad_pool_t * const p_pool, IN osm_madw_t * const p_madw)
-{
- CL_ASSERT(p_madw);
-
- /*
- First, return the wire mad to the pool
- */
- if (p_madw->p_mad)
- osm_vendor_put(p_madw->h_bind, &p_madw->vend_wrap);
-
- /*
- Return the mad wrapper to the wrapper pool
- */
- free(p_madw);
- cl_atomic_dec(&p_pool->mads_out);
-}
diff --git a/contrib/ofed/management/opensm/opensm/osm_mcast_fwd_rcv.c b/contrib/ofed/management/opensm/opensm/osm_mcast_fwd_rcv.c
deleted file mode 100644
index 635c7da..0000000
--- a/contrib/ofed/management/opensm/opensm/osm_mcast_fwd_rcv.c
+++ /dev/null
@@ -1,121 +0,0 @@
-/*
- * Copyright (c) 2004-2008 Voltaire, Inc. All rights reserved.
- * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved.
- * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- */
-
-/*
- * Abstract:
- * Implementation of osm_mft_rcv_t.
- * This object represents the Multicast Forwarding Table Receiver object.
- * This object is part of the opensm family of objects.
- */
-
-#if HAVE_CONFIG_H
-# include <config.h>
-#endif /* HAVE_CONFIG_H */
-
-#include <string.h>
-#include <iba/ib_types.h>
-#include <complib/cl_qmap.h>
-#include <complib/cl_passivelock.h>
-#include <complib/cl_debug.h>
-#include <opensm/osm_madw.h>
-#include <opensm/osm_log.h>
-#include <opensm/osm_switch.h>
-#include <opensm/osm_subnet.h>
-#include <opensm/osm_sm.h>
-
-/**********************************************************************
- **********************************************************************/
-void osm_mft_rcv_process(IN void *context, IN void *data)
-{
- osm_sm_t *sm = context;
- osm_madw_t *p_madw = data;
- ib_smp_t *p_smp;
- uint32_t block_num;
- uint8_t position;
- osm_switch_t *p_sw;
- osm_mft_context_t *p_mft_context;
- uint16_t *p_block;
- ib_net64_t node_guid;
- ib_api_status_t status;
-
- CL_ASSERT(sm);
-
- OSM_LOG_ENTER(sm->p_log);
-
- CL_ASSERT(p_madw);
-
- p_smp = osm_madw_get_smp_ptr(p_madw);
- p_block = (uint16_t *) ib_smp_get_payload_ptr(p_smp);
- block_num = cl_ntoh32(p_smp->attr_mod) & IB_MCAST_BLOCK_ID_MASK_HO;
- position = (uint8_t) ((cl_ntoh32(p_smp->attr_mod) &
- IB_MCAST_POSITION_MASK_HO) >>
- IB_MCAST_POSITION_SHIFT);
-
- /*
- Acquire the switch object for this switch.
- */
- p_mft_context = osm_madw_get_mft_context_ptr(p_madw);
- node_guid = p_mft_context->node_guid;
-
- OSM_LOG(sm->p_log, OSM_LOG_DEBUG,
- "Setting MFT block %u, position %u, "
- "Switch 0x%016" PRIx64 ", TID 0x%" PRIx64 "\n",
- block_num, position, cl_ntoh64(node_guid),
- cl_ntoh64(p_smp->trans_id));
-
- CL_PLOCK_EXCL_ACQUIRE(sm->p_lock);
- p_sw = osm_get_switch_by_guid(sm->p_subn, node_guid);
-
- if (!p_sw) {
- OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR 0801: "
- "MFT received for nonexistent node "
- "0x%016" PRIx64 "\n", cl_ntoh64(node_guid));
- } else {
- status = osm_switch_set_mft_block(p_sw, p_block,
- (uint16_t) block_num,
- position);
- if (status != IB_SUCCESS) {
- OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR 0802: "
- "Setting MFT block failed (%s)"
- "\n\t\t\t\tSwitch 0x%016" PRIx64
- ", block %u, position %u\n",
- ib_get_err_str(status),
- cl_ntoh64(node_guid), block_num, position);
- }
- }
-
- CL_PLOCK_RELEASE(sm->p_lock);
- OSM_LOG_EXIT(sm->p_log);
-}
diff --git a/contrib/ofed/management/opensm/opensm/osm_mcast_mgr.c b/contrib/ofed/management/opensm/opensm/osm_mcast_mgr.c
deleted file mode 100644
index 2f9cb5e..0000000
--- a/contrib/ofed/management/opensm/opensm/osm_mcast_mgr.c
+++ /dev/null
@@ -1,1267 +0,0 @@
-/*
- * Copyright (c) 2004-2008 Voltaire, Inc. All rights reserved.
- * Copyright (c) 2002-2006 Mellanox Technologies LTD. All rights reserved.
- * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
- * Copyright (c) 2008 Xsigo Systems Inc. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- */
-
-/*
- * Abstract:
- * Implementation of osm_mcast_mgr_t.
- * This file implements the Multicast Manager object.
- */
-
-#if HAVE_CONFIG_H
-# include <config.h>
-#endif /* HAVE_CONFIG_H */
-
-#include <stdlib.h>
-#include <string.h>
-#include <iba/ib_types.h>
-#include <complib/cl_debug.h>
-#include <opensm/osm_opensm.h>
-#include <opensm/osm_sm.h>
-#include <opensm/osm_multicast.h>
-#include <opensm/osm_node.h>
-#include <opensm/osm_switch.h>
-#include <opensm/osm_helper.h>
-#include <opensm/osm_msgdef.h>
-
-/**********************************************************************
- **********************************************************************/
-typedef struct osm_mcast_work_obj {
- cl_list_item_t list_item;
- osm_port_t *p_port;
-} osm_mcast_work_obj_t;
-
-/**********************************************************************
- **********************************************************************/
-static osm_mcast_work_obj_t *__osm_mcast_work_obj_new(IN const osm_port_t *
- const p_port)
-{
- /*
- TO DO - get these objects from a lockpool.
- */
- osm_mcast_work_obj_t *p_obj;
-
- /*
- clean allocated memory to avoid assertion when trying to insert to
- qlist.
- see cl_qlist_insert_tail(): CL_ASSERT(p_list_item->p_list != p_list)
- */
- p_obj = malloc(sizeof(*p_obj));
- if (p_obj) {
- memset(p_obj, 0, sizeof(*p_obj));
- p_obj->p_port = (osm_port_t *) p_port;
- }
-
- return (p_obj);
-}
-
-/**********************************************************************
- **********************************************************************/
-static void __osm_mcast_work_obj_delete(IN osm_mcast_work_obj_t * p_wobj)
-{
- free(p_wobj);
-}
-
-/**********************************************************************
- Recursively remove nodes from the tree
- *********************************************************************/
-static void __osm_mcast_mgr_purge_tree_node(IN osm_mtree_node_t * p_mtn)
-{
- uint8_t i;
-
- for (i = 0; i < p_mtn->max_children; i++) {
- if (p_mtn->child_array[i] &&
- (p_mtn->child_array[i] != OSM_MTREE_LEAF))
- __osm_mcast_mgr_purge_tree_node(p_mtn->child_array[i]);
-
- p_mtn->child_array[i] = NULL;
-
- }
-
- free(p_mtn);
-}
-
-/**********************************************************************
- **********************************************************************/
-static void
-__osm_mcast_mgr_purge_tree(osm_sm_t * sm, IN osm_mgrp_t * const p_mgrp)
-{
- OSM_LOG_ENTER(sm->p_log);
-
- if (p_mgrp->p_root)
- __osm_mcast_mgr_purge_tree_node(p_mgrp->p_root);
-
- p_mgrp->p_root = NULL;
-
- OSM_LOG_EXIT(sm->p_log);
-}
-
-/**********************************************************************
- **********************************************************************/
-static float
-osm_mcast_mgr_compute_avg_hops(osm_sm_t * sm,
- const osm_mgrp_t * const p_mgrp,
- const osm_switch_t * const p_sw)
-{
- float avg_hops = 0;
- uint32_t hops = 0;
- uint32_t num_ports = 0;
- const osm_port_t *p_port;
- const osm_mcm_port_t *p_mcm_port;
- const cl_qmap_t *p_mcm_tbl;
-
- OSM_LOG_ENTER(sm->p_log);
-
- p_mcm_tbl = &p_mgrp->mcm_port_tbl;
-
- /*
- For each member of the multicast group, compute the
- number of hops to its base LID.
- */
- for (p_mcm_port = (osm_mcm_port_t *) cl_qmap_head(p_mcm_tbl);
- p_mcm_port != (osm_mcm_port_t *) cl_qmap_end(p_mcm_tbl);
- p_mcm_port =
- (osm_mcm_port_t *) cl_qmap_next(&p_mcm_port->map_item)) {
- /*
- Acquire the port object for this port guid, then create
- the new worker object to build the list.
- */
- p_port = osm_get_port_by_guid(sm->p_subn,
- ib_gid_get_guid(&p_mcm_port->
- port_gid));
-
- if (!p_port) {
- OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR 0A18: "
- "No port object for port 0x%016" PRIx64 "\n",
- cl_ntoh64(ib_gid_get_guid
- (&p_mcm_port->port_gid)));
- continue;
- }
-
- hops += osm_switch_get_port_least_hops(p_sw, p_port);
- num_ports++;
- }
-
- /*
- We should be here if there aren't any ports in the group.
- */
- CL_ASSERT(num_ports);
-
- if (num_ports != 0)
- avg_hops = (float)(hops / num_ports);
-
- OSM_LOG_EXIT(sm->p_log);
- return (avg_hops);
-}
-
-/**********************************************************************
- Calculate the maximal "min hops" from the given switch to any
- of the group HCAs
- **********************************************************************/
-static float
-osm_mcast_mgr_compute_max_hops(osm_sm_t * sm,
- const osm_mgrp_t * const p_mgrp,
- const osm_switch_t * const p_sw)
-{
- uint32_t max_hops = 0;
- uint32_t hops = 0;
- const osm_port_t *p_port;
- const osm_mcm_port_t *p_mcm_port;
- const cl_qmap_t *p_mcm_tbl;
-
- OSM_LOG_ENTER(sm->p_log);
-
- p_mcm_tbl = &p_mgrp->mcm_port_tbl;
-
- /*
- For each member of the multicast group, compute the
- number of hops to its base LID.
- */
- for (p_mcm_port = (osm_mcm_port_t *) cl_qmap_head(p_mcm_tbl);
- p_mcm_port != (osm_mcm_port_t *) cl_qmap_end(p_mcm_tbl);
- p_mcm_port =
- (osm_mcm_port_t *) cl_qmap_next(&p_mcm_port->map_item)) {
- /*
- Acquire the port object for this port guid, then create
- the new worker object to build the list.
- */
- p_port = osm_get_port_by_guid(sm->p_subn,
- ib_gid_get_guid(&p_mcm_port->
- port_gid));
-
- if (!p_port) {
- OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR 0A1A: "
- "No port object for port 0x%016" PRIx64 "\n",
- cl_ntoh64(ib_gid_get_guid
- (&p_mcm_port->port_gid)));
- continue;
- }
-
- hops = osm_switch_get_port_least_hops(p_sw, p_port);
- if (hops > max_hops)
- max_hops = hops;
- }
-
- if (max_hops == 0) {
- /*
- We should be here if there aren't any ports in the group.
- */
- max_hops = 10001; /* see later - we use it to realize no hops */
- }
-
- OSM_LOG_EXIT(sm->p_log);
- return (float)(max_hops);
-}
-
-/**********************************************************************
- This function attempts to locate the optimal switch for the
- center of the spanning tree. The current algorithm chooses
- a switch with the lowest average hop count to the members
- of the multicast group.
-**********************************************************************/
-static osm_switch_t *__osm_mcast_mgr_find_optimal_switch(osm_sm_t * sm,
- const osm_mgrp_t *
- const p_mgrp)
-{
- cl_qmap_t *p_sw_tbl;
- const osm_switch_t *p_sw;
- const osm_switch_t *p_best_sw = NULL;
- float hops = 0;
- float best_hops = 10000; /* any big # will do */
-#ifdef OSM_VENDOR_INTF_ANAFA
- boolean_t use_avg_hops = TRUE; /* anafa2 - bug hca on switch *//* use max hops for root */
-#else
- boolean_t use_avg_hops = FALSE; /* use max hops for root */
-#endif
-
- OSM_LOG_ENTER(sm->p_log);
-
- p_sw_tbl = &sm->p_subn->sw_guid_tbl;
-
- CL_ASSERT(!osm_mgrp_is_empty(p_mgrp));
-
- for (p_sw = (osm_switch_t *) cl_qmap_head(p_sw_tbl);
- p_sw != (osm_switch_t *) cl_qmap_end(p_sw_tbl);
- p_sw = (osm_switch_t *) cl_qmap_next(&p_sw->map_item)) {
- if (!osm_switch_supports_mcast(p_sw))
- continue;
-
- if (use_avg_hops)
- hops = osm_mcast_mgr_compute_avg_hops(sm, p_mgrp, p_sw);
- else
- hops = osm_mcast_mgr_compute_max_hops(sm, p_mgrp, p_sw);
-
- OSM_LOG(sm->p_log, OSM_LOG_DEBUG,
- "Switch 0x%016" PRIx64 ", hops = %f\n",
- cl_ntoh64(osm_node_get_node_guid(p_sw->p_node)), hops);
-
- if (hops < best_hops) {
- p_best_sw = p_sw;
- best_hops = hops;
- }
- }
-
- if (p_best_sw)
- OSM_LOG(sm->p_log, OSM_LOG_VERBOSE,
- "Best switch is 0x%" PRIx64 ", hops = %f\n",
- cl_ntoh64(osm_node_get_node_guid(p_best_sw->p_node)),
- best_hops);
- else
- OSM_LOG(sm->p_log, OSM_LOG_VERBOSE,
- "No multicast capable switches detected\n");
-
- OSM_LOG_EXIT(sm->p_log);
- return ((osm_switch_t *) p_best_sw);
-}
-
-/**********************************************************************
- This function returns the existing or optimal root swtich for the tree.
-**********************************************************************/
-static osm_switch_t *__osm_mcast_mgr_find_root_switch(osm_sm_t * sm,
- const osm_mgrp_t *
- const p_mgrp)
-{
- const osm_switch_t *p_sw = NULL;
-
- OSM_LOG_ENTER(sm->p_log);
-
- /*
- We always look for the best multicast tree root switch.
- Otherwise since we always start with a a single join
- the root will be always on the first switch attached to it.
- - Very bad ...
- */
- p_sw = __osm_mcast_mgr_find_optimal_switch(sm, p_mgrp);
-
- OSM_LOG_EXIT(sm->p_log);
- return ((osm_switch_t *) p_sw);
-}
-
-/**********************************************************************
- **********************************************************************/
-static osm_signal_t
-__osm_mcast_mgr_set_tbl(osm_sm_t * sm, IN osm_switch_t * const p_sw)
-{
- osm_node_t *p_node;
- osm_dr_path_t *p_path;
- osm_madw_context_t mad_context;
- ib_api_status_t status;
- uint32_t block_id_ho = 0;
- int16_t block_num = 0;
- uint32_t position = 0;
- uint32_t max_position;
- osm_mcast_tbl_t *p_tbl;
- ib_net16_t block[IB_MCAST_BLOCK_SIZE];
- osm_signal_t signal = OSM_SIGNAL_DONE;
-
- CL_ASSERT(sm);
-
- OSM_LOG_ENTER(sm->p_log);
-
- CL_ASSERT(p_sw);
-
- p_node = p_sw->p_node;
-
- CL_ASSERT(p_node);
-
- p_path = osm_physp_get_dr_path_ptr(osm_node_get_physp_ptr(p_node, 0));
-
- /*
- Send multicast forwarding table blocks to the switch
- as long as the switch indicates it has blocks needing
- configuration.
- */
-
- mad_context.mft_context.node_guid = osm_node_get_node_guid(p_node);
- mad_context.mft_context.set_method = TRUE;
-
- p_tbl = osm_switch_get_mcast_tbl_ptr(p_sw);
- max_position = p_tbl->max_position;
-
- while (osm_mcast_tbl_get_block(p_tbl, block_num,
- (uint8_t) position, block)) {
- OSM_LOG(sm->p_log, OSM_LOG_DEBUG,
- "Writing MFT block 0x%X\n", block_id_ho);
-
- block_id_ho = block_num + (position << 28);
-
- status = osm_req_set(sm, p_path, (void *)block, sizeof(block),
- IB_MAD_ATTR_MCAST_FWD_TBL,
- cl_hton32(block_id_ho),
- CL_DISP_MSGID_NONE, &mad_context);
-
- if (status != IB_SUCCESS) {
- OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR 0A02: "
- "Sending multicast fwd. tbl. block failed (%s)\n",
- ib_get_err_str(status));
- }
-
- signal = OSM_SIGNAL_DONE_PENDING;
-
- if (++position > max_position) {
- position = 0;
- block_num++;
- }
- }
-
- OSM_LOG_EXIT(sm->p_log);
- return (signal);
-}
-
-/**********************************************************************
- This is part of the recursive function to compute the paths in the
- spanning tree that eminate from this switch. On input, the p_list
- contains the group members that must be routed from this switch.
-**********************************************************************/
-static void
-__osm_mcast_mgr_subdivide(osm_sm_t * sm,
- osm_mgrp_t * const p_mgrp,
- osm_switch_t * const p_sw,
- cl_qlist_t * const p_list,
- cl_qlist_t * const list_array,
- uint8_t const array_size)
-{
- uint8_t port_num;
- uint16_t mlid_ho;
- boolean_t ignore_existing;
- osm_mcast_work_obj_t *p_wobj;
-
- OSM_LOG_ENTER(sm->p_log);
-
- mlid_ho = cl_ntoh16(osm_mgrp_get_mlid(p_mgrp));
-
- /*
- For Multicast Groups, we want not to count on previous
- configurations - since we can easily generate a storm
- by loops.
- */
- ignore_existing = TRUE;
-
- /*
- Subdivide the set of ports into non-overlapping subsets
- that will be routed to other switches.
- */
- while ((p_wobj =
- (osm_mcast_work_obj_t *) cl_qlist_remove_head(p_list)) !=
- (osm_mcast_work_obj_t *) cl_qlist_end(p_list)) {
- port_num =
- osm_switch_recommend_mcast_path(p_sw, p_wobj->p_port,
- mlid_ho, ignore_existing);
-
- if (port_num == OSM_NO_PATH) {
- /*
- This typically occurs if the switch does not support
- multicast and the multicast tree must branch at this
- switch.
- */
- uint64_t node_guid_ho =
- cl_ntoh64(osm_node_get_node_guid(p_sw->p_node));
- OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR 0A03: "
- "Error routing MLID 0x%X through switch 0x%"
- PRIx64 "\n"
- "\t\t\t\tNo multicast paths from this switch for port "
- "with LID %u\n", mlid_ho, node_guid_ho,
- cl_ntoh16(osm_port_get_base_lid
- (p_wobj->p_port)));
-
- __osm_mcast_work_obj_delete(p_wobj);
- continue;
- }
-
- if (port_num > array_size) {
- uint64_t node_guid_ho =
- cl_ntoh64(osm_node_get_node_guid(p_sw->p_node));
- OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR 0A04: "
- "Error routing MLID 0x%X through switch 0x%"
- PRIx64 "\n"
- "\t\t\t\tNo multicast paths from this switch to port "
- "with LID %u\n", mlid_ho, node_guid_ho,
- cl_ntoh16(osm_port_get_base_lid
- (p_wobj->p_port)));
-
- __osm_mcast_work_obj_delete(p_wobj);
-
- /* This is means OpenSM has a bug. */
- CL_ASSERT(FALSE);
- continue;
- }
-
- cl_qlist_insert_tail(&list_array[port_num], &p_wobj->list_item);
- }
-
- OSM_LOG_EXIT(sm->p_log);
-}
-
-/**********************************************************************
- **********************************************************************/
-static void __osm_mcast_mgr_purge_list(osm_sm_t * sm, cl_qlist_t * const p_list)
-{
- osm_mcast_work_obj_t *p_wobj;
-
- OSM_LOG_ENTER(sm->p_log);
-
- while ((p_wobj = (osm_mcast_work_obj_t *) cl_qlist_remove_head(p_list))
- != (osm_mcast_work_obj_t *) cl_qlist_end(p_list)) {
- OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR 0A06: "
- "Unable to route for port 0x%" PRIx64 "\n",
- osm_port_get_guid(p_wobj->p_port));
- __osm_mcast_work_obj_delete(p_wobj);
- }
-
- OSM_LOG_EXIT(sm->p_log);
-}
-
-/**********************************************************************
- This is the recursive function to compute the paths in the spanning
- tree that emanate from this switch. On input, the p_list contains
- the group members that must be routed from this switch.
-
- The function returns the newly created mtree node element.
-**********************************************************************/
-static osm_mtree_node_t *__osm_mcast_mgr_branch(osm_sm_t * sm,
- osm_mgrp_t * const p_mgrp,
- osm_switch_t * const p_sw,
- cl_qlist_t * const p_list,
- uint8_t depth,
- uint8_t const upstream_port,
- uint8_t * const p_max_depth)
-{
- uint8_t max_children;
- osm_mtree_node_t *p_mtn = NULL;
- cl_qlist_t *list_array = NULL;
- uint8_t i;
- ib_net64_t node_guid;
- uint64_t node_guid_ho;
- osm_mcast_work_obj_t *p_wobj;
- cl_qlist_t *p_port_list;
- size_t count;
- uint16_t mlid_ho;
- osm_mcast_tbl_t *p_tbl;
-
- OSM_LOG_ENTER(sm->p_log);
-
- CL_ASSERT(p_sw);
- CL_ASSERT(p_list);
- CL_ASSERT(p_max_depth);
-
- node_guid = osm_node_get_node_guid(p_sw->p_node);
- node_guid_ho = cl_ntoh64(node_guid);
- mlid_ho = cl_ntoh16(osm_mgrp_get_mlid(p_mgrp));
-
- OSM_LOG(sm->p_log, OSM_LOG_VERBOSE,
- "Routing MLID 0x%X through switch 0x%" PRIx64
- ", %u nodes at depth %u\n",
- mlid_ho, node_guid_ho, cl_qlist_count(p_list), depth);
-
- CL_ASSERT(cl_qlist_count(p_list) > 0);
-
- depth++;
-
- if (depth >= 64) {
- OSM_LOG(sm->p_log, OSM_LOG_ERROR,
- "Maximal hops number is reached for MLID 0x%x."
- " Break processing.", mlid_ho);
- __osm_mcast_mgr_purge_list(sm, p_list);
- goto Exit;
- }
-
- if (depth > *p_max_depth) {
- CL_ASSERT(depth == *p_max_depth + 1);
- *p_max_depth = depth;
- }
-
- if (osm_switch_supports_mcast(p_sw) == FALSE) {
- /*
- This switch doesn't do multicast. Clean-up.
- */
- OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR 0A14: "
- "Switch 0x%" PRIx64 " does not support multicast\n",
- node_guid_ho);
-
- /*
- Deallocate all the work objects on this branch of the tree.
- */
- __osm_mcast_mgr_purge_list(sm, p_list);
- goto Exit;
- }
-
- p_mtn = osm_mtree_node_new(p_sw);
- if (p_mtn == NULL) {
- /*
- We are unable to continue routing down this
- leg of the tree. Clean-up.
- */
- OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR 0A15: "
- "Insufficient memory to build multicast tree\n");
-
- /*
- Deallocate all the work objects on this branch of the tree.
- */
- __osm_mcast_mgr_purge_list(sm, p_list);
- goto Exit;
- }
-
- max_children = osm_mtree_node_get_max_children(p_mtn);
-
- CL_ASSERT(max_children > 1);
-
- /*
- Prepare an empty list for each port in the switch.
- TO DO - this list array could probably be moved
- inside the switch element to save on malloc thrashing.
- */
- list_array = malloc(sizeof(cl_qlist_t) * max_children);
- if (list_array == NULL) {
- OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR 0A16: "
- "Unable to allocate list array\n");
- __osm_mcast_mgr_purge_list(sm, p_list);
- goto Exit;
- }
-
- memset(list_array, 0, sizeof(cl_qlist_t) * max_children);
-
- for (i = 0; i < max_children; i++)
- cl_qlist_init(&list_array[i]);
-
- __osm_mcast_mgr_subdivide(sm, p_mgrp, p_sw, p_list, list_array,
- max_children);
-
- p_tbl = osm_switch_get_mcast_tbl_ptr(p_sw);
-
- /*
- Add the upstream port to the forwarding table unless
- we're at the root of the spanning tree.
- */
- if (depth > 1) {
- OSM_LOG(sm->p_log, OSM_LOG_DEBUG,
- "Adding upstream port %u\n", upstream_port);
-
- CL_ASSERT(upstream_port);
- osm_mcast_tbl_set(p_tbl, mlid_ho, upstream_port);
- }
-
- /*
- For each port that was allocated some routes,
- recurse into this function to continue building the tree
- if the node on the other end of that port is another switch.
- Otherwise, the node is an endpoint, and we've found a leaf
- of the tree. Mark leaves with our special pointer value.
- */
-
- for (i = 0; i < max_children; i++) {
- const osm_physp_t *p_physp;
- const osm_physp_t *p_remote_physp;
- osm_node_t *p_node;
- const osm_node_t *p_remote_node;
-
- p_port_list = &list_array[i];
-
- count = cl_qlist_count(p_port_list);
-
- /*
- There should be no children routed through the upstream port!
- */
- CL_ASSERT((upstream_port == 0) || (i != upstream_port) ||
- ((i == upstream_port) && (count == 0)));
-
- if (count == 0)
- continue; /* No routes down this port. */
-
- OSM_LOG(sm->p_log, OSM_LOG_DEBUG,
- "Routing %zu destinations via switch port %u\n",
- count, i);
-
- /*
- This port routes frames for this mcast group. Therefore,
- set the appropriate bit in the multicast forwarding
- table for this switch.
- */
- osm_mcast_tbl_set(p_tbl, mlid_ho, i);
- if (i == 0) {
- /* This means we are adding the switch to the MC group.
- We do not need to continue looking at the remote port, just
- needed to add the port to the table */
- CL_ASSERT(count == 1);
-
- p_wobj = (osm_mcast_work_obj_t *)
- cl_qlist_remove_head(p_port_list);
- __osm_mcast_work_obj_delete(p_wobj);
- continue;
- }
-
- p_node = p_sw->p_node;
- p_remote_node = osm_node_get_remote_node(p_node, i, NULL);
- if (!p_remote_node)
- continue;
-
- if (osm_node_get_type(p_remote_node) == IB_NODE_TYPE_SWITCH) {
- /*
- Acquire a pointer to the remote switch then recurse.
- */
- CL_ASSERT(p_remote_node->sw);
-
- p_physp = osm_node_get_physp_ptr(p_node, i);
- CL_ASSERT(p_physp);
-
- p_remote_physp = osm_physp_get_remote(p_physp);
- CL_ASSERT(p_remote_physp);
-
- p_mtn->child_array[i] =
- __osm_mcast_mgr_branch(sm, p_mgrp,
- p_remote_node->sw,
- p_port_list, depth,
- osm_physp_get_port_num
- (p_remote_physp),
- p_max_depth);
- } else {
- /*
- The neighbor node is not a switch, so this
- must be a leaf.
- */
- CL_ASSERT(count == 1);
-
- p_mtn->child_array[i] = OSM_MTREE_LEAF;
- p_wobj = (osm_mcast_work_obj_t *)
- cl_qlist_remove_head(p_port_list);
-
- CL_ASSERT(cl_is_qlist_empty(p_port_list));
-
- OSM_LOG(sm->p_log, OSM_LOG_DEBUG,
- "Found leaf for port 0x%016" PRIx64
- " on switch port %u\n",
- cl_ntoh64(osm_port_get_guid(p_wobj->p_port)),
- i);
-
- __osm_mcast_work_obj_delete(p_wobj);
- }
- }
-
- free(list_array);
-Exit:
- OSM_LOG_EXIT(sm->p_log);
- return (p_mtn);
-}
-
-/**********************************************************************
- **********************************************************************/
-static ib_api_status_t
-__osm_mcast_mgr_build_spanning_tree(osm_sm_t * sm, osm_mgrp_t * const p_mgrp)
-{
- const cl_qmap_t *p_mcm_tbl;
- const osm_port_t *p_port;
- const osm_mcm_port_t *p_mcm_port;
- uint32_t num_ports;
- cl_qlist_t port_list;
- osm_switch_t *p_sw;
- osm_mcast_work_obj_t *p_wobj;
- ib_api_status_t status = IB_SUCCESS;
- uint8_t max_depth = 0;
- uint32_t count;
-
- OSM_LOG_ENTER(sm->p_log);
-
- cl_qlist_init(&port_list);
-
- /*
- TO DO - for now, just blow away the old tree.
- In the future we'll need to construct the tree based
- on multicast forwarding table information if the user wants to
- preserve existing multicast routes.
- */
- __osm_mcast_mgr_purge_tree(sm, p_mgrp);
-
- p_mcm_tbl = &p_mgrp->mcm_port_tbl;
- num_ports = cl_qmap_count(p_mcm_tbl);
- if (num_ports == 0) {
- OSM_LOG(sm->p_log, OSM_LOG_VERBOSE,
- "MLID 0x%X has no members - nothing to do\n",
- cl_ntoh16(osm_mgrp_get_mlid(p_mgrp)));
- goto Exit;
- }
-
- /*
- This function builds the single spanning tree recursively.
- At each stage, the ports to be reached are divided into
- non-overlapping subsets of member ports that can be reached through
- a given switch port. Construction then moves down each
- branch, and the process starts again with each branch computing
- for its own subset of the member ports.
-
- The maximum recursion depth is at worst the maximum hop count in the
- subnet, which is spec limited to 64.
- */
-
- /*
- Locate the switch around which to create the spanning
- tree for this multicast group.
- */
- p_sw = __osm_mcast_mgr_find_root_switch(sm, p_mgrp);
- if (p_sw == NULL) {
- OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR 0A08: "
- "Unable to locate a suitable switch for group 0x%X\n",
- cl_ntoh16(osm_mgrp_get_mlid(p_mgrp)));
- status = IB_ERROR;
- goto Exit;
- }
-
- /*
- Build the first "subset" containing all member ports.
- */
- for (p_mcm_port = (osm_mcm_port_t *) cl_qmap_head(p_mcm_tbl);
- p_mcm_port != (osm_mcm_port_t *) cl_qmap_end(p_mcm_tbl);
- p_mcm_port =
- (osm_mcm_port_t *) cl_qmap_next(&p_mcm_port->map_item)) {
- /*
- Acquire the port object for this port guid, then create
- the new worker object to build the list.
- */
- p_port = osm_get_port_by_guid(sm->p_subn,
- ib_gid_get_guid(&p_mcm_port->
- port_gid));
- if (!p_port) {
- OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR 0A09: "
- "No port object for port 0x%016" PRIx64 "\n",
- cl_ntoh64(ib_gid_get_guid
- (&p_mcm_port->port_gid)));
- continue;
- }
-
- p_wobj = __osm_mcast_work_obj_new(p_port);
- if (p_wobj == NULL) {
- OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR 0A10: "
- "Insufficient memory to route port 0x%016"
- PRIx64 "\n",
- cl_ntoh64(osm_port_get_guid(p_port)));
- continue;
- }
-
- cl_qlist_insert_tail(&port_list, &p_wobj->list_item);
- }
-
- count = cl_qlist_count(&port_list);
- p_mgrp->p_root = __osm_mcast_mgr_branch(sm, p_mgrp, p_sw,
- &port_list, 0, 0, &max_depth);
-
- OSM_LOG(sm->p_log, OSM_LOG_VERBOSE,
- "Configured MLID 0x%X for %u ports, max tree depth = %u\n",
- cl_ntoh16(osm_mgrp_get_mlid(p_mgrp)), count, max_depth);
-
-Exit:
- OSM_LOG_EXIT(sm->p_log);
- return (status);
-}
-
-#if 0
-/* unused */
-/**********************************************************************
- **********************************************************************/
-void
-osm_mcast_mgr_set_table(osm_sm_t * sm,
- IN const osm_mgrp_t * const p_mgrp,
- IN const osm_mtree_node_t * const p_mtn)
-{
- uint8_t i;
- uint8_t max_children;
- osm_mtree_node_t *p_child_mtn;
- uint16_t mlid_ho;
- osm_mcast_tbl_t *p_tbl;
- osm_switch_t *p_sw;
-
- OSM_LOG_ENTER(sm->p_log);
-
- mlid_ho = cl_ntoh16(osm_mgrp_get_mlid(p_mgrp));
- p_sw = osm_mtree_node_get_switch_ptr(p_mtn);
-
- CL_ASSERT(p_sw);
-
- OSM_LOG(sm->p_log, OSM_LOG_VERBOSE,
- "Configuring MLID 0x%X on switch 0x%" PRIx64 "\n",
- mlid_ho, osm_node_get_node_guid(p_sw->p_node));
-
- /*
- For every child of this tree node, set the corresponding
- bit in the switch's mcast table.
- */
- p_tbl = osm_switch_get_mcast_tbl_ptr(p_sw);
- max_children = osm_mtree_node_get_max_children(p_mtn);
-
- CL_ASSERT(max_children <= osm_switch_get_num_ports(p_sw));
-
- osm_mcast_tbl_clear_mlid(p_tbl, mlid_ho);
-
- for (i = 0; i < max_children; i++) {
- p_child_mtn = osm_mtree_node_get_child(p_mtn, i);
- if (p_child_mtn == NULL)
- continue;
-
- osm_mcast_tbl_set(p_tbl, mlid_ho, i);
- }
-
- OSM_LOG_EXIT(sm->p_log);
-}
-#endif
-
-/**********************************************************************
- **********************************************************************/
-static void __osm_mcast_mgr_clear(osm_sm_t * sm, IN osm_mgrp_t * const p_mgrp)
-{
- osm_switch_t *p_sw;
- cl_qmap_t *p_sw_tbl;
- osm_mcast_tbl_t *p_mcast_tbl;
-
- OSM_LOG_ENTER(sm->p_log);
-
- /*
- Walk the switches and clear the routing entries for
- this MLID.
- */
- p_sw_tbl = &sm->p_subn->sw_guid_tbl;
- p_sw = (osm_switch_t *) cl_qmap_head(p_sw_tbl);
- while (p_sw != (osm_switch_t *) cl_qmap_end(p_sw_tbl)) {
- p_mcast_tbl = osm_switch_get_mcast_tbl_ptr(p_sw);
- osm_mcast_tbl_clear_mlid(p_mcast_tbl, cl_ntoh16(p_mgrp->mlid));
- p_sw = (osm_switch_t *) cl_qmap_next(&p_sw->map_item);
- }
-
- OSM_LOG_EXIT(sm->p_log);
-}
-
-#if 0
-/* TO DO - make this real -- at least update spanning tree */
-/**********************************************************************
- Lock must be held on entry.
-**********************************************************************/
-ib_api_status_t
-osm_mcast_mgr_process_single(osm_sm_t * sm,
- IN ib_net16_t const mlid,
- IN ib_net64_t const port_guid,
- IN uint8_t const join_state)
-{
- uint8_t port_num;
- uint16_t mlid_ho;
- ib_net64_t sw_guid;
- osm_port_t *p_port;
- osm_physp_t *p_physp;
- osm_physp_t *p_remote_physp;
- osm_node_t *p_remote_node;
- osm_mcast_tbl_t *p_mcast_tbl;
- ib_api_status_t status = IB_SUCCESS;
-
- OSM_LOG_ENTER(sm->p_log);
-
- CL_ASSERT(mlid);
- CL_ASSERT(port_guid);
-
- mlid_ho = cl_ntoh16(mlid);
-
- OSM_LOG(sm->p_log, OSM_LOG_DEBUG,
- "Attempting to add port 0x%" PRIx64 " to MLID 0x%X, "
- "\n\t\t\t\tjoin state = 0x%X\n",
- cl_ntoh64(port_guid), mlid_ho, join_state);
-
- /*
- Acquire the Port object.
- */
- p_port = osm_get_port_by_guid(sm->p_subn, port_guid);
- if (!p_port) {
- OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR 0A01: "
- "Unable to acquire port object for 0x%" PRIx64 "\n",
- cl_ntoh64(port_guid));
- status = IB_ERROR;
- goto Exit;
- }
-
- p_physp = p_port->p_physp;
- if (p_physp == NULL) {
- OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR 0A05: "
- "Unable to acquire phsyical port object for 0x%" PRIx64
- "\n", cl_ntoh64(port_guid));
- status = IB_ERROR;
- goto Exit;
- }
-
- p_remote_physp = osm_physp_get_remote(p_physp);
- if (p_remote_physp == NULL) {
- OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR 0A11: "
- "Unable to acquire remote phsyical port object "
- "for 0x%" PRIx64 "\n", cl_ntoh64(port_guid));
- status = IB_ERROR;
- goto Exit;
- }
-
- p_remote_node = osm_physp_get_node_ptr(p_remote_physp);
-
- CL_ASSERT(p_remote_node);
-
- sw_guid = osm_node_get_node_guid(p_remote_node);
-
- if (osm_node_get_type(p_remote_node) != IB_NODE_TYPE_SWITCH) {
- OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR 0A22: "
- "Remote node not a switch node 0x%" PRIx64 "\n",
- cl_ntoh64(sw_guid));
- status = IB_ERROR;
- goto Exit;
- }
-
- if (!p_remote_node->sw) {
- OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR 0A12: "
- "No switch object 0x%" PRIx64 "\n", cl_ntoh64(sw_guid));
- status = IB_ERROR;
- goto Exit;
- }
-
- if (osm_switch_is_in_mcast_tree(p_remote_node->sw, mlid_ho)) {
- /*
- We're in luck. The switch attached to this port
- is already in the multicast group, so we can just
- add the specified port as a new leaf of the tree.
- */
- if (join_state & (IB_JOIN_STATE_FULL | IB_JOIN_STATE_NON)) {
- /*
- This node wants to receive multicast frames.
- Get the switch port number to which the new member port
- is attached, then configure this single mcast table.
- */
- port_num = osm_physp_get_port_num(p_remote_physp);
- CL_ASSERT(port_num);
-
- p_mcast_tbl =
- osm_switch_get_mcast_tbl_ptr(p_remote_node->sw);
- osm_mcast_tbl_set(p_mcast_tbl, mlid_ho, port_num);
- } else {
- if (join_state & IB_JOIN_STATE_SEND_ONLY)
- OSM_LOG(sm->p_log, OSM_LOG_DEBUG,
- "Success. Nothing to do for send"
- "only member\n");
- else {
- OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR 0A13: "
- "Unknown join state 0x%X\n",
- join_state);
- status = IB_ERROR;
- goto Exit;
- }
- }
- } else
- OSM_LOG(sm->p_log, OSM_LOG_DEBUG, "Unable to add port\n");
-
-Exit:
- OSM_LOG_EXIT(sm->p_log);
- return (status);
-}
-#endif
-
-/**********************************************************************
- lock must already be held on entry
-**********************************************************************/
-static ib_api_status_t
-osm_mcast_mgr_process_tree(osm_sm_t * sm,
- IN osm_mgrp_t * const p_mgrp,
- IN osm_mcast_req_type_t req_type,
- ib_net64_t port_guid)
-{
- ib_api_status_t status = IB_SUCCESS;
- ib_net16_t mlid;
-
- OSM_LOG_ENTER(sm->p_log);
-
- mlid = osm_mgrp_get_mlid(p_mgrp);
-
- OSM_LOG(sm->p_log, OSM_LOG_DEBUG,
- "Processing multicast group 0x%X\n", cl_ntoh16(mlid));
-
- /*
- If there are no switches in the subnet, then we have nothing to do.
- */
- if (cl_qmap_count(&sm->p_subn->sw_guid_tbl) == 0) {
- OSM_LOG(sm->p_log, OSM_LOG_DEBUG,
- "No switches in subnet. Nothing to do\n");
- goto Exit;
- }
-
- /*
- Clear the multicast tables to start clean, then build
- the spanning tree which sets the mcast table bits for each
- port in the group.
- */
- __osm_mcast_mgr_clear(sm, p_mgrp);
-
- if (!p_mgrp->full_members)
- goto Exit;
-
- status = __osm_mcast_mgr_build_spanning_tree(sm, p_mgrp);
- if (status != IB_SUCCESS) {
- OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR 0A17: "
- "Unable to create spanning tree (%s)\n",
- ib_get_err_str(status));
- goto Exit;
- }
-
-Exit:
- OSM_LOG_EXIT(sm->p_log);
- return (status);
-}
-
-/**********************************************************************
- Process the entire group.
- NOTE : The lock should be held externally!
- **********************************************************************/
-static ib_api_status_t
-mcast_mgr_process_mgrp(osm_sm_t * sm,
- IN osm_mgrp_t * const p_mgrp,
- IN osm_mcast_req_type_t req_type,
- IN ib_net64_t port_guid)
-{
- ib_api_status_t status;
-
- OSM_LOG_ENTER(sm->p_log);
-
- status = osm_mcast_mgr_process_tree(sm, p_mgrp, req_type, port_guid);
- if (status != IB_SUCCESS) {
- OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR 0A19: "
- "Unable to create spanning tree (%s)\n",
- ib_get_err_str(status));
- goto Exit;
- }
- p_mgrp->last_tree_id = p_mgrp->last_change_id;
-
- /* remove MCGRP if it is marked for deletion */
- if (p_mgrp->to_be_deleted) {
- OSM_LOG(sm->p_log, OSM_LOG_DEBUG,
- "Destroying mgrp with lid:0x%x\n",
- cl_ntoh16(p_mgrp->mlid));
- sm->p_subn->mgroups[cl_ntoh16(p_mgrp->mlid) - IB_LID_MCAST_START_HO] = NULL;
- osm_mgrp_delete(p_mgrp);
- }
-
-Exit:
- OSM_LOG_EXIT(sm->p_log);
- return status;
-}
-
-/**********************************************************************
- **********************************************************************/
-osm_signal_t osm_mcast_mgr_process(osm_sm_t * sm)
-{
- osm_signal_t signal;
- osm_switch_t *p_sw;
- cl_qmap_t *p_sw_tbl;
- cl_qlist_t *p_list = &sm->mgrp_list;
- osm_mgrp_t *p_mgrp;
- boolean_t pending_transactions = FALSE;
- int i;
-
- OSM_LOG_ENTER(sm->p_log);
-
- p_sw_tbl = &sm->p_subn->sw_guid_tbl;
- /*
- While holding the lock, iterate over all the established
- multicast groups, servicing each in turn.
-
- Then, download the multicast tables to the switches.
- */
- CL_PLOCK_EXCL_ACQUIRE(sm->p_lock);
-
- for (i = 0; i <= sm->p_subn->max_mcast_lid_ho - IB_LID_MCAST_START_HO;
- i++) {
- /*
- We reached here due to some change that caused a heavy sweep
- of the subnet. Not due to a specific multicast request.
- So the request type is subnet_change and the port guid is 0.
- */
- p_mgrp = sm->p_subn->mgroups[i];
- if (p_mgrp)
- mcast_mgr_process_mgrp(sm, p_mgrp,
- OSM_MCAST_REQ_TYPE_SUBNET_CHANGE,
- 0);
- }
-
- /*
- Walk the switches and download the tables for each.
- */
- p_sw = (osm_switch_t *) cl_qmap_head(p_sw_tbl);
- while (p_sw != (osm_switch_t *) cl_qmap_end(p_sw_tbl)) {
- signal = __osm_mcast_mgr_set_tbl(sm, p_sw);
- if (signal == OSM_SIGNAL_DONE_PENDING)
- pending_transactions = TRUE;
- p_sw = (osm_switch_t *) cl_qmap_next(&p_sw->map_item);
- }
-
- while (!cl_is_qlist_empty(p_list)) {
- cl_list_item_t *p = cl_qlist_remove_head(p_list);
- free(p);
- }
-
- CL_PLOCK_RELEASE(sm->p_lock);
-
- OSM_LOG_EXIT(sm->p_log);
-
- if (pending_transactions == TRUE)
- return (OSM_SIGNAL_DONE_PENDING);
- else
- return (OSM_SIGNAL_DONE);
-}
-
-/**********************************************************************
- This is the function that is invoked during idle time to handle the
- process request for mcast groups where join/leave/delete was required.
- **********************************************************************/
-osm_signal_t osm_mcast_mgr_process_mgroups(osm_sm_t * sm)
-{
- cl_qlist_t *p_list = &sm->mgrp_list;
- osm_switch_t *p_sw;
- cl_qmap_t *p_sw_tbl;
- osm_mgrp_t *p_mgrp;
- ib_net16_t mlid;
- osm_signal_t ret, signal = OSM_SIGNAL_DONE;
- osm_mcast_mgr_ctxt_t *ctx;
- osm_mcast_req_type_t req_type;
- ib_net64_t port_guid;
-
- OSM_LOG_ENTER(sm->p_log);
-
- /* we need a lock to make sure the p_mgrp is not change other ways */
- CL_PLOCK_EXCL_ACQUIRE(sm->p_lock);
-
- while (!cl_is_qlist_empty(p_list)) {
- ctx = (osm_mcast_mgr_ctxt_t *) cl_qlist_remove_head(p_list);
- req_type = ctx->req_type;
- port_guid = ctx->port_guid;
-
- /* nice copy no warning on size diff */
- memcpy(&mlid, &ctx->mlid, sizeof(mlid));
-
- /* we can destroy the context now */
- free(ctx);
-
- /* since we delayed the execution we prefer to pass the
- mlid as the mgrp identifier and then find it or abort */
- p_mgrp = osm_get_mgrp_by_mlid(sm->p_subn, mlid);
- if (!p_mgrp)
- continue;
-
- /* if there was no change from the last time
- * we processed the group we can skip doing anything
- */
- if (p_mgrp->last_change_id == p_mgrp->last_tree_id) {
- OSM_LOG(sm->p_log, OSM_LOG_DEBUG,
- "Skip processing mgrp with lid:0x%X change id:%u\n",
- cl_ntoh16(mlid), p_mgrp->last_change_id);
- continue;
- }
-
- OSM_LOG(sm->p_log, OSM_LOG_DEBUG,
- "Processing mgrp with lid:0x%X change id:%u\n",
- cl_ntoh16(mlid), p_mgrp->last_change_id);
- mcast_mgr_process_mgrp(sm, p_mgrp, req_type, port_guid);
- }
-
- /*
- Walk the switches and download the tables for each.
- */
- p_sw_tbl = &sm->p_subn->sw_guid_tbl;
- p_sw = (osm_switch_t *) cl_qmap_head(p_sw_tbl);
- while (p_sw != (osm_switch_t *) cl_qmap_end(p_sw_tbl)) {
- ret = __osm_mcast_mgr_set_tbl(sm, p_sw);
- if (ret == OSM_SIGNAL_DONE_PENDING)
- signal = ret;
- p_sw = (osm_switch_t *) cl_qmap_next(&p_sw->map_item);
- }
-
- osm_dump_mcast_routes(sm->p_subn->p_osm);
-
- CL_PLOCK_RELEASE(sm->p_lock);
- OSM_LOG_EXIT(sm->p_log);
- return signal;
-}
diff --git a/contrib/ofed/management/opensm/opensm/osm_mcast_tbl.c b/contrib/ofed/management/opensm/opensm/osm_mcast_tbl.c
deleted file mode 100644
index 17fb69c..0000000
--- a/contrib/ofed/management/opensm/opensm/osm_mcast_tbl.c
+++ /dev/null
@@ -1,284 +0,0 @@
-/*
- * Copyright (c) 2004-2006 Voltaire, Inc. All rights reserved.
- * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved.
- * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- */
-
-/*
- * Abstract:
- * Implementation of osm_mcast_tbl_t.
- * This object represents an multicast forwarding table.
- * This object is part of the opensm family of objects.
- */
-
-#if HAVE_CONFIG_H
-# include <config.h>
-#endif /* HAVE_CONFIG_H */
-
-#include <stdlib.h>
-#include <string.h>
-#include <complib/cl_math.h>
-#include <iba/ib_types.h>
-#include <opensm/osm_mcast_tbl.h>
-
-/**********************************************************************
- **********************************************************************/
-ib_api_status_t
-osm_mcast_tbl_init(IN osm_mcast_tbl_t * const p_tbl,
- IN uint8_t const num_ports, IN uint16_t const capacity)
-{
- CL_ASSERT(p_tbl);
- CL_ASSERT(num_ports);
-
- memset(p_tbl, 0, sizeof(*p_tbl));
-
- p_tbl->max_block_in_use = -1;
-
- if (capacity == 0) {
- /*
- This switch apparently doesn't support multicast.
- Everything is initialized to zero already, so return.
- */
- return (IB_SUCCESS);
- }
-
- p_tbl->num_entries = capacity;
- p_tbl->num_ports = num_ports;
- p_tbl->max_position =
- (uint8_t) ((ROUNDUP(num_ports, IB_MCAST_MASK_SIZE) /
- IB_MCAST_MASK_SIZE) - 1);
-
- p_tbl->max_block = (uint16_t) ((ROUNDUP(p_tbl->num_entries,
- IB_MCAST_BLOCK_SIZE) /
- IB_MCAST_BLOCK_SIZE) - 1);
-
- p_tbl->max_mlid_ho = (uint16_t) (IB_LID_MCAST_START_HO + capacity - 1);
-
- /*
- The number of bytes needed in the mask table is:
- The (maximum bit mask 'position' + 1) times the
- number of bytes in each bit mask times the
- number of MLIDs supported by the table.
-
- We must always allocate the array with the maximum position
- since it is (and must be) defined that way the table structure
- in order to create a pointer to a two dimensional array.
- */
- p_tbl->p_mask_tbl = malloc(p_tbl->num_entries *
- (IB_MCAST_POSITION_MAX +
- 1) * IB_MCAST_MASK_SIZE / 8);
-
- if (p_tbl->p_mask_tbl == NULL)
- return (IB_INSUFFICIENT_MEMORY);
-
- memset(p_tbl->p_mask_tbl, 0,
- p_tbl->num_entries * (IB_MCAST_POSITION_MAX +
- 1) * IB_MCAST_MASK_SIZE / 8);
- return (IB_SUCCESS);
-}
-
-/**********************************************************************
- **********************************************************************/
-void osm_mcast_tbl_destroy(IN osm_mcast_tbl_t * const p_tbl)
-{
- free(p_tbl->p_mask_tbl);
-}
-
-/**********************************************************************
- **********************************************************************/
-void
-osm_mcast_tbl_set(IN osm_mcast_tbl_t * const p_tbl,
- IN const uint16_t mlid_ho, IN const uint8_t port)
-{
- uintn_t mlid_offset;
- uintn_t mask_offset;
- uintn_t bit_mask;
- int16_t block_num;
-
- CL_ASSERT(p_tbl);
- CL_ASSERT(mlid_ho >= IB_LID_MCAST_START_HO);
- CL_ASSERT(mlid_ho <= p_tbl->max_mlid_ho);
- CL_ASSERT(p_tbl->p_mask_tbl);
-
- mlid_offset = mlid_ho - IB_LID_MCAST_START_HO;
- mask_offset = port / IB_MCAST_MASK_SIZE;
- bit_mask = cl_ntoh16((uint16_t) (1 << (port % IB_MCAST_MASK_SIZE)));
- (*p_tbl->p_mask_tbl)[mlid_offset][mask_offset] |= bit_mask;
-
- block_num = (int16_t) (mlid_offset / IB_MCAST_BLOCK_SIZE);
-
- if (block_num > p_tbl->max_block_in_use)
- p_tbl->max_block_in_use = (uint16_t) block_num;
-}
-
-/**********************************************************************
- **********************************************************************/
-boolean_t
-osm_mcast_tbl_is_port(IN const osm_mcast_tbl_t * const p_tbl,
- IN const uint16_t mlid_ho, IN const uint8_t port_num)
-{
- uintn_t mlid_offset;
- uintn_t mask_offset;
- uintn_t bit_mask;
-
- CL_ASSERT(p_tbl);
-
- if (p_tbl->p_mask_tbl) {
- CL_ASSERT(port_num <=
- (p_tbl->max_position + 1) * IB_MCAST_MASK_SIZE);
- CL_ASSERT(mlid_ho >= IB_LID_MCAST_START_HO);
- CL_ASSERT(mlid_ho <= p_tbl->max_mlid_ho);
-
- mlid_offset = mlid_ho - IB_LID_MCAST_START_HO;
- mask_offset = port_num / IB_MCAST_MASK_SIZE;
- bit_mask = cl_ntoh16((uint16_t)
- (1 << (port_num % IB_MCAST_MASK_SIZE)));
- return (((*p_tbl->
- p_mask_tbl)[mlid_offset][mask_offset] & bit_mask) ==
- bit_mask);
- }
-
- return (FALSE);
-}
-
-/**********************************************************************
- **********************************************************************/
-boolean_t
-osm_mcast_tbl_is_any_port(IN const osm_mcast_tbl_t * const p_tbl,
- IN const uint16_t mlid_ho)
-{
- uintn_t mlid_offset;
- uint8_t position;
- uint16_t result = 0;
-
- CL_ASSERT(p_tbl);
-
- if (p_tbl->p_mask_tbl) {
- CL_ASSERT(mlid_ho >= IB_LID_MCAST_START_HO);
- CL_ASSERT(mlid_ho <= p_tbl->max_mlid_ho);
-
- mlid_offset = mlid_ho - IB_LID_MCAST_START_HO;
-
- for (position = 0; position <= p_tbl->max_position; position++)
- result |= (*p_tbl->p_mask_tbl)[mlid_offset][position];
- }
-
- return (result != 0);
-}
-
-/**********************************************************************
- **********************************************************************/
-ib_api_status_t
-osm_mcast_tbl_set_block(IN osm_mcast_tbl_t * const p_tbl,
- IN const ib_net16_t * const p_block,
- IN const int16_t block_num, IN const uint8_t position)
-{
- uint32_t i;
- uint16_t mlid_start_ho;
-
- CL_ASSERT(p_tbl);
- CL_ASSERT(p_block);
-
- if (block_num > p_tbl->max_block)
- return (IB_INVALID_PARAMETER);
-
- if (position > p_tbl->max_position)
- return (IB_INVALID_PARAMETER);
-
- mlid_start_ho = (uint16_t) (block_num * IB_MCAST_BLOCK_SIZE);
-
- if (mlid_start_ho + IB_MCAST_BLOCK_SIZE - 1 > p_tbl->max_mlid_ho)
- return (IB_INVALID_PARAMETER);
-
- for (i = 0; i < IB_MCAST_BLOCK_SIZE; i++)
- (*p_tbl->p_mask_tbl)[mlid_start_ho + i][position] = p_block[i];
-
- if (block_num > p_tbl->max_block_in_use)
- p_tbl->max_block_in_use = (uint16_t) block_num;
-
- return (IB_SUCCESS);
-}
-
-/**********************************************************************
- **********************************************************************/
-void
-osm_mcast_tbl_clear_mlid(IN osm_mcast_tbl_t * const p_tbl,
- IN const uint16_t mlid_ho)
-{
- uint8_t i;
- uintn_t mlid_offset;
-
- CL_ASSERT(p_tbl);
- CL_ASSERT(mlid_ho >= IB_LID_MCAST_START_HO);
-
- if (p_tbl->p_mask_tbl && (mlid_ho <= p_tbl->max_mlid_ho)) {
- mlid_offset = mlid_ho - IB_LID_MCAST_START_HO;
- for (i = 0; i <= p_tbl->max_position; i++)
- (*p_tbl->p_mask_tbl)[mlid_offset][i] = 0;
- }
-}
-
-/**********************************************************************
- **********************************************************************/
-boolean_t
-osm_mcast_tbl_get_block(IN osm_mcast_tbl_t * const p_tbl,
- IN int16_t const block_num,
- IN uint8_t const position,
- OUT ib_net16_t * const p_block)
-{
- uint32_t i;
- uint16_t mlid_start_ho;
-
- CL_ASSERT(p_tbl);
- CL_ASSERT(p_block);
-
- if (block_num > p_tbl->max_block_in_use)
- return (FALSE);
-
- if (position > p_tbl->max_position) {
- /*
- Caller shouldn't do this for efficiency's sake...
- */
- memset(p_block, 0, IB_SMP_DATA_SIZE);
- return (TRUE);
- }
-
- mlid_start_ho = (uint16_t) (block_num * IB_MCAST_BLOCK_SIZE);
-
- if (mlid_start_ho + IB_MCAST_BLOCK_SIZE - 1 > p_tbl->max_mlid_ho)
- return (IB_INVALID_PARAMETER);
-
- for (i = 0; i < IB_MCAST_BLOCK_SIZE; i++)
- p_block[i] = (*p_tbl->p_mask_tbl)[mlid_start_ho + i][position];
-
- return (TRUE);
-}
diff --git a/contrib/ofed/management/opensm/opensm/osm_mcm_info.c b/contrib/ofed/management/opensm/opensm/osm_mcm_info.c
deleted file mode 100644
index 0325a34..0000000
--- a/contrib/ofed/management/opensm/opensm/osm_mcm_info.c
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * Copyright (c) 2004-2007 Voltaire, Inc. All rights reserved.
- * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved.
- * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- */
-
-/*
- * Abstract:
- * Declaration of osm_mcm_info_t.
- * This object represents a Multicast Forwarding Information object.
- * This object is part of the OpenSM family of objects.
- */
-
-#if HAVE_CONFIG_H
-# include <config.h>
-#endif /* HAVE_CONFIG_H */
-
-#include <stdlib.h>
-#include <opensm/osm_mcm_info.h>
-
-/**********************************************************************
- **********************************************************************/
-osm_mcm_info_t *osm_mcm_info_new(IN const ib_net16_t mlid)
-{
- osm_mcm_info_t *p_mcm;
-
- p_mcm = (osm_mcm_info_t *) malloc(sizeof(*p_mcm));
- if (p_mcm) {
- memset(p_mcm, 0, sizeof(*p_mcm));
- p_mcm->mlid = mlid;
- }
-
- return (p_mcm);
-}
-
-/**********************************************************************
- **********************************************************************/
-void osm_mcm_info_delete(IN osm_mcm_info_t * const p_mcm)
-{
- free(p_mcm);
-}
diff --git a/contrib/ofed/management/opensm/opensm/osm_mcm_port.c b/contrib/ofed/management/opensm/opensm/osm_mcm_port.c
deleted file mode 100644
index b6b6149..0000000
--- a/contrib/ofed/management/opensm/opensm/osm_mcm_port.c
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * Copyright (c) 2004-2008 Voltaire, Inc. All rights reserved.
- * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved.
- * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- */
-
-/*
- * Abstract:
- * Implementation of osm_mcm_port_t.
- * This object represents the membership of a port in a multicast group.
- * This object is part of the OpenSM family of objects.
- */
-
-#if HAVE_CONFIG_H
-# include <config.h>
-#endif /* HAVE_CONFIG_H */
-
-#include <stdlib.h>
-#include <string.h>
-#include <opensm/osm_mcm_port.h>
-
-/**********************************************************************
- **********************************************************************/
-osm_mcm_port_t *osm_mcm_port_new(IN const ib_gid_t * const p_port_gid,
- IN const uint8_t scope_state,
- IN const boolean_t proxy_join)
-{
- osm_mcm_port_t *p_mcm;
-
- p_mcm = malloc(sizeof(*p_mcm));
- if (p_mcm) {
- memset(p_mcm, 0, sizeof(*p_mcm));
- p_mcm->port_gid = *p_port_gid;
- p_mcm->scope_state = scope_state;
- p_mcm->proxy_join = proxy_join;
- }
-
- return (p_mcm);
-}
-
-/**********************************************************************
- **********************************************************************/
-void osm_mcm_port_delete(IN osm_mcm_port_t * const p_mcm)
-{
- CL_ASSERT(p_mcm);
- free(p_mcm);
-}
diff --git a/contrib/ofed/management/opensm/opensm/osm_mtree.c b/contrib/ofed/management/opensm/opensm/osm_mtree.c
deleted file mode 100644
index 3832e7d..0000000
--- a/contrib/ofed/management/opensm/opensm/osm_mtree.c
+++ /dev/null
@@ -1,125 +0,0 @@
-/*
- * Copyright (c) 2004-2008 Voltaire, Inc. All rights reserved.
- * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved.
- * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- */
-
-/*
- * Abstract:
- * Implementation of osm_mtree_node_t.
- * This file implements the Multicast Tree object.
- */
-
-#if HAVE_CONFIG_H
-# include <config.h>
-#endif /* HAVE_CONFIG_H */
-
-#include <stdlib.h>
-#include <complib/cl_debug.h>
-#include <opensm/osm_mtree.h>
-
-/**********************************************************************
- **********************************************************************/
-static void
-osm_mtree_node_init(IN osm_mtree_node_t * const p_mtn,
- IN const osm_switch_t * const p_sw)
-{
- uint32_t i;
-
- CL_ASSERT(p_mtn);
- CL_ASSERT(p_sw);
-
- memset(p_mtn, 0, sizeof(*p_mtn));
-
- p_mtn->p_sw = (osm_switch_t *) p_sw;
- p_mtn->max_children = p_sw->num_ports;
-
- for (i = 0; i < p_mtn->max_children; i++)
- p_mtn->child_array[i] = NULL;
-}
-
-/**********************************************************************
- **********************************************************************/
-osm_mtree_node_t *osm_mtree_node_new(IN const osm_switch_t * const p_sw)
-{
- osm_mtree_node_t *p_mtn;
-
- p_mtn = malloc(sizeof(osm_mtree_node_t) +
- sizeof(void *) * (p_sw->num_ports - 1));
-
- if (p_mtn != NULL)
- osm_mtree_node_init(p_mtn, p_sw);
-
- return (p_mtn);
-}
-
-/**********************************************************************
- **********************************************************************/
-void osm_mtree_destroy(IN osm_mtree_node_t * p_mtn)
-{
- uint32_t i;
-
- if (p_mtn == NULL)
- return;
-
- if (p_mtn->child_array != NULL)
- for (i = 0; i < p_mtn->max_children; i++)
- if ((p_mtn->child_array[i] != NULL) &&
- (p_mtn->child_array[i] != OSM_MTREE_LEAF))
- osm_mtree_destroy(p_mtn->child_array[i]);
-
- free(p_mtn);
-}
-
-/**********************************************************************
- **********************************************************************/
-#if 0
-static void __osm_mtree_dump(IN osm_mtree_node_t * p_mtn)
-{
- uint32_t i;
-
- if (p_mtn == NULL)
- return;
-
- printf("GUID:0x%016" PRIx64 " max_children:%u\n",
- cl_ntoh64(p_mtn->p_sw->p_node->node_info.node_guid),
- p_mtn->max_children);
- if (p_mtn->child_array != NULL) {
- for (i = 0; i < p_mtn->max_children; i++) {
- printf("i=%d\n", i);
- if ((p_mtn->child_array[i] != NULL)
- && (p_mtn->child_array[i] != OSM_MTREE_LEAF))
- __osm_mtree_dump(p_mtn->child_array[i]);
- }
- }
-}
-#endif
diff --git a/contrib/ofed/management/opensm/opensm/osm_multicast.c b/contrib/ofed/management/opensm/opensm/osm_multicast.c
deleted file mode 100644
index 350fd22..0000000
--- a/contrib/ofed/management/opensm/opensm/osm_multicast.c
+++ /dev/null
@@ -1,302 +0,0 @@
-/*
- * Copyright (c) 2004-2008 Voltaire, Inc. All rights reserved.
- * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved.
- * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- */
-
-/*
- * Abstract:
- * Implementation of multicast functions.
- */
-
-#if HAVE_CONFIG_H
-# include <config.h>
-#endif /* HAVE_CONFIG_H */
-
-#include <stdlib.h>
-#include <string.h>
-#include <opensm/osm_multicast.h>
-#include <opensm/osm_mcm_port.h>
-#include <opensm/osm_mtree.h>
-#include <opensm/osm_inform.h>
-
-/**********************************************************************
- **********************************************************************/
-void osm_mgrp_delete(IN osm_mgrp_t * const p_mgrp)
-{
- osm_mcm_port_t *p_mcm_port;
- osm_mcm_port_t *p_next_mcm_port;
-
- CL_ASSERT(p_mgrp);
-
- p_next_mcm_port =
- (osm_mcm_port_t *) cl_qmap_head(&p_mgrp->mcm_port_tbl);
- while (p_next_mcm_port !=
- (osm_mcm_port_t *) cl_qmap_end(&p_mgrp->mcm_port_tbl)) {
- p_mcm_port = p_next_mcm_port;
- p_next_mcm_port =
- (osm_mcm_port_t *) cl_qmap_next(&p_mcm_port->map_item);
- osm_mcm_port_delete(p_mcm_port);
- }
- /* destroy the mtree_node structure */
- osm_mtree_destroy(p_mgrp->p_root);
-
- free(p_mgrp);
-}
-
-/**********************************************************************
- **********************************************************************/
-osm_mgrp_t *osm_mgrp_new(IN const ib_net16_t mlid)
-{
- osm_mgrp_t *p_mgrp;
-
- p_mgrp = (osm_mgrp_t *) malloc(sizeof(*p_mgrp));
- if (!p_mgrp)
- return NULL;
-
- memset(p_mgrp, 0, sizeof(*p_mgrp));
- cl_qmap_init(&p_mgrp->mcm_port_tbl);
- p_mgrp->mlid = mlid;
- p_mgrp->last_change_id = 0;
- p_mgrp->last_tree_id = 0;
- p_mgrp->to_be_deleted = FALSE;
-
- return p_mgrp;
-}
-
-/**********************************************************************
- **********************************************************************/
-static void mgrp_send_notice(osm_subn_t *subn, osm_log_t *log,
- osm_mgrp_t *mgrp, unsigned num)
-{
- ib_mad_notice_attr_t notice;
- ib_api_status_t status;
-
- notice.generic_type = 0x83; /* generic SubnMgt type */
- ib_notice_set_prod_type_ho(&notice, 4); /* A Class Manager generator */
- notice.g_or_v.generic.trap_num = CL_HTON16(num);
- /* The sm_base_lid is saved in network order already. */
- notice.issuer_lid = subn->sm_base_lid;
- /* following o14-12.1.11 and table 120 p726 */
- /* we need to provide the MGID */
- memcpy(&notice.data_details.ntc_64_67.gid,
- &mgrp->mcmember_rec.mgid, sizeof(ib_gid_t));
-
- /* According to page 653 - the issuer gid in this case of trap
- is the SM gid, since the SM is the initiator of this trap. */
- notice.issuer_gid.unicast.prefix = subn->opt.subnet_prefix;
- notice.issuer_gid.unicast.interface_id = subn->sm_port_guid;
-
- if ((status = osm_report_notice(log, subn, &notice)))
- OSM_LOG(log, OSM_LOG_ERROR, "ERR 7601: "
- "Error sending trap reports (%s)\n",
- ib_get_err_str(status));
-}
-
-/**********************************************************************
- **********************************************************************/
-osm_mcm_port_t *osm_mgrp_add_port(IN osm_subn_t *subn, osm_log_t *log,
- IN osm_mgrp_t * const p_mgrp,
- IN const ib_gid_t * const p_port_gid,
- IN const uint8_t join_state,
- IN boolean_t proxy_join)
-{
- ib_net64_t port_guid;
- osm_mcm_port_t *p_mcm_port;
- cl_map_item_t *prev_item;
- uint8_t prev_join_state = 0;
- uint8_t prev_scope;
-
- p_mcm_port = osm_mcm_port_new(p_port_gid, join_state, proxy_join);
- if (!p_mcm_port)
- return NULL;
-
- port_guid = p_port_gid->unicast.interface_id;
-
- /*
- prev_item = cl_qmap_insert(...)
- Pointer to the item in the map with the specified key. If insertion
- was successful, this is the pointer to the item. If an item with the
- specified key already exists in the map, the pointer to that item is
- returned.
- */
- prev_item = cl_qmap_insert(&p_mgrp->mcm_port_tbl,
- port_guid, &p_mcm_port->map_item);
-
- /* if already exists - revert the insertion and only update join state */
- if (prev_item != &p_mcm_port->map_item) {
- osm_mcm_port_delete(p_mcm_port);
- p_mcm_port = (osm_mcm_port_t *) prev_item;
-
- /*
- o15.0.1.11
- Join state of the end port should be the or of the
- previous setting with the current one
- */
- ib_member_get_scope_state(p_mcm_port->scope_state, &prev_scope,
- &prev_join_state);
- p_mcm_port->scope_state =
- ib_member_set_scope_state(prev_scope,
- prev_join_state | join_state);
- } else {
- /* track the fact we modified the group ports */
- p_mgrp->last_change_id++;
- }
-
- if ((join_state & IB_JOIN_STATE_FULL) &&
- !(prev_join_state & IB_JOIN_STATE_FULL) &&
- (++p_mgrp->full_members == 1)) {
- mgrp_send_notice(subn, log, p_mgrp, 66);
- p_mgrp->to_be_deleted = 0;
- }
-
- return (p_mcm_port);
-}
-
-/**********************************************************************
- **********************************************************************/
-int osm_mgrp_remove_port(osm_subn_t *subn, osm_log_t *log, osm_mgrp_t *mgrp,
- osm_mcm_port_t *mcm, uint8_t join_state)
-{
- int ret;
- uint8_t port_join_state;
- uint8_t new_join_state;
-
- /*
- * according to the same o15-0.1.14 we get the stored
- * JoinState and the request JoinState and they must be
- * opposite to leave - otherwise just update it
- */
- port_join_state = mcm->scope_state & 0x0F;
- new_join_state = port_join_state & ~join_state;
-
- if (new_join_state) {
- mcm->scope_state = new_join_state | (mcm->scope_state & 0xf0);
- OSM_LOG(log, OSM_LOG_DEBUG,
- "updating port 0x%" PRIx64 " JoinState 0x%x -> 0x%x\n",
- cl_ntoh64(mcm->port_gid.unicast.interface_id),
- port_join_state, new_join_state);
- ret = 0;
- } else {
- cl_qmap_remove_item(&mgrp->mcm_port_tbl, &mcm->map_item);
- OSM_LOG(log, OSM_LOG_DEBUG, "removing port 0x%" PRIx64 "\n",
- cl_ntoh64(mcm->port_gid.unicast.interface_id));
- osm_mcm_port_delete(mcm);
- /* track the fact we modified the group */
- mgrp->last_change_id++;
- ret = 1;
- }
-
- /* no more full members so the group will be deleted after re-route
- but only if it is not a well known group */
- if ((port_join_state & IB_JOIN_STATE_FULL) &&
- !(new_join_state & IB_JOIN_STATE_FULL) &&
- (--mgrp->full_members == 0)) {
- mgrp_send_notice(subn, log, mgrp, 67);
- if (!mgrp->well_known)
- mgrp->to_be_deleted = 1;
- }
-
- return ret;
-}
-
-void osm_mgrp_delete_port(osm_subn_t *subn, osm_log_t *log, osm_mgrp_t *mgrp,
- ib_net64_t port_guid)
-{
- cl_map_item_t *item = cl_qmap_get(&mgrp->mcm_port_tbl, port_guid);
-
- if (item != cl_qmap_end(&mgrp->mcm_port_tbl))
- osm_mgrp_remove_port(subn, log, mgrp, (osm_mcm_port_t *)item, 0xf);
-}
-
-/**********************************************************************
- **********************************************************************/
-boolean_t
-osm_mgrp_is_port_present(IN const osm_mgrp_t * const p_mgrp,
- IN const ib_net64_t port_guid,
- OUT osm_mcm_port_t ** const pp_mcm_port)
-{
- cl_map_item_t *p_map_item;
-
- CL_ASSERT(p_mgrp);
-
- p_map_item = cl_qmap_get(&p_mgrp->mcm_port_tbl, port_guid);
-
- if (p_map_item != cl_qmap_end(&p_mgrp->mcm_port_tbl)) {
- if (pp_mcm_port)
- *pp_mcm_port = (osm_mcm_port_t *) p_map_item;
- return TRUE;
- }
- if (pp_mcm_port)
- *pp_mcm_port = NULL;
- return FALSE;
-}
-
-/**********************************************************************
- **********************************************************************/
-static void
-__osm_mgrp_apply_func_sub(const osm_mgrp_t * const p_mgrp,
- const osm_mtree_node_t * const p_mtn,
- osm_mgrp_func_t p_func, void *context)
-{
- uint8_t i = 0;
- uint8_t max_children;
- osm_mtree_node_t *p_child_mtn;
-
- /* Call the user, then recurse. */
- p_func(p_mgrp, p_mtn, context);
-
- max_children = osm_mtree_node_get_max_children(p_mtn);
- for (i = 0; i < max_children; i++) {
- p_child_mtn = osm_mtree_node_get_child(p_mtn, i);
- if (p_child_mtn)
- __osm_mgrp_apply_func_sub(p_mgrp, p_child_mtn, p_func,
- context);
- }
-}
-
-/**********************************************************************
- **********************************************************************/
-void
-osm_mgrp_apply_func(const osm_mgrp_t * const p_mgrp,
- osm_mgrp_func_t p_func, void *context)
-{
- osm_mtree_node_t *p_mtn;
-
- CL_ASSERT(p_mgrp);
- CL_ASSERT(p_func);
-
- p_mtn = p_mgrp->p_root;
-
- if (p_mtn)
- __osm_mgrp_apply_func_sub(p_mgrp, p_mtn, p_func, context);
-}
diff --git a/contrib/ofed/management/opensm/opensm/osm_node.c b/contrib/ofed/management/opensm/opensm/osm_node.c
deleted file mode 100644
index 07371a2..0000000
--- a/contrib/ofed/management/opensm/opensm/osm_node.c
+++ /dev/null
@@ -1,312 +0,0 @@
-/*
- * Copyright (c) 2004-2008 Voltaire, Inc. All rights reserved.
- * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved.
- * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- */
-
-/*
- * Abstract:
- * Implementation of osm_node_t.
- * This object represents an Infiniband Node.
- * This object is part of the opensm family of objects.
- */
-
-#if HAVE_CONFIG_H
-# include <config.h>
-#endif /* HAVE_CONFIG_H */
-
-#include <stdlib.h>
-#include <iba/ib_types.h>
-#include <opensm/osm_node.h>
-#include <opensm/osm_madw.h>
-
-/**********************************************************************
- **********************************************************************/
-void
-osm_node_init_physp(IN osm_node_t * const p_node,
- IN const osm_madw_t * const p_madw)
-{
- ib_net64_t port_guid;
- ib_smp_t *p_smp;
- ib_node_info_t *p_ni;
- uint8_t port_num;
-
- p_smp = osm_madw_get_smp_ptr(p_madw);
-
- p_ni = (ib_node_info_t *) ib_smp_get_payload_ptr(p_smp);
- port_guid = p_ni->port_guid;
- port_num = ib_node_info_get_local_port_num(p_ni);
-
- CL_ASSERT(port_num < p_node->physp_tbl_size);
-
- osm_physp_init(&p_node->physp_table[port_num],
- port_guid, port_num, p_node,
- osm_madw_get_bind_handle(p_madw),
- p_smp->hop_count, p_smp->initial_path);
-}
-
-/**********************************************************************
- **********************************************************************/
-static void node_init_physp0(IN osm_node_t * const p_node,
- IN const osm_madw_t * const p_madw)
-{
- ib_smp_t *p_smp;
- ib_node_info_t *p_ni;
-
- p_smp = osm_madw_get_smp_ptr(p_madw);
- p_ni = (ib_node_info_t *) ib_smp_get_payload_ptr(p_smp);
-
- osm_physp_init(&p_node->physp_table[0],
- p_ni->port_guid, 0, p_node,
- osm_madw_get_bind_handle(p_madw),
- p_smp->hop_count, p_smp->initial_path);
-}
-
-/**********************************************************************
- **********************************************************************/
-osm_node_t *osm_node_new(IN const osm_madw_t * const p_madw)
-{
- osm_node_t *p_node;
- ib_smp_t *p_smp;
- ib_node_info_t *p_ni;
- uint8_t i;
- uint32_t size;
-
- p_smp = osm_madw_get_smp_ptr(p_madw);
- p_ni = (ib_node_info_t *) ib_smp_get_payload_ptr(p_smp);
-
- /*
- The node object already contains one physical port object.
- Therefore, subtract 1 from the number of physical ports
- used by the switch. This is not done for CA's since they
- need to occupy 1 more physp than they physically have since
- we still reserve room for a "port 0".
- */
- size = p_ni->num_ports;
-
- p_node = malloc(sizeof(*p_node) + sizeof(osm_physp_t) * size);
- if (!p_node)
- return NULL;
-
- memset(p_node, 0, sizeof(*p_node) + sizeof(osm_physp_t) * size);
- p_node->node_info = *p_ni;
- p_node->physp_tbl_size = size + 1;
-
- /*
- Construct Physical Port objects owned by this Node.
- Then, initialize the Physical Port through with we
- discovered this port.
- For switches, all ports have the same GUID.
- For CAs and routers, each port has a different GUID, so we only
- know the GUID for the port that responded to our
- Get(NodeInfo).
- */
- for (i = 0; i < p_node->physp_tbl_size; i++)
- osm_physp_construct(&p_node->physp_table[i]);
-
- osm_node_init_physp(p_node, p_madw);
- if (p_ni->node_type == IB_NODE_TYPE_SWITCH)
- node_init_physp0(p_node, p_madw);
- p_node->print_desc = strdup(OSM_NODE_DESC_UNKNOWN);
-
- return (p_node);
-}
-
-/**********************************************************************
- **********************************************************************/
-static void osm_node_destroy(IN osm_node_t * p_node)
-{
- uint16_t i;
-
- /*
- Cleanup all physports
- */
- for (i = 0; i < p_node->physp_tbl_size; i++)
- osm_physp_destroy(&p_node->physp_table[i]);
-
- /* cleanup printable node_desc field */
- if (p_node->print_desc) {
- free(p_node->print_desc);
- }
-}
-
-/**********************************************************************
- **********************************************************************/
-void osm_node_delete(IN OUT osm_node_t ** const p_node)
-{
- CL_ASSERT(p_node && *p_node);
- osm_node_destroy(*p_node);
- free(*p_node);
- *p_node = NULL;
-}
-
-/**********************************************************************
- **********************************************************************/
-void
-osm_node_link(IN osm_node_t * const p_node,
- IN const uint8_t port_num,
- IN osm_node_t * const p_remote_node,
- IN const uint8_t remote_port_num)
-{
- osm_physp_t *p_physp;
- osm_physp_t *p_remote_physp;
-
- CL_ASSERT(port_num < p_node->physp_tbl_size);
- CL_ASSERT(remote_port_num < p_remote_node->physp_tbl_size);
-
- p_physp = osm_node_get_physp_ptr(p_node, port_num);
- p_remote_physp = osm_node_get_physp_ptr(p_remote_node, remote_port_num);
-
- if (p_physp->p_remote_physp)
- p_physp->p_remote_physp->p_remote_physp = NULL;
- if (p_remote_physp->p_remote_physp)
- p_remote_physp->p_remote_physp->p_remote_physp = NULL;
-
- osm_physp_link(p_physp, p_remote_physp);
-}
-
-/**********************************************************************
- **********************************************************************/
-void
-osm_node_unlink(IN osm_node_t * const p_node,
- IN const uint8_t port_num,
- IN osm_node_t * const p_remote_node,
- IN const uint8_t remote_port_num)
-{
- osm_physp_t *p_physp;
- osm_physp_t *p_remote_physp;
-
- CL_ASSERT(port_num < p_node->physp_tbl_size);
- CL_ASSERT(remote_port_num < p_remote_node->physp_tbl_size);
-
- if (osm_node_link_exists(p_node, port_num,
- p_remote_node, remote_port_num)) {
-
- p_physp = osm_node_get_physp_ptr(p_node, port_num);
- p_remote_physp =
- osm_node_get_physp_ptr(p_remote_node, remote_port_num);
-
- osm_physp_unlink(p_physp, p_remote_physp);
- }
-}
-
-/**********************************************************************
- **********************************************************************/
-boolean_t
-osm_node_link_exists(IN osm_node_t * const p_node,
- IN const uint8_t port_num,
- IN osm_node_t * const p_remote_node,
- IN const uint8_t remote_port_num)
-{
- osm_physp_t *p_physp;
- osm_physp_t *p_remote_physp;
-
- CL_ASSERT(port_num < p_node->physp_tbl_size);
- CL_ASSERT(remote_port_num < p_remote_node->physp_tbl_size);
-
- p_physp = osm_node_get_physp_ptr(p_node, port_num);
- p_remote_physp = osm_node_get_physp_ptr(p_remote_node, remote_port_num);
-
- return (osm_physp_link_exists(p_physp, p_remote_physp));
-}
-
-/**********************************************************************
- **********************************************************************/
-boolean_t
-osm_node_link_has_valid_ports(IN osm_node_t * const p_node,
- IN const uint8_t port_num,
- IN osm_node_t * const p_remote_node,
- IN const uint8_t remote_port_num)
-{
- osm_physp_t *p_physp;
- osm_physp_t *p_remote_physp;
-
- CL_ASSERT(port_num < p_node->physp_tbl_size);
- CL_ASSERT(remote_port_num < p_remote_node->physp_tbl_size);
-
- p_physp = osm_node_get_physp_ptr(p_node, port_num);
- p_remote_physp = osm_node_get_physp_ptr(p_remote_node, remote_port_num);
-
- return (p_physp && p_remote_physp);
-}
-
-/**********************************************************************
- **********************************************************************/
-boolean_t
-osm_node_has_any_link(IN osm_node_t * const p_node, IN const uint8_t port_num)
-{
- osm_physp_t *p_physp;
- CL_ASSERT(port_num < p_node->physp_tbl_size);
- p_physp = osm_node_get_physp_ptr(p_node, port_num);
- return (osm_physp_has_any_link(p_physp));
-}
-
-/**********************************************************************
- **********************************************************************/
-osm_node_t *osm_node_get_remote_node(IN osm_node_t * const p_node,
- IN const uint8_t port_num,
- OUT uint8_t * p_remote_port_num)
-{
- osm_physp_t *p_physp;
- osm_physp_t *p_remote_physp;
-
- p_physp = osm_node_get_physp_ptr(p_node, port_num);
-
- if (!p_physp || !osm_physp_has_any_link(p_physp))
- return (NULL);
-
- p_remote_physp = osm_physp_get_remote(p_physp);
- if (p_remote_port_num)
- *p_remote_port_num = osm_physp_get_port_num(p_remote_physp);
-
- return (osm_physp_get_node_ptr(p_remote_physp));
-}
-
-/**********************************************************************
- The lock must be held before calling this function.
-**********************************************************************/
-ib_net16_t
-osm_node_get_remote_base_lid(IN osm_node_t * const p_node,
- IN const uint32_t port_num)
-{
- osm_physp_t *p_physp;
- osm_physp_t *p_remote_physp;
- CL_ASSERT(port_num < p_node->physp_tbl_size);
-
- p_physp = osm_node_get_physp_ptr(p_node, port_num);
- if (p_physp) {
- p_remote_physp = osm_physp_get_remote(p_physp);
- return (osm_physp_get_base_lid(p_remote_physp));
- }
-
- return (0);
-}
diff --git a/contrib/ofed/management/opensm/opensm/osm_node_desc_rcv.c b/contrib/ofed/management/opensm/opensm/osm_node_desc_rcv.c
deleted file mode 100644
index f6178b9..0000000
--- a/contrib/ofed/management/opensm/opensm/osm_node_desc_rcv.c
+++ /dev/null
@@ -1,128 +0,0 @@
-/*
- * Copyright (c) 2004-2008 Voltaire, Inc. All rights reserved.
- * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved.
- * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- */
-
-/*
- * Abstract:
- * Implementation of osm_nd_rcv_t.
- * This object represents the NodeDescription Receiver object.
- * This object is part of the opensm family of objects.
- */
-
-#if HAVE_CONFIG_H
-# include <config.h>
-#endif /* HAVE_CONFIG_H */
-
-#include <string.h>
-#include <iba/ib_types.h>
-#include <complib/cl_qmap.h>
-#include <complib/cl_passivelock.h>
-#include <complib/cl_debug.h>
-#include <opensm/osm_madw.h>
-#include <opensm/osm_log.h>
-#include <opensm/osm_node.h>
-#include <opensm/osm_opensm.h>
-#include <opensm/osm_subnet.h>
-
-/**********************************************************************
- **********************************************************************/
-static void
-__osm_nd_rcv_process_nd(IN osm_sm_t * sm,
- IN osm_node_t * const p_node,
- IN const ib_node_desc_t * const p_nd)
-{
- char *tmp_desc;
- char print_desc[IB_NODE_DESCRIPTION_SIZE + 1];
-
- OSM_LOG_ENTER(sm->p_log);
-
- memcpy(&p_node->node_desc.description, p_nd, sizeof(*p_nd));
-
- /* also set up a printable version */
- memcpy(print_desc, p_nd, sizeof(*p_nd));
- print_desc[IB_NODE_DESCRIPTION_SIZE] = '\0';
- tmp_desc = remap_node_name(sm->p_subn->p_osm->node_name_map,
- cl_ntoh64(osm_node_get_node_guid(p_node)),
- print_desc);
-
- /* make a copy for this node to "own" */
- if (p_node->print_desc)
- free(p_node->print_desc);
- p_node->print_desc = tmp_desc;
-
- OSM_LOG(sm->p_log, OSM_LOG_VERBOSE,
- "Node 0x%" PRIx64 "\n\t\t\t\tDescription = %s\n",
- cl_ntoh64(osm_node_get_node_guid(p_node)), p_node->print_desc);
-
- OSM_LOG_EXIT(sm->p_log);
-}
-
-/**********************************************************************
- **********************************************************************/
-void osm_nd_rcv_process(IN void *context, IN void *data)
-{
- osm_sm_t *sm = context;
- osm_madw_t *p_madw = data;
- ib_node_desc_t *p_nd;
- ib_smp_t *p_smp;
- osm_node_t *p_node;
- ib_net64_t node_guid;
-
- CL_ASSERT(sm);
-
- OSM_LOG_ENTER(sm->p_log);
-
- CL_ASSERT(p_madw);
-
- p_smp = osm_madw_get_smp_ptr(p_madw);
- p_nd = (ib_node_desc_t *) ib_smp_get_payload_ptr(p_smp);
-
- /*
- Acquire the node object and add the node description.
- */
-
- node_guid = osm_madw_get_nd_context_ptr(p_madw)->node_guid;
- CL_PLOCK_EXCL_ACQUIRE(sm->p_lock);
- p_node = osm_get_node_by_guid(sm->p_subn, node_guid);
- if (!p_node) {
- OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR 0B01: "
- "NodeDescription received for nonexistent node "
- "0x%" PRIx64 "\n", cl_ntoh64(node_guid));
- } else {
- __osm_nd_rcv_process_nd(sm, p_node, p_nd);
- }
-
- CL_PLOCK_RELEASE(sm->p_lock);
- OSM_LOG_EXIT(sm->p_log);
-}
diff --git a/contrib/ofed/management/opensm/opensm/osm_node_info_rcv.c b/contrib/ofed/management/opensm/opensm/osm_node_info_rcv.c
deleted file mode 100644
index c52c0d5..0000000
--- a/contrib/ofed/management/opensm/opensm/osm_node_info_rcv.c
+++ /dev/null
@@ -1,849 +0,0 @@
-/*
- * Copyright (c) 2004-2008 Voltaire, Inc. All rights reserved.
- * Copyright (c) 2002-2008 Mellanox Technologies LTD. All rights reserved.
- * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- */
-
-/*
- * Abstract:
- * Implementation of osm_ni_rcv_t.
- * This object represents the NodeInfo Receiver object.
- * This object is part of the opensm family of objects.
- */
-
-#if HAVE_CONFIG_H
-# include <config.h>
-#endif /* HAVE_CONFIG_H */
-
-#include <stdlib.h>
-#include <string.h>
-#include <iba/ib_types.h>
-#include <complib/cl_qmap.h>
-#include <complib/cl_passivelock.h>
-#include <complib/cl_debug.h>
-#include <opensm/osm_madw.h>
-#include <opensm/osm_log.h>
-#include <opensm/osm_node.h>
-#include <opensm/osm_subnet.h>
-#include <opensm/osm_router.h>
-#include <opensm/osm_mad_pool.h>
-#include <opensm/osm_helper.h>
-#include <opensm/osm_msgdef.h>
-#include <opensm/osm_opensm.h>
-#include <opensm/osm_ucast_mgr.h>
-
-static void
-report_duplicated_guid(IN osm_sm_t * sm,
- osm_physp_t * p_physp,
- osm_node_t * p_neighbor_node, const uint8_t port_num)
-{
- osm_physp_t *p_old, *p_new;
- osm_dr_path_t path;
-
- p_old = p_physp->p_remote_physp;
- p_new = osm_node_get_physp_ptr(p_neighbor_node, port_num);
-
- OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR 0D01: "
- "Found duplicated node.\n"
- "Node 0x%" PRIx64 " port %u is reachable from remote node "
- "0x%" PRIx64 " port %u and remote node 0x%" PRIx64 " port %u.\n"
- "Paths are:\n",
- cl_ntoh64(p_physp->p_node->node_info.node_guid),
- p_physp->port_num,
- cl_ntoh64(p_old->p_node->node_info.node_guid), p_old->port_num,
- cl_ntoh64(p_new->p_node->node_info.node_guid), p_new->port_num);
-
- osm_dump_dr_path(sm->p_log, osm_physp_get_dr_path_ptr(p_physp),
- OSM_LOG_ERROR);
-
- path = *osm_physp_get_dr_path_ptr(p_new);
- osm_dr_path_extend(&path, port_num);
- osm_dump_dr_path(sm->p_log, &path, OSM_LOG_ERROR);
-
- osm_log(sm->p_log, OSM_LOG_SYS,
- "FATAL: duplicated guids or 12x lane reversal\n");
-}
-
-static void requery_dup_node_info(IN osm_sm_t * sm,
- osm_physp_t * p_physp, unsigned count)
-{
- osm_madw_context_t context;
- osm_dr_path_t path;
- cl_status_t status;
-
- path = *osm_physp_get_dr_path_ptr(p_physp->p_remote_physp);
- osm_dr_path_extend(&path, p_physp->p_remote_physp->port_num);
-
- context.ni_context.node_guid =
- p_physp->p_remote_physp->p_node->node_info.port_guid;
- context.ni_context.port_num = p_physp->p_remote_physp->port_num;
- context.ni_context.dup_node_guid = p_physp->p_node->node_info.node_guid;
- context.ni_context.dup_port_num = p_physp->port_num;
- context.ni_context.dup_count = count;
-
- status = osm_req_get(sm, &path, IB_MAD_ATTR_NODE_INFO,
- 0, CL_DISP_MSGID_NONE, &context);
-
- if (status != IB_SUCCESS)
- OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR 0D02: "
- "Failure initiating NodeInfo request (%s)\n",
- ib_get_err_str(status));
-}
-
-/**********************************************************************
- The plock must be held before calling this function.
-**********************************************************************/
-static void
-__osm_ni_rcv_set_links(IN osm_sm_t * sm,
- osm_node_t * p_node,
- const uint8_t port_num,
- const osm_ni_context_t * const p_ni_context)
-{
- osm_node_t *p_neighbor_node;
- osm_physp_t *p_physp;
-
- OSM_LOG_ENTER(sm->p_log);
-
- /*
- A special case exists in which the node we're trying to
- link is our own node. In this case, the guid value in
- the ni_context will be zero.
- */
- if (p_ni_context->node_guid == 0) {
- OSM_LOG(sm->p_log, OSM_LOG_DEBUG,
- "Nothing to link for our own node 0x%" PRIx64 "\n",
- cl_ntoh64(osm_node_get_node_guid(p_node)));
- goto _exit;
- }
-
- p_neighbor_node = osm_get_node_by_guid(sm->p_subn,
- p_ni_context->node_guid);
- if (!p_neighbor_node) {
- OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR 0D10: "
- "Unexpected removal of neighbor node "
- "0x%" PRIx64 "\n", cl_ntoh64(p_ni_context->node_guid));
- goto _exit;
- }
-
- /*
- We have seen this neighbor node before, but we might
- not have seen this port on the neighbor node before.
- We should not set links to an uninitialized port on the
- neighbor, so check validity up front. If it's not
- valid, do nothing, since we'll see this link again
- when we probe the neighbor.
- */
- if (!osm_node_link_has_valid_ports(p_node, port_num,
- p_neighbor_node,
- p_ni_context->port_num))
- goto _exit;
-
- if (osm_node_link_exists(p_node, port_num,
- p_neighbor_node, p_ni_context->port_num)) {
- OSM_LOG(sm->p_log, OSM_LOG_DEBUG, "Link already exists\n");
- goto _exit;
- }
-
- if (osm_node_has_any_link(p_node, port_num) &&
- sm->p_subn->force_heavy_sweep == FALSE &&
- (!p_ni_context->dup_count ||
- (p_ni_context->dup_node_guid == osm_node_get_node_guid(p_node) &&
- p_ni_context->dup_port_num == port_num))) {
- /*
- Uh oh...
- This could be reconnected ports, but also duplicated GUID
- (2 nodes have the same guid) or a 12x link with lane reversal
- that is not configured correctly.
- We will try to recover by querying NodeInfo again.
- In order to catch even fast port moving to new location(s) and
- back we will count up to 5.
- Some crazy reconnections (newly created switch loop right before
- targeted CA) will not be catched this way. So in worst case -
- report GUID duplication and request new discovery.
- When switch node is targeted NodeInfo querying will be done in
- opposite order, this is much stronger check, unfortunately it is
- impossible with CAs.
- */
- p_physp = osm_node_get_physp_ptr(p_node, port_num);
- if (p_ni_context->dup_count > 5) {
- report_duplicated_guid(sm, p_physp,
- p_neighbor_node,
- p_ni_context->port_num);
- sm->p_subn->force_heavy_sweep = TRUE;
- } else if (p_node->sw)
- requery_dup_node_info(sm, p_physp->p_remote_physp,
- p_ni_context->dup_count + 1);
- else
- requery_dup_node_info(sm, p_physp,
- p_ni_context->dup_count + 1);
- }
-
- /*
- When there are only two nodes with exact same guids (connected back
- to back) - the previous check for duplicated guid will not catch
- them. But the link will be from the port to itself...
- Enhanced Port 0 is an exception to this
- */
- if ((osm_node_get_node_guid(p_node) == p_ni_context->node_guid) &&
- (port_num == p_ni_context->port_num) &&
- port_num != 0 && cl_qmap_count(&sm->p_subn->sw_guid_tbl) == 0) {
- OSM_LOG(sm->p_log, OSM_LOG_VERBOSE,
- "Duplicate GUID found by link from a port to itself:"
- "node 0x%" PRIx64 ", port number %u\n",
- cl_ntoh64(osm_node_get_node_guid(p_node)), port_num);
- p_physp = osm_node_get_physp_ptr(p_node, port_num);
- osm_dump_dr_path(sm->p_log,
- osm_physp_get_dr_path_ptr(p_physp),
- OSM_LOG_VERBOSE);
-
- if (sm->p_subn->opt.exit_on_fatal == TRUE) {
- osm_log(sm->p_log, OSM_LOG_SYS,
- "Errors on subnet. Duplicate GUID found "
- "by link from a port to itself. "
- "See verbose opensm.log for more details\n");
- exit(1);
- }
- }
-
- OSM_LOG(sm->p_log, OSM_LOG_DEBUG,
- "Creating new link between:\n\t\t\t\tnode 0x%" PRIx64
- ", port number %u and\n\t\t\t\tnode 0x%" PRIx64
- ", port number %u\n",
- cl_ntoh64(osm_node_get_node_guid(p_node)), port_num,
- cl_ntoh64(p_ni_context->node_guid), p_ni_context->port_num);
-
- if (sm->ucast_mgr.cache_valid)
- osm_ucast_cache_check_new_link(&sm->ucast_mgr,
- p_node, port_num,
- p_neighbor_node,
- p_ni_context->port_num);
-
- osm_node_link(p_node, port_num, p_neighbor_node,
- p_ni_context->port_num);
-
-_exit:
- OSM_LOG_EXIT(sm->p_log);
-}
-
-/**********************************************************************
- The plock must be held before calling this function.
-**********************************************************************/
-static void
-__osm_ni_rcv_process_new_node(IN osm_sm_t * sm,
- IN osm_node_t * const p_node,
- IN const osm_madw_t * const p_madw)
-{
- ib_api_status_t status = IB_SUCCESS;
- osm_madw_context_t context;
- osm_physp_t *p_physp;
- ib_node_info_t *p_ni;
- ib_smp_t *p_smp;
- uint8_t port_num;
-
- OSM_LOG_ENTER(sm->p_log);
-
- p_smp = osm_madw_get_smp_ptr(p_madw);
- p_ni = (ib_node_info_t *) ib_smp_get_payload_ptr(p_smp);
- port_num = ib_node_info_get_local_port_num(p_ni);
-
- /*
- Request PortInfo & NodeDescription attributes for the port
- that responded to the NodeInfo attribute.
- Because this is a channel adapter or router, we are
- not allowed to request PortInfo for the other ports.
- Set the context union properly, so the recipient
- knows which node & port are relevant.
- */
- p_physp = osm_node_get_physp_ptr(p_node, port_num);
-
- context.pi_context.node_guid = p_ni->node_guid;
- context.pi_context.port_guid = p_ni->port_guid;
- context.pi_context.set_method = FALSE;
- context.pi_context.light_sweep = FALSE;
- context.pi_context.active_transition = FALSE;
-
- status = osm_req_get(sm, osm_physp_get_dr_path_ptr(p_physp),
- IB_MAD_ATTR_PORT_INFO,
- cl_hton32(port_num), CL_DISP_MSGID_NONE, &context);
- if (status != IB_SUCCESS)
- OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR 0D02: "
- "Failure initiating PortInfo request (%s)\n",
- ib_get_err_str(status));
-
- OSM_LOG_EXIT(sm->p_log);
-}
-
-/**********************************************************************
- The plock must be held before calling this function.
-**********************************************************************/
-void
-osm_req_get_node_desc(IN osm_sm_t * sm,
- osm_physp_t *p_physp)
-{
- ib_api_status_t status = IB_SUCCESS;
- osm_madw_context_t context;
-
- OSM_LOG_ENTER(sm->p_log);
-
- context.nd_context.node_guid =
- osm_node_get_node_guid(osm_physp_get_node_ptr(p_physp));
-
- status = osm_req_get(sm, osm_physp_get_dr_path_ptr(p_physp),
- IB_MAD_ATTR_NODE_DESC,
- 0, CL_DISP_MSGID_NONE, &context);
- if (status != IB_SUCCESS)
- OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR 0D03: "
- "Failure initiating NodeDescription request (%s)\n",
- ib_get_err_str(status));
-
- OSM_LOG_EXIT(sm->p_log);
-}
-
-/**********************************************************************
- The plock must be held before calling this function.
-**********************************************************************/
-static void
-__osm_ni_rcv_get_node_desc(IN osm_sm_t * sm,
- IN osm_node_t * const p_node,
- IN const osm_madw_t * const p_madw)
-{
- ib_node_info_t *p_ni;
- ib_smp_t *p_smp;
- uint8_t port_num;
- osm_physp_t *p_physp = NULL;
-
- OSM_LOG_ENTER(sm->p_log);
-
- p_smp = osm_madw_get_smp_ptr(p_madw);
- p_ni = (ib_node_info_t *) ib_smp_get_payload_ptr(p_smp);
- port_num = ib_node_info_get_local_port_num(p_ni);
-
- /*
- Request PortInfo & NodeDescription attributes for the port
- that responded to the NodeInfo attribute.
- Because this is a channel adapter or router, we are
- not allowed to request PortInfo for the other ports.
- Set the context union properly, so the recipient
- knows which node & port are relevant.
- */
- p_physp = osm_node_get_physp_ptr(p_node, port_num);
-
- osm_req_get_node_desc(sm, p_physp);
-
- OSM_LOG_EXIT(sm->p_log);
-}
-
-/**********************************************************************
- The plock must be held before calling this function.
-**********************************************************************/
-static void
-__osm_ni_rcv_process_new_ca_or_router(IN osm_sm_t * sm,
- IN osm_node_t * const p_node,
- IN const osm_madw_t * const p_madw)
-{
- OSM_LOG_ENTER(sm->p_log);
-
- __osm_ni_rcv_process_new_node(sm, p_node, p_madw);
-
- /*
- A node guid of 0 is the corner case that indicates
- we discovered our own node. Initialize the subnet
- object with the SM's own port guid.
- */
- if (osm_madw_get_ni_context_ptr(p_madw)->node_guid == 0)
- sm->p_subn->sm_port_guid = p_node->node_info.port_guid;
-
- OSM_LOG_EXIT(sm->p_log);
-}
-
-/**********************************************************************
- The plock must be held before calling this function.
-**********************************************************************/
-static void
-__osm_ni_rcv_process_existing_ca_or_router(IN osm_sm_t * sm,
- IN osm_node_t * const p_node,
- IN const osm_madw_t * const p_madw)
-{
- ib_node_info_t *p_ni;
- ib_smp_t *p_smp;
- osm_port_t *p_port;
- osm_port_t *p_port_check;
- osm_madw_context_t context;
- uint8_t port_num;
- osm_physp_t *p_physp;
- ib_api_status_t status;
- osm_dr_path_t *p_dr_path;
- osm_bind_handle_t h_bind;
-
- OSM_LOG_ENTER(sm->p_log);
-
- p_smp = osm_madw_get_smp_ptr(p_madw);
- p_ni = (ib_node_info_t *) ib_smp_get_payload_ptr(p_smp);
- port_num = ib_node_info_get_local_port_num(p_ni);
- h_bind = osm_madw_get_bind_handle(p_madw);
-
- /*
- Determine if we have encountered this node through a
- previously undiscovered port. If so, build the new
- port object.
- */
- p_port = osm_get_port_by_guid(sm->p_subn, p_ni->port_guid);
- if (!p_port) {
- OSM_LOG(sm->p_log, OSM_LOG_VERBOSE,
- "Creating new port object with GUID 0x%" PRIx64 "\n",
- cl_ntoh64(p_ni->port_guid));
-
- osm_node_init_physp(p_node, p_madw);
-
- p_port = osm_port_new(p_ni, p_node);
- if (p_port == NULL) {
- OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR 0D04: "
- "Unable to create new port object\n");
- goto Exit;
- }
-
- /*
- Add the new port object to the database.
- */
- p_port_check =
- (osm_port_t *) cl_qmap_insert(&sm->p_subn->port_guid_tbl,
- p_ni->port_guid,
- &p_port->map_item);
- if (p_port_check != p_port) {
- /*
- We should never be here!
- Somehow, this port GUID already exists in the table.
- */
- OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR 0D12: "
- "Port 0x%" PRIx64 " already in the database!\n",
- cl_ntoh64(p_ni->port_guid));
-
- osm_port_delete(&p_port);
- goto Exit;
- }
-
- /* If we are a master, then this means the port is new on the subnet.
- Mark it as new - need to send trap 64 on these ports.
- The condition that we are master is true, since if we are in discovering
- state (meaning we woke up from standby or we are just initializing),
- then these ports may be new to us, but are not new on the subnet.
- If we are master, then the subnet as we know it is the updated one,
- and any new ports we encounter should cause trap 64. C14-72.1.1 */
- if (sm->p_subn->sm_state == IB_SMINFO_STATE_MASTER)
- p_port->is_new = 1;
-
- p_physp = osm_node_get_physp_ptr(p_node, port_num);
- } else {
- p_physp = osm_node_get_physp_ptr(p_node, port_num);
- /*
- Update the DR Path to the port,
- in case the old one is no longer available.
- */
- p_dr_path = osm_physp_get_dr_path_ptr(p_physp);
-
- osm_dr_path_init(p_dr_path, h_bind, p_smp->hop_count,
- p_smp->initial_path);
- }
-
- context.pi_context.node_guid = p_ni->node_guid;
- context.pi_context.port_guid = p_ni->port_guid;
- context.pi_context.set_method = FALSE;
- context.pi_context.light_sweep = FALSE;
-
- status = osm_req_get(sm, osm_physp_get_dr_path_ptr(p_physp),
- IB_MAD_ATTR_PORT_INFO,
- cl_hton32(port_num), CL_DISP_MSGID_NONE, &context);
-
- if (status != IB_SUCCESS)
- OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR 0D13: "
- "Failure initiating PortInfo request (%s)\n",
- ib_get_err_str(status));
-
-Exit:
- OSM_LOG_EXIT(sm->p_log);
-}
-
-/**********************************************************************
- **********************************************************************/
-static void
-__osm_ni_rcv_process_switch(IN osm_sm_t * sm,
- IN osm_node_t * const p_node,
- IN const osm_madw_t * const p_madw)
-{
- ib_api_status_t status = IB_SUCCESS;
- osm_madw_context_t context;
- osm_dr_path_t *path;
- ib_smp_t *p_smp;
-
- OSM_LOG_ENTER(sm->p_log);
-
- p_smp = osm_madw_get_smp_ptr(p_madw);
-
- /* update DR path of already initialized switch port 0 */
- path = osm_physp_get_dr_path_ptr(osm_node_get_physp_ptr(p_node, 0));
- osm_dr_path_init(path, osm_madw_get_bind_handle(p_madw),
- p_smp->hop_count, p_smp->initial_path);
-
- context.si_context.node_guid = osm_node_get_node_guid(p_node);
- context.si_context.set_method = FALSE;
- context.si_context.light_sweep = FALSE;
-
- /* Request a SwitchInfo attribute */
- status = osm_req_get(sm, path, IB_MAD_ATTR_SWITCH_INFO,
- 0, CL_DISP_MSGID_NONE, &context);
- if (status != IB_SUCCESS)
- /* continue despite error */
- OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR 0D06: "
- "Failure initiating SwitchInfo request (%s)\n",
- ib_get_err_str(status));
-
- OSM_LOG_EXIT(sm->p_log);
-}
-
-/**********************************************************************
- The plock must be held before calling this function.
-**********************************************************************/
-static void
-__osm_ni_rcv_process_existing_switch(IN osm_sm_t * sm,
- IN osm_node_t * const p_node,
- IN const osm_madw_t * const p_madw)
-{
- OSM_LOG_ENTER(sm->p_log);
-
- /*
- If this switch has already been probed during this sweep,
- then don't bother reprobing it.
- There is one exception - if the node has been visited, but
- for some reason we don't have the switch object (this can happen
- if the SwitchInfo mad didn't reach the SM) then we want
- to retry to probe the switch.
- */
- if (p_node->discovery_count == 1)
- __osm_ni_rcv_process_switch(sm, p_node, p_madw);
- else if (!p_node->sw || p_node->sw->discovery_count == 0) {
- /* we don't have the SwitchInfo - retry to get it */
- OSM_LOG(sm->p_log, OSM_LOG_DEBUG,
- "Retry to get SwitchInfo on node GUID:0x%"
- PRIx64 "\n", cl_ntoh64(osm_node_get_node_guid(p_node)));
- __osm_ni_rcv_process_switch(sm, p_node, p_madw);
- }
-
- OSM_LOG_EXIT(sm->p_log);
-}
-
-/**********************************************************************
- The plock must be held before calling this function.
-**********************************************************************/
-static void
-__osm_ni_rcv_process_new_switch(IN osm_sm_t * sm,
- IN osm_node_t * const p_node,
- IN const osm_madw_t * const p_madw)
-{
- OSM_LOG_ENTER(sm->p_log);
-
- __osm_ni_rcv_process_switch(sm, p_node, p_madw);
-
- /*
- A node guid of 0 is the corner case that indicates
- we discovered our own node. Initialize the subnet
- object with the SM's own port guid.
- */
- if (osm_madw_get_ni_context_ptr(p_madw)->node_guid == 0)
- sm->p_subn->sm_port_guid = p_node->node_info.port_guid;
-
- OSM_LOG_EXIT(sm->p_log);
-}
-
-/**********************************************************************
- The plock must NOT be held before calling this function.
-**********************************************************************/
-static void
-__osm_ni_rcv_process_new(IN osm_sm_t * sm,
- IN const osm_madw_t * const p_madw)
-{
- osm_node_t *p_node;
- osm_node_t *p_node_check;
- osm_port_t *p_port;
- osm_port_t *p_port_check;
- osm_router_t *p_rtr = NULL;
- osm_router_t *p_rtr_check;
- cl_qmap_t *p_rtr_guid_tbl;
- ib_node_info_t *p_ni;
- ib_smp_t *p_smp;
- osm_ni_context_t *p_ni_context;
- uint8_t port_num;
-
- OSM_LOG_ENTER(sm->p_log);
-
- p_smp = osm_madw_get_smp_ptr(p_madw);
- p_ni = (ib_node_info_t *) ib_smp_get_payload_ptr(p_smp);
- p_ni_context = osm_madw_get_ni_context_ptr(p_madw);
- port_num = ib_node_info_get_local_port_num(p_ni);
-
- osm_dump_smp_dr_path(sm->p_log, p_smp, OSM_LOG_VERBOSE);
-
- OSM_LOG(sm->p_log, OSM_LOG_VERBOSE,
- "Discovered new %s node,"
- "\n\t\t\t\tGUID 0x%" PRIx64 ", TID 0x%" PRIx64 "\n",
- ib_get_node_type_str(p_ni->node_type),
- cl_ntoh64(p_ni->node_guid), cl_ntoh64(p_smp->trans_id));
-
- p_node = osm_node_new(p_madw);
- if (p_node == NULL) {
- OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR 0D07: "
- "Unable to create new node object\n");
- goto Exit;
- }
-
- /*
- Create a new port object to represent this node's physical
- ports in the port table.
- */
- p_port = osm_port_new(p_ni, p_node);
- if (p_port == NULL) {
- OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR 0D14: "
- "Unable to create new port object\n");
- osm_node_delete(&p_node);
- goto Exit;
- }
-
- /*
- Add the new port object to the database.
- */
- p_port_check =
- (osm_port_t *) cl_qmap_insert(&sm->p_subn->port_guid_tbl,
- p_ni->port_guid, &p_port->map_item);
- if (p_port_check != p_port) {
- /*
- We should never be here!
- Somehow, this port GUID already exists in the table.
- */
- OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR 0D15: "
- "Duplicate Port GUID 0x%" PRIx64
- "! Found by the two directed routes:\n",
- cl_ntoh64(p_ni->port_guid));
- osm_dump_dr_path(sm->p_log,
- osm_physp_get_dr_path_ptr(p_port->p_physp),
- OSM_LOG_ERROR);
- osm_dump_dr_path(sm->p_log,
- osm_physp_get_dr_path_ptr(p_port_check->
- p_physp),
- OSM_LOG_ERROR);
- osm_port_delete(&p_port);
- osm_node_delete(&p_node);
- goto Exit;
- }
-
- /* If we are a master, then this means the port is new on the subnet.
- Mark it as new - need to send trap 64 on these ports.
- The condition that we are master is true, since if we are in discovering
- state (meaning we woke up from standby or we are just initializing),
- then these ports may be new to us, but are not new on the subnet.
- If we are master, then the subnet as we know it is the updated one,
- and any new ports we encounter should cause trap 64. C14-72.1.1 */
- if (sm->p_subn->sm_state == IB_SMINFO_STATE_MASTER)
- p_port->is_new = 1;
-
- /* If there were RouterInfo or other router attribute,
- this would be elsewhere */
- if (p_ni->node_type == IB_NODE_TYPE_ROUTER) {
- if ((p_rtr = osm_router_new(p_port)) == NULL)
- OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR 0D1A: "
- "Unable to create new router object\n");
- else {
- p_rtr_guid_tbl = &sm->p_subn->rtr_guid_tbl;
- p_rtr_check =
- (osm_router_t *) cl_qmap_insert(p_rtr_guid_tbl,
- p_ni->port_guid,
- &p_rtr->map_item);
- if (p_rtr_check != p_rtr)
- OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR 0D1B: "
- "Unable to add port GUID:0x%016" PRIx64
- " to router table\n",
- cl_ntoh64(p_ni->port_guid));
- }
- }
-
- p_node_check =
- (osm_node_t *) cl_qmap_insert(&sm->p_subn->node_guid_tbl,
- p_ni->node_guid, &p_node->map_item);
- if (p_node_check != p_node) {
- /*
- This node must have been inserted by another thread.
- This is unexpected, but is not an error.
- We can simply clean-up, since the other thread will
- see this processing through to completion.
- */
- OSM_LOG(sm->p_log, OSM_LOG_VERBOSE,
- "Discovery race detected at node 0x%" PRIx64 "\n",
- cl_ntoh64(p_ni->node_guid));
- osm_node_delete(&p_node);
- p_node = p_node_check;
- __osm_ni_rcv_set_links(sm, p_node, port_num, p_ni_context);
- goto Exit;
- } else
- __osm_ni_rcv_set_links(sm, p_node, port_num, p_ni_context);
-
- p_node->discovery_count++;
- __osm_ni_rcv_get_node_desc(sm, p_node, p_madw);
-
- switch (p_ni->node_type) {
- case IB_NODE_TYPE_CA:
- case IB_NODE_TYPE_ROUTER:
- __osm_ni_rcv_process_new_ca_or_router(sm, p_node, p_madw);
- break;
- case IB_NODE_TYPE_SWITCH:
- __osm_ni_rcv_process_new_switch(sm, p_node, p_madw);
- break;
- default:
- OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR 0D16: "
- "Unknown node type %u with GUID 0x%" PRIx64 "\n",
- p_ni->node_type, cl_ntoh64(p_ni->node_guid));
- break;
- }
-
-Exit:
- OSM_LOG_EXIT(sm->p_log);
-}
-
-/**********************************************************************
- The plock must be held before calling this function.
-**********************************************************************/
-static void
-__osm_ni_rcv_process_existing(IN osm_sm_t * sm,
- IN osm_node_t * const p_node,
- IN const osm_madw_t * const p_madw)
-{
- ib_node_info_t *p_ni;
- ib_smp_t *p_smp;
- osm_ni_context_t *p_ni_context;
- uint8_t port_num;
-
- OSM_LOG_ENTER(sm->p_log);
-
- p_smp = osm_madw_get_smp_ptr(p_madw);
- p_ni = (ib_node_info_t *) ib_smp_get_payload_ptr(p_smp);
- p_ni_context = osm_madw_get_ni_context_ptr(p_madw);
- port_num = ib_node_info_get_local_port_num(p_ni);
-
- OSM_LOG(sm->p_log, OSM_LOG_VERBOSE,
- "Rediscovered %s node 0x%" PRIx64 " TID 0x%" PRIx64
- ", discovered %u times already\n",
- ib_get_node_type_str(p_ni->node_type),
- cl_ntoh64(p_ni->node_guid),
- cl_ntoh64(p_smp->trans_id), p_node->discovery_count);
-
- /*
- If we haven't already encountered this existing node
- on this particular sweep, then process further.
- */
- p_node->discovery_count++;
-
- switch (p_ni->node_type) {
- case IB_NODE_TYPE_CA:
- case IB_NODE_TYPE_ROUTER:
- __osm_ni_rcv_process_existing_ca_or_router(sm, p_node,
- p_madw);
- break;
-
- case IB_NODE_TYPE_SWITCH:
- __osm_ni_rcv_process_existing_switch(sm, p_node, p_madw);
- break;
-
- default:
- OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR 0D09: "
- "Unknown node type %u with GUID 0x%" PRIx64 "\n",
- p_ni->node_type, cl_ntoh64(p_ni->node_guid));
- break;
- }
-
- __osm_ni_rcv_set_links(sm, p_node, port_num, p_ni_context);
-
- OSM_LOG_EXIT(sm->p_log);
-}
-
-/**********************************************************************
- **********************************************************************/
-void osm_ni_rcv_process(IN void *context, IN void *data)
-{
- osm_sm_t *sm = context;
- osm_madw_t *p_madw = data;
- ib_node_info_t *p_ni;
- ib_smp_t *p_smp;
- osm_node_t *p_node;
-
- CL_ASSERT(sm);
-
- OSM_LOG_ENTER(sm->p_log);
-
- CL_ASSERT(p_madw);
-
- p_smp = osm_madw_get_smp_ptr(p_madw);
- p_ni = (ib_node_info_t *) ib_smp_get_payload_ptr(p_smp);
-
- CL_ASSERT(p_smp->attr_id == IB_MAD_ATTR_NODE_INFO);
-
- if (p_ni->node_guid == 0) {
- OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR 0D16: "
- "Got Zero Node GUID! Found on the directed route:\n");
- osm_dump_smp_dr_path(sm->p_log, p_smp, OSM_LOG_ERROR);
- goto Exit;
- }
-
- if (p_ni->port_guid == 0) {
- OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR 0D17: "
- "Got Zero Port GUID! Found on the directed route:\n");
- osm_dump_smp_dr_path(sm->p_log, p_smp, OSM_LOG_ERROR);
- goto Exit;
- }
-
- /*
- Determine if this node has already been discovered,
- and process accordingly.
- During processing of this node, hold the shared lock.
- */
-
- CL_PLOCK_EXCL_ACQUIRE(sm->p_lock);
- p_node = osm_get_node_by_guid(sm->p_subn, p_ni->node_guid);
-
- osm_dump_node_info(sm->p_log, p_ni, OSM_LOG_DEBUG);
-
- if (!p_node)
- __osm_ni_rcv_process_new(sm, p_madw);
- else
- __osm_ni_rcv_process_existing(sm, p_node, p_madw);
-
- CL_PLOCK_RELEASE(sm->p_lock);
-
-Exit:
- OSM_LOG_EXIT(sm->p_log);
-}
diff --git a/contrib/ofed/management/opensm/opensm/osm_opensm.c b/contrib/ofed/management/opensm/opensm/osm_opensm.c
deleted file mode 100644
index 7de2e5b..0000000
--- a/contrib/ofed/management/opensm/opensm/osm_opensm.c
+++ /dev/null
@@ -1,497 +0,0 @@
-/*
- * Copyright (c) 2004-2008 Voltaire, Inc. All rights reserved.
- * Copyright (c) 2002-2006 Mellanox Technologies LTD. All rights reserved.
- * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- */
-
-/*
- * Abstract:
- * Implementation of osm_opensm_t.
- * This object represents the opensm super object.
- * This object is part of the opensm family of objects.
- */
-
-#if HAVE_CONFIG_H
-# include <config.h>
-#endif /* HAVE_CONFIG_H */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <complib/cl_dispatcher.h>
-#include <complib/cl_passivelock.h>
-#include <vendor/osm_vendor_api.h>
-#include <opensm/osm_version.h>
-#include <opensm/osm_base.h>
-#include <opensm/osm_opensm.h>
-#include <opensm/osm_log.h>
-#include <opensm/osm_subnet.h>
-#include <opensm/osm_sm.h>
-#include <opensm/osm_vl15intf.h>
-#include <opensm/osm_event_plugin.h>
-
-struct routing_engine_module {
- const char *name;
- int (*setup) (struct osm_routing_engine *, osm_opensm_t *);
-};
-
-extern int osm_ucast_minhop_setup(struct osm_routing_engine *, osm_opensm_t *);
-extern int osm_ucast_updn_setup(struct osm_routing_engine *, osm_opensm_t *);
-extern int osm_ucast_file_setup(struct osm_routing_engine *, osm_opensm_t *);
-extern int osm_ucast_ftree_setup(struct osm_routing_engine *, osm_opensm_t *);
-extern int osm_ucast_lash_setup(struct osm_routing_engine *, osm_opensm_t *);
-extern int osm_ucast_dor_setup(struct osm_routing_engine *, osm_opensm_t *);
-
-const static struct routing_engine_module routing_modules[] = {
- {"minhop", osm_ucast_minhop_setup},
- {"updn", osm_ucast_updn_setup},
- {"file", osm_ucast_file_setup},
- {"ftree", osm_ucast_ftree_setup},
- {"lash", osm_ucast_lash_setup},
- {"dor", osm_ucast_dor_setup},
- {NULL, NULL}
-};
-
-/**********************************************************************
- **********************************************************************/
-const char *osm_routing_engine_type_str(IN osm_routing_engine_type_t type)
-{
- switch (type) {
- case OSM_ROUTING_ENGINE_TYPE_NONE:
- return "none";
- case OSM_ROUTING_ENGINE_TYPE_MINHOP:
- return "minhop";
- case OSM_ROUTING_ENGINE_TYPE_UPDN:
- return "updn";
- case OSM_ROUTING_ENGINE_TYPE_FILE:
- return "file";
- case OSM_ROUTING_ENGINE_TYPE_FTREE:
- return "ftree";
- case OSM_ROUTING_ENGINE_TYPE_LASH:
- return "lash";
- case OSM_ROUTING_ENGINE_TYPE_DOR:
- return "dor";
- default:
- break;
- }
- return "unknown";
-}
-
-/**********************************************************************
- **********************************************************************/
-osm_routing_engine_type_t osm_routing_engine_type(IN const char *str)
-{
- /* For legacy reasons, consider a NULL pointer and the string
- * "null" as the minhop routing engine.
- */
- if (!str || !strcasecmp(str, "null")
- || !strcasecmp(str, "minhop"))
- return OSM_ROUTING_ENGINE_TYPE_MINHOP;
- else if (!strcasecmp(str, "none"))
- return OSM_ROUTING_ENGINE_TYPE_NONE;
- else if (!strcasecmp(str, "updn"))
- return OSM_ROUTING_ENGINE_TYPE_UPDN;
- else if (!strcasecmp(str, "file"))
- return OSM_ROUTING_ENGINE_TYPE_FILE;
- else if (!strcasecmp(str, "ftree"))
- return OSM_ROUTING_ENGINE_TYPE_FTREE;
- else if (!strcasecmp(str, "lash"))
- return OSM_ROUTING_ENGINE_TYPE_LASH;
- else if (!strcasecmp(str, "dor"))
- return OSM_ROUTING_ENGINE_TYPE_DOR;
- else
- return OSM_ROUTING_ENGINE_TYPE_UNKNOWN;
-}
-
-/**********************************************************************
- **********************************************************************/
-static void append_routing_engine(osm_opensm_t *osm,
- struct osm_routing_engine *routing_engine)
-{
- struct osm_routing_engine *r;
-
- routing_engine->next = NULL;
-
- if (!osm->routing_engine_list) {
- osm->routing_engine_list = routing_engine;
- return;
- }
-
- r = osm->routing_engine_list;
- while (r->next)
- r = r->next;
-
- r->next = routing_engine;
-}
-
-static void setup_routing_engine(osm_opensm_t *osm, const char *name)
-{
- struct osm_routing_engine *re;
- const struct routing_engine_module *m;
-
- for (m = routing_modules; m->name && *m->name; m++) {
- if (!strcmp(m->name, name)) {
- re = malloc(sizeof(struct osm_routing_engine));
- if (!re) {
- OSM_LOG(&osm->log, OSM_LOG_VERBOSE,
- "memory allocation failed\n");
- return;
- }
- memset(re, 0, sizeof(struct osm_routing_engine));
-
- re->name = m->name;
- if (m->setup(re, osm)) {
- OSM_LOG(&osm->log, OSM_LOG_VERBOSE,
- "setup of routing"
- " engine \'%s\' failed\n", name);
- return;
- }
- OSM_LOG(&osm->log, OSM_LOG_DEBUG,
- "\'%s\' routing engine set up\n", re->name);
- append_routing_engine(osm, re);
- return;
- }
- }
-
- OSM_LOG(&osm->log, OSM_LOG_ERROR,
- "cannot find or setup routing engine \'%s\'", name);
-}
-
-static void setup_routing_engines(osm_opensm_t *osm, const char *engine_names)
-{
- char *name, *str, *p;
-
- if (!engine_names || !*engine_names) {
- setup_routing_engine(osm, "minhop");
- return;
- }
-
- str = strdup(engine_names);
- name = strtok_r(str, ", \t\n", &p);
- while (name && *name) {
- setup_routing_engine(osm, name);
- name = strtok_r(NULL, ", \t\n", &p);
- }
- free(str);
-
- if (!osm->routing_engine_list)
- setup_routing_engine(osm, "minhop");
-}
-
-/**********************************************************************
- **********************************************************************/
-void osm_opensm_construct(IN osm_opensm_t * const p_osm)
-{
- memset(p_osm, 0, sizeof(*p_osm));
- p_osm->osm_version = OSM_VERSION;
- osm_subn_construct(&p_osm->subn);
- osm_sm_construct(&p_osm->sm);
- osm_sa_construct(&p_osm->sa);
- osm_db_construct(&p_osm->db);
- osm_mad_pool_construct(&p_osm->mad_pool);
- osm_vl15_construct(&p_osm->vl15);
- osm_log_construct(&p_osm->log);
-}
-
-/**********************************************************************
- **********************************************************************/
-static void destroy_routing_engines(osm_opensm_t *osm)
-{
- struct osm_routing_engine *r, *next;
-
- next = osm->routing_engine_list;
- while (next) {
- r = next;
- next = r->next;
- if (r->delete)
- r->delete(r->context);
- free(r);
- }
-}
-
-/**********************************************************************
- **********************************************************************/
-static void destroy_plugins(osm_opensm_t *osm)
-{
- osm_epi_plugin_t *p;
- /* remove from the list, and destroy it */
- while (!cl_is_qlist_empty(&osm->plugin_list)){
- p = (osm_epi_plugin_t *)cl_qlist_remove_head(&osm->plugin_list);
- /* plugin is responsible for freeing its own resources */
- osm_epi_destroy(p);
- }
-}
-
-void osm_opensm_destroy(IN osm_opensm_t * const p_osm)
-{
- /* in case of shutdown through exit proc - no ^C */
- osm_exit_flag = TRUE;
-
- /*
- * First of all, clear the is_sm bit.
- */
- if (p_osm->sm.mad_ctrl.h_bind)
- osm_vendor_set_sm(p_osm->sm.mad_ctrl.h_bind, FALSE);
-
-#ifdef ENABLE_OSM_PERF_MGR
- /* Shutdown the PerfMgr */
- osm_perfmgr_shutdown(&p_osm->perfmgr);
-#endif /* ENABLE_OSM_PERF_MGR */
-
- /* shut down the SA
- * - unbind from QP1 messages
- */
- osm_sa_shutdown(&p_osm->sa);
-
- /* shut down the SM
- * - make sure the SM sweeper thread exited
- * - unbind from QP0 messages
- */
- osm_sm_shutdown(&p_osm->sm);
-
- /* cleanup all messages on VL15 fifo that were not sent yet */
- osm_vl15_shutdown(&p_osm->vl15, &p_osm->mad_pool);
-
- /* shut down the dispatcher - so no new messages cross */
- cl_disp_shutdown(&p_osm->disp);
-
- /* dump SA DB */
- osm_sa_db_file_dump(p_osm);
-
- /* do the destruction in reverse order as init */
- destroy_plugins(p_osm);
- destroy_routing_engines(p_osm);
- osm_sa_destroy(&p_osm->sa);
- osm_sm_destroy(&p_osm->sm);
-#ifdef ENABLE_OSM_PERF_MGR
- osm_perfmgr_destroy(&p_osm->perfmgr);
-#endif /* ENABLE_OSM_PERF_MGR */
- osm_db_destroy(&p_osm->db);
- osm_vl15_destroy(&p_osm->vl15, &p_osm->mad_pool);
- osm_mad_pool_destroy(&p_osm->mad_pool);
- osm_vendor_delete(&p_osm->p_vendor);
- osm_subn_destroy(&p_osm->subn);
- cl_disp_destroy(&p_osm->disp);
-#ifdef HAVE_LIBPTHREAD
- pthread_cond_destroy(&p_osm->stats.cond);
- pthread_mutex_destroy(&p_osm->stats.mutex);
-#else
- cl_event_destroy(&p_osm->stats.event);
-#endif
- close_node_name_map(p_osm->node_name_map);
-
- cl_plock_destroy(&p_osm->lock);
-
- osm_log_destroy(&p_osm->log);
-}
-
-static void load_plugins(osm_opensm_t *osm, const char *plugin_names)
-{
- osm_epi_plugin_t *epi;
- char *p_names, *name, *p;
-
- p_names = strdup(plugin_names);
- name = strtok_r(p_names, " \t\n", &p);
- while (name && *name) {
- epi = osm_epi_construct(osm, name);
- if (!epi)
- osm_log(&osm->log, OSM_LOG_ERROR,
- "cannot load plugin \'%s\'\n", name);
- else
- cl_qlist_insert_tail(&osm->plugin_list, &epi->list);
- name = strtok_r(NULL, " \t\n", &p);
- }
- free(p_names);
-}
-
-/**********************************************************************
- **********************************************************************/
-ib_api_status_t
-osm_opensm_init(IN osm_opensm_t * const p_osm,
- IN const osm_subn_opt_t * const p_opt)
-{
- ib_api_status_t status;
-
- /* Can't use log macros here, since we're initializing the log */
- osm_opensm_construct(p_osm);
-
- if (p_opt->daemon)
- p_osm->log.daemon = 1;
-
- status = osm_log_init_v2(&p_osm->log, p_opt->force_log_flush,
- p_opt->log_flags, p_opt->log_file,
- p_opt->log_max_size, p_opt->accum_log_file);
- if (status != IB_SUCCESS)
- return (status);
-
- /* If there is a log level defined - add the OSM_VERSION to it */
- osm_log(&p_osm->log,
- osm_log_get_level(&p_osm->log) & (OSM_LOG_SYS ^ 0xFF), "%s\n",
- p_osm->osm_version);
- /* Write the OSM_VERSION to the SYS_LOG */
- osm_log(&p_osm->log, OSM_LOG_SYS, "%s\n", p_osm->osm_version); /* Format Waived */
-
- OSM_LOG(&p_osm->log, OSM_LOG_FUNCS, "[\n"); /* Format Waived */
-
- status = cl_plock_init(&p_osm->lock);
- if (status != IB_SUCCESS)
- goto Exit;
-
-#ifdef HAVE_LIBPTHREAD
- pthread_mutex_init(&p_osm->stats.mutex, NULL);
- pthread_cond_init(&p_osm->stats.cond, NULL);
-#else
- status = cl_event_init(&p_osm->stats.event, FALSE);
- if (status != IB_SUCCESS)
- goto Exit;
-#endif
-
- if (p_opt->single_thread) {
- OSM_LOG(&p_osm->log, OSM_LOG_INFO,
- "Forcing single threaded dispatcher\n");
- status = cl_disp_init(&p_osm->disp, 1, "opensm");
- } else {
- /*
- * Normal behavior is to initialize the dispatcher with
- * one thread per CPU, as specified by a thread count of '0'.
- */
- status = cl_disp_init(&p_osm->disp, 0, "opensm");
- }
- if (status != IB_SUCCESS)
- goto Exit;
-
- status = osm_subn_init(&p_osm->subn, p_osm, p_opt);
- if (status != IB_SUCCESS)
- goto Exit;
-
- p_osm->p_vendor =
- osm_vendor_new(&p_osm->log, p_opt->transaction_timeout);
- if (p_osm->p_vendor == NULL) {
- status = IB_INSUFFICIENT_RESOURCES;
- goto Exit;
- }
-
- status = osm_mad_pool_init(&p_osm->mad_pool);
- if (status != IB_SUCCESS)
- goto Exit;
-
- status = osm_vl15_init(&p_osm->vl15, p_osm->p_vendor,
- &p_osm->log, &p_osm->stats,
- p_opt->max_wire_smps);
- if (status != IB_SUCCESS)
- goto Exit;
-
- /* the DB is in use by the SM and SA so init before */
- status = osm_db_init(&p_osm->db, &p_osm->log);
- if (status != IB_SUCCESS)
- goto Exit;
-
- status = osm_sm_init(&p_osm->sm, &p_osm->subn, &p_osm->db,
- p_osm->p_vendor, &p_osm->mad_pool, &p_osm->vl15,
- &p_osm->log, &p_osm->stats, &p_osm->disp,
- &p_osm->lock);
-
- if (status != IB_SUCCESS)
- goto Exit;
-
- status = osm_sa_init(&p_osm->sm, &p_osm->sa, &p_osm->subn,
- p_osm->p_vendor, &p_osm->mad_pool, &p_osm->log,
- &p_osm->stats, &p_osm->disp, &p_osm->lock);
-
- if (status != IB_SUCCESS)
- goto Exit;
-
- cl_qlist_init(&p_osm->plugin_list);
-
- if (p_opt->event_plugin_name)
- load_plugins(p_osm, p_opt->event_plugin_name);
-
-#ifdef ENABLE_OSM_PERF_MGR
- status = osm_perfmgr_init(&p_osm->perfmgr, p_osm, p_opt);
- if (status != IB_SUCCESS)
- goto Exit;
-#endif /* ENABLE_OSM_PERF_MGR */
-
- setup_routing_engines(p_osm, p_opt->routing_engine_names);
-
- p_osm->routing_engine_used = OSM_ROUTING_ENGINE_TYPE_NONE;
-
- p_osm->node_name_map = open_node_name_map(p_opt->node_name_map_name);
-
-Exit:
- OSM_LOG(&p_osm->log, OSM_LOG_FUNCS, "]\n"); /* Format Waived */
- return (status);
-}
-
-/**********************************************************************
- **********************************************************************/
-ib_api_status_t
-osm_opensm_bind(IN osm_opensm_t * const p_osm, IN const ib_net64_t guid)
-{
- ib_api_status_t status;
-
- OSM_LOG_ENTER(&p_osm->log);
-
- status = osm_sm_bind(&p_osm->sm, guid);
- if (status != IB_SUCCESS)
- goto Exit;
-
- status = osm_sa_bind(&p_osm->sa, guid);
- if (status != IB_SUCCESS)
- goto Exit;
-
-#ifdef ENABLE_OSM_PERF_MGR
- status = osm_perfmgr_bind(&p_osm->perfmgr, guid);
- if (status != IB_SUCCESS)
- goto Exit;
-#endif /* ENABLE_OSM_PERF_MGR */
-
-Exit:
- OSM_LOG_EXIT(&p_osm->log);
- return (status);
-}
-
-/**********************************************************************
- **********************************************************************/
-void osm_opensm_report_event(osm_opensm_t *osm, osm_epi_event_id_t event_id,
- void *event_data)
-{
- cl_list_item_t *item;
-
- for (item = cl_qlist_head(&osm->plugin_list);
- item != cl_qlist_end(&osm->plugin_list);
- item = cl_qlist_next(item)) {
- osm_epi_plugin_t *p = (osm_epi_plugin_t *)item;
- if (p->impl->report)
- p->impl->report(p->plugin_data, event_id, event_data);
- }
-}
diff --git a/contrib/ofed/management/opensm/opensm/osm_perfmgr.c b/contrib/ofed/management/opensm/opensm/osm_perfmgr.c
deleted file mode 100644
index f7da2dc..0000000
--- a/contrib/ofed/management/opensm/opensm/osm_perfmgr.c
+++ /dev/null
@@ -1,1311 +0,0 @@
-/*
- * Copyright (c) 2007 The Regents of the University of California.
- * Copyright (c) 2007-2008 Voltaire, Inc. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- */
-
-/*
- * Abstract:
- * Implementation of osm_perfmgr_t.
- * This object implements an IBA performance manager.
- *
- * Author:
- * Ira Weiny, LLNL
- */
-
-#if HAVE_CONFIG_H
-# include <config.h>
-#endif /* HAVE_CONFIG_H */
-
-#ifdef ENABLE_OSM_PERF_MGR
-
-#include <stdlib.h>
-#include <stdint.h>
-#include <string.h>
-#include <poll.h>
-#include <errno.h>
-#include <sys/time.h>
-#include <netinet/in.h>
-#include <float.h>
-#include <arpa/inet.h>
-#include <iba/ib_types.h>
-#include <complib/cl_debug.h>
-#include <complib/cl_thread.h>
-#include <vendor/osm_vendor_api.h>
-#include <opensm/osm_perfmgr.h>
-#include <opensm/osm_log.h>
-#include <opensm/osm_node.h>
-#include <opensm/osm_opensm.h>
-
-#define OSM_PERFMGR_INITIAL_TID_VALUE 0xcafe
-
-#if ENABLE_OSM_PERF_MGR_PROFILE
-struct {
- double fastest_us;
- double slowest_us;
- double avg_us;
- uint64_t num;
-} perfmgr_mad_stats = {
- fastest_us: DBL_MAX,
- slowest_us: DBL_MIN,
- avg_us: 0,
- num: 0
-};
-
-/* diff must be something which can fit in a susecond_t */
-static inline void update_mad_stats(struct timeval *diff)
-{
- double new = (diff->tv_sec * 1000000) + diff->tv_usec;
- if (new < perfmgr_mad_stats.fastest_us)
- perfmgr_mad_stats.fastest_us = new;
- if (new > perfmgr_mad_stats.slowest_us)
- perfmgr_mad_stats.slowest_us = new;
-
- perfmgr_mad_stats.avg_us =
- ((perfmgr_mad_stats.avg_us * perfmgr_mad_stats.num) + new)
- / (perfmgr_mad_stats.num + 1);
- perfmgr_mad_stats.num++;
-}
-
-static inline void perfmgr_clear_mad_stats(void)
-{
- perfmgr_mad_stats.fastest_us = DBL_MAX;
- perfmgr_mad_stats.slowest_us = DBL_MIN;
- perfmgr_mad_stats.avg_us = 0;
- perfmgr_mad_stats.num = 0;
-}
-
-/* after and diff can be the same struct */
-static inline void diff_time(struct timeval *before,
- struct timeval *after, struct timeval *diff)
-{
- struct timeval tmp = *after;
- if (tmp.tv_usec < before->tv_usec) {
- tmp.tv_sec--;
- tmp.tv_usec += 1000000;
- }
- diff->tv_sec = tmp.tv_sec - before->tv_sec;
- diff->tv_usec = tmp.tv_usec - before->tv_usec;
-}
-
-#endif
-
-extern int wait_for_pending_transactions(osm_stats_t * stats);
-
-/**********************************************************************
- * Internal helper functions.
- **********************************************************************/
-static inline void __init_monitored_nodes(osm_perfmgr_t * pm)
-{
- cl_qmap_init(&pm->monitored_map);
- pm->remove_list = NULL;
- cl_event_construct(&pm->sig_query);
- cl_event_init(&pm->sig_query, FALSE);
-}
-
-static inline void
-__mark_for_removal(osm_perfmgr_t * pm, __monitored_node_t * node)
-{
- if (pm->remove_list) {
- node->next = pm->remove_list;
- pm->remove_list = node;
- } else {
- node->next = NULL;
- pm->remove_list = node;
- }
-}
-
-static inline void __remove_marked_nodes(osm_perfmgr_t * pm)
-{
- while (pm->remove_list) {
- __monitored_node_t *next = pm->remove_list->next;
-
- cl_qmap_remove_item(&(pm->monitored_map),
- (cl_map_item_t *) (pm->remove_list));
-
- if (pm->remove_list->name)
- free(pm->remove_list->name);
- free(pm->remove_list);
- pm->remove_list = next;
- }
-}
-
-static inline void __decrement_outstanding_queries(osm_perfmgr_t * pm)
-{
- cl_atomic_dec(&(pm->outstanding_queries));
- cl_event_signal(&(pm->sig_query));
-}
-
-/**********************************************************************
- * Receive the MAD from the vendor layer and post it for processing by
- * the dispatcher.
- **********************************************************************/
-static void
-osm_perfmgr_mad_recv_callback(osm_madw_t * p_madw, void *bind_context,
- osm_madw_t * p_req_madw)
-{
- osm_perfmgr_t *pm = (osm_perfmgr_t *) bind_context;
-
- OSM_LOG_ENTER(pm->log);
-
- osm_madw_copy_context(p_madw, p_req_madw);
- osm_mad_pool_put(pm->mad_pool, p_req_madw);
-
- __decrement_outstanding_queries(pm);
-
- /* post this message for later processing. */
- if (cl_disp_post(pm->pc_disp_h, OSM_MSG_MAD_PORT_COUNTERS,
- (void *)p_madw, NULL, NULL) != CL_SUCCESS) {
- OSM_LOG(pm->log, OSM_LOG_ERROR, "ERR 4C01: "
- "PerfMgr Dispatcher post failed\n");
- osm_mad_pool_put(pm->mad_pool, p_madw);
- }
- OSM_LOG_EXIT(pm->log);
-}
-
-/**********************************************************************
- * Process MAD send errors.
- **********************************************************************/
-static void
-osm_perfmgr_mad_send_err_callback(void *bind_context, osm_madw_t * p_madw)
-{
- osm_perfmgr_t *pm = (osm_perfmgr_t *) bind_context;
- osm_madw_context_t *context = &(p_madw->context);
- uint64_t node_guid = context->perfmgr_context.node_guid;
- uint8_t port = context->perfmgr_context.port;
- cl_map_item_t *p_node;
- __monitored_node_t *p_mon_node;
-
- OSM_LOG_ENTER(pm->log);
-
- /* go ahead and get the monitored node struct to have the printable
- * name if needed in messages
- */
- if ((p_node = cl_qmap_get(&(pm->monitored_map), node_guid)) ==
- cl_qmap_end(&(pm->monitored_map))) {
- OSM_LOG(pm->log, OSM_LOG_ERROR, "ERR 4C15: GUID 0x%016"
- PRIx64 " not found in monitored map\n",
- node_guid);
- goto Exit;
- }
- p_mon_node = (__monitored_node_t *) p_node;
-
- OSM_LOG(pm->log, OSM_LOG_ERROR, "ERR 4C02: %s (0x%" PRIx64
- ") port %u\n", p_mon_node->name, p_mon_node->guid, port);
-
- if (pm->subn->opt.perfmgr_redir && p_madw->status == IB_TIMEOUT) {
- /* First, find the node in the monitored map */
- cl_plock_acquire(pm->lock);
- /* Now, validate port number */
- if (port > p_mon_node->redir_tbl_size) {
- cl_plock_release(pm->lock);
- OSM_LOG(pm->log, OSM_LOG_ERROR, "ERR 4C16: "
- "Invalid port num %u for %s (GUID 0x%016"
- PRIx64 ") num ports %u\n", port, p_mon_node->name,
- p_mon_node->guid, p_mon_node->redir_tbl_size);
- goto Exit;
- }
- /* Clear redirection info */
- p_mon_node->redir_port[port].redir_lid = 0;
- p_mon_node->redir_port[port].redir_qp = 0;
- cl_plock_release(pm->lock);
- }
-
-Exit:
- osm_mad_pool_put(pm->mad_pool, p_madw);
-
- __decrement_outstanding_queries(pm);
-
- OSM_LOG_EXIT(pm->log);
-}
-
-/**********************************************************************
- * Bind the PerfMgr to the vendor layer for MAD sends/receives
- **********************************************************************/
-ib_api_status_t
-osm_perfmgr_bind(osm_perfmgr_t * const pm, const ib_net64_t port_guid)
-{
- osm_bind_info_t bind_info;
- ib_api_status_t status = IB_SUCCESS;
-
- OSM_LOG_ENTER(pm->log);
-
- if (pm->bind_handle != OSM_BIND_INVALID_HANDLE) {
- OSM_LOG(pm->log, OSM_LOG_ERROR,
- "ERR 4C03: Multiple binds not allowed\n");
- status = IB_ERROR;
- goto Exit;
- }
-
- bind_info.port_guid = port_guid;
- bind_info.mad_class = IB_MCLASS_PERF;
- bind_info.class_version = 1;
- bind_info.is_responder = FALSE;
- bind_info.is_report_processor = FALSE;
- bind_info.is_trap_processor = FALSE;
- bind_info.recv_q_size = OSM_PM_DEFAULT_QP1_RCV_SIZE;
- bind_info.send_q_size = OSM_PM_DEFAULT_QP1_SEND_SIZE;
-
- OSM_LOG(pm->log, OSM_LOG_VERBOSE,
- "Binding to port GUID 0x%" PRIx64 "\n", cl_ntoh64(port_guid));
-
- pm->bind_handle = osm_vendor_bind(pm->vendor,
- &bind_info,
- pm->mad_pool,
- osm_perfmgr_mad_recv_callback,
- osm_perfmgr_mad_send_err_callback,
- pm);
-
- if (pm->bind_handle == OSM_BIND_INVALID_HANDLE) {
- status = IB_ERROR;
- OSM_LOG(pm->log, OSM_LOG_ERROR,
- "ERR 4C04: Vendor specific bind failed (%s)\n",
- ib_get_err_str(status));
- goto Exit;
- }
-
-Exit:
- OSM_LOG_EXIT(pm->log);
- return (status);
-}
-
-/**********************************************************************
- * Unbind the PerfMgr from the vendor layer for MAD sends/receives
- **********************************************************************/
-static void osm_perfmgr_mad_unbind(osm_perfmgr_t * const pm)
-{
- OSM_LOG_ENTER(pm->log);
- if (pm->bind_handle == OSM_BIND_INVALID_HANDLE) {
- OSM_LOG(pm->log, OSM_LOG_ERROR, "ERR 4C05: No previous bind\n");
- goto Exit;
- }
- osm_vendor_unbind(pm->bind_handle);
-Exit:
- OSM_LOG_EXIT(pm->log);
-}
-
-/**********************************************************************
- * Given a monitored node and a port, return the qp
- **********************************************************************/
-static ib_net32_t get_qp(__monitored_node_t * mon_node, uint8_t port)
-{
- ib_net32_t qp = cl_ntoh32(1);
-
- if (mon_node && mon_node->redir_tbl_size &&
- port < mon_node->redir_tbl_size &&
- mon_node->redir_port[port].redir_lid &&
- mon_node->redir_port[port].redir_qp)
- qp = mon_node->redir_port[port].redir_qp;
-
- return qp;
-}
-
-/**********************************************************************
- * Given a node, a port, and an optional monitored node,
- * return the appropriate lid to query that port
- **********************************************************************/
-static ib_net16_t
-get_lid(osm_node_t * p_node, uint8_t port, __monitored_node_t * mon_node)
-{
- if (mon_node && mon_node->redir_tbl_size &&
- port < mon_node->redir_tbl_size &&
- mon_node->redir_port[port].redir_lid)
- return mon_node->redir_port[port].redir_lid;
-
- switch (p_node->node_info.node_type) {
- case IB_NODE_TYPE_CA:
- case IB_NODE_TYPE_ROUTER:
- return osm_node_get_base_lid(p_node, port);
- case IB_NODE_TYPE_SWITCH:
- return osm_node_get_base_lid(p_node, 0);
- default:
- return 0;
- }
-}
-
-/**********************************************************************
- * Form and send the Port Counters MAD for a single port.
- **********************************************************************/
-static ib_api_status_t
-osm_perfmgr_send_pc_mad(osm_perfmgr_t * perfmgr, ib_net16_t dest_lid,
- ib_net32_t dest_qp, uint8_t port, uint8_t mad_method,
- osm_madw_context_t * const p_context)
-{
- ib_api_status_t status = IB_SUCCESS;
- ib_port_counters_t *port_counter = NULL;
- ib_perfmgt_mad_t *pm_mad = NULL;
- osm_madw_t *p_madw = NULL;
-
- OSM_LOG_ENTER(perfmgr->log);
-
- p_madw =
- osm_mad_pool_get(perfmgr->mad_pool, perfmgr->bind_handle,
- MAD_BLOCK_SIZE, NULL);
- if (p_madw == NULL)
- return (IB_INSUFFICIENT_MEMORY);
-
- pm_mad = osm_madw_get_perfmgt_mad_ptr(p_madw);
-
- /* build the mad */
- pm_mad->header.base_ver = 1;
- pm_mad->header.mgmt_class = IB_MCLASS_PERF;
- pm_mad->header.class_ver = 1;
- pm_mad->header.method = mad_method;
- pm_mad->header.status = 0;
- pm_mad->header.class_spec = 0;
- pm_mad->header.trans_id =
- cl_hton64((uint64_t) cl_atomic_inc(&(perfmgr->trans_id)));
- pm_mad->header.attr_id = IB_MAD_ATTR_PORT_CNTRS;
- pm_mad->header.resv = 0;
- pm_mad->header.attr_mod = 0;
-
- port_counter = (ib_port_counters_t *) & (pm_mad->data);
- memset(port_counter, 0, sizeof(*port_counter));
- port_counter->port_select = port;
- port_counter->counter_select = 0xFFFF;
-
- p_madw->mad_addr.dest_lid = dest_lid;
- p_madw->mad_addr.addr_type.gsi.remote_qp = dest_qp;
- p_madw->mad_addr.addr_type.gsi.remote_qkey =
- cl_hton32(IB_QP1_WELL_KNOWN_Q_KEY);
- /* FIXME what about other partitions */
- p_madw->mad_addr.addr_type.gsi.pkey_ix = 0;
- p_madw->mad_addr.addr_type.gsi.service_level = 0;
- p_madw->mad_addr.addr_type.gsi.global_route = FALSE;
- p_madw->resp_expected = TRUE;
-
- if (p_context)
- p_madw->context = *p_context;
-
- status = osm_vendor_send(perfmgr->bind_handle, p_madw, TRUE);
-
- if (status == IB_SUCCESS) {
- /* pause this thread if we have too many outstanding requests */
- cl_atomic_inc(&(perfmgr->outstanding_queries));
- if (perfmgr->outstanding_queries >
- perfmgr->max_outstanding_queries) {
- perfmgr->sweep_state = PERFMGR_SWEEP_SUSPENDED;
- cl_event_wait_on(&perfmgr->sig_query, EVENT_NO_TIMEOUT,
- TRUE);
- perfmgr->sweep_state = PERFMGR_SWEEP_ACTIVE;
- }
- }
-
- OSM_LOG_EXIT(perfmgr->log);
- return (status);
-}
-
-/**********************************************************************
- * sweep the node_guid_tbl and collect the node guids to be tracked
- **********************************************************************/
-static void __collect_guids(cl_map_item_t * const p_map_item, void *context)
-{
- osm_node_t *node = (osm_node_t *) p_map_item;
- uint64_t node_guid = cl_ntoh64(node->node_info.node_guid);
- osm_perfmgr_t *pm = (osm_perfmgr_t *) context;
- __monitored_node_t *mon_node = NULL;
- uint32_t size;
-
- OSM_LOG_ENTER(pm->log);
-
- if (cl_qmap_get(&(pm->monitored_map), node_guid)
- == cl_qmap_end(&(pm->monitored_map))) {
- /* if not already in our map add it */
- size = node->node_info.num_ports;
- mon_node = malloc(sizeof(*mon_node) + sizeof(redir_t) * size);
- if (!mon_node) {
- OSM_LOG(pm->log, OSM_LOG_ERROR, "PerfMgr: ERR 4C06: "
- "malloc failed: not handling node %s"
- "(GUID 0x%" PRIx64 ")\n", node->print_desc, node_guid);
- goto Exit;
- }
- memset(mon_node, 0, sizeof(*mon_node) + sizeof(redir_t) * size);
- mon_node->guid = node_guid;
- mon_node->name = strdup(node->print_desc);
- mon_node->redir_tbl_size = size + 1;
- cl_qmap_insert(&(pm->monitored_map), node_guid,
- (cl_map_item_t *) mon_node);
- }
-
-Exit:
- OSM_LOG_EXIT(pm->log);
-}
-
-/**********************************************************************
- * query the Port Counters of all the nodes in the subnet.
- **********************************************************************/
-static void
-__osm_perfmgr_query_counters(cl_map_item_t * const p_map_item, void *context)
-{
- ib_api_status_t status = IB_SUCCESS;
- uint8_t port = 0, startport = 1;
- osm_perfmgr_t *pm = (osm_perfmgr_t *) context;
- osm_node_t *node = NULL;
- __monitored_node_t *mon_node = (__monitored_node_t *) p_map_item;
- osm_madw_context_t mad_context;
- uint8_t num_ports = 0;
- uint64_t node_guid = 0;
- ib_net32_t remote_qp;
-
- OSM_LOG_ENTER(pm->log);
-
- cl_plock_acquire(pm->lock);
- node = osm_get_node_by_guid(pm->subn, cl_hton64(mon_node->guid));
- if (!node) {
- OSM_LOG(pm->log, OSM_LOG_ERROR,
- "ERR 4C07: Node \"%s\" (guid 0x%" PRIx64
- ") no longer exists so removing from PerfMgr monitoring\n",
- mon_node->name, mon_node->guid);
- __mark_for_removal(pm, mon_node);
- goto Exit;
- }
-
- num_ports = osm_node_get_num_physp(node);
- node_guid = cl_ntoh64(node->node_info.node_guid);
-
- /* make sure we have a database object ready to store this information */
- if (perfmgr_db_create_entry(pm->db, node_guid, num_ports,
- node->print_desc) !=
- PERFMGR_EVENT_DB_SUCCESS) {
- OSM_LOG(pm->log, OSM_LOG_ERROR,
- "ERR 4C08: DB create entry failed for 0x%"
- PRIx64 " (%s) : %s\n", node_guid, node->print_desc,
- strerror(errno));
- goto Exit;
- }
-
- /* if switch, check for enhanced port 0 */
- if (osm_node_get_type(node) == IB_NODE_TYPE_SWITCH &&
- node->sw &&
- ib_switch_info_is_enhanced_port0(&node->sw->switch_info))
- startport = 0;
-
- /* issue the query for each port */
- for (port = startport; port < num_ports; port++) {
- ib_net16_t lid;
-
- if (!osm_node_get_physp_ptr(node, port))
- continue;
-
- lid = get_lid(node, port, mon_node);
- if (lid == 0) {
- OSM_LOG(pm->log, OSM_LOG_DEBUG, "WARN: node 0x%" PRIx64
- " port %d (%s): port out of range, skipping\n",
- cl_ntoh64(node->node_info.node_guid), port,
- node->print_desc);
- continue;
- }
-
- remote_qp = get_qp(mon_node, port);
-
- mad_context.perfmgr_context.node_guid = node_guid;
- mad_context.perfmgr_context.port = port;
- mad_context.perfmgr_context.mad_method = IB_MAD_METHOD_GET;
-#if ENABLE_OSM_PERF_MGR_PROFILE
- gettimeofday(&(mad_context.perfmgr_context.query_start), NULL);
-#endif
- OSM_LOG(pm->log, OSM_LOG_VERBOSE, "Getting stats for node 0x%"
- PRIx64 " port %d (lid %u) (%s)\n", node_guid, port,
- cl_ntoh16(lid), node->print_desc);
- status =
- osm_perfmgr_send_pc_mad(pm, lid, remote_qp, port,
- IB_MAD_METHOD_GET, &mad_context);
- if (status != IB_SUCCESS)
- OSM_LOG(pm->log, OSM_LOG_ERROR, "ERR 4C09: "
- "Failed to issue port counter query for node 0x%"
- PRIx64 " port %d (%s)\n",
- node->node_info.node_guid, port,
- node->print_desc);
- }
-Exit:
- cl_plock_release(pm->lock);
- OSM_LOG_EXIT(pm->log);
-}
-
-/**********************************************************************
- * Discovery stuff.
- * Basically this code should not be here, but merged with main OpenSM
- **********************************************************************/
-extern void osm_drop_mgr_process(IN osm_sm_t *sm);
-
-static int sweep_hop_1(osm_sm_t * sm)
-{
- ib_api_status_t status = IB_SUCCESS;
- osm_bind_handle_t h_bind;
- osm_madw_context_t context;
- osm_node_t *p_node;
- osm_port_t *p_port;
- osm_physp_t *p_physp;
- osm_dr_path_t *p_dr_path;
- osm_dr_path_t hop_1_path;
- ib_net64_t port_guid;
- uint8_t port_num;
- uint8_t path_array[IB_SUBNET_PATH_HOPS_MAX];
- uint8_t num_ports;
- osm_physp_t *p_ext_physp;
-
- port_guid = sm->p_subn->sm_port_guid;
-
- p_port = osm_get_port_by_guid(sm->p_subn, port_guid);
- if (!p_port) {
- OSM_LOG(sm->p_log, OSM_LOG_ERROR,
- "ERR 4C81: No SM port object\n");
- return -1;
- }
-
- p_node = p_port->p_node;
- port_num = ib_node_info_get_local_port_num(&p_node->node_info);
-
- OSM_LOG(sm->p_log, OSM_LOG_DEBUG,
- "Probing hop 1 on local port %u\n", port_num);
-
- p_physp = osm_node_get_physp_ptr(p_node, port_num);
-
- CL_ASSERT(p_physp);
-
- p_dr_path = osm_physp_get_dr_path_ptr(p_physp);
- h_bind = osm_dr_path_get_bind_handle(p_dr_path);
-
- CL_ASSERT(h_bind != OSM_BIND_INVALID_HANDLE);
-
- memset(path_array, 0, sizeof(path_array));
- /* the hop_1 operations depend on the type of our node.
- * Currently - legal nodes that can host SM are SW and CA */
- switch (osm_node_get_type(p_node)) {
- case IB_NODE_TYPE_CA:
- case IB_NODE_TYPE_ROUTER:
- memset(&context, 0, sizeof(context));
- context.ni_context.node_guid = osm_node_get_node_guid(p_node);
- context.ni_context.port_num = port_num;
-
- path_array[1] = port_num;
-
- osm_dr_path_init(&hop_1_path, h_bind, 1, path_array);
- status = osm_req_get(sm, &hop_1_path,
- IB_MAD_ATTR_NODE_INFO, 0,
- CL_DISP_MSGID_NONE, &context);
-
- if (status != IB_SUCCESS)
- OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR 4C82: "
- "Request for NodeInfo failed\n");
- break;
-
- case IB_NODE_TYPE_SWITCH:
- /* Need to go over all the ports of the switch, and send a node_info
- * from them. This doesn't include the port 0 of the switch, which
- * hosts the SM.
- * Note: We'll send another switchInfo on port 0, since if no ports
- * are connected, we still want to get some response, and have the
- * subnet come up.
- */
- num_ports = osm_node_get_num_physp(p_node);
- for (port_num = 0; port_num < num_ports; port_num++) {
- /* go through the port only if the port is not DOWN */
- p_ext_physp = osm_node_get_physp_ptr(p_node, port_num);
- if (!p_ext_physp || ib_port_info_get_port_state
- (&p_ext_physp->port_info) <= IB_LINK_DOWN)
- continue;
-
- memset(&context, 0, sizeof(context));
- context.ni_context.node_guid =
- osm_node_get_node_guid(p_node);
- context.ni_context.port_num = port_num;
-
- path_array[1] = port_num;
-
- osm_dr_path_init(&hop_1_path, h_bind, 1, path_array);
- status = osm_req_get(sm, &hop_1_path,
- IB_MAD_ATTR_NODE_INFO, 0,
- CL_DISP_MSGID_NONE, &context);
-
- if (status != IB_SUCCESS)
- OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR 4C82: "
- "Request for NodeInfo failed\n");
- }
- break;
-
- default:
- OSM_LOG(sm->p_log, OSM_LOG_ERROR,
- "ERR 4C83: Unknown node type %d\n",
- osm_node_get_type(p_node));
- }
-
- return (status);
-}
-
-static unsigned is_sm_port_down(osm_sm_t * const sm)
-{
- ib_net64_t port_guid;
- osm_port_t *p_port;
-
- port_guid = sm->p_subn->sm_port_guid;
- if (port_guid == 0)
- return 1;
-
- CL_PLOCK_ACQUIRE(sm->p_lock);
- p_port = osm_get_port_by_guid(sm->p_subn, port_guid);
- if (!p_port) {
- CL_PLOCK_RELEASE(sm->p_lock);
- OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR 4C85: "
- "SM port with GUID:%016" PRIx64 " is unknown\n",
- cl_ntoh64(port_guid));
- return 1;
- }
- CL_PLOCK_RELEASE(sm->p_lock);
-
- return osm_physp_get_port_state(p_port->p_physp) == IB_LINK_DOWN;
-}
-
-static int sweep_hop_0(osm_sm_t * const sm)
-{
- ib_api_status_t status;
- osm_dr_path_t dr_path;
- osm_bind_handle_t h_bind;
- uint8_t path_array[IB_SUBNET_PATH_HOPS_MAX];
-
- memset(path_array, 0, sizeof(path_array));
-
- h_bind = osm_sm_mad_ctrl_get_bind_handle(&sm->mad_ctrl);
- if (h_bind == OSM_BIND_INVALID_HANDLE) {
- OSM_LOG(sm->p_log, OSM_LOG_DEBUG, "No bound ports.\n");
- return -1;
- }
-
- osm_dr_path_init(&dr_path, h_bind, 0, path_array);
- status = osm_req_get(sm, &dr_path, IB_MAD_ATTR_NODE_INFO, 0,
- CL_DISP_MSGID_NONE, NULL);
-
- if (status != IB_SUCCESS)
- OSM_LOG(sm->p_log, OSM_LOG_ERROR,
- "ERR 4C86: Request for NodeInfo failed\n");
-
- return (status);
-}
-
-static void reset_node_count(cl_map_item_t * const p_map_item, void *cxt)
-{
- osm_node_t *p_node = (osm_node_t *) p_map_item;
- p_node->discovery_count = 0;
-}
-
-static void reset_port_count(cl_map_item_t * const p_map_item, void *cxt)
-{
- osm_port_t *p_port = (osm_port_t *) p_map_item;
- p_port->discovery_count = 0;
-}
-
-static void reset_switch_count(cl_map_item_t * const p_map_item, void *cxt)
-{
- osm_switch_t *p_sw = (osm_switch_t *) p_map_item;
- p_sw->discovery_count = 0;
- p_sw->need_update = 0;
-}
-
-static int perfmgr_discovery(osm_opensm_t * osm)
-{
- int ret;
-
- CL_PLOCK_ACQUIRE(&osm->lock);
- cl_qmap_apply_func(&osm->subn.node_guid_tbl, reset_node_count, NULL);
- cl_qmap_apply_func(&osm->subn.port_guid_tbl, reset_port_count, NULL);
- cl_qmap_apply_func(&osm->subn.sw_guid_tbl, reset_switch_count, NULL);
- CL_PLOCK_RELEASE(&osm->lock);
-
- osm->subn.in_sweep_hop_0 = TRUE;
-
- ret = sweep_hop_0(&osm->sm);
- if (ret)
- goto _exit;
-
- if (wait_for_pending_transactions(&osm->stats))
- goto _exit;
-
- if (is_sm_port_down(&osm->sm)) {
- OSM_LOG(&osm->log, OSM_LOG_VERBOSE, "SM port is down\n");
- goto _drop;
- }
-
- osm->subn.in_sweep_hop_0 = FALSE;
-
- ret = sweep_hop_1(&osm->sm);
- if (ret)
- goto _exit;
-
- if (wait_for_pending_transactions(&osm->stats))
- goto _exit;
-
-_drop:
- osm_drop_mgr_process(&osm->sm);
-
-_exit:
- return ret;
-}
-
-/**********************************************************************
- * Main PerfMgr processor - query the performance counters.
- **********************************************************************/
-void osm_perfmgr_process(osm_perfmgr_t * pm)
-{
-#if ENABLE_OSM_PERF_MGR_PROFILE
- struct timeval before, after;
-#endif
-
- if (pm->state != PERFMGR_STATE_ENABLED)
- return;
-
- if (pm->subn->sm_state == IB_SMINFO_STATE_STANDBY ||
- pm->subn->sm_state == IB_SMINFO_STATE_NOTACTIVE)
- perfmgr_discovery(pm->subn->p_osm);
-
-#if ENABLE_OSM_PERF_MGR_PROFILE
- gettimeofday(&before, NULL);
-#endif
- pm->sweep_state = PERFMGR_SWEEP_ACTIVE;
- /* With the global lock held collect the node guids */
- /* FIXME we should be able to track SA notices
- * and not have to sweep the node_guid_tbl each pass
- */
- OSM_LOG(pm->log, OSM_LOG_VERBOSE, "Gathering PerfMgr stats\n");
- cl_plock_acquire(pm->lock);
- cl_qmap_apply_func(&(pm->subn->node_guid_tbl),
- __collect_guids, (void *)pm);
- cl_plock_release(pm->lock);
-
- /* then for each node query their counters */
- cl_qmap_apply_func(&(pm->monitored_map),
- __osm_perfmgr_query_counters, (void *)pm);
-
- /* Clean out any nodes found to be removed during the
- * sweep
- */
- __remove_marked_nodes(pm);
-
-#if ENABLE_OSM_PERF_MGR_PROFILE
- /* spin on outstanding queries */
- while (pm->outstanding_queries > 0)
- cl_event_wait_on(&pm->sig_sweep, 1000, TRUE);
-
- gettimeofday(&after, NULL);
- diff_time(&before, &after, &after);
- osm_log(pm->log, OSM_LOG_INFO,
- "PerfMgr total sweep time : %ld.%06ld s\n"
- " fastest mad : %g us\n"
- " slowest mad : %g us\n"
- " average mad : %g us\n",
- after.tv_sec, after.tv_usec,
- perfmgr_mad_stats.fastest_us,
- perfmgr_mad_stats.slowest_us, perfmgr_mad_stats.avg_us);
- perfmgr_clear_mad_stats();
-#endif
-
- pm->sweep_state = PERFMGR_SWEEP_SLEEP;
-}
-
-/**********************************************************************
- * PerfMgr timer - loop continuously and signal SM to run PerfMgr
- * processor.
- **********************************************************************/
-static void perfmgr_sweep(void *arg)
-{
- osm_perfmgr_t *pm = arg;
-
- if (pm->state == PERFMGR_STATE_ENABLED)
- osm_sm_signal(pm->sm, OSM_SIGNAL_PERFMGR_SWEEP);
- cl_timer_start(&pm->sweep_timer, pm->sweep_time_s * 1000);
-}
-
-/**********************************************************************
- **********************************************************************/
-void osm_perfmgr_shutdown(osm_perfmgr_t * const pm)
-{
- OSM_LOG_ENTER(pm->log);
- cl_timer_stop(&pm->sweep_timer);
- osm_perfmgr_mad_unbind(pm);
- OSM_LOG_EXIT(pm->log);
-}
-
-/**********************************************************************
- **********************************************************************/
-void osm_perfmgr_destroy(osm_perfmgr_t * const pm)
-{
- OSM_LOG_ENTER(pm->log);
- perfmgr_db_destroy(pm->db);
- cl_timer_destroy(&pm->sweep_timer);
- OSM_LOG_EXIT(pm->log);
-}
-
-/**********************************************************************
- * Detect if someone else on the network could have cleared the counters
- * without us knowing. This is easy to detect because the counters never wrap
- * but are "sticky"
- *
- * The one time this will not work is if the port is getting errors fast enough
- * to have the reading overtake the previous reading. In this case counters
- * will be missed.
- **********************************************************************/
-static void
-osm_perfmgr_check_oob_clear(osm_perfmgr_t * pm, __monitored_node_t *mon_node,
- uint8_t port, perfmgr_db_err_reading_t * cr,
- perfmgr_db_data_cnt_reading_t * dc)
-{
- perfmgr_db_err_reading_t prev_err;
- perfmgr_db_data_cnt_reading_t prev_dc;
-
- if (perfmgr_db_get_prev_err(pm->db, mon_node->guid, port, &prev_err)
- != PERFMGR_EVENT_DB_SUCCESS) {
- OSM_LOG(pm->log, OSM_LOG_VERBOSE, "Failed to find previous "
- "error reading for %s (guid 0x%" PRIx64 ") port %u\n",
- mon_node->name, mon_node->guid, port);
- return;
- }
-
- if (cr->symbol_err_cnt < prev_err.symbol_err_cnt ||
- cr->link_err_recover < prev_err.link_err_recover ||
- cr->link_downed < prev_err.link_downed ||
- cr->rcv_err < prev_err.rcv_err ||
- cr->rcv_rem_phys_err < prev_err.rcv_rem_phys_err ||
- cr->rcv_switch_relay_err < prev_err.rcv_switch_relay_err ||
- cr->xmit_discards < prev_err.xmit_discards ||
- cr->xmit_constraint_err < prev_err.xmit_constraint_err ||
- cr->rcv_constraint_err < prev_err.rcv_constraint_err ||
- cr->link_integrity < prev_err.link_integrity ||
- cr->buffer_overrun < prev_err.buffer_overrun ||
- cr->vl15_dropped < prev_err.vl15_dropped) {
- OSM_LOG(pm->log, OSM_LOG_ERROR, "PerfMgr: ERR 4C0A: "
- "Detected an out of band error clear "
- "on %s (0x%" PRIx64 ") port %u\n",
- mon_node->name, mon_node->guid, port);
- perfmgr_db_clear_prev_err(pm->db, mon_node->guid, port);
- }
-
- /* FIXME handle extended counters */
- if (perfmgr_db_get_prev_dc(pm->db, mon_node->guid, port, &prev_dc)
- != PERFMGR_EVENT_DB_SUCCESS) {
- OSM_LOG(pm->log, OSM_LOG_VERBOSE,
- "Failed to find previous data count "
- "reading for %s (0x%" PRIx64 ") port %u\n",
- mon_node->name, mon_node->guid, port);
- return;
- }
-
- if (dc->xmit_data < prev_dc.xmit_data ||
- dc->rcv_data < prev_dc.rcv_data ||
- dc->xmit_pkts < prev_dc.xmit_pkts ||
- dc->rcv_pkts < prev_dc.rcv_pkts) {
- OSM_LOG(pm->log, OSM_LOG_ERROR,
- "PerfMgr: ERR 4C0B: Detected an out of band data counter "
- "clear on node %s (0x%" PRIx64 ") port %u\n",
- mon_node->name, mon_node->guid, port);
- perfmgr_db_clear_prev_dc(pm->db, mon_node->guid, port);
- }
-}
-
-/**********************************************************************
- * Return 1 if the value is "close" to overflowing
- **********************************************************************/
-static int counter_overflow_4(uint8_t val)
-{
- return (val >= 10);
-}
-
-static int counter_overflow_8(uint8_t val)
-{
- return (val >= (UINT8_MAX - (UINT8_MAX / 4)));
-}
-
-static int counter_overflow_16(ib_net16_t val)
-{
- return (cl_ntoh16(val) >= (UINT16_MAX - (UINT16_MAX / 4)));
-}
-
-static int counter_overflow_32(ib_net32_t val)
-{
- return (cl_ntoh32(val) >= (UINT32_MAX - (UINT32_MAX / 4)));
-}
-
-/**********************************************************************
- * Check if the port counters have overflowed and if so issue a clear
- * MAD to the port.
- **********************************************************************/
-static void
-osm_perfmgr_check_overflow(osm_perfmgr_t * pm, __monitored_node_t *mon_node,
- uint8_t port, ib_port_counters_t * pc)
-{
- osm_madw_context_t mad_context;
- ib_api_status_t status;
- ib_net32_t remote_qp;
-
- OSM_LOG_ENTER(pm->log);
-
- if (counter_overflow_16(pc->symbol_err_cnt) ||
- counter_overflow_8(pc->link_err_recover) ||
- counter_overflow_8(pc->link_downed) ||
- counter_overflow_16(pc->rcv_err) ||
- counter_overflow_16(pc->rcv_rem_phys_err) ||
- counter_overflow_16(pc->rcv_switch_relay_err) ||
- counter_overflow_16(pc->xmit_discards) ||
- counter_overflow_8(pc->xmit_constraint_err) ||
- counter_overflow_8(pc->rcv_constraint_err) ||
- counter_overflow_4(PC_LINK_INT(pc->link_int_buffer_overrun)) ||
- counter_overflow_4(PC_BUF_OVERRUN(pc->link_int_buffer_overrun)) ||
- counter_overflow_16(pc->vl15_dropped) ||
- counter_overflow_32(pc->xmit_data) ||
- counter_overflow_32(pc->rcv_data) ||
- counter_overflow_32(pc->xmit_pkts) ||
- counter_overflow_32(pc->rcv_pkts)) {
- osm_node_t *p_node = NULL;
- ib_net16_t lid = 0;
-
- osm_log(pm->log, OSM_LOG_VERBOSE,
- "PerfMgr: Counter overflow: %s (0x%" PRIx64
- ") port %d; clearing counters\n",
- mon_node->name, mon_node->guid, port);
-
- cl_plock_acquire(pm->lock);
- p_node = osm_get_node_by_guid(pm->subn, cl_hton64(mon_node->guid));
- lid = get_lid(p_node, port, mon_node);
- cl_plock_release(pm->lock);
- if (lid == 0) {
- OSM_LOG(pm->log, OSM_LOG_ERROR, "PerfMgr: ERR 4C0C: "
- "Failed to clear counters for %s (0x%"
- PRIx64 ") port %d; failed to get lid\n",
- mon_node->name, mon_node->guid, port);
- goto Exit;
- }
-
- remote_qp = get_qp(NULL, port);
-
- mad_context.perfmgr_context.node_guid = mon_node->guid;
- mad_context.perfmgr_context.port = port;
- mad_context.perfmgr_context.mad_method = IB_MAD_METHOD_SET;
- /* clear port counters */
- status =
- osm_perfmgr_send_pc_mad(pm, lid, remote_qp, port,
- IB_MAD_METHOD_SET, &mad_context);
- if (status != IB_SUCCESS)
- OSM_LOG(pm->log, OSM_LOG_ERROR, "PerfMgr: ERR 4C11: "
- "Failed to send clear counters MAD for %s (0x%"
- PRIx64 ") port %d\n",
- mon_node->name, mon_node->guid, port);
-
- perfmgr_db_clear_prev_dc(pm->db, mon_node->guid, port);
- }
-
-Exit:
- OSM_LOG_EXIT(pm->log);
-}
-
-/**********************************************************************
- * Check values for logging of errors
- **********************************************************************/
-static void
-osm_perfmgr_log_events(osm_perfmgr_t * pm, __monitored_node_t *mon_node, uint8_t port,
- perfmgr_db_err_reading_t * reading)
-{
- perfmgr_db_err_reading_t prev_read;
- time_t time_diff = 0;
- perfmgr_db_err_t err =
- perfmgr_db_get_prev_err(pm->db, mon_node->guid, port, &prev_read);
-
- if (err != PERFMGR_EVENT_DB_SUCCESS) {
- OSM_LOG(pm->log, OSM_LOG_VERBOSE, "Failed to find previous "
- "reading for %s (0x%" PRIx64 ") port %u\n",
- mon_node->name, mon_node->guid, port);
- return;
- }
- time_diff = (reading->time - prev_read.time);
-
- /* FIXME these events should be defineable by the user in a config
- * file somewhere. */
- if (reading->symbol_err_cnt > prev_read.symbol_err_cnt)
- OSM_LOG(pm->log, OSM_LOG_ERROR, "ERR 4C0D: "
- "Found %" PRIu64 " Symbol errors in %lu sec on %s (0x%"
- PRIx64 ") port %u\n",
- (reading->symbol_err_cnt - prev_read.symbol_err_cnt),
- time_diff, mon_node->name, mon_node->guid, port);
-
- if (reading->rcv_err > prev_read.rcv_err)
- OSM_LOG(pm->log, OSM_LOG_ERROR, "ERR 4C0E: "
- "Found %" PRIu64
- " Receive errors in %lu sec on %s (0x%" PRIx64
- ") port %u\n", (reading->rcv_err - prev_read.rcv_err),
- time_diff, mon_node->name, mon_node->guid, port);
-
- if (reading->xmit_discards > prev_read.xmit_discards)
- OSM_LOG(pm->log, OSM_LOG_ERROR, "ERR 4C0F: "
- "Found %" PRIu64 " Xmit Discards in %lu sec on %s (0x%"
- PRIx64 ") port %u\n",
- (reading->xmit_discards - prev_read.xmit_discards),
- time_diff, mon_node->name, mon_node->guid, port);
-}
-
-/**********************************************************************
- * The dispatcher uses a thread pool which will call this function when
- * we have a thread available to process our mad received from the wire.
- **********************************************************************/
-static void osm_pc_rcv_process(void *context, void *data)
-{
- osm_perfmgr_t *const pm = (osm_perfmgr_t *) context;
- osm_madw_t *p_madw = (osm_madw_t *) data;
- osm_madw_context_t *mad_context = &(p_madw->context);
- ib_port_counters_t *wire_read =
- (ib_port_counters_t *) & (osm_madw_get_perfmgt_mad_ptr(p_madw)->
- data);
- ib_mad_t *p_mad = osm_madw_get_mad_ptr(p_madw);
- uint64_t node_guid = mad_context->perfmgr_context.node_guid;
- uint8_t port = mad_context->perfmgr_context.port;
- perfmgr_db_err_reading_t err_reading;
- perfmgr_db_data_cnt_reading_t data_reading;
- cl_map_item_t *p_node;
- __monitored_node_t *p_mon_node;
-
- OSM_LOG_ENTER(pm->log);
-
- /* go ahead and get the monitored node struct to have the printable
- * name if needed in messages
- */
- if ((p_node = cl_qmap_get(&(pm->monitored_map), node_guid)) ==
- cl_qmap_end(&(pm->monitored_map))) {
- OSM_LOG(pm->log, OSM_LOG_ERROR, "ERR 4C12: GUID 0x%016"
- PRIx64 " not found in monitored map\n",
- node_guid);
- goto Exit;
- }
- p_mon_node = (__monitored_node_t *) p_node;
-
- OSM_LOG(pm->log, OSM_LOG_VERBOSE,
- "Processing received MAD status 0x%x context 0x%"
- PRIx64 " port %u\n", p_mad->status, node_guid, port);
-
- /* Response could also be redirection (IBM eHCA PMA does this) */
- if (p_mad->attr_id == IB_MAD_ATTR_CLASS_PORT_INFO) {
- char gid_str[INET6_ADDRSTRLEN];
- ib_class_port_info_t *cpi =
- (ib_class_port_info_t *) &
- (osm_madw_get_perfmgt_mad_ptr(p_madw)->data);
- ib_api_status_t status;
-
- OSM_LOG(pm->log, OSM_LOG_VERBOSE,
- "Redirection to LID %u GID %s QP 0x%x received\n",
- cl_ntoh16(cpi->redir_lid),
- inet_ntop(AF_INET6, cpi->redir_gid.raw, gid_str,
- sizeof gid_str),
- cl_ntoh32(cpi->redir_qp));
-
- /* LID or GID redirection ? */
- /* For GID redirection, need to get PathRecord from SA */
- if (cpi->redir_lid == 0) {
- OSM_LOG(pm->log, OSM_LOG_VERBOSE,
- "GID redirection not currently implemented!\n");
- goto Exit;
- }
-
- if (!pm->subn->opt.perfmgr_redir) {
- OSM_LOG(pm->log, OSM_LOG_ERROR, "ERR 4C16: "
- "redirection requested but disabled\n");
- goto Exit;
- }
-
- /* LID redirection support (easier than GID redirection) */
- cl_plock_acquire(pm->lock);
- /* Now, validate port number */
- if (port > p_mon_node->redir_tbl_size) {
- cl_plock_release(pm->lock);
- OSM_LOG(pm->log, OSM_LOG_ERROR, "ERR 4C13: "
- "Invalid port num %d for GUID 0x%016"
- PRIx64 " num ports %d\n", port, node_guid,
- p_mon_node->redir_tbl_size);
- goto Exit;
- }
- p_mon_node->redir_port[port].redir_lid = cpi->redir_lid;
- p_mon_node->redir_port[port].redir_qp = cpi->redir_qp;
- cl_plock_release(pm->lock);
-
- /* Finally, reissue the query to the redirected location */
- status =
- osm_perfmgr_send_pc_mad(pm, cpi->redir_lid, cpi->redir_qp,
- port,
- mad_context->perfmgr_context.
- mad_method, mad_context);
- if (status != IB_SUCCESS)
- OSM_LOG(pm->log, OSM_LOG_ERROR, "ERR 4C14: "
- "Failed to send redirected MAD with method 0x%x for node 0x%"
- PRIx64 " port %d\n",
- mad_context->perfmgr_context.mad_method,
- node_guid, port);
- goto Exit;
- }
-
- CL_ASSERT(p_mad->attr_id == IB_MAD_ATTR_PORT_CNTRS);
-
- perfmgr_db_fill_err_read(wire_read, &err_reading);
- /* FIXME separate query for extended counters if they are supported
- * on the port.
- */
- perfmgr_db_fill_data_cnt_read_pc(wire_read, &data_reading);
-
- /* detect an out of band clear on the port */
- if (mad_context->perfmgr_context.mad_method != IB_MAD_METHOD_SET)
- osm_perfmgr_check_oob_clear(pm, p_mon_node, port,
- &err_reading, &data_reading);
-
- /* log any critical events from this reading */
- osm_perfmgr_log_events(pm, p_mon_node, port, &err_reading);
-
- if (mad_context->perfmgr_context.mad_method == IB_MAD_METHOD_GET) {
- perfmgr_db_add_err_reading(pm->db, node_guid, port,
- &err_reading);
- perfmgr_db_add_dc_reading(pm->db, node_guid, port,
- &data_reading);
- } else {
- perfmgr_db_clear_prev_err(pm->db, node_guid, port);
- perfmgr_db_clear_prev_dc(pm->db, node_guid, port);
- }
-
- osm_perfmgr_check_overflow(pm, p_mon_node, port, wire_read);
-
-#if ENABLE_OSM_PERF_MGR_PROFILE
- do {
- struct timeval proc_time;
- gettimeofday(&proc_time, NULL);
- diff_time(&(p_madw->context.perfmgr_context.query_start),
- &proc_time, &proc_time);
- update_mad_stats(&proc_time);
- } while (0);
-#endif
-
-Exit:
- osm_mad_pool_put(pm->mad_pool, p_madw);
-
- OSM_LOG_EXIT(pm->log);
-}
-
-/**********************************************************************
- * Initialize the PerfMgr object
- **********************************************************************/
-ib_api_status_t
-osm_perfmgr_init(osm_perfmgr_t * const pm, osm_opensm_t *osm,
- const osm_subn_opt_t * const p_opt)
-{
- ib_api_status_t status = IB_SUCCESS;
-
- OSM_LOG_ENTER(&osm->log);
-
- OSM_LOG(&osm->log, OSM_LOG_VERBOSE, "Initializing PerfMgr\n");
-
- memset(pm, 0, sizeof(*pm));
-
- cl_event_construct(&pm->sig_sweep);
- cl_event_init(&pm->sig_sweep, FALSE);
- pm->subn = &osm->subn;
- pm->sm = &osm->sm;
- pm->log = &osm->log;
- pm->mad_pool = &osm->mad_pool;
- pm->vendor = osm->p_vendor;
- pm->trans_id = OSM_PERFMGR_INITIAL_TID_VALUE;
- pm->lock = &osm->lock;
- pm->state =
- p_opt->perfmgr ? PERFMGR_STATE_ENABLED : PERFMGR_STATE_DISABLE;
- pm->sweep_time_s = p_opt->perfmgr_sweep_time_s;
- pm->max_outstanding_queries = p_opt->perfmgr_max_outstanding_queries;
- pm->osm = osm;
-
- status = cl_timer_init(&pm->sweep_timer, perfmgr_sweep, pm);
- if (status != IB_SUCCESS)
- goto Exit;
-
- pm->db = perfmgr_db_construct(pm);
- if (!pm->db) {
- pm->state = PERFMGR_STATE_NO_DB;
- goto Exit;
- }
-
- pm->pc_disp_h = cl_disp_register(&osm->disp, OSM_MSG_MAD_PORT_COUNTERS,
- osm_pc_rcv_process, pm);
- if (pm->pc_disp_h == CL_DISP_INVALID_HANDLE)
- goto Exit;
-
- __init_monitored_nodes(pm);
-
- cl_timer_start(&pm->sweep_timer, pm->sweep_time_s * 1000);
-
-Exit:
- OSM_LOG_EXIT(pm->log);
- return (status);
-}
-
-/**********************************************************************
- * Clear the counters from the db
- **********************************************************************/
-void osm_perfmgr_clear_counters(osm_perfmgr_t * pm)
-{
- /**
- * FIXME todo issue clear on the fabric?
- */
- perfmgr_db_clear_counters(pm->db);
- osm_log(pm->log, OSM_LOG_INFO, "PerfMgr counters cleared\n");
-}
-
-/*******************************************************************
- * Have the DB dump its information to the file specified
- *******************************************************************/
-void osm_perfmgr_dump_counters(osm_perfmgr_t * pm, perfmgr_db_dump_t dump_type)
-{
- char path[256];
- char *file_name;
- if (pm->subn->opt.event_db_dump_file)
- file_name = pm->subn->opt.event_db_dump_file;
- else {
- snprintf(path, sizeof(path), "%s/%s",
- pm->subn->opt.dump_files_dir,
- OSM_PERFMGR_DEFAULT_DUMP_FILE);
- file_name = path;
- }
- if (perfmgr_db_dump(pm->db, file_name, dump_type) != 0)
- OSM_LOG(pm->log, OSM_LOG_ERROR, "Failed to dump file %s : %s",
- file_name, strerror(errno));
-}
-
-/*******************************************************************
- * Have the DB print its information to the fp specified
- *******************************************************************/
-void
-osm_perfmgr_print_counters(osm_perfmgr_t *pm, char *nodename, FILE *fp)
-{
- uint64_t guid = strtoull(nodename, NULL, 0);
- if (guid == 0 && errno == EINVAL) {
- perfmgr_db_print_by_name(pm->db, nodename, fp);
- } else {
- perfmgr_db_print_by_guid(pm->db, guid, fp);
- }
-}
-
-#endif /* ENABLE_OSM_PERF_MGR */
diff --git a/contrib/ofed/management/opensm/opensm/osm_perfmgr_db.c b/contrib/ofed/management/opensm/opensm/osm_perfmgr_db.c
deleted file mode 100644
index 934be77..0000000
--- a/contrib/ofed/management/opensm/opensm/osm_perfmgr_db.c
+++ /dev/null
@@ -1,807 +0,0 @@
-/*
- * Copyright (c) 2008 Voltaire, Inc. All rights reserved.
- * Copyright (c) 2007 The Regents of the University of California.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- */
-
-#if HAVE_CONFIG_H
-# include <config.h>
-#endif /* HAVE_CONFIG_H */
-
-#ifdef ENABLE_OSM_PERF_MGR
-
-#include <stdlib.h>
-#include <errno.h>
-#include <limits.h>
-#include <dlfcn.h>
-#include <sys/stat.h>
-
-#include <opensm/osm_perfmgr_db.h>
-#include <opensm/osm_perfmgr.h>
-#include <opensm/osm_opensm.h>
-
-/** =========================================================================
- */
-perfmgr_db_t *perfmgr_db_construct(osm_perfmgr_t *perfmgr)
-{
- perfmgr_db_t *db = malloc(sizeof(*db));
- if (!db)
- return (NULL);
-
- cl_qmap_init(&(db->pc_data));
- cl_plock_construct(&(db->lock));
- cl_plock_init(&(db->lock));
- db->perfmgr = perfmgr;
- return ((void *)db);
-}
-
-/** =========================================================================
- */
-void perfmgr_db_destroy(perfmgr_db_t * db)
-{
- if (db) {
- cl_plock_destroy(&(db->lock));
- free(db);
- }
-}
-
-/**********************************************************************
- * Internal call db->lock should be held when calling
- **********************************************************************/
-static inline _db_node_t *_get(perfmgr_db_t * db, uint64_t guid)
-{
- cl_map_item_t *rc = cl_qmap_get(&(db->pc_data), guid);
- const cl_map_item_t *end = cl_qmap_end(&(db->pc_data));
-
- if (rc == end)
- return (NULL);
- return ((_db_node_t *) rc);
-}
-
-static inline perfmgr_db_err_t bad_node_port(_db_node_t * node, uint8_t port)
-{
- if (!node)
- return (PERFMGR_EVENT_DB_GUIDNOTFOUND);
- if (port == 0 || port >= node->num_ports)
- return (PERFMGR_EVENT_DB_PORTNOTFOUND);
- return (PERFMGR_EVENT_DB_SUCCESS);
-}
-
-/** =========================================================================
- */
-static _db_node_t *__malloc_node(uint64_t guid, uint8_t num_ports, char *name)
-{
- int i = 0;
- time_t cur_time = 0;
- _db_node_t *rc = malloc(sizeof(*rc));
- if (!rc)
- return (NULL);
-
- rc->ports = calloc(num_ports, sizeof(_db_port_t));
- if (!rc->ports)
- goto free_rc;
- rc->num_ports = num_ports;
- rc->node_guid = guid;
-
- cur_time = time(NULL);
- for (i = 0; i < num_ports; i++) {
- rc->ports[i].last_reset = cur_time;
- rc->ports[i].err_previous.time = cur_time;
- rc->ports[i].dc_previous.time = cur_time;
- }
- snprintf(rc->node_name, NODE_NAME_SIZE, "%s", name);
-
- return (rc);
-
-free_rc:
- free(rc);
- return (NULL);
-}
-
-/** =========================================================================
- */
-static void __free_node(_db_node_t * node)
-{
- if (!node)
- return;
- if (node->ports)
- free(node->ports);
- free(node);
-}
-
-/* insert nodes to the database */
-static perfmgr_db_err_t __insert(perfmgr_db_t * db, _db_node_t * node)
-{
- cl_map_item_t *rc = cl_qmap_insert(&(db->pc_data), node->node_guid,
- (cl_map_item_t *) node);
-
- if ((void *)rc != (void *)node)
- return (PERFMGR_EVENT_DB_FAIL);
- return (PERFMGR_EVENT_DB_SUCCESS);
-}
-
-/**********************************************************************
- **********************************************************************/
-perfmgr_db_err_t
-perfmgr_db_create_entry(perfmgr_db_t * db, uint64_t guid,
- uint8_t num_ports, char *name)
-{
- perfmgr_db_err_t rc = PERFMGR_EVENT_DB_SUCCESS;
-
- cl_plock_excl_acquire(&(db->lock));
- if (!_get(db, guid)) {
- _db_node_t *pc_node = __malloc_node(guid, num_ports, name);
- if (!pc_node) {
- rc = PERFMGR_EVENT_DB_NOMEM;
- goto Exit;
- }
- if (__insert(db, pc_node)) {
- __free_node(pc_node);
- rc = PERFMGR_EVENT_DB_FAIL;
- goto Exit;
- }
- }
-Exit:
- cl_plock_release(&(db->lock));
- return (rc);
-}
-
-/**********************************************************************
- * Dump a reading vs the previous reading to stdout
- **********************************************************************/
-static inline void
-debug_dump_err_reading(perfmgr_db_t * db, uint64_t guid, uint8_t port_num,
- _db_port_t * port, perfmgr_db_err_reading_t * cur)
-{
- osm_log_t *log = db->perfmgr->log;
-
- if (!osm_log_is_active(log, OSM_LOG_DEBUG))
- return; /* optimize this a bit */
-
- osm_log(log, OSM_LOG_DEBUG,
- "GUID 0x%" PRIx64 " Port %u:\n", guid, port_num);
- osm_log(log, OSM_LOG_DEBUG,
- "sym %" PRIu64 " <-- %" PRIu64 " (%" PRIu64 ")\n",
- cur->symbol_err_cnt, port->err_previous.symbol_err_cnt,
- port->err_total.symbol_err_cnt);
- osm_log(log, OSM_LOG_DEBUG,
- "ler %" PRIu64 " <-- %" PRIu64 " (%" PRIu64 ")\n",
- cur->link_err_recover, port->err_previous.link_err_recover,
- port->err_total.link_err_recover);
- osm_log(log, OSM_LOG_DEBUG,
- "ld %" PRIu64 " <-- %" PRIu64 " (%" PRIu64 ")\n",
- cur->link_downed, port->err_previous.link_downed,
- port->err_total.link_downed);
- osm_log(log, OSM_LOG_DEBUG,
- "re %" PRIu64 " <-- %" PRIu64 " (%" PRIu64 ")\n", cur->rcv_err,
- port->err_previous.rcv_err, port->err_total.rcv_err);
- osm_log(log, OSM_LOG_DEBUG,
- "rrp %" PRIu64 " <-- %" PRIu64 " (%" PRIu64 ")\n",
- cur->rcv_rem_phys_err, port->err_previous.rcv_rem_phys_err,
- port->err_total.rcv_rem_phys_err);
- osm_log(log, OSM_LOG_DEBUG,
- "rsr %" PRIu64 " <-- %" PRIu64 " (%" PRIu64 ")\n",
- cur->rcv_switch_relay_err,
- port->err_previous.rcv_switch_relay_err,
- port->err_total.rcv_switch_relay_err);
- osm_log(log, OSM_LOG_DEBUG,
- "xd %" PRIu64 " <-- %" PRIu64 " (%" PRIu64 ")\n",
- cur->xmit_discards, port->err_previous.xmit_discards,
- port->err_total.xmit_discards);
- osm_log(log, OSM_LOG_DEBUG,
- "xce %" PRIu64 " <-- %" PRIu64 " (%" PRIu64 ")\n",
- cur->xmit_constraint_err,
- port->err_previous.xmit_constraint_err,
- port->err_total.xmit_constraint_err);
- osm_log(log, OSM_LOG_DEBUG,
- "rce %" PRIu64 " <-- %" PRIu64 " (%" PRIu64 ")\n",
- cur->rcv_constraint_err, port->err_previous.rcv_constraint_err,
- port->err_total.rcv_constraint_err);
- osm_log(log, OSM_LOG_DEBUG,
- "li %" PRIu64 " <-- %" PRIu64 " (%" PRIu64 ")\n",
- cur->link_integrity, port->err_previous.link_integrity,
- port->err_total.link_integrity);
- osm_log(log, OSM_LOG_DEBUG,
- "bo %" PRIu64 " <-- %" PRIu64 " (%" PRIu64 ")\n",
- cur->buffer_overrun, port->err_previous.buffer_overrun,
- port->err_total.buffer_overrun);
- osm_log(log, OSM_LOG_DEBUG,
- "vld %" PRIu64 " <-- %" PRIu64 " (%" PRIu64 ")\n",
- cur->vl15_dropped, port->err_previous.vl15_dropped,
- port->err_total.vl15_dropped);
-}
-
-/**********************************************************************
- * perfmgr_db_err_reading_t functions
- **********************************************************************/
-perfmgr_db_err_t
-perfmgr_db_add_err_reading(perfmgr_db_t * db, uint64_t guid,
- uint8_t port, perfmgr_db_err_reading_t * reading)
-{
- _db_port_t *p_port = NULL;
- _db_node_t *node = NULL;
- perfmgr_db_err_reading_t *previous = NULL;
- perfmgr_db_err_t rc = PERFMGR_EVENT_DB_SUCCESS;
- osm_epi_pe_event_t epi_pe_data;
-
- cl_plock_excl_acquire(&(db->lock));
- node = _get(db, guid);
- if ((rc = bad_node_port(node, port)) != PERFMGR_EVENT_DB_SUCCESS)
- goto Exit;
-
- p_port = &(node->ports[port]);
- previous = &(node->ports[port].err_previous);
-
- debug_dump_err_reading(db, guid, port, p_port, reading);
-
- epi_pe_data.time_diff_s = (reading->time - previous->time);
- osm_epi_create_port_id(&(epi_pe_data.port_id), guid, port,
- node->node_name);
-
- /* calculate changes from previous reading */
- epi_pe_data.symbol_err_cnt =
- (reading->symbol_err_cnt - previous->symbol_err_cnt);
- p_port->err_total.symbol_err_cnt += epi_pe_data.symbol_err_cnt;
- epi_pe_data.link_err_recover =
- (reading->link_err_recover - previous->link_err_recover);
- p_port->err_total.link_err_recover += epi_pe_data.link_err_recover;
- epi_pe_data.link_downed =
- (reading->link_downed - previous->link_downed);
- p_port->err_total.link_downed += epi_pe_data.link_downed;
- epi_pe_data.rcv_err = (reading->rcv_err - previous->rcv_err);
- p_port->err_total.rcv_err += epi_pe_data.rcv_err;
- epi_pe_data.rcv_rem_phys_err =
- (reading->rcv_rem_phys_err - previous->rcv_rem_phys_err);
- p_port->err_total.rcv_rem_phys_err += epi_pe_data.rcv_rem_phys_err;
- epi_pe_data.rcv_switch_relay_err =
- (reading->rcv_switch_relay_err - previous->rcv_switch_relay_err);
- p_port->err_total.rcv_switch_relay_err +=
- epi_pe_data.rcv_switch_relay_err;
- epi_pe_data.xmit_discards =
- (reading->xmit_discards - previous->xmit_discards);
- p_port->err_total.xmit_discards += epi_pe_data.xmit_discards;
- epi_pe_data.xmit_constraint_err =
- (reading->xmit_constraint_err - previous->xmit_constraint_err);
- p_port->err_total.xmit_constraint_err +=
- epi_pe_data.xmit_constraint_err;
- epi_pe_data.rcv_constraint_err =
- (reading->rcv_constraint_err - previous->rcv_constraint_err);
- p_port->err_total.rcv_constraint_err += epi_pe_data.rcv_constraint_err;
- epi_pe_data.link_integrity =
- (reading->link_integrity - previous->link_integrity);
- p_port->err_total.link_integrity += epi_pe_data.link_integrity;
- epi_pe_data.buffer_overrun =
- (reading->buffer_overrun - previous->buffer_overrun);
- p_port->err_total.buffer_overrun += epi_pe_data.buffer_overrun;
- epi_pe_data.vl15_dropped =
- (reading->vl15_dropped - previous->vl15_dropped);
- p_port->err_total.vl15_dropped += epi_pe_data.vl15_dropped;
-
- p_port->err_previous = *reading;
-
- osm_opensm_report_event(db->perfmgr->osm, OSM_EVENT_ID_PORT_ERRORS,
- &epi_pe_data);
-
-Exit:
- cl_plock_release(&(db->lock));
- return (rc);
-}
-
-perfmgr_db_err_t perfmgr_db_get_prev_err(perfmgr_db_t * db, uint64_t guid,
- uint8_t port,
- perfmgr_db_err_reading_t * reading)
-{
- _db_node_t *node = NULL;
- perfmgr_db_err_t rc = PERFMGR_EVENT_DB_SUCCESS;
-
- cl_plock_acquire(&(db->lock));
-
- node = _get(db, guid);
- if ((rc = bad_node_port(node, port)) != PERFMGR_EVENT_DB_SUCCESS)
- goto Exit;
-
- *reading = node->ports[port].err_previous;
-
-Exit:
- cl_plock_release(&(db->lock));
- return (rc);
-}
-
-perfmgr_db_err_t
-perfmgr_db_clear_prev_err(perfmgr_db_t * db, uint64_t guid, uint8_t port)
-{
- _db_node_t *node = NULL;
- perfmgr_db_err_reading_t *previous = NULL;
- perfmgr_db_err_t rc = PERFMGR_EVENT_DB_SUCCESS;
-
- cl_plock_excl_acquire(&(db->lock));
- node = _get(db, guid);
- if ((rc = bad_node_port(node, port)) != PERFMGR_EVENT_DB_SUCCESS)
- goto Exit;
-
- previous = &(node->ports[port].err_previous);
-
- memset(previous, 0, sizeof(*previous));
- node->ports[port].err_previous.time = time(NULL);
-
-Exit:
- cl_plock_release(&(db->lock));
- return (rc);
-}
-
-static inline void
-debug_dump_dc_reading(perfmgr_db_t * db, uint64_t guid, uint8_t port_num,
- _db_port_t * port, perfmgr_db_data_cnt_reading_t * cur)
-{
- osm_log_t *log = db->perfmgr->log;
- if (!osm_log_is_active(log, OSM_LOG_DEBUG))
- return; /* optimize this a big */
-
- osm_log(log, OSM_LOG_DEBUG,
- "xd %" PRIu64 " <-- %" PRIu64 " (%" PRIu64 ")\n",
- cur->xmit_data, port->dc_previous.xmit_data,
- port->dc_total.xmit_data);
- osm_log(log, OSM_LOG_DEBUG,
- "rd %" PRIu64 " <-- %" PRIu64 " (%" PRIu64 ")\n", cur->rcv_data,
- port->dc_previous.rcv_data, port->dc_total.rcv_data);
- osm_log(log, OSM_LOG_DEBUG,
- "xp %" PRIu64 " <-- %" PRIu64 " (%" PRIu64 ")\n",
- cur->xmit_pkts, port->dc_previous.xmit_pkts,
- port->dc_total.xmit_pkts);
- osm_log(log, OSM_LOG_DEBUG,
- "rp %" PRIu64 " <-- %" PRIu64 " (%" PRIu64 ")\n", cur->rcv_pkts,
- port->dc_previous.rcv_pkts, port->dc_total.rcv_pkts);
-}
-
-/**********************************************************************
- * perfmgr_db_data_cnt_reading_t functions
- **********************************************************************/
-perfmgr_db_err_t
-perfmgr_db_add_dc_reading(perfmgr_db_t * db, uint64_t guid,
- uint8_t port, perfmgr_db_data_cnt_reading_t * reading)
-{
- _db_port_t *p_port = NULL;
- _db_node_t *node = NULL;
- perfmgr_db_data_cnt_reading_t *previous = NULL;
- perfmgr_db_err_t rc = PERFMGR_EVENT_DB_SUCCESS;
- osm_epi_dc_event_t epi_dc_data;
-
- cl_plock_excl_acquire(&(db->lock));
- node = _get(db, guid);
- if ((rc = bad_node_port(node, port)) != PERFMGR_EVENT_DB_SUCCESS)
- goto Exit;
-
- p_port = &(node->ports[port]);
- previous = &(node->ports[port].dc_previous);
-
- debug_dump_dc_reading(db, guid, port, p_port, reading);
-
- epi_dc_data.time_diff_s = (reading->time - previous->time);
- osm_epi_create_port_id(&(epi_dc_data.port_id), guid, port,
- node->node_name);
-
- /* calculate changes from previous reading */
- epi_dc_data.xmit_data = (reading->xmit_data - previous->xmit_data);
- p_port->dc_total.xmit_data += epi_dc_data.xmit_data;
- epi_dc_data.rcv_data = (reading->rcv_data - previous->rcv_data);
- p_port->dc_total.rcv_data += epi_dc_data.rcv_data;
- epi_dc_data.xmit_pkts = (reading->xmit_pkts - previous->xmit_pkts);
- p_port->dc_total.xmit_pkts += epi_dc_data.xmit_pkts;
- epi_dc_data.rcv_pkts = (reading->rcv_pkts - previous->rcv_pkts);
- p_port->dc_total.rcv_pkts += epi_dc_data.rcv_pkts;
- epi_dc_data.unicast_xmit_pkts =
- (reading->unicast_xmit_pkts - previous->unicast_xmit_pkts);
- p_port->dc_total.unicast_xmit_pkts += epi_dc_data.unicast_xmit_pkts;
- epi_dc_data.unicast_rcv_pkts =
- (reading->unicast_rcv_pkts - previous->unicast_rcv_pkts);
- p_port->dc_total.unicast_rcv_pkts += epi_dc_data.unicast_rcv_pkts;
- epi_dc_data.multicast_xmit_pkts =
- (reading->multicast_xmit_pkts - previous->multicast_xmit_pkts);
- p_port->dc_total.multicast_xmit_pkts += epi_dc_data.multicast_xmit_pkts;
- epi_dc_data.multicast_rcv_pkts =
- (reading->multicast_rcv_pkts - previous->multicast_rcv_pkts);
- p_port->dc_total.multicast_rcv_pkts += epi_dc_data.multicast_rcv_pkts;
-
- p_port->dc_previous = *reading;
-
- osm_opensm_report_event(db->perfmgr->osm,
- OSM_EVENT_ID_PORT_DATA_COUNTERS, &epi_dc_data);
-
-Exit:
- cl_plock_release(&(db->lock));
- return (rc);
-}
-
-perfmgr_db_err_t perfmgr_db_get_prev_dc(perfmgr_db_t * db, uint64_t guid,
- uint8_t port,
- perfmgr_db_data_cnt_reading_t * reading)
-{
- _db_node_t *node = NULL;
- perfmgr_db_err_t rc = PERFMGR_EVENT_DB_SUCCESS;
-
- cl_plock_acquire(&(db->lock));
-
- node = _get(db, guid);
- if ((rc = bad_node_port(node, port)) != PERFMGR_EVENT_DB_SUCCESS)
- goto Exit;
-
- *reading = node->ports[port].dc_previous;
-
-Exit:
- cl_plock_release(&(db->lock));
- return (rc);
-}
-
-perfmgr_db_err_t
-perfmgr_db_clear_prev_dc(perfmgr_db_t * db, uint64_t guid, uint8_t port)
-{
- _db_node_t *node = NULL;
- perfmgr_db_data_cnt_reading_t *previous = NULL;
- perfmgr_db_err_t rc = PERFMGR_EVENT_DB_SUCCESS;
-
- cl_plock_excl_acquire(&(db->lock));
- node = _get(db, guid);
- if ((rc = bad_node_port(node, port)) != PERFMGR_EVENT_DB_SUCCESS)
- goto Exit;
-
- previous = &(node->ports[port].dc_previous);
-
- memset(previous, 0, sizeof(*previous));
- node->ports[port].dc_previous.time = time(NULL);
-
-Exit:
- cl_plock_release(&(db->lock));
- return (rc);
-}
-
-static void __clear_counters(cl_map_item_t * const p_map_item, void *context)
-{
- _db_node_t *node = (_db_node_t *) p_map_item;
- int i = 0;
- time_t ts = time(NULL);
-
- for (i = 0; i < node->num_ports; i++) {
- node->ports[i].err_total.symbol_err_cnt = 0;
- node->ports[i].err_total.link_err_recover = 0;
- node->ports[i].err_total.link_downed = 0;
- node->ports[i].err_total.rcv_err = 0;
- node->ports[i].err_total.rcv_rem_phys_err = 0;
- node->ports[i].err_total.rcv_switch_relay_err = 0;
- node->ports[i].err_total.xmit_discards = 0;
- node->ports[i].err_total.xmit_constraint_err = 0;
- node->ports[i].err_total.rcv_constraint_err = 0;
- node->ports[i].err_total.link_integrity = 0;
- node->ports[i].err_total.buffer_overrun = 0;
- node->ports[i].err_total.vl15_dropped = 0;
- node->ports[i].err_total.time = ts;
-
- node->ports[i].dc_total.xmit_data = 0;
- node->ports[i].dc_total.rcv_data = 0;
- node->ports[i].dc_total.xmit_pkts = 0;
- node->ports[i].dc_total.rcv_pkts = 0;
- node->ports[i].dc_total.unicast_xmit_pkts = 0;
- node->ports[i].dc_total.unicast_rcv_pkts = 0;
- node->ports[i].dc_total.multicast_xmit_pkts = 0;
- node->ports[i].dc_total.multicast_rcv_pkts = 0;
- node->ports[i].dc_total.time = ts;
-
- node->ports[i].last_reset = ts;
- }
-}
-
-/**********************************************************************
- * Clear all the counters from the db
- **********************************************************************/
-void perfmgr_db_clear_counters(perfmgr_db_t * db)
-{
- cl_plock_excl_acquire(&(db->lock));
- cl_qmap_apply_func(&(db->pc_data), __clear_counters, (void *)db);
- cl_plock_release(&(db->lock));
-#if 0
- if (db->db_impl->clear_counters)
- db->db_impl->clear_counters(db->db_data);
-#endif
-}
-
-/**********************************************************************
- * Output a tab delimited output of the port counters
- **********************************************************************/
-static void __dump_node_mr(_db_node_t * node, FILE * fp)
-{
- int i = 0;
-
- fprintf(fp, "\nName\tGUID\tPort\tLast Reset\t"
- "%s\t%s\t"
- "%s\t%s\t%s\t%s\t%s\t%s\t%s\t"
- "%s\t%s\t%s\t%s\t%s\t%s\t%s\t"
- "%s\t%s\t%s\t%s\n",
- "symbol_err_cnt",
- "link_err_recover",
- "link_downed",
- "rcv_err",
- "rcv_rem_phys_err",
- "rcv_switch_relay_err",
- "xmit_discards",
- "xmit_constraint_err",
- "rcv_constraint_err",
- "link_int_err",
- "buf_overrun_err",
- "vl15_dropped",
- "xmit_data",
- "rcv_data",
- "xmit_pkts",
- "rcv_pkts",
- "unicast_xmit_pkts",
- "unicast_rcv_pkts",
- "multicast_xmit_pkts", "multicast_rcv_pkts");
- for (i = 1; i < node->num_ports; i++) {
- char *since = ctime(&(node->ports[i].last_reset));
- since[strlen(since) - 1] = '\0'; /* remove \n */
-
- fprintf(fp,
- "%s\t0x%" PRIx64 "\t%d\t%s\t%" PRIu64 "\t%" PRIu64 "\t"
- "%" PRIu64 "\t%" PRIu64 "\t%" PRIu64 "\t%" PRIu64 "\t"
- "%" PRIu64 "\t%" PRIu64 "\t%" PRIu64 "\t" "%" PRIu64
- "\t%" PRIu64 "\t%" PRIu64 "\t" "%" PRIu64 "\t%" PRIu64
- "\t%" PRIu64 "\t%" PRIu64 "\t" "%" PRIu64 "\t%" PRIu64
- "\t%" PRIu64 "\t%" PRIu64 "\n", node->node_name,
- node->node_guid, i, since,
- node->ports[i].err_total.symbol_err_cnt,
- node->ports[i].err_total.link_err_recover,
- node->ports[i].err_total.link_downed,
- node->ports[i].err_total.rcv_err,
- node->ports[i].err_total.rcv_rem_phys_err,
- node->ports[i].err_total.rcv_switch_relay_err,
- node->ports[i].err_total.xmit_discards,
- node->ports[i].err_total.xmit_constraint_err,
- node->ports[i].err_total.rcv_constraint_err,
- node->ports[i].err_total.link_integrity,
- node->ports[i].err_total.buffer_overrun,
- node->ports[i].err_total.vl15_dropped,
- node->ports[i].dc_total.xmit_data,
- node->ports[i].dc_total.rcv_data,
- node->ports[i].dc_total.xmit_pkts,
- node->ports[i].dc_total.rcv_pkts,
- node->ports[i].dc_total.unicast_xmit_pkts,
- node->ports[i].dc_total.unicast_rcv_pkts,
- node->ports[i].dc_total.multicast_xmit_pkts,
- node->ports[i].dc_total.multicast_rcv_pkts);
- }
-}
-
-/**********************************************************************
- * Output a human readable output of the port counters
- **********************************************************************/
-static void __dump_node_hr(_db_node_t * node, FILE * fp)
-{
- int i = 0;
-
- fprintf(fp, "\n");
- for (i = 1; i < node->num_ports; i++) {
- char *since = ctime(&(node->ports[i].last_reset));
- since[strlen(since) - 1] = '\0'; /* remove \n */
-
- fprintf(fp, "\"%s\" 0x%" PRIx64 " port %d (Since %s)\n"
- " symbol_err_cnt : %" PRIu64 "\n"
- " link_err_recover : %" PRIu64 "\n"
- " link_downed : %" PRIu64 "\n"
- " rcv_err : %" PRIu64 "\n"
- " rcv_rem_phys_err : %" PRIu64 "\n"
- " rcv_switch_relay_err : %" PRIu64 "\n"
- " xmit_discards : %" PRIu64 "\n"
- " xmit_constraint_err : %" PRIu64 "\n"
- " rcv_constraint_err : %" PRIu64 "\n"
- " link_integrity_err : %" PRIu64 "\n"
- " buf_overrun_err : %" PRIu64 "\n"
- " vl15_dropped : %" PRIu64 "\n"
- " xmit_data : %" PRIu64 "\n"
- " rcv_data : %" PRIu64 "\n"
- " xmit_pkts : %" PRIu64 "\n"
- " rcv_pkts : %" PRIu64 "\n"
- " unicast_xmit_pkts : %" PRIu64 "\n"
- " unicast_rcv_pkts : %" PRIu64 "\n"
- " multicast_xmit_pkts : %" PRIu64 "\n"
- " multicast_rcv_pkts : %" PRIu64 "\n",
- node->node_name,
- node->node_guid,
- i,
- since,
- node->ports[i].err_total.symbol_err_cnt,
- node->ports[i].err_total.link_err_recover,
- node->ports[i].err_total.link_downed,
- node->ports[i].err_total.rcv_err,
- node->ports[i].err_total.rcv_rem_phys_err,
- node->ports[i].err_total.rcv_switch_relay_err,
- node->ports[i].err_total.xmit_discards,
- node->ports[i].err_total.xmit_constraint_err,
- node->ports[i].err_total.rcv_constraint_err,
- node->ports[i].err_total.link_integrity,
- node->ports[i].err_total.buffer_overrun,
- node->ports[i].err_total.vl15_dropped,
- node->ports[i].dc_total.xmit_data,
- node->ports[i].dc_total.rcv_data,
- node->ports[i].dc_total.xmit_pkts,
- node->ports[i].dc_total.rcv_pkts,
- node->ports[i].dc_total.unicast_xmit_pkts,
- node->ports[i].dc_total.unicast_rcv_pkts,
- node->ports[i].dc_total.multicast_xmit_pkts,
- node->ports[i].dc_total.multicast_rcv_pkts);
- }
-}
-
-/* Define a context for the __db_dump callback */
-typedef struct {
- FILE *fp;
- perfmgr_db_dump_t dump_type;
-} dump_context_t;
-
-/**********************************************************************
- **********************************************************************/
-static void __db_dump(cl_map_item_t * const p_map_item, void *context)
-{
- _db_node_t *node = (_db_node_t *) p_map_item;
- dump_context_t *c = (dump_context_t *) context;
- FILE *fp = c->fp;
-
- switch (c->dump_type) {
- case PERFMGR_EVENT_DB_DUMP_MR:
- __dump_node_mr(node, fp);
- break;
- case PERFMGR_EVENT_DB_DUMP_HR:
- default:
- __dump_node_hr(node, fp);
- break;
- }
-}
-
-/**********************************************************************
- * print node data to fp
- **********************************************************************/
-void
-perfmgr_db_print_by_name(perfmgr_db_t * db, char *nodename, FILE *fp)
-{
- cl_map_item_t *item = NULL;
- _db_node_t *node = NULL;
-
- cl_plock_acquire(&(db->lock));
-
- /* find the node */
- item = cl_qmap_head(&(db->pc_data));
- while (item != cl_qmap_end(&(db->pc_data))) {
- node = (_db_node_t *)item;
- if (strcmp(node->node_name, nodename) == 0) {
- __dump_node_hr(node, fp);
- goto done;
- }
- item = cl_qmap_next(item);
- }
-
- fprintf(fp, "Node %s not found...\n", nodename);
-done:
- cl_plock_release(&(db->lock));
-}
-
-/**********************************************************************
- * print node data to fp
- **********************************************************************/
-void
-perfmgr_db_print_by_guid(perfmgr_db_t * db, uint64_t nodeguid, FILE *fp)
-{
- cl_map_item_t *node = NULL;
-
- cl_plock_acquire(&(db->lock));
-
- node = cl_qmap_get(&(db->pc_data), nodeguid);
- if (node != cl_qmap_end(&(db->pc_data)))
- __dump_node_hr((_db_node_t *)node, fp);
- else
- fprintf(fp, "Node %"PRIx64" not found...\n", nodeguid);
-
- cl_plock_release(&(db->lock));
-}
-
-/**********************************************************************
- * dump the data to the file "file"
- **********************************************************************/
-perfmgr_db_err_t
-perfmgr_db_dump(perfmgr_db_t * db, char *file, perfmgr_db_dump_t dump_type)
-{
- dump_context_t context;
-
- context.fp = fopen(file, "w+");
- if (!context.fp)
- return (PERFMGR_EVENT_DB_FAIL);
- context.dump_type = dump_type;
-
- cl_plock_acquire(&(db->lock));
- cl_qmap_apply_func(&(db->pc_data), __db_dump, (void *)&context);
- cl_plock_release(&(db->lock));
- fclose(context.fp);
- return (PERFMGR_EVENT_DB_SUCCESS);
-}
-
-/**********************************************************************
- * Fill in the various DB objects from their wire counter parts
- **********************************************************************/
-void
-perfmgr_db_fill_err_read(ib_port_counters_t * wire_read,
- perfmgr_db_err_reading_t * reading)
-{
- reading->symbol_err_cnt = cl_ntoh16(wire_read->symbol_err_cnt);
- reading->link_err_recover = cl_ntoh16(wire_read->link_err_recover);
- reading->link_downed = wire_read->link_downed;
- reading->rcv_err = wire_read->rcv_err;
- reading->rcv_rem_phys_err = cl_ntoh16(wire_read->rcv_rem_phys_err);
- reading->rcv_switch_relay_err =
- cl_ntoh16(wire_read->rcv_switch_relay_err);
- reading->xmit_discards = cl_ntoh16(wire_read->xmit_discards);
- reading->xmit_constraint_err =
- cl_ntoh16(wire_read->xmit_constraint_err);
- reading->rcv_constraint_err = wire_read->rcv_constraint_err;
- reading->link_integrity =
- PC_LINK_INT(wire_read->link_int_buffer_overrun);
- reading->buffer_overrun =
- PC_BUF_OVERRUN(wire_read->link_int_buffer_overrun);
- reading->vl15_dropped = cl_ntoh16(wire_read->vl15_dropped);
- reading->time = time(NULL);
-}
-
-void
-perfmgr_db_fill_data_cnt_read_pc(ib_port_counters_t * wire_read,
- perfmgr_db_data_cnt_reading_t * reading)
-{
- reading->xmit_data = cl_ntoh32(wire_read->xmit_data);
- reading->rcv_data = cl_ntoh32(wire_read->rcv_data);
- reading->xmit_pkts = cl_ntoh32(wire_read->xmit_pkts);
- reading->rcv_pkts = cl_ntoh32(wire_read->rcv_pkts);
- reading->unicast_xmit_pkts = 0;
- reading->unicast_rcv_pkts = 0;
- reading->multicast_xmit_pkts = 0;
- reading->multicast_rcv_pkts = 0;
- reading->time = time(NULL);
-}
-
-void
-perfmgr_db_fill_data_cnt_read_epc(ib_port_counters_ext_t * wire_read,
- perfmgr_db_data_cnt_reading_t * reading)
-{
- reading->xmit_data = cl_ntoh64(wire_read->xmit_data);
- reading->rcv_data = cl_ntoh64(wire_read->rcv_data);
- reading->xmit_pkts = cl_ntoh64(wire_read->xmit_pkts);
- reading->rcv_pkts = cl_ntoh64(wire_read->rcv_pkts);
- reading->unicast_xmit_pkts = cl_ntoh64(wire_read->unicast_xmit_pkts);
- reading->unicast_rcv_pkts = cl_ntoh64(wire_read->unicast_rcv_pkts);
- reading->multicast_xmit_pkts =
- cl_ntoh64(wire_read->multicast_xmit_pkts);
- reading->multicast_rcv_pkts = cl_ntoh64(wire_read->multicast_rcv_pkts);
- reading->time = time(NULL);
-}
-#endif /* ENABLE_OSM_PERF_MGR */
diff --git a/contrib/ofed/management/opensm/opensm/osm_pkey.c b/contrib/ofed/management/opensm/opensm/osm_pkey.c
deleted file mode 100644
index 4666186..0000000
--- a/contrib/ofed/management/opensm/opensm/osm_pkey.c
+++ /dev/null
@@ -1,467 +0,0 @@
-/*
- * Copyright (c) 2004-2008 Voltaire, Inc. All rights reserved.
- * Copyright (c) 2002-2006 Mellanox Technologies LTD. All rights reserved.
- * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- */
-
-/*
- * Abstract:
- * Implementation of opensm pkey manipulation functions.
- */
-
-#if HAVE_CONFIG_H
-# include <config.h>
-#endif /* HAVE_CONFIG_H */
-
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-#include <complib/cl_debug.h>
-#include <iba/ib_types.h>
-#include <opensm/osm_pkey.h>
-#include <opensm/osm_log.h>
-#include <opensm/osm_port.h>
-#include <opensm/osm_node.h>
-#include <opensm/osm_switch.h>
-#include <opensm/osm_helper.h>
-
-/**********************************************************************
- **********************************************************************/
-void osm_pkey_tbl_construct(IN osm_pkey_tbl_t * p_pkey_tbl)
-{
- cl_ptr_vector_construct(&p_pkey_tbl->blocks);
- cl_ptr_vector_construct(&p_pkey_tbl->new_blocks);
- cl_map_construct(&p_pkey_tbl->keys);
-}
-
-/**********************************************************************
- **********************************************************************/
-void osm_pkey_tbl_destroy(IN osm_pkey_tbl_t * p_pkey_tbl)
-{
- ib_pkey_table_t *p_block;
- uint16_t num_blocks, i;
-
- num_blocks = (uint16_t) (cl_ptr_vector_get_size(&p_pkey_tbl->blocks));
- for (i = 0; i < num_blocks; i++)
- if ((p_block = cl_ptr_vector_get(&p_pkey_tbl->blocks, i)))
- free(p_block);
- cl_ptr_vector_destroy(&p_pkey_tbl->blocks);
-
- num_blocks =
- (uint16_t) (cl_ptr_vector_get_size(&p_pkey_tbl->new_blocks));
- for (i = 0; i < num_blocks; i++)
- if ((p_block = cl_ptr_vector_get(&p_pkey_tbl->new_blocks, i)))
- free(p_block);
- cl_ptr_vector_destroy(&p_pkey_tbl->new_blocks);
-
- cl_map_remove_all(&p_pkey_tbl->keys);
- cl_map_destroy(&p_pkey_tbl->keys);
-}
-
-/**********************************************************************
- **********************************************************************/
-ib_api_status_t osm_pkey_tbl_init(IN osm_pkey_tbl_t * p_pkey_tbl)
-{
- cl_ptr_vector_init(&p_pkey_tbl->blocks, 0, 1);
- cl_ptr_vector_init(&p_pkey_tbl->new_blocks, 0, 1);
- cl_map_init(&p_pkey_tbl->keys, 1);
- cl_qlist_init(&p_pkey_tbl->pending);
- p_pkey_tbl->used_blocks = 0;
- p_pkey_tbl->max_blocks = 0;
- return (IB_SUCCESS);
-}
-
-/**********************************************************************
- **********************************************************************/
-void osm_pkey_tbl_init_new_blocks(IN const osm_pkey_tbl_t * p_pkey_tbl)
-{
- ib_pkey_table_t *p_block;
- size_t b, num_blocks = cl_ptr_vector_get_size(&p_pkey_tbl->new_blocks);
-
- for (b = 0; b < num_blocks; b++)
- if ((p_block = cl_ptr_vector_get(&p_pkey_tbl->new_blocks, b)))
- memset(p_block, 0, sizeof(*p_block));
-}
-
-/**********************************************************************
- **********************************************************************/
-void osm_pkey_tbl_cleanup_pending(IN osm_pkey_tbl_t * p_pkey_tbl)
-{
- cl_list_item_t *p_item;
-
- p_item = cl_qlist_remove_head(&p_pkey_tbl->pending);
- while (p_item != cl_qlist_end(&p_pkey_tbl->pending)) {
- free((osm_pending_pkey_t *) p_item);
- }
-}
-
-/**********************************************************************
- **********************************************************************/
-ib_api_status_t
-osm_pkey_tbl_set(IN osm_pkey_tbl_t * p_pkey_tbl,
- IN uint16_t block, IN ib_pkey_table_t * p_tbl)
-{
- uint16_t b, i;
- ib_pkey_table_t *p_pkey_block;
- uint16_t *p_prev_pkey;
- ib_net16_t pkey;
-
- /* make sure the block is allocated */
- if (cl_ptr_vector_get_size(&p_pkey_tbl->blocks) > block)
- p_pkey_block =
- (ib_pkey_table_t *) cl_ptr_vector_get(&p_pkey_tbl->blocks,
- block);
- else
- p_pkey_block = NULL;
-
- if (!p_pkey_block) {
- p_pkey_block =
- (ib_pkey_table_t *) malloc(sizeof(ib_pkey_table_t));
- if (!p_pkey_block)
- return (IB_ERROR);
- memset(p_pkey_block, 0, sizeof(ib_pkey_table_t));
- cl_ptr_vector_set(&p_pkey_tbl->blocks, block, p_pkey_block);
- }
-
- /* sets the block values */
- memcpy(p_pkey_block, p_tbl, sizeof(ib_pkey_table_t));
-
- /*
- NOTE: as the spec does not require uniqueness of PKeys in
- tables there is no other way but to refresh the entire keys map.
-
- Moreover, if the same key exists but with full membership it should
- have precedence on the key with limited membership !
- */
- cl_map_remove_all(&p_pkey_tbl->keys);
-
- for (b = 0; b < cl_ptr_vector_get_size(&p_pkey_tbl->blocks); b++) {
-
- p_pkey_block = cl_ptr_vector_get(&p_pkey_tbl->blocks, b);
- if (!p_pkey_block)
- continue;
-
- for (i = 0; i < IB_NUM_PKEY_ELEMENTS_IN_BLOCK; i++) {
- pkey = p_pkey_block->pkey_entry[i];
- if (ib_pkey_is_invalid(pkey))
- continue;
-
- /*
- ignore the PKey Full Member bit in the key but store
- the pointer to the table element as the map value
- */
- p_prev_pkey =
- cl_map_get(&p_pkey_tbl->keys,
- ib_pkey_get_base(pkey));
-
- /* we only insert if no previous or it is not full member */
- if ((p_prev_pkey == NULL) ||
- (cl_ntoh16(*p_prev_pkey) < cl_ntoh16(pkey)))
- cl_map_insert(&p_pkey_tbl->keys,
- ib_pkey_get_base(pkey),
- &(p_pkey_block->pkey_entry[i])
- );
- }
- }
- return (IB_SUCCESS);
-}
-
-/**********************************************************************
- **********************************************************************/
-/*
- Store the given pkey in the "new" blocks array.
- Also, make sure the regular block exists.
-*/
-ib_api_status_t
-osm_pkey_tbl_set_new_entry(IN osm_pkey_tbl_t * p_pkey_tbl,
- IN uint16_t block_idx,
- IN uint8_t pkey_idx, IN uint16_t pkey)
-{
- ib_pkey_table_t *p_block;
-
- if (!(p_block = osm_pkey_tbl_new_block_get(p_pkey_tbl, block_idx))) {
- p_block = (ib_pkey_table_t *) malloc(sizeof(ib_pkey_table_t));
- if (!p_block)
- return (IB_ERROR);
- memset(p_block, 0, sizeof(ib_pkey_table_t));
- cl_ptr_vector_set(&p_pkey_tbl->new_blocks, block_idx, p_block);
- }
-
- p_block->pkey_entry[pkey_idx] = pkey;
- if (p_pkey_tbl->used_blocks <= block_idx)
- p_pkey_tbl->used_blocks = block_idx + 1;
-
- return (IB_SUCCESS);
-}
-
-/**********************************************************************
- **********************************************************************/
-boolean_t
-osm_pkey_find_next_free_entry(IN osm_pkey_tbl_t * p_pkey_tbl,
- OUT uint16_t * p_block_idx,
- OUT uint8_t * p_pkey_idx)
-{
- ib_pkey_table_t *p_new_block;
-
- CL_ASSERT(p_block_idx);
- CL_ASSERT(p_pkey_idx);
-
- while (*p_block_idx < p_pkey_tbl->max_blocks) {
- if (*p_pkey_idx > IB_NUM_PKEY_ELEMENTS_IN_BLOCK - 1) {
- *p_pkey_idx = 0;
- (*p_block_idx)++;
- if (*p_block_idx >= p_pkey_tbl->max_blocks)
- return FALSE;
- }
-
- p_new_block =
- osm_pkey_tbl_new_block_get(p_pkey_tbl, *p_block_idx);
-
- if (!p_new_block ||
- ib_pkey_is_invalid(p_new_block->pkey_entry[*p_pkey_idx]))
- return TRUE;
- else
- (*p_pkey_idx)++;
- }
- return FALSE;
-}
-
-/**********************************************************************
- **********************************************************************/
-ib_api_status_t
-osm_pkey_tbl_get_block_and_idx(IN osm_pkey_tbl_t * p_pkey_tbl,
- IN uint16_t * p_pkey,
- OUT uint16_t * p_block_idx,
- OUT uint8_t * p_pkey_idx)
-{
- uint16_t num_of_blocks;
- uint16_t block_index;
- ib_pkey_table_t *block;
-
- CL_ASSERT(p_block_idx != NULL);
- CL_ASSERT(p_pkey_idx != NULL);
-
- num_of_blocks = (uint16_t) cl_ptr_vector_get_size(&p_pkey_tbl->blocks);
- for (block_index = 0; block_index < num_of_blocks; block_index++) {
- block = osm_pkey_tbl_block_get(p_pkey_tbl, block_index);
- if ((block->pkey_entry <= p_pkey) &&
- (p_pkey <
- block->pkey_entry + IB_NUM_PKEY_ELEMENTS_IN_BLOCK)) {
- *p_block_idx = block_index;
- *p_pkey_idx = (uint8_t) (p_pkey - block->pkey_entry);
- return (IB_SUCCESS);
- }
- }
- return (IB_NOT_FOUND);
-}
-
-/**********************************************************************
- **********************************************************************/
-static boolean_t
-__osm_match_pkey(IN const ib_net16_t * pkey1, IN const ib_net16_t * pkey2)
-{
-
- /* if both pkeys are not full member - this is not a match */
- if (!(ib_pkey_is_full_member(*pkey1) || ib_pkey_is_full_member(*pkey2)))
- return (FALSE);
-
- /* compare if the bases are the same. if they are - then
- this is a match */
- if (ib_pkey_get_base(*pkey1) != ib_pkey_get_base(*pkey2))
- return (FALSE);
-
- return (TRUE);
-}
-
-/**********************************************************************
- **********************************************************************/
-boolean_t
-osm_physp_share_this_pkey(IN const osm_physp_t * const p_physp1,
- IN const osm_physp_t * const p_physp2,
- IN const ib_net16_t pkey)
-{
- ib_net16_t *pkey1, *pkey2;
-
- pkey1 = cl_map_get(&(osm_physp_get_pkey_tbl(p_physp1))->keys,
- ib_pkey_get_base(pkey));
- pkey2 = cl_map_get(&(osm_physp_get_pkey_tbl(p_physp2))->keys,
- ib_pkey_get_base(pkey));
- return (pkey1 && pkey2 && __osm_match_pkey(pkey1, pkey2));
-}
-
-/**********************************************************************
- **********************************************************************/
-ib_net16_t
-osm_physp_find_common_pkey(IN const osm_physp_t * const p_physp1,
- IN const osm_physp_t * const p_physp2)
-{
- ib_net16_t *pkey1, *pkey2;
- uint64_t pkey1_base, pkey2_base;
- const osm_pkey_tbl_t *pkey_tbl1, *pkey_tbl2;
- cl_map_iterator_t map_iter1, map_iter2;
-
- pkey_tbl1 = osm_physp_get_pkey_tbl(p_physp1);
- pkey_tbl2 = osm_physp_get_pkey_tbl(p_physp2);
-
- map_iter1 = cl_map_head(&pkey_tbl1->keys);
- map_iter2 = cl_map_head(&pkey_tbl2->keys);
-
- /* we rely on the fact the map are sorted by pkey */
- while ((map_iter1 != cl_map_end(&pkey_tbl1->keys)) &&
- (map_iter2 != cl_map_end(&pkey_tbl2->keys))) {
- pkey1 = (ib_net16_t *) cl_map_obj(map_iter1);
- pkey2 = (ib_net16_t *) cl_map_obj(map_iter2);
-
- if (__osm_match_pkey(pkey1, pkey2))
- return *pkey1;
-
- /* advance the lower value if they are not equal */
- pkey1_base = cl_map_key(map_iter1);
- pkey2_base = cl_map_key(map_iter2);
- if (pkey2_base == pkey1_base) {
- map_iter1 = cl_map_next(map_iter1);
- map_iter2 = cl_map_next(map_iter2);
- } else if (pkey2_base < pkey1_base)
- map_iter2 = cl_map_next(map_iter2);
- else
- map_iter1 = cl_map_next(map_iter1);
- }
-
- return 0;
-}
-
-/**********************************************************************
- **********************************************************************/
-boolean_t
-osm_physp_share_pkey(IN osm_log_t * p_log,
- IN const osm_physp_t * const p_physp_1,
- IN const osm_physp_t * const p_physp_2)
-{
- const osm_pkey_tbl_t *pkey_tbl1, *pkey_tbl2;
-
- if (p_physp_1 == p_physp_2)
- return TRUE;
-
- pkey_tbl1 = osm_physp_get_pkey_tbl(p_physp_1);
- pkey_tbl2 = osm_physp_get_pkey_tbl(p_physp_2);
-
- /*
- The spec: 10.9.2 does not require each phys port to have PKey Table.
- So actually if it does not, we need to use the default port instead.
-
- HACK: meanwhile we will ignore the check
- */
- if (cl_is_map_empty(&pkey_tbl1->keys)
- || cl_is_map_empty(&pkey_tbl2->keys))
- return TRUE;
-
- return
- !ib_pkey_is_invalid(osm_physp_find_common_pkey
- (p_physp_1, p_physp_2));
-}
-
-/**********************************************************************
- **********************************************************************/
-boolean_t
-osm_port_share_pkey(IN osm_log_t * p_log,
- IN const osm_port_t * const p_port_1,
- IN const osm_port_t * const p_port_2)
-{
-
- osm_physp_t *p_physp1, *p_physp2;
- boolean_t ret;
-
- OSM_LOG_ENTER(p_log);
-
- if (!p_port_1 || !p_port_2) {
- ret = FALSE;
- goto Exit;
- }
-
- p_physp1 = p_port_1->p_physp;
- p_physp2 = p_port_2->p_physp;
-
- if (!p_physp1 || !p_physp2) {
- ret = FALSE;
- goto Exit;
- }
-
- ret = osm_physp_share_pkey(p_log, p_physp1, p_physp2);
-
-Exit:
- OSM_LOG_EXIT(p_log);
- return ret;
-}
-
-/**********************************************************************
- **********************************************************************/
-boolean_t
-osm_physp_has_pkey(IN osm_log_t * p_log,
- IN const ib_net16_t pkey,
- IN const osm_physp_t * const p_physp)
-{
-
- ib_net16_t *p_pkey, pkey_base;
- const osm_pkey_tbl_t *pkey_tbl;
- boolean_t res = FALSE;
-
- OSM_LOG_ENTER(p_log);
-
- OSM_LOG(p_log, OSM_LOG_DEBUG,
- "Search for PKey: 0x%04x\n", cl_ntoh16(pkey));
-
- /* if the pkey given is an invalid pkey - return TRUE. */
- if (ib_pkey_is_invalid(pkey)) {
- OSM_LOG(p_log, OSM_LOG_DEBUG,
- "Given invalid PKey - we treat it loosely and allow it\n");
- res = TRUE;
- goto Exit;
- }
-
- pkey_base = ib_pkey_get_base(pkey);
-
- pkey_tbl = osm_physp_get_pkey_tbl(p_physp);
-
- p_pkey = cl_map_get(&pkey_tbl->keys, pkey_base);
- if (p_pkey) {
- res = TRUE;
- OSM_LOG(p_log, OSM_LOG_DEBUG,
- "PKey 0x%04x was found\n", cl_ntoh16(pkey));
- } else {
- OSM_LOG(p_log, OSM_LOG_DEBUG,
- "PKey 0x%04x was not found\n", cl_ntoh16(pkey));
- }
-
-Exit:
- OSM_LOG_EXIT(p_log);
- return res;
-}
diff --git a/contrib/ofed/management/opensm/opensm/osm_pkey_mgr.c b/contrib/ofed/management/opensm/opensm/osm_pkey_mgr.c
deleted file mode 100644
index ae16eb6..0000000
--- a/contrib/ofed/management/opensm/opensm/osm_pkey_mgr.c
+++ /dev/null
@@ -1,528 +0,0 @@
-/*
- * Copyright (c) 2004-2008 Voltaire, Inc. All rights reserved.
- * Copyright (c) 2002-2006 Mellanox Technologies LTD. All rights reserved.
- * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- */
-
-/*
- * Abstract:
- * Implementation of the P_Key Manager (Partititon Manager).
- * This is part of the OpenSM.
- */
-
-#if HAVE_CONFIG_H
-# include <config.h>
-#endif /* HAVE_CONFIG_H */
-
-#include <string.h>
-#include <iba/ib_types.h>
-#include <complib/cl_qmap.h>
-#include <complib/cl_debug.h>
-#include <opensm/osm_node.h>
-#include <opensm/osm_switch.h>
-#include <opensm/osm_partition.h>
-#include <opensm/osm_opensm.h>
-
-/**********************************************************************
- **********************************************************************/
-/*
- The max number of pkey blocks for a physical port is located in
- a different place for switch external ports (SwitchInfo) and the
- rest of the ports (NodeInfo).
-*/
-static uint16_t
-pkey_mgr_get_physp_max_blocks(IN const osm_subn_t * p_subn,
- IN const osm_physp_t * p_physp)
-{
- osm_node_t *p_node = osm_physp_get_node_ptr(p_physp);
- uint16_t num_pkeys = 0;
-
- if (!p_node->sw || (osm_physp_get_port_num(p_physp) == 0))
- num_pkeys = cl_ntoh16(p_node->node_info.partition_cap);
- else
- num_pkeys = cl_ntoh16(p_node->sw->switch_info.enforce_cap);
- return ((num_pkeys + 31) / 32);
-}
-
-/**********************************************************************
- **********************************************************************/
-/*
- * Insert new pending pkey entry to the specific port pkey table
- * pending pkeys. New entries are inserted at the back.
- */
-static void
-pkey_mgr_process_physical_port(IN osm_log_t * p_log,
- IN osm_sm_t * sm,
- IN const ib_net16_t pkey,
- IN osm_physp_t * p_physp)
-{
- osm_node_t *p_node = osm_physp_get_node_ptr(p_physp);
- osm_pkey_tbl_t *p_pkey_tbl;
- ib_net16_t *p_orig_pkey;
- char *stat = NULL;
- osm_pending_pkey_t *p_pending;
-
- p_pkey_tbl = &p_physp->pkeys;
- p_pending = (osm_pending_pkey_t *) malloc(sizeof(osm_pending_pkey_t));
- if (!p_pending) {
- OSM_LOG(p_log, OSM_LOG_ERROR, "ERR 0502: "
- "Failed to allocate new pending pkey entry for node "
- "0x%016" PRIx64 " port %u\n",
- cl_ntoh64(osm_node_get_node_guid(p_node)),
- osm_physp_get_port_num(p_physp));
- return;
- }
- p_pending->pkey = pkey;
- p_orig_pkey = cl_map_get(&p_pkey_tbl->keys, ib_pkey_get_base(pkey));
- if (!p_orig_pkey) {
- p_pending->is_new = TRUE;
- cl_qlist_insert_tail(&p_pkey_tbl->pending,
- (cl_list_item_t *) p_pending);
- stat = "inserted";
- } else {
- CL_ASSERT(ib_pkey_get_base(*p_orig_pkey) ==
- ib_pkey_get_base(pkey));
- p_pending->is_new = FALSE;
- if (osm_pkey_tbl_get_block_and_idx(p_pkey_tbl, p_orig_pkey,
- &p_pending->block,
- &p_pending->index) !=
- IB_SUCCESS) {
- OSM_LOG(p_log, OSM_LOG_ERROR, "ERR 0503: "
- "Failed to obtain P_Key 0x%04x block and index for node "
- "0x%016" PRIx64 " port %u\n",
- ib_pkey_get_base(pkey),
- cl_ntoh64(osm_node_get_node_guid(p_node)),
- osm_physp_get_port_num(p_physp));
- return;
- }
- cl_qlist_insert_head(&p_pkey_tbl->pending,
- (cl_list_item_t *) p_pending);
- stat = "updated";
- }
-
- OSM_LOG(p_log, OSM_LOG_DEBUG,
- "pkey 0x%04x was %s for node 0x%016" PRIx64 " port %u\n",
- cl_ntoh16(pkey), stat,
- cl_ntoh64(osm_node_get_node_guid(p_node)),
- osm_physp_get_port_num(p_physp));
-}
-
-/**********************************************************************
- **********************************************************************/
-static void
-pkey_mgr_process_partition_table(osm_log_t * p_log, osm_sm_t * sm,
- const osm_prtn_t * p_prtn,
- const boolean_t full)
-{
- const cl_map_t *p_tbl =
- full ? &p_prtn->full_guid_tbl : &p_prtn->part_guid_tbl;
- cl_map_iterator_t i, i_next;
- ib_net16_t pkey = p_prtn->pkey;
- osm_physp_t *p_physp;
-
- if (full)
- pkey |= cl_hton16(0x8000);
-
- i_next = cl_map_head(p_tbl);
- while (i_next != cl_map_end(p_tbl)) {
- i = i_next;
- i_next = cl_map_next(i);
- p_physp = cl_map_obj(i);
- if (p_physp)
- pkey_mgr_process_physical_port(p_log, sm, pkey,
- p_physp);
- }
-}
-
-/**********************************************************************
- **********************************************************************/
-static ib_api_status_t
-pkey_mgr_update_pkey_entry(IN osm_sm_t * sm,
- IN const osm_physp_t * p_physp,
- IN const ib_pkey_table_t * block,
- IN const uint16_t block_index)
-{
- osm_madw_context_t context;
- osm_node_t *p_node = osm_physp_get_node_ptr(p_physp);
- uint32_t attr_mod;
-
- context.pkey_context.node_guid = osm_node_get_node_guid(p_node);
- context.pkey_context.port_guid = osm_physp_get_port_guid(p_physp);
- context.pkey_context.set_method = TRUE;
- attr_mod = block_index;
- if (osm_node_get_type(p_node) == IB_NODE_TYPE_SWITCH)
- attr_mod |= osm_physp_get_port_num(p_physp) << 16;
- return osm_req_set(sm, osm_physp_get_dr_path_ptr(p_physp),
- (uint8_t *) block, sizeof(*block),
- IB_MAD_ATTR_P_KEY_TABLE,
- cl_hton32(attr_mod), CL_DISP_MSGID_NONE, &context);
-}
-
-/**********************************************************************
- **********************************************************************/
-static boolean_t
-pkey_mgr_enforce_partition(IN osm_log_t * p_log, osm_sm_t * sm,
- IN osm_physp_t * p_physp, IN const boolean_t enforce)
-{
- osm_madw_context_t context;
- uint8_t payload[IB_SMP_DATA_SIZE];
- ib_port_info_t *p_pi;
- ib_api_status_t status;
-
- p_pi = &p_physp->port_info;
-
- if ((p_pi->vl_enforce & 0xc) == (0xc) * (enforce == TRUE)) {
- OSM_LOG(p_log, OSM_LOG_DEBUG,
- "No need to update PortInfo for "
- "node 0x%016" PRIx64 " port %u\n",
- cl_ntoh64(osm_node_get_node_guid
- (osm_physp_get_node_ptr(p_physp))),
- osm_physp_get_port_num(p_physp));
- return FALSE;
- }
-
- memset(payload, 0, IB_SMP_DATA_SIZE);
- memcpy(payload, p_pi, sizeof(ib_port_info_t));
-
- p_pi = (ib_port_info_t *) payload;
- if (enforce == TRUE)
- p_pi->vl_enforce |= 0xc;
- else
- p_pi->vl_enforce &= ~0xc;
- p_pi->state_info2 = 0;
- ib_port_info_set_port_state(p_pi, IB_LINK_NO_CHANGE);
-
- context.pi_context.node_guid =
- osm_node_get_node_guid(osm_physp_get_node_ptr(p_physp));
- context.pi_context.port_guid = osm_physp_get_port_guid(p_physp);
- context.pi_context.set_method = TRUE;
- context.pi_context.light_sweep = FALSE;
- context.pi_context.active_transition = FALSE;
-
- status = osm_req_set(sm, osm_physp_get_dr_path_ptr(p_physp),
- payload, sizeof(payload),
- IB_MAD_ATTR_PORT_INFO,
- cl_hton32(osm_physp_get_port_num(p_physp)),
- CL_DISP_MSGID_NONE, &context);
- if (status != IB_SUCCESS) {
- OSM_LOG(p_log, OSM_LOG_ERROR, "ERR 0511: "
- "Failed to set PortInfo for "
- "node 0x%016" PRIx64 " port %u\n",
- cl_ntoh64(osm_node_get_node_guid
- (osm_physp_get_node_ptr(p_physp))),
- osm_physp_get_port_num(p_physp));
- return FALSE;
- } else {
- OSM_LOG(p_log, OSM_LOG_DEBUG,
- "Set PortInfo for node 0x%016" PRIx64 " port %u\n",
- cl_ntoh64(osm_node_get_node_guid
- (osm_physp_get_node_ptr(p_physp))),
- osm_physp_get_port_num(p_physp));
- return TRUE;
- }
-}
-
-/**********************************************************************
- **********************************************************************/
-static boolean_t pkey_mgr_update_port(osm_log_t * p_log, osm_sm_t * sm,
- const osm_port_t * const p_port)
-{
- osm_physp_t *p_physp;
- osm_node_t *p_node;
- ib_pkey_table_t *block, *new_block;
- osm_pkey_tbl_t *p_pkey_tbl;
- uint16_t block_index;
- uint8_t pkey_index;
- uint16_t last_free_block_index = 0;
- uint8_t last_free_pkey_index = 0;
- uint16_t num_of_blocks;
- uint16_t max_num_of_blocks;
- ib_api_status_t status;
- boolean_t ret_val = FALSE;
- osm_pending_pkey_t *p_pending;
- boolean_t found;
- ib_pkey_table_t empty_block;
-
- memset(&empty_block, 0, sizeof(ib_pkey_table_t));
-
- p_physp = p_port->p_physp;
- if (!p_physp)
- return FALSE;
-
- p_node = osm_physp_get_node_ptr(p_physp);
- p_pkey_tbl = &p_physp->pkeys;
- num_of_blocks = osm_pkey_tbl_get_num_blocks(p_pkey_tbl);
- max_num_of_blocks =
- pkey_mgr_get_physp_max_blocks(sm->p_subn, p_physp);
- if (p_pkey_tbl->max_blocks > max_num_of_blocks) {
- OSM_LOG(p_log, OSM_LOG_INFO,
- "Max number of blocks reduced from %u to %u "
- "for node 0x%016" PRIx64 " port %u\n",
- p_pkey_tbl->max_blocks, max_num_of_blocks,
- cl_ntoh64(osm_node_get_node_guid(p_node)),
- osm_physp_get_port_num(p_physp));
- }
- p_pkey_tbl->max_blocks = max_num_of_blocks;
-
- osm_pkey_tbl_init_new_blocks(p_pkey_tbl);
- p_pkey_tbl->used_blocks = 0;
-
- /*
- process every pending pkey in order -
- first must be "updated" last are "new"
- */
- p_pending =
- (osm_pending_pkey_t *) cl_qlist_remove_head(&p_pkey_tbl->pending);
- while (p_pending !=
- (osm_pending_pkey_t *) cl_qlist_end(&p_pkey_tbl->pending)) {
- if (p_pending->is_new == FALSE) {
- block_index = p_pending->block;
- pkey_index = p_pending->index;
- found = TRUE;
- } else {
- found = osm_pkey_find_next_free_entry(p_pkey_tbl,
- &last_free_block_index,
- &last_free_pkey_index);
- if (!found) {
- OSM_LOG(p_log, OSM_LOG_ERROR, "ERR 0504: "
- "Failed to find empty space for new pkey 0x%04x "
- "for node 0x%016" PRIx64 " port %u\n",
- cl_ntoh16(p_pending->pkey),
- cl_ntoh64(osm_node_get_node_guid
- (p_node)),
- osm_physp_get_port_num(p_physp));
- } else {
- block_index = last_free_block_index;
- pkey_index = last_free_pkey_index++;
- }
- }
-
- if (found) {
- if (IB_SUCCESS !=
- osm_pkey_tbl_set_new_entry(p_pkey_tbl, block_index,
- pkey_index,
- p_pending->pkey)) {
- OSM_LOG(p_log, OSM_LOG_ERROR, "ERR 0505: "
- "Failed to set PKey 0x%04x in block %u idx %u "
- "for node 0x%016" PRIx64 " port %u\n",
- cl_ntoh16(p_pending->pkey), block_index,
- pkey_index,
- cl_ntoh64(osm_node_get_node_guid
- (p_node)),
- osm_physp_get_port_num(p_physp));
- }
- }
-
- free(p_pending);
- p_pending =
- (osm_pending_pkey_t *) cl_qlist_remove_head(&p_pkey_tbl->
- pending);
- }
-
- /* now look for changes and store */
- for (block_index = 0; block_index < num_of_blocks; block_index++) {
- block = osm_pkey_tbl_block_get(p_pkey_tbl, block_index);
- new_block = osm_pkey_tbl_new_block_get(p_pkey_tbl, block_index);
- if (!new_block)
- new_block = &empty_block;
- if (block && !memcmp(new_block, block, sizeof(*block)))
- continue;
-
- status =
- pkey_mgr_update_pkey_entry(sm, p_physp, new_block,
- block_index);
- if (status == IB_SUCCESS) {
- OSM_LOG(p_log, OSM_LOG_DEBUG,
- "Updated pkey table block %d for node 0x%016"
- PRIx64 " port %u\n", block_index,
- cl_ntoh64(osm_node_get_node_guid(p_node)),
- osm_physp_get_port_num(p_physp));
- ret_val = TRUE;
- } else {
- OSM_LOG(p_log, OSM_LOG_ERROR, "ERR 0506: "
- "pkey_mgr_update_pkey_entry() failed to update "
- "pkey table block %d for node 0x%016" PRIx64
- " port %u\n", block_index,
- cl_ntoh64(osm_node_get_node_guid(p_node)),
- osm_physp_get_port_num(p_physp));
- }
- }
-
- return ret_val;
-}
-
-/**********************************************************************
- **********************************************************************/
-static boolean_t
-pkey_mgr_update_peer_port(osm_log_t * p_log, osm_sm_t * sm,
- const osm_subn_t * p_subn,
- const osm_port_t * const p_port, boolean_t enforce)
-{
- osm_physp_t *p_physp, *peer;
- osm_node_t *p_node;
- ib_pkey_table_t *block, *peer_block;
- const osm_pkey_tbl_t *p_pkey_tbl;
- osm_pkey_tbl_t *p_peer_pkey_tbl;
- uint16_t block_index;
- uint16_t num_of_blocks;
- uint16_t peer_max_blocks;
- ib_api_status_t status = IB_SUCCESS;
- boolean_t ret_val = FALSE;
- boolean_t port_info_set = FALSE;
- ib_pkey_table_t empty_block;
-
- memset(&empty_block, 0, sizeof(ib_pkey_table_t));
-
- p_physp = p_port->p_physp;
- if (!p_physp)
- return FALSE;
- peer = osm_physp_get_remote(p_physp);
- if (!peer)
- return FALSE;
- p_node = osm_physp_get_node_ptr(peer);
- if (!p_node->sw || !p_node->sw->switch_info.enforce_cap)
- return FALSE;
-
- p_pkey_tbl = osm_physp_get_pkey_tbl(p_physp);
- p_peer_pkey_tbl = &peer->pkeys;
- num_of_blocks = osm_pkey_tbl_get_num_blocks(p_pkey_tbl);
- peer_max_blocks = pkey_mgr_get_physp_max_blocks(p_subn, peer);
- if (peer_max_blocks < p_pkey_tbl->used_blocks) {
- OSM_LOG(p_log, OSM_LOG_ERROR, "ERR 0508: "
- "Not enough pkey entries (%u < %u) on switch 0x%016"
- PRIx64 " port %u. Clearing Enforcement bit\n",
- peer_max_blocks, num_of_blocks,
- cl_ntoh64(osm_node_get_node_guid(p_node)),
- osm_physp_get_port_num(peer));
- enforce = FALSE;
- }
-
- if (pkey_mgr_enforce_partition(p_log, sm, peer, enforce))
- port_info_set = TRUE;
-
- if (enforce == FALSE)
- return port_info_set;
-
- p_peer_pkey_tbl->used_blocks = p_pkey_tbl->used_blocks;
- for (block_index = 0; block_index < p_pkey_tbl->used_blocks;
- block_index++) {
- block = osm_pkey_tbl_new_block_get(p_pkey_tbl, block_index);
- if (!block)
- block = &empty_block;
-
- peer_block =
- osm_pkey_tbl_block_get(p_peer_pkey_tbl, block_index);
- if (!peer_block
- || memcmp(peer_block, block, sizeof(*peer_block))) {
- status =
- pkey_mgr_update_pkey_entry(sm, peer, block,
- block_index);
- if (status == IB_SUCCESS)
- ret_val = TRUE;
- else
- OSM_LOG(p_log, OSM_LOG_ERROR, "ERR 0509: "
- "pkey_mgr_update_pkey_entry() failed to update "
- "pkey table block %d for node 0x%016"
- PRIx64 " port %u\n", block_index,
- cl_ntoh64(osm_node_get_node_guid
- (p_node)),
- osm_physp_get_port_num(peer));
- }
- }
-
- if (ret_val)
- OSM_LOG(p_log, OSM_LOG_DEBUG,
- "Pkey table was updated for node 0x%016" PRIx64
- " port %u\n",
- cl_ntoh64(osm_node_get_node_guid(p_node)),
- osm_physp_get_port_num(peer));
-
- if (port_info_set)
- return TRUE;
- return ret_val;
-}
-
-/**********************************************************************
- **********************************************************************/
-osm_signal_t osm_pkey_mgr_process(IN osm_opensm_t * p_osm)
-{
- cl_qmap_t *p_tbl;
- cl_map_item_t *p_next;
- osm_prtn_t *p_prtn;
- osm_port_t *p_port;
- osm_signal_t signal = OSM_SIGNAL_DONE;
-
- CL_ASSERT(p_osm);
-
- OSM_LOG_ENTER(&p_osm->log);
-
- CL_PLOCK_EXCL_ACQUIRE(&p_osm->lock);
-
- if (osm_prtn_make_partitions(&p_osm->log, &p_osm->subn) != IB_SUCCESS) {
- OSM_LOG(&p_osm->log, OSM_LOG_ERROR, "ERR 0510: "
- "osm_prtn_make_partitions() failed\n");
- goto _err;
- }
-
- /* populate the pending pkey entries by scanning all partitions */
- p_tbl = &p_osm->subn.prtn_pkey_tbl;
- p_next = cl_qmap_head(p_tbl);
- while (p_next != cl_qmap_end(p_tbl)) {
- p_prtn = (osm_prtn_t *) p_next;
- p_next = cl_qmap_next(p_next);
- pkey_mgr_process_partition_table(&p_osm->log, &p_osm->sm,
- p_prtn, FALSE);
- pkey_mgr_process_partition_table(&p_osm->log, &p_osm->sm,
- p_prtn, TRUE);
- }
-
- /* calculate and set new pkey tables */
- p_tbl = &p_osm->subn.port_guid_tbl;
- p_next = cl_qmap_head(p_tbl);
- while (p_next != cl_qmap_end(p_tbl)) {
- p_port = (osm_port_t *) p_next;
- p_next = cl_qmap_next(p_next);
- if (pkey_mgr_update_port(&p_osm->log, &p_osm->sm, p_port))
- signal = OSM_SIGNAL_DONE_PENDING;
- if ((osm_node_get_type(p_port->p_node) != IB_NODE_TYPE_SWITCH)
- && pkey_mgr_update_peer_port(&p_osm->log, &p_osm->sm,
- &p_osm->subn, p_port,
- !p_osm->subn.opt.
- no_partition_enforcement))
- signal = OSM_SIGNAL_DONE_PENDING;
- }
-
-_err:
- CL_PLOCK_RELEASE(&p_osm->lock);
- OSM_LOG_EXIT(&p_osm->log);
- return (signal);
-}
diff --git a/contrib/ofed/management/opensm/opensm/osm_pkey_rcv.c b/contrib/ofed/management/opensm/opensm/osm_pkey_rcv.c
deleted file mode 100644
index 7061941..0000000
--- a/contrib/ofed/management/opensm/opensm/osm_pkey_rcv.c
+++ /dev/null
@@ -1,145 +0,0 @@
-/*
- * Copyright (c) 2004-2008 Voltaire, Inc. All rights reserved.
- * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved.
- * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- */
-
-#if HAVE_CONFIG_H
-# include <config.h>
-#endif /* HAVE_CONFIG_H */
-
-#include <string.h>
-#include <iba/ib_types.h>
-#include <complib/cl_passivelock.h>
-#include <complib/cl_debug.h>
-#include <opensm/osm_madw.h>
-#include <opensm/osm_log.h>
-#include <opensm/osm_node.h>
-#include <opensm/osm_subnet.h>
-#include <opensm/osm_helper.h>
-#include <opensm/osm_sm.h>
-
-/**********************************************************************
- **********************************************************************/
-/*
- * WE MIGHT ONLY RECEIVE GET or SET responses
- */
-void osm_pkey_rcv_process(IN void *context, IN void *data)
-{
- osm_sm_t *sm = context;
- osm_madw_t *p_madw = data;
- ib_pkey_table_t *p_pkey_tbl;
- ib_smp_t *p_smp;
- osm_port_t *p_port;
- osm_physp_t *p_physp;
- osm_node_t *p_node;
- osm_pkey_context_t *p_context;
- ib_net64_t port_guid;
- ib_net64_t node_guid;
- uint8_t port_num;
- uint16_t block_num;
-
- CL_ASSERT(sm);
-
- OSM_LOG_ENTER(sm->p_log);
-
- CL_ASSERT(p_madw);
-
- p_smp = osm_madw_get_smp_ptr(p_madw);
-
- p_context = osm_madw_get_pkey_context_ptr(p_madw);
- p_pkey_tbl = (ib_pkey_table_t *) ib_smp_get_payload_ptr(p_smp);
-
- port_guid = p_context->port_guid;
- node_guid = p_context->node_guid;
-
- CL_ASSERT(p_smp->attr_id == IB_MAD_ATTR_P_KEY_TABLE);
-
- cl_plock_excl_acquire(sm->p_lock);
- p_port = osm_get_port_by_guid(sm->p_subn, port_guid);
- if (!p_port) {
- OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR 4806: "
- "No port object for port with GUID 0x%" PRIx64
- "\n\t\t\t\tfor parent node GUID 0x%" PRIx64
- ", TID 0x%" PRIx64 "\n",
- cl_ntoh64(port_guid),
- cl_ntoh64(node_guid), cl_ntoh64(p_smp->trans_id));
- goto Exit;
- }
-
- p_node = p_port->p_node;
- CL_ASSERT(p_node);
-
- block_num = (uint16_t) ((cl_ntoh32(p_smp->attr_mod)) & 0x0000FFFF);
- /* in case of a non switch node the attr modifier should be ignored */
- if (osm_node_get_type(p_node) == IB_NODE_TYPE_SWITCH) {
- port_num =
- (uint8_t) (((cl_ntoh32(p_smp->attr_mod)) & 0x00FF0000) >>
- 16);
- p_physp = osm_node_get_physp_ptr(p_node, port_num);
- } else {
- p_physp = p_port->p_physp;
- port_num = p_physp->port_num;
- }
-
- /*
- We do not mind if this is a result of a set or get - all we want is to
- update the subnet.
- */
- OSM_LOG(sm->p_log, OSM_LOG_VERBOSE,
- "Got GetResp(PKey) block:%u port_num %u with GUID 0x%"
- PRIx64 " for parent node GUID 0x%" PRIx64 ", TID 0x%"
- PRIx64 "\n", block_num, port_num, cl_ntoh64(port_guid),
- cl_ntoh64(node_guid), cl_ntoh64(p_smp->trans_id));
-
- /*
- Determine if we encountered a new Physical Port.
- If so, ignore it.
- */
- if (!p_physp) {
- OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR 4807: "
- "Got invalid port number %u\n", port_num);
- goto Exit;
- }
-
- osm_dump_pkey_block(sm->p_log,
- port_guid, block_num,
- port_num, p_pkey_tbl, OSM_LOG_DEBUG);
-
- osm_physp_set_pkey_tbl(sm->p_log, sm->p_subn,
- p_physp, p_pkey_tbl, block_num);
-
-Exit:
- cl_plock_release(sm->p_lock);
-
- OSM_LOG_EXIT(sm->p_log);
-}
diff --git a/contrib/ofed/management/opensm/opensm/osm_port.c b/contrib/ofed/management/opensm/opensm/osm_port.c
deleted file mode 100644
index 4b4d4b8..0000000
--- a/contrib/ofed/management/opensm/opensm/osm_port.c
+++ /dev/null
@@ -1,780 +0,0 @@
-/*
- * Copyright (c) 2004-2008 Voltaire, Inc. All rights reserved.
- * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved.
- * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- */
-
-/*
- * Abstract:
- * Implementation of osm_physp_t.
- * This object represents an Infiniband Port.
- * This object is part of the opensm family of objects.
- */
-
-#if HAVE_CONFIG_H
-# include <config.h>
-#endif /* HAVE_CONFIG_H */
-
-#include <stdlib.h>
-#include <string.h>
-#include <complib/cl_debug.h>
-#include <iba/ib_types.h>
-#include <opensm/osm_port.h>
-#include <opensm/osm_node.h>
-#include <opensm/osm_madw.h>
-#include <opensm/osm_mcm_info.h>
-#include <opensm/osm_switch.h>
-
-/**********************************************************************
- **********************************************************************/
-void osm_physp_construct(IN osm_physp_t * const p_physp)
-{
- memset(p_physp, 0, sizeof(*p_physp));
- osm_dr_path_construct(&p_physp->dr_path);
- cl_ptr_vector_construct(&p_physp->slvl_by_port);
- osm_pkey_tbl_construct(&p_physp->pkeys);
-}
-
-/**********************************************************************
- **********************************************************************/
-void osm_physp_destroy(IN osm_physp_t * const p_physp)
-{
- size_t num_slvl, i;
-
- /* the physp might be uninitialized */
- if (p_physp->port_guid) {
- /* free the SL2VL Tables */
- num_slvl = cl_ptr_vector_get_size(&p_physp->slvl_by_port);
- for (i = 0; i < num_slvl; i++)
- free(cl_ptr_vector_get(&p_physp->slvl_by_port, i));
- cl_ptr_vector_destroy(&p_physp->slvl_by_port);
-
- /* free the P_Key Tables */
- osm_pkey_tbl_destroy(&p_physp->pkeys);
-
- memset(p_physp, 0, sizeof(*p_physp));
- osm_dr_path_construct(&p_physp->dr_path); /* clear dr_path */
- }
-}
-
-/**********************************************************************
- **********************************************************************/
-void
-osm_physp_init(IN osm_physp_t * const p_physp,
- IN const ib_net64_t port_guid,
- IN const uint8_t port_num,
- IN const struct osm_node *const p_node,
- IN const osm_bind_handle_t h_bind,
- IN const uint8_t hop_count,
- IN const uint8_t * const p_initial_path)
-{
- uint16_t num_slvl, i;
- ib_slvl_table_t *p_slvl;
-
- CL_ASSERT(p_node);
-
- osm_physp_construct(p_physp);
- p_physp->port_guid = port_guid;
- p_physp->port_num = port_num;
- p_physp->healthy = TRUE;
- p_physp->need_update = 2;
- p_physp->p_node = (struct osm_node *)p_node;
-
- osm_dr_path_init(&p_physp->dr_path, h_bind, hop_count, p_initial_path);
-
- /* allocate enough SL2VL tables */
- if (osm_node_get_type(p_node) == IB_NODE_TYPE_SWITCH)
- /* we need node num ports + 1 SL2VL tables */
- num_slvl = osm_node_get_num_physp(p_node) + 1;
- else
- /* An end node - we need only one SL2VL */
- num_slvl = 1;
-
- cl_ptr_vector_init(&p_physp->slvl_by_port, num_slvl, 1);
- for (i = 0; i < num_slvl; i++) {
- p_slvl = (ib_slvl_table_t *) malloc(sizeof(ib_slvl_table_t));
- if (!p_slvl)
- break;
- memset(p_slvl, 0, sizeof(ib_slvl_table_t));
- cl_ptr_vector_set(&p_physp->slvl_by_port, i, p_slvl);
- }
-
- /* initialize the pkey table */
- osm_pkey_tbl_init(&p_physp->pkeys);
-}
-
-/**********************************************************************
- **********************************************************************/
-void osm_port_delete(IN OUT osm_port_t ** const pp_port)
-{
- /* cleanup all mcm recs attached */
- osm_port_remove_all_mgrp(*pp_port);
- free(*pp_port);
- *pp_port = NULL;
-}
-
-/**********************************************************************
- **********************************************************************/
-static void
-osm_port_init(IN osm_port_t * const p_port,
- IN const ib_node_info_t * p_ni,
- IN osm_node_t * const p_parent_node)
-{
- ib_net64_t port_guid;
- osm_physp_t *p_physp;
- uint8_t port_num;
-
- CL_ASSERT(p_port);
- CL_ASSERT(p_ni);
- CL_ASSERT(p_parent_node);
-
- memset(p_port, 0, sizeof(*p_port));
- cl_qlist_init(&p_port->mcm_list);
- p_port->p_node = (struct osm_node *)p_parent_node;
- port_guid = p_ni->port_guid;
- p_port->guid = port_guid;
- port_num = p_ni->node_type == IB_NODE_TYPE_SWITCH ?
- 0 : ib_node_info_get_local_port_num(p_ni);
-
- /*
- Get the pointers to the physical node objects "owned" by this
- logical port GUID.
- For switches, port '0' is owned; for HCA's and routers,
- only the singular part that has this GUID is owned.
- */
- p_physp = osm_node_get_physp_ptr(p_parent_node, port_num);
- CL_ASSERT(port_guid == osm_physp_get_port_guid(p_physp));
- p_port->p_physp = p_physp;
-}
-
-/**********************************************************************
- **********************************************************************/
-osm_port_t *osm_port_new(IN const ib_node_info_t * p_ni,
- IN osm_node_t * const p_parent_node)
-{
- osm_port_t *p_port;
-
- p_port = malloc(sizeof(*p_port));
- if (p_port != NULL) {
- memset(p_port, 0, sizeof(*p_port));
- osm_port_init(p_port, p_ni, p_parent_node);
- }
-
- return (p_port);
-}
-
-/**********************************************************************
- **********************************************************************/
-void
-osm_port_get_lid_range_ho(IN const osm_port_t * const p_port,
- IN uint16_t * const p_min_lid,
- IN uint16_t * const p_max_lid)
-{
- uint8_t lmc;
-
- *p_min_lid = cl_ntoh16(osm_port_get_base_lid(p_port));
- lmc = osm_port_get_lmc(p_port);
- *p_max_lid = (uint16_t) (*p_min_lid + (1 << lmc) - 1);
-}
-
-/**********************************************************************
- **********************************************************************/
-ib_api_status_t
-osm_get_port_by_base_lid(IN const osm_subn_t * const p_subn,
- IN const ib_net16_t lid,
- IN OUT const osm_port_t ** const pp_port)
-{
- ib_api_status_t status;
- uint16_t base_lid;
- uint8_t lmc;
-
- *pp_port = NULL;
-
- /* Loop on lmc from 0 up through max LMC possible */
- for (lmc = 0; lmc <= IB_PORT_LMC_MAX; lmc++) {
- /* Calculate a base LID assuming this is the real LMC */
- base_lid = cl_ntoh16(lid) & ~((1 << lmc) - 1);
-
- /* Look for a match */
- status = cl_ptr_vector_at(&p_subn->port_lid_tbl,
- base_lid, (void **)pp_port);
- if ((status == CL_SUCCESS) && (*pp_port != NULL)) {
- /* Determine if base LID "tested" is the real base LID */
- /* This is true if the LMC "tested" is the port's actual LMC */
- if (lmc == osm_port_get_lmc(*pp_port)) {
- status = IB_SUCCESS;
- goto Found;
- }
- }
- }
- *pp_port = NULL;
- status = IB_NOT_FOUND;
-
-Found:
- return status;
-}
-
-/**********************************************************************
- **********************************************************************/
-ib_api_status_t
-osm_port_add_mgrp(IN osm_port_t * const p_port, IN const ib_net16_t mlid)
-{
- ib_api_status_t status = IB_SUCCESS;
- osm_mcm_info_t *p_mcm;
-
- p_mcm = osm_mcm_info_new(mlid);
- if (p_mcm)
- cl_qlist_insert_tail(&p_port->mcm_list,
- (cl_list_item_t *) p_mcm);
- else
- status = IB_INSUFFICIENT_MEMORY;
-
- return (status);
-}
-
-/**********************************************************************
- **********************************************************************/
-static cl_status_t
-__osm_port_mgrp_find_func(IN const cl_list_item_t * const p_list_item,
- IN void *context)
-{
- if (*((ib_net16_t *) context) == ((osm_mcm_info_t *) p_list_item)->mlid)
- return (CL_SUCCESS);
- else
- return (CL_NOT_FOUND);
-}
-
-/**********************************************************************
- **********************************************************************/
-void
-osm_port_remove_mgrp(IN osm_port_t * const p_port, IN const ib_net16_t mlid)
-{
- cl_list_item_t *p_mcm;
-
- p_mcm = cl_qlist_find_from_head(&p_port->mcm_list,
- __osm_port_mgrp_find_func, &mlid);
-
- if (p_mcm != cl_qlist_end(&p_port->mcm_list)) {
- cl_qlist_remove_item(&p_port->mcm_list, p_mcm);
- osm_mcm_info_delete((osm_mcm_info_t *) p_mcm);
- }
-}
-
-/**********************************************************************
- **********************************************************************/
-void osm_port_remove_all_mgrp(IN osm_port_t * const p_port)
-{
- cl_list_item_t *p_mcm;
-
- p_mcm = cl_qlist_remove_head(&p_port->mcm_list);
- while (p_mcm != cl_qlist_end(&p_port->mcm_list)) {
- osm_mcm_info_delete((osm_mcm_info_t *) p_mcm);
- p_mcm = cl_qlist_remove_head(&p_port->mcm_list);
- }
-}
-
-/**********************************************************************
- **********************************************************************/
-uint8_t
-osm_physp_calc_link_mtu(IN osm_log_t * p_log, IN const osm_physp_t * p_physp)
-{
- const osm_physp_t *p_remote_physp;
- uint8_t mtu;
- uint8_t remote_mtu;
-
- OSM_LOG_ENTER(p_log);
-
- p_remote_physp = osm_physp_get_remote(p_physp);
- if (p_remote_physp) {
- /* use the available MTU */
- mtu = ib_port_info_get_mtu_cap(&p_physp->port_info);
-
- remote_mtu =
- ib_port_info_get_mtu_cap(&p_remote_physp->port_info);
-
- OSM_LOG(p_log, OSM_LOG_DEBUG,
- "Remote port 0x%016" PRIx64 " port = %u : "
- "MTU = %u. This Port MTU: %u\n",
- cl_ntoh64(osm_physp_get_port_guid(p_remote_physp)),
- osm_physp_get_port_num(p_remote_physp),
- remote_mtu, mtu);
-
- if (mtu != remote_mtu) {
- if (mtu > remote_mtu)
- mtu = remote_mtu;
-
- OSM_LOG(p_log, OSM_LOG_VERBOSE,
- "MTU mismatch between ports."
- "\n\t\t\t\tPort 0x%016" PRIx64 ", port %u"
- " and port 0x%016" PRIx64 ", port %u."
- "\n\t\t\t\tUsing lower MTU of %u\n",
- cl_ntoh64(osm_physp_get_port_guid(p_physp)),
- osm_physp_get_port_num(p_physp),
- cl_ntoh64(osm_physp_get_port_guid(p_remote_physp)),
- osm_physp_get_port_num(p_remote_physp),mtu);
- }
- } else
- mtu = ib_port_info_get_neighbor_mtu(&p_physp->port_info);
-
- if (mtu == 0) {
- OSM_LOG(p_log, OSM_LOG_DEBUG, "ERR 4101: "
- "Invalid MTU = 0. Forcing correction to 256\n");
- mtu = 1;
- }
-
- OSM_LOG_EXIT(p_log);
- return (mtu);
-}
-
-/**********************************************************************
- **********************************************************************/
-uint8_t
-osm_physp_calc_link_op_vls(IN osm_log_t * p_log,
- IN const osm_subn_t * p_subn,
- IN const osm_physp_t * p_physp)
-{
- const osm_physp_t *p_remote_physp;
- uint8_t op_vls;
- uint8_t remote_op_vls;
-
- OSM_LOG_ENTER(p_log);
-
- p_remote_physp = osm_physp_get_remote(p_physp);
- if (p_remote_physp) {
- /* use the available VLCap */
- op_vls = ib_port_info_get_vl_cap(&p_physp->port_info);
-
- remote_op_vls =
- ib_port_info_get_vl_cap(&p_remote_physp->port_info);
-
- OSM_LOG(p_log, OSM_LOG_DEBUG,
- "Remote port 0x%016" PRIx64 " port = 0x%X : "
- "VL_CAP = %u. This port VL_CAP = %u\n",
- cl_ntoh64(osm_physp_get_port_guid(p_remote_physp)),
- osm_physp_get_port_num(p_remote_physp),
- remote_op_vls, op_vls);
-
- if (op_vls != remote_op_vls) {
- if (op_vls > remote_op_vls)
- op_vls = remote_op_vls;
-
- OSM_LOG(p_log, OSM_LOG_VERBOSE,
- "OP_VLS mismatch between ports."
- "\n\t\t\t\tPort 0x%016" PRIx64 ", port 0x%X"
- " and port 0x%016" PRIx64 ", port 0x%X."
- "\n\t\t\t\tUsing lower OP_VLS of %u\n",
- cl_ntoh64(osm_physp_get_port_guid(p_physp)),
- osm_physp_get_port_num(p_physp),
- cl_ntoh64(osm_physp_get_port_guid(p_remote_physp)),
- osm_physp_get_port_num(p_remote_physp), op_vls);
- }
- } else
- op_vls = ib_port_info_get_op_vls(&p_physp->port_info);
-
- /* support user limitation of max_op_vls */
- if (op_vls > p_subn->opt.max_op_vls)
- op_vls = p_subn->opt.max_op_vls;
-
- if (op_vls == 0) {
- OSM_LOG(p_log, OSM_LOG_DEBUG, "ERR 4102: "
- "Invalid OP_VLS = 0. Forcing correction to 1 (VL0)\n");
- op_vls = 1;
- }
-
- OSM_LOG_EXIT(p_log);
- return (op_vls);
-}
-
-static inline uint64_t __osm_ptr_to_key(void const *p)
-{
- uint64_t k = 0;
-
- memcpy(&k, p, sizeof(void *));
- return k;
-}
-
-static inline void *__osm_key_to_ptr(uint64_t k)
-{
- void *p = 0;
-
- memcpy(&p, &k, sizeof(void *));
- return p;
-}
-
-/**********************************************************************
- Traverse the fabric from the SM node following the DR path given and
- add every phys port traversed to the map. Avoid tracking the first and
- last phys ports (going into the first switch and into the target port).
- **********************************************************************/
-static cl_status_t
-__osm_physp_get_dr_physp_set(IN osm_log_t * p_log,
- IN osm_subn_t const *p_subn,
- IN osm_dr_path_t const *p_path,
- OUT cl_map_t * p_physp_map)
-{
- osm_port_t *p_port;
- osm_physp_t *p_physp;
- osm_node_t *p_node;
- uint8_t hop;
- cl_status_t status = CL_SUCCESS;
-
- OSM_LOG_ENTER(p_log);
-
- /* find the OSM node */
- p_port = osm_get_port_by_guid(p_subn, p_subn->sm_port_guid);
- if (!p_port) {
- OSM_LOG(p_log, OSM_LOG_ERROR, "ERR 4103: "
- "Failed to find the SM own port by guid\n");
- status = CL_ERROR;
- goto Exit;
- }
-
- /* get the node of the SM */
- p_node = p_port->p_node;
-
- /*
- traverse the path adding the nodes to the table
- start after the first dummy hop and stop just before the
- last one
- */
- for (hop = 1; hop < p_path->hop_count - 1; hop++) {
- /* go out using the phys port of the path */
- p_physp = osm_node_get_physp_ptr(p_node, p_path->path[hop]);
-
- /* make sure we got a valid port and it has a remote port */
- if (!p_physp) {
- OSM_LOG(p_log, OSM_LOG_ERROR, "ERR 4104: "
- "DR Traversal stopped on invalid port at hop:%u\n",
- hop);
- status = CL_ERROR;
- goto Exit;
- }
-
- /* we track the ports we go out along the path */
- if (hop > 1)
- cl_map_insert(p_physp_map, __osm_ptr_to_key(p_physp),
- NULL);
-
- OSM_LOG(p_log, OSM_LOG_DEBUG,
- "Traversed through node: 0x%016" PRIx64
- " port:%u\n",
- cl_ntoh64(p_node->node_info.node_guid),
- p_path->path[hop]);
-
- if (!(p_physp = osm_physp_get_remote(p_physp))) {
- OSM_LOG(p_log, OSM_LOG_ERROR, "ERR 4106: "
- "DR Traversal stopped on missing remote physp at hop:%u\n",
- hop);
- status = CL_ERROR;
- goto Exit;
- }
-
- p_node = osm_physp_get_node_ptr(p_physp);
- }
-
-Exit:
- OSM_LOG_EXIT(p_log);
- return status;
-}
-
-/**********************************************************************
- **********************************************************************/
-static void
-__osm_physp_update_new_dr_path(IN osm_physp_t const *p_dest_physp,
- IN cl_map_t * p_visited_map,
- IN osm_bind_handle_t * h_bind)
-{
- cl_list_t tmpPortsList;
- osm_physp_t *p_physp, *p_src_physp = NULL;
- uint8_t path_array[IB_SUBNET_PATH_HOPS_MAX];
- uint8_t i = 0;
- osm_dr_path_t *p_dr_path;
-
- cl_list_construct(&tmpPortsList);
- cl_list_init(&tmpPortsList, 10);
-
- cl_list_insert_head(&tmpPortsList, p_dest_physp);
- /* get the output port where we need to come from */
- p_physp = (osm_physp_t *) cl_map_get(p_visited_map,
- __osm_ptr_to_key(p_dest_physp));
- while (p_physp != NULL) {
- cl_list_insert_head(&tmpPortsList, p_physp);
- /* get the input port through where we reached the output port */
- p_src_physp = p_physp;
- p_physp = (osm_physp_t *) cl_map_get(p_visited_map,
- __osm_ptr_to_key(p_physp));
- /* if we reached a null p_physp - this means we are at the begining
- of the path. Break. */
- if (p_physp == NULL)
- break;
- /* get the output port */
- p_physp = (osm_physp_t *) cl_map_get(p_visited_map,
- __osm_ptr_to_key(p_physp));
- }
-
- memset(path_array, 0, sizeof(path_array));
- p_physp = (osm_physp_t *) cl_list_remove_head(&tmpPortsList);
- while (p_physp != NULL) {
- i++;
- path_array[i] = p_physp->port_num;
- p_physp = (osm_physp_t *) cl_list_remove_head(&tmpPortsList);
- }
- if (p_src_physp) {
- p_dr_path = osm_physp_get_dr_path_ptr(p_src_physp);
- osm_dr_path_init(p_dr_path, h_bind, i, path_array);
- }
-
- cl_list_destroy(&tmpPortsList);
-}
-
-/**********************************************************************
- **********************************************************************/
-void
-osm_physp_replace_dr_path_with_alternate_dr_path(IN osm_log_t * p_log,
- IN osm_subn_t const *p_subn,
- IN osm_physp_t const
- *p_dest_physp,
- IN osm_bind_handle_t * h_bind)
-{
- cl_map_t physp_map;
- cl_map_t visited_map;
- osm_dr_path_t *p_dr_path;
- cl_list_t *p_currPortsList;
- cl_list_t *p_nextPortsList;
- osm_port_t *p_port;
- osm_physp_t *p_physp, *p_remote_physp;
- ib_net64_t port_guid;
- boolean_t next_list_is_full = TRUE, reached_dest = FALSE;
- uint8_t num_ports, port_num;
-
- p_nextPortsList = (cl_list_t *) malloc(sizeof(cl_list_t));
- if (!p_nextPortsList)
- return;
-
- /*
- initialize the map of all port participating in current dr path
- not including first and last switches
- */
- cl_map_construct(&physp_map);
- cl_map_init(&physp_map, 4);
- cl_map_construct(&visited_map);
- cl_map_init(&visited_map, 4);
- p_dr_path = osm_physp_get_dr_path_ptr(p_dest_physp);
- __osm_physp_get_dr_physp_set(p_log, p_subn, p_dr_path, &physp_map);
-
- /*
- BFS from OSM port until we find the target physp but avoid
- going through mapped ports
- */
- cl_list_construct(p_nextPortsList);
- cl_list_init(p_nextPortsList, 10);
-
- port_guid = p_subn->sm_port_guid;
-
- CL_ASSERT(port_guid);
-
- p_port = osm_get_port_by_guid(p_subn, port_guid);
- if (!p_port) {
- OSM_LOG(p_log, OSM_LOG_ERROR, "ERR 4105: No SM port object\n");
- goto Exit;
- }
-
- /*
- HACK: We are assuming SM is running on HCA, so when getting the default
- port we'll get the port connected to the rest of the subnet. If SM is
- running on SWITCH - we should try to get a dr path from all switch ports.
- */
- p_physp = p_port->p_physp;
-
- CL_ASSERT(p_physp);
-
- cl_list_insert_tail(p_nextPortsList, p_physp);
-
- while (next_list_is_full == TRUE) {
- next_list_is_full = FALSE;
- p_currPortsList = p_nextPortsList;
- p_nextPortsList = (cl_list_t *) malloc(sizeof(cl_list_t));
- if (!p_nextPortsList) {
- p_nextPortsList = p_currPortsList;
- goto Exit;
- }
- cl_list_construct(p_nextPortsList);
- cl_list_init(p_nextPortsList, 10);
- p_physp = (osm_physp_t *) cl_list_remove_head(p_currPortsList);
- while (p_physp != NULL) {
- /* If we are in a switch - need to go out through all
- the other physical ports of the switch */
- num_ports = osm_node_get_num_physp(p_physp->p_node);
-
- for (port_num = 1; port_num < num_ports; port_num++) {
- if (osm_node_get_type(p_physp->p_node) ==
- IB_NODE_TYPE_SWITCH)
- p_remote_physp =
- osm_node_get_physp_ptr(p_physp->
- p_node,
- port_num);
- else
- /* this is HCA or router - the remote port is just the port connected
- on the other side */
- p_remote_physp =
- p_physp->p_remote_physp;
-
- /*
- make sure that all of the following occurred:
- 1. The port isn't NULL
- 2. This is not the port we came from
- 3. The port is not in the physp_map
- 4. This port haven't been visited before
- */
- if (p_remote_physp &&
- p_remote_physp != p_physp &&
- cl_map_get(&physp_map,
- __osm_ptr_to_key(p_remote_physp))
- == NULL
- && cl_map_get(&visited_map,
- __osm_ptr_to_key
- (p_remote_physp)) == NULL) {
- /* Insert the port into the visited_map, and save its source port */
- cl_map_insert(&visited_map,
- __osm_ptr_to_key
- (p_remote_physp),
- p_physp);
-
- /* Is this the p_dest_physp? */
- if (p_remote_physp == p_dest_physp) {
- /* update the new dr path */
- __osm_physp_update_new_dr_path
- (p_dest_physp, &visited_map,
- h_bind);
- reached_dest = TRUE;
- break;
- }
-
- /* add the p_remote_physp to the nextPortsList */
- cl_list_insert_tail(p_nextPortsList,
- p_remote_physp);
- next_list_is_full = TRUE;
- }
- }
-
- p_physp = (osm_physp_t *)
- cl_list_remove_head(p_currPortsList);
- if (reached_dest == TRUE) {
- /* free the rest of the currPortsList */
- while (p_physp != NULL)
- p_physp = (osm_physp_t *)
- cl_list_remove_head
- (p_currPortsList);
- /* free the nextPortsList, if items were added to it */
- p_physp = (osm_physp_t *)
- cl_list_remove_head(p_nextPortsList);
- while (p_physp != NULL)
- p_physp = (osm_physp_t *)
- cl_list_remove_head
- (p_nextPortsList);
- next_list_is_full = FALSE;
- }
- }
- cl_list_destroy(p_currPortsList);
- free(p_currPortsList);
- }
-
- /* cleanup */
-Exit:
- cl_list_destroy(p_nextPortsList);
- free(p_nextPortsList);
- cl_map_destroy(&physp_map);
- cl_map_destroy(&visited_map);
-}
-
-/**********************************************************************
- **********************************************************************/
-boolean_t osm_link_is_healthy(IN const osm_physp_t * const p_physp)
-{
- osm_physp_t *p_remote_physp;
-
- CL_ASSERT(p_physp);
- p_remote_physp = p_physp->p_remote_physp;
- if (p_remote_physp != NULL)
- return ((p_physp->healthy) & (p_remote_physp->healthy));
- /* the other side is not known - consider the link as healthy */
- return (TRUE);
-}
-
-/**********************************************************************
- **********************************************************************/
-void
-osm_physp_set_pkey_tbl(IN osm_log_t * p_log,
- IN const osm_subn_t * p_subn,
- IN osm_physp_t * const p_physp,
- IN ib_pkey_table_t * p_pkey_tbl, IN uint16_t block_num)
-{
- uint16_t max_blocks;
-
- CL_ASSERT(p_pkey_tbl);
- /*
- (14.2.5.7) - the block number valid values are 0-2047, and are
- further limited by the size of the P_Key table specified by
- the PartitionCap on the node.
- */
- if (!p_physp->p_node->sw || p_physp->port_num == 0)
- /*
- The maximum blocks is defined in the node info: partition cap
- for CA, router, and switch management ports.
- */
- max_blocks =
- (cl_ntoh16(p_physp->p_node->node_info.partition_cap) +
- IB_NUM_PKEY_ELEMENTS_IN_BLOCK - 1)
- / IB_NUM_PKEY_ELEMENTS_IN_BLOCK;
- else
- /*
- This is a switch, and not a management port. The maximum
- blocks is defined in the switch info: partition enforcement
- cap.
- */
- max_blocks =
- (cl_ntoh16(p_physp->p_node->sw->switch_info.enforce_cap) +
- IB_NUM_PKEY_ELEMENTS_IN_BLOCK -
- 1) / IB_NUM_PKEY_ELEMENTS_IN_BLOCK;
-
- if (block_num >= max_blocks) {
- OSM_LOG(p_log, OSM_LOG_ERROR, "ERR 4108: "
- "Got illegal set for block number:%u "
- "For GUID: %" PRIx64 " port number:%u\n",
- block_num,
- cl_ntoh64(p_physp->p_node->node_info.node_guid),
- p_physp->port_num);
- return;
- }
-
- osm_pkey_tbl_set(&p_physp->pkeys, block_num, p_pkey_tbl);
-}
diff --git a/contrib/ofed/management/opensm/opensm/osm_port_info_rcv.c b/contrib/ofed/management/opensm/opensm/osm_port_info_rcv.c
deleted file mode 100644
index 8763b87..0000000
--- a/contrib/ofed/management/opensm/opensm/osm_port_info_rcv.c
+++ /dev/null
@@ -1,687 +0,0 @@
-/*
- * Copyright (c) 2004-2008 Voltaire, Inc. All rights reserved.
- * Copyright (c) 2002-2008 Mellanox Technologies LTD. All rights reserved.
- * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- */
-
-/*
- * Abstract:
- * Implementation of osm_pi_rcv_t.
- * This object represents the PortInfo Receiver object.
- * This object is part of the opensm family of objects.
- */
-
-#if HAVE_CONFIG_H
-# include <config.h>
-#endif /* HAVE_CONFIG_H */
-
-#include <string.h>
-#include <iba/ib_types.h>
-#include <complib/cl_qmap.h>
-#include <complib/cl_passivelock.h>
-#include <complib/cl_debug.h>
-#include <vendor/osm_vendor_api.h>
-#include <opensm/osm_madw.h>
-#include <opensm/osm_log.h>
-#include <opensm/osm_node.h>
-#include <opensm/osm_subnet.h>
-#include <opensm/osm_mad_pool.h>
-#include <opensm/osm_msgdef.h>
-#include <opensm/osm_helper.h>
-#include <opensm/osm_pkey.h>
-#include <opensm/osm_remote_sm.h>
-#include <opensm/osm_opensm.h>
-#include <opensm/osm_ucast_mgr.h>
-
-/**********************************************************************
- **********************************************************************/
-static void
-__osm_pi_rcv_set_sm(IN osm_sm_t * sm,
- IN osm_physp_t * const p_physp)
-{
- osm_bind_handle_t h_bind;
- osm_dr_path_t *p_dr_path;
-
- OSM_LOG_ENTER(sm->p_log);
-
- OSM_LOG(sm->p_log, OSM_LOG_DEBUG,
- "Setting IS_SM bit in port attributes\n");
-
- p_dr_path = osm_physp_get_dr_path_ptr(p_physp);
- h_bind = osm_dr_path_get_bind_handle(p_dr_path);
-
- /*
- The 'IS_SM' bit isn't already set, so set it.
- */
- osm_vendor_set_sm(h_bind, TRUE);
-
- OSM_LOG_EXIT(sm->p_log);
-}
-
-/**********************************************************************
- **********************************************************************/
-static void pi_rcv_check_and_fix_lid(osm_log_t *log, ib_port_info_t * const pi,
- osm_physp_t * p)
-{
- if (cl_ntoh16(pi->base_lid) > IB_LID_UCAST_END_HO) {
- OSM_LOG(log, OSM_LOG_ERROR, "ERR 0F04: "
- "Got invalid base LID %u from the network. "
- "Corrected to %u.\n", cl_ntoh16(pi->base_lid),
- cl_ntoh16(p->port_info.base_lid));
- pi->base_lid = p->port_info.base_lid;
- }
-}
-
-/**********************************************************************
- **********************************************************************/
-static void
-__osm_pi_rcv_process_endport(IN osm_sm_t * sm,
- IN osm_physp_t * const p_physp,
- IN const ib_port_info_t * const p_pi)
-{
- osm_madw_context_t context;
- ib_api_status_t status;
- ib_net64_t port_guid;
- uint8_t rate, mtu;
- cl_qmap_t *p_sm_tbl;
- osm_remote_sm_t *p_sm;
-
- OSM_LOG_ENTER(sm->p_log);
-
- port_guid = osm_physp_get_port_guid(p_physp);
-
- /* HACK extended port 0 should be handled too! */
- if (osm_physp_get_port_num(p_physp) != 0) {
- /* track the minimal endport MTU and rate */
- mtu = ib_port_info_get_mtu_cap(p_pi);
- if (mtu < sm->p_subn->min_ca_mtu) {
- OSM_LOG(sm->p_log, OSM_LOG_VERBOSE,
- "Setting endport minimal MTU to:%u defined by port:0x%"
- PRIx64 "\n", mtu, cl_ntoh64(port_guid));
- sm->p_subn->min_ca_mtu = mtu;
- }
-
- rate = ib_port_info_compute_rate(p_pi);
- if (rate < sm->p_subn->min_ca_rate) {
- OSM_LOG(sm->p_log, OSM_LOG_VERBOSE,
- "Setting endport minimal rate to:%u defined by port:0x%"
- PRIx64 "\n", rate, cl_ntoh64(port_guid));
- sm->p_subn->min_ca_rate = rate;
- }
- }
-
- if (port_guid == sm->p_subn->sm_port_guid) {
- /*
- We received the PortInfo for our own port.
- */
- if (!(p_pi->capability_mask & IB_PORT_CAP_IS_SM))
- /*
- Set the IS_SM bit to indicate our port hosts an SM.
- */
- __osm_pi_rcv_set_sm(sm, p_physp);
- } else {
- p_sm_tbl = &sm->p_subn->sm_guid_tbl;
- if (p_pi->capability_mask & IB_PORT_CAP_IS_SM) {
- /*
- * Before querying the SM - we want to make sure we
- * clean its state, so if the querying fails we
- * recognize that this SM is not active.
- */
- p_sm = (osm_remote_sm_t *) cl_qmap_get(p_sm_tbl, port_guid);
- if (p_sm != (osm_remote_sm_t *) cl_qmap_end(p_sm_tbl))
- /* clean it up */
- p_sm->smi.pri_state = 0xF0 & p_sm->smi.pri_state;
- if (sm->p_subn->opt.ignore_other_sm)
- OSM_LOG(sm->p_log, OSM_LOG_VERBOSE,
- "Ignoring SM on port 0x%" PRIx64 "\n",
- cl_ntoh64(port_guid));
- else {
- OSM_LOG(sm->p_log, OSM_LOG_VERBOSE,
- "Detected another SM. Requesting SMInfo"
- "\n\t\t\t\tPort 0x%" PRIx64 "\n",
- cl_ntoh64(port_guid));
-
- /*
- This port indicates it's an SM and
- it's not our own port.
- Acquire the SMInfo Attribute.
- */
- memset(&context, 0, sizeof(context));
- context.smi_context.set_method = FALSE;
- context.smi_context.port_guid = port_guid;
- status = osm_req_get(sm,
- osm_physp_get_dr_path_ptr
- (p_physp),
- IB_MAD_ATTR_SM_INFO, 0,
- CL_DISP_MSGID_NONE,
- &context);
-
- if (status != IB_SUCCESS)
- OSM_LOG(sm->p_log, OSM_LOG_ERROR,
- "ERR 0F05: "
- "Failure requesting SMInfo (%s)\n",
- ib_get_err_str(status));
- }
- } else {
- p_sm = (osm_remote_sm_t *) cl_qmap_remove(p_sm_tbl, port_guid);
- if (p_sm != (osm_remote_sm_t *) cl_qmap_end(p_sm_tbl))
- free(p_sm);
- }
- }
-
- OSM_LOG_EXIT(sm->p_log);
-}
-
-/**********************************************************************
- The plock must be held before calling this function.
-**********************************************************************/
-static void
-__osm_pi_rcv_process_switch_port(IN osm_sm_t * sm,
- IN osm_node_t * const p_node,
- IN osm_physp_t * const p_physp,
- IN ib_port_info_t * const p_pi)
-{
- ib_api_status_t status = IB_SUCCESS;
- osm_madw_context_t context;
- osm_physp_t *p_remote_physp;
- osm_node_t *p_remote_node;
- uint8_t port_num;
- uint8_t remote_port_num;
- osm_dr_path_t path;
-
- OSM_LOG_ENTER(sm->p_log);
-
- /*
- Check the state of the physical port.
- If there appears to be something on the other end of the wire,
- then ask for NodeInfo. Ignore the switch management port.
- */
- port_num = osm_physp_get_port_num(p_physp);
- /* if in_sweep_hop_0 is TRUE, then this means the SM is on the switch,
- and we got switchInfo of our local switch. Do not continue
- probing through the switch. */
- if (port_num != 0 && sm->p_subn->in_sweep_hop_0 == FALSE) {
- switch (ib_port_info_get_port_state(p_pi)) {
- case IB_LINK_DOWN:
- p_remote_physp = osm_physp_get_remote(p_physp);
- if (p_remote_physp) {
- p_remote_node =
- osm_physp_get_node_ptr(p_remote_physp);
- remote_port_num =
- osm_physp_get_port_num(p_remote_physp);
-
- OSM_LOG(sm->p_log, OSM_LOG_VERBOSE,
- "Unlinking local node 0x%" PRIx64
- ", port %u"
- "\n\t\t\t\tand remote node 0x%" PRIx64
- ", port %u\n",
- cl_ntoh64(osm_node_get_node_guid
- (p_node)), port_num,
- cl_ntoh64(osm_node_get_node_guid
- (p_remote_node)),
- remote_port_num);
-
- if (sm->ucast_mgr.cache_valid)
- osm_ucast_cache_add_link(&sm->ucast_mgr,
- p_physp,
- p_remote_physp);
-
- osm_node_unlink(p_node, (uint8_t) port_num,
- p_remote_node,
- (uint8_t) remote_port_num);
-
- }
- break;
-
- case IB_LINK_INIT:
- case IB_LINK_ARMED:
- case IB_LINK_ACTIVE:
- /*
- To avoid looping forever, only probe the port if it
- is NOT the port that responded to the SMP.
-
- Request node info from the other end of this link:
- 1) Copy the current path from the parent node.
- 2) Extend the path to the next hop thru this port.
- 3) Request node info with the new path
-
- */
- if (p_pi->local_port_num !=
- osm_physp_get_port_num(p_physp)) {
- path = *osm_physp_get_dr_path_ptr(p_physp);
-
- osm_dr_path_extend(&path,
- osm_physp_get_port_num
- (p_physp));
-
- memset(&context, 0, sizeof(context));
- context.ni_context.node_guid =
- osm_node_get_node_guid(p_node);
- context.ni_context.port_num =
- osm_physp_get_port_num(p_physp);
-
- status = osm_req_get(sm,
- &path,
- IB_MAD_ATTR_NODE_INFO,
- 0,
- CL_DISP_MSGID_NONE,
- &context);
-
- if (status != IB_SUCCESS)
- OSM_LOG(sm->p_log, OSM_LOG_ERROR,
- "ERR 0F02: "
- "Failure initiating NodeInfo request (%s)\n",
- ib_get_err_str(status));
- } else
- OSM_LOG(sm->p_log, OSM_LOG_DEBUG,
- "Skipping SMP responder port %u\n",
- p_pi->local_port_num);
- break;
-
- default:
- OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR 0F03: "
- "Unknown link state = %u, port = %u\n",
- ib_port_info_get_port_state(p_pi),
- p_pi->local_port_num);
- break;
- }
- }
-
- if (ib_port_info_get_port_state(p_pi) > IB_LINK_INIT && p_node->sw &&
- p_node->sw->need_update == 1)
- p_node->sw->need_update = 0;
-
- if (p_physp->need_update)
- sm->p_subn->ignore_existing_lfts = TRUE;
-
- if (port_num == 0)
- pi_rcv_check_and_fix_lid(sm->p_log, p_pi, p_physp);
-
- /*
- Update the PortInfo attribute.
- */
- osm_physp_set_port_info(p_physp, p_pi);
-
- if (port_num == 0) {
- /* Determine if base switch port 0 */
- if (p_node->sw &&
- !ib_switch_info_is_enhanced_port0(&p_node->sw->switch_info))
- /* PortState is not used on BSP0 but just in case it is DOWN */
- p_physp->port_info = *p_pi;
- __osm_pi_rcv_process_endport(sm, p_physp, p_pi);
- }
-
- OSM_LOG_EXIT(sm->p_log);
-}
-
-/**********************************************************************
- **********************************************************************/
-static void
-__osm_pi_rcv_process_ca_or_router_port(IN osm_sm_t * sm,
- IN osm_node_t * const p_node,
- IN osm_physp_t * const p_physp,
- IN ib_port_info_t * const p_pi)
-{
- OSM_LOG_ENTER(sm->p_log);
-
- UNUSED_PARAM(p_node);
-
- pi_rcv_check_and_fix_lid(sm->p_log, p_pi, p_physp);
-
- osm_physp_set_port_info(p_physp, p_pi);
-
- __osm_pi_rcv_process_endport(sm, p_physp, p_pi);
-
- OSM_LOG_EXIT(sm->p_log);
-}
-
-#define IBM_VENDOR_ID (0x5076)
-/**********************************************************************
- **********************************************************************/
-static void get_pkey_table(IN osm_log_t * p_log,
- IN osm_sm_t * sm,
- IN osm_node_t * const p_node,
- IN osm_physp_t * const p_physp)
-{
-
- osm_madw_context_t context;
- ib_api_status_t status;
- osm_dr_path_t path;
- uint8_t port_num;
- uint16_t block_num, max_blocks;
- uint32_t attr_mod_ho;
-
- OSM_LOG_ENTER(p_log);
-
- path = *osm_physp_get_dr_path_ptr(p_physp);
-
- context.pkey_context.node_guid = osm_node_get_node_guid(p_node);
- context.pkey_context.port_guid = osm_physp_get_port_guid(p_physp);
- context.pkey_context.set_method = FALSE;
-
- port_num = p_physp->port_num;
-
- if (!p_node->sw || port_num == 0)
- /* The maximum blocks is defined by the node info partition cap for CA,
- router, and switch management ports. */
- max_blocks =
- (cl_ntoh16(p_node->node_info.partition_cap) +
- IB_NUM_PKEY_ELEMENTS_IN_BLOCK - 1)
- / IB_NUM_PKEY_ELEMENTS_IN_BLOCK;
- else {
- /* This is a switch, and not a management port. The maximum blocks
- is defined in the switch info partition enforcement cap. */
-
- /* Check for IBM eHCA firmware defect in reporting partition enforcement cap */
- if (cl_ntoh32(ib_node_info_get_vendor_id(&p_node->node_info)) ==
- IBM_VENDOR_ID)
- p_node->sw->switch_info.enforce_cap = 0;
-
- /* Bail out if this is a switch with no partition enforcement capability */
- if (cl_ntoh16(p_node->sw->switch_info.enforce_cap) == 0)
- goto Exit;
-
- max_blocks = (cl_ntoh16(p_node->sw->switch_info.enforce_cap) +
- IB_NUM_PKEY_ELEMENTS_IN_BLOCK -
- 1) / IB_NUM_PKEY_ELEMENTS_IN_BLOCK;
- }
-
- for (block_num = 0; block_num < max_blocks; block_num++) {
- if (osm_node_get_type(p_node) != IB_NODE_TYPE_SWITCH)
- attr_mod_ho = block_num;
- else
- attr_mod_ho = block_num | (port_num << 16);
- status = osm_req_get(sm, &path, IB_MAD_ATTR_P_KEY_TABLE,
- cl_hton32(attr_mod_ho),
- CL_DISP_MSGID_NONE, &context);
-
- if (status != IB_SUCCESS) {
- OSM_LOG(p_log, OSM_LOG_ERROR, "ERR 0F12: "
- "Failure initiating PKeyTable request (%s)\n",
- ib_get_err_str(status));
- goto Exit;
- }
- }
-
-Exit:
- OSM_LOG_EXIT(p_log);
-}
-
-/**********************************************************************
- **********************************************************************/
-static void
-__osm_pi_rcv_get_pkey_slvl_vla_tables(IN osm_sm_t * sm,
- IN osm_node_t * const p_node,
- IN osm_physp_t * const p_physp)
-{
- OSM_LOG_ENTER(sm->p_log);
-
- get_pkey_table(sm->p_log, sm, p_node, p_physp);
-
- OSM_LOG_EXIT(sm->p_log);
-}
-
-/**********************************************************************
- **********************************************************************/
-static void
-osm_pi_rcv_process_set(IN osm_sm_t * sm, IN osm_node_t * const p_node,
- IN const uint8_t port_num, IN osm_madw_t * const p_madw)
-{
- osm_physp_t *p_physp;
- ib_net64_t port_guid;
- ib_smp_t *p_smp;
- ib_port_info_t *p_pi;
- osm_pi_context_t *p_context;
- osm_log_level_t level;
-
- OSM_LOG_ENTER(sm->p_log);
-
- p_context = osm_madw_get_pi_context_ptr(p_madw);
-
- CL_ASSERT(p_node);
-
- p_physp = osm_node_get_physp_ptr(p_node, port_num);
- CL_ASSERT(p_physp);
-
- port_guid = osm_physp_get_port_guid(p_physp);
-
- p_smp = osm_madw_get_smp_ptr(p_madw);
- p_pi = (ib_port_info_t *) ib_smp_get_payload_ptr(p_smp);
-
- /* check for error */
- if (cl_ntoh16(p_smp->status) & 0x7fff) {
- /* If port already ACTIVE, don't treat status 7 as error */
- if (p_context->active_transition &&
- (cl_ntoh16(p_smp->status) & 0x7fff) == 0x1c) {
- level = OSM_LOG_INFO;
- OSM_LOG(sm->p_log, OSM_LOG_INFO,
- "Received error status 0x%x for SetResp() during ACTIVE transition\n",
- cl_ntoh16(p_smp->status) & 0x7fff);
- /* Should there be a subsequent Get to validate that port is ACTIVE ? */
- } else {
- level = OSM_LOG_ERROR;
- OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR 0F10: "
- "Received error status for SetResp()\n");
- }
- osm_dump_port_info(sm->p_log,
- osm_node_get_node_guid(p_node),
- port_guid, port_num, p_pi, level);
- }
-
- OSM_LOG(sm->p_log, OSM_LOG_DEBUG,
- "Received logical SetResp() for GUID 0x%" PRIx64
- ", port num %u"
- "\n\t\t\t\tfor parent node GUID 0x%" PRIx64
- " TID 0x%" PRIx64 "\n",
- cl_ntoh64(port_guid), port_num,
- cl_ntoh64(osm_node_get_node_guid(p_node)),
- cl_ntoh64(p_smp->trans_id));
-
- osm_physp_set_port_info(p_physp, p_pi);
-
- OSM_LOG_EXIT(sm->p_log);
-}
-
-/**********************************************************************
- **********************************************************************/
-void osm_pi_rcv_process(IN void *context, IN void *data)
-{
- osm_sm_t *sm = context;
- osm_madw_t *p_madw = data;
- ib_port_info_t *p_pi;
- ib_smp_t *p_smp;
- osm_port_t *p_port;
- osm_physp_t *p_physp;
- osm_dr_path_t *p_dr_path;
- osm_node_t *p_node;
- osm_pi_context_t *p_context;
- ib_net64_t port_guid;
- ib_net64_t node_guid;
- uint8_t port_num;
-
- OSM_LOG_ENTER(sm->p_log);
-
- CL_ASSERT(sm);
- CL_ASSERT(p_madw);
-
- p_smp = osm_madw_get_smp_ptr(p_madw);
- p_context = osm_madw_get_pi_context_ptr(p_madw);
- p_pi = (ib_port_info_t *) ib_smp_get_payload_ptr(p_smp);
-
- CL_ASSERT(p_smp->attr_id == IB_MAD_ATTR_PORT_INFO);
-
- port_num = (uint8_t) cl_ntoh32(p_smp->attr_mod);
-
- port_guid = p_context->port_guid;
- node_guid = p_context->node_guid;
-
- osm_dump_port_info(sm->p_log,
- node_guid, port_guid, port_num, p_pi, OSM_LOG_DEBUG);
-
- /* On receipt of client reregister, clear the reregister bit so
- reregistering won't be sent again and again */
- if (ib_port_info_get_client_rereg(p_pi)) {
- OSM_LOG(sm->p_log, OSM_LOG_DEBUG,
- "Client reregister received on response\n");
- ib_port_info_set_client_rereg(p_pi, 0);
- }
-
- /*
- we might get a response during a light sweep looking for a change in
- the status of a remote port that did not respond in earlier sweeps.
- So if the context of the Get was light_sweep - we do not need to
- do anything with the response - just flag that we need a heavy sweep
- */
- if (p_context->light_sweep == TRUE) {
- OSM_LOG(sm->p_log, OSM_LOG_VERBOSE,
- "Got light sweep response from remote port of parent node "
- "GUID 0x%" PRIx64 " port 0x%016" PRIx64
- ", Commencing heavy sweep\n",
- cl_ntoh64(node_guid), cl_ntoh64(port_guid));
- sm->p_subn->force_heavy_sweep = TRUE;
- sm->p_subn->ignore_existing_lfts = TRUE;
- goto Exit;
- }
-
- CL_PLOCK_EXCL_ACQUIRE(sm->p_lock);
- p_port = osm_get_port_by_guid(sm->p_subn, port_guid);
- if (!p_port) {
- CL_PLOCK_RELEASE(sm->p_lock);
- OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR 0F06: "
- "No port object for port with GUID 0x%" PRIx64
- "\n\t\t\t\tfor parent node GUID 0x%" PRIx64
- ", TID 0x%" PRIx64 "\n",
- cl_ntoh64(port_guid),
- cl_ntoh64(node_guid), cl_ntoh64(p_smp->trans_id));
- goto Exit;
- }
-
- p_node = p_port->p_node;
- CL_ASSERT(p_node);
-
- /*
- If we were setting the PortInfo, then receiving
- this attribute was not part of sweeping the subnet.
- In this case, just update the PortInfo attribute.
-
- In an unfortunate blunder, the IB spec defines the
- return method for Set() as a GetResp(). Thus, we can't
- use the method (what would have been SetResp()) to determine
- our course of action. So, we have to carry this extra
- boolean around to determine if we were doing Get() or Set().
- */
- if (p_context->set_method)
- osm_pi_rcv_process_set(sm, p_node, port_num, p_madw);
- else {
- p_port->discovery_count++;
-
- /*
- This PortInfo arrived because we did a Get() method,
- most likely due to a subnet sweep in progress.
- */
- OSM_LOG(sm->p_log, OSM_LOG_VERBOSE,
- "Discovered port num %u with GUID 0x%" PRIx64
- " for parent node GUID 0x%" PRIx64
- ", TID 0x%" PRIx64 "\n",
- port_num, cl_ntoh64(port_guid),
- cl_ntoh64(node_guid), cl_ntoh64(p_smp->trans_id));
-
- p_physp = osm_node_get_physp_ptr(p_node, port_num);
-
- /*
- Determine if we encountered a new Physical Port.
- If so, initialize the new Physical Port then
- continue processing as normal.
- */
- if (!p_physp) {
- OSM_LOG(sm->p_log, OSM_LOG_VERBOSE,
- "Initializing port number %u\n", port_num);
- p_physp = &p_node->physp_table[port_num];
- osm_physp_init(p_physp,
- port_guid,
- port_num,
- p_node,
- osm_madw_get_bind_handle(p_madw),
- p_smp->hop_count, p_smp->initial_path);
- } else {
- /*
- Update the directed route path to this port
- in case the old path is no longer usable.
- */
- p_dr_path = osm_physp_get_dr_path_ptr(p_physp);
- osm_dr_path_init(p_dr_path,
- osm_madw_get_bind_handle(p_madw),
- p_smp->hop_count, p_smp->initial_path);
- }
-
- /* if port just inited or reached INIT state (external reset)
- request update for port related tables */
- p_physp->need_update =
- (ib_port_info_get_port_state(p_pi) == IB_LINK_INIT ||
- p_physp->need_update > 1) ? 1 : 0;
-
- switch (osm_node_get_type(p_node)) {
- case IB_NODE_TYPE_CA:
- case IB_NODE_TYPE_ROUTER:
- __osm_pi_rcv_process_ca_or_router_port(sm,
- p_node, p_physp,
- p_pi);
- break;
- case IB_NODE_TYPE_SWITCH:
- __osm_pi_rcv_process_switch_port(sm,
- p_node, p_physp, p_pi);
- break;
- default:
- OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR 0F07: "
- "Unknown node type %u with GUID 0x%" PRIx64
- "\n", osm_node_get_type(p_node),
- cl_ntoh64(node_guid));
- break;
- }
-
- /*
- Get the tables on the physp.
- */
- if (p_physp->need_update || sm->p_subn->need_update)
- __osm_pi_rcv_get_pkey_slvl_vla_tables(sm, p_node,
- p_physp);
-
- }
-
- CL_PLOCK_RELEASE(sm->p_lock);
-
-Exit:
- /*
- Release the lock before jumping here!!
- */
- OSM_LOG_EXIT(sm->p_log);
-}
diff --git a/contrib/ofed/management/opensm/opensm/osm_prtn.c b/contrib/ofed/management/opensm/opensm/osm_prtn.c
deleted file mode 100644
index be51410..0000000
--- a/contrib/ofed/management/opensm/opensm/osm_prtn.c
+++ /dev/null
@@ -1,392 +0,0 @@
-/*
- * Copyright (c) 2006-2008 Voltaire, Inc. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- */
-
-/*
- * Abstract:
- * Implementation of osm_prtn_t.
- * This object represents an IBA partition.
- * This object is part of the opensm family of objects.
- */
-
-#if HAVE_CONFIG_H
-# include <config.h>
-#endif /* HAVE_CONFIG_H */
-
-#include <stdlib.h>
-#include <string.h>
-#include <stdio.h>
-#include <sys/stat.h>
-#include <complib/cl_debug.h>
-#include <iba/ib_types.h>
-#include <opensm/osm_opensm.h>
-#include <opensm/osm_partition.h>
-#include <opensm/osm_node.h>
-#include <opensm/osm_sa.h>
-#include <opensm/osm_multicast.h>
-
-extern int osm_prtn_config_parse_file(osm_log_t * const p_log,
- osm_subn_t * const p_subn,
- const char *file_name);
-
-static uint16_t global_pkey_counter;
-
-osm_prtn_t *osm_prtn_new(IN const char *name, IN const uint16_t pkey)
-{
- osm_prtn_t *p = malloc(sizeof(*p));
- if (!p)
- return NULL;
-
- memset(p, 0, sizeof(*p));
- p->pkey = pkey;
- p->sl = OSM_DEFAULT_SL;
- cl_map_construct(&p->full_guid_tbl);
- cl_map_init(&p->full_guid_tbl, 32);
- cl_map_construct(&p->part_guid_tbl);
- cl_map_init(&p->part_guid_tbl, 32);
-
- if (name && *name)
- strncpy(p->name, name, sizeof(p->name));
- else
- snprintf(p->name, sizeof(p->name), "%04x", cl_ntoh16(pkey));
-
- return p;
-}
-
-void osm_prtn_delete(IN OUT osm_prtn_t ** const pp_prtn)
-{
- osm_prtn_t *p = *pp_prtn;
-
- cl_map_remove_all(&p->full_guid_tbl);
- cl_map_destroy(&p->full_guid_tbl);
- cl_map_remove_all(&p->part_guid_tbl);
- cl_map_destroy(&p->part_guid_tbl);
- free(p);
- *pp_prtn = NULL;
-}
-
-ib_api_status_t osm_prtn_add_port(osm_log_t * p_log, osm_subn_t * p_subn,
- osm_prtn_t * p, ib_net64_t guid,
- boolean_t full)
-{
- ib_api_status_t status = IB_SUCCESS;
- cl_map_t *p_tbl;
- osm_port_t *p_port;
- osm_physp_t *p_physp;
-
- p_port = osm_get_port_by_guid(p_subn, guid);
- if (!p_port) {
- OSM_LOG(p_log, OSM_LOG_VERBOSE,
- "port 0x%" PRIx64 " not found\n", cl_ntoh64(guid));
- return status;
- }
-
- p_physp = p_port->p_physp;
- if (!p_physp) {
- OSM_LOG(p_log, OSM_LOG_VERBOSE,
- "no physical for port 0x%" PRIx64 "\n",
- cl_ntoh64(guid));
- return status;
- }
-
- if (cl_map_remove(&p->part_guid_tbl, guid) ||
- cl_map_remove(&p->full_guid_tbl, guid)) {
- OSM_LOG(p_log, OSM_LOG_VERBOSE,
- "port 0x%" PRIx64 " already in "
- "partition \'%s\' (0x%04x). Will overwrite\n",
- cl_ntoh64(guid), p->name, cl_ntoh16(p->pkey));
- }
-
- p_tbl = (full == TRUE) ? &p->full_guid_tbl : &p->part_guid_tbl;
-
- if (cl_map_insert(p_tbl, guid, p_physp) == NULL)
- return IB_INSUFFICIENT_MEMORY;
-
- return status;
-}
-
-ib_api_status_t osm_prtn_add_all(osm_log_t * p_log, osm_subn_t * p_subn,
- osm_prtn_t * p, boolean_t full)
-{
- cl_qmap_t *p_port_tbl = &p_subn->port_guid_tbl;
- cl_map_item_t *p_item;
- osm_port_t *p_port;
- ib_api_status_t status = IB_SUCCESS;
-
- p_item = cl_qmap_head(p_port_tbl);
- while (p_item != cl_qmap_end(p_port_tbl)) {
- p_port = (osm_port_t *) p_item;
- p_item = cl_qmap_next(p_item);
- status = osm_prtn_add_port(p_log, p_subn, p,
- osm_port_get_guid(p_port), full);
- if (status != IB_SUCCESS)
- goto _err;
- }
-
-_err:
- return status;
-}
-
-static const ib_gid_t osm_ipoib_mgid = {
- {
- 0xff, /* multicast field */
- 0x12, /* non-permanent bit, link local scope */
- 0x40, 0x1b, /* IPv4 signature */
- 0xff, 0xff, /* 16 bits of P_Key (to be filled in) */
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 48 bits of zeros */
- 0xff, 0xff, 0xff, 0xff, /* 32 bit IPv4 broadcast address */
- },
-};
-
-/*
- * HACK: Until TS resolves their noncompliant join compmask,
- * we have to pre-define the MGID
- */
-static const ib_gid_t osm_ts_ipoib_mgid = {
- {
- 0xff, /* multicast field */
- 0x12, /* non-permanent bit, link local scope */
- 0x40, 0x1b, /* IPv4 signature */
- 0xff, 0xff, /* 16 bits of P_Key (to be filled in) */
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 48 bits of zeros */
- 0x00, 0x00, 0x00, 0x01, /* 32 bit IPv4 broadcast address */
- },
-};
-
-ib_api_status_t osm_prtn_add_mcgroup(osm_log_t * p_log,
- osm_subn_t * p_subn, osm_prtn_t * p,
- uint8_t rate,
- uint8_t mtu, uint8_t scope)
-{
- ib_member_rec_t mc_rec;
- ib_net64_t comp_mask;
- ib_net16_t pkey;
- osm_mgrp_t *p_mgrp = NULL;
- osm_sa_t *p_sa = &p_subn->p_osm->sa;
- ib_api_status_t status = IB_SUCCESS;
- uint8_t hop_limit;
-
- pkey = p->pkey | cl_hton16(0x8000);
- if (!scope)
- scope = OSM_DEFAULT_MGRP_SCOPE;
- hop_limit = (scope == IB_MC_SCOPE_LINK_LOCAL) ? 0 : IB_HOPLIMIT_MAX;
-
- memset(&mc_rec, 0, sizeof(mc_rec));
-
- mc_rec.mgid = osm_ipoib_mgid; /* ipv4 broadcast group */
- memcpy(&mc_rec.mgid.raw[4], &pkey, sizeof(pkey));
-
- mc_rec.qkey = CL_HTON32(0x0b1b);
- mc_rec.mtu = (mtu ? mtu : OSM_DEFAULT_MGRP_MTU) | (2 << 6); /* 2048 Bytes */
- mc_rec.tclass = 0;
- mc_rec.pkey = pkey;
- mc_rec.rate = (rate ? rate : OSM_DEFAULT_MGRP_RATE) | (2 << 6); /* 10Gb/sec */
- mc_rec.pkt_life = p_subn->opt.subnet_timeout;
- mc_rec.sl_flow_hop = ib_member_set_sl_flow_hop(p->sl, 0, hop_limit);
- /* Scope in MCMemberRecord (if present) needs to be consistent with MGID */
- mc_rec.scope_state = ib_member_set_scope_state(scope, IB_MC_REC_STATE_FULL_MEMBER);
- ib_mgid_set_scope(&mc_rec.mgid, scope);
-
- /* don't update rate, mtu */
- comp_mask = IB_MCR_COMPMASK_MTU | IB_MCR_COMPMASK_MTU_SEL |
- IB_MCR_COMPMASK_RATE | IB_MCR_COMPMASK_RATE_SEL;
- status = osm_mcmr_rcv_find_or_create_new_mgrp(p_sa, comp_mask, &mc_rec,
- &p_mgrp);
- if (!p_mgrp || status != IB_SUCCESS)
- OSM_LOG(p_log, OSM_LOG_ERROR,
- "Failed to create MC group with pkey 0x%04x\n",
- cl_ntoh16(pkey));
- if (p_mgrp) {
- p_mgrp->well_known = TRUE;
- p->mlid = p_mgrp->mlid;
- }
-
- /* workaround for TS */
- /* FIXME: remove this upon TS fixes */
- mc_rec.mgid = osm_ts_ipoib_mgid;
- memcpy(&mc_rec.mgid.raw[4], &pkey, sizeof(pkey));
- /* Scope in MCMemberRecord (if present) needs to be consistent with MGID */
- mc_rec.scope_state = ib_member_set_scope_state(scope, IB_MC_REC_STATE_FULL_MEMBER);
- ib_mgid_set_scope(&mc_rec.mgid, scope);
-
- status = osm_mcmr_rcv_find_or_create_new_mgrp(p_sa, comp_mask, &mc_rec,
- &p_mgrp);
- if (p_mgrp) {
- p_mgrp->well_known = TRUE;
- if (!p->mlid)
- p->mlid = p_mgrp->mlid;
- }
-
- return status;
-}
-
-static uint16_t __generate_pkey(osm_subn_t * p_subn)
-{
- uint16_t pkey;
-
- cl_qmap_t *m = &p_subn->prtn_pkey_tbl;
- while (global_pkey_counter < cl_ntoh16(IB_DEFAULT_PARTIAL_PKEY) - 1) {
- pkey = ++global_pkey_counter;
- pkey = cl_hton16(pkey);
- if (cl_qmap_get(m, pkey) == cl_qmap_end(m))
- return pkey;
- }
- return 0;
-}
-
-osm_prtn_t *osm_prtn_find_by_name(osm_subn_t * p_subn, const char *name)
-{
- cl_map_item_t *p_next;
- osm_prtn_t *p;
-
- p_next = cl_qmap_head(&p_subn->prtn_pkey_tbl);
- while (p_next != cl_qmap_end(&p_subn->prtn_pkey_tbl)) {
- p = (osm_prtn_t *) p_next;
- p_next = cl_qmap_next(&p->map_item);
- if (!strncmp(p->name, name, sizeof(p->name)))
- return p;
- }
-
- return NULL;
-}
-
-osm_prtn_t *osm_prtn_make_new(osm_log_t * p_log, osm_subn_t * p_subn,
- const char *name, uint16_t pkey)
-{
- osm_prtn_t *p = NULL, *p_check;
-
- pkey &= cl_hton16((uint16_t) ~ 0x8000);
-
- if (!pkey) {
- if (name && (p = osm_prtn_find_by_name(p_subn, name)))
- return p;
- if (!(pkey = __generate_pkey(p_subn)))
- return NULL;
- }
-
- p = osm_prtn_new(name, pkey);
- if (!p) {
- OSM_LOG(p_log, OSM_LOG_ERROR, "Unable to create"
- " partition \'%s\' (0x%04x)\n", name, cl_ntoh16(pkey));
- return NULL;
- }
-
- p_check = (osm_prtn_t *) cl_qmap_insert(&p_subn->prtn_pkey_tbl,
- p->pkey, &p->map_item);
- if (p != p_check) {
- OSM_LOG(p_log, OSM_LOG_VERBOSE, "Duplicated partition"
- " definition: \'%s\' (0x%04x) prev name \'%s\'"
- ". Will use it\n",
- name, cl_ntoh16(pkey), p_check->name);
- osm_prtn_delete(&p);
- p = p_check;
- }
-
- return p;
-}
-
-static ib_api_status_t osm_prtn_make_default(osm_log_t * const p_log,
- osm_subn_t * const p_subn,
- boolean_t no_config)
-{
- ib_api_status_t status = IB_UNKNOWN_ERROR;
- osm_prtn_t *p;
-
- p = osm_prtn_make_new(p_log, p_subn, "Default",
- IB_DEFAULT_PARTIAL_PKEY);
- if (!p)
- goto _err;
- status = osm_prtn_add_all(p_log, p_subn, p, no_config);
- if (status != IB_SUCCESS)
- goto _err;
- cl_map_remove(&p->part_guid_tbl, p_subn->sm_port_guid);
- status =
- osm_prtn_add_port(p_log, p_subn, p, p_subn->sm_port_guid, TRUE);
-
- if (no_config)
- osm_prtn_add_mcgroup(p_log, p_subn, p, 0, 0, 0);
-
-_err:
- return status;
-}
-
-ib_api_status_t osm_prtn_make_partitions(osm_log_t * const p_log,
- osm_subn_t * const p_subn)
-{
- struct stat statbuf;
- const char *file_name;
- boolean_t is_config = TRUE;
- ib_api_status_t status = IB_SUCCESS;
- cl_map_item_t *p_next;
- osm_prtn_t *p;
-
- file_name = p_subn->opt.partition_config_file ?
- p_subn->opt.partition_config_file : OSM_DEFAULT_PARTITION_CONFIG_FILE;
- if (stat(file_name, &statbuf))
- is_config = FALSE;
-
- /* clean up current port maps */
- p_next = cl_qmap_head(&p_subn->prtn_pkey_tbl);
- while (p_next != cl_qmap_end(&p_subn->prtn_pkey_tbl)) {
- p = (osm_prtn_t *) p_next;
- p_next = cl_qmap_next(&p->map_item);
- cl_map_remove_all(&p->part_guid_tbl);
- cl_map_remove_all(&p->full_guid_tbl);
- }
-
- global_pkey_counter = 0;
-
- status = osm_prtn_make_default(p_log, p_subn, !is_config);
- if (status != IB_SUCCESS)
- goto _err;
-
- if (is_config && osm_prtn_config_parse_file(p_log, p_subn, file_name)) {
- OSM_LOG(p_log, OSM_LOG_VERBOSE, "Partition configuration "
- "was not fully processed\n");
- }
-
- /* and now clean up empty partitions */
- p_next = cl_qmap_head(&p_subn->prtn_pkey_tbl);
- while (p_next != cl_qmap_end(&p_subn->prtn_pkey_tbl)) {
- p = (osm_prtn_t *) p_next;
- p_next = cl_qmap_next(&p->map_item);
- if (cl_map_count(&p->part_guid_tbl) == 0 &&
- cl_map_count(&p->full_guid_tbl) == 0) {
- cl_qmap_remove_item(&p_subn->prtn_pkey_tbl,
- (cl_map_item_t *) p);
- osm_prtn_delete(&p);
- }
- }
-
-_err:
- return status;
-}
diff --git a/contrib/ofed/management/opensm/opensm/osm_prtn_config.c b/contrib/ofed/management/opensm/opensm/osm_prtn_config.c
deleted file mode 100644
index d663fad..0000000
--- a/contrib/ofed/management/opensm/opensm/osm_prtn_config.c
+++ /dev/null
@@ -1,462 +0,0 @@
-/*
- * Copyright (c) 2006-2007 Voltaire, Inc. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- */
-
-/*
- * Abstract:
- * Implementation of opensm partition management configuration
- */
-
-#if HAVE_CONFIG_H
-# include <config.h>
-#endif /* HAVE_CONFIG_H */
-
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-#include <errno.h>
-#include <ctype.h>
-
-#include <iba/ib_types.h>
-#include <opensm/osm_base.h>
-#include <opensm/osm_partition.h>
-#include <opensm/osm_subnet.h>
-#include <opensm/osm_log.h>
-
-#include <complib/cl_byteswap.h>
-
-struct part_conf {
- osm_log_t *p_log;
- osm_subn_t *p_subn;
- osm_prtn_t *p_prtn;
- unsigned is_ipoib, mtu, rate, sl, scope_mask;
- boolean_t full;
-};
-
-extern osm_prtn_t *osm_prtn_make_new(osm_log_t * p_log, osm_subn_t * p_subn,
- const char *name, uint16_t pkey);
-extern ib_api_status_t osm_prtn_add_all(osm_log_t * p_log,
- osm_subn_t * p_subn,
- osm_prtn_t * p, boolean_t full);
-extern ib_api_status_t osm_prtn_add_port(osm_log_t * p_log,
- osm_subn_t * p_subn, osm_prtn_t * p,
- ib_net64_t guid, boolean_t full);
-extern ib_api_status_t osm_prtn_add_mcgroup(osm_log_t * p_log,
- osm_subn_t * p_subn, osm_prtn_t * p,
- uint8_t rate,
- uint8_t mtu, uint8_t scope);
-
-static int partition_create(unsigned lineno, struct part_conf *conf,
- char *name, char *id, char *flag, char *flag_val)
-{
- uint16_t pkey;
- unsigned int scope;
-
- if (!id && name && isdigit(*name)) {
- id = name;
- name = NULL;
- }
-
- if (id) {
- char *end;
-
- pkey = (uint16_t) strtoul(id, &end, 0);
- if (end == id || *end)
- return -1;
- } else
- pkey = 0;
-
- conf->p_prtn = osm_prtn_make_new(conf->p_log, conf->p_subn,
- name, cl_hton16(pkey));
- if (!conf->p_prtn)
- return -1;
-
- if (!conf->p_subn->opt.qos && conf->sl != OSM_DEFAULT_SL) {
- OSM_LOG(conf->p_log, OSM_LOG_DEBUG, "Overriding SL %d"
- " to default SL %d on partition %s"
- " as QoS is not enabled.\n",
- conf->sl, OSM_DEFAULT_SL, name);
- conf->sl = OSM_DEFAULT_SL;
- }
- conf->p_prtn->sl = (uint8_t) conf->sl;
-
- if (!conf->is_ipoib)
- return 0;
-
- if (!conf->scope_mask) {
- osm_prtn_add_mcgroup(conf->p_log, conf->p_subn, conf->p_prtn,
- (uint8_t) conf->rate,
- (uint8_t) conf->mtu,
- 0);
- return 0;
- }
-
- for (scope = 0; scope < 16; scope++) {
- if (((1<<scope) & conf->scope_mask) == 0)
- continue;
-
- osm_prtn_add_mcgroup(conf->p_log, conf->p_subn, conf->p_prtn,
- (uint8_t) conf->rate,
- (uint8_t) conf->mtu,
- (uint8_t) scope);
- }
- return 0;
-}
-
-static int partition_add_flag(unsigned lineno, struct part_conf *conf,
- char *flag, char *val)
-{
- int len = strlen(flag);
- if (!strncmp(flag, "ipoib", len)) {
- conf->is_ipoib = 1;
- } else if (!strncmp(flag, "mtu", len)) {
- if (!val || (conf->mtu = strtoul(val, NULL, 0)) == 0)
- OSM_LOG(conf->p_log, OSM_LOG_VERBOSE,
- "PARSE WARN: line %d: "
- "flag \'mtu\' requires valid value"
- " - skipped\n", lineno);
- } else if (!strncmp(flag, "rate", len)) {
- if (!val || (conf->rate = strtoul(val, NULL, 0)) == 0)
- OSM_LOG(conf->p_log, OSM_LOG_VERBOSE,
- "PARSE WARN: line %d: "
- "flag \'rate\' requires valid value"
- " - skipped\n", lineno);
- } else if (!strncmp(flag, "scope", len)) {
- unsigned int scope;
- if (!val || (scope = strtoul(val, NULL, 0)) == 0 || scope > 0xF)
- OSM_LOG(conf->p_log, OSM_LOG_VERBOSE,
- "PARSE WARN: line %d: "
- "flag \'scope\' requires valid value"
- " - skipped\n", lineno);
- else
- conf->scope_mask |= (1<<scope);
- } else if (!strncmp(flag, "sl", len)) {
- unsigned sl;
- char *end;
-
- if (!val || !*val || (sl = strtoul(val, &end, 0)) > 15 ||
- (*end && !isspace(*end)))
- OSM_LOG(conf->p_log, OSM_LOG_VERBOSE,
- "PARSE WARN: line %d: "
- "flag \'sl\' requires valid value"
- " - skipped\n", lineno);
- else
- conf->sl = sl;
- } else if (!strncmp(flag, "defmember", len)) {
- if (!val || (strncmp(val, "limited", strlen(val))
- && strncmp(val, "full", strlen(val))))
- OSM_LOG(conf->p_log, OSM_LOG_VERBOSE,
- "PARSE WARN: line %d: "
- "flag \'defmember\' requires valid value (limited or full)"
- " - skipped\n", lineno);
- else
- conf->full = strncmp(val, "full", strlen(val)) == 0;
- } else {
- OSM_LOG(conf->p_log, OSM_LOG_VERBOSE,
- "PARSE WARN: line %d: "
- "unrecognized partition flag \'%s\'"
- " - ignored\n", lineno, flag);
- }
- return 0;
-}
-
-static int partition_add_port(unsigned lineno, struct part_conf *conf,
- char *name, char *flag)
-{
- osm_prtn_t *p = conf->p_prtn;
- ib_net64_t guid;
- boolean_t full = conf->full;
-
- if (!name || !*name || !strncmp(name, "NONE", strlen(name)))
- return 0;
-
- if (flag) {
- /* reset default membership to limited */
- full = FALSE;
- if (!strncmp(flag, "full", strlen(flag)))
- full = TRUE;
- else if (strncmp(flag, "limited", strlen(flag))) {
- OSM_LOG(conf->p_log, OSM_LOG_VERBOSE,
- "PARSE WARN: line %d: "
- "unrecognized port flag \'%s\'."
- " Assume \'limited\'\n", lineno, flag);
- }
- }
-
- if (!strncmp(name, "ALL", strlen(name))) {
- return osm_prtn_add_all(conf->p_log, conf->p_subn, p,
- full) == IB_SUCCESS ? 0 : -1;
- } else if (!strncmp(name, "SELF", strlen(name))) {
- guid = cl_ntoh64(conf->p_subn->sm_port_guid);
- } else {
- char *end;
- guid = strtoull(name, &end, 0);
- if (!guid || *end)
- return -1;
- }
-
- if (osm_prtn_add_port(conf->p_log, conf->p_subn, p,
- cl_hton64(guid), full) != IB_SUCCESS)
- return -1;
-
- return 0;
-}
-
-/* conf file parser */
-
-#define STRIP_HEAD_SPACES(p) while (*(p) == ' ' || *(p) == '\t' || \
- *(p) == '\n') { (p)++; }
-#define STRIP_TAIL_SPACES(p) { char *q = (p) + strlen(p); \
- while ( q != (p) && ( *q == '\0' || \
- *q == ' ' || *q == '\t' || \
- *q == '\n')) { *q-- = '\0'; }; }
-
-static int parse_name_token(char *str, char **name, char **val)
-{
- int len = 0;
- char *p, *q;
-
- *name = *val = NULL;
-
- p = str;
-
- while (*p == ' ' || *p == '\t' || *p == '\n')
- p++;
-
- q = strchr(p, '=');
- if (q)
- *q++ = '\0';
-
- len = strlen(str) + 1;
- str = q;
-
- q = p + strlen(p);
- while (q != p && (*q == '\0' || *q == ' ' || *q == '\t' || *q == '\n'))
- *q-- = '\0';
-
- *name = p;
-
- p = str;
- if (!p)
- return len;
-
- while (*p == ' ' || *p == '\t' || *p == '\n')
- p++;
-
- q = p + strlen(p);
- len += (int)(q - str) + 1;
- while (q != p && (*q == '\0' || *q == ' ' || *q == '\t' || *q == '\n'))
- *q-- = '\0';
- *val = p;
-
- return len;
-}
-
-static struct part_conf *new_part_conf(osm_log_t * p_log, osm_subn_t * p_subn)
-{
- static struct part_conf part;
- struct part_conf *conf = &part;
-
- memset(conf, 0, sizeof(*conf));
- conf->p_log = p_log;
- conf->p_subn = p_subn;
- conf->p_prtn = NULL;
- conf->is_ipoib = 0;
- conf->sl = OSM_DEFAULT_SL;
- conf->full = FALSE;
- return conf;
-}
-
-static int flush_part_conf(struct part_conf *conf)
-{
- memset(conf, 0, sizeof(*conf));
- return 0;
-}
-
-static int parse_part_conf(struct part_conf *conf, char *str, int lineno)
-{
- int ret, len = 0;
- char *name, *id, *flag, *flval;
- char *q, *p;
-
- p = str;
- if (*p == '\t' || *p == '\0' || *p == '\n')
- p++;
-
- len += (int)(p - str);
- str = p;
-
- if (conf->p_prtn)
- goto skip_header;
-
- q = strchr(p, ':');
- if (!q) {
- OSM_LOG(conf->p_log, OSM_LOG_ERROR, "PARSE ERROR: line %d: "
- "no partition definition found\n", lineno);
- fprintf(stderr, "\nPARSE ERROR: line %d: "
- "no partition definition found\n", lineno);
- return -1;
- }
-
- *q++ = '\0';
- str = q;
-
- name = id = flag = flval = NULL;
-
- q = strchr(p, ',');
- if (q)
- *q = '\0';
-
- ret = parse_name_token(p, &name, &id);
- p += ret;
- len += ret;
-
- while (q) {
- flag = flval = NULL;
- q = strchr(p, ',');
- if (q)
- *q++ = '\0';
- ret = parse_name_token(p, &flag, &flval);
- if (!flag) {
- OSM_LOG(conf->p_log, OSM_LOG_ERROR,
- "PARSE ERROR: line %d: "
- "bad partition flags\n", lineno);
- fprintf(stderr, "\nPARSE ERROR: line %d: "
- "bad partition flags\n", lineno);
- return -1;
- }
- p += ret;
- len += ret;
- partition_add_flag(lineno, conf, flag, flval);
- }
-
- if (p != str || (partition_create(lineno, conf,
- name, id, flag, flval) < 0)) {
- OSM_LOG(conf->p_log, OSM_LOG_ERROR, "PARSE ERROR: line %d: "
- "bad partition definition\n", lineno);
- fprintf(stderr, "\nPARSE ERROR: line %d: "
- "bad partition definition\n", lineno);
- return -1;
- }
-
-skip_header:
- do {
- name = flag = NULL;
- q = strchr(p, ',');
- if (q)
- *q++ = '\0';
- ret = parse_name_token(p, &name, &flag);
- if (partition_add_port(lineno, conf, name, flag) < 0) {
- OSM_LOG(conf->p_log, OSM_LOG_ERROR,
- "PARSE ERROR: line %d: "
- "bad PortGUID\n", lineno);
- fprintf(stderr, "PARSE ERROR: line %d: "
- "bad PortGUID\n", lineno);
- return -1;
- }
- p += ret;
- len += ret;
- } while (q);
-
- return len;
-}
-
-int osm_prtn_config_parse_file(osm_log_t * p_log, osm_subn_t * p_subn,
- const char *file_name)
-{
- char line[1024];
- struct part_conf *conf = NULL;
- FILE *file;
- int lineno;
-
- file = fopen(file_name, "r");
- if (!file) {
- OSM_LOG(p_log, OSM_LOG_VERBOSE,
- "Cannot open config file \'%s\': %s\n",
- file_name, strerror(errno));
- return -1;
- }
-
- lineno = 0;
-
- while (fgets(line, sizeof(line) - 1, file) != NULL) {
- char *q, *p = line;
-
- lineno++;
-
- p = line;
-
- q = strchr(p, '#');
- if (q)
- *q = '\0';
-
- do {
- int len;
- while (*p == ' ' || *p == '\t' || *p == '\n')
- p++;
- if (*p == '\0')
- break;
-
- if (!conf && !(conf = new_part_conf(p_log, p_subn))) {
- OSM_LOG(conf->p_log, OSM_LOG_ERROR,
- "PARSE ERROR: line %d: "
- "internal: cannot create config\n",
- lineno);
- fprintf(stderr,
- "PARSE ERROR: line %d: "
- "internal: cannot create config\n",
- lineno);
- break;
- }
-
- q = strchr(p, ';');
- if (q)
- *q = '\0';
-
- len = parse_part_conf(conf, p, lineno);
- if (len < 0) {
- break;
- }
-
- p += len;
-
- if (q) {
- flush_part_conf(conf);
- conf = NULL;
- }
- } while (q);
- }
-
- fclose(file);
-
- return 0;
-}
diff --git a/contrib/ofed/management/opensm/opensm/osm_qos.c b/contrib/ofed/management/opensm/opensm/osm_qos.c
deleted file mode 100644
index b451c25..0000000
--- a/contrib/ofed/management/opensm/opensm/osm_qos.c
+++ /dev/null
@@ -1,413 +0,0 @@
-/*
- * Copyright (c) 2006-2008 Voltaire, Inc. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- */
-
-/*
- * Abstract:
- * Implementation of OpenSM QoS infrastructure primitives
- */
-
-#if HAVE_CONFIG_H
-# include <config.h>
-#endif /* HAVE_CONFIG_H */
-
-#include <stdlib.h>
-#include <string.h>
-
-#include <iba/ib_types.h>
-#include <complib/cl_qmap.h>
-#include <complib/cl_debug.h>
-#include <opensm/osm_opensm.h>
-#include <opensm/osm_subnet.h>
-#include <opensm/osm_qos_policy.h>
-
-struct qos_config {
- uint8_t max_vls;
- uint8_t vl_high_limit;
- ib_vl_arb_table_t vlarb_high[2];
- ib_vl_arb_table_t vlarb_low[2];
- ib_slvl_table_t sl2vl;
-};
-
-static void qos_build_config(struct qos_config *cfg,
- osm_qos_options_t * opt, osm_qos_options_t * dflt);
-
-/*
- * QoS primitives
- */
-static ib_api_status_t vlarb_update_table_block(osm_sm_t * sm,
- osm_physp_t * p,
- uint8_t port_num,
- unsigned force_update,
- const ib_vl_arb_table_t *
- table_block,
- unsigned block_length,
- unsigned block_num)
-{
- ib_vl_arb_table_t block;
- osm_madw_context_t context;
- uint32_t attr_mod;
- unsigned vl_mask, i;
-
- vl_mask = (1 << (ib_port_info_get_op_vls(&p->port_info) - 1)) - 1;
-
- memset(&block, 0, sizeof(block));
- memcpy(&block, table_block, block_length * sizeof(block.vl_entry[0]));
- for (i = 0; i < block_length; i++)
- block.vl_entry[i].vl &= vl_mask;
-
- if (!force_update &&
- !memcmp(&p->vl_arb[block_num], &block,
- block_length * sizeof(block.vl_entry[0])))
- return IB_SUCCESS;
-
- context.vla_context.node_guid =
- osm_node_get_node_guid(osm_physp_get_node_ptr(p));
- context.vla_context.port_guid = osm_physp_get_port_guid(p);
- context.vla_context.set_method = TRUE;
- attr_mod = ((block_num + 1) << 16) | port_num;
-
- return osm_req_set(sm, osm_physp_get_dr_path_ptr(p),
- (uint8_t *) & block, sizeof(block),
- IB_MAD_ATTR_VL_ARBITRATION,
- cl_hton32(attr_mod), CL_DISP_MSGID_NONE, &context);
-}
-
-static ib_api_status_t vlarb_update(osm_sm_t * sm,
- osm_physp_t * p, uint8_t port_num,
- unsigned force_update,
- const struct qos_config *qcfg)
-{
- ib_api_status_t status = IB_SUCCESS;
- ib_port_info_t *p_pi = &p->port_info;
- unsigned len;
-
- if (p_pi->vl_arb_low_cap > 0) {
- len = p_pi->vl_arb_low_cap < IB_NUM_VL_ARB_ELEMENTS_IN_BLOCK ?
- p_pi->vl_arb_low_cap : IB_NUM_VL_ARB_ELEMENTS_IN_BLOCK;
- if ((status = vlarb_update_table_block(sm, p, port_num,
- force_update,
- &qcfg->vlarb_low[0],
- len, 0)) != IB_SUCCESS)
- return status;
- }
- if (p_pi->vl_arb_low_cap > IB_NUM_VL_ARB_ELEMENTS_IN_BLOCK) {
- len = p_pi->vl_arb_low_cap % IB_NUM_VL_ARB_ELEMENTS_IN_BLOCK;
- if ((status = vlarb_update_table_block(sm, p, port_num,
- force_update,
- &qcfg->vlarb_low[1],
- len, 1)) != IB_SUCCESS)
- return status;
- }
- if (p_pi->vl_arb_high_cap > 0) {
- len = p_pi->vl_arb_high_cap < IB_NUM_VL_ARB_ELEMENTS_IN_BLOCK ?
- p_pi->vl_arb_high_cap : IB_NUM_VL_ARB_ELEMENTS_IN_BLOCK;
- if ((status = vlarb_update_table_block(sm, p, port_num,
- force_update,
- &qcfg->vlarb_high[0],
- len, 2)) != IB_SUCCESS)
- return status;
- }
- if (p_pi->vl_arb_high_cap > IB_NUM_VL_ARB_ELEMENTS_IN_BLOCK) {
- len = p_pi->vl_arb_high_cap % IB_NUM_VL_ARB_ELEMENTS_IN_BLOCK;
- if ((status = vlarb_update_table_block(sm, p, port_num,
- force_update,
- &qcfg->vlarb_high[1],
- len, 3)) != IB_SUCCESS)
- return status;
- }
-
- return status;
-}
-
-static ib_api_status_t sl2vl_update_table(osm_sm_t * sm,
- osm_physp_t * p, uint8_t in_port,
- uint8_t out_port,
- unsigned force_update,
- const ib_slvl_table_t * sl2vl_table)
-{
- osm_madw_context_t context;
- ib_slvl_table_t tbl, *p_tbl;
- osm_node_t *p_node = osm_physp_get_node_ptr(p);
- uint32_t attr_mod;
- unsigned vl_mask;
- uint8_t vl1, vl2;
- int i;
-
- vl_mask = (1 << (ib_port_info_get_op_vls(&p->port_info) - 1)) - 1;
-
- for (i = 0; i < IB_MAX_NUM_VLS / 2; i++) {
- vl1 = sl2vl_table->raw_vl_by_sl[i] >> 4;
- vl2 = sl2vl_table->raw_vl_by_sl[i] & 0xf;
- if (vl1 != 15)
- vl1 &= vl_mask;
- if (vl2 != 15)
- vl2 &= vl_mask;
- tbl.raw_vl_by_sl[i] = (vl1 << 4) | vl2;
- }
-
- if (!force_update && (p_tbl = osm_physp_get_slvl_tbl(p, in_port)) &&
- !memcmp(p_tbl, &tbl, sizeof(tbl)))
- return IB_SUCCESS;
-
- context.slvl_context.node_guid = osm_node_get_node_guid(p_node);
- context.slvl_context.port_guid = osm_physp_get_port_guid(p);
- context.slvl_context.set_method = TRUE;
- attr_mod = in_port << 8 | out_port;
- return osm_req_set(sm, osm_physp_get_dr_path_ptr(p),
- (uint8_t *) & tbl, sizeof(tbl),
- IB_MAD_ATTR_SLVL_TABLE,
- cl_hton32(attr_mod), CL_DISP_MSGID_NONE, &context);
-}
-
-static ib_api_status_t sl2vl_update(osm_sm_t * sm, osm_port_t * p_port,
- osm_physp_t * p, uint8_t port_num,
- unsigned force_update,
- const struct qos_config *qcfg)
-{
- ib_api_status_t status;
- uint8_t i, num_ports;
- osm_physp_t *p_physp;
-
- if (osm_node_get_type(osm_physp_get_node_ptr(p)) == IB_NODE_TYPE_SWITCH) {
- if (ib_port_info_get_vl_cap(&p->port_info) == 1) {
- /* Check port 0's capability mask */
- p_physp = p_port->p_physp;
- if (!
- (p_physp->port_info.
- capability_mask & IB_PORT_CAP_HAS_SL_MAP))
- return IB_SUCCESS;
- }
- num_ports = osm_node_get_num_physp(osm_physp_get_node_ptr(p));
- } else {
- if (!(p->port_info.capability_mask & IB_PORT_CAP_HAS_SL_MAP))
- return IB_SUCCESS;
- num_ports = 1;
- }
-
- for (i = 0; i < num_ports; i++) {
- status =
- sl2vl_update_table(sm, p, i, port_num,
- force_update, &qcfg->sl2vl);
- if (status != IB_SUCCESS)
- return status;
- }
-
- return IB_SUCCESS;
-}
-
-static ib_api_status_t qos_physp_setup(osm_log_t * p_log, osm_sm_t * sm,
- osm_port_t * p_port, osm_physp_t * p,
- uint8_t port_num,
- unsigned force_update,
- const struct qos_config *qcfg)
-{
- ib_api_status_t status;
-
- /* OpVLs should be ok at this moment - just use it */
-
- /* setup VL high limit on the physp later to be updated by link mgr */
- p->vl_high_limit = qcfg->vl_high_limit;
-
- /* setup VLArbitration */
- status = vlarb_update(sm, p, port_num, force_update, qcfg);
- if (status != IB_SUCCESS) {
- OSM_LOG(p_log, OSM_LOG_ERROR, "ERR 6202 : "
- "failed to update VLArbitration tables "
- "for port %" PRIx64 " #%d\n",
- cl_ntoh64(p->port_guid), port_num);
- return status;
- }
-
- /* setup SL2VL tables */
- status = sl2vl_update(sm, p_port, p, port_num, force_update, qcfg);
- if (status != IB_SUCCESS) {
- OSM_LOG(p_log, OSM_LOG_ERROR, "ERR 6203 : "
- "failed to update SL2VLMapping tables "
- "for port %" PRIx64 " #%d\n",
- cl_ntoh64(p->port_guid), port_num);
- return status;
- }
-
- return IB_SUCCESS;
-}
-
-osm_signal_t osm_qos_setup(osm_opensm_t * p_osm)
-{
- struct qos_config ca_config, sw0_config, swe_config, rtr_config;
- struct qos_config *cfg;
- cl_qmap_t *p_tbl;
- cl_map_item_t *p_next;
- osm_port_t *p_port;
- uint32_t num_physp;
- osm_physp_t *p_physp;
- osm_node_t *p_node;
- ib_api_status_t status;
- unsigned force_update;
- uint8_t i;
-
- if (!p_osm->subn.opt.qos)
- return OSM_SIGNAL_DONE;
-
- OSM_LOG_ENTER(&p_osm->log);
-
- qos_build_config(&ca_config, &p_osm->subn.opt.qos_ca_options,
- &p_osm->subn.opt.qos_options);
- qos_build_config(&sw0_config, &p_osm->subn.opt.qos_sw0_options,
- &p_osm->subn.opt.qos_options);
- qos_build_config(&swe_config, &p_osm->subn.opt.qos_swe_options,
- &p_osm->subn.opt.qos_options);
- qos_build_config(&rtr_config, &p_osm->subn.opt.qos_rtr_options,
- &p_osm->subn.opt.qos_options);
-
- cl_plock_excl_acquire(&p_osm->lock);
-
- /* read QoS policy config file */
- osm_qos_parse_policy_file(&p_osm->subn);
-
- p_tbl = &p_osm->subn.port_guid_tbl;
- p_next = cl_qmap_head(p_tbl);
- while (p_next != cl_qmap_end(p_tbl)) {
- p_port = (osm_port_t *) p_next;
- p_next = cl_qmap_next(p_next);
-
- p_node = p_port->p_node;
- if (p_node->sw) {
- num_physp = osm_node_get_num_physp(p_node);
- for (i = 1; i < num_physp; i++) {
- p_physp = osm_node_get_physp_ptr(p_node, i);
- if (!p_physp)
- continue;
- force_update = p_physp->need_update ||
- p_osm->subn.need_update;
- status =
- qos_physp_setup(&p_osm->log, &p_osm->sm,
- p_port, p_physp, i,
- force_update, &swe_config);
- }
- /* skip base port 0 */
- if (!ib_switch_info_is_enhanced_port0
- (&p_node->sw->switch_info))
- continue;
-
- cfg = &sw0_config;
- } else if (osm_node_get_type(p_node) == IB_NODE_TYPE_ROUTER)
- cfg = &rtr_config;
- else
- cfg = &ca_config;
-
- p_physp = p_port->p_physp;
- if (!p_physp)
- continue;
-
- force_update = p_physp->need_update || p_osm->subn.need_update;
- status = qos_physp_setup(&p_osm->log, &p_osm->sm,
- p_port, p_physp, 0, force_update, cfg);
- }
-
- cl_plock_release(&p_osm->lock);
- OSM_LOG_EXIT(&p_osm->log);
-
- return OSM_SIGNAL_DONE;
-}
-
-/*
- * QoS config stuff
- */
-static int parse_one_unsigned(char *str, char delim, unsigned *val)
-{
- char *end;
- *val = strtoul(str, &end, 0);
- if (*end)
- end++;
- return (int)(end - str);
-}
-
-static int parse_vlarb_entry(char *str, ib_vl_arb_element_t * e)
-{
- unsigned val;
- char *p = str;
- p += parse_one_unsigned(p, ':', &val);
- e->vl = val % 15;
- p += parse_one_unsigned(p, ',', &val);
- e->weight = (uint8_t) val;
- return (int)(p - str);
-}
-
-static int parse_sl2vl_entry(char *str, uint8_t * raw)
-{
- unsigned val1, val2;
- char *p = str;
- p += parse_one_unsigned(p, ',', &val1);
- p += parse_one_unsigned(p, ',', &val2);
- *raw = (val1 << 4) | (val2 & 0xf);
- return (int)(p - str);
-}
-
-static void qos_build_config(struct qos_config *cfg,
- osm_qos_options_t * opt, osm_qos_options_t * dflt)
-{
- int i;
- char *p;
-
- memset(cfg, 0, sizeof(*cfg));
-
- cfg->max_vls = opt->max_vls > 0 ? opt->max_vls : dflt->max_vls;
-
- if (opt->high_limit >= 0)
- cfg->vl_high_limit = (uint8_t) opt->high_limit;
- else
- cfg->vl_high_limit = (uint8_t) dflt->high_limit;
-
- p = opt->vlarb_high ? opt->vlarb_high : dflt->vlarb_high;
- for (i = 0; i < 2 * IB_NUM_VL_ARB_ELEMENTS_IN_BLOCK; i++) {
- p += parse_vlarb_entry(p,
- &cfg->vlarb_high[i /
- IB_NUM_VL_ARB_ELEMENTS_IN_BLOCK].
- vl_entry[i %
- IB_NUM_VL_ARB_ELEMENTS_IN_BLOCK]);
- }
-
- p = opt->vlarb_low ? opt->vlarb_low : dflt->vlarb_low;
- for (i = 0; i < 2 * IB_NUM_VL_ARB_ELEMENTS_IN_BLOCK; i++) {
- p += parse_vlarb_entry(p,
- &cfg->vlarb_low[i /
- IB_NUM_VL_ARB_ELEMENTS_IN_BLOCK].
- vl_entry[i %
- IB_NUM_VL_ARB_ELEMENTS_IN_BLOCK]);
- }
-
- p = opt->sl2vl ? opt->sl2vl : dflt->sl2vl;
- for (i = 0; i < IB_MAX_NUM_VLS / 2; i++)
- p += parse_sl2vl_entry(p, &cfg->sl2vl.raw_vl_by_sl[i]);
-
-}
diff --git a/contrib/ofed/management/opensm/opensm/osm_qos_parser_l.l b/contrib/ofed/management/opensm/opensm/osm_qos_parser_l.l
deleted file mode 100644
index ecdee8a..0000000
--- a/contrib/ofed/management/opensm/opensm/osm_qos_parser_l.l
+++ /dev/null
@@ -1,394 +0,0 @@
-%{
-/*
- * Copyright (c) 2004-2006 Voltaire, Inc. All rights reserved.
- * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved.
- * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- */
-
-/*
- * Abstract:
- * Lexer of OSM QoS parser.
- *
- * Environment:
- * Linux User Mode
- *
- * Author:
- * Yevgeny Kliteynik, Mellanox
- */
-
-#include <opensm/osm_qos_policy.h>
-#include "osm_qos_parser_y.h"
-
-#define HANDLE_IF_IN_DESCRIPTION if (in_description) { yylval = strdup(yytext); return TK_TEXT; }
-
-#define SAVE_POS save_pos()
-static void save_pos();
-
-extern int column_num;
-extern int line_num;
-extern FILE * yyin;
-extern YYSTYPE yylval;
-
-boolean_t in_description = FALSE;
-boolean_t in_list_of_hex_num_ranges = FALSE;
-boolean_t in_node_type = FALSE;
-boolean_t in_list_of_numbers = FALSE;
-boolean_t in_list_of_strings = FALSE;
-boolean_t in_list_of_num_pairs = FALSE;
-boolean_t in_asterisk_or_list_of_numbers = FALSE;
-boolean_t in_list_of_num_ranges = FALSE;
-boolean_t in_single_string = FALSE;
-boolean_t in_single_number = FALSE;
-
-static void reset_new_line_flags();
-#define RESET_NEW_LINE_FLAGS reset_new_line_flags()
-
-#define START_USE {in_description = TRUE;} /* list of strings including whitespace (description) */
-#define START_PORT_GUID {in_list_of_hex_num_ranges = TRUE;} /* comma-separated list of hex num ranges */
-#define START_PORT_NAME {in_list_of_strings = TRUE;} /* comma-separated list of following strings: ../../.. */
-#define START_PARTITION {in_single_string = TRUE;} /* single string w/o whitespaces (partition name) */
-#define START_NAME {in_single_string = TRUE;} /* single string w/o whitespaces (port group name) */
-#define START_QOS_LEVEL_NAME {in_single_string = TRUE;} /* single string w/o whitespaces (qos level name in match rule) */
-
-#define START_NODE_TYPE {in_node_type = TRUE;} /* comma-separated list of node types (ROUTER,CA,...) */
-#define START_SL2VL_TABLE {in_list_of_numbers = TRUE;} /* comma-separated list of hex or dec numbers */
-
-#define START_GROUP {in_list_of_strings = TRUE;} /* list of strings w/o whitespaces (group names) */
-#define START_ACROSS {in_list_of_strings = TRUE;} /* list of strings w/o whitespaces (group names) */
-#define START_ACROSS_TO {in_list_of_strings = TRUE;} /* list of strings w/o whitespaces (group names) */
-#define START_ACROSS_FROM {in_list_of_strings = TRUE;} /* list of strings w/o whitespaces (group names) */
-#define START_SOURCE {in_list_of_strings = TRUE;} /* list of strings w/o whitespaces (group names) */
-#define START_DESTINATION {in_list_of_strings = TRUE;} /* list of strings w/o whitespaces (group names) */
-
-#define START_VLARB_HIGH {in_list_of_num_pairs = TRUE;} /* comma-separated list of hex or dec num pairs: "num1:num2" */
-#define START_VLARB_LOW {in_list_of_num_pairs = TRUE;} /* comma-separated list of hex or dec num pairs: "num1:num2" */
-
-#define START_TO {in_asterisk_or_list_of_numbers = TRUE;} /* (asterisk) or (comma-separated list of hex or dec numbers) */
-#define START_FROM {in_asterisk_or_list_of_numbers = TRUE;} /* (asterisk) or (comma-separated list of hex or dec numbers) */
-
-#define START_PATH_BITS {in_list_of_num_ranges = TRUE;} /* comma-separated list of hex or dec num ranges */
-#define START_QOS_CLASS {in_list_of_num_ranges = TRUE;} /* comma-separated list of hex or dec num ranges */
-#define START_SERVICE_ID {in_list_of_num_ranges = TRUE;} /* comma-separated list of hex or dec num ranges */
-#define START_PKEY {in_list_of_num_ranges = TRUE;} /* comma-separated list of hex or dec num ranges */
-
-#define START_SL {in_single_number = TRUE;} /* single number */
-#define START_VLARB_HIGH_LIMIT {in_single_number = TRUE;} /* single number */
-#define START_MTU_LIMIT {in_single_number = TRUE;} /* single number */
-#define START_RATE_LIMIT {in_single_number = TRUE;} /* single number */
-#define START_PACKET_LIFE {in_single_number = TRUE;} /* single number */
-
-#define START_ULP_DEFAULT {in_single_number = TRUE;} /* single number */
-#define START_ULP_ANY {in_list_of_num_ranges = TRUE;} /* comma-separated list of hex or dec num ranges */
-#define START_ULP_SDP_DEFAULT {in_single_number = TRUE;} /* single number */
-#define START_ULP_SDP_PORT {in_list_of_num_ranges = TRUE;} /* comma-separated list of hex or dec num ranges */
-#define START_ULP_RDS_DEFAULT {in_single_number = TRUE;} /* single number */
-#define START_ULP_RDS_PORT {in_list_of_num_ranges = TRUE;} /* comma-separated list of hex or dec num ranges */
-#define START_ULP_ISER_DEFAULT {in_single_number = TRUE;} /* single number */
-#define START_ULP_ISER_PORT {in_list_of_num_ranges = TRUE;} /* comma-separated list of hex or dec num ranges */
-#define START_ULP_SRP_GUID {in_list_of_num_ranges = TRUE;} /* comma-separated list of hex or dec num ranges */
-#define START_ULP_IPOIB_DEFAULT {in_single_number = TRUE;} /* single number */
-#define START_ULP_IPOIB_PKEY {in_list_of_num_ranges = TRUE;} /* comma-separated list of hex or dec num ranges */
-
-
-%}
-
-%option nounput noinput
-
-QOS_ULPS_START qos\-ulps
-QOS_ULPS_END end\-qos\-ulps
-PORT_GROUPS_START port\-groups
-PORT_GROUPS_END end\-port\-groups
-PORT_GROUP_START port\-group
-PORT_GROUP_END end\-port\-group
-PORT_NUM port\-num
-NAME name
-USE use
-PORT_GUID port\-guid
-TARGET_PORT_GUID target\-port\-guid
-PORT_NAME port\-name
-PARTITION partition
-NODE_TYPE node\-type
-QOS_SETUP_START qos\-setup
-QOS_SETUP_END end\-qos\-setup
-VLARB_TABLES_START vlarb\-tables
-VLARB_TABLES_END end\-vlarb\-tables
-VLARB_SCOPE_START vlarb\-scope
-VLARB_SCOPE_END end\-vlarb\-scope
-GROUP group
-ACROSS across
-VLARB_HIGH vlarb\-high
-VLARB_LOW vlarb\-low
-VLARB_HIGH_LIMIT vl\-high\-limit
-SL2VL_TABLES_START sl2vl\-tables
-SL2VL_TABLES_END end\-sl2vl\-tables
-SL2VL_SCOPE_START sl2vl\-scope
-SL2VL_SCOPE_END end\-sl2vl\-scope
-TO to
-FROM from
-ACROSS_TO across\-to
-ACROSS_FROM across\-from
-SL2VL_TABLE sl2vl\-table
-QOS_LEVELS_START qos\-levels
-QOS_LEVELS_END end\-qos\-levels
-QOS_LEVEL_START qos\-level
-QOS_LEVEL_END end\-qos\-level
-SL sl
-MTU_LIMIT mtu\-limit
-RATE_LIMIT rate\-limit
-PACKET_LIFE packet\-life
-PATH_BITS path\-bits
-QOS_MATCH_RULES_START qos\-match\-rules
-QOS_MATCH_RULES_END end\-qos\-match\-rules
-QOS_MATCH_RULE_START qos\-match\-rule
-QOS_MATCH_RULE_END end\-qos\-match\-rule
-QOS_CLASS qos\-class
-SOURCE source
-DESTINATION destination
-SERVICE_ID service\-id
-PKEY pkey
-QOS_LEVEL_NAME qos\-level\-name
-
-ROUTER [Rr][Oo][Uu][Tt][Ee][Rr]
-CA [Cc][Aa]
-SWITCH [Ss][Ww][Ii][Tt][Cc][Hh]
-SELF [Ss][Ee][Ll][Ff]
-ALL [Aa][Ll][Ll]
-
-ULP_SDP [Ss][Dd][Pp]
-ULP_SRP [Ss][Rr][Pp]
-ULP_RDS [Rr][Dd][Ss]
-ULP_IPOIB [Ii][Pp][Oo][Ii][Bb]
-ULP_ISER [Ii][Ss][Ee][Rr]
-ULP_ANY [Aa][Nn][Yy]
-ULP_DEFAULT [Dd][Ee][Ff][Aa][Uu][Ll][Tt]
-
-WHITE [ \t]+
-NEW_LINE \n
-COMMENT \#.*\n
-WHITE_DOTDOT_WHITE [ \t]*:[ \t]*
-WHITE_COMMA_WHITE [ \t]*,[ \t]*
-QUOTED_TEXT \"[^\"]*\"
-
-%%
-
-
-{COMMENT} { SAVE_POS; RESET_NEW_LINE_FLAGS; } /* swallow comment */
-{WHITE}{NEW_LINE} { SAVE_POS; RESET_NEW_LINE_FLAGS; } /* trailing blanks with new line */
-{WHITE} { SAVE_POS; HANDLE_IF_IN_DESCRIPTION; }
-{NEW_LINE} { SAVE_POS; RESET_NEW_LINE_FLAGS; }
-
-{QOS_ULPS_START} { SAVE_POS; HANDLE_IF_IN_DESCRIPTION; return TK_QOS_ULPS_START; }
-{QOS_ULPS_END} { SAVE_POS; HANDLE_IF_IN_DESCRIPTION; return TK_QOS_ULPS_END; }
-
-{PORT_GROUPS_START} { SAVE_POS; HANDLE_IF_IN_DESCRIPTION; return TK_PORT_GROUPS_START; }
-{PORT_GROUPS_END} { SAVE_POS; HANDLE_IF_IN_DESCRIPTION; return TK_PORT_GROUPS_END; }
-{PORT_GROUP_START} { SAVE_POS; HANDLE_IF_IN_DESCRIPTION; return TK_PORT_GROUP_START; }
-{PORT_GROUP_END} { SAVE_POS; HANDLE_IF_IN_DESCRIPTION; return TK_PORT_GROUP_END; }
-
-{QOS_SETUP_START} { SAVE_POS; HANDLE_IF_IN_DESCRIPTION; return TK_QOS_SETUP_START; }
-{QOS_SETUP_END} { SAVE_POS; HANDLE_IF_IN_DESCRIPTION; return TK_QOS_SETUP_END; }
-{VLARB_TABLES_START} { SAVE_POS; HANDLE_IF_IN_DESCRIPTION; return TK_VLARB_TABLES_START; }
-{VLARB_TABLES_END} { SAVE_POS; HANDLE_IF_IN_DESCRIPTION; return TK_VLARB_TABLES_END; }
-{VLARB_SCOPE_START} { SAVE_POS; HANDLE_IF_IN_DESCRIPTION; return TK_VLARB_SCOPE_START; }
-{VLARB_SCOPE_END} { SAVE_POS; HANDLE_IF_IN_DESCRIPTION; return TK_VLARB_SCOPE_END; }
-
-{SL2VL_TABLES_START} { SAVE_POS; HANDLE_IF_IN_DESCRIPTION; return TK_SL2VL_TABLES_START; }
-{SL2VL_TABLES_END} { SAVE_POS; HANDLE_IF_IN_DESCRIPTION; return TK_SL2VL_TABLES_END; }
-{SL2VL_SCOPE_START} { SAVE_POS; HANDLE_IF_IN_DESCRIPTION; return TK_SL2VL_SCOPE_START; }
-{SL2VL_SCOPE_END} { SAVE_POS; HANDLE_IF_IN_DESCRIPTION; return TK_SL2VL_SCOPE_END; }
-
-{QOS_LEVELS_START} { SAVE_POS; HANDLE_IF_IN_DESCRIPTION; return TK_QOS_LEVELS_START; }
-{QOS_LEVELS_END} { SAVE_POS; HANDLE_IF_IN_DESCRIPTION; return TK_QOS_LEVELS_END; }
-{QOS_LEVEL_START} { SAVE_POS; HANDLE_IF_IN_DESCRIPTION; return TK_QOS_LEVEL_START; }
-{QOS_LEVEL_END} { SAVE_POS; HANDLE_IF_IN_DESCRIPTION; return TK_QOS_LEVEL_END; }
-
-{QOS_MATCH_RULES_START} { SAVE_POS; HANDLE_IF_IN_DESCRIPTION; return TK_QOS_MATCH_RULES_START; }
-{QOS_MATCH_RULES_END} { SAVE_POS; HANDLE_IF_IN_DESCRIPTION; return TK_QOS_MATCH_RULES_END; }
-{QOS_MATCH_RULE_START} { SAVE_POS; HANDLE_IF_IN_DESCRIPTION; return TK_QOS_MATCH_RULE_START; }
-{QOS_MATCH_RULE_END} { SAVE_POS; HANDLE_IF_IN_DESCRIPTION; return TK_QOS_MATCH_RULE_END; }
-
-{PORT_GUID}{WHITE_DOTDOT_WHITE} { SAVE_POS; HANDLE_IF_IN_DESCRIPTION; START_PORT_GUID; return TK_PORT_GUID; }
-{PORT_NAME}{WHITE_DOTDOT_WHITE} { SAVE_POS; HANDLE_IF_IN_DESCRIPTION; START_PORT_NAME; return TK_PORT_NAME; }
-{PARTITION}{WHITE_DOTDOT_WHITE} { SAVE_POS; HANDLE_IF_IN_DESCRIPTION; START_PARTITION; return TK_PARTITION; }
-{NODE_TYPE}{WHITE_DOTDOT_WHITE} { SAVE_POS; HANDLE_IF_IN_DESCRIPTION; START_NODE_TYPE; return TK_NODE_TYPE; }
-{NAME}{WHITE_DOTDOT_WHITE} { SAVE_POS; HANDLE_IF_IN_DESCRIPTION; START_NAME; return TK_NAME; }
-{USE}{WHITE_DOTDOT_WHITE} { SAVE_POS; HANDLE_IF_IN_DESCRIPTION; START_USE; return TK_USE; }
-{GROUP}{WHITE_DOTDOT_WHITE} { SAVE_POS; HANDLE_IF_IN_DESCRIPTION; START_GROUP; return TK_GROUP; }
-{VLARB_HIGH}{WHITE_DOTDOT_WHITE} { SAVE_POS; HANDLE_IF_IN_DESCRIPTION; START_VLARB_HIGH; return TK_VLARB_HIGH; }
-{VLARB_LOW}{WHITE_DOTDOT_WHITE} { SAVE_POS; HANDLE_IF_IN_DESCRIPTION; START_VLARB_LOW; return TK_VLARB_LOW; }
-{VLARB_HIGH_LIMIT}{WHITE_DOTDOT_WHITE} { SAVE_POS; HANDLE_IF_IN_DESCRIPTION; START_VLARB_HIGH_LIMIT; return TK_VLARB_HIGH_LIMIT;}
-{TO}{WHITE_DOTDOT_WHITE} { SAVE_POS; HANDLE_IF_IN_DESCRIPTION; START_TO; return TK_TO; }
-{FROM}{WHITE_DOTDOT_WHITE} { SAVE_POS; HANDLE_IF_IN_DESCRIPTION; START_FROM; return TK_FROM; }
-{ACROSS_TO}{WHITE_DOTDOT_WHITE} { SAVE_POS; HANDLE_IF_IN_DESCRIPTION; START_ACROSS_TO; return TK_ACROSS_TO; }
-{ACROSS_FROM}{WHITE_DOTDOT_WHITE} { SAVE_POS; HANDLE_IF_IN_DESCRIPTION; START_ACROSS_FROM; return TK_ACROSS_FROM;}
-{ACROSS}{WHITE_DOTDOT_WHITE} { SAVE_POS; HANDLE_IF_IN_DESCRIPTION; START_ACROSS; return TK_ACROSS; }
-{SL2VL_TABLE}{WHITE_DOTDOT_WHITE} { SAVE_POS; HANDLE_IF_IN_DESCRIPTION; START_SL2VL_TABLE; return TK_SL2VL_TABLE;}
-{SL}{WHITE_DOTDOT_WHITE} { SAVE_POS; HANDLE_IF_IN_DESCRIPTION; START_SL; return TK_SL; }
-{MTU_LIMIT}{WHITE_DOTDOT_WHITE} { SAVE_POS; HANDLE_IF_IN_DESCRIPTION; START_MTU_LIMIT; return TK_MTU_LIMIT; }
-{RATE_LIMIT}{WHITE_DOTDOT_WHITE} { SAVE_POS; HANDLE_IF_IN_DESCRIPTION; START_RATE_LIMIT; return TK_RATE_LIMIT; }
-{PACKET_LIFE}{WHITE_DOTDOT_WHITE} { SAVE_POS; HANDLE_IF_IN_DESCRIPTION; START_PACKET_LIFE; return TK_PACKET_LIFE;}
-{PATH_BITS}{WHITE_DOTDOT_WHITE} { SAVE_POS; HANDLE_IF_IN_DESCRIPTION; START_PATH_BITS; return TK_PATH_BITS; }
-{QOS_CLASS}{WHITE_DOTDOT_WHITE} { SAVE_POS; HANDLE_IF_IN_DESCRIPTION; START_QOS_CLASS; return TK_QOS_CLASS; }
-{SOURCE}{WHITE_DOTDOT_WHITE} { SAVE_POS; HANDLE_IF_IN_DESCRIPTION; START_SOURCE; return TK_SOURCE; }
-{DESTINATION}{WHITE_DOTDOT_WHITE} { SAVE_POS; HANDLE_IF_IN_DESCRIPTION; START_DESTINATION; return TK_DESTINATION;}
-{SERVICE_ID}{WHITE_DOTDOT_WHITE} { SAVE_POS; HANDLE_IF_IN_DESCRIPTION; START_SERVICE_ID; return TK_SERVICE_ID; }
-{PKEY}{WHITE_DOTDOT_WHITE} { SAVE_POS; HANDLE_IF_IN_DESCRIPTION; START_PKEY; return TK_PKEY; }
-{QOS_LEVEL_NAME}{WHITE_DOTDOT_WHITE} { SAVE_POS; HANDLE_IF_IN_DESCRIPTION; START_QOS_LEVEL_NAME; return TK_QOS_LEVEL_NAME;}
-
-{ROUTER} { SAVE_POS; if (in_node_type) return TK_NODE_TYPE_ROUTER; yylval = strdup(yytext); return TK_TEXT; }
-{CA} { SAVE_POS; if (in_node_type) return TK_NODE_TYPE_CA; yylval = strdup(yytext); return TK_TEXT; }
-{SWITCH} { SAVE_POS; if (in_node_type) return TK_NODE_TYPE_SWITCH; yylval = strdup(yytext); return TK_TEXT; }
-{SELF} { SAVE_POS; if (in_node_type) return TK_NODE_TYPE_SELF; yylval = strdup(yytext); return TK_TEXT; }
-{ALL} { SAVE_POS; if (in_node_type) return TK_NODE_TYPE_ALL; yylval = strdup(yytext); return TK_TEXT; }
-
-{ULP_DEFAULT}{WHITE_DOTDOT_WHITE} { SAVE_POS; HANDLE_IF_IN_DESCRIPTION; START_ULP_DEFAULT; return TK_ULP_DEFAULT; }
-{ULP_ANY}{WHITE_COMMA_WHITE}{SERVICE_ID} { SAVE_POS; HANDLE_IF_IN_DESCRIPTION; START_ULP_ANY; return TK_ULP_ANY_SERVICE_ID; }
-{ULP_ANY}{WHITE_COMMA_WHITE}{PKEY} { SAVE_POS; HANDLE_IF_IN_DESCRIPTION; START_ULP_ANY; return TK_ULP_ANY_PKEY; }
-{ULP_ANY}{WHITE_COMMA_WHITE}{TARGET_PORT_GUID} { SAVE_POS; HANDLE_IF_IN_DESCRIPTION; START_ULP_ANY; return TK_ULP_ANY_TARGET_PORT_GUID; }
-
-{ULP_SDP}{WHITE_DOTDOT_WHITE} { SAVE_POS; HANDLE_IF_IN_DESCRIPTION; START_ULP_SDP_DEFAULT; return TK_ULP_SDP_DEFAULT; }
-{ULP_SDP}{WHITE_COMMA_WHITE}{PORT_NUM} { SAVE_POS; HANDLE_IF_IN_DESCRIPTION; START_ULP_SDP_PORT; return TK_ULP_SDP_PORT; }
-
-{ULP_RDS}{WHITE_DOTDOT_WHITE} { SAVE_POS; HANDLE_IF_IN_DESCRIPTION; START_ULP_RDS_DEFAULT; return TK_ULP_RDS_DEFAULT; }
-{ULP_RDS}{WHITE_COMMA_WHITE}{PORT_NUM} { SAVE_POS; HANDLE_IF_IN_DESCRIPTION; START_ULP_RDS_PORT; return TK_ULP_RDS_PORT; }
-
-{ULP_ISER}{WHITE_DOTDOT_WHITE} { SAVE_POS; HANDLE_IF_IN_DESCRIPTION; START_ULP_SDP_DEFAULT; return TK_ULP_ISER_DEFAULT; }
-{ULP_ISER}{WHITE_COMMA_WHITE}{PORT_NUM} { SAVE_POS; HANDLE_IF_IN_DESCRIPTION; START_ULP_SDP_PORT; return TK_ULP_ISER_PORT; }
-
-{ULP_SRP}{WHITE_COMMA_WHITE}{TARGET_PORT_GUID} { SAVE_POS; HANDLE_IF_IN_DESCRIPTION; START_ULP_SRP_GUID; return TK_ULP_SRP_GUID; }
-
-{ULP_IPOIB}{WHITE_DOTDOT_WHITE} { SAVE_POS; HANDLE_IF_IN_DESCRIPTION; START_ULP_IPOIB_DEFAULT; return TK_ULP_IPOIB_DEFAULT; }
-{ULP_IPOIB}{WHITE_COMMA_WHITE}{PKEY} { SAVE_POS; HANDLE_IF_IN_DESCRIPTION; START_ULP_IPOIB_PKEY; return TK_ULP_IPOIB_PKEY; }
-
-0[xX][0-9a-fA-F]+ {
- SAVE_POS;
- yylval = strdup(yytext);
- if (in_description || in_list_of_strings || in_single_string)
- return TK_TEXT;
- return TK_NUMBER;
- }
-
-[0-9]+ {
- SAVE_POS;
- yylval = strdup(yytext);
- if (in_description || in_list_of_strings || in_single_string)
- return TK_TEXT;
- return TK_NUMBER;
- }
-
-
-- {
- SAVE_POS;
- if (in_description || in_list_of_strings || in_single_string)
- {
- yylval = strdup(yytext);
- return TK_TEXT;
- }
- return TK_DASH;
- }
-
-: {
- SAVE_POS;
- if (in_description || in_list_of_strings || in_single_string)
- {
- yylval = strdup(yytext);
- return TK_TEXT;
- }
- return TK_DOTDOT;
- }
-
-, {
- SAVE_POS;
- if (in_description)
- {
- yylval = strdup(yytext);
- return TK_TEXT;
- }
- return TK_COMMA;
- }
-
-\* {
- SAVE_POS;
- if (in_description || in_list_of_strings || in_single_string)
- {
- yylval = strdup(yytext);
- return TK_TEXT;
- }
- return TK_ASTERISK;
- }
-
-{QUOTED_TEXT} {
- SAVE_POS;
- yylval = strdup(&yytext[1]);
- yylval[strlen(yylval)-1] = '\0';
- return TK_TEXT;
- }
-
-. { SAVE_POS; yylval = strdup(yytext); return TK_TEXT;}
-
-%%
-
-
-/*********************************************
- *********************************************/
-
-static void save_pos()
-{
- int i;
- for (i = 0; i < yyleng; i++)
- {
- if (yytext[i] == '\n')
- {
- line_num ++;
- column_num = 1;
- }
- else
- column_num ++;
- }
-}
-
-/*********************************************
- *********************************************/
-
-static void reset_new_line_flags()
-{
- in_description = FALSE;
- in_list_of_hex_num_ranges = FALSE;
- in_node_type = FALSE;
- in_list_of_numbers = FALSE;
- in_list_of_strings = FALSE;
- in_list_of_num_pairs = FALSE;
- in_asterisk_or_list_of_numbers = FALSE;
- in_list_of_num_ranges = FALSE;
- in_single_string = FALSE;
- in_single_number = FALSE;
-}
diff --git a/contrib/ofed/management/opensm/opensm/osm_qos_parser_y.y b/contrib/ofed/management/opensm/opensm/osm_qos_parser_y.y
deleted file mode 100644
index 6b5a9b1..0000000
--- a/contrib/ofed/management/opensm/opensm/osm_qos_parser_y.y
+++ /dev/null
@@ -1,3063 +0,0 @@
-%{
-/*
- * Copyright (c) 2004-2006 Voltaire, Inc. All rights reserved.
- * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved.
- * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
- * Copyright (c) 2008 HNR Consulting. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- */
-
-/*
- * Abstract:
- * Grammar of OSM QoS parser.
- *
- * Environment:
- * Linux User Mode
- *
- * Author:
- * Yevgeny Kliteynik, Mellanox
- */
-
-#include <stdio.h>
-#include <assert.h>
-#include <stdarg.h>
-#include <stdlib.h>
-#include <string.h>
-#include <ctype.h>
-#include <errno.h>
-#include <opensm/osm_opensm.h>
-#include <opensm/osm_qos_policy.h>
-
-#define OSM_QOS_POLICY_MAX_LINE_LEN 1024*10
-#define OSM_QOS_POLICY_SL2VL_TABLE_LEN IB_MAX_NUM_VLS
-#define OSM_QOS_POLICY_MAX_VL_NUM IB_MAX_NUM_VLS
-
-typedef struct tmp_parser_struct_t_ {
- char str[OSM_QOS_POLICY_MAX_LINE_LEN];
- uint64_t num_pair[2];
- cl_list_t str_list;
- cl_list_t num_list;
- cl_list_t num_pair_list;
-} tmp_parser_struct_t;
-
-static void __parser_tmp_struct_init();
-static void __parser_tmp_struct_reset();
-static void __parser_tmp_struct_destroy();
-
-static char * __parser_strip_white(char * str);
-
-static void __parser_str2uint64(uint64_t * p_val, char * str);
-
-static void __parser_port_group_start();
-static int __parser_port_group_end();
-
-static void __parser_sl2vl_scope_start();
-static int __parser_sl2vl_scope_end();
-
-static void __parser_vlarb_scope_start();
-static int __parser_vlarb_scope_end();
-
-static void __parser_qos_level_start();
-static int __parser_qos_level_end();
-
-static void __parser_match_rule_start();
-static int __parser_match_rule_end();
-
-static void __parser_ulp_match_rule_start();
-static int __parser_ulp_match_rule_end();
-
-static void __pkey_rangelist2rangearr(
- cl_list_t * p_list,
- uint64_t ** * p_arr,
- unsigned * p_arr_len);
-
-static void __rangelist2rangearr(
- cl_list_t * p_list,
- uint64_t ** * p_arr,
- unsigned * p_arr_len);
-
-static void __merge_rangearr(
- uint64_t ** range_arr_1,
- unsigned range_len_1,
- uint64_t ** range_arr_2,
- unsigned range_len_2,
- uint64_t ** * p_arr,
- unsigned * p_arr_len );
-
-static void __parser_add_port_to_port_map(
- cl_qmap_t * p_map,
- osm_physp_t * p_physp);
-
-static void __parser_add_guid_range_to_port_map(
- cl_qmap_t * p_map,
- uint64_t ** range_arr,
- unsigned range_len);
-
-static void __parser_add_pkey_range_to_port_map(
- cl_qmap_t * p_map,
- uint64_t ** range_arr,
- unsigned range_len);
-
-static void __parser_add_partition_list_to_port_map(
- cl_qmap_t * p_map,
- cl_list_t * p_list);
-
-static void __parser_add_map_to_port_map(
- cl_qmap_t * p_dmap,
- cl_map_t * p_smap);
-
-static int __validate_pkeys(
- uint64_t ** range_arr,
- unsigned range_len,
- boolean_t is_ipoib);
-
-static void __setup_simple_qos_levels();
-static void __clear_simple_qos_levels();
-static void __setup_ulp_match_rules();
-static void __process_ulp_match_rules();
-static void yyerror(const char *format, ...);
-
-extern char * yytext;
-extern int yylex (void);
-extern FILE * yyin;
-extern int errno;
-int yyparse();
-
-#define RESET_BUFFER __parser_tmp_struct_reset()
-
-tmp_parser_struct_t tmp_parser_struct;
-
-int column_num;
-int line_num;
-
-osm_qos_policy_t * p_qos_policy = NULL;
-osm_qos_port_group_t * p_current_port_group = NULL;
-osm_qos_sl2vl_scope_t * p_current_sl2vl_scope = NULL;
-osm_qos_vlarb_scope_t * p_current_vlarb_scope = NULL;
-osm_qos_level_t * p_current_qos_level = NULL;
-osm_qos_match_rule_t * p_current_qos_match_rule = NULL;
-osm_log_t * p_qos_parser_osm_log;
-
-/* 16 Simple QoS Levels - one for each SL */
-static osm_qos_level_t osm_qos_policy_simple_qos_levels[16];
-
-/* Default Simple QoS Level */
-osm_qos_level_t __default_simple_qos_level;
-
-/*
- * List of match rules that will be generated by the
- * qos-ulp section. These rules are concatenated to
- * the end of the usual matching rules list at the
- * end of parsing.
- */
-static cl_list_t __ulp_match_rules;
-
-/***************************************************/
-
-%}
-
-%token TK_NUMBER
-%token TK_DASH
-%token TK_DOTDOT
-%token TK_COMMA
-%token TK_ASTERISK
-%token TK_TEXT
-
-%token TK_QOS_ULPS_START
-%token TK_QOS_ULPS_END
-
-%token TK_PORT_GROUPS_START
-%token TK_PORT_GROUPS_END
-%token TK_PORT_GROUP_START
-%token TK_PORT_GROUP_END
-
-%token TK_QOS_SETUP_START
-%token TK_QOS_SETUP_END
-%token TK_VLARB_TABLES_START
-%token TK_VLARB_TABLES_END
-%token TK_VLARB_SCOPE_START
-%token TK_VLARB_SCOPE_END
-
-%token TK_SL2VL_TABLES_START
-%token TK_SL2VL_TABLES_END
-%token TK_SL2VL_SCOPE_START
-%token TK_SL2VL_SCOPE_END
-
-%token TK_QOS_LEVELS_START
-%token TK_QOS_LEVELS_END
-%token TK_QOS_LEVEL_START
-%token TK_QOS_LEVEL_END
-
-%token TK_QOS_MATCH_RULES_START
-%token TK_QOS_MATCH_RULES_END
-%token TK_QOS_MATCH_RULE_START
-%token TK_QOS_MATCH_RULE_END
-
-%token TK_NAME
-%token TK_USE
-%token TK_PORT_GUID
-%token TK_PORT_NAME
-%token TK_PARTITION
-%token TK_NODE_TYPE
-%token TK_GROUP
-%token TK_ACROSS
-%token TK_VLARB_HIGH
-%token TK_VLARB_LOW
-%token TK_VLARB_HIGH_LIMIT
-%token TK_TO
-%token TK_FROM
-%token TK_ACROSS_TO
-%token TK_ACROSS_FROM
-%token TK_SL2VL_TABLE
-%token TK_SL
-%token TK_MTU_LIMIT
-%token TK_RATE_LIMIT
-%token TK_PACKET_LIFE
-%token TK_PATH_BITS
-%token TK_QOS_CLASS
-%token TK_SOURCE
-%token TK_DESTINATION
-%token TK_SERVICE_ID
-%token TK_QOS_LEVEL_NAME
-%token TK_PKEY
-
-%token TK_NODE_TYPE_ROUTER
-%token TK_NODE_TYPE_CA
-%token TK_NODE_TYPE_SWITCH
-%token TK_NODE_TYPE_SELF
-%token TK_NODE_TYPE_ALL
-
-%token TK_ULP_DEFAULT
-%token TK_ULP_ANY_SERVICE_ID
-%token TK_ULP_ANY_PKEY
-%token TK_ULP_ANY_TARGET_PORT_GUID
-%token TK_ULP_SDP_DEFAULT
-%token TK_ULP_SDP_PORT
-%token TK_ULP_RDS_DEFAULT
-%token TK_ULP_RDS_PORT
-%token TK_ULP_ISER_DEFAULT
-%token TK_ULP_ISER_PORT
-%token TK_ULP_SRP_GUID
-%token TK_ULP_IPOIB_DEFAULT
-%token TK_ULP_IPOIB_PKEY
-
-%start head
-
-%%
-
-head: qos_policy_entries
- ;
-
-qos_policy_entries: /* empty */
- | qos_policy_entries qos_policy_entry
- ;
-
-qos_policy_entry: qos_ulps_section
- | port_groups_section
- | qos_setup_section
- | qos_levels_section
- | qos_match_rules_section
- ;
-
- /*
- * Parsing qos-ulps:
- * -------------------
- * qos-ulps
- * default : 0 #default SL
- * sdp, port-num 30000 : 1 #SL for SDP when destination port is 30000
- * sdp, port-num 10000-20000 : 2
- * sdp : 0 #default SL for SDP
- * srp, target-port-guid 0x1234 : 2
- * rds, port-num 25000 : 2 #SL for RDS when destination port is 25000
- * rds, : 0 #default SL for RDS
- * iser, port-num 900 : 5 #SL for iSER where target port is 900
- * iser : 4 #default SL for iSER
- * ipoib, pkey 0x0001 : 5 #SL for IPoIB on partition with pkey 0x0001
- * ipoib : 6 #default IPoIB partition - pkey=0x7FFF
- * any, service-id 0x6234 : 2
- * any, pkey 0x0ABC : 3
- * any, target-port-guid 0x0ABC-0xFFFFF : 6
- * end-qos-ulps
- */
-
-qos_ulps_section: TK_QOS_ULPS_START qos_ulps TK_QOS_ULPS_END
- ;
-
-qos_ulps: qos_ulp
- | qos_ulps qos_ulp
- ;
-
- /*
- * Parsing port groups:
- * -------------------
- * port-groups
- * port-group
- * name: Storage
- * use: our SRP storage targets
- * port-guid: 0x1000000000000001,0x1000000000000002
- * ...
- * port-name: vs1 HCA-1/P1
- * port-name: node_description/P2
- * ...
- * pkey: 0x00FF-0x0FFF
- * ...
- * partition: Part1
- * ...
- * node-type: ROUTER,CA,SWITCH,SELF,ALL
- * ...
- * end-port-group
- * port-group
- * ...
- * end-port-group
- * end-port-groups
- */
-
-
-port_groups_section: TK_PORT_GROUPS_START port_groups TK_PORT_GROUPS_END
- ;
-
-port_groups: port_group
- | port_groups port_group
- ;
-
-port_group: port_group_start port_group_entries port_group_end
- ;
-
-port_group_start: TK_PORT_GROUP_START {
- __parser_port_group_start();
- }
- ;
-
-port_group_end: TK_PORT_GROUP_END {
- if ( __parser_port_group_end() )
- return 1;
- }
- ;
-
-port_group_entries: /* empty */
- | port_group_entries port_group_entry
- ;
-
-port_group_entry: port_group_name
- | port_group_use
- | port_group_port_guid
- | port_group_port_name
- | port_group_pkey
- | port_group_partition
- | port_group_node_type
- ;
-
-
- /*
- * Parsing qos setup:
- * -----------------
- * qos-setup
- * vlarb-tables
- * vlarb-scope
- * ...
- * end-vlarb-scope
- * vlarb-scope
- * ...
- * end-vlarb-scope
- * end-vlarb-tables
- * sl2vl-tables
- * sl2vl-scope
- * ...
- * end-sl2vl-scope
- * sl2vl-scope
- * ...
- * end-sl2vl-scope
- * end-sl2vl-tables
- * end-qos-setup
- */
-
-qos_setup_section: TK_QOS_SETUP_START qos_setup_items TK_QOS_SETUP_END
- ;
-
-qos_setup_items: /* empty */
- | qos_setup_items vlarb_tables
- | qos_setup_items sl2vl_tables
- ;
-
- /* Parsing vlarb-tables */
-
-vlarb_tables: TK_VLARB_TABLES_START vlarb_scope_items TK_VLARB_TABLES_END
- ;
-
-vlarb_scope_items: /* empty */
- | vlarb_scope_items vlarb_scope
- ;
-
-vlarb_scope: vlarb_scope_start vlarb_scope_entries vlarb_scope_end
- ;
-
-vlarb_scope_start: TK_VLARB_SCOPE_START {
- __parser_vlarb_scope_start();
- }
- ;
-
-vlarb_scope_end: TK_VLARB_SCOPE_END {
- if ( __parser_vlarb_scope_end() )
- return 1;
- }
- ;
-
-vlarb_scope_entries:/* empty */
- | vlarb_scope_entries vlarb_scope_entry
- ;
-
- /*
- * vlarb-scope
- * group: Storage
- * ...
- * across: Storage
- * ...
- * vlarb-high: 0:255,1:127,2:63,3:31,4:15,5:7,6:3,7:1
- * vlarb-low: 8:255,9:127,10:63,11:31,12:15,13:7,14:3
- * vl-high-limit: 10
- * end-vlarb-scope
- */
-
-vlarb_scope_entry: vlarb_scope_group
- | vlarb_scope_across
- | vlarb_scope_vlarb_high
- | vlarb_scope_vlarb_low
- | vlarb_scope_vlarb_high_limit
- ;
-
- /* Parsing sl2vl-tables */
-
-sl2vl_tables: TK_SL2VL_TABLES_START sl2vl_scope_items TK_SL2VL_TABLES_END
- ;
-
-sl2vl_scope_items: /* empty */
- | sl2vl_scope_items sl2vl_scope
- ;
-
-sl2vl_scope: sl2vl_scope_start sl2vl_scope_entries sl2vl_scope_end
- ;
-
-sl2vl_scope_start: TK_SL2VL_SCOPE_START {
- __parser_sl2vl_scope_start();
- }
- ;
-
-sl2vl_scope_end: TK_SL2VL_SCOPE_END {
- if ( __parser_sl2vl_scope_end() )
- return 1;
- }
- ;
-
-sl2vl_scope_entries:/* empty */
- | sl2vl_scope_entries sl2vl_scope_entry
- ;
-
- /*
- * sl2vl-scope
- * group: Part1
- * ...
- * from: *
- * ...
- * to: *
- * ...
- * across-to: Storage2
- * ...
- * across-from: Storage1
- * ...
- * sl2vl-table: 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,7
- * end-sl2vl-scope
- */
-
-sl2vl_scope_entry: sl2vl_scope_group
- | sl2vl_scope_across
- | sl2vl_scope_across_from
- | sl2vl_scope_across_to
- | sl2vl_scope_from
- | sl2vl_scope_to
- | sl2vl_scope_sl2vl_table
- ;
-
- /*
- * Parsing qos-levels:
- * ------------------
- * qos-levels
- * qos-level
- * name: qos_level_1
- * use: for the lowest priority communication
- * sl: 15
- * mtu-limit: 1
- * rate-limit: 1
- * packet-life: 12
- * path-bits: 2,4,8-32
- * pkey: 0x00FF-0x0FFF
- * end-qos-level
- * ...
- * qos-level
- * end-qos-level
- * end-qos-levels
- */
-
-
-qos_levels_section: TK_QOS_LEVELS_START qos_levels TK_QOS_LEVELS_END
- ;
-
-qos_levels: /* empty */
- | qos_levels qos_level
- ;
-
-qos_level: qos_level_start qos_level_entries qos_level_end
- ;
-
-qos_level_start: TK_QOS_LEVEL_START {
- __parser_qos_level_start();
- }
- ;
-
-qos_level_end: TK_QOS_LEVEL_END {
- if ( __parser_qos_level_end() )
- return 1;
- }
- ;
-
-qos_level_entries: /* empty */
- | qos_level_entries qos_level_entry
- ;
-
-qos_level_entry: qos_level_name
- | qos_level_use
- | qos_level_sl
- | qos_level_mtu_limit
- | qos_level_rate_limit
- | qos_level_packet_life
- | qos_level_path_bits
- | qos_level_pkey
- ;
-
- /*
- * Parsing qos-match-rules:
- * -----------------------
- * qos-match-rules
- * qos-match-rule
- * use: low latency by class 7-9 or 11 and bla bla
- * qos-class: 7-9,11
- * qos-level-name: default
- * source: Storage
- * destination: Storage
- * service-id: 22,4719-5000
- * pkey: 0x00FF-0x0FFF
- * end-qos-match-rule
- * qos-match-rule
- * ...
- * end-qos-match-rule
- * end-qos-match-rules
- */
-
-qos_match_rules_section: TK_QOS_MATCH_RULES_START qos_match_rules TK_QOS_MATCH_RULES_END
- ;
-
-qos_match_rules: /* empty */
- | qos_match_rules qos_match_rule
- ;
-
-qos_match_rule: qos_match_rule_start qos_match_rule_entries qos_match_rule_end
- ;
-
-qos_match_rule_start: TK_QOS_MATCH_RULE_START {
- __parser_match_rule_start();
- }
- ;
-
-qos_match_rule_end: TK_QOS_MATCH_RULE_END {
- if ( __parser_match_rule_end() )
- return 1;
- }
- ;
-
-qos_match_rule_entries: /* empty */
- | qos_match_rule_entries qos_match_rule_entry
- ;
-
-qos_match_rule_entry: qos_match_rule_use
- | qos_match_rule_qos_class
- | qos_match_rule_qos_level_name
- | qos_match_rule_source
- | qos_match_rule_destination
- | qos_match_rule_service_id
- | qos_match_rule_pkey
- ;
-
-
- /*
- * Parsing qos-ulps:
- * -----------------
- * default
- * sdp
- * sdp with port-num
- * rds
- * rds with port-num
- * srp with port-guid
- * iser
- * iser with port-num
- * ipoib
- * ipoib with pkey
- * any with service-id
- * any with pkey
- * any with target-port-guid
- */
-
-qos_ulp: TK_ULP_DEFAULT single_number {
- /* parsing default ulp rule: "default: num" */
- cl_list_iterator_t list_iterator;
- uint64_t * p_tmp_num;
-
- list_iterator = cl_list_head(&tmp_parser_struct.num_list);
- p_tmp_num = (uint64_t*)cl_list_obj(list_iterator);
- if (*p_tmp_num > 15)
- {
- yyerror("illegal SL value");
- return 1;
- }
- __default_simple_qos_level.sl = (uint8_t)(*p_tmp_num);
- __default_simple_qos_level.sl_set = TRUE;
- free(p_tmp_num);
- cl_list_remove_all(&tmp_parser_struct.num_list);
- }
-
- | qos_ulp_type_any_service list_of_ranges TK_DOTDOT {
- /* "any, service-id ... : sl" - one instance of list of ranges */
- uint64_t ** range_arr;
- unsigned range_len;
-
- if (!cl_list_count(&tmp_parser_struct.num_pair_list))
- {
- yyerror("ULP rule doesn't have service ids");
- return 1;
- }
-
- /* get all the service id ranges */
- __rangelist2rangearr( &tmp_parser_struct.num_pair_list,
- &range_arr,
- &range_len );
-
- p_current_qos_match_rule->service_id_range_arr = range_arr;
- p_current_qos_match_rule->service_id_range_len = range_len;
-
- } qos_ulp_sl
-
- | qos_ulp_type_any_pkey list_of_ranges TK_DOTDOT {
- /* "any, pkey ... : sl" - one instance of list of ranges */
- uint64_t ** range_arr;
- unsigned range_len;
-
- if (!cl_list_count(&tmp_parser_struct.num_pair_list))
- {
- yyerror("ULP rule doesn't have pkeys");
- return 1;
- }
-
- /* get all the pkey ranges */
- __pkey_rangelist2rangearr( &tmp_parser_struct.num_pair_list,
- &range_arr,
- &range_len );
-
- p_current_qos_match_rule->pkey_range_arr = range_arr;
- p_current_qos_match_rule->pkey_range_len = range_len;
-
- } qos_ulp_sl
-
- | qos_ulp_type_any_target_port_guid list_of_ranges TK_DOTDOT {
- /* any, target-port-guid ... : sl */
- uint64_t ** range_arr;
- unsigned range_len;
-
- if (!cl_list_count(&tmp_parser_struct.num_pair_list))
- {
- yyerror("ULP rule doesn't have port guids");
- return 1;
- }
-
- /* create a new port group with these ports */
- __parser_port_group_start();
-
- p_current_port_group->name = strdup("_ULP_Targets_");
- p_current_port_group->use = strdup("Generated from ULP rules");
-
- __rangelist2rangearr( &tmp_parser_struct.num_pair_list,
- &range_arr,
- &range_len );
-
- __parser_add_guid_range_to_port_map(
- &p_current_port_group->port_map,
- range_arr,
- range_len);
-
- /* add this port group to the destination
- groups of the current match rule */
- cl_list_insert_tail(&p_current_qos_match_rule->destination_group_list,
- p_current_port_group);
-
- __parser_port_group_end();
-
- } qos_ulp_sl
-
- | qos_ulp_type_sdp_default {
- /* "sdp : sl" - default SL for SDP */
- uint64_t ** range_arr =
- (uint64_t **)malloc(sizeof(uint64_t *));
- range_arr[0] = (uint64_t *)malloc(2*sizeof(uint64_t));
- range_arr[0][0] = OSM_QOS_POLICY_ULP_SDP_SERVICE_ID;
- range_arr[0][1] = OSM_QOS_POLICY_ULP_SDP_SERVICE_ID + 0xFFFF;
-
- p_current_qos_match_rule->service_id_range_arr = range_arr;
- p_current_qos_match_rule->service_id_range_len = 1;
-
- } qos_ulp_sl
-
- | qos_ulp_type_sdp_port list_of_ranges TK_DOTDOT {
- /* sdp with port numbers */
- uint64_t ** range_arr;
- unsigned range_len;
- unsigned i;
-
- if (!cl_list_count(&tmp_parser_struct.num_pair_list))
- {
- yyerror("SDP ULP rule doesn't have port numbers");
- return 1;
- }
-
- /* get all the port ranges */
- __rangelist2rangearr( &tmp_parser_struct.num_pair_list,
- &range_arr,
- &range_len );
- /* now translate these port numbers into service ids */
- for (i = 0; i < range_len; i++)
- {
- if (range_arr[i][0] > 0xFFFF || range_arr[i][1] > 0xFFFF)
- {
- yyerror("SDP port number out of range");
- return 1;
- }
- range_arr[i][0] += OSM_QOS_POLICY_ULP_SDP_SERVICE_ID;
- range_arr[i][1] += OSM_QOS_POLICY_ULP_SDP_SERVICE_ID;
- }
-
- p_current_qos_match_rule->service_id_range_arr = range_arr;
- p_current_qos_match_rule->service_id_range_len = range_len;
-
- } qos_ulp_sl
-
- | qos_ulp_type_rds_default {
- /* "rds : sl" - default SL for RDS */
- uint64_t ** range_arr =
- (uint64_t **)malloc(sizeof(uint64_t *));
- range_arr[0] = (uint64_t *)malloc(2*sizeof(uint64_t));
- range_arr[0][0] = range_arr[0][1] =
- OSM_QOS_POLICY_ULP_RDS_SERVICE_ID + OSM_QOS_POLICY_ULP_RDS_PORT;
-
- p_current_qos_match_rule->service_id_range_arr = range_arr;
- p_current_qos_match_rule->service_id_range_len = 1;
-
- } qos_ulp_sl
-
- | qos_ulp_type_rds_port list_of_ranges TK_DOTDOT {
- /* rds with port numbers */
- uint64_t ** range_arr;
- unsigned range_len;
- unsigned i;
-
- if (!cl_list_count(&tmp_parser_struct.num_pair_list))
- {
- yyerror("RDS ULP rule doesn't have port numbers");
- return 1;
- }
-
- /* get all the port ranges */
- __rangelist2rangearr( &tmp_parser_struct.num_pair_list,
- &range_arr,
- &range_len );
- /* now translate these port numbers into service ids */
- for (i = 0; i < range_len; i++)
- {
- if (range_arr[i][0] > 0xFFFF || range_arr[i][1] > 0xFFFF)
- {
- yyerror("SDP port number out of range");
- return 1;
- }
- range_arr[i][0] += OSM_QOS_POLICY_ULP_RDS_SERVICE_ID;
- range_arr[i][1] += OSM_QOS_POLICY_ULP_RDS_SERVICE_ID;
- }
-
- p_current_qos_match_rule->service_id_range_arr = range_arr;
- p_current_qos_match_rule->service_id_range_len = range_len;
-
- } qos_ulp_sl
-
- | qos_ulp_type_iser_default {
- /* "iSER : sl" - default SL for iSER */
- uint64_t ** range_arr =
- (uint64_t **)malloc(sizeof(uint64_t *));
- range_arr[0] = (uint64_t *)malloc(2*sizeof(uint64_t));
- range_arr[0][0] = range_arr[0][1] =
- OSM_QOS_POLICY_ULP_ISER_SERVICE_ID + OSM_QOS_POLICY_ULP_ISER_PORT;
-
- p_current_qos_match_rule->service_id_range_arr = range_arr;
- p_current_qos_match_rule->service_id_range_len = 1;
-
- } qos_ulp_sl
-
- | qos_ulp_type_iser_port list_of_ranges TK_DOTDOT {
- /* iser with port numbers */
- uint64_t ** range_arr;
- unsigned range_len;
- unsigned i;
-
- if (!cl_list_count(&tmp_parser_struct.num_pair_list))
- {
- yyerror("iSER ULP rule doesn't have port numbers");
- return 1;
- }
-
- /* get all the port ranges */
- __rangelist2rangearr( &tmp_parser_struct.num_pair_list,
- &range_arr,
- &range_len );
- /* now translate these port numbers into service ids */
- for (i = 0; i < range_len; i++)
- {
- if (range_arr[i][0] > 0xFFFF || range_arr[i][1] > 0xFFFF)
- {
- yyerror("SDP port number out of range");
- return 1;
- }
- range_arr[i][0] += OSM_QOS_POLICY_ULP_ISER_SERVICE_ID;
- range_arr[i][1] += OSM_QOS_POLICY_ULP_ISER_SERVICE_ID;
- }
-
- p_current_qos_match_rule->service_id_range_arr = range_arr;
- p_current_qos_match_rule->service_id_range_len = range_len;
-
- } qos_ulp_sl
-
- | qos_ulp_type_srp_guid list_of_ranges TK_DOTDOT {
- /* srp with target guids - this rule is similar
- to writing 'any' ulp with target port guids */
- uint64_t ** range_arr;
- unsigned range_len;
-
- if (!cl_list_count(&tmp_parser_struct.num_pair_list))
- {
- yyerror("SRP ULP rule doesn't have port guids");
- return 1;
- }
-
- /* create a new port group with these ports */
- __parser_port_group_start();
-
- p_current_port_group->name = strdup("_SRP_Targets_");
- p_current_port_group->use = strdup("Generated from ULP rules");
-
- __rangelist2rangearr( &tmp_parser_struct.num_pair_list,
- &range_arr,
- &range_len );
-
- __parser_add_guid_range_to_port_map(
- &p_current_port_group->port_map,
- range_arr,
- range_len);
-
- /* add this port group to the destination
- groups of the current match rule */
- cl_list_insert_tail(&p_current_qos_match_rule->destination_group_list,
- p_current_port_group);
-
- __parser_port_group_end();
-
- } qos_ulp_sl
-
- | qos_ulp_type_ipoib_default {
- /* ipoib w/o any pkeys (default pkey) */
- uint64_t ** range_arr =
- (uint64_t **)malloc(sizeof(uint64_t *));
- range_arr[0] = (uint64_t *)malloc(2*sizeof(uint64_t));
- range_arr[0][0] = range_arr[0][1] = 0x7fff;
-
- /*
- * Although we know that the default partition exists,
- * we still need to validate it by checking that it has
- * at least two full members. Otherwise IPoIB won't work.
- */
- if (__validate_pkeys(range_arr, 1, TRUE))
- return 1;
-
- p_current_qos_match_rule->pkey_range_arr = range_arr;
- p_current_qos_match_rule->pkey_range_len = 1;
-
- } qos_ulp_sl
-
- | qos_ulp_type_ipoib_pkey list_of_ranges TK_DOTDOT {
- /* ipoib with pkeys */
- uint64_t ** range_arr;
- unsigned range_len;
-
- if (!cl_list_count(&tmp_parser_struct.num_pair_list))
- {
- yyerror("IPoIB ULP rule doesn't have pkeys");
- return 1;
- }
-
- /* get all the pkey ranges */
- __pkey_rangelist2rangearr( &tmp_parser_struct.num_pair_list,
- &range_arr,
- &range_len );
-
- /*
- * Validate pkeys.
- * For IPoIB pkeys the validation is strict.
- * If some problem would be found, parsing will
- * be aborted with a proper error messages.
- */
- if (__validate_pkeys(range_arr, range_len, TRUE))
- return 1;
-
- p_current_qos_match_rule->pkey_range_arr = range_arr;
- p_current_qos_match_rule->pkey_range_len = range_len;
-
- } qos_ulp_sl
- ;
-
-qos_ulp_type_any_service: TK_ULP_ANY_SERVICE_ID
- { __parser_ulp_match_rule_start(); };
-
-qos_ulp_type_any_pkey: TK_ULP_ANY_PKEY
- { __parser_ulp_match_rule_start(); };
-
-qos_ulp_type_any_target_port_guid: TK_ULP_ANY_TARGET_PORT_GUID
- { __parser_ulp_match_rule_start(); };
-
-qos_ulp_type_sdp_default: TK_ULP_SDP_DEFAULT
- { __parser_ulp_match_rule_start(); };
-
-qos_ulp_type_sdp_port: TK_ULP_SDP_PORT
- { __parser_ulp_match_rule_start(); };
-
-qos_ulp_type_rds_default: TK_ULP_RDS_DEFAULT
- { __parser_ulp_match_rule_start(); };
-
-qos_ulp_type_rds_port: TK_ULP_RDS_PORT
- { __parser_ulp_match_rule_start(); };
-
-qos_ulp_type_iser_default: TK_ULP_ISER_DEFAULT
- { __parser_ulp_match_rule_start(); };
-
-qos_ulp_type_iser_port: TK_ULP_ISER_PORT
- { __parser_ulp_match_rule_start(); };
-
-qos_ulp_type_srp_guid: TK_ULP_SRP_GUID
- { __parser_ulp_match_rule_start(); };
-
-qos_ulp_type_ipoib_default: TK_ULP_IPOIB_DEFAULT
- { __parser_ulp_match_rule_start(); };
-
-qos_ulp_type_ipoib_pkey: TK_ULP_IPOIB_PKEY
- { __parser_ulp_match_rule_start(); };
-
-
-qos_ulp_sl: single_number {
- /* get the SL for ULP rules */
- cl_list_iterator_t list_iterator;
- uint64_t * p_tmp_num;
- uint8_t sl;
-
- list_iterator = cl_list_head(&tmp_parser_struct.num_list);
- p_tmp_num = (uint64_t*)cl_list_obj(list_iterator);
- if (*p_tmp_num > 15)
- {
- yyerror("illegal SL value");
- return 1;
- }
-
- sl = (uint8_t)(*p_tmp_num);
- free(p_tmp_num);
- cl_list_remove_all(&tmp_parser_struct.num_list);
-
- p_current_qos_match_rule->p_qos_level =
- &osm_qos_policy_simple_qos_levels[sl];
- p_current_qos_match_rule->qos_level_name =
- strdup(osm_qos_policy_simple_qos_levels[sl].name);
-
- if (__parser_ulp_match_rule_end())
- return 1;
- }
- ;
-
- /*
- * port_group_entry values:
- * port_group_name
- * port_group_use
- * port_group_port_guid
- * port_group_port_name
- * port_group_pkey
- * port_group_partition
- * port_group_node_type
- */
-
-port_group_name: port_group_name_start single_string {
- /* 'name' of 'port-group' - one instance */
- cl_list_iterator_t list_iterator;
- char * tmp_str;
-
- if (p_current_port_group->name)
- {
- yyerror("port-group has multiple 'name' tags");
- cl_list_remove_all(&tmp_parser_struct.str_list);
- return 1;
- }
-
- list_iterator = cl_list_head(&tmp_parser_struct.str_list);
- if ( list_iterator != cl_list_end(&tmp_parser_struct.str_list) )
- {
- tmp_str = (char*)cl_list_obj(list_iterator);
- if (tmp_str)
- p_current_port_group->name = tmp_str;
- }
- cl_list_remove_all(&tmp_parser_struct.str_list);
- }
- ;
-
-port_group_name_start: TK_NAME {
- RESET_BUFFER;
- }
- ;
-
-port_group_use: port_group_use_start single_string {
- /* 'use' of 'port-group' - one instance */
- cl_list_iterator_t list_iterator;
- char * tmp_str;
-
- if (p_current_port_group->use)
- {
- yyerror("port-group has multiple 'use' tags");
- cl_list_remove_all(&tmp_parser_struct.str_list);
- return 1;
- }
-
- list_iterator = cl_list_head(&tmp_parser_struct.str_list);
- if ( list_iterator != cl_list_end(&tmp_parser_struct.str_list) )
- {
- tmp_str = (char*)cl_list_obj(list_iterator);
- if (tmp_str)
- p_current_port_group->use = tmp_str;
- }
- cl_list_remove_all(&tmp_parser_struct.str_list);
- }
- ;
-
-port_group_use_start: TK_USE {
- RESET_BUFFER;
- }
- ;
-
-port_group_port_name: port_group_port_name_start string_list {
- /* 'port-name' in 'port-group' - any num of instances */
- cl_list_iterator_t list_iterator;
- osm_node_t * p_node;
- osm_physp_t * p_physp;
- unsigned port_num;
- char * tmp_str;
- char * port_str;
-
- /* parsing port name strings */
- for (list_iterator = cl_list_head(&tmp_parser_struct.str_list);
- list_iterator != cl_list_end(&tmp_parser_struct.str_list);
- list_iterator = cl_list_next(list_iterator))
- {
- tmp_str = (char*)cl_list_obj(list_iterator);
- if (tmp_str)
- {
- /* last slash in port name string is a separator
- between node name and port number */
- port_str = strrchr(tmp_str, '/');
- if (!port_str || (strlen(port_str) < 3) ||
- (port_str[1] != 'p' && port_str[1] != 'P')) {
- yyerror("'%s' - illegal port name",
- tmp_str);
- free(tmp_str);
- cl_list_remove_all(&tmp_parser_struct.str_list);
- return 1;
- }
-
- if (!(port_num = strtoul(&port_str[2],NULL,0))) {
- yyerror(
- "'%s' - illegal port number in port name",
- tmp_str);
- free(tmp_str);
- cl_list_remove_all(&tmp_parser_struct.str_list);
- return 1;
- }
-
- /* separate node name from port number */
- port_str[0] = '\0';
-
- if (st_lookup(p_qos_policy->p_node_hash,
- (st_data_t)tmp_str,
- (void *)&p_node))
- {
- /* we found the node, now get the right port */
- p_physp = osm_node_get_physp_ptr(p_node, port_num);
- if (!p_physp) {
- yyerror(
- "'%s' - port number out of range in port name",
- tmp_str);
- free(tmp_str);
- cl_list_remove_all(&tmp_parser_struct.str_list);
- return 1;
- }
- /* we found the port, now add it to guid table */
- __parser_add_port_to_port_map(&p_current_port_group->port_map,
- p_physp);
- }
- free(tmp_str);
- }
- }
- cl_list_remove_all(&tmp_parser_struct.str_list);
- }
- ;
-
-port_group_port_name_start: TK_PORT_NAME {
- RESET_BUFFER;
- }
- ;
-
-port_group_port_guid: port_group_port_guid_start list_of_ranges {
- /* 'port-guid' in 'port-group' - any num of instances */
- /* list of guid ranges */
- if (cl_list_count(&tmp_parser_struct.num_pair_list))
- {
- uint64_t ** range_arr;
- unsigned range_len;
-
- __rangelist2rangearr( &tmp_parser_struct.num_pair_list,
- &range_arr,
- &range_len );
-
- __parser_add_guid_range_to_port_map(
- &p_current_port_group->port_map,
- range_arr,
- range_len);
- }
- }
- ;
-
-port_group_port_guid_start: TK_PORT_GUID {
- RESET_BUFFER;
- }
- ;
-
-port_group_pkey: port_group_pkey_start list_of_ranges {
- /* 'pkey' in 'port-group' - any num of instances */
- /* list of pkey ranges */
- if (cl_list_count(&tmp_parser_struct.num_pair_list))
- {
- uint64_t ** range_arr;
- unsigned range_len;
-
- __pkey_rangelist2rangearr( &tmp_parser_struct.num_pair_list,
- &range_arr,
- &range_len );
-
- __parser_add_pkey_range_to_port_map(
- &p_current_port_group->port_map,
- range_arr,
- range_len);
- }
- }
- ;
-
-port_group_pkey_start: TK_PKEY {
- RESET_BUFFER;
- }
- ;
-
-port_group_partition: port_group_partition_start string_list {
- /* 'partition' in 'port-group' - any num of instances */
- __parser_add_partition_list_to_port_map(
- &p_current_port_group->port_map,
- &tmp_parser_struct.str_list);
- }
- ;
-
-port_group_partition_start: TK_PARTITION {
- RESET_BUFFER;
- }
- ;
-
-port_group_node_type: port_group_node_type_start port_group_node_type_list {
- /* 'node-type' in 'port-group' - any num of instances */
- }
- ;
-
-port_group_node_type_start: TK_NODE_TYPE {
- RESET_BUFFER;
- }
- ;
-
-port_group_node_type_list: node_type_item
- | port_group_node_type_list TK_COMMA node_type_item
- ;
-
-node_type_item: node_type_ca
- | node_type_switch
- | node_type_router
- | node_type_all
- | node_type_self
- ;
-
-node_type_ca: TK_NODE_TYPE_CA {
- p_current_port_group->node_types |=
- OSM_QOS_POLICY_NODE_TYPE_CA;
- }
- ;
-
-node_type_switch: TK_NODE_TYPE_SWITCH {
- p_current_port_group->node_types |=
- OSM_QOS_POLICY_NODE_TYPE_SWITCH;
- }
- ;
-
-node_type_router: TK_NODE_TYPE_ROUTER {
- p_current_port_group->node_types |=
- OSM_QOS_POLICY_NODE_TYPE_ROUTER;
- }
- ;
-
-node_type_all: TK_NODE_TYPE_ALL {
- p_current_port_group->node_types |=
- (OSM_QOS_POLICY_NODE_TYPE_CA |
- OSM_QOS_POLICY_NODE_TYPE_SWITCH |
- OSM_QOS_POLICY_NODE_TYPE_ROUTER);
- }
- ;
-
-node_type_self: TK_NODE_TYPE_SELF {
- osm_port_t * p_osm_port =
- osm_get_port_by_guid(p_qos_policy->p_subn,
- p_qos_policy->p_subn->sm_port_guid);
- if (p_osm_port)
- __parser_add_port_to_port_map(
- &p_current_port_group->port_map,
- p_osm_port->p_physp);
- }
- ;
-
- /*
- * vlarb_scope_entry values:
- * vlarb_scope_group
- * vlarb_scope_across
- * vlarb_scope_vlarb_high
- * vlarb_scope_vlarb_low
- * vlarb_scope_vlarb_high_limit
- */
-
-
-
-vlarb_scope_group: vlarb_scope_group_start string_list {
- /* 'group' in 'vlarb-scope' - any num of instances */
- cl_list_iterator_t list_iterator;
- char * tmp_str;
-
- list_iterator = cl_list_head(&tmp_parser_struct.str_list);
- while( list_iterator != cl_list_end(&tmp_parser_struct.str_list) )
- {
- tmp_str = (char*)cl_list_obj(list_iterator);
- if (tmp_str)
- cl_list_insert_tail(&p_current_vlarb_scope->group_list,tmp_str);
- list_iterator = cl_list_next(list_iterator);
- }
- cl_list_remove_all(&tmp_parser_struct.str_list);
- }
- ;
-
-vlarb_scope_group_start: TK_GROUP {
- RESET_BUFFER;
- }
- ;
-
-vlarb_scope_across: vlarb_scope_across_start string_list {
- /* 'across' in 'vlarb-scope' - any num of instances */
- cl_list_iterator_t list_iterator;
- char * tmp_str;
-
- list_iterator = cl_list_head(&tmp_parser_struct.str_list);
- while( list_iterator != cl_list_end(&tmp_parser_struct.str_list) )
- {
- tmp_str = (char*)cl_list_obj(list_iterator);
- if (tmp_str)
- cl_list_insert_tail(&p_current_vlarb_scope->across_list,tmp_str);
- list_iterator = cl_list_next(list_iterator);
- }
- cl_list_remove_all(&tmp_parser_struct.str_list);
- }
- ;
-
-vlarb_scope_across_start: TK_ACROSS {
- RESET_BUFFER;
- }
- ;
-
-vlarb_scope_vlarb_high_limit: vlarb_scope_vlarb_high_limit_start single_number {
- /* 'vl-high-limit' in 'vlarb-scope' - one instance of one number */
- cl_list_iterator_t list_iterator;
- uint64_t * p_tmp_num;
-
- list_iterator = cl_list_head(&tmp_parser_struct.num_list);
- p_tmp_num = (uint64_t*)cl_list_obj(list_iterator);
- if (p_tmp_num)
- {
- p_current_vlarb_scope->vl_high_limit = (uint32_t)(*p_tmp_num);
- p_current_vlarb_scope->vl_high_limit_set = TRUE;
- free(p_tmp_num);
- }
-
- cl_list_remove_all(&tmp_parser_struct.num_list);
- }
- ;
-
-vlarb_scope_vlarb_high_limit_start: TK_VLARB_HIGH_LIMIT {
- RESET_BUFFER;
- }
- ;
-
-vlarb_scope_vlarb_high: vlarb_scope_vlarb_high_start num_list_with_dotdot {
- /* 'vlarb-high' in 'vlarb-scope' - list of pairs of numbers with ':' and ',' */
- cl_list_iterator_t list_iterator;
- uint64_t * num_pair;
-
- list_iterator = cl_list_head(&tmp_parser_struct.num_pair_list);
- while( list_iterator != cl_list_end(&tmp_parser_struct.num_pair_list) )
- {
- num_pair = (uint64_t*)cl_list_obj(list_iterator);
- if (num_pair)
- cl_list_insert_tail(&p_current_vlarb_scope->vlarb_high_list,num_pair);
- list_iterator = cl_list_next(list_iterator);
- }
- cl_list_remove_all(&tmp_parser_struct.num_pair_list);
- }
- ;
-
-vlarb_scope_vlarb_high_start: TK_VLARB_HIGH {
- RESET_BUFFER;
- }
- ;
-
-vlarb_scope_vlarb_low: vlarb_scope_vlarb_low_start num_list_with_dotdot {
- /* 'vlarb-low' in 'vlarb-scope' - list of pairs of numbers with ':' and ',' */
- cl_list_iterator_t list_iterator;
- uint64_t * num_pair;
-
- list_iterator = cl_list_head(&tmp_parser_struct.num_pair_list);
- while( list_iterator != cl_list_end(&tmp_parser_struct.num_pair_list) )
- {
- num_pair = (uint64_t*)cl_list_obj(list_iterator);
- if (num_pair)
- cl_list_insert_tail(&p_current_vlarb_scope->vlarb_low_list,num_pair);
- list_iterator = cl_list_next(list_iterator);
- }
- cl_list_remove_all(&tmp_parser_struct.num_pair_list);
- }
- ;
-
-vlarb_scope_vlarb_low_start: TK_VLARB_LOW {
- RESET_BUFFER;
- }
- ;
-
- /*
- * sl2vl_scope_entry values:
- * sl2vl_scope_group
- * sl2vl_scope_across
- * sl2vl_scope_across_from
- * sl2vl_scope_across_to
- * sl2vl_scope_from
- * sl2vl_scope_to
- * sl2vl_scope_sl2vl_table
- */
-
-sl2vl_scope_group: sl2vl_scope_group_start string_list {
- /* 'group' in 'sl2vl-scope' - any num of instances */
- cl_list_iterator_t list_iterator;
- char * tmp_str;
-
- list_iterator = cl_list_head(&tmp_parser_struct.str_list);
- while( list_iterator != cl_list_end(&tmp_parser_struct.str_list) )
- {
- tmp_str = (char*)cl_list_obj(list_iterator);
- if (tmp_str)
- cl_list_insert_tail(&p_current_sl2vl_scope->group_list,tmp_str);
- list_iterator = cl_list_next(list_iterator);
- }
- cl_list_remove_all(&tmp_parser_struct.str_list);
- }
- ;
-
-sl2vl_scope_group_start: TK_GROUP {
- RESET_BUFFER;
- }
- ;
-
-sl2vl_scope_across: sl2vl_scope_across_start string_list {
- /* 'across' in 'sl2vl-scope' - any num of instances */
- cl_list_iterator_t list_iterator;
- char * tmp_str;
-
- list_iterator = cl_list_head(&tmp_parser_struct.str_list);
- while( list_iterator != cl_list_end(&tmp_parser_struct.str_list) )
- {
- tmp_str = (char*)cl_list_obj(list_iterator);
- if (tmp_str) {
- cl_list_insert_tail(&p_current_sl2vl_scope->across_from_list,tmp_str);
- cl_list_insert_tail(&p_current_sl2vl_scope->across_to_list,strdup(tmp_str));
- }
- list_iterator = cl_list_next(list_iterator);
- }
- cl_list_remove_all(&tmp_parser_struct.str_list);
- }
- ;
-
-sl2vl_scope_across_start: TK_ACROSS {
- RESET_BUFFER;
- }
- ;
-
-sl2vl_scope_across_from: sl2vl_scope_across_from_start string_list {
- /* 'across-from' in 'sl2vl-scope' - any num of instances */
- cl_list_iterator_t list_iterator;
- char * tmp_str;
-
- list_iterator = cl_list_head(&tmp_parser_struct.str_list);
- while( list_iterator != cl_list_end(&tmp_parser_struct.str_list) )
- {
- tmp_str = (char*)cl_list_obj(list_iterator);
- if (tmp_str)
- cl_list_insert_tail(&p_current_sl2vl_scope->across_from_list,tmp_str);
- list_iterator = cl_list_next(list_iterator);
- }
- cl_list_remove_all(&tmp_parser_struct.str_list);
- }
- ;
-
-sl2vl_scope_across_from_start: TK_ACROSS_FROM {
- RESET_BUFFER;
- }
- ;
-
-sl2vl_scope_across_to: sl2vl_scope_across_to_start string_list {
- /* 'across-to' in 'sl2vl-scope' - any num of instances */
- cl_list_iterator_t list_iterator;
- char * tmp_str;
-
- list_iterator = cl_list_head(&tmp_parser_struct.str_list);
- while( list_iterator != cl_list_end(&tmp_parser_struct.str_list) )
- {
- tmp_str = (char*)cl_list_obj(list_iterator);
- if (tmp_str) {
- cl_list_insert_tail(&p_current_sl2vl_scope->across_to_list,tmp_str);
- }
- list_iterator = cl_list_next(list_iterator);
- }
- cl_list_remove_all(&tmp_parser_struct.str_list);
- }
- ;
-
-sl2vl_scope_across_to_start: TK_ACROSS_TO {
- RESET_BUFFER;
- }
- ;
-
-sl2vl_scope_from: sl2vl_scope_from_start sl2vl_scope_from_list_or_asterisk {
- /* 'from' in 'sl2vl-scope' - any num of instances */
- }
- ;
-
-sl2vl_scope_from_start: TK_FROM {
- RESET_BUFFER;
- }
- ;
-
-sl2vl_scope_to: sl2vl_scope_to_start sl2vl_scope_to_list_or_asterisk {
- /* 'to' in 'sl2vl-scope' - any num of instances */
- }
- ;
-
-sl2vl_scope_to_start: TK_TO {
- RESET_BUFFER;
- }
- ;
-
-sl2vl_scope_from_list_or_asterisk: sl2vl_scope_from_asterisk
- | sl2vl_scope_from_list_of_ranges
- ;
-
-sl2vl_scope_from_asterisk: TK_ASTERISK {
- int i;
- for (i = 0; i < OSM_QOS_POLICY_MAX_PORTS_ON_SWITCH; i++)
- p_current_sl2vl_scope->from[i] = TRUE;
- }
- ;
-
-sl2vl_scope_to_list_or_asterisk: sl2vl_scope_to_asterisk
- | sl2vl_scope_to_list_of_ranges
- ;
-
-sl2vl_scope_to_asterisk: TK_ASTERISK {
- int i;
- for (i = 0; i < OSM_QOS_POLICY_MAX_PORTS_ON_SWITCH; i++)
- p_current_sl2vl_scope->to[i] = TRUE;
- }
- ;
-
-sl2vl_scope_from_list_of_ranges: list_of_ranges {
- int i;
- cl_list_iterator_t list_iterator;
- uint64_t * num_pair;
- uint8_t num1, num2;
-
- list_iterator = cl_list_head(&tmp_parser_struct.num_pair_list);
- while( list_iterator != cl_list_end(&tmp_parser_struct.num_pair_list) )
- {
- num_pair = (uint64_t*)cl_list_obj(list_iterator);
- if (num_pair)
- {
- if ( num_pair[0] < 0 ||
- num_pair[1] >= OSM_QOS_POLICY_MAX_PORTS_ON_SWITCH )
- {
- yyerror("port number out of range 'from' list");
- free(num_pair);
- cl_list_remove_all(&tmp_parser_struct.num_pair_list);
- return 1;
- }
- num1 = (uint8_t)num_pair[0];
- num2 = (uint8_t)num_pair[1];
- free(num_pair);
- for (i = num1; i <= num2; i++)
- p_current_sl2vl_scope->from[i] = TRUE;
- }
- list_iterator = cl_list_next(list_iterator);
- }
- cl_list_remove_all(&tmp_parser_struct.num_pair_list);
- }
- ;
-
-sl2vl_scope_to_list_of_ranges: list_of_ranges {
- int i;
- cl_list_iterator_t list_iterator;
- uint64_t * num_pair;
- uint8_t num1, num2;
-
- list_iterator = cl_list_head(&tmp_parser_struct.num_pair_list);
- while( list_iterator != cl_list_end(&tmp_parser_struct.num_pair_list) )
- {
- num_pair = (uint64_t*)cl_list_obj(list_iterator);
- if (num_pair)
- {
- if ( num_pair[0] < 0 ||
- num_pair[1] >= OSM_QOS_POLICY_MAX_PORTS_ON_SWITCH )
- {
- yyerror("port number out of range 'to' list");
- free(num_pair);
- cl_list_remove_all(&tmp_parser_struct.num_pair_list);
- return 1;
- }
- num1 = (uint8_t)num_pair[0];
- num2 = (uint8_t)num_pair[1];
- free(num_pair);
- for (i = num1; i <= num2; i++)
- p_current_sl2vl_scope->to[i] = TRUE;
- }
- list_iterator = cl_list_next(list_iterator);
- }
- cl_list_remove_all(&tmp_parser_struct.num_pair_list);
- }
- ;
-
-
-sl2vl_scope_sl2vl_table: sl2vl_scope_sl2vl_table_start num_list {
- /* 'sl2vl-table' - one instance of exactly
- OSM_QOS_POLICY_SL2VL_TABLE_LEN numbers */
- cl_list_iterator_t list_iterator;
- uint64_t num;
- uint64_t * p_num;
- int i = 0;
-
- if (p_current_sl2vl_scope->sl2vl_table_set)
- {
- yyerror("sl2vl-scope has more than one sl2vl-table");
- cl_list_remove_all(&tmp_parser_struct.num_list);
- return 1;
- }
-
- if (cl_list_count(&tmp_parser_struct.num_list) != OSM_QOS_POLICY_SL2VL_TABLE_LEN)
- {
- yyerror("wrong number of values in 'sl2vl-table' (should be 16)");
- cl_list_remove_all(&tmp_parser_struct.num_list);
- return 1;
- }
-
- list_iterator = cl_list_head(&tmp_parser_struct.num_list);
- while( list_iterator != cl_list_end(&tmp_parser_struct.num_list) )
- {
- p_num = (uint64_t*)cl_list_obj(list_iterator);
- num = *p_num;
- free(p_num);
- if (num >= OSM_QOS_POLICY_MAX_VL_NUM)
- {
- yyerror("wrong VL value in 'sl2vl-table' (should be 0 to 15)");
- cl_list_remove_all(&tmp_parser_struct.num_list);
- return 1;
- }
-
- p_current_sl2vl_scope->sl2vl_table[i++] = (uint8_t)num;
- list_iterator = cl_list_next(list_iterator);
- }
- p_current_sl2vl_scope->sl2vl_table_set = TRUE;
- cl_list_remove_all(&tmp_parser_struct.num_list);
- }
- ;
-
-sl2vl_scope_sl2vl_table_start: TK_SL2VL_TABLE {
- RESET_BUFFER;
- }
- ;
-
- /*
- * qos_level_entry values:
- * qos_level_name
- * qos_level_use
- * qos_level_sl
- * qos_level_mtu_limit
- * qos_level_rate_limit
- * qos_level_packet_life
- * qos_level_path_bits
- * qos_level_pkey
- */
-
-qos_level_name: qos_level_name_start single_string {
- /* 'name' of 'qos-level' - one instance */
- cl_list_iterator_t list_iterator;
- char * tmp_str;
-
- if (p_current_qos_level->name)
- {
- yyerror("qos-level has multiple 'name' tags");
- cl_list_remove_all(&tmp_parser_struct.str_list);
- return 1;
- }
-
- list_iterator = cl_list_head(&tmp_parser_struct.str_list);
- if ( list_iterator != cl_list_end(&tmp_parser_struct.str_list) )
- {
- tmp_str = (char*)cl_list_obj(list_iterator);
- if (tmp_str)
- p_current_qos_level->name = tmp_str;
- }
- cl_list_remove_all(&tmp_parser_struct.str_list);
- }
- ;
-
-qos_level_name_start: TK_NAME {
- RESET_BUFFER;
- }
- ;
-
-qos_level_use: qos_level_use_start single_string {
- /* 'use' of 'qos-level' - one instance */
- cl_list_iterator_t list_iterator;
- char * tmp_str;
-
- if (p_current_qos_level->use)
- {
- yyerror("qos-level has multiple 'use' tags");
- cl_list_remove_all(&tmp_parser_struct.str_list);
- return 1;
- }
-
- list_iterator = cl_list_head(&tmp_parser_struct.str_list);
- if ( list_iterator != cl_list_end(&tmp_parser_struct.str_list) )
- {
- tmp_str = (char*)cl_list_obj(list_iterator);
- if (tmp_str)
- p_current_qos_level->use = tmp_str;
- }
- cl_list_remove_all(&tmp_parser_struct.str_list);
- }
- ;
-
-qos_level_use_start: TK_USE {
- RESET_BUFFER;
- }
- ;
-
-qos_level_sl: qos_level_sl_start single_number {
- /* 'sl' in 'qos-level' - one instance */
- cl_list_iterator_t list_iterator;
- uint64_t * p_num;
-
- if (p_current_qos_level->sl_set)
- {
- yyerror("'qos-level' has multiple 'sl' tags");
- cl_list_remove_all(&tmp_parser_struct.num_list);
- return 1;
- }
- list_iterator = cl_list_head(&tmp_parser_struct.num_list);
- p_num = (uint64_t*)cl_list_obj(list_iterator);
- p_current_qos_level->sl = (uint8_t)(*p_num);
- free(p_num);
- p_current_qos_level->sl_set = TRUE;
- cl_list_remove_all(&tmp_parser_struct.num_list);
- }
- ;
-
-qos_level_sl_start: TK_SL {
- RESET_BUFFER;
- }
- ;
-
-qos_level_mtu_limit: qos_level_mtu_limit_start single_number {
- /* 'mtu-limit' in 'qos-level' - one instance */
- cl_list_iterator_t list_iterator;
- uint64_t * p_num;
-
- if (p_current_qos_level->mtu_limit_set)
- {
- yyerror("'qos-level' has multiple 'mtu-limit' tags");
- cl_list_remove_all(&tmp_parser_struct.num_list);
- return 1;
- }
- list_iterator = cl_list_head(&tmp_parser_struct.num_list);
- p_num = (uint64_t*)cl_list_obj(list_iterator);
- p_current_qos_level->mtu_limit = (uint8_t)(*p_num);
- free(p_num);
- p_current_qos_level->mtu_limit_set = TRUE;
- cl_list_remove_all(&tmp_parser_struct.num_list);
- }
- ;
-
-qos_level_mtu_limit_start: TK_MTU_LIMIT {
- /* 'mtu-limit' in 'qos-level' - one instance */
- RESET_BUFFER;
- }
- ;
-
-qos_level_rate_limit: qos_level_rate_limit_start single_number {
- /* 'rate-limit' in 'qos-level' - one instance */
- cl_list_iterator_t list_iterator;
- uint64_t * p_num;
-
- if (p_current_qos_level->rate_limit_set)
- {
- yyerror("'qos-level' has multiple 'rate-limit' tags");
- cl_list_remove_all(&tmp_parser_struct.num_list);
- return 1;
- }
- list_iterator = cl_list_head(&tmp_parser_struct.num_list);
- p_num = (uint64_t*)cl_list_obj(list_iterator);
- p_current_qos_level->rate_limit = (uint8_t)(*p_num);
- free(p_num);
- p_current_qos_level->rate_limit_set = TRUE;
- cl_list_remove_all(&tmp_parser_struct.num_list);
- }
- ;
-
-qos_level_rate_limit_start: TK_RATE_LIMIT {
- /* 'rate-limit' in 'qos-level' - one instance */
- RESET_BUFFER;
- }
- ;
-
-qos_level_packet_life: qos_level_packet_life_start single_number {
- /* 'packet-life' in 'qos-level' - one instance */
- cl_list_iterator_t list_iterator;
- uint64_t * p_num;
-
- if (p_current_qos_level->pkt_life_set)
- {
- yyerror("'qos-level' has multiple 'packet-life' tags");
- cl_list_remove_all(&tmp_parser_struct.num_list);
- return 1;
- }
- list_iterator = cl_list_head(&tmp_parser_struct.num_list);
- p_num = (uint64_t*)cl_list_obj(list_iterator);
- p_current_qos_level->pkt_life = (uint8_t)(*p_num);
- free(p_num);
- p_current_qos_level->pkt_life_set= TRUE;
- cl_list_remove_all(&tmp_parser_struct.num_list);
- }
- ;
-
-qos_level_packet_life_start: TK_PACKET_LIFE {
- /* 'packet-life' in 'qos-level' - one instance */
- RESET_BUFFER;
- }
- ;
-
-qos_level_path_bits: qos_level_path_bits_start list_of_ranges {
- /* 'path-bits' in 'qos-level' - any num of instances */
- /* list of path bit ranges */
-
- if (cl_list_count(&tmp_parser_struct.num_pair_list))
- {
- uint64_t ** range_arr;
- unsigned range_len;
-
- __rangelist2rangearr( &tmp_parser_struct.num_pair_list,
- &range_arr,
- &range_len );
-
- if ( !p_current_qos_level->path_bits_range_len )
- {
- p_current_qos_level->path_bits_range_arr = range_arr;
- p_current_qos_level->path_bits_range_len = range_len;
- }
- else
- {
- uint64_t ** new_range_arr;
- unsigned new_range_len;
- __merge_rangearr( p_current_qos_level->path_bits_range_arr,
- p_current_qos_level->path_bits_range_len,
- range_arr,
- range_len,
- &new_range_arr,
- &new_range_len );
- p_current_qos_level->path_bits_range_arr = new_range_arr;
- p_current_qos_level->path_bits_range_len = new_range_len;
- }
- }
- }
- ;
-
-qos_level_path_bits_start: TK_PATH_BITS {
- RESET_BUFFER;
- }
- ;
-
-qos_level_pkey: qos_level_pkey_start list_of_ranges {
- /* 'pkey' in 'qos-level' - num of instances of list of ranges */
- if (cl_list_count(&tmp_parser_struct.num_pair_list))
- {
- uint64_t ** range_arr;
- unsigned range_len;
-
- __pkey_rangelist2rangearr( &tmp_parser_struct.num_pair_list,
- &range_arr,
- &range_len );
-
- if ( !p_current_qos_level->pkey_range_len )
- {
- p_current_qos_level->pkey_range_arr = range_arr;
- p_current_qos_level->pkey_range_len = range_len;
- }
- else
- {
- uint64_t ** new_range_arr;
- unsigned new_range_len;
- __merge_rangearr( p_current_qos_level->pkey_range_arr,
- p_current_qos_level->pkey_range_len,
- range_arr,
- range_len,
- &new_range_arr,
- &new_range_len );
- p_current_qos_level->pkey_range_arr = new_range_arr;
- p_current_qos_level->pkey_range_len = new_range_len;
- }
- }
- }
- ;
-
-qos_level_pkey_start: TK_PKEY {
- RESET_BUFFER;
- }
- ;
-
- /*
- * qos_match_rule_entry values:
- * qos_match_rule_use
- * qos_match_rule_qos_class
- * qos_match_rule_qos_level_name
- * qos_match_rule_source
- * qos_match_rule_destination
- * qos_match_rule_service_id
- * qos_match_rule_pkey
- */
-
-
-qos_match_rule_use: qos_match_rule_use_start single_string {
- /* 'use' of 'qos-match-rule' - one instance */
- cl_list_iterator_t list_iterator;
- char * tmp_str;
-
- if (p_current_qos_match_rule->use)
- {
- yyerror("'qos-match-rule' has multiple 'use' tags");
- cl_list_remove_all(&tmp_parser_struct.str_list);
- return 1;
- }
-
- list_iterator = cl_list_head(&tmp_parser_struct.str_list);
- if ( list_iterator != cl_list_end(&tmp_parser_struct.str_list) )
- {
- tmp_str = (char*)cl_list_obj(list_iterator);
- if (tmp_str)
- p_current_qos_match_rule->use = tmp_str;
- }
- cl_list_remove_all(&tmp_parser_struct.str_list);
- }
- ;
-
-qos_match_rule_use_start: TK_USE {
- RESET_BUFFER;
- }
- ;
-
-qos_match_rule_qos_class: qos_match_rule_qos_class_start list_of_ranges {
- /* 'qos-class' in 'qos-match-rule' - num of instances of list of ranges */
- /* list of class ranges (QoS Class is 12-bit value) */
- if (cl_list_count(&tmp_parser_struct.num_pair_list))
- {
- uint64_t ** range_arr;
- unsigned range_len;
-
- __rangelist2rangearr( &tmp_parser_struct.num_pair_list,
- &range_arr,
- &range_len );
-
- if ( !p_current_qos_match_rule->qos_class_range_len )
- {
- p_current_qos_match_rule->qos_class_range_arr = range_arr;
- p_current_qos_match_rule->qos_class_range_len = range_len;
- }
- else
- {
- uint64_t ** new_range_arr;
- unsigned new_range_len;
- __merge_rangearr( p_current_qos_match_rule->qos_class_range_arr,
- p_current_qos_match_rule->qos_class_range_len,
- range_arr,
- range_len,
- &new_range_arr,
- &new_range_len );
- p_current_qos_match_rule->qos_class_range_arr = new_range_arr;
- p_current_qos_match_rule->qos_class_range_len = new_range_len;
- }
- }
- }
- ;
-
-qos_match_rule_qos_class_start: TK_QOS_CLASS {
- RESET_BUFFER;
- }
- ;
-
-qos_match_rule_source: qos_match_rule_source_start string_list {
- /* 'source' in 'qos-match-rule' - text */
- cl_list_iterator_t list_iterator;
- char * tmp_str;
-
- list_iterator = cl_list_head(&tmp_parser_struct.str_list);
- while( list_iterator != cl_list_end(&tmp_parser_struct.str_list) )
- {
- tmp_str = (char*)cl_list_obj(list_iterator);
- if (tmp_str)
- cl_list_insert_tail(&p_current_qos_match_rule->source_list,tmp_str);
- list_iterator = cl_list_next(list_iterator);
- }
- cl_list_remove_all(&tmp_parser_struct.str_list);
- }
- ;
-
-qos_match_rule_source_start: TK_SOURCE {
- RESET_BUFFER;
- }
- ;
-
-qos_match_rule_destination: qos_match_rule_destination_start string_list {
- /* 'destination' in 'qos-match-rule' - text */
- cl_list_iterator_t list_iterator;
- char * tmp_str;
-
- list_iterator = cl_list_head(&tmp_parser_struct.str_list);
- while( list_iterator != cl_list_end(&tmp_parser_struct.str_list) )
- {
- tmp_str = (char*)cl_list_obj(list_iterator);
- if (tmp_str)
- cl_list_insert_tail(&p_current_qos_match_rule->destination_list,tmp_str);
- list_iterator = cl_list_next(list_iterator);
- }
- cl_list_remove_all(&tmp_parser_struct.str_list);
- }
- ;
-
-qos_match_rule_destination_start: TK_DESTINATION {
- RESET_BUFFER;
- }
- ;
-
-qos_match_rule_qos_level_name: qos_match_rule_qos_level_name_start single_string {
- /* 'qos-level-name' in 'qos-match-rule' - single string */
- cl_list_iterator_t list_iterator;
- char * tmp_str;
-
- if (p_current_qos_match_rule->qos_level_name)
- {
- yyerror("qos-match-rule has multiple 'qos-level-name' tags");
- cl_list_remove_all(&tmp_parser_struct.num_list);
- return 1;
- }
-
- list_iterator = cl_list_head(&tmp_parser_struct.str_list);
- if ( list_iterator != cl_list_end(&tmp_parser_struct.str_list) )
- {
- tmp_str = (char*)cl_list_obj(list_iterator);
- if (tmp_str)
- p_current_qos_match_rule->qos_level_name = tmp_str;
- }
- cl_list_remove_all(&tmp_parser_struct.str_list);
- }
- ;
-
-qos_match_rule_qos_level_name_start: TK_QOS_LEVEL_NAME {
- RESET_BUFFER;
- }
- ;
-
-qos_match_rule_service_id: qos_match_rule_service_id_start list_of_ranges {
- /* 'service-id' in 'qos-match-rule' - num of instances of list of ranges */
- if (cl_list_count(&tmp_parser_struct.num_pair_list))
- {
- uint64_t ** range_arr;
- unsigned range_len;
-
- __rangelist2rangearr( &tmp_parser_struct.num_pair_list,
- &range_arr,
- &range_len );
-
- if ( !p_current_qos_match_rule->service_id_range_len )
- {
- p_current_qos_match_rule->service_id_range_arr = range_arr;
- p_current_qos_match_rule->service_id_range_len = range_len;
- }
- else
- {
- uint64_t ** new_range_arr;
- unsigned new_range_len;
- __merge_rangearr( p_current_qos_match_rule->service_id_range_arr,
- p_current_qos_match_rule->service_id_range_len,
- range_arr,
- range_len,
- &new_range_arr,
- &new_range_len );
- p_current_qos_match_rule->service_id_range_arr = new_range_arr;
- p_current_qos_match_rule->service_id_range_len = new_range_len;
- }
- }
- }
- ;
-
-qos_match_rule_service_id_start: TK_SERVICE_ID {
- RESET_BUFFER;
- }
- ;
-
-qos_match_rule_pkey: qos_match_rule_pkey_start list_of_ranges {
- /* 'pkey' in 'qos-match-rule' - num of instances of list of ranges */
- if (cl_list_count(&tmp_parser_struct.num_pair_list))
- {
- uint64_t ** range_arr;
- unsigned range_len;
-
- __pkey_rangelist2rangearr( &tmp_parser_struct.num_pair_list,
- &range_arr,
- &range_len );
-
- if ( !p_current_qos_match_rule->pkey_range_len )
- {
- p_current_qos_match_rule->pkey_range_arr = range_arr;
- p_current_qos_match_rule->pkey_range_len = range_len;
- }
- else
- {
- uint64_t ** new_range_arr;
- unsigned new_range_len;
- __merge_rangearr( p_current_qos_match_rule->pkey_range_arr,
- p_current_qos_match_rule->pkey_range_len,
- range_arr,
- range_len,
- &new_range_arr,
- &new_range_len );
- p_current_qos_match_rule->pkey_range_arr = new_range_arr;
- p_current_qos_match_rule->pkey_range_len = new_range_len;
- }
- }
- }
- ;
-
-qos_match_rule_pkey_start: TK_PKEY {
- RESET_BUFFER;
- }
- ;
-
-
- /*
- * Common part
- */
-
-
-single_string: single_string_elems {
- cl_list_insert_tail(&tmp_parser_struct.str_list,
- strdup(__parser_strip_white(tmp_parser_struct.str)));
- tmp_parser_struct.str[0] = '\0';
- }
- ;
-
-single_string_elems: single_string_element
- | single_string_elems single_string_element
- ;
-
-single_string_element: TK_TEXT {
- strcat(tmp_parser_struct.str,$1);
- free($1);
- }
- ;
-
-
-string_list: single_string
- | string_list TK_COMMA single_string
- ;
-
-
-
-single_number: number
- ;
-
-num_list: number
- | num_list TK_COMMA number
- ;
-
-number: TK_NUMBER {
- uint64_t * p_num = (uint64_t*)malloc(sizeof(uint64_t));
- __parser_str2uint64(p_num,$1);
- free($1);
- cl_list_insert_tail(&tmp_parser_struct.num_list, p_num);
- }
- ;
-
-num_list_with_dotdot: number_from_pair_1 TK_DOTDOT number_from_pair_2 {
- uint64_t * num_pair = (uint64_t*)malloc(sizeof(uint64_t)*2);
- num_pair[0] = tmp_parser_struct.num_pair[0];
- num_pair[1] = tmp_parser_struct.num_pair[1];
- cl_list_insert_tail(&tmp_parser_struct.num_pair_list, num_pair);
- }
- | num_list_with_dotdot TK_COMMA number_from_pair_1 TK_DOTDOT number_from_pair_2 {
- uint64_t * num_pair = (uint64_t*)malloc(sizeof(uint64_t)*2);
- num_pair[0] = tmp_parser_struct.num_pair[0];
- num_pair[1] = tmp_parser_struct.num_pair[1];
- cl_list_insert_tail(&tmp_parser_struct.num_pair_list, num_pair);
- }
- ;
-
-number_from_pair_1: TK_NUMBER {
- __parser_str2uint64(&tmp_parser_struct.num_pair[0],$1);
- free($1);
- }
- ;
-
-number_from_pair_2: TK_NUMBER {
- __parser_str2uint64(&tmp_parser_struct.num_pair[1],$1);
- free($1);
- }
- ;
-
-list_of_ranges: num_list_with_dash
- ;
-
-num_list_with_dash: single_number_from_range {
- uint64_t * num_pair = (uint64_t*)malloc(sizeof(uint64_t)*2);
- num_pair[0] = tmp_parser_struct.num_pair[0];
- num_pair[1] = tmp_parser_struct.num_pair[1];
- cl_list_insert_tail(&tmp_parser_struct.num_pair_list, num_pair);
- }
- | number_from_range_1 TK_DASH number_from_range_2 {
- uint64_t * num_pair = (uint64_t*)malloc(sizeof(uint64_t)*2);
- if (tmp_parser_struct.num_pair[0] <= tmp_parser_struct.num_pair[1]) {
- num_pair[0] = tmp_parser_struct.num_pair[0];
- num_pair[1] = tmp_parser_struct.num_pair[1];
- }
- else {
- num_pair[1] = tmp_parser_struct.num_pair[0];
- num_pair[0] = tmp_parser_struct.num_pair[1];
- }
- cl_list_insert_tail(&tmp_parser_struct.num_pair_list, num_pair);
- }
- | num_list_with_dash TK_COMMA number_from_range_1 TK_DASH number_from_range_2 {
- uint64_t * num_pair = (uint64_t*)malloc(sizeof(uint64_t)*2);
- if (tmp_parser_struct.num_pair[0] <= tmp_parser_struct.num_pair[1]) {
- num_pair[0] = tmp_parser_struct.num_pair[0];
- num_pair[1] = tmp_parser_struct.num_pair[1];
- }
- else {
- num_pair[1] = tmp_parser_struct.num_pair[0];
- num_pair[0] = tmp_parser_struct.num_pair[1];
- }
- cl_list_insert_tail(&tmp_parser_struct.num_pair_list, num_pair);
- }
- | num_list_with_dash TK_COMMA single_number_from_range {
- uint64_t * num_pair = (uint64_t*)malloc(sizeof(uint64_t)*2);
- num_pair[0] = tmp_parser_struct.num_pair[0];
- num_pair[1] = tmp_parser_struct.num_pair[1];
- cl_list_insert_tail(&tmp_parser_struct.num_pair_list, num_pair);
- }
- ;
-
-single_number_from_range: TK_NUMBER {
- __parser_str2uint64(&tmp_parser_struct.num_pair[0],$1);
- __parser_str2uint64(&tmp_parser_struct.num_pair[1],$1);
- free($1);
- }
- ;
-
-number_from_range_1: TK_NUMBER {
- __parser_str2uint64(&tmp_parser_struct.num_pair[0],$1);
- free($1);
- }
- ;
-
-number_from_range_2: TK_NUMBER {
- __parser_str2uint64(&tmp_parser_struct.num_pair[1],$1);
- free($1);
- }
- ;
-
-%%
-
-/***************************************************
- ***************************************************/
-
-int osm_qos_parse_policy_file(IN osm_subn_t * const p_subn)
-{
- int res = 0;
- static boolean_t first_time = TRUE;
- p_qos_parser_osm_log = &p_subn->p_osm->log;
-
- OSM_LOG_ENTER(p_qos_parser_osm_log);
-
- osm_qos_policy_destroy(p_subn->p_qos_policy);
- p_subn->p_qos_policy = NULL;
-
- yyin = fopen (p_subn->opt.qos_policy_file, "r");
- if (!yyin)
- {
- if (strcmp(p_subn->opt.qos_policy_file,OSM_DEFAULT_QOS_POLICY_FILE)) {
- OSM_LOG(p_qos_parser_osm_log, OSM_LOG_ERROR, "ERR AC01: "
- "Failed opening QoS policy file %s - %s\n",
- p_subn->opt.qos_policy_file, strerror(errno));
- res = 1;
- }
- else
- OSM_LOG(p_qos_parser_osm_log, OSM_LOG_VERBOSE,
- "QoS policy file not found (%s)\n",
- p_subn->opt.qos_policy_file);
-
- goto Exit;
- }
-
- if (first_time)
- {
- first_time = FALSE;
- __setup_simple_qos_levels();
- __setup_ulp_match_rules();
- OSM_LOG(p_qos_parser_osm_log, OSM_LOG_INFO,
- "Loading QoS policy file (%s)\n",
- p_subn->opt.qos_policy_file);
- }
- else
- /*
- * ULP match rules list was emptied at the end of
- * previous parsing iteration.
- * What's left is to clear simple QoS levels.
- */
- __clear_simple_qos_levels();
-
- column_num = 1;
- line_num = 1;
-
- p_subn->p_qos_policy = osm_qos_policy_create(p_subn);
-
- __parser_tmp_struct_init();
- p_qos_policy = p_subn->p_qos_policy;
-
- res = yyparse();
-
- __parser_tmp_struct_destroy();
-
- if (res != 0)
- {
- OSM_LOG(p_qos_parser_osm_log, OSM_LOG_ERROR, "ERR AC03: "
- "Failed parsing QoS policy file (%s)\n",
- p_subn->opt.qos_policy_file);
- osm_qos_policy_destroy(p_subn->p_qos_policy);
- p_subn->p_qos_policy = NULL;
- res = 1;
- goto Exit;
- }
-
- /* add generated ULP match rules to the usual match rules */
- __process_ulp_match_rules();
-
- if (osm_qos_policy_validate(p_subn->p_qos_policy,p_qos_parser_osm_log))
- {
- OSM_LOG(p_qos_parser_osm_log, OSM_LOG_ERROR, "ERR AC04: "
- "Error(s) in QoS policy file (%s)\n",
- p_subn->opt.qos_policy_file);
- fprintf(stderr, "Error(s) in QoS policy file (%s)\n",
- p_subn->opt.qos_policy_file);
- osm_qos_policy_destroy(p_subn->p_qos_policy);
- p_subn->p_qos_policy = NULL;
- res = 1;
- goto Exit;
- }
-
- Exit:
- if (yyin)
- fclose(yyin);
- OSM_LOG_EXIT(p_qos_parser_osm_log);
- return res;
-}
-
-/***************************************************
- ***************************************************/
-
-int yywrap()
-{
- return(1);
-}
-
-/***************************************************
- ***************************************************/
-
-static void yyerror(const char *format, ...)
-{
- char s[256];
- va_list pvar;
-
- OSM_LOG_ENTER(p_qos_parser_osm_log);
-
- va_start(pvar, format);
- vsnprintf(s, sizeof(s), format, pvar);
- va_end(pvar);
-
- OSM_LOG(p_qos_parser_osm_log, OSM_LOG_ERROR, "ERR AC05: "
- "Syntax error (line %d:%d): %s\n",
- line_num, column_num, s);
- fprintf(stderr, "Error in QoS Policy File (line %d:%d): %s.\n",
- line_num, column_num, s);
- OSM_LOG_EXIT(p_qos_parser_osm_log);
-}
-
-/***************************************************
- ***************************************************/
-
-static char * __parser_strip_white(char * str)
-{
- int i;
- for (i = (strlen(str)-1); i >= 0; i--)
- {
- if (isspace(str[i]))
- str[i] = '\0';
- else
- break;
- }
- for (i = 0; i < strlen(str); i++)
- {
- if (!isspace(str[i]))
- break;
- }
- return &(str[i]);
-}
-
-/***************************************************
- ***************************************************/
-
-static void __parser_str2uint64(uint64_t * p_val, char * str)
-{
- *p_val = strtoull(str, NULL, 0);
-}
-
-/***************************************************
- ***************************************************/
-
-static void __parser_port_group_start()
-{
- p_current_port_group = osm_qos_policy_port_group_create();
-}
-
-/***************************************************
- ***************************************************/
-
-static int __parser_port_group_end()
-{
- if(!p_current_port_group->name)
- {
- yyerror("port-group validation failed - no port group name specified");
- return -1;
- }
-
- cl_list_insert_tail(&p_qos_policy->port_groups,
- p_current_port_group);
- p_current_port_group = NULL;
- return 0;
-}
-
-/***************************************************
- ***************************************************/
-
-static void __parser_vlarb_scope_start()
-{
- p_current_vlarb_scope = osm_qos_policy_vlarb_scope_create();
-}
-
-/***************************************************
- ***************************************************/
-
-static int __parser_vlarb_scope_end()
-{
- if ( !cl_list_count(&p_current_vlarb_scope->group_list) &&
- !cl_list_count(&p_current_vlarb_scope->across_list) )
- {
- yyerror("vlarb-scope validation failed - no port groups specified by 'group' or by 'across'");
- return -1;
- }
-
- cl_list_insert_tail(&p_qos_policy->vlarb_tables,
- p_current_vlarb_scope);
- p_current_vlarb_scope = NULL;
- return 0;
-}
-
-/***************************************************
- ***************************************************/
-
-static void __parser_sl2vl_scope_start()
-{
- p_current_sl2vl_scope = osm_qos_policy_sl2vl_scope_create();
-}
-
-/***************************************************
- ***************************************************/
-
-static int __parser_sl2vl_scope_end()
-{
- if (!p_current_sl2vl_scope->sl2vl_table_set)
- {
- yyerror("sl2vl-scope validation failed - no sl2vl table specified");
- return -1;
- }
- if ( !cl_list_count(&p_current_sl2vl_scope->group_list) &&
- !cl_list_count(&p_current_sl2vl_scope->across_to_list) &&
- !cl_list_count(&p_current_sl2vl_scope->across_from_list) )
- {
- yyerror("sl2vl-scope validation failed - no port groups specified by 'group', 'across-to' or 'across-from'");
- return -1;
- }
-
- cl_list_insert_tail(&p_qos_policy->sl2vl_tables,
- p_current_sl2vl_scope);
- p_current_sl2vl_scope = NULL;
- return 0;
-}
-
-/***************************************************
- ***************************************************/
-
-static void __parser_qos_level_start()
-{
- p_current_qos_level = osm_qos_policy_qos_level_create();
-}
-
-/***************************************************
- ***************************************************/
-
-static int __parser_qos_level_end()
-{
- if (!p_current_qos_level->sl_set)
- {
- yyerror("qos-level validation failed - no 'sl' specified");
- return -1;
- }
- if (!p_current_qos_level->name)
- {
- yyerror("qos-level validation failed - no 'name' specified");
- return -1;
- }
-
- cl_list_insert_tail(&p_qos_policy->qos_levels,
- p_current_qos_level);
- p_current_qos_level = NULL;
- return 0;
-}
-
-/***************************************************
- ***************************************************/
-
-static void __parser_match_rule_start()
-{
- p_current_qos_match_rule = osm_qos_policy_match_rule_create();
-}
-
-/***************************************************
- ***************************************************/
-
-static int __parser_match_rule_end()
-{
- if (!p_current_qos_match_rule->qos_level_name)
- {
- yyerror("match-rule validation failed - no 'qos-level-name' specified");
- return -1;
- }
-
- cl_list_insert_tail(&p_qos_policy->qos_match_rules,
- p_current_qos_match_rule);
- p_current_qos_match_rule = NULL;
- return 0;
-}
-
-/***************************************************
- ***************************************************/
-
-static void __parser_ulp_match_rule_start()
-{
- p_current_qos_match_rule = osm_qos_policy_match_rule_create();
-}
-
-/***************************************************
- ***************************************************/
-
-static int __parser_ulp_match_rule_end()
-{
- CL_ASSERT(p_current_qos_match_rule->p_qos_level);
- cl_list_insert_tail(&__ulp_match_rules,
- p_current_qos_match_rule);
- p_current_qos_match_rule = NULL;
- return 0;
-}
-
-/***************************************************
- ***************************************************/
-
-static void __parser_tmp_struct_init()
-{
- tmp_parser_struct.str[0] = '\0';
- cl_list_construct(&tmp_parser_struct.str_list);
- cl_list_init(&tmp_parser_struct.str_list, 10);
- cl_list_construct(&tmp_parser_struct.num_list);
- cl_list_init(&tmp_parser_struct.num_list, 10);
- cl_list_construct(&tmp_parser_struct.num_pair_list);
- cl_list_init(&tmp_parser_struct.num_pair_list, 10);
-}
-
-/***************************************************
- ***************************************************/
-
-/*
- * Do NOT free objects from the temp struct.
- * Either they are inserted into the parse tree data
- * structure, or they are already freed when copying
- * their values to the parse tree data structure.
- */
-static void __parser_tmp_struct_reset()
-{
- tmp_parser_struct.str[0] = '\0';
- cl_list_remove_all(&tmp_parser_struct.str_list);
- cl_list_remove_all(&tmp_parser_struct.num_list);
- cl_list_remove_all(&tmp_parser_struct.num_pair_list);
-}
-
-/***************************************************
- ***************************************************/
-
-static void __parser_tmp_struct_destroy()
-{
- __parser_tmp_struct_reset();
- cl_list_destroy(&tmp_parser_struct.str_list);
- cl_list_destroy(&tmp_parser_struct.num_list);
- cl_list_destroy(&tmp_parser_struct.num_pair_list);
-}
-
-/***************************************************
- ***************************************************/
-
-#define __SIMPLE_QOS_LEVEL_NAME "SimpleQoSLevel_SL"
-#define __SIMPLE_QOS_LEVEL_DEFAULT_NAME "SimpleQoSLevel_DEFAULT"
-
-static void __setup_simple_qos_levels()
-{
- uint8_t i;
- char tmp_buf[30];
- memset(osm_qos_policy_simple_qos_levels, 0,
- sizeof(osm_qos_policy_simple_qos_levels));
- for (i = 0; i < 16; i++)
- {
- osm_qos_policy_simple_qos_levels[i].sl = i;
- osm_qos_policy_simple_qos_levels[i].sl_set = TRUE;
- sprintf(tmp_buf, "%s%u", __SIMPLE_QOS_LEVEL_NAME, i);
- osm_qos_policy_simple_qos_levels[i].name = strdup(tmp_buf);
- }
-
- memset(&__default_simple_qos_level, 0,
- sizeof(__default_simple_qos_level));
- __default_simple_qos_level.name =
- strdup(__SIMPLE_QOS_LEVEL_DEFAULT_NAME);
-}
-
-/***************************************************
- ***************************************************/
-
-static void __clear_simple_qos_levels()
-{
- /*
- * Simple QoS levels are static.
- * What's left is to invalidate default simple QoS level.
- */
- __default_simple_qos_level.sl_set = FALSE;
-}
-
-/***************************************************
- ***************************************************/
-
-static void __setup_ulp_match_rules()
-{
- cl_list_construct(&__ulp_match_rules);
- cl_list_init(&__ulp_match_rules, 10);
-}
-
-/***************************************************
- ***************************************************/
-
-static void __process_ulp_match_rules()
-{
- cl_list_iterator_t list_iterator;
- osm_qos_match_rule_t *p_qos_match_rule = NULL;
-
- list_iterator = cl_list_head(&__ulp_match_rules);
- while (list_iterator != cl_list_end(&__ulp_match_rules))
- {
- p_qos_match_rule = (osm_qos_match_rule_t *) cl_list_obj(list_iterator);
- if (p_qos_match_rule)
- cl_list_insert_tail(&p_qos_policy->qos_match_rules,
- p_qos_match_rule);
- list_iterator = cl_list_next(list_iterator);
- }
- cl_list_remove_all(&__ulp_match_rules);
-}
-
-/***************************************************
- ***************************************************/
-
-static int OSM_CDECL
-__cmp_num_range(
- const void * p1,
- const void * p2)
-{
- uint64_t * pair1 = *((uint64_t **)p1);
- uint64_t * pair2 = *((uint64_t **)p2);
-
- if (pair1[0] < pair2[0])
- return -1;
- if (pair1[0] > pair2[0])
- return 1;
-
- if (pair1[1] < pair2[1])
- return -1;
- if (pair1[1] > pair2[1])
- return 1;
-
- return 0;
-}
-
-/***************************************************
- ***************************************************/
-
-static void __sort_reduce_rangearr(
- uint64_t ** arr,
- unsigned arr_len,
- uint64_t ** * p_res_arr,
- unsigned * p_res_arr_len )
-{
- unsigned i = 0;
- unsigned j = 0;
- unsigned last_valid_ind = 0;
- unsigned valid_cnt = 0;
- uint64_t ** res_arr;
- boolean_t * is_valid_arr;
-
- *p_res_arr = NULL;
- *p_res_arr_len = 0;
-
- qsort(arr, arr_len, sizeof(uint64_t*), __cmp_num_range);
-
- is_valid_arr = (boolean_t *)malloc(arr_len * sizeof(boolean_t));
- is_valid_arr[last_valid_ind] = TRUE;
- valid_cnt++;
- for (i = 1; i < arr_len; i++)
- {
- if (arr[i][0] <= arr[last_valid_ind][1])
- {
- if (arr[i][1] > arr[last_valid_ind][1])
- arr[last_valid_ind][1] = arr[i][1];
- free(arr[i]);
- arr[i] = NULL;
- is_valid_arr[i] = FALSE;
- }
- else if ((arr[i][0] - 1) == arr[last_valid_ind][1])
- {
- arr[last_valid_ind][1] = arr[i][1];
- free(arr[i]);
- arr[i] = NULL;
- is_valid_arr[i] = FALSE;
- }
- else
- {
- is_valid_arr[i] = TRUE;
- last_valid_ind = i;
- valid_cnt++;
- }
- }
-
- res_arr = (uint64_t **)malloc(valid_cnt * sizeof(uint64_t *));
- for (i = 0; i < arr_len; i++)
- {
- if (is_valid_arr[i])
- res_arr[j++] = arr[i];
- }
- free(is_valid_arr);
- free(arr);
-
- *p_res_arr = res_arr;
- *p_res_arr_len = valid_cnt;
-}
-
-/***************************************************
- ***************************************************/
-
-static void __pkey_rangelist2rangearr(
- cl_list_t * p_list,
- uint64_t ** * p_arr,
- unsigned * p_arr_len)
-{
- uint64_t tmp_pkey;
- uint64_t * p_pkeys;
- cl_list_iterator_t list_iterator;
-
- list_iterator= cl_list_head(p_list);
- while( list_iterator != cl_list_end(p_list) )
- {
- p_pkeys = (uint64_t *)cl_list_obj(list_iterator);
- p_pkeys[0] &= 0x7fff;
- p_pkeys[1] &= 0x7fff;
- if (p_pkeys[0] > p_pkeys[1])
- {
- tmp_pkey = p_pkeys[1];
- p_pkeys[1] = p_pkeys[0];
- p_pkeys[0] = tmp_pkey;
- }
- list_iterator = cl_list_next(list_iterator);
- }
-
- __rangelist2rangearr(p_list, p_arr, p_arr_len);
-}
-
-/***************************************************
- ***************************************************/
-
-static void __rangelist2rangearr(
- cl_list_t * p_list,
- uint64_t ** * p_arr,
- unsigned * p_arr_len)
-{
- cl_list_iterator_t list_iterator;
- unsigned len = cl_list_count(p_list);
- unsigned i = 0;
- uint64_t ** tmp_arr;
- uint64_t ** res_arr = NULL;
- unsigned res_arr_len = 0;
-
- tmp_arr = (uint64_t **)malloc(len * sizeof(uint64_t *));
-
- list_iterator = cl_list_head(p_list);
- while( list_iterator != cl_list_end(p_list) )
- {
- tmp_arr[i++] = (uint64_t *)cl_list_obj(list_iterator);
- list_iterator = cl_list_next(list_iterator);
- }
- cl_list_remove_all(p_list);
-
- __sort_reduce_rangearr( tmp_arr,
- len,
- &res_arr,
- &res_arr_len );
- *p_arr = res_arr;
- *p_arr_len = res_arr_len;
-}
-
-/***************************************************
- ***************************************************/
-
-static void __merge_rangearr(
- uint64_t ** range_arr_1,
- unsigned range_len_1,
- uint64_t ** range_arr_2,
- unsigned range_len_2,
- uint64_t ** * p_arr,
- unsigned * p_arr_len )
-{
- unsigned i = 0;
- unsigned j = 0;
- unsigned len = range_len_1 + range_len_2;
- uint64_t ** tmp_arr;
- uint64_t ** res_arr = NULL;
- unsigned res_arr_len = 0;
-
- *p_arr = NULL;
- *p_arr_len = 0;
-
- tmp_arr = (uint64_t **)malloc(len * sizeof(uint64_t *));
-
- for (i = 0; i < range_len_1; i++)
- tmp_arr[j++] = range_arr_1[i];
- for (i = 0; i < range_len_2; i++)
- tmp_arr[j++] = range_arr_2[i];
- free(range_arr_1);
- free(range_arr_2);
-
- __sort_reduce_rangearr( tmp_arr,
- len,
- &res_arr,
- &res_arr_len );
- *p_arr = res_arr;
- *p_arr_len = res_arr_len;
-}
-
-/***************************************************
- ***************************************************/
-
-static void __parser_add_port_to_port_map(
- cl_qmap_t * p_map,
- osm_physp_t * p_physp)
-{
- if (cl_qmap_get(p_map, cl_ntoh64(osm_physp_get_port_guid(p_physp))) ==
- cl_qmap_end(p_map))
- {
- osm_qos_port_t * p_port = osm_qos_policy_port_create(p_physp);
- if (p_port)
- cl_qmap_insert(p_map,
- cl_ntoh64(osm_physp_get_port_guid(p_physp)),
- &p_port->map_item);
- }
-}
-
-/***************************************************
- ***************************************************/
-
-static void __parser_add_guid_range_to_port_map(
- cl_qmap_t * p_map,
- uint64_t ** range_arr,
- unsigned range_len)
-{
- unsigned i;
- uint64_t guid_ho;
- osm_port_t * p_osm_port;
-
- if (!range_arr || !range_len)
- return;
-
- for (i = 0; i < range_len; i++) {
- for (guid_ho = range_arr[i][0]; guid_ho <= range_arr[i][1]; guid_ho++) {
- p_osm_port =
- osm_get_port_by_guid(p_qos_policy->p_subn, cl_hton64(guid_ho));
- if (p_osm_port)
- __parser_add_port_to_port_map(p_map, p_osm_port->p_physp);
- }
- free(range_arr[i]);
- }
- free(range_arr);
-}
-
-/***************************************************
- ***************************************************/
-
-static void __parser_add_pkey_range_to_port_map(
- cl_qmap_t * p_map,
- uint64_t ** range_arr,
- unsigned range_len)
-{
- unsigned i;
- uint64_t pkey_64;
- ib_net16_t pkey;
- osm_prtn_t * p_prtn;
-
- if (!range_arr || !range_len)
- return;
-
- for (i = 0; i < range_len; i++) {
- for (pkey_64 = range_arr[i][0]; pkey_64 <= range_arr[i][1]; pkey_64++) {
- pkey = cl_hton16((uint16_t)(pkey_64 & 0x7fff));
- p_prtn = (osm_prtn_t *)
- cl_qmap_get(&p_qos_policy->p_subn->prtn_pkey_tbl, pkey);
- if (p_prtn != (osm_prtn_t *)cl_qmap_end(
- &p_qos_policy->p_subn->prtn_pkey_tbl)) {
- __parser_add_map_to_port_map(p_map, &p_prtn->part_guid_tbl);
- __parser_add_map_to_port_map(p_map, &p_prtn->full_guid_tbl);
- }
- }
- free(range_arr[i]);
- }
- free(range_arr);
-}
-
-/***************************************************
- ***************************************************/
-
-static void __parser_add_partition_list_to_port_map(
- cl_qmap_t * p_map,
- cl_list_t * p_list)
-{
- cl_list_iterator_t list_iterator;
- char * tmp_str;
- osm_prtn_t * p_prtn;
-
- /* extract all the ports from the partition
- to the port map of this port group */
- list_iterator = cl_list_head(p_list);
- while(list_iterator != cl_list_end(p_list)) {
- tmp_str = (char*)cl_list_obj(list_iterator);
- if (tmp_str) {
- p_prtn = osm_prtn_find_by_name(p_qos_policy->p_subn, tmp_str);
- if (p_prtn) {
- __parser_add_map_to_port_map(p_map, &p_prtn->part_guid_tbl);
- __parser_add_map_to_port_map(p_map, &p_prtn->full_guid_tbl);
- }
- free(tmp_str);
- }
- list_iterator = cl_list_next(list_iterator);
- }
- cl_list_remove_all(p_list);
-}
-
-/***************************************************
- ***************************************************/
-
-static void __parser_add_map_to_port_map(
- cl_qmap_t * p_dmap,
- cl_map_t * p_smap)
-{
- cl_map_iterator_t map_iterator;
- osm_physp_t * p_physp;
-
- if (!p_dmap || !p_smap)
- return;
-
- map_iterator = cl_map_head(p_smap);
- while (map_iterator != cl_map_end(p_smap)) {
- p_physp = (osm_physp_t*)cl_map_obj(map_iterator);
- __parser_add_port_to_port_map(p_dmap, p_physp);
- map_iterator = cl_map_next(map_iterator);
- }
-}
-
-/***************************************************
- ***************************************************/
-
-static int __validate_pkeys( uint64_t ** range_arr,
- unsigned range_len,
- boolean_t is_ipoib)
-{
- unsigned i;
- uint64_t pkey_64;
- ib_net16_t pkey;
- osm_prtn_t * p_prtn;
-
- if (!range_arr || !range_len)
- return 0;
-
- for (i = 0; i < range_len; i++) {
- for (pkey_64 = range_arr[i][0]; pkey_64 <= range_arr[i][1]; pkey_64++) {
- pkey = cl_hton16((uint16_t)(pkey_64 & 0x7fff));
- p_prtn = (osm_prtn_t *)
- cl_qmap_get(&p_qos_policy->p_subn->prtn_pkey_tbl, pkey);
-
- if (p_prtn == (osm_prtn_t *)cl_qmap_end(
- &p_qos_policy->p_subn->prtn_pkey_tbl))
- p_prtn = NULL;
-
- if (is_ipoib) {
- /*
- * Be very strict for IPoIB partition:
- * - the partition for the pkey have to exist
- * - it has to have at least 2 full members
- */
- if (!p_prtn) {
- yyerror("IPoIB partition, pkey 0x%04X - "
- "partition doesn't exist",
- cl_ntoh16(pkey));
- return 1;
- }
- else if (cl_map_count(&p_prtn->full_guid_tbl) < 2) {
- yyerror("IPoIB partition, pkey 0x%04X - "
- "partition has less than two full members",
- cl_ntoh16(pkey));
- return 1;
- }
- }
- else if (!p_prtn) {
- /*
- * For non-IPoIB pkey we just want to check that
- * the relevant partition exists.
- * And even if it doesn't, don't exit - just print
- * error message and continue.
- */
- OSM_LOG(p_qos_parser_osm_log, OSM_LOG_ERROR, "ERR AC02: "
- "pkey 0x%04X - partition doesn't exist",
- cl_ntoh16(pkey));
- }
- }
- }
- return 0;
-}
-
-/***************************************************
- ***************************************************/
diff --git a/contrib/ofed/management/opensm/opensm/osm_qos_policy.c b/contrib/ofed/management/opensm/opensm/osm_qos_policy.c
deleted file mode 100644
index 094fef2..0000000
--- a/contrib/ofed/management/opensm/opensm/osm_qos_policy.c
+++ /dev/null
@@ -1,1091 +0,0 @@
-/*
- * Copyright (c) 2004-2008 Voltaire, Inc. All rights reserved.
- * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved.
- * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
- * Copyright (c) 2008 Xsigo Systems Inc. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- */
-
-/*
- * Abstract:
- * OSM QoS Policy functions.
- *
- * Author:
- * Yevgeny Kliteynik, Mellanox
- */
-
-#include <stdio.h>
-#include <assert.h>
-#include <stdlib.h>
-#include <string.h>
-#include <ctype.h>
-#include <opensm/osm_log.h>
-#include <opensm/osm_node.h>
-#include <opensm/osm_port.h>
-#include <opensm/osm_partition.h>
-#include <opensm/osm_opensm.h>
-#include <opensm/osm_qos_policy.h>
-
-extern osm_qos_level_t __default_simple_qos_level;
-
-/***************************************************
- ***************************************************/
-
-static void
-__build_nodebyname_hash(osm_qos_policy_t * p_qos_policy)
-{
- osm_node_t * p_node;
- cl_qmap_t * p_node_guid_tbl = &p_qos_policy->p_subn->node_guid_tbl;
-
- p_qos_policy->p_node_hash = st_init_strtable();
- CL_ASSERT(p_qos_policy->p_node_hash);
-
- if (!p_node_guid_tbl || !cl_qmap_count(p_node_guid_tbl))
- return;
-
- for (p_node = (osm_node_t *) cl_qmap_head(p_node_guid_tbl);
- p_node != (osm_node_t *) cl_qmap_end(p_node_guid_tbl);
- p_node = (osm_node_t *) cl_qmap_next(&p_node->map_item)) {
- if (!st_lookup(p_qos_policy->p_node_hash,
- (st_data_t)p_node->print_desc, NULL))
- st_insert(p_qos_policy->p_node_hash,
- (st_data_t)p_node->print_desc,
- (st_data_t)p_node);
- }
-}
-
-/***************************************************
- ***************************************************/
-
-static boolean_t
-__is_num_in_range_arr(uint64_t ** range_arr,
- unsigned range_arr_len, uint64_t num)
-{
- unsigned ind_1 = 0;
- unsigned ind_2 = range_arr_len - 1;
- unsigned ind_mid;
-
- if (!range_arr || !range_arr_len)
- return FALSE;
-
- while (ind_1 <= ind_2) {
- if (num < range_arr[ind_1][0] || num > range_arr[ind_2][1])
- return FALSE;
- else if (num <= range_arr[ind_1][1] || num >= range_arr[ind_2][0])
- return TRUE;
-
- ind_mid = ind_1 + (ind_2 - ind_1 + 1)/2;
-
- if (num < range_arr[ind_mid][0])
- ind_2 = ind_mid;
- else if (num > range_arr[ind_mid][1])
- ind_1 = ind_mid;
- else
- return TRUE;
-
- ind_1++;
- ind_2--;
- }
-
- return FALSE;
-}
-
-/***************************************************
- ***************************************************/
-
-static void __free_single_element(void *p_element, void *context)
-{
- if (p_element)
- free(p_element);
-}
-
-/***************************************************
- ***************************************************/
-
-osm_qos_port_t *osm_qos_policy_port_create(osm_physp_t *p_physp)
-{
- osm_qos_port_t *p =
- (osm_qos_port_t *) malloc(sizeof(osm_qos_port_t));
- if (!p)
- return NULL;
- memset(p, 0, sizeof(osm_qos_port_t));
-
- p->p_physp = p_physp;
- return p;
-}
-
-/***************************************************
- ***************************************************/
-
-osm_qos_port_group_t *osm_qos_policy_port_group_create()
-{
- osm_qos_port_group_t *p =
- (osm_qos_port_group_t *) malloc(sizeof(osm_qos_port_group_t));
- if (!p)
- return NULL;
-
- memset(p, 0, sizeof(osm_qos_port_group_t));
- cl_qmap_init(&p->port_map);
-
- return p;
-}
-
-/***************************************************
- ***************************************************/
-
-void osm_qos_policy_port_group_destroy(osm_qos_port_group_t * p)
-{
- osm_qos_port_t * p_port;
- osm_qos_port_t * p_old_port;
-
- if (!p)
- return;
-
- if (p->name)
- free(p->name);
- if (p->use)
- free(p->use);
-
- p_port = (osm_qos_port_t *) cl_qmap_head(&p->port_map);
- while (p_port != (osm_qos_port_t *) cl_qmap_end(&p->port_map))
- {
- p_old_port = p_port;
- p_port = (osm_qos_port_t *) cl_qmap_next(&p_port->map_item);
- free(p_old_port);
- }
- cl_qmap_remove_all(&p->port_map);
-
- free(p);
-}
-
-/***************************************************
- ***************************************************/
-
-osm_qos_vlarb_scope_t *osm_qos_policy_vlarb_scope_create()
-{
- osm_qos_vlarb_scope_t *p =
- (osm_qos_vlarb_scope_t *) malloc(sizeof(osm_qos_sl2vl_scope_t));
- if (!p)
- return NULL;
-
- memset(p, 0, sizeof(osm_qos_vlarb_scope_t));
-
- cl_list_init(&p->group_list, 10);
- cl_list_init(&p->across_list, 10);
- cl_list_init(&p->vlarb_high_list, 10);
- cl_list_init(&p->vlarb_low_list, 10);
-
- return p;
-}
-
-/***************************************************
- ***************************************************/
-
-void osm_qos_policy_vlarb_scope_destroy(osm_qos_vlarb_scope_t * p)
-{
- if (!p)
- return;
-
- cl_list_apply_func(&p->group_list, __free_single_element, NULL);
- cl_list_apply_func(&p->across_list, __free_single_element, NULL);
- cl_list_apply_func(&p->vlarb_high_list, __free_single_element, NULL);
- cl_list_apply_func(&p->vlarb_low_list, __free_single_element, NULL);
-
- cl_list_remove_all(&p->group_list);
- cl_list_remove_all(&p->across_list);
- cl_list_remove_all(&p->vlarb_high_list);
- cl_list_remove_all(&p->vlarb_low_list);
-
- cl_list_destroy(&p->group_list);
- cl_list_destroy(&p->across_list);
- cl_list_destroy(&p->vlarb_high_list);
- cl_list_destroy(&p->vlarb_low_list);
-
- free(p);
-}
-
-/***************************************************
- ***************************************************/
-
-osm_qos_sl2vl_scope_t *osm_qos_policy_sl2vl_scope_create()
-{
- osm_qos_sl2vl_scope_t *p =
- (osm_qos_sl2vl_scope_t *) malloc(sizeof(osm_qos_sl2vl_scope_t));
- if (!p)
- return NULL;
-
- memset(p, 0, sizeof(osm_qos_sl2vl_scope_t));
-
- cl_list_init(&p->group_list, 10);
- cl_list_init(&p->across_from_list, 10);
- cl_list_init(&p->across_to_list, 10);
-
- return p;
-}
-
-/***************************************************
- ***************************************************/
-
-void osm_qos_policy_sl2vl_scope_destroy(osm_qos_sl2vl_scope_t * p)
-{
- if (!p)
- return;
-
- cl_list_apply_func(&p->group_list, __free_single_element, NULL);
- cl_list_apply_func(&p->across_from_list, __free_single_element, NULL);
- cl_list_apply_func(&p->across_to_list, __free_single_element, NULL);
-
- cl_list_remove_all(&p->group_list);
- cl_list_remove_all(&p->across_from_list);
- cl_list_remove_all(&p->across_to_list);
-
- cl_list_destroy(&p->group_list);
- cl_list_destroy(&p->across_from_list);
- cl_list_destroy(&p->across_to_list);
-
- free(p);
-}
-
-/***************************************************
- ***************************************************/
-
-osm_qos_level_t *osm_qos_policy_qos_level_create()
-{
- osm_qos_level_t *p =
- (osm_qos_level_t *) malloc(sizeof(osm_qos_level_t));
- if (!p)
- return NULL;
- memset(p, 0, sizeof(osm_qos_level_t));
- return p;
-}
-
-/***************************************************
- ***************************************************/
-
-void osm_qos_policy_qos_level_destroy(osm_qos_level_t * p)
-{
- unsigned i;
-
- if (!p)
- return;
-
- if (p->name)
- free(p->name);
- if (p->use)
- free(p->use);
-
- for (i = 0; i < p->path_bits_range_len; i++)
- free(p->path_bits_range_arr[i]);
- if (p->path_bits_range_arr)
- free(p->path_bits_range_arr);
-
- free(p);
-}
-
-/***************************************************
- ***************************************************/
-
-boolean_t osm_qos_level_has_pkey(IN const osm_qos_level_t * p_qos_level,
- IN ib_net16_t pkey)
-{
- if (!p_qos_level || !p_qos_level->pkey_range_len)
- return FALSE;
- return __is_num_in_range_arr(p_qos_level->pkey_range_arr,
- p_qos_level->pkey_range_len,
- cl_ntoh16(pkey));
-}
-
-/***************************************************
- ***************************************************/
-
-ib_net16_t osm_qos_level_get_shared_pkey(IN const osm_qos_level_t * p_qos_level,
- IN const osm_physp_t * p_src_physp,
- IN const osm_physp_t * p_dest_physp)
-{
- unsigned i;
- uint16_t pkey_ho = 0;
-
- if (!p_qos_level || !p_qos_level->pkey_range_len)
- return 0;
-
- /*
- * ToDo: This approach is not optimal.
- * Think how to find shared pkey that also exists
- * in QoS level in less runtime.
- */
-
- for (i = 0; i < p_qos_level->pkey_range_len; i++) {
- for (pkey_ho = p_qos_level->pkey_range_arr[i][0];
- pkey_ho <= p_qos_level->pkey_range_arr[i][1]; pkey_ho++) {
- if (osm_physp_share_this_pkey
- (p_src_physp, p_dest_physp, cl_hton16(pkey_ho)))
- return cl_hton16(pkey_ho);
- }
- }
-
- return 0;
-}
-
-/***************************************************
- ***************************************************/
-
-osm_qos_match_rule_t *osm_qos_policy_match_rule_create()
-{
- osm_qos_match_rule_t *p =
- (osm_qos_match_rule_t *) malloc(sizeof(osm_qos_match_rule_t));
- if (!p)
- return NULL;
-
- memset(p, 0, sizeof(osm_qos_match_rule_t));
-
- cl_list_init(&p->source_list, 10);
- cl_list_init(&p->source_group_list, 10);
- cl_list_init(&p->destination_list, 10);
- cl_list_init(&p->destination_group_list, 10);
-
- return p;
-}
-
-/***************************************************
- ***************************************************/
-
-void osm_qos_policy_match_rule_destroy(osm_qos_match_rule_t * p)
-{
- unsigned i;
-
- if (!p)
- return;
-
- if (p->qos_level_name)
- free(p->qos_level_name);
- if (p->use)
- free(p->use);
-
- for (i = 0; i < p->service_id_range_len; i++)
- free(p->service_id_range_arr[i]);
- if (p->service_id_range_arr)
- free(p->service_id_range_arr);
-
- for (i = 0; i < p->qos_class_range_len; i++)
- free(p->qos_class_range_arr[i]);
- if (p->qos_class_range_arr)
- free(p->qos_class_range_arr);
-
- for (i = 0; i < p->pkey_range_len; i++)
- free(p->pkey_range_arr[i]);
- if (p->pkey_range_arr)
- free(p->pkey_range_arr);
-
- cl_list_apply_func(&p->source_list, __free_single_element, NULL);
- cl_list_remove_all(&p->source_list);
- cl_list_destroy(&p->source_list);
-
- cl_list_remove_all(&p->source_group_list);
- cl_list_destroy(&p->source_group_list);
-
- cl_list_apply_func(&p->destination_list, __free_single_element, NULL);
- cl_list_remove_all(&p->destination_list);
- cl_list_destroy(&p->destination_list);
-
- cl_list_remove_all(&p->destination_group_list);
- cl_list_destroy(&p->destination_group_list);
-
- free(p);
-}
-
-/***************************************************
- ***************************************************/
-
-osm_qos_policy_t * osm_qos_policy_create(osm_subn_t * p_subn)
-{
- osm_qos_policy_t * p_qos_policy = (osm_qos_policy_t *)malloc(sizeof(osm_qos_policy_t));
- if (!p_qos_policy)
- return NULL;
-
- memset(p_qos_policy, 0, sizeof(osm_qos_policy_t));
-
- cl_list_construct(&p_qos_policy->port_groups);
- cl_list_init(&p_qos_policy->port_groups, 10);
-
- cl_list_construct(&p_qos_policy->vlarb_tables);
- cl_list_init(&p_qos_policy->vlarb_tables, 10);
-
- cl_list_construct(&p_qos_policy->sl2vl_tables);
- cl_list_init(&p_qos_policy->sl2vl_tables, 10);
-
- cl_list_construct(&p_qos_policy->qos_levels);
- cl_list_init(&p_qos_policy->qos_levels, 10);
-
- cl_list_construct(&p_qos_policy->qos_match_rules);
- cl_list_init(&p_qos_policy->qos_match_rules, 10);
-
- p_qos_policy->p_subn = p_subn;
- __build_nodebyname_hash(p_qos_policy);
-
- return p_qos_policy;
-}
-
-/***************************************************
- ***************************************************/
-
-void osm_qos_policy_destroy(osm_qos_policy_t * p_qos_policy)
-{
- cl_list_iterator_t list_iterator;
- osm_qos_port_group_t *p_port_group = NULL;
- osm_qos_vlarb_scope_t *p_vlarb_scope = NULL;
- osm_qos_sl2vl_scope_t *p_sl2vl_scope = NULL;
- osm_qos_level_t *p_qos_level = NULL;
- osm_qos_match_rule_t *p_qos_match_rule = NULL;
-
- if (!p_qos_policy)
- return;
-
- list_iterator = cl_list_head(&p_qos_policy->port_groups);
- while (list_iterator != cl_list_end(&p_qos_policy->port_groups)) {
- p_port_group =
- (osm_qos_port_group_t *) cl_list_obj(list_iterator);
- if (p_port_group)
- osm_qos_policy_port_group_destroy(p_port_group);
- list_iterator = cl_list_next(list_iterator);
- }
- cl_list_remove_all(&p_qos_policy->port_groups);
- cl_list_destroy(&p_qos_policy->port_groups);
-
- list_iterator = cl_list_head(&p_qos_policy->vlarb_tables);
- while (list_iterator != cl_list_end(&p_qos_policy->vlarb_tables)) {
- p_vlarb_scope =
- (osm_qos_vlarb_scope_t *) cl_list_obj(list_iterator);
- if (p_vlarb_scope)
- osm_qos_policy_vlarb_scope_destroy(p_vlarb_scope);
- list_iterator = cl_list_next(list_iterator);
- }
- cl_list_remove_all(&p_qos_policy->vlarb_tables);
- cl_list_destroy(&p_qos_policy->vlarb_tables);
-
- list_iterator = cl_list_head(&p_qos_policy->sl2vl_tables);
- while (list_iterator != cl_list_end(&p_qos_policy->sl2vl_tables)) {
- p_sl2vl_scope =
- (osm_qos_sl2vl_scope_t *) cl_list_obj(list_iterator);
- if (p_sl2vl_scope)
- osm_qos_policy_sl2vl_scope_destroy(p_sl2vl_scope);
- list_iterator = cl_list_next(list_iterator);
- }
- cl_list_remove_all(&p_qos_policy->sl2vl_tables);
- cl_list_destroy(&p_qos_policy->sl2vl_tables);
-
- list_iterator = cl_list_head(&p_qos_policy->qos_levels);
- while (list_iterator != cl_list_end(&p_qos_policy->qos_levels)) {
- p_qos_level = (osm_qos_level_t *) cl_list_obj(list_iterator);
- if (p_qos_level)
- osm_qos_policy_qos_level_destroy(p_qos_level);
- list_iterator = cl_list_next(list_iterator);
- }
- cl_list_remove_all(&p_qos_policy->qos_levels);
- cl_list_destroy(&p_qos_policy->qos_levels);
-
- list_iterator = cl_list_head(&p_qos_policy->qos_match_rules);
- while (list_iterator != cl_list_end(&p_qos_policy->qos_match_rules)) {
- p_qos_match_rule =
- (osm_qos_match_rule_t *) cl_list_obj(list_iterator);
- if (p_qos_match_rule)
- osm_qos_policy_match_rule_destroy(p_qos_match_rule);
- list_iterator = cl_list_next(list_iterator);
- }
- cl_list_remove_all(&p_qos_policy->qos_match_rules);
- cl_list_destroy(&p_qos_policy->qos_match_rules);
-
- if (p_qos_policy->p_node_hash)
- st_free_table(p_qos_policy->p_node_hash);
-
- free(p_qos_policy);
-
- p_qos_policy = NULL;
-}
-
-/***************************************************
- ***************************************************/
-
-static boolean_t
-__qos_policy_is_port_in_group(osm_subn_t * p_subn,
- const osm_physp_t * p_physp,
- osm_qos_port_group_t * p_port_group)
-{
- osm_node_t *p_node = osm_physp_get_node_ptr(p_physp);
- ib_net64_t port_guid = osm_physp_get_port_guid(p_physp);
- uint64_t port_guid_ho = cl_ntoh64(port_guid);
-
- /* check whether this port's type matches any of group's types */
-
- if ( p_port_group->node_types &
- (((uint8_t)1)<<osm_node_get_type(p_node)) )
- return TRUE;
-
- /* check whether this port's guid is in group's port map */
-
- if (cl_qmap_get(&p_port_group->port_map, port_guid_ho) !=
- cl_qmap_end(&p_port_group->port_map))
- return TRUE;
-
- return FALSE;
-} /* __qos_policy_is_port_in_group() */
-
-/***************************************************
- ***************************************************/
-
-static boolean_t
-__qos_policy_is_port_in_group_list(const osm_qos_policy_t * p_qos_policy,
- const osm_physp_t * p_physp,
- cl_list_t * p_port_group_list)
-{
- osm_qos_port_group_t *p_port_group;
- cl_list_iterator_t list_iterator;
-
- list_iterator = cl_list_head(p_port_group_list);
- while (list_iterator != cl_list_end(p_port_group_list)) {
- p_port_group =
- (osm_qos_port_group_t *) cl_list_obj(list_iterator);
- if (p_port_group) {
- if (__qos_policy_is_port_in_group
- (p_qos_policy->p_subn, p_physp, p_port_group))
- return TRUE;
- }
- list_iterator = cl_list_next(list_iterator);
- }
- return FALSE;
-}
-
-/***************************************************
- ***************************************************/
-
-static osm_qos_match_rule_t *__qos_policy_get_match_rule_by_params(
- const osm_qos_policy_t * p_qos_policy,
- uint64_t service_id,
- uint16_t qos_class,
- uint16_t pkey,
- const osm_physp_t * p_src_physp,
- const osm_physp_t * p_dest_physp,
- ib_net64_t comp_mask)
-{
- osm_qos_match_rule_t *p_qos_match_rule = NULL;
- cl_list_iterator_t list_iterator;
- osm_log_t * p_log = &p_qos_policy->p_subn->p_osm->log;
-
- boolean_t matched_by_sguid = FALSE,
- matched_by_dguid = FALSE,
- matched_by_class = FALSE,
- matched_by_sid = FALSE,
- matched_by_pkey = FALSE;
-
- if (!cl_list_count(&p_qos_policy->qos_match_rules))
- return NULL;
-
- OSM_LOG_ENTER(p_log);
-
- /* Go over all QoS match rules and find the one that matches the request */
-
- list_iterator = cl_list_head(&p_qos_policy->qos_match_rules);
- while (list_iterator != cl_list_end(&p_qos_policy->qos_match_rules)) {
- p_qos_match_rule =
- (osm_qos_match_rule_t *) cl_list_obj(list_iterator);
- if (!p_qos_match_rule) {
- list_iterator = cl_list_next(list_iterator);
- continue;
- }
-
- /* If a match rule has Source groups, PR request source has to be in this list */
-
- if (cl_list_count(&p_qos_match_rule->source_group_list)) {
- if (!__qos_policy_is_port_in_group_list(p_qos_policy,
- p_src_physp,
- &p_qos_match_rule->
- source_group_list))
- {
- list_iterator = cl_list_next(list_iterator);
- continue;
- }
- matched_by_sguid = TRUE;
- }
-
- /* If a match rule has Destination groups, PR request dest. has to be in this list */
-
- if (cl_list_count(&p_qos_match_rule->destination_group_list)) {
- if (!__qos_policy_is_port_in_group_list(p_qos_policy,
- p_dest_physp,
- &p_qos_match_rule->
- destination_group_list))
- {
- list_iterator = cl_list_next(list_iterator);
- continue;
- }
- matched_by_dguid = TRUE;
- }
-
- /* If a match rule has QoS classes, PR request HAS
- to have a matching QoS class to match the rule */
-
- if (p_qos_match_rule->qos_class_range_len) {
- if (!(comp_mask & IB_PR_COMPMASK_QOS_CLASS)) {
- list_iterator = cl_list_next(list_iterator);
- continue;
- }
-
- if (!__is_num_in_range_arr
- (p_qos_match_rule->qos_class_range_arr,
- p_qos_match_rule->qos_class_range_len,
- qos_class)) {
- list_iterator = cl_list_next(list_iterator);
- continue;
- }
- matched_by_class = TRUE;
- }
-
- /* If a match rule has Service IDs, PR request HAS
- to have a matching Service ID to match the rule */
-
- if (p_qos_match_rule->service_id_range_len) {
- if (!(comp_mask & IB_PR_COMPMASK_SERVICEID_MSB) ||
- !(comp_mask & IB_PR_COMPMASK_SERVICEID_LSB)) {
- list_iterator = cl_list_next(list_iterator);
- continue;
- }
-
- if (!__is_num_in_range_arr
- (p_qos_match_rule->service_id_range_arr,
- p_qos_match_rule->service_id_range_len,
- service_id)) {
- list_iterator = cl_list_next(list_iterator);
- continue;
- }
- matched_by_sid = TRUE;
- }
-
- /* If a match rule has PKeys, PR request HAS
- to have a matching PKey to match the rule */
-
- if (p_qos_match_rule->pkey_range_len) {
- if (!(comp_mask & IB_PR_COMPMASK_PKEY)) {
- list_iterator = cl_list_next(list_iterator);
- continue;
- }
-
- if (!__is_num_in_range_arr
- (p_qos_match_rule->pkey_range_arr,
- p_qos_match_rule->pkey_range_len,
- pkey & 0x7FFF)) {
- list_iterator = cl_list_next(list_iterator);
- continue;
- }
- matched_by_pkey = TRUE;
- }
-
- /* if we got here, then this match-rule matched this PR request */
- break;
- }
-
- if (list_iterator == cl_list_end(&p_qos_policy->qos_match_rules))
- p_qos_match_rule = NULL;
-
- if (p_qos_match_rule)
- OSM_LOG(p_log, OSM_LOG_DEBUG,
- "request matched rule (%s) by:%s%s%s%s%s\n",
- (p_qos_match_rule->use) ?
- p_qos_match_rule->use : "no description",
- (matched_by_sguid) ? " SGUID" : "",
- (matched_by_dguid) ? " DGUID" : "",
- (matched_by_class) ? " QoS_Class" : "",
- (matched_by_sid) ? " ServiceID" : "",
- (matched_by_pkey) ? " PKey" : "");
- else
- OSM_LOG(p_log, OSM_LOG_DEBUG,
- "request not matched any rule\n");
-
- OSM_LOG_EXIT(p_log);
- return p_qos_match_rule;
-} /* __qos_policy_get_match_rule_by_params() */
-
-/***************************************************
- ***************************************************/
-
-static osm_qos_level_t *__qos_policy_get_qos_level_by_name(
- const osm_qos_policy_t * p_qos_policy,
- char *name)
-{
- osm_qos_level_t *p_qos_level = NULL;
- cl_list_iterator_t list_iterator;
-
- list_iterator = cl_list_head(&p_qos_policy->qos_levels);
- while (list_iterator != cl_list_end(&p_qos_policy->qos_levels)) {
- p_qos_level = (osm_qos_level_t *) cl_list_obj(list_iterator);
- if (!p_qos_level)
- continue;
-
- /* names are case INsensitive */
- if (strcasecmp(name, p_qos_level->name) == 0)
- return p_qos_level;
-
- list_iterator = cl_list_next(list_iterator);
- }
-
- return NULL;
-}
-
-/***************************************************
- ***************************************************/
-
-static osm_qos_port_group_t *__qos_policy_get_port_group_by_name(
- const osm_qos_policy_t * p_qos_policy,
- const char *const name)
-{
- osm_qos_port_group_t *p_port_group = NULL;
- cl_list_iterator_t list_iterator;
-
- list_iterator = cl_list_head(&p_qos_policy->port_groups);
- while (list_iterator != cl_list_end(&p_qos_policy->port_groups)) {
- p_port_group =
- (osm_qos_port_group_t *) cl_list_obj(list_iterator);
- if (!p_port_group)
- continue;
-
- /* names are case INsensitive */
- if (strcasecmp(name, p_port_group->name) == 0)
- return p_port_group;
-
- list_iterator = cl_list_next(list_iterator);
- }
-
- return NULL;
-}
-
-/***************************************************
- ***************************************************/
-
-static void __qos_policy_validate_pkey(
- osm_qos_policy_t * p_qos_policy,
- osm_qos_match_rule_t * p_qos_match_rule,
- osm_prtn_t * p_prtn)
-{
- uint8_t sl;
- uint32_t flow;
- uint8_t hop;
- osm_mgrp_t * p_mgrp;
-
- if (!p_qos_policy || !p_qos_match_rule || !p_prtn)
- return;
-
- if (!p_qos_match_rule->p_qos_level->sl_set ||
- p_prtn->sl == p_qos_match_rule->p_qos_level->sl)
- return;
-
- /* overriding partition's SL */
- OSM_LOG(&p_qos_policy->p_subn->p_osm->log, OSM_LOG_ERROR,
- "ERR AC15: pkey 0x%04X in match rule - "
- "overriding partition SL (%u) with QoS Level SL (%u)\n",
- cl_ntoh16(p_prtn->pkey), p_prtn->sl,
- p_qos_match_rule->p_qos_level->sl);
- p_prtn->sl = p_qos_match_rule->p_qos_level->sl;
-
-
- /* If this partition is an IPoIB partition, there should
- be a matching MCast group. Fix this group's SL too */
-
- if (!p_prtn->mlid)
- return;
-
- p_mgrp = osm_get_mgrp_by_mlid(p_qos_policy->p_subn, p_prtn->mlid);
- if (!p_mgrp) {
- OSM_LOG(&p_qos_policy->p_subn->p_osm->log, OSM_LOG_ERROR,
- "ERR AC16: MCast group for partition with "
- "pkey 0x%04X not found\n",
- cl_ntoh16(p_prtn->pkey));
- return;
- }
-
- CL_ASSERT((cl_ntoh16(p_mgrp->mcmember_rec.pkey) & 0x7fff) ==
- (cl_ntoh16(p_prtn->pkey) & 0x7fff));
-
- ib_member_get_sl_flow_hop(p_mgrp->mcmember_rec.sl_flow_hop,
- &sl, &flow, &hop);
- if (sl != p_prtn->sl) {
- OSM_LOG(&p_qos_policy->p_subn->p_osm->log, OSM_LOG_DEBUG,
- "Updating MCGroup (MLID 0x%04x) SL to "
- "match partition SL (%u)\n",
- cl_hton16(p_mgrp->mcmember_rec.mlid),
- p_prtn->sl);
- p_mgrp->mcmember_rec.sl_flow_hop =
- ib_member_set_sl_flow_hop(p_prtn->sl, flow, hop);
- }
-}
-
-/***************************************************
- ***************************************************/
-
-int osm_qos_policy_validate(osm_qos_policy_t * p_qos_policy,
- osm_log_t *p_log)
-{
- cl_list_iterator_t match_rules_list_iterator;
- cl_list_iterator_t list_iterator;
- osm_qos_port_group_t *p_port_group = NULL;
- osm_qos_match_rule_t *p_qos_match_rule = NULL;
- char *str;
- unsigned i, j;
- int res = 0;
- uint64_t pkey_64;
- ib_net16_t pkey;
- osm_prtn_t * p_prtn;
-
- OSM_LOG_ENTER(p_log);
-
- /* set default qos level */
-
- p_qos_policy->p_default_qos_level =
- __qos_policy_get_qos_level_by_name(p_qos_policy, OSM_QOS_POLICY_DEFAULT_LEVEL_NAME);
- if (!p_qos_policy->p_default_qos_level) {
- /* There's no default QoS level in the usual qos-level section.
- Check whether the 'simple' default QoS level that can be
- defined in the qos-ulp section exists */
- if (__default_simple_qos_level.sl_set) {
- p_qos_policy->p_default_qos_level = &__default_simple_qos_level;
- }
- else {
- OSM_LOG(p_log, OSM_LOG_ERROR, "ERR AC10: "
- "Default qos-level (%s) not defined.\n",
- OSM_QOS_POLICY_DEFAULT_LEVEL_NAME);
- res = 1;
- goto Exit;
- }
- }
-
- /* scan all the match rules, and fill the lists of pointers to
- relevant qos levels and port groups to speed up PR matching */
-
- i = 1;
- match_rules_list_iterator =
- cl_list_head(&p_qos_policy->qos_match_rules);
- while (match_rules_list_iterator !=
- cl_list_end(&p_qos_policy->qos_match_rules)) {
- p_qos_match_rule =
- (osm_qos_match_rule_t *)
- cl_list_obj(match_rules_list_iterator);
- CL_ASSERT(p_qos_match_rule);
-
- /* find the matching qos-level for each match-rule */
-
- if (!p_qos_match_rule->p_qos_level)
- p_qos_match_rule->p_qos_level =
- __qos_policy_get_qos_level_by_name(p_qos_policy,
- p_qos_match_rule->qos_level_name);
-
- if (!p_qos_match_rule->p_qos_level) {
- OSM_LOG(p_log, OSM_LOG_ERROR, "ERR AC11: "
- "qos-match-rule num %u: qos-level '%s' not found\n",
- i, p_qos_match_rule->qos_level_name);
- res = 1;
- goto Exit;
- }
-
- /* find the matching port-group for element of source_list */
-
- if (cl_list_count(&p_qos_match_rule->source_list)) {
- list_iterator =
- cl_list_head(&p_qos_match_rule->source_list);
- while (list_iterator !=
- cl_list_end(&p_qos_match_rule->source_list)) {
- str = (char *)cl_list_obj(list_iterator);
- CL_ASSERT(str);
-
- p_port_group =
- __qos_policy_get_port_group_by_name(p_qos_policy, str);
- if (!p_port_group) {
- OSM_LOG(p_log, OSM_LOG_ERROR, "ERR AC12: "
- "qos-match-rule num %u: source port-group '%s' not found\n",
- i, str);
- res = 1;
- goto Exit;
- }
-
- cl_list_insert_tail(&p_qos_match_rule->
- source_group_list,
- p_port_group);
-
- list_iterator = cl_list_next(list_iterator);
- }
- }
-
- /* find the matching port-group for element of destination_list */
-
- if (cl_list_count(&p_qos_match_rule->destination_list)) {
- list_iterator =
- cl_list_head(&p_qos_match_rule->destination_list);
- while (list_iterator !=
- cl_list_end(&p_qos_match_rule->
- destination_list)) {
- str = (char *)cl_list_obj(list_iterator);
- CL_ASSERT(str);
-
- p_port_group =
- __qos_policy_get_port_group_by_name(p_qos_policy,str);
- if (!p_port_group) {
- OSM_LOG(p_log, OSM_LOG_ERROR, "ERR AC13: "
- "qos-match-rule num %u: destination port-group '%s' not found\n",
- i, str);
- res = 1;
- goto Exit;
- }
-
- cl_list_insert_tail(&p_qos_match_rule->
- destination_group_list,
- p_port_group);
-
- list_iterator = cl_list_next(list_iterator);
- }
- }
-
- /*
- * Scan all the pkeys in matching rule, and if the
- * partition for these pkeys exists, set the SL
- * according to the QoS Level.
- * Warn if there's mismatch between QoS level SL
- * and Partition SL.
- */
-
- for (j = 0; j < p_qos_match_rule->pkey_range_len; j++) {
- for ( pkey_64 = p_qos_match_rule->pkey_range_arr[j][0];
- pkey_64 <= p_qos_match_rule->pkey_range_arr[j][1];
- pkey_64++) {
- pkey = cl_hton16((uint16_t)(pkey_64 & 0x7fff));
- p_prtn = (osm_prtn_t *)cl_qmap_get(
- &p_qos_policy->p_subn->prtn_pkey_tbl, pkey);
-
- if (p_prtn == (osm_prtn_t *)cl_qmap_end(
- &p_qos_policy->p_subn->prtn_pkey_tbl))
- /* partition for this pkey not found */
- OSM_LOG(p_log, OSM_LOG_ERROR, "ERR AC14: "
- "pkey 0x%04X in match rule - "
- "partition doesn't exist\n",
- cl_ntoh16(pkey));
- else
- __qos_policy_validate_pkey(p_qos_policy,
- p_qos_match_rule,
- p_prtn);
- }
- }
-
- /* done with the current match-rule */
-
- match_rules_list_iterator =
- cl_list_next(match_rules_list_iterator);
- i++;
- }
-
-Exit:
- OSM_LOG_EXIT(p_log);
- return res;
-} /* osm_qos_policy_validate() */
-
-/***************************************************
- ***************************************************/
-
-static osm_qos_level_t * __qos_policy_get_qos_level_by_params(
- IN const osm_qos_policy_t * p_qos_policy,
- IN const osm_physp_t * p_src_physp,
- IN const osm_physp_t * p_dest_physp,
- IN uint64_t service_id,
- IN uint16_t qos_class,
- IN uint16_t pkey,
- IN ib_net64_t comp_mask)
-{
- osm_qos_match_rule_t *p_qos_match_rule = NULL;
-
- if (!p_qos_policy)
- return NULL;
-
- p_qos_match_rule = __qos_policy_get_match_rule_by_params(
- p_qos_policy, service_id, qos_class, pkey,
- p_src_physp, p_dest_physp, comp_mask);
-
- return p_qos_match_rule ? p_qos_match_rule->p_qos_level :
- p_qos_policy->p_default_qos_level;
-} /* __qos_policy_get_qos_level_by_params() */
-
-/***************************************************
- ***************************************************/
-
-osm_qos_level_t * osm_qos_policy_get_qos_level_by_pr(
- IN const osm_qos_policy_t * p_qos_policy,
- IN const ib_path_rec_t * p_pr,
- IN const osm_physp_t * p_src_physp,
- IN const osm_physp_t * p_dest_physp,
- IN ib_net64_t comp_mask)
-{
- return __qos_policy_get_qos_level_by_params(
- p_qos_policy, p_src_physp, p_dest_physp,
- cl_ntoh64(p_pr->service_id), ib_path_rec_qos_class(p_pr),
- cl_ntoh16(p_pr->pkey), comp_mask);
-}
-
-/***************************************************
- ***************************************************/
-
-osm_qos_level_t * osm_qos_policy_get_qos_level_by_mpr(
- IN const osm_qos_policy_t * p_qos_policy,
- IN const ib_multipath_rec_t * p_mpr,
- IN const osm_physp_t * p_src_physp,
- IN const osm_physp_t * p_dest_physp,
- IN ib_net64_t comp_mask)
-{
- ib_net64_t pr_comp_mask = 0;
-
- if (!p_qos_policy)
- return NULL;
-
- /*
- * Converting MultiPathRecord compmask to the PathRecord
- * compmask. Note that only relevant bits are set.
- */
- pr_comp_mask =
- ((comp_mask & IB_MPR_COMPMASK_QOS_CLASS) ?
- IB_PR_COMPMASK_QOS_CLASS : 0) |
- ((comp_mask & IB_MPR_COMPMASK_PKEY) ?
- IB_PR_COMPMASK_PKEY : 0) |
- ((comp_mask & IB_MPR_COMPMASK_SERVICEID_MSB) ?
- IB_PR_COMPMASK_SERVICEID_MSB : 0) |
- ((comp_mask & IB_MPR_COMPMASK_SERVICEID_LSB) ?
- IB_PR_COMPMASK_SERVICEID_LSB : 0);
-
- return __qos_policy_get_qos_level_by_params(
- p_qos_policy, p_src_physp, p_dest_physp,
- cl_ntoh64(ib_multipath_rec_service_id(p_mpr)),
- ib_multipath_rec_qos_class(p_mpr),
- cl_ntoh16(p_mpr->pkey), pr_comp_mask);
-}
-
-/***************************************************
- ***************************************************/
diff --git a/contrib/ofed/management/opensm/opensm/osm_remote_sm.c b/contrib/ofed/management/opensm/opensm/osm_remote_sm.c
deleted file mode 100644
index 96bfd78..0000000
--- a/contrib/ofed/management/opensm/opensm/osm_remote_sm.c
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * Copyright (c) 2004-2006 Voltaire, Inc. All rights reserved.
- * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved.
- * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- */
-
-/*
- * Abstract:
- * Implementation of osm_sm_t.
- * This object represents the remote SM object.
- * This object is part of the opensm family of objects.
- */
-
-#if HAVE_CONFIG_H
-# include <config.h>
-#endif /* HAVE_CONFIG_H */
-
-#include <string.h>
-#include <opensm/osm_remote_sm.h>
-
-/**********************************************************************
- **********************************************************************/
-void osm_remote_sm_construct(IN osm_remote_sm_t * const p_sm)
-{
- memset(p_sm, 0, sizeof(*p_sm));
-}
-
-/**********************************************************************
- **********************************************************************/
-void osm_remote_sm_destroy(IN osm_remote_sm_t * const p_sm)
-{
- memset(p_sm, 0, sizeof(*p_sm));
-}
-
-/**********************************************************************
- **********************************************************************/
-void
-osm_remote_sm_init(IN osm_remote_sm_t * const p_sm,
- IN const osm_port_t * const p_port,
- IN const ib_sm_info_t * const p_smi)
-{
- CL_ASSERT(p_sm);
- CL_ASSERT(p_port);
-
- osm_remote_sm_construct(p_sm);
-
- p_sm->p_port = p_port;
- p_sm->smi = *p_smi;
- return;
-}
diff --git a/contrib/ofed/management/opensm/opensm/osm_req.c b/contrib/ofed/management/opensm/opensm/osm_req.c
deleted file mode 100644
index 0865ce5..0000000
--- a/contrib/ofed/management/opensm/opensm/osm_req.c
+++ /dev/null
@@ -1,280 +0,0 @@
-/*
- * Copyright (c) 2004-2008 Voltaire, Inc. All rights reserved.
- * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved.
- * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- */
-
-/*
- * Abstract:
- * Implementation of osm_req_t.
- * This object represents the generic attribute requester.
- * This object is part of the opensm family of objects.
- */
-
-#if HAVE_CONFIG_H
-# include <config.h>
-#endif /* HAVE_CONFIG_H */
-
-#include <string.h>
-#include <iba/ib_types.h>
-#include <complib/cl_debug.h>
-#include <opensm/osm_madw.h>
-#include <opensm/osm_attrib_req.h>
-#include <opensm/osm_log.h>
-#include <opensm/osm_helper.h>
-#include <opensm/osm_mad_pool.h>
-#include <opensm/osm_vl15intf.h>
-#include <opensm/osm_msgdef.h>
-#include <opensm/osm_opensm.h>
-
-/**********************************************************************
- The plock MAY or MAY NOT be held before calling this function.
-**********************************************************************/
-ib_api_status_t
-osm_req_get(IN osm_sm_t * sm,
- IN const osm_dr_path_t * const p_path,
- IN const uint16_t attr_id,
- IN const uint32_t attr_mod,
- IN const cl_disp_msgid_t err_msg,
- IN const osm_madw_context_t * const p_context)
-{
- osm_madw_t *p_madw;
- ib_api_status_t status = IB_SUCCESS;
- ib_net64_t tid;
-
- CL_ASSERT(sm);
-
- OSM_LOG_ENTER(sm->p_log);
-
- CL_ASSERT(p_path);
- CL_ASSERT(attr_id);
-
- /* do nothing if we are exiting ... */
- if (osm_exit_flag)
- goto Exit;
-
- /* p_context may be NULL. */
-
- p_madw = osm_mad_pool_get(sm->p_mad_pool,
- p_path->h_bind, MAD_BLOCK_SIZE, NULL);
-
- if (p_madw == NULL) {
- OSM_LOG(sm->p_log, OSM_LOG_ERROR,
- "ERR 1101: Unable to acquire MAD\n");
- status = IB_INSUFFICIENT_RESOURCES;
- goto Exit;
- }
-
- tid = cl_hton64((uint64_t) cl_atomic_inc(&sm->sm_trans_id));
-
- OSM_LOG(sm->p_log, OSM_LOG_DEBUG,
- "Getting %s (0x%X), modifier 0x%X, TID 0x%" PRIx64 "\n",
- ib_get_sm_attr_str(attr_id), cl_ntoh16(attr_id),
- cl_ntoh32(attr_mod), cl_ntoh64(tid));
-
- ib_smp_init_new(osm_madw_get_smp_ptr(p_madw),
- IB_MAD_METHOD_GET,
- tid,
- attr_id,
- attr_mod,
- p_path->hop_count,
- sm->p_subn->opt.m_key,
- p_path->path, IB_LID_PERMISSIVE, IB_LID_PERMISSIVE);
-
- p_madw->mad_addr.dest_lid = IB_LID_PERMISSIVE;
- p_madw->mad_addr.addr_type.smi.source_lid = IB_LID_PERMISSIVE;
- p_madw->resp_expected = TRUE;
- p_madw->fail_msg = err_msg;
-
- /*
- Fill in the mad wrapper context for the recipient.
- In this case, the only thing the recipient needs is the
- guid value.
- */
-
- if (p_context)
- p_madw->context = *p_context;
-
- osm_vl15_post(sm->p_vl15, p_madw);
-
-Exit:
- OSM_LOG_EXIT(sm->p_log);
- return (status);
-}
-
-/**********************************************************************
- The plock MAY or MAY NOT be held before calling this function.
-**********************************************************************/
-ib_api_status_t
-osm_req_set(IN osm_sm_t * sm,
- IN const osm_dr_path_t * const p_path,
- IN const uint8_t * const p_payload,
- IN const size_t payload_size,
- IN const uint16_t attr_id,
- IN const uint32_t attr_mod,
- IN const cl_disp_msgid_t err_msg,
- IN const osm_madw_context_t * const p_context)
-{
- osm_madw_t *p_madw;
- ib_api_status_t status = IB_SUCCESS;
- ib_net64_t tid;
-
- CL_ASSERT(sm);
-
- OSM_LOG_ENTER(sm->p_log);
-
- CL_ASSERT(p_path);
- CL_ASSERT(attr_id);
- CL_ASSERT(p_payload);
-
- /* do nothing if we are exiting ... */
- if (osm_exit_flag)
- goto Exit;
-
- /* p_context may be NULL. */
-
- p_madw = osm_mad_pool_get(sm->p_mad_pool,
- p_path->h_bind, MAD_BLOCK_SIZE, NULL);
-
- if (p_madw == NULL) {
- OSM_LOG(sm->p_log, OSM_LOG_ERROR,
- "ERR 1102: Unable to acquire MAD\n");
- status = IB_INSUFFICIENT_RESOURCES;
- goto Exit;
- }
-
- tid = cl_hton64((uint64_t) cl_atomic_inc(&sm->sm_trans_id));
-
- OSM_LOG(sm->p_log, OSM_LOG_DEBUG,
- "Setting %s (0x%X), modifier 0x%X, TID 0x%" PRIx64 "\n",
- ib_get_sm_attr_str(attr_id), cl_ntoh16(attr_id),
- cl_ntoh32(attr_mod), cl_ntoh64(tid));
-
- ib_smp_init_new(osm_madw_get_smp_ptr(p_madw),
- IB_MAD_METHOD_SET,
- tid,
- attr_id,
- attr_mod,
- p_path->hop_count,
- sm->p_subn->opt.m_key,
- p_path->path, IB_LID_PERMISSIVE, IB_LID_PERMISSIVE);
-
- p_madw->mad_addr.dest_lid = IB_LID_PERMISSIVE;
- p_madw->mad_addr.addr_type.smi.source_lid = IB_LID_PERMISSIVE;
- p_madw->resp_expected = TRUE;
- p_madw->fail_msg = err_msg;
-
- /*
- Fill in the mad wrapper context for the recipient.
- In this case, the only thing the recipient needs is the
- guid value.
- */
-
- if (p_context)
- p_madw->context = *p_context;
-
- memcpy(osm_madw_get_smp_ptr(p_madw)->data, p_payload, payload_size);
-
- osm_vl15_post(sm->p_vl15, p_madw);
-
-Exit:
- OSM_LOG_EXIT(sm->p_log);
- return (status);
-}
-
-int osm_send_trap144(osm_sm_t *sm, ib_net16_t local)
-{
- osm_madw_t *madw;
- ib_smp_t *smp;
- ib_mad_notice_attr_t *ntc;
- osm_port_t *port;
- ib_port_info_t *pi;
-
- port = osm_get_port_by_guid(sm->p_subn, sm->p_subn->sm_port_guid);
- if (!port) {
- OSM_LOG(sm->p_log, OSM_LOG_ERROR,
- "ERR 1104: cannot find SM port by guid 0x%" PRIx64 "\n",
- cl_ntoh64(sm->p_subn->sm_port_guid));
- return -1;
- }
-
- pi = &port->p_physp->port_info;
-
- /* don't bother with sending trap when SMA supports this */
- if (!local &&
- pi->capability_mask&(IB_PORT_CAP_HAS_TRAP|IB_PORT_CAP_HAS_CAP_NTC))
- return 0;
-
- madw = osm_mad_pool_get(sm->p_mad_pool,
- osm_sm_mad_ctrl_get_bind_handle(&sm->mad_ctrl),
- MAD_BLOCK_SIZE, NULL);
- if (madw == NULL) {
- OSM_LOG(sm->p_log, OSM_LOG_ERROR,
- "ERR 1105: Unable to acquire MAD\n");
- return -1;
- }
-
- madw->mad_addr.dest_lid = pi->master_sm_base_lid;
- madw->mad_addr.addr_type.smi.source_lid = pi->base_lid;
- madw->fail_msg = CL_DISP_MSGID_NONE;
-
- smp = osm_madw_get_smp_ptr(madw);
- memset(smp, 0, sizeof(*smp));
-
- smp->base_ver = 1;
- smp->mgmt_class = IB_MCLASS_SUBN_LID;
- smp->class_ver = 1;
- smp->method = IB_MAD_METHOD_TRAP;
- smp->trans_id = cl_hton64((uint64_t)cl_atomic_inc(&sm->sm_trans_id));
- smp->attr_id = IB_MAD_ATTR_NOTICE;
- smp->m_key = sm->p_subn->opt.m_key;
-
- ntc = (ib_mad_notice_attr_t *)smp->data;
-
- ntc->generic_type = 0x80 | IB_NOTICE_TYPE_INFO;
- ib_notice_set_prod_type_ho(ntc, IB_NODE_TYPE_CA);
- ntc->g_or_v.generic.trap_num = cl_hton16(144);
- ntc->issuer_lid = pi->base_lid;
- ntc->data_details.ntc_144.lid = pi->base_lid;
- ntc->data_details.ntc_144.local_changes = local ?
- TRAP_144_MASK_OTHER_LOCAL_CHANGES : 0;
- ntc->data_details.ntc_144.new_cap_mask = pi->capability_mask;
- ntc->data_details.ntc_144.change_flgs = local;
-
- OSM_LOG(sm->p_log, OSM_LOG_DEBUG,
- "Sending Trap 144, TID 0x%" PRIx64 " to SM lid %u\n",
- cl_ntoh64(smp->trans_id), cl_ntoh16(pi->master_sm_base_lid));
-
- osm_vl15_post(sm->p_vl15, madw);
-
- return 0;
-}
diff --git a/contrib/ofed/management/opensm/opensm/osm_resp.c b/contrib/ofed/management/opensm/opensm/osm_resp.c
deleted file mode 100644
index 9cd44f5..0000000
--- a/contrib/ofed/management/opensm/opensm/osm_resp.c
+++ /dev/null
@@ -1,157 +0,0 @@
-/*
- * Copyright (c) 2004-2008 Voltaire, Inc. All rights reserved.
- * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved.
- * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- */
-
-/*
- * Abstract:
- * Implementation of osm_resp_t.
- * This object represents the generic attribute responder.
- * This object is part of the opensm family of objects.
- */
-
-#if HAVE_CONFIG_H
-# include <config.h>
-#endif /* HAVE_CONFIG_H */
-
-#include <string.h>
-#include <iba/ib_types.h>
-#include <complib/cl_debug.h>
-#include <opensm/osm_madw.h>
-#include <opensm/osm_attrib_req.h>
-#include <opensm/osm_log.h>
-#include <opensm/osm_helper.h>
-#include <opensm/osm_mad_pool.h>
-#include <opensm/osm_vl15intf.h>
-#include <opensm/osm_msgdef.h>
-#include <opensm/osm_opensm.h>
-
-/**********************************************************************
- **********************************************************************/
-static void
-osm_resp_make_resp_smp(IN osm_sm_t * sm,
- IN const ib_smp_t * const p_src_smp,
- IN const ib_net16_t status,
- IN const uint8_t * const p_payload,
- OUT ib_smp_t * const p_dest_smp)
-{
- OSM_LOG_ENTER(sm->p_log);
-
- CL_ASSERT(p_dest_smp);
- CL_ASSERT(p_src_smp);
- CL_ASSERT(!ib_smp_is_response(p_src_smp));
-
- *p_dest_smp = *p_src_smp;
- if (p_src_smp->method == IB_MAD_METHOD_GET ||
- p_src_smp->method == IB_MAD_METHOD_SET) {
- p_dest_smp->method = IB_MAD_METHOD_GET_RESP;
- p_dest_smp->status = status;
- } else if (p_src_smp->method == IB_MAD_METHOD_TRAP) {
- p_dest_smp->method = IB_MAD_METHOD_TRAP_REPRESS;
- p_dest_smp->status = 0;
- } else {
- OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR 1302: "
- "src smp method unsupported 0x%X\n", p_src_smp->method);
- goto Exit;
- }
-
- if (p_src_smp->mgmt_class == IB_MCLASS_SUBN_DIR)
- p_dest_smp->status |= IB_SMP_DIRECTION;
-
- p_dest_smp->dr_dlid = p_dest_smp->dr_slid;
- p_dest_smp->dr_slid = p_dest_smp->dr_dlid;
- memcpy(&p_dest_smp->data, p_payload, IB_SMP_DATA_SIZE);
-
-Exit:
- OSM_LOG_EXIT(sm->p_log);
-}
-
-/**********************************************************************
- **********************************************************************/
-ib_api_status_t
-osm_resp_send(IN osm_sm_t * sm,
- IN const osm_madw_t * const p_req_madw,
- IN const ib_net16_t mad_status,
- IN const uint8_t * const p_payload)
-{
- const ib_smp_t *p_req_smp;
- ib_smp_t *p_smp;
- osm_madw_t *p_madw;
- ib_api_status_t status = IB_SUCCESS;
-
- OSM_LOG_ENTER(sm->p_log);
-
- CL_ASSERT(p_req_madw);
- CL_ASSERT(p_payload);
-
- /* do nothing if we are exiting ... */
- if (osm_exit_flag)
- goto Exit;
-
- p_madw = osm_mad_pool_get(sm->p_mad_pool,
- osm_madw_get_bind_handle(p_req_madw),
- MAD_BLOCK_SIZE, NULL);
-
- if (p_madw == NULL) {
- OSM_LOG(sm->p_log, OSM_LOG_ERROR,
- "ERR 1301: Unable to acquire MAD\n");
- status = IB_INSUFFICIENT_RESOURCES;
- goto Exit;
- }
-
- /*
- Copy the request smp to the response smp, then just
- update the necessary fields.
- */
- p_smp = osm_madw_get_smp_ptr(p_madw);
- p_req_smp = osm_madw_get_smp_ptr(p_req_madw);
- osm_resp_make_resp_smp(sm, p_req_smp, mad_status, p_payload, p_smp);
- p_madw->mad_addr.dest_lid =
- p_req_madw->mad_addr.addr_type.smi.source_lid;
- p_madw->mad_addr.addr_type.smi.source_lid =
- p_req_madw->mad_addr.dest_lid;
-
- p_madw->resp_expected = FALSE;
- p_madw->fail_msg = CL_DISP_MSGID_NONE;
-
- OSM_LOG(sm->p_log, OSM_LOG_DEBUG, "Responding to %s (0x%X)"
- "\n\t\t\t\tattribute modifier 0x%X, TID 0x%" PRIx64 "\n",
- ib_get_sm_attr_str(p_smp->attr_id), cl_ntoh16(p_smp->attr_id),
- cl_ntoh32(p_smp->attr_mod), cl_ntoh64(p_smp->trans_id));
-
- osm_vl15_post(sm->p_vl15, p_madw);
-
-Exit:
- OSM_LOG_EXIT(sm->p_log);
- return (status);
-}
diff --git a/contrib/ofed/management/opensm/opensm/osm_router.c b/contrib/ofed/management/opensm/opensm/osm_router.c
deleted file mode 100644
index cb5a236..0000000
--- a/contrib/ofed/management/opensm/opensm/osm_router.c
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- * Copyright (c) 2004-2007 Voltaire, Inc. All rights reserved.
- * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved.
- * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- */
-
-/*
- * Abstract:
- * Implementation of osm_router_t.
- * This object represents an Infiniband router.
- * This object is part of the opensm family of objects.
- */
-
-#if HAVE_CONFIG_H
-# include <config.h>
-#endif /* HAVE_CONFIG_H */
-
-#include <stdlib.h>
-#include <string.h>
-#include <iba/ib_types.h>
-#include <opensm/osm_router.h>
-
-/**********************************************************************
- **********************************************************************/
-void osm_router_delete(IN OUT osm_router_t ** const pp_rtr)
-{
- free(*pp_rtr);
- *pp_rtr = NULL;
-}
-
-/**********************************************************************
- **********************************************************************/
-osm_router_t *osm_router_new(IN osm_port_t * const p_port)
-{
- osm_router_t *p_rtr;
-
- CL_ASSERT(p_port);
-
- p_rtr = (osm_router_t *) malloc(sizeof(*p_rtr));
- if (p_rtr) {
- memset(p_rtr, 0, sizeof(*p_rtr));
- p_rtr->p_port = p_port;
- }
-
- return (p_rtr);
-}
diff --git a/contrib/ofed/management/opensm/opensm/osm_sa.c b/contrib/ofed/management/opensm/opensm/osm_sa.c
deleted file mode 100644
index 185557f..0000000
--- a/contrib/ofed/management/opensm/opensm/osm_sa.c
+++ /dev/null
@@ -1,1123 +0,0 @@
-/*
- * Copyright (c) 2004-2008 Voltaire, Inc. All rights reserved.
- * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved.
- * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
- * Copyright (c) 2008 Xsigo Systems Inc. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- */
-
-/*
- * Abstract:
- * Implementation of osm_sa_t.
- * This object represents the Subnet Administration object.
- * This object is part of the opensm family of objects.
- */
-
-#if HAVE_CONFIG_H
-# include <config.h>
-#endif /* HAVE_CONFIG_H */
-
-#include <string.h>
-#include <ctype.h>
-#include <errno.h>
-#include <stdlib.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <complib/cl_qmap.h>
-#include <complib/cl_passivelock.h>
-#include <complib/cl_debug.h>
-#include <iba/ib_types.h>
-#include <opensm/osm_sa.h>
-#include <opensm/osm_madw.h>
-#include <opensm/osm_log.h>
-#include <opensm/osm_subnet.h>
-#include <opensm/osm_mad_pool.h>
-#include <opensm/osm_msgdef.h>
-#include <opensm/osm_opensm.h>
-#include <opensm/osm_multicast.h>
-#include <opensm/osm_inform.h>
-#include <opensm/osm_service.h>
-#include <opensm/osm_helper.h>
-#include <vendor/osm_vendor_api.h>
-
-#define OSM_SA_INITIAL_TID_VALUE 0xabc
-
-extern void osm_cpi_rcv_process(IN void *context, IN void *data);
-extern void osm_gir_rcv_process(IN void *context, IN void *data);
-extern void osm_infr_rcv_process(IN void *context, IN void *data);
-extern void osm_infir_rcv_process(IN void *context, IN void *data);
-extern void osm_lftr_rcv_process(IN void *context, IN void *data);
-extern void osm_lr_rcv_process(IN void *context, IN void *data);
-extern void osm_mcmr_rcv_process(IN void *context, IN void *data);
-extern void osm_mftr_rcv_process(IN void *context, IN void *data);
-extern void osm_mpr_rcv_process(IN void *context, IN void *data);
-extern void osm_nr_rcv_process(IN void *context, IN void *data);
-extern void osm_pr_rcv_process(IN void *context, IN void *data);
-extern void osm_pkey_rec_rcv_process(IN void *context, IN void *data);
-extern void osm_pir_rcv_process(IN void *context, IN void *data);
-extern void osm_sr_rcv_process(IN void *context, IN void *data);
-extern void osm_slvl_rec_rcv_process(IN void *context, IN void *data);
-extern void osm_smir_rcv_process(IN void *context, IN void *data);
-extern void osm_sir_rcv_process(IN void *context, IN void *data);
-extern void osm_vlarb_rec_rcv_process(IN void *context, IN void *data);
-extern void osm_sr_rcv_lease_cb(IN void *context);
-
-/**********************************************************************
- **********************************************************************/
-void osm_sa_construct(IN osm_sa_t * const p_sa)
-{
- memset(p_sa, 0, sizeof(*p_sa));
- p_sa->state = OSM_SA_STATE_INIT;
- p_sa->sa_trans_id = OSM_SA_INITIAL_TID_VALUE;
-
- cl_timer_construct(&p_sa->sr_timer);
-}
-
-/**********************************************************************
- **********************************************************************/
-void osm_sa_shutdown(IN osm_sa_t * const p_sa)
-{
- ib_api_status_t status;
- OSM_LOG_ENTER(p_sa->p_log);
-
- cl_timer_stop(&p_sa->sr_timer);
-
- /* unbind from the mad service */
- status = osm_sa_mad_ctrl_unbind(&p_sa->mad_ctrl);
-
- /* remove any registered dispatcher message */
- cl_disp_unregister(p_sa->nr_disp_h);
- cl_disp_unregister(p_sa->pir_disp_h);
- cl_disp_unregister(p_sa->gir_disp_h);
- cl_disp_unregister(p_sa->lr_disp_h);
- cl_disp_unregister(p_sa->pr_disp_h);
-#if defined (VENDOR_RMPP_SUPPORT) && defined (DUAL_SIDED_RMPP)
- cl_disp_unregister(p_sa->mpr_disp_h);
-#endif
- cl_disp_unregister(p_sa->smir_disp_h);
- cl_disp_unregister(p_sa->mcmr_disp_h);
- cl_disp_unregister(p_sa->sr_disp_h);
- cl_disp_unregister(p_sa->infr_disp_h);
- cl_disp_unregister(p_sa->infir_disp_h);
- cl_disp_unregister(p_sa->vlarb_disp_h);
- cl_disp_unregister(p_sa->slvl_disp_h);
- cl_disp_unregister(p_sa->pkey_disp_h);
- cl_disp_unregister(p_sa->lft_disp_h);
- cl_disp_unregister(p_sa->sir_disp_h);
- cl_disp_unregister(p_sa->mft_disp_h);
- osm_sa_mad_ctrl_destroy(&p_sa->mad_ctrl);
-
- OSM_LOG_EXIT(p_sa->p_log);
-}
-
-/**********************************************************************
- **********************************************************************/
-void osm_sa_destroy(IN osm_sa_t * const p_sa)
-{
- OSM_LOG_ENTER(p_sa->p_log);
-
- p_sa->state = OSM_SA_STATE_INIT;
-
- cl_timer_destroy(&p_sa->sr_timer);
-
- OSM_LOG_EXIT(p_sa->p_log);
-}
-
-/**********************************************************************
- **********************************************************************/
-ib_api_status_t
-osm_sa_init(IN osm_sm_t * const p_sm,
- IN osm_sa_t * const p_sa,
- IN osm_subn_t * const p_subn,
- IN osm_vendor_t * const p_vendor,
- IN osm_mad_pool_t * const p_mad_pool,
- IN osm_log_t * const p_log,
- IN osm_stats_t * const p_stats,
- IN cl_dispatcher_t * const p_disp, IN cl_plock_t * const p_lock)
-{
- ib_api_status_t status = IB_SUCCESS;
-
- OSM_LOG_ENTER(p_log);
-
- p_sa->sm = p_sm;
- p_sa->p_subn = p_subn;
- p_sa->p_vendor = p_vendor;
- p_sa->p_mad_pool = p_mad_pool;
- p_sa->p_log = p_log;
- p_sa->p_disp = p_disp;
- p_sa->p_lock = p_lock;
-
- p_sa->state = OSM_SA_STATE_READY;
-
- status = osm_sa_mad_ctrl_init(&p_sa->mad_ctrl,
- p_sa,
- p_sa->p_mad_pool,
- p_sa->p_vendor,
- p_subn, p_log, p_stats, p_disp);
- if (status != IB_SUCCESS)
- goto Exit;
-
- status = cl_timer_init(&p_sa->sr_timer, osm_sr_rcv_lease_cb, p_sa);
- if (status != IB_SUCCESS)
- goto Exit;
-
- p_sa->cpi_disp_h = cl_disp_register(p_disp, OSM_MSG_MAD_CLASS_PORT_INFO,
- osm_cpi_rcv_process, p_sa);
- if (p_sa->cpi_disp_h == CL_DISP_INVALID_HANDLE)
- goto Exit;
-
- p_sa->nr_disp_h = cl_disp_register(p_disp, OSM_MSG_MAD_NODE_RECORD,
- osm_nr_rcv_process, p_sa);
- if (p_sa->nr_disp_h == CL_DISP_INVALID_HANDLE)
- goto Exit;
-
- p_sa->pir_disp_h = cl_disp_register(p_disp, OSM_MSG_MAD_PORTINFO_RECORD,
- osm_pir_rcv_process, p_sa);
- if (p_sa->pir_disp_h == CL_DISP_INVALID_HANDLE)
- goto Exit;
-
- p_sa->gir_disp_h = cl_disp_register(p_disp, OSM_MSG_MAD_GUIDINFO_RECORD,
- osm_gir_rcv_process, p_sa);
- if (p_sa->gir_disp_h == CL_DISP_INVALID_HANDLE)
- goto Exit;
-
- p_sa->lr_disp_h = cl_disp_register(p_disp, OSM_MSG_MAD_LINK_RECORD,
- osm_lr_rcv_process, p_sa);
- if (p_sa->lr_disp_h == CL_DISP_INVALID_HANDLE)
- goto Exit;
-
- p_sa->pr_disp_h = cl_disp_register(p_disp, OSM_MSG_MAD_PATH_RECORD,
- osm_pr_rcv_process, p_sa);
- if (p_sa->pr_disp_h == CL_DISP_INVALID_HANDLE)
- goto Exit;
-
-#if defined (VENDOR_RMPP_SUPPORT) && defined (DUAL_SIDED_RMPP)
- p_sa->mpr_disp_h =
- cl_disp_register(p_disp, OSM_MSG_MAD_MULTIPATH_RECORD,
- osm_mpr_rcv_process, p_sa);
- if (p_sa->mpr_disp_h == CL_DISP_INVALID_HANDLE)
- goto Exit;
-#endif
-
- p_sa->smir_disp_h = cl_disp_register(p_disp, OSM_MSG_MAD_SMINFO_RECORD,
- osm_smir_rcv_process, p_sa);
- if (p_sa->smir_disp_h == CL_DISP_INVALID_HANDLE)
- goto Exit;
-
- p_sa->mcmr_disp_h =
- cl_disp_register(p_disp, OSM_MSG_MAD_MCMEMBER_RECORD,
- osm_mcmr_rcv_process, p_sa);
- if (p_sa->mcmr_disp_h == CL_DISP_INVALID_HANDLE)
- goto Exit;
-
- p_sa->sr_disp_h = cl_disp_register(p_disp, OSM_MSG_MAD_SERVICE_RECORD,
- osm_sr_rcv_process, p_sa);
- if (p_sa->sr_disp_h == CL_DISP_INVALID_HANDLE)
- goto Exit;
-
- p_sa->infr_disp_h = cl_disp_register(p_disp, OSM_MSG_MAD_INFORM_INFO,
- osm_infr_rcv_process, p_sa);
- if (p_sa->infr_disp_h == CL_DISP_INVALID_HANDLE)
- goto Exit;
-
- p_sa->infir_disp_h =
- cl_disp_register(p_disp, OSM_MSG_MAD_INFORM_INFO_RECORD,
- osm_infir_rcv_process, p_sa);
- if (p_sa->infir_disp_h == CL_DISP_INVALID_HANDLE)
- goto Exit;
-
- p_sa->vlarb_disp_h = cl_disp_register(p_disp, OSM_MSG_MAD_VL_ARB_RECORD,
- osm_vlarb_rec_rcv_process, p_sa);
- if (p_sa->vlarb_disp_h == CL_DISP_INVALID_HANDLE)
- goto Exit;
-
- p_sa->slvl_disp_h =
- cl_disp_register(p_disp, OSM_MSG_MAD_SLVL_TBL_RECORD,
- osm_slvl_rec_rcv_process, p_sa);
- if (p_sa->slvl_disp_h == CL_DISP_INVALID_HANDLE)
- goto Exit;
-
- p_sa->pkey_disp_h =
- cl_disp_register(p_disp, OSM_MSG_MAD_PKEY_TBL_RECORD,
- osm_pkey_rec_rcv_process, p_sa);
- if (p_sa->pkey_disp_h == CL_DISP_INVALID_HANDLE)
- goto Exit;
-
- p_sa->lft_disp_h = cl_disp_register(p_disp, OSM_MSG_MAD_LFT_RECORD,
- osm_lftr_rcv_process, p_sa);
- if (p_sa->lft_disp_h == CL_DISP_INVALID_HANDLE)
- goto Exit;
-
- p_sa->sir_disp_h =
- cl_disp_register(p_disp, OSM_MSG_MAD_SWITCH_INFO_RECORD,
- osm_sir_rcv_process, p_sa);
- if (p_sa->sir_disp_h == CL_DISP_INVALID_HANDLE)
- goto Exit;
-
- p_sa->mft_disp_h = cl_disp_register(p_disp, OSM_MSG_MAD_MFT_RECORD,
- osm_mftr_rcv_process, p_sa);
- if (p_sa->mft_disp_h == CL_DISP_INVALID_HANDLE)
- goto Exit;
-
-Exit:
- OSM_LOG_EXIT(p_log);
- return (status);
-}
-
-/**********************************************************************
- **********************************************************************/
-ib_api_status_t
-osm_sa_bind(IN osm_sa_t * const p_sa, IN const ib_net64_t port_guid)
-{
- ib_api_status_t status;
-
- OSM_LOG_ENTER(p_sa->p_log);
-
- status = osm_sa_mad_ctrl_bind(&p_sa->mad_ctrl, port_guid);
-
- if (status != IB_SUCCESS) {
- OSM_LOG(p_sa->p_log, OSM_LOG_ERROR, "ERR 4C03: "
- "SA MAD Controller bind failed (%s)\n",
- ib_get_err_str(status));
- goto Exit;
- }
-
-Exit:
- OSM_LOG_EXIT(p_sa->p_log);
- return (status);
-}
-
-ib_api_status_t osm_sa_send(osm_sa_t *sa,
- IN osm_madw_t * const p_madw,
- IN boolean_t const resp_expected)
-{
- ib_api_status_t status;
-
- cl_atomic_inc(&sa->p_subn->p_osm->stats.sa_mads_sent);
- status = osm_vendor_send(p_madw->h_bind, p_madw, resp_expected);
- if (status != IB_SUCCESS) {
- cl_atomic_dec(&sa->p_subn->p_osm->stats.sa_mads_sent);
- OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 4C04: "
- "osm_vendor_send failed, status = %s\n",
- ib_get_err_str(status));
- }
- return status;
-}
-
-void
-osm_sa_send_error(IN osm_sa_t * sa,
- IN const osm_madw_t * const p_madw,
- IN const ib_net16_t sa_status)
-{
- osm_madw_t *p_resp_madw;
- ib_sa_mad_t *p_resp_sa_mad;
- ib_sa_mad_t *p_sa_mad;
-
- OSM_LOG_ENTER(sa->p_log);
-
- /* avoid races - if we are exiting - exit */
- if (osm_exit_flag) {
- OSM_LOG(sa->p_log, OSM_LOG_DEBUG,
- "Ignoring requested send after exit\n");
- goto Exit;
- }
-
- p_resp_madw = osm_mad_pool_get(sa->p_mad_pool,
- p_madw->h_bind, MAD_BLOCK_SIZE,
- &p_madw->mad_addr);
-
- if (p_resp_madw == NULL) {
- OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 4C07: "
- "Unable to acquire response MAD\n");
- goto Exit;
- }
-
- p_resp_sa_mad = osm_madw_get_sa_mad_ptr(p_resp_madw);
- p_sa_mad = osm_madw_get_sa_mad_ptr(p_madw);
-
- /* Copy the MAD header back into the response mad */
- *p_resp_sa_mad = *p_sa_mad;
- p_resp_sa_mad->status = sa_status;
-
- if (p_resp_sa_mad->method == IB_MAD_METHOD_SET)
- p_resp_sa_mad->method = IB_MAD_METHOD_GET;
- else if (p_resp_sa_mad->method == IB_MAD_METHOD_GETTABLE)
- p_resp_sa_mad->attr_offset = 0;
-
- p_resp_sa_mad->method |= IB_MAD_METHOD_RESP_MASK;
-
- /*
- * C15-0.1.5 - always return SM_Key = 0 (table 185 p 884)
- */
- p_resp_sa_mad->sm_key = 0;
-
- /*
- * o15-0.2.7 - The PathRecord Attribute ID shall be used in
- * the response (to a SubnAdmGetMulti(MultiPathRecord)
- */
- if (p_resp_sa_mad->attr_id == IB_MAD_ATTR_MULTIPATH_RECORD)
- p_resp_sa_mad->attr_id = IB_MAD_ATTR_PATH_RECORD;
-
- if (osm_log_is_active(sa->p_log, OSM_LOG_FRAMES))
- osm_dump_sa_mad(sa->p_log, p_resp_sa_mad, OSM_LOG_FRAMES);
-
- osm_sa_send(sa, p_resp_madw, FALSE);
-
-Exit:
- OSM_LOG_EXIT(sa->p_log);
-}
-
-void osm_sa_respond(osm_sa_t *sa, osm_madw_t *madw, size_t attr_size,
- cl_qlist_t *list)
-{
- struct item_data {
- cl_list_item_t list;
- char data[0];
- };
- cl_list_item_t *item;
- osm_madw_t *resp_madw;
- ib_sa_mad_t *sa_mad, *resp_sa_mad;
- unsigned num_rec, i;
-#ifndef VENDOR_RMPP_SUPPORT
- unsigned trim_num_rec;
-#endif
- void *p;
-
- sa_mad = osm_madw_get_sa_mad_ptr(madw);
- num_rec = cl_qlist_count(list);
-
- /*
- * C15-0.1.30:
- * If we do a SubnAdmGet and got more than one record it is an error!
- */
- if (sa_mad->method == IB_MAD_METHOD_GET && num_rec > 1) {
- OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 4C05: "
- "Got more than one record for SubnAdmGet (%u)\n",
- num_rec);
- osm_sa_send_error(sa, madw, IB_SA_MAD_STATUS_TOO_MANY_RECORDS);
- goto Exit;
- }
-
-#ifndef VENDOR_RMPP_SUPPORT
- trim_num_rec = (MAD_BLOCK_SIZE - IB_SA_MAD_HDR_SIZE) / attr_size;
- if (trim_num_rec < num_rec) {
- OSM_LOG(sa->p_log, OSM_LOG_VERBOSE,
- "Number of records:%u trimmed to:%u to fit in one MAD\n",
- num_rec, trim_num_rec);
- num_rec = trim_num_rec;
- }
-#endif
-
- OSM_LOG(sa->p_log, OSM_LOG_DEBUG, "Returning %u records\n", num_rec);
-
- if (sa_mad->method == IB_MAD_METHOD_GET && num_rec == 0) {
- osm_sa_send_error(sa, madw, IB_SA_MAD_STATUS_NO_RECORDS);
- goto Exit;
- }
-
- /*
- * Get a MAD to reply. Address of Mad is in the received mad_wrapper
- */
- resp_madw = osm_mad_pool_get(sa->p_mad_pool, madw->h_bind,
- num_rec * attr_size + IB_SA_MAD_HDR_SIZE,
- &madw->mad_addr);
- if (!resp_madw) {
- OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 4C06: "
- "osm_mad_pool_get failed\n");
- osm_sa_send_error(sa, madw, IB_SA_MAD_STATUS_NO_RESOURCES);
- goto Exit;
- }
-
- resp_sa_mad = osm_madw_get_sa_mad_ptr(resp_madw);
-
- /*
- Copy the MAD header back into the response mad.
- Set the 'R' bit and the payload length,
- Then copy all records from the list into the response payload.
- */
-
- memcpy(resp_sa_mad, sa_mad, IB_SA_MAD_HDR_SIZE);
- if (resp_sa_mad->method == IB_MAD_METHOD_SET)
- resp_sa_mad->method = IB_MAD_METHOD_GET;
- resp_sa_mad->method |= IB_MAD_METHOD_RESP_MASK;
- /* C15-0.1.5 - always return SM_Key = 0 (table 185 p 884) */
- resp_sa_mad->sm_key = 0;
-
- /* Fill in the offset (paylen will be done by the rmpp SAR) */
- resp_sa_mad->attr_offset = num_rec ? ib_get_attr_offset(attr_size) : 0;
-
- p = ib_sa_mad_get_payload_ptr(resp_sa_mad);
-
-#ifndef VENDOR_RMPP_SUPPORT
- /* we support only one packet RMPP - so we will set the first and
- last flags for gettable */
- if (resp_sa_mad->method == IB_MAD_METHOD_GETTABLE_RESP) {
- resp_sa_mad->rmpp_type = IB_RMPP_TYPE_DATA;
- resp_sa_mad->rmpp_flags =
- IB_RMPP_FLAG_FIRST | IB_RMPP_FLAG_LAST |
- IB_RMPP_FLAG_ACTIVE;
- }
-#else
- /* forcefully define the packet as RMPP one */
- if (resp_sa_mad->method == IB_MAD_METHOD_GETTABLE_RESP)
- resp_sa_mad->rmpp_flags = IB_RMPP_FLAG_ACTIVE;
-#endif
-
- for (i = 0; i < num_rec; i++) {
- item = cl_qlist_remove_head(list);
- memcpy(p, ((struct item_data *)item)->data, attr_size);
- p += attr_size;
- free(item);
- }
-
- osm_sa_send(sa, resp_madw, FALSE);
-
- osm_dump_sa_mad(sa->p_log, resp_sa_mad, OSM_LOG_FRAMES);
-Exit:
- /* need to set the mem free ... */
- item = cl_qlist_remove_head(list);
- while (item != cl_qlist_end(list)) {
- free(item);
- item = cl_qlist_remove_head(list);
- }
-}
-
-/**********************************************************************
- **********************************************************************/
-/*
- * SA DB Dumper
- *
- */
-
-struct opensm_dump_context {
- osm_opensm_t *p_osm;
- FILE *file;
-};
-
-static int
-opensm_dump_to_file(osm_opensm_t * p_osm, const char *file_name,
- void (*dump_func) (osm_opensm_t * p_osm, FILE * file))
-{
- char path[1024];
- FILE *file;
-
- snprintf(path, sizeof(path), "%s/%s",
- p_osm->subn.opt.dump_files_dir, file_name);
-
- file = fopen(path, "w");
- if (!file) {
- OSM_LOG(&p_osm->log, OSM_LOG_ERROR, "ERR 4C01: "
- "cannot open file \'%s\': %s\n",
- file_name, strerror(errno));
- return -1;
- }
-
- chmod(path, S_IRUSR | S_IWUSR);
-
- dump_func(p_osm, file);
-
- fclose(file);
- return 0;
-}
-
-static void mcast_mgr_dump_one_port(cl_map_item_t * p_map_item, void *cxt)
-{
- FILE *file = ((struct opensm_dump_context *)cxt)->file;
- osm_mcm_port_t *p_mcm_port = (osm_mcm_port_t *) p_map_item;
-
- fprintf(file, "mcm_port: "
- "port_gid=0x%016" PRIx64 ":0x%016" PRIx64 " "
- "scope_state=0x%02x proxy_join=0x%x" "\n\n",
- cl_ntoh64(p_mcm_port->port_gid.unicast.prefix),
- cl_ntoh64(p_mcm_port->port_gid.unicast.interface_id),
- p_mcm_port->scope_state, p_mcm_port->proxy_join);
-}
-
-static void sa_dump_one_mgrp(osm_mgrp_t *p_mgrp, void *cxt)
-{
- struct opensm_dump_context dump_context;
- osm_opensm_t *p_osm = ((struct opensm_dump_context *)cxt)->p_osm;
- FILE *file = ((struct opensm_dump_context *)cxt)->file;
-
- fprintf(file, "MC Group 0x%04x %s:"
- " mgid=0x%016" PRIx64 ":0x%016" PRIx64
- " port_gid=0x%016" PRIx64 ":0x%016" PRIx64
- " qkey=0x%08x mlid=0x%04x mtu=0x%02x tclass=0x%02x"
- " pkey=0x%04x rate=0x%02x pkt_life=0x%02x sl_flow_hop=0x%08x"
- " scope_state=0x%02x proxy_join=0x%x" "\n\n",
- cl_ntoh16(p_mgrp->mlid),
- p_mgrp->well_known ? " (well known)" : "",
- cl_ntoh64(p_mgrp->mcmember_rec.mgid.unicast.prefix),
- cl_ntoh64(p_mgrp->mcmember_rec.mgid.unicast.interface_id),
- cl_ntoh64(p_mgrp->mcmember_rec.port_gid.unicast.prefix),
- cl_ntoh64(p_mgrp->mcmember_rec.port_gid.unicast.interface_id),
- cl_ntoh32(p_mgrp->mcmember_rec.qkey),
- cl_ntoh16(p_mgrp->mcmember_rec.mlid),
- p_mgrp->mcmember_rec.mtu,
- p_mgrp->mcmember_rec.tclass,
- cl_ntoh16(p_mgrp->mcmember_rec.pkey),
- p_mgrp->mcmember_rec.rate,
- p_mgrp->mcmember_rec.pkt_life,
- cl_ntoh32(p_mgrp->mcmember_rec.sl_flow_hop),
- p_mgrp->mcmember_rec.scope_state,
- p_mgrp->mcmember_rec.proxy_join);
-
- dump_context.p_osm = p_osm;
- dump_context.file = file;
-
- cl_qmap_apply_func(&p_mgrp->mcm_port_tbl,
- mcast_mgr_dump_one_port, &dump_context);
-}
-
-static void sa_dump_one_inform(cl_list_item_t * p_list_item, void *cxt)
-{
- FILE *file = ((struct opensm_dump_context *)cxt)->file;
- osm_infr_t *p_infr = (osm_infr_t *) p_list_item;
- ib_inform_info_record_t *p_iir = &p_infr->inform_record;
-
- fprintf(file, "InformInfo Record:"
- " subscriber_gid=0x%016" PRIx64 ":0x%016" PRIx64
- " subscriber_enum=0x%x"
- " InformInfo:"
- " gid=0x%016" PRIx64 ":0x%016" PRIx64
- " lid_range_begin=0x%x"
- " lid_range_end=0x%x"
- " is_generic=0x%x"
- " subscribe=0x%x"
- " trap_type=0x%x"
- " trap_num=0x%x"
- " qpn_resp_time_val=0x%x"
- " node_type=0x%06x"
- " rep_addr: lid=0x%04x path_bits=0x%02x static_rate=0x%02x"
- " remote_qp=0x%08x remote_qkey=0x%08x pkey_ix=0x%04x sl=0x%02x"
- "\n\n",
- cl_ntoh64(p_iir->subscriber_gid.unicast.prefix),
- cl_ntoh64(p_iir->subscriber_gid.unicast.interface_id),
- cl_ntoh16(p_iir->subscriber_enum),
- cl_ntoh64(p_iir->inform_info.gid.unicast.prefix),
- cl_ntoh64(p_iir->inform_info.gid.unicast.interface_id),
- cl_ntoh16(p_iir->inform_info.lid_range_begin),
- cl_ntoh16(p_iir->inform_info.lid_range_end),
- p_iir->inform_info.is_generic,
- p_iir->inform_info.subscribe,
- cl_ntoh16(p_iir->inform_info.trap_type),
- cl_ntoh16(p_iir->inform_info.g_or_v.generic.trap_num),
- cl_ntoh32(p_iir->inform_info.g_or_v.generic.qpn_resp_time_val),
- cl_ntoh32(ib_inform_info_get_prod_type(&p_iir->inform_info)),
- cl_ntoh16(p_infr->report_addr.dest_lid),
- p_infr->report_addr.path_bits,
- p_infr->report_addr.static_rate,
- cl_ntoh32(p_infr->report_addr.addr_type.gsi.remote_qp),
- cl_ntoh32(p_infr->report_addr.addr_type.gsi.remote_qkey),
- p_infr->report_addr.addr_type.gsi.pkey_ix,
- p_infr->report_addr.addr_type.gsi.service_level);
-}
-
-static void sa_dump_one_service(cl_list_item_t * p_list_item, void *cxt)
-{
- FILE *file = ((struct opensm_dump_context *)cxt)->file;
- osm_svcr_t *p_svcr = (osm_svcr_t *) p_list_item;
- ib_service_record_t *p_sr = &p_svcr->service_record;
-
- fprintf(file, "Service Record: id=0x%016" PRIx64
- " gid=0x%016" PRIx64 ":0x%016" PRIx64
- " pkey=0x%x"
- " lease=0x%x"
- " key=0x%02x%02x%02x%02x%02x%02x%02x%02x"
- ":0x%02x%02x%02x%02x%02x%02x%02x%02x"
- " name=\'%s\'"
- " data8=0x%02x%02x%02x%02x%02x%02x%02x%02x"
- ":0x%02x%02x%02x%02x%02x%02x%02x%02x"
- " data16=0x%04x%04x%04x%04x:0x%04x%04x%04x%04x"
- " data32=0x%08x%08x:0x%08x%08x"
- " data64=0x%016" PRIx64 ":0x%016" PRIx64
- " modified_time=0x%x lease_period=0x%x\n\n",
- cl_ntoh64(p_sr->service_id),
- cl_ntoh64(p_sr->service_gid.unicast.prefix),
- cl_ntoh64(p_sr->service_gid.unicast.interface_id),
- cl_ntoh16(p_sr->service_pkey),
- cl_ntoh32(p_sr->service_lease),
- p_sr->service_key[0], p_sr->service_key[1],
- p_sr->service_key[2], p_sr->service_key[3],
- p_sr->service_key[4], p_sr->service_key[5],
- p_sr->service_key[6], p_sr->service_key[7],
- p_sr->service_key[8], p_sr->service_key[9],
- p_sr->service_key[10], p_sr->service_key[11],
- p_sr->service_key[12], p_sr->service_key[13],
- p_sr->service_key[14], p_sr->service_key[15],
- p_sr->service_name,
- p_sr->service_data8[0], p_sr->service_data8[1],
- p_sr->service_data8[2], p_sr->service_data8[3],
- p_sr->service_data8[4], p_sr->service_data8[5],
- p_sr->service_data8[6], p_sr->service_data8[7],
- p_sr->service_data8[8], p_sr->service_data8[9],
- p_sr->service_data8[10], p_sr->service_data8[11],
- p_sr->service_data8[12], p_sr->service_data8[13],
- p_sr->service_data8[14], p_sr->service_data8[15],
- cl_ntoh16(p_sr->service_data16[0]),
- cl_ntoh16(p_sr->service_data16[1]),
- cl_ntoh16(p_sr->service_data16[2]),
- cl_ntoh16(p_sr->service_data16[3]),
- cl_ntoh16(p_sr->service_data16[4]),
- cl_ntoh16(p_sr->service_data16[5]),
- cl_ntoh16(p_sr->service_data16[6]),
- cl_ntoh16(p_sr->service_data16[7]),
- cl_ntoh32(p_sr->service_data32[0]),
- cl_ntoh32(p_sr->service_data32[1]),
- cl_ntoh32(p_sr->service_data32[2]),
- cl_ntoh32(p_sr->service_data32[3]),
- cl_ntoh64(p_sr->service_data64[0]),
- cl_ntoh64(p_sr->service_data64[1]),
- p_svcr->modified_time, p_svcr->lease_period);
-}
-
-static void sa_dump_all_sa(osm_opensm_t * p_osm, FILE * file)
-{
- struct opensm_dump_context dump_context;
- osm_mgrp_t *p_mgrp;
- int i;
-
- dump_context.p_osm = p_osm;
- dump_context.file = file;
- OSM_LOG(&p_osm->log, OSM_LOG_DEBUG, "Dump multicast:\n");
- cl_plock_acquire(&p_osm->lock);
- for (i = 0; i <= p_osm->subn.max_mcast_lid_ho - IB_LID_MCAST_START_HO;
- i++) {
- p_mgrp = p_osm->subn.mgroups[i];
- if (p_mgrp)
- sa_dump_one_mgrp(p_mgrp, &dump_context);
- }
- OSM_LOG(&p_osm->log, OSM_LOG_DEBUG, "Dump inform:\n");
- cl_qlist_apply_func(&p_osm->subn.sa_infr_list,
- sa_dump_one_inform, &dump_context);
- OSM_LOG(&p_osm->log, OSM_LOG_DEBUG, "Dump services:\n");
- cl_qlist_apply_func(&p_osm->subn.sa_sr_list,
- sa_dump_one_service, &dump_context);
- cl_plock_release(&p_osm->lock);
-}
-
-int osm_sa_db_file_dump(osm_opensm_t * p_osm)
-{
- return opensm_dump_to_file(p_osm, "opensm-sa.dump", sa_dump_all_sa);
-}
-
-/*
- * SA DB Loader
- */
-static osm_mgrp_t *load_mcgroup(osm_opensm_t * p_osm, ib_net16_t mlid,
- ib_member_rec_t * p_mcm_rec,
- unsigned well_known)
-{
- ib_net64_t comp_mask;
- osm_mgrp_t *p_mgrp;
-
- cl_plock_excl_acquire(&p_osm->lock);
-
- p_mgrp = osm_get_mgrp_by_mlid(&p_osm->subn, mlid);
- if (p_mgrp) {
- if (!memcmp(&p_mgrp->mcmember_rec.mgid, &p_mcm_rec->mgid,
- sizeof(ib_gid_t))) {
- OSM_LOG(&p_osm->log, OSM_LOG_DEBUG,
- "mgrp %04x is already here.", cl_ntoh16(mlid));
- goto _out;
- }
- OSM_LOG(&p_osm->log, OSM_LOG_VERBOSE,
- "mlid %04x is already used by another MC group. Will "
- "request clients reregistration.\n", cl_ntoh16(mlid));
- p_mgrp = NULL;
- goto _out;
- }
-
- comp_mask = IB_MCR_COMPMASK_MTU | IB_MCR_COMPMASK_MTU_SEL
- | IB_MCR_COMPMASK_RATE | IB_MCR_COMPMASK_RATE_SEL;
- if (osm_mcmr_rcv_find_or_create_new_mgrp(&p_osm->sa,
- comp_mask, p_mcm_rec,
- &p_mgrp) != IB_SUCCESS ||
- !p_mgrp || p_mgrp->mlid != mlid) {
- OSM_LOG(&p_osm->log, OSM_LOG_ERROR,
- "cannot create MC group with mlid 0x%04x and mgid "
- "0x%016" PRIx64 ":0x%016" PRIx64 "\n", cl_ntoh16(mlid),
- cl_ntoh64(p_mcm_rec->mgid.unicast.prefix),
- cl_ntoh64(p_mcm_rec->mgid.unicast.interface_id));
- p_mgrp = NULL;
- } else if (well_known)
- p_mgrp->well_known = TRUE;
-
-_out:
- cl_plock_release(&p_osm->lock);
-
- return p_mgrp;
-}
-
-static int load_svcr(osm_opensm_t * p_osm, ib_service_record_t * sr,
- uint32_t modified_time, uint32_t lease_period)
-{
- osm_svcr_t *p_svcr;
- int ret = 0;
-
- cl_plock_excl_acquire(&p_osm->lock);
-
- if (osm_svcr_get_by_rid(&p_osm->subn, &p_osm->log, sr)) {
- OSM_LOG(&p_osm->log, OSM_LOG_VERBOSE,
- "ServiceRecord already exists\n");
- goto _out;
- }
-
- if (!(p_svcr = osm_svcr_new(sr))) {
- OSM_LOG(&p_osm->log, OSM_LOG_ERROR,
- "cannot allocate new service struct\n");
- ret = -1;
- goto _out;
- }
-
- p_svcr->modified_time = modified_time;
- p_svcr->lease_period = lease_period;
-
- OSM_LOG(&p_osm->log, OSM_LOG_DEBUG, "adding ServiceRecord...\n");
-
- osm_svcr_insert_to_db(&p_osm->subn, &p_osm->log, p_svcr);
-
- if (lease_period != 0xffffffff)
- cl_timer_trim(&p_osm->sa.sr_timer, 1000);
-
-_out:
- cl_plock_release(&p_osm->lock);
-
- return ret;
-}
-
-static int load_infr(osm_opensm_t * p_osm, ib_inform_info_record_t * iir,
- osm_mad_addr_t * addr)
-{
- osm_infr_t infr, *p_infr;
- int ret = 0;
-
- infr.h_bind = p_osm->sa.mad_ctrl.h_bind;
- infr.sa = &p_osm->sa;
- /* other possible way to restore mad_addr partially is
- to extract qpn from InformInfo and to find lid by gid */
- infr.report_addr = *addr;
- infr.inform_record = *iir;
-
- cl_plock_excl_acquire(&p_osm->lock);
- if (osm_infr_get_by_rec(&p_osm->subn, &p_osm->log, &infr)) {
- OSM_LOG(&p_osm->log, OSM_LOG_VERBOSE,
- "InformInfo Record already exists\n");
- goto _out;
- }
-
- if (!(p_infr = osm_infr_new(&infr))) {
- OSM_LOG(&p_osm->log, OSM_LOG_ERROR,
- "cannot allocate new infr struct\n");
- ret = -1;
- goto _out;
- }
-
- OSM_LOG(&p_osm->log, OSM_LOG_DEBUG, "adding InformInfo Record...\n");
-
- osm_infr_insert_to_db(&p_osm->subn, &p_osm->log, p_infr);
-
-_out:
- cl_plock_release(&p_osm->lock);
-
- return ret;
-}
-
-#define UNPACK_FUNC(name,x) \
-static int unpack_##name##x(char *p, uint##x##_t *val_ptr) \
-{ \
- char *q; \
- unsigned long long num; \
- num = strtoull(p, &q, 16); \
- if (num > ~((uint##x##_t)0x0) \
- || q == p || (!isspace(*q) && *q != ':')) { \
- *val_ptr = 0; \
- return -1; \
- } \
- *val_ptr = cl_hton##x((uint##x##_t)num); \
- return (int)(q - p); \
-}
-
-#define cl_hton8(x) (x)
-
-UNPACK_FUNC(net, 8);
-UNPACK_FUNC(net, 16);
-UNPACK_FUNC(net, 32);
-UNPACK_FUNC(net, 64);
-
-static int unpack_string(char *p, uint8_t * buf, unsigned len)
-{
- char *q = p;
- char delim = ' ';
-
- if (*q == '\'' || *q == '\"')
- delim = *q++;
- while (--len && *q && *q != delim)
- *buf++ = *q++;
- *buf = '\0';
- if (*q == delim && delim != ' ')
- q++;
- return (int)(q - p);
-}
-
-static int unpack_string64(char *p, uint8_t * buf)
-{
- return unpack_string(p, buf, 64);
-}
-
-#define PARSE_AHEAD(p, x, name, val_ptr) { int _ret; \
- p = strstr(p, name); \
- if (!p) { \
- OSM_LOG(&p_osm->log, OSM_LOG_ERROR, \
- "PARSE ERROR: %s:%u: cannot find \"%s\" string\n", \
- file_name, lineno, (name)); \
- ret = -2; \
- goto _error; \
- } \
- p += strlen(name); \
- _ret = unpack_##x(p, (val_ptr)); \
- if (_ret < 0) { \
- OSM_LOG(&p_osm->log, OSM_LOG_ERROR, \
- "PARSE ERROR: %s:%u: cannot parse "#x" value " \
- "after \"%s\"\n", file_name, lineno, (name)); \
- ret = _ret; \
- goto _error; \
- } \
- p += _ret; \
-}
-
-int osm_sa_db_file_load(osm_opensm_t * p_osm)
-{
- char line[1024];
- char *file_name;
- FILE *file;
- int ret = 0;
- osm_mgrp_t *p_mgrp = NULL;
- unsigned rereg_clients = 0;
- unsigned lineno;
-
- file_name = p_osm->subn.opt.sa_db_file;
- if (!file_name) {
- OSM_LOG(&p_osm->log, OSM_LOG_VERBOSE,
- "sa db file name is not specifed. Skip restore\n");
- return 0;
- }
-
- file = fopen(file_name, "r");
- if (!file) {
- OSM_LOG(&p_osm->log, OSM_LOG_ERROR | OSM_LOG_SYS, "ERR 4C02: "
- "cannot open sa db file \'%s\'. Skip restoring\n",
- file_name);
- return -1;
- }
-
- lineno = 0;
-
- while (fgets(line, sizeof(line) - 1, file) != NULL) {
- char *p;
- uint8_t val;
-
- lineno++;
-
- p = line;
- while (isspace(*p))
- p++;
-
- if (*p == '#')
- continue;
-
- if (!strncmp(p, "MC Group", 8)) {
- ib_member_rec_t mcm_rec;
- ib_net16_t mlid;
- unsigned well_known = 0;
-
- p_mgrp = NULL;
- memset(&mcm_rec, 0, sizeof(mcm_rec));
-
- PARSE_AHEAD(p, net16, " 0x", &mlid);
- if (strstr(p, "well known"))
- well_known = 1;
- PARSE_AHEAD(p, net64, " mgid=0x",
- &mcm_rec.mgid.unicast.prefix);
- PARSE_AHEAD(p, net64, ":0x",
- &mcm_rec.mgid.unicast.interface_id);
- PARSE_AHEAD(p, net64, " port_gid=0x",
- &mcm_rec.port_gid.unicast.prefix);
- PARSE_AHEAD(p, net64, ":0x",
- &mcm_rec.port_gid.unicast.interface_id);
- PARSE_AHEAD(p, net32, " qkey=0x", &mcm_rec.qkey);
- PARSE_AHEAD(p, net16, " mlid=0x", &mcm_rec.mlid);
- PARSE_AHEAD(p, net8, " mtu=0x", &mcm_rec.mtu);
- PARSE_AHEAD(p, net8, " tclass=0x", &mcm_rec.tclass);
- PARSE_AHEAD(p, net16, " pkey=0x", &mcm_rec.pkey);
- PARSE_AHEAD(p, net8, " rate=0x", &mcm_rec.rate);
- PARSE_AHEAD(p, net8, " pkt_life=0x", &mcm_rec.pkt_life);
- PARSE_AHEAD(p, net32, " sl_flow_hop=0x",
- &mcm_rec.sl_flow_hop);
- PARSE_AHEAD(p, net8, " scope_state=0x",
- &mcm_rec.scope_state);
- PARSE_AHEAD(p, net8, " proxy_join=0x", &val);
- mcm_rec.proxy_join = val;
-
- p_mgrp = load_mcgroup(p_osm, mlid, &mcm_rec,
- well_known);
- if (!p_mgrp)
- rereg_clients = 1;
- } else if (p_mgrp && !strncmp(p, "mcm_port", 8)) {
- ib_gid_t port_gid;
- ib_net64_t guid;
- uint8_t scope_state;
- boolean_t proxy_join;
-
- PARSE_AHEAD(p, net64, " port_gid=0x",
- &port_gid.unicast.prefix);
- PARSE_AHEAD(p, net64, ":0x",
- &port_gid.unicast.interface_id);
- PARSE_AHEAD(p, net8, " scope_state=0x", &scope_state);
- PARSE_AHEAD(p, net8, " proxy_join=0x", &val);
- proxy_join = val;
-
- guid = port_gid.unicast.interface_id;
- if (cl_qmap_get(&p_mgrp->mcm_port_tbl,
- port_gid.unicast.interface_id) ==
- cl_qmap_end(&p_mgrp->mcm_port_tbl))
- osm_mgrp_add_port(&p_osm->subn, &p_osm->log,
- p_mgrp, &port_gid,
- scope_state, proxy_join);
- } else if (!strncmp(p, "Service Record:", 15)) {
- ib_service_record_t s_rec;
- uint32_t modified_time, lease_period;
-
- p_mgrp = NULL;
- memset(&s_rec, 0, sizeof(s_rec));
-
- PARSE_AHEAD(p, net64, " id=0x", &s_rec.service_id);
- PARSE_AHEAD(p, net64, " gid=0x",
- &s_rec.service_gid.unicast.prefix);
- PARSE_AHEAD(p, net64, ":0x",
- &s_rec.service_gid.unicast.interface_id);
- PARSE_AHEAD(p, net16, " pkey=0x", &s_rec.service_pkey);
- PARSE_AHEAD(p, net32, " lease=0x",
- &s_rec.service_lease);
- PARSE_AHEAD(p, net64, " key=0x",
- (ib_net64_t *) (&s_rec.service_key[0]));
- PARSE_AHEAD(p, net64, ":0x",
- (ib_net64_t *) (&s_rec.service_key[8]));
- PARSE_AHEAD(p, string64, " name=", s_rec.service_name);
- PARSE_AHEAD(p, net64, " data8=0x",
- (ib_net64_t *) (&s_rec.service_data8[0]));
- PARSE_AHEAD(p, net64, ":0x",
- (ib_net64_t *) (&s_rec.service_data8[8]));
- PARSE_AHEAD(p, net64, " data16=0x",
- (ib_net64_t *) (&s_rec.service_data16[0]));
- PARSE_AHEAD(p, net64, ":0x",
- (ib_net64_t *) (&s_rec.service_data16[4]));
- PARSE_AHEAD(p, net64, " data32=0x",
- (ib_net64_t *) (&s_rec.service_data32[0]));
- PARSE_AHEAD(p, net64, ":0x",
- (ib_net64_t *) (&s_rec.service_data32[2]));
- PARSE_AHEAD(p, net64, " data64=0x",
- &s_rec.service_data64[0]);
- PARSE_AHEAD(p, net64, ":0x", &s_rec.service_data64[1]);
- PARSE_AHEAD(p, net32, " modified_time=0x",
- &modified_time);
- PARSE_AHEAD(p, net32, " lease_period=0x",
- &lease_period);
-
- if (load_svcr(p_osm, &s_rec, cl_ntoh32(modified_time),
- cl_ntoh32(lease_period)))
- rereg_clients = 1;
- } else if (!strncmp(p, "InformInfo Record:", 18)) {
- ib_inform_info_record_t i_rec;
- osm_mad_addr_t rep_addr;
- ib_net16_t val16;
-
- p_mgrp = NULL;
- memset(&i_rec, 0, sizeof(i_rec));
- memset(&rep_addr, 0, sizeof(rep_addr));
-
- PARSE_AHEAD(p, net64, " subscriber_gid=0x",
- &i_rec.subscriber_gid.unicast.prefix);
- PARSE_AHEAD(p, net64, ":0x",
- &i_rec.subscriber_gid.unicast.interface_id);
- PARSE_AHEAD(p, net16, " subscriber_enum=0x",
- &i_rec.subscriber_enum);
- PARSE_AHEAD(p, net64, " gid=0x",
- &i_rec.inform_info.gid.unicast.prefix);
- PARSE_AHEAD(p, net64, ":0x",
- &i_rec.inform_info.gid.unicast.
- interface_id);
- PARSE_AHEAD(p, net16, " lid_range_begin=0x",
- &i_rec.inform_info.lid_range_begin);
- PARSE_AHEAD(p, net16, " lid_range_end=0x",
- &i_rec.inform_info.lid_range_end);
- PARSE_AHEAD(p, net8, " is_generic=0x",
- &i_rec.inform_info.is_generic);
- PARSE_AHEAD(p, net8, " subscribe=0x",
- &i_rec.inform_info.subscribe);
- PARSE_AHEAD(p, net16, " trap_type=0x",
- &i_rec.inform_info.trap_type);
- PARSE_AHEAD(p, net16, " trap_num=0x",
- &i_rec.inform_info.g_or_v.generic.trap_num);
- PARSE_AHEAD(p, net32, " qpn_resp_time_val=0x",
- &i_rec.inform_info.g_or_v.generic.
- qpn_resp_time_val);
- PARSE_AHEAD(p, net32, " node_type=0x",
- (uint32_t *) & i_rec.inform_info.g_or_v.
- generic.reserved2);
-
- PARSE_AHEAD(p, net16, " rep_addr: lid=0x",
- &rep_addr.dest_lid);
- PARSE_AHEAD(p, net8, " path_bits=0x",
- &rep_addr.path_bits);
- PARSE_AHEAD(p, net8, " static_rate=0x",
- &rep_addr.static_rate);
- PARSE_AHEAD(p, net32, " remote_qp=0x",
- &rep_addr.addr_type.gsi.remote_qp);
- PARSE_AHEAD(p, net32, " remote_qkey=0x",
- &rep_addr.addr_type.gsi.remote_qkey);
- PARSE_AHEAD(p, net16, " pkey_ix=0x", &val16);
- rep_addr.addr_type.gsi.pkey_ix = cl_ntoh16(val16);
- PARSE_AHEAD(p, net8, " sl=0x",
- &rep_addr.addr_type.gsi.service_level);
-
- if (load_infr(p_osm, &i_rec, &rep_addr))
- rereg_clients = 1;
- }
- }
-
- if (!rereg_clients)
- p_osm->subn.opt.no_clients_rereg = TRUE;
-
-_error:
- fclose(file);
- return ret;
-}
diff --git a/contrib/ofed/management/opensm/opensm/osm_sa_class_port_info.c b/contrib/ofed/management/opensm/opensm/osm_sa_class_port_info.c
deleted file mode 100644
index a3a2782..0000000
--- a/contrib/ofed/management/opensm/opensm/osm_sa_class_port_info.c
+++ /dev/null
@@ -1,213 +0,0 @@
-/*
- * Copyright (c) 2004-2008 Voltaire, Inc. All rights reserved.
- * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved.
- * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- */
-
-/*
- * Abstract:
- * Implementation of osm_cpi_rcv_t.
- * This object represents the ClassPortInfo Receiver object.
- * This object is part of the opensm family of objects.
- */
-
-#if HAVE_CONFIG_H
-# include <config.h>
-#endif /* HAVE_CONFIG_H */
-
-#include <string.h>
-#include <iba/ib_types.h>
-#include <complib/cl_qmap.h>
-#include <complib/cl_passivelock.h>
-#include <complib/cl_debug.h>
-#include <complib/cl_qlist.h>
-#include <vendor/osm_vendor_api.h>
-#include <opensm/osm_helper.h>
-#include <opensm/osm_sa.h>
-
-#define MAX_MSECS_TO_RTV 24
-/* Precalculated table in msec (index is related to encoded value) */
-/* 4.096 usec * 2 ** n (where n = 8 - 31) */
-const static uint32_t __msecs_to_rtv_table[MAX_MSECS_TO_RTV] = {
- 1, 2, 4, 8,
- 16, 33, 67, 134,
- 268, 536, 1073, 2147,
- 4294, 8589, 17179, 34359,
- 68719, 137438, 274877, 549755,
- 1099511, 2199023, 4398046, 8796093
-};
-
-/**********************************************************************
- **********************************************************************/
-static void
-__osm_cpi_rcv_respond(IN osm_sa_t * sa,
- IN const osm_madw_t * const p_madw)
-{
- osm_madw_t *p_resp_madw;
- const ib_sa_mad_t *p_sa_mad;
- ib_sa_mad_t *p_resp_sa_mad;
- ib_class_port_info_t *p_resp_cpi;
- ib_gid_t zero_gid;
- uint8_t rtv;
-
- OSM_LOG_ENTER(sa->p_log);
-
- memset(&zero_gid, 0, sizeof(ib_gid_t));
-
- /*
- Get a MAD to reply. Address of Mad is in the received mad_wrapper
- */
- p_resp_madw = osm_mad_pool_get(sa->p_mad_pool, p_madw->h_bind,
- MAD_BLOCK_SIZE, &p_madw->mad_addr);
- if (!p_resp_madw) {
- OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 1408: "
- "Unable to allocate MAD\n");
- goto Exit;
- }
-
- p_sa_mad = osm_madw_get_sa_mad_ptr(p_madw);
- p_resp_sa_mad = osm_madw_get_sa_mad_ptr(p_resp_madw);
-
- memcpy(p_resp_sa_mad, p_sa_mad, IB_SA_MAD_HDR_SIZE);
- p_resp_sa_mad->method |= IB_MAD_METHOD_RESP_MASK;
- /* C15-0.1.5 - always return SM_Key = 0 (table 185 p 884) */
- p_resp_sa_mad->sm_key = 0;
-
- p_resp_cpi =
- (ib_class_port_info_t *) ib_sa_mad_get_payload_ptr(p_resp_sa_mad);
-
- /* finally do it (the job) man ! */
- p_resp_cpi->base_ver = 1;
- p_resp_cpi->class_ver = 2;
- /* Calculate encoded response time value */
- /* transaction timeout is in msec */
- if (sa->p_subn->opt.transaction_timeout >
- __msecs_to_rtv_table[MAX_MSECS_TO_RTV - 1])
- rtv = MAX_MSECS_TO_RTV - 1;
- else {
- for (rtv = 0; rtv < MAX_MSECS_TO_RTV; rtv++) {
- if (sa->p_subn->opt.transaction_timeout <=
- __msecs_to_rtv_table[rtv])
- break;
- }
- }
- rtv += 8;
- ib_class_set_resp_time_val(p_resp_cpi, rtv);
- p_resp_cpi->redir_gid = zero_gid;
- p_resp_cpi->redir_tc_sl_fl = 0;
- p_resp_cpi->redir_lid = 0;
- p_resp_cpi->redir_pkey = 0;
- p_resp_cpi->redir_qp = CL_NTOH32(1);
- p_resp_cpi->redir_qkey = IB_QP1_WELL_KNOWN_Q_KEY;
- p_resp_cpi->trap_gid = zero_gid;
- p_resp_cpi->trap_tc_sl_fl = 0;
- p_resp_cpi->trap_lid = 0;
- p_resp_cpi->trap_pkey = 0;
- p_resp_cpi->trap_hop_qp = 0;
- p_resp_cpi->trap_qkey = IB_QP1_WELL_KNOWN_Q_KEY;
-
- /* set specific capability mask bits */
- /* we do not support the following options/optional records:
- OSM_CAP_IS_SUBN_OPT_RECS_SUP :
- RandomForwardingTableRecord,
- ServiceAssociationRecord
- other optional records supported "under the table"
-
- OSM_CAP_IS_MULTIPATH_SUP:
- TraceRecord
-
- OSM_CAP_IS_REINIT_SUP:
- For reinitialization functionality.
-
- So not sending traps, but supporting Get(Notice) and Set(Notice).
- */
-
- /* Note host notation replaced later */
-#if defined (VENDOR_RMPP_SUPPORT) && defined (DUAL_SIDED_RMPP)
- p_resp_cpi->cap_mask = OSM_CAP_IS_SUBN_GET_SET_NOTICE_SUP |
- OSM_CAP_IS_PORT_INFO_CAPMASK_MATCH_SUPPORTED |
- OSM_CAP_IS_MULTIPATH_SUP;
-#else
- p_resp_cpi->cap_mask = OSM_CAP_IS_SUBN_GET_SET_NOTICE_SUP |
- OSM_CAP_IS_PORT_INFO_CAPMASK_MATCH_SUPPORTED;
-#endif
- if (sa->p_subn->opt.qos)
- ib_class_set_cap_mask2(p_resp_cpi, OSM_CAP2_IS_QOS_SUPPORTED);
-
- if (!sa->p_subn->opt.disable_multicast)
- p_resp_cpi->cap_mask |= OSM_CAP_IS_UD_MCAST_SUP;
- p_resp_cpi->cap_mask = cl_hton16(p_resp_cpi->cap_mask);
-
- if (osm_log_is_active(sa->p_log, OSM_LOG_FRAMES))
- osm_dump_sa_mad(sa->p_log, p_resp_sa_mad, OSM_LOG_FRAMES);
-
- osm_sa_send(sa, p_resp_madw, FALSE);
-
-Exit:
- OSM_LOG_EXIT(sa->p_log);
-}
-
-/**********************************************************************
- * This code actually handles the call
- **********************************************************************/
-void osm_cpi_rcv_process(IN void *context, IN void *data)
-{
- osm_sa_t *sa = context;
- osm_madw_t *p_madw = data;
- const ib_sa_mad_t *p_sa_mad;
-
- OSM_LOG_ENTER(sa->p_log);
-
- CL_ASSERT(p_madw);
-
- p_sa_mad = osm_madw_get_sa_mad_ptr(p_madw);
-
- /* we only support GET */
- if (p_sa_mad->method != IB_MAD_METHOD_GET) {
- OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 1403: "
- "Unsupported Method (%s)\n",
- ib_get_sa_method_str(p_sa_mad->method));
- osm_sa_send_error(sa, p_madw, IB_SA_MAD_STATUS_REQ_INVALID);
- goto Exit;
- }
-
- CL_ASSERT(p_sa_mad->attr_id == IB_MAD_ATTR_CLASS_PORT_INFO);
-
- /*
- CLASS PORT INFO does not really look on the SMDB - no lock required.
- */
-
- __osm_cpi_rcv_respond(sa, p_madw);
-
-Exit:
- OSM_LOG_EXIT(sa->p_log);
-}
diff --git a/contrib/ofed/management/opensm/opensm/osm_sa_guidinfo_record.c b/contrib/ofed/management/opensm/opensm/osm_sa_guidinfo_record.c
deleted file mode 100644
index 39dae72..0000000
--- a/contrib/ofed/management/opensm/opensm/osm_sa_guidinfo_record.c
+++ /dev/null
@@ -1,362 +0,0 @@
-/*
- * Copyright (c) 2006-2008 Voltaire, Inc. All rights reserved.
- * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved.
- * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- */
-
-/*
- * Abstract:
- * Implementation of osm_gir_rcv_t.
- * This object represents the GUIDInfoRecord Receiver object.
- * This object is part of the opensm family of objects.
- */
-
-#if HAVE_CONFIG_H
-# include <config.h>
-#endif /* HAVE_CONFIG_H */
-
-#include <string.h>
-#include <iba/ib_types.h>
-#include <complib/cl_qmap.h>
-#include <complib/cl_passivelock.h>
-#include <complib/cl_debug.h>
-#include <complib/cl_qlist.h>
-#include <vendor/osm_vendor_api.h>
-#include <opensm/osm_port.h>
-#include <opensm/osm_node.h>
-#include <opensm/osm_helper.h>
-#include <opensm/osm_pkey.h>
-#include <opensm/osm_sa.h>
-
-typedef struct osm_gir_item {
- cl_list_item_t list_item;
- ib_guidinfo_record_t rec;
-} osm_gir_item_t;
-
-typedef struct osm_gir_search_ctxt {
- const ib_guidinfo_record_t *p_rcvd_rec;
- ib_net64_t comp_mask;
- cl_qlist_t *p_list;
- osm_sa_t *sa;
- const osm_physp_t *p_req_physp;
-} osm_gir_search_ctxt_t;
-
-/**********************************************************************
- **********************************************************************/
-static ib_api_status_t
-__osm_gir_rcv_new_gir(IN osm_sa_t * sa,
- IN const osm_node_t * const p_node,
- IN cl_qlist_t * const p_list,
- IN ib_net64_t const match_port_guid,
- IN ib_net16_t const match_lid,
- IN const osm_physp_t * const p_req_physp,
- IN uint8_t const block_num)
-{
- osm_gir_item_t *p_rec_item;
- ib_api_status_t status = IB_SUCCESS;
-
- OSM_LOG_ENTER(sa->p_log);
-
- p_rec_item = malloc(sizeof(*p_rec_item));
- if (p_rec_item == NULL) {
- OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 5102: "
- "rec_item alloc failed\n");
- status = IB_INSUFFICIENT_RESOURCES;
- goto Exit;
- }
-
- OSM_LOG(sa->p_log, OSM_LOG_DEBUG,
- "New GUIDInfoRecord: lid %u, block num %d\n",
- cl_ntoh16(match_lid), block_num);
-
- memset(p_rec_item, 0, sizeof(*p_rec_item));
-
- p_rec_item->rec.lid = match_lid;
- p_rec_item->rec.block_num = block_num;
- if (!block_num)
- p_rec_item->rec.guid_info.guid[0] =
- osm_physp_get_port_guid(p_req_physp);
-
- cl_qlist_insert_tail(p_list, &p_rec_item->list_item);
-
-Exit:
- OSM_LOG_EXIT(sa->p_log);
- return (status);
-}
-
-/**********************************************************************
- **********************************************************************/
-static void
-__osm_sa_gir_create_gir(IN osm_sa_t * sa,
- IN osm_node_t * const p_node,
- IN cl_qlist_t * const p_list,
- IN ib_net64_t const match_port_guid,
- IN ib_net16_t const match_lid,
- IN const osm_physp_t * const p_req_physp,
- IN uint8_t const match_block_num)
-{
- const osm_physp_t *p_physp;
- uint8_t port_num;
- uint8_t num_ports;
- uint16_t match_lid_ho;
- ib_net16_t base_lid_ho;
- ib_net16_t max_lid_ho;
- uint8_t lmc;
- ib_net64_t port_guid;
- uint8_t block_num, start_block_num, end_block_num, num_blocks;
-
- OSM_LOG_ENTER(sa->p_log);
-
- OSM_LOG(sa->p_log, OSM_LOG_DEBUG,
- "Looking for GUIDRecord with LID: %u GUID:0x%016"
- PRIx64 "\n", cl_ntoh16(match_lid), cl_ntoh64(match_port_guid));
-
- /*
- For switches, do not return the GUIDInfo record(s)
- for each port on the switch, just for port 0.
- */
- if (osm_node_get_type(p_node) == IB_NODE_TYPE_SWITCH)
- num_ports = 1;
- else
- num_ports = osm_node_get_num_physp(p_node);
-
- for (port_num = 0; port_num < num_ports; port_num++) {
- p_physp = osm_node_get_physp_ptr(p_node, port_num);
- if (!p_physp)
- continue;
-
- /* Check to see if the found p_physp and the requester physp
- share a pkey. If not, continue */
- if (!osm_physp_share_pkey(sa->p_log, p_physp, p_req_physp))
- continue;
-
- port_guid = osm_physp_get_port_guid(p_physp);
-
- if (match_port_guid && (port_guid != match_port_guid))
- continue;
-
- /*
- Note: the following check is a temporary workaround
- Since 1. GUIDCap should never be 0 on ports where this applies
- and 2. GUIDCap should not be used on ports where it doesn't apply
- So this should really be a check for whether the port is a
- switch external port or not!
- */
- if (p_physp->port_info.guid_cap == 0)
- continue;
-
- num_blocks = p_physp->port_info.guid_cap / 8;
- if (p_physp->port_info.guid_cap % 8)
- num_blocks++;
- if (match_block_num == 255) {
- start_block_num = 0;
- end_block_num = num_blocks - 1;
- } else {
- if (match_block_num >= num_blocks)
- continue;
- end_block_num = start_block_num = match_block_num;
- }
-
- base_lid_ho = cl_ntoh16(osm_physp_get_base_lid(p_physp));
- match_lid_ho = cl_ntoh16(match_lid);
- if (match_lid_ho) {
- lmc = osm_physp_get_lmc(p_physp);
- max_lid_ho = (uint16_t) (base_lid_ho + (1 << lmc) - 1);
-
- /*
- We validate that the lid belongs to this node.
- */
- OSM_LOG(sa->p_log, OSM_LOG_DEBUG,
- "Comparing LID: %u <= %u <= %u\n",
- base_lid_ho, match_lid_ho, max_lid_ho);
-
- if (match_lid_ho < base_lid_ho
- || match_lid_ho > max_lid_ho)
- continue;
- }
-
- for (block_num = start_block_num; block_num <= end_block_num;
- block_num++)
- __osm_gir_rcv_new_gir(sa, p_node, p_list, port_guid,
- cl_ntoh16(base_lid_ho), p_physp,
- block_num);
-
- }
-
- OSM_LOG_EXIT(sa->p_log);
-}
-
-/**********************************************************************
- **********************************************************************/
-static void
-__osm_sa_gir_by_comp_mask_cb(IN cl_map_item_t * const p_map_item,
- IN void *context)
-{
- const osm_gir_search_ctxt_t *const p_ctxt =
- (osm_gir_search_ctxt_t *) context;
- osm_node_t *const p_node = (osm_node_t *) p_map_item;
- const ib_guidinfo_record_t *const p_rcvd_rec = p_ctxt->p_rcvd_rec;
- const osm_physp_t *const p_req_physp = p_ctxt->p_req_physp;
- osm_sa_t *sa = p_ctxt->sa;
- const ib_guid_info_t *p_comp_gi;
- ib_net64_t const comp_mask = p_ctxt->comp_mask;
- ib_net64_t match_port_guid = 0;
- ib_net16_t match_lid = 0;
- uint8_t match_block_num = 255;
-
- OSM_LOG_ENTER(p_ctxt->sa->p_log);
-
- if (comp_mask & IB_GIR_COMPMASK_LID)
- match_lid = p_rcvd_rec->lid;
-
- if (comp_mask & IB_GIR_COMPMASK_BLOCKNUM)
- match_block_num = p_rcvd_rec->block_num;
-
- p_comp_gi = &p_rcvd_rec->guid_info;
- /* Different rule for block 0 v. other blocks */
- if (comp_mask & IB_GIR_COMPMASK_GID0) {
- if (!p_rcvd_rec->block_num)
- match_port_guid = osm_physp_get_port_guid(p_req_physp);
- if (p_comp_gi->guid[0] != match_port_guid)
- goto Exit;
- }
-
- if (comp_mask & IB_GIR_COMPMASK_GID1) {
- if (p_comp_gi->guid[1] != 0)
- goto Exit;
- }
-
- if (comp_mask & IB_GIR_COMPMASK_GID2) {
- if (p_comp_gi->guid[2] != 0)
- goto Exit;
- }
-
- if (comp_mask & IB_GIR_COMPMASK_GID3) {
- if (p_comp_gi->guid[3] != 0)
- goto Exit;
- }
-
- if (comp_mask & IB_GIR_COMPMASK_GID4) {
- if (p_comp_gi->guid[4] != 0)
- goto Exit;
- }
-
- if (comp_mask & IB_GIR_COMPMASK_GID5) {
- if (p_comp_gi->guid[5] != 0)
- goto Exit;
- }
-
- if (comp_mask & IB_GIR_COMPMASK_GID6) {
- if (p_comp_gi->guid[6] != 0)
- goto Exit;
- }
-
- if (comp_mask & IB_GIR_COMPMASK_GID7) {
- if (p_comp_gi->guid[7] != 0)
- goto Exit;
- }
-
- __osm_sa_gir_create_gir(sa, p_node, p_ctxt->p_list,
- match_port_guid, match_lid, p_req_physp,
- match_block_num);
-
-Exit:
- OSM_LOG_EXIT(p_ctxt->sa->p_log);
-}
-
-/**********************************************************************
- **********************************************************************/
-void osm_gir_rcv_process(IN void *ctx, IN void *data)
-{
- osm_sa_t *sa = ctx;
- osm_madw_t *p_madw = data;
- const ib_sa_mad_t *p_rcvd_mad;
- const ib_guidinfo_record_t *p_rcvd_rec;
- cl_qlist_t rec_list;
- osm_gir_search_ctxt_t context;
- osm_physp_t *p_req_physp;
-
- CL_ASSERT(sa);
-
- OSM_LOG_ENTER(sa->p_log);
-
- CL_ASSERT(p_madw);
-
- p_rcvd_mad = osm_madw_get_sa_mad_ptr(p_madw);
- p_rcvd_rec =
- (ib_guidinfo_record_t *) ib_sa_mad_get_payload_ptr(p_rcvd_mad);
-
- CL_ASSERT(p_rcvd_mad->attr_id == IB_MAD_ATTR_GUIDINFO_RECORD);
-
- /* we only support SubnAdmGet and SubnAdmGetTable methods */
- if (p_rcvd_mad->method != IB_MAD_METHOD_GET &&
- p_rcvd_mad->method != IB_MAD_METHOD_GETTABLE) {
- OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 5105: "
- "Unsupported Method (%s)\n",
- ib_get_sa_method_str(p_rcvd_mad->method));
- osm_sa_send_error(sa, p_madw, IB_MAD_STATUS_UNSUP_METHOD_ATTR);
- goto Exit;
- }
-
- /* update the requester physical port. */
- p_req_physp = osm_get_physp_by_mad_addr(sa->p_log, sa->p_subn,
- osm_madw_get_mad_addr_ptr
- (p_madw));
- if (p_req_physp == NULL) {
- OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 5104: "
- "Cannot find requester physical port\n");
- goto Exit;
- }
-
- if (osm_log_is_active(sa->p_log, OSM_LOG_DEBUG))
- osm_dump_guidinfo_record(sa->p_log, p_rcvd_rec, OSM_LOG_DEBUG);
-
- cl_qlist_init(&rec_list);
-
- context.p_rcvd_rec = p_rcvd_rec;
- context.p_list = &rec_list;
- context.comp_mask = p_rcvd_mad->comp_mask;
- context.sa = sa;
- context.p_req_physp = p_req_physp;
-
- cl_plock_acquire(sa->p_lock);
-
- cl_qmap_apply_func(&sa->p_subn->node_guid_tbl,
- __osm_sa_gir_by_comp_mask_cb, &context);
-
- cl_plock_release(sa->p_lock);
-
- osm_sa_respond(sa, p_madw, sizeof(ib_guidinfo_record_t), &rec_list);
-
-Exit:
- OSM_LOG_EXIT(sa->p_log);
-}
diff --git a/contrib/ofed/management/opensm/opensm/osm_sa_informinfo.c b/contrib/ofed/management/opensm/opensm/osm_sa_informinfo.c
deleted file mode 100644
index a48b546..0000000
--- a/contrib/ofed/management/opensm/opensm/osm_sa_informinfo.c
+++ /dev/null
@@ -1,626 +0,0 @@
-/*
- * Copyright (c) 2004-2008 Voltaire, Inc. All rights reserved.
- * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved.
- * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- */
-
-/*
- * Abstract:
- * Implementation of osm_infr_rcv_t.
- * This object represents the InformInfo Receiver object.
- * This object is part of the opensm family of objects.
- */
-
-#if HAVE_CONFIG_H
-# include <config.h>
-#endif /* HAVE_CONFIG_H */
-
-#include <string.h>
-#include <iba/ib_types.h>
-#include <arpa/inet.h>
-#include <complib/cl_qmap.h>
-#include <complib/cl_passivelock.h>
-#include <complib/cl_debug.h>
-#include <complib/cl_qlist.h>
-#include <vendor/osm_vendor_api.h>
-#include <opensm/osm_port.h>
-#include <opensm/osm_node.h>
-#include <opensm/osm_switch.h>
-#include <opensm/osm_helper.h>
-#include <opensm/osm_sa.h>
-#include <opensm/osm_inform.h>
-#include <opensm/osm_pkey.h>
-
-#include <sys/socket.h>
-
-typedef struct osm_iir_item {
- cl_list_item_t list_item;
- ib_inform_info_record_t rec;
-} osm_iir_item_t;
-
-typedef struct osm_iir_search_ctxt {
- const ib_inform_info_record_t *p_rcvd_rec;
- ib_net64_t comp_mask;
- cl_qlist_t *p_list;
- ib_gid_t subscriber_gid;
- ib_net16_t subscriber_enum;
- osm_sa_t *sa;
- osm_physp_t *p_req_physp;
-} osm_iir_search_ctxt_t;
-
-/**********************************************************************
-o13-14.1.1: Except for Set(InformInfo) requests with Inform-
-Info:LIDRangeBegin=0xFFFF, managers that support event forwarding
-shall, upon receiving a Set(InformInfo), verify that the requester
-originating the Set(InformInfo) and a Trap() source identified by Inform-
-can access each other - can use path record to verify that.
-**********************************************************************/
-static boolean_t
-__validate_ports_access_rights(IN osm_sa_t * sa,
- IN osm_infr_t * p_infr_rec)
-{
- boolean_t valid = TRUE;
- osm_physp_t *p_requester_physp;
- osm_port_t *p_port;
- osm_physp_t *p_physp;
- ib_net64_t portguid;
- ib_net16_t lid_range_begin;
- ib_net16_t lid_range_end;
- ib_net16_t lid;
- const cl_ptr_vector_t *p_tbl;
- ib_gid_t zero_gid;
-
- OSM_LOG_ENTER(sa->p_log);
-
- /* get the requester physp from the request address */
- p_requester_physp = osm_get_physp_by_mad_addr(sa->p_log, sa->p_subn,
- &p_infr_rec->report_addr);
-
- memset(&zero_gid, 0, sizeof(zero_gid));
- if (memcmp(&(p_infr_rec->inform_record.inform_info.gid),
- &zero_gid, sizeof(ib_gid_t))) {
- /* a gid is defined */
- portguid =
- p_infr_rec->inform_record.inform_info.gid.unicast.
- interface_id;
-
- p_port = osm_get_port_by_guid(sa->p_subn, portguid);
-
- if (p_port == NULL) {
- OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 4301: "
- "Invalid port guid: 0x%016" PRIx64 "\n",
- cl_ntoh64(portguid));
- valid = FALSE;
- goto Exit;
- }
-
- /* get the destination InformInfo physical port */
- p_physp = p_port->p_physp;
-
- /* make sure that the requester and destination port can access each other
- according to the current partitioning. */
- if (!osm_physp_share_pkey
- (sa->p_log, p_physp, p_requester_physp)) {
- OSM_LOG(sa->p_log, OSM_LOG_DEBUG,
- "port and requester don't share pkey\n");
- valid = FALSE;
- goto Exit;
- }
- } else {
- /* gid is zero - check if LID range is defined */
- lid_range_begin =
- cl_ntoh16(p_infr_rec->inform_record.inform_info.
- lid_range_begin);
- /* if lid is 0xFFFF - meaning all endports managed by the manager */
- if (lid_range_begin == 0xFFFF)
- goto Exit;
-
- lid_range_end =
- cl_ntoh16(p_infr_rec->inform_record.inform_info.
- lid_range_end);
-
- /* lid_range_end is set to zero if no range desired. In this case -
- just make it equal to the lid_range_begin. */
- if (lid_range_end == 0)
- lid_range_end = lid_range_begin;
-
- /* go over all defined lids within the range and make sure that the
- requester port can access them according to current partitioning. */
- for (lid = lid_range_begin; lid <= lid_range_end; lid++) {
- p_tbl = &sa->p_subn->port_lid_tbl;
- if (cl_ptr_vector_get_size(p_tbl) > lid)
- p_port = cl_ptr_vector_get(p_tbl, lid);
- else {
- /* lid requested is out of range */
- OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 4302: "
- "Given LID (%u) is out of range:%u\n",
- lid, cl_ptr_vector_get_size(p_tbl));
- valid = FALSE;
- goto Exit;
- }
- if (p_port == NULL)
- continue;
-
- p_physp = p_port->p_physp;
- /* make sure that the requester and destination port can access
- each other according to the current partitioning. */
- if (!osm_physp_share_pkey
- (sa->p_log, p_physp, p_requester_physp)) {
- OSM_LOG(sa->p_log, OSM_LOG_DEBUG,
- "port and requester don't share pkey\n");
- valid = FALSE;
- goto Exit;
- }
- }
- }
-
-Exit:
- OSM_LOG_EXIT(sa->p_log);
- return valid;
-}
-
-/**********************************************************************
- **********************************************************************/
-static boolean_t
-__validate_infr(IN osm_sa_t * sa, IN osm_infr_t * p_infr_rec)
-{
- boolean_t valid = TRUE;
-
- OSM_LOG_ENTER(sa->p_log);
-
- valid = __validate_ports_access_rights(sa, p_infr_rec);
- if (!valid) {
- OSM_LOG(sa->p_log, OSM_LOG_DEBUG,
- "Invalid Access for InformInfo\n");
- valid = FALSE;
- }
-
- OSM_LOG_EXIT(sa->p_log);
- return valid;
-}
-
-/**********************************************************************
-o13-12.1.1: Confirm a valid request for event subscription by responding
-with an InformInfo attribute that is a copy of the data in the
-Set(InformInfo) request.
-**********************************************************************/
-static void
-__osm_infr_rcv_respond(IN osm_sa_t * sa,
- IN osm_madw_t * const p_madw)
-{
- cl_qlist_t rec_list;
- osm_iir_item_t *item;
-
- OSM_LOG_ENTER(sa->p_log);
-
- OSM_LOG(sa->p_log, OSM_LOG_DEBUG,
- "Generating successful InformInfo response\n");
-
- item = malloc(sizeof(*item));
- if (!item) {
- OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 4303: "
- "rec_item alloc failed\n");
- goto Exit;
- }
-
- memcpy(&item->rec,
- ib_sa_mad_get_payload_ptr(osm_madw_get_sa_mad_ptr(p_madw)),
- sizeof(item->rec));
-
- cl_qlist_init(&rec_list);
- cl_qlist_insert_tail(&rec_list, &item->list_item);
-
- osm_sa_respond(sa, p_madw, sizeof(ib_inform_info_t), &rec_list);
-
-Exit:
- OSM_LOG_EXIT(sa->p_log);
-}
-
-/**********************************************************************
- **********************************************************************/
-static void
-__osm_sa_inform_info_rec_by_comp_mask(IN osm_sa_t * sa,
- IN const osm_infr_t * const p_infr,
- osm_iir_search_ctxt_t * const p_ctxt)
-{
- const ib_inform_info_record_t *p_rcvd_rec = NULL;
- ib_net64_t comp_mask;
- ib_net64_t portguid;
- osm_port_t *p_subscriber_port;
- osm_physp_t *p_subscriber_physp;
- const osm_physp_t *p_req_physp;
- osm_iir_item_t *p_rec_item;
-
- OSM_LOG_ENTER(sa->p_log);
-
- p_rcvd_rec = p_ctxt->p_rcvd_rec;
- comp_mask = p_ctxt->comp_mask;
- p_req_physp = p_ctxt->p_req_physp;
-
- if (comp_mask & IB_IIR_COMPMASK_SUBSCRIBERGID &&
- memcmp(&p_infr->inform_record.subscriber_gid,
- &p_ctxt->subscriber_gid,
- sizeof(p_infr->inform_record.subscriber_gid)))
- goto Exit;
-
- if (comp_mask & IB_IIR_COMPMASK_ENUM &&
- p_infr->inform_record.subscriber_enum != p_ctxt->subscriber_enum)
- goto Exit;
-
- /* Implement any other needed search cases */
-
- /* Ensure pkey is shared before returning any records */
- portguid = p_infr->inform_record.subscriber_gid.unicast.interface_id;
- p_subscriber_port = osm_get_port_by_guid(sa->p_subn, portguid);
- if (p_subscriber_port == NULL) {
- OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 430D: "
- "Invalid subscriber port guid: 0x%016" PRIx64 "\n",
- cl_ntoh64(portguid));
- goto Exit;
- }
-
- /* get the subscriber InformInfo physical port */
- p_subscriber_physp = p_subscriber_port->p_physp;
- /* make sure that the requester and subscriber port can access each other
- according to the current partitioning. */
- if (!osm_physp_share_pkey
- (sa->p_log, p_req_physp, p_subscriber_physp)) {
- OSM_LOG(sa->p_log, OSM_LOG_DEBUG,
- "requester and subscriber ports don't share pkey\n");
- goto Exit;
- }
-
- p_rec_item = malloc(sizeof(*p_rec_item));
- if (p_rec_item == NULL) {
- OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 430E: "
- "rec_item alloc failed\n");
- goto Exit;
- }
-
- memcpy((void *)&p_rec_item->rec, (void *)&p_infr->inform_record,
- sizeof(ib_inform_info_record_t));
- cl_qlist_insert_tail(p_ctxt->p_list, &p_rec_item->list_item);
-
-Exit:
- OSM_LOG_EXIT(sa->p_log);
-}
-
-/**********************************************************************
- **********************************************************************/
-static void
-__osm_sa_inform_info_rec_by_comp_mask_cb(IN cl_list_item_t * const p_list_item,
- IN void *context)
-{
- const osm_infr_t *const p_infr = (osm_infr_t *) p_list_item;
- osm_iir_search_ctxt_t *const p_ctxt = (osm_iir_search_ctxt_t *) context;
-
- __osm_sa_inform_info_rec_by_comp_mask(p_ctxt->sa, p_infr, p_ctxt);
-}
-
-/**********************************************************************
-Received a Get(InformInfoRecord) or GetTable(InformInfoRecord) MAD
-**********************************************************************/
-static void
-osm_infr_rcv_process_get_method(IN osm_sa_t * sa,
- IN osm_madw_t * const p_madw)
-{
- char gid_str[INET6_ADDRSTRLEN];
- ib_sa_mad_t *p_rcvd_mad;
- const ib_inform_info_record_t *p_rcvd_rec;
- cl_qlist_t rec_list;
- osm_iir_search_ctxt_t context;
- osm_physp_t *p_req_physp;
- osm_iir_item_t *item;
-
- OSM_LOG_ENTER(sa->p_log);
-
- CL_ASSERT(p_madw);
- p_rcvd_mad = osm_madw_get_sa_mad_ptr(p_madw);
- p_rcvd_rec =
- (ib_inform_info_record_t *) ib_sa_mad_get_payload_ptr(p_rcvd_mad);
-
- /* update the requester physical port. */
- p_req_physp = osm_get_physp_by_mad_addr(sa->p_log, sa->p_subn,
- osm_madw_get_mad_addr_ptr
- (p_madw));
- if (p_req_physp == NULL) {
- OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 4309: "
- "Cannot find requester physical port\n");
- goto Exit;
- }
-
- if (osm_log_is_active(sa->p_log, OSM_LOG_DEBUG))
- osm_dump_inform_info_record(sa->p_log, p_rcvd_rec,
- OSM_LOG_DEBUG);
-
- cl_qlist_init(&rec_list);
-
- context.p_rcvd_rec = p_rcvd_rec;
- context.p_list = &rec_list;
- context.comp_mask = p_rcvd_mad->comp_mask;
- context.subscriber_gid = p_rcvd_rec->subscriber_gid;
- context.subscriber_enum = p_rcvd_rec->subscriber_enum;
- context.sa = sa;
- context.p_req_physp = p_req_physp;
-
- OSM_LOG(sa->p_log, OSM_LOG_DEBUG,
- "Query Subscriber GID:%s(%02X) Enum:0x%X(%02X)\n",
- inet_ntop(AF_INET6, p_rcvd_rec->subscriber_gid.raw,
- gid_str, sizeof gid_str),
- (p_rcvd_mad->comp_mask & IB_IIR_COMPMASK_SUBSCRIBERGID) != 0,
- cl_ntoh16(p_rcvd_rec->subscriber_enum),
- (p_rcvd_mad->comp_mask & IB_IIR_COMPMASK_ENUM) != 0);
-
- cl_plock_acquire(sa->p_lock);
-
- cl_qlist_apply_func(&sa->p_subn->sa_infr_list,
- __osm_sa_inform_info_rec_by_comp_mask_cb, &context);
-
- cl_plock_release(sa->p_lock);
-
- /* clear reserved and pad fields in InformInfoRecord */
- for (item = (osm_iir_item_t *) cl_qlist_head(&rec_list);
- item != (osm_iir_item_t *) cl_qlist_end(&rec_list);
- item = (osm_iir_item_t *)cl_qlist_next(&item->list_item)) {
- memset(item->rec.reserved, 0, sizeof(item->rec.reserved));
- memset(item->rec.pad, 0, sizeof(item->rec.pad));
- }
-
- osm_sa_respond(sa, p_madw, sizeof(ib_inform_info_record_t), &rec_list);
-
-Exit:
- OSM_LOG_EXIT(sa->p_log);
-}
-
-/*********************************************************************
-Received a Set(InformInfo) MAD
-**********************************************************************/
-static void
-osm_infr_rcv_process_set_method(IN osm_sa_t * sa,
- IN osm_madw_t * const p_madw)
-{
- ib_sa_mad_t *p_sa_mad;
- ib_inform_info_t *p_recvd_inform_info;
- osm_infr_t inform_info_rec; /* actual inform record to be stored for reports */
- osm_infr_t *p_infr;
- ib_net32_t qpn;
- uint8_t resp_time_val;
- ib_api_status_t res;
-
- OSM_LOG_ENTER(sa->p_log);
-
- CL_ASSERT(p_madw);
-
- p_sa_mad = osm_madw_get_sa_mad_ptr(p_madw);
- p_recvd_inform_info =
- (ib_inform_info_t *) ib_sa_mad_get_payload_ptr(p_sa_mad);
-
-#if 0
- if (osm_log_is_active(sa->p_log, OSM_LOG_DEBUG))
- osm_dump_inform_info(sa->p_log, p_recvd_inform_info,
- OSM_LOG_DEBUG);
-#endif
-
- /* Grab the lock */
- cl_plock_excl_acquire(sa->p_lock);
-
- /* define the inform record */
- inform_info_rec.inform_record.inform_info = *p_recvd_inform_info;
-
- /* following C13-32.1.2 Tbl 120: we only copy the source address vector */
- inform_info_rec.report_addr = p_madw->mad_addr;
-
- /* we will need to know the mad srvc to send back through */
- inform_info_rec.h_bind = p_madw->h_bind;
- inform_info_rec.sa = sa;
-
- /* update the subscriber GID according to mad address */
- res = osm_get_gid_by_mad_addr(sa->p_log, sa->p_subn, &p_madw->mad_addr,
- &inform_info_rec.inform_record.
- subscriber_gid);
- if (res != IB_SUCCESS) {
- cl_plock_release(sa->p_lock);
-
- OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 4308 "
- "Subscribe Request from unknown LID: %u\n",
- cl_ntoh16(p_madw->mad_addr.dest_lid));
- osm_sa_send_error(sa, p_madw, IB_SA_MAD_STATUS_REQ_INVALID);
- goto Exit;
- }
-
- /* HACK: enum is always 0 (currently) */
- inform_info_rec.inform_record.subscriber_enum = 0;
-
- /* Subscribe values above 1 are undefined */
- if (p_recvd_inform_info->subscribe > 1) {
- cl_plock_release(sa->p_lock);
-
- OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 4308 "
- "Invalid subscribe: %d\n",
- p_recvd_inform_info->subscribe);
- osm_sa_send_error(sa, p_madw, IB_SA_MAD_STATUS_REQ_INVALID);
- goto Exit;
- }
-
- /*
- * MODIFICATIONS DONE ON INCOMING REQUEST:
- *
- * QPN:
- * Internally we keep the QPN field of the InformInfo updated
- * so we can simply compare it in the record - when finding such.
- */
- if (p_recvd_inform_info->subscribe) {
- ib_inform_info_set_qpn(&inform_info_rec.inform_record.
- inform_info,
- inform_info_rec.report_addr.addr_type.
- gsi.remote_qp);
-
- OSM_LOG(sa->p_log, OSM_LOG_DEBUG,
- "Subscribe Request with QPN: 0x%06X\n",
- cl_ntoh32(inform_info_rec.report_addr.addr_type.gsi.
- remote_qp));
- } else {
- ib_inform_info_get_qpn_resp_time(p_recvd_inform_info->g_or_v.
- generic.qpn_resp_time_val,
- &qpn, &resp_time_val);
-
- OSM_LOG(sa->p_log, OSM_LOG_DEBUG,
- "UnSubscribe Request with QPN: 0x%06X\n",
- cl_ntoh32(qpn));
- }
-
- /* If record exists with matching InformInfo */
- p_infr =
- osm_infr_get_by_rec(sa->p_subn, sa->p_log, &inform_info_rec);
-
- /* check to see if the request was for subscribe */
- if (p_recvd_inform_info->subscribe) {
- /* validate the request for a new or update InformInfo */
- if (__validate_infr(sa, &inform_info_rec) != TRUE) {
- cl_plock_release(sa->p_lock);
-
- OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 4305: "
- "Failed to validate a new inform object\n");
-
- /* o13-13.1.1: we need to set the subscribe bit to 0 */
- p_recvd_inform_info->subscribe = 0;
- osm_sa_send_error(sa, p_madw,
- IB_SA_MAD_STATUS_REQ_INVALID);
- goto Exit;
- }
-
- /* ok - we can try and create a new entry */
- if (p_infr == NULL) {
- /* Create the instance of the osm_infr_t object */
- p_infr = osm_infr_new(&inform_info_rec);
- if (p_infr == NULL) {
- cl_plock_release(sa->p_lock);
-
- OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 4306: "
- "Failed to create a new inform object\n");
-
- /* o13-13.1.1: we need to set the subscribe bit to 0 */
- p_recvd_inform_info->subscribe = 0;
- osm_sa_send_error(sa, p_madw,
- IB_SA_MAD_STATUS_NO_RESOURCES);
- goto Exit;
- }
-
- /* Add this new osm_infr_t object to subnet object */
- osm_infr_insert_to_db(sa->p_subn, sa->p_log, p_infr);
- } else
- /* Update the old instance of the osm_infr_t object */
- p_infr->inform_record = inform_info_rec.inform_record;
- /* We got an UnSubscribe request */
- } else if (p_infr == NULL) {
- cl_plock_release(sa->p_lock);
-
- /* No Such Item - So Error */
- OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 4307: "
- "Failed to UnSubscribe to non existing inform object\n");
-
- /* o13-13.1.1: we need to set the subscribe bit to 0 */
- p_recvd_inform_info->subscribe = 0;
- osm_sa_send_error(sa, p_madw, IB_SA_MAD_STATUS_REQ_INVALID);
- goto Exit;
- } else
- /* Delete this object from the subnet list of informs */
- osm_infr_remove_from_db(sa->p_subn, sa->p_log, p_infr);
-
- cl_plock_release(sa->p_lock);
-
- /* send the success response */
- __osm_infr_rcv_respond(sa, p_madw);
-
-Exit:
- OSM_LOG_EXIT(sa->p_log);
-}
-
-/*********************************************************************
-**********************************************************************/
-void osm_infr_rcv_process(IN void *context, IN void *data)
-{
- osm_sa_t *sa = context;
- osm_madw_t *p_madw = data;
- ib_sa_mad_t *p_sa_mad;
-
- OSM_LOG_ENTER(sa->p_log);
-
- CL_ASSERT(p_madw);
-
- p_sa_mad = osm_madw_get_sa_mad_ptr(p_madw);
-
- CL_ASSERT(p_sa_mad->attr_id == IB_MAD_ATTR_INFORM_INFO);
-
- if (p_sa_mad->method != IB_MAD_METHOD_SET) {
- OSM_LOG(sa->p_log, OSM_LOG_DEBUG,
- "Unsupported Method (%s)\n",
- ib_get_sa_method_str(p_sa_mad->method));
- osm_sa_send_error(sa, p_madw, IB_MAD_STATUS_UNSUP_METHOD_ATTR);
- goto Exit;
- }
-
- osm_infr_rcv_process_set_method(sa, p_madw);
-
-Exit:
- OSM_LOG_EXIT(sa->p_log);
-}
-
-/*********************************************************************
-**********************************************************************/
-void osm_infir_rcv_process(IN void *context, IN void *data)
-{
- osm_sa_t *sa = context;
- osm_madw_t *p_madw = data;
- ib_sa_mad_t *p_sa_mad;
-
- OSM_LOG_ENTER(sa->p_log);
-
- CL_ASSERT(p_madw);
-
- p_sa_mad = osm_madw_get_sa_mad_ptr(p_madw);
-
- CL_ASSERT(p_sa_mad->attr_id == IB_MAD_ATTR_INFORM_INFO_RECORD);
-
- if (p_sa_mad->method != IB_MAD_METHOD_GET &&
- p_sa_mad->method != IB_MAD_METHOD_GETTABLE) {
- OSM_LOG(sa->p_log, OSM_LOG_DEBUG, "Unsupported Method (%s)\n",
- ib_get_sa_method_str(p_sa_mad->method));
- osm_sa_send_error(sa, p_madw, IB_MAD_STATUS_UNSUP_METHOD_ATTR);
- goto Exit;
- }
-
- osm_infr_rcv_process_get_method(sa, p_madw);
-
-Exit:
- OSM_LOG_EXIT(sa->p_log);
-}
diff --git a/contrib/ofed/management/opensm/opensm/osm_sa_lft_record.c b/contrib/ofed/management/opensm/opensm/osm_sa_lft_record.c
deleted file mode 100644
index d84a6a5..0000000
--- a/contrib/ofed/management/opensm/opensm/osm_sa_lft_record.c
+++ /dev/null
@@ -1,246 +0,0 @@
-/*
- * Copyright (c) 2004-2008 Voltaire, Inc. All rights reserved.
- * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved.
- * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- */
-
-/*
- * Abstract:
- * Implementation of osm_lftr_rcv_t.
- * This object represents the LinearForwardingTable Receiver object.
- * This object is part of the opensm family of objects.
- */
-
-#if HAVE_CONFIG_H
-# include <config.h>
-#endif /* HAVE_CONFIG_H */
-
-#include <string.h>
-#include <iba/ib_types.h>
-#include <complib/cl_debug.h>
-#include <complib/cl_qlist.h>
-#include <vendor/osm_vendor_api.h>
-#include <opensm/osm_switch.h>
-#include <opensm/osm_helper.h>
-#include <opensm/osm_pkey.h>
-#include <opensm/osm_sa.h>
-
-typedef struct osm_lftr_item {
- cl_list_item_t list_item;
- ib_lft_record_t rec;
-} osm_lftr_item_t;
-
-typedef struct osm_lftr_search_ctxt {
- const ib_lft_record_t *p_rcvd_rec;
- ib_net64_t comp_mask;
- cl_qlist_t *p_list;
- osm_sa_t *sa;
- const osm_physp_t *p_req_physp;
-} osm_lftr_search_ctxt_t;
-
-/**********************************************************************
- **********************************************************************/
-static ib_api_status_t
-__osm_lftr_rcv_new_lftr(IN osm_sa_t * sa,
- IN const osm_switch_t * const p_sw,
- IN cl_qlist_t * const p_list,
- IN ib_net16_t const lid, IN uint16_t const block)
-{
- osm_lftr_item_t *p_rec_item;
- ib_api_status_t status = IB_SUCCESS;
-
- OSM_LOG_ENTER(sa->p_log);
-
- p_rec_item = malloc(sizeof(*p_rec_item));
- if (p_rec_item == NULL) {
- OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 4402: "
- "rec_item alloc failed\n");
- status = IB_INSUFFICIENT_RESOURCES;
- goto Exit;
- }
-
- OSM_LOG(sa->p_log, OSM_LOG_DEBUG,
- "New LinearForwardingTable: sw 0x%016" PRIx64
- "\n\t\t\t\tblock 0x%02X lid %u\n",
- cl_ntoh64(osm_node_get_node_guid(p_sw->p_node)),
- block, cl_ntoh16(lid));
-
- memset(p_rec_item, 0, sizeof(*p_rec_item));
-
- p_rec_item->rec.lid = lid;
- p_rec_item->rec.block_num = cl_hton16(block);
-
- /* copy the lft block */
- osm_switch_get_lft_block(p_sw, block, p_rec_item->rec.lft);
-
- cl_qlist_insert_tail(p_list, &p_rec_item->list_item);
-
-Exit:
- OSM_LOG_EXIT(sa->p_log);
- return (status);
-}
-
-/**********************************************************************
- **********************************************************************/
-static void
-__osm_lftr_rcv_by_comp_mask(IN cl_map_item_t * const p_map_item,
- IN void *context)
-{
- const osm_lftr_search_ctxt_t *const p_ctxt =
- (osm_lftr_search_ctxt_t *) context;
- const osm_switch_t *const p_sw = (osm_switch_t *) p_map_item;
- const ib_lft_record_t *const p_rcvd_rec = p_ctxt->p_rcvd_rec;
- osm_sa_t *sa = p_ctxt->sa;
- ib_net64_t const comp_mask = p_ctxt->comp_mask;
- const osm_physp_t *const p_req_physp = p_ctxt->p_req_physp;
- osm_port_t *p_port;
- uint16_t min_lid_ho, max_lid_ho;
- uint16_t min_block, max_block, block;
- const osm_physp_t *p_physp;
-
- /* In switches, the port guid is the node guid. */
- p_port = osm_get_port_by_guid(sa->p_subn,
- p_sw->p_node->node_info.port_guid);
- if (!p_port) {
- OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 4405: "
- "Failed to find Port by Node Guid:0x%016" PRIx64
- "\n", cl_ntoh64(p_sw->p_node->node_info.node_guid));
- return;
- }
-
- /* check that the requester physp and the current physp are under
- the same partition. */
- p_physp = p_port->p_physp;
- if (!p_physp) {
- OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 4406: "
- "Failed to find default physical Port by Node Guid:0x%016"
- PRIx64 "\n",
- cl_ntoh64(p_sw->p_node->node_info.node_guid));
- return;
- }
- if (!osm_physp_share_pkey(sa->p_log, p_req_physp, p_physp))
- return;
-
- /* get the port 0 of the switch */
- osm_port_get_lid_range_ho(p_port, &min_lid_ho, &max_lid_ho);
-
- /* compare the lids - if required */
- if (comp_mask & IB_LFTR_COMPMASK_LID) {
- OSM_LOG(sa->p_log, OSM_LOG_DEBUG,
- "Comparing lid:%u to port lid range: %u .. %u\n",
- cl_ntoh16(p_rcvd_rec->lid), min_lid_ho, max_lid_ho);
- /* ok we are ready for range check */
- if (min_lid_ho > cl_ntoh16(p_rcvd_rec->lid) ||
- max_lid_ho < cl_ntoh16(p_rcvd_rec->lid))
- return;
- }
-
- /* now we need to decide which blocks to output */
- max_block = osm_switch_get_max_block_id_in_use(p_sw);
- if (comp_mask & IB_LFTR_COMPMASK_BLOCK) {
- min_block = cl_ntoh16(p_rcvd_rec->block_num);
- if (min_block > max_block)
- return;
- max_block = min_block;
- } else /* use as many blocks as "in use" */
- min_block = 0;
-
- /* so we can add these blocks one by one ... */
- for (block = min_block; block <= max_block; block++)
- __osm_lftr_rcv_new_lftr(sa, p_sw, p_ctxt->p_list,
- osm_port_get_base_lid(p_port), block);
-}
-
-/**********************************************************************
- **********************************************************************/
-void osm_lftr_rcv_process(IN void *ctx, IN void *data)
-{
- osm_sa_t *sa = ctx;
- osm_madw_t *p_madw = data;
- const ib_sa_mad_t *p_rcvd_mad;
- const ib_lft_record_t *p_rcvd_rec;
- cl_qlist_t rec_list;
- osm_lftr_search_ctxt_t context;
- osm_physp_t *p_req_physp;
-
- CL_ASSERT(sa);
-
- OSM_LOG_ENTER(sa->p_log);
-
- CL_ASSERT(p_madw);
-
- p_rcvd_mad = osm_madw_get_sa_mad_ptr(p_madw);
- p_rcvd_rec = (ib_lft_record_t *) ib_sa_mad_get_payload_ptr(p_rcvd_mad);
-
- CL_ASSERT(p_rcvd_mad->attr_id == IB_MAD_ATTR_LFT_RECORD);
-
- /* we only support SubnAdmGet and SubnAdmGetTable methods */
- if (p_rcvd_mad->method != IB_MAD_METHOD_GET &&
- p_rcvd_mad->method != IB_MAD_METHOD_GETTABLE) {
- OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 4408: "
- "Unsupported Method (%s)\n",
- ib_get_sa_method_str(p_rcvd_mad->method));
- osm_sa_send_error(sa, p_madw, IB_MAD_STATUS_UNSUP_METHOD_ATTR);
- goto Exit;
- }
-
- /* update the requester physical port. */
- p_req_physp = osm_get_physp_by_mad_addr(sa->p_log, sa->p_subn,
- osm_madw_get_mad_addr_ptr
- (p_madw));
- if (p_req_physp == NULL) {
- OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 4407: "
- "Cannot find requester physical port\n");
- goto Exit;
- }
-
- cl_qlist_init(&rec_list);
-
- context.p_rcvd_rec = p_rcvd_rec;
- context.p_list = &rec_list;
- context.comp_mask = p_rcvd_mad->comp_mask;
- context.sa = sa;
- context.p_req_physp = p_req_physp;
-
- cl_plock_acquire(sa->p_lock);
-
- /* Go over all switches */
- cl_qmap_apply_func(&sa->p_subn->sw_guid_tbl,
- __osm_lftr_rcv_by_comp_mask, &context);
-
- cl_plock_release(sa->p_lock);
-
- osm_sa_respond(sa, p_madw, sizeof(ib_lft_record_t), &rec_list);
-
-Exit:
- OSM_LOG_EXIT(sa->p_log);
-}
diff --git a/contrib/ofed/management/opensm/opensm/osm_sa_link_record.c b/contrib/ofed/management/opensm/opensm/osm_sa_link_record.c
deleted file mode 100644
index b92845e..0000000
--- a/contrib/ofed/management/opensm/opensm/osm_sa_link_record.c
+++ /dev/null
@@ -1,505 +0,0 @@
-/*
- * Copyright (c) 2004-2008 Voltaire, Inc. All rights reserved.
- * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved.
- * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- */
-
-/*
- * Abstract:
- * Implementation of osm_lr_rcv_t.
- * This object represents the LinkRecord Receiver object.
- * This object is part of the opensm family of objects.
- */
-
-#if HAVE_CONFIG_H
-# include <config.h>
-#endif /* HAVE_CONFIG_H */
-
-#include <string.h>
-#include <iba/ib_types.h>
-#include <complib/cl_qmap.h>
-#include <complib/cl_debug.h>
-#include <vendor/osm_vendor_api.h>
-#include <opensm/osm_node.h>
-#include <opensm/osm_switch.h>
-#include <opensm/osm_helper.h>
-#include <opensm/osm_pkey.h>
-#include <opensm/osm_sa.h>
-
-typedef struct osm_lr_item {
- cl_list_item_t list_item;
- ib_link_record_t link_rec;
-} osm_lr_item_t;
-
-/**********************************************************************
- **********************************************************************/
-static void
-__osm_lr_rcv_build_physp_link(IN osm_sa_t * sa,
- IN const ib_net16_t from_lid,
- IN const ib_net16_t to_lid,
- IN const uint8_t from_port,
- IN const uint8_t to_port, IN cl_qlist_t * p_list)
-{
- osm_lr_item_t *p_lr_item;
-
- p_lr_item = malloc(sizeof(*p_lr_item));
- if (p_lr_item == NULL) {
- OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 1801: "
- "Unable to acquire link record\n"
- "\t\t\t\tFrom port %u\n"
- "\t\t\t\tTo port %u\n"
- "\t\t\t\tFrom lid %u\n"
- "\t\t\t\tTo lid %u\n",
- from_port, to_port,
- cl_ntoh16(from_lid), cl_ntoh16(to_lid));
- return;
- }
- memset(p_lr_item, 0, sizeof(*p_lr_item));
-
- p_lr_item->link_rec.from_port_num = from_port;
- p_lr_item->link_rec.to_port_num = to_port;
- p_lr_item->link_rec.to_lid = to_lid;
- p_lr_item->link_rec.from_lid = from_lid;
-
- cl_qlist_insert_tail(p_list, &p_lr_item->list_item);
-}
-
-/**********************************************************************
- **********************************************************************/
-static void
-__get_base_lid(IN const osm_physp_t * p_physp, OUT ib_net16_t * p_base_lid)
-{
- if (p_physp->p_node->node_info.node_type == IB_NODE_TYPE_SWITCH)
- *p_base_lid = osm_physp_get_base_lid
- (osm_node_get_physp_ptr(p_physp->p_node, 0));
- else
- *p_base_lid = osm_physp_get_base_lid(p_physp);
-}
-
-/**********************************************************************
- **********************************************************************/
-static void
-__osm_lr_rcv_get_physp_link(IN osm_sa_t * sa,
- IN const ib_link_record_t * const p_lr,
- IN const osm_physp_t * p_src_physp,
- IN const osm_physp_t * p_dest_physp,
- IN const ib_net64_t comp_mask,
- IN cl_qlist_t * const p_list,
- IN const osm_physp_t * p_req_physp)
-{
- uint8_t src_port_num;
- uint8_t dest_port_num;
- ib_net16_t from_base_lid;
- ib_net16_t to_base_lid;
- ib_net16_t lmc_mask;
-
- OSM_LOG_ENTER(sa->p_log);
-
- /*
- If only one end of the link is specified, determine
- the other side.
- */
- if (p_src_physp) {
- if (p_dest_physp) {
- /*
- Ensure the two physp's are actually connected.
- If not, bail out.
- */
- if (osm_physp_get_remote(p_src_physp) != p_dest_physp)
- goto Exit;
- } else {
- p_dest_physp = osm_physp_get_remote(p_src_physp);
- if (p_dest_physp == NULL)
- goto Exit;
- }
- } else {
- if (p_dest_physp) {
- p_src_physp = osm_physp_get_remote(p_dest_physp);
- if (p_src_physp == NULL)
- goto Exit;
- } else
- goto Exit; /* no physp's, so nothing to do */
- }
-
- /* Check that the p_src_physp, p_dest_physp and p_req_physp
- all share a pkey (doesn't have to be the same p_key). */
- if (!osm_physp_share_pkey(sa->p_log, p_src_physp, p_dest_physp)) {
- OSM_LOG(sa->p_log, OSM_LOG_DEBUG,
- "Source and Dest PhysPorts do not share PKey\n");
- goto Exit;
- }
- if (!osm_physp_share_pkey(sa->p_log, p_src_physp, p_req_physp)) {
- OSM_LOG(sa->p_log, OSM_LOG_DEBUG,
- "Source and Requester PhysPorts do not share PKey\n");
- goto Exit;
- }
- if (!osm_physp_share_pkey(sa->p_log, p_req_physp, p_dest_physp)) {
- OSM_LOG(sa->p_log, OSM_LOG_DEBUG,
- "Requester and Dest PhysPorts do not share PKey\n");
- goto Exit;
- }
-
- src_port_num = osm_physp_get_port_num(p_src_physp);
- dest_port_num = osm_physp_get_port_num(p_dest_physp);
-
- if (comp_mask & IB_LR_COMPMASK_FROM_PORT)
- if (src_port_num != p_lr->from_port_num)
- goto Exit;
-
- if (comp_mask & IB_LR_COMPMASK_TO_PORT)
- if (dest_port_num != p_lr->to_port_num)
- goto Exit;
-
- __get_base_lid(p_src_physp, &from_base_lid);
- __get_base_lid(p_dest_physp, &to_base_lid);
-
- lmc_mask = ~((1 << sa->p_subn->opt.lmc) - 1);
- lmc_mask = cl_hton16(lmc_mask);
-
- if (comp_mask & IB_LR_COMPMASK_FROM_LID)
- if (from_base_lid != (p_lr->from_lid & lmc_mask))
- goto Exit;
-
- if (comp_mask & IB_LR_COMPMASK_TO_LID)
- if (to_base_lid != (p_lr->to_lid & lmc_mask))
- goto Exit;
-
- OSM_LOG(sa->p_log, OSM_LOG_DEBUG, "Acquiring link record\n"
- "\t\t\t\tsrc port 0x%" PRIx64 " (port %u)"
- ", dest port 0x%" PRIx64 " (port %u)\n",
- cl_ntoh64(osm_physp_get_port_guid(p_src_physp)), src_port_num,
- cl_ntoh64(osm_physp_get_port_guid(p_dest_physp)),
- dest_port_num);
-
-
- __osm_lr_rcv_build_physp_link(sa, from_base_lid, to_base_lid,
- src_port_num, dest_port_num, p_list);
-
-Exit:
- OSM_LOG_EXIT(sa->p_log);
-}
-
-/**********************************************************************
- **********************************************************************/
-static void
-__osm_lr_rcv_get_port_links(IN osm_sa_t * sa,
- IN const ib_link_record_t * const p_lr,
- IN const osm_port_t * p_src_port,
- IN const osm_port_t * p_dest_port,
- IN const ib_net64_t comp_mask,
- IN cl_qlist_t * const p_list,
- IN const osm_physp_t * p_req_physp)
-{
- const osm_physp_t *p_src_physp;
- const osm_physp_t *p_dest_physp;
- const cl_qmap_t *p_node_tbl;
- osm_node_t * p_node;
- uint8_t port_num;
- uint8_t num_ports;
- uint8_t dest_num_ports;
- uint8_t dest_port_num;
-
- OSM_LOG_ENTER(sa->p_log);
-
- if (p_src_port) {
- if (p_dest_port) {
- /*
- Build an LR for every link connected between both ports.
- The inner function will discard physp combinations
- that do not actually connect. Don't bother screening
- for that here.
- */
- num_ports = osm_node_get_num_physp(p_src_port->p_node);
- dest_num_ports =
- osm_node_get_num_physp(p_dest_port->p_node);
- for (port_num = 1; port_num < num_ports; port_num++) {
- p_src_physp =
- osm_node_get_physp_ptr(p_src_port->p_node,
- port_num);
- for (dest_port_num = 1;
- dest_port_num < dest_num_ports;
- dest_port_num++) {
- p_dest_physp =
- osm_node_get_physp_ptr(p_dest_port->
- p_node,
- dest_port_num);
- /* both physical ports should be with data */
- if (p_src_physp && p_dest_physp)
- __osm_lr_rcv_get_physp_link
- (sa, p_lr, p_src_physp,
- p_dest_physp, comp_mask,
- p_list, p_req_physp);
- }
- }
- } else {
- /*
- Build an LR for every link connected from the source port.
- */
- if (comp_mask & IB_LR_COMPMASK_FROM_PORT) {
- port_num = p_lr->from_port_num;
- /* If the port number is out of the range of the p_src_port, then
- this couldn't be a relevant record. */
- if (port_num <
- p_src_port->p_node->physp_tbl_size) {
- p_src_physp =
- osm_node_get_physp_ptr(p_src_port->
- p_node,
- port_num);
- if (p_src_physp)
- __osm_lr_rcv_get_physp_link
- (sa, p_lr, p_src_physp,
- NULL, comp_mask, p_list,
- p_req_physp);
- }
- } else {
- num_ports =
- osm_node_get_num_physp(p_src_port->p_node);
- for (port_num = 1; port_num < num_ports;
- port_num++) {
- p_src_physp =
- osm_node_get_physp_ptr(p_src_port->
- p_node,
- port_num);
- if (p_src_physp)
- __osm_lr_rcv_get_physp_link
- (sa, p_lr, p_src_physp,
- NULL, comp_mask, p_list,
- p_req_physp);
- }
- }
- }
- } else {
- if (p_dest_port) {
- /*
- Build an LR for every link connected to the dest port.
- */
- if (comp_mask & IB_LR_COMPMASK_TO_PORT) {
- port_num = p_lr->to_port_num;
- /* If the port number is out of the range of the p_dest_port, then
- this couldn't be a relevant record. */
- if (port_num <
- p_dest_port->p_node->physp_tbl_size) {
- p_dest_physp =
- osm_node_get_physp_ptr(p_dest_port->
- p_node,
- port_num);
- if (p_dest_physp)
- __osm_lr_rcv_get_physp_link
- (sa, p_lr, NULL,
- p_dest_physp, comp_mask,
- p_list, p_req_physp);
- }
- } else {
- num_ports =
- osm_node_get_num_physp(p_dest_port->p_node);
- for (port_num = 1; port_num < num_ports;
- port_num++) {
- p_dest_physp =
- osm_node_get_physp_ptr(p_dest_port->
- p_node,
- port_num);
- if (p_dest_physp)
- __osm_lr_rcv_get_physp_link
- (sa, p_lr, NULL,
- p_dest_physp, comp_mask,
- p_list, p_req_physp);
- }
- }
- } else {
- /*
- Process the world (recurse once back into this function).
- */
- p_node_tbl = &sa->p_subn->node_guid_tbl;
- p_node = (osm_node_t *)cl_qmap_head(p_node_tbl);
-
- while (p_node != (osm_node_t *)cl_qmap_end(p_node_tbl)) {
- num_ports = osm_node_get_num_physp(p_node);
- for (port_num = 1; port_num < num_ports;
- port_num++) {
- p_src_physp =
- osm_node_get_physp_ptr(p_node,
- port_num);
- if (p_src_physp)
- __osm_lr_rcv_get_physp_link
- (sa, p_lr, p_src_physp,
- NULL, comp_mask, p_list,
- p_req_physp);
- }
- p_node = (osm_node_t *) cl_qmap_next(&p_node->
- map_item);
- }
- }
- }
-
- OSM_LOG_EXIT(sa->p_log);
-}
-
-/**********************************************************************
- Returns the SA status to return to the client.
- **********************************************************************/
-static ib_net16_t
-__osm_lr_rcv_get_end_points(IN osm_sa_t * sa,
- IN const osm_madw_t * const p_madw,
- OUT const osm_port_t ** const pp_src_port,
- OUT const osm_port_t ** const pp_dest_port)
-{
- const ib_link_record_t *p_lr;
- const ib_sa_mad_t *p_sa_mad;
- ib_net64_t comp_mask;
- ib_api_status_t status;
- ib_net16_t sa_status = IB_SA_MAD_STATUS_SUCCESS;
-
- OSM_LOG_ENTER(sa->p_log);
-
- /*
- Determine what fields are valid and then get a pointer
- to the source and destination port objects, if possible.
- */
- p_sa_mad = osm_madw_get_sa_mad_ptr(p_madw);
- p_lr = (ib_link_record_t *) ib_sa_mad_get_payload_ptr(p_sa_mad);
-
- comp_mask = p_sa_mad->comp_mask;
- *pp_src_port = NULL;
- *pp_dest_port = NULL;
-
- if (p_sa_mad->comp_mask & IB_LR_COMPMASK_FROM_LID) {
- status = osm_get_port_by_base_lid(sa->p_subn,
- p_lr->from_lid, pp_src_port);
-
- if ((status != IB_SUCCESS) || (*pp_src_port == NULL)) {
- /*
- This 'error' is the client's fault (bad lid) so
- don't enter it as an error in our own log.
- Return an error response to the client.
- */
- OSM_LOG(sa->p_log, OSM_LOG_VERBOSE,
- "No source port with LID %u\n",
- cl_ntoh16(p_lr->from_lid));
-
- sa_status = IB_SA_MAD_STATUS_NO_RECORDS;
- goto Exit;
- }
- }
-
- if (p_sa_mad->comp_mask & IB_LR_COMPMASK_TO_LID) {
- status = osm_get_port_by_base_lid(sa->p_subn,
- p_lr->to_lid, pp_dest_port);
-
- if ((status != IB_SUCCESS) || (*pp_dest_port == NULL)) {
- /*
- This 'error' is the client's fault (bad lid) so
- don't enter it as an error in our own log.
- Return an error response to the client.
- */
- OSM_LOG(sa->p_log, OSM_LOG_VERBOSE,
- "No dest port with LID %u\n",
- cl_ntoh16(p_lr->to_lid));
-
- sa_status = IB_SA_MAD_STATUS_NO_RECORDS;
- goto Exit;
- }
- }
-
-Exit:
- OSM_LOG_EXIT(sa->p_log);
- return (sa_status);
-}
-
-/**********************************************************************
- **********************************************************************/
-void osm_lr_rcv_process(IN void *context, IN void *data)
-{
- osm_sa_t *sa = context;
- osm_madw_t *p_madw = data;
- const ib_link_record_t *p_lr;
- const ib_sa_mad_t *p_sa_mad;
- const osm_port_t *p_src_port;
- const osm_port_t *p_dest_port;
- cl_qlist_t lr_list;
- ib_net16_t sa_status;
- osm_physp_t *p_req_physp;
-
- OSM_LOG_ENTER(sa->p_log);
-
- CL_ASSERT(p_madw);
-
- p_sa_mad = osm_madw_get_sa_mad_ptr(p_madw);
- p_lr = (ib_link_record_t *) ib_sa_mad_get_payload_ptr(p_sa_mad);
-
- CL_ASSERT(p_sa_mad->attr_id == IB_MAD_ATTR_LINK_RECORD);
-
- /* we only support SubnAdmGet and SubnAdmGetTable methods */
- if (p_sa_mad->method != IB_MAD_METHOD_GET &&
- p_sa_mad->method != IB_MAD_METHOD_GETTABLE) {
- OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 1804: "
- "Unsupported Method (%s)\n",
- ib_get_sa_method_str(p_sa_mad->method));
- osm_sa_send_error(sa, p_madw, IB_MAD_STATUS_UNSUP_METHOD_ATTR);
- goto Exit;
- }
-
- /* update the requester physical port. */
- p_req_physp = osm_get_physp_by_mad_addr(sa->p_log, sa->p_subn,
- osm_madw_get_mad_addr_ptr
- (p_madw));
- if (p_req_physp == NULL) {
- OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 1805: "
- "Cannot find requester physical port\n");
- goto Exit;
- }
-
- if (osm_log_is_active(sa->p_log, OSM_LOG_DEBUG))
- osm_dump_link_record(sa->p_log, p_lr, OSM_LOG_DEBUG);
-
- cl_qlist_init(&lr_list);
-
- /*
- Most SA functions (including this one) are read-only on the
- subnet object, so we grab the lock non-exclusively.
- */
- cl_plock_acquire(sa->p_lock);
-
- sa_status = __osm_lr_rcv_get_end_points(sa, p_madw,
- &p_src_port, &p_dest_port);
-
- if (sa_status == IB_SA_MAD_STATUS_SUCCESS)
- __osm_lr_rcv_get_port_links(sa, p_lr, p_src_port,
- p_dest_port, p_sa_mad->comp_mask,
- &lr_list, p_req_physp);
-
- cl_plock_release(sa->p_lock);
-
- osm_sa_respond(sa, p_madw, sizeof(ib_link_record_t), &lr_list);
-
-Exit:
- OSM_LOG_EXIT(sa->p_log);
-}
diff --git a/contrib/ofed/management/opensm/opensm/osm_sa_mad_ctrl.c b/contrib/ofed/management/opensm/opensm/osm_sa_mad_ctrl.c
deleted file mode 100644
index 49309f9..0000000
--- a/contrib/ofed/management/opensm/opensm/osm_sa_mad_ctrl.c
+++ /dev/null
@@ -1,592 +0,0 @@
-/*
- * Copyright (c) 2004-2008 Voltaire, Inc. All rights reserved.
- * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved.
- * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- */
-
-/*
- * Abstract:
- * Implementation of osm_sa_mad_ctrl_t.
- * This object is part of the SA object.
- */
-
-#if HAVE_CONFIG_H
-# include <config.h>
-#endif /* HAVE_CONFIG_H */
-
-#include <string.h>
-#include <complib/cl_debug.h>
-#include <iba/ib_types.h>
-#include <vendor/osm_vendor_api.h>
-#include <opensm/osm_sa_mad_ctrl.h>
-#include <opensm/osm_msgdef.h>
-#include <opensm/osm_helper.h>
-#include <opensm/osm_sa.h>
-
-/****f* opensm: SA/__osm_sa_mad_ctrl_disp_done_callback
- * NAME
- * __osm_sa_mad_ctrl_disp_done_callback
- *
- * DESCRIPTION
- * This function is the Dispatcher callback that indicates
- * a received MAD has been processed by the recipient.
- *
- * SYNOPSIS
- */
-static void
-__osm_sa_mad_ctrl_disp_done_callback(IN void *context, IN void *p_data)
-{
- osm_sa_mad_ctrl_t *const p_ctrl = (osm_sa_mad_ctrl_t *) context;
- osm_madw_t *const p_madw = (osm_madw_t *) p_data;
-
- OSM_LOG_ENTER(p_ctrl->p_log);
-
- CL_ASSERT(p_madw);
- /*
- Return the MAD & wrapper to the pool.
- */
- osm_mad_pool_put(p_ctrl->p_mad_pool, p_madw);
- OSM_LOG_EXIT(p_ctrl->p_log);
-}
-
-/************/
-
-/****f* opensm: SA/__osm_sa_mad_ctrl_process
- * NAME
- * __osm_sa_mad_ctrl_process
- *
- * DESCRIPTION
- * This function handles known methods for received MADs.
- *
- * SYNOPSIS
- */
-static void
-__osm_sa_mad_ctrl_process(IN osm_sa_mad_ctrl_t * const p_ctrl,
- IN osm_madw_t * p_madw)
-{
- ib_sa_mad_t *p_sa_mad;
- cl_status_t status;
- cl_disp_msgid_t msg_id = CL_DISP_MSGID_NONE;
- uint64_t last_dispatched_msg_queue_time_msec;
- uint32_t num_messages;
-
- OSM_LOG_ENTER(p_ctrl->p_log);
-
- /*
- If the dispatcher is showing us that it is overloaded
- there is no point in placing the request in. We should instead provide
- immediate response - IB_RESOURCE_BUSY
- But how do we know?
- The dispatcher reports back the number of outstanding messages and the
- time the last message stayed in the queue.
- HACK: Actually, we cannot send a mad from within the receive callback;
- thus - we will just drop it.
- */
- cl_disp_get_queue_status(p_ctrl->h_disp,
- &num_messages,
- &last_dispatched_msg_queue_time_msec);
- if ((num_messages > 1) &&
- (p_ctrl->p_subn->opt.max_msg_fifo_timeout) &&
- (last_dispatched_msg_queue_time_msec >
- p_ctrl->p_subn->opt.max_msg_fifo_timeout)) {
- OSM_LOG(p_ctrl->p_log, OSM_LOG_INFO,
- /* "Responding BUSY status since the dispatcher is already" */
- "Dropping MAD since the dispatcher is already"
- " overloaded with %u messages and queue time of:"
- "%" PRIu64 "[msec]\n",
- num_messages, last_dispatched_msg_queue_time_msec);
-
- /* send a busy response */
- /* osm_sa_send_error(p_ctrl->p_resp, p_madw, IB_RESOURCE_BUSY); */
-
- /* return the request to the pool */
- osm_mad_pool_put(p_ctrl->p_mad_pool, p_madw);
-
- goto Exit;
- }
-
- p_sa_mad = osm_madw_get_sa_mad_ptr(p_madw);
-
- /*
- Note that attr_id (like the rest of the MAD) is in
- network byte order.
- */
- switch (p_sa_mad->attr_id) {
- case IB_MAD_ATTR_CLASS_PORT_INFO:
- msg_id = OSM_MSG_MAD_CLASS_PORT_INFO;
- break;
-
- case IB_MAD_ATTR_NODE_RECORD:
- msg_id = OSM_MSG_MAD_NODE_RECORD;
- break;
-
- case IB_MAD_ATTR_PORTINFO_RECORD:
- msg_id = OSM_MSG_MAD_PORTINFO_RECORD;
- break;
-
- case IB_MAD_ATTR_LINK_RECORD:
- msg_id = OSM_MSG_MAD_LINK_RECORD;
- break;
-
- case IB_MAD_ATTR_SMINFO_RECORD:
- msg_id = OSM_MSG_MAD_SMINFO_RECORD;
- break;
-
- case IB_MAD_ATTR_SERVICE_RECORD:
- msg_id = OSM_MSG_MAD_SERVICE_RECORD;
- break;
-
- case IB_MAD_ATTR_PATH_RECORD:
- msg_id = OSM_MSG_MAD_PATH_RECORD;
- break;
-
- case IB_MAD_ATTR_MCMEMBER_RECORD:
- msg_id = OSM_MSG_MAD_MCMEMBER_RECORD;
- break;
-
- case IB_MAD_ATTR_INFORM_INFO:
- msg_id = OSM_MSG_MAD_INFORM_INFO;
- break;
-
- case IB_MAD_ATTR_VLARB_RECORD:
- msg_id = OSM_MSG_MAD_VL_ARB_RECORD;
- break;
-
- case IB_MAD_ATTR_SLVL_RECORD:
- msg_id = OSM_MSG_MAD_SLVL_TBL_RECORD;
- break;
-
- case IB_MAD_ATTR_PKEY_TBL_RECORD:
- msg_id = OSM_MSG_MAD_PKEY_TBL_RECORD;
- break;
-
- case IB_MAD_ATTR_LFT_RECORD:
- msg_id = OSM_MSG_MAD_LFT_RECORD;
- break;
-
- case IB_MAD_ATTR_GUIDINFO_RECORD:
- msg_id = OSM_MSG_MAD_GUIDINFO_RECORD;
- break;
-
- case IB_MAD_ATTR_INFORM_INFO_RECORD:
- msg_id = OSM_MSG_MAD_INFORM_INFO_RECORD;
- break;
-
- case IB_MAD_ATTR_SWITCH_INFO_RECORD:
- msg_id = OSM_MSG_MAD_SWITCH_INFO_RECORD;
- break;
-
- case IB_MAD_ATTR_MFT_RECORD:
- msg_id = OSM_MSG_MAD_MFT_RECORD;
- break;
-
-#if defined (VENDOR_RMPP_SUPPORT) && defined (DUAL_SIDED_RMPP)
- case IB_MAD_ATTR_MULTIPATH_RECORD:
- msg_id = OSM_MSG_MAD_MULTIPATH_RECORD;
- break;
-#endif
-
- default:
- OSM_LOG(p_ctrl->p_log, OSM_LOG_ERROR, "ERR 1A01: "
- "Unsupported attribute = 0x%X\n",
- cl_ntoh16(p_sa_mad->attr_id));
- osm_dump_sa_mad(p_ctrl->p_log, p_sa_mad, OSM_LOG_ERROR);
- }
-
- if (msg_id != CL_DISP_MSGID_NONE) {
- /*
- Post this MAD to the dispatcher for asynchronous
- processing by the appropriate controller.
- */
-
- OSM_LOG(p_ctrl->p_log, OSM_LOG_DEBUG,
- "Posting Dispatcher message %s\n",
- osm_get_disp_msg_str(msg_id));
-
- status = cl_disp_post(p_ctrl->h_disp,
- msg_id,
- p_madw,
- __osm_sa_mad_ctrl_disp_done_callback,
- p_ctrl);
-
- if (status != CL_SUCCESS) {
- OSM_LOG(p_ctrl->p_log, OSM_LOG_ERROR, "ERR 1A02: "
- "Dispatcher post message failed (%s) for attribute = 0x%X\n",
- CL_STATUS_MSG(status),
- cl_ntoh16(p_sa_mad->attr_id));
-
- osm_mad_pool_put(p_ctrl->p_mad_pool, p_madw);
- goto Exit;
- }
- } else {
- /*
- There is an unknown MAD attribute type for which there is
- no recipient. Simply retire the MAD here.
- */
- cl_atomic_inc(&p_ctrl->p_stats->sa_mads_rcvd_unknown);
- osm_mad_pool_put(p_ctrl->p_mad_pool, p_madw);
- }
-
-Exit:
- OSM_LOG_EXIT(p_ctrl->p_log);
-}
-
-/*
- * PARAMETERS
- *
- * RETURN VALUES
- *
- * NOTES
- *
- * SEE ALSO
- *********/
-
-/****f* opensm: SA/__osm_sa_mad_ctrl_rcv_callback
- * NAME
- * __osm_sa_mad_ctrl_rcv_callback
- *
- * DESCRIPTION
- * This is the callback from the transport layer for received MADs.
- *
- * SYNOPSIS
- */
-static void
-__osm_sa_mad_ctrl_rcv_callback(IN osm_madw_t * p_madw,
- IN void *bind_context,
- IN osm_madw_t * p_req_madw)
-{
- osm_sa_mad_ctrl_t *p_ctrl = (osm_sa_mad_ctrl_t *) bind_context;
- ib_sa_mad_t *p_sa_mad;
-
- OSM_LOG_ENTER(p_ctrl->p_log);
-
- CL_ASSERT(p_madw);
-
- /*
- A MAD was received from the wire, possibly in response to a request.
- */
- cl_atomic_inc(&p_ctrl->p_stats->sa_mads_rcvd);
-
- OSM_LOG(p_ctrl->p_log, OSM_LOG_DEBUG,
- "%u SA MADs received\n", p_ctrl->p_stats->sa_mads_rcvd);
-
- /*
- * C15-0.1.3 requires not responding to any MAD if the SM is
- * not in active state!
- * We will not respond if the sm_state is not MASTER, or if the
- * first_time_master_sweep flag (of the subnet) is TRUE - this
- * flag indicates that the master still didn't finish its first
- * sweep, so the subnet is not up and stable yet.
- */
- if (p_ctrl->p_subn->sm_state != IB_SMINFO_STATE_MASTER) {
- cl_atomic_inc(&p_ctrl->p_stats->sa_mads_ignored);
- OSM_LOG(p_ctrl->p_log, OSM_LOG_VERBOSE,
- "Received SA MAD while SM not MASTER. MAD ignored\n");
- osm_mad_pool_put(p_ctrl->p_mad_pool, p_madw);
- goto Exit;
- }
- if (p_ctrl->p_subn->first_time_master_sweep == TRUE) {
- cl_atomic_inc(&p_ctrl->p_stats->sa_mads_ignored);
- OSM_LOG(p_ctrl->p_log, OSM_LOG_VERBOSE,
- "Received SA MAD while SM in first sweep. MAD ignored\n");
- osm_mad_pool_put(p_ctrl->p_mad_pool, p_madw);
- goto Exit;
- }
-
- p_sa_mad = osm_madw_get_sa_mad_ptr(p_madw);
-
- if (osm_log_is_active(p_ctrl->p_log, OSM_LOG_FRAMES))
- osm_dump_sa_mad(p_ctrl->p_log, p_sa_mad, OSM_LOG_FRAMES);
-
- /*
- * C15-0.1.5 - Table 185: SA Header - p884
- * SM_key should be either 0 or match the current SM_Key
- * otherwise discard the MAD.
- */
- if ((p_sa_mad->sm_key != 0) &&
- (p_sa_mad->sm_key != p_ctrl->p_subn->opt.sa_key)) {
- OSM_LOG(p_ctrl->p_log, OSM_LOG_ERROR, "ERR 1A04: "
- "Non-Zero SA MAD SM_Key: 0x%" PRIx64 " != SM_Key: 0x%"
- PRIx64 "; MAD ignored\n", cl_ntoh64(p_sa_mad->sm_key),
- cl_ntoh64(p_ctrl->p_subn->opt.sa_key)
- );
- osm_mad_pool_put(p_ctrl->p_mad_pool, p_madw);
- goto Exit;
- }
-
- switch (p_sa_mad->method) {
- case IB_MAD_METHOD_REPORT_RESP:
- /* we do not really do anything with report represses -
- just retire the transaction */
- OSM_LOG(p_ctrl->p_log, OSM_LOG_DEBUG,
- "Received Report Repress. Retiring the transaction\n");
-
- if (p_req_madw)
- osm_mad_pool_put(p_ctrl->p_mad_pool, p_req_madw);
- osm_mad_pool_put(p_ctrl->p_mad_pool, p_madw);
-
- break;
-
- case IB_MAD_METHOD_GET:
- case IB_MAD_METHOD_GETTABLE:
-#if defined (VENDOR_RMPP_SUPPORT) && defined (DUAL_SIDED_RMPP)
- case IB_MAD_METHOD_GETMULTI:
-#endif
- case IB_MAD_METHOD_SET:
- case IB_MAD_METHOD_DELETE:
- __osm_sa_mad_ctrl_process(p_ctrl, p_madw);
- break;
-
- default:
- cl_atomic_inc(&p_ctrl->p_stats->sa_mads_rcvd_unknown);
- OSM_LOG(p_ctrl->p_log, OSM_LOG_ERROR, "ERR 1A05: "
- "Unsupported method = 0x%X\n", p_sa_mad->method);
- osm_mad_pool_put(p_ctrl->p_mad_pool, p_madw);
- goto Exit;
- }
-
-Exit:
- OSM_LOG_EXIT(p_ctrl->p_log);
-}
-
-/*
- * PARAMETERS
- *
- * RETURN VALUES
- *
- * NOTES
- *
- * SEE ALSO
- *********/
-
-/****f* opensm: SA/__osm_sa_mad_ctrl_send_err_callback
- * NAME
- * __osm_sa_mad_ctrl_send_err_callback
- *
- * DESCRIPTION
- * This is the callback from the transport layer for send errors
- * on MADs that were expecting a response.
- *
- * SYNOPSIS
- */
-static void
-__osm_sa_mad_ctrl_send_err_callback(IN void *bind_context,
- IN osm_madw_t * p_madw)
-{
- osm_sa_mad_ctrl_t *p_ctrl = (osm_sa_mad_ctrl_t *) bind_context;
- cl_status_t status;
-
- OSM_LOG_ENTER(p_ctrl->p_log);
-
- OSM_LOG(p_ctrl->p_log, OSM_LOG_ERROR, "ERR 1A06: "
- "MAD transaction completed in error\n");
-
- /*
- We should never be here since the SA never originates a request.
- Unless we generated a Report(Notice)
- */
-
- CL_ASSERT(p_madw);
-
- /*
- An error occurred. No response was received to a request MAD.
- Retire the original request MAD.
- */
-
- osm_dump_sa_mad(p_ctrl->p_log, osm_madw_get_sa_mad_ptr(p_madw),
- OSM_LOG_ERROR);
-
- /* __osm_sm_mad_ctrl_update_wire_stats( p_ctrl ); */
-
- if (osm_madw_get_err_msg(p_madw) != CL_DISP_MSGID_NONE) {
- OSM_LOG(p_ctrl->p_log, OSM_LOG_DEBUG,
- "Posting Dispatcher message %s\n",
- osm_get_disp_msg_str(osm_madw_get_err_msg(p_madw)));
-
- status = cl_disp_post(p_ctrl->h_disp,
- osm_madw_get_err_msg(p_madw),
- p_madw,
- __osm_sa_mad_ctrl_disp_done_callback,
- p_ctrl);
- if (status != CL_SUCCESS) {
- OSM_LOG(p_ctrl->p_log, OSM_LOG_ERROR, "ERR 1A07: "
- "Dispatcher post message failed (%s)\n",
- CL_STATUS_MSG(status));
- }
- } else {
- /*
- No error message was provided, just retire the MAD.
- */
- osm_mad_pool_put(p_ctrl->p_mad_pool, p_madw);
- }
-
- OSM_LOG_EXIT(p_ctrl->p_log);
-}
-
-/*
- * PARAMETERS
- *
- * RETURN VALUES
- *
- * NOTES
- *
- * SEE ALSO
- *********/
-
-/**********************************************************************
- **********************************************************************/
-void osm_sa_mad_ctrl_construct(IN osm_sa_mad_ctrl_t * const p_ctrl)
-{
- CL_ASSERT(p_ctrl);
- memset(p_ctrl, 0, sizeof(*p_ctrl));
- p_ctrl->h_disp = CL_DISP_INVALID_HANDLE;
-}
-
-/**********************************************************************
- **********************************************************************/
-void osm_sa_mad_ctrl_destroy(IN osm_sa_mad_ctrl_t * const p_ctrl)
-{
- CL_ASSERT(p_ctrl);
- cl_disp_unregister(p_ctrl->h_disp);
-}
-
-/**********************************************************************
- **********************************************************************/
-ib_api_status_t
-osm_sa_mad_ctrl_init(IN osm_sa_mad_ctrl_t * const p_ctrl,
- IN osm_sa_t * sa,
- IN osm_mad_pool_t * const p_mad_pool,
- IN osm_vendor_t * const p_vendor,
- IN osm_subn_t * const p_subn,
- IN osm_log_t * const p_log,
- IN osm_stats_t * const p_stats,
- IN cl_dispatcher_t * const p_disp)
-{
- ib_api_status_t status = IB_SUCCESS;
-
- OSM_LOG_ENTER(p_log);
-
- osm_sa_mad_ctrl_construct(p_ctrl);
-
- p_ctrl->sa = sa;
- p_ctrl->p_log = p_log;
- p_ctrl->p_disp = p_disp;
- p_ctrl->p_mad_pool = p_mad_pool;
- p_ctrl->p_vendor = p_vendor;
- p_ctrl->p_stats = p_stats;
- p_ctrl->p_subn = p_subn;
-
- p_ctrl->h_disp = cl_disp_register(p_disp,
- CL_DISP_MSGID_NONE, NULL, p_ctrl);
-
- if (p_ctrl->h_disp == CL_DISP_INVALID_HANDLE) {
- OSM_LOG(p_log, OSM_LOG_ERROR, "ERR 1A08: "
- "Dispatcher registration failed\n");
- status = IB_INSUFFICIENT_RESOURCES;
- goto Exit;
- }
-
-Exit:
- OSM_LOG_EXIT(p_log);
- return (status);
-}
-
-/**********************************************************************
- **********************************************************************/
-ib_api_status_t
-osm_sa_mad_ctrl_bind(IN osm_sa_mad_ctrl_t * const p_ctrl,
- IN const ib_net64_t port_guid)
-{
- osm_bind_info_t bind_info;
- ib_api_status_t status = IB_SUCCESS;
-
- OSM_LOG_ENTER(p_ctrl->p_log);
-
- if (p_ctrl->h_bind != OSM_BIND_INVALID_HANDLE) {
- OSM_LOG(p_ctrl->p_log, OSM_LOG_ERROR, "ERR 1A09: "
- "Multiple binds not allowed\n");
- status = IB_ERROR;
- goto Exit;
- }
-
- bind_info.class_version = 2;
- bind_info.is_responder = TRUE;
- bind_info.is_report_processor = FALSE;
- bind_info.is_trap_processor = FALSE;
- bind_info.mad_class = IB_MCLASS_SUBN_ADM;
- bind_info.port_guid = port_guid;
- bind_info.recv_q_size = OSM_SM_DEFAULT_QP1_RCV_SIZE;
- bind_info.send_q_size = OSM_SM_DEFAULT_QP1_SEND_SIZE;
-
- OSM_LOG(p_ctrl->p_log, OSM_LOG_VERBOSE,
- "Binding to port GUID 0x%" PRIx64 "\n", cl_ntoh64(port_guid));
-
- p_ctrl->h_bind = osm_vendor_bind(p_ctrl->p_vendor,
- &bind_info,
- p_ctrl->p_mad_pool,
- __osm_sa_mad_ctrl_rcv_callback,
- __osm_sa_mad_ctrl_send_err_callback,
- p_ctrl);
-
- if (p_ctrl->h_bind == OSM_BIND_INVALID_HANDLE) {
- status = IB_ERROR;
- OSM_LOG(p_ctrl->p_log, OSM_LOG_ERROR, "ERR 1A10: "
- "Vendor specific bind failed (%s)\n",
- ib_get_err_str(status));
- goto Exit;
- }
-
-Exit:
- OSM_LOG_EXIT(p_ctrl->p_log);
- return (status);
-}
-
-/**********************************************************************
- **********************************************************************/
-ib_api_status_t osm_sa_mad_ctrl_unbind(IN osm_sa_mad_ctrl_t * const p_ctrl)
-{
- ib_api_status_t status = IB_SUCCESS;
-
- OSM_LOG_ENTER(p_ctrl->p_log);
-
- if (p_ctrl->h_bind == OSM_BIND_INVALID_HANDLE) {
- OSM_LOG(p_ctrl->p_log, OSM_LOG_ERROR, "ERR 1A11: "
- "No previous bind\n");
- status = IB_ERROR;
- goto Exit;
- }
-
- osm_vendor_unbind(p_ctrl->h_bind);
-Exit:
- OSM_LOG_EXIT(p_ctrl->p_log);
- return (status);
-}
diff --git a/contrib/ofed/management/opensm/opensm/osm_sa_mcmember_record.c b/contrib/ofed/management/opensm/opensm/osm_sa_mcmember_record.c
deleted file mode 100644
index 37e78b5..0000000
--- a/contrib/ofed/management/opensm/opensm/osm_sa_mcmember_record.c
+++ /dev/null
@@ -1,1735 +0,0 @@
-/*
- * Copyright (c) 2004-2008 Voltaire, Inc. All rights reserved.
- * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved.
- * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
- * Copyright (c) 2008 Xsigo Systems Inc. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- */
-
-/*
- * Abstract:
- * Implementation of osm_mcmr_recv_t.
- * This object represents the MCMemberRecord Receiver object.
- * This object is part of the opensm family of objects.
- */
-
-#if HAVE_CONFIG_H
-# include <config.h>
-#endif /* HAVE_CONFIG_H */
-
-#include <stdlib.h>
-#include <string.h>
-#include <arpa/inet.h>
-#include <iba/ib_types.h>
-#include <complib/cl_qmap.h>
-#include <complib/cl_passivelock.h>
-#include <complib/cl_debug.h>
-#include <complib/cl_qlist.h>
-#include <vendor/osm_vendor_api.h>
-#include <opensm/osm_madw.h>
-#include <opensm/osm_log.h>
-#include <opensm/osm_subnet.h>
-#include <opensm/osm_mad_pool.h>
-#include <opensm/osm_helper.h>
-#include <opensm/osm_msgdef.h>
-#include <opensm/osm_pkey.h>
-#include <opensm/osm_inform.h>
-#include <opensm/osm_sa.h>
-
-#include <sys/socket.h>
-
-#define JOIN_MC_COMP_MASK (IB_MCR_COMPMASK_MGID | \
- IB_MCR_COMPMASK_PORT_GID | \
- IB_MCR_COMPMASK_JOIN_STATE)
-
-#define REQUIRED_MC_CREATE_COMP_MASK (IB_MCR_COMPMASK_MGID | \
- IB_MCR_COMPMASK_PORT_GID | \
- IB_MCR_COMPMASK_JOIN_STATE | \
- IB_MCR_COMPMASK_QKEY | \
- IB_MCR_COMPMASK_TCLASS | \
- IB_MCR_COMPMASK_PKEY | \
- IB_MCR_COMPMASK_FLOW | \
- IB_MCR_COMPMASK_SL)
-
-typedef struct osm_mcmr_item {
- cl_list_item_t list_item;
- ib_member_rec_t rec;
-} osm_mcmr_item_t;
-
-/*********************************************************************
- Copy certain fields between two mcmember records
- used during the process of join request to copy data from the mgrp
- to the port record.
-**********************************************************************/
-static inline void
-__copy_from_create_mc_rec(IN ib_member_rec_t * const dest,
- IN const ib_member_rec_t * const src)
-{
- dest->qkey = src->qkey;
- dest->mlid = src->mlid;
- dest->tclass = src->tclass;
- dest->pkey = src->pkey;
- dest->sl_flow_hop = src->sl_flow_hop;
- dest->mtu = src->mtu;
- dest->rate = src->rate;
- dest->pkt_life = src->pkt_life;
-}
-
-/*********************************************************************
- Return mlid to the pool of free mlids.
- But this implementation is not a pool - it simply scans through
- the MGRP database for unused mlids...
-*********************************************************************/
-static void __free_mlid(IN osm_sa_t * sa, IN uint16_t mlid)
-{
- UNUSED_PARAM(sa);
- UNUSED_PARAM(mlid);
-}
-
-/*********************************************************************
- Get a new unused mlid by scanning all the used ones in the subnet.
-**********************************************************************/
-static ib_net16_t __get_new_mlid(osm_sa_t *sa, ib_net16_t requested_mlid)
-{
- osm_subn_t *p_subn = sa->p_subn;
- unsigned i, max;
-
- if (requested_mlid && cl_ntoh16(requested_mlid) >= IB_LID_MCAST_START_HO
- && cl_ntoh16(requested_mlid) <= p_subn->max_mcast_lid_ho
- && !osm_get_mgrp_by_mlid(p_subn, requested_mlid))
- return requested_mlid;
-
- max = p_subn->max_mcast_lid_ho - IB_LID_MCAST_START_HO + 1;
- for (i = 0; i < max; i++) {
- osm_mgrp_t *p_mgrp = sa->p_subn->mgroups[i];
- if (!p_mgrp || p_mgrp->to_be_deleted)
- return cl_hton16(i + IB_LID_MCAST_START_HO);
- }
-
- return 0;
-}
-
-/*********************************************************************
- This procedure is only invoked to cleanup an INTERMEDIATE mgrp.
- If there is only one port on the mgrp it means that the current
- request was the only member and the group is not really needed. So
- we silently drop it. Since it was an intermediate group no need to
- re-route it.
-**********************************************************************/
-static void __cleanup_mgrp(IN osm_sa_t * sa, osm_mgrp_t *mgrp)
-{
- /* Remove MGRP only if osm_mcm_port_t count is 0 and
- not a well known group */
- if (cl_is_qmap_empty(&mgrp->mcm_port_tbl) && !mgrp->well_known) {
- sa->p_subn->mgroups[cl_ntoh16(mgrp->mlid) - IB_LID_MCAST_START_HO] = NULL;
- osm_mgrp_delete(mgrp);
- }
-}
-
-/*********************************************************************
- Add a port to the group. Calculating its PROXY_JOIN by the Port and
- requester gids.
-**********************************************************************/
-static ib_api_status_t
-__add_new_mgrp_port(IN osm_sa_t * sa,
- IN osm_mgrp_t * p_mgrp,
- IN ib_member_rec_t * p_recvd_mcmember_rec,
- IN osm_mad_addr_t * p_mad_addr,
- OUT osm_mcm_port_t ** pp_mcmr_port)
-{
- boolean_t proxy_join;
- ib_gid_t requester_gid;
- ib_api_status_t res;
-
- /* set the proxy_join if the requester gid is not identical to the
- joined gid */
- res = osm_get_gid_by_mad_addr(sa->p_log, sa->p_subn,
- p_mad_addr, &requester_gid);
- if (res != IB_SUCCESS) {
- OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 1B29: "
- "Could not find GID for requester\n");
-
- return IB_INVALID_PARAMETER;
- }
-
- if (!memcmp(&p_recvd_mcmember_rec->port_gid, &requester_gid,
- sizeof(ib_gid_t))) {
- proxy_join = FALSE;
- OSM_LOG(sa->p_log, OSM_LOG_DEBUG,
- "Create new port with proxy_join FALSE\n");
- } else {
- /* The port is not the one specified in PortGID.
- The check that the requester is in the same partition as
- the PortGID is done before - just need to update
- the proxy_join. */
- proxy_join = TRUE;
- OSM_LOG(sa->p_log, OSM_LOG_DEBUG,
- "Create new port with proxy_join TRUE\n");
- }
-
- *pp_mcmr_port = osm_mgrp_add_port(sa->p_subn, sa->p_log, p_mgrp,
- &p_recvd_mcmember_rec->port_gid,
- p_recvd_mcmember_rec->scope_state,
- proxy_join);
- if (*pp_mcmr_port == NULL) {
- OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 1B06: "
- "osm_mgrp_add_port failed\n");
-
- return IB_INSUFFICIENT_MEMORY;
- }
-
- return IB_SUCCESS;
-}
-
-/**********************************************************************
- **********************************************************************/
-static inline boolean_t __check_join_comp_mask(ib_net64_t comp_mask)
-{
- return ((comp_mask & JOIN_MC_COMP_MASK) == JOIN_MC_COMP_MASK);
-}
-
-/**********************************************************************
- **********************************************************************/
-static inline boolean_t
-__check_create_comp_mask(ib_net64_t comp_mask,
- ib_member_rec_t * p_recvd_mcmember_rec)
-{
- return ((comp_mask & REQUIRED_MC_CREATE_COMP_MASK) ==
- REQUIRED_MC_CREATE_COMP_MASK);
-}
-
-/**********************************************************************
- Generate the response MAD
-**********************************************************************/
-static void
-__osm_mcmr_rcv_respond(IN osm_sa_t * sa,
- IN osm_madw_t * const p_madw,
- IN ib_member_rec_t * p_mcmember_rec)
-{
- cl_qlist_t rec_list;
- osm_mcmr_item_t *item;
-
- OSM_LOG_ENTER(sa->p_log);
-
- item = malloc(sizeof(*item));
- if (!item) {
- OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 1B16: "
- "rec_item alloc failed\n");
- goto Exit;
- }
-
- item->rec = *p_mcmember_rec;
-
- /* Fill in the mtu, rate, and packet lifetime selectors */
- item->rec.mtu &= 0x3f;
- item->rec.mtu |= 2 << 6; /* exactly */
- item->rec.rate &= 0x3f;
- item->rec.rate |= 2 << 6; /* exactly */
- item->rec.pkt_life &= 0x3f;
- item->rec.pkt_life |= 2 << 6; /* exactly */
-
- cl_qlist_init(&rec_list);
- cl_qlist_insert_tail(&rec_list, &item->list_item);
-
- osm_sa_respond(sa, p_madw, sizeof(ib_member_rec_t), &rec_list);
-
-Exit:
- OSM_LOG_EXIT(sa->p_log);
-}
-
-/*********************************************************************
- In joining an existing group, or when querying the mc groups,
- we make sure the following components provided match: MTU and RATE
- HACK: Currently we ignore the PKT_LIFETIME field.
-**********************************************************************/
-static boolean_t
-__validate_more_comp_fields(osm_log_t * p_log,
- const osm_mgrp_t * p_mgrp,
- const ib_member_rec_t * p_recvd_mcmember_rec,
- ib_net64_t comp_mask)
-{
- uint8_t mtu_sel;
- uint8_t mtu_required;
- uint8_t mtu_mgrp;
- uint8_t rate_sel;
- uint8_t rate_required;
- uint8_t rate_mgrp;
-
- if (comp_mask & IB_MCR_COMPMASK_MTU_SEL) {
- mtu_sel = (uint8_t) (p_recvd_mcmember_rec->mtu >> 6);
- /* Clearing last 2 bits */
- mtu_required = (uint8_t) (p_recvd_mcmember_rec->mtu & 0x3F);
- mtu_mgrp = (uint8_t) (p_mgrp->mcmember_rec.mtu & 0x3F);
- switch (mtu_sel) {
- case 0: /* Greater than MTU specified */
- if (mtu_mgrp <= mtu_required) {
- OSM_LOG(p_log, OSM_LOG_DEBUG,
- "Requested mcast group has MTU %x, "
- "which is not greater than %x\n",
- mtu_mgrp, mtu_required);
- return FALSE;
- }
- break;
- case 1: /* Less than MTU specified */
- if (mtu_mgrp >= mtu_required) {
- OSM_LOG(p_log, OSM_LOG_DEBUG,
- "Requested mcast group has MTU %x, "
- "which is not less than %x\n",
- mtu_mgrp, mtu_required);
- return FALSE;
- }
- break;
- case 2: /* Exactly MTU specified */
- if (mtu_mgrp != mtu_required) {
- OSM_LOG(p_log, OSM_LOG_DEBUG,
- "Requested mcast group has MTU %x, "
- "which is not equal to %x\n",
- mtu_mgrp, mtu_required);
- return FALSE;
- }
- break;
- default:
- break;
- }
- }
-
- /* what about rate ? */
- if (comp_mask & IB_MCR_COMPMASK_RATE_SEL) {
- rate_sel = (uint8_t) (p_recvd_mcmember_rec->rate >> 6);
- /* Clearing last 2 bits */
- rate_required = (uint8_t) (p_recvd_mcmember_rec->rate & 0x3F);
- rate_mgrp = (uint8_t) (p_mgrp->mcmember_rec.rate & 0x3F);
- switch (rate_sel) {
- case 0: /* Greater than RATE specified */
- if (rate_mgrp <= rate_required) {
- OSM_LOG(p_log, OSM_LOG_DEBUG,
- "Requested mcast group has RATE %x, "
- "which is not greater than %x\n",
- rate_mgrp, rate_required);
- return FALSE;
- }
- break;
- case 1: /* Less than RATE specified */
- if (rate_mgrp >= rate_required) {
- OSM_LOG(p_log, OSM_LOG_DEBUG,
- "Requested mcast group has RATE %x, "
- "which is not less than %x\n",
- rate_mgrp, rate_required);
- return FALSE;
- }
- break;
- case 2: /* Exactly RATE specified */
- if (rate_mgrp != rate_required) {
- OSM_LOG(p_log, OSM_LOG_DEBUG,
- "Requested mcast group has RATE %x, "
- "which is not equal to %x\n",
- rate_mgrp, rate_required);
- return FALSE;
- }
- break;
- default:
- break;
- }
- }
-
- return TRUE;
-}
-
-/*********************************************************************
- In joining an existing group, we make sure the following components
- are physically realizable: MTU and RATE
-**********************************************************************/
-static boolean_t
-__validate_port_caps(osm_log_t * const p_log,
- const osm_mgrp_t * p_mgrp, const osm_physp_t * p_physp)
-{
- uint8_t mtu_required;
- uint8_t mtu_mgrp;
- uint8_t rate_required;
- uint8_t rate_mgrp;
-
- mtu_required = ib_port_info_get_mtu_cap(&p_physp->port_info);
- mtu_mgrp = (uint8_t) (p_mgrp->mcmember_rec.mtu & 0x3F);
- if (mtu_required < mtu_mgrp) {
- OSM_LOG(p_log, OSM_LOG_DEBUG,
- "Port's MTU %x is less than %x\n",
- mtu_required, mtu_mgrp);
- return FALSE;
- }
-
- rate_required = ib_port_info_compute_rate(&p_physp->port_info);
- rate_mgrp = (uint8_t) (p_mgrp->mcmember_rec.rate & 0x3F);
- if (rate_required < rate_mgrp) {
- OSM_LOG(p_log, OSM_LOG_DEBUG,
- "Port's RATE %x is less than %x\n",
- rate_required, rate_mgrp);
- return FALSE;
- }
-
- return TRUE;
-}
-
-/**********************************************************************
- * o15-0.2.1: If SA supports UD multicast, then if SA receives a SubnAdmSet()
- * or SubnAdmDelete() method that would modify an existing
- * MCMemberRecord, SA shall not modify that MCMemberRecord and shall
- * return an error status of ERR_REQ_INVALID in response in the
- * following cases:
- * 1. Saved MCMemberRecord.ProxyJoin is not set and the request is
- * issued by a requester with a GID other than the Port-GID.
- * 2. Saved MCMemberRecord.ProxyJoin is set and the requester is not
- * part of the partition for that MCMemberRecord.
- **********************************************************************/
-static boolean_t
-__validate_modify(IN osm_sa_t * sa,
- IN osm_mgrp_t * p_mgrp,
- IN osm_mad_addr_t * p_mad_addr,
- IN ib_member_rec_t * p_recvd_mcmember_rec,
- OUT osm_mcm_port_t ** pp_mcm_port)
-{
- ib_net64_t portguid;
- ib_gid_t request_gid;
- osm_physp_t *p_request_physp;
- ib_api_status_t res;
-
- portguid = p_recvd_mcmember_rec->port_gid.unicast.interface_id;
-
- *pp_mcm_port = NULL;
-
- /* o15-0.2.1: If this is a new port being added - nothing to check */
- if (!osm_mgrp_is_port_present(p_mgrp, portguid, pp_mcm_port)) {
- OSM_LOG(sa->p_log, OSM_LOG_DEBUG,
- "This is a new port in the MC group\n");
- return TRUE;
- }
-
- /* We validate the request according the the proxy_join.
- Check if the proxy_join is set or not */
- if ((*pp_mcm_port)->proxy_join == FALSE) {
- /* The proxy_join is not set. Modifying can by done only
- if the requester GID == PortGID */
- res = osm_get_gid_by_mad_addr(sa->p_log,
- sa->p_subn,
- p_mad_addr, &request_gid);
-
- if (res != IB_SUCCESS) {
- OSM_LOG(sa->p_log, OSM_LOG_DEBUG,
- "Could not find port for requested address\n");
- return FALSE;
- }
-
- if (memcmp(&((*pp_mcm_port)->port_gid), &request_gid,
- sizeof(ib_gid_t))) {
- OSM_LOG(sa->p_log, OSM_LOG_DEBUG,
- "No ProxyJoin but different ports: stored:"
- "0x%016" PRIx64 " request:0x%016" PRIx64 "\n",
- cl_ntoh64((*pp_mcm_port)->port_gid.unicast.
- interface_id),
- cl_ntoh64(p_mad_addr->addr_type.gsi.grh_info.
- src_gid.unicast.interface_id));
- return FALSE;
- }
- } else {
- /* The proxy_join is set. Modification allowed only if the
- requester is part of the partition for this MCMemberRecord */
- p_request_physp = osm_get_physp_by_mad_addr(sa->p_log,
- sa->p_subn,
- p_mad_addr);
- if (p_request_physp == NULL)
- return FALSE;
-
- if (!osm_physp_has_pkey(sa->p_log, p_mgrp->mcmember_rec.pkey,
- p_request_physp)) {
- /* the request port is not part of the partition for this mgrp */
- OSM_LOG(sa->p_log, OSM_LOG_DEBUG,
- "ProxyJoin but port not in partition. stored:"
- "0x%016" PRIx64 " request:0x%016" PRIx64 "\n",
- cl_ntoh64((*pp_mcm_port)->port_gid.unicast.
- interface_id),
- cl_ntoh64(p_mad_addr->addr_type.gsi.grh_info.
- src_gid.unicast.interface_id));
- return FALSE;
- }
- }
- return TRUE;
-}
-
-/**********************************************************************
- **********************************************************************/
-/*
- * Check legality of the requested MGID DELETE
- * o15-0.1.14 = VALID DELETE:
- * To be a valid delete MAD needs to:
- * 1 the MADs PortGID and MGID components match the PortGID and
- * MGID of a stored MCMemberRecord;
- * 2 the MADs JoinState component contains at least one bit set to 1
- * in the same position as that stored MCMemberRecords JoinState
- * has a bit set to 1,
- * i.e., the logical AND of the two JoinState components
- * is not all zeros;
- * 3 the MADs JoinState component does not have some bits set
- * which are not set in the stored MCMemberRecords JoinState component;
- * 4 either the stored MCMemberRecord:ProxyJoin is reset (0), and the
- * MADs source is the stored PortGID;
- * OR
- * the stored MCMemberRecord:ProxyJoin is set (1), (see o15-
- * 0.1.2:); and the MADs source is a member of the partition indicated
- * by the stored MCMemberRecord:P_Key.
- */
-static boolean_t
-__validate_delete(IN osm_sa_t * sa,
- IN osm_mgrp_t * p_mgrp,
- IN osm_mad_addr_t * p_mad_addr,
- IN ib_member_rec_t * p_recvd_mcmember_rec,
- OUT osm_mcm_port_t ** pp_mcm_port)
-{
- ib_net64_t portguid;
-
- portguid = p_recvd_mcmember_rec->port_gid.unicast.interface_id;
-
- *pp_mcm_port = NULL;
-
- /* 1 */
- if (!osm_mgrp_is_port_present(p_mgrp, portguid, pp_mcm_port)) {
- OSM_LOG(sa->p_log, OSM_LOG_DEBUG,
- "Failed to find the port in the MC group\n");
- return FALSE;
- }
-
- /* 2 */
- if (!(p_recvd_mcmember_rec->scope_state & 0x0F &
- (*pp_mcm_port)->scope_state)) {
- OSM_LOG(sa->p_log, OSM_LOG_DEBUG,
- "Could not find any matching bits in the stored "
- "and requested JoinStates\n");
- return FALSE;
- }
-
- /* 3 */
- if (((p_recvd_mcmember_rec->scope_state & 0x0F) |
- (0x0F & (*pp_mcm_port)->scope_state)) !=
- (0x0F & (*pp_mcm_port)->scope_state)) {
- OSM_LOG(sa->p_log, OSM_LOG_DEBUG,
- "Some bits in the request JoinState (0x%X) are not "
- "set in the stored port (0x%X)\n",
- (p_recvd_mcmember_rec->scope_state & 0x0F),
- (0x0F & (*pp_mcm_port)->scope_state));
- return FALSE;
- }
-
- /* 4 */
- /* Validate according the the proxy_join (o15-0.1.2) */
- if (__validate_modify(sa, p_mgrp, p_mad_addr, p_recvd_mcmember_rec,
- pp_mcm_port) == FALSE) {
- OSM_LOG(sa->p_log, OSM_LOG_DEBUG,
- "proxy_join validation failure\n");
- return FALSE;
- }
- return TRUE;
-}
-
-/**********************************************************************
- **********************************************************************/
-/*
- * Check legality of the requested MGID (note this does not hold for SA
- * created MGIDs)
- *
- * Implementing o15-0.1.5:
- * A multicast GID is considered to be invalid if:
- * 1. It does not comply with the rules as specified in 4.1.1 "GID Usage and
- * Properties" on page 145:
- *
- * 14) The multicast GID format is (bytes are comma sep):
- * 0xff,<Fl><Sc>,<Si>,<Si>,<P>,<P>,<P>,<P>,<P>,<P>,<P>,<P>,<Id>,<Id>,<Id>,<Id>
- * Fl 4bit = Flags (b)
- * Sc 4bit = Scope (c)
- * Si 16bit = Signature (2)
- * P 64bit = GID Prefix (should be a subnet unique ID - normally Subnet Prefix)
- * Id 32bit = Unique ID in the Subnet (might be MLID or Pkey ?)
- *
- * a) 8-bits of 11111111 at the start of the GID identifies this as being a
- * multicast GID.
- * b) Flags is a set of four 1-bit flags: 000T with three flags reserved
- * and defined as zero (0). The T flag is defined as follows:
- * i) T = 0 indicates this is a permanently assigned (i.e. wellknown)
- * multicast GID. See RFC 2373 and RFC 2375 as reference
- * for these permanently assigned GIDs.
- * ii) T = 1 indicates this is a non-permanently assigned (i.e. transient)
- * multicast GID.
- * c) Scope is a 4-bit multicast scope value used to limit the scope of
- * the multicast group. The following table defines scope value and
- * interpretation.
- *
- * Multicast Address Scope Values:
- * 0x2 Link-local
- * 0x5 Site-local
- * 0x8 Organization-local
- * 0xE Global
- *
- * 2. It contains the SA-specific signature of 0xA01B and has the link-local
- * scope bits set. (EZ: the idea here is that SA created MGIDs are the
- * only source for this signature with link-local scope)
- */
-static ib_api_status_t
-__validate_requested_mgid(IN osm_sa_t * sa,
- IN const ib_member_rec_t * p_mcm_rec)
-{
- uint16_t signature;
- boolean_t valid = TRUE;
-
- OSM_LOG_ENTER(sa->p_log);
-
- /* 14-a: mcast GID must start with 0xFF */
- if (p_mcm_rec->mgid.multicast.header[0] != 0xFF) {
- OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 1B01: "
- "Wrong MGID Prefix 0x%02X must be 0xFF\n",
- cl_ntoh16(p_mcm_rec->mgid.multicast.header[0]));
- valid = FALSE;
- goto Exit;
- }
-
- /* the MGID signature can mark IPoIB or SA assigned MGIDs */
- memcpy(&signature, &(p_mcm_rec->mgid.multicast.raw_group_id),
- sizeof(signature));
- signature = cl_ntoh16(signature);
- OSM_LOG(sa->p_log, OSM_LOG_DEBUG,
- "MGID Signed as 0x%04X\n", signature);
-
- /*
- * We skip any checks for MGIDs that follow IPoIB
- * GID structure as defined by the IETF ipoib-link-multicast.
- *
- * For IPv4 over IB, the signature will be "0x401B".
- *
- * | 8 | 4 | 4 | 16 bits | 16 bits | 48 bits | 32 bits |
- * +--------+----+----+-----------------+---------+----------+---------+
- * |11111111|0001|scop|<IPoIB signature>|< P_Key >|00.......0|<all 1's>|
- * +--------+----+----+-----------------+---------+----------+---------+
- *
- * For IPv6 over IB, the signature will be "0x601B".
- *
- * | 8 | 4 | 4 | 16 bits | 16 bits | 80 bits |
- * +--------+----+----+-----------------+---------+--------------------+
- * |11111111|0001|scop|<IPoIB signature>|< P_Key >|000.............0001|
- * +--------+----+----+-----------------+---------+--------------------+
- *
- */
- if (signature == 0x401B || signature == 0x601B) {
- OSM_LOG(sa->p_log, OSM_LOG_DEBUG,
- "Skipping MGID Validation for IPoIB Signed (0x%04X) MGIDs\n",
- signature);
- goto Exit;
- }
-
- /* 14-b: the 3 upper bits in the "flags" should be zero: */
- if (p_mcm_rec->mgid.multicast.header[1] & 0xE0) {
- OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 1B28: "
- "MGID uses Reserved Flags: flags=0x%X\n",
- (p_mcm_rec->mgid.multicast.header[1] & 0xE0) >> 4);
- valid = FALSE;
- goto Exit;
- }
-
- /* 2 - now what if the link local format 0xA01B is used -
- the scope should not be link local */
- if (signature == 0xA01B &&
- (p_mcm_rec->mgid.multicast.header[1] & 0x0F) ==
- IB_MC_SCOPE_LINK_LOCAL) {
- OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 1B24: "
- "MGID uses 0xA01B signature but with link-local scope\n");
- valid = FALSE;
- goto Exit;
- }
-
- /*
- * For SA assigned MGIDs (signature 0xA01B):
- * There is no real way to make sure the Unique MGID Prefix is really unique.
- * If we could enforce using the Subnet Prefix for that purpose it would
- * have been nice. But the spec does not require it.
- */
-
-Exit:
- OSM_LOG_EXIT(sa->p_log);
- return (valid);
-}
-
-/**********************************************************************
- Check if the requested new MC group parameters are realizable.
- Also set the default MTU and Rate if not provided by the user.
-**********************************************************************/
-static boolean_t
-__mgrp_request_is_realizable(IN osm_sa_t * sa,
- IN ib_net64_t comp_mask,
- IN ib_member_rec_t * p_mcm_rec,
- IN const osm_physp_t * const p_physp)
-{
- uint8_t mtu_sel = 2; /* exactly */
- uint8_t mtu_required, mtu, port_mtu;
- uint8_t rate_sel = 2; /* exactly */
- uint8_t rate_required, rate, port_rate;
- osm_log_t *p_log = sa->p_log;
-
- OSM_LOG_ENTER(sa->p_log);
-
- /*
- * End of o15-0.2.3 specifies:
- * ....
- * The entity may also supply the other components such as HopLimit,
- * MTU, etc. during group creation time. If these components are not
- * provided during group creation time, SA will provide them for the
- * group. The values chosen are vendor-dependent and beyond the scope
- * of the specification.
- *
- * so we might also need to assign RATE/MTU if they are not comp
- * masked in.
- */
-
- port_mtu = p_physp ? ib_port_info_get_mtu_cap(&p_physp->port_info) : 0;
- if (!(comp_mask & IB_MCR_COMPMASK_MTU) ||
- !(comp_mask & IB_MCR_COMPMASK_MTU_SEL) ||
- (mtu_sel = (p_mcm_rec->mtu >> 6)) == 3)
- mtu = port_mtu ? port_mtu : sa->p_subn->min_ca_mtu;
- else {
- mtu_required = (uint8_t) (p_mcm_rec->mtu & 0x3F);
- mtu = mtu_required;
- switch (mtu_sel) {
- case 0: /* Greater than MTU specified */
- if (port_mtu && mtu_required >= port_mtu) {
- OSM_LOG(p_log, OSM_LOG_DEBUG,
- "Requested MTU %x >= the port\'s mtu:%x\n",
- mtu_required, port_mtu);
- return FALSE;
- }
- /* we provide the largest MTU possible if we can */
- if (port_mtu)
- mtu = port_mtu;
- else if (mtu_required < sa->p_subn->min_ca_mtu)
- mtu = sa->p_subn->min_ca_mtu;
- else
- mtu++;
- break;
- case 1: /* Less than MTU specified */
- /* use the smaller of the two:
- a. one lower then the required
- b. the mtu of the requesting port (if exists) */
- if (port_mtu && mtu_required > port_mtu)
- mtu = port_mtu;
- else
- mtu--;
- break;
- case 2: /* Exactly MTU specified */
- default:
- break;
- }
- /* make sure it still be in the range */
- if (mtu < IB_MIN_MTU || mtu > IB_MAX_MTU) {
- OSM_LOG(p_log, OSM_LOG_DEBUG,
- "Calculated MTU %x is out of range\n", mtu);
- return FALSE;
- }
- }
- p_mcm_rec->mtu = (mtu_sel << 6) | mtu;
-
- port_rate =
- p_physp ? ib_port_info_compute_rate(&p_physp->port_info) : 0;
- if (!(comp_mask & IB_MCR_COMPMASK_RATE)
- || !(comp_mask & IB_MCR_COMPMASK_RATE_SEL)
- || (rate_sel = (p_mcm_rec->rate >> 6)) == 3)
- rate = port_rate ? port_rate : sa->p_subn->min_ca_rate;
- else {
- rate_required = (uint8_t) (p_mcm_rec->rate & 0x3F);
- rate = rate_required;
- switch (rate_sel) {
- case 0: /* Greater than RATE specified */
- if (port_rate && rate_required >= port_rate) {
- OSM_LOG(p_log, OSM_LOG_DEBUG,
- "Requested RATE %x >= the port\'s rate:%x\n",
- rate_required, port_rate);
- return FALSE;
- }
- /* we provide the largest RATE possible if we can */
- if (port_rate)
- rate = port_rate;
- else if (rate_required < sa->p_subn->min_ca_rate)
- rate = sa->p_subn->min_ca_rate;
- else
- rate++;
- break;
- case 1: /* Less than RATE specified */
- /* use the smaller of the two:
- a. one lower then the required
- b. the rate of the requesting port (if exists) */
- if (port_rate && rate_required > port_rate)
- rate = port_rate;
- else
- rate--;
- break;
- case 2: /* Exactly RATE specified */
- default:
- break;
- }
- /* make sure it still is in the range */
- if (rate < IB_MIN_RATE || rate > IB_MAX_RATE) {
- OSM_LOG(p_log, OSM_LOG_DEBUG,
- "Calculated RATE %x is out of range\n", rate);
- return FALSE;
- }
- }
- p_mcm_rec->rate = (rate_sel << 6) | rate;
-
- OSM_LOG_EXIT(sa->p_log);
- return TRUE;
-}
-
-/**********************************************************************
- Call this function to create a new mgrp.
-**********************************************************************/
-ib_api_status_t
-osm_mcmr_rcv_create_new_mgrp(IN osm_sa_t * sa,
- IN ib_net64_t comp_mask,
- IN const ib_member_rec_t *
- const p_recvd_mcmember_rec,
- IN const osm_physp_t * const p_physp,
- OUT osm_mgrp_t ** pp_mgrp)
-{
- ib_net16_t mlid;
- unsigned zero_mgid, i;
- uint8_t scope;
- ib_gid_t *p_mgid;
- osm_mgrp_t *p_prev_mgrp;
- ib_api_status_t status = IB_SUCCESS;
- ib_member_rec_t mcm_rec = *p_recvd_mcmember_rec; /* copy for modifications */
-
- OSM_LOG_ENTER(sa->p_log);
-
- /* but what if the given MGID was not 0 ? */
- zero_mgid = 1;
- for (i = 0; i < sizeof(p_recvd_mcmember_rec->mgid); i++)
- if (p_recvd_mcmember_rec->mgid.raw[i] != 0) {
- zero_mgid = 0;
- break;
- }
-
- /*
- we allocate a new mlid number before we might use it
- for MGID ...
- */
- mlid = __get_new_mlid(sa, mcm_rec.mlid);
- if (mlid == 0) {
- OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 1B19: "
- "__get_new_mlid failed request mlid 0x%04x\n", cl_ntoh16(mcm_rec.mlid));
- status = IB_SA_MAD_STATUS_NO_RESOURCES;
- goto Exit;
- }
-
- OSM_LOG(sa->p_log, OSM_LOG_DEBUG,
- "Obtained new mlid 0x%X\n", cl_ntoh16(mlid));
-
- /* we need to create the new MGID if it was not defined */
- if (zero_mgid) {
- /* create a new MGID */
- char gid_str[INET6_ADDRSTRLEN];
-
- /* use the given scope state only if requested! */
- if (comp_mask & IB_MCR_COMPMASK_SCOPE)
- ib_member_get_scope_state(p_recvd_mcmember_rec->
- scope_state, &scope, NULL);
- else
- /* to guarantee no collision with other subnets use local scope! */
- scope = IB_MC_SCOPE_LINK_LOCAL;
-
- p_mgid = &(mcm_rec.mgid);
- p_mgid->raw[0] = 0xFF;
- p_mgid->raw[1] = 0x10 | scope;
- p_mgid->raw[2] = 0xA0;
- p_mgid->raw[3] = 0x1B;
-
- /* HACK: use the SA port gid to make it globally unique */
- memcpy((&p_mgid->raw[4]),
- &sa->p_subn->opt.subnet_prefix, sizeof(uint64_t));
-
- /* HACK: how do we get a unique number - use the mlid twice */
- memcpy(&p_mgid->raw[10], &mlid, sizeof(uint16_t));
- memcpy(&p_mgid->raw[12], &mlid, sizeof(uint16_t));
- OSM_LOG(sa->p_log, OSM_LOG_DEBUG, "Allocated new MGID:%s\n",
- inet_ntop(AF_INET6, p_mgid->raw, gid_str,
- sizeof gid_str));
- } else if (!__validate_requested_mgid(sa, &mcm_rec)) {
- /* a specific MGID was requested so validate the resulting MGID */
- OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 1B22: "
- "Invalid requested MGID\n");
- __free_mlid(sa, mlid);
- status = IB_SA_MAD_STATUS_REQ_INVALID;
- goto Exit;
- }
-
- /* check the requested parameters are realizable */
- if (__mgrp_request_is_realizable(sa, comp_mask, &mcm_rec, p_physp) ==
- FALSE) {
- OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 1B26: "
- "Requested MGRP parameters are not realizable\n");
- __free_mlid(sa, mlid);
- status = IB_SA_MAD_STATUS_REQ_INVALID;
- goto Exit;
- }
-
- /* create a new MC Group */
- *pp_mgrp = osm_mgrp_new(mlid);
- if (*pp_mgrp == NULL) {
- OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 1B08: "
- "osm_mgrp_new failed\n");
- __free_mlid(sa, mlid);
- status = IB_SA_MAD_STATUS_NO_RESOURCES;
- goto Exit;
- }
-
- /* Initialize the mgrp */
- (*pp_mgrp)->mcmember_rec = mcm_rec;
- (*pp_mgrp)->mcmember_rec.mlid = mlid;
-
- /* the mcmember_record should have mtu_sel, rate_sel, and pkt_lifetime_sel = 2 */
- (*pp_mgrp)->mcmember_rec.mtu &= 0x3f;
- (*pp_mgrp)->mcmember_rec.mtu |= 2 << 6; /* exactly */
- (*pp_mgrp)->mcmember_rec.rate &= 0x3f;
- (*pp_mgrp)->mcmember_rec.rate |= 2 << 6; /* exactly */
- (*pp_mgrp)->mcmember_rec.pkt_life &= 0x3f;
- (*pp_mgrp)->mcmember_rec.pkt_life |= 2 << 6; /* exactly */
-
- /* Insert the new group in the data base */
-
- /* since we might have an old group by that mlid
- one whose deletion was delayed for an idle time
- we need to deallocate it first */
- p_prev_mgrp = osm_get_mgrp_by_mlid(sa->p_subn, mlid);
- if (p_prev_mgrp) {
- OSM_LOG(sa->p_log, OSM_LOG_DEBUG,
- "Found previous group for mlid:0x%04x - "
- "Destroying it first\n",
- cl_ntoh16(mlid));
- sa->p_subn->mgroups[cl_ntoh16(mlid) - IB_LID_MCAST_START_HO] = NULL;
- osm_mgrp_delete(p_prev_mgrp);
- }
-
- sa->p_subn->mgroups[cl_ntoh16(mlid) - IB_LID_MCAST_START_HO] = *pp_mgrp;
-
-Exit:
- OSM_LOG_EXIT(sa->p_log);
- return status;
-}
-
-/**********************************************************************
- *********************************************************************/
-static unsigned match_mgrp_by_mgid(IN osm_mgrp_t * const p_mgrp, ib_gid_t *mgid)
-{
- /* ignore groups marked for deletion */
- if (p_mgrp->to_be_deleted ||
- memcmp(&p_mgrp->mcmember_rec.mgid, mgid, sizeof(ib_gid_t)))
- return 0;
- else
- return 1;
-}
-
-/**********************************************************************
- **********************************************************************/
-#define PREFIX_MASK CL_HTON64(0xff10ffff0000ffffULL)
-#define PREFIX_SIGNATURE CL_HTON64(0xff10601b00000000ULL)
-#define INT_ID_MASK CL_HTON64(0xfffffff1ff000000ULL)
-#define INT_ID_SIGNATURE CL_HTON64(0x00000001ff000000ULL)
-
-/* Special Case IPv6 Solicited Node Multicast (SNM) addresses */
-/* 0xff1Z601bXXXX0000 : 0x00000001ffYYYYYY */
-/* Where Z is the scope, XXXX is the P_Key, and
- * YYYYYY is the last 24 bits of the port guid */
-static unsigned match_and_update_ipv6_snm_mgid(ib_gid_t *mgid)
-{
- if ((mgid->unicast.prefix & PREFIX_MASK) == PREFIX_SIGNATURE &&
- (mgid->unicast.interface_id & INT_ID_MASK) == INT_ID_SIGNATURE) {
- mgid->unicast.prefix &= PREFIX_MASK;
- mgid->unicast.interface_id &= INT_ID_MASK;
- return 1;
- }
- return 0;
-}
-
-osm_mgrp_t *osm_get_mgrp_by_mgid(IN osm_sa_t *sa, IN ib_gid_t *p_mgid)
-{
- int i;
-
- if (sa->p_subn->opt.consolidate_ipv6_snm_req &&
- match_and_update_ipv6_snm_mgid(p_mgid)) {
- char gid_str[INET6_ADDRSTRLEN];
- OSM_LOG(sa->p_log, OSM_LOG_DEBUG,
- "Special Case Solicited Node Mcast Join for MGID %s\n",
- inet_ntop(AF_INET6, p_mgid->raw, gid_str,
- sizeof gid_str));
- }
-
- for (i = 0; i <= sa->p_subn->max_mcast_lid_ho - IB_LID_MCAST_START_HO;
- i++)
- if (sa->p_subn->mgroups[i] &&
- match_mgrp_by_mgid(sa->p_subn->mgroups[i], p_mgid))
- return sa->p_subn->mgroups[i];
-
- return NULL;
-}
-
-/**********************************************************************
- Call this function to find or create a new mgrp.
-**********************************************************************/
-ib_api_status_t
-osm_mcmr_rcv_find_or_create_new_mgrp(IN osm_sa_t * sa,
- IN ib_net64_t comp_mask,
- IN ib_member_rec_t *
- const p_recvd_mcmember_rec,
- OUT osm_mgrp_t ** pp_mgrp)
-{
- osm_mgrp_t *mgrp;
-
- if ((mgrp = osm_get_mgrp_by_mgid(sa, &p_recvd_mcmember_rec->mgid))) {
- *pp_mgrp = mgrp;
- return IB_SUCCESS;
- }
- return osm_mcmr_rcv_create_new_mgrp(sa, comp_mask,
- p_recvd_mcmember_rec, NULL,
- pp_mgrp);
-}
-
-/*********************************************************************
-Process a request for leaving the group
-**********************************************************************/
-static void
-__osm_mcmr_rcv_leave_mgrp(IN osm_sa_t * sa,
- IN osm_madw_t * const p_madw)
-{
- osm_mgrp_t *p_mgrp;
- ib_sa_mad_t *p_sa_mad;
- ib_member_rec_t *p_recvd_mcmember_rec;
- ib_member_rec_t mcmember_rec;
- ib_net16_t mlid;
- ib_net64_t portguid;
- osm_mcm_port_t *p_mcm_port;
- int removed;
-
- OSM_LOG_ENTER(sa->p_log);
-
- p_sa_mad = osm_madw_get_sa_mad_ptr(p_madw);
- p_recvd_mcmember_rec =
- (ib_member_rec_t *) ib_sa_mad_get_payload_ptr(p_sa_mad);
-
- mcmember_rec = *p_recvd_mcmember_rec;
-
- if (osm_log_is_active(sa->p_log, OSM_LOG_DEBUG)) {
- OSM_LOG(sa->p_log, OSM_LOG_DEBUG, "Dump of record\n");
- osm_dump_mc_record(sa->p_log, &mcmember_rec, OSM_LOG_DEBUG);
- }
-
- CL_PLOCK_EXCL_ACQUIRE(sa->p_lock);
- p_mgrp = osm_get_mgrp_by_mgid(sa, &p_recvd_mcmember_rec->mgid);
- if (!p_mgrp) {
- char gid_str[INET6_ADDRSTRLEN];
- CL_PLOCK_RELEASE(sa->p_lock);
- OSM_LOG(sa->p_log, OSM_LOG_DEBUG,
- "Failed since multicast group %s not present\n",
- inet_ntop(AF_INET6, p_recvd_mcmember_rec->mgid.raw,
- gid_str, sizeof gid_str));
- osm_sa_send_error(sa, p_madw, IB_SA_MAD_STATUS_REQ_INVALID);
- goto Exit;
- }
-
- mlid = p_mgrp->mlid;
- portguid = p_recvd_mcmember_rec->port_gid.unicast.interface_id;
-
- /* check validity of the delete request o15-0.1.14 */
- if (!__validate_delete(sa, p_mgrp, osm_madw_get_mad_addr_ptr(p_madw),
- p_recvd_mcmember_rec, &p_mcm_port)) {
- char gid_str[INET6_ADDRSTRLEN];
- char gid_str2[INET6_ADDRSTRLEN];
- CL_PLOCK_RELEASE(sa->p_lock);
- OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 1B25: "
- "Received an invalid delete request for "
- "MGID: %s for PortGID: %s\n",
- inet_ntop(AF_INET6, p_recvd_mcmember_rec->mgid.raw,
- gid_str, sizeof gid_str),
- inet_ntop(AF_INET6, p_recvd_mcmember_rec->port_gid.raw,
- gid_str2, sizeof gid_str2));
- osm_sa_send_error(sa, p_madw, IB_SA_MAD_STATUS_REQ_INVALID);
- goto Exit;
- }
-
- /* store state - we'll need it if the port is removed */
- mcmember_rec.scope_state = p_mcm_port->scope_state;
-
- /* remove port or update join state */
- removed = osm_mgrp_remove_port(sa->p_subn, sa->p_log, p_mgrp, p_mcm_port,
- p_recvd_mcmember_rec->scope_state&0x0F);
- if (!removed)
- mcmember_rec.scope_state = p_mcm_port->scope_state;
-
- CL_PLOCK_RELEASE(sa->p_lock);
-
- /* we can leave if port was deleted from MCG */
- if (removed && osm_sm_mcgrp_leave(sa->sm, mlid, portguid))
- OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 1B09: "
- "osm_sm_mcgrp_leave failed\n");
-
- /* Send an SA response */
- __osm_mcmr_rcv_respond(sa, p_madw, &mcmember_rec);
-
-Exit:
- OSM_LOG_EXIT(sa->p_log);
-}
-
-/**********************************************************************
- Handle a join (or create) request
-**********************************************************************/
-static void
-__osm_mcmr_rcv_join_mgrp(IN osm_sa_t * sa, IN osm_madw_t * const p_madw)
-{
- osm_mgrp_t *p_mgrp = NULL;
- ib_api_status_t status;
- ib_sa_mad_t *p_sa_mad;
- ib_member_rec_t *p_recvd_mcmember_rec;
- ib_member_rec_t mcmember_rec;
- ib_net16_t mlid;
- osm_mcm_port_t *p_mcmr_port;
- ib_net64_t portguid;
- osm_port_t *p_port;
- osm_physp_t *p_physp;
- osm_physp_t *p_request_physp;
- uint8_t is_new_group; /* TRUE = there is a need to create a group */
- osm_mcast_req_type_t req_type;
- uint8_t join_state;
-
- OSM_LOG_ENTER(sa->p_log);
-
- p_sa_mad = osm_madw_get_sa_mad_ptr(p_madw);
- p_recvd_mcmember_rec = ib_sa_mad_get_payload_ptr(p_sa_mad);
-
- portguid = p_recvd_mcmember_rec->port_gid.unicast.interface_id;
-
- mcmember_rec = *p_recvd_mcmember_rec;
-
- if (osm_log_is_active(sa->p_log, OSM_LOG_DEBUG)) {
- OSM_LOG(sa->p_log, OSM_LOG_DEBUG, "Dump of incoming record\n");
- osm_dump_mc_record(sa->p_log, &mcmember_rec, OSM_LOG_DEBUG);
- }
-
- CL_PLOCK_EXCL_ACQUIRE(sa->p_lock);
-
- /* make sure the requested port guid is known to the SM */
- p_port = osm_get_port_by_guid(sa->p_subn, portguid);
- if (!p_port) {
- CL_PLOCK_RELEASE(sa->p_lock);
-
- OSM_LOG(sa->p_log, OSM_LOG_DEBUG,
- "Unknown port GUID 0x%016" PRIx64 "\n",
- cl_ntoh64(portguid));
- osm_sa_send_error(sa, p_madw, IB_SA_MAD_STATUS_REQ_INVALID);
- goto Exit;
- }
-
- p_physp = p_port->p_physp;
- /* Check that the p_physp and the requester physp are in the same
- partition. */
- p_request_physp =
- osm_get_physp_by_mad_addr(sa->p_log, sa->p_subn,
- osm_madw_get_mad_addr_ptr(p_madw));
- if (p_request_physp == NULL) {
- CL_PLOCK_RELEASE(sa->p_lock);
- goto Exit;
- }
-
- if (!osm_physp_share_pkey(sa->p_log, p_physp, p_request_physp)) {
- CL_PLOCK_RELEASE(sa->p_lock);
-
- OSM_LOG(sa->p_log, OSM_LOG_DEBUG,
- "Port and requester don't share pkey\n");
- osm_sa_send_error(sa, p_madw, IB_SA_MAD_STATUS_REQ_INVALID);
- goto Exit;
- }
-
- ib_member_get_scope_state(p_recvd_mcmember_rec->scope_state, NULL,
- &join_state);
-
- /* do we need to create a new group? */
- p_mgrp = osm_get_mgrp_by_mgid(sa, &p_recvd_mcmember_rec->mgid);
- if (!p_mgrp || p_mgrp->to_be_deleted) {
- /* check for JoinState.FullMember = 1 o15.0.1.9 */
- if ((join_state & 0x01) != 0x01) {
- char gid_str[INET6_ADDRSTRLEN];
- CL_PLOCK_RELEASE(sa->p_lock);
- OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 1B10: "
- "Provided Join State != FullMember - "
- "required for create, "
- "MGID: %s from port 0x%016" PRIx64 " (%s)\n",
- inet_ntop(AF_INET6,
- p_recvd_mcmember_rec->mgid.raw,
- gid_str, sizeof gid_str),
- cl_ntoh64(portguid),
- p_port->p_node->print_desc);
- osm_sa_send_error(sa, p_madw,
- IB_SA_MAD_STATUS_REQ_INVALID);
- goto Exit;
- }
-
- /* check the comp_mask */
- if (!__check_create_comp_mask(p_sa_mad->comp_mask,
- p_recvd_mcmember_rec)) {
- char gid_str[INET6_ADDRSTRLEN];
- CL_PLOCK_RELEASE(sa->p_lock);
-
- OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 1B11: "
- "method = %s, scope_state = 0x%x, "
- "component mask = 0x%016" PRIx64 ", "
- "expected comp mask = 0x%016" PRIx64 ", "
- "MGID: %s from port 0x%016" PRIx64 " (%s)\n",
- ib_get_sa_method_str(p_sa_mad->method),
- p_recvd_mcmember_rec->scope_state,
- cl_ntoh64(p_sa_mad->comp_mask),
- CL_NTOH64(REQUIRED_MC_CREATE_COMP_MASK),
- inet_ntop(AF_INET6,
- p_recvd_mcmember_rec->mgid.raw,
- gid_str, sizeof gid_str),
- cl_ntoh64(portguid),
- p_port->p_node->print_desc);
-
- osm_sa_send_error(sa, p_madw,
- IB_SA_MAD_STATUS_INSUF_COMPS);
- goto Exit;
- }
-
- status = osm_mcmr_rcv_create_new_mgrp(sa, p_sa_mad->comp_mask,
- p_recvd_mcmember_rec,
- p_physp, &p_mgrp);
- if (status != IB_SUCCESS) {
- CL_PLOCK_RELEASE(sa->p_lock);
- osm_sa_send_error(sa, p_madw, status);
- goto Exit;
- }
- /* copy the MGID to the result */
- mcmember_rec.mgid = p_mgrp->mcmember_rec.mgid;
- is_new_group = 1;
- req_type = OSM_MCAST_REQ_TYPE_CREATE;
- } else {
- /* no need for a new group */
- is_new_group = 0;
- req_type = OSM_MCAST_REQ_TYPE_JOIN;
- }
-
- CL_ASSERT(p_mgrp);
- mlid = p_mgrp->mlid;
-
- /*
- * o15-0.2.4: If SA supports UD multicast, then SA shall cause an
- * endport to join an existing multicast group if:
- * 1. It receives a SubnAdmSet() method for a MCMemberRecord, and
- * - WE KNOW THAT ALREADY
- * 2. The MGID is specified and matches an existing multicast
- * group, and
- * - WE KNOW THAT ALREADY
- * 3. The MCMemberRecord:JoinState is not all 0s, and
- * 4. PortGID is specified and
- * - WE KNOW THAT ALREADY (as it matched a real one)
- * 5. All other components match that existing group, either by
- * being wildcarded or by having values identical to those specified
- * by the component mask and in use by the group with the exception
- * of components such as ProxyJoin and Reserved, which are ignored
- * by SA.
- *
- * We need to check #3 and #5 here:
- */
- if (!__validate_more_comp_fields(sa->p_log, p_mgrp,
- p_recvd_mcmember_rec,
- p_sa_mad->comp_mask)
- || !__validate_port_caps(sa->p_log, p_mgrp, p_physp)
- || !(join_state != 0)) {
- /* since we might have created the new group we need to cleanup */
- __cleanup_mgrp(sa, p_mgrp);
-
- CL_PLOCK_RELEASE(sa->p_lock);
-
- OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 1B12: "
- "__validate_more_comp_fields, __validate_port_caps, "
- "or JoinState = 0 failed from port 0x%016" PRIx64
- " (%s), " "sending IB_SA_MAD_STATUS_REQ_INVALID\n",
- cl_ntoh64(portguid), p_port->p_node->print_desc);
-
- osm_sa_send_error(sa, p_madw, IB_SA_MAD_STATUS_REQ_INVALID);
- goto Exit;
- }
-
- /*
- * o15-0.2.1 requires validation of the requesting port
- * in the case of modification:
- */
- if (!is_new_group &&
- !__validate_modify(sa, p_mgrp, osm_madw_get_mad_addr_ptr(p_madw),
- p_recvd_mcmember_rec, &p_mcmr_port)) {
- CL_PLOCK_RELEASE(sa->p_lock);
-
- OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 1B13: "
- "__validate_modify failed from port 0x%016" PRIx64
- " (%s), sending IB_SA_MAD_STATUS_REQ_INVALID\n",
- cl_ntoh64(portguid), p_port->p_node->print_desc);
-
- osm_sa_send_error(sa, p_madw, IB_SA_MAD_STATUS_REQ_INVALID);
- goto Exit;
- }
-
- /* create or update existing port (join-state will be updated) */
- status = __add_new_mgrp_port(sa, p_mgrp, p_recvd_mcmember_rec,
- osm_madw_get_mad_addr_ptr(p_madw),
- &p_mcmr_port);
-
- if (status != IB_SUCCESS) {
- /* we fail to add the port so we might need to delete the group */
- __cleanup_mgrp(sa, p_mgrp);
-
- CL_PLOCK_RELEASE(sa->p_lock);
-
- osm_sa_send_error(sa, p_madw, status == IB_INVALID_PARAMETER ?
- IB_SA_MAD_STATUS_REQ_INVALID :
- IB_SA_MAD_STATUS_NO_RESOURCES);
- goto Exit;
- }
-
- /* o15.0.1.11: copy the join state */
- mcmember_rec.scope_state = p_mcmr_port->scope_state;
-
- /* copy qkey mlid tclass pkey sl_flow_hop mtu rate pkt_life sl_flow_hop */
- __copy_from_create_mc_rec(&mcmember_rec, &p_mgrp->mcmember_rec);
-
- /* Release the lock as we don't need it. */
- CL_PLOCK_RELEASE(sa->p_lock);
-
- /* do the actual routing (actually schedule the update) */
- status = osm_sm_mcgrp_join(sa->sm, mlid,
- p_recvd_mcmember_rec->port_gid.unicast.
- interface_id, req_type);
-
- if (status != IB_SUCCESS) {
- OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 1B14: "
- "osm_sm_mcgrp_join failed from port 0x%016" PRIx64
- " (%s), " "sending IB_SA_MAD_STATUS_NO_RESOURCES\n",
- cl_ntoh64(portguid), p_port->p_node->print_desc);
-
- CL_PLOCK_EXCL_ACQUIRE(sa->p_lock);
-
- /* the request for routing failed so we need to remove the port */
- osm_mgrp_delete_port(sa->p_subn, sa->p_log, p_mgrp,
- p_recvd_mcmember_rec->port_gid.
- unicast.interface_id);
- __cleanup_mgrp(sa, p_mgrp);
- CL_PLOCK_RELEASE(sa->p_lock);
- osm_sa_send_error(sa, p_madw, IB_SA_MAD_STATUS_NO_RESOURCES);
- goto Exit;
-
- }
- /* failed to route */
- if (osm_log_is_active(sa->p_log, OSM_LOG_DEBUG))
- osm_dump_mc_record(sa->p_log, &mcmember_rec, OSM_LOG_DEBUG);
-
- __osm_mcmr_rcv_respond(sa, p_madw, &mcmember_rec);
-
-Exit:
- OSM_LOG_EXIT(sa->p_log);
-}
-
-/**********************************************************************
- Add a patched multicast group to the results list
-**********************************************************************/
-static ib_api_status_t
-__osm_mcmr_rcv_new_mcmr(IN osm_sa_t * sa,
- IN const ib_member_rec_t * p_rcvd_rec,
- IN cl_qlist_t * const p_list)
-{
- osm_mcmr_item_t *p_rec_item;
- ib_api_status_t status = IB_SUCCESS;
-
- OSM_LOG_ENTER(sa->p_log);
-
- p_rec_item = malloc(sizeof(*p_rec_item));
- if (p_rec_item == NULL) {
- OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 1B15: "
- "rec_item alloc failed\n");
- status = IB_INSUFFICIENT_RESOURCES;
- goto Exit;
- }
-
- memset(p_rec_item, 0, sizeof(*p_rec_item));
-
- /* HACK: Untrusted requesters should result with 0 Join
- State, Port Guid, and Proxy */
- p_rec_item->rec = *p_rcvd_rec;
- cl_qlist_insert_tail(p_list, &p_rec_item->list_item);
-
-Exit:
- OSM_LOG_EXIT(sa->p_log);
- return (status);
-}
-
-/**********************************************************************
- Match the given mgrp to the requested mcmr
-**********************************************************************/
-static void mcmr_by_comp_mask(osm_sa_t *sa, const ib_member_rec_t *p_rcvd_rec,
- ib_net64_t comp_mask, osm_mgrp_t *p_mgrp,
- const osm_physp_t *p_req_physp,
- boolean_t trusted_req, cl_qlist_t *list)
-{
- /* since we might change scope_state */
- ib_member_rec_t match_rec;
- osm_mcm_port_t *p_mcm_port;
- ib_net64_t portguid = p_rcvd_rec->port_gid.unicast.interface_id;
- /* will be used for group or port info */
- uint8_t scope_state;
- uint8_t scope_state_mask = 0;
- cl_map_item_t *p_item;
- ib_gid_t port_gid;
- boolean_t proxy_join = FALSE;
-
- OSM_LOG_ENTER(sa->p_log);
-
- OSM_LOG(sa->p_log, OSM_LOG_DEBUG,
- "Checking mlid:0x%X\n", cl_ntoh16(p_mgrp->mlid));
-
- /* the group might be marked for deletion */
- if (p_mgrp->to_be_deleted) {
- OSM_LOG(sa->p_log, OSM_LOG_DEBUG,
- "Group mlid:0x%X is marked to be deleted\n",
- cl_ntoh16(p_mgrp->mlid));
- goto Exit;
- }
-
- /* first try to eliminate the group by MGID, MLID, or P_Key */
- if ((IB_MCR_COMPMASK_MGID & comp_mask) &&
- memcmp(&p_rcvd_rec->mgid, &p_mgrp->mcmember_rec.mgid,
- sizeof(ib_gid_t)))
- goto Exit;
-
- if ((IB_MCR_COMPMASK_MLID & comp_mask) &&
- memcmp(&p_rcvd_rec->mlid, &p_mgrp->mcmember_rec.mlid,
- sizeof(uint16_t)))
- goto Exit;
-
- /* if the requester physical port doesn't have the pkey that is defined
- for the group - exit. */
- if (!osm_physp_has_pkey(sa->p_log, p_mgrp->mcmember_rec.pkey,
- p_req_physp))
- goto Exit;
-
- /* now do the rest of the match */
- if ((IB_MCR_COMPMASK_QKEY & comp_mask) &&
- p_rcvd_rec->qkey != p_mgrp->mcmember_rec.qkey)
- goto Exit;
-
- if ((IB_MCR_COMPMASK_PKEY & comp_mask) &&
- p_rcvd_rec->pkey != p_mgrp->mcmember_rec.pkey)
- goto Exit;
-
- if ((IB_MCR_COMPMASK_TCLASS & comp_mask) &&
- p_rcvd_rec->tclass != p_mgrp->mcmember_rec.tclass)
- goto Exit;
-
- /* check SL, Flow, and Hop limit */
- {
- uint8_t mgrp_sl, query_sl;
- uint32_t mgrp_flow, query_flow;
- uint8_t mgrp_hop, query_hop;
-
- ib_member_get_sl_flow_hop(p_rcvd_rec->sl_flow_hop,
- &query_sl, &query_flow, &query_hop);
-
- ib_member_get_sl_flow_hop(p_mgrp->mcmember_rec.sl_flow_hop,
- &mgrp_sl, &mgrp_flow, &mgrp_hop);
-
- if ((IB_MCR_COMPMASK_SL & comp_mask) && query_sl != mgrp_sl)
- goto Exit;
-
- if ((IB_MCR_COMPMASK_FLOW & comp_mask) &&
- query_flow != mgrp_flow)
- goto Exit;
-
- if ((IB_MCR_COMPMASK_HOP & comp_mask) && query_hop != mgrp_hop)
- goto Exit;
- }
-
- if ((IB_MCR_COMPMASK_PROXY & comp_mask) &&
- p_rcvd_rec->proxy_join != p_mgrp->mcmember_rec.proxy_join)
- goto Exit;
-
- /* need to validate mtu, rate, and pkt_lifetime fields */
- if (__validate_more_comp_fields(sa->p_log, p_mgrp, p_rcvd_rec,
- comp_mask) == FALSE)
- goto Exit;
-
- /* Port specific fields */
- /* so did we get the PortGUID mask */
- if (IB_MCR_COMPMASK_PORT_GID & comp_mask) {
- /* try to find this port */
- if (osm_mgrp_is_port_present(p_mgrp, portguid, &p_mcm_port)) {
- scope_state = p_mcm_port->scope_state;
- memcpy(&port_gid, &(p_mcm_port->port_gid),
- sizeof(ib_gid_t));
- proxy_join = p_mcm_port->proxy_join;
- } else {
- /* port not in group */
- goto Exit;
- }
- } else {
- /* point to the group information */
- scope_state = p_mgrp->mcmember_rec.scope_state;
- }
-
- if (IB_MCR_COMPMASK_SCOPE & comp_mask)
- scope_state_mask = 0xF0;
-
- if (IB_MCR_COMPMASK_JOIN_STATE & comp_mask)
- scope_state_mask = scope_state_mask | 0x0F;
-
- /* Many MC records returned */
- if (trusted_req == TRUE
- && !(IB_MCR_COMPMASK_PORT_GID & comp_mask)) {
- char gid_str[INET6_ADDRSTRLEN];
- OSM_LOG(sa->p_log, OSM_LOG_DEBUG,
- "Trusted req is TRUE and no specific port defined\n");
-
- /* return all the ports that match in this MC group */
- p_item = cl_qmap_head(&(p_mgrp->mcm_port_tbl));
- while (p_item != cl_qmap_end(&(p_mgrp->mcm_port_tbl))) {
- p_mcm_port = (osm_mcm_port_t *) p_item;
-
- if ((scope_state_mask & p_rcvd_rec->scope_state) ==
- (scope_state_mask & p_mcm_port->scope_state)) {
- /* add to the list */
- match_rec = p_mgrp->mcmember_rec;
- match_rec.scope_state = p_mcm_port->scope_state;
- memcpy(&(match_rec.port_gid),
- &(p_mcm_port->port_gid),
- sizeof(ib_gid_t));
- OSM_LOG(sa->p_log, OSM_LOG_DEBUG,
- "Record of port_gid: %s"
- " in multicast_lid: 0x%X is returned\n",
- inet_ntop(AF_INET6, match_rec.port_gid.raw,
- gid_str, sizeof gid_str),
- cl_ntoh16(p_mgrp->mlid));
-
- match_rec.proxy_join =
- (uint8_t) (p_mcm_port->proxy_join);
-
- __osm_mcmr_rcv_new_mcmr(sa, &match_rec, list);
- }
- p_item = cl_qmap_next(p_item);
- }
- }
- /* One MC record returned */
- else {
- if ((scope_state_mask & p_rcvd_rec->scope_state) !=
- (scope_state_mask & scope_state))
- goto Exit;
-
- /* add to the list */
- match_rec = p_mgrp->mcmember_rec;
- match_rec.scope_state = scope_state;
- memcpy(&(match_rec.port_gid), &port_gid, sizeof(ib_gid_t));
- match_rec.proxy_join = (uint8_t) proxy_join;
-
- __osm_mcmr_rcv_new_mcmr(sa, &match_rec, list);
- }
-
-Exit:
- OSM_LOG_EXIT(sa->p_log);
-}
-
-/**********************************************************************
- Handle a query request
-**********************************************************************/
-static void
-__osm_mcmr_query_mgrp(IN osm_sa_t * sa,
- IN osm_madw_t * const p_madw)
-{
- const ib_sa_mad_t *p_rcvd_mad;
- const ib_member_rec_t *p_rcvd_rec;
- cl_qlist_t rec_list;
- ib_net64_t comp_mask;
- osm_physp_t *p_req_physp;
- boolean_t trusted_req;
- osm_mgrp_t *p_mgrp;
- int i;
-
- OSM_LOG_ENTER(sa->p_log);
-
- p_rcvd_mad = osm_madw_get_sa_mad_ptr(p_madw);
- p_rcvd_rec = (ib_member_rec_t *) ib_sa_mad_get_payload_ptr(p_rcvd_mad);
- comp_mask = p_rcvd_mad->comp_mask;
-
- /*
- if sm_key is not zero and does not match we never get here
- see main SA receiver
- */
- trusted_req = (p_rcvd_mad->sm_key != 0);
-
- /* update the requester physical port. */
- p_req_physp = osm_get_physp_by_mad_addr(sa->p_log, sa->p_subn,
- osm_madw_get_mad_addr_ptr
- (p_madw));
- if (p_req_physp == NULL) {
- OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 1B04: "
- "Cannot find requester physical port\n");
- goto Exit;
- }
-
- cl_qlist_init(&rec_list);
-
- CL_PLOCK_ACQUIRE(sa->p_lock);
-
- /* simply go over all MCGs and match */
- for (i = 0; i <= sa->p_subn->max_mcast_lid_ho - IB_LID_MCAST_START_HO;
- i++) {
- p_mgrp = sa->p_subn->mgroups[i];
- if (p_mgrp)
- mcmr_by_comp_mask(sa, p_rcvd_rec, comp_mask, p_mgrp,
- p_req_physp, trusted_req, &rec_list);
- }
-
- CL_PLOCK_RELEASE(sa->p_lock);
-
- /*
- p923 - The PortGID, JoinState and ProxyJoin shall be zero,
- except in the case of a trusted request.
- Note: In the mad controller we check that the SM_Key received on
- the mad is valid. Meaning - is either zero or equal to the local
- sm_key.
- */
-
- if (!p_rcvd_mad->sm_key) {
- osm_mcmr_item_t *item;
- for (item = (osm_mcmr_item_t *) cl_qlist_head(&rec_list);
- item != (osm_mcmr_item_t *) cl_qlist_end(&rec_list);
- item = (osm_mcmr_item_t *)cl_qlist_next(&item->list_item)) {
- memset(&item->rec.port_gid, 0, sizeof(ib_gid_t));
- ib_member_set_join_state(&item->rec, 0);
- item->rec.proxy_join = 0;
- }
- }
-
- osm_sa_respond(sa, p_madw, sizeof(ib_member_rec_t), &rec_list);
-
-Exit:
- OSM_LOG_EXIT(sa->p_log);
-}
-
-/**********************************************************************
- **********************************************************************/
-void osm_mcmr_rcv_process(IN void *context, IN void *data)
-{
- osm_sa_t *sa = context;
- osm_madw_t *p_madw = data;
- ib_sa_mad_t *p_sa_mad;
- ib_member_rec_t *p_recvd_mcmember_rec;
-
- CL_ASSERT(sa);
-
- OSM_LOG_ENTER(sa->p_log);
-
- CL_ASSERT(p_madw);
-
- p_sa_mad = osm_madw_get_sa_mad_ptr(p_madw);
- p_recvd_mcmember_rec =
- (ib_member_rec_t *) ib_sa_mad_get_payload_ptr(p_sa_mad);
-
- CL_ASSERT(p_sa_mad->attr_id == IB_MAD_ATTR_MCMEMBER_RECORD);
-
- switch (p_sa_mad->method) {
- case IB_MAD_METHOD_SET:
- if (!__check_join_comp_mask(p_sa_mad->comp_mask)) {
- char gid_str[INET6_ADDRSTRLEN];
- char gid_str2[INET6_ADDRSTRLEN];
- OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 1B18: "
- "component mask = 0x%016" PRIx64 ", "
- "expected comp mask = 0x%016" PRIx64 ", "
- "MGID: %s for PortGID: %s\n",
- cl_ntoh64(p_sa_mad->comp_mask),
- CL_NTOH64(JOIN_MC_COMP_MASK),
- inet_ntop(AF_INET6,
- p_recvd_mcmember_rec->mgid.raw,
- gid_str, sizeof gid_str),
- inet_ntop(AF_INET6,
- p_recvd_mcmember_rec->port_gid.raw,
- gid_str2, sizeof gid_str2));
-
- osm_sa_send_error(sa, p_madw,
- IB_SA_MAD_STATUS_REQ_INVALID);
- goto Exit;
- }
-
- /*
- * Join or Create Multicast Group
- */
- __osm_mcmr_rcv_join_mgrp(sa, p_madw);
- break;
- case IB_MAD_METHOD_DELETE:
- if (!__check_join_comp_mask(p_sa_mad->comp_mask)) {
- OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 1B20: "
- "component mask = 0x%016" PRIx64 ", "
- "expected comp mask = 0x%016" PRIx64 "\n",
- cl_ntoh64(p_sa_mad->comp_mask),
- CL_NTOH64(JOIN_MC_COMP_MASK));
-
- osm_sa_send_error(sa, p_madw,
- IB_SA_MAD_STATUS_REQ_INVALID);
- goto Exit;
- }
-
- /*
- * Leave Multicast Group
- */
- __osm_mcmr_rcv_leave_mgrp(sa, p_madw);
- break;
- case IB_MAD_METHOD_GET:
- case IB_MAD_METHOD_GETTABLE:
- /*
- * Querying a Multicast Group
- */
- __osm_mcmr_query_mgrp(sa, p_madw);
- break;
- default:
- OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 1B21: "
- "Unsupported Method (%s)\n",
- ib_get_sa_method_str(p_sa_mad->method));
- osm_sa_send_error(sa, p_madw,
- IB_MAD_STATUS_UNSUP_METHOD_ATTR);
- break;
- }
-
-Exit:
- OSM_LOG_EXIT(sa->p_log);
- return;
-}
diff --git a/contrib/ofed/management/opensm/opensm/osm_sa_mft_record.c b/contrib/ofed/management/opensm/opensm/osm_sa_mft_record.c
deleted file mode 100644
index bda9aee..0000000
--- a/contrib/ofed/management/opensm/opensm/osm_sa_mft_record.c
+++ /dev/null
@@ -1,280 +0,0 @@
-/*
- * Copyright (c) 2004-2008 Voltaire, Inc. All rights reserved.
- * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved.
- * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- */
-
-/*
- * Abstract:
- * Implementation of osm_mftr_rcv_t.
- * This object represents the MulticastForwardingTable Receiver object.
- * This object is part of the opensm family of objects.
- */
-
-#if HAVE_CONFIG_H
-# include <config.h>
-#endif /* HAVE_CONFIG_H */
-
-#include <string.h>
-#include <iba/ib_types.h>
-#include <complib/cl_debug.h>
-#include <complib/cl_qlist.h>
-#include <vendor/osm_vendor_api.h>
-#include <opensm/osm_switch.h>
-#include <opensm/osm_helper.h>
-#include <opensm/osm_pkey.h>
-#include <opensm/osm_sa.h>
-
-typedef struct osm_mftr_item {
- cl_list_item_t list_item;
- ib_mft_record_t rec;
-} osm_mftr_item_t;
-
-typedef struct osm_mftr_search_ctxt {
- const ib_mft_record_t *p_rcvd_rec;
- ib_net64_t comp_mask;
- cl_qlist_t *p_list;
- osm_sa_t *sa;
- const osm_physp_t *p_req_physp;
-} osm_mftr_search_ctxt_t;
-
-/**********************************************************************
- **********************************************************************/
-static ib_api_status_t
-__osm_mftr_rcv_new_mftr(IN osm_sa_t * sa,
- IN osm_switch_t * const p_sw,
- IN cl_qlist_t * const p_list,
- IN ib_net16_t const lid,
- IN uint16_t const block, IN uint8_t const position)
-{
- osm_mftr_item_t *p_rec_item;
- ib_api_status_t status = IB_SUCCESS;
- uint16_t position_block_num;
-
- OSM_LOG_ENTER(sa->p_log);
-
- p_rec_item = malloc(sizeof(*p_rec_item));
- if (p_rec_item == NULL) {
- OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 4A02: "
- "rec_item alloc failed\n");
- status = IB_INSUFFICIENT_RESOURCES;
- goto Exit;
- }
-
- OSM_LOG(sa->p_log, OSM_LOG_DEBUG,
- "New MulticastForwardingTable: sw 0x%016" PRIx64
- "\n\t\t\t\tblock %u position %u lid %u\n",
- cl_ntoh64(osm_node_get_node_guid(p_sw->p_node)),
- block, position, cl_ntoh16(lid));
-
- position_block_num = ((uint16_t) position << 12) |
- (block & IB_MCAST_BLOCK_ID_MASK_HO);
-
- memset(p_rec_item, 0, sizeof(*p_rec_item));
-
- p_rec_item->rec.lid = lid;
- p_rec_item->rec.position_block_num = cl_hton16(position_block_num);
-
- /* copy the mft block */
- osm_switch_get_mft_block(p_sw, block, position, p_rec_item->rec.mft);
-
- cl_qlist_insert_tail(p_list, &p_rec_item->list_item);
-
-Exit:
- OSM_LOG_EXIT(sa->p_log);
- return (status);
-}
-
-/**********************************************************************
- **********************************************************************/
-static void
-__osm_mftr_rcv_by_comp_mask(IN cl_map_item_t * const p_map_item,
- IN void *context)
-{
- const osm_mftr_search_ctxt_t *const p_ctxt =
- (osm_mftr_search_ctxt_t *) context;
- osm_switch_t *const p_sw = (osm_switch_t *) p_map_item;
- const ib_mft_record_t *const p_rcvd_rec = p_ctxt->p_rcvd_rec;
- osm_sa_t *sa = p_ctxt->sa;
- ib_net64_t const comp_mask = p_ctxt->comp_mask;
- const osm_physp_t *const p_req_physp = p_ctxt->p_req_physp;
- osm_port_t *p_port;
- uint16_t min_lid_ho, max_lid_ho;
- uint16_t position_block_num_ho;
- uint16_t min_block, max_block, block;
- const osm_physp_t *p_physp;
- uint8_t min_position, max_position, position;
-
- /* In switches, the port guid is the node guid. */
- p_port =
- osm_get_port_by_guid(sa->p_subn, p_sw->p_node->node_info.port_guid);
- if (!p_port) {
- OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 4A05: "
- "Failed to find Port by Node Guid:0x%016" PRIx64
- "\n", cl_ntoh64(p_sw->p_node->node_info.node_guid));
- return;
- }
-
- /* check that the requester physp and the current physp are under
- the same partition. */
- p_physp = p_port->p_physp;
- if (!p_physp) {
- OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 4A06: "
- "Failed to find default physical Port by Node Guid:0x%016"
- PRIx64 "\n",
- cl_ntoh64(p_sw->p_node->node_info.node_guid));
- return;
- }
- if (!osm_physp_share_pkey(sa->p_log, p_req_physp, p_physp))
- return;
-
- /* get the port 0 of the switch */
- osm_port_get_lid_range_ho(p_port, &min_lid_ho, &max_lid_ho);
-
- /* compare the lids - if required */
- if (comp_mask & IB_MFTR_COMPMASK_LID) {
- OSM_LOG(sa->p_log, OSM_LOG_DEBUG,
- "Comparing lid:%u to port lid range: %u .. %u\n",
- cl_ntoh16(p_rcvd_rec->lid), min_lid_ho, max_lid_ho);
- /* ok we are ready for range check */
- if (min_lid_ho > cl_ntoh16(p_rcvd_rec->lid) ||
- max_lid_ho < cl_ntoh16(p_rcvd_rec->lid))
- return;
- }
-
- if (!osm_switch_supports_mcast(p_sw))
- return;
-
- /* Are there any blocks in use ? */
- if (osm_switch_get_mft_max_block_in_use(p_sw) == -1)
- return;
-
- position_block_num_ho = cl_ntoh16(p_rcvd_rec->position_block_num);
-
- /* now we need to decide which blocks to output */
- if (comp_mask & IB_MFTR_COMPMASK_BLOCK) {
- max_block = min_block =
- position_block_num_ho & IB_MCAST_BLOCK_ID_MASK_HO;
- if (max_block > osm_switch_get_mft_max_block_in_use(p_sw))
- return;
- } else {
- /* use as many blocks as needed */
- min_block = 0;
- max_block = osm_switch_get_mft_max_block_in_use(p_sw);
- }
-
- /* need to decide which positions to output */
- if (comp_mask & IB_MFTR_COMPMASK_POSITION) {
- min_position = max_position =
- (position_block_num_ho & 0xF000) >> 12;
- if (max_position > osm_switch_get_mft_max_position(p_sw))
- return;
- } else {
- /* use as many positions as needed */
- min_position = 0;
- max_position = osm_switch_get_mft_max_position(p_sw);
- }
-
- /* so we can add these one by one ... */
- for (block = min_block; block <= max_block; block++)
- for (position = min_position; position <= max_position;
- position++)
- __osm_mftr_rcv_new_mftr(sa, p_sw, p_ctxt->p_list,
- osm_port_get_base_lid(p_port),
- block, position);
-}
-
-/**********************************************************************
- **********************************************************************/
-void osm_mftr_rcv_process(IN void *ctx, IN void *data)
-{
- osm_sa_t *sa = ctx;
- osm_madw_t *p_madw = data;
- const ib_sa_mad_t *p_rcvd_mad;
- const ib_mft_record_t *p_rcvd_rec;
- cl_qlist_t rec_list;
- osm_mftr_search_ctxt_t context;
- osm_physp_t *p_req_physp;
-
- CL_ASSERT(sa);
-
- OSM_LOG_ENTER(sa->p_log);
-
- CL_ASSERT(p_madw);
-
- p_rcvd_mad = osm_madw_get_sa_mad_ptr(p_madw);
- p_rcvd_rec = (ib_mft_record_t *) ib_sa_mad_get_payload_ptr(p_rcvd_mad);
-
- CL_ASSERT(p_rcvd_mad->attr_id == IB_MAD_ATTR_MFT_RECORD);
-
- /* we only support SubnAdmGet and SubnAdmGetTable methods */
- if (p_rcvd_mad->method != IB_MAD_METHOD_GET &&
- p_rcvd_mad->method != IB_MAD_METHOD_GETTABLE) {
- OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 4A08: "
- "Unsupported Method (%s)\n",
- ib_get_sa_method_str(p_rcvd_mad->method));
- osm_sa_send_error(sa, p_madw, IB_MAD_STATUS_UNSUP_METHOD_ATTR);
- goto Exit;
- }
-
- /* update the requester physical port. */
- p_req_physp = osm_get_physp_by_mad_addr(sa->p_log,
- sa->p_subn,
- osm_madw_get_mad_addr_ptr
- (p_madw));
- if (p_req_physp == NULL) {
- OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 4A07: "
- "Cannot find requester physical port\n");
- goto Exit;
- }
-
- cl_qlist_init(&rec_list);
-
- context.p_rcvd_rec = p_rcvd_rec;
- context.p_list = &rec_list;
- context.comp_mask = p_rcvd_mad->comp_mask;
- context.sa = sa;
- context.p_req_physp = p_req_physp;
-
- cl_plock_acquire(sa->p_lock);
-
- /* Go over all switches */
- cl_qmap_apply_func(&sa->p_subn->sw_guid_tbl,
- __osm_mftr_rcv_by_comp_mask, &context);
-
- cl_plock_release(sa->p_lock);
-
- osm_sa_respond(sa, p_madw, sizeof(ib_mft_record_t), &rec_list);
-
-Exit:
- OSM_LOG_EXIT(sa->p_log);
-}
diff --git a/contrib/ofed/management/opensm/opensm/osm_sa_multipath_record.c b/contrib/ofed/management/opensm/opensm/osm_sa_multipath_record.c
deleted file mode 100644
index b9164be..0000000
--- a/contrib/ofed/management/opensm/opensm/osm_sa_multipath_record.c
+++ /dev/null
@@ -1,1536 +0,0 @@
-/*
- * Copyright (c) 2006-2008 Voltaire, Inc. All rights reserved.
- * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved.
- * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- */
-
-/*
- * Abstract:
- * Implementation of osm_mpr_rcv_t.
- * This object represents the MultiPath Record Receiver object.
- * This object is part of the opensm family of objects.
- */
-
-#if HAVE_CONFIG_H
-# include <config.h>
-#endif /* HAVE_CONFIG_H */
-
-#if defined (VENDOR_RMPP_SUPPORT) && defined (DUAL_SIDED_RMPP)
-
-#include <string.h>
-#include <iba/ib_types.h>
-#include <complib/cl_qmap.h>
-#include <complib/cl_passivelock.h>
-#include <complib/cl_debug.h>
-#include <complib/cl_qlist.h>
-#include <vendor/osm_vendor_api.h>
-#include <opensm/osm_port.h>
-#include <opensm/osm_node.h>
-#include <opensm/osm_switch.h>
-#include <opensm/osm_partition.h>
-#include <opensm/osm_helper.h>
-#include <opensm/osm_qos_policy.h>
-#include <opensm/osm_sa.h>
-
-#define OSM_SA_MPR_MAX_NUM_PATH 127
-
-typedef struct osm_mpr_item {
- cl_list_item_t list_item;
- ib_path_rec_t path_rec;
- const osm_port_t *p_src_port;
- const osm_port_t *p_dest_port;
- int hops;
-} osm_mpr_item_t;
-
-typedef struct osm_path_parms {
- ib_net16_t pkey;
- uint8_t mtu;
- uint8_t rate;
- uint8_t sl;
- uint8_t pkt_life;
- boolean_t reversible;
- int hops;
-} osm_path_parms_t;
-
-/**********************************************************************
- **********************************************************************/
-static inline boolean_t
-__osm_sa_multipath_rec_is_tavor_port(IN const osm_port_t * const p_port)
-{
- osm_node_t const *p_node;
- ib_net32_t vend_id;
-
- p_node = p_port->p_node;
- vend_id = ib_node_info_get_vendor_id(&p_node->node_info);
-
- return ((p_node->node_info.device_id == CL_HTON16(23108)) &&
- ((vend_id == CL_HTON32(OSM_VENDOR_ID_MELLANOX)) ||
- (vend_id == CL_HTON32(OSM_VENDOR_ID_TOPSPIN)) ||
- (vend_id == CL_HTON32(OSM_VENDOR_ID_SILVERSTORM)) ||
- (vend_id == CL_HTON32(OSM_VENDOR_ID_VOLTAIRE))));
-}
-
-/**********************************************************************
- **********************************************************************/
-static boolean_t
-__osm_sa_multipath_rec_apply_tavor_mtu_limit(IN const ib_multipath_rec_t *
- const p_mpr,
- IN const osm_port_t *
- const p_src_port,
- IN const osm_port_t *
- const p_dest_port,
- IN const ib_net64_t comp_mask)
-{
- uint8_t required_mtu;
-
- /* only if at least one of the ports is a Tavor device */
- if (!__osm_sa_multipath_rec_is_tavor_port(p_src_port) &&
- !__osm_sa_multipath_rec_is_tavor_port(p_dest_port))
- return (FALSE);
-
- /*
- we can apply the patch if either:
- 1. No MTU required
- 2. Required MTU <
- 3. Required MTU = 1K or 512 or 256
- 4. Required MTU > 256 or 512
- */
- required_mtu = ib_multipath_rec_mtu(p_mpr);
- if ((comp_mask & IB_MPR_COMPMASK_MTUSELEC) &&
- (comp_mask & IB_MPR_COMPMASK_MTU)) {
- switch (ib_multipath_rec_mtu_sel(p_mpr)) {
- case 0: /* must be greater than */
- case 2: /* exact match */
- if (IB_MTU_LEN_1024 < required_mtu)
- return (FALSE);
- break;
-
- case 1: /* must be less than */
- /* can't be disqualified by this one */
- break;
-
- case 3: /* largest available */
- /* the ULP intentionally requested */
- /* the largest MTU possible */
- return (FALSE);
- break;
-
- default:
- /* if we're here, there's a bug in ib_multipath_rec_mtu_sel() */
- CL_ASSERT(FALSE);
- break;
- }
- }
-
- return (TRUE);
-}
-
-/**********************************************************************
- **********************************************************************/
-static ib_api_status_t
-__osm_mpr_rcv_get_path_parms(IN osm_sa_t * sa,
- IN const ib_multipath_rec_t * const p_mpr,
- IN const osm_port_t * const p_src_port,
- IN const osm_port_t * const p_dest_port,
- IN const uint16_t dest_lid_ho,
- IN const ib_net64_t comp_mask,
- OUT osm_path_parms_t * const p_parms)
-{
- const osm_node_t *p_node;
- const osm_physp_t *p_physp;
- const osm_physp_t *p_src_physp;
- const osm_physp_t *p_dest_physp;
- const osm_prtn_t *p_prtn = NULL;
- const ib_port_info_t *p_pi;
- ib_slvl_table_t *p_slvl_tbl;
- ib_api_status_t status = IB_SUCCESS;
- uint8_t mtu;
- uint8_t rate;
- uint8_t pkt_life;
- uint8_t required_mtu;
- uint8_t required_rate;
- ib_net16_t required_pkey;
- uint8_t required_sl;
- uint8_t required_pkt_life;
- ib_net16_t dest_lid;
- int hops = 0;
- int in_port_num = 0;
- uint8_t i;
- osm_qos_level_t *p_qos_level = NULL;
- uint16_t valid_sl_mask = 0xffff;
-
- OSM_LOG_ENTER(sa->p_log);
-
- dest_lid = cl_hton16(dest_lid_ho);
-
- p_dest_physp = p_dest_port->p_physp;
- p_physp = p_src_port->p_physp;
- p_src_physp = p_physp;
- p_pi = &p_physp->port_info;
-
- mtu = ib_port_info_get_mtu_cap(p_pi);
- rate = ib_port_info_compute_rate(p_pi);
-
- /*
- Mellanox Tavor device performance is better using 1K MTU.
- If required MTU and MTU selector are such that 1K is OK
- and at least one end of the path is Tavor we override the
- port MTU with 1K.
- */
- if (sa->p_subn->opt.enable_quirks &&
- __osm_sa_multipath_rec_apply_tavor_mtu_limit(p_mpr, p_src_port,
- p_dest_port,
- comp_mask))
- if (mtu > IB_MTU_LEN_1024) {
- mtu = IB_MTU_LEN_1024;
- OSM_LOG(sa->p_log, OSM_LOG_DEBUG,
- "Optimized Path MTU to 1K for Mellanox Tavor device\n");
- }
-
- /*
- Walk the subnet object from source to destination,
- tracking the most restrictive rate and mtu values along the way...
-
- If source port node is a switch, then p_physp should
- point to the port that routes the destination lid
- */
-
- p_node = osm_physp_get_node_ptr(p_physp);
-
- if (p_node->sw) {
- /*
- * Source node is a switch.
- * Make sure that p_physp points to the out port of the
- * switch that routes to the destination lid (dest_lid_ho)
- */
- p_physp = osm_switch_get_route_by_lid(p_node->sw, dest_lid);
- if (p_physp == 0) {
- OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 4514: "
- "Can't find routing to LID %u from switch for GUID 0x%016"
- PRIx64 "\n", dest_lid_ho,
- cl_ntoh64(osm_node_get_node_guid(p_node)));
- status = IB_NOT_FOUND;
- goto Exit;
- }
- }
-
- if (sa->p_subn->opt.qos) {
-
- /*
- * Whether this node is switch or CA, the IN port for
- * the sl2vl table is 0, because this is a source node.
- */
- p_slvl_tbl = osm_physp_get_slvl_tbl(p_physp, 0);
-
- /* update valid SLs that still exist on this route */
- for (i = 0; i < IB_MAX_NUM_VLS; i++) {
- if (valid_sl_mask & (1 << i) &&
- ib_slvl_table_get(p_slvl_tbl, i) == IB_DROP_VL)
- valid_sl_mask &= ~(1 << i);
- }
- if (!valid_sl_mask) {
- OSM_LOG(sa->p_log, OSM_LOG_DEBUG,
- "All the SLs lead to VL15 on this path\n");
- status = IB_NOT_FOUND;
- goto Exit;
- }
- }
-
- /*
- * Same as above
- */
- p_node = osm_physp_get_node_ptr(p_dest_physp);
-
- if (p_node->sw) {
- /*
- * if destination is switch, we want p_dest_physp to point to port 0
- */
- p_dest_physp = osm_switch_get_route_by_lid(p_node->sw, dest_lid);
-
- if (p_dest_physp == 0) {
- OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 4515: "
- "Can't find routing to LID %u from switch for GUID 0x%016"
- PRIx64 "\n", dest_lid_ho,
- cl_ntoh64(osm_node_get_node_guid(p_node)));
- status = IB_NOT_FOUND;
- goto Exit;
- }
-
- }
-
- /*
- * Now go through the path step by step
- */
-
- while (p_physp != p_dest_physp) {
-
- p_node = osm_physp_get_node_ptr(p_physp);
- p_physp = osm_physp_get_remote(p_physp);
-
- if (p_physp == 0) {
- OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 4505: "
- "Can't find remote phys port when routing to LID %u from node GUID 0x%016"
- PRIx64 "\n", dest_lid_ho,
- cl_ntoh64(osm_node_get_node_guid(p_node)));
- status = IB_ERROR;
- goto Exit;
- }
-
- hops++;
- in_port_num = osm_physp_get_port_num(p_physp);
-
- /*
- This is point to point case (no switch in between)
- */
- if (p_physp == p_dest_physp)
- break;
-
- p_node = osm_physp_get_node_ptr(p_physp);
-
- if (!p_node->sw) {
- /*
- There is some sort of problem in the subnet object!
- If this isn't a switch, we should have reached
- the destination by now!
- */
- OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 4503: "
- "Internal error, bad path\n");
- status = IB_ERROR;
- goto Exit;
- }
-
- /*
- Check parameters for the ingress port in this switch.
- */
- p_pi = &p_physp->port_info;
-
- if (mtu > ib_port_info_get_mtu_cap(p_pi))
- mtu = ib_port_info_get_mtu_cap(p_pi);
-
- if (rate > ib_port_info_compute_rate(p_pi))
- rate = ib_port_info_compute_rate(p_pi);
-
- /*
- Continue with the egress port on this switch.
- */
- p_physp = osm_switch_get_route_by_lid(p_node->sw, dest_lid);
- if (p_physp == 0) {
- OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 4516: "
- "Dead end on path to LID %u from switch for GUID 0x%016"
- PRIx64 "\n", dest_lid_ho,
- cl_ntoh64(osm_node_get_node_guid(p_node)));
- status = IB_ERROR;
- goto Exit;
- }
-
- p_pi = &p_physp->port_info;
-
- if (mtu > ib_port_info_get_mtu_cap(p_pi))
- mtu = ib_port_info_get_mtu_cap(p_pi);
-
- if (rate > ib_port_info_compute_rate(p_pi))
- rate = ib_port_info_compute_rate(p_pi);
-
- if (sa->p_subn->opt.qos) {
- /*
- * Check SL2VL table of the switch and update valid SLs
- */
- p_slvl_tbl = osm_physp_get_slvl_tbl(p_physp, in_port_num);
- for (i = 0; i < IB_MAX_NUM_VLS; i++) {
- if (valid_sl_mask & (1 << i) &&
- ib_slvl_table_get(p_slvl_tbl, i) == IB_DROP_VL)
- valid_sl_mask &= ~(1 << i);
- }
- if (!valid_sl_mask) {
- OSM_LOG(sa->p_log, OSM_LOG_DEBUG,
- "All the SLs lead to VL15 "
- "on this path\n");
- status = IB_NOT_FOUND;
- goto Exit;
- }
- }
- }
-
- /*
- p_physp now points to the destination
- */
- p_pi = &p_physp->port_info;
-
- if (mtu > ib_port_info_get_mtu_cap(p_pi))
- mtu = ib_port_info_get_mtu_cap(p_pi);
-
- if (rate > ib_port_info_compute_rate(p_pi))
- rate = ib_port_info_compute_rate(p_pi);
-
- OSM_LOG(sa->p_log, OSM_LOG_DEBUG,
- "Path min MTU = %u, min rate = %u\n", mtu, rate);
-
- /*
- * Get QoS Level object according to the MultiPath request
- * and adjust MultiPath parameters according to QoS settings
- */
- if (sa->p_subn->opt.qos &&
- sa->p_subn->p_qos_policy &&
- (p_qos_level =
- osm_qos_policy_get_qos_level_by_mpr(sa->p_subn->p_qos_policy,
- p_mpr, p_src_physp,
- p_dest_physp, comp_mask))) {
-
- OSM_LOG(sa->p_log, OSM_LOG_DEBUG,
- "MultiPathRecord request matches QoS Level '%s' (%s)\n",
- p_qos_level->name,
- p_qos_level->use ? p_qos_level->use : "no description");
-
- if (p_qos_level->mtu_limit_set
- && (mtu > p_qos_level->mtu_limit))
- mtu = p_qos_level->mtu_limit;
-
- if (p_qos_level->rate_limit_set
- && (rate > p_qos_level->rate_limit))
- rate = p_qos_level->rate_limit;
-
- if (p_qos_level->sl_set) {
- required_sl = p_qos_level->sl;
- if (!(valid_sl_mask & (1 << required_sl))) {
- status = IB_NOT_FOUND;
- goto Exit;
- }
- }
- }
-
- /*
- Determine if these values meet the user criteria
- */
-
- /* we silently ignore cases where only the MTU selector is defined */
- if ((comp_mask & IB_MPR_COMPMASK_MTUSELEC) &&
- (comp_mask & IB_MPR_COMPMASK_MTU)) {
- required_mtu = ib_multipath_rec_mtu(p_mpr);
- switch (ib_multipath_rec_mtu_sel(p_mpr)) {
- case 0: /* must be greater than */
- if (mtu <= required_mtu)
- status = IB_NOT_FOUND;
- break;
-
- case 1: /* must be less than */
- if (mtu >= required_mtu) {
- /* adjust to use the highest mtu
- lower then the required one */
- if (required_mtu > 1)
- mtu = required_mtu - 1;
- else
- status = IB_NOT_FOUND;
- }
- break;
-
- case 2: /* exact match */
- if (mtu < required_mtu)
- status = IB_NOT_FOUND;
- else
- mtu = required_mtu;
- break;
-
- case 3: /* largest available */
- /* can't be disqualified by this one */
- break;
-
- default:
- /* if we're here, there's a bug in ib_multipath_rec_mtu_sel() */
- CL_ASSERT(FALSE);
- status = IB_ERROR;
- break;
- }
- }
- if (status != IB_SUCCESS)
- goto Exit;
-
- /* we silently ignore cases where only the Rate selector is defined */
- if ((comp_mask & IB_MPR_COMPMASK_RATESELEC) &&
- (comp_mask & IB_MPR_COMPMASK_RATE)) {
- required_rate = ib_multipath_rec_rate(p_mpr);
- switch (ib_multipath_rec_rate_sel(p_mpr)) {
- case 0: /* must be greater than */
- if (rate <= required_rate)
- status = IB_NOT_FOUND;
- break;
-
- case 1: /* must be less than */
- if (rate >= required_rate) {
- /* adjust the rate to use the highest rate
- lower then the required one */
- if (required_rate > 2)
- rate = required_rate - 1;
- else
- status = IB_NOT_FOUND;
- }
- break;
-
- case 2: /* exact match */
- if (rate < required_rate)
- status = IB_NOT_FOUND;
- else
- rate = required_rate;
- break;
-
- case 3: /* largest available */
- /* can't be disqualified by this one */
- break;
-
- default:
- /* if we're here, there's a bug in ib_multipath_rec_mtu_sel() */
- CL_ASSERT(FALSE);
- status = IB_ERROR;
- break;
- }
- }
- if (status != IB_SUCCESS)
- goto Exit;
-
- /* Verify the pkt_life_time */
- /* According to spec definition IBA 1.2 Table 205 PacketLifeTime description,
- for loopback paths, packetLifeTime shall be zero. */
- if (p_src_port == p_dest_port)
- pkt_life = 0; /* loopback */
- else if (p_qos_level && p_qos_level->pkt_life_set)
- pkt_life = p_qos_level->pkt_life;
- else
- pkt_life = sa->p_subn->opt.subnet_timeout;
-
- /* we silently ignore cases where only the PktLife selector is defined */
- if ((comp_mask & IB_MPR_COMPMASK_PKTLIFETIMESELEC) &&
- (comp_mask & IB_MPR_COMPMASK_PKTLIFETIME)) {
- required_pkt_life = ib_multipath_rec_pkt_life(p_mpr);
- switch (ib_multipath_rec_pkt_life_sel(p_mpr)) {
- case 0: /* must be greater than */
- if (pkt_life <= required_pkt_life)
- status = IB_NOT_FOUND;
- break;
-
- case 1: /* must be less than */
- if (pkt_life >= required_pkt_life) {
- /* adjust the lifetime to use the highest possible
- lower then the required one */
- if (required_pkt_life > 1)
- pkt_life = required_pkt_life - 1;
- else
- status = IB_NOT_FOUND;
- }
- break;
-
- case 2: /* exact match */
- if (pkt_life < required_pkt_life)
- status = IB_NOT_FOUND;
- else
- pkt_life = required_pkt_life;
- break;
-
- case 3: /* smallest available */
- /* can't be disqualified by this one */
- break;
-
- default:
- /* if we're here, there's a bug in ib_path_rec_pkt_life_sel() */
- CL_ASSERT(FALSE);
- status = IB_ERROR;
- break;
- }
- }
-
- if (status != IB_SUCCESS)
- goto Exit;
-
- /*
- * set Pkey for this MultiPath record request
- */
-
- if (comp_mask & IB_MPR_COMPMASK_RAWTRAFFIC &&
- cl_ntoh32(p_mpr->hop_flow_raw) & (1 << 31))
- required_pkey =
- osm_physp_find_common_pkey(p_src_physp, p_dest_physp);
-
- else if (comp_mask & IB_MPR_COMPMASK_PKEY) {
- /*
- * MPR request has a specific pkey:
- * Check that source and destination share this pkey.
- * If QoS level has pkeys, check that this pkey exists
- * in the QoS level pkeys.
- * MPR returned pkey is the requested pkey.
- */
- required_pkey = p_mpr->pkey;
- if (!osm_physp_share_this_pkey
- (p_src_physp, p_dest_physp, required_pkey)) {
- OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 4518: "
- "Ports do not share specified PKey 0x%04x\n"
- "\t\tsrc %" PRIx64 " dst %" PRIx64 "\n",
- cl_ntoh16(required_pkey),
- cl_ntoh64(osm_physp_get_port_guid(p_src_physp)),
- cl_ntoh64(osm_physp_get_port_guid
- (p_dest_physp)));
- status = IB_NOT_FOUND;
- goto Exit;
- }
- if (p_qos_level && p_qos_level->pkey_range_len &&
- !osm_qos_level_has_pkey(p_qos_level, required_pkey)) {
- OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 451C: "
- "Ports do not share PKeys defined by QoS level\n");
- status = IB_NOT_FOUND;
- goto Exit;
- }
-
- } else if (p_qos_level && p_qos_level->pkey_range_len) {
- /*
- * MPR request doesn't have a specific pkey, but QoS level
- * has pkeys - get shared pkey from QoS level pkeys
- */
- required_pkey = osm_qos_level_get_shared_pkey(p_qos_level,
- p_src_physp,
- p_dest_physp);
- if (!required_pkey) {
- OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 451D: "
- "Ports do not share PKeys defined by QoS level\n");
- status = IB_NOT_FOUND;
- goto Exit;
- }
-
- } else {
- /*
- * Neither MPR request nor QoS level have pkey.
- * Just get any shared pkey.
- */
- required_pkey =
- osm_physp_find_common_pkey(p_src_physp, p_dest_physp);
- if (!required_pkey) {
- OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 4519: "
- "Ports do not have any shared PKeys\n"
- "\t\tsrc %" PRIx64 " dst %" PRIx64 "\n",
- cl_ntoh64(osm_physp_get_port_guid(p_physp)),
- cl_ntoh64(osm_physp_get_port_guid
- (p_dest_physp)));
- status = IB_NOT_FOUND;
- goto Exit;
- }
- }
-
- if (required_pkey) {
- p_prtn =
- (osm_prtn_t *) cl_qmap_get(&sa->p_subn->prtn_pkey_tbl,
- required_pkey &
- cl_ntoh16((uint16_t) ~ 0x8000));
- if (p_prtn ==
- (osm_prtn_t *) cl_qmap_end(&sa->p_subn->prtn_pkey_tbl))
- p_prtn = NULL;
- }
-
- /*
- * Set MultiPathRecord SL.
- */
-
- if (comp_mask & IB_MPR_COMPMASK_SL) {
- /*
- * Specific SL was requested
- */
- required_sl = ib_multipath_rec_sl(p_mpr);
-
- if (p_qos_level && p_qos_level->sl_set &&
- p_qos_level->sl != required_sl) {
- OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 451E: "
- "QoS constaraints: required MultiPathRecord SL (%u) "
- "doesn't match QoS policy SL (%u)\n",
- required_sl, p_qos_level->sl);
- status = IB_NOT_FOUND;
- goto Exit;
- }
-
- } else if (p_qos_level && p_qos_level->sl_set) {
- /*
- * No specific SL was requested,
- * but there is an SL in QoS level.
- */
- required_sl = p_qos_level->sl;
-
- if (required_pkey && p_prtn && p_prtn->sl != p_qos_level->sl)
- OSM_LOG(sa->p_log, OSM_LOG_DEBUG,
- "QoS level SL (%u) overrides partition SL (%u)\n",
- p_qos_level->sl, p_prtn->sl);
-
- } else if (required_pkey) {
- /*
- * No specific SL in request or in QoS level - use partition SL
- */
- p_prtn =
- (osm_prtn_t *) cl_qmap_get(&sa->p_subn->prtn_pkey_tbl,
- required_pkey &
- cl_ntoh16((uint16_t) ~ 0x8000));
- if (!p_prtn) {
- required_sl = OSM_DEFAULT_SL;
- /* this may be possible when pkey tables are created somehow in
- previous runs or things are going wrong here */
- OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 451A: "
- "No partition found for PKey 0x%04x - using default SL %d\n",
- cl_ntoh16(required_pkey), required_sl);
- } else
- required_sl = p_prtn->sl;
-
- } else if (sa->p_subn->opt.qos) {
- if (valid_sl_mask & (1 << OSM_DEFAULT_SL))
- required_sl = OSM_DEFAULT_SL;
- else {
- for (i = 0; i < IB_MAX_NUM_VLS; i++)
- if (valid_sl_mask & (1 << i))
- break;
- required_sl = i;
- }
- } else
- required_sl = OSM_DEFAULT_SL;
-
- if (sa->p_subn->opt.qos && !(valid_sl_mask & (1 << required_sl))) {
- OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 451F: "
- "Selected SL (%u) leads to VL15\n", required_sl);
- status = IB_NOT_FOUND;
- goto Exit;
- }
-
- /* reset pkey when raw traffic */
- if (comp_mask & IB_MPR_COMPMASK_RAWTRAFFIC &&
- cl_ntoh32(p_mpr->hop_flow_raw) & (1 << 31))
- required_pkey = 0;
-
- p_parms->mtu = mtu;
- p_parms->rate = rate;
- p_parms->pkey = required_pkey;
- p_parms->pkt_life = pkt_life;
- p_parms->sl = required_sl;
- p_parms->hops = hops;
-
- OSM_LOG(sa->p_log, OSM_LOG_DEBUG, "MultiPath params:"
- " mtu = %u, rate = %u, packet lifetime = %u,"
- " pkey = 0x%04X, sl = %u, hops = %u\n", mtu, rate,
- pkt_life, cl_ntoh16(required_pkey), required_sl, hops);
-
-Exit:
- OSM_LOG_EXIT(sa->p_log);
- return (status);
-}
-
-/**********************************************************************
- **********************************************************************/
-static void
-__osm_mpr_rcv_build_pr(IN osm_sa_t * sa,
- IN const osm_port_t * const p_src_port,
- IN const osm_port_t * const p_dest_port,
- IN const uint16_t src_lid_ho,
- IN const uint16_t dest_lid_ho,
- IN const uint8_t preference,
- IN const osm_path_parms_t * const p_parms,
- OUT ib_path_rec_t * const p_pr)
-{
- const osm_physp_t *p_src_physp;
- const osm_physp_t *p_dest_physp;
-
- OSM_LOG_ENTER(sa->p_log);
-
- p_src_physp = p_src_port->p_physp;
- p_dest_physp = p_dest_port->p_physp;
-
- p_pr->dgid.unicast.prefix = osm_physp_get_subnet_prefix(p_dest_physp);
- p_pr->dgid.unicast.interface_id = osm_physp_get_port_guid(p_dest_physp);
-
- p_pr->sgid.unicast.prefix = osm_physp_get_subnet_prefix(p_src_physp);
- p_pr->sgid.unicast.interface_id = osm_physp_get_port_guid(p_src_physp);
-
- p_pr->dlid = cl_hton16(dest_lid_ho);
- p_pr->slid = cl_hton16(src_lid_ho);
-
- p_pr->hop_flow_raw &= cl_hton32(1 << 31);
-
- p_pr->pkey = p_parms->pkey;
- ib_path_rec_set_qos_class(p_pr, 0);
- ib_path_rec_set_sl(p_pr, p_parms->sl);
- p_pr->mtu = (uint8_t) (p_parms->mtu | 0x80);
- p_pr->rate = (uint8_t) (p_parms->rate | 0x80);
-
- /* According to 1.2 spec definition Table 205 PacketLifeTime description,
- for loopback paths, packetLifeTime shall be zero. */
- if (p_src_port == p_dest_port)
- p_pr->pkt_life = 0x80; /* loopback */
- else
- p_pr->pkt_life = (uint8_t) (p_parms->pkt_life | 0x80);
-
- p_pr->preference = preference;
-
- /* always return num_path = 0 so this is only the reversible component */
- if (p_parms->reversible)
- p_pr->num_path = 0x80;
-
- OSM_LOG_EXIT(sa->p_log);
-}
-
-/**********************************************************************
- **********************************************************************/
-static osm_mpr_item_t *
-__osm_mpr_rcv_get_lid_pair_path(IN osm_sa_t * sa,
- IN const ib_multipath_rec_t * const p_mpr,
- IN const osm_port_t * const p_src_port,
- IN const osm_port_t * const p_dest_port,
- IN const uint16_t src_lid_ho,
- IN const uint16_t dest_lid_ho,
- IN const ib_net64_t comp_mask,
- IN const uint8_t preference)
-{
- osm_path_parms_t path_parms;
- osm_path_parms_t rev_path_parms;
- osm_mpr_item_t *p_pr_item;
- ib_api_status_t status, rev_path_status;
-
- OSM_LOG_ENTER(sa->p_log);
-
- OSM_LOG(sa->p_log, OSM_LOG_DEBUG, "Src LID %u, Dest LID %u\n",
- src_lid_ho, dest_lid_ho);
-
- p_pr_item = malloc(sizeof(*p_pr_item));
- if (p_pr_item == NULL) {
- OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 4501: "
- "Unable to allocate path record\n");
- goto Exit;
- }
- memset(p_pr_item, 0, sizeof(*p_pr_item));
-
- status = __osm_mpr_rcv_get_path_parms(sa, p_mpr, p_src_port,
- p_dest_port, dest_lid_ho,
- comp_mask, &path_parms);
-
- if (status != IB_SUCCESS) {
- free(p_pr_item);
- p_pr_item = NULL;
- goto Exit;
- }
-
- /* now try the reversible path */
- rev_path_status =
- __osm_mpr_rcv_get_path_parms(sa, p_mpr, p_dest_port, p_src_port,
- src_lid_ho, comp_mask,
- &rev_path_parms);
- path_parms.reversible = (rev_path_status == IB_SUCCESS);
-
- /* did we get a Reversible Path compmask ? */
- /*
- NOTE that if the reversible component = 0, it is a don't care
- rather then requiring non-reversible paths ...
- see Vol1 Ver1.2 p900 l16
- */
- if (comp_mask & IB_MPR_COMPMASK_REVERSIBLE) {
- if ((!path_parms.reversible && (p_mpr->num_path & 0x80))) {
- OSM_LOG(sa->p_log, OSM_LOG_DEBUG,
- "Requested reversible path but failed to get one\n");
-
- free(p_pr_item);
- p_pr_item = NULL;
- goto Exit;
- }
- }
-
- p_pr_item->p_src_port = p_src_port;
- p_pr_item->p_dest_port = p_dest_port;
- p_pr_item->hops = path_parms.hops;
-
- __osm_mpr_rcv_build_pr(sa, p_src_port, p_dest_port, src_lid_ho,
- dest_lid_ho, preference, &path_parms,
- &p_pr_item->path_rec);
-
-Exit:
- OSM_LOG_EXIT(sa->p_log);
- return (p_pr_item);
-}
-
-/**********************************************************************
- **********************************************************************/
-static uint32_t
-__osm_mpr_rcv_get_port_pair_paths(IN osm_sa_t * sa,
- IN const ib_multipath_rec_t * const p_mpr,
- IN const osm_port_t * const p_req_port,
- IN const osm_port_t * const p_src_port,
- IN const osm_port_t * const p_dest_port,
- IN const uint32_t rem_paths,
- IN const ib_net64_t comp_mask,
- IN cl_qlist_t * const p_list)
-{
- osm_mpr_item_t *p_pr_item;
- uint16_t src_lid_min_ho;
- uint16_t src_lid_max_ho;
- uint16_t dest_lid_min_ho;
- uint16_t dest_lid_max_ho;
- uint16_t src_lid_ho;
- uint16_t dest_lid_ho;
- uint32_t path_num = 0;
- uint8_t preference;
- uintn_t src_offset;
- uintn_t dest_offset;
-
- OSM_LOG_ENTER(sa->p_log);
-
- OSM_LOG(sa->p_log, OSM_LOG_DEBUG,
- "Src port 0x%016" PRIx64 ", Dst port 0x%016" PRIx64 "\n",
- cl_ntoh64(osm_port_get_guid(p_src_port)),
- cl_ntoh64(osm_port_get_guid(p_dest_port)));
-
- /* Check that the req_port, src_port and dest_port all share a
- pkey. The check is done on the default physical port of the ports. */
- if (osm_port_share_pkey(sa->p_log, p_req_port, p_src_port) == FALSE
- || osm_port_share_pkey(sa->p_log, p_req_port,
- p_dest_port) == FALSE
- || osm_port_share_pkey(sa->p_log, p_src_port,
- p_dest_port) == FALSE)
- /* One of the pairs doesn't share a pkey so the path is disqualified. */
- goto Exit;
-
- /*
- We shouldn't be here if the paths are disqualified in some way...
- Thus, we assume every possible connection is valid.
-
- We desire to return high-quality paths first.
- In OpenSM, higher quality mean least overlap with other paths.
- This is acheived in practice by returning paths with
- different LID value on each end, which means these
- paths are more redundant that paths with the same LID repeated
- on one side. For example, in OpenSM the paths between two
- endpoints with LMC = 1 might be as follows:
-
- Port A, LID 1 <-> Port B, LID 3
- Port A, LID 1 <-> Port B, LID 4
- Port A, LID 2 <-> Port B, LID 3
- Port A, LID 2 <-> Port B, LID 4
-
- The OpenSM unicast routing algorithms attempt to disperse each path
- to as varied a physical path as is reasonable. 1<->3 and 1<->4 have
- more physical overlap (hence less redundancy) than 1<->3 and 2<->4.
-
- OpenSM ranks paths in three preference groups:
-
- Preference Value Description
- ---------------- -------------------------------------------
- 0 Redundant in both directions with other
- pref value = 0 paths
-
- 1 Redundant in one direction with other
- pref value = 0 and pref value = 1 paths
-
- 2 Not redundant in either direction with
- other paths
-
- 3-FF Unused
-
- SA clients don't need to know these details, only that the lower
- preference paths are preferred, as stated in the spec. The paths
- may not actually be physically redundant depending on the topology
- of the subnet, but the point of LMC > 0 is to offer redundancy,
- so I assume the subnet is physically appropriate for the specified
- LMC value. A more advanced implementation could inspect for physical
- redundancy, but I'm not going to bother with that now.
- */
-
- osm_port_get_lid_range_ho(p_src_port, &src_lid_min_ho, &src_lid_max_ho);
- osm_port_get_lid_range_ho(p_dest_port, &dest_lid_min_ho,
- &dest_lid_max_ho);
-
- OSM_LOG(sa->p_log, OSM_LOG_DEBUG, "Src LID [%u-%u], Dest LID [%u-%u]\n",
- src_lid_min_ho, src_lid_max_ho,
- dest_lid_min_ho, dest_lid_max_ho);
-
- src_lid_ho = src_lid_min_ho;
- dest_lid_ho = dest_lid_min_ho;
-
- /*
- Preferred paths come first in OpenSM
- */
- preference = 0;
-
- while (path_num < rem_paths) {
- /*
- These paths are "fully redundant"
- */
- p_pr_item = __osm_mpr_rcv_get_lid_pair_path(sa, p_mpr,
- p_src_port,
- p_dest_port,
- src_lid_ho,
- dest_lid_ho,
- comp_mask,
- preference);
-
- if (p_pr_item) {
- cl_qlist_insert_tail(p_list, &p_pr_item->list_item);
- ++path_num;
- }
-
- if (++src_lid_ho > src_lid_max_ho)
- break;
-
- if (++dest_lid_ho > dest_lid_max_ho)
- break;
- }
-
- /*
- Check if we've accumulated all the paths that the user cares to see
- */
- if (path_num == rem_paths)
- goto Exit;
-
- /*
- Don't bother reporting preference 1 paths for now.
- It's more trouble than it's worth and can only occur
- if ports have different LMC values, which isn't supported
- by OpenSM right now anyway.
- */
- preference = 2;
- src_lid_ho = src_lid_min_ho;
- dest_lid_ho = dest_lid_min_ho;
- src_offset = 0;
- dest_offset = 0;
-
- /*
- Iterate over the remaining paths
- */
- while (path_num < rem_paths) {
- dest_offset++;
- dest_lid_ho++;
-
- if (dest_lid_ho > dest_lid_max_ho) {
- src_offset++;
- src_lid_ho++;
-
- if (src_lid_ho > src_lid_max_ho)
- break; /* done */
-
- dest_offset = 0;
- dest_lid_ho = dest_lid_min_ho;
- }
-
- /*
- These paths are "fully non-redundant" with paths already
- identified above and consequently not of much value.
-
- Don't return paths we already identified above, as indicated
- by the offset values being equal.
- */
- if (src_offset == dest_offset)
- continue; /* already reported */
-
- p_pr_item = __osm_mpr_rcv_get_lid_pair_path(sa, p_mpr,
- p_src_port,
- p_dest_port,
- src_lid_ho,
- dest_lid_ho,
- comp_mask,
- preference);
-
- if (p_pr_item) {
- cl_qlist_insert_tail(p_list, &p_pr_item->list_item);
- ++path_num;
- }
- }
-
-Exit:
- OSM_LOG_EXIT(sa->p_log);
- return path_num;
-}
-
-#undef min
-#define min(x,y) (((x) < (y)) ? (x) : (y))
-
-/**********************************************************************
- **********************************************************************/
-static osm_mpr_item_t *
-__osm_mpr_rcv_get_apm_port_pair_paths(IN osm_sa_t * sa,
- IN const ib_multipath_rec_t * const p_mpr,
- IN const osm_port_t * const p_src_port,
- IN const osm_port_t * const p_dest_port,
- IN int base_offs,
- IN const ib_net64_t comp_mask,
- IN cl_qlist_t * const p_list)
-{
- osm_mpr_item_t *p_pr_item = 0;
- uint16_t src_lid_min_ho;
- uint16_t src_lid_max_ho;
- uint16_t dest_lid_min_ho;
- uint16_t dest_lid_max_ho;
- uint16_t src_lid_ho;
- uint16_t dest_lid_ho;
- uintn_t iterations;
- int src_lids, dest_lids;
-
- OSM_LOG_ENTER(sa->p_log);
-
- OSM_LOG(sa->p_log, OSM_LOG_DEBUG, "Src port 0x%016" PRIx64 ", "
- "Dst port 0x%016" PRIx64 ", base offs %d\n",
- cl_ntoh64(osm_port_get_guid(p_src_port)),
- cl_ntoh64(osm_port_get_guid(p_dest_port)), base_offs);
-
- osm_port_get_lid_range_ho(p_src_port, &src_lid_min_ho, &src_lid_max_ho);
- osm_port_get_lid_range_ho(p_dest_port, &dest_lid_min_ho,
- &dest_lid_max_ho);
-
- src_lid_ho = src_lid_min_ho;
- dest_lid_ho = dest_lid_min_ho;
-
- src_lids = src_lid_max_ho - src_lid_min_ho + 1;
- dest_lids = dest_lid_max_ho - dest_lid_min_ho + 1;
-
- src_lid_ho += base_offs % src_lids;
- dest_lid_ho += base_offs % dest_lids;
-
- OSM_LOG(sa->p_log, OSM_LOG_DEBUG,
- "Src LIDs [%u-%u] hashed %u, "
- "Dest LIDs [%u-%u] hashed %u\n",
- src_lid_min_ho, src_lid_max_ho, src_lid_ho,
- dest_lid_min_ho, dest_lid_max_ho, dest_lid_ho);
-
- iterations = min(src_lids, dest_lids);
-
- while (iterations--) {
- /*
- These paths are "fully redundant"
- */
- p_pr_item = __osm_mpr_rcv_get_lid_pair_path(sa, p_mpr,
- p_src_port,
- p_dest_port,
- src_lid_ho,
- dest_lid_ho,
- comp_mask, 0);
-
- if (p_pr_item) {
- OSM_LOG(sa->p_log, OSM_LOG_DEBUG,
- "Found matching path from Src LID %u to Dest LID %u with %d hops\n",
- src_lid_ho, dest_lid_ho, p_pr_item->hops);
- break;
- }
-
- if (++src_lid_ho > src_lid_max_ho)
- src_lid_ho = src_lid_min_ho;
-
- if (++dest_lid_ho > dest_lid_max_ho)
- dest_lid_ho = dest_lid_min_ho;
- }
-
- OSM_LOG_EXIT(sa->p_log);
- return p_pr_item;
-}
-
-/**********************************************************************
- **********************************************************************/
-static ib_net16_t
-__osm_mpr_rcv_get_gids(IN osm_sa_t * sa,
- IN const ib_gid_t * gids,
- IN int ngids, IN int is_sgid, OUT osm_port_t ** pp_port)
-{
- osm_port_t *p_port;
- ib_net16_t ib_status = IB_SUCCESS;
- int i;
-
- OSM_LOG_ENTER(sa->p_log);
-
- for (i = 0; i < ngids; i++, gids++) {
- if (!ib_gid_is_link_local(gids)) {
- if ((is_sgid && ib_gid_is_multicast(gids)) ||
- (ib_gid_get_subnet_prefix(gids) !=
- sa->p_subn->opt.subnet_prefix)) {
- /*
- This 'error' is the client's fault (bad gid)
- so don't enter it as an error in our own log.
- Return an error response to the client.
- */
- OSM_LOG(sa->p_log, OSM_LOG_VERBOSE, "ERR 451B: "
- "%sGID 0x%016" PRIx64
- " is multicast or non local subnet prefix\n",
- is_sgid ? "S" : "D",
- cl_ntoh64(gids->unicast.prefix));
-
- ib_status = IB_SA_MAD_STATUS_INVALID_GID;
- goto Exit;
- }
- }
-
- p_port =
- osm_get_port_by_guid(sa->p_subn,
- gids->unicast.interface_id);
- if (!p_port) {
- /*
- This 'error' is the client's fault (bad gid) so
- don't enter it as an error in our own log.
- Return an error response to the client.
- */
- OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 4506: "
- "No port with GUID 0x%016" PRIx64 "\n",
- cl_ntoh64(gids->unicast.interface_id));
-
- ib_status = IB_SA_MAD_STATUS_INVALID_GID;
- goto Exit;
- }
-
- pp_port[i] = p_port;
- }
-
-Exit:
- OSM_LOG_EXIT(sa->p_log);
-
- return ib_status;
-}
-
-/**********************************************************************
- **********************************************************************/
-static ib_net16_t
-__osm_mpr_rcv_get_end_points(IN osm_sa_t * sa,
- IN const osm_madw_t * const p_madw,
- OUT osm_port_t ** pp_ports,
- OUT int *nsrc, OUT int *ndest)
-{
- const ib_multipath_rec_t *p_mpr;
- const ib_sa_mad_t *p_sa_mad;
- ib_net64_t comp_mask;
- ib_net16_t sa_status = IB_SA_MAD_STATUS_SUCCESS;
- ib_gid_t *gids;
-
- OSM_LOG_ENTER(sa->p_log);
-
- /*
- Determine what fields are valid and then get a pointer
- to the source and destination port objects, if possible.
- */
- p_sa_mad = osm_madw_get_sa_mad_ptr(p_madw);
- p_mpr = (ib_multipath_rec_t *) ib_sa_mad_get_payload_ptr(p_sa_mad);
- gids = (ib_gid_t *) p_mpr->gids;
-
- comp_mask = p_sa_mad->comp_mask;
-
- /*
- Check a few easy disqualifying cases up front before getting
- into the endpoints.
- */
- *nsrc = *ndest = 0;
-
- if (comp_mask & IB_MPR_COMPMASK_SGIDCOUNT) {
- *nsrc = p_mpr->sgid_count;
- if (*nsrc > IB_MULTIPATH_MAX_GIDS)
- *nsrc = IB_MULTIPATH_MAX_GIDS;
- sa_status =
- __osm_mpr_rcv_get_gids(sa, gids, *nsrc, 1, pp_ports);
- if (sa_status != IB_SUCCESS)
- goto Exit;
- }
-
- if (comp_mask & IB_MPR_COMPMASK_DGIDCOUNT) {
- *ndest = p_mpr->dgid_count;
- if (*ndest + *nsrc > IB_MULTIPATH_MAX_GIDS)
- *ndest = IB_MULTIPATH_MAX_GIDS - *nsrc;
- sa_status =
- __osm_mpr_rcv_get_gids(sa, gids + *nsrc, *ndest, 0,
- pp_ports + *nsrc);
- }
-
-Exit:
- OSM_LOG_EXIT(sa->p_log);
- return (sa_status);
-}
-
-#define __hash_lids(a, b, lmc) \
- (((((a) >> (lmc)) << 4) | ((b) >> (lmc))) % 103)
-
-/**********************************************************************
- **********************************************************************/
-static void
-__osm_mpr_rcv_get_apm_paths(IN osm_sa_t * sa,
- IN const ib_multipath_rec_t * const p_mpr,
- IN const osm_port_t * const p_req_port,
- IN osm_port_t ** _pp_ports,
- IN const ib_net64_t comp_mask,
- IN cl_qlist_t * const p_list)
-{
- osm_port_t *pp_ports[4];
- osm_mpr_item_t *matrix[2][2];
- int base_offs, src_lid_ho, dest_lid_ho;
- int sumA, sumB, minA, minB;
-
- OSM_LOG_ENTER(sa->p_log);
-
- /*
- * We want to:
- * 1. use different lid offsets (from base) for the resultant paths
- * to increase the probability of redundant paths or in case
- * of Clos - to ensure it (different offset => different spine!)
- * 2. keep consistent paths no matter of direction and order of ports
- * 3. distibute the lid offsets to balance the load
- * So, we sort the ports (within the srcs, and within the dests),
- * hash the lids of S0, D0 (after the sort), and call __osm_mpr_rcv_get_apm_port_pair_paths
- * with base_lid for S0, D0 and base_lid + 1 for S1, D1. This way we will get
- * always the same offsets - order indepentent, and make sure different spines are used.
- * Note that the diagonals on a Clos have the same number of hops, so it doesn't
- * really matter which diagonal we use.
- */
- if (_pp_ports[0]->guid < _pp_ports[1]->guid) {
- pp_ports[0] = _pp_ports[0];
- pp_ports[1] = _pp_ports[1];
- } else {
- pp_ports[0] = _pp_ports[1];
- pp_ports[1] = _pp_ports[0];
- }
- if (_pp_ports[2]->guid < _pp_ports[3]->guid) {
- pp_ports[2] = _pp_ports[2];
- pp_ports[3] = _pp_ports[3];
- } else {
- pp_ports[2] = _pp_ports[3];
- pp_ports[3] = _pp_ports[2];
- }
-
- src_lid_ho = osm_port_get_base_lid(pp_ports[0]);
- dest_lid_ho = osm_port_get_base_lid(pp_ports[2]);
-
- base_offs = src_lid_ho < dest_lid_ho ?
- __hash_lids(src_lid_ho, dest_lid_ho, sa->p_subn->opt.lmc) :
- __hash_lids(dest_lid_ho, src_lid_ho, sa->p_subn->opt.lmc);
-
- matrix[0][0] =
- __osm_mpr_rcv_get_apm_port_pair_paths(sa, p_mpr, pp_ports[0],
- pp_ports[2], base_offs,
- comp_mask, p_list);
- matrix[0][1] =
- __osm_mpr_rcv_get_apm_port_pair_paths(sa, p_mpr, pp_ports[0],
- pp_ports[3], base_offs,
- comp_mask, p_list);
- matrix[1][0] =
- __osm_mpr_rcv_get_apm_port_pair_paths(sa, p_mpr, pp_ports[1],
- pp_ports[2], base_offs + 1,
- comp_mask, p_list);
- matrix[1][1] =
- __osm_mpr_rcv_get_apm_port_pair_paths(sa, p_mpr, pp_ports[1],
- pp_ports[3], base_offs + 1,
- comp_mask, p_list);
-
- OSM_LOG(sa->p_log, OSM_LOG_DEBUG, "APM matrix:\n"
- "\t{0,0} 0x%X->0x%X (%d)\t| {0,1} 0x%X->0x%X (%d)\n"
- "\t{1,0} 0x%X->0x%X (%d)\t| {1,1} 0x%X->0x%X (%d)\n",
- matrix[0][0]->path_rec.slid, matrix[0][0]->path_rec.dlid,
- matrix[0][0]->hops, matrix[0][1]->path_rec.slid,
- matrix[0][1]->path_rec.dlid, matrix[0][1]->hops,
- matrix[1][0]->path_rec.slid, matrix[1][0]->path_rec.dlid,
- matrix[1][0]->hops, matrix[1][1]->path_rec.slid,
- matrix[1][1]->path_rec.dlid, matrix[1][1]->hops);
-
- /* check diagonal A {(0,0), (1,1)} */
- sumA = matrix[0][0]->hops + matrix[1][1]->hops;
- minA = min(matrix[0][0]->hops, matrix[1][1]->hops);
-
- /* check diagonal B {(0,1), (1,0)} */
- sumB = matrix[0][1]->hops + matrix[1][0]->hops;
- minB = min(matrix[0][1]->hops, matrix[1][0]->hops);
-
- /* and the winner is... */
- if (minA <= minB || (minA == minB && sumA < sumB)) {
- /* Diag A */
- OSM_LOG(sa->p_log, OSM_LOG_DEBUG,
- "Diag {0,0} & {1,1} is the best:\n"
- "\t{0,0} 0x%X->0x%X (%d)\t & {1,1} 0x%X->0x%X (%d)\n",
- matrix[0][0]->path_rec.slid,
- matrix[0][0]->path_rec.dlid, matrix[0][0]->hops,
- matrix[1][1]->path_rec.slid,
- matrix[1][1]->path_rec.dlid, matrix[1][1]->hops);
- cl_qlist_insert_tail(p_list, &matrix[0][0]->list_item);
- cl_qlist_insert_tail(p_list, &matrix[1][1]->list_item);
- free(matrix[0][1]);
- free(matrix[1][0]);
- } else {
- /* Diag B */
- OSM_LOG(sa->p_log, OSM_LOG_DEBUG,
- "Diag {0,1} & {1,0} is the best:\n"
- "\t{0,1} 0x%X->0x%X (%d)\t & {1,0} 0x%X->0x%X (%d)\n",
- matrix[0][1]->path_rec.slid,
- matrix[0][1]->path_rec.dlid, matrix[0][1]->hops,
- matrix[1][0]->path_rec.slid,
- matrix[1][0]->path_rec.dlid, matrix[1][0]->hops);
- cl_qlist_insert_tail(p_list, &matrix[0][1]->list_item);
- cl_qlist_insert_tail(p_list, &matrix[1][0]->list_item);
- free(matrix[0][0]);
- free(matrix[1][1]);
- }
-
- OSM_LOG_EXIT(sa->p_log);
-}
-
-/**********************************************************************
- **********************************************************************/
-static void
-__osm_mpr_rcv_process_pairs(IN osm_sa_t * sa,
- IN const ib_multipath_rec_t * const p_mpr,
- IN osm_port_t * const p_req_port,
- IN osm_port_t ** pp_ports,
- IN const int nsrc,
- IN const int ndest,
- IN const ib_net64_t comp_mask,
- IN cl_qlist_t * const p_list)
-{
- osm_port_t **pp_src_port, **pp_es;
- osm_port_t **pp_dest_port, **pp_ed;
- uint32_t max_paths, num_paths, total_paths = 0;
-
- OSM_LOG_ENTER(sa->p_log);
-
- if (comp_mask & IB_MPR_COMPMASK_NUMBPATH)
- max_paths = p_mpr->num_path & 0x7F;
- else
- max_paths = OSM_SA_MPR_MAX_NUM_PATH;
-
- for (pp_src_port = pp_ports, pp_es = pp_ports + nsrc;
- pp_src_port < pp_es; pp_src_port++) {
- for (pp_dest_port = pp_es, pp_ed = pp_es + ndest;
- pp_dest_port < pp_ed; pp_dest_port++) {
- num_paths =
- __osm_mpr_rcv_get_port_pair_paths(sa, p_mpr,
- p_req_port,
- *pp_src_port,
- *pp_dest_port,
- max_paths -
- total_paths,
- comp_mask,
- p_list);
- total_paths += num_paths;
- OSM_LOG(sa->p_log, OSM_LOG_DEBUG,
- "%d paths %d total paths %d max paths\n",
- num_paths, total_paths, max_paths);
- /* Just take first NumbPaths found */
- if (total_paths >= max_paths)
- goto Exit;
- }
- }
-
-Exit:
- OSM_LOG_EXIT(sa->p_log);
-}
-
-/**********************************************************************
- **********************************************************************/
-void osm_mpr_rcv_process(IN void *context, IN void *data)
-{
- osm_sa_t *sa = context;
- osm_madw_t *p_madw = data;
- const ib_multipath_rec_t *p_mpr;
- ib_sa_mad_t *p_sa_mad;
- osm_port_t *requester_port;
- osm_port_t *pp_ports[IB_MULTIPATH_MAX_GIDS];
- cl_qlist_t pr_list;
- ib_net16_t sa_status;
- int nsrc, ndest;
-
- OSM_LOG_ENTER(sa->p_log);
-
- CL_ASSERT(p_madw);
-
- p_sa_mad = osm_madw_get_sa_mad_ptr(p_madw);
- p_mpr = (ib_multipath_rec_t *) ib_sa_mad_get_payload_ptr(p_sa_mad);
-
- CL_ASSERT(p_sa_mad->attr_id == IB_MAD_ATTR_MULTIPATH_RECORD);
-
- if ((p_sa_mad->rmpp_flags & IB_RMPP_FLAG_ACTIVE) != IB_RMPP_FLAG_ACTIVE) {
- OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 4510: "
- "Invalid request since RMPP_FLAG_ACTIVE is not set\n");
- osm_sa_send_error(sa, p_madw, IB_SA_MAD_STATUS_REQ_INVALID);
- goto Exit;
- }
-
- /* we only support SubnAdmGetMulti method */
- if (p_sa_mad->method != IB_MAD_METHOD_GETMULTI) {
- OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 4513: "
- "Unsupported Method (%s)\n",
- ib_get_sa_method_str(p_sa_mad->method));
- osm_sa_send_error(sa, p_madw, IB_MAD_STATUS_UNSUP_METHOD_ATTR);
- goto Exit;
- }
-
- /* update the requester physical port. */
- requester_port = osm_get_port_by_mad_addr(sa->p_log, sa->p_subn,
- osm_madw_get_mad_addr_ptr
- (p_madw));
- if (requester_port == NULL) {
- OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 4517: "
- "Cannot find requester physical port\n");
- goto Exit;
- }
-
- if (osm_log_is_active(sa->p_log, OSM_LOG_DEBUG))
- osm_dump_multipath_record(sa->p_log, p_mpr, OSM_LOG_DEBUG);
-
- cl_qlist_init(&pr_list);
-
- /*
- Most SA functions (including this one) are read-only on the
- subnet object, so we grab the lock non-exclusively.
- */
- cl_plock_acquire(sa->p_lock);
-
- sa_status = __osm_mpr_rcv_get_end_points(sa, p_madw, pp_ports,
- &nsrc, &ndest);
-
- if (sa_status != IB_SA_MAD_STATUS_SUCCESS || !nsrc || !ndest) {
- if (sa_status == IB_SA_MAD_STATUS_SUCCESS && (!nsrc || !ndest))
- OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 4512: "
- "__osm_mpr_rcv_get_end_points failed, not enough GIDs "
- "(nsrc %d ndest %d)\n", nsrc, ndest);
- cl_plock_release(sa->p_lock);
- if (sa_status == IB_SA_MAD_STATUS_SUCCESS)
- osm_sa_send_error(sa, p_madw,
- IB_SA_MAD_STATUS_REQ_INVALID);
- else
- osm_sa_send_error(sa, p_madw, sa_status);
- goto Exit;
- }
-
- /* APM request */
- if (nsrc == 2 && ndest == 2 && (p_mpr->num_path & 0x7F) == 2)
- __osm_mpr_rcv_get_apm_paths(sa, p_mpr, requester_port,
- pp_ports, p_sa_mad->comp_mask,
- &pr_list);
- else
- __osm_mpr_rcv_process_pairs(sa, p_mpr, requester_port,
- pp_ports, nsrc, ndest,
- p_sa_mad->comp_mask, &pr_list);
-
- cl_plock_release(sa->p_lock);
-
- /* o15-0.2.7: If MultiPath is supported, then SA shall respond to a
- SubnAdmGetMulti() containing a valid MultiPathRecord attribute with
- a set of zero or more PathRecords satisfying the constraints
- indicated in the MultiPathRecord received. The PathRecord Attribute
- ID shall be used in the response.
- */
- p_sa_mad->attr_id = IB_MAD_ATTR_PATH_RECORD;
- osm_sa_respond(sa, p_madw, sizeof(ib_path_rec_t), &pr_list);
-
-Exit:
- OSM_LOG_EXIT(sa->p_log);
-}
-#endif
diff --git a/contrib/ofed/management/opensm/opensm/osm_sa_node_record.c b/contrib/ofed/management/opensm/opensm/osm_sa_node_record.c
deleted file mode 100644
index 4df2c91..0000000
--- a/contrib/ofed/management/opensm/opensm/osm_sa_node_record.c
+++ /dev/null
@@ -1,355 +0,0 @@
-/*
- * Copyright (c) 2004-2008 Voltaire, Inc. All rights reserved.
- * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved.
- * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- */
-
-/*
- * Abstract:
- * Implementation of osm_nr_rcv_t.
- * This object represents the NodeInfo Receiver object.
- * This object is part of the opensm family of objects.
- */
-
-#if HAVE_CONFIG_H
-# include <config.h>
-#endif /* HAVE_CONFIG_H */
-
-#include <string.h>
-#include <iba/ib_types.h>
-#include <complib/cl_debug.h>
-#include <complib/cl_qlist.h>
-#include <vendor/osm_vendor_api.h>
-#include <opensm/osm_node.h>
-#include <opensm/osm_helper.h>
-#include <opensm/osm_pkey.h>
-#include <opensm/osm_sa.h>
-
-typedef struct osm_nr_item {
- cl_list_item_t list_item;
- ib_node_record_t rec;
-} osm_nr_item_t;
-
-typedef struct osm_nr_search_ctxt {
- const ib_node_record_t *p_rcvd_rec;
- ib_net64_t comp_mask;
- cl_qlist_t *p_list;
- osm_sa_t *sa;
- const osm_physp_t *p_req_physp;
-} osm_nr_search_ctxt_t;
-
-/**********************************************************************
- **********************************************************************/
-static ib_api_status_t
-__osm_nr_rcv_new_nr(IN osm_sa_t * sa,
- IN const osm_node_t * const p_node,
- IN cl_qlist_t * const p_list,
- IN ib_net64_t const port_guid, IN ib_net16_t const lid)
-{
- osm_nr_item_t *p_rec_item;
- ib_api_status_t status = IB_SUCCESS;
-
- OSM_LOG_ENTER(sa->p_log);
-
- p_rec_item = malloc(sizeof(*p_rec_item));
- if (p_rec_item == NULL) {
- OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 1D02: "
- "rec_item alloc failed\n");
- status = IB_INSUFFICIENT_RESOURCES;
- goto Exit;
- }
-
- OSM_LOG(sa->p_log, OSM_LOG_DEBUG,
- "New NodeRecord: node 0x%016" PRIx64
- "\n\t\t\t\tport 0x%016" PRIx64 ", lid %u\n",
- cl_ntoh64(osm_node_get_node_guid(p_node)),
- cl_ntoh64(port_guid), cl_ntoh16(lid));
-
- memset(p_rec_item, 0, sizeof(*p_rec_item));
-
- p_rec_item->rec.lid = lid;
-
- p_rec_item->rec.node_info = p_node->node_info;
- p_rec_item->rec.node_info.port_guid = port_guid;
- memcpy(&(p_rec_item->rec.node_desc), &(p_node->node_desc),
- IB_NODE_DESCRIPTION_SIZE);
- cl_qlist_insert_tail(p_list, &p_rec_item->list_item);
-
-Exit:
- OSM_LOG_EXIT(sa->p_log);
- return (status);
-}
-
-/**********************************************************************
- **********************************************************************/
-static void
-__osm_nr_rcv_create_nr(IN osm_sa_t * sa,
- IN osm_node_t * const p_node,
- IN cl_qlist_t * const p_list,
- IN ib_net64_t const match_port_guid,
- IN ib_net16_t const match_lid,
- IN const osm_physp_t * const p_req_physp)
-{
- const osm_physp_t *p_physp;
- uint8_t port_num;
- uint8_t num_ports;
- uint16_t match_lid_ho;
- ib_net16_t base_lid;
- ib_net16_t base_lid_ho;
- ib_net16_t max_lid_ho;
- uint8_t lmc;
- ib_net64_t port_guid;
-
- OSM_LOG_ENTER(sa->p_log);
-
- OSM_LOG(sa->p_log, OSM_LOG_DEBUG,
- "Looking for NodeRecord with LID: %u GUID:0x%016"
- PRIx64 "\n", cl_ntoh16(match_lid),
- cl_ntoh64(match_port_guid));
-
- /*
- For switches, do not return the NodeInfo record
- for each port on the switch, just for port 0.
- */
- if (osm_node_get_type(p_node) == IB_NODE_TYPE_SWITCH)
- num_ports = 1;
- else
- num_ports = osm_node_get_num_physp(p_node);
-
- for (port_num = 0; port_num < num_ports; port_num++) {
- p_physp = osm_node_get_physp_ptr(p_node, port_num);
- if (!p_physp)
- continue;
-
- /* Check to see if the found p_physp and the requester physp
- share a pkey. If not - continue */
- if (!osm_physp_share_pkey(sa->p_log, p_physp, p_req_physp))
- continue;
-
- port_guid = osm_physp_get_port_guid(p_physp);
-
- if (match_port_guid && (port_guid != match_port_guid))
- continue;
-
- base_lid = osm_physp_get_base_lid(p_physp);
- base_lid_ho = cl_ntoh16(base_lid);
- lmc = osm_physp_get_lmc(p_physp);
- max_lid_ho = (uint16_t) (base_lid_ho + (1 << lmc) - 1);
- match_lid_ho = cl_ntoh16(match_lid);
-
- if (match_lid_ho) {
- /*
- We validate that the lid belongs to this node.
- */
- OSM_LOG(sa->p_log, OSM_LOG_DEBUG,
- "Comparing LID: %u <= %u <= %u\n",
- base_lid_ho, match_lid_ho, max_lid_ho);
-
- if (match_lid_ho < base_lid_ho
- || match_lid_ho > max_lid_ho)
- continue;
- }
-
- __osm_nr_rcv_new_nr(sa, p_node, p_list, port_guid, base_lid);
-
- }
-
- OSM_LOG_EXIT(sa->p_log);
-}
-
-/**********************************************************************
- **********************************************************************/
-static void
-__osm_nr_rcv_by_comp_mask(IN cl_map_item_t * const p_map_item, IN void *context)
-{
- const osm_nr_search_ctxt_t *const p_ctxt =
- (osm_nr_search_ctxt_t *) context;
- osm_node_t *const p_node = (osm_node_t *) p_map_item;
- const ib_node_record_t *const p_rcvd_rec = p_ctxt->p_rcvd_rec;
- const osm_physp_t *const p_req_physp = p_ctxt->p_req_physp;
- osm_sa_t *sa = p_ctxt->sa;
- ib_net64_t const comp_mask = p_ctxt->comp_mask;
- ib_net64_t match_port_guid = 0;
- ib_net16_t match_lid = 0;
-
- OSM_LOG_ENTER(p_ctxt->sa->p_log);
-
- osm_dump_node_info(p_ctxt->sa->p_log,
- &p_node->node_info, OSM_LOG_VERBOSE);
-
- if (comp_mask & IB_NR_COMPMASK_LID)
- match_lid = p_rcvd_rec->lid;
-
- if (comp_mask & IB_NR_COMPMASK_NODEGUID) {
- OSM_LOG(sa->p_log, OSM_LOG_DEBUG,
- "Looking for node 0x%016" PRIx64
- ", found 0x%016" PRIx64 "\n",
- cl_ntoh64(p_rcvd_rec->node_info.node_guid),
- cl_ntoh64(osm_node_get_node_guid(p_node)));
-
- if ((p_node->node_info.node_guid !=
- p_rcvd_rec->node_info.node_guid))
- goto Exit;
- }
- if (comp_mask & IB_NR_COMPMASK_PORTGUID) {
- match_port_guid = p_rcvd_rec->node_info.port_guid;
- }
- if (comp_mask & IB_NR_COMPMASK_SYSIMAGEGUID) {
- if ((p_node->node_info.sys_guid !=
- p_rcvd_rec->node_info.sys_guid))
- goto Exit;
- }
- if (comp_mask & IB_NR_COMPMASK_BASEVERSION) {
- if ((p_node->node_info.base_version !=
- p_rcvd_rec->node_info.base_version))
- goto Exit;
- }
- if (comp_mask & IB_NR_COMPMASK_CLASSVERSION) {
- if ((p_node->node_info.class_version !=
- p_rcvd_rec->node_info.class_version))
- goto Exit;
- }
- if (comp_mask & IB_NR_COMPMASK_NODETYPE) {
- if ((p_node->node_info.node_type !=
- p_rcvd_rec->node_info.node_type))
- goto Exit;
- }
- if (comp_mask & IB_NR_COMPMASK_NUMPORTS) {
- if ((p_node->node_info.num_ports !=
- p_rcvd_rec->node_info.num_ports))
- goto Exit;
- }
- if (comp_mask & IB_NR_COMPMASK_PARTCAP) {
- if ((p_node->node_info.partition_cap !=
- p_rcvd_rec->node_info.partition_cap))
- goto Exit;
- }
- if (comp_mask & IB_NR_COMPMASK_DEVID) {
- if ((p_node->node_info.device_id !=
- p_rcvd_rec->node_info.device_id))
- goto Exit;
- }
- if (comp_mask & IB_NR_COMPMASK_REV) {
- if ((p_node->node_info.revision !=
- p_rcvd_rec->node_info.revision))
- goto Exit;
- }
- if (comp_mask & IB_NR_COMPMASK_PORTNUM) {
- if (ib_node_info_get_local_port_num(&p_node->node_info) !=
- ib_node_info_get_local_port_num(&p_rcvd_rec->node_info))
- goto Exit;
- }
- if (comp_mask & IB_NR_COMPMASK_VENDID) {
- if (ib_node_info_get_vendor_id(&p_node->node_info) !=
- ib_node_info_get_vendor_id(&p_rcvd_rec->node_info))
- goto Exit;
- }
- if (comp_mask & IB_NR_COMPMASK_NODEDESC) {
- if (strncmp((char *)&p_node->node_desc,
- (char *)&p_rcvd_rec->node_desc,
- sizeof(ib_node_desc_t)))
- goto Exit;
- }
-
- __osm_nr_rcv_create_nr(sa, p_node, p_ctxt->p_list,
- match_port_guid, match_lid, p_req_physp);
-
-Exit:
- OSM_LOG_EXIT(p_ctxt->sa->p_log);
-}
-
-/**********************************************************************
- **********************************************************************/
-void osm_nr_rcv_process(IN void *ctx, IN void *data)
-{
- osm_sa_t *sa = ctx;
- osm_madw_t *p_madw = data;
- const ib_sa_mad_t *p_rcvd_mad;
- const ib_node_record_t *p_rcvd_rec;
- cl_qlist_t rec_list;
- osm_nr_search_ctxt_t context;
- osm_physp_t *p_req_physp;
-
- CL_ASSERT(sa);
-
- OSM_LOG_ENTER(sa->p_log);
-
- CL_ASSERT(p_madw);
-
- p_rcvd_mad = osm_madw_get_sa_mad_ptr(p_madw);
- p_rcvd_rec = (ib_node_record_t *) ib_sa_mad_get_payload_ptr(p_rcvd_mad);
-
- CL_ASSERT(p_rcvd_mad->attr_id == IB_MAD_ATTR_NODE_RECORD);
-
- /* we only support SubnAdmGet and SubnAdmGetTable methods */
- if (p_rcvd_mad->method != IB_MAD_METHOD_GET &&
- p_rcvd_mad->method != IB_MAD_METHOD_GETTABLE) {
- OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 1D05: "
- "Unsupported Method (%s)\n",
- ib_get_sa_method_str(p_rcvd_mad->method));
- osm_sa_send_error(sa, p_madw, IB_MAD_STATUS_UNSUP_METHOD_ATTR);
- goto Exit;
- }
-
- /* update the requester physical port. */
- p_req_physp = osm_get_physp_by_mad_addr(sa->p_log, sa->p_subn,
- osm_madw_get_mad_addr_ptr
- (p_madw));
- if (p_req_physp == NULL) {
- OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 1D04: "
- "Cannot find requester physical port\n");
- goto Exit;
- }
-
- if (osm_log_is_active(sa->p_log, OSM_LOG_DEBUG))
- osm_dump_node_record(sa->p_log, p_rcvd_rec, OSM_LOG_DEBUG);
-
- cl_qlist_init(&rec_list);
-
- context.p_rcvd_rec = p_rcvd_rec;
- context.p_list = &rec_list;
- context.comp_mask = p_rcvd_mad->comp_mask;
- context.sa = sa;
- context.p_req_physp = p_req_physp;
-
- cl_plock_acquire(sa->p_lock);
-
- cl_qmap_apply_func(&sa->p_subn->node_guid_tbl,
- __osm_nr_rcv_by_comp_mask, &context);
-
- cl_plock_release(sa->p_lock);
-
- osm_sa_respond(sa, p_madw, sizeof(ib_node_record_t), &rec_list);
-
-Exit:
- OSM_LOG_EXIT(sa->p_log);
-}
diff --git a/contrib/ofed/management/opensm/opensm/osm_sa_path_record.c b/contrib/ofed/management/opensm/opensm/osm_sa_path_record.c
deleted file mode 100644
index 6fdada7..0000000
--- a/contrib/ofed/management/opensm/opensm/osm_sa_path_record.c
+++ /dev/null
@@ -1,1813 +0,0 @@
-/*
- * Copyright (c) 2004-2008 Voltaire, Inc. All rights reserved.
- * Copyright (c) 2002-2006 Mellanox Technologies LTD. All rights reserved.
- * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
- * Copyright (c) 2008 Xsigo Systems Inc. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- */
-
-/*
- * Abstract:
- * Implementation of osm_pr_rcv_t.
- * This object represents the PathRecord Receiver object.
- * This object is part of the opensm family of objects.
- */
-
-#if HAVE_CONFIG_H
-# include <config.h>
-#endif /* HAVE_CONFIG_H */
-
-#include <string.h>
-#include <arpa/inet.h>
-#include <iba/ib_types.h>
-#include <complib/cl_qmap.h>
-#include <complib/cl_passivelock.h>
-#include <complib/cl_debug.h>
-#include <complib/cl_qlist.h>
-#include <vendor/osm_vendor_api.h>
-#include <opensm/osm_base.h>
-#include <opensm/osm_port.h>
-#include <opensm/osm_node.h>
-#include <opensm/osm_switch.h>
-#include <opensm/osm_helper.h>
-#include <opensm/osm_pkey.h>
-#include <opensm/osm_multicast.h>
-#include <opensm/osm_partition.h>
-#include <opensm/osm_opensm.h>
-#include <opensm/osm_qos_policy.h>
-#include <opensm/osm_sa.h>
-#include <opensm/osm_router.h>
-#include <opensm/osm_prefix_route.h>
-
-#include <sys/socket.h>
-
-extern uint8_t osm_get_lash_sl(osm_opensm_t * p_osm,
- const osm_port_t * p_src_port,
- const osm_port_t * p_dst_port);
-
-typedef struct osm_pr_item {
- cl_list_item_t list_item;
- ib_path_rec_t path_rec;
-} osm_pr_item_t;
-
-typedef struct osm_path_parms {
- ib_net16_t pkey;
- uint8_t mtu;
- uint8_t rate;
- uint8_t sl;
- uint8_t pkt_life;
- boolean_t reversible;
-} osm_path_parms_t;
-
-static const ib_gid_t zero_gid = { {0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00},
-};
-
-/**********************************************************************
- **********************************************************************/
-static inline boolean_t
-__osm_sa_path_rec_is_tavor_port(IN const osm_port_t * const p_port)
-{
- osm_node_t const *p_node;
- ib_net32_t vend_id;
-
- p_node = p_port->p_node;
- vend_id = ib_node_info_get_vendor_id(&p_node->node_info);
-
- return ((p_node->node_info.device_id == CL_HTON16(23108)) &&
- ((vend_id == CL_HTON32(OSM_VENDOR_ID_MELLANOX)) ||
- (vend_id == CL_HTON32(OSM_VENDOR_ID_TOPSPIN)) ||
- (vend_id == CL_HTON32(OSM_VENDOR_ID_SILVERSTORM)) ||
- (vend_id == CL_HTON32(OSM_VENDOR_ID_VOLTAIRE))));
-}
-
-/**********************************************************************
- **********************************************************************/
-static boolean_t
-__osm_sa_path_rec_apply_tavor_mtu_limit(IN const ib_path_rec_t * const p_pr,
- IN const osm_port_t * const p_src_port,
- IN const osm_port_t * const p_dest_port,
- IN const ib_net64_t comp_mask)
-{
- uint8_t required_mtu;
-
- /* only if at least one of the ports is a Tavor device */
- if (!__osm_sa_path_rec_is_tavor_port(p_src_port) &&
- !__osm_sa_path_rec_is_tavor_port(p_dest_port))
- return (FALSE);
-
- /*
- we can apply the patch if either:
- 1. No MTU required
- 2. Required MTU <
- 3. Required MTU = 1K or 512 or 256
- 4. Required MTU > 256 or 512
- */
- required_mtu = ib_path_rec_mtu(p_pr);
- if ((comp_mask & IB_PR_COMPMASK_MTUSELEC) &&
- (comp_mask & IB_PR_COMPMASK_MTU)) {
- switch (ib_path_rec_mtu_sel(p_pr)) {
- case 0: /* must be greater than */
- case 2: /* exact match */
- if (IB_MTU_LEN_1024 < required_mtu)
- return (FALSE);
- break;
-
- case 1: /* must be less than */
- /* can't be disqualified by this one */
- break;
-
- case 3: /* largest available */
- /* the ULP intentionally requested */
- /* the largest MTU possible */
- return (FALSE);
- break;
-
- default:
- /* if we're here, there's a bug in ib_path_rec_mtu_sel() */
- CL_ASSERT(FALSE);
- break;
- }
- }
-
- return (TRUE);
-}
-
-/**********************************************************************
- **********************************************************************/
-static ib_api_status_t
-__osm_pr_rcv_get_path_parms(IN osm_sa_t * sa,
- IN const ib_path_rec_t * const p_pr,
- IN const osm_port_t * const p_src_port,
- IN const osm_port_t * const p_dest_port,
- IN const uint16_t dest_lid_ho,
- IN const ib_net64_t comp_mask,
- OUT osm_path_parms_t * const p_parms)
-{
- const osm_node_t *p_node;
- const osm_physp_t *p_physp;
- const osm_physp_t *p_src_physp;
- const osm_physp_t *p_dest_physp;
- const osm_prtn_t *p_prtn = NULL;
- osm_opensm_t *p_osm;
- const ib_port_info_t *p_pi;
- ib_api_status_t status = IB_SUCCESS;
- ib_net16_t pkey;
- uint8_t mtu;
- uint8_t rate;
- uint8_t pkt_life;
- uint8_t required_mtu;
- uint8_t required_rate;
- uint8_t required_pkt_life;
- uint8_t sl;
- uint8_t in_port_num;
- ib_net16_t dest_lid;
- uint8_t i;
- ib_slvl_table_t *p_slvl_tbl = NULL;
- osm_qos_level_t *p_qos_level = NULL;
- uint16_t valid_sl_mask = 0xffff;
- int is_lash;
-
- OSM_LOG_ENTER(sa->p_log);
-
- dest_lid = cl_hton16(dest_lid_ho);
-
- p_dest_physp = p_dest_port->p_physp;
- p_physp = p_src_port->p_physp;
- p_src_physp = p_physp;
- p_pi = &p_physp->port_info;
- p_osm = sa->p_subn->p_osm;
-
- mtu = ib_port_info_get_mtu_cap(p_pi);
- rate = ib_port_info_compute_rate(p_pi);
-
- /*
- Mellanox Tavor device performance is better using 1K MTU.
- If required MTU and MTU selector are such that 1K is OK
- and at least one end of the path is Tavor we override the
- port MTU with 1K.
- */
- if (sa->p_subn->opt.enable_quirks &&
- __osm_sa_path_rec_apply_tavor_mtu_limit(p_pr, p_src_port,
- p_dest_port, comp_mask))
- if (mtu > IB_MTU_LEN_1024) {
- mtu = IB_MTU_LEN_1024;
- OSM_LOG(sa->p_log, OSM_LOG_DEBUG,
- "Optimized Path MTU to 1K for Mellanox Tavor device\n");
- }
-
- /*
- Walk the subnet object from source to destination,
- tracking the most restrictive rate and mtu values along the way...
-
- If source port node is a switch, then p_physp should
- point to the port that routes the destination lid
- */
-
- p_node = osm_physp_get_node_ptr(p_physp);
-
- if (p_node->sw) {
- /*
- * Source node is a switch.
- * Make sure that p_physp points to the out port of the
- * switch that routes to the destination lid (dest_lid_ho)
- */
- p_physp = osm_switch_get_route_by_lid(p_node->sw, dest_lid);
- if (p_physp == 0) {
- OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 1F02: "
- "Cannot find routing to LID %u from switch for GUID 0x%016"
- PRIx64 "\n", dest_lid_ho,
- cl_ntoh64(osm_node_get_node_guid(p_node)));
- status = IB_NOT_FOUND;
- goto Exit;
- }
- }
-
- if (sa->p_subn->opt.qos) {
-
- /*
- * Whether this node is switch or CA, the IN port for
- * the sl2vl table is 0, because this is a source node.
- */
- p_slvl_tbl = osm_physp_get_slvl_tbl(p_physp, 0);
-
- /* update valid SLs that still exist on this route */
- for (i = 0; i < IB_MAX_NUM_VLS; i++) {
- if (valid_sl_mask & (1 << i) &&
- ib_slvl_table_get(p_slvl_tbl, i) == IB_DROP_VL)
- valid_sl_mask &= ~(1 << i);
- }
- if (!valid_sl_mask) {
- OSM_LOG(sa->p_log, OSM_LOG_DEBUG,
- "All the SLs lead to VL15 on this path\n");
- status = IB_NOT_FOUND;
- goto Exit;
- }
- }
-
- /*
- * Same as above
- */
- p_node = osm_physp_get_node_ptr(p_dest_physp);
-
- if (p_node->sw) {
- /*
- * if destination is switch, we want p_dest_physp to point to port 0
- */
- p_dest_physp = osm_switch_get_route_by_lid(p_node->sw, dest_lid);
-
- if (p_dest_physp == 0) {
- OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 1F03: "
- "Cannot find routing to LID %u from switch for GUID 0x%016"
- PRIx64 "\n", dest_lid_ho,
- cl_ntoh64(osm_node_get_node_guid(p_node)));
- status = IB_NOT_FOUND;
- goto Exit;
- }
-
- }
-
- /*
- * Now go through the path step by step
- */
-
- while (p_physp != p_dest_physp) {
-
- p_node = osm_physp_get_node_ptr(p_physp);
- p_physp = osm_physp_get_remote(p_physp);
-
- if (p_physp == 0) {
- OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 1F05: "
- "Cannot find remote phys port when routing to LID %u from node GUID 0x%016"
- PRIx64 "\n", dest_lid_ho,
- cl_ntoh64(osm_node_get_node_guid(p_node)));
- status = IB_ERROR;
- goto Exit;
- }
-
- in_port_num = osm_physp_get_port_num(p_physp);
-
- /*
- This is point to point case (no switch in between)
- */
- if (p_physp == p_dest_physp)
- break;
-
- p_node = osm_physp_get_node_ptr(p_physp);
-
- if (!p_node->sw) {
- /*
- There is some sort of problem in the subnet object!
- If this isn't a switch, we should have reached
- the destination by now!
- */
- OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 1F06: "
- "Internal error, bad path\n");
- status = IB_ERROR;
- goto Exit;
- }
-
- /*
- Check parameters for the ingress port in this switch.
- */
- p_pi = &p_physp->port_info;
-
- if (mtu > ib_port_info_get_mtu_cap(p_pi))
- mtu = ib_port_info_get_mtu_cap(p_pi);
-
- if (rate > ib_port_info_compute_rate(p_pi))
- rate = ib_port_info_compute_rate(p_pi);
-
- /*
- Continue with the egress port on this switch.
- */
- p_physp = osm_switch_get_route_by_lid(p_node->sw, dest_lid);
- if (p_physp == 0) {
- OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 1F07: "
- "Dead end on path to LID %u from switch for GUID 0x%016"
- PRIx64 "\n", dest_lid_ho,
- cl_ntoh64(osm_node_get_node_guid(p_node)));
- status = IB_ERROR;
- goto Exit;
- }
-
- p_pi = &p_physp->port_info;
-
- if (mtu > ib_port_info_get_mtu_cap(p_pi))
- mtu = ib_port_info_get_mtu_cap(p_pi);
-
- if (rate > ib_port_info_compute_rate(p_pi))
- rate = ib_port_info_compute_rate(p_pi);
-
- if (sa->p_subn->opt.qos) {
- /*
- * Check SL2VL table of the switch and update valid SLs
- */
- p_slvl_tbl = osm_physp_get_slvl_tbl(p_physp, in_port_num);
- for (i = 0; i < IB_MAX_NUM_VLS; i++) {
- if (valid_sl_mask & (1 << i) &&
- ib_slvl_table_get(p_slvl_tbl, i) == IB_DROP_VL)
- valid_sl_mask &= ~(1 << i);
- }
- if (!valid_sl_mask) {
- OSM_LOG(sa->p_log, OSM_LOG_DEBUG, "All the SLs "
- "lead to VL15 on this path\n");
- status = IB_NOT_FOUND;
- goto Exit;
- }
- }
- }
-
- /*
- p_physp now points to the destination
- */
- p_pi = &p_physp->port_info;
-
- if (mtu > ib_port_info_get_mtu_cap(p_pi))
- mtu = ib_port_info_get_mtu_cap(p_pi);
-
- if (rate > ib_port_info_compute_rate(p_pi))
- rate = ib_port_info_compute_rate(p_pi);
-
- OSM_LOG(sa->p_log, OSM_LOG_DEBUG,
- "Path min MTU = %u, min rate = %u\n", mtu, rate);
-
- /*
- * Get QoS Level object according to the path request
- * and adjust path parameters according to QoS settings
- */
- if (sa->p_subn->opt.qos &&
- sa->p_subn->p_qos_policy &&
- (p_qos_level =
- osm_qos_policy_get_qos_level_by_pr(sa->p_subn->p_qos_policy,
- p_pr, p_src_physp, p_dest_physp,
- comp_mask))) {
- OSM_LOG(sa->p_log, OSM_LOG_DEBUG,
- "PathRecord request matches QoS Level '%s' (%s)\n",
- p_qos_level->name, p_qos_level->use ?
- p_qos_level->use : "no description");
-
- if (p_qos_level->mtu_limit_set
- && (mtu > p_qos_level->mtu_limit))
- mtu = p_qos_level->mtu_limit;
-
- if (p_qos_level->rate_limit_set
- && (rate > p_qos_level->rate_limit))
- rate = p_qos_level->rate_limit;
-
- if (p_qos_level->sl_set) {
- sl = p_qos_level->sl;
- if (!(valid_sl_mask & (1 << sl))) {
- status = IB_NOT_FOUND;
- goto Exit;
- }
- }
- }
-
- /*
- * Set packet lifetime.
- * According to spec definition IBA 1.2 Table 205
- * PacketLifeTime description, for loopback paths,
- * packetLifeTime shall be zero.
- */
- if (p_src_port == p_dest_port)
- pkt_life = 0;
- else if (p_qos_level && p_qos_level->pkt_life_set)
- pkt_life = p_qos_level->pkt_life;
- else
- pkt_life = sa->p_subn->opt.subnet_timeout;
-
- /*
- Determine if these values meet the user criteria
- and adjust appropriately
- */
-
- /* we silently ignore cases where only the MTU selector is defined */
- if ((comp_mask & IB_PR_COMPMASK_MTUSELEC) &&
- (comp_mask & IB_PR_COMPMASK_MTU)) {
- required_mtu = ib_path_rec_mtu(p_pr);
- switch (ib_path_rec_mtu_sel(p_pr)) {
- case 0: /* must be greater than */
- if (mtu <= required_mtu)
- status = IB_NOT_FOUND;
- break;
-
- case 1: /* must be less than */
- if (mtu >= required_mtu) {
- /* adjust to use the highest mtu
- lower then the required one */
- if (required_mtu > 1)
- mtu = required_mtu - 1;
- else
- status = IB_NOT_FOUND;
- }
- break;
-
- case 2: /* exact match */
- if (mtu < required_mtu)
- status = IB_NOT_FOUND;
- else
- mtu = required_mtu;
- break;
-
- case 3: /* largest available */
- /* can't be disqualified by this one */
- break;
-
- default:
- /* if we're here, there's a bug in ib_path_rec_mtu_sel() */
- CL_ASSERT(FALSE);
- status = IB_ERROR;
- break;
- }
- }
- if (status != IB_SUCCESS)
- goto Exit;
-
- /* we silently ignore cases where only the Rate selector is defined */
- if ((comp_mask & IB_PR_COMPMASK_RATESELEC) &&
- (comp_mask & IB_PR_COMPMASK_RATE)) {
- required_rate = ib_path_rec_rate(p_pr);
- switch (ib_path_rec_rate_sel(p_pr)) {
- case 0: /* must be greater than */
- if (rate <= required_rate)
- status = IB_NOT_FOUND;
- break;
-
- case 1: /* must be less than */
- if (rate >= required_rate) {
- /* adjust the rate to use the highest rate
- lower then the required one */
- if (required_rate > 2)
- rate = required_rate - 1;
- else
- status = IB_NOT_FOUND;
- }
- break;
-
- case 2: /* exact match */
- if (rate < required_rate)
- status = IB_NOT_FOUND;
- else
- rate = required_rate;
- break;
-
- case 3: /* largest available */
- /* can't be disqualified by this one */
- break;
-
- default:
- /* if we're here, there's a bug in ib_path_rec_mtu_sel() */
- CL_ASSERT(FALSE);
- status = IB_ERROR;
- break;
- }
- }
- if (status != IB_SUCCESS)
- goto Exit;
-
- /* we silently ignore cases where only the PktLife selector is defined */
- if ((comp_mask & IB_PR_COMPMASK_PKTLIFETIMESELEC) &&
- (comp_mask & IB_PR_COMPMASK_PKTLIFETIME)) {
- required_pkt_life = ib_path_rec_pkt_life(p_pr);
- switch (ib_path_rec_pkt_life_sel(p_pr)) {
- case 0: /* must be greater than */
- if (pkt_life <= required_pkt_life)
- status = IB_NOT_FOUND;
- break;
-
- case 1: /* must be less than */
- if (pkt_life >= required_pkt_life) {
- /* adjust the lifetime to use the highest possible
- lower then the required one */
- if (required_pkt_life > 1)
- pkt_life = required_pkt_life - 1;
- else
- status = IB_NOT_FOUND;
- }
- break;
-
- case 2: /* exact match */
- if (pkt_life < required_pkt_life)
- status = IB_NOT_FOUND;
- else
- pkt_life = required_pkt_life;
- break;
-
- case 3: /* smallest available */
- /* can't be disqualified by this one */
- break;
-
- default:
- /* if we're here, there's a bug in ib_path_rec_pkt_life_sel() */
- CL_ASSERT(FALSE);
- status = IB_ERROR;
- break;
- }
- }
-
- if (status != IB_SUCCESS)
- goto Exit;
-
- /*
- * set Pkey for this path record request
- */
-
- if ((comp_mask & IB_PR_COMPMASK_RAWTRAFFIC) &&
- (cl_ntoh32(p_pr->hop_flow_raw) & (1 << 31)))
- pkey = osm_physp_find_common_pkey(p_src_physp, p_dest_physp);
-
- else if (comp_mask & IB_PR_COMPMASK_PKEY) {
- /*
- * PR request has a specific pkey:
- * Check that source and destination share this pkey.
- * If QoS level has pkeys, check that this pkey exists
- * in the QoS level pkeys.
- * PR returned pkey is the requested pkey.
- */
- pkey = p_pr->pkey;
- if (!osm_physp_share_this_pkey(p_src_physp, p_dest_physp, pkey)) {
- OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 1F1A: "
- "Ports 0x%016" PRIx64 " 0x%016" PRIx64
- " do not share specified PKey 0x%04x\n",
- cl_ntoh64(osm_physp_get_port_guid(p_src_physp)),
- cl_ntoh64(osm_physp_get_port_guid(p_dest_physp)),
- cl_ntoh16(pkey));
- status = IB_NOT_FOUND;
- goto Exit;
- }
- if (p_qos_level && p_qos_level->pkey_range_len &&
- !osm_qos_level_has_pkey(p_qos_level, pkey)) {
- OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 1F1D: "
- "Ports do not share PKeys defined by QoS level\n");
- status = IB_NOT_FOUND;
- goto Exit;
- }
-
- } else if (p_qos_level && p_qos_level->pkey_range_len) {
- /*
- * PR request doesn't have a specific pkey, but QoS level
- * has pkeys - get shared pkey from QoS level pkeys
- */
- pkey = osm_qos_level_get_shared_pkey(p_qos_level,
- p_src_physp, p_dest_physp);
- if (!pkey) {
- OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 1F1E: "
- "Ports 0x%016" PRIx64 " 0x%016" PRIx64
- " do not share PKeys defined by QoS level\n",
- cl_ntoh64(osm_physp_get_port_guid(p_src_physp)),
- cl_ntoh64(osm_physp_get_port_guid(p_dest_physp)));
- status = IB_NOT_FOUND;
- goto Exit;
- }
- } else {
- /*
- * Neither PR request nor QoS level have pkey.
- * Just get any shared pkey.
- */
- pkey = osm_physp_find_common_pkey(p_src_physp, p_dest_physp);
- if (!pkey) {
- OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 1F1B: "
- "Ports 0x%016" PRIx64 " 0x%016" PRIx64
- " do not have any shared PKeys\n",
- cl_ntoh64(osm_physp_get_port_guid(p_src_physp)),
- cl_ntoh64(osm_physp_get_port_guid(p_dest_physp)));
- status = IB_NOT_FOUND;
- goto Exit;
- }
- }
-
- if (pkey) {
- p_prtn =
- (osm_prtn_t *) cl_qmap_get(&sa->p_subn->prtn_pkey_tbl,
- pkey & cl_hton16((uint16_t) ~
- 0x8000));
- if (p_prtn ==
- (osm_prtn_t *) cl_qmap_end(&sa->p_subn->prtn_pkey_tbl))
- p_prtn = NULL;
- }
-
- /*
- * Set PathRecord SL.
- */
-
- is_lash = (p_osm->routing_engine_used == OSM_ROUTING_ENGINE_TYPE_LASH);
-
- if (comp_mask & IB_PR_COMPMASK_SL) {
- /*
- * Specific SL was requested
- */
- sl = ib_path_rec_sl(p_pr);
-
- if (p_qos_level && p_qos_level->sl_set
- && (p_qos_level->sl != sl)) {
- OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 1F1F: "
- "QoS constaraints: required PathRecord SL (%u) "
- "doesn't match QoS policy SL (%u)\n", sl,
- p_qos_level->sl);
- status = IB_NOT_FOUND;
- goto Exit;
- }
-
- if (is_lash
- && osm_get_lash_sl(p_osm, p_src_port, p_dest_port) != sl) {
- OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 1F23: "
- "Required PathRecord SL (%u) doesn't "
- "match LASH SL\n", sl);
- status = IB_NOT_FOUND;
- goto Exit;
- }
-
- } else if (is_lash) {
- /*
- * No specific SL in PathRecord request.
- * If it's LASH routing - use its SL.
- * slid and dest_lid are stored in network in lash.
- */
- sl = osm_get_lash_sl(p_osm, p_src_port, p_dest_port);
- } else if (p_qos_level && p_qos_level->sl_set) {
- /*
- * No specific SL was requested, and we're not in
- * LASH routing, but there is an SL in QoS level.
- */
- sl = p_qos_level->sl;
-
- if (pkey && p_prtn && p_prtn->sl != p_qos_level->sl)
- OSM_LOG(sa->p_log, OSM_LOG_DEBUG,
- "QoS level SL (%u) overrides partition SL (%u)\n",
- p_qos_level->sl, p_prtn->sl);
-
- } else if (pkey) {
- /*
- * No specific SL in request or in QoS level - use partition SL
- */
- if (!p_prtn) {
- sl = OSM_DEFAULT_SL;
- /* this may be possible when pkey tables are created somehow in
- previous runs or things are going wrong here */
- OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 1F1C: "
- "No partition found for PKey 0x%04x - using default SL %d\n",
- cl_ntoh16(pkey), sl);
- } else
- sl = p_prtn->sl;
- } else if (sa->p_subn->opt.qos) {
- if (valid_sl_mask & (1 << OSM_DEFAULT_SL))
- sl = OSM_DEFAULT_SL;
- else {
- for (i = 0; i < IB_MAX_NUM_VLS; i++)
- if (valid_sl_mask & (1 << i))
- break;
- sl = i;
- }
- } else
- sl = OSM_DEFAULT_SL;
-
- if (sa->p_subn->opt.qos && !(valid_sl_mask & (1 << sl))) {
- OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 1F24: "
- "Selected SL (%u) leads to VL15\n", sl);
- status = IB_NOT_FOUND;
- goto Exit;
- }
-
- /* reset pkey when raw traffic */
- if (comp_mask & IB_PR_COMPMASK_RAWTRAFFIC &&
- cl_ntoh32(p_pr->hop_flow_raw) & (1 << 31))
- pkey = 0;
-
- p_parms->mtu = mtu;
- p_parms->rate = rate;
- p_parms->pkt_life = pkt_life;
- p_parms->pkey = pkey;
- p_parms->sl = sl;
-
- OSM_LOG(sa->p_log, OSM_LOG_DEBUG, "Path params: mtu = %u, rate = %u,"
- " packet lifetime = %u, pkey = 0x%04X, sl = %u\n",
- mtu, rate, pkt_life, cl_ntoh16(pkey), sl);
-Exit:
- OSM_LOG_EXIT(sa->p_log);
- return (status);
-}
-
-/**********************************************************************
- **********************************************************************/
-static void
-__osm_pr_rcv_build_pr(IN osm_sa_t * sa,
- IN const osm_port_t * const p_src_port,
- IN const osm_port_t * const p_dest_port,
- IN const ib_gid_t * const p_dgid,
- IN const uint16_t src_lid_ho,
- IN const uint16_t dest_lid_ho,
- IN const uint8_t preference,
- IN const osm_path_parms_t * const p_parms,
- OUT ib_path_rec_t * const p_pr)
-{
- const osm_physp_t *p_src_physp;
- const osm_physp_t *p_dest_physp;
- boolean_t is_nonzero_gid = 0;
-
- OSM_LOG_ENTER(sa->p_log);
-
- p_src_physp = p_src_port->p_physp;
-
- if (p_dgid) {
- if (memcmp(p_dgid, &zero_gid, sizeof(*p_dgid)))
- is_nonzero_gid = 1;
- }
-
- if (is_nonzero_gid)
- p_pr->dgid = *p_dgid;
- else {
- p_dest_physp = p_dest_port->p_physp;
-
- p_pr->dgid.unicast.prefix =
- osm_physp_get_subnet_prefix(p_dest_physp);
- p_pr->dgid.unicast.interface_id =
- osm_physp_get_port_guid(p_dest_physp);
- }
-
- p_pr->sgid.unicast.prefix = osm_physp_get_subnet_prefix(p_src_physp);
- p_pr->sgid.unicast.interface_id = osm_physp_get_port_guid(p_src_physp);
-
- p_pr->dlid = cl_hton16(dest_lid_ho);
- p_pr->slid = cl_hton16(src_lid_ho);
-
- p_pr->hop_flow_raw &= cl_hton32(1 << 31);
-
- /* Only set HopLimit if going through a router */
- if (is_nonzero_gid)
- p_pr->hop_flow_raw |= cl_hton32(IB_HOPLIMIT_MAX);
-
- p_pr->pkey = p_parms->pkey;
- ib_path_rec_set_sl(p_pr, p_parms->sl);
- ib_path_rec_set_qos_class(p_pr, 0);
- p_pr->mtu = (uint8_t) (p_parms->mtu | 0x80);
- p_pr->rate = (uint8_t) (p_parms->rate | 0x80);
-
- /* According to 1.2 spec definition Table 205 PacketLifeTime description,
- for loopback paths, packetLifeTime shall be zero. */
- if (p_src_port == p_dest_port)
- p_pr->pkt_life = 0x80; /* loopback */
- else
- p_pr->pkt_life = (uint8_t) (p_parms->pkt_life | 0x80);
-
- p_pr->preference = preference;
-
- /* always return num_path = 0 so this is only the reversible component */
- if (p_parms->reversible)
- p_pr->num_path = 0x80;
-
- OSM_LOG_EXIT(sa->p_log);
-}
-
-/**********************************************************************
- **********************************************************************/
-static osm_pr_item_t *
-__osm_pr_rcv_get_lid_pair_path(IN osm_sa_t * sa,
- IN const ib_path_rec_t * const p_pr,
- IN const osm_port_t * const p_src_port,
- IN const osm_port_t * const p_dest_port,
- IN const ib_gid_t * const p_dgid,
- IN const uint16_t src_lid_ho,
- IN const uint16_t dest_lid_ho,
- IN const ib_net64_t comp_mask,
- IN const uint8_t preference)
-{
- osm_path_parms_t path_parms;
- osm_path_parms_t rev_path_parms;
- osm_pr_item_t *p_pr_item;
- ib_api_status_t status, rev_path_status;
-
- OSM_LOG_ENTER(sa->p_log);
-
- OSM_LOG(sa->p_log, OSM_LOG_DEBUG, "Src LID %u, Dest LID %u\n",
- src_lid_ho, dest_lid_ho);
-
- p_pr_item = malloc(sizeof(*p_pr_item));
- if (p_pr_item == NULL) {
- OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 1F01: "
- "Unable to allocate path record\n");
- goto Exit;
- }
- memset(p_pr_item, 0, sizeof(*p_pr_item));
-
- status = __osm_pr_rcv_get_path_parms(sa, p_pr, p_src_port,
- p_dest_port, dest_lid_ho,
- comp_mask, &path_parms);
-
- if (status != IB_SUCCESS) {
- free(p_pr_item);
- p_pr_item = NULL;
- goto Exit;
- }
-
- /* now try the reversible path */
- rev_path_status = __osm_pr_rcv_get_path_parms(sa, p_pr, p_dest_port,
- p_src_port, src_lid_ho,
- comp_mask,
- &rev_path_parms);
- path_parms.reversible = (rev_path_status == IB_SUCCESS);
-
- /* did we get a Reversible Path compmask ? */
- /*
- NOTE that if the reversible component = 0, it is a don't care
- rather then requiring non-reversible paths ...
- see Vol1 Ver1.2 p900 l16
- */
- if (comp_mask & IB_PR_COMPMASK_REVERSIBLE) {
- if ((!path_parms.reversible && (p_pr->num_path & 0x80))) {
- OSM_LOG(sa->p_log, OSM_LOG_DEBUG,
- "Requested reversible path but failed to get one\n");
-
- free(p_pr_item);
- p_pr_item = NULL;
- goto Exit;
- }
- }
-
- __osm_pr_rcv_build_pr(sa, p_src_port, p_dest_port, p_dgid,
- src_lid_ho, dest_lid_ho, preference, &path_parms,
- &p_pr_item->path_rec);
-
-Exit:
- OSM_LOG_EXIT(sa->p_log);
- return (p_pr_item);
-}
-
-/**********************************************************************
- **********************************************************************/
-static void
-__osm_pr_rcv_get_port_pair_paths(IN osm_sa_t * sa,
- IN const osm_madw_t * const p_madw,
- IN const osm_port_t * const p_req_port,
- IN const osm_port_t * const p_src_port,
- IN const osm_port_t * const p_dest_port,
- IN const ib_gid_t * const p_dgid,
- IN const ib_net64_t comp_mask,
- IN cl_qlist_t * const p_list)
-{
- const ib_path_rec_t *p_pr;
- const ib_sa_mad_t *p_sa_mad;
- osm_pr_item_t *p_pr_item;
- uint16_t src_lid_min_ho;
- uint16_t src_lid_max_ho;
- uint16_t dest_lid_min_ho;
- uint16_t dest_lid_max_ho;
- uint16_t src_lid_ho;
- uint16_t dest_lid_ho;
- uint32_t path_num;
- uint8_t preference;
- uintn_t iterations;
- uintn_t src_offset;
- uintn_t dest_offset;
-
- OSM_LOG_ENTER(sa->p_log);
-
- OSM_LOG(sa->p_log, OSM_LOG_DEBUG,
- "Src port 0x%016" PRIx64 ", Dst port 0x%016" PRIx64 "\n",
- cl_ntoh64(osm_port_get_guid(p_src_port)),
- cl_ntoh64(osm_port_get_guid(p_dest_port)));
-
- /* Check that the req_port, src_port and dest_port all share a
- pkey. The check is done on the default physical port of the ports. */
- if (osm_port_share_pkey(sa->p_log, p_req_port, p_src_port) == FALSE
- || osm_port_share_pkey(sa->p_log, p_req_port,
- p_dest_port) == FALSE
- || osm_port_share_pkey(sa->p_log, p_src_port,
- p_dest_port) == FALSE)
- /* One of the pairs doesn't share a pkey so the path is disqualified. */
- goto Exit;
-
- p_sa_mad = osm_madw_get_sa_mad_ptr(p_madw);
- p_pr = (ib_path_rec_t *) ib_sa_mad_get_payload_ptr(p_sa_mad);
-
- /*
- We shouldn't be here if the paths are disqualified in some way...
- Thus, we assume every possible connection is valid.
-
- We desire to return high-quality paths first.
- In OpenSM, higher quality means least overlap with other paths.
- This is acheived in practice by returning paths with
- different LID value on each end, which means these
- paths are more redundant that paths with the same LID repeated
- on one side. For example, in OpenSM the paths between two
- endpoints with LMC = 1 might be as follows:
-
- Port A, LID 1 <-> Port B, LID 3
- Port A, LID 1 <-> Port B, LID 4
- Port A, LID 2 <-> Port B, LID 3
- Port A, LID 2 <-> Port B, LID 4
-
- The OpenSM unicast routing algorithms attempt to disperse each path
- to as varied a physical path as is reasonable. 1<->3 and 1<->4 have
- more physical overlap (hence less redundancy) than 1<->3 and 2<->4.
-
- OpenSM ranks paths in three preference groups:
-
- Preference Value Description
- ---------------- -------------------------------------------
- 0 Redundant in both directions with other
- pref value = 0 paths
-
- 1 Redundant in one direction with other
- pref value = 0 and pref value = 1 paths
-
- 2 Not redundant in either direction with
- other paths
-
- 3-FF Unused
-
- SA clients don't need to know these details, only that the lower
- preference paths are preferred, as stated in the spec. The paths
- may not actually be physically redundant depending on the topology
- of the subnet, but the point of LMC > 0 is to offer redundancy,
- so it is assumed that the subnet is physically appropriate for the
- specified LMC value. A more advanced implementation would inspect for
- physical redundancy, but I'm not going to bother with that now.
- */
-
- /*
- Refine our search if the client specified end-point LIDs
- */
- if (comp_mask & IB_PR_COMPMASK_DLID) {
- dest_lid_min_ho = cl_ntoh16(p_pr->dlid);
- dest_lid_max_ho = cl_ntoh16(p_pr->dlid);
- } else
- osm_port_get_lid_range_ho(p_dest_port, &dest_lid_min_ho,
- &dest_lid_max_ho);
-
- if (comp_mask & IB_PR_COMPMASK_SLID) {
- src_lid_min_ho = cl_ntoh16(p_pr->slid);
- src_lid_max_ho = cl_ntoh16(p_pr->slid);
- } else
- osm_port_get_lid_range_ho(p_src_port, &src_lid_min_ho,
- &src_lid_max_ho);
-
- if (src_lid_min_ho == 0) {
- OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 1F20:"
- "Obtained source LID of 0. No such LID possible\n");
- goto Exit;
- }
-
- if (dest_lid_min_ho == 0) {
- OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 1F21:"
- "Obtained destination LID of 0. No such LID possible\n");
- goto Exit;
- }
-
- OSM_LOG(sa->p_log, OSM_LOG_DEBUG,
- "Src LIDs [%u-%u], Dest LIDs [%u-%u]\n",
- src_lid_min_ho, src_lid_max_ho,
- dest_lid_min_ho, dest_lid_max_ho);
-
- src_lid_ho = src_lid_min_ho;
- dest_lid_ho = dest_lid_min_ho;
-
- /*
- Preferred paths come first in OpenSM
- */
- preference = 0;
- path_num = 0;
-
- /* If SubnAdmGet, assume NumbPaths 1 (1.2 erratum) */
- if (p_sa_mad->method != IB_MAD_METHOD_GET)
- if (comp_mask & IB_PR_COMPMASK_NUMBPATH)
- iterations = ib_path_rec_num_path(p_pr);
- else
- iterations = (uintn_t) (-1);
- else
- iterations = 1;
-
- while (path_num < iterations) {
- /*
- These paths are "fully redundant"
- */
-
- p_pr_item = __osm_pr_rcv_get_lid_pair_path(sa, p_pr,
- p_src_port,
- p_dest_port, p_dgid,
- src_lid_ho,
- dest_lid_ho,
- comp_mask,
- preference);
-
- if (p_pr_item) {
- cl_qlist_insert_tail(p_list, &p_pr_item->list_item);
- ++path_num;
- }
-
- if (++src_lid_ho > src_lid_max_ho)
- break;
-
- if (++dest_lid_ho > dest_lid_max_ho)
- break;
- }
-
- /*
- Check if we've accumulated all the paths that the user cares to see
- */
- if (path_num == iterations)
- goto Exit;
-
- /*
- Don't bother reporting preference 1 paths for now.
- It's more trouble than it's worth and can only occur
- if ports have different LMC values, which isn't supported
- by OpenSM right now anyway.
- */
- preference = 2;
- src_lid_ho = src_lid_min_ho;
- dest_lid_ho = dest_lid_min_ho;
- src_offset = 0;
- dest_offset = 0;
-
- /*
- Iterate over the remaining paths
- */
- while (path_num < iterations) {
- dest_offset++;
- dest_lid_ho++;
-
- if (dest_lid_ho > dest_lid_max_ho) {
- src_offset++;
- src_lid_ho++;
-
- if (src_lid_ho > src_lid_max_ho)
- break; /* done */
-
- dest_offset = 0;
- dest_lid_ho = dest_lid_min_ho;
- }
-
- /*
- These paths are "fully non-redundant" with paths already
- identified above and consequently not of much value.
-
- Don't return paths we already identified above, as indicated
- by the offset values being equal.
- */
- if (src_offset == dest_offset)
- continue; /* already reported */
-
- p_pr_item = __osm_pr_rcv_get_lid_pair_path(sa, p_pr,
- p_src_port,
- p_dest_port, p_dgid,
- src_lid_ho,
- dest_lid_ho,
- comp_mask,
- preference);
-
- if (p_pr_item) {
- cl_qlist_insert_tail(p_list, &p_pr_item->list_item);
- ++path_num;
- }
- }
-
-Exit:
- OSM_LOG_EXIT(sa->p_log);
-}
-
-/**********************************************************************
- **********************************************************************/
-static ib_net16_t
-__osm_pr_rcv_get_end_points(IN osm_sa_t * sa,
- IN const osm_madw_t * const p_madw,
- OUT const osm_port_t ** const pp_src_port,
- OUT const osm_port_t ** const pp_dest_port,
- OUT ib_gid_t * const p_dgid)
-{
- const ib_path_rec_t *p_pr;
- const ib_sa_mad_t *p_sa_mad;
- ib_net64_t comp_mask;
- ib_net64_t dest_guid;
- ib_api_status_t status;
- ib_net16_t sa_status = IB_SA_MAD_STATUS_SUCCESS;
- osm_router_t *p_rtr;
- osm_port_t *p_rtr_port;
-
- OSM_LOG_ENTER(sa->p_log);
-
- /*
- Determine what fields are valid and then get a pointer
- to the source and destination port objects, if possible.
- */
-
- p_sa_mad = osm_madw_get_sa_mad_ptr(p_madw);
- p_pr = (ib_path_rec_t *) ib_sa_mad_get_payload_ptr(p_sa_mad);
-
- comp_mask = p_sa_mad->comp_mask;
-
- /*
- Check a few easy disqualifying cases up front before getting
- into the endpoints.
- */
-
- if (comp_mask & IB_PR_COMPMASK_SGID) {
- if (!ib_gid_is_link_local(&p_pr->sgid)) {
- if (ib_gid_get_subnet_prefix(&p_pr->sgid) !=
- sa->p_subn->opt.subnet_prefix) {
- /*
- This 'error' is the client's fault (bad gid)
- so don't enter it as an error in our own log.
- Return an error response to the client.
- */
- OSM_LOG(sa->p_log, OSM_LOG_VERBOSE,
- "Non local SGID subnet prefix 0x%016"
- PRIx64 "\n",
- cl_ntoh64(p_pr->sgid.unicast.prefix));
-
- sa_status = IB_SA_MAD_STATUS_INVALID_GID;
- goto Exit;
- }
- }
-
- *pp_src_port = osm_get_port_by_guid(sa->p_subn,
- p_pr->sgid.unicast.
- interface_id);
- if (!*pp_src_port) {
- /*
- This 'error' is the client's fault (bad gid) so
- don't enter it as an error in our own log.
- Return an error response to the client.
- */
- OSM_LOG(sa->p_log, OSM_LOG_VERBOSE,
- "No source port with GUID 0x%016" PRIx64 "\n",
- cl_ntoh64(p_pr->sgid.unicast.interface_id));
-
- sa_status = IB_SA_MAD_STATUS_INVALID_GID;
- goto Exit;
- }
- } else {
- *pp_src_port = 0;
- if (comp_mask & IB_PR_COMPMASK_SLID) {
- status = cl_ptr_vector_at(&sa->p_subn->port_lid_tbl,
- cl_ntoh16(p_pr->slid),
- (void **)pp_src_port);
-
- if ((status != CL_SUCCESS) || (*pp_src_port == NULL)) {
- /*
- This 'error' is the client's fault (bad lid) so
- don't enter it as an error in our own log.
- Return an error response to the client.
- */
- OSM_LOG(sa->p_log, OSM_LOG_VERBOSE,
- "No source port with LID %u\n",
- cl_ntoh16(p_pr->slid));
-
- sa_status = IB_SA_MAD_STATUS_NO_RECORDS;
- goto Exit;
- }
- }
- }
-
- if (p_dgid)
- memset(p_dgid, 0, sizeof(*p_dgid));
-
- if (comp_mask & IB_PR_COMPMASK_DGID) {
- dest_guid = p_pr->dgid.unicast.interface_id;
- if (!ib_gid_is_link_local(&p_pr->dgid)) {
- if (!ib_gid_is_multicast(&p_pr->dgid) &&
- ib_gid_get_subnet_prefix(&p_pr->dgid) !=
- sa->p_subn->opt.subnet_prefix) {
- OSM_LOG(sa->p_log, OSM_LOG_VERBOSE,
- "Non local DGID subnet prefix 0x%016"
- PRIx64 "\n",
- cl_ntoh64(p_pr->dgid.unicast.prefix));
-
- /* Find the router port that is configured to
- handle this prefix, if any */
- osm_prefix_route_t *route = NULL;
- osm_prefix_route_t *r = (osm_prefix_route_t *)
- cl_qlist_head(&sa->p_subn->prefix_routes_list);
-
- while (r != (osm_prefix_route_t *)
- cl_qlist_end(&sa->p_subn->prefix_routes_list))
- {
- if (r->prefix == p_pr->dgid.unicast.prefix ||
- r->prefix == 0)
- {
- route = r;
- break;
- }
- r = (osm_prefix_route_t *) cl_qlist_next(&r->list_item);
- }
-
- if (!route) {
- /*
- This 'error' is the client's fault (bad gid) so
- don't enter it as an error in our own log.
- Return an error response to the client.
- */
- sa_status = IB_SA_MAD_STATUS_INVALID_GID;
- goto Exit;
- } else if (route->guid == 0) {
- /* first router */
- p_rtr = (osm_router_t *)
- cl_qmap_head(&sa->
- p_subn->
- rtr_guid_tbl);
- } else {
- p_rtr = (osm_router_t *)
- cl_qmap_get(&sa->
- p_subn->
- rtr_guid_tbl,
- route->guid);
- }
-
- if (p_rtr ==
- (osm_router_t *) cl_qmap_end(&sa->
- p_subn->
- rtr_guid_tbl))
- {
- OSM_LOG(sa->p_log, OSM_LOG_ERROR,
- "ERR 1F22: "
- "Off subnet DGID but router not found\n");
- sa_status =
- IB_SA_MAD_STATUS_INVALID_GID;
- goto Exit;
- }
-
- p_rtr_port = osm_router_get_port_ptr(p_rtr);
- dest_guid = osm_port_get_guid(p_rtr_port);
- if (p_dgid)
- *p_dgid = p_pr->dgid;
- }
- }
-
- *pp_dest_port = osm_get_port_by_guid(sa->p_subn, dest_guid);
- if (!*pp_dest_port) {
- /*
- This 'error' is the client's fault (bad gid) so
- don't enter it as an error in our own log.
- Return an error response to the client.
- */
- OSM_LOG(sa->p_log, OSM_LOG_VERBOSE,
- "No dest port with GUID 0x%016" PRIx64 "\n",
- cl_ntoh64(dest_guid));
-
- sa_status = IB_SA_MAD_STATUS_INVALID_GID;
- goto Exit;
- }
- } else {
- *pp_dest_port = 0;
- if (comp_mask & IB_PR_COMPMASK_DLID) {
- status = cl_ptr_vector_at(&sa->p_subn->port_lid_tbl,
- cl_ntoh16(p_pr->dlid),
- (void **)pp_dest_port);
-
- if ((status != CL_SUCCESS) || (*pp_dest_port == NULL)) {
- /*
- This 'error' is the client's fault (bad lid)
- so don't enter it as an error in our own log.
- Return an error response to the client.
- */
- OSM_LOG(sa->p_log, OSM_LOG_VERBOSE,
- "No dest port with LID %u\n",
- cl_ntoh16(p_pr->dlid));
-
- sa_status = IB_SA_MAD_STATUS_NO_RECORDS;
- goto Exit;
- }
- }
- }
-
-Exit:
- OSM_LOG_EXIT(sa->p_log);
- return (sa_status);
-}
-
-/**********************************************************************
- **********************************************************************/
-static void
-__osm_pr_rcv_process_world(IN osm_sa_t * sa,
- IN const osm_madw_t * const p_madw,
- IN const osm_port_t * const requester_port,
- IN const ib_gid_t * const p_dgid,
- IN const ib_net64_t comp_mask,
- IN cl_qlist_t * const p_list)
-{
- const cl_qmap_t *p_tbl;
- const osm_port_t *p_dest_port;
- const osm_port_t *p_src_port;
-
- OSM_LOG_ENTER(sa->p_log);
-
- /*
- Iterate the entire port space over itself.
- A path record from a port to itself is legit, so no
- need for a special case there.
-
- We compute both A -> B and B -> A, since we don't have
- any check to determine the reversability of the paths.
- */
- p_tbl = &sa->p_subn->port_guid_tbl;
-
- p_dest_port = (osm_port_t *) cl_qmap_head(p_tbl);
- while (p_dest_port != (osm_port_t *) cl_qmap_end(p_tbl)) {
- p_src_port = (osm_port_t *) cl_qmap_head(p_tbl);
- while (p_src_port != (osm_port_t *) cl_qmap_end(p_tbl)) {
- __osm_pr_rcv_get_port_pair_paths(sa, p_madw,
- requester_port,
- p_src_port,
- p_dest_port, p_dgid,
- comp_mask, p_list);
-
- p_src_port =
- (osm_port_t *) cl_qmap_next(&p_src_port->map_item);
- }
-
- p_dest_port =
- (osm_port_t *) cl_qmap_next(&p_dest_port->map_item);
- }
-
- OSM_LOG_EXIT(sa->p_log);
-}
-
-/**********************************************************************
- **********************************************************************/
-static void
-__osm_pr_rcv_process_half(IN osm_sa_t * sa,
- IN const osm_madw_t * const p_madw,
- IN const osm_port_t * const requester_port,
- IN const osm_port_t * const p_src_port,
- IN const osm_port_t * const p_dest_port,
- IN const ib_gid_t * const p_dgid,
- IN const ib_net64_t comp_mask,
- IN cl_qlist_t * const p_list)
-{
- const cl_qmap_t *p_tbl;
- const osm_port_t *p_port;
-
- OSM_LOG_ENTER(sa->p_log);
-
- /*
- Iterate over every port, looking for matches...
- A path record from a port to itself is legit, so no
- need to special case that one.
- */
- p_tbl = &sa->p_subn->port_guid_tbl;
-
- if (p_src_port) {
- /*
- The src port if fixed, so iterate over destination ports.
- */
- p_port = (osm_port_t *) cl_qmap_head(p_tbl);
- while (p_port != (osm_port_t *) cl_qmap_end(p_tbl)) {
- __osm_pr_rcv_get_port_pair_paths(sa, p_madw,
- requester_port,
- p_src_port, p_port,
- p_dgid, comp_mask,
- p_list);
- p_port = (osm_port_t *) cl_qmap_next(&p_port->map_item);
- }
- } else {
- /*
- The dest port if fixed, so iterate over source ports.
- */
- p_port = (osm_port_t *) cl_qmap_head(p_tbl);
- while (p_port != (osm_port_t *) cl_qmap_end(p_tbl)) {
- __osm_pr_rcv_get_port_pair_paths(sa, p_madw,
- requester_port, p_port,
- p_dest_port, p_dgid,
- comp_mask, p_list);
- p_port = (osm_port_t *) cl_qmap_next(&p_port->map_item);
- }
- }
-
- OSM_LOG_EXIT(sa->p_log);
-}
-
-/**********************************************************************
- **********************************************************************/
-static void
-__osm_pr_rcv_process_pair(IN osm_sa_t * sa,
- IN const osm_madw_t * const p_madw,
- IN const osm_port_t * const requester_port,
- IN const osm_port_t * const p_src_port,
- IN const osm_port_t * const p_dest_port,
- IN const ib_gid_t * const p_dgid,
- IN const ib_net64_t comp_mask,
- IN cl_qlist_t * const p_list)
-{
- OSM_LOG_ENTER(sa->p_log);
-
- __osm_pr_rcv_get_port_pair_paths(sa, p_madw, requester_port,
- p_src_port, p_dest_port, p_dgid,
- comp_mask, p_list);
-
- OSM_LOG_EXIT(sa->p_log);
-}
-
-/**********************************************************************
- **********************************************************************/
-static osm_mgrp_t *pr_get_mgrp(IN osm_sa_t * sa,
- IN const osm_madw_t * const p_madw)
-{
- ib_path_rec_t *p_pr;
- const ib_sa_mad_t *p_sa_mad;
- ib_net64_t comp_mask;
- osm_mgrp_t *mgrp = NULL;
-
- p_sa_mad = osm_madw_get_sa_mad_ptr(p_madw);
- p_pr = (ib_path_rec_t *) ib_sa_mad_get_payload_ptr(p_sa_mad);
-
- comp_mask = p_sa_mad->comp_mask;
-
- if ((comp_mask & IB_PR_COMPMASK_DGID) &&
- !(mgrp = osm_get_mgrp_by_mgid(sa, &p_pr->dgid))) {
- char gid_str[INET6_ADDRSTRLEN];
- OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 1F09: "
- "No MC group found for PathRecord destination GID %s\n",
- inet_ntop(AF_INET6, p_pr->dgid.raw, gid_str,
- sizeof gid_str));
- goto Exit;
- }
-
- if (comp_mask & IB_PR_COMPMASK_DLID) {
- if (mgrp) {
- /* check that the MLID in the MC group is */
- /* the same as the DLID in the PathRecord */
- if (mgrp->mlid != p_pr->dlid) {
- /* Note: perhaps this might be better indicated as an invalid request */
- OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 1F10: "
- "MC group MLID 0x%x does not match "
- "PathRecord destination LID 0x%x\n",
- mgrp->mlid, p_pr->dlid);
- mgrp = NULL;
- goto Exit;
- }
- } else if (!(mgrp = osm_get_mgrp_by_mlid(sa->p_subn, p_pr->dlid)))
- OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 1F11: "
- "No MC group found for PathRecord "
- "destination LID 0x%x\n", p_pr->dlid);
- }
-
-Exit:
- return mgrp;
-}
-
-/**********************************************************************
- **********************************************************************/
-static ib_api_status_t
-__osm_pr_match_mgrp_attributes(IN osm_sa_t * sa,
- IN const osm_madw_t * const p_madw,
- IN const osm_mgrp_t * const p_mgrp)
-{
- const ib_path_rec_t *p_pr;
- const ib_sa_mad_t *p_sa_mad;
- ib_net64_t comp_mask;
- ib_api_status_t status = IB_ERROR;
- uint32_t flow_label;
- uint8_t sl;
- uint8_t hop_limit;
-
- OSM_LOG_ENTER(sa->p_log);
-
- p_sa_mad = osm_madw_get_sa_mad_ptr(p_madw);
- p_pr = (ib_path_rec_t *) ib_sa_mad_get_payload_ptr(p_sa_mad);
-
- comp_mask = p_sa_mad->comp_mask;
-
- /* If SGID and/or SLID specified, should validate as member of MC group */
- /* Also, MTU, rate, packet lifetime, and raw traffic requested are not currently checked */
- if (comp_mask & IB_PR_COMPMASK_PKEY) {
- if (p_pr->pkey != p_mgrp->mcmember_rec.pkey)
- goto Exit;
- }
-
- ib_member_get_sl_flow_hop(p_mgrp->mcmember_rec.sl_flow_hop,
- &sl, &flow_label, &hop_limit);
-
- if (comp_mask & IB_PR_COMPMASK_SL) {
- if (ib_path_rec_sl(p_pr) != sl)
- goto Exit;
- }
-
- /* If SubnAdmGet, assume NumbPaths of 1 (1.2 erratum) */
- if ((comp_mask & IB_PR_COMPMASK_NUMBPATH) &&
- (p_sa_mad->method != IB_MAD_METHOD_GET)) {
- if (ib_path_rec_num_path(p_pr) == 0)
- goto Exit;
- }
-
- if (comp_mask & IB_PR_COMPMASK_FLOWLABEL) {
- if (ib_path_rec_flow_lbl(p_pr) != flow_label)
- goto Exit;
- }
-
- if (comp_mask & IB_PR_COMPMASK_HOPLIMIT) {
- if (ib_path_rec_hop_limit(p_pr) != hop_limit)
- goto Exit;
- }
-
- if (comp_mask & IB_PR_COMPMASK_TCLASS) {
- if (p_pr->tclass != p_mgrp->mcmember_rec.tclass)
- goto Exit;
- }
-
- status = IB_SUCCESS;
-
-Exit:
- OSM_LOG_EXIT(sa->p_log);
- return (status);
-}
-
-/**********************************************************************
- **********************************************************************/
-static int
-__osm_pr_rcv_check_mcast_dest(IN osm_sa_t * sa,
- IN const osm_madw_t * const p_madw)
-{
- const ib_path_rec_t *p_pr;
- const ib_sa_mad_t *p_sa_mad;
- ib_net64_t comp_mask;
- int is_multicast = 0;
-
- OSM_LOG_ENTER(sa->p_log);
-
- p_sa_mad = osm_madw_get_sa_mad_ptr(p_madw);
- p_pr = (ib_path_rec_t *) ib_sa_mad_get_payload_ptr(p_sa_mad);
-
- comp_mask = p_sa_mad->comp_mask;
-
- if (comp_mask & IB_PR_COMPMASK_DGID) {
- is_multicast = ib_gid_is_multicast(&p_pr->dgid);
- if (!is_multicast)
- goto Exit;
- }
-
- if (comp_mask & IB_PR_COMPMASK_DLID) {
- if (cl_ntoh16(p_pr->dlid) >= IB_LID_MCAST_START_HO &&
- cl_ntoh16(p_pr->dlid) <= IB_LID_MCAST_END_HO)
- is_multicast = 1;
- else if (is_multicast) {
- OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 1F12: "
- "PathRecord request indicates MGID but not MLID\n");
- is_multicast = -1;
- }
- }
-
-Exit:
- OSM_LOG_EXIT(sa->p_log);
- return (is_multicast);
-}
-
-/**********************************************************************
- **********************************************************************/
-void osm_pr_rcv_process(IN void *context, IN void *data)
-{
- osm_sa_t *sa = context;
- osm_madw_t *p_madw = data;
- const ib_path_rec_t *p_pr;
- const ib_sa_mad_t *p_sa_mad;
- const osm_port_t *p_src_port;
- const osm_port_t *p_dest_port;
- cl_qlist_t pr_list;
- ib_gid_t dgid;
- ib_net16_t sa_status;
- osm_port_t *requester_port;
- int ret;
-
- OSM_LOG_ENTER(sa->p_log);
-
- CL_ASSERT(p_madw);
-
- p_sa_mad = osm_madw_get_sa_mad_ptr(p_madw);
- p_pr = (ib_path_rec_t *) ib_sa_mad_get_payload_ptr(p_sa_mad);
-
- CL_ASSERT(p_sa_mad->attr_id == IB_MAD_ATTR_PATH_RECORD);
-
- /* we only support SubnAdmGet and SubnAdmGetTable methods */
- if (p_sa_mad->method != IB_MAD_METHOD_GET &&
- p_sa_mad->method != IB_MAD_METHOD_GETTABLE) {
- OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 1F17: "
- "Unsupported Method (%s)\n",
- ib_get_sa_method_str(p_sa_mad->method));
- osm_sa_send_error(sa, p_madw, IB_MAD_STATUS_UNSUP_METHOD_ATTR);
- goto Exit;
- }
-
- /* update the requester physical port. */
- requester_port = osm_get_port_by_mad_addr(sa->p_log, sa->p_subn,
- osm_madw_get_mad_addr_ptr
- (p_madw));
- if (requester_port == NULL) {
- OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 1F16: "
- "Cannot find requester physical port\n");
- goto Exit;
- }
-
- if (osm_log_is_active(sa->p_log, OSM_LOG_DEBUG))
- osm_dump_path_record(sa->p_log, p_pr, OSM_LOG_DEBUG);
-
- cl_qlist_init(&pr_list);
-
- /*
- Most SA functions (including this one) are read-only on the
- subnet object, so we grab the lock non-exclusively.
- */
- cl_plock_acquire(sa->p_lock);
-
- /* Handle multicast destinations separately */
- if ((ret = __osm_pr_rcv_check_mcast_dest(sa, p_madw)) < 0) {
- /* Multicast DGID with unicast DLID */
- cl_plock_release(sa->p_lock);
- osm_sa_send_error(sa, p_madw, IB_MAD_STATUS_INVALID_FIELD);
- goto Exit;
- }
-
- if (ret > 0)
- goto McastDest;
-
- OSM_LOG(sa->p_log, OSM_LOG_DEBUG, "Unicast destination requested\n");
-
- sa_status = __osm_pr_rcv_get_end_points(sa, p_madw,
- &p_src_port, &p_dest_port,
- &dgid);
-
- if (sa_status == IB_SA_MAD_STATUS_SUCCESS) {
- /*
- What happens next depends on the type of endpoint information
- that was specified....
- */
- if (p_src_port) {
- if (p_dest_port)
- __osm_pr_rcv_process_pair(sa, p_madw,
- requester_port,
- p_src_port,
- p_dest_port, &dgid,
- p_sa_mad->comp_mask,
- &pr_list);
- else
- __osm_pr_rcv_process_half(sa, p_madw,
- requester_port,
- p_src_port, NULL,
- &dgid,
- p_sa_mad->comp_mask,
- &pr_list);
- } else {
- if (p_dest_port)
- __osm_pr_rcv_process_half(sa, p_madw,
- requester_port, NULL,
- p_dest_port, &dgid,
- p_sa_mad->comp_mask,
- &pr_list);
- else
- /*
- Katie, bar the door!
- */
- __osm_pr_rcv_process_world(sa, p_madw,
- requester_port,
- &dgid,
- p_sa_mad->comp_mask,
- &pr_list);
- }
- }
- goto Unlock;
-
-McastDest:
- OSM_LOG(sa->p_log, OSM_LOG_DEBUG, "Multicast destination requested\n");
- {
- osm_mgrp_t *p_mgrp = NULL;
- ib_api_status_t status;
- osm_pr_item_t *p_pr_item;
- uint32_t flow_label;
- uint8_t sl;
- uint8_t hop_limit;
-
- /* First, get the MC info */
- p_mgrp = pr_get_mgrp(sa, p_madw);
-
- if (!p_mgrp)
- goto Unlock;
-
- /* Make sure the rest of the PathRecord matches the MC group attributes */
- status = __osm_pr_match_mgrp_attributes(sa, p_madw, p_mgrp);
- if (status != IB_SUCCESS) {
- OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 1F19: "
- "MC group attributes don't match PathRecord request\n");
- goto Unlock;
- }
-
- p_pr_item = malloc(sizeof(*p_pr_item));
- if (p_pr_item == NULL) {
- OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 1F18: "
- "Unable to allocate path record for MC group\n");
- goto Unlock;
- }
- memset(p_pr_item, 0, sizeof(*p_pr_item));
-
- /* Copy PathRecord request into response */
- p_sa_mad = osm_madw_get_sa_mad_ptr(p_madw);
- p_pr = (ib_path_rec_t *)
- ib_sa_mad_get_payload_ptr(p_sa_mad);
- p_pr_item->path_rec = *p_pr;
-
- /* Now, use the MC info to cruft up the PathRecord response */
- p_pr_item->path_rec.dgid = p_mgrp->mcmember_rec.mgid;
- p_pr_item->path_rec.dlid = p_mgrp->mcmember_rec.mlid;
- p_pr_item->path_rec.tclass = p_mgrp->mcmember_rec.tclass;
- p_pr_item->path_rec.num_path = 1;
- p_pr_item->path_rec.pkey = p_mgrp->mcmember_rec.pkey;
-
- /* MTU, rate, and packet lifetime should be exactly */
- p_pr_item->path_rec.mtu = (2 << 6) | p_mgrp->mcmember_rec.mtu;
- p_pr_item->path_rec.rate = (2 << 6) | p_mgrp->mcmember_rec.rate;
- p_pr_item->path_rec.pkt_life =
- (2 << 6) | p_mgrp->mcmember_rec.pkt_life;
-
- /* SL, Hop Limit, and Flow Label */
- ib_member_get_sl_flow_hop(p_mgrp->mcmember_rec.sl_flow_hop,
- &sl, &flow_label, &hop_limit);
- ib_path_rec_set_sl(&p_pr_item->path_rec, sl);
- ib_path_rec_set_qos_class(&p_pr_item->path_rec, 0);
-
- /* HopLimit is not yet set in non link local MC groups */
- /* If it were, this would not be needed */
- if (ib_mgid_get_scope(&p_mgrp->mcmember_rec.mgid) != IB_MC_SCOPE_LINK_LOCAL)
- hop_limit = IB_HOPLIMIT_MAX;
-
- p_pr_item->path_rec.hop_flow_raw =
- cl_hton32(hop_limit) | (flow_label << 8);
-
- cl_qlist_insert_tail(&pr_list, &p_pr_item->list_item);
- }
-
-Unlock:
- cl_plock_release(sa->p_lock);
-
- /* Now, (finally) respond to the PathRecord request */
- osm_sa_respond(sa, p_madw, sizeof(ib_path_rec_t), &pr_list);
-
-Exit:
- OSM_LOG_EXIT(sa->p_log);
-}
diff --git a/contrib/ofed/management/opensm/opensm/osm_sa_pkey_record.c b/contrib/ofed/management/opensm/opensm/osm_sa_pkey_record.c
deleted file mode 100644
index 70c6047..0000000
--- a/contrib/ofed/management/opensm/opensm/osm_sa_pkey_record.c
+++ /dev/null
@@ -1,341 +0,0 @@
-/*
- * Copyright (c) 2004-2008 Voltaire, Inc. All rights reserved.
- * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved.
- * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- */
-
-#if HAVE_CONFIG_H
-# include <config.h>
-#endif /* HAVE_CONFIG_H */
-
-#include <string.h>
-#include <iba/ib_types.h>
-#include <complib/cl_qmap.h>
-#include <complib/cl_passivelock.h>
-#include <complib/cl_debug.h>
-#include <complib/cl_qlist.h>
-#include <vendor/osm_vendor_api.h>
-#include <opensm/osm_port.h>
-#include <opensm/osm_node.h>
-#include <opensm/osm_helper.h>
-#include <opensm/osm_pkey.h>
-#include <opensm/osm_sa.h>
-
-typedef struct osm_pkey_item {
- cl_list_item_t list_item;
- ib_pkey_table_record_t rec;
-} osm_pkey_item_t;
-
-typedef struct osm_pkey_search_ctxt {
- const ib_pkey_table_record_t *p_rcvd_rec;
- ib_net64_t comp_mask;
- uint16_t block_num;
- cl_qlist_t *p_list;
- osm_sa_t *sa;
- const osm_physp_t *p_req_physp;
-} osm_pkey_search_ctxt_t;
-
-/**********************************************************************
- **********************************************************************/
-static void
-__osm_sa_pkey_create(IN osm_sa_t * sa,
- IN osm_physp_t * const p_physp,
- IN osm_pkey_search_ctxt_t * const p_ctxt,
- IN uint16_t block)
-{
- osm_pkey_item_t *p_rec_item;
- uint16_t lid;
- ib_api_status_t status = IB_SUCCESS;
-
- OSM_LOG_ENTER(sa->p_log);
-
- p_rec_item = malloc(sizeof(*p_rec_item));
- if (p_rec_item == NULL) {
- OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 4602: "
- "rec_item alloc failed\n");
- status = IB_INSUFFICIENT_RESOURCES;
- goto Exit;
- }
-
- if (p_physp->p_node->node_info.node_type != IB_NODE_TYPE_SWITCH)
- lid = p_physp->port_info.base_lid;
- else
- lid = osm_node_get_base_lid(p_physp->p_node, 0);
-
- OSM_LOG(sa->p_log, OSM_LOG_DEBUG,
- "New P_Key table for: port 0x%016" PRIx64
- ", lid %u, port %u Block:%u\n",
- cl_ntoh64(osm_physp_get_port_guid(p_physp)),
- cl_ntoh16(lid), osm_physp_get_port_num(p_physp), block);
-
- memset(p_rec_item, 0, sizeof(*p_rec_item));
-
- p_rec_item->rec.lid = lid;
- p_rec_item->rec.block_num = block;
- p_rec_item->rec.port_num = osm_physp_get_port_num(p_physp);
- p_rec_item->rec.pkey_tbl =
- *(osm_pkey_tbl_block_get(osm_physp_get_pkey_tbl(p_physp), block));
-
- cl_qlist_insert_tail(p_ctxt->p_list, &p_rec_item->list_item);
-
-Exit:
- OSM_LOG_EXIT(sa->p_log);
-}
-
-/**********************************************************************
- **********************************************************************/
-static void
-__osm_sa_pkey_check_physp(IN osm_sa_t * sa,
- IN osm_physp_t * const p_physp,
- osm_pkey_search_ctxt_t * const p_ctxt)
-{
- ib_net64_t comp_mask = p_ctxt->comp_mask;
- uint16_t block, num_blocks;
-
- OSM_LOG_ENTER(sa->p_log);
-
- /* we got here with the phys port - all is left is to get the right block */
- if (comp_mask & IB_PKEY_COMPMASK_BLOCK) {
- __osm_sa_pkey_create(sa, p_physp, p_ctxt, p_ctxt->block_num);
- } else {
- num_blocks =
- osm_pkey_tbl_get_num_blocks(osm_physp_get_pkey_tbl
- (p_physp));
- for (block = 0; block < num_blocks; block++) {
- __osm_sa_pkey_create(sa, p_physp, p_ctxt, block);
- }
- }
-
- OSM_LOG_EXIT(sa->p_log);
-}
-
-/**********************************************************************
- **********************************************************************/
-static void
-__osm_sa_pkey_by_comp_mask(IN osm_sa_t * sa,
- IN const osm_port_t * const p_port,
- osm_pkey_search_ctxt_t * const p_ctxt)
-{
- const ib_pkey_table_record_t *p_rcvd_rec;
- ib_net64_t comp_mask;
- osm_physp_t *p_physp;
- uint8_t port_num;
- uint8_t num_ports;
- const osm_physp_t *p_req_physp;
-
- OSM_LOG_ENTER(sa->p_log);
-
- p_rcvd_rec = p_ctxt->p_rcvd_rec;
- comp_mask = p_ctxt->comp_mask;
- port_num = p_rcvd_rec->port_num;
- p_req_physp = p_ctxt->p_req_physp;
-
- /* if this is a switch port we can search all ports
- otherwise we must be looking on port 0 */
- if (p_port->p_node->node_info.node_type != IB_NODE_TYPE_SWITCH) {
- /* we put it in the comp mask and port num */
- port_num = p_port->p_physp->port_num;
- OSM_LOG(sa->p_log, OSM_LOG_DEBUG,
- "Using Physical Default Port Number: 0x%X (for End Node)\n",
- port_num);
- comp_mask |= IB_PKEY_COMPMASK_PORT;
- }
-
- if (comp_mask & IB_PKEY_COMPMASK_PORT) {
- if (port_num < osm_node_get_num_physp(p_port->p_node)) {
- p_physp =
- osm_node_get_physp_ptr(p_port->p_node, port_num);
- /* Check that the p_physp is valid, and that is shares a pkey
- with the p_req_physp. */
- if (p_physp &&
- (osm_physp_share_pkey
- (sa->p_log, p_req_physp, p_physp)))
- __osm_sa_pkey_check_physp(sa, p_physp,
- p_ctxt);
- } else {
- OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 4603: "
- "Given Physical Port Number: 0x%X is out of range should be < 0x%X\n",
- port_num,
- osm_node_get_num_physp(p_port->p_node));
- goto Exit;
- }
- } else {
- num_ports = osm_node_get_num_physp(p_port->p_node);
- for (port_num = 0; port_num < num_ports; port_num++) {
- p_physp =
- osm_node_get_physp_ptr(p_port->p_node, port_num);
- if (!p_physp)
- continue;
-
- /* if the requester and the p_physp don't share a pkey -
- continue */
- if (!osm_physp_share_pkey
- (sa->p_log, p_req_physp, p_physp))
- continue;
-
- __osm_sa_pkey_check_physp(sa, p_physp, p_ctxt);
- }
- }
-Exit:
- OSM_LOG_EXIT(sa->p_log);
-}
-
-/**********************************************************************
- **********************************************************************/
-static void
-__osm_sa_pkey_by_comp_mask_cb(IN cl_map_item_t * const p_map_item,
- IN void *context)
-{
- const osm_port_t *const p_port = (osm_port_t *) p_map_item;
- osm_pkey_search_ctxt_t *const p_ctxt =
- (osm_pkey_search_ctxt_t *) context;
-
- __osm_sa_pkey_by_comp_mask(p_ctxt->sa, p_port, p_ctxt);
-}
-
-/**********************************************************************
- **********************************************************************/
-void osm_pkey_rec_rcv_process(IN void *ctx, IN void *data)
-{
- osm_sa_t *sa = ctx;
- osm_madw_t *p_madw = data;
- const ib_sa_mad_t *p_rcvd_mad;
- const ib_pkey_table_record_t *p_rcvd_rec;
- const osm_port_t *p_port = NULL;
- const ib_pkey_table_t *p_pkey;
- cl_qlist_t rec_list;
- osm_pkey_search_ctxt_t context;
- ib_api_status_t status = IB_SUCCESS;
- ib_net64_t comp_mask;
- osm_physp_t *p_req_physp;
-
- CL_ASSERT(sa);
-
- OSM_LOG_ENTER(sa->p_log);
-
- CL_ASSERT(p_madw);
-
- p_rcvd_mad = osm_madw_get_sa_mad_ptr(p_madw);
- p_rcvd_rec =
- (ib_pkey_table_record_t *) ib_sa_mad_get_payload_ptr(p_rcvd_mad);
- comp_mask = p_rcvd_mad->comp_mask;
-
- CL_ASSERT(p_rcvd_mad->attr_id == IB_MAD_ATTR_PKEY_TBL_RECORD);
-
- /* we only support SubnAdmGet and SubnAdmGetTable methods */
- if (p_rcvd_mad->method != IB_MAD_METHOD_GET &&
- p_rcvd_mad->method != IB_MAD_METHOD_GETTABLE) {
- OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 4605: "
- "Unsupported Method (%s)\n",
- ib_get_sa_method_str(p_rcvd_mad->method));
- osm_sa_send_error(sa, p_madw, IB_MAD_STATUS_UNSUP_METHOD_ATTR);
- goto Exit;
- }
-
- /*
- p922 - P_KeyTableRecords shall only be provided in response
- to trusted requests.
- Check that the requester is a trusted one.
- */
- if (p_rcvd_mad->sm_key != sa->p_subn->opt.sa_key) {
- /* This is not a trusted requester! */
- OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 4608: "
- "Request from non-trusted requester: "
- "Given SM_Key:0x%016" PRIx64 "\n",
- cl_ntoh64(p_rcvd_mad->sm_key));
- osm_sa_send_error(sa, p_madw, IB_SA_MAD_STATUS_REQ_INVALID);
- goto Exit;
- }
-
- /* update the requester physical port. */
- p_req_physp = osm_get_physp_by_mad_addr(sa->p_log, sa->p_subn,
- osm_madw_get_mad_addr_ptr
- (p_madw));
- if (p_req_physp == NULL) {
- OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 4604: "
- "Cannot find requester physical port\n");
- goto Exit;
- }
-
- p_pkey = (ib_pkey_table_t *) ib_sa_mad_get_payload_ptr(p_rcvd_mad);
-
- cl_qlist_init(&rec_list);
-
- context.p_rcvd_rec = p_rcvd_rec;
- context.p_list = &rec_list;
- context.comp_mask = p_rcvd_mad->comp_mask;
- context.sa = sa;
- context.block_num = p_rcvd_rec->block_num;
- context.p_req_physp = p_req_physp;
-
- OSM_LOG(sa->p_log, OSM_LOG_DEBUG,
- "Got Query Lid:%u(%02X), Block:0x%02X(%02X), Port:0x%02X(%02X)\n",
- cl_ntoh16(p_rcvd_rec->lid),
- (comp_mask & IB_PKEY_COMPMASK_LID) != 0, p_rcvd_rec->port_num,
- (comp_mask & IB_PKEY_COMPMASK_PORT) != 0, p_rcvd_rec->block_num,
- (comp_mask & IB_PKEY_COMPMASK_BLOCK) != 0);
-
- cl_plock_acquire(sa->p_lock);
-
- /*
- If the user specified a LID, it obviously narrows our
- work load, since we don't have to search every port
- */
- if (comp_mask & IB_PKEY_COMPMASK_LID) {
- status = osm_get_port_by_base_lid(sa->p_subn, p_rcvd_rec->lid,
- &p_port);
- if (status != IB_SUCCESS || p_port == NULL) {
- status = IB_NOT_FOUND;
- OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 460B: "
- "No port found with LID %u\n",
- cl_ntoh16(p_rcvd_rec->lid));
- }
- }
-
- if (status == IB_SUCCESS) {
- /* if we got a unique port - no need for a port search */
- if (p_port)
- /* this does the loop on all the port phys ports */
- __osm_sa_pkey_by_comp_mask(sa, p_port, &context);
- else
- cl_qmap_apply_func(&sa->p_subn->port_guid_tbl,
- __osm_sa_pkey_by_comp_mask_cb,
- &context);
- }
-
- cl_plock_release(sa->p_lock);
-
- osm_sa_respond(sa, p_madw, sizeof(ib_pkey_table_record_t), &rec_list);
-
-Exit:
- OSM_LOG_EXIT(sa->p_log);
-}
diff --git a/contrib/ofed/management/opensm/opensm/osm_sa_portinfo_record.c b/contrib/ofed/management/opensm/opensm/osm_sa_portinfo_record.c
deleted file mode 100644
index 753c3db..0000000
--- a/contrib/ofed/management/opensm/opensm/osm_sa_portinfo_record.c
+++ /dev/null
@@ -1,592 +0,0 @@
-/*
- * Copyright (c) 2004-2008 Voltaire, Inc. All rights reserved.
- * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved.
- * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- */
-
-/*
- * Abstract:
- * Implementation of osm_pir_rcv_t.
- * This object represents the PortInfoRecord Receiver object.
- * This object is part of the opensm family of objects.
- */
-
-#if HAVE_CONFIG_H
-# include <config.h>
-#endif /* HAVE_CONFIG_H */
-
-#include <string.h>
-#include <iba/ib_types.h>
-#include <complib/cl_qmap.h>
-#include <complib/cl_passivelock.h>
-#include <complib/cl_debug.h>
-#include <complib/cl_qlist.h>
-#include <vendor/osm_vendor_api.h>
-#include <opensm/osm_port.h>
-#include <opensm/osm_node.h>
-#include <opensm/osm_switch.h>
-#include <opensm/osm_helper.h>
-#include <opensm/osm_pkey.h>
-#include <opensm/osm_sa.h>
-
-typedef struct osm_pir_item {
- cl_list_item_t list_item;
- ib_portinfo_record_t rec;
-} osm_pir_item_t;
-
-typedef struct osm_pir_search_ctxt {
- const ib_portinfo_record_t *p_rcvd_rec;
- ib_net64_t comp_mask;
- cl_qlist_t *p_list;
- osm_sa_t *sa;
- const osm_physp_t *p_req_physp;
- boolean_t is_enhanced_comp_mask;
-} osm_pir_search_ctxt_t;
-
-/**********************************************************************
- **********************************************************************/
-static ib_api_status_t
-__osm_pir_rcv_new_pir(IN osm_sa_t * sa,
- IN const osm_physp_t * const p_physp,
- IN cl_qlist_t * const p_list, IN ib_net16_t const lid)
-{
- osm_pir_item_t *p_rec_item;
- ib_api_status_t status = IB_SUCCESS;
-
- OSM_LOG_ENTER(sa->p_log);
-
- p_rec_item = malloc(sizeof(*p_rec_item));
- if (p_rec_item == NULL) {
- OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 2102: "
- "rec_item alloc failed\n");
- status = IB_INSUFFICIENT_RESOURCES;
- goto Exit;
- }
-
- OSM_LOG(sa->p_log, OSM_LOG_DEBUG,
- "New PortInfoRecord: port 0x%016" PRIx64
- ", lid %u, port %u\n",
- cl_ntoh64(osm_physp_get_port_guid(p_physp)),
- cl_ntoh16(lid), osm_physp_get_port_num(p_physp));
-
- memset(p_rec_item, 0, sizeof(*p_rec_item));
-
- p_rec_item->rec.lid = lid;
- p_rec_item->rec.port_info = p_physp->port_info;
- p_rec_item->rec.port_num = osm_physp_get_port_num(p_physp);
-
- cl_qlist_insert_tail(p_list, &p_rec_item->list_item);
-
-Exit:
- OSM_LOG_EXIT(sa->p_log);
- return (status);
-}
-
-/**********************************************************************
- **********************************************************************/
-static void
-__osm_sa_pir_create(IN osm_sa_t * sa,
- IN const osm_physp_t * const p_physp,
- IN osm_pir_search_ctxt_t * const p_ctxt)
-{
- uint8_t lmc;
- uint16_t max_lid_ho;
- uint16_t base_lid_ho;
- uint16_t match_lid_ho;
- osm_physp_t *p_node_physp;
-
- OSM_LOG_ENTER(sa->p_log);
-
- if (p_physp->p_node->sw) {
- p_node_physp = osm_node_get_physp_ptr(p_physp->p_node, 0);
- base_lid_ho = cl_ntoh16(osm_physp_get_base_lid(p_node_physp));
- lmc =
- osm_switch_sp0_is_lmc_capable(p_physp->p_node->sw,
- sa->
- p_subn) ?
- osm_physp_get_lmc(p_node_physp) : 0;
- } else {
- lmc = osm_physp_get_lmc(p_physp);
- base_lid_ho = cl_ntoh16(osm_physp_get_base_lid(p_physp));
- }
- max_lid_ho = (uint16_t) (base_lid_ho + (1 << lmc) - 1);
-
- if (p_ctxt->comp_mask & IB_PIR_COMPMASK_LID) {
- match_lid_ho = cl_ntoh16(p_ctxt->p_rcvd_rec->lid);
-
- /*
- We validate that the lid belongs to this node.
- */
- OSM_LOG(sa->p_log, OSM_LOG_DEBUG,
- "Comparing LID: %u <= %u <= %u\n",
- base_lid_ho, match_lid_ho, max_lid_ho);
-
- if (match_lid_ho < base_lid_ho || match_lid_ho > max_lid_ho)
- goto Exit;
- }
-
- __osm_pir_rcv_new_pir(sa, p_physp, p_ctxt->p_list,
- cl_hton16(base_lid_ho));
-
-Exit:
- OSM_LOG_EXIT(sa->p_log);
-}
-
-/**********************************************************************
- **********************************************************************/
-static void
-__osm_sa_pir_check_physp(IN osm_sa_t * sa,
- IN const osm_physp_t * const p_physp,
- osm_pir_search_ctxt_t * const p_ctxt)
-{
- const ib_portinfo_record_t *p_rcvd_rec;
- ib_net64_t comp_mask;
- const ib_port_info_t *p_comp_pi;
- const ib_port_info_t *p_pi;
-
- OSM_LOG_ENTER(sa->p_log);
-
- p_rcvd_rec = p_ctxt->p_rcvd_rec;
- comp_mask = p_ctxt->comp_mask;
- p_comp_pi = &p_rcvd_rec->port_info;
- p_pi = &p_physp->port_info;
-
- osm_dump_port_info(sa->p_log,
- osm_node_get_node_guid(p_physp->p_node),
- p_physp->port_guid,
- p_physp->port_num,
- &p_physp->port_info, OSM_LOG_DEBUG);
-
- /* We have to re-check the base_lid, since if the given
- base_lid in p_pi is zero - we are comparing on all ports. */
- if (comp_mask & IB_PIR_COMPMASK_BASELID) {
- if (p_comp_pi->base_lid != p_pi->base_lid)
- goto Exit;
- }
- if (comp_mask & IB_PIR_COMPMASK_MKEY) {
- if (p_comp_pi->m_key != p_pi->m_key)
- goto Exit;
- }
- if (comp_mask & IB_PIR_COMPMASK_GIDPRE) {
- if (p_comp_pi->subnet_prefix != p_pi->subnet_prefix)
- goto Exit;
- }
- if (comp_mask & IB_PIR_COMPMASK_SMLID) {
- if (p_comp_pi->master_sm_base_lid != p_pi->master_sm_base_lid)
- goto Exit;
- }
-
- /* IBTA 1.2 errata provides support for bitwise compare if the bit 31
- of the attribute modifier of the Get/GetTable is set */
- if (comp_mask & IB_PIR_COMPMASK_CAPMASK) {
- if (p_ctxt->is_enhanced_comp_mask) {
- if (((p_comp_pi->capability_mask & p_pi->
- capability_mask) != p_comp_pi->capability_mask))
- goto Exit;
- } else {
- if (p_comp_pi->capability_mask != p_pi->capability_mask)
- goto Exit;
- }
- }
-
- if (comp_mask & IB_PIR_COMPMASK_DIAGCODE) {
- if (p_comp_pi->diag_code != p_pi->diag_code)
- goto Exit;
- }
- if (comp_mask & IB_PIR_COMPMASK_MKEYLEASEPRD) {
- if (p_comp_pi->m_key_lease_period != p_pi->m_key_lease_period)
- goto Exit;
- }
- if (comp_mask & IB_PIR_COMPMASK_LOCALPORTNUM) {
- if (p_comp_pi->local_port_num != p_pi->local_port_num)
- goto Exit;
- }
- if (comp_mask & IB_PIR_COMPMASK_LNKWIDTHSUPPORT) {
- if (p_comp_pi->link_width_supported !=
- p_pi->link_width_supported)
- goto Exit;
- }
- if (comp_mask & IB_PIR_COMPMASK_LNKWIDTHACTIVE) {
- if (p_comp_pi->link_width_active != p_pi->link_width_active)
- goto Exit;
- }
- if (comp_mask & IB_PIR_COMPMASK_LINKWIDTHENABLED) {
- if (p_comp_pi->link_width_enabled != p_pi->link_width_enabled)
- goto Exit;
- }
- if (comp_mask & IB_PIR_COMPMASK_LNKSPEEDSUPPORT) {
- if (ib_port_info_get_link_speed_sup(p_comp_pi) !=
- ib_port_info_get_link_speed_sup(p_pi))
- goto Exit;
- }
- if (comp_mask & IB_PIR_COMPMASK_PORTSTATE) {
- if (ib_port_info_get_port_state(p_comp_pi) !=
- ib_port_info_get_port_state(p_pi))
- goto Exit;
- }
- if (comp_mask & IB_PIR_COMPMASK_PORTPHYSTATE) {
- if (ib_port_info_get_port_phys_state(p_comp_pi) !=
- ib_port_info_get_port_phys_state(p_pi))
- goto Exit;
- }
- if (comp_mask & IB_PIR_COMPMASK_LINKDWNDFLTSTATE) {
- if (ib_port_info_get_link_down_def_state(p_comp_pi) !=
- ib_port_info_get_link_down_def_state(p_pi))
- goto Exit;
- }
- if (comp_mask & IB_PIR_COMPMASK_MKEYPROTBITS) {
- if (ib_port_info_get_mpb(p_comp_pi) !=
- ib_port_info_get_mpb(p_pi))
- goto Exit;
- }
- if (comp_mask & IB_PIR_COMPMASK_LMC) {
- if (ib_port_info_get_lmc(p_comp_pi) !=
- ib_port_info_get_lmc(p_pi))
- goto Exit;
- }
- if (comp_mask & IB_PIR_COMPMASK_LINKSPEEDACTIVE) {
- if (ib_port_info_get_link_speed_active(p_comp_pi) !=
- ib_port_info_get_link_speed_active(p_pi))
- goto Exit;
- }
- if (comp_mask & IB_PIR_COMPMASK_LINKSPEEDENABLE) {
- if (ib_port_info_get_link_speed_enabled(p_comp_pi) !=
- ib_port_info_get_link_speed_enabled(p_pi))
- goto Exit;
- }
- if (comp_mask & IB_PIR_COMPMASK_NEIGHBORMTU) {
- if (ib_port_info_get_neighbor_mtu(p_comp_pi) !=
- ib_port_info_get_neighbor_mtu(p_pi))
- goto Exit;
- }
- if (comp_mask & IB_PIR_COMPMASK_MASTERSMSL) {
- if (ib_port_info_get_master_smsl(p_comp_pi) !=
- ib_port_info_get_master_smsl(p_pi))
- goto Exit;
- }
- if (comp_mask & IB_PIR_COMPMASK_VLCAP) {
- if (ib_port_info_get_vl_cap(p_comp_pi) !=
- ib_port_info_get_vl_cap(p_pi))
- goto Exit;
- }
- if (comp_mask & IB_PIR_COMPMASK_INITTYPE) {
- if (ib_port_info_get_init_type(p_comp_pi) !=
- ib_port_info_get_init_type(p_pi))
- goto Exit;
- }
- if (comp_mask & IB_PIR_COMPMASK_VLHIGHLIMIT) {
- if (p_comp_pi->vl_high_limit != p_pi->vl_high_limit)
- goto Exit;
- }
- if (comp_mask & IB_PIR_COMPMASK_VLARBHIGHCAP) {
- if (p_comp_pi->vl_arb_high_cap != p_pi->vl_arb_high_cap)
- goto Exit;
- }
- if (comp_mask & IB_PIR_COMPMASK_VLARBLOWCAP) {
- if (p_comp_pi->vl_arb_low_cap != p_pi->vl_arb_low_cap)
- goto Exit;
- }
- if (comp_mask & IB_PIR_COMPMASK_MTUCAP) {
- if (ib_port_info_get_mtu_cap(p_comp_pi) !=
- ib_port_info_get_mtu_cap(p_pi))
- goto Exit;
- }
- if (comp_mask & IB_PIR_COMPMASK_VLSTALLCNT) {
- if (ib_port_info_get_vl_stall_count(p_comp_pi) !=
- ib_port_info_get_vl_stall_count(p_pi))
- goto Exit;
- }
- if (comp_mask & IB_PIR_COMPMASK_HOQLIFE) {
- if ((p_comp_pi->vl_stall_life & 0x1F) !=
- (p_pi->vl_stall_life & 0x1F))
- goto Exit;
- }
- if (comp_mask & IB_PIR_COMPMASK_OPVLS) {
- if ((p_comp_pi->vl_enforce & 0xF0) != (p_pi->vl_enforce & 0xF0))
- goto Exit;
- }
- if (comp_mask & IB_PIR_COMPMASK_PARENFIN) {
- if ((p_comp_pi->vl_enforce & 0x08) != (p_pi->vl_enforce & 0x08))
- goto Exit;
- }
- if (comp_mask & IB_PIR_COMPMASK_PARENFOUT) {
- if ((p_comp_pi->vl_enforce & 0x04) != (p_pi->vl_enforce & 0x04))
- goto Exit;
- }
- if (comp_mask & IB_PIR_COMPMASK_FILTERRAWIN) {
- if ((p_comp_pi->vl_enforce & 0x02) != (p_pi->vl_enforce & 0x02))
- goto Exit;
- }
- if (comp_mask & IB_PIR_COMPMASK_FILTERRAWOUT) {
- if ((p_comp_pi->vl_enforce & 0x01) != (p_pi->vl_enforce & 0x01))
- goto Exit;
- }
- if (comp_mask & IB_PIR_COMPMASK_MKEYVIO) {
- if (p_comp_pi->m_key_violations != p_pi->m_key_violations)
- goto Exit;
- }
- if (comp_mask & IB_PIR_COMPMASK_PKEYVIO) {
- if (p_comp_pi->p_key_violations != p_pi->p_key_violations)
- goto Exit;
- }
- if (comp_mask & IB_PIR_COMPMASK_QKEYVIO) {
- if (p_comp_pi->q_key_violations != p_pi->q_key_violations)
- goto Exit;
- }
- if (comp_mask & IB_PIR_COMPMASK_GUIDCAP) {
- if (p_comp_pi->guid_cap != p_pi->guid_cap)
- goto Exit;
- }
- if (comp_mask & IB_PIR_COMPMASK_SUBNTO) {
- if (ib_port_info_get_timeout(p_comp_pi) !=
- ib_port_info_get_timeout(p_pi))
- goto Exit;
- }
- if (comp_mask & IB_PIR_COMPMASK_RESPTIME) {
- if ((p_comp_pi->resp_time_value & 0x1F) !=
- (p_pi->resp_time_value & 0x1F))
- goto Exit;
- }
- if (comp_mask & IB_PIR_COMPMASK_LOCALPHYERR) {
- if (ib_port_info_get_local_phy_err_thd(p_comp_pi) !=
- ib_port_info_get_local_phy_err_thd(p_pi))
- goto Exit;
- }
- if (comp_mask & IB_PIR_COMPMASK_OVERRUNERR) {
- if (ib_port_info_get_overrun_err_thd(p_comp_pi) !=
- ib_port_info_get_overrun_err_thd(p_pi))
- goto Exit;
- }
-
- __osm_sa_pir_create(sa, p_physp, p_ctxt);
-
-Exit:
- OSM_LOG_EXIT(sa->p_log);
-}
-
-/**********************************************************************
- **********************************************************************/
-static void
-__osm_sa_pir_by_comp_mask(IN osm_sa_t * sa,
- IN osm_node_t * const p_node,
- osm_pir_search_ctxt_t * const p_ctxt)
-{
- const ib_portinfo_record_t *p_rcvd_rec;
- ib_net64_t comp_mask;
- const osm_physp_t *p_physp;
- uint8_t port_num;
- uint8_t num_ports;
- const osm_physp_t *p_req_physp;
-
- OSM_LOG_ENTER(sa->p_log);
-
- p_rcvd_rec = p_ctxt->p_rcvd_rec;
- comp_mask = p_ctxt->comp_mask;
- p_req_physp = p_ctxt->p_req_physp;
-
- num_ports = osm_node_get_num_physp(p_node);
-
- if (comp_mask & IB_PIR_COMPMASK_PORTNUM) {
- if (p_rcvd_rec->port_num < num_ports) {
- p_physp =
- osm_node_get_physp_ptr(p_node,
- p_rcvd_rec->port_num);
- /* Check that the p_physp is valid, and that the
- p_physp and the p_req_physp share a pkey. */
- if (p_physp &&
- osm_physp_share_pkey(sa->p_log, p_req_physp,
- p_physp))
- __osm_sa_pir_check_physp(sa, p_physp,
- p_ctxt);
- }
- } else {
- for (port_num = 0; port_num < num_ports; port_num++) {
- p_physp =
- osm_node_get_physp_ptr(p_node, port_num);
- if (!p_physp)
- continue;
-
- /* if the requester and the p_physp don't share a pkey -
- continue */
- if (!osm_physp_share_pkey
- (sa->p_log, p_req_physp, p_physp))
- continue;
-
- __osm_sa_pir_check_physp(sa, p_physp, p_ctxt);
- }
- }
-
- OSM_LOG_EXIT(sa->p_log);
-}
-
-/**********************************************************************
- **********************************************************************/
-static void
-__osm_sa_pir_by_comp_mask_cb(IN cl_map_item_t * const p_map_item,
- IN void *context)
-{
- osm_node_t *const p_node = (osm_node_t *) p_map_item;
- osm_pir_search_ctxt_t *const p_ctxt = (osm_pir_search_ctxt_t *) context;
-
- __osm_sa_pir_by_comp_mask(p_ctxt->sa, p_node, p_ctxt);
-}
-
-/**********************************************************************
- **********************************************************************/
-void osm_pir_rcv_process(IN void *ctx, IN void *data)
-{
- osm_sa_t *sa = ctx;
- osm_madw_t *p_madw = data;
- const ib_sa_mad_t *p_rcvd_mad;
- const ib_portinfo_record_t *p_rcvd_rec;
- const cl_ptr_vector_t *p_tbl;
- const osm_port_t *p_port = NULL;
- const ib_port_info_t *p_pi;
- cl_qlist_t rec_list;
- osm_pir_search_ctxt_t context;
- ib_api_status_t status = IB_SUCCESS;
- ib_net64_t comp_mask;
- osm_physp_t *p_req_physp;
-
- CL_ASSERT(sa);
-
- OSM_LOG_ENTER(sa->p_log);
-
- CL_ASSERT(p_madw);
-
- p_rcvd_mad = osm_madw_get_sa_mad_ptr(p_madw);
- p_rcvd_rec =
- (ib_portinfo_record_t *) ib_sa_mad_get_payload_ptr(p_rcvd_mad);
- comp_mask = p_rcvd_mad->comp_mask;
-
- CL_ASSERT(p_rcvd_mad->attr_id == IB_MAD_ATTR_PORTINFO_RECORD);
-
- /* we only support SubnAdmGet and SubnAdmGetTable methods */
- if (p_rcvd_mad->method != IB_MAD_METHOD_GET &&
- p_rcvd_mad->method != IB_MAD_METHOD_GETTABLE) {
- OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 2105: "
- "Unsupported Method (%s)\n",
- ib_get_sa_method_str(p_rcvd_mad->method));
- osm_sa_send_error(sa, p_madw, IB_MAD_STATUS_UNSUP_METHOD_ATTR);
- goto Exit;
- }
-
- /* update the requester physical port. */
- p_req_physp = osm_get_physp_by_mad_addr(sa->p_log, sa->p_subn,
- osm_madw_get_mad_addr_ptr
- (p_madw));
- if (p_req_physp == NULL) {
- OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 2104: "
- "Cannot find requester physical port\n");
- goto Exit;
- }
-
- if (osm_log_is_active(sa->p_log, OSM_LOG_DEBUG))
- osm_dump_portinfo_record(sa->p_log, p_rcvd_rec, OSM_LOG_DEBUG);
-
- p_tbl = &sa->p_subn->port_lid_tbl;
- p_pi = &p_rcvd_rec->port_info;
-
- cl_qlist_init(&rec_list);
-
- context.p_rcvd_rec = p_rcvd_rec;
- context.p_list = &rec_list;
- context.comp_mask = p_rcvd_mad->comp_mask;
- context.sa = sa;
- context.p_req_physp = p_req_physp;
- context.is_enhanced_comp_mask =
- cl_ntoh32(p_rcvd_mad->attr_mod) & (1 << 31);
-
- cl_plock_acquire(sa->p_lock);
-
- CL_ASSERT(cl_ptr_vector_get_size(p_tbl) < 0x10000);
-
- /*
- If the user specified a LID, it obviously narrows our
- work load, since we don't have to search every port
- */
- if (comp_mask & IB_PIR_COMPMASK_LID) {
- status =
- osm_get_port_by_base_lid(sa->p_subn, p_rcvd_rec->lid,
- &p_port);
- if ((status != IB_SUCCESS) || (p_port == NULL)) {
- status = IB_NOT_FOUND;
- OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 2109: "
- "No port found with LID %u\n",
- cl_ntoh16(p_rcvd_rec->lid));
- }
- } else if (comp_mask & IB_PIR_COMPMASK_BASELID) {
- if ((uint16_t) cl_ptr_vector_get_size(p_tbl) >
- cl_ntoh16(p_pi->base_lid))
- p_port = cl_ptr_vector_get(p_tbl,
- cl_ntoh16(p_pi->base_lid));
- else {
- status = IB_NOT_FOUND;
- OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 2103: "
- "Given LID (%u) is out of range:%u\n",
- cl_ntoh16(p_pi->base_lid),
- cl_ptr_vector_get_size(p_tbl));
- }
- }
-
- if (status == IB_SUCCESS) {
- if (p_port)
- __osm_sa_pir_by_comp_mask(sa, p_port->p_node,
- &context);
- else
- cl_qmap_apply_func(&sa->p_subn->node_guid_tbl,
- __osm_sa_pir_by_comp_mask_cb,
- &context);
- }
-
- cl_plock_release(sa->p_lock);
-
- /*
- p922 - The M_Key returned shall be zero, except in the case of a
- trusted request.
- Note: In the mad controller we check that the SM_Key received on
- the mad is valid. Meaning - is either zero or equal to the local
- sm_key.
- */
- if (!p_rcvd_mad->sm_key) {
- osm_pir_item_t *item;
- for (item = (osm_pir_item_t *) cl_qlist_head(&rec_list);
- item != (osm_pir_item_t *) cl_qlist_end(&rec_list);
- item = (osm_pir_item_t *)cl_qlist_next(&item->list_item))
- item->rec.port_info.m_key = 0;
- }
-
- osm_sa_respond(sa, p_madw, sizeof(ib_portinfo_record_t), &rec_list);
-
-Exit:
- OSM_LOG_EXIT(sa->p_log);
-}
diff --git a/contrib/ofed/management/opensm/opensm/osm_sa_service_record.c b/contrib/ofed/management/opensm/opensm/osm_sa_service_record.c
deleted file mode 100644
index 66b4cb7..0000000
--- a/contrib/ofed/management/opensm/opensm/osm_sa_service_record.c
+++ /dev/null
@@ -1,842 +0,0 @@
-/*
- * Copyright (c) 2004-2008 Voltaire, Inc. All rights reserved.
- * Copyright (c) 2002-2006 Mellanox Technologies LTD. All rights reserved.
- * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- */
-
-/*
- * Abstract:
- * Implementation of osm_sr_rcv_t.
- * This object represents the ServiceRecord Receiver object.
- * This object is part of the opensm family of objects.
- */
-
-#if HAVE_CONFIG_H
-# include <config.h>
-#endif /* HAVE_CONFIG_H */
-
-#include <string.h>
-#include <iba/ib_types.h>
-#include <complib/cl_qmap.h>
-#include <complib/cl_passivelock.h>
-#include <complib/cl_debug.h>
-#include <complib/cl_qlist.h>
-#include <vendor/osm_vendor_api.h>
-#include <opensm/osm_port.h>
-#include <opensm/osm_node.h>
-#include <opensm/osm_switch.h>
-#include <opensm/osm_helper.h>
-#include <opensm/osm_sa.h>
-#include <opensm/osm_service.h>
-#include <opensm/osm_pkey.h>
-
-typedef struct osm_sr_item {
- cl_list_item_t list_item;
- ib_service_record_t service_rec;
-} osm_sr_item_t;
-
-typedef struct osm_sr_match_item {
- cl_qlist_t sr_list;
- ib_service_record_t *p_service_rec;
- ib_net64_t comp_mask;
- osm_sa_t *sa;
-} osm_sr_match_item_t;
-
-typedef struct osm_sr_search_ctxt {
- osm_sr_match_item_t *p_sr_item;
- const osm_physp_t *p_req_physp;
-} osm_sr_search_ctxt_t;
-
-/**********************************************************************
- **********************************************************************/
-static boolean_t
-__match_service_pkey_with_ports_pkey(IN osm_sa_t * sa,
- IN const osm_madw_t * const p_madw,
- ib_service_record_t * const p_service_rec,
- ib_net64_t const comp_mask)
-{
- boolean_t valid = TRUE;
- osm_physp_t *p_req_physp;
- ib_net64_t service_guid;
- osm_port_t *service_port;
-
- /* update the requester physical port. */
- p_req_physp = osm_get_physp_by_mad_addr(sa->p_log,
- sa->p_subn,
- osm_madw_get_mad_addr_ptr
- (p_madw));
- if (p_req_physp == NULL) {
- OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 2404: "
- "Cannot find requester physical port\n");
- valid = FALSE;
- goto Exit;
- }
-
- if ((comp_mask & IB_SR_COMPMASK_SPKEY) == IB_SR_COMPMASK_SPKEY) {
- /* We have a ServiceP_Key - check matching on requester port, and
- ServiceGid port (if such exists) */
- /* Make sure it matches the p_req_physp */
- if (!osm_physp_has_pkey
- (sa->p_log, p_service_rec->service_pkey, p_req_physp)) {
- valid = FALSE;
- goto Exit;
- }
-
- /* Make sure it matches the port of the ServiceGid */
- if ((comp_mask & IB_SR_COMPMASK_SGID) == IB_SR_COMPMASK_SGID) {
- service_guid =
- p_service_rec->service_gid.unicast.interface_id;
- service_port =
- osm_get_port_by_guid(sa->p_subn, service_guid);
- if (!service_port) {
- OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 2405: "
- "No port object for port 0x%016" PRIx64
- "\n", cl_ntoh64(service_guid));
- valid = FALSE;
- goto Exit;
- }
- /* check on the table of the default physical port of the service port */
- if (!osm_physp_has_pkey(sa->p_log,
- p_service_rec->service_pkey,
- service_port->p_physp)) {
- valid = FALSE;
- goto Exit;
- }
- }
- }
-
-Exit:
- return valid;
-}
-
-/**********************************************************************
- **********************************************************************/
-static boolean_t
-__match_name_to_key_association(IN osm_sa_t * sa,
- ib_service_record_t * p_service_rec,
- ib_net64_t comp_mask)
-{
- UNUSED_PARAM(p_service_rec);
- UNUSED_PARAM(sa);
-
- if ((comp_mask & (IB_SR_COMPMASK_SKEY | IB_SR_COMPMASK_SNAME)) ==
- (IB_SR_COMPMASK_SKEY | IB_SR_COMPMASK_SNAME)) {
- /* For now, we are not maintaining the ServiceAssociation record
- * so just return TRUE
- */
- return TRUE;
- }
-
- return TRUE;
-}
-
-/**********************************************************************
- **********************************************************************/
-static boolean_t
-__validate_sr(IN osm_sa_t * sa, IN const osm_madw_t * const p_madw)
-{
- boolean_t valid = TRUE;
- ib_sa_mad_t *p_sa_mad;
- ib_service_record_t *p_recvd_service_rec;
-
- OSM_LOG_ENTER(sa->p_log);
-
- p_sa_mad = osm_madw_get_sa_mad_ptr(p_madw);
- p_recvd_service_rec =
- (ib_service_record_t *) ib_sa_mad_get_payload_ptr(p_sa_mad);
-
- valid = __match_service_pkey_with_ports_pkey(sa,
- p_madw,
- p_recvd_service_rec,
- p_sa_mad->comp_mask);
-
- if (!valid) {
- OSM_LOG(sa->p_log, OSM_LOG_DEBUG,
- "No Match for Service Pkey\n");
- valid = FALSE;
- goto Exit;
- }
-
- valid = __match_name_to_key_association(sa,
- p_recvd_service_rec,
- p_sa_mad->comp_mask);
-
- if (!valid) {
- OSM_LOG(sa->p_log, OSM_LOG_DEBUG,
- "Service Record Name to key matching failed\n");
- valid = FALSE;
- goto Exit;
- }
-
-Exit:
- OSM_LOG_EXIT(sa->p_log);
- return valid;
-}
-
-/**********************************************************************
- **********************************************************************/
-static void
-__osm_sr_rcv_respond(IN osm_sa_t * sa,
- IN osm_madw_t * const p_madw,
- IN cl_qlist_t * const p_list)
-{
- /* p923 - The ServiceKey shall be set to 0, except in the case of
- a trusted request.
- Note: In the mad controller we check that the SM_Key received on
- the mad is valid. Meaning - is either zero or equal to the local
- sm_key.
- */
- if (!osm_madw_get_sa_mad_ptr(p_madw)->sm_key) {
- osm_sr_item_t *item;
- for (item = (osm_sr_item_t *) cl_qlist_head(p_list);
- item != (osm_sr_item_t *) cl_qlist_end(p_list);
- item = (osm_sr_item_t *)cl_qlist_next(&item->list_item))
- memset(item->service_rec.service_key, 0,
- sizeof(item->service_rec.service_key));
- }
-
- osm_sa_respond(sa, p_madw, sizeof(ib_service_record_t), p_list);
-}
-
-/**********************************************************************
- **********************************************************************/
-static void
-__get_matching_sr(IN cl_list_item_t * const p_list_item, IN void *context)
-{
- osm_sr_search_ctxt_t *const p_ctxt = (osm_sr_search_ctxt_t *) context;
- osm_svcr_t *p_svcr = (osm_svcr_t *) p_list_item;
- osm_sr_item_t *p_sr_pool_item;
- osm_sr_match_item_t *p_sr_item = p_ctxt->p_sr_item;
- ib_net64_t comp_mask = p_sr_item->comp_mask;
- const osm_physp_t *p_req_physp = p_ctxt->p_req_physp;
-
- if ((comp_mask & IB_SR_COMPMASK_SID) == IB_SR_COMPMASK_SID) {
- if (p_sr_item->p_service_rec->service_id !=
- p_svcr->service_record.service_id)
- return;
- }
- if ((comp_mask & IB_SR_COMPMASK_SGID) == IB_SR_COMPMASK_SGID) {
- if (memcmp(&p_sr_item->p_service_rec->service_gid,
- &p_svcr->service_record.service_gid,
- sizeof(p_svcr->service_record.service_gid)) != 0)
- return;
- }
- if ((comp_mask & IB_SR_COMPMASK_SPKEY) == IB_SR_COMPMASK_SPKEY) {
- if (p_sr_item->p_service_rec->service_pkey !=
- p_svcr->service_record.service_pkey)
- return;
- }
-
- if ((comp_mask & IB_SR_COMPMASK_SKEY) == IB_SR_COMPMASK_SKEY) {
- if (memcmp(p_sr_item->p_service_rec->service_key,
- p_svcr->service_record.service_key,
- 16 * sizeof(uint8_t)))
- return;
- }
- if ((comp_mask & IB_SR_COMPMASK_SNAME) == IB_SR_COMPMASK_SNAME) {
- if (memcmp(p_sr_item->p_service_rec->service_name,
- p_svcr->service_record.service_name,
- sizeof(p_svcr->service_record.service_name)) != 0)
- return;
- }
- if ((comp_mask & IB_SR_COMPMASK_SDATA8_0) == IB_SR_COMPMASK_SDATA8_0) {
- if (p_sr_item->p_service_rec->service_data8[0] !=
- p_svcr->service_record.service_data8[0])
- return;
- }
-
- if ((comp_mask & IB_SR_COMPMASK_SDATA8_1) == IB_SR_COMPMASK_SDATA8_1) {
- if (p_sr_item->p_service_rec->service_data8[1] !=
- p_svcr->service_record.service_data8[1])
- return;
- }
- if ((comp_mask & IB_SR_COMPMASK_SDATA8_2) == IB_SR_COMPMASK_SDATA8_2) {
- if (p_sr_item->p_service_rec->service_data8[2] !=
- p_svcr->service_record.service_data8[2])
- return;
- }
- if ((comp_mask & IB_SR_COMPMASK_SDATA8_3) == IB_SR_COMPMASK_SDATA8_3) {
- if (p_sr_item->p_service_rec->service_data8[3] !=
- p_svcr->service_record.service_data8[3])
- return;
- }
- if ((comp_mask & IB_SR_COMPMASK_SDATA8_4) == IB_SR_COMPMASK_SDATA8_4) {
- if (p_sr_item->p_service_rec->service_data8[4] !=
- p_svcr->service_record.service_data8[4])
- return;
- }
- if ((comp_mask & IB_SR_COMPMASK_SDATA8_5) == IB_SR_COMPMASK_SDATA8_5) {
- if (p_sr_item->p_service_rec->service_data8[5] !=
- p_svcr->service_record.service_data8[5])
- return;
- }
- if ((comp_mask & IB_SR_COMPMASK_SDATA8_6) == IB_SR_COMPMASK_SDATA8_6) {
- if (p_sr_item->p_service_rec->service_data8[6] !=
- p_svcr->service_record.service_data8[6])
- return;
- }
-
- if ((comp_mask & IB_SR_COMPMASK_SDATA8_7) == IB_SR_COMPMASK_SDATA8_7) {
- if (p_sr_item->p_service_rec->service_data8[7] !=
- p_svcr->service_record.service_data8[7])
- return;
- }
-
- if ((comp_mask & IB_SR_COMPMASK_SDATA8_8) == IB_SR_COMPMASK_SDATA8_8) {
- if (p_sr_item->p_service_rec->service_data8[8] !=
- p_svcr->service_record.service_data8[8])
- return;
- }
-
- if ((comp_mask & IB_SR_COMPMASK_SDATA8_9) == IB_SR_COMPMASK_SDATA8_9) {
- if (p_sr_item->p_service_rec->service_data8[9] !=
- p_svcr->service_record.service_data8[9])
- return;
- }
-
- if ((comp_mask & IB_SR_COMPMASK_SDATA8_10) == IB_SR_COMPMASK_SDATA8_10) {
- if (p_sr_item->p_service_rec->service_data8[10] !=
- p_svcr->service_record.service_data8[10])
- return;
- }
-
- if ((comp_mask & IB_SR_COMPMASK_SDATA8_11) == IB_SR_COMPMASK_SDATA8_11) {
- if (p_sr_item->p_service_rec->service_data8[11] !=
- p_svcr->service_record.service_data8[11])
- return;
- }
-
- if ((comp_mask & IB_SR_COMPMASK_SDATA8_12) == IB_SR_COMPMASK_SDATA8_12) {
- if (p_sr_item->p_service_rec->service_data8[12] !=
- p_svcr->service_record.service_data8[12])
- return;
- }
- if ((comp_mask & IB_SR_COMPMASK_SDATA8_13) == IB_SR_COMPMASK_SDATA8_13) {
- if (p_sr_item->p_service_rec->service_data8[13] !=
- p_svcr->service_record.service_data8[13])
- return;
- }
- if ((comp_mask & IB_SR_COMPMASK_SDATA8_14) == IB_SR_COMPMASK_SDATA8_14) {
- if (p_sr_item->p_service_rec->service_data8[14] !=
- p_svcr->service_record.service_data8[14])
- return;
- }
- if ((comp_mask & IB_SR_COMPMASK_SDATA8_15) == IB_SR_COMPMASK_SDATA8_15) {
- if (p_sr_item->p_service_rec->service_data8[15] !=
- p_svcr->service_record.service_data8[15])
- return;
- }
- if ((comp_mask & IB_SR_COMPMASK_SDATA16_0) == IB_SR_COMPMASK_SDATA16_0) {
- if (p_sr_item->p_service_rec->service_data16[0] !=
- p_svcr->service_record.service_data16[0])
- return;
- }
- if ((comp_mask & IB_SR_COMPMASK_SDATA16_1) == IB_SR_COMPMASK_SDATA16_1) {
- if (p_sr_item->p_service_rec->service_data16[1] !=
- p_svcr->service_record.service_data16[1])
- return;
- }
- if ((comp_mask & IB_SR_COMPMASK_SDATA16_2) == IB_SR_COMPMASK_SDATA16_2) {
- if (p_sr_item->p_service_rec->service_data16[2] !=
- p_svcr->service_record.service_data16[2])
- return;
- }
- if ((comp_mask & IB_SR_COMPMASK_SDATA16_3) == IB_SR_COMPMASK_SDATA16_3) {
- if (p_sr_item->p_service_rec->service_data16[3] !=
- p_svcr->service_record.service_data16[3])
- return;
- }
- if ((comp_mask & IB_SR_COMPMASK_SDATA16_4) == IB_SR_COMPMASK_SDATA16_4) {
- if (p_sr_item->p_service_rec->service_data16[4] !=
- p_svcr->service_record.service_data16[4])
- return;
- }
- if ((comp_mask & IB_SR_COMPMASK_SDATA16_5) == IB_SR_COMPMASK_SDATA16_5) {
- if (p_sr_item->p_service_rec->service_data16[5] !=
- p_svcr->service_record.service_data16[5])
- return;
- }
- if ((comp_mask & IB_SR_COMPMASK_SDATA16_6) == IB_SR_COMPMASK_SDATA16_6) {
- if (p_sr_item->p_service_rec->service_data16[6] !=
- p_svcr->service_record.service_data16[6])
- return;
- }
- if ((comp_mask & IB_SR_COMPMASK_SDATA16_7) == IB_SR_COMPMASK_SDATA16_7) {
- if (p_sr_item->p_service_rec->service_data16[7] !=
- p_svcr->service_record.service_data16[7])
- return;
- }
- if ((comp_mask & IB_SR_COMPMASK_SDATA32_0) == IB_SR_COMPMASK_SDATA32_0) {
- if (p_sr_item->p_service_rec->service_data32[0] !=
- p_svcr->service_record.service_data32[0])
- return;
- }
- if ((comp_mask & IB_SR_COMPMASK_SDATA32_1) == IB_SR_COMPMASK_SDATA32_1) {
- if (p_sr_item->p_service_rec->service_data32[1] !=
- p_svcr->service_record.service_data32[1])
- return;
- }
- if ((comp_mask & IB_SR_COMPMASK_SDATA32_2) == IB_SR_COMPMASK_SDATA32_2) {
- if (p_sr_item->p_service_rec->service_data32[2] !=
- p_svcr->service_record.service_data32[2])
- return;
- }
- if ((comp_mask & IB_SR_COMPMASK_SDATA32_3) == IB_SR_COMPMASK_SDATA32_3) {
- if (p_sr_item->p_service_rec->service_data32[3] !=
- p_svcr->service_record.service_data32[3])
- return;
- }
-
- if ((comp_mask & IB_SR_COMPMASK_SDATA64_0) == IB_SR_COMPMASK_SDATA64_0) {
- if (p_sr_item->p_service_rec->service_data64[0] !=
- p_svcr->service_record.service_data64[0])
- return;
- }
- if ((comp_mask & IB_SR_COMPMASK_SDATA64_1) == IB_SR_COMPMASK_SDATA64_1) {
- if (p_sr_item->p_service_rec->service_data64[1] !=
- p_svcr->service_record.service_data64[1])
- return;
- }
-
- /* Check that the requester port has the pkey which is the service_pkey.
- If not - then it cannot receive this ServiceRecord. */
- /* The check is relevant only if the service_pkey is valid */
- if (!ib_pkey_is_invalid(p_svcr->service_record.service_pkey)) {
- if (!osm_physp_has_pkey(p_sr_item->sa->p_log,
- p_svcr->service_record.service_pkey,
- p_req_physp)) {
- OSM_LOG(p_sr_item->sa->p_log, OSM_LOG_VERBOSE,
- "requester port doesn't have the service_pkey: 0x%X\n",
- cl_ntoh16(p_svcr->service_record.service_pkey));
- return;
- }
- }
-
- p_sr_pool_item = malloc(sizeof(*p_sr_pool_item));
- if (p_sr_pool_item == NULL) {
- OSM_LOG(p_sr_item->sa->p_log, OSM_LOG_ERROR, "ERR 2408: "
- "Unable to acquire Service Record from pool\n");
- goto Exit;
- }
-
- p_sr_pool_item->service_rec = p_svcr->service_record;
-
- cl_qlist_insert_tail(&p_sr_item->sr_list, &p_sr_pool_item->list_item);
-
-Exit:
- return;
-}
-
-/**********************************************************************
- **********************************************************************/
-static void
-osm_sr_rcv_process_get_method(IN osm_sa_t * sa,
- IN osm_madw_t * const p_madw)
-{
- ib_sa_mad_t *p_sa_mad;
- ib_service_record_t *p_recvd_service_rec;
- osm_sr_match_item_t sr_match_item;
- osm_sr_search_ctxt_t context;
- osm_physp_t *p_req_physp;
-
- OSM_LOG_ENTER(sa->p_log);
-
- CL_ASSERT(p_madw);
-
- /* update the requester physical port. */
- p_req_physp = osm_get_physp_by_mad_addr(sa->p_log,
- sa->p_subn,
- osm_madw_get_mad_addr_ptr
- (p_madw));
- if (p_req_physp == NULL) {
- OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 2409: "
- "Cannot find requester physical port\n");
- goto Exit;
- }
-
- p_sa_mad = osm_madw_get_sa_mad_ptr(p_madw);
- p_recvd_service_rec =
- (ib_service_record_t *) ib_sa_mad_get_payload_ptr(p_sa_mad);
-
- if (osm_log_is_active(sa->p_log, OSM_LOG_DEBUG))
- osm_dump_service_record(sa->p_log, p_recvd_service_rec,
- OSM_LOG_DEBUG);
-
- cl_qlist_init(&sr_match_item.sr_list);
- sr_match_item.p_service_rec = p_recvd_service_rec;
- sr_match_item.comp_mask = p_sa_mad->comp_mask;
- sr_match_item.sa = sa;
-
- context.p_sr_item = &sr_match_item;
- context.p_req_physp = p_req_physp;
-
- /* Grab the lock */
- cl_plock_excl_acquire(sa->p_lock);
-
- cl_qlist_apply_func(&sa->p_subn->sa_sr_list,
- __get_matching_sr, &context);
-
- cl_plock_release(sa->p_lock);
-
- if (p_sa_mad->method == IB_MAD_METHOD_GET &&
- cl_qlist_count(&sr_match_item.sr_list) == 0) {
- OSM_LOG(sa->p_log, OSM_LOG_DEBUG,
- "No records matched the Service Record query\n");
-
- osm_sa_send_error(sa, p_madw, IB_SA_MAD_STATUS_NO_RECORDS);
- goto Exit;
- }
-
- __osm_sr_rcv_respond(sa, p_madw, &sr_match_item.sr_list);
-
-Exit:
- OSM_LOG_EXIT(sa->p_log);
- return;
-}
-
-/**********************************************************************
- **********************************************************************/
-static void
-osm_sr_rcv_process_set_method(IN osm_sa_t * sa,
- IN osm_madw_t * const p_madw)
-{
- ib_sa_mad_t *p_sa_mad;
- ib_service_record_t *p_recvd_service_rec;
- ib_net64_t comp_mask;
- osm_svcr_t *p_svcr;
- osm_sr_item_t *p_sr_item;
- cl_qlist_t sr_list;
-
- OSM_LOG_ENTER(sa->p_log);
-
- CL_ASSERT(p_madw);
-
- p_sa_mad = osm_madw_get_sa_mad_ptr(p_madw);
- p_recvd_service_rec =
- (ib_service_record_t *) ib_sa_mad_get_payload_ptr(p_sa_mad);
-
- comp_mask = p_sa_mad->comp_mask;
-
- if (osm_log_is_active(sa->p_log, OSM_LOG_DEBUG))
- osm_dump_service_record(sa->p_log, p_recvd_service_rec,
- OSM_LOG_DEBUG);
-
- if ((comp_mask & (IB_SR_COMPMASK_SID | IB_SR_COMPMASK_SGID)) !=
- (IB_SR_COMPMASK_SID | IB_SR_COMPMASK_SGID)) {
- OSM_LOG(sa->p_log, OSM_LOG_VERBOSE,
- "Component Mask RID check failed for METHOD_SET\n");
- osm_sa_send_error(sa, p_madw, IB_SA_MAD_STATUS_REQ_INVALID);
- goto Exit;
- }
-
- /* if we were not provided with a service lease make it
- infinite */
- if ((comp_mask & IB_SR_COMPMASK_SLEASE) != IB_SR_COMPMASK_SLEASE) {
- OSM_LOG(sa->p_log, OSM_LOG_DEBUG,
- "ServiceLease Component Mask not set - using infinite lease\n");
- p_recvd_service_rec->service_lease = 0xFFFFFFFF;
- }
-
- /* Grab the lock */
- cl_plock_excl_acquire(sa->p_lock);
-
- /* If Record exists with matching RID */
- p_svcr = osm_svcr_get_by_rid(sa->p_subn,
- sa->p_log, p_recvd_service_rec);
-
- if (p_svcr == NULL) {
- /* Create the instance of the osm_svcr_t object */
- p_svcr = osm_svcr_new(p_recvd_service_rec);
- if (p_svcr == NULL) {
- cl_plock_release(sa->p_lock);
-
- OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 2411: "
- "osm_svcr_get_by_rid failed\n");
-
- osm_sa_send_error(sa, p_madw,
- IB_SA_MAD_STATUS_NO_RESOURCES);
- goto Exit;
- }
-
- /* Add this new osm_svcr_t object to subnet object */
- osm_svcr_insert_to_db(sa->p_subn, sa->p_log, p_svcr);
-
- } else {
- /* Update the old instance of the osm_svcr_t object */
- osm_svcr_init(p_svcr, p_recvd_service_rec);
- }
-
- cl_plock_release(sa->p_lock);
-
- if (p_recvd_service_rec->service_lease != 0xFFFFFFFF) {
-#if 0
- cl_timer_trim(&sa->sr_timer,
- p_recvd_service_rec->service_lease * 1000);
-#endif
- /* This was a bug since no check was made to see if too long */
- /* just make sure the timer works - get a call back within a second */
- cl_timer_trim(&sa->sr_timer, 1000);
- p_svcr->modified_time = cl_get_time_stamp_sec();
- }
-
- p_sr_item = malloc(sizeof(*p_sr_item));
- if (p_sr_item == NULL) {
- OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 2412: "
- "Unable to acquire Service record\n");
- osm_sa_send_error(sa, p_madw, IB_SA_MAD_STATUS_NO_RESOURCES);
- goto Exit;
- }
-
- if ((comp_mask & IB_SR_COMPMASK_SPKEY) != IB_SR_COMPMASK_SPKEY) {
- /* Set the Default Service P_Key in the response */
- p_recvd_service_rec->service_pkey = IB_DEFAULT_PKEY;
- }
-
- p_sr_item->service_rec = *p_recvd_service_rec;
- cl_qlist_init(&sr_list);
-
- cl_qlist_insert_tail(&sr_list, &p_sr_item->list_item);
-
- __osm_sr_rcv_respond(sa, p_madw, &sr_list);
-
-Exit:
- OSM_LOG_EXIT(sa->p_log);
-}
-
-/**********************************************************************
- **********************************************************************/
-static void
-osm_sr_rcv_process_delete_method(IN osm_sa_t * sa,
- IN osm_madw_t * const p_madw)
-{
- ib_sa_mad_t *p_sa_mad;
- ib_service_record_t *p_recvd_service_rec;
- ib_net64_t comp_mask;
- osm_svcr_t *p_svcr;
- osm_sr_item_t *p_sr_item;
- cl_qlist_t sr_list;
-
- OSM_LOG_ENTER(sa->p_log);
-
- CL_ASSERT(p_madw);
-
- p_sa_mad = osm_madw_get_sa_mad_ptr(p_madw);
- p_recvd_service_rec =
- (ib_service_record_t *) ib_sa_mad_get_payload_ptr(p_sa_mad);
-
- comp_mask = p_sa_mad->comp_mask;
-
- if (osm_log_is_active(sa->p_log, OSM_LOG_DEBUG))
- osm_dump_service_record(sa->p_log, p_recvd_service_rec,
- OSM_LOG_DEBUG);
-
- /* Grab the lock */
- cl_plock_excl_acquire(sa->p_lock);
-
- /* If Record exists with matching RID */
- p_svcr = osm_svcr_get_by_rid(sa->p_subn,
- sa->p_log, p_recvd_service_rec);
-
- if (p_svcr == NULL) {
- cl_plock_release(sa->p_lock);
- OSM_LOG(sa->p_log, OSM_LOG_DEBUG,
- "No records matched the RID\n");
- osm_sa_send_error(sa, p_madw, IB_SA_MAD_STATUS_NO_RECORDS);
- goto Exit;
- } else {
- osm_svcr_remove_from_db(sa->p_subn, sa->p_log, p_svcr);
- }
-
- cl_plock_release(sa->p_lock);
-
- p_sr_item = malloc(sizeof(*p_sr_item));
- if (p_sr_item == NULL) {
- OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 2413: "
- "Unable to acquire Service record\n");
- osm_sa_send_error(sa, p_madw, IB_SA_MAD_STATUS_NO_RESOURCES);
- goto Exit;
- }
-
- /* provide back the copy of the record */
- p_sr_item->service_rec = p_svcr->service_record;
- cl_qlist_init(&sr_list);
-
- cl_qlist_insert_tail(&sr_list, &p_sr_item->list_item);
-
- if (p_svcr)
- osm_svcr_delete(p_svcr);
-
- __osm_sr_rcv_respond(sa, p_madw, &sr_list);
-
-Exit:
- OSM_LOG_EXIT(sa->p_log);
- return;
-}
-
-/**********************************************************************
- **********************************************************************/
-void osm_sr_rcv_process(IN void *context, IN void *data)
-{
- osm_sa_t *sa = context;
- osm_madw_t *p_madw = data;
- ib_sa_mad_t *p_sa_mad;
- boolean_t valid;
-
- OSM_LOG_ENTER(sa->p_log);
-
- CL_ASSERT(p_madw);
-
- p_sa_mad = osm_madw_get_sa_mad_ptr(p_madw);
-
- CL_ASSERT(p_sa_mad->attr_id == IB_MAD_ATTR_SERVICE_RECORD);
-
- switch (p_sa_mad->method) {
- case IB_MAD_METHOD_SET:
- valid = __validate_sr(sa, p_madw);
- if (!valid) {
- OSM_LOG(sa->p_log, OSM_LOG_VERBOSE,
- "Component Mask check failed for set request\n");
- osm_sa_send_error(sa, p_madw,
- IB_SA_MAD_STATUS_REQ_INVALID);
- goto Exit;
- }
- osm_sr_rcv_process_set_method(sa, p_madw);
- break;
- case IB_MAD_METHOD_DELETE:
- valid = __validate_sr(sa, p_madw);
- if (!valid) {
- OSM_LOG(sa->p_log, OSM_LOG_DEBUG,
- "Component Mask check failed for delete request\n");
- osm_sa_send_error(sa, p_madw,
- IB_SA_MAD_STATUS_REQ_INVALID);
- goto Exit;
- }
- osm_sr_rcv_process_delete_method(sa, p_madw);
- break;
- case IB_MAD_METHOD_GET:
- case IB_MAD_METHOD_GETTABLE:
- osm_sr_rcv_process_get_method(sa, p_madw);
- break;
- default:
- OSM_LOG(sa->p_log, OSM_LOG_DEBUG,
- "Unsupported Method (%s)\n",
- ib_get_sa_method_str(p_sa_mad->method));
- osm_sa_send_error(sa, p_madw, IB_MAD_STATUS_UNSUP_METHOD_ATTR);
- break;
- }
-
-Exit:
- OSM_LOG_EXIT(sa->p_log);
-}
-
-/**********************************************************************
- **********************************************************************/
-void osm_sr_rcv_lease_cb(IN void *context)
-{
- osm_sa_t *sa = context;
- cl_list_item_t *p_list_item;
- cl_list_item_t *p_next_list_item;
- osm_svcr_t *p_svcr;
- uint32_t curr_time;
- uint32_t elapsed_time;
- uint32_t trim_time = 20; /* maxiaml timer refresh is 20 seconds */
-
- OSM_LOG_ENTER(sa->p_log);
-
- cl_plock_excl_acquire(sa->p_lock);
-
- p_list_item = cl_qlist_head(&sa->p_subn->sa_sr_list);
-
- while (p_list_item != cl_qlist_end(&sa->p_subn->sa_sr_list)) {
- p_svcr = (osm_svcr_t *) p_list_item;
-
- if (p_svcr->service_record.service_lease == 0xFFFFFFFF) {
- p_list_item = cl_qlist_next(p_list_item);
- continue;
- }
-
- /* current time in seconds */
- curr_time = cl_get_time_stamp_sec();
- /* elapsed time from last modify */
- elapsed_time = curr_time - p_svcr->modified_time;
- /* but it can not be less then 1 */
- if (elapsed_time < 1)
- elapsed_time = 1;
-
- if (elapsed_time < p_svcr->lease_period) {
- /*
- Just update the service lease period
- note: for simplicity we work with a uint32_t field
- external to the network order lease_period of the MAD
- */
- p_svcr->lease_period -= elapsed_time;
-
- OSM_LOG(sa->p_log, OSM_LOG_DEBUG,
- "Remaining time for Service Name:%s is:0x%X\n",
- p_svcr->service_record.service_name,
- p_svcr->lease_period);
-
- p_svcr->modified_time = curr_time;
-
- /* Update the trim timer */
- if (trim_time > p_svcr->lease_period) {
- trim_time = p_svcr->lease_period;
- if (trim_time < 1)
- trim_time = 1;
- }
-
- p_list_item = cl_qlist_next(p_list_item);
- continue;
-
- } else {
- p_next_list_item = cl_qlist_next(p_list_item);
-
- /* Remove the service Record */
- osm_svcr_remove_from_db(sa->p_subn,
- sa->p_log, p_svcr);
-
- osm_svcr_delete(p_svcr);
-
- p_list_item = p_next_list_item;
- continue;
- }
- }
-
- /* Release the Lock */
- cl_plock_release(sa->p_lock);
-
- if (trim_time != 0xFFFFFFFF) {
- cl_timer_trim(&sa->sr_timer, trim_time * 1000); /* Convert to milli seconds */
- }
-
- OSM_LOG_EXIT(sa->p_log);
-}
diff --git a/contrib/ofed/management/opensm/opensm/osm_sa_slvl_record.c b/contrib/ofed/management/opensm/opensm/osm_sa_slvl_record.c
deleted file mode 100644
index 0550fc1..0000000
--- a/contrib/ofed/management/opensm/opensm/osm_sa_slvl_record.c
+++ /dev/null
@@ -1,313 +0,0 @@
-/*
- * Copyright (c) 2004-2008 Voltaire, Inc. All rights reserved.
- * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved.
- * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- */
-
-/*
- * Abstract:
- * Implementation of osm_slvl_rec_rcv_t.
- * This object represents the SLtoVL Mapping Query Receiver object.
- * This object is part of the opensm family of objects.
- */
-
-#if HAVE_CONFIG_H
-# include <config.h>
-#endif /* HAVE_CONFIG_H */
-
-#include <string.h>
-#include <iba/ib_types.h>
-#include <complib/cl_qmap.h>
-#include <complib/cl_passivelock.h>
-#include <complib/cl_debug.h>
-#include <complib/cl_qlist.h>
-#include <vendor/osm_vendor_api.h>
-#include <opensm/osm_port.h>
-#include <opensm/osm_node.h>
-#include <opensm/osm_helper.h>
-#include <opensm/osm_pkey.h>
-#include <opensm/osm_sa.h>
-
-typedef struct osm_slvl_item {
- cl_list_item_t list_item;
- ib_slvl_table_record_t rec;
-} osm_slvl_item_t;
-
-typedef struct osm_slvl_search_ctxt {
- const ib_slvl_table_record_t *p_rcvd_rec;
- ib_net64_t comp_mask;
- uint8_t in_port_num;
- cl_qlist_t *p_list;
- osm_sa_t *sa;
- const osm_physp_t *p_req_physp;
-} osm_slvl_search_ctxt_t;
-
-/**********************************************************************
- **********************************************************************/
-static void
-__osm_sa_slvl_create(IN osm_sa_t * sa,
- IN const osm_physp_t * const p_physp,
- IN osm_slvl_search_ctxt_t * const p_ctxt,
- IN uint8_t in_port_idx)
-{
- osm_slvl_item_t *p_rec_item;
- uint16_t lid;
- ib_api_status_t status = IB_SUCCESS;
-
- OSM_LOG_ENTER(sa->p_log);
-
- p_rec_item = malloc(sizeof(*p_rec_item));
- if (p_rec_item == NULL) {
- OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 2602: "
- "rec_item alloc failed\n");
- status = IB_INSUFFICIENT_RESOURCES;
- goto Exit;
- }
-
- if (p_physp->p_node->node_info.node_type != IB_NODE_TYPE_SWITCH)
- lid = p_physp->port_info.base_lid;
- else
- lid = osm_node_get_base_lid(p_physp->p_node, 0);
-
- OSM_LOG(sa->p_log, OSM_LOG_DEBUG,
- "New SLtoVL Map for: OUT port 0x%016" PRIx64
- ", lid 0x%X, port %u to In Port:%u\n",
- cl_ntoh64(osm_physp_get_port_guid(p_physp)),
- cl_ntoh16(lid), osm_physp_get_port_num(p_physp), in_port_idx);
-
- memset(p_rec_item, 0, sizeof(*p_rec_item));
-
- p_rec_item->rec.lid = lid;
- p_rec_item->rec.out_port_num = osm_physp_get_port_num(p_physp);
- p_rec_item->rec.in_port_num = in_port_idx;
- p_rec_item->rec.slvl_tbl =
- *(osm_physp_get_slvl_tbl(p_physp, in_port_idx));
-
- cl_qlist_insert_tail(p_ctxt->p_list, &p_rec_item->list_item);
-
-Exit:
- OSM_LOG_EXIT(sa->p_log);
-}
-
-/**********************************************************************
- **********************************************************************/
-static void
-__osm_sa_slvl_by_comp_mask(IN osm_sa_t * sa,
- IN const osm_port_t * const p_port,
- osm_slvl_search_ctxt_t * const p_ctxt)
-{
- const ib_slvl_table_record_t *p_rcvd_rec;
- ib_net64_t comp_mask;
- const osm_physp_t *p_out_physp, *p_in_physp;
- uint8_t in_port_num, out_port_num;
- uint8_t num_ports;
- uint8_t in_port_start, in_port_end;
- uint8_t out_port_start, out_port_end;
- const osm_physp_t *p_req_physp;
-
- OSM_LOG_ENTER(sa->p_log);
-
- p_rcvd_rec = p_ctxt->p_rcvd_rec;
- comp_mask = p_ctxt->comp_mask;
- num_ports = osm_node_get_num_physp(p_port->p_node);
- in_port_start = 0;
- in_port_end = num_ports - 1;
- out_port_start = 0;
- out_port_end = num_ports - 1;
- p_req_physp = p_ctxt->p_req_physp;
-
- if (p_port->p_node->node_info.node_type != IB_NODE_TYPE_SWITCH) {
- OSM_LOG(sa->p_log, OSM_LOG_DEBUG,
- "Using Physical Default Port Number: 0x%X (for End Node)\n",
- p_port->p_physp->port_num);
- p_out_physp = p_port->p_physp;
- /* check that the p_out_physp and the p_req_physp share a pkey */
- if (osm_physp_share_pkey
- (sa->p_log, p_req_physp, p_out_physp))
- __osm_sa_slvl_create(sa, p_out_physp, p_ctxt, 0);
- } else {
- if (comp_mask & IB_SLVL_COMPMASK_OUT_PORT)
- out_port_start = out_port_end =
- p_rcvd_rec->out_port_num;
- if (comp_mask & IB_SLVL_COMPMASK_IN_PORT)
- in_port_start = in_port_end = p_rcvd_rec->in_port_num;
-
- for (out_port_num = out_port_start;
- out_port_num <= out_port_end; out_port_num++) {
- p_out_physp =
- osm_node_get_physp_ptr(p_port->p_node,
- out_port_num);
- if (!p_out_physp)
- continue;
-
- for (in_port_num = in_port_start;
- in_port_num <= in_port_end; in_port_num++) {
-#if 0
- if (out_port_num && out_port_num == in_port_num)
- continue;
-#endif
-
- p_in_physp =
- osm_node_get_physp_ptr(p_port->p_node,
- in_port_num);
- if (!p_in_physp)
- continue;
-
- /* if the requester and the p_out_physp don't share a pkey -
- continue */
- if (!osm_physp_share_pkey
- (sa->p_log, p_req_physp, p_out_physp))
- continue;
-
- __osm_sa_slvl_create(sa, p_out_physp, p_ctxt,
- in_port_num);
- }
- }
- }
- OSM_LOG_EXIT(sa->p_log);
-}
-
-/**********************************************************************
- **********************************************************************/
-static void
-__osm_sa_slvl_by_comp_mask_cb(IN cl_map_item_t * const p_map_item,
- IN void *context)
-{
- const osm_port_t *const p_port = (osm_port_t *) p_map_item;
- osm_slvl_search_ctxt_t *const p_ctxt =
- (osm_slvl_search_ctxt_t *) context;
-
- __osm_sa_slvl_by_comp_mask(p_ctxt->sa, p_port, p_ctxt);
-}
-
-/**********************************************************************
- **********************************************************************/
-void osm_slvl_rec_rcv_process(IN void *ctx, IN void *data)
-{
- osm_sa_t *sa = ctx;
- osm_madw_t *p_madw = data;
- const ib_sa_mad_t *p_rcvd_mad;
- const ib_slvl_table_record_t *p_rcvd_rec;
- const osm_port_t *p_port = NULL;
- cl_qlist_t rec_list;
- osm_slvl_search_ctxt_t context;
- ib_api_status_t status = IB_SUCCESS;
- ib_net64_t comp_mask;
- osm_physp_t *p_req_physp;
-
- CL_ASSERT(sa);
-
- OSM_LOG_ENTER(sa->p_log);
-
- CL_ASSERT(p_madw);
-
- p_rcvd_mad = osm_madw_get_sa_mad_ptr(p_madw);
- p_rcvd_rec =
- (ib_slvl_table_record_t *) ib_sa_mad_get_payload_ptr(p_rcvd_mad);
- comp_mask = p_rcvd_mad->comp_mask;
-
- CL_ASSERT(p_rcvd_mad->attr_id == IB_MAD_ATTR_SLVL_RECORD);
-
- /* we only support SubnAdmGet and SubnAdmGetTable methods */
- if (p_rcvd_mad->method != IB_MAD_METHOD_GET &&
- p_rcvd_mad->method != IB_MAD_METHOD_GETTABLE) {
- OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 2604: "
- "Unsupported Method (%s)\n",
- ib_get_sa_method_str(p_rcvd_mad->method));
- osm_sa_send_error(sa, p_madw, IB_MAD_STATUS_UNSUP_METHOD_ATTR);
- goto Exit;
- }
-
- /* update the requester physical port. */
- p_req_physp = osm_get_physp_by_mad_addr(sa->p_log, sa->p_subn,
- osm_madw_get_mad_addr_ptr
- (p_madw));
- if (p_req_physp == NULL) {
- OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 2603: "
- "Cannot find requester physical port\n");
- goto Exit;
- }
-
- cl_qlist_init(&rec_list);
-
- context.p_rcvd_rec = p_rcvd_rec;
- context.p_list = &rec_list;
- context.comp_mask = p_rcvd_mad->comp_mask;
- context.sa = sa;
- context.in_port_num = p_rcvd_rec->in_port_num;
- context.p_req_physp = p_req_physp;
-
- cl_plock_acquire(sa->p_lock);
-
- OSM_LOG(sa->p_log, OSM_LOG_DEBUG,
- "Got Query Lid:%u(%02X), In-Port:0x%02X(%02X), Out-Port:0x%02X(%02X)\n",
- cl_ntoh16(p_rcvd_rec->lid),
- (comp_mask & IB_SLVL_COMPMASK_LID) != 0,
- p_rcvd_rec->in_port_num,
- (comp_mask & IB_SLVL_COMPMASK_IN_PORT) != 0,
- p_rcvd_rec->out_port_num,
- (comp_mask & IB_SLVL_COMPMASK_OUT_PORT) != 0);
-
- /*
- If the user specified a LID, it obviously narrows our
- work load, since we don't have to search every port
- */
- if (comp_mask & IB_SLVL_COMPMASK_LID) {
- status =
- osm_get_port_by_base_lid(sa->p_subn, p_rcvd_rec->lid,
- &p_port);
- if ((status != IB_SUCCESS) || (p_port == NULL)) {
- status = IB_NOT_FOUND;
- OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 2608: "
- "No port found with LID %u\n",
- cl_ntoh16(p_rcvd_rec->lid));
- }
- }
-
- if (status == IB_SUCCESS) {
- /* if we have a unique port - no need for a port search */
- if (p_port)
- /* this does the loop on all the port phys ports */
- __osm_sa_slvl_by_comp_mask(sa, p_port, &context);
- else
- cl_qmap_apply_func(&sa->p_subn->port_guid_tbl,
- __osm_sa_slvl_by_comp_mask_cb,
- &context);
- }
-
- cl_plock_release(sa->p_lock);
-
- osm_sa_respond(sa, p_madw, sizeof(ib_slvl_table_record_t), &rec_list);
-
-Exit:
- OSM_LOG_EXIT(sa->p_log);
-}
diff --git a/contrib/ofed/management/opensm/opensm/osm_sa_sminfo_record.c b/contrib/ofed/management/opensm/opensm/osm_sa_sminfo_record.c
deleted file mode 100644
index de99065..0000000
--- a/contrib/ofed/management/opensm/opensm/osm_sa_sminfo_record.c
+++ /dev/null
@@ -1,331 +0,0 @@
-/*
- * Copyright (c) 2004-2008 Voltaire, Inc. All rights reserved.
- * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved.
- * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- */
-
-/*
- * Abstract:
- * Implementation of osm_smir_rcv_t.
- * This object represents the SMInfo Receiver object.
- * This object is part of the opensm family of objects.
- */
-
-#if HAVE_CONFIG_H
-# include <config.h>
-#endif /* HAVE_CONFIG_H */
-
-#include <string.h>
-#include <iba/ib_types.h>
-#include <complib/cl_qmap.h>
-#include <complib/cl_passivelock.h>
-#include <complib/cl_debug.h>
-#include <complib/cl_qlist.h>
-#include <vendor/osm_vendor_api.h>
-#include <opensm/osm_madw.h>
-#include <opensm/osm_log.h>
-#include <opensm/osm_subnet.h>
-#include <opensm/osm_mad_pool.h>
-#include <opensm/osm_helper.h>
-#include <opensm/osm_msgdef.h>
-#include <opensm/osm_port.h>
-#include <opensm/osm_pkey.h>
-#include <opensm/osm_remote_sm.h>
-#include <opensm/osm_sa.h>
-#include <opensm/osm_opensm.h>
-
-typedef struct osm_smir_item {
- cl_list_item_t list_item;
- ib_sminfo_record_t rec;
-} osm_smir_item_t;
-
-typedef struct osm_smir_search_ctxt {
- const ib_sminfo_record_t *p_rcvd_rec;
- ib_net64_t comp_mask;
- cl_qlist_t *p_list;
- osm_sa_t *sa;
- const osm_physp_t *p_req_physp;
-} osm_smir_search_ctxt_t;
-
-static ib_api_status_t
-__osm_smir_rcv_new_smir(IN osm_sa_t * sa,
- IN const osm_port_t * const p_port,
- IN cl_qlist_t * const p_list,
- IN ib_net64_t const guid,
- IN ib_net32_t const act_count,
- IN uint8_t const pri_state,
- IN const osm_physp_t * const p_req_physp)
-{
- osm_smir_item_t *p_rec_item;
- ib_api_status_t status = IB_SUCCESS;
-
- OSM_LOG_ENTER(sa->p_log);
-
- p_rec_item = malloc(sizeof(*p_rec_item));
- if (p_rec_item == NULL) {
- OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 2801: "
- "rec_item alloc failed\n");
- status = IB_INSUFFICIENT_RESOURCES;
- goto Exit;
- }
-
- OSM_LOG(sa->p_log, OSM_LOG_DEBUG,
- "New SMInfo: GUID 0x%016" PRIx64 "\n", cl_ntoh64(guid));
-
- memset(p_rec_item, 0, sizeof(*p_rec_item));
-
- p_rec_item->rec.lid = osm_port_get_base_lid(p_port);
- p_rec_item->rec.sm_info.guid = guid;
- p_rec_item->rec.sm_info.act_count = act_count;
- p_rec_item->rec.sm_info.pri_state = pri_state;
-
- cl_qlist_insert_tail(p_list, &p_rec_item->list_item);
-
-Exit:
- OSM_LOG_EXIT(sa->p_log);
- return (status);
-}
-
-/**********************************************************************
- **********************************************************************/
-static void
-__osm_sa_smir_by_comp_mask(IN osm_sa_t * sa,
- IN const osm_remote_sm_t * const p_rem_sm,
- osm_smir_search_ctxt_t * const p_ctxt)
-{
- const ib_sminfo_record_t *const p_rcvd_rec = p_ctxt->p_rcvd_rec;
- const osm_physp_t *const p_req_physp = p_ctxt->p_req_physp;
- ib_net64_t const comp_mask = p_ctxt->comp_mask;
-
- OSM_LOG_ENTER(sa->p_log);
-
- if (comp_mask & IB_SMIR_COMPMASK_GUID) {
- if (p_rem_sm->smi.guid != p_rcvd_rec->sm_info.guid)
- goto Exit;
- }
-
- if (comp_mask & IB_SMIR_COMPMASK_PRIORITY) {
- if (ib_sminfo_get_priority(&p_rem_sm->smi) !=
- ib_sminfo_get_priority(&p_rcvd_rec->sm_info))
- goto Exit;
- }
-
- if (comp_mask & IB_SMIR_COMPMASK_SMSTATE) {
- if (ib_sminfo_get_state(&p_rem_sm->smi) !=
- ib_sminfo_get_state(&p_rcvd_rec->sm_info))
- goto Exit;
- }
-
- /* Implement any other needed search cases */
-
- __osm_smir_rcv_new_smir(sa, p_rem_sm->p_port, p_ctxt->p_list,
- p_rem_sm->smi.guid,
- p_rem_sm->smi.act_count,
- p_rem_sm->smi.pri_state, p_req_physp);
-
-Exit:
- OSM_LOG_EXIT(sa->p_log);
-}
-
-/**********************************************************************
- **********************************************************************/
-static void
-__osm_sa_smir_by_comp_mask_cb(IN cl_map_item_t * const p_map_item,
- IN void *context)
-{
- const osm_remote_sm_t *const p_rem_sm = (osm_remote_sm_t *) p_map_item;
- osm_smir_search_ctxt_t *const p_ctxt =
- (osm_smir_search_ctxt_t *) context;
-
- __osm_sa_smir_by_comp_mask(p_ctxt->sa, p_rem_sm, p_ctxt);
-}
-
-/**********************************************************************
- **********************************************************************/
-void osm_smir_rcv_process(IN void *ctx, IN void *data)
-{
- osm_sa_t *sa = ctx;
- osm_madw_t *p_madw = data;
- const ib_sa_mad_t *sad_mad;
- const ib_sminfo_record_t *p_rcvd_rec;
- const osm_port_t *p_port = NULL;
- const ib_sm_info_t *p_smi;
- cl_qlist_t rec_list;
- osm_smir_search_ctxt_t context;
- ib_api_status_t status = IB_SUCCESS;
- ib_net64_t comp_mask;
- ib_net64_t port_guid;
- osm_physp_t *p_req_physp;
- osm_port_t *local_port;
- osm_remote_sm_t *p_rem_sm;
- cl_qmap_t *p_sm_guid_tbl;
- uint8_t pri_state;
-
- CL_ASSERT(sa);
-
- OSM_LOG_ENTER(sa->p_log);
-
- CL_ASSERT(p_madw);
-
- sad_mad = osm_madw_get_sa_mad_ptr(p_madw);
- p_rcvd_rec =
- (ib_sminfo_record_t *) ib_sa_mad_get_payload_ptr(sad_mad);
- comp_mask = sad_mad->comp_mask;
-
- CL_ASSERT(sad_mad->attr_id == IB_MAD_ATTR_SMINFO_RECORD);
-
- /* we only support SubnAdmGet and SubnAdmGetTable methods */
- if (sad_mad->method != IB_MAD_METHOD_GET &&
- sad_mad->method != IB_MAD_METHOD_GETTABLE) {
- OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 2804: "
- "Unsupported Method (%s)\n",
- ib_get_sa_method_str(sad_mad->method));
- osm_sa_send_error(sa, p_madw, IB_MAD_STATUS_UNSUP_METHOD_ATTR);
- goto Exit;
- }
-
- /* update the requester physical port. */
- p_req_physp = osm_get_physp_by_mad_addr(sa->p_log, sa->p_subn,
- osm_madw_get_mad_addr_ptr
- (p_madw));
- if (p_req_physp == NULL) {
- OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 2803: "
- "Cannot find requester physical port\n");
- goto Exit;
- }
-
- if (osm_log_is_active(sa->p_log, OSM_LOG_DEBUG))
- osm_dump_sm_info_record(sa->p_log, p_rcvd_rec, OSM_LOG_DEBUG);
-
- p_smi = &p_rcvd_rec->sm_info;
-
- cl_qlist_init(&rec_list);
-
- context.p_rcvd_rec = p_rcvd_rec;
- context.p_list = &rec_list;
- context.comp_mask = sad_mad->comp_mask;
- context.sa = sa;
- context.p_req_physp = p_req_physp;
-
- cl_plock_acquire(sa->p_lock);
-
- /*
- If the user specified a LID, it obviously narrows our
- work load, since we don't have to search every port
- */
- if (comp_mask & IB_SMIR_COMPMASK_LID) {
- status =
- osm_get_port_by_base_lid(sa->p_subn, p_rcvd_rec->lid,
- &p_port);
- if ((status != IB_SUCCESS) || (p_port == NULL)) {
- status = IB_NOT_FOUND;
- OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 2806: "
- "No port found with LID %u\n",
- cl_ntoh16(p_rcvd_rec->lid));
- }
- }
-
- if (status == IB_SUCCESS) {
- /* Handle our own SM first */
- local_port = osm_get_port_by_guid(sa->p_subn,
- sa->p_subn->sm_port_guid);
- if (!local_port) {
- cl_plock_release(sa->p_lock);
- OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 2809: "
- "No port found with GUID 0x%016" PRIx64 "\n",
- cl_ntoh64(sa->p_subn->sm_port_guid));
- goto Exit;
- }
-
- if (!p_port || local_port == p_port) {
- if (FALSE ==
- osm_physp_share_pkey(sa->p_log, p_req_physp,
- local_port->p_physp)) {
- cl_plock_release(sa->p_lock);
- OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 2805: "
- "Cannot get SMInfo record due to pkey violation\n");
- goto Exit;
- }
-
- /* Check that other search components specified match */
- if ((comp_mask & IB_SMIR_COMPMASK_GUID) &&
- sa->p_subn->sm_port_guid != p_smi->guid)
- goto Remotes;
- if ((comp_mask & IB_SMIR_COMPMASK_PRIORITY) &&
- sa->p_subn->opt.sm_priority !=
- ib_sminfo_get_priority(p_smi))
- goto Remotes;
- if ((comp_mask & IB_SMIR_COMPMASK_SMSTATE) &&
- sa->p_subn->sm_state != ib_sminfo_get_state(p_smi))
- goto Remotes;
-
- /* Now, add local SMInfo to list */
- pri_state = sa->p_subn->sm_state & 0x0F;
- pri_state |=
- (sa->p_subn->opt.sm_priority & 0x0F) << 4;
- __osm_smir_rcv_new_smir(sa, local_port, context.p_list,
- sa->p_subn->sm_port_guid,
- cl_ntoh32(sa->p_subn->p_osm->stats.qp0_mads_sent),
- pri_state, p_req_physp);
- }
-
- Remotes:
- if (p_port && p_port != local_port) {
- /* Find remote SM corresponding to p_port */
- port_guid = osm_port_get_guid(p_port);
- p_sm_guid_tbl = &sa->p_subn->sm_guid_tbl;
- p_rem_sm =
- (osm_remote_sm_t *) cl_qmap_get(p_sm_guid_tbl,
- port_guid);
- if (p_rem_sm !=
- (osm_remote_sm_t *) cl_qmap_end(p_sm_guid_tbl))
- __osm_sa_smir_by_comp_mask(sa, p_rem_sm,
- &context);
- else
- OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 280A: "
- "No remote SM for GUID 0x%016" PRIx64
- "\n", cl_ntoh64(port_guid));
- } else {
- /* Go over all other known (remote) SMs */
- cl_qmap_apply_func(&sa->p_subn->sm_guid_tbl,
- __osm_sa_smir_by_comp_mask_cb,
- &context);
- }
- }
-
- cl_plock_release(sa->p_lock);
-
- osm_sa_respond(sa, p_madw, sizeof(ib_sminfo_record_t), &rec_list);
-
-Exit:
- OSM_LOG_EXIT(sa->p_log);
-}
diff --git a/contrib/ofed/management/opensm/opensm/osm_sa_sw_info_record.c b/contrib/ofed/management/opensm/opensm/osm_sa_sw_info_record.c
deleted file mode 100644
index 649b0ac..0000000
--- a/contrib/ofed/management/opensm/opensm/osm_sa_sw_info_record.c
+++ /dev/null
@@ -1,273 +0,0 @@
-/*
- * Copyright (c) 2004-2008 Voltaire, Inc. All rights reserved.
- * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved.
- * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- */
-
-/*
- * Abstract:
- * Implementation of osm_sir_rcv_t.
- * This object represents the SwitchInfo Receiver object.
- * This object is part of the opensm family of objects.
- */
-
-#if HAVE_CONFIG_H
-# include <config.h>
-#endif /* HAVE_CONFIG_H */
-
-#include <string.h>
-#include <iba/ib_types.h>
-#include <complib/cl_debug.h>
-#include <complib/cl_qlist.h>
-#include <vendor/osm_vendor_api.h>
-#include <opensm/osm_node.h>
-#include <opensm/osm_helper.h>
-#include <opensm/osm_pkey.h>
-#include <opensm/osm_sa.h>
-
-typedef struct osm_sir_item {
- cl_list_item_t list_item;
- ib_switch_info_record_t rec;
-} osm_sir_item_t;
-
-typedef struct osm_sir_search_ctxt {
- const ib_switch_info_record_t *p_rcvd_rec;
- ib_net64_t comp_mask;
- cl_qlist_t *p_list;
- osm_sa_t *sa;
- const osm_physp_t *p_req_physp;
-} osm_sir_search_ctxt_t;
-
-/**********************************************************************
- **********************************************************************/
-static ib_api_status_t
-__osm_sir_rcv_new_sir(IN osm_sa_t * sa,
- IN const osm_switch_t * const p_sw,
- IN cl_qlist_t * const p_list, IN ib_net16_t const lid)
-{
- osm_sir_item_t *p_rec_item;
- ib_api_status_t status = IB_SUCCESS;
-
- OSM_LOG_ENTER(sa->p_log);
-
- p_rec_item = malloc(sizeof(*p_rec_item));
- if (p_rec_item == NULL) {
- OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 5308: "
- "rec_item alloc failed\n");
- status = IB_INSUFFICIENT_RESOURCES;
- goto Exit;
- }
-
- OSM_LOG(sa->p_log, OSM_LOG_DEBUG,
- "New SwitchInfoRecord: lid %u\n", cl_ntoh16(lid));
-
- memset(p_rec_item, 0, sizeof(*p_rec_item));
-
- p_rec_item->rec.lid = lid;
- p_rec_item->rec.switch_info = p_sw->switch_info;
-
- cl_qlist_insert_tail(p_list, &p_rec_item->list_item);
-
-Exit:
- OSM_LOG_EXIT(sa->p_log);
- return (status);
-}
-
-/**********************************************************************
- **********************************************************************/
-static void
-__osm_sir_rcv_create_sir(IN osm_sa_t * sa,
- IN const osm_switch_t * const p_sw,
- IN cl_qlist_t * const p_list,
- IN ib_net16_t const match_lid,
- IN const osm_physp_t * const p_req_physp)
-{
- osm_port_t *p_port;
- const osm_physp_t *p_physp;
- uint16_t match_lid_ho;
- ib_net16_t min_lid_ho;
- ib_net16_t max_lid_ho;
-
- OSM_LOG_ENTER(sa->p_log);
-
- OSM_LOG(sa->p_log, OSM_LOG_DEBUG,
- "Looking for SwitchInfoRecord with LID: %u\n",
- cl_ntoh16(match_lid));
-
- /* In switches, the port guid is the node guid. */
- p_port =
- osm_get_port_by_guid(sa->p_subn, p_sw->p_node->node_info.port_guid);
- if (!p_port) {
- OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 530A: "
- "Failed to find Port by Node Guid:0x%016" PRIx64
- "\n", cl_ntoh64(p_sw->p_node->node_info.node_guid));
- goto Exit;
- }
-
- /* check that the requester physp and the current physp are under
- the same partition. */
- p_physp = p_port->p_physp;
- if (!p_physp) {
- OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 530B: "
- "Failed to find default physical Port by Node Guid:0x%016"
- PRIx64 "\n",
- cl_ntoh64(p_sw->p_node->node_info.node_guid));
- goto Exit;
- }
- if (!osm_physp_share_pkey(sa->p_log, p_req_physp, p_physp))
- goto Exit;
-
- /* get the port 0 of the switch */
- osm_port_get_lid_range_ho(p_port, &min_lid_ho, &max_lid_ho);
-
- match_lid_ho = cl_ntoh16(match_lid);
- if (match_lid_ho) {
- /*
- We validate that the lid belongs to this switch.
- */
- OSM_LOG(sa->p_log, OSM_LOG_DEBUG,
- "Comparing LID: %u <= %u <= %u\n",
- min_lid_ho, match_lid_ho, max_lid_ho);
-
- if (match_lid_ho < min_lid_ho || match_lid_ho > max_lid_ho)
- goto Exit;
-
- }
-
- __osm_sir_rcv_new_sir(sa, p_sw, p_list, osm_port_get_base_lid(p_port));
-
-Exit:
- OSM_LOG_EXIT(sa->p_log);
-}
-
-/**********************************************************************
- **********************************************************************/
-static void
-__osm_sir_rcv_by_comp_mask(IN cl_map_item_t * const p_map_item,
- IN void *context)
-{
- const osm_sir_search_ctxt_t *const p_ctxt =
- (osm_sir_search_ctxt_t *) context;
- const osm_switch_t *const p_sw = (osm_switch_t *) p_map_item;
- const ib_switch_info_record_t *const p_rcvd_rec = p_ctxt->p_rcvd_rec;
- const osm_physp_t *const p_req_physp = p_ctxt->p_req_physp;
- osm_sa_t *sa = p_ctxt->sa;
- ib_net64_t const comp_mask = p_ctxt->comp_mask;
- ib_net16_t match_lid = 0;
-
- OSM_LOG_ENTER(p_ctxt->sa->p_log);
-
- osm_dump_switch_info(p_ctxt->sa->p_log,
- &p_sw->switch_info, OSM_LOG_VERBOSE);
-
- if (comp_mask & IB_SWIR_COMPMASK_LID) {
- match_lid = p_rcvd_rec->lid;
- if (!match_lid)
- goto Exit;
- }
-
- __osm_sir_rcv_create_sir(sa, p_sw, p_ctxt->p_list,
- match_lid, p_req_physp);
-
-Exit:
- OSM_LOG_EXIT(p_ctxt->sa->p_log);
-}
-
-/**********************************************************************
- **********************************************************************/
-void osm_sir_rcv_process(IN void *ctx, IN void *data)
-{
- osm_sa_t *sa = ctx;
- osm_madw_t *p_madw = data;
- const ib_sa_mad_t *sad_mad;
- const ib_switch_info_record_t *p_rcvd_rec;
- cl_qlist_t rec_list;
- osm_sir_search_ctxt_t context;
- osm_physp_t *p_req_physp;
-
- CL_ASSERT(sa);
-
- OSM_LOG_ENTER(sa->p_log);
-
- CL_ASSERT(p_madw);
-
- sad_mad = osm_madw_get_sa_mad_ptr(p_madw);
- p_rcvd_rec =
- (ib_switch_info_record_t *) ib_sa_mad_get_payload_ptr(sad_mad);
-
- CL_ASSERT(sad_mad->attr_id == IB_MAD_ATTR_SWITCH_INFO_RECORD);
-
- /* we only support SubnAdmGet and SubnAdmGetTable methods */
- if (sad_mad->method != IB_MAD_METHOD_GET &&
- sad_mad->method != IB_MAD_METHOD_GETTABLE) {
- OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 5305: "
- "Unsupported Method (%s)\n",
- ib_get_sa_method_str(sad_mad->method));
- osm_sa_send_error(sa, p_madw, IB_MAD_STATUS_UNSUP_METHOD_ATTR);
- goto Exit;
- }
-
- /* update the requester physical port. */
- p_req_physp = osm_get_physp_by_mad_addr(sa->p_log, sa->p_subn,
- osm_madw_get_mad_addr_ptr
- (p_madw));
- if (p_req_physp == NULL) {
- OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 5304: "
- "Cannot find requester physical port\n");
- goto Exit;
- }
-
- if (osm_log_is_active(sa->p_log, OSM_LOG_DEBUG))
- osm_dump_switch_info_record(sa->p_log, p_rcvd_rec,
- OSM_LOG_DEBUG);
-
- cl_qlist_init(&rec_list);
-
- context.p_rcvd_rec = p_rcvd_rec;
- context.p_list = &rec_list;
- context.comp_mask = sad_mad->comp_mask;
- context.sa = sa;
- context.p_req_physp = p_req_physp;
-
- cl_plock_acquire(sa->p_lock);
-
- /* Go over all switches */
- cl_qmap_apply_func(&sa->p_subn->sw_guid_tbl,
- __osm_sir_rcv_by_comp_mask, &context);
-
- cl_plock_release(sa->p_lock);
-
- osm_sa_respond(sa, p_madw, sizeof(ib_switch_info_record_t), &rec_list);
-
-Exit:
- OSM_LOG_EXIT(sa->p_log);
-}
diff --git a/contrib/ofed/management/opensm/opensm/osm_sa_vlarb_record.c b/contrib/ofed/management/opensm/opensm/osm_sa_vlarb_record.c
deleted file mode 100644
index 3bc9b8a..0000000
--- a/contrib/ofed/management/opensm/opensm/osm_sa_vlarb_record.c
+++ /dev/null
@@ -1,330 +0,0 @@
-/*
- * Copyright (c) 2004-2008 Voltaire, Inc. All rights reserved.
- * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved.
- * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- */
-
-/*
- * Abstract:
- * Implementation of osm_vlarb_rec_rcv_t.
- * This object represents the VLArbitrationRecord Receiver object.
- * This object is part of the opensm family of objects.
- */
-
-#if HAVE_CONFIG_H
-# include <config.h>
-#endif /* HAVE_CONFIG_H */
-
-#include <string.h>
-#include <iba/ib_types.h>
-#include <complib/cl_qmap.h>
-#include <complib/cl_passivelock.h>
-#include <complib/cl_debug.h>
-#include <complib/cl_qlist.h>
-#include <vendor/osm_vendor_api.h>
-#include <opensm/osm_port.h>
-#include <opensm/osm_node.h>
-#include <opensm/osm_helper.h>
-#include <opensm/osm_pkey.h>
-#include <opensm/osm_sa.h>
-
-typedef struct osm_vl_arb_item {
- cl_list_item_t list_item;
- ib_vl_arb_table_record_t rec;
-} osm_vl_arb_item_t;
-
-typedef struct osm_vl_arb_search_ctxt {
- const ib_vl_arb_table_record_t *p_rcvd_rec;
- ib_net64_t comp_mask;
- uint8_t block_num;
- cl_qlist_t *p_list;
- osm_sa_t *sa;
- const osm_physp_t *p_req_physp;
-} osm_vl_arb_search_ctxt_t;
-
-/**********************************************************************
- **********************************************************************/
-static void
-__osm_sa_vl_arb_create(IN osm_sa_t * sa,
- IN osm_physp_t * const p_physp,
- IN osm_vl_arb_search_ctxt_t * const p_ctxt,
- IN uint8_t block)
-{
- osm_vl_arb_item_t *p_rec_item;
- uint16_t lid;
- ib_api_status_t status = IB_SUCCESS;
-
- OSM_LOG_ENTER(sa->p_log);
-
- p_rec_item = malloc(sizeof(*p_rec_item));
- if (p_rec_item == NULL) {
- OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 2A02: "
- "rec_item alloc failed\n");
- status = IB_INSUFFICIENT_RESOURCES;
- goto Exit;
- }
-
- if (p_physp->p_node->node_info.node_type != IB_NODE_TYPE_SWITCH)
- lid = p_physp->port_info.base_lid;
- else
- lid = osm_node_get_base_lid(p_physp->p_node, 0);
-
- OSM_LOG(sa->p_log, OSM_LOG_DEBUG,
- "New VLArbitration for: port 0x%016" PRIx64
- ", lid %u, port %u Block:%u\n",
- cl_ntoh64(osm_physp_get_port_guid(p_physp)),
- cl_ntoh16(lid), osm_physp_get_port_num(p_physp), block);
-
- memset(p_rec_item, 0, sizeof(*p_rec_item));
-
- p_rec_item->rec.lid = lid;
- p_rec_item->rec.port_num = osm_physp_get_port_num(p_physp);
- p_rec_item->rec.block_num = block;
- p_rec_item->rec.vl_arb_tbl = *(osm_physp_get_vla_tbl(p_physp, block));
-
- cl_qlist_insert_tail(p_ctxt->p_list, &p_rec_item->list_item);
-
-Exit:
- OSM_LOG_EXIT(sa->p_log);
-}
-
-/**********************************************************************
- **********************************************************************/
-static void
-__osm_sa_vl_arb_check_physp(IN osm_sa_t * sa,
- IN osm_physp_t * const p_physp,
- osm_vl_arb_search_ctxt_t * const p_ctxt)
-{
- ib_net64_t comp_mask = p_ctxt->comp_mask;
- uint8_t block;
-
- OSM_LOG_ENTER(sa->p_log);
-
- /* we got here with the phys port - all that's left is to get the right block */
- for (block = 1; block <= 4; block++) {
- if (!(comp_mask & IB_VLA_COMPMASK_BLOCK)
- || block == p_ctxt->block_num) {
- __osm_sa_vl_arb_create(sa, p_physp, p_ctxt, block);
- }
- }
-
- OSM_LOG_EXIT(sa->p_log);
-}
-
-/**********************************************************************
- **********************************************************************/
-static void
-__osm_sa_vl_arb_by_comp_mask(IN osm_sa_t * sa,
- IN const osm_port_t * const p_port,
- osm_vl_arb_search_ctxt_t * const p_ctxt)
-{
- const ib_vl_arb_table_record_t *p_rcvd_rec;
- ib_net64_t comp_mask;
- osm_physp_t *p_physp;
- uint8_t port_num;
- uint8_t num_ports;
- const osm_physp_t *p_req_physp;
-
- OSM_LOG_ENTER(sa->p_log);
-
- p_rcvd_rec = p_ctxt->p_rcvd_rec;
- comp_mask = p_ctxt->comp_mask;
- port_num = p_rcvd_rec->port_num;
- p_req_physp = p_ctxt->p_req_physp;
-
- /* if this is a switch port we can search all ports
- otherwise we must be looking on port 0 */
- if (p_port->p_node->node_info.node_type != IB_NODE_TYPE_SWITCH) {
- /* we put it in the comp mask and port num */
- port_num = p_port->p_physp->port_num;
- OSM_LOG(sa->p_log, OSM_LOG_DEBUG,
- "Using Physical Default Port Number: 0x%X (for End Node)\n",
- port_num);
- comp_mask |= IB_VLA_COMPMASK_OUT_PORT;
- }
-
- if (comp_mask & IB_VLA_COMPMASK_OUT_PORT) {
- if (port_num < osm_node_get_num_physp(p_port->p_node)) {
- p_physp =
- osm_node_get_physp_ptr(p_port->p_node, port_num);
- /* check that the p_physp is valid, and that the requester
- and the p_physp share a pkey. */
- if (p_physp &&
- osm_physp_share_pkey(sa->p_log, p_req_physp,
- p_physp))
- __osm_sa_vl_arb_check_physp(sa, p_physp,
- p_ctxt);
- } else {
- OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 2A03: "
- "Given Physical Port Number: 0x%X is out of range should be < 0x%X\n",
- port_num,
- osm_node_get_num_physp(p_port->p_node));
- goto Exit;
- }
- } else {
- num_ports = osm_node_get_num_physp(p_port->p_node);
- for (port_num = 0; port_num < num_ports; port_num++) {
- p_physp =
- osm_node_get_physp_ptr(p_port->p_node, port_num);
- if (!p_physp)
- continue;
-
- /* if the requester and the p_physp don't share a pkey -
- continue */
- if (!osm_physp_share_pkey
- (sa->p_log, p_req_physp, p_physp))
- continue;
-
- __osm_sa_vl_arb_check_physp(sa, p_physp, p_ctxt);
- }
- }
-Exit:
- OSM_LOG_EXIT(sa->p_log);
-}
-
-/**********************************************************************
- **********************************************************************/
-static void
-__osm_sa_vl_arb_by_comp_mask_cb(IN cl_map_item_t * const p_map_item,
- IN void *context)
-{
- const osm_port_t *const p_port = (osm_port_t *) p_map_item;
- osm_vl_arb_search_ctxt_t *const p_ctxt =
- (osm_vl_arb_search_ctxt_t *) context;
-
- __osm_sa_vl_arb_by_comp_mask(p_ctxt->sa, p_port, p_ctxt);
-}
-
-/**********************************************************************
- **********************************************************************/
-void osm_vlarb_rec_rcv_process(IN void *ctx, IN void *data)
-{
- osm_sa_t *sa = ctx;
- osm_madw_t *p_madw = data;
- const ib_sa_mad_t *sad_mad;
- const ib_vl_arb_table_record_t *p_rcvd_rec;
- const osm_port_t *p_port = NULL;
- const ib_vl_arb_table_t *p_vl_arb;
- cl_qlist_t rec_list;
- osm_vl_arb_search_ctxt_t context;
- ib_api_status_t status = IB_SUCCESS;
- ib_net64_t comp_mask;
- osm_physp_t *p_req_physp;
-
- CL_ASSERT(sa);
-
- OSM_LOG_ENTER(sa->p_log);
-
- CL_ASSERT(p_madw);
-
- sad_mad = osm_madw_get_sa_mad_ptr(p_madw);
- p_rcvd_rec =
- (ib_vl_arb_table_record_t *) ib_sa_mad_get_payload_ptr(sad_mad);
- comp_mask = sad_mad->comp_mask;
-
- CL_ASSERT(sad_mad->attr_id == IB_MAD_ATTR_VLARB_RECORD);
-
- /* we only support SubnAdmGet and SubnAdmGetTable methods */
- if (sad_mad->method != IB_MAD_METHOD_GET &&
- sad_mad->method != IB_MAD_METHOD_GETTABLE) {
- OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 2A05: "
- "Unsupported Method (%s)\n",
- ib_get_sa_method_str(sad_mad->method));
- osm_sa_send_error(sa, p_madw, IB_MAD_STATUS_UNSUP_METHOD_ATTR);
- goto Exit;
- }
-
- /* update the requester physical port. */
- p_req_physp = osm_get_physp_by_mad_addr(sa->p_log, sa->p_subn,
- osm_madw_get_mad_addr_ptr
- (p_madw));
- if (p_req_physp == NULL) {
- OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 2A04: "
- "Cannot find requester physical port\n");
- goto Exit;
- }
-
- p_vl_arb = (ib_vl_arb_table_t *) ib_sa_mad_get_payload_ptr(sad_mad);
-
- cl_qlist_init(&rec_list);
-
- context.p_rcvd_rec = p_rcvd_rec;
- context.p_list = &rec_list;
- context.comp_mask = sad_mad->comp_mask;
- context.sa = sa;
- context.block_num = p_rcvd_rec->block_num;
- context.p_req_physp = p_req_physp;
-
- OSM_LOG(sa->p_log, OSM_LOG_DEBUG,
- "Got Query Lid:%u(%02X), Port:0x%02X(%02X), Block:0x%02X(%02X)\n",
- cl_ntoh16(p_rcvd_rec->lid),
- (comp_mask & IB_VLA_COMPMASK_LID) != 0, p_rcvd_rec->port_num,
- (comp_mask & IB_VLA_COMPMASK_OUT_PORT) != 0,
- p_rcvd_rec->block_num,
- (comp_mask & IB_VLA_COMPMASK_BLOCK) != 0);
-
- cl_plock_acquire(sa->p_lock);
-
- /*
- If the user specified a LID, it obviously narrows our
- work load, since we don't have to search every port
- */
- if (comp_mask & IB_VLA_COMPMASK_LID) {
- status =
- osm_get_port_by_base_lid(sa->p_subn, p_rcvd_rec->lid,
- &p_port);
- if ((status != IB_SUCCESS) || (p_port == NULL)) {
- status = IB_NOT_FOUND;
- OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 2A09: "
- "No port found with LID %u\n",
- cl_ntoh16(p_rcvd_rec->lid));
- }
- }
-
- if (status == IB_SUCCESS) {
- /* if we got a unique port - no need for a port search */
- if (p_port)
- /* this does the loop on all the port phys ports */
- __osm_sa_vl_arb_by_comp_mask(sa, p_port, &context);
- else
- cl_qmap_apply_func(&sa->p_subn->port_guid_tbl,
- __osm_sa_vl_arb_by_comp_mask_cb,
- &context);
- }
-
- cl_plock_release(sa->p_lock);
-
- osm_sa_respond(sa, p_madw, sizeof(ib_vl_arb_table_record_t), &rec_list);
-
-Exit:
- OSM_LOG_EXIT(sa->p_log);
-}
diff --git a/contrib/ofed/management/opensm/opensm/osm_service.c b/contrib/ofed/management/opensm/opensm/osm_service.c
deleted file mode 100644
index b7c1270..0000000
--- a/contrib/ofed/management/opensm/opensm/osm_service.c
+++ /dev/null
@@ -1,166 +0,0 @@
-/*
- * Copyright (c) 2004-2008 Voltaire, Inc. All rights reserved.
- * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved.
- * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- */
-
-/*
- * Abstract:
- * Implementation of service record functions.
- */
-
-#if HAVE_CONFIG_H
-# include <config.h>
-#endif /* HAVE_CONFIG_H */
-
-#include <stdlib.h>
-#include <complib/cl_debug.h>
-#include <complib/cl_timer.h>
-#include <opensm/osm_service.h>
-
-/**********************************************************************
- **********************************************************************/
-void osm_svcr_delete(IN osm_svcr_t * const p_svcr)
-{
- free(p_svcr);
-}
-
-/**********************************************************************
- **********************************************************************/
-void
-osm_svcr_init(IN osm_svcr_t * const p_svcr,
- IN const ib_service_record_t * p_svc_rec)
-{
- CL_ASSERT(p_svcr);
-
- p_svcr->modified_time = cl_get_time_stamp_sec();
-
- /* We track the time left for this service in
- an external field to avoid extra cl_ntoh/hton
- required for working with the MAD field */
- p_svcr->lease_period = cl_ntoh32(p_svc_rec->service_lease);
- p_svcr->service_record = *p_svc_rec;
-}
-
-/**********************************************************************
- **********************************************************************/
-osm_svcr_t *osm_svcr_new(IN const ib_service_record_t * p_svc_rec)
-{
- osm_svcr_t *p_svcr;
-
- CL_ASSERT(p_svc_rec);
-
- p_svcr = (osm_svcr_t *) malloc(sizeof(*p_svcr));
- if (p_svcr) {
- memset(p_svcr, 0, sizeof(*p_svcr));
- osm_svcr_init(p_svcr, p_svc_rec);
- }
-
- return (p_svcr);
-}
-
-/**********************************************************************
- **********************************************************************/
-static
- cl_status_t
-__match_rid_of_svc_rec(IN const cl_list_item_t * const p_list_item,
- IN void *context)
-{
- ib_service_record_t *p_svc_rec = (ib_service_record_t *) context;
- osm_svcr_t *p_svcr = (osm_svcr_t *) p_list_item;
- int32_t count;
-
- count = memcmp(&p_svcr->service_record,
- p_svc_rec,
- sizeof(p_svc_rec->service_id) +
- sizeof(p_svc_rec->service_gid) +
- sizeof(p_svc_rec->service_pkey));
-
- if (count == 0)
- return CL_SUCCESS;
- else
- return CL_NOT_FOUND;
-
-}
-
-/**********************************************************************
- **********************************************************************/
-osm_svcr_t *osm_svcr_get_by_rid(IN osm_subn_t const *p_subn,
- IN osm_log_t * p_log,
- IN ib_service_record_t * const p_svc_rec)
-{
- cl_list_item_t *p_list_item;
-
- OSM_LOG_ENTER(p_log);
-
- p_list_item = cl_qlist_find_from_head(&p_subn->sa_sr_list,
- __match_rid_of_svc_rec,
- p_svc_rec);
-
- if (p_list_item == cl_qlist_end(&p_subn->sa_sr_list))
- p_list_item = NULL;
-
- OSM_LOG_EXIT(p_log);
- return (osm_svcr_t *) p_list_item;
-}
-
-/**********************************************************************
- **********************************************************************/
-void
-osm_svcr_insert_to_db(IN osm_subn_t * p_subn,
- IN osm_log_t * p_log, IN osm_svcr_t * p_svcr)
-{
- OSM_LOG_ENTER(p_log);
-
- OSM_LOG(p_log, OSM_LOG_DEBUG,
- "Inserting new Service Record into Database\n");
-
- cl_qlist_insert_head(&p_subn->sa_sr_list, &p_svcr->list_item);
-
- OSM_LOG_EXIT(p_log);
-}
-
-void
-osm_svcr_remove_from_db(IN osm_subn_t * p_subn,
- IN osm_log_t * p_log, IN osm_svcr_t * p_svcr)
-{
- OSM_LOG_ENTER(p_log);
-
- OSM_LOG(p_log, OSM_LOG_DEBUG,
- "Removing Service Record Name:%s ID:0x%016" PRIx64
- " from Database\n", p_svcr->service_record.service_name,
- p_svcr->service_record.service_id);
-
- cl_qlist_remove_item(&p_subn->sa_sr_list, &p_svcr->list_item);
-
- OSM_LOG_EXIT(p_log);
-}
diff --git a/contrib/ofed/management/opensm/opensm/osm_slvl_map_rcv.c b/contrib/ofed/management/opensm/opensm/osm_slvl_map_rcv.c
deleted file mode 100644
index e177345..0000000
--- a/contrib/ofed/management/opensm/opensm/osm_slvl_map_rcv.c
+++ /dev/null
@@ -1,152 +0,0 @@
-/*
- * Copyright (c) 2004-2008 Voltaire, Inc. All rights reserved.
- * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved.
- * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- */
-
-/*
- * Abstract:
- * Implementation of osm_slvl_rcv_t.
- * This object represents the SLtoVL Receiver object.
- * This object is part of the opensm family of objects.
- */
-
-#if HAVE_CONFIG_H
-# include <config.h>
-#endif /* HAVE_CONFIG_H */
-
-#include <string.h>
-#include <iba/ib_types.h>
-#include <complib/cl_passivelock.h>
-#include <complib/cl_debug.h>
-#include <opensm/osm_madw.h>
-#include <opensm/osm_log.h>
-#include <opensm/osm_node.h>
-#include <opensm/osm_subnet.h>
-#include <opensm/osm_helper.h>
-#include <opensm/osm_sm.h>
-
-/**********************************************************************
- **********************************************************************/
-/*
- * WE MIGHT ONLY RECEIVE A GET or SET responses
- */
-void osm_slvl_rcv_process(IN void *context, IN void *p_data)
-{
- osm_sm_t *sm = context;
- osm_madw_t *p_madw = p_data;
- ib_slvl_table_t *p_slvl_tbl;
- ib_smp_t *p_smp;
- osm_port_t *p_port;
- osm_physp_t *p_physp;
- osm_node_t *p_node;
- osm_slvl_context_t *p_context;
- ib_net64_t port_guid;
- ib_net64_t node_guid;
- uint8_t out_port_num, in_port_num;
-
- CL_ASSERT(sm);
-
- OSM_LOG_ENTER(sm->p_log);
-
- CL_ASSERT(p_madw);
-
- p_smp = osm_madw_get_smp_ptr(p_madw);
- p_context = osm_madw_get_slvl_context_ptr(p_madw);
- p_slvl_tbl = (ib_slvl_table_t *) ib_smp_get_payload_ptr(p_smp);
-
- port_guid = p_context->port_guid;
- node_guid = p_context->node_guid;
-
- CL_ASSERT(p_smp->attr_id == IB_MAD_ATTR_SLVL_TABLE);
-
- cl_plock_excl_acquire(sm->p_lock);
- p_port = osm_get_port_by_guid(sm->p_subn, port_guid);
-
- if (!p_port) {
- cl_plock_release(sm->p_lock);
- OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR 2C06: "
- "No port object for port with GUID 0x%" PRIx64
- "\n\t\t\t\tfor parent node GUID 0x%" PRIx64
- ", TID 0x%" PRIx64 "\n",
- cl_ntoh64(port_guid),
- cl_ntoh64(node_guid), cl_ntoh64(p_smp->trans_id));
- goto Exit;
- }
-
- p_node = p_port->p_node;
- CL_ASSERT(p_node);
-
- /* in case of a non switch node the attr modifier should be ignored */
- if (osm_node_get_type(p_node) == IB_NODE_TYPE_SWITCH) {
- out_port_num =
- (uint8_t) cl_ntoh32(p_smp->attr_mod & 0xFF000000);
- in_port_num =
- (uint8_t) cl_ntoh32((p_smp->attr_mod & 0x00FF0000) << 8);
- p_physp = osm_node_get_physp_ptr(p_node, out_port_num);
- } else {
- p_physp = p_port->p_physp;
- out_port_num = p_physp->port_num;
- in_port_num = 0;
- }
-
- /*
- We do not mind if this is a result of a set or get - all we want is to update
- the subnet.
- */
- OSM_LOG(sm->p_log, OSM_LOG_VERBOSE,
- "Got SLtoVL get response in_port_num %u out_port_num %u with "
- "GUID 0x%" PRIx64 " for parent node GUID 0x%" PRIx64 ", TID 0x%"
- PRIx64 "\n", in_port_num, out_port_num, cl_ntoh64(port_guid),
- cl_ntoh64(node_guid), cl_ntoh64(p_smp->trans_id));
-
- /*
- Determine if we encountered a new Physical Port.
- If so, Ignore it.
- */
- if (!p_physp) {
- OSM_LOG(sm->p_log, OSM_LOG_ERROR,
- "Got invalid port number %u\n", out_port_num);
- goto Exit;
- }
-
- osm_dump_slvl_map_table(sm->p_log,
- port_guid, in_port_num,
- out_port_num, p_slvl_tbl, OSM_LOG_DEBUG);
-
- osm_physp_set_slvl_tbl(p_physp, p_slvl_tbl, in_port_num);
-
-Exit:
- cl_plock_release(sm->p_lock);
-
- OSM_LOG_EXIT(sm->p_log);
-}
diff --git a/contrib/ofed/management/opensm/opensm/osm_sm.c b/contrib/ofed/management/opensm/opensm/osm_sm.c
deleted file mode 100644
index 649ff2a..0000000
--- a/contrib/ofed/management/opensm/opensm/osm_sm.c
+++ /dev/null
@@ -1,655 +0,0 @@
-/*
- * Copyright (c) 2004-2008 Voltaire, Inc. All rights reserved.
- * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved.
- * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
- * Copyright (c) 2008 Xsigo Systems Inc. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- */
-
-/*
- * Abstract:
- * Implementation of osm_sm_t.
- * This object represents the SM Receiver object.
- * This object is part of the opensm family of objects.
- */
-
-#if HAVE_CONFIG_H
-# include <config.h>
-#endif /* HAVE_CONFIG_H */
-
-#include <stdlib.h>
-#include <string.h>
-#include <iba/ib_types.h>
-#include <complib/cl_qmap.h>
-#include <complib/cl_passivelock.h>
-#include <complib/cl_debug.h>
-#include <complib/cl_thread.h>
-#include <opensm/osm_sm.h>
-#include <opensm/osm_madw.h>
-#include <opensm/osm_log.h>
-#include <opensm/osm_node.h>
-#include <opensm/osm_msgdef.h>
-#include <opensm/osm_mcm_info.h>
-#include <opensm/osm_perfmgr.h>
-#include <opensm/osm_opensm.h>
-
-#define OSM_SM_INITIAL_TID_VALUE 0x1233
-
-extern void osm_lft_rcv_process(IN void *context, IN void *data);
-extern void osm_mft_rcv_process(IN void *context, IN void *data);
-extern void osm_nd_rcv_process(IN void *context, IN void *data);
-extern void osm_ni_rcv_process(IN void *context, IN void *data);
-extern void osm_pkey_rcv_process(IN void *context, IN void *data);
-extern void osm_pi_rcv_process(IN void *context, IN void *data);
-extern void osm_slvl_rcv_process(IN void *context, IN void *p_data);
-extern void osm_sminfo_rcv_process(IN void *context, IN void *data);
-extern void osm_si_rcv_process(IN void *context, IN void *data);
-extern void osm_trap_rcv_process(IN void *context, IN void *data);
-extern void osm_vla_rcv_process(IN void *context, IN void *data);
-
-extern void osm_state_mgr_process(IN osm_sm_t * sm, IN osm_signal_t signal);
-extern void osm_sm_state_mgr_polling_callback(IN void *context);
-
-/**********************************************************************
- **********************************************************************/
-static void osm_sm_process(osm_sm_t * sm, osm_signal_t signal)
-{
-#ifdef ENABLE_OSM_PERF_MGR
- if (signal == OSM_SIGNAL_PERFMGR_SWEEP)
- osm_perfmgr_process(&sm->p_subn->p_osm->perfmgr);
- else
-#endif
- osm_state_mgr_process(sm, signal);
-}
-
-static void __osm_sm_sweeper(IN void *p_ptr)
-{
- ib_api_status_t status;
- osm_sm_t *const p_sm = (osm_sm_t *) p_ptr;
- unsigned signals, i;
-
- OSM_LOG_ENTER(p_sm->p_log);
-
- while (p_sm->thread_state == OSM_THREAD_STATE_RUN) {
- /*
- * Wait on the event with a timeout.
- * Sweeps may be initiated "off schedule" by simply
- * signaling the event.
- */
- status = cl_event_wait_on(&p_sm->signal_event,
- EVENT_NO_TIMEOUT, TRUE);
-
- if (status == CL_SUCCESS)
- OSM_LOG(p_sm->p_log, OSM_LOG_DEBUG,
- "Off schedule sweep signalled\n");
- else if (status != CL_TIMEOUT) {
- OSM_LOG(p_sm->p_log, OSM_LOG_ERROR, "ERR 2E01: "
- "Event wait failed (%s)\n",
- CL_STATUS_MSG(status));
- continue;
- }
-
- if (osm_exit_flag)
- break;
-
- cl_spinlock_acquire(&p_sm->signal_lock);
- signals = p_sm->signal_mask;
- p_sm->signal_mask = 0;
- cl_spinlock_release(&p_sm->signal_lock);
-
- for (i = 0; signals; signals >>= 1, i++)
- if (signals & 1)
- osm_sm_process(p_sm, i);
- }
-
- OSM_LOG_EXIT(p_sm->p_log);
-}
-
-static void sm_sweep(void *arg)
-{
- osm_sm_t *sm = arg;
-
- /* do the sweep only if we are in MASTER state */
- if (sm->p_subn->sm_state == IB_SMINFO_STATE_MASTER ||
- sm->p_subn->sm_state == IB_SMINFO_STATE_DISCOVERING)
- osm_sm_signal(sm, OSM_SIGNAL_SWEEP);
- cl_timer_start(&sm->sweep_timer, sm->p_subn->opt.sweep_interval * 1000);
-}
-
-static void sweep_fail_process(IN void *context, IN void *p_data)
-{
- osm_sm_t *sm = context;
-
- OSM_LOG(sm->p_log, OSM_LOG_DEBUG, "light sweep failed\n");
- sm->p_subn->force_heavy_sweep = TRUE;
-}
-
-/**********************************************************************
- **********************************************************************/
-void osm_sm_construct(IN osm_sm_t * const p_sm)
-{
- memset(p_sm, 0, sizeof(*p_sm));
- p_sm->thread_state = OSM_THREAD_STATE_NONE;
- p_sm->sm_trans_id = OSM_SM_INITIAL_TID_VALUE;
- cl_spinlock_construct(&p_sm->signal_lock);
- cl_spinlock_construct(&p_sm->state_lock);
- cl_timer_construct(&p_sm->polling_timer);
- cl_event_construct(&p_sm->signal_event);
- cl_event_construct(&p_sm->subnet_up_event);
- cl_event_wheel_construct(&p_sm->trap_aging_tracker);
- cl_thread_construct(&p_sm->sweeper);
- cl_spinlock_construct(&p_sm->mgrp_lock);
- osm_sm_mad_ctrl_construct(&p_sm->mad_ctrl);
- osm_lid_mgr_construct(&p_sm->lid_mgr);
- osm_ucast_mgr_construct(&p_sm->ucast_mgr);
-}
-
-/**********************************************************************
- **********************************************************************/
-void osm_sm_shutdown(IN osm_sm_t * const p_sm)
-{
- boolean_t signal_event = FALSE;
-
- OSM_LOG_ENTER(p_sm->p_log);
-
- /*
- * Signal our threads that we're leaving.
- */
- if (p_sm->thread_state != OSM_THREAD_STATE_NONE)
- signal_event = TRUE;
-
- p_sm->thread_state = OSM_THREAD_STATE_EXIT;
-
- /*
- * Don't trigger unless event has been initialized.
- * Destroy the thread before we tear down the other objects.
- */
- if (signal_event)
- cl_event_signal(&p_sm->signal_event);
-
- cl_timer_stop(&p_sm->polling_timer);
- cl_timer_stop(&p_sm->sweep_timer);
- cl_thread_destroy(&p_sm->sweeper);
-
- /*
- * Always destroy controllers before the corresponding
- * receiver to guarantee that all callbacks from the
- * dispatcher are complete.
- */
- osm_sm_mad_ctrl_destroy(&p_sm->mad_ctrl);
- cl_disp_unregister(p_sm->ni_disp_h);
- cl_disp_unregister(p_sm->pi_disp_h);
- cl_disp_unregister(p_sm->si_disp_h);
- cl_disp_unregister(p_sm->nd_disp_h);
- cl_disp_unregister(p_sm->lft_disp_h);
- cl_disp_unregister(p_sm->mft_disp_h);
- cl_disp_unregister(p_sm->sm_info_disp_h);
- cl_disp_unregister(p_sm->trap_disp_h);
- cl_disp_unregister(p_sm->slvl_disp_h);
- cl_disp_unregister(p_sm->vla_disp_h);
- cl_disp_unregister(p_sm->pkey_disp_h);
- cl_disp_unregister(p_sm->sweep_fail_disp_h);
-
- OSM_LOG_EXIT(p_sm->p_log);
-}
-
-/**********************************************************************
- **********************************************************************/
-void osm_sm_destroy(IN osm_sm_t * const p_sm)
-{
- OSM_LOG_ENTER(p_sm->p_log);
- osm_lid_mgr_destroy(&p_sm->lid_mgr);
- osm_ucast_mgr_destroy(&p_sm->ucast_mgr);
- cl_event_wheel_destroy(&p_sm->trap_aging_tracker);
- cl_timer_destroy(&p_sm->sweep_timer);
- cl_timer_destroy(&p_sm->polling_timer);
- cl_event_destroy(&p_sm->signal_event);
- cl_event_destroy(&p_sm->subnet_up_event);
- cl_spinlock_destroy(&p_sm->signal_lock);
- cl_spinlock_destroy(&p_sm->mgrp_lock);
- cl_spinlock_destroy(&p_sm->state_lock);
-
- osm_log(p_sm->p_log, OSM_LOG_SYS, "Exiting SM\n"); /* Format Waived */
- OSM_LOG_EXIT(p_sm->p_log);
-}
-
-/**********************************************************************
- **********************************************************************/
-ib_api_status_t
-osm_sm_init(IN osm_sm_t * const p_sm,
- IN osm_subn_t * const p_subn,
- IN osm_db_t * const p_db,
- IN osm_vendor_t * const p_vendor,
- IN osm_mad_pool_t * const p_mad_pool,
- IN osm_vl15_t * const p_vl15,
- IN osm_log_t * const p_log,
- IN osm_stats_t * const p_stats,
- IN cl_dispatcher_t * const p_disp, IN cl_plock_t * const p_lock)
-{
- ib_api_status_t status = IB_SUCCESS;
-
- OSM_LOG_ENTER(p_log);
-
- p_sm->p_subn = p_subn;
- p_sm->p_db = p_db;
- p_sm->p_vendor = p_vendor;
- p_sm->p_mad_pool = p_mad_pool;
- p_sm->p_vl15 = p_vl15;
- p_sm->p_log = p_log;
- p_sm->p_disp = p_disp;
- p_sm->p_lock = p_lock;
-
- status = cl_spinlock_init(&p_sm->signal_lock);
- if (status != CL_SUCCESS)
- goto Exit;
-
- status = cl_spinlock_init(&p_sm->state_lock);
- if (status != CL_SUCCESS)
- goto Exit;
-
- status = cl_event_init(&p_sm->signal_event, FALSE);
- if (status != CL_SUCCESS)
- goto Exit;
-
- status = cl_event_init(&p_sm->subnet_up_event, FALSE);
- if (status != CL_SUCCESS)
- goto Exit;
-
- status = cl_timer_init(&p_sm->sweep_timer, sm_sweep, p_sm);
- if (status != CL_SUCCESS)
- goto Exit;
-
- status = cl_timer_init(&p_sm->polling_timer,
- osm_sm_state_mgr_polling_callback, p_sm);
- if (status != CL_SUCCESS)
- goto Exit;
-
- cl_qlist_init(&p_sm->mgrp_list);
-
- status = cl_spinlock_init(&p_sm->mgrp_lock);
- if (status != CL_SUCCESS)
- goto Exit;
-
- status = osm_sm_mad_ctrl_init(&p_sm->mad_ctrl,
- p_sm->p_subn,
- p_sm->p_mad_pool,
- p_sm->p_vl15,
- p_sm->p_vendor,
- p_log, p_stats, p_lock, p_disp);
- if (status != IB_SUCCESS)
- goto Exit;
-
- status = cl_event_wheel_init(&p_sm->trap_aging_tracker);
- if (status != IB_SUCCESS)
- goto Exit;
-
- status = osm_lid_mgr_init(&p_sm->lid_mgr, p_sm);
- if (status != IB_SUCCESS)
- goto Exit;
-
- status = osm_ucast_mgr_init(&p_sm->ucast_mgr, p_sm);
- if (status != IB_SUCCESS)
- goto Exit;
-
- p_sm->sweep_fail_disp_h = cl_disp_register(p_disp,
- OSM_MSG_LIGHT_SWEEP_FAIL,
- sweep_fail_process, p_sm);
- if (p_sm->sweep_fail_disp_h == CL_DISP_INVALID_HANDLE)
- goto Exit;
-
- p_sm->ni_disp_h = cl_disp_register(p_disp, OSM_MSG_MAD_NODE_INFO,
- osm_ni_rcv_process, p_sm);
- if (p_sm->ni_disp_h == CL_DISP_INVALID_HANDLE)
- goto Exit;
-
- p_sm->pi_disp_h = cl_disp_register(p_disp, OSM_MSG_MAD_PORT_INFO,
- osm_pi_rcv_process, p_sm);
- if (p_sm->pi_disp_h == CL_DISP_INVALID_HANDLE)
- goto Exit;
-
- p_sm->si_disp_h = cl_disp_register(p_disp, OSM_MSG_MAD_SWITCH_INFO,
- osm_si_rcv_process, p_sm);
- if (p_sm->si_disp_h == CL_DISP_INVALID_HANDLE)
- goto Exit;
-
- p_sm->nd_disp_h = cl_disp_register(p_disp, OSM_MSG_MAD_NODE_DESC,
- osm_nd_rcv_process, p_sm);
- if (p_sm->nd_disp_h == CL_DISP_INVALID_HANDLE)
- goto Exit;
-
- p_sm->lft_disp_h = cl_disp_register(p_disp, OSM_MSG_MAD_LFT,
- osm_lft_rcv_process, p_sm);
- if (p_sm->lft_disp_h == CL_DISP_INVALID_HANDLE)
- goto Exit;
-
- p_sm->mft_disp_h = cl_disp_register(p_disp, OSM_MSG_MAD_MFT,
- osm_mft_rcv_process, p_sm);
- if (p_sm->mft_disp_h == CL_DISP_INVALID_HANDLE)
- goto Exit;
-
- p_sm->sm_info_disp_h = cl_disp_register(p_disp, OSM_MSG_MAD_SM_INFO,
- osm_sminfo_rcv_process, p_sm);
- if (p_sm->sm_info_disp_h == CL_DISP_INVALID_HANDLE)
- goto Exit;
-
- p_sm->trap_disp_h = cl_disp_register(p_disp, OSM_MSG_MAD_NOTICE,
- osm_trap_rcv_process, p_sm);
- if (p_sm->trap_disp_h == CL_DISP_INVALID_HANDLE)
- goto Exit;
-
- p_sm->slvl_disp_h = cl_disp_register(p_disp, OSM_MSG_MAD_SLVL,
- osm_slvl_rcv_process, p_sm);
- if (p_sm->slvl_disp_h == CL_DISP_INVALID_HANDLE)
- goto Exit;
-
- p_sm->vla_disp_h = cl_disp_register(p_disp, OSM_MSG_MAD_VL_ARB,
- osm_vla_rcv_process, p_sm);
- if (p_sm->vla_disp_h == CL_DISP_INVALID_HANDLE)
- goto Exit;
-
- p_sm->pkey_disp_h = cl_disp_register(p_disp, OSM_MSG_MAD_PKEY,
- osm_pkey_rcv_process, p_sm);
- if (p_sm->pkey_disp_h == CL_DISP_INVALID_HANDLE)
- goto Exit;
-
- p_subn->sm_state = p_subn->opt.sm_inactive ?
- IB_SMINFO_STATE_NOTACTIVE : IB_SMINFO_STATE_DISCOVERING;
- osm_report_sm_state(p_sm);
-
- /*
- * Now that the component objects are initialized, start
- * the sweeper thread if the user wants sweeping.
- */
- p_sm->thread_state = OSM_THREAD_STATE_RUN;
- status = cl_thread_init(&p_sm->sweeper, __osm_sm_sweeper, p_sm,
- "opensm sweeper");
- if (status != IB_SUCCESS)
- goto Exit;
-
- if (p_sm->p_subn->opt.sweep_interval)
- cl_timer_start(&p_sm->sweep_timer,
- p_sm->p_subn->opt.sweep_interval * 1000);
-
-Exit:
- OSM_LOG_EXIT(p_log);
- return (status);
-}
-
-/**********************************************************************
- **********************************************************************/
-void osm_sm_signal(osm_sm_t * p_sm, osm_signal_t signal)
-{
- cl_spinlock_acquire(&p_sm->signal_lock);
- p_sm->signal_mask |= 1 << signal;
- cl_event_signal(&p_sm->signal_event);
- cl_spinlock_release(&p_sm->signal_lock);
-}
-
-/**********************************************************************
- **********************************************************************/
-void osm_sm_sweep(IN osm_sm_t * const p_sm)
-{
- OSM_LOG_ENTER(p_sm->p_log);
- osm_sm_signal(p_sm, OSM_SIGNAL_SWEEP);
- OSM_LOG_EXIT(p_sm->p_log);
-}
-
-/**********************************************************************
- **********************************************************************/
-ib_api_status_t
-osm_sm_bind(IN osm_sm_t * const p_sm, IN const ib_net64_t port_guid)
-{
- ib_api_status_t status;
-
- OSM_LOG_ENTER(p_sm->p_log);
-
- status = osm_sm_mad_ctrl_bind(&p_sm->mad_ctrl, port_guid);
-
- if (status != IB_SUCCESS) {
- OSM_LOG(p_sm->p_log, OSM_LOG_ERROR, "ERR 2E10: "
- "SM MAD Controller bind failed (%s)\n",
- ib_get_err_str(status));
- goto Exit;
- }
-
-Exit:
- OSM_LOG_EXIT(p_sm->p_log);
- return (status);
-}
-
-/**********************************************************************
- **********************************************************************/
-static ib_api_status_t
-__osm_sm_mgrp_process(IN osm_sm_t * const p_sm,
- IN osm_mgrp_t * const p_mgrp,
- IN const ib_net64_t port_guid,
- IN osm_mcast_req_type_t req_type)
-{
- osm_mcast_mgr_ctxt_t *ctx;
-
- /*
- * 'Schedule' all the QP0 traffic for when the state manager
- * isn't busy trying to do something else.
- */
- ctx = malloc(sizeof(*ctx));
- if (!ctx)
- return IB_ERROR;
- memset(ctx, 0, sizeof(*ctx));
- ctx->mlid = p_mgrp->mlid;
- ctx->req_type = req_type;
- ctx->port_guid = port_guid;
-
- cl_spinlock_acquire(&p_sm->mgrp_lock);
- cl_qlist_insert_tail(&p_sm->mgrp_list, &ctx->list_item);
- cl_spinlock_release(&p_sm->mgrp_lock);
-
- osm_sm_signal(p_sm, OSM_SIGNAL_IDLE_TIME_PROCESS_REQUEST);
-
- return IB_SUCCESS;
-}
-
-/**********************************************************************
- **********************************************************************/
-static ib_api_status_t
-__osm_sm_mgrp_connect(IN osm_sm_t * const p_sm,
- IN osm_mgrp_t * const p_mgrp,
- IN const ib_net64_t port_guid,
- IN osm_mcast_req_type_t req_type)
-{
- return __osm_sm_mgrp_process(p_sm, p_mgrp, port_guid, req_type);
-}
-
-/**********************************************************************
- **********************************************************************/
-static void
-__osm_sm_mgrp_disconnect(IN osm_sm_t * const p_sm,
- IN osm_mgrp_t * const p_mgrp,
- IN const ib_net64_t port_guid)
-{
- __osm_sm_mgrp_process(p_sm, p_mgrp, port_guid,
- OSM_MCAST_REQ_TYPE_LEAVE);
-}
-
-/**********************************************************************
- **********************************************************************/
-ib_api_status_t
-osm_sm_mcgrp_join(IN osm_sm_t * const p_sm,
- IN const ib_net16_t mlid,
- IN const ib_net64_t port_guid,
- IN osm_mcast_req_type_t req_type)
-{
- osm_mgrp_t *p_mgrp;
- osm_port_t *p_port;
- ib_api_status_t status = IB_SUCCESS;
- osm_mcm_info_t *p_mcm;
-
- OSM_LOG_ENTER(p_sm->p_log);
-
- OSM_LOG(p_sm->p_log, OSM_LOG_VERBOSE,
- "Port 0x%016" PRIx64 " joining MLID 0x%X\n",
- cl_ntoh64(port_guid), cl_ntoh16(mlid));
-
- /*
- * Acquire the port object for the port joining this group.
- */
- CL_PLOCK_EXCL_ACQUIRE(p_sm->p_lock);
- p_port = osm_get_port_by_guid(p_sm->p_subn, port_guid);
- if (!p_port) {
- CL_PLOCK_RELEASE(p_sm->p_lock);
- OSM_LOG(p_sm->p_log, OSM_LOG_ERROR, "ERR 2E05: "
- "No port object for port 0x%016" PRIx64 "\n",
- cl_ntoh64(port_guid));
- status = IB_INVALID_PARAMETER;
- goto Exit;
- }
-
- /*
- * If this multicast group does not already exist, create it.
- */
- p_mgrp = osm_get_mgrp_by_mlid(p_sm->p_subn, mlid);
- if (!p_mgrp || !osm_mgrp_is_guid(p_mgrp, port_guid)) {
- /*
- * The group removed or the port is not a
- * member of the group, then fail immediately.
- * This can happen since the spinlock is released briefly
- * before the SA calls this function.
- */
- CL_PLOCK_RELEASE(p_sm->p_lock);
- OSM_LOG(p_sm->p_log, OSM_LOG_ERROR, "ERR 2E12: "
- "MC group with mlid 0x%x doesn't exist or "
- "port 0x%016" PRIx64 " is not in the group.\n",
- cl_ntoh16(mlid), cl_ntoh64(port_guid));
- status = IB_NOT_FOUND;
- goto Exit;
- }
-
- /*
- * Check if the object (according to mlid) already exists on this port.
- * If it does - then no need to update it again, and no need to
- * create the mc tree again. Just goto Exit.
- */
- p_mcm = (osm_mcm_info_t *) cl_qlist_head(&p_port->mcm_list);
- while (p_mcm != (osm_mcm_info_t *) cl_qlist_end(&p_port->mcm_list)) {
- if (p_mcm->mlid == mlid) {
- CL_PLOCK_RELEASE(p_sm->p_lock);
- OSM_LOG(p_sm->p_log, OSM_LOG_DEBUG,
- "Found mlid object for Port:"
- "0x%016" PRIx64 " lid:0x%X\n",
- cl_ntoh64(port_guid), cl_ntoh16(mlid));
- goto Exit;
- }
- p_mcm = (osm_mcm_info_t *) cl_qlist_next(&p_mcm->list_item);
- }
-
- status = osm_port_add_mgrp(p_port, mlid);
- if (status != IB_SUCCESS) {
- CL_PLOCK_RELEASE(p_sm->p_lock);
- OSM_LOG(p_sm->p_log, OSM_LOG_ERROR, "ERR 2E03: "
- "Unable to associate port 0x%" PRIx64 " to mlid 0x%X\n",
- cl_ntoh64(osm_port_get_guid(p_port)),
- cl_ntoh16(osm_mgrp_get_mlid(p_mgrp)));
- goto Exit;
- }
-
- status = __osm_sm_mgrp_connect(p_sm, p_mgrp, port_guid, req_type);
- CL_PLOCK_RELEASE(p_sm->p_lock);
-
-Exit:
- OSM_LOG_EXIT(p_sm->p_log);
- return (status);
-}
-
-/**********************************************************************
- **********************************************************************/
-ib_api_status_t
-osm_sm_mcgrp_leave(IN osm_sm_t * const p_sm,
- IN const ib_net16_t mlid, IN const ib_net64_t port_guid)
-{
- osm_mgrp_t *p_mgrp;
- osm_port_t *p_port;
- ib_api_status_t status = IB_SUCCESS;
-
- OSM_LOG_ENTER(p_sm->p_log);
-
- OSM_LOG(p_sm->p_log, OSM_LOG_VERBOSE,
- "Port 0x%" PRIx64 " leaving MLID 0x%X\n",
- cl_ntoh64(port_guid), cl_ntoh16(mlid));
-
- /*
- * Acquire the port object for the port leaving this group.
- */
- CL_PLOCK_EXCL_ACQUIRE(p_sm->p_lock);
-
- p_port = osm_get_port_by_guid(p_sm->p_subn, port_guid);
- if (!p_port) {
- CL_PLOCK_RELEASE(p_sm->p_lock);
- OSM_LOG(p_sm->p_log, OSM_LOG_ERROR, "ERR 2E04: "
- "No port object for port 0x%" PRIx64 "\n",
- cl_ntoh64(port_guid));
- status = IB_INVALID_PARAMETER;
- goto Exit;
- }
-
- /*
- * Get the multicast group object for this group.
- */
- p_mgrp = osm_get_mgrp_by_mlid(p_sm->p_subn, mlid);
- if (!p_mgrp) {
- CL_PLOCK_RELEASE(p_sm->p_lock);
- OSM_LOG(p_sm->p_log, OSM_LOG_ERROR, "ERR 2E08: "
- "No multicast group for MLID 0x%X\n", cl_ntoh16(mlid));
- status = IB_INVALID_PARAMETER;
- goto Exit;
- }
-
- /*
- * Walk the list of ports in the group, and remove the appropriate one.
- */
- osm_port_remove_mgrp(p_port, mlid);
-
- __osm_sm_mgrp_disconnect(p_sm, p_mgrp, port_guid);
- CL_PLOCK_RELEASE(p_sm->p_lock);
-
-Exit:
- OSM_LOG_EXIT(p_sm->p_log);
- return (status);
-}
-
-void osm_set_sm_priority(osm_sm_t *sm, uint8_t priority)
-{
- uint8_t old_pri = sm->p_subn->opt.sm_priority;
-
- sm->p_subn->opt.sm_priority = priority;
-
- if (old_pri < priority &&
- sm->p_subn->sm_state == IB_SMINFO_STATE_STANDBY)
- osm_send_trap144(sm, TRAP_144_MASK_SM_PRIORITY_CHANGE);
-}
diff --git a/contrib/ofed/management/opensm/opensm/osm_sm_mad_ctrl.c b/contrib/ofed/management/opensm/opensm/osm_sm_mad_ctrl.c
deleted file mode 100644
index 267ec85..0000000
--- a/contrib/ofed/management/opensm/opensm/osm_sm_mad_ctrl.c
+++ /dev/null
@@ -1,874 +0,0 @@
-/*
- * Copyright (c) 2004-2008 Voltaire, Inc. All rights reserved.
- * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved.
- * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- */
-
-/*
- * Abstract:
- * Implementation of osm_sm_mad_ctrl_t.
- * This object represents the SM MAD request controller object.
- * This object is part of the opensm family of objects.
- */
-
-#if HAVE_CONFIG_H
-# include <config.h>
-#endif /* HAVE_CONFIG_H */
-
-#include <string.h>
-#include <complib/cl_debug.h>
-#include <iba/ib_types.h>
-#include <opensm/osm_sm_mad_ctrl.h>
-#include <vendor/osm_vendor_api.h>
-#include <opensm/osm_madw.h>
-#include <opensm/osm_msgdef.h>
-#include <opensm/osm_helper.h>
-#include <opensm/osm_opensm.h>
-
-/****f* opensm: SM/__osm_sm_mad_ctrl_retire_trans_mad
- * NAME
- * __osm_sm_mad_ctrl_retire_trans_mad
- *
- * DESCRIPTION
- * This function handles clean-up of MADs associated with the SM's
- * outstanding transactions on the wire.
- *
- * SYNOPSIS
- */
-
-static void
-__osm_sm_mad_ctrl_retire_trans_mad(IN osm_sm_mad_ctrl_t * const p_ctrl,
- IN osm_madw_t * const p_madw)
-{
- uint32_t outstanding;
-
- OSM_LOG_ENTER(p_ctrl->p_log);
-
- CL_ASSERT(p_madw);
- /*
- Return the MAD & wrapper to the pool.
- */
- OSM_LOG(p_ctrl->p_log, OSM_LOG_DEBUG,
- "Retiring MAD with TID 0x%" PRIx64 "\n",
- cl_ntoh64(osm_madw_get_smp_ptr(p_madw)->trans_id));
-
- osm_mad_pool_put(p_ctrl->p_mad_pool, p_madw);
-
- outstanding = osm_stats_dec_qp0_outstanding(p_ctrl->p_stats);
-
- OSM_LOG(p_ctrl->p_log, OSM_LOG_DEBUG, "%u QP0 MADs outstanding%s\n",
- p_ctrl->p_stats->qp0_mads_outstanding,
- outstanding ? "" : ": wire is clean.");
-
- OSM_LOG_EXIT(p_ctrl->p_log);
-}
-
-/************/
-
-/****f* opensm: SM/__osm_sm_mad_ctrl_disp_done_callback
- * NAME
- * __osm_sm_mad_ctrl_disp_done_callback
- *
- * DESCRIPTION
- * This function is the Dispatcher callback that indicates
- * a received MAD has been processed by the recipient.
- *
- * SYNOPSIS
- */
-static void
-__osm_sm_mad_ctrl_disp_done_callback(IN void *context, IN void *p_data)
-{
- osm_sm_mad_ctrl_t *const p_ctrl = (osm_sm_mad_ctrl_t *) context;
- osm_madw_t *const p_madw = (osm_madw_t *) p_data;
- ib_smp_t *p_smp;
-
- OSM_LOG_ENTER(p_ctrl->p_log);
-
- /*
- If the MAD that just finished processing was a response,
- then retire the transaction, since we must have generated
- the request.
-
- Otherwise, retire the transaction if a response was expected,
- as in the case of a send failure. If a response was not expected,
- just put the MAD back in the pool, because the MAD was a query
- from some outside agent, e.g. Get(SMInfo) from another SM.
- */
- p_smp = osm_madw_get_smp_ptr(p_madw);
- if (ib_smp_is_response(p_smp)) {
- CL_ASSERT(p_madw->resp_expected == FALSE);
- __osm_sm_mad_ctrl_retire_trans_mad(p_ctrl, p_madw);
- } else if (p_madw->resp_expected == TRUE)
- __osm_sm_mad_ctrl_retire_trans_mad(p_ctrl, p_madw);
- else
- osm_mad_pool_put(p_ctrl->p_mad_pool, p_madw);
-
- OSM_LOG_EXIT(p_ctrl->p_log);
-}
-
-/************/
-
-/****f* opensm: SM/__osm_sm_mad_ctrl_update_wire_stats
- * NAME
- * __osm_sm_mad_ctrl_update_wire_stats
- *
- * DESCRIPTION
- * Updates wire stats for outstanding MADs and calls the VL15 poller.
- *
- * SYNOPSIS
- */
-static void
-__osm_sm_mad_ctrl_update_wire_stats(IN osm_sm_mad_ctrl_t * const p_ctrl)
-{
- uint32_t mads_on_wire;
-
- OSM_LOG_ENTER(p_ctrl->p_log);
-
- mads_on_wire =
- cl_atomic_dec(&p_ctrl->p_stats->qp0_mads_outstanding_on_wire);
-
- OSM_LOG(p_ctrl->p_log, OSM_LOG_DEBUG,
- "%u SMPs on the wire, %u outstanding\n", mads_on_wire,
- p_ctrl->p_stats->qp0_mads_outstanding);
-
- /*
- We can signal the VL15 controller to send another MAD
- if any are waiting for transmission.
- */
- osm_vl15_poll(p_ctrl->p_vl15);
- OSM_LOG_EXIT(p_ctrl->p_log);
-}
-
-/****f* opensm: SM/__osm_sm_mad_ctrl_process_get_resp
- * NAME
- * __osm_sm_mad_ctrl_process_get_resp
- *
- * DESCRIPTION
- * This function handles method GetResp() for received MADs.
- * This is the most common path for QP0 MADs.
- *
- * SYNOPSIS
- */
-static void
-__osm_sm_mad_ctrl_process_get_resp(IN osm_sm_mad_ctrl_t * const p_ctrl,
- IN osm_madw_t * p_madw,
- IN void *transaction_context)
-{
- ib_smp_t *p_smp;
- cl_status_t status;
- osm_madw_t *p_old_madw;
- cl_disp_msgid_t msg_id = CL_DISP_MSGID_NONE;
-
- OSM_LOG_ENTER(p_ctrl->p_log);
-
- CL_ASSERT(p_madw);
- CL_ASSERT(transaction_context);
-
- p_smp = osm_madw_get_smp_ptr(p_madw);
-
- if (p_smp->mgmt_class == IB_MCLASS_SUBN_DIR && !ib_smp_is_d(p_smp)) {
- OSM_LOG(p_ctrl->p_log, OSM_LOG_ERROR, "ERR 3102: "
- "'D' bit not set in returned SMP\n");
- osm_dump_dr_smp(p_ctrl->p_log, p_smp, OSM_LOG_ERROR);
- }
-
- p_old_madw = (osm_madw_t *) transaction_context;
-
- __osm_sm_mad_ctrl_update_wire_stats(p_ctrl);
-
- /*
- Copy the MAD Wrapper context from the requesting MAD
- to the new MAD. This mechanism allows the recipient
- controller to recover its own context regarding this
- MAD transaction. Once we've copied the context, we
- can return the original MAD to the pool.
- */
- osm_madw_copy_context(p_madw, p_old_madw);
- osm_mad_pool_put(p_ctrl->p_mad_pool, p_old_madw);
-
- /*
- Note that attr_id (like the rest of the MAD) is in
- network byte order.
- */
- switch (p_smp->attr_id) {
- case IB_MAD_ATTR_NODE_DESC:
- msg_id = OSM_MSG_MAD_NODE_DESC;
- break;
- case IB_MAD_ATTR_NODE_INFO:
- msg_id = OSM_MSG_MAD_NODE_INFO;
- break;
- case IB_MAD_ATTR_SWITCH_INFO:
- msg_id = OSM_MSG_MAD_SWITCH_INFO;
- break;
- case IB_MAD_ATTR_PORT_INFO:
- msg_id = OSM_MSG_MAD_PORT_INFO;
- break;
- case IB_MAD_ATTR_LIN_FWD_TBL:
- msg_id = OSM_MSG_MAD_LFT;
- break;
- case IB_MAD_ATTR_MCAST_FWD_TBL:
- msg_id = OSM_MSG_MAD_MFT;
- break;
- case IB_MAD_ATTR_SM_INFO:
- msg_id = OSM_MSG_MAD_SM_INFO;
- break;
- case IB_MAD_ATTR_SLVL_TABLE:
- msg_id = OSM_MSG_MAD_SLVL;
- break;
- case IB_MAD_ATTR_VL_ARBITRATION:
- msg_id = OSM_MSG_MAD_VL_ARB;
- break;
- case IB_MAD_ATTR_P_KEY_TABLE:
- msg_id = OSM_MSG_MAD_PKEY;
- break;
-
- case IB_MAD_ATTR_GUID_INFO:
- case IB_MAD_ATTR_CLASS_PORT_INFO:
- case IB_MAD_ATTR_NOTICE:
- case IB_MAD_ATTR_INFORM_INFO:
- default:
- cl_atomic_inc(&p_ctrl->p_stats->qp0_mads_rcvd_unknown);
- OSM_LOG(p_ctrl->p_log, OSM_LOG_ERROR, "ERR 3103: "
- "Unsupported attribute = 0x%X\n",
- cl_ntoh16(p_smp->attr_id));
- osm_dump_dr_smp(p_ctrl->p_log, p_smp, OSM_LOG_ERROR);
- goto Exit;
- }
-
- if (msg_id == CL_DISP_MSGID_NONE)
- goto Exit;
-
- /*
- Post this MAD to the dispatcher for asynchronous
- processing by the appropriate controller.
- */
-
- OSM_LOG(p_ctrl->p_log, OSM_LOG_DEBUG, "Posting Dispatcher message %s\n",
- osm_get_disp_msg_str(msg_id));
-
- status = cl_disp_post(p_ctrl->h_disp, msg_id, p_madw,
- __osm_sm_mad_ctrl_disp_done_callback, p_ctrl);
-
- if (status != CL_SUCCESS) {
- OSM_LOG(p_ctrl->p_log, OSM_LOG_ERROR, "ERR 3104: "
- "Dispatcher post message failed (%s) for attribute = 0x%X\n",
- CL_STATUS_MSG(status), cl_ntoh16(p_smp->attr_id));
- goto Exit;
- }
-
-Exit:
- OSM_LOG_EXIT(p_ctrl->p_log);
-}
-
-/****f* opensm: SM/__osm_sm_mad_ctrl_process_get
- * NAME
- * __osm_sm_mad_ctrl_process_get
- *
- * DESCRIPTION
- * This function handles method Get() for received MADs.
- *
- * SYNOPSIS
- */
-static void
-__osm_sm_mad_ctrl_process_get(IN osm_sm_mad_ctrl_t * const p_ctrl,
- IN osm_madw_t * p_madw)
-{
- ib_smp_t *p_smp;
- cl_status_t status;
- cl_disp_msgid_t msg_id = CL_DISP_MSGID_NONE;
-
- OSM_LOG_ENTER(p_ctrl->p_log);
-
- p_smp = osm_madw_get_smp_ptr(p_madw);
-
- /*
- Note that attr_id (like the rest of the MAD) is in
- network byte order.
- */
- switch (p_smp->attr_id) {
- case IB_MAD_ATTR_SM_INFO:
- msg_id = OSM_MSG_MAD_SM_INFO;
- break;
-
- default:
- cl_atomic_inc(&p_ctrl->p_stats->qp0_mads_rcvd_unknown);
- OSM_LOG(p_ctrl->p_log, OSM_LOG_VERBOSE,
- "Ignoring SubnGet MAD - unsupported attribute = 0x%X\n",
- cl_ntoh16(p_smp->attr_id));
- break;
- }
-
- if (msg_id == CL_DISP_MSGID_NONE) {
- /*
- There is an unknown MAD attribute type for which there is
- no recipient. Simply retire the MAD here.
- */
- osm_mad_pool_put(p_ctrl->p_mad_pool, p_madw);
- goto Exit;
- }
-
- /*
- Post this MAD to the dispatcher for asynchronous
- processing by the appropriate controller.
- */
-
- OSM_LOG(p_ctrl->p_log, OSM_LOG_DEBUG, "Posting Dispatcher message %s\n",
- osm_get_disp_msg_str(msg_id));
-
- status = cl_disp_post(p_ctrl->h_disp, msg_id, p_madw,
- __osm_sm_mad_ctrl_disp_done_callback, p_ctrl);
-
- if (status != CL_SUCCESS) {
- OSM_LOG(p_ctrl->p_log, OSM_LOG_ERROR, "ERR 3106: "
- "Dispatcher post message failed (%s)\n",
- CL_STATUS_MSG(status));
- goto Exit;
- }
-
-Exit:
- OSM_LOG_EXIT(p_ctrl->p_log);
-}
-
-/*
- * PARAMETERS
- *
- * RETURN VALUES
- *
- * NOTES
- *
- * SEE ALSO
- *********/
-
-/****f* opensm: SM/__osm_sm_mad_ctrl_process_set
- * NAME
- * __osm_sm_mad_ctrl_process_set
- *
- * DESCRIPTION
- * This function handles method Set() for received MADs.
- *
- * SYNOPSIS
- */
-static void
-__osm_sm_mad_ctrl_process_set(IN osm_sm_mad_ctrl_t * const p_ctrl,
- IN osm_madw_t * p_madw)
-{
- ib_smp_t *p_smp;
- cl_status_t status;
- cl_disp_msgid_t msg_id = CL_DISP_MSGID_NONE;
-
- OSM_LOG_ENTER(p_ctrl->p_log);
-
- p_smp = osm_madw_get_smp_ptr(p_madw);
-
- /*
- Note that attr_id (like the rest of the MAD) is in
- network byte order.
- */
- switch (p_smp->attr_id) {
- case IB_MAD_ATTR_SM_INFO:
- msg_id = OSM_MSG_MAD_SM_INFO;
- break;
-
- default:
- cl_atomic_inc(&p_ctrl->p_stats->qp0_mads_rcvd_unknown);
- OSM_LOG(p_ctrl->p_log, OSM_LOG_ERROR, "ERR 3107: "
- "Unsupported attribute = 0x%X\n",
- cl_ntoh16(p_smp->attr_id));
- osm_dump_dr_smp(p_ctrl->p_log, p_smp, OSM_LOG_ERROR);
- break;
- }
-
- if (msg_id == CL_DISP_MSGID_NONE) {
- /*
- There is an unknown MAD attribute type for which there is
- no recipient. Simply retire the MAD here.
- */
- osm_mad_pool_put(p_ctrl->p_mad_pool, p_madw);
- goto Exit;
- }
-
- /*
- Post this MAD to the dispatcher for asynchronous
- processing by the appropriate controller.
- */
-
- OSM_LOG(p_ctrl->p_log, OSM_LOG_DEBUG, "Posting Dispatcher message %s\n",
- osm_get_disp_msg_str(msg_id));
-
- status = cl_disp_post(p_ctrl->h_disp, msg_id, p_madw,
- __osm_sm_mad_ctrl_disp_done_callback, p_ctrl);
-
- if (status != CL_SUCCESS) {
- OSM_LOG(p_ctrl->p_log, OSM_LOG_ERROR, "ERR 3108: "
- "Dispatcher post message failed (%s)\n",
- CL_STATUS_MSG(status));
- goto Exit;
- }
-
-Exit:
- OSM_LOG_EXIT(p_ctrl->p_log);
-}
-
-/*
- * PARAMETERS
- *
- * RETURN VALUES
- *
- * NOTES
- *
- * SEE ALSO
- *********/
-
-/****f* opensm: SM/__osm_sm_mad_ctrl_process_trap
- * NAME
- * __osm_sm_mad_ctrl_process_trap
- *
- * DESCRIPTION
- * This function handles method Trap() for received MADs.
- *
- * SYNOPSIS
- */
-static void
-__osm_sm_mad_ctrl_process_trap(IN osm_sm_mad_ctrl_t * const p_ctrl,
- IN osm_madw_t * p_madw)
-{
- ib_smp_t *p_smp;
- cl_status_t status;
- cl_disp_msgid_t msg_id = CL_DISP_MSGID_NONE;
-
- OSM_LOG_ENTER(p_ctrl->p_log);
-
- p_smp = osm_madw_get_smp_ptr(p_madw);
-
- /* Make sure OpenSM is master. If not - then we should not process the trap */
- if (p_ctrl->p_subn->sm_state != IB_SMINFO_STATE_MASTER) {
- OSM_LOG(p_ctrl->p_log, OSM_LOG_DEBUG,
- "Received trap but OpenSM is not in MASTER state. "
- "Dropping mad\n");
- osm_mad_pool_put(p_ctrl->p_mad_pool, p_madw);
- goto Exit;
- }
-
- /*
- Note that attr_id (like the rest of the MAD) is in
- network byte order.
- */
- switch (p_smp->attr_id) {
- case IB_MAD_ATTR_NOTICE:
- msg_id = OSM_MSG_MAD_NOTICE;
- break;
-
- default:
- cl_atomic_inc(&p_ctrl->p_stats->qp0_mads_rcvd_unknown);
- OSM_LOG(p_ctrl->p_log, OSM_LOG_ERROR, "ERR 3109: "
- "Unsupported attribute = 0x%X\n",
- cl_ntoh16(p_smp->attr_id));
- osm_dump_dr_smp(p_ctrl->p_log, p_smp, OSM_LOG_ERROR);
- break;
- }
-
- if (msg_id == CL_DISP_MSGID_NONE) {
- /*
- There is an unknown MAD attribute type for which there is
- no recipient. Simply retire the MAD here.
- */
- osm_mad_pool_put(p_ctrl->p_mad_pool, p_madw);
- goto Exit;
- }
-
- /*
- Post this MAD to the dispatcher for asynchronous
- processing by the appropriate controller.
- */
-
- OSM_LOG(p_ctrl->p_log, OSM_LOG_DEBUG, "Posting Dispatcher message %s\n",
- osm_get_disp_msg_str(msg_id));
-
- status = cl_disp_post(p_ctrl->h_disp, msg_id, p_madw,
- __osm_sm_mad_ctrl_disp_done_callback, p_ctrl);
-
- if (status != CL_SUCCESS) {
- OSM_LOG(p_ctrl->p_log, OSM_LOG_ERROR, "ERR 3110: "
- "Dispatcher post message failed (%s)\n",
- CL_STATUS_MSG(status));
- goto Exit;
- }
-
-Exit:
- OSM_LOG_EXIT(p_ctrl->p_log);
-}
-
-/*
- * PARAMETERS
- *
- * RETURN VALUES
- *
- * NOTES
- *
- * SEE ALSO
- *********/
-
-/****f* opensm: SM/__osm_sm_mad_ctrl_rcv_callback
- * NAME
- * __osm_sm_mad_ctrl_rcv_callback
- *
- * DESCRIPTION
- * This is the callback from the transport layer for received MADs.
- *
- * SYNOPSIS
- */
-static void
-__osm_sm_mad_ctrl_rcv_callback(IN osm_madw_t * p_madw,
- IN void *bind_context,
- IN osm_madw_t * p_req_madw)
-{
- osm_sm_mad_ctrl_t *p_ctrl = (osm_sm_mad_ctrl_t *) bind_context;
- ib_smp_t *p_smp;
- ib_net16_t status;
-
- OSM_LOG_ENTER(p_ctrl->p_log);
-
- CL_ASSERT(p_madw);
-
- /*
- A MAD was received from the wire, possibly in response to a request.
- */
- cl_atomic_inc(&p_ctrl->p_stats->qp0_mads_rcvd);
-
- OSM_LOG(p_ctrl->p_log, OSM_LOG_DEBUG, "%u QP0 MADs received\n",
- p_ctrl->p_stats->qp0_mads_rcvd);
-
- p_smp = osm_madw_get_smp_ptr(p_madw);
-
- /* if we are closing down simply do nothing */
- if (osm_exit_flag) {
- OSM_LOG(p_ctrl->p_log, OSM_LOG_ERROR,
- "Ignoring received mad - since we are exiting\n");
-
- osm_dump_dr_smp(p_ctrl->p_log, p_smp, OSM_LOG_DEBUG);
-
- /* retire the mad or put it back */
- if (ib_smp_is_response(p_smp) ||
- (p_smp->method == IB_MAD_METHOD_TRAP_REPRESS)) {
- CL_ASSERT(p_madw->resp_expected == FALSE);
- __osm_sm_mad_ctrl_retire_trans_mad(p_ctrl, p_madw);
- } else if (p_madw->resp_expected == TRUE)
- __osm_sm_mad_ctrl_retire_trans_mad(p_ctrl, p_madw);
- else
- osm_mad_pool_put(p_ctrl->p_mad_pool, p_madw);
-
- goto Exit;
- }
-
- if (osm_log_is_active(p_ctrl->p_log, OSM_LOG_FRAMES))
- osm_dump_dr_smp(p_ctrl->p_log, p_smp, OSM_LOG_FRAMES);
-
- if (p_smp->mgmt_class == IB_MCLASS_SUBN_DIR)
- status = ib_smp_get_status(p_smp);
- else
- status = p_smp->status;
-
- if (status != 0) {
- OSM_LOG(p_ctrl->p_log, OSM_LOG_ERROR, "ERR 3111: "
- "Error status = 0x%X\n", status);
- osm_dump_dr_smp(p_ctrl->p_log, p_smp, OSM_LOG_ERROR);
- }
-
- switch (p_smp->method) {
- case IB_MAD_METHOD_GET_RESP:
- CL_ASSERT(p_req_madw != NULL);
- __osm_sm_mad_ctrl_process_get_resp(p_ctrl, p_madw, p_req_madw);
- break;
-
- case IB_MAD_METHOD_GET:
- CL_ASSERT(p_req_madw == NULL);
- __osm_sm_mad_ctrl_process_get(p_ctrl, p_madw);
- break;
-
- case IB_MAD_METHOD_TRAP:
- CL_ASSERT(p_req_madw == NULL);
- __osm_sm_mad_ctrl_process_trap(p_ctrl, p_madw);
- break;
-
- case IB_MAD_METHOD_SET:
- CL_ASSERT(p_req_madw == NULL);
- __osm_sm_mad_ctrl_process_set(p_ctrl, p_madw);
- break;
-
- case IB_MAD_METHOD_SEND:
- case IB_MAD_METHOD_REPORT:
- case IB_MAD_METHOD_REPORT_RESP:
- case IB_MAD_METHOD_TRAP_REPRESS:
- default:
- cl_atomic_inc(&p_ctrl->p_stats->qp0_mads_rcvd_unknown);
- OSM_LOG(p_ctrl->p_log, OSM_LOG_ERROR, "ERR 3112: "
- "Unsupported method = 0x%X\n", p_smp->method);
- osm_dump_dr_smp(p_ctrl->p_log, p_smp, OSM_LOG_ERROR);
- osm_mad_pool_put(p_ctrl->p_mad_pool, p_madw);
- goto Exit;
- }
-
-Exit:
- OSM_LOG_EXIT(p_ctrl->p_log);
-}
-
-/*
- * PARAMETERS
- *
- * RETURN VALUES
- *
- * NOTES
- *
- * SEE ALSO
- *********/
-
-/****f* opensm: SM/__osm_sm_mad_ctrl_send_err_cb
- * NAME
- * __osm_sm_mad_ctrl_send_err_cb
- *
- * DESCRIPTION
- * This is the callback from the transport layer for send errors
- * on MADs that were expecting a response.
- *
- * SYNOPSIS
- */
-static void
-__osm_sm_mad_ctrl_send_err_cb(IN void *bind_context, IN osm_madw_t * p_madw)
-{
- osm_sm_mad_ctrl_t *p_ctrl = (osm_sm_mad_ctrl_t *) bind_context;
- ib_api_status_t status;
- ib_smp_t *p_smp;
-
- OSM_LOG_ENTER(p_ctrl->p_log);
-
- CL_ASSERT(p_madw);
-
- OSM_LOG(p_ctrl->p_log, OSM_LOG_ERROR, "ERR 3113: "
- "MAD completed in error (%s)\n",
- ib_get_err_str(p_madw->status));
-
- /*
- If this was a SubnSet MAD, then this error might indicate a problem
- in configuring the subnet. In this case - need to mark that there was
- such a problem. The subnet will not be up, and the next sweep should
- be a heavy sweep as well.
- */
- p_smp = osm_madw_get_smp_ptr(p_madw);
- if (p_smp->method == IB_MAD_METHOD_SET &&
- (p_smp->attr_id == IB_MAD_ATTR_PORT_INFO ||
- p_smp->attr_id == IB_MAD_ATTR_MCAST_FWD_TBL ||
- p_smp->attr_id == IB_MAD_ATTR_SWITCH_INFO ||
- p_smp->attr_id == IB_MAD_ATTR_LIN_FWD_TBL)) {
- OSM_LOG(p_ctrl->p_log, OSM_LOG_ERROR, "ERR 3119: "
- "Set method failed\n");
- p_ctrl->p_subn->subnet_initialization_error = TRUE;
- }
-
- /*
- Since we did not get any response we suspect the DR path
- used for the target port.
- Find it and replace it with an alternate path.
- This is true only if the destination lid is not 0xFFFF, since
- then we are aiming for a specific path and not specific destination
- lid.
- */
- /* For now - do not add the alternate dr path to the release */
-#if 0
- if (p_madw->mad_addr.dest_lid != 0xFFFF) {
- osm_physp_t *p_physp =
- osm_get_physp_by_mad_addr(p_ctrl->p_log,
- p_ctrl->p_subn,
- &(p_madw->mad_addr));
- if (!p_physp) {
- OSM_LOG(p_ctrl->p_log, OSM_LOG_ERROR, "ERR 3114: "
- "Failed to find the corresponding phys port\n");
- } else {
- osm_physp_replace_dr_path_with_alternate_dr_path
- (p_ctrl->p_log, p_ctrl->p_subn, p_physp,
- p_madw->h_bind);
- }
- }
-#endif
-
- /*
- An error occurred. No response was received to a request MAD.
- Retire the original request MAD.
- */
-
- osm_dump_dr_smp(p_ctrl->p_log, osm_madw_get_smp_ptr(p_madw),
- OSM_LOG_ERROR);
-
- __osm_sm_mad_ctrl_update_wire_stats(p_ctrl);
-
- if (osm_madw_get_err_msg(p_madw) != CL_DISP_MSGID_NONE) {
- OSM_LOG(p_ctrl->p_log, OSM_LOG_DEBUG,
- "Posting Dispatcher message %s\n",
- osm_get_disp_msg_str(osm_madw_get_err_msg(p_madw)));
-
- status = cl_disp_post(p_ctrl->h_disp,
- osm_madw_get_err_msg(p_madw),
- p_madw,
- __osm_sm_mad_ctrl_disp_done_callback,
- p_ctrl);
- if (status != CL_SUCCESS)
- OSM_LOG(p_ctrl->p_log, OSM_LOG_ERROR, "ERR 3115: "
- "Dispatcher post message failed (%s)\n",
- CL_STATUS_MSG(status));
- } else
- /*
- No error message was provided, just retire the MAD.
- */
- __osm_sm_mad_ctrl_retire_trans_mad(p_ctrl, p_madw);
-
- OSM_LOG_EXIT(p_ctrl->p_log);
-}
-
-/*
- * PARAMETERS
- *
- * RETURN VALUES
- *
- * NOTES
- *
- * SEE ALSO
- *********/
-
-/**********************************************************************
- **********************************************************************/
-void osm_sm_mad_ctrl_construct(IN osm_sm_mad_ctrl_t * const p_ctrl)
-{
- CL_ASSERT(p_ctrl);
- memset(p_ctrl, 0, sizeof(*p_ctrl));
- p_ctrl->h_disp = CL_DISP_INVALID_HANDLE;
-}
-
-/**********************************************************************
- **********************************************************************/
-void osm_sm_mad_ctrl_destroy(IN osm_sm_mad_ctrl_t * const p_ctrl)
-{
- CL_ASSERT(p_ctrl);
-
- if (p_ctrl->h_bind != CL_DISP_INVALID_HANDLE)
- osm_vendor_unbind(p_ctrl->h_bind);
- cl_disp_unregister(p_ctrl->h_disp);
-}
-
-/**********************************************************************
- **********************************************************************/
-ib_api_status_t
-osm_sm_mad_ctrl_init(IN osm_sm_mad_ctrl_t * const p_ctrl,
- IN osm_subn_t * const p_subn,
- IN osm_mad_pool_t * const p_mad_pool,
- IN osm_vl15_t * const p_vl15,
- IN osm_vendor_t * const p_vendor,
- IN osm_log_t * const p_log,
- IN osm_stats_t * const p_stats,
- IN cl_plock_t * const p_lock,
- IN cl_dispatcher_t * const p_disp)
-{
- ib_api_status_t status = IB_SUCCESS;
-
- OSM_LOG_ENTER(p_log);
-
- osm_sm_mad_ctrl_construct(p_ctrl);
-
- p_ctrl->p_subn = p_subn;
- p_ctrl->p_log = p_log;
- p_ctrl->p_disp = p_disp;
- p_ctrl->p_mad_pool = p_mad_pool;
- p_ctrl->p_vendor = p_vendor;
- p_ctrl->p_stats = p_stats;
- p_ctrl->p_lock = p_lock;
- p_ctrl->p_vl15 = p_vl15;
-
- p_ctrl->h_disp = cl_disp_register(p_disp,
- CL_DISP_MSGID_NONE, NULL, NULL);
-
- if (p_ctrl->h_disp == CL_DISP_INVALID_HANDLE) {
- OSM_LOG(p_log, OSM_LOG_ERROR, "ERR 3116: "
- "Dispatcher registration failed\n");
- status = IB_INSUFFICIENT_RESOURCES;
- goto Exit;
- }
-
-Exit:
- OSM_LOG_EXIT(p_log);
- return (status);
-}
-
-/**********************************************************************
- **********************************************************************/
-ib_api_status_t
-osm_sm_mad_ctrl_bind(IN osm_sm_mad_ctrl_t * const p_ctrl,
- IN const ib_net64_t port_guid)
-{
- osm_bind_info_t bind_info;
- ib_api_status_t status = IB_SUCCESS;
-
- OSM_LOG_ENTER(p_ctrl->p_log);
-
- if (p_ctrl->h_bind != OSM_BIND_INVALID_HANDLE) {
- OSM_LOG(p_ctrl->p_log, OSM_LOG_ERROR, "ERR 3117: "
- "Multiple binds not allowed\n");
- status = IB_ERROR;
- goto Exit;
- }
-
- bind_info.class_version = 1;
- bind_info.is_report_processor = FALSE;
- bind_info.is_responder = TRUE;
- bind_info.is_trap_processor = TRUE;
- bind_info.mad_class = IB_MCLASS_SUBN_DIR;
- bind_info.port_guid = port_guid;
- bind_info.recv_q_size = OSM_SM_DEFAULT_QP0_RCV_SIZE;
- bind_info.send_q_size = OSM_SM_DEFAULT_QP0_SEND_SIZE;
-
- OSM_LOG(p_ctrl->p_log, OSM_LOG_VERBOSE,
- "Binding to port 0x%" PRIx64 "\n", cl_ntoh64(port_guid));
-
- p_ctrl->h_bind = osm_vendor_bind(p_ctrl->p_vendor,
- &bind_info,
- p_ctrl->p_mad_pool,
- __osm_sm_mad_ctrl_rcv_callback,
- __osm_sm_mad_ctrl_send_err_cb, p_ctrl);
-
- if (p_ctrl->h_bind == OSM_BIND_INVALID_HANDLE) {
- status = IB_ERROR;
- OSM_LOG(p_ctrl->p_log, OSM_LOG_ERROR, "ERR 3118: "
- "Vendor specific bind failed\n");
- goto Exit;
- }
-
-Exit:
- OSM_LOG_EXIT(p_ctrl->p_log);
- return (status);
-}
diff --git a/contrib/ofed/management/opensm/opensm/osm_sm_state_mgr.c b/contrib/ofed/management/opensm/opensm/osm_sm_state_mgr.c
deleted file mode 100644
index 343a9e3..0000000
--- a/contrib/ofed/management/opensm/opensm/osm_sm_state_mgr.c
+++ /dev/null
@@ -1,551 +0,0 @@
-/*
- * Copyright (c) 2004-2008 Voltaire, Inc. All rights reserved.
- * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved.
- * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- */
-
-/*
- * Abstract:
- * Implementation of osm_sm_state_mgr_t.
- * This file implements the SM State Manager object.
- */
-
-#if HAVE_CONFIG_H
-# include <config.h>
-#endif /* HAVE_CONFIG_H */
-
-#include <string.h>
-#include <time.h>
-#include <iba/ib_types.h>
-#include <complib/cl_passivelock.h>
-#include <complib/cl_debug.h>
-#include <opensm/osm_sm.h>
-#include <opensm/osm_madw.h>
-#include <opensm/osm_switch.h>
-#include <opensm/osm_log.h>
-#include <opensm/osm_subnet.h>
-#include <opensm/osm_helper.h>
-#include <opensm/osm_msgdef.h>
-#include <opensm/osm_node.h>
-#include <opensm/osm_port.h>
-#include <vendor/osm_vendor_api.h>
-#include <opensm/osm_helper.h>
-#include <opensm/osm_opensm.h>
-
-/**********************************************************************
- **********************************************************************/
-void osm_report_sm_state(osm_sm_t * sm)
-{
- char buf[64];
- const char *state_str = osm_get_sm_mgr_state_str(sm->p_subn->sm_state);
-
- osm_log(sm->p_log, OSM_LOG_SYS, "Entering %s state\n", state_str);
- snprintf(buf, sizeof(buf), "ENTERING SM %s STATE", state_str);
- OSM_LOG_MSG_BOX(sm->p_log, OSM_LOG_VERBOSE, buf);
-}
-
-/**********************************************************************
- **********************************************************************/
-static void __osm_sm_state_mgr_send_master_sm_info_req(osm_sm_t * sm)
-{
- osm_madw_context_t context;
- const osm_port_t *p_port;
- ib_api_status_t status;
-
- OSM_LOG_ENTER(sm->p_log);
-
- memset(&context, 0, sizeof(context));
- if (sm->p_subn->sm_state == IB_SMINFO_STATE_STANDBY) {
- /*
- * We are in STANDBY state - this means we need to poll on the master
- * SM (according to master_guid)
- * Send a query of SubnGet(SMInfo) to the subn master_sm_base_lid object.
- */
- p_port = osm_get_port_by_guid(sm->p_subn, sm->master_sm_guid);
- } else {
- /*
- * We are not in STANDBY - this means we are in MASTER state - so we need
- * to poll on the SM that is saved in p_polling_sm under sm.
- * Send a query of SubnGet(SMInfo) to that SM.
- */
- p_port = sm->p_polling_sm->p_port;
- }
- if (p_port == NULL) {
- OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR 3203: "
- "No port object for GUID 0x%016" PRIx64 "\n",
- cl_ntoh64(sm->master_sm_guid));
- goto Exit;
- }
-
- context.smi_context.port_guid = p_port->guid;
- context.smi_context.set_method = FALSE;
-
- status = osm_req_get(sm, osm_physp_get_dr_path_ptr(p_port->p_physp),
- IB_MAD_ATTR_SM_INFO, 0, CL_DISP_MSGID_NONE,
- &context);
-
- if (status != IB_SUCCESS)
- OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR 3204: "
- "Failure requesting SMInfo (%s)\n",
- ib_get_err_str(status));
-
-Exit:
- OSM_LOG_EXIT(sm->p_log);
-}
-
-/**********************************************************************
- **********************************************************************/
-static void __osm_sm_state_mgr_start_polling(osm_sm_t * sm)
-{
- uint32_t timeout = sm->p_subn->opt.sminfo_polling_timeout;
- cl_status_t cl_status;
-
- OSM_LOG_ENTER(sm->p_log);
-
- /*
- * Init the retry_number back to zero - need to restart counting
- */
- sm->retry_number = 0;
-
- /*
- * Send a SubnGet(SMInfo) query to the current (or new) master found.
- */
- __osm_sm_state_mgr_send_master_sm_info_req(sm);
-
- /*
- * Start a timer that will wake up every sminfo_polling_timeout milliseconds.
- * The callback of the timer will send a SubnGet(SMInfo) to the Master SM
- * and restart the timer
- */
- cl_status = cl_timer_start(&sm->polling_timer, timeout);
- if (cl_status != CL_SUCCESS)
- OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR 3210: "
- "Failed to start timer\n");
-
- OSM_LOG_EXIT(sm->p_log);
-}
-
-/**********************************************************************
- **********************************************************************/
-void osm_sm_state_mgr_polling_callback(IN void *context)
-{
- osm_sm_t *sm = context;
- uint32_t timeout = sm->p_subn->opt.sminfo_polling_timeout;
- cl_status_t cl_status;
-
- OSM_LOG_ENTER(sm->p_log);
-
- /*
- * We can be here in one of two cases:
- * 1. We are a STANDBY sm polling on the master SM.
- * 2. We are a MASTER sm, waiting for a handover from a remote master sm.
- * If we are not in one of these cases - don't need to restart the poller.
- */
- if (!((sm->p_subn->sm_state == IB_SMINFO_STATE_MASTER &&
- sm->p_polling_sm != NULL) ||
- (sm->p_subn->sm_state == IB_SMINFO_STATE_STANDBY)))
- goto Exit;
-
- /*
- * If we are a STANDBY sm and the osm_exit_flag is set, then let's
- * signal the subnet_up. This is relevant for the case of running only
- * once. In that case - the program is stuck until this signal is
- * received. In other cases - it is not relevant whether or not the
- * signal is on - since we are currently in exit flow
- */
- if (sm->p_subn->sm_state == IB_SMINFO_STATE_STANDBY && osm_exit_flag) {
- OSM_LOG(sm->p_log, OSM_LOG_VERBOSE,
- "Signalling subnet_up_event\n");
- cl_event_signal(&sm->subnet_up_event);
- goto Exit;
- }
-
- /*
- * Incr the retry number.
- * If it reached the max_retry_number in the subnet opt - call
- * osm_sm_state_mgr_process with signal OSM_SM_SIGNAL_POLLING_TIMEOUT
- */
- sm->retry_number++;
- OSM_LOG(sm->p_log, OSM_LOG_VERBOSE,
- "Retry number:%d\n", sm->retry_number);
-
- if (sm->retry_number >= sm->p_subn->opt.polling_retry_number) {
- OSM_LOG(sm->p_log, OSM_LOG_DEBUG,
- "Reached polling_retry_number value in retry_number. "
- "Go to DISCOVERY state\n");
- osm_sm_state_mgr_process(sm, OSM_SM_SIGNAL_POLLING_TIMEOUT);
- goto Exit;
- }
-
- /* Send a SubnGet(SMInfo) request to the remote sm (depends on our state) */
- __osm_sm_state_mgr_send_master_sm_info_req(sm);
-
- /* restart the timer */
- cl_status = cl_timer_start(&sm->polling_timer, timeout);
- if (cl_status != CL_SUCCESS)
- OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR 3211: "
- "Failed to restart timer\n");
-
-Exit:
- OSM_LOG_EXIT(sm->p_log);
- return;
-}
-
-/**********************************************************************
- **********************************************************************/
-static void __osm_sm_state_mgr_signal_error(osm_sm_t * sm,
- IN const osm_sm_signal_t signal)
-{
- OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR 3207: "
- "Invalid signal %s in state %s\n",
- osm_get_sm_mgr_signal_str(signal),
- osm_get_sm_mgr_state_str(sm->p_subn->sm_state));
-}
-
-/**********************************************************************
- **********************************************************************/
-void osm_sm_state_mgr_signal_master_is_alive(osm_sm_t * sm)
-{
- OSM_LOG_ENTER(sm->p_log);
- sm->retry_number = 0;
- OSM_LOG_EXIT(sm->p_log);
-}
-
-/**********************************************************************
- **********************************************************************/
-ib_api_status_t osm_sm_state_mgr_process(osm_sm_t * sm,
- IN osm_sm_signal_t signal)
-{
- ib_api_status_t status = IB_SUCCESS;
-
- CL_ASSERT(sm);
-
- OSM_LOG_ENTER(sm->p_log);
-
- /*
- * The state lock prevents many race conditions from screwing
- * up the state transition process.
- */
- cl_spinlock_acquire(&sm->state_lock);
-
- OSM_LOG(sm->p_log, OSM_LOG_DEBUG,
- "Received signal %s in state %s\n",
- osm_get_sm_mgr_signal_str(signal),
- osm_get_sm_mgr_state_str(sm->p_subn->sm_state));
-
- switch (sm->p_subn->sm_state) {
- case IB_SMINFO_STATE_DISCOVERING:
- switch (signal) {
- case OSM_SM_SIGNAL_DISCOVERY_COMPLETED:
- /*
- * Update the state of the SM to MASTER
- */
- /* Turn on the first_time_master_sweep flag */
- sm->p_subn->first_time_master_sweep = TRUE;
- sm->p_subn->sm_state = IB_SMINFO_STATE_MASTER;
- osm_report_sm_state(sm);
- /*
- * Make sure to set the subnet master_sm_base_lid
- * to the sm_base_lid value
- */
- sm->p_subn->master_sm_base_lid =
- sm->p_subn->sm_base_lid;
- break;
- case OSM_SM_SIGNAL_MASTER_OR_HIGHER_SM_DETECTED:
- /*
- * Finished all discovery actions - move to STANDBY
- * start the polling
- */
- sm->p_subn->sm_state = IB_SMINFO_STATE_STANDBY;
- osm_report_sm_state(sm);
- /*
- * Since another SM is doing the LFT config - we should not
- * ignore the results of it
- */
- sm->p_subn->ignore_existing_lfts = FALSE;
-
- __osm_sm_state_mgr_start_polling(sm);
- break;
- case OSM_SM_SIGNAL_HANDOVER:
- /*
- * Do nothing. We will discover it later on. If we already discovered
- * this SM, and got the HANDOVER - this means the remote SM is of
- * lower priority. In this case we will stop polling it (since it is
- * a lower priority SM in STANDBY state).
- */
- break;
- default:
- __osm_sm_state_mgr_signal_error(sm, signal);
- status = IB_INVALID_PARAMETER;
- break;
- }
- break;
-
- case IB_SMINFO_STATE_STANDBY:
- switch (signal) {
- case OSM_SM_SIGNAL_POLLING_TIMEOUT:
- case OSM_SM_SIGNAL_DISCOVER:
- /*
- * case 1: Polling timeout occured - this means that the Master SM
- * is no longer alive.
- * case 2: Got a signal to move to DISCOVERING
- * Move to DISCOVERING state and start sweeping
- */
- sm->p_subn->sm_state = IB_SMINFO_STATE_DISCOVERING;
- osm_report_sm_state(sm);
- sm->p_subn->coming_out_of_standby = TRUE;
- osm_sm_signal(sm, OSM_SIGNAL_SWEEP);
- break;
- case OSM_SM_SIGNAL_DISABLE:
- /*
- * Update the state to NOT_ACTIVE
- */
- sm->p_subn->sm_state = IB_SMINFO_STATE_NOTACTIVE;
- osm_report_sm_state(sm);
- osm_vendor_set_sm(sm->mad_ctrl.h_bind, FALSE);
- break;
- case OSM_SM_SIGNAL_HANDOVER:
- /*
- * Update the state to MASTER, and start sweeping
- * OPTIONAL: send ACKNOWLEDGE
- */
- /* Turn on the first_time_master_sweep flag */
- sm->p_subn->first_time_master_sweep = TRUE;
- /* Turn on the force_heavy_sweep - we want a
- * heavy sweep to occur on the first sweep of this SM. */
- sm->p_subn->force_heavy_sweep = TRUE;
-
- sm->p_subn->sm_state = IB_SMINFO_STATE_MASTER;
- osm_report_sm_state(sm);
- /*
- * Make sure to set the subnet master_sm_base_lid
- * to the sm_base_lid value
- */
- sm->p_subn->master_sm_base_lid =
- sm->p_subn->sm_base_lid;
- sm->p_subn->coming_out_of_standby = TRUE;
- osm_sm_signal(sm, OSM_SIGNAL_SWEEP);
- break;
- case OSM_SM_SIGNAL_ACKNOWLEDGE:
- /*
- * Do nothing - already moved to STANDBY
- */
- break;
- default:
- __osm_sm_state_mgr_signal_error(sm, signal);
- status = IB_INVALID_PARAMETER;
- break;
- }
- break;
-
- case IB_SMINFO_STATE_NOTACTIVE:
- switch (signal) {
- case OSM_SM_SIGNAL_STANDBY:
- /*
- * Update the state to STANDBY
- * start the polling
- */
- sm->p_subn->sm_state = IB_SMINFO_STATE_STANDBY;
- osm_report_sm_state(sm);
- __osm_sm_state_mgr_start_polling(sm);
- break;
- default:
- __osm_sm_state_mgr_signal_error(sm, signal);
- status = IB_INVALID_PARAMETER;
- break;
- }
- break;
-
- case IB_SMINFO_STATE_MASTER:
- switch (signal) {
- case OSM_SM_SIGNAL_POLLING_TIMEOUT:
- /*
- * we received a polling timeout - this means that we waited for
- * a remote master sm to send us a handover, but didn't get it, and
- * didn't get a response from that remote sm.
- * We want to force a heavy sweep - hopefully this occurred because
- * the remote sm died, and we'll find this out and configure the
- * subnet after a heavy sweep.
- * We also want to clear the p_polling_sm object - since we are
- * done polling on that remote sm - we are sweeping again.
- */
- case OSM_SM_SIGNAL_HANDOVER:
- /*
- * If we received a handover in a master state - then we want to
- * force a heavy sweep. This means that either we are in a sweep
- * currently - in this case - no change, or we are in idle state -
- * since we recognized a master SM before - so we want to make a
- * heavy sweep and reconfigure the new subnet.
- * We also want to clear the p_polling_sm object - since we are
- * done polling on that remote sm - we got a handover from it.
- */
- OSM_LOG(sm->p_log, OSM_LOG_VERBOSE,
- "Forcing heavy sweep. "
- "Received OSM_SM_SIGNAL_HANDOVER or OSM_SM_SIGNAL_POLLING_TIMEOUT\n");
- sm->p_polling_sm = NULL;
- sm->p_subn->force_heavy_sweep = TRUE;
- osm_sm_signal(sm, OSM_SIGNAL_SWEEP);
- break;
- case OSM_SM_SIGNAL_HANDOVER_SENT:
- /*
- * Just sent a HANDOVER signal - move to STANDBY
- * start the polling
- */
- sm->p_subn->sm_state = IB_SMINFO_STATE_STANDBY;
- osm_report_sm_state(sm);
- __osm_sm_state_mgr_start_polling(sm);
- break;
- case OSM_SM_SIGNAL_WAIT_FOR_HANDOVER:
- /*
- * We found a remote master SM, and we are waiting for it
- * to handover the mastership to us. Need to start polling
- * on that SM, to make sure it is alive, if it isn't - then
- * we should move back to discovering, since something must
- * have happened to it.
- */
- __osm_sm_state_mgr_start_polling(sm);
- break;
- case OSM_SM_SIGNAL_DISCOVER:
- sm->p_subn->sm_state = IB_SMINFO_STATE_DISCOVERING;
- osm_report_sm_state(sm);
- break;
- default:
- __osm_sm_state_mgr_signal_error(sm, signal);
- status = IB_INVALID_PARAMETER;
- break;
- }
- break;
-
- default:
- OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR 3208: "
- "Invalid state %s\n",
- osm_get_sm_mgr_state_str(sm->p_subn->sm_state));
-
- }
-
- cl_spinlock_release(&sm->state_lock);
-
- OSM_LOG_EXIT(sm->p_log);
- return (status);
-}
-
-/**********************************************************************
- **********************************************************************/
-ib_api_status_t osm_sm_state_mgr_check_legality(osm_sm_t * sm,
- IN osm_sm_signal_t signal)
-{
- ib_api_status_t status = IB_SUCCESS;
-
- CL_ASSERT(sm);
-
- OSM_LOG_ENTER(sm->p_log);
-
- /*
- * The state lock prevents many race conditions from screwing
- * up the state transition process.
- */
- cl_spinlock_acquire(&sm->state_lock);
-
- OSM_LOG(sm->p_log, OSM_LOG_DEBUG,
- "Received signal %s in state %s\n",
- osm_get_sm_mgr_signal_str(signal),
- osm_get_sm_mgr_state_str(sm->p_subn->sm_state));
-
- switch (sm->p_subn->sm_state) {
- case IB_SMINFO_STATE_DISCOVERING:
- switch (signal) {
- case OSM_SM_SIGNAL_DISCOVERY_COMPLETED:
- case OSM_SM_SIGNAL_MASTER_OR_HIGHER_SM_DETECTED:
- case OSM_SM_SIGNAL_HANDOVER:
- status = IB_SUCCESS;
- break;
- default:
- __osm_sm_state_mgr_signal_error(sm, signal);
- status = IB_INVALID_PARAMETER;
- break;
- }
- break;
-
- case IB_SMINFO_STATE_STANDBY:
- switch (signal) {
- case OSM_SM_SIGNAL_POLLING_TIMEOUT:
- case OSM_SM_SIGNAL_DISCOVER:
- case OSM_SM_SIGNAL_DISABLE:
- case OSM_SM_SIGNAL_HANDOVER:
- case OSM_SM_SIGNAL_ACKNOWLEDGE:
- status = IB_SUCCESS;
- break;
- default:
- __osm_sm_state_mgr_signal_error(sm, signal);
- status = IB_INVALID_PARAMETER;
- break;
- }
- break;
-
- case IB_SMINFO_STATE_NOTACTIVE:
- switch (signal) {
- case OSM_SM_SIGNAL_STANDBY:
- status = IB_SUCCESS;
- break;
- default:
- __osm_sm_state_mgr_signal_error(sm, signal);
- status = IB_INVALID_PARAMETER;
- break;
- }
- break;
-
- case IB_SMINFO_STATE_MASTER:
- switch (signal) {
- case OSM_SM_SIGNAL_HANDOVER:
- case OSM_SM_SIGNAL_HANDOVER_SENT:
- status = IB_SUCCESS;
- break;
- default:
- __osm_sm_state_mgr_signal_error(sm, signal);
- status = IB_INVALID_PARAMETER;
- break;
- }
- break;
-
- default:
- OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR 3209: "
- "Invalid state %s\n",
- osm_get_sm_mgr_state_str(sm->p_subn->sm_state));
- status = IB_INVALID_PARAMETER;
-
- }
-
- cl_spinlock_release(&sm->state_lock);
-
- OSM_LOG_EXIT(sm->p_log);
- return (status);
-}
diff --git a/contrib/ofed/management/opensm/opensm/osm_sminfo_rcv.c b/contrib/ofed/management/opensm/opensm/osm_sminfo_rcv.c
deleted file mode 100644
index 98c1994..0000000
--- a/contrib/ofed/management/opensm/opensm/osm_sminfo_rcv.c
+++ /dev/null
@@ -1,604 +0,0 @@
-/*
- * Copyright (c) 2004-2008 Voltaire, Inc. All rights reserved.
- * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved.
- * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- */
-
-/*
- * Abstract:
- * Implementation of osm_sminfo_rcv_t.
- * This object represents the SMInfo Receiver object.
- * This object is part of the opensm family of objects.
- */
-
-#if HAVE_CONFIG_H
-# include <config.h>
-#endif /* HAVE_CONFIG_H */
-
-#include <stdlib.h>
-#include <string.h>
-#include <iba/ib_types.h>
-#include <complib/cl_qmap.h>
-#include <complib/cl_passivelock.h>
-#include <complib/cl_debug.h>
-#include <opensm/osm_madw.h>
-#include <opensm/osm_log.h>
-#include <opensm/osm_node.h>
-#include <opensm/osm_helper.h>
-#include <opensm/osm_subnet.h>
-#include <opensm/osm_sm.h>
-#include <opensm/osm_opensm.h>
-
-/**********************************************************************
- Return TRUE if the remote sm given (by ib_sm_info_t) is higher,
- return FALSE otherwise.
- By higher - we mean: SM with higher priority or with same priority
- and lower GUID.
-**********************************************************************/
-static inline boolean_t
-__osm_sminfo_rcv_remote_sm_is_higher(IN osm_sm_t * sm,
- IN const ib_sm_info_t * p_remote_smi)
-{
- return (osm_sm_is_greater_than(ib_sminfo_get_priority(p_remote_smi),
- p_remote_smi->guid,
- sm->p_subn->opt.sm_priority,
- sm->p_subn->sm_port_guid));
-
-}
-
-/**********************************************************************
- **********************************************************************/
-static void
-__osm_sminfo_rcv_process_get_request(IN osm_sm_t * sm,
- IN const osm_madw_t * const p_madw)
-{
- uint8_t payload[IB_SMP_DATA_SIZE];
- ib_smp_t *p_smp;
- ib_sm_info_t *p_smi = (ib_sm_info_t *) payload;
- ib_api_status_t status;
- ib_sm_info_t *p_remote_smi;
-
- OSM_LOG_ENTER(sm->p_log);
-
- CL_ASSERT(p_madw);
-
- /* No real need to grab the lock for this function. */
- memset(payload, 0, sizeof(payload));
-
- p_smp = osm_madw_get_smp_ptr(p_madw);
-
- CL_ASSERT(p_smp->method == IB_MAD_METHOD_GET);
-
- p_smi->guid = sm->p_subn->sm_port_guid;
- p_smi->act_count = cl_hton32(sm->p_subn->p_osm->stats.qp0_mads_sent);
- p_smi->pri_state = (uint8_t) (sm->p_subn->sm_state |
- sm->p_subn->opt.sm_priority << 4);
- /*
- p.840 line 20 - Return 0 for the SM key unless we authenticate the
- requester as the master SM.
- */
- p_remote_smi = ib_smp_get_payload_ptr(osm_madw_get_smp_ptr(p_madw));
- if (ib_sminfo_get_state(p_remote_smi) == IB_SMINFO_STATE_MASTER) {
- OSM_LOG(sm->p_log, OSM_LOG_DEBUG,
- "Responding to master SM with real sm_key\n");
- p_smi->sm_key = sm->p_subn->opt.sm_key;
- } else {
- /* The requester is not authenticated as master - set sm_key to zero. */
- OSM_LOG(sm->p_log, OSM_LOG_DEBUG,
- "Responding to SM not master with zero sm_key\n");
- p_smi->sm_key = 0;
- }
-
- status = osm_resp_send(sm, p_madw, 0, payload);
- if (status != IB_SUCCESS) {
- OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR 2F02: "
- "Error sending response (%s)\n",
- ib_get_err_str(status));
- goto Exit;
- }
-
-Exit:
- OSM_LOG_EXIT(sm->p_log);
-}
-
-/**********************************************************************
- * Check if the p_smp received is legal.
- * Current checks:
- * MADHeader:AttributeModifier of ACKNOWLEDGE that was not sent by a
- * Standby SM.
- * MADHeader:AttributeModifiers of HANDOVER/DISABLE/STANDBY/DISCOVER
- * that was not sent by a Master SM.
- * FUTURE - TO DO:
- * Check that the SM_Key matches.
- **********************************************************************/
-static ib_api_status_t
-__osm_sminfo_rcv_check_set_req_legality(IN const ib_smp_t * const p_smp)
-{
- ib_sm_info_t *p_smi;
-
- p_smi = ib_smp_get_payload_ptr(p_smp);
-
- if (p_smp->attr_mod == IB_SMINFO_ATTR_MOD_ACKNOWLEDGE) {
- if (ib_sminfo_get_state(p_smi) == IB_SMINFO_STATE_STANDBY)
- return (IB_SUCCESS);
- } else if (p_smp->attr_mod == IB_SMINFO_ATTR_MOD_HANDOVER ||
- p_smp->attr_mod == IB_SMINFO_ATTR_MOD_DISABLE ||
- p_smp->attr_mod == IB_SMINFO_ATTR_MOD_STANDBY ||
- p_smp->attr_mod == IB_SMINFO_ATTR_MOD_DISCOVER) {
- if (ib_sminfo_get_state(p_smi) == IB_SMINFO_STATE_MASTER)
- return (IB_SUCCESS);
- }
-
- return (IB_INVALID_PARAMETER);
-}
-
-/**********************************************************************
- **********************************************************************/
-static void
-__osm_sminfo_rcv_process_set_request(IN osm_sm_t * sm,
- IN const osm_madw_t * const p_madw)
-{
- uint8_t payload[IB_SMP_DATA_SIZE];
- ib_smp_t *p_smp;
- ib_sm_info_t *p_smi = (ib_sm_info_t *) payload;
- ib_sm_info_t *sm_smi;
- ib_api_status_t status;
- osm_sm_signal_t sm_signal;
- ib_sm_info_t *p_remote_smi;
-
- OSM_LOG_ENTER(sm->p_log);
-
- CL_ASSERT(p_madw);
-
- memset(payload, 0, sizeof(payload));
-
- p_smp = osm_madw_get_smp_ptr(p_madw);
- sm_smi = ib_smp_get_payload_ptr(p_smp);
-
- if (p_smp->method != IB_MAD_METHOD_SET) {
- OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR 2F03: "
- "Unsupported method 0x%X\n", p_smp->method);
- goto Exit;
- }
-
- CL_PLOCK_EXCL_ACQUIRE(sm->p_lock);
-
- p_smi->guid = sm->p_subn->sm_port_guid;
- p_smi->act_count = cl_hton32(sm->p_subn->p_osm->stats.qp0_mads_sent);
- p_smi->pri_state = (uint8_t) (sm->p_subn->sm_state |
- sm->p_subn->opt.sm_priority << 4);
- /*
- p.840 line 20 - Return 0 for the SM key unless we authenticate the
- requester as the master SM.
- */
- p_remote_smi = ib_smp_get_payload_ptr(osm_madw_get_smp_ptr(p_madw));
- if (ib_sminfo_get_state(p_remote_smi) == IB_SMINFO_STATE_MASTER) {
- OSM_LOG(sm->p_log, OSM_LOG_DEBUG,
- "Responding to master SM with real sm_key\n");
- p_smi->sm_key = sm->p_subn->opt.sm_key;
- } else {
- /* The requester is not authenticated as master - set sm_key to zero. */
- OSM_LOG(sm->p_log, OSM_LOG_DEBUG,
- "Responding to SM not master with zero sm_key\n");
- p_smi->sm_key = 0;
- }
-
- /* Check the legality of the packet */
- status = __osm_sminfo_rcv_check_set_req_legality(p_smp);
- if (status != IB_SUCCESS) {
- OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR 2F04: "
- "Check legality failed. AttributeModifier:0x%X RemoteState:%s\n",
- p_smp->attr_mod,
- osm_get_sm_mgr_state_str(ib_sminfo_get_state(sm_smi)));
- status = osm_resp_send(sm, p_madw, 7, payload);
- if (status != IB_SUCCESS)
- OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR 2F05: "
- "Error sending response (%s)\n",
- ib_get_err_str(status));
- CL_PLOCK_RELEASE(sm->p_lock);
- goto Exit;
- }
-
- /* translate from IB_SMINFO_ATTR to OSM_SM_SIGNAL */
- switch (p_smp->attr_mod) {
- case IB_SMINFO_ATTR_MOD_HANDOVER:
- sm_signal = OSM_SM_SIGNAL_HANDOVER;
- break;
- case IB_SMINFO_ATTR_MOD_ACKNOWLEDGE:
- sm_signal = OSM_SM_SIGNAL_ACKNOWLEDGE;
- break;
- case IB_SMINFO_ATTR_MOD_DISABLE:
- sm_signal = OSM_SM_SIGNAL_DISABLE;
- break;
- case IB_SMINFO_ATTR_MOD_STANDBY:
- sm_signal = OSM_SM_SIGNAL_STANDBY;
- break;
- case IB_SMINFO_ATTR_MOD_DISCOVER:
- sm_signal = OSM_SM_SIGNAL_DISCOVER;
- break;
- default:
- /*
- This code shouldn't be reached - checked in the
- check legality
- */
- OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR 2F06: "
- "THIS CODE SHOULD NOT BE REACHED!!\n");
- CL_PLOCK_RELEASE(sm->p_lock);
- goto Exit;
- }
-
- /* check legality of the needed transition in the SM state machine */
- status = osm_sm_state_mgr_check_legality(sm, sm_signal);
- if (status != IB_SUCCESS) {
- OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR 2F07: "
- "Failed check of legality of needed SM transition. AttributeModifier:0x%X RemoteState:%s\n",
- p_smp->attr_mod,
- osm_get_sm_mgr_state_str(ib_sminfo_get_state(sm_smi)));
- status = osm_resp_send(sm, p_madw, 7, payload);
- if (status != IB_SUCCESS)
- OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR 2F08: "
- "Error sending response (%s)\n",
- ib_get_err_str(status));
- CL_PLOCK_RELEASE(sm->p_lock);
- goto Exit;
- }
-
- /* the SubnSet(SMInfo) command is ok. Send a response. */
- status = osm_resp_send(sm, p_madw, 0, payload);
- if (status != IB_SUCCESS)
- OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR 2F09: "
- "Error sending response (%s)\n",
- ib_get_err_str(status));
-
- /* it is a legal packet - act according to it */
-
- /* if the AttributeModifier is STANDBY - need to save on the sm in */
- /* the master_sm_guid variable - the guid of the current master. */
- if (p_smp->attr_mod == IB_SMINFO_ATTR_MOD_STANDBY) {
- OSM_LOG(sm->p_log, OSM_LOG_VERBOSE,
- "Received a STANDBY signal. Updating "
- "sm_state_mgr master_guid: 0x%016" PRIx64 "\n",
- cl_ntoh64(sm_smi->guid));
- sm->master_sm_guid = sm_smi->guid;
- }
-
- CL_PLOCK_RELEASE(sm->p_lock);
- status = osm_sm_state_mgr_process(sm, sm_signal);
-
- if (status != IB_SUCCESS)
- OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR 2F10: "
- "Error in SM state transition (%s)\n",
- ib_get_err_str(status));
-
-Exit:
- OSM_LOG_EXIT(sm->p_log);
-}
-
-/**********************************************************************
- **********************************************************************/
-static osm_signal_t
-__osm_sminfo_rcv_process_get_sm(IN osm_sm_t * sm,
- IN const osm_remote_sm_t * const p_sm,
- boolean_t light_sweep)
-{
- const ib_sm_info_t *p_smi;
-
- OSM_LOG_ENTER(sm->p_log);
-
- p_smi = &p_sm->smi;
-
- OSM_LOG(sm->p_log, OSM_LOG_VERBOSE,
- "Detected SM 0x%016" PRIx64 " in state %u\n",
- cl_ntoh64(p_smi->guid), ib_sminfo_get_state(p_smi));
-
- /* Check the state of this SM vs. our own. */
- switch (sm->p_subn->sm_state) {
- case IB_SMINFO_STATE_NOTACTIVE:
- break;
-
- case IB_SMINFO_STATE_DISCOVERING:
- switch (ib_sminfo_get_state(p_smi)) {
- case IB_SMINFO_STATE_NOTACTIVE:
- break;
- case IB_SMINFO_STATE_MASTER:
- sm->master_sm_found = 1;
- /* save on the sm the guid of the current master. */
- OSM_LOG(sm->p_log, OSM_LOG_VERBOSE,
- "Found master SM. Updating sm_state_mgr master_guid: 0x%016"
- PRIx64 "\n", cl_ntoh64(p_sm->p_port->guid));
- sm->master_sm_guid = p_sm->p_port->guid;
- break;
- case IB_SMINFO_STATE_DISCOVERING:
- case IB_SMINFO_STATE_STANDBY:
- if (__osm_sminfo_rcv_remote_sm_is_higher(sm, p_smi)
- == TRUE) {
- /* the remote is a higher sm - need to stop sweeping */
- sm->master_sm_found = 1;
- /* save on the sm the guid of the higher SM we found - */
- /* we will poll it - as long as it lives - we should be in Standby. */
- OSM_LOG(sm->p_log, OSM_LOG_VERBOSE,
- "Found higher SM. Updating sm_state_mgr master_guid:"
- " 0x%016" PRIx64 "\n",
- cl_ntoh64(p_sm->p_port->guid));
- sm->master_sm_guid = p_sm->p_port->guid;
- }
- break;
- default:
- break;
- }
- break;
-
- case IB_SMINFO_STATE_STANDBY:
- /* if the guid of the SM that sent us this response is equal to the */
- /* p_sm_mgr->master_guid - then this is a signal that the polling */
- switch (ib_sminfo_get_state(p_smi)) {
- case IB_SMINFO_STATE_MASTER:
- /* This means the master is alive */
- /* Signal that to the SM state mgr */
- osm_sm_state_mgr_signal_master_is_alive(sm);
- break;
- case IB_SMINFO_STATE_STANDBY:
- /* This should be the response from the sm we are polling. */
- /* If it is - then signal master is alive */
- if (sm->master_sm_guid == p_sm->p_port->guid) {
- /* Make sure that it is an SM with higher priority than us.
- If we started polling it when it was master, and it moved
- to standby - then it might be with a lower priority than
- us - and then we don't want to continue polling it. */
- if (__osm_sminfo_rcv_remote_sm_is_higher
- (sm, p_smi) == TRUE)
- osm_sm_state_mgr_signal_master_is_alive(sm);
- }
- break;
- default:
- /* any other state - do nothing */
- break;
- }
- break;
-
- case IB_SMINFO_STATE_MASTER:
- switch (ib_sminfo_get_state(p_smi)) {
- case IB_SMINFO_STATE_MASTER:
- /* If this is a response due to our polling, this means that we are
- waiting for a handover from this SM, and it is still alive -
- signal that. */
- if (sm->p_polling_sm)
- osm_sm_state_mgr_signal_master_is_alive(sm);
- else {
- /* This is a response we got while sweeping the subnet.
- We will handle a case of handover needed later on, when the sweep
- is done and all SMs are recongnized. */
- }
- break;
- case IB_SMINFO_STATE_STANDBY:
- if (light_sweep &&
- __osm_sminfo_rcv_remote_sm_is_higher(sm, p_smi))
- sm->p_subn->force_heavy_sweep = TRUE;
- break;
- default:
- /* any other state - do nothing */
- break;
- }
- break;
-
- default:
- break;
- }
-
- OSM_LOG_EXIT(sm->p_log);
- return 0;
-}
-
-/**********************************************************************
- **********************************************************************/
-static void
-__osm_sminfo_rcv_process_get_response(IN osm_sm_t * sm,
- IN const osm_madw_t * const p_madw)
-{
- const ib_smp_t *p_smp;
- const ib_sm_info_t *p_smi;
- cl_qmap_t *p_sm_tbl;
- osm_port_t *p_port;
- ib_net64_t port_guid;
- osm_remote_sm_t *p_sm;
-
- OSM_LOG_ENTER(sm->p_log);
-
- CL_ASSERT(p_madw);
-
- p_smp = osm_madw_get_smp_ptr(p_madw);
-
- if (p_smp->method != IB_MAD_METHOD_GET_RESP) {
- OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR 2F11: "
- "Unsupported method 0x%X\n", p_smp->method);
- goto Exit;
- }
-
- p_smi = ib_smp_get_payload_ptr(p_smp);
- p_sm_tbl = &sm->p_subn->sm_guid_tbl;
- port_guid = p_smi->guid;
-
- osm_dump_sm_info(sm->p_log, p_smi, OSM_LOG_DEBUG);
-
- /* Check that the sm_key of the found SM is the same as ours,
- or is zero. If not - OpenSM cannot continue with configuration!. */
- if (p_smi->sm_key != 0 && p_smi->sm_key != sm->p_subn->opt.sm_key) {
- OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR 2F18: "
- "Got SM with sm_key that doesn't match our "
- "local key. Exiting\n");
- osm_log(sm->p_log, OSM_LOG_SYS,
- "Found remote SM with non-matching sm_key. Exiting\n");
- osm_exit_flag = TRUE;
- goto Exit;
- }
-
- /* Determine if we already have another SM object for this SM. */
- CL_PLOCK_EXCL_ACQUIRE(sm->p_lock);
-
- p_port = osm_get_port_by_guid(sm->p_subn, port_guid);
- if (!p_port) {
- OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR 2F12: "
- "No port object for this SM\n");
- goto _unlock_and_exit;
- }
-
- if (osm_port_get_guid(p_port) != p_smi->guid) {
- OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR 2F13: "
- "Bogus SM port GUID\n\t\t\t\tExpected 0x%016" PRIx64
- ", Received 0x%016" PRIx64 "\n",
- cl_ntoh64(osm_port_get_guid(p_port)),
- cl_ntoh64(p_smi->guid));
- goto _unlock_and_exit;
- }
-
- if (port_guid == sm->p_subn->sm_port_guid) {
- OSM_LOG(sm->p_log, OSM_LOG_VERBOSE,
- "Self query response received - SM port 0x%016" PRIx64
- "\n", cl_ntoh64(port_guid));
- goto _unlock_and_exit;
- }
-
- p_sm = (osm_remote_sm_t *) cl_qmap_get(p_sm_tbl, port_guid);
- if (p_sm == (osm_remote_sm_t *) cl_qmap_end(p_sm_tbl)) {
- p_sm = malloc(sizeof(*p_sm));
- if (p_sm == NULL) {
- OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR 2F14: "
- "Unable to allocate SM object\n");
- goto _unlock_and_exit;
- }
-
- osm_remote_sm_init(p_sm, p_port, p_smi);
-
- cl_qmap_insert(p_sm_tbl, port_guid, &p_sm->map_item);
- } else
- /* We already know this SM. Update the SMInfo attribute. */
- p_sm->smi = *p_smi;
-
- __osm_sminfo_rcv_process_get_sm(sm, p_sm,
- osm_madw_get_smi_context_ptr(p_madw)->light_sweep);
-
-_unlock_and_exit:
- CL_PLOCK_RELEASE(sm->p_lock);
-
-Exit:
- OSM_LOG_EXIT(sm->p_log);
-}
-
-/**********************************************************************
- **********************************************************************/
-static void
-__osm_sminfo_rcv_process_set_response(IN osm_sm_t * sm,
- IN const osm_madw_t * const p_madw)
-{
- const ib_smp_t *p_smp;
- const ib_sm_info_t *p_smi;
-
- OSM_LOG_ENTER(sm->p_log);
-
- CL_ASSERT(p_madw);
-
- p_smp = osm_madw_get_smp_ptr(p_madw);
-
- if (p_smp->method != IB_MAD_METHOD_GET_RESP) {
- OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR 2F16: "
- "Unsupported method 0x%X\n", p_smp->method);
- goto Exit;
- }
-
- p_smi = ib_smp_get_payload_ptr(p_smp);
- osm_dump_sm_info(sm->p_log, p_smi, OSM_LOG_DEBUG);
-
- /* Check the AttributeModifier */
- if (p_smp->attr_mod != IB_SMINFO_ATTR_MOD_HANDOVER) {
- OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR 2F17: "
- "Unsupported attribute modifier 0x%X\n",
- p_smp->attr_mod);
- goto Exit;
- }
-
- /* This is a response on a HANDOVER request - Nothing to do. */
-
-Exit:
- OSM_LOG_EXIT(sm->p_log);
-}
-
-/**********************************************************************
- **********************************************************************/
-void osm_sminfo_rcv_process(IN void *context, IN void *data)
-{
- osm_sm_t *sm = context;
- osm_madw_t *p_madw = data;
- ib_smp_t *p_smp;
- osm_smi_context_t *p_smi_context;
-
- OSM_LOG_ENTER(sm->p_log);
-
- CL_ASSERT(p_madw);
-
- p_smp = osm_madw_get_smp_ptr(p_madw);
-
- /* Determine if this is a request for our own SMInfo or if
- this is a response to our request for another SM's SMInfo. */
- if (ib_smp_is_response(p_smp)) {
- const ib_sm_info_t *p_smi = ib_smp_get_payload_ptr(p_smp);
-
- /* Get the context - to see if this is a response to a Get or Set method */
- p_smi_context = osm_madw_get_smi_context_ptr(p_madw);
-
- /* Verify that response is from expected port and there is
- no port moving issue. */
- if (p_smi_context->port_guid != p_smi->guid) {
- OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR 2F19: "
- "Unexpected SM port GUID in response"
- "\n\t\t\t\tExpected 0x%016" PRIx64
- ", Received 0x%016" PRIx64 "\n",
- cl_ntoh64(p_smi_context->port_guid),
- cl_ntoh64(p_smi->guid));
- goto Exit;
- }
-
- if (p_smi_context->set_method == FALSE)
- /* this is a response to a Get method */
- __osm_sminfo_rcv_process_get_response(sm, p_madw);
- else
- /* this is a response to a Set method */
- __osm_sminfo_rcv_process_set_response(sm, p_madw);
- } else if (p_smp->method == IB_MAD_METHOD_GET)
- /* This is a SubnGet request */
- __osm_sminfo_rcv_process_get_request(sm, p_madw);
- else
- /* This should be a SubnSet request */
- __osm_sminfo_rcv_process_set_request(sm, p_madw);
-
-Exit:
- OSM_LOG_EXIT(sm->p_log);
-}
diff --git a/contrib/ofed/management/opensm/opensm/osm_state_mgr.c b/contrib/ofed/management/opensm/opensm/osm_state_mgr.c
deleted file mode 100644
index 625e026..0000000
--- a/contrib/ofed/management/opensm/opensm/osm_state_mgr.c
+++ /dev/null
@@ -1,1396 +0,0 @@
-/*
- * Copyright (c) 2004-2008 Voltaire, Inc. All rights reserved.
- * Copyright (c) 2002-2008 Mellanox Technologies LTD. All rights reserved.
- * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- */
-
-/*
- * Abstract:
- * Implementation of osm_state_mgr_t.
- * This file implements the State Manager object.
- */
-
-#if HAVE_CONFIG_H
-# include <config.h>
-#endif /* HAVE_CONFIG_H */
-
-#include <unistd.h>
-#include <stdlib.h>
-#include <string.h>
-#include <iba/ib_types.h>
-#include <complib/cl_passivelock.h>
-#include <complib/cl_debug.h>
-#include <complib/cl_qmap.h>
-#include <opensm/osm_sm.h>
-#include <opensm/osm_madw.h>
-#include <opensm/osm_switch.h>
-#include <opensm/osm_log.h>
-#include <opensm/osm_subnet.h>
-#include <opensm/osm_helper.h>
-#include <opensm/osm_msgdef.h>
-#include <opensm/osm_node.h>
-#include <opensm/osm_port.h>
-#include <vendor/osm_vendor_api.h>
-#include <opensm/osm_inform.h>
-#include <opensm/osm_opensm.h>
-
-extern void osm_drop_mgr_process(IN osm_sm_t * sm);
-extern osm_signal_t osm_qos_setup(IN osm_opensm_t * p_osm);
-extern osm_signal_t osm_pkey_mgr_process(IN osm_opensm_t * p_osm);
-extern osm_signal_t osm_mcast_mgr_process(IN osm_sm_t * sm);
-extern osm_signal_t osm_mcast_mgr_process_mgroups(IN osm_sm_t * sm);
-extern osm_signal_t osm_link_mgr_process(IN osm_sm_t * sm, IN uint8_t state);
-
-/**********************************************************************
- **********************************************************************/
-static void __osm_state_mgr_up_msg(IN const osm_sm_t * sm)
-{
- /*
- * This message should be written only once - when the
- * SM moves to Master state and the subnet is up for
- * the first time.
- */
- osm_log(sm->p_log, sm->p_subn->first_time_master_sweep ?
- OSM_LOG_SYS : OSM_LOG_INFO, "SUBNET UP\n");
-
- OSM_LOG_MSG_BOX(sm->p_log, OSM_LOG_VERBOSE,
- sm->p_subn->opt.sweep_interval ?
- "SUBNET UP" : "SUBNET UP (sweep disabled)");
-}
-
-/**********************************************************************
- **********************************************************************/
-static void __osm_state_mgr_reset_node_count(IN cl_map_item_t *
- const p_map_item, IN void *context)
-{
- osm_node_t *p_node = (osm_node_t *) p_map_item;
-
- p_node->discovery_count = 0;
-}
-
-/**********************************************************************
- **********************************************************************/
-static void __osm_state_mgr_reset_port_count(IN cl_map_item_t *
- const p_map_item, IN void *context)
-{
- osm_port_t *p_port = (osm_port_t *) p_map_item;
-
- p_port->discovery_count = 0;
-}
-
-/**********************************************************************
- **********************************************************************/
-static void
-__osm_state_mgr_reset_switch_count(IN cl_map_item_t * const p_map_item,
- IN void *context)
-{
- osm_switch_t *p_sw = (osm_switch_t *) p_map_item;
-
- p_sw->discovery_count = 0;
- p_sw->need_update = 1;
-}
-
-/**********************************************************************
- **********************************************************************/
-static void __osm_state_mgr_get_sw_info(IN cl_map_item_t * const p_object,
- IN void *context)
-{
- osm_node_t *p_node;
- osm_dr_path_t *p_dr_path;
- osm_madw_context_t mad_context;
- osm_switch_t *const p_sw = (osm_switch_t *) p_object;
- osm_sm_t *sm = context;
- ib_api_status_t status;
-
- OSM_LOG_ENTER(sm->p_log);
-
- p_node = p_sw->p_node;
- p_dr_path = osm_physp_get_dr_path_ptr(osm_node_get_physp_ptr(p_node, 0));
-
- memset(&mad_context, 0, sizeof(mad_context));
-
- mad_context.si_context.node_guid = osm_node_get_node_guid(p_node);
- mad_context.si_context.set_method = FALSE;
- mad_context.si_context.light_sweep = TRUE;
-
- status = osm_req_get(sm, p_dr_path, IB_MAD_ATTR_SWITCH_INFO, 0,
- OSM_MSG_LIGHT_SWEEP_FAIL, &mad_context);
-
- if (status != IB_SUCCESS)
- OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR 3304: "
- "Request for SwitchInfo failed\n");
-
- OSM_LOG_EXIT(sm->p_log);
-}
-
-/**********************************************************************
- Initiate a remote port info request for the given physical port
- **********************************************************************/
-static void
-__osm_state_mgr_get_remote_port_info(IN osm_sm_t * sm,
- IN osm_physp_t * const p_physp)
-{
- osm_dr_path_t *p_dr_path;
- osm_dr_path_t rem_node_dr_path;
- osm_madw_context_t mad_context;
- ib_api_status_t status;
-
- OSM_LOG_ENTER(sm->p_log);
-
- /* generate a dr path leaving on the physp to the remote node */
- p_dr_path = osm_physp_get_dr_path_ptr(p_physp);
- memcpy(&rem_node_dr_path, p_dr_path, sizeof(osm_dr_path_t));
- osm_dr_path_extend(&rem_node_dr_path, osm_physp_get_port_num(p_physp));
-
- memset(&mad_context, 0, sizeof(mad_context));
-
- mad_context.pi_context.node_guid =
- osm_node_get_node_guid(osm_physp_get_node_ptr(p_physp));
- mad_context.pi_context.port_guid = p_physp->port_guid;
- mad_context.pi_context.set_method = FALSE;
- mad_context.pi_context.light_sweep = TRUE;
- mad_context.pi_context.active_transition = FALSE;
-
- /* note that with some negative logic - if the query failed it means that
- * there is no point in going to heavy sweep */
- status = osm_req_get(sm, &rem_node_dr_path,
- IB_MAD_ATTR_PORT_INFO, 0, CL_DISP_MSGID_NONE,
- &mad_context);
-
- if (status != IB_SUCCESS)
- OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR 332E: "
- "Request for PortInfo failed\n");
-
- OSM_LOG_EXIT(sm->p_log);
-}
-
-/**********************************************************************
- Initiates a thorough sweep of the subnet.
- Used when there is suspicion that something on the subnet has changed.
-**********************************************************************/
-static ib_api_status_t __osm_state_mgr_sweep_hop_0(IN osm_sm_t * sm)
-{
- ib_api_status_t status;
- osm_dr_path_t dr_path;
- osm_bind_handle_t h_bind;
- uint8_t path_array[IB_SUBNET_PATH_HOPS_MAX];
-
- OSM_LOG_ENTER(sm->p_log);
-
- memset(path_array, 0, sizeof(path_array));
-
- /*
- * First, get the bind handle.
- */
- h_bind = osm_sm_mad_ctrl_get_bind_handle(&sm->mad_ctrl);
- if (h_bind != OSM_BIND_INVALID_HANDLE) {
- OSM_LOG_MSG_BOX(sm->p_log, OSM_LOG_VERBOSE,
- "INITIATING HEAVY SWEEP");
- /*
- * Start the sweep by clearing the port counts, then
- * get our own NodeInfo at 0 hops.
- */
- CL_PLOCK_ACQUIRE(sm->p_lock);
-
- cl_qmap_apply_func(&sm->p_subn->node_guid_tbl,
- __osm_state_mgr_reset_node_count, sm);
-
- cl_qmap_apply_func(&sm->p_subn->port_guid_tbl,
- __osm_state_mgr_reset_port_count, sm);
-
- cl_qmap_apply_func(&sm->p_subn->sw_guid_tbl,
- __osm_state_mgr_reset_switch_count, sm);
-
- /* Set the in_sweep_hop_0 flag in subn to be TRUE.
- * This will indicate the sweeping not to continue beyond the
- * the current node.
- * This is relevant for the case of SM on switch, since in the
- * switch info we need to signal somehow not to continue
- * the sweeping. */
- sm->p_subn->in_sweep_hop_0 = TRUE;
-
- CL_PLOCK_RELEASE(sm->p_lock);
-
- osm_dr_path_init(&dr_path, h_bind, 0, path_array);
- status = osm_req_get(sm, &dr_path, IB_MAD_ATTR_NODE_INFO, 0,
- CL_DISP_MSGID_NONE, NULL);
-
- if (status != IB_SUCCESS)
- OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR 3305: "
- "Request for NodeInfo failed\n");
- } else {
- OSM_LOG(sm->p_log, OSM_LOG_DEBUG,
- "No bound ports. Deferring sweep...\n");
- status = IB_INVALID_STATE;
- }
-
- OSM_LOG_EXIT(sm->p_log);
- return (status);
-}
-
-/**********************************************************************
- Clear out all existing port lid assignments
-**********************************************************************/
-static ib_api_status_t __osm_state_mgr_clean_known_lids(IN osm_sm_t * sm)
-{
- ib_api_status_t status = IB_SUCCESS;
- cl_ptr_vector_t *p_vec = &(sm->p_subn->port_lid_tbl);
- uint32_t i;
-
- OSM_LOG_ENTER(sm->p_log);
-
- /* we need a lock here! */
- CL_PLOCK_ACQUIRE(sm->p_lock);
-
- for (i = 0; i < cl_ptr_vector_get_size(p_vec); i++)
- cl_ptr_vector_set(p_vec, i, NULL);
-
- CL_PLOCK_RELEASE(sm->p_lock);
-
- OSM_LOG_EXIT(sm->p_log);
- return (status);
-}
-
-/**********************************************************************
- Notifies the transport layer that the local LID has changed,
- which give it a chance to update address vectors, etc..
-**********************************************************************/
-static ib_api_status_t __osm_state_mgr_notify_lid_change(IN osm_sm_t * sm)
-{
- ib_api_status_t status;
- osm_bind_handle_t h_bind;
-
- OSM_LOG_ENTER(sm->p_log);
-
- /*
- * First, get the bind handle.
- */
- h_bind = osm_sm_mad_ctrl_get_bind_handle(&sm->mad_ctrl);
- if (h_bind == OSM_BIND_INVALID_HANDLE) {
- OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR 3306: "
- "No bound ports\n");
- status = IB_ERROR;
- goto Exit;
- }
-
- /*
- * Notify the transport layer that we changed the local LID.
- */
- status = osm_vendor_local_lid_change(h_bind);
- if (status != IB_SUCCESS)
- OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR 3307: "
- "Vendor LID update failed (%s)\n",
- ib_get_err_str(status));
-
-Exit:
- OSM_LOG_EXIT(sm->p_log);
- return (status);
-}
-
-/**********************************************************************
- Returns true if the SM port is down.
- The SM's port object must exist in the port_guid table.
-**********************************************************************/
-static boolean_t __osm_state_mgr_is_sm_port_down(IN osm_sm_t * sm)
-{
- ib_net64_t port_guid;
- osm_port_t *p_port;
- osm_physp_t *p_physp;
- uint8_t state;
-
- OSM_LOG_ENTER(sm->p_log);
-
- port_guid = sm->p_subn->sm_port_guid;
-
- /*
- * If we don't know our own port guid yet, assume the port is down.
- */
- if (port_guid == 0) {
- OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR 3308: "
- "SM port GUID unknown\n");
- state = IB_LINK_DOWN;
- goto Exit;
- }
-
- CL_ASSERT(port_guid);
-
- CL_PLOCK_ACQUIRE(sm->p_lock);
- p_port = osm_get_port_by_guid(sm->p_subn, port_guid);
- if (!p_port) {
- OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR 3309: "
- "SM port with GUID:%016" PRIx64 " is unknown\n",
- cl_ntoh64(port_guid));
- state = IB_LINK_DOWN;
- CL_PLOCK_RELEASE(sm->p_lock);
- goto Exit;
- }
-
- p_physp = p_port->p_physp;
-
- CL_ASSERT(p_physp);
-
- state = osm_physp_get_port_state(p_physp);
- CL_PLOCK_RELEASE(sm->p_lock);
-
-Exit:
- OSM_LOG_EXIT(sm->p_log);
- return (state == IB_LINK_DOWN);
-}
-
-/**********************************************************************
- Sweeps the node 1 hop away.
- This sets off a "chain reaction" that causes discovery of the subnet.
- Used when there is suspicion that something on the subnet has changed.
-**********************************************************************/
-static ib_api_status_t __osm_state_mgr_sweep_hop_1(IN osm_sm_t * sm)
-{
- ib_api_status_t status = IB_SUCCESS;
- osm_bind_handle_t h_bind;
- osm_madw_context_t context;
- osm_node_t *p_node;
- osm_port_t *p_port;
- osm_physp_t *p_physp;
- osm_dr_path_t *p_dr_path;
- osm_dr_path_t hop_1_path;
- ib_net64_t port_guid;
- uint8_t port_num;
- uint8_t path_array[IB_SUBNET_PATH_HOPS_MAX];
- uint8_t num_ports;
- osm_physp_t *p_ext_physp;
-
- OSM_LOG_ENTER(sm->p_log);
-
- /*
- * First, get our own port and node objects.
- */
- port_guid = sm->p_subn->sm_port_guid;
-
- CL_ASSERT(port_guid);
-
- /* Set the in_sweep_hop_0 flag in subn to be FALSE.
- * This will indicate the sweeping to continue beyond the
- * the current node.
- * This is relevant for the case of SM on switch, since in the
- * switch info we need to signal that the sweeping should
- * continue through the switch. */
- sm->p_subn->in_sweep_hop_0 = FALSE;
-
- p_port = osm_get_port_by_guid(sm->p_subn, port_guid);
- if (!p_port) {
- OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR 3310: "
- "No SM port object\n");
- status = IB_ERROR;
- goto Exit;
- }
-
- p_node = p_port->p_node;
- CL_ASSERT(p_node);
-
- port_num = ib_node_info_get_local_port_num(&p_node->node_info);
-
- OSM_LOG(sm->p_log, OSM_LOG_DEBUG,
- "Probing hop 1 on local port %u\n", port_num);
-
- p_physp = osm_node_get_physp_ptr(p_node, port_num);
-
- CL_ASSERT(p_physp);
-
- p_dr_path = osm_physp_get_dr_path_ptr(p_physp);
- h_bind = osm_dr_path_get_bind_handle(p_dr_path);
-
- CL_ASSERT(h_bind != OSM_BIND_INVALID_HANDLE);
-
- memset(path_array, 0, sizeof(path_array));
- /* the hop_1 operations depend on the type of our node.
- * Currently - legal nodes that can host SM are SW and CA */
- switch (osm_node_get_type(p_node)) {
- case IB_NODE_TYPE_CA:
- case IB_NODE_TYPE_ROUTER:
- memset(&context, 0, sizeof(context));
- context.ni_context.node_guid = osm_node_get_node_guid(p_node);
- context.ni_context.port_num = port_num;
-
- path_array[1] = port_num;
-
- osm_dr_path_init(&hop_1_path, h_bind, 1, path_array);
- status = osm_req_get(sm, &hop_1_path, IB_MAD_ATTR_NODE_INFO, 0,
- CL_DISP_MSGID_NONE, &context);
- if (status != IB_SUCCESS)
- OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR 3311: "
- "Request for NodeInfo failed\n");
- break;
-
- case IB_NODE_TYPE_SWITCH:
- /* Need to go over all the ports of the switch, and send a node_info
- * from them. This doesn't include the port 0 of the switch, which
- * hosts the SM.
- * Note: We'll send another switchInfo on port 0, since if no ports
- * are connected, we still want to get some response, and have the
- * subnet come up.
- */
- num_ports = osm_node_get_num_physp(p_node);
- for (port_num = 0; port_num < num_ports; port_num++) {
- /* go through the port only if the port is not DOWN */
- p_ext_physp = osm_node_get_physp_ptr(p_node, port_num);
- if (p_ext_physp && ib_port_info_get_port_state
- (&(p_ext_physp->port_info)) > IB_LINK_DOWN) {
- memset(&context, 0, sizeof(context));
- context.ni_context.node_guid =
- osm_node_get_node_guid(p_node);
- context.ni_context.port_num = port_num;
-
- path_array[1] = port_num;
- osm_dr_path_init(&hop_1_path, h_bind, 1,
- path_array);
- status = osm_req_get(sm, &hop_1_path,
- IB_MAD_ATTR_NODE_INFO, 0,
- CL_DISP_MSGID_NONE,
- &context);
-
- if (status != IB_SUCCESS)
- OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR 3312: "
- "Request for NodeInfo failed\n");
- }
- }
- break;
-
- default:
- OSM_LOG(sm->p_log, OSM_LOG_ERROR,
- "ERR 3313: Unknown node type %d (%s)\n",
- osm_node_get_type(p_node), p_node->print_desc);
- }
-
-Exit:
- OSM_LOG_EXIT(sm->p_log);
- return (status);
-}
-
-static void query_sm_info(cl_map_item_t *item, void *cxt)
-{
- osm_madw_context_t context;
- osm_remote_sm_t *r_sm = cl_item_obj(item, r_sm, map_item);
- osm_sm_t *sm = cxt;
- ib_api_status_t ret;
-
- context.smi_context.port_guid = r_sm->p_port->guid;
- context.smi_context.set_method = FALSE;
- context.smi_context.light_sweep = TRUE;
-
- ret = osm_req_get(sm, osm_physp_get_dr_path_ptr(r_sm->p_port->p_physp),
- IB_MAD_ATTR_SM_INFO, 0, CL_DISP_MSGID_NONE, &context);
- if (ret != IB_SUCCESS)
- OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR 3314: "
- "Failure requesting SMInfo (%s)\n",
- ib_get_err_str(ret));
-}
-
-/**********************************************************************
- During a light sweep check each node to see if the node descriptor is valid
- if not issue a ND query.
-**********************************************************************/
-static void __osm_state_mgr_get_node_desc(IN cl_map_item_t * const p_object,
- IN void *context)
-{
- osm_madw_context_t mad_context;
- osm_node_t *const p_node = (osm_node_t *) p_object;
- osm_sm_t *sm = context;
- osm_physp_t *p_physp = NULL;
- unsigned i, num_ports;
- ib_api_status_t status;
-
- OSM_LOG_ENTER(sm->p_log);
-
- CL_ASSERT(p_node);
-
- if (p_node->print_desc && strcmp(p_node->print_desc, OSM_NODE_DESC_UNKNOWN))
- /* if ND is valid, do nothing */
- goto exit;
-
- OSM_LOG(sm->p_log, OSM_LOG_ERROR,
- "ERR 3319: Unknown node description for node GUID "
- "0x%016" PRIx64 ". Reissuing ND query\n",
- cl_ntoh64(osm_node_get_node_guid (p_node)));
-
- /* get a physp to request from. */
- num_ports = osm_node_get_num_physp(p_node);
- for (i = 0; i < num_ports; i++)
- if ((p_physp = osm_node_get_physp_ptr(p_node, i)))
- break;
-
- if (!p_physp) {
- OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR 331C: "
- "Failed to find any valid physical port object.\n");
- goto exit;
- }
-
- mad_context.nd_context.node_guid = osm_node_get_node_guid(p_node);
-
- status = osm_req_get(sm, osm_physp_get_dr_path_ptr(p_physp),
- IB_MAD_ATTR_NODE_DESC, 0, CL_DISP_MSGID_NONE,
- &mad_context);
- if (status != IB_SUCCESS)
- OSM_LOG(sm->p_log, OSM_LOG_ERROR,
- "ERR 331B: Failure initiating NodeDescription request "
- "(%s)\n", ib_get_err_str(status));
-
-exit:
- OSM_LOG_EXIT(sm->p_log);
-}
-
-/**********************************************************************
- Initiates a lightweight sweep of the subnet.
- Used during normal sweeps after the subnet is up.
-**********************************************************************/
-static ib_api_status_t __osm_state_mgr_light_sweep_start(IN osm_sm_t * sm)
-{
- ib_api_status_t status = IB_SUCCESS;
- osm_bind_handle_t h_bind;
- cl_qmap_t *p_sw_tbl;
- cl_map_item_t *p_next;
- osm_node_t *p_node;
- osm_physp_t *p_physp;
- uint8_t port_num;
-
- OSM_LOG_ENTER(sm->p_log);
-
- p_sw_tbl = &sm->p_subn->sw_guid_tbl;
-
- /*
- * First, get the bind handle.
- */
- h_bind = osm_sm_mad_ctrl_get_bind_handle(&sm->mad_ctrl);
- if (h_bind == OSM_BIND_INVALID_HANDLE) {
- OSM_LOG(sm->p_log, OSM_LOG_DEBUG,
- "No bound ports. Deferring sweep...\n");
- status = IB_INVALID_STATE;
- goto _exit;
- }
-
- OSM_LOG_MSG_BOX(sm->p_log, OSM_LOG_VERBOSE, "INITIATING LIGHT SWEEP");
- CL_PLOCK_ACQUIRE(sm->p_lock);
- cl_qmap_apply_func(p_sw_tbl, __osm_state_mgr_get_sw_info, sm);
- CL_PLOCK_RELEASE(sm->p_lock);
-
- CL_PLOCK_ACQUIRE(sm->p_lock);
- cl_qmap_apply_func(&sm->p_subn->node_guid_tbl, __osm_state_mgr_get_node_desc, sm);
- CL_PLOCK_RELEASE(sm->p_lock);
-
- /* now scan the list of physical ports that were not down but have no remote port */
- CL_PLOCK_ACQUIRE(sm->p_lock);
- p_next = cl_qmap_head(&sm->p_subn->node_guid_tbl);
- while (p_next != cl_qmap_end(&sm->p_subn->node_guid_tbl)) {
- p_node = (osm_node_t *) p_next;
- p_next = cl_qmap_next(p_next);
-
- for (port_num = 1; port_num < osm_node_get_num_physp(p_node);
- port_num++) {
- p_physp = osm_node_get_physp_ptr(p_node, port_num);
- if (p_physp && (osm_physp_get_port_state(p_physp) !=
- IB_LINK_DOWN)
- && !osm_physp_get_remote(p_physp)) {
- OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR 3315: "
- "Unknown remote side for node 0x%016"
- PRIx64
- "(%s) port %u. Adding to light sweep sampling list\n",
- cl_ntoh64(osm_node_get_node_guid
- (p_node)),
- p_node->print_desc, port_num);
-
- osm_dump_dr_path(sm->p_log,
- osm_physp_get_dr_path_ptr
- (p_physp), OSM_LOG_ERROR);
-
- __osm_state_mgr_get_remote_port_info(sm,
- p_physp);
- }
- }
- }
-
- cl_qmap_apply_func(&sm->p_subn->sm_guid_tbl, query_sm_info, sm);
-
- CL_PLOCK_RELEASE(sm->p_lock);
-
-_exit:
- OSM_LOG_EXIT(sm->p_log);
- return (status);
-}
-
-/**********************************************************************
- * Go over all the remote SMs (as updated in the sm_guid_tbl).
- * Find if there is a remote sm that is a master SM.
- * If there is a remote master SM - return a pointer to it,
- * else - return NULL.
- **********************************************************************/
-static osm_remote_sm_t *__osm_state_mgr_exists_other_master_sm(IN osm_sm_t * sm)
-{
- cl_qmap_t *p_sm_tbl;
- osm_remote_sm_t *p_sm;
- osm_remote_sm_t *p_sm_res = NULL;
-
- OSM_LOG_ENTER(sm->p_log);
-
- p_sm_tbl = &sm->p_subn->sm_guid_tbl;
-
- /* go over all the remote SMs */
- for (p_sm = (osm_remote_sm_t *) cl_qmap_head(p_sm_tbl);
- p_sm != (osm_remote_sm_t *) cl_qmap_end(p_sm_tbl);
- p_sm = (osm_remote_sm_t *) cl_qmap_next(&p_sm->map_item)) {
- /* If the sm is in MASTER state - return a pointer to it */
- if (ib_sminfo_get_state(&p_sm->smi) == IB_SMINFO_STATE_MASTER) {
- OSM_LOG(sm->p_log, OSM_LOG_VERBOSE,
- "Found remote master SM with guid:0x%016" PRIx64
- " (node %s)\n", cl_ntoh64(p_sm->smi.guid),
- p_sm->p_port->p_node ? p_sm->p_port->p_node->
- print_desc : "UNKNOWN");
- p_sm_res = p_sm;
- goto Exit;
- }
- }
-
-Exit:
- OSM_LOG_EXIT(sm->p_log);
- return (p_sm_res);
-}
-
-/**********************************************************************
- * Go over all remote SMs (as updated in the sm_guid_tbl).
- * Find the one with the highest priority and lowest guid.
- * Compare this SM to the local SM. If the local SM is higher -
- * return NULL, if the remote SM is higher - return a pointer to it.
- **********************************************************************/
-static osm_remote_sm_t *__osm_state_mgr_get_highest_sm(IN osm_sm_t * sm)
-{
- cl_qmap_t *p_sm_tbl;
- osm_remote_sm_t *p_sm = NULL;
- osm_remote_sm_t *p_highest_sm;
- uint8_t highest_sm_priority;
- ib_net64_t highest_sm_guid;
-
- OSM_LOG_ENTER(sm->p_log);
-
- p_sm_tbl = &sm->p_subn->sm_guid_tbl;
-
- /* Start with the local sm as the standard */
- p_highest_sm = NULL;
- highest_sm_priority = sm->p_subn->opt.sm_priority;
- highest_sm_guid = sm->p_subn->sm_port_guid;
-
- /* go over all the remote SMs */
- for (p_sm = (osm_remote_sm_t *) cl_qmap_head(p_sm_tbl);
- p_sm != (osm_remote_sm_t *) cl_qmap_end(p_sm_tbl);
- p_sm = (osm_remote_sm_t *) cl_qmap_next(&p_sm->map_item)) {
-
- /* If the sm is in NOTACTIVE state - continue */
- if (ib_sminfo_get_state(&p_sm->smi) ==
- IB_SMINFO_STATE_NOTACTIVE)
- continue;
-
- if (osm_sm_is_greater_than(ib_sminfo_get_priority(&p_sm->smi),
- p_sm->smi.guid, highest_sm_priority,
- highest_sm_guid)) {
- /* the new p_sm is with higher priority - update the highest_sm */
- /* to this sm */
- p_highest_sm = p_sm;
- highest_sm_priority =
- ib_sminfo_get_priority(&p_sm->smi);
- highest_sm_guid = p_sm->smi.guid;
- }
- }
-
- if (p_highest_sm != NULL)
- OSM_LOG(sm->p_log, OSM_LOG_DEBUG,
- "Found higher SM with guid: %016" PRIx64 " (node %s)\n",
- cl_ntoh64(p_highest_sm->smi.guid),
- p_highest_sm->p_port->p_node ?
- p_highest_sm->p_port->p_node->print_desc : "UNKNOWN");
-
- OSM_LOG_EXIT(sm->p_log);
- return (p_highest_sm);
-}
-
-/**********************************************************************
- * Send SubnSet(SMInfo) SMP with HANDOVER attribute to the
- * remote_sm indicated.
- **********************************************************************/
-static void
-__osm_state_mgr_send_handover(IN osm_sm_t * const sm,
- IN osm_remote_sm_t * const p_sm)
-{
- uint8_t payload[IB_SMP_DATA_SIZE];
- ib_sm_info_t *p_smi = (ib_sm_info_t *) payload;
- osm_madw_context_t context;
- const osm_port_t *p_port;
- ib_api_status_t status;
-
- OSM_LOG_ENTER(sm->p_log);
-
- /*
- * Send a query of SubnSet(SMInfo) HANDOVER to the remote sm given.
- */
-
- memset(&context, 0, sizeof(context));
- p_port = p_sm->p_port;
- if (p_port == NULL) {
- OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR 3316: "
- "No port object on given remote_sm object\n");
- goto Exit;
- }
-
- /* update the master_guid in the sm_state_mgr object according to */
- /* the guid of the port where the new Master SM should reside. */
- OSM_LOG(sm->p_log, OSM_LOG_VERBOSE,
- "Handing over mastership. Updating sm_state_mgr master_guid: %016"
- PRIx64 " (node %s)\n", cl_ntoh64(p_port->guid),
- p_port->p_node ? p_port->p_node->print_desc : "UNKNOWN");
- sm->master_sm_guid = p_port->guid;
-
- context.smi_context.port_guid = p_port->guid;
- context.smi_context.set_method = TRUE;
-
- p_smi->guid = sm->p_subn->sm_port_guid;
- p_smi->act_count = cl_hton32(sm->p_subn->p_osm->stats.qp0_mads_sent);
- p_smi->pri_state = (uint8_t) (sm->p_subn->sm_state |
- sm->p_subn->opt.sm_priority << 4);
- /*
- * Return 0 for the SM key unless we authenticate the requester
- * as the master SM.
- */
- if (ib_sminfo_get_state(&p_sm->smi) == IB_SMINFO_STATE_MASTER) {
- OSM_LOG(sm->p_log, OSM_LOG_DEBUG,
- "Responding to master SM with real sm_key\n");
- p_smi->sm_key = sm->p_subn->opt.sm_key;
- } else {
- /* The requester is not authenticated as master - set sm_key to zero */
- OSM_LOG(sm->p_log, OSM_LOG_DEBUG,
- "Responding to SM not master with zero sm_key\n");
- p_smi->sm_key = 0;
- }
-
- status = osm_req_set(sm, osm_physp_get_dr_path_ptr(p_port->p_physp),
- payload, sizeof(payload), IB_MAD_ATTR_SM_INFO,
- IB_SMINFO_ATTR_MOD_HANDOVER, CL_DISP_MSGID_NONE,
- &context);
-
- if (status != IB_SUCCESS)
- OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR 3317: "
- "Failure requesting SMInfo (%s)\n",
- ib_get_err_str(status));
-
-Exit:
- OSM_LOG_EXIT(sm->p_log);
-}
-
-/**********************************************************************
- * Send Trap 64 on all new ports.
- **********************************************************************/
-static void __osm_state_mgr_report_new_ports(IN osm_sm_t * sm)
-{
- ib_gid_t port_gid;
- ib_mad_notice_attr_t notice;
- ib_api_status_t status;
- ib_net64_t port_guid;
- cl_map_item_t *p_next;
- osm_port_t *p_port;
- uint16_t min_lid_ho;
- uint16_t max_lid_ho;
-
- OSM_LOG_ENTER(sm->p_log);
-
- CL_PLOCK_ACQUIRE(sm->p_lock);
- p_next = cl_qmap_head(&sm->p_subn->port_guid_tbl);
- while (p_next != cl_qmap_end(&sm->p_subn->port_guid_tbl)) {
- p_port = (osm_port_t *) p_next;
- p_next = cl_qmap_next(p_next);
-
- if (!p_port->is_new)
- continue;
-
- port_guid = osm_port_get_guid(p_port);
- /* issue a notice - trap 64 */
-
- /* details of the notice */
- notice.generic_type = 0x83; /* is generic subn mgt type */
- ib_notice_set_prod_type_ho(&notice, 4); /* A Class Manager generator */
- /* endport becomes to be reachable */
- notice.g_or_v.generic.trap_num = CL_HTON16(64);
- /* The sm_base_lid is saved in network order already. */
- notice.issuer_lid = sm->p_subn->sm_base_lid;
- /* following C14-72.1.1 and table 119 p739 */
- /* we need to provide the GID */
- port_gid.unicast.prefix = sm->p_subn->opt.subnet_prefix;
- port_gid.unicast.interface_id = port_guid;
- memcpy(&(notice.data_details.ntc_64_67.gid), &(port_gid),
- sizeof(ib_gid_t));
-
- /* According to page 653 - the issuer gid in this case of trap
- * is the SM gid, since the SM is the initiator of this trap. */
- notice.issuer_gid.unicast.prefix =
- sm->p_subn->opt.subnet_prefix;
- notice.issuer_gid.unicast.interface_id =
- sm->p_subn->sm_port_guid;
-
- status = osm_report_notice(sm->p_log, sm->p_subn, &notice);
- if (status != IB_SUCCESS)
- OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR 3318: "
- "Error sending trap reports on GUID:0x%016"
- PRIx64 " (%s)\n", port_gid.unicast.interface_id,
- ib_get_err_str(status));
- osm_port_get_lid_range_ho(p_port, &min_lid_ho, &max_lid_ho);
- OSM_LOG(sm->p_log, OSM_LOG_INFO,
- "Discovered new port with GUID:0x%016" PRIx64
- " LID range [%u,%u] of node:%s\n",
- cl_ntoh64(port_gid.unicast.interface_id),
- min_lid_ho, max_lid_ho,
- p_port->p_node ? p_port->p_node->
- print_desc : "UNKNOWN");
-
- p_port->is_new = 0;
- }
- CL_PLOCK_RELEASE(sm->p_lock);
-
- OSM_LOG_EXIT(sm->p_log);
-}
-
-/**********************************************************************
- * Make sure that the lid_port_tbl of the subnet has only the ports
- * that are recognized, and in the correct lid place. There could be
- * errors if we wanted to assign a certain port with lid X, but that
- * request didn't reach the port. In this case port_lid_tbl will have
- * the port under lid X, though the port isn't updated with this lid.
- * We will run a new heavy sweep (since there were errors in the
- * initialization), but here we'll clean the database from incorrect
- * information.
- **********************************************************************/
-static void __osm_state_mgr_check_tbl_consistency(IN osm_sm_t * sm)
-{
- cl_qmap_t *p_port_guid_tbl;
- osm_port_t *p_port;
- osm_port_t *p_next_port;
- cl_ptr_vector_t *p_port_lid_tbl;
- size_t max_lid, ref_size, curr_size, lid;
- osm_port_t *p_port_ref, *p_port_stored;
- cl_ptr_vector_t ref_port_lid_tbl;
- uint16_t min_lid_ho;
- uint16_t max_lid_ho;
- uint16_t lid_ho;
-
- OSM_LOG_ENTER(sm->p_log);
-
- cl_ptr_vector_construct(&ref_port_lid_tbl);
- cl_ptr_vector_init(&ref_port_lid_tbl,
- cl_ptr_vector_get_size(&sm->p_subn->port_lid_tbl),
- OSM_SUBNET_VECTOR_GROW_SIZE);
-
- p_port_guid_tbl = &sm->p_subn->port_guid_tbl;
-
- /* Let's go over all the ports according to port_guid_tbl,
- * and add the port to a reference port_lid_tbl. */
- p_next_port = (osm_port_t *) cl_qmap_head(p_port_guid_tbl);
- while (p_next_port != (osm_port_t *) cl_qmap_end(p_port_guid_tbl)) {
- p_port = p_next_port;
- p_next_port =
- (osm_port_t *) cl_qmap_next(&p_next_port->map_item);
-
- osm_port_get_lid_range_ho(p_port, &min_lid_ho, &max_lid_ho);
- for (lid_ho = min_lid_ho; lid_ho <= max_lid_ho; lid_ho++)
- cl_ptr_vector_set(&ref_port_lid_tbl, lid_ho, p_port);
- }
-
- p_port_lid_tbl = &sm->p_subn->port_lid_tbl;
-
- ref_size = cl_ptr_vector_get_size(&ref_port_lid_tbl);
- curr_size = cl_ptr_vector_get_size(p_port_lid_tbl);
- /* They should be the same, but compare it anyway */
- max_lid = (ref_size > curr_size) ? ref_size : curr_size;
-
- for (lid = 1; lid <= max_lid; lid++) {
- p_port_ref = NULL;
- p_port_stored = NULL;
- cl_ptr_vector_at(p_port_lid_tbl, lid, (void *)&p_port_stored);
- cl_ptr_vector_at(&ref_port_lid_tbl, lid, (void *)&p_port_ref);
-
- if (p_port_stored == p_port_ref)
- /* This is the "good" case - both entries are the
- * same for this lid. Nothing to do. */
- continue;
-
- if (p_port_ref == NULL)
- /* There is an object in the subnet database for this
- * lid, but no such object exists in the reference
- * port_list_tbl. This can occur if we wanted to assign
- * a certain port with some lid (different than the one
- * pre-assigned to it), and the port didn't get the
- * PortInfo Set request. Due to this, the port is
- * updated with its original lid in our database, but
- * with the new lid we wanted to give it in our
- * port_lid_tbl. */
- OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR 3322: "
- "lid %zu is wrongly assigned to port 0x%016"
- PRIx64 " (\'%s\' port %u) in port_lid_tbl\n",
- lid,
- cl_ntoh64(osm_port_get_guid(p_port_stored)),
- p_port_stored->p_node->print_desc,
- p_port_stored->p_physp->port_num);
- else if (p_port_stored == NULL)
- /* There is an object in the new database, but no
- * object in our subnet database. This is the matching
- * case of the prior check - the port still has its
- * original lid. */
- OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR 3323: "
- "port 0x%016" PRIx64 " (\'%s\' port %u)"
- " exists in new port_lid_tbl under lid %zu,"
- " but missing in subnet port_lid_tbl db\n",
- cl_ntoh64(osm_port_get_guid(p_port_ref)),
- p_port_ref->p_node->print_desc,
- p_port_ref->p_physp->port_num, lid);
- else
- /* if we reached here then p_port_stored != p_port_ref.
- * We were trying to set a lid to p_port_stored, but
- * it didn't reach it, and p_port_ref also didn't get
- * the lid update. */
- OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR 3324: "
- "lid %zu has port 0x%016" PRIx64
- " (\'%s\' port %u) in new port_lid_tbl db, "
- "and port 0x%016" PRIx64 " (\'%s\' port %u)"
- " in subnet port_lid_tbl db\n", lid,
- cl_ntoh64(osm_port_get_guid(p_port_ref)),
- p_port_ref->p_node->print_desc,
- p_port_ref->p_physp->port_num,
- cl_ntoh64(osm_port_get_guid(p_port_stored)),
- p_port_ref->p_node->print_desc,
- p_port_ref->p_physp->port_num);
-
- /* In any of these cases we want to set NULL in the
- * port_lid_tbl, since this entry is invalid. Also, make sure
- * we'll do another heavy sweep. */
- cl_ptr_vector_set(p_port_lid_tbl, lid, NULL);
- sm->p_subn->subnet_initialization_error = TRUE;
- }
-
- cl_ptr_vector_destroy(&ref_port_lid_tbl);
- OSM_LOG_EXIT(sm->p_log);
-}
-
-static void cleanup_switch(cl_map_item_t *item, void *log)
-{
- osm_switch_t *sw = (osm_switch_t *)item;
-
- if (!sw->new_lft)
- return;
-
- if (memcmp(sw->lft, sw->new_lft, IB_LID_UCAST_END_HO + 1))
- osm_log(log, OSM_LOG_ERROR, "ERR 331D: "
- "LFT of switch 0x%016" PRIx64 " is not up to date.\n",
- cl_ntoh64(sw->p_node->node_info.node_guid));
- else {
- free(sw->new_lft);
- sw->new_lft = NULL;
- }
-}
-
-/**********************************************************************
- **********************************************************************/
-int wait_for_pending_transactions(osm_stats_t * stats)
-{
-#ifdef HAVE_LIBPTHREAD
- pthread_mutex_lock(&stats->mutex);
- while (stats->qp0_mads_outstanding && !osm_exit_flag)
- pthread_cond_wait(&stats->cond, &stats->mutex);
- pthread_mutex_unlock(&stats->mutex);
-#else
- while (1) {
- unsigned count = stats->qp0_mads_outstanding;
- if (!count || osm_exit_flag)
- break;
- cl_event_wait_on(&stats->event, EVENT_NO_TIMEOUT, TRUE);
- }
-#endif
- return osm_exit_flag;
-}
-
-static void do_sweep(osm_sm_t * sm)
-{
- ib_api_status_t status;
- osm_remote_sm_t *p_remote_sm;
-
- if (sm->p_subn->sm_state != IB_SMINFO_STATE_MASTER &&
- sm->p_subn->sm_state != IB_SMINFO_STATE_DISCOVERING)
- return;
-
- if (sm->p_subn->coming_out_of_standby)
- /*
- * Need to force re-write of sm_base_lid to all ports
- * to do that we want all the ports to be considered
- * foreign
- */
- __osm_state_mgr_clean_known_lids(sm);
-
- sm->master_sm_found = 0;
-
- /*
- * If we already have switches, then try a light sweep.
- * Otherwise, this is probably our first discovery pass
- * or we are connected in loopback. In both cases do a
- * heavy sweep.
- * Note: If we are connected in loopback we want a heavy
- * sweep, since we will not be getting any traps if there is
- * a lost connection.
- */
- /* if we are in DISCOVERING state - this means it is either in
- * initializing or wake up from STANDBY - run the heavy sweep */
- if (cl_qmap_count(&sm->p_subn->sw_guid_tbl)
- && sm->p_subn->sm_state != IB_SMINFO_STATE_DISCOVERING
- && sm->p_subn->opt.force_heavy_sweep == FALSE
- && sm->p_subn->force_heavy_sweep == FALSE
- && sm->p_subn->force_reroute == FALSE
- && sm->p_subn->subnet_initialization_error == FALSE
- && (__osm_state_mgr_light_sweep_start(sm) == IB_SUCCESS)) {
- if (wait_for_pending_transactions(&sm->p_subn->p_osm->stats))
- return;
- if (!sm->p_subn->force_heavy_sweep) {
- OSM_LOG_MSG_BOX(sm->p_log, OSM_LOG_VERBOSE,
- "LIGHT SWEEP COMPLETE");
- return;
- }
- }
-
- /*
- * Unicast cache should be invalidated if there were errors
- * during initialization or if subnet re-route is requested.
- */
- if (sm->p_subn->opt.use_ucast_cache &&
- (sm->p_subn->subnet_initialization_error ||
- sm->p_subn->force_reroute))
- osm_ucast_cache_invalidate(&sm->ucast_mgr);
-
- /*
- * If we don't need to do a heavy sweep and we want to do a reroute,
- * just reroute only.
- */
- if (cl_qmap_count(&sm->p_subn->sw_guid_tbl)
- && sm->p_subn->sm_state != IB_SMINFO_STATE_DISCOVERING
- && sm->p_subn->opt.force_heavy_sweep == FALSE
- && sm->p_subn->force_heavy_sweep == FALSE
- && sm->p_subn->force_reroute == TRUE
- && sm->p_subn->subnet_initialization_error == FALSE) {
- /* Reset flag */
- sm->p_subn->force_reroute = FALSE;
-
- /* Re-program the switches fully */
- sm->p_subn->ignore_existing_lfts = TRUE;
-
- osm_ucast_mgr_process(&sm->ucast_mgr);
-
- /* Reset flag */
- sm->p_subn->ignore_existing_lfts = FALSE;
-
- if (wait_for_pending_transactions(&sm->p_subn->p_osm->stats))
- return;
-
- if (!sm->p_subn->subnet_initialization_error) {
- OSM_LOG_MSG_BOX(sm->p_log, OSM_LOG_VERBOSE,
- "REROUTE COMPLETE");
- return;
- }
- }
-
- /* go to heavy sweep */
-_repeat_discovery:
-
- /* First of all - unset all flags */
- sm->p_subn->force_heavy_sweep = FALSE;
- sm->p_subn->force_reroute = FALSE;
- sm->p_subn->subnet_initialization_error = FALSE;
-
- /* rescan configuration updates */
- if (osm_subn_rescan_conf_files(sm->p_subn) < 0)
- OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR 331A: "
- "osm_subn_rescan_conf_file failed\n");
-
- if (sm->p_subn->sm_state != IB_SMINFO_STATE_MASTER)
- sm->p_subn->need_update = 1;
-
- status = __osm_state_mgr_sweep_hop_0(sm);
- if (status != IB_SUCCESS ||
- wait_for_pending_transactions(&sm->p_subn->p_osm->stats))
- return;
-
- if (__osm_state_mgr_is_sm_port_down(sm) == TRUE) {
- osm_log(sm->p_log, OSM_LOG_SYS, "SM port is down\n");
- OSM_LOG_MSG_BOX(sm->p_log, OSM_LOG_VERBOSE, "SM PORT DOWN");
-
- /* Run the drop manager - we want to clear all records */
- osm_drop_mgr_process(sm);
-
- /* Move to DISCOVERING state */
- osm_sm_state_mgr_process(sm, OSM_SM_SIGNAL_DISCOVER);
- return;
- }
-
- status = __osm_state_mgr_sweep_hop_1(sm);
- if (status != IB_SUCCESS ||
- wait_for_pending_transactions(&sm->p_subn->p_osm->stats))
- return;
-
- /* discovery completed - check other sm presense */
- if (sm->master_sm_found) {
- /*
- * Call the sm_state_mgr with signal
- * MASTER_OR_HIGHER_SM_DETECTED_DONE
- */
- osm_sm_state_mgr_process(sm,
- OSM_SM_SIGNAL_MASTER_OR_HIGHER_SM_DETECTED);
- OSM_LOG_MSG_BOX(sm->p_log, OSM_LOG_VERBOSE,
- "ENTERING STANDBY STATE");
- /* notify master SM about us */
- osm_send_trap144(sm, 0);
- return;
- }
-
- /* if new sweep requested - don't bother with the rest */
- if (sm->p_subn->force_heavy_sweep)
- goto _repeat_discovery;
-
- OSM_LOG_MSG_BOX(sm->p_log, OSM_LOG_VERBOSE, "HEAVY SWEEP COMPLETE");
-
- /* If we are MASTER - get the highest remote_sm, and
- * see if it is higher than our local sm.
- */
- if (sm->p_subn->sm_state == IB_SMINFO_STATE_MASTER) {
- p_remote_sm = __osm_state_mgr_get_highest_sm(sm);
- if (p_remote_sm != NULL) {
- /* report new ports (trap 64) before leaving MASTER */
- __osm_state_mgr_report_new_ports(sm);
-
- /* need to handover the mastership
- * to the remote sm, and move to standby */
- __osm_state_mgr_send_handover(sm, p_remote_sm);
- osm_sm_state_mgr_process(sm,
- OSM_SM_SIGNAL_HANDOVER_SENT);
- return;
- } else {
- /* We are the highest sm - check to see if there is
- * a remote SM that is in master state. */
- p_remote_sm =
- __osm_state_mgr_exists_other_master_sm(sm);
- if (p_remote_sm != NULL) {
- /* There is a remote SM that is master.
- * need to wait for that SM to relinquish control
- * of its portion of the subnet. C14-60.2.1.
- * Also - need to start polling on that SM. */
- sm->p_polling_sm = p_remote_sm;
- osm_sm_state_mgr_process(sm,
- OSM_SM_SIGNAL_WAIT_FOR_HANDOVER);
- return;
- }
- }
- }
-
- /* Need to continue with lid assignment */
- osm_drop_mgr_process(sm);
-
- /*
- * If we are not MASTER already - this means that we are
- * in discovery state. call osm_sm_state_mgr with signal
- * DISCOVERY_COMPLETED
- */
- if (sm->p_subn->sm_state == IB_SMINFO_STATE_DISCOVERING)
- osm_sm_state_mgr_process(sm, OSM_SM_SIGNAL_DISCOVERY_COMPLETED);
-
- osm_pkey_mgr_process(sm->p_subn->p_osm);
-
- osm_qos_setup(sm->p_subn->p_osm);
-
- /* try to restore SA DB (this should be before lid_mgr
- because we may want to disable clients reregistration
- when SA DB is restored) */
- osm_sa_db_file_load(sm->p_subn->p_osm);
-
- if (wait_for_pending_transactions(&sm->p_subn->p_osm->stats))
- return;
-
- osm_lid_mgr_process_sm(&sm->lid_mgr);
- if (wait_for_pending_transactions(&sm->p_subn->p_osm->stats))
- return;
-
- OSM_LOG_MSG_BOX(sm->p_log, OSM_LOG_VERBOSE,
- "SM LID ASSIGNMENT COMPLETE - STARTING SUBNET LID CONFIG");
- __osm_state_mgr_notify_lid_change(sm);
-
- osm_lid_mgr_process_subnet(&sm->lid_mgr);
- if (wait_for_pending_transactions(&sm->p_subn->p_osm->stats))
- return;
-
- /* At this point we need to check the consistency of
- * the port_lid_tbl under the subnet. There might be
- * errors in it if PortInfo Set requests didn't reach
- * their destination. */
- __osm_state_mgr_check_tbl_consistency(sm);
-
- OSM_LOG_MSG_BOX(sm->p_log, OSM_LOG_VERBOSE,
- "LID ASSIGNMENT COMPLETE - STARTING SWITCH TABLE CONFIG");
-
- /*
- * Proceed with unicast forwarding table configuration.
- */
-
- if (!sm->ucast_mgr.cache_valid ||
- osm_ucast_cache_process(&sm->ucast_mgr))
- osm_ucast_mgr_process(&sm->ucast_mgr);
-
- if (wait_for_pending_transactions(&sm->p_subn->p_osm->stats))
- return;
-
- /* cleanup switch lft buffers */
- cl_qmap_apply_func(&sm->p_subn->sw_guid_tbl, cleanup_switch, sm->p_log);
-
- /* We are done setting all LFTs so clear the ignore existing.
- * From now on, as long as we are still master, we want to
- * take into account these lfts. */
- sm->p_subn->ignore_existing_lfts = FALSE;
-
- OSM_LOG_MSG_BOX(sm->p_log, OSM_LOG_VERBOSE,
- "SWITCHES CONFIGURED FOR UNICAST");
-
- if (!sm->p_subn->opt.disable_multicast) {
- osm_mcast_mgr_process(sm);
- if (wait_for_pending_transactions(&sm->p_subn->p_osm->stats))
- return;
- OSM_LOG_MSG_BOX(sm->p_log, OSM_LOG_VERBOSE,
- "SWITCHES CONFIGURED FOR MULTICAST");
- }
-
- /*
- * The LINK_PORTS state is required since we cannot count on
- * the port state change MADs to succeed. This is an artifact
- * of the spec defining state change from state X to state X
- * as an error. The hardware then is not required to process
- * other parameters provided by the Set(PortInfo) Packet.
- */
-
- osm_link_mgr_process(sm, IB_LINK_NO_CHANGE);
- if (wait_for_pending_transactions(&sm->p_subn->p_osm->stats))
- return;
-
- OSM_LOG_MSG_BOX(sm->p_log, OSM_LOG_VERBOSE,
- "LINKS PORTS CONFIGURED - SET LINKS TO ARMED STATE");
-
- osm_link_mgr_process(sm, IB_LINK_ARMED);
- if (wait_for_pending_transactions(&sm->p_subn->p_osm->stats))
- return;
-
- OSM_LOG_MSG_BOX(sm->p_log, OSM_LOG_VERBOSE,
- "LINKS ARMED - SET LINKS TO ACTIVE STATE");
-
- osm_link_mgr_process(sm, IB_LINK_ACTIVE);
- if (wait_for_pending_transactions(&sm->p_subn->p_osm->stats))
- return;
-
- /*
- * The sweep completed!
- */
-
- /*
- * Send trap 64 on newly discovered endports
- */
- __osm_state_mgr_report_new_ports(sm);
-
- /* in any case we zero this flag */
- sm->p_subn->coming_out_of_standby = FALSE;
-
- /* If there were errors - then the subnet is not really up */
- if (sm->p_subn->subnet_initialization_error == TRUE) {
- osm_log(sm->p_log, OSM_LOG_SYS,
- "Errors during initialization\n");
- OSM_LOG_MSG_BOX(sm->p_log, OSM_LOG_ERROR,
- "ERRORS DURING INITIALIZATION");
- } else {
- sm->p_subn->need_update = 0;
- osm_dump_all(sm->p_subn->p_osm);
- __osm_state_mgr_up_msg(sm);
- sm->p_subn->first_time_master_sweep = FALSE;
-
- if (osm_log_is_active(sm->p_log, OSM_LOG_VERBOSE))
- osm_sa_db_file_dump(sm->p_subn->p_osm);
- }
-
- /*
- * Finally signal the subnet up event
- */
- cl_event_signal(&sm->subnet_up_event);
-
- osm_opensm_report_event(sm->p_subn->p_osm, OSM_EVENT_ID_SUBNET_UP, NULL);
-
- /* if we got a signal to force heavy sweep or errors
- * in the middle of the sweep - try another sweep. */
- if (sm->p_subn->force_heavy_sweep
- || sm->p_subn->subnet_initialization_error)
- osm_sm_signal(sm, OSM_SIGNAL_SWEEP);
-}
-
-static void do_process_mgrp_queue(osm_sm_t * sm)
-{
- if (sm->p_subn->sm_state != IB_SMINFO_STATE_MASTER)
- return;
- osm_mcast_mgr_process_mgroups(sm);
- wait_for_pending_transactions(&sm->p_subn->p_osm->stats);
-}
-
-void osm_state_mgr_process(IN osm_sm_t * sm, IN osm_signal_t signal)
-{
- CL_ASSERT(sm);
-
- OSM_LOG_ENTER(sm->p_log);
-
- OSM_LOG(sm->p_log, OSM_LOG_DEBUG,
- "Received signal %s in state %s\n",
- osm_get_sm_signal_str(signal),
- osm_get_sm_mgr_state_str(sm->p_subn->sm_state));
-
- switch (signal) {
- case OSM_SIGNAL_SWEEP:
- do_sweep(sm);
- break;
-
- case OSM_SIGNAL_IDLE_TIME_PROCESS_REQUEST:
- do_process_mgrp_queue(sm);
- break;
-
- default:
- CL_ASSERT(FALSE);
- OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR 3320: "
- "Invalid SM signal %u\n", signal);
- break;
- }
-
- OSM_LOG_EXIT(sm->p_log);
-}
diff --git a/contrib/ofed/management/opensm/opensm/osm_subnet.c b/contrib/ofed/management/opensm/opensm/osm_subnet.c
deleted file mode 100644
index 558027c..0000000
--- a/contrib/ofed/management/opensm/opensm/osm_subnet.c
+++ /dev/null
@@ -1,1719 +0,0 @@
-/*
- * Copyright (c) 2004-2008 Voltaire, Inc. All rights reserved.
- * Copyright (c) 2002-2008 Mellanox Technologies LTD. All rights reserved.
- * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
- * Copyright (c) 2008 Xsigo Systems Inc. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- */
-
-/*
- * Abstract:
- * Implementation of osm_subn_t.
- * This object represents an IBA subnet.
- * This object is part of the opensm family of objects.
- */
-
-#if HAVE_CONFIG_H
-# include <config.h>
-#endif /* HAVE_CONFIG_H */
-
-#include <string.h>
-#include <stdio.h>
-#include <stdarg.h>
-#include <limits.h>
-#include <errno.h>
-#include <ctype.h>
-#include <complib/cl_debug.h>
-#include <complib/cl_log.h>
-#include <opensm/osm_subnet.h>
-#include <opensm/osm_opensm.h>
-#include <opensm/osm_log.h>
-#include <opensm/osm_madw.h>
-#include <opensm/osm_port.h>
-#include <opensm/osm_switch.h>
-#include <opensm/osm_remote_sm.h>
-#include <opensm/osm_partition.h>
-#include <opensm/osm_node.h>
-#include <opensm/osm_multicast.h>
-#include <opensm/osm_inform.h>
-#include <opensm/osm_console.h>
-#include <opensm/osm_perfmgr.h>
-#include <opensm/osm_event_plugin.h>
-#include <opensm/osm_qos_policy.h>
-
-static const char null_str[] = "(null)";
-
-/**********************************************************************
- **********************************************************************/
-void osm_subn_construct(IN osm_subn_t * const p_subn)
-{
- memset(p_subn, 0, sizeof(*p_subn));
- cl_ptr_vector_construct(&p_subn->port_lid_tbl);
- cl_qmap_init(&p_subn->sw_guid_tbl);
- cl_qmap_init(&p_subn->node_guid_tbl);
- cl_qmap_init(&p_subn->port_guid_tbl);
- cl_qmap_init(&p_subn->sm_guid_tbl);
- cl_qlist_init(&p_subn->sa_sr_list);
- cl_qlist_init(&p_subn->sa_infr_list);
- cl_qlist_init(&p_subn->prefix_routes_list);
- cl_qmap_init(&p_subn->rtr_guid_tbl);
- cl_qmap_init(&p_subn->prtn_pkey_tbl);
-}
-
-/**********************************************************************
- **********************************************************************/
-void osm_subn_destroy(IN osm_subn_t * const p_subn)
-{
- int i;
- osm_node_t *p_node, *p_next_node;
- osm_port_t *p_port, *p_next_port;
- osm_switch_t *p_sw, *p_next_sw;
- osm_remote_sm_t *p_rsm, *p_next_rsm;
- osm_prtn_t *p_prtn, *p_next_prtn;
- osm_mgrp_t *p_mgrp;
- osm_infr_t *p_infr, *p_next_infr;
-
- /* it might be a good idea to de-allocate all known objects */
- p_next_node = (osm_node_t *) cl_qmap_head(&p_subn->node_guid_tbl);
- while (p_next_node !=
- (osm_node_t *) cl_qmap_end(&p_subn->node_guid_tbl)) {
- p_node = p_next_node;
- p_next_node = (osm_node_t *) cl_qmap_next(&p_node->map_item);
- osm_node_delete(&p_node);
- }
-
- p_next_port = (osm_port_t *) cl_qmap_head(&p_subn->port_guid_tbl);
- while (p_next_port !=
- (osm_port_t *) cl_qmap_end(&p_subn->port_guid_tbl)) {
- p_port = p_next_port;
- p_next_port = (osm_port_t *) cl_qmap_next(&p_port->map_item);
- osm_port_delete(&p_port);
- }
-
- p_next_sw = (osm_switch_t *) cl_qmap_head(&p_subn->sw_guid_tbl);
- while (p_next_sw != (osm_switch_t *) cl_qmap_end(&p_subn->sw_guid_tbl)) {
- p_sw = p_next_sw;
- p_next_sw = (osm_switch_t *) cl_qmap_next(&p_sw->map_item);
- osm_switch_delete(&p_sw);
- }
-
- p_next_rsm = (osm_remote_sm_t *) cl_qmap_head(&p_subn->sm_guid_tbl);
- while (p_next_rsm !=
- (osm_remote_sm_t *) cl_qmap_end(&p_subn->sm_guid_tbl)) {
- p_rsm = p_next_rsm;
- p_next_rsm = (osm_remote_sm_t *) cl_qmap_next(&p_rsm->map_item);
- free(p_rsm);
- }
-
- p_next_prtn = (osm_prtn_t *) cl_qmap_head(&p_subn->prtn_pkey_tbl);
- while (p_next_prtn !=
- (osm_prtn_t *) cl_qmap_end(&p_subn->prtn_pkey_tbl)) {
- p_prtn = p_next_prtn;
- p_next_prtn = (osm_prtn_t *) cl_qmap_next(&p_prtn->map_item);
- osm_prtn_delete(&p_prtn);
- }
-
- for (i = 0; i <= p_subn->max_mcast_lid_ho - IB_LID_MCAST_START_HO;
- i++) {
- p_mgrp = p_subn->mgroups[i];
- p_subn->mgroups[i] = NULL;
- if (p_mgrp)
- osm_mgrp_delete(p_mgrp);
- }
-
- p_next_infr = (osm_infr_t *) cl_qlist_head(&p_subn->sa_infr_list);
- while (p_next_infr !=
- (osm_infr_t *) cl_qlist_end(&p_subn->sa_infr_list)) {
- p_infr = p_next_infr;
- p_next_infr = (osm_infr_t *) cl_qlist_next(&p_infr->list_item);
- osm_infr_delete(p_infr);
- }
-
- cl_ptr_vector_destroy(&p_subn->port_lid_tbl);
-
- osm_qos_policy_destroy(p_subn->p_qos_policy);
-
- while (!cl_is_qlist_empty(&p_subn->prefix_routes_list)) {
- cl_list_item_t *item = cl_qlist_remove_head(&p_subn->prefix_routes_list);
- free(item);
- }
-}
-
-/**********************************************************************
- **********************************************************************/
-ib_api_status_t
-osm_subn_init(IN osm_subn_t * const p_subn,
- IN osm_opensm_t * const p_osm,
- IN const osm_subn_opt_t * const p_opt)
-{
- cl_status_t status;
-
- p_subn->p_osm = p_osm;
-
- status = cl_ptr_vector_init(&p_subn->port_lid_tbl,
- OSM_SUBNET_VECTOR_MIN_SIZE,
- OSM_SUBNET_VECTOR_GROW_SIZE);
- if (status != CL_SUCCESS)
- return (status);
-
- status = cl_ptr_vector_set_capacity(&p_subn->port_lid_tbl,
- OSM_SUBNET_VECTOR_CAPACITY);
- if (status != CL_SUCCESS)
- return (status);
-
- /*
- LID zero is not valid. NULL out this entry for the
- convenience of other code.
- */
- cl_ptr_vector_set(&p_subn->port_lid_tbl, 0, NULL);
-
- p_subn->opt = *p_opt;
- p_subn->max_ucast_lid_ho = IB_LID_UCAST_END_HO;
- p_subn->max_mcast_lid_ho = IB_LID_MCAST_END_HO;
- p_subn->min_ca_mtu = IB_MAX_MTU;
- p_subn->min_ca_rate = IB_MAX_RATE;
- p_subn->ignore_existing_lfts = TRUE;
-
- /* we assume master by default - so we only need to set it true if STANDBY */
- p_subn->coming_out_of_standby = FALSE;
-
- return (IB_SUCCESS);
-}
-
-/**********************************************************************
- **********************************************************************/
-ib_api_status_t
-osm_get_gid_by_mad_addr(IN osm_log_t * p_log,
- IN const osm_subn_t * p_subn,
- IN const osm_mad_addr_t * p_mad_addr,
- OUT ib_gid_t * p_gid)
-{
- const cl_ptr_vector_t *p_tbl;
- const osm_port_t *p_port = NULL;
-
- if (p_gid == NULL) {
- OSM_LOG(p_log, OSM_LOG_ERROR, "ERR 7505: "
- "Provided output GID is NULL\n");
- return (IB_INVALID_PARAMETER);
- }
-
- /* Find the port gid of the request in the subnet */
- p_tbl = &p_subn->port_lid_tbl;
-
- CL_ASSERT(cl_ptr_vector_get_size(p_tbl) < 0x10000);
-
- if ((uint16_t) cl_ptr_vector_get_size(p_tbl) >
- cl_ntoh16(p_mad_addr->dest_lid)) {
- p_port =
- cl_ptr_vector_get(p_tbl, cl_ntoh16(p_mad_addr->dest_lid));
- if (p_port == NULL) {
- OSM_LOG(p_log, OSM_LOG_DEBUG,
- "Did not find any port with LID: %u\n",
- cl_ntoh16(p_mad_addr->dest_lid));
- return (IB_INVALID_PARAMETER);
- }
- p_gid->unicast.interface_id = p_port->p_physp->port_guid;
- p_gid->unicast.prefix = p_subn->opt.subnet_prefix;
- } else {
- /* The dest_lid is not in the subnet table - this is an error */
- OSM_LOG(p_log, OSM_LOG_ERROR, "ERR 7501: "
- "LID is out of range: %u\n",
- cl_ntoh16(p_mad_addr->dest_lid));
- return (IB_INVALID_PARAMETER);
- }
-
- return (IB_SUCCESS);
-}
-
-/**********************************************************************
- **********************************************************************/
-osm_physp_t *osm_get_physp_by_mad_addr(IN osm_log_t * p_log,
- IN const osm_subn_t * p_subn,
- IN osm_mad_addr_t * p_mad_addr)
-{
- const cl_ptr_vector_t *p_port_lid_tbl;
- osm_port_t *p_port = NULL;
- osm_physp_t *p_physp = NULL;
-
- /* Find the port gid of the request in the subnet */
- p_port_lid_tbl = &p_subn->port_lid_tbl;
-
- CL_ASSERT(cl_ptr_vector_get_size(p_port_lid_tbl) < 0x10000);
-
- if ((uint16_t) cl_ptr_vector_get_size(p_port_lid_tbl) >
- cl_ntoh16(p_mad_addr->dest_lid)) {
- p_port =
- cl_ptr_vector_get(p_port_lid_tbl,
- cl_ntoh16(p_mad_addr->dest_lid));
- if (p_port == NULL) {
- /* The port is not in the port_lid table - this is an error */
- OSM_LOG(p_log, OSM_LOG_ERROR, "ERR 7502: "
- "Cannot locate port object by lid: %u\n",
- cl_ntoh16(p_mad_addr->dest_lid));
-
- goto Exit;
- }
- p_physp = p_port->p_physp;
- } else {
- /* The dest_lid is not in the subnet table - this is an error */
- OSM_LOG(p_log, OSM_LOG_ERROR, "ERR 7503: "
- "Lid is out of range: %u\n",
- cl_ntoh16(p_mad_addr->dest_lid));
- }
-
-Exit:
- return p_physp;
-}
-
-/**********************************************************************
- **********************************************************************/
-osm_port_t *osm_get_port_by_mad_addr(IN osm_log_t * p_log,
- IN const osm_subn_t * p_subn,
- IN osm_mad_addr_t * p_mad_addr)
-{
- const cl_ptr_vector_t *p_port_lid_tbl;
- osm_port_t *p_port = NULL;
-
- /* Find the port gid of the request in the subnet */
- p_port_lid_tbl = &p_subn->port_lid_tbl;
-
- CL_ASSERT(cl_ptr_vector_get_size(p_port_lid_tbl) < 0x10000);
-
- if ((uint16_t) cl_ptr_vector_get_size(p_port_lid_tbl) >
- cl_ntoh16(p_mad_addr->dest_lid)) {
- p_port =
- cl_ptr_vector_get(p_port_lid_tbl,
- cl_ntoh16(p_mad_addr->dest_lid));
- } else {
- /* The dest_lid is not in the subnet table - this is an error */
- OSM_LOG(p_log, OSM_LOG_ERROR, "ERR 7504: "
- "Lid is out of range: %u\n",
- cl_ntoh16(p_mad_addr->dest_lid));
- }
-
- return p_port;
-}
-
-/**********************************************************************
- **********************************************************************/
-osm_switch_t *osm_get_switch_by_guid(IN const osm_subn_t * p_subn,
- IN uint64_t guid)
-{
- osm_switch_t *p_switch;
-
- p_switch = (osm_switch_t *) cl_qmap_get(&(p_subn->sw_guid_tbl), guid);
- if (p_switch == (osm_switch_t *) cl_qmap_end(&(p_subn->sw_guid_tbl)))
- p_switch = NULL;
- return p_switch;
-}
-
-/**********************************************************************
- **********************************************************************/
-osm_node_t *osm_get_node_by_guid(IN osm_subn_t const *p_subn, IN uint64_t guid)
-{
- osm_node_t *p_node;
-
- p_node = (osm_node_t *) cl_qmap_get(&(p_subn->node_guid_tbl), guid);
- if (p_node == (osm_node_t *) cl_qmap_end(&(p_subn->node_guid_tbl)))
- p_node = NULL;
- return p_node;
-}
-
-/**********************************************************************
- **********************************************************************/
-osm_port_t *osm_get_port_by_guid(IN osm_subn_t const *p_subn, IN ib_net64_t guid)
-{
- osm_port_t *p_port;
-
- p_port = (osm_port_t *) cl_qmap_get(&(p_subn->port_guid_tbl), guid);
- if (p_port == (osm_port_t *) cl_qmap_end(&(p_subn->port_guid_tbl)))
- p_port = NULL;
- return p_port;
-}
-
-/**********************************************************************
- **********************************************************************/
-static void subn_set_default_qos_options(IN osm_qos_options_t * opt)
-{
- opt->max_vls = OSM_DEFAULT_QOS_MAX_VLS;
- opt->high_limit = OSM_DEFAULT_QOS_HIGH_LIMIT;
- opt->vlarb_high = OSM_DEFAULT_QOS_VLARB_HIGH;
- opt->vlarb_low = OSM_DEFAULT_QOS_VLARB_LOW;
- opt->sl2vl = OSM_DEFAULT_QOS_SL2VL;
-}
-
-static void subn_init_qos_options(IN osm_qos_options_t * opt)
-{
- opt->max_vls = 0;
- opt->high_limit = -1;
- opt->vlarb_high = NULL;
- opt->vlarb_low = NULL;
- opt->sl2vl = NULL;
-}
-
-/**********************************************************************
- **********************************************************************/
-void osm_subn_set_default_opt(IN osm_subn_opt_t * const p_opt)
-{
- memset(p_opt, 0, sizeof(osm_subn_opt_t));
- p_opt->guid = 0;
- p_opt->m_key = OSM_DEFAULT_M_KEY;
- p_opt->sm_key = OSM_DEFAULT_SM_KEY;
- p_opt->sa_key = OSM_DEFAULT_SA_KEY;
- p_opt->subnet_prefix = IB_DEFAULT_SUBNET_PREFIX;
- p_opt->m_key_lease_period = 0;
- p_opt->sweep_interval = OSM_DEFAULT_SWEEP_INTERVAL_SECS;
- p_opt->max_wire_smps = OSM_DEFAULT_SMP_MAX_ON_WIRE;
- p_opt->console = OSM_DEFAULT_CONSOLE;
- p_opt->console_port = OSM_DEFAULT_CONSOLE_PORT;
- p_opt->transaction_timeout = OSM_DEFAULT_TRANS_TIMEOUT_MILLISEC;
- /* by default we will consider waiting for 50x transaction timeout normal */
- p_opt->max_msg_fifo_timeout = 50 * OSM_DEFAULT_TRANS_TIMEOUT_MILLISEC;
- p_opt->sm_priority = OSM_DEFAULT_SM_PRIORITY;
- p_opt->lmc = OSM_DEFAULT_LMC;
- p_opt->lmc_esp0 = FALSE;
- p_opt->max_op_vls = OSM_DEFAULT_MAX_OP_VLS;
- p_opt->force_link_speed = 15;
- p_opt->reassign_lids = FALSE;
- p_opt->ignore_other_sm = FALSE;
- p_opt->single_thread = FALSE;
- p_opt->disable_multicast = FALSE;
- p_opt->force_log_flush = FALSE;
- p_opt->subnet_timeout = OSM_DEFAULT_SUBNET_TIMEOUT;
- p_opt->packet_life_time = OSM_DEFAULT_SWITCH_PACKET_LIFE;
- p_opt->vl_stall_count = OSM_DEFAULT_VL_STALL_COUNT;
- p_opt->leaf_vl_stall_count = OSM_DEFAULT_LEAF_VL_STALL_COUNT;
- p_opt->head_of_queue_lifetime = OSM_DEFAULT_HEAD_OF_QUEUE_LIFE;
- p_opt->leaf_head_of_queue_lifetime =
- OSM_DEFAULT_LEAF_HEAD_OF_QUEUE_LIFE;
- p_opt->local_phy_errors_threshold = OSM_DEFAULT_ERROR_THRESHOLD;
- p_opt->overrun_errors_threshold = OSM_DEFAULT_ERROR_THRESHOLD;
- p_opt->sminfo_polling_timeout =
- OSM_SM_DEFAULT_POLLING_TIMEOUT_MILLISECS;
- p_opt->polling_retry_number = OSM_SM_DEFAULT_POLLING_RETRY_NUMBER;
- p_opt->force_heavy_sweep = FALSE;
- p_opt->log_flags = OSM_LOG_DEFAULT_LEVEL;
- p_opt->honor_guid2lid_file = FALSE;
- p_opt->daemon = FALSE;
- p_opt->sm_inactive = FALSE;
- p_opt->babbling_port_policy = FALSE;
-#ifdef ENABLE_OSM_PERF_MGR
- p_opt->perfmgr = FALSE;
- p_opt->perfmgr_redir = TRUE;
- p_opt->perfmgr_sweep_time_s = OSM_PERFMGR_DEFAULT_SWEEP_TIME_S;
- p_opt->perfmgr_max_outstanding_queries =
- OSM_PERFMGR_DEFAULT_MAX_OUTSTANDING_QUERIES;
- p_opt->event_db_dump_file = NULL; /* use default */
-#endif /* ENABLE_OSM_PERF_MGR */
-
- p_opt->event_plugin_name = NULL;
- p_opt->node_name_map_name = NULL;
-
- p_opt->dump_files_dir = getenv("OSM_TMP_DIR");
- if (!p_opt->dump_files_dir || !(*p_opt->dump_files_dir))
- p_opt->dump_files_dir = OSM_DEFAULT_TMP_DIR;
-
- p_opt->log_file = OSM_DEFAULT_LOG_FILE;
- p_opt->log_max_size = 0;
- p_opt->partition_config_file = OSM_DEFAULT_PARTITION_CONFIG_FILE;
- p_opt->no_partition_enforcement = FALSE;
- p_opt->qos = FALSE;
- p_opt->qos_policy_file = OSM_DEFAULT_QOS_POLICY_FILE;
- p_opt->accum_log_file = TRUE;
- p_opt->port_prof_ignore_file = NULL;
- p_opt->port_profile_switch_nodes = FALSE;
- p_opt->sweep_on_trap = TRUE;
- p_opt->use_ucast_cache = FALSE;
- p_opt->routing_engine_names = NULL;
- p_opt->connect_roots = FALSE;
- p_opt->lid_matrix_dump_file = NULL;
- p_opt->lfts_file = NULL;
- p_opt->root_guid_file = NULL;
- p_opt->cn_guid_file = NULL;
- p_opt->ids_guid_file = NULL;
- p_opt->guid_routing_order_file = NULL;
- p_opt->sa_db_file = NULL;
- p_opt->exit_on_fatal = TRUE;
- p_opt->enable_quirks = FALSE;
- p_opt->no_clients_rereg = FALSE;
- p_opt->prefix_routes_file = OSM_DEFAULT_PREFIX_ROUTES_FILE;
- p_opt->consolidate_ipv6_snm_req = FALSE;
- subn_init_qos_options(&p_opt->qos_options);
- subn_init_qos_options(&p_opt->qos_ca_options);
- subn_init_qos_options(&p_opt->qos_sw0_options);
- subn_init_qos_options(&p_opt->qos_swe_options);
- subn_init_qos_options(&p_opt->qos_rtr_options);
-}
-
-/**********************************************************************
- **********************************************************************/
-static void log_report(const char *fmt, ...)
-{
- char buf[128];
- va_list args;
- va_start(args, fmt);
- vsnprintf(buf, sizeof(buf), fmt, args);
- va_end(args);
- printf("%s", buf);
- cl_log_event("OpenSM", CL_LOG_INFO, buf, NULL, 0);
-}
-
-static void log_config_value(char *name, const char *fmt, ...)
-{
- char buf[128];
- va_list args;
- unsigned n;
- va_start(args, fmt);
- n = snprintf(buf, sizeof(buf), " Loading Cached Option:%s = ", name);
- if (n > sizeof(buf))
- n = sizeof(buf);
- n += vsnprintf(buf + n, sizeof(buf) - n, fmt, args);
- if (n > sizeof(buf))
- n = sizeof(buf);
- snprintf(buf + n, sizeof(buf) - n, "\n");
- va_end(args);
- printf("%s", buf);
- cl_log_event("OpenSM", CL_LOG_INFO, buf, NULL, 0);
-}
-
-static void
-opts_unpack_net64(IN char *p_req_key,
- IN char *p_key, IN char *p_val_str, IN uint64_t * p_val)
-{
- if (!strcmp(p_req_key, p_key)) {
- uint64_t val = strtoull(p_val_str, NULL, 0);
- if (cl_hton64(val) != *p_val) {
- log_config_value(p_key, "0x%016" PRIx64, val);
- *p_val = cl_ntoh64(val);
- }
- }
-}
-
-/**********************************************************************
- **********************************************************************/
-static void
-opts_unpack_uint32(IN char *p_req_key,
- IN char *p_key, IN char *p_val_str, IN uint32_t * p_val)
-{
- if (!strcmp(p_req_key, p_key)) {
- uint32_t val = strtoul(p_val_str, NULL, 0);
- if (val != *p_val) {
- log_config_value(p_key, "%u", val);
- *p_val = val;
- }
- }
-}
-
-/**********************************************************************
- **********************************************************************/
-static void
-opts_unpack_int32(IN char *p_req_key,
- IN char *p_key, IN char *p_val_str, IN int32_t * p_val)
-{
- if (!strcmp(p_req_key, p_key)) {
- int32_t val = strtol(p_val_str, NULL, 0);
- if (val != *p_val) {
- log_config_value(p_key, "%d", val);
- *p_val = val;
- }
- }
-}
-
-/**********************************************************************
- **********************************************************************/
-static void
-opts_unpack_uint16(IN char *p_req_key,
- IN char *p_key, IN char *p_val_str, IN uint16_t * p_val)
-{
- if (!strcmp(p_req_key, p_key)) {
- uint16_t val = (uint16_t) strtoul(p_val_str, NULL, 0);
- if (val != *p_val) {
- log_config_value(p_key, "%u", val);
- *p_val = val;
- }
- }
-}
-
-/**********************************************************************
- **********************************************************************/
-static void
-opts_unpack_net16(IN char *p_req_key,
- IN char *p_key, IN char *p_val_str, IN uint16_t * p_val)
-{
- if (!strcmp(p_req_key, p_key)) {
- uint32_t val;
- val = strtoul(p_val_str, NULL, 0);
- CL_ASSERT(val < 0x10000);
- if (cl_hton32(val) != *p_val) {
- log_config_value(p_key, "0x%04x", val);
- *p_val = cl_hton16((uint16_t) val);
- }
- }
-}
-
-/**********************************************************************
- **********************************************************************/
-static void
-opts_unpack_uint8(IN char *p_req_key,
- IN char *p_key, IN char *p_val_str, IN uint8_t * p_val)
-{
- if (!strcmp(p_req_key, p_key)) {
- uint32_t val;
- val = strtoul(p_val_str, NULL, 0);
- CL_ASSERT(val < 0x100);
- if (val != *p_val) {
- log_config_value(p_key, "%u", val);
- *p_val = (uint8_t) val;
- }
- }
-}
-
-/**********************************************************************
- **********************************************************************/
-static void
-opts_unpack_boolean(IN char *p_req_key,
- IN char *p_key, IN char *p_val_str, IN boolean_t * p_val)
-{
- if (!strcmp(p_req_key, p_key) && p_val_str) {
- boolean_t val;
- if (strcmp("TRUE", p_val_str))
- val = FALSE;
- else
- val = TRUE;
-
- if (val != *p_val) {
- log_config_value(p_key, "%s", p_val_str);
- *p_val = val;
- }
- }
-}
-
-/**********************************************************************
- **********************************************************************/
-static void
-opts_unpack_charp(IN char *p_req_key,
- IN char *p_key, IN char *p_val_str, IN char **p_val)
-{
- if (!strcmp(p_req_key, p_key) && p_val_str) {
- const char *current_str = *p_val ? *p_val : null_str ;
- if (strcmp(p_val_str, current_str)) {
- log_config_value(p_key, "%s", p_val_str);
- /* special case the "(null)" string */
- if (strcmp(null_str, p_val_str) == 0) {
- *p_val = NULL;
- } else {
- /*
- Ignore the possible memory leak here;
- the pointer may be to a static default.
- */
- *p_val = strdup(p_val_str);
- }
- }
- }
-}
-
-/**********************************************************************
- **********************************************************************/
-static char *clean_val(char *val)
-{
- char *p = val;
- /* clean leading spaces */
- while (isspace(*p))
- p++;
- val = p;
- if (!*val)
- return val;
- /* clean trailing spaces */
- p = val + strlen(val) - 1;
- while (p > val && isspace(*p))
- p--;
- p[1] = '\0';
- /* clean quotas */
- if ((*val == '\"' && *p == '\"') || (*val == '\'' && *p == '\'')) {
- val++;
- p--;
- }
- return val;
-}
-
-/**********************************************************************
- **********************************************************************/
-static void
-subn_parse_qos_options(IN const char *prefix,
- IN char *p_key,
- IN char *p_val_str, IN osm_qos_options_t * opt)
-{
- char name[256];
-
- snprintf(name, sizeof(name), "%s_max_vls", prefix);
- opts_unpack_uint32(name, p_key, p_val_str, &opt->max_vls);
- snprintf(name, sizeof(name), "%s_high_limit", prefix);
- opts_unpack_int32(name, p_key, p_val_str, &opt->high_limit);
- snprintf(name, sizeof(name), "%s_vlarb_high", prefix);
- opts_unpack_charp(name, p_key, p_val_str, &opt->vlarb_high);
- snprintf(name, sizeof(name), "%s_vlarb_low", prefix);
- opts_unpack_charp(name, p_key, p_val_str, &opt->vlarb_low);
- snprintf(name, sizeof(name), "%s_sl2vl", prefix);
- opts_unpack_charp(name, p_key, p_val_str, &opt->sl2vl);
-}
-
-static int
-subn_dump_qos_options(FILE * file,
- const char *set_name,
- const char *prefix, osm_qos_options_t * opt)
-{
- return fprintf(file, "# %s\n"
- "%s_max_vls %u\n"
- "%s_high_limit %d\n"
- "%s_vlarb_high %s\n"
- "%s_vlarb_low %s\n"
- "%s_sl2vl %s\n",
- set_name,
- prefix, opt->max_vls,
- prefix, opt->high_limit,
- prefix, opt->vlarb_high,
- prefix, opt->vlarb_low, prefix, opt->sl2vl);
-}
-
-/**********************************************************************
- **********************************************************************/
-static ib_api_status_t
-append_prefix_route(IN osm_subn_t * const p_subn, uint64_t prefix, uint64_t guid)
-{
- osm_prefix_route_t *route;
-
- route = malloc(sizeof *route);
- if (! route) {
- OSM_LOG(&p_subn->p_osm->log, OSM_LOG_ERROR, "out of memory");
- return IB_ERROR;
- }
-
- route->prefix = cl_hton64(prefix);
- route->guid = cl_hton64(guid);
- cl_qlist_insert_tail(&p_subn->prefix_routes_list, &route->list_item);
- return IB_SUCCESS;
-}
-
-static ib_api_status_t
-osm_parse_prefix_routes_file(IN osm_subn_t * const p_subn)
-{
- osm_log_t *log = &p_subn->p_osm->log;
- FILE *fp;
- char buf[1024];
- int line = 0;
- int errors = 0;
-
- while (!cl_is_qlist_empty(&p_subn->prefix_routes_list)) {
- cl_list_item_t *item = cl_qlist_remove_head(&p_subn->prefix_routes_list);
- free(item);
- }
-
- fp = fopen(p_subn->opt.prefix_routes_file, "r");
- if (! fp) {
- if (errno == ENOENT)
- return IB_SUCCESS;
-
- OSM_LOG(log, OSM_LOG_ERROR, "fopen(%s) failed: %s",
- p_subn->opt.prefix_routes_file, strerror(errno));
- return IB_ERROR;
- }
-
- while (fgets(buf, sizeof buf, fp) != NULL) {
- char *p_prefix, *p_guid, *p_extra, *p_last, *p_end;
- uint64_t prefix, guid;
-
- line++;
- if (errors > 10)
- break;
-
- p_prefix = strtok_r(buf, " \t\n", &p_last);
- if (! p_prefix)
- continue; /* ignore blank lines */
-
- if (*p_prefix == '#')
- continue; /* ignore comment lines */
-
- p_guid = strtok_r(NULL, " \t\n", &p_last);
- if (! p_guid) {
- OSM_LOG(log, OSM_LOG_ERROR, "%s:%d: missing GUID\n",
- p_subn->opt.prefix_routes_file, line);
- errors++;
- continue;
- }
-
- p_extra = strtok_r(NULL, " \t\n", &p_last);
- if (p_extra && *p_extra != '#') {
- OSM_LOG(log, OSM_LOG_INFO, "%s:%d: extra tokens ignored\n",
- p_subn->opt.prefix_routes_file, line);
- }
-
- if (strcmp(p_prefix, "*") == 0)
- prefix = 0;
- else {
- prefix = strtoull(p_prefix, &p_end, 16);
- if (*p_end != '\0') {
- OSM_LOG(log, OSM_LOG_ERROR, "%s:%d: illegal prefix: %s\n",
- p_subn->opt.prefix_routes_file, line, p_prefix);
- errors++;
- continue;
- }
- }
-
- if (strcmp(p_guid, "*") == 0)
- guid = 0;
- else {
- guid = strtoull(p_guid, &p_end, 16);
- if (*p_end != '\0' && *p_end != '#') {
- OSM_LOG(log, OSM_LOG_ERROR, "%s:%d: illegal GUID: %s\n",
- p_subn->opt.prefix_routes_file, line, p_guid);
- errors++;
- continue;
- }
- }
-
- if (append_prefix_route(p_subn, prefix, guid) != IB_SUCCESS) {
- errors++;
- break;
- }
- }
-
- fclose(fp);
- return (errors == 0) ? IB_SUCCESS : IB_ERROR;
-}
-
-/**********************************************************************
- **********************************************************************/
-static void subn_verify_max_vls(unsigned *max_vls, const char *prefix, unsigned dflt)
-{
- if (!(*max_vls) || *max_vls > 15) {
- log_report(" Invalid Cached Option: %s_max_vls=%u: "
- "Using Default = %u\n", prefix, *max_vls, dflt);
- *max_vls = dflt;
- }
-}
-
-static void subn_verify_high_limit(int *high_limit, const char *prefix, int dflt)
-{
- if (*high_limit < 0 || *high_limit > 255) {
- log_report(" Invalid Cached Option: %s_high_limit=%d: "
- "Using Default: %d\n", prefix, *high_limit, dflt);
- *high_limit = dflt;
- }
-}
-
-static void subn_verify_vlarb(char **vlarb, const char *prefix,
- const char *suffix, char *dflt)
-{
- char *str, *tok, *end, *ptr;
- int count = 0;
-
- if (*vlarb == NULL) {
- log_report(" Invalid Cached Option: %s_vlarb_%s: "
- "Using Default\n", prefix, suffix);
- *vlarb = dflt;
- return;
- }
-
- str = strdup(*vlarb);
-
- tok = strtok_r(str, ",\n", &ptr);
- while (tok) {
- char *vl_str, *weight_str;
-
- vl_str = tok;
- weight_str = strchr(tok, ':');
-
- if (weight_str) {
- long vl, weight;
-
- *weight_str = '\0';
- weight_str++;
-
- vl = strtol(vl_str, &end, 0);
-
- if (*end)
- log_report(" Warning: Cached Option "
- "%s_vlarb_%s:vl=%s"
- " improperly formatted\n",
- prefix, suffix, vl_str);
- else if (vl < 0 || vl > 14)
- log_report(" Warning: Cached Option "
- "%s_vlarb_%s:vl=%ld out of range\n",
- prefix, suffix, vl);
-
- weight = strtol(weight_str, &end, 0);
-
- if (*end)
- log_report(" Warning: Cached Option "
- "%s_vlarb_%s:weight=%s "
- "improperly formatted\n",
- prefix, suffix, weight_str);
- else if (weight < 0 || weight > 255)
- log_report(" Warning: Cached Option "
- "%s_vlarb_%s:weight=%ld "
- "out of range\n",
- prefix, suffix, weight);
- } else
- log_report(" Warning: Cached Option "
- "%s_vlarb_%s:vl:weight=%s "
- "improperly formatted\n",
- prefix, suffix, tok);
-
- count++;
- tok = strtok_r(NULL, ",\n", &ptr);
- }
-
- if (count > 64)
- log_report(" Warning: Cached Option %s_vlarb_%s: > 64 listed:"
- " excess vl:weight pairs will be dropped\n",
- prefix, suffix);
-
- free(str);
-}
-
-static void subn_verify_sl2vl(char **sl2vl, const char *prefix, char *dflt)
-{
- char *str, *tok, *end, *ptr;
- int count = 0;
-
- if (*sl2vl == NULL) {
- log_report(" Invalid Cached Option: %s_sl2vl: Using Default\n",
- prefix);
- *sl2vl = dflt;
- return;
- }
-
- str = strdup(*sl2vl);
-
- tok = strtok_r(str, ",\n", &ptr);
- while (tok) {
- long vl = strtol(tok, &end, 0);
-
- if (*end)
- log_report(" Warning: Cached Option %s_sl2vl:vl=%s "
- "improperly formatted\n", prefix, tok);
- else if (vl < 0 || vl > 15)
- log_report(" Warning: Cached Option %s_sl2vl:vl=%ld "
- "out of range\n", prefix, vl);
-
- count++;
- tok = strtok_r(NULL, ",\n", &ptr);
- }
-
- if (count < 16)
- log_report(" Warning: Cached Option %s_sl2vl: < 16 VLs "
- "listed\n", prefix);
-
- if (count > 16)
- log_report(" Warning: Cached Option %s_sl2vl: > 16 listed: "
- "excess VLs will be dropped\n", prefix);
-
- free(str);
-}
-
-static void subn_verify_qos_set(osm_qos_options_t *set, const char *prefix,
- osm_qos_options_t *dflt)
-{
- subn_verify_max_vls(&set->max_vls, prefix, dflt->max_vls);
- subn_verify_high_limit(&set->high_limit, prefix, dflt->high_limit);
- subn_verify_vlarb(&set->vlarb_low, prefix, "low", dflt->vlarb_low);
- subn_verify_vlarb(&set->vlarb_high, prefix, "high", dflt->vlarb_high);
- subn_verify_sl2vl(&set->sl2vl, prefix, dflt->sl2vl);
-}
-
-int osm_subn_verify_config(IN osm_subn_opt_t * const p_opts)
-{
- if (p_opts->lmc > 7) {
- log_report(" Invalid Cached Option Value:lmc = %u:"
- "Using Default:%u\n", p_opts->lmc, OSM_DEFAULT_LMC);
- p_opts->lmc = OSM_DEFAULT_LMC;
- }
-
- if (15 < p_opts->sm_priority) {
- log_report(" Invalid Cached Option Value:sm_priority = %u:"
- "Using Default:%u\n",
- p_opts->sm_priority, OSM_DEFAULT_SM_PRIORITY);
- p_opts->sm_priority = OSM_DEFAULT_SM_PRIORITY;
- }
-
- if ((15 < p_opts->force_link_speed) ||
- (p_opts->force_link_speed > 7 && p_opts->force_link_speed < 15)) {
- log_report(" Invalid Cached Option Value:force_link_speed = %u:"
- "Using Default:%u\n", p_opts->force_link_speed,
- IB_PORT_LINK_SPEED_ENABLED_MASK);
- p_opts->force_link_speed = IB_PORT_LINK_SPEED_ENABLED_MASK;
- }
-
- if (strcmp(p_opts->console, OSM_DISABLE_CONSOLE)
- && strcmp(p_opts->console, OSM_LOCAL_CONSOLE)
-#ifdef ENABLE_OSM_CONSOLE_SOCKET
- && strcmp(p_opts->console, OSM_LOOPBACK_CONSOLE)
- && strcmp(p_opts->console, OSM_REMOTE_CONSOLE)
-#endif
- ) {
- log_report(" Invalid Cached Option Value:console = %s"
- ", Using Default:%s\n",
- p_opts->console, OSM_DEFAULT_CONSOLE);
- p_opts->console = OSM_DEFAULT_CONSOLE;
- }
-
- if (p_opts->qos) {
- osm_qos_options_t dflt;
-
- /* the default options in qos_options must be correct.
- * every other one need not be, b/c those will default
- * back to whatever is in qos_options.
- */
-
- subn_set_default_qos_options(&dflt);
-
- subn_verify_qos_set(&p_opts->qos_options, "qos", &dflt);
- subn_verify_qos_set(&p_opts->qos_ca_options, "qos_ca",
- &p_opts->qos_options);
- subn_verify_qos_set(&p_opts->qos_sw0_options, "qos_sw0",
- &p_opts->qos_options);
- subn_verify_qos_set(&p_opts->qos_swe_options, "qos_swe",
- &p_opts->qos_options);
- subn_verify_qos_set(&p_opts->qos_rtr_options, "qos_rtr",
- &p_opts->qos_options);
- }
-
-#ifdef ENABLE_OSM_PERF_MGR
- if (p_opts->perfmgr_sweep_time_s < 1) {
- log_report(" Invalid Cached Option Value:perfmgr_sweep_time_s "
- "= %u Using Default:%u\n",
- p_opts->perfmgr_sweep_time_s,
- OSM_PERFMGR_DEFAULT_SWEEP_TIME_S);
- p_opts->perfmgr_sweep_time_s = OSM_PERFMGR_DEFAULT_SWEEP_TIME_S;
- }
- if (p_opts->perfmgr_max_outstanding_queries < 1) {
- log_report(" Invalid Cached Option Value:"
- "perfmgr_max_outstanding_queries = %u"
- " Using Default:%u\n",
- p_opts->perfmgr_max_outstanding_queries,
- OSM_PERFMGR_DEFAULT_MAX_OUTSTANDING_QUERIES);
- p_opts->perfmgr_max_outstanding_queries =
- OSM_PERFMGR_DEFAULT_MAX_OUTSTANDING_QUERIES;
- }
-#endif
-
- return 0;
-}
-
-/**********************************************************************
- **********************************************************************/
-int osm_subn_parse_conf_file(char *file_name, osm_subn_opt_t * const p_opts)
-{
- char line[1024];
- FILE *opts_file;
- char *p_key, *p_val;
-
- opts_file = fopen(file_name, "r");
- if (!opts_file) {
- if (errno == ENOENT)
- return 1;
- printf("cannot open file \'%s\': %s\n",
- file_name, strerror(errno));
- return -1;
- }
-
- printf(" Reading Cached Option File: %s\n", file_name);
- cl_log_event("OpenSM", CL_LOG_INFO, line, NULL, 0);
-
- p_opts->config_file = file_name;
-
- while (fgets(line, 1023, opts_file) != NULL) {
- /* get the first token */
- p_key = strtok_r(line, " \t\n", &p_val);
- if (!p_key)
- continue;
-
- p_val = clean_val(p_val);
-
- opts_unpack_net64("guid", p_key, p_val, &p_opts->guid);
-
- opts_unpack_net64("m_key", p_key, p_val, &p_opts->m_key);
-
- opts_unpack_net64("sm_key", p_key, p_val, &p_opts->sm_key);
-
- opts_unpack_net64("sa_key", p_key, p_val, &p_opts->sa_key);
-
- opts_unpack_net64("subnet_prefix",
- p_key, p_val, &p_opts->subnet_prefix);
-
- opts_unpack_net16("m_key_lease_period",
- p_key, p_val, &p_opts->m_key_lease_period);
-
- opts_unpack_uint32("sweep_interval",
- p_key, p_val, &p_opts->sweep_interval);
-
- opts_unpack_uint32("max_wire_smps",
- p_key, p_val, &p_opts->max_wire_smps);
-
- opts_unpack_charp("console", p_key, p_val, &p_opts->console);
-
- opts_unpack_uint16("console_port",
- p_key, p_val, &p_opts->console_port);
-
- opts_unpack_uint32("transaction_timeout",
- p_key, p_val, &p_opts->transaction_timeout);
-
- opts_unpack_uint32("max_msg_fifo_timeout",
- p_key, p_val, &p_opts->max_msg_fifo_timeout);
-
- opts_unpack_uint8("sm_priority",
- p_key, p_val, &p_opts->sm_priority);
-
- opts_unpack_uint8("lmc", p_key, p_val, &p_opts->lmc);
-
- opts_unpack_boolean("lmc_esp0",
- p_key, p_val, &p_opts->lmc_esp0);
-
- opts_unpack_uint8("max_op_vls",
- p_key, p_val, &p_opts->max_op_vls);
-
- opts_unpack_uint8("force_link_speed",
- p_key, p_val, &p_opts->force_link_speed);
-
- opts_unpack_boolean("reassign_lids",
- p_key, p_val, &p_opts->reassign_lids);
-
- opts_unpack_boolean("ignore_other_sm",
- p_key, p_val, &p_opts->ignore_other_sm);
-
- opts_unpack_boolean("single_thread",
- p_key, p_val, &p_opts->single_thread);
-
- opts_unpack_boolean("disable_multicast",
- p_key, p_val, &p_opts->disable_multicast);
-
- opts_unpack_boolean("force_log_flush",
- p_key, p_val, &p_opts->force_log_flush);
-
- opts_unpack_uint8("subnet_timeout",
- p_key, p_val, &p_opts->subnet_timeout);
-
- opts_unpack_uint8("packet_life_time",
- p_key, p_val, &p_opts->packet_life_time);
-
- opts_unpack_uint8("vl_stall_count",
- p_key, p_val, &p_opts->vl_stall_count);
-
- opts_unpack_uint8("leaf_vl_stall_count",
- p_key, p_val, &p_opts->leaf_vl_stall_count);
-
- opts_unpack_uint8("head_of_queue_lifetime",
- p_key, p_val,
- &p_opts->head_of_queue_lifetime);
-
- opts_unpack_uint8("leaf_head_of_queue_lifetime", p_key, p_val,
- &p_opts->leaf_head_of_queue_lifetime);
-
- opts_unpack_uint8("local_phy_errors_threshold", p_key, p_val,
- &p_opts->local_phy_errors_threshold);
-
- opts_unpack_uint8("overrun_errors_threshold",
- p_key, p_val,
- &p_opts->overrun_errors_threshold);
-
- opts_unpack_uint32("sminfo_polling_timeout",
- p_key, p_val,
- &p_opts->sminfo_polling_timeout);
-
- opts_unpack_uint32("polling_retry_number",
- p_key, p_val, &p_opts->polling_retry_number);
-
- opts_unpack_boolean("force_heavy_sweep",
- p_key, p_val, &p_opts->force_heavy_sweep);
-
- opts_unpack_uint8("log_flags",
- p_key, p_val, &p_opts->log_flags);
-
- opts_unpack_charp("port_prof_ignore_file", p_key, p_val,
- &p_opts->port_prof_ignore_file);
-
- opts_unpack_boolean("port_profile_switch_nodes", p_key, p_val,
- &p_opts->port_profile_switch_nodes);
-
- opts_unpack_boolean("sweep_on_trap",
- p_key, p_val, &p_opts->sweep_on_trap);
-
- opts_unpack_charp("routing_engine",
- p_key, p_val, &p_opts->routing_engine_names);
-
- opts_unpack_boolean("connect_roots",
- p_key, p_val, &p_opts->connect_roots);
-
- opts_unpack_boolean("use_ucast_cache",
- p_key, p_val, &p_opts->use_ucast_cache);
-
- opts_unpack_charp("log_file", p_key, p_val, &p_opts->log_file);
-
- opts_unpack_uint32("log_max_size",
- p_key, p_val,
- (void *) & p_opts->log_max_size);
- p_opts->log_max_size *= 1024 * 1024; /* convert to MB */
-
- opts_unpack_charp("partition_config_file",
- p_key, p_val, &p_opts->partition_config_file);
-
- opts_unpack_boolean("no_partition_enforcement", p_key, p_val,
- &p_opts->no_partition_enforcement);
-
- opts_unpack_boolean("qos", p_key, p_val, &p_opts->qos);
-
- opts_unpack_charp("qos_policy_file",
- p_key, p_val, &p_opts->qos_policy_file);
-
- opts_unpack_boolean("accum_log_file",
- p_key, p_val, &p_opts->accum_log_file);
-
- opts_unpack_charp("dump_files_dir",
- p_key, p_val, &p_opts->dump_files_dir);
-
- opts_unpack_charp("lid_matrix_dump_file",
- p_key, p_val, &p_opts->lid_matrix_dump_file);
-
- opts_unpack_charp("lfts_file",
- p_key, p_val, &p_opts->lfts_file);
-
- opts_unpack_charp("root_guid_file",
- p_key, p_val, &p_opts->root_guid_file);
-
- opts_unpack_charp("cn_guid_file",
- p_key, p_val, &p_opts->cn_guid_file);
-
- opts_unpack_charp("ids_guid_file",
- p_key, p_val, &p_opts->ids_guid_file);
-
- opts_unpack_charp("guid_routing_order_file",
- p_key, p_val, &p_opts->guid_routing_order_file);
-
- opts_unpack_charp("sa_db_file",
- p_key, p_val, &p_opts->sa_db_file);
-
- opts_unpack_boolean("exit_on_fatal",
- p_key, p_val, &p_opts->exit_on_fatal);
-
- opts_unpack_boolean("honor_guid2lid_file",
- p_key, p_val, &p_opts->honor_guid2lid_file);
-
- opts_unpack_boolean("daemon", p_key, p_val, &p_opts->daemon);
-
- opts_unpack_boolean("sm_inactive",
- p_key, p_val, &p_opts->sm_inactive);
-
- opts_unpack_boolean("babbling_port_policy",
- p_key, p_val,
- &p_opts->babbling_port_policy);
-
-#ifdef ENABLE_OSM_PERF_MGR
- opts_unpack_boolean("perfmgr", p_key, p_val, &p_opts->perfmgr);
-
- opts_unpack_boolean("perfmgr_redir",
- p_key, p_val, &p_opts->perfmgr_redir);
-
- opts_unpack_uint16("perfmgr_sweep_time_s",
- p_key, p_val, &p_opts->perfmgr_sweep_time_s);
-
- opts_unpack_uint32("perfmgr_max_outstanding_queries",
- p_key, p_val,
- &p_opts->perfmgr_max_outstanding_queries);
-
- opts_unpack_charp("event_db_dump_file",
- p_key, p_val, &p_opts->event_db_dump_file);
-#endif /* ENABLE_OSM_PERF_MGR */
-
- opts_unpack_charp("event_plugin_name",
- p_key, p_val, &p_opts->event_plugin_name);
-
- opts_unpack_charp("node_name_map_name",
- p_key, p_val, &p_opts->node_name_map_name);
-
- subn_parse_qos_options("qos",
- p_key, p_val, &p_opts->qos_options);
-
- subn_parse_qos_options("qos_ca",
- p_key, p_val, &p_opts->qos_ca_options);
-
- subn_parse_qos_options("qos_sw0",
- p_key, p_val, &p_opts->qos_sw0_options);
-
- subn_parse_qos_options("qos_swe",
- p_key, p_val, &p_opts->qos_swe_options);
-
- subn_parse_qos_options("qos_rtr",
- p_key, p_val, &p_opts->qos_rtr_options);
-
- opts_unpack_boolean("enable_quirks",
- p_key, p_val, &p_opts->enable_quirks);
-
- opts_unpack_boolean("no_clients_rereg",
- p_key, p_val, &p_opts->no_clients_rereg);
-
- opts_unpack_charp("prefix_routes_file",
- p_key, p_val, &p_opts->prefix_routes_file);
-
- opts_unpack_boolean("consolidate_ipv6_snm_req",
- p_key, p_val, &p_opts->consolidate_ipv6_snm_req);
- }
- fclose(opts_file);
-
- osm_subn_verify_config(p_opts);
-
- return 0;
-}
-
-int osm_subn_rescan_conf_files(IN osm_subn_t * const p_subn)
-{
- FILE *opts_file;
- char line[1024];
- char *p_key, *p_val, *p_last;
-
- if (!p_subn->opt.config_file)
- return 0;
-
- opts_file = fopen(p_subn->opt.config_file, "r");
- if (!opts_file) {
- if (errno == ENOENT)
- return 1;
- OSM_LOG(&p_subn->p_osm->log, OSM_LOG_ERROR,
- "cannot open file \'%s\': %s\n",
- p_subn->opt.config_file, strerror(errno));
- return -1;
- }
-
- subn_init_qos_options(&p_subn->opt.qos_options);
- subn_init_qos_options(&p_subn->opt.qos_ca_options);
- subn_init_qos_options(&p_subn->opt.qos_sw0_options);
- subn_init_qos_options(&p_subn->opt.qos_swe_options);
- subn_init_qos_options(&p_subn->opt.qos_rtr_options);
-
- while (fgets(line, 1023, opts_file) != NULL) {
- /* get the first token */
- p_key = strtok_r(line, " \t\n", &p_last);
- if (p_key) {
- p_val = strtok_r(NULL, " \t\n", &p_last);
-
- subn_parse_qos_options("qos", p_key, p_val,
- &p_subn->opt.qos_options);
-
- subn_parse_qos_options("qos_ca", p_key, p_val,
- &p_subn->opt.qos_ca_options);
-
- subn_parse_qos_options("qos_sw0", p_key, p_val,
- &p_subn->opt.qos_sw0_options);
-
- subn_parse_qos_options("qos_swe", p_key, p_val,
- &p_subn->opt.qos_swe_options);
-
- subn_parse_qos_options("qos_rtr", p_key, p_val,
- &p_subn->opt.qos_rtr_options);
-
- }
- }
- fclose(opts_file);
-
- osm_subn_verify_config(&p_subn->opt);
-
- osm_parse_prefix_routes_file(p_subn);
-
- return 0;
-}
-
-/**********************************************************************
- **********************************************************************/
-int osm_subn_output_conf(FILE *out, IN osm_subn_opt_t *const p_opts)
-{
- fprintf(out,
- "#\n# DEVICE ATTRIBUTES OPTIONS\n#\n"
- "# The port GUID on which the OpenSM is running\n"
- "guid 0x%016" PRIx64 "\n\n"
- "# M_Key value sent to all ports qualifying all Set(PortInfo)\n"
- "m_key 0x%016" PRIx64 "\n\n"
- "# The lease period used for the M_Key on this subnet in [sec]\n"
- "m_key_lease_period %u\n\n"
- "# SM_Key value of the SM used for SM authentication\n"
- "sm_key 0x%016" PRIx64 "\n\n"
- "# SM_Key value to qualify rcv SA queries as 'trusted'\n"
- "sa_key 0x%016" PRIx64 "\n\n"
- "# Note that for both values above (sm_key and sa_key)\n"
- "# OpenSM version 3.2.1 and below used the default value '1'\n"
- "# in a host byte order, it is fixed now but you may need to\n"
- "# change the values to interoperate with old OpenSM running\n"
- "# on a little endian machine.\n\n"
- "# Subnet prefix used on this subnet\n"
- "subnet_prefix 0x%016" PRIx64 "\n\n"
- "# The LMC value used on this subnet\n"
- "lmc %u\n\n"
- "# lmc_esp0 determines whether LMC value used on subnet is used for\n"
- "# enhanced switch port 0. If TRUE, LMC value for subnet is used for\n"
- "# ESP0. Otherwise, LMC value for ESP0s is 0.\n"
- "lmc_esp0 %s\n\n"
- "# The code of maximal time a packet can live in a switch\n"
- "# The actual time is 4.096usec * 2^<packet_life_time>\n"
- "# The value 0x14 disables this mechanism\n"
- "packet_life_time 0x%02x\n\n"
- "# The number of sequential packets dropped that cause the port\n"
- "# to enter the VLStalled state. The result of setting this value to\n"
- "# zero is undefined.\n"
- "vl_stall_count 0x%02x\n\n"
- "# The number of sequential packets dropped that cause the port\n"
- "# to enter the VLStalled state. This value is for switch ports\n"
- "# driving a CA or router port. The result of setting this value\n"
- "# to zero is undefined.\n"
- "leaf_vl_stall_count 0x%02x\n\n"
- "# The code of maximal time a packet can wait at the head of\n"
- "# transmission queue.\n"
- "# The actual time is 4.096usec * 2^<head_of_queue_lifetime>\n"
- "# The value 0x14 disables this mechanism\n"
- "head_of_queue_lifetime 0x%02x\n\n"
- "# The maximal time a packet can wait at the head of queue on\n"
- "# switch port connected to a CA or router port\n"
- "leaf_head_of_queue_lifetime 0x%02x\n\n"
- "# Limit the maximal operational VLs\n"
- "max_op_vls %u\n\n"
- "# Force PortInfo:LinkSpeedEnabled on switch ports\n"
- "# If 0, don't modify PortInfo:LinkSpeedEnabled on switch port\n"
- "# Otherwise, use value for PortInfo:LinkSpeedEnabled on switch port\n"
- "# Values are (IB Spec 1.2.1, 14.2.5.6 Table 146 \"PortInfo\")\n"
- "# 1: 2.5 Gbps\n"
- "# 3: 2.5 or 5.0 Gbps\n"
- "# 5: 2.5 or 10.0 Gbps\n"
- "# 7: 2.5 or 5.0 or 10.0 Gbps\n"
- "# 2,4,6,8-14 Reserved\n"
- "# Default 15: set to PortInfo:LinkSpeedSupported\n"
- "force_link_speed %u\n\n"
- "# The subnet_timeout code that will be set for all the ports\n"
- "# The actual timeout is 4.096usec * 2^<subnet_timeout>\n"
- "subnet_timeout %u\n\n"
- "# Threshold of local phy errors for sending Trap 129\n"
- "local_phy_errors_threshold 0x%02x\n\n"
- "# Threshold of credit overrun errors for sending Trap 130\n"
- "overrun_errors_threshold 0x%02x\n\n",
- cl_ntoh64(p_opts->guid),
- cl_ntoh64(p_opts->m_key),
- cl_ntoh16(p_opts->m_key_lease_period),
- cl_ntoh64(p_opts->sm_key),
- cl_ntoh64(p_opts->sa_key),
- cl_ntoh64(p_opts->subnet_prefix),
- p_opts->lmc,
- p_opts->lmc_esp0 ? "TRUE" : "FALSE",
- p_opts->packet_life_time,
- p_opts->vl_stall_count,
- p_opts->leaf_vl_stall_count,
- p_opts->head_of_queue_lifetime,
- p_opts->leaf_head_of_queue_lifetime,
- p_opts->max_op_vls,
- p_opts->force_link_speed,
- p_opts->subnet_timeout,
- p_opts->local_phy_errors_threshold,
- p_opts->overrun_errors_threshold);
-
- fprintf(out,
- "#\n# PARTITIONING OPTIONS\n#\n"
- "# Partition configuration file to be used\n"
- "partition_config_file %s\n\n"
- "# Disable partition enforcement by switches\n"
- "no_partition_enforcement %s\n\n",
- p_opts->partition_config_file,
- p_opts->no_partition_enforcement ? "TRUE" : "FALSE");
-
- fprintf(out,
- "#\n# SWEEP OPTIONS\n#\n"
- "# The number of seconds between subnet sweeps (0 disables it)\n"
- "sweep_interval %u\n\n"
- "# If TRUE cause all lids to be reassigned\n"
- "reassign_lids %s\n\n"
- "# If TRUE forces every sweep to be a heavy sweep\n"
- "force_heavy_sweep %s\n\n"
- "# If TRUE every trap will cause a heavy sweep.\n"
- "# NOTE: successive identical traps (>10) are suppressed\n"
- "sweep_on_trap %s\n\n",
- p_opts->sweep_interval,
- p_opts->reassign_lids ? "TRUE" : "FALSE",
- p_opts->force_heavy_sweep ? "TRUE" : "FALSE",
- p_opts->sweep_on_trap ? "TRUE" : "FALSE");
-
- fprintf(out,
- "#\n# ROUTING OPTIONS\n#\n"
- "# If TRUE count switches as link subscriptions\n"
- "port_profile_switch_nodes %s\n\n",
- p_opts->port_profile_switch_nodes ? "TRUE" : "FALSE");
-
- fprintf(out,
- "# Name of file with port guids to be ignored by port profiling\n"
- "port_prof_ignore_file %s\n\n", p_opts->port_prof_ignore_file ?
- p_opts->port_prof_ignore_file : null_str);
-
- fprintf(out,
- "# Routing engine\n"
- "# Multiple routing engines can be specified separated by\n"
- "# commas so that specific ordering of routing algorithms will\n"
- "# be tried if earlier routing engines fail.\n"
- "# Supported engines: minhop, updn, file, ftree, lash, dor\n"
- "routing_engine %s\n\n", p_opts->routing_engine_names ?
- p_opts->routing_engine_names : null_str);
-
- fprintf(out,
- "# Connect roots (use FALSE if unsure)\n"
- "connect_roots %s\n\n",
- p_opts->connect_roots ? "TRUE" : "FALSE");
-
- fprintf(out,
- "# Use unicast routing cache (use FALSE if unsure)\n"
- "use_ucast_cache %s\n\n",
- p_opts->use_ucast_cache ? "TRUE" : "FALSE");
-
- fprintf(out,
- "# Lid matrix dump file name\n"
- "lid_matrix_dump_file %s\n\n", p_opts->lid_matrix_dump_file ?
- p_opts->lid_matrix_dump_file : null_str);
-
- fprintf(out,
- "# LFTs file name\nlfts_file %s\n\n",
- p_opts->lfts_file ? p_opts->lfts_file : null_str);
-
- fprintf(out,
- "# The file holding the root node guids (for fat-tree or Up/Down)\n"
- "# One guid in each line\nroot_guid_file %s\n\n",
- p_opts->root_guid_file ? p_opts->root_guid_file : null_str);
-
- fprintf(out,
- "# The file holding the fat-tree compute node guids\n"
- "# One guid in each line\ncn_guid_file %s\n\n",
- p_opts->cn_guid_file ? p_opts->cn_guid_file : null_str);
-
- fprintf(out,
- "# The file holding the node ids which will be used by"
- " Up/Down algorithm instead\n# of GUIDs (one guid and"
- " id in each line)\nids_guid_file %s\n\n",
- p_opts->ids_guid_file ? p_opts->ids_guid_file : null_str);
-
- fprintf(out,
- "# The file holding guid routing order guids (for MinHop and Up/Down)\n"
- "guid_routing_order_file %s\n\n",
- p_opts->guid_routing_order_file ? p_opts->guid_routing_order_file : null_str);
-
- fprintf(out,
- "# SA database file name\nsa_db_file %s\n\n",
- p_opts->sa_db_file ? p_opts->sa_db_file : null_str);
-
- fprintf(out,
- "#\n# HANDOVER - MULTIPLE SMs OPTIONS\n#\n"
- "# SM priority used for deciding who is the master\n"
- "# Range goes from 0 (lowest priority) to 15 (highest).\n"
- "sm_priority %u\n\n"
- "# If TRUE other SMs on the subnet should be ignored\n"
- "ignore_other_sm %s\n\n"
- "# Timeout in [msec] between two polls of active master SM\n"
- "sminfo_polling_timeout %u\n\n"
- "# Number of failing polls of remote SM that declares it dead\n"
- "polling_retry_number %u\n\n"
- "# If TRUE honor the guid2lid file when coming out of standby\n"
- "# state, if such file exists and is valid\n"
- "honor_guid2lid_file %s\n\n",
- p_opts->sm_priority,
- p_opts->ignore_other_sm ? "TRUE" : "FALSE",
- p_opts->sminfo_polling_timeout,
- p_opts->polling_retry_number,
- p_opts->honor_guid2lid_file ? "TRUE" : "FALSE");
-
- fprintf(out,
- "#\n# TIMING AND THREADING OPTIONS\n#\n"
- "# Maximum number of SMPs sent in parallel\n"
- "max_wire_smps %u\n\n"
- "# The maximum time in [msec] allowed for a transaction to complete\n"
- "transaction_timeout %u\n\n"
- "# Maximal time in [msec] a message can stay in the incoming message queue.\n"
- "# If there is more than one message in the queue and the last message\n"
- "# stayed in the queue more than this value, any SA request will be\n"
- "# immediately returned with a BUSY status.\n"
- "max_msg_fifo_timeout %u\n\n"
- "# Use a single thread for handling SA queries\n"
- "single_thread %s\n\n",
- p_opts->max_wire_smps,
- p_opts->transaction_timeout,
- p_opts->max_msg_fifo_timeout,
- p_opts->single_thread ? "TRUE" : "FALSE");
-
- fprintf(out,
- "#\n# MISC OPTIONS\n#\n"
- "# Daemon mode\n"
- "daemon %s\n\n"
- "# SM Inactive\n"
- "sm_inactive %s\n\n"
- "# Babbling Port Policy\n"
- "babbling_port_policy %s\n\n",
- p_opts->daemon ? "TRUE" : "FALSE",
- p_opts->sm_inactive ? "TRUE" : "FALSE",
- p_opts->babbling_port_policy ? "TRUE" : "FALSE");
-
-#ifdef ENABLE_OSM_PERF_MGR
- fprintf(out,
- "#\n# Performance Manager Options\n#\n"
- "# perfmgr enable\n"
- "perfmgr %s\n\n"
- "# perfmgr redirection enable\n"
- "perfmgr_redir %s\n\n"
- "# sweep time in seconds\n"
- "perfmgr_sweep_time_s %u\n\n"
- "# Max outstanding queries\n"
- "perfmgr_max_outstanding_queries %u\n\n",
- p_opts->perfmgr ? "TRUE" : "FALSE",
- p_opts->perfmgr_redir ? "TRUE" : "FALSE",
- p_opts->perfmgr_sweep_time_s,
- p_opts->perfmgr_max_outstanding_queries);
-
- fprintf(out,
- "#\n# Event DB Options\n#\n"
- "# Dump file to dump the events to\n"
- "event_db_dump_file %s\n\n", p_opts->event_db_dump_file ?
- p_opts->event_db_dump_file : null_str);
-#endif /* ENABLE_OSM_PERF_MGR */
-
- fprintf(out,
- "#\n# Event Plugin Options\n#\n"
- "event_plugin_name %s\n\n", p_opts->event_plugin_name ?
- p_opts->event_plugin_name : null_str);
-
- fprintf(out,
- "#\n# Node name map for mapping node's to more descriptive node descriptions\n"
- "# (man ibnetdiscover for more information)\n#\n"
- "node_name_map_name %s\n\n", p_opts->node_name_map_name ?
- p_opts->node_name_map_name : null_str);
-
- fprintf(out,
- "#\n# DEBUG FEATURES\n#\n"
- "# The log flags used\n"
- "log_flags 0x%02x\n\n"
- "# Force flush of the log file after each log message\n"
- "force_log_flush %s\n\n"
- "# Log file to be used\n"
- "log_file %s\n\n"
- "# Limit the size of the log file in MB. If overrun, log is restarted\n"
- "log_max_size %lu\n\n"
- "# If TRUE will accumulate the log over multiple OpenSM sessions\n"
- "accum_log_file %s\n\n"
- "# The directory to hold the file OpenSM dumps\n"
- "dump_files_dir %s\n\n"
- "# If TRUE enables new high risk options and hardware specific quirks\n"
- "enable_quirks %s\n\n"
- "# If TRUE disables client reregistration\n"
- "no_clients_rereg %s\n\n"
- "# If TRUE OpenSM should disable multicast support and\n"
- "# no multicast routing is performed if TRUE\n"
- "disable_multicast %s\n\n"
- "# If TRUE opensm will exit on fatal initialization issues\n"
- "exit_on_fatal %s\n\n" "# console [off|local"
-#ifdef ENABLE_OSM_CONSOLE_SOCKET
- "|loopback|socket]\n"
-#else
- "]\n"
-#endif
- "console %s\n\n"
- "# Telnet port for console (default %d)\n"
- "console_port %d\n\n",
- p_opts->log_flags,
- p_opts->force_log_flush ? "TRUE" : "FALSE",
- p_opts->log_file,
- p_opts->log_max_size/1024/1024,
- p_opts->accum_log_file ? "TRUE" : "FALSE",
- p_opts->dump_files_dir,
- p_opts->enable_quirks ? "TRUE" : "FALSE",
- p_opts->no_clients_rereg ? "TRUE" : "FALSE",
- p_opts->disable_multicast ? "TRUE" : "FALSE",
- p_opts->exit_on_fatal ? "TRUE" : "FALSE",
- p_opts->console,
- OSM_DEFAULT_CONSOLE_PORT, p_opts->console_port);
-
- fprintf(out,
- "#\n# QoS OPTIONS\n#\n"
- "# Enable QoS setup\n"
- "qos %s\n\n"
- "# QoS policy file to be used\n"
- "qos_policy_file %s\n\n",
- p_opts->qos ? "TRUE" : "FALSE", p_opts->qos_policy_file);
-
- subn_dump_qos_options(out,
- "QoS default options", "qos",
- &p_opts->qos_options);
- fprintf(out, "\n");
- subn_dump_qos_options(out,
- "QoS CA options", "qos_ca",
- &p_opts->qos_ca_options);
- fprintf(out, "\n");
- subn_dump_qos_options(out,
- "QoS Switch Port 0 options", "qos_sw0",
- &p_opts->qos_sw0_options);
- fprintf(out, "\n");
- subn_dump_qos_options(out,
- "QoS Switch external ports options", "qos_swe",
- &p_opts->qos_swe_options);
- fprintf(out, "\n");
- subn_dump_qos_options(out,
- "QoS Router ports options", "qos_rtr",
- &p_opts->qos_rtr_options);
- fprintf(out, "\n");
-
- fprintf(out,
- "# Prefix routes file name\n"
- "prefix_routes_file %s\n\n",
- p_opts->prefix_routes_file);
-
- fprintf(out,
- "#\n# IPv6 Solicited Node Multicast (SNM) Options\n#\n"
- "consolidate_ipv6_snm_req %s\n\n",
- p_opts->consolidate_ipv6_snm_req ? "TRUE" : "FALSE");
-
- /* optional string attributes ... */
-
- return 0;
-}
-
-int osm_subn_write_conf_file(char *file_name, IN osm_subn_opt_t *const p_opts)
-{
- FILE *opts_file;
-
- opts_file = fopen(file_name, "w");
- if (!opts_file) {
- printf("cannot open file \'%s\' for writing: %s\n",
- file_name, strerror(errno));
- return -1;
- }
-
- if (osm_subn_output_conf(opts_file, p_opts) < 0)
- return -1;
-
- fclose(opts_file);
-
- return 0;
-}
diff --git a/contrib/ofed/management/opensm/opensm/osm_sw_info_rcv.c b/contrib/ofed/management/opensm/opensm/osm_sw_info_rcv.c
deleted file mode 100644
index ce86adb..0000000
--- a/contrib/ofed/management/opensm/opensm/osm_sw_info_rcv.c
+++ /dev/null
@@ -1,506 +0,0 @@
-/*
- * Copyright (c) 2004-2008 Voltaire, Inc. All rights reserved.
- * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved.
- * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- */
-
-/*
- * Abstract:
- * Implementation of osm_si_rcv_t.
- * This object represents the SwitchInfo Receiver object.
- * This object is part of the opensm family of objects.
- */
-
-#if HAVE_CONFIG_H
-# include <config.h>
-#endif /* HAVE_CONFIG_H */
-
-#include <string.h>
-#include <iba/ib_types.h>
-#include <complib/cl_qmap.h>
-#include <complib/cl_passivelock.h>
-#include <complib/cl_debug.h>
-#include <opensm/osm_log.h>
-#include <opensm/osm_switch.h>
-#include <opensm/osm_subnet.h>
-#include <opensm/osm_helper.h>
-#include <opensm/osm_opensm.h>
-
-/**********************************************************************
- The plock must be held before calling this function.
-**********************************************************************/
-static void
-__osm_si_rcv_get_port_info(IN osm_sm_t * sm, IN osm_switch_t * const p_sw)
-{
- osm_madw_context_t context;
- uint8_t port_num;
- osm_physp_t *p_physp;
- osm_node_t *p_node;
- uint8_t num_ports;
- ib_api_status_t status = IB_SUCCESS;
-
- OSM_LOG_ENTER(sm->p_log);
-
- CL_ASSERT(p_sw);
-
- p_node = p_sw->p_node;
-
- CL_ASSERT(osm_node_get_type(p_node) == IB_NODE_TYPE_SWITCH);
-
- /*
- Request PortInfo attribute for each port on the switch.
- */
- p_physp = osm_node_get_physp_ptr(p_node, 0);
-
- context.pi_context.node_guid = osm_node_get_node_guid(p_node);
- context.pi_context.port_guid = osm_physp_get_port_guid(p_physp);
- context.pi_context.set_method = FALSE;
- context.pi_context.light_sweep = FALSE;
- context.pi_context.active_transition = FALSE;
-
- num_ports = osm_node_get_num_physp(p_node);
-
- for (port_num = 0; port_num < num_ports; port_num++) {
- status = osm_req_get(sm, osm_physp_get_dr_path_ptr(p_physp),
- IB_MAD_ATTR_PORT_INFO, cl_hton32(port_num),
- CL_DISP_MSGID_NONE, &context);
- if (status != IB_SUCCESS)
- /* continue the loop despite the error */
- OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR 3602: "
- "Failure initiating PortInfo request (%s)\n",
- ib_get_err_str(status));
- }
-
- OSM_LOG_EXIT(sm->p_log);
-}
-
-#if 0
-/**********************************************************************
- The plock must be held before calling this function.
-**********************************************************************/
-static void
-__osm_si_rcv_get_fwd_tbl(IN osm_sm_t * sm, IN osm_switch_t * const p_sw)
-{
- osm_madw_context_t context;
- osm_dr_path_t *p_dr_path;
- osm_physp_t *p_physp;
- osm_node_t *p_node;
- uint32_t block_id_ho;
- uint32_t max_block_id_ho;
- ib_api_status_t status = IB_SUCCESS;
-
- OSM_LOG_ENTER(sm->p_log);
-
- CL_ASSERT(p_sw);
-
- p_node = p_sw->p_node;
-
- CL_ASSERT(osm_node_get_type(p_node) == IB_NODE_TYPE_SWITCH);
-
- context.lft_context.node_guid = osm_node_get_node_guid(p_node);
- context.lft_context.set_method = FALSE;
-
- max_block_id_ho = osm_switch_get_max_block_id_in_use(p_sw);
-
- p_physp = osm_node_get_physp_ptr(p_node, 0);
- p_dr_path = osm_physp_get_dr_path_ptr(p_physp);
-
- for (block_id_ho = 0; block_id_ho <= max_block_id_ho; block_id_ho++) {
- OSM_LOG(sm->p_log, OSM_LOG_DEBUG,
- "Retrieving FT block %u\n", block_id_ho);
-
- status = osm_req_get(sm, p_dr_path, IB_MAD_ATTR_LIN_FWD_TBL,
- cl_hton32(block_id_ho),
- CL_DISP_MSGID_NONE, &context);
- if (status != IB_SUCCESS)
- /* continue the loop despite the error */
- OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR 3603: "
- "Failure initiating PortInfo request (%s)\n",
- ib_get_err_str(status));
- }
-
- OSM_LOG_EXIT(sm->p_log);
-}
-
-/**********************************************************************
- The plock must be held before calling this function.
-**********************************************************************/
-static void
-__osm_si_rcv_get_mcast_fwd_tbl(IN osm_sm_t * sm, IN osm_switch_t * const p_sw)
-{
- osm_madw_context_t context;
- osm_dr_path_t *p_dr_path;
- osm_physp_t *p_physp;
- osm_node_t *p_node;
- osm_mcast_tbl_t *p_tbl;
- uint32_t block_id_ho;
- uint32_t max_block_id_ho;
- uint32_t position;
- uint32_t max_position;
- uint32_t attr_mod_ho;
- ib_api_status_t status = IB_SUCCESS;
-
- OSM_LOG_ENTER(sm->p_log);
-
- CL_ASSERT(p_sw);
-
- p_node = p_sw->p_node;
-
- CL_ASSERT(osm_node_get_type(p_node) == IB_NODE_TYPE_SWITCH);
-
- if (osm_switch_get_mcast_fwd_tbl_size(p_sw) == 0) {
- OSM_LOG(sm->p_log, OSM_LOG_DEBUG,
- "Multicast not supported by switch 0x%016" PRIx64 "\n",
- cl_ntoh64(osm_node_get_node_guid(p_node)));
- goto Exit;
- }
-
- context.mft_context.node_guid = osm_node_get_node_guid(p_node);
- context.mft_context.set_method = FALSE;
-
- p_tbl = osm_switch_get_mcast_tbl_ptr(p_sw);
- max_block_id_ho = osm_mcast_tbl_get_max_block(p_tbl);
-
- if (max_block_id_ho > IB_MCAST_MAX_BLOCK_ID) {
- OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR 3609: "
- "Out-of-range mcast block size = %u on switch 0x%016"
- PRIx64 "\n", max_block_id_ho,
- cl_ntoh64(osm_node_get_node_guid(p_node)));
- goto Exit;
- }
-
- max_position = osm_mcast_tbl_get_max_position(p_tbl);
-
- CL_ASSERT(max_position <= IB_MCAST_POSITION_MAX);
-
- OSM_LOG(sm->p_log, OSM_LOG_DEBUG,
- "Max MFT block = %u, Max position = %u\n", max_block_id_ho,
- max_position);
-
- p_physp = osm_node_get_physp_ptr(p_node, 0);
- p_dr_path = osm_physp_get_dr_path_ptr(p_physp);
-
- for (block_id_ho = 0; block_id_ho <= max_block_id_ho; block_id_ho++) {
- OSM_LOG(sm->p_log, OSM_LOG_DEBUG,
- "Retrieving MFT block %u\n", block_id_ho);
-
- for (position = 0; position <= max_position; position++) {
- OSM_LOG(sm->p_log, OSM_LOG_DEBUG,
- "Retrieving MFT position %u\n", position);
-
- attr_mod_ho =
- block_id_ho | position << IB_MCAST_POSITION_SHIFT;
- status =
- osm_req_get(sm, p_dr_path,
- IB_MAD_ATTR_MCAST_FWD_TBL,
- cl_hton32(attr_mod_ho),
- CL_DISP_MSGID_NONE, &context);
- if (status != IB_SUCCESS)
- /* continue the loop despite the error */
- OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR 3607: "
- "Failure initiating PortInfo request (%s)\n",
- ib_get_err_str(status));
- }
- }
-
-Exit:
- OSM_LOG_EXIT(sm->p_log);
-}
-#endif
-
-/**********************************************************************
- Lock must be held on entry to this function.
-**********************************************************************/
-static void
-__osm_si_rcv_process_new(IN osm_sm_t * sm,
- IN osm_node_t * const p_node,
- IN const osm_madw_t * const p_madw)
-{
- osm_switch_t *p_sw;
- osm_switch_t *p_check;
- ib_switch_info_t *p_si;
- ib_smp_t *p_smp;
- cl_qmap_t *p_sw_guid_tbl;
-
- CL_ASSERT(sm);
-
- OSM_LOG_ENTER(sm->p_log);
-
- CL_ASSERT(p_madw);
-
- p_sw_guid_tbl = &sm->p_subn->sw_guid_tbl;
-
- p_smp = osm_madw_get_smp_ptr(p_madw);
- p_si = (ib_switch_info_t *) ib_smp_get_payload_ptr(p_smp);
-
- osm_dump_switch_info(sm->p_log, p_si, OSM_LOG_DEBUG);
-
- /*
- Allocate a new switch object for this switch,
- and place it in the switch table.
- */
- p_sw = osm_switch_new(p_node, p_madw);
- if (p_sw == NULL) {
- OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR 3608: "
- "Unable to allocate new switch object\n");
- goto Exit;
- }
-
- /* set subnet max mlid to the minimum MulticastFDBCap of all switches */
- if (p_sw->mcast_tbl.max_mlid_ho < sm->p_subn->max_mcast_lid_ho) {
- sm->p_subn->max_mcast_lid_ho = p_sw->mcast_tbl.max_mlid_ho;
- OSM_LOG(sm->p_log, OSM_LOG_VERBOSE,
- "Subnet max multicast lid is 0x%X\n",
- sm->p_subn->max_mcast_lid_ho);
- }
-
- /* set subnet max unicast lid to the minimum LinearFDBCap of all switches */
- if (cl_ntoh16(p_si->lin_cap) < sm->p_subn->max_ucast_lid_ho) {
- sm->p_subn->max_ucast_lid_ho = cl_ntoh16(p_si->lin_cap);
- OSM_LOG(sm->p_log, OSM_LOG_VERBOSE,
- "Subnet max unicast lid is 0x%X\n",
- sm->p_subn->max_ucast_lid_ho);
- }
-
- p_check = (osm_switch_t *) cl_qmap_insert(p_sw_guid_tbl,
- osm_node_get_node_guid
- (p_node), &p_sw->map_item);
-
- if (p_check != p_sw) {
- /*
- This shouldn't happen since we hold the lock!
- */
- OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR 3605: "
- "Unable to add new switch object to database\n");
- osm_switch_delete(&p_sw);
- goto Exit;
- }
-
- p_node->sw = p_sw;
-
- /*
- Update the switch info according to the
- info we just received.
- */
- osm_switch_set_switch_info(p_sw, p_si);
- p_sw->discovery_count++;
-
- /*
- Get the PortInfo attribute for every port.
- */
- __osm_si_rcv_get_port_info(sm, p_sw);
-
- /*
- Don't bother retrieving the current unicast and multicast tables
- from the switches. The current version of SM does
- not support silent take-over of an existing multicast
- configuration.
-
- Gathering the multicast tables can also generate large amounts
- of extra subnet-init traffic.
-
- The code to retrieve the tables was fully debugged.
- */
-#if 0
- __osm_si_rcv_get_fwd_tbl(sm, p_sw);
- if (!sm->p_subn->opt.disable_multicast)
- __osm_si_rcv_get_mcast_fwd_tbl(sm, p_sw);
-#endif
-
-Exit:
- OSM_LOG_EXIT(sm->p_log);
-}
-
-/**********************************************************************
- Lock must be held on entry to this function.
- Return 1 if the caller is expected to send a change_detected event.
- this can not be done internally as the event needs the lock...
-**********************************************************************/
-static boolean_t
-__osm_si_rcv_process_existing(IN osm_sm_t * sm,
- IN osm_node_t * const p_node,
- IN const osm_madw_t * const p_madw)
-{
- osm_switch_t *p_sw = p_node->sw;
- ib_switch_info_t *p_si;
- osm_si_context_t *p_si_context;
- ib_smp_t *p_smp;
- boolean_t is_change_detected = FALSE;
-
- OSM_LOG_ENTER(sm->p_log);
-
- CL_ASSERT(p_madw);
-
- p_smp = osm_madw_get_smp_ptr(p_madw);
- p_si = (ib_switch_info_t *) ib_smp_get_payload_ptr(p_smp);
- p_si_context = osm_madw_get_si_context_ptr(p_madw);
-
- if (p_si_context->set_method) {
- OSM_LOG(sm->p_log, OSM_LOG_DEBUG,
- "Received logical SetResp()\n");
-
- osm_switch_set_switch_info(p_sw, p_si);
- } else {
- OSM_LOG(sm->p_log, OSM_LOG_DEBUG,
- "Received logical GetResp()\n");
-
- osm_switch_set_switch_info(p_sw, p_si);
-
- /*
- Check the port state change bit. If true, then this switch
- has seen a port state transition, so continue probing.
- */
- if (p_si_context->light_sweep == TRUE) {
- /* This is a light sweep */
- /* If the mad was returned with an error -
- signal a change to the state manager. */
- if (ib_smp_get_status(p_smp) != 0) {
- OSM_LOG(sm->p_log, OSM_LOG_VERBOSE,
- "GetResp() received with error in light sweep. "
- "Commencing heavy sweep\n");
- is_change_detected = TRUE;
- } else {
- /*
- If something changed, then just signal the
- state manager. Don't attempt to probe
- further during a light sweep.
- */
- if (ib_switch_info_get_state_change(p_si)) {
- osm_dump_switch_info(sm->p_log, p_si,
- OSM_LOG_DEBUG);
- is_change_detected = TRUE;
- }
- }
- } else {
- /*
- This is a heavy sweep. Get information regardless
- of the state change bit.
- */
- p_sw->discovery_count++;
- OSM_LOG(sm->p_log, OSM_LOG_VERBOSE,
- "discovery_count is:%u\n",
- p_sw->discovery_count);
-
- /* If this is the first discovery - then get the port_info */
- if (p_sw->discovery_count == 1)
- __osm_si_rcv_get_port_info(sm, p_sw);
- else
- OSM_LOG(sm->p_log, OSM_LOG_DEBUG,
- "Not discovering again through switch:0x%"
- PRIx64 "\n",
- osm_node_get_node_guid(p_sw->p_node));
- }
- }
-
- OSM_LOG_EXIT(sm->p_log);
- return is_change_detected;
-}
-
-/**********************************************************************
- **********************************************************************/
-void osm_si_rcv_process(IN void *context, IN void *data)
-{
- osm_sm_t *sm = context;
- osm_madw_t *p_madw = data;
- ib_switch_info_t *p_si;
- ib_smp_t *p_smp;
- osm_node_t *p_node;
- ib_net64_t node_guid;
- osm_si_context_t *p_context;
-
- CL_ASSERT(sm);
-
- OSM_LOG_ENTER(sm->p_log);
-
- CL_ASSERT(p_madw);
-
- p_smp = osm_madw_get_smp_ptr(p_madw);
- p_si = (ib_switch_info_t *) ib_smp_get_payload_ptr(p_smp);
-
- /*
- Acquire the switch object and add the switch info.
- */
- p_context = osm_madw_get_si_context_ptr(p_madw);
-
- node_guid = p_context->node_guid;
-
- OSM_LOG(sm->p_log, OSM_LOG_DEBUG,
- "Switch GUID 0x%016" PRIx64 ", TID 0x%" PRIx64 "\n",
- cl_ntoh64(node_guid), cl_ntoh64(p_smp->trans_id));
-
- CL_PLOCK_EXCL_ACQUIRE(sm->p_lock);
-
- p_node = osm_get_node_by_guid(sm->p_subn, node_guid);
- if (!p_node)
- OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR 3606: "
- "SwitchInfo received for nonexistent node "
- "with GUID 0x%" PRIx64 "\n", cl_ntoh64(node_guid));
- else {
-
- /*
- Hack for bad value in Mellanox switch
- */
- if (cl_ntoh16(p_si->lin_top) > IB_LID_UCAST_END_HO) {
- OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR 3610: "
- "\n\t\t\t\tBad LinearFDBTop value = 0x%X "
- "on switch 0x%" PRIx64
- "\n\t\t\t\tForcing internal correction to 0x%X\n",
- cl_ntoh16(p_si->lin_top),
- cl_ntoh64(osm_node_get_node_guid(p_node)), 0);
-
- p_si->lin_top = 0;
- }
-
- /*
- Acquire the switch object for this switch.
- */
- if (!p_node->sw) {
- __osm_si_rcv_process_new(sm, p_node, p_madw);
- /*
- A new switch was found during the sweep so we need
- to ignore the current LFT settings.
- */
- sm->p_subn->ignore_existing_lfts = TRUE;
- } else {
- /* we might get back a request for signaling change was detected */
- if (__osm_si_rcv_process_existing(sm, p_node, p_madw)) {
- CL_PLOCK_RELEASE(sm->p_lock);
- sm->p_subn->force_heavy_sweep = TRUE;
- goto Exit;
- }
- }
- }
-
- CL_PLOCK_RELEASE(sm->p_lock);
-Exit:
- OSM_LOG_EXIT(sm->p_log);
-}
diff --git a/contrib/ofed/management/opensm/opensm/osm_switch.c b/contrib/ofed/management/opensm/opensm/osm_switch.c
deleted file mode 100644
index 9807791..0000000
--- a/contrib/ofed/management/opensm/opensm/osm_switch.c
+++ /dev/null
@@ -1,667 +0,0 @@
-/*
- * Copyright (c) 2004-2008 Voltaire, Inc. All rights reserved.
- * Copyright (c) 2002-2008 Mellanox Technologies LTD. All rights reserved.
- * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- */
-
-/*
- * Abstract:
- * Implementation of osm_switch_t.
- * This object represents an Infiniband switch.
- * This object is part of the opensm family of objects.
- */
-
-#if HAVE_CONFIG_H
-# include <config.h>
-#endif /* HAVE_CONFIG_H */
-
-#include <stdlib.h>
-#include <string.h>
-#include <complib/cl_math.h>
-#include <iba/ib_types.h>
-#include <opensm/osm_switch.h>
-
-/**********************************************************************
- **********************************************************************/
-cl_status_t
-osm_switch_set_hops(IN osm_switch_t * const p_sw,
- IN const uint16_t lid_ho,
- IN const uint8_t port_num, IN const uint8_t num_hops)
-{
- if (lid_ho > p_sw->max_lid_ho)
- return -1;
- if (!p_sw->hops[lid_ho]) {
- p_sw->hops[lid_ho] = malloc(p_sw->num_ports);
- if (!p_sw->hops[lid_ho])
- return -1;
- memset(p_sw->hops[lid_ho], OSM_NO_PATH, p_sw->num_ports);
- }
-
- p_sw->hops[lid_ho][port_num] = num_hops;
- if (p_sw->hops[lid_ho][0] > num_hops)
- p_sw->hops[lid_ho][0] = num_hops;
-
- return 0;
-}
-
-/**********************************************************************
- **********************************************************************/
-static ib_api_status_t
-osm_switch_init(IN osm_switch_t * const p_sw,
- IN osm_node_t * const p_node,
- IN const osm_madw_t * const p_madw)
-{
- ib_api_status_t status = IB_SUCCESS;
- ib_switch_info_t *p_si;
- ib_smp_t *p_smp;
- uint8_t num_ports;
- uint32_t port_num;
-
- p_smp = osm_madw_get_smp_ptr(p_madw);
- p_si = (ib_switch_info_t *) ib_smp_get_payload_ptr(p_smp);
- num_ports = osm_node_get_num_physp(p_node);
-
- CL_ASSERT(p_smp->attr_id == IB_MAD_ATTR_SWITCH_INFO);
-
- p_sw->p_node = p_node;
- p_sw->switch_info = *p_si;
- p_sw->num_ports = num_ports;
- p_sw->need_update = 2;
-
- /* Initiate the linear forwarding table */
-
- if (!p_si->lin_cap) {
- /* This switch does not support linear forwarding tables */
- status = IB_UNSUPPORTED;
- goto Exit;
- }
-
- p_sw->lft = malloc(IB_LID_UCAST_END_HO + 1);
- if (!p_sw->lft) {
- status = IB_INSUFFICIENT_MEMORY;
- goto Exit;
- }
-
- /* Initialize the table to OSM_NO_PATH, which is "invalid port" */
- memset(p_sw->lft, OSM_NO_PATH, IB_LID_UCAST_END_HO + 1);
-
- p_sw->p_prof = malloc(sizeof(*p_sw->p_prof) * num_ports);
- if (p_sw->p_prof == NULL) {
- status = IB_INSUFFICIENT_MEMORY;
- goto Exit;
- }
-
- memset(p_sw->p_prof, 0, sizeof(*p_sw->p_prof) * num_ports);
-
- status = osm_mcast_tbl_init(&p_sw->mcast_tbl,
- osm_node_get_num_physp(p_node),
- cl_ntoh16(p_si->mcast_cap));
- if (status != IB_SUCCESS)
- goto Exit;
-
- for (port_num = 0; port_num < num_ports; port_num++)
- osm_port_prof_construct(&p_sw->p_prof[port_num]);
-
-Exit:
- return (status);
-}
-
-/**********************************************************************
- **********************************************************************/
-void osm_switch_delete(IN OUT osm_switch_t ** const pp_sw)
-{
- osm_switch_t *p_sw = *pp_sw;
- unsigned i;
-
- osm_mcast_tbl_destroy(&p_sw->mcast_tbl);
- free(p_sw->p_prof);
- if (p_sw->lft)
- free(p_sw->lft);
- if (p_sw->new_lft)
- free(p_sw->new_lft);
- if (p_sw->hops) {
- for (i = 0; i < p_sw->num_hops; i++)
- if (p_sw->hops[i])
- free(p_sw->hops[i]);
- free(p_sw->hops);
- }
- free(*pp_sw);
- *pp_sw = NULL;
-}
-
-/**********************************************************************
- **********************************************************************/
-osm_switch_t *osm_switch_new(IN osm_node_t * const p_node,
- IN const osm_madw_t * const p_madw)
-{
- ib_api_status_t status;
- osm_switch_t *p_sw;
-
- CL_ASSERT(p_madw);
- CL_ASSERT(p_node);
-
- p_sw = (osm_switch_t *) malloc(sizeof(*p_sw));
- if (p_sw) {
- memset(p_sw, 0, sizeof(*p_sw));
- status = osm_switch_init(p_sw, p_node, p_madw);
- if (status != IB_SUCCESS)
- osm_switch_delete(&p_sw);
- }
-
- return (p_sw);
-}
-
-/**********************************************************************
- **********************************************************************/
-boolean_t
-osm_switch_get_lft_block(IN const osm_switch_t * const p_sw,
- IN const uint16_t block_id,
- OUT uint8_t * const p_block)
-{
- uint16_t base_lid_ho = block_id * IB_SMP_DATA_SIZE;
-
- CL_ASSERT(p_sw);
- CL_ASSERT(p_block);
-
- if (base_lid_ho > p_sw->max_lid_ho)
- return FALSE;
-
- CL_ASSERT(base_lid_ho + IB_SMP_DATA_SIZE <= IB_LID_UCAST_END_HO);
- memcpy(p_block, &(p_sw->lft[base_lid_ho]), IB_SMP_DATA_SIZE);
- return TRUE;
-}
-
-/**********************************************************************
- **********************************************************************/
-static struct osm_remote_node *
-osm_switch_find_guid_common(IN const osm_switch_t * const p_sw,
- IN struct osm_remote_guids_count *r,
- IN uint8_t port_num,
- IN int find_sys_guid,
- IN int find_node_guid)
-{
- struct osm_remote_node *p_remote_guid = NULL;
- osm_physp_t *p_physp;
- osm_physp_t *p_rem_physp;
- osm_node_t *p_rem_node;
- uint64_t sys_guid;
- uint64_t node_guid;
- int i;
-
- CL_ASSERT(p_sw);
-
- p_physp = osm_node_get_physp_ptr(p_sw->p_node, port_num);
- p_rem_physp = osm_physp_get_remote(p_physp);
- p_rem_node = osm_physp_get_node_ptr(p_rem_physp);
- sys_guid = p_rem_node->node_info.sys_guid;
- node_guid = p_rem_node->node_info.node_guid;
-
- for (i = 0; i < r->count; i++) {
- if ((!find_sys_guid
- || r->guids[i].node->node_info.sys_guid == sys_guid)
- && (!find_node_guid
- || r->guids[i].node->node_info.node_guid == node_guid)) {
- p_remote_guid = &r->guids[i];
- break;
- }
- }
-
- return p_remote_guid;
-}
-
-static struct osm_remote_node *
-osm_switch_find_sys_guid_count(IN const osm_switch_t * const p_sw,
- IN struct osm_remote_guids_count *r,
- IN uint8_t port_num)
-{
- return osm_switch_find_guid_common(p_sw, r, port_num, 1, 0);
-}
-
-static struct osm_remote_node *
-osm_switch_find_node_guid_count(IN const osm_switch_t * const p_sw,
- IN struct osm_remote_guids_count *r,
- IN uint8_t port_num)
-{
- return osm_switch_find_guid_common(p_sw, r, port_num, 0, 1);
-}
-
-/**********************************************************************
- **********************************************************************/
-uint8_t
-osm_switch_recommend_path(IN const osm_switch_t * const p_sw,
- IN osm_port_t * p_port,
- IN const uint16_t lid_ho,
- IN unsigned start_from,
- IN const boolean_t ignore_existing,
- IN const boolean_t dor)
-{
- /*
- We support an enhanced LMC aware routing mode:
- In the case of LMC > 0, we can track the remote side
- system and node for all of the lids of the target
- and try and avoid routing again through the same
- system / node.
-
- If this procedure is provided with the tracking array
- and counter we can conduct this algorithm.
- */
- boolean_t routing_for_lmc = (p_port->priv != NULL);
- uint16_t base_lid;
- uint8_t hops;
- uint8_t least_hops;
- uint8_t port_num;
- uint8_t num_ports;
- uint32_t least_paths = 0xFFFFFFFF;
- unsigned i;
- /*
- The follwing will track the least paths if the
- route should go through a new system/node
- */
- uint32_t least_paths_other_sys = 0xFFFFFFFF;
- uint32_t least_paths_other_nodes = 0xFFFFFFFF;
- uint32_t least_forwarded_to = 0xFFFFFFFF;
- uint32_t check_count;
- uint8_t best_port = 0;
- /*
- These vars track the best port if it connects to
- not used system/node.
- */
- uint8_t best_port_other_sys = 0;
- uint8_t best_port_other_node = 0;
- boolean_t port_found = FALSE;
- osm_physp_t *p_physp;
- osm_physp_t *p_rem_physp;
- osm_node_t *p_rem_node;
- osm_node_t *p_rem_node_first = NULL;
- struct osm_remote_node *p_remote_guid = NULL;
-
- CL_ASSERT(lid_ho > 0);
-
- if (p_port->p_node->sw) {
- if (p_port->p_node->sw == p_sw)
- return 0;
- base_lid = osm_port_get_base_lid(p_port);
- } else {
- p_physp = p_port->p_physp;
- if (!p_physp || !p_physp->p_remote_physp ||
- !p_physp->p_remote_physp->p_node->sw)
- return OSM_NO_PATH;
-
- if (p_physp->p_remote_physp->p_node->sw == p_sw)
- return p_physp->p_remote_physp->port_num;
- base_lid =
- osm_node_get_base_lid(p_physp->p_remote_physp->p_node, 0);
- }
- base_lid = cl_ntoh16(base_lid);
-
- num_ports = p_sw->num_ports;
-
- least_hops = osm_switch_get_least_hops(p_sw, base_lid);
- if (least_hops == OSM_NO_PATH)
- return (OSM_NO_PATH);
-
- /*
- First, inquire with the forwarding table for an existing
- route. If one is found, honor it unless:
- 1. the ignore existing flag is set.
- 2. the physical port is not a valid one or not healthy
- 3. the physical port has a remote port (the link is up)
- 4. the port has min-hops to the target (avoid loops)
- */
- if (!ignore_existing) {
- port_num = osm_switch_get_port_by_lid(p_sw, lid_ho);
-
- if (port_num != OSM_NO_PATH) {
- CL_ASSERT(port_num < num_ports);
-
- p_physp =
- osm_node_get_physp_ptr(p_sw->p_node, port_num);
- /*
- Don't be too trusting of the current forwarding table!
- Verify that the port number is legal and that the
- LID is reachable through this port.
- */
- if (p_physp && osm_physp_is_healthy(p_physp) &&
- osm_physp_get_remote(p_physp)) {
- hops =
- osm_switch_get_hop_count(p_sw, base_lid,
- port_num);
- /*
- If we aren't using pre-defined user routes
- function, then we need to make sure that the
- current path is the minimum one. In case of
- having such a user function - this check will
- not be done, and the old routing will be used.
- Note: This means that it is the user's job to
- clean all data in the forwarding tables that
- he wants to be overridden by the minimum
- hop function.
- */
- if (hops == least_hops)
- return (port_num);
- }
- }
- }
-
- /*
- This algorithm selects a port based on a static load balanced
- selection across equal hop-count ports.
- There is lots of room for improved sophistication here,
- possibly guided by user configuration info.
- */
-
- /*
- OpenSM routing is "local" - not considering a full lid to lid
- path. As such we can not guarantee a path will not loop if we
- do not always follow least hops.
- So we must abort if not least hops.
- */
-
- /* port number starts with one and num_ports is 1 + num phys ports */
- for (i = start_from; i < start_from + num_ports; i++) {
- port_num = i%num_ports;
- if (!port_num ||
- osm_switch_get_hop_count(p_sw, base_lid, port_num) !=
- least_hops)
- continue;
-
- /* let us make sure it is not down or unhealthy */
- p_physp = osm_node_get_physp_ptr(p_sw->p_node, port_num);
- if (!p_physp || !osm_physp_is_healthy(p_physp) ||
- /*
- we require all - non sma ports to be linked
- to be routed through
- */
- !osm_physp_get_remote(p_physp))
- continue;
-
- /*
- We located a least-hop port, possibly one of many.
- For this port, check the running total count of
- the number of paths through this port. Select
- the port routing the least number of paths.
- */
- check_count =
- osm_port_prof_path_count_get(&p_sw->p_prof[port_num]);
-
- /*
- Advanced LMC routing requires tracking of the
- best port by the node connected to the other side of
- it.
- */
- if (routing_for_lmc) {
- /* Is the sys guid already used ? */
- p_remote_guid = osm_switch_find_sys_guid_count(p_sw,
- p_port->priv,
- port_num);
-
- /* If not update the least hops for this case */
- if (!p_remote_guid) {
- if (check_count < least_paths_other_sys) {
- least_paths_other_sys = check_count;
- best_port_other_sys = port_num;
- least_forwarded_to = 0;
- }
- } else { /* same sys found - try node */
- /* Else is the node guid already used ? */
- p_remote_guid = osm_switch_find_node_guid_count(p_sw,
- p_port->priv,
- port_num);
-
- /* If not update the least hops for this case */
- if (!p_remote_guid
- && check_count < least_paths_other_nodes) {
- least_paths_other_nodes = check_count;
- best_port_other_node = port_num;
- least_forwarded_to = 0;
- }
- /* else prior sys and node guid already used */
-
- } /* same sys found */
- }
-
- /* routing for LMC mode */
- /*
- the count is min but also lower then the max subscribed
- */
- if (check_count < least_paths) {
- if (dor) {
- /* Get the Remote Node */
- p_rem_physp = osm_physp_get_remote(p_physp);
- p_rem_node =
- osm_physp_get_node_ptr(p_rem_physp);
- /* use the first dimension, but spread
- * traffic out among the group of ports
- * representing that dimension */
- if (port_found) {
- if (p_rem_node != p_rem_node_first)
- continue;
- } else
- p_rem_node_first = p_rem_node;
- }
- port_found = TRUE;
- best_port = port_num;
- least_paths = check_count;
- if (routing_for_lmc
- && p_remote_guid
- && p_remote_guid->forwarded_to < least_forwarded_to)
- least_forwarded_to = p_remote_guid->forwarded_to;
- } else if (routing_for_lmc
- && p_remote_guid
- && check_count == least_paths
- && p_remote_guid->forwarded_to < least_forwarded_to) {
- least_forwarded_to = p_remote_guid->forwarded_to;
- best_port = port_num;
- }
- }
-
- if (port_found == FALSE)
- return (OSM_NO_PATH);
-
- /*
- if we are in enhanced routing mode and the best port is not
- the local port 0
- */
- if (routing_for_lmc && best_port) {
- /* Select the least hop port of the non used sys first */
- if (best_port_other_sys)
- best_port = best_port_other_sys;
- else if (best_port_other_node)
- best_port = best_port_other_node;
- }
-
- return (best_port);
-}
-
-/**********************************************************************
- **********************************************************************/
-void osm_switch_clear_hops(IN osm_switch_t * p_sw)
-{
- unsigned i;
-
- for (i = 0; i < p_sw->num_hops; i++)
- if (p_sw->hops[i])
- memset(p_sw->hops[i], OSM_NO_PATH, p_sw->num_ports);
-}
-
-/**********************************************************************
- **********************************************************************/
-int
-osm_switch_prepare_path_rebuild(IN osm_switch_t * p_sw, IN uint16_t max_lids)
-{
- uint8_t **hops;
- unsigned i;
-
- for (i = 0; i < p_sw->num_ports; i++)
- osm_port_prof_construct(&p_sw->p_prof[i]);
-
- osm_switch_clear_hops(p_sw);
-
- if (!p_sw->new_lft &&
- !(p_sw->new_lft = malloc(IB_LID_UCAST_END_HO + 1)))
- return IB_INSUFFICIENT_MEMORY;
-
- memset(p_sw->new_lft, OSM_NO_PATH, IB_LID_UCAST_END_HO + 1);
-
- if (!p_sw->hops) {
- hops = malloc((max_lids + 1) * sizeof(hops[0]));
- if (!hops)
- return -1;
- memset(hops, 0, (max_lids + 1) * sizeof(hops[0]));
- p_sw->hops = hops;
- p_sw->num_hops = max_lids + 1;
- } else if (max_lids + 1 > p_sw->num_hops) {
- uint8_t **old_hops;
-
- hops = malloc((max_lids + 1) * sizeof(hops[0]));
- if (!hops)
- return -1;
- memcpy(hops, p_sw->hops, p_sw->num_hops * sizeof(hops[0]));
- memset(hops + p_sw->num_hops, 0,
- (max_lids + 1 - p_sw->num_hops) * sizeof(hops[0]));
- old_hops = p_sw->hops;
- p_sw->hops = hops;
- p_sw->num_hops = max_lids + 1;
- free(old_hops);
- }
- p_sw->max_lid_ho = max_lids;
-
- return 0;
-}
-
-/**********************************************************************
- **********************************************************************/
-uint8_t
-osm_switch_get_port_least_hops(IN const osm_switch_t * const p_sw,
- IN const osm_port_t * p_port)
-{
- uint16_t lid;
-
- if (p_port->p_node->sw) {
- if (p_port->p_node->sw == p_sw)
- return 0;
- lid = osm_node_get_base_lid(p_port->p_node, 0);
- return osm_switch_get_least_hops(p_sw, cl_ntoh16(lid));
- } else {
- osm_physp_t *p = p_port->p_physp;
- uint8_t hops;
-
- if (!p || !p->p_remote_physp || !p->p_remote_physp->p_node->sw)
- return OSM_NO_PATH;
- if (p->p_remote_physp->p_node->sw == p_sw)
- return 1;
- lid = osm_node_get_base_lid(p->p_remote_physp->p_node, 0);
- hops = osm_switch_get_least_hops(p_sw, cl_ntoh16(lid));
- return hops != OSM_NO_PATH ? hops + 1 : OSM_NO_PATH;
- }
-}
-
-/**********************************************************************
- **********************************************************************/
-uint8_t
-osm_switch_recommend_mcast_path(IN osm_switch_t * const p_sw,
- IN osm_port_t * p_port,
- IN uint16_t const mlid_ho,
- IN boolean_t const ignore_existing)
-{
- uint16_t base_lid;
- uint8_t hops;
- uint8_t port_num;
- uint8_t num_ports;
- uint8_t least_hops;
-
- CL_ASSERT(mlid_ho >= IB_LID_MCAST_START_HO);
-
- if (p_port->p_node->sw) {
- if (p_port->p_node->sw == p_sw)
- return 0;
- base_lid = osm_port_get_base_lid(p_port);
- } else {
- osm_physp_t *p_physp = p_port->p_physp;
- if (!p_physp || !p_physp->p_remote_physp ||
- !p_physp->p_remote_physp->p_node->sw)
- return OSM_NO_PATH;
- if (p_physp->p_remote_physp->p_node->sw == p_sw)
- return p_physp->p_remote_physp->port_num;
- base_lid =
- osm_node_get_base_lid(p_physp->p_remote_physp->p_node, 0);
- }
- base_lid = cl_ntoh16(base_lid);
- num_ports = p_sw->num_ports;
-
- /*
- If the user wants us to ignore existing multicast routes,
- then simply return the shortest hop count path to the
- target port.
-
- Otherwise, return the first port that has a path to the target,
- picking from the ports that are already in the multicast group.
- */
- if (!ignore_existing) {
- for (port_num = 1; port_num < num_ports; port_num++) {
- if (!osm_mcast_tbl_is_port
- (&p_sw->mcast_tbl, mlid_ho, port_num))
- continue;
- /*
- Don't be too trusting of the current forwarding table!
- Verify that the LID is reachable through this port.
- */
- hops =
- osm_switch_get_hop_count(p_sw, base_lid, port_num);
- if (hops != OSM_NO_PATH)
- return (port_num);
- }
- }
-
- /*
- Either no existing mcast paths reach this port or we are
- ignoring existing paths.
-
- Determine the best multicast path to the target. Note that this
- algorithm is slightly different from the one used for unicast route
- recommendation. In this case (multicast), we must NOT
- perform any sort of load balancing. We MUST take the FIRST
- port found that has <= the lowest hop count path. This prevents
- more than one multicast path to the same remote switch which
- prevents a multicast loop. Multicast loops are bad since the same
- multicast packet will go around and around, inevitably creating
- a black hole that will destroy the Earth in a firey conflagration.
- */
- least_hops = osm_switch_get_least_hops(p_sw, base_lid);
- for (port_num = 1; port_num < num_ports; port_num++)
- if (osm_switch_get_hop_count(p_sw, base_lid, port_num) ==
- least_hops)
- break;
-
- CL_ASSERT(port_num < num_ports);
- return (port_num);
-}
diff --git a/contrib/ofed/management/opensm/opensm/osm_trap_rcv.c b/contrib/ofed/management/opensm/opensm/osm_trap_rcv.c
deleted file mode 100644
index 46fbad7..0000000
--- a/contrib/ofed/management/opensm/opensm/osm_trap_rcv.c
+++ /dev/null
@@ -1,714 +0,0 @@
-/*
- * Copyright (c) 2004-2008 Voltaire, Inc. All rights reserved.
- * Copyright (c) 2002-2006 Mellanox Technologies LTD. All rights reserved.
- * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- */
-
-/*
- * Abstract:
- * Implementation of osm_trap_rcv_t.
- * This object represents the Trap Receiver object.
- * This object is part of the opensm family of objects.
- */
-
-#if HAVE_CONFIG_H
-# include <config.h>
-#endif /* HAVE_CONFIG_H */
-
-#include <string.h>
-#include <iba/ib_types.h>
-#include <complib/cl_qmap.h>
-#include <complib/cl_debug.h>
-#include <opensm/osm_madw.h>
-#include <opensm/osm_log.h>
-#include <opensm/osm_node.h>
-#include <opensm/osm_helper.h>
-#include <opensm/osm_subnet.h>
-#include <opensm/osm_inform.h>
-#include <opensm/osm_opensm.h>
-
-extern void osm_req_get_node_desc(IN osm_sm_t * sm, osm_physp_t *p_physp);
-
-/**********************************************************************
- *
- * TRAP HANDLING:
- *
- * Assuming traps can be caused by bad hardware we should provide
- * a mechanism for filtering their propagation into the actual logic
- * of OpenSM such that it is not overloaded by them.
- *
- * We will provide a trap filtering mechanism with "Aging" capability.
- * This mechanism will track incoming traps, clasify them by their
- * source and content and provide back their age.
- *
- * A timer running in the background will toggle a timer counter
- * that should be referenced by the aging algorithm.
- * To provide an efficient handling of aging. We also track all traps
- * in a sorted list by their aging.
- *
- * The generic Aging Tracker mechanism is implemented in the
- * cl_aging_tracker object.
- *
- **********************************************************************/
-
-typedef struct osm_trap_agingracker_context {
- osm_log_t *p_log;
- osm_physp_t *p_physp;
-} osm_trap_aging_tracker_context_t;
-
-/**********************************************************************
- **********************************************************************/
-static osm_physp_t *get_physp_by_lid_and_num(IN osm_sm_t * sm,
- IN uint16_t lid, IN uint8_t num)
-{
- cl_ptr_vector_t *p_vec = &(sm->p_subn->port_lid_tbl);
- osm_port_t *p_port;
-
- if (lid > cl_ptr_vector_get_size(p_vec))
- return NULL;
-
- p_port = (osm_port_t *) cl_ptr_vector_get(p_vec, lid);
- if (!p_port)
- return NULL;
-
- if (osm_node_get_num_physp(p_port->p_node) < num)
- return NULL;
-
- return osm_node_get_physp_ptr(p_port->p_node, num);
-}
-
-/**********************************************************************
- **********************************************************************/
-uint64_t
-osm_trap_rcv_aging_tracker_callback(IN uint64_t key,
- IN uint32_t num_regs, IN void *context)
-{
- osm_sm_t *sm = context;
- uint16_t lid;
- uint8_t port_num;
- osm_physp_t *p_physp;
-
- OSM_LOG_ENTER(sm->p_log);
-
- if (osm_exit_flag)
- /* We got an exit flag - do nothing */
- return 0;
-
- lid = cl_ntoh16((uint16_t) ((key & 0x0000FFFF00000000ULL) >> 32));
- port_num = (uint8_t) ((key & 0x00FF000000000000ULL) >> 48);
-
- p_physp = get_physp_by_lid_and_num(sm, lid, port_num);
- if (!p_physp)
- OSM_LOG(sm->p_log, OSM_LOG_VERBOSE,
- "Cannot find port num:%u with lid:%u\n",
- port_num, lid);
- /* make sure the physp is still valid */
- /* If the health port was false - set it to true */
- else if (!osm_physp_is_healthy(p_physp)) {
- OSM_LOG(sm->p_log, OSM_LOG_VERBOSE,
- "Clearing health bit of port num:%u with lid:%u\n",
- port_num, lid);
-
- /* Clear its health bit */
- osm_physp_set_health(p_physp, TRUE);
- }
-
- OSM_LOG_EXIT(sm->p_log);
-
- /* We want to remove the event from the tracker - so
- need to return zero. */
- return 0;
-}
-
-/**********************************************************************
- * CRC calculation for notice identification
- **********************************************************************/
-
-#define CRC32_POLYNOMIAL 0xEDB88320L
-
-/* calculate the crc for a given buffer */
-static uint32_t __osm_trap_calc_crc32(void *buffer, uint32_t count)
-{
- uint32_t temp1, temp2;
- uint32_t crc = -1L;
- unsigned char *p = (unsigned char *)buffer;
- /* pre - calculated table for faster crc calculation */
- static uint32_t crc_table[256];
- static boolean_t first = TRUE;
- int i, j;
-
- /* if we need to initialize the lookup table */
- if (first) {
- /* calc the CRC table */
- for (i = 0; i <= 255; i++) {
- crc = i;
- for (j = 8; j > 0; j--)
- if (crc & 1)
- crc = (crc >> 1) ^ CRC32_POLYNOMIAL;
- else
- crc >>= 1;
- crc_table[i] = crc;
- }
- first = FALSE;
- }
-
- crc = -1L;
- /* do the calculation */
- while (count-- != 0) {
- temp1 = (crc >> 8) & 0x00FFFFFFL;
- temp2 = crc_table[((int)crc ^ *p++) & 0xFF];
- crc = temp1 ^ temp2;
- }
- return crc;
-}
-
-/********************************************************************
- ********************************************************************/
-
-/* The key is created in the following manner:
- port_num lid crc
- \______/ \___/ \___/
- 16b 16b 32b
-*/
-static void
-__osm_trap_get_key(IN uint16_t lid,
- IN uint8_t port_num,
- IN ib_mad_notice_attr_t * p_ntci, OUT uint64_t * trap_key)
-{
- uint32_t crc = 0;
-
- CL_ASSERT(trap_key);
-
- crc = __osm_trap_calc_crc32(p_ntci, sizeof(ib_mad_notice_attr_t));
- *trap_key = ((uint64_t) port_num << 48) | ((uint64_t) lid << 32) | crc;
-}
-
-/**********************************************************************
- **********************************************************************/
-static int __print_num_received(IN uint32_t num_received)
-{
- uint32_t i;
-
- /* Series is 10, 20, 50, 100, 200, 500, ... */
- i = num_received;
- while (i >= 10) {
- if (i % 10)
- break;
- i = i / 10;
- }
-
- if (i == 1 || i == 2 || i == 5)
- return 1;
- else
- return 0;
-}
-
-static int disable_port(osm_sm_t *sm, osm_physp_t *p)
-{
- uint8_t payload[IB_SMP_DATA_SIZE];
- osm_madw_context_t context;
- ib_port_info_t *pi = (ib_port_info_t *)payload;
- int ret;
-
- /* select the nearest port to master opensm */
- if (p->p_remote_physp &&
- p->dr_path.hop_count > p->p_remote_physp->dr_path.hop_count)
- p = p->p_remote_physp;
-
- /* If trap 131, might want to disable peer port if available */
- /* but peer port has been observed not to respond to SM requests */
-
- OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR 3810: "
- "Disabling physical port 0x%016" PRIx64 " num:%u\n",
- cl_ntoh64(osm_physp_get_port_guid(p)), p->port_num);
-
- memcpy(payload, &p->port_info, sizeof(ib_port_info_t));
-
- /* Set port to disabled/down */
- ib_port_info_set_port_state(pi, IB_LINK_DOWN);
- ib_port_info_set_port_phys_state(IB_PORT_PHYS_STATE_DISABLED, pi);
-
- /* Issue set of PortInfo */
- context.pi_context.node_guid = osm_node_get_node_guid(p->p_node);
- context.pi_context.port_guid = osm_physp_get_port_guid(p);
- context.pi_context.set_method = TRUE;
- context.pi_context.light_sweep = FALSE;
- context.pi_context.active_transition = FALSE;
-
- ret = osm_req_set(sm, osm_physp_get_dr_path_ptr(p),
- payload, sizeof(payload), IB_MAD_ATTR_PORT_INFO,
- cl_hton32(osm_physp_get_port_num(p)),
- CL_DISP_MSGID_NONE, &context);
- if (ret)
- OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR 3811: "
- "Request to set PortInfo failed\n");
-
- return ret;
-}
-
-/**********************************************************************
- **********************************************************************/
-static void
-__osm_trap_rcv_process_request(IN osm_sm_t * sm,
- IN const osm_madw_t * const p_madw)
-{
- uint8_t payload[sizeof(ib_mad_notice_attr_t)];
- ib_smp_t *p_smp;
- ib_mad_notice_attr_t *p_ntci = (ib_mad_notice_attr_t *) payload;
- ib_api_status_t status;
- osm_madw_t tmp_madw; /* we need a copy to last after repress */
- uint64_t trap_key;
- uint32_t num_received;
- osm_physp_t *p_physp;
- cl_ptr_vector_t *p_tbl;
- osm_port_t *p_port;
- ib_net16_t source_lid = 0;
- boolean_t is_gsi = TRUE;
- uint8_t port_num = 0;
- boolean_t physp_change_trap = FALSE;
- uint64_t event_wheel_timeout = OSM_DEFAULT_TRAP_SUPRESSION_TIMEOUT;
- boolean_t run_heavy_sweep = FALSE;
-
- OSM_LOG_ENTER(sm->p_log);
-
- CL_ASSERT(p_madw);
-
- if (osm_exit_flag)
- /*
- We got an exit flag - do nothing
- Otherwise we start a sweep on the trap 144 caused by
- cleaning up SM Cap bit...
- */
- goto Exit;
-
- /* update the is_gsi flag according to the mgmt_class field */
- if (p_madw->p_mad->mgmt_class == IB_MCLASS_SUBN_LID ||
- p_madw->p_mad->mgmt_class == IB_MCLASS_SUBN_DIR)
- is_gsi = FALSE;
-
- /* No real need to grab the lock for this function. */
- memset(payload, 0, sizeof(payload));
- memset(&tmp_madw, 0, sizeof(tmp_madw));
-
- p_smp = osm_madw_get_smp_ptr(p_madw);
-
- if (p_smp->method != IB_MAD_METHOD_TRAP) {
- OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR 3801: "
- "Unsupported method 0x%X\n", p_smp->method);
- goto Exit;
- }
-
- /*
- * The NOTICE Attribute is part of the SMP CLASS attributes
- * As such the actual attribute data resides inside the SMP
- * payload.
- */
-
- memcpy(payload, &(p_smp->data), IB_SMP_DATA_SIZE);
- memcpy(&tmp_madw, p_madw, sizeof(tmp_madw));
-
- if (is_gsi == FALSE) {
- /* We are in smi flow */
- /*
- * When we received a TRAP with dlid = 0 - it means it
- * came from our own node. So we need to fix it.
- */
-
- if (p_madw->mad_addr.addr_type.smi.source_lid == 0) {
- /* Check if the sm_base_lid is 0. If yes - this means
- that the local lid wasn't configured yet. Don't send
- a response to the trap. */
- if (sm->p_subn->sm_base_lid == 0) {
- OSM_LOG(sm->p_log, OSM_LOG_DEBUG,
- "Received SLID=0 Trap with local LID=0. Ignoring MAD\n");
- goto Exit;
- }
- OSM_LOG(sm->p_log, OSM_LOG_DEBUG,
- "Received SLID=0 Trap. Using local LID:%u instead\n",
- cl_ntoh16(sm->p_subn->sm_base_lid));
- tmp_madw.mad_addr.addr_type.smi.source_lid =
- sm->p_subn->sm_base_lid;
- }
-
- source_lid = tmp_madw.mad_addr.addr_type.smi.source_lid;
-
- /* Print some info about the incoming Trap */
- if (ib_notice_is_generic(p_ntci)) {
- if ((p_ntci->g_or_v.generic.trap_num == CL_HTON16(129))
- || (p_ntci->g_or_v.generic.trap_num ==
- CL_HTON16(130))
- || (p_ntci->g_or_v.generic.trap_num ==
- CL_HTON16(131)))
- OSM_LOG(sm->p_log, OSM_LOG_ERROR,
- "Received Generic Notice type:%u "
- "num:%u (%s) Producer:%u (%s) "
- "from LID:%u Port %d TID:0x%016"
- PRIx64 "\n", ib_notice_get_type(p_ntci),
- cl_ntoh16(p_ntci->g_or_v.generic.
- trap_num),
- ib_get_trap_str(p_ntci->g_or_v.generic.
- trap_num),
- cl_ntoh32(ib_notice_get_prod_type
- (p_ntci)),
- ib_get_producer_type_str
- (ib_notice_get_prod_type(p_ntci)),
- cl_hton16(source_lid),
- p_ntci->data_details.ntc_129_131.
- port_num, cl_ntoh64(p_smp->trans_id));
- else
- OSM_LOG(sm->p_log, OSM_LOG_ERROR,
- "Received Generic Notice type:%u "
- "num:%u (%s) Producer:%u (%s) "
- "from LID:%u TID:0x%016" PRIx64
- "\n", ib_notice_get_type(p_ntci),
- cl_ntoh16(p_ntci->g_or_v.generic.
- trap_num),
- ib_get_trap_str(p_ntci->g_or_v.generic.
- trap_num),
- cl_ntoh32(ib_notice_get_prod_type
- (p_ntci)),
- ib_get_producer_type_str
- (ib_notice_get_prod_type(p_ntci)),
- cl_hton16(source_lid),
- cl_ntoh64(p_smp->trans_id));
- } else
- OSM_LOG(sm->p_log, OSM_LOG_ERROR,
- "Received Vendor Notice type:%u vend:0x%06X "
- "dev:%u from LID:%u TID:0x%016" PRIx64 "\n",
- ib_notice_get_type(p_ntci),
- cl_ntoh32(ib_notice_get_vend_id(p_ntci)),
- cl_ntoh16(p_ntci->g_or_v.vend.dev_id),
- cl_ntoh16(source_lid),
- cl_ntoh64(p_smp->trans_id));
- }
-
- osm_dump_notice(sm->p_log, p_ntci, OSM_LOG_VERBOSE);
-
- p_physp = osm_get_physp_by_mad_addr(sm->p_log,
- sm->p_subn, &tmp_madw.mad_addr);
- if (p_physp)
- p_smp->m_key = p_physp->port_info.m_key;
- else
- OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR 3809: "
- "Failed to find source physical port for trap\n");
-
- status = osm_resp_send(sm, &tmp_madw, 0, payload);
- if (status != IB_SUCCESS) {
- OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR 3802: "
- "Error sending response (%s)\n",
- ib_get_err_str(status));
- goto Exit;
- }
-
- /*
- * We would like to filter out recurring Traps so we track them by
- * their source lid and content. If the same trap was already
- * received within the aging time window more than 10 times,
- * we simply ignore it. This is done only if we are in smi mode
- */
-
- if (is_gsi == FALSE) {
- if (ib_notice_is_generic(p_ntci) &&
- ((p_ntci->g_or_v.generic.trap_num == CL_HTON16(129)) ||
- (p_ntci->g_or_v.generic.trap_num == CL_HTON16(130)) ||
- (p_ntci->g_or_v.generic.trap_num == CL_HTON16(131)))) {
- /* If this is a trap 129, 130, or 131 - then this is a
- * trap signaling a change on a physical port.
- * Mark the physp_change_trap flag as TRUE.
- */
- physp_change_trap = TRUE;
- /* The source_lid should be based on the source_lid from the trap */
- source_lid = p_ntci->data_details.ntc_129_131.lid;
- }
-
- /* If physp_change_trap is TRUE - the key will include the port number.
- If not - the port_number in the key will be zero. */
- if (physp_change_trap == TRUE) {
- port_num = p_ntci->data_details.ntc_129_131.port_num;
- __osm_trap_get_key(source_lid, port_num, p_ntci,
- &trap_key);
- } else
- __osm_trap_get_key(source_lid, 0, p_ntci, &trap_key);
-
- /* try to find it in the aging tracker */
- num_received =
- cl_event_wheel_num_regs(&sm->trap_aging_tracker,
- trap_key);
-
- /* Now we know how many times it provided this trap */
- if (num_received > 10) {
- if (__print_num_received(num_received))
- OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR 3804: "
- "Received trap %u times consecutively\n",
- num_received);
- /*
- * If the trap provides info about a bad port
- * we mark it as unhealthy.
- */
- if (physp_change_trap == TRUE) {
- /* get the port */
- p_physp = get_physp_by_lid_and_num(sm,
- cl_ntoh16
- (p_ntci->
- data_details.
- ntc_129_131.
- lid),
- port_num);
-
- if (!p_physp)
- OSM_LOG(sm->p_log, OSM_LOG_ERROR,
- "ERR 3805: "
- "Failed to find physical port by lid:%u num:%u\n",
- cl_ntoh16(p_ntci->data_details.
- ntc_129_131.lid),
- p_ntci->data_details.
- ntc_129_131.port_num);
- else {
- /* When babbling port policy option is enabled and
- Threshold for disabling a "babbling" port is exceeded */
- if (sm->p_subn->opt.
- babbling_port_policy
- && num_received >= 250
- && disable_port(sm, p_physp) == 0)
- goto Exit;
-
- OSM_LOG(sm->p_log, OSM_LOG_VERBOSE,
- "Marking unhealthy physical port by lid:%u num:%u\n",
- cl_ntoh16(p_ntci->data_details.
- ntc_129_131.lid),
- p_ntci->data_details.
- ntc_129_131.port_num);
- /* check if the current state of the p_physp is healthy. If
- it is - then this is a first change of state. Run a heavy sweep.
- if it is not - no need to mark it again - just restart the timer. */
- if (osm_physp_is_healthy(p_physp)) {
- osm_physp_set_health(p_physp,
- FALSE);
- /* Make sure we sweep again - force a heavy sweep. */
- /* The sweep should be done only after the re-registration, or
- else we'll be losing track of the timer. */
- run_heavy_sweep = TRUE;
- }
- /* If we are marking the port as unhealthy - we want to
- keep this for a longer period of time than the
- OSM_DEFAULT_TRAP_SUPRESSION_TIMEOUT. Use the
- OSM_DEFAULT_UNHEALTHY_TIMEOUT */
- event_wheel_timeout =
- OSM_DEFAULT_UNHEALTHY_TIMEOUT;
- }
- }
- }
-
- /* restart the aging anyway */
- /* If physp_change_trap is TRUE - then use a callback to unset the
- healthy bit. If not - no need to use a callback. */
- if (physp_change_trap == TRUE)
- cl_event_wheel_reg(&sm->trap_aging_tracker, trap_key, cl_get_time_stamp() + event_wheel_timeout, osm_trap_rcv_aging_tracker_callback, /* no callback */
- sm /* no context */ );
- else
- cl_event_wheel_reg(&sm->trap_aging_tracker, trap_key, cl_get_time_stamp() + event_wheel_timeout, NULL, /* no callback */
- NULL /* no context */ );
-
- /* If was already registered do nothing more */
- if (num_received > 10 && run_heavy_sweep == FALSE) {
- if (__print_num_received(num_received))
- OSM_LOG(sm->p_log, OSM_LOG_VERBOSE,
- "Continuously received this trap %u times. Ignoring\n",
- num_received);
- goto Exit;
- }
- }
-
- /* Check for node description update. IB Spec v1.2.1 pg 823 */
- if ((p_ntci->data_details.ntc_144.local_changes & TRAP_144_MASK_OTHER_LOCAL_CHANGES) &&
- (p_ntci->data_details.ntc_144.change_flgs & TRAP_144_MASK_NODE_DESCRIPTION_CHANGE)
- ) {
- OSM_LOG(sm->p_log, OSM_LOG_INFO, "Trap 144 Node description update\n");
-
- if (p_physp) {
- CL_PLOCK_ACQUIRE(sm->p_lock);
- osm_req_get_node_desc(sm, p_physp);
- CL_PLOCK_RELEASE(sm->p_lock);
- } else {
- OSM_LOG(sm->p_log, OSM_LOG_ERROR,
- "ERR 3812: No physical port found for "
- "trap 144: \"node description update\"\n");
- }
- }
-
- /* do a sweep if we received a trap */
- if (sm->p_subn->opt.sweep_on_trap) {
- /* if this is trap number 128 or run_heavy_sweep is TRUE - update the
- force_single_heavy_sweep flag of the subnet.
- Sweep also on traps 144/145 - these traps signal a change of a certain
- port capability/system image guid.
- TODO: In the future we can change this to just getting PortInfo on
- this port instead of sweeping the entire subnet. */
- if (ib_notice_is_generic(p_ntci) &&
- ((cl_ntoh16(p_ntci->g_or_v.generic.trap_num) == 128) ||
- (cl_ntoh16(p_ntci->g_or_v.generic.trap_num) == 144) ||
- (cl_ntoh16(p_ntci->g_or_v.generic.trap_num) == 145) ||
- run_heavy_sweep)) {
- OSM_LOG(sm->p_log, OSM_LOG_VERBOSE,
- "Forcing heavy sweep. Received trap:%u\n",
- cl_ntoh16(p_ntci->g_or_v.generic.trap_num));
-
- sm->p_subn->force_heavy_sweep = TRUE;
- }
- osm_sm_signal(sm, OSM_SIGNAL_SWEEP);
- }
-
- /* If we reached here due to trap 129/130/131 - do not need to do
- the notice report. Just goto exit. We know this is the case
- if physp_change_trap is TRUE. */
- if (physp_change_trap == TRUE)
- goto Exit;
-
- /* Add a call to osm_report_notice */
- /* We are going to report the notice - so need to fix the IssuerGID
- accordingly. See IBA 1.2 p.739 or IBA 1.1 p.653 for details. */
- if (is_gsi) {
- if (!tmp_madw.mad_addr.addr_type.gsi.global_route) {
- OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR 3806: "
- "Received gsi trap with global_route FALSE. "
- "Cannot update issuer_gid!\n");
- goto Exit;
- }
- memcpy(&(p_ntci->issuer_gid),
- &(tmp_madw.mad_addr.addr_type.gsi.grh_info.src_gid),
- sizeof(ib_gid_t));
- } else {
- /* Need to use the IssuerLID */
- p_tbl = &sm->p_subn->port_lid_tbl;
-
- CL_ASSERT(cl_ptr_vector_get_size(p_tbl) < 0x10000);
-
- if ((uint16_t) cl_ptr_vector_get_size(p_tbl) <=
- cl_ntoh16(source_lid)) {
- /* the source lid is out of range */
- OSM_LOG(sm->p_log, OSM_LOG_VERBOSE,
- "source lid is out of range:%u\n",
- cl_ntoh16(source_lid));
-
- goto Exit;
- }
- p_port = cl_ptr_vector_get(p_tbl, cl_ntoh16(source_lid));
- if (p_port == 0) {
- /* We have the lid - but no corresponding port */
- OSM_LOG(sm->p_log, OSM_LOG_VERBOSE,
- "Cannot find port corresponding to lid:%u\n",
- cl_ntoh16(source_lid));
-
- goto Exit;
- }
-
- p_ntci->issuer_gid.unicast.prefix =
- sm->p_subn->opt.subnet_prefix;
- p_ntci->issuer_gid.unicast.interface_id = p_port->guid;
- }
-
- /* we need a lock here as the InformInfo DB must be stable */
- CL_PLOCK_ACQUIRE(sm->p_lock);
- status = osm_report_notice(sm->p_log, sm->p_subn, p_ntci);
- CL_PLOCK_RELEASE(sm->p_lock);
- if (status != IB_SUCCESS) {
- OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR 3803: "
- "Error sending trap reports (%s)\n",
- ib_get_err_str(status));
- goto Exit;
- }
-
-Exit:
- OSM_LOG_EXIT(sm->p_log);
-}
-
-#if 0
-/**********************************************************************
- CURRENTLY WE ARE NOT CREATING TRAPS - SO THIS CALL IS AN ERROR
-**********************************************************************/
-static void
-__osm_trap_rcv_process_sm(IN osm_sm_t * sm,
- IN const osm_remote_sm_t * const p_sm)
-{
- /* const ib_sm_info_t* p_smi; */
-
- OSM_LOG_ENTER(sm->p_log);
-
- OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR 3807: "
- "This function is not supported yet\n");
-
- OSM_LOG_EXIT(sm->p_log);
-}
-#endif
-
-/**********************************************************************
- CURRENTLY WE ARE NOT CREATING TRAPS - SO THIS CALL IN AN ERROR
-**********************************************************************/
-static void
-__osm_trap_rcv_process_response(IN osm_sm_t * sm,
- IN const osm_madw_t * const p_madw)
-{
-
- OSM_LOG_ENTER(sm->p_log);
-
- OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR 3808: "
- "This function is not supported yet\n");
-
- OSM_LOG_EXIT(sm->p_log);
-}
-
-/**********************************************************************
- **********************************************************************/
-void osm_trap_rcv_process(IN void *context, IN void *data)
-{
- osm_sm_t *sm = context;
- osm_madw_t *p_madw = data;
- ib_smp_t *p_smp;
-
- OSM_LOG_ENTER(sm->p_log);
-
- CL_ASSERT(p_madw);
-
- p_smp = osm_madw_get_smp_ptr(p_madw);
-
- /*
- Determine if this is a request for our own Trap
- or if this is a response to our request for another
- SM's Trap.
- */
- if (ib_smp_is_response(p_smp))
- __osm_trap_rcv_process_response(sm, p_madw);
- else
- __osm_trap_rcv_process_request(sm, p_madw);
-
- OSM_LOG_EXIT(sm->p_log);
-}
diff --git a/contrib/ofed/management/opensm/opensm/osm_ucast_cache.c b/contrib/ofed/management/opensm/opensm/osm_ucast_cache.c
deleted file mode 100644
index c89e24d..0000000
--- a/contrib/ofed/management/opensm/opensm/osm_ucast_cache.c
+++ /dev/null
@@ -1,1095 +0,0 @@
-/*
- * Copyright (c) 2008 Mellanox Technologies LTD. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- */
-
-/*
- * Abstract:
- * Implementation of OpenSM Cached Unicast Routing
- *
- * Environment:
- * Linux User Mode
- *
- */
-
-#if HAVE_CONFIG_H
-# include <config.h>
-#endif
-
-#include <stdlib.h>
-#include <string.h>
-#include <ctype.h>
-#include <errno.h>
-#include <iba/ib_types.h>
-#include <complib/cl_qmap.h>
-#include <complib/cl_pool.h>
-#include <complib/cl_debug.h>
-#include <opensm/osm_opensm.h>
-#include <opensm/osm_ucast_mgr.h>
-#include <opensm/osm_ucast_cache.h>
-#include <opensm/osm_switch.h>
-#include <opensm/osm_node.h>
-#include <opensm/osm_port.h>
-
-#define CACHE_SW_PORTS 36
-
-typedef struct cache_port {
- boolean_t is_leaf;
- uint16_t remote_lid_ho;
-} cache_port_t;
-
-typedef struct cache_switch {
- cl_map_item_t map_item;
- boolean_t dropped;
- uint16_t max_lid_ho;
- uint16_t num_hops;
- uint8_t **hops;
- uint8_t *lft;
- uint8_t num_ports;
- cache_port_t ports[0];
-} cache_switch_t;
-
-/**********************************************************************
- **********************************************************************/
-
-static uint16_t __cache_sw_get_base_lid_ho(cache_switch_t * p_sw)
-{
- return p_sw->ports[0].remote_lid_ho;
-}
-
-/**********************************************************************
- **********************************************************************/
-
-static boolean_t __cache_sw_is_leaf(cache_switch_t * p_sw)
-{
- return p_sw->ports[0].is_leaf;
-}
-
-/**********************************************************************
- **********************************************************************/
-
-static void __cache_sw_set_leaf(cache_switch_t * p_sw)
-{
- p_sw->ports[0].is_leaf = TRUE;
-}
-
-/**********************************************************************
- **********************************************************************/
-
-static cache_switch_t *__cache_sw_new(uint16_t lid_ho, unsigned num_ports)
-{
- cache_switch_t *p_cache_sw = malloc(sizeof(cache_switch_t) +
- num_ports * sizeof(cache_port_t));
- if (!p_cache_sw)
- return NULL;
-
- memset(p_cache_sw, 0,
- sizeof(*p_cache_sw) + num_ports * sizeof(cache_port_t));
-
- p_cache_sw->num_ports = num_ports;
-
- /* port[0] fields represent this switch details - lid and type */
- p_cache_sw->ports[0].remote_lid_ho = lid_ho;
- p_cache_sw->ports[0].is_leaf = FALSE;
-
- return p_cache_sw;
-}
-
-/**********************************************************************
- **********************************************************************/
-
-static void __cache_sw_destroy(cache_switch_t * p_sw)
-{
- if (!p_sw)
- return;
-
- if (p_sw->lft)
- free(p_sw->lft);
- if (p_sw->hops)
- free(p_sw->hops);
- free(p_sw);
-}
-
-/**********************************************************************
- **********************************************************************/
-
-static cache_switch_t *__cache_get_sw(osm_ucast_mgr_t * p_mgr, uint16_t lid_ho)
-{
- cache_switch_t *p_cache_sw = (cache_switch_t *)
- cl_qmap_get(&p_mgr->cache_sw_tbl, lid_ho);
- if (p_cache_sw == (cache_switch_t *)
- cl_qmap_end(&p_mgr->cache_sw_tbl))
- p_cache_sw = NULL;
-
- return p_cache_sw;
-}
-
-/**********************************************************************
- **********************************************************************/
-static void __cache_add_sw_link(osm_ucast_mgr_t * p_mgr, osm_physp_t *p,
- uint16_t remote_lid_ho, boolean_t is_ca)
-{
- cache_switch_t *p_cache_sw;
- uint16_t lid_ho = cl_ntoh16(osm_node_get_base_lid(p->p_node, 0));
-
- OSM_LOG_ENTER(p_mgr->p_log);
-
- if (!lid_ho || !remote_lid_ho || !p->port_num)
- goto Exit;
-
- OSM_LOG(p_mgr->p_log, OSM_LOG_DEBUG,
- "Caching switch port: lid %u [port %u] -> lid %u (%s)\n",
- lid_ho, p->port_num, remote_lid_ho, (is_ca) ? "CA/RTR" : "SW");
-
- p_cache_sw = __cache_get_sw(p_mgr, lid_ho);
- if (!p_cache_sw) {
- p_cache_sw = __cache_sw_new(lid_ho, p->p_node->sw->num_ports);
- if (!p_cache_sw) {
- OSM_LOG(p_mgr->p_log, OSM_LOG_ERROR,
- "ERR AD01: Out of memory - cache is invalid\n");
- osm_ucast_cache_invalidate(p_mgr);
- goto Exit;
- }
- cl_qmap_insert(&p_mgr->cache_sw_tbl, lid_ho,
- &p_cache_sw->map_item);
- }
-
- if (p->port_num >= p_cache_sw->num_ports) {
- OSM_LOG(p_mgr->p_log, OSM_LOG_ERROR,
- "ERR AD02: Wrong switch? - cache is invalid\n");
- osm_ucast_cache_invalidate(p_mgr);
- goto Exit;
- }
-
- if (is_ca)
- __cache_sw_set_leaf(p_cache_sw);
-
- if (p_cache_sw->ports[p->port_num].remote_lid_ho == 0) {
- /* cache this link only if it hasn't been already cached */
- p_cache_sw->ports[p->port_num].remote_lid_ho = remote_lid_ho;
- p_cache_sw->ports[p->port_num].is_leaf = is_ca;
- }
-Exit:
- OSM_LOG_EXIT(p_mgr->p_log);
-}
-
-/**********************************************************************
- **********************************************************************/
-
-static void __cache_cleanup_switches(osm_ucast_mgr_t * p_mgr)
-{
- cache_switch_t *p_sw;
- cache_switch_t *p_next_sw;
- unsigned port_num;
- boolean_t found_port;
-
- if (!p_mgr->cache_valid)
- return;
-
- p_next_sw = (cache_switch_t *) cl_qmap_head(&p_mgr->cache_sw_tbl);
- while (p_next_sw !=
- (cache_switch_t *) cl_qmap_end(&p_mgr->cache_sw_tbl)) {
- p_sw = p_next_sw;
- p_next_sw = (cache_switch_t *) cl_qmap_next(&p_sw->map_item);
-
- found_port = FALSE;
- for (port_num = 1; port_num < p_sw->num_ports; port_num++)
- if (p_sw->ports[port_num].remote_lid_ho)
- found_port = TRUE;
-
- if (!found_port) {
- cl_qmap_remove_item(&p_mgr->cache_sw_tbl,
- &p_sw->map_item);
- __cache_sw_destroy(p_sw);
- }
- }
-}
-
-/**********************************************************************
- **********************************************************************/
-
-static void
-__cache_check_link_change(osm_ucast_mgr_t * p_mgr,
- osm_physp_t * p_physp_1, osm_physp_t * p_physp_2)
-{
- OSM_LOG_ENTER(p_mgr->p_log);
- CL_ASSERT(p_physp_1 && p_physp_2);
-
- if (!p_mgr->cache_valid)
- goto Exit;
-
- if (!p_physp_1->p_remote_physp && !p_physp_2->p_remote_physp)
- /* both ports were down - new link */
- goto Exit;
-
- /* unicast cache cannot tolerate any link location change */
-
- if ((p_physp_1->p_remote_physp &&
- p_physp_1->p_remote_physp->p_remote_physp) ||
- (p_physp_2->p_remote_physp &&
- p_physp_2->p_remote_physp->p_remote_physp)) {
- OSM_LOG(p_mgr->p_log, OSM_LOG_INFO,
- "Link location change discovered - cache is invalid\n");
- osm_ucast_cache_invalidate(p_mgr);
- goto Exit;
- }
-Exit:
- OSM_LOG_EXIT(p_mgr->p_log);
-}
-
-/**********************************************************************
- **********************************************************************/
-
-static void __cache_remove_port(osm_ucast_mgr_t * p_mgr, uint16_t lid_ho,
- uint8_t port_num, uint16_t remote_lid_ho,
- boolean_t is_ca)
-{
- cache_switch_t *p_cache_sw;
-
- OSM_LOG_ENTER(p_mgr->p_log);
-
- if (!p_mgr->cache_valid)
- goto Exit;
-
- p_cache_sw = __cache_get_sw(p_mgr, lid_ho);
- if (!p_cache_sw) {
- OSM_LOG(p_mgr->p_log, OSM_LOG_INFO,
- "Found uncached switch/link (lid %u, port %u) - "
- "cache is invalid\n", lid_ho, port_num);
- osm_ucast_cache_invalidate(p_mgr);
- goto Exit;
- }
-
- if (port_num >= p_cache_sw->num_ports ||
- !p_cache_sw->ports[port_num].remote_lid_ho) {
- OSM_LOG(p_mgr->p_log, OSM_LOG_INFO,
- "Found uncached switch link (lid %u, port %u) - "
- "cache is invalid\n", lid_ho, port_num);
- osm_ucast_cache_invalidate(p_mgr);
- goto Exit;
- }
-
- if (p_cache_sw->ports[port_num].remote_lid_ho != remote_lid_ho) {
- OSM_LOG(p_mgr->p_log, OSM_LOG_INFO,
- "Remote lid change on switch lid %u, port %u "
- "(was %u, now %u) - cache is invalid\n",
- lid_ho, port_num,
- p_cache_sw->ports[port_num].remote_lid_ho,
- remote_lid_ho);
- osm_ucast_cache_invalidate(p_mgr);
- goto Exit;
- }
-
- if ((p_cache_sw->ports[port_num].is_leaf && !is_ca) ||
- (!p_cache_sw->ports[port_num].is_leaf && is_ca)) {
- OSM_LOG(p_mgr->p_log, OSM_LOG_INFO,
- "Remote node type change on switch lid %u, port %u - "
- "cache is invalid\n", lid_ho, port_num);
- osm_ucast_cache_invalidate(p_mgr);
- goto Exit;
- }
-
- OSM_LOG(p_mgr->p_log, OSM_LOG_DEBUG,
- "New link from lid %u, port %u to lid %u - "
- "found in cache\n", lid_ho, port_num, remote_lid_ho);
-
- /* the new link was cached - clean it from the cache */
-
- p_cache_sw->ports[port_num].remote_lid_ho = 0;
- p_cache_sw->ports[port_num].is_leaf = FALSE;
-Exit:
- OSM_LOG_EXIT(p_mgr->p_log);
-} /* __cache_remove_port() */
-
-/**********************************************************************
- **********************************************************************/
-
-static void
-__cache_restore_ucast_info(osm_ucast_mgr_t * p_mgr,
- cache_switch_t * p_cache_sw, osm_switch_t * p_sw)
-{
- if (!p_mgr->cache_valid)
- return;
-
- /* when seting unicast info, the cached port
- should have all the required info */
- CL_ASSERT(p_cache_sw->max_lid_ho && p_cache_sw->lft &&
- p_cache_sw->num_hops && p_cache_sw->hops);
-
- p_sw->max_lid_ho = p_cache_sw->max_lid_ho;
-
- if (p_sw->new_lft)
- free(p_sw->new_lft);
- p_sw->new_lft = p_cache_sw->lft;
- p_cache_sw->lft = NULL;
-
- p_sw->num_hops = p_cache_sw->num_hops;
- p_cache_sw->num_hops = 0;
- if (p_sw->hops)
- free(p_sw->hops);
- p_sw->hops = p_cache_sw->hops;
- p_cache_sw->hops = NULL;
-}
-
-/**********************************************************************
- **********************************************************************/
-
-static void __ucast_cache_dump(osm_ucast_mgr_t * p_mgr)
-{
- cache_switch_t *p_sw;
- unsigned i;
-
- OSM_LOG_ENTER(p_mgr->p_log);
-
- if (!osm_log_is_active(p_mgr->p_log, OSM_LOG_DEBUG))
- goto Exit;
-
- OSM_LOG(p_mgr->p_log, OSM_LOG_DEBUG,
- "Dumping missing nodes/links as logged by unicast cache:\n");
- for (p_sw = (cache_switch_t *) cl_qmap_head(&p_mgr->cache_sw_tbl);
- p_sw != (cache_switch_t *) cl_qmap_end(&p_mgr->cache_sw_tbl);
- p_sw = (cache_switch_t *) cl_qmap_next(&p_sw->map_item)) {
-
- OSM_LOG(p_mgr->p_log, OSM_LOG_DEBUG,
- "\t Switch lid %u %s%s\n",
- __cache_sw_get_base_lid_ho(p_sw),
- (__cache_sw_is_leaf(p_sw)) ? "[leaf switch] " : "",
- (p_sw->dropped) ? "[whole switch missing]" : "");
-
- for (i = 1; i < p_sw->num_ports; i++)
- if (p_sw->ports[i].remote_lid_ho > 0)
- OSM_LOG(p_mgr->p_log,
- OSM_LOG_DEBUG,
- "\t - port %u -> lid %u %s\n",
- i, p_sw->ports[i].remote_lid_ho,
- (p_sw->ports[i].is_leaf) ?
- "[remote node is leaf]" : "");
- }
-Exit:
- OSM_LOG_EXIT(p_mgr->p_log);
-}
-
-/**********************************************************************
- **********************************************************************/
-
-void osm_ucast_cache_invalidate(osm_ucast_mgr_t * p_mgr)
-{
- cache_switch_t *p_sw;
- cache_switch_t *p_next_sw;
-
- OSM_LOG_ENTER(p_mgr->p_log);
- OSM_LOG(p_mgr->p_log, OSM_LOG_DEBUG, "Invalidating unicast cache\n");
-
- if (!p_mgr->cache_valid)
- goto Exit;
-
- p_mgr->cache_valid = FALSE;
-
- p_next_sw = (cache_switch_t *) cl_qmap_head(&p_mgr->cache_sw_tbl);
- while (p_next_sw !=
- (cache_switch_t *) cl_qmap_end(&p_mgr->cache_sw_tbl)) {
- p_sw = p_next_sw;
- p_next_sw = (cache_switch_t *) cl_qmap_next(&p_sw->map_item);
- __cache_sw_destroy(p_sw);
- }
- cl_qmap_remove_all(&p_mgr->cache_sw_tbl);
-Exit:
- OSM_LOG_EXIT(p_mgr->p_log);
-}
-
-/**********************************************************************
- **********************************************************************/
-
-static void ucast_cache_validate(osm_ucast_mgr_t * p_mgr)
-{
- cache_switch_t *p_cache_sw;
- cache_switch_t *p_remote_cache_sw;
- unsigned port_num;
- unsigned max_ports;
- uint8_t remote_node_type;
- uint16_t lid_ho;
- uint16_t remote_lid_ho;
- osm_switch_t *p_sw;
- osm_switch_t *p_remote_sw;
- osm_node_t *p_node;
- osm_physp_t *p_physp;
- osm_physp_t *p_remote_physp;
- osm_port_t *p_remote_port;
- cl_qmap_t *p_sw_tbl;
-
- OSM_LOG_ENTER(p_mgr->p_log);
- if (!p_mgr->cache_valid)
- goto Exit;
-
- /* If there are no switches in the subnet, we are done */
- p_sw_tbl = &p_mgr->p_subn->sw_guid_tbl;
- if (cl_qmap_count(p_sw_tbl) == 0) {
- osm_ucast_cache_invalidate(p_mgr);
- goto Exit;
- }
-
- /*
- * Scan all the physical switch ports in the subnet.
- * If the port need_update flag is on, check whether
- * it's just some node/port reset or a cached topology
- * change. Otherwise the cache is invalid.
- */
- for (p_sw = (osm_switch_t *) cl_qmap_head(p_sw_tbl);
- p_sw != (osm_switch_t *) cl_qmap_end(p_sw_tbl);
- p_sw = (osm_switch_t *) cl_qmap_next(&p_sw->map_item)) {
-
- p_node = p_sw->p_node;
-
- lid_ho = cl_ntoh16(osm_node_get_base_lid(p_node, 0));
- p_cache_sw = __cache_get_sw(p_mgr, lid_ho);
-
- max_ports = osm_node_get_num_physp(p_node);
-
- /* skip port 0 */
- for (port_num = 1; port_num < max_ports; port_num++) {
-
- p_physp = osm_node_get_physp_ptr(p_node, port_num);
-
- if (!p_physp || !p_physp->p_remote_physp ||
- !osm_physp_link_exists(p_physp,
- p_physp->p_remote_physp))
- /* no valid link */
- continue;
-
- /*
- * While scanning all the physical ports in the subnet,
- * mark corresponding leaf switches in the cache.
- */
- if (p_cache_sw &&
- !p_cache_sw->dropped &&
- !__cache_sw_is_leaf(p_cache_sw) &&
- p_physp->p_remote_physp->p_node &&
- osm_node_get_type(p_physp->p_remote_physp->
- p_node) != IB_NODE_TYPE_SWITCH)
- __cache_sw_set_leaf(p_cache_sw);
-
- if (!p_physp->need_update)
- continue;
-
- OSM_LOG(p_mgr->p_log, OSM_LOG_DEBUG,
- "Checking switch lid %u, port %u\n",
- lid_ho, port_num);
-
- p_remote_physp = osm_physp_get_remote(p_physp);
- remote_node_type =
- osm_node_get_type(p_remote_physp->p_node);
-
- if (remote_node_type == IB_NODE_TYPE_SWITCH)
- remote_lid_ho =
- cl_ntoh16(osm_node_get_base_lid
- (p_remote_physp->p_node, 0));
- else
- remote_lid_ho =
- cl_ntoh16(osm_node_get_base_lid
- (p_remote_physp->p_node,
- osm_physp_get_port_num
- (p_remote_physp)));
-
- if (!p_cache_sw ||
- port_num >= p_cache_sw->num_ports ||
- !p_cache_sw->ports[port_num].remote_lid_ho) {
- /*
- * There is some uncached change on the port.
- * In general, the reasons might be as follows:
- * - switch reset
- * - port reset (or port down/up)
- * - quick connection location change
- * - new link (or new switch)
- *
- * First two reasons allow cache usage, while
- * the last two reasons should invalidate cache.
- *
- * In case of quick connection location change,
- * cache would have been invalidated by
- * osm_ucast_cache_check_new_link() function.
- *
- * In case of new link between two known nodes,
- * cache also would have been invalidated by
- * osm_ucast_cache_check_new_link() function.
- *
- * Another reason is cached link between two
- * known switches went back. In this case the
- * osm_ucast_cache_check_new_link() function would
- * clear both sides of the link from the cache
- * during the discovery process, so effectively
- * this would be equivalent to port reset.
- *
- * So three possible reasons remain:
- * - switch reset
- * - port reset (or port down/up)
- * - link of a new switch
- *
- * To validate cache, we need to check only the
- * third reason - link of a new node/switch:
- * - If this is the local switch that is new,
- * then it should have (p_sw->need_update == 2).
- * - If the remote node is switch and it's new,
- * then it also should have
- * (p_sw->need_update == 2).
- * - If the remote node is CA/RTR and it's new,
- * then its port should have is_new flag on.
- */
- if (p_sw->need_update == 2) {
- OSM_LOG(p_mgr->p_log, OSM_LOG_INFO,
- "New switch found (lid %u) - "
- "cache is invalid\n", lid_ho);
- osm_ucast_cache_invalidate(p_mgr);
- goto Exit;
- }
-
- if (remote_node_type == IB_NODE_TYPE_SWITCH) {
-
- p_remote_sw =
- p_remote_physp->p_node->sw;
- if (p_remote_sw->need_update == 2) {
- /* this could also be case of
- switch coming back with an
- additional link that it
- didn't have before */
- OSM_LOG(p_mgr->p_log,
- OSM_LOG_INFO,
- "New switch/link found (lid %u) - "
- "cache is invalid\n",
- remote_lid_ho);
- osm_ucast_cache_invalidate
- (p_mgr);
- goto Exit;
- }
- } else {
- /*
- * Remote node is CA/RTR.
- * Get p_port of the remote node and
- * check its p_port->is_new flag.
- */
- p_remote_port =
- osm_get_port_by_guid(p_mgr->p_subn,
- osm_physp_get_port_guid
- (p_remote_physp));
- if (p_remote_port->is_new) {
- OSM_LOG(p_mgr->p_log,
- OSM_LOG_INFO,
- "New CA/RTR found (lid %u) - "
- "cache is invalid\n",
- remote_lid_ho);
- osm_ucast_cache_invalidate
- (p_mgr);
- goto Exit;
- }
- }
- } else {
- /*
- * The change on the port is cached.
- * In general, the reasons might be as follows:
- * - link between two known nodes went back
- * - one or more nodes went back, causing all
- * the links to reappear
- *
- * If it was link that went back, then this case
- * would have been taken care of during the
- * discovery by osm_ucast_cache_check_new_link(),
- * so it's some node that went back.
- */
- if ((p_cache_sw->ports[port_num].is_leaf &&
- remote_node_type == IB_NODE_TYPE_SWITCH) ||
- (!p_cache_sw->ports[port_num].is_leaf &&
- remote_node_type != IB_NODE_TYPE_SWITCH)) {
- OSM_LOG(p_mgr->p_log, OSM_LOG_INFO,
- "Remote node type change on switch lid %u, port %u - "
- "cache is invalid\n",
- lid_ho, port_num);
- osm_ucast_cache_invalidate(p_mgr);
- goto Exit;
- }
-
- if (p_cache_sw->ports[port_num].remote_lid_ho !=
- remote_lid_ho) {
- OSM_LOG(p_mgr->p_log, OSM_LOG_INFO,
- "Remote lid change on switch lid %u, port %u"
- "(was %u, now %u) - cache is invalid\n",
- lid_ho, port_num,
- p_cache_sw->ports[port_num].
- remote_lid_ho, remote_lid_ho);
- osm_ucast_cache_invalidate(p_mgr);
- goto Exit;
- }
-
- /*
- * We don't care who is the node that has
- * reappeared in the subnet (local or remote).
- * What's important that the cached link matches
- * the real fabrics link.
- * Just clean it from cache.
- */
-
- p_cache_sw->ports[port_num].remote_lid_ho = 0;
- p_cache_sw->ports[port_num].is_leaf = FALSE;
- if (p_cache_sw->dropped) {
- __cache_restore_ucast_info(p_mgr,
- p_cache_sw,
- p_sw);
- p_cache_sw->dropped = FALSE;
- }
-
- OSM_LOG(p_mgr->p_log, OSM_LOG_DEBUG,
- "Restored link from cache: lid %u, port %u to lid %u\n",
- lid_ho, port_num, remote_lid_ho);
- }
- }
- }
-
- /* Remove all the cached switches that
- have all their ports restored */
- __cache_cleanup_switches(p_mgr);
-
- /*
- * Done scanning all the physical switch ports in the subnet.
- * Now we need to check the other side:
- * Scan all the cached switches and their ports:
- * - If the cached switch is missing in the subnet
- * (dropped flag is on), check that it's a leaf switch.
- * If it's not a leaf, the cache is invalid, because
- * cache can tolerate only leaf switch removal.
- * - If the cached switch exists in fabric, check all
- * its cached ports. These cached ports represent
- * missing link in the fabric.
- * The missing links that can be tolerated are:
- * + link to missing CA/RTR
- * + link to missing leaf switch
- */
- for (p_cache_sw = (cache_switch_t *) cl_qmap_head(&p_mgr->cache_sw_tbl);
- p_cache_sw != (cache_switch_t *) cl_qmap_end(&p_mgr->cache_sw_tbl);
- p_cache_sw =
- (cache_switch_t *) cl_qmap_next(&p_cache_sw->map_item)) {
-
- if (p_cache_sw->dropped) {
- if (!__cache_sw_is_leaf(p_cache_sw)) {
- OSM_LOG(p_mgr->p_log, OSM_LOG_INFO,
- "Missing non-leaf switch (lid %u) - "
- "cache is invalid\n",
- __cache_sw_get_base_lid_ho(p_cache_sw));
- osm_ucast_cache_invalidate(p_mgr);
- goto Exit;
- }
-
- OSM_LOG(p_mgr->p_log, OSM_LOG_DEBUG,
- "Missing leaf switch (lid %u) - "
- "continuing validation\n",
- __cache_sw_get_base_lid_ho(p_cache_sw));
- continue;
- }
-
- for (port_num = 1; port_num < p_cache_sw->num_ports; port_num++) {
- if (!p_cache_sw->ports[port_num].remote_lid_ho)
- continue;
-
- if (p_cache_sw->ports[port_num].is_leaf) {
- CL_ASSERT(__cache_sw_is_leaf(p_cache_sw));
- OSM_LOG(p_mgr->p_log, OSM_LOG_DEBUG,
- "Switch lid %u, port %u: missing link to CA/RTR - "
- "continuing validation\n",
- __cache_sw_get_base_lid_ho(p_cache_sw),
- port_num);
- continue;
- }
-
- p_remote_cache_sw = __cache_get_sw(p_mgr,
- p_cache_sw->
- ports[port_num].
- remote_lid_ho);
-
- if (!p_remote_cache_sw || !p_remote_cache_sw->dropped) {
- OSM_LOG(p_mgr->p_log, OSM_LOG_INFO,
- "Switch lid %u, port %u: missing link to existing switch - "
- "cache is invalid\n",
- __cache_sw_get_base_lid_ho(p_cache_sw),
- port_num);
- osm_ucast_cache_invalidate(p_mgr);
- goto Exit;
- }
-
- if (!__cache_sw_is_leaf(p_remote_cache_sw)) {
- OSM_LOG(p_mgr->p_log, OSM_LOG_INFO,
- "Switch lid %u, port %u: missing link to non-leaf switch - "
- "cache is invalid\n",
- __cache_sw_get_base_lid_ho(p_cache_sw),
- port_num);
- osm_ucast_cache_invalidate(p_mgr);
- goto Exit;
- }
-
- /*
- * At this point we know that the missing link is to
- * a leaf switch. However, one case deserves a special
- * treatment. If there was a link between two leaf
- * switches, then missing leaf switch might break
- * routing. It is possible that there are routes
- * that use leaf switches to get from switch to switch
- * and not just to get to the CAs behind the leaf switch.
- */
- if (__cache_sw_is_leaf(p_cache_sw) &&
- __cache_sw_is_leaf(p_remote_cache_sw)) {
- OSM_LOG(p_mgr->p_log, OSM_LOG_INFO,
- "Switch lid %u, port %u: missing leaf-2-leaf link - "
- "cache is invalid\n",
- __cache_sw_get_base_lid_ho(p_cache_sw),
- port_num);
- osm_ucast_cache_invalidate(p_mgr);
- goto Exit;
- }
-
- OSM_LOG(p_mgr->p_log, OSM_LOG_DEBUG,
- "Switch lid %u, port %u: missing remote leaf switch - "
- "continuing validation\n",
- __cache_sw_get_base_lid_ho(p_cache_sw),
- port_num);
- }
- }
-
- OSM_LOG(p_mgr->p_log, OSM_LOG_DEBUG, "Unicast cache is valid\n");
- __ucast_cache_dump(p_mgr);
-Exit:
- OSM_LOG_EXIT(p_mgr->p_log);
-} /* osm_ucast_cache_validate() */
-
-/**********************************************************************
- **********************************************************************/
-
-void osm_ucast_cache_check_new_link(osm_ucast_mgr_t * p_mgr,
- osm_node_t * p_node_1, uint8_t port_num_1,
- osm_node_t * p_node_2, uint8_t port_num_2)
-{
- uint16_t lid_ho_1;
- uint16_t lid_ho_2;
-
- OSM_LOG_ENTER(p_mgr->p_log);
-
- if (!p_mgr->cache_valid)
- goto Exit;
-
- __cache_check_link_change(p_mgr,
- osm_node_get_physp_ptr(p_node_1, port_num_1),
- osm_node_get_physp_ptr(p_node_2, port_num_2));
-
- if (!p_mgr->cache_valid)
- goto Exit;
-
- if (osm_node_get_type(p_node_1) != IB_NODE_TYPE_SWITCH &&
- osm_node_get_type(p_node_2) != IB_NODE_TYPE_SWITCH) {
- OSM_LOG(p_mgr->p_log, OSM_LOG_INFO,
- "Found CA/RTR-2-CA/RTR link - cache is invalid\n");
- osm_ucast_cache_invalidate(p_mgr);
- goto Exit;
- }
-
- /* for code simplicity, we want the first node to be switch */
- if (osm_node_get_type(p_node_1) != IB_NODE_TYPE_SWITCH) {
- osm_node_t *tmp_node = p_node_1;
- uint8_t tmp_port_num = port_num_1;
- p_node_1 = p_node_2;
- port_num_1 = port_num_2;
- p_node_2 = tmp_node;
- port_num_2 = tmp_port_num;
- }
-
- lid_ho_1 = cl_ntoh16(osm_node_get_base_lid(p_node_1, 0));
-
- if (osm_node_get_type(p_node_2) == IB_NODE_TYPE_SWITCH)
- lid_ho_2 = cl_ntoh16(osm_node_get_base_lid(p_node_2, 0));
- else
- lid_ho_2 =
- cl_ntoh16(osm_node_get_base_lid(p_node_2, port_num_2));
-
- if (!lid_ho_1 || !lid_ho_2) {
- /*
- * No lid assigned, which means that one of the nodes is new.
- * Need to wait for lid manager to process this node.
- * The switches and their links will be checked later when
- * the whole cache validity will be verified.
- */
- OSM_LOG(p_mgr->p_log, OSM_LOG_DEBUG,
- "Link port %u <-> %u reveals new node - cache will "
- "be validated later\n", port_num_1, port_num_2);
- goto Exit;
- }
-
- __cache_remove_port(p_mgr, lid_ho_1, port_num_1, lid_ho_2,
- (osm_node_get_type(p_node_2) !=
- IB_NODE_TYPE_SWITCH));
-
- /* if node_2 is a switch, the link should be cleaned from its cache */
-
- if (osm_node_get_type(p_node_2) == IB_NODE_TYPE_SWITCH)
- __cache_remove_port(p_mgr, lid_ho_2,
- port_num_2, lid_ho_1, FALSE);
-
-Exit:
- OSM_LOG_EXIT(p_mgr->p_log);
-} /* osm_ucast_cache_check_new_link() */
-
-/**********************************************************************
- **********************************************************************/
-
-void osm_ucast_cache_add_link(osm_ucast_mgr_t * p_mgr,
- osm_physp_t * p_physp1, osm_physp_t * p_physp2)
-{
- osm_node_t *p_node_1 = p_physp1->p_node, *p_node_2 = p_physp2->p_node;
- uint16_t lid_ho_1, lid_ho_2;
-
- OSM_LOG_ENTER(p_mgr->p_log);
-
- if (!p_mgr->cache_valid)
- goto Exit;
-
- if (osm_node_get_type(p_node_1) != IB_NODE_TYPE_SWITCH &&
- osm_node_get_type(p_node_2) != IB_NODE_TYPE_SWITCH) {
- OSM_LOG(p_mgr->p_log, OSM_LOG_INFO,
- "Dropping CA-2-CA link - cache invalid\n");
- osm_ucast_cache_invalidate(p_mgr);
- goto Exit;
- }
-
- if ((osm_node_get_type(p_node_1) == IB_NODE_TYPE_SWITCH &&
- !osm_node_get_physp_ptr(p_node_1, 0)) ||
- (osm_node_get_type(p_node_2) == IB_NODE_TYPE_SWITCH &&
- !osm_node_get_physp_ptr(p_node_2, 0))) {
- /* we're caching a link when one of the nodes
- has already been dropped and cached */
- OSM_LOG(p_mgr->p_log, OSM_LOG_DEBUG,
- "Port %u <-> port %u: port0 on one of the nodes "
- "has already been dropped and cached\n",
- p_physp1->port_num, p_physp2->port_num);
- goto Exit;
- }
-
- /* One of the nodes is switch. Just for code
- simplicity, make sure that it's the first node. */
-
- if (osm_node_get_type(p_node_1) != IB_NODE_TYPE_SWITCH) {
- osm_physp_t *tmp = p_physp1;
- p_physp1 = p_physp2;
- p_physp2 = tmp;
- p_node_1 = p_physp1->p_node;
- p_node_2 = p_physp2->p_node;
- }
-
- if (!p_node_1->sw) {
- /* something is wrong - we'd better not use cache */
- osm_ucast_cache_invalidate(p_mgr);
- goto Exit;
- }
-
- lid_ho_1 = cl_ntoh16(osm_node_get_base_lid(p_node_1, 0));
-
- if (osm_node_get_type(p_node_2) == IB_NODE_TYPE_SWITCH) {
-
- if (!p_node_2->sw) {
- /* something is wrong - we'd better not use cache */
- osm_ucast_cache_invalidate(p_mgr);
- goto Exit;
- }
-
- lid_ho_2 = cl_ntoh16(osm_node_get_base_lid(p_node_2, 0));
-
- /* lost switch-2-switch link - cache both sides */
- __cache_add_sw_link(p_mgr, p_physp1, lid_ho_2, FALSE);
- __cache_add_sw_link(p_mgr, p_physp2, lid_ho_1, FALSE);
- } else {
- lid_ho_2 = cl_ntoh16(osm_physp_get_base_lid(p_physp2));
-
- /* lost link to CA/RTR - cache only switch side */
- __cache_add_sw_link(p_mgr, p_physp1, lid_ho_2, TRUE);
- }
-
-Exit:
- OSM_LOG_EXIT(p_mgr->p_log);
-} /* osm_ucast_cache_add_link() */
-
-/**********************************************************************
- **********************************************************************/
-
-void osm_ucast_cache_add_node(osm_ucast_mgr_t * p_mgr, osm_node_t * p_node)
-{
- uint16_t lid_ho;
- uint8_t max_ports;
- uint8_t port_num;
- osm_physp_t *p_physp;
- cache_switch_t *p_cache_sw;
-
- OSM_LOG_ENTER(p_mgr->p_log);
-
- if (!p_mgr->cache_valid)
- goto Exit;
-
- if (osm_node_get_type(p_node) == IB_NODE_TYPE_SWITCH) {
-
- lid_ho = cl_ntoh16(osm_node_get_base_lid(p_node, 0));
-
- OSM_LOG(p_mgr->p_log, OSM_LOG_DEBUG,
- "Caching dropped switch lid %u\n", lid_ho);
-
- if (!p_node->sw) {
- /* something is wrong - forget about cache */
- OSM_LOG(p_mgr->p_log, OSM_LOG_ERROR,
- "ERR AD03: no switch info for node lid %u - "
- "clearing cache\n", lid_ho);
- osm_ucast_cache_invalidate(p_mgr);
- goto Exit;
- }
-
- /* unlink (add to cache) all the ports of this switch */
- max_ports = osm_node_get_num_physp(p_node);
- for (port_num = 1; port_num < max_ports; port_num++) {
-
- p_physp = osm_node_get_physp_ptr(p_node, port_num);
- if (!p_physp || !p_physp->p_remote_physp)
- continue;
-
- osm_ucast_cache_add_link(p_mgr, p_physp,
- p_physp->p_remote_physp);
- }
-
- /*
- * All the ports have been dropped (cached).
- * If one of the ports was connected to CA/RTR,
- * then the cached switch would be marked as leaf.
- * If it isn't, then the dropped switch isn't a leaf,
- * and cache can't handle it.
- */
-
- p_cache_sw = __cache_get_sw(p_mgr, lid_ho);
- CL_ASSERT(p_cache_sw);
-
- if (!__cache_sw_is_leaf(p_cache_sw)) {
- OSM_LOG(p_mgr->p_log, OSM_LOG_INFO,
- "Dropped non-leaf switch (lid %u) - "
- "cache is invalid\n", lid_ho);
- osm_ucast_cache_invalidate(p_mgr);
- goto Exit;
- }
-
- p_cache_sw->dropped = TRUE;
-
- if (!p_node->sw->num_hops || !p_node->sw->hops) {
- OSM_LOG(p_mgr->p_log, OSM_LOG_INFO,
- "No LID matrices for switch lid %u - "
- "cache is invalid\n", lid_ho);
- osm_ucast_cache_invalidate(p_mgr);
- goto Exit;
- }
-
- /* lid matrices */
-
- p_cache_sw->num_hops = p_node->sw->num_hops;
- p_node->sw->num_hops = 0;
- p_cache_sw->hops = p_node->sw->hops;
- p_node->sw->hops = NULL;
-
- /* linear forwarding table */
-
- if (p_node->sw->new_lft) {
- /* LFT buffer exists - we use it, because
- it is more updated than the switch's LFT */
- p_cache_sw->lft = p_node->sw->new_lft;
- p_node->sw->new_lft = NULL;
- } else {
- /* no LFT buffer, so we use the switch's LFT */
- p_cache_sw->lft = p_node->sw->lft;
- p_node->sw->lft = NULL;
- }
- p_cache_sw->max_lid_ho = p_node->sw->max_lid_ho;
- } else {
- /* dropping CA/RTR: add to cache all the ports of this node */
- max_ports = osm_node_get_num_physp(p_node);
- for (port_num = 1; port_num < max_ports; port_num++) {
-
- p_physp = osm_node_get_physp_ptr(p_node, port_num);
- if (!p_physp || !p_physp->p_remote_physp)
- continue;
-
- CL_ASSERT(osm_node_get_type
- (p_physp->p_remote_physp->p_node) ==
- IB_NODE_TYPE_SWITCH);
-
- osm_ucast_cache_add_link(p_mgr,
- p_physp->p_remote_physp,
- p_physp);
- }
- }
-Exit:
- OSM_LOG_EXIT(p_mgr->p_log);
-} /* osm_ucast_cache_add_node() */
-
-/**********************************************************************
- **********************************************************************/
-
-int osm_ucast_cache_process(osm_ucast_mgr_t * p_mgr)
-{
- cl_qmap_t *tbl = &p_mgr->p_subn->sw_guid_tbl;
- cl_map_item_t *item;
- osm_switch_t *p_sw;
-
- if (!p_mgr->p_subn->opt.use_ucast_cache)
- return 1;
-
- ucast_cache_validate(p_mgr);
- if (!p_mgr->cache_valid)
- return 1;
-
- OSM_LOG(p_mgr->p_log, OSM_LOG_INFO,
- "Configuring switch tables using cached routing\n");
-
- for (item = cl_qmap_head(tbl); item != cl_qmap_end(tbl);
- item = cl_qmap_next(item)) {
- p_sw = (osm_switch_t *) item;
-
- if (p_sw->need_update && !p_sw->new_lft) {
- /* no new routing was recently calculated for this
- switch, but the LFT needs to be updated anyway */
- p_sw->new_lft = p_sw->lft;
- p_sw->lft = malloc(IB_LID_UCAST_END_HO + 1);
- if (!p_sw->lft)
- return IB_INSUFFICIENT_MEMORY;
- memset(p_sw->lft, OSM_NO_PATH, IB_LID_UCAST_END_HO + 1);
- }
-
- osm_ucast_mgr_set_fwd_table(p_mgr, p_sw);
- }
-
- return 0;
-}
-
-/**********************************************************************
- **********************************************************************/
diff --git a/contrib/ofed/management/opensm/opensm/osm_ucast_file.c b/contrib/ofed/management/opensm/opensm/osm_ucast_file.c
deleted file mode 100644
index 2505c46..0000000
--- a/contrib/ofed/management/opensm/opensm/osm_ucast_file.c
+++ /dev/null
@@ -1,396 +0,0 @@
-/*
- * Copyright (c) 2006,2007 Voltaire, Inc. All rights reserved.
- * Copyright (c) 2008 Mellanox Technologies LTD. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- */
-
-/*
- * Abstract:
- * Implementation of OpenSM unicast routing module which loads
- * routes from the dump file
- */
-
-#if HAVE_CONFIG_H
-# include <config.h>
-#endif /* HAVE_CONFIG_H */
-
-#include <stdlib.h>
-#include <string.h>
-#include <ctype.h>
-
-#include <iba/ib_types.h>
-#include <complib/cl_qmap.h>
-#include <complib/cl_debug.h>
-#include <opensm/osm_opensm.h>
-#include <opensm/osm_switch.h>
-#include <opensm/osm_log.h>
-
-static uint16_t remap_lid(osm_opensm_t * p_osm, uint16_t lid, ib_net64_t guid)
-{
- osm_port_t *p_port;
- uint16_t min_lid, max_lid;
- uint8_t lmc;
-
- p_port = osm_get_port_by_guid(&p_osm->subn, guid);
- if (!p_port) {
- OSM_LOG(&p_osm->log, OSM_LOG_VERBOSE,
- "cannot find port guid 0x%016" PRIx64
- " , will use the same lid\n", cl_ntoh64(guid));
- return lid;
- }
-
- osm_port_get_lid_range_ho(p_port, &min_lid, &max_lid);
- if (min_lid <= lid && lid <= max_lid)
- return lid;
-
- lmc = osm_port_get_lmc(p_port);
- return min_lid + (lid & ((1 << lmc) - 1));
-}
-
-static void add_path(osm_opensm_t * p_osm,
- osm_switch_t * p_sw, uint16_t lid, uint8_t port_num,
- ib_net64_t port_guid)
-{
- uint16_t new_lid;
- uint8_t old_port;
-
- new_lid = port_guid ? remap_lid(p_osm, lid, port_guid) : lid;
- old_port = osm_switch_get_port_by_lid(p_sw, new_lid);
- if (old_port != OSM_NO_PATH && old_port != port_num) {
- OSM_LOG(&p_osm->log, OSM_LOG_VERBOSE,
- "LID collision is detected on switch "
- "0x016%" PRIx64 ", will overwrite LID %u entry\n",
- cl_ntoh64(osm_node_get_node_guid(p_sw->p_node)),
- new_lid);
- }
-
- p_sw->new_lft[new_lid] = port_num;
- if (!(p_osm->subn.opt.port_profile_switch_nodes && port_guid &&
- osm_get_switch_by_guid(&p_osm->subn, port_guid)))
- osm_switch_count_path(p_sw, port_num);
-
- OSM_LOG(&p_osm->log, OSM_LOG_DEBUG,
- "route 0x%04x(was 0x%04x) %u 0x%016" PRIx64
- " is added to switch 0x%016" PRIx64 "\n",
- new_lid, lid, port_num, cl_ntoh64(port_guid),
- cl_ntoh64(osm_node_get_node_guid(p_sw->p_node)));
-}
-
-static void add_lid_hops(osm_opensm_t * p_osm, osm_switch_t * p_sw,
- uint16_t lid, ib_net64_t guid,
- uint8_t hops[], unsigned len)
-{
- uint16_t new_lid;
- uint8_t i;
-
- new_lid = guid ? remap_lid(p_osm, lid, guid) : lid;
- if (len > p_sw->num_ports)
- len = p_sw->num_ports;
-
- for (i = 0; i < len; i++)
- osm_switch_set_hops(p_sw, lid, i, hops[i]);
-}
-
-static int do_ucast_file_load(void *context)
-{
- char line[1024];
- char *file_name;
- FILE *file;
- ib_net64_t sw_guid, port_guid;
- osm_opensm_t *p_osm = context;
- osm_switch_t *p_sw;
- uint16_t lid;
- uint8_t port_num;
- unsigned lineno;
-
- file_name = p_osm->subn.opt.lfts_file;
- if (!file_name) {
- OSM_LOG(&p_osm->log, OSM_LOG_VERBOSE,
- "LFTs file name is not given; "
- "using default routing algorithm\n");
- return 1;
- }
-
- file = fopen(file_name, "r");
- if (!file) {
- OSM_LOG(&p_osm->log, OSM_LOG_ERROR | OSM_LOG_SYS, "ERR 6302: "
- "cannot open ucast dump file \'%s\': %m\n", file_name);
- return -1;
- }
-
- lineno = 0;
- p_sw = NULL;
-
- while (fgets(line, sizeof(line) - 1, file) != NULL) {
- char *p, *q;
- lineno++;
-
- p = line;
- while (isspace(*p))
- p++;
-
- if (*p == '#')
- continue;
-
- if (!strncmp(p, "Multicast mlids", 15)) {
- OSM_LOG(&p_osm->log, OSM_LOG_ERROR | OSM_LOG_SYS,
- "ERR 6303: "
- "Multicast dump file detected; "
- "skipping parsing. Using default "
- "routing algorithm\n");
- } else if (!strncmp(p, "Unicast lids", 12)) {
- if (p_sw)
- osm_ucast_mgr_set_fwd_table(&p_osm->sm.
- ucast_mgr, p_sw);
- q = strstr(p, " guid 0x");
- if (!q) {
- OSM_LOG(&p_osm->log, OSM_LOG_ERROR,
- "PARSE ERROR: %s:%u: "
- "cannot parse switch definition\n",
- file_name, lineno);
- return -1;
- }
- p = q + 8;
- sw_guid = strtoull(p, &q, 16);
- if (q == p || !isspace(*q)) {
- OSM_LOG(&p_osm->log, OSM_LOG_ERROR,
- "PARSE ERROR: %s:%u: "
- "cannot parse switch guid: \'%s\'\n",
- file_name, lineno, p);
- return -1;
- }
- sw_guid = cl_hton64(sw_guid);
-
- p_sw = osm_get_switch_by_guid(&p_osm->subn, sw_guid);
- if (!p_sw) {
- OSM_LOG(&p_osm->log, OSM_LOG_VERBOSE,
- "cannot find switch %016" PRIx64 "\n",
- cl_ntoh64(sw_guid));
- continue;
- }
- memset(p_sw->new_lft, OSM_NO_PATH,
- IB_LID_UCAST_END_HO + 1);
- } else if (p_sw && !strncmp(p, "0x", 2)) {
- p += 2;
- lid = (uint16_t) strtoul(p, &q, 16);
- if (q == p || !isspace(*q)) {
- OSM_LOG(&p_osm->log, OSM_LOG_ERROR,
- "PARSE ERROR: %s:%u: "
- "cannot parse lid: \'%s\'\n",
- file_name, lineno, p);
- return -1;
- }
- p = q;
- while (isspace(*p))
- p++;
- port_num = (uint8_t) strtoul(p, &q, 10);
- if (q == p || !isspace(*q)) {
- OSM_LOG(&p_osm->log, OSM_LOG_ERROR,
- "PARSE ERROR: %s:%u: "
- "cannot parse port: \'%s\'\n",
- file_name, lineno, p);
- return -1;
- }
- p = q;
- /* additionally try to exract guid */
- q = strstr(p, " portguid 0x");
- if (!q) {
- OSM_LOG(&p_osm->log, OSM_LOG_VERBOSE,
- "PARSE WARNING: %s:%u: "
- "cannot find port guid "
- "(maybe broken dump): \'%s\'\n",
- file_name, lineno, p);
- port_guid = 0;
- } else {
- p = q + 12;
- port_guid = strtoull(p, &q, 16);
- if (q == p || (!isspace(*q) && *q != ':')) {
- OSM_LOG(&p_osm->log, OSM_LOG_VERBOSE,
- "PARSE WARNING: %s:%u: "
- "cannot parse port guid "
- "(maybe broken dump): \'%s\'\n",
- file_name, lineno, p);
- port_guid = 0;
- }
- }
- port_guid = cl_hton64(port_guid);
- add_path(p_osm, p_sw, lid, port_num, port_guid);
- }
- }
-
- if (p_sw)
- osm_ucast_mgr_set_fwd_table(&p_osm->sm.ucast_mgr, p_sw);
-
- fclose(file);
- return 0;
-}
-
-static int do_lid_matrix_file_load(void *context)
-{
- char line[1024];
- uint8_t hops[256];
- char *file_name;
- FILE *file;
- ib_net64_t guid;
- osm_opensm_t *p_osm = context;
- osm_switch_t *p_sw;
- unsigned lineno;
- uint16_t lid;
-
- file_name = p_osm->subn.opt.lid_matrix_dump_file;
- if (!file_name) {
- OSM_LOG(&p_osm->log, OSM_LOG_VERBOSE,
- "lid matrix file name is not given; "
- "using default lid matrix generation algorithm\n");
- return 1;
- }
-
- file = fopen(file_name, "r");
- if (!file) {
- OSM_LOG(&p_osm->log, OSM_LOG_ERROR | OSM_LOG_SYS, "ERR 6305: "
- "cannot open lid matrix file \'%s\': %m\n", file_name);
- return -1;
- }
-
- lineno = 0;
- p_sw = NULL;
-
- while (fgets(line, sizeof(line) - 1, file) != NULL) {
- char *p, *q;
- lineno++;
-
- p = line;
- while (isspace(*p))
- p++;
-
- if (*p == '#')
- continue;
-
- if (!strncmp(p, "Switch", 6)) {
- q = strstr(p, " guid 0x");
- if (!q) {
- OSM_LOG(&p_osm->log, OSM_LOG_ERROR,
- "PARSE ERROR: %s:%u: "
- "cannot parse switch definition\n",
- file_name, lineno);
- return -1;
- }
- p = q + 8;
- guid = strtoull(p, &q, 16);
- if (q == p || !isspace(*q)) {
- OSM_LOG(&p_osm->log, OSM_LOG_ERROR,
- "PARSE ERROR: %s:%u: "
- "cannot parse switch guid: \'%s\'\n",
- file_name, lineno, p);
- return -1;
- }
- guid = cl_hton64(guid);
-
- p_sw = osm_get_switch_by_guid(&p_osm->subn, guid);
- if (!p_sw) {
- OSM_LOG(&p_osm->log, OSM_LOG_VERBOSE,
- "cannot find switch %016" PRIx64 "\n",
- cl_ntoh64(guid));
- continue;
- }
- } else if (p_sw && !strncmp(p, "0x", 2)) {
- unsigned long num;
- unsigned len = 0;
-
- memset(hops, 0xff, sizeof(hops));
-
- p += 2;
- num = strtoul(p, &q, 16);
- if (num > 0xffff || q == p ||
- (*q != ':' && !isspace(*q))) {
- OSM_LOG(&p_osm->log, OSM_LOG_ERROR,
- "PARSE ERROR: %s:%u: "
- "cannot parse lid: \'%s\'\n",
- file_name, lineno, p);
- return -1;
- }
- /* Just checked the range, so casting is safe */
- lid = (uint16_t) num;
- p = q;
- while (isspace(*p) || *p == ':')
- p++;
- while (len < 256 && *p && *p != '#') {
- num = strtoul(p, &q, 16);
- if (num > 0xff || q == p) {
- OSM_LOG(&p_osm->log, OSM_LOG_ERROR,
- "PARSE ERROR: %s:%u: "
- "cannot parse hops number: \'%s\'\n",
- file_name, lineno, p);
- return -1;
- }
- /* Just checked the range, so casting is safe */
- hops[len++] = (uint8_t) num;
- p = q;
- while (isspace(*p))
- p++;
- }
- /* additionally try to extract guid */
- q = strstr(p, " portguid 0x");
- if (!q) {
- OSM_LOG(&p_osm->log, OSM_LOG_VERBOSE,
- "PARSE WARNING: %s:%u: "
- "cannot find port guid "
- "(maybe broken dump): \'%s\'\n",
- file_name, lineno, p);
- guid = 0;
- } else {
- p = q + 12;
- guid = strtoull(p, &q, 16);
- if (q == p || !isspace(*q)) {
- OSM_LOG(&p_osm->log, OSM_LOG_VERBOSE,
- "PARSE WARNING: %s:%u: "
- "cannot parse port guid "
- "(maybe broken dump): \'%s\'\n",
- file_name, lineno, p);
- guid = 0;
- }
- }
- guid = cl_hton64(guid);
- add_lid_hops(p_osm, p_sw, lid, guid, hops, len);
- }
- }
-
- fclose(file);
- return 0;
-}
-
-int osm_ucast_file_setup(struct osm_routing_engine *r, osm_opensm_t *osm)
-{
- r->context = osm;
- r->build_lid_matrices = do_lid_matrix_file_load;
- r->ucast_build_fwd_tables = do_ucast_file_load;
- return 0;
-}
diff --git a/contrib/ofed/management/opensm/opensm/osm_ucast_ftree.c b/contrib/ofed/management/opensm/opensm/osm_ucast_ftree.c
deleted file mode 100644
index 88a8c7b..0000000
--- a/contrib/ofed/management/opensm/opensm/osm_ucast_ftree.c
+++ /dev/null
@@ -1,3673 +0,0 @@
-/*
- * Copyright (c) 2004-2008 Voltaire, Inc. All rights reserved.
- * Copyright (c) 2002-2007 Mellanox Technologies LTD. All rights reserved.
- * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- */
-
-/*
- * Abstract:
- * Implementation of OpenSM FatTree routing
- */
-
-#if HAVE_CONFIG_H
-# include <config.h>
-#endif
-
-#include <stdlib.h>
-#include <string.h>
-#include <ctype.h>
-#include <errno.h>
-#include <iba/ib_types.h>
-#include <complib/cl_qmap.h>
-#include <complib/cl_debug.h>
-#include <opensm/osm_opensm.h>
-#include <opensm/osm_switch.h>
-
-/*
- * FatTree rank is bounded between 2 and 8:
- * - Tree of rank 1 has only trivial routing paths,
- * so no need to use FatTree routing.
- * - Why maximum rank is 8:
- * Each node (switch) is assigned a unique tuple.
- * Switches are stored in two cl_qmaps - one is
- * ordered by guid, and the other by a key that is
- * generated from tuple. Since cl_qmap supports only
- * a 64-bit key, the maximal tuple lenght is 8 bytes.
- * which means that maximal tree rank is 8.
- * Note that the above also implies that each switch
- * can have at max 255 up/down ports.
- */
-
-#define FAT_TREE_MIN_RANK 2
-#define FAT_TREE_MAX_RANK 8
-
-typedef enum {
- FTREE_DIRECTION_DOWN = -1,
- FTREE_DIRECTION_SAME,
- FTREE_DIRECTION_UP
-} ftree_direction_t;
-
-/***************************************************
- **
- ** Forward references
- **
- ***************************************************/
-
-struct ftree_sw_t_;
-struct ftree_hca_t_;
-struct ftree_port_t_;
-struct ftree_port_group_t_;
-struct ftree_fabric_t_;
-
-/***************************************************
- **
- ** ftree_tuple_t definition
- **
- ***************************************************/
-
-#define FTREE_TUPLE_BUFF_LEN 1024
-#define FTREE_TUPLE_LEN 8
-
-typedef uint8_t ftree_tuple_t[FTREE_TUPLE_LEN];
-typedef uint64_t ftree_tuple_key_t;
-
-struct guid_list_item {
- cl_list_item_t list;
- uint64_t guid;
-};
-
-/***************************************************
- **
- ** ftree_sw_table_element_t definition
- **
- ***************************************************/
-
-typedef struct {
- cl_map_item_t map_item;
- struct ftree_sw_t_ *p_sw;
-} ftree_sw_tbl_element_t;
-
-/***************************************************
- **
- ** ftree_port_t definition
- **
- ***************************************************/
-
-typedef struct ftree_port_t_ {
- cl_map_item_t map_item;
- uint8_t port_num; /* port number on the current node */
- uint8_t remote_port_num; /* port number on the remote node */
- uint32_t counter_up; /* number of allocated routs upwards */
- uint32_t counter_down; /* number of allocated routs downwards */
-} ftree_port_t;
-
-/***************************************************
- **
- ** ftree_port_group_t definition
- **
- ***************************************************/
-
-typedef union ftree_hca_or_sw_ {
- struct ftree_hca_t_ *p_hca;
- struct ftree_sw_t_ *p_sw;
-} ftree_hca_or_sw;
-
-typedef struct ftree_port_group_t_ {
- cl_map_item_t map_item;
- ib_net16_t base_lid; /* base lid of the current node */
- ib_net16_t remote_base_lid; /* base lid of the remote node */
- ib_net64_t port_guid; /* port guid of this port */
- ib_net64_t node_guid; /* this node's guid */
- uint8_t node_type; /* this node's type */
- ib_net64_t remote_port_guid; /* port guid of the remote port */
- ib_net64_t remote_node_guid; /* node guid of the remote node */
- uint8_t remote_node_type; /* IB_NODE_TYPE_{CA,SWITCH,ROUTER,...} */
- ftree_hca_or_sw hca_or_sw; /* pointer to this hca/switch */
- ftree_hca_or_sw remote_hca_or_sw; /* pointer to remote hca/switch */
- cl_ptr_vector_t ports; /* vector of ports to the same lid */
- boolean_t is_cn; /* whether this port is a compute node */
- uint32_t counter_down; /* number of allocated routs downwards */
-} ftree_port_group_t;
-
-/***************************************************
- **
- ** ftree_sw_t definition
- **
- ***************************************************/
-
-typedef struct ftree_sw_t_ {
- cl_map_item_t map_item;
- osm_switch_t *p_osm_sw;
- uint32_t rank;
- ftree_tuple_t tuple;
- ib_net16_t base_lid;
- ftree_port_group_t **down_port_groups;
- uint8_t down_port_groups_num;
- ftree_port_group_t **up_port_groups;
- uint8_t up_port_groups_num;
- boolean_t is_leaf;
- int down_port_groups_idx;
-} ftree_sw_t;
-
-/***************************************************
- **
- ** ftree_hca_t definition
- **
- ***************************************************/
-
-typedef struct ftree_hca_t_ {
- cl_map_item_t map_item;
- osm_node_t *p_osm_node;
- ftree_port_group_t **up_port_groups;
- uint16_t up_port_groups_num;
- unsigned cn_num;
-} ftree_hca_t;
-
-/***************************************************
- **
- ** ftree_fabric_t definition
- **
- ***************************************************/
-
-typedef struct ftree_fabric_t_ {
- osm_opensm_t *p_osm;
- cl_qmap_t hca_tbl;
- cl_qmap_t sw_tbl;
- cl_qmap_t sw_by_tuple_tbl;
- cl_qlist_t root_guid_list;
- cl_qmap_t cn_guid_tbl;
- unsigned cn_num;
- uint8_t leaf_switch_rank;
- uint8_t max_switch_rank;
- ftree_sw_t **leaf_switches;
- uint32_t leaf_switches_num;
- uint16_t max_cn_per_leaf;
- uint16_t lft_max_lid_ho;
- boolean_t fabric_built;
-} ftree_fabric_t;
-
-/***************************************************
- **
- ** comparators
- **
- ***************************************************/
-
-static int OSM_CDECL __osm_ftree_compare_switches_by_index(IN const void *p1,
- IN const void *p2)
-{
- ftree_sw_t **pp_sw1 = (ftree_sw_t **) p1;
- ftree_sw_t **pp_sw2 = (ftree_sw_t **) p2;
-
- uint16_t i;
- for (i = 0; i < FTREE_TUPLE_LEN; i++) {
- if ((*pp_sw1)->tuple[i] > (*pp_sw2)->tuple[i])
- return 1;
- if ((*pp_sw1)->tuple[i] < (*pp_sw2)->tuple[i])
- return -1;
- }
- return 0;
-}
-
-/***************************************************/
-
-static int OSM_CDECL
-__osm_ftree_compare_port_groups_by_remote_switch_index(IN const void *p1,
- IN const void *p2)
-{
- ftree_port_group_t **pp_g1 = (ftree_port_group_t **) p1;
- ftree_port_group_t **pp_g2 = (ftree_port_group_t **) p2;
-
- return
- __osm_ftree_compare_switches_by_index(&
- ((*pp_g1)->remote_hca_or_sw.
- p_sw),
- &((*pp_g2)->remote_hca_or_sw.
- p_sw));
-}
-
-/***************************************************
- **
- ** ftree_tuple_t functions
- **
- ***************************************************/
-
-static void __osm_ftree_tuple_init(IN ftree_tuple_t tuple)
-{
- memset(tuple, 0xFF, FTREE_TUPLE_LEN);
-}
-
-/***************************************************/
-
-static inline boolean_t __osm_ftree_tuple_assigned(IN ftree_tuple_t tuple)
-{
- return (tuple[0] != 0xFF);
-}
-
-/***************************************************/
-
-#define FTREE_TUPLE_BUFFERS_NUM 6
-
-static char *__osm_ftree_tuple_to_str(IN ftree_tuple_t tuple)
-{
- static char buffer[FTREE_TUPLE_BUFFERS_NUM][FTREE_TUPLE_BUFF_LEN];
- static uint8_t ind = 0;
- char *ret_buffer;
- uint32_t i;
-
- if (!__osm_ftree_tuple_assigned(tuple))
- return "INDEX.NOT.ASSIGNED";
-
- buffer[ind][0] = '\0';
-
- for (i = 0; (i < FTREE_TUPLE_LEN) && (tuple[i] != 0xFF); i++) {
- if ((strlen(buffer[ind]) + 10) > FTREE_TUPLE_BUFF_LEN)
- return "INDEX.TOO.LONG";
- if (i != 0)
- strcat(buffer[ind], ".");
- sprintf(&buffer[ind][strlen(buffer[ind])], "%u", tuple[i]);
- }
-
- ret_buffer = buffer[ind];
- ind = (ind + 1) % FTREE_TUPLE_BUFFERS_NUM;
- return ret_buffer;
-} /* __osm_ftree_tuple_to_str() */
-
-/***************************************************/
-
-static inline ftree_tuple_key_t __osm_ftree_tuple_to_key(IN ftree_tuple_t tuple)
-{
- ftree_tuple_key_t key;
- memcpy(&key, tuple, FTREE_TUPLE_LEN);
- return key;
-}
-
-/***************************************************/
-
-static inline void __osm_ftree_tuple_from_key(IN ftree_tuple_t tuple,
- IN ftree_tuple_key_t key)
-{
- memcpy(tuple, &key, FTREE_TUPLE_LEN);
-}
-
-/***************************************************
- **
- ** ftree_sw_tbl_element_t functions
- **
- ***************************************************/
-
-static ftree_sw_tbl_element_t *__osm_ftree_sw_tbl_element_create(IN ftree_sw_t *
- p_sw)
-{
- ftree_sw_tbl_element_t *p_element =
- (ftree_sw_tbl_element_t *) malloc(sizeof(ftree_sw_tbl_element_t));
- if (!p_element)
- return NULL;
- memset(p_element, 0, sizeof(ftree_sw_tbl_element_t));
-
- p_element->p_sw = p_sw;
- return p_element;
-}
-
-/***************************************************/
-
-static void __osm_ftree_sw_tbl_element_destroy(IN ftree_sw_tbl_element_t *
- p_element)
-{
- if (!p_element)
- return;
- free(p_element);
-}
-
-/***************************************************
- **
- ** ftree_port_t functions
- **
- ***************************************************/
-
-static ftree_port_t *__osm_ftree_port_create(IN uint8_t port_num,
- IN uint8_t remote_port_num)
-{
- ftree_port_t *p_port = (ftree_port_t *) malloc(sizeof(ftree_port_t));
- if (!p_port)
- return NULL;
- memset(p_port, 0, sizeof(ftree_port_t));
-
- p_port->port_num = port_num;
- p_port->remote_port_num = remote_port_num;
-
- return p_port;
-}
-
-/***************************************************/
-
-static void __osm_ftree_port_destroy(IN ftree_port_t * p_port)
-{
- if (p_port)
- free(p_port);
-}
-
-/***************************************************
- **
- ** ftree_port_group_t functions
- **
- ***************************************************/
-
-static ftree_port_group_t *
-__osm_ftree_port_group_create(IN ib_net16_t base_lid,
- IN ib_net16_t remote_base_lid,
- IN ib_net64_t port_guid,
- IN ib_net64_t node_guid,
- IN uint8_t node_type,
- IN void *p_hca_or_sw,
- IN ib_net64_t remote_port_guid,
- IN ib_net64_t remote_node_guid,
- IN uint8_t remote_node_type,
- IN void *p_remote_hca_or_sw,
- IN boolean_t is_cn)
-{
- ftree_port_group_t *p_group =
- (ftree_port_group_t *) malloc(sizeof(ftree_port_group_t));
- if (p_group == NULL)
- return NULL;
- memset(p_group, 0, sizeof(ftree_port_group_t));
-
- p_group->base_lid = base_lid;
- p_group->remote_base_lid = remote_base_lid;
- memcpy(&p_group->port_guid, &port_guid, sizeof(ib_net64_t));
- memcpy(&p_group->node_guid, &node_guid, sizeof(ib_net64_t));
- memcpy(&p_group->remote_port_guid, &remote_port_guid,
- sizeof(ib_net64_t));
- memcpy(&p_group->remote_node_guid, &remote_node_guid,
- sizeof(ib_net64_t));
-
- p_group->node_type = node_type;
- switch (node_type) {
- case IB_NODE_TYPE_CA:
- p_group->hca_or_sw.p_hca = (ftree_hca_t *) p_hca_or_sw;
- break;
- case IB_NODE_TYPE_SWITCH:
- p_group->hca_or_sw.p_sw = (ftree_sw_t *) p_hca_or_sw;
- break;
- default:
- /* we shouldn't get here - port is created only in hca or switch */
- CL_ASSERT(0);
- }
-
- p_group->remote_node_type = remote_node_type;
- switch (remote_node_type) {
- case IB_NODE_TYPE_CA:
- p_group->remote_hca_or_sw.p_hca =
- (ftree_hca_t *) p_remote_hca_or_sw;
- break;
- case IB_NODE_TYPE_SWITCH:
- p_group->remote_hca_or_sw.p_sw =
- (ftree_sw_t *) p_remote_hca_or_sw;
- break;
- default:
- /* we shouldn't get here - port is created only in hca or switch */
- CL_ASSERT(0);
- }
-
- cl_ptr_vector_init(&p_group->ports, 0, /* min size */
- 8); /* grow size */
- p_group->is_cn = is_cn;
- return p_group;
-} /* __osm_ftree_port_group_create() */
-
-/***************************************************/
-
-static void __osm_ftree_port_group_destroy(IN ftree_port_group_t * p_group)
-{
- uint32_t i;
- uint32_t size;
- ftree_port_t *p_port;
-
- if (!p_group)
- return;
-
- /* remove all the elements of p_group->ports vector */
- size = cl_ptr_vector_get_size(&p_group->ports);
- for (i = 0; i < size; i++) {
- cl_ptr_vector_at(&p_group->ports, i, (void *)&p_port);
- __osm_ftree_port_destroy(p_port);
- }
- cl_ptr_vector_destroy(&p_group->ports);
- free(p_group);
-} /* __osm_ftree_port_group_destroy() */
-
-/***************************************************/
-
-static void
-__osm_ftree_port_group_dump(IN ftree_fabric_t * p_ftree,
- IN ftree_port_group_t * p_group,
- IN ftree_direction_t direction)
-{
- ftree_port_t *p_port;
- uint32_t size;
- uint32_t i;
- char buff[10 * 1024];
-
- if (!p_group)
- return;
-
- if (!osm_log_is_active(&p_ftree->p_osm->log, OSM_LOG_DEBUG))
- return;
-
- size = cl_ptr_vector_get_size(&p_group->ports);
- buff[0] = '\0';
-
- for (i = 0; i < size; i++) {
- cl_ptr_vector_at(&p_group->ports, i, (void *)&p_port);
- CL_ASSERT(p_port);
-
- if (i != 0)
- strcat(buff, ", ");
- sprintf(buff + strlen(buff), "%u", p_port->port_num);
- }
-
- OSM_LOG(&p_ftree->p_osm->log, OSM_LOG_DEBUG,
- " Port Group of size %u, port(s): %s, direction: %s\n"
- " Local <--> Remote GUID (LID):"
- "0x%016" PRIx64 " (0x%04x) <--> 0x%016" PRIx64 " (0x%04x)\n",
- size,
- buff,
- (direction == FTREE_DIRECTION_DOWN) ? "DOWN" : "UP",
- cl_ntoh64(p_group->port_guid),
- cl_ntoh16(p_group->base_lid),
- cl_ntoh64(p_group->remote_port_guid),
- cl_ntoh16(p_group->remote_base_lid));
-
-} /* __osm_ftree_port_group_dump() */
-
-/***************************************************/
-
-static void
-__osm_ftree_port_group_add_port(IN ftree_port_group_t * p_group,
- IN uint8_t port_num, IN uint8_t remote_port_num)
-{
- uint16_t i;
- ftree_port_t *p_port;
-
- for (i = 0; i < cl_ptr_vector_get_size(&p_group->ports); i++) {
- cl_ptr_vector_at(&p_group->ports, i, (void *)&p_port);
- if (p_port->port_num == port_num)
- return;
- }
-
- p_port = __osm_ftree_port_create(port_num, remote_port_num);
- cl_ptr_vector_insert(&p_group->ports, p_port, NULL);
-}
-
-/***************************************************
- **
- ** ftree_sw_t functions
- **
- ***************************************************/
-
-static ftree_sw_t *__osm_ftree_sw_create(IN ftree_fabric_t * p_ftree,
- IN osm_switch_t * p_osm_sw)
-{
- ftree_sw_t *p_sw;
- uint8_t ports_num;
-
- /* make sure that the switch has ports */
- if (p_osm_sw->num_ports == 1)
- return NULL;
-
- p_sw = (ftree_sw_t *) malloc(sizeof(ftree_sw_t));
- if (p_sw == NULL)
- return NULL;
- memset(p_sw, 0, sizeof(ftree_sw_t));
-
- p_sw->p_osm_sw = p_osm_sw;
- p_sw->rank = 0xFFFFFFFF;
- __osm_ftree_tuple_init(p_sw->tuple);
-
- p_sw->base_lid = osm_node_get_base_lid(p_sw->p_osm_sw->p_node, 0);
-
- ports_num = osm_node_get_num_physp(p_sw->p_osm_sw->p_node);
- p_sw->down_port_groups =
- (ftree_port_group_t **) malloc(ports_num *
- sizeof(ftree_port_group_t *));
- p_sw->up_port_groups =
- (ftree_port_group_t **) malloc(ports_num *
- sizeof(ftree_port_group_t *));
- if (!p_sw->down_port_groups || !p_sw->up_port_groups)
- return NULL;
- p_sw->down_port_groups_num = 0;
- p_sw->up_port_groups_num = 0;
-
- /* initialize lft buffer */
- memset(p_osm_sw->new_lft, OSM_NO_PATH, IB_LID_UCAST_END_HO + 1);
-
- p_sw->down_port_groups_idx = -1;
-
- return p_sw;
-} /* __osm_ftree_sw_create() */
-
-/***************************************************/
-
-static void __osm_ftree_sw_destroy(IN ftree_fabric_t * p_ftree,
- IN ftree_sw_t * p_sw)
-{
- uint8_t i;
-
- if (!p_sw)
- return;
-
- for (i = 0; i < p_sw->down_port_groups_num; i++)
- __osm_ftree_port_group_destroy(p_sw->down_port_groups[i]);
- for (i = 0; i < p_sw->up_port_groups_num; i++)
- __osm_ftree_port_group_destroy(p_sw->up_port_groups[i]);
- if (p_sw->down_port_groups)
- free(p_sw->down_port_groups);
- if (p_sw->up_port_groups)
- free(p_sw->up_port_groups);
-
- free(p_sw);
-} /* __osm_ftree_sw_destroy() */
-
-/***************************************************/
-
-static uint64_t __osm_ftree_sw_get_guid_no(IN ftree_sw_t * p_sw)
-{
- if (!p_sw)
- return 0;
- return osm_node_get_node_guid(p_sw->p_osm_sw->p_node);
-}
-
-/***************************************************/
-
-static uint64_t __osm_ftree_sw_get_guid_ho(IN ftree_sw_t * p_sw)
-{
- return cl_ntoh64(__osm_ftree_sw_get_guid_no(p_sw));
-}
-
-/***************************************************/
-
-static void __osm_ftree_sw_dump(IN ftree_fabric_t * p_ftree,
- IN ftree_sw_t * p_sw)
-{
- uint32_t i;
-
- if (!p_sw)
- return;
-
- if (!osm_log_is_active(&p_ftree->p_osm->log, OSM_LOG_DEBUG))
- return;
-
- OSM_LOG(&p_ftree->p_osm->log, OSM_LOG_DEBUG,
- "Switch index: %s, GUID: 0x%016" PRIx64
- ", Ports: %u DOWN, %u UP\n",
- __osm_ftree_tuple_to_str(p_sw->tuple),
- __osm_ftree_sw_get_guid_ho(p_sw), p_sw->down_port_groups_num,
- p_sw->up_port_groups_num);
-
- for (i = 0; i < p_sw->down_port_groups_num; i++)
- __osm_ftree_port_group_dump(p_ftree,
- p_sw->down_port_groups[i],
- FTREE_DIRECTION_DOWN);
- for (i = 0; i < p_sw->up_port_groups_num; i++)
- __osm_ftree_port_group_dump(p_ftree, p_sw->up_port_groups[i],
- FTREE_DIRECTION_UP);
-
-} /* __osm_ftree_sw_dump() */
-
-/***************************************************/
-
-static boolean_t __osm_ftree_sw_ranked(IN ftree_sw_t * p_sw)
-{
- return (p_sw->rank != 0xFFFFFFFF);
-}
-
-/***************************************************/
-
-static ftree_port_group_t *
-__osm_ftree_sw_get_port_group_by_remote_lid(IN ftree_sw_t * p_sw,
- IN ib_net16_t remote_base_lid,
- IN ftree_direction_t direction)
-{
- uint32_t i;
- uint32_t size;
- ftree_port_group_t **port_groups;
-
- if (direction == FTREE_DIRECTION_UP) {
- port_groups = p_sw->up_port_groups;
- size = p_sw->up_port_groups_num;
- } else {
- port_groups = p_sw->down_port_groups;
- size = p_sw->down_port_groups_num;
- }
-
- for (i = 0; i < size; i++)
- if (remote_base_lid == port_groups[i]->remote_base_lid)
- return port_groups[i];
-
- return NULL;
-} /* __osm_ftree_sw_get_port_group_by_remote_lid() */
-
-/***************************************************/
-
-static void
-__osm_ftree_sw_add_port(IN ftree_sw_t * p_sw,
- IN uint8_t port_num,
- IN uint8_t remote_port_num,
- IN ib_net16_t base_lid,
- IN ib_net16_t remote_base_lid,
- IN ib_net64_t port_guid,
- IN ib_net64_t remote_port_guid,
- IN ib_net64_t remote_node_guid,
- IN uint8_t remote_node_type,
- IN void *p_remote_hca_or_sw,
- IN ftree_direction_t direction)
-{
- ftree_port_group_t *p_group =
- __osm_ftree_sw_get_port_group_by_remote_lid(p_sw, remote_base_lid,
- direction);
-
- if (!p_group) {
- p_group = __osm_ftree_port_group_create(base_lid,
- remote_base_lid,
- port_guid,
- __osm_ftree_sw_get_guid_no
- (p_sw),
- IB_NODE_TYPE_SWITCH,
- p_sw, remote_port_guid,
- remote_node_guid,
- remote_node_type,
- p_remote_hca_or_sw,
- FALSE);
- CL_ASSERT(p_group);
-
- if (direction == FTREE_DIRECTION_UP)
- p_sw->up_port_groups[p_sw->up_port_groups_num++] =
- p_group;
- else
- p_sw->down_port_groups[p_sw->down_port_groups_num++] =
- p_group;
- }
- __osm_ftree_port_group_add_port(p_group, port_num, remote_port_num);
-
-} /* __osm_ftree_sw_add_port() */
-
-/***************************************************/
-
-static inline cl_status_t
-__osm_ftree_sw_set_hops(IN ftree_sw_t * p_sw,
- IN uint16_t lid_ho, IN uint8_t port_num,
- IN uint8_t hops)
-{
- /* set local min hop table(LID) */
- return osm_switch_set_hops(p_sw->p_osm_sw, lid_ho, port_num, hops);
-}
-
-/***************************************************
- **
- ** ftree_hca_t functions
- **
- ***************************************************/
-
-static ftree_hca_t *__osm_ftree_hca_create(IN osm_node_t * p_osm_node)
-{
- ftree_hca_t *p_hca = (ftree_hca_t *) malloc(sizeof(ftree_hca_t));
- if (p_hca == NULL)
- return NULL;
- memset(p_hca, 0, sizeof(ftree_hca_t));
-
- p_hca->p_osm_node = p_osm_node;
- p_hca->up_port_groups = (ftree_port_group_t **)
- malloc(osm_node_get_num_physp(p_hca->p_osm_node) *
- sizeof(ftree_port_group_t *));
- if (!p_hca->up_port_groups)
- return NULL;
- p_hca->up_port_groups_num = 0;
- return p_hca;
-}
-
-/***************************************************/
-
-static void __osm_ftree_hca_destroy(IN ftree_hca_t * p_hca)
-{
- uint32_t i;
-
- if (!p_hca)
- return;
-
- for (i = 0; i < p_hca->up_port_groups_num; i++)
- __osm_ftree_port_group_destroy(p_hca->up_port_groups[i]);
-
- if (p_hca->up_port_groups)
- free(p_hca->up_port_groups);
-
- free(p_hca);
-}
-
-/***************************************************/
-
-static uint64_t __osm_ftree_hca_get_guid_no(IN ftree_hca_t * p_hca)
-{
- if (!p_hca)
- return 0;
- return osm_node_get_node_guid(p_hca->p_osm_node);
-}
-
-/***************************************************/
-
-static uint64_t __osm_ftree_hca_get_guid_ho(IN ftree_hca_t * p_hca)
-{
- return cl_ntoh64(__osm_ftree_hca_get_guid_no(p_hca));
-}
-
-/***************************************************/
-
-static void __osm_ftree_hca_dump(IN ftree_fabric_t * p_ftree,
- IN ftree_hca_t * p_hca)
-{
- uint32_t i;
-
- if (!p_hca)
- return;
-
- if (!osm_log_is_active(&p_ftree->p_osm->log, OSM_LOG_DEBUG))
- return;
-
- OSM_LOG(&p_ftree->p_osm->log, OSM_LOG_DEBUG,
- "CA GUID: 0x%016" PRIx64 ", Ports: %u UP\n",
- __osm_ftree_hca_get_guid_ho(p_hca), p_hca->up_port_groups_num);
-
- for (i = 0; i < p_hca->up_port_groups_num; i++)
- __osm_ftree_port_group_dump(p_ftree, p_hca->up_port_groups[i],
- FTREE_DIRECTION_UP);
-}
-
-/***************************************************/
-
-static ftree_port_group_t *
-__osm_ftree_hca_get_port_group_by_remote_lid(IN ftree_hca_t * p_hca,
- IN ib_net16_t remote_base_lid)
-{
- uint32_t i;
- for (i = 0; i < p_hca->up_port_groups_num; i++)
- if (remote_base_lid ==
- p_hca->up_port_groups[i]->remote_base_lid)
- return p_hca->up_port_groups[i];
-
- return NULL;
-}
-
-/***************************************************/
-
-static void
-__osm_ftree_hca_add_port(IN ftree_hca_t * p_hca,
- IN uint8_t port_num,
- IN uint8_t remote_port_num,
- IN ib_net16_t base_lid,
- IN ib_net16_t remote_base_lid,
- IN ib_net64_t port_guid,
- IN ib_net64_t remote_port_guid,
- IN ib_net64_t remote_node_guid,
- IN uint8_t remote_node_type,
- IN void *p_remote_hca_or_sw, IN boolean_t is_cn)
-{
- ftree_port_group_t *p_group;
-
- /* this function is supposed to be called only for adding ports
- in hca's that lead to switches */
- CL_ASSERT(remote_node_type == IB_NODE_TYPE_SWITCH);
-
- p_group =
- __osm_ftree_hca_get_port_group_by_remote_lid(p_hca,
- remote_base_lid);
-
- if (!p_group) {
- p_group = __osm_ftree_port_group_create(base_lid,
- remote_base_lid,
- port_guid,
- __osm_ftree_hca_get_guid_no
- (p_hca),
- IB_NODE_TYPE_CA, p_hca,
- remote_port_guid,
- remote_node_guid,
- remote_node_type,
- p_remote_hca_or_sw,
- is_cn);
- p_hca->up_port_groups[p_hca->up_port_groups_num++] = p_group;
- }
- __osm_ftree_port_group_add_port(p_group, port_num, remote_port_num);
-
-} /* __osm_ftree_hca_add_port() */
-
-/***************************************************
- **
- ** ftree_fabric_t functions
- **
- ***************************************************/
-
-static ftree_fabric_t *__osm_ftree_fabric_create()
-{
- ftree_fabric_t *p_ftree =
- (ftree_fabric_t *) malloc(sizeof(ftree_fabric_t));
- if (p_ftree == NULL)
- return NULL;
-
- memset(p_ftree, 0, sizeof(ftree_fabric_t));
-
- cl_qmap_init(&p_ftree->hca_tbl);
- cl_qmap_init(&p_ftree->sw_tbl);
- cl_qmap_init(&p_ftree->sw_by_tuple_tbl);
- cl_qmap_init(&p_ftree->cn_guid_tbl);
-
- cl_qlist_init(&p_ftree->root_guid_list);
-
- return p_ftree;
-}
-
-/***************************************************/
-
-static void __osm_ftree_fabric_clear(ftree_fabric_t * p_ftree)
-{
- ftree_hca_t *p_hca;
- ftree_hca_t *p_next_hca;
- ftree_sw_t *p_sw;
- ftree_sw_t *p_next_sw;
- ftree_sw_tbl_element_t *p_element;
- ftree_sw_tbl_element_t *p_next_element;
- name_map_item_t *p_guid_element, *p_next_guid_element;
-
- if (!p_ftree)
- return;
-
- /* remove all the elements of hca_tbl */
-
- p_next_hca = (ftree_hca_t *) cl_qmap_head(&p_ftree->hca_tbl);
- while (p_next_hca != (ftree_hca_t *) cl_qmap_end(&p_ftree->hca_tbl)) {
- p_hca = p_next_hca;
- p_next_hca = (ftree_hca_t *) cl_qmap_next(&p_hca->map_item);
- __osm_ftree_hca_destroy(p_hca);
- }
- cl_qmap_remove_all(&p_ftree->hca_tbl);
-
- /* remove all the elements of sw_tbl */
-
- p_next_sw = (ftree_sw_t *) cl_qmap_head(&p_ftree->sw_tbl);
- while (p_next_sw != (ftree_sw_t *) cl_qmap_end(&p_ftree->sw_tbl)) {
- p_sw = p_next_sw;
- p_next_sw = (ftree_sw_t *) cl_qmap_next(&p_sw->map_item);
- __osm_ftree_sw_destroy(p_ftree, p_sw);
- }
- cl_qmap_remove_all(&p_ftree->sw_tbl);
-
- /* remove all the elements of sw_by_tuple_tbl */
-
- p_next_element =
- (ftree_sw_tbl_element_t *) cl_qmap_head(&p_ftree->sw_by_tuple_tbl);
- while (p_next_element !=
- (ftree_sw_tbl_element_t *) cl_qmap_end(&p_ftree->
- sw_by_tuple_tbl)) {
- p_element = p_next_element;
- p_next_element =
- (ftree_sw_tbl_element_t *) cl_qmap_next(&p_element->
- map_item);
- __osm_ftree_sw_tbl_element_destroy(p_element);
- }
- cl_qmap_remove_all(&p_ftree->sw_by_tuple_tbl);
-
- /* remove all the elements of cn_guid_tbl */
- p_next_guid_element =
- (name_map_item_t *) cl_qmap_head(&p_ftree->cn_guid_tbl);
- while (p_next_guid_element !=
- (name_map_item_t *) cl_qmap_end(&p_ftree->cn_guid_tbl)) {
- p_guid_element = p_next_guid_element;
- p_next_guid_element =
- (name_map_item_t *) cl_qmap_next(&p_guid_element->item);
- free(p_guid_element);
- }
- cl_qmap_remove_all(&p_ftree->cn_guid_tbl);
-
- /* remove all the elements of root_guid_list */
- while (!cl_is_qlist_empty(&p_ftree->root_guid_list))
- free(cl_qlist_remove_head(&p_ftree->root_guid_list));
-
- /* free the leaf switches array */
- if ((p_ftree->leaf_switches_num > 0) && (p_ftree->leaf_switches))
- free(p_ftree->leaf_switches);
-
- p_ftree->leaf_switches_num = 0;
- p_ftree->cn_num = 0;
- p_ftree->leaf_switch_rank = 0;
- p_ftree->max_switch_rank = 0;
- p_ftree->max_cn_per_leaf = 0;
- p_ftree->lft_max_lid_ho = 0;
- p_ftree->leaf_switches = NULL;
- p_ftree->fabric_built = FALSE;
-
-} /* __osm_ftree_fabric_destroy() */
-
-/***************************************************/
-
-static void __osm_ftree_fabric_destroy(ftree_fabric_t * p_ftree)
-{
- if (!p_ftree)
- return;
- __osm_ftree_fabric_clear(p_ftree);
- free(p_ftree);
-}
-
-/***************************************************/
-
-static uint8_t __osm_ftree_fabric_get_rank(ftree_fabric_t * p_ftree)
-{
- return p_ftree->leaf_switch_rank + 1;
-}
-
-/***************************************************/
-
-static void __osm_ftree_fabric_add_hca(ftree_fabric_t * p_ftree,
- osm_node_t * p_osm_node)
-{
- ftree_hca_t *p_hca = __osm_ftree_hca_create(p_osm_node);
-
- CL_ASSERT(osm_node_get_type(p_osm_node) == IB_NODE_TYPE_CA);
-
- cl_qmap_insert(&p_ftree->hca_tbl, p_osm_node->node_info.node_guid,
- &p_hca->map_item);
-}
-
-/***************************************************/
-
-static void __osm_ftree_fabric_add_sw(ftree_fabric_t * p_ftree,
- osm_switch_t * p_osm_sw)
-{
- ftree_sw_t *p_sw = __osm_ftree_sw_create(p_ftree, p_osm_sw);
-
- CL_ASSERT(osm_node_get_type(p_osm_sw->p_node) == IB_NODE_TYPE_SWITCH);
-
- cl_qmap_insert(&p_ftree->sw_tbl, p_osm_sw->p_node->node_info.node_guid,
- &p_sw->map_item);
-
- /* track the max lid (in host order) that exists in the fabric */
- if (cl_ntoh16(p_sw->base_lid) > p_ftree->lft_max_lid_ho)
- p_ftree->lft_max_lid_ho = cl_ntoh16(p_sw->base_lid);
-}
-
-/***************************************************/
-
-static void __osm_ftree_fabric_add_sw_by_tuple(IN ftree_fabric_t * p_ftree,
- IN ftree_sw_t * p_sw)
-{
- CL_ASSERT(__osm_ftree_tuple_assigned(p_sw->tuple));
-
- cl_qmap_insert(&p_ftree->sw_by_tuple_tbl,
- __osm_ftree_tuple_to_key(p_sw->tuple),
- &__osm_ftree_sw_tbl_element_create(p_sw)->map_item);
-}
-
-/***************************************************/
-
-static ftree_sw_t *__osm_ftree_fabric_get_sw_by_tuple(IN ftree_fabric_t *
- p_ftree,
- IN ftree_tuple_t tuple)
-{
- ftree_sw_tbl_element_t *p_element;
-
- CL_ASSERT(__osm_ftree_tuple_assigned(tuple));
-
- __osm_ftree_tuple_to_key(tuple);
-
- p_element =
- (ftree_sw_tbl_element_t *) cl_qmap_get(&p_ftree->sw_by_tuple_tbl,
- __osm_ftree_tuple_to_key
- (tuple));
- if (p_element ==
- (ftree_sw_tbl_element_t *) cl_qmap_end(&p_ftree->sw_by_tuple_tbl))
- return NULL;
-
- return p_element->p_sw;
-}
-
-/***************************************************/
-
-static ftree_sw_t *__osm_ftree_fabric_get_sw_by_guid(IN ftree_fabric_t *
- p_ftree, IN uint64_t guid)
-{
- ftree_sw_t *p_sw;
- p_sw = (ftree_sw_t *) cl_qmap_get(&p_ftree->sw_tbl, guid);
- if (p_sw == (ftree_sw_t *) cl_qmap_end(&p_ftree->sw_tbl))
- return NULL;
- return p_sw;
-}
-
-/***************************************************/
-
-static ftree_hca_t *__osm_ftree_fabric_get_hca_by_guid(IN ftree_fabric_t *
- p_ftree,
- IN uint64_t guid)
-{
- ftree_hca_t *p_hca;
- p_hca = (ftree_hca_t *) cl_qmap_get(&p_ftree->hca_tbl, guid);
- if (p_hca == (ftree_hca_t *) cl_qmap_end(&p_ftree->hca_tbl))
- return NULL;
- return p_hca;
-}
-
-/***************************************************/
-
-static void __osm_ftree_fabric_dump(ftree_fabric_t * p_ftree)
-{
- uint32_t i;
- ftree_hca_t *p_hca;
- ftree_sw_t *p_sw;
-
- if (!osm_log_is_active(&p_ftree->p_osm->log, OSM_LOG_DEBUG))
- return;
-
- OSM_LOG(&p_ftree->p_osm->log, OSM_LOG_DEBUG, "\n"
- " |-------------------------------|\n"
- " |- Full fabric topology dump -|\n"
- " |-------------------------------|\n\n");
-
- OSM_LOG(&p_ftree->p_osm->log, OSM_LOG_DEBUG, "-- CAs:\n");
-
- for (p_hca = (ftree_hca_t *) cl_qmap_head(&p_ftree->hca_tbl);
- p_hca != (ftree_hca_t *) cl_qmap_end(&p_ftree->hca_tbl);
- p_hca = (ftree_hca_t *) cl_qmap_next(&p_hca->map_item)) {
- __osm_ftree_hca_dump(p_ftree, p_hca);
- }
-
- for (i = 0; i < p_ftree->max_switch_rank; i++) {
- OSM_LOG(&p_ftree->p_osm->log, OSM_LOG_DEBUG,
- "-- Rank %u switches\n", i);
- for (p_sw = (ftree_sw_t *) cl_qmap_head(&p_ftree->sw_tbl);
- p_sw != (ftree_sw_t *) cl_qmap_end(&p_ftree->sw_tbl);
- p_sw = (ftree_sw_t *) cl_qmap_next(&p_sw->map_item)) {
- if (p_sw->rank == i)
- __osm_ftree_sw_dump(p_ftree, p_sw);
- }
- }
-
- OSM_LOG(&p_ftree->p_osm->log, OSM_LOG_DEBUG, "\n"
- " |---------------------------------------|\n"
- " |- Full fabric topology dump completed -|\n"
- " |---------------------------------------|\n\n");
-} /* __osm_ftree_fabric_dump() */
-
-/***************************************************/
-
-static void __osm_ftree_fabric_dump_general_info(IN ftree_fabric_t * p_ftree)
-{
- uint32_t i, j;
- ftree_sw_t *p_sw;
-
- OSM_LOG(&p_ftree->p_osm->log, OSM_LOG_INFO,
- "General fabric topology info\n");
- OSM_LOG(&p_ftree->p_osm->log, OSM_LOG_INFO,
- "============================\n");
-
- OSM_LOG(&p_ftree->p_osm->log, OSM_LOG_INFO,
- " - FatTree rank (roots to leaf switches): %u\n",
- p_ftree->leaf_switch_rank + 1);
- OSM_LOG(&p_ftree->p_osm->log, OSM_LOG_INFO,
- " - FatTree max switch rank: %u\n", p_ftree->max_switch_rank);
- OSM_LOG(&p_ftree->p_osm->log, OSM_LOG_INFO,
- " - Fabric has %u CAs (%u of them CNs), %u switches\n",
- cl_qmap_count(&p_ftree->hca_tbl), p_ftree->cn_num,
- cl_qmap_count(&p_ftree->sw_tbl));
-
- CL_ASSERT(cl_qmap_count(&p_ftree->hca_tbl) >= p_ftree->cn_num);
-
- for (i = 0; i <= p_ftree->max_switch_rank; i++) {
- j = 0;
- for (p_sw = (ftree_sw_t *) cl_qmap_head(&p_ftree->sw_tbl);
- p_sw != (ftree_sw_t *) cl_qmap_end(&p_ftree->sw_tbl);
- p_sw = (ftree_sw_t *) cl_qmap_next(&p_sw->map_item)) {
- if (p_sw->rank == i)
- j++;
- }
- if (i == 0)
- OSM_LOG(&p_ftree->p_osm->log, OSM_LOG_INFO,
- " - Fabric has %u switches at rank %u (roots)\n",
- j, i);
- else if (i == p_ftree->leaf_switch_rank)
- OSM_LOG(&p_ftree->p_osm->log, OSM_LOG_INFO,
- " - Fabric has %u switches at rank %u (%u of them leafs)\n",
- j, i, p_ftree->leaf_switches_num);
- else
- OSM_LOG(&p_ftree->p_osm->log, OSM_LOG_INFO,
- " - Fabric has %u switches at rank %u\n", j,
- i);
- }
-
- if (osm_log_is_active(&p_ftree->p_osm->log, OSM_LOG_VERBOSE)) {
- OSM_LOG(&p_ftree->p_osm->log, OSM_LOG_VERBOSE,
- " - Root switches:\n");
- for (p_sw = (ftree_sw_t *) cl_qmap_head(&p_ftree->sw_tbl);
- p_sw != (ftree_sw_t *) cl_qmap_end(&p_ftree->sw_tbl);
- p_sw = (ftree_sw_t *) cl_qmap_next(&p_sw->map_item)) {
- if (p_sw->rank == 0)
- OSM_LOG(&p_ftree->p_osm->log, OSM_LOG_VERBOSE,
- " GUID: 0x%016" PRIx64
- ", LID: %u, Index %s\n",
- __osm_ftree_sw_get_guid_ho(p_sw),
- cl_ntoh16(p_sw->base_lid),
- __osm_ftree_tuple_to_str(p_sw->tuple));
- }
-
- OSM_LOG(&p_ftree->p_osm->log, OSM_LOG_VERBOSE,
- " - Leaf switches (sorted by index):\n");
- for (i = 0; i < p_ftree->leaf_switches_num; i++) {
- OSM_LOG(&p_ftree->p_osm->log, OSM_LOG_VERBOSE,
- " GUID: 0x%016" PRIx64
- ", LID: %u, Index %s\n",
- __osm_ftree_sw_get_guid_ho(p_ftree->
- leaf_switches[i]),
- cl_ntoh16(p_ftree->leaf_switches[i]->base_lid),
- __osm_ftree_tuple_to_str(p_ftree->
- leaf_switches[i]->
- tuple));
- }
- }
-} /* __osm_ftree_fabric_dump_general_info() */
-
-/***************************************************/
-
-static void __osm_ftree_fabric_dump_hca_ordering(IN ftree_fabric_t * p_ftree)
-{
- ftree_hca_t *p_hca;
- ftree_sw_t *p_sw;
- ftree_port_group_t *p_group_on_sw;
- ftree_port_group_t *p_group_on_hca;
- uint32_t i;
- uint32_t j;
- unsigned printed_hcas_on_leaf;
-
- char path[1024];
- FILE *p_hca_ordering_file;
- char *filename = "opensm-ftree-ca-order.dump";
-
- snprintf(path, sizeof(path), "%s/%s",
- p_ftree->p_osm->subn.opt.dump_files_dir, filename);
- p_hca_ordering_file = fopen(path, "w");
- if (!p_hca_ordering_file) {
- OSM_LOG(&p_ftree->p_osm->log, OSM_LOG_ERROR, "ERR AB01: "
- "cannot open file \'%s\': %s\n", filename,
- strerror(errno));
- return;
- }
-
- /* for each leaf switch (in indexing order) */
- for (i = 0; i < p_ftree->leaf_switches_num; i++) {
- p_sw = p_ftree->leaf_switches[i];
- printed_hcas_on_leaf = 0;
-
- /* for each real CA (CNs and not) connected to this switch */
- for (j = 0; j < p_sw->down_port_groups_num; j++) {
- p_group_on_sw = p_sw->down_port_groups[j];
-
- if (p_group_on_sw->remote_node_type != IB_NODE_TYPE_CA)
- continue;
-
- p_hca = p_group_on_sw->remote_hca_or_sw.p_hca;
- p_group_on_hca =
- __osm_ftree_hca_get_port_group_by_remote_lid(p_hca,
- p_group_on_sw->
- base_lid);
-
- /* treat non-compute nodes as dummies */
- if (!p_group_on_hca->is_cn)
- continue;
-
- fprintf(p_hca_ordering_file, "0x%04x\t%s\n",
- cl_ntoh16(p_group_on_hca->base_lid),
- p_hca->p_osm_node->print_desc);
-
- printed_hcas_on_leaf++;
- }
-
- /* now print missing HCAs */
- for (j = 0;
- j < (p_ftree->max_cn_per_leaf - printed_hcas_on_leaf); j++)
- fprintf(p_hca_ordering_file, "0xFFFF\tDUMMY\n");
-
- }
- /* done going through all the leaf switches */
-
- fclose(p_hca_ordering_file);
-} /* __osm_ftree_fabric_dump_hca_ordering() */
-
-/***************************************************/
-
-static void
-__osm_ftree_fabric_assign_tuple(IN ftree_fabric_t * p_ftree,
- IN ftree_sw_t * p_sw,
- IN ftree_tuple_t new_tuple)
-{
- memcpy(p_sw->tuple, new_tuple, FTREE_TUPLE_LEN);
- __osm_ftree_fabric_add_sw_by_tuple(p_ftree, p_sw);
-}
-
-/***************************************************/
-
-static void __osm_ftree_fabric_assign_first_tuple(IN ftree_fabric_t * p_ftree,
- IN ftree_sw_t * p_sw)
-{
- uint8_t i;
- ftree_tuple_t new_tuple;
-
- __osm_ftree_tuple_init(new_tuple);
- new_tuple[0] = (uint8_t) p_sw->rank;
- for (i = 1; i <= p_sw->rank; i++)
- new_tuple[i] = 0;
-
- __osm_ftree_fabric_assign_tuple(p_ftree, p_sw, new_tuple);
-}
-
-/***************************************************/
-
-static void
-__osm_ftree_fabric_get_new_tuple(IN ftree_fabric_t * p_ftree,
- OUT ftree_tuple_t new_tuple,
- IN ftree_tuple_t from_tuple,
- IN ftree_direction_t direction)
-{
- ftree_sw_t *p_sw;
- ftree_tuple_t temp_tuple;
- uint8_t var_index;
- uint8_t i;
-
- __osm_ftree_tuple_init(new_tuple);
- memcpy(temp_tuple, from_tuple, FTREE_TUPLE_LEN);
-
- if (direction == FTREE_DIRECTION_DOWN) {
- temp_tuple[0]++;
- var_index = from_tuple[0] + 1;
- } else {
- temp_tuple[0]--;
- var_index = from_tuple[0];
- }
-
- for (i = 0; i < 0xFF; i++) {
- temp_tuple[var_index] = i;
- p_sw = __osm_ftree_fabric_get_sw_by_tuple(p_ftree, temp_tuple);
- if (p_sw == NULL) /* found free tuple */
- break;
- }
-
- if (i == 0xFF) {
- /* new tuple not found - there are more than 255 ports in one direction */
- return;
- }
- memcpy(new_tuple, temp_tuple, FTREE_TUPLE_LEN);
-
-} /* __osm_ftree_fabric_get_new_tuple() */
-
-/***************************************************/
-
-static inline boolean_t __osm_ftree_fabric_roots_provided(IN ftree_fabric_t *
- p_ftree)
-{
- return (p_ftree->p_osm->subn.opt.root_guid_file != NULL);
-}
-
-/***************************************************/
-
-static inline boolean_t __osm_ftree_fabric_cns_provided(IN ftree_fabric_t *
- p_ftree)
-{
- return (p_ftree->p_osm->subn.opt.cn_guid_file != NULL);
-}
-
-/***************************************************/
-
-static int __osm_ftree_fabric_mark_leaf_switches(IN ftree_fabric_t * p_ftree)
-{
- ftree_sw_t *p_sw;
- ftree_hca_t *p_hca;
- ftree_hca_t *p_next_hca;
- unsigned i;
- int res = 0;
-
- OSM_LOG_ENTER(&p_ftree->p_osm->log);
-
- OSM_LOG(&p_ftree->p_osm->log, OSM_LOG_VERBOSE,
- "Marking leaf switches in fabric\n");
-
- /* Scan all the CAs, if they have CNs - find CN port and mark switch
- that is connected to this port as leaf switch.
- Also, ensure that this marked leaf has rank of p_ftree->leaf_switch_rank. */
- p_next_hca = (ftree_hca_t *) cl_qmap_head(&p_ftree->hca_tbl);
- while (p_next_hca != (ftree_hca_t *) cl_qmap_end(&p_ftree->hca_tbl)) {
- p_hca = p_next_hca;
- p_next_hca = (ftree_hca_t *) cl_qmap_next(&p_hca->map_item);
- if (!p_hca->cn_num)
- continue;
-
- for (i = 0; i < p_hca->up_port_groups_num; i++) {
- if (!p_hca->up_port_groups[i]->is_cn)
- continue;
-
- /* In CAs, port group alway has one port, and since this
- port group is CN, we know that this port is compute node */
- CL_ASSERT(p_hca->up_port_groups[i]->remote_node_type ==
- IB_NODE_TYPE_SWITCH);
- p_sw = p_hca->up_port_groups[i]->remote_hca_or_sw.p_sw;
-
- /* check if this switch was already processed */
- if (p_sw->is_leaf)
- continue;
- p_sw->is_leaf = TRUE;
-
- /* ensure that this leaf switch is at the correct tree level */
- if (p_sw->rank != p_ftree->leaf_switch_rank) {
- OSM_LOG(&p_ftree->p_osm->log, OSM_LOG_ERROR,
- "ERR AB26: CN port 0x%" PRIx64
- " is connected to switch 0x%" PRIx64
- " with rank %u, "
- "while FatTree leaf rank is %u\n",
- cl_ntoh64(p_hca->up_port_groups[i]->
- port_guid),
- __osm_ftree_sw_get_guid_ho(p_sw),
- p_sw->rank, p_ftree->leaf_switch_rank);
- res = -1;
- goto Exit;
-
- }
- }
- }
-
-Exit:
- OSM_LOG_EXIT(&p_ftree->p_osm->log);
- return res;
-} /* __osm_ftree_fabric_mark_leaf_switches() */
-
-/***************************************************/
-
-static void __osm_ftree_fabric_make_indexing(IN ftree_fabric_t * p_ftree)
-{
- ftree_sw_t *p_remote_sw;
- ftree_sw_t *p_sw = NULL;
- ftree_sw_t *p_next_sw;
- ftree_tuple_t new_tuple;
- uint32_t i;
- cl_list_t bfs_list;
- ftree_sw_tbl_element_t *p_sw_tbl_element;
-
- OSM_LOG_ENTER(&p_ftree->p_osm->log);
-
- OSM_LOG(&p_ftree->p_osm->log, OSM_LOG_VERBOSE,
- "Starting FatTree indexing\n");
-
- /* using the first leaf switch as a starting point for indexing algorithm. */
- p_next_sw = (ftree_sw_t *) cl_qmap_head(&p_ftree->sw_tbl);
- while (p_next_sw != (ftree_sw_t *) cl_qmap_end(&p_ftree->sw_tbl)) {
- p_sw = p_next_sw;
- if (p_sw->is_leaf)
- break;
- p_next_sw = (ftree_sw_t *) cl_qmap_next(&p_sw->map_item);
- }
-
- CL_ASSERT(p_next_sw != (ftree_sw_t *) cl_qmap_end(&p_ftree->sw_tbl));
-
- /* Assign the first tuple to the switch that is used as BFS starting point.
- The tuple will be as follows: [rank].0.0.0...
- This fuction also adds the switch it into the switch_by_tuple table. */
- __osm_ftree_fabric_assign_first_tuple(p_ftree, p_sw);
-
- OSM_LOG(&p_ftree->p_osm->log, OSM_LOG_VERBOSE,
- "Indexing starting point:\n"
- " - Switch rank : %u\n"
- " - Switch index : %s\n"
- " - Node LID : %u\n"
- " - Node GUID : 0x%016"
- PRIx64 "\n", p_sw->rank, __osm_ftree_tuple_to_str(p_sw->tuple),
- cl_ntoh16(p_sw->base_lid), __osm_ftree_sw_get_guid_ho(p_sw));
-
- /*
- * Now run BFS and assign indexes to all switches
- * Pseudo code of the algorithm is as follows:
- *
- * * Add first switch to BFS queue
- * * While (BFS queue not empty)
- * - Pop the switch from the head of the queue
- * - Scan all the downward and upward ports
- * - For each port
- * + Get the remote switch
- * + Assign index to the remote switch
- * + Add remote switch to the BFS queue
- */
-
- cl_list_init(&bfs_list, cl_qmap_count(&p_ftree->sw_tbl));
- cl_list_insert_tail(&bfs_list,
- &__osm_ftree_sw_tbl_element_create(p_sw)->map_item);
-
- while (!cl_is_list_empty(&bfs_list)) {
- p_sw_tbl_element =
- (ftree_sw_tbl_element_t *) cl_list_remove_head(&bfs_list);
- p_sw = p_sw_tbl_element->p_sw;
- __osm_ftree_sw_tbl_element_destroy(p_sw_tbl_element);
-
- /* Discover all the nodes from ports that are pointing down */
-
- if (p_sw->rank >= p_ftree->leaf_switch_rank) {
- /* whether downward ports are pointing to CAs or switches,
- we don't assign indexes to switches that are located
- lower than leaf switches */
- } else {
- /* This is not the leaf switch */
- for (i = 0; i < p_sw->down_port_groups_num; i++) {
- /* Work with port groups that are pointing to switches only.
- No need to assign indexing to HCAs */
- if (p_sw->down_port_groups[i]->
- remote_node_type != IB_NODE_TYPE_SWITCH)
- continue;
-
- p_remote_sw =
- p_sw->down_port_groups[i]->remote_hca_or_sw.
- p_sw;
- if (__osm_ftree_tuple_assigned
- (p_remote_sw->tuple)) {
- /* this switch has been already indexed */
- continue;
- }
- /* allocate new tuple */
- __osm_ftree_fabric_get_new_tuple(p_ftree,
- new_tuple,
- p_sw->tuple,
- FTREE_DIRECTION_DOWN);
- /* Assign the new tuple to the remote switch.
- This fuction also adds the switch into the switch_by_tuple table. */
- __osm_ftree_fabric_assign_tuple(p_ftree,
- p_remote_sw,
- new_tuple);
-
- /* add the newly discovered switch to the BFS queue */
- cl_list_insert_tail(&bfs_list,
- &__osm_ftree_sw_tbl_element_create
- (p_remote_sw)->map_item);
- }
- /* Done assigning indexes to all the remote switches
- that are pointed by the downgoing ports.
- Now sort port groups according to remote index. */
- qsort(p_sw->down_port_groups, /* array */
- p_sw->down_port_groups_num, /* number of elements */
- sizeof(ftree_port_group_t *), /* size of each element */
- __osm_ftree_compare_port_groups_by_remote_switch_index); /* comparator */
- }
-
- /* Done indexing switches from ports that go down.
- Now do the same with ports that are pointing up. */
-
- if (p_sw->rank != 0) {
- /* This is not the root switch, which means that all the ports
- that are pointing up are taking us to another switches. */
- for (i = 0; i < p_sw->up_port_groups_num; i++) {
- p_remote_sw =
- p_sw->up_port_groups[i]->remote_hca_or_sw.
- p_sw;
- if (__osm_ftree_tuple_assigned
- (p_remote_sw->tuple))
- continue;
- /* allocate new tuple */
- __osm_ftree_fabric_get_new_tuple(p_ftree,
- new_tuple,
- p_sw->tuple,
- FTREE_DIRECTION_UP);
- /* Assign the new tuple to the remote switch.
- This fuction also adds the switch to the
- switch_by_tuple table. */
- __osm_ftree_fabric_assign_tuple(p_ftree,
- p_remote_sw,
- new_tuple);
- /* add the newly discovered switch to the BFS queue */
- cl_list_insert_tail(&bfs_list,
- &__osm_ftree_sw_tbl_element_create
- (p_remote_sw)->map_item);
- }
- /* Done assigning indexes to all the remote switches
- that are pointed by the upgoing ports.
- Now sort port groups according to remote index. */
- qsort(p_sw->up_port_groups, /* array */
- p_sw->up_port_groups_num, /* number of elements */
- sizeof(ftree_port_group_t *), /* size of each element */
- __osm_ftree_compare_port_groups_by_remote_switch_index); /* comparator */
- }
- /* Done assigning indexes to all the switches that are directly connected
- to the current switch - go to the next switch in the BFS queue */
- }
- cl_list_destroy(&bfs_list);
-
- OSM_LOG_EXIT(&p_ftree->p_osm->log);
-} /* __osm_ftree_fabric_make_indexing() */
-
-/***************************************************/
-
-static int __osm_ftree_fabric_create_leaf_switch_array(IN ftree_fabric_t *
- p_ftree)
-{
- ftree_sw_t *p_sw;
- ftree_sw_t *p_next_sw;
- ftree_sw_t **all_switches_at_leaf_level;
- unsigned i;
- unsigned all_leaf_idx = 0;
- unsigned first_leaf_idx;
- unsigned last_leaf_idx;
- int res = 0;
-
- OSM_LOG_ENTER(&p_ftree->p_osm->log);
-
- /* create array of ALL the switches that have leaf rank */
- all_switches_at_leaf_level = (ftree_sw_t **)
- malloc(cl_qmap_count(&p_ftree->sw_tbl) * sizeof(ftree_sw_t *));
- if (!all_switches_at_leaf_level) {
- osm_log(&p_ftree->p_osm->log, OSM_LOG_SYS,
- "Fat-tree routing: Memory allocation failed\n");
- res = -1;
- goto Exit;
- }
- memset(all_switches_at_leaf_level, 0,
- cl_qmap_count(&p_ftree->sw_tbl) * sizeof(ftree_sw_t *));
-
- p_next_sw = (ftree_sw_t *) cl_qmap_head(&p_ftree->sw_tbl);
- while (p_next_sw != (ftree_sw_t *) cl_qmap_end(&p_ftree->sw_tbl)) {
- p_sw = p_next_sw;
- p_next_sw = (ftree_sw_t *) cl_qmap_next(&p_sw->map_item);
- if (p_sw->rank == p_ftree->leaf_switch_rank) {
- OSM_LOG(&p_ftree->p_osm->log, OSM_LOG_DEBUG,
- "Adding switch 0x%" PRIx64
- " to full leaf switch array\n",
- __osm_ftree_sw_get_guid_ho(p_sw));
- all_switches_at_leaf_level[all_leaf_idx++] = p_sw;
-
- }
- }
-
- /* quick-sort array of leaf switches by index */
- qsort(all_switches_at_leaf_level, /* array */
- all_leaf_idx, /* number of elements */
- sizeof(ftree_sw_t *), /* size of each element */
- __osm_ftree_compare_switches_by_index); /* comparator */
-
- /* check the first and the last REAL leaf (the one
- that has CNs) in the array of all the leafs */
-
- first_leaf_idx = all_leaf_idx;
- last_leaf_idx = 0;
- for (i = 0; i < all_leaf_idx; i++) {
- if (all_switches_at_leaf_level[i]->is_leaf) {
- if (i < first_leaf_idx)
- first_leaf_idx = i;
- last_leaf_idx = i;
- }
- }
- CL_ASSERT(first_leaf_idx < last_leaf_idx);
-
- OSM_LOG(&p_ftree->p_osm->log, OSM_LOG_DEBUG,
- "Full leaf array info: first_leaf_idx = %u, last_leaf_idx = %u\n",
- first_leaf_idx, last_leaf_idx);
-
- /* Create array of REAL leaf switches, sorted by index.
- This array may contain switches at the same rank w/o CNs,
- in case this is the order of indexing. */
- p_ftree->leaf_switches_num = last_leaf_idx - first_leaf_idx + 1;
- p_ftree->leaf_switches = (ftree_sw_t **)
- malloc(p_ftree->leaf_switches_num * sizeof(ftree_sw_t *));
- if (!p_ftree->leaf_switches) {
- osm_log(&p_ftree->p_osm->log, OSM_LOG_SYS,
- "Fat-tree routing: Memory allocation failed\n");
- res = -1;
- goto Exit;
- }
-
- memcpy(p_ftree->leaf_switches,
- &(all_switches_at_leaf_level[first_leaf_idx]),
- p_ftree->leaf_switches_num * sizeof(ftree_sw_t *));
-
- free(all_switches_at_leaf_level);
-
- OSM_LOG(&p_ftree->p_osm->log, OSM_LOG_DEBUG,
- "Created array of %u leaf switches\n",
- p_ftree->leaf_switches_num);
-
-Exit:
- OSM_LOG_EXIT(&p_ftree->p_osm->log);
- return res;
-} /* __osm_ftree_fabric_create_leaf_switch_array() */
-
-/***************************************************/
-
-static void __osm_ftree_fabric_set_max_cn_per_leaf(IN ftree_fabric_t * p_ftree)
-{
- unsigned i;
- unsigned j;
- unsigned cns_on_this_leaf;
- ftree_sw_t *p_sw;
- ftree_port_group_t *p_group;
-
- for (i = 0; i < p_ftree->leaf_switches_num; i++) {
- p_sw = p_ftree->leaf_switches[i];
- cns_on_this_leaf = 0;
- for (j = 0; j < p_sw->down_port_groups_num; j++) {
- p_group = p_sw->down_port_groups[j];
- if (p_group->remote_node_type != IB_NODE_TYPE_CA)
- continue;
- cns_on_this_leaf +=
- p_group->remote_hca_or_sw.p_hca->cn_num;
- }
- if (cns_on_this_leaf > p_ftree->max_cn_per_leaf)
- p_ftree->max_cn_per_leaf = cns_on_this_leaf;
- }
-} /* __osm_ftree_fabric_set_max_cn_per_leaf() */
-
-/***************************************************/
-
-static boolean_t __osm_ftree_fabric_validate_topology(IN ftree_fabric_t *
- p_ftree)
-{
- ftree_port_group_t *p_group;
- ftree_port_group_t *p_ref_group;
- ftree_sw_t *p_sw;
- ftree_sw_t *p_next_sw;
- ftree_sw_t **reference_sw_arr;
- uint16_t tree_rank = __osm_ftree_fabric_get_rank(p_ftree);
- boolean_t res = TRUE;
- uint8_t i;
-
- OSM_LOG_ENTER(&p_ftree->p_osm->log);
-
- OSM_LOG(&p_ftree->p_osm->log, OSM_LOG_VERBOSE,
- "Validating fabric topology\n");
-
- reference_sw_arr =
- (ftree_sw_t **) malloc(tree_rank * sizeof(ftree_sw_t *));
- if (reference_sw_arr == NULL) {
- osm_log(&p_ftree->p_osm->log, OSM_LOG_SYS,
- "Fat-tree routing: Memory allocation failed\n");
- return FALSE;
- }
- memset(reference_sw_arr, 0, tree_rank * sizeof(ftree_sw_t *));
-
- p_next_sw = (ftree_sw_t *) cl_qmap_head(&p_ftree->sw_tbl);
- while (res && p_next_sw != (ftree_sw_t *) cl_qmap_end(&p_ftree->sw_tbl)) {
- p_sw = p_next_sw;
- p_next_sw = (ftree_sw_t *) cl_qmap_next(&p_sw->map_item);
-
- if (!reference_sw_arr[p_sw->rank]) {
- /* This is the first switch in the current level that
- we're checking - use it as a reference */
- reference_sw_arr[p_sw->rank] = p_sw;
- } else {
- /* compare this switch properties to the reference switch */
-
- if (reference_sw_arr[p_sw->rank]->up_port_groups_num !=
- p_sw->up_port_groups_num) {
- OSM_LOG(&p_ftree->p_osm->log, OSM_LOG_ERROR,
- "ERR AB09: Different number of upward port groups on switches:\n"
- " GUID 0x%016" PRIx64
- ", LID %u, Index %s - %u groups\n"
- " GUID 0x%016" PRIx64
- ", LID %u, Index %s - %u groups\n",
- __osm_ftree_sw_get_guid_ho
- (reference_sw_arr[p_sw->rank]),
- cl_ntoh16(reference_sw_arr[p_sw->rank]->
- base_lid),
- __osm_ftree_tuple_to_str
- (reference_sw_arr[p_sw->rank]->tuple),
- reference_sw_arr[p_sw->rank]->
- up_port_groups_num,
- __osm_ftree_sw_get_guid_ho(p_sw),
- cl_ntoh16(p_sw->base_lid),
- __osm_ftree_tuple_to_str(p_sw->tuple),
- p_sw->up_port_groups_num);
- res = FALSE;
- break;
- }
-
- if (p_sw->rank != (tree_rank - 1) &&
- reference_sw_arr[p_sw->rank]->
- down_port_groups_num !=
- p_sw->down_port_groups_num) {
- /* we're allowing some hca's to be missing */
- OSM_LOG(&p_ftree->p_osm->log, OSM_LOG_ERROR,
- "ERR AB0A: Different number of downward port groups on switches:\n"
- " GUID 0x%016" PRIx64
- ", LID %u, Index %s - %u port groups\n"
- " GUID 0x%016" PRIx64
- ", LID %u, Index %s - %u port groups\n",
- __osm_ftree_sw_get_guid_ho
- (reference_sw_arr[p_sw->rank]),
- cl_ntoh16(reference_sw_arr[p_sw->rank]->
- base_lid),
- __osm_ftree_tuple_to_str
- (reference_sw_arr[p_sw->rank]->tuple),
- reference_sw_arr[p_sw->rank]->
- down_port_groups_num,
- __osm_ftree_sw_get_guid_ho(p_sw),
- cl_ntoh16(p_sw->base_lid),
- __osm_ftree_tuple_to_str(p_sw->tuple),
- p_sw->down_port_groups_num);
- res = FALSE;
- break;
- }
-
- if (reference_sw_arr[p_sw->rank]->up_port_groups_num !=
- 0) {
- p_ref_group =
- reference_sw_arr[p_sw->rank]->
- up_port_groups[0];
- for (i = 0; i < p_sw->up_port_groups_num; i++) {
- p_group = p_sw->up_port_groups[i];
- if (cl_ptr_vector_get_size
- (&p_ref_group->ports) !=
- cl_ptr_vector_get_size(&p_group->
- ports)) {
- OSM_LOG(&p_ftree->p_osm->log,
- OSM_LOG_ERROR,
- "ERR AB0B: Different number of ports in an upward port group on switches:\n"
- " GUID 0x%016"
- PRIx64
- ", LID %u, Index %s - %u ports\n"
- " GUID 0x%016"
- PRIx64
- ", LID %u, Index %s - %u ports\n",
- __osm_ftree_sw_get_guid_ho
- (reference_sw_arr
- [p_sw->rank]),
- cl_ntoh16
- (reference_sw_arr
- [p_sw->rank]->
- base_lid),
- __osm_ftree_tuple_to_str
- (reference_sw_arr
- [p_sw->rank]->tuple),
- cl_ptr_vector_get_size
- (&p_ref_group->ports),
- __osm_ftree_sw_get_guid_ho
- (p_sw),
- cl_ntoh16(p_sw->
- base_lid),
- __osm_ftree_tuple_to_str
- (p_sw->tuple),
- cl_ptr_vector_get_size
- (&p_group->ports));
- res = FALSE;
- break;
- }
- }
- }
- if (reference_sw_arr[p_sw->rank]->
- down_port_groups_num != 0
- && p_sw->rank != (tree_rank - 1)) {
- /* we're allowing some hca's to be missing */
- p_ref_group =
- reference_sw_arr[p_sw->rank]->
- down_port_groups[0];
- for (i = 0; i < p_sw->down_port_groups_num; i++) {
- p_group = p_sw->down_port_groups[0];
- if (cl_ptr_vector_get_size
- (&p_ref_group->ports) !=
- cl_ptr_vector_get_size(&p_group->
- ports)) {
- OSM_LOG(&p_ftree->p_osm->log,
- OSM_LOG_ERROR,
- "ERR AB0C: Different number of ports in an downward port group on switches:\n"
- " GUID 0x%016"
- PRIx64
- ", LID %u, Index %s - %u ports\n"
- " GUID 0x%016"
- PRIx64
- ", LID %u, Index %s - %u ports\n",
- __osm_ftree_sw_get_guid_ho
- (reference_sw_arr
- [p_sw->rank]),
- cl_ntoh16
- (reference_sw_arr
- [p_sw->rank]->
- base_lid),
- __osm_ftree_tuple_to_str
- (reference_sw_arr
- [p_sw->rank]->tuple),
- cl_ptr_vector_get_size
- (&p_ref_group->ports),
- __osm_ftree_sw_get_guid_ho
- (p_sw),
- cl_ntoh16(p_sw->
- base_lid),
- __osm_ftree_tuple_to_str
- (p_sw->tuple),
- cl_ptr_vector_get_size
- (&p_group->ports));
- res = FALSE;
- break;
- }
- }
- }
- } /* end of else */
- } /* end of while */
-
- if (res == TRUE)
- OSM_LOG(&p_ftree->p_osm->log, OSM_LOG_VERBOSE,
- "Fabric topology has been identified as FatTree\n");
- else
- OSM_LOG(&p_ftree->p_osm->log, OSM_LOG_ERROR,
- "ERR AB0D: Fabric topology hasn't been identified as FatTree\n");
-
- free(reference_sw_arr);
- OSM_LOG_EXIT(&p_ftree->p_osm->log);
- return res;
-} /* __osm_ftree_fabric_validate_topology() */
-
-/***************************************************
- ***************************************************/
-
-static void __osm_ftree_set_sw_fwd_table(IN cl_map_item_t * const p_map_item,
- IN void *context)
-{
- ftree_sw_t *p_sw = (ftree_sw_t * const)p_map_item;
- ftree_fabric_t *p_ftree = (ftree_fabric_t *) context;
-
- p_sw->p_osm_sw->max_lid_ho = p_ftree->lft_max_lid_ho;
- osm_ucast_mgr_set_fwd_table(&p_ftree->p_osm->sm.ucast_mgr,
- p_sw->p_osm_sw);
-}
-
-/***************************************************
- ***************************************************/
-
-/*
- * Function: assign-up-going-port-by-descending-down
- * Given : a switch and a LID
- * Pseudo code:
- * foreach down-going-port-group (in indexing order)
- * skip this group if the LFT(LID) port is part of this group
- * find the least loaded port of the group (scan in indexing order)
- * r-port is the remote port connected to it
- * assign the remote switch node LFT(LID) to r-port
- * increase r-port usage counter
- * assign-up-going-port-by-descending-down to r-port node (recursion)
- */
-
-static void
-__osm_ftree_fabric_route_upgoing_by_going_down(IN ftree_fabric_t * p_ftree,
- IN ftree_sw_t * p_sw,
- IN ftree_sw_t * p_prev_sw,
- IN ib_net16_t target_lid,
- IN uint8_t target_rank,
- IN boolean_t is_real_lid,
- IN boolean_t is_main_path,
- IN uint8_t highest_rank_in_route)
-{
- ftree_sw_t *p_remote_sw;
- uint16_t ports_num;
- ftree_port_group_t *p_group;
- ftree_port_t *p_port;
- ftree_port_t *p_min_port;
- uint16_t i;
- uint16_t j;
- uint16_t k;
-
- /* we shouldn't enter here if both real_lid and main_path are false */
- CL_ASSERT(is_real_lid || is_main_path);
-
- /* if there is no down-going ports */
- if (p_sw->down_port_groups_num == 0)
- return;
-
- /* promote the index that indicates which group should we
- start with when going through all the downgoing groups */
- p_sw->down_port_groups_idx =
- (p_sw->down_port_groups_idx + 1) % p_sw->down_port_groups_num;
-
- /* foreach down-going port group (in indexing order) */
- i = p_sw->down_port_groups_idx;
- for (k = 0; k < p_sw->down_port_groups_num; k++) {
-
- p_group = p_sw->down_port_groups[i];
- i = (i + 1) % p_sw->down_port_groups_num;
-
- /* Skip this port group unless it points to a switch */
- if (p_group->remote_node_type != IB_NODE_TYPE_SWITCH)
- continue;
-
- if (p_prev_sw
- && (p_group->remote_base_lid == p_prev_sw->base_lid)) {
- /* This port group has a port that was used when we entered this switch,
- which means that the current group points to the switch where we were
- at the previous step of the algorithm (before going up).
- Skipping this group. */
- continue;
- }
-
- /* find the least loaded port of the group (in indexing order) */
- p_min_port = NULL;
- ports_num = (uint16_t) cl_ptr_vector_get_size(&p_group->ports);
- /* ToDo: no need to select a least loaded port for non-main path.
- Think about optimization. */
- for (j = 0; j < ports_num; j++) {
- cl_ptr_vector_at(&p_group->ports, j, (void *)&p_port);
- if (!p_min_port) {
- /* first port that we're checking - set as port with the lowest load */
- p_min_port = p_port;
- } else if (p_port->counter_up < p_min_port->counter_up) {
- /* this port is less loaded - use it as min */
- p_min_port = p_port;
- }
- }
- /* At this point we have selected a port in this group with the
- lowest load of upgoing routes.
- Set on the remote switch how to get to the target_lid -
- set LFT(target_lid) on the remote switch to the remote port */
- p_remote_sw = p_group->remote_hca_or_sw.p_sw;
-
- if (osm_switch_get_least_hops(p_remote_sw->p_osm_sw,
- cl_ntoh16(target_lid)) !=
- OSM_NO_PATH) {
- /* Loop in the fabric - we already routed the remote switch
- on our way UP, and now we see it again on our way DOWN */
- OSM_LOG(&p_ftree->p_osm->log, OSM_LOG_DEBUG,
- "Loop of lenght %d in the fabric:\n "
- "Switch %s (LID %u) closes loop through switch %s (LID %u)\n",
- (p_remote_sw->rank - highest_rank_in_route) * 2,
- __osm_ftree_tuple_to_str(p_remote_sw->tuple),
- cl_ntoh16(p_group->base_lid),
- __osm_ftree_tuple_to_str(p_sw->tuple),
- cl_ntoh16(p_group->remote_base_lid));
- continue;
- }
-
- /* Four possible cases:
- *
- * 1. is_real_lid == TRUE && is_main_path == TRUE:
- * - going DOWN(TRUE,TRUE) through ALL the groups
- * + promoting port counter
- * + setting path in remote switch fwd tbl
- * + setting hops in remote switch on all the ports of each group
- *
- * 2. is_real_lid == TRUE && is_main_path == FALSE:
- * - going DOWN(TRUE,FALSE) through ALL the groups but only if
- * the remote (lower) switch hasn't been already configured
- * for this target LID
- * + NOT promoting port counter
- * + setting path in remote switch fwd tbl if it hasn't been set yet
- * + setting hops in remote switch on all the ports of each group
- * if it hasn't been set yet
- *
- * 3. is_real_lid == FALSE && is_main_path == TRUE:
- * - going DOWN(FALSE,TRUE) through ALL the groups
- * + promoting port counter
- * + NOT setting path in remote switch fwd tbl
- * + NOT setting hops in remote switch
- *
- * 4. is_real_lid == FALSE && is_main_path == FALSE:
- * - illegal state - we shouldn't get here
- */
-
- /* second case: skip the port group if the remote (lower)
- switch has been already configured for this target LID */
- if (is_real_lid && !is_main_path &&
- p_remote_sw->p_osm_sw->new_lft[cl_ntoh16(target_lid)] != OSM_NO_PATH)
- continue;
-
- /* setting fwd tbl port only if this is real LID */
- if (is_real_lid) {
- p_remote_sw->p_osm_sw->new_lft[cl_ntoh16(target_lid)] =
- p_min_port->remote_port_num;
- OSM_LOG(&p_ftree->p_osm->log, OSM_LOG_DEBUG,
- "Switch %s: set path to CA LID %u through port %u\n",
- __osm_ftree_tuple_to_str(p_remote_sw->tuple),
- cl_ntoh16(target_lid),
- p_min_port->remote_port_num);
-
- /* On the remote switch that is pointed by the p_group,
- set hops for ALL the ports in the remote group. */
-
- for (j = 0; j < ports_num; j++) {
- cl_ptr_vector_at(&p_group->ports, j,
- (void *)&p_port);
-
- __osm_ftree_sw_set_hops(p_remote_sw,
- cl_ntoh16(target_lid),
- p_port->remote_port_num,
- ((target_rank -
- highest_rank_in_route)
- + (p_remote_sw->rank -
- highest_rank_in_route)));
- }
-
- }
-
- /* The number of upgoing routes is tracked in the
- p_port->counter_up counter of the port that belongs to
- the upper side of the link (on switch with lower rank).
- Counter is promoted only if we're routing LID on the main
- path (whether it's a real LID or a dummy one). */
- if (is_main_path)
- p_min_port->counter_up++;
-
- /* Recursion step:
- Assign upgoing ports by stepping down, starting on REMOTE switch */
- __osm_ftree_fabric_route_upgoing_by_going_down(p_ftree, p_remote_sw, /* remote switch - used as a route-upgoing alg. start point */
- NULL, /* prev. position - NULL to mark that we went down and not up */
- target_lid, /* LID that we're routing to */
- target_rank, /* rank of the LID that we're routing to */
- is_real_lid, /* whether the target LID is real or dummy */
- is_main_path, /* whether this is path to HCA that should by tracked by counters */
- highest_rank_in_route); /* highest visited point in the tree before going down */
- }
- /* done scanning all the down-going port groups */
-
-} /* __osm_ftree_fabric_route_upgoing_by_going_down() */
-
-/***************************************************/
-
-/*
- * Function: assign-down-going-port-by-ascending-up
- * Given : a switch and a LID
- * Pseudo code:
- * find the least loaded port of all the upgoing groups (scan in indexing order)
- * assign the LFT(LID) of remote switch to that port
- * track that port usage
- * assign-up-going-port-by-descending-down on CURRENT switch
- * assign-down-going-port-by-ascending-up on REMOTE switch (recursion)
- */
-
-static void
-__osm_ftree_fabric_route_downgoing_by_going_up(IN ftree_fabric_t * p_ftree,
- IN ftree_sw_t * p_sw,
- IN ftree_sw_t * p_prev_sw,
- IN ib_net16_t target_lid,
- IN uint8_t target_rank,
- IN boolean_t is_real_lid,
- IN boolean_t is_main_path)
-{
- ftree_sw_t *p_remote_sw;
- uint16_t ports_num;
- ftree_port_group_t *p_group;
- ftree_port_t *p_port;
- ftree_port_group_t *p_min_group;
- ftree_port_t *p_min_port;
- uint16_t i;
- uint16_t j;
-
- /* we shouldn't enter here if both real_lid and main_path are false */
- CL_ASSERT(is_real_lid || is_main_path);
-
- /* Assign upgoing ports by stepping down, starting on THIS switch */
- __osm_ftree_fabric_route_upgoing_by_going_down(p_ftree, p_sw, /* local switch - used as a route-upgoing alg. start point */
- p_prev_sw, /* switch that we went up from (NULL means that we went down) */
- target_lid, /* LID that we're routing to */
- target_rank, /* rank of the LID that we're routing to */
- is_real_lid, /* whether this target LID is real or dummy */
- is_main_path, /* whether this path to HCA should by tracked by counters */
- p_sw->rank); /* the highest visited point in the tree before going down */
-
- /* recursion stop condition - if it's a root switch, */
- if (p_sw->rank == 0)
- return;
-
- /* Find the least loaded upgoing port group */
- p_min_group = NULL;
- for (i = 0; i < p_sw->up_port_groups_num; i++) {
- p_group = p_sw->up_port_groups[i];
- if (!p_min_group) {
- /* first group that we're checking - use
- it as a group with the lowest load */
- p_min_group = p_group;
- } else if (p_group->counter_down < p_min_group->counter_down) {
- /* this group is less loaded - use it as min */
- p_min_group = p_group;
- }
- }
-
- /* Find the least loaded upgoing port in the selected group */
- p_min_port = NULL;
- ports_num = (uint16_t) cl_ptr_vector_get_size(&p_min_group->ports);
- for (j = 0; j < ports_num; j++) {
- cl_ptr_vector_at(&p_min_group->ports, j, (void *)&p_port);
- if (!p_min_port) {
- /* first port that we're checking - use
- it as a port with the lowest load */
- p_min_port = p_port;
- } else if (p_port->counter_down < p_min_port->counter_down) {
- /* this port is less loaded - use it as min */
- p_min_port = p_port;
- }
- }
-
- /* At this point we have selected a group and port with the
- lowest load of downgoing routes.
- Set on the remote switch how to get to the target_lid -
- set LFT(target_lid) on the remote switch to the remote port */
- p_remote_sw = p_min_group->remote_hca_or_sw.p_sw;
-
- /* Four possible cases:
- *
- * 1. is_real_lid == TRUE && is_main_path == TRUE:
- * - going UP(TRUE,TRUE) on selected min_group and min_port
- * + promoting port counter
- * + setting path in remote switch fwd tbl
- * + setting hops in remote switch on all the ports of selected group
- * - going UP(TRUE,FALSE) on rest of the groups, each time on port 0
- * + NOT promoting port counter
- * + setting path in remote switch fwd tbl if it hasn't been set yet
- * + setting hops in remote switch on all the ports of each group
- * if it hasn't been set yet
- *
- * 2. is_real_lid == TRUE && is_main_path == FALSE:
- * - going UP(TRUE,FALSE) on ALL the groups, each time on port 0,
- * but only if the remote (upper) switch hasn't been already
- * configured for this target LID
- * + NOT promoting port counter
- * + setting path in remote switch fwd tbl if it hasn't been set yet
- * + setting hops in remote switch on all the ports of each group
- * if it hasn't been set yet
- *
- * 3. is_real_lid == FALSE && is_main_path == TRUE:
- * - going UP(FALSE,TRUE) ONLY on selected min_group and min_port
- * + promoting port counter
- * + NOT setting path in remote switch fwd tbl
- * + NOT setting hops in remote switch
- *
- * 4. is_real_lid == FALSE && is_main_path == FALSE:
- * - illegal state - we shouldn't get here
- */
-
- /* covering first half of case 1, and case 3 */
- if (is_main_path) {
- if (p_sw->is_leaf) {
- OSM_LOG(&p_ftree->p_osm->log, OSM_LOG_DEBUG,
- " - Routing MAIN path for %s CA LID %u: %s --> %s\n",
- (is_real_lid) ? "real" : "DUMMY",
- cl_ntoh16(target_lid),
- __osm_ftree_tuple_to_str(p_sw->tuple),
- __osm_ftree_tuple_to_str(p_remote_sw->tuple));
- }
- /* The number of downgoing routes is tracked in the
- p_group->counter_down p_port->counter_down counters of the
- group and port that belong to the lower side of the link
- (on switch with higher rank) */
- p_min_group->counter_down++;
- p_min_port->counter_down++;
- if (is_real_lid) {
- p_remote_sw->p_osm_sw->new_lft[cl_ntoh16(target_lid)] =
- p_min_port->remote_port_num;
- OSM_LOG(&p_ftree->p_osm->log, OSM_LOG_DEBUG,
- "Switch %s: set path to CA LID %u through port %u\n",
- __osm_ftree_tuple_to_str(p_remote_sw->tuple),
- cl_ntoh16(target_lid),
- p_min_port->remote_port_num);
-
- /* On the remote switch that is pointed by the min_group,
- set hops for ALL the ports in the remote group. */
-
- ports_num =
- (uint16_t) cl_ptr_vector_get_size(&p_min_group->
- ports);
- for (j = 0; j < ports_num; j++) {
- cl_ptr_vector_at(&p_min_group->ports, j,
- (void *)&p_port);
- __osm_ftree_sw_set_hops(p_remote_sw,
- cl_ntoh16(target_lid),
- p_port->remote_port_num,
- target_rank -
- p_remote_sw->rank);
- }
- }
-
- /* Recursion step:
- Assign downgoing ports by stepping up, starting on REMOTE switch. */
- __osm_ftree_fabric_route_downgoing_by_going_up(p_ftree, p_remote_sw, /* remote switch - used as a route-downgoing alg. next step point */
- p_sw, /* this switch - prev. position switch for the function */
- target_lid, /* LID that we're routing to */
- target_rank, /* rank of the LID that we're routing to */
- is_real_lid, /* whether this target LID is real or dummy */
- is_main_path); /* whether this is path to HCA that should by tracked by counters */
- }
-
- /* we're done for the third case */
- if (!is_real_lid)
- return;
-
- /* What's left to do at this point:
- *
- * 1. is_real_lid == TRUE && is_main_path == TRUE:
- * - going UP(TRUE,FALSE) on rest of the groups, each time on port 0,
- * but only if the remote (upper) switch hasn't been already
- * configured for this target LID
- * + NOT promoting port counter
- * + setting path in remote switch fwd tbl if it hasn't been set yet
- * + setting hops in remote switch on all the ports of each group
- * if it hasn't been set yet
- *
- * 2. is_real_lid == TRUE && is_main_path == FALSE:
- * - going UP(TRUE,FALSE) on ALL the groups, each time on port 0,
- * but only if the remote (upper) switch hasn't been already
- * configured for this target LID
- * + NOT promoting port counter
- * + setting path in remote switch fwd tbl if it hasn't been set yet
- * + setting hops in remote switch on all the ports of each group
- * if it hasn't been set yet
- *
- * These two rules can be rephrased this way:
- * - foreach UP port group
- * + if remote switch has been set with the target LID
- * - skip this port group
- * + else
- * - select port 0
- * - do NOT promote port counter
- * - set path in remote switch fwd tbl
- * - set hops in remote switch on all the ports of this group
- * - go UP(TRUE,FALSE) to the remote switch
- */
-
- for (i = 0; i < p_sw->up_port_groups_num; i++) {
- p_group = p_sw->up_port_groups[i];
- p_remote_sw = p_group->remote_hca_or_sw.p_sw;
-
- /* skip if target lid has been already set on remote switch fwd tbl */
- if (p_remote_sw->p_osm_sw->new_lft[cl_ntoh16(target_lid)] != OSM_NO_PATH)
- continue;
-
- if (p_sw->is_leaf) {
- OSM_LOG(&p_ftree->p_osm->log, OSM_LOG_DEBUG,
- " - Routing SECONDARY path for LID %u: %s --> %s\n",
- cl_ntoh16(target_lid),
- __osm_ftree_tuple_to_str(p_sw->tuple),
- __osm_ftree_tuple_to_str(p_remote_sw->tuple));
- }
-
- /* Routing REAL lids on SECONDARY path means routing
- switch-to-switch or switch-to-CA paths.
- We can safely assume that switch will initiate very
- few traffic, so there's no point waisting runtime on
- trying to balance these routes - always pick port 0. */
-
- cl_ptr_vector_at(&p_group->ports, 0, (void *)&p_port);
- p_remote_sw->p_osm_sw->new_lft[cl_ntoh16(target_lid)] =
- p_port->remote_port_num;
-
- /* On the remote switch that is pointed by the p_group,
- set hops for ALL the ports in the remote group. */
-
- ports_num = (uint16_t) cl_ptr_vector_get_size(&p_group->ports);
- for (j = 0; j < ports_num; j++) {
- cl_ptr_vector_at(&p_group->ports, j, (void *)&p_port);
-
- __osm_ftree_sw_set_hops(p_remote_sw,
- cl_ntoh16(target_lid),
- p_port->remote_port_num,
- target_rank -
- p_remote_sw->rank);
- }
-
- /* Recursion step:
- Assign downgoing ports by stepping up, starting on REMOTE switch. */
- __osm_ftree_fabric_route_downgoing_by_going_up(p_ftree, p_remote_sw, /* remote switch - used as a route-downgoing alg. next step point */
- p_sw, /* this switch - prev. position switch for the function */
- target_lid, /* LID that we're routing to */
- target_rank, /* rank of the LID that we're routing to */
- TRUE, /* whether the target LID is real or dummy */
- FALSE); /* whether this is path to HCA that should by tracked by counters */
- }
-
-} /* ftree_fabric_route_downgoing_by_going_up() */
-
-/***************************************************/
-
-/*
- * Pseudo code:
- * foreach leaf switch (in indexing order)
- * for each compute node (in indexing order)
- * obtain the LID of the compute node
- * set local LFT(LID) of the port connecting to compute node
- * call assign-down-going-port-by-ascending-up(TRUE,TRUE) on CURRENT switch
- * for each MISSING compute node
- * call assign-down-going-port-by-ascending-up(FALSE,TRUE) on CURRENT switch
- */
-
-static void __osm_ftree_fabric_route_to_cns(IN ftree_fabric_t * p_ftree)
-{
- ftree_sw_t *p_sw;
- ftree_hca_t *p_hca;
- ftree_port_group_t *p_leaf_port_group;
- ftree_port_group_t *p_hca_port_group;
- ftree_port_t *p_port;
- uint32_t i;
- uint32_t j;
- ib_net16_t hca_lid;
- unsigned routed_targets_on_leaf;
-
- OSM_LOG_ENTER(&p_ftree->p_osm->log);
-
- /* for each leaf switch (in indexing order) */
- for (i = 0; i < p_ftree->leaf_switches_num; i++) {
- p_sw = p_ftree->leaf_switches[i];
- routed_targets_on_leaf = 0;
-
- /* for each HCA connected to this switch */
- for (j = 0; j < p_sw->down_port_groups_num; j++) {
- p_leaf_port_group = p_sw->down_port_groups[j];
-
- /* work with this port group only if the remote node is CA */
- if (p_leaf_port_group->remote_node_type !=
- IB_NODE_TYPE_CA)
- continue;
-
- p_hca = p_leaf_port_group->remote_hca_or_sw.p_hca;
-
- /* work with this port group only if remote HCA has CNs */
- if (!p_hca->cn_num)
- continue;
-
- p_hca_port_group =
- __osm_ftree_hca_get_port_group_by_remote_lid(p_hca,
- p_leaf_port_group->
- base_lid);
- CL_ASSERT(p_hca_port_group);
-
- /* work with this port group only if remote port is CN */
- if (!p_hca_port_group->is_cn)
- continue;
-
- /* obtain the LID of HCA port */
- hca_lid = p_leaf_port_group->remote_base_lid;
-
- /* set local LFT(LID) to the port that is connected to HCA */
- cl_ptr_vector_at(&p_leaf_port_group->ports, 0,
- (void *)&p_port);
- p_sw->p_osm_sw->new_lft[cl_ntoh16(hca_lid)] = p_port->port_num;
-
- OSM_LOG(&p_ftree->p_osm->log, OSM_LOG_DEBUG,
- "Switch %s: set path to CN LID %u through port %u\n",
- __osm_ftree_tuple_to_str(p_sw->tuple),
- cl_ntoh16(hca_lid), p_port->port_num);
-
- /* set local min hop table(LID) to route to the CA */
- __osm_ftree_sw_set_hops(p_sw,
- cl_ntoh16(hca_lid),
- p_port->port_num, 1);
-
- /* Assign downgoing ports by stepping up.
- Since we're routing here only CNs, we're routing it as REAL
- LID and updating fat-tree balancing counters. */
- __osm_ftree_fabric_route_downgoing_by_going_up(p_ftree, p_sw, /* local switch - used as a route-downgoing alg. start point */
- NULL, /* prev. position switch */
- hca_lid, /* LID that we're routing to */
- p_sw->rank + 1, /* rank of the LID that we're routing to */
- TRUE, /* whether this HCA LID is real or dummy */
- TRUE); /* whether this path to HCA should by tracked by counters */
-
- /* count how many real targets have been routed from this leaf switch */
- routed_targets_on_leaf++;
- }
-
- /* We're done with the real targets (all CNs) of this leaf switch.
- Now route the dummy HCAs that are missing or that are non-CNs.
- When routing to dummy HCAs we don't fill lid matrices. */
-
- if (p_ftree->max_cn_per_leaf > routed_targets_on_leaf) {
- OSM_LOG(&p_ftree->p_osm->log, OSM_LOG_DEBUG,
- "Routing %u dummy CAs\n",
- p_ftree->max_cn_per_leaf -
- p_sw->down_port_groups_num);
- for (j = 0;
- ((int)j) <
- (p_ftree->max_cn_per_leaf -
- routed_targets_on_leaf); j++) {
- /* assign downgoing ports by stepping up */
- __osm_ftree_fabric_route_downgoing_by_going_up(p_ftree, p_sw, /* local switch - used as a route-downgoing alg. start point */
- NULL, /* prev. position switch */
- 0, /* LID that we're routing to - ignored for dummy HCA */
- 0, /* rank of the LID that we're routing to - ignored for dummy HCA */
- FALSE, /* whether this HCA LID is real or dummy */
- TRUE); /* whether this path to HCA should by tracked by counters */
- }
- }
- }
- /* done going through all the leaf switches */
- OSM_LOG_EXIT(&p_ftree->p_osm->log);
-} /* __osm_ftree_fabric_route_to_cns() */
-
-/***************************************************/
-
-/*
- * Pseudo code:
- * foreach HCA non-CN port in fabric
- * obtain the LID of the HCA port
- * get switch that is connected to this HCA port
- * set switch LFT(LID) to the port connecting to compute node
- * call assign-down-going-port-by-ascending-up(TRUE,FALSE) on CURRENT switch
- *
- * Routing to these HCAs is routing a REAL hca lid on SECONDARY path.
- * However, we do want to allow load-leveling of the traffic to the non-CNs,
- * because such nodes may include IO nodes with heavy usage
- * - we should set fwd tables
- * - we should update port counters
- * Routing to non-CNs is done after routing to CNs, so updated port
- * counters will not affect CN-to-CN routing.
- */
-
-static void __osm_ftree_fabric_route_to_non_cns(IN ftree_fabric_t * p_ftree)
-{
- ftree_sw_t *p_sw;
- ftree_hca_t *p_hca;
- ftree_hca_t *p_next_hca;
- ftree_port_t *p_hca_port;
- ftree_port_group_t *p_hca_port_group;
- ib_net16_t hca_lid;
- unsigned port_num_on_switch;
- unsigned i;
-
- OSM_LOG_ENTER(&p_ftree->p_osm->log);
-
- p_next_hca = (ftree_hca_t *) cl_qmap_head(&p_ftree->hca_tbl);
- while (p_next_hca != (ftree_hca_t *) cl_qmap_end(&p_ftree->hca_tbl)) {
- p_hca = p_next_hca;
- p_next_hca = (ftree_hca_t *) cl_qmap_next(&p_hca->map_item);
-
- for (i = 0; i < p_hca->up_port_groups_num; i++) {
- p_hca_port_group = p_hca->up_port_groups[i];
-
- /* skip this port if it's CN, in which case it has been already routed */
- if (p_hca_port_group->is_cn)
- continue;
-
- /* skip this port if it is not connected to switch */
- if (p_hca_port_group->remote_node_type !=
- IB_NODE_TYPE_SWITCH)
- continue;
-
- p_sw = p_hca_port_group->remote_hca_or_sw.p_sw;
- hca_lid = p_hca_port_group->base_lid;
-
- /* set switches LFT(LID) to the port that is connected to HCA */
- cl_ptr_vector_at(&p_hca_port_group->ports, 0,
- (void *)&p_hca_port);
- port_num_on_switch = p_hca_port->remote_port_num;
- p_sw->p_osm_sw->new_lft[cl_ntoh16(hca_lid)] = port_num_on_switch;
-
- OSM_LOG(&p_ftree->p_osm->log, OSM_LOG_DEBUG,
- "Switch %s: set path to non-CN HCA LID %u through port %u\n",
- __osm_ftree_tuple_to_str(p_sw->tuple),
- cl_ntoh16(hca_lid), port_num_on_switch);
-
- /* set local min hop table(LID) to route to the CA */
- __osm_ftree_sw_set_hops(p_sw, cl_ntoh16(hca_lid),
- port_num_on_switch, /* port num */
- 1); /* hops */
-
- /* Assign downgoing ports by stepping up.
- We're routing REAL targets. They are not CNs and not included
- in the leafs array, but we treat them as MAIN path to allow load
- leveling, which means that the counters will be updated. */
- __osm_ftree_fabric_route_downgoing_by_going_up(p_ftree, p_sw, /* local switch - used as a route-downgoing alg. start point */
- NULL, /* prev. position switch */
- hca_lid, /* LID that we're routing to */
- p_sw->rank + 1, /* rank of the LID that we're routing to */
- TRUE, /* whether this HCA LID is real or dummy */
- TRUE); /* whether this path to HCA should by tracked by counters */
- }
- /* done with all the port groups of this HCA - go to next HCA */
- }
-
- OSM_LOG_EXIT(&p_ftree->p_osm->log);
-} /* __osm_ftree_fabric_route_to_non_cns() */
-
-/***************************************************/
-
-/*
- * Pseudo code:
- * foreach switch in fabric
- * obtain its LID
- * set local LFT(LID) to port 0
- * call assign-down-going-port-by-ascending-up(TRUE,FALSE) on CURRENT switch
- *
- * Routing to switch is similar to routing a REAL hca lid on SECONDARY path:
- * - we should set fwd tables
- * - we should NOT update port counters
- */
-
-static void __osm_ftree_fabric_route_to_switches(IN ftree_fabric_t * p_ftree)
-{
- ftree_sw_t *p_sw;
- ftree_sw_t *p_next_sw;
-
- OSM_LOG_ENTER(&p_ftree->p_osm->log);
-
- p_next_sw = (ftree_sw_t *) cl_qmap_head(&p_ftree->sw_tbl);
- while (p_next_sw != (ftree_sw_t *) cl_qmap_end(&p_ftree->sw_tbl)) {
- p_sw = p_next_sw;
- p_next_sw = (ftree_sw_t *) cl_qmap_next(&p_sw->map_item);
-
- /* set local LFT(LID) to 0 (route to itself) */
- p_sw->p_osm_sw->new_lft[cl_ntoh16(p_sw->base_lid)] = 0;
-
- OSM_LOG(&p_ftree->p_osm->log, OSM_LOG_DEBUG,
- "Switch %s (LID %u): routing switch-to-switch paths\n",
- __osm_ftree_tuple_to_str(p_sw->tuple),
- cl_ntoh16(p_sw->base_lid));
-
- /* set min hop table of the switch to itself */
- __osm_ftree_sw_set_hops(p_sw, cl_ntoh16(p_sw->base_lid),
- 0, /* port_num */
- 0); /* hops */
-
- __osm_ftree_fabric_route_downgoing_by_going_up(p_ftree, p_sw, /* local switch - used as a route-downgoing alg. start point */
- NULL, /* prev. position switch */
- p_sw->base_lid, /* LID that we're routing to */
- p_sw->rank, /* rank of the LID that we're routing to */
- TRUE, /* whether the target LID is a real or dummy */
- FALSE); /* whether this path should by tracked by counters */
- }
-
- OSM_LOG_EXIT(&p_ftree->p_osm->log);
-} /* __osm_ftree_fabric_route_to_switches() */
-
-/***************************************************
- ***************************************************/
-
-static int __osm_ftree_fabric_populate_nodes(IN ftree_fabric_t * p_ftree)
-{
- osm_node_t *p_osm_node;
- osm_node_t *p_next_osm_node;
-
- OSM_LOG_ENTER(&p_ftree->p_osm->log);
-
- p_next_osm_node =
- (osm_node_t *) cl_qmap_head(&p_ftree->p_osm->subn.node_guid_tbl);
- while (p_next_osm_node !=
- (osm_node_t *) cl_qmap_end(&p_ftree->p_osm->subn.
- node_guid_tbl)) {
- p_osm_node = p_next_osm_node;
- p_next_osm_node =
- (osm_node_t *) cl_qmap_next(&p_osm_node->map_item);
- switch (osm_node_get_type(p_osm_node)) {
- case IB_NODE_TYPE_CA:
- __osm_ftree_fabric_add_hca(p_ftree, p_osm_node);
- break;
- case IB_NODE_TYPE_ROUTER:
- break;
- case IB_NODE_TYPE_SWITCH:
- __osm_ftree_fabric_add_sw(p_ftree, p_osm_node->sw);
- break;
- default:
- OSM_LOG(&p_ftree->p_osm->log, OSM_LOG_ERROR, "ERR AB0E: "
- "Node GUID 0x%016" PRIx64
- " - Unknown node type: %s\n",
- cl_ntoh64(osm_node_get_node_guid(p_osm_node)),
- ib_get_node_type_str(osm_node_get_type
- (p_osm_node)));
- OSM_LOG_EXIT(&p_ftree->p_osm->log);
- return -1;
- }
- }
-
- OSM_LOG_EXIT(&p_ftree->p_osm->log);
- return 0;
-} /* __osm_ftree_fabric_populate_nodes() */
-
-/***************************************************
- ***************************************************/
-
-static boolean_t __osm_ftree_sw_update_rank(IN ftree_sw_t * p_sw,
- IN uint32_t new_rank)
-{
- if (__osm_ftree_sw_ranked(p_sw) && p_sw->rank <= new_rank)
- return FALSE;
- p_sw->rank = new_rank;
- return TRUE;
-
-}
-
-/***************************************************/
-
-static void
-__osm_ftree_rank_switches_from_leafs(IN ftree_fabric_t * p_ftree,
- IN cl_list_t * p_ranking_bfs_list)
-{
- ftree_sw_t *p_sw;
- ftree_sw_t *p_remote_sw;
- osm_node_t *p_node;
- osm_node_t *p_remote_node;
- osm_physp_t *p_osm_port;
- uint8_t i;
- unsigned max_rank = 0;
-
- while (!cl_is_list_empty(p_ranking_bfs_list)) {
- p_sw = (ftree_sw_t *) cl_list_remove_head(p_ranking_bfs_list);
- p_node = p_sw->p_osm_sw->p_node;
-
- /* note: skipping port 0 on switches */
- for (i = 1; i < osm_node_get_num_physp(p_node); i++) {
- p_osm_port = osm_node_get_physp_ptr(p_node, i);
- if (!p_osm_port || !osm_link_is_healthy(p_osm_port))
- continue;
-
- p_remote_node =
- osm_node_get_remote_node(p_node, i, NULL);
- if (!p_remote_node)
- continue;
- if (osm_node_get_type(p_remote_node) !=
- IB_NODE_TYPE_SWITCH)
- continue;
-
- p_remote_sw = __osm_ftree_fabric_get_sw_by_guid(p_ftree,
- osm_node_get_node_guid
- (p_remote_node));
- if (!p_remote_sw) {
- /* remote node is not a switch */
- continue;
- }
-
- /* if needed, rank the remote switch and add it to the BFS list */
- if (__osm_ftree_sw_update_rank
- (p_remote_sw, p_sw->rank + 1)) {
- max_rank = p_remote_sw->rank;
- cl_list_insert_tail(p_ranking_bfs_list,
- p_remote_sw);
- }
- }
- }
-
- /* set FatTree maximal switch rank */
- p_ftree->max_switch_rank = max_rank;
-
-} /* __osm_ftree_rank_switches_from_leafs() */
-
-/***************************************************/
-
-static int
-__osm_ftree_rank_leaf_switches(IN ftree_fabric_t * p_ftree,
- IN ftree_hca_t * p_hca,
- IN cl_list_t * p_ranking_bfs_list)
-{
- ftree_sw_t *p_sw;
- osm_node_t *p_osm_node = p_hca->p_osm_node;
- osm_node_t *p_remote_osm_node;
- osm_physp_t *p_osm_port;
- static uint8_t i = 0;
- int res = 0;
-
- OSM_LOG_ENTER(&p_ftree->p_osm->log);
-
- for (i = 0; i < osm_node_get_num_physp(p_osm_node); i++) {
- p_osm_port = osm_node_get_physp_ptr(p_osm_node, i);
- if (!p_osm_port || !osm_link_is_healthy(p_osm_port))
- continue;
-
- p_remote_osm_node =
- osm_node_get_remote_node(p_osm_node, i, NULL);
- if (!p_remote_osm_node)
- continue;
-
- switch (osm_node_get_type(p_remote_osm_node)) {
- case IB_NODE_TYPE_CA:
- /* HCA connected directly to another HCA - not FatTree */
- OSM_LOG(&p_ftree->p_osm->log, OSM_LOG_ERROR, "ERR AB0F: "
- "CA conected directly to another CA: "
- "0x%016" PRIx64 " <---> 0x%016" PRIx64 "\n",
- __osm_ftree_hca_get_guid_ho(p_hca),
- cl_ntoh64(osm_node_get_node_guid
- (p_remote_osm_node)));
- res = -1;
- goto Exit;
-
- case IB_NODE_TYPE_ROUTER:
- /* leaving this port - proceeding to the next one */
- continue;
-
- case IB_NODE_TYPE_SWITCH:
- /* continue with this port */
- break;
-
- default:
- OSM_LOG(&p_ftree->p_osm->log, OSM_LOG_ERROR,
- "ERR AB10: Node GUID 0x%016" PRIx64
- " - Unknown node type: %s\n",
- cl_ntoh64(osm_node_get_node_guid
- (p_remote_osm_node)),
- ib_get_node_type_str(osm_node_get_type
- (p_remote_osm_node)));
- res = -1;
- goto Exit;
- }
-
- /* remote node is switch */
-
- p_sw = __osm_ftree_fabric_get_sw_by_guid(p_ftree,
- osm_node_get_node_guid
- (p_osm_port->
- p_remote_physp->
- p_node));
- CL_ASSERT(p_sw);
-
- /* if needed, rank the remote switch and add it to the BFS list */
-
- if (!__osm_ftree_sw_update_rank(p_sw, 0))
- continue;
- OSM_LOG(&p_ftree->p_osm->log, OSM_LOG_DEBUG,
- "Marking rank of switch that is directly connected to CA:\n"
- " - CA guid : 0x%016"
- PRIx64 "\n"
- " - Switch guid: 0x%016"
- PRIx64 "\n"
- " - Switch LID : %u\n",
- __osm_ftree_hca_get_guid_ho(p_hca),
- __osm_ftree_sw_get_guid_ho(p_sw),
- cl_ntoh16(p_sw->base_lid));
- cl_list_insert_tail(p_ranking_bfs_list, p_sw);
- }
-
-Exit:
- OSM_LOG_EXIT(&p_ftree->p_osm->log);
- return res;
-} /* __osm_ftree_rank_leaf_switches() */
-
-/***************************************************/
-
-static void __osm_ftree_sw_reverse_rank(IN cl_map_item_t * const p_map_item,
- IN void *context)
-{
- ftree_fabric_t *p_ftree = (ftree_fabric_t *) context;
- ftree_sw_t *p_sw = (ftree_sw_t * const)p_map_item;
- p_sw->rank = p_ftree->max_switch_rank - p_sw->rank;
-}
-
-/***************************************************
- ***************************************************/
-
-static int
-__osm_ftree_fabric_construct_hca_ports(IN ftree_fabric_t * p_ftree,
- IN ftree_hca_t * p_hca)
-{
- ftree_sw_t *p_remote_sw;
- osm_node_t *p_node = p_hca->p_osm_node;
- osm_node_t *p_remote_node;
- uint8_t remote_node_type;
- ib_net64_t remote_node_guid;
- osm_physp_t *p_remote_osm_port;
- uint8_t i;
- uint8_t remote_port_num;
- boolean_t is_cn = FALSE;
- int res = 0;
-
- for (i = 0; i < osm_node_get_num_physp(p_node); i++) {
- osm_physp_t *p_osm_port = osm_node_get_physp_ptr(p_node, i);
- if (!p_osm_port || !osm_link_is_healthy(p_osm_port))
- continue;
-
- p_remote_osm_port = osm_physp_get_remote(p_osm_port);
- p_remote_node =
- osm_node_get_remote_node(p_node, i, &remote_port_num);
-
- if (!p_remote_osm_port)
- continue;
-
- remote_node_type = osm_node_get_type(p_remote_node);
- remote_node_guid = osm_node_get_node_guid(p_remote_node);
-
- switch (remote_node_type) {
- case IB_NODE_TYPE_ROUTER:
- /* leaving this port - proceeding to the next one */
- continue;
-
- case IB_NODE_TYPE_CA:
- /* HCA connected directly to another HCA - not FatTree */
- OSM_LOG(&p_ftree->p_osm->log, OSM_LOG_ERROR, "ERR AB11: "
- "CA conected directly to another CA: "
- "0x%016" PRIx64 " <---> 0x%016" PRIx64 "\n",
- cl_ntoh64(osm_node_get_node_guid(p_node)),
- cl_ntoh64(remote_node_guid));
- res = -1;
- goto Exit;
-
- case IB_NODE_TYPE_SWITCH:
- /* continue with this port */
- break;
-
- default:
- OSM_LOG(&p_ftree->p_osm->log, OSM_LOG_ERROR,
- "ERR AB12: Node GUID 0x%016" PRIx64
- " - Unknown node type: %s\n",
- cl_ntoh64(remote_node_guid),
- ib_get_node_type_str(remote_node_type));
- res = -1;
- goto Exit;
- }
-
- /* remote node is switch */
-
- p_remote_sw =
- __osm_ftree_fabric_get_sw_by_guid(p_ftree,
- remote_node_guid);
- CL_ASSERT(p_remote_sw);
-
- /* If CN file is not supplied, then all the CAs considered as Compute Nodes.
- Otherwise all the CAs are not CNs, and only guids that are present in the
- CN file will be marked as compute nodes. */
- if (!__osm_ftree_fabric_cns_provided(p_ftree)) {
- is_cn = TRUE;
- } else {
- name_map_item_t *p_elem =
- (name_map_item_t *) cl_qmap_get(&p_ftree->
- cn_guid_tbl,
- cl_ntoh64(osm_physp_get_port_guid
- (p_osm_port)));
- if (p_elem !=
- (name_map_item_t *) cl_qmap_end(&p_ftree->
- cn_guid_tbl))
- is_cn = TRUE;
- }
-
- if (is_cn) {
- p_ftree->cn_num++;
- p_hca->cn_num++;
- OSM_LOG(&p_ftree->p_osm->log, OSM_LOG_DEBUG,
- "Marking CN port GUID 0x%016" PRIx64 "\n",
- cl_ntoh64(osm_physp_get_port_guid(p_osm_port)));
- } else {
- OSM_LOG(&p_ftree->p_osm->log, OSM_LOG_DEBUG,
- "Marking non-CN port GUID 0x%016" PRIx64 "\n",
- cl_ntoh64(osm_physp_get_port_guid(p_osm_port)));
- }
-
- __osm_ftree_hca_add_port(p_hca, /* local ftree_hca object */
- i, /* local port number */
- remote_port_num, /* remote port number */
- osm_node_get_base_lid(p_node, i), /* local lid */
- osm_node_get_base_lid(p_remote_node, 0), /* remote lid */
- osm_physp_get_port_guid(p_osm_port), /* local port guid */
- osm_physp_get_port_guid(p_remote_osm_port), /* remote port guid */
- remote_node_guid, /* remote node guid */
- remote_node_type, /* remote node type */
- (void *)p_remote_sw, /* remote ftree_hca/sw object */
- is_cn); /* whether this port is compute node */
- }
-
-Exit:
- return res;
-} /* __osm_ftree_fabric_construct_hca_ports() */
-
-/***************************************************
- ***************************************************/
-static boolean_t __osm_invalid_link_rank_diff(const uint32_t val)
-{
- return (val != 1U && val != -1U);
-}
-
-static int __osm_ftree_fabric_construct_sw_ports(IN ftree_fabric_t * p_ftree,
- IN ftree_sw_t * p_sw)
-{
- ftree_hca_t *p_remote_hca;
- ftree_sw_t *p_remote_sw;
- osm_node_t *p_node = p_sw->p_osm_sw->p_node;
- osm_node_t *p_remote_node;
- ib_net16_t remote_base_lid;
- uint8_t remote_node_type;
- ib_net64_t remote_node_guid;
- osm_physp_t *p_remote_osm_port;
- ftree_direction_t direction;
- void *p_remote_hca_or_sw;
- uint8_t i;
- uint8_t remote_port_num;
- int res = 0;
-
- CL_ASSERT(osm_node_get_type(p_node) == IB_NODE_TYPE_SWITCH);
-
- for (i = 1; i < osm_node_get_num_physp(p_node); i++) {
- osm_physp_t *p_osm_port = osm_node_get_physp_ptr(p_node, i);
- if (!p_osm_port || !osm_link_is_healthy(p_osm_port))
- continue;
-
- p_remote_osm_port = osm_physp_get_remote(p_osm_port);
- if (!p_remote_osm_port)
- continue;
-
- p_remote_node =
- osm_node_get_remote_node(p_node, i, &remote_port_num);
-
- /* ignore any loopback connection on switch */
- if (p_node == p_remote_node) {
- OSM_LOG(&p_ftree->p_osm->log, OSM_LOG_DEBUG,
- "Ignoring loopback on switch GUID 0x%016" PRIx64
- ", LID %u, rank %u\n",
- __osm_ftree_sw_get_guid_ho(p_sw),
- cl_ntoh16(p_sw->base_lid),
- p_sw->rank);
- continue;
- }
-
- remote_node_type = osm_node_get_type(p_remote_node);
- remote_node_guid = osm_node_get_node_guid(p_remote_node);
-
- switch (remote_node_type) {
- case IB_NODE_TYPE_ROUTER:
- /* leaving this port - proceeding to the next one */
- continue;
-
- case IB_NODE_TYPE_CA:
- /* switch connected to hca */
-
- p_remote_hca =
- __osm_ftree_fabric_get_hca_by_guid(p_ftree,
- remote_node_guid);
- CL_ASSERT(p_remote_hca);
-
- p_remote_hca_or_sw = (void *)p_remote_hca;
- direction = FTREE_DIRECTION_DOWN;
-
- remote_base_lid =
- osm_physp_get_base_lid(p_remote_osm_port);
- break;
-
- case IB_NODE_TYPE_SWITCH:
- /* switch connected to another switch */
-
- p_remote_sw =
- __osm_ftree_fabric_get_sw_by_guid(p_ftree,
- remote_node_guid);
- CL_ASSERT(p_remote_sw);
-
- p_remote_hca_or_sw = (void *)p_remote_sw;
-
- if (__osm_invalid_link_rank_diff(p_sw->rank - p_remote_sw->rank)) {
- OSM_LOG(&p_ftree->p_osm->log, OSM_LOG_ERROR,
- "ERR AB16: "
- "Illegal link between switches with ranks %u and %u:\n"
- " GUID 0x%016" PRIx64
- ", LID %u, rank %u\n"
- " GUID 0x%016" PRIx64
- ", LID %u, rank %u\n", p_sw->rank,
- p_remote_sw->rank,
- __osm_ftree_sw_get_guid_ho(p_sw),
- cl_ntoh16(p_sw->base_lid), p_sw->rank,
- __osm_ftree_sw_get_guid_ho(p_remote_sw),
- cl_ntoh16(p_remote_sw->base_lid),
- p_remote_sw->rank);
- res = -1;
- goto Exit;
- }
-
- if (p_sw->rank > p_remote_sw->rank)
- direction = FTREE_DIRECTION_UP;
- else
- direction = FTREE_DIRECTION_DOWN;
-
- /* switch LID is only in port 0 port_info structure */
- remote_base_lid =
- osm_node_get_base_lid(p_remote_node, 0);
-
- break;
-
- default:
- OSM_LOG(&p_ftree->p_osm->log, OSM_LOG_ERROR,
- "ERR AB13: Node GUID 0x%016" PRIx64
- " - Unknown node type: %s\n",
- cl_ntoh64(remote_node_guid),
- ib_get_node_type_str(remote_node_type));
- res = -1;
- goto Exit;
- }
- __osm_ftree_sw_add_port(p_sw, /* local ftree_sw object */
- i, /* local port number */
- remote_port_num, /* remote port number */
- p_sw->base_lid, /* local lid */
- remote_base_lid, /* remote lid */
- osm_physp_get_port_guid(p_osm_port), /* local port guid */
- osm_physp_get_port_guid(p_remote_osm_port), /* remote port guid */
- remote_node_guid, /* remote node guid */
- remote_node_type, /* remote node type */
- p_remote_hca_or_sw, /* remote ftree_hca/sw object */
- direction); /* port direction (up or down) */
-
- /* Track the max lid (in host order) that exists in the fabric */
- if (cl_ntoh16(remote_base_lid) > p_ftree->lft_max_lid_ho)
- p_ftree->lft_max_lid_ho = cl_ntoh16(remote_base_lid);
- }
-
-Exit:
- return res;
-} /* __osm_ftree_fabric_construct_sw_ports() */
-
-/***************************************************
- ***************************************************/
-
-static int __osm_ftree_fabric_rank_from_roots(IN ftree_fabric_t * p_ftree)
-{
- osm_node_t *p_osm_node;
- osm_node_t *p_remote_osm_node;
- osm_physp_t *p_osm_physp;
- ftree_sw_t *p_sw;
- ftree_sw_t *p_remote_sw;
- cl_list_t ranking_bfs_list;
- struct guid_list_item *item;
- int res = 0;
- unsigned num_roots;
- unsigned max_rank = 0;
- unsigned i;
-
- OSM_LOG_ENTER(&p_ftree->p_osm->log);
- cl_list_init(&ranking_bfs_list, 10);
-
- /* Rank all the roots and add them to list */
- for (item = (void *)cl_qlist_head(&p_ftree->root_guid_list);
- item != (void *)cl_qlist_end(&p_ftree->root_guid_list);
- item = (void *)cl_qlist_next(&item->list)) {
- p_sw =
- __osm_ftree_fabric_get_sw_by_guid(p_ftree,
- cl_hton64(item->guid));
- if (!p_sw) {
- /* the specified root guid wasn't found in the fabric */
- OSM_LOG(&p_ftree->p_osm->log, OSM_LOG_ERROR, "ERR AB24: "
- "Root switch GUID 0x%" PRIx64 " not found\n",
- item->guid);
- continue;
- }
-
- OSM_LOG(&p_ftree->p_osm->log, OSM_LOG_DEBUG,
- "Ranking root switch with GUID 0x%" PRIx64 "\n",
- item->guid);
- p_sw->rank = 0;
- cl_list_insert_tail(&ranking_bfs_list, p_sw);
- }
-
- num_roots = cl_list_count(&ranking_bfs_list);
- if (!num_roots) {
- OSM_LOG(&p_ftree->p_osm->log, OSM_LOG_ERROR, "ERR AB25: "
- "No valid roots supplied\n");
- res = -1;
- goto Exit;
- }
-
- OSM_LOG(&p_ftree->p_osm->log, OSM_LOG_VERBOSE,
- "Ranked %u valid root switches\n", num_roots);
-
- /* Now the list has all the roots.
- BFS the subnet and update rank on all the switches. */
-
- while (!cl_is_list_empty(&ranking_bfs_list)) {
- p_sw = (ftree_sw_t *) cl_list_remove_head(&ranking_bfs_list);
- p_osm_node = p_sw->p_osm_sw->p_node;
-
- /* note: skipping port 0 on switches */
- for (i = 1; i < osm_node_get_num_physp(p_osm_node); i++) {
- p_osm_physp = osm_node_get_physp_ptr(p_osm_node, i);
- if (!p_osm_physp || !osm_link_is_healthy(p_osm_physp))
- continue;
-
- p_remote_osm_node =
- osm_node_get_remote_node(p_osm_node, i, NULL);
- if (!p_remote_osm_node)
- continue;
-
- if (osm_node_get_type(p_remote_osm_node) !=
- IB_NODE_TYPE_SWITCH)
- continue;
-
- p_remote_sw = __osm_ftree_fabric_get_sw_by_guid(p_ftree,
- osm_node_get_node_guid
- (p_remote_osm_node));
- CL_ASSERT(p_remote_sw);
-
- /* if needed, rank the remote switch and add it to the BFS list */
- if (__osm_ftree_sw_update_rank
- (p_remote_sw, p_sw->rank + 1)) {
- OSM_LOG(&p_ftree->p_osm->log, OSM_LOG_DEBUG,
- "Ranking switch 0x%" PRIx64
- " with rank %u\n",
- __osm_ftree_sw_get_guid_ho(p_remote_sw),
- p_remote_sw->rank);
- max_rank = p_remote_sw->rank;
- cl_list_insert_tail(&ranking_bfs_list,
- p_remote_sw);
- }
- }
- /* done with ports of this switch - go to the next switch in the list */
- }
-
- OSM_LOG(&p_ftree->p_osm->log, OSM_LOG_VERBOSE,
- "Subnet ranking completed. Max Node Rank = %u\n", max_rank);
-
- /* set FatTree maximal switch rank */
- p_ftree->max_switch_rank = max_rank;
-
-Exit:
- cl_list_destroy(&ranking_bfs_list);
- OSM_LOG_EXIT(&p_ftree->p_osm->log);
- return res;
-} /* __osm_ftree_fabric_rank_from_roots() */
-
-/***************************************************
- ***************************************************/
-
-static int __osm_ftree_fabric_rank_from_hcas(IN ftree_fabric_t * p_ftree)
-{
- ftree_hca_t *p_hca;
- ftree_hca_t *p_next_hca;
- cl_list_t ranking_bfs_list;
- int res = 0;
-
- OSM_LOG_ENTER(&p_ftree->p_osm->log);
-
- cl_list_init(&ranking_bfs_list, 10);
-
- /* Mark REVERSED rank of all the switches in the subnet.
- Start from switches that are connected to hca's, and
- scan all the switches in the subnet. */
- p_next_hca = (ftree_hca_t *) cl_qmap_head(&p_ftree->hca_tbl);
- while (p_next_hca != (ftree_hca_t *) cl_qmap_end(&p_ftree->hca_tbl)) {
- p_hca = p_next_hca;
- p_next_hca = (ftree_hca_t *) cl_qmap_next(&p_hca->map_item);
- if (__osm_ftree_rank_leaf_switches
- (p_ftree, p_hca, &ranking_bfs_list) != 0) {
- res = -1;
- OSM_LOG(&p_ftree->p_osm->log, OSM_LOG_ERROR, "ERR AB14: "
- "Subnet ranking failed - subnet is not FatTree");
- goto Exit;
- }
- }
-
- /* Now rank rest of the switches in the fabric, while the
- list already contains all the ranked leaf switches */
- __osm_ftree_rank_switches_from_leafs(p_ftree, &ranking_bfs_list);
-
- /* fix ranking of the switches by reversing the ranking direction */
- cl_qmap_apply_func(&p_ftree->sw_tbl, __osm_ftree_sw_reverse_rank,
- (void *)p_ftree);
-
-Exit:
- cl_list_destroy(&ranking_bfs_list);
- OSM_LOG_EXIT(&p_ftree->p_osm->log);
- return res;
-} /* __osm_ftree_fabric_rank_from_hcas() */
-
-/***************************************************
- ***************************************************/
-
-static int __osm_ftree_fabric_rank(IN ftree_fabric_t * p_ftree)
-{
- int res = 0;
-
- OSM_LOG_ENTER(&p_ftree->p_osm->log);
-
- if (__osm_ftree_fabric_roots_provided(p_ftree))
- res = __osm_ftree_fabric_rank_from_roots(p_ftree);
- else
- res = __osm_ftree_fabric_rank_from_hcas(p_ftree);
-
- if (res)
- goto Exit;
-
- OSM_LOG(&p_ftree->p_osm->log, OSM_LOG_INFO,
- "FatTree max switch rank is %u\n", p_ftree->max_switch_rank);
-
-Exit:
- OSM_LOG_EXIT(&p_ftree->p_osm->log);
- return res;
-} /* __osm_ftree_fabric_rank() */
-
-/***************************************************
- ***************************************************/
-
-static void __osm_ftree_fabric_set_leaf_rank(IN ftree_fabric_t * p_ftree)
-{
- unsigned i;
- ftree_sw_t *p_sw;
- ftree_hca_t *p_hca = NULL;
- ftree_hca_t *p_next_hca;
-
- OSM_LOG_ENTER(&p_ftree->p_osm->log);
-
- if (!__osm_ftree_fabric_roots_provided(p_ftree)) {
- /* If root file is not provided, the fabric has to be pure fat-tree
- in terms of ranking. Thus, leaf switches rank is the max rank. */
- p_ftree->leaf_switch_rank = p_ftree->max_switch_rank;
- } else {
- /* Find the first CN and set the leaf_switch_rank to the rank
- of the switch that is connected to this CN. Later we will
- ensure that all the leaf switches have the same rank. */
- p_next_hca = (ftree_hca_t *) cl_qmap_head(&p_ftree->hca_tbl);
- while (p_next_hca !=
- (ftree_hca_t *) cl_qmap_end(&p_ftree->hca_tbl)) {
- p_hca = p_next_hca;
- if (p_hca->cn_num)
- break;
- p_next_hca =
- (ftree_hca_t *) cl_qmap_next(&p_hca->map_item);
- }
- /* we know that there are CNs in the fabric, so just to be sure... */
- CL_ASSERT(p_next_hca !=
- (ftree_hca_t *) cl_qmap_end(&p_ftree->hca_tbl));
-
- OSM_LOG(&p_ftree->p_osm->log, OSM_LOG_DEBUG,
- "Selected CN port GUID 0x%" PRIx64 "\n",
- __osm_ftree_hca_get_guid_ho(p_hca));
-
- for (i = 0; (i < p_hca->up_port_groups_num)
- && (!p_hca->up_port_groups[i]->is_cn); i++) ;
- CL_ASSERT(i < p_hca->up_port_groups_num);
- CL_ASSERT(p_hca->up_port_groups[i]->remote_node_type ==
- IB_NODE_TYPE_SWITCH);
-
- p_sw = p_hca->up_port_groups[i]->remote_hca_or_sw.p_sw;
- OSM_LOG(&p_ftree->p_osm->log, OSM_LOG_DEBUG,
- "Selected leaf switch GUID 0x%" PRIx64 ", rank %u\n",
- __osm_ftree_sw_get_guid_ho(p_sw), p_sw->rank);
- p_ftree->leaf_switch_rank = p_sw->rank;
- }
-
- OSM_LOG(&p_ftree->p_osm->log, OSM_LOG_INFO,
- "FatTree leaf switch rank is %u\n", p_ftree->leaf_switch_rank);
- OSM_LOG_EXIT(&p_ftree->p_osm->log);
-} /* __osm_ftree_fabric_set_leaf_rank() */
-
-/***************************************************
- ***************************************************/
-
-static int __osm_ftree_fabric_populate_ports(IN ftree_fabric_t * p_ftree)
-{
- ftree_hca_t *p_hca;
- ftree_hca_t *p_next_hca;
- ftree_sw_t *p_sw;
- ftree_sw_t *p_next_sw;
- int res = 0;
-
- OSM_LOG_ENTER(&p_ftree->p_osm->log);
-
- p_next_hca = (ftree_hca_t *) cl_qmap_head(&p_ftree->hca_tbl);
- while (p_next_hca != (ftree_hca_t *) cl_qmap_end(&p_ftree->hca_tbl)) {
- p_hca = p_next_hca;
- p_next_hca = (ftree_hca_t *) cl_qmap_next(&p_hca->map_item);
- if (__osm_ftree_fabric_construct_hca_ports(p_ftree, p_hca) != 0) {
- res = -1;
- goto Exit;
- }
- }
-
- p_next_sw = (ftree_sw_t *) cl_qmap_head(&p_ftree->sw_tbl);
- while (p_next_sw != (ftree_sw_t *) cl_qmap_end(&p_ftree->sw_tbl)) {
- p_sw = p_next_sw;
- p_next_sw = (ftree_sw_t *) cl_qmap_next(&p_sw->map_item);
- if (__osm_ftree_fabric_construct_sw_ports(p_ftree, p_sw) != 0) {
- res = -1;
- goto Exit;
- }
- }
-Exit:
- OSM_LOG_EXIT(&p_ftree->p_osm->log);
- return res;
-} /* __osm_ftree_fabric_populate_ports() */
-
-/***************************************************
- ***************************************************/
-static int add_guid_item_to_list(void *cxt, uint64_t guid, char *p)
-{
- cl_qlist_t *list = cxt;
- struct guid_list_item *item;
-
- item = malloc(sizeof(*item));
- if (!item)
- return -1;
-
- item->guid = guid;
- cl_qlist_insert_tail(list, &item->list);
-
- return 0;
-}
-
-static int add_guid_item_to_map(void *cxt, uint64_t guid, char *p)
-{
- cl_qmap_t *map = cxt;
- name_map_item_t *item;
-
- item = malloc(sizeof(*item));
- if (!item)
- return -1;
-
- item->guid = guid;
- cl_qmap_insert(map, guid, &item->item);
-
- return 0;
-}
-
-static int __osm_ftree_fabric_read_guid_files(IN ftree_fabric_t * p_ftree)
-{
- int status = 0;
-
- OSM_LOG_ENTER(&p_ftree->p_osm->log);
-
- if (__osm_ftree_fabric_roots_provided(p_ftree)) {
- OSM_LOG(&p_ftree->p_osm->log, OSM_LOG_DEBUG,
- "Fetching root nodes from file %s\n",
- p_ftree->p_osm->subn.opt.root_guid_file);
-
- if (parse_node_map(p_ftree->p_osm->subn.opt.root_guid_file,
- add_guid_item_to_list,
- &p_ftree->root_guid_list)) {
- status = -1;
- goto Exit;
- }
-
- if (!cl_qlist_count(&p_ftree->root_guid_list)) {
- OSM_LOG(&p_ftree->p_osm->log, OSM_LOG_ERROR, "ERR AB22: "
- "Root guids file has no valid guids\n");
- status = -1;
- goto Exit;
- }
- }
-
- if (__osm_ftree_fabric_cns_provided(p_ftree)) {
- OSM_LOG(&p_ftree->p_osm->log, OSM_LOG_DEBUG,
- "Fetching compute nodes from file %s\n",
- p_ftree->p_osm->subn.opt.cn_guid_file);
-
- if (parse_node_map(p_ftree->p_osm->subn.opt.cn_guid_file,
- add_guid_item_to_map,
- &p_ftree->cn_guid_tbl)) {
- status = -1;
- goto Exit;
- }
-
- if (!cl_qmap_count(&p_ftree->cn_guid_tbl)) {
- OSM_LOG(&p_ftree->p_osm->log, OSM_LOG_ERROR, "ERR AB23: "
- "Compute node guids file has no valid guids\n");
- status = -1;
- goto Exit;
- }
- }
-
-Exit:
- OSM_LOG_EXIT(&p_ftree->p_osm->log);
- return status;
-} /*__osm_ftree_fabric_read_guid_files() */
-
-/***************************************************
- ***************************************************/
-
-static int __osm_ftree_construct_fabric(IN void *context)
-{
- ftree_fabric_t *p_ftree = context;
- int status = 0;
-
- OSM_LOG_ENTER(&p_ftree->p_osm->log);
-
- __osm_ftree_fabric_clear(p_ftree);
-
- if (p_ftree->p_osm->subn.opt.lmc > 0) {
- osm_log(&p_ftree->p_osm->log, OSM_LOG_SYS,
- "LMC > 0 is not supported by fat-tree routing.\n"
- "Falling back to default routing\n");
- status = -1;
- goto Exit;
- }
-
- if (cl_qmap_count(&p_ftree->p_osm->subn.sw_guid_tbl) < 2) {
- osm_log(&p_ftree->p_osm->log, OSM_LOG_SYS,
- "Fabric has %u switches - topology is not fat-tree.\n"
- "Falling back to default routing\n",
- cl_qmap_count(&p_ftree->p_osm->subn.sw_guid_tbl));
- status = -1;
- goto Exit;
- }
-
- if ((cl_qmap_count(&p_ftree->p_osm->subn.node_guid_tbl) -
- cl_qmap_count(&p_ftree->p_osm->subn.sw_guid_tbl)) < 2) {
- osm_log(&p_ftree->p_osm->log, OSM_LOG_SYS,
- "Fabric has %u nodes (%u switches) - topology is not fat-tree.\n"
- "Falling back to default routing\n",
- cl_qmap_count(&p_ftree->p_osm->subn.node_guid_tbl),
- cl_qmap_count(&p_ftree->p_osm->subn.sw_guid_tbl));
- status = -1;
- goto Exit;
- }
-
- OSM_LOG(&p_ftree->p_osm->log, OSM_LOG_VERBOSE, "\n"
- " |----------------------------------------|\n"
- " |- Starting FatTree fabric construction -|\n"
- " |----------------------------------------|\n\n");
-
- OSM_LOG(&p_ftree->p_osm->log, OSM_LOG_VERBOSE,
- "Populating FatTree Switch and CA tables\n");
- if (__osm_ftree_fabric_populate_nodes(p_ftree) != 0) {
- osm_log(&p_ftree->p_osm->log, OSM_LOG_SYS,
- "Fabric topology is not fat-tree - "
- "falling back to default routing\n");
- status = -1;
- goto Exit;
- }
-
- OSM_LOG(&p_ftree->p_osm->log, OSM_LOG_VERBOSE,
- "Reading guid files provided by user\n");
- if (__osm_ftree_fabric_read_guid_files(p_ftree) != 0) {
- osm_log(&p_ftree->p_osm->log, OSM_LOG_SYS,
- "Failed reading guid files - "
- "falling back to default routing\n");
- status = -1;
- goto Exit;
- }
-
- if (cl_qmap_count(&p_ftree->hca_tbl) < 2) {
- osm_log(&p_ftree->p_osm->log, OSM_LOG_SYS,
- "Fabric has %u CAa - topology is not fat-tree.\n"
- "Falling back to default routing\n",
- cl_qmap_count(&p_ftree->hca_tbl));
- status = -1;
- goto Exit;
- }
-
- /* Rank all the switches in the fabric.
- After that we will know only fabric max switch rank.
- We will be able to check leaf switches rank and the
- whole tree rank after filling ports and marking CNs. */
- OSM_LOG(&p_ftree->p_osm->log, OSM_LOG_VERBOSE, "Ranking FatTree\n");
- if (__osm_ftree_fabric_rank(p_ftree) != 0) {
- osm_log(&p_ftree->p_osm->log, OSM_LOG_SYS,
- "Failed ranking the tree\n");
- status = -1;
- goto Exit;
- }
-
- /* For each hca and switch, construct array of ports.
- This is done after the whole FatTree data structure is ready,
- because we want the ports to have pointers to ftree_{sw,hca}_t
- objects, and we need the switches to be already ranked because
- that's how the port direction is determined. */
- OSM_LOG(&p_ftree->p_osm->log, OSM_LOG_VERBOSE,
- "Populating CA & switch ports\n");
- if (__osm_ftree_fabric_populate_ports(p_ftree) != 0) {
- osm_log(&p_ftree->p_osm->log, OSM_LOG_SYS,
- "Fabric topology is not a fat-tree\n");
- status = -1;
- goto Exit;
- } else if (p_ftree->cn_num == 0) {
- osm_log(&p_ftree->p_osm->log, OSM_LOG_SYS,
- "Fabric has no valid compute nodes\n");
- status = -1;
- goto Exit;
- }
-
- /* Now that the CA ports have been created and CNs were marked,
- we can complete the fabric ranking - set leaf switches rank. */
- __osm_ftree_fabric_set_leaf_rank(p_ftree);
-
- if (__osm_ftree_fabric_get_rank(p_ftree) > FAT_TREE_MAX_RANK ||
- __osm_ftree_fabric_get_rank(p_ftree) < FAT_TREE_MIN_RANK) {
- osm_log(&p_ftree->p_osm->log, OSM_LOG_SYS,
- "Fabric rank is %u (should be between %u and %u)\n",
- __osm_ftree_fabric_get_rank(p_ftree), FAT_TREE_MIN_RANK,
- FAT_TREE_MAX_RANK);
- status = -1;
- goto Exit;
- }
-
- /* Mark all the switches in the fabric with rank equal to
- p_ftree->leaf_switch_rank and that are also connected to CNs.
- As a by-product, this function also runs basic topology
- validation - it checks that all the CNs are at the same rank. */
- if (__osm_ftree_fabric_mark_leaf_switches(p_ftree)) {
- osm_log(&p_ftree->p_osm->log, OSM_LOG_SYS,
- "Fabric topology is not a fat-tree\n");
- status = -1;
- goto Exit;
- }
-
- /* Assign index to all the switches in the fabric.
- This function also sorts leaf switch array by the switch index,
- sorts all the port arrays of the indexed switches by remote
- switch index, and creates switch-by-tuple table (sw_by_tuple_tbl) */
- __osm_ftree_fabric_make_indexing(p_ftree);
-
- /* Create leaf switch array sorted by index.
- This array contains switches with rank equal to p_ftree->leaf_switch_rank
- and that are also connected to CNs (REAL leafs), and it may contain
- switches at the same leaf rank w/o CNs, if this is the order of indexing.
- In any case, the first and the last switches in the array are REAL leafs. */
- if (__osm_ftree_fabric_create_leaf_switch_array(p_ftree)) {
- osm_log(&p_ftree->p_osm->log, OSM_LOG_SYS,
- "Fabric topology is not a fat-tree\n");
- status = -1;
- goto Exit;
- }
-
- /* calculate and set ftree.max_cn_per_leaf field */
- __osm_ftree_fabric_set_max_cn_per_leaf(p_ftree);
-
- /* print general info about fabric topology */
- __osm_ftree_fabric_dump_general_info(p_ftree);
-
- /* dump full tree topology */
- if (osm_log_is_active(&p_ftree->p_osm->log, OSM_LOG_DEBUG))
- __osm_ftree_fabric_dump(p_ftree);
-
- /* the fabric is required to be PURE fat-tree only if the root
- guid file hasn't been provided by user */
- if (!__osm_ftree_fabric_roots_provided(p_ftree) &&
- !__osm_ftree_fabric_validate_topology(p_ftree)) {
- osm_log(&p_ftree->p_osm->log, OSM_LOG_SYS,
- "Fabric topology is not a fat-tree\n");
- status = -1;
- goto Exit;
- }
-
- OSM_LOG(&p_ftree->p_osm->log, OSM_LOG_VERBOSE,
- "Max LID in switch LFTs: %u\n",
- p_ftree->lft_max_lid_ho);
-
-Exit:
- if (status != 0) {
- OSM_LOG(&p_ftree->p_osm->log, OSM_LOG_VERBOSE,
- "Clearing FatTree Fabric data structures\n");
- __osm_ftree_fabric_clear(p_ftree);
- } else
- p_ftree->fabric_built = TRUE;
-
- OSM_LOG(&p_ftree->p_osm->log, OSM_LOG_VERBOSE, "\n"
- " |--------------------------------------------------|\n"
- " |- Done constructing FatTree fabric (status = %d) -|\n"
- " |--------------------------------------------------|\n\n",
- status);
-
- OSM_LOG_EXIT(&p_ftree->p_osm->log);
- return status;
-} /* __osm_ftree_construct_fabric() */
-
-/***************************************************
- ***************************************************/
-
-static int __osm_ftree_do_routing(IN void *context)
-{
- ftree_fabric_t *p_ftree = context;
- int status = 0;
-
- OSM_LOG_ENTER(&p_ftree->p_osm->log);
-
- if (!p_ftree->fabric_built) {
- status = -1;
- goto Exit;
- }
-
- OSM_LOG(&p_ftree->p_osm->log, OSM_LOG_VERBOSE,
- "Starting FatTree routing\n");
-
- OSM_LOG(&p_ftree->p_osm->log, OSM_LOG_VERBOSE,
- "Filling switch forwarding tables for Compute Nodes\n");
- __osm_ftree_fabric_route_to_cns(p_ftree);
-
- OSM_LOG(&p_ftree->p_osm->log, OSM_LOG_VERBOSE,
- "Filling switch forwarding tables for non-CN targets\n");
- __osm_ftree_fabric_route_to_non_cns(p_ftree);
-
- OSM_LOG(&p_ftree->p_osm->log, OSM_LOG_VERBOSE,
- "Filling switch forwarding tables for switch-to-switch paths\n");
- __osm_ftree_fabric_route_to_switches(p_ftree);
-
- /* for each switch, set its fwd table */
- cl_qmap_apply_func(&p_ftree->sw_tbl, __osm_ftree_set_sw_fwd_table,
- (void *)p_ftree);
-
- /* write out hca ordering file */
- __osm_ftree_fabric_dump_hca_ordering(p_ftree);
-
- OSM_LOG(&p_ftree->p_osm->log, OSM_LOG_VERBOSE,
- "FatTree routing is done\n");
-
-Exit:
- OSM_LOG_EXIT(&p_ftree->p_osm->log);
- return status;
-}
-
-/***************************************************
- ***************************************************/
-
-static void __osm_ftree_delete(IN void *context)
-{
- if (!context)
- return;
- __osm_ftree_fabric_destroy((ftree_fabric_t *) context);
-}
-
-/***************************************************
- ***************************************************/
-
-int osm_ucast_ftree_setup(struct osm_routing_engine *r, osm_opensm_t * p_osm)
-{
- ftree_fabric_t *p_ftree = __osm_ftree_fabric_create();
- if (!p_ftree)
- return -1;
-
- p_ftree->p_osm = p_osm;
-
- r->context = (void *)p_ftree;
- r->build_lid_matrices = __osm_ftree_construct_fabric;
- r->ucast_build_fwd_tables = __osm_ftree_do_routing;
- r->delete = __osm_ftree_delete;
-
- return 0;
-}
diff --git a/contrib/ofed/management/opensm/opensm/osm_ucast_lash.c b/contrib/ofed/management/opensm/opensm/osm_ucast_lash.c
deleted file mode 100644
index f6795f6..0000000
--- a/contrib/ofed/management/opensm/opensm/osm_ucast_lash.c
+++ /dev/null
@@ -1,1356 +0,0 @@
-/*
- * Copyright (c) 2004-2008 Voltaire, Inc. All rights reserved.
- * Copyright (c) 2002-2008 Mellanox Technologies LTD. All rights reserved.
- * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
- * Copyright (c) 2007 Simula Research Laboratory. All rights reserved.
- * Copyright (c) 2007 Silicon Graphics Inc. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- */
-
-/*
- * Abstract:
- * Implementation of LASH algorithm Calculation functions
- */
-
-#if HAVE_CONFIG_H
-# include <config.h>
-#endif /* HAVE_CONFIG_H */
-
-#include <stdlib.h>
-#include <stdio.h>
-#include <errno.h>
-#include <complib/cl_debug.h>
-#include <complib/cl_qmap.h>
-#include <opensm/osm_switch.h>
-#include <opensm/osm_opensm.h>
-#include <opensm/osm_log.h>
-
-/* //////////////////////////// */
-/* Local types */
-/* //////////////////////////// */
-
-enum {
- UNQUEUED,
- Q_MEMBER,
- MST_MEMBER,
- MAX_INT = 9999,
- NONE = MAX_INT
-};
-
-typedef struct _cdg_vertex {
- int num_dependencies;
- struct _cdg_vertex **dependency;
- int from;
- int to;
- int seen;
- int temp;
- int visiting_number;
- struct _cdg_vertex *next;
- int num_temp_depend;
- int num_using_vertex;
- int *num_using_this_depend;
-} cdg_vertex_t;
-
-typedef struct _reachable_dest {
- int switch_id;
- struct _reachable_dest *next;
-} reachable_dest_t;
-
-typedef struct _switch {
- osm_switch_t *p_sw;
- int *dij_channels;
- int id;
- int used_channels;
- int q_state;
- struct routing_table {
- unsigned out_link;
- unsigned lane;
- } *routing_table;
- unsigned int num_connections;
- int *virtual_physical_port_table;
- int *phys_connections;
-} switch_t;
-
-typedef struct _lash {
- osm_opensm_t *p_osm;
- int num_switches;
- uint8_t vl_min;
- int balance_limit;
- switch_t **switches;
- cdg_vertex_t ****cdg_vertex_matrix;
- int *num_mst_in_lane;
- int ***virtual_location;
-} lash_t;
-
-static cdg_vertex_t *create_cdg_vertex(unsigned num_switches)
-{
- cdg_vertex_t *cdg_vertex = (cdg_vertex_t *) malloc(sizeof(cdg_vertex_t));
-
- cdg_vertex->dependency = malloc((num_switches - 1) * sizeof(cdg_vertex_t *));
- cdg_vertex->num_using_this_depend = (int *)malloc((num_switches - 1) * sizeof(int));
- return cdg_vertex;
-}
-
-static void connect_switches(lash_t * p_lash, int sw1, int sw2, int phy_port_1)
-{
- osm_log_t *p_log = &p_lash->p_osm->log;
- unsigned num = p_lash->switches[sw1]->num_connections;
-
- p_lash->switches[sw1]->phys_connections[num] = sw2;
- p_lash->switches[sw1]->virtual_physical_port_table[num] = phy_port_1;
- p_lash->switches[sw1]->num_connections++;
-
- OSM_LOG(p_log, OSM_LOG_VERBOSE,
- "LASH connect: %d, %d, %d\n", sw1, sw2,
- phy_port_1);
-
-}
-
-static osm_switch_t *get_osm_switch_from_port(osm_port_t * port)
-{
- osm_physp_t *p = port->p_physp;
- if (p->p_node->sw)
- return p->p_node->sw;
- else if (p->p_remote_physp->p_node->sw)
- return p->p_remote_physp->p_node->sw;
- return NULL;
-}
-
-#if 0
-static int randint(int high)
-{
- int r;
-
- if (high == 0)
- return 0;
- r = rand();
- high++;
- return (r % high);
-}
-#endif
-
-static int cycle_exists(cdg_vertex_t * start, cdg_vertex_t * current,
- cdg_vertex_t * prev, int visit_num)
-{
- cdg_vertex_t *h;
- int i, new_visit_num;
- int cycle_found = 0;
-
- if (current != NULL && current->visiting_number > 0) {
- if (visit_num > current->visiting_number && current->seen == 0) {
- h = start;
- cycle_found = 1;
- }
- } else {
- if (current == NULL) {
- current = start;
- CL_ASSERT(prev == NULL);
- }
-
- current->visiting_number = visit_num;
-
- if (prev != NULL) {
- prev->next = current;
- CL_ASSERT(prev->to == current->from);
- CL_ASSERT(prev->visiting_number > 0);
- }
-
- new_visit_num = visit_num + 1;
-
- for (i = 0; i < current->num_dependencies; i++) {
- cycle_found =
- cycle_exists(start, current->dependency[i], current,
- new_visit_num);
- if (cycle_found == 1)
- i = current->num_dependencies;
- }
-
- current->seen = 1;
- if (prev != NULL)
- prev->next = NULL;
- }
-
- return cycle_found;
-}
-
-static void remove_semipermanent_depend_for_sp(lash_t * p_lash, int sw,
- int dest_switch, int lane)
-{
- switch_t **switches = p_lash->switches;
- cdg_vertex_t ****cdg_vertex_matrix = p_lash->cdg_vertex_matrix;
- int i_next_switch, output_link, i, next_link, i_next_next_switch,
- depend = 0;
- cdg_vertex_t *v;
- int found;
-
- output_link = switches[sw]->routing_table[dest_switch].out_link;
- i_next_switch = switches[sw]->phys_connections[output_link];
-
- while (sw != dest_switch) {
- v = cdg_vertex_matrix[lane][sw][i_next_switch];
- CL_ASSERT(v != NULL);
-
- if (v->num_using_vertex == 1) {
-
- cdg_vertex_matrix[lane][sw][i_next_switch] = NULL;
-
- free(v);
- } else {
- v->num_using_vertex--;
- if (i_next_switch != dest_switch) {
- next_link =
- switches[i_next_switch]->routing_table[dest_switch].out_link;
- i_next_next_switch =
- switches[i_next_switch]->phys_connections[next_link];
- found = 0;
-
- for (i = 0; i < v->num_dependencies; i++)
- if (v->dependency[i] ==
- cdg_vertex_matrix[lane][i_next_switch]
- [i_next_next_switch]) {
- found = 1;
- depend = i;
- }
-
- CL_ASSERT(found);
-
- if (v->num_using_this_depend[depend] == 1) {
- for (i = depend;
- i < v->num_dependencies - 1; i++) {
- v->dependency[i] =
- v->dependency[i + 1];
- v->num_using_this_depend[i] =
- v->num_using_this_depend[i +
- 1];
- }
-
- v->num_dependencies--;
- } else
- v->num_using_this_depend[depend]--;
- }
- }
-
- sw = i_next_switch;
- output_link = switches[sw]->routing_table[dest_switch].out_link;
-
- if (sw != dest_switch)
- i_next_switch =
- switches[sw]->phys_connections[output_link];
- }
-}
-
-inline static void enqueue(cl_list_t * bfsq, switch_t * sw)
-{
- CL_ASSERT(sw->q_state == UNQUEUED);
- sw->q_state = Q_MEMBER;
- cl_list_insert_tail(bfsq, sw);
-}
-
-inline static void dequeue(cl_list_t * bfsq, switch_t ** sw)
-{
- *sw = (switch_t *) cl_list_remove_head(bfsq);
- CL_ASSERT((*sw)->q_state == Q_MEMBER);
- (*sw)->q_state = MST_MEMBER;
-}
-
-static int get_phys_connection(switch_t *sw, int switch_to)
-{
- unsigned int i = 0;
-
- for (i = 0; i < sw->num_connections; i++)
- if (sw->phys_connections[i] == switch_to)
- return i;
- return i;
-}
-
-static void shortest_path(lash_t * p_lash, int ir)
-{
- switch_t **switches = p_lash->switches, *sw, *swi;
- unsigned int i;
- cl_list_t bfsq;
-
- cl_list_construct(&bfsq);
- cl_list_init(&bfsq, 20);
-
- enqueue(&bfsq, switches[ir]);
-
- while (!cl_is_list_empty(&bfsq)) {
- dequeue(&bfsq, &sw);
- for (i = 0; i < sw->num_connections; i++) {
- swi = switches[sw->phys_connections[i]];
- if (swi->q_state == UNQUEUED) {
- enqueue(&bfsq, swi);
- sw->dij_channels[sw->used_channels++] = swi->id;
- }
- }
- }
-
- cl_list_destroy(&bfsq);
-}
-
-static void generate_routing_func_for_mst(lash_t * p_lash, int sw_id,
- reachable_dest_t ** destinations)
-{
- int i, next_switch;
- switch_t *sw = p_lash->switches[sw_id];
- int num_channels = sw->used_channels;
- reachable_dest_t *dest, *i_dest, *concat_dest = NULL, *prev;
-
- for (i = 0; i < num_channels; i++) {
- next_switch = sw->dij_channels[i];
- generate_routing_func_for_mst(p_lash, next_switch, &dest);
-
- i_dest = dest;
- prev = i_dest;
-
- while (i_dest != NULL) {
- if (sw->routing_table[i_dest->switch_id].out_link ==
- NONE) {
- sw->routing_table[i_dest->switch_id].out_link =
- get_phys_connection(sw, next_switch);
- }
-
- prev = i_dest;
- i_dest = i_dest->next;
- }
-
- CL_ASSERT(prev->next == NULL);
- prev->next = concat_dest;
- concat_dest = dest;
- }
-
- i_dest = (reachable_dest_t *) malloc(sizeof(reachable_dest_t));
- i_dest->switch_id = sw->id;
- i_dest->next = concat_dest;
- *destinations = i_dest;
-}
-
-static void generate_cdg_for_sp(lash_t * p_lash, int sw, int dest_switch,
- int lane)
-{
- unsigned num_switches = p_lash->num_switches;
- switch_t **switches = p_lash->switches;
- cdg_vertex_t ****cdg_vertex_matrix = p_lash->cdg_vertex_matrix;
- int next_switch, output_link, j, exists;
- cdg_vertex_t *v, *prev = NULL;
-
- output_link = switches[sw]->routing_table[dest_switch].out_link;
- next_switch = switches[sw]->phys_connections[output_link];
-
- while (sw != dest_switch) {
-
- if (cdg_vertex_matrix[lane][sw][next_switch] == NULL) {
- unsigned i;
- v = create_cdg_vertex(num_switches);
-
- for (i = 0; i < num_switches - 1; i++) {
- v->dependency[i] = NULL;
- v->num_using_this_depend[i] = 0;
- }
-
- v->num_using_vertex = 0;
- v->num_dependencies = 0;
- v->from = sw;
- v->to = next_switch;
- v->seen = 0;
- v->visiting_number = 0;
- v->next = NULL;
- v->temp = 1;
- v->num_temp_depend = 0;
-
- cdg_vertex_matrix[lane][sw][next_switch] = v;
- } else
- v = cdg_vertex_matrix[lane][sw][next_switch];
-
- v->num_using_vertex++;
-
- if (prev != NULL) {
- exists = 0;
-
- for (j = 0; j < prev->num_dependencies; j++)
- if (prev->dependency[j] == v) {
- exists = 1;
- prev->num_using_this_depend[j]++;
- }
-
- if (exists == 0) {
- prev->dependency[prev->num_dependencies] = v;
- prev->num_using_this_depend[prev->num_dependencies]++;
- prev->num_dependencies++;
-
- CL_ASSERT(prev->num_dependencies < (int)num_switches);
-
- if (prev->temp == 0)
- prev->num_temp_depend++;
-
- }
- }
-
- sw = next_switch;
- output_link = switches[sw]->routing_table[dest_switch].out_link;
-
- if (sw != dest_switch) {
- CL_ASSERT(output_link != NONE);
- next_switch = switches[sw]->phys_connections[output_link];
- }
-
- prev = v;
- }
-}
-
-static void set_temp_depend_to_permanent_for_sp(lash_t * p_lash, int sw,
- int dest_switch, int lane)
-{
- switch_t **switches = p_lash->switches;
- cdg_vertex_t ****cdg_vertex_matrix = p_lash->cdg_vertex_matrix;
- int next_switch, output_link;
- cdg_vertex_t *v;
-
- output_link = switches[sw]->routing_table[dest_switch].out_link;
- next_switch = switches[sw]->phys_connections[output_link];
-
- while (sw != dest_switch) {
- v = cdg_vertex_matrix[lane][sw][next_switch];
- CL_ASSERT(v != NULL);
-
- if (v->temp == 1)
- v->temp = 0;
- else
- v->num_temp_depend = 0;
-
- sw = next_switch;
- output_link = switches[sw]->routing_table[dest_switch].out_link;
-
- if (sw != dest_switch)
- next_switch =
- switches[sw]->phys_connections[output_link];
- }
-
-}
-
-static void remove_temp_depend_for_sp(lash_t * p_lash, int sw, int dest_switch,
- int lane)
-{
- switch_t **switches = p_lash->switches;
- cdg_vertex_t ****cdg_vertex_matrix = p_lash->cdg_vertex_matrix;
- int next_switch, output_link, i;
- cdg_vertex_t *v;
-
- output_link = switches[sw]->routing_table[dest_switch].out_link;
- next_switch = switches[sw]->phys_connections[output_link];
-
- while (sw != dest_switch) {
- v = cdg_vertex_matrix[lane][sw][next_switch];
- CL_ASSERT(v != NULL);
-
- if (v->temp == 1) {
- cdg_vertex_matrix[lane][sw][next_switch] = NULL;
- free(v);
- } else {
- CL_ASSERT(v->num_temp_depend <= v->num_dependencies);
- v->num_dependencies =
- v->num_dependencies - v->num_temp_depend;
- v->num_temp_depend = 0;
- v->num_using_vertex--;
-
- for (i = v->num_dependencies;
- i < p_lash->num_switches - 1; i++)
- v->num_using_this_depend[i] = 0;
- }
-
- sw = next_switch;
- output_link = switches[sw]->routing_table[dest_switch].out_link;
-
- if (sw != dest_switch)
- next_switch =
- switches[sw]->phys_connections[output_link];
-
- }
-}
-
-static void balance_virtual_lanes(lash_t * p_lash, unsigned lanes_needed)
-{
- unsigned num_switches = p_lash->num_switches;
- cdg_vertex_t ****cdg_vertex_matrix = p_lash->cdg_vertex_matrix;
- int *num_mst_in_lane = p_lash->num_mst_in_lane;
- int ***virtual_location = p_lash->virtual_location;
- int min_filled_lane, max_filled_lane, medium_filled_lane, trials;
- int old_min_filled_lane, old_max_filled_lane, new_num_min_lane,
- new_num_max_lane;
- unsigned int i, j;
- int src, dest, start, next_switch, output_link;
- int next_switch2, output_link2;
- int stop = 0, cycle_found;
- int cycle_found2;
-
- max_filled_lane = 0;
- min_filled_lane = lanes_needed - 1;
-
- if (max_filled_lane > 1)
- medium_filled_lane = max_filled_lane - 1;
-
- trials = num_mst_in_lane[max_filled_lane];
- if (lanes_needed == 1)
- stop = 1;
-
- while (stop == 0) {
- src = abs(rand()) % (num_switches);
- dest = abs(rand()) % (num_switches);
-
- while (virtual_location[src][dest][max_filled_lane] != 1) {
- start = dest;
- if (dest == num_switches - 1)
- dest = 0;
- else
- dest++;
-
- while (dest != start
- && virtual_location[src][dest][max_filled_lane]
- != 1) {
- if (dest == num_switches - 1)
- dest = 0;
- else
- dest++;
- }
-
- if (virtual_location[src][dest][max_filled_lane] != 1) {
- if (src == num_switches - 1)
- src = 0;
- else
- src++;
- }
- }
-
- generate_cdg_for_sp(p_lash, src, dest, min_filled_lane);
- generate_cdg_for_sp(p_lash, dest, src, min_filled_lane);
-
- output_link = p_lash->switches[src]->routing_table[dest].out_link;
- next_switch = p_lash->switches[src]->phys_connections[output_link];
-
- output_link2 = p_lash->switches[dest]->routing_table[src].out_link;
- next_switch2 = p_lash->switches[dest]->phys_connections[output_link2];
-
- CL_ASSERT(cdg_vertex_matrix[min_filled_lane][src][next_switch] != NULL);
- CL_ASSERT(cdg_vertex_matrix[min_filled_lane][dest][next_switch2] != NULL);
-
- cycle_found =
- cycle_exists(cdg_vertex_matrix[min_filled_lane][src][next_switch], NULL, NULL,
- 1);
- cycle_found2 =
- cycle_exists(cdg_vertex_matrix[min_filled_lane][dest][next_switch2], NULL, NULL,
- 1);
-
- for (i = 0; i < num_switches; i++)
- for (j = 0; j < num_switches; j++)
- if (cdg_vertex_matrix[min_filled_lane][i][j] != NULL) {
- cdg_vertex_matrix[min_filled_lane][i][j]->visiting_number =
- 0;
- cdg_vertex_matrix[min_filled_lane][i][j]->seen = 0;
- }
-
- if (cycle_found == 1 || cycle_found2 == 1) {
- remove_temp_depend_for_sp(p_lash, src, dest, min_filled_lane);
- remove_temp_depend_for_sp(p_lash, dest, src, min_filled_lane);
-
- virtual_location[src][dest][max_filled_lane] = 2;
- virtual_location[dest][src][max_filled_lane] = 2;
- trials--;
- trials--;
- } else {
- set_temp_depend_to_permanent_for_sp(p_lash, src, dest, min_filled_lane);
- set_temp_depend_to_permanent_for_sp(p_lash, dest, src, min_filled_lane);
-
- num_mst_in_lane[max_filled_lane]--;
- num_mst_in_lane[max_filled_lane]--;
- num_mst_in_lane[min_filled_lane]++;
- num_mst_in_lane[min_filled_lane]++;
-
- remove_semipermanent_depend_for_sp(p_lash, src, dest, max_filled_lane);
- remove_semipermanent_depend_for_sp(p_lash, dest, src, max_filled_lane);
- virtual_location[src][dest][max_filled_lane] = 0;
- virtual_location[dest][src][max_filled_lane] = 0;
- virtual_location[src][dest][min_filled_lane] = 1;
- virtual_location[dest][src][min_filled_lane] = 1;
- p_lash->switches[src]->routing_table[dest].lane = min_filled_lane;
- p_lash->switches[dest]->routing_table[src].lane = min_filled_lane;
- }
-
- if (trials == 0)
- stop = 1;
- else {
- if (num_mst_in_lane[max_filled_lane] - num_mst_in_lane[min_filled_lane] <
- p_lash->balance_limit)
- stop = 1;
- }
-
- old_min_filled_lane = min_filled_lane;
- old_max_filled_lane = max_filled_lane;
-
- new_num_min_lane = MAX_INT;
- new_num_max_lane = 0;
-
- for (i = 0; i < lanes_needed; i++) {
-
- if (num_mst_in_lane[i] < new_num_min_lane) {
- new_num_min_lane = num_mst_in_lane[i];
- min_filled_lane = i;
- }
-
- if (num_mst_in_lane[i] > new_num_max_lane) {
- new_num_max_lane = num_mst_in_lane[i];
- max_filled_lane = i;
- }
- }
-
- if (old_min_filled_lane != min_filled_lane) {
- trials = num_mst_in_lane[max_filled_lane];
- for (i = 0; i < num_switches; i++)
- for (j = 0; j < num_switches; j++)
- if (virtual_location[i][j][max_filled_lane] == 2)
- virtual_location[i][j][max_filled_lane] = 1;
- }
-
- if (old_max_filled_lane != max_filled_lane) {
- trials = num_mst_in_lane[max_filled_lane];
- for (i = 0; i < num_switches; i++)
- for (j = 0; j < num_switches; j++)
- if (virtual_location[i][j][old_max_filled_lane] == 2)
- virtual_location[i][j][old_max_filled_lane] = 1;
- }
- }
-}
-
-static switch_t *switch_create(lash_t * p_lash, unsigned id, osm_switch_t * p_sw)
-{
- unsigned num_switches = p_lash->num_switches;
- unsigned num_ports = p_sw->num_ports;
- switch_t *sw;
- unsigned int i;
-
- sw = malloc(sizeof(*sw));
- if (!sw)
- return NULL;
-
- memset(sw, 0, sizeof(*sw));
-
- sw->id = id;
- sw->dij_channels = malloc(num_ports * sizeof(int));
- if (!sw->dij_channels) {
- free(sw);
- return NULL;
- }
-
- sw->virtual_physical_port_table = malloc(num_ports * sizeof(int));
- if (!sw->virtual_physical_port_table) {
- free(sw->dij_channels);
- free(sw);
- return NULL;
- }
-
- sw->phys_connections = malloc(num_ports * sizeof(int));
- if (!sw->phys_connections) {
- free(sw->virtual_physical_port_table);
- free(sw->dij_channels);
- free(sw);
- return NULL;
- }
-
- sw->routing_table = malloc(num_switches * sizeof(sw->routing_table[0]));
- if (!sw->routing_table) {
- free(sw->phys_connections);
- free(sw->virtual_physical_port_table);
- free(sw->dij_channels);
- free(sw);
- return NULL;
- }
-
- for (i = 0; i < num_switches; i++) {
- sw->routing_table[i].out_link = NONE;
- sw->routing_table[i].lane = NONE;
- }
-
- for (i = 0; i < num_ports; i++) {
- sw->virtual_physical_port_table[i] = -1;
- sw->phys_connections[i] = NONE;
- }
-
- sw->p_sw = p_sw;
- if (p_sw)
- p_sw->priv = sw;
-
- return sw;
-}
-
-static void switch_delete(switch_t * sw)
-{
- if (sw->dij_channels)
- free(sw->dij_channels);
- if (sw->virtual_physical_port_table)
- free(sw->virtual_physical_port_table);
- if (sw->phys_connections)
- free(sw->phys_connections);
- if (sw->routing_table)
- free(sw->routing_table);
- free(sw);
-}
-
-static void free_lash_structures(lash_t * p_lash)
-{
- unsigned int i, j, k;
- unsigned num_switches = p_lash->num_switches;
- osm_log_t *p_log = &p_lash->p_osm->log;
-
- OSM_LOG_ENTER(p_log);
-
- // free cdg_vertex_matrix
- for (i = 0; i < p_lash->vl_min; i++) {
- for (j = 0; j < num_switches; j++) {
- for (k = 0; k < num_switches; k++) {
- if (p_lash->cdg_vertex_matrix[i][j][k]) {
-
- if (p_lash->cdg_vertex_matrix[i][j][k]->dependency)
- free(p_lash->cdg_vertex_matrix[i][j][k]->
- dependency);
-
- if (p_lash->cdg_vertex_matrix[i][j][k]->
- num_using_this_depend)
- free(p_lash->cdg_vertex_matrix[i][j][k]->
- num_using_this_depend);
-
- free(p_lash->cdg_vertex_matrix[i][j][k]);
- }
- }
- if (p_lash->cdg_vertex_matrix[i][j])
- free(p_lash->cdg_vertex_matrix[i][j]);
- }
- if (p_lash->cdg_vertex_matrix[i])
- free(p_lash->cdg_vertex_matrix[i]);
- }
-
- if (p_lash->cdg_vertex_matrix)
- free(p_lash->cdg_vertex_matrix);
-
- // free virtual_location
- for (i = 0; i < num_switches; i++) {
- for (j = 0; j < num_switches; j++) {
- if (p_lash->virtual_location[i][j])
- free(p_lash->virtual_location[i][j]);
- }
- if (p_lash->virtual_location[i])
- free(p_lash->virtual_location[i]);
- }
- if (p_lash->virtual_location)
- free(p_lash->virtual_location);
-
- if (p_lash->num_mst_in_lane)
- free(p_lash->num_mst_in_lane);
-
- OSM_LOG_EXIT(p_log);
-}
-
-static int init_lash_structures(lash_t * p_lash)
-{
- unsigned vl_min = p_lash->vl_min;
- unsigned num_switches = p_lash->num_switches;
- osm_log_t *p_log = &p_lash->p_osm->log;
- int status = 0;
- unsigned int i, j, k;
-
- OSM_LOG_ENTER(p_log);
-
- // initialise cdg_vertex_matrix[num_switches][num_switches][num_switches]
- p_lash->cdg_vertex_matrix =
- (cdg_vertex_t ****) malloc(vl_min * sizeof(cdg_vertex_t ****));
- for (i = 0; i < vl_min; i++) {
- p_lash->cdg_vertex_matrix[i] =
- (cdg_vertex_t ***) malloc(num_switches *
- sizeof(cdg_vertex_t ***));
-
- if (p_lash->cdg_vertex_matrix[i] == NULL)
- goto Exit_Mem_Error;
- }
-
- for (i = 0; i < vl_min; i++) {
- for (j = 0; j < num_switches; j++) {
- p_lash->cdg_vertex_matrix[i][j] =
- (cdg_vertex_t **) malloc(num_switches *
- sizeof(cdg_vertex_t **));
- if (p_lash->cdg_vertex_matrix[i][j] == NULL)
- goto Exit_Mem_Error;
-
- for (k = 0; k < num_switches; k++) {
- p_lash->cdg_vertex_matrix[i][j][k] = NULL;
- }
- }
- }
-
- // initialise virtual_location[num_switches][num_switches][num_layers],
- // default value = 0
- p_lash->virtual_location =
- (int ***)malloc(num_switches * sizeof(int ***));
- if (p_lash->virtual_location == NULL)
- goto Exit_Mem_Error;
-
- for (i = 0; i < num_switches; i++) {
- p_lash->virtual_location[i] =
- (int **)malloc(num_switches * sizeof(int **));
- if (p_lash->virtual_location[i] == NULL)
- goto Exit_Mem_Error;
- }
-
- for (i = 0; i < num_switches; i++) {
- for (j = 0; j < num_switches; j++) {
- p_lash->virtual_location[i][j] =
- (int *)malloc(vl_min * sizeof(int *));
- if (p_lash->virtual_location[i][j] == NULL)
- goto Exit_Mem_Error;
- for (k = 0; k < vl_min; k++) {
- p_lash->virtual_location[i][j][k] = 0;
- }
- }
- }
-
- // initialise num_mst_in_lane[num_switches], default 0
- p_lash->num_mst_in_lane = (int *)malloc(num_switches * sizeof(int));
- if (p_lash->num_mst_in_lane == NULL)
- goto Exit_Mem_Error;
- memset(p_lash->num_mst_in_lane, 0,
- num_switches * sizeof(p_lash->num_mst_in_lane[0]));
-
- goto Exit;
-
-Exit_Mem_Error:
- status = -1;
- OSM_LOG(p_log, OSM_LOG_ERROR, "ERR 4D01: "
- "Could not allocate required memory for LASH errno %d, errno %d for lack of memory\n",
- errno, ENOMEM);
-
-Exit:
- OSM_LOG_EXIT(p_log);
- return status;
-}
-
-static int lash_core(lash_t * p_lash)
-{
- osm_log_t *p_log = &p_lash->p_osm->log;
- unsigned num_switches = p_lash->num_switches;
- switch_t **switches = p_lash->switches;
- unsigned lanes_needed = 1;
- unsigned int i, j, k, dest_switch = 0;
- reachable_dest_t *dests, *idest;
- int cycle_found = 0;
- unsigned v_lane;
- int stop = 0, output_link, i_next_switch;
- int output_link2, i_next_switch2;
- int cycle_found2 = 0;
- int status = 0;
- int *switch_bitmap; /* Bitmap to check if we have processed this pair */
-
- OSM_LOG_ENTER(p_log);
-
- for (i = 0; i < num_switches; i++) {
-
- shortest_path(p_lash, i);
- generate_routing_func_for_mst(p_lash, i, &dests);
-
- idest = dests;
- while (idest != NULL) {
- dests = dests->next;
- free(idest);
- idest = dests;
- }
-
- for (j = 0; j < num_switches; j++) {
- switches[j]->used_channels = 0;
- switches[j]->q_state = UNQUEUED;
- }
- }
-
- switch_bitmap = malloc(num_switches * num_switches * sizeof(int));
- if (!switch_bitmap) {
- OSM_LOG(p_log, OSM_LOG_ERROR, "ERR 4D04: "
- "Failed allocating switch_bitmap - out of memory\n");
- goto Exit;
- }
- memset(switch_bitmap, 0, num_switches * num_switches * sizeof(int));
-
- for (i = 0; i < num_switches; i++) {
- for (dest_switch = 0; dest_switch < num_switches; dest_switch++)
- if (dest_switch != i && switch_bitmap[i * num_switches + dest_switch] == 0) {
- v_lane = 0;
- stop = 0;
- while (v_lane < lanes_needed && stop == 0) {
- generate_cdg_for_sp(p_lash, i, dest_switch, v_lane);
- generate_cdg_for_sp(p_lash, dest_switch, i, v_lane);
-
- output_link =
- switches[i]->routing_table[dest_switch].out_link;
- output_link2 =
- switches[dest_switch]->routing_table[i].out_link;
-
- i_next_switch = switches[i]->phys_connections[output_link];
- i_next_switch2 =
- switches[dest_switch]->phys_connections[output_link2];
-
- CL_ASSERT(p_lash->
- cdg_vertex_matrix[v_lane][i][i_next_switch] !=
- NULL);
- CL_ASSERT(p_lash->
- cdg_vertex_matrix[v_lane][dest_switch]
- [i_next_switch2] != NULL);
-
- cycle_found =
- cycle_exists(p_lash->
- cdg_vertex_matrix[v_lane][i]
- [i_next_switch], NULL, NULL, 1);
- cycle_found2 =
- cycle_exists(p_lash->
- cdg_vertex_matrix[v_lane][dest_switch]
- [i_next_switch2], NULL, NULL, 1);
-
- for (j = 0; j < num_switches; j++)
- for (k = 0; k < num_switches; k++)
- if (p_lash->
- cdg_vertex_matrix[v_lane][j][k] !=
- NULL) {
- p_lash->
- cdg_vertex_matrix[v_lane][j]
- [k]->visiting_number = 0;
- p_lash->
- cdg_vertex_matrix[v_lane][j]
- [k]->seen = 0;
- }
-
- if (cycle_found == 1 || cycle_found2 == 1) {
- remove_temp_depend_for_sp(p_lash, i, dest_switch,
- v_lane);
- remove_temp_depend_for_sp(p_lash, dest_switch, i,
- v_lane);
- v_lane++;
- } else {
- set_temp_depend_to_permanent_for_sp(p_lash, i,
- dest_switch,
- v_lane);
- set_temp_depend_to_permanent_for_sp(p_lash,
- dest_switch, i,
- v_lane);
- stop = 1;
- p_lash->num_mst_in_lane[v_lane]++;
- p_lash->num_mst_in_lane[v_lane]++;
- }
- }
-
- switches[i]->routing_table[dest_switch].lane = v_lane;
- switches[dest_switch]->routing_table[i].lane = v_lane;
-
- if (cycle_found == 1 || cycle_found2 == 1) {
- if (++lanes_needed > p_lash->vl_min)
- goto Error_Not_Enough_Lanes;
-
- generate_cdg_for_sp(p_lash, i, dest_switch, v_lane);
- generate_cdg_for_sp(p_lash, dest_switch, i, v_lane);
-
- set_temp_depend_to_permanent_for_sp(p_lash, i, dest_switch,
- v_lane);
- set_temp_depend_to_permanent_for_sp(p_lash, dest_switch, i,
- v_lane);
-
- p_lash->num_mst_in_lane[v_lane]++;
- p_lash->num_mst_in_lane[v_lane]++;
- }
- p_lash->virtual_location[i][dest_switch][v_lane] = 1;
- p_lash->virtual_location[dest_switch][i][v_lane] = 1;
-
- switch_bitmap[i * num_switches + dest_switch] = 1;
- switch_bitmap[dest_switch * num_switches + i] = 1;
- }
- }
-
- OSM_LOG(p_log, OSM_LOG_INFO,
- "Lanes needed: %d, Balancing\n", lanes_needed);
-
- for (i = 0; i < lanes_needed; i++) {
- OSM_LOG(p_log, OSM_LOG_INFO, "Lanes in layer %d: %d\n",
- i, p_lash->num_mst_in_lane[i]);
- }
-
- balance_virtual_lanes(p_lash, lanes_needed);
-
- for (i = 0; i < lanes_needed; i++) {
- OSM_LOG(p_log, OSM_LOG_INFO, "Lanes in layer %d: %d\n",
- i, p_lash->num_mst_in_lane[i]);
- }
-
- goto Exit;
-
-Error_Not_Enough_Lanes:
- status = -1;
- OSM_LOG(p_log, OSM_LOG_ERROR, "ERR 4D02: "
- "Lane requirements (%d) exceed available lanes (%d)\n",
- p_lash->vl_min, lanes_needed);
-Exit:
- if (switch_bitmap)
- free(switch_bitmap);
- OSM_LOG_EXIT(p_log);
- return status;
-}
-
-static unsigned get_lash_id(osm_switch_t * p_sw)
-{
- return ((switch_t *) p_sw->priv)->id;
-}
-
-static void populate_fwd_tbls(lash_t * p_lash)
-{
- osm_log_t *p_log = &p_lash->p_osm->log;
- osm_subn_t *p_subn = &p_lash->p_osm->subn;
- osm_opensm_t *p_osm = p_lash->p_osm;
- osm_switch_t *p_sw, *p_next_sw, *p_dst_sw;
- osm_port_t *port;
- uint16_t max_lid_ho, lid;
-
- OSM_LOG_ENTER(p_log);
-
- p_next_sw = (osm_switch_t *) cl_qmap_head(&p_subn->sw_guid_tbl);
-
- // Go through each swtich individually
- while (p_next_sw != (osm_switch_t *) cl_qmap_end(&p_subn->sw_guid_tbl)) {
- uint64_t current_guid;
- switch_t *sw;
- p_sw = p_next_sw;
- p_next_sw = (osm_switch_t *) cl_qmap_next(&p_sw->map_item);
-
- max_lid_ho = p_sw->max_lid_ho;
- current_guid = p_sw->p_node->node_info.port_guid;
- sw = p_sw->priv;
-
- memset(p_sw->new_lft, OSM_NO_PATH, IB_LID_UCAST_END_HO + 1);
-
- for (lid = 1; lid <= max_lid_ho; lid++) {
- port = cl_ptr_vector_get(&p_subn->port_lid_tbl, lid);
- if (!port)
- continue;
-
- p_dst_sw = get_osm_switch_from_port(port);
- if (p_dst_sw == p_sw) {
- uint8_t egress_port = port->p_node->sw ? 0 :
- port->p_physp->p_remote_physp->port_num;
- p_sw->new_lft[lid] = egress_port;
- OSM_LOG(p_log, OSM_LOG_VERBOSE,
- "LASH fwd MY SRC SRC GUID 0x%016" PRIx64
- " src lash id (%d), src lid no (%u) src lash port (%d) "
- "DST GUID 0x%016" PRIx64
- " src lash id (%d), src lash port (%d)\n",
- cl_ntoh64(current_guid), -1, lid,
- egress_port, cl_ntoh64(current_guid),
- -1, egress_port);
- } else if (p_dst_sw) {
- unsigned dst_lash_switch_id =
- get_lash_id(p_dst_sw);
- uint8_t lash_egress_port =
- (uint8_t) sw->
- routing_table[dst_lash_switch_id].out_link;
- uint8_t physical_egress_port =
- (uint8_t) sw->
- virtual_physical_port_table
- [lash_egress_port];
-
- p_sw->new_lft[lid] = physical_egress_port;
- OSM_LOG(p_log, OSM_LOG_VERBOSE,
- "LASH fwd SRC GUID 0x%016" PRIx64
- " src lash id (%d), "
- "src lid no (%u) src lash port (%d) "
- "DST GUID 0x%016" PRIx64
- " src lash id (%d), src lash port (%d)\n",
- cl_ntoh64(current_guid), sw->id, lid,
- lash_egress_port,
- cl_ntoh64(p_dst_sw->p_node->node_info.
- port_guid),
- dst_lash_switch_id,
- physical_egress_port);
- }
- } // for
- osm_ucast_mgr_set_fwd_table(&p_osm->sm.ucast_mgr, p_sw);
- }
- OSM_LOG_EXIT(p_log);
-}
-
-static void osm_lash_process_switch(lash_t * p_lash, osm_switch_t * p_sw)
-{
- osm_log_t *p_log = &p_lash->p_osm->log;
- int i, port_count;
- osm_physp_t *p_current_physp, *p_remote_physp;
- unsigned switch_a_lash_id, switch_b_lash_id;
-
- OSM_LOG_ENTER(p_log);
-
- switch_a_lash_id = get_lash_id(p_sw);
- port_count = osm_node_get_num_physp(p_sw->p_node);
-
- // starting at port 1, ignoring management port on switch
- for (i = 1; i < port_count; i++) {
-
- p_current_physp = osm_node_get_physp_ptr(p_sw->p_node, i);
- if (p_current_physp) {
- p_remote_physp = p_current_physp->p_remote_physp;
- if (p_remote_physp && p_remote_physp->p_node->sw) {
- int physical_port_a_num =
- osm_physp_get_port_num(p_current_physp);
- int physical_port_b_num =
- osm_physp_get_port_num(p_remote_physp);
- switch_b_lash_id =
- get_lash_id(p_remote_physp->p_node->sw);
-
- connect_switches(p_lash, switch_a_lash_id,
- switch_b_lash_id,
- physical_port_a_num);
- OSM_LOG(p_log, OSM_LOG_VERBOSE,
- "LASH SUCCESS connected G 0x%016" PRIx64
- " , lash_id(%u), P(%u) " " to G 0x%016"
- PRIx64 " , lash_id(%u) , P(%u)\n",
- cl_ntoh64(osm_physp_get_port_guid
- (p_current_physp)),
- switch_a_lash_id, physical_port_a_num,
- cl_ntoh64(osm_physp_get_port_guid
- (p_remote_physp)),
- switch_b_lash_id, physical_port_b_num);
- }
- }
- }
-
- OSM_LOG_EXIT(p_log);
-}
-
-static void lash_cleanup(lash_t * p_lash)
-{
- osm_subn_t *p_subn = &p_lash->p_osm->subn;
- osm_switch_t *p_next_sw, *p_sw;
-
- /* drop any existing references to old lash switches */
- p_next_sw = (osm_switch_t *) cl_qmap_head(&p_subn->sw_guid_tbl);
- while (p_next_sw != (osm_switch_t *) cl_qmap_end(&p_subn->sw_guid_tbl)) {
- p_sw = p_next_sw;
- p_next_sw = (osm_switch_t *) cl_qmap_next(&p_sw->map_item);
- p_sw->priv = NULL;
- }
-
- if (p_lash->switches) {
- unsigned id;
- for (id = 0; ((int)id) < p_lash->num_switches; id++)
- if (p_lash->switches[id])
- switch_delete(p_lash->switches[id]);
- free(p_lash->switches);
- }
- p_lash->switches = NULL;
-}
-
-/*
- static int discover_network_properties()
- Traverse the topology of the network in order to determine
- - the maximum number of switches,
- - the minimum number of virtual layers
-*/
-
-static int discover_network_properties(lash_t * p_lash)
-{
- int i = 0, id = 0;
- uint8_t vl_min;
- osm_subn_t *p_subn = &p_lash->p_osm->subn;
- osm_switch_t *p_next_sw, *p_sw;
- osm_log_t *p_log = &p_lash->p_osm->log;
-
- p_lash->num_switches = cl_qmap_count(&p_subn->sw_guid_tbl);
-
- p_lash->switches = malloc(p_lash->num_switches * sizeof(switch_t *));
- if (!p_lash->switches)
- return -1;
- memset(p_lash->switches, 0, p_lash->num_switches * sizeof(switch_t *));
-
- vl_min = 5; // set to a high value
-
- p_next_sw = (osm_switch_t *) cl_qmap_head(&p_subn->sw_guid_tbl);
- while (p_next_sw != (osm_switch_t *) cl_qmap_end(&p_subn->sw_guid_tbl)) {
- uint16_t port_count;
- p_sw = p_next_sw;
- p_next_sw = (osm_switch_t *) cl_qmap_next(&p_sw->map_item);
-
- p_lash->switches[id] = switch_create(p_lash, id, p_sw);
- if (!p_lash->switches[id])
- return -1;
- id++;
-
- port_count = osm_node_get_num_physp(p_sw->p_node);
-
- // Note, ignoring port 0. management port
- for (i = 1; i < port_count; i++) {
- osm_physp_t *p_current_physp =
- osm_node_get_physp_ptr(p_sw->p_node, i);
-
- if (p_current_physp
- && p_current_physp->p_remote_physp) {
-
- ib_port_info_t *p_port_info =
- &p_current_physp->port_info;
- uint8_t port_vl_min =
- ib_port_info_get_op_vls(p_port_info);
- if (port_vl_min && port_vl_min < vl_min)
- vl_min = port_vl_min;
- }
- } // for
- } // while
-
- vl_min = 1 << (vl_min - 1);
- if (vl_min > 15)
- vl_min = 15;
-
- p_lash->vl_min = vl_min;
-
- OSM_LOG(p_log, OSM_LOG_INFO,
- "min operational vl(%d) max_switches(%d)\n", p_lash->vl_min,
- p_lash->num_switches);
- return 0;
-}
-
-static void process_switches(lash_t * p_lash)
-{
- osm_switch_t *p_sw, *p_next_sw;
- osm_subn_t *p_subn = &p_lash->p_osm->subn;
-
- /* Go through each swithc and process it. i.e build the connection
- structure required by LASH */
- p_next_sw = (osm_switch_t *) cl_qmap_head(&p_subn->sw_guid_tbl);
- while (p_next_sw != (osm_switch_t *) cl_qmap_end(&p_subn->sw_guid_tbl)) {
- p_sw = p_next_sw;
- p_next_sw = (osm_switch_t *) cl_qmap_next(&p_sw->map_item);
-
- osm_lash_process_switch(p_lash, p_sw);
- }
-}
-
-static int lash_process(void *context)
-{
- lash_t *p_lash = context;
- osm_log_t *p_log = &p_lash->p_osm->log;
- int return_status = IB_SUCCESS;
-
- OSM_LOG_ENTER(p_log);
-
- p_lash->balance_limit = 6;
-
- // everything starts here
- lash_cleanup(p_lash);
-
- discover_network_properties(p_lash);
-
- return_status = init_lash_structures(p_lash);
- if (return_status != IB_SUCCESS)
- goto Exit;
-
- process_switches(p_lash);
-
- return_status = lash_core(p_lash);
- if (return_status != IB_SUCCESS)
- goto Exit;
-
- populate_fwd_tbls(p_lash);
-
-Exit:
- free_lash_structures(p_lash);
- OSM_LOG_EXIT(p_log);
-
- return return_status;
-}
-
-static lash_t *lash_create(osm_opensm_t * p_osm)
-{
- lash_t *p_lash;
-
- p_lash = malloc(sizeof(lash_t));
- if (!p_lash)
- return NULL;
-
- memset(p_lash, 0, sizeof(lash_t));
- p_lash->p_osm = p_osm;
-
- return (p_lash);
-}
-
-static void lash_delete(void *context)
-{
- lash_t *p_lash = context;
- if (p_lash->switches) {
- unsigned id;
- for (id = 0; ((int)id) < p_lash->num_switches; id++)
- if (p_lash->switches[id])
- switch_delete(p_lash->switches[id]);
- free(p_lash->switches);
- }
- free(p_lash);
-}
-
-uint8_t osm_get_lash_sl(osm_opensm_t * p_osm, osm_port_t * p_src_port,
- osm_port_t * p_dst_port)
-{
- unsigned dst_id;
- unsigned src_id;
- osm_switch_t *p_sw;
-
- if (p_osm->routing_engine_used != OSM_ROUTING_ENGINE_TYPE_LASH)
- return OSM_DEFAULT_SL;
-
- p_sw = get_osm_switch_from_port(p_dst_port);
- if (!p_sw || !p_sw->priv)
- return OSM_DEFAULT_SL;
- dst_id = get_lash_id(p_sw);
-
- p_sw = get_osm_switch_from_port(p_src_port);
- if (!p_sw || !p_sw->priv)
- return OSM_DEFAULT_SL;
-
- src_id = get_lash_id(p_sw);
- if (src_id == dst_id)
- return OSM_DEFAULT_SL;
-
- return (uint8_t) ((switch_t *) p_sw->priv)->routing_table[dst_id].lane;
-}
-
-int osm_ucast_lash_setup(struct osm_routing_engine *r, osm_opensm_t *p_osm)
-{
- lash_t *p_lash = lash_create(p_osm);
- if (!p_lash)
- return -1;
-
- r->context = p_lash;
- r->ucast_build_fwd_tables = lash_process;
- r->delete = lash_delete;
-
- return 0;
-}
diff --git a/contrib/ofed/management/opensm/opensm/osm_ucast_mgr.c b/contrib/ofed/management/opensm/opensm/osm_ucast_mgr.c
deleted file mode 100644
index d332b36..0000000
--- a/contrib/ofed/management/opensm/opensm/osm_ucast_mgr.c
+++ /dev/null
@@ -1,903 +0,0 @@
-/*
- * Copyright (c) 2004-2008 Voltaire, Inc. All rights reserved.
- * Copyright (c) 2002-2008 Mellanox Technologies LTD. All rights reserved.
- * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- */
-
-/*
- * Abstract:
- * Implementation of osm_ucast_mgr_t.
- * This file implements the Unicast Manager object.
- */
-
-#if HAVE_CONFIG_H
-# include <config.h>
-#endif /* HAVE_CONFIG_H */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <iba/ib_types.h>
-#include <complib/cl_qmap.h>
-#include <complib/cl_debug.h>
-#include <complib/cl_qlist.h>
-#include <opensm/osm_ucast_mgr.h>
-#include <opensm/osm_sm.h>
-#include <opensm/osm_log.h>
-#include <opensm/osm_node.h>
-#include <opensm/osm_switch.h>
-#include <opensm/osm_helper.h>
-#include <opensm/osm_msgdef.h>
-#include <opensm/osm_opensm.h>
-
-/**********************************************************************
- **********************************************************************/
-void osm_ucast_mgr_construct(IN osm_ucast_mgr_t * const p_mgr)
-{
- memset(p_mgr, 0, sizeof(*p_mgr));
-}
-
-/**********************************************************************
- **********************************************************************/
-void osm_ucast_mgr_destroy(IN osm_ucast_mgr_t * const p_mgr)
-{
- CL_ASSERT(p_mgr);
-
- OSM_LOG_ENTER(p_mgr->p_log);
-
- if (p_mgr->cache_valid)
- osm_ucast_cache_invalidate(p_mgr);
-
- OSM_LOG_EXIT(p_mgr->p_log);
-}
-
-/**********************************************************************
- **********************************************************************/
-ib_api_status_t
-osm_ucast_mgr_init(IN osm_ucast_mgr_t * const p_mgr, IN osm_sm_t * sm)
-{
- ib_api_status_t status = IB_SUCCESS;
-
- OSM_LOG_ENTER(sm->p_log);
-
- osm_ucast_mgr_construct(p_mgr);
-
- p_mgr->sm = sm;
- p_mgr->p_log = sm->p_log;
- p_mgr->p_subn = sm->p_subn;
- p_mgr->p_lock = sm->p_lock;
-
- if (sm->p_subn->opt.use_ucast_cache)
- cl_qmap_init(&p_mgr->cache_sw_tbl);
-
- OSM_LOG_EXIT(p_mgr->p_log);
- return (status);
-}
-
-/**********************************************************************
- Add each switch's own and neighbor LIDs to its LID matrix
-**********************************************************************/
-static void
-__osm_ucast_mgr_process_hop_0_1(IN cl_map_item_t * const p_map_item,
- IN void *context)
-{
- osm_switch_t *const p_sw = (osm_switch_t *) p_map_item;
- osm_node_t *p_remote_node;
- uint16_t lid, remote_lid;
- uint8_t i, remote_port;
-
- lid = osm_node_get_base_lid(p_sw->p_node, 0);
- lid = cl_ntoh16(lid);
- osm_switch_set_hops(p_sw, lid, 0, 0);
-
- for (i = 1; i < p_sw->num_ports; i++) {
- p_remote_node =
- osm_node_get_remote_node(p_sw->p_node, i, &remote_port);
-
- if (p_remote_node && p_remote_node->sw &&
- (p_remote_node != p_sw->p_node)) {
- remote_lid = osm_node_get_base_lid(p_remote_node, 0);
- remote_lid = cl_ntoh16(remote_lid);
- osm_switch_set_hops(p_sw, remote_lid, i, 1);
- osm_switch_set_hops(p_remote_node->sw, lid, remote_port,
- 1);
- }
- }
-}
-
-/**********************************************************************
- **********************************************************************/
-static void
-__osm_ucast_mgr_process_neighbor(IN osm_ucast_mgr_t * const p_mgr,
- IN osm_switch_t * const p_this_sw,
- IN osm_switch_t * const p_remote_sw,
- IN const uint8_t port_num,
- IN const uint8_t remote_port_num)
-{
- osm_switch_t *p_sw, *p_next_sw;
- uint16_t lid_ho;
- uint8_t hops;
-
- OSM_LOG_ENTER(p_mgr->p_log);
-
- OSM_LOG(p_mgr->p_log, OSM_LOG_DEBUG,
- "Node 0x%" PRIx64 ", remote node 0x%" PRIx64
- ", port %u, remote port %u\n",
- cl_ntoh64(osm_node_get_node_guid(p_this_sw->p_node)),
- cl_ntoh64(osm_node_get_node_guid(p_remote_sw->p_node)),
- port_num, remote_port_num);
-
- p_next_sw = (osm_switch_t *) cl_qmap_head(&p_mgr->p_subn->sw_guid_tbl);
- while (p_next_sw !=
- (osm_switch_t *) cl_qmap_end(&p_mgr->p_subn->sw_guid_tbl)) {
- p_sw = p_next_sw;
- p_next_sw = (osm_switch_t *) cl_qmap_next(&p_sw->map_item);
- lid_ho = osm_node_get_base_lid(p_sw->p_node, 0);
- lid_ho = cl_ntoh16(lid_ho);
- hops = osm_switch_get_least_hops(p_remote_sw, lid_ho);
- if (hops == OSM_NO_PATH)
- continue;
- hops++;
- if (hops <
- osm_switch_get_hop_count(p_this_sw, lid_ho, port_num)) {
- if (osm_switch_set_hops
- (p_this_sw, lid_ho, port_num, hops) != 0)
- OSM_LOG(p_mgr->p_log, OSM_LOG_ERROR,
- "cannot set hops for lid %u at switch 0x%"
- PRIx64 "\n", lid_ho,
- cl_ntoh64(osm_node_get_node_guid
- (p_this_sw->p_node)));
- p_mgr->some_hop_count_set = TRUE;
- }
- }
-
- OSM_LOG_EXIT(p_mgr->p_log);
-}
-
-/**********************************************************************
- **********************************************************************/
-static struct osm_remote_node *
-find_and_add_remote_sys(osm_switch_t *sw, uint8_t port,
- struct osm_remote_guids_count *r)
-{
- unsigned i;
- osm_physp_t *p = osm_node_get_physp_ptr(sw->p_node, port);
- osm_node_t *node = p->p_remote_physp->p_node;
-
- for (i = 0; i < r->count; i++)
- if (r->guids[i].node == node)
- return &r->guids[i];
-
- r->guids[i].node = node;
- r->guids[i].forwarded_to = 0;
- r->count++;
- return &r->guids[i];
-}
-
-static void
-__osm_ucast_mgr_process_port(IN osm_ucast_mgr_t * const p_mgr,
- IN osm_switch_t * const p_sw,
- IN osm_port_t * const p_port,
- IN unsigned lid_offset)
-{
- uint16_t min_lid_ho;
- uint16_t max_lid_ho;
- uint16_t lid_ho;
- uint8_t port;
- boolean_t is_ignored_by_port_prof;
- ib_net64_t node_guid;
- unsigned start_from = 1;
-
- OSM_LOG_ENTER(p_mgr->p_log);
-
- osm_port_get_lid_range_ho(p_port, &min_lid_ho, &max_lid_ho);
-
- /* If the lids are zero - then there was some problem with
- * the initialization. Don't handle this port. */
- if (min_lid_ho == 0 || max_lid_ho == 0) {
- OSM_LOG(p_mgr->p_log, OSM_LOG_ERROR, "ERR 3A04: "
- "Port 0x%" PRIx64 " has LID 0. An initialization "
- "error occurred. Ignoring port\n",
- cl_ntoh64(osm_port_get_guid(p_port)));
- goto Exit;
- }
-
- lid_ho = min_lid_ho + lid_offset;
-
- if (lid_ho > max_lid_ho)
- goto Exit;
-
- if (lid_offset)
- /* ignore potential overflow - it is handled in osm_switch.c */
- start_from = osm_switch_get_port_by_lid(p_sw, lid_ho - 1) + 1;
-
- OSM_LOG(p_mgr->p_log, OSM_LOG_DEBUG,
- "Processing port 0x%" PRIx64 " (\'%s\' port %u), LID %u [%u,%u]\n",
- cl_ntoh64(osm_port_get_guid(p_port)),
- p_port->p_node->print_desc, p_port->p_physp->port_num,
- lid_ho, min_lid_ho, max_lid_ho);
-
- /* TODO - This should be runtime error, not a CL_ASSERT() */
- CL_ASSERT(max_lid_ho <= IB_LID_UCAST_END_HO);
-
- node_guid = osm_node_get_node_guid(p_sw->p_node);
-
- /*
- The lid matrix contains the number of hops to each
- lid from each port. From this information we determine
- how best to distribute the LID range across the ports
- that can reach those LIDs.
- */
- port = osm_switch_recommend_path(p_sw, p_port, lid_ho, start_from,
- p_mgr->p_subn->ignore_existing_lfts,
- p_mgr->is_dor);
-
- if (port == OSM_NO_PATH) {
- /* do not try to overwrite the ppro of non existing port ... */
- is_ignored_by_port_prof = TRUE;
-
- OSM_LOG(p_mgr->p_log, OSM_LOG_DEBUG,
- "No path to get to LID %u from switch 0x%" PRIx64 "\n",
- lid_ho, cl_ntoh64(node_guid));
- } else {
- osm_physp_t *p = osm_node_get_physp_ptr(p_sw->p_node, port);
-
- OSM_LOG(p_mgr->p_log, OSM_LOG_DEBUG,
- "Routing LID %u to port %u"
- " for switch 0x%" PRIx64 "\n",
- lid_ho, port, cl_ntoh64(node_guid));
-
- /*
- we would like to optionally ignore this port in equalization
- as in the case of the Mellanox Anafa Internal PCI TCA port
- */
- is_ignored_by_port_prof = p->is_prof_ignored;
-
- /*
- We also would ignore this route if the target lid is of
- a switch and the port_profile_switch_node is not TRUE
- */
- if (!p_mgr->p_subn->opt.port_profile_switch_nodes)
- is_ignored_by_port_prof |=
- (osm_node_get_type(p_port->p_node) ==
- IB_NODE_TYPE_SWITCH);
- }
-
- /*
- We have selected the port for this LID.
- Write it to the forwarding tables.
- */
- p_sw->new_lft[lid_ho] = port;
- if (!is_ignored_by_port_prof) {
- struct osm_remote_node *rem_node_used;
- osm_switch_count_path(p_sw, port);
- if (port > 0 && p_port->priv &&
- (rem_node_used = find_and_add_remote_sys(p_sw, port,
- p_port->priv)))
- rem_node_used->forwarded_to++;
- }
-
-Exit:
- OSM_LOG_EXIT(p_mgr->p_log);
-}
-
-/**********************************************************************
- **********************************************************************/
-int osm_ucast_mgr_set_fwd_table(IN osm_ucast_mgr_t * const p_mgr,
- IN osm_switch_t * const p_sw)
-{
- osm_node_t *p_node;
- osm_dr_path_t *p_path;
- osm_madw_context_t context;
- ib_api_status_t status;
- ib_switch_info_t si;
- uint16_t block_id_ho = 0;
- uint8_t block[IB_SMP_DATA_SIZE];
- boolean_t set_swinfo_require = FALSE;
- uint16_t lin_top;
- uint8_t life_state;
-
- CL_ASSERT(p_mgr);
-
- OSM_LOG_ENTER(p_mgr->p_log);
-
- CL_ASSERT(p_sw);
-
- p_node = p_sw->p_node;
-
- CL_ASSERT(p_node);
-
- p_path = osm_physp_get_dr_path_ptr(osm_node_get_physp_ptr(p_node, 0));
-
- /*
- Set the top of the unicast forwarding table.
- */
- si = p_sw->switch_info;
- lin_top = cl_hton16(p_sw->max_lid_ho);
- if (lin_top != si.lin_top) {
- set_swinfo_require = TRUE;
- si.lin_top = lin_top;
- }
-
- /* check to see if the change state bit is on. If it is - then we
- need to clear it. */
- if (ib_switch_info_get_state_change(&si))
- life_state = ((p_mgr->p_subn->opt.packet_life_time << 3)
- | (si.life_state & IB_SWITCH_PSC)) & 0xfc;
- else
- life_state = (p_mgr->p_subn->opt.packet_life_time << 3) & 0xf8;
-
- if ((life_state != si.life_state)
- || ib_switch_info_get_state_change(&si)) {
- set_swinfo_require = TRUE;
- si.life_state = life_state;
- }
-
- if (set_swinfo_require) {
- OSM_LOG(p_mgr->p_log, OSM_LOG_DEBUG,
- "Setting switch FT top to LID %u\n", p_sw->max_lid_ho);
-
- context.si_context.light_sweep = FALSE;
- context.si_context.node_guid = osm_node_get_node_guid(p_node);
- context.si_context.set_method = TRUE;
-
- status = osm_req_set(p_mgr->sm, p_path, (uint8_t *) & si,
- sizeof(si),
- IB_MAD_ATTR_SWITCH_INFO,
- 0, CL_DISP_MSGID_NONE, &context);
-
- if (status != IB_SUCCESS)
- OSM_LOG(p_mgr->p_log, OSM_LOG_ERROR, "ERR 3A06: "
- "Sending SwitchInfo attribute failed (%s)\n",
- ib_get_err_str(status));
- }
-
- /*
- Send linear forwarding table blocks to the switch
- as long as the switch indicates it has blocks needing
- configuration.
- */
-
- context.lft_context.node_guid = osm_node_get_node_guid(p_node);
- context.lft_context.set_method = TRUE;
-
- if (!p_sw->new_lft) {
- /* any routing should provide the new_lft */
- CL_ASSERT(p_mgr->p_subn->opt.use_ucast_cache &&
- p_mgr->cache_valid && !p_sw->need_update);
- goto Exit;
- }
-
- for (block_id_ho = 0;
- osm_switch_get_lft_block(p_sw, block_id_ho, block);
- block_id_ho++) {
- if (!p_sw->need_update &&
- !memcmp(block,
- p_sw->new_lft + block_id_ho * IB_SMP_DATA_SIZE,
- IB_SMP_DATA_SIZE))
- continue;
-
- OSM_LOG(p_mgr->p_log, OSM_LOG_DEBUG,
- "Writing FT block %u\n", block_id_ho);
-
- status = osm_req_set(p_mgr->sm, p_path,
- p_sw->new_lft + block_id_ho * IB_SMP_DATA_SIZE,
- sizeof(block),
- IB_MAD_ATTR_LIN_FWD_TBL,
- cl_hton32(block_id_ho),
- CL_DISP_MSGID_NONE, &context);
-
- if (status != IB_SUCCESS)
- OSM_LOG(p_mgr->p_log, OSM_LOG_ERROR, "ERR 3A05: "
- "Sending linear fwd. tbl. block failed (%s)\n",
- ib_get_err_str(status));
- }
-
-Exit:
- OSM_LOG_EXIT(p_mgr->p_log);
- return 0;
-}
-
-/**********************************************************************
- **********************************************************************/
-static void alloc_ports_priv(osm_ucast_mgr_t *mgr)
-{
- cl_qmap_t *port_tbl = &mgr->p_subn->port_guid_tbl;
- struct osm_remote_guids_count *r;
- osm_port_t *port;
- cl_map_item_t *item;
- unsigned lmc;
-
- for (item = cl_qmap_head(port_tbl); item != cl_qmap_end(port_tbl);
- item = cl_qmap_next(item)) {
- port = (osm_port_t *)item;
- lmc = ib_port_info_get_lmc(&port->p_physp->port_info);
- if (!lmc)
- continue;
- r = malloc(sizeof(*r) + sizeof(r->guids[0]) * (1 << lmc));
- if (!r) {
- OSM_LOG(mgr->p_log, OSM_LOG_ERROR, "ERR 3A09: "
- "cannot allocate memory to track remote"
- " systems for lmc > 0\n");
- port->priv = NULL;
- continue;
- }
- memset(r, 0, sizeof(*r) + sizeof(r->guids[0]) * (1 << lmc));
- port->priv = r;
- }
-}
-
-static void free_ports_priv(osm_ucast_mgr_t *mgr)
-{
- cl_qmap_t *port_tbl = &mgr->p_subn->port_guid_tbl;
- osm_port_t *port;
- cl_map_item_t *item;
- for (item = cl_qmap_head(port_tbl); item != cl_qmap_end(port_tbl);
- item = cl_qmap_next(item)) {
- port = (osm_port_t *)item;
- if (port->priv) {
- free(port->priv);
- port->priv = NULL;
- }
- }
-}
-
-static void
-__osm_ucast_mgr_process_tbl(IN cl_map_item_t * const p_map_item,
- IN void *context)
-{
- osm_ucast_mgr_t *p_mgr = context;
- osm_switch_t *const p_sw = (osm_switch_t *) p_map_item;
- unsigned i, lids_per_port;
-
- OSM_LOG_ENTER(p_mgr->p_log);
-
- CL_ASSERT(p_sw && p_sw->p_node);
-
- OSM_LOG(p_mgr->p_log, OSM_LOG_DEBUG,
- "Processing switch 0x%" PRIx64 "\n",
- cl_ntoh64(osm_node_get_node_guid(p_sw->p_node)));
-
- /* Initialize LIDs in buffer to invalid port number. */
- memset(p_sw->new_lft, OSM_NO_PATH, IB_LID_UCAST_END_HO + 1);
-
- if (p_mgr->p_subn->opt.lmc)
- alloc_ports_priv(p_mgr);
-
- /*
- Iterate through every port setting LID routes for each
- port based on base LID and LMC value.
- */
- lids_per_port = 1 << p_mgr->p_subn->opt.lmc;
- for (i = 0; i < lids_per_port; i++) {
- cl_qlist_t *list = &p_mgr->port_order_list;
- cl_list_item_t *item;
- for (item = cl_qlist_head(list); item != cl_qlist_end(list);
- item = cl_qlist_next(item)) {
- osm_port_t *port = cl_item_obj(item, port, list_item);
- __osm_ucast_mgr_process_port(p_mgr, p_sw, port, i);
- }
- }
-
- osm_ucast_mgr_set_fwd_table(p_mgr, p_sw);
-
- if (p_mgr->p_subn->opt.lmc)
- free_ports_priv(p_mgr);
-
- OSM_LOG_EXIT(p_mgr->p_log);
-}
-
-/**********************************************************************
- **********************************************************************/
-static void
-__osm_ucast_mgr_process_neighbors(IN cl_map_item_t * const p_map_item,
- IN void *context)
-{
- osm_switch_t *const p_sw = (osm_switch_t *) p_map_item;
- osm_ucast_mgr_t *const p_mgr = (osm_ucast_mgr_t *) context;
- osm_node_t *p_node;
- osm_node_t *p_remote_node;
- uint32_t port_num;
- uint8_t remote_port_num;
- uint32_t num_ports;
- osm_physp_t *p_physp;
-
- OSM_LOG_ENTER(p_mgr->p_log);
-
- p_node = p_sw->p_node;
-
- CL_ASSERT(p_node);
- CL_ASSERT(osm_node_get_type(p_node) == IB_NODE_TYPE_SWITCH);
-
- OSM_LOG(p_mgr->p_log, OSM_LOG_DEBUG,
- "Processing switch with GUID 0x%" PRIx64 "\n",
- cl_ntoh64(osm_node_get_node_guid(p_node)));
-
- num_ports = osm_node_get_num_physp(p_node);
-
- /*
- Start with port 1 to skip the switch's management port.
- */
- for (port_num = 1; port_num < num_ports; port_num++) {
- p_remote_node = osm_node_get_remote_node(p_node,
- (uint8_t) port_num,
- &remote_port_num);
-
- if (p_remote_node && p_remote_node->sw
- && (p_remote_node != p_node)) {
- /* make sure the link is healthy. If it is not - don't
- propagate through it. */
- p_physp = osm_node_get_physp_ptr(p_node, port_num);
- if (!p_physp || !osm_link_is_healthy(p_physp))
- continue;
-
- __osm_ucast_mgr_process_neighbor(p_mgr, p_sw,
- p_remote_node->sw,
- (uint8_t) port_num,
- remote_port_num);
-
- }
- }
-
- OSM_LOG_EXIT(p_mgr->p_log);
-}
-
-/**********************************************************************
- **********************************************************************/
-int osm_ucast_mgr_build_lid_matrices(IN osm_ucast_mgr_t * const p_mgr)
-{
- uint32_t i;
- uint32_t iteration_max;
- cl_qmap_t *p_sw_guid_tbl;
-
- p_sw_guid_tbl = &p_mgr->p_subn->sw_guid_tbl;
-
- OSM_LOG(p_mgr->p_log, OSM_LOG_VERBOSE,
- "Starting switches' Min Hop Table Assignment\n");
-
- /*
- Set the switch matrices for each switch's own port 0 LID(s)
- then set the lid matrices for the each switch's leaf nodes.
- */
- cl_qmap_apply_func(p_sw_guid_tbl,
- __osm_ucast_mgr_process_hop_0_1, p_mgr);
-
- /*
- Get the switch matrices for each switch's neighbors.
- This process requires a number of iterations equal to
- the number of switches in the subnet minus 1.
-
- In each iteration, a switch learns the lid/port/hop
- information (as contained by a switch's lid matrix) from
- its immediate neighbors. After each iteration, a switch
- (and it's neighbors) know more routing information than
- it did on the previous iteration.
- Thus, by repeatedly absorbing the routing information of
- neighbor switches, every switch eventually learns how to
- route all LIDs on the subnet.
-
- Note that there may not be any switches in the subnet if
- we are in simple p2p configuration.
- */
- iteration_max = cl_qmap_count(p_sw_guid_tbl);
-
- /*
- If there are switches in the subnet, iterate until the lid
- matrix has been constructed. Otherwise, just immediately
- indicate we're done if no switches exist.
- */
- if (iteration_max) {
- iteration_max--;
-
- /*
- we need to find out when the propagation of
- hop counts has relaxed. So this global variable
- is preset to 0 on each iteration and if
- if non of the switches was set will exit the
- while loop
- */
- p_mgr->some_hop_count_set = TRUE;
- for (i = 0; (i < iteration_max) && p_mgr->some_hop_count_set;
- i++) {
- p_mgr->some_hop_count_set = FALSE;
- cl_qmap_apply_func(p_sw_guid_tbl,
- __osm_ucast_mgr_process_neighbors,
- p_mgr);
- }
- OSM_LOG(p_mgr->p_log, OSM_LOG_DEBUG,
- "Min-hop propagated in %d steps\n", i);
- }
-
- return 0;
-}
-
-/**********************************************************************
- **********************************************************************/
-static int ucast_mgr_setup_all_switches(osm_subn_t * p_subn)
-{
- osm_switch_t *p_sw;
- uint16_t lids;
-
- lids = (uint16_t) cl_ptr_vector_get_size(&p_subn->port_lid_tbl);
- lids = lids ? lids - 1 : 0;
-
- for (p_sw = (osm_switch_t *) cl_qmap_head(&p_subn->sw_guid_tbl);
- p_sw != (osm_switch_t *) cl_qmap_end(&p_subn->sw_guid_tbl);
- p_sw = (osm_switch_t *) cl_qmap_next(&p_sw->map_item))
- if (osm_switch_prepare_path_rebuild(p_sw, lids)) {
- OSM_LOG(&p_subn->p_osm->log, OSM_LOG_ERROR, "ERR 3A0B: "
- "cannot setup switch 0x%016" PRIx64 "\n",
- cl_ntoh64(osm_node_get_node_guid
- (p_sw->p_node)));
- return -1;
- }
-
- return 0;
-}
-
-/**********************************************************************
- **********************************************************************/
-
-static int add_guid_to_order_list(void *ctx, uint64_t guid, char *p)
-{
- osm_ucast_mgr_t *m = ctx;
- osm_port_t *port = osm_get_port_by_guid(m->p_subn, cl_hton64(guid));
-
- if (!port) {
- OSM_LOG(m->p_log, OSM_LOG_DEBUG,
- "port guid not found: 0x%016" PRIx64 "\n", guid);
- return 0;
- }
-
- if (port->flag) {
- OSM_LOG(m->p_log, OSM_LOG_DEBUG,
- "port guid specified multiple times 0x%016" PRIx64 "\n",
- guid);
- return 0;
- }
-
- cl_qlist_insert_tail(&m->port_order_list, &port->list_item);
- port->flag = 1;
-
- return 0;
-}
-
-static void add_port_to_order_list(cl_map_item_t * const p_map_item, void *ctx)
-{
- osm_port_t *port = (osm_port_t *)p_map_item;
- osm_ucast_mgr_t *m = ctx;
-
- if (!port->flag)
- cl_qlist_insert_tail(&m->port_order_list, &port->list_item);
- else
- port->flag = 0;
-}
-
-static int mark_ignored_port(void *ctx, uint64_t guid, char *p)
-{
- osm_ucast_mgr_t *m = ctx;
- osm_node_t *node = osm_get_node_by_guid(m->p_subn, cl_hton64(guid));
- osm_physp_t *physp;
- unsigned port;
-
- if (!node || !node->sw) {
- OSM_LOG(m->p_log, OSM_LOG_DEBUG,
- "switch with guid 0x%016" PRIx64 " is not found\n",
- guid);
- return 0;
- }
-
- if (!p || !*p || !(port = strtoul(p, NULL, 0)) ||
- port >= node->sw->num_ports) {
- OSM_LOG(m->p_log, OSM_LOG_DEBUG,
- "bad port specified for guid 0x%016" PRIx64 "\n", guid);
- return 0;
- }
-
- physp = osm_node_get_physp_ptr(node, port);
- if (!physp)
- return 0;
-
- physp->is_prof_ignored = 1;
-
- return 0;
-}
-
-static void clear_prof_ignore_flag(cl_map_item_t * const p_map_item, void *ctx)
-{
- osm_switch_t *sw = (osm_switch_t *)p_map_item;
- int i;
-
- for (i = 1; i < sw->num_ports; i++) {
- osm_physp_t *p = osm_node_get_physp_ptr(sw->p_node, i);
- if (p)
- p->is_prof_ignored = 0;
- }
-}
-
-static int ucast_mgr_build_lfts(osm_ucast_mgr_t *p_mgr)
-{
- cl_qlist_init(&p_mgr->port_order_list);
-
- if (p_mgr->p_subn->opt.guid_routing_order_file) {
- OSM_LOG(p_mgr->p_log, OSM_LOG_DEBUG,
- "Fetching guid routing order file \'%s\'\n",
- p_mgr->p_subn->opt.guid_routing_order_file);
-
- if (parse_node_map(p_mgr->p_subn->opt.guid_routing_order_file,
- add_guid_to_order_list, p_mgr))
- OSM_LOG(p_mgr->p_log, OSM_LOG_ERROR, "ERR : "
- "cannot parse guid routing order file \'%s\'\n",
- p_mgr->p_subn->opt.guid_routing_order_file);
- }
-
- if (p_mgr->p_subn->opt.port_prof_ignore_file) {
- cl_qmap_apply_func(&p_mgr->p_subn->sw_guid_tbl,
- clear_prof_ignore_flag, NULL);
- if (parse_node_map(p_mgr->p_subn->opt.port_prof_ignore_file,
- mark_ignored_port, p_mgr)) {
- OSM_LOG(p_mgr->p_log, OSM_LOG_ERROR, "ERR : "
- "cannot parse port prof ignore file \'%s\'\n",
- p_mgr->p_subn->opt.port_prof_ignore_file);
- }
- }
-
- cl_qmap_apply_func(&p_mgr->p_subn->port_guid_tbl,
- add_port_to_order_list, p_mgr);
-
- cl_qmap_apply_func(&p_mgr->p_subn->sw_guid_tbl,
- __osm_ucast_mgr_process_tbl, p_mgr);
-
- cl_qlist_remove_all(&p_mgr->port_order_list);
-
- return 0;
-}
-
-/**********************************************************************
- **********************************************************************/
-static int ucast_mgr_route(struct osm_routing_engine *r, osm_opensm_t *osm)
-{
- int ret;
-
- OSM_LOG(&osm->log, OSM_LOG_VERBOSE,
- "building routing with \'%s\' routing algorithm...\n", r->name);
-
- if (!r->build_lid_matrices ||
- (ret = r->build_lid_matrices(r->context)) > 0)
- ret = osm_ucast_mgr_build_lid_matrices(&osm->sm.ucast_mgr);
-
- if (ret < 0) {
- OSM_LOG(&osm->log, OSM_LOG_ERROR,
- "%s: cannot build lid matrices.\n", r->name);
- return ret;
- }
-
- if (!r->ucast_build_fwd_tables ||
- (ret = r->ucast_build_fwd_tables(r->context)) > 0)
- ret = ucast_mgr_build_lfts(&osm->sm.ucast_mgr);
-
- if (ret < 0) {
- OSM_LOG(&osm->log, OSM_LOG_ERROR,
- "%s: cannot build fwd tables.\n", r->name);
- return ret;
- }
-
- osm->routing_engine_used = osm_routing_engine_type(r->name);
-
- return 0;
-}
-
-int osm_ucast_mgr_process(IN osm_ucast_mgr_t * const p_mgr)
-{
- osm_opensm_t *p_osm;
- struct osm_routing_engine *p_routing_eng;
- cl_qmap_t *p_sw_guid_tbl;
-
- OSM_LOG_ENTER(p_mgr->p_log);
-
- p_sw_guid_tbl = &p_mgr->p_subn->sw_guid_tbl;
- p_osm = p_mgr->p_subn->p_osm;
- p_routing_eng = p_osm->routing_engine_list;
-
- CL_PLOCK_EXCL_ACQUIRE(p_mgr->p_lock);
-
- /*
- If there are no switches in the subnet, we are done.
- */
- if (cl_qmap_count(p_sw_guid_tbl) == 0 ||
- ucast_mgr_setup_all_switches(p_mgr->p_subn) < 0)
- goto Exit;
-
- p_osm->routing_engine_used = OSM_ROUTING_ENGINE_TYPE_NONE;
- while (p_routing_eng) {
- if (!ucast_mgr_route(p_routing_eng, p_osm))
- break;
- p_routing_eng = p_routing_eng->next;
- }
-
- if (p_osm->routing_engine_used == OSM_ROUTING_ENGINE_TYPE_NONE) {
- /* If configured routing algorithm failed, use default MinHop */
- osm_ucast_mgr_build_lid_matrices(p_mgr);
- ucast_mgr_build_lfts(p_mgr);
- p_osm->routing_engine_used = OSM_ROUTING_ENGINE_TYPE_MINHOP;
- }
-
- OSM_LOG(p_mgr->p_log, OSM_LOG_INFO,
- "%s tables configured on all switches\n",
- osm_routing_engine_type_str(p_osm->routing_engine_used));
-
- if (p_mgr->p_subn->opt.use_ucast_cache)
- p_mgr->cache_valid = TRUE;
-
-Exit:
- CL_PLOCK_RELEASE(p_mgr->p_lock);
- OSM_LOG_EXIT(p_mgr->p_log);
- return 0;
-}
-
-static int ucast_build_lid_matrices(void *context)
-{
- return osm_ucast_mgr_build_lid_matrices(context);
-}
-
-static int ucast_build_lfts(void *context)
-{
- return ucast_mgr_build_lfts(context);
-}
-
-int osm_ucast_minhop_setup(struct osm_routing_engine *r, osm_opensm_t *osm)
-{
- r->context = &osm->sm.ucast_mgr;
- r->build_lid_matrices = ucast_build_lid_matrices;
- r->ucast_build_fwd_tables = ucast_build_lfts;
- return 0;
-}
-
-static int ucast_dor_build_lfts(void *context)
-{
- osm_ucast_mgr_t *mgr = context;
- int ret;
-
- mgr->is_dor = 1;
- ret = ucast_mgr_build_lfts(mgr);
- mgr->is_dor = 0;
-
- return ret;
-}
-
-int osm_ucast_dor_setup(struct osm_routing_engine *r, osm_opensm_t *osm)
-{
- r->context = &osm->sm.ucast_mgr;
- r->build_lid_matrices = ucast_build_lid_matrices;
- r->ucast_build_fwd_tables = ucast_dor_build_lfts;
- return 0;
-}
diff --git a/contrib/ofed/management/opensm/opensm/osm_ucast_updn.c b/contrib/ofed/management/opensm/opensm/osm_ucast_updn.c
deleted file mode 100644
index bb9ccda..0000000
--- a/contrib/ofed/management/opensm/opensm/osm_ucast_updn.c
+++ /dev/null
@@ -1,686 +0,0 @@
-/*
- * Copyright (c) 2004-2008 Voltaire, Inc. All rights reserved.
- * Copyright (c) 2002-2006 Mellanox Technologies LTD. All rights reserved.
- * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- */
-
-/*
- * Abstract:
- * Implementation of Up Down Algorithm using ranking & Min Hop
- * Calculation functions
- */
-
-#if HAVE_CONFIG_H
-# include <config.h>
-#endif /* HAVE_CONFIG_H */
-
-#include <stdlib.h>
-#include <ctype.h>
-#include <complib/cl_debug.h>
-#include <complib/cl_qmap.h>
-#include <opensm/osm_switch.h>
-#include <opensm/osm_opensm.h>
-#include <opensm/osm_ucast_mgr.h>
-
-/* //////////////////////////// */
-/* Local types */
-/* //////////////////////////// */
-
-/* direction */
-typedef enum updn_switch_dir {
- UP = 0,
- DOWN
-} updn_switch_dir_t;
-
-/* updn structure */
-typedef struct updn {
- unsigned num_roots;
- osm_opensm_t *p_osm;
-} updn_t;
-
-struct updn_node {
- cl_list_item_t list;
- osm_switch_t *sw;
- uint64_t id;
- updn_switch_dir_t dir;
- unsigned rank;
- unsigned visited;
-};
-
-/**********************************************************************
- **********************************************************************/
-/* This function returns direction based on rank and guid info of current &
- remote ports */
-static updn_switch_dir_t updn_get_dir(unsigned cur_rank, unsigned rem_rank,
- uint64_t cur_id, uint64_t rem_id)
-{
- /* HACK: comes to solve root nodes connection, in a classic subnet root nodes do not connect
- directly, but in case they are we assign to root node an UP direction to allow UPDN to discover
- the subnet correctly (and not from the point of view of the last root node).
- */
- if (!cur_rank && !rem_rank)
- return UP;
-
- if (cur_rank < rem_rank)
- return DOWN;
- else if (cur_rank > rem_rank)
- return UP;
- else {
- /* Equal rank, decide by id number, bigger == UP direction */
- if (cur_id > rem_id)
- return UP;
- else
- return DOWN;
- }
-}
-
-/**********************************************************************
- * This function does the bfs of min hop table calculation by guid index
- * as a starting point.
- **********************************************************************/
-static int updn_bfs_by_node(IN osm_log_t * p_log, IN osm_subn_t * p_subn,
- IN osm_switch_t * p_sw)
-{
- uint8_t pn, pn_rem;
- cl_qlist_t list;
- uint16_t lid;
- struct updn_node *u;
- updn_switch_dir_t next_dir, current_dir;
-
- OSM_LOG_ENTER(p_log);
-
- lid = osm_node_get_base_lid(p_sw->p_node, 0);
- lid = cl_ntoh16(lid);
- osm_switch_set_hops(p_sw, lid, 0, 0);
-
- OSM_LOG(p_log, OSM_LOG_DEBUG,
- "Starting from switch - port GUID 0x%" PRIx64 " lid %u\n",
- cl_ntoh64(p_sw->p_node->node_info.port_guid), lid);
-
- u = p_sw->priv;
- u->dir = UP;
-
- /* Update list with the new element */
- cl_qlist_init(&list);
- cl_qlist_insert_tail(&list, &u->list);
-
- /* BFS the list till no next element */
- while (!cl_is_qlist_empty(&list)) {
- u = (struct updn_node *)cl_qlist_remove_head(&list);
- u->visited = 0; /* cleanup */
- current_dir = u->dir;
- /* Go over all ports of the switch and find unvisited remote nodes */
- for (pn = 1; pn < u->sw->num_ports; pn++) {
- osm_node_t *p_remote_node;
- struct updn_node *rem_u;
- uint8_t current_min_hop, remote_min_hop,
- set_hop_return_value;
- osm_switch_t *p_remote_sw;
-
- p_remote_node =
- osm_node_get_remote_node(u->sw->p_node, pn,
- &pn_rem);
- /* If no remote node OR remote node is not a SWITCH
- continue to next pn */
- if (!p_remote_node || !p_remote_node->sw)
- continue;
- /* Fetch remote guid only after validation of remote node */
- p_remote_sw = p_remote_node->sw;
- rem_u = p_remote_sw->priv;
- /* Decide which direction to mark it (UP/DOWN) */
- next_dir = updn_get_dir(u->rank, rem_u->rank,
- u->id, rem_u->id);
-
- /* Check if this is a legal step : the only illegal step is going
- from DOWN to UP */
- if ((current_dir == DOWN) && (next_dir == UP)) {
- OSM_LOG(p_log, OSM_LOG_DEBUG,
- "Avoiding move from 0x%016" PRIx64
- " to 0x%016" PRIx64 "\n",
- cl_ntoh64(osm_node_get_node_guid(u->sw->p_node)),
- cl_ntoh64(osm_node_get_node_guid(p_remote_node)));
- /* Illegal step */
- continue;
- }
- /* Set MinHop value for the current lid */
- current_min_hop = osm_switch_get_least_hops(u->sw, lid);
- /* Check hop count if better insert into list && update
- the remote node Min Hop Table */
- remote_min_hop =
- osm_switch_get_hop_count(p_remote_sw, lid, pn_rem);
- if (current_min_hop + 1 < remote_min_hop) {
- set_hop_return_value =
- osm_switch_set_hops(p_remote_sw, lid,
- pn_rem,
- current_min_hop + 1);
- if (set_hop_return_value) {
- OSM_LOG(p_log, OSM_LOG_ERROR, "ERR AA01: "
- "Invalid value returned from set min hop is: %d\n",
- set_hop_return_value);
- }
- /* Check if remote port has already been visited */
- if (!rem_u->visited) {
- /* Insert updn_switch item into the list */
- rem_u->dir = next_dir;
- rem_u->visited = 1;
- cl_qlist_insert_tail(&list,
- &rem_u->list);
- }
- }
- }
- }
-
- OSM_LOG_EXIT(p_log);
- return 0;
-}
-
-/**********************************************************************
- **********************************************************************/
-/* NOTE : PLS check if we need to decide that the first */
-/* rank is a SWITCH for BFS purpose */
-static int updn_subn_rank(IN updn_t * p_updn)
-{
- osm_switch_t *p_sw;
- osm_physp_t *p_physp, *p_remote_physp;
- cl_qlist_t list;
- cl_map_item_t *item;
- struct updn_node *u, *remote_u;
- uint8_t num_ports, port_num;
- osm_log_t *p_log = &p_updn->p_osm->log;
- unsigned max_rank = 0;
-
- OSM_LOG_ENTER(p_log);
- cl_qlist_init(&list);
-
- /* add all roots to the list */
- for (item = cl_qmap_head(&p_updn->p_osm->subn.sw_guid_tbl);
- item != cl_qmap_end(&p_updn->p_osm->subn.sw_guid_tbl);
- item = cl_qmap_next(item)) {
- p_sw = (osm_switch_t *)item;
- u = p_sw->priv;
- if (!u->rank)
- cl_qlist_insert_tail(&list, &u->list);
- }
-
- /* BFS the list till it's empty */
- while (!cl_is_qlist_empty(&list)) {
- u = (struct updn_node *)cl_qlist_remove_head(&list);
- /* Go over all remote nodes and rank them (if not already visited) */
- p_sw = u->sw;
- num_ports = p_sw->num_ports;
- OSM_LOG(p_log, OSM_LOG_DEBUG,
- "Handling switch GUID 0x%" PRIx64 "\n",
- cl_ntoh64(osm_node_get_node_guid(p_sw->p_node)));
- for (port_num = 1; port_num < num_ports; port_num++) {
- ib_net64_t port_guid;
-
- /* Current port fetched in order to get remote side */
- p_physp =
- osm_node_get_physp_ptr(p_sw->p_node, port_num);
-
- if (!p_physp)
- continue;
-
- p_remote_physp = p_physp->p_remote_physp;
-
- /*
- make sure that all the following occur on p_remote_physp:
- 1. The port isn't NULL
- 2. It is a switch
- */
- if (p_remote_physp && p_remote_physp->p_node->sw) {
- remote_u = p_remote_physp->p_node->sw->priv;
- port_guid = p_remote_physp->port_guid;
-
- if (remote_u->rank > u->rank + 1) {
- remote_u->rank = u->rank + 1;
- max_rank = remote_u->rank;
- cl_qlist_insert_tail(&list,
- &remote_u->list);
- OSM_LOG(p_log, OSM_LOG_DEBUG,
- "Rank of port GUID 0x%" PRIx64
- " = %u\n", cl_ntoh64(port_guid),
- remote_u->rank);
- }
- }
- }
- }
-
- /* Print Summary of ranking */
- OSM_LOG(p_log, OSM_LOG_VERBOSE,
- "Subnet ranking completed. Max Node Rank = %d\n", max_rank);
- OSM_LOG_EXIT(p_log);
- return 0;
-}
-
-/**********************************************************************
- **********************************************************************/
-/* hack: preserve min hops entries to any other root switches */
-static void updn_clear_root_hops(updn_t * p_updn, osm_switch_t * p_sw)
-{
- osm_port_t *p_port;
- unsigned i;
-
- for (i = 0; i < p_sw->num_hops; i++)
- if (p_sw->hops[i]) {
- p_port =
- cl_ptr_vector_get(&p_updn->p_osm->subn.port_lid_tbl,
- i);
- if (!p_port || !p_port->p_node->sw
- || ((struct updn_node *)p_port->p_node->sw->priv)->
- rank != 0)
- memset(p_sw->hops[i], 0xff, p_sw->num_ports);
- }
-}
-
-/**********************************************************************
- **********************************************************************/
-static int updn_set_min_hop_table(IN updn_t * p_updn)
-{
- osm_subn_t *p_subn = &p_updn->p_osm->subn;
- osm_log_t *p_log = &p_updn->p_osm->log;
- osm_switch_t *p_sw;
- cl_map_item_t *item;
-
- OSM_LOG_ENTER(p_log);
-
- /* Go over all the switches in the subnet - for each init their Min Hop
- Table */
- OSM_LOG(p_log, OSM_LOG_VERBOSE,
- "Init Min Hop Table of all switches [\n");
-
- for (item = cl_qmap_head(&p_updn->p_osm->subn.sw_guid_tbl);
- item != cl_qmap_end(&p_updn->p_osm->subn.sw_guid_tbl);
- item = cl_qmap_next(item)) {
- p_sw = (osm_switch_t *)item;
- /* Clear Min Hop Table */
- if (p_subn->opt.connect_roots)
- updn_clear_root_hops(p_updn, p_sw);
- else
- osm_switch_clear_hops(p_sw);
- }
-
- OSM_LOG(p_log, OSM_LOG_VERBOSE,
- "Init Min Hop Table of all switches ]\n");
-
- /* Now do the BFS for each port in the subnet */
- OSM_LOG(p_log, OSM_LOG_VERBOSE,
- "BFS through all port guids in the subnet [\n");
-
- for (item = cl_qmap_head(&p_updn->p_osm->subn.sw_guid_tbl);
- item != cl_qmap_end(&p_updn->p_osm->subn.sw_guid_tbl);
- item = cl_qmap_next(item)) {
- p_sw = (osm_switch_t *)item;
- updn_bfs_by_node(p_log, p_subn, p_sw);
- }
-
- OSM_LOG(p_log, OSM_LOG_VERBOSE,
- "BFS through all port guids in the subnet ]\n");
- /* Cleanup */
- OSM_LOG_EXIT(p_log);
- return 0;
-}
-
-/**********************************************************************
- **********************************************************************/
-static int updn_build_lid_matrices(IN updn_t * p_updn)
-{
- int status;
-
- OSM_LOG_ENTER(&p_updn->p_osm->log);
-
- OSM_LOG(&p_updn->p_osm->log, OSM_LOG_VERBOSE,
- "Ranking all port guids in the list\n");
- if (!p_updn->num_roots) {
- OSM_LOG(&p_updn->p_osm->log, OSM_LOG_ERROR, "ERR AA0A: "
- "No guids were provided or number of guids is 0\n");
- status = -1;
- goto _exit;
- }
-
- /* Check if it's not a switched subnet */
- if (cl_is_qmap_empty(&p_updn->p_osm->subn.sw_guid_tbl)) {
- OSM_LOG(&p_updn->p_osm->log, OSM_LOG_ERROR, "ERR AAOB: "
- "This is not a switched subnet, cannot perform UPDN algorithm\n");
- status = -1;
- goto _exit;
- }
-
- /* Rank the subnet switches */
- updn_subn_rank(p_updn);
-
- /* After multiple ranking need to set Min Hop Table by UpDn algorithm */
- OSM_LOG(&p_updn->p_osm->log, OSM_LOG_VERBOSE,
- "Setting all switches' Min Hop Table\n");
- status = updn_set_min_hop_table(p_updn);
-
-_exit:
- OSM_LOG_EXIT(&p_updn->p_osm->log);
- return status;
-}
-
-/**********************************************************************
- **********************************************************************/
-static struct updn_node *create_updn_node(osm_switch_t * sw)
-{
- struct updn_node *u;
-
- u = malloc(sizeof(*u));
- if (!u)
- return NULL;
- memset(u, 0, sizeof(*u));
- u->sw = sw;
- u->id = cl_ntoh64(osm_node_get_node_guid(sw->p_node));
- u->rank = 0xffffffff;
- return u;
-}
-
-static void delete_updn_node(struct updn_node *u)
-{
- u->sw->priv = NULL;
- free(u);
-}
-
-/**********************************************************************
- **********************************************************************/
-/* Find Root nodes automatically by Min Hop Table info */
-static void updn_find_root_nodes_by_min_hop(OUT updn_t * p_updn)
-{
- osm_opensm_t *p_osm = p_updn->p_osm;
- osm_switch_t *p_sw;
- osm_port_t *p_port;
- osm_physp_t *p_physp;
- cl_map_item_t *item;
- double thd1, thd2;
- unsigned i, cas_num = 0;
- unsigned *cas_per_sw;
- uint16_t lid_ho;
-
- OSM_LOG_ENTER(&p_osm->log);
-
- OSM_LOG(&p_osm->log, OSM_LOG_DEBUG,
- "Current number of ports in the subnet is %d\n",
- cl_qmap_count(&p_osm->subn.port_guid_tbl));
-
- cas_per_sw = malloc((IB_LID_UCAST_END_HO + 1) * sizeof(*cas_per_sw));
- if (!cas_per_sw) {
- OSM_LOG(&p_osm->log, OSM_LOG_ERROR, "ERR AA14: "
- "cannot alloc mem for CAs per switch counter array\n");
- goto _exit;
- }
- memset(cas_per_sw, 0, (IB_LID_UCAST_END_HO + 1) * sizeof(*cas_per_sw));
-
- /* Find the Maximum number of CAs (and routers) for histogram normalization */
- OSM_LOG(&p_osm->log, OSM_LOG_VERBOSE,
- "Finding the number of CAs and storing them in cl_map\n");
- for (item = cl_qmap_head(&p_updn->p_osm->subn.port_guid_tbl);
- item != cl_qmap_end(&p_updn->p_osm->subn.port_guid_tbl);
- item = cl_qmap_next(item)) {
- p_port = (osm_port_t *)item;
- if (!p_port->p_node->sw) {
- p_physp = p_port->p_physp->p_remote_physp;
- if (!p_physp || !p_physp->p_node->sw)
- continue;
- lid_ho = osm_node_get_base_lid(p_physp->p_node, 0);
- lid_ho = cl_ntoh16(lid_ho);
- cas_per_sw[lid_ho]++;
- cas_num++;
- }
- }
-
- thd1 = cas_num * 0.9;
- thd2 = cas_num * 0.05;
- OSM_LOG(&p_osm->log, OSM_LOG_DEBUG,
- "Found %u CAs and RTRs, %u SWs in the subnet. "
- "Thresholds are thd1 = %f && thd2 = %f\n",
- cas_num, cl_qmap_count(&p_osm->subn.sw_guid_tbl), thd1, thd2);
-
- OSM_LOG(&p_osm->log, OSM_LOG_VERBOSE,
- "Passing through all switches to collect Min Hop info\n");
- for (item = cl_qmap_head(&p_updn->p_osm->subn.sw_guid_tbl);
- item != cl_qmap_end(&p_updn->p_osm->subn.sw_guid_tbl);
- item = cl_qmap_next(item)) {
- unsigned hop_hist[IB_SUBNET_PATH_HOPS_MAX];
- uint16_t max_lid_ho;
- uint8_t hop_val;
- uint16_t numHopBarsOverThd1 = 0;
- uint16_t numHopBarsOverThd2 = 0;
-
- p_sw = (osm_switch_t *) item;
-
- memset(hop_hist, 0, sizeof(hop_hist));
-
- max_lid_ho = p_sw->max_lid_ho;
- for (lid_ho = 1; lid_ho <= max_lid_ho; lid_ho++)
- if (cas_per_sw[lid_ho]) {
- hop_val =
- osm_switch_get_least_hops(p_sw, lid_ho);
- if (hop_val >= IB_SUBNET_PATH_HOPS_MAX)
- continue;
-
- hop_hist[hop_val] += cas_per_sw[lid_ho];
- }
-
- /* Now recognize the spines by requiring one bar to be
- above 90% of the number of CAs and RTRs */
- for (i = 0; i < IB_SUBNET_PATH_HOPS_MAX; i++) {
- if (hop_hist[i] > thd1)
- numHopBarsOverThd1++;
- if (hop_hist[i] > thd2)
- numHopBarsOverThd2++;
- }
-
- /* If thd conditions are valid - rank the root node */
- if (numHopBarsOverThd1 == 1 && numHopBarsOverThd2 == 1) {
- OSM_LOG(&p_osm->log, OSM_LOG_DEBUG,
- "Ranking GUID 0x%" PRIx64 " as root node\n",
- cl_ntoh64(osm_node_get_node_guid(p_sw->p_node)));
- ((struct updn_node *)p_sw->priv)->rank = 0;
- p_updn->num_roots++;
- }
- }
-
- free(cas_per_sw);
-_exit:
- OSM_LOG_EXIT(&p_osm->log);
- return;
-}
-
-/**********************************************************************
- **********************************************************************/
-static void dump_roots(cl_map_item_t *item, FILE *file, void *cxt)
-{
- osm_switch_t *sw = (osm_switch_t *)item;
- if (!((struct updn_node *)sw->priv)->rank)
- fprintf(file, "0x%" PRIx64 "\n",
- cl_ntoh64(osm_node_get_node_guid(sw->p_node)));
-}
-
-static int update_id(void *cxt, uint64_t guid, char *p)
-{
- osm_opensm_t *osm = cxt;
- osm_switch_t *sw;
- uint64_t id;
- char *e;
-
- sw = osm_get_switch_by_guid(&osm->subn, cl_hton64(guid));
- if (!sw) {
- OSM_LOG(&osm->log, OSM_LOG_VERBOSE,
- "switch with guid 0x%" PRIx64 " is not found\n", guid);
- return 0;
- }
-
- id = strtoull(p, &e, 0);
- if (*e && !isspace(*e)) {
- OSM_LOG(&osm->log, OSM_LOG_ERROR,
- "ERR: cannot parse node id \'%s\'", p);
- return -1;
- }
-
- OSM_LOG(&osm->log, OSM_LOG_DEBUG,
- "update node 0x%" PRIx64 " id to 0x%" PRIx64 "\n", guid, id);
-
- ((struct updn_node *)sw->priv)->id = id;
-
- return 0;
-}
-
-static int rank_root_node(void *cxt, uint64_t guid, char *p)
-{
- updn_t *updn = cxt;
- osm_switch_t *sw;
-
- sw = osm_get_switch_by_guid(&updn->p_osm->subn, cl_hton64(guid));
- if (!sw) {
- OSM_LOG(&updn->p_osm->log, OSM_LOG_VERBOSE,
- "switch with guid 0x%" PRIx64 " is not found\n", guid);
- return 0;
- }
-
- OSM_LOG(&updn->p_osm->log, OSM_LOG_DEBUG,
- "Ranking root port GUID 0x%" PRIx64 "\n", guid);
-
- ((struct updn_node *)sw->priv)->rank = 0;
- updn->num_roots++;
-
- return 0;
-}
-
-/* UPDN callback function */
-static int updn_lid_matrices(void *ctx)
-{
- updn_t *p_updn = ctx;
- cl_map_item_t *item;
- osm_switch_t *p_sw;
- int ret = 0;
-
- OSM_LOG_ENTER(&p_updn->p_osm->log);
-
- for (item = cl_qmap_head(&p_updn->p_osm->subn.sw_guid_tbl);
- item != cl_qmap_end(&p_updn->p_osm->subn.sw_guid_tbl);
- item = cl_qmap_next(item)) {
- p_sw = (osm_switch_t *)item;
- p_sw->priv = create_updn_node(p_sw);
- if (!p_sw->priv) {
- OSM_LOG(&(p_updn->p_osm->log), OSM_LOG_ERROR, "ERR AA0C: "
- "cannot create updn node\n");
- OSM_LOG_EXIT(&p_updn->p_osm->log);
- return -1;
- }
- }
-
- /* First setup root nodes */
- p_updn->num_roots = 0;
-
- if (p_updn->p_osm->subn.opt.root_guid_file) {
- OSM_LOG(&p_updn->p_osm->log, OSM_LOG_DEBUG,
- "UPDN - Fetching root nodes from file \'%s\'\n",
- p_updn->p_osm->subn.opt.root_guid_file);
-
- ret = parse_node_map(p_updn->p_osm->subn.opt.root_guid_file,
- rank_root_node, p_updn);
- if (ret)
- OSM_LOG(&p_updn->p_osm->log, OSM_LOG_ERROR, "ERR : "
- "cannot parse root guids file \'%s\'\n",
- p_updn->p_osm->subn.opt.root_guid_file);
- if (p_updn->p_osm->subn.opt.connect_roots &&
- p_updn->num_roots > 1)
- osm_ucast_mgr_build_lid_matrices(&p_updn->p_osm->sm.ucast_mgr);
- } else {
- osm_ucast_mgr_build_lid_matrices(&p_updn->p_osm->sm.ucast_mgr);
- updn_find_root_nodes_by_min_hop(p_updn);
- }
-
- if (p_updn->p_osm->subn.opt.ids_guid_file) {
- OSM_LOG(&p_updn->p_osm->log, OSM_LOG_DEBUG,
- "UPDN - update node ids from file \'%s\'\n",
- p_updn->p_osm->subn.opt.ids_guid_file);
-
- ret = parse_node_map(p_updn->p_osm->subn.opt.ids_guid_file,
- update_id, p_updn->p_osm);
- if (ret)
- OSM_LOG(&p_updn->p_osm->log, OSM_LOG_ERROR, "ERR : "
- "cannot parse node ids file \'%s\'\n",
- p_updn->p_osm->subn.opt.ids_guid_file);
- }
-
- /* Only if there are assigned root nodes do the algorithm, otherwise perform do nothing */
- if (p_updn->num_roots) {
- OSM_LOG(&p_updn->p_osm->log, OSM_LOG_DEBUG,
- "activating UPDN algorithm\n");
- ret = updn_build_lid_matrices(p_updn);
- } else {
- OSM_LOG(&p_updn->p_osm->log, OSM_LOG_INFO,
- "disabling UPDN algorithm, no root nodes were found\n");
- ret = -1;
- }
-
- if (osm_log_is_active(&p_updn->p_osm->log, OSM_LOG_ROUTING))
- osm_dump_qmap_to_file(p_updn->p_osm, "opensm-updn-roots.dump",
- &p_updn->p_osm->subn.sw_guid_tbl,
- dump_roots, NULL);
-
- for (item = cl_qmap_head(&p_updn->p_osm->subn.sw_guid_tbl);
- item != cl_qmap_end(&p_updn->p_osm->subn.sw_guid_tbl);
- item = cl_qmap_next(item)) {
- p_sw = (osm_switch_t *) item;
- delete_updn_node(p_sw->priv);
- }
-
- OSM_LOG_EXIT(&p_updn->p_osm->log);
- return ret;
-}
-
-/**********************************************************************
- **********************************************************************/
-static void updn_delete(void *context)
-{
- free(context);
-}
-
-int osm_ucast_updn_setup(struct osm_routing_engine *r, osm_opensm_t *osm)
-{
- updn_t *updn;
-
- updn = malloc(sizeof(updn_t));
- if (!updn)
- return -1;
- memset(updn, 0, sizeof(updn_t));
-
- updn->p_osm = osm;
-
- r->context = updn;
- r->delete = updn_delete;
- r->build_lid_matrices = updn_lid_matrices;
-
- return 0;
-}
diff --git a/contrib/ofed/management/opensm/opensm/osm_vl15intf.c b/contrib/ofed/management/opensm/opensm/osm_vl15intf.c
deleted file mode 100644
index 0703a4f..0000000
--- a/contrib/ofed/management/opensm/opensm/osm_vl15intf.c
+++ /dev/null
@@ -1,386 +0,0 @@
-/*
- * Copyright (c) 2004-2008 Voltaire, Inc. All rights reserved.
- * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved.
- * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- */
-
-/*
- * Abstract:
- * Implementation of osm_vl15_t.
- * This object represents the VL15 Interface object.
- * This object is part of the opensm family of objects.
- */
-
-#if HAVE_CONFIG_H
-# include <config.h>
-#endif /* HAVE_CONFIG_H */
-
-#include <string.h>
-#include <iba/ib_types.h>
-#include <complib/cl_thread.h>
-#include <vendor/osm_vendor_api.h>
-#include <opensm/osm_vl15intf.h>
-#include <opensm/osm_madw.h>
-#include <opensm/osm_log.h>
-#include <opensm/osm_helper.h>
-
-/**********************************************************************
- **********************************************************************/
-
-static void vl15_send_mad(osm_vl15_t * p_vl, osm_madw_t * p_madw)
-{
- ib_api_status_t status;
-
- /*
- Non-response-expected mads are not throttled on the wire
- since we can have no confirmation that they arrived
- at their destination.
- */
- if (p_madw->resp_expected == TRUE)
- /*
- Note that other threads may not see the response MAD
- arrive before send() even returns.
- In that case, the wire count would temporarily go negative.
- To avoid this confusion, preincrement the counts on the
- assumption that send() will succeed.
- */
- cl_atomic_inc(&p_vl->p_stats->qp0_mads_outstanding_on_wire);
- else
- cl_atomic_inc(&p_vl->p_stats->qp0_unicasts_sent);
-
- cl_atomic_inc(&p_vl->p_stats->qp0_mads_sent);
-
- status = osm_vendor_send(osm_madw_get_bind_handle(p_madw),
- p_madw, p_madw->resp_expected);
-
- if (status == IB_SUCCESS) {
- OSM_LOG(p_vl->p_log, OSM_LOG_DEBUG,
- "%u QP0 MADs on wire, %u outstanding, "
- "%u unicasts sent, %u total sent\n",
- p_vl->p_stats->qp0_mads_outstanding_on_wire,
- p_vl->p_stats->qp0_mads_outstanding,
- p_vl->p_stats->qp0_unicasts_sent,
- p_vl->p_stats->qp0_mads_sent);
- return;
- }
-
- OSM_LOG(p_vl->p_log, OSM_LOG_ERROR, "ERR 3E03: "
- "MAD send failed (%s)\n", ib_get_err_str(status));
-
- /*
- The MAD was never successfully sent, so
- fix up the pre-incremented count values.
- */
-
- /* Decrement qp0_mads_sent that were incremented in the code above.
- qp0_mads_outstanding will be decremented by send error callback
- (called by osm_vendor_send() */
- cl_atomic_dec(&p_vl->p_stats->qp0_mads_sent);
- if (!p_madw->resp_expected)
- cl_atomic_dec(&p_vl->p_stats->qp0_unicasts_sent);
-}
-
-static void __osm_vl15_poller(IN void *p_ptr)
-{
- ib_api_status_t status;
- osm_madw_t *p_madw;
- osm_vl15_t *const p_vl = (osm_vl15_t *) p_ptr;
- cl_qlist_t *p_fifo;
-
- OSM_LOG_ENTER(p_vl->p_log);
-
- if (p_vl->thread_state == OSM_THREAD_STATE_NONE)
- p_vl->thread_state = OSM_THREAD_STATE_RUN;
-
- while (p_vl->thread_state == OSM_THREAD_STATE_RUN) {
- /*
- Start servicing the FIFOs by pulling off MAD wrappers
- and passing them to the transport interface.
- There are lots of corner cases here so tread carefully.
-
- The unicast FIFO has priority, since somebody is waiting
- for a timely response.
- */
- cl_spinlock_acquire(&p_vl->lock);
-
- if (cl_qlist_count(&p_vl->ufifo) != 0)
- p_fifo = &p_vl->ufifo;
- else
- p_fifo = &p_vl->rfifo;
-
- p_madw = (osm_madw_t *) cl_qlist_remove_head(p_fifo);
-
- cl_spinlock_release(&p_vl->lock);
-
- if (p_madw != (osm_madw_t *) cl_qlist_end(p_fifo)) {
- OSM_LOG(p_vl->p_log, OSM_LOG_DEBUG,
- "Servicing p_madw = %p\n", p_madw);
- if (osm_log_is_active(p_vl->p_log, OSM_LOG_FRAMES))
- osm_dump_dr_smp(p_vl->p_log,
- osm_madw_get_smp_ptr(p_madw),
- OSM_LOG_FRAMES);
-
- vl15_send_mad(p_vl, p_madw);
- } else
- /*
- The VL15 FIFO is empty, so we have nothing left to do.
- */
- status = cl_event_wait_on(&p_vl->signal,
- EVENT_NO_TIMEOUT, TRUE);
-
- while ((p_vl->p_stats->qp0_mads_outstanding_on_wire >=
- (int32_t) p_vl->max_wire_smps) &&
- (p_vl->thread_state == OSM_THREAD_STATE_RUN)) {
- status = cl_event_wait_on(&p_vl->signal,
- EVENT_NO_TIMEOUT, TRUE);
- if (status != CL_SUCCESS) {
- OSM_LOG(p_vl->p_log, OSM_LOG_ERROR, "ERR 3E02: "
- "Event wait failed (%s)\n",
- CL_STATUS_MSG(status));
- break;
- }
- }
- }
-
- /*
- since we abort immediately when the state != OSM_THREAD_STATE_RUN
- we might have some mads on the queues. After the thread exits
- the vl15 destroy routine should put these mads back...
- */
-
- OSM_LOG_EXIT(p_vl->p_log);
-}
-
-/**********************************************************************
- **********************************************************************/
-void osm_vl15_construct(IN osm_vl15_t * const p_vl)
-{
- memset(p_vl, 0, sizeof(*p_vl));
- p_vl->state = OSM_VL15_STATE_INIT;
- p_vl->thread_state = OSM_THREAD_STATE_NONE;
- cl_event_construct(&p_vl->signal);
- cl_spinlock_construct(&p_vl->lock);
- cl_qlist_init(&p_vl->rfifo);
- cl_qlist_init(&p_vl->ufifo);
- cl_thread_construct(&p_vl->poller);
-}
-
-/**********************************************************************
- **********************************************************************/
-void
-osm_vl15_destroy(IN osm_vl15_t * const p_vl, IN struct osm_mad_pool *p_pool)
-{
- osm_madw_t *p_madw;
-
- OSM_LOG_ENTER(p_vl->p_log);
-
- /*
- Signal our threads that we're leaving.
- */
- p_vl->thread_state = OSM_THREAD_STATE_EXIT;
-
- /*
- Don't trigger unless event has been initialized.
- Destroy the thread before we tear down the other objects.
- */
- if (p_vl->state != OSM_VL15_STATE_INIT)
- cl_event_signal(&p_vl->signal);
-
- cl_thread_destroy(&p_vl->poller);
-
- /*
- Return the outstanding messages to the pool
- */
-
- cl_spinlock_acquire(&p_vl->lock);
-
- while (!cl_is_qlist_empty(&p_vl->rfifo)) {
- p_madw = (osm_madw_t *) cl_qlist_remove_head(&p_vl->rfifo);
- osm_mad_pool_put(p_pool, p_madw);
- }
- while (!cl_is_qlist_empty(&p_vl->ufifo)) {
- p_madw = (osm_madw_t *) cl_qlist_remove_head(&p_vl->ufifo);
- osm_mad_pool_put(p_pool, p_madw);
- }
-
- cl_spinlock_release(&p_vl->lock);
-
- cl_event_destroy(&p_vl->signal);
- p_vl->state = OSM_VL15_STATE_INIT;
- cl_spinlock_destroy(&p_vl->lock);
-
- OSM_LOG_EXIT(p_vl->p_log);
-}
-
-/**********************************************************************
- **********************************************************************/
-ib_api_status_t
-osm_vl15_init(IN osm_vl15_t * const p_vl,
- IN osm_vendor_t * const p_vend,
- IN osm_log_t * const p_log,
- IN osm_stats_t * const p_stats, IN const int32_t max_wire_smps)
-{
- ib_api_status_t status = IB_SUCCESS;
-
- OSM_LOG_ENTER(p_log);
-
- p_vl->p_vend = p_vend;
- p_vl->p_log = p_log;
- p_vl->p_stats = p_stats;
- p_vl->max_wire_smps = max_wire_smps;
-
- status = cl_event_init(&p_vl->signal, FALSE);
- if (status != IB_SUCCESS)
- goto Exit;
-
- p_vl->state = OSM_VL15_STATE_READY;
-
- status = cl_spinlock_init(&p_vl->lock);
- if (status != IB_SUCCESS)
- goto Exit;
-
- /*
- Initialize the thread after all other dependent objects
- have been initialized.
- */
- status = cl_thread_init(&p_vl->poller, __osm_vl15_poller, p_vl,
- "opensm poller");
- if (status != IB_SUCCESS)
- goto Exit;
-
-Exit:
- OSM_LOG_EXIT(p_log);
- return (status);
-}
-
-/**********************************************************************
- **********************************************************************/
-void osm_vl15_poll(IN osm_vl15_t * const p_vl)
-{
- OSM_LOG_ENTER(p_vl->p_log);
-
- CL_ASSERT(p_vl->state == OSM_VL15_STATE_READY);
-
- /*
- If we have room for more VL15 MADs on the wire,
- then signal the poller thread.
-
- This is not an airtight check, since the poller thread
- could be just about to send another MAD as we signal
- the event here. To cover this rare case, the poller
- thread checks for a spurious wake-up.
- */
- if (p_vl->p_stats->qp0_mads_outstanding_on_wire <
- (int32_t) p_vl->max_wire_smps) {
- OSM_LOG(p_vl->p_log, OSM_LOG_DEBUG,
- "Signalling poller thread\n");
- cl_event_signal(&p_vl->signal);
- }
-
- OSM_LOG_EXIT(p_vl->p_log);
-}
-
-/**********************************************************************
- **********************************************************************/
-void osm_vl15_post(IN osm_vl15_t * const p_vl, IN osm_madw_t * const p_madw)
-{
- OSM_LOG_ENTER(p_vl->p_log);
-
- CL_ASSERT(p_vl->state == OSM_VL15_STATE_READY);
-
- OSM_LOG(p_vl->p_log, OSM_LOG_DEBUG, "Posting p_madw = 0x%p\n", p_madw);
-
- /*
- Determine in which fifo to place the pending madw.
- */
- cl_spinlock_acquire(&p_vl->lock);
- if (p_madw->resp_expected == TRUE) {
- cl_qlist_insert_tail(&p_vl->rfifo, &p_madw->list_item);
- osm_stats_inc_qp0_outstanding(p_vl->p_stats);
- } else
- cl_qlist_insert_tail(&p_vl->ufifo, &p_madw->list_item);
- cl_spinlock_release(&p_vl->lock);
-
- OSM_LOG(p_vl->p_log, OSM_LOG_DEBUG,
- "%u QP0 MADs on wire, %u QP0 MADs outstanding\n",
- p_vl->p_stats->qp0_mads_outstanding_on_wire,
- p_vl->p_stats->qp0_mads_outstanding);
-
- osm_vl15_poll(p_vl);
-
- OSM_LOG_EXIT(p_vl->p_log);
-}
-
-void
-osm_vl15_shutdown(IN osm_vl15_t * const p_vl,
- IN osm_mad_pool_t * const p_mad_pool)
-{
- osm_madw_t *p_madw;
-
- OSM_LOG_ENTER(p_vl->p_log);
-
- /* we only should get here after the VL15 interface was initialized */
- CL_ASSERT(p_vl->state == OSM_VL15_STATE_READY);
-
- /* grap a lock on the object */
- cl_spinlock_acquire(&p_vl->lock);
-
- /* go over all outstanding MADs and retire their transactions */
-
- /* first we handle the list of response MADs */
- p_madw = (osm_madw_t *) cl_qlist_remove_head(&p_vl->ufifo);
- while (p_madw != (osm_madw_t *) cl_qlist_end(&p_vl->ufifo)) {
- OSM_LOG(p_vl->p_log, OSM_LOG_DEBUG,
- "Releasing Response p_madw = %p\n", p_madw);
-
- osm_mad_pool_put(p_mad_pool, p_madw);
-
- p_madw = (osm_madw_t *) cl_qlist_remove_head(&p_vl->ufifo);
- }
-
- /* Request MADs we send out */
- p_madw = (osm_madw_t *) cl_qlist_remove_head(&p_vl->rfifo);
- while (p_madw != (osm_madw_t *) cl_qlist_end(&p_vl->rfifo)) {
- OSM_LOG(p_vl->p_log, OSM_LOG_DEBUG,
- "Releasing Request p_madw = %p\n", p_madw);
-
- osm_mad_pool_put(p_mad_pool, p_madw);
- osm_stats_dec_qp0_outstanding(p_vl->p_stats);
-
- p_madw = (osm_madw_t *) cl_qlist_remove_head(&p_vl->rfifo);
- }
-
- /* free the lock */
- cl_spinlock_release(&p_vl->lock);
-
- OSM_LOG_EXIT(p_vl->p_log);
-}
diff --git a/contrib/ofed/management/opensm/opensm/osm_vl_arb_rcv.c b/contrib/ofed/management/opensm/opensm/osm_vl_arb_rcv.c
deleted file mode 100644
index ec04d67..0000000
--- a/contrib/ofed/management/opensm/opensm/osm_vl_arb_rcv.c
+++ /dev/null
@@ -1,154 +0,0 @@
-/*
- * Copyright (c) 2004-2008 Voltaire, Inc. All rights reserved.
- * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved.
- * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- */
-
-/*
- * Abstract:
- * Implementation of osm_vla_rcv_t.
- * This object represents the Vl Arbitration Receiver object.
- * This object is part of the opensm family of objects.
- */
-
-#if HAVE_CONFIG_H
-# include <config.h>
-#endif /* HAVE_CONFIG_H */
-
-#include <string.h>
-#include <iba/ib_types.h>
-#include <complib/cl_passivelock.h>
-#include <complib/cl_debug.h>
-#include <opensm/osm_madw.h>
-#include <opensm/osm_log.h>
-#include <opensm/osm_node.h>
-#include <opensm/osm_subnet.h>
-#include <opensm/osm_helper.h>
-#include <opensm/osm_sm.h>
-
-/**********************************************************************
- **********************************************************************/
-/*
- * WE MIGHT ONLY RECEIVE GET or SET responses
- */
-void osm_vla_rcv_process(IN void *context, IN void *data)
-{
- osm_sm_t *sm = context;
- osm_madw_t *p_madw = data;
- ib_vl_arb_table_t *p_vla_tbl;
- ib_smp_t *p_smp;
- osm_port_t *p_port;
- osm_physp_t *p_physp;
- osm_node_t *p_node;
- osm_vla_context_t *p_context;
- ib_net64_t port_guid;
- ib_net64_t node_guid;
- uint8_t port_num, block_num;
-
- CL_ASSERT(sm);
-
- OSM_LOG_ENTER(sm->p_log);
-
- CL_ASSERT(p_madw);
-
- p_smp = osm_madw_get_smp_ptr(p_madw);
-
- p_context = osm_madw_get_vla_context_ptr(p_madw);
- p_vla_tbl = (ib_vl_arb_table_t *) ib_smp_get_payload_ptr(p_smp);
-
- port_guid = p_context->port_guid;
- node_guid = p_context->node_guid;
-
- CL_ASSERT(p_smp->attr_id == IB_MAD_ATTR_VL_ARBITRATION);
-
- cl_plock_excl_acquire(sm->p_lock);
- p_port = osm_get_port_by_guid(sm->p_subn, port_guid);
- if (!p_port) {
- cl_plock_release(sm->p_lock);
- OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR 3F06: "
- "No port object for port with GUID 0x%" PRIx64
- "\n\t\t\t\tfor parent node GUID 0x%" PRIx64
- ", TID 0x%" PRIx64 "\n",
- cl_ntoh64(port_guid),
- cl_ntoh64(node_guid), cl_ntoh64(p_smp->trans_id));
- goto Exit;
- }
-
- p_node = p_port->p_node;
- CL_ASSERT(p_node);
-
- block_num = (uint8_t) (cl_ntoh32(p_smp->attr_mod) >> 16);
- /* in case of a non switch node the attr modifier should be ignored */
- if (osm_node_get_type(p_node) == IB_NODE_TYPE_SWITCH) {
- port_num = (uint8_t) (cl_ntoh32(p_smp->attr_mod) & 0x000000FF);
- p_physp = osm_node_get_physp_ptr(p_node, port_num);
- } else {
- p_physp = p_port->p_physp;
- port_num = p_physp->port_num;
- }
-
- /*
- We do not mind if this is a result of a set or get - all we want is to update
- the subnet.
- */
- OSM_LOG(sm->p_log, OSM_LOG_VERBOSE,
- "Got GetResp(VLArb) block:%u port_num %u with GUID 0x%"
- PRIx64 " for parent node GUID 0x%" PRIx64 ", TID 0x%"
- PRIx64 "\n", block_num, port_num, cl_ntoh64(port_guid),
- cl_ntoh64(node_guid), cl_ntoh64(p_smp->trans_id));
-
- /*
- Determine if we encountered a new Physical Port.
- If so, Ignore it.
- */
- if (!p_physp) {
- OSM_LOG(sm->p_log, OSM_LOG_ERROR,
- "Got invalid port number %u\n", port_num);
- goto Exit;
- }
-
- osm_dump_vl_arb_table(sm->p_log,
- port_guid, block_num,
- port_num, p_vla_tbl, OSM_LOG_DEBUG);
-
- if ((block_num < 1) || (block_num > 4)) {
- OSM_LOG(sm->p_log, OSM_LOG_ERROR,
- "Got invalid block number 0x%X\n", block_num);
- goto Exit;
- }
- osm_physp_set_vla_tbl(p_physp, p_vla_tbl, block_num);
-
-Exit:
- cl_plock_release(sm->p_lock);
-
- OSM_LOG_EXIT(sm->p_log);
-}
diff --git a/contrib/ofed/management/opensm/opensm/st.c b/contrib/ofed/management/opensm/opensm/st.c
deleted file mode 100644
index c5a2f53..0000000
--- a/contrib/ofed/management/opensm/opensm/st.c
+++ /dev/null
@@ -1,588 +0,0 @@
-/*
- * Copyright (c) 2004-2006 Voltaire, Inc. All rights reserved.
- * Copyright (c) 2002-2006 Mellanox Technologies LTD. All rights reserved.
- * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- */
-
-/* static char sccsid[] = "@(#) st.c 5.1 89/12/14 Crucible"; */
-
-#if HAVE_CONFIG_H
-# include <config.h>
-#endif /* HAVE_CONFIG_H */
-
-#include <stdio.h>
-#include <string.h>
-#include <opensm/st.h>
-
-#ifdef _WIN32
-#include <malloc.h>
-#endif
-
-typedef struct st_table_entry st_table_entry;
-
-struct st_table_entry {
- unsigned int hash;
- st_data_t key;
- st_data_t record;
- st_table_entry *next;
-};
-
-#define ST_DEFAULT_MAX_DENSITY 5
-#define ST_DEFAULT_INIT_TABLE_SIZE 11
-
-/*
- * DEFAULT_MAX_DENSITY is the default for the largest we allow the
- * average number of items per bin before increasing the number of
- * bins
- *
- * DEFAULT_INIT_TABLE_SIZE is the default for the number of bins
- * allocated initially
- *
- */
-static int numcmp(void *, void *);
-static st_ptr_t numhash(void *);
-static struct st_hash_type type_numhash = {
- numcmp,
- numhash,
-};
-
-/* extern int strcmp(const char *, const char *); */
-static int strhash(const char *);
-
-static inline st_ptr_t st_strhash(void *key)
-{
- return strhash((const char *)key);
-}
-
-static inline int st_strcmp(void *key1, void *key2)
-{
- return strcmp((const char *)key1, (const char *)key2);
-}
-
-static struct st_hash_type type_strhash = {
- st_strcmp,
- st_strhash
-};
-
-#define xmalloc malloc
-#define xcalloc calloc
-#define xrealloc realloc
-#define xfree free
-
-static void rehash(st_table *);
-
-#define alloc(type) (type*)xmalloc(sizeof(type))
-#define Calloc(n,s) (char*)xcalloc((n), (s))
-
-#define EQUAL(table,x,y) ((x)==(y) || (*table->type->compare)(((void*)x),((void *)y)) == 0)
-
-#define do_hash(key,table) (unsigned int)(*(table)->type->hash)(((void*)key))
-#define do_hash_bin(key,table) (do_hash(key, table)%(table)->num_bins)
-
-/*
- * MINSIZE is the minimum size of a dictionary.
- */
-
-#define MINSIZE 8
-
-/*
- Table of prime numbers 2^n+a, 2<=n<=30.
-*/
-static long primes[] = {
- 8 + 3,
- 16 + 3,
- 32 + 5,
- 64 + 3,
- 128 + 3,
- 256 + 27,
- 512 + 9,
- 1024 + 9,
- 2048 + 5,
- 4096 + 3,
- 8192 + 27,
- 16384 + 43,
- 32768 + 3,
- 65536 + 45,
- 131072 + 29,
- 262144 + 3,
- 524288 + 21,
- 1048576 + 7,
- 2097152 + 17,
- 4194304 + 15,
- 8388608 + 9,
- 16777216 + 43,
- 33554432 + 35,
- 67108864 + 15,
- 134217728 + 29,
- 268435456 + 3,
- 536870912 + 11,
- 1073741824 + 85,
- 0
-};
-
-static int new_size(int size)
-{
- int i;
-
-#if 0
- for (i = 3; i < 31; i++) {
- if ((1 << i) > size)
- return 1 << i;
- }
- return -1;
-#else
- int newsize;
-
- for (i = 0, newsize = MINSIZE;
- i < sizeof(primes) / sizeof(primes[0]); i++, newsize <<= 1) {
- if (newsize > size)
- return primes[i];
- }
- /* Ran out of polynomials */
- return -1; /* should raise exception */
-#endif
-}
-
-#ifdef HASH_LOG
-static int collision = 0;
-static int init_st = 0;
-
-static void stat_col()
-{
- FILE *f = fopen("/var/log/osm_st_col", "w");
- fprintf(f, "collision: %d\n", collision);
- fclose(f);
-}
-#endif
-
-st_table *st_init_table_with_size(type, size)
-struct st_hash_type *type;
-size_t size;
-{
- st_table *tbl;
-
-#ifdef HASH_LOG
- if (init_st == 0) {
- init_st = 1;
- atexit(stat_col);
- }
-#endif
-
- size = new_size(size); /* round up to prime number */
-
- tbl = alloc(st_table);
- tbl->type = type;
- tbl->num_entries = 0;
- tbl->num_bins = size;
- tbl->bins = (st_table_entry **) Calloc(size, sizeof(st_table_entry *));
-
- return tbl;
-}
-
-st_table *st_init_table(type)
-struct st_hash_type *type;
-{
- return st_init_table_with_size(type, 0);
-}
-
-st_table *st_init_numtable(void)
-{
- return st_init_table(&type_numhash);
-}
-
-st_table *st_init_numtable_with_size(size)
-size_t size;
-{
- return st_init_table_with_size(&type_numhash, size);
-}
-
-st_table *st_init_strtable(void)
-{
- return st_init_table(&type_strhash);
-}
-
-st_table *st_init_strtable_with_size(size)
-size_t size;
-{
- return st_init_table_with_size(&type_strhash, size);
-}
-
-void st_free_table(table)
-st_table *table;
-{
- register st_table_entry *ptr, *next;
- int i;
-
- for (i = 0; i < table->num_bins; i++) {
- ptr = table->bins[i];
- while (ptr != 0) {
- next = ptr->next;
- free(ptr);
- ptr = next;
- }
- }
- free(table->bins);
- free(table);
-}
-
-#define PTR_NOT_EQUAL(table, ptr, hash_val, key) \
-((ptr) != 0 && (ptr->hash != (hash_val) || !EQUAL((table), (key), (ptr)->key)))
-
-#ifdef HASH_LOG
-#define COLLISION collision++
-#else
-#define COLLISION
-#endif
-
-#define FIND_ENTRY(table, ptr, hash_val, bin_pos) do {\
- bin_pos = hash_val%(table)->num_bins;\
- ptr = (table)->bins[bin_pos];\
- if (PTR_NOT_EQUAL(table, ptr, hash_val, key)) \
- {\
- COLLISION;\
- while (PTR_NOT_EQUAL(table, ptr->next, hash_val, key)) {\
- ptr = ptr->next;\
- }\
- ptr = ptr->next;\
- }\
-} while (0)
-
-int st_lookup(table, key, value)
-st_table *table;
-register st_data_t key;
-st_data_t *value;
-{
- unsigned int hash_val, bin_pos;
- register st_table_entry *ptr;
-
- hash_val = do_hash(key, table);
- FIND_ENTRY(table, ptr, hash_val, bin_pos);
-
- if (ptr == 0) {
- return 0;
- } else {
- if (value != 0)
- *value = ptr->record;
- return 1;
- }
-}
-
-#define ADD_DIRECT(table, key, value, hash_val, bin_pos)\
-do {\
- st_table_entry *entry;\
- if (table->num_entries/(table->num_bins) > ST_DEFAULT_MAX_DENSITY) \
- {\
- rehash(table);\
- bin_pos = hash_val % table->num_bins;\
- }\
- \
- entry = alloc(st_table_entry);\
- \
- entry->hash = hash_val;\
- entry->key = key;\
- entry->record = value;\
- entry->next = table->bins[bin_pos];\
- table->bins[bin_pos] = entry;\
- table->num_entries++;\
-} while (0);
-
-int st_insert(table, key, value)
-register st_table *table;
-register st_data_t key;
-st_data_t value;
-{
- unsigned int hash_val, bin_pos;
- register st_table_entry *ptr;
-
- hash_val = do_hash(key, table);
- FIND_ENTRY(table, ptr, hash_val, bin_pos);
-
- if (ptr == 0) {
- ADD_DIRECT(table, key, value, hash_val, bin_pos);
- return 0;
- } else {
- ptr->record = value;
- return 1;
- }
-}
-
-void st_add_direct(table, key, value)
-st_table *table;
-st_data_t key;
-st_data_t value;
-{
- unsigned int hash_val, bin_pos;
-
- hash_val = do_hash(key, table);
- bin_pos = hash_val % table->num_bins;
- ADD_DIRECT(table, key, value, hash_val, bin_pos);
-}
-
-static void rehash(table)
-register st_table *table;
-{
- register st_table_entry *ptr, *next, **new_bins;
- int i, old_num_bins = table->num_bins, new_num_bins;
- unsigned int hash_val;
-
- new_num_bins = new_size(old_num_bins + 1);
- new_bins =
- (st_table_entry **) Calloc(new_num_bins, sizeof(st_table_entry *));
-
- for (i = 0; i < old_num_bins; i++) {
- ptr = table->bins[i];
- while (ptr != 0) {
- next = ptr->next;
- hash_val = ptr->hash % new_num_bins;
- ptr->next = new_bins[hash_val];
- new_bins[hash_val] = ptr;
- ptr = next;
- }
- }
- free(table->bins);
- table->num_bins = new_num_bins;
- table->bins = new_bins;
-}
-
-st_table *st_copy(old_table)
-st_table *old_table;
-{
- st_table *new_table;
- st_table_entry *ptr, *entry;
- size_t i, num_bins = old_table->num_bins;
-
- new_table = alloc(st_table);
- if (new_table == 0) {
- return 0;
- }
-
- *new_table = *old_table;
- new_table->bins = (st_table_entry **)
- Calloc(num_bins, sizeof(st_table_entry *));
-
- if (new_table->bins == 0) {
- free(new_table);
- return 0;
- }
-
- for (i = 0; i < num_bins; i++) {
- new_table->bins[i] = 0;
- ptr = old_table->bins[i];
- while (ptr != 0) {
- entry = alloc(st_table_entry);
- if (entry == 0) {
- free(new_table->bins);
- free(new_table);
- return 0;
- }
- *entry = *ptr;
- entry->next = new_table->bins[i];
- new_table->bins[i] = entry;
- ptr = ptr->next;
- }
- }
- return new_table;
-}
-
-int st_delete(table, key, value)
-register st_table *table;
-register st_data_t *key;
-st_data_t *value;
-{
- unsigned int hash_val;
- st_table_entry *tmp;
- register st_table_entry *ptr;
-
- hash_val = do_hash_bin(*key, table);
- ptr = table->bins[hash_val];
-
- if (ptr == 0) {
- if (value != 0)
- *value = 0;
- return 0;
- }
-
- if (EQUAL(table, *key, ptr->key)) {
- table->bins[hash_val] = ptr->next;
- table->num_entries--;
- if (value != 0)
- *value = ptr->record;
- *key = ptr->key;
- free(ptr);
- return 1;
- }
-
- for (; ptr->next != 0; ptr = ptr->next) {
- if (EQUAL(table, ptr->next->key, *key)) {
- tmp = ptr->next;
- ptr->next = ptr->next->next;
- table->num_entries--;
- if (value != 0)
- *value = tmp->record;
- *key = tmp->key;
- free(tmp);
- return 1;
- }
- }
-
- return 0;
-}
-
-int st_delete_safe(table, key, value, never)
-register st_table *table;
-register st_data_t *key;
-st_data_t *value;
-st_data_t never;
-{
- unsigned int hash_val;
- register st_table_entry *ptr;
-
- hash_val = do_hash_bin(*key, table);
- ptr = table->bins[hash_val];
-
- if (ptr == 0) {
- if (value != 0)
- *value = 0;
- return 0;
- }
-
- for (; ptr != 0; ptr = ptr->next) {
- if ((ptr->key != never) && EQUAL(table, ptr->key, *key)) {
- table->num_entries--;
- *key = ptr->key;
- if (value != 0)
- *value = ptr->record;
- ptr->key = ptr->record = never;
- return 1;
- }
- }
-
- return 0;
-}
-
-static int delete_never(st_data_t key, st_data_t value, st_data_t never)
-{
- if (value == never)
- return ST_DELETE;
- return ST_CONTINUE;
-}
-
-void st_cleanup_safe(table, never)
-st_table *table;
-st_data_t never;
-{
- int num_entries = table->num_entries;
-
- st_foreach(table, delete_never, never);
- table->num_entries = num_entries;
-}
-
-void st_foreach(table, func, arg)
-st_table *table;
-int (*func) (st_data_t key, st_data_t val, st_data_t arg);
-st_data_t arg;
-{
- st_table_entry *ptr, *last, *tmp;
- enum st_retval retval;
- int i;
-
- for (i = 0; i < table->num_bins; i++) {
- last = 0;
- for (ptr = table->bins[i]; ptr != 0;) {
- retval = (*func) (ptr->key, ptr->record, arg);
- switch (retval) {
- case ST_CONTINUE:
- last = ptr;
- ptr = ptr->next;
- break;
- case ST_STOP:
- return;
- case ST_DELETE:
- tmp = ptr;
- if (last == 0) {
- table->bins[i] = ptr->next;
- } else {
- last->next = ptr->next;
- }
- ptr = ptr->next;
- free(tmp);
- table->num_entries--;
- }
- }
- }
-}
-
-static int strhash(string)
-register const char *string;
-{
- register int c;
-
-#ifdef HASH_ELFHASH
- register unsigned int h = 0, g;
-
- while ((c = *string++) != '\0') {
- h = (h << 4) + c;
- if (g = h & 0xF0000000)
- h ^= g >> 24;
- h &= ~g;
- }
- return h;
-#elif HASH_PERL
- register int val = 0;
-
- while ((c = *string++) != '\0') {
- val = val * 33 + c;
- }
-
- return val + (val >> 5);
-#else
- register int val = 0;
-
- while ((c = *string++) != '\0') {
- val = val * 997 + c;
- }
-
- return val + (val >> 5);
-#endif
-}
-
-static int numcmp(x, y)
-void *x, *y;
-{
- return (st_ptr_t) x != (st_ptr_t) y;
-}
-
-static st_ptr_t numhash(n)
-void *n;
-{
- return (st_ptr_t) n;
-}
diff --git a/contrib/ofed/management/opensm/osmeventplugin/Makefile.am b/contrib/ofed/management/opensm/osmeventplugin/Makefile.am
deleted file mode 100644
index 79e3d55..0000000
--- a/contrib/ofed/management/opensm/osmeventplugin/Makefile.am
+++ /dev/null
@@ -1,34 +0,0 @@
-
-INCLUDES = -I$(srcdir)/../include \
- -I$(includedir)/infiniband
-
-lib_LTLIBRARIES = libosmeventplugin.la
-
-if DEBUG
-DBGFLAGS = -ggdb -D_DEBUG_
-else
-DBGFLAGS = -g
-endif
-
-libosmeventplugin_la_CFLAGS = -Wall $(DBGFLAGS) -D_XOPEN_SOURCE=600 -D_BSD_SOURCE=1
-
-if HAVE_LD_VERSION_SCRIPT
- libosmeventplugin_version_script = -Wl,--version-script=$(srcdir)/libosmeventplugin.map
-else
- libosmeventplugin_version_script =
-endif
-
-osmeventplugin_api_version=$(shell grep LIBVERSION= $(srcdir)/libosmeventplugin.ver | sed 's/LIBVERSION=//')
-
-libosmeventplugin_la_SOURCES = src/osmeventplugin.c
-libosmeventplugin_la_LDFLAGS = -version-info $(osmeventplugin_api_version) \
- -export-dynamic $(libosmeventplugin_version_script)
-libosmeventplugin_la_LIBADD = -L../complib $(OSMV_LDADD) -losmcomp
-libosmeventplugin_la_DEPENDENCIES = $(srcdir)/libosmeventplugin.map
-
-libosmeventpluginincludedir = $(includedir)/infiniband/complib
-
-libosmeventplugininclude_HEADERS =
-
-# headers are distributed as part of the include dir
-EXTRA_DIST = $(srcdir)/libosmeventplugin.map $(srcdir)/libosmeventplugin.ver
diff --git a/contrib/ofed/management/opensm/osmeventplugin/libosmeventplugin.map b/contrib/ofed/management/opensm/osmeventplugin/libosmeventplugin.map
deleted file mode 100644
index 346d1f3..0000000
--- a/contrib/ofed/management/opensm/osmeventplugin/libosmeventplugin.map
+++ /dev/null
@@ -1,5 +0,0 @@
-OSMPMDB_1.0 {
- global:
- osm_event_plugin;
- local: *;
-};
diff --git a/contrib/ofed/management/opensm/osmeventplugin/libosmeventplugin.ver b/contrib/ofed/management/opensm/osmeventplugin/libosmeventplugin.ver
deleted file mode 100644
index f755ff6..0000000
--- a/contrib/ofed/management/opensm/osmeventplugin/libosmeventplugin.ver
+++ /dev/null
@@ -1,9 +0,0 @@
-# In this file we track the current API version
-# of the vendor interface (and libraries)
-# The version is built of the following
-# tree numbers:
-# API_REV:RUNNING_REV:AGE
-# API_REV - advance on any added API
-# RUNNING_REV - advance any change to the vendor files
-# AGE - number of backward versions the API still supports
-LIBVERSION=1:0:0
diff --git a/contrib/ofed/management/opensm/osmeventplugin/src/osmeventplugin.c b/contrib/ofed/management/opensm/osmeventplugin/src/osmeventplugin.c
deleted file mode 100644
index f0781eb..0000000
--- a/contrib/ofed/management/opensm/osmeventplugin/src/osmeventplugin.c
+++ /dev/null
@@ -1,188 +0,0 @@
-/*
- * Copyright (c) 2008 Voltaire, Inc. All rights reserved.
- * Copyright (c) 2007 The Regents of the University of California.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- */
-
-#if HAVE_CONFIG_H
-# include <config.h>
-#endif /* HAVE_CONFIG_H */
-
-#include <errno.h>
-#include <string.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include <time.h>
-#include <dlfcn.h>
-#include <stdint.h>
-#include <complib/cl_qmap.h>
-#include <complib/cl_passivelock.h>
-#include <opensm/osm_version.h>
-#include <opensm/osm_opensm.h>
-#include <opensm/osm_log.h>
-
-/** =========================================================================
- * This is a simple example plugin which logs some of the events the OSM
- * generates to this interface.
- */
-#define SAMPLE_PLUGIN_OUTPUT_FILE "/tmp/osm_sample_event_plugin_output"
-typedef struct _log_events {
- FILE *log_file;
- osm_log_t *osmlog;
-} _log_events_t;
-
-/** =========================================================================
- */
-static void *construct(osm_opensm_t *osm)
-{
- _log_events_t *log = malloc(sizeof(*log));
- if (!log)
- return (NULL);
-
- log->log_file = fopen(SAMPLE_PLUGIN_OUTPUT_FILE, "a+");
-
- if (!(log->log_file)) {
- osm_log(&osm->log, OSM_LOG_ERROR,
- "Sample Event Plugin: Failed to open output file \"%s\"\n",
- SAMPLE_PLUGIN_OUTPUT_FILE);
- free(log);
- return (NULL);
- }
-
- log->osmlog = &osm->log;
- return ((void *)log);
-}
-
-/** =========================================================================
- */
-static void destroy(void *_log)
-{
- _log_events_t *log = (_log_events_t *) _log;
- fclose(log->log_file);
- free(log);
-}
-
-/** =========================================================================
- */
-static void handle_port_counter(_log_events_t * log, osm_epi_pe_event_t * pc)
-{
- if (pc->symbol_err_cnt > 0
- || pc->link_err_recover > 0
- || pc->link_downed > 0
- || pc->rcv_err > 0
- || pc->rcv_rem_phys_err > 0
- || pc->rcv_switch_relay_err > 0
- || pc->xmit_discards > 0
- || pc->xmit_constraint_err > 0
- || pc->rcv_constraint_err > 0
- || pc->link_integrity > 0
- || pc->buffer_overrun > 0 || pc->vl15_dropped > 0) {
- fprintf(log->log_file,
- "Port counter errors for node 0x%" PRIx64
- " (%s) port %d\n", pc->port_id.node_guid,
- pc->port_id.node_name, pc->port_id.port_num);
- }
-}
-
-/** =========================================================================
- */
-static void
-handle_port_counter_ext(_log_events_t * log, osm_epi_dc_event_t * epc)
-{
- fprintf(log->log_file,
- "Recieved Data counters for node 0x%" PRIx64 " (%s) port %d\n",
- epc->port_id.node_guid,
- epc->port_id.node_name, epc->port_id.port_num);
-}
-
-/** =========================================================================
- */
-static void handle_port_select(_log_events_t * log, osm_epi_ps_event_t * ps)
-{
- if (ps->xmit_wait > 0) {
- fprintf(log->log_file,
- "Port select Xmit Wait counts for node 0x%" PRIx64
- " (%s) port %d\n", ps->port_id.node_guid,
- ps->port_id.node_name, ps->port_id.port_num);
- }
-}
-
-/** =========================================================================
- */
-static void handle_trap_event(_log_events_t * log, osm_epi_trap_event_t * trap)
-{
- fprintf(log->log_file,
- "Trap event %d from 0x%" PRIx64 " (%s) port %d\n",
- trap->trap_num,
- trap->port_id.node_guid,
- trap->port_id.node_name, trap->port_id.port_num);
-}
-
-/** =========================================================================
- */
-static void report(void *_log, osm_epi_event_id_t event_id, void *event_data)
-{
- _log_events_t *log = (_log_events_t *) _log;
-
- switch (event_id) {
- case OSM_EVENT_ID_PORT_ERRORS:
- handle_port_counter(log, (osm_epi_pe_event_t *) event_data);
- break;
- case OSM_EVENT_ID_PORT_DATA_COUNTERS:
- handle_port_counter_ext(log, (osm_epi_dc_event_t *) event_data);
- break;
- case OSM_EVENT_ID_PORT_SELECT:
- handle_port_select(log, (osm_epi_ps_event_t *) event_data);
- break;
- case OSM_EVENT_ID_TRAP:
- handle_trap_event(log, (osm_epi_trap_event_t *) event_data);
- break;
- case OSM_EVENT_ID_MAX:
- default:
- osm_log(log->osmlog, OSM_LOG_ERROR,
- "Unknown event reported to plugin\n");
- }
-}
-
-/** =========================================================================
- * Define the object symbol for loading
- */
-
-#if OSM_EVENT_PLUGIN_INTERFACE_VER != 2
-#error OpenSM plugin interface version missmatch
-#endif
-
-osm_event_plugin_t osm_event_plugin = {
- osm_version:OSM_VERSION,
- create:construct,
- delete:destroy,
- report:report
-};
diff --git a/contrib/ofed/management/opensm/osmtest/Makefile.am b/contrib/ofed/management/opensm/osmtest/Makefile.am
deleted file mode 100644
index 4c68852..0000000
--- a/contrib/ofed/management/opensm/osmtest/Makefile.am
+++ /dev/null
@@ -1,23 +0,0 @@
-
-if DEBUG
-DBGFLAGS = -ggdb -D_DEBUG_
-else
-DBGFLAGS = -g
-endif
-
-INCLUDES = -I$(srcdir)/include $(OSMV_INCLUDES)
-
-sbin_PROGRAMS = osmtest
-osmtest_SOURCES = main.c osmtest.c osmt_service.c osmt_slvl_vl_arb.c \
- osmt_multicast.c osmt_inform.c
-if OSMV_VAPI
-osmtest_SOURCES += osmt_mtl_regular_qp.c
-endif
-osmtest_CFLAGS = -Wall $(DBGFLAGS)
-osmtest_LDADD = -L../complib -losmcomp -L../libvendor -losmvendor -L../opensm -lopensm $(OSMV_LDADD)
-
-EXTRA_DIST = $(srcdir)/include/osmt_inform.h \
- $(srcdir)/include/osmtest_subnet.h \
- $(srcdir)/include/osmtest.h \
- $(srcdir)/include/osmt_mtl_regular_qp.h \
- $(srcdir)/include/osmtest_base.h
diff --git a/contrib/ofed/management/opensm/osmtest/include/osmt_inform.h b/contrib/ofed/management/opensm/osmtest/include/osmt_inform.h
deleted file mode 100644
index bc796cc..0000000
--- a/contrib/ofed/management/opensm/osmtest/include/osmt_inform.h
+++ /dev/null
@@ -1,78 +0,0 @@
-/*
- * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved.
- * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- */
-
-#ifndef __OSMT_INFORM__
-#define __OSMT_INFORM__
-
-#ifdef OSM_VENDOR_INTF_MTL
-#include <vendor/osm_vendor_mlx_inout.h>
-#include <ib_mgt.h>
-#include "osmt_mtl_regular_qp.h"
-#endif
-
-typedef struct _osmt_qp_ctx {
-#ifdef OSM_VENDOR_INTF_MTL
- osmt_mtl_mad_res_t qp_bind_hndl;
-#endif
- uint8_t *p_send_buf;
- uint8_t *p_recv_buf;
-#ifdef OSM_VENDOR_INTF_MTL
- IB_MGT_mad_hndl_t ib_mgt_qp0_handle;
-#endif
-} osmt_qp_ctx_t;
-
-ib_api_status_t
-osmt_bind_inform_qp(IN osmtest_t * const p_osmt, OUT osmt_qp_ctx_t * p_qp_ctx);
-
-void
-osmt_unbind_inform_qp(IN osmtest_t * const p_osmt, IN osmt_qp_ctx_t * p_qp_ctx);
-
-ib_api_status_t
-osmt_reg_unreg_inform_info(IN osmtest_t * p_osmt,
- IN osmt_qp_ctx_t * p_qp_ctx,
- IN ib_inform_info_t * p_inform_info,
- IN uint8_t reg_flag);
-
-ib_api_status_t
-osmt_trap_wait(IN osmtest_t * const p_osmt, IN osmt_qp_ctx_t * p_qp_ctx);
-
-ib_api_status_t
-osmt_init_inform_info(IN osmtest_t * const p_osmt, OUT ib_inform_info_t * p_ii);
-
-ib_api_status_t
-osmt_init_inform_info_by_trap(IN osmtest_t * const p_osmt,
- IN ib_net16_t trap_num,
- OUT ib_inform_info_t * p_ii);
-
-#endif /* __OSMT_INFORM__ */
diff --git a/contrib/ofed/management/opensm/osmtest/include/osmt_mtl_regular_qp.h b/contrib/ofed/management/opensm/osmtest/include/osmt_mtl_regular_qp.h
deleted file mode 100644
index 3fd6e9d..0000000
--- a/contrib/ofed/management/opensm/osmtest/include/osmt_mtl_regular_qp.h
+++ /dev/null
@@ -1,162 +0,0 @@
-/*
- * Copyright (c) 2001-2005 Mellanox Technologies LTD. All rights reserved.
- * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- */
-
-/*
- * mad.h -
- * Header file for common special QP resources creation code.
- *
- * Creation date:
- *
- * Version: osmt_mtl_regular_qp.h,v 1.2 2003/03/20 16:05:10 eitan
- *
- * Authors:
- * Elazar Raab
- *
- * Changes:
- */
-
-#ifndef H_MAD_H
-#define H_MAD_H
-
-#include <vapi.h>
-#include <evapi.h>
-#include <vapi_common.h>
-#include <ib_defs.h>
-
-#if defined(MAD_IN) || defined(MAD_OUT)
-#error MACROS MAD_IN and MAD_OUT are in use, do not override
-#endif
-#define MAD_IN
-#define MAD_OUT
-
-/* HCA Constants */
-#define HCA_ID "mt21108_pci0"
-#define GRH_LEN 40
-#define KNOWN_QP1_QKEY 0x80010000
-
-#define MAX_OUTS_SQ 2 /* Max. buffers posted for requests in SQ */
-#define MAX_OUTS_RQ 5 /* Max. buffers posted for responses in RQ */
-
-#define MAX_POLL_CNT 300
-#define POLL_SLEEP 1 /* for usleep */
-
-#define MAD_SIZE 256 /* MADs are always 256B */
-#define MAD_ATTR_OFFSET 16
-#define MAD_TID_OFFSET 8
-
-/* Verbs SQP resources handles */
-typedef struct {
- VAPI_hca_id_t hca_id; /*id of HCA */
- u_int8_t port_num; /* the port num to use */
- VAPI_hca_hndl_t hca_hndl; /*handle of HCA */
- VAPI_qp_hndl_t qp_hndl; /*handle of QP I use */
- VAPI_mr_hndl_t mr_hndl; /*handle of memory region */
- VAPI_cq_hndl_t rq_cq_hndl, sq_cq_hndl; /*handle of send & receive completion Queues */
- VAPI_pd_hndl_t pd_hndl; /*handle of Partition Domain */
- /* VAPI_ud_av_hndl_t av_hndl; */
- IB_lid_t slid;
- /*LID*/ void *buf_ptr; /*mem buffer for outstanding pkts */
- MT_size_t buf_size; /*size of mem buffer for outstanding pkts */
-
- u_int32_t max_outs_sq; /*max # of outstanding pkts in send queue */
- u_int32_t max_outs_rq; /*max # of outstanding pkts in receive queue */
-
- IB_rkey_t l_key; /*my l_key for memory regions */
- VAPI_qkey_t qkey; /*my qkey */
-
- EVAPI_compl_handler_hndl_t rq_cq_eventh, sq_cq_eventh; /* event handlers for polling */
-
- bool is_sqp; /* relate to union below - my QP */
- union {
- VAPI_special_qp_t sqp_type;
- VAPI_qp_num_t qp_num;
- } qp_id;
- void *wait_q;
-} osmt_mtl_mad_res_t;
-
-/* init an osmt_mtl_mad_res_t with all resources initialized (use functions below) */
-VAPI_ret_t osmt_mtl_init(osmt_mtl_mad_res_t * res /*pointer to res (resources) struct */
- );
-VAPI_ret_t osmt_mtl_init_opened_hca(osmt_mtl_mad_res_t * res /*pointer to res (resources) struct */
- );
-
-/* Cleanup all resources of (which are valid) in res */
-VAPI_ret_t osmt_mtl_mad_cleanup(osmt_mtl_mad_res_t * res /*pointer to res (resources) struct */
- );
-
-/* create CQs and QP as given in res->is_sqp (if TRUE, get special QP) */
-VAPI_ret_t osmt_mtl_get_qp_resources(osmt_mtl_mad_res_t * res /*pointer to res (resources) struct */
- );
-
-/* move QP to RTS state */
-VAPI_ret_t osmt_mtl_mad_qp_init(osmt_mtl_mad_res_t * res /*max number of outstanding packets allowed in send queue */
- );
-
-/* create and register res->buf_ptr */
-VAPI_ret_t osmt_mtl_mad_create_mr(osmt_mtl_mad_res_t * res /*pointer to res (resources) struct */
- );
-
-VAPI_ret_t osmt_mtl_create_av(osmt_mtl_mad_res_t * res, /* pointer to res (resources) struct */
- int16_t dlid, /*destination lid */
- VAPI_ud_av_hndl_t * avh_p /* address vectr handle to update */
- );
-
-/* Send MAD to given dest QP*/
-VAPI_ret_t osmt_mtl_mad_send(osmt_mtl_mad_res_t * res, /*pointer to res (resources) struct */
- VAPI_wr_id_t id, /*wqe ID */
- void *mad, /*mad buffer to send */
- VAPI_qp_num_t dest_qp, /*destination QP */
- IB_sl_t sl, /*Service Level */
- u_int32_t dest_qkey, /*Destination QP KEY */
- VAPI_ud_av_hndl_t avh /* address vectr handle to use */
- );
-
-/* post buffers to RQ. returns num of buffers actually posted */
-int osmt_mtl_mad_post_recv_bufs(osmt_mtl_mad_res_t * res, /*pointer to res (resources) struct */
- void *buf_array, /*array of receive buffers */
- u_int32_t num_o_bufs, /*number of receive buffers */
- u_int32_t size, /* size of expected receive packet - MAD */
- VAPI_wr_id_t start_id /* start id for receive buffers */
- );
-
-/* Poll given CQ for completion max_poll times (POLL_SLEEP [usec] delays). result in wc_desc_p. */
-VAPI_ret_t osmt_mtl_mad_poll4cqe(VAPI_hca_hndl_t hca, /*handle for HCA */
- VAPI_cq_hndl_t cq, /*handle for Completion Queue - Rcv/Send */
- VAPI_wc_desc_t * wc_desc_p, /*handle of cqe */
- u_int32_t max_poll, /*number of polling iterations */
- u_int32_t poll_sleep, /*timeout for each polling */
- VAPI_ud_av_hndl_t * avh_p /* address vectopr handle to cleanup */
- );
-
-#endif
diff --git a/contrib/ofed/management/opensm/osmtest/include/osmtest.h b/contrib/ofed/management/opensm/osmtest/include/osmtest.h
deleted file mode 100644
index c3134ef..0000000
--- a/contrib/ofed/management/opensm/osmtest/include/osmtest.h
+++ /dev/null
@@ -1,510 +0,0 @@
-/*
- * Copyright (c) 2006 Voltaire, Inc. All rights reserved.
- * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved.
- * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- */
-
-/*
- * Abstract:
- * Declaration of osmtest_t.
- * This object represents the OSMTest Test object.
- *
- */
-
-#ifndef _OSMTEST_H_
-#define _OSMTEST_H_
-
-#include <complib/cl_qmap.h>
-#include <opensm/osm_log.h>
-#include <vendor/osm_vendor_api.h>
-#include <vendor/osm_vendor_sa_api.h>
-#include <opensm/osm_mad_pool.h>
-#include <opensm/osm_helper.h>
-#include "osmtest_base.h"
-#include "osmtest_subnet.h"
-
-enum OSMT_FLOWS {
- OSMT_FLOW_ALL = 0,
- OSMT_FLOW_CREATE_INVENTORY,
- OSMT_FLOW_VALIDATE_INVENTORY,
- OSMT_FLOW_SERVICE_REGISTRATION,
- OSMT_FLOW_EVENT_FORWARDING,
- OSMT_FLOW_STRESS_SA,
- OSMT_FLOW_MULTICAST,
- OSMT_FLOW_QOS,
- OSMT_FLOW_TRAP,
-};
-
-/****s* OpenSM: Subnet/osmtest_opt_t
- * NAME
- * osmtest_opt_t
- *
- * DESCRIPTION
- * Subnet options structure. This structure contains the various
- * site specific configuration parameters for osmtest.
- *
- * SYNOPSIS
- */
-typedef struct _osmtest_opt {
- uint32_t transaction_timeout;
- boolean_t force_log_flush;
- boolean_t create;
- uint32_t retry_count;
- uint32_t stress;
- uint32_t mmode;
- char file_name[OSMTEST_FILE_PATH_MAX];
- uint8_t flow;
- uint8_t wait_time;
- char *log_file;
- boolean_t ignore_path_records;
-} osmtest_opt_t;
-
-/*
- * FIELDS
- *
- * SEE ALSO
- *********/
-
-/****h* OSMTest/OSMTest
- * NAME
- * OSMTest
- *
- * DESCRIPTION
- * The OSMTest object tests an SM/SA for conformance to a known
- * set of data about an Infiniband subnet.
- *
- * AUTHOR
- * Steve King, Intel
- *
- *********/
-
-/****s* OSMTest/osmtest_t
- * NAME
- * osmtest_t
- *
- * DESCRIPTION
- * OSMTest structure.
- *
- * This object should be treated as opaque and should
- * be manipulated only through the provided functions.
- *
- * SYNOPSIS
- */
-typedef struct _osmtest {
- osm_log_t log;
- struct _osm_vendor *p_vendor;
- osm_bind_handle_t h_bind;
- osm_mad_pool_t mad_pool;
-
- osmtest_opt_t opt;
- ib_port_attr_t local_port;
- subnet_t exp_subn;
- cl_qpool_t node_pool;
- cl_qpool_t port_pool;
- cl_qpool_t link_pool;
-
- uint16_t max_lid;
-} osmtest_t;
-
-/*
- * FIELDS
- * log
- * Log facility used by all OSMTest components.
- *
- * p_vendor
- * Pointer to the vendor transport layer.
- *
- * h_bind
- * The bind handle obtained by osm_vendor_sa_api/osmv_bind_sa
- *
- * mad_pool
- * The mad pool provided for teh vendor layer to allocate mad wrappers in
- *
- * opt
- * osmtest options structure
- *
- * local_port
- * Port attributes for the port over which osmtest is running.
- *
- * exp_subn
- * Subnet object representing the expected subnet
- *
- * node_pool
- * Pool of objects for use in populating the subnet databases.
- *
- * port_pool
- * Pool of objects for use in populating the subnet databases.
- *
- * link_pool
- * Pool of objects for use in populating the subnet databases.
- *
- * SEE ALSO
- *********/
-
-/****s* OpenSM: Subnet/osmtest_req_context_t
- * NAME
- * osmtest_req_context_t
- *
- * DESCRIPTION
- * Query context for ib_query callback function.
- *
- * SYNOPSIS
- */
-typedef struct _osmtest_req_context {
- osmtest_t *p_osmt;
- osmv_query_res_t result;
-} osmtest_req_context_t;
-
-typedef struct _osmtest_mgrp_t {
- cl_map_item_t map_item;
- ib_member_rec_t mcmember_rec;
-} osmtest_mgrp_t;
-
-/*
- * FIELDS
- *
- * SEE ALSO
- *********/
-
-/****f* OSMTest/osmtest_construct
- * NAME
- * osmtest_construct
- *
- * DESCRIPTION
- * This function constructs an OSMTest object.
- *
- * SYNOPSIS
- */
-void osmtest_construct(IN osmtest_t * const p_osmt);
-
-/*
- * PARAMETERS
- * p_osmt
- * [in] Pointer to a OSMTest object to construct.
- *
- * RETURN VALUE
- * This function does not return a value.
- *
- * NOTES
- * Allows calling osmtest_init, osmtest_destroy.
- *
- * Calling osmtest_construct is a prerequisite to calling any other
- * method except osmtest_init.
- *
- * SEE ALSO
- * SM object, osmtest_init, osmtest_destroy
- *********/
-
-/****f* OSMTest/osmtest_destroy
- * NAME
- * osmtest_destroy
- *
- * DESCRIPTION
- * The osmtest_destroy function destroys an osmtest object, releasing
- * all resources.
- *
- * SYNOPSIS
- */
-void osmtest_destroy(IN osmtest_t * const p_osmt);
-
-/*
- * PARAMETERS
- * p_osmt
- * [in] Pointer to a OSMTest object to destroy.
- *
- * RETURN VALUE
- * This function does not return a value.
- *
- * NOTES
- * Performs any necessary cleanup of the specified OSMTest object.
- * Further operations should not be attempted on the destroyed object.
- * This function should only be called after a call to osmtest_construct or
- * osmtest_init.
- *
- * SEE ALSO
- * SM object, osmtest_construct, osmtest_init
- *********/
-
-/****f* OSMTest/osmtest_init
- * NAME
- * osmtest_init
- *
- * DESCRIPTION
- * The osmtest_init function initializes a OSMTest object for use.
- *
- * SYNOPSIS
- */
-ib_api_status_t osmtest_init(IN osmtest_t * const p_osmt,
- IN const osmtest_opt_t * const p_opt,
- IN const osm_log_level_t log_flags);
-
-/*
- * PARAMETERS
- * p_osmt
- * [in] Pointer to an osmtest_t object to initialize.
- *
- * p_opt
- * [in] Pointer to the options structure.
- *
- * log_flags
- * [in] Log level flags to set.
- *
- * RETURN VALUES
- * IB_SUCCESS if the OSMTest object was initialized successfully.
- *
- * NOTES
- * Allows calling other OSMTest methods.
- *
- * SEE ALSO
- * SM object, osmtest_construct, osmtest_destroy
- *********/
-
-/****f* OSMTest/osmtest_run
- * NAME
- * osmtest_run
- *
- * DESCRIPTION
- * Runs the osmtest suite.
- *
- * SYNOPSIS
- */
-ib_api_status_t osmtest_run(IN osmtest_t * const p_osmt);
-
-/*
- * PARAMETERS
- * p_osmt
- * [in] Pointer to an osmtest_t object.
- *
- * guid
- * [in] Port GUID over which to run the test suite.
- *
- * RETURN VALUES
- * IB_SUCCESS
- *
- * NOTES
- *
- * SEE ALSO
- *********/
-
-/****f* OSMTest/osmtest_bind
- * NAME
- * osmtest_bind
- *
- * DESCRIPTION
- * Binds osmtest to a local port.
- *
- * SYNOPSIS
- */
-ib_api_status_t osmtest_bind(IN osmtest_t * p_osmt,
- IN uint16_t max_lid, IN ib_net64_t guid OPTIONAL);
-
-/*
- * PARAMETERS
- * p_osmt
- * [in] Pointer to an osmtest_t object.
- *
- * max_lid
- * [in] The maximal lid to query about (if RMPP is not supported)
- *
- * guid
- * [in] Port GUID over which to run the test suite.
- * If zero, the bind function will display a menu of local
- * port guids and wait for user input.
- *
- * RETURN VALUES
- * IB_SUCCESS
- *
- * NOTES
- *
- * SEE ALSO
- *********/
-
-/****f* OSMTest/osmtest_query_res_cb
- * NAME
- * osmtest_query_res_cb
- *
- * DESCRIPTION
- * A Callback for the query to invoke on completion
- *
- * SYNOPSIS
- */
-void osmtest_query_res_cb(IN osmv_query_res_t * p_rec);
-/*
- * PARAMETERS
- * p_rec
- * [in] Pointer to an ib_query_rec_t object used for the query.
- *
- * RETURN VALUES
- * NONE
- *
- * NOTES
- *
- * SEE ALSO
- *********/
-
-/****f* OSMTest/ib_get_mad_status_str
- * NAME
- * ib_get_mad_status_str
- *
- * DESCRIPTION
- * return the string representing the given mad status
- *
- * SYNOPSIS
- */
-const char *ib_get_mad_status_str(IN const ib_mad_t * const p_mad);
-/*
- * PARAMETERS
- * p_mad
- * [in] Pointer to the mad payload
- *
- * RETURN VALUES
- * NONE
- *
- * NOTES
- *
- * SEE ALSO
- *********/
-
-/****f* OSMTest/osmt_run_service_records_flow
- * NAME
- * osmt_run_service_records_flow
- *
- * DESCRIPTION
- * Run the service record testing flow.
- *
- * SYNOPSIS
- */
-ib_api_status_t osmt_run_service_records_flow(IN osmtest_t * const p_osmt);
-/*
- * PARAMETERS
- * p_osmt
- * [in] Pointer to the osmtest obj
- *
- * RETURN VALUES
- * IB_SUCCESS if PASS
- *
- * NOTES
- *
- * SEE ALSO
- *********/
-
-ib_api_status_t osmt_run_inform_info_flow(IN osmtest_t * const p_osmt);
-
-/****f* OSMTest/osmt_run_slvl_and_vlarb_records_flow
- * NAME
- * osmt_run_slvl_and_vlarb_records_flow
- *
- * DESCRIPTION
- * Run the sl2vl and vlarb tables testing flow.
- *
- * SYNOPSIS
- */
-ib_api_status_t
-osmt_run_slvl_and_vlarb_records_flow(IN osmtest_t * const p_osmt);
-/*
- * PARAMETERS
- * p_osmt
- * [in] Pointer to the osmtest obj
- *
- * RETURN VALUES
- * IB_SUCCESS if PASS
- *
- * NOTES
- *
- * SEE ALSO
- *********/
-
-/****f* OSMTest/osmt_run_mcast_flow
- * NAME
- * osmt_run_mcast_flow
- *
- * DESCRIPTION
- * Run the multicast test flow
- *
- * SYNOPSIS
- */
-ib_api_status_t osmt_run_mcast_flow(IN osmtest_t * const p_osmt);
-/*
- * PARAMETERS
- * p_osmt
- * [in] Pointer to the osmtest obj
- *
- * RETURN VALUES
- * IB_SUCCESS if PASS
- *
- * NOTES
- *
- * SEE ALSO
- *********/
-
-/****f* OSMTest/osmt_run_trap64_65_flow
- * NAME
- * osmt_run_trap64_65_flow
- *
- * DESCRIPTION
- * Run the trap 64/65 test flow. This test is ran with
- * an outside tool.
- *
- * SYNOPSIS
- */
-ib_api_status_t osmt_run_trap64_65_flow(IN osmtest_t * const p_osmt);
-/*
- * PARAMETERS
- * p_osmt
- * [in] Pointer to the osmtest obj
- *
- * RETURN VALUES
- * IB_SUCCESS if PASS
- *
- * NOTES
- *
- * SEE ALSO
- *********/
-
-ib_api_status_t
-osmtest_get_all_recs(IN osmtest_t * const p_osmt,
- IN ib_net16_t const attr_id,
- IN size_t const attr_size,
- IN OUT osmtest_req_context_t * const p_context);
-
-ib_api_status_t
-osmtest_get_local_port_lmc(IN osmtest_t * const p_osmt,
- IN ib_net16_t lid, OUT uint8_t * const p_lmc);
-
-/*
- * A few auxiliary macros for logging
- */
-
-#define EXPECTING_ERRORS_START "[[ ===== Expecting Errors - START ===== "
-#define EXPECTING_ERRORS_END " ===== Expecting Errors - END ===== ]]"
-
-#endif /* _OSMTEST_H_ */
diff --git a/contrib/ofed/management/opensm/osmtest/include/osmtest_base.h b/contrib/ofed/management/opensm/osmtest/include/osmtest_base.h
deleted file mode 100644
index 7c33da3..0000000
--- a/contrib/ofed/management/opensm/osmtest/include/osmtest_base.h
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved.
- * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- */
-
-/*
- * Abstract:
- * Declaration of osmtest_t.
- * This object represents the OSMTest Test object.
- *
- */
-#ifndef _OSMTEST_BASE_H_
-#define _OSMTEST_BASE_H_
-
-#ifndef __WIN__
-#include <limits.h>
-#else
-#include <vendor/winosm_common.h>
-#endif
-
-#define OSMTEST_MAX_LINE_LEN 120
-#ifdef WIN32
-#define OSMTEST_FILE_PATH_MAX 4096
-#else
-#define OSMTEST_FILE_PATH_MAX PATH_MAX
-#endif
-
-#define STRESS_SMALL_RMPP_THR 100000
-/*
- Take long times when quering big clusters (over 40 nodes) , an average of : 0.25 sec for query
- each query receives 1000 records
-*/
-#define STRESS_LARGE_RMPP_THR 4000
-#define STRESS_LARGE_PR_RMPP_THR 20000
-
-extern const char *const p_file;
-
-#endif /* _OSMTEST_BASE_H_ */
diff --git a/contrib/ofed/management/opensm/osmtest/include/osmtest_subnet.h b/contrib/ofed/management/opensm/osmtest/include/osmtest_subnet.h
deleted file mode 100644
index 09063dd..0000000
--- a/contrib/ofed/management/opensm/osmtest/include/osmtest_subnet.h
+++ /dev/null
@@ -1,326 +0,0 @@
-/*
- * Copyright (c) 2006 Voltaire, Inc. All rights reserved.
- * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved.
- * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- */
-
-/*
- * Abstract:
- * Declaration of osmtest_t.
- * This object represents the OSMTest Test object.
- *
- */
-
-#ifndef _OSMTEST_SUBNET_H_
-#define _OSMTEST_SUBNET_H_
-
-#include <stdlib.h>
-#include <complib/cl_qmap.h>
-#include <opensm/osm_log.h>
-#include <vendor/osm_vendor_api.h>
-#include <opensm/osm_mad_pool.h>
-#include <opensm/osm_helper.h>
-
-/****s* Subnet Database/generic_t
-* NAME
-* generic_t
-*
-* DESCRIPTION
-* Subnet database object for fields common to all record types.
-* All other database types must be castable to this type.
-*
-* SYNOPSIS
-*/
-typedef struct _generic {
- cl_map_item_t map_item; /* must be first element! */
- uint32_t count; /* must be second element! */
-} generic_t;
-
-/*
-* FIELDS
-*
-* SEE ALSO
-*********/
-
-/****s* Subnet Database/node_t
-* NAME
-* node_t
-*
-* DESCRIPTION
-* Subnet database object for nodes.
-* Must be castable to generic_t.
-*
-* SYNOPSIS
-*/
-typedef struct _node {
- cl_map_item_t map_item; /* must be first element! */
- uint32_t count; /* must be second element! */
- ib_node_record_t rec;
- ib_node_record_t comp;
-} node_t;
-
-/*
-* FIELDS
-* map_item
-* Provides linkage for the qmap container.
-*
-* rec
-* NodeRecord for this node as read from the database file.
-*
-* comp
-* NodeRecord indicating which fields should be compared against rec.
-* Bits set in the comp NodeRecord indicate that bit in the rec structure
-* should be compared against real-time data from the SA.
-*
-* count
-* Utility counter used by the validation logic. Typically used to
-* to indicate the number of times a matching node was received from
-* the SA.
-*
-* SEE ALSO
-*********/
-
-static inline node_t *node_new(void)
-{
- node_t *p_obj;
-
- p_obj = malloc(sizeof(*p_obj));
- if (p_obj)
- memset(p_obj, 0, sizeof(*p_obj));
- return (p_obj);
-}
-
-static inline void node_delete(IN node_t * p_obj)
-{
- free(p_obj);
-}
-
-/****s* Subnet Database/port_t
-* NAME
-* port_t
-*
-* DESCRIPTION
-* Subnet database object for ports.
-* Must be castable to generic_t.
-*
-* SYNOPSIS
-*/
-typedef struct _port {
- cl_map_item_t map_item; /* must be first element! */
- uint32_t count; /* must be second element! */
- /* Since there is no unique identifier for all ports we
- must be able to have such a key by the lid and port num */
- uint64_t port_id;
- ib_portinfo_record_t rec;
- ib_portinfo_record_t comp;
-} port_t;
-
-/*
-* FIELDS
-*
-* map_item
-* Provides linkage for the qmap container.
-*
-* rec
-* PortInfoRecord for this port as read from the database file.
-*
-* comp
-* PortInfoRecord indicating which fields should be compared against rec.
-* Bits set in the comp NodeRecord indicate that bit in the rec structure
-* should be compared against real-time data from the SA.
-*
-* count
-* Utility counter used by the validation logic. Typically used to
-* to indicate the number of times a matching node was received from
-* the SA.
-*
-* SEE ALSO
-*********/
-
-static inline port_t *port_new(void)
-{
- port_t *p_obj;
-
- p_obj = malloc(sizeof(*p_obj));
- if (p_obj)
- memset(p_obj, 0, sizeof(*p_obj));
- return (p_obj);
-}
-
-static inline void port_delete(IN port_t * p_obj)
-{
- free(p_obj);
-}
-
-static inline uint64_t
-port_gen_id(IN ib_net16_t const lid, IN uint8_t const port_num)
-{
- return (lid << 8 | port_num);
-}
-
-static inline void
-port_ext_id(IN uint64_t id, IN ib_net16_t * p_lid, IN uint8_t * p_port_num)
-{
- CL_ASSERT((id & 0xFF) < 0x100);
- *p_port_num = (uint8_t) (id & 0xFF);
- CL_ASSERT(((id >> 8) & 0xFFFF) < 0x10000);
- *p_lid = (uint16_t) ((id >> 8) & 0xFFFF);
-}
-
-static inline void
-port_set_id(IN port_t * p_obj,
- IN ib_net16_t const lid, IN uint8_t const port_num)
-{
- p_obj->port_id = port_gen_id(lid, port_num);
-}
-
-static inline void
-port_get_id(IN port_t * p_obj, IN ib_net16_t * p_lid, IN uint8_t * p_port_num)
-{
- port_ext_id(p_obj->port_id, p_lid, p_port_num);
-}
-
-/****s* Subnet Database/path_t
-* NAME
-* node_t
-*
-* DESCRIPTION
-* Subnet database object for paths.
-* Must be castable to generic_t.
-*
-* SYNOPSIS
-*/
-typedef struct _path {
- cl_map_item_t map_item; /* must be first element! */
- uint32_t count; /* must be second element! */
- ib_path_rec_t rec;
- ib_path_rec_t comp;
-} path_t;
-
-/*
-* FIELDS
-* map_item
-* Provides linkage for the qmap container.
-*
-* rec
-* PathRecord for this path as read from the database file.
-*
-* comp
-* PathRecord indicating which fields should be compared against rec.
-* Bits set in the comp PathRecord indicate that bit in the rec structure
-* should be compared against real-time data from the SA.
-*
-* count
-* Utility counter used by the validation logic. Typically used to
-* to indicate the number of times a matching node was received from
-* the SA.
-*
-* SEE ALSO
-*********/
-
-static inline path_t *path_new(void)
-{
- path_t *p_obj;
-
- p_obj = malloc(sizeof(*p_obj));
- if (p_obj)
- memset(p_obj, 0, sizeof(*p_obj));
- return (p_obj);
-}
-
-static inline void path_delete(IN path_t * p_obj)
-{
- free(p_obj);
-}
-
-/****s* Subnet Database/subnet_t
-* NAME
-* subnet_t
-*
-* DESCRIPTION
-* Subnet database object.
-*
-* SYNOPSIS
-*/
-typedef struct _subnet {
- cl_qmap_t node_lid_tbl;
- cl_qmap_t node_guid_tbl;
- cl_qmap_t mgrp_mlid_tbl;
- /* cl_qmap_t port_lid_tbl; */
- /* cl_qmap_t port_guid_tbl; */
- cl_qmap_t port_key_tbl;
- cl_qmap_t link_tbl;
- cl_qmap_t path_tbl;
-} subnet_t;
-
-/*
-* FIELDS
-*
-* SEE ALSO
-*********/
-
-/****f* Subnet Database/subnet_construct
-* NAME
-* subnet_construct
-*
-* DESCRIPTION
-* This function constructs an subnet database object.
-* This function cannot fail.
-*
-* SYNOPSIS
-*/
-void subnet_construct(IN subnet_t * const p_subn);
-
-/*
-* FIELDS
-*
-* SEE ALSO
-*********/
-
-/****f* Subnet Database/subnet_init
-* NAME
-* subnet_init
-*
-* DESCRIPTION
-* This function initializes an subnet database object.
-*
-* SYNOPSIS
-*/
-cl_status_t subnet_init(IN subnet_t * const p_subn);
-
-/*
-* FIELDS
-*
-* SEE ALSO
-*********/
-
-#endif
diff --git a/contrib/ofed/management/opensm/osmtest/main.c b/contrib/ofed/management/opensm/osmtest/main.c
deleted file mode 100644
index 8bb3b80..0000000
--- a/contrib/ofed/management/opensm/osmtest/main.c
+++ /dev/null
@@ -1,624 +0,0 @@
-/*
- * Copyright (c) 2004-2006 Voltaire, Inc. All rights reserved.
- * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- */
-
-/*
- * Abstract:
- * Command line interface for osmtest.
- *
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <getopt.h>
-#include <complib/cl_debug.h>
-#include "osmtest.h"
-
-/********************************************************************
- D E F I N E G L O B A L V A R I A B L E S
-*********************************************************************/
-
-/*
- This is the global osmtest object.
- One osmtest object is required per subnet.
- Future versions could support multiple subents by
- instantiating more than one osmtest object.
-*/
-#define GUID_ARRAY_SIZE 64
-#define OSMT_DEFAULT_RETRY_COUNT 3
-#define OSMT_DEFAULT_TRANS_TIMEOUT_MILLISEC 1000
-#define OSMT_DEFAULT_TRAP_WAIT_TIMEOUT_SEC 10
-#define INVALID_GUID (0xFFFFFFFFFFFFFFFFULL)
-
-/**********************************************************************
- **********************************************************************/
-boolean_t osmt_is_debug(void)
-{
-#if defined( _DEBUG_ )
- return TRUE;
-#else
- return FALSE;
-#endif /* defined( _DEBUG_ ) */
-}
-
-/**********************************************************************
- **********************************************************************/
-void show_usage(void);
-
-void show_usage()
-{
- printf
- ("\n------- osmtest - Usage and options ----------------------\n");
- printf("Usage: osmtest [options]\n");
- printf("Options:\n");
- printf("-f <c|a|v|s|e|f|m|q|t>\n"
- "--flow <c|a|v|s|e|f|m|q|t>\n"
- " This option directs osmtest to run a specific flow:\n"
- " FLOW DESCRIPTION\n"
- " c = create an inventory file with all nodes, ports and paths\n"
- " a = run all validation tests (expecting an input inventory)\n"
- " v = only validate the given inventory file\n"
- " s = run service registration, deregistration, and lease test\n"
- " e = run event forwarding test\n"
- " f = flood the SA with queries according to the stress mode\n"
- " m = multicast flow\n"
- " q = QoS info: dump VLArb and SLtoVL tables\n"
- " t = run trap 64/65 flow (this flow requires running of external tool)\n"
- " (default is all flows except QoS)\n\n");
-
- printf("-w <trap_wait_time>\n"
- "--wait <trap_wait_time>\n"
- " This option specifies the wait time for trap 64/65 in seconds\n"
- " It is used only when running -f t - the trap 64/65 flow\n"
- " (default to 10 sec)\n\n");
- printf("-d <number>\n"
- "--debug <number>\n"
- " This option specifies a debug option\n"
- " These options are not normally needed\n"
- " The number following -d selects the debug\n"
- " option to enable as follows:\n"
- " OPT Description\n"
- " --- -----------------\n"
- " -d0 - Unused.\n"
- " -d1 - Do not scan/compare path records.\n"
- " -d2 - Force log flushing after each log message.\n"
- " Without -d, no debug options are enabled\n\n");
- printf("-m <LID in hex>\n"
- "--max_lid <LID in hex>\n"
- " This option specifies the maximal LID number to be searched\n"
- " for during inventory file build (default to 100)\n\n");
- printf("-g <GUID in hex>\n"
- "--guid <GUID in hex>\n"
- " This option specifies the local port GUID value\n"
- " with which osmtest should bind. osmtest may be\n"
- " bound to 1 port at a time\n\n");
- printf("-p \n"
- "--port\n"
- " This option displays a menu of possible local port GUID values\n"
- " with which osmtest could bind\n\n");
- printf("-h\n"
- "--help\n" " Display this usage info then exit\n\n");
- printf("-i <filename>\n"
- "--inventory <filename>\n"
- " This option specifies the name of the inventory file\n"
- " Normally, osmtest expects to find an inventory file,\n"
- " which osmtest uses to validate real-time information\n"
- " received from the SA during testing\n"
- " If -i is not specified, osmtest defaults to the file\n"
- " 'osmtest.dat'\n"
- " See -c option for related information\n\n");
- printf("-s\n"
- "--stress\n"
- " This option runs the specified stress test instead\n"
- " of the normal test suite\n"
- " Stress test options are as follows:\n"
- " OPT Description\n"
- " --- -----------------\n"
- " -s1 - Single-MAD response SA queries\n"
- " -s2 - Multi-MAD (RMPP) response SA queries\n"
- " -s3 - Multi-MAD (RMPP) Path Record SA queries\n"
- " Without -s, stress testing is not performed\n\n");
- printf("-M\n"
- "--Multicast_Mode\n"
- " This option specify length of Multicast test:\n"
- " OPT Description\n"
- " --- -----------------\n"
- " -M1 - Short Multicast Flow (default) - single mode\n"
- " -M2 - Short Multicast Flow - multiple mode\n"
- " -M3 - Long Multicast Flow - single mode\n"
- " -M4 - Long Multicast Flow - multiple mode\n"
- " Single mode - Osmtest is tested alone, with no other\n"
- " apps that interact with OpenSM MC\n"
- " Multiple mode - Could be run with other apps using MC with\n"
- " OpenSM."
- " Without -M, default flow testing is performed\n\n");
-
- printf("-t <milliseconds>\n"
- " This option specifies the time in milliseconds\n"
- " used for transaction timeouts\n"
- " Specifying -t 0 disables timeouts\n"
- " Without -t, osmtest defaults to a timeout value of\n"
- " 1 second\n\n");
- printf("-l\n"
- "--log_file\n"
- " This option defines the log to be the given file\n"
- " By default the log goes to stdout\n\n");
- printf("-v\n"
- " This option increases the log verbosity level\n"
- " The -v option may be specified multiple times\n"
- " to further increase the verbosity level\n"
- " See the -vf option for more information about.\n"
- " log verbosity\n\n");
- printf("-V\n"
- " This option sets the maximum verbosity level and\n"
- " forces log flushing\n"
- " The -V is equivalent to '-vf 0xFF -d 2'\n"
- " See the -vf option for more information about.\n"
- " log verbosity\n\n");
- printf("-vf <flags>\n"
- " This option sets the log verbosity level\n"
- " A flags field must follow the -vf option\n"
- " A bit set/clear in the flags enables/disables a\n"
- " specific log level as follows:\n"
- " BIT LOG LEVEL ENABLED\n"
- " ---- -----------------\n"
- " 0x01 - ERROR (error messages)\n"
- " 0x02 - INFO (basic messages, low volume)\n"
- " 0x04 - VERBOSE (interesting stuff, moderate volume)\n"
- " 0x08 - DEBUG (diagnostic, high volume)\n"
- " 0x10 - FUNCS (function entry/exit, very high volume)\n"
- " 0x20 - FRAMES (dumps all SMP and GMP frames)\n"
- " 0x40 - currently unused\n"
- " 0x80 - currently unused\n"
- " Without -vf, osmtest defaults to ERROR + INFO (0x3)\n"
- " Specifying -vf 0 disables all messages\n"
- " Specifying -vf 0xFF enables all messages (see -V)\n"
- " High verbosity levels may require increasing\n"
- " the transaction timeout with the -t option\n\n");
-}
-
-/**********************************************************************
- **********************************************************************/
-static void print_all_guids(IN osmtest_t * p_osmt);
-static void print_all_guids(IN osmtest_t * p_osmt)
-{
- ib_api_status_t status;
- uint32_t num_ports = GUID_ARRAY_SIZE;
- ib_port_attr_t attr_array[GUID_ARRAY_SIZE];
- int i;
-
- /*
- Call the transport layer for a list of local port
- GUID values.
- */
- status =
- osm_vendor_get_all_port_attr(p_osmt->p_vendor, attr_array,
- &num_ports);
- if (status != IB_SUCCESS) {
- printf("\nError from osm_vendor_get_all_port_attr (%x)\n",
- status);
- return;
- }
-
- printf("\nListing GUIDs:\n");
- for (i = 0; i < num_ports; i++)
- printf("Port %i: 0x%" PRIx64 "\n", i,
- cl_hton64(attr_array[i].port_guid));
-}
-
-/**********************************************************************
- **********************************************************************/
-ib_net64_t get_port_guid(IN osmtest_t * p_osmt, uint64_t port_guid)
-{
- ib_api_status_t status;
- uint32_t num_ports = GUID_ARRAY_SIZE;
- ib_port_attr_t attr_array[GUID_ARRAY_SIZE];
- int i;
-
- /*
- Call the transport layer for a list of local port
- GUID values.
- */
-/* "local ports" is(?) phys, shouldn't this exclude port 0 then ? */
- status =
- osm_vendor_get_all_port_attr(p_osmt->p_vendor, attr_array,
- &num_ports);
- if (status != IB_SUCCESS) {
- printf("\nError from osm_vendor_get_all_port_attr (%x)\n",
- status);
- return (0);
- }
-
- if (num_ports == 1) {
- printf("using default guid 0x%" PRIx64 "\n",
- cl_hton64(attr_array[0].port_guid));
- return (attr_array[0].port_guid);
- }
-
- for (i = 0; i < num_ports; i++) {
- if (attr_array[i].port_guid == port_guid ||
- (!port_guid && attr_array[i].link_state > IB_LINK_DOWN))
- return attr_array[i].port_guid;
- }
-
- return 0;
-}
-
-/**********************************************************************
- **********************************************************************/
-int main(int argc, char *argv[])
-{
- static osmtest_t osm_test;
- osmtest_opt_t opt = { 0 };
- ib_net64_t guid = 0;
- uint16_t max_lid = 100;
- ib_api_status_t status;
- uint32_t log_flags = OSM_LOG_ERROR | OSM_LOG_INFO;
- int32_t vendor_debug = 0;
- char flow_name[64];
- uint32_t next_option;
- const char *const short_option = "f:l:m:M:d:g:s:t:i:pcvVh";
-
- /*
- * In the array below, the 2nd parameter specified the number
- * of arguments as follows:
- * 0: no arguments
- * 1: argument
- * 2: optional
- */
- const struct option long_option[] = {
- {"create", 0, NULL, 'c'},
- {"debug", 1, NULL, 'd'},
- {"flow", 1, NULL, 'f'},
- {"wait", 1, NULL, 'w'},
- {"inventory", 1, NULL, 'i'},
- {"max_lid", 1, NULL, 'm'},
- {"guid", 2, NULL, 'g'},
- {"port", 0, NULL, 'p'},
- {"help", 0, NULL, 'h'},
- {"stress", 1, NULL, 's'},
- {"Multicast_Mode", 1, NULL, 'M'},
- {"timeout", 1, NULL, 't'},
- {"verbose", 0, NULL, 'v'},
- {"log_file", 1, NULL, 'l'},
- {"vf", 1, NULL, 'x'},
- {"V", 0, NULL, 'V'},
-
- {NULL, 0, NULL, 0} /* Required at end of array */
- };
-
- /* Make sure that the opensm, complib and osmtest were compiled using
- same modes (debug/free) */
- if (osm_is_debug() != cl_is_debug() || osm_is_debug() != osmt_is_debug()
- || osmt_is_debug() != cl_is_debug()) {
- fprintf(stderr,
- "-E- OpenSM, Complib and OsmTest were compiled using different modes\n");
- fprintf(stderr,
- "-E- OpenSM debug:%d Complib debug:%d OsmTest debug:%d \n",
- osm_is_debug(), cl_is_debug(), osmt_is_debug());
- exit(1);
- }
-
- opt.transaction_timeout = OSMT_DEFAULT_TRANS_TIMEOUT_MILLISEC;
- opt.wait_time = OSMT_DEFAULT_TRAP_WAIT_TIMEOUT_SEC;
- opt.retry_count = OSMT_DEFAULT_RETRY_COUNT;
- opt.force_log_flush = FALSE;
- opt.stress = 0;
- opt.log_file = NULL;
- opt.create = FALSE;
- opt.mmode = 1;
- opt.ignore_path_records = FALSE; /* Do path Records too */
- opt.flow = OSMT_FLOW_ALL; /* run all validation tests */
- strcpy(flow_name, "All Validations");
- strcpy(opt.file_name, "osmtest.dat");
-
- printf("\nCommand Line Arguments\n");
- do {
- next_option = getopt_long_only(argc, argv, short_option,
- long_option, NULL);
- switch (next_option) {
- case 'c':
- /*
- * Create the inventory file.
- */
- opt.create = TRUE;
- printf("\tCreating inventory file\n");
- break;
-
- case 'i':
- /*
- * Specifies inventory file name.
- */
- if (strlen(optarg) > OSMTEST_FILE_PATH_MAX)
- printf
- ("\nError: path name too long (ignored)\n");
- else
- strcpy(opt.file_name, optarg);
-
- printf("\tFile = %s\n", opt.file_name);
- break;
-
- case 'f':
- /*
- * Specifies Flow .
- */
- if (strlen(optarg) > OSMTEST_FILE_PATH_MAX)
- printf
- ("\nError: path name too long (ignored)\n");
- else
- strcpy(flow_name, optarg);
-
- if (!strcmp("c", optarg)) {
- strcpy(flow_name, "Create Inventory");
- opt.flow = OSMT_FLOW_CREATE_INVENTORY;
- } else if (!strcmp("v", optarg)) {
- strcpy(flow_name, "Validate Inventory");
- opt.flow = OSMT_FLOW_VALIDATE_INVENTORY;
- } else if (!strcmp("s", optarg)) {
- strcpy(flow_name, "Services Registration");
- opt.flow = OSMT_FLOW_SERVICE_REGISTRATION;
- } else if (!strcmp("e", optarg)) {
- strcpy(flow_name, "Event Forwarding");
- opt.flow = OSMT_FLOW_EVENT_FORWARDING;
- } else if (!strcmp("f", optarg)) {
- strcpy(flow_name, "Stress SA");
- opt.flow = OSMT_FLOW_STRESS_SA;
- } else if (!strcmp("m", optarg)) {
- strcpy(flow_name, "Multicast");
- opt.flow = OSMT_FLOW_MULTICAST;
- } else if (!strcmp("q", optarg)) {
- strcpy(flow_name, "QoS: VLArb and SLtoVL");
- opt.flow = OSMT_FLOW_QOS;
- } else if (!strcmp("t", optarg)) {
- strcpy(flow_name, "Trap 64/65");
- opt.flow = OSMT_FLOW_TRAP;
- } else if (!strcmp("a", optarg)) {
- strcpy(flow_name, "All Validations");
- opt.flow = OSMT_FLOW_ALL;
- } else {
- printf("\nError: unknown flow %s\n", flow_name);
- exit(2);
- }
- break;
-
- case 'w':
- /*
- * Specifies trap 64/65 wait time
- */
- CL_ASSERT(strtol(optarg, NULL, 0) < 0x100);
- opt.wait_time = (uint8_t) strtol(optarg, NULL, 0);
- printf("\tTrap 64/65 wait time = %d\n", opt.wait_time);
- break;
-
- case 'm':
- /*
- * Specifies the max LID to search for during exploration.
- */
- max_lid = atoi(optarg);
- printf("\tMAX-LID %u\n", max_lid);
- break;
-
- case 'g':
- /*
- * Specifies port guid with which to bind.
- */
- guid = cl_hton64(strtoull(optarg, NULL, 16));
- printf(" Guid <0x%" PRIx64 ">\n", cl_hton64(guid));
- break;
-
- case 'p':
- /*
- * Display current port guids
- */
- guid = INVALID_GUID;
- break;
-
- case 't':
- /*
- * Specifies transaction timeout.
- */
- opt.transaction_timeout = strtol(optarg, NULL, 0);
- printf("\tTransaction timeout = %d\n",
- opt.transaction_timeout);
- break;
-
- case 'l':
- opt.log_file = optarg;
- printf("\tLog File:%s\n", opt.log_file);
- break;
-
- case 'v':
- /*
- * Increases log verbosity.
- */
- log_flags = (log_flags << 1) | 1;
- printf("\tVerbose option -v (log flags = 0x%X)\n",
- log_flags);
- break;
-
- case 'V':
- /*
- * Specifies maximum log verbosity.
- */
- log_flags = 0xFFFFFFFF;
- opt.force_log_flush = TRUE;
- printf("\tEnabling maximum log verbosity\n");
- break;
-
- case 's':
- /*
- * Perform stress test.
- */
- opt.stress = strtol(optarg, NULL, 0);
- printf("\tStress test enabled: ");
- switch (opt.stress) {
- case 1:
- printf("Small SA queries\n");
- break;
- case 2:
- printf("Large SA queries\n");
- break;
- case 3:
- printf("Large Path Record SA queries\n");
- break;
- default:
- printf("Unknown value %u (ignored)\n",
- opt.stress);
- opt.stress = 0;
- break;
- }
- break;
-
- case 'M':
- /*
- * Perform multicast test.
- */
- opt.mmode = strtol(optarg, NULL, 0);
- printf("\tMulticast test enabled: ");
- switch (opt.mmode) {
- case 1:
- printf
- ("Short MC Flow - single mode (default)\n");
- break;
- case 2:
- printf("Short MC Flow - multiple mode\n");
- break;
- case 3:
- printf("Long MC Flow - single mode\n");
- break;
- case 4:
- printf("Long MC Flow - multiple mode\n");
- break;
- default:
- printf("Unknown value %u (ignored)\n",
- opt.stress);
- opt.mmode = 0;
- break;
- }
- break;
-
- case 'd':
- /*
- * Debug Options
- */
- printf("\tDebug Option: ");
- switch (strtol(optarg, NULL, 0)) {
- case 1:
- printf("Ignore Path Records\n");
- opt.ignore_path_records = TRUE;
- break;
- case 2:
- printf("Force Log Flush\n");
- opt.force_log_flush = TRUE;
- break;
- case 3:
- /* Used to be memory tracking */
- default:
- printf("Unknown value %ld (ignored)\n",
- strtol(optarg, NULL, 0));
- break;
- }
- break;
-
- case 'h':
- show_usage();
- return 0;
-
- case 'x':
- log_flags = strtol(optarg, NULL, 0);
- printf
- ("\t\t\t\tVerbose option -vf (log flags = 0x%X)\n",
- log_flags);
- break;
-
- case -1:
- printf("Done with args\n");
- break;
-
- default:
- show_usage();
- return 1;
- }
-
- }
- while (next_option != -1);
-
- printf("\tFlow = %s\n", flow_name);
-
- if (vendor_debug)
- osm_vendor_set_debug(osm_test.p_vendor, vendor_debug);
-
- complib_init();
-
- status = osmtest_init(&osm_test, &opt, (osm_log_level_t) log_flags);
- if (status != IB_SUCCESS) {
- printf("\nError from osmtest_init: %s\n",
- ib_get_err_str(status));
- goto Exit;
- }
- if (cl_hton64(guid) == cl_hton64(INVALID_GUID)) {
- print_all_guids(&osm_test);
- complib_exit();
- return (status);
- }
-
- /*
- If the user didn't specify a GUID on the command line,
- then get a port GUID value with which to bind.
- */
- if (guid == 0 && !(guid = get_port_guid(&osm_test, guid))) {
- printf("\nError: port guid 0x%" PRIx64 " not found\n", guid);
- goto Exit;
- }
-
- /*
- * Guid may be zero going into this function if the user
- * hasn't specified a binding port on the command line.
- */
- status = osmtest_bind(&osm_test, max_lid, guid);
- if (status != IB_SUCCESS)
- exit(status);
-
- status = osmtest_run(&osm_test);
- if (status != IB_SUCCESS) {
- printf("OSMTEST: TEST \"%s\" FAIL\n", flow_name);
- } else {
- printf("OSMTEST: TEST \"%s\" PASS\n", flow_name);
- }
- osmtest_destroy(&osm_test);
-
- complib_exit();
-
-Exit:
- return (status);
-}
diff --git a/contrib/ofed/management/opensm/osmtest/osmt_inform.c b/contrib/ofed/management/opensm/osmtest/osmt_inform.c
deleted file mode 100644
index c252a4c..0000000
--- a/contrib/ofed/management/opensm/osmtest/osmt_inform.c
+++ /dev/null
@@ -1,767 +0,0 @@
-/*
- * Copyright (c) 2006-2008 Voltaire, Inc. All rights reserved.
- * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved.
- * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- */
-
-#ifdef OSM_VENDOR_INTF_MTL
-/*
- * Abstract:
- * Implementation of InformInfo testing flow..
- * Top level is osmt_run_inform_info_flow:
- * osmt_bind_inform_qp
- * osmt_reg_unreg_inform_info
- * osmt_send_trap_wait_for_forward
- *
- */
-
-#include <unistd.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <complib/cl_debug.h>
-#include <vendor/osm_vendor_mlx_hca.h>
-#include "osmtest.h"
-#include "osmt_inform.h"
-
-/*
- * Prepare an asynchronous QP (rcv) for sending inform info and
- * handling the incoming reports.
- *
- */
-ib_api_status_t
-osmt_bind_inform_qp(IN osmtest_t * const p_osmt, OUT osmt_qp_ctx_t * p_qp_ctx)
-{
- ib_net64_t port_guid;
- VAPI_hca_hndl_t hca_hndl;
- VAPI_hca_id_t hca_id;
- uint32_t port_num;
- VAPI_ret_t vapi_ret;
- IB_MGT_ret_t mgt_ret;
- uint8_t hca_index;
- osm_log_t *p_log = &p_osmt->log;
- ib_api_status_t status = IB_SUCCESS;
-
- OSM_LOG_ENTER(p_log);
-
- port_guid = p_osmt->local_port.port_guid;
-
- OSM_LOG(p_log, OSM_LOG_DEBUG, "Binding to port 0x%" PRIx64 "\n",
- cl_ntoh64(port_guid));
-
- /* obtain the hca name and port num from the guid */
- OSM_LOG(p_log, OSM_LOG_DEBUG,
- "Finding CA and Port that owns port guid 0x%" PRIx64 "\n",
- port_guid);
-
- mgt_ret =
- osm_vendor_get_guid_ca_and_port(p_osmt->p_vendor,
- port_guid,
- &hca_hndl,
- &hca_id[0], &hca_index, &port_num);
- if (mgt_ret != IB_MGT_OK) {
- OSM_LOG(p_log, OSM_LOG_ERROR, "ERR 0109: "
- "Unable to obtain CA and port (%d).\n");
- status = IB_ERROR;
- goto Exit;
- }
-#define OSMT_MTL_REVERSE_QP1_WELL_KNOWN_Q_KEY 0x80010000
-
- strncpy(p_qp_ctx->qp_bind_hndl.hca_id, hca_id, sizeof(hca_id));
- p_qp_ctx->qp_bind_hndl.hca_hndl = hca_hndl;
- p_qp_ctx->qp_bind_hndl.port_num = port_num;
- p_qp_ctx->qp_bind_hndl.max_outs_sq = 10;
- p_qp_ctx->qp_bind_hndl.max_outs_rq = 10;
- p_qp_ctx->qp_bind_hndl.qkey = OSMT_MTL_REVERSE_QP1_WELL_KNOWN_Q_KEY;
-
- vapi_ret = osmt_mtl_init_opened_hca(&p_qp_ctx->qp_bind_hndl);
- if (vapi_ret != VAPI_OK) {
- OSM_LOG(p_log, OSM_LOG_ERROR, "ERR 0114: "
- "Error initializing QP.\n");
- status = IB_ERROR;
- goto Exit;
- }
-
- /* we use the pre-allocated buffers for send and receive :
- send from buf[0]
- receive from buf[2]
- */
- p_qp_ctx->p_send_buf =
- (uint8_t *) p_qp_ctx->qp_bind_hndl.buf_ptr + GRH_LEN;
- p_qp_ctx->p_recv_buf =
- (uint8_t *) p_qp_ctx->qp_bind_hndl.buf_ptr + 2 * (GRH_LEN +
- MAD_BLOCK_SIZE);
-
- /* Need to clear assigned memory of p_send_buf - before using it to send any data */
- memset(p_qp_ctx->p_send_buf, 0, MAD_BLOCK_SIZE);
-
- status = IB_SUCCESS;
- OSM_LOG(p_log, OSM_LOG_DEBUG, "Initialized QP:0x%X in VAPI Mode\n",
- p_qp_ctx->qp_bind_hndl.qp_id);
-
- OSM_LOG(p_log, OSM_LOG_DEBUG, "Binding to IB_MGT SMI\n");
-
- /* we also need a QP0 handle for sending packets */
- mgt_ret = IB_MGT_get_handle(hca_id, port_num, IB_MGT_SMI,
- &(p_qp_ctx->ib_mgt_qp0_handle));
- if (IB_MGT_OK != mgt_ret) {
- OSM_LOG(p_log, OSM_LOG_ERROR, "ERR 0115: "
- "Error obtaining IB_MGT handle to SMI\n");
- status = IB_ERROR;
- goto Exit;
- }
-
-Exit:
- OSM_LOG_EXIT(p_log);
- return status;
-}
-
-/*
- * Close the QP
- */
-void
-osmt_unbind_inform_qp(IN osmtest_t * const p_osmt, IN osmt_qp_ctx_t * p_qp_ctx)
-{
- osm_log_t *p_log = &p_osmt->log;
-
- OSM_LOG_ENTER(p_log);
-
- osmt_mtl_mad_cleanup(&p_qp_ctx->qp_bind_hndl);
-
- IB_MGT_release_handle(p_qp_ctx->ib_mgt_qp0_handle);
-
- OSM_LOG(p_log, OSM_LOG_DEBUG, "Unbind QP handles\n");
- OSM_LOG_EXIT(&p_osmt->log);
-}
-
-/*
- * Register/Unregister to receive the given InformInfo
- *
- * Uses the qp context to send the inform info mad.
- * Wait for GetResp(InformInfoResp)
- *
- */
-ib_api_status_t
-osmt_reg_unreg_inform_info(IN osmtest_t * p_osmt,
- IN osmt_qp_ctx_t * p_qp_ctx,
- IN ib_inform_info_t * p_inform_info,
- IN uint8_t reg_flag)
-{
- ib_sa_mad_t *p_sa_mad = (ib_sa_mad_t *) (p_qp_ctx->p_send_buf);
- ib_inform_info_t *p_ii = ib_sa_mad_get_payload_ptr(p_sa_mad); /* SA Payload */
- VAPI_ret_t vapi_ret;
- VAPI_wc_desc_t wc_desc;
- VAPI_ud_av_hndl_t avh;
- static VAPI_wr_id_t wrid = 16198;
- osm_log_t *p_log = &p_osmt->log;
- ib_api_status_t status = IB_SUCCESS;
-
- OSM_LOG_ENTER(&p_osmt->log);
-
- /* init the MAD */
- ib_mad_init_new((ib_mad_t *) p_sa_mad,
- IB_MCLASS_SUBN_ADM,
- (uint8_t) 2,
- IB_MAD_METHOD_SET, cl_hton64(wrid), (ib_net16_t) 0, 0);
- wrid++;
- p_sa_mad->attr_id = IB_MAD_ATTR_INFORM_INFO;
-
- /* copy the reference inform info */
- memcpy(p_ii, p_inform_info, sizeof(ib_inform_info_t));
-
- if (reg_flag) {
- OSM_LOG(&p_osmt->log, OSM_LOG_INFO,
- "Subscribing InformInfo: Traps from lid:0x%X to 0x%X, trap num :0x%X\n",
- p_ii->lid_range_begin, p_ii->lid_range_end,
- p_ii->g_or_v.generic.trap_num);
- } else {
- OSM_LOG(&p_osmt->log, OSM_LOG_INFO,
- "UnSubscribing InformInfo: Traps from lid:0x%X to 0x%X\n",
- p_ii->lid_range_begin, p_ii->lid_range_end);
- }
-
- /* set the subscribe bit */
- if (reg_flag) {
- p_ii->subscribe = 1;
- } else {
- p_ii->subscribe = 0;
- /*
- * we need to set the QPN on the mad if we unsubscribe:
- * o13-2.1.1 - QPN Field need to be set when unsubscribing.
- */
- ib_inform_info_set_qpn(p_ii,
- cl_hton32(p_qp_ctx->qp_bind_hndl.qp_id.
- qp_num));
- }
-
- osm_dump_inform_info(&p_osmt->log, p_ii, OSM_LOG_DEBUG);
-
- /* --------------------- PREP ------------------------- */
- if (osmt_mtl_mad_post_recv_bufs(&p_qp_ctx->qp_bind_hndl, p_qp_ctx->p_recv_buf, 1, /* but we need only one mad at a time */
- GRH_LEN + MAD_BLOCK_SIZE, wrid) != 1) {
- OSM_LOG(p_log, OSM_LOG_ERROR, "ERR 0120: "
- "Error posting recv bufs\n");
- status = IB_ERROR;
- goto Exit;
- }
- OSM_LOG(p_log, OSM_LOG_DEBUG, "Posted recv bufs\n");
-
- vapi_ret =
- osmt_mtl_create_av(&p_qp_ctx->qp_bind_hndl,
- p_osmt->local_port.sm_lid, &avh);
- if (vapi_ret != VAPI_OK) {
- OSM_LOG(p_log, OSM_LOG_ERROR, "ERR 0121: "
- "Error Preparing AVH (%s)\n",
- VAPI_strerror_sym(vapi_ret));
- status = IB_ERROR;
- goto Exit;
- }
- OSM_LOG(p_log, OSM_LOG_DEBUG, "Prepared AVH\n");
-
- if (osm_log_is_active(p_log, OSM_LOG_DEBUG)) {
- osm_dump_sa_mad(p_log, (ib_sa_mad_t *) (p_qp_ctx->p_send_buf),
- OSM_LOG_DEBUG);
-#if 0
- for (i = 56; i < 253; i++) {
- if (i % 8 == 0) {
- printf("\n %d : ", i);
- }
- printf("0x%02X ", p_qp_ctx->p_send_buf[i]);
- }
-#endif
- printf("\n");
- }
-
- /* --------------------- SEND ------------------------- */
- vapi_ret = osmt_mtl_mad_send(&p_qp_ctx->qp_bind_hndl, wrid, p_qp_ctx->p_send_buf, 1, /* SA is QP1 */
- 0, /* SL is 0 */
- OSMT_MTL_REVERSE_QP1_WELL_KNOWN_Q_KEY,
- avh);
- if (vapi_ret != VAPI_OK) {
- OSM_LOG(p_log, OSM_LOG_ERROR, "ERR 0122: "
- "Error sending mad (%s)\n",
- VAPI_strerror_sym(vapi_ret));
- status = IB_ERROR;
- goto Exit;
- }
-
- vapi_ret = osmt_mtl_mad_poll4cqe(p_qp_ctx->qp_bind_hndl.hca_hndl,
- p_qp_ctx->qp_bind_hndl.sq_cq_hndl,
- &wc_desc, 20, 10000, NULL);
- if (vapi_ret != VAPI_OK) {
- OSM_LOG(p_log, OSM_LOG_ERROR, "ERR 0123: "
- "Error getting send completion (%s)\n",
- VAPI_strerror_sym(vapi_ret));
- status = IB_ERROR;
- goto Exit;
- }
-
- if (wc_desc.status != VAPI_SUCCESS) {
- OSM_LOG(p_log, OSM_LOG_ERROR, "ERR 0124: "
- "Error on send completion (%s) (%d)\n",
- VAPI_strerror_sym(wc_desc.status), wc_desc.status);
- status = IB_ERROR;
- goto Exit;
- }
- OSM_LOG(p_log, OSM_LOG_DEBUG, "Sent MAD\n");
-
- /* --------------------- RECV ------------------------- */
- vapi_ret = osmt_mtl_mad_poll4cqe(p_qp_ctx->qp_bind_hndl.hca_hndl,
- p_qp_ctx->qp_bind_hndl.rq_cq_hndl,
- &wc_desc, 20, 10000, &avh);
- if (vapi_ret != VAPI_SUCCESS) {
- if (vapi_ret == VAPI_CQ_EMPTY) {
- status = IB_TIMEOUT;
- } else {
- OSM_LOG(p_log, OSM_LOG_ERROR, "ERR 0125: "
- "Error receiving mad (%s)\n",
- VAPI_strerror_sym(vapi_ret));
- status = IB_ERROR;
- }
- goto Exit;
- }
-
- /* check to see if successful - by examination of the subscribe bit */
- p_sa_mad = (ib_sa_mad_t *) (p_qp_ctx->p_recv_buf + GRH_LEN);
-
- if (p_sa_mad->status != IB_SUCCESS) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "Remote error = %s\n",
- ib_get_mad_status_str((ib_mad_t *) p_sa_mad));
- status = IB_REMOTE_ERROR;
- goto Exit;
- }
-
- if (p_sa_mad->method != IB_MAD_METHOD_GET_RESP) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR,
- "Expected IB_MAD_METHOD_GET_RESP but got:(%X)\n",
- p_sa_mad->method);
- status = IB_REMOTE_ERROR;
- goto Exit;
- }
-
- if (p_sa_mad->attr_id != IB_MAD_ATTR_INFORM_INFO) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR,
- "Expected IB_MAD_ATTR_INFORM_INFO but got:(%X)\n",
- cl_ntoh16(p_sa_mad->attr_id));
- status = IB_REMOTE_ERROR;
- goto Exit;
- }
-
- p_ii = ib_sa_mad_get_payload_ptr(p_sa_mad);
- if (!p_ii->subscribe) {
- OSM_LOG(p_log, OSM_LOG_ERROR, "ERR 0126: "
- "Subscribe/Unsubscribe Failed\n");
- status = IB_REMOTE_ERROR;
- }
-
-Exit:
- OSM_LOG_EXIT(&p_osmt->log);
- return status;
-}
-
-/*
- * Send a trap (Subn LID Route) Trap(Notice) through the regular
- * connection QP connection (targeted at QP0)
- *
- * Wait for the trap repress
- */
-ib_api_status_t
-osmt_send_trap_wait_for_forward(IN osmtest_t * const p_osmt,
- IN osmt_qp_ctx_t * p_qp_ctx)
-{
- ib_smp_t *p_smp = (ib_smp_t *) (p_qp_ctx->p_send_buf);
- ib_mad_notice_attr_t *p_ntc = ib_smp_get_payload_ptr(p_smp);
- ib_sa_mad_t *p_sa_mad;
- IB_MGT_ret_t mgt_res;
- VAPI_ret_t vapi_ret;
- VAPI_wc_desc_t wc_desc;
- VAPI_ud_av_hndl_t avh;
- IB_ud_av_t av;
- static VAPI_wr_id_t wrid = 2222;
- osm_log_t *p_log = &p_osmt->log;
- ib_api_status_t status = IB_SUCCESS;
-
- OSM_LOG_ENTER(p_log);
-
- OSM_LOG(p_log, OSM_LOG_INFO,
- "Sending Traps to QP0 of SA LID:0x%X\n",
- p_osmt->local_port.sm_lid);
-
- /* init the MAD */
- memset(p_smp, 0, sizeof(ib_smp_t));
- ib_mad_init_new((ib_mad_t *) p_smp,
- IB_MCLASS_SUBN_LID,
- (uint8_t) 2,
- IB_MAD_METHOD_TRAP, cl_hton64(wrid), (ib_net16_t) 0, 0);
-
- wrid++;
- p_smp->attr_id = IB_MAD_ATTR_NOTICE;
-
- /* prepare the notice */
- p_ntc->generic_type = 0x82; /* generic, type = 2 */
- ib_notice_set_prod_type_ho(p_ntc, 1);
- p_ntc->g_or_v.generic.trap_num = cl_hton16(0x26);
- p_ntc->issuer_lid = cl_hton16(2);
-
- /* --------------------- PREP ------------------------- */
- if (osmt_mtl_mad_post_recv_bufs(&p_qp_ctx->qp_bind_hndl, p_qp_ctx->p_recv_buf, 1, /* we need to receive both trap repress and report */
- GRH_LEN + MAD_BLOCK_SIZE, wrid) != 1) {
- OSM_LOG(p_log, OSM_LOG_ERROR, "ERR 0127: "
- "Error posting recv bufs\n");
- status = IB_ERROR;
- goto Exit;
- }
- OSM_LOG(p_log, OSM_LOG_DEBUG, "Posted recv bufs\n");
-
- av.dlid = p_osmt->local_port.sm_lid;
- av.grh_flag = FALSE;
-
- /* EZ: returned in HACK: use constants */
- av.static_rate = 0; /* p_mad_addr->static_rate; */
- av.src_path_bits = 1; /* p_mad_addr->path_bits; */
- av.sl = 0; /* p_mad_addr->addr_type.gsi.service_level; */
-
- OSM_LOG(p_log, OSM_LOG_DEBUG,
- "av.dlid 0x%X, av.static_rate %d, av.path_bits %d\n",
- cl_ntoh16(av.dlid), av.static_rate, av.src_path_bits);
-
- /* send it */
- mgt_res = IB_MGT_send_mad(p_qp_ctx->ib_mgt_qp0_handle, p_smp, /* actual payload */
- &av, /* address vector */
- wrid, /* casting the mad wrapper pointer for err cb */
- p_osmt->opt.transaction_timeout);
- if (mgt_res != IB_MGT_OK) {
- OSM_LOG(p_log, OSM_LOG_ERROR, "ERR 0128: "
- "Error sending mad (%d)\n", mgt_res);
- status = IB_ERROR;
- goto Exit;
- }
-
- vapi_ret =
- osmt_mtl_create_av(&p_qp_ctx->qp_bind_hndl,
- p_osmt->local_port.sm_lid, &avh);
- if (vapi_ret != VAPI_OK) {
- OSM_LOG(p_log, OSM_LOG_ERROR, "ERR 0129: "
- "Error Preparing AVH (%s)\n",
- VAPI_strerror_sym(vapi_ret));
- status = IB_ERROR;
- goto Exit;
- }
- OSM_LOG(p_log, OSM_LOG_DEBUG, "Prepared AVH\n");
-
- OSM_LOG(p_log, OSM_LOG_DEBUG, "Trap MAD Sent\n");
-
- /* --------------------- RECV ------------------------- */
- vapi_ret = osmt_mtl_mad_poll4cqe(p_qp_ctx->qp_bind_hndl.hca_hndl,
- p_qp_ctx->qp_bind_hndl.rq_cq_hndl,
- &wc_desc, 200, 10000, &avh);
- if (vapi_ret != VAPI_SUCCESS) {
- if (vapi_ret == VAPI_CQ_EMPTY) {
- OSM_LOG(p_log, OSM_LOG_ERROR, "ERR 0130: "
- "Timeout receiving mad (%s)\n",
- VAPI_strerror_sym(vapi_ret));
- status = IB_TIMEOUT;
- } else {
- OSM_LOG(p_log, OSM_LOG_ERROR, "ERR 0131: "
- "Error receiving mad (%s)\n",
- VAPI_strerror_sym(vapi_ret));
- status = IB_ERROR;
- }
- goto Exit;
- }
-
- /* check to see if successful - by examination of the subscribe bit */
- p_sa_mad = (ib_sa_mad_t *) (p_qp_ctx->p_recv_buf + GRH_LEN);
-
- if (p_sa_mad->method == IB_MAD_METHOD_REPORT) {
- if (p_sa_mad->attr_id == IB_MAD_ATTR_NOTICE) {
- OSM_LOG(p_log, OSM_LOG_INFO, "Received the Report!\n");
- status = IB_SUCCESS;
- } else {
- OSM_LOG(p_log, OSM_LOG_ERROR, "ERR 1020"
- "Did not receive a Report(Notice) but attr:%d\n",
- cl_ntoh16(p_sa_mad->attr_id));
- status = IB_ERROR;
- }
- } else {
- OSM_LOG(p_log, OSM_LOG_ERROR, "ERR 1020"
- "Received an Unexpected Method:%d\n", p_smp->method);
- status = IB_ERROR;
- }
-
-Exit:
- OSM_LOG_EXIT(p_log);
- return status;
-}
-
-/*
- * Wait for a trap on QPn
- *
- */
-ib_api_status_t
-osmt_trap_wait(IN osmtest_t * const p_osmt, IN osmt_qp_ctx_t * p_qp_ctx)
-{
- ib_smp_t *p_smp = (ib_smp_t *) (p_qp_ctx->p_send_buf);
- ib_sa_mad_t *p_sa_mad;
- VAPI_ret_t vapi_ret;
- VAPI_wc_desc_t wc_desc;
- osm_log_t *p_log = &p_osmt->log;
- ib_api_status_t status = IB_SUCCESS;
-
- OSM_LOG_ENTER(p_log);
-
- OSM_LOG(p_log, OSM_LOG_INFO,
- "Waiting for Traps under QP:0x%X of SA LID:0x%X\n",
- cl_ntoh16(p_osmt->local_port.sm_lid));
-
- /* --------------------- RECV ------------------------- */
- vapi_ret = osmt_mtl_mad_poll4cqe(p_qp_ctx->qp_bind_hndl.hca_hndl,
- p_qp_ctx->qp_bind_hndl.rq_cq_hndl,
- &wc_desc,
- // 200,
- p_osmt->opt.wait_time * 100,
- 10000, NULL);
- if (vapi_ret != VAPI_SUCCESS) {
- if (vapi_ret == VAPI_CQ_EMPTY) {
- OSM_LOG(p_log, OSM_LOG_ERROR, "ERR 0130: "
- "Timeout receiving mad (%s)\n",
- VAPI_strerror_sym(vapi_ret));
- status = IB_TIMEOUT;
- } else {
- OSM_LOG(p_log, OSM_LOG_ERROR, "ERR 0131: "
- "Error receiving mad (%s)\n",
- VAPI_strerror_sym(vapi_ret));
- status = IB_ERROR;
- }
- goto Exit;
- }
-
- /* check to see if successful - by examination of the subscribe bit */
- p_sa_mad = (ib_sa_mad_t *) (p_qp_ctx->p_recv_buf + GRH_LEN);
-
- if (p_sa_mad->method == IB_MAD_METHOD_REPORT) {
- if (p_sa_mad->attr_id == IB_MAD_ATTR_NOTICE) {
- OSM_LOG(&p_osmt->log, OSM_LOG_INFO,
- "Received the Report!\n");
- status = IB_SUCCESS;
- } else {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 1020"
- "Did not receive a Report(Notice) but attr:%d\n",
- cl_ntoh16(p_sa_mad->attr_id));
- status = IB_ERROR;
- }
- } else {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 1020"
- "Received an Unexpected Method:%d\n", p_smp->method);
- status = IB_ERROR;
- }
-
-Exit:
- OSM_LOG_EXIT(p_log);
- return status;
-}
-
-/*
- * Initialize an inform info attribute:
- * Catch all traps in the lid range of the p_osmt
- *
- */
-ib_api_status_t
-osmt_init_inform_info(IN osmtest_t * const p_osmt, OUT ib_inform_info_t * p_ii)
-{
-
- memset(p_ii, 0, sizeof(ib_inform_info_t));
- /* p_ii->lid_range_begin = cl_hton16(1); */
- p_ii->lid_range_begin = 0xFFFF;
- p_ii->lid_range_end = cl_hton16(p_osmt->max_lid);
- p_ii->is_generic = 1; /* have to choose */
- p_ii->trap_type = 0xFFFF; /* ALL */
- p_ii->g_or_v.generic.trap_num = 0xFFFF; /* ALL */
- p_ii->g_or_v.generic.node_type_lsb = 0xFFFF; /* ALL */
- p_ii->g_or_v.generic.node_type_msb = 0xFF; /* ALL */
- return IB_SUCCESS;
-}
-
-ib_api_status_t
-osmt_init_inform_info_by_trap(IN osmtest_t * const p_osmt,
- IN ib_net16_t trap_num,
- OUT ib_inform_info_t * p_ii)
-{
-
- memset(p_ii, 0, sizeof(ib_inform_info_t));
- /* p_ii->lid_range_begin = cl_hton16(1); */
- p_ii->lid_range_begin = 0xFFFF;
- p_ii->lid_range_end = cl_hton16(p_osmt->max_lid);
- p_ii->is_generic = 1; /* have to choose */
- p_ii->trap_type = 0xFFFF; /* ALL */
- p_ii->g_or_v.generic.trap_num = trap_num; /* ALL */
- p_ii->g_or_v.generic.node_type_lsb = 0xFFFF; /* ALL */
- p_ii->g_or_v.generic.node_type_msb = 0xFF; /* ALL */
- return IB_SUCCESS;
-}
-
-/*
- * Run a complete inform info test flow:
- * - try to unregister inform info (should fail)
- * - register an inform info
- * - try to unregister inform info (should succeed)
- * - register an inform info
- * - send a trap - sleep
- * - check that a Report(Notice) arrived that match the sent one
- *
- */
-ib_api_status_t osmt_run_inform_info_flow(IN osmtest_t * const p_osmt)
-{
- ib_inform_info_t inform_info;
- ib_api_status_t status;
- osmt_qp_ctx_t qp_ctx;
-
- OSM_LOG_ENTER(&p_osmt->log);
-
- /* bind the QP */
- status = osmt_bind_inform_qp(p_osmt, &qp_ctx);
- if (status != IB_SUCCESS) {
- goto Exit;
- }
-
- /* init the inform info */
- osmt_init_inform_info(p_osmt, &inform_info);
-
- /* first try to unsubscribe */
- status = osmt_reg_unreg_inform_info(p_osmt, &qp_ctx, &inform_info, 0);
- /* WAS IB_REMOTE_ERROR */
- if (status != IB_REMOTE_ERROR) {
- if (status != IB_SUCCESS) {
- OSM_LOG(&p_osmt->log, OSM_LOG_INFO,
- "Error during UnSubscribe: (%s)\n",
- ib_get_err_str(status));
- goto Exit;
- } else {
- OSM_LOG(&p_osmt->log, OSM_LOG_INFO,
- "Expected Failure to UnSubscribe non existing InformInfo\n");
- status = IB_ERROR;
- goto Exit;
- }
- }
-
- /* send the inform info registration */
- status = osmt_reg_unreg_inform_info(p_osmt, &qp_ctx, &inform_info, 1);
- if (status != IB_SUCCESS) {
- goto Exit;
- }
-
- /* send a trap through QP0 and wait on QPN */
- status = osmt_send_trap_wait_for_forward(p_osmt, &qp_ctx);
- if (status != IB_SUCCESS) {
- OSM_LOG(&p_osmt->log, OSM_LOG_INFO,
- "Error during Send Trap and Wait For Report: (%s)\n",
- ib_get_err_str(status));
- goto Exit;
- }
-
- /* try to unsubscribe for cleanup */
- status = osmt_reg_unreg_inform_info(p_osmt, &qp_ctx, &inform_info, 0);
-
- if (status != IB_SUCCESS) {
- OSM_LOG(&p_osmt->log, OSM_LOG_INFO,
- "Error during UnSubscribe: (%s)\n",
- ib_get_err_str(status));
- goto Exit;
- } else {
- if (status == IB_REMOTE_ERROR) {
- OSM_LOG(&p_osmt->log, OSM_LOG_INFO,
- "Remote Error during UnSubscribe\n");
- status = IB_ERROR;
- goto Exit;
- }
- }
-
-Exit:
- osmt_unbind_inform_qp(p_osmt, &qp_ctx);
- OSM_LOG_EXIT(&p_osmt->log);
- return status;
-}
-
-/*
- * Run a complete inform info test flow:
- * - try to unregister inform info (should fail)
- * - register an inform info
- * - try to unregister inform info (should succeed)
- * - register an inform info
- * - send a trap - sleep
- * - check that a Report(Notice) arrived that match the sent one
- *
- */
-ib_api_status_t osmt_run_trap64_65_flow(IN osmtest_t * const p_osmt)
-{
- ib_inform_info_t inform_info;
- ib_api_status_t status;
- osmt_qp_ctx_t qp_ctx;
-
- OSM_LOG_ENTER(&p_osmt->log);
-
- /* bind the QP */
- status = osmt_bind_inform_qp(p_osmt, &qp_ctx);
- if (status != IB_SUCCESS) {
- goto Exit;
- }
-
- /* init the inform info */
- osmt_init_inform_info_by_trap(p_osmt, cl_hton16(64), &inform_info);
-
- /* send the inform info registration */
- status = osmt_reg_unreg_inform_info(p_osmt, &qp_ctx, &inform_info, 1);
- if (status != IB_SUCCESS) {
- goto Exit;
- }
-
- /*--------------------- PREP -------------------------*/
- if (osmt_mtl_mad_post_recv_bufs(&qp_ctx.qp_bind_hndl, qp_ctx.p_recv_buf, 1, /* we need to receive the report */
- GRH_LEN + MAD_BLOCK_SIZE, 1) != 1) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0127: "
- "Error posting recv bufs for trap 64\n");
- status = IB_ERROR;
- goto Exit;
- }
-
- OSM_LOG(&p_osmt->log, OSM_LOG_DEBUG, "Posted recv bufs for trap 64\n");
-
- /* init the inform info */
- osmt_init_inform_info_by_trap(p_osmt, cl_hton16(65), &inform_info);
-
- /* send the inform info registration */
- status = osmt_reg_unreg_inform_info(p_osmt, &qp_ctx, &inform_info, 1);
- if (status != IB_SUCCESS) {
- goto Exit;
- }
-
- /*--------------------- PREP -------------------------*/
- if (osmt_mtl_mad_post_recv_bufs(&qp_ctx.qp_bind_hndl, qp_ctx.p_recv_buf, 1, /* we need to reveive the report */
- GRH_LEN + MAD_BLOCK_SIZE, 1) != 1) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0127: "
- "Error posting recv bufs for trap 65\n");
- status = IB_ERROR;
- goto Exit;
- }
- OSM_LOG(&p_osmt->log, OSM_LOG_DEBUG, "Posted recv bufs for trap 65\n");
-
- /* Sleep for x seconds in order to allow external script trap generation */
-#if 0
- sleep(p_osmt->opt.wait_time);
-#endif
-
- /* wait for a trap on QPN */
- status = osmt_trap_wait(p_osmt, &qp_ctx);
- if (status != IB_SUCCESS) {
- OSM_LOG(&p_osmt->log, OSM_LOG_INFO,
- "Error during Send Trap and Wait For Report: (%s)\n",
- ib_get_err_str(status));
- goto Exit;
- }
-
- /* try to unsubscribe for cleanup */
- status = osmt_reg_unreg_inform_info(p_osmt, &qp_ctx, &inform_info, 0);
-
- if (status != IB_SUCCESS) {
- OSM_LOG(&p_osmt->log, OSM_LOG_INFO,
- "Error during UnSubscribe: (%s)\n",
- ib_get_err_str(status));
- goto Exit;
- }
-
-Exit:
- osmt_unbind_inform_qp(p_osmt, &qp_ctx);
- OSM_LOG_EXIT(&p_osmt->log);
- return status;
-}
-
-#endif /* OSM_VENDOR_INTF_MTL */
diff --git a/contrib/ofed/management/opensm/osmtest/osmt_mtl_regular_qp.c b/contrib/ofed/management/opensm/osmtest/osmt_mtl_regular_qp.c
deleted file mode 100644
index 6374dc2..0000000
--- a/contrib/ofed/management/opensm/osmtest/osmt_mtl_regular_qp.c
+++ /dev/null
@@ -1,469 +0,0 @@
-/*
- * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved.
- * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- */
-
-#ifdef OSM_VENDOR_INTF_MTL
-
-/* - Mellanox Confidential and Proprietary -
- *
- * Copyright (C) Jul. 2001, Mellanox Technologies Ltd. ALL RIGHTS RESERVED.
- *
- * Except as specifically permitted herein, no portion of the information,
- * including but not limited to object code and source code, may be reproduced,
- * modified, distributed, republished or otherwise exploited in any form or by
- * any means for any purpose without the prior written permission of Mellanox
- * Technologies Ltd. Use of software subject to the terms and conditions
- * detailed in the file "LICENSE.txt".
- *
- * End of legal section ......................................................
- *
- * osmt_mtl_regular_qp.c -
- * Provide Simple Interface for Sending and Receiving MADS through a regular QP
- *
- * Creation date:
- *
- * Version: $Id$
- *
- * Authors:
- * Eitan Zahavi
- *
- * Changes:
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-#include <signal.h>
-
-#include <mtl_common.h>
-#include <vapi.h>
-#include <evapi.h>
-#include <vapi_common.h>
-#include <ib_defs.h>
-#include <osmt_mtl_regular_qp.h>
-#include <complib/cl_types.h>
-/*
- * Initialize the QP etc.
- * Given in res: port_num, max_outs_sq, max_outs_rq
- */
-VAPI_ret_t osmt_mtl_get_qp_resources(IN OUT osmt_mtl_mad_res_t * res)
-{
- VAPI_ret_t ret;
- VAPI_hca_port_t hca_port_info;
- VAPI_qp_init_attr_t qp_init_attr;
- VAPI_qp_prop_t qp_prop;
- VAPI_cqe_num_t act_num;
-
- /* Get HCA LID */
- ret =
- VAPI_query_hca_port_prop(res->hca_hndl, res->port_num,
- &hca_port_info);
- VAPI_CHECK_RET;
- res->slid = hca_port_info.lid;
-
- /* Get a PD */
- ret = VAPI_alloc_pd(res->hca_hndl, &(res->pd_hndl));
- VAPI_CHECK_RET;
-
- /* Create CQ for RQ and SQ *//* TBD - Check we have enough act nums */
- ret =
- VAPI_create_cq(res->hca_hndl, res->max_outs_sq + 1,
- &(res->sq_cq_hndl), &act_num);
- VAPI_CHECK_RET;
- ret =
- VAPI_create_cq(res->hca_hndl, res->max_outs_rq + 1,
- &(res->rq_cq_hndl), &act_num);
- VAPI_CHECK_RET;
-
- /* register event handlers for polling(block mode) internal use */
- /* ret= EVAPI_set_comp_eventh(res->hca_hndl,res->rq_cq_hndl, */
- /* EVAPI_POLL_CQ_UNBLOCK_HANDLER,NULL,&(res->rq_cq_eventh)); */
- /* VAPI_CHECK_RET; */
- /* ret= EVAPI_set_comp_eventh(res->hca_hndl,res->sq_cq_hndl, */
- /* EVAPI_POLL_CQ_UNBLOCK_HANDLER,NULL,&(res->sq_cq_eventh)); */
- /* VAPI_CHECK_RET; */
-
- /* Create QP */
- qp_init_attr.cap.max_oust_wr_sq = res->max_outs_sq + 1;
- qp_init_attr.cap.max_oust_wr_rq = res->max_outs_rq + 1;
- qp_init_attr.cap.max_sg_size_sq = 4;
- qp_init_attr.cap.max_sg_size_rq = 4;
-
- qp_init_attr.pd_hndl = res->pd_hndl;
- qp_init_attr.rdd_hndl = 0;
- qp_init_attr.rq_cq_hndl = res->rq_cq_hndl;
- qp_init_attr.rq_sig_type = VAPI_SIGNAL_ALL_WR; /* That's default for IB */
- qp_init_attr.sq_cq_hndl = res->sq_cq_hndl;
- qp_init_attr.sq_sig_type = VAPI_SIGNAL_REQ_WR;
- qp_init_attr.ts_type = VAPI_TS_UD;
-
- ret =
- VAPI_create_qp(res->hca_hndl, &qp_init_attr, &(res->qp_hndl),
- &qp_prop);
- VAPI_CHECK_RET;
- res->qp_id.qp_num = qp_prop.qp_num;
-
- return (VAPI_OK);
-}
-
-VAPI_ret_t osmt_mtl_qp_init(osmt_mtl_mad_res_t * res)
-{
- VAPI_ret_t ret;
-
- VAPI_qp_attr_t qp_attr;
- VAPI_qp_attr_mask_t qp_attr_mask;
- VAPI_qp_cap_t qp_cap;
-
- /*
- * Change QP to INIT
- *
- */
- QP_ATTR_MASK_CLR_ALL(qp_attr_mask);
- qp_attr.qp_state = VAPI_INIT;
- QP_ATTR_MASK_SET(qp_attr_mask, QP_ATTR_QP_STATE);
- qp_attr.pkey_ix = 0;
- QP_ATTR_MASK_SET(qp_attr_mask, QP_ATTR_PKEY_IX);
- qp_attr.port = res->port_num;
- QP_ATTR_MASK_SET(qp_attr_mask, QP_ATTR_PORT);
- qp_attr.qkey = res->qkey;
- QP_ATTR_MASK_SET(qp_attr_mask, QP_ATTR_QKEY);
-
- /* If I do not set this mask, I get an error from HH. QPM should catch it */
- ret =
- VAPI_modify_qp(res->hca_hndl, res->qp_hndl, &qp_attr, &qp_attr_mask,
- &qp_cap);
- VAPI_CHECK_RET;
-
- return (ret);
-
-}
-
-VAPI_ret_t osmt_mtl_qp_2_rtr_rts(osmt_mtl_mad_res_t * res)
-{
- VAPI_ret_t ret;
-
- VAPI_qp_attr_t qp_attr;
- VAPI_qp_attr_mask_t qp_attr_mask;
- VAPI_qp_cap_t qp_cap;
-
- /*
- * Change QP to RTR
- *
- */
- QP_ATTR_MASK_CLR_ALL(qp_attr_mask);
- qp_attr.qp_state = VAPI_RTR;
- QP_ATTR_MASK_SET(qp_attr_mask, QP_ATTR_QP_STATE);
- /* qp_attr.rq_psn = 0; */
- /* QP_ATTR_MASK_SET(qp_attr_mask,QP_ATTR_RQ_PSN); */
-
- ret =
- VAPI_modify_qp(res->hca_hndl, res->qp_hndl, &qp_attr, &qp_attr_mask,
- &qp_cap);
- VAPI_CHECK_RET;
-
- /*
- * Change QP to RTS
- *
- */
- QP_ATTR_MASK_CLR_ALL(qp_attr_mask);
- qp_attr.qp_state = VAPI_RTS;
- QP_ATTR_MASK_SET(qp_attr_mask, QP_ATTR_QP_STATE);
- qp_attr.sq_psn = 0;
- QP_ATTR_MASK_SET(qp_attr_mask, QP_ATTR_SQ_PSN);
-
- ret =
- VAPI_modify_qp(res->hca_hndl, res->qp_hndl, &qp_attr, &qp_attr_mask,
- &qp_cap);
- VAPI_CHECK_RET;
-
- return (ret);
-}
-
-VAPI_ret_t osmt_mtl_mad_create_mr(osmt_mtl_mad_res_t * res)
-{
-
- VAPI_ret_t ret;
-
- VAPI_mrw_t mr_in, mr_out;
-
- res->buf_size =
- (MAD_SIZE + GRH_LEN) * (res->max_outs_sq + res->max_outs_rq + 1);
-
- /* Register single memory address region for all buffers */
- res->buf_ptr = VMALLOC(res->buf_size);
-
- if (res->buf_ptr == ((VAPI_virt_addr_t) NULL)) {
- ret = VAPI_EAGAIN;
- VAPI_CHECK_RET;
- }
-
- /* Enable local and remote access to memory region */
- mr_in.acl = VAPI_EN_LOCAL_WRITE | VAPI_EN_REMOTE_WRITE;
- mr_in.l_key = 0;
- mr_in.pd_hndl = res->pd_hndl;
- mr_in.r_key = 0;
- mr_in.size = res->buf_size;
- ASSERT_VOIDP2UINTN(res->buf_ptr);
- mr_in.start = (VAPI_virt_addr_t) (uintn_t) (res->buf_ptr);
- mr_in.type = VAPI_MR;
-
- ret = VAPI_register_mr(res->hca_hndl, &mr_in, &(res->mr_hndl), &mr_out);
- VAPI_CHECK_RET;
-
- res->l_key = mr_out.l_key;
-
- return (ret);
-}
-
-VAPI_ret_t osmt_mtl_init_opened_hca(osmt_mtl_mad_res_t * res)
-{
- VAPI_ret_t ret;
-
- res->pd_hndl = VAPI_INVAL_HNDL;
- res->rq_cq_hndl = VAPI_INVAL_HNDL;
- res->sq_cq_hndl = VAPI_INVAL_HNDL;
- res->sq_cq_eventh = VAPI_INVAL_HNDL;
- res->rq_cq_eventh = VAPI_INVAL_HNDL;
- res->qp_hndl = VAPI_INVAL_HNDL;
- res->mr_hndl = VAPI_INVAL_HNDL;
-
- /*
- * Create QP
- *
- */
- ret = osmt_mtl_get_qp_resources(res);
- if (ret != VAPI_OK) {
- return ret;
- }
-
- /*
- * Move to init
- *
- */
- ret = osmt_mtl_qp_init(res);
- if (ret != VAPI_OK) {
- return ret;
- }
-
- /*
- * Initialize memory regions
- *
- */
- ret = osmt_mtl_mad_create_mr(res);
- if (ret != VAPI_OK) {
- return ret;
- }
-
- /* only now move to RTR and RTS */
- ret = osmt_mtl_qp_2_rtr_rts(res);
- if (ret != VAPI_OK) {
- return ret;
- }
-
- return VAPI_OK;
-}
-
-VAPI_ret_t osmt_mtl_mad_cleanup(osmt_mtl_mad_res_t * res)
-{
- if (res->qp_hndl != VAPI_INVAL_HNDL) {
- VAPI_destroy_qp(res->hca_hndl, res->qp_hndl);
- }
- if (res->sq_cq_eventh != VAPI_INVAL_HNDL) {
- EVAPI_clear_comp_eventh(res->hca_hndl, res->sq_cq_eventh);
- }
- if (res->rq_cq_eventh != VAPI_INVAL_HNDL) {
- EVAPI_clear_comp_eventh(res->hca_hndl, res->rq_cq_eventh);
- }
- if (res->rq_cq_hndl != VAPI_INVAL_HNDL) {
- VAPI_destroy_cq(res->hca_hndl, res->rq_cq_hndl);
- }
- if (res->sq_cq_hndl != VAPI_INVAL_HNDL) {
- VAPI_destroy_cq(res->hca_hndl, res->sq_cq_hndl);
- }
- if (res->mr_hndl != VAPI_INVAL_HNDL) {
- VAPI_deregister_mr(res->hca_hndl, res->mr_hndl);
- }
- if (res->pd_hndl != VAPI_INVAL_HNDL) {
- VAPI_dealloc_pd(res->hca_hndl, res->pd_hndl);
- }
-#if 0
- /* open/close of HCA should be done system wide - not per application */
- if (res->hca_hndl != VAPI_INVAL_HNDL) {
- VAPI_close_hca(res->hca_hndl); /* TBD: HCA_open/close should be done on a system wide basis */
- }
-#endif
- return VAPI_OK;
-}
-
-VAPI_ret_t osmt_mtl_create_av(osmt_mtl_mad_res_t * res, int16_t dlid,
- VAPI_ud_av_hndl_t * avh_p)
-{
- VAPI_ud_av_t av;
- VAPI_ret_t ret;
-
- av.dlid = dlid;
- av.port = res->port_num;
- av.sl = 0; /* dest->sl; */
- av.src_path_bits = 0; /* dest->ee_dlid.dst_path_bits; */
- av.static_rate = 0;
- /* GRH ? */
- av.grh_flag = 0;
-
- ret = VAPI_create_addr_hndl(res->hca_hndl, res->pd_hndl, &av, avh_p);
- if (ret != VAPI_OK) {
- MTL_ERROR1("%s: failed VAPI_create_addr_hndl (%s)\n", __func__,
- VAPI_strerror_sym(ret));
- return ret;
- }
- return VAPI_OK;
-}
-
-VAPI_ret_t osmt_mtl_mad_send(osmt_mtl_mad_res_t * res, VAPI_wr_id_t id,
- void *mad, VAPI_qp_num_t dest_qp, IB_sl_t sl,
- u_int32_t dest_qkey, VAPI_ud_av_hndl_t avh)
-{
- VAPI_sr_desc_t sr;
- VAPI_sg_lst_entry_t sg_entry;
- VAPI_ret_t ret;
-
- /* building SEND request */
- sr.opcode = VAPI_SEND;
- sr.remote_ah = avh;
- sr.remote_qp = dest_qp;
- sr.remote_qkey = dest_qkey;
-
- sr.id = id;
- sr.set_se = FALSE;
- sr.fence = FALSE;
- sr.comp_type = VAPI_SIGNALED;
- sr.sg_lst_len = 1;
- sr.sg_lst_p = &sg_entry;
- ASSERT_VOIDP2UINTN(mad);
- sg_entry.addr = (VAPI_virt_addr_t) (uintn_t) (mad);
- sg_entry.len = MAD_SIZE;
- sg_entry.lkey = res->l_key;
-
- ret = VAPI_post_sr(res->hca_hndl, res->qp_hndl, &sr);
- if (ret != VAPI_OK) {
- MTL_ERROR1(__FUNCTION__ ": failed VAPI_post_sr (%s)\n",
- VAPI_strerror_sym(ret));
- return ret;
- }
-
- return VAPI_OK;
-}
-
-int osmt_mtl_mad_post_recv_bufs(osmt_mtl_mad_res_t * res, void *buf_array,
- u_int32_t num_o_bufs, u_int32_t size,
- VAPI_wr_id_t start_id)
-{
- uint32_t i;
- void *cur_buf;
- VAPI_rr_desc_t rr;
- VAPI_sg_lst_entry_t sg_entry;
- VAPI_ret_t ret;
-
- rr.opcode = VAPI_RECEIVE;
- rr.comp_type = VAPI_SIGNALED; /* All with CQE (IB compliant) */
- rr.sg_lst_len = 1; /* single buffers */
- rr.sg_lst_p = &sg_entry;
- sg_entry.lkey = res->l_key;
- cur_buf = buf_array;
- for (i = 0; i < num_o_bufs; i++) {
- rr.id = start_id + i; /* WQE id used is the index to buffers ptr array */
- ASSERT_VOIDP2UINTN(cur_buf);
- sg_entry.addr = (VAPI_virt_addr_t) (uintn_t) cur_buf;
- sg_entry.len = size;
- memset(cur_buf, 0x00, size); /* fill with 0 */
- ret = VAPI_post_rr(res->hca_hndl, res->qp_hndl, &rr);
- if (ret != VAPI_OK) {
- MTL_ERROR1(__FUNCTION__
- ": failed posting RQ WQE (%s)\n",
- VAPI_strerror_sym(ret));
- return i;
- }
- MTL_DEBUG4(__FUNCTION__ ": posted buf at %p\n", cur_buf);
- cur_buf += size;
- }
-
- return i; /* num of buffers posted */
-}
-
-VAPI_ret_t osmt_mtl_mad_poll4cqe(VAPI_hca_hndl_t hca, VAPI_cq_hndl_t cq,
- VAPI_wc_desc_t * wc_desc_p,
- u_int32_t max_poll, u_int32_t poll_sleep,
- VAPI_ud_av_hndl_t * avh_p)
-{
- VAPI_ret_t ret = VAPI_CQ_EMPTY;
- u_int32_t poll_cnt = 0;
-
- /* wait for something to arrive */
- while ((ret == VAPI_CQ_EMPTY) && (poll_cnt < max_poll)) {
- ret = VAPI_poll_cq(hca, cq, wc_desc_p);
- /* don't sleep if we already succeeded) */
- if (ret != VAPI_CQ_EMPTY) {
- break;
- }
- usleep(poll_sleep);
- poll_cnt++;
- }
-
- /* if passed an AVH to destory - do it */
- if (avh_p != NULL) {
- VAPI_destroy_addr_hndl(hca, *avh_p);
- }
-
- if ((poll_cnt == max_poll) && (ret == VAPI_CQ_EMPTY)) {
- MTL_DEBUG1(__FUNCTION__
- ": Failed to get completion on wq after %d polls.\n",
- max_poll);
- return VAPI_CQ_EMPTY;
- }
-
- if (ret != VAPI_OK) {
- MTL_DEBUG1(__FUNCTION__
- ": VAPI_poll_cq failed with ret=%s on sq_cq\n",
- mtl_strerror_sym(ret));
- return ret;
- }
-
- if (wc_desc_p->status != VAPI_SUCCESS) {
- MTL_DEBUG1(__FUNCTION__ ": completion error (%d) detected\n",
- wc_desc_p->status);
- }
-
- return VAPI_OK;
-}
-
-#endif /* OSM_VENDOR_INTF_MTL */
diff --git a/contrib/ofed/management/opensm/osmtest/osmt_multicast.c b/contrib/ofed/management/opensm/osmtest/osmt_multicast.c
deleted file mode 100644
index 8329a2b..0000000
--- a/contrib/ofed/management/opensm/osmtest/osmt_multicast.c
+++ /dev/null
@@ -1,2708 +0,0 @@
-/*
- * Copyright (c) 2006-2008 Voltaire, Inc. All rights reserved.
- * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved.
- * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- */
-
-/*
- * Abstract:
- * Implementation of Multicast Member testing flow..
- *
- */
-
-#ifndef __WIN__
-#include <unistd.h>
-#endif
-#include <sys/socket.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <arpa/inet.h>
-#include <complib/cl_debug.h>
-#include <complib/cl_map.h>
-#include <complib/cl_list.h>
-#include "osmtest.h"
-
-/**********************************************************************
- **********************************************************************/
-
-static void __osmt_print_all_multicast_records(IN osmtest_t * const p_osmt)
-{
- uint32_t i;
- ib_api_status_t status;
- osmv_query_req_t req;
- osmv_user_query_t user;
- osmtest_req_context_t context;
- ib_member_rec_t *mcast_record;
-
- memset(&context, 0, sizeof(context));
- memset(&req, 0, sizeof(req));
- memset(&user, 0, sizeof(user));
-
- user.attr_id = IB_MAD_ATTR_MCMEMBER_RECORD;
- user.attr_offset = ib_get_attr_offset(sizeof(*mcast_record));
-
- req.query_type = OSMV_QUERY_USER_DEFINED;
- req.timeout_ms = p_osmt->opt.transaction_timeout;
- req.retry_cnt = 1;
- req.flags = OSM_SA_FLAGS_SYNC;
- context.p_osmt = p_osmt;
- req.query_context = &context;
- req.pfn_query_cb = osmtest_query_res_cb;
- req.p_query_input = &user;
-
- /* UnTrusted (SMKey of 0) - get the multicast groups */
- status = osmv_query_sa(p_osmt->h_bind, &req);
-
- if (status != IB_SUCCESS || context.result.status != IB_SUCCESS) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 02B5: "
- "Failed getting the multicast groups records - %s/%s\n",
- ib_get_err_str(status),
- ib_get_err_str(context.result.status));
- return;
- }
-
- osm_log(&p_osmt->log, OSM_LOG_INFO,
- "\n |------------------------------------------|"
- "\n | Remaining Multicast Groups |"
- "\n |------------------------------------------|\n");
-
- for (i = 0; i < context.result.result_cnt; i++) {
- mcast_record =
- osmv_get_query_mc_rec(context.result.p_result_madw, i);
- osm_dump_mc_record(&p_osmt->log, mcast_record, OSM_LOG_INFO);
- }
-
- /* Trusted - now get the multicast group members */
- req.sm_key = OSM_DEFAULT_SM_KEY;
- status = osmv_query_sa(p_osmt->h_bind, &req);
-
- if (status != IB_SUCCESS || context.result.status != IB_SUCCESS) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 02B6: "
- "Failed getting the multicast group members records - %s/%s\n",
- ib_get_err_str(status),
- ib_get_err_str(context.result.status));
- return;
- }
-
- osm_log(&p_osmt->log, OSM_LOG_INFO,
- "\n |--------------------------------------------------|"
- "\n | Remaining Multicast Group Members |"
- "\n |--------------------------------------------------|\n");
-
- for (i = 0; i < context.result.result_cnt; i++) {
- mcast_record =
- osmv_get_query_mc_rec(context.result.p_result_madw, i);
- osm_dump_mc_record(&p_osmt->log, mcast_record, OSM_LOG_INFO);
- }
-
-}
-
-/**********************************************************************
- **********************************************************************/
-
-static cl_status_t
-__match_mgids(IN const void *const p_object, IN void *context)
-{
- ib_gid_t *p_mgid_context = (ib_gid_t *) context;
- ib_gid_t *p_mgid_list_item = (ib_gid_t *) p_object;
- int32_t count;
-
- count = memcmp(p_mgid_context, p_mgid_list_item, sizeof(ib_gid_t));
- if (count == 0)
- return CL_SUCCESS;
- else
- return CL_NOT_FOUND;
-}
-
-/**********************************************************************
- **********************************************************************/
-
-ib_api_status_t osmt_query_mcast(IN osmtest_t * const p_osmt)
-{
- ib_api_status_t status = IB_SUCCESS;
- osmv_user_query_t user;
- osmv_query_req_t req;
- osmtest_req_context_t context;
- ib_member_rec_t *p_rec;
- uint32_t i, num_recs = 0;
- cl_list_t mgids_list;
- cl_list_t *p_mgids_list;
- cl_list_iterator_t p_mgids_res;
- cl_status_t cl_status;
- cl_map_item_t *p_item, *p_next_item;
- osmtest_mgrp_t *p_mgrp;
-
- OSM_LOG_ENTER(&p_osmt->log);
-
- /*
- * Do a blocking query for all Multicast Records in the subnet.
- * The result is returned in the result field of the caller's
- * context structure.
- *
- * The query structures are locals.
- */
-
- memset(&req, 0, sizeof(req));
- memset(&user, 0, sizeof(user));
-
- context.p_osmt = p_osmt;
- user.attr_id = IB_MAD_ATTR_MCMEMBER_RECORD;
- user.attr_offset = ib_get_attr_offset(sizeof(ib_member_rec_t));
-
- req.query_type = OSMV_QUERY_USER_DEFINED;
- req.timeout_ms = p_osmt->opt.transaction_timeout;
- req.retry_cnt = p_osmt->opt.retry_count;
- req.flags = OSM_SA_FLAGS_SYNC;
- req.query_context = &context;
- req.pfn_query_cb = osmtest_query_res_cb;
- req.p_query_input = &user;
-
- status = osmv_query_sa(p_osmt->h_bind, &req);
-
- if (status != IB_SUCCESS) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0203: "
- "ib_query failed (%s)\n", ib_get_err_str(status));
- goto Exit;
- }
-
- status = context.result.status;
-
- if (status != IB_SUCCESS) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0264: "
- "ib_query failed (%s)\n", ib_get_err_str(status));
- if (status == IB_REMOTE_ERROR) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR,
- "Remote error = %s.\n",
- ib_get_mad_status_str(osm_madw_get_mad_ptr
- (context.result.
- p_result_madw)));
- }
- goto Exit;
- }
-
- /* ok we have got something */
- /* First Delete the old MGID Table */
- p_next_item = cl_qmap_head(&p_osmt->exp_subn.mgrp_mlid_tbl);
- while (p_next_item != cl_qmap_end(&p_osmt->exp_subn.mgrp_mlid_tbl)) {
- p_item = p_next_item;
- p_next_item = cl_qmap_next(p_item);
- cl_qmap_remove_item(&p_osmt->exp_subn.mgrp_mlid_tbl, p_item);
- free(p_item);
-
- }
-
- cl_list_construct(&mgids_list);
- cl_list_init(&mgids_list, num_recs);
- p_mgids_list = &mgids_list;
- num_recs = context.result.result_cnt;
- OSM_LOG(&p_osmt->log, OSM_LOG_VERBOSE, "Received %u records\n",
- num_recs);
-
- for (i = 0; i < num_recs; i++) {
- p_rec = osmv_get_query_result(context.result.p_result_madw, i);
- p_mgids_res =
- cl_list_find_from_head(p_mgids_list, __match_mgids,
- &(p_rec->mgid));
- /* If returns iterator other than end of list, same mgid exists already */
- if (p_mgids_res != cl_list_end(p_mgids_list)) {
- char gid_str[INET6_ADDRSTRLEN];
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0265: "
- "MCG MGIDs are the same - invalid MGID : %s\n",
- inet_ntop(AF_INET6, p_rec->mgid.raw, gid_str,
- sizeof gid_str));
- status = IB_ERROR;
- goto Exit;
-
- }
- osm_dump_mc_record(&p_osmt->log, p_rec, OSM_LOG_VERBOSE);
- cl_status = cl_list_insert_head(p_mgids_list, &(p_rec->mgid));
- if (cl_status) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0205: "
- "Could not add MGID to cl_list\n");
- status = IB_ERROR;
- goto Exit;
- }
- p_mgrp = (osmtest_mgrp_t *) malloc(sizeof(*p_mgrp));
- if (!p_mgrp) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0204: "
- "Could not allocate new MCG\n");
- status = IB_ERROR;
- goto Exit;
- }
- memcpy(&p_mgrp->mcmember_rec, p_rec,
- sizeof(p_mgrp->mcmember_rec));
- cl_qmap_insert(&p_osmt->exp_subn.mgrp_mlid_tbl,
- cl_ntoh16(p_rec->mlid), &p_mgrp->map_item);
- }
-
-Exit:
- if (context.result.p_result_madw != NULL) {
- osm_mad_pool_put(&p_osmt->mad_pool,
- context.result.p_result_madw);
- context.result.p_result_madw = NULL;
- }
-
- OSM_LOG_EXIT(&p_osmt->log);
- return (status);
-}
-
-/**********************************************************************
- **********************************************************************/
-
-/* given a multicast request send and wait for response. */
-ib_api_status_t
-osmt_send_mcast_request(IN osmtest_t * const p_osmt,
- IN uint8_t is_set,
- IN ib_member_rec_t * p_mc_req,
- IN uint64_t comp_mask, OUT ib_sa_mad_t * p_res)
-{
- osmtest_req_context_t context;
- ib_api_status_t status = IB_SUCCESS;
- osmv_user_query_t user;
- osmv_query_req_t req;
-
- OSM_LOG_ENTER(&p_osmt->log);
-
- /*
- * Do a blocking query for this record in the subnet.
- *
- * The query structures are locals.
- */
- memset(&req, 0, sizeof(req));
- memset(&user, 0, sizeof(user));
- memset(&context, 0, sizeof(context));
- memset(p_res, 0, sizeof(ib_sa_mad_t));
-
- context.p_osmt = p_osmt;
-
- user.p_attr = p_mc_req;
- user.comp_mask = comp_mask;
-
- if (is_set == 1) {
- req.query_type = OSMV_QUERY_UD_MULTICAST_SET;
- } else if (is_set == 0) {
- req.query_type = OSMV_QUERY_UD_MULTICAST_DELETE;
- } else if (is_set == 0xee) {
- OSM_LOG(&p_osmt->log, OSM_LOG_VERBOSE,
- "Set USER DEFINED QUERY\n");
- req.query_type = OSMV_QUERY_USER_DEFINED;
- user.method = IB_MAD_METHOD_GET;
- user.attr_id = IB_MAD_ATTR_MCMEMBER_RECORD;
- user.attr_offset = ib_get_attr_offset(sizeof(ib_member_rec_t));
- } else if (is_set == 0xff) {
- OSM_LOG(&p_osmt->log, OSM_LOG_VERBOSE,
- "Set USER DEFINED QUERY\n");
- req.query_type = OSMV_QUERY_USER_DEFINED;
- user.method = IB_MAD_METHOD_SET;
- user.attr_id = IB_MAD_ATTR_MCMEMBER_RECORD;
- user.attr_offset = ib_get_attr_offset(sizeof(ib_member_rec_t));
- }
-
- /* TODO : Check the validity of all user fields in order to use
- OSMV_QUERY_USER_DEFINED
- p_user_query = ( osmv_user_query_t * ) p_query_req->p_query_input;
- if (p_user_query->method) sa_mad_data.method = p_user_query->method;
- sa_mad_data.attr_offset = p_user_query->attr_offset;
- sa_mad_data.attr_id = p_user_query->attr_id;
- sa_mad_data.comp_mask = p_user_query->comp_mask;
- sa_mad_data.p_attr = p_user_query->p_attr;
- */
-
- req.timeout_ms = p_osmt->opt.transaction_timeout;
- req.retry_cnt = p_osmt->opt.retry_count;
- req.flags = OSM_SA_FLAGS_SYNC;
- req.query_context = &context;
- req.pfn_query_cb = osmtest_query_res_cb;
- req.p_query_input = &user;
-
- status = osmv_query_sa(p_osmt->h_bind, &req);
-
- if (status != IB_SUCCESS) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0206: "
- "ib_query failed (%s)\n", ib_get_err_str(status));
- goto Exit;
- }
-
- /* ok it worked */
- memcpy(p_res,
- osm_madw_get_mad_ptr(context.result.p_result_madw),
- sizeof(ib_sa_mad_t));
-
- status = context.result.status;
-
- if (status != IB_SUCCESS) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0224: "
- "ib_query failed (%s)\n", ib_get_err_str(status));
- if (status == IB_REMOTE_ERROR) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR,
- "Remote error = %s\n",
- ib_get_mad_status_str(osm_madw_get_mad_ptr
- (context.result.
- p_result_madw)));
- }
- }
-
-Exit:
- /*
- * Return the IB query MAD to the pool as necessary.
- */
- if (context.result.p_result_madw != NULL) {
- osm_mad_pool_put(&p_osmt->mad_pool,
- context.result.p_result_madw);
- context.result.p_result_madw = NULL;
- }
-
- OSM_LOG_EXIT(&p_osmt->log);
- return (status);
-}
-
-/**********************************************************************
- **********************************************************************/
-
-void
-osmt_init_mc_query_rec(IN osmtest_t * const p_osmt,
- IN OUT ib_member_rec_t * p_mc_req)
-{
- /* use default values so we can change only what we want later */
- memset(p_mc_req, 0, sizeof(ib_member_rec_t));
-
- /* we leave the MGID to the user */
- memcpy(&p_mc_req->port_gid.unicast.interface_id,
- &p_osmt->local_port.port_guid,
- sizeof(p_osmt->local_port.port_guid)
- );
-
- /* use our own subnet prefix: */
- p_mc_req->port_gid.unicast.prefix = CL_HTON64(0xFE80000000000000ULL);
-
- /* ib_net32_t qkey; */
- /* ib_net16_t mlid; - we keep it zero for upper level to decide. */
- /* uint8_t mtu; - keep it zero means - anything you have please. */
- /* uint8_t tclass; can leave as zero for now (between subnets) */
- /* ib_net16_t pkey; leave as zero */
- p_mc_req->rate = IB_LINK_WIDTH_ACTIVE_4X;
- /* uint8_t pkt_life; zero means greater than zero ... */
- /* ib_net32_t sl_flow_hop; keep it all zeros */
- /* we want to use a link local scope: 0x02 */
- p_mc_req->scope_state = ib_member_set_scope_state(0x02, 0);
-}
-
-/***********************************************************************
- * UD Multicast testing flow:
- * o15.0.1.3:
- * - Request new MCG with not enough components in comp_mask :
- * ERR_INSUFFICIENT_COMPONENTS
- * o15.0.1.8:
- * - Request a join with irrelevant RATE and get a ERR_INVALID_REQ
- * o15.0.1.4:
- * - Create an MGID by asking for a join with MGID = 0
- * providing P_Key, Q_Key, SL, FlowLabel, Tclass.
- * o15.0.1.5:
- * - Check the returned MGID is valid. (p 804)
- * o15.0.1.6:
- * - Create a new MCG with valid requested MGID.
- * - Try to create a new MCG with invalid MGID : get back ERR_REQ_INVALID
- * - Try again with MGID prefix = 0xA01B (maybe 0x1BA0 little or big ?)
- * - Try to create again the already created group: ERR_REQ_INVALID
- * o15.0.1.7 - implicitlly checked during the prev steps.
- * o15.0.1.9
- * - Create MCG with Invalid JoinState.FullMember != 1 : get ERR_REQ_INVALID
- * o15.0.1.10 - can't check on a single client .
- * o15.0.1.11:
- * - Try to join into a MGID that exists with JoinState=SendOnlyMember -
- * see that it updates JoinState. What is the routing change?
- * - We can not check simple join since we have only one tester (for now)
- * o15.0.1.12:
- * - The last join should have a special treatment in the SA (sender only)
- * but what is it ?
- * o15.0.1.13:
- * - Try joining with wrong rate - ERR_REQ_INVALID
- * o15.0.1.14:
- * - Try partial delete - actually updating the join state. check it.
- * - Register by InformInfo flow to receive trap 67 on MCG delete.
- * - Try full delete (JoinState and should be 0)
- * - Wait for trap 67.
- * - Try joining (not full mem) again to see the group was deleted.
- * (should fail - o15.0.1.13)
- * o15.0.1.15:
- * - Try deletion of the IPoIB MCG and get: ERR_REQ_INVALID
- * o15.0.1.16:
- * - Try GetTable with PortGUID wildcarded and get back some groups.
- ***********************************************************************/
-
-/* The following macro can be used only within the osmt_run_mcast_flow() function */
-#define IS_IPOIB_MGID(p_mgid) \
- ( !memcmp(&osm_ipoib_good_mgid, (p_mgid), sizeof(osm_ipoib_good_mgid)) || \
- !memcmp(&osm_ts_ipoib_good_mgid, (p_mgid), sizeof(osm_ts_ipoib_good_mgid)) )
-
-ib_api_status_t osmt_run_mcast_flow(IN osmtest_t * const p_osmt)
-{
- char gid_str[INET6_ADDRSTRLEN];
- char gid_str2[INET6_ADDRSTRLEN];
- ib_api_status_t status;
- ib_member_rec_t mc_req_rec;
- ib_member_rec_t *p_mc_res;
- ib_sa_mad_t res_sa_mad;
- uint64_t comp_mask = 0;
- ib_net64_t remote_port_guid = 0x0;
- cl_qmap_t *p_mgrp_mlid_tbl;
- osmtest_mgrp_t *p_mgrp;
- ib_gid_t special_mgid, tmp_mgid, proxy_mgid;
- ib_net16_t invalid_mlid = 0x0;
- ib_net16_t max_mlid = cl_hton16(0xFFFE), tmp_mlid;
- boolean_t ReachedMlidLimit = FALSE;
- int start_cnt = 0, cnt, middle_cnt = 0, end_cnt = 0;
- int start_ipoib_cnt = 0, end_ipoib_cnt = 0;
- int mcg_outside_test_cnt = 0, fail_to_delete_mcg = 0;
- osmtest_req_context_t context;
- ib_node_record_t *p_rec;
- uint32_t num_recs = 0, i;
- uint8_t mtu_phys = 0, rate_phys = 0;
- cl_map_t test_created_mlids; /* List of all mlids created in this test */
- ib_member_rec_t *p_recvd_rec;
- boolean_t got_error = FALSE;
-
- static ib_gid_t good_mgid = {
- {
- 0xFF, 0x12, 0xA0, 0x1C,
- 0xFE, 0x80, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x12, 0x34, 0x56, 0x78}
- };
- static ib_gid_t osm_ipoib_mgid = {
- {
- 0xff, /* multicast field */
- 0x12, /* scope */
- 0x40, 0x1b, /* IPv4 signature */
- 0xff, 0xff, /* 16 bits of P_Key (to be filled in) */
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 48 bits of zeros */
- 0xff, 0xff, 0xff, 0xee, /* 32 bit IPv4 broadcast address */
- },
- };
- static ib_gid_t osm_ts_ipoib_good_mgid = {
- {
- 0xff, /* multicast field */
- 0x12, /* non-permanent bit,scope */
- 0x40, 0x1b, /* IPv4 signature */
- 0xff, 0xff, /* 16 bits of P_Key (to be filled in) */
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 48 bits of zeros */
- 0x00, 0x00, 0x00, 0x01, /* 32 bit IPv4 broadcast address */
- },
- };
- static ib_gid_t osm_ipoib_good_mgid = {
- {
- 0xff, /* multicast field */
- 0x12, /* non-permanent bit,scope */
- 0x40, 0x1b, /* IPv4 signature */
- 0xff, 0xff, /* 16 bits of P_Key (to be filled in) */
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 48 bits of zeros */
- 0xff, 0xff, 0xff, 0xff, /* 32 bit IPv4 broadcast address */
- },
- };
- static ib_gid_t osm_link_local_mgid = {
- {
- 0xFF, 0x02, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x01},
- };
-
- OSM_LOG_ENTER(&p_osmt->log);
-
- OSM_LOG(&p_osmt->log, OSM_LOG_INFO, "GetTable of all current MCGs...\n");
- status = osmt_query_mcast(p_osmt);
- if (status != IB_SUCCESS) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 2FF "
- "GetTable of all records has failed!\n");
- goto Exit;
- }
-
- /* Initialize the test_created_mgrps map */
- cl_map_construct(&test_created_mlids);
- cl_map_init(&test_created_mlids, 1000);
-
- p_mgrp_mlid_tbl = &p_osmt->exp_subn.mgrp_mlid_tbl;
- osmt_init_mc_query_rec(p_osmt, &mc_req_rec);
-
- p_mc_res = ib_sa_mad_get_payload_ptr(&res_sa_mad);
-
- /* Only when we are on single mode check flow - do the count comparison, otherwise skip */
- if (p_osmt->opt.mmode == 1 || p_osmt->opt.mmode == 3) {
- start_cnt = cl_qmap_count(p_mgrp_mlid_tbl);
- OSM_LOG(&p_osmt->log, OSM_LOG_INFO, "(start): "
- "Number of MC Records found in SA DB is %d\n",
- start_cnt);
- }
-
- /* This flow is being added due to bug discovered using SilverStorm stack -
- The bug was initializing MCast with MTU & RATE min values that do
- not match the subnet capability, even though that OpenSM
- reponds with the correct value it does not store it in the MCG.
- We want the check a join request to already existing group (ipoib)
- without using MTU or RATE then getting response from OpenSM with
- the correct values then join again with them and get IB_SUCCESS
- all the way
- */
-
- /* First validate IPoIB exist in the SA DB */
- p_mgrp = (osmtest_mgrp_t *) cl_qmap_head(p_mgrp_mlid_tbl);
- /* scan all available multicast groups in the DB and fill in the table */
- while (p_mgrp != (osmtest_mgrp_t *) cl_qmap_end(p_mgrp_mlid_tbl)) {
- /* search for ipoib mgid */
- if (IS_IPOIB_MGID(&p_mgrp->mcmember_rec.mgid)) {
- start_ipoib_cnt++;
- } else {
- OSM_LOG(&p_osmt->log, OSM_LOG_INFO,
- "Non-IPoIB MC Groups exist: mgid=%s\n",
- inet_ntop(AF_INET6,
- p_mgrp->mcmember_rec.mgid.raw,
- gid_str, sizeof gid_str));
- mcg_outside_test_cnt++;
- }
-
- p_mgrp = (osmtest_mgrp_t *) cl_qmap_next(&p_mgrp->map_item);
- }
-
- OSM_LOG(&p_osmt->log, OSM_LOG_INFO,
- "Found %d non-IPoIB MC Groups\n", mcg_outside_test_cnt);
-
- if (start_ipoib_cnt) {
- /* o15-0.2.4 - Check a join request to already created MCG */
- OSM_LOG(&p_osmt->log, OSM_LOG_INFO,
- "Found IPoIB MC Group, so we run SilverStorm Bug Flow...\n");
- /* Try to join first like IPoIB of SilverStorm */
- memcpy(&mc_req_rec.mgid, &osm_ipoib_good_mgid,
- sizeof(ib_gid_t));
- /* Request Join */
- ib_member_set_join_state(&mc_req_rec,
- IB_MC_REC_STATE_FULL_MEMBER);
- comp_mask =
- IB_MCR_COMPMASK_MGID | IB_MCR_COMPMASK_PORT_GID |
- IB_MCR_COMPMASK_JOIN_STATE;
-
- status = osmt_send_mcast_request(p_osmt, 0xff, /* User Defined query Set */
- &mc_req_rec,
- comp_mask, &res_sa_mad);
-
- OSM_LOG(&p_osmt->log, OSM_LOG_INFO,
- "Joining an existing IPoIB multicast group\n");
- OSM_LOG(&p_osmt->log, OSM_LOG_INFO,
- "Sent Join request with :\n\t\tport_gid=%s, mgid=%s\n"
- "\t\tjoin state= 0x%x, response is : %s\n",
- inet_ntop(AF_INET6, mc_req_rec.port_gid.raw,
- gid_str, sizeof gid_str),
- inet_ntop(AF_INET6, mc_req_rec.mgid.raw,
- gid_str2, sizeof gid_str2),
- (mc_req_rec.scope_state & 0x0F),
- ib_get_err_str(status));
- if (status != IB_SUCCESS) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 02B3: "
- "Failed joining existing IPoIB MCGroup - got %s\n",
- ib_get_err_str(status));
- goto Exit;
- }
- /* Check MTU & Rate Value and resend with SA suggested values */
- p_mc_res = ib_sa_mad_get_payload_ptr(&res_sa_mad);
-
- /* Prepare the mc_req_rec for the rest of the flow */
- osmt_init_mc_query_rec(p_osmt, &mc_req_rec);
- /*
- We simulate the same situation as in SilverStorm - a response with the
- exact RATE & MTU as the SA responded with. Actually the query
- has included some more fields but we know that problem was
- genereated by the RATE
- */
- OSM_LOG(&p_osmt->log, OSM_LOG_INFO,
- "Received attributes of MCG : \n\t\tMTU=0x%02X, RATE=0x%02X\n",
- p_mc_res->mtu, p_mc_res->rate);
-
- mc_req_rec.mtu = p_mc_res->mtu;
- mc_req_rec.rate = p_mc_res->rate;
- /* Set feasible mtu & rate that will allow check the
- exact statement of OpenSM */
- mtu_phys = p_mc_res->mtu;
- rate_phys = p_mc_res->rate;
-
- memcpy(&mc_req_rec.mgid, &osm_ipoib_good_mgid,
- sizeof(ib_gid_t));
- /* Request Join */
- ib_member_set_join_state(&mc_req_rec,
- IB_MC_REC_STATE_FULL_MEMBER);
- comp_mask =
- IB_MCR_COMPMASK_MGID | IB_MCR_COMPMASK_PORT_GID |
- IB_MCR_COMPMASK_JOIN_STATE | IB_MCR_COMPMASK_MTU_SEL |
- IB_MCR_COMPMASK_MTU | IB_MCR_COMPMASK_RATE_SEL |
- IB_MCR_COMPMASK_RATE;
-
- OSM_LOG(&p_osmt->log, OSM_LOG_INFO,
- "Sending attributes of MCG : \n\t\tMTU=0x%02X, RATE=0x%02X\n",
- mc_req_rec.mtu, mc_req_rec.rate);
- status = osmt_send_mcast_request(p_osmt, 0xff, /* User Defined query */
- &mc_req_rec,
- comp_mask, &res_sa_mad);
- OSM_LOG(&p_osmt->log, OSM_LOG_INFO,
- "Sent Join request using response values, response is : %s\n",
- ib_get_err_str(status));
- if (status != IB_SUCCESS) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 02EF: "
- "Query as Full Member of already existing "
- "ipoib group gid %s has failed\n",
- inet_ntop(AF_INET6, mc_req_rec.mgid.raw,
- gid_str, sizeof gid_str));
- goto Exit;
- }
- /* We do not want to leave the MCG since its IPoIB */
- }
-
- /**************************************************************************/
- /* Check Get with invalid mlid */
-
- OSM_LOG(&p_osmt->log, OSM_LOG_INFO,
- "Checking Get with invalid mlid...\n");
- /* Request Get */
- ib_member_set_join_state(&mc_req_rec, IB_MC_REC_STATE_FULL_MEMBER);
- mc_req_rec.mlid = invalid_mlid;
- comp_mask = IB_MCR_COMPMASK_MLID;
-
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, EXPECTING_ERRORS_START "\n");
- status = osmt_send_mcast_request(p_osmt, 0xee, /* User Defined query Get */
- &mc_req_rec, comp_mask, &res_sa_mad);
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, EXPECTING_ERRORS_END "\n");
-
- if (status == IB_SUCCESS) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 2E0 "
- "SubnAdmGet with invalid mlid 0x%x succeeded\n",
- cl_ntoh16(mc_req_rec.mlid));
- status = IB_ERROR;
- goto Exit;
- }
-
- /* Prepare the mc_req_rec for the rest of the flow */
- osmt_init_mc_query_rec(p_osmt, &mc_req_rec);
- /**************************************************************************/
- /* Check Get with invalid port guid */
-
- OSM_LOG(&p_osmt->log, OSM_LOG_INFO,
- "Checking Get with invalid port guid (0x0) but valid interface ID : 0x%"
- PRIx64 "...\n",
- cl_ntoh64(mc_req_rec.port_gid.unicast.interface_id));
-
- /* Request Get */
- ib_member_set_join_state(&mc_req_rec, IB_MC_REC_STATE_FULL_MEMBER);
- memset(&mc_req_rec.port_gid.unicast.interface_id, 0,
- sizeof(ib_net64_t));
- comp_mask = IB_MCR_COMPMASK_GID;
-
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, EXPECTING_ERRORS_START "\n");
- status = osmt_send_mcast_request(p_osmt, 0xee, /* User Defined query Get */
- &mc_req_rec, comp_mask, &res_sa_mad);
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, EXPECTING_ERRORS_END "\n");
-
- if (status == IB_SUCCESS) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 2E4 "
- "SubnAdmGet with invalid port guid succeeded\n");
- status = IB_ERROR;
- goto Exit;
- }
-
- /* Prepare the mc_req_rec for the rest of the flow */
- osmt_init_mc_query_rec(p_osmt, &mc_req_rec);
- /**************************************************************************/
-
- /* o15.0.1.3: */
- /* - Request Join with insufficient comp_mask */
-
- OSM_LOG(&p_osmt->log, OSM_LOG_INFO,
- "Checking Join with insufficient comp mask qkey & pkey (o15.0.1.3)...\n");
-
- /* no MGID */
- memset(&mc_req_rec.mgid, 0, sizeof(ib_gid_t));
- /* Request Join */
- ib_member_set_join_state(&mc_req_rec, IB_MC_REC_STATE_FULL_MEMBER);
-
- comp_mask = IB_MCR_COMPMASK_MGID | IB_MCR_COMPMASK_PORT_GID |
- /* IB_MCR_COMPMASK_QKEY | */
- /* IB_MCR_COMPMASK_PKEY | intentionaly missed to raise the error */
- IB_MCR_COMPMASK_SL | IB_MCR_COMPMASK_FLOW | IB_MCR_COMPMASK_JOIN_STATE | IB_MCR_COMPMASK_TCLASS | /* all above are required */
- IB_MCR_COMPMASK_RATE_SEL | IB_MCR_COMPMASK_RATE;
-
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, EXPECTING_ERRORS_START "\n");
- status = osmt_send_mcast_request(p_osmt, 1,
- &mc_req_rec, comp_mask, &res_sa_mad);
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, EXPECTING_ERRORS_END "\n");
-
- if (status != IB_REMOTE_ERROR ||
- ((ib_net16_t) (res_sa_mad.status & IB_SMP_STATUS_MASK)) !=
- IB_SA_MAD_STATUS_INSUF_COMPS) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 02EE: "
- "Expectedd REMOTE ERROR IB_SA_MAD_STATUS_INSUF_COMPS got:%s/%s\n",
- ib_get_err_str(status),
- ib_get_mad_status_str((ib_mad_t *) (&res_sa_mad)));
- status = IB_ERROR;
- goto Exit;
- }
-
- OSM_LOG(&p_osmt->log, OSM_LOG_INFO,
- "Checking Join with insufficient comp mask - sl (15.0.1.3)...\n");
-
- /* no MGID */
- memset(&mc_req_rec.mgid, 0, sizeof(ib_gid_t));
- /* Request Join */
- ib_member_set_join_state(&mc_req_rec, IB_MC_REC_STATE_FULL_MEMBER);
-
- comp_mask =
- IB_MCR_COMPMASK_MGID |
- IB_MCR_COMPMASK_PORT_GID |
- IB_MCR_COMPMASK_QKEY | IB_MCR_COMPMASK_PKEY |
- /* IB_MCR_COMPMASK_SL | */
- IB_MCR_COMPMASK_FLOW | IB_MCR_COMPMASK_JOIN_STATE | IB_MCR_COMPMASK_TCLASS | /* all above are required */
- IB_MCR_COMPMASK_RATE_SEL | IB_MCR_COMPMASK_RATE;
-
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, EXPECTING_ERRORS_START "\n");
- status = osmt_send_mcast_request(p_osmt, 1,
- &mc_req_rec, comp_mask, &res_sa_mad);
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, EXPECTING_ERRORS_END "\n");
-
- if (status != IB_REMOTE_ERROR ||
- ((ib_net16_t) (res_sa_mad.status & IB_SMP_STATUS_MASK)) !=
- IB_SA_MAD_STATUS_INSUF_COMPS) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 02ED: "
- "Expectedd REMOTE ERROR IB_SA_MAD_STATUS_INSUF_COMPS got:%s/%s\n",
- ib_get_err_str(status),
- ib_get_mad_status_str((ib_mad_t *) (&res_sa_mad)));
- status = IB_ERROR;
- goto Exit;
- }
-
- osmt_init_mc_query_rec(p_osmt, &mc_req_rec);
- /* no MGID */
- memset(&mc_req_rec.mgid, 0, sizeof(ib_gid_t));
-
- mc_req_rec.mgid.raw[15] = 0x01;
-
- p_mc_res = ib_sa_mad_get_payload_ptr(&res_sa_mad);
-
- OSM_LOG(&p_osmt->log, OSM_LOG_INFO,
- "Checking Join with insufficient comp mask - flow label (o15.0.1.3)...\n");
-
- /* Request Join */
- ib_member_set_join_state(&mc_req_rec, IB_MC_REC_STATE_FULL_MEMBER);
-
- comp_mask =
- IB_MCR_COMPMASK_MGID |
- IB_MCR_COMPMASK_PORT_GID |
- IB_MCR_COMPMASK_QKEY | IB_MCR_COMPMASK_PKEY | IB_MCR_COMPMASK_SL |
- /* IB_MCR_COMPMASK_FLOW | intentionaly missed to raise the error */
- IB_MCR_COMPMASK_JOIN_STATE | IB_MCR_COMPMASK_TCLASS | /* all above are required */
- IB_MCR_COMPMASK_RATE_SEL | IB_MCR_COMPMASK_RATE;
-
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, EXPECTING_ERRORS_START "\n");
- status = osmt_send_mcast_request(p_osmt, 1,
- &mc_req_rec, comp_mask, &res_sa_mad);
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, EXPECTING_ERRORS_END "\n");
-
- if (status != IB_REMOTE_ERROR ||
- ((ib_net16_t) (res_sa_mad.status & IB_SMP_STATUS_MASK)) !=
- IB_SA_MAD_STATUS_INSUF_COMPS) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 02EC: "
- "Expected REMOTE ERROR IB_SA_MAD_STATUS_INSUF_COMPS got:%s/%s\n",
- ib_get_err_str(status),
- ib_get_mad_status_str((ib_mad_t *) (&res_sa_mad)));
- status = IB_ERROR;
- goto Exit;
- }
-
- osmt_init_mc_query_rec(p_osmt, &mc_req_rec);
-
- p_mc_res = ib_sa_mad_get_payload_ptr(&res_sa_mad);
-
- OSM_LOG(&p_osmt->log, OSM_LOG_INFO,
- "Checking Join with insufficient comp mask - tclass (o15.0.1.3)...\n");
-
- /* Request Join */
- ib_member_set_join_state(&mc_req_rec, IB_MC_REC_STATE_FULL_MEMBER);
-
- comp_mask =
- IB_MCR_COMPMASK_MGID |
- IB_MCR_COMPMASK_PORT_GID |
- IB_MCR_COMPMASK_QKEY |
- IB_MCR_COMPMASK_PKEY |
- IB_MCR_COMPMASK_SL |
- IB_MCR_COMPMASK_FLOW | IB_MCR_COMPMASK_JOIN_STATE |
- /* IB_MCR_COMPMASK_TCLASS | Intentionally missed to raise an error */
- IB_MCR_COMPMASK_RATE_SEL | IB_MCR_COMPMASK_RATE;
-
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, EXPECTING_ERRORS_START "\n");
- status = osmt_send_mcast_request(p_osmt, 1,
- &mc_req_rec, comp_mask, &res_sa_mad);
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, EXPECTING_ERRORS_END "\n");
-
- if (status != IB_REMOTE_ERROR ||
- ((ib_net16_t) (res_sa_mad.status & IB_SMP_STATUS_MASK)) !=
- IB_SA_MAD_STATUS_INSUF_COMPS) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 02EA: "
- "Expected REMOTE ERROR IB_SA_MAD_STATUS_INSUF_COMPS got:%s/%s\n",
- ib_get_err_str(status),
- ib_get_mad_status_str((ib_mad_t *) (&res_sa_mad)));
- status = IB_ERROR;
- goto Exit;
- }
-
- osmt_init_mc_query_rec(p_osmt, &mc_req_rec);
-
- p_mc_res = ib_sa_mad_get_payload_ptr(&res_sa_mad);
-
- OSM_LOG(&p_osmt->log, OSM_LOG_INFO,
- "Checking Join with insufficient comp mask - tclass qkey (o15.0.1.3)...\n");
-
- /* no MGID */
- /* memset(&mc_req_rec.mgid, 0, sizeof(ib_gid_t)); */
- /* Request Join */
- ib_member_set_join_state(&mc_req_rec, IB_MC_REC_STATE_FULL_MEMBER);
-
- comp_mask = IB_MCR_COMPMASK_MGID | IB_MCR_COMPMASK_PORT_GID |
- /* IB_MCR_COMPMASK_QKEY | intentionaly missed to raise the error */
- IB_MCR_COMPMASK_PKEY |
- IB_MCR_COMPMASK_SL |
- IB_MCR_COMPMASK_FLOW | IB_MCR_COMPMASK_JOIN_STATE |
- /* IB_MCR_COMPMASK_TCLASS | intentionaly missed to raise the error */
- IB_MCR_COMPMASK_RATE_SEL | IB_MCR_COMPMASK_RATE;
-
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, EXPECTING_ERRORS_START "\n");
- status = osmt_send_mcast_request(p_osmt, 1,
- &mc_req_rec, comp_mask, &res_sa_mad);
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, EXPECTING_ERRORS_END "\n");
-
- if (status != IB_REMOTE_ERROR ||
- ((ib_net16_t) (res_sa_mad.status & IB_SMP_STATUS_MASK)) !=
- IB_SA_MAD_STATUS_INSUF_COMPS) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 02E9: "
- "Expected REMOTE ERROR IB_SA_MAD_STATUS_INSUF_COMPS got:%s/%s\n",
- ib_get_err_str(status),
- ib_get_mad_status_str((ib_mad_t *) (&res_sa_mad)));
- status = IB_ERROR;
- goto Exit;
- }
-
- /* o15.0.1.8: */
- /* - Request join with irrelevant RATE : get a ERR_INSUFFICIENT_COMPONENTS */
- OSM_LOG(&p_osmt->log, OSM_LOG_INFO,
- "Checking Join with unrealistic rate (o15.0.1.8)...\n");
-
- /* impossible requested rate */
- mc_req_rec.rate =
- IB_LINK_WIDTH_ACTIVE_12X | IB_PATH_SELECTOR_GREATER_THAN << 6;
-
- comp_mask = IB_MCR_COMPMASK_GID | IB_MCR_COMPMASK_PORT_GID | IB_MCR_COMPMASK_QKEY | IB_MCR_COMPMASK_PKEY | IB_MCR_COMPMASK_SL | IB_MCR_COMPMASK_FLOW | IB_MCR_COMPMASK_JOIN_STATE | IB_MCR_COMPMASK_TCLASS | /* all above are required */
- IB_MCR_COMPMASK_RATE_SEL | IB_MCR_COMPMASK_RATE;
-
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, EXPECTING_ERRORS_START "\n");
- status = osmt_send_mcast_request(p_osmt, 1,
- &mc_req_rec, comp_mask, &res_sa_mad);
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, EXPECTING_ERRORS_END "\n");
-
- if (status != IB_REMOTE_ERROR ||
- res_sa_mad.status != IB_SA_MAD_STATUS_REQ_INVALID) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0207: "
- "Expected REMOTE ERROR IB_SA_MAD_STATUS_REQ_INVALID got:%s/%s\n",
- ib_get_err_str(status),
- ib_get_mad_status_str((ib_mad_t *) (&res_sa_mad)));
- status = IB_ERROR;
- goto Exit;
- }
-
- /* Check Valid value which is unreasonable now */
- OSM_LOG(&p_osmt->log, OSM_LOG_INFO,
- "Checking Join with unrealistic rate 120GB (o15.0.1.8)...\n");
-
- /* impossible requested rate */
- mc_req_rec.rate =
- IB_PATH_RECORD_RATE_120_GBS | IB_PATH_SELECTOR_GREATER_THAN << 6;
-
- comp_mask = IB_MCR_COMPMASK_GID | IB_MCR_COMPMASK_PORT_GID | IB_MCR_COMPMASK_QKEY | IB_MCR_COMPMASK_PKEY | IB_MCR_COMPMASK_SL | IB_MCR_COMPMASK_FLOW | IB_MCR_COMPMASK_JOIN_STATE | IB_MCR_COMPMASK_TCLASS | /* all above are required */
- IB_MCR_COMPMASK_RATE_SEL | IB_MCR_COMPMASK_RATE;
-
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, EXPECTING_ERRORS_START "\n");
- status = osmt_send_mcast_request(p_osmt, 1,
- &mc_req_rec, comp_mask, &res_sa_mad);
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, EXPECTING_ERRORS_END "\n");
-
- if (status != IB_REMOTE_ERROR ||
- res_sa_mad.status != IB_SA_MAD_STATUS_REQ_INVALID) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0208: "
- "Expected REMOTE ERROR IB_SA_MAD_STATUS_REQ_INVALID got:%s/%s\n",
- ib_get_err_str(status),
- ib_get_mad_status_str((ib_mad_t *) (&res_sa_mad)));
- status = IB_ERROR;
- goto Exit;
- }
-
- /* Check Valid value which is unreasonable now */
- OSM_LOG(&p_osmt->log, OSM_LOG_INFO,
- "Checking Join with less than min rate 2.5GB (o15.0.1.8)...\n");
-
- /* impossible requested rate */
- mc_req_rec.rate =
- IB_PATH_RECORD_RATE_2_5_GBS | IB_PATH_SELECTOR_LESS_THAN << 6;
-
- comp_mask = IB_MCR_COMPMASK_GID | IB_MCR_COMPMASK_PORT_GID | IB_MCR_COMPMASK_QKEY | IB_MCR_COMPMASK_PKEY | IB_MCR_COMPMASK_SL | IB_MCR_COMPMASK_FLOW | IB_MCR_COMPMASK_JOIN_STATE | IB_MCR_COMPMASK_TCLASS | /* all above are required */
- IB_MCR_COMPMASK_RATE_SEL | IB_MCR_COMPMASK_RATE;
-
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, EXPECTING_ERRORS_START "\n");
- status = osmt_send_mcast_request(p_osmt, 1,
- &mc_req_rec, comp_mask, &res_sa_mad);
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, EXPECTING_ERRORS_END "\n");
-
- if (status != IB_REMOTE_ERROR ||
- res_sa_mad.status != IB_SA_MAD_STATUS_REQ_INVALID) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 02AB: "
- "Expected REMOTE ERROR IB_SA_MAD_STATUS_REQ_INVALID got:%s/%s\n",
- ib_get_err_str(status),
- ib_get_mad_status_str((ib_mad_t *) (&res_sa_mad)));
- status = IB_ERROR;
- goto Exit;
- }
-
- /* Checking above max value of MTU which is impossible */
- OSM_LOG(&p_osmt->log, OSM_LOG_INFO,
- "Checking Join with unrealistic mtu : \n\t\tmore than 4096 -"
- " max (o15.0.1.8)...\n");
-
- /* impossible requested mtu */
- mc_req_rec.mtu = IB_MTU_LEN_4096 | IB_PATH_SELECTOR_GREATER_THAN << 6;
-
- comp_mask = IB_MCR_COMPMASK_GID | IB_MCR_COMPMASK_PORT_GID | IB_MCR_COMPMASK_QKEY | IB_MCR_COMPMASK_PKEY | IB_MCR_COMPMASK_SL | IB_MCR_COMPMASK_FLOW | IB_MCR_COMPMASK_JOIN_STATE | IB_MCR_COMPMASK_TCLASS | /* all above are required */
- IB_MCR_COMPMASK_MTU_SEL | IB_MCR_COMPMASK_MTU;
-
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, EXPECTING_ERRORS_START "\n");
- status = osmt_send_mcast_request(p_osmt, 1,
- &mc_req_rec, comp_mask, &res_sa_mad);
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, EXPECTING_ERRORS_END "\n");
-
- if (status != IB_REMOTE_ERROR ||
- res_sa_mad.status != IB_SA_MAD_STATUS_REQ_INVALID) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 02AC: "
- "Expected REMOTE ERROR IB_SA_MAD_STATUS_REQ_INVALID got:%s/%s\n",
- ib_get_err_str(status),
- ib_get_mad_status_str((ib_mad_t *) (&res_sa_mad))
- );
- status = IB_ERROR;
- goto Exit;
- }
-
- /* Checking below min value of MTU which is impossible */
- OSM_LOG(&p_osmt->log, OSM_LOG_INFO,
- "Checking Join with unrealistic mtu : \n\t\tless than 256 -"
- " min (o15.0.1.8)...\n");
-
- /* impossible requested mtu */
- mc_req_rec.mtu = IB_MTU_LEN_256 | IB_PATH_SELECTOR_LESS_THAN << 6;
-
- comp_mask = IB_MCR_COMPMASK_GID | IB_MCR_COMPMASK_PORT_GID | IB_MCR_COMPMASK_QKEY | IB_MCR_COMPMASK_PKEY | IB_MCR_COMPMASK_SL | IB_MCR_COMPMASK_FLOW | IB_MCR_COMPMASK_JOIN_STATE | IB_MCR_COMPMASK_TCLASS | /* all above are required */
- IB_MCR_COMPMASK_MTU_SEL | IB_MCR_COMPMASK_MTU;
-
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, EXPECTING_ERRORS_START "\n");
- status = osmt_send_mcast_request(p_osmt, 1,
- &mc_req_rec, comp_mask, &res_sa_mad);
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, EXPECTING_ERRORS_END "\n");
-
- if (status != IB_REMOTE_ERROR ||
- res_sa_mad.status != IB_SA_MAD_STATUS_REQ_INVALID) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 02AD: "
- "Expected REMOTE ERROR IB_SA_MAD_STATUS_REQ_INVALID got:%s/%s\n",
- ib_get_err_str(status),
- ib_get_mad_status_str((ib_mad_t *) (&res_sa_mad)));
- status = IB_ERROR;
- goto Exit;
- }
-
- OSM_LOG(&p_osmt->log, OSM_LOG_INFO,
- "Checking Join with unrealistic mtu (o15.0.1.8)...\n");
-
- /* impossible requested mtu */
- mc_req_rec.mtu = 0x6 | IB_PATH_SELECTOR_GREATER_THAN << 6;
-
- comp_mask = IB_MCR_COMPMASK_GID | IB_MCR_COMPMASK_PORT_GID | IB_MCR_COMPMASK_QKEY | IB_MCR_COMPMASK_PKEY | IB_MCR_COMPMASK_SL | IB_MCR_COMPMASK_FLOW | IB_MCR_COMPMASK_JOIN_STATE | IB_MCR_COMPMASK_TCLASS | /* all above are required */
- IB_MCR_COMPMASK_MTU_SEL | IB_MCR_COMPMASK_MTU;
-
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, EXPECTING_ERRORS_START "\n");
- status = osmt_send_mcast_request(p_osmt, 1,
- &mc_req_rec, comp_mask, &res_sa_mad);
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, EXPECTING_ERRORS_END "\n");
-
- if (status != IB_REMOTE_ERROR ||
- res_sa_mad.status != IB_SA_MAD_STATUS_REQ_INVALID) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 02AE: "
- "Expected REMOTE ERROR IB_SA_MAD_STATUS_REQ_INVALID got:%s/%s\n",
- ib_get_err_str(status),
- ib_get_mad_status_str((ib_mad_t *) (&res_sa_mad)));
- status = IB_ERROR;
- goto Exit;
- }
-#if 0
- /* Currently PacketLifeTime isn't checked in opensm */
- /* Check PacketLifeTime as 0 */
- OSM_LOG(&p_osmt->log, OSM_LOG_INFO,
- "Checking Create with unrealistic packet life value less than 0 (o15.0.1.8)...\n");
-
- /* impossible requested packet life */
- mc_req_rec.pkt_life = 0 | IB_PATH_SELECTOR_LESS_THAN << 6;
-
- comp_mask = IB_MCR_COMPMASK_GID | IB_MCR_COMPMASK_PORT_GID | IB_MCR_COMPMASK_QKEY | IB_MCR_COMPMASK_PKEY | IB_MCR_COMPMASK_SL | IB_MCR_COMPMASK_FLOW | IB_MCR_COMPMASK_JOIN_STATE | IB_MCR_COMPMASK_TCLASS | /* all above are required */
- IB_MCR_COMPMASK_LIFE | IB_MCR_COMPMASK_LIFE_SEL;
-
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, EXPECTING_ERRORS_START "\n");
- status = osmt_send_mcast_request(p_osmt, 1,
- &mc_req_rec, comp_mask, &res_sa_mad);
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, EXPECTING_ERRORS_END "\n");
-
- if (status != IB_REMOTE_ERROR ||
- res_sa_mad.status != IB_SA_MAD_STATUS_REQ_INVALID) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 02AF: "
- "Expected REMOTE ERROR IB_SA_MAD_STATUS_REQ_INVALID got:%s/%s\n",
- ib_get_err_str(status),
- ib_get_mad_status_str((ib_mad_t *) (&res_sa_mad)));
- status = IB_ERROR;
- goto Exit;
- }
-#endif
-
- /* o15.0.1.4: */
- /* - Create an MGID by asking for a join with MGID = 0 */
- /* providing P_Key, Q_Key, SL, FlowLabel, Tclass. */
-
- OSM_LOG(&p_osmt->log, OSM_LOG_INFO,
- "Checking Create given MGID=0 skip service level (o15.0.1.4)...\n");
-
- osmt_init_mc_query_rec(p_osmt, &mc_req_rec);
-
- p_mc_res = ib_sa_mad_get_payload_ptr(&res_sa_mad);
-
- /* no MGID */
- memset(&mc_req_rec.mgid, 0, sizeof(ib_gid_t));
- /* Request Join */
- ib_member_set_join_state(&mc_req_rec, IB_MC_REC_STATE_FULL_MEMBER);
-
- comp_mask =
- IB_MCR_COMPMASK_MGID |
- IB_MCR_COMPMASK_PORT_GID |
- IB_MCR_COMPMASK_QKEY | IB_MCR_COMPMASK_PKEY |
- /* IB_MCR_COMPMASK_SL | Intentionally missed */
- IB_MCR_COMPMASK_FLOW | IB_MCR_COMPMASK_JOIN_STATE | IB_MCR_COMPMASK_TCLASS | /* all above are required */
- IB_MCR_COMPMASK_RATE_SEL | IB_MCR_COMPMASK_RATE;
-
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, EXPECTING_ERRORS_START "\n");
- status = osmt_send_mcast_request(p_osmt, 1,
- &mc_req_rec, comp_mask, &res_sa_mad);
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, EXPECTING_ERRORS_END "\n");
-
- if (status != IB_REMOTE_ERROR ||
- ((ib_net16_t) (res_sa_mad.status & IB_SMP_STATUS_MASK)) !=
- IB_SA_MAD_STATUS_INSUF_COMPS) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 02A8: "
- "Expected REMOTE ERROR IB_SA_MAD_STATUS_INSUF_COMPS got:%s/%s\n",
- ib_get_err_str(status),
- ib_get_mad_status_str((ib_mad_t *) (&res_sa_mad)));
- status = IB_ERROR;
- goto Exit;
- }
-
- /* Check that no same MCG in the SMDB */
- status = osmt_query_mcast(p_osmt);
-
- if (status != IB_SUCCESS) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 02AA: "
- "Could not get all MC Records in subnet, got:%s/%s\n",
- ib_get_err_str(status),
- ib_get_mad_status_str((ib_mad_t *) (&res_sa_mad)));
- goto Exit;
- }
-
- /* Only when we are on single mode check flow - do the count comparison, otherwise skip */
- if (p_osmt->opt.mmode == 1 || p_osmt->opt.mmode == 3) {
- middle_cnt = cl_qmap_count(&p_osmt->exp_subn.mgrp_mlid_tbl);
- OSM_LOG(&p_osmt->log, OSM_LOG_INFO, "(post false create): "
- "Number of MC Records found in SA DB is %d\n",
- middle_cnt);
- if (middle_cnt != start_cnt) {
- OSM_LOG(&p_osmt->log, OSM_LOG_INFO,
- "Got different number of records stored in SA DB (before any creation)\n"
- "Instead of %d got %d\n", start_cnt,
- middle_cnt);
- }
- }
-
- OSM_LOG(&p_osmt->log, OSM_LOG_INFO,
- "Checking Create given MGID=0 skip Qkey and Pkey (o15.0.1.4)...\n");
-
- osmt_init_mc_query_rec(p_osmt, &mc_req_rec);
-
- p_mc_res = ib_sa_mad_get_payload_ptr(&res_sa_mad);
-
- /* no MGID */
- memset(&mc_req_rec.mgid, 0, sizeof(ib_gid_t));
- /* Request Join */
- ib_member_set_join_state(&mc_req_rec, IB_MC_REC_STATE_FULL_MEMBER);
-
- comp_mask = IB_MCR_COMPMASK_MGID | IB_MCR_COMPMASK_PORT_GID |
- /* IB_MCR_COMPMASK_QKEY | */
- /* IB_MCR_COMPMASK_PKEY | Intentionally missed */
- IB_MCR_COMPMASK_SL | IB_MCR_COMPMASK_FLOW | IB_MCR_COMPMASK_JOIN_STATE | IB_MCR_COMPMASK_TCLASS | /* all above are required */
- IB_MCR_COMPMASK_RATE_SEL | IB_MCR_COMPMASK_RATE;
-
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, EXPECTING_ERRORS_START "\n");
- status = osmt_send_mcast_request(p_osmt, 1,
- &mc_req_rec, comp_mask, &res_sa_mad);
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, EXPECTING_ERRORS_END "\n");
-
- if (status != IB_REMOTE_ERROR ||
- ((ib_net16_t) (res_sa_mad.status & IB_SMP_STATUS_MASK)) !=
- IB_SA_MAD_STATUS_INSUF_COMPS) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 02A7: "
- "Expected REMOTE ERROR IB_SA_MAD_STATUS_INSUF_COMPS got:%s/%s\n",
- ib_get_err_str(status),
- ib_get_mad_status_str((ib_mad_t *) (&res_sa_mad)));
- status = IB_ERROR;
- goto Exit;
- }
-
- /* Bad Query o15.0.1.4 */
-
- status = osmt_query_mcast(p_osmt);
-
- OSM_LOG(&p_osmt->log, OSM_LOG_INFO,
- "Checking Create given MGID=0 skip TClass (o15.0.1.4)...\n");
-
- osmt_init_mc_query_rec(p_osmt, &mc_req_rec);
-
- p_mc_res = ib_sa_mad_get_payload_ptr(&res_sa_mad);
-
- /* no MGID */
- memset(&mc_req_rec.mgid, 0, sizeof(ib_gid_t));
- /* Request Join */
- ib_member_set_join_state(&mc_req_rec, IB_MC_REC_STATE_FULL_MEMBER);
-
- comp_mask =
- IB_MCR_COMPMASK_MGID |
- IB_MCR_COMPMASK_PORT_GID |
- IB_MCR_COMPMASK_QKEY |
- IB_MCR_COMPMASK_PKEY |
- IB_MCR_COMPMASK_SL |
- IB_MCR_COMPMASK_FLOW | IB_MCR_COMPMASK_JOIN_STATE |
- /* IB_MCR_COMPMASK_TCLASS | Intentionally missed */
- /* all above are required */
- IB_MCR_COMPMASK_RATE_SEL | IB_MCR_COMPMASK_RATE;
-
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, EXPECTING_ERRORS_START "\n");
- status = osmt_send_mcast_request(p_osmt, 1,
- &mc_req_rec, comp_mask, &res_sa_mad);
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, EXPECTING_ERRORS_END "\n");
-
- if (status != IB_REMOTE_ERROR ||
- ((ib_net16_t) (res_sa_mad.status & IB_SMP_STATUS_MASK)) !=
- IB_SA_MAD_STATUS_INSUF_COMPS) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 02A6: "
- "Expected REMOTE ERROR IB_SA_MAD_STATUS_INSUF_COMPS got:%s/%s\n",
- ib_get_err_str(status),
- ib_get_mad_status_str((ib_mad_t *) (&res_sa_mad)));
- status = IB_ERROR;
- goto Exit;
- }
-
- OSM_LOG(&p_osmt->log, OSM_LOG_INFO,
- "Checking Create given MGID=0 valid Set several options :\n\t\t"
- "First above min RATE, Second less than max RATE\n\t\t"
- "Third above min MTU, Second less than max MTU\n\t\t"
- "Fifth exact MTU & RATE feasible, Sixth exact RATE feasible\n\t\t"
- "Seventh exact MTU feasible (o15.0.1.4)...\n");
-
- /* Good Flow - mgid is 0 while giving all required fields for join : P_Key, Q_Key, SL, FlowLabel, Tclass */
-
- mc_req_rec.rate =
- IB_LINK_WIDTH_ACTIVE_1X | IB_PATH_SELECTOR_GREATER_THAN << 6;
-
- comp_mask = IB_MCR_COMPMASK_MGID | IB_MCR_COMPMASK_PORT_GID | IB_MCR_COMPMASK_QKEY | IB_MCR_COMPMASK_PKEY | IB_MCR_COMPMASK_SL | IB_MCR_COMPMASK_FLOW | IB_MCR_COMPMASK_JOIN_STATE | IB_MCR_COMPMASK_TCLASS | /* all above are required */
- IB_MCR_COMPMASK_RATE_SEL | IB_MCR_COMPMASK_RATE;
-
- status = osmt_send_mcast_request(p_osmt, 1,
- &mc_req_rec, comp_mask, &res_sa_mad);
- if (status != IB_SUCCESS) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 02A5: "
- "Failed to create MCG for MGID=0 with higher than minimum RATE - got %s/%s\n",
- ib_get_err_str(status),
- ib_get_mad_status_str((ib_mad_t *) (&res_sa_mad)));
- goto Exit;
- }
-
- /* Save the mlid created in test_created_mlids map */
- p_recvd_rec =
- (ib_member_rec_t *) ib_sa_mad_get_payload_ptr(&res_sa_mad);
- OSM_LOG(&p_osmt->log, OSM_LOG_VERBOSE, "created MGID:%s MLID:0x%04X\n",
- inet_ntop(AF_INET6, p_recvd_rec->mgid.raw, gid_str,
- sizeof gid_str), cl_ntoh16(p_recvd_rec->mlid));
- cl_map_insert(&test_created_mlids, cl_ntoh16(p_recvd_rec->mlid),
- p_recvd_rec);
-
- /* Good Flow - mgid is 0 while giving all required fields for join : P_Key, Q_Key, SL, FlowLabel, Tclass */
-
- mc_req_rec.rate =
- IB_LINK_WIDTH_ACTIVE_12X | IB_PATH_SELECTOR_LESS_THAN << 6;
-
- comp_mask = IB_MCR_COMPMASK_MGID | IB_MCR_COMPMASK_PORT_GID | IB_MCR_COMPMASK_QKEY | IB_MCR_COMPMASK_PKEY | IB_MCR_COMPMASK_SL | IB_MCR_COMPMASK_FLOW | IB_MCR_COMPMASK_JOIN_STATE | IB_MCR_COMPMASK_TCLASS | /* all above are required */
- IB_MCR_COMPMASK_RATE_SEL | IB_MCR_COMPMASK_RATE;
-
- status = osmt_send_mcast_request(p_osmt, 1,
- &mc_req_rec, comp_mask, &res_sa_mad);
- if (status != IB_SUCCESS) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0211: "
- "Failed to create MCG for MGID=0 with less than highest RATE - got %s/%s\n",
- ib_get_err_str(status),
- ib_get_mad_status_str((ib_mad_t *) (&res_sa_mad)));
- goto Exit;
- }
-
- /* Save the mlid created in test_created_mlids map */
- p_recvd_rec =
- (ib_member_rec_t *) ib_sa_mad_get_payload_ptr(&res_sa_mad);
- OSM_LOG(&p_osmt->log, OSM_LOG_VERBOSE, "Created MGID:%s MLID:0x%04X\n",
- inet_ntop(AF_INET6, p_recvd_rec->mgid.raw, gid_str,
- sizeof gid_str), cl_ntoh16(p_recvd_rec->mlid));
- cl_map_insert(&test_created_mlids, cl_ntoh16(p_recvd_rec->mlid),
- p_recvd_rec);
-
- /* Good Flow - mgid is 0 while giving all required fields for join : P_Key, Q_Key, SL, FlowLabel, Tclass */
-
- mc_req_rec.mtu = IB_MTU_LEN_4096 | IB_PATH_SELECTOR_LESS_THAN << 6;
-
- comp_mask = IB_MCR_COMPMASK_MGID | IB_MCR_COMPMASK_PORT_GID | IB_MCR_COMPMASK_QKEY | IB_MCR_COMPMASK_PKEY | IB_MCR_COMPMASK_SL | IB_MCR_COMPMASK_FLOW | IB_MCR_COMPMASK_JOIN_STATE | IB_MCR_COMPMASK_TCLASS | /* all above are required */
- IB_MCR_COMPMASK_MTU_SEL | IB_MCR_COMPMASK_MTU;
-
- status = osmt_send_mcast_request(p_osmt, 1,
- &mc_req_rec, comp_mask, &res_sa_mad);
- if (status != IB_SUCCESS) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0238: "
- "Failed to create MCG for MGID=0 with less than highest MTU - got %s/%s\n",
- ib_get_err_str(status),
- ib_get_mad_status_str((ib_mad_t *) (&res_sa_mad)));
- goto Exit;
- }
-
- /* Save the mlid created in test_created_mlids map */
- p_recvd_rec =
- (ib_member_rec_t *) ib_sa_mad_get_payload_ptr(&res_sa_mad);
- OSM_LOG(&p_osmt->log, OSM_LOG_VERBOSE, "Created MGID:%s MLID:0x%04X\n",
- inet_ntop(AF_INET6, p_recvd_rec->mgid.raw, gid_str,
- sizeof gid_str), cl_ntoh16(p_recvd_rec->mlid));
- cl_map_insert(&test_created_mlids, cl_ntoh16(p_recvd_rec->mlid),
- p_recvd_rec);
-
- /* Good Flow - mgid is 0 while giving all required fields for join : P_Key, Q_Key, SL, FlowLabel, Tclass */
- mc_req_rec.mtu = IB_MTU_LEN_256 | IB_PATH_SELECTOR_GREATER_THAN << 6;
-
- comp_mask = IB_MCR_COMPMASK_MGID | IB_MCR_COMPMASK_PORT_GID | IB_MCR_COMPMASK_QKEY | IB_MCR_COMPMASK_PKEY | IB_MCR_COMPMASK_SL | IB_MCR_COMPMASK_FLOW | IB_MCR_COMPMASK_JOIN_STATE | IB_MCR_COMPMASK_TCLASS | /* all above are required */
- IB_MCR_COMPMASK_MTU_SEL | IB_MCR_COMPMASK_MTU;
-
- status = osmt_send_mcast_request(p_osmt, 1,
- &mc_req_rec, comp_mask, &res_sa_mad);
- if (status != IB_SUCCESS) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0239: "
- "Failed to create MCG for MGID=0 with higher than lowest MTU - got %s/%s\n",
- ib_get_err_str(status),
- ib_get_mad_status_str((ib_mad_t *) (&res_sa_mad)));
- goto Exit;
- }
-
- /* Save the mlid created in test_created_mlids map */
- p_recvd_rec =
- (ib_member_rec_t *) ib_sa_mad_get_payload_ptr(&res_sa_mad);
- OSM_LOG(&p_osmt->log, OSM_LOG_VERBOSE, "Created MGID:%s MLID:0x%04X\n",
- inet_ntop(AF_INET6, p_recvd_rec->mgid.raw, gid_str,
- sizeof gid_str), cl_ntoh16(p_recvd_rec->mlid));
- cl_map_insert(&test_created_mlids, cl_ntoh16(p_recvd_rec->mlid),
- p_recvd_rec);
-
- /* Good Flow - mgid is 0 while giving all required fields for join : P_Key, Q_Key, SL, FlowLabel, Tclass */
- /* Using Exact feasible MTU & RATE */
-
- OSM_LOG(&p_osmt->log, OSM_LOG_VERBOSE,
- "Using Exact feasible MTU & RATE: "
- "MTU = 0x%02X, RATE = 0x%02X\n", mtu_phys, rate_phys);
-
- mc_req_rec.mtu = mtu_phys;
- mc_req_rec.rate = rate_phys;
-
- comp_mask = IB_MCR_COMPMASK_MGID | IB_MCR_COMPMASK_PORT_GID | IB_MCR_COMPMASK_QKEY | IB_MCR_COMPMASK_PKEY | IB_MCR_COMPMASK_SL | IB_MCR_COMPMASK_FLOW | IB_MCR_COMPMASK_JOIN_STATE | IB_MCR_COMPMASK_TCLASS | /* all above are required */
- IB_MCR_COMPMASK_MTU_SEL |
- IB_MCR_COMPMASK_MTU |
- IB_MCR_COMPMASK_RATE_SEL | IB_MCR_COMPMASK_RATE;
-
- status = osmt_send_mcast_request(p_osmt, 1,
- &mc_req_rec, comp_mask, &res_sa_mad);
-
- if (status != IB_SUCCESS) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0240: "
- "Failed to create MCG for MGID=0 with exact MTU & RATE - got %s/%s\n",
- ib_get_err_str(status),
- ib_get_mad_status_str((ib_mad_t *) (&res_sa_mad)));
- goto Exit;
- }
-
- /* Save the mlid created in test_created_mlids map */
- p_recvd_rec =
- (ib_member_rec_t *) ib_sa_mad_get_payload_ptr(&res_sa_mad);
- OSM_LOG(&p_osmt->log, OSM_LOG_VERBOSE, "Created MGID:%s MLID:0x%04X\n",
- inet_ntop(AF_INET6, p_recvd_rec->mgid.raw, gid_str,
- sizeof gid_str), cl_ntoh16(p_recvd_rec->mlid));
- cl_map_insert(&test_created_mlids, cl_ntoh16(p_recvd_rec->mlid),
- p_recvd_rec);
-
- /* Good Flow - mgid is 0 while giving all required fields for join : P_Key, Q_Key, SL, FlowLabel, Tclass */
- /* Using Exact feasible RATE */
-
- OSM_LOG(&p_osmt->log, OSM_LOG_VERBOSE,
- "Using Exact feasible RATE: 0x%02X\n", rate_phys);
-
- mc_req_rec.rate = rate_phys;
-
- comp_mask = IB_MCR_COMPMASK_MGID | IB_MCR_COMPMASK_PORT_GID | IB_MCR_COMPMASK_QKEY | IB_MCR_COMPMASK_PKEY | IB_MCR_COMPMASK_SL | IB_MCR_COMPMASK_FLOW | IB_MCR_COMPMASK_JOIN_STATE | IB_MCR_COMPMASK_TCLASS | /* all above are required */
- IB_MCR_COMPMASK_RATE_SEL | IB_MCR_COMPMASK_RATE;
-
- status = osmt_send_mcast_request(p_osmt, 1,
- &mc_req_rec, comp_mask, &res_sa_mad);
- if (status != IB_SUCCESS) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0241: "
- "Failed to create MCG for MGID=0 with exact RATE - got %s/%s\n",
- ib_get_err_str(status),
- ib_get_mad_status_str((ib_mad_t *) (&res_sa_mad)));
- goto Exit;
- }
-
- /* Save the mlid created in test_created_mlids map */
- p_recvd_rec =
- (ib_member_rec_t *) ib_sa_mad_get_payload_ptr(&res_sa_mad);
- OSM_LOG(&p_osmt->log, OSM_LOG_VERBOSE, "Created MGID:%s MLID:0x%04X\n",
- inet_ntop(AF_INET6, p_recvd_rec->mgid.raw, gid_str,
- sizeof gid_str), cl_ntoh16(p_recvd_rec->mlid));
- cl_map_insert(&test_created_mlids, cl_ntoh16(p_recvd_rec->mlid),
- p_recvd_rec);
-
- /* Good Flow - mgid is 0 while giving all required fields for join : P_Key, Q_Key, SL, FlowLabel, Tclass */
- /* Using Exact feasible MTU */
-
- OSM_LOG(&p_osmt->log, OSM_LOG_VERBOSE,
- "Using Exact feasible MTU: 0x%02X\n", mtu_phys);
-
- mc_req_rec.mtu = mtu_phys;
-
- comp_mask = IB_MCR_COMPMASK_MGID | IB_MCR_COMPMASK_PORT_GID | IB_MCR_COMPMASK_QKEY | IB_MCR_COMPMASK_PKEY | IB_MCR_COMPMASK_SL | IB_MCR_COMPMASK_FLOW | IB_MCR_COMPMASK_JOIN_STATE | IB_MCR_COMPMASK_TCLASS | /* all above are required */
- IB_MCR_COMPMASK_MTU_SEL | IB_MCR_COMPMASK_MTU;
-
- status = osmt_send_mcast_request(p_osmt, 1,
- &mc_req_rec, comp_mask, &res_sa_mad);
- if (status != IB_SUCCESS) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0242: "
- "Failed to create MCG for MGID=0 with exact MTU - got %s/%s\n",
- ib_get_err_str(status),
- ib_get_mad_status_str((ib_mad_t *) (&res_sa_mad)));
- goto Exit;
- }
-
- /* Save the mlid created in test_created_mlids map */
- p_recvd_rec =
- (ib_member_rec_t *) ib_sa_mad_get_payload_ptr(&res_sa_mad);
- OSM_LOG(&p_osmt->log, OSM_LOG_VERBOSE, "Created MGID:%s MLID:0x%04X\n",
- inet_ntop(AF_INET6, p_recvd_rec->mgid.raw, gid_str,
- sizeof gid_str), cl_ntoh16(p_recvd_rec->mlid));
- cl_map_insert(&test_created_mlids, cl_ntoh16(p_recvd_rec->mlid),
- p_recvd_rec);
-
- /* o15.0.1.5: */
- /* - Check the returned MGID is valid. (p 804) */
- OSM_LOG(&p_osmt->log, OSM_LOG_INFO,
- "Validating resulting MGID (o15.0.1.5)...\n");
- /* prefix 0xFF1 Scope 0xA01B */
- /* Since we did not directly specified SCOPE in comp mask
- we should get the comp mask that is link-local scope */
- if ((p_mc_res->mgid.multicast.header[0] != 0xFF) ||
- (p_mc_res->mgid.multicast.header[1] != 0x12) ||
- (p_mc_res->mgid.multicast.raw_group_id[0] != 0xA0) ||
- (p_mc_res->mgid.multicast.raw_group_id[1] != 0x1B)) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0209: "
- "Validating MGID failed. MGID:%s\n",
- inet_ntop(AF_INET6, p_mc_res->mgid.raw, gid_str,
- sizeof gid_str));
- status = IB_ERROR;
- goto Exit;
- }
-
- /* Good Flow - mgid is 0 while giving all required fields for join : P_Key, Q_Key, SL, FlowLabel, Tclass */
- /* Using feasible GREATER_THAN 0 packet lifitime */
- OSM_LOG(&p_osmt->log, OSM_LOG_INFO,
- "Checking Create given MGID=0 (o15.0.1.4)...\n");
-
- status = osmt_query_mcast(p_osmt);
-
- osmt_init_mc_query_rec(p_osmt, &mc_req_rec);
-
- p_mc_res = ib_sa_mad_get_payload_ptr(&res_sa_mad);
-
- /* no MGID */
- memset(&mc_req_rec.mgid, 0, sizeof(ib_gid_t));
- /* Request Join */
- ib_member_set_join_state(&mc_req_rec, IB_MC_REC_STATE_FULL_MEMBER);
-
- mc_req_rec.pkt_life = 0 | IB_PATH_SELECTOR_GREATER_THAN << 6;
-
- comp_mask = IB_MCR_COMPMASK_MGID | IB_MCR_COMPMASK_PORT_GID | IB_MCR_COMPMASK_QKEY | IB_MCR_COMPMASK_PKEY | IB_MCR_COMPMASK_SL | IB_MCR_COMPMASK_FLOW | IB_MCR_COMPMASK_JOIN_STATE | IB_MCR_COMPMASK_TCLASS | /* all above are required */
- IB_MCR_COMPMASK_LIFE | IB_MCR_COMPMASK_LIFE_SEL;
-
- status = osmt_send_mcast_request(p_osmt, 1,
- &mc_req_rec, comp_mask, &res_sa_mad);
- if (status != IB_SUCCESS) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0210: "
- "Failed to create MCG for MGID=0 - got %s/%s\n",
- ib_get_err_str(status),
- ib_get_mad_status_str((ib_mad_t *) (&res_sa_mad)));
- goto Exit;
- }
-
- /* Save the mlid created in test_created_mlids map */
- p_recvd_rec =
- (ib_member_rec_t *) ib_sa_mad_get_payload_ptr(&res_sa_mad);
- OSM_LOG(&p_osmt->log, OSM_LOG_VERBOSE, "Created MGID:%s MLID:0x%04X\n",
- inet_ntop(AF_INET6, p_recvd_rec->mgid.raw, gid_str,
- sizeof gid_str), cl_ntoh16(p_recvd_rec->mlid));
- cl_map_insert(&test_created_mlids, cl_ntoh16(p_recvd_rec->mlid),
- p_recvd_rec);
-
- /* o15.0.1.6: */
- /* - Create a new MCG with valid requested MGID. */
- osmt_init_mc_query_rec(p_osmt, &mc_req_rec);
- mc_req_rec.mgid = good_mgid;
-
- OSM_LOG(&p_osmt->log, OSM_LOG_INFO,
- "Checking Create given valid MGID=%s (o15.0.1.6)...\n",
- inet_ntop(AF_INET6, mc_req_rec.mgid.raw, gid_str,
- sizeof gid_str));
-
- /* Before creation, need to check that this group doesn't exist */
- OSM_LOG(&p_osmt->log, OSM_LOG_INFO,
- "Verifying that MCGroup with this MGID doesn't exist by trying to Join it (o15.0.1.13)...\n");
-
- ib_member_set_join_state(&mc_req_rec, IB_MC_REC_STATE_NON_MEMBER);
-
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, EXPECTING_ERRORS_START "\n");
- status = osmt_send_mcast_request(p_osmt, 1, /* join */
- &mc_req_rec, comp_mask, &res_sa_mad);
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, EXPECTING_ERRORS_END "\n");
-
- if ((status != IB_REMOTE_ERROR) ||
- (res_sa_mad.status != IB_SA_MAD_STATUS_REQ_INVALID)) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0301: "
- "Tried joining group that shouldn't have existed - got %s/%s\n",
- ib_get_err_str(status),
- ib_get_mad_status_str((ib_mad_t *) (&res_sa_mad)));
- status = IB_ERROR;
- goto Exit;
- }
-
- /* Set State to full member to allow group creation */
- ib_member_set_join_state(&mc_req_rec, IB_MC_REC_STATE_FULL_MEMBER);
-
- OSM_LOG(&p_osmt->log, OSM_LOG_INFO,
- "Now creating group with given valid MGID=%s (o15.0.1.6)...\n",
- inet_ntop(AF_INET6, mc_req_rec.mgid.raw, gid_str,
- sizeof gid_str));
-
- status = osmt_send_mcast_request(p_osmt, 1,
- &mc_req_rec, comp_mask, &res_sa_mad);
- if (status != IB_SUCCESS) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0211: "
- "Failed to create MCG for MGID=%s (o15.0.1.6) - got %s/%s\n",
- inet_ntop(AF_INET6, good_mgid.raw, gid_str,
- sizeof gid_str), ib_get_err_str(status),
- ib_get_mad_status_str((ib_mad_t *) (&res_sa_mad)));
- goto Exit;
- }
-
- /* Save the mlid created in test_created_mlids map */
- p_recvd_rec =
- (ib_member_rec_t *) ib_sa_mad_get_payload_ptr(&res_sa_mad);
- OSM_LOG(&p_osmt->log, OSM_LOG_VERBOSE, "Created MGID:%s MLID:0x%04X\n",
- inet_ntop(AF_INET6, p_recvd_rec->mgid.raw, gid_str,
- sizeof gid_str), cl_ntoh16(p_recvd_rec->mlid));
- cl_map_insert(&test_created_mlids, cl_ntoh16(p_recvd_rec->mlid),
- p_recvd_rec);
-
- OSM_LOG(&p_osmt->log, OSM_LOG_INFO,
- "Validating resulting MGID (o15.0.1.6)...\n");
- /* prefix 0xFF1 Scope 0xA01B */
- if ((p_mc_res->mgid.multicast.header[0] != 0xFF) || (p_mc_res->mgid.multicast.header[1] != 0x12) || /* HACK hardcoded scope = 0x02 */
- (p_mc_res->mgid.multicast.raw_group_id[0] != 0xA0) ||
- (p_mc_res->mgid.multicast.raw_group_id[1] != 0x1C)) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0212: "
- "Validating MGID failed. MGID:%s\n",
- inet_ntop(AF_INET6, p_mc_res->mgid.raw, gid_str,
- sizeof gid_str));
- status = IB_ERROR;
- goto Exit;
- }
-
- /* - Try to create a new MCG with invalid MGID : get back ERR_REQ_INVALID */
- OSM_LOG(&p_osmt->log, OSM_LOG_INFO,
- "Checking BAD MGID=0xFA..... (o15.0.1.6)...\n");
-
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, EXPECTING_ERRORS_START "\n");
-
- mc_req_rec.mgid.raw[0] = 0xFA;
- status = osmt_send_mcast_request(p_osmt, 1,
- &mc_req_rec, comp_mask, &res_sa_mad);
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, EXPECTING_ERRORS_END "\n");
-
- if ((status != IB_REMOTE_ERROR) ||
- (res_sa_mad.status != IB_SA_MAD_STATUS_REQ_INVALID)) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0213: "
- "Failed to recognize MGID error for MGID=0xFA - got %s/%s\n",
- ib_get_err_str(status),
- ib_get_mad_status_str((ib_mad_t *) (&res_sa_mad)));
- status = IB_ERROR;
- goto Exit;
- }
-
- /* - Try again with MGID prefix = 0xA01B (maybe 0x1BA0 little or big ?) */
- OSM_LOG(&p_osmt->log, OSM_LOG_INFO,
- "Checking BAD MGID=0xFF12A01B..... with link-local scope (o15.0.1.6)...\n");
-
- mc_req_rec.mgid.raw[0] = 0xFF;
- mc_req_rec.mgid.raw[3] = 0x1B;
- comp_mask = comp_mask | IB_MCR_COMPMASK_SCOPE;
- mc_req_rec.scope_state = mc_req_rec.scope_state & 0x2F; /* local scope */
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, EXPECTING_ERRORS_START "\n");
- status = osmt_send_mcast_request(p_osmt, 1,
- &mc_req_rec, comp_mask, &res_sa_mad);
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, EXPECTING_ERRORS_END "\n");
-
- if ((status != IB_REMOTE_ERROR) ||
- (res_sa_mad.status != IB_SA_MAD_STATUS_REQ_INVALID)) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0214: "
- "Failed to recognize MGID error for A01B with link-local bit (status %s) (rem status %s)\n",
- ib_get_err_str(status),
- ib_get_mad_status_str((ib_mad_t *) (&res_sa_mad)));
- status = IB_ERROR;
- goto Exit;
- }
-
- /* Change the mgid prefix - get back ERR_REQ_INVALID */
-
- OSM_LOG(&p_osmt->log, OSM_LOG_INFO,
- "Checking BAD MGID PREFIX=0xEF... (o15.0.1.6)...\n");
-
- mc_req_rec.mgid = good_mgid;
-
- mc_req_rec.mgid.raw[0] = 0xEF;
-
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, EXPECTING_ERRORS_START "\n");
- status = osmt_send_mcast_request(p_osmt, 1,
- &mc_req_rec, comp_mask, &res_sa_mad);
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, EXPECTING_ERRORS_END "\n");
-
- if ((status != IB_REMOTE_ERROR) ||
- (res_sa_mad.status != IB_SA_MAD_STATUS_REQ_INVALID)) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0215: "
- "Failed to recognize MGID PREFIX error for MGID=0xEF - got %s/%s\n",
- ib_get_err_str(status),
- ib_get_mad_status_str((ib_mad_t *) (&res_sa_mad)));
- status = IB_ERROR;
- goto Exit;
- }
-
- /* Change the scope to reserved - get back VALID REQ */
-
- OSM_LOG(&p_osmt->log, OSM_LOG_INFO,
- "Checking local scope with full member \n\t\tand valid mgid %s"
- " ... (o15.0.1.6)...\n",
- inet_ntop(AF_INET6, mc_req_rec.mgid.raw, gid_str,
- sizeof gid_str));
-
- mc_req_rec.mgid = good_mgid;
-
- mc_req_rec.mgid.raw[1] = 0x1F;
-
- status = osmt_send_mcast_request(p_osmt, 1,
- &mc_req_rec, comp_mask, &res_sa_mad);
- if (status != IB_SUCCESS) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0216: "
- "Failed to create MCG for MGID=%s - got %s/%s\n",
- inet_ntop(AF_INET6, good_mgid.raw, gid_str,
- sizeof gid_str), ib_get_err_str(status),
- ib_get_mad_status_str((ib_mad_t *) (&res_sa_mad)));
- goto Exit;
- }
-
- /* Save the mlid created in test_created_mlids map */
- p_recvd_rec =
- (ib_member_rec_t *) ib_sa_mad_get_payload_ptr(&res_sa_mad);
- OSM_LOG(&p_osmt->log, OSM_LOG_VERBOSE, "Created MGID:%s MLID:0x%04X\n",
- inet_ntop(AF_INET6, p_recvd_rec->mgid.raw, gid_str,
- sizeof gid_str), cl_ntoh16(p_recvd_rec->mlid));
- cl_map_insert(&test_created_mlids, cl_ntoh16(p_recvd_rec->mlid),
- p_recvd_rec);
-
- /* Change the flags to invalid value 0x2 - get back INVALID REQ */
-
- OSM_LOG(&p_osmt->log, OSM_LOG_INFO,
- "Checking invalid flags=0xFF 22 ... (o15.0.1.6)...\n");
-
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, EXPECTING_ERRORS_START "\n");
-
- mc_req_rec.mgid = good_mgid;
-
- mc_req_rec.mgid.raw[1] = 0x22;
-
- status = osmt_send_mcast_request(p_osmt, 1,
- &mc_req_rec, comp_mask, &res_sa_mad);
-
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, EXPECTING_ERRORS_END "\n");
-
- if ((status != IB_REMOTE_ERROR) ||
- (res_sa_mad.status != IB_SA_MAD_STATUS_REQ_INVALID)) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0217: "
- "Failed to recognize create with invalid flags value 0x2 - got %s/%s\n",
- ib_get_err_str(status),
- ib_get_mad_status_str((ib_mad_t *) (&res_sa_mad)));
- status = IB_ERROR;
- goto Exit;
- }
-
- /* Change the MGID to link local MGID - get back VALID REQ */
-
- OSM_LOG(&p_osmt->log, OSM_LOG_INFO,
- "Checking link local MGID 0xFF02:0:0:0:0:0:0:1 (o15.0.1.6)...\n");
-
- mc_req_rec.mgid = osm_link_local_mgid;
-
- status = osmt_send_mcast_request(p_osmt, 1,
- &mc_req_rec, comp_mask, &res_sa_mad);
- if (status != IB_SUCCESS) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0218: "
- "Failed to create MCG for MGID=0xFF02:0:0:0:0:0:0:1 - got %s/%s\n",
- ib_get_err_str(status),
- ib_get_mad_status_str((ib_mad_t *) (&res_sa_mad)));
- goto Exit;
- }
-
- /* Save the mlid created in test_created_mlids map */
- p_recvd_rec =
- (ib_member_rec_t *) ib_sa_mad_get_payload_ptr(&res_sa_mad);
- OSM_LOG(&p_osmt->log, OSM_LOG_VERBOSE, "Created MGID:%s MLID:0x%04X\n",
- inet_ntop(AF_INET6, p_recvd_rec->mgid.raw, gid_str,
- sizeof gid_str), cl_ntoh16(p_recvd_rec->mlid));
- cl_map_insert(&test_created_mlids, cl_ntoh16(p_recvd_rec->mlid),
- p_recvd_rec);
-
- /* o15.0.1.7 - implicitlly checked during the prev steps. */
- /* o15.0.1.8 - implicitlly checked during the prev steps. */
-
- /* o15.0.1.9 */
- /* - Create MCG with Invalid JoinState.FullMember != 1 : get ERR_REQ_INVALID */
-
- OSM_LOG(&p_osmt->log, OSM_LOG_INFO,
- "Checking new MGID with invalid join state (o15.0.1.9)...\n");
-
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, EXPECTING_ERRORS_START "\n");
-
- mc_req_rec.mgid = good_mgid;
- mc_req_rec.mgid.raw[12] = 0xFF;
- mc_req_rec.scope_state = 0x22; /* link-local scope, non-member state */
-
- status = osmt_send_mcast_request(p_osmt, 1,
- &mc_req_rec, comp_mask, &res_sa_mad);
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, EXPECTING_ERRORS_END "\n");
-
- if ((status != IB_REMOTE_ERROR) ||
- (res_sa_mad.status != IB_SA_MAD_STATUS_REQ_INVALID)) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0219: "
- "Failed to recognize create with JoinState != FullMember - got %s/%s\n",
- ib_get_err_str(status),
- ib_get_mad_status_str((ib_mad_t *) (&res_sa_mad)));
- status = IB_ERROR;
- goto Exit;
- }
-
- /* Lets try a valid join scope state */
- OSM_LOG(&p_osmt->log, OSM_LOG_INFO,
- "Checking new MGID with valid join state (o15.0.1.9)...\n");
-
- mc_req_rec.mgid = good_mgid;
- mc_req_rec.scope_state = 0x23; /* link-local scope, non member and full member */
-
- status = osmt_send_mcast_request(p_osmt, 1,
- &mc_req_rec, comp_mask, &res_sa_mad);
-
- if (status != IB_SUCCESS) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0220: "
- "Failed to create MCG with valid join state 0x3 - got %s/%s\n",
- ib_get_err_str(status),
- ib_get_mad_status_str((ib_mad_t *) (&res_sa_mad)));
- goto Exit;
- }
-
- /* Save the mlid created in test_created_mlids map */
- p_recvd_rec =
- (ib_member_rec_t *) ib_sa_mad_get_payload_ptr(&res_sa_mad);
- OSM_LOG(&p_osmt->log, OSM_LOG_VERBOSE, "Created MGID:%s MLID:0x%04X\n",
- inet_ntop(AF_INET6, p_recvd_rec->mgid.raw, gid_str,
- sizeof gid_str), cl_ntoh16(p_recvd_rec->mlid));
- cl_map_insert(&test_created_mlids, cl_ntoh16(p_recvd_rec->mlid),
- p_recvd_rec);
-
- /* Lets try another invalid join scope state */
- OSM_LOG(&p_osmt->log, OSM_LOG_INFO,
- "Checking new MGID with invalid join state (o15.0.1.9)...\n");
-
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, EXPECTING_ERRORS_START "\n");
-
- /* We have created a new MCG so now we need different mgid when cresting group otherwise it will be counted as join request . */
- mc_req_rec.mgid = good_mgid;
- mc_req_rec.mgid.raw[12] = 0xFC;
-
- mc_req_rec.scope_state = 0x24; /* link-local scope, send only member */
-
- status = osmt_send_mcast_request(p_osmt, 1,
- &mc_req_rec, comp_mask, &res_sa_mad);
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, EXPECTING_ERRORS_END "\n");
-
- if ((status != IB_REMOTE_ERROR) ||
- (res_sa_mad.status != IB_SA_MAD_STATUS_REQ_INVALID)) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0221: "
- "Failed to recognize create with JoinState != FullMember - got %s/%s\n",
- ib_get_err_str(status),
- ib_get_mad_status_str((ib_mad_t *) (&res_sa_mad)));
- status = IB_ERROR;
- goto Exit;
- }
-
- /* Lets try another valid join scope state */
- OSM_LOG(&p_osmt->log, OSM_LOG_INFO,
- "Checking new MGID creation with valid join state (o15.0.2.3)...\n");
-
- mc_req_rec.mgid = good_mgid;
- mc_req_rec.mgid.raw[12] = 0xFB;
- memcpy(&special_mgid, &mc_req_rec.mgid, sizeof(ib_gid_t));
- mc_req_rec.scope_state = 0x2F; /* link-local scope, Full member with all other bits turned on */
-
- status = osmt_send_mcast_request(p_osmt, 1,
- &mc_req_rec, comp_mask, &res_sa_mad);
-
- if (status != IB_SUCCESS) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0222: "
- "Failed to create MCG with valid join state 0xF - got %s/%s\n",
- ib_get_err_str(status),
- ib_get_mad_status_str((ib_mad_t *) (&res_sa_mad)));
- goto Exit;
- }
-
- /* Save the mlid created in test_created_mlids map */
- p_recvd_rec =
- (ib_member_rec_t *) ib_sa_mad_get_payload_ptr(&res_sa_mad);
- OSM_LOG(&p_osmt->log, OSM_LOG_VERBOSE, "Created MGID:%s MLID:0x%04X\n",
- inet_ntop(AF_INET6, p_recvd_rec->mgid.raw, gid_str,
- sizeof gid_str), cl_ntoh16(p_recvd_rec->mlid));
- cl_map_insert(&test_created_mlids, cl_ntoh16(p_recvd_rec->mlid),
- p_recvd_rec);
-
- /* o15.0.1.10 - can't check on a single client .-- obsolete -
- checked by SilverStorm bug o15-0.2.4, never the less recheck */
- /* o15-0.2.4 - Check a join request to already created MCG */
- p_mc_res = ib_sa_mad_get_payload_ptr(&res_sa_mad);
- OSM_LOG(&p_osmt->log, OSM_LOG_INFO, "Check o15-0.2.4 statement...\n");
- /* Try to join */
- memcpy(&mc_req_rec.mgid, &p_mc_res->mgid, sizeof(ib_gid_t));
- /* Request Join */
- ib_member_set_join_state(&mc_req_rec, IB_MC_REC_STATE_NON_MEMBER);
- comp_mask =
- IB_MCR_COMPMASK_MGID |
- IB_MCR_COMPMASK_PORT_GID | IB_MCR_COMPMASK_JOIN_STATE;
-
- status = osmt_send_mcast_request(p_osmt, 0x1, /* SubnAdmSet */
- &mc_req_rec, comp_mask, &res_sa_mad);
- if (status != IB_SUCCESS) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 02CC: "
- "Failed to join MCG with valid req, returned status = %s\n",
- ib_get_mad_status_str((ib_mad_t *) (&res_sa_mad)));
- goto Exit;
- }
-
- p_mc_res = ib_sa_mad_get_payload_ptr(&res_sa_mad);
- if ((p_mc_res->scope_state & 0x7) != 0x7) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 02D0: "
- "Validating JoinState update failed. "
- "Expected 0x27 got 0x%02X\n",
- p_mc_res->scope_state);
- status = IB_ERROR;
- goto Exit;
- }
-
- /* o15.0.1.11: */
- /* - Try to join into a MGID that exists with JoinState=SendOnlyMember - */
- /* see that it updates JoinState. What is the routing change? */
- OSM_LOG(&p_osmt->log, OSM_LOG_INFO,
- "Checking Retry of existing MGID - See JoinState update (o15.0.1.11)...\n");
-
- mc_req_rec.mgid = good_mgid;
-
- /* first, make sure that the group exists */
- mc_req_rec.scope_state = 0x21;
- status = osmt_send_mcast_request(p_osmt, 1,
- &mc_req_rec, comp_mask, &res_sa_mad);
- if (status != IB_SUCCESS) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 02CD: "
- "Failed to create/join as full member - got %s/%s\n",
- ib_get_err_str(status),
- ib_get_mad_status_str((ib_mad_t *) (&res_sa_mad)));
- goto Exit;
- }
-
- mc_req_rec.scope_state = 0x22; /* link-local scope, non-member */
- status = osmt_send_mcast_request(p_osmt, 1,
- &mc_req_rec, comp_mask, &res_sa_mad);
- if (status != IB_SUCCESS) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 02D1: "
- "Failed to update existing MGID - got %s/%s\n",
- ib_get_err_str(status),
- ib_get_mad_status_str((ib_mad_t *) (&res_sa_mad)));
- goto Exit;
- }
-
- OSM_LOG(&p_osmt->log, OSM_LOG_INFO,
- "Validating Join State update with NonMember (o15.0.1.11)...\n");
-
- if (p_mc_res->scope_state != 0x23) { /* scope is LSB */
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 02CE: "
- "Validating JoinState update failed. Expected 0x23 got: 0x%02X\n",
- p_mc_res->scope_state);
- status = IB_ERROR;
- goto Exit;
- }
-
- /* Try delete current join state then update it with another value */
- OSM_LOG(&p_osmt->log, OSM_LOG_INFO,
- "Checking JoinState update request should return 0x22 (o15.0.1.11)...\n");
-
- mc_req_rec.rate =
- IB_LINK_WIDTH_ACTIVE_1X | IB_PATH_SELECTOR_GREATER_THAN << 6;
- mc_req_rec.mgid = good_mgid;
-
- OSM_LOG(&p_osmt->log, OSM_LOG_INFO,
- "Checking Partially delete JoinState (o15.0.1.14)...\n");
-
- /* link-local scope, both non-member bits,
- so we should not be able to delete) */
- mc_req_rec.scope_state = 0x26;
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, EXPECTING_ERRORS_START "\n");
- status = osmt_send_mcast_request(p_osmt, 0,
- &mc_req_rec, comp_mask, &res_sa_mad);
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, EXPECTING_ERRORS_END "\n");
-
- if (status != IB_REMOTE_ERROR) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 02CF: "
- "Expected to fail partially update JoinState, "
- "but got %s\n",
- ib_get_err_str(status));
- status = IB_ERROR;
- goto Exit;
- }
-
- /* link-local scope, NonMember bit, the FullMember bit should stay */
- mc_req_rec.scope_state = 0x22;
- status = osmt_send_mcast_request(p_osmt, 0,
- &mc_req_rec, comp_mask, &res_sa_mad);
- if (status != IB_SUCCESS) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 02D3: "
- "Failed to partially update JoinState : %s/%s\n",
- ib_get_err_str(status),
- ib_get_mad_status_str((ib_mad_t *) (&res_sa_mad)));
- status = IB_ERROR;
- goto Exit;
- }
-
- p_mc_res = ib_sa_mad_get_payload_ptr(&res_sa_mad);
- if (p_mc_res->scope_state != 0x21) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 02D4: "
- "Failed to partially update JoinState : "
- "JoinState = 0x%02X, expected 0x%02X\n",
- p_mc_res->scope_state, 0x21);
- status = IB_ERROR;
- goto Exit;
- }
-
- /* So far successfully delete state - Now change it */
- mc_req_rec.mgid = good_mgid;
- mc_req_rec.scope_state = 0x24; /* link-local scope, send only member */
-
- status = osmt_send_mcast_request(p_osmt, 1,
- &mc_req_rec, comp_mask, &res_sa_mad);
- if (status != IB_SUCCESS) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 02C0: "
- "Failed to update existing MCG - got %s/%s\n",
- ib_get_err_str(status),
- ib_get_mad_status_str((ib_mad_t *) (&res_sa_mad)));
- goto Exit;
- }
-
- OSM_LOG(&p_osmt->log, OSM_LOG_INFO,
- "Validating Join State update with Send Only Member (o15.0.1.11)...\n");
-
- if (p_mc_res->scope_state != 0x25) { /* scope is MSB */
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 02C1: "
- "Validating JoinState update failed. Expected 0x25 got: 0x%02X\n",
- p_mc_res->scope_state);
- status = IB_ERROR;
- goto Exit;
- }
- /* Now try to update value of join state */
- mc_req_rec.scope_state = 0x21; /* link-local scope, full member */
-
- status = osmt_send_mcast_request(p_osmt, 1,
- &mc_req_rec, comp_mask, &res_sa_mad);
- if (status != IB_SUCCESS) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 02C2: "
- "Failed to update existing MGID - got %s/%s\n",
- ib_get_err_str(status),
- ib_get_mad_status_str((ib_mad_t *) (&res_sa_mad)));
- goto Exit;
- }
-
- OSM_LOG(&p_osmt->log, OSM_LOG_INFO,
- "Validating Join State update with Full Member\n\t\t"
- "to an existing 0x5 state MCG (o15.0.1.11)...\n");
-
- if (p_mc_res->scope_state != 0x25) { /* scope is LSB */
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 02C3: "
- "Validating JoinState update failed. Expected 0x25 got: 0x%02X\n",
- p_mc_res->scope_state);
- status = IB_ERROR;
- goto Exit;
- }
-
- /* Now try to update value of join state */
- mc_req_rec.scope_state = 0x22; /* link-local scope,non member */
-
- status = osmt_send_mcast_request(p_osmt, 1,
- &mc_req_rec, comp_mask, &res_sa_mad);
- if (status != IB_SUCCESS) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 02C4: "
- "Failed to update existing MGID - got %s/%s\n",
- ib_get_err_str(status),
- ib_get_mad_status_str((ib_mad_t *) (&res_sa_mad)));
- goto Exit;
- }
- OSM_LOG(&p_osmt->log, OSM_LOG_INFO,
- "Validating Join State update with Non Member\n\t\t"
- "to an existing 0x5 state MCG (o15.0.1.11)...\n");
-
- if (p_mc_res->scope_state != 0x27) { /* scope is LSB */
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 02C5: "
- "Validating JoinState update failed. Expected 0x27 got: 0x%02X\n",
- p_mc_res->scope_state);
- status = IB_ERROR;
- goto Exit;
- }
-
- OSM_LOG(&p_osmt->log, OSM_LOG_VERBOSE,
- "DEBUG - Current scope_state value : 0x%02X...\n",
- p_mc_res->scope_state);
-
- /* - We can not check simple join since we have only one tester (for now) */
-
- /* o15.0.1.12: Not Supported */
- /* - The SendOnlyNonMem join should have a special treatment in the
- SA but what is it ? */
-
- /* o15.0.1.13: */
- /* - Try joining with rate that does not exist in any MCG -
- ERR_REQ_INVALID */
-
- OSM_LOG(&p_osmt->log, OSM_LOG_INFO,
- "Checking BAD RATE when connecting to existing MGID (o15.0.1.13)...\n");
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, EXPECTING_ERRORS_START "\n");
-
- mc_req_rec.mgid = good_mgid;
- mc_req_rec.rate =
- IB_LINK_WIDTH_ACTIVE_1X | IB_PATH_SELECTOR_LESS_THAN << 6;
- comp_mask = IB_MCR_COMPMASK_GID | IB_MCR_COMPMASK_PORT_GID | IB_MCR_COMPMASK_QKEY | IB_MCR_COMPMASK_PKEY | IB_MCR_COMPMASK_SL | IB_MCR_COMPMASK_FLOW | IB_MCR_COMPMASK_JOIN_STATE | IB_MCR_COMPMASK_TCLASS | /* all above are required */
- IB_MCR_COMPMASK_RATE_SEL | IB_MCR_COMPMASK_RATE;
-
- status = osmt_send_mcast_request(p_osmt, 1,
- &mc_req_rec, comp_mask, &res_sa_mad);
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, EXPECTING_ERRORS_END "\n");
-
- if ((status != IB_REMOTE_ERROR) ||
- (res_sa_mad.status != IB_SA_MAD_STATUS_REQ_INVALID)) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 02C6: "
- "Failed to catch BAD RATE joining an exiting MGID: %s/%s\n",
- ib_get_err_str(status),
- ib_get_mad_status_str((ib_mad_t *) (&res_sa_mad)));
- status = IB_ERROR;
- goto Exit;
- }
-
- /* Try MTU that does not exist in any MCG */
- OSM_LOG(&p_osmt->log, OSM_LOG_INFO,
- "Checking BAD MTU (higher them max) when connecting to "
- "existing MGID (o15.0.1.13)...\n");
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, EXPECTING_ERRORS_START "\n");
-
- mc_req_rec.mgid = osm_ipoib_mgid;
- mc_req_rec.mtu = IB_MTU_LEN_4096 | IB_PATH_SELECTOR_GREATER_THAN << 6;
- comp_mask = IB_MCR_COMPMASK_GID | IB_MCR_COMPMASK_PORT_GID | IB_MCR_COMPMASK_QKEY | IB_MCR_COMPMASK_PKEY | IB_MCR_COMPMASK_SL | IB_MCR_COMPMASK_FLOW | IB_MCR_COMPMASK_JOIN_STATE | IB_MCR_COMPMASK_TCLASS | /* all above are required */
- IB_MCR_COMPMASK_MTU_SEL | IB_MCR_COMPMASK_MTU;
-
- status = osmt_send_mcast_request(p_osmt, 1,
- &mc_req_rec, comp_mask, &res_sa_mad);
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, EXPECTING_ERRORS_END "\n");
-
- if ((status != IB_REMOTE_ERROR) ||
- (res_sa_mad.status != IB_SA_MAD_STATUS_REQ_INVALID)) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 02C7: "
- "Failed to catch BAD RATE (higher them max) joining an exiting MGID: %s/%s\n",
- ib_get_err_str(status),
- ib_get_mad_status_str((ib_mad_t *) (&res_sa_mad)));
- status = IB_ERROR;
- goto Exit;
- }
-
- /* Try another MTU that does not exist in any MCG */
- OSM_LOG(&p_osmt->log, OSM_LOG_INFO,
- "Checking BAD MTU (less than min) when connecting "
- "to existing MGID (o15.0.1.13)...\n");
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, EXPECTING_ERRORS_START "\n");
-
- mc_req_rec.mgid = osm_ipoib_mgid;
- mc_req_rec.mtu = IB_MTU_LEN_256 | IB_PATH_SELECTOR_LESS_THAN << 6;
- comp_mask = IB_MCR_COMPMASK_GID | IB_MCR_COMPMASK_PORT_GID | IB_MCR_COMPMASK_QKEY | IB_MCR_COMPMASK_PKEY | IB_MCR_COMPMASK_SL | IB_MCR_COMPMASK_FLOW | IB_MCR_COMPMASK_JOIN_STATE | IB_MCR_COMPMASK_TCLASS | /* all above are required */
- IB_MCR_COMPMASK_MTU_SEL | IB_MCR_COMPMASK_MTU;
-
- status = osmt_send_mcast_request(p_osmt, 1,
- &mc_req_rec, comp_mask, &res_sa_mad);
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, EXPECTING_ERRORS_END "\n");
-
- if ((status != IB_REMOTE_ERROR) ||
- (res_sa_mad.status != IB_SA_MAD_STATUS_REQ_INVALID)) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 02C8: "
- "Failed to catch BAD RATE (less them min) joining an exiting MGID: %s/%s\n",
- ib_get_err_str(status),
- ib_get_mad_status_str((ib_mad_t *) (&res_sa_mad)));
- status = IB_ERROR;
- goto Exit;
- }
-
- /* o15.0.1.14: */
- /* - Try partial delete - actually updating the join state. check it. */
-
- OSM_LOG(&p_osmt->log, OSM_LOG_INFO,
- "Checking partial JoinState delete request - removing NonMember (o15.0.1.14)...\n");
-
- mc_req_rec.rate =
- IB_LINK_WIDTH_ACTIVE_1X | IB_PATH_SELECTOR_GREATER_THAN << 6;
- mc_req_rec.mgid = good_mgid;
- comp_mask = IB_MCR_COMPMASK_GID | IB_MCR_COMPMASK_PORT_GID | IB_MCR_COMPMASK_QKEY | IB_MCR_COMPMASK_PKEY | IB_MCR_COMPMASK_SL | IB_MCR_COMPMASK_FLOW | IB_MCR_COMPMASK_JOIN_STATE | IB_MCR_COMPMASK_TCLASS | /* all above are required */
- IB_MCR_COMPMASK_RATE_SEL | IB_MCR_COMPMASK_RATE;
- /* link-local scope, non member (so we should not be able to delete) */
- /* but the NonMember bit should be gone */
- mc_req_rec.scope_state = 0x22;
-
- status = osmt_send_mcast_request(p_osmt, 0,
- &mc_req_rec, comp_mask, &res_sa_mad);
-
- if (status != IB_SUCCESS) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 02C9: "
- "Fail to partially update JoinState during delete: %s/%s\n",
- ib_get_err_str(status),
- ib_get_mad_status_str((ib_mad_t *) (&res_sa_mad)));
- status = IB_ERROR;
- goto Exit;
- }
-
- OSM_LOG(&p_osmt->log, OSM_LOG_INFO,
- "Validating Join State removal of Non Member bit (o15.0.1.14)...\n");
- if (p_mc_res->scope_state != 0x25) { /* scope is MSB - now only the full member & send only member have left */
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 02CA: "
- "Validating JoinState update failed. Expected 0x25 got: 0x%02X\n",
- p_mc_res->scope_state);
- status = IB_ERROR;
- goto Exit;
- }
-
- /* Now use the same scope_state and delete all JoinState - leave multicast group since state is 0x0 */
-
- mc_req_rec.scope_state = 0x25;
- status = osmt_send_mcast_request(p_osmt, 0,
- &mc_req_rec, comp_mask, &res_sa_mad);
-
- if (status != IB_SUCCESS) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 02CB: "
- "Failed to update JoinState during delete: %s/%s\n",
- ib_get_err_str(status),
- ib_get_mad_status_str((ib_mad_t *) (&res_sa_mad)));
- status = IB_ERROR;
- goto Exit;
- }
-
- OSM_LOG(&p_osmt->log, OSM_LOG_INFO,
- "Validating Join State update remove (o15.0.1.14)...\n");
-
- if (p_mc_res->scope_state != 0x25) { /* scope is MSB - now only 0x0 so port is removed from MCG */
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 02BF: "
- "Validating JoinState update failed. Expected 0x25 got: 0x%02X\n",
- p_mc_res->scope_state);
- status = IB_ERROR;
- goto Exit;
- }
-
- /* - Try joining (not full mem) again to see the group was deleted. (should fail) */
- OSM_LOG(&p_osmt->log, OSM_LOG_INFO,
- "Checking Delete by trying to Join deleted group (o15.0.1.13)...\n");
-
- mc_req_rec.scope_state = 0x22; /* use non member - so if no group fail */
-
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, EXPECTING_ERRORS_START "\n");
- status = osmt_send_mcast_request(p_osmt, 1, /* join */
- &mc_req_rec, comp_mask, &res_sa_mad);
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, EXPECTING_ERRORS_END "\n");
-
- if (status != IB_REMOTE_ERROR) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 02BC: "
- "Succeeded Joining Deleted Group: %s/%s\n",
- ib_get_err_str(status),
- ib_get_mad_status_str((ib_mad_t *) (&res_sa_mad)));
- status = IB_ERROR;
- goto Exit;
- }
-
- /* - Try deletion of the IPoIB MCG and get: ERR_REQ_INVALID */
- OSM_LOG(&p_osmt->log, OSM_LOG_INFO,
- "Checking BAD Delete of Mgid membership (no prev join) (o15.0.1.15)...\n");
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, EXPECTING_ERRORS_START "\n");
-
- mc_req_rec.mgid = osm_ipoib_mgid;
- mc_req_rec.rate =
- IB_LINK_WIDTH_ACTIVE_1X | IB_PATH_SELECTOR_GREATER_THAN << 6;
- mc_req_rec.scope_state = 0x21; /* delete full member */
-
- status = osmt_send_mcast_request(p_osmt, 0, /* delete flag */
- &mc_req_rec, comp_mask, &res_sa_mad);
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, EXPECTING_ERRORS_END "\n");
-
- if ((status != IB_REMOTE_ERROR) ||
- (res_sa_mad.status != IB_SA_MAD_STATUS_REQ_INVALID)) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 02BD: "
- "Failed to catch BAD delete from IPoIB: %s/%s\n",
- ib_get_err_str(status),
- ib_get_mad_status_str((ib_mad_t *) (&res_sa_mad)));
- status = IB_ERROR;
- goto Exit;
- }
-
- /* Prepare another MCG for the following tests : */
- OSM_LOG(&p_osmt->log, OSM_LOG_INFO,
- "Checking Create given MGID=%s\n\t\t(o15.0.1.4)...\n",
- inet_ntop(AF_INET6, osm_ipoib_mgid.raw, gid_str,
- sizeof gid_str));
-
- mc_req_rec.mgid = good_mgid;
- mc_req_rec.mgid.raw[12] = 0xAA;
- mc_req_rec.pkt_life = 0 | IB_PATH_SELECTOR_GREATER_THAN << 6;
- mc_req_rec.scope_state = 0x21; /* Full memeber */
- comp_mask = IB_MCR_COMPMASK_GID | IB_MCR_COMPMASK_PORT_GID | IB_MCR_COMPMASK_QKEY | IB_MCR_COMPMASK_PKEY | IB_MCR_COMPMASK_SL | IB_MCR_COMPMASK_FLOW | IB_MCR_COMPMASK_JOIN_STATE | IB_MCR_COMPMASK_TCLASS | /* all above are required */
- IB_MCR_COMPMASK_LIFE | IB_MCR_COMPMASK_LIFE_SEL;
-
- status = osmt_send_mcast_request(p_osmt, 1,
- &mc_req_rec, comp_mask, &res_sa_mad);
- if (status != IB_SUCCESS) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 02BE: "
- "Failed to create MCG for %s - got %s/%s\n",
- inet_ntop(AF_INET6, good_mgid.raw, gid_str,
- sizeof gid_str), ib_get_err_str(status),
- ib_get_mad_status_str((ib_mad_t *) (&res_sa_mad)));
- goto Exit;
- }
-
- /* - Try delete with valid join state */
- OSM_LOG(&p_osmt->log, OSM_LOG_INFO,
- "Checking Full Delete of a group (o15.0.1.14)...\n");
- mc_req_rec.scope_state = 0x21; /* the FullMember is the current JoinState */
- status = osmt_send_mcast_request(p_osmt, 0,
- &mc_req_rec, comp_mask, &res_sa_mad);
-
- if (status != IB_SUCCESS) {
- goto Exit;
- }
-
- /* o15.0.1.15: */
- /* - Try deletion of the IPoIB MCG and get: ERR_REQ_INVALID */
- OSM_LOG(&p_osmt->log, OSM_LOG_INFO,
- "Checking BAD Delete of IPoIB membership (no prev join) (o15.0.1.15)...\n");
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, EXPECTING_ERRORS_START "\n");
-
- mc_req_rec.mgid = osm_ipoib_mgid;
- mc_req_rec.rate =
- IB_LINK_WIDTH_ACTIVE_1X | IB_PATH_SELECTOR_GREATER_THAN << 6;
- mc_req_rec.scope_state = 0x21; /* delete full member */
-
- status = osmt_send_mcast_request(p_osmt, 0, /* delete flag */
- &mc_req_rec, comp_mask, &res_sa_mad);
-
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, EXPECTING_ERRORS_END "\n");
-
- if ((status != IB_REMOTE_ERROR) ||
- (res_sa_mad.status != IB_SA_MAD_STATUS_REQ_INVALID)) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0223: "
- "Failed to catch BAD delete from IPoIB: %s/%s\n",
- ib_get_err_str(status),
- ib_get_mad_status_str((ib_mad_t *) (&res_sa_mad)));
- status = IB_ERROR;
- goto Exit;
- }
-
- /**************************************************************************/
- /* Checking join with invalid MTU */
- osmt_init_mc_query_rec(p_osmt, &mc_req_rec);
- OSM_LOG(&p_osmt->log, OSM_LOG_INFO,
- "Checking Join with unrealistic mtu : \n"
- "\t\tFirst create new MCG than try to join it \n"
- "\t\twith unrealistic MTU greater than 4096 (o15.0.1.8)...\n");
-
- /* First create new mgrp */
- ib_member_set_join_state(&mc_req_rec, IB_MC_REC_STATE_FULL_MEMBER);
- mc_req_rec.mtu = IB_MTU_LEN_1024 | IB_PATH_SELECTOR_EXACTLY << 6;
- memset(&mc_req_rec.mgid, 0, sizeof(ib_gid_t));
- comp_mask = IB_MCR_COMPMASK_MGID | IB_MCR_COMPMASK_PORT_GID | IB_MCR_COMPMASK_QKEY | IB_MCR_COMPMASK_PKEY | IB_MCR_COMPMASK_SL | IB_MCR_COMPMASK_FLOW | IB_MCR_COMPMASK_JOIN_STATE | IB_MCR_COMPMASK_TCLASS | /* all above are required */
- IB_MCR_COMPMASK_MTU_SEL | IB_MCR_COMPMASK_MTU;
-
- status = osmt_send_mcast_request(p_osmt, 1,
- &mc_req_rec, comp_mask, &res_sa_mad);
- p_mc_res = ib_sa_mad_get_payload_ptr(&res_sa_mad);
- if (status != IB_SUCCESS) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 02EB: "
- "Failed to create new mgrp\n");
- goto Exit;
- }
- memcpy(&tmp_mgid, &p_mc_res->mgid, sizeof(ib_gid_t));
- osm_dump_mc_record(&p_osmt->log, p_mc_res, OSM_LOG_INFO);
- /* tmp_mtu = p_mc_res->mtu & 0x3F; */
-
- /* impossible requested mtu always greater than exist in MCG */
- mc_req_rec.mtu = IB_MTU_LEN_4096 | IB_PATH_SELECTOR_GREATER_THAN << 6;
- memcpy(&mc_req_rec.mgid, &tmp_mgid, sizeof(ib_gid_t));
- ib_member_set_join_state(&mc_req_rec, IB_MC_REC_STATE_FULL_MEMBER);
- comp_mask =
- IB_MCR_COMPMASK_GID |
- IB_MCR_COMPMASK_PORT_GID |
- IB_MCR_COMPMASK_JOIN_STATE |
- IB_MCR_COMPMASK_MTU_SEL | IB_MCR_COMPMASK_MTU;
-
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, EXPECTING_ERRORS_START "\n");
- status = osmt_send_mcast_request(p_osmt, 1,
- &mc_req_rec, comp_mask, &res_sa_mad);
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, EXPECTING_ERRORS_END "\n");
-
- if (status == IB_SUCCESS) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 02E4: "
- "Expected REMOTE ERROR got:%s/%s\n",
- ib_get_err_str(status),
- ib_get_mad_status_str((ib_mad_t *) (&res_sa_mad)));
- status = IB_ERROR;
- goto Exit;
- }
-
- /* - Try GetTable with PortGUID wildcarded and get back some groups. */
- status = osmt_query_mcast(p_osmt);
- cnt = cl_qmap_count(&p_osmt->exp_subn.mgrp_mlid_tbl);
- OSM_LOG(&p_osmt->log, OSM_LOG_INFO, "(Before checking Max MCG creation): "
- "Number of MC Records found in SA DB is %d\n", cnt);
-
- /**************************************************************************/
- /* Checking join on behalf of remote port gid */
- OSM_LOG(&p_osmt->log, OSM_LOG_INFO, "Checking Proxy Join...\n");
- osmt_init_mc_query_rec(p_osmt, &mc_req_rec);
- memset(&context, 0, sizeof(context));
-
- /*
- * Do a blocking query for all NodeRecords in the subnet.
- */
- status = osmtest_get_all_recs(p_osmt, IB_MAD_ATTR_NODE_RECORD,
- sizeof(*p_rec), &context);
-
- if (status != IB_SUCCESS) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 02E5: "
- "osmtest_get_all_recs failed on getting all node records(%s)\n",
- ib_get_err_str(status));
- goto Exit;
- }
-
- /*
- * Populate the database with the received records.
- */
- num_recs = context.result.result_cnt;
- OSM_LOG(&p_osmt->log, OSM_LOG_VERBOSE, "Received %u records\n", num_recs);
-
- for (i = 0; i < num_recs; i++) {
- p_rec =
- osmv_get_query_node_rec(context.result.p_result_madw, i);
- if (p_rec->node_info.port_guid != p_osmt->local_port.port_guid
- && p_rec->node_info.node_type == IB_NODE_TYPE_CA) {
- OSM_LOG(&p_osmt->log, OSM_LOG_VERBOSE,
- "remote port_guid = 0x%" PRIx64 "\n",
- cl_ntoh64(p_rec->node_info.port_guid));
-
- remote_port_guid = p_rec->node_info.port_guid;
- i = num_recs;
- break;
- }
- }
-
- if (remote_port_guid != 0x0) {
- ib_member_set_join_state(&mc_req_rec,
- IB_MC_REC_STATE_FULL_MEMBER);
- memset(&mc_req_rec.mgid, 0, sizeof(ib_gid_t));
- mc_req_rec.port_gid.unicast.interface_id = remote_port_guid;
- comp_mask = IB_MCR_COMPMASK_MGID | IB_MCR_COMPMASK_PORT_GID | IB_MCR_COMPMASK_QKEY | IB_MCR_COMPMASK_PKEY | IB_MCR_COMPMASK_SL | IB_MCR_COMPMASK_FLOW | IB_MCR_COMPMASK_JOIN_STATE | IB_MCR_COMPMASK_TCLASS; /* all above are required */
-
- status = osmt_send_mcast_request(p_osmt, 1,
- &mc_req_rec,
- comp_mask, &res_sa_mad);
-
- if (status != IB_SUCCESS) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 02B4: "
- "Could not join on behalf of remote port 0x%016"
- PRIx64 " remote status: %s\n",
- cl_ntoh64(remote_port_guid),
- ib_get_mad_status_str((ib_mad_t
- *) (&res_sa_mad)));
- status = IB_ERROR;
- goto Exit;
- }
-
- p_mc_res = ib_sa_mad_get_payload_ptr(&res_sa_mad);
- memcpy(&proxy_mgid, &p_mc_res->mgid, sizeof(ib_gid_t));
-
- /* First try a bad deletion then good one */
-
- OSM_LOG(&p_osmt->log, OSM_LOG_INFO,
- "Trying deletion of remote port with local port guid\n");
-
- osmt_init_mc_query_rec(p_osmt, &mc_req_rec);
- ib_member_set_join_state(&mc_req_rec,
- IB_MC_REC_STATE_FULL_MEMBER);
- comp_mask =
- IB_MCR_COMPMASK_MGID | IB_MCR_COMPMASK_PORT_GID |
- IB_MCR_COMPMASK_JOIN_STATE;
-
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, EXPECTING_ERRORS_START "\n");
-
- status = osmt_send_mcast_request(p_osmt, 0, /* delete flag */
- &mc_req_rec,
- comp_mask, &res_sa_mad);
-
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, EXPECTING_ERRORS_END "\n");
-
- if (status == IB_SUCCESS) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 02A9: "
- "Successful deletion of remote port guid with local one MGID : "
- "%s, Got : %s/%s\n",
- inet_ntop(AF_INET6,
- p_mgrp->mcmember_rec.mgid.raw,
- gid_str, sizeof gid_str),
- ib_get_err_str(status),
- ib_get_mad_status_str((ib_mad_t
- *) (&res_sa_mad)));
- status = IB_ERROR;
- goto Exit;
- }
-
- OSM_LOG(&p_osmt->log, OSM_LOG_INFO,
- "Trying deletion of remote port with the right port guid\n");
-
- osmt_init_mc_query_rec(p_osmt, &mc_req_rec);
- ib_member_set_join_state(&mc_req_rec,
- IB_MC_REC_STATE_FULL_MEMBER);
- mc_req_rec.mgid = proxy_mgid;
- mc_req_rec.port_gid.unicast.interface_id = remote_port_guid;
- comp_mask =
- IB_MCR_COMPMASK_MGID |
- IB_MCR_COMPMASK_PORT_GID | IB_MCR_COMPMASK_JOIN_STATE;
- status = osmt_send_mcast_request(p_osmt, 0, /* delete flag */
- &mc_req_rec,
- comp_mask, &res_sa_mad);
- if (status != IB_SUCCESS) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 02B0: "
- "Failed to delete mgid with remote port guid MGID : "
- "%s, Got : %s/%s\n",
- inet_ntop(AF_INET6,
- p_mgrp->mcmember_rec.mgid.raw,
- gid_str, sizeof gid_str),
- ib_get_err_str(status),
- ib_get_mad_status_str((ib_mad_t
- *) (&res_sa_mad)));
- goto Exit;
- }
- } else {
- OSM_LOG(&p_osmt->log, OSM_LOG_INFO,
- "Could not check proxy join since could not found remote port, different from local port\n");
- }
-
- /* prepare init for next check */
- osmt_init_mc_query_rec(p_osmt, &mc_req_rec);
-
- /**************************************************************************/
- if (p_osmt->opt.mmode > 2) {
- /* Check invalid Join with max mlid which is more than the
- Mellanox switches support 0xC000+0x1000 = 0xd000 */
- OSM_LOG(&p_osmt->log, OSM_LOG_INFO,
- "Checking Creation of Maximum avaliable Groups (MulticastFDBCap)...\n");
- tmp_mlid = cl_ntoh16(max_mlid) - cnt;
-
- while (tmp_mlid > 0 && !ReachedMlidLimit) {
- uint16_t cur_mlid = 0;
-
- /* Request Set */
- ib_member_set_join_state(&mc_req_rec,
- IB_MC_REC_STATE_FULL_MEMBER);
- /* Good Flow - mgid is 0 while giving all required fields for
- join : P_Key, Q_Key, SL, FlowLabel, Tclass */
-
- mc_req_rec.rate =
- IB_LINK_WIDTH_ACTIVE_1X |
- IB_PATH_SELECTOR_GREATER_THAN << 6;
- mc_req_rec.mlid = max_mlid;
- memset(&mc_req_rec.mgid, 0, sizeof(ib_gid_t));
- comp_mask = IB_MCR_COMPMASK_MGID | IB_MCR_COMPMASK_PORT_GID | IB_MCR_COMPMASK_QKEY | IB_MCR_COMPMASK_PKEY | IB_MCR_COMPMASK_SL | IB_MCR_COMPMASK_FLOW | IB_MCR_COMPMASK_JOIN_STATE | IB_MCR_COMPMASK_TCLASS | /* all above are required */
- IB_MCR_COMPMASK_MLID;
- status = osmt_send_mcast_request(p_osmt, 1,
- &mc_req_rec,
- comp_mask,
- &res_sa_mad);
-
- p_mc_res = ib_sa_mad_get_payload_ptr(&res_sa_mad);
- if (status != IB_SUCCESS) {
-
- if (cur_mlid > cl_ntoh16(max_mlid)) {
-
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR,
- "ERR 2E1 "
- "Successful Join with greater mlid than switches support (MulticastFDBCap) 0x%04X\n",
- cur_mlid);
- status = IB_ERROR;
- osm_dump_mc_record(&p_osmt->log,
- p_mc_res,
- OSM_LOG_VERBOSE);
- goto Exit;
- } else
- if ((res_sa_mad.
- status & IB_SMP_STATUS_MASK) ==
- IB_SA_MAD_STATUS_NO_RESOURCES) {
- /* You can quitly exit the loop since no available mlid in SA DB
- i.e. reached the maximum valiad avalable mlid */
- ReachedMlidLimit = TRUE;
- }
- } else {
- cur_mlid = cl_ntoh16(p_mc_res->mlid);
- /* Save the mlid created in test_created_mlids map */
- p_recvd_rec =
- (ib_member_rec_t *)
- ib_sa_mad_get_payload_ptr(&res_sa_mad);
- OSM_LOG(&p_osmt->log, OSM_LOG_VERBOSE,
- "Created MGID:%s MLID:0x%04X\n",
- inet_ntop(AF_INET6,
- p_recvd_rec->mgid.raw,
- gid_str, sizeof gid_str),
- cl_ntoh16(p_recvd_rec->mlid));
- cl_map_insert(&test_created_mlids,
- cl_ntoh16(p_recvd_rec->mlid),
- p_recvd_rec);
- }
- tmp_mlid--;
- }
- }
-
- /* Prepare the mc_req_rec for the rest of the flow */
- osmt_init_mc_query_rec(p_osmt, &mc_req_rec);
-
- /**************************************************************************/
- /* o15.0.1.16: */
- /* - Try GetTable with PortGUID wildcarded and get back some groups. */
-
- status = osmt_query_mcast(p_osmt);
- if (status != IB_SUCCESS) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 02B1: "
- "Failed to query multicast groups: %s\n",
- ib_get_err_str(status));
- goto Exit;
- }
-
- cnt = cl_qmap_count(&p_osmt->exp_subn.mgrp_mlid_tbl);
- OSM_LOG(&p_osmt->log, OSM_LOG_INFO, "(Before Deletion of all MCG): "
- "Number of MC Records found in SA DB is %d\n", cnt);
-
- /* Delete all MCG that are not of IPoIB */
- OSM_LOG(&p_osmt->log, OSM_LOG_INFO,
- "Cleanup all MCG that are not IPoIB...\n");
-
- p_mgrp_mlid_tbl = &p_osmt->exp_subn.mgrp_mlid_tbl;
- p_mgrp = (osmtest_mgrp_t *) cl_qmap_head(p_mgrp_mlid_tbl);
- /* scan all available multicast groups in the DB and fill in the table */
- while (p_mgrp != (osmtest_mgrp_t *) cl_qmap_end(p_mgrp_mlid_tbl)) {
- /* Only if different from IPoIB Mgid try to delete */
- if (!IS_IPOIB_MGID(&p_mgrp->mcmember_rec.mgid)) {
- osmt_init_mc_query_rec(p_osmt, &mc_req_rec);
- mc_req_rec.mgid = p_mgrp->mcmember_rec.mgid;
-
- /* o15-0.1.4 - need to specify the oppsite state for a valid delete */
- if (!memcmp
- (&special_mgid, &p_mgrp->mcmember_rec.mgid,
- sizeof(special_mgid))) {
- mc_req_rec.scope_state = 0x2F;
- } else {
- mc_req_rec.scope_state = 0x21;
- }
- comp_mask =
- IB_MCR_COMPMASK_MGID |
- IB_MCR_COMPMASK_PORT_GID |
- IB_MCR_COMPMASK_JOIN_STATE;
-
- OSM_LOG(&p_osmt->log, OSM_LOG_VERBOSE,
- "Sending request to delete MGID : %s"
- ", scope_state : 0x%02X\n",
- inet_ntop(AF_INET6, mc_req_rec.mgid.raw,
- gid_str, sizeof gid_str),
- mc_req_rec.scope_state);
- status = osmt_send_mcast_request(p_osmt, 0, /* delete flag */
- &mc_req_rec,
- comp_mask,
- &res_sa_mad);
- if (status != IB_SUCCESS) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR,
- "ERR 02FF: Failed to delete MGID : %s"
- " ,\n\t\t it is not our MCG, Status : %s/%s\n",
- inet_ntop(AF_INET6,
- p_mgrp->mcmember_rec.mgid.raw,
- gid_str, sizeof gid_str),
- ib_get_err_str(status),
- ib_get_mad_status_str((ib_mad_t *)
- (&res_sa_mad)));
- fail_to_delete_mcg++;
- }
- } else {
- end_ipoib_cnt++;
- }
- p_mgrp = (osmtest_mgrp_t *) cl_qmap_next(&p_mgrp->map_item);
- }
-
- status = osmt_query_mcast(p_osmt);
-
- if (status != IB_SUCCESS) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 02B2 "
- "GetTable of all records has failed - got %s\n",
- ib_get_err_str(status));
- goto Exit;
- }
-
- /* If we are in single mode check flow - need to make sure all the multicast groups
- that are left are not ones created during the flow.
- */
- if (p_osmt->opt.mmode == 1 || p_osmt->opt.mmode == 3) {
- end_cnt = cl_qmap_count(&p_osmt->exp_subn.mgrp_mlid_tbl);
-
- OSM_LOG(&p_osmt->log, OSM_LOG_INFO, "Status of MC Records in SA DB during the test flow:\n" " Beginning of test\n" " Unrelated to the test: %d\n" " IPoIB MC Records : %d\n" " Total : %d\n" " End of test\n" " Failed to delete : %d\n" " IPoIB MC Records : %d\n" " Total : %d\n", mcg_outside_test_cnt, /* Non-IPoIB that existed at the beginning */
- start_ipoib_cnt, /* IPoIB records */
- start_cnt, /* Total: IPoIB and MC Records unrelated to the test */
- fail_to_delete_mcg, /* Failed to delete at the end */
- end_ipoib_cnt, /* IPoIB records */
- end_cnt); /* Total MC Records at the end */
-
- /* when we compare num of MCG we should consider an outside source which create other MCGs */
- if ((end_cnt - fail_to_delete_mcg - end_ipoib_cnt) !=
- (start_cnt - mcg_outside_test_cnt - start_ipoib_cnt)) {
- OSM_LOG(&p_osmt->log, OSM_LOG_INFO,
- "Got different number of non-IPoIB records stored in SA DB\n\t\t"
- "at Start got %d, at End got %d (IPoIB groups only)\n",
- (start_cnt - mcg_outside_test_cnt -
- start_ipoib_cnt),
- (end_cnt - fail_to_delete_mcg - end_ipoib_cnt));
- }
-
- p_mgrp_mlid_tbl = &p_osmt->exp_subn.mgrp_mlid_tbl;
- p_mgrp = (osmtest_mgrp_t *) cl_qmap_head(p_mgrp_mlid_tbl);
- while (p_mgrp !=
- (osmtest_mgrp_t *) cl_qmap_end(p_mgrp_mlid_tbl)) {
- uint16_t mlid =
- (uint16_t) cl_qmap_key((cl_map_item_t *) p_mgrp);
-
- OSM_LOG(&p_osmt->log, OSM_LOG_INFO,
- "Found MLID:0x%04X\n", mlid);
- /* Check if the mlid is in the test_created_mlids. If TRUE, then we
- didn't delete a MCgroup that was created in this flow. */
- if (cl_map_get(&test_created_mlids, mlid) != NULL) {
- /* This means that we still have an mgrp that we created!! */
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 02FE: "
- "Wasn't able to erase mgrp with MGID:%s"
- " MLID:0x%04X\n",
- inet_ntop(AF_INET6,
- p_mgrp->mcmember_rec.mgid.raw,
- gid_str, sizeof gid_str),
- mlid);
- got_error = TRUE;
- } else {
- OSM_LOG(&p_osmt->log, OSM_LOG_INFO,
- "Still exists %s MGID:%s\n",
- (IS_IPOIB_MGID
- (&p_mgrp->mcmember_rec.
- mgid)) ? "IPoIB" : "non-IPoIB",
- inet_ntop(AF_INET6,
- p_mgrp->mcmember_rec.mgid.raw,
- gid_str, sizeof gid_str));
- }
- p_mgrp =
- (osmtest_mgrp_t *) cl_qmap_next(&p_mgrp->map_item);
- }
-
- if (got_error) {
- __osmt_print_all_multicast_records(p_osmt);
- status = IB_ERROR;
- }
- }
-Exit:
- OSM_LOG_EXIT(&p_osmt->log);
- return status;
-}
diff --git a/contrib/ofed/management/opensm/osmtest/osmt_service.c b/contrib/ofed/management/opensm/osmtest/osmt_service.c
deleted file mode 100644
index 97f1492..0000000
--- a/contrib/ofed/management/opensm/osmtest/osmt_service.c
+++ /dev/null
@@ -1,1616 +0,0 @@
-/*
- * Copyright (c) 2006-2008 Voltaire, Inc. All rights reserved.
- * Copyright (c) 2002-2006 Mellanox Technologies LTD. All rights reserved.
- * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- */
-
-/*
- * Abstract:
- * Implementation of service records testing flow..
- * Top level is osmt_run_service_records_flow:
- * osmt_register_service
- * osmt_get_service_by_name
- * osmt_get_all_services
- * osmt_delete_service_by_name
- *
- */
-
-#ifndef __WIN__
-#include <unistd.h>
-#else
-#include <time.h>
-#endif
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <complib/cl_debug.h>
-#include "osmtest.h"
-
-/**********************************************************************
- **********************************************************************/
-
-ib_api_status_t
-osmt_register_service(IN osmtest_t * const p_osmt,
- IN ib_net64_t service_id,
- IN ib_net16_t service_pkey,
- IN ib_net32_t service_lease,
- IN uint8_t service_key_lsb, IN char *service_name)
-{
- osmv_query_req_t req;
- osmv_user_query_t user;
- osmtest_req_context_t context;
- ib_service_record_t svc_rec;
- osm_log_t *p_log = &p_osmt->log;
- ib_api_status_t status;
-
- OSM_LOG_ENTER(p_log);
-
- OSM_LOG(&p_osmt->log, OSM_LOG_INFO,
- "Registering service: name: %s id: 0x%" PRIx64 "\n",
- service_name, cl_ntoh64(service_id));
-
- memset(&req, 0, sizeof(req));
- memset(&context, 0, sizeof(context));
- memset(&user, 0, sizeof(user));
- memset(&svc_rec, 0, sizeof(svc_rec));
-
- /* set the new service record fields */
- svc_rec.service_id = service_id;
- svc_rec.service_pkey = service_pkey;
- svc_rec.service_gid.unicast.prefix = 0;
- svc_rec.service_gid.unicast.interface_id = p_osmt->local_port.port_guid;
- svc_rec.service_lease = service_lease;
- memset(&svc_rec.service_key, 0, 16 * sizeof(uint8_t));
- svc_rec.service_key[0] = service_key_lsb;
- memset(svc_rec.service_name, 0, sizeof(svc_rec.service_name));
- memcpy(svc_rec.service_name, service_name,
- (strlen(service_name) + 1) * sizeof(char));
-
- /* prepare the data used for this query */
- /* sa_mad_data.method = IB_MAD_METHOD_SET; */
- /* sa_mad_data.sm_key = 0; */
-
- context.p_osmt = p_osmt;
- req.query_context = &context;
- req.query_type = OSMV_QUERY_USER_DEFINED;
- req.pfn_query_cb = osmtest_query_res_cb;
- req.p_query_input = &user;
- req.flags = OSM_SA_FLAGS_SYNC;
- req.sm_key = 0;
- req.timeout_ms = p_osmt->opt.transaction_timeout;
-
- user.method = IB_MAD_METHOD_SET;
- user.attr_id = IB_MAD_ATTR_SERVICE_RECORD;
- if (ib_pkey_is_invalid(service_pkey)) {
- /* if given an invalid service_pkey - don't turn the PKEY compmask on */
- user.comp_mask = IB_SR_COMPMASK_SID |
- IB_SR_COMPMASK_SGID |
- IB_SR_COMPMASK_SLEASE |
- IB_SR_COMPMASK_SKEY | IB_SR_COMPMASK_SNAME;
- } else {
- user.comp_mask = IB_SR_COMPMASK_SID |
- IB_SR_COMPMASK_SGID |
- IB_SR_COMPMASK_SPKEY |
- IB_SR_COMPMASK_SLEASE |
- IB_SR_COMPMASK_SKEY | IB_SR_COMPMASK_SNAME;
- }
- user.attr_offset = ib_get_attr_offset(sizeof(ib_service_record_t));
- user.p_attr = &svc_rec;
-
- status = osmv_query_sa(p_osmt->h_bind, &req);
- if (status != IB_SUCCESS) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 4A01: "
- "ib_query failed (%s)\n", ib_get_err_str(status));
- goto Exit;
- }
-
- status = context.result.status;
-
- if (status != IB_SUCCESS) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 4A02: "
- "ib_query failed (%s)\n", ib_get_err_str(status));
-
- if (status == IB_REMOTE_ERROR) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR,
- "Remote error = %s\n",
- ib_get_mad_status_str(osm_madw_get_mad_ptr
- (context.result.
- p_result_madw)));
- }
- goto Exit;
- }
-
-Exit:
- if (context.result.p_result_madw != NULL) {
- osm_mad_pool_put(&p_osmt->mad_pool,
- context.result.p_result_madw);
- context.result.p_result_madw = NULL;
- }
-
- OSM_LOG_EXIT(&p_osmt->log);
- return status;
-}
-
-/**********************************************************************
- **********************************************************************/
-
-ib_api_status_t
-osmt_register_service_with_full_key(IN osmtest_t * const p_osmt,
- IN ib_net64_t service_id,
- IN ib_net16_t service_pkey,
- IN ib_net32_t service_lease,
- IN uint8_t * service_key,
- IN char *service_name)
-{
- osmv_query_req_t req;
- osmv_user_query_t user;
- osmtest_req_context_t context;
- ib_service_record_t svc_rec, *p_rec;
- osm_log_t *p_log = &p_osmt->log;
- ib_api_status_t status;
- uint8_t i, skey[16];
-
- OSM_LOG_ENTER(p_log);
-
- OSM_LOG(&p_osmt->log, OSM_LOG_INFO,
- "Registering service: name: %s id: 0x%" PRIx64 "\n",
- service_name, cl_ntoh64(service_id));
-
- memset(&req, 0, sizeof(req));
- memset(&context, 0, sizeof(context));
- memset(&user, 0, sizeof(user));
- memset(&svc_rec, 0, sizeof(svc_rec));
-
- /* set the new service record fields */
- svc_rec.service_id = service_id;
- svc_rec.service_pkey = service_pkey;
- svc_rec.service_gid.unicast.prefix = 0;
- svc_rec.service_gid.unicast.interface_id = p_osmt->local_port.port_guid;
- svc_rec.service_lease = service_lease;
- memset(&svc_rec.service_key, 0, 16 * sizeof(uint8_t));
- memcpy(svc_rec.service_key, service_key, 16 * sizeof(uint8_t));
- memset(svc_rec.service_name, 0, sizeof(svc_rec.service_name));
- memset(skey, 0, 16 * sizeof(uint8_t));
- memcpy(svc_rec.service_name, service_name,
- (strlen(service_name) + 1) * sizeof(char));
-
- /* prepare the data used for this query */
- /* sa_mad_data.method = IB_MAD_METHOD_SET; */
- /* sa_mad_data.sm_key = 0; */
-
- context.p_osmt = p_osmt;
- req.query_context = &context;
- req.query_type = OSMV_QUERY_USER_DEFINED;
- req.pfn_query_cb = osmtest_query_res_cb;
- req.p_query_input = &user;
- req.flags = OSM_SA_FLAGS_SYNC;
- req.sm_key = 0;
- req.timeout_ms = p_osmt->opt.transaction_timeout;
-
- user.method = IB_MAD_METHOD_SET;
- user.attr_id = IB_MAD_ATTR_SERVICE_RECORD;
- if (ib_pkey_is_invalid(service_pkey)) {
- /* if given an invalid service_pkey - don't turn the PKEY compmask on */
- user.comp_mask = IB_SR_COMPMASK_SID |
- IB_SR_COMPMASK_SGID |
- IB_SR_COMPMASK_SLEASE |
- IB_SR_COMPMASK_SKEY | IB_SR_COMPMASK_SNAME;
- } else {
- user.comp_mask = IB_SR_COMPMASK_SID |
- IB_SR_COMPMASK_SGID |
- IB_SR_COMPMASK_SPKEY |
- IB_SR_COMPMASK_SLEASE |
- IB_SR_COMPMASK_SKEY | IB_SR_COMPMASK_SNAME;
- }
- user.attr_offset = ib_get_attr_offset(sizeof(ib_service_record_t));
- user.p_attr = &svc_rec;
-
- status = osmv_query_sa(p_osmt->h_bind, &req);
- if (status != IB_SUCCESS) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 4A03: "
- "ib_query failed (%s)\n", ib_get_err_str(status));
- goto Exit;
- }
-
- status = context.result.status;
- if (status != IB_SUCCESS) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 4A04: "
- "ib_query failed (%s)\n", ib_get_err_str(status));
-
- if (status == IB_REMOTE_ERROR) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR,
- "Remote error = %s\n",
- ib_get_mad_status_str(osm_madw_get_mad_ptr
- (context.result.
- p_result_madw)));
- }
- goto Exit;
- }
-
- /* Check service key on context to see if match */
- p_rec = osmv_get_query_svc_rec(context.result.p_result_madw, 0);
- OSM_LOG(&p_osmt->log, OSM_LOG_VERBOSE,
- "Comparing service key...\n" "return key is:\n");
- for (i = 0; i <= 15; i++) {
- OSM_LOG(&p_osmt->log, OSM_LOG_VERBOSE,
- "service_key sent[%u] = %u, service_key returned[%u] = %u\n",
- i, service_key[i], i, p_rec->service_key[i]);
- }
- /* since c15-0.1.14 not supported all key association queries should bring in return zero in service key */
- if (memcmp(skey, p_rec->service_key, 16 * sizeof(uint8_t)) != 0) {
- status = IB_REMOTE_ERROR;
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 4A33: "
- "Data mismatch in service_key\n");
- goto Exit;
- }
-
-Exit:
- if (context.result.p_result_madw != NULL) {
- osm_mad_pool_put(&p_osmt->mad_pool,
- context.result.p_result_madw);
- context.result.p_result_madw = NULL;
- }
-
- OSM_LOG_EXIT(&p_osmt->log);
- return status;
-}
-
-/**********************************************************************
- **********************************************************************/
-
-ib_api_status_t
-osmt_register_service_with_data(IN osmtest_t * const p_osmt,
- IN ib_net64_t service_id,
- IN ib_net16_t service_pkey,
- IN ib_net32_t service_lease,
- IN uint8_t service_key_lsb,
- IN uint8_t * service_data8,
- IN ib_net16_t * service_data16,
- IN ib_net32_t * service_data32,
- IN ib_net64_t * service_data64,
- IN char *service_name)
-{
- osmv_query_req_t req;
- osmv_user_query_t user;
- osmtest_req_context_t context;
- ib_service_record_t svc_rec, *p_rec;
- osm_log_t *p_log = &p_osmt->log;
- ib_api_status_t status;
- /* ib_service_record_t* p_rec; */
-
- OSM_LOG_ENTER(p_log);
-
- OSM_LOG(&p_osmt->log, OSM_LOG_INFO,
- "Registering service: name: %s id: 0x%" PRIx64 "\n",
- service_name, cl_ntoh64(service_id));
-
- memset(&req, 0, sizeof(req));
- memset(&context, 0, sizeof(context));
- memset(&user, 0, sizeof(user));
- memset(&svc_rec, 0, sizeof(svc_rec));
-
- /* set the new service record fields */
- svc_rec.service_id = service_id;
- svc_rec.service_pkey = service_pkey;
- svc_rec.service_gid.unicast.prefix = 0;
- svc_rec.service_gid.unicast.interface_id = p_osmt->local_port.port_guid;
- svc_rec.service_lease = service_lease;
- memset(&svc_rec.service_key, 0, 16 * sizeof(uint8_t));
- svc_rec.service_key[0] = service_key_lsb;
-
- /* Copy data to service_data arrays */
- memcpy(svc_rec.service_data8, service_data8, 16 * sizeof(uint8_t));
- memcpy(svc_rec.service_data16, service_data16, 8 * sizeof(ib_net16_t));
- memcpy(svc_rec.service_data32, service_data32, 4 * sizeof(ib_net32_t));
- memcpy(svc_rec.service_data64, service_data64, 2 * sizeof(ib_net64_t));
-
- memset(svc_rec.service_name, 0, sizeof(svc_rec.service_name));
- memcpy(svc_rec.service_name, service_name,
- (strlen(service_name) + 1) * sizeof(char));
-
- /* prepare the data used for this query */
- /* sa_mad_data.method = IB_MAD_METHOD_SET; */
- /* sa_mad_data.sm_key = 0; */
-
- context.p_osmt = p_osmt;
- req.query_context = &context;
- req.query_type = OSMV_QUERY_USER_DEFINED;
- req.pfn_query_cb = osmtest_query_res_cb;
- req.p_query_input = &user;
- req.flags = OSM_SA_FLAGS_SYNC;
- req.sm_key = 0;
- req.timeout_ms = p_osmt->opt.transaction_timeout;
-
- user.method = IB_MAD_METHOD_SET;
- user.attr_id = IB_MAD_ATTR_SERVICE_RECORD;
- if (ib_pkey_is_invalid(service_pkey)) {
- /* if given an invalid service_pkey - don't turn the PKEY compmask on */
- user.comp_mask = IB_SR_COMPMASK_SID |
- IB_SR_COMPMASK_SGID |
- IB_SR_COMPMASK_SLEASE |
- IB_SR_COMPMASK_SKEY |
- IB_SR_COMPMASK_SNAME |
- IB_SR_COMPMASK_SDATA8_0 |
- IB_SR_COMPMASK_SDATA8_1 |
- IB_SR_COMPMASK_SDATA16_0 |
- IB_SR_COMPMASK_SDATA16_1 |
- IB_SR_COMPMASK_SDATA32_0 |
- IB_SR_COMPMASK_SDATA32_1 |
- IB_SR_COMPMASK_SDATA64_0 | IB_SR_COMPMASK_SDATA64_1;
- } else {
- user.comp_mask = IB_SR_COMPMASK_SID |
- IB_SR_COMPMASK_SGID |
- IB_SR_COMPMASK_SPKEY |
- IB_SR_COMPMASK_SLEASE |
- IB_SR_COMPMASK_SKEY |
- IB_SR_COMPMASK_SNAME |
- IB_SR_COMPMASK_SDATA8_0 |
- IB_SR_COMPMASK_SDATA8_1 |
- IB_SR_COMPMASK_SDATA16_0 |
- IB_SR_COMPMASK_SDATA16_1 |
- IB_SR_COMPMASK_SDATA32_0 |
- IB_SR_COMPMASK_SDATA32_1 |
- IB_SR_COMPMASK_SDATA64_0 | IB_SR_COMPMASK_SDATA64_1;
- }
- user.attr_offset = ib_get_attr_offset(sizeof(ib_service_record_t));
- user.p_attr = &svc_rec;
-
- /* Dump to Service Data b4 send */
- OSM_LOG(&p_osmt->log, OSM_LOG_VERBOSE,
- "Dumping service data b4 send\n");
- osm_dump_service_record(&p_osmt->log, &svc_rec, OSM_LOG_VERBOSE);
-
- status = osmv_query_sa(p_osmt->h_bind, &req);
- if (status != IB_SUCCESS) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 4A05: "
- "ib_query failed (%s)\n", ib_get_err_str(status));
- goto Exit;
- }
-
- status = context.result.status;
-
- if (status != IB_SUCCESS) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 4A06: "
- "ib_query failed (%s)\n", ib_get_err_str(status));
-
- if (status == IB_REMOTE_ERROR) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR,
- "Remote error = %s\n",
- ib_get_mad_status_str(osm_madw_get_mad_ptr
- (context.result.
- p_result_madw)));
- }
- goto Exit;
- }
-
- /* Check data on context to see if match */
- p_rec = osmv_get_query_svc_rec(context.result.p_result_madw, 0);
- OSM_LOG(&p_osmt->log, OSM_LOG_VERBOSE, "Comparing service data...\n");
- if (memcmp(service_data8, p_rec->service_data8, 16 * sizeof(uint8_t)) !=
- 0
- || memcmp(service_data16, p_rec->service_data16,
- 8 * sizeof(uint16_t)) != 0
- || memcmp(service_data32, p_rec->service_data32,
- 4 * sizeof(uint32_t)) != 0
- || memcmp(service_data64, p_rec->service_data64,
- 2 * sizeof(uint64_t)) != 0) {
- status = IB_REMOTE_ERROR;
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR,
- "Data mismatch in service_data8\n");
- goto Exit;
- }
-
-Exit:
- if (context.result.p_result_madw != NULL) {
- osm_mad_pool_put(&p_osmt->mad_pool,
- context.result.p_result_madw);
- context.result.p_result_madw = NULL;
- }
-
- OSM_LOG_EXIT(&p_osmt->log);
- return status;
-}
-
-/**********************************************************************
- **********************************************************************/
-
-ib_api_status_t
-osmt_get_service_by_id_and_name(IN osmtest_t * const p_osmt,
- IN uint32_t rec_num,
- IN ib_net64_t sid,
- IN char *sr_name,
- OUT ib_service_record_t * p_out_rec)
-{
-
- ib_api_status_t status = IB_SUCCESS;
- osmtest_req_context_t context;
- osmv_query_req_t req;
- ib_service_record_t svc_rec, *p_rec;
- uint32_t num_recs = 0;
- osmv_user_query_t user;
-
- OSM_LOG_ENTER(&p_osmt->log);
-
- OSM_LOG(&p_osmt->log, OSM_LOG_VERBOSE,
- "Getting service record: id: 0x%016" PRIx64
- " and name: %s\n", cl_ntoh64(sid), sr_name);
-
- /*
- * Do a blocking query for this record in the subnet.
- * The result is returned in the result field of the caller's
- * context structure.
- *
- * The query structures are locals.
- */
- memset(&req, 0, sizeof(req));
- memset(&context, 0, sizeof(context));
-
- context.p_osmt = p_osmt;
-
- /* prepare the data used for this query */
- req.query_type = OSMV_QUERY_USER_DEFINED;
- req.timeout_ms = p_osmt->opt.transaction_timeout;
- req.retry_cnt = p_osmt->opt.retry_count;
- req.flags = OSM_SA_FLAGS_SYNC;
- req.query_context = &context;
- req.pfn_query_cb = osmtest_query_res_cb;
- req.sm_key = 0;
-
- memset(&svc_rec, 0, sizeof(svc_rec));
- memset(&user, 0, sizeof(user));
- /* set the new service record fields */
- memset(svc_rec.service_name, 0, sizeof(svc_rec.service_name));
- memcpy(svc_rec.service_name, sr_name,
- (strlen(sr_name) + 1) * sizeof(char));
- svc_rec.service_id = sid;
- req.p_query_input = &user;
-
- user.method = IB_MAD_METHOD_GET;
- user.attr_id = IB_MAD_ATTR_SERVICE_RECORD;
- user.comp_mask = IB_SR_COMPMASK_SID | IB_SR_COMPMASK_SNAME;
- user.attr_offset = ib_get_attr_offset(sizeof(ib_service_record_t));
- user.p_attr = &svc_rec;
-
- status = osmv_query_sa(p_osmt->h_bind, &req);
- if (status != IB_SUCCESS) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 4A07: "
- "ib_query failed (%s)\n", ib_get_err_str(status));
- goto Exit;
- }
-
- status = context.result.status;
- num_recs = context.result.result_cnt;
-
- if (status != IB_SUCCESS) {
- char mad_stat_err[256];
-
- /* If the failure is due to IB_SA_MAD_STATUS_NO_RECORDS and rec_num is 0,
- then this is fine */
- if (status == IB_REMOTE_ERROR)
- strcpy(mad_stat_err,
- ib_get_mad_status_str(osm_madw_get_mad_ptr
- (context.result.
- p_result_madw)));
- else
- strcpy(mad_stat_err, ib_get_err_str(status));
- if (status == IB_REMOTE_ERROR &&
- !strcmp(mad_stat_err, "IB_SA_MAD_STATUS_NO_RECORDS") &&
- rec_num == 0) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR,
- "IS EXPECTED ERROR ^^^^\n");
- status = IB_SUCCESS;
- } else {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 4A08: "
- "Query failed: %s (%s)\n",
- ib_get_err_str(status), mad_stat_err);
- goto Exit;
- }
- }
-
- if (rec_num && num_recs != rec_num) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR,
- "Unmatched number of records: expected: %d, received: %d\n",
- rec_num, num_recs);
- status = IB_REMOTE_ERROR;
- goto Exit;
- }
-
- p_rec = osmv_get_query_svc_rec(context.result.p_result_madw, 0);
- *p_out_rec = *p_rec;
-
- if (num_recs) {
- OSM_LOG(&p_osmt->log, OSM_LOG_VERBOSE,
- "Found service record: name: %s id: 0x%016" PRIx64 "\n",
- p_rec->service_name, cl_ntoh64(p_rec->service_id));
-
- osm_dump_service_record(&p_osmt->log, p_rec, OSM_LOG_DEBUG);
- }
-
-Exit:
- OSM_LOG(&p_osmt->log, OSM_LOG_VERBOSE,
- "Expected and found %d records\n", rec_num);
-
- if (context.result.p_result_madw != NULL) {
- osm_mad_pool_put(&p_osmt->mad_pool,
- context.result.p_result_madw);
- context.result.p_result_madw = NULL;
- }
-
- OSM_LOG_EXIT(&p_osmt->log);
- return status;
-}
-
-/**********************************************************************
- **********************************************************************/
-
-ib_api_status_t
-osmt_get_service_by_id(IN osmtest_t * const p_osmt,
- IN uint32_t rec_num,
- IN ib_net64_t sid, OUT ib_service_record_t * p_out_rec)
-{
-
- ib_api_status_t status = IB_SUCCESS;
- osmtest_req_context_t context;
- osmv_query_req_t req;
- ib_service_record_t svc_rec, *p_rec;
- uint32_t num_recs = 0;
- osmv_user_query_t user;
-
- OSM_LOG_ENTER(&p_osmt->log);
-
- OSM_LOG(&p_osmt->log, OSM_LOG_VERBOSE,
- "Getting service record: id: 0x%016" PRIx64 "\n",
- cl_ntoh64(sid));
-
- /*
- * Do a blocking query for this record in the subnet.
- * The result is returned in the result field of the caller's
- * context structure.
- *
- * The query structures are locals.
- */
- memset(&req, 0, sizeof(req));
- memset(&context, 0, sizeof(context));
-
- context.p_osmt = p_osmt;
-
- /* prepare the data used for this query */
- req.query_type = OSMV_QUERY_USER_DEFINED;
- req.timeout_ms = p_osmt->opt.transaction_timeout;
- req.retry_cnt = p_osmt->opt.retry_count;
- req.flags = OSM_SA_FLAGS_SYNC;
- req.query_context = &context;
- req.pfn_query_cb = osmtest_query_res_cb;
- req.sm_key = 0;
-
- memset(&svc_rec, 0, sizeof(svc_rec));
- memset(&user, 0, sizeof(user));
- /* set the new service record fields */
- svc_rec.service_id = sid;
- req.p_query_input = &user;
-
- user.method = IB_MAD_METHOD_GET;
- user.attr_id = IB_MAD_ATTR_SERVICE_RECORD;
- user.comp_mask = IB_SR_COMPMASK_SID;
- user.attr_offset = ib_get_attr_offset(sizeof(ib_service_record_t));
- user.p_attr = &svc_rec;
-
- status = osmv_query_sa(p_osmt->h_bind, &req);
- if (status != IB_SUCCESS) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 4A09: "
- "ib_query failed (%s)\n", ib_get_err_str(status));
- goto Exit;
- }
-
- status = context.result.status;
- num_recs = context.result.result_cnt;
-
- if (status != IB_SUCCESS) {
- char mad_stat_err[256];
-
- /* If the failure is due to IB_SA_MAD_STATUS_NO_RECORDS and rec_num is 0,
- then this is fine */
- if (status == IB_REMOTE_ERROR)
- strcpy(mad_stat_err,
- ib_get_mad_status_str(osm_madw_get_mad_ptr
- (context.result.
- p_result_madw)));
- else
- strcpy(mad_stat_err, ib_get_err_str(status));
-
- if (status == IB_REMOTE_ERROR &&
- !strcmp(mad_stat_err, "IB_SA_MAD_STATUS_NO_RECORDS") &&
- rec_num == 0) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR,
- "IS EXPECTED ERROR ^^^^\n");
- status = IB_SUCCESS;
- } else {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 4A0A: "
- "Query failed: %s (%s)\n",
- ib_get_err_str(status), mad_stat_err);
- goto Exit;
- }
- }
-
- if (rec_num && num_recs != rec_num) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 4A0B: "
- "Unmatched number of records: expected: %d received: %d\n",
- rec_num, num_recs);
- status = IB_REMOTE_ERROR;
- goto Exit;
- }
-
- p_rec = osmv_get_query_svc_rec(context.result.p_result_madw, 0);
- *p_out_rec = *p_rec;
-
- if (num_recs) {
- OSM_LOG(&p_osmt->log, OSM_LOG_VERBOSE,
- "Found service record: name: %s id: 0x%016" PRIx64 "\n",
- p_rec->service_name, cl_ntoh64(p_rec->service_id));
-
- osm_dump_service_record(&p_osmt->log, p_rec, OSM_LOG_DEBUG);
- }
-
-Exit:
- OSM_LOG(&p_osmt->log, OSM_LOG_VERBOSE,
- "Expected and found %d records\n", rec_num);
-
- if (context.result.p_result_madw != NULL) {
- osm_mad_pool_put(&p_osmt->mad_pool,
- context.result.p_result_madw);
- context.result.p_result_madw = NULL;
- }
-
- OSM_LOG_EXIT(&p_osmt->log);
- return status;
-}
-
-/**********************************************************************
- **********************************************************************/
-
-ib_api_status_t
-osmt_get_service_by_name_and_key(IN osmtest_t * const p_osmt,
- IN char *sr_name,
- IN uint32_t rec_num,
- IN uint8_t * skey,
- OUT ib_service_record_t * p_out_rec)
-{
-
- ib_api_status_t status = IB_SUCCESS;
- osmtest_req_context_t context;
- osmv_query_req_t req;
- ib_service_record_t svc_rec, *p_rec;
- uint32_t num_recs = 0, i;
- osmv_user_query_t user;
-
- OSM_LOG_ENTER(&p_osmt->log);
-
- OSM_LOG(&p_osmt->log, OSM_LOG_VERBOSE,
- "Getting service record: name: %s and key: "
- "0x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x\n",
- sr_name, skey[0], skey[1], skey[2], skey[3], skey[4], skey[5],
- skey[6], skey[7], skey[8], skey[9], skey[10], skey[11],
- skey[12], skey[13], skey[14], skey[15]);
-
- /*
- * Do a blocking query for this record in the subnet.
- * The result is returned in the result field of the caller's
- * context structure.
- *
- * The query structures are locals.
- */
- memset(&req, 0, sizeof(req));
- memset(&context, 0, sizeof(context));
-
- context.p_osmt = p_osmt;
-
- /* prepare the data used for this query */
- req.query_type = OSMV_QUERY_USER_DEFINED;
- req.timeout_ms = p_osmt->opt.transaction_timeout;
- req.retry_cnt = p_osmt->opt.retry_count;
- req.flags = OSM_SA_FLAGS_SYNC;
- req.query_context = &context;
- req.pfn_query_cb = osmtest_query_res_cb;
- req.sm_key = 0;
-
- memset(&svc_rec, 0, sizeof(svc_rec));
- memset(&user, 0, sizeof(user));
- /* set the new service record fields */
- memset(svc_rec.service_name, 0, sizeof(svc_rec.service_name));
- memcpy(svc_rec.service_name, sr_name,
- (strlen(sr_name) + 1) * sizeof(char));
- for (i = 0; i <= 15; i++)
- svc_rec.service_key[i] = skey[i];
-
- req.p_query_input = &user;
-
- user.method = IB_MAD_METHOD_GET;
- user.attr_id = IB_MAD_ATTR_SERVICE_RECORD;
- user.comp_mask = IB_SR_COMPMASK_SNAME | IB_SR_COMPMASK_SKEY;
- user.attr_offset = ib_get_attr_offset(sizeof(ib_service_record_t));
- user.p_attr = &svc_rec;
- status = osmv_query_sa(p_osmt->h_bind, &req);
- if (status != IB_SUCCESS) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 4A0C: "
- "ib_query failed (%s)\n", ib_get_err_str(status));
- goto Exit;
- }
-
- status = context.result.status;
- num_recs = context.result.result_cnt;
-
- if (status != IB_SUCCESS) {
- char mad_stat_err[256];
-
- /* If the failure is due to IB_SA_MAD_STATUS_NO_RECORDS and rec_num is 0,
- then this is fine */
- if (status == IB_REMOTE_ERROR)
- strcpy(mad_stat_err,
- ib_get_mad_status_str(osm_madw_get_mad_ptr
- (context.result.
- p_result_madw)));
- else
- strcpy(mad_stat_err, ib_get_err_str(status));
-
- if (status == IB_REMOTE_ERROR &&
- !strcmp(mad_stat_err, "IB_SA_MAD_STATUS_NO_RECORDS") &&
- rec_num == 0) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR,
- "IS EXPECTED ERROR ^^^^\n");
- status = IB_SUCCESS;
- } else {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 4A0D: "
- "Query failed:%s (%s)\n",
- ib_get_err_str(status), mad_stat_err);
- goto Exit;
- }
- }
-
- if (rec_num && num_recs != rec_num) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR,
- "Unmatched number of records: expected: %d, received: %d\n",
- rec_num, num_recs);
- status = IB_REMOTE_ERROR;
- goto Exit;
- }
-
- p_rec = osmv_get_query_svc_rec(context.result.p_result_madw, 0);
- *p_out_rec = *p_rec;
-
- if (num_recs) {
- OSM_LOG(&p_osmt->log, OSM_LOG_VERBOSE,
- "Found service record: name: %s id: 0x%016" PRIx64 "\n",
- sr_name, cl_ntoh64(p_rec->service_id));
-
- osm_dump_service_record(&p_osmt->log, p_rec, OSM_LOG_DEBUG);
- }
-
-Exit:
- OSM_LOG(&p_osmt->log, OSM_LOG_VERBOSE,
- "Expected and found %d records\n", rec_num);
-
- if (context.result.p_result_madw != NULL) {
- osm_mad_pool_put(&p_osmt->mad_pool,
- context.result.p_result_madw);
- context.result.p_result_madw = NULL;
- }
-
- OSM_LOG_EXIT(&p_osmt->log);
- return status;
-}
-
-/**********************************************************************
- **********************************************************************/
-
-ib_api_status_t
-osmt_get_service_by_name(IN osmtest_t * const p_osmt,
- IN char *sr_name,
- IN uint32_t rec_num,
- OUT ib_service_record_t * p_out_rec)
-{
-
- ib_api_status_t status = IB_SUCCESS;
- osmtest_req_context_t context;
- osmv_query_req_t req;
- ib_service_record_t *p_rec;
- ib_svc_name_t service_name;
- uint32_t num_recs = 0;
-
- OSM_LOG_ENTER(&p_osmt->log);
-
- OSM_LOG(&p_osmt->log, OSM_LOG_VERBOSE,
- "Getting service record: name: %s\n", sr_name);
-
- /*
- * Do a blocking query for this record in the subnet.
- * The result is returned in the result field of the caller's
- * context structure.
- *
- * The query structures are locals.
- */
- memset(&req, 0, sizeof(req));
- memset(&context, 0, sizeof(context));
-
- context.p_osmt = p_osmt;
-
- /* prepare the data used for this query */
- req.query_type = OSMV_QUERY_SVC_REC_BY_NAME;
- req.timeout_ms = p_osmt->opt.transaction_timeout;
- req.retry_cnt = p_osmt->opt.retry_count;
- req.flags = OSM_SA_FLAGS_SYNC;
- req.query_context = &context;
- req.pfn_query_cb = osmtest_query_res_cb;
- req.sm_key = 0;
-
- memset(service_name, 0, sizeof(service_name));
- memcpy(service_name, sr_name, (strlen(sr_name) + 1) * sizeof(char));
- req.p_query_input = service_name;
-
- status = osmv_query_sa(p_osmt->h_bind, &req);
- if (status != IB_SUCCESS) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 4A0E: "
- "ib_query failed (%s)\n", ib_get_err_str(status));
- goto Exit;
- }
-
- status = context.result.status;
- num_recs = context.result.result_cnt;
-
- if (status != IB_SUCCESS) {
- char mad_stat_err[256];
-
- /* If the failure is due to IB_SA_MAD_STATUS_NO_RECORDS and rec_num is 0,
- then this is fine */
- if (status == IB_REMOTE_ERROR)
- strcpy(mad_stat_err,
- ib_get_mad_status_str(osm_madw_get_mad_ptr
- (context.result.
- p_result_madw)));
- else
- strcpy(mad_stat_err, ib_get_err_str(status));
-
- if (status == IB_REMOTE_ERROR &&
- !strcmp(mad_stat_err, "IB_SA_MAD_STATUS_NO_RECORDS") &&
- rec_num == 0) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR,
- "IS EXPECTED ERROR ^^^^\n");
- status = IB_SUCCESS;
- } else {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 4A0F: "
- "Query failed: %s (%s)\n",
- ib_get_err_str(status), mad_stat_err);
- goto Exit;
- }
- }
-
- if (rec_num && num_recs != rec_num) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 4A10: "
- "Unmatched number of records: expected: %d, received: %d\n",
- rec_num, num_recs);
- status = IB_REMOTE_ERROR;
- goto Exit;
- }
-
- p_rec = osmv_get_query_svc_rec(context.result.p_result_madw, 0);
- *p_out_rec = *p_rec;
-
- if (num_recs) {
- OSM_LOG(&p_osmt->log, OSM_LOG_VERBOSE,
- "Found service record: name: %s id: 0x%016" PRIx64 "\n",
- sr_name, cl_ntoh64(p_rec->service_id));
-
- osm_dump_service_record(&p_osmt->log, p_rec, OSM_LOG_DEBUG);
- }
-
-Exit:
- OSM_LOG(&p_osmt->log, OSM_LOG_VERBOSE,
- "Expected and found %d records\n", rec_num);
-
- if (context.result.p_result_madw != NULL) {
- osm_mad_pool_put(&p_osmt->mad_pool,
- context.result.p_result_madw);
- context.result.p_result_madw = NULL;
- }
-
- OSM_LOG_EXIT(&p_osmt->log);
- return status;
-}
-
-/**********************************************************************
- **********************************************************************/
-
-#ifdef VENDOR_RMPP_SUPPORT
-ib_api_status_t
-osmt_get_all_services_and_check_names(IN osmtest_t * const p_osmt,
- IN ib_svc_name_t *
- const p_valid_service_names_arr,
- IN uint8_t num_of_valid_names,
- OUT uint32_t * num_services)
-{
- ib_api_status_t status = IB_SUCCESS;
- osmtest_req_context_t context;
- osmv_query_req_t req;
- ib_service_record_t *p_rec;
- uint32_t num_recs = 0, i, j;
- uint8_t *p_checked_names;
-
- OSM_LOG_ENTER(&p_osmt->log);
-
- /* Prepare tracker for the checked names */
- p_checked_names =
- (uint8_t *) malloc(sizeof(uint8_t) * num_of_valid_names);
- for (j = 0; j < num_of_valid_names; j++) {
- p_checked_names[j] = 0;
- }
-
- OSM_LOG(&p_osmt->log, OSM_LOG_VERBOSE, "Getting all service records\n");
-
- /*
- * Do a blocking query for this record in the subnet.
- * The result is returned in the result field of the caller's
- * context structure.
- *
- * The query structures are locals.
- */
- memset(&req, 0, sizeof(req));
- memset(&context, 0, sizeof(context));
-
- context.p_osmt = p_osmt;
-
- req.query_type = OSMV_QUERY_ALL_SVC_RECS;
- req.timeout_ms = p_osmt->opt.transaction_timeout;
- req.retry_cnt = p_osmt->opt.retry_count;
- req.flags = OSM_SA_FLAGS_SYNC;
- req.query_context = &context;
- req.pfn_query_cb = osmtest_query_res_cb;
- req.sm_key = 0;
-
- status = osmv_query_sa(p_osmt->h_bind, &req);
- if (status != IB_SUCCESS) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 4A12: "
- "ib_query failed (%s)\n", ib_get_err_str(status));
- goto Exit;
- }
-
- status = context.result.status;
-
- if (status != IB_SUCCESS) {
- if (status != IB_INVALID_PARAMETER) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 4A13: "
- "ib_query failed (%s)\n", ib_get_err_str(status));
- }
- if (status == IB_REMOTE_ERROR) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR,
- "Remote error = %s\n",
- ib_get_mad_status_str(osm_madw_get_mad_ptr
- (context.result.
- p_result_madw)));
- }
- goto Exit;
- }
-
- num_recs = context.result.result_cnt;
- OSM_LOG(&p_osmt->log, OSM_LOG_VERBOSE,
- "Received %u records\n", num_recs);
-
- for (i = 0; i < num_recs; i++) {
- p_rec = osmv_get_query_svc_rec(context.result.p_result_madw, i);
- OSM_LOG(&p_osmt->log, OSM_LOG_VERBOSE,
- "Found service record: name: %s id: 0x%016" PRIx64 "\n",
- p_rec->service_name, cl_ntoh64(p_rec->service_id));
- osm_dump_service_record(&p_osmt->log, p_rec, OSM_LOG_VERBOSE);
- for (j = 0; j < num_of_valid_names; j++) {
- /* If the service names exist in the record, mark it as checked (1) */
- OSM_LOG(&p_osmt->log, OSM_LOG_VERBOSE,
- "-I- Comparing source name : >%s<, with record name : >%s<, idx : %d\n",
- p_valid_service_names_arr[j],
- p_rec->service_name, p_checked_names[j]);
- if (strcmp
- ((char *)p_valid_service_names_arr[j],
- (char *)p_rec->service_name) == 0) {
- OSM_LOG(&p_osmt->log, OSM_LOG_VERBOSE,
- "-I- The service %s is valid\n",
- p_valid_service_names_arr[j]);
- p_checked_names[j] = 1;
- break;
- }
- }
- }
- /* Check that all service names have been identified */
- for (j = 0; j < num_of_valid_names; j++)
- if (p_checked_names[j] == 0) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 4A14: "
- "Missing valid service: name: %s\n",
- p_valid_service_names_arr[j]);
- status = IB_ERROR;
- goto Exit;
- }
- *num_services = num_recs;
-
-Exit:
- if (context.result.p_result_madw != NULL) {
- osm_mad_pool_put(&p_osmt->mad_pool,
- context.result.p_result_madw);
- context.result.p_result_madw = NULL;
- }
-
- OSM_LOG_EXIT(&p_osmt->log);
- return status;
-}
-#endif
-
-/**********************************************************************
- **********************************************************************/
-
-ib_api_status_t
-osmt_delete_service_by_name(IN osmtest_t * const p_osmt,
- IN uint8_t IsServiceExist,
- IN char *sr_name, IN uint32_t rec_num)
-{
- osmv_query_req_t req;
- osmv_user_query_t user;
- osmtest_req_context_t context;
- ib_service_record_t svc_rec;
- ib_api_status_t status;
-
- OSM_LOG_ENTER(&p_osmt->log);
-
- OSM_LOG(&p_osmt->log, OSM_LOG_INFO,
- "Trying to Delete service name: %s\n", sr_name);
-
- memset(&svc_rec, 0, sizeof(svc_rec));
-
- status = osmt_get_service_by_name(p_osmt, sr_name, rec_num, &svc_rec);
- if (status != IB_SUCCESS) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 4A15: "
- "Failed to get service: name: %s\n", sr_name);
- goto ExitNoDel;
- }
-
- memset(&req, 0, sizeof(req));
- memset(&context, 0, sizeof(context));
- memset(&user, 0, sizeof(user));
-
- /* set the new service record fields */
- memset(svc_rec.service_name, 0, sizeof(svc_rec.service_name));
- memcpy(svc_rec.service_name, sr_name,
- (strlen(sr_name) + 1) * sizeof(char));
-
- /* prepare the data used for this query */
- context.p_osmt = p_osmt;
- req.timeout_ms = p_osmt->opt.transaction_timeout;
- req.query_context = &context;
- req.query_type = OSMV_QUERY_USER_DEFINED; /* basically a don't care here */
- req.pfn_query_cb = osmtest_query_res_cb;
- req.p_query_input = &user;
- req.flags = OSM_SA_FLAGS_SYNC;
- req.sm_key = 0;
-
- user.method = IB_MAD_METHOD_DELETE;
- user.attr_id = IB_MAD_ATTR_SERVICE_RECORD;
- user.comp_mask = IB_SR_COMPMASK_SNAME;
- user.attr_offset = ib_get_attr_offset(sizeof(ib_service_record_t));
- user.p_attr = &svc_rec;
-
- status = osmv_query_sa(p_osmt->h_bind, &req);
- if (status != IB_SUCCESS) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 4A16: "
- "ib_query failed (%s)\n", ib_get_err_str(status));
- goto Exit;
- }
-
- status = context.result.status;
- if (IsServiceExist) {
- /* If IsServiceExist = 1 then we should succeed here */
- if (status != IB_SUCCESS) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 4A17: "
- "ib_query failed (%s)\n",
- ib_get_err_str(status));
-
- if (status == IB_REMOTE_ERROR) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR,
- "ERR 4A18: Remote error = %s\n",
- ib_get_mad_status_str
- (osm_madw_get_mad_ptr
- (context.result.p_result_madw)));
- }
- }
- } else {
- /* If IsServiceExist = 0 then we should fail here */
- if (status == IB_SUCCESS) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 4A19: "
- "Succeeded to delete service: %s which "
- "shouldn't exist", sr_name);
- status = IB_ERROR;
- } else {
- /* The deletion should have failed, since the service_name
- shouldn't exist. */
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR,
- "IS EXPECTED ERROR ^^^^\n");
- OSM_LOG(&p_osmt->log, OSM_LOG_INFO,
- "Failed to delete service_name: %s\n", sr_name);
- status = IB_SUCCESS;
- }
- }
-
-Exit:
- if (context.result.p_result_madw != NULL) {
- osm_mad_pool_put(&p_osmt->mad_pool,
- context.result.p_result_madw);
- context.result.p_result_madw = NULL;
- }
-
-ExitNoDel:
- OSM_LOG_EXIT(&p_osmt->log);
- return status;
-}
-
-/**********************************************************************
- **********************************************************************/
-
-/*
- * Run a complete service records flow:
- * - register a service
- * - register a service (with a lease period)
- * - get a service by name
- * - get all services / must be 2
- * - delete a service
- * - get all services / must be 1
- * - wait for the lease to expire
- * - get all services / must be 0
- * - get / set service by data
- */
-ib_api_status_t osmt_run_service_records_flow(IN osmtest_t * const p_osmt)
-{
- ib_service_record_t srv_rec;
- ib_api_status_t status;
- uint8_t instance, i;
- uint8_t service_data8[16], service_key[16];
- ib_net16_t service_data16[8];
- ib_net32_t service_data32[4];
- ib_net64_t service_data64[2];
- uint64_t pid = getpid();
- uint64_t id[7];
- /* We use up to seven service names - we use the extra for bad flow */
- ib_svc_name_t service_name[7];
-#ifdef VENDOR_RMPP_SUPPORT
- /* This array contain only the valid names after registering vs SM */
- ib_svc_name_t service_valid_names[3];
- uint32_t num_recs = 0;
-#endif
-
- OSM_LOG_ENTER(&p_osmt->log);
-
- /* Init Service names */
- for (i = 0; i < 7; i++) {
-#ifdef __WIN__
- uint64_t rand_val = rand() - (uint64_t) i;
-#else
- uint64_t rand_val = random() - (uint64_t) i;
-#endif
- id[i] = abs((int)(pid - rand_val));
- /* Just to be unique any place on any host */
- sprintf((char *)(service_name[i]),
- "osmt.srvc.%" PRIu64 ".%" PRIu64, rand_val, pid);
- /*printf("-I- Service Name is : %s, ID is : 0x%" PRIx64 "\n",service_name[i],id[i]); */
- }
-
- status = osmt_register_service(p_osmt, cl_ntoh64(id[0]), /* IN ib_net64_t service_id, */
- IB_DEFAULT_PKEY, /* IN ib_net16_t service_pkey, */
- 0xFFFFFFFF, /* IN ib_net32_t service_lease, */
- 11, /* IN uint8_t service_key_lsb, */
- (char *)service_name[0] /* IN char *service_name */
- );
- if (status != IB_SUCCESS) {
- goto Exit;
- }
-
- status = osmt_register_service(p_osmt, cl_ntoh64(id[1]), /* IN ib_net64_t service_id, */
- IB_DEFAULT_PKEY, /* IN ib_net16_t service_pkey, */
- cl_hton32(0x00000004), /* IN ib_net32_t service_lease, */
- 11, /* IN uint8_t service_key_lsb, */
- (char *)service_name[1] /* IN char *service_name */
- );
- if (status != IB_SUCCESS) {
- goto Exit;
- }
-
- status = osmt_register_service(p_osmt, cl_ntoh64(id[2]), /* IN ib_net64_t service_id, */
- 0, /* IN ib_net16_t service_pkey, */
- 0xFFFFFFFF, /* IN ib_net32_t service_lease, */
- 11, /* Remove Service Record IN uint8_t service_key_lsb, */
- (char *)service_name[2] /* IN char *service_name */
- );
-
- if (status != IB_SUCCESS) {
- goto Exit;
- }
-
- /* Generate 2 instances of service record with consecutive data */
- for (instance = 0; instance < 2; instance++) {
- /* First, clear all arrays */
- memset(service_data8, 0, 16 * sizeof(uint8_t));
- memset(service_data16, 0, 8 * sizeof(uint16_t));
- memset(service_data32, 0, 4 * sizeof(uint32_t));
- memset(service_data64, 0, 2 * sizeof(uint64_t));
- service_data8[instance] = instance + 1;
- service_data16[instance] = cl_hton16(instance + 2);
- service_data32[instance] = cl_hton32(instance + 3);
- service_data64[instance] = cl_hton64(instance + 4);
- status = osmt_register_service_with_data(p_osmt, cl_ntoh64(id[3]), /* IN ib_net64_t service_id, */
- IB_DEFAULT_PKEY, /* IN ib_net16_t service_pkey, */
- cl_ntoh32(10), /* IN ib_net32_t service_lease, */
- 12, /* IN uint8_t service_key_lsb, */
- service_data8, service_data16, service_data32, service_data64, /* service data structures */
- (char *)service_name[3] /* IN char *service_name */
- );
-
- if (status != IB_SUCCESS) {
- goto Exit;
- }
-
- }
-
- /* Trying to create service with zero key */
- memset(service_key, 0, 16 * sizeof(uint8_t));
- status = osmt_register_service_with_full_key(p_osmt, cl_ntoh64(id[5]), /* IN ib_net64_t service_id, */
- 0, /* IN ib_net16_t service_pkey, */
- 0xFFFFFFFF, /* IN ib_net32_t service_lease, */
- service_key, /* full service_key, */
- (char *)service_name[5] /* IN char *service_name */
- );
-
- if (status != IB_SUCCESS) {
- goto Exit;
- }
-
- /* Now update it with Unique key and different service name */
- for (i = 0; i <= 15; i++) {
- service_key[i] = i + 1;
- }
- status = osmt_register_service_with_full_key(p_osmt, cl_ntoh64(id[5]), /* IN ib_net64_t service_id, */
- 0, /* IN ib_net16_t service_pkey, */
- 0xFFFFFFFF, /* IN ib_net32_t service_lease, */
- service_key, /* full service_key, */
- (char *)service_name[6] /* IN char *service_name */
- );
- if (status != IB_SUCCESS) {
- goto Exit;
- }
-
- /* Let OpenSM handle it */
- usleep(100);
-
- /* Make sure service_name[0] exists */
- status = osmt_get_service_by_name(p_osmt,
- (char *)service_name[0], 1, &srv_rec);
- if (status != IB_SUCCESS) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 4A1A: "
- "Fail to find service: name: %s\n",
- (char *)service_name[0]);
- status = IB_ERROR;
- goto Exit;
- }
-
- /* Make sure service_name[1] exists */
- status = osmt_get_service_by_name(p_osmt,
- (char *)service_name[1], 1, &srv_rec);
- if (status != IB_SUCCESS) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 4A1B: "
- "Fail to find service: name: %s\n",
- (char *)service_name[1]);
- status = IB_ERROR;
- goto Exit;
- }
-
- /* Make sure service_name[2] exists */
- status = osmt_get_service_by_name(p_osmt,
- (char *)service_name[2], 1, &srv_rec);
- if (status != IB_SUCCESS) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 4A1C: "
- "Fail to find service: name: %s\n",
- (char *)service_name[2]);
- status = IB_ERROR;
- goto Exit;
- }
-
- /* Make sure service_name[3] exists. */
- /* After 10 seconds the service should not exist: service_lease = 10 */
- status = osmt_get_service_by_name(p_osmt,
- (char *)service_name[3], 1, &srv_rec);
- if (status != IB_SUCCESS) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 4A1D: "
- "Fail to find service: name: %s\n",
- (char *)service_name[3]);
- status = IB_ERROR;
- goto Exit;
- }
-
- sleep(10);
-
- status = osmt_get_service_by_name(p_osmt,
- (char *)service_name[3], 0, &srv_rec);
- if (status != IB_SUCCESS) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 4A1E: "
- "Found service: name: %s that should have been "
- "deleted due to service lease expiring\n",
- (char *)service_name[3]);
- status = IB_ERROR;
- goto Exit;
- }
-
- /* Check that for service: id[5] only one record exists */
- status = osmt_get_service_by_id(p_osmt, 1, cl_ntoh64(id[5]), &srv_rec);
- if (status != IB_SUCCESS) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 4A1F: "
- "Found number of records != 1 for "
- "service: id: 0x%016" PRIx64 "\n", id[5]);
- status = IB_ERROR;
- goto Exit;
- }
-
- /* Bad Flow of Get with invalid Service ID: id[6] */
- status = osmt_get_service_by_id(p_osmt, 0, cl_ntoh64(id[6]), &srv_rec);
- if (status != IB_SUCCESS) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 4A20: "
- "Found service: id: 0x%016" PRIx64 " "
- "that is invalid\n", id[6]);
- status = IB_ERROR;
- goto Exit;
- }
-
- /* Check by both id and service name: id[0], service_name[0] */
- status = osmt_get_service_by_id_and_name(p_osmt, 1, cl_ntoh64(id[0]),
- (char *)service_name[0],
- &srv_rec);
- if (status != IB_SUCCESS) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 4A21: "
- "Fail to find service: id: 0x%016" PRIx64 " "
- "name: %s\n", id[0], (char *)service_name[0]);
- status = IB_ERROR;
- goto Exit;
- }
-
- /* Check by both id and service name: id[5], service_name[6] */
- status = osmt_get_service_by_id_and_name(p_osmt, 1, cl_ntoh64(id[5]),
- (char *)service_name[6],
- &srv_rec);
- if (status != IB_SUCCESS) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 4A22: "
- "Fail to find service: id: 0x%016" PRIx64 " "
- "name: %s\n", id[5], (char *)service_name[6]);
- status = IB_ERROR;
- goto Exit;
- }
-
- /* Bad Flow of Get with invalid name(service_name[3]) and valid ID(id[0]) */
- status = osmt_get_service_by_id_and_name(p_osmt, 0, cl_ntoh64(id[0]),
- (char *)service_name[3],
- &srv_rec);
- if (status != IB_SUCCESS) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 4A23: "
- "Found service: id: 0x%016" PRIx64
- "name: %s which is an invalid service\n",
- id[0], (char *)service_name[3]);
- status = IB_ERROR;
- goto Exit;
- }
-
- /* Bad Flow of Get with unmatched name(service_name[5]) and id(id[3]) (both valid) */
- status = osmt_get_service_by_id_and_name(p_osmt, 0, cl_ntoh64(id[3]),
- (char *)service_name[5],
- &srv_rec);
- if (status != IB_SUCCESS) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 4A24: "
- "Found service: id: 0x%016" PRIx64
- "name: %s which is an invalid service\n",
- id[3], (char *)service_name[5]);
- status = IB_ERROR;
- goto Exit;
- }
-
- /* Bad Flow of Get with service name that doesn't exist (service_name[4]) */
- status = osmt_get_service_by_name(p_osmt,
- (char *)service_name[4], 0, &srv_rec);
- if (status != IB_SUCCESS) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 4A25: "
- "Found service: name: %s that shouldn't exist\n",
- (char *)service_name[4]);
- status = IB_ERROR;
- goto Exit;
- }
-
- /* Bad Flow : Check that getting service_name[5] brings no records since another service
- has been updated with the same ID (service_name[6] */
- status = osmt_get_service_by_name(p_osmt,
- (char *)service_name[5], 0, &srv_rec);
- if (status != IB_SUCCESS) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 4A26: "
- "Found service: name: %s which is an "
- "invalid service\n", (char *)service_name[5]);
- status = IB_ERROR;
- goto Exit;
- }
-
- /* Check that getting service_name[6] by name ONLY is valid,
- since we do not support key&name association, also trusted queries */
- status = osmt_get_service_by_name(p_osmt,
- (char *)service_name[6], 1, &srv_rec);
- if (status != IB_SUCCESS) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 4A27: "
- "Fail to find service: name: %s\n",
- (char *)service_name[6]);
- status = IB_ERROR;
- goto Exit;
- }
-
- /* Test Service Key */
- memset(service_key, 0, 16 * sizeof(uint8_t));
-
- /* Check for service_name[5] with service_key=0 - the service shouldn't
- exist with this name. */
- status = osmt_get_service_by_name_and_key(p_osmt,
- (char *)service_name[5],
- 0, service_key, &srv_rec);
- if (status != IB_SUCCESS) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 4A28: "
- "Found service: name: %s key:0 which is an "
- "invalid service (wrong name)\n",
- (char *)service_name[5]);
- status = IB_ERROR;
- goto Exit;
- }
-
- /* Check for service_name[6] with service_key=0 - the service should
- exist with different key. */
- status = osmt_get_service_by_name_and_key(p_osmt,
- (char *)service_name[6],
- 0, service_key, &srv_rec);
- if (status != IB_SUCCESS) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 4A29: "
- "Found service: name: %s key: 0 which is an "
- "invalid service (wrong service_key)\n",
- (char *)service_name[6]);
- status = IB_ERROR;
- goto Exit;
- }
-
- /* check for service_name[6] with the correct service_key */
- for (i = 0; i <= 15; i++)
- service_key[i] = i + 1;
- status = osmt_get_service_by_name_and_key(p_osmt,
- (char *)service_name[6],
- 1, service_key, &srv_rec);
- if (status != IB_SUCCESS) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 4A2A: "
- "Fail to find service: name: %s with "
- "correct service key\n", (char *)service_name[6]);
- status = IB_ERROR;
- goto Exit;
- }
-#ifdef VENDOR_RMPP_SUPPORT
- /* These ar the only service_names which are valid */
- memcpy(&service_valid_names[0], &service_name[0], sizeof(uint8_t) * 64);
- memcpy(&service_valid_names[1], &service_name[2], sizeof(uint8_t) * 64);
- memcpy(&service_valid_names[2], &service_name[6], sizeof(uint8_t) * 64);
-
- status =
- osmt_get_all_services_and_check_names(p_osmt, service_valid_names,
- 3, &num_recs);
- if (status != IB_SUCCESS) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 4A2B: "
- "Fail to find all services that should exist\n");
- status = IB_ERROR;
- goto Exit;
- }
-#endif
-
- /* Delete service_name[0] */
- status = osmt_delete_service_by_name(p_osmt, 1,
- (char *)service_name[0], 1);
- if (status != IB_SUCCESS) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 4A2C: "
- "Fail to delete service: name: %s\n",
- (char *)service_name[0]);
- status = IB_ERROR;
- goto Exit;
- }
-
- /* Make sure deletion of service_name[0] succeeded */
- status = osmt_get_service_by_name(p_osmt,
- (char *)service_name[0], 0, &srv_rec);
- if (status != IB_SUCCESS) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 4A2D: "
- "Found service: name: %s that was deleted\n",
- (char *)service_name[0]);
- status = IB_ERROR;
- goto Exit;
- }
-
- /* Make sure service_name[1] doesn't exist (expired service lease) */
- status = osmt_get_service_by_name(p_osmt,
- (char *)service_name[1], 0, &srv_rec);
- if (status != IB_SUCCESS) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 4A2E: "
- "Found service: name: %s that should have expired\n",
- (char *)service_name[1]);
- status = IB_ERROR;
- goto Exit;
- }
-
- /* Make sure service_name[2] exists */
- status = osmt_get_service_by_name(p_osmt,
- (char *)service_name[2], 1, &srv_rec);
- if (status != IB_SUCCESS) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 4A2F: "
- "Fail to find service: name: %s\n",
- (char *)service_name[2]);
- status = IB_ERROR;
- goto Exit;
- }
-
- /* Bad Flow - try to delete non-existent service_name[5] */
- status = osmt_delete_service_by_name(p_osmt, 0,
- (char *)service_name[5], 0);
- if (status != IB_SUCCESS) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 4A30: "
- "Succeed to delete non-existent service: name: %s\n",
- (char *)service_name[5]);
- status = IB_ERROR;
- goto Exit;
- }
-
- /* Delete service_name[2] */
- status = osmt_delete_service_by_name(p_osmt, 1,
- (char *)service_name[2], 1);
- if (status != IB_SUCCESS) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 4A31: "
- "Fail to delete service: name: %s\n",
- (char *)service_name[2]);
- status = IB_ERROR;
- goto Exit;
- }
-
- /* Delete service_name[6] */
- status = osmt_delete_service_by_name(p_osmt, 1,
- (char *)service_name[6], 1);
- if (status != IB_SUCCESS) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 4A32: "
- "Failed to delete service name: %s\n",
- (char *)service_name[6]);
- goto Exit;
- }
-
-Exit:
- OSM_LOG_EXIT(&p_osmt->log);
- return status;
-}
diff --git a/contrib/ofed/management/opensm/osmtest/osmt_slvl_vl_arb.c b/contrib/ofed/management/opensm/osmtest/osmt_slvl_vl_arb.c
deleted file mode 100644
index 82a6f39..0000000
--- a/contrib/ofed/management/opensm/osmtest/osmt_slvl_vl_arb.c
+++ /dev/null
@@ -1,528 +0,0 @@
-/*
- * Copyright (c) 2006-2008 Voltaire, Inc. All rights reserved.
- * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved.
- * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- */
-
-/*
- * Abstract:
- * Implementation of SLtoVL and VL Arbitration testing flow..
- * Top level is osmt_run_slvl_and_vlarb_records_flow:
- * osmt_query_all_ports_vl_arb
- * osmt_query_all_ports_slvl_map
- *
- */
-
-#ifndef __WIN__
-#include <unistd.h>
-#endif
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <complib/cl_debug.h>
-#include "osmtest.h"
-
-/**********************************************************************
- **********************************************************************/
-static ib_api_status_t
-osmtest_write_vl_arb_table(IN osmtest_t * const p_osmt,
- IN FILE * fh,
- IN const ib_vl_arb_table_record_t * const p_rec)
-{
- int result, i;
- cl_status_t status = IB_SUCCESS;
-
- OSM_LOG_ENTER(&p_osmt->log);
-
- result = fprintf(fh,
- "VL_ARBITRATION_TABLE\n"
- "lid 0x%X\n"
- "port_num 0x%X\n"
- "block 0x%X\n",
- cl_ntoh16(p_rec->lid),
- p_rec->port_num, p_rec->block_num);
-
- fprintf(fh, " ");
- for (i = 0; i < 32; i++)
- fprintf(fh, "| %-2u ", i);
- fprintf(fh, "|\nVL: ");
-
- for (i = 0; i < 32; i++)
- fprintf(fh, "|0x%02X", p_rec->vl_arb_tbl.vl_entry[i].vl);
- fprintf(fh, "|\nWEIGHT:");
-
- for (i = 0; i < 32; i++)
- fprintf(fh, "|0x%02X", p_rec->vl_arb_tbl.vl_entry[i].weight);
- fprintf(fh, "|\nEND\n\n");
-
- /* Exit: */
- OSM_LOG_EXIT(&p_osmt->log);
- return (status);
-}
-
-/**********************************************************************
- * GET A SINGLE PORT INFO BY NODE LID AND PORT NUMBER
- **********************************************************************/
-ib_api_status_t
-osmt_query_vl_arb(IN osmtest_t * const p_osmt,
- IN ib_net16_t const lid,
- IN uint8_t const port_num,
- IN uint8_t const block_num, IN FILE * fh)
-{
- osmtest_req_context_t context;
- ib_api_status_t status = IB_SUCCESS;
- osmv_user_query_t user;
- osmv_query_req_t req;
- ib_vl_arb_table_record_t record, *p_rec;
-
- OSM_LOG_ENTER(&p_osmt->log);
-
- OSM_LOG(&p_osmt->log, OSM_LOG_DEBUG,
- "Getting VL_Arbitration Table for port with LID 0x%X Num:0x%X\n",
- cl_ntoh16(lid), port_num);
-
- /*
- * Do a blocking query for this record in the subnet.
- * The result is returned in the result field of the caller's
- * context structure.
- *
- * The query structures are locals.
- */
- memset(&req, 0, sizeof(req));
- memset(&user, 0, sizeof(user));
- memset(&context, 0, sizeof(context));
-
- context.p_osmt = p_osmt;
-
- record.lid = lid;
- record.port_num = port_num;
- record.block_num = block_num;
- user.p_attr = &record;
-
- req.query_type = OSMV_QUERY_VLARB_BY_LID_PORT_BLOCK;
- req.timeout_ms = p_osmt->opt.transaction_timeout;
- req.retry_cnt = p_osmt->opt.retry_count;
- req.flags = OSM_SA_FLAGS_SYNC;
- req.query_context = &context;
- req.pfn_query_cb = osmtest_query_res_cb;
- req.p_query_input = &user;
- req.sm_key = 0;
-
- status = osmv_query_sa(p_osmt->h_bind, &req);
-
- if (status != IB_SUCCESS) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0405: "
- "ib_query failed (%s)\n", ib_get_err_str(status));
- goto Exit;
- }
-
- status = context.result.status;
-
- if (status != IB_SUCCESS) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0466: "
- "ib_query failed (%s)\n", ib_get_err_str(status));
-
- if (status == IB_REMOTE_ERROR) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR,
- "Remote error = %s\n",
- ib_get_mad_status_str(osm_madw_get_mad_ptr
- (context.result.
- p_result_madw)));
- }
- goto Exit;
- }
-
- /* ok it worked */
- p_rec = osmv_get_query_result(context.result.p_result_madw, 0);
- if (fh) {
- osmtest_write_vl_arb_table(p_osmt, fh, p_rec);
- }
-
-Exit:
- /*
- * Return the IB query MAD to the pool as necessary.
- */
- if (context.result.p_result_madw != NULL) {
- osm_mad_pool_put(&p_osmt->mad_pool,
- context.result.p_result_madw);
- context.result.p_result_madw = NULL;
- }
-
- OSM_LOG_EXIT(&p_osmt->log);
- return (status);
-}
-
-static ib_api_status_t
-osmt_query_all_ports_vl_arb(IN osmtest_t * const p_osmt, IN FILE * fh)
-{
- cl_status_t status = CL_SUCCESS;
- cl_qmap_t *p_tbl;
- port_t *p_src_port;
- uint8_t block, anyErr = 0;
-
- OSM_LOG_ENTER(&p_osmt->log);
-
- OSM_LOG(&p_osmt->log, OSM_LOG_VERBOSE,
- "Obtaining ALL Ports VL Arbitration Tables\n");
-
- /*
- * Go over all ports that exist in the subnet
- * get the relevant VLarbs
- */
-
- p_tbl = &p_osmt->exp_subn.port_key_tbl;
-
- p_src_port = (port_t *) cl_qmap_head(p_tbl);
-
- while (p_src_port != (port_t *) cl_qmap_end(p_tbl)) {
-
- /* HACK we use capability_mask to know diff a CA port from switch port */
- if (p_src_port->rec.port_info.capability_mask) {
- /* this is an hca port */
- for (block = 1; block <= 4; block++) {
- /* NOTE to comply we must set port number to 0 and the SA should figure it out */
- /* since it is a CA port */
- status =
- osmt_query_vl_arb(p_osmt,
- p_src_port->rec.lid, 0,
- block, fh);
- if (status != IB_SUCCESS) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR,
- "ERR 0467: "
- "Failed to get Lid:0x%X Port:0x%X (%s)\n",
- cl_ntoh16(p_src_port->rec.lid),
- 0, ib_get_err_str(status));
- anyErr = 1;
- }
- }
- } else {
- /* this is a switch port */
- for (block = 1; block <= 4; block++) {
- status =
- osmt_query_vl_arb(p_osmt,
- p_src_port->rec.lid,
- p_src_port->rec.port_num,
- block, fh);
- if (status != IB_SUCCESS) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR,
- "ERR 0468: "
- "Failed to get Lid:0x%X Port:0x%X (%s)\n",
- cl_ntoh16(p_src_port->rec.lid),
- p_src_port->rec.port_num,
- ib_get_err_str(status));
- anyErr = 1;
- }
- }
- }
-
- p_src_port = (port_t *) cl_qmap_next(&p_src_port->map_item);
- }
-
- OSM_LOG_EXIT(&p_osmt->log);
- if (anyErr) {
- status = IB_ERROR;
- }
- return (status);
-}
-
-/*******************************************************************************
- SLtoVL
-*******************************************************************************/
-static ib_api_status_t
-osmtest_write_slvl_map_table(IN osmtest_t * const p_osmt,
- IN FILE * fh,
- IN const ib_slvl_table_record_t * const p_rec)
-{
- int result, i;
- cl_status_t status = IB_SUCCESS;
-
- OSM_LOG_ENTER(&p_osmt->log);
-
- result = fprintf(fh,
- "SLtoVL_MAP_TABLE\n"
- "lid 0x%X\n"
- "in_port_num 0x%X\n"
- "out_port_num 0x%X\n",
- cl_ntoh16(p_rec->lid),
- p_rec->in_port_num, p_rec->out_port_num);
-
- fprintf(fh, "SL:");
- for (i = 0; i < 16; i++)
- fprintf(fh, "| %-2u ", i);
- fprintf(fh, "|\nVL:");
-
- for (i = 0; i < 16; i++)
- fprintf(fh, "| 0x%01X ",
- ib_slvl_table_get(&p_rec->slvl_tbl, (uint8_t) i));
- fprintf(fh, "|\nEND\n\n");
-
- /* Exit: */
- OSM_LOG_EXIT(&p_osmt->log);
- return (status);
-}
-
-/**********************************************************************
- * GET A SINGLE PORT INFO BY NODE LID AND PORT NUMBER
- **********************************************************************/
-ib_api_status_t
-osmt_query_slvl_map(IN osmtest_t * const p_osmt,
- IN ib_net16_t const lid,
- IN uint8_t const out_port_num,
- IN uint8_t const in_port_num, IN FILE * fh)
-{
- osmtest_req_context_t context;
- ib_api_status_t status = IB_SUCCESS;
- osmv_user_query_t user;
- osmv_query_req_t req;
- ib_slvl_table_record_t record, *p_rec;
-
- OSM_LOG_ENTER(&p_osmt->log);
-
- OSM_LOG(&p_osmt->log, OSM_LOG_DEBUG,
- "Getting SLtoVL Map Table for out-port with LID 0x%X Num:0x%X from In-Port:0x%X\n",
- cl_ntoh16(lid), out_port_num, in_port_num);
-
- /*
- * Do a blocking query for this record in the subnet.
- * The result is returned in the result field of the caller's
- * context structure.
- *
- * The query structures are locals.
- */
- memset(&req, 0, sizeof(req));
- memset(&user, 0, sizeof(user));
- memset(&context, 0, sizeof(context));
-
- context.p_osmt = p_osmt;
-
- record.lid = lid;
- record.in_port_num = in_port_num;
- record.out_port_num = out_port_num;
- user.p_attr = &record;
-
- req.query_type = OSMV_QUERY_SLVL_BY_LID_AND_PORTS;
- req.timeout_ms = p_osmt->opt.transaction_timeout;
- req.retry_cnt = p_osmt->opt.retry_count;
- req.flags = OSM_SA_FLAGS_SYNC;
- req.query_context = &context;
- req.pfn_query_cb = osmtest_query_res_cb;
- req.p_query_input = &user;
- req.sm_key = 0;
-
- status = osmv_query_sa(p_osmt->h_bind, &req);
-
- if (status != IB_SUCCESS) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0469: "
- "ib_query failed (%s)\n", ib_get_err_str(status));
- goto Exit;
- }
-
- status = context.result.status;
-
- if (status != IB_SUCCESS) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0470: "
- "ib_query failed (%s)\n", ib_get_err_str(status));
-
- if (status == IB_REMOTE_ERROR) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR,
- "Remote error = %s\n",
- ib_get_mad_status_str(osm_madw_get_mad_ptr
- (context.result.
- p_result_madw)));
- }
- goto Exit;
- }
-
- /* ok it worked */
- p_rec = osmv_get_query_result(context.result.p_result_madw, 0);
- if (fh) {
- osmtest_write_slvl_map_table(p_osmt, fh, p_rec);
- }
-
-Exit:
- /*
- * Return the IB query MAD to the pool as necessary.
- */
- if (context.result.p_result_madw != NULL) {
- osm_mad_pool_put(&p_osmt->mad_pool,
- context.result.p_result_madw);
- context.result.p_result_madw = NULL;
- }
-
- OSM_LOG_EXIT(&p_osmt->log);
- return (status);
-}
-
-static ib_api_status_t
-osmt_query_all_ports_slvl_map(IN osmtest_t * const p_osmt, IN FILE * fh)
-{
- cl_status_t status = CL_SUCCESS;
- cl_qmap_t *p_tbl;
- port_t *p_src_port;
- uint8_t in_port, anyErr = 0, num_ports;
- node_t *p_node;
- const cl_qmap_t *p_node_tbl;
-
- OSM_LOG_ENTER(&p_osmt->log);
-
- /*
- * Go over all ports that exist in the subnet
- * get the relevant SLtoVLs
- */
-
- OSM_LOG(&p_osmt->log, OSM_LOG_VERBOSE,
- "Obtaining ALL Ports (to other ports) SLtoVL Maps\n");
-
- p_tbl = &p_osmt->exp_subn.port_key_tbl;
- p_node_tbl = &p_osmt->exp_subn.node_lid_tbl;
-
- p_src_port = (port_t *) cl_qmap_head(p_tbl);
-
- while (p_src_port != (port_t *) cl_qmap_end(p_tbl)) {
-
- /* HACK we use capability_mask to know diff a CA port from switch port */
- if (p_src_port->rec.port_info.capability_mask) {
- /* this is an hca port */
- /* NOTE to comply we must set port number to 0 and the SA should figure it out */
- /* since it is a CA port */
- status =
- osmt_query_slvl_map(p_osmt, p_src_port->rec.lid, 0,
- 0, fh);
- if (status != IB_SUCCESS) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0471: "
- "Failed to get Lid:0x%X In-Port:0x%X Out-Port:0x%X(%s)\n",
- cl_ntoh16(p_src_port->rec.lid), 0, 0,
- ib_get_err_str(status));
- anyErr = 1;
- }
- } else {
- /* this is a switch port */
- /* get the node */
- p_node =
- (node_t *) cl_qmap_get(p_node_tbl,
- p_src_port->rec.lid);
- if (p_node == (node_t *) cl_qmap_end(p_node_tbl)) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0472: "
- "Failed to get Node by Lid:0x%X\n",
- p_src_port->rec.lid);
- goto Exit;
- }
-
- num_ports = p_node->rec.node_info.num_ports;
-
- for (in_port = 1; in_port <= num_ports; in_port++) {
- status =
- osmt_query_slvl_map(p_osmt,
- p_src_port->rec.lid,
- p_src_port->rec.
- port_num, in_port, fh);
- if (status != IB_SUCCESS) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR,
- "ERR 0473: "
- "Failed to get Lid:0x%X In-Port:0x%X Out-Port:0x%X (%s)\n",
- cl_ntoh16(p_src_port->rec.lid),
- p_src_port->rec.port_num,
- in_port,
- ib_get_err_str(status));
- anyErr = 1;
- }
- }
- }
-
- p_src_port = (port_t *) cl_qmap_next(&p_src_port->map_item);
- }
-
-Exit:
- OSM_LOG_EXIT(&p_osmt->log);
- if (anyErr) {
- status = IB_ERROR;
- }
- return (status);
-}
-
-/*
- * Run a vl arbitration queries and sl2vl maps queries flow:
- * Good flow:
- * - for each physical port on the network - obtain the VL Arb
- * - for each CA physical port obtain its SLtoVL Map
- * - for each SW physical port (out) obtain the SLtoVL Map to each other port
- * BAD flow:
- * - Try get with multiple results
- * - Try gettable
- * - Try providing non existing port
- */
-ib_api_status_t
-osmt_run_slvl_and_vlarb_records_flow(IN osmtest_t * const p_osmt)
-{
- ib_api_status_t status;
- FILE *fh;
- ib_net16_t test_lid;
- uint8_t lmc;
-
- OSM_LOG_ENTER(&p_osmt->log);
-
- fh = fopen("qos.txt", "w");
-
- /* go over all ports in the subnet */
- status = osmt_query_all_ports_vl_arb(p_osmt, fh);
- if (status != IB_SUCCESS) {
- goto Exit;
- }
-
- status = osmt_query_all_ports_slvl_map(p_osmt, fh);
- if (status != IB_SUCCESS) {
- goto Exit;
- }
-
- /* If LMC > 0, test non base LID SA QoS Record requests */
- status =
- osmtest_get_local_port_lmc(p_osmt, p_osmt->local_port.lid, &lmc);
- if (status != IB_SUCCESS)
- goto Exit;
-
- if (lmc != 0) {
- test_lid = cl_ntoh16(p_osmt->local_port.lid + 1);
-
- status = osmt_query_vl_arb(p_osmt, test_lid, 0, 1, NULL);
- if (status != IB_SUCCESS)
- goto Exit;
-
- status = osmt_query_slvl_map(p_osmt, test_lid, 0, 0, NULL);
- if (status != IB_SUCCESS)
- goto Exit;
- }
-
-Exit:
- fclose(fh);
- OSM_LOG_EXIT(&p_osmt->log);
- return status;
-}
diff --git a/contrib/ofed/management/opensm/osmtest/osmtest.c b/contrib/ofed/management/opensm/osmtest/osmtest.c
deleted file mode 100644
index 7b82758..0000000
--- a/contrib/ofed/management/opensm/osmtest/osmtest.c
+++ /dev/null
@@ -1,7403 +0,0 @@
-/*
- * Copyright (c) 2006-2008 Voltaire, Inc. All rights reserved.
- * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved.
- * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- */
-
-/* TODO : Check why we dont free the cl_qmap_items we store when reading DB */
-
-/*
- * Abstract:
- * Implementation of osmtest_t.
- * This object represents the OSMTest Test object.
- *
- */
-
-#ifdef __WIN__
-#pragma warning(disable : 4996)
-#endif
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#ifdef __WIN__
-#include <complib/cl_timer.h>
-#else
-#include <strings.h>
-#include <sys/time.h>
-#endif
-#include <complib/cl_debug.h>
-#include "osmtest.h"
-
-#ifndef __WIN__
-#define strnicmp strncasecmp
-#endif
-
-#define POOL_MIN_ITEMS 64
-#define GUID_ARRAY_SIZE 64
-
-typedef struct _osmtest_sm_info_rec {
- ib_net64_t sm_guid;
- ib_net16_t lid;
- uint8_t priority;
- uint8_t sm_state;
-} osmtest_sm_info_rec_t;
-
-typedef struct _osmtest_inform_info {
- boolean_t subscribe;
- ib_net32_t qpn;
- ib_net16_t trap;
-} osmtest_inform_info_t;
-
-typedef struct _osmtest_inform_info_rec {
- ib_gid_t subscriber_gid;
- ib_net16_t subscriber_enum;
-} osmtest_inform_info_rec_t;
-
-typedef enum _osmtest_token_val {
- OSMTEST_TOKEN_COMMENT = 0,
- OSMTEST_TOKEN_END,
- OSMTEST_TOKEN_DEFINE_NODE,
- OSMTEST_TOKEN_DEFINE_PORT,
- OSMTEST_TOKEN_DEFINE_PATH,
- OSMTEST_TOKEN_DEFINE_LINK,
- OSMTEST_TOKEN_LID,
- OSMTEST_TOKEN_BASE_VERSION,
- OSMTEST_TOKEN_CLASS_VERSION,
- OSMTEST_TOKEN_NODE_TYPE,
- OSMTEST_TOKEN_NUM_PORTS,
- OSMTEST_TOKEN_SYS_GUID,
- OSMTEST_TOKEN_NODE_GUID,
- OSMTEST_TOKEN_PORT_GUID,
- OSMTEST_TOKEN_PARTITION_CAP,
- OSMTEST_TOKEN_DEVICE_ID,
- OSMTEST_TOKEN_REVISION,
- OSMTEST_TOKEN_PORT_NUM,
- OSMTEST_TOKEN_VENDOR_ID,
- OSMTEST_TOKEN_DGID,
- OSMTEST_TOKEN_SGID,
- OSMTEST_TOKEN_DLID,
- OSMTEST_TOKEN_SLID,
- OSMTEST_TOKEN_HOP_FLOW_RAW,
- OSMTEST_TOKEN_TCLASS,
- OSMTEST_TOKEN_NUM_PATH,
- OSMTEST_TOKEN_PKEY,
- OSMTEST_TOKEN_SL,
- OSMTEST_TOKEN_RATE,
- OSMTEST_TOKEN_PKT_LIFE,
- OSMTEST_TOKEN_PREFERENCE,
- OSMTEST_TOKEN_MKEY,
- OSMTEST_TOKEN_SUBN_PREF,
- OSMTEST_TOKEN_BASE_LID,
- OSMTEST_TOKEN_SM_BASE_LID,
- OSMTEST_TOKEN_CAP_MASK,
- OSMTEST_TOKEN_DIAG_CODE,
- OSMTEST_TOKEN_MKEY_LEASE_PER,
- OSMTEST_TOKEN_LOC_PORT_NUM,
- OSMTEST_TOKEN_LINK_WID_EN,
- OSMTEST_TOKEN_LINK_WID_SUP,
- OSMTEST_TOKEN_LINK_WID_ACT,
- OSMTEST_TOKEN_LINK_SPEED_SUP,
- OSMTEST_TOKEN_PORT_STATE,
- OSMTEST_TOKEN_STATE_INFO2,
- OSMTEST_TOKEN_MKEY_PROT_BITS,
- OSMTEST_TOKEN_LMC,
- OSMTEST_TOKEN_LINK_SPEED,
- OSMTEST_TOKEN_MTU_SMSL,
- OSMTEST_TOKEN_VL_CAP,
- OSMTEST_TOKEN_VL_HIGH_LIMIT,
- OSMTEST_TOKEN_VL_ARB_HIGH_CAP,
- OSMTEST_TOKEN_VL_ARB_LOW_CAP,
- OSMTEST_TOKEN_MTU_CAP,
- OSMTEST_TOKEN_VL_STALL_LIFE,
- OSMTEST_TOKEN_VL_ENFORCE,
- OSMTEST_TOKEN_MKEY_VIOL,
- OSMTEST_TOKEN_PKEY_VIOL,
- OSMTEST_TOKEN_QKEY_VIOL,
- OSMTEST_TOKEN_GUID_CAP,
- OSMTEST_TOKEN_SUBN_TIMEOUT,
- OSMTEST_TOKEN_RESP_TIME_VAL,
- OSMTEST_TOKEN_ERR_THRESHOLD,
- OSMTEST_TOKEN_MTU,
- OSMTEST_TOKEN_FROMLID,
- OSMTEST_TOKEN_FROMPORTNUM,
- OSMTEST_TOKEN_TOPORTNUM,
- OSMTEST_TOKEN_TOLID,
- OSMTEST_TOKEN_UNKNOWN
-} osmtest_token_val_t;
-
-typedef struct _osmtest_token {
- osmtest_token_val_t val;
- size_t str_size;
- const char *str;
-} osmtest_token_t;
-
-const osmtest_token_t token_array[] = {
- {OSMTEST_TOKEN_COMMENT, 1, "#"},
- {OSMTEST_TOKEN_END, 3, "END"},
- {OSMTEST_TOKEN_DEFINE_NODE, 11, "DEFINE_NODE"},
- {OSMTEST_TOKEN_DEFINE_PORT, 11, "DEFINE_PORT"},
- {OSMTEST_TOKEN_DEFINE_PATH, 11, "DEFINE_PATH"},
- {OSMTEST_TOKEN_DEFINE_LINK, 11, "DEFINE_LINK"},
- {OSMTEST_TOKEN_LID, 3, "LID"},
- {OSMTEST_TOKEN_BASE_VERSION, 12, "BASE_VERSION"},
- {OSMTEST_TOKEN_CLASS_VERSION, 13, "CLASS_VERSION"},
- {OSMTEST_TOKEN_NODE_TYPE, 9, "NODE_TYPE"},
- {OSMTEST_TOKEN_NUM_PORTS, 9, "NUM_PORTS"},
- {OSMTEST_TOKEN_SYS_GUID, 8, "SYS_GUID"},
- {OSMTEST_TOKEN_NODE_GUID, 9, "NODE_GUID"},
- {OSMTEST_TOKEN_PORT_GUID, 9, "PORT_GUID"},
- {OSMTEST_TOKEN_PARTITION_CAP, 13, "PARTITION_CAP"},
- {OSMTEST_TOKEN_DEVICE_ID, 9, "DEVICE_ID"},
- {OSMTEST_TOKEN_REVISION, 8, "REVISION"},
- {OSMTEST_TOKEN_PORT_NUM, 8, "PORT_NUM"},
- {OSMTEST_TOKEN_VENDOR_ID, 9, "VENDOR_ID"},
- {OSMTEST_TOKEN_DGID, 4, "DGID"},
- {OSMTEST_TOKEN_SGID, 4, "SGID"},
- {OSMTEST_TOKEN_DLID, 4, "DLID"},
- {OSMTEST_TOKEN_SLID, 4, "SLID"},
- {OSMTEST_TOKEN_HOP_FLOW_RAW, 12, "HOP_FLOW_RAW"},
- {OSMTEST_TOKEN_TCLASS, 6, "TCLASS"},
- {OSMTEST_TOKEN_NUM_PATH, 8, "NUM_PATH"},
- {OSMTEST_TOKEN_PKEY, 4, "PKEY"},
- {OSMTEST_TOKEN_SL, 2, "SL"},
- {OSMTEST_TOKEN_RATE, 4, "RATE"},
- {OSMTEST_TOKEN_PKT_LIFE, 8, "PKT_LIFE"},
- {OSMTEST_TOKEN_PREFERENCE, 10, "PREFERENCE"},
- {OSMTEST_TOKEN_MKEY, 4, "M_KEY"},
- {OSMTEST_TOKEN_SUBN_PREF, 13, "SUBNET_PREFIX"},
- {OSMTEST_TOKEN_BASE_LID, 8, "BASE_LID"},
- {OSMTEST_TOKEN_SM_BASE_LID, 18, "MASTER_SM_BASE_LID"},
- {OSMTEST_TOKEN_CAP_MASK, 15, "CAPABILITY_MASK"},
- {OSMTEST_TOKEN_DIAG_CODE, 9, "DIAG_CODE"},
- {OSMTEST_TOKEN_MKEY_LEASE_PER, 18, "m_key_lease_period"},
- {OSMTEST_TOKEN_LOC_PORT_NUM, 14, "local_port_num"},
- {OSMTEST_TOKEN_LINK_WID_EN, 18, "link_width_enabled"},
- {OSMTEST_TOKEN_LINK_WID_SUP, 20, "link_width_supported"},
- {OSMTEST_TOKEN_LINK_WID_ACT, 17, "link_width_active"},
- {OSMTEST_TOKEN_LINK_SPEED_SUP, 20, "link_speed_supported"},
- {OSMTEST_TOKEN_PORT_STATE, 10, "port_state"},
- {OSMTEST_TOKEN_STATE_INFO2, 10, "state_info2"},
- {OSMTEST_TOKEN_MKEY_PROT_BITS, 3, "mpb"},
- {OSMTEST_TOKEN_LMC, 3, "lmc"},
- {OSMTEST_TOKEN_LINK_SPEED, 10, "link_speed"},
- {OSMTEST_TOKEN_MTU_SMSL, 8, "mtu_smsl"},
- {OSMTEST_TOKEN_VL_CAP, 6, "vl_cap"},
- {OSMTEST_TOKEN_VL_HIGH_LIMIT, 13, "vl_high_limit"},
- {OSMTEST_TOKEN_VL_ARB_HIGH_CAP, 15, "vl_arb_high_cap"},
- {OSMTEST_TOKEN_VL_ARB_LOW_CAP, 14, "vl_arb_low_cap"},
- {OSMTEST_TOKEN_MTU_CAP, 7, "mtu_cap"},
- {OSMTEST_TOKEN_VL_STALL_LIFE, 13, "vl_stall_life"},
- {OSMTEST_TOKEN_VL_ENFORCE, 10, "vl_enforce"},
- {OSMTEST_TOKEN_MKEY_VIOL, 16, "m_key_violations"},
- {OSMTEST_TOKEN_PKEY_VIOL, 16, "p_key_violations"},
- {OSMTEST_TOKEN_QKEY_VIOL, 16, "q_key_violations"},
- {OSMTEST_TOKEN_GUID_CAP, 8, "guid_cap"},
- {OSMTEST_TOKEN_SUBN_TIMEOUT, 14, "subnet_timeout"},
- {OSMTEST_TOKEN_RESP_TIME_VAL, 15, "resp_time_value"},
- {OSMTEST_TOKEN_ERR_THRESHOLD, 15, "error_threshold"},
- {OSMTEST_TOKEN_MTU, 3, "MTU"}, /* must be after the other mtu... tokens. */
- {OSMTEST_TOKEN_FROMLID, 8, "from_lid"},
- {OSMTEST_TOKEN_FROMPORTNUM, 13, "from_port_num"},
- {OSMTEST_TOKEN_TOPORTNUM, 11, "to_port_num"},
- {OSMTEST_TOKEN_TOLID, 6, "to_lid"},
- {OSMTEST_TOKEN_UNKNOWN, 0, ""} /* must be last entry */
-};
-
-#define IB_MAD_STATUS_CLASS_MASK (CL_HTON16(0xFF00))
-
-static const char ib_mad_status_str_busy[] = "IB_MAD_STATUS_BUSY";
-static const char ib_mad_status_str_redirect[] = "IB_MAD_STATUS_REDIRECT";
-static const char ib_mad_status_str_unsup_class_ver[] =
- "IB_MAD_STATUS_UNSUP_CLASS_VER";
-static const char ib_mad_status_str_unsup_method[] =
- "IB_MAD_STATUS_UNSUP_METHOD";
-static const char ib_mad_status_str_unsup_method_attr[] =
- "IB_MAD_STATUS_UNSUP_METHOD_ATTR";
-static const char ib_mad_status_str_invalid_field[] =
- "IB_MAD_STATUS_INVALID_FIELD";
-static const char ib_mad_status_str_no_resources[] =
- "IB_SA_MAD_STATUS_NO_RESOURCES";
-static const char ib_mad_status_str_req_invalid[] =
- "IB_SA_MAD_STATUS_REQ_INVALID";
-static const char ib_mad_status_str_no_records[] =
- "IB_SA_MAD_STATUS_NO_RECORDS";
-static const char ib_mad_status_str_too_many_records[] =
- "IB_SA_MAD_STATUS_TOO_MANY_RECORDS";
-static const char ib_mad_status_str_invalid_gid[] =
- "IB_SA_MAD_STATUS_INVALID_GID";
-static const char ib_mad_status_str_insuf_comps[] =
- "IB_SA_MAD_STATUS_INSUF_COMPS";
-static const char generic_or_str[] = " | ";
-
-/**********************************************************************
- **********************************************************************/
-const char *ib_get_mad_status_str(IN const ib_mad_t * const p_mad)
-{
- static char line[512];
- uint32_t offset = 0;
- ib_net16_t status;
- boolean_t first = TRUE;
-
- line[offset] = '\0';
-
- status = (ib_net16_t) (p_mad->status & IB_SMP_STATUS_MASK);
-
- if (status == 0) {
- strcat(&line[offset], "IB_SUCCESS");
- return (line);
- }
-
- if (status & IB_MAD_STATUS_BUSY) {
- strcat(&line[offset], ib_mad_status_str_busy);
- offset += sizeof(ib_mad_status_str_busy);
- }
- if (status & IB_MAD_STATUS_REDIRECT) {
- if (!first) {
- strcat(&line[offset], generic_or_str);
- offset += sizeof(generic_or_str) - 1;
- }
- first = FALSE;
- strcat(&line[offset], ib_mad_status_str_redirect);
- offset += sizeof(ib_mad_status_str_redirect) - 1;
- }
- if ((status & IB_MAD_STATUS_INVALID_FIELD) ==
- IB_MAD_STATUS_UNSUP_CLASS_VER) {
- if (!first) {
- strcat(&line[offset], generic_or_str);
- offset += sizeof(generic_or_str) - 1;
- }
- first = FALSE;
- strcat(&line[offset], ib_mad_status_str_unsup_class_ver);
- offset += sizeof(ib_mad_status_str_unsup_class_ver) - 1;
- }
- if ((status & IB_MAD_STATUS_INVALID_FIELD) ==
- IB_MAD_STATUS_UNSUP_METHOD) {
- if (!first) {
- strcat(&line[offset], generic_or_str);
- offset += sizeof(generic_or_str) - 1;
- }
- first = FALSE;
- strcat(&line[offset], ib_mad_status_str_unsup_method);
- offset += sizeof(ib_mad_status_str_unsup_method) - 1;
- }
- if ((status & IB_MAD_STATUS_INVALID_FIELD) ==
- IB_MAD_STATUS_UNSUP_METHOD_ATTR) {
- if (!first) {
- strcat(&line[offset], generic_or_str);
- offset += sizeof(generic_or_str) - 1;
- }
- first = FALSE;
- strcat(&line[offset], ib_mad_status_str_unsup_method_attr);
- offset += sizeof(ib_mad_status_str_unsup_method_attr) - 1;
- }
- if ((status & IB_MAD_STATUS_INVALID_FIELD) ==
- IB_MAD_STATUS_INVALID_FIELD) {
- if (!first) {
- strcat(&line[offset], generic_or_str);
- offset += sizeof(generic_or_str) - 1;
- }
- first = FALSE;
- strcat(&line[offset], ib_mad_status_str_invalid_field);
- offset += sizeof(ib_mad_status_str_invalid_field) - 1;
- }
- if ((status & IB_MAD_STATUS_CLASS_MASK) ==
- IB_SA_MAD_STATUS_NO_RESOURCES) {
- if (!first) {
- strcat(&line[offset], generic_or_str);
- offset += sizeof(generic_or_str) - 1;
- }
- first = FALSE;
- strcat(&line[offset], ib_mad_status_str_no_resources);
- offset += sizeof(ib_mad_status_str_no_resources) - 1;
- }
- if ((status & IB_MAD_STATUS_CLASS_MASK) == IB_SA_MAD_STATUS_REQ_INVALID) {
- if (!first) {
- strcat(&line[offset], generic_or_str);
- offset += sizeof(generic_or_str) - 1;
- }
- first = FALSE;
- strcat(&line[offset], ib_mad_status_str_req_invalid);
- offset += sizeof(ib_mad_status_str_req_invalid) - 1;
- }
- if ((status & IB_MAD_STATUS_CLASS_MASK) == IB_SA_MAD_STATUS_NO_RECORDS) {
- if (!first) {
- strcat(&line[offset], generic_or_str);
- offset += sizeof(generic_or_str) - 1;
- }
- first = FALSE;
- strcat(&line[offset], ib_mad_status_str_no_records);
- offset += sizeof(ib_mad_status_str_no_records) - 1;
- }
- if ((status & IB_MAD_STATUS_CLASS_MASK) ==
- IB_SA_MAD_STATUS_TOO_MANY_RECORDS) {
- if (!first) {
- strcat(&line[offset], generic_or_str);
- offset += sizeof(generic_or_str) - 1;
- }
- first = FALSE;
- strcat(&line[offset], ib_mad_status_str_too_many_records);
- offset += sizeof(ib_mad_status_str_too_many_records) - 1;
- }
- if ((status & IB_MAD_STATUS_CLASS_MASK) == IB_SA_MAD_STATUS_INVALID_GID) {
- if (!first) {
- strcat(&line[offset], generic_or_str);
- offset += sizeof(generic_or_str) - 1;
- }
- first = FALSE;
- strcat(&line[offset], ib_mad_status_str_invalid_gid);
- offset += sizeof(ib_mad_status_str_invalid_gid) - 1;
- }
- if ((status & IB_MAD_STATUS_CLASS_MASK) == IB_SA_MAD_STATUS_INSUF_COMPS) {
- if (!first) {
- strcat(&line[offset], generic_or_str);
- offset += sizeof(generic_or_str) - 1;
- }
- first = FALSE;
- strcat(&line[offset], ib_mad_status_str_insuf_comps);
- offset += sizeof(ib_mad_status_str_insuf_comps) - 1;
- }
-
- return (line);
-}
-
-/**********************************************************************
- **********************************************************************/
-void subnet_construct(IN subnet_t * const p_subn)
-{
- cl_qmap_init(&p_subn->link_tbl);
- cl_qmap_init(&p_subn->node_lid_tbl);
- cl_qmap_init(&p_subn->node_guid_tbl);
- cl_qmap_init(&p_subn->mgrp_mlid_tbl);
-
- /* NO WAY TO HAVE UNIQUE PORT BY LID OR GUID */
- /* cl_qmap_init( &p_subn->port_lid_tbl ); */
- /* cl_qmap_init( &p_subn->port_guid_tbl ); */
-
- /* port key is a lid and num pair */
- cl_qmap_init(&p_subn->port_key_tbl);
- cl_qmap_init(&p_subn->path_tbl);
-}
-
-/**********************************************************************
- **********************************************************************/
-cl_status_t subnet_init(IN subnet_t * const p_subn)
-{
- cl_status_t status = IB_SUCCESS;
-
- subnet_construct(p_subn);
-
- return (status);
-}
-
-/**********************************************************************
- **********************************************************************/
-void osmtest_construct(IN osmtest_t * const p_osmt)
-{
- memset(p_osmt, 0, sizeof(*p_osmt));
- osm_log_construct(&p_osmt->log);
- subnet_construct(&p_osmt->exp_subn);
-}
-
-/**********************************************************************
- **********************************************************************/
-void osmtest_destroy(IN osmtest_t * const p_osmt)
-{
- cl_map_item_t *p_item, *p_next_item;
-
- /* Currently there is a problem with IBAL exit flow - memory overrun,
- so bypass vendor deletion - it will be cleaned by the Windows OS */
-#ifndef __WIN__
- if (p_osmt->p_vendor)
- osm_vendor_delete(&p_osmt->p_vendor);
-#endif
-
- cl_qpool_destroy(&p_osmt->port_pool);
- cl_qpool_destroy(&p_osmt->node_pool);
-
- /* destroy the qmap tables */
- p_next_item = cl_qmap_head(&p_osmt->exp_subn.link_tbl);
- while (p_next_item != cl_qmap_end(&p_osmt->exp_subn.link_tbl)) {
- p_item = p_next_item;
- p_next_item = cl_qmap_next(p_item);
- free(p_item);
- }
- p_next_item = cl_qmap_head(&p_osmt->exp_subn.mgrp_mlid_tbl);
- while (p_next_item != cl_qmap_end(&p_osmt->exp_subn.mgrp_mlid_tbl)) {
- p_item = p_next_item;
- p_next_item = cl_qmap_next(p_item);
- free(p_item);
- }
- p_next_item = cl_qmap_head(&p_osmt->exp_subn.node_guid_tbl);
- while (p_next_item != cl_qmap_end(&p_osmt->exp_subn.node_guid_tbl)) {
- p_item = p_next_item;
- p_next_item = cl_qmap_next(p_item);
- free(p_item);
- }
-
- p_next_item = cl_qmap_head(&p_osmt->exp_subn.node_lid_tbl);
- while (p_next_item != cl_qmap_end(&p_osmt->exp_subn.node_lid_tbl)) {
- p_item = p_next_item;
- p_next_item = cl_qmap_next(p_item);
- free(p_item);
- }
-
- p_next_item = cl_qmap_head(&p_osmt->exp_subn.path_tbl);
- while (p_next_item != cl_qmap_end(&p_osmt->exp_subn.path_tbl)) {
- p_item = p_next_item;
- p_next_item = cl_qmap_next(p_item);
- free(p_item);
- }
- p_next_item = cl_qmap_head(&p_osmt->exp_subn.port_key_tbl);
- while (p_next_item != cl_qmap_end(&p_osmt->exp_subn.port_key_tbl)) {
- p_item = p_next_item;
- p_next_item = cl_qmap_next(p_item);
- free(p_item);
- }
-
- osm_log_destroy(&p_osmt->log);
-}
-
-/**********************************************************************
- **********************************************************************/
-ib_api_status_t
-osmtest_init(IN osmtest_t * const p_osmt,
- IN const osmtest_opt_t * const p_opt,
- IN const osm_log_level_t log_flags)
-{
- ib_api_status_t status;
-
- /* Can't use log macros here, since we're initializing the log. */
- osmtest_construct(p_osmt);
-
- status = osm_log_init_v2(&p_osmt->log, p_opt->force_log_flush,
- 0x0001, p_opt->log_file, 0, TRUE);
- if (status != IB_SUCCESS)
- return (status);
-
- /* but we do not want any extra stuff here */
- osm_log_set_level(&p_osmt->log, log_flags);
-
- OSM_LOG(&p_osmt->log, OSM_LOG_FUNCS, "[\n");
-
- p_osmt->opt = *p_opt;
-
- status = cl_qpool_init(&p_osmt->node_pool, POOL_MIN_ITEMS, 0,
- POOL_MIN_ITEMS, sizeof(node_t), NULL, NULL,
- NULL);
- CL_ASSERT(status == CL_SUCCESS);
-
- status = cl_qpool_init(&p_osmt->port_pool, POOL_MIN_ITEMS, 0,
- POOL_MIN_ITEMS, sizeof(port_t), NULL, NULL,
- NULL);
- CL_ASSERT(status == CL_SUCCESS);
-
- p_osmt->p_vendor = osm_vendor_new(&p_osmt->log,
- p_opt->transaction_timeout);
-
- if (p_osmt->p_vendor == NULL) {
- status = IB_INSUFFICIENT_RESOURCES;
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0001: "
- "Unable to allocate vendor object");
- status = IB_ERROR;
- goto Exit;
- }
-
- osm_mad_pool_construct(&p_osmt->mad_pool);
- status = osm_mad_pool_init(&p_osmt->mad_pool);
- if (status != IB_SUCCESS)
- goto Exit;
-
-Exit:
- OSM_LOG(&p_osmt->log, OSM_LOG_FUNCS, "]\n");
- return (status);
-}
-
-/**********************************************************************
- **********************************************************************/
-void osmtest_query_res_cb(IN osmv_query_res_t * p_rec)
-{
- osmtest_req_context_t *const p_ctxt =
- (osmtest_req_context_t *) p_rec->query_context;
- osmtest_t *const p_osmt = p_ctxt->p_osmt;
-
- OSM_LOG_ENTER(&p_osmt->log);
-
- p_ctxt->result = *p_rec;
-
- if (p_rec->status != IB_SUCCESS) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0003: "
- "Error on query (%s)\n", ib_get_err_str(p_rec->status));
- }
-
- OSM_LOG_EXIT(&p_osmt->log);
-}
-
-/**********************************************************************
- **********************************************************************/
-ib_api_status_t
-osmtest_get_all_recs(IN osmtest_t * const p_osmt,
- IN ib_net16_t const attr_id,
- IN size_t const attr_size,
- IN OUT osmtest_req_context_t * const p_context)
-{
- ib_api_status_t status = IB_SUCCESS;
- osmv_user_query_t user;
- osmv_query_req_t req;
-
- OSM_LOG_ENTER(&p_osmt->log);
-
- OSM_LOG(&p_osmt->log, OSM_LOG_DEBUG, "Getting all %s records\n",
- ib_get_sa_attr_str(attr_id));
-
- /*
- * Do a blocking query for all <attr_id> records in the subnet.
- * The result is returned in the result field of the caller's
- * context structure.
- *
- * The query structures are locals.
- */
- memset(&req, 0, sizeof(req));
- memset(&user, 0, sizeof(user));
-
- p_context->p_osmt = p_osmt;
- user.attr_id = attr_id;
- user.attr_offset = cl_ntoh16((uint16_t) (attr_size >> 3));
-
- req.query_type = OSMV_QUERY_USER_DEFINED;
- req.timeout_ms = p_osmt->opt.transaction_timeout;
- req.retry_cnt = p_osmt->opt.retry_count;
- req.flags = OSM_SA_FLAGS_SYNC;
- req.query_context = p_context;
- req.pfn_query_cb = osmtest_query_res_cb;
- req.p_query_input = &user;
- req.sm_key = 0;
-
- status = osmv_query_sa(p_osmt->h_bind, &req);
- if (status != IB_SUCCESS) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0004: "
- "ib_query failed (%s)\n", ib_get_err_str(status));
- goto Exit;
- }
-
- status = p_context->result.status;
-
- if (status != IB_SUCCESS) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0064: "
- "ib_query failed (%s)\n", ib_get_err_str(status));
-
- if (status == IB_REMOTE_ERROR) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR,
- "Remote error = %s\n",
- ib_get_mad_status_str(osm_madw_get_mad_ptr
- (p_context->result.
- p_result_madw)));
- }
- goto Exit;
- }
-
-Exit:
- OSM_LOG_EXIT(&p_osmt->log);
- return (status);
-}
-
-/**********************************************************************
- **********************************************************************/
-ib_api_status_t osmtest_validate_sa_class_port_info(IN osmtest_t * const p_osmt)
-{
- ib_api_status_t status = IB_SUCCESS;
- osmv_query_req_t req;
- ib_class_port_info_t *p_cpi;
- osmtest_req_context_t context;
- osmtest_req_context_t *p_context = &context;
- ib_sa_mad_t *p_resp_sa_madp;
-
- OSM_LOG_ENTER(&p_osmt->log);
-
- OSM_LOG(&p_osmt->log, OSM_LOG_VERBOSE, "Getting ClassPortInfo\n");
-
- /*
- * Do a blocking query for this record in the subnet.
- * The result is returned in the result field of the caller's
- * context structure.
- *
- * The query structures are locals.
- */
- memset(&req, 0, sizeof(req));
-
- p_context->p_osmt = p_osmt;
- req.query_type = OSMV_QUERY_CLASS_PORT_INFO;
- req.timeout_ms = p_osmt->opt.transaction_timeout;
- req.retry_cnt = p_osmt->opt.retry_count;
- req.flags = OSM_SA_FLAGS_SYNC;
- req.query_context = p_context;
- req.pfn_query_cb = osmtest_query_res_cb;
- req.p_query_input = 0;
- req.sm_key = 0;
-
- status = osmv_query_sa(p_osmt->h_bind, &req);
- if (status != IB_SUCCESS) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0065: "
- "ib_query failed (%s)\n", ib_get_err_str(status));
- goto Exit;
- }
-
- status = p_context->result.status;
-
- if (status != IB_SUCCESS) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0070: "
- "ib_query failed (%s)\n", ib_get_err_str(status));
- if (status == IB_REMOTE_ERROR) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR,
- "Remote error = %s\n",
- ib_get_mad_status_str(osm_madw_get_mad_ptr
- (p_context->result.
- p_result_madw)));
- }
- goto Exit;
- }
-
- /* ok we got it so please print it out */
- p_resp_sa_madp =
- (ib_sa_mad_t *) osm_madw_get_mad_ptr(context.result.p_result_madw);
- p_cpi =
- (ib_class_port_info_t *) ib_sa_mad_get_payload_ptr(p_resp_sa_madp);
-
- OSM_LOG(&p_osmt->log, OSM_LOG_INFO,
- "\n-----------------------------\n"
- "SA Class Port Info:\n"
- " base_ver:%u\n"
- " class_ver:%u\n"
- " cap_mask:0x%X\n"
- " cap_mask2:0x%X\n"
- " resp_time_val:0x%X\n"
- "-----------------------------\n",
- p_cpi->base_ver, p_cpi->class_ver, cl_ntoh16(p_cpi->cap_mask),
- ib_class_cap_mask2(p_cpi), ib_class_resp_time_val(p_cpi));
-
-Exit:
-#if 0
- if (context.result.p_result_madw != NULL) {
- osm_mad_pool_put(&p_osmt->mad_pool,
- context.result.p_result_madw);
- context.result.p_result_madw = NULL;
- }
-#endif
-
- OSM_LOG_EXIT(&p_osmt->log);
- return (status);
-}
-
-/**********************************************************************
- **********************************************************************/
-ib_api_status_t
-osmtest_get_node_rec(IN osmtest_t * const p_osmt,
- IN ib_net64_t const node_guid,
- IN OUT osmtest_req_context_t * const p_context)
-{
- ib_api_status_t status = IB_SUCCESS;
- osmv_user_query_t user;
- osmv_query_req_t req;
- ib_node_record_t record;
-
- OSM_LOG_ENTER(&p_osmt->log);
-
- OSM_LOG(&p_osmt->log, OSM_LOG_VERBOSE,
- "Getting node record for 0x%016" PRIx64 "\n",
- cl_ntoh64(node_guid));
-
- /*
- * Do a blocking query for this record in the subnet.
- * The result is returned in the result field of the caller's
- * context structure.
- *
- * The query structures are locals.
- */
- memset(&req, 0, sizeof(req));
- memset(&user, 0, sizeof(user));
- memset(&record, 0, sizeof(record));
-
- record.node_info.node_guid = node_guid;
-
- p_context->p_osmt = p_osmt;
- user.comp_mask = IB_NR_COMPMASK_NODEGUID;
- user.attr_id = IB_MAD_ATTR_NODE_RECORD;
- user.attr_offset = cl_ntoh16((uint16_t) (sizeof(record) >> 3));
- user.p_attr = &record;
-
- req.query_type = OSMV_QUERY_USER_DEFINED;
- req.timeout_ms = p_osmt->opt.transaction_timeout;
- req.retry_cnt = p_osmt->opt.retry_count;
- req.flags = OSM_SA_FLAGS_SYNC;
- req.query_context = p_context;
- req.pfn_query_cb = osmtest_query_res_cb;
- req.p_query_input = &user;
- req.sm_key = 0;
-
- status = osmv_query_sa(p_osmt->h_bind, &req);
- if (status != IB_SUCCESS) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0071: "
- "ib_query failed (%s)\n", ib_get_err_str(status));
- goto Exit;
- }
-
- status = p_context->result.status;
-
- if (status != IB_SUCCESS) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0072: "
- "ib_query failed (%s)\n", ib_get_err_str(status));
- if (status == IB_REMOTE_ERROR) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR,
- "Remote error = %s\n",
- ib_get_mad_status_str(osm_madw_get_mad_ptr
- (p_context->result.
- p_result_madw)));
- }
- goto Exit;
- }
-
-Exit:
- OSM_LOG_EXIT(&p_osmt->log);
- return (status);
-}
-
-/**********************************************************************
- * Get a node record by node LID
- **********************************************************************/
-ib_api_status_t
-osmtest_get_node_rec_by_lid(IN osmtest_t * const p_osmt,
- IN ib_net16_t const lid,
- IN OUT osmtest_req_context_t * const p_context)
-{
- ib_api_status_t status = IB_SUCCESS;
- osmv_user_query_t user;
- osmv_query_req_t req;
- ib_node_record_t record;
- ib_mad_t *p_mad;
-
- OSM_LOG_ENTER(&p_osmt->log);
-
- OSM_LOG(&p_osmt->log, OSM_LOG_VERBOSE,
- "Getting node record for LID 0x%02X\n", cl_ntoh16(lid));
-
- /*
- * Do a blocking query for this record in the subnet.
- * The result is returned in the result field of the caller's
- * context structure.
- *
- * The query structures are locals.
- */
- memset(&req, 0, sizeof(req));
- memset(&user, 0, sizeof(user));
- memset(&record, 0, sizeof(record));
-
- record.lid = lid;
-
- p_context->p_osmt = p_osmt;
- user.comp_mask = IB_NR_COMPMASK_LID;
- user.attr_id = IB_MAD_ATTR_NODE_RECORD;
- user.attr_offset = cl_ntoh16((uint16_t) (sizeof(record) >> 3));
- user.p_attr = &record;
-
- req.query_type = OSMV_QUERY_USER_DEFINED;
- req.timeout_ms = p_osmt->opt.transaction_timeout;
- req.retry_cnt = p_osmt->opt.retry_count;
- req.flags = OSM_SA_FLAGS_SYNC;
- req.query_context = p_context;
- req.pfn_query_cb = osmtest_query_res_cb;
- req.p_query_input = &user;
- req.sm_key = 0;
-
- status = osmv_query_sa(p_osmt->h_bind, &req);
- if (status != IB_SUCCESS) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0073: "
- "ib_query failed (%s)\n", ib_get_err_str(status));
- goto Exit;
- }
-
- status = p_context->result.status;
-
- if (status != IB_SUCCESS) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0074: "
- "ib_query failed (%s)\n", ib_get_err_str(status));
- if (status == IB_REMOTE_ERROR) {
- p_mad =
- osm_madw_get_mad_ptr(p_context->result.
- p_result_madw);
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR,
- "Remote error = %s\n",
- ib_get_mad_status_str(p_mad));
-
- status =
- (ib_net16_t) (p_mad->status & IB_SMP_STATUS_MASK);
- }
- goto Exit;
- }
-
-Exit:
- OSM_LOG_EXIT(&p_osmt->log);
- return (status);
-}
-
-/**********************************************************************
- **********************************************************************/
-static ib_api_status_t
-osmtest_get_path_rec_by_guid_pair(IN osmtest_t * const p_osmt,
- IN ib_net64_t sguid,
- IN ib_net64_t dguid,
- IN osmtest_req_context_t * p_context)
-{
- cl_status_t status = IB_SUCCESS;
- osmv_query_req_t req;
- osmv_guid_pair_t guid_pair;
-
- OSM_LOG_ENTER(&p_osmt->log);
-
- memset(&req, 0, sizeof(req));
- memset(p_context, 0, sizeof(*p_context));
-
- p_context->p_osmt = p_osmt;
- req.timeout_ms = p_osmt->opt.transaction_timeout;
- req.retry_cnt = p_osmt->opt.retry_count;
- req.flags = OSM_SA_FLAGS_SYNC;
- req.query_context = p_context;
- req.pfn_query_cb = osmtest_query_res_cb;
-
- req.query_type = OSMV_QUERY_PATH_REC_BY_PORT_GUIDS;
-
- guid_pair.dest_guid = dguid;
- guid_pair.src_guid = sguid;
-
- req.p_query_input = &guid_pair;
- req.sm_key = 0;
-
- OSM_LOG(&p_osmt->log, OSM_LOG_VERBOSE,
- "Query for path from 0x%" PRIx64 " to 0x%" PRIx64 "\n",
- sguid, dguid);
-
- status = osmv_query_sa(p_osmt->h_bind, &req);
- if (status != IB_SUCCESS) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0063: "
- "ib_query failed (%s)\n", ib_get_err_str(status));
- goto Exit;
- }
-
- status = (*p_context).result.status;
-
- if (status != IB_SUCCESS) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0066: "
- "ib_query failed (%s)\n", ib_get_err_str(status));
-
- if (status == IB_REMOTE_ERROR) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR,
- "Remote error = %s\n",
- ib_get_mad_status_str(osm_madw_get_mad_ptr
- ((*p_context).result.
- p_result_madw)));
- }
- goto Exit;
- }
-
-Exit:
-
- OSM_LOG_EXIT(&p_osmt->log);
- return (status);
-}
-
-/**********************************************************************
- **********************************************************************/
-static ib_api_status_t
-osmtest_get_path_rec_by_gid_pair(IN osmtest_t * const p_osmt,
- IN ib_gid_t sgid,
- IN ib_gid_t dgid,
- IN osmtest_req_context_t * p_context)
-{
- cl_status_t status = IB_SUCCESS;
- osmv_query_req_t req;
- osmv_gid_pair_t gid_pair;
-
- OSM_LOG_ENTER(&p_osmt->log);
-
- memset(&req, 0, sizeof(req));
- memset(p_context, 0, sizeof(*p_context));
-
- p_context->p_osmt = p_osmt;
- req.timeout_ms = p_osmt->opt.transaction_timeout;
- req.retry_cnt = p_osmt->opt.retry_count;
- req.flags = OSM_SA_FLAGS_SYNC;
- req.query_context = p_context;
- req.pfn_query_cb = osmtest_query_res_cb;
-
- req.query_type = OSMV_QUERY_PATH_REC_BY_GIDS;
-
- gid_pair.dest_gid = dgid;
- gid_pair.src_gid = sgid;
-
- req.p_query_input = &gid_pair;
- req.sm_key = 0;
-
- OSM_LOG(&p_osmt->log, OSM_LOG_VERBOSE,
- "Query for path from 0x%016" PRIx64 " 0x%016" PRIx64
- " to 0x%016" PRIx64 " 0x%016" PRIx64 "\n", sgid.unicast.prefix,
- sgid.unicast.interface_id, dgid.unicast.prefix,
- dgid.unicast.interface_id);
-
- status = osmv_query_sa(p_osmt->h_bind, &req);
- if (status != IB_SUCCESS) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 006A: "
- "ib_query failed (%s)\n", ib_get_err_str(status));
- goto Exit;
- }
-
- status = (*p_context).result.status;
-
- if (status != IB_SUCCESS) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 006B: "
- "ib_query failed (%s)\n", ib_get_err_str(status));
-
- if (status == IB_REMOTE_ERROR) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR,
- "Remote error = %s\n",
- ib_get_mad_status_str(osm_madw_get_mad_ptr
- ((*p_context).result.
- p_result_madw)));
- }
- goto Exit;
- }
-
-Exit:
-
- OSM_LOG_EXIT(&p_osmt->log);
- return (status);
-}
-
-#if defined (VENDOR_RMPP_SUPPORT) && defined (DUAL_SIDED_RMPP)
-/**********************************************************************
- **********************************************************************/
-static ib_api_status_t
-osmtest_get_multipath_rec(IN osmtest_t * const p_osmt,
- IN osmv_multipath_req_t * p_request,
- IN osmtest_req_context_t * p_context)
-{
- cl_status_t status = IB_SUCCESS;
- osmv_query_req_t req;
-
- OSM_LOG_ENTER(&p_osmt->log);
-
- /*
- * Do a blocking query for this record in the subnet.
- * The result is returned in the result field of the caller's
- * context structure.
- *
- * The query structures are locals.
- */
- memset(&req, 0, sizeof(req));
-
- p_context->p_osmt = p_osmt;
- req.timeout_ms = p_osmt->opt.transaction_timeout;
- req.retry_cnt = p_osmt->opt.retry_count;
- req.flags = OSM_SA_FLAGS_SYNC;
- req.query_context = p_context;
- req.pfn_query_cb = osmtest_query_res_cb;
-
- req.query_type = OSMV_QUERY_MULTIPATH_REC;
-
- req.p_query_input = p_request;
- req.sm_key = 0;
-
- status = osmv_query_sa(p_osmt->h_bind, &req);
- if (status != IB_SUCCESS) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0068: "
- "ib_query failed (%s)\n", ib_get_err_str(status));
- goto Exit;
- }
-
- status = p_context->result.status;
-
- if (status != IB_SUCCESS) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0069: "
- "ib_query failed (%s)\n", ib_get_err_str(status));
-
- if (status == IB_REMOTE_ERROR) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR,
- "Remote error = %s\n",
- ib_get_mad_status_str(osm_madw_get_mad_ptr
- (p_context->result.
- p_result_madw)));
- }
- goto Exit;
- }
-
-Exit:
- OSM_LOG_EXIT(&p_osmt->log);
- return (status);
-}
-#endif
-
-/**********************************************************************
- **********************************************************************/
-ib_api_status_t
-osmtest_get_port_rec(IN osmtest_t * const p_osmt,
- IN ib_net16_t const lid,
- IN OUT osmtest_req_context_t * const p_context)
-{
- ib_api_status_t status = IB_SUCCESS;
- osmv_user_query_t user;
- osmv_query_req_t req;
- ib_portinfo_record_t record;
-
- OSM_LOG_ENTER(&p_osmt->log);
-
- OSM_LOG(&p_osmt->log, OSM_LOG_DEBUG,
- "Getting PortInfoRecord for port with LID 0x%X\n",
- cl_ntoh16(lid));
-
- /*
- * Do a blocking query for this record in the subnet.
- * The result is returned in the result field of the caller's
- * context structure.
- *
- * The query structures are locals.
- */
- memset(&req, 0, sizeof(req));
- memset(&user, 0, sizeof(user));
- memset(&record, 0, sizeof(record));
-
- record.lid = lid;
-
- p_context->p_osmt = p_osmt;
- user.comp_mask = IB_PIR_COMPMASK_LID;
- user.attr_id = IB_MAD_ATTR_PORTINFO_RECORD;
- user.attr_offset = cl_ntoh16((uint16_t) (sizeof(record) >> 3));
- user.p_attr = &record;
-
- req.query_type = OSMV_QUERY_USER_DEFINED;
- req.timeout_ms = p_osmt->opt.transaction_timeout;
- req.retry_cnt = p_osmt->opt.retry_count;
- req.flags = OSM_SA_FLAGS_SYNC;
- req.query_context = p_context;
- req.pfn_query_cb = osmtest_query_res_cb;
- req.p_query_input = &user;
- req.sm_key = 0;
-
- status = osmv_query_sa(p_osmt->h_bind, &req);
- if (status != IB_SUCCESS) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0075: "
- "ib_query failed (%s)\n", ib_get_err_str(status));
- goto Exit;
- }
-
- status = p_context->result.status;
-
- if (status != IB_SUCCESS) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0076: "
- "ib_query failed (%s)\n", ib_get_err_str(status));
-
- if (status == IB_REMOTE_ERROR) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR,
- "Remote error = %s\n",
- ib_get_mad_status_str(osm_madw_get_mad_ptr
- (p_context->result.
- p_result_madw)));
- }
- goto Exit;
- }
-
-Exit:
- OSM_LOG_EXIT(&p_osmt->log);
- return (status);
-}
-
-/**********************************************************************
- **********************************************************************/
-ib_api_status_t
-osmtest_get_port_rec_by_num(IN osmtest_t * const p_osmt,
- IN ib_net16_t const lid,
- IN uint8_t const port_num,
- IN OUT osmtest_req_context_t * const p_context)
-{
- ib_api_status_t status = IB_SUCCESS;
- osmv_user_query_t user;
- osmv_query_req_t req;
- ib_portinfo_record_t record;
- ib_mad_t *p_mad;
-
- OSM_LOG_ENTER(&p_osmt->log);
-
- OSM_LOG(&p_osmt->log, OSM_LOG_DEBUG,
- "Getting PortInfoRecord for port with LID 0x%X Num:0x%X\n",
- cl_ntoh16(lid), port_num);
-
- /*
- * Do a blocking query for this record in the subnet.
- * The result is returned in the result field of the caller's
- * context structure.
- *
- * The query structures are locals.
- */
- memset(&req, 0, sizeof(req));
- memset(&user, 0, sizeof(user));
- memset(&record, 0, sizeof(record));
-
- record.lid = lid;
- record.port_num = port_num;
- user.p_attr = &record;
-
- p_context->p_osmt = p_osmt;
-
- req.query_type = OSMV_QUERY_PORT_REC_BY_LID_AND_NUM;
- req.timeout_ms = p_osmt->opt.transaction_timeout;
- req.retry_cnt = p_osmt->opt.retry_count;
- req.flags = OSM_SA_FLAGS_SYNC;
- req.query_context = p_context;
- req.pfn_query_cb = osmtest_query_res_cb;
- req.p_query_input = &user;
- req.sm_key = 0;
-
- status = osmv_query_sa(p_osmt->h_bind, &req);
- if (status != IB_SUCCESS) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0077: "
- "ib_query failed (%s)\n", ib_get_err_str(status));
- goto Exit;
- }
-
- status = p_context->result.status;
-
- if (status != IB_SUCCESS) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0078: "
- "ib_query failed (%s)\n", ib_get_err_str(status));
-
- if (status == IB_REMOTE_ERROR) {
- p_mad =
- osm_madw_get_mad_ptr(p_context->result.
- p_result_madw);
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR,
- "Remote error = %s\n",
- ib_get_mad_status_str(p_mad));
- status =
- (ib_net16_t) (p_mad->status & IB_SMP_STATUS_MASK);
- }
- goto Exit;
- }
-
-Exit:
- OSM_LOG_EXIT(&p_osmt->log);
- return (status);
-}
-
-/**********************************************************************
- **********************************************************************/
-ib_api_status_t
-osmtest_stress_port_recs_large(IN osmtest_t * const p_osmt,
- OUT uint32_t * const p_num_recs,
- OUT uint32_t * const p_num_queries)
-{
- osmtest_req_context_t context;
- ib_portinfo_record_t *p_rec;
- uint32_t i;
- cl_status_t status;
- uint32_t num_recs = 0;
-
- OSM_LOG_ENTER(&p_osmt->log);
-
- memset(&context, 0, sizeof(context));
- /*
- * Do a blocking query for all PortInfoRecords in the subnet.
- */
- status = osmtest_get_all_recs(p_osmt, IB_MAD_ATTR_PORTINFO_RECORD,
- sizeof(*p_rec), &context);
-
- if (status != IB_SUCCESS) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0006: "
- "osmtest_get_all_recs failed (%s)\n",
- ib_get_err_str(status));
- goto Exit;
- }
-
- /*
- * Populate the database with the received records.
- */
- num_recs = context.result.result_cnt;
- *p_num_recs += num_recs;
- ++*p_num_queries;
-
- if (osm_log_is_active(&p_osmt->log, OSM_LOG_VERBOSE)) {
- OSM_LOG(&p_osmt->log, OSM_LOG_VERBOSE,
- "Received %u records\n", num_recs);
-
- for (i = 0; i < num_recs; i++) {
- p_rec =
- osmv_get_query_portinfo_rec(context.result.
- p_result_madw, i);
- osm_dump_portinfo_record(&p_osmt->log, p_rec,
- OSM_LOG_VERBOSE);
- }
- }
-
-Exit:
- /*
- * Return the IB query MAD to the pool as necessary.
- */
- if (context.result.p_result_madw != NULL) {
- osm_mad_pool_put(&p_osmt->mad_pool,
- context.result.p_result_madw);
- context.result.p_result_madw = NULL;
- }
-
- OSM_LOG_EXIT(&p_osmt->log);
- return (status);
-}
-
-/**********************************************************************
- **********************************************************************/
-ib_api_status_t
-osmtest_stress_node_recs_large(IN osmtest_t * const p_osmt,
- OUT uint32_t * const p_num_recs,
- OUT uint32_t * const p_num_queries)
-{
- osmtest_req_context_t context;
- ib_node_record_t *p_rec;
- uint32_t i;
- cl_status_t status;
- uint32_t num_recs = 0;
-
- OSM_LOG_ENTER(&p_osmt->log);
-
- memset(&context, 0, sizeof(context));
-
- /*
- * Do a blocking query for all NodeRecords in the subnet.
- */
- status = osmtest_get_all_recs(p_osmt, IB_MAD_ATTR_NODE_RECORD,
- sizeof(*p_rec), &context);
-
- if (status != IB_SUCCESS) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0007: "
- "osmtest_get_all_recs failed (%s)\n",
- ib_get_err_str(status));
- goto Exit;
- }
-
- /*
- * Populate the database with the received records.
- */
- num_recs = context.result.result_cnt;
- *p_num_recs += num_recs;
- ++*p_num_queries;
-
- if (osm_log_is_active(&p_osmt->log, OSM_LOG_VERBOSE)) {
- OSM_LOG(&p_osmt->log, OSM_LOG_VERBOSE,
- "Received %u records\n", num_recs);
-
- for (i = 0; i < num_recs; i++) {
- p_rec =
- osmv_get_query_node_rec(context.result.
- p_result_madw, i);
- osm_dump_node_record(&p_osmt->log, p_rec,
- OSM_LOG_VERBOSE);
- }
- }
-
-Exit:
- /*
- * Return the IB query MAD to the pool as necessary.
- */
- if (context.result.p_result_madw != NULL) {
- osm_mad_pool_put(&p_osmt->mad_pool,
- context.result.p_result_madw);
- context.result.p_result_madw = NULL;
- }
-
- OSM_LOG_EXIT(&p_osmt->log);
- return (status);
-}
-
-/**********************************************************************
- **********************************************************************/
-ib_api_status_t
-osmtest_stress_path_recs_large(IN osmtest_t * const p_osmt,
- OUT uint32_t * const p_num_recs,
- OUT uint32_t * const p_num_queries)
-{
- osmtest_req_context_t context;
- ib_path_rec_t *p_rec;
- uint32_t i;
- cl_status_t status;
- uint32_t num_recs = 0;
-
- OSM_LOG_ENTER(&p_osmt->log);
-
- memset(&context, 0, sizeof(context));
-
- /*
- * Do a blocking query for all PathRecords in the subnet.
- */
- status = osmtest_get_all_recs(p_osmt, IB_MAD_ATTR_PATH_RECORD,
- sizeof(*p_rec), &context);
- if (status != IB_SUCCESS) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0008: "
- "osmtest_get_all_recs failed (%s)\n",
- ib_get_err_str(status));
- goto Exit;
- }
-
- /*
- * Populate the database with the received records.
- */
- num_recs = context.result.result_cnt;
- *p_num_recs += num_recs;
- ++*p_num_queries;
-
- if (osm_log_is_active(&p_osmt->log, OSM_LOG_VERBOSE)) {
- OSM_LOG(&p_osmt->log, OSM_LOG_VERBOSE,
- "Received %u records\n", num_recs);
-
- for (i = 0; i < num_recs; i++) {
- p_rec =
- osmv_get_query_path_rec(context.result.
- p_result_madw, i);
- osm_dump_path_record(&p_osmt->log, p_rec,
- OSM_LOG_VERBOSE);
- }
- }
-
-Exit:
- /*
- * Return the IB query MAD to the pool as necessary.
- */
- if (context.result.p_result_madw != NULL) {
- osm_mad_pool_put(&p_osmt->mad_pool,
- context.result.p_result_madw);
- context.result.p_result_madw = NULL;
- }
-
- OSM_LOG_EXIT(&p_osmt->log);
- return (status);
-}
-
-/**********************************************************************
- **********************************************************************/
-ib_api_status_t
-osmtest_stress_path_recs_by_guid(IN osmtest_t * const p_osmt,
- OUT uint32_t * const p_num_recs,
- OUT uint32_t * const p_num_queries)
-{
- osmtest_req_context_t context;
- ib_path_rec_t *p_rec;
- uint32_t i;
- cl_status_t status = IB_SUCCESS;
- uint32_t num_recs = 0;
- node_t *p_src_node, *p_dst_node;
- cl_qmap_t *p_tbl;
-
- OSM_LOG_ENTER(&p_osmt->log);
-
- memset(&context, 0, sizeof(context));
-
- context.p_osmt = p_osmt;
-
- p_tbl = &p_osmt->exp_subn.node_guid_tbl;
-
- p_src_node = (node_t *) cl_qmap_head(p_tbl);
-
- /*
- * Go over all nodes that exist in the subnet
- * for each pair that are not switch nodes get the path record
- */
- while (p_src_node != (node_t *) cl_qmap_end(p_tbl)) {
- p_dst_node = (node_t *) cl_qmap_head(p_tbl);
-
- while (p_dst_node != (node_t *) cl_qmap_end(p_tbl)) {
- /*
- * Do a blocking query for CA to CA Path Record
- */
- OSM_LOG(&p_osmt->log, OSM_LOG_VERBOSE,
- "Source : guid = 0x%" PRIx64 " type = %d"
- "Target : guid = 0x%" PRIx64 " type = %d\n",
- cl_ntoh64(p_src_node->rec.node_info.port_guid),
- p_src_node->rec.node_info.node_type,
- cl_ntoh64(p_dst_node->rec.node_info.port_guid),
- p_dst_node->rec.node_info.node_type);
-
- if (p_src_node->rec.node_info.node_type ==
- IB_NODE_TYPE_CA
- && p_dst_node->rec.node_info.node_type ==
- IB_NODE_TYPE_CA) {
- status =
- osmtest_get_path_rec_by_guid_pair(p_osmt,
- p_src_node->
- rec.
- node_info.
- port_guid,
- p_dst_node->
- rec.
- node_info.
- port_guid,
- &context);
-
- /* In a case of TIMEOUT you still can try sending but cant count, maybe its a temporary issue */
- if (status != IB_SUCCESS) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR,
- "ERR 0009: "
- "osmtest_get_path_rec_by_guid_pair failed (%s)\n",
- ib_get_err_str(status));
- if (status != IB_TIMEOUT)
- goto Exit;
- } else {
- /* we might have received several records */
- num_recs = context.result.result_cnt;
- /*
- * Populate the database with the received records.
- */
- *p_num_recs += num_recs;
- ++*p_num_queries;
- OSM_LOG(&p_osmt->log, OSM_LOG_VERBOSE,
- "Received %u records\n", num_recs);
- /* Dont waste time if not VERBOSE and above */
- if (p_osmt->log.level & OSM_LOG_VERBOSE) {
- for (i = 0; i < num_recs; i++) {
- p_rec =
- osmv_get_query_path_rec
- (context.result.
- p_result_madw, i);
- osm_dump_path_record
- (&p_osmt->log,
- p_rec,
- OSM_LOG_VERBOSE);
- }
- }
- }
- if (context.result.p_result_madw != NULL) {
- osm_mad_pool_put(&p_osmt->mad_pool,
- context.result.
- p_result_madw);
- context.result.p_result_madw = NULL;
- }
- }
- /* next one please */
- p_dst_node =
- (node_t *) cl_qmap_next(&p_dst_node->map_item);
- }
-
- p_src_node = (node_t *) cl_qmap_next(&p_src_node->map_item);
- }
-
-Exit:
- OSM_LOG_EXIT(&p_osmt->log);
- return (status);
-}
-
-/**********************************************************************
- **********************************************************************/
-ib_api_status_t
-osmtest_stress_port_recs_small(IN osmtest_t * const p_osmt,
- OUT uint32_t * const p_num_recs,
- OUT uint32_t * const p_num_queries)
-{
- osmtest_req_context_t context;
- ib_portinfo_record_t *p_rec;
- uint32_t i;
- cl_status_t status;
- uint32_t num_recs = 0;
-
- OSM_LOG_ENTER(&p_osmt->log);
-
- memset(&context, 0, sizeof(context));
-
- /*
- * Do a blocking query for our own PortInfoRecord in the subnet.
- */
- status = osmtest_get_port_rec(p_osmt,
- cl_ntoh16(p_osmt->local_port.lid),
- &context);
-
- if (status != IB_SUCCESS) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0010: "
- "osmtest_get_port_rec failed (%s)\n",
- ib_get_err_str(status));
- goto Exit;
- }
-
- /*
- * Populate the database with the received records.
- */
- num_recs = context.result.result_cnt;
- *p_num_recs += num_recs;
- ++*p_num_queries;
-
- if (osm_log_is_active(&p_osmt->log, OSM_LOG_VERBOSE)) {
- OSM_LOG(&p_osmt->log, OSM_LOG_VERBOSE,
- "Received %u records\n", num_recs);
-
- for (i = 0; i < num_recs; i++) {
- p_rec =
- osmv_get_query_portinfo_rec(context.result.
- p_result_madw, i);
- osm_dump_portinfo_record(&p_osmt->log, p_rec,
- OSM_LOG_VERBOSE);
- }
- }
-
-Exit:
- /*
- * Return the IB query MAD to the pool as necessary.
- */
- if (context.result.p_result_madw != NULL) {
- osm_mad_pool_put(&p_osmt->mad_pool,
- context.result.p_result_madw);
- context.result.p_result_madw = NULL;
- }
-
- OSM_LOG_EXIT(&p_osmt->log);
- return (status);
-}
-
-/**********************************************************************
- **********************************************************************/
-ib_api_status_t
-osmtest_get_local_port_lmc(IN osmtest_t * const p_osmt,
- IN ib_net16_t lid, OUT uint8_t * const p_lmc)
-{
- osmtest_req_context_t context;
- ib_portinfo_record_t *p_rec;
- uint32_t i;
- cl_status_t status;
- uint32_t num_recs = 0;
-
- OSM_LOG_ENTER(&p_osmt->log);
-
- memset(&context, 0, sizeof(context));
-
- /*
- * Do a blocking query for our own PortInfoRecord in the subnet.
- */
- status = osmtest_get_port_rec(p_osmt, cl_ntoh16(lid), &context);
-
- if (status != IB_SUCCESS) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 001A: "
- "osmtest_get_port_rec failed (%s)\n",
- ib_get_err_str(status));
- goto Exit;
- }
-
- num_recs = context.result.result_cnt;
-
- OSM_LOG(&p_osmt->log, OSM_LOG_VERBOSE, "Received %u records\n", num_recs);
-
- for (i = 0; i < num_recs; i++) {
- p_rec =
- osmv_get_query_portinfo_rec(context.result.p_result_madw,
- i);
- osm_dump_portinfo_record(&p_osmt->log, p_rec, OSM_LOG_VERBOSE);
- if (p_lmc) {
- *p_lmc = ib_port_info_get_lmc(&p_rec->port_info);
- OSM_LOG(&p_osmt->log, OSM_LOG_DEBUG, "LMC %d\n", *p_lmc);
- }
- }
-
-Exit:
- /*
- * Return the IB query MAD to the pool as necessary.
- */
- if (context.result.p_result_madw != NULL) {
- osm_mad_pool_put(&p_osmt->mad_pool,
- context.result.p_result_madw);
- context.result.p_result_madw = NULL;
- }
-
- OSM_LOG_EXIT(&p_osmt->log);
- return (status);
-}
-
-/**********************************************************************
- * Use a wrong SM_Key in a simple port query and report success if
- * failed.
- **********************************************************************/
-ib_api_status_t osmtest_wrong_sm_key_ignored(IN osmtest_t * const p_osmt)
-{
- ib_api_status_t status = IB_SUCCESS;
- osmv_user_query_t user;
- osmv_query_req_t req;
- ib_portinfo_record_t record;
- osmtest_req_context_t context;
- osmtest_req_context_t *p_context = &context;
- uint8_t port_num = 1;
-
- OSM_LOG_ENTER(&p_osmt->log);
-
- OSM_LOG(&p_osmt->log, OSM_LOG_INFO,
- "Trying PortInfoRecord for port with LID 0x%X Num:0x%X\n",
- p_osmt->local_port.sm_lid, port_num);
-
- /*
- * Do a blocking query for this record in the subnet.
- * The result is returned in the result field of the caller's
- * context structure.
- *
- * The query structures are locals.
- */
- memset(&req, 0, sizeof(req));
- memset(&user, 0, sizeof(user));
- memset(&record, 0, sizeof(record));
-
- record.lid = p_osmt->local_port.sm_lid;
- record.port_num = port_num;
- user.p_attr = &record;
-
- p_context->p_osmt = p_osmt;
-
- req.query_type = OSMV_QUERY_PORT_REC_BY_LID_AND_NUM;
- req.timeout_ms = p_osmt->opt.transaction_timeout;
- req.retry_cnt = p_osmt->opt.retry_count;
- req.flags = OSM_SA_FLAGS_SYNC;
- req.query_context = p_context;
- req.pfn_query_cb = osmtest_query_res_cb;
- req.p_query_input = &user;
- req.sm_key = 9999;
- context.result.p_result_madw = NULL;
-
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, EXPECTING_ERRORS_START "\n");
- status = osmv_query_sa(p_osmt->h_bind, &req);
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, EXPECTING_ERRORS_END "\n");
-
- /* since we use a wrong sm_key we should get a timeout */
- if (status != IB_TIMEOUT) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0011: "
- "Did not get a timeout but got (%s)\n",
- ib_get_err_str(status));
- if (status == IB_SUCCESS) {
- /* assign some error value to status, since IB_SUCCESS is a bad rc */
- status = IB_ERROR;
- }
- goto Exit;
- } else {
- status = IB_SUCCESS;
- }
-
-Exit:
- if (context.result.p_result_madw != NULL) {
- osm_mad_pool_put(&p_osmt->mad_pool,
- context.result.p_result_madw);
- context.result.p_result_madw = NULL;
- }
-
- OSM_LOG_EXIT(&p_osmt->log);
- return (status);
-}
-
-/**********************************************************************
- **********************************************************************/
-static ib_api_status_t
-osmtest_write_port_info(IN osmtest_t * const p_osmt,
- IN FILE * fh,
- IN const ib_portinfo_record_t * const p_rec)
-{
- int result;
- cl_status_t status = IB_SUCCESS;
-
- OSM_LOG_ENTER(&p_osmt->log);
-
- result = fprintf(fh,
- "DEFINE_PORT\n"
- "lid 0x%X\n"
- "port_num 0x%X\n"
- "m_key 0x%016" PRIx64 "\n"
- "subnet_prefix 0x%016" PRIx64 "\n"
- "base_lid 0x%X\n"
- "master_sm_base_lid 0x%X\n"
- "capability_mask 0x%X\n"
- "diag_code 0x%X\n"
- "m_key_lease_period 0x%X\n"
- "local_port_num 0x%X\n"
- "link_width_enabled 0x%X\n"
- "link_width_supported 0x%X\n"
- "link_width_active 0x%X\n"
- "link_speed_supported 0x%X\n"
- "port_state %s\n"
- "state_info2 0x%X\n"
- "mpb 0x%X\n"
- "lmc 0x%X\n"
- "link_speed 0x%X\n"
- "mtu_smsl 0x%X\n"
- "vl_cap 0x%X\n"
- "vl_high_limit 0x%X\n"
- "vl_arb_high_cap 0x%X\n"
- "vl_arb_low_cap 0x%X\n"
- "mtu_cap 0x%X\n"
- "vl_stall_life 0x%X\n"
- "vl_enforce 0x%X\n"
- "m_key_violations 0x%X\n"
- "p_key_violations 0x%X\n"
- "q_key_violations 0x%X\n"
- "guid_cap 0x%X\n"
- "subnet_timeout 0x%X\n"
- "resp_time_value 0x%X\n"
- "error_threshold 0x%X\n"
- "END\n\n",
- cl_ntoh16(p_rec->lid),
- p_rec->port_num,
- cl_ntoh64(p_rec->port_info.m_key),
- cl_ntoh64(p_rec->port_info.subnet_prefix),
- cl_ntoh16(p_rec->port_info.base_lid),
- cl_ntoh16(p_rec->port_info.master_sm_base_lid),
- cl_ntoh32(p_rec->port_info.capability_mask),
- cl_ntoh16(p_rec->port_info.diag_code),
- cl_ntoh16(p_rec->port_info.m_key_lease_period),
- p_rec->port_info.local_port_num,
- p_rec->port_info.link_width_enabled,
- p_rec->port_info.link_width_supported,
- p_rec->port_info.link_width_active,
- ib_port_info_get_link_speed_sup(&p_rec->port_info),
- ib_get_port_state_str(ib_port_info_get_port_state
- (&p_rec->port_info)),
- p_rec->port_info.state_info2,
- ib_port_info_get_mpb(&p_rec->port_info),
- ib_port_info_get_lmc(&p_rec->port_info),
- p_rec->port_info.link_speed, p_rec->port_info.mtu_smsl,
- p_rec->port_info.vl_cap,
- p_rec->port_info.vl_high_limit,
- p_rec->port_info.vl_arb_high_cap,
- p_rec->port_info.vl_arb_low_cap,
- p_rec->port_info.mtu_cap,
- p_rec->port_info.vl_stall_life,
- p_rec->port_info.vl_enforce,
- cl_ntoh16(p_rec->port_info.m_key_violations),
- cl_ntoh16(p_rec->port_info.p_key_violations),
- cl_ntoh16(p_rec->port_info.q_key_violations),
- p_rec->port_info.guid_cap,
- ib_port_info_get_timeout(&p_rec->port_info),
- p_rec->port_info.resp_time_value,
- p_rec->port_info.error_threshold);
-
- if (result < 0) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0161: "
- "Write failed\n");
- status = IB_ERROR;
- goto Exit;
- }
-
-Exit:
- OSM_LOG_EXIT(&p_osmt->log);
- return (status);
-}
-
-/**********************************************************************
- **********************************************************************/
-static ib_api_status_t
-osmtest_write_path_info(IN osmtest_t * const p_osmt,
- IN FILE * fh, IN const ib_path_rec_t * const p_rec)
-{
- int result;
- cl_status_t status = IB_SUCCESS;
-
- OSM_LOG_ENTER(&p_osmt->log);
-
- result = fprintf(fh,
- "DEFINE_PATH\n"
- "dgid 0x%016" PRIx64 " 0x%016"
- PRIx64 "\nsgid 0x%016" PRIx64
- " 0x%016" PRIx64 "\ndlid 0x%X\n"
- "slid 0x%X\n"
- "# hop_flow_raw 0x%X\n"
- "# tclass 0x%X\n"
- "# num_path 0x%X\n"
- "pkey 0x%X\n"
- "# sl 0x%X\n"
- "# qos_class 0x%X\n"
- "# mtu 0x%X\n"
- "# rate 0x%X\n"
- "# pkt_life 0x%X\n"
- "# preference 0x%X\n" "END\n\n",
- cl_ntoh64(p_rec->dgid.unicast.prefix),
- cl_ntoh64(p_rec->dgid.unicast.interface_id),
- cl_ntoh64(p_rec->sgid.unicast.prefix),
- cl_ntoh64(p_rec->sgid.unicast.interface_id),
- cl_ntoh16(p_rec->dlid), cl_ntoh16(p_rec->slid),
- cl_ntoh32(p_rec->hop_flow_raw), p_rec->tclass,
- p_rec->num_path, cl_ntoh16(p_rec->pkey),
- ib_path_rec_sl(p_rec), ib_path_rec_qos_class(p_rec),
- p_rec->mtu, p_rec->rate, p_rec->pkt_life,
- p_rec->preference);
-
- if (result < 0) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0162: "
- "Write failed\n");
- status = IB_ERROR;
- goto Exit;
- }
-
-Exit:
- OSM_LOG_EXIT(&p_osmt->log);
- return (status);
-}
-
-/**********************************************************************
- **********************************************************************/
-static ib_api_status_t
-osmtest_write_node_info(IN osmtest_t * const p_osmt,
- IN FILE * fh, IN const ib_node_record_t * const p_rec)
-{
- int result;
- cl_status_t status = IB_SUCCESS;
- char desc[IB_NODE_DESCRIPTION_SIZE + 1];
-
- OSM_LOG_ENTER(&p_osmt->log);
-
- memcpy(desc, p_rec->node_desc.description, IB_NODE_DESCRIPTION_SIZE);
- desc[IB_NODE_DESCRIPTION_SIZE] = '\0';
-
- result = fprintf(fh,
- "DEFINE_NODE\n"
- "lid 0x%X\n"
- "base_version 0x%X\n"
- "class_version 0x%X\n"
- "node_type 0x%X # (%s)\n"
- "num_ports 0x%X\n"
- "sys_guid 0x%016" PRIx64 "\n"
- "node_guid 0x%016" PRIx64 "\n"
- "port_guid 0x%016" PRIx64 "\n"
- "partition_cap 0x%X\n"
- "device_id 0x%X\n"
- "revision 0x%X\n"
- "# port_num 0x%X\n"
- "# vendor_id 0x%X\n"
- "# node_desc %s\n"
- "END\n\n",
- cl_ntoh16(p_rec->lid),
- p_rec->node_info.base_version,
- p_rec->node_info.class_version,
- p_rec->node_info.node_type,
- ib_get_node_type_str(p_rec->node_info.node_type),
- p_rec->node_info.num_ports,
- cl_ntoh64(p_rec->node_info.sys_guid),
- cl_ntoh64(p_rec->node_info.node_guid),
- cl_ntoh64(p_rec->node_info.port_guid),
- cl_ntoh16(p_rec->node_info.partition_cap),
- cl_ntoh16(p_rec->node_info.device_id),
- cl_ntoh32(p_rec->node_info.revision),
- ib_node_info_get_local_port_num(&p_rec->node_info),
- cl_ntoh32(ib_node_info_get_vendor_id
- (&p_rec->node_info)), desc);
-
- if (result < 0) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0163: "
- "Write failed\n");
- status = IB_ERROR;
- goto Exit;
- }
-
-Exit:
- OSM_LOG_EXIT(&p_osmt->log);
- return (status);
-}
-
-/**********************************************************************
- **********************************************************************/
-static ib_api_status_t
-osmtest_write_link(IN osmtest_t * const p_osmt,
- IN FILE * fh, IN const ib_link_record_t * const p_rec)
-{
- int result;
- cl_status_t status = IB_SUCCESS;
-
- OSM_LOG_ENTER(&p_osmt->log);
-
- result = fprintf(fh,
- "DEFINE_LINK\n"
- "from_lid 0x%X\n"
- "from_port_num 0x%X\n"
- "to_port_num 0x%X\n"
- "to_lid 0x%X\n"
- "END\n\n",
- cl_ntoh16(p_rec->from_lid),
- p_rec->from_port_num,
- p_rec->to_port_num, cl_ntoh16(p_rec->to_lid));
-
- if (result < 0) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0164: "
- "Write failed\n");
- status = IB_ERROR;
- goto Exit;
- }
-
-Exit:
- OSM_LOG_EXIT(&p_osmt->log);
- return (status);
-}
-
-/**********************************************************************
- **********************************************************************/
-static ib_api_status_t
-osmtest_write_all_link_recs(IN osmtest_t * const p_osmt, IN FILE * fh)
-{
- osmtest_req_context_t context;
- const ib_link_record_t *p_rec;
- uint32_t i;
- cl_status_t status;
- size_t num_recs;
- int result;
-
- OSM_LOG_ENTER(&p_osmt->log);
-
- memset(&context, 0, sizeof(context));
-
- /*
- * Do a blocking query for all NodeRecords in the subnet.
- */
- status = osmtest_get_all_recs(p_osmt, IB_MAD_ATTR_LINK_RECORD,
- sizeof(*p_rec), &context);
-
- if (status != IB_SUCCESS) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0165: "
- "osmtest_get_all_recs failed (%s)\n",
- ib_get_err_str(status));
- goto Exit;
- }
-
- /*
- * Write the received records out to the file.
- */
- num_recs = context.result.result_cnt;
-
- OSM_LOG(&p_osmt->log, OSM_LOG_VERBOSE,
- "Received %zu records\n", num_recs);
-
- result = fprintf(fh, "#\n" "# Link Records\n" "#\n");
- if (result < 0) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0166: "
- "Write failed\n");
- status = IB_ERROR;
- goto Exit;
- }
-
- for (i = 0; i < num_recs; i++) {
- p_rec =
- (ib_link_record_t *) osmv_get_query_result(context.result.
- p_result_madw,
- i);
-
- osmtest_write_link(p_osmt, fh, p_rec);
- }
-
-Exit:
- /*
- * Return the IB query MAD to the pool as necessary.
- */
- if (context.result.p_result_madw != NULL) {
- osm_mad_pool_put(&p_osmt->mad_pool,
- context.result.p_result_madw);
- context.result.p_result_madw = NULL;
- }
-
- OSM_LOG_EXIT(&p_osmt->log);
- return (status);
-}
-
-/**********************************************************************
- **********************************************************************/
-static ib_api_status_t
-osmtest_get_path_rec_by_lid_pair(IN osmtest_t * const p_osmt,
- IN ib_net16_t slid,
- IN ib_net16_t dlid,
- IN osmtest_req_context_t * p_context)
-{
- cl_status_t status = IB_SUCCESS;
- osmv_query_req_t req;
- osmv_lid_pair_t lid_pair;
-
- OSM_LOG_ENTER(&p_osmt->log);
-
- memset(&req, 0, sizeof(req));
- memset(p_context, 0, sizeof(*p_context));
-
- p_context->p_osmt = p_osmt;
- req.timeout_ms = p_osmt->opt.transaction_timeout;
- req.retry_cnt = p_osmt->opt.retry_count;
- req.flags = OSM_SA_FLAGS_SYNC;
- req.query_context = p_context;
- req.pfn_query_cb = osmtest_query_res_cb;
-
- req.query_type = OSMV_QUERY_PATH_REC_BY_LIDS;
-
- lid_pair.dest_lid = dlid;
- lid_pair.src_lid = slid;
-
- req.p_query_input = &lid_pair;
- req.sm_key = 0;
-
- OSM_LOG(&p_osmt->log, OSM_LOG_VERBOSE,
- "Query for path from 0x%X to 0x%X\n", slid, dlid);
- status = osmv_query_sa(p_osmt->h_bind, &req);
- if (status != IB_SUCCESS) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0053: "
- "ib_query failed (%s)\n", ib_get_err_str(status));
- goto Exit;
- }
-
- status = (*p_context).result.status;
-
- if (status != IB_SUCCESS) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0067: "
- "ib_query failed (%s)\n", ib_get_err_str(status));
-
- if (status == IB_REMOTE_ERROR) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR,
- "Remote error = %s\n",
- ib_get_mad_status_str(osm_madw_get_mad_ptr
- ((*p_context).result.
- p_result_madw)));
- }
- goto Exit;
- }
-
-Exit:
- OSM_LOG_EXIT(&p_osmt->log);
- return (status);
-}
-
-#ifdef VENDOR_RMPP_SUPPORT
-/**********************************************************************
- * ASSUMES RMPP
- **********************************************************************/
-static ib_api_status_t
-osmtest_write_all_node_recs(IN osmtest_t * const p_osmt, IN FILE * fh)
-{
- osmtest_req_context_t context;
- const ib_node_record_t *p_rec;
- uint32_t i;
- cl_status_t status;
- size_t num_recs;
- int result;
-
- OSM_LOG_ENTER(&p_osmt->log);
-
- memset(&context, 0, sizeof(context));
-
- /*
- * Do a blocking query for all NodeRecords in the subnet.
- */
- status = osmtest_get_all_recs(p_osmt, IB_MAD_ATTR_NODE_RECORD,
- sizeof(*p_rec), &context);
-
- if (status != IB_SUCCESS) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0022: "
- "osmtest_get_all_recs failed (%s)\n",
- ib_get_err_str(status));
- goto Exit;
- }
-
- /*
- * Write the received records out to the file.
- */
- num_recs = context.result.result_cnt;
-
- OSM_LOG(&p_osmt->log, OSM_LOG_VERBOSE, "Received %zu records\n", num_recs);
-
- result = fprintf(fh, "#\n" "# Node Records\n" "#\n");
- if (result < 0) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0023: "
- "Write failed\n");
- status = IB_ERROR;
- goto Exit;
- }
-
- for (i = 0; i < num_recs; i++) {
- p_rec =
- osmv_get_query_node_rec(context.result.p_result_madw, i);
- osmtest_write_node_info(p_osmt, fh, p_rec);
- }
-
-Exit:
- /*
- * Return the IB query MAD to the pool as necessary.
- */
- if (context.result.p_result_madw != NULL) {
- osm_mad_pool_put(&p_osmt->mad_pool,
- context.result.p_result_madw);
- context.result.p_result_madw = NULL;
- }
-
- OSM_LOG_EXIT(&p_osmt->log);
- return (status);
-}
-
-/**********************************************************************
- * ASSUMES RMPP
- **********************************************************************/
-static ib_api_status_t
-osmtest_write_all_port_recs(IN osmtest_t * const p_osmt, IN FILE * fh)
-{
- osmtest_req_context_t context;
- const ib_portinfo_record_t *p_rec;
- uint32_t i;
- cl_status_t status;
- size_t num_recs;
- int result;
-
- OSM_LOG_ENTER(&p_osmt->log);
-
- memset(&context, 0, sizeof(context));
-
- /*
- * Do a blocking query for all NodeRecords in the subnet.
- */
- status = osmtest_get_all_recs(p_osmt, IB_MAD_ATTR_PORTINFO_RECORD,
- sizeof(*p_rec), &context);
-
- if (status != IB_SUCCESS) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0167: "
- "osmtest_get_all_recs failed (%s)\n",
- ib_get_err_str(status));
- goto Exit;
- }
-
- /*
- * Write the received records out to the file.
- */
- num_recs = context.result.result_cnt;
-
- OSM_LOG(&p_osmt->log, OSM_LOG_VERBOSE, "Received %zu records\n", num_recs);
-
- result = fprintf(fh, "#\n" "# PortInfo Records\n" "#\n");
- if (result < 0) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0024: "
- "Write failed\n");
- status = IB_ERROR;
- goto Exit;
- }
-
- for (i = 0; i < num_recs; i++) {
- p_rec =
- osmv_get_query_portinfo_rec(context.result.p_result_madw,
- i);
- osmtest_write_port_info(p_osmt, fh, p_rec);
- }
-
-Exit:
- /*
- * Return the IB query MAD to the pool as necessary.
- */
- if (context.result.p_result_madw != NULL) {
- osm_mad_pool_put(&p_osmt->mad_pool,
- context.result.p_result_madw);
- context.result.p_result_madw = NULL;
- }
-
- OSM_LOG_EXIT(&p_osmt->log);
- return (status);
-}
-
-/**********************************************************************
- * ASSUMES RMPP
- **********************************************************************/
-static ib_api_status_t
-osmtest_write_all_path_recs(IN osmtest_t * const p_osmt, IN FILE * fh)
-{
- osmtest_req_context_t context;
- const ib_path_rec_t *p_rec;
- uint32_t i;
- cl_status_t status;
- size_t num_recs;
- int result;
-
- OSM_LOG_ENTER(&p_osmt->log);
-
- memset(&context, 0, sizeof(context));
-
- /*
- * Do a blocking query for all PathRecords in the subnet.
- */
- status = osmtest_get_all_recs(p_osmt, IB_MAD_ATTR_PATH_RECORD,
- sizeof(*p_rec), &context);
-
- if (status != IB_SUCCESS) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0025: "
- "osmtest_get_all_recs failed (%s)\n",
- ib_get_err_str(status));
- goto Exit;
- }
-
- /*
- * Write the received records out to the file.
- */
- num_recs = context.result.result_cnt;
-
- OSM_LOG(&p_osmt->log, OSM_LOG_VERBOSE, "Received %zu records\n", num_recs);
-
- result = fprintf(fh, "#\n" "# Path Records\n" "#\n");
- if (result < 0) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0026: "
- "Write failed\n");
- status = IB_ERROR;
- goto Exit;
- }
-
- for (i = 0; i < num_recs; i++) {
- p_rec =
- osmv_get_query_path_rec(context.result.p_result_madw, i);
- osmtest_write_path_info(p_osmt, fh, p_rec);
- }
-
-Exit:
- /*
- * Return the IB query MAD to the pool as necessary.
- */
- if (context.result.p_result_madw != NULL) {
- osm_mad_pool_put(&p_osmt->mad_pool,
- context.result.p_result_madw);
- context.result.p_result_madw = NULL;
- }
-
- OSM_LOG_EXIT(&p_osmt->log);
- return (status);
-}
-
-#else
-/*
- * NON RMPP BASED QUERY FOR ALL NODES: BASED ON THE MAX LID GIVEN BY THE USER
- */
-static ib_api_status_t
-osmtest_write_all_node_recs(IN osmtest_t * const p_osmt, IN FILE * fh)
-{
- osmtest_req_context_t context;
- node_t *p_node;
- node_t *p_guid_node;
- const ib_node_record_t *p_rec;
- cl_status_t status = CL_SUCCESS;
- int result;
- uint16_t lid;
-
- OSM_LOG_ENTER(&p_osmt->log);
-
- result = fprintf(fh, "#\n" "# Node Records\n" "#\n");
- if (result < 0) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0027: "
- "Write failed\n");
- status = IB_ERROR;
- goto Exit;
- }
-
- /*
- * Go over all LIDs in the range 1 to max_lid and do a
- * NodeRecord query by that lid.
- */
- for (lid = 1; lid <= p_osmt->max_lid; lid++) {
- /* prepare the query context */
- memset(&context, 0, sizeof(context));
-
- status =
- osmtest_get_node_rec_by_lid(p_osmt, cl_ntoh16(lid),
- &context);
- if (status != IB_SUCCESS) {
- if (status != IB_SA_MAD_STATUS_NO_RECORDS) {
- OSM_LOG(&p_osmt->log, OSM_LOG_DEBUG, "ERR 0028: "
- "failed to get node info for LID:0x%02X (%s)\n",
- cl_ntoh16(lid), ib_get_err_str(status));
- goto Exit;
- } else {
- OSM_LOG(&p_osmt->log, OSM_LOG_DEBUG, "WRN 0121: "
- "failed to get node info for LID:0x%02X (%s)\n",
- cl_ntoh16(lid), ib_get_err_str(status));
- status = IB_SUCCESS;
- }
- } else {
- /* OK we got something */
- p_rec =
- osmv_get_query_node_rec(context.result.
- p_result_madw, 0);
- osmtest_write_node_info(p_osmt, fh, p_rec);
-
- /* create a subnet object */
- p_node = node_new();
- CL_ASSERT(p_node != NULL);
-
- /* copy the info to the subnet node object */
- p_node->rec = *p_rec;
-
- cl_qmap_insert(&p_osmt->exp_subn.node_lid_tbl,
- p_node->rec.lid, &p_node->map_item);
-
- p_guid_node = node_new();
- CL_ASSERT(p_guid_node != NULL);
-
- *p_guid_node = *p_node;
-
- cl_qmap_insert(&p_osmt->exp_subn.node_guid_tbl,
- p_guid_node->rec.node_info.node_guid,
- &p_guid_node->map_item);
-
- }
-
- if (context.result.p_result_madw != NULL) {
- osm_mad_pool_put(&p_osmt->mad_pool,
- context.result.p_result_madw);
- context.result.p_result_madw = NULL;
- }
- }
-
-Exit:
- if (context.result.p_result_madw != NULL) {
- osm_mad_pool_put(&p_osmt->mad_pool,
- context.result.p_result_madw);
- context.result.p_result_madw = NULL;
- }
-
- OSM_LOG_EXIT(&p_osmt->log);
- return (status);
-}
-
-/*
- * GET ALL PORT RECORDS IN THE FABRIC -
- * one by one by using the node info received
- */
-static ib_api_status_t
-osmtest_write_all_port_recs(IN osmtest_t * const p_osmt, IN FILE * fh)
-{
- osmtest_req_context_t context;
- const ib_node_record_t *p_node_rec;
- const ib_portinfo_record_t *p_rec;
- uint8_t port_num;
- cl_status_t status = CL_SUCCESS;
- cl_qmap_t *p_tbl;
- node_t *p_node;
- port_t *p_port;
- int result;
-
- OSM_LOG_ENTER(&p_osmt->log);
-
- memset(&context, 0, sizeof(context));
-
- /* print header */
- result = fprintf(fh, "#\n" "# PortInfo Records\n" "#\n");
- if (result < 0) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0029: "
- "Write failed\n");
- status = IB_ERROR;
- goto Exit;
- }
-
- /* use the pre-explored set of nodes */
- p_tbl = &p_osmt->exp_subn.node_lid_tbl;
- p_node = (node_t *) cl_qmap_head(p_tbl);
-
- /*
- * Go over all LIDs in the range 1 to max_lid and do a
- * NodeRecord query by that lid.
- */
- while (p_node != (node_t *) cl_qmap_end(p_tbl)) {
-
- p_node_rec = &(p_node->rec);
-
- /* go through all ports of the node: */
- for (port_num = 0; port_num <= p_node_rec->node_info.num_ports;
- port_num++) {
- /* prepare the query context */
- memset(&context, 0, sizeof(context));
-
- status = osmtest_get_port_rec_by_num(p_osmt,
- p_node_rec->lid,
- port_num,
- &context);
- if (status != IB_SUCCESS) {
- if (status != IB_SA_MAD_STATUS_NO_RECORDS) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR,
- "WRN 0122: "
- "Error encountered getting port info for LID:0x%04X Num:0x%02X (%s)\n",
- p_node_rec->lid, port_num,
- ib_get_err_str(status));
- goto Exit;
- } else {
- OSM_LOG(&p_osmt->log, OSM_LOG_DEBUG,
- "WRN 0123: "
- "failed to get port info for LID:0x%04X Num:0x%02X (%s)\n",
- p_node_rec->lid, port_num,
- ib_get_err_str(status));
- status = IB_SUCCESS;
- }
- } else {
- /* OK we got something */
- p_rec =
- osmv_get_query_portinfo_rec(context.result.
- p_result_madw,
- 0);
- osmtest_write_port_info(p_osmt, fh, p_rec);
-
- /* create a subnet object */
- p_port = port_new();
- CL_ASSERT(p_port != NULL);
-
- /* copy the info to the subnet node object */
- p_port->rec = *p_rec;
-
- cl_qmap_insert(&p_osmt->exp_subn.port_key_tbl,
- port_gen_id(p_node_rec->lid,
- port_num),
- &p_port->map_item);
- }
-
- if (context.result.p_result_madw != NULL) {
- osm_mad_pool_put(&p_osmt->mad_pool,
- context.result.p_result_madw);
- context.result.p_result_madw = NULL;
- }
- }
- p_node = (node_t *) cl_qmap_next(&p_node->map_item);
- }
-
- /* we must set the exist status to avoid abort of the over all algorith */
-
-Exit:
- /*
- * Return the IB query MAD to the pool as necessary.
- */
-
- if (context.result.p_result_madw != NULL) {
- osm_mad_pool_put(&p_osmt->mad_pool,
- context.result.p_result_madw);
- context.result.p_result_madw = NULL;
- }
-
- OSM_LOG_EXIT(&p_osmt->log);
- return (status);
-}
-
-/**********************************************************************
- * ASSUMES NO RMPP
- **********************************************************************/
-static ib_api_status_t
-osmtest_write_all_path_recs(IN osmtest_t * const p_osmt, IN FILE * fh)
-{
- osmtest_req_context_t context;
- const ib_path_rec_t *p_rec;
- cl_status_t status = CL_SUCCESS;
- int num_recs, i;
- cl_qmap_t *p_tbl;
- node_t *p_src_node, *p_dst_node;
- ib_api_status_t got_status = IB_SUCCESS;
-
- OSM_LOG_ENTER(&p_osmt->log);
-
- memset(&context, 0, sizeof(context));
-
- /*
- * Go over all nodes that exist in the subnet
- * for each pair that are not switch nodes get the path record
- */
-
- context.p_osmt = p_osmt;
-
- p_tbl = &p_osmt->exp_subn.node_lid_tbl;
-
- p_src_node = (node_t *) cl_qmap_head(p_tbl);
-
- while (p_src_node != (node_t *) cl_qmap_end(p_tbl)) {
- /* HACK we use capability_mask to know diff a CA node from switch node */
- /* if(p_src_node->rec.node_info.capability_mask ) { */
- p_dst_node = (node_t *) cl_qmap_head(p_tbl);
-
- while (p_dst_node != (node_t *) cl_qmap_end(p_tbl)) {
- /* HACK we use capability_mask to know diff a CA node from switch node */
- /* if (p_dst_node->rec.node_info.capability_mask) { */
-
- /* query for it: */
- status = osmtest_get_path_rec_by_lid_pair(p_osmt,
- p_src_node->
- rec.lid,
- p_dst_node->
- rec.lid,
- &context);
-
- if (status != IB_SUCCESS) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 012D: "
- "failed to get path info from LID:0x%X To LID:0x%X (%s)\n",
- p_src_node->rec.lid,
- p_dst_node->rec.lid,
- ib_get_err_str(status));
- /* remember the first error status */
- got_status =
- (got_status ==
- IB_SUCCESS) ? status : got_status;
- } else {
- /* we might have received several records */
- num_recs = context.result.result_cnt;
- for (i = 0; i < num_recs; i++) {
- p_rec =
- osmv_get_query_path_rec(context.
- result.
- p_result_madw,
- i);
- osmtest_write_path_info(p_osmt, fh,
- p_rec);
- }
- }
-/* } */
-
- if (context.result.p_result_madw != NULL) {
- osm_mad_pool_put(&p_osmt->mad_pool,
- context.result.p_result_madw);
- context.result.p_result_madw = NULL;
- }
-
- /* next one please */
- p_dst_node =
- (node_t *) cl_qmap_next(&p_dst_node->map_item);
- }
-/* } */
-
- p_src_node = (node_t *) cl_qmap_next(&p_src_node->map_item);
- }
-
- if (got_status != IB_SUCCESS)
- status = got_status;
-
- /*
- * Return the IB query MAD to the pool as necessary.
- */
- if (context.result.p_result_madw != NULL) {
- osm_mad_pool_put(&p_osmt->mad_pool,
- context.result.p_result_madw);
- context.result.p_result_madw = NULL;
- }
-
- OSM_LOG_EXIT(&p_osmt->log);
- return (status);
-}
-
-#endif
-
-/**********************************************************************
- **********************************************************************/
-static ib_api_status_t
-osmtest_create_inventory_file(IN osmtest_t * const p_osmt)
-{
- FILE *fh;
- ib_api_status_t status = IB_SUCCESS;
-
- OSM_LOG_ENTER(&p_osmt->log);
-
- fh = fopen(p_osmt->opt.file_name, "w");
- if (fh == NULL) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0079: "
- "Unable to open inventory file (%s)\n",
- p_osmt->opt.file_name);
- status = IB_ERROR;
- goto Exit;
- }
-
- /* HACK: the order is important: nodes ports paths */
- status = osmtest_write_all_node_recs(p_osmt, fh);
- if (status != IB_SUCCESS)
- goto Exit;
-
- status = osmtest_write_all_port_recs(p_osmt, fh);
- if (status != IB_SUCCESS)
- goto Exit;
-
- if (!p_osmt->opt.ignore_path_records) {
- status = osmtest_write_all_path_recs(p_osmt, fh);
- if (status != IB_SUCCESS)
- goto Exit;
- }
-
- status = osmtest_write_all_link_recs(p_osmt, fh);
- if (status != IB_SUCCESS)
- goto Exit;
-
- fclose(fh);
-
-Exit:
- OSM_LOG_EXIT(&p_osmt->log);
- return (status);
-}
-
-/**********************************************************************
- **********************************************************************/
-static ib_api_status_t osmtest_stress_large_rmpp_pr(IN osmtest_t * const p_osmt)
-{
- ib_api_status_t status = IB_SUCCESS;
- uint64_t num_recs = 0;
- uint64_t num_queries = 0;
- uint32_t delta_recs;
- uint32_t delta_queries;
- uint32_t print_freq = 0;
- struct timeval start_tv, end_tv;
- long sec_diff, usec_diff;
- float ratio;
-
- OSM_LOG_ENTER(&p_osmt->log);
- gettimeofday(&start_tv, NULL);
- printf("-I- Start time is : %09ld:%06ld [sec:usec]\n", (long)start_tv.tv_sec,
- (long)start_tv.tv_usec);
-
- while (num_queries < STRESS_LARGE_PR_RMPP_THR) {
- delta_recs = 0;
- delta_queries = 0;
-
- status = osmtest_stress_path_recs_by_guid(p_osmt, &delta_recs,
- &delta_queries);
- if (status != IB_SUCCESS)
- goto Exit;
-
- num_recs += delta_recs;
- num_queries += delta_queries;
-
- print_freq += delta_recs;
- if (print_freq > 10000) {
- gettimeofday(&end_tv, NULL);
- if (end_tv.tv_usec > start_tv.tv_usec) {
- sec_diff = end_tv.tv_sec - start_tv.tv_sec;
- usec_diff = end_tv.tv_usec - start_tv.tv_usec;
- } else {
- sec_diff = end_tv.tv_sec - start_tv.tv_sec - 1;
- usec_diff =
- 1000000 - (start_tv.tv_usec -
- end_tv.tv_usec);
- }
- printf("-I- End time is : %09ld:%06ld [sec:usec]\n",
- (long)end_tv.tv_sec, (long)end_tv.tv_usec);
- printf("-I- Querying %" PRId64
- " Path Record queries CA to CA (rmpp)\n\ttook %04ld:%06ld [sec:usec]\n",
- num_queries, sec_diff, usec_diff);
- if (num_recs == 0)
- ratio = 0;
- else
- ratio = ((float)num_queries / (float)num_recs);
- printf("-I- Queries to Record Ratio is %" PRIu64
- " records, %" PRIu64 " queries : %.2f \n",
- num_recs, num_queries, ratio);
- print_freq = 0;
- }
- }
-
-Exit:
- gettimeofday(&end_tv, NULL);
- printf("-I- End time is : %09ld:%06ld [sec:usec]\n",
- (long)end_tv.tv_sec, (long)end_tv.tv_usec);
- if (end_tv.tv_usec > start_tv.tv_usec) {
- sec_diff = end_tv.tv_sec - start_tv.tv_sec;
- usec_diff = end_tv.tv_usec - start_tv.tv_usec;
- } else {
- sec_diff = end_tv.tv_sec - start_tv.tv_sec - 1;
- usec_diff = 1000000 - (start_tv.tv_usec - end_tv.tv_usec);
- }
-
- printf("-I- Querying %" PRId64
- " Path Record queries (rmpp) took %04ld:%06ld [sec:usec]\n",
- num_queries, sec_diff, usec_diff);
-
- OSM_LOG_EXIT(&p_osmt->log);
- return (status);
-}
-
-/**********************************************************************
- **********************************************************************/
-static ib_api_status_t osmtest_stress_large_rmpp(IN osmtest_t * const p_osmt)
-{
- ib_api_status_t status = IB_SUCCESS;
- uint64_t num_recs = 0;
- uint64_t num_queries = 0;
- uint32_t delta_recs;
- uint32_t delta_queries;
- uint32_t print_freq = 0;
- struct timeval start_tv, end_tv;
- long sec_diff, usec_diff;
-
- OSM_LOG_ENTER(&p_osmt->log);
- gettimeofday(&start_tv, NULL);
- printf("-I- Start time is : %09ld:%06ld [sec:usec]\n", (long)start_tv.tv_sec,
- (long)start_tv.tv_usec);
-
- while (num_queries < STRESS_LARGE_RMPP_THR) {
- delta_recs = 0;
- delta_queries = 0;
-
- status = osmtest_stress_node_recs_large(p_osmt, &delta_recs,
- &delta_queries);
- if (status != IB_SUCCESS)
- goto Exit;
-
- status = osmtest_stress_path_recs_large(p_osmt, &delta_recs,
- &delta_queries);
- if (status != IB_SUCCESS)
- goto Exit;
-
- status = osmtest_stress_port_recs_large(p_osmt, &delta_recs,
- &delta_queries);
- if (status != IB_SUCCESS)
- goto Exit;
-
- num_recs += delta_recs;
- num_queries += delta_queries;
-
- print_freq += delta_recs;
-
- if (print_freq > 100000) {
- gettimeofday(&end_tv, NULL);
- if (end_tv.tv_usec > start_tv.tv_usec) {
- sec_diff = end_tv.tv_sec - start_tv.tv_sec;
- usec_diff = end_tv.tv_usec - start_tv.tv_usec;
- } else {
- sec_diff = end_tv.tv_sec - start_tv.tv_sec - 1;
- usec_diff =
- 1000000 - (start_tv.tv_usec -
- end_tv.tv_usec);
- }
- printf("-I- End time is : %09ld:%06ld [sec:usec]\n",
- (long)end_tv.tv_sec, (long)end_tv.tv_usec);
- printf("-I- Querying %" PRId64
- " large mixed queries (rmpp) took %04ld:%06ld [sec:usec]\n",
- num_queries, sec_diff, usec_diff);
- printf("%" PRIu64 " records, %" PRIu64 " queries\n",
- num_recs, num_queries);
- print_freq = 0;
- }
- }
-
-Exit:
- gettimeofday(&end_tv, NULL);
- printf("-I- End time is : %09ld:%06ld [sec:usec]\n",
- (long)end_tv.tv_sec, (long)end_tv.tv_usec);
- if (end_tv.tv_usec > start_tv.tv_usec) {
- sec_diff = end_tv.tv_sec - start_tv.tv_sec;
- usec_diff = end_tv.tv_usec - start_tv.tv_usec;
- } else {
- sec_diff = end_tv.tv_sec - start_tv.tv_sec - 1;
- usec_diff = 1000000 - (start_tv.tv_usec - end_tv.tv_usec);
- }
-
- printf("-I- Querying %" PRId64
- " large mixed queries (rmpp) took %04ld:%06ld [sec:usec]\n",
- num_queries, sec_diff, usec_diff);
-
- OSM_LOG_EXIT(&p_osmt->log);
- return (status);
-}
-
-/**********************************************************************
- **********************************************************************/
-static ib_api_status_t osmtest_stress_small_rmpp(IN osmtest_t * const p_osmt)
-{
- ib_api_status_t status = IB_SUCCESS;
- uint64_t num_recs = 0;
- uint64_t num_queries = 0;
- uint32_t delta_recs;
- uint32_t delta_queries;
- uint32_t print_freq = 0;
- int num_timeouts = 0;
- struct timeval start_tv, end_tv;
- long sec_diff, usec_diff;
-
- OSM_LOG_ENTER(&p_osmt->log);
- gettimeofday(&start_tv, NULL);
- printf("-I- Start time is : %09ld:%06ld [sec:usec]\n",
- (long)start_tv.tv_sec, (long)start_tv.tv_usec);
-
- while ((num_queries < STRESS_SMALL_RMPP_THR) && (num_timeouts < 100)) {
- delta_recs = 0;
- delta_queries = 0;
-
- status = osmtest_stress_port_recs_small(p_osmt, &delta_recs,
- &delta_queries);
- if (status != IB_SUCCESS)
- goto Exit;
-
- num_recs += delta_recs;
- num_queries += delta_queries;
-
- print_freq += delta_recs;
- if (print_freq > 5000) {
- gettimeofday(&end_tv, NULL);
- printf("%" PRIu64 " records, %" PRIu64 " queries\n",
- num_recs, num_queries);
- if (end_tv.tv_usec > start_tv.tv_usec) {
- sec_diff = end_tv.tv_sec - start_tv.tv_sec;
- usec_diff = end_tv.tv_usec - start_tv.tv_usec;
- } else {
- sec_diff = end_tv.tv_sec - start_tv.tv_sec - 1;
- usec_diff =
- 1000000 - (start_tv.tv_usec -
- end_tv.tv_usec);
- }
- printf("-I- End time is : %09ld:%06ld [sec:usec]\n",
- (long)end_tv.tv_sec, (long)end_tv.tv_usec);
- printf("-I- Querying %" PRId64
- " port_info queries (single mad) took %04ld:%06ld [sec:usec]\n",
- num_queries, sec_diff, usec_diff);
- print_freq = 0;
- }
- }
-
-Exit:
- gettimeofday(&end_tv, NULL);
- printf("-I- End time is : %09ld:%06ld [sec:usec]\n",
- (long)end_tv.tv_sec, (long)end_tv.tv_usec);
- if (end_tv.tv_usec > start_tv.tv_usec) {
- sec_diff = end_tv.tv_sec - start_tv.tv_sec;
- usec_diff = end_tv.tv_usec - start_tv.tv_usec;
- } else {
- sec_diff = end_tv.tv_sec - start_tv.tv_sec - 1;
- usec_diff = 1000000 - (start_tv.tv_usec - end_tv.tv_usec);
- }
-
- printf("-I- Querying %" PRId64
- " port_info queries (single mad) took %04ld:%06ld [sec:usec]\n",
- num_queries, sec_diff, usec_diff);
- if (num_timeouts > 50) {
- status = IB_TIMEOUT;
- }
- /* Exit: */
- OSM_LOG_EXIT(&p_osmt->log);
- return (status);
-}
-
-/**********************************************************************
- **********************************************************************/
-static void
-osmtest_prepare_db_generic(IN osmtest_t * const p_osmt,
- IN cl_qmap_t * const p_tbl)
-{
- generic_t *p_generic;
-
- OSM_LOG_ENTER(&p_osmt->log);
-
- p_generic = (generic_t *) cl_qmap_head(p_tbl);
-
- while (p_generic != (generic_t *) cl_qmap_end(p_tbl)) {
- p_generic->count = 0;
- p_generic = (generic_t *) cl_qmap_next(&p_generic->map_item);
- }
-
- OSM_LOG_EXIT(&p_osmt->log);
-}
-
-/**********************************************************************
- **********************************************************************/
-static void osmtest_prepare_db(IN osmtest_t * const p_osmt)
-{
- OSM_LOG_ENTER(&p_osmt->log);
-
- osmtest_prepare_db_generic(p_osmt, &p_osmt->exp_subn.node_lid_tbl);
- osmtest_prepare_db_generic(p_osmt, &p_osmt->exp_subn.path_tbl);
-
- OSM_LOG_EXIT(&p_osmt->log);
-}
-
-/**********************************************************************
- **********************************************************************/
-static ib_api_status_t osmtest_check_missing_nodes(IN osmtest_t * const p_osmt)
-{
- const node_t *p_node;
- cl_status_t status = IB_SUCCESS;
- cl_qmap_t *p_tbl;
-
- OSM_LOG_ENTER(&p_osmt->log);
-
- p_tbl = &p_osmt->exp_subn.node_lid_tbl;
-
- p_node = (node_t *) cl_qmap_head(p_tbl);
-
- while (p_node != (node_t *) cl_qmap_end(p_tbl)) {
- if (p_node->count == 0) {
- /*
- * This node was not reported by the SA
- */
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0080: "
- "Missing node 0x%016" PRIx64 "\n",
- cl_ntoh64(p_node->rec.node_info.node_guid));
- status = IB_ERROR;
- }
-
- p_node = (node_t *) cl_qmap_next(&p_node->map_item);
- }
-
- OSM_LOG_EXIT(&p_osmt->log);
- return (status);
-}
-
-/**********************************************************************
- **********************************************************************/
-static ib_api_status_t osmtest_check_missing_ports(IN osmtest_t * const p_osmt)
-{
- const port_t *p_port;
- cl_status_t status = IB_SUCCESS;
- cl_qmap_t *p_tbl;
-
- OSM_LOG_ENTER(&p_osmt->log);
-
- p_tbl = &p_osmt->exp_subn.port_key_tbl;
-
- p_port = (port_t *) cl_qmap_head(p_tbl);
-
- while (p_port != (port_t *) cl_qmap_end(p_tbl)) {
- if (p_port->count == 0) {
- /*
- * This port was not reported by the SA
- */
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0081: "
- "Missing port LID:0x%X Num:0x%X\n",
- cl_ntoh16(p_port->rec.lid),
- p_port->rec.port_num);
- status = IB_ERROR;
- }
-
- p_port = (port_t *) cl_qmap_next(&p_port->map_item);
- }
-
- OSM_LOG_EXIT(&p_osmt->log);
- return (status);
-}
-
-/**********************************************************************
- **********************************************************************/
-static ib_api_status_t osmtest_check_missing_paths(IN osmtest_t * const p_osmt)
-{
- const path_t *p_path;
- cl_status_t status = IB_SUCCESS;
- cl_qmap_t *p_tbl;
-
- OSM_LOG_ENTER(&p_osmt->log);
-
- p_tbl = &p_osmt->exp_subn.path_tbl;
-
- p_path = (path_t *) cl_qmap_head(p_tbl);
-
- while (p_path != (path_t *) cl_qmap_end(p_tbl)) {
- if (p_path->count == 0) {
- /*
- * This path was not reported by the SA
- */
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0051: "
- "SA did not return path SLID 0x%X to DLID 0x%X\n",
- cl_ntoh16(p_path->rec.slid),
- cl_ntoh16(p_path->rec.dlid));
- status = IB_ERROR;
- goto Exit;
- }
-
- p_path = (path_t *) cl_qmap_next(&p_path->map_item);
- }
-
-Exit:
- OSM_LOG_EXIT(&p_osmt->log);
- return (status);
-}
-
-/**********************************************************************
- **********************************************************************/
-static inline uint32_t osmtest_path_rec_key_get(IN const ib_path_rec_t * const p_rec)
-{
- return (p_rec->dlid << 16 | p_rec->slid);
-}
-
-/**********************************************************************
- **********************************************************************/
-static boolean_t
-osmtest_path_rec_kay_is_valid(IN osmtest_t * const p_osmt,
- IN const path_t * const p_path)
-{
- if ((p_path->comp.dlid == 0) || (p_path->comp.slid == 0)) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0168: "
- "SLID and DLID must be specified for defined paths\n");
- return (FALSE);
- }
-
- return (TRUE);
-}
-
-/**********************************************************************
- **********************************************************************/
-static ib_api_status_t
-osmtest_validate_path_data(IN osmtest_t * const p_osmt,
- IN path_t * const p_path,
- IN const ib_path_rec_t * const p_rec)
-{
- cl_status_t status = IB_SUCCESS;
- uint8_t lmc = 0;
-
- OSM_LOG_ENTER(&p_osmt->log);
-
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR,
- "Checking path SLID 0x%X to DLID 0x%X\n",
- cl_ntoh16(p_rec->slid), cl_ntoh16(p_rec->dlid));
-
- status =
- osmtest_get_local_port_lmc(p_osmt, p_osmt->local_port.lid, &lmc);
- if (status != IB_SUCCESS)
- goto Exit;
-
- /* HACK: Assume uniform LMC across endports in the subnet */
- /* This is the only LMC mode which OpenSM currently supports */
- /* In absence of this assumption, validation of this is much more complicated */
- if (lmc == 0) {
- /*
- * Has this record already been returned?
- */
- if (p_path->count != 0) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0056: "
- "Already received path SLID 0x%X to DLID 0x%X\n",
- cl_ntoh16(p_rec->slid), cl_ntoh16(p_rec->dlid));
- status = IB_ERROR;
- goto Exit;
- }
- } else {
- /* Also, this doesn't detect fewer than the correct number of paths being returned */
- if (p_path->count >= (uint32_t) (1 << (2 * lmc))) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0052: "
- "Already received path SLID 0x%X to DLID 0x%X count %d LMC %d\n",
- cl_ntoh16(p_rec->slid), cl_ntoh16(p_rec->dlid),
- p_path->count, lmc);
- status = IB_ERROR;
- goto Exit;
- }
- }
-
- ++p_path->count;
-
- /*
- * Check the fields the user wants checked.
- */
- if ((p_path->comp.dgid.unicast.interface_id &
- p_path->rec.dgid.unicast.interface_id) !=
- (p_path->comp.dgid.unicast.interface_id &
- p_rec->dgid.unicast.interface_id)) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0169: "
- "DGID mismatch on path SLID 0x%X to DLID 0x%X\n"
- "\t\t\t\tExpected 0x%016" PRIx64 " 0x%016" PRIx64 "\n"
- "\t\t\t\tReceived 0x%016" PRIx64 " 0x%016" PRIx64 "\n",
- cl_ntoh16(p_path->rec.slid),
- cl_ntoh16(p_path->rec.dlid),
- cl_ntoh64(p_path->rec.dgid.unicast.prefix),
- cl_ntoh64(p_path->rec.dgid.unicast.interface_id),
- cl_ntoh64(p_rec->dgid.unicast.prefix),
- cl_ntoh64(p_rec->dgid.unicast.interface_id));
- status = IB_ERROR;
- goto Exit;
- }
-
- /*
- * Check the fields the user wants checked.
- */
- if ((p_path->comp.sgid.unicast.interface_id &
- p_path->rec.sgid.unicast.interface_id) !=
- (p_path->comp.sgid.unicast.interface_id &
- p_rec->sgid.unicast.interface_id)) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0057: "
- "SGID mismatch on path SLID 0x%X to DLID 0x%X\n"
- "\t\t\t\tExpected 0x%016" PRIx64 " 0x%016" PRIx64 ",\n"
- "\t\t\t\tReceived 0x%016" PRIx64 " 0x%016" PRIx64 ".\n",
- cl_ntoh16(p_path->rec.slid),
- cl_ntoh16(p_path->rec.dlid),
- cl_ntoh64(p_path->rec.sgid.unicast.prefix),
- cl_ntoh64(p_path->rec.sgid.unicast.interface_id),
- cl_ntoh64(p_rec->sgid.unicast.prefix),
- cl_ntoh64(p_rec->sgid.unicast.interface_id));
- status = IB_ERROR;
- goto Exit;
- }
-
- /*
- * Compare the fields the user wishes to validate.
- */
- if ((p_path->comp.pkey & p_path->rec.pkey) !=
- (p_path->comp.pkey & p_rec->pkey)) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0012: "
- "PKEY mismatch on path SLID 0x%X to DLID 0x%X\n"
- "\t\t\t\tExpected 0x%X, received 0x%X\n",
- cl_ntoh16(p_path->rec.slid),
- cl_ntoh16(p_path->rec.dlid),
- cl_ntoh16(p_path->rec.pkey), cl_ntoh16(p_rec->pkey));
- status = IB_ERROR;
- goto Exit;
- }
-
-Exit:
- OSM_LOG_EXIT(&p_osmt->log);
- return (status);
-}
-
-/**********************************************************************
- **********************************************************************/
-static ib_api_status_t
-osmtest_validate_node_data(IN osmtest_t * const p_osmt,
- IN node_t * const p_node,
- IN const ib_node_record_t * const p_rec)
-{
- cl_status_t status = IB_SUCCESS;
-
- OSM_LOG_ENTER(&p_osmt->log);
-
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR,
- "Checking node 0x%016" PRIx64 ", LID 0x%X\n",
- cl_ntoh64(p_rec->node_info.node_guid), cl_ntoh16(p_rec->lid));
-
- /*
- * Has this record already been returned?
- */
- if (p_node->count != 0) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0013: "
- "Already received node 0x%016" PRIx64 "\n",
- cl_ntoh64(p_node->rec.node_info.node_guid));
- status = IB_ERROR;
- goto Exit;
- }
-
- ++p_node->count;
-
- /*
- * Compare the fields the user wishes to validate.
- */
- if ((p_node->comp.lid & p_node->rec.lid) !=
- (p_node->comp.lid & p_rec->lid)) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0014: "
- "Field mismatch node 0x%016" PRIx64 ", LID 0x%X\n"
- "\t\t\t\tExpected LID 0x%X, received 0x%X\n",
- cl_ntoh64(p_rec->node_info.node_guid),
- cl_ntoh16(p_rec->lid), p_node->rec.lid, p_rec->lid);
- status = IB_ERROR;
- goto Exit;
- }
-
- if ((p_node->comp.node_info.base_version &
- p_node->rec.node_info.base_version) !=
- (p_node->comp.node_info.base_version &
- p_rec->node_info.base_version)) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0015: "
- "Field mismatch node 0x%016" PRIx64 ", LID 0x%X\n"
- "\t\t\t\tExpected base_version 0x%X, received 0x%X\n",
- cl_ntoh64(p_rec->node_info.node_guid),
- cl_ntoh16(p_rec->lid),
- p_node->rec.node_info.base_version,
- p_rec->node_info.base_version);
- status = IB_ERROR;
- goto Exit;
- }
-
- if ((p_node->comp.node_info.class_version &
- p_node->rec.node_info.class_version) !=
- (p_node->comp.node_info.class_version &
- p_rec->node_info.class_version)) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0016: "
- "Field mismatch node 0x%016" PRIx64 ", LID 0x%X\n"
- "\t\t\t\tExpected class_version 0x%X, received 0x%X\n",
- cl_ntoh64(p_rec->node_info.node_guid),
- cl_ntoh16(p_rec->lid),
- p_node->rec.node_info.class_version,
- p_rec->node_info.class_version);
- status = IB_ERROR;
- goto Exit;
- }
-
- if ((p_node->comp.node_info.node_type &
- p_node->rec.node_info.node_type) !=
- (p_node->comp.node_info.node_type & p_rec->node_info.node_type)) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0017: "
- "Field mismatch node 0x%016" PRIx64 ", LID 0x%X\n"
- "\t\t\t\tExpected node_type 0x%X, received 0x%X\n",
- cl_ntoh64(p_rec->node_info.node_guid),
- cl_ntoh16(p_rec->lid),
- p_node->rec.node_info.node_type,
- p_rec->node_info.node_type);
- status = IB_ERROR;
- goto Exit;
- }
-
- if ((p_node->comp.node_info.sys_guid &
- p_node->rec.node_info.sys_guid) !=
- (p_node->comp.node_info.sys_guid & p_rec->node_info.sys_guid)) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0018: "
- "Field mismatch node 0x%016" PRIx64 ", LID 0x%X\n"
- "\t\t\t\tExpected sys_guid 0x%016" PRIx64
- ", received 0x%016" PRIx64 "\n",
- cl_ntoh64(p_rec->node_info.node_guid),
- cl_ntoh16(p_rec->lid),
- cl_ntoh64(p_node->rec.node_info.sys_guid),
- cl_ntoh64(p_rec->node_info.sys_guid));
- status = IB_ERROR;
- goto Exit;
- }
-
- if ((p_node->comp.node_info.node_guid &
- p_node->rec.node_info.node_guid) !=
- (p_node->comp.node_info.node_guid & p_rec->node_info.node_guid)) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0019: "
- "Field mismatch node 0x%016" PRIx64 ", LID 0x%X\n"
- "\t\t\t\tExpected node_guid 0x%016" PRIx64
- ", received 0x%016" PRIx64 "\n",
- cl_ntoh64(p_rec->node_info.node_guid),
- cl_ntoh16(p_rec->lid),
- cl_ntoh64(p_node->rec.node_info.node_guid),
- cl_ntoh64(p_rec->node_info.node_guid));
- status = IB_ERROR;
- goto Exit;
- }
-
- if ((p_node->comp.node_info.port_guid &
- p_node->rec.node_info.port_guid) !=
- (p_node->comp.node_info.port_guid & p_rec->node_info.port_guid)) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0031: "
- "Field mismatch node 0x%016" PRIx64 ", LID 0x%X\n"
- "\t\t\t\tExpected port_guid 0x%016" PRIx64
- ", received 0x%016" PRIx64 "\n",
- cl_ntoh64(p_rec->node_info.node_guid),
- cl_ntoh16(p_rec->lid),
- cl_ntoh64(p_node->rec.node_info.port_guid),
- cl_ntoh64(p_rec->node_info.port_guid));
- status = IB_ERROR;
- goto Exit;
- }
-
- if ((p_node->comp.node_info.partition_cap &
- p_node->rec.node_info.partition_cap) !=
- (p_node->comp.node_info.partition_cap &
- p_rec->node_info.partition_cap)) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0032: "
- "Field mismatch node 0x%016" PRIx64 ", LID 0x%X\n"
- "\t\t\t\tExpected partition_cap 0x%X, received 0x%X\n",
- cl_ntoh64(p_rec->node_info.node_guid),
- cl_ntoh16(p_rec->lid),
- cl_ntoh16(p_node->rec.node_info.partition_cap),
- cl_ntoh16(p_rec->node_info.partition_cap));
- status = IB_ERROR;
- goto Exit;
- }
-
- if ((p_node->comp.node_info.device_id &
- p_node->rec.node_info.device_id) !=
- (p_node->comp.node_info.device_id & p_rec->node_info.device_id)) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0033: "
- "Field mismatch node 0x%016" PRIx64 ", LID 0x%X\n"
- "\t\t\t\tExpected device_id 0x%X, received 0x%X\n",
- cl_ntoh64(p_rec->node_info.node_guid),
- cl_ntoh16(p_rec->lid),
- cl_ntoh16(p_node->rec.node_info.device_id),
- cl_ntoh16(p_rec->node_info.device_id));
- status = IB_ERROR;
- goto Exit;
- }
-
- if ((p_node->comp.node_info.revision &
- p_node->rec.node_info.revision) !=
- (p_node->comp.node_info.revision & p_rec->node_info.revision)) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0034: "
- "Field mismatch node 0x%016" PRIx64 ", LID 0x%X\n"
- "\t\t\t\tExpected revision 0x%X, received 0x%X\n",
- cl_ntoh64(p_rec->node_info.node_guid),
- cl_ntoh16(p_rec->lid),
- cl_ntoh32(p_node->rec.node_info.revision),
- cl_ntoh32(p_rec->node_info.revision));
- status = IB_ERROR;
- goto Exit;
- }
-
-Exit:
- OSM_LOG_EXIT(&p_osmt->log);
- return (status);
-}
-
-/**********************************************************************
- **********************************************************************/
-static ib_api_status_t
-osmtest_validate_node_rec(IN osmtest_t * const p_osmt,
- IN const ib_node_record_t * const p_rec)
-{
- cl_status_t status = IB_SUCCESS;
- node_t *p_node;
- const cl_qmap_t *p_tbl;
-
- OSM_LOG_ENTER(&p_osmt->log);
-
- /*
- * Find proper node record in the database.
- */
- p_tbl = &p_osmt->exp_subn.node_lid_tbl;
- p_node = (node_t *) cl_qmap_get(p_tbl, p_rec->lid);
- if (p_node == (node_t *) cl_qmap_end(p_tbl)) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0035: "
- "Unexpected node 0x%016" PRIx64 ", LID 0x%X\n",
- cl_ntoh64(p_rec->node_info.node_guid),
- cl_ntoh16(p_rec->lid));
- status = IB_ERROR;
- goto Exit;
- }
-
- status = osmtest_validate_node_data(p_osmt, p_node, p_rec);
-
-Exit:
- OSM_LOG_EXIT(&p_osmt->log);
- return (status);
-}
-
-/**********************************************************************
- **********************************************************************/
-static ib_api_status_t
-osmtest_validate_port_data(IN osmtest_t * const p_osmt,
- IN port_t * const p_port,
- IN const ib_portinfo_record_t * const p_rec)
-{
- cl_status_t status = IB_SUCCESS;
-
- OSM_LOG_ENTER(&p_osmt->log);
-
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR,
- "Checking port LID 0x%X, Num 0x%X\n",
- cl_ntoh16(p_rec->lid), p_rec->port_num);
-
- /*
- * Has this record already been returned?
- */
- if (p_port->count != 0) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0036: "
- "Already received port LID 0x%X, Num 0x%X\n",
- cl_ntoh16(p_rec->lid), p_rec->port_num);
- status = IB_ERROR;
- goto Exit;
- }
-
- ++p_port->count;
-
- /*
- * Compare the fields the user wishes to validate.
- */
- if ((p_port->comp.lid & p_port->rec.lid) !=
- (p_port->comp.lid & p_rec->lid)) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0037: "
- "Field mismatch port LID 0x%X Num:0x%X\n"
- "\t\t\t\tExpected LID 0x%X, received 0x%X\n",
- cl_ntoh16(p_rec->lid), p_rec->port_num,
- p_port->rec.lid, p_rec->lid);
- status = IB_ERROR;
- goto Exit;
- }
-
- if ((p_port->comp.port_num & p_port->rec.port_num) !=
- (p_port->comp.port_num & p_rec->port_num)) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0038: "
- "Field mismatch port LID 0x%X Num:0x%X\n"
- "\t\t\t\tExpected port_num 0x%X, received 0x%X\n",
- cl_ntoh16(p_rec->lid), p_rec->port_num,
- p_port->rec.port_num, p_rec->port_num);
- status = IB_ERROR;
- goto Exit;
- }
-
- if ((p_port->comp.port_info.m_key & p_port->rec.port_info.m_key) !=
- (p_port->comp.port_info.m_key & p_rec->port_info.m_key)) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0039: "
- "Field mismatch port LID 0x%X Num:0x%X\n"
- "\t\t\t\tExpected m_key 0x%016" PRIx64
- ", received 0x%016" PRIx64 "\n", cl_ntoh16(p_rec->lid),
- p_rec->port_num, p_port->rec.port_info.m_key,
- p_rec->port_info.m_key);
- status = IB_ERROR;
- goto Exit;
- }
-
- if ((p_port->comp.port_info.subnet_prefix & p_port->rec.port_info.
- subnet_prefix) !=
- (p_port->comp.port_info.subnet_prefix & p_rec->port_info.
- subnet_prefix)) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0040: "
- "Field mismatch port LID 0x%X Num:0x%X\n"
- "\t\t\t\tExpected subnet_prefix 0x%016" PRIx64
- ", received 0x%016" PRIx64 "\n", cl_ntoh16(p_rec->lid),
- p_rec->port_num, p_port->rec.port_info.subnet_prefix,
- p_rec->port_info.subnet_prefix);
- status = IB_ERROR;
- goto Exit;
- }
-
- if ((p_port->comp.port_info.base_lid & p_port->rec.port_info.
- base_lid) !=
- (p_port->comp.port_info.base_lid & p_rec->port_info.base_lid)) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0041: "
- "Field mismatch port LID 0x%X Num:0x%X\n"
- "\t\t\t\tExpected base_lid 0x%X, received 0x%X\n",
- cl_ntoh16(p_rec->lid), p_rec->port_num,
- p_port->rec.port_info.base_lid,
- p_rec->port_info.base_lid);
- status = IB_ERROR;
- goto Exit;
- }
-
- if ((p_port->comp.port_info.master_sm_base_lid & p_port->rec.port_info.
- master_sm_base_lid) !=
- (p_port->comp.port_info.master_sm_base_lid & p_rec->port_info.
- master_sm_base_lid)) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0042: "
- "Field mismatch port LID 0x%X Num:0x%X\n"
- "\t\t\t\tExpected master_sm_base_lid 0x%X, received 0x%X\n",
- cl_ntoh16(p_rec->lid), p_rec->port_num,
- p_port->rec.port_info.master_sm_base_lid,
- p_rec->port_info.master_sm_base_lid);
- status = IB_ERROR;
- goto Exit;
- }
-
- if ((p_port->comp.port_info.capability_mask & p_port->rec.port_info.
- capability_mask) !=
- (p_port->comp.port_info.capability_mask & p_rec->port_info.
- capability_mask)) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0043: "
- "Field mismatch port LID 0x%X Num:0x%X\n"
- "\t\t\t\tExpected capability_mask 0x%X, received 0x%X\n",
- cl_ntoh16(p_rec->lid), p_rec->port_num,
- cl_ntoh32(p_port->rec.port_info.capability_mask),
- cl_ntoh32(p_rec->port_info.capability_mask));
- status = IB_ERROR;
- goto Exit;
- }
-
- if ((p_port->comp.port_info.diag_code & p_port->rec.port_info.
- diag_code) !=
- (p_port->comp.port_info.diag_code & p_rec->port_info.diag_code)) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0044: "
- "Field mismatch port LID 0x%X Num:0x%X\n"
- "\t\t\t\tExpected diag_code 0x%X, received 0x%X\n",
- cl_ntoh16(p_rec->lid), p_rec->port_num,
- p_port->rec.port_info.diag_code,
- p_rec->port_info.diag_code);
- status = IB_ERROR;
- goto Exit;
- }
-
- if ((p_port->comp.port_info.m_key_lease_period & p_port->rec.port_info.
- m_key_lease_period) !=
- (p_port->comp.port_info.m_key_lease_period & p_rec->port_info.
- m_key_lease_period)) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0045: "
- "Field mismatch port LID 0x%X Num:0x%X\n"
- "\t\t\t\tExpected m_key_lease_period 0x%X, received 0x%X\n",
- cl_ntoh16(p_rec->lid), p_rec->port_num,
- p_port->rec.port_info.m_key_lease_period,
- p_rec->port_info.m_key_lease_period);
- status = IB_ERROR;
- goto Exit;
- }
-
- if ((p_port->comp.port_info.local_port_num & p_port->rec.port_info.
- local_port_num) !=
- (p_port->comp.port_info.local_port_num & p_rec->port_info.
- local_port_num)) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0046: "
- "Field mismatch port LID 0x%X Num:0x%X\n"
- "\t\t\t\tExpected local_port_num 0x%X, received 0x%X\n",
- cl_ntoh16(p_rec->lid), p_rec->port_num,
- p_port->rec.port_info.local_port_num,
- p_rec->port_info.local_port_num);
- status = IB_ERROR;
- goto Exit;
- }
-
- if ((p_port->comp.port_info.link_width_enabled & p_port->rec.port_info.
- link_width_enabled) !=
- (p_port->comp.port_info.link_width_enabled & p_rec->port_info.
- link_width_enabled)) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0047: "
- "Field mismatch port LID 0x%X Num:0x%X\n"
- "\t\t\t\tExpected link_width_enabled 0x%X, received 0x%X\n",
- cl_ntoh16(p_rec->lid), p_rec->port_num,
- p_port->rec.port_info.link_width_enabled,
- p_rec->port_info.link_width_enabled);
- status = IB_ERROR;
- goto Exit;
- }
-
- if ((p_port->comp.port_info.link_width_supported & p_port->rec.
- port_info.link_width_supported) !=
- (p_port->comp.port_info.link_width_supported & p_rec->port_info.
- link_width_supported)) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0048: "
- "Field mismatch port LID 0x%X Num:0x%X\n"
- "\t\t\t\tExpected link_width_supported 0x%X, received 0x%X\n",
- cl_ntoh16(p_rec->lid), p_rec->port_num,
- p_port->rec.port_info.link_width_supported,
- p_rec->port_info.link_width_supported);
- status = IB_ERROR;
- goto Exit;
- }
-
- if ((p_port->comp.port_info.link_width_active & p_port->rec.port_info.
- link_width_active) !=
- (p_port->comp.port_info.link_width_active & p_rec->port_info.
- link_width_active)) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0049: "
- "Field mismatch port LID 0x%X Num:0x%X\n"
- "\t\t\t\tExpected link_width_active 0x%X, received 0x%X\n",
- cl_ntoh16(p_rec->lid), p_rec->port_num,
- p_port->rec.port_info.link_width_active,
- p_rec->port_info.link_width_active);
- status = IB_ERROR;
- goto Exit;
- }
-
- if ((p_port->comp.port_info.link_speed & p_port->rec.port_info.
- link_speed) !=
- (p_port->comp.port_info.link_speed & p_rec->port_info.link_speed)) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0054: "
- "Field mismatch port LID 0x%X Num:0x%X\n"
- "\t\t\t\tExpected link_speed 0x%X, received 0x%X\n",
- cl_ntoh16(p_rec->lid), p_rec->port_num,
- p_port->rec.port_info.link_speed,
- p_rec->port_info.link_speed);
- status = IB_ERROR;
- goto Exit;
- }
-
- if ((p_port->comp.port_info.state_info1 & p_port->rec.port_info.
- state_info1) !=
- (p_port->comp.port_info.state_info1 & p_rec->port_info.
- state_info1)) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0055: "
- "Field mismatch port LID 0x%X Num:0x%X\n"
- "\t\t\t\tExpected state_info1 0x%X, received 0x%X\n",
- cl_ntoh16(p_rec->lid), p_rec->port_num,
- p_port->rec.port_info.state_info1,
- p_rec->port_info.state_info1);
- status = IB_ERROR;
- goto Exit;
- }
-
- if ((p_port->comp.port_info.state_info2 & p_port->rec.port_info.
- state_info2) !=
- (p_port->comp.port_info.state_info2 & p_rec->port_info.
- state_info2)) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0058: "
- "Field mismatch port LID 0x%X Num:0x%X\n"
- "\t\t\t\tExpected state_info2 0x%X, received 0x%X\n",
- cl_ntoh16(p_rec->lid), p_rec->port_num,
- p_port->rec.port_info.state_info2,
- p_rec->port_info.state_info2);
- status = IB_ERROR;
- goto Exit;
- }
-
- if ((p_port->comp.port_info.mkey_lmc & p_port->rec.port_info.
- mkey_lmc) !=
- (p_port->comp.port_info.mkey_lmc & p_rec->port_info.mkey_lmc)) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0059: "
- "Field mismatch port LID 0x%X Num:0x%X\n"
- "\t\t\t\tExpected mkey_lmc 0x%X, received 0x%X\n",
- cl_ntoh16(p_rec->lid), p_rec->port_num,
- p_port->rec.port_info.mkey_lmc,
- p_rec->port_info.mkey_lmc);
- status = IB_ERROR;
- goto Exit;
- }
-
- if ((p_port->comp.port_info.link_speed & p_port->rec.port_info.
- link_speed) !=
- (p_port->comp.port_info.link_speed & p_rec->port_info.link_speed)) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0060: "
- "Field mismatch port LID 0x%X Num:0x%X\n"
- "\t\t\t\tExpected link_speed 0x%X, received 0x%X\n",
- cl_ntoh16(p_rec->lid), p_rec->port_num,
- p_port->rec.port_info.link_speed,
- p_rec->port_info.link_speed);
- status = IB_ERROR;
- goto Exit;
- }
-
- if ((p_port->comp.port_info.mtu_smsl & p_port->rec.port_info.
- mtu_smsl) !=
- (p_port->comp.port_info.mtu_smsl & p_rec->port_info.mtu_smsl)) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0061: "
- "Field mismatch port LID 0x%X Num:0x%X\n"
- "\t\t\t\tExpected mtu_smsl 0x%X, received 0x%X\n",
- cl_ntoh16(p_rec->lid), p_rec->port_num,
- p_port->rec.port_info.mtu_smsl,
- p_rec->port_info.mtu_smsl);
- status = IB_ERROR;
- goto Exit;
- }
-
- if ((p_port->comp.port_info.vl_cap & p_port->rec.port_info.vl_cap) !=
- (p_port->comp.port_info.vl_cap & p_rec->port_info.vl_cap)) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0062: "
- "Field mismatch port LID 0x%X Num:0x%X\n"
- "\t\t\t\tExpected vl_cap 0x%X, received 0x%X\n",
- cl_ntoh16(p_rec->lid), p_rec->port_num,
- p_port->rec.port_info.vl_cap, p_rec->port_info.vl_cap);
- status = IB_ERROR;
- goto Exit;
- }
-
- if ((p_port->comp.port_info.vl_high_limit & p_port->rec.port_info.
- vl_high_limit) !=
- (p_port->comp.port_info.vl_high_limit & p_rec->port_info.
- vl_high_limit)) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0082: "
- "Field mismatch port LID 0x%X Num:0x%X\n"
- "\t\t\t\tExpected vl_high_limit 0x%X, received 0x%X\n",
- cl_ntoh16(p_rec->lid), p_rec->port_num,
- p_port->rec.port_info.vl_high_limit,
- p_rec->port_info.vl_high_limit);
- status = IB_ERROR;
- goto Exit;
- }
-
- if ((p_port->comp.port_info.vl_arb_high_cap & p_port->rec.port_info.
- vl_arb_high_cap) !=
- (p_port->comp.port_info.vl_arb_high_cap & p_rec->port_info.
- vl_arb_high_cap)) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0083: "
- "Field mismatch port LID 0x%X Num:0x%X\n"
- "\t\t\t\tExpected vl_arb_high_cap 0x%X, received 0x%X\n",
- cl_ntoh16(p_rec->lid), p_rec->port_num,
- p_port->rec.port_info.vl_arb_high_cap,
- p_rec->port_info.vl_arb_high_cap);
- status = IB_ERROR;
- goto Exit;
- }
-
- if ((p_port->comp.port_info.vl_arb_low_cap & p_port->rec.port_info.
- vl_arb_low_cap) !=
- (p_port->comp.port_info.vl_arb_low_cap & p_rec->port_info.
- vl_arb_low_cap)) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0084: "
- "Field mismatch port LID 0x%X Num:0x%X\n"
- "\t\t\t\tExpected vl_arb_low_cap 0x%X, received 0x%X\n",
- cl_ntoh16(p_rec->lid), p_rec->port_num,
- p_port->rec.port_info.vl_arb_low_cap,
- p_rec->port_info.vl_arb_low_cap);
- status = IB_ERROR;
- goto Exit;
- }
-
- if ((p_port->comp.port_info.mtu_cap & p_port->rec.port_info.mtu_cap) !=
- (p_port->comp.port_info.mtu_cap & p_rec->port_info.mtu_cap)) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0085: "
- "Field mismatch port LID 0x%X Num:0x%X\n"
- "\t\t\t\tExpected mtu_cap 0x%X, received 0x%X\n",
- cl_ntoh16(p_rec->lid), p_rec->port_num,
- p_port->rec.port_info.mtu_cap,
- p_rec->port_info.mtu_cap);
- status = IB_ERROR;
- goto Exit;
- }
-#if 0
- /* this is a dynamic attribute */
- if ((p_port->comp.port_info.vl_stall_life & p_port->rec.port_info.
- vl_stall_life) !=
- (p_port->comp.port_info.vl_stall_life & p_rec->port_info.
- vl_stall_life)) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 012F: "
- "Field mismatch port LID 0x%X Num:0x%X\n"
- "\t\t\t\tExpected vl_stall_life 0x%X, received 0x%X\n",
- cl_ntoh16(p_rec->lid), p_rec->port_num,
- p_port->rec.port_info.vl_stall_life,
- p_rec->port_info.vl_stall_life);
- status = IB_ERROR;
- goto Exit;
- }
-#endif
-
- if ((p_port->comp.port_info.vl_enforce & p_port->rec.port_info.
- vl_enforce) !=
- (p_port->comp.port_info.vl_enforce & p_rec->port_info.vl_enforce)) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0086: "
- "Field mismatch port LID 0x%X Num:0x%X\n"
- "\t\t\t\tExpected vl_enforce 0x%X, received 0x%X\n",
- cl_ntoh16(p_rec->lid), p_rec->port_num,
- p_port->rec.port_info.vl_enforce,
- p_rec->port_info.vl_enforce);
- status = IB_ERROR;
- goto Exit;
- }
-
- if ((p_port->comp.port_info.m_key_violations & p_port->rec.port_info.
- m_key_violations) !=
- (p_port->comp.port_info.m_key_violations & p_rec->port_info.
- m_key_violations)) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0087: "
- "Field mismatch port LID 0x%X Num:0x%X\n"
- "\t\t\t\tExpected m_key_violations 0x%X, received 0x%X\n",
- cl_ntoh16(p_rec->lid), p_rec->port_num,
- cl_ntoh16(p_port->rec.port_info.m_key_violations),
- cl_ntoh16(p_rec->port_info.m_key_violations));
- status = IB_ERROR;
- goto Exit;
- }
-
- if ((p_port->comp.port_info.p_key_violations & p_port->rec.port_info.
- p_key_violations) !=
- (p_port->comp.port_info.p_key_violations & p_rec->port_info.
- p_key_violations)) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0088: "
- "Field mismatch port LID 0x%X Num:0x%X\n"
- "\t\t\t\tExpected p_key_violations 0x%X, received 0x%X\n",
- cl_ntoh16(p_rec->lid), p_rec->port_num,
- cl_ntoh16(p_port->rec.port_info.p_key_violations),
- cl_ntoh16(p_rec->port_info.p_key_violations));
- status = IB_ERROR;
- goto Exit;
- }
-
- if ((p_port->comp.port_info.q_key_violations & p_port->rec.port_info.
- q_key_violations) !=
- (p_port->comp.port_info.q_key_violations & p_rec->port_info.
- q_key_violations)) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0089: "
- "Field mismatch port LID 0x%X Num:0x%X\n"
- "\t\t\t\tExpected q_key_violations 0x%X, received 0x%X\n",
- cl_ntoh16(p_rec->lid), p_rec->port_num,
- cl_ntoh16(p_port->rec.port_info.q_key_violations),
- cl_ntoh16(p_rec->port_info.q_key_violations));
- status = IB_ERROR;
- goto Exit;
- }
-
- if ((p_port->comp.port_info.guid_cap & p_port->rec.port_info.
- guid_cap) !=
- (p_port->comp.port_info.guid_cap & p_rec->port_info.guid_cap)) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0090: "
- "Field mismatch port LID 0x%X Num:0x%X\n"
- "\t\t\t\tExpected guid_cap 0x%X, received 0x%X\n",
- cl_ntoh16(p_rec->lid), p_rec->port_num,
- p_port->rec.port_info.guid_cap,
- p_rec->port_info.guid_cap);
- status = IB_ERROR;
- goto Exit;
- }
-
- if ((p_port->comp.port_info.subnet_timeout & p_port->rec.port_info.
- subnet_timeout) !=
- (p_port->comp.port_info.subnet_timeout & p_rec->port_info.
- subnet_timeout)) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0091: "
- "Field mismatch port LID 0x%X Num:0x%X\n"
- "\t\t\t\tExpected subnet_timeout 0x%X, received 0x%X\n",
- cl_ntoh16(p_rec->lid), p_rec->port_num,
- ib_port_info_get_timeout(&p_port->rec.port_info),
- ib_port_info_get_timeout(&p_rec->port_info));
- status = IB_ERROR;
- goto Exit;
- }
-
- if ((p_port->comp.port_info.resp_time_value & p_port->rec.port_info.
- resp_time_value) !=
- (p_port->comp.port_info.resp_time_value & p_rec->port_info.
- resp_time_value)) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0092: "
- "Field mismatch port LID 0x%X Num:0x%X\n"
- "\t\t\t\tExpected resp_time_value 0x%X, received 0x%X\n",
- cl_ntoh16(p_rec->lid), p_rec->port_num,
- p_port->rec.port_info.resp_time_value,
- p_rec->port_info.resp_time_value);
- status = IB_ERROR;
- goto Exit;
- }
-
- if ((p_port->comp.port_info.error_threshold & p_port->rec.port_info.
- error_threshold) !=
- (p_port->comp.port_info.error_threshold & p_rec->port_info.
- error_threshold)) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0093: "
- "Field mismatch port LID 0x%X Num:0x%X\n"
- "\t\t\t\tExpected error_threshold 0x%X, received 0x%X\n",
- cl_ntoh16(p_rec->lid), p_rec->port_num,
- p_port->rec.port_info.error_threshold,
- p_rec->port_info.error_threshold);
- status = IB_ERROR;
- goto Exit;
- }
-
-Exit:
- OSM_LOG_EXIT(&p_osmt->log);
- return (status);
-}
-
-/**********************************************************************
- **********************************************************************/
-static ib_api_status_t
-osmtest_validate_port_rec(IN osmtest_t * const p_osmt,
- IN const ib_portinfo_record_t * const p_rec)
-{
- cl_status_t status = IB_SUCCESS;
- port_t *p_port;
- const cl_qmap_t *p_tbl;
-
- OSM_LOG_ENTER(&p_osmt->log);
-
- /*
- * Find proper port record in the database.
- * (we use by guid - since lid is not unique)
- */
- p_tbl = &p_osmt->exp_subn.port_key_tbl;
- p_port =
- (port_t *) cl_qmap_get(p_tbl,
- port_gen_id(p_rec->lid, p_rec->port_num));
- if (p_port == (port_t *) cl_qmap_end(p_tbl)) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0094: "
- "Unexpected port LID 0x%X, Num:0x%X\n",
- cl_ntoh16(p_rec->lid), p_rec->port_num);
- status = IB_ERROR;
- goto Exit;
- }
-
- status = osmtest_validate_port_data(p_osmt, p_port, p_rec);
-
-Exit:
- OSM_LOG_EXIT(&p_osmt->log);
- return (status);
-}
-
-/**********************************************************************
- **********************************************************************/
-static ib_api_status_t
-osmtest_validate_path_rec(IN osmtest_t * const p_osmt,
- IN const ib_path_rec_t * const p_rec)
-{
- cl_status_t status = IB_SUCCESS;
- path_t *p_path;
- const cl_qmap_t *p_tbl;
-
- OSM_LOG_ENTER(&p_osmt->log);
-
- /*
- * Find proper path record in the database.
- */
- p_tbl = &p_osmt->exp_subn.path_tbl;
- p_path = (path_t *) cl_qmap_get(p_tbl, osmtest_path_rec_key_get(p_rec));
- if (p_path == (path_t *) cl_qmap_end(p_tbl)) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0095: "
- "Unexpected path SLID 0x%X to DLID 0x%X\n",
- cl_ntoh16(p_rec->slid), cl_ntoh16(p_rec->dlid));
- status = IB_ERROR;
- goto Exit;
- }
-
- status = osmtest_validate_path_data(p_osmt, p_path, p_rec);
-
-Exit:
- OSM_LOG_EXIT(&p_osmt->log);
- return (status);
-}
-
-#ifdef VENDOR_RMPP_SUPPORT
-ib_net64_t portguid = 0;
-
-/**********************************************************************
- **********************************************************************/
-static ib_api_status_t
-osmtest_validate_all_node_recs(IN osmtest_t * const p_osmt)
-{
- osmtest_req_context_t context;
- const ib_node_record_t *p_rec;
- uint32_t i;
- cl_status_t status;
- size_t num_recs;
-
- OSM_LOG_ENTER(&p_osmt->log);
-
- memset(&context, 0, sizeof(context));
-
- /*
- * Do a blocking query for all NodeRecords in the subnet.
- */
- status = osmtest_get_all_recs(p_osmt, IB_MAD_ATTR_NODE_RECORD,
- sizeof(*p_rec), &context);
-
- if (status != IB_SUCCESS) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0096: "
- "osmtest_get_all_recs failed (%s)\n",
- ib_get_err_str(status));
- goto Exit;
- }
-
- num_recs = context.result.result_cnt;
-
- OSM_LOG(&p_osmt->log, OSM_LOG_VERBOSE, "Received %zu records\n",
- num_recs);
-
- /*
- * Compare the received records to the database.
- */
- osmtest_prepare_db(p_osmt);
-
- for (i = 0; i < num_recs; i++) {
- p_rec =
- osmv_get_query_node_rec(context.result.p_result_madw, i);
-
- status = osmtest_validate_node_rec(p_osmt, p_rec);
- if (status != IB_SUCCESS) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0097: "
- "osmtest_valid_node_rec failed (%s)\n",
- ib_get_err_str(status));
- goto Exit;
- }
- if (!portguid)
- portguid = p_rec->node_info.port_guid;
- }
-
- status = osmtest_check_missing_nodes(p_osmt);
- if (status != IB_SUCCESS) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0098: "
- "osmtest_check_missing_nodes failed (%s)\n",
- ib_get_err_str(status));
- goto Exit;
- }
-
-Exit:
- /*
- * Return the IB query MAD to the pool as necessary.
- */
- if (context.result.p_result_madw != NULL) {
- osm_mad_pool_put(&p_osmt->mad_pool,
- context.result.p_result_madw);
- context.result.p_result_madw = NULL;
- }
-
- OSM_LOG_EXIT(&p_osmt->log);
- return (status);
-}
-
-/**********************************************************************
- **********************************************************************/
-static ib_api_status_t
-osmtest_validate_all_guidinfo_recs(IN osmtest_t * const p_osmt)
-{
- osmtest_req_context_t context;
- const ib_guidinfo_record_t *p_rec;
- cl_status_t status;
- size_t num_recs;
-
- OSM_LOG_ENTER(&p_osmt->log);
-
- memset(&context, 0, sizeof(context));
-
- /*
- * Do a blocking query for all GuidInfoRecords in the subnet.
- */
- status = osmtest_get_all_recs(p_osmt, IB_MAD_ATTR_GUIDINFO_RECORD,
- sizeof(*p_rec), &context);
-
- if (status != IB_SUCCESS) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0099: "
- "osmtest_get_all_recs failed (%s)\n",
- ib_get_err_str(status));
- goto Exit;
- }
-
- num_recs = context.result.result_cnt;
-
- OSM_LOG(&p_osmt->log, OSM_LOG_VERBOSE, "Received %zu records\n",
- num_recs);
-
- /* No validation as yet */
-
-Exit:
- /*
- * Return the IB query MAD to the pool as necessary.
- */
- if (context.result.p_result_madw != NULL) {
- osm_mad_pool_put(&p_osmt->mad_pool,
- context.result.p_result_madw);
- context.result.p_result_madw = NULL;
- }
-
- OSM_LOG_EXIT(&p_osmt->log);
- return (status);
-}
-
-/**********************************************************************
- **********************************************************************/
-static ib_api_status_t
-osmtest_validate_all_path_recs(IN osmtest_t * const p_osmt)
-{
- osmtest_req_context_t context;
- const ib_path_rec_t *p_rec;
- uint32_t i;
- cl_status_t status;
- size_t num_recs;
-
- OSM_LOG_ENTER(&p_osmt->log);
-
- memset(&context, 0, sizeof(context));
-
- /*
- * Do a blocking query for all PathRecords in the subnet.
- */
- status = osmtest_get_all_recs(p_osmt, IB_MAD_ATTR_PATH_RECORD,
- sizeof(*p_rec), &context);
-
- if (status != IB_SUCCESS) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 009A: "
- "osmtest_get_all_recs failed (%s)\n",
- ib_get_err_str(status));
- goto Exit;
- }
-
- num_recs = context.result.result_cnt;
-
- OSM_LOG(&p_osmt->log, OSM_LOG_VERBOSE, "Received %zu records\n",
- num_recs);
-
- /*
- * Compare the received records to the database.
- */
- osmtest_prepare_db(p_osmt);
-
- for (i = 0; i < num_recs; i++) {
- p_rec =
- osmv_get_query_path_rec(context.result.p_result_madw, i);
-
- status = osmtest_validate_path_rec(p_osmt, p_rec);
- if (status != IB_SUCCESS) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0100: "
- "osmtest_validate_path_rec failed (%s)\n",
- ib_get_err_str(status));
- goto Exit;
- }
- }
-
- status = osmtest_check_missing_paths(p_osmt);
- if (status != IB_SUCCESS) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0101: "
- "osmtest_check_missing_paths failed (%s)\n",
- ib_get_err_str(status));
- goto Exit;
- }
-
-Exit:
- /*
- * Return the IB query MAD to the pool as necessary.
- */
- if (context.result.p_result_madw != NULL) {
- osm_mad_pool_put(&p_osmt->mad_pool,
- context.result.p_result_madw);
- context.result.p_result_madw = NULL;
- }
-
- OSM_LOG_EXIT(&p_osmt->log);
- return (status);
-}
-
-/**********************************************************************
- * Get link record by LID
- **********************************************************************/
-ib_api_status_t
-osmtest_get_link_rec_by_lid(IN osmtest_t * const p_osmt,
- IN ib_net16_t const from_lid,
- IN ib_net16_t const to_lid,
- IN OUT osmtest_req_context_t * const p_context)
-{
- ib_api_status_t status = IB_SUCCESS;
- osmv_user_query_t user;
- osmv_query_req_t req;
- ib_link_record_t record;
- ib_mad_t *p_mad;
-
- OSM_LOG_ENTER(&p_osmt->log);
-
- OSM_LOG(&p_osmt->log, OSM_LOG_VERBOSE,
- "Getting link record from LID 0x%02X to LID 0x%02X\n",
- cl_ntoh16(from_lid), cl_ntoh16(to_lid));
-
- /*
- * Do a blocking query for this record in the subnet.
- * The result is returned in the result field of the caller's
- * context structure.
- *
- * The query structures are locals.
- */
- memset(&req, 0, sizeof(req));
- memset(&user, 0, sizeof(user));
- memset(&record, 0, sizeof(record));
-
- record.from_lid = from_lid;
- record.to_lid = to_lid;
- p_context->p_osmt = p_osmt;
- if (from_lid)
- user.comp_mask |= IB_LR_COMPMASK_FROM_LID;
- if (to_lid)
- user.comp_mask |= IB_LR_COMPMASK_TO_LID;
- user.attr_id = IB_MAD_ATTR_LINK_RECORD;
- user.attr_offset = cl_ntoh16((uint16_t) (sizeof(record) >> 3));
- user.p_attr = &record;
-
- req.query_type = OSMV_QUERY_USER_DEFINED;
- req.timeout_ms = p_osmt->opt.transaction_timeout;
- req.retry_cnt = p_osmt->opt.retry_count;
- req.flags = OSM_SA_FLAGS_SYNC;
- req.query_context = p_context;
- req.pfn_query_cb = osmtest_query_res_cb;
- req.p_query_input = &user;
- req.sm_key = 0;
-
- status = osmv_query_sa(p_osmt->h_bind, &req);
- if (status != IB_SUCCESS) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 007A: "
- "ib_query failed (%s)\n", ib_get_err_str(status));
- goto Exit;
- }
-
- status = p_context->result.status;
-
- if (status != IB_SUCCESS) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 007B: "
- "ib_query failed (%s)\n", ib_get_err_str(status));
- if (status == IB_REMOTE_ERROR) {
- p_mad =
- osm_madw_get_mad_ptr(p_context->result.
- p_result_madw);
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR,
- "osmtest_get_link_rec_by_lid: "
- "Remote error = %s\n",
- ib_get_mad_status_str(p_mad));
-
- status =
- (ib_net16_t) (p_mad->status & IB_SMP_STATUS_MASK);
- }
- goto Exit;
- }
-
-Exit:
- OSM_LOG_EXIT(&p_osmt->log);
- return (status);
-}
-
-/**********************************************************************
- * Get GUIDInfo record by LID
- **********************************************************************/
-ib_api_status_t
-osmtest_get_guidinfo_rec_by_lid(IN osmtest_t * const p_osmt,
- IN ib_net16_t const lid,
- IN OUT osmtest_req_context_t * const p_context)
-{
- ib_api_status_t status = IB_SUCCESS;
- osmv_user_query_t user;
- osmv_query_req_t req;
- ib_guidinfo_record_t record;
- ib_mad_t *p_mad;
-
- OSM_LOG_ENTER(&p_osmt->log);
-
- OSM_LOG(&p_osmt->log, OSM_LOG_VERBOSE,
- "Getting GUIDInfo record for LID 0x%02X\n", cl_ntoh16(lid));
-
- /*
- * Do a blocking query for this record in the subnet.
- * The result is returned in the result field of the caller's
- * context structure.
- *
- * The query structures are locals.
- */
- memset(&req, 0, sizeof(req));
- memset(&user, 0, sizeof(user));
- memset(&record, 0, sizeof(record));
-
- record.lid = lid;
- p_context->p_osmt = p_osmt;
- user.comp_mask = IB_GIR_COMPMASK_LID;
- user.attr_id = IB_MAD_ATTR_GUIDINFO_RECORD;
- user.attr_offset = cl_ntoh16((uint16_t) (sizeof(record) >> 3));
- user.p_attr = &record;
-
- req.query_type = OSMV_QUERY_USER_DEFINED;
- req.timeout_ms = p_osmt->opt.transaction_timeout;
- req.retry_cnt = p_osmt->opt.retry_count;
-
- req.flags = OSM_SA_FLAGS_SYNC;
- req.query_context = p_context;
- req.pfn_query_cb = osmtest_query_res_cb;
- req.p_query_input = &user;
- req.sm_key = 0;
-
- status = osmv_query_sa(p_osmt->h_bind, &req);
- if (status != IB_SUCCESS) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 007C: "
- "ib_query failed (%s)\n", ib_get_err_str(status));
- goto Exit;
- }
-
- status = p_context->result.status;
-
- if (status != IB_SUCCESS) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 007D: "
- "ib_query failed (%s)\n", ib_get_err_str(status));
- if (status == IB_REMOTE_ERROR) {
- p_mad =
- osm_madw_get_mad_ptr(p_context->result.
- p_result_madw);
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR,
- "Remote error = %s\n",
- ib_get_mad_status_str(p_mad));
-
- status =
- (ib_net16_t) (p_mad->status & IB_SMP_STATUS_MASK);
- }
- goto Exit;
- }
-
-Exit:
- OSM_LOG_EXIT(&p_osmt->log);
- return (status);
-}
-
-/**********************************************************************
- * Get PKeyTable record by LID
- **********************************************************************/
-ib_api_status_t
-osmtest_get_pkeytbl_rec_by_lid(IN osmtest_t * const p_osmt,
- IN ib_net16_t const lid,
- IN ib_net64_t const sm_key,
- IN OUT osmtest_req_context_t * const p_context)
-{
- ib_api_status_t status = IB_SUCCESS;
- osmv_user_query_t user;
- osmv_query_req_t req;
- ib_pkey_table_record_t record;
- ib_mad_t *p_mad;
-
- OSM_LOG_ENTER(&p_osmt->log);
-
- OSM_LOG(&p_osmt->log, OSM_LOG_VERBOSE,
- "Getting PKeyTable record for LID 0x%02X\n", cl_ntoh16(lid));
-
- /*
- * Do a blocking query for this record in the subnet.
- * The result is returned in the result field of the caller's
- * context structure.
- *
- * The query structures are locals.
- */
- memset(&req, 0, sizeof(req));
- memset(&user, 0, sizeof(user));
- memset(&record, 0, sizeof(record));
-
- record.lid = lid;
- p_context->p_osmt = p_osmt;
- user.comp_mask = IB_PKEY_COMPMASK_LID;
- user.attr_id = IB_MAD_ATTR_PKEY_TBL_RECORD;
- user.attr_offset = cl_ntoh16((uint16_t) (sizeof(record) >> 3));
- user.p_attr = &record;
-
- req.query_type = OSMV_QUERY_USER_DEFINED;
- req.timeout_ms = p_osmt->opt.transaction_timeout;
- req.retry_cnt = p_osmt->opt.retry_count;
-
- req.flags = OSM_SA_FLAGS_SYNC;
- req.query_context = p_context;
- req.pfn_query_cb = osmtest_query_res_cb;
- req.p_query_input = &user;
- req.sm_key = sm_key;
-
- status = osmv_query_sa(p_osmt->h_bind, &req);
- if (status != IB_SUCCESS) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 007E: "
- "ib_query failed (%s)\n", ib_get_err_str(status));
- goto Exit;
- }
-
- status = p_context->result.status;
-
- if (status != IB_SUCCESS) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 007F: "
- "ib_query failed (%s)\n", ib_get_err_str(status));
- if (status == IB_REMOTE_ERROR) {
- p_mad =
- osm_madw_get_mad_ptr(p_context->result.
- p_result_madw);
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR,
- "Remote error = %s\n",
- ib_get_mad_status_str(p_mad));
-
- status =
- (ib_net16_t) (p_mad->status & IB_SMP_STATUS_MASK);
- }
- goto Exit;
- }
-
-Exit:
- OSM_LOG_EXIT(&p_osmt->log);
- return (status);
-}
-
-/**********************************************************************
- * Get SwitchInfo record by LID
- **********************************************************************/
-ib_api_status_t
-osmtest_get_sw_info_rec_by_lid(IN osmtest_t * const p_osmt,
- IN ib_net16_t const lid,
- IN OUT osmtest_req_context_t * const p_context)
-{
- ib_api_status_t status = IB_SUCCESS;
- osmv_user_query_t user;
- osmv_query_req_t req;
- ib_switch_info_record_t record;
- ib_mad_t *p_mad;
-
- OSM_LOG_ENTER(&p_osmt->log);
-
- OSM_LOG(&p_osmt->log, OSM_LOG_VERBOSE,
- "Getting SwitchInfo record for LID 0x%02X\n", cl_ntoh16(lid));
-
- /*
- * Do a blocking query for this record in the subnet.
- * The result is returned in the result field of the caller's
- * context structure.
- *
- * The query structures are locals.
- */
- memset(&req, 0, sizeof(req));
- memset(&user, 0, sizeof(user));
- memset(&record, 0, sizeof(record));
-
- record.lid = lid;
- p_context->p_osmt = p_osmt;
- if (lid)
- user.comp_mask = IB_SWIR_COMPMASK_LID;
- user.attr_id = IB_MAD_ATTR_SWITCH_INFO_RECORD;
- user.attr_offset = cl_ntoh16((uint16_t) (sizeof(record) >> 3));
- user.p_attr = &record;
-
- req.query_type = OSMV_QUERY_USER_DEFINED;
- req.timeout_ms = p_osmt->opt.transaction_timeout;
- req.retry_cnt = p_osmt->opt.retry_count;
-
- req.flags = OSM_SA_FLAGS_SYNC;
- req.query_context = p_context;
- req.pfn_query_cb = osmtest_query_res_cb;
- req.p_query_input = &user;
- req.sm_key = 0;
-
- status = osmv_query_sa(p_osmt->h_bind, &req);
- if (status != IB_SUCCESS) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 006C: "
- "ib_query failed (%s)\n", ib_get_err_str(status));
- goto Exit;
- }
-
- status = p_context->result.status;
-
- if (status != IB_SUCCESS) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 006D: "
- "ib_query failed (%s)\n", ib_get_err_str(status));
- if (status == IB_REMOTE_ERROR) {
- p_mad =
- osm_madw_get_mad_ptr(p_context->result.
- p_result_madw);
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR,
- "Remote error = %s\n",
- ib_get_mad_status_str(p_mad));
-
- status =
- (ib_net16_t) (p_mad->status & IB_SMP_STATUS_MASK);
- }
- goto Exit;
- }
-
-Exit:
- OSM_LOG_EXIT(&p_osmt->log);
- return (status);
-}
-
-/**********************************************************************
- * Get LFT record by LID
- **********************************************************************/
-ib_api_status_t
-osmtest_get_lft_rec_by_lid(IN osmtest_t * const p_osmt,
- IN ib_net16_t const lid,
- IN OUT osmtest_req_context_t * const p_context)
-{
- ib_api_status_t status = IB_SUCCESS;
- osmv_user_query_t user;
- osmv_query_req_t req;
- ib_lft_record_t record;
- ib_mad_t *p_mad;
-
- OSM_LOG_ENTER(&p_osmt->log);
-
- OSM_LOG(&p_osmt->log, OSM_LOG_VERBOSE,
- "Getting LFT record for LID 0x%02X\n", cl_ntoh16(lid));
-
- /*
- * Do a blocking query for this record in the subnet.
- * The result is returned in the result field of the caller's
- * context structure.
- *
- * The query structures are locals.
- */
- memset(&req, 0, sizeof(req));
- memset(&user, 0, sizeof(user));
- memset(&record, 0, sizeof(record));
-
- record.lid = lid;
- p_context->p_osmt = p_osmt;
- if (lid)
- user.comp_mask = IB_LFTR_COMPMASK_LID;
- user.attr_id = IB_MAD_ATTR_LFT_RECORD;
- user.attr_offset = cl_ntoh16((uint16_t) (sizeof(record) >> 3));
- user.p_attr = &record;
-
- req.query_type = OSMV_QUERY_USER_DEFINED;
- req.timeout_ms = p_osmt->opt.transaction_timeout;
- req.retry_cnt = p_osmt->opt.retry_count;
-
- req.flags = OSM_SA_FLAGS_SYNC;
- req.query_context = p_context;
- req.pfn_query_cb = osmtest_query_res_cb;
- req.p_query_input = &user;
- req.sm_key = 0;
-
- status = osmv_query_sa(p_osmt->h_bind, &req);
- if (status != IB_SUCCESS) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 008A: "
- "ib_query failed (%s)\n", ib_get_err_str(status));
- goto Exit;
- }
-
- status = p_context->result.status;
-
- if (status != IB_SUCCESS) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 008B: "
- "ib_query failed (%s)\n", ib_get_err_str(status));
- if (status == IB_REMOTE_ERROR) {
- p_mad =
- osm_madw_get_mad_ptr(p_context->result.
- p_result_madw);
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR,
- "Remote error = %s\n",
- ib_get_mad_status_str(p_mad));
-
- status =
- (ib_net16_t) (p_mad->status & IB_SMP_STATUS_MASK);
- }
- goto Exit;
- }
-
-Exit:
- OSM_LOG_EXIT(&p_osmt->log);
- return (status);
-}
-
-/**********************************************************************
- * Get MFT record by LID
- **********************************************************************/
-ib_api_status_t
-osmtest_get_mft_rec_by_lid(IN osmtest_t * const p_osmt,
- IN ib_net16_t const lid,
- IN OUT osmtest_req_context_t * const p_context)
-{
- ib_api_status_t status = IB_SUCCESS;
- osmv_user_query_t user;
- osmv_query_req_t req;
- ib_mft_record_t record;
- ib_mad_t *p_mad;
-
- OSM_LOG_ENTER(&p_osmt->log);
-
- OSM_LOG(&p_osmt->log, OSM_LOG_VERBOSE,
- "Getting MFT record for LID 0x%02X\n", cl_ntoh16(lid));
-
- /*
- * Do a blocking query for this record in the subnet.
- * The result is returned in the result field of the caller's
- * context structure.
- *
- * The query structures are locals.
- */
- memset(&req, 0, sizeof(req));
- memset(&user, 0, sizeof(user));
- memset(&record, 0, sizeof(record));
-
- record.lid = lid;
- p_context->p_osmt = p_osmt;
- if (lid)
- user.comp_mask = IB_MFTR_COMPMASK_LID;
- user.attr_id = IB_MAD_ATTR_MFT_RECORD;
- user.attr_offset = cl_ntoh16((uint16_t) (sizeof(record) >> 3));
- user.p_attr = &record;
-
- req.query_type = OSMV_QUERY_USER_DEFINED;
- req.timeout_ms = p_osmt->opt.transaction_timeout;
- req.retry_cnt = p_osmt->opt.retry_count;
-
- req.flags = OSM_SA_FLAGS_SYNC;
- req.query_context = p_context;
- req.pfn_query_cb = osmtest_query_res_cb;
- req.p_query_input = &user;
- req.sm_key = 0;
-
- status = osmv_query_sa(p_osmt->h_bind, &req);
- if (status != IB_SUCCESS) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 009B: "
- "ib_query failed (%s)\n", ib_get_err_str(status));
- goto Exit;
- }
-
- status = p_context->result.status;
-
- if (status != IB_SUCCESS) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 009C: "
- "ib_query failed (%s)\n", ib_get_err_str(status));
- if (status == IB_REMOTE_ERROR) {
- p_mad =
- osm_madw_get_mad_ptr(p_context->result.
- p_result_madw);
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR,
- "Remote error = %s\n",
- ib_get_mad_status_str(p_mad));
-
- status =
- (ib_net16_t) (p_mad->status & IB_SMP_STATUS_MASK);
- }
- goto Exit;
- }
-
-Exit:
- OSM_LOG_EXIT(&p_osmt->log);
- return (status);
-}
-
-/**********************************************************************
- **********************************************************************/
-static ib_api_status_t
-osmtest_sminfo_record_request(IN osmtest_t * const p_osmt,
- IN uint8_t method,
- IN void *p_options,
- IN OUT osmtest_req_context_t * const p_context)
-{
- ib_api_status_t status = IB_SUCCESS;
- osmv_user_query_t user;
- osmv_query_req_t req;
- ib_sminfo_record_t record;
- ib_mad_t *p_mad;
- osmtest_sm_info_rec_t *p_sm_info_opt;
-
- OSM_LOG_ENTER(&p_osmt->log);
-
- /*
- * Do a blocking query for these records in the subnet.
- * The result is returned in the result field of the caller's
- * context structure.
- *
- * The query structures are locals.
- */
- memset(&req, 0, sizeof(req));
- memset(&user, 0, sizeof(user));
- memset(&record, 0, sizeof(record));
-
- p_context->p_osmt = p_osmt;
- user.attr_id = IB_MAD_ATTR_SMINFO_RECORD;
- user.attr_offset = cl_ntoh16((uint16_t) (sizeof(record) >> 3));
- p_sm_info_opt = p_options;
- if (p_sm_info_opt->sm_guid != 0) {
- record.sm_info.guid = p_sm_info_opt->sm_guid;
- user.comp_mask |= IB_SMIR_COMPMASK_GUID;
- }
- if (p_sm_info_opt->lid != 0) {
- record.lid = p_sm_info_opt->lid;
- user.comp_mask |= IB_SMIR_COMPMASK_LID;
- }
- if (p_sm_info_opt->priority != 0) {
- record.sm_info.pri_state =
- (p_sm_info_opt->priority & 0x0F) << 4;
- user.comp_mask |= IB_SMIR_COMPMASK_PRIORITY;
- }
- if (p_sm_info_opt->sm_state != 0) {
- record.sm_info.pri_state |= p_sm_info_opt->sm_state & 0x0F;
- user.comp_mask |= IB_SMIR_COMPMASK_SMSTATE;
- }
-
- user.method = method;
- user.p_attr = &record;
-
- req.query_type = OSMV_QUERY_USER_DEFINED;
- req.timeout_ms = p_osmt->opt.transaction_timeout;
- req.retry_cnt = p_osmt->opt.retry_count;
-
- req.flags = OSM_SA_FLAGS_SYNC;
- req.query_context = p_context;
- req.pfn_query_cb = osmtest_query_res_cb;
- req.p_query_input = &user;
- req.sm_key = 0;
-
- status = osmv_query_sa(p_osmt->h_bind, &req);
- if (status != IB_SUCCESS) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 008C: "
- "ib_query failed (%s)\n", ib_get_err_str(status));
- goto Exit;
- }
-
- status = p_context->result.status;
-
- if (status != IB_SUCCESS) {
- if (status != IB_INVALID_PARAMETER) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 008D: "
- "ib_query failed (%s)\n",
- ib_get_err_str(status));
- }
- if (status == IB_REMOTE_ERROR) {
- p_mad =
- osm_madw_get_mad_ptr(p_context->result.
- p_result_madw);
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR,
- "Remote error = %s\n",
- ib_get_mad_status_str(p_mad));
-
- status =
- (ib_net16_t) (p_mad->status & IB_SMP_STATUS_MASK);
- }
- goto Exit;
- }
-
-Exit:
- OSM_LOG_EXIT(&p_osmt->log);
- return (status);
-}
-
-/**********************************************************************
- **********************************************************************/
-static ib_api_status_t
-osmtest_informinfo_request(IN osmtest_t * const p_osmt,
- IN ib_net16_t attr_id,
- IN uint8_t method,
- IN void *p_options,
- IN OUT osmtest_req_context_t * const p_context)
-{
- ib_api_status_t status = IB_SUCCESS;
- osmv_user_query_t user;
- osmv_query_req_t req;
- ib_inform_info_t rec;
- ib_inform_info_record_t record;
- ib_mad_t *p_mad;
- osmtest_inform_info_t *p_inform_info_opt;
- osmtest_inform_info_rec_t *p_inform_info_rec_opt;
-
- OSM_LOG_ENTER(&p_osmt->log);
-
- /*
- * Do a blocking query for these records in the subnet.
- * The result is returned in the result field of the caller's
- * context structure.
- *
- * The query structures are locals.
- */
- memset(&req, 0, sizeof(req));
- memset(&user, 0, sizeof(user));
- memset(&rec, 0, sizeof(rec));
- memset(&record, 0, sizeof(record));
-
- p_context->p_osmt = p_osmt;
- user.attr_id = attr_id;
- if (attr_id == IB_MAD_ATTR_INFORM_INFO_RECORD) {
- user.attr_offset = cl_ntoh16((uint16_t) (sizeof(record) >> 3));
- p_inform_info_rec_opt = p_options;
- if (p_inform_info_rec_opt->subscriber_gid.unicast.prefix != 0 &&
- p_inform_info_rec_opt->subscriber_gid.unicast.
- interface_id != 0) {
- record.subscriber_gid =
- p_inform_info_rec_opt->subscriber_gid;
- user.comp_mask = IB_IIR_COMPMASK_SUBSCRIBERGID;
- }
- record.subscriber_enum =
- cl_hton16(p_inform_info_rec_opt->subscriber_enum);
- user.comp_mask |= IB_IIR_COMPMASK_ENUM;
- user.p_attr = &record;
- } else {
- user.attr_offset = cl_ntoh16((uint16_t) (sizeof(rec) >> 3));
- /* comp mask bits below are for InformInfoRecord rather than InformInfo */
- /* as currently no comp mask bits defined for InformInfo!!! */
- user.comp_mask = IB_IIR_COMPMASK_SUBSCRIBE;
- p_inform_info_opt = p_options;
- rec.subscribe = (uint8_t) p_inform_info_opt->subscribe;
- if (p_inform_info_opt->qpn) {
- rec.g_or_v.generic.qpn_resp_time_val =
- cl_hton32(p_inform_info_opt->qpn << 8);
- user.comp_mask |= IB_IIR_COMPMASK_QPN;
- }
- if (p_inform_info_opt->trap) {
- rec.g_or_v.generic.trap_num =
- cl_hton16(p_inform_info_opt->trap);
- user.comp_mask |= IB_IIR_COMPMASK_TRAPNUMB;
- }
- user.p_attr = &rec;
- }
- user.method = method;
-
- req.query_type = OSMV_QUERY_USER_DEFINED;
- req.timeout_ms = p_osmt->opt.transaction_timeout;
- req.retry_cnt = p_osmt->opt.retry_count;
-
- req.flags = OSM_SA_FLAGS_SYNC;
- req.query_context = p_context;
- req.pfn_query_cb = osmtest_query_res_cb;
- req.p_query_input = &user;
- req.sm_key = 0;
-
- status = osmv_query_sa(p_osmt->h_bind, &req);
- if (status != IB_SUCCESS) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 008E: "
- "ib_query failed (%s)\n", ib_get_err_str(status));
- goto Exit;
- }
-
- status = p_context->result.status;
-
- if (status != IB_SUCCESS) {
- if (status != IB_INVALID_PARAMETER) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 008F: "
- "ib_query failed (%s)\n",
- ib_get_err_str(status));
- }
- if (status == IB_REMOTE_ERROR) {
- p_mad =
- osm_madw_get_mad_ptr(p_context->result.
- p_result_madw);
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR,
- "Remote error = %s\n",
- ib_get_mad_status_str(p_mad));
-
- status =
- (ib_net16_t) (p_mad->status & IB_SMP_STATUS_MASK);
- }
- goto Exit;
- }
-
-Exit:
- OSM_LOG_EXIT(&p_osmt->log);
- return (status);
-}
-#endif
-
-/**********************************************************************
- **********************************************************************/
-static ib_api_status_t
-osmtest_validate_single_path_rec_lid_pair(IN osmtest_t * const p_osmt,
- IN path_t * const p_path)
-{
- osmtest_req_context_t context;
- const ib_path_rec_t *p_rec;
- cl_status_t status = IB_SUCCESS;
- size_t num_recs;
-
- OSM_LOG_ENTER(&p_osmt->log);
-
- memset(&context, 0, sizeof(context));
-
- status = osmtest_get_path_rec_by_lid_pair(p_osmt,
- p_path->rec.slid,
- p_path->rec.dlid, &context);
- if (status != IB_SUCCESS) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0102: "
- "ib_query failed (%s)\n", ib_get_err_str(status));
- goto Exit;
- }
-
- num_recs = context.result.result_cnt;
- if (num_recs != 1) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0103: "
- "Too many records. Expected 1, received %zu\n",
- num_recs);
-
- status = IB_ERROR;
- } else {
- p_rec =
- osmv_get_query_path_rec(context.result.p_result_madw, 0);
-
- status = osmtest_validate_path_data(p_osmt, p_path, p_rec);
- if (status != IB_SUCCESS) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0104: "
- "osmtest_validate_path_data failed (%s)\n",
- ib_get_err_str(status));
- }
- }
-
-Exit:
- /*
- * Return the IB query MAD to the pool as necessary.
- */
- if (context.result.p_result_madw != NULL) {
- osm_mad_pool_put(&p_osmt->mad_pool,
- context.result.p_result_madw);
- context.result.p_result_madw = NULL;
- }
-
- OSM_LOG_EXIT(&p_osmt->log);
- return (status);
-}
-
-/**********************************************************************
- **********************************************************************/
-static ib_api_status_t
-osmtest_validate_single_node_rec_lid(IN osmtest_t * const p_osmt,
- IN ib_net16_t const lid,
- IN node_t * const p_node)
-{
- cl_status_t status = IB_SUCCESS;
- osmv_user_query_t user;
- osmv_query_req_t req;
- ib_node_record_t record;
-
- osmtest_req_context_t context;
- const ib_node_record_t *p_rec;
- int num_recs, i;
-
- OSM_LOG_ENTER(&p_osmt->log);
-
- OSM_LOG(&p_osmt->log, OSM_LOG_DEBUG,
- "Getting NodeRecord for node with LID 0x%X\n", cl_ntoh16(lid));
-
- memset(&context, 0, sizeof(context));
- memset(&req, 0, sizeof(req));
- memset(&user, 0, sizeof(user));
- memset(&record, 0, sizeof(record));
-
- record.lid = lid;
-
- context.p_osmt = p_osmt;
- user.comp_mask = IB_NR_COMPMASK_LID;
- user.attr_id = IB_MAD_ATTR_NODE_RECORD;
- user.attr_offset = cl_ntoh16((uint16_t) (sizeof(record) >> 3));
- user.p_attr = &record;
-
- req.query_type = OSMV_QUERY_USER_DEFINED;
- req.timeout_ms = p_osmt->opt.transaction_timeout;
- req.retry_cnt = p_osmt->opt.retry_count;
- req.flags = OSM_SA_FLAGS_SYNC;
- req.query_context = &context;
- req.pfn_query_cb = osmtest_query_res_cb;
- req.p_query_input = &user;
- req.sm_key = 0;
-
- status = osmv_query_sa(p_osmt->h_bind, &req);
-
- if (status != IB_SUCCESS) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0105: "
- "ib_query failed (%s)\n", ib_get_err_str(status));
- goto Exit;
- }
-
- status = context.result.status;
-
- if (status != IB_SUCCESS) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0106: "
- "ib_query failed (%s)\n", ib_get_err_str(status));
-
- if (status == IB_REMOTE_ERROR) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR,
- "Remote error = %s\n",
- ib_get_mad_status_str(osm_madw_get_mad_ptr
- (context.result.
- p_result_madw)));
- }
- goto Exit;
- }
-
- num_recs = context.result.result_cnt;
- OSM_LOG(&p_osmt->log, OSM_LOG_VERBOSE,
- "Received %d nodes\n", num_recs);
-
- for (i = 0; i < num_recs; i++) {
- p_rec =
- osmv_get_query_node_rec(context.result.p_result_madw, i);
-
- status = osmtest_validate_node_rec(p_osmt, p_rec);
- if (status != IB_SUCCESS) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0107: "
- "osmtest_validate_node_data failed (%s)\n",
- ib_get_err_str(status));
- goto Exit;
- }
- }
-
-Exit:
- /*
- * Return the IB query MAD to the pool as necessary.
- */
- if (context.result.p_result_madw != NULL) {
- osm_mad_pool_put(&p_osmt->mad_pool,
- context.result.p_result_madw);
- context.result.p_result_madw = NULL;
- }
-
- OSM_LOG_EXIT(&p_osmt->log);
- return (status);
-}
-
-/**********************************************************************
- **********************************************************************/
-static ib_api_status_t
-osmtest_validate_single_port_rec_lid(IN osmtest_t * const p_osmt,
- IN port_t * const p_port)
-{
- osmtest_req_context_t context;
-
- const ib_portinfo_record_t *p_rec;
- cl_status_t status = IB_SUCCESS;
-
- OSM_LOG_ENTER(&p_osmt->log);
-
- memset(&context, 0, sizeof(context));
-
- context.p_osmt = p_osmt;
- osmtest_get_port_rec_by_num(p_osmt,
- p_port->rec.lid,
- p_port->rec.port_num, &context);
- if (status != IB_SUCCESS) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0108: "
- "ib_query failed (%s)\n", ib_get_err_str(status));
-
- goto Exit;
- }
-
- /* we should have got exactly one port */
- p_rec = osmv_get_query_portinfo_rec(context.result.p_result_madw, 0);
- status = osmtest_validate_port_rec(p_osmt, p_rec);
- if (status != IB_SUCCESS) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0109: "
- "osmtest_validate_port_data failed (%s)\n",
- ib_get_err_str(status));
- }
-
-Exit:
- /*
- * Return the IB query MAD to the pool as necessary.
- */
- if (context.result.p_result_madw != NULL) {
- osm_mad_pool_put(&p_osmt->mad_pool,
- context.result.p_result_madw);
- context.result.p_result_madw = NULL;
- }
-
- OSM_LOG_EXIT(&p_osmt->log);
- return (status);
-}
-
-/**********************************************************************
- **********************************************************************/
-static ib_api_status_t
-osmtest_validate_single_path_rec_guid_pair(IN osmtest_t * const p_osmt,
- IN const osmv_guid_pair_t *
- const p_pair)
-{
- osmtest_req_context_t context;
- const ib_path_rec_t *p_rec;
- cl_status_t status = IB_SUCCESS;
- size_t num_recs;
- osmv_query_req_t req;
- uint32_t i;
- boolean_t got_error = FALSE;
-
- OSM_LOG_ENTER(&p_osmt->log);
-
- memset(&req, 0, sizeof(req));
- memset(&context, 0, sizeof(context));
-
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR,
- "\n\t\t\t\tChecking src 0x%016" PRIx64
- " to dest 0x%016" PRIx64 "\n",
- cl_ntoh64(p_pair->src_guid), cl_ntoh64(p_pair->dest_guid));
-
- context.p_osmt = p_osmt;
-
- req.timeout_ms = p_osmt->opt.transaction_timeout;
- req.retry_cnt = p_osmt->opt.retry_count;
- req.flags = OSM_SA_FLAGS_SYNC;
- req.query_context = &context;
- req.pfn_query_cb = osmtest_query_res_cb;
-
- req.query_type = OSMV_QUERY_PATH_REC_BY_PORT_GUIDS;
- req.p_query_input = p_pair;
- req.sm_key = 0;
-
- status = osmv_query_sa(p_osmt->h_bind, &req);
- if (status != IB_SUCCESS) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0110: "
- "ib_query failed (%s)\n", ib_get_err_str(status));
- goto Exit;
- }
-
- status = context.result.status;
-
- if (status != IB_SUCCESS) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0111: "
- "ib_query failed (%s)\n", ib_get_err_str(status));
-
- if (status == IB_REMOTE_ERROR) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR,
- "Remote error = %s\n",
- ib_get_mad_status_str(osm_madw_get_mad_ptr
- (context.result.
- p_result_madw)));
- }
- goto Exit;
- }
-
- num_recs = context.result.result_cnt;
- OSM_LOG(&p_osmt->log, OSM_LOG_VERBOSE, "%zu records\n", num_recs);
-
- for (i = 0; i < num_recs; i++) {
- p_rec =
- osmv_get_query_path_rec(context.result.p_result_madw, i);
-
- /*
- * Make sure the GUID values are correct
- */
- if (p_rec->dgid.unicast.interface_id != p_pair->dest_guid) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0112: "
- "Destination GUID mismatch\n"
- "\t\t\t\texpected 0x%016" PRIx64
- ", received 0x%016" PRIx64 "\n",
- cl_ntoh64(p_pair->dest_guid),
- cl_ntoh64(p_rec->dgid.unicast.interface_id));
- got_error = TRUE;
- }
-
- if (p_rec->sgid.unicast.interface_id != p_pair->src_guid) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0113: "
- "Source GUID mismatch\n"
- "\t\t\t\texpected 0x%016" PRIx64
- ", received 0x%016" PRIx64 ".\n",
- cl_ntoh64(p_pair->src_guid),
- cl_ntoh64(p_rec->sgid.unicast.interface_id));
- got_error = TRUE;
- }
-
- status = osmtest_validate_path_rec(p_osmt, p_rec);
- if (status != IB_SUCCESS) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0114: "
- "osmtest_validate_path_rec failed (%s)\n",
- ib_get_err_str(status));
- got_error = TRUE;
- }
- if (got_error || (status != IB_SUCCESS)) {
- osm_dump_path_record(&p_osmt->log, p_rec,
- OSM_LOG_VERBOSE);
- if (status == IB_SUCCESS)
- status = IB_ERROR;
- goto Exit;
- }
- }
-
-Exit:
- /*
- * Return the IB query MAD to the pool as necessary.
- */
- if (context.result.p_result_madw != NULL) {
- osm_mad_pool_put(&p_osmt->mad_pool,
- context.result.p_result_madw);
- context.result.p_result_madw = NULL;
- }
-
- OSM_LOG_EXIT(&p_osmt->log);
- return (status);
-}
-
-/**********************************************************************
- **********************************************************************/
-static ib_api_status_t
-osmtest_validate_single_path_recs(IN osmtest_t * const p_osmt)
-{
- path_t *p_path;
- cl_status_t status = IB_SUCCESS;
- const cl_qmap_t *p_path_tbl;
-/* We skip node to node path record validation since it might contains
- NONEXISTENT PATHS, i.e. when using UPDN */
- osmv_guid_pair_t guid_pair;
- uint16_t cnt;
-
- OSM_LOG_ENTER(&p_osmt->log);
-
- OSM_LOG(&p_osmt->log, OSM_LOG_VERBOSE,
- "Validating individual path record queries\n");
- p_path_tbl = &p_osmt->exp_subn.path_tbl;
-
- osmtest_prepare_db(p_osmt);
-
- /*
- * Walk the list of all path records, and ask for each one
- * specifically. Make sure we get it.
- */
- cnt = 0;
- p_path = (path_t *) cl_qmap_head(p_path_tbl);
- while (p_path != (path_t *) cl_qmap_end(p_path_tbl)) {
- status =
- osmtest_validate_single_path_rec_lid_pair(p_osmt, p_path);
- if (status != IB_SUCCESS)
- goto Exit;
- cnt++;
- p_path = (path_t *) cl_qmap_next(&p_path->map_item);
- }
-
- OSM_LOG(&p_osmt->log, OSM_LOG_VERBOSE,
- "Total of %u path records validated using LID based query\n",
- cnt);
-
- status = osmtest_check_missing_paths(p_osmt);
- if (status != IB_SUCCESS) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0115: "
- "osmtest_check_missing_paths failed (%s)\n",
- ib_get_err_str(status));
- goto Exit;
- }
-
- /*
- * Do the whole thing again with port GUID pairs.
- * Note that multiple path records may be returned
- * for each guid pair if LMC > 0.
- */
- osmtest_prepare_db(p_osmt);
- cnt = 0;
- p_path = (path_t *) cl_qmap_head(p_path_tbl);
- while (p_path != (path_t *) cl_qmap_end(p_path_tbl)) {
- guid_pair.src_guid = p_path->rec.sgid.unicast.interface_id;
- guid_pair.dest_guid = p_path->rec.dgid.unicast.interface_id;
- status = osmtest_validate_single_path_rec_guid_pair(p_osmt,
- &guid_pair);
- if (status != IB_SUCCESS)
- goto Exit;
- cnt++;
- p_path = (path_t *) cl_qmap_next(&p_path->map_item);
- }
-
- OSM_LOG(&p_osmt->log, OSM_LOG_VERBOSE,
- "Total of %u path records validated using GUID based query\n",
- cnt);
-
- status = osmtest_check_missing_paths(p_osmt);
- if (status != IB_SUCCESS) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0116: "
- "osmtest_check_missing_paths failed (%s)\n",
- ib_get_err_str(status));
- goto Exit;
- }
-
-Exit:
- OSM_LOG_EXIT(&p_osmt->log);
- return (status);
-}
-
-/**********************************************************************
- **********************************************************************/
-static ib_api_status_t
-osmtest_validate_single_node_recs(IN osmtest_t * const p_osmt)
-{
- node_t *p_node;
- cl_status_t status = IB_SUCCESS;
- const cl_qmap_t *p_node_lid_tbl;
- uint16_t cnt = 0;
-
- OSM_LOG_ENTER(&p_osmt->log);
-
- p_node_lid_tbl = &p_osmt->exp_subn.node_lid_tbl;
-
- osmtest_prepare_db(p_osmt);
-
- OSM_LOG(&p_osmt->log, OSM_LOG_VERBOSE,
- "Validating individual node record queries\n");
-
- /*
- * Walk the list of all node records, and ask for each one
- * specifically. Make sure we get it.
- */
- p_node = (node_t *) cl_qmap_head(p_node_lid_tbl);
- while (p_node != (node_t *) cl_qmap_end(p_node_lid_tbl)) {
- status = osmtest_validate_single_node_rec_lid(p_osmt,
- (ib_net16_t)
- cl_qmap_key((cl_map_item_t *) p_node), p_node);
- if (status != IB_SUCCESS) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 011A: "
- "osmtest_validate_single_node_rec_lid (%s)\n",
- ib_get_err_str(status));
- goto Exit;
- }
- cnt++;
- p_node = (node_t *) cl_qmap_next(&p_node->map_item);
- }
-
- OSM_LOG(&p_osmt->log, OSM_LOG_VERBOSE,
- "Total of %u node records validated\n", cnt);
-
- status = osmtest_check_missing_nodes(p_osmt);
- if (status != IB_SUCCESS) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0117: "
- "osmtest_check_missing_nodes (%s)\n",
- ib_get_err_str(status));
- goto Exit;
- }
-
-Exit:
- OSM_LOG_EXIT(&p_osmt->log);
- return (status);
-}
-
-/**********************************************************************
- **********************************************************************/
-static ib_api_status_t
-osmtest_validate_single_port_recs(IN osmtest_t * const p_osmt)
-{
- port_t *p_port;
- cl_status_t status = IB_SUCCESS;
- const cl_qmap_t *p_port_key_tbl;
- uint16_t cnt = 0;
-
- OSM_LOG_ENTER(&p_osmt->log);
-
- p_port_key_tbl = &p_osmt->exp_subn.port_key_tbl;
-
- osmtest_prepare_db(p_osmt);
-
- OSM_LOG(&p_osmt->log, OSM_LOG_VERBOSE,
- "Validating individual port record queries\n");
-
- /*
- * Walk the list of all port records, and ask for each one
- * specifically. Make sure we get it.
- */
- p_port = (port_t *) cl_qmap_head(p_port_key_tbl);
- while (p_port != (port_t *) cl_qmap_end(p_port_key_tbl)) {
- status = osmtest_validate_single_port_rec_lid(p_osmt, p_port);
- if (status != IB_SUCCESS) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 011B: "
- "osmtest_validate_single_port_rec_lid (%s)\n",
- ib_get_err_str(status));
- goto Exit;
- }
- cnt++;
- p_port = (port_t *) cl_qmap_next(&p_port->map_item);
- }
-
- OSM_LOG(&p_osmt->log, OSM_LOG_VERBOSE,
- "Total of %u port records validated\n", cnt);
-
- status = osmtest_check_missing_ports(p_osmt);
- if (status != IB_SUCCESS) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0118: "
- "osmtest_check_missing_paths failed (%s)\n",
- ib_get_err_str(status));
- goto Exit;
- }
-
-Exit:
- OSM_LOG_EXIT(&p_osmt->log);
- return (status);
-}
-
-/**********************************************************************
- **********************************************************************/
-static ib_api_status_t osmtest_validate_against_db(IN osmtest_t * const p_osmt)
-{
- ib_api_status_t status = IB_SUCCESS;
- ib_gid_t portgid, mgid;
- osmtest_sm_info_rec_t sm_info_rec_opt;
- osmtest_inform_info_t inform_info_opt;
- osmtest_inform_info_rec_t inform_info_rec_opt;
-#ifdef VENDOR_RMPP_SUPPORT
- ib_net64_t sm_key;
- ib_net16_t test_lid;
- uint8_t lmc;
- osmtest_req_context_t context;
-#ifdef DUAL_SIDED_RMPP
- osmv_multipath_req_t request;
-#endif
- uint8_t i;
-#endif
-
- OSM_LOG_ENTER(&p_osmt->log);
-
-#ifdef VENDOR_RMPP_SUPPORT
- status = osmtest_validate_all_node_recs(p_osmt);
- if (status != IB_SUCCESS)
- goto Exit;
-#endif
-
- status = osmtest_validate_single_node_recs(p_osmt);
- if (status != IB_SUCCESS)
- goto Exit;
-
- /* Exercise SA PathRecord multicast destination code */
- memset(&context, 0, sizeof(context));
- ib_gid_set_default(&portgid, portguid);
- /* Set IPoIB broadcast MGID */
- mgid.unicast.prefix = CL_HTON64(0xff12401bffff0000ULL);
- mgid.unicast.interface_id = CL_HTON64(0x00000000ffffffffULL);
- /* Can't check status as don't know whether port is running IPoIB */
- osmtest_get_path_rec_by_gid_pair(p_osmt, portgid, mgid, &context);
-
- /* Other link local unicast PathRecord */
- memset(&context, 0, sizeof(context));
- ib_gid_set_default(&portgid, portguid);
- ib_gid_set_default(&mgid, portguid);
- mgid.raw[7] = 0xff; /* not default GID prefix */
- /* Can't check status as don't know whether ??? */
- osmtest_get_path_rec_by_gid_pair(p_osmt, portgid, mgid, &context);
-
- /* Off subnet (site local) unicast PathRecord */
- memset(&context, 0, sizeof(context));
- ib_gid_set_default(&portgid, portguid);
- ib_gid_set_default(&mgid, portguid);
- mgid.raw[1] = 0xc0; /* site local */
- /* Can't check status as don't know whether ??? */
- osmtest_get_path_rec_by_gid_pair(p_osmt, portgid, mgid, &context);
-
- /* More than link local scope multicast PathRecord */
- memset(&context, 0, sizeof(context));
- ib_gid_set_default(&portgid, portguid);
- /* Set IPoIB broadcast MGID */
- mgid.unicast.prefix = CL_HTON64(0xff15401bffff0000ULL); /* site local */
- mgid.unicast.interface_id = CL_HTON64(0x00000000ffffffffULL);
- /* Can't check status as don't know whether port is running IPoIB */
- osmtest_get_path_rec_by_gid_pair(p_osmt, portgid, mgid, &context);
-
-#if defined (VENDOR_RMPP_SUPPORT) && defined (DUAL_SIDED_RMPP)
- memset(&context, 0, sizeof(context));
- memset(&request, 0, sizeof(request));
- request.comp_mask =
- IB_MPR_COMPMASK_SGIDCOUNT | IB_MPR_COMPMASK_DGIDCOUNT;
- request.sgid_count = 1;
- request.dgid_count = 1;
- ib_gid_set_default(&request.gids[0], portguid);
- ib_gid_set_default(&request.gids[1], portguid);
- status = osmtest_get_multipath_rec(p_osmt, &request, &context);
- if (status != IB_SUCCESS)
- goto Exit;
-
- memset(&context, 0, sizeof(context));
- memset(&request, 0, sizeof(request));
-
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, EXPECTING_ERRORS_START "\n");
- status = osmtest_get_multipath_rec(p_osmt, &request, &context);
- if (status != IB_SUCCESS) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR,
- "Got error %s\n", ib_get_err_str(status));
- }
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, EXPECTING_ERRORS_END "\n");
-
- if (status == IB_SUCCESS) {
- status = IB_ERROR;
- goto Exit;
- }
-
- memset(&context, 0, sizeof(context));
- memset(&request, 0, sizeof(request));
- request.comp_mask = IB_MPR_COMPMASK_SGIDCOUNT;
- request.sgid_count = 1;
- ib_gid_set_default(&request.gids[0], portguid);
-
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, EXPECTING_ERRORS_START "\n");
- status = osmtest_get_multipath_rec(p_osmt, &request, &context);
- if (status != IB_SUCCESS) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR,
- "Got error %s\n", ib_get_err_str(status));
- }
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, EXPECTING_ERRORS_END "\n");
-
- if (status == IB_SUCCESS) {
- status = IB_ERROR;
- goto Exit;
- }
-
- memset(&context, 0, sizeof(context));
- memset(&request, 0, sizeof(request));
- request.comp_mask =
- IB_MPR_COMPMASK_SGIDCOUNT | IB_MPR_COMPMASK_DGIDCOUNT;
- request.sgid_count = 1;
- request.dgid_count = 1;
- ib_gid_set_default(&request.gids[0], portguid);
- /* Set IPoIB broadcast MGID as DGID */
- request.gids[1].unicast.prefix = CL_HTON64(0xff12401bffff0000ULL);
- request.gids[1].unicast.interface_id = CL_HTON64(0x00000000ffffffffULL);
-
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, EXPECTING_ERRORS_START "\n");
- status = osmtest_get_multipath_rec(p_osmt, &request, &context);
- if (status != IB_SUCCESS) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR,
- "Got error %s\n", ib_get_err_str(status));
- }
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, EXPECTING_ERRORS_END "\n");
-
- if (status == IB_SUCCESS) {
- status = IB_ERROR;
- goto Exit;
- }
-
- memset(&context, 0, sizeof(context));
- request.comp_mask =
- IB_MPR_COMPMASK_SGIDCOUNT | IB_MPR_COMPMASK_DGIDCOUNT;
- request.sgid_count = 1;
- request.dgid_count = 1;
- /* Set IPoIB broadcast MGID as SGID */
- request.gids[0].unicast.prefix = CL_HTON64(0xff12401bffff0000ULL);
- request.gids[0].unicast.interface_id = CL_HTON64(0x00000000ffffffffULL);
- ib_gid_set_default(&request.gids[1], portguid);
-
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, EXPECTING_ERRORS_START "\n");
- status = osmtest_get_multipath_rec(p_osmt, &request, &context);
- if (status != IB_SUCCESS) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR,
- "Got error %s\n", ib_get_err_str(status));
- }
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, EXPECTING_ERRORS_END "\n");
-
- if (status == IB_SUCCESS) {
- status = IB_ERROR;
- goto Exit;
- }
-
- memset(&context, 0, sizeof(context));
- memset(&request, 0, sizeof(request));
- request.comp_mask =
- IB_MPR_COMPMASK_SGIDCOUNT | IB_MPR_COMPMASK_DGIDCOUNT |
- IB_MPR_COMPMASK_NUMBPATH;
- request.sgid_count = 2;
- request.dgid_count = 2;
- request.num_path = 2;
- ib_gid_set_default(&request.gids[0], portguid);
- ib_gid_set_default(&request.gids[1], portguid);
- ib_gid_set_default(&request.gids[2], portguid);
- ib_gid_set_default(&request.gids[3], portguid);
- status = osmtest_get_multipath_rec(p_osmt, &request, &context);
- if (status != IB_SUCCESS)
- goto Exit;
-#endif
-
-#ifdef VENDOR_RMPP_SUPPORT
- /* GUIDInfoRecords */
- status = osmtest_validate_all_guidinfo_recs(p_osmt);
- if (status != IB_SUCCESS)
- goto Exit;
-
- /* If LMC > 0, test non base LID SA PortInfoRecord request */
- status =
- osmtest_get_local_port_lmc(p_osmt, p_osmt->local_port.lid, &lmc);
- if (status != IB_SUCCESS)
- goto Exit;
-
- if (lmc != 0) {
- status =
- osmtest_get_local_port_lmc(p_osmt,
- p_osmt->local_port.lid + 1,
- NULL);
- if (status != IB_SUCCESS)
- goto Exit;
- }
-
- status = osmtest_get_local_port_lmc(p_osmt, 0xffff, NULL);
- if (status != IB_SUCCESS)
- goto Exit;
-
- test_lid = cl_ntoh16(p_osmt->local_port.lid);
-
- /* More GUIDInfo Record tests */
- memset(&context, 0, sizeof(context));
- status = osmtest_get_guidinfo_rec_by_lid(p_osmt, test_lid, &context);
- if (status != IB_SUCCESS)
- goto Exit;
-
- memset(&context, 0, sizeof(context));
- status = osmtest_get_guidinfo_rec_by_lid(p_osmt, 0xffff, &context);
- if (status != IB_SUCCESS)
- goto Exit;
-
- /* Some PKeyTable Record tests */
- sm_key = OSM_DEFAULT_SM_KEY;
- memset(&context, 0, sizeof(context));
- status =
- osmtest_get_pkeytbl_rec_by_lid(p_osmt, test_lid, sm_key, &context);
- if (status != IB_SUCCESS)
- goto Exit;
-
- memset(&context, 0, sizeof(context));
-
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, EXPECTING_ERRORS_START "\n");
- status = osmtest_get_pkeytbl_rec_by_lid(p_osmt, test_lid, 0, &context);
- if (status != IB_SUCCESS) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR,
- "Got error %s\n", ib_get_err_str(status));
- }
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, EXPECTING_ERRORS_END "\n");
-
- if (status == IB_SUCCESS) {
- status = IB_ERROR;
- goto Exit;
- }
-
- memset(&context, 0, sizeof(context));
- status =
- osmtest_get_pkeytbl_rec_by_lid(p_osmt, 0xffff, sm_key, &context);
- if (status != IB_SUCCESS)
- goto Exit;
-
- /* SwitchInfo Record tests */
- memset(&context, 0, sizeof(context));
- status = osmtest_get_sw_info_rec_by_lid(p_osmt, 0, &context);
- if (status != IB_SUCCESS)
- goto Exit;
-
- memset(&context, 0, sizeof(context));
- status = osmtest_get_sw_info_rec_by_lid(p_osmt, test_lid, &context);
- if (status != IB_SUCCESS)
- goto Exit;
-
- /* LFT Record tests */
- memset(&context, 0, sizeof(context));
- status = osmtest_get_lft_rec_by_lid(p_osmt, 0, &context);
- if (status != IB_SUCCESS)
- goto Exit;
-
- memset(&context, 0, sizeof(context));
- status = osmtest_get_lft_rec_by_lid(p_osmt, test_lid, &context);
- if (status != IB_SUCCESS)
- goto Exit;
-
- /* MFT Record tests */
- memset(&context, 0, sizeof(context));
- status = osmtest_get_mft_rec_by_lid(p_osmt, 0, &context);
- if (status != IB_SUCCESS)
- goto Exit;
-
- memset(&context, 0, sizeof(context));
- status = osmtest_get_mft_rec_by_lid(p_osmt, test_lid, &context);
- if (status != IB_SUCCESS)
- goto Exit;
-
- /* Some LinkRecord tests */
- /* FromLID */
- memset(&context, 0, sizeof(context));
- status = osmtest_get_link_rec_by_lid(p_osmt, test_lid, 0, &context);
- if (status != IB_SUCCESS)
- goto Exit;
-
- /* ToLID */
- memset(&context, 0, sizeof(context));
- status = osmtest_get_link_rec_by_lid(p_osmt, 0, test_lid, &context);
- if (status != IB_SUCCESS)
- goto Exit;
-
- /* FromLID & ToLID */
- memset(&context, 0, sizeof(context));
- status =
- osmtest_get_link_rec_by_lid(p_osmt, test_lid, test_lid, &context);
- if (status != IB_SUCCESS)
- goto Exit;
-
- /* NodeRecord test */
- memset(&context, 0, sizeof(context));
- status = osmtest_get_node_rec_by_lid(p_osmt, 0xffff, &context);
- if (status != IB_SUCCESS)
- goto Exit;
-
- /* SMInfoRecord tests */
- memset(&sm_info_rec_opt, 0, sizeof(sm_info_rec_opt));
- memset(&context, 0, sizeof(context));
- status = osmtest_sminfo_record_request(p_osmt, IB_MAD_METHOD_SET,
- &sm_info_rec_opt, &context);
- if (status == IB_SUCCESS) {
- status = IB_ERROR;
- goto Exit;
- } else {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "IS EXPECTED ERROR ^^^^\n");
- }
-
- memset(&sm_info_rec_opt, 0, sizeof(sm_info_rec_opt));
- memset(&context, 0, sizeof(context));
- status = osmtest_sminfo_record_request(p_osmt, IB_MAD_METHOD_GETTABLE,
- &sm_info_rec_opt, &context);
- if (status != IB_SUCCESS)
- goto Exit;
-
- memset(&sm_info_rec_opt, 0, sizeof(sm_info_rec_opt));
- sm_info_rec_opt.lid = test_lid; /* local LID */
- memset(&context, 0, sizeof(context));
- status = osmtest_sminfo_record_request(p_osmt, IB_MAD_METHOD_GETTABLE,
- &sm_info_rec_opt, &context);
- if (status != IB_SUCCESS)
- goto Exit;
-
- if (portguid != 0) {
- memset(&sm_info_rec_opt, 0, sizeof(sm_info_rec_opt));
- sm_info_rec_opt.sm_guid = portguid; /* local GUID */
- memset(&context, 0, sizeof(context));
- status =
- osmtest_sminfo_record_request(p_osmt,
- IB_MAD_METHOD_GETTABLE,
- &sm_info_rec_opt, &context);
- if (status != IB_SUCCESS)
- goto Exit;
- }
-
- for (i = 1; i < 16; i++) {
- memset(&sm_info_rec_opt, 0, sizeof(sm_info_rec_opt));
- sm_info_rec_opt.priority = i;
- memset(&context, 0, sizeof(context));
- status =
- osmtest_sminfo_record_request(p_osmt,
- IB_MAD_METHOD_GETTABLE,
- &sm_info_rec_opt, &context);
- if (status != IB_SUCCESS)
- goto Exit;
- }
-
- for (i = 1; i < 4; i++) {
- memset(&sm_info_rec_opt, 0, sizeof(sm_info_rec_opt));
- sm_info_rec_opt.sm_state = i;
- memset(&context, 0, sizeof(context));
- status =
- osmtest_sminfo_record_request(p_osmt,
- IB_MAD_METHOD_GETTABLE,
- &sm_info_rec_opt, &context);
- if (status != IB_SUCCESS)
- goto Exit;
- }
-
- /* InformInfoRecord tests */
- OSM_LOG(&p_osmt->log, OSM_LOG_VERBOSE, "InformInfoRecord "
- "Sending a BAD - Set Unsubscribe request\n");
- memset(&inform_info_opt, 0, sizeof(inform_info_opt));
- memset(&inform_info_rec_opt, 0, sizeof(inform_info_rec_opt));
- memset(&context, 0, sizeof(context));
- status =
- osmtest_informinfo_request(p_osmt, IB_MAD_ATTR_INFORM_INFO_RECORD,
- IB_MAD_METHOD_SET, &inform_info_rec_opt,
- &context);
- if (status == IB_SUCCESS) {
- status = IB_ERROR;
- goto Exit;
- } else {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "InformInfoRecord "
- "IS EXPECTED ERROR ^^^^\n");
- }
-
- OSM_LOG(&p_osmt->log, OSM_LOG_VERBOSE, "InformInfoRecord "
- "Sending a Good - Empty GetTable request\n");
- memset(&context, 0, sizeof(context));
- status =
- osmtest_informinfo_request(p_osmt, IB_MAD_ATTR_INFORM_INFO_RECORD,
- IB_MAD_METHOD_GETTABLE,
- &inform_info_rec_opt, &context);
- if (status != IB_SUCCESS)
- goto Exit;
-
- /* InformInfo tests */
- OSM_LOG(&p_osmt->log, OSM_LOG_VERBOSE, "InformInfo "
- "Sending a BAD - Empty Get request "
- "(should fail with NO_RECORDS)\n");
- memset(&context, 0, sizeof(context));
- status = osmtest_informinfo_request(p_osmt, IB_MAD_ATTR_INFORM_INFO,
- IB_MAD_METHOD_GET, &inform_info_opt,
- &context);
- if (status == IB_SUCCESS) {
- status = IB_ERROR;
- goto Exit;
- } else {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "InformInfo "
- "IS EXPECTED ERROR ^^^^\n");
- }
-
- OSM_LOG(&p_osmt->log, OSM_LOG_VERBOSE, "InformInfo "
- "Sending a BAD - Set Unsubscribe request\n");
- memset(&context, 0, sizeof(context));
- status = osmtest_informinfo_request(p_osmt, IB_MAD_ATTR_INFORM_INFO,
- IB_MAD_METHOD_SET, &inform_info_opt,
- &context);
- if (status == IB_SUCCESS) {
- status = IB_ERROR;
- goto Exit;
- } else {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "InformInfo UnSubscribe "
- "IS EXPECTED ERROR ^^^^\n");
- }
-
- /* Now subscribe */
- OSM_LOG(&p_osmt->log, OSM_LOG_VERBOSE, "InformInfo "
- "Sending a Good - Set Subscribe request\n");
- inform_info_opt.subscribe = TRUE;
- memset(&context, 0, sizeof(context));
- status = osmtest_informinfo_request(p_osmt, IB_MAD_ATTR_INFORM_INFO,
- IB_MAD_METHOD_SET, &inform_info_opt,
- &context);
- if (status != IB_SUCCESS)
- goto Exit;
-
- /* Now unsubscribe (QPN needs to be 1 to work) */
- OSM_LOG(&p_osmt->log, OSM_LOG_VERBOSE, "InformInfo "
- "Sending a Good - Set Unsubscribe request\n");
- inform_info_opt.subscribe = FALSE;
- inform_info_opt.qpn = 1;
- memset(&context, 0, sizeof(context));
- status = osmtest_informinfo_request(p_osmt, IB_MAD_ATTR_INFORM_INFO,
- IB_MAD_METHOD_SET, &inform_info_opt,
- &context);
- if (status != IB_SUCCESS)
- goto Exit;
-
- /* Now subscribe again */
- OSM_LOG(&p_osmt->log, OSM_LOG_VERBOSE, "InformInfo "
- "Sending a Good - Set Subscribe request\n");
- inform_info_opt.subscribe = TRUE;
- inform_info_opt.qpn = 1;
- memset(&context, 0, sizeof(context));
- status = osmtest_informinfo_request(p_osmt, IB_MAD_ATTR_INFORM_INFO,
- IB_MAD_METHOD_SET, &inform_info_opt,
- &context);
- if (status != IB_SUCCESS)
- goto Exit;
-
- /* Subscribe over existing subscription */
- OSM_LOG(&p_osmt->log, OSM_LOG_VERBOSE, "InformInfo "
- "Sending a Good - Set Subscribe (again) request\n");
- inform_info_opt.qpn = 0;
- memset(&context, 0, sizeof(context));
- status = osmtest_informinfo_request(p_osmt, IB_MAD_ATTR_INFORM_INFO,
- IB_MAD_METHOD_SET, &inform_info_opt,
- &context);
- if (status != IB_SUCCESS)
- goto Exit;
-
- /* More InformInfoRecord tests */
- /* RID lookup (with currently invalid enum) */
- OSM_LOG(&p_osmt->log, OSM_LOG_VERBOSE, "InformInfoRecord "
- "Sending a Good - GetTable by GID\n");
- ib_gid_set_default(&inform_info_rec_opt.subscriber_gid,
- p_osmt->local_port.port_guid);
- inform_info_rec_opt.subscriber_enum = 1;
- memset(&context, 0, sizeof(context));
- status =
- osmtest_informinfo_request(p_osmt, IB_MAD_ATTR_INFORM_INFO_RECORD,
- IB_MAD_METHOD_GETTABLE,
- &inform_info_rec_opt, &context);
- if (status != IB_SUCCESS)
- goto Exit;
-
- /* Enum lookup */
- OSM_LOG(&p_osmt->log, OSM_LOG_VERBOSE, "InformInfoRecord "
- "Sending a Good - GetTable (subscriber_enum == 0) request\n");
- inform_info_rec_opt.subscriber_enum = 0;
- memset(&context, 0, sizeof(context));
- status =
- osmtest_informinfo_request(p_osmt, IB_MAD_ATTR_INFORM_INFO_RECORD,
- IB_MAD_METHOD_GETTABLE,
- &inform_info_rec_opt, &context);
- if (status != IB_SUCCESS)
- goto Exit;
-
- /* Get all InformInfoRecords */
- OSM_LOG(&p_osmt->log, OSM_LOG_VERBOSE, "InformInfoRecord "
- "Sending a Good - GetTable (ALL records) request\n");
- memset(&inform_info_rec_opt, 0, sizeof(inform_info_rec_opt));
- memset(&context, 0, sizeof(context));
- status =
- osmtest_informinfo_request(p_osmt, IB_MAD_ATTR_INFORM_INFO_RECORD,
- IB_MAD_METHOD_GETTABLE,
- &inform_info_rec_opt, &context);
- if (status != IB_SUCCESS)
- goto Exit;
-
- /* Another subscription */
- OSM_LOG(&p_osmt->log, OSM_LOG_VERBOSE, "InformInfo "
- "Sending another Good - Set Subscribe (again) request\n");
- inform_info_opt.qpn = 0;
- inform_info_opt.trap = 0x1234;
- memset(&context, 0, sizeof(context));
- status = osmtest_informinfo_request(p_osmt, IB_MAD_ATTR_INFORM_INFO,
- IB_MAD_METHOD_SET, &inform_info_opt,
- &context);
- if (status != IB_SUCCESS)
- goto Exit;
-
- /* Get all InformInfoRecords again */
- OSM_LOG(&p_osmt->log, OSM_LOG_VERBOSE, "InformInfoRecord "
- "Sending a Good - GetTable (ALL records) request\n");
- memset(&inform_info_rec_opt, 0, sizeof(inform_info_rec_opt));
- memset(&context, 0, sizeof(context));
- status =
- osmtest_informinfo_request(p_osmt, IB_MAD_ATTR_INFORM_INFO_RECORD,
- IB_MAD_METHOD_GETTABLE,
- &inform_info_rec_opt, &context);
- if (status != IB_SUCCESS)
- goto Exit;
-
- /* Cleanup subscriptions before further testing */
- /* Does order of deletion matter ? Test this !!! */
- OSM_LOG(&p_osmt->log, OSM_LOG_VERBOSE, "InformInfo "
- "Sending a Good - Set (cleanup) request\n");
- inform_info_opt.subscribe = FALSE;
- inform_info_opt.qpn = 1;
- memset(&context, 0, sizeof(context));
- status = osmtest_informinfo_request(p_osmt, IB_MAD_ATTR_INFORM_INFO,
- IB_MAD_METHOD_SET,
- &inform_info_opt, &context);
- if (status != IB_SUCCESS)
- goto Exit;
-
- /* Get all InformInfoRecords again */
- OSM_LOG(&p_osmt->log, OSM_LOG_VERBOSE, "InformInfoRecord "
- "Sending a Good - GetTable (ALL records) request\n");
- memset(&inform_info_rec_opt, 0, sizeof(inform_info_rec_opt));
- memset(&context, 0, sizeof(context));
- status =
- osmtest_informinfo_request(p_osmt, IB_MAD_ATTR_INFORM_INFO_RECORD,
- IB_MAD_METHOD_GETTABLE,
- &inform_info_rec_opt, &context);
- if (status != IB_SUCCESS)
- goto Exit;
-
- OSM_LOG(&p_osmt->log, OSM_LOG_VERBOSE, "InformInfo"
- "Sending a Good - Set (cleanup) request\n");
- inform_info_opt.subscribe = FALSE;
- inform_info_opt.qpn = 1;
- inform_info_opt.trap = 0;
- memset(&context, 0, sizeof(context));
- status = osmtest_informinfo_request(p_osmt, IB_MAD_ATTR_INFORM_INFO,
- IB_MAD_METHOD_SET,
- &inform_info_opt, &context);
- if (status != IB_SUCCESS)
- goto Exit;
-
- /* Get all InformInfoRecords a final time */
- OSM_LOG(&p_osmt->log, OSM_LOG_VERBOSE, "InformInfoRecord "
- "Sending a Good - GetTable (ALL records) request\n");
- memset(&inform_info_rec_opt, 0, sizeof(inform_info_rec_opt));
- memset(&context, 0, sizeof(context));
- status =
- osmtest_informinfo_request(p_osmt, IB_MAD_ATTR_INFORM_INFO_RECORD,
- IB_MAD_METHOD_GETTABLE,
- &inform_info_rec_opt, &context);
- if (status != IB_SUCCESS)
- goto Exit;
-
- if (lmc != 0) {
- test_lid = cl_ntoh16(p_osmt->local_port.lid + 1);
-
- /* Another GUIDInfo Record test */
- memset(&context, 0, sizeof(context));
- status =
- osmtest_get_guidinfo_rec_by_lid(p_osmt, test_lid, &context);
- if (status != IB_SUCCESS)
- goto Exit;
-
- /* Another PKeyTable Record test */
- memset(&context, 0, sizeof(context));
- status =
- osmtest_get_pkeytbl_rec_by_lid(p_osmt, test_lid, sm_key,
- &context);
- if (status != IB_SUCCESS)
- goto Exit;
-
- /* Another SwitchInfo Record test */
- memset(&context, 0, sizeof(context));
- status =
- osmtest_get_sw_info_rec_by_lid(p_osmt, test_lid, &context);
- if (status != IB_SUCCESS)
- goto Exit;
-
- /* Another LFT Record test */
- memset(&context, 0, sizeof(context));
- status = osmtest_get_lft_rec_by_lid(p_osmt, test_lid, &context);
- if (status != IB_SUCCESS)
- goto Exit;
-
- /* Another MFT Record test */
- memset(&context, 0, sizeof(context));
- status = osmtest_get_mft_rec_by_lid(p_osmt, test_lid, &context);
- if (status != IB_SUCCESS)
- goto Exit;
-
- /* More LinkRecord tests */
- /* FromLID */
- memset(&context, 0, sizeof(context));
- status =
- osmtest_get_link_rec_by_lid(p_osmt, test_lid, 0, &context);
- if (status != IB_SUCCESS)
- goto Exit;
-
- /* ToLID */
- memset(&context, 0, sizeof(context));
- status =
- osmtest_get_link_rec_by_lid(p_osmt, 0, test_lid, &context);
- if (status != IB_SUCCESS)
- goto Exit;
-
- /* Another NodeRecord test */
- memset(&context, 0, sizeof(context));
- status =
- osmtest_get_node_rec_by_lid(p_osmt, test_lid, &context);
- if (status != IB_SUCCESS)
- goto Exit;
- }
-
- /* PathRecords */
- if (!p_osmt->opt.ignore_path_records) {
- status = osmtest_validate_all_path_recs(p_osmt);
- if (status != IB_SUCCESS)
- goto Exit;
-
- if (lmc != 0) {
- memset(&context, 0, sizeof(context));
- status =
- osmtest_get_path_rec_by_lid_pair(p_osmt, test_lid,
- test_lid,
- &context);
- if (status != IB_SUCCESS)
- goto Exit;
-
- memset(&context, 0, sizeof(context));
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR,
- EXPECTING_ERRORS_START "\n");
- status =
- osmtest_get_path_rec_by_lid_pair(p_osmt, 0xffff,
- 0xffff, &context);
- if (status != IB_SUCCESS) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR,
- "Got error %s\n",
- ib_get_err_str(status));
- }
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR,
- EXPECTING_ERRORS_END "\n");
-
- if (status == IB_SUCCESS) {
- status = IB_ERROR;
- goto Exit;
- }
-
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR,
- EXPECTING_ERRORS_START "\n");
-
- status =
- osmtest_get_path_rec_by_lid_pair(p_osmt, test_lid,
- 0xffff, &context);
- if (status != IB_SUCCESS) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR,
- "Got error %s\n",
- ib_get_err_str(status));
- }
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR,
- EXPECTING_ERRORS_END "\n");
-
- if (status == IB_SUCCESS) {
- status = IB_ERROR;
- goto Exit;
- }
- }
- }
-#endif
-
- status = osmtest_validate_single_port_recs(p_osmt);
- if (status != IB_SUCCESS)
- goto Exit;
-
- if (!p_osmt->opt.ignore_path_records) {
- status = osmtest_validate_single_path_recs(p_osmt);
- if (status != IB_SUCCESS)
- goto Exit;
- }
-
-Exit:
- OSM_LOG_EXIT(&p_osmt->log);
- return (status);
-}
-
-/**********************************************************************
- **********************************************************************/
-static const osmtest_token_t *str_get_token(IN char *const p_str)
-{
- const osmtest_token_t *p_tok;
- uint32_t index = 0;
-
- p_tok = &token_array[index];
-
- while (p_tok->val != OSMTEST_TOKEN_UNKNOWN) {
- if (strnicmp(p_str, p_tok->str, p_tok->str_size) == 0)
- return (p_tok);
-
- p_tok = &token_array[++index];
- }
-
- return (NULL);
-}
-
-/**********************************************************************
- Returns true if not whitespace character encountered before EOL.
-**********************************************************************/
-static boolean_t
-str_skip_white(IN char line[], IN OUT uint32_t * const p_offset)
-{
- while (((line[*p_offset] == '\t') ||
- (line[*p_offset] == ' ')) &&
- (line[*p_offset] != '\n') && (line[*p_offset] != '\0')) {
- ++*p_offset;
- }
-
- if ((line[*p_offset] == '\n') || (line[*p_offset] == '\0'))
- return (FALSE);
- else
- return (TRUE);
-}
-
-/**********************************************************************
- Returns true if not whitespace character encountered before EOL.
-**********************************************************************/
-static void str_skip_token(IN char line[], IN OUT uint32_t * const p_offset)
-{
- while ((line[*p_offset] != '\t') &&
- (line[*p_offset] != ' ') && (line[*p_offset] != '\0')) {
- ++*p_offset;
- }
-}
-
-/**********************************************************************
- **********************************************************************/
-static ib_api_status_t
-osmtest_parse_node(IN osmtest_t * const p_osmt,
- IN FILE * const fh, IN OUT uint32_t * const p_line_num)
-{
- ib_api_status_t status = IB_SUCCESS;
- uint32_t offset;
- char line[OSMTEST_MAX_LINE_LEN];
- boolean_t done = FALSE;
- node_t *p_node;
- node_t *p_guid_node;
- const osmtest_token_t *p_tok;
-
- OSM_LOG_ENTER(&p_osmt->log);
-
- p_node = node_new();
- CL_ASSERT(p_node != NULL);
-
- /*
- * Parse the inventory file and create the database.
- */
- while (!done) {
- if (fgets(line, OSMTEST_MAX_LINE_LEN, fh) == NULL) {
- /*
- * End of file in the middle of a definition.
- */
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0119: "
- "Unexpected end of file\n");
- status = IB_ERROR;
- goto Exit;
- }
-
- ++*p_line_num;
-
- /*
- * Skip whitespace
- */
- offset = 0;
- if (!str_skip_white(line, &offset))
- continue; /* whole line was whitespace */
-
- p_tok = str_get_token(&line[offset]);
- if (p_tok == NULL) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0120: "
- "Ignoring line %u with unknown token: %s\n",
- *p_line_num, &line[offset]);
- continue;
- }
-
- OSM_LOG(&p_osmt->log, OSM_LOG_DEBUG,
- "Found '%s' (line %u)\n", p_tok->str, *p_line_num);
-
- str_skip_token(line, &offset);
-
- switch (p_tok->val) {
- case OSMTEST_TOKEN_COMMENT:
- break;
-
- case OSMTEST_TOKEN_LID:
- p_node->comp.lid = 0xFFFF;
- p_node->rec.lid =
- cl_hton16((uint16_t)
- strtoul(&line[offset], NULL, 0));
- OSM_LOG(&p_osmt->log, OSM_LOG_DEBUG, "lid = 0x%X\n",
- cl_ntoh16(p_node->rec.lid));
- break;
-
- case OSMTEST_TOKEN_BASE_VERSION:
- p_node->comp.node_info.base_version = 0xFF;
- p_node->rec.node_info.base_version =
- (uint8_t) strtoul(&line[offset], NULL, 0);
- OSM_LOG(&p_osmt->log, OSM_LOG_DEBUG,
- "base_version = 0x%X\n",
- p_node->rec.node_info.base_version);
- break;
-
- case OSMTEST_TOKEN_CLASS_VERSION:
- p_node->comp.node_info.class_version = 0xFF;
- p_node->rec.node_info.class_version =
- (uint8_t) strtoul(&line[offset], NULL, 0);
- OSM_LOG(&p_osmt->log, OSM_LOG_DEBUG,
- "class_version = 0x%X\n",
- p_node->rec.node_info.class_version);
- break;
-
- case OSMTEST_TOKEN_NODE_TYPE:
- p_node->comp.node_info.node_type = 0xFF;
- p_node->rec.node_info.node_type =
- (uint8_t) strtoul(&line[offset], NULL, 0);
- OSM_LOG(&p_osmt->log, OSM_LOG_DEBUG,
- "node_type = 0x%X\n",
- p_node->rec.node_info.node_type);
- break;
-
- case OSMTEST_TOKEN_NUM_PORTS:
- p_node->comp.node_info.num_ports = 0xFF;
- p_node->rec.node_info.num_ports =
- (uint8_t) strtoul(&line[offset], NULL, 0);
- OSM_LOG(&p_osmt->log, OSM_LOG_DEBUG,
- "num_ports = 0x%X\n",
- p_node->rec.node_info.num_ports);
- break;
-
- case OSMTEST_TOKEN_SYS_GUID:
- p_node->comp.node_info.sys_guid = 0xFFFFFFFFFFFFFFFFULL;
- p_node->rec.node_info.sys_guid =
- cl_hton64(strtoull(&line[offset], NULL, 0));
- OSM_LOG(&p_osmt->log, OSM_LOG_DEBUG,
- "sys_guid = 0x%016" PRIx64 "\n",
- cl_ntoh64(p_node->rec.node_info.sys_guid));
- break;
-
- case OSMTEST_TOKEN_NODE_GUID:
- p_node->comp.node_info.node_guid =
- 0xFFFFFFFFFFFFFFFFULL;
- p_node->rec.node_info.node_guid =
- cl_hton64(strtoull(&line[offset], NULL, 0));
- OSM_LOG(&p_osmt->log, OSM_LOG_DEBUG,
- "node_guid = 0x%016" PRIx64 "\n",
- cl_ntoh64(p_node->rec.node_info.node_guid));
- break;
-
- case OSMTEST_TOKEN_PORT_GUID:
- p_node->comp.node_info.port_guid =
- 0xFFFFFFFFFFFFFFFFULL;
- p_node->rec.node_info.port_guid =
- cl_hton64(strtoull(&line[offset], NULL, 0));
- OSM_LOG(&p_osmt->log, OSM_LOG_DEBUG,
- "port_guid = 0x%016" PRIx64 "\n",
- cl_ntoh64(p_node->rec.node_info.port_guid));
- break;
-
- case OSMTEST_TOKEN_PARTITION_CAP:
- p_node->comp.node_info.partition_cap = 0xFFFF;
- p_node->rec.node_info.partition_cap =
- cl_hton16((uint16_t)
- strtoul(&line[offset], NULL, 0));
- OSM_LOG(&p_osmt->log, OSM_LOG_DEBUG,
- "partition_cap = 0x%X\n",
- cl_ntoh16(p_node->rec.node_info.partition_cap));
- break;
-
- case OSMTEST_TOKEN_DEVICE_ID:
- p_node->comp.node_info.device_id = 0xFFFF;
- p_node->rec.node_info.device_id = cl_hton16((uint16_t)
- strtoul
- (&line
- [offset],
- NULL, 0));
- OSM_LOG(&p_osmt->log, OSM_LOG_DEBUG,
- "device_id = 0x%X\n",
- cl_ntoh16(p_node->rec.node_info.device_id));
- break;
-
- case OSMTEST_TOKEN_REVISION:
- p_node->comp.node_info.revision = 0xFFFFFFFF;
- p_node->rec.node_info.revision =
- cl_hton32(strtoul(&line[offset], NULL, 0));
- OSM_LOG(&p_osmt->log, OSM_LOG_DEBUG,
- "revision = 0x%X\n",
- cl_ntoh32(p_node->rec.node_info.revision));
- break;
-
- case OSMTEST_TOKEN_PORT_NUM:
- p_node->comp.node_info.port_num_vendor_id |=
- IB_NODE_INFO_PORT_NUM_MASK;
- p_node->rec.node_info.port_num_vendor_id |=
- (uint8_t) strtoul(&line[offset], NULL, 0);
- OSM_LOG(&p_osmt->log, OSM_LOG_DEBUG,
- "local_port_num = 0x%X\n",
- ib_node_info_get_local_port_num
- (&p_node->rec.node_info));
- break;
-
- case OSMTEST_TOKEN_VENDOR_ID:
- p_node->comp.node_info.port_num_vendor_id |=
- IB_NODE_INFO_VEND_ID_MASK;
- p_node->rec.node_info.port_num_vendor_id |=
- cl_hton32(strtoul(&line[offset], NULL, 0));
- OSM_LOG(&p_osmt->log, OSM_LOG_DEBUG,
- "vendor_id = 0x%X\n",
- cl_ntoh32(ib_node_info_get_vendor_id
- (&p_node->rec.node_info)));
- break;
-
- case OSMTEST_TOKEN_END:
- done = TRUE;
- break;
-
- default:
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0121: "
- "Ignoring line %u with unknown token: %s\n",
- *p_line_num, &line[offset]);
-
- break;
- }
- }
-
- /*
- * Make sure the user specified enough information, then
- * add this object to the database.
- */
- if (p_node->comp.lid == 0) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0122: "
- "LID must be specified for defined nodes\n");
- node_delete(p_node);
- goto Exit;
- }
-
- cl_qmap_insert(&p_osmt->exp_subn.node_lid_tbl,
- p_node->rec.lid, &p_node->map_item);
-
- p_guid_node = node_new();
- CL_ASSERT(p_node != NULL);
-
- *p_guid_node = *p_node;
-
- cl_qmap_insert(&p_osmt->exp_subn.node_guid_tbl,
- p_guid_node->rec.node_info.node_guid,
- &p_guid_node->map_item);
-
-Exit:
- OSM_LOG_EXIT(&p_osmt->log);
- return (status);
-}
-
-/**********************************************************************
- **********************************************************************/
-static ib_api_status_t
-osmtest_parse_port(IN osmtest_t * const p_osmt,
- IN FILE * const fh, IN OUT uint32_t * const p_line_num)
-{
- ib_api_status_t status = IB_SUCCESS;
- uint32_t offset;
- char line[OSMTEST_MAX_LINE_LEN];
- boolean_t done = FALSE;
- port_t *p_port;
- const osmtest_token_t *p_tok;
-
- OSM_LOG_ENTER(&p_osmt->log);
-
- p_port = port_new();
- CL_ASSERT(p_port != NULL);
-
- /*
- * Parse the inventory file and create the database.
- */
- while (!done) {
- if (fgets(line, OSMTEST_MAX_LINE_LEN, fh) == NULL) {
- /*
- * End of file in the middle of a definition.
- */
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0123: "
- "Unexpected end of file\n");
- status = IB_ERROR;
- goto Exit;
- }
-
- ++*p_line_num;
-
- /*
- * Skip whitespace
- */
- offset = 0;
- if (!str_skip_white(line, &offset))
- continue; /* whole line was whitespace */
-
- p_tok = str_get_token(&line[offset]);
- if (p_tok == NULL) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0124: "
- "Ignoring line %u with unknown token: %s\n",
- *p_line_num, &line[offset]);
- continue;
- }
-
- OSM_LOG(&p_osmt->log, OSM_LOG_DEBUG,
- "Found '%s' (line %u)\n", p_tok->str, *p_line_num);
-
- str_skip_token(line, &offset);
-
- switch (p_tok->val) {
- case OSMTEST_TOKEN_COMMENT:
- break;
-
- case OSMTEST_TOKEN_LID:
- p_port->comp.lid = 0xFFFF;
- p_port->rec.lid =
- cl_hton16((uint16_t)
- strtoul(&line[offset], NULL, 0));
- OSM_LOG(&p_osmt->log, OSM_LOG_DEBUG, "lid = 0x%X\n",
- cl_ntoh16(p_port->rec.lid));
- break;
-
- case OSMTEST_TOKEN_PORT_NUM:
- p_port->comp.port_num = 0xFF;
- p_port->rec.port_num =
- (uint8_t) strtoul(&line[offset], NULL, 0);
- OSM_LOG(&p_osmt->log, OSM_LOG_DEBUG,
- "port_num = 0x%u\n", p_port->rec.port_num);
- break;
-
- case OSMTEST_TOKEN_MKEY:
- p_port->comp.port_info.m_key = 0xFFFFFFFFFFFFFFFFULL;
- p_port->rec.port_info.m_key =
- cl_hton64(strtoull(&line[offset], NULL, 0));
- OSM_LOG(&p_osmt->log, OSM_LOG_DEBUG,
- "m_key = 0x%016" PRIx64 "\n",
- cl_ntoh64(p_port->rec.port_info.m_key));
- break;
-
- case OSMTEST_TOKEN_SUBN_PREF:
- p_port->comp.port_info.subnet_prefix =
- 0xFFFFFFFFFFFFFFFFULL;
- p_port->rec.port_info.subnet_prefix =
- cl_hton64(strtoull(&line[offset], NULL, 0));
- OSM_LOG(&p_osmt->log, OSM_LOG_DEBUG,
- "subnet_prefix = 0x%016" PRIx64 "\n",
- cl_ntoh64(p_port->rec.port_info.subnet_prefix));
- break;
-
- case OSMTEST_TOKEN_BASE_LID:
- p_port->comp.port_info.base_lid = 0xFFFF;
- p_port->rec.port_info.base_lid =
- cl_hton16((uint16_t)
- strtoul(&line[offset], NULL, 0));
- OSM_LOG(&p_osmt->log, OSM_LOG_DEBUG,
- "base_lid = 0x%X\n",
- cl_ntoh16(p_port->rec.port_info.base_lid));
- break;
-
- case OSMTEST_TOKEN_SM_BASE_LID:
- p_port->comp.port_info.master_sm_base_lid = 0xFFFF;
- p_port->rec.port_info.master_sm_base_lid =
- cl_hton16((uint16_t)
- strtoul(&line[offset], NULL, 0));
- OSM_LOG(&p_osmt->log, OSM_LOG_DEBUG,
- "master_sm_base_lid = 0x%X\n",
- cl_ntoh16(p_port->rec.port_info.master_sm_base_lid));
- break;
-
- case OSMTEST_TOKEN_CAP_MASK:
- p_port->comp.port_info.capability_mask = 0xFFFFFFFF;
- p_port->rec.port_info.capability_mask =
- cl_hton32((uint32_t)
- strtoul(&line[offset], NULL, 0));
- OSM_LOG(&p_osmt->log, OSM_LOG_DEBUG,
- "capability_mask = 0x%X\n",
- cl_ntoh32(p_port->rec.port_info.capability_mask));
- break;
-
- case OSMTEST_TOKEN_DIAG_CODE:
- p_port->comp.port_info.diag_code = 0xFFFF;
- p_port->rec.port_info.diag_code =
- cl_hton16((uint16_t)
- strtoul(&line[offset], NULL, 0));
- OSM_LOG(&p_osmt->log, OSM_LOG_DEBUG,
- "diag_code = 0x%X\n",
- cl_ntoh16(p_port->rec.port_info.diag_code));
- break;
-
- case OSMTEST_TOKEN_MKEY_LEASE_PER:
- p_port->comp.port_info.m_key_lease_period = 0xFFFF;
- p_port->rec.port_info.m_key_lease_period =
- cl_hton16((uint16_t)
- strtoul(&line[offset], NULL, 0));
- OSM_LOG(&p_osmt->log, OSM_LOG_DEBUG,
- "m_key_lease_period = 0x%X\n",
- cl_ntoh16(p_port->rec.port_info.m_key_lease_period));
- break;
-
- case OSMTEST_TOKEN_LOC_PORT_NUM:
- p_port->comp.port_info.local_port_num = 0xFF;
- p_port->rec.port_info.local_port_num =
- (uint8_t) strtoul(&line[offset], NULL, 0);
- OSM_LOG(&p_osmt->log, OSM_LOG_DEBUG,
- "local_port_num = 0x%u\n",
- p_port->rec.port_info.local_port_num);
- break;
-
- case OSMTEST_TOKEN_LINK_WID_EN:
- p_port->comp.port_info.link_width_enabled = 0xFF;
- p_port->rec.port_info.link_width_enabled =
- (uint8_t) strtoul(&line[offset], NULL, 0);
- OSM_LOG(&p_osmt->log, OSM_LOG_DEBUG,
- "link_width_enabled = 0x%u\n",
- p_port->rec.port_info.link_width_enabled);
- break;
-
- case OSMTEST_TOKEN_LINK_WID_SUP:
- p_port->comp.port_info.link_width_supported = 0xFF;
- p_port->rec.port_info.link_width_supported =
- (uint8_t) strtoul(&line[offset], NULL, 0);
- OSM_LOG(&p_osmt->log, OSM_LOG_DEBUG,
- "link_width_supported = 0x%u\n",
- p_port->rec.port_info.link_width_supported);
- break;
-
- case OSMTEST_TOKEN_LINK_WID_ACT:
- p_port->comp.port_info.link_width_active = 0xFF;
- p_port->rec.port_info.link_width_active =
- (uint8_t) strtoul(&line[offset], NULL, 0);
- OSM_LOG(&p_osmt->log, OSM_LOG_DEBUG,
- "link_width_active = 0x%u\n",
- p_port->rec.port_info.link_width_active);
- break;
-
- case OSMTEST_TOKEN_LINK_SPEED_SUP:
- p_port->comp.port_info.state_info1 = 0xFF;
- ib_port_info_set_link_speed_sup((uint8_t)
- strtoul(&line[offset],
- NULL, 0),
- &p_port->rec.port_info);
- OSM_LOG(&p_osmt->log, OSM_LOG_DEBUG,
- "link_speed_supported = 0x%u\n",
- ib_port_info_get_link_speed_sup(&p_port->rec.port_info));
- break;
-
- case OSMTEST_TOKEN_PORT_STATE:
- str_skip_white(line, &offset);
- p_port->comp.port_info.state_info1 = 0xFF;
- ib_port_info_set_port_state(&p_port->rec.port_info,
- ib_get_port_state_from_str
- (&line[offset]));
- OSM_LOG(&p_osmt->log, OSM_LOG_DEBUG,
- "port_state = 0x%u\n",
- ib_port_info_get_port_state(&p_port->rec.port_info));
- break;
-
- case OSMTEST_TOKEN_STATE_INFO2:
- p_port->comp.port_info.state_info2 = 0xFF;
- p_port->rec.port_info.state_info2 =
- (uint8_t) strtoul(&line[offset], NULL, 0);
- OSM_LOG(&p_osmt->log, OSM_LOG_DEBUG,
- "state_info2 = 0x%u\n",
- p_port->rec.port_info.state_info2);
- break;
-
- case OSMTEST_TOKEN_MKEY_PROT_BITS:
- p_port->comp.port_info.mkey_lmc = 0xFF;
- ib_port_info_set_mpb(&p_port->rec.port_info,
- (uint8_t) strtoul(&line[offset],
- NULL, 0));
- OSM_LOG(&p_osmt->log, OSM_LOG_DEBUG, "mpb = 0x%u\n",
- ib_port_info_get_mpb(&p_port->rec.port_info));
- break;
-
- case OSMTEST_TOKEN_LMC:
- p_port->comp.port_info.mkey_lmc = 0xFF;
- ib_port_info_set_lmc(&p_port->rec.port_info,
- (uint8_t) strtoul(&line[offset],
- NULL, 0));
- OSM_LOG(&p_osmt->log, OSM_LOG_DEBUG, "lmc = 0x%u\n",
- ib_port_info_get_lmc(&p_port->rec.port_info));
- break;
-
- case OSMTEST_TOKEN_LINK_SPEED:
- p_port->comp.port_info.link_speed = 0xFF;
- p_port->rec.port_info.link_speed =
- (uint8_t) strtoul(&line[offset], NULL, 0);
- OSM_LOG(&p_osmt->log, OSM_LOG_DEBUG,
- "link_speed = 0x%u\n",
- p_port->rec.port_info.link_speed);
- break;
-
- case OSMTEST_TOKEN_MTU_SMSL:
- p_port->comp.port_info.mtu_smsl = 0xFF;
- p_port->rec.port_info.mtu_smsl =
- (uint8_t) strtoul(&line[offset], NULL, 0);
- OSM_LOG(&p_osmt->log, OSM_LOG_DEBUG,
- "mtu_smsl = 0x%u\n",
- p_port->rec.port_info.mtu_smsl);
- break;
-
- case OSMTEST_TOKEN_VL_CAP:
- p_port->comp.port_info.vl_cap = 0xFF;
- p_port->rec.port_info.vl_cap =
- (uint8_t) strtoul(&line[offset], NULL, 0);
- OSM_LOG(&p_osmt->log, OSM_LOG_DEBUG, "vl_cap = 0x%u\n",
- p_port->rec.port_info.vl_cap);
- break;
-
- case OSMTEST_TOKEN_VL_HIGH_LIMIT:
- p_port->comp.port_info.vl_high_limit = 0xFF;
- p_port->rec.port_info.vl_high_limit =
- (uint8_t) strtoul(&line[offset], NULL, 0);
- OSM_LOG(&p_osmt->log, OSM_LOG_DEBUG,
- "vl_high_limit = 0x%u\n",
- p_port->rec.port_info.vl_high_limit);
- break;
-
- case OSMTEST_TOKEN_VL_ARB_HIGH_CAP:
- p_port->comp.port_info.vl_arb_high_cap = 0xFF;
- p_port->rec.port_info.vl_arb_high_cap =
- (uint8_t) strtoul(&line[offset], NULL, 0);
- OSM_LOG(&p_osmt->log, OSM_LOG_DEBUG,
- "vl_arb_high_cap = 0x%u\n",
- p_port->rec.port_info.vl_arb_high_cap);
- break;
-
- case OSMTEST_TOKEN_VL_ARB_LOW_CAP:
- p_port->comp.port_info.vl_arb_low_cap = 0xFF;
- p_port->rec.port_info.vl_arb_low_cap =
- (uint8_t) strtoul(&line[offset], NULL, 0);
- OSM_LOG(&p_osmt->log, OSM_LOG_DEBUG,
- "vl_arb_low_cap = 0x%u\n",
- p_port->rec.port_info.vl_arb_low_cap);
- break;
-
- case OSMTEST_TOKEN_MTU_CAP:
- p_port->comp.port_info.mtu_cap = 0xFF;
- p_port->rec.port_info.mtu_cap =
- (uint8_t) strtoul(&line[offset], NULL, 0);
- OSM_LOG(&p_osmt->log, OSM_LOG_DEBUG, "mtu_cap = 0x%u\n",
- p_port->rec.port_info.mtu_cap);
- break;
-
- case OSMTEST_TOKEN_VL_STALL_LIFE:
- p_port->comp.port_info.vl_stall_life = 0xFF;
- p_port->rec.port_info.vl_stall_life =
- (uint8_t) strtoul(&line[offset], NULL, 0);
- OSM_LOG(&p_osmt->log, OSM_LOG_DEBUG,
- "vl_stall_life = 0x%u\n",
- p_port->rec.port_info.vl_stall_life);
- break;
-
- case OSMTEST_TOKEN_VL_ENFORCE:
- p_port->comp.port_info.vl_enforce = 0xFF;
- p_port->rec.port_info.vl_enforce =
- (uint8_t) strtoul(&line[offset], NULL, 0);
- OSM_LOG(&p_osmt->log, OSM_LOG_DEBUG,
- "vl_enforce = 0x%u\n",
- p_port->rec.port_info.vl_enforce);
- break;
-
- case OSMTEST_TOKEN_MKEY_VIOL:
- p_port->comp.port_info.m_key_violations = 0xFFFF;
- p_port->rec.port_info.m_key_violations =
- cl_hton16((uint16_t)
- strtoul(&line[offset], NULL, 0));
- OSM_LOG(&p_osmt->log, OSM_LOG_DEBUG,
- "m_key_violations = 0x%X\n",
- cl_ntoh16(p_port->rec.port_info.m_key_violations));
- break;
-
- case OSMTEST_TOKEN_PKEY_VIOL:
- p_port->comp.port_info.p_key_violations = 0xFFFF;
- p_port->rec.port_info.p_key_violations =
- cl_hton16((uint16_t)
- strtoul(&line[offset], NULL, 0));
- OSM_LOG(&p_osmt->log, OSM_LOG_DEBUG,
- "p_key_violations = 0x%X\n",
- cl_ntoh16(p_port->rec.port_info.p_key_violations));
- break;
-
- case OSMTEST_TOKEN_QKEY_VIOL:
- p_port->comp.port_info.q_key_violations = 0xFFFF;
- p_port->rec.port_info.q_key_violations =
- cl_hton16((uint16_t)
- strtoul(&line[offset], NULL, 0));
- OSM_LOG(&p_osmt->log, OSM_LOG_DEBUG,
- "q_key_violations = 0x%X\n",
- cl_ntoh16(p_port->rec.port_info.q_key_violations));
- break;
-
- case OSMTEST_TOKEN_GUID_CAP:
- p_port->comp.port_info.guid_cap = 0xFF;
- p_port->rec.port_info.guid_cap =
- (uint8_t) strtoul(&line[offset], NULL, 0);
- OSM_LOG(&p_osmt->log, OSM_LOG_DEBUG,
- "guid_cap = 0x%u\n",
- p_port->rec.port_info.guid_cap);
- break;
-
- case OSMTEST_TOKEN_SUBN_TIMEOUT:
- p_port->comp.port_info.subnet_timeout = 0x1F;
- p_port->rec.port_info.subnet_timeout =
- (uint8_t) strtoul(&line[offset], NULL, 0);
- OSM_LOG(&p_osmt->log, OSM_LOG_DEBUG,
- "subnet_timeout = 0x%u\n",
- ib_port_info_get_timeout(&p_port->rec.port_info));
- break;
-
- case OSMTEST_TOKEN_RESP_TIME_VAL:
- p_port->comp.port_info.resp_time_value = 0xFF;
- p_port->rec.port_info.resp_time_value =
- (uint8_t) strtoul(&line[offset], NULL, 0);
- OSM_LOG(&p_osmt->log, OSM_LOG_DEBUG,
- "resp_time_value = 0x%u\n",
- p_port->rec.port_info.resp_time_value);
- break;
-
- case OSMTEST_TOKEN_ERR_THRESHOLD:
- p_port->comp.port_info.error_threshold = 0xFF;
- p_port->rec.port_info.error_threshold =
- (uint8_t) strtoul(&line[offset], NULL, 0);
- OSM_LOG(&p_osmt->log, OSM_LOG_DEBUG,
- "error_threshold = 0x%u\n",
- p_port->rec.port_info.error_threshold);
- break;
-
- case OSMTEST_TOKEN_END:
- done = TRUE;
- break;
-
- default:
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0125: "
- "Ignoring line %u with unknown token: %s\n",
- *p_line_num, &line[offset]);
- break;
- }
- }
-
- /*
- * Make sure the user specified enough information, then
- * add this object to the database.
- */
- if (p_port->comp.lid == 0) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0126: "
- "LID must be specified for defined ports\n");
- port_delete(p_port);
- status = IB_ERROR;
- goto Exit;
- }
-
- cl_qmap_insert(&p_osmt->exp_subn.port_key_tbl,
- port_gen_id(p_port->rec.lid, p_port->rec.port_num),
- &p_port->map_item);
-
-Exit:
- OSM_LOG_EXIT(&p_osmt->log);
- return (status);
-}
-
-/**********************************************************************
- **********************************************************************/
-static ib_api_status_t
-osmtest_parse_path(IN osmtest_t * const p_osmt,
- IN FILE * const fh, IN OUT uint32_t * const p_line_num)
-{
- ib_api_status_t status = IB_SUCCESS;
- uint32_t offset;
- char line[OSMTEST_MAX_LINE_LEN];
- boolean_t done = FALSE;
- path_t *p_path;
- const osmtest_token_t *p_tok;
- boolean_t got_error = FALSE;
-
- OSM_LOG_ENTER(&p_osmt->log);
-
- p_path = path_new();
- CL_ASSERT(p_path != NULL);
-
- /*
- * Parse the inventory file and create the database.
- */
- while (!done) {
- if (fgets(line, OSMTEST_MAX_LINE_LEN, fh) == NULL) {
- /*
- * End of file in the middle of a definition.
- */
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0127: "
- "Unexpected end of file\n");
- status = IB_ERROR;
- goto Exit;
- }
-
- ++*p_line_num;
-
- /*
- * Skip whitespace
- */
- offset = 0;
- if (!str_skip_white(line, &offset))
- continue; /* whole line was whitespace */
-
- p_tok = str_get_token(&line[offset]);
- if (p_tok == NULL) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0128: "
- "Ignoring line %u with unknown token: %s\n",
- *p_line_num, &line[offset]);
- got_error = TRUE;
- continue;
- }
-
- OSM_LOG(&p_osmt->log, OSM_LOG_DEBUG,
- "Found '%s' (line %u)\n", p_tok->str, *p_line_num);
-
- str_skip_token(line, &offset);
-
- switch (p_tok->val) {
- case OSMTEST_TOKEN_COMMENT:
- break;
-
- case OSMTEST_TOKEN_DGID:
- p_path->comp.dgid.unicast.prefix =
- 0xFFFFFFFFFFFFFFFFULL;
- p_path->comp.dgid.unicast.interface_id =
- 0xFFFFFFFFFFFFFFFFULL;
-
- str_skip_white(line, &offset);
- p_path->rec.dgid.unicast.prefix =
- cl_hton64(strtoull(&line[offset], NULL, 0));
- str_skip_token(line, &offset);
- p_path->rec.dgid.unicast.interface_id =
- cl_hton64(strtoull(&line[offset], NULL, 0));
-
- OSM_LOG(&p_osmt->log, OSM_LOG_DEBUG,
- "dgid = 0x%016" PRIx64 " 0x%016" PRIx64 "\n",
- cl_ntoh64(p_path->rec.dgid.unicast.prefix),
- cl_ntoh64(p_path->rec.dgid.unicast.interface_id));
- break;
-
- case OSMTEST_TOKEN_SGID:
- p_path->comp.sgid.unicast.prefix =
- 0xFFFFFFFFFFFFFFFFULL;
- p_path->comp.sgid.unicast.interface_id =
- 0xFFFFFFFFFFFFFFFFULL;
-
- str_skip_white(line, &offset);
- p_path->rec.sgid.unicast.prefix =
- cl_hton64(strtoull(&line[offset], NULL, 0));
- str_skip_token(line, &offset);
- p_path->rec.sgid.unicast.interface_id =
- cl_hton64(strtoull(&line[offset], NULL, 0));
-
- OSM_LOG(&p_osmt->log, OSM_LOG_DEBUG,
- "sgid = 0x%016" PRIx64 " 0x%016" PRIx64 "\n",
- cl_ntoh64(p_path->rec.sgid.unicast.prefix),
- cl_ntoh64(p_path->rec.sgid.unicast.interface_id));
- break;
-
- case OSMTEST_TOKEN_DLID:
- p_path->comp.dlid = 0xFFFF;
- p_path->rec.dlid =
- cl_hton16((uint16_t)
- strtoul(&line[offset], NULL, 0));
- OSM_LOG(&p_osmt->log, OSM_LOG_DEBUG, "dlid = 0x%X\n",
- cl_ntoh16(p_path->rec.dlid));
- break;
-
- case OSMTEST_TOKEN_SLID:
- p_path->comp.slid = 0xFFFF;
- p_path->rec.slid =
- cl_hton16((uint16_t)
- strtoul(&line[offset], NULL, 0));
- OSM_LOG(&p_osmt->log, OSM_LOG_DEBUG, "slid = 0x%X\n",
- cl_ntoh16(p_path->rec.slid));
- break;
-
- case OSMTEST_TOKEN_PKEY:
- p_path->comp.pkey = 0xFFFF;
- p_path->rec.pkey =
- cl_hton16((uint16_t)
- strtoul(&line[offset], NULL, 0));
- OSM_LOG(&p_osmt->log, OSM_LOG_DEBUG, "pkey = 0x%X\n",
- cl_ntoh16(p_path->rec.pkey));
- break;
-
- case OSMTEST_TOKEN_END:
- done = TRUE;
- break;
-
- default:
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0129: "
- "Ignoring line %u with unknown token: %s\n",
- *p_line_num, &line[offset]);
- got_error = TRUE;
- break;
- }
- }
-
- if (got_error) {
- status = IB_ERROR;
- goto Exit;
- }
- /*
- * Make sure the user specified enough information, then
- * add this object to the database.
- */
- if (osmtest_path_rec_kay_is_valid(p_osmt, p_path) == FALSE) {
- path_delete(p_path);
- status = IB_ERROR;
- goto Exit;
- }
-
- cl_qmap_insert(&p_osmt->exp_subn.path_tbl,
- osmtest_path_rec_key_get(&p_path->rec),
- &p_path->map_item);
-
-Exit:
- OSM_LOG_EXIT(&p_osmt->log);
- return (status);
-}
-
-/**********************************************************************
- **********************************************************************/
-static ib_api_status_t
-osmtest_parse_link(IN osmtest_t * const p_osmt,
- IN FILE * const fh, IN OUT uint32_t * const p_line_num)
-{
- ib_api_status_t status = IB_SUCCESS;
- uint32_t offset;
- char line[OSMTEST_MAX_LINE_LEN];
- boolean_t done = FALSE;
- const osmtest_token_t *p_tok;
- boolean_t got_error = FALSE;
-
- OSM_LOG_ENTER(&p_osmt->log);
-
- /*
- * Parse the inventory file and create the database.
- */
- while (!done) {
- if (fgets(line, OSMTEST_MAX_LINE_LEN, fh) == NULL) {
- /*
- * End of file in the middle of a definition.
- */
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 012A: "
- "Unexpected end of file\n");
- status = IB_ERROR;
- goto Exit;
- }
-
- ++*p_line_num;
-
- /*
- * Skip whitespace
- */
- offset = 0;
- if (!str_skip_white(line, &offset))
- continue; /* whole line was whitespace */
-
- p_tok = str_get_token(&line[offset]);
- if (p_tok == NULL) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 012B: "
- "Ignoring line %u with unknown token: %s\n",
- *p_line_num, &line[offset]);
- got_error = TRUE;
- continue;
- }
-
- OSM_LOG(&p_osmt->log, OSM_LOG_DEBUG,
- "Found '%s' (line %u)\n", p_tok->str, *p_line_num);
-
- str_skip_token(line, &offset);
-
- switch (p_tok->val) {
- case OSMTEST_TOKEN_FROMLID:
- case OSMTEST_TOKEN_FROMPORTNUM:
- case OSMTEST_TOKEN_TOPORTNUM:
- case OSMTEST_TOKEN_TOLID:
- /* For now */
- break;
-
- case OSMTEST_TOKEN_END:
- done = TRUE;
- break;
-
- default:
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 012C: "
- "Ignoring line %u with unknown token: %s\n",
- *p_line_num, &line[offset]);
- got_error = TRUE;
- break;
- }
- }
-
- if (got_error)
- status = IB_ERROR;
-
-Exit:
- OSM_LOG_EXIT(&p_osmt->log);
- return (status);
-}
-
-/**********************************************************************
- **********************************************************************/
-static ib_api_status_t osmtest_create_db(IN osmtest_t * const p_osmt)
-{
- FILE *fh;
- ib_api_status_t status = IB_SUCCESS;
- uint32_t offset;
- char line[OSMTEST_MAX_LINE_LEN];
- uint32_t line_num = 0;
- const osmtest_token_t *p_tok;
- boolean_t got_error = FALSE;
-
- OSM_LOG_ENTER(&p_osmt->log);
-
- fh = fopen(p_osmt->opt.file_name, "r");
- if (fh == NULL) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0130: "
- "Unable to open inventory file (%s)\n",
- p_osmt->opt.file_name);
- status = IB_ERROR;
- goto Exit;
- }
-
- /*
- * Parse the inventory file and create the database.
- */
- while (fgets(line, OSMTEST_MAX_LINE_LEN, fh) != NULL) {
- line_num++;
-
- /*
- * Skip whitespace
- */
- offset = 0;
- if (!str_skip_white(line, &offset))
- continue; /* whole line was whitespace */
-
- p_tok = str_get_token(&line[offset]);
- if (p_tok == NULL) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0131: "
- "Ignoring line %u: %s\n", line_num,
- &line[offset]);
- got_error = TRUE;
- continue;
- }
-
- OSM_LOG(&p_osmt->log, OSM_LOG_DEBUG,
- "Found '%s' (line %u)\n", p_tok->str, line_num);
-
- switch (p_tok->val) {
- case OSMTEST_TOKEN_COMMENT:
- break;
-
- case OSMTEST_TOKEN_DEFINE_NODE:
- status = osmtest_parse_node(p_osmt, fh, &line_num);
- break;
-
- case OSMTEST_TOKEN_DEFINE_PORT:
- status = osmtest_parse_port(p_osmt, fh, &line_num);
- break;
-
- case OSMTEST_TOKEN_DEFINE_PATH:
- status = osmtest_parse_path(p_osmt, fh, &line_num);
- break;
-
- case OSMTEST_TOKEN_DEFINE_LINK:
- status = osmtest_parse_link(p_osmt, fh, &line_num);
- break;
-
- default:
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0132: "
- "Ignoring line %u: %s\n", line_num,
- &line[offset]);
- got_error = TRUE;
- break;
- }
-
- if (got_error)
- status = IB_ERROR;
-
- if (status != IB_SUCCESS) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0133: "
- "Bad status received during parsing (%s)\n",
- ib_get_err_str(status));
- fclose(fh);
- goto Exit;
- }
- }
-
- fclose(fh);
-
-Exit:
- OSM_LOG_EXIT(&p_osmt->log);
- return (status);
-}
-
-/**********************************************************************
- Returns the index in the local port attribute array for the
- user's selection.
-**********************************************************************/
-static uint32_t
-osmtest_get_user_port(IN osmtest_t * const p_osmt,
- IN const ib_port_attr_t p_attr_array[],
- IN uint32_t const num_ports)
-{
- uint32_t i;
- uint32_t choice = 0;
- boolean_t done_flag = FALSE;
-
- OSM_LOG_ENTER(&p_osmt->log);
-
- /*
- * User needs prompting for the local port GUID with which
- * to bind.
- */
-
- while (done_flag == FALSE) {
- printf("\nChoose a local port number with which to bind:\n\n");
- for (i = 0; i < num_ports; i++) {
- /*
- * Print the index + 1 since by convention, port numbers
- * start with 1 on host channel adapters.
- */
-
- printf("\t%u: GUID = 0x%8" PRIx64
- ", lid = 0x%04X, state = %s\n", i + 1,
- cl_ntoh64(p_attr_array[i].port_guid),
- p_attr_array[i].lid,
- ib_get_port_state_str(p_attr_array[i].
- link_state));
- }
-
- printf("\nEnter choice (1-%u): ", i);
- scanf("%u", &choice);
- if (choice > num_ports)
- printf("\nError: Lame choice!\n");
- else
- done_flag = TRUE;
-
- }
- printf("\n");
- OSM_LOG_EXIT(&p_osmt->log);
- return (choice - 1);
-}
-
-/**********************************************************************
- **********************************************************************/
-ib_api_status_t
-osmtest_bind(IN osmtest_t * p_osmt,
- IN uint16_t max_lid, IN ib_net64_t guid OPTIONAL)
-{
- uint32_t port_index;
- ib_api_status_t status;
- uint32_t num_ports = GUID_ARRAY_SIZE;
- ib_port_attr_t attr_array[GUID_ARRAY_SIZE];
-
- OSM_LOG_ENTER(&p_osmt->log);
-
- /*
- * Call the transport layer for a list of local port
- * GUID values.
- */
- status = osm_vendor_get_all_port_attr(p_osmt->p_vendor,
- attr_array, &num_ports);
- if (status != IB_SUCCESS) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0134: "
- "Failure getting local port attributes (%s)\n",
- ib_get_err_str(status));
- goto Exit;
- }
-
- if (guid == 0) {
- /*
- * User needs prompting for the local port GUID with which
- * to bind.
- */
- port_index =
- osmtest_get_user_port(p_osmt, attr_array, num_ports);
-
- if (num_ports == 0) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0135: "
- "No local ports. Unable to proceed\n");
- goto Exit;
- }
- guid = attr_array[port_index].port_guid;
- } else {
- for (port_index = 0; port_index < num_ports; port_index++) {
- if (attr_array[port_index].port_guid == guid)
- break;
- }
-
- if (port_index == num_ports) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0136: "
- "No local port with guid 0x%016" PRIx64 "\n",
- cl_ntoh64(guid));
- status = IB_NOT_FOUND;
- goto Exit;
- }
- }
-
- /*
- * Copy the port info for the selected port.
- */
- memcpy(&p_osmt->local_port, &attr_array[port_index],
- sizeof(p_osmt->local_port));
-
- /* bind to the SA */
- OSM_LOG(&p_osmt->log, OSM_LOG_DEBUG,
- "Using port with SM LID:0x%04X\n", p_osmt->local_port.sm_lid);
- p_osmt->max_lid = max_lid;
-
- p_osmt->h_bind =
- osmv_bind_sa(p_osmt->p_vendor, &p_osmt->mad_pool, guid);
-
- if (p_osmt->h_bind == OSM_BIND_INVALID_HANDLE) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0137: "
- "Unable to bind to SA\n");
- status = IB_ERROR;
- goto Exit;
- }
-
-Exit:
- OSM_LOG_EXIT(&p_osmt->log);
- return (status);
-}
-
-/**********************************************************************
- **********************************************************************/
-ib_api_status_t osmtest_run(IN osmtest_t * const p_osmt)
-{
- ib_api_status_t status = IB_SUCCESS;
-
- OSM_LOG_ENTER(&p_osmt->log);
-
- status = osmtest_validate_sa_class_port_info(p_osmt);
- if (status != IB_SUCCESS) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0138: "
- "Could not obtain SA ClassPortInfo (%s)\n",
- ib_get_err_str(status));
- goto Exit;
- }
-
- if (p_osmt->opt.flow == OSMT_FLOW_CREATE_INVENTORY) {
- /*
- * Creating an inventory file with all nodes, ports and paths
- */
- status = osmtest_create_inventory_file(p_osmt);
- if (status != IB_SUCCESS) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0139: "
- "Inventory file create failed (%s)\n",
- ib_get_err_str(status));
- goto Exit;
- }
- } else {
- if (p_osmt->opt.flow == OSMT_FLOW_STRESS_SA) {
- /*
- * Stress SA - flood the SA with queries
- */
- switch (p_osmt->opt.stress) {
- case 0:
- case 1: /* small response SA query stress */
- status = osmtest_stress_small_rmpp(p_osmt);
- if (status != IB_SUCCESS) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR,
- "ERR 0140: "
- "Small RMPP stress test failed (%s)\n",
- ib_get_err_str(status));
- goto Exit;
- }
- break;
- case 2: /* large response SA query stress */
- status = osmtest_stress_large_rmpp(p_osmt);
- if (status != IB_SUCCESS) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR,
- "ERR 0141: "
- "Large RMPP stress test failed (%s)\n",
- ib_get_err_str(status));
- goto Exit;
- }
- break;
- case 3: /* large response Path Record SA query stress */
- status = osmtest_create_db(p_osmt);
- if (status != IB_SUCCESS) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR,
- "ERR 0142: "
- "Database creation failed (%s)\n",
- ib_get_err_str(status));
- goto Exit;
- }
-
- status = osmtest_stress_large_rmpp_pr(p_osmt);
- if (status != IB_SUCCESS) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR,
- "ERR 0143: "
- "Large RMPP stress test failed (%s)\n",
- ib_get_err_str(status));
- goto Exit;
- }
- break;
- default:
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR,
- "ERR 0144: "
- "Unknown stress test value %u\n",
- p_osmt->opt.stress);
- break;
- }
- } else {
-
- /*
- * Run normal validation tests.
- */
- if (p_osmt->opt.flow == OSMT_FLOW_ALL ||
- p_osmt->opt.flow == OSMT_FLOW_VALIDATE_INVENTORY) {
- /*
- * Only validate the given inventory file
- */
- status = osmtest_create_db(p_osmt);
- if (status != IB_SUCCESS) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR,
- "ERR 0145: "
- "Database creation failed (%s)\n",
- ib_get_err_str(status));
- goto Exit;
- }
-
- status = osmtest_validate_against_db(p_osmt);
- if (status != IB_SUCCESS) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR,
- "ERR 0146: "
- "SA validation database failure (%s)\n",
- ib_get_err_str(status));
- goto Exit;
- }
- }
-
- if (p_osmt->opt.flow == OSMT_FLOW_ALL) {
- status = osmtest_wrong_sm_key_ignored(p_osmt);
- if (status != IB_SUCCESS) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR,
- "ERR 0147: "
- "Try wrong SM_Key failed (%s)\n",
- ib_get_err_str(status));
- goto Exit;
- }
- }
-
- if (p_osmt->opt.flow == OSMT_FLOW_ALL ||
- p_osmt->opt.flow == OSMT_FLOW_SERVICE_REGISTRATION)
- {
- /*
- * run service registration, deregistration, and lease test
- */
- status = osmt_run_service_records_flow(p_osmt);
- if (status != IB_SUCCESS) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR,
- "ERR 0148: "
- "Service Flow failed (%s)\n",
- ib_get_err_str(status));
- goto Exit;
- }
- }
-
- if (p_osmt->opt.flow == OSMT_FLOW_ALL ||
- p_osmt->opt.flow == OSMT_FLOW_EVENT_FORWARDING) {
- /*
- * Run event forwarding test
- */
-#ifdef OSM_VENDOR_INTF_MTL
- status = osmt_run_inform_info_flow(p_osmt);
-
- if (status != IB_SUCCESS) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR,
- "ERR 0149: "
- "Inform Info Flow failed: (%s)\n",
- ib_get_err_str(status));
- goto Exit;
- }
-#else
- OSM_LOG(&p_osmt->log, OSM_LOG_INFO,
- "The event forwarding flow "
- "is not implemented yet!\n");
- status = IB_SUCCESS;
- goto Exit;
-#endif
- }
-
- if (p_osmt->opt.flow == OSMT_FLOW_QOS) {
- /*
- * QoS info: dump VLArb and SLtoVL tables.
- * Since it generates a huge file, we run it only
- * if explicitly required to
- */
- status = osmtest_create_db(p_osmt);
- if (status != IB_SUCCESS) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR,
- "ERR 014A: "
- "Database creation failed (%s)\n",
- ib_get_err_str(status));
- goto Exit;
- }
-
- status =
- osmt_run_slvl_and_vlarb_records_flow
- (p_osmt);
- if (status != IB_SUCCESS) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR,
- "ERR 0150: "
- "Failed to get SLtoVL and VL Arbitration Tables (%s)\n",
- ib_get_err_str(status));
- goto Exit;
- }
- }
-
- if (p_osmt->opt.flow == OSMT_FLOW_TRAP) {
- /*
- * Run trap 64/65 flow (this flow requires running of external tool)
- */
-#ifdef OSM_VENDOR_INTF_MTL
- status = osmt_run_trap64_65_flow(p_osmt);
- if (status != IB_SUCCESS) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR,
- "ERR 0151: "
- "Trap 64/65 Flow failed: (%s)\n",
- ib_get_err_str(status));
- goto Exit;
- }
-#else
- OSM_LOG(&p_osmt->log, OSM_LOG_INFO,
- "The event forwarding flow "
- "is not implemented yet!\n");
- status = IB_SUCCESS;
- goto Exit;
-#endif
- }
-
- if (p_osmt->opt.flow == OSMT_FLOW_ALL ||
- p_osmt->opt.flow == OSMT_FLOW_MULTICAST) {
- /*
- * Multicast flow
- */
- status = osmt_run_mcast_flow(p_osmt);
- if (status != IB_SUCCESS) {
- OSM_LOG(&p_osmt->log, OSM_LOG_ERROR,
- "ERR 0152: "
- "Multicast Flow failed: (%s)\n",
- ib_get_err_str(status));
- goto Exit;
- }
- }
-
- OSM_LOG(&p_osmt->log, OSM_LOG_INFO,
- "\n\n***************** ALL TESTS PASS *****************\n\n");
-
- }
- }
-
-Exit:
- OSM_LOG_EXIT(&p_osmt->log);
- return (status);
-}
diff --git a/contrib/ofed/management/opensm/scripts/opensm.init.in b/contrib/ofed/management/opensm/scripts/opensm.init.in
deleted file mode 100644
index 52293eb..0000000
--- a/contrib/ofed/management/opensm/scripts/opensm.init.in
+++ /dev/null
@@ -1,133 +0,0 @@
-#!/bin/bash
-#
-# opensm: Manage OpenSM
-#
-# chkconfig: - 09 91
-# description: Manage OpenSM
-#
-### BEGIN INIT INFO
-# Provides: opensm
-# Required-Start: $syslog
-# Default-Start: none
-# Default-Stop: 0 1 6
-# Description: Manage OpenSM
-### END INIT INFO
-#
-# Copyright (c) 2008 Voltaire, Inc. All rights reserved.
-# Copyright 2006 PathScale, Inc. All Rights Reserved.
-#
-# This Software is licensed under one of the following licenses:
-#
-# 1) under the terms of the "Common Public License 1.0" a copy of which is
-# available from the Open Source Initiative, see
-# http://www.opensource.org/licenses/cpl.php.
-#
-# 2) under the terms of the "The BSD License" a copy of which is
-# available from the Open Source Initiative, see
-# http://www.opensource.org/licenses/bsd-license.php.
-#
-# 3) under the terms of the "GNU General Public License (GPL) Version 2" a
-# copy of which is available from the Open Source Initiative, see
-# http://www.opensource.org/licenses/gpl-license.php.
-#
-# Licensee has the right to choose one of the above licenses.
-#
-# Redistributions of source code must retain the above copyright
-# notice and one of the license notices.
-#
-# Redistributions in binary form must reproduce both the above copyright
-# notice, one of the license notices in the documentation
-# and/or other materials provided with the distribution.
-
-prefix=@prefix@
-exec_prefix=@exec_prefix@
-
-# Source function library.
-if [[ -s /etc/init.d/functions ]]; then
- . /etc/init.d/functions
- rc_status() { :; }
- rc_exit() { exit $RETVAL; }
-fi
-if [[ -s /etc/rc.status ]]; then
- . /etc/rc.status
- failure() { rc_status -v; }
- success() { rc_status -v; }
-fi
-
-CONFIG=@sysconfdir@/sysconfig/opensm
-if [[ -s $CONFIG ]]; then
- . $CONFIG
-fi
-
-start () {
- echo -n "Starting opensm: "
- @sbindir@/opensm --daemon $OPTIONS > /dev/null
- if [[ $RETVAL -eq 0 ]]; then
- touch /var/lock/subsys/opensm
- success
- else
- failure
- fi
- echo
-}
-
-stop () {
- echo -n "Shutting down opensm: "
- killproc opensm
- if [[ $RETVAL -eq 0 ]]; then
- rm -f /var/lock/subsys/opensm
- success
- else
- failure
- fi
- echo
-}
-
-Xstatus () {
- pid="`pidof opensm`"
- ret=$?
- if [ $ret -eq 0 ] ; then
- echo "OpenSM is running... pid=$pid"
- else
- echo "OpenSM is not running."
- fi
-}
-
-restart() {
- stop
- start
-}
-
-# See how we were called.
-case "$1" in
- start)
- start
- ;;
- stop)
- stop
- ;;
- status)
- Xstatus
- ;;
- restart | force-reload | reload)
- restart
- ;;
- try-restart | condrestart)
- [ -e /var/lock/subsys/opensm ] && restart
- ;;
- resweep)
- killall -HUP opensm
- RETVAL=$?
- ;;
- rotatelog)
- killall -USR1 opensm
- RETVAL=$?
- ;;
- *)
- echo $"Usage: $0 {start|stop|status|restart|reload|condrestart|resweep|rotatelog}"
- RETVAL=1
- ;;
-esac
-
-_rc_status_all=$RETVAL
-rc_exit
diff --git a/contrib/ofed/management/opensm/scripts/opensm.logrotate b/contrib/ofed/management/opensm/scripts/opensm.logrotate
deleted file mode 100644
index e16e227a..0000000
--- a/contrib/ofed/management/opensm/scripts/opensm.logrotate
+++ /dev/null
@@ -1,7 +0,0 @@
-/var/log/opensm.log {
- missingok
- notifempty
- copytruncate
- weekly
- compress
-}
diff --git a/contrib/ofed/management/opensm/scripts/opensm.sysconfig b/contrib/ofed/management/opensm/scripts/opensm.sysconfig
deleted file mode 100644
index 2cc02e6..0000000
--- a/contrib/ofed/management/opensm/scripts/opensm.sysconfig
+++ /dev/null
@@ -1,2 +0,0 @@
-# It will be used for sldd.sh
-OSM_HOSTS=""
diff --git a/contrib/ofed/management/opensm/scripts/redhat-opensm.init.in b/contrib/ofed/management/opensm/scripts/redhat-opensm.init.in
deleted file mode 100755
index 9c22275..0000000
--- a/contrib/ofed/management/opensm/scripts/redhat-opensm.init.in
+++ /dev/null
@@ -1,292 +0,0 @@
-#!/bin/bash
-#
-# Bring up/down opensm
-#
-# chkconfig: - 15 85
-# description: Activates/Deactivates InfiniBand Subnet Manager
-#
-### BEGIN INIT INFO
-# Provides: opensm
-### END INIT INFO
-#
-# Copyright (c) 2008 Voltaire, Inc. All rights reserved.
-# Copyright (c) 2006 Mellanox Technologies. All rights reserved.
-#
-# This Software is licensed under one of the following licenses:
-#
-# 1) under the terms of the "Common Public License 1.0" a copy of which is
-# available from the Open Source Initiative, see
-# http://www.opensource.org/licenses/cpl.php.
-#
-# 2) under the terms of the "The BSD License" a copy of which is
-# available from the Open Source Initiative, see
-# http://www.opensource.org/licenses/bsd-license.php.
-#
-# 3) under the terms of the "GNU General Public License (GPL) Version 2" a
-# copy of which is available from the Open Source Initiative, see
-# http://www.opensource.org/licenses/gpl-license.php.
-#
-# Licensee has the right to choose one of the above licenses.
-#
-# Redistributions of source code must retain the above copyright
-# notice and one of the license notices.
-#
-# Redistributions in binary form must reproduce both the above copyright
-# notice, one of the license notices in the documentation
-# and/or other materials provided with the distribution.
-#
-#
-# $Id: openib-1.0-opensm.init,v 1.5 2006/08/02 18:18:23 dledford Exp $
-#
-# processname: @sbindir@/opensm
-# config: @sysconfdir@/sysconfig/opensm
-# pidfile: /var/run/opensm.pid
-
-prefix=@prefix@
-exec_prefix=@exec_prefix@
-
-. /etc/rc.d/init.d/functions
-
-CONFIG=@sysconfdir@/sysconfig/opensm
-if [ -f $CONFIG ]; then
- . $CONFIG
-fi
-
-prog=@sbindir@/opensm
-bin=${prog##*/}
-
-# Handover daemon for updating guid2lid cache file
-sldd_prog=@sbindir@/sldd.sh
-sldd_bin=${sldd_prog##*/}
-sldd_pid_file=/var/run/sldd.pid
-
-ACTION=$1
-
-# Setting OpenSM start parameters
-PID_FILE=/var/run/${bin}.pid
-touch $PID_FILE
-
-if [[ -n "${OSM_HOSTS}" && $(echo -n ${OSM_HOSTS} | wc -w | tr -d '[:space:]') -gt 1 ]]; then
- HONORE_GUID2LID="--honor_guid2lid"
-fi
-
-#########################################################################
-
-start_sldd()
-{
- if [ -f $sldd_pid_file ]; then
- local line p
- read line < $sldd_pid_file
- for p in $line ; do
- [ -z "${p//[0-9]/}" -a -d "/proc/$p" ] && sldd_pid="$sldd_pid $p"
- done
- fi
-
- if [ -z "$sldd_pid" ]; then
- sldd_pid=`pidof -x $sldd_bin`
- fi
-
- if [ -n "${sldd_pid:-}" ] ; then
- kill -9 ${sldd_pid} > /dev/null 2>&1
- fi
-
- $sldd_prog > /dev/null 2>&1 &
- sldd_pid=$!
-
- echo ${sldd_pid} > $sldd_pid_file
- # Sleep is needed in order to update local gid2lid cache file before running opensm
- sleep 3
-}
-
-stop_sldd()
-{
- if [ -f $sldd_pid_file ]; then
- local line p
- read line < $sldd_pid_file
- for p in $line ; do
- [ -z "${p//[0-9]/}" -a -d "/proc/$p" ] && sldd_pid="$sldd_pid $p"
- done
- fi
-
- if [ -z "$sldd_pid" ]; then
- sldd_pid=`pidof -x $sldd_bin`
- fi
-
- if [ -n "${sldd_pid:-}" ] ; then
- kill -15 ${sldd_pid} > /dev/null 2>&1
- fi
-
-}
-
-start()
-{
- local OSM_PID=
-
- pid=""
-
- if [ -f $PID_FILE ]; then
- local line p
- read line < $PID_FILE
- for p in $line ; do
- [ -z "${p//[0-9]/}" -a -d "/proc/$p" ] && pid="$pid $p"
- done
- fi
-
- if [ -z "$pid" ]; then
- pid=`pidof -o $$ -o $PPID -o %PPID -x $bin`
- fi
-
- if [ -n "${pid:-}" ] ; then
- echo $"${bin} (pid $pid) is already running..."
- else
-
- if [ -n "${HONORE_GUID2LID}" ]; then
- # Run sldd daemod
- start_sldd
- fi
-
- # Start opensm
- echo -n "Starting IB Subnet Manager"
- $prog --daemon ${HONORE_GUID2LID} ${OPTIONS} > /dev/null
- cnt=0; alive=0
- while [ $cnt -lt 6 -a $alive -ne 1 ]; do
- echo -n ".";
- sleep 1
- alive=0
- OSM_PID=`pidof $prog`
- if [ "$OSM_PID" != "" ]; then
- alive=1
- fi
- let cnt++;
- done
-
- echo $OSM_PID > $PID_FILE
- checkpid $OSM_PID
- RC=$?
- [ $RC -eq 0 ] && echo_success || echo_failure
- [ $RC -eq 0 ] && touch /var/lock/subsys/opensm
- echo
-
- fi
-return $RC
-}
-
-stop()
-{
- local pid=
- local pid1=
- local pid2=
-
- # Stop sldd daemon
- stop_sldd
-
- if [ -f $PID_FILE ]; then
- local line p
- read line < $PID_FILE
- for p in $line ; do
- [ -z "${p//[0-9]/}" -a -d "/proc/$p" ] && pid1="$pid1 $p"
- done
- fi
-
- pid2=`pidof -o $$ -o $PPID -o %PPID -x $bin`
-
- pid=`echo "$pid1 $pid2" | sed -e 's/\ /\n/g' | sort -n | uniq | sed -e 's/\n/\ /g'`
-
- if [ -n "${pid:-}" ] ; then
- # Kill opensm
- echo -n "Stopping IB Subnet Manager."
- kill -15 $pid > /dev/null 2>&1
- cnt=0; alive=1
- while [ $cnt -lt 6 -a $alive -ne 0 ]; do
- echo -n ".";
- alive=0
- for p in $pid; do
- if checkpid $p ; then alive=1; echo -n "-"; fi
- done
- let cnt++;
- sleep $alive
- done
-
- for p in $pid
- do
- while checkpid $p ; do
- kill -KILL $p > /dev/null 2>&1
- echo -n "+"
- sleep 1
- done
- done
- checkpid $pid
- RC=$?
- [ $RC -eq 0 ] && echo_failure || echo_success
- echo
- RC=$((! $RC))
- else
- echo -n "Stopping IB Subnet Manager."
- echo_failure
- echo
- RC=1
- fi
-
- # Remove pid file if any.
- rm -f $PID_FILE
- rm -f /var/lock/subsys/opensm
- return $RC
-}
-
-status()
-{
- local pid
-
- # First try "pidof"
- pid=`pidof -o $$ -o $PPID -o %PPID -x ${bin}`
- if [ -n "$pid" ]; then
- echo $"${bin} (pid $pid) is running..."
- return 0
- fi
-
- # Next try "/var/run/opensm.pid" files
- if [ -f $PID_FILE ] ; then
- read pid < $PID_FILE
- if [ -n "$pid" ]; then
- echo $"${bin} dead but pid file $PID_FILE exists"
- return 1
- fi
- fi
- echo $"${bin} is stopped"
- return 3
-}
-
-
-
-case $ACTION in
- start)
- start
- ;;
- stop)
- stop
- ;;
- restart)
- stop
- start
- ;;
- status)
- status
- ;;
- condrestart)
- pid=`pidof -o $$ -o $PPID -o %PPID -x $bin`
- if [ -n "$pid" ]; then
- stop
- sleep 1
- start
- fi
- ;;
- *)
- echo
- echo "Usage: `basename $0` {start|stop|restart|status}"
- echo
- exit 1
- ;;
-esac
-
-RC=$?
-exit $RC
diff --git a/contrib/ofed/management/opensm/scripts/sldd.sh.in b/contrib/ofed/management/opensm/scripts/sldd.sh.in
deleted file mode 100755
index f7635fe..0000000
--- a/contrib/ofed/management/opensm/scripts/sldd.sh.in
+++ /dev/null
@@ -1,246 +0,0 @@
-#!/bin/bash
-#
-# Copyright (c) 2008 Voltaire, Inc. All rights reserved.
-# Copyright (c) 2006 Mellanox Technologies. All rights reserved.
-#
-# This Software is licensed under one of the following licenses:
-#
-# 1) under the terms of the "Common Public License 1.0" a copy of which is
-# available from the Open Source Initiative, see
-# http://www.opensource.org/licenses/cpl.php.
-#
-# 2) under the terms of the "The BSD License" a copy of which is
-# available from the Open Source Initiative, see
-# http://www.opensource.org/licenses/bsd-license.php.
-#
-# 3) under the terms of the "GNU General Public License (GPL) Version 2" a
-# copy of which is available from the Open Source Initiative, see
-# http://www.opensource.org/licenses/gpl-license.php.
-#
-# Licensee has the right to choose one of the above licenses.
-#
-# Redistributions of source code must retain the above copyright
-# notice and one of the license notices.
-#
-# Redistributions in binary form must reproduce both the above copyright
-# notice, one of the license notices in the documentation
-# and/or other materials provided with the distribution.
-#
-#
-
-# OpenSM found to have the following problem
-# when handover is performed:
-# If some of the cluster nodes are rebooted during the handover they loose their LID assignment.
-# The reason for it is that the standby SM does not obey its own Guid to LID table
-# and simply uses the discovered LIDs. If some nodes are not available for it
-# their previous LID assignment is lost forever.
-
-# The idea is to use an external daemon that will distribute
-# the semi-static LID assignment table from the master SM to all standby SMs.
-# A standby SM, becoming a master . needs to obey the copied semi static LID assignment table.
-
-prefix=@prefix@
-exec_prefix=@exec_prefix@
-
-CONFIG=@sysconfdir@/sysconfig/opensm
-if [ -f $CONFIG ]; then
- . $CONFIG
-fi
-
-SLDD_DEBUG=${SLDD_DEBUG:-0}
-
-CACHE_FILE=${CACHE_FILE:-/var/cache/opensm/guid2lid}
-CACHE_DIR=$(dirname ${CACHE_FILE})
-tmp_cache=${CACHE_FILE}.tmp
-
-PING='ping -w 1 -c 1'
-
-RCP=${RCP:-/usr/bin/scp}
-RSH=${RSH:-/usr/bin/ssh}
-IFCONFIG=${IFCONFIG:-'/sbin/ifconfig -a'}
-
-declare -i SLDD_DEBUG
-RESCAN_TIME=${RESCAN_TIME:-60}
-
-if [ -z "${OSM_HOSTS}" ]; then
- [ $SLDD_DEBUG -eq 1 ] &&
- echo "No OpenSM servers (OSM_HOSTS) configured for the IB subnet."
- exit 0
-fi
-
-
-declare -a arr_OSM_HOSTS
-arr_OSM_HOSTS=(${OSM_HOSTS})
-
-num_of_osm_hosts=${#arr_OSM_HOSTS[@]}
-
-if [ ${num_of_osm_hosts} -eq 1 ]; then
- [ $SLDD_DEBUG -eq 1 ] &&
- echo "One OpenSM server configured in the IB subnet." &&
- echo "Nothing to be done for SLDD"
-
- exit 0
-fi
-
-trap 'trap_handler' 15
-
-trap_handler()
-{
- logger -i "SLDD: Exiting."
- exit 0
-}
-
-is_alive()
-{
- $PING $1 > /dev/null 2>&1
- return $?
-}
-
-is_local()
-{
- $IFCONFIG | grep -w "$1" > /dev/null 2>&1
- return $?
-}
-
-update_remote_cache()
-{
- /bin/rm -f ${CACHE_FILE}.upd
- /bin/cp -a ${CACHE_FILE} ${CACHE_FILE}.upd
-
- [ $SLDD_DEBUG -eq 1 ] &&
- echo "Updating remote cache file"
-
- for host in ${OSM_HOSTS}
- do
- # Skip local host update
- if [ "${host}" == "${local_host}" ]; then
- continue
- fi
-
- if is_alive $host; then
- stat=$($RSH $host "/bin/mkdir -p ${CACHE_DIR} > /dev/null 2>&1; /bin/rm -f ${CACHE_FILE}.${local_host} > /dev/null 2>&1; echo \$?" | tr -d '[:space:]')
- if [ "X${stat}" == "X0" ]; then
- [ $SLDD_DEBUG -eq 1 ] &&
- echo "Updating $host"
- logger -i "SLDD: updating $host with ${CACHE_FILE}"
- $RCP ${CACHE_FILE}.upd ${host}:${CACHE_FILE}.${local_host}
- /bin/cp ${CACHE_FILE}.upd ${CACHE_FILE}.${host}
- else
- [ $SLDD_DEBUG -eq 1 ] &&
- echo "$RSH to $host failed."
- logger -i "SLDD: Failed to update $host with ${CACHE_FILE}. $RSH without password should be enabled"
- exit 5
- fi
- else
- [ $SLDD_DEBUG -eq 1 ] &&
- echo "$host is down."
- continue
- fi
- done
-}
-
-get_latest_remote_cache()
-{
- # Find most updated remote cache file (the suffix should be like ip address: *.*.*.*)
- echo -n "$(/bin/ls -1t ${CACHE_FILE}.*.* 2> /dev/null | head -1)"
-}
-
-get_largest_remote_cache()
-{
- # Find largest (size) remote cache file (the suffix should be like ip address: *.*.*.*)
- echo -n "$(/bin/ls -1S ${CACHE_FILE}.*.* 2> /dev/null | head -1)"
-}
-
-swap_cache_files()
-{
- /bin/rm -f ${CACHE_FILE}.old
- /bin/mv ${CACHE_FILE} ${CACHE_FILE}.old
- /bin/cp ${largest_remote_cache} ${CACHE_FILE}
- touch ${CACHE_FILE}.tmp
-}
-
-# Find local host in the osm hosts list
-local_host=""
-for host in ${OSM_HOSTS}
-do
- if is_local $host; then
- local_host=${host}
- fi
-done
-
-# Get cache file info
-declare -i new_size=0
-declare -i last_size=0
-declare -i largest_remote_cache_size=0
-
-if [ -e ${CACHE_FILE} ]; then
- last_size=$(du -b ${CACHE_FILE} | awk '{print$1}' | tr -d '[:space:]')
-else
- touch ${CACHE_FILE} ${CACHE_FILE}.tmp
-fi
-
-# if [ ${last_size} -gt 0 ]; then
-# # First time update
-# update_remote_cache
-# fi
-
-while true
-do
- if [ -s "${CACHE_FILE}" ]; then
- new_size=$(du -b ${CACHE_FILE} | awk '{print$1}' | tr -d '[:space:]')
- # Check if local cache file grew from its last version or the time stamp changed
- if [ ${new_size} -gt ${last_size} ]
- [ "$(/bin/ls -1t ${CACHE_FILE} ${CACHE_FILE}.tmp 2> /dev/null | head -1)" != "${CACHE_FILE}.tmp" ]; then
- largest_remote_cache=$(get_largest_remote_cache)
- if [[ -n "${largest_remote_cache}" && -s "${largest_remote_cache}" ]]; then
- largest_remote_cache_size=$(du -b ${largest_remote_cache} 2> /dev/null | awk '{print$1}' | tr -d '[:space:]')
- else
- largest_remote_cache_size=0
- fi
-
- # Check if local cache file larger than remote chache file
- if [ ${new_size} -gt ${largest_remote_cache_size} ]; then
- [ $SLDD_DEBUG -eq 1 ] &&
- echo "Local cache file larger then remote. Update remote cache files"
- last_size=${new_size}
- update_remote_cache
- continue
- fi
- fi
-
- largest_remote_cache=$(get_largest_remote_cache)
- if [[ -n "${largest_remote_cache}" && -s "${largest_remote_cache}" ]]; then
- largest_remote_cache_size=$(du -b ${largest_remote_cache} 2> /dev/null | awk '{print$1}' | tr -d '[:space:]')
- else
- largest_remote_cache_size=0
- fi
-
- # Update local cache file from remote
- if [ ${largest_remote_cache_size} -gt ${new_size} ]; then
- [ $SLDD_DEBUG -eq 1 ] &&
- echo "Local cache file shorter then remote. Use ${largest_remote_cache}"
- logger -i "SLDD: updating local cache file with ${largest_remote_cache}"
- swap_cache_files
- last_size=${largest_remote_cache_size}
- fi
-
- else # The local cache file is empty
- [ $SLDD_DEBUG -eq 1 ] &&
- echo "${CACHE_FILE} is empty"
-
- largest_remote_cache=$(get_largest_remote_cache)
- if [[ -n "${largest_remote_cache}" && -s "${largest_remote_cache}" ]]; then
- # Copy it to the current cache
- [ $SLDD_DEBUG -eq 1 ] &&
- echo "Local cache file is empty. Use ${largest_remote_cache}"
- logger -i "SLDD: updating local cache file with ${largest_remote_cache}"
- swap_cache_files
- fi
-
- fi
-
- [ $SLDD_DEBUG -eq 1 ] &&
- echo "Sleeping ${RESCAN_TIME} seconds."
- sleep ${RESCAN_TIME}
-
-done
diff --git a/contrib/ofed/opensm/complib/Makefile b/contrib/ofed/opensm/complib/Makefile
new file mode 100644
index 0000000..f3005ff
--- /dev/null
+++ b/contrib/ofed/opensm/complib/Makefile
@@ -0,0 +1,34 @@
+# $FreeBSD$
+
+.PATH: ${.CURDIR}
+
+SHLIBDIR?= /usr/lib
+LIB= osmcomp
+SHLIB_MAJOR= 3
+MK_PROFILE= no
+
+SRCS= \
+cl_complib.c \
+cl_dispatcher.c \
+cl_event.c \
+cl_event_wheel.c \
+cl_list.c \
+cl_log.c \
+cl_map.c \
+cl_nodenamemap.c \
+cl_pool.c \
+cl_ptr_vector.c \
+cl_spinlock.c \
+cl_statustext.c \
+cl_thread.c \
+cl_threadpool.c \
+cl_timer.c \
+cl_vector.c \
+ib_statustext.c
+
+CFLAGS+= -I${.CURDIR}/.. -DHAVE_CONFIG_H=1
+CFLAGS+= -I${SYSROOT:U${DESTDIR}}/${INCLUDEDIR}/infiniband
+LIBADD= pthread
+VERSION_MAP= ${.CURDIR}/libosmcomp.map
+
+.include <bsd.lib.mk>
diff --git a/contrib/ofed/opensm/complib/cl_complib.c b/contrib/ofed/opensm/complib/cl_complib.c
new file mode 100644
index 0000000..286306d
--- /dev/null
+++ b/contrib/ofed/opensm/complib/cl_complib.c
@@ -0,0 +1,90 @@
+/*
+ * Copyright (c) 2004-2006 Voltaire, Inc. All rights reserved.
+ * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved.
+ * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+#if HAVE_CONFIG_H
+# include <config.h>
+#endif /* HAVE_CONFIG_H */
+
+#include <complib/cl_types.h>
+#include <complib/cl_debug.h>
+#include <complib/cl_spinlock.h>
+
+#include <stdio.h>
+#include <unistd.h>
+#include <stdlib.h>
+
+/*
+ * Prototypes
+ */
+
+extern cl_status_t __cl_timer_prov_create(void);
+
+extern void __cl_timer_prov_destroy(void);
+
+cl_spinlock_t cl_atomic_spinlock;
+
+void complib_init(void)
+{
+ cl_status_t status = CL_SUCCESS;
+
+ status = cl_spinlock_init(&cl_atomic_spinlock);
+ if (status != CL_SUCCESS)
+ goto _error;
+
+ status = __cl_timer_prov_create();
+ if (status != CL_SUCCESS)
+ goto _error;
+ return;
+
+_error:
+ cl_msg_out("__init: failed to create complib (%s)\n",
+ CL_STATUS_MSG(status));
+ exit(1);
+}
+
+void complib_exit(void)
+{
+ __cl_timer_prov_destroy();
+ cl_spinlock_destroy(&cl_atomic_spinlock);
+}
+
+boolean_t cl_is_debug(void)
+{
+#if defined( _DEBUG_ )
+ return TRUE;
+#else
+ return FALSE;
+#endif /* defined( _DEBUG_ ) */
+}
diff --git a/contrib/ofed/opensm/complib/cl_dispatcher.c b/contrib/ofed/opensm/complib/cl_dispatcher.c
new file mode 100644
index 0000000..1255c83
--- /dev/null
+++ b/contrib/ofed/opensm/complib/cl_dispatcher.c
@@ -0,0 +1,366 @@
+/*
+ * Copyright (c) 2004-2006 Voltaire, Inc. All rights reserved.
+ * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved.
+ * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+/*
+ * Abstract:
+ * Implementation of Dispatcher abstraction.
+ *
+ */
+
+#if HAVE_CONFIG_H
+# include <config.h>
+#endif /* HAVE_CONFIG_H */
+
+#include <stdlib.h>
+#include <complib/cl_dispatcher.h>
+#include <complib/cl_thread.h>
+#include <complib/cl_timer.h>
+
+/* give some guidance when we build our cl_pool of messages */
+#define CL_DISP_INITIAL_MSG_COUNT 256
+#define CL_DISP_MSG_GROW_SIZE 64
+
+/* give some guidance when we build our cl_pool of registration elements */
+#define CL_DISP_INITIAL_REG_COUNT 16
+#define CL_DISP_REG_GROW_SIZE 16
+
+/********************************************************************
+ __cl_disp_worker
+
+ Description:
+ This function takes messages off the FIFO and calls Processmsg()
+ This function executes as passive level.
+
+ Inputs:
+ p_disp - Pointer to Dispatcher object
+
+ Outputs:
+ None
+
+ Returns:
+ None
+********************************************************************/
+void __cl_disp_worker(IN void *context)
+{
+ cl_disp_msg_t *p_msg;
+ cl_dispatcher_t *p_disp = (cl_dispatcher_t *) context;
+
+ cl_spinlock_acquire(&p_disp->lock);
+
+ /* Process the FIFO until we drain it dry. */
+ while (cl_qlist_count(&p_disp->msg_fifo)) {
+ /* Pop the message at the head from the FIFO. */
+ p_msg =
+ (cl_disp_msg_t *) cl_qlist_remove_head(&p_disp->msg_fifo);
+
+ /* we track the tim ethe last message spent in the queue */
+ p_disp->last_msg_queue_time_us =
+ cl_get_time_stamp() - p_msg->in_time;
+
+ /*
+ * Release the spinlock while the message is processed.
+ * The user's callback may reenter the dispatcher
+ * and cause the lock to be reaquired.
+ */
+ cl_spinlock_release(&p_disp->lock);
+ p_msg->p_dest_reg->pfn_rcv_callback((void *)p_msg->p_dest_reg->
+ context,
+ (void *)p_msg->p_data);
+
+ cl_atomic_dec(&p_msg->p_dest_reg->ref_cnt);
+
+ /* The client has seen the data. Notify the sender as appropriate. */
+ if (p_msg->pfn_xmt_callback) {
+ p_msg->pfn_xmt_callback((void *)p_msg->context,
+ (void *)p_msg->p_data);
+ cl_atomic_dec(&p_msg->p_src_reg->ref_cnt);
+ }
+
+ /* Grab the lock for the next iteration through the list. */
+ cl_spinlock_acquire(&p_disp->lock);
+
+ /* Return this message to the pool. */
+ cl_qpool_put(&p_disp->msg_pool, (cl_pool_item_t *) p_msg);
+ }
+
+ cl_spinlock_release(&p_disp->lock);
+}
+
+void cl_disp_construct(IN cl_dispatcher_t * const p_disp)
+{
+ CL_ASSERT(p_disp);
+
+ cl_qlist_init(&p_disp->reg_list);
+ cl_ptr_vector_construct(&p_disp->reg_vec);
+ cl_qlist_init(&p_disp->msg_fifo);
+ cl_spinlock_construct(&p_disp->lock);
+ cl_qpool_construct(&p_disp->msg_pool);
+}
+
+void cl_disp_shutdown(IN cl_dispatcher_t * const p_disp)
+{
+ CL_ASSERT(p_disp);
+
+ /* Stop the thread pool. */
+ cl_thread_pool_destroy(&p_disp->worker_threads);
+
+ /* Process all outstanding callbacks. */
+ __cl_disp_worker(p_disp);
+
+ /* Free all registration info. */
+ while (!cl_is_qlist_empty(&p_disp->reg_list))
+ free(cl_qlist_remove_head(&p_disp->reg_list));
+}
+
+void cl_disp_destroy(IN cl_dispatcher_t * const p_disp)
+{
+ CL_ASSERT(p_disp);
+
+ cl_spinlock_destroy(&p_disp->lock);
+ /* Destroy the message pool */
+ cl_qpool_destroy(&p_disp->msg_pool);
+ /* Destroy the pointer vector of registrants. */
+ cl_ptr_vector_destroy(&p_disp->reg_vec);
+}
+
+cl_status_t cl_disp_init(IN cl_dispatcher_t * const p_disp,
+ IN const uint32_t thread_count,
+ IN const char *const name)
+{
+ cl_status_t status;
+
+ CL_ASSERT(p_disp);
+
+ cl_disp_construct(p_disp);
+
+ status = cl_spinlock_init(&p_disp->lock);
+ if (status != CL_SUCCESS) {
+ cl_disp_destroy(p_disp);
+ return (status);
+ }
+
+ /* Specify no upper limit to the number of messages in the pool */
+ status = cl_qpool_init(&p_disp->msg_pool, CL_DISP_INITIAL_MSG_COUNT,
+ 0, CL_DISP_MSG_GROW_SIZE, sizeof(cl_disp_msg_t),
+ NULL, NULL, NULL);
+ if (status != CL_SUCCESS) {
+ cl_disp_destroy(p_disp);
+ return (status);
+ }
+
+ status = cl_ptr_vector_init(&p_disp->reg_vec, CL_DISP_INITIAL_REG_COUNT,
+ CL_DISP_REG_GROW_SIZE);
+ if (status != CL_SUCCESS) {
+ cl_disp_destroy(p_disp);
+ return (status);
+ }
+
+ status = cl_thread_pool_init(&p_disp->worker_threads, thread_count,
+ __cl_disp_worker, p_disp, name);
+ if (status != CL_SUCCESS)
+ cl_disp_destroy(p_disp);
+
+ return (status);
+}
+
+cl_disp_reg_handle_t cl_disp_register(IN cl_dispatcher_t * const p_disp,
+ IN const cl_disp_msgid_t msg_id,
+ IN cl_pfn_msgrcv_cb_t pfn_callback
+ OPTIONAL,
+ IN const void *const context OPTIONAL)
+{
+ cl_disp_reg_info_t *p_reg;
+ cl_status_t status;
+
+ CL_ASSERT(p_disp);
+
+ /* Check that the requested registrant ID is available. */
+ cl_spinlock_acquire(&p_disp->lock);
+ if ((msg_id != CL_DISP_MSGID_NONE) &&
+ (msg_id < cl_ptr_vector_get_size(&p_disp->reg_vec)) &&
+ (cl_ptr_vector_get(&p_disp->reg_vec, msg_id))) {
+ cl_spinlock_release(&p_disp->lock);
+ return (NULL);
+ }
+
+ /* Get a registration info from the pool. */
+ p_reg = (cl_disp_reg_info_t *) malloc(sizeof(cl_disp_reg_info_t));
+ if (!p_reg) {
+ cl_spinlock_release(&p_disp->lock);
+ return (NULL);
+ } else {
+ memset(p_reg, 0, sizeof(cl_disp_reg_info_t));
+ }
+
+ p_reg->p_disp = p_disp;
+ p_reg->ref_cnt = 0;
+ p_reg->pfn_rcv_callback = pfn_callback;
+ p_reg->context = context;
+ p_reg->msg_id = msg_id;
+
+ /* Insert the registration in the list. */
+ cl_qlist_insert_tail(&p_disp->reg_list, (cl_list_item_t *) p_reg);
+
+ /* Set the array entry to the registrant. */
+ /* The ptr_vector grow automatically as necessary. */
+ if (msg_id != CL_DISP_MSGID_NONE) {
+ status = cl_ptr_vector_set(&p_disp->reg_vec, msg_id, p_reg);
+ if (status != CL_SUCCESS) {
+ free(p_reg);
+ cl_spinlock_release(&p_disp->lock);
+ return (NULL);
+ }
+ }
+
+ cl_spinlock_release(&p_disp->lock);
+
+ return (p_reg);
+}
+
+void cl_disp_unregister(IN const cl_disp_reg_handle_t handle)
+{
+ cl_disp_reg_info_t *p_reg;
+ cl_dispatcher_t *p_disp;
+
+ if (handle == CL_DISP_INVALID_HANDLE)
+ return;
+
+ p_reg = (cl_disp_reg_info_t *) handle;
+ p_disp = p_reg->p_disp;
+ CL_ASSERT(p_disp);
+
+ cl_spinlock_acquire(&p_disp->lock);
+ /*
+ * Clear the registrant vector entry. This will cause any further
+ * post calls to fail.
+ */
+ if (p_reg->msg_id != CL_DISP_MSGID_NONE) {
+ CL_ASSERT(p_reg->msg_id <
+ cl_ptr_vector_get_size(&p_disp->reg_vec));
+ cl_ptr_vector_set(&p_disp->reg_vec, p_reg->msg_id, NULL);
+ }
+ cl_spinlock_release(&p_disp->lock);
+
+ while (p_reg->ref_cnt > 0)
+ cl_thread_suspend(1);
+
+ cl_spinlock_acquire(&p_disp->lock);
+ /* Remove the registrant from the list. */
+ cl_qlist_remove_item(&p_disp->reg_list, (cl_list_item_t *) p_reg);
+ /* Return the registration info to the pool */
+ free(p_reg);
+
+ cl_spinlock_release(&p_disp->lock);
+}
+
+cl_status_t cl_disp_post(IN const cl_disp_reg_handle_t handle,
+ IN const cl_disp_msgid_t msg_id,
+ IN const void *const p_data,
+ IN cl_pfn_msgdone_cb_t pfn_callback OPTIONAL,
+ IN const void *const context OPTIONAL)
+{
+ cl_disp_reg_info_t *p_src_reg = (cl_disp_reg_info_t *) handle;
+ cl_disp_reg_info_t *p_dest_reg;
+ cl_dispatcher_t *p_disp;
+ cl_disp_msg_t *p_msg;
+
+ p_disp = handle->p_disp;
+ CL_ASSERT(p_disp);
+ CL_ASSERT(msg_id != CL_DISP_MSGID_NONE);
+
+ cl_spinlock_acquire(&p_disp->lock);
+ /* Check that the recipient exists. */
+ if (cl_ptr_vector_get_size(&p_disp->reg_vec) <= msg_id) {
+ cl_spinlock_release(&p_disp->lock);
+ return (CL_NOT_FOUND);
+ }
+
+ p_dest_reg = cl_ptr_vector_get(&p_disp->reg_vec, msg_id);
+ if (!p_dest_reg) {
+ cl_spinlock_release(&p_disp->lock);
+ return (CL_NOT_FOUND);
+ }
+
+ /* Get a free message from the pool. */
+ p_msg = (cl_disp_msg_t *) cl_qpool_get(&p_disp->msg_pool);
+ if (!p_msg) {
+ cl_spinlock_release(&p_disp->lock);
+ return (CL_INSUFFICIENT_MEMORY);
+ }
+
+ /* Initialize the message */
+ p_msg->p_src_reg = p_src_reg;
+ p_msg->p_dest_reg = p_dest_reg;
+ p_msg->p_data = p_data;
+ p_msg->pfn_xmt_callback = pfn_callback;
+ p_msg->context = context;
+ p_msg->in_time = cl_get_time_stamp();
+
+ /*
+ * Increment the sender's reference count if they request a completion
+ * notification.
+ */
+ if (pfn_callback)
+ cl_atomic_inc(&p_src_reg->ref_cnt);
+
+ /* Increment the recipient's reference count. */
+ cl_atomic_inc(&p_dest_reg->ref_cnt);
+
+ /* Queue the message in the FIFO. */
+ cl_qlist_insert_tail(&p_disp->msg_fifo, (cl_list_item_t *) p_msg);
+ cl_spinlock_release(&p_disp->lock);
+
+ /* Signal the thread pool that there is work to be done. */
+ cl_thread_pool_signal(&p_disp->worker_threads);
+ return (CL_SUCCESS);
+}
+
+void cl_disp_get_queue_status(IN const cl_disp_reg_handle_t handle,
+ OUT uint32_t * p_num_queued_msgs,
+ OUT uint64_t * p_last_msg_queue_time_ms)
+{
+ cl_dispatcher_t *p_disp = ((cl_disp_reg_info_t *) handle)->p_disp;
+
+ cl_spinlock_acquire(&p_disp->lock);
+
+ if (p_last_msg_queue_time_ms)
+ *p_last_msg_queue_time_ms =
+ p_disp->last_msg_queue_time_us / 1000;
+
+ if (p_num_queued_msgs)
+ *p_num_queued_msgs = cl_qlist_count(&p_disp->msg_fifo);
+
+ cl_spinlock_release(&p_disp->lock);
+}
diff --git a/contrib/ofed/opensm/complib/cl_event.c b/contrib/ofed/opensm/complib/cl_event.c
new file mode 100644
index 0000000..27b4ae5
--- /dev/null
+++ b/contrib/ofed/opensm/complib/cl_event.c
@@ -0,0 +1,175 @@
+/*
+ * Copyright (c) 2004-2009 Voltaire, Inc. All rights reserved.
+ * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved.
+ * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+#if HAVE_CONFIG_H
+# include <config.h>
+#endif /* HAVE_CONFIG_H */
+
+#include <complib/cl_event.h>
+#include <complib/cl_debug.h>
+#include <sys/time.h>
+#include <sys/errno.h>
+
+void cl_event_construct(IN cl_event_t * p_event)
+{
+ CL_ASSERT(p_event);
+
+ p_event->state = CL_UNINITIALIZED;
+}
+
+cl_status_t cl_event_init(IN cl_event_t * const p_event,
+ IN const boolean_t manual_reset)
+{
+ CL_ASSERT(p_event);
+
+ cl_event_construct(p_event);
+
+ pthread_cond_init(&p_event->condvar, NULL);
+ pthread_mutex_init(&p_event->mutex, NULL);
+ p_event->signaled = FALSE;
+ p_event->manual_reset = manual_reset;
+ p_event->state = CL_INITIALIZED;
+
+ return CL_SUCCESS;
+}
+
+void cl_event_destroy(IN cl_event_t * const p_event)
+{
+ CL_ASSERT(cl_is_state_valid(p_event->state));
+
+ /* Destroy only if the event was constructed */
+ if (p_event->state == CL_INITIALIZED) {
+ pthread_cond_broadcast(&p_event->condvar);
+ pthread_cond_destroy(&p_event->condvar);
+ pthread_mutex_destroy(&p_event->mutex);
+ }
+
+ p_event->state = CL_UNINITIALIZED;
+}
+
+cl_status_t cl_event_signal(IN cl_event_t * const p_event)
+{
+ /* Make sure that the event was started */
+ CL_ASSERT(p_event->state == CL_INITIALIZED);
+
+ pthread_mutex_lock(&p_event->mutex);
+ p_event->signaled = TRUE;
+ /* Wake up one or all depending on whether the event is auto-resetting. */
+ if (p_event->manual_reset)
+ pthread_cond_broadcast(&p_event->condvar);
+ else
+ pthread_cond_signal(&p_event->condvar);
+
+ pthread_mutex_unlock(&p_event->mutex);
+
+ return CL_SUCCESS;
+}
+
+cl_status_t cl_event_reset(IN cl_event_t * const p_event)
+{
+ /* Make sure that the event was started */
+ CL_ASSERT(p_event->state == CL_INITIALIZED);
+
+ pthread_mutex_lock(&p_event->mutex);
+ p_event->signaled = FALSE;
+ pthread_mutex_unlock(&p_event->mutex);
+
+ return CL_SUCCESS;
+}
+
+cl_status_t cl_event_wait_on(IN cl_event_t * const p_event,
+ IN const uint32_t wait_us,
+ IN const boolean_t interruptible)
+{
+ cl_status_t status;
+ int wait_ret;
+ struct timespec timeout;
+ struct timeval curtime;
+
+ /* Make sure that the event was Started */
+ CL_ASSERT(p_event->state == CL_INITIALIZED);
+
+ pthread_mutex_lock(&p_event->mutex);
+
+ /* Return immediately if the event is signalled. */
+ if (p_event->signaled) {
+ if (!p_event->manual_reset)
+ p_event->signaled = FALSE;
+
+ pthread_mutex_unlock(&p_event->mutex);
+ return CL_SUCCESS;
+ }
+
+ /* If just testing the state, return CL_TIMEOUT. */
+ if (wait_us == 0) {
+ pthread_mutex_unlock(&p_event->mutex);
+ return CL_TIMEOUT;
+ }
+
+ if (wait_us == EVENT_NO_TIMEOUT) {
+ /* Wait for condition variable to be signaled or broadcast. */
+ if (pthread_cond_wait(&p_event->condvar, &p_event->mutex))
+ status = CL_NOT_DONE;
+ else
+ status = CL_SUCCESS;
+ } else {
+ /* Get the current time */
+ if (gettimeofday(&curtime, NULL) == 0) {
+ unsigned long n_sec =
+ (curtime.tv_usec + (wait_us % 1000000)) * 1000;
+ timeout.tv_sec = curtime.tv_sec + (wait_us / 1000000)
+ + (n_sec / 1000000000);
+ timeout.tv_nsec = n_sec % 1000000000;
+
+ wait_ret = pthread_cond_timedwait(&p_event->condvar,
+ &p_event->mutex,
+ &timeout);
+ if (wait_ret == 0)
+ status =
+ (p_event->
+ signaled ? CL_SUCCESS : CL_NOT_DONE);
+ else if (wait_ret == ETIMEDOUT)
+ status = CL_TIMEOUT;
+ else
+ status = CL_NOT_DONE;
+ } else
+ status = CL_ERROR;
+ }
+ if (!p_event->manual_reset)
+ p_event->signaled = FALSE;
+
+ pthread_mutex_unlock(&p_event->mutex);
+ return status;
+}
diff --git a/contrib/ofed/opensm/complib/cl_event_wheel.c b/contrib/ofed/opensm/complib/cl_event_wheel.c
new file mode 100644
index 0000000..27443f6
--- /dev/null
+++ b/contrib/ofed/opensm/complib/cl_event_wheel.c
@@ -0,0 +1,570 @@
+/*
+ * Copyright (c) 2004-2007 Voltaire, Inc. All rights reserved.
+ * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved.
+ * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+#if HAVE_CONFIG_H
+# include <config.h>
+#endif /* HAVE_CONFIG_H */
+
+#include <math.h>
+#include <stdlib.h>
+#include <complib/cl_event_wheel.h>
+#include <complib/cl_debug.h>
+
+#define CL_DBG(fmt, ...)
+
+static cl_status_t __event_will_age_before(IN const cl_list_item_t *
+ const p_list_item, IN void *context)
+{
+ uint64_t aging_time = *((uint64_t *) context);
+ cl_event_wheel_reg_info_t *p_event;
+
+ p_event =
+ PARENT_STRUCT(p_list_item, cl_event_wheel_reg_info_t, list_item);
+
+ if (p_event->aging_time < aging_time)
+ return CL_SUCCESS;
+ else
+ return CL_NOT_FOUND;
+}
+
+static void __cl_event_wheel_callback(IN void *context)
+{
+ cl_event_wheel_t *p_event_wheel = (cl_event_wheel_t *) context;
+ cl_list_item_t *p_list_item, *p_prev_event_list_item;
+ cl_list_item_t *p_list_next_item;
+ cl_event_wheel_reg_info_t *p_event;
+ uint64_t current_time;
+ uint64_t next_aging_time;
+ uint32_t new_timeout;
+ cl_status_t cl_status;
+
+ /* might be during closing ... */
+ if (p_event_wheel->closing)
+ return;
+
+ current_time = cl_get_time_stamp();
+
+ if (NULL != p_event_wheel->p_external_lock)
+
+ /* Take care of the order of acquiring locks to avoid the deadlock!
+ * The external lock goes first.
+ */
+ cl_spinlock_acquire(p_event_wheel->p_external_lock);
+
+ cl_spinlock_acquire(&p_event_wheel->lock);
+
+ p_list_item = cl_qlist_head(&p_event_wheel->events_wheel);
+ if (p_list_item == cl_qlist_end(&p_event_wheel->events_wheel))
+ /* the list is empty - nothing to do */
+ goto Exit;
+
+ /* we found such an item. get the p_event */
+ p_event =
+ PARENT_STRUCT(p_list_item, cl_event_wheel_reg_info_t, list_item);
+
+ while (p_event->aging_time <= current_time) {
+ /* this object has aged - invoke it's callback */
+ if (p_event->pfn_aged_callback)
+ next_aging_time =
+ p_event->pfn_aged_callback(p_event->key,
+ p_event->num_regs,
+ p_event->context);
+ else
+ next_aging_time = 0;
+
+ /* point to the next object in the wheel */
+ p_list_next_item = cl_qlist_next(p_list_item);
+
+ /* We need to retire the event if the next aging time passed */
+ if (next_aging_time < current_time) {
+ /* remove it from the map */
+ cl_qmap_remove_item(&p_event_wheel->events_map,
+ &(p_event->map_item));
+
+ /* pop p_event from the wheel */
+ cl_qlist_remove_head(&p_event_wheel->events_wheel);
+
+ /* delete the event info object - allocated by cl_event_wheel_reg */
+ free(p_event);
+ } else {
+ /* update the required aging time */
+ p_event->aging_time = next_aging_time;
+ p_event->num_regs++;
+
+ /* do not remove from the map - but remove from the list head and
+ place in the correct position */
+
+ /* pop p_event from the wheel */
+ cl_qlist_remove_head(&p_event_wheel->events_wheel);
+
+ /* find the event that ages just before */
+ p_prev_event_list_item =
+ cl_qlist_find_from_tail(&p_event_wheel->
+ events_wheel,
+ __event_will_age_before,
+ &p_event->aging_time);
+
+ /* insert just after */
+ cl_qlist_insert_next(&p_event_wheel->events_wheel,
+ p_prev_event_list_item,
+ &p_event->list_item);
+
+ /* as we have modified the list - restart from first item: */
+ p_list_next_item =
+ cl_qlist_head(&p_event_wheel->events_wheel);
+ }
+
+ /* advance to next event */
+ p_list_item = p_list_next_item;
+ if (p_list_item == cl_qlist_end(&p_event_wheel->events_wheel))
+ /* the list is empty - nothing to do */
+ break;
+
+ /* get the p_event */
+ p_event =
+ PARENT_STRUCT(p_list_item, cl_event_wheel_reg_info_t,
+ list_item);
+ }
+
+ /* We need to restart the timer only if the list is not empty now */
+ if (p_list_item != cl_qlist_end(&p_event_wheel->events_wheel)) {
+ /* get the p_event */
+ p_event =
+ PARENT_STRUCT(p_list_item, cl_event_wheel_reg_info_t,
+ list_item);
+
+ /* start the timer to the timeout [msec] */
+ new_timeout =
+ (uint32_t) ((p_event->aging_time - current_time + 500) / 1000);
+ CL_DBG("__cl_event_wheel_callback: Restart timer in: "
+ "%u [msec]\n", new_timeout);
+ cl_status = cl_timer_start(&p_event_wheel->timer, new_timeout);
+ if (cl_status != CL_SUCCESS) {
+ CL_DBG("__cl_event_wheel_callback : ERR 6200: "
+ "Failed to start timer\n");
+ }
+ }
+
+ /* release the lock */
+Exit:
+ cl_spinlock_release(&p_event_wheel->lock);
+ if (NULL != p_event_wheel->p_external_lock)
+ cl_spinlock_release(p_event_wheel->p_external_lock);
+}
+
+/*
+ * Construct and Initialize
+ */
+void cl_event_wheel_construct(IN cl_event_wheel_t * const p_event_wheel)
+{
+ cl_spinlock_construct(&(p_event_wheel->lock));
+ cl_timer_construct(&(p_event_wheel->timer));
+}
+
+cl_status_t cl_event_wheel_init(IN cl_event_wheel_t * const p_event_wheel)
+{
+ cl_status_t cl_status = CL_SUCCESS;
+
+ /* initialize */
+ p_event_wheel->p_external_lock = NULL;
+ p_event_wheel->closing = FALSE;
+ cl_status = cl_spinlock_init(&(p_event_wheel->lock));
+ if (cl_status != CL_SUCCESS)
+ return cl_status;
+ cl_qlist_init(&p_event_wheel->events_wheel);
+ cl_qmap_init(&p_event_wheel->events_map);
+
+ /* init the timer with timeout */
+ cl_status = cl_timer_init(&p_event_wheel->timer, __cl_event_wheel_callback, p_event_wheel); /* cb context */
+
+ return cl_status;
+}
+
+cl_status_t cl_event_wheel_init_ex(IN cl_event_wheel_t * const p_event_wheel,
+ IN cl_spinlock_t * p_external_lock)
+{
+ cl_status_t cl_status;
+
+ cl_status = cl_event_wheel_init(p_event_wheel);
+ if (CL_SUCCESS != cl_status)
+ return cl_status;
+
+ p_event_wheel->p_external_lock = p_external_lock;
+ return cl_status;
+}
+
+void cl_event_wheel_dump(IN cl_event_wheel_t * const p_event_wheel)
+{
+ cl_list_item_t *p_list_item;
+ cl_event_wheel_reg_info_t __attribute__((__unused__)) *p_event;
+
+ p_list_item = cl_qlist_head(&p_event_wheel->events_wheel);
+
+ while (p_list_item != cl_qlist_end(&p_event_wheel->events_wheel)) {
+ p_event =
+ PARENT_STRUCT(p_list_item, cl_event_wheel_reg_info_t,
+ list_item);
+ CL_DBG("cl_event_wheel_dump: Found event key:<0x%"
+ PRIx64 ">, num_regs:%d, aging time:%" PRIu64 "\n",
+ p_event->key, p_event->num_regs, p_event->aging_time);
+ p_list_item = cl_qlist_next(p_list_item);
+ }
+}
+
+void cl_event_wheel_destroy(IN cl_event_wheel_t * const p_event_wheel)
+{
+ cl_list_item_t *p_list_item;
+ cl_map_item_t *p_map_item;
+ cl_event_wheel_reg_info_t *p_event;
+
+ /* we need to get a lock */
+ cl_spinlock_acquire(&p_event_wheel->lock);
+
+ cl_event_wheel_dump(p_event_wheel);
+
+ /* go over all the items in the list and remove them */
+ p_list_item = cl_qlist_remove_head(&p_event_wheel->events_wheel);
+ while (p_list_item != cl_qlist_end(&p_event_wheel->events_wheel)) {
+ p_event =
+ PARENT_STRUCT(p_list_item, cl_event_wheel_reg_info_t,
+ list_item);
+
+ CL_DBG("cl_event_wheel_destroy: Found outstanding event"
+ " key:<0x%" PRIx64 ">\n", p_event->key);
+
+ /* remove it from the map */
+ p_map_item = &(p_event->map_item);
+ cl_qmap_remove_item(&p_event_wheel->events_map, p_map_item);
+ free(p_event); /* allocated by cl_event_wheel_reg */
+ p_list_item =
+ cl_qlist_remove_head(&p_event_wheel->events_wheel);
+ }
+
+ /* destroy the timer */
+ cl_timer_destroy(&p_event_wheel->timer);
+
+ /* destroy the lock (this should be done without releasing - we don't want
+ any other run to grab the lock at this point. */
+ cl_spinlock_release(&p_event_wheel->lock);
+ cl_spinlock_destroy(&(p_event_wheel->lock));
+}
+
+cl_status_t cl_event_wheel_reg(IN cl_event_wheel_t * const p_event_wheel,
+ IN const uint64_t key,
+ IN const uint64_t aging_time_usec,
+ IN cl_pfn_event_aged_cb_t pfn_callback,
+ IN void *const context)
+{
+ cl_event_wheel_reg_info_t *p_event;
+ uint64_t timeout;
+ uint32_t to;
+ cl_status_t cl_status = CL_SUCCESS;
+ cl_list_item_t *prev_event_list_item;
+ cl_map_item_t *p_map_item;
+
+ /* Get the lock on the manager */
+ cl_spinlock_acquire(&(p_event_wheel->lock));
+
+ cl_event_wheel_dump(p_event_wheel);
+
+ /* Make sure such a key does not exists */
+ p_map_item = cl_qmap_get(&p_event_wheel->events_map, key);
+ if (p_map_item != cl_qmap_end(&p_event_wheel->events_map)) {
+ CL_DBG("cl_event_wheel_reg: Already exists key:0x%"
+ PRIx64 "\n", key);
+
+ /* already there - remove it from the list as it is getting a new time */
+ p_event =
+ PARENT_STRUCT(p_map_item, cl_event_wheel_reg_info_t,
+ map_item);
+
+ /* remove the item from the qlist */
+ cl_qlist_remove_item(&p_event_wheel->events_wheel,
+ &p_event->list_item);
+ /* and the qmap */
+ cl_qmap_remove_item(&p_event_wheel->events_map,
+ &p_event->map_item);
+ } else {
+ /* make a new one */
+ p_event = (cl_event_wheel_reg_info_t *)
+ malloc(sizeof(cl_event_wheel_reg_info_t));
+ p_event->num_regs = 0;
+ }
+
+ p_event->key = key;
+ p_event->aging_time = aging_time_usec;
+ p_event->pfn_aged_callback = pfn_callback;
+ p_event->context = context;
+ p_event->num_regs++;
+
+ CL_DBG("cl_event_wheel_reg: Registering event key:0x%" PRIx64
+ " aging in %u [msec]\n", p_event->key,
+ (uint32_t) ((p_event->aging_time - cl_get_time_stamp()) / 1000));
+
+ /* If the list is empty - need to start the timer */
+ if (cl_is_qlist_empty(&p_event_wheel->events_wheel)) {
+ /* Edward Bortnikov 03/29/2003
+ * ++TBD Consider moving the timer manipulation behind the list manipulation.
+ */
+
+ /* calculate the new timeout */
+ timeout =
+ (p_event->aging_time - cl_get_time_stamp() + 500) / 1000;
+
+ /* stop the timer if it is running */
+
+ /* Edward Bortnikov 03/29/2003
+ * Don't call cl_timer_stop() because it spins forever.
+ * cl_timer_start() will invoke cl_timer_stop() by itself.
+ *
+ * The problematic scenario is when __cl_event_wheel_callback()
+ * is in race condition with this code. It sets timer.in_timer_cb
+ * to TRUE and then blocks on p_event_wheel->lock. Following this,
+ * the call to cl_timer_stop() hangs. Following this, the whole system
+ * enters into a deadlock.
+ *
+ * cl_timer_stop(&p_event_wheel->timer);
+ */
+
+ /* The timeout for the cl_timer_start should be given as uint32_t.
+ if there is an overflow - warn about it. */
+ to = (uint32_t) timeout;
+ if (timeout > (uint32_t) timeout) {
+ to = 0xffffffff; /* max 32 bit timer */
+ CL_DBG("cl_event_wheel_reg: timeout requested is "
+ "too large. Using timeout: %u\n", to);
+ }
+
+ /* start the timer to the timeout [msec] */
+ cl_status = cl_timer_start(&p_event_wheel->timer, to);
+ if (cl_status != CL_SUCCESS) {
+ CL_DBG("cl_event_wheel_reg : ERR 6203: "
+ "Failed to start timer\n");
+ goto Exit;
+ }
+ }
+
+ /* insert the object to the qlist and the qmap */
+
+ /* BUT WE MUST INSERT IT IN A SORTED MANNER */
+ prev_event_list_item =
+ cl_qlist_find_from_tail(&p_event_wheel->events_wheel,
+ __event_will_age_before,
+ &p_event->aging_time);
+
+ cl_qlist_insert_next(&p_event_wheel->events_wheel,
+ prev_event_list_item, &p_event->list_item);
+
+ cl_qmap_insert(&p_event_wheel->events_map, key, &(p_event->map_item));
+
+Exit:
+ cl_spinlock_release(&p_event_wheel->lock);
+
+ return cl_status;
+}
+
+void cl_event_wheel_unreg(IN cl_event_wheel_t * const p_event_wheel,
+ IN uint64_t key)
+{
+ cl_event_wheel_reg_info_t *p_event;
+ cl_map_item_t *p_map_item;
+
+ CL_DBG("cl_event_wheel_unreg: " "Removing key:0x%" PRIx64 "\n", key);
+
+ cl_spinlock_acquire(&p_event_wheel->lock);
+ p_map_item = cl_qmap_get(&p_event_wheel->events_map, key);
+ if (p_map_item != cl_qmap_end(&p_event_wheel->events_map)) {
+ /* we found such an item. */
+ p_event =
+ PARENT_STRUCT(p_map_item, cl_event_wheel_reg_info_t,
+ map_item);
+
+ /* remove the item from the qlist */
+ cl_qlist_remove_item(&p_event_wheel->events_wheel,
+ &(p_event->list_item));
+ /* remove the item from the qmap */
+ cl_qmap_remove_item(&p_event_wheel->events_map,
+ &(p_event->map_item));
+
+ CL_DBG("cl_event_wheel_unreg: Removed key:0x%" PRIx64 "\n",
+ key);
+
+ /* free the item */
+ free(p_event);
+ } else {
+ CL_DBG("cl_event_wheel_unreg: did not find key:0x%" PRIx64
+ "\n", key);
+ }
+
+ cl_spinlock_release(&p_event_wheel->lock);
+}
+
+uint32_t cl_event_wheel_num_regs(IN cl_event_wheel_t * const p_event_wheel,
+ IN uint64_t key)
+{
+
+ cl_event_wheel_reg_info_t *p_event;
+ cl_map_item_t *p_map_item;
+ uint32_t num_regs = 0;
+
+ /* try to find the key in the map */
+ CL_DBG("cl_event_wheel_num_regs: Looking for key:0x%" PRIx64 "\n", key);
+
+ cl_spinlock_acquire(&p_event_wheel->lock);
+ p_map_item = cl_qmap_get(&p_event_wheel->events_map, key);
+ if (p_map_item != cl_qmap_end(&p_event_wheel->events_map)) {
+ /* ok so we can simply return it's num_regs */
+ p_event =
+ PARENT_STRUCT(p_map_item, cl_event_wheel_reg_info_t,
+ map_item);
+ num_regs = p_event->num_regs;
+ }
+
+ cl_spinlock_release(&p_event_wheel->lock);
+ return (num_regs);
+}
+
+#ifdef __CL_EVENT_WHEEL_TEST__
+
+/* Dump out the complete state of the event wheel */
+void __cl_event_wheel_dump(IN cl_event_wheel_t * const p_event_wheel)
+{
+ cl_list_item_t *p_list_item;
+ cl_map_item_t *p_map_item;
+ cl_event_wheel_reg_info_t *p_event;
+
+ printf("************** Event Wheel Dump ***********************\n");
+ printf("Event Wheel List has %u items:\n",
+ cl_qlist_count(&p_event_wheel->events_wheel));
+
+ p_list_item = cl_qlist_head(&p_event_wheel->events_wheel);
+ while (p_list_item != cl_qlist_end(&p_event_wheel->events_wheel)) {
+ p_event =
+ PARENT_STRUCT(p_list_item, cl_event_wheel_reg_info_t,
+ list_item);
+ printf("Event key:0x%" PRIx64 " Context:%s NumRegs:%u\n",
+ p_event->key, (char *)p_event->context,
+ p_event->num_regs);
+
+ /* next */
+ p_list_item = cl_qlist_next(p_list_item);
+ }
+
+ printf("Event Map has %u items:\n",
+ cl_qmap_count(&p_event_wheel->events_map));
+
+ p_map_item = cl_qmap_head(&p_event_wheel->events_map);
+ while (p_map_item != cl_qmap_end(&p_event_wheel->events_map)) {
+ p_event =
+ PARENT_STRUCT(p_map_item, cl_event_wheel_reg_info_t,
+ map_item);
+ printf("Event key:0x%" PRIx64 " Context:%s NumRegs:%u\n",
+ p_event->key, (char *)p_event->context,
+ p_event->num_regs);
+
+ /* next */
+ p_map_item = cl_qmap_next(p_map_item);
+ }
+
+}
+
+/* The callback for aging event */
+/* We assume we pass a text context */
+static uint64_t __test_event_aging(uint64_t key, uint32_t num_regs, void *context)
+{
+ printf("*****************************************************\n");
+ printf("Aged key: 0x%" PRIx64 " Context:%s\n", key, (char *)context);
+}
+
+int main()
+{
+ cl_event_wheel_t event_wheel;
+ /* uint64_t key; */
+
+ /* init complib */
+ complib_init();
+
+ /* construct */
+ cl_event_wheel_construct(&event_wheel);
+
+ /* init */
+ cl_event_wheel_init(&event_wheel);
+
+ /* Start Playing */
+ cl_event_wheel_reg(&event_wheel, 1, /* key */
+ cl_get_time_stamp() + 3000000, /* 3 sec lifetime */
+ __test_event_aging, /* cb */
+ "The first Aging Event");
+
+ cl_event_wheel_reg(&event_wheel, 2, /* key */
+ cl_get_time_stamp() + 3000000, /* 3 sec lifetime */
+ __test_event_aging, /* cb */
+ "The Second Aging Event");
+
+ cl_event_wheel_reg(&event_wheel, 3, /* key */
+ cl_get_time_stamp() + 3500000, /* 3 sec lifetime */
+ __test_event_aging, /* cb */
+ "The Third Aging Event");
+
+ __cl_event_wheel_dump(&event_wheel);
+
+ sleep(2);
+ cl_event_wheel_reg(&event_wheel, 2, /* key */
+ cl_get_time_stamp() + 8000000, /* 3 sec lifetime */
+ __test_event_aging, /* cb */
+ "The Second Aging Event Moved");
+
+ __cl_event_wheel_dump(&event_wheel);
+
+ sleep(1);
+ /* remove the third event */
+ cl_event_wheel_unreg(&event_wheel, 3); /* key */
+
+ /* get the number of registrations for the keys */
+ printf("Event 1 Registered: %u\n",
+ cl_event_wheel_num_regs(&event_wheel, 1));
+ printf("Event 2 Registered: %u\n",
+ cl_event_wheel_num_regs(&event_wheel, 2));
+
+ sleep(5);
+ /* destroy */
+ cl_event_wheel_destroy(&event_wheel);
+
+ complib_exit();
+
+ return (0);
+}
+
+#endif /* __CL_EVENT_WHEEL_TEST__ */
diff --git a/contrib/ofed/opensm/complib/cl_list.c b/contrib/ofed/opensm/complib/cl_list.c
new file mode 100644
index 0000000..87ebc71
--- /dev/null
+++ b/contrib/ofed/opensm/complib/cl_list.c
@@ -0,0 +1,564 @@
+/*
+ * Copyright (c) 2004-2009 Voltaire, Inc. All rights reserved.
+ * Copyright (c) 2002-2005,2009 Mellanox Technologies LTD. All rights reserved.
+ * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+/*
+ * Abstract:
+ * Implementation of quick list, and list.
+ *
+ */
+
+#if HAVE_CONFIG_H
+# include <config.h>
+#endif /* HAVE_CONFIG_H */
+
+#include <complib/cl_qlist.h>
+#include <complib/cl_list.h>
+
+#define FREE_ITEM_GROW_SIZE 10
+
+/******************************************************************************
+ IMPLEMENTATION OF QUICK LIST
+******************************************************************************/
+void cl_qlist_insert_array_head(IN cl_qlist_t * const p_list,
+ IN cl_list_item_t * const p_array,
+ IN uint32_t item_count,
+ IN const uint32_t item_size)
+{
+ cl_list_item_t *p_item;
+
+ CL_ASSERT(p_list);
+ CL_ASSERT(p_list->state == CL_INITIALIZED);
+ CL_ASSERT(p_array);
+ CL_ASSERT(item_size >= sizeof(cl_list_item_t));
+ CL_ASSERT(item_count);
+
+ /*
+ * To add items from the array to the list in the same order as
+ * the elements appear in the array, we add them starting with
+ * the last one first. Locate the last item.
+ */
+ p_item = (cl_list_item_t *) ((uint8_t *) p_array +
+ (item_size * (item_count - 1)));
+
+ /* Continue to add all items to the list. */
+ while (item_count--) {
+ cl_qlist_insert_head(p_list, p_item);
+
+ /* Get the next object to add to the list. */
+ p_item = (cl_list_item_t *) ((uint8_t *) p_item - item_size);
+ }
+}
+
+void cl_qlist_insert_array_tail(IN cl_qlist_t * const p_list,
+ IN cl_list_item_t * const p_array,
+ IN uint32_t item_count,
+ IN const uint32_t item_size)
+{
+ cl_list_item_t *p_item;
+
+ CL_ASSERT(p_list);
+ CL_ASSERT(p_list->state == CL_INITIALIZED);
+ CL_ASSERT(p_array);
+ CL_ASSERT(item_size >= sizeof(cl_list_item_t));
+ CL_ASSERT(item_count);
+
+ /* Set the first item to add to the list. */
+ p_item = p_array;
+
+ /* Continue to add all items to the list. */
+ while (item_count--) {
+ cl_qlist_insert_tail(p_list, p_item);
+
+ /* Get the next object to add to the list. */
+ p_item = (cl_list_item_t *) ((uint8_t *) p_item + item_size);
+ }
+}
+
+void cl_qlist_insert_list_head(IN cl_qlist_t * const p_dest_list,
+ IN cl_qlist_t * const p_src_list)
+{
+#if defined( _DEBUG_ )
+ cl_list_item_t *p_item;
+#endif
+
+ CL_ASSERT(p_dest_list);
+ CL_ASSERT(p_src_list);
+ CL_ASSERT(p_dest_list->state == CL_INITIALIZED);
+ CL_ASSERT(p_src_list->state == CL_INITIALIZED);
+
+ /*
+ * Is the src list empty?
+ * We must have this check here for code below to work.
+ */
+ if (cl_is_qlist_empty(p_src_list))
+ return;
+
+#if defined( _DEBUG_ )
+ /* Check that all items in the source list belong there. */
+ p_item = cl_qlist_head(p_src_list);
+ while (p_item != cl_qlist_end(p_src_list)) {
+ /* All list items in the source list must point to it. */
+ CL_ASSERT(p_item->p_list == p_src_list);
+ /* Point them all to the destination list. */
+ p_item->p_list = p_dest_list;
+ p_item = cl_qlist_next(p_item);
+ }
+#endif
+
+ /* Chain the destination list to the tail of the source list. */
+ cl_qlist_tail(p_src_list)->p_next = cl_qlist_head(p_dest_list);
+ cl_qlist_head(p_dest_list)->p_prev = cl_qlist_tail(p_src_list);
+
+ /*
+ * Update the head of the destination list to the head of
+ * the source list.
+ */
+ p_dest_list->end.p_next = cl_qlist_head(p_src_list);
+ cl_qlist_head(p_src_list)->p_prev = &p_dest_list->end;
+
+ /*
+ * Update the count of the destination to reflect the source items having
+ * been added.
+ */
+ p_dest_list->count += p_src_list->count;
+
+ /* Update source list to reflect being empty. */
+ __cl_qlist_reset(p_src_list);
+}
+
+void cl_qlist_insert_list_tail(IN cl_qlist_t * const p_dest_list,
+ IN cl_qlist_t * const p_src_list)
+{
+#if defined( _DEBUG_ )
+ cl_list_item_t *p_item;
+#endif
+
+ CL_ASSERT(p_dest_list);
+ CL_ASSERT(p_src_list);
+ CL_ASSERT(p_dest_list->state == CL_INITIALIZED);
+ CL_ASSERT(p_src_list->state == CL_INITIALIZED);
+
+ /*
+ * Is the src list empty?
+ * We must have this check here for code below to work.
+ */
+ if (cl_is_qlist_empty(p_src_list))
+ return;
+
+#if defined( _DEBUG_ )
+ /* Check that all items in the source list belong there. */
+ p_item = cl_qlist_head(p_src_list);
+ while (p_item != cl_qlist_end(p_src_list)) {
+ /* All list items in the source list must point to it. */
+ CL_ASSERT(p_item->p_list == p_src_list);
+ /* Point them all to the destination list. */
+ p_item->p_list = p_dest_list;
+ p_item = cl_qlist_next(p_item);
+ }
+#endif
+
+ /* Chain the source list to the tail of the destination list. */
+ cl_qlist_tail(p_dest_list)->p_next = cl_qlist_head(p_src_list);
+ cl_qlist_head(p_src_list)->p_prev = cl_qlist_tail(p_dest_list);
+
+ /*
+ * Update the tail of the destination list to the tail of
+ * the source list.
+ */
+ p_dest_list->end.p_prev = cl_qlist_tail(p_src_list);
+ cl_qlist_tail(p_src_list)->p_next = &p_dest_list->end;
+
+ /*
+ * Update the count of the destination to reflect the source items having
+ * been added.
+ */
+ p_dest_list->count += p_src_list->count;
+
+ /* Update source list to reflect being empty. */
+ __cl_qlist_reset(p_src_list);
+}
+
+boolean_t cl_is_item_in_qlist(IN const cl_qlist_t * const p_list,
+ IN const cl_list_item_t * const p_list_item)
+{
+ const cl_list_item_t *p_temp;
+
+ CL_ASSERT(p_list);
+ CL_ASSERT(p_list_item);
+ CL_ASSERT(p_list->state == CL_INITIALIZED);
+
+ /* Traverse looking for a match */
+ p_temp = cl_qlist_head(p_list);
+ while (p_temp != cl_qlist_end(p_list)) {
+ if (p_temp == p_list_item) {
+ CL_ASSERT(p_list_item->p_list == p_list);
+ return (TRUE);
+ }
+
+ p_temp = cl_qlist_next(p_temp);
+ }
+
+ return (FALSE);
+}
+
+cl_list_item_t *cl_qlist_find_next(IN const cl_qlist_t * const p_list,
+ IN const cl_list_item_t * const p_list_item,
+ IN cl_pfn_qlist_find_t pfn_func,
+ IN const void *const context)
+{
+ cl_list_item_t *p_found_item;
+
+ CL_ASSERT(p_list);
+ CL_ASSERT(p_list->state == CL_INITIALIZED);
+ CL_ASSERT(p_list_item);
+ CL_ASSERT(p_list_item->p_list == p_list);
+ CL_ASSERT(pfn_func);
+
+ p_found_item = cl_qlist_next(p_list_item);
+
+ /* The user provided a compare function */
+ while (p_found_item != cl_qlist_end(p_list)) {
+ CL_ASSERT(p_found_item->p_list == p_list);
+
+ if (pfn_func(p_found_item, (void *)context) == CL_SUCCESS)
+ break;
+
+ p_found_item = cl_qlist_next(p_found_item);
+ }
+
+ /* No match */
+ return (p_found_item);
+}
+
+cl_list_item_t *cl_qlist_find_prev(IN const cl_qlist_t * const p_list,
+ IN const cl_list_item_t * const p_list_item,
+ IN cl_pfn_qlist_find_t pfn_func,
+ IN const void *const context)
+{
+ cl_list_item_t *p_found_item;
+
+ CL_ASSERT(p_list);
+ CL_ASSERT(p_list->state == CL_INITIALIZED);
+ CL_ASSERT(p_list_item);
+ CL_ASSERT(p_list_item->p_list == p_list);
+ CL_ASSERT(pfn_func);
+
+ p_found_item = cl_qlist_prev(p_list_item);
+
+ /* The user provided a compare function */
+ while (p_found_item != cl_qlist_end(p_list)) {
+ CL_ASSERT(p_found_item->p_list == p_list);
+
+ if (pfn_func(p_found_item, (void *)context) == CL_SUCCESS)
+ break;
+
+ p_found_item = cl_qlist_prev(p_found_item);
+ }
+
+ /* No match */
+ return (p_found_item);
+}
+
+void cl_qlist_apply_func(IN const cl_qlist_t * const p_list,
+ IN cl_pfn_qlist_apply_t pfn_func,
+ IN const void *const context)
+{
+ cl_list_item_t *p_list_item;
+
+ /* Note that context can have any arbitrary value. */
+ CL_ASSERT(p_list);
+ CL_ASSERT(p_list->state == CL_INITIALIZED);
+ CL_ASSERT(pfn_func);
+
+ p_list_item = cl_qlist_head(p_list);
+ while (p_list_item != cl_qlist_end(p_list)) {
+ pfn_func(p_list_item, (void *)context);
+ p_list_item = cl_qlist_next(p_list_item);
+ }
+}
+
+void cl_qlist_move_items(IN cl_qlist_t * const p_src_list,
+ IN cl_qlist_t * const p_dest_list,
+ IN cl_pfn_qlist_find_t pfn_func,
+ IN const void *const context)
+{
+ cl_list_item_t *p_current_item, *p_next;
+
+ CL_ASSERT(p_src_list);
+ CL_ASSERT(p_dest_list);
+ CL_ASSERT(p_src_list->state == CL_INITIALIZED);
+ CL_ASSERT(p_dest_list->state == CL_INITIALIZED);
+ CL_ASSERT(pfn_func);
+
+ p_current_item = cl_qlist_head(p_src_list);
+
+ while (p_current_item != cl_qlist_end(p_src_list)) {
+ /* Before we do anything, get a pointer to the next item. */
+ p_next = cl_qlist_next(p_current_item);
+
+ if (pfn_func(p_current_item, (void *)context) == CL_SUCCESS) {
+ /* Move the item from one list to the other. */
+ cl_qlist_remove_item(p_src_list, p_current_item);
+ cl_qlist_insert_tail(p_dest_list, p_current_item);
+ }
+ p_current_item = p_next;
+ }
+}
+
+/******************************************************************************
+ IMPLEMENTATION OF LIST
+******************************************************************************/
+void cl_list_construct(IN cl_list_t * const p_list)
+{
+ CL_ASSERT(p_list);
+
+ cl_qpool_construct(&p_list->list_item_pool);
+}
+
+cl_status_t cl_list_init(IN cl_list_t * const p_list, IN const size_t min_items)
+{
+ uint32_t grow_size;
+
+ CL_ASSERT(p_list);
+ cl_qlist_init(&p_list->list);
+
+ /*
+ * We will grow by min_items/8 items at a time, with a minimum of
+ * FREE_ITEM_GROW_SIZE.
+ */
+ grow_size = (uint32_t) min_items >> 3;
+ if (grow_size < FREE_ITEM_GROW_SIZE)
+ grow_size = FREE_ITEM_GROW_SIZE;
+
+ /* Initialize the pool of list items. */
+ return (cl_qpool_init(&p_list->list_item_pool, min_items, 0, grow_size,
+ sizeof(cl_pool_obj_t), NULL, NULL, NULL));
+}
+
+void cl_list_destroy(IN cl_list_t * const p_list)
+{
+ CL_ASSERT(p_list);
+
+ cl_qpool_destroy(&p_list->list_item_pool);
+}
+
+static cl_status_t cl_list_find_cb(IN const cl_list_item_t * const p_list_item,
+ IN void *const context)
+{
+ CL_ASSERT(p_list_item);
+
+ if (cl_list_obj(p_list_item) == context)
+ return (CL_SUCCESS);
+
+ return (CL_NOT_FOUND);
+}
+
+cl_status_t cl_list_remove_object(IN cl_list_t * const p_list,
+ IN const void *const p_object)
+{
+ cl_list_item_t *p_list_item;
+
+ CL_ASSERT(p_list);
+ CL_ASSERT(cl_is_qpool_inited(&p_list->list_item_pool));
+
+ /* find the item in question */
+ p_list_item =
+ cl_qlist_find_from_head(&p_list->list, cl_list_find_cb, p_object);
+ if (p_list_item != cl_qlist_end(&p_list->list)) {
+ /* remove this item */
+ cl_qlist_remove_item(&p_list->list, p_list_item);
+ cl_qpool_put(&p_list->list_item_pool,
+ (cl_pool_item_t *) p_list_item);
+ return (CL_SUCCESS);
+ }
+ return (CL_NOT_FOUND);
+}
+
+boolean_t cl_is_object_in_list(IN const cl_list_t * const p_list,
+ IN const void *const p_object)
+{
+ CL_ASSERT(p_list);
+ CL_ASSERT(cl_is_qpool_inited(&p_list->list_item_pool));
+
+ return (cl_qlist_find_from_head
+ (&p_list->list, cl_list_find_cb, p_object)
+ != cl_qlist_end(&p_list->list));
+}
+
+cl_status_t cl_list_insert_array_head(IN cl_list_t * const p_list,
+ IN const void *const p_array,
+ IN uint32_t item_count,
+ IN const uint32_t item_size)
+{
+ cl_status_t status;
+ void *p_object;
+ uint32_t items_remain = item_count;
+
+ CL_ASSERT(p_list);
+ CL_ASSERT(cl_is_qpool_inited(&p_list->list_item_pool));
+ CL_ASSERT(p_array);
+ CL_ASSERT(item_size);
+ CL_ASSERT(item_count);
+
+ /*
+ * To add items from the array to the list in the same order as
+ * the elements appear in the array, we add them starting with
+ * the last one first. Locate the last item.
+ */
+ p_object = ((uint8_t *) p_array + (item_size * (item_count - 1)));
+
+ /* Continue to add all items to the list. */
+ while (items_remain--) {
+ status = cl_list_insert_head(p_list, p_object);
+ if (status != CL_SUCCESS) {
+ /* Remove all items that have been inserted. */
+ while (items_remain++ < (item_count - 1))
+ cl_list_remove_head(p_list);
+ return (status);
+ }
+
+ /* Get the next object to add to the list. */
+ p_object = ((uint8_t *) p_object - item_size);
+ }
+
+ return (CL_SUCCESS);
+}
+
+cl_status_t cl_list_insert_array_tail(IN cl_list_t * const p_list,
+ IN const void *const p_array,
+ IN uint32_t item_count,
+ IN const uint32_t item_size)
+{
+ cl_status_t status;
+ void *p_object;
+ uint32_t items_remain = item_count;
+
+ CL_ASSERT(p_list);
+ CL_ASSERT(cl_is_qpool_inited(&p_list->list_item_pool));
+ CL_ASSERT(p_array);
+ CL_ASSERT(item_size);
+ CL_ASSERT(item_count);
+
+ /* Set the first item to add to the list. */
+ p_object = (void *)p_array;
+
+ /* Continue to add all items to the list. */
+ while (items_remain--) {
+ status = cl_list_insert_tail(p_list, p_object);
+ if (status != CL_SUCCESS) {
+ /* Remove all items that have been inserted. */
+ while (items_remain++ < (item_count - 1))
+ cl_list_remove_tail(p_list);
+ return (status);
+ }
+
+ /* Get the next object to add to the list. */
+ p_object = ((uint8_t *) p_object + item_size);
+ }
+
+ return (CL_SUCCESS);
+}
+
+cl_list_iterator_t cl_list_find_from_head(IN const cl_list_t * const p_list,
+ IN cl_pfn_list_find_t pfn_func,
+ IN const void *const context)
+{
+ cl_status_t status;
+ cl_list_iterator_t itor;
+
+ /* Note that context can have any arbitrary value. */
+ CL_ASSERT(p_list);
+ CL_ASSERT(cl_is_qpool_inited(&p_list->list_item_pool));
+ CL_ASSERT(pfn_func);
+
+ itor = cl_list_head(p_list);
+
+ while (itor != cl_list_end(p_list)) {
+ status = pfn_func(cl_list_obj(itor), (void *)context);
+ if (status == CL_SUCCESS)
+ break;
+
+ itor = cl_list_next(itor);
+ }
+
+ /* no match */
+ return (itor);
+}
+
+cl_list_iterator_t cl_list_find_from_tail(IN const cl_list_t * const p_list,
+ IN cl_pfn_list_find_t pfn_func,
+ IN const void *const context)
+{
+ cl_status_t status;
+ cl_list_iterator_t itor;
+
+ /* Note that context can have any arbitrary value. */
+ CL_ASSERT(p_list);
+ CL_ASSERT(cl_is_qpool_inited(&p_list->list_item_pool));
+ CL_ASSERT(pfn_func);
+
+ itor = cl_list_tail(p_list);
+
+ while (itor != cl_list_end(p_list)) {
+ status = pfn_func(cl_list_obj(itor), (void *)context);
+ if (status == CL_SUCCESS)
+ break;
+
+ itor = cl_list_prev(itor);
+ }
+
+ /* no match */
+ return (itor);
+}
+
+void cl_list_apply_func(IN const cl_list_t * const p_list,
+ IN cl_pfn_list_apply_t pfn_func,
+ IN const void *const context)
+{
+ cl_list_iterator_t itor;
+
+ /* Note that context can have any arbitrary value. */
+ CL_ASSERT(p_list);
+ CL_ASSERT(cl_is_qpool_inited(&p_list->list_item_pool));
+ CL_ASSERT(pfn_func);
+
+ itor = cl_list_head(p_list);
+
+ while (itor != cl_list_end(p_list)) {
+ pfn_func(cl_list_obj(itor), (void *)context);
+
+ itor = cl_list_next(itor);
+ }
+}
diff --git a/contrib/ofed/opensm/complib/cl_log.c b/contrib/ofed/opensm/complib/cl_log.c
new file mode 100644
index 0000000..c63cf74
--- /dev/null
+++ b/contrib/ofed/opensm/complib/cl_log.c
@@ -0,0 +1,117 @@
+/*
+ * Copyright (c) 2004, 2005 Voltaire, Inc. All rights reserved.
+ * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved.
+ * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+#ifdef __WIN__
+#pragma warning(disable : 4996)
+#endif
+
+#if HAVE_CONFIG_H
+# include <config.h>
+#endif /* HAVE_CONFIG_H */
+
+#include <complib/cl_log.h>
+#include <complib/cl_debug.h>
+#include <syslog.h>
+
+/* Maximum number of bytes that can be logged. */
+#define CL_MAX_LOG_DATA (256)
+
+/*
+ * Size of the character buffer to allow logging the above
+ * number of bytes. A space is added after every DWORD, and
+ * a new line is added after 8 DWORDS (for a line length less than 80).
+ */
+#define CL_LOG_DATA_SIZE (CL_MAX_LOG_DATA + (CL_MAX_LOG_DATA/4))
+
+void cl_log_event(IN const char *const name, IN const cl_log_type_t type,
+ IN const char *const message,
+ IN const void *const p_data OPTIONAL,
+ IN const uint32_t data_len)
+{
+ int priority, i;
+ char data[CL_LOG_DATA_SIZE];
+ char *p_buf;
+ uint8_t *p_int_data = (uint8_t *) p_data;
+
+ CL_ASSERT(name);
+ CL_ASSERT(message);
+
+ openlog(name, LOG_NDELAY | LOG_PID, LOG_USER);
+ switch (type) {
+ case CL_LOG_ERROR:
+ priority = LOG_ERR;
+ break;
+
+ case CL_LOG_WARN:
+ priority = LOG_WARNING;
+ break;
+
+ case CL_LOG_INFO:
+ default:
+ priority = LOG_INFO;
+ break;
+ }
+
+ if (p_data) {
+ CL_ASSERT(data_len);
+ if (data_len < CL_MAX_LOG_DATA) {
+ p_buf = data;
+ /* Format the data into ASCII. */
+ for (i = 0; i < data_len; i++) {
+ sprintf(p_buf, "%02x", *p_int_data++);
+ p_buf += 2;
+
+ /* Add line break after 8 DWORDS. */
+ if (i % 32) {
+ sprintf(p_buf++, "\n");
+ continue;
+ }
+
+ /* Add a space between DWORDS. */
+ if (i % 4)
+ sprintf(p_buf++, " ");
+ }
+ syslog(priority, "%s data:\n%s\n", message, p_buf);
+ } else {
+ /* The data portion is too large to log. */
+ cl_msg_out
+ ("cl_log() - WARNING: data too large to log.\n");
+ syslog(priority, "%s\n", message);
+ }
+ } else {
+ syslog(priority, "%s\n", message);
+ }
+ closelog();
+}
diff --git a/contrib/ofed/opensm/complib/cl_map.c b/contrib/ofed/opensm/complib/cl_map.c
new file mode 100644
index 0000000..81426ee
--- /dev/null
+++ b/contrib/ofed/opensm/complib/cl_map.c
@@ -0,0 +1,1622 @@
+/*
+ * Copyright (c) 2004-2009 Voltaire, Inc. All rights reserved.
+ * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved.
+ * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+/*
+ * Abstract:
+ * Implementation of quick map, a binary tree where the caller always
+ * provides all necessary storage.
+ *
+ */
+
+/*****************************************************************************
+*
+* Map
+*
+* Map is an associative array. By providing a key, the caller can retrieve
+* an object from the map. All objects in the map have an associated key,
+* as specified by the caller when the object was inserted into the map.
+* In addition to random access, the caller can traverse the map much like
+* a linked list, either forwards from the first object or backwards from
+* the last object. The objects in the map are always traversed in
+* order since the nodes are stored sorted.
+*
+* This implementation of Map uses a red black tree verified against
+* Cormen-Leiserson-Rivest text, McGraw-Hill Edition, fourteenth
+* printing, 1994.
+*
+*****************************************************************************/
+
+#if HAVE_CONFIG_H
+# include <config.h>
+#endif /* HAVE_CONFIG_H */
+
+#include <string.h>
+#include <complib/cl_qmap.h>
+#include <complib/cl_map.h>
+#include <complib/cl_fleximap.h>
+
+/******************************************************************************
+ IMPLEMENTATION OF QUICK MAP
+******************************************************************************/
+
+/*
+ * Get the root.
+ */
+static inline cl_map_item_t *__cl_map_root(IN const cl_qmap_t * const p_map)
+{
+ CL_ASSERT(p_map);
+ return (p_map->root.p_left);
+}
+
+/*
+ * Returns whether a given item is on the left of its parent.
+ */
+static boolean_t __cl_map_is_left_child(IN const cl_map_item_t * const p_item)
+{
+ CL_ASSERT(p_item);
+ CL_ASSERT(p_item->p_up);
+ CL_ASSERT(p_item->p_up != p_item);
+
+ return (p_item->p_up->p_left == p_item);
+}
+
+/*
+ * Retrieve the pointer to the parent's pointer to an item.
+ */
+static cl_map_item_t **__cl_map_get_parent_ptr_to_item(IN cl_map_item_t *
+ const p_item)
+{
+ CL_ASSERT(p_item);
+ CL_ASSERT(p_item->p_up);
+ CL_ASSERT(p_item->p_up != p_item);
+
+ if (__cl_map_is_left_child(p_item))
+ return (&p_item->p_up->p_left);
+
+ CL_ASSERT(p_item->p_up->p_right == p_item);
+ return (&p_item->p_up->p_right);
+}
+
+/*
+ * Rotate a node to the left. This rotation affects the least number of links
+ * between nodes and brings the level of C up by one while increasing the depth
+ * of A one. Note that the links to/from W, X, Y, and Z are not affected.
+ *
+ * R R
+ * | |
+ * A C
+ * / \ / \
+ * W C A Z
+ * / \ / \
+ * B Z W B
+ * / \ / \
+ * X Y X Y
+ */
+static void __cl_map_rot_left(IN cl_qmap_t * const p_map,
+ IN cl_map_item_t * const p_item)
+{
+ cl_map_item_t **pp_root;
+
+ CL_ASSERT(p_map);
+ CL_ASSERT(p_item);
+ CL_ASSERT(p_item->p_right != &p_map->nil);
+
+ pp_root = __cl_map_get_parent_ptr_to_item(p_item);
+
+ /* Point R to C instead of A. */
+ *pp_root = p_item->p_right;
+ /* Set C's parent to R. */
+ (*pp_root)->p_up = p_item->p_up;
+
+ /* Set A's right to B */
+ p_item->p_right = (*pp_root)->p_left;
+ /*
+ * Set B's parent to A. We trap for B being NIL since the
+ * caller may depend on NIL not changing.
+ */
+ if ((*pp_root)->p_left != &p_map->nil)
+ (*pp_root)->p_left->p_up = p_item;
+
+ /* Set C's left to A. */
+ (*pp_root)->p_left = p_item;
+ /* Set A's parent to C. */
+ p_item->p_up = *pp_root;
+}
+
+/*
+ * Rotate a node to the right. This rotation affects the least number of links
+ * between nodes and brings the level of A up by one while increasing the depth
+ * of C one. Note that the links to/from W, X, Y, and Z are not affected.
+ *
+ * R R
+ * | |
+ * C A
+ * / \ / \
+ * A Z W C
+ * / \ / \
+ * W B B Z
+ * / \ / \
+ * X Y X Y
+ */
+static void __cl_map_rot_right(IN cl_qmap_t * const p_map,
+ IN cl_map_item_t * const p_item)
+{
+ cl_map_item_t **pp_root;
+
+ CL_ASSERT(p_map);
+ CL_ASSERT(p_item);
+ CL_ASSERT(p_item->p_left != &p_map->nil);
+
+ /* Point R to A instead of C. */
+ pp_root = __cl_map_get_parent_ptr_to_item(p_item);
+ (*pp_root) = p_item->p_left;
+ /* Set A's parent to R. */
+ (*pp_root)->p_up = p_item->p_up;
+
+ /* Set C's left to B */
+ p_item->p_left = (*pp_root)->p_right;
+ /*
+ * Set B's parent to C. We trap for B being NIL since the
+ * caller may depend on NIL not changing.
+ */
+ if ((*pp_root)->p_right != &p_map->nil)
+ (*pp_root)->p_right->p_up = p_item;
+
+ /* Set A's right to C. */
+ (*pp_root)->p_right = p_item;
+ /* Set C's parent to A. */
+ p_item->p_up = *pp_root;
+}
+
+void cl_qmap_init(IN cl_qmap_t * const p_map)
+{
+ CL_ASSERT(p_map);
+
+ memset(p_map, 0, sizeof(cl_qmap_t));
+
+ /* special setup for the root node */
+ p_map->root.p_up = &p_map->root;
+ p_map->root.p_left = &p_map->nil;
+ p_map->root.p_right = &p_map->nil;
+ p_map->root.color = CL_MAP_BLACK;
+
+ /* Setup the node used as terminator for all leaves. */
+ p_map->nil.p_up = &p_map->nil;
+ p_map->nil.p_left = &p_map->nil;
+ p_map->nil.p_right = &p_map->nil;
+ p_map->nil.color = CL_MAP_BLACK;
+
+ p_map->state = CL_INITIALIZED;
+
+ cl_qmap_remove_all(p_map);
+}
+
+cl_map_item_t *cl_qmap_get(IN const cl_qmap_t * const p_map,
+ IN const uint64_t key)
+{
+ cl_map_item_t *p_item;
+
+ CL_ASSERT(p_map);
+ CL_ASSERT(p_map->state == CL_INITIALIZED);
+
+ p_item = __cl_map_root(p_map);
+
+ while (p_item != &p_map->nil) {
+ if (key == p_item->key)
+ break; /* just right */
+
+ if (key < p_item->key)
+ p_item = p_item->p_left; /* too small */
+ else
+ p_item = p_item->p_right; /* too big */
+ }
+
+ return (p_item);
+}
+
+cl_map_item_t *cl_qmap_get_next(IN const cl_qmap_t * const p_map,
+ IN const uint64_t key)
+{
+ cl_map_item_t *p_item;
+ cl_map_item_t *p_item_found;
+
+ CL_ASSERT(p_map);
+ CL_ASSERT(p_map->state == CL_INITIALIZED);
+
+ p_item = __cl_map_root(p_map);
+ p_item_found = (cl_map_item_t *) & p_map->nil;
+
+ while (p_item != &p_map->nil) {
+ if (key < p_item->key) {
+ p_item_found = p_item;
+ p_item = p_item->p_left;
+ } else {
+ p_item = p_item->p_right;
+ }
+ }
+
+ return (p_item_found);
+}
+
+void cl_qmap_apply_func(IN const cl_qmap_t * const p_map,
+ IN cl_pfn_qmap_apply_t pfn_func,
+ IN const void *const context)
+{
+ cl_map_item_t *p_map_item;
+
+ /* Note that context can have any arbitrary value. */
+ CL_ASSERT(p_map);
+ CL_ASSERT(p_map->state == CL_INITIALIZED);
+ CL_ASSERT(pfn_func);
+
+ p_map_item = cl_qmap_head(p_map);
+ while (p_map_item != cl_qmap_end(p_map)) {
+ pfn_func(p_map_item, (void *)context);
+ p_map_item = cl_qmap_next(p_map_item);
+ }
+}
+
+/*
+ * Balance a tree starting at a given item back to the root.
+ */
+static void __cl_map_ins_bal(IN cl_qmap_t * const p_map,
+ IN cl_map_item_t * p_item)
+{
+ cl_map_item_t *p_grand_uncle;
+
+ CL_ASSERT(p_map);
+ CL_ASSERT(p_item);
+ CL_ASSERT(p_item != &p_map->root);
+
+ while (p_item->p_up->color == CL_MAP_RED) {
+ if (__cl_map_is_left_child(p_item->p_up)) {
+ p_grand_uncle = p_item->p_up->p_up->p_right;
+ CL_ASSERT(p_grand_uncle);
+ if (p_grand_uncle->color == CL_MAP_RED) {
+ p_grand_uncle->color = CL_MAP_BLACK;
+ p_item->p_up->color = CL_MAP_BLACK;
+ p_item->p_up->p_up->color = CL_MAP_RED;
+ p_item = p_item->p_up->p_up;
+ continue;
+ }
+
+ if (!__cl_map_is_left_child(p_item)) {
+ p_item = p_item->p_up;
+ __cl_map_rot_left(p_map, p_item);
+ }
+ p_item->p_up->color = CL_MAP_BLACK;
+ p_item->p_up->p_up->color = CL_MAP_RED;
+ __cl_map_rot_right(p_map, p_item->p_up->p_up);
+ } else {
+ p_grand_uncle = p_item->p_up->p_up->p_left;
+ CL_ASSERT(p_grand_uncle);
+ if (p_grand_uncle->color == CL_MAP_RED) {
+ p_grand_uncle->color = CL_MAP_BLACK;
+ p_item->p_up->color = CL_MAP_BLACK;
+ p_item->p_up->p_up->color = CL_MAP_RED;
+ p_item = p_item->p_up->p_up;
+ continue;
+ }
+
+ if (__cl_map_is_left_child(p_item)) {
+ p_item = p_item->p_up;
+ __cl_map_rot_right(p_map, p_item);
+ }
+ p_item->p_up->color = CL_MAP_BLACK;
+ p_item->p_up->p_up->color = CL_MAP_RED;
+ __cl_map_rot_left(p_map, p_item->p_up->p_up);
+ }
+ }
+}
+
+cl_map_item_t *cl_qmap_insert(IN cl_qmap_t * const p_map,
+ IN const uint64_t key,
+ IN cl_map_item_t * const p_item)
+{
+ cl_map_item_t *p_insert_at, *p_comp_item;
+
+ CL_ASSERT(p_map);
+ CL_ASSERT(p_map->state == CL_INITIALIZED);
+ CL_ASSERT(p_item);
+ CL_ASSERT(p_map->root.p_up == &p_map->root);
+ CL_ASSERT(p_map->root.color != CL_MAP_RED);
+ CL_ASSERT(p_map->nil.color != CL_MAP_RED);
+
+ p_item->p_left = &p_map->nil;
+ p_item->p_right = &p_map->nil;
+ p_item->key = key;
+ p_item->color = CL_MAP_RED;
+
+ /* Find the insertion location. */
+ p_insert_at = &p_map->root;
+ p_comp_item = __cl_map_root(p_map);
+
+ while (p_comp_item != &p_map->nil) {
+ p_insert_at = p_comp_item;
+
+ if (key == p_insert_at->key)
+ return (p_insert_at);
+
+ /* Traverse the tree until the correct insertion point is found. */
+ if (key < p_insert_at->key)
+ p_comp_item = p_insert_at->p_left;
+ else
+ p_comp_item = p_insert_at->p_right;
+ }
+
+ CL_ASSERT(p_insert_at != &p_map->nil);
+ CL_ASSERT(p_comp_item == &p_map->nil);
+ /* Insert the item. */
+ if (p_insert_at == &p_map->root) {
+ p_insert_at->p_left = p_item;
+ /*
+ * Primitive insert places the new item in front of
+ * the existing item.
+ */
+ __cl_primitive_insert(&p_map->nil.pool_item.list_item,
+ &p_item->pool_item.list_item);
+ } else if (key < p_insert_at->key) {
+ p_insert_at->p_left = p_item;
+ /*
+ * Primitive insert places the new item in front of
+ * the existing item.
+ */
+ __cl_primitive_insert(&p_insert_at->pool_item.list_item,
+ &p_item->pool_item.list_item);
+ } else {
+ p_insert_at->p_right = p_item;
+ /*
+ * Primitive insert places the new item in front of
+ * the existing item.
+ */
+ __cl_primitive_insert(p_insert_at->pool_item.list_item.p_next,
+ &p_item->pool_item.list_item);
+ }
+ /* Increase the count. */
+ p_map->count++;
+
+ p_item->p_up = p_insert_at;
+
+ /*
+ * We have added depth to this section of the tree.
+ * Rebalance as necessary as we retrace our path through the tree
+ * and update colors.
+ */
+ __cl_map_ins_bal(p_map, p_item);
+
+ __cl_map_root(p_map)->color = CL_MAP_BLACK;
+
+ /*
+ * Note that it is not necessary to re-color the nil node black because all
+ * red color assignments are made via the p_up pointer, and nil is never
+ * set as the value of a p_up pointer.
+ */
+
+#ifdef _DEBUG_
+ /* Set the pointer to the map in the map item for consistency checking. */
+ p_item->p_map = p_map;
+#endif
+
+ return (p_item);
+}
+
+static void __cl_map_del_bal(IN cl_qmap_t * const p_map,
+ IN cl_map_item_t * p_item)
+{
+ cl_map_item_t *p_uncle;
+
+ while ((p_item->color != CL_MAP_RED) && (p_item->p_up != &p_map->root)) {
+ if (__cl_map_is_left_child(p_item)) {
+ p_uncle = p_item->p_up->p_right;
+
+ if (p_uncle->color == CL_MAP_RED) {
+ p_uncle->color = CL_MAP_BLACK;
+ p_item->p_up->color = CL_MAP_RED;
+ __cl_map_rot_left(p_map, p_item->p_up);
+ p_uncle = p_item->p_up->p_right;
+ }
+
+ if (p_uncle->p_right->color != CL_MAP_RED) {
+ if (p_uncle->p_left->color != CL_MAP_RED) {
+ p_uncle->color = CL_MAP_RED;
+ p_item = p_item->p_up;
+ continue;
+ }
+
+ p_uncle->p_left->color = CL_MAP_BLACK;
+ p_uncle->color = CL_MAP_RED;
+ __cl_map_rot_right(p_map, p_uncle);
+ p_uncle = p_item->p_up->p_right;
+ }
+ p_uncle->color = p_item->p_up->color;
+ p_item->p_up->color = CL_MAP_BLACK;
+ p_uncle->p_right->color = CL_MAP_BLACK;
+ __cl_map_rot_left(p_map, p_item->p_up);
+ break;
+ } else {
+ p_uncle = p_item->p_up->p_left;
+
+ if (p_uncle->color == CL_MAP_RED) {
+ p_uncle->color = CL_MAP_BLACK;
+ p_item->p_up->color = CL_MAP_RED;
+ __cl_map_rot_right(p_map, p_item->p_up);
+ p_uncle = p_item->p_up->p_left;
+ }
+
+ if (p_uncle->p_left->color != CL_MAP_RED) {
+ if (p_uncle->p_right->color != CL_MAP_RED) {
+ p_uncle->color = CL_MAP_RED;
+ p_item = p_item->p_up;
+ continue;
+ }
+
+ p_uncle->p_right->color = CL_MAP_BLACK;
+ p_uncle->color = CL_MAP_RED;
+ __cl_map_rot_left(p_map, p_uncle);
+ p_uncle = p_item->p_up->p_left;
+ }
+ p_uncle->color = p_item->p_up->color;
+ p_item->p_up->color = CL_MAP_BLACK;
+ p_uncle->p_left->color = CL_MAP_BLACK;
+ __cl_map_rot_right(p_map, p_item->p_up);
+ break;
+ }
+ }
+ p_item->color = CL_MAP_BLACK;
+}
+
+void cl_qmap_remove_item(IN cl_qmap_t * const p_map,
+ IN cl_map_item_t * const p_item)
+{
+ cl_map_item_t *p_child, *p_del_item;
+
+ CL_ASSERT(p_map);
+ CL_ASSERT(p_map->state == CL_INITIALIZED);
+ CL_ASSERT(p_item);
+
+ if (p_item == cl_qmap_end(p_map))
+ return;
+
+ /* must be checked after comparing to cl_qmap_end, since
+ the end is not a valid item. */
+ CL_ASSERT(p_item->p_map == p_map);
+
+ if ((p_item->p_right == &p_map->nil) || (p_item->p_left == &p_map->nil)) {
+ /* The item being removed has children on at most on side. */
+ p_del_item = p_item;
+ } else {
+ /*
+ * The item being removed has children on both side.
+ * We select the item that will replace it. After removing
+ * the substitute item and rebalancing, the tree will have the
+ * correct topology. Exchanging the substitute for the item
+ * will finalize the removal.
+ */
+ p_del_item = cl_qmap_next(p_item);
+ CL_ASSERT(p_del_item != &p_map->nil);
+ }
+
+ /* Remove the item from the list. */
+ __cl_primitive_remove(&p_item->pool_item.list_item);
+ /* Decrement the item count. */
+ p_map->count--;
+
+ /* Get the pointer to the new root's child, if any. */
+ if (p_del_item->p_left != &p_map->nil)
+ p_child = p_del_item->p_left;
+ else
+ p_child = p_del_item->p_right;
+
+ /*
+ * This assignment may modify the parent pointer of the nil node.
+ * This is inconsequential.
+ */
+ p_child->p_up = p_del_item->p_up;
+ (*__cl_map_get_parent_ptr_to_item(p_del_item)) = p_child;
+
+ if (p_del_item->color != CL_MAP_RED)
+ __cl_map_del_bal(p_map, p_child);
+
+ /*
+ * Note that the splicing done below does not need to occur before
+ * the tree is balanced, since the actual topology changes are made by the
+ * preceding code. The topology is preserved by the color assignment made
+ * below (reader should be reminded that p_del_item == p_item in some cases).
+ */
+ if (p_del_item != p_item) {
+ /*
+ * Finalize the removal of the specified item by exchanging it with
+ * the substitute which we removed above.
+ */
+ p_del_item->p_up = p_item->p_up;
+ p_del_item->p_left = p_item->p_left;
+ p_del_item->p_right = p_item->p_right;
+ (*__cl_map_get_parent_ptr_to_item(p_item)) = p_del_item;
+ p_item->p_right->p_up = p_del_item;
+ p_item->p_left->p_up = p_del_item;
+ p_del_item->color = p_item->color;
+ }
+
+ CL_ASSERT(p_map->nil.color != CL_MAP_RED);
+
+#ifdef _DEBUG_
+ /* Clear the pointer to the map since the item has been removed. */
+ p_item->p_map = NULL;
+#endif
+}
+
+cl_map_item_t *cl_qmap_remove(IN cl_qmap_t * const p_map, IN const uint64_t key)
+{
+ cl_map_item_t *p_item;
+
+ CL_ASSERT(p_map);
+ CL_ASSERT(p_map->state == CL_INITIALIZED);
+
+ /* Seek the node with the specified key */
+ p_item = cl_qmap_get(p_map, key);
+
+ cl_qmap_remove_item(p_map, p_item);
+
+ return (p_item);
+}
+
+void cl_qmap_merge(OUT cl_qmap_t * const p_dest_map,
+ IN OUT cl_qmap_t * const p_src_map)
+{
+ cl_map_item_t *p_item, *p_item2, *p_next;
+
+ CL_ASSERT(p_dest_map);
+ CL_ASSERT(p_src_map);
+
+ p_item = cl_qmap_head(p_src_map);
+
+ while (p_item != cl_qmap_end(p_src_map)) {
+ p_next = cl_qmap_next(p_item);
+
+ /* Remove the item from its current map. */
+ cl_qmap_remove_item(p_src_map, p_item);
+ /* Insert the item into the destination map. */
+ p_item2 =
+ cl_qmap_insert(p_dest_map, cl_qmap_key(p_item), p_item);
+ /* Check that the item was successfully inserted. */
+ if (p_item2 != p_item) {
+ /* Put the item in back in the source map. */
+ p_item2 =
+ cl_qmap_insert(p_src_map, cl_qmap_key(p_item),
+ p_item);
+ CL_ASSERT(p_item2 == p_item);
+ }
+ p_item = p_next;
+ }
+}
+
+static void __cl_qmap_delta_move(IN OUT cl_qmap_t * const p_dest,
+ IN OUT cl_qmap_t * const p_src,
+ IN OUT cl_map_item_t ** const pp_item)
+{
+ cl_map_item_t __attribute__((__unused__)) *p_temp;
+ cl_map_item_t *p_next;
+
+ /*
+ * Get the next item so that we can ensure that pp_item points to
+ * a valid item upon return from the function.
+ */
+ p_next = cl_qmap_next(*pp_item);
+ /* Move the old item from its current map the the old map. */
+ cl_qmap_remove_item(p_src, *pp_item);
+ p_temp = cl_qmap_insert(p_dest, cl_qmap_key(*pp_item), *pp_item);
+ /* We should never have duplicates. */
+ CL_ASSERT(p_temp == *pp_item);
+ /* Point pp_item to a valid item in the source map. */
+ (*pp_item) = p_next;
+}
+
+void cl_qmap_delta(IN OUT cl_qmap_t * const p_map1,
+ IN OUT cl_qmap_t * const p_map2,
+ OUT cl_qmap_t * const p_new, OUT cl_qmap_t * const p_old)
+{
+ cl_map_item_t *p_item1, *p_item2;
+ uint64_t key1, key2;
+
+ CL_ASSERT(p_map1);
+ CL_ASSERT(p_map2);
+ CL_ASSERT(p_new);
+ CL_ASSERT(p_old);
+ CL_ASSERT(cl_is_qmap_empty(p_new));
+ CL_ASSERT(cl_is_qmap_empty(p_old));
+
+ p_item1 = cl_qmap_head(p_map1);
+ p_item2 = cl_qmap_head(p_map2);
+
+ while (p_item1 != cl_qmap_end(p_map1) && p_item2 != cl_qmap_end(p_map2)) {
+ key1 = cl_qmap_key(p_item1);
+ key2 = cl_qmap_key(p_item2);
+ if (key1 < key2) {
+ /* We found an old item. */
+ __cl_qmap_delta_move(p_old, p_map1, &p_item1);
+ } else if (key1 > key2) {
+ /* We found a new item. */
+ __cl_qmap_delta_move(p_new, p_map2, &p_item2);
+ } else {
+ /* Move both forward since they have the same key. */
+ p_item1 = cl_qmap_next(p_item1);
+ p_item2 = cl_qmap_next(p_item2);
+ }
+ }
+
+ /* Process the remainder if the end of either source map was reached. */
+ while (p_item2 != cl_qmap_end(p_map2))
+ __cl_qmap_delta_move(p_new, p_map2, &p_item2);
+
+ while (p_item1 != cl_qmap_end(p_map1))
+ __cl_qmap_delta_move(p_old, p_map1, &p_item1);
+}
+
+/******************************************************************************
+ IMPLEMENTATION OF MAP
+******************************************************************************/
+
+#define MAP_GROW_SIZE 32
+
+void cl_map_construct(IN cl_map_t * const p_map)
+{
+ CL_ASSERT(p_map);
+
+ cl_qpool_construct(&p_map->pool);
+}
+
+cl_status_t cl_map_init(IN cl_map_t * const p_map, IN const uint32_t min_items)
+{
+ uint32_t grow_size;
+
+ CL_ASSERT(p_map);
+
+ cl_qmap_init(&p_map->qmap);
+
+ /*
+ * We will grow by min_items/8 items at a time, with a minimum of
+ * MAP_GROW_SIZE.
+ */
+ grow_size = min_items >> 3;
+ if (grow_size < MAP_GROW_SIZE)
+ grow_size = MAP_GROW_SIZE;
+
+ return (cl_qpool_init(&p_map->pool, min_items, 0, grow_size,
+ sizeof(cl_map_obj_t), NULL, NULL, NULL));
+}
+
+void cl_map_destroy(IN cl_map_t * const p_map)
+{
+ CL_ASSERT(p_map);
+
+ cl_qpool_destroy(&p_map->pool);
+}
+
+void *cl_map_insert(IN cl_map_t * const p_map,
+ IN const uint64_t key, IN const void *const p_object)
+{
+ cl_map_obj_t *p_map_obj, *p_obj_at_key;
+
+ CL_ASSERT(p_map);
+
+ p_map_obj = (cl_map_obj_t *) cl_qpool_get(&p_map->pool);
+
+ if (!p_map_obj)
+ return (NULL);
+
+ cl_qmap_set_obj(p_map_obj, p_object);
+
+ p_obj_at_key =
+ (cl_map_obj_t *) cl_qmap_insert(&p_map->qmap, key,
+ &p_map_obj->item);
+
+ /* Return the item to the pool if insertion failed. */
+ if (p_obj_at_key != p_map_obj)
+ cl_qpool_put(&p_map->pool, &p_map_obj->item.pool_item);
+
+ return (cl_qmap_obj(p_obj_at_key));
+}
+
+void *cl_map_get(IN const cl_map_t * const p_map, IN const uint64_t key)
+{
+ cl_map_item_t *p_item;
+
+ CL_ASSERT(p_map);
+
+ p_item = cl_qmap_get(&p_map->qmap, key);
+
+ if (p_item == cl_qmap_end(&p_map->qmap))
+ return (NULL);
+
+ return (cl_qmap_obj(PARENT_STRUCT(p_item, cl_map_obj_t, item)));
+}
+
+void *cl_map_get_next(IN const cl_map_t * const p_map, IN const uint64_t key)
+{
+ cl_map_item_t *p_item;
+
+ CL_ASSERT(p_map);
+
+ p_item = cl_qmap_get_next(&p_map->qmap, key);
+
+ if (p_item == cl_qmap_end(&p_map->qmap))
+ return (NULL);
+
+ return (cl_qmap_obj(PARENT_STRUCT(p_item, cl_map_obj_t, item)));
+}
+
+void cl_map_remove_item(IN cl_map_t * const p_map,
+ IN const cl_map_iterator_t itor)
+{
+ CL_ASSERT(itor->p_map == &p_map->qmap);
+
+ if (itor == cl_map_end(p_map))
+ return;
+
+ cl_qmap_remove_item(&p_map->qmap, (cl_map_item_t *) itor);
+ cl_qpool_put(&p_map->pool, &((cl_map_item_t *) itor)->pool_item);
+}
+
+void *cl_map_remove(IN cl_map_t * const p_map, IN const uint64_t key)
+{
+ cl_map_item_t *p_item;
+ void *p_obj;
+
+ CL_ASSERT(p_map);
+
+ p_item = cl_qmap_remove(&p_map->qmap, key);
+
+ if (p_item == cl_qmap_end(&p_map->qmap))
+ return (NULL);
+
+ p_obj = cl_qmap_obj((cl_map_obj_t *) p_item);
+ cl_qpool_put(&p_map->pool, &p_item->pool_item);
+
+ return (p_obj);
+}
+
+void cl_map_remove_all(IN cl_map_t * const p_map)
+{
+ cl_map_item_t *p_item;
+
+ CL_ASSERT(p_map);
+
+ /* Return all map items to the pool. */
+ while (!cl_is_qmap_empty(&p_map->qmap)) {
+ p_item = cl_qmap_head(&p_map->qmap);
+ cl_qmap_remove_item(&p_map->qmap, p_item);
+ cl_qpool_put(&p_map->pool, &p_item->pool_item);
+
+ if (!cl_is_qmap_empty(&p_map->qmap)) {
+ p_item = cl_qmap_tail(&p_map->qmap);
+ cl_qmap_remove_item(&p_map->qmap, p_item);
+ cl_qpool_put(&p_map->pool, &p_item->pool_item);
+ }
+ }
+}
+
+cl_status_t cl_map_merge(OUT cl_map_t * const p_dest_map,
+ IN OUT cl_map_t * const p_src_map)
+{
+ cl_status_t status = CL_SUCCESS;
+ cl_map_iterator_t itor, next;
+ uint64_t key;
+ void *p_obj, *p_obj2;
+
+ CL_ASSERT(p_dest_map);
+ CL_ASSERT(p_src_map);
+
+ itor = cl_map_head(p_src_map);
+ while (itor != cl_map_end(p_src_map)) {
+ next = cl_map_next(itor);
+
+ p_obj = cl_map_obj(itor);
+ key = cl_map_key(itor);
+
+ cl_map_remove_item(p_src_map, itor);
+
+ /* Insert the object into the destination map. */
+ p_obj2 = cl_map_insert(p_dest_map, key, p_obj);
+ /* Trap for failure. */
+ if (p_obj != p_obj2) {
+ if (!p_obj2)
+ status = CL_INSUFFICIENT_MEMORY;
+ /* Put the object back in the source map. This must succeed. */
+ p_obj2 = cl_map_insert(p_src_map, key, p_obj);
+ CL_ASSERT(p_obj == p_obj2);
+ /* If the failure was due to insufficient memory, return. */
+ if (status != CL_SUCCESS)
+ return (status);
+ }
+ itor = next;
+ }
+
+ return (CL_SUCCESS);
+}
+
+static void __cl_map_revert(IN OUT cl_map_t * const p_map1,
+ IN OUT cl_map_t * const p_map2,
+ IN OUT cl_map_t * const p_new,
+ IN OUT cl_map_t * const p_old)
+{
+ cl_status_t __attribute__((__unused__)) status;
+
+ /* Restore the initial state. */
+ status = cl_map_merge(p_map1, p_old);
+ CL_ASSERT(status == CL_SUCCESS);
+ status = cl_map_merge(p_map2, p_new);
+ CL_ASSERT(status == CL_SUCCESS);
+}
+
+static cl_status_t __cl_map_delta_move(OUT cl_map_t * const p_dest,
+ IN OUT cl_map_t * const p_src,
+ IN OUT cl_map_iterator_t * const p_itor)
+{
+ cl_map_iterator_t next;
+ void *p_obj, *p_obj2;
+ uint64_t key;
+
+ /* Get a valid iterator so we can continue the loop. */
+ next = cl_map_next(*p_itor);
+ /* Get the pointer to the object for insertion. */
+ p_obj = cl_map_obj(*p_itor);
+ /* Get the key for the object. */
+ key = cl_map_key(*p_itor);
+ /* Move the object. */
+ cl_map_remove_item(p_src, *p_itor);
+ p_obj2 = cl_map_insert(p_dest, key, p_obj);
+ /* Check for failure. We should never get a duplicate. */
+ if (!p_obj2) {
+ p_obj2 = cl_map_insert(p_src, key, p_obj);
+ CL_ASSERT(p_obj2 == p_obj);
+ return (CL_INSUFFICIENT_MEMORY);
+ }
+
+ /* We should never get a duplicate */
+ CL_ASSERT(p_obj == p_obj2);
+ /* Update the iterator so that it is valid. */
+ (*p_itor) = next;
+
+ return (CL_SUCCESS);
+}
+
+cl_status_t cl_map_delta(IN OUT cl_map_t * const p_map1,
+ IN OUT cl_map_t * const p_map2,
+ OUT cl_map_t * const p_new, OUT cl_map_t * const p_old)
+{
+ cl_map_iterator_t itor1, itor2;
+ uint64_t key1, key2;
+ cl_status_t status;
+
+ CL_ASSERT(p_map1);
+ CL_ASSERT(p_map2);
+ CL_ASSERT(p_new);
+ CL_ASSERT(p_old);
+ CL_ASSERT(cl_is_map_empty(p_new));
+ CL_ASSERT(cl_is_map_empty(p_old));
+
+ itor1 = cl_map_head(p_map1);
+ itor2 = cl_map_head(p_map2);
+
+ /*
+ * Note that the check is for the end, since duplicate items will remain
+ * in their respective maps.
+ */
+ while (itor1 != cl_map_end(p_map1) && itor2 != cl_map_end(p_map2)) {
+ key1 = cl_map_key(itor1);
+ key2 = cl_map_key(itor2);
+ if (key1 < key2) {
+ status = __cl_map_delta_move(p_old, p_map1, &itor1);
+ /* Check for failure. */
+ if (status != CL_SUCCESS) {
+ /* Restore the initial state. */
+ __cl_map_revert(p_map1, p_map2, p_new, p_old);
+ /* Return the failure status. */
+ return (status);
+ }
+ } else if (key1 > key2) {
+ status = __cl_map_delta_move(p_new, p_map2, &itor2);
+ if (status != CL_SUCCESS) {
+ /* Restore the initial state. */
+ __cl_map_revert(p_map1, p_map2, p_new, p_old);
+ /* Return the failure status. */
+ return (status);
+ }
+ } else {
+ /* Move both forward since they have the same key. */
+ itor1 = cl_map_next(itor1);
+ itor2 = cl_map_next(itor2);
+ }
+ }
+
+ /* Process the remainder if either source map is empty. */
+ while (itor2 != cl_map_end(p_map2)) {
+ status = __cl_map_delta_move(p_new, p_map2, &itor2);
+ if (status != CL_SUCCESS) {
+ /* Restore the initial state. */
+ __cl_map_revert(p_map1, p_map2, p_new, p_old);
+ /* Return the failure status. */
+ return (status);
+ }
+ }
+
+ while (itor1 != cl_map_end(p_map1)) {
+ status = __cl_map_delta_move(p_old, p_map1, &itor1);
+ if (status != CL_SUCCESS) {
+ /* Restore the initial state. */
+ __cl_map_revert(p_map1, p_map2, p_new, p_old);
+ /* Return the failure status. */
+ return (status);
+ }
+ }
+
+ return (CL_SUCCESS);
+}
+
+/******************************************************************************
+ IMPLEMENTATION OF FLEXI MAP
+******************************************************************************/
+
+/*
+ * Get the root.
+ */
+static inline cl_fmap_item_t *__cl_fmap_root(IN const cl_fmap_t * const p_map)
+{
+ CL_ASSERT(p_map);
+ return (p_map->root.p_left);
+}
+
+/*
+ * Returns whether a given item is on the left of its parent.
+ */
+static boolean_t __cl_fmap_is_left_child(IN const cl_fmap_item_t * const p_item)
+{
+ CL_ASSERT(p_item);
+ CL_ASSERT(p_item->p_up);
+ CL_ASSERT(p_item->p_up != p_item);
+
+ return (p_item->p_up->p_left == p_item);
+}
+
+/*
+ * Retrieve the pointer to the parent's pointer to an item.
+ */
+static cl_fmap_item_t **__cl_fmap_get_parent_ptr_to_item(IN cl_fmap_item_t *
+ const p_item)
+{
+ CL_ASSERT(p_item);
+ CL_ASSERT(p_item->p_up);
+ CL_ASSERT(p_item->p_up != p_item);
+
+ if (__cl_fmap_is_left_child(p_item))
+ return (&p_item->p_up->p_left);
+
+ CL_ASSERT(p_item->p_up->p_right == p_item);
+ return (&p_item->p_up->p_right);
+}
+
+/*
+ * Rotate a node to the left. This rotation affects the least number of links
+ * between nodes and brings the level of C up by one while increasing the depth
+ * of A one. Note that the links to/from W, X, Y, and Z are not affected.
+ *
+ * R R
+ * | |
+ * A C
+ * / \ / \
+ * W C A Z
+ * / \ / \
+ * B Z W B
+ * / \ / \
+ * X Y X Y
+ */
+static void __cl_fmap_rot_left(IN cl_fmap_t * const p_map,
+ IN cl_fmap_item_t * const p_item)
+{
+ cl_fmap_item_t **pp_root;
+
+ CL_ASSERT(p_map);
+ CL_ASSERT(p_item);
+ CL_ASSERT(p_item->p_right != &p_map->nil);
+
+ pp_root = __cl_fmap_get_parent_ptr_to_item(p_item);
+
+ /* Point R to C instead of A. */
+ *pp_root = p_item->p_right;
+ /* Set C's parent to R. */
+ (*pp_root)->p_up = p_item->p_up;
+
+ /* Set A's right to B */
+ p_item->p_right = (*pp_root)->p_left;
+ /*
+ * Set B's parent to A. We trap for B being NIL since the
+ * caller may depend on NIL not changing.
+ */
+ if ((*pp_root)->p_left != &p_map->nil)
+ (*pp_root)->p_left->p_up = p_item;
+
+ /* Set C's left to A. */
+ (*pp_root)->p_left = p_item;
+ /* Set A's parent to C. */
+ p_item->p_up = *pp_root;
+}
+
+/*
+ * Rotate a node to the right. This rotation affects the least number of links
+ * between nodes and brings the level of A up by one while increasing the depth
+ * of C one. Note that the links to/from W, X, Y, and Z are not affected.
+ *
+ * R R
+ * | |
+ * C A
+ * / \ / \
+ * A Z W C
+ * / \ / \
+ * W B B Z
+ * / \ / \
+ * X Y X Y
+ */
+static void __cl_fmap_rot_right(IN cl_fmap_t * const p_map,
+ IN cl_fmap_item_t * const p_item)
+{
+ cl_fmap_item_t **pp_root;
+
+ CL_ASSERT(p_map);
+ CL_ASSERT(p_item);
+ CL_ASSERT(p_item->p_left != &p_map->nil);
+
+ /* Point R to A instead of C. */
+ pp_root = __cl_fmap_get_parent_ptr_to_item(p_item);
+ (*pp_root) = p_item->p_left;
+ /* Set A's parent to R. */
+ (*pp_root)->p_up = p_item->p_up;
+
+ /* Set C's left to B */
+ p_item->p_left = (*pp_root)->p_right;
+ /*
+ * Set B's parent to C. We trap for B being NIL since the
+ * caller may depend on NIL not changing.
+ */
+ if ((*pp_root)->p_right != &p_map->nil)
+ (*pp_root)->p_right->p_up = p_item;
+
+ /* Set A's right to C. */
+ (*pp_root)->p_right = p_item;
+ /* Set C's parent to A. */
+ p_item->p_up = *pp_root;
+}
+
+void cl_fmap_init(IN cl_fmap_t * const p_map, IN cl_pfn_fmap_cmp_t pfn_compare)
+{
+ CL_ASSERT(p_map);
+ CL_ASSERT(pfn_compare);
+
+ memset(p_map, 0, sizeof(cl_fmap_t));
+
+ /* special setup for the root node */
+ p_map->root.p_up = &p_map->root;
+ p_map->root.p_left = &p_map->nil;
+ p_map->root.p_right = &p_map->nil;
+ p_map->root.color = CL_MAP_BLACK;
+
+ /* Setup the node used as terminator for all leaves. */
+ p_map->nil.p_up = &p_map->nil;
+ p_map->nil.p_left = &p_map->nil;
+ p_map->nil.p_right = &p_map->nil;
+ p_map->nil.color = CL_MAP_BLACK;
+
+ /* Store the compare function pointer. */
+ p_map->pfn_compare = pfn_compare;
+
+ p_map->state = CL_INITIALIZED;
+
+ cl_fmap_remove_all(p_map);
+}
+
+cl_fmap_item_t *cl_fmap_match(IN const cl_fmap_t * const p_map,
+ IN const void *const p_key,
+ IN cl_pfn_fmap_cmp_t pfn_compare)
+{
+ cl_fmap_item_t *p_item;
+ int cmp;
+
+ CL_ASSERT(p_map);
+ CL_ASSERT(p_map->state == CL_INITIALIZED);
+
+ p_item = __cl_fmap_root(p_map);
+
+ while (p_item != &p_map->nil) {
+ cmp = pfn_compare ? pfn_compare(p_key, p_item->p_key) :
+ p_map->pfn_compare(p_key, p_item->p_key);
+
+ if (!cmp)
+ break; /* just right */
+
+ if (cmp < 0)
+ p_item = p_item->p_left; /* too small */
+ else
+ p_item = p_item->p_right; /* too big */
+ }
+
+ return (p_item);
+}
+
+cl_fmap_item_t *cl_fmap_get(IN const cl_fmap_t * const p_map,
+ IN const void *const p_key)
+{
+ return cl_fmap_match(p_map, p_key, p_map->pfn_compare);
+}
+
+cl_fmap_item_t *cl_fmap_get_next(IN const cl_fmap_t * const p_map,
+ IN const void *const p_key)
+{
+ cl_fmap_item_t *p_item;
+ cl_fmap_item_t *p_item_found;
+ int cmp;
+
+ CL_ASSERT(p_map);
+ CL_ASSERT(p_map->state == CL_INITIALIZED);
+
+ p_item = __cl_fmap_root(p_map);
+ p_item_found = (cl_fmap_item_t *) & p_map->nil;
+
+ while (p_item != &p_map->nil) {
+ cmp = p_map->pfn_compare(p_key, p_item->p_key);
+
+ if (cmp < 0) {
+ p_item_found = p_item;
+ p_item = p_item->p_left; /* too small */
+ } else {
+ p_item = p_item->p_right; /* too big or match */
+ }
+ }
+
+ return (p_item_found);
+}
+
+void cl_fmap_apply_func(IN const cl_fmap_t * const p_map,
+ IN cl_pfn_fmap_apply_t pfn_func,
+ IN const void *const context)
+{
+ cl_fmap_item_t *p_fmap_item;
+
+ /* Note that context can have any arbitrary value. */
+ CL_ASSERT(p_map);
+ CL_ASSERT(p_map->state == CL_INITIALIZED);
+ CL_ASSERT(pfn_func);
+
+ p_fmap_item = cl_fmap_head(p_map);
+ while (p_fmap_item != cl_fmap_end(p_map)) {
+ pfn_func(p_fmap_item, (void *)context);
+ p_fmap_item = cl_fmap_next(p_fmap_item);
+ }
+}
+
+/*
+ * Balance a tree starting at a given item back to the root.
+ */
+static void __cl_fmap_ins_bal(IN cl_fmap_t * const p_map,
+ IN cl_fmap_item_t * p_item)
+{
+ cl_fmap_item_t *p_grand_uncle;
+
+ CL_ASSERT(p_map);
+ CL_ASSERT(p_item);
+ CL_ASSERT(p_item != &p_map->root);
+
+ while (p_item->p_up->color == CL_MAP_RED) {
+ if (__cl_fmap_is_left_child(p_item->p_up)) {
+ p_grand_uncle = p_item->p_up->p_up->p_right;
+ CL_ASSERT(p_grand_uncle);
+ if (p_grand_uncle->color == CL_MAP_RED) {
+ p_grand_uncle->color = CL_MAP_BLACK;
+ p_item->p_up->color = CL_MAP_BLACK;
+ p_item->p_up->p_up->color = CL_MAP_RED;
+ p_item = p_item->p_up->p_up;
+ continue;
+ }
+
+ if (!__cl_fmap_is_left_child(p_item)) {
+ p_item = p_item->p_up;
+ __cl_fmap_rot_left(p_map, p_item);
+ }
+ p_item->p_up->color = CL_MAP_BLACK;
+ p_item->p_up->p_up->color = CL_MAP_RED;
+ __cl_fmap_rot_right(p_map, p_item->p_up->p_up);
+ } else {
+ p_grand_uncle = p_item->p_up->p_up->p_left;
+ CL_ASSERT(p_grand_uncle);
+ if (p_grand_uncle->color == CL_MAP_RED) {
+ p_grand_uncle->color = CL_MAP_BLACK;
+ p_item->p_up->color = CL_MAP_BLACK;
+ p_item->p_up->p_up->color = CL_MAP_RED;
+ p_item = p_item->p_up->p_up;
+ continue;
+ }
+
+ if (__cl_fmap_is_left_child(p_item)) {
+ p_item = p_item->p_up;
+ __cl_fmap_rot_right(p_map, p_item);
+ }
+ p_item->p_up->color = CL_MAP_BLACK;
+ p_item->p_up->p_up->color = CL_MAP_RED;
+ __cl_fmap_rot_left(p_map, p_item->p_up->p_up);
+ }
+ }
+}
+
+cl_fmap_item_t *cl_fmap_insert(IN cl_fmap_t * const p_map,
+ IN const void *const p_key,
+ IN cl_fmap_item_t * const p_item)
+{
+ cl_fmap_item_t *p_insert_at, *p_comp_item;
+ int cmp = 0;
+
+ CL_ASSERT(p_map);
+ CL_ASSERT(p_map->state == CL_INITIALIZED);
+ CL_ASSERT(p_item);
+ CL_ASSERT(p_map->root.p_up == &p_map->root);
+ CL_ASSERT(p_map->root.color != CL_MAP_RED);
+ CL_ASSERT(p_map->nil.color != CL_MAP_RED);
+
+ p_item->p_left = &p_map->nil;
+ p_item->p_right = &p_map->nil;
+ p_item->p_key = p_key;
+ p_item->color = CL_MAP_RED;
+
+ /* Find the insertion location. */
+ p_insert_at = &p_map->root;
+ p_comp_item = __cl_fmap_root(p_map);
+
+ while (p_comp_item != &p_map->nil) {
+ p_insert_at = p_comp_item;
+
+ cmp = p_map->pfn_compare(p_key, p_insert_at->p_key);
+
+ if (!cmp)
+ return (p_insert_at);
+
+ /* Traverse the tree until the correct insertion point is found. */
+ if (cmp < 0)
+ p_comp_item = p_insert_at->p_left;
+ else
+ p_comp_item = p_insert_at->p_right;
+ }
+
+ CL_ASSERT(p_insert_at != &p_map->nil);
+ CL_ASSERT(p_comp_item == &p_map->nil);
+ /* Insert the item. */
+ if (p_insert_at == &p_map->root) {
+ p_insert_at->p_left = p_item;
+ /*
+ * Primitive insert places the new item in front of
+ * the existing item.
+ */
+ __cl_primitive_insert(&p_map->nil.pool_item.list_item,
+ &p_item->pool_item.list_item);
+ } else if (cmp < 0) {
+ p_insert_at->p_left = p_item;
+ /*
+ * Primitive insert places the new item in front of
+ * the existing item.
+ */
+ __cl_primitive_insert(&p_insert_at->pool_item.list_item,
+ &p_item->pool_item.list_item);
+ } else {
+ p_insert_at->p_right = p_item;
+ /*
+ * Primitive insert places the new item in front of
+ * the existing item.
+ */
+ __cl_primitive_insert(p_insert_at->pool_item.list_item.p_next,
+ &p_item->pool_item.list_item);
+ }
+ /* Increase the count. */
+ p_map->count++;
+
+ p_item->p_up = p_insert_at;
+
+ /*
+ * We have added depth to this section of the tree.
+ * Rebalance as necessary as we retrace our path through the tree
+ * and update colors.
+ */
+ __cl_fmap_ins_bal(p_map, p_item);
+
+ __cl_fmap_root(p_map)->color = CL_MAP_BLACK;
+
+ /*
+ * Note that it is not necessary to re-color the nil node black because all
+ * red color assignments are made via the p_up pointer, and nil is never
+ * set as the value of a p_up pointer.
+ */
+
+#ifdef _DEBUG_
+ /* Set the pointer to the map in the map item for consistency checking. */
+ p_item->p_map = p_map;
+#endif
+
+ return (p_item);
+}
+
+static void __cl_fmap_del_bal(IN cl_fmap_t * const p_map,
+ IN cl_fmap_item_t * p_item)
+{
+ cl_fmap_item_t *p_uncle;
+
+ while ((p_item->color != CL_MAP_RED) && (p_item->p_up != &p_map->root)) {
+ if (__cl_fmap_is_left_child(p_item)) {
+ p_uncle = p_item->p_up->p_right;
+
+ if (p_uncle->color == CL_MAP_RED) {
+ p_uncle->color = CL_MAP_BLACK;
+ p_item->p_up->color = CL_MAP_RED;
+ __cl_fmap_rot_left(p_map, p_item->p_up);
+ p_uncle = p_item->p_up->p_right;
+ }
+
+ if (p_uncle->p_right->color != CL_MAP_RED) {
+ if (p_uncle->p_left->color != CL_MAP_RED) {
+ p_uncle->color = CL_MAP_RED;
+ p_item = p_item->p_up;
+ continue;
+ }
+
+ p_uncle->p_left->color = CL_MAP_BLACK;
+ p_uncle->color = CL_MAP_RED;
+ __cl_fmap_rot_right(p_map, p_uncle);
+ p_uncle = p_item->p_up->p_right;
+ }
+ p_uncle->color = p_item->p_up->color;
+ p_item->p_up->color = CL_MAP_BLACK;
+ p_uncle->p_right->color = CL_MAP_BLACK;
+ __cl_fmap_rot_left(p_map, p_item->p_up);
+ break;
+ } else {
+ p_uncle = p_item->p_up->p_left;
+
+ if (p_uncle->color == CL_MAP_RED) {
+ p_uncle->color = CL_MAP_BLACK;
+ p_item->p_up->color = CL_MAP_RED;
+ __cl_fmap_rot_right(p_map, p_item->p_up);
+ p_uncle = p_item->p_up->p_left;
+ }
+
+ if (p_uncle->p_left->color != CL_MAP_RED) {
+ if (p_uncle->p_right->color != CL_MAP_RED) {
+ p_uncle->color = CL_MAP_RED;
+ p_item = p_item->p_up;
+ continue;
+ }
+
+ p_uncle->p_right->color = CL_MAP_BLACK;
+ p_uncle->color = CL_MAP_RED;
+ __cl_fmap_rot_left(p_map, p_uncle);
+ p_uncle = p_item->p_up->p_left;
+ }
+ p_uncle->color = p_item->p_up->color;
+ p_item->p_up->color = CL_MAP_BLACK;
+ p_uncle->p_left->color = CL_MAP_BLACK;
+ __cl_fmap_rot_right(p_map, p_item->p_up);
+ break;
+ }
+ }
+ p_item->color = CL_MAP_BLACK;
+}
+
+void cl_fmap_remove_item(IN cl_fmap_t * const p_map,
+ IN cl_fmap_item_t * const p_item)
+{
+ cl_fmap_item_t *p_child, *p_del_item;
+
+ CL_ASSERT(p_map);
+ CL_ASSERT(p_map->state == CL_INITIALIZED);
+ CL_ASSERT(p_item);
+ CL_ASSERT(p_item->p_map == p_map);
+
+ if (p_item == cl_fmap_end(p_map))
+ return;
+
+ if ((p_item->p_right == &p_map->nil) || (p_item->p_left == &p_map->nil)) {
+ /* The item being removed has children on at most on side. */
+ p_del_item = p_item;
+ } else {
+ /*
+ * The item being removed has children on both side.
+ * We select the item that will replace it. After removing
+ * the substitute item and rebalancing, the tree will have the
+ * correct topology. Exchanging the substitute for the item
+ * will finalize the removal.
+ */
+ p_del_item = cl_fmap_next(p_item);
+ CL_ASSERT(p_del_item != &p_map->nil);
+ }
+
+ /* Remove the item from the list. */
+ __cl_primitive_remove(&p_item->pool_item.list_item);
+ /* Decrement the item count. */
+ p_map->count--;
+
+ /* Get the pointer to the new root's child, if any. */
+ if (p_del_item->p_left != &p_map->nil)
+ p_child = p_del_item->p_left;
+ else
+ p_child = p_del_item->p_right;
+
+ /*
+ * This assignment may modify the parent pointer of the nil node.
+ * This is inconsequential.
+ */
+ p_child->p_up = p_del_item->p_up;
+ (*__cl_fmap_get_parent_ptr_to_item(p_del_item)) = p_child;
+
+ if (p_del_item->color != CL_MAP_RED)
+ __cl_fmap_del_bal(p_map, p_child);
+
+ /*
+ * Note that the splicing done below does not need to occur before
+ * the tree is balanced, since the actual topology changes are made by the
+ * preceding code. The topology is preserved by the color assignment made
+ * below (reader should be reminded that p_del_item == p_item in some cases).
+ */
+ if (p_del_item != p_item) {
+ /*
+ * Finalize the removal of the specified item by exchanging it with
+ * the substitute which we removed above.
+ */
+ p_del_item->p_up = p_item->p_up;
+ p_del_item->p_left = p_item->p_left;
+ p_del_item->p_right = p_item->p_right;
+ (*__cl_fmap_get_parent_ptr_to_item(p_item)) = p_del_item;
+ p_item->p_right->p_up = p_del_item;
+ p_item->p_left->p_up = p_del_item;
+ p_del_item->color = p_item->color;
+ }
+
+ CL_ASSERT(p_map->nil.color != CL_MAP_RED);
+
+#ifdef _DEBUG_
+ /* Clear the pointer to the map since the item has been removed. */
+ p_item->p_map = NULL;
+#endif
+}
+
+cl_fmap_item_t *cl_fmap_remove(IN cl_fmap_t * const p_map,
+ IN const void *const p_key)
+{
+ cl_fmap_item_t *p_item;
+
+ CL_ASSERT(p_map);
+ CL_ASSERT(p_map->state == CL_INITIALIZED);
+
+ /* Seek the node with the specified key */
+ p_item = cl_fmap_get(p_map, p_key);
+
+ cl_fmap_remove_item(p_map, p_item);
+
+ return (p_item);
+}
+
+void cl_fmap_merge(OUT cl_fmap_t * const p_dest_map,
+ IN OUT cl_fmap_t * const p_src_map)
+{
+ cl_fmap_item_t *p_item, *p_item2, *p_next;
+
+ CL_ASSERT(p_dest_map);
+ CL_ASSERT(p_src_map);
+
+ p_item = cl_fmap_head(p_src_map);
+
+ while (p_item != cl_fmap_end(p_src_map)) {
+ p_next = cl_fmap_next(p_item);
+
+ /* Remove the item from its current map. */
+ cl_fmap_remove_item(p_src_map, p_item);
+ /* Insert the item into the destination map. */
+ p_item2 =
+ cl_fmap_insert(p_dest_map, cl_fmap_key(p_item), p_item);
+ /* Check that the item was successfully inserted. */
+ if (p_item2 != p_item) {
+ /* Put the item in back in the source map. */
+ p_item2 =
+ cl_fmap_insert(p_src_map, cl_fmap_key(p_item),
+ p_item);
+ CL_ASSERT(p_item2 == p_item);
+ }
+ p_item = p_next;
+ }
+}
+
+static void __cl_fmap_delta_move(IN OUT cl_fmap_t * const p_dest,
+ IN OUT cl_fmap_t * const p_src,
+ IN OUT cl_fmap_item_t ** const pp_item)
+{
+ cl_fmap_item_t __attribute__((__unused__)) *p_temp;
+ cl_fmap_item_t *p_next;
+
+ /*
+ * Get the next item so that we can ensure that pp_item points to
+ * a valid item upon return from the function.
+ */
+ p_next = cl_fmap_next(*pp_item);
+ /* Move the old item from its current map the the old map. */
+ cl_fmap_remove_item(p_src, *pp_item);
+ p_temp = cl_fmap_insert(p_dest, cl_fmap_key(*pp_item), *pp_item);
+ /* We should never have duplicates. */
+ CL_ASSERT(p_temp == *pp_item);
+ /* Point pp_item to a valid item in the source map. */
+ (*pp_item) = p_next;
+}
+
+void cl_fmap_delta(IN OUT cl_fmap_t * const p_map1,
+ IN OUT cl_fmap_t * const p_map2,
+ OUT cl_fmap_t * const p_new, OUT cl_fmap_t * const p_old)
+{
+ cl_fmap_item_t *p_item1, *p_item2;
+ int cmp;
+
+ CL_ASSERT(p_map1);
+ CL_ASSERT(p_map2);
+ CL_ASSERT(p_new);
+ CL_ASSERT(p_old);
+ CL_ASSERT(cl_is_fmap_empty(p_new));
+ CL_ASSERT(cl_is_fmap_empty(p_old));
+
+ p_item1 = cl_fmap_head(p_map1);
+ p_item2 = cl_fmap_head(p_map2);
+
+ while (p_item1 != cl_fmap_end(p_map1) && p_item2 != cl_fmap_end(p_map2)) {
+ cmp = p_map1->pfn_compare(cl_fmap_key(p_item1),
+ cl_fmap_key(p_item2));
+ if (cmp < 0) {
+ /* We found an old item. */
+ __cl_fmap_delta_move(p_old, p_map1, &p_item1);
+ } else if (cmp > 0) {
+ /* We found a new item. */
+ __cl_fmap_delta_move(p_new, p_map2, &p_item2);
+ } else {
+ /* Move both forward since they have the same key. */
+ p_item1 = cl_fmap_next(p_item1);
+ p_item2 = cl_fmap_next(p_item2);
+ }
+ }
+
+ /* Process the remainder if the end of either source map was reached. */
+ while (p_item2 != cl_fmap_end(p_map2))
+ __cl_fmap_delta_move(p_new, p_map2, &p_item2);
+
+ while (p_item1 != cl_fmap_end(p_map1))
+ __cl_fmap_delta_move(p_old, p_map1, &p_item1);
+}
diff --git a/contrib/ofed/opensm/complib/cl_nodenamemap.c b/contrib/ofed/opensm/complib/cl_nodenamemap.c
new file mode 100644
index 0000000..8ac88cd
--- /dev/null
+++ b/contrib/ofed/opensm/complib/cl_nodenamemap.c
@@ -0,0 +1,229 @@
+/*
+ * Copyright (c) 2008 Voltaire, Inc. All rights reserved.
+ * Copyright (c) 2007 Lawrence Livermore National Lab
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+#define _GNU_SOURCE
+#include <stdio.h>
+#include <errno.h>
+#include <string.h>
+#include <stdlib.h>
+#include <stdarg.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <unistd.h>
+#include <ctype.h>
+#include <config.h>
+#include <errno.h>
+
+#include <complib/cl_nodenamemap.h>
+#include <complib/cl_math.h>
+
+#define PARSE_NODE_MAP_BUFLEN 256
+
+static int parse_node_map_wrap(const char *file_name,
+ int (*create)(void *, uint64_t, char *),
+ void *cxt,
+ char *linebuf,
+ unsigned int linebuflen);
+
+static int map_name(void *cxt, uint64_t guid, char *p)
+{
+ cl_qmap_t *map = cxt;
+ name_map_item_t *item;
+
+ p = strtok(p, "\"#");
+ if (!p)
+ return 0;
+
+ item = malloc(sizeof(*item));
+ if (!item)
+ return -1;
+ item->guid = guid;
+ item->name = strdup(p);
+ cl_qmap_insert(map, item->guid, (cl_map_item_t *) item);
+ return 0;
+}
+
+nn_map_t *open_node_name_map(const char *node_name_map)
+{
+ nn_map_t *map;
+ char linebuf[PARSE_NODE_MAP_BUFLEN + 1];
+
+ if (!node_name_map) {
+#ifdef HAVE_DEFAULT_NODENAME_MAP
+ struct stat buf;
+ node_name_map = HAVE_DEFAULT_NODENAME_MAP;
+ if (stat(node_name_map, &buf))
+ return NULL;
+#else
+ return NULL;
+#endif /* HAVE_DEFAULT_NODENAME_MAP */
+ }
+
+ map = malloc(sizeof(*map));
+ if (!map)
+ return NULL;
+ cl_qmap_init(map);
+
+ memset(linebuf, '\0', PARSE_NODE_MAP_BUFLEN + 1);
+ if (parse_node_map_wrap(node_name_map, map_name, map,
+ linebuf, PARSE_NODE_MAP_BUFLEN)) {
+ if (errno == EIO) {
+ fprintf(stderr,
+ "WARNING failed to parse node name map "
+ "\"%s\"\n",
+ node_name_map);
+ fprintf(stderr,
+ "WARNING failed line: \"%s\"\n",
+ linebuf);
+ }
+ else
+ fprintf(stderr,
+ "WARNING failed to open node name map "
+ "\"%s\" (%s)\n",
+ node_name_map, strerror(errno));
+ close_node_name_map(map);
+ return NULL;
+ }
+
+ return map;
+}
+
+void close_node_name_map(nn_map_t * map)
+{
+ name_map_item_t *item = NULL;
+
+ if (!map)
+ return;
+
+ item = (name_map_item_t *) cl_qmap_head(map);
+ while (item != (name_map_item_t *) cl_qmap_end(map)) {
+ item = (name_map_item_t *) cl_qmap_remove(map, item->guid);
+ free(item->name);
+ free(item);
+ item = (name_map_item_t *) cl_qmap_head(map);
+ }
+ free(map);
+}
+
+char *remap_node_name(nn_map_t * map, uint64_t target_guid, char *nodedesc)
+{
+ char *rc = NULL;
+ name_map_item_t *item = NULL;
+
+ if (!map)
+ goto done;
+
+ item = (name_map_item_t *) cl_qmap_get(map, target_guid);
+ if (item != (name_map_item_t *) cl_qmap_end(map))
+ rc = strdup(item->name);
+
+done:
+ if (rc == NULL)
+ rc = strdup(clean_nodedesc(nodedesc));
+ return (rc);
+}
+
+char *clean_nodedesc(char *nodedesc)
+{
+ int i = 0;
+
+ nodedesc[63] = '\0';
+ while (nodedesc[i]) {
+ if (!isprint(nodedesc[i]))
+ nodedesc[i] = ' ';
+ i++;
+ }
+
+ return (nodedesc);
+}
+
+static int parse_node_map_wrap(const char *file_name,
+ int (*create) (void *, uint64_t, char *),
+ void *cxt,
+ char *linebuf,
+ unsigned int linebuflen)
+{
+ char line[PARSE_NODE_MAP_BUFLEN];
+ FILE *f;
+
+ if (!(f = fopen(file_name, "r")))
+ return -1;
+
+ while (fgets(line, sizeof(line), f)) {
+ uint64_t guid;
+ char *p, *e;
+
+ p = line;
+ while (isspace(*p))
+ p++;
+ if (*p == '\0' || *p == '\n' || *p == '#')
+ continue;
+
+ guid = strtoull(p, &e, 0);
+ if (e == p || (!isspace(*e) && *e != '#' && *e != '\0')) {
+ fclose(f);
+ errno = EIO;
+ if (linebuf) {
+ memcpy(linebuf, line,
+ MIN(PARSE_NODE_MAP_BUFLEN, linebuflen));
+ e = strpbrk(linebuf, "\n");
+ if (e)
+ *e = '\0';
+ }
+ return -1;
+ }
+
+ p = e;
+ while (isspace(*p))
+ p++;
+
+ e = strpbrk(p, "\n");
+ if (e)
+ *e = '\0';
+
+ if (create(cxt, guid, p)) {
+ fclose(f);
+ return -1;
+ }
+ }
+
+ fclose(f);
+ return 0;
+}
+
+int parse_node_map(const char *file_name,
+ int (*create) (void *, uint64_t, char *), void *cxt)
+{
+ return parse_node_map_wrap(file_name, create, cxt, NULL, 0);
+}
diff --git a/contrib/ofed/opensm/complib/cl_pool.c b/contrib/ofed/opensm/complib/cl_pool.c
new file mode 100644
index 0000000..6248688
--- /dev/null
+++ b/contrib/ofed/opensm/complib/cl_pool.c
@@ -0,0 +1,656 @@
+/*
+ * Copyright (c) 2004-2009 Voltaire, Inc. All rights reserved.
+ * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved.
+ * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+/*
+ * Abstract:
+ * Implementation of the grow pools. The grow pools manage a pool of objects.
+ * The pools can grow to meet demand, limited only by system memory.
+ *
+ */
+
+#if HAVE_CONFIG_H
+# include <config.h>
+#endif /* HAVE_CONFIG_H */
+
+#include <stdlib.h>
+#include <string.h>
+#include <complib/cl_qcomppool.h>
+#include <complib/cl_comppool.h>
+#include <complib/cl_qpool.h>
+#include <complib/cl_pool.h>
+#include <complib/cl_math.h>
+
+/*
+ * IMPLEMENTATION OF QUICK COMPOSITE POOL
+ */
+void cl_qcpool_construct(IN cl_qcpool_t * const p_pool)
+{
+ CL_ASSERT(p_pool);
+
+ memset(p_pool, 0, sizeof(cl_qcpool_t));
+
+ p_pool->state = CL_UNINITIALIZED;
+}
+
+cl_status_t cl_qcpool_init(IN cl_qcpool_t * const p_pool,
+ IN const size_t min_size, IN const size_t max_size,
+ IN const size_t grow_size,
+ IN const size_t * const component_sizes,
+ IN const uint32_t num_components,
+ IN cl_pfn_qcpool_init_t pfn_initializer OPTIONAL,
+ IN cl_pfn_qcpool_dtor_t pfn_destructor OPTIONAL,
+ IN const void *const context)
+{
+ cl_status_t status;
+ uint32_t i;
+
+ CL_ASSERT(p_pool);
+ /* Must have a minimum of 1 component. */
+ CL_ASSERT(num_components);
+ /* A component size array is required. */
+ CL_ASSERT(component_sizes);
+ /*
+ * If no initializer is provided, the first component must be large
+ * enough to hold a pool item.
+ */
+ CL_ASSERT(pfn_initializer ||
+ (component_sizes[0] >= sizeof(cl_pool_item_t)));
+
+ cl_qcpool_construct(p_pool);
+
+ if (num_components > 1 && !pfn_initializer)
+ return (CL_INVALID_SETTING);
+
+ if (max_size && max_size < min_size)
+ return (CL_INVALID_SETTING);
+
+ /*
+ * Allocate the array of component sizes and component pointers all
+ * in one allocation.
+ */
+ p_pool->component_sizes = (size_t *) malloc((sizeof(size_t) +
+ sizeof(void *)) *
+ num_components);
+
+ if (!p_pool->component_sizes)
+ return (CL_INSUFFICIENT_MEMORY);
+ else
+ memset(p_pool->component_sizes, 0,
+ (sizeof(size_t) + sizeof(void *)) * num_components);
+
+ /* Calculate the pointer to the array of pointers, used for callbacks. */
+ p_pool->p_components =
+ (void **)(p_pool->component_sizes + num_components);
+
+ /* Copy the user's sizes into our array for future use. */
+ memcpy(p_pool->component_sizes, component_sizes,
+ sizeof(component_sizes[0]) * num_components);
+
+ /* Store the number of components per object. */
+ p_pool->num_components = num_components;
+
+ /* Round up and store the size of the components. */
+ for (i = 0; i < num_components; i++) {
+ /*
+ * We roundup each component size so that all components
+ * are aligned on a natural boundary.
+ */
+ p_pool->component_sizes[i] =
+ ROUNDUP(p_pool->component_sizes[i], sizeof(uintptr_t));
+ }
+
+ p_pool->max_objects = max_size ? max_size : ~(size_t) 0;
+ p_pool->grow_size = grow_size;
+
+ /* Store callback function pointers. */
+ p_pool->pfn_init = pfn_initializer; /* may be NULL */
+ p_pool->pfn_dtor = pfn_destructor; /* may be NULL */
+ p_pool->context = context;
+
+ cl_qlist_init(&p_pool->alloc_list);
+
+ cl_qlist_init(&p_pool->free_list);
+
+ /*
+ * We are now initialized. We change the initialized flag before
+ * growing since the grow function asserts that we are initialized.
+ */
+ p_pool->state = CL_INITIALIZED;
+
+ /* Allocate the minimum number of objects as requested. */
+ if (!min_size)
+ return (CL_SUCCESS);
+
+ status = cl_qcpool_grow(p_pool, min_size);
+ /* Trap for error and cleanup if necessary. */
+ if (status != CL_SUCCESS)
+ cl_qcpool_destroy(p_pool);
+
+ return (status);
+}
+
+void cl_qcpool_destroy(IN cl_qcpool_t * const p_pool)
+{
+ /* CL_ASSERT that a non-NULL pointer was provided. */
+ CL_ASSERT(p_pool);
+ /* CL_ASSERT that we are in a valid state (not uninitialized memory). */
+ CL_ASSERT(cl_is_state_valid(p_pool->state));
+
+ if (p_pool->state == CL_INITIALIZED) {
+ /*
+ * Assert if the user hasn't put everything back in the pool
+ * before destroying it
+ * if they haven't, then most likely they are still using memory
+ * that will be freed, and the destructor will not be called!
+ */
+#ifdef _DEBUG_
+ /* but we do not want "free" version to assert on this one */
+ CL_ASSERT(cl_qcpool_count(p_pool) == p_pool->num_objects);
+#endif
+ /* call the user's destructor for each object in the pool */
+ if (p_pool->pfn_dtor) {
+ while (!cl_is_qlist_empty(&p_pool->free_list)) {
+ p_pool->pfn_dtor((cl_pool_item_t *)
+ cl_qlist_remove_head(&p_pool->
+ free_list),
+ (void *)p_pool->context);
+ }
+ } else {
+ cl_qlist_remove_all(&p_pool->free_list);
+ }
+
+ /* Free all allocated memory blocks. */
+ while (!cl_is_qlist_empty(&p_pool->alloc_list))
+ free(cl_qlist_remove_head(&p_pool->alloc_list));
+
+ if (p_pool->component_sizes) {
+ free(p_pool->component_sizes);
+ p_pool->component_sizes = NULL;
+ }
+ }
+
+ p_pool->state = CL_UNINITIALIZED;
+}
+
+cl_status_t cl_qcpool_grow(IN cl_qcpool_t * const p_pool, IN size_t obj_count)
+{
+ cl_status_t status = CL_SUCCESS;
+ uint8_t *p_objects;
+ cl_pool_item_t *p_pool_item;
+ uint32_t i;
+ size_t obj_size;
+
+ CL_ASSERT(p_pool);
+ CL_ASSERT(p_pool->state == CL_INITIALIZED);
+ CL_ASSERT(obj_count);
+
+ /* Validate that growth is possible. */
+ if (p_pool->num_objects == p_pool->max_objects)
+ return (CL_INSUFFICIENT_MEMORY);
+
+ /* Cap the growth to the desired maximum. */
+ if (obj_count > (p_pool->max_objects - p_pool->num_objects))
+ obj_count = p_pool->max_objects - p_pool->num_objects;
+
+ /* Calculate the size of an object. */
+ obj_size = 0;
+ for (i = 0; i < p_pool->num_components; i++)
+ obj_size += p_pool->component_sizes[i];
+
+ /* Allocate the buffer for the new objects. */
+ p_objects = (uint8_t *)
+ malloc(sizeof(cl_list_item_t) + (obj_size * obj_count));
+
+ /* Make sure the allocation succeeded. */
+ if (!p_objects)
+ return (CL_INSUFFICIENT_MEMORY);
+ else
+ memset(p_objects, 0,
+ sizeof(cl_list_item_t) + (obj_size * obj_count));
+
+ /* Insert the allocation in our list. */
+ cl_qlist_insert_tail(&p_pool->alloc_list, (cl_list_item_t *) p_objects);
+ p_objects += sizeof(cl_list_item_t);
+
+ /* initialize the new elements and add them to the free list */
+ while (obj_count--) {
+ /* Setup the array of components for the current object. */
+ p_pool->p_components[0] = p_objects;
+ for (i = 1; i < p_pool->num_components; i++) {
+ /* Calculate the pointer to the next component. */
+ p_pool->p_components[i] =
+ (uint8_t *) p_pool->p_components[i - 1] +
+ p_pool->component_sizes[i - 1];
+ }
+
+ /*
+ * call the user's initializer
+ * this can fail!
+ */
+ if (p_pool->pfn_init) {
+ p_pool_item = NULL;
+ status = p_pool->pfn_init(p_pool->p_components,
+ p_pool->num_components,
+ (void *)p_pool->context,
+ &p_pool_item);
+ if (status != CL_SUCCESS) {
+ /*
+ * User initialization failed
+ * we may have only grown the pool by some partial amount
+ * Invoke the destructor for the object that failed
+ * initialization.
+ */
+ if (p_pool->pfn_dtor)
+ p_pool->pfn_dtor(p_pool_item,
+ (void *)p_pool->
+ context);
+
+ /* Return the user's status. */
+ return (status);
+ }
+ CL_ASSERT(p_pool_item);
+ } else {
+ /*
+ * If no initializer is provided, assume that the pool item
+ * is stored at the beginning of the first component.
+ */
+ p_pool_item =
+ (cl_pool_item_t *) p_pool->p_components[0];
+ }
+
+#ifdef _DEBUG_
+ /*
+ * Set the pool item's pool pointer to this pool so that we can
+ * check that items get returned to the correct pool.
+ */
+ p_pool_item->p_pool = p_pool;
+#endif
+
+ /* Insert the new item in the free list, traping for failure. */
+ cl_qlist_insert_head(&p_pool->free_list,
+ &p_pool_item->list_item);
+
+ p_pool->num_objects++;
+
+ /* move the pointer to the next item */
+ p_objects += obj_size;
+ }
+
+ return (status);
+}
+
+cl_pool_item_t *cl_qcpool_get(IN cl_qcpool_t * const p_pool)
+{
+ cl_list_item_t *p_list_item;
+
+ CL_ASSERT(p_pool);
+ CL_ASSERT(p_pool->state == CL_INITIALIZED);
+
+ if (cl_is_qlist_empty(&p_pool->free_list)) {
+ /*
+ * No object is available.
+ * Return NULL if the user does not want automatic growth.
+ */
+ if (!p_pool->grow_size)
+ return (NULL);
+
+ /* We ran out of elements. Get more */
+ cl_qcpool_grow(p_pool, p_pool->grow_size);
+ /*
+ * We may not have gotten everything we wanted but we might have
+ * gotten something.
+ */
+ if (cl_is_qlist_empty(&p_pool->free_list))
+ return (NULL);
+ }
+
+ p_list_item = cl_qlist_remove_head(&p_pool->free_list);
+ /* OK, at this point we have an object */
+ CL_ASSERT(p_list_item != cl_qlist_end(&p_pool->free_list));
+ return ((cl_pool_item_t *) p_list_item);
+}
+
+cl_pool_item_t *cl_qcpool_get_tail(IN cl_qcpool_t * const p_pool)
+{
+ cl_list_item_t *p_list_item;
+
+ CL_ASSERT(p_pool);
+ CL_ASSERT(p_pool->state == CL_INITIALIZED);
+
+ if (cl_is_qlist_empty(&p_pool->free_list)) {
+ /*
+ * No object is available.
+ * Return NULL if the user does not want automatic growth.
+ */
+ if (!p_pool->grow_size)
+ return (NULL);
+
+ /* We ran out of elements. Get more */
+ cl_qcpool_grow(p_pool, p_pool->grow_size);
+ /*
+ * We may not have gotten everything we wanted but we might have
+ * gotten something.
+ */
+ if (cl_is_qlist_empty(&p_pool->free_list))
+ return (NULL);
+ }
+
+ p_list_item = cl_qlist_remove_tail(&p_pool->free_list);
+ /* OK, at this point we have an object */
+ CL_ASSERT(p_list_item != cl_qlist_end(&p_pool->free_list));
+ return ((cl_pool_item_t *) p_list_item);
+}
+
+/*
+ * IMPLEMENTATION OF QUICK GROW POOL
+ */
+
+/*
+ * Callback to translate quick composite to quick grow pool
+ * initializer callback.
+ */
+static cl_status_t __cl_qpool_init_cb(IN void **const p_comp_array,
+ IN const uint32_t num_components,
+ IN void *const context,
+ OUT cl_pool_item_t ** const pp_pool_item)
+{
+ cl_qpool_t *p_pool = (cl_qpool_t *) context;
+
+ CL_ASSERT(p_pool);
+ CL_ASSERT(p_pool->pfn_init);
+ CL_ASSERT(num_components == 1);
+
+ UNUSED_PARAM(num_components);
+
+ return (p_pool->pfn_init(p_comp_array[0], (void *)p_pool->context,
+ pp_pool_item));
+}
+
+/*
+ * Callback to translate quick composite to quick grow pool
+ * destructor callback.
+ */
+static void __cl_qpool_dtor_cb(IN const cl_pool_item_t * const p_pool_item,
+ IN void *const context)
+{
+ cl_qpool_t *p_pool = (cl_qpool_t *) context;
+
+ CL_ASSERT(p_pool);
+ CL_ASSERT(p_pool->pfn_dtor);
+
+ p_pool->pfn_dtor(p_pool_item, (void *)p_pool->context);
+}
+
+void cl_qpool_construct(IN cl_qpool_t * const p_pool)
+{
+ memset(p_pool, 0, sizeof(cl_qpool_t));
+
+ cl_qcpool_construct(&p_pool->qcpool);
+}
+
+cl_status_t cl_qpool_init(IN cl_qpool_t * const p_pool,
+ IN const size_t min_size, IN const size_t max_size,
+ IN const size_t grow_size,
+ IN const size_t object_size,
+ IN cl_pfn_qpool_init_t pfn_initializer OPTIONAL,
+ IN cl_pfn_qpool_dtor_t pfn_destructor OPTIONAL,
+ IN const void *const context)
+{
+ cl_status_t status;
+
+ CL_ASSERT(p_pool);
+
+ p_pool->pfn_init = pfn_initializer; /* may be NULL */
+ p_pool->pfn_dtor = pfn_destructor; /* may be NULL */
+ p_pool->context = context;
+
+ status = cl_qcpool_init(&p_pool->qcpool, min_size, max_size, grow_size,
+ &object_size, 1,
+ pfn_initializer ? __cl_qpool_init_cb : NULL,
+ pfn_destructor ? __cl_qpool_dtor_cb : NULL,
+ p_pool);
+
+ return (status);
+}
+
+/*
+ * IMPLEMENTATION OF COMPOSITE POOL
+ */
+
+/*
+ * Callback to translate quick composite to compsite pool
+ * initializer callback.
+ */
+static cl_status_t __cl_cpool_init_cb(IN void **const p_comp_array,
+ IN const uint32_t num_components,
+ IN void *const context,
+ OUT cl_pool_item_t ** const pp_pool_item)
+{
+ cl_cpool_t *p_pool = (cl_cpool_t *) context;
+ cl_pool_obj_t *p_pool_obj;
+ cl_status_t status = CL_SUCCESS;
+
+ CL_ASSERT(p_pool);
+
+ /*
+ * Set our pointer to the list item, which is stored at the beginning of
+ * the first component.
+ */
+ p_pool_obj = (cl_pool_obj_t *) p_comp_array[0];
+ /* Set the pool item pointer for the caller. */
+ *pp_pool_item = &p_pool_obj->pool_item;
+
+ /* Calculate the pointer to the user's first component. */
+ p_comp_array[0] = ((uint8_t *) p_comp_array[0]) + sizeof(cl_pool_obj_t);
+
+ /*
+ * Set the object pointer in the pool object to point to the first of the
+ * user's components.
+ */
+ p_pool_obj->p_object = p_comp_array[0];
+
+ /* Invoke the user's constructor callback. */
+ if (p_pool->pfn_init) {
+ status = p_pool->pfn_init(p_comp_array, num_components,
+ (void *)p_pool->context);
+ }
+
+ return (status);
+}
+
+/*
+ * Callback to translate quick composite to composite pool
+ * destructor callback.
+ */
+static void __cl_cpool_dtor_cb(IN const cl_pool_item_t * const p_pool_item,
+ IN void *const context)
+{
+ cl_cpool_t *p_pool = (cl_cpool_t *) context;
+
+ CL_ASSERT(p_pool);
+ CL_ASSERT(p_pool->pfn_dtor);
+ CL_ASSERT(((cl_pool_obj_t *) p_pool_item)->p_object);
+
+ /* Invoke the user's destructor callback. */
+ p_pool->pfn_dtor((void *)((cl_pool_obj_t *) p_pool_item)->p_object,
+ (void *)p_pool->context);
+}
+
+void cl_cpool_construct(IN cl_cpool_t * const p_pool)
+{
+ CL_ASSERT(p_pool);
+
+ memset(p_pool, 0, sizeof(cl_cpool_t));
+
+ cl_qcpool_construct(&p_pool->qcpool);
+}
+
+cl_status_t cl_cpool_init(IN cl_cpool_t * const p_pool,
+ IN const size_t min_size, IN const size_t max_size,
+ IN const size_t grow_size,
+ IN size_t * const component_sizes,
+ IN const uint32_t num_components,
+ IN cl_pfn_cpool_init_t pfn_initializer OPTIONAL,
+ IN cl_pfn_cpool_dtor_t pfn_destructor OPTIONAL,
+ IN const void *const context)
+{
+ cl_status_t status;
+
+ CL_ASSERT(p_pool);
+ CL_ASSERT(num_components);
+ CL_ASSERT(component_sizes);
+
+ /* Add the size of the pool object to the first component. */
+ component_sizes[0] += sizeof(cl_pool_obj_t);
+
+ /* Store callback function pointers. */
+ p_pool->pfn_init = pfn_initializer; /* may be NULL */
+ p_pool->pfn_dtor = pfn_destructor; /* may be NULL */
+ p_pool->context = context;
+
+ status = cl_qcpool_init(&p_pool->qcpool, min_size, max_size, grow_size,
+ component_sizes, num_components,
+ __cl_cpool_init_cb,
+ pfn_destructor ? __cl_cpool_dtor_cb : NULL,
+ p_pool);
+
+ /* Restore the original value of the first component. */
+ component_sizes[0] -= sizeof(cl_pool_obj_t);
+
+ return (status);
+}
+
+/*
+ * IMPLEMENTATION OF GROW POOL
+ */
+
+/*
+ * Callback to translate quick composite to grow pool constructor callback.
+ */
+static cl_status_t __cl_pool_init_cb(IN void **const pp_obj,
+ IN const uint32_t count,
+ IN void *const context,
+ OUT cl_pool_item_t ** const pp_pool_item)
+{
+ cl_pool_t *p_pool = (cl_pool_t *) context;
+ cl_pool_obj_t *p_pool_obj;
+ cl_status_t status = CL_SUCCESS;
+
+ CL_ASSERT(p_pool);
+ CL_ASSERT(pp_obj);
+ CL_ASSERT(count == 1);
+
+ UNUSED_PARAM(count);
+
+ /*
+ * Set our pointer to the list item, which is stored at the beginning of
+ * the first component.
+ */
+ p_pool_obj = (cl_pool_obj_t *) * pp_obj;
+ *pp_pool_item = &p_pool_obj->pool_item;
+
+ /* Calculate the pointer to the user's first component. */
+ *pp_obj = ((uint8_t *) * pp_obj) + sizeof(cl_pool_obj_t);
+
+ /*
+ * Set the object pointer in the pool item to point to the first of the
+ * user's components.
+ */
+ p_pool_obj->p_object = *pp_obj;
+
+ /* Invoke the user's constructor callback. */
+ if (p_pool->pfn_init)
+ status = p_pool->pfn_init(*pp_obj, (void *)p_pool->context);
+
+ return (status);
+}
+
+/*
+ * Callback to translate quick composite to grow pool destructor callback.
+ */
+static void __cl_pool_dtor_cb(IN const cl_pool_item_t * const p_pool_item,
+ IN void *const context)
+{
+ cl_pool_t *p_pool = (cl_pool_t *) context;
+
+ CL_ASSERT(p_pool);
+ CL_ASSERT(p_pool->pfn_dtor);
+ CL_ASSERT(((cl_pool_obj_t *) p_pool_item)->p_object);
+
+ /* Invoke the user's destructor callback. */
+ p_pool->pfn_dtor((void *)((cl_pool_obj_t *) p_pool_item)->p_object,
+ (void *)p_pool->context);
+}
+
+void cl_pool_construct(IN cl_pool_t * const p_pool)
+{
+ CL_ASSERT(p_pool);
+
+ memset(p_pool, 0, sizeof(cl_pool_t));
+
+ cl_qcpool_construct(&p_pool->qcpool);
+}
+
+cl_status_t cl_pool_init(IN cl_pool_t * const p_pool, IN const size_t min_size,
+ IN const size_t max_size, IN const size_t grow_size,
+ IN const size_t object_size,
+ IN cl_pfn_pool_init_t pfn_initializer OPTIONAL,
+ IN cl_pfn_pool_dtor_t pfn_destructor OPTIONAL,
+ IN const void *const context)
+{
+ cl_status_t status;
+ size_t total_size;
+
+ CL_ASSERT(p_pool);
+
+ /* Add the size of the list item to the first component. */
+ total_size = object_size + sizeof(cl_pool_obj_t);
+
+ /* Store callback function pointers. */
+ p_pool->pfn_init = pfn_initializer; /* may be NULL */
+ p_pool->pfn_dtor = pfn_destructor; /* may be NULL */
+ p_pool->context = context;
+
+ /*
+ * We need an initializer in all cases for quick composite pool, since
+ * the user pointer must be manipulated to hide the prefixed cl_pool_obj_t.
+ */
+ status = cl_qcpool_init(&p_pool->qcpool, min_size, max_size, grow_size,
+ &total_size, 1, __cl_pool_init_cb,
+ pfn_destructor ? __cl_pool_dtor_cb : NULL,
+ p_pool);
+
+ return (status);
+}
diff --git a/contrib/ofed/opensm/complib/cl_ptr_vector.c b/contrib/ofed/opensm/complib/cl_ptr_vector.c
new file mode 100644
index 0000000..36db4db
--- /dev/null
+++ b/contrib/ofed/opensm/complib/cl_ptr_vector.c
@@ -0,0 +1,313 @@
+/*
+ * Copyright (c) 2004-2006 Voltaire, Inc. All rights reserved.
+ * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved.
+ * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+/*
+ * Abstract:
+ * This file contains ivector and isvector implementations.
+ *
+ */
+
+#if HAVE_CONFIG_H
+# include <config.h>
+#endif /* HAVE_CONFIG_H */
+
+#include <stdlib.h>
+#include <string.h>
+#include <complib/cl_ptr_vector.h>
+
+void cl_ptr_vector_construct(IN cl_ptr_vector_t * const p_vector)
+{
+ CL_ASSERT(p_vector);
+
+ memset(p_vector, 0, sizeof(cl_ptr_vector_t));
+
+ p_vector->state = CL_UNINITIALIZED;
+}
+
+cl_status_t cl_ptr_vector_init(IN cl_ptr_vector_t * const p_vector,
+ IN const size_t min_size,
+ IN const size_t grow_size)
+{
+ cl_status_t status = CL_SUCCESS;
+
+ CL_ASSERT(p_vector);
+
+ cl_ptr_vector_construct(p_vector);
+
+ p_vector->grow_size = grow_size;
+
+ /*
+ * Set the state to initialized so that the call to set_size
+ * doesn't assert.
+ */
+ p_vector->state = CL_INITIALIZED;
+
+ /* get the storage needed by the user */
+ if (min_size) {
+ status = cl_ptr_vector_set_size(p_vector, min_size);
+ if (status != CL_SUCCESS)
+ cl_ptr_vector_destroy(p_vector);
+ }
+
+ return (status);
+}
+
+void cl_ptr_vector_destroy(IN cl_ptr_vector_t * const p_vector)
+{
+ CL_ASSERT(p_vector);
+ CL_ASSERT(cl_is_state_valid(p_vector->state));
+
+ /* Call the user's destructor for each element in the array. */
+ if (p_vector->state == CL_INITIALIZED) {
+ /* Destroy the page vector. */
+ if (p_vector->p_ptr_array) {
+ free((void *)p_vector->p_ptr_array);
+ p_vector->p_ptr_array = NULL;
+ }
+ }
+
+ p_vector->state = CL_UNINITIALIZED;
+}
+
+cl_status_t cl_ptr_vector_at(IN const cl_ptr_vector_t * const p_vector,
+ IN const size_t index, OUT void **const p_element)
+{
+ CL_ASSERT(p_vector);
+ CL_ASSERT(p_vector->state == CL_INITIALIZED);
+
+ /* Range check */
+ if (index >= p_vector->size)
+ return (CL_INVALID_PARAMETER);
+
+ *p_element = cl_ptr_vector_get(p_vector, index);
+ return (CL_SUCCESS);
+}
+
+cl_status_t cl_ptr_vector_set(IN cl_ptr_vector_t * const p_vector,
+ IN const size_t index,
+ IN const void *const element)
+{
+ cl_status_t status;
+
+ CL_ASSERT(p_vector);
+ CL_ASSERT(p_vector->state == CL_INITIALIZED);
+
+ /* Determine if the vector has room for this element. */
+ if (index >= p_vector->size) {
+ /* Resize to accomodate the given index. */
+ status = cl_ptr_vector_set_size(p_vector, index + 1);
+
+ /* Check for failure on or before the given index. */
+ if ((status != CL_SUCCESS) && (p_vector->size < index))
+ return (status);
+ }
+
+ /* At this point, the array is guaranteed to be big enough */
+ p_vector->p_ptr_array[index] = element;
+
+ return (CL_SUCCESS);
+}
+
+void *cl_ptr_vector_remove(IN cl_ptr_vector_t * const p_vector,
+ IN const size_t index)
+{
+ size_t src;
+ const void *element;
+
+ CL_ASSERT(p_vector);
+ CL_ASSERT(p_vector->state == CL_INITIALIZED);
+ CL_ASSERT(p_vector->size > index);
+
+ /* Store a copy of the element to return. */
+ element = p_vector->p_ptr_array[index];
+ /* Shift all items above the removed item down. */
+ if (index < --p_vector->size) {
+ for (src = index; src < p_vector->size; src++)
+ p_vector->p_ptr_array[src] =
+ p_vector->p_ptr_array[src + 1];
+ }
+ /* Clear the entry for the element just outside of the new upper bound. */
+ p_vector->p_ptr_array[p_vector->size] = NULL;
+
+ return ((void *)element);
+}
+
+cl_status_t cl_ptr_vector_set_capacity(IN cl_ptr_vector_t * const p_vector,
+ IN const size_t new_capacity)
+{
+ void *p_new_ptr_array;
+
+ CL_ASSERT(p_vector);
+ CL_ASSERT(p_vector->state == CL_INITIALIZED);
+
+ /* Do we have to do anything here? */
+ if (new_capacity <= p_vector->capacity) {
+ /* Nope */
+ return (CL_SUCCESS);
+ }
+
+ /* Allocate our pointer array. */
+ p_new_ptr_array = malloc(new_capacity * sizeof(void *));
+ if (!p_new_ptr_array)
+ return (CL_INSUFFICIENT_MEMORY);
+ else
+ memset(p_new_ptr_array, 0, new_capacity * sizeof(void *));
+
+ if (p_vector->p_ptr_array) {
+ /* Copy the old pointer array into the new. */
+ memcpy(p_new_ptr_array, p_vector->p_ptr_array,
+ p_vector->capacity * sizeof(void *));
+
+ /* Free the old pointer array. */
+ free((void *)p_vector->p_ptr_array);
+ }
+
+ /* Set the new array. */
+ p_vector->p_ptr_array = p_new_ptr_array;
+
+ /* Update the vector with the new capactity. */
+ p_vector->capacity = new_capacity;
+
+ return (CL_SUCCESS);
+}
+
+cl_status_t cl_ptr_vector_set_size(IN cl_ptr_vector_t * const p_vector,
+ IN const size_t size)
+{
+ cl_status_t status;
+ size_t new_capacity;
+
+ CL_ASSERT(p_vector);
+ CL_ASSERT(p_vector->state == CL_INITIALIZED);
+
+ /* Check to see if the requested size is the same as the existing size. */
+ if (size == p_vector->size)
+ return (CL_SUCCESS);
+
+ /* Determine if the vector has room for this element. */
+ if (size >= p_vector->capacity) {
+ if (!p_vector->grow_size)
+ return (CL_INSUFFICIENT_MEMORY);
+
+ /* Calculate the new capacity, taking into account the grow size. */
+ new_capacity = size;
+ if (size % p_vector->grow_size) {
+ /* Round up to nearest grow_size boundary. */
+ new_capacity += p_vector->grow_size -
+ (size % p_vector->grow_size);
+ }
+
+ status = cl_ptr_vector_set_capacity(p_vector, new_capacity);
+ if (status != CL_SUCCESS)
+ return (status);
+ }
+
+ p_vector->size = size;
+ return (CL_SUCCESS);
+}
+
+cl_status_t cl_ptr_vector_set_min_size(IN cl_ptr_vector_t * const p_vector,
+ IN const size_t min_size)
+{
+ CL_ASSERT(p_vector);
+ CL_ASSERT(p_vector->state == CL_INITIALIZED);
+
+ if (min_size > p_vector->size) {
+ /* We have to resize the array */
+ return (cl_ptr_vector_set_size(p_vector, min_size));
+ }
+
+ /* We didn't have to do anything */
+ return (CL_SUCCESS);
+}
+
+void cl_ptr_vector_apply_func(IN const cl_ptr_vector_t * const p_vector,
+ IN cl_pfn_ptr_vec_apply_t pfn_callback,
+ IN const void *const context)
+{
+ size_t i;
+
+ CL_ASSERT(p_vector);
+ CL_ASSERT(p_vector->state == CL_INITIALIZED);
+ CL_ASSERT(pfn_callback);
+
+ for (i = 0; i < p_vector->size; i++)
+ pfn_callback(i, (void *)p_vector->p_ptr_array[i],
+ (void *)context);
+}
+
+size_t cl_ptr_vector_find_from_start(IN const cl_ptr_vector_t * const p_vector,
+ IN cl_pfn_ptr_vec_find_t pfn_callback,
+ IN const void *const context)
+{
+ size_t i;
+
+ CL_ASSERT(p_vector);
+ CL_ASSERT(p_vector->state == CL_INITIALIZED);
+ CL_ASSERT(pfn_callback);
+
+ for (i = 0; i < p_vector->size; i++) {
+ /* Invoke the callback */
+ if (pfn_callback(i, (void *)p_vector->p_ptr_array[i],
+ (void *)context) == CL_SUCCESS) {
+ break;
+ }
+ }
+ return (i);
+}
+
+size_t cl_ptr_vector_find_from_end(IN const cl_ptr_vector_t * const p_vector,
+ IN cl_pfn_ptr_vec_find_t pfn_callback,
+ IN const void *const context)
+{
+ size_t i;
+
+ CL_ASSERT(p_vector);
+ CL_ASSERT(p_vector->state == CL_INITIALIZED);
+ CL_ASSERT(pfn_callback);
+
+ i = p_vector->size;
+
+ while (i) {
+ /* Invoke the callback for the current element. */
+ i--;
+ if (pfn_callback(i, (void *)p_vector->p_ptr_array[i],
+ (void *)context) == CL_SUCCESS) {
+ return (i);
+ }
+ }
+
+ return (p_vector->size);
+}
diff --git a/contrib/ofed/management/opensm/complib/cl_spinlock.c b/contrib/ofed/opensm/complib/cl_spinlock.c
index 2d81696c..2d81696c 100644
--- a/contrib/ofed/management/opensm/complib/cl_spinlock.c
+++ b/contrib/ofed/opensm/complib/cl_spinlock.c
diff --git a/contrib/ofed/management/opensm/complib/cl_statustext.c b/contrib/ofed/opensm/complib/cl_statustext.c
index b02b8b8..b02b8b8 100644
--- a/contrib/ofed/management/opensm/complib/cl_statustext.c
+++ b/contrib/ofed/opensm/complib/cl_statustext.c
diff --git a/contrib/ofed/opensm/complib/cl_thread.c b/contrib/ofed/opensm/complib/cl_thread.c
new file mode 100644
index 0000000..8ddea32
--- /dev/null
+++ b/contrib/ofed/opensm/complib/cl_thread.c
@@ -0,0 +1,140 @@
+/*
+ * Copyright (c) 2004, 2005 Voltaire, Inc. All rights reserved.
+ * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved.
+ * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+#if HAVE_CONFIG_H
+# include <config.h>
+#endif /* HAVE_CONFIG_H */
+
+#include <stdio.h>
+#include <unistd.h>
+#include <sys/sysctl.h>
+#include <complib/cl_thread.h>
+
+/*
+ * Internal function to run a new user mode thread.
+ * This function is always run as a result of creation a new user mode thread.
+ * Its main job is to synchronize the creation and running of the new thread.
+ */
+static void *__cl_thread_wrapper(void *arg)
+{
+ cl_thread_t *p_thread = (cl_thread_t *) arg;
+
+ CL_ASSERT(p_thread);
+ CL_ASSERT(p_thread->pfn_callback);
+
+ p_thread->pfn_callback((void *)p_thread->context);
+
+ return (NULL);
+}
+
+void cl_thread_construct(IN cl_thread_t * const p_thread)
+{
+ CL_ASSERT(p_thread);
+
+ p_thread->osd.state = CL_UNINITIALIZED;
+}
+
+cl_status_t cl_thread_init(IN cl_thread_t * const p_thread,
+ IN cl_pfn_thread_callback_t pfn_callback,
+ IN const void *const context,
+ IN const char *const name)
+{
+ int ret;
+
+ CL_ASSERT(p_thread);
+
+ cl_thread_construct(p_thread);
+
+ /* Initialize the thread structure */
+ p_thread->pfn_callback = pfn_callback;
+ p_thread->context = context;
+
+ ret = pthread_create(&p_thread->osd.id, NULL,
+ __cl_thread_wrapper, (void *)p_thread);
+
+ if (ret != 0) /* pthread_create returns a "0" for success */
+ return (CL_ERROR);
+
+ p_thread->osd.state = CL_INITIALIZED;
+
+ return (CL_SUCCESS);
+}
+
+void cl_thread_destroy(IN cl_thread_t * const p_thread)
+{
+ CL_ASSERT(p_thread);
+ CL_ASSERT(cl_is_state_valid(p_thread->osd.state));
+
+ if (p_thread->osd.state == CL_INITIALIZED)
+ pthread_join(p_thread->osd.id, NULL);
+
+ p_thread->osd.state = CL_UNINITIALIZED;
+}
+
+void cl_thread_suspend(IN const uint32_t pause_ms)
+{
+ /* Convert to micro seconds */
+ usleep(pause_ms * 1000);
+}
+
+void cl_thread_stall(IN const uint32_t pause_us)
+{
+ /*
+ * Not quite a busy wait, but Linux is lacking in terms of high
+ * resolution time stamp information in user mode.
+ */
+ usleep(pause_us);
+}
+
+int cl_proc_count(void)
+{
+ int ret;
+ size_t size = sizeof(ret);
+
+ if (sysctlbyname("hw.ncpu", &ret, &size, NULL, 0) != 0 || ret < 1)
+ ret = 1;
+ return ret;
+}
+
+boolean_t cl_is_current_thread(IN const cl_thread_t * const p_thread)
+{
+ pthread_t current;
+
+ CL_ASSERT(p_thread);
+ CL_ASSERT(p_thread->osd.state == CL_INITIALIZED);
+
+ current = pthread_self();
+ return (pthread_equal(current, p_thread->osd.id));
+}
diff --git a/contrib/ofed/opensm/complib/cl_threadpool.c b/contrib/ofed/opensm/complib/cl_threadpool.c
new file mode 100644
index 0000000..11abfbb
--- /dev/null
+++ b/contrib/ofed/opensm/complib/cl_threadpool.c
@@ -0,0 +1,150 @@
+/*
+ * Copyright (c) 2004-2007 Voltaire, Inc. All rights reserved.
+ * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved.
+ * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+/*
+ * Abstract:
+ * Implementation of thread pool.
+ *
+ */
+
+#if HAVE_CONFIG_H
+# include <config.h>
+#endif /* HAVE_CONFIG_H */
+
+#include <stdlib.h>
+#include <string.h>
+#include <pthread.h>
+#include <complib/cl_threadpool.h>
+
+static void cleanup_mutex(void *arg)
+{
+ pthread_mutex_unlock(&((cl_thread_pool_t *) arg)->mutex);
+}
+
+static void *thread_pool_routine(void *context)
+{
+ cl_thread_pool_t *p_thread_pool = (cl_thread_pool_t *) context;
+
+ do {
+ pthread_mutex_lock(&p_thread_pool->mutex);
+ pthread_cleanup_push(cleanup_mutex, p_thread_pool);
+ while (!p_thread_pool->events)
+ pthread_cond_wait(&p_thread_pool->cond,
+ &p_thread_pool->mutex);
+ p_thread_pool->events--;
+ pthread_cleanup_pop(1);
+ /* The event has been signalled. Invoke the callback. */
+ (*p_thread_pool->pfn_callback) (p_thread_pool->context);
+ } while (1);
+
+ return NULL;
+}
+
+cl_status_t cl_thread_pool_init(IN cl_thread_pool_t * const p_thread_pool,
+ IN unsigned count,
+ IN void (*pfn_callback) (void *),
+ IN void *context, IN const char *const name)
+{
+ int i;
+
+ CL_ASSERT(p_thread_pool);
+ CL_ASSERT(pfn_callback);
+
+ memset(p_thread_pool, 0, sizeof(*p_thread_pool));
+
+ if (!count)
+ count = cl_proc_count();
+
+ pthread_mutex_init(&p_thread_pool->mutex, NULL);
+ pthread_cond_init(&p_thread_pool->cond, NULL);
+
+ p_thread_pool->events = 0;
+
+ p_thread_pool->pfn_callback = pfn_callback;
+ p_thread_pool->context = context;
+
+ p_thread_pool->tid = calloc(count, sizeof(*p_thread_pool->tid));
+ if (!p_thread_pool->tid) {
+ cl_thread_pool_destroy(p_thread_pool);
+ return CL_INSUFFICIENT_MEMORY;
+ }
+
+ p_thread_pool->running_count = count;
+
+ for (i = 0; i < count; i++) {
+ if (pthread_create(&p_thread_pool->tid[i], NULL,
+ thread_pool_routine, p_thread_pool) != 0) {
+ cl_thread_pool_destroy(p_thread_pool);
+ return CL_INSUFFICIENT_RESOURCES;
+ }
+ }
+
+ return (CL_SUCCESS);
+}
+
+void cl_thread_pool_destroy(IN cl_thread_pool_t * const p_thread_pool)
+{
+ int i;
+
+ CL_ASSERT(p_thread_pool);
+
+ for (i = 0; i < p_thread_pool->running_count; i++)
+ if (p_thread_pool->tid[i])
+ pthread_cancel(p_thread_pool->tid[i]);
+
+ for (i = 0; i < p_thread_pool->running_count; i++)
+ if (p_thread_pool->tid[i])
+ pthread_join(p_thread_pool->tid[i], NULL);
+
+ p_thread_pool->running_count = 0;
+
+ free(p_thread_pool->tid);
+
+ pthread_cond_destroy(&p_thread_pool->cond);
+ pthread_mutex_destroy(&p_thread_pool->mutex);
+
+ p_thread_pool->events = 0;
+}
+
+cl_status_t cl_thread_pool_signal(IN cl_thread_pool_t * const p_thread_pool)
+{
+ int ret;
+ CL_ASSERT(p_thread_pool);
+ pthread_mutex_lock(&p_thread_pool->mutex);
+ p_thread_pool->events++;
+ ret = pthread_cond_signal(&p_thread_pool->cond);
+ pthread_mutex_unlock(&p_thread_pool->mutex);
+ return ret;
+}
diff --git a/contrib/ofed/opensm/complib/cl_timer.c b/contrib/ofed/opensm/complib/cl_timer.c
new file mode 100644
index 0000000..92b8102
--- /dev/null
+++ b/contrib/ofed/opensm/complib/cl_timer.c
@@ -0,0 +1,437 @@
+/*
+ * Copyright (c) 2004-2006 Voltaire, Inc. All rights reserved.
+ * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved.
+ * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+/*
+ * Abstract:
+ * Abstraction of Timer create, destroy functions.
+ *
+ */
+
+#if HAVE_CONFIG_H
+# include <config.h>
+#endif /* HAVE_CONFIG_H */
+
+#include <stdlib.h>
+#include <string.h>
+#include <complib/cl_timer.h>
+#include <sys/time.h>
+#include <sys/errno.h>
+#include <stdio.h>
+
+/* Timer provider (emulates timers in user mode). */
+typedef struct _cl_timer_prov {
+ pthread_t thread;
+ pthread_mutex_t mutex;
+ pthread_cond_t cond;
+ cl_qlist_t queue;
+
+ boolean_t exit;
+
+} cl_timer_prov_t;
+
+/* Global timer provider. */
+static cl_timer_prov_t *gp_timer_prov = NULL;
+
+static void *__cl_timer_prov_cb(IN void *const context);
+
+/*
+ * Creates the process global timer provider. Must be called by the shared
+ * object framework to solve all serialization issues.
+ */
+cl_status_t __cl_timer_prov_create(void)
+{
+ CL_ASSERT(gp_timer_prov == NULL);
+
+ gp_timer_prov = malloc(sizeof(cl_timer_prov_t));
+ if (!gp_timer_prov)
+ return (CL_INSUFFICIENT_MEMORY);
+ else
+ memset(gp_timer_prov, 0, sizeof(cl_timer_prov_t));
+
+ cl_qlist_init(&gp_timer_prov->queue);
+
+ pthread_mutex_init(&gp_timer_prov->mutex, NULL);
+ pthread_cond_init(&gp_timer_prov->cond, NULL);
+
+ if (pthread_create(&gp_timer_prov->thread, NULL,
+ __cl_timer_prov_cb, NULL)) {
+ __cl_timer_prov_destroy();
+ return (CL_ERROR);
+ }
+
+ return (CL_SUCCESS);
+}
+
+void __cl_timer_prov_destroy(void)
+{
+ pthread_t tid;
+
+ if (!gp_timer_prov)
+ return;
+
+ tid = gp_timer_prov->thread;
+ pthread_mutex_lock(&gp_timer_prov->mutex);
+ gp_timer_prov->exit = TRUE;
+ pthread_cond_broadcast(&gp_timer_prov->cond);
+ pthread_mutex_unlock(&gp_timer_prov->mutex);
+ pthread_join(tid, NULL);
+
+ /* Destroy the mutex and condition variable. */
+ pthread_mutex_destroy(&gp_timer_prov->mutex);
+ pthread_cond_destroy(&gp_timer_prov->cond);
+
+ /* Free the memory and reset the global pointer. */
+ free(gp_timer_prov);
+ gp_timer_prov = NULL;
+}
+
+/*
+ * This is the internal work function executed by the timer's thread.
+ */
+static void *__cl_timer_prov_cb(IN void *const context)
+{
+ int ret;
+ cl_timer_t *p_timer;
+
+ pthread_mutex_lock(&gp_timer_prov->mutex);
+ while (!gp_timer_prov->exit) {
+ if (cl_is_qlist_empty(&gp_timer_prov->queue)) {
+ /* Wait until we exit or a timer is queued. */
+ /* cond wait does:
+ * pthread_cond_wait atomically unlocks the mutex (as per
+ * pthread_unlock_mutex) and waits for the condition variable
+ * cond to be signaled. The thread execution is suspended and
+ * does not consume any CPU time until the condition variable is
+ * signaled. The mutex must be locked by the calling thread on
+ * entrance to pthread_cond_wait. Before RETURNING TO THE
+ * CALLING THREAD, PTHREAD_COND_WAIT RE-ACQUIRES MUTEX (as per
+ * pthread_lock_mutex).
+ */
+ ret = pthread_cond_wait(&gp_timer_prov->cond,
+ &gp_timer_prov->mutex);
+ } else {
+ /*
+ * The timer elements are on the queue in expiration order.
+ * Get the first in the list to determine how long to wait.
+ */
+
+ p_timer =
+ (cl_timer_t *) cl_qlist_head(&gp_timer_prov->queue);
+ ret =
+ pthread_cond_timedwait(&gp_timer_prov->cond,
+ &gp_timer_prov->mutex,
+ &p_timer->timeout);
+
+ /*
+ Sleep again on every event other than timeout and invalid
+ Note: EINVAL means that we got behind. This can occur when
+ we are very busy...
+ */
+ if (ret != ETIMEDOUT && ret != EINVAL)
+ continue;
+
+ /*
+ * The timer expired. Check the state in case it was cancelled
+ * after it expired but before we got a chance to invoke the
+ * callback.
+ */
+ if (p_timer->timer_state != CL_TIMER_QUEUED)
+ continue;
+
+ /*
+ * Mark the timer as running to synchronize with its
+ * cancelation since we can't hold the mutex during the
+ * callback.
+ */
+ p_timer->timer_state = CL_TIMER_RUNNING;
+
+ /* Remove the item from the timer queue. */
+ cl_qlist_remove_item(&gp_timer_prov->queue,
+ &p_timer->list_item);
+ pthread_mutex_unlock(&gp_timer_prov->mutex);
+ /* Invoke the callback. */
+ p_timer->pfn_callback((void *)p_timer->context);
+
+ /* Acquire the mutex again. */
+ pthread_mutex_lock(&gp_timer_prov->mutex);
+ /*
+ * Only set the state to idle if the timer has not been accessed
+ * from the callback
+ */
+ if (p_timer->timer_state == CL_TIMER_RUNNING)
+ p_timer->timer_state = CL_TIMER_IDLE;
+
+ /*
+ * Signal any thread trying to manipulate the timer
+ * that expired.
+ */
+ pthread_cond_signal(&p_timer->cond);
+ }
+ }
+ gp_timer_prov->thread = 0;
+ pthread_mutex_unlock(&gp_timer_prov->mutex);
+ pthread_exit(NULL);
+}
+
+/* Timer implementation. */
+void cl_timer_construct(IN cl_timer_t * const p_timer)
+{
+ memset(p_timer, 0, sizeof(cl_timer_t));
+ p_timer->state = CL_UNINITIALIZED;
+}
+
+cl_status_t cl_timer_init(IN cl_timer_t * const p_timer,
+ IN cl_pfn_timer_callback_t pfn_callback,
+ IN const void *const context)
+{
+ CL_ASSERT(p_timer);
+ CL_ASSERT(pfn_callback);
+
+ cl_timer_construct(p_timer);
+
+ if (!gp_timer_prov)
+ return (CL_ERROR);
+
+ /* Store timer parameters. */
+ p_timer->pfn_callback = pfn_callback;
+ p_timer->context = context;
+
+ /* Mark the timer as idle. */
+ p_timer->timer_state = CL_TIMER_IDLE;
+
+ /* Create the condition variable that is used when cancelling a timer. */
+ pthread_cond_init(&p_timer->cond, NULL);
+
+ p_timer->state = CL_INITIALIZED;
+
+ return (CL_SUCCESS);
+}
+
+void cl_timer_destroy(IN cl_timer_t * const p_timer)
+{
+ CL_ASSERT(p_timer);
+ CL_ASSERT(cl_is_state_valid(p_timer->state));
+
+ if (p_timer->state == CL_INITIALIZED)
+ cl_timer_stop(p_timer);
+
+ p_timer->state = CL_UNINITIALIZED;
+
+ /* is it possible we have some threads waiting on the cond now? */
+ pthread_cond_broadcast(&p_timer->cond);
+ pthread_cond_destroy(&p_timer->cond);
+
+}
+
+/*
+ * Return TRUE if timeout value 1 is earlier than timeout value 2.
+ */
+static __inline boolean_t __cl_timer_is_earlier(IN struct timespec *p_timeout1,
+ IN struct timespec *p_timeout2)
+{
+ return ((p_timeout1->tv_sec < p_timeout2->tv_sec) ||
+ ((p_timeout1->tv_sec == p_timeout2->tv_sec) &&
+ (p_timeout1->tv_nsec < p_timeout2->tv_nsec)));
+}
+
+/*
+ * Search for a timer with an earlier timeout than the one provided by
+ * the context. Both the list item and the context are pointers to
+ * a cl_timer_t structure with valid timeouts.
+ */
+static cl_status_t __cl_timer_find(IN const cl_list_item_t * const p_list_item,
+ IN void *const context)
+{
+ cl_timer_t *p_in_list;
+ cl_timer_t *p_new;
+
+ CL_ASSERT(p_list_item);
+ CL_ASSERT(context);
+
+ p_in_list = (cl_timer_t *) p_list_item;
+ p_new = (cl_timer_t *) context;
+
+ CL_ASSERT(p_in_list->state == CL_INITIALIZED);
+ CL_ASSERT(p_new->state == CL_INITIALIZED);
+
+ CL_ASSERT(p_in_list->timer_state == CL_TIMER_QUEUED);
+
+ if (__cl_timer_is_earlier(&p_in_list->timeout, &p_new->timeout))
+ return (CL_SUCCESS);
+
+ return (CL_NOT_FOUND);
+}
+
+/*
+ * Calculate 'struct timespec' value that is the
+ * current time plus the 'time_ms' milliseconds.
+ */
+static __inline void __cl_timer_calculate(IN const uint32_t time_ms,
+ OUT struct timespec * const p_timer)
+{
+ struct timeval curtime, deltatime, endtime;
+
+ gettimeofday(&curtime, NULL);
+
+ deltatime.tv_sec = time_ms / 1000;
+ deltatime.tv_usec = (time_ms % 1000) * 1000;
+ timeradd(&curtime, &deltatime, &endtime);
+ p_timer->tv_sec = endtime.tv_sec;
+ p_timer->tv_nsec = endtime.tv_usec * 1000;
+}
+
+cl_status_t cl_timer_start(IN cl_timer_t * const p_timer,
+ IN const uint32_t time_ms)
+{
+ cl_list_item_t *p_list_item;
+
+ CL_ASSERT(p_timer);
+ CL_ASSERT(p_timer->state == CL_INITIALIZED);
+
+ pthread_mutex_lock(&gp_timer_prov->mutex);
+ /* Signal the timer provider thread to wake up. */
+ pthread_cond_signal(&gp_timer_prov->cond);
+
+ /* Remove the timer from the queue if currently queued. */
+ if (p_timer->timer_state == CL_TIMER_QUEUED)
+ cl_qlist_remove_item(&gp_timer_prov->queue,
+ &p_timer->list_item);
+
+ __cl_timer_calculate(time_ms, &p_timer->timeout);
+
+ /* Add the timer to the queue. */
+ if (cl_is_qlist_empty(&gp_timer_prov->queue)) {
+ /* The timer list is empty. Add to the head. */
+ cl_qlist_insert_head(&gp_timer_prov->queue,
+ &p_timer->list_item);
+ } else {
+ /* Find the correct insertion place in the list for the timer. */
+ p_list_item = cl_qlist_find_from_tail(&gp_timer_prov->queue,
+ __cl_timer_find, p_timer);
+
+ /* Insert the timer. */
+ cl_qlist_insert_next(&gp_timer_prov->queue, p_list_item,
+ &p_timer->list_item);
+ }
+ /* Set the state. */
+ p_timer->timer_state = CL_TIMER_QUEUED;
+ pthread_mutex_unlock(&gp_timer_prov->mutex);
+
+ return (CL_SUCCESS);
+}
+
+void cl_timer_stop(IN cl_timer_t * const p_timer)
+{
+ CL_ASSERT(p_timer);
+ CL_ASSERT(p_timer->state == CL_INITIALIZED);
+
+ pthread_mutex_lock(&gp_timer_prov->mutex);
+ switch (p_timer->timer_state) {
+ case CL_TIMER_RUNNING:
+ /* Wait for the callback to complete. */
+ pthread_cond_wait(&p_timer->cond, &gp_timer_prov->mutex);
+ /* Timer could have been queued while we were waiting. */
+ if (p_timer->timer_state != CL_TIMER_QUEUED)
+ break;
+
+ case CL_TIMER_QUEUED:
+ /* Change the state of the timer. */
+ p_timer->timer_state = CL_TIMER_IDLE;
+ /* Remove the timer from the queue. */
+ cl_qlist_remove_item(&gp_timer_prov->queue,
+ &p_timer->list_item);
+ /*
+ * Signal the timer provider thread to move onto the
+ * next timer in the queue.
+ */
+ pthread_cond_signal(&gp_timer_prov->cond);
+ break;
+
+ case CL_TIMER_IDLE:
+ break;
+ }
+ pthread_mutex_unlock(&gp_timer_prov->mutex);
+}
+
+cl_status_t cl_timer_trim(IN cl_timer_t * const p_timer,
+ IN const uint32_t time_ms)
+{
+ struct timespec newtime;
+ cl_status_t status;
+
+ CL_ASSERT(p_timer);
+ CL_ASSERT(p_timer->state == CL_INITIALIZED);
+
+ pthread_mutex_lock(&gp_timer_prov->mutex);
+
+ __cl_timer_calculate(time_ms, &newtime);
+
+ if (p_timer->timer_state == CL_TIMER_QUEUED) {
+ /* If the old time is earlier, do not trim it. Just return. */
+ if (__cl_timer_is_earlier(&p_timer->timeout, &newtime)) {
+ pthread_mutex_unlock(&gp_timer_prov->mutex);
+ return (CL_SUCCESS);
+ }
+ }
+
+ /* Reset the timer to the new timeout value. */
+
+ pthread_mutex_unlock(&gp_timer_prov->mutex);
+ status = cl_timer_start(p_timer, time_ms);
+
+ return (status);
+}
+
+uint64_t cl_get_time_stamp(void)
+{
+ uint64_t tstamp;
+ struct timeval tv;
+
+ gettimeofday(&tv, NULL);
+
+ /* Convert the time of day into a microsecond timestamp. */
+ tstamp = ((uint64_t) tv.tv_sec * 1000000) + (uint64_t) tv.tv_usec;
+
+ return (tstamp);
+}
+
+uint32_t cl_get_time_stamp_sec(void)
+{
+ struct timeval tv;
+
+ gettimeofday(&tv, NULL);
+
+ return (tv.tv_sec);
+}
diff --git a/contrib/ofed/opensm/complib/cl_vector.c b/contrib/ofed/opensm/complib/cl_vector.c
new file mode 100644
index 0000000..f309a09
--- /dev/null
+++ b/contrib/ofed/opensm/complib/cl_vector.c
@@ -0,0 +1,548 @@
+/*
+ * Copyright (c) 2004-2006 Voltaire, Inc. All rights reserved.
+ * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved.
+ * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+/*
+ * Abstract:
+ * This file contains ivector and isvector implementations.
+ *
+ */
+
+#if HAVE_CONFIG_H
+# include <config.h>
+#endif /* HAVE_CONFIG_H */
+
+#include <stdlib.h>
+#include <string.h>
+#include <complib/cl_vector.h>
+
+/*
+ * Define the maximum size for array pages in an cl_vector_t.
+ * This size is in objects, not bytes.
+ */
+#define SVEC_MAX_PAGE_SIZE 0x1000
+
+/*
+ * cl_vector_copy_general
+ *
+ * Description:
+ * copy operator used when size of the user object doesn't fit one of the
+ * other optimized copy functions.
+ *
+ * Inputs:
+ * p_src - source for copy
+ *
+ * Outputs:
+ * p_dest - destination for copy
+ *
+ * Returns:
+ * None
+ *
+ */
+static void cl_vector_copy_general(OUT void *const p_dest,
+ IN const void *const p_src,
+ IN const size_t size)
+{
+ memcpy(p_dest, p_src, size);
+}
+
+/*
+ * cl_vector_copy8
+ *
+ * Description:
+ * copy operator used when the user structure is only 8 bits long.
+ *
+ * Inputs:
+ * p_src - source for copy
+ *
+ * Outputs:
+ * p_dest - destination for copy
+ *
+ * Returns:
+ * None
+ *
+ */
+static void cl_vector_copy8(OUT void *const p_dest,
+ IN const void *const p_src, IN const size_t size)
+{
+ CL_ASSERT(size == sizeof(uint8_t));
+ UNUSED_PARAM(size);
+
+ *(uint8_t *) p_dest = *(uint8_t *) p_src;
+}
+
+/*
+ * cl_vector_copy16
+ *
+ * Description:
+ * copy operator used when the user structure is only 16 bits long.
+ *
+ * Inputs:
+ * p_src - source for copy
+ *
+ * Outputs:
+ * p_dest - destination for copy
+ *
+ * Returns:
+ * None
+ *
+ */
+void cl_vector_copy16(OUT void *const p_dest,
+ IN const void *const p_src, IN const size_t size)
+{
+ CL_ASSERT(size == sizeof(uint16_t));
+ UNUSED_PARAM(size);
+
+ *(uint16_t *) p_dest = *(uint16_t *) p_src;
+}
+
+/*
+ * cl_vector_copy32
+ *
+ * Description:
+ * copy operator used when the user structure is only 32 bits long.
+ *
+ * Inputs:
+ * p_src - source for copy
+ *
+ * Outputs:
+ * p_dest - destination for copy
+ *
+ * Returns:
+ * None
+ *
+ */
+void cl_vector_copy32(OUT void *const p_dest,
+ IN const void *const p_src, IN const size_t size)
+{
+ CL_ASSERT(size == sizeof(uint32_t));
+ UNUSED_PARAM(size);
+
+ *(uint32_t *) p_dest = *(uint32_t *) p_src;
+}
+
+/*
+ * cl_vector_copy64
+ *
+ * Description:
+ * copy operator used when the user structure is only 64 bits long.
+ *
+ * Inputs:
+ * p_src - source for copy
+ *
+ * Outputs:
+ * p_dest - destination for copy
+ *
+ * Returns:
+ * None
+ *
+ */
+void cl_vector_copy64(OUT void *const p_dest,
+ IN const void *const p_src, IN const size_t size)
+{
+ CL_ASSERT(size == sizeof(uint64_t));
+ UNUSED_PARAM(size);
+
+ *(uint64_t *) p_dest = *(uint64_t *) p_src;
+}
+
+void cl_vector_construct(IN cl_vector_t * const p_vector)
+{
+ CL_ASSERT(p_vector);
+
+ memset(p_vector, 0, sizeof(cl_vector_t));
+
+ p_vector->state = CL_UNINITIALIZED;
+}
+
+cl_status_t cl_vector_init(IN cl_vector_t * const p_vector,
+ IN const size_t min_size, IN const size_t grow_size,
+ IN const size_t element_size,
+ IN cl_pfn_vec_init_t pfn_init OPTIONAL,
+ IN cl_pfn_vec_dtor_t pfn_dtor OPTIONAL,
+ IN const void *const context)
+{
+ cl_status_t status = CL_SUCCESS;
+
+ CL_ASSERT(p_vector);
+ CL_ASSERT(element_size);
+
+ cl_vector_construct(p_vector);
+
+ p_vector->grow_size = grow_size;
+ p_vector->element_size = element_size;
+ p_vector->pfn_init = pfn_init;
+ p_vector->pfn_dtor = pfn_dtor;
+ p_vector->context = context;
+
+ /*
+ * Try to choose a smart copy operator
+ * someday, we could simply let the users pass one in
+ */
+ switch (element_size) {
+ case sizeof(uint8_t):
+ p_vector->pfn_copy = cl_vector_copy8;
+ break;
+
+ case sizeof(uint16_t):
+ p_vector->pfn_copy = cl_vector_copy16;
+ break;
+
+ case sizeof(uint32_t):
+ p_vector->pfn_copy = cl_vector_copy32;
+ break;
+
+ case sizeof(uint64_t):
+ p_vector->pfn_copy = cl_vector_copy64;
+ break;
+
+ default:
+ p_vector->pfn_copy = cl_vector_copy_general;
+ break;
+ }
+
+ /*
+ * Set the state to initialized so that the call to set_size
+ * doesn't assert.
+ */
+ p_vector->state = CL_INITIALIZED;
+
+ /* Initialize the allocation list */
+ cl_qlist_init(&p_vector->alloc_list);
+
+ /* get the storage needed by the user */
+ if (min_size) {
+ status = cl_vector_set_size(p_vector, min_size);
+ if (status != CL_SUCCESS)
+ cl_vector_destroy(p_vector);
+ }
+
+ return (status);
+}
+
+void cl_vector_destroy(IN cl_vector_t * const p_vector)
+{
+ size_t i;
+ void *p_element;
+
+ CL_ASSERT(p_vector);
+ CL_ASSERT(cl_is_state_valid(p_vector->state));
+
+ /* Call the user's destructor for each element in the array. */
+ if (p_vector->state == CL_INITIALIZED) {
+ if (p_vector->pfn_dtor) {
+ for (i = 0; i < p_vector->size; i++) {
+ p_element = p_vector->p_ptr_array[i];
+ /* Sanity check! */
+ CL_ASSERT(p_element);
+ p_vector->pfn_dtor(p_element,
+ (void *)p_vector->context);
+ }
+ }
+
+ /* Deallocate the pages */
+ while (!cl_is_qlist_empty(&p_vector->alloc_list))
+ free(cl_qlist_remove_head(&p_vector->alloc_list));
+
+ /* Destroy the page vector. */
+ if (p_vector->p_ptr_array) {
+ free(p_vector->p_ptr_array);
+ p_vector->p_ptr_array = NULL;
+ }
+ }
+
+ p_vector->state = CL_UNINITIALIZED;
+}
+
+cl_status_t cl_vector_at(IN const cl_vector_t * const p_vector,
+ IN const size_t index, OUT void *const p_element)
+{
+ CL_ASSERT(p_vector);
+ CL_ASSERT(p_vector->state == CL_INITIALIZED);
+
+ /* Range check */
+ if (index >= p_vector->size)
+ return (CL_INVALID_PARAMETER);
+
+ cl_vector_get(p_vector, index, p_element);
+ return (CL_SUCCESS);
+}
+
+cl_status_t cl_vector_set(IN cl_vector_t * const p_vector,
+ IN const size_t index, IN void *const p_element)
+{
+ cl_status_t status;
+ void *p_dest;
+
+ CL_ASSERT(p_vector);
+ CL_ASSERT(p_vector->state == CL_INITIALIZED);
+ CL_ASSERT(p_element);
+
+ /* Determine if the vector has room for this element. */
+ if (index >= p_vector->size) {
+ /* Resize to accomodate the given index. */
+ status = cl_vector_set_size(p_vector, index + 1);
+
+ /* Check for failure on or before the given index. */
+ if ((status != CL_SUCCESS) && (p_vector->size < index))
+ return (status);
+ }
+
+ /* At this point, the array is guaranteed to be big enough */
+ p_dest = cl_vector_get_ptr(p_vector, index);
+ /* Sanity check! */
+ CL_ASSERT(p_dest);
+
+ /* Copy the data into the array */
+ p_vector->pfn_copy(p_dest, p_element, p_vector->element_size);
+
+ return (CL_SUCCESS);
+}
+
+cl_status_t cl_vector_set_capacity(IN cl_vector_t * const p_vector,
+ IN const size_t new_capacity)
+{
+ size_t new_elements;
+ size_t alloc_size;
+ size_t i;
+ cl_list_item_t *p_buf;
+ void *p_new_ptr_array;
+
+ CL_ASSERT(p_vector);
+ CL_ASSERT(p_vector->state == CL_INITIALIZED);
+
+ /* Do we have to do anything here? */
+ if (new_capacity <= p_vector->capacity) {
+ /* Nope */
+ return (CL_SUCCESS);
+ }
+
+ /* Allocate our pointer array. */
+ p_new_ptr_array = malloc(new_capacity * sizeof(void *));
+ if (!p_new_ptr_array)
+ return (CL_INSUFFICIENT_MEMORY);
+ else
+ memset(p_new_ptr_array, 0, new_capacity * sizeof(void *));
+
+ if (p_vector->p_ptr_array) {
+ /* Copy the old pointer array into the new. */
+ memcpy(p_new_ptr_array, p_vector->p_ptr_array,
+ p_vector->capacity * sizeof(void *));
+
+ /* Free the old pointer array. */
+ free(p_vector->p_ptr_array);
+ }
+
+ /* Set the new array. */
+ p_vector->p_ptr_array = p_new_ptr_array;
+
+ /*
+ * We have to add capacity to the array. Determine how many
+ * elements to add.
+ */
+ new_elements = new_capacity - p_vector->capacity;
+ /* Determine the allocation size for the new array elements. */
+ alloc_size = new_elements * p_vector->element_size;
+
+ p_buf = (cl_list_item_t *) malloc(alloc_size + sizeof(cl_list_item_t));
+ if (!p_buf)
+ return (CL_INSUFFICIENT_MEMORY);
+ else
+ memset(p_buf, 0, alloc_size + sizeof(cl_list_item_t));
+
+ cl_qlist_insert_tail(&p_vector->alloc_list, p_buf);
+ /* Advance the buffer pointer past the list item. */
+ p_buf++;
+
+ for (i = p_vector->capacity; i < new_capacity; i++) {
+ p_vector->p_ptr_array[i] = p_buf;
+ /* Move the buffer pointer to the next element. */
+ p_buf = (void *)(((uint8_t *) p_buf) + p_vector->element_size);
+ }
+
+ /* Update the vector with the new capactity. */
+ p_vector->capacity = new_capacity;
+
+ return (CL_SUCCESS);
+}
+
+cl_status_t cl_vector_set_size(IN cl_vector_t * const p_vector,
+ IN const size_t size)
+{
+ cl_status_t status;
+ size_t new_capacity;
+ size_t index;
+ void *p_element;
+
+ CL_ASSERT(p_vector);
+ CL_ASSERT(p_vector->state == CL_INITIALIZED);
+
+ /* Check to see if the requested size is the same as the existing size. */
+ if (size == p_vector->size)
+ return (CL_SUCCESS);
+
+ /* Determine if the vector has room for this element. */
+ if (size >= p_vector->capacity) {
+ if (!p_vector->grow_size)
+ return (CL_INSUFFICIENT_MEMORY);
+
+ /* Calculate the new capacity, taking into account the grow size. */
+ new_capacity = size;
+ if (size % p_vector->grow_size) {
+ /* Round up to nearest grow_size boundary. */
+ new_capacity += p_vector->grow_size -
+ (size % p_vector->grow_size);
+ }
+
+ status = cl_vector_set_capacity(p_vector, new_capacity);
+ if (status != CL_SUCCESS)
+ return (status);
+ }
+
+ /* Are we growing the array and need to invoke an initializer callback? */
+ if (size > p_vector->size && p_vector->pfn_init) {
+ for (index = p_vector->size; index < size; index++) {
+ /* Get a pointer to this element */
+ p_element = cl_vector_get_ptr(p_vector, index);
+
+ /* Call the user's initializer and trap failures. */
+ status =
+ p_vector->pfn_init(p_element,
+ (void *)p_vector->context);
+ if (status != CL_SUCCESS) {
+ /* Call the destructor for this object */
+ if (p_vector->pfn_dtor)
+ p_vector->pfn_dtor(p_element,
+ (void *)p_vector->
+ context);
+
+ /* Return the failure status to the caller. */
+ return (status);
+ }
+
+ /* The array just grew by one element */
+ p_vector->size++;
+ }
+ } else if (p_vector->pfn_dtor) {
+ /* The array is shrinking and there is a destructor to invoke. */
+ for (index = size; index < p_vector->size; index++) {
+ /* compute the address of the new elements */
+ p_element = cl_vector_get_ptr(p_vector, index);
+ /* call the user's destructor */
+ p_vector->pfn_dtor(p_element,
+ (void *)p_vector->context);
+ }
+ }
+
+ p_vector->size = size;
+ return (CL_SUCCESS);
+}
+
+cl_status_t cl_vector_set_min_size(IN cl_vector_t * const p_vector,
+ IN const size_t min_size)
+{
+ CL_ASSERT(p_vector);
+ CL_ASSERT(p_vector->state == CL_INITIALIZED);
+
+ if (min_size > p_vector->size) {
+ /* We have to resize the array */
+ return (cl_vector_set_size(p_vector, min_size));
+ }
+
+ /* We didn't have to do anything */
+ return (CL_SUCCESS);
+}
+
+void cl_vector_apply_func(IN const cl_vector_t * const p_vector,
+ IN cl_pfn_vec_apply_t pfn_callback,
+ IN const void *const context)
+{
+ size_t i;
+ void *p_element;
+
+ CL_ASSERT(p_vector);
+ CL_ASSERT(p_vector->state == CL_INITIALIZED);
+ CL_ASSERT(pfn_callback);
+
+ for (i = 0; i < p_vector->size; i++) {
+ p_element = cl_vector_get_ptr(p_vector, i);
+ pfn_callback(i, p_element, (void *)context);
+ }
+}
+
+size_t cl_vector_find_from_start(IN const cl_vector_t * const p_vector,
+ IN cl_pfn_vec_find_t pfn_callback,
+ IN const void *const context)
+{
+ size_t i;
+ void *p_element;
+
+ CL_ASSERT(p_vector);
+ CL_ASSERT(p_vector->state == CL_INITIALIZED);
+ CL_ASSERT(pfn_callback);
+
+ for (i = 0; i < p_vector->size; i++) {
+ p_element = cl_vector_get_ptr(p_vector, i);
+ /* Invoke the callback */
+ if (pfn_callback(i, p_element, (void *)context) == CL_SUCCESS)
+ break;
+ }
+ return (i);
+}
+
+size_t cl_vector_find_from_end(IN const cl_vector_t * const p_vector,
+ IN cl_pfn_vec_find_t pfn_callback,
+ IN const void *const context)
+{
+ size_t i;
+ void *p_element;
+
+ CL_ASSERT(p_vector);
+ CL_ASSERT(p_vector->state == CL_INITIALIZED);
+ CL_ASSERT(pfn_callback);
+
+ i = p_vector->size;
+
+ while (i) {
+ /* Get a pointer to the element in the array. */
+ p_element = cl_vector_get_ptr(p_vector, --i);
+ CL_ASSERT(p_element);
+
+ /* Invoke the callback for the current element. */
+ if (pfn_callback(i, p_element, (void *)context) == CL_SUCCESS)
+ return (i);
+ }
+
+ return (p_vector->size);
+}
diff --git a/contrib/ofed/management/opensm/complib/ib_statustext.c b/contrib/ofed/opensm/complib/ib_statustext.c
index 52b2adc..52b2adc 100644
--- a/contrib/ofed/management/opensm/complib/ib_statustext.c
+++ b/contrib/ofed/opensm/complib/ib_statustext.c
diff --git a/contrib/ofed/opensm/complib/libosmcomp.map b/contrib/ofed/opensm/complib/libosmcomp.map
new file mode 100644
index 0000000..52410cc
--- /dev/null
+++ b/contrib/ofed/opensm/complib/libosmcomp.map
@@ -0,0 +1,155 @@
+OSMCOMP_2.3 {
+ global:
+ complib_init;
+ complib_exit;
+ cl_is_debug;
+ cl_disp_construct;
+ cl_disp_init;
+ cl_disp_destroy;
+ cl_disp_register;
+ cl_disp_unregister;
+ cl_disp_post;
+ cl_disp_shutdown;
+ cl_disp_get_queue_status;
+ cl_event_construct;
+ cl_event_init;
+ cl_event_destroy;
+ cl_event_signal;
+ cl_event_reset;
+ cl_event_wait_on;
+ cl_event_wheel_construct;
+ cl_event_wheel_init;
+ cl_event_wheel_init_ex;
+ cl_event_wheel_destroy;
+ cl_event_wheel_dump;
+ cl_event_wheel_reg;
+ cl_event_wheel_unreg;
+ cl_event_wheel_num_regs;
+ cl_qlist_insert_array_head;
+ cl_qlist_insert_array_tail;
+ cl_qlist_insert_list_head;
+ cl_qlist_insert_list_tail;
+ cl_is_item_in_qlist;
+ cl_qlist_find_next;
+ cl_qlist_find_prev;
+ cl_qlist_apply_func;
+ cl_qlist_move_items;
+ cl_list_construct;
+ cl_list_init;
+ cl_list_destroy;
+ cl_list_remove_object;
+ cl_is_object_in_list;
+ cl_list_insert_array_head;
+ cl_list_insert_array_tail;
+ cl_list_find_from_head;
+ cl_list_find_from_tail;
+ cl_list_apply_func;
+ cl_log_event;
+ cl_qmap_init;
+ cl_qmap_get;
+ cl_qmap_get_next;
+ cl_qmap_apply_func;
+ cl_qmap_insert;
+ cl_qmap_remove_item;
+ cl_qmap_remove;
+ cl_qmap_merge;
+ cl_qmap_delta;
+ cl_map_construct;
+ cl_map_init;
+ cl_map_destroy;
+ cl_map_insert;
+ cl_map_get;
+ cl_map_get_next;
+ cl_map_remove_item;
+ cl_map_remove;
+ cl_map_remove_all;
+ cl_map_merge;
+ cl_map_delta;
+ cl_fmap_init;
+ cl_fmap_match;
+ cl_fmap_get;
+ cl_fmap_get_next;
+ cl_fmap_apply_func;
+ cl_fmap_insert;
+ cl_fmap_remove_item;
+ cl_fmap_remove;
+ cl_fmap_merge;
+ cl_fmap_delta;
+ cl_qcpool_construct;
+ cl_qcpool_init;
+ cl_qcpool_destroy;
+ cl_qcpool_grow;
+ cl_qcpool_get;
+ cl_qcpool_get_tail;
+ cl_qpool_construct;
+ cl_qpool_init;
+ cl_cpool_construct;
+ cl_cpool_init;
+ cl_pool_construct;
+ cl_pool_init;
+ cl_ptr_vector_construct;
+ cl_ptr_vector_init;
+ cl_ptr_vector_destroy;
+ cl_ptr_vector_at;
+ cl_ptr_vector_set;
+ cl_ptr_vector_remove;
+ cl_ptr_vector_set_capacity;
+ cl_ptr_vector_set_size;
+ cl_ptr_vector_set_min_size;
+ cl_ptr_vector_apply_func;
+ cl_ptr_vector_find_from_start;
+ cl_ptr_vector_find_from_end;
+ cl_spinlock_construct;
+ cl_spinlock_init;
+ cl_spinlock_destroy;
+ cl_spinlock_acquire;
+ cl_spinlock_release;
+ cl_status_text;
+ cl_thread_construct;
+ cl_thread_init;
+ cl_thread_destroy;
+ cl_thread_suspend;
+ cl_thread_stall;
+ cl_proc_count;
+ cl_is_current_thread;
+ cl_thread_pool_construct;
+ cl_thread_pool_init;
+ cl_thread_pool_destroy;
+ cl_thread_pool_signal;
+ __cl_timer_prov_create;
+ __cl_timer_prov_destroy;
+ cl_timer_construct;
+ cl_timer_init;
+ cl_timer_destroy;
+ cl_timer_start;
+ cl_timer_stop;
+ cl_timer_trim;
+ cl_get_time_stamp;
+ cl_get_time_stamp_sec;
+ cl_vector_copy_general;
+ cl_vector_copy16;
+ cl_vector_copy32;
+ cl_vector_copy64;
+ cl_vector_construct;
+ cl_vector_init;
+ cl_vector_destroy;
+ cl_vector_at;
+ cl_vector_set;
+ cl_vector_set_capacity;
+ cl_vector_set_size;
+ cl_vector_set_min_size;
+ cl_vector_apply_func;
+ cl_vector_find_from_start;
+ cl_vector_find_from_end;
+ cl_atomic_spinlock;
+ cl_atomic_dec;
+ ib_error_str;
+ ib_async_event_str;
+ ib_wc_status_str;
+ open_node_name_map;
+ close_node_name_map;
+ parse_node_map;
+ remap_node_name;
+ clean_nodedesc;
+ local: *;
+};
diff --git a/contrib/ofed/opensm/complib/libosmcomp.ver b/contrib/ofed/opensm/complib/libosmcomp.ver
new file mode 100644
index 0000000..753ed84
--- /dev/null
+++ b/contrib/ofed/opensm/complib/libosmcomp.ver
@@ -0,0 +1,9 @@
+# In this file we track the current API version
+# of the complib library interface
+# The version is built of the following
+# tree numbers:
+# API_REV:RUNNING_REV:AGE
+# API_REV - advance on any added API
+# RUNNING_REV - advance any change to the vendor files
+# AGE - number of backward versions the API still supports
+LIBVERSION=3:10:0
diff --git a/contrib/ofed/opensm/config.h b/contrib/ofed/opensm/config.h
new file mode 100644
index 0000000..ebeb6af
--- /dev/null
+++ b/contrib/ofed/opensm/config.h
@@ -0,0 +1,165 @@
+/* $FreeBSD$ */
+
+/* Define as 1 if you want Dual Sided RMPP Support */
+#define DUAL_SIDED_RMPP 1
+
+/* Define as 1 if you want to enable a loopback console */
+#define ENABLE_OSM_CONSOLE_LOOPBACK 1
+
+/* Define as 1 if you want to enable a console on a socket connection */
+/* #undef ENABLE_OSM_CONSOLE_SOCKET */
+
+/* Define as 1 if you want to enable the event plugin */
+/* #undef ENABLE_OSM_DEFAULT_EVENT_PLUGIN */
+
+/* Define as 1 if you want to enable the performance manager */
+#define ENABLE_OSM_PERF_MGR 1
+
+/* Define as 1 if you want to enable the performance manager profiling code */
+/* #undef ENABLE_OSM_PERF_MGR_PROFILE */
+
+/* Define to 1 if the compiler supports __builtin_expect. */
+#define HAVE_BUILTIN_EXPECT 1
+
+/* Define a default node name map file */
+#define HAVE_DEFAULT_NODENAME_MAP "/etc/opensm/ib-node-name-map"
+
+/* Define a default OpenSM config file */
+#define HAVE_DEFAULT_OPENSM_CONFIG_FILE "/etc/opensm/opensm.conf"
+
+/* Define a Partition config file */
+#define HAVE_DEFAULT_PARTITION_CONFIG_FILE "/etc/opensm/partitions.conf"
+
+/* Define a Per Module Logging config file */
+#define HAVE_DEFAULT_PER_MOD_LOGGING_FILE "/etc/opensm/per-module-logging.conf"
+
+/* Define a Prefix Routes config file */
+#define HAVE_DEFAULT_PREFIX_ROUTES_FILE "/etc/opensm/prefix-routes.conf"
+
+/* Define a QOS policy config file */
+#define HAVE_DEFAULT_QOS_POLICY_FILE "/etc/opensm/qos-policy.conf"
+
+/* Define to 1 if you have the <dlfcn.h> header file. */
+#define HAVE_DLFCN_H 1
+
+/* Define to 1 if you have the <inttypes.h> header file. */
+#define HAVE_INTTYPES_H 1
+
+/* Define to 1 if you have the `ibumad' library (-libumad). */
+#define HAVE_LIBIBUMAD 1
+
+/* Define to 1 if you have the `pthread' library (-lpthread). */
+#define HAVE_LIBPTHREAD 1
+
+/* Define to 1 if you have the `vapi' library (-lvapi). */
+/* #undef HAVE_LIBVAPI */
+
+/* Define to 1 if you have the `wrap' library (-lwrap). */
+#define HAVE_LIBWRAP 1
+
+/* Define to 1 if you have the <memory.h> header file. */
+#define HAVE_MEMORY_H 1
+
+/* Define to 1 if you have the <stdint.h> header file. */
+#define HAVE_STDINT_H 1
+
+/* Define to 1 if you have the <stdlib.h> header file. */
+#define HAVE_STDLIB_H 1
+
+/* Define to 1 if you have the <strings.h> header file. */
+#define HAVE_STRINGS_H 1
+
+/* Define to 1 if you have the <string.h> header file. */
+#define HAVE_STRING_H 1
+
+/* Define to 1 if you have the <sys/stat.h> header file. */
+#define HAVE_SYS_STAT_H 1
+
+/* Define to 1 if you have the <sys/types.h> header file. */
+#define HAVE_SYS_TYPES_H 1
+
+/* Define to 1 if you have the <unistd.h> header file. */
+#define HAVE_UNISTD_H 1
+
+/* Define OpenSM config directory */
+#define OPENSM_CONFIG_DIR "/etc/opensm"
+
+/* define 1 if OpenSM build is in a debug mode */
+/* #undef OSM_DEBUG */
+
+/* Define as 1 for vapi vendor */
+/* #undef OSM_VENDOR_INTF_MTL */
+
+/* Define as 1 for OpenIB vendor */
+#define OSM_VENDOR_INTF_OPENIB 1
+
+/* Define as 1 for sim vendor */
+/* #undef OSM_VENDOR_INTF_SIM */
+
+/* Define as 1 for ts vendor */
+/* #undef OSM_VENDOR_INTF_TS */
+
+/* Name of package */
+#define PACKAGE "opensm"
+
+/* Define to the address where bug reports for this package should be sent. */
+#define PACKAGE_BUGREPORT "linux-rdma@vger.kernel.org"
+
+/* Define to the full name of this package. */
+#define PACKAGE_NAME "opensm"
+
+/* Define to the full name and version of this package. */
+#define PACKAGE_STRING "opensm 3.3.20"
+
+/* Define to the one symbol short name of this package. */
+#define PACKAGE_TARNAME "opensm"
+
+/* Define to the home page for this package. */
+#define PACKAGE_URL ""
+
+/* Define to the version of this package. */
+#define PACKAGE_VERSION "3.3.20"
+
+/* Define to 1 if you have the ANSI C header files. */
+#define STDC_HEADERS 1
+
+/* Define to 1 if you can safely include both <sys/time.h> and <time.h>. */
+#define TIME_WITH_SYS_TIME 1
+
+/* Define to 1 if your <sys/time.h> declares `struct tm'. */
+/* #undef TM_IN_SYS_TIME */
+
+/* Define as 1 if you want Vendor RMPP Support */
+#define VENDOR_RMPP_SUPPORT 1
+
+/* Version number of package */
+#define VERSION "3.3.20"
+
+/* Define to 1 if `lex' declares `yytext' as a `char *' by default, not a
+ `char[]'. */
+#define YYTEXT_POINTER 1
+
+/* define 1 if OpenSM build is in a debug mode */
+/* #undef _DEBUG_ */
+
+/* mark config.h inclusion */
+#define _OSM_CONFIG_H_ 1
+
+/* Define to empty if `const' does not conform to ANSI C. */
+/* #undef const */
+
+/* Define to `__inline__' or `__inline' if that's what the C compiler
+ calls it, or to nothing if 'inline' is not supported under any name. */
+#ifndef __cplusplus
+/* #undef inline */
+#endif
+
+/* Define to `int' if <sys/types.h> does not define. */
+/* #undef pid_t */
+
+/* Define to `unsigned int' if <sys/types.h> does not define. */
+/* #undef size_t */
+
+/* Define to empty if the keyword `volatile' does not work. Warning: valid
+ code using `volatile' can become incorrect without. Disable with care. */
+/* #undef volatile */
diff --git a/contrib/ofed/opensm/include/complib/cl_atomic.h b/contrib/ofed/opensm/include/complib/cl_atomic.h
new file mode 100644
index 0000000..ba21442
--- /dev/null
+++ b/contrib/ofed/opensm/include/complib/cl_atomic.h
@@ -0,0 +1,192 @@
+/*
+ * Copyright (c) 2004-2006 Voltaire, Inc. All rights reserved.
+ * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved.
+ * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+/*
+ * Abstract:
+ * Declaration of atomic manipulation functions.
+ */
+
+#ifndef _CL_ATOMIC_H_
+#define _CL_ATOMIC_H_
+
+#include <complib/cl_atomic_osd.h>
+
+#ifdef __cplusplus
+# define BEGIN_C_DECLS extern "C" {
+# define END_C_DECLS }
+#else /* !__cplusplus */
+# define BEGIN_C_DECLS
+# define END_C_DECLS
+#endif /* __cplusplus */
+
+BEGIN_C_DECLS
+/****h* Component Library/Atomic Operations
+* NAME
+* Atomic Operations
+*
+* DESCRIPTION
+* The Atomic Operations functions allow callers to operate on
+* 32-bit signed integers in an atomic fashion.
+*********/
+/****f* Component Library: Atomic Operations/cl_atomic_inc
+* NAME
+* cl_atomic_inc
+*
+* DESCRIPTION
+* The cl_atomic_inc function atomically increments a 32-bit signed
+* integer and returns the incremented value.
+*
+* SYNOPSIS
+*/
+int32_t cl_atomic_inc(IN atomic32_t * const p_value);
+/*
+* PARAMETERS
+* p_value
+* [in] Pointer to a 32-bit integer to increment.
+*
+* RETURN VALUE
+* Returns the incremented value pointed to by p_value.
+*
+* NOTES
+* The provided value is incremented and its value returned in one atomic
+* operation.
+*
+* cl_atomic_inc maintains data consistency without requiring additional
+* synchronization mechanisms in multi-threaded environments.
+*
+* SEE ALSO
+* Atomic Operations, cl_atomic_dec, cl_atomic_add, cl_atomic_sub
+*********/
+
+/****f* Component Library: Atomic Operations/cl_atomic_dec
+* NAME
+* cl_atomic_dec
+*
+* DESCRIPTION
+* The cl_atomic_dec function atomically decrements a 32-bit signed
+* integer and returns the decremented value.
+*
+* SYNOPSIS
+*/
+int32_t cl_atomic_dec(IN atomic32_t * const p_value);
+/*
+* PARAMETERS
+* p_value
+* [in] Pointer to a 32-bit integer to decrement.
+*
+* RETURN VALUE
+* Returns the decremented value pointed to by p_value.
+*
+* NOTES
+* The provided value is decremented and its value returned in one atomic
+* operation.
+*
+* cl_atomic_dec maintains data consistency without requiring additional
+* synchronization mechanisms in multi-threaded environments.
+*
+* SEE ALSO
+* Atomic Operations, cl_atomic_inc, cl_atomic_add, cl_atomic_sub
+*********/
+
+/****f* Component Library: Atomic Operations/cl_atomic_add
+* NAME
+* cl_atomic_add
+*
+* DESCRIPTION
+* The cl_atomic_add function atomically adds a value to a
+* 32-bit signed integer and returns the resulting value.
+*
+* SYNOPSIS
+*/
+int32_t
+cl_atomic_add(IN atomic32_t * const p_value, IN const int32_t increment);
+/*
+* PARAMETERS
+* p_value
+* [in] Pointer to a 32-bit integer that will be added to.
+*
+* increment
+* [in] Value by which to increment the integer pointed to by p_value.
+*
+* RETURN VALUE
+* Returns the value pointed to by p_value after the addition.
+*
+* NOTES
+* The provided increment is added to the value and the result returned in
+* one atomic operation.
+*
+* cl_atomic_add maintains data consistency without requiring additional
+* synchronization mechanisms in multi-threaded environments.
+*
+* SEE ALSO
+* Atomic Operations, cl_atomic_inc, cl_atomic_dec, cl_atomic_sub
+*********/
+
+/****f* Component Library: Atomic Operations/cl_atomic_sub
+* NAME
+* cl_atomic_sub
+*
+* DESCRIPTION
+* The cl_atomic_sub function atomically subtracts a value from a
+* 32-bit signed integer and returns the resulting value.
+*
+* SYNOPSIS
+*/
+int32_t
+cl_atomic_sub(IN atomic32_t * const p_value, IN const int32_t decrement);
+/*
+* PARAMETERS
+* p_value
+* [in] Pointer to a 32-bit integer that will be subtracted from.
+*
+* decrement
+* [in] Value by which to decrement the integer pointed to by p_value.
+*
+* RETURN VALUE
+* Returns the value pointed to by p_value after the subtraction.
+*
+* NOTES
+* The provided decrement is subtracted from the value and the result
+* returned in one atomic operation.
+*
+* cl_atomic_sub maintains data consistency without requiring additional
+* synchronization mechanisms in multi-threaded environments.
+*
+* SEE ALSO
+* Atomic Operations, cl_atomic_inc, cl_atomic_dec, cl_atomic_add
+*********/
+
+END_C_DECLS
+#endif /* _CL_ATOMIC_H_ */
diff --git a/contrib/ofed/opensm/include/complib/cl_atomic_osd.h b/contrib/ofed/opensm/include/complib/cl_atomic_osd.h
new file mode 100644
index 0000000..822c19d
--- /dev/null
+++ b/contrib/ofed/opensm/include/complib/cl_atomic_osd.h
@@ -0,0 +1,106 @@
+/*
+ * Copyright (c) 2004-2006 Voltaire, Inc. All rights reserved.
+ * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved.
+ * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+/*
+ * Abstract:
+ * Implementation specific header files for atomic operations.
+ */
+
+#ifndef _CL_ATOMIC_OSD_H_
+#define _CL_ATOMIC_OSD_H_
+
+#include <complib/cl_types.h>
+#include <complib/cl_spinlock.h>
+
+#ifdef __cplusplus
+# define BEGIN_C_DECLS extern "C" {
+# define END_C_DECLS }
+#else /* !__cplusplus */
+# define BEGIN_C_DECLS
+# define END_C_DECLS
+#endif /* __cplusplus */
+
+BEGIN_C_DECLS
+
+extern cl_spinlock_t cl_atomic_spinlock;
+
+static inline int32_t cl_atomic_inc(IN atomic32_t * const p_value)
+{
+ int32_t new_val;
+
+ cl_spinlock_acquire(&cl_atomic_spinlock);
+ new_val = *p_value + 1;
+ *p_value = new_val;
+ cl_spinlock_release(&cl_atomic_spinlock);
+ return (new_val);
+}
+
+static inline int32_t cl_atomic_dec(IN atomic32_t * const p_value)
+{
+ int32_t new_val;
+
+ cl_spinlock_acquire(&cl_atomic_spinlock);
+ new_val = *p_value - 1;
+ *p_value = new_val;
+ cl_spinlock_release(&cl_atomic_spinlock);
+ return (new_val);
+}
+
+static inline int32_t
+cl_atomic_add(IN atomic32_t * const p_value, IN const int32_t increment)
+{
+ int32_t new_val;
+
+ cl_spinlock_acquire(&cl_atomic_spinlock);
+ new_val = *p_value + increment;
+ *p_value = new_val;
+ cl_spinlock_release(&cl_atomic_spinlock);
+ return (new_val);
+}
+
+static inline int32_t
+cl_atomic_sub(IN atomic32_t * const p_value, IN const int32_t decrement)
+{
+ int32_t new_val;
+
+ cl_spinlock_acquire(&cl_atomic_spinlock);
+ new_val = *p_value - decrement;
+ *p_value = new_val;
+ cl_spinlock_release(&cl_atomic_spinlock);
+ return (new_val);
+}
+
+END_C_DECLS
+#endif /* _CL_ATOMIC_OSD_H_ */
diff --git a/contrib/ofed/opensm/include/complib/cl_byteswap.h b/contrib/ofed/opensm/include/complib/cl_byteswap.h
new file mode 100644
index 0000000..bef24b0
--- /dev/null
+++ b/contrib/ofed/opensm/include/complib/cl_byteswap.h
@@ -0,0 +1,524 @@
+/*
+ * Copyright (c) 2004-2006 Voltaire, Inc. All rights reserved.
+ * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved.
+ * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+/*
+ * Abstract:
+ * provides byteswapping utilities. Basic functions are obtained from
+ * platform specific implementations from byteswap_osd.h.
+ */
+
+#ifndef _CL_BYTESWAP_H_
+#define _CL_BYTESWAP_H_
+
+#include <string.h>
+#include <complib/cl_byteswap_osd.h>
+
+#ifdef __cplusplus
+# define BEGIN_C_DECLS extern "C" {
+# define END_C_DECLS }
+#else /* !__cplusplus */
+# define BEGIN_C_DECLS
+# define END_C_DECLS
+#endif /* __cplusplus */
+
+BEGIN_C_DECLS
+/****h* Component Library/Byte Swapping
+* NAME
+* Byte Swapping
+*
+* DESCRIPTION
+* The byte swapping functions and macros allow swapping bytes from network
+* byte order to host byte order.
+*
+* All data transmitted between systems should be in network byte order.
+* In order to utilize such data, it must be converted to host byte order
+* before use.
+*
+* SEE ALSO
+* Functions:
+* cl_ntoh16, cl_hton16, cl_ntoh32, cl_hton32, cl_ntoh64, cl_hton64,
+* cl_ntoh
+*
+* Macros:
+* CL_NTOH16, CL_HTON16, CL_NTOH32, CL_HTON32, CL_NTOH64, CL_HTON64
+*********/
+/*
+ * The byteswap_osd.h provides the following macros.
+ * __LITTLE_ENDIAN
+ * __BIG_ENDIAN
+ * __BYTE_ORDER
+ *
+ * If the platform provides byte swapping functions, byteswap_osd.h also
+ * provides the following macros.
+ * ntoh16, hton16
+ * ntoh32, hton32
+ * ntoh64, hton64
+ */
+#ifndef __BYTE_ORDER
+#error "__BYTE_ORDER macro undefined. Missing in endian.h?"
+#endif
+#if __BYTE_ORDER == __LITTLE_ENDIAN
+#define CPU_LE 1
+#define CPU_BE 0
+#else
+#define CPU_LE 0
+#define CPU_BE 1
+#endif
+/****d* Component Library: Byte Swapping/CL_NTOH16
+* NAME
+* CL_NTOH16
+*
+* DESCRIPTION
+* The CL_NTOH16 macro converts a 16-bit value from network byte order to
+* host byte order. The CL_NTOH16 macro will cause constant values to be
+* swapped by the pre-processor. For variables, CL_NTOH16 is less efficient
+* than the cl_ntoh16 function.
+*
+* SYNOPSIS
+* CL_NTOH16( val );
+*
+* PARAMETERS
+* val
+* [in] 16-bit value to swap from network byte order to host byte order.
+*
+* RESULT
+* Value of val converted to host byte order.
+*
+* NOTES
+* This macro is analogous to CL_HTON16.
+*
+* SEE ALSO
+* Byte Swapping, CL_HTON16, CL_NTOH32, CL_NTOH64,
+* cl_ntoh16, cl_ntoh32, cl_ntoh64, cl_ntoh
+*********/
+/****d* Component Library: Byte Swapping/CL_HTON16
+* NAME
+* CL_HTON16
+*
+* DESCRIPTION
+* The CL_HTON16 macro converts a 16-bit value from host byte order to
+* network byte order. The CL_HTON16 macro will cause constant values to be
+* swapped by the pre-processor. For variables, CL_HTON16 is less efficient
+* than the cl_hton16 function.
+*
+* SYNOPSIS
+* CL_HTON16( val );
+*
+* PARAMETERS
+* val
+* [in] 16-bit value to swap from host byte order to network byte order.
+*
+* RESULT
+* Value of val converted to network byte order.
+*
+* NOTES
+* This macro is analogous to CL_NTOH16.
+*
+* SEE ALSO
+* Byte Swapping, CL_NTOH16, CL_HTON32, CL_HTON64,
+* cl_hton16, cl_hton32, cl_hton64, cl_ntoh
+*********/
+#if CPU_LE
+#define CL_NTOH16( x ) (uint16_t)( \
+ (((uint16_t)(x) & 0x00FF) << 8) | \
+ (((uint16_t)(x) & 0xFF00) >> 8) )
+#else
+#define CL_NTOH16( x ) (x)
+#endif
+#define CL_HTON16 CL_NTOH16
+/****f* Component Library: Byte Swapping/cl_ntoh16
+* NAME
+* cl_ntoh16
+*
+* DESCRIPTION
+* The cl_ntoh16 function converts a 16-bit value from network byte order to
+* host byte order.
+*
+* SYNOPSIS
+* uint16_t
+* cl_ntoh16(
+* IN const uint16_t val );
+*
+* PARAMETERS
+* val
+* [in] Value to swap from network byte order to host byte order.
+*
+* RETURN VALUE
+* Value of val converted to host byte order.
+*
+* NOTES
+* This function is analogous to cl_hton16.
+*
+* SEE ALSO
+* Byte Swapping, cl_hton16, cl_ntoh32, cl_ntoh64, cl_ntoh
+*********/
+/****f* Component Library: Byte Swapping/cl_hton16
+* NAME
+* cl_hton16
+*
+* DESCRIPTION
+* The cl_hton16 function converts a 16-bit value from host byte order to
+* network byte order.
+*
+* SYNOPSIS
+* uint16_t
+* cl_hton16(
+* IN const uint16_t val );
+*
+* PARAMETERS
+* val
+* [in] Value to swap from host byte order to network byte order .
+*
+* RETURN VALUE
+* Value of val converted to network byte order.
+*
+* NOTES
+* This function is analogous to cl_ntoh16.
+*
+* SEE ALSO
+* Byte Swapping, cl_ntoh16, cl_hton32, cl_hton64, cl_ntoh
+*********/
+#ifndef cl_ntoh16
+#define cl_ntoh16 CL_NTOH16
+#define cl_hton16 CL_HTON16
+#endif
+/****d* Component Library: Byte Swapping/CL_NTOH32
+* NAME
+* CL_NTOH32
+*
+* DESCRIPTION
+* The CL_NTOH32 macro converts a 32-bit value from network byte order to
+* host byte order. The CL_NTOH32 macro will cause constant values to be
+* swapped by the pre-processor. For variables, CL_NTOH32 is less efficient
+* than the cl_ntoh32 function.
+*
+* SYNOPSIS
+* CL_NTOH32( val );
+*
+* PARAMETERS
+* val
+* [in] 32-bit value to swap from network byte order to host byte order.
+*
+* RESULT
+* Value of val converted to host byte order.
+*
+* NOTES
+* This macro is analogous to CL_HTON32.
+*
+* SEE ALSO
+* Byte Swapping, CL_HTON32, CL_NTOH16, CL_NTOH64,
+* cl_ntoh16, cl_ntoh32, cl_ntoh64, cl_ntoh
+*********/
+/****d* Component Library: Byte Swapping/CL_HTON32
+* NAME
+* CL_HTON32
+*
+* DESCRIPTION
+* The CL_HTON32 macro converts a 32-bit value from host byte order to
+* network byte order. The CL_HTON32 macro will cause constant values to be
+* swapped by the pre-processor. For variables, CL_HTON32 is less efficient
+* than the cl_hton32 function.
+*
+* SYNOPSIS
+* CL_HTON32( val );
+*
+* PARAMETERS
+* val
+* [in] 32-bit value to swap from host byte order to network byte order.
+*
+* RESULT
+* Value of val converted to network byte order.
+*
+* NOTES
+* This macro is analogous to CL_NTOH32.
+*
+* SEE ALSO
+* Byte Swapping, CL_NTOH32, CL_HTON16, CL_HTON64,
+* cl_hton16, cl_hton32, cl_hton64, cl_ntoh
+*********/
+#if CPU_LE
+#define CL_NTOH32( x ) (uint32_t)( \
+ (((uint32_t)(x) & 0x000000FF) << 24) | \
+ (((uint32_t)(x) & 0x0000FF00) << 8) | \
+ (((uint32_t)(x) & 0x00FF0000) >> 8) | \
+ (((uint32_t)(x) & 0xFF000000) >> 24) )
+#else
+#define CL_NTOH32( x ) (x)
+#endif
+#define CL_HTON32 CL_NTOH32
+/****f* Component Library: Byte Swapping/cl_ntoh32
+* NAME
+* cl_ntoh32
+*
+* DESCRIPTION
+* The cl_ntoh32 function converts a 32-bit value from network byte order to
+* host byte order.
+*
+* SYNOPSIS
+* uint32_t
+* cl_ntoh32(
+* IN const uint32_t val );
+*
+* PARAMETERS
+* val
+* [in] Value to swap from network byte order to host byte order.
+*
+* RETURN VALUE
+* Value of val converted in host byte order.
+*
+* NOTES
+* This function is analogous to cl_hton32.
+*
+* SEE ALSO
+* Byte Swapping, cl_hton32, cl_ntoh16, cl_ntoh64, cl_ntoh
+*********/
+/****f* Component Library: Byte Swapping/cl_hton32
+* NAME
+* cl_hton32
+*
+* DESCRIPTION
+* The cl_hton32 function converts a 32-bit value from host byte order to
+* network byte order.
+*
+* SYNOPSIS
+* uint32_t
+* cl_hton32(
+* IN const uint32_t val );
+*
+* PARAMETERS
+* val
+* [in] Value to swap from host byte order to network byte order .
+*
+* RETURN VALUE
+* Value of val converted to network byte order.
+*
+* NOTES
+* This function is analogous to cl_ntoh32.
+*
+* SEE ALSO
+* Byte Swapping, cl_ntoh32, cl_hton16, cl_hton64, cl_ntoh
+*********/
+#ifndef cl_ntoh32
+#define cl_ntoh32 CL_NTOH32
+#define cl_hton32 CL_HTON32
+#endif
+/****d* Component Library: Byte Swapping/CL_NTOH64
+* NAME
+* CL_NTOH64
+*
+* DESCRIPTION
+* The CL_NTOH64 macro converts a 64-bit value from network byte order to
+* host byte order. The CL_NTOH64 macro will cause constant values to be
+* swapped by the pre-processor. For variables, CL_NTOH64 is less efficient
+* than the cl_ntoh64 function.
+*
+* SYNOPSIS
+* CL_NTOH64( val );
+*
+* PARAMETERS
+* val
+* [in] 64-bit value to swap from network byte order to host byte order.
+*
+* RESULT
+* Value of val converted to host byte order.
+*
+* NOTES
+* This macro is analogous to CL_HTON64.
+*
+* SEE ALSO
+* Byte Swapping, CL_HTON64, CL_NTOH16, CL_NTOH32,
+* cl_ntoh16, cl_ntoh32, cl_ntoh64, cl_ntoh
+*********/
+/****d* Component Library: Byte Swapping/CL_HTON64
+* NAME
+* CL_HTON64
+*
+* DESCRIPTION
+* The CL_HTON64 macro converts a 64-bit value from host byte order to
+* network byte order. The CL_HTON64 macro will cause constant values to be
+* swapped by the pre-processor. For variables, CL_HTON64 is less efficient
+* than the cl_hton64 function.
+*
+* SYNOPSIS
+* CL_HTON64( val );
+*
+* PARAMETERS
+* val
+* [in] 64-bit value to swap from host byte order to network byte order.
+*
+* RESULT
+* Value of val converted to network byte order.
+*
+* NOTES
+* This macro is analogous to CL_NTOH64.
+*
+* SEE ALSO
+* Byte Swapping, CL_NTOH64, CL_HTON16, CL_HTON32,
+* cl_hton16, cl_hton32, cl_hton64, cl_ntoh
+*********/
+#if CPU_LE
+#define CL_NTOH64( x ) (uint64_t)( \
+ (((uint64_t)(x) & 0x00000000000000FFULL) << 56) | \
+ (((uint64_t)(x) & 0x000000000000FF00ULL) << 40) | \
+ (((uint64_t)(x) & 0x0000000000FF0000ULL) << 24) | \
+ (((uint64_t)(x) & 0x00000000FF000000ULL) << 8 ) | \
+ (((uint64_t)(x) & 0x000000FF00000000ULL) >> 8 ) | \
+ (((uint64_t)(x) & 0x0000FF0000000000ULL) >> 24) | \
+ (((uint64_t)(x) & 0x00FF000000000000ULL) >> 40) | \
+ (((uint64_t)(x) & 0xFF00000000000000ULL) >> 56) )
+#else
+#define CL_NTOH64( x ) (x)
+#endif
+#define CL_HTON64 CL_NTOH64
+/****f* Component Library: Byte Swapping/cl_ntoh64
+* NAME
+* cl_ntoh64
+*
+* DESCRIPTION
+* The cl_ntoh64 function converts a 64-bit value from network byte order to
+* host byte order.
+*
+* SYNOPSIS
+* uint64_t
+* cl_ntoh64(
+* IN const uint64_t val );
+*
+* PARAMETERS
+* val
+* [in] Value to swap from network byte order to host byte order.
+*
+* RETURN VALUE
+* Value of val converted in host byte order.
+*
+* NOTES
+* This function is analogous to cl_hton64.
+*
+* SEE ALSO
+* Byte Swapping, cl_hton64, cl_ntoh16, cl_ntoh32, cl_ntoh
+*********/
+/****f* Component Library: Byte Swapping/cl_hton64
+* NAME
+* cl_hton64
+*
+* DESCRIPTION
+* The cl_hton64 function converts a 64-bit value from host byte order to
+* network byte order.
+*
+* SYNOPSIS
+* uint64_t
+* cl_hton64(
+* IN const uint64_t val );
+*
+* PARAMETERS
+* val
+* [in] Value to swap from host byte order to network byte order .
+*
+* RETURN VALUE
+* Value of val converted to network byte order.
+*
+* NOTES
+* This function is analogous to cl_ntoh64.
+*
+* SEE ALSO
+* Byte Swapping, cl_ntoh64, cl_hton16, cl_hton32, cl_ntoh
+*********/
+#ifndef cl_ntoh64
+#define cl_ntoh64 CL_NTOH64
+#define cl_hton64 CL_HTON64
+#endif
+/****f* Component Library: Byte Swapping/cl_ntoh
+* NAME
+* cl_ntoh
+*
+* DESCRIPTION
+* The cl_ntoh function converts a value from network byte order to
+* host byte order.
+*
+* SYNOPSIS
+*/
+static inline void
+cl_ntoh(OUT char *const p_dest,
+ IN const char *const p_src, IN const uint8_t size)
+{
+#if CPU_LE
+ uint8_t i;
+ char temp;
+
+ if (p_src == p_dest) {
+ /* Swap in place if source and destination are the same. */
+ for (i = 0; i < size / 2; i++) {
+ temp = p_dest[i];
+ p_dest[i] = p_src[size - 1 - i];
+ p_dest[size - 1 - i] = temp;
+ }
+ } else {
+ for (i = 0; i < size; i++)
+ p_dest[i] = p_src[size - 1 - i];
+ }
+#else
+ /*
+ * If the source and destination are not the same, copy the source to
+ * the destination.
+ */
+ if (p_src != p_dest)
+ memcpy(p_dest, p_src, size);
+#endif
+}
+
+/*
+* PARAMETERS
+* p_dest
+* [in] Pointer to a byte array to contain the converted value of p_src.
+*
+* p_src
+* [in] Pointer to a byte array to be converted from network byte
+* ordering.
+*
+* size
+* [in] Number of bytes to swap.p_dest
+*
+* RETURN VALUE
+* This function does not return a value.
+*
+* NOTES
+* cl_ntoh can perform in place swapping if both p_src and p_dest point to
+* the same buffer.
+*
+* SEE ALSO
+* Byte Swapping, cl_ntoh16, cl_ntoh32, cl_ntoh64
+*********/
+
+END_C_DECLS
+#endif /* _CL_BYTESWAP_H_ */
diff --git a/contrib/ofed/opensm/include/complib/cl_byteswap_osd.h b/contrib/ofed/opensm/include/complib/cl_byteswap_osd.h
new file mode 100644
index 0000000..a32e82e
--- /dev/null
+++ b/contrib/ofed/opensm/include/complib/cl_byteswap_osd.h
@@ -0,0 +1,75 @@
+/*
+ * Copyright (c) 2004, 2005 Voltaire, Inc. All rights reserved.
+ * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved.
+ * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+/*
+ * Abstract:
+ * Provides common macros for dealing with byte swapping issues.
+ */
+
+#ifndef _CL_BYTESWAP_OSD_H_
+#define _CL_BYTESWAP_OSD_H_
+
+/*
+ * This provides defines __LITTLE_ENDIAN, __BIG_ENDIAN and __BYTE_ORDER
+ */
+#include <infiniband/endian.h>
+#include <infiniband/byteswap.h>
+
+#ifdef __cplusplus
+# define BEGIN_C_DECLS extern "C" {
+# define END_C_DECLS }
+#else /* !__cplusplus */
+# define BEGIN_C_DECLS
+# define END_C_DECLS
+#endif /* __cplusplus */
+
+BEGIN_C_DECLS
+#if __BYTE_ORDER == __LITTLE_ENDIAN
+#define cl_ntoh16(x) bswap_16(x)
+#define cl_hton16(x) bswap_16(x)
+#define cl_ntoh32(x) bswap_32(x)
+#define cl_hton32(x) bswap_32(x)
+#define cl_ntoh64(x) (uint64_t)bswap_64(x)
+#define cl_hton64(x) (uint64_t)bswap_64(x)
+#else /* Big Endian */
+#define cl_ntoh16(x) (x)
+#define cl_hton16(x) (x)
+#define cl_ntoh32(x) (x)
+#define cl_hton32(x) (x)
+#define cl_ntoh64(x) (x)
+#define cl_hton64(x) (x)
+#endif
+END_C_DECLS
+#endif /* _CL_BYTESWAP_OSD_H_ */
diff --git a/contrib/ofed/management/opensm/include/complib/cl_comppool.h b/contrib/ofed/opensm/include/complib/cl_comppool.h
index 503ae18..503ae18 100644
--- a/contrib/ofed/management/opensm/include/complib/cl_comppool.h
+++ b/contrib/ofed/opensm/include/complib/cl_comppool.h
diff --git a/contrib/ofed/management/opensm/include/complib/cl_debug.h b/contrib/ofed/opensm/include/complib/cl_debug.h
index 05e9769..05e9769 100644
--- a/contrib/ofed/management/opensm/include/complib/cl_debug.h
+++ b/contrib/ofed/opensm/include/complib/cl_debug.h
diff --git a/contrib/ofed/management/opensm/include/complib/cl_debug_osd.h b/contrib/ofed/opensm/include/complib/cl_debug_osd.h
index b61891b..b61891b 100644
--- a/contrib/ofed/management/opensm/include/complib/cl_debug_osd.h
+++ b/contrib/ofed/opensm/include/complib/cl_debug_osd.h
diff --git a/contrib/ofed/management/opensm/include/complib/cl_dispatcher.h b/contrib/ofed/opensm/include/complib/cl_dispatcher.h
index a5b4a28..a5b4a28 100644
--- a/contrib/ofed/management/opensm/include/complib/cl_dispatcher.h
+++ b/contrib/ofed/opensm/include/complib/cl_dispatcher.h
diff --git a/contrib/ofed/management/opensm/include/complib/cl_event.h b/contrib/ofed/opensm/include/complib/cl_event.h
index 10805fb..10805fb 100644
--- a/contrib/ofed/management/opensm/include/complib/cl_event.h
+++ b/contrib/ofed/opensm/include/complib/cl_event.h
diff --git a/contrib/ofed/management/opensm/include/complib/cl_event_osd.h b/contrib/ofed/opensm/include/complib/cl_event_osd.h
index 541ced0..541ced0 100644
--- a/contrib/ofed/management/opensm/include/complib/cl_event_osd.h
+++ b/contrib/ofed/opensm/include/complib/cl_event_osd.h
diff --git a/contrib/ofed/opensm/include/complib/cl_event_wheel.h b/contrib/ofed/opensm/include/complib/cl_event_wheel.h
new file mode 100644
index 0000000..4883353
--- /dev/null
+++ b/contrib/ofed/opensm/include/complib/cl_event_wheel.h
@@ -0,0 +1,457 @@
+/*
+ * Copyright (c) 2004, 2005 Voltaire, Inc. All rights reserved.
+ * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved.
+ * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+/*
+ * Abstract:
+ * Declaration of event wheel abstraction.
+ */
+
+#ifndef _CL_EVENT_WHEEL_H_
+#define _CL_EVENT_WHEEL_H_
+
+#include <complib/cl_atomic.h>
+#include <complib/cl_qlist.h>
+#include <complib/cl_qmap.h>
+#include <complib/cl_timer.h>
+#include <complib/cl_spinlock.h>
+
+#ifdef __cplusplus
+# define BEGIN_C_DECLS extern "C" {
+# define END_C_DECLS }
+#else /* !__cplusplus */
+# define BEGIN_C_DECLS
+# define END_C_DECLS
+#endif /* __cplusplus */
+
+BEGIN_C_DECLS
+/****h* Component Library/Event_Wheel
+* NAME
+* Event_Wheel
+*
+* DESCRIPTION
+* The Event_Wheel provides a facility for registering delayed events
+* and getting called once they timeout.
+*
+* The Event_Wheel functions operate on a cl_event_wheel_t structure
+* which should be treated as opaque and should be manipulated
+* only through the provided functions.
+*
+* SEE ALSO
+* Structures:
+* cl_event_wheel_t
+*
+* Initialization/Destruction:
+* cl_event_wheel_construct, cl_event_wheel_init, cl_event_wheel_destroy
+*
+* Manipulation:
+* cl_event_wheel_reg, cl_event_wheel_unreg
+*
+*********/
+/****f* Component Library: Event_Wheel/cl_pfn_event_aged_cb_t
+* NAME
+* cl_pfn_event_aged_cb_t
+*
+* DESCRIPTION
+* This typedef defines the prototype for client functions invoked
+* by the Event_Wheel. The Event_Wheel calls the corresponding
+* client function when the specific item has aged.
+*
+* SYNOPSIS
+*/
+typedef uint64_t
+ (*cl_pfn_event_aged_cb_t) (IN uint64_t key,
+ IN uint32_t num_regs, IN void *context);
+/*
+* PARAMETERS
+* key
+* [in] The key used for registering the item in the call to
+* cl_event_wheel_reg.
+*
+* num_regs
+* [in] The number of times this event was registered (pushed in time).
+*
+* context
+* [in] Client specific context specified in a call to
+* cl_event_wheel_reg
+*
+* RETURN VALUE
+* This function returns the abosolute time the event should fire in [usec].
+* If lower then current time means the event should be unregistered
+* immediatly.
+*
+* NOTES
+* This typedef provides a function prototype reference for
+* the function provided by Event_Wheel clients as a parameter
+* to the cl_event_wheel_reg function.
+*
+* SEE ALSO
+* Event_Wheel, cl_event_wheel_reg
+*********/
+
+/****s* Component Library: Event_Wheel/cl_event_wheel_t
+* NAME
+* cl_event_wheel_t
+*
+* DESCRIPTION
+* Event_Wheel structure.
+*
+* The Event_Wheel is thread safe.
+*
+* The cl_event_wheel_t structure should be treated as opaque and should
+* be manipulated only through the provided functions.
+*
+* SYNOPSIS
+*/
+typedef struct _cl_event_wheel {
+ cl_spinlock_t lock;
+ cl_spinlock_t *p_external_lock;
+
+ cl_qmap_t events_map;
+ boolean_t closing;
+ cl_qlist_t events_wheel;
+ cl_timer_t timer;
+} cl_event_wheel_t;
+/*
+* FIELDS
+* lock
+* Spinlock to guard internal structures.
+*
+* p_external_lock
+* Reference to external spinlock to guard internal structures
+* if the event wheel is part of a larger object protected by its own lock
+*
+* events_map
+* A Map holding all registered event items by their key.
+*
+* closing
+* A flag indicating the event wheel is closing. This means that
+* callbacks that are called when closing == TRUE should just be ignored.
+*
+* events_wheel
+* A list of the events sorted by expiration time.
+*
+* timer
+* The timer scheduling event time propagation.
+*
+* SEE ALSO
+* Event_Wheel
+*********/
+
+/****s* Component Library: Event_Wheel/cl_event_wheel_reg_info_t
+* NAME
+* cl_event_wheel_reg_info_t
+*
+* DESCRIPTION
+* Defines the event_wheel registration object structure.
+*
+* The cl_event_wheel_reg_info_t structure is for internal use by the
+* Event_Wheel only.
+*
+* SYNOPSIS
+*/
+typedef struct _cl_event_wheel_reg_info {
+ cl_map_item_t map_item;
+ cl_list_item_t list_item;
+ uint64_t key;
+ cl_pfn_event_aged_cb_t pfn_aged_callback;
+ uint64_t aging_time;
+ uint32_t num_regs;
+ void *context;
+ cl_event_wheel_t *p_event_wheel;
+} cl_event_wheel_reg_info_t;
+/*
+* FIELDS
+* map_item
+* The map item of this event
+*
+* list_item
+* The sorted by aging time list item
+*
+* key
+* The key by which one can find the event
+*
+* pfn_aged_callback
+* The clients Event-Aged callback
+*
+* aging_time
+* The delta time [msec] for which the event should age.
+*
+* num_regs
+* The number of times the same event (key) was registered
+*
+* context
+* Client's context for event-aged callback.
+*
+* p_event_wheel
+* Pointer to this event wheel object
+*
+* SEE ALSO
+*********/
+
+/****f* Component Library: Event_Wheel/cl_event_wheel_construct
+* NAME
+* cl_event_wheel_construct
+*
+* DESCRIPTION
+* This function constructs a Event_Wheel object.
+*
+* SYNOPSIS
+*/
+void cl_event_wheel_construct(IN cl_event_wheel_t * const p_event_wheel);
+/*
+* PARAMETERS
+* p_event_wheel
+* [in] Pointer to a Event_Wheel.
+*
+* RETURN VALUE
+* This function does not return a value.
+*
+* NOTES
+* Allows calling cl_event_wheel_init and cl_event_wheel_destroy.
+*
+* SEE ALSO
+* Event_Wheel, cl_event_wheel_init, cl_event_wheel_destroy
+*********/
+
+/****f* Component Library: Event_Wheel/cl_event_wheel_init
+* NAME
+* cl_event_wheel_init
+*
+* DESCRIPTION
+* This function initializes a Event_Wheel object.
+*
+* SYNOPSIS
+*/
+cl_status_t
+cl_event_wheel_init(IN cl_event_wheel_t * const p_event_wheel);
+
+/*
+* PARAMETERS
+* p_event_wheel
+* [in] Pointer to a Event_Wheel.
+*
+* RETURN VALUE
+* CL_SUCCESS if the operation is successful.
+*
+* SEE ALSO
+* Event_Wheel, cl_event_wheel_destoy, cl_event_wheel_reg, cl_event_wheel_unreg
+*
+*********/
+
+/****f* Component Library: Event_Wheel/cl_event_wheel_init
+* NAME
+* cl_event_wheel_init
+*
+* DESCRIPTION
+* This function initializes a Event_Wheel object.
+*
+* SYNOPSIS
+*/
+cl_status_t
+cl_event_wheel_init_ex(IN cl_event_wheel_t * const p_event_wheel,
+ IN cl_spinlock_t * p_external_lock);
+
+/*
+* PARAMETERS
+* p_event_wheel
+* [in] Pointer to a Event_Wheel.
+*
+* p_external_lock
+* [in] Reference to external spinlock to guard internal structures
+* if the event wheel is part of a larger object protected by its own lock
+*
+* RETURN VALUE
+* CL_SUCCESS if the operation is successful.
+*
+* SEE ALSO
+* Event_Wheel, cl_event_wheel_destoy, cl_event_wheel_reg, cl_event_wheel_unreg
+*
+*********/
+
+/****f* Component Library: Event_Wheel/cl_event_wheel_destroy
+* NAME
+* cl_event_wheel_destroy
+*
+* DESCRIPTION
+* This function destroys a Event_Wheel object.
+*
+* SYNOPSIS
+*/
+void cl_event_wheel_destroy(IN cl_event_wheel_t * const p_event_wheel);
+/*
+* PARAMETERS
+* p_event_wheel
+* [in] Pointer to a Event_Wheel.
+*
+* RETURN VALUE
+* This function does not return a value.
+*
+* NOTES
+* This function does not returns until all client callback functions
+* been successfully finished.
+*
+* SEE ALSO
+* Event_Wheel, cl_event_wheel_construct, cl_event_wheel_init
+*********/
+
+/****f* Component Library: Event_Wheel/cl_event_wheel_dump
+* NAME
+* cl_event_wheel_dump
+*
+* DESCRIPTION
+* This function dumps the details of an Event_Whell object.
+*
+* SYNOPSIS
+*/
+void cl_event_wheel_dump(IN cl_event_wheel_t * const p_event_wheel);
+/*
+* PARAMETERS
+* p_event_wheel
+* [in] Pointer to a Event_Wheel.
+*
+* RETURN VALUE
+* This function does not return a value.
+*
+* NOTES
+* Note that this function should be called inside a lock of the event wheel!
+* It doesn't aquire the lock by itself.
+*
+* SEE ALSO
+* Event_Wheel, cl_event_wheel_construct, cl_event_wheel_init
+*********/
+
+/****f* Component Library: Event_Wheel/cl_event_wheel_reg
+* NAME
+* cl_event_wheel_reg
+*
+* DESCRIPTION
+* This function registers a client with a Event_Wheel object.
+*
+* SYNOPSIS
+*/
+cl_status_t
+cl_event_wheel_reg(IN cl_event_wheel_t * const p_event_wheel,
+ IN const uint64_t key,
+ IN const uint64_t aging_time_usec,
+ IN cl_pfn_event_aged_cb_t pfn_callback,
+ IN void *const context);
+/*
+* PARAMETERS
+* p_event_wheel
+* [in] Pointer to a Event_Wheel.
+*
+* key
+* [in] The specifc Key by which events are registered.
+*
+* aging_time_usec
+* [in] The absolute time this event should age in usec
+*
+* pfn_callback
+* [in] Event Aging callback. The Event_Wheel calls this
+* function after the time the event has registed for has come.
+*
+* context
+* [in] Client context value passed to the cl_pfn_event_aged_cb_t
+* function.
+*
+* RETURN VALUE
+* On success a Event_Wheel CL_SUCCESS or CL_ERROR otherwise.
+*
+* SEE ALSO
+* Event_Wheel, cl_event_wheel_unreg
+*********/
+
+/****f* Component Library: Event_Wheel/cl_event_wheel_unreg
+* NAME
+* cl_event_wheel_unreg
+*
+* DESCRIPTION
+* This function unregisters a client event from a Event_Wheel.
+*
+* SYNOPSIS
+*/
+void
+cl_event_wheel_unreg(IN cl_event_wheel_t * const p_event_wheel,
+ IN uint64_t key);
+/*
+* PARAMETERS
+* p_event_wheel
+* [in] Pointer to a Event_Wheel.
+*
+* key
+* [in] The key used for registering the event
+*
+* RETURN VALUE
+* This function does not return a value.
+*
+* NOTES
+* After the event has aged it is automatically removed from
+* the event wheel. So it should only be invoked when the need arises
+* to remove existing events before they age.
+*
+* SEE ALSO
+* Event_Wheel, cl_event_wheel_reg
+*********/
+
+/****f* Component Library: Event_Wheel/cl_event_wheel_num_regs
+* NAME
+* cl_event_wheel_num_regs
+*
+* DESCRIPTION
+* This function returns the number of times an event was registered.
+*
+* SYNOPSIS
+*/
+uint32_t
+cl_event_wheel_num_regs(IN cl_event_wheel_t * const p_event_wheel,
+ IN uint64_t key);
+/*
+* PARAMETERS
+* p_event_wheel
+* [in] Pointer to a Event_Wheel.
+*
+* key
+* [in] The key used for registering the event
+*
+* RETURN VALUE
+* The number of times the event was registered.
+* 0 if never registered or eventually aged.
+*
+* SEE ALSO
+* Event_Wheel, cl_event_wheel_reg, cl_event_wheel_unreg
+*********/
+
+END_C_DECLS
+#endif /* !defined(_CL_EVENT_WHEEL_H_) */
diff --git a/contrib/ofed/opensm/include/complib/cl_fleximap.h b/contrib/ofed/opensm/include/complib/cl_fleximap.h
new file mode 100644
index 0000000..89bc7c0
--- /dev/null
+++ b/contrib/ofed/opensm/include/complib/cl_fleximap.h
@@ -0,0 +1,943 @@
+/*
+ * Copyright (c) 2004-2009 Voltaire, Inc. All rights reserved.
+ * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved.
+ * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+/*
+ * Abstract:
+ * Declaration of flexi map, a binary tree where the caller always provides
+ * all necessary storage.
+ */
+
+#ifndef _CL_FLEXIMAP_H_
+#define _CL_FLEXIMAP_H_
+
+#include <complib/cl_qmap.h>
+
+#ifdef __cplusplus
+# define BEGIN_C_DECLS extern "C" {
+# define END_C_DECLS }
+#else /* !__cplusplus */
+# define BEGIN_C_DECLS
+# define END_C_DECLS
+#endif /* __cplusplus */
+
+BEGIN_C_DECLS
+/****h* Component Library/Flexi Map
+* NAME
+* Flexi Map
+*
+* DESCRIPTION
+* Flexi map implements a binary tree that stores user provided cl_fmap_item_t
+* structures. Each item stored in a flexi map has a unique user defined
+* key (duplicates are not allowed). Flexi map provides the ability to
+* efficiently search for an item given a key. Flexi map allows user
+* defined keys of any size. Storage for keys and a comparison function
+* are provided by users to allow flexi map to store items with arbitrary
+* key values.
+*
+* Flexi map does not allocate any memory, and can therefore not fail
+* any operations due to insufficient memory. Flexi map can thus be useful
+* in minimizing the error paths in code.
+*
+* Flexi map is not thread safe, and users must provide serialization when
+* adding and removing items from the map.
+*
+* The flexi map functions operate on a cl_fmap_t structure which should
+* be treated as opaque and should be manipulated only through the provided
+* functions.
+*
+* SEE ALSO
+* Structures:
+* cl_fmap_t, cl_fmap_item_t
+*
+* Callbacks:
+* cl_pfn_fmap_apply_t
+*
+* Item Manipulation:
+* cl_fmap_key
+*
+* Initialization:
+* cl_fmap_init
+*
+* Iteration:
+* cl_fmap_end, cl_fmap_head, cl_fmap_tail, cl_fmap_next, cl_fmap_prev
+*
+* Manipulation:
+* cl_fmap_insert, cl_fmap_get, cl_fmap_remove_item, cl_fmap_remove,
+* cl_fmap_remove_all, cl_fmap_merge, cl_fmap_delta, cl_fmap_get_next
+*
+* Search:
+* cl_fmap_apply_func
+*
+* Attributes:
+* cl_fmap_count, cl_is_fmap_empty,
+*********/
+/****s* Component Library: Flexi Map/cl_fmap_item_t
+* NAME
+* cl_fmap_item_t
+*
+* DESCRIPTION
+* The cl_fmap_item_t structure is used by maps to store objects.
+*
+* The cl_fmap_item_t structure should be treated as opaque and should
+* be manipulated only through the provided functions.
+*
+* SYNOPSIS
+*/
+typedef struct _cl_fmap_item {
+ /* Must be first to allow casting. */
+ cl_pool_item_t pool_item;
+ struct _cl_fmap_item *p_left;
+ struct _cl_fmap_item *p_right;
+ struct _cl_fmap_item *p_up;
+ cl_map_color_t color;
+ const void *p_key;
+#ifdef _DEBUG_
+ struct _cl_fmap *p_map;
+#endif
+} cl_fmap_item_t;
+/*
+* FIELDS
+* pool_item
+* Used to store the item in a doubly linked list, allowing more
+* efficient map traversal.
+*
+* p_left
+* Pointer to the map item that is a child to the left of the node.
+*
+* p_right
+* Pointer to the map item that is a child to the right of the node.
+*
+* p_up
+* Pointer to the map item that is the parent of the node.
+*
+* p_nil
+* Pointer to the map's NIL item, used as a terminator for leaves.
+* The NIL sentinel is in the cl_fmap_t structure.
+*
+* color
+* Indicates whether a node is red or black in the map.
+*
+* p_key
+* Pointer to the value that uniquely represents a node in a map. This
+* pointer is set by calling cl_fmap_insert and can be retrieved by
+* calling cl_fmap_key.
+*
+* NOTES
+* None of the fields of this structure should be manipulated by users, as
+* they are crititcal to the proper operation of the map in which they
+* are stored.
+*
+* To allow storing items in either a quick list, a quick pool, or a flexi
+* map, the map implementation guarantees that the map item can be safely
+* cast to a pool item used for storing an object in a quick pool, or cast
+* to a list item used for storing an object in a quick list. This removes
+* the need to embed a flexi map item, a list item, and a pool item in
+* objects that need to be stored in a quick list, a quick pool, and a
+* flexi map.
+*
+* SEE ALSO
+* Flexi Map, cl_fmap_insert, cl_fmap_key, cl_pool_item_t, cl_list_item_t
+*********/
+
+/****d* Component Library: Flexi Map/cl_pfn_fmap_cmp_t
+* NAME
+* cl_pfn_fmap_cmp_t
+*
+* DESCRIPTION
+* The cl_pfn_fmap_cmp_t function type defines the prototype for functions
+* used to compare item keys in a flexi map.
+*
+* SYNOPSIS
+*/
+typedef int
+ (*cl_pfn_fmap_cmp_t) (IN const void *const p_key1,
+ IN const void *const p_key2);
+/*
+* PARAMETERS
+* p_key1
+* [in] Pointer to the first of two keys to compare.
+*
+* p_key2
+* [in] Pointer to the second of two keys to compare.
+*
+* RETURN VALUE
+* Returns 0 if the keys match.
+* Returns less than 0 if *p_key1 is less than *p_key2.
+* Returns greater than 0 if *p_key1 is greater than *p_key2.
+*
+* NOTES
+* This function type is provided as function prototype reference for the
+* function provided by users as a parameter to the cl_fmap_init function.
+*
+* SEE ALSO
+* Flexi Map, cl_fmap_init
+*********/
+
+/****s* Component Library: Flexi Map/cl_fmap_t
+* NAME
+* cl_fmap_t
+*
+* DESCRIPTION
+* Flexi map structure.
+*
+* The cl_fmap_t structure should be treated as opaque and should
+* be manipulated only through the provided functions.
+*
+* SYNOPSIS
+*/
+typedef struct _cl_fmap {
+ cl_fmap_item_t root;
+ cl_fmap_item_t nil;
+ cl_state_t state;
+ size_t count;
+ cl_pfn_fmap_cmp_t pfn_compare;
+} cl_fmap_t;
+/*
+* PARAMETERS
+* root
+* Map item that serves as root of the map. The root is set up to
+* always have itself as parent. The left pointer is set to point
+* to the item at the root.
+*
+* nil
+* Map item that serves as terminator for all leaves, as well as
+* providing the list item used as quick list for storing map items
+* in a list for faster traversal.
+*
+* state
+* State of the map, used to verify that operations are permitted.
+*
+* count
+* Number of items in the map.
+*
+* pfn_compare
+* Pointer to a compare function to invoke to compare the keys of
+* items in the map.
+*
+* SEE ALSO
+* Flexi Map, cl_pfn_fmap_cmp_t
+*********/
+
+/****d* Component Library: Flexi Map/cl_pfn_fmap_apply_t
+* NAME
+* cl_pfn_fmap_apply_t
+*
+* DESCRIPTION
+* The cl_pfn_fmap_apply_t function type defines the prototype for
+* functions used to iterate items in a flexi map.
+*
+* SYNOPSIS
+*/
+typedef void
+ (*cl_pfn_fmap_apply_t) (IN cl_fmap_item_t * const p_map_item,
+ IN void *context);
+/*
+* PARAMETERS
+* p_map_item
+* [in] Pointer to a cl_fmap_item_t structure.
+*
+* context
+* [in] Value passed to the callback function.
+*
+* RETURN VALUE
+* This function does not return a value.
+*
+* NOTES
+* This function type is provided as function prototype reference for the
+* function provided by users as a parameter to the cl_fmap_apply_func
+* function.
+*
+* SEE ALSO
+* Flexi Map, cl_fmap_apply_func
+*********/
+
+/****f* Component Library: Flexi Map/cl_fmap_count
+* NAME
+* cl_fmap_count
+*
+* DESCRIPTION
+* The cl_fmap_count function returns the number of items stored
+* in a flexi map.
+*
+* SYNOPSIS
+*/
+static inline size_t cl_fmap_count(IN const cl_fmap_t * const p_map)
+{
+ CL_ASSERT(p_map);
+ CL_ASSERT(p_map->state == CL_INITIALIZED);
+ return (p_map->count);
+}
+
+/*
+* PARAMETERS
+* p_map
+* [in] Pointer to a cl_fmap_t structure whose item count to return.
+*
+* RETURN VALUE
+* Returns the number of items stored in the map.
+*
+* SEE ALSO
+* Flexi Map, cl_is_fmap_empty
+*********/
+
+/****f* Component Library: Flexi Map/cl_is_fmap_empty
+* NAME
+* cl_is_fmap_empty
+*
+* DESCRIPTION
+* The cl_is_fmap_empty function returns whether a flexi map is empty.
+*
+* SYNOPSIS
+*/
+static inline boolean_t cl_is_fmap_empty(IN const cl_fmap_t * const p_map)
+{
+ CL_ASSERT(p_map);
+ CL_ASSERT(p_map->state == CL_INITIALIZED);
+
+ return (p_map->count == 0);
+}
+
+/*
+* PARAMETERS
+* p_map
+* [in] Pointer to a cl_fmap_t structure to test for emptiness.
+*
+* RETURN VALUES
+* TRUE if the flexi map is empty.
+*
+* FALSE otherwise.
+*
+* SEE ALSO
+* Flexi Map, cl_fmap_count, cl_fmap_remove_all
+*********/
+
+/****f* Component Library: Flexi Map/cl_fmap_key
+* NAME
+* cl_fmap_key
+*
+* DESCRIPTION
+* The cl_fmap_key function retrieves the key value of a map item.
+*
+* SYNOPSIS
+*/
+static inline const void *cl_fmap_key(IN const cl_fmap_item_t * const p_item)
+{
+ CL_ASSERT(p_item);
+ return (p_item->p_key);
+}
+
+/*
+* PARAMETERS
+* p_item
+* [in] Pointer to a map item whose key value to return.
+*
+* RETURN VALUE
+* Returns the a pointer to the key value for the specified map item.
+* The key value should not be modified to insure proper flexi map operation.
+*
+* NOTES
+* The key value is set in a call to cl_fmap_insert.
+*
+* SEE ALSO
+* Flexi Map, cl_fmap_insert
+*********/
+
+/****f* Component Library: Flexi Map/cl_fmap_init
+* NAME
+* cl_fmap_init
+*
+* DESCRIPTION
+* The cl_fmap_init function initialized a flexi map for use.
+*
+* SYNOPSIS
+*/
+void cl_fmap_init(IN cl_fmap_t * const p_map, IN cl_pfn_fmap_cmp_t pfn_compare);
+/*
+* PARAMETERS
+* p_map
+* [in] Pointer to a cl_fmap_t structure to initialize.
+*
+* pfn_compare
+* [in] Pointer to the compare function used to compare keys.
+* See the cl_pfn_fmap_cmp_t function type declaration for details
+* about the callback function.
+*
+* RETURN VALUES
+* This function does not return a value.
+*
+* NOTES
+* Allows calling flexi map manipulation functions.
+*
+* SEE ALSO
+* Flexi Map, cl_fmap_insert, cl_fmap_remove
+*********/
+
+/****f* Component Library: Flexi Map/cl_fmap_end
+* NAME
+* cl_fmap_end
+*
+* DESCRIPTION
+* The cl_fmap_end function returns the end of a flexi map.
+*
+* SYNOPSIS
+*/
+static inline const cl_fmap_item_t *cl_fmap_end(IN const cl_fmap_t *
+ const p_map)
+{
+ CL_ASSERT(p_map);
+ CL_ASSERT(p_map->state == CL_INITIALIZED);
+ /* Nil is the end of the map. */
+ return (&p_map->nil);
+}
+
+/*
+* PARAMETERS
+* p_map
+* [in] Pointer to a cl_fmap_t structure whose end to return.
+*
+* RETURN VALUE
+* Pointer to the end of the map.
+*
+* NOTES
+* cl_fmap_end is useful for determining the validity of map items returned
+* by cl_fmap_head, cl_fmap_tail, cl_fmap_next, or cl_fmap_prev. If the
+* map item pointer returned by any of these functions compares to the end,
+* the end of the map was encoutered.
+* When using cl_fmap_head or cl_fmap_tail, this condition indicates that
+* the map is empty.
+*
+* SEE ALSO
+* Flexi Map, cl_fmap_head, cl_fmap_tail, cl_fmap_next, cl_fmap_prev
+*********/
+
+/****f* Component Library: Flexi Map/cl_fmap_head
+* NAME
+* cl_fmap_head
+*
+* DESCRIPTION
+* The cl_fmap_head function returns the map item with the lowest key
+* value stored in a flexi map.
+*
+* SYNOPSIS
+*/
+static inline cl_fmap_item_t *cl_fmap_head(IN const cl_fmap_t * const p_map)
+{
+ CL_ASSERT(p_map);
+ CL_ASSERT(p_map->state == CL_INITIALIZED);
+ return ((cl_fmap_item_t *) p_map->nil.pool_item.list_item.p_next);
+}
+
+/*
+* PARAMETERS
+* p_map
+* [in] Pointer to a cl_fmap_t structure whose item with the lowest
+* key is returned.
+*
+* RETURN VALUES
+* Pointer to the map item with the lowest key in the flexi map.
+*
+* Pointer to the map end if the flexi map was empty.
+*
+* NOTES
+* cl_fmap_head does not remove the item from the map.
+*
+* SEE ALSO
+* Flexi Map, cl_fmap_tail, cl_fmap_next, cl_fmap_prev, cl_fmap_end,
+* cl_fmap_item_t
+*********/
+
+/****f* Component Library: Flexi Map/cl_fmap_tail
+* NAME
+* cl_fmap_tail
+*
+* DESCRIPTION
+* The cl_fmap_tail function returns the map item with the highest key
+* value stored in a flexi map.
+*
+* SYNOPSIS
+*/
+static inline cl_fmap_item_t *cl_fmap_tail(IN const cl_fmap_t * const p_map)
+{
+ CL_ASSERT(p_map);
+ CL_ASSERT(p_map->state == CL_INITIALIZED);
+ return ((cl_fmap_item_t *) p_map->nil.pool_item.list_item.p_prev);
+}
+
+/*
+* PARAMETERS
+* p_map
+* [in] Pointer to a cl_fmap_t structure whose item with the highest key
+* is returned.
+*
+* RETURN VALUES
+* Pointer to the map item with the highest key in the flexi map.
+*
+* Pointer to the map end if the flexi map was empty.
+*
+* NOTES
+* cl_fmap_end does not remove the item from the map.
+*
+* SEE ALSO
+* Flexi Map, cl_fmap_head, cl_fmap_next, cl_fmap_prev, cl_fmap_end,
+* cl_fmap_item_t
+*********/
+
+/****f* Component Library: Flexi Map/cl_fmap_next
+* NAME
+* cl_fmap_next
+*
+* DESCRIPTION
+* The cl_fmap_next function returns the map item with the next higher
+* key value than a specified map item.
+*
+* SYNOPSIS
+*/
+static inline cl_fmap_item_t *cl_fmap_next(IN const cl_fmap_item_t *
+ const p_item)
+{
+ CL_ASSERT(p_item);
+ return ((cl_fmap_item_t *) p_item->pool_item.list_item.p_next);
+}
+
+/*
+* PARAMETERS
+* p_item
+* [in] Pointer to a map item whose successor to return.
+*
+* RETURN VALUES
+* Pointer to the map item with the next higher key value in a flexi map.
+*
+* Pointer to the map end if the specified item was the last item in
+* the flexi map.
+*
+* SEE ALSO
+* Flexi Map, cl_fmap_head, cl_fmap_tail, cl_fmap_prev, cl_fmap_end,
+* cl_fmap_item_t
+*********/
+
+/****f* Component Library: Flexi Map/cl_fmap_prev
+* NAME
+* cl_fmap_prev
+*
+* DESCRIPTION
+* The cl_fmap_prev function returns the map item with the next lower
+* key value than a precified map item.
+*
+* SYNOPSIS
+*/
+static inline cl_fmap_item_t *cl_fmap_prev(IN const cl_fmap_item_t *
+ const p_item)
+{
+ CL_ASSERT(p_item);
+ return ((cl_fmap_item_t *) p_item->pool_item.list_item.p_prev);
+}
+
+/*
+* PARAMETERS
+* p_item
+* [in] Pointer to a map item whose predecessor to return.
+*
+* RETURN VALUES
+* Pointer to the map item with the next lower key value in a flexi map.
+*
+* Pointer to the map end if the specifid item was the first item in
+* the flexi map.
+*
+* SEE ALSO
+* Flexi Map, cl_fmap_head, cl_fmap_tail, cl_fmap_next, cl_fmap_end,
+* cl_fmap_item_t
+*********/
+
+/****f* Component Library: Flexi Map/cl_fmap_insert
+* NAME
+* cl_fmap_insert
+*
+* DESCRIPTION
+* The cl_fmap_insert function inserts a map item into a flexi map.
+*
+* SYNOPSIS
+*/
+cl_fmap_item_t *cl_fmap_insert(IN cl_fmap_t * const p_map,
+ IN const void *const p_key,
+ IN cl_fmap_item_t * const p_item);
+/*
+* PARAMETERS
+* p_map
+* [in] Pointer to a cl_fmap_t structure into which to add the item.
+*
+* p_key
+* [in] Pointer to the key value to assign to the item. Storage
+* for the key must be persistant, as only the pointer is stored.
+* Users are responsible for maintaining the validity of key
+* pointers while they are in use.
+*
+* p_item
+* [in] Pointer to a cl_fmap_item_t stucture to insert into the flexi map.
+*
+* RETURN VALUE
+* Pointer to the item in the map with the specified key. If insertion
+* was successful, this is the pointer to the item. If an item with the
+* specified key already exists in the map, the pointer to that item is
+* returned.
+*
+* NOTES
+* Insertion operations may cause the flexi map to rebalance.
+*
+* SEE ALSO
+* Flexi Map, cl_fmap_remove, cl_fmap_item_t
+*********/
+
+/****f* Component Library: Flexi Map/cl_fmap_match
+* NAME
+* cl_fmap_match
+*
+* DESCRIPTION
+* The cl_fmap_match function returns the map item matching a key.
+*
+* SYNOPSIS
+*/
+cl_fmap_item_t *cl_fmap_match(IN const cl_fmap_t * const p_map,
+ IN const void *const p_key,
+ IN cl_pfn_fmap_cmp_t pfn_compare);
+/*
+* PARAMETERS
+* p_map
+* [in] Pointer to a cl_fmap_t structure from which to retrieve the
+* item with the specified key.
+*
+* p_key
+* [in] Pointer to a key value used to search for the desired map item.
+*
+* pfn_compare
+* [in] Pointer to a compare function to invoke to compare the
+* keys of items in the map. Passing NULL here makes such call
+* to be equivalent to using cl_fmap_get().
+*
+* RETURN VALUES
+* Pointer to the map item matching the desired key value.
+*
+* Pointer to the map end if there was no item matching the desired key
+* value stored in the flexi map.
+*
+* SEE ALSO
+* Flexi Map, cl_fmap_remove, cl_fmap_get
+*********/
+
+/****f* Component Library: Flexi Map/cl_fmap_get
+* NAME
+* cl_fmap_get
+*
+* DESCRIPTION
+* The cl_fmap_get function returns the map item associated with a key.
+*
+* SYNOPSIS
+*/
+cl_fmap_item_t *cl_fmap_get(IN const cl_fmap_t * const p_map,
+ IN const void *const p_key);
+/*
+* PARAMETERS
+* p_map
+* [in] Pointer to a cl_fmap_t structure from which to retrieve the
+* item with the specified key.
+*
+* p_key
+* [in] Pointer to a key value used to search for the desired map item.
+*
+* RETURN VALUES
+* Pointer to the map item with the desired key value.
+*
+* Pointer to the map end if there was no item with the desired key value
+* stored in the flexi map.
+*
+* NOTES
+* cl_fmap_get does not remove the item from the flexi map.
+*
+* SEE ALSO
+* Flexi Map, cl_fmap_remove, cl_fmap_get_next
+*********/
+
+/****f* Component Library: Flexi Map/cl_fmap_get_next
+* NAME
+* cl_fmap_get_next
+*
+* DESCRIPTION
+* The cl_fmap_get_next function returns the first map item associated with
+* a key > the key specified.
+*
+* SYNOPSIS
+*/
+cl_fmap_item_t *cl_fmap_get_next(IN const cl_fmap_t * const p_map,
+ IN const void *const p_key);
+/*
+* PARAMETERS
+* p_map
+* [in] Pointer to a cl_fmap_t structure from which to retrieve the
+* item with the specified key.
+*
+* p_key
+* [in] Pointer to a key value used to search for the desired map item.
+*
+* RETURN VALUES
+* Pointer to the first map item with a key > the desired key value.
+*
+* Pointer to the map end if there was no item with a key > the desired key
+* value stored in the flexi map.
+*
+* NOTES
+* cl_fmap_get_next does not remove the item from the flexi map.
+*
+* SEE ALSO
+* Flexi Map, cl_fmap_remove, cl_fmap_get
+*********/
+
+/****f* Component Library: Flexi Map/cl_fmap_remove_item
+* NAME
+* cl_fmap_remove_item
+*
+* DESCRIPTION
+* The cl_fmap_remove_item function removes the specified map item
+* from a flexi map.
+*
+* SYNOPSIS
+*/
+void
+cl_fmap_remove_item(IN cl_fmap_t * const p_map,
+ IN cl_fmap_item_t * const p_item);
+/*
+* PARAMETERS
+* p_item
+* [in] Pointer to a map item to remove from its flexi map.
+*
+* RETURN VALUES
+* This function does not return a value.
+*
+* In a debug build, cl_fmap_remove_item asserts that the item being
+* removed is in the specified map.
+*
+* NOTES
+* Removes the map item pointed to by p_item from its flexi map.
+*
+* SEE ALSO
+* Flexi Map, cl_fmap_remove, cl_fmap_remove_all, cl_fmap_insert
+*********/
+
+/****f* Component Library: Flexi Map/cl_fmap_remove
+* NAME
+* cl_fmap_remove
+*
+* DESCRIPTION
+* The cl_fmap_remove function removes the map item with the specified key
+* from a flexi map.
+*
+* SYNOPSIS
+*/
+cl_fmap_item_t *cl_fmap_remove(IN cl_fmap_t * const p_map,
+ IN const void *const p_key);
+/*
+* PARAMETERS
+* p_map
+* [in] Pointer to a cl_fmap_t structure from which to remove the
+* item with the specified key.
+*
+* p_key
+* [in] Pointer to the key value used to search for the map item
+* to remove.
+*
+* RETURN VALUES
+* Pointer to the removed map item if it was found.
+*
+* Pointer to the map end if no item with the specified key exists in the
+* flexi map.
+*
+* SEE ALSO
+* Flexi Map, cl_fmap_remove_item, cl_fmap_remove_all, cl_fmap_insert
+*********/
+
+/****f* Component Library: Flexi Map/cl_fmap_remove_all
+* NAME
+* cl_fmap_remove_all
+*
+* DESCRIPTION
+* The cl_fmap_remove_all function removes all items in a flexi map,
+* leaving it empty.
+*
+* SYNOPSIS
+*/
+static inline void cl_fmap_remove_all(IN cl_fmap_t * const p_map)
+{
+ CL_ASSERT(p_map);
+ CL_ASSERT(p_map->state == CL_INITIALIZED);
+
+ p_map->root.p_left = &p_map->nil;
+ p_map->nil.pool_item.list_item.p_next = &p_map->nil.pool_item.list_item;
+ p_map->nil.pool_item.list_item.p_prev = &p_map->nil.pool_item.list_item;
+ p_map->count = 0;
+}
+
+/*
+* PARAMETERS
+* p_map
+* [in] Pointer to a cl_fmap_t structure to empty.
+*
+* RETURN VALUES
+* This function does not return a value.
+*
+* SEE ALSO
+* Flexi Map, cl_fmap_remove, cl_fmap_remove_item
+*********/
+
+/****f* Component Library: Flexi Map/cl_fmap_merge
+* NAME
+* cl_fmap_merge
+*
+* DESCRIPTION
+* The cl_fmap_merge function moves all items from one map to another,
+* excluding duplicates.
+*
+* SYNOPSIS
+*/
+void
+cl_fmap_merge(OUT cl_fmap_t * const p_dest_map,
+ IN OUT cl_fmap_t * const p_src_map);
+/*
+* PARAMETERS
+* p_dest_map
+* [out] Pointer to a cl_fmap_t structure to which items should be added.
+*
+* p_src_map
+* [in/out] Pointer to a cl_fmap_t structure whose items to add
+* to p_dest_map.
+*
+* RETURN VALUES
+* This function does not return a value.
+*
+* NOTES
+* Items are evaluated based on their keys only.
+*
+* Upon return from cl_fmap_merge, the flexi map referenced by p_src_map
+* contains all duplicate items.
+*
+* SEE ALSO
+* Flexi Map, cl_fmap_delta
+*********/
+
+/****f* Component Library: Flexi Map/cl_fmap_delta
+* NAME
+* cl_fmap_delta
+*
+* DESCRIPTION
+* The cl_fmap_delta function computes the differences between two maps.
+*
+* SYNOPSIS
+*/
+void
+cl_fmap_delta(IN OUT cl_fmap_t * const p_map1,
+ IN OUT cl_fmap_t * const p_map2,
+ OUT cl_fmap_t * const p_new, OUT cl_fmap_t * const p_old);
+/*
+* PARAMETERS
+* p_map1
+* [in/out] Pointer to the first of two cl_fmap_t structures whose
+* differences to compute.
+*
+* p_map2
+* [in/out] Pointer to the second of two cl_fmap_t structures whose
+* differences to compute.
+*
+* p_new
+* [out] Pointer to an empty cl_fmap_t structure that contains the
+* items unique to p_map2 upon return from the function.
+*
+* p_old
+* [out] Pointer to an empty cl_fmap_t structure that contains the
+* items unique to p_map1 upon return from the function.
+*
+* RETURN VALUES
+* This function does not return a value.
+*
+* NOTES
+* Items are evaluated based on their keys. Items that exist in both
+* p_map1 and p_map2 remain in their respective maps. Items that
+* exist only p_map1 are moved to p_old. Likewise, items that exist only
+* in p_map2 are moved to p_new. This function can be useful in evaluating
+* changes between two maps.
+*
+* Both maps pointed to by p_new and p_old must be empty on input. This
+* requirement removes the possibility of failures.
+*
+* SEE ALSO
+* Flexi Map, cl_fmap_merge
+*********/
+
+/****f* Component Library: Flexi Map/cl_fmap_apply_func
+* NAME
+* cl_fmap_apply_func
+*
+* DESCRIPTION
+* The cl_fmap_apply_func function executes a specified function
+* for every item stored in a flexi map.
+*
+* SYNOPSIS
+*/
+void
+cl_fmap_apply_func(IN const cl_fmap_t * const p_map,
+ IN cl_pfn_fmap_apply_t pfn_func,
+ IN const void *const context);
+/*
+* PARAMETERS
+* p_map
+* [in] Pointer to a cl_fmap_t structure.
+*
+* pfn_func
+* [in] Function invoked for every item in the flexi map.
+* See the cl_pfn_fmap_apply_t function type declaration for
+* details about the callback function.
+*
+* context
+* [in] Value to pass to the callback functions to provide context.
+*
+* RETURN VALUE
+* This function does not return a value.
+*
+* NOTES
+* The function provided must not perform any map operations, as these
+* would corrupt the flexi map.
+*
+* SEE ALSO
+* Flexi Map, cl_pfn_fmap_apply_t
+*********/
+
+END_C_DECLS
+#endif /* _CL_FLEXIMAP_H_ */
diff --git a/contrib/ofed/management/opensm/include/complib/cl_list.h b/contrib/ofed/opensm/include/complib/cl_list.h
index 5d40b19..5d40b19 100644
--- a/contrib/ofed/management/opensm/include/complib/cl_list.h
+++ b/contrib/ofed/opensm/include/complib/cl_list.h
diff --git a/contrib/ofed/management/opensm/include/complib/cl_log.h b/contrib/ofed/opensm/include/complib/cl_log.h
index 45c7ec3..45c7ec3 100644
--- a/contrib/ofed/management/opensm/include/complib/cl_log.h
+++ b/contrib/ofed/opensm/include/complib/cl_log.h
diff --git a/contrib/ofed/management/opensm/include/complib/cl_map.h b/contrib/ofed/opensm/include/complib/cl_map.h
index 5bf779c..5bf779c 100644
--- a/contrib/ofed/management/opensm/include/complib/cl_map.h
+++ b/contrib/ofed/opensm/include/complib/cl_map.h
diff --git a/contrib/ofed/management/opensm/include/complib/cl_math.h b/contrib/ofed/opensm/include/complib/cl_math.h
index 47489bd..47489bd 100644
--- a/contrib/ofed/management/opensm/include/complib/cl_math.h
+++ b/contrib/ofed/opensm/include/complib/cl_math.h
diff --git a/contrib/ofed/opensm/include/complib/cl_nodenamemap.h b/contrib/ofed/opensm/include/complib/cl_nodenamemap.h
new file mode 100644
index 0000000..bfe290b
--- /dev/null
+++ b/contrib/ofed/opensm/include/complib/cl_nodenamemap.h
@@ -0,0 +1,64 @@
+/*
+ * Copyright (c) 2008 Voltaire, Inc. All rights reserved.
+ * Copyright (c) 2007 Lawrence Livermore National Lab
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+#ifndef _CL_NODE_NAME_MAP_H_
+#define _CL_NODE_NAME_MAP_H_
+
+#include <stdio.h>
+#include <stdint.h>
+#include <complib/cl_qmap.h>
+
+/* NOTE: this may modify the parameter "nodedesc". */
+char *clean_nodedesc(char *nodedesc);
+
+typedef struct _name_map_item {
+ cl_map_item_t item;
+ uint64_t guid;
+ char *name;
+} name_map_item_t;
+
+typedef cl_qmap_t nn_map_t;
+
+/**
+ * Node name map interface.
+ * It is OK to pass NULL for the node_name_map[_fp] parameters.
+ */
+nn_map_t *open_node_name_map(const char *node_name_map);
+void close_node_name_map(nn_map_t *map);
+char *remap_node_name(nn_map_t *map, uint64_t target_guid, char *nodedesc);
+ /* NOTE: parameter "nodedesc" may be modified here. */
+int parse_node_map(const char *file_name,
+ int (*create)(void *, uint64_t, char *), void *cxt);
+
+#endif /* _CL_NODE_NAME_MAP_H_ */
diff --git a/contrib/ofed/management/opensm/include/complib/cl_packoff.h b/contrib/ofed/opensm/include/complib/cl_packoff.h
index 52ee381..52ee381 100644
--- a/contrib/ofed/management/opensm/include/complib/cl_packoff.h
+++ b/contrib/ofed/opensm/include/complib/cl_packoff.h
diff --git a/contrib/ofed/opensm/include/complib/cl_packon.h b/contrib/ofed/opensm/include/complib/cl_packon.h
new file mode 100644
index 0000000..e2e45b4
--- /dev/null
+++ b/contrib/ofed/opensm/include/complib/cl_packon.h
@@ -0,0 +1,83 @@
+/*
+ * Copyright (c) 2004, 2005 Voltaire, Inc. All rights reserved.
+ * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved.
+ * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+/*
+ * Abstract:
+ * Turns on byte packing, which is necessary for passing information from
+ * system to system over a network to ensure no padding by the compiler has
+ * taken place.
+ */
+
+/****h* Component Library/Structure Packing
+* NAME
+* Structure Packing
+*
+* DESCRIPTION
+* The structure packing header files allow packing structures on byte
+* boundaries.
+*
+* Structure packing should be used whenever a structure is transmitted
+* between systems, as different platforms pad structures differently if
+* they are not packed. Packing a structure that is not transmitted between
+* systems can be detrimental to performance, as fields in the structure may
+* not align properly for some platforms. Care must be taken when creating
+* packed structures that the alignment rules for all platforms are followed.
+*
+* To pack a structure, include cl_packon.h before defining the structure, and
+* include cl_packoff.h after the structure definition. Multiple structures
+* can be packed between the two include statements if desired.
+*
+* The structure definition itself must use the PACK_SUFFIX keyword.
+*
+* EXAMPLE
+* #include <complib/cl_packon.h>
+*
+* typedef _my_struct_t
+* {
+* uint64 large;
+* uint32 medium;
+* uint16 small;
+*
+* } PACK_SUFFIX my_struct_t;
+* #include <complib/cl_packoff.h>
+*********/
+
+#ifndef PACK_SUFFIX
+#define PACK_SUFFIX __attribute__((packed))
+#endif
+
+#ifdef _MSC_VER
+#pragma pack (push, 1)
+#endif
diff --git a/contrib/ofed/opensm/include/complib/cl_passivelock.h b/contrib/ofed/opensm/include/complib/cl_passivelock.h
new file mode 100644
index 0000000..0fad6ef
--- /dev/null
+++ b/contrib/ofed/opensm/include/complib/cl_passivelock.h
@@ -0,0 +1,323 @@
+/*
+ * Copyright (c) 2004, 2005 Voltaire, Inc. All rights reserved.
+ * Copyright (c) 2002-2010 Mellanox Technologies LTD. All rights reserved.
+ * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+/*
+ * Abstract:
+ * This file contains the passive lock, which synchronizes passive threads.
+ * The passive lock allows multiple readers to access a resource
+ * simultaneously, exclusive from a single thread allowed writing.
+ * Several writer threads are allowed - but only one can write at a given time
+ */
+
+#ifndef _CL_PASSIVE_LOCK_H_
+#define _CL_PASSIVE_LOCK_H_
+#include <complib/cl_types.h>
+#include <pthread.h>
+
+#ifdef __cplusplus
+# define BEGIN_C_DECLS extern "C" {
+# define END_C_DECLS }
+#else /* !__cplusplus */
+# define BEGIN_C_DECLS
+# define END_C_DECLS
+#endif /* __cplusplus */
+
+BEGIN_C_DECLS
+/****h* Component Library/Passive Lock
+* NAME
+* Passive Lock
+*
+* DESCRIPTION
+* The Passive Lock provides synchronization between multiple threads that
+* are sharing the lock with a single thread holding the lock exclusively.
+*
+* Passive lock works exclusively between threads and cannot be used in
+* situations where the caller cannot be put into a waiting state.
+*
+* The passive lock functions operate a cl_plock_t structure which should
+* be treated as opaque and should be manipulated only through the provided
+* functions.
+*
+* SEE ALSO
+* Structures:
+* cl_plock_t
+*
+* Initialization:
+* cl_plock_construct, cl_plock_init, cl_plock_destroy
+*
+* Manipulation
+* cl_plock_acquire, cl_plock_excl_acquire, cl_plock_release
+*********/
+/****s* Component Library: Passive Lock/cl_plock_t
+* NAME
+* cl_plock_t
+*
+* DESCRIPTION
+* Passive Lock structure.
+*
+* The cl_plock_t structure should be treated as opaque and should
+* be manipulated only through the provided functions.
+*
+* SYNOPSIS
+*/
+typedef struct _cl_plock {
+ pthread_rwlock_t lock;
+ cl_state_t state;
+} cl_plock_t;
+/*
+* FIELDS
+* lock
+* Pthread RWLOCK object
+*
+* state
+* Records the current state of the lock, such as initialized,
+* destroying, etc.
+*
+* SEE ALSO
+* Passive Lock
+*********/
+
+/****f* Component Library: Passive Lock/cl_plock_construct
+* NAME
+* cl_plock_construct
+*
+* DESCRIPTION
+* The cl_plock_construct function initializes the state of a
+* passive lock.
+*
+* SYNOPSIS
+*/
+static inline void cl_plock_construct(IN cl_plock_t * const p_lock)
+{
+ CL_ASSERT(p_lock);
+
+ p_lock->state = CL_UNINITIALIZED;
+}
+
+/*
+* PARAMETERS
+* p_lock
+* [in] Pointer to a cl_plock_t structure whose state to initialize.
+*
+* RETURN VALUE
+* This function does not return a value.
+*
+* NOTES
+* Allows calling cl_plock_destroy without first calling cl_plock_init.
+*
+* Calling cl_plock_construct is a prerequisite to calling any other
+* passive lock function except cl_plock_init.
+*
+* SEE ALSO
+* Passive Lock, cl_plock_init, cl_plock_destroy
+*********/
+
+/****f* Component Library: Passive Lock/cl_plock_destroy
+* NAME
+* cl_plock_destroy
+*
+* DESCRIPTION
+* The cl_plock_destroy function performs any necessary cleanup
+* of a passive lock.
+*
+* SYNOPSIS
+*/
+static inline void cl_plock_destroy(IN cl_plock_t * const p_lock)
+{
+ CL_ASSERT(p_lock);
+ p_lock->state = CL_DESTROYING;
+ pthread_rwlock_destroy(&p_lock->lock);
+ p_lock->state = CL_DESTROYED;
+}
+
+/*
+* PARAMETERS
+* p_lock
+* [in] Pointer to a cl_plock_t structure whose state to initialize.
+*
+* RETURN VALUE
+* This function does not return a value.
+*
+* NOTES
+* cl_plock_destroy performs any necessary cleanup of the specified
+* passive lock.
+*
+* This function must only be called if cl_plock_construct or
+* cl_plock_init has been called. The passive lock must not be held
+* when calling this function.
+*
+* SEE ALSO
+* Passive Lock, cl_plock_construct, cl_plock_init
+*********/
+
+/****f* Component Library: Passive Lock/cl_plock_init
+* NAME
+* cl_plock_init
+*
+* DESCRIPTION
+* The cl_plock_init function initializes a passive lock.
+*
+* SYNOPSIS
+*/
+static inline cl_status_t cl_plock_init(IN cl_plock_t * const p_lock)
+{
+ cl_status_t status;
+
+ CL_ASSERT(p_lock);
+ status = pthread_rwlock_init(&p_lock->lock, NULL);
+ if (status)
+ return CL_ERROR;
+ p_lock->state = CL_INITIALIZED;
+ return (CL_SUCCESS);
+}
+
+/*
+* PARAMETERS
+* p_lock
+* [in] Pointer to a cl_plock_t structure to initialize.
+*
+* RETURN VALUES
+* CL_SUCCESS if the passive lock was initialized successfully.
+*
+* CL_ERROR otherwise.
+*
+* NOTES
+* Allows calling cl_plock_acquire, cl_plock_release,
+* cl_plock_excl_acquire
+*
+* SEE ALSO
+* Passive Lock, cl_plock_construct, cl_plock_destroy,
+* cl_plock_excl_acquire, cl_plock_acquire, cl_plock_release
+*********/
+
+/****f* Component Library: Passive Lock/cl_plock_acquire
+* NAME
+* cl_plock_acquire
+*
+* DESCRIPTION
+* The cl_plock_acquire function acquires a passive lock for
+* shared access.
+*
+* SYNOPSIS
+*/
+static inline void cl_plock_acquire(IN cl_plock_t * const p_lock)
+{
+ cl_status_t __attribute__((unused)) status;
+ CL_ASSERT(p_lock);
+ CL_ASSERT(p_lock->state == CL_INITIALIZED);
+
+ status = pthread_rwlock_rdlock(&p_lock->lock);
+ CL_ASSERT(status == 0);
+}
+
+/*
+* PARAMETERS
+* p_lock
+* [in] Pointer to a cl_plock_t structure to acquire.
+*
+* RETURN VALUE
+* This function does not return a value.
+*
+* SEE ALSO
+* Passive Lock, cl_plock_release, cl_plock_excl_acquire
+*********/
+
+/****f* Component Library: Passive Lock/cl_plock_excl_acquire
+* NAME
+* cl_plock_excl_acquire
+*
+* DESCRIPTION
+* The cl_plock_excl_acquire function acquires exclusive access
+* to a passive lock.
+*
+* SYNOPSIS
+*/
+static inline void cl_plock_excl_acquire(IN cl_plock_t * const p_lock)
+{
+ cl_status_t __attribute__((unused)) status;
+
+ CL_ASSERT(p_lock);
+ CL_ASSERT(p_lock->state == CL_INITIALIZED);
+
+ status = pthread_rwlock_wrlock(&p_lock->lock);
+ CL_ASSERT(status == 0);
+}
+
+/*
+* PARAMETERS
+* p_lock
+* [in] Pointer to a cl_plock_t structure to acquire exclusively.
+*
+* RETURN VALUE
+* This function does not return a value.
+*
+* SEE ALSO
+* Passive Lock, cl_plock_release, cl_plock_acquire
+*********/
+
+/****f* Component Library: Passive Lock/cl_plock_release
+* NAME
+* cl_plock_release
+*
+* DESCRIPTION
+* The cl_plock_release function releases a passive lock from
+* shared or exclusive access.
+*
+* SYNOPSIS
+*/
+static inline void cl_plock_release(IN cl_plock_t * const p_lock)
+{
+ cl_status_t __attribute__((unused)) status;
+ CL_ASSERT(p_lock);
+ CL_ASSERT(p_lock->state == CL_INITIALIZED);
+
+ status = pthread_rwlock_unlock(&p_lock->lock);
+ CL_ASSERT(status == 0);
+}
+
+/*
+* PARAMETERS
+* p_lock
+* [in] Pointer to a cl_plock_t structure to release.
+*
+* RETURN VALUE
+* This function does not return a value.
+*
+* SEE ALSO
+* Passive Lock, cl_plock_acquire, cl_plock_excl_acquire
+*********/
+
+END_C_DECLS
+#endif /* _CL_PASSIVE_LOCK_H_ */
diff --git a/contrib/ofed/management/opensm/include/complib/cl_pool.h b/contrib/ofed/opensm/include/complib/cl_pool.h
index f01de96..f01de96 100644
--- a/contrib/ofed/management/opensm/include/complib/cl_pool.h
+++ b/contrib/ofed/opensm/include/complib/cl_pool.h
diff --git a/contrib/ofed/opensm/include/complib/cl_ptr_vector.h b/contrib/ofed/opensm/include/complib/cl_ptr_vector.h
new file mode 100644
index 0000000..c767f31
--- /dev/null
+++ b/contrib/ofed/opensm/include/complib/cl_ptr_vector.h
@@ -0,0 +1,825 @@
+/*
+ * Copyright (c) 2004, 2005 Voltaire, Inc. All rights reserved.
+ * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved.
+ * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+/*
+ * Abstract:
+ * This file contains pointer vector definitions. Pointer Vector provides
+ * dynmically resizable array functionality.
+ */
+
+#ifndef _CL_PTR_VECTOR_H_
+#define _CL_PTR_VECTOR_H_
+
+#include <complib/cl_types.h>
+
+#ifdef __cplusplus
+# define BEGIN_C_DECLS extern "C" {
+# define END_C_DECLS }
+#else /* !__cplusplus */
+# define BEGIN_C_DECLS
+# define END_C_DECLS
+#endif /* __cplusplus */
+
+BEGIN_C_DECLS
+/****h* Component Library/Pointer Vector
+* NAME
+* Pointer Vector
+*
+* DESCRIPTION
+* The Pointer Vector is a self-sizing array of pointers. Like a traditonal
+* array, a pointer vector allows efficient constant time access to elements
+* with a specified index. A pointer vector grows transparently as the
+* user adds elements to the array.
+*
+* The cl_pointer vector_t structure should be treated as opaque and should be
+* manipulated only through the provided functions.
+*
+* SEE ALSO
+* Structures:
+* cl_ptr_vector_t
+*
+* Callbacks:
+* cl_pfn_ptr_vec_apply_t, cl_pfn_ptr_vec_find_t
+*
+* Item Manipulation:
+* cl_ptr_vector_set, cl_ptr_vector_obj
+*
+* Initialization:
+* cl_ptr_vector_construct, cl_ptr_vector_init, cl_ptr_vector_destroy
+*
+* Manipulation:
+* cl_ptr_vector_get_capacity, cl_ptr_vector_set_capacity,
+* cl_ptr_vector_get_size, cl_ptr_vector_set_size, cl_ptr_vector_set_min_size
+* cl_ptr_vector_get_ptr, cl_ptr_vector_get, cl_ptr_vector_at, cl_ptr_vector_set
+*
+* Search:
+* cl_ptr_vector_find_from_start, cl_ptr_vector_find_from_end
+* cl_ptr_vector_apply_func
+*********/
+/****d* Component Library: Pointer Vector/cl_pfn_ptr_vec_apply_t
+* NAME
+* cl_pfn_ptr_vec_apply_t
+*
+* DESCRIPTION
+* The cl_pfn_ptr_vec_apply_t function type defines the prototype for
+* functions used to iterate elements in a pointer vector.
+*
+* SYNOPSIS
+*/
+typedef void
+ (*cl_pfn_ptr_vec_apply_t) (IN const size_t index,
+ IN void *const element, IN void *context);
+/*
+* PARAMETERS
+* index
+* [in] Index of the element.
+*
+* p_element
+* [in] Pointer to an element at the specified index in the pointer vector.
+*
+* context
+* [in] Context provided in a call to cl_ptr_vector_apply_func.
+*
+* RETURN VALUE
+* This function does not return a value.
+*
+* NOTES
+* This function type is provided as function prototype reference for
+* the function passed by users as a parameter to the cl_ptr_vector_apply_func
+* function.
+*
+* SEE ALSO
+* Pointer Vector, cl_ptr_vector_apply_func
+*********/
+
+/****d* Component Library: Pointer Vector/cl_pfn_ptr_vec_find_t
+* NAME
+* cl_pfn_ptr_vec_find_t
+*
+* DESCRIPTION
+* The cl_pfn_ptr_vec_find_t function type defines the prototype for
+* functions used to find elements in a pointer vector.
+*
+* SYNOPSIS
+*/
+typedef cl_status_t
+ (*cl_pfn_ptr_vec_find_t) (IN const size_t index,
+ IN const void *const element, IN void *context);
+/*
+* PARAMETERS
+* index
+* [in] Index of the element.
+*
+* p_element
+* [in] Pointer to an element at the specified index in the
+* pointer vector.
+*
+* context
+* [in] Context provided in a call to cl_ptr_vector_find_from_start or
+* cl_ptr_vector_find_from_end.
+*
+* RETURN VALUES
+* Return CL_SUCCESS if the element was found. This stops pointer vector
+* iteration.
+*
+* CL_NOT_FOUND to continue the pointer vector iteration.
+*
+* NOTES
+* This function type is provided as function prototype reference for the
+* function provided by users as a parameter to the
+* cl_ptr_vector_find_from_start and cl_ptr_vector_find_from_end functions.
+*
+* SEE ALSO
+* Pointer Vector, cl_ptr_vector_find_from_start, cl_ptr_vector_find_from_end
+*********/
+
+/****s* Component Library: Pointer Vector/cl_ptr_vector_t
+* NAME
+* cl_ptr_vector_t
+*
+* DESCRIPTION
+* Pointer Vector structure.
+*
+* The cl_ptr_vector_t structure should be treated as opaque and should be
+* manipulated only through the provided functions.
+*
+* SYNOPSIS
+*/
+typedef struct _cl_ptr_vector {
+ size_t size;
+ size_t grow_size;
+ size_t capacity;
+ const void **p_ptr_array;
+ cl_state_t state;
+} cl_ptr_vector_t;
+/*
+* FIELDS
+* size
+* Number of elements successfully initialized in the pointer vector.
+*
+* grow_size
+* Number of elements to allocate when growing.
+*
+* capacity
+* total # of elements allocated.
+*
+* alloc_list
+* List of allocations.
+*
+* p_ptr_array
+* Internal array of pointers to elements.
+*
+* state
+* State of the pointer vector.
+*
+* SEE ALSO
+* Pointer Vector
+*********/
+
+/****f* Component Library: Pointer Vector/cl_ptr_vector_construct
+* NAME
+* cl_ptr_vector_construct
+*
+* DESCRIPTION
+* The cl_ptr_vector_construct function constructs a pointer vector.
+*
+* SYNOPSIS
+*/
+void cl_ptr_vector_construct(IN cl_ptr_vector_t * const p_vector);
+/*
+* PARAMETERS
+* p_vector
+* [in] Pointer to a cl_ptr_vector_t structure to construct.
+*
+* RETURN VALUE
+* This function does not return a value.
+*
+* NOTES
+* Allows calling cl_ptr_vector_destroy without first calling
+* cl_ptr_vector_init.
+*
+* Calling cl_ptr_vector_construct is a prerequisite to calling any other
+* pointer vector function except cl_ptr_vector_init.
+*
+* SEE ALSO
+* Pointer Vector, cl_ptr_vector_init, cl_ptr_vector_destroy
+*********/
+
+/****f* Component Library: Pointer Vector/cl_ptr_vector_init
+* NAME
+* cl_ptr_vector_init
+*
+* DESCRIPTION
+* The cl_ptr_vector_init function initializes a pointer vector for use.
+*
+* SYNOPSIS
+*/
+cl_status_t
+cl_ptr_vector_init(IN cl_ptr_vector_t * const p_vector,
+ IN const size_t min_size, IN const size_t grow_size);
+/*
+* PARAMETERS
+* p_vector
+* [in] Pointer to a cl_ptr_vector_t structure to inititalize.
+*
+* min_size
+* [in] Initial number of elements.
+*
+* grow_size
+* [in] Number of elements to allocate when incrementally growing
+* the pointer vector. A value of zero disables automatic growth.
+*
+* RETURN VALUES
+* CL_SUCCESS if the pointer vector was initialized successfully.
+*
+* CL_INSUFFICIENT_MEMORY if the initialization failed.
+*
+* SEE ALSO
+* Pointer Vector, cl_ptr_vector_construct, cl_ptr_vector_destroy,
+* cl_ptr_vector_set, cl_ptr_vector_get, cl_ptr_vector_at
+*********/
+
+/****f* Component Library: Pointer Vector/cl_ptr_vector_destroy
+* NAME
+* cl_ptr_vector_destroy
+*
+* DESCRIPTION
+* The cl_ptr_vector_destroy function destroys a pointer vector.
+*
+* SYNOPSIS
+*/
+void cl_ptr_vector_destroy(IN cl_ptr_vector_t * const p_vector);
+/*
+* PARAMETERS
+* p_vector
+* [in] Pointer to a cl_ptr_vector_t structure to destroy.
+*
+* RETURN VALUE
+* This function does not return a value.
+*
+* NOTES
+* cl_ptr_vector_destroy frees all memory allocated for the pointer vector.
+*
+* This function should only be called after a call to cl_ptr_vector_construct
+* or cl_ptr_vector_init.
+*
+* SEE ALSO
+* Pointer Vector, cl_ptr_vector_construct, cl_ptr_vector_init
+*********/
+
+/****f* Component Library: Pointer Vector/cl_ptr_vector_get_capacity
+* NAME
+* cl_ptr_vector_get_capacity
+*
+* DESCRIPTION
+* The cl_ptr_vector_get_capacity function returns the capacity of
+* a pointer vector.
+*
+* SYNOPSIS
+*/
+static inline size_t
+cl_ptr_vector_get_capacity(IN const cl_ptr_vector_t * const p_vector)
+{
+ CL_ASSERT(p_vector);
+ CL_ASSERT(p_vector->state == CL_INITIALIZED);
+
+ return (p_vector->capacity);
+}
+
+/*
+* PARAMETERS
+* p_vector
+* [in] Pointer to a cl_ptr_vector_t structure whose capacity to return.
+*
+* RETURN VALUE
+* Capacity, in elements, of the pointer vector.
+*
+* NOTES
+* The capacity is the number of elements that the pointer vector can store,
+* and can be greater than the number of elements stored. To get the number
+* of elements stored in the pointer vector, use cl_ptr_vector_get_size.
+*
+* SEE ALSO
+* Pointer Vector, cl_ptr_vector_set_capacity, cl_ptr_vector_get_size
+*********/
+
+/****f* Component Library: Pointer Vector/cl_ptr_vector_get_size
+* NAME
+* cl_ptr_vector_get_size
+*
+* DESCRIPTION
+* The cl_ptr_vector_get_size function returns the size of a pointer vector.
+*
+* SYNOPSIS
+*/
+static inline uint32_t
+cl_ptr_vector_get_size(IN const cl_ptr_vector_t * const p_vector)
+{
+ CL_ASSERT(p_vector);
+ CL_ASSERT(p_vector->state == CL_INITIALIZED);
+ return ((uint32_t) p_vector->size);
+
+}
+
+/*
+* PARAMETERS
+* p_vector
+* [in] Pointer to a cl_ptr_vector_t structure whose size to return.
+*
+* RETURN VALUE
+* Size, in elements, of the pointer vector.
+*
+* SEE ALSO
+* Pointer Vector, cl_ptr_vector_set_size, cl_ptr_vector_get_capacity
+*********/
+
+/****f* Component Library: Pointer Vector/cl_ptr_vector_get
+* NAME
+* cl_ptr_vector_get
+*
+* DESCRIPTION
+* The cl_ptr_vector_get function returns the pointer stored in a
+* pointer vector at a specified index.
+*
+* SYNOPSIS
+*/
+static inline void *cl_ptr_vector_get(IN const cl_ptr_vector_t * const p_vector,
+ IN const size_t index)
+{
+ CL_ASSERT(p_vector);
+ CL_ASSERT(p_vector->state == CL_INITIALIZED);
+ CL_ASSERT(p_vector->size > index);
+
+ return ((void *)p_vector->p_ptr_array[index]);
+}
+
+/*
+* PARAMETERS
+* p_vector
+* [in] Pointer to a cl_ptr_vector_t structure from which to get an
+* element.
+*
+* index
+* [in] Index of the element.
+*
+* RETURN VALUE
+* Value of the pointer stored at the specified index.
+*
+* NOTES
+* cl_ptr_vector_get provides constant access times regardless of the index.
+*
+* cl_ptr_vector_get does not perform boundary checking. Callers are
+* responsible for providing an index that is within the range of the pointer
+* vector.
+*
+* SEE ALSO
+* Pointer Vector, cl_ptr_vector_at, cl_ptr_vector_set, cl_ptr_vector_get_size
+*********/
+
+/****f* Component Library: Pointer Vector/cl_ptr_vector_at
+* NAME
+* cl_ptr_vector_at
+*
+* DESCRIPTION
+* The cl_ptr_vector_at function copies an element stored in a pointer
+* vector at a specified index, performing boundary checks.
+*
+* SYNOPSIS
+*/
+cl_status_t
+cl_ptr_vector_at(IN const cl_ptr_vector_t * const p_vector,
+ IN const size_t index, OUT void **const p_element);
+/*
+* PARAMETERS
+* p_vector
+* [in] Pointer to a cl_ptr_vector_t structure from which to get a copy of
+* an element.
+*
+* index
+* [in] Index of the element.
+*
+* p_element
+* [out] Pointer to storage for the pointer element. Contains a copy of
+* the desired pointer upon successful completion of the call.
+*
+* RETURN VALUES
+* CL_SUCCESS if an element was found at the specified index.
+*
+* CL_INVALID_SETTING if the index was out of range.
+*
+* NOTES
+* cl_ptr_vector_at provides constant time access regardless of
+* the index, and performs boundary checking on the pointer vector.
+*
+* Upon success, the p_element parameter contains a copy of the
+* desired element.
+*
+* SEE ALSO
+* Pointer Vector, cl_ptr_vector_get
+*********/
+
+/****f* Component Library: Pointer Vector/cl_ptr_vector_set
+* NAME
+* cl_ptr_vector_set
+*
+* DESCRIPTION
+* The cl_ptr_vector_set function sets the element at the specified index.
+*
+* SYNOPSIS
+*/
+cl_status_t
+cl_ptr_vector_set(IN cl_ptr_vector_t * const p_vector,
+ IN const size_t index, IN const void *const element);
+/*
+* PARAMETERS
+* p_vector
+* [in] Pointer to a cl_ptr_vector_t structure into which to store
+* an element.
+*
+* index
+* [in] Index of the element.
+*
+* element
+* [in] Pointer to store in the pointer vector.
+*
+* RETURN VALUES
+* CL_SUCCESS if the element was successfully set.
+*
+* CL_INSUFFICIENT_MEMORY if the pointer vector could not be resized to
+* accommodate the new element.
+*
+* NOTES
+* cl_ptr_vector_set grows the pointer vector as needed to accommodate
+* the new element, unless the grow_size parameter passed into the
+* cl_ptr_vector_init function was zero.
+*
+* SEE ALSO
+* Pointer Vector, cl_ptr_vector_get
+*********/
+
+/****f* Component Library: Pointer Vector/cl_ptr_vector_insert
+* NAME
+* cl_ptr_vector_insert
+*
+* DESCRIPTION
+* The cl_ptr_vector_insert function inserts an element into a pointer vector.
+*
+* SYNOPSIS
+*/
+static inline cl_status_t
+cl_ptr_vector_insert(IN cl_ptr_vector_t * const p_vector,
+ IN const void *const element,
+ OUT size_t * const p_index OPTIONAL)
+{
+ cl_status_t status;
+
+ CL_ASSERT(p_vector);
+ CL_ASSERT(p_vector->state == CL_INITIALIZED);
+
+ status = cl_ptr_vector_set(p_vector, p_vector->size, element);
+ if (status == CL_SUCCESS && p_index)
+ *p_index = p_vector->size - 1;
+
+ return (status);
+}
+
+/*
+* PARAMETERS
+* p_vector
+* [in] Pointer to a cl_ptr_vector_t structure into which to store
+* an element.
+*
+* element
+* [in] Pointer to store in the pointer vector.
+*
+* p_index
+* [out] Pointer to the index of the element. Valid only if
+* insertion was successful.
+*
+* RETURN VALUES
+* CL_SUCCESS if the element was successfully inserted.
+*
+* CL_INSUFFICIENT_MEMORY if the pointer vector could not be resized to
+* accommodate the new element.
+*
+* NOTES
+* cl_ptr_vector_insert places the new element at the end of
+* the pointer vector.
+*
+* cl_ptr_vector_insert grows the pointer vector as needed to accommodate
+* the new element, unless the grow_size parameter passed into the
+* cl_ptr_vector_init function was zero.
+*
+* SEE ALSO
+* Pointer Vector, cl_ptr_vector_remove, cl_ptr_vector_set
+*********/
+
+/****f* Component Library: Pointer Vector/cl_ptr_vector_remove
+* NAME
+* cl_ptr_vector_remove
+*
+* DESCRIPTION
+* The cl_ptr_vector_remove function removes and returns the pointer stored
+* in a pointer vector at a specified index. Items beyond the removed item
+* are shifted down and the size of the pointer vector is decremented.
+*
+* SYNOPSIS
+*/
+void *cl_ptr_vector_remove(IN cl_ptr_vector_t * const p_vector,
+ IN const size_t index);
+/*
+* PARAMETERS
+* p_vector
+* [in] Pointer to a cl_ptr_vector_t structure from which to get an
+* element.
+*
+* index
+* [in] Index of the element.
+*
+* RETURN VALUE
+* Value of the pointer stored at the specified index.
+*
+* NOTES
+* cl_ptr_vector_get does not perform boundary checking. Callers are
+* responsible for providing an index that is within the range of the pointer
+* vector.
+*
+* SEE ALSO
+* Pointer Vector, cl_ptr_vector_insert, cl_ptr_vector_get_size
+*********/
+
+/****f* Component Library: Pointer Vector/cl_ptr_vector_set_capacity
+* NAME
+* cl_ptr_vector_set_capacity
+*
+* DESCRIPTION
+* The cl_ptr_vector_set_capacity function reserves memory in a
+* pointer vector for a specified number of pointers.
+*
+* SYNOPSIS
+*/
+cl_status_t
+cl_ptr_vector_set_capacity(IN cl_ptr_vector_t * const p_vector,
+ IN const size_t new_capacity);
+/*
+* PARAMETERS
+* p_vector
+* [in] Pointer to a cl_ptr_vector_t structure whose capacity to set.
+*
+* new_capacity
+* [in] Total number of elements for which the pointer vector should
+* allocate memory.
+*
+* RETURN VALUES
+* CL_SUCCESS if the capacity was successfully set.
+*
+* CL_INSUFFICIENT_MEMORY if there was not enough memory to satisfy the
+* operation. The pointer vector is left unchanged.
+*
+* NOTES
+* cl_ptr_vector_set_capacity increases the capacity of the pointer vector.
+* It does not change the size of the pointer vector. If the requested
+* capacity is less than the current capacity, the pointer vector is left
+* unchanged.
+*
+* SEE ALSO
+* Pointer Vector, cl_ptr_vector_get_capacity, cl_ptr_vector_set_size,
+* cl_ptr_vector_set_min_size
+*********/
+
+/****f* Component Library: Pointer Vector/cl_ptr_vector_set_size
+* NAME
+* cl_ptr_vector_set_size
+*
+* DESCRIPTION
+* The cl_ptr_vector_set_size function resizes a pointer vector, either
+* increasing or decreasing its size.
+*
+* SYNOPSIS
+*/
+cl_status_t
+cl_ptr_vector_set_size(IN cl_ptr_vector_t * const p_vector,
+ IN const size_t size);
+/*
+* PARAMETERS
+* p_vector
+* [in] Pointer to a cl_ptr_vector_t structure whose size to set.
+*
+* size
+* [in] Number of elements desired in the pointer vector.
+*
+* RETURN VALUES
+* CL_SUCCESS if the size of the pointer vector was set successfully.
+*
+* CL_INSUFFICIENT_MEMORY if there was not enough memory to complete the
+* operation. The pointer vector is left unchanged.
+*
+* NOTES
+* cl_ptr_vector_set_size sets the pointer vector to the specified size.
+* If size is smaller than the current size of the pointer vector, the size
+* is reduced.
+*
+* This function can only fail if size is larger than the current capacity.
+*
+* SEE ALSO
+* Pointer Vector, cl_ptr_vector_get_size, cl_ptr_vector_set_min_size,
+* cl_ptr_vector_set_capacity
+*********/
+
+/****f* Component Library: Pointer Vector/cl_ptr_vector_set_min_size
+* NAME
+* cl_ptr_vector_set_min_size
+*
+* DESCRIPTION
+* The cl_ptr_vector_set_min_size function resizes a pointer vector to a
+* specified size if the pointer vector is smaller than the specified size.
+*
+* SYNOPSIS
+*/
+cl_status_t
+cl_ptr_vector_set_min_size(IN cl_ptr_vector_t * const p_vector,
+ IN const size_t min_size);
+/*
+* PARAMETERS
+* p_vector
+* [in] Pointer to a cl_ptr_vector_t structure whose minimum size to set.
+*
+* min_size
+* [in] Minimum number of elements that the pointer vector should contain.
+*
+* RETURN VALUES
+* CL_SUCCESS if the pointer vector size is greater than or equal to min_size.
+* This could indicate that the pointer vector's capacity was increased to
+* min_size or that the pointer vector was already of sufficient size.
+*
+* CL_INSUFFICIENT_MEMORY if there was not enough memory to resize the
+* pointer vector. The pointer vector is left unchanged.
+*
+* NOTES
+* If min_size is smaller than the current size of the pointer vector,
+* the pointer vector is unchanged. The pointer vector is unchanged if the
+* size could not be changed due to insufficient memory being available to
+* perform the operation.
+*
+* SEE ALSO
+* Pointer Vector, cl_ptr_vector_get_size, cl_ptr_vector_set_size,
+* cl_ptr_vector_set_capacity
+*********/
+
+/****f* Component Library: Pointer Vector/cl_ptr_vector_apply_func
+* NAME
+* cl_ptr_vector_apply_func
+*
+* DESCRIPTION
+* The cl_ptr_vector_apply_func function invokes a specified function for
+* every element in a pointer vector.
+*
+* SYNOPSIS
+*/
+void
+cl_ptr_vector_apply_func(IN const cl_ptr_vector_t * const p_vector,
+ IN cl_pfn_ptr_vec_apply_t pfn_callback,
+ IN const void *const context);
+/*
+* PARAMETERS
+* p_vector
+* [in] Pointer to a cl_ptr_vector_t structure whose elements to iterate.
+*
+* pfn_callback
+* [in] Function invoked for every element in the array.
+* See the cl_pfn_ptr_vec_apply_t function type declaration for details
+* about the callback function.
+*
+* context
+* [in] Value to pass to the callback function.
+*
+* RETURN VALUE
+* This function does not return a value.
+*
+* NOTES
+* cl_ptr_vector_apply_func invokes the specified function for every element
+* in the pointer vector, starting from the beginning of the pointer vector.
+*
+* SEE ALSO
+* Pointer Vector, cl_ptr_vector_find_from_start, cl_ptr_vector_find_from_end,
+* cl_pfn_ptr_vec_apply_t
+*********/
+
+/****f* Component Library: Pointer Vector/cl_ptr_vector_find_from_start
+* NAME
+* cl_ptr_vector_find_from_start
+*
+* DESCRIPTION
+* The cl_ptr_vector_find_from_start function uses a specified function to
+* search for elements in a pointer vector starting from the lowest index.
+*
+* SYNOPSIS
+*/
+size_t
+cl_ptr_vector_find_from_start(IN const cl_ptr_vector_t * const p_vector,
+ IN cl_pfn_ptr_vec_find_t pfn_callback,
+ IN const void *const context);
+/*
+* PARAMETERS
+* p_vector
+* [in] Pointer to a cl_ptr_vector_t structure to inititalize.
+*
+* pfn_callback
+* [in] Function invoked to determine if a match was found.
+* See the cl_pfn_ptr_vec_find_t function type declaration for details
+* about the callback function.
+*
+* context
+* [in] Value to pass to the callback function.
+*
+* RETURN VALUES
+* Index of the element, if found.
+*
+* Size of the pointer vector if the element was not found.
+*
+* NOTES
+* cl_ptr_vector_find_from_start does not remove the found element from
+* the pointer vector. The index of the element is returned when the function
+* provided by the pfn_callback parameter returns CL_SUCCESS.
+*
+* SEE ALSO
+* Pointer Vector, cl_ptr_vector_find_from_end, cl_ptr_vector_apply_func,
+* cl_pfn_ptr_vec_find_t
+*********/
+
+/****f* Component Library: Pointer Vector/cl_ptr_vector_find_from_end
+* NAME
+* cl_ptr_vector_find_from_end
+*
+* DESCRIPTION
+* The cl_ptr_vector_find_from_end function uses a specified function to
+* search for elements in a pointer vector starting from the highest index.
+*
+* SYNOPSIS
+*/
+size_t
+cl_ptr_vector_find_from_end(IN const cl_ptr_vector_t * const p_vector,
+ IN cl_pfn_ptr_vec_find_t pfn_callback,
+ IN const void *const context);
+/*
+* PARAMETERS
+* p_vector
+* [in] Pointer to a cl_ptr_vector_t structure to inititalize.
+*
+* pfn_callback
+* [in] Function invoked to determine if a match was found.
+* See the cl_pfn_ptr_vec_find_t function type declaration for details
+* about the callback function.
+*
+* context
+* [in] Value to pass to the callback function.
+*
+* RETURN VALUES
+* Index of the element, if found.
+*
+* Size of the pointer vector if the element was not found.
+*
+* NOTES
+* cl_ptr_vector_find_from_end does not remove the found element from
+* the pointer vector. The index of the element is returned when the function
+* provided by the pfn_callback parameter returns CL_SUCCESS.
+*
+* SEE ALSO
+* Pointer Vector, cl_ptr_vector_find_from_start, cl_ptr_vector_apply_func,
+* cl_pfn_ptr_vec_find_t
+*********/
+
+END_C_DECLS
+#endif /* _CL_PTR_VECTOR_H_ */
diff --git a/contrib/ofed/management/opensm/include/complib/cl_qcomppool.h b/contrib/ofed/opensm/include/complib/cl_qcomppool.h
index 58862e3..58862e3 100644
--- a/contrib/ofed/management/opensm/include/complib/cl_qcomppool.h
+++ b/contrib/ofed/opensm/include/complib/cl_qcomppool.h
diff --git a/contrib/ofed/management/opensm/include/complib/cl_qlist.h b/contrib/ofed/opensm/include/complib/cl_qlist.h
index accbd98..accbd98 100644
--- a/contrib/ofed/management/opensm/include/complib/cl_qlist.h
+++ b/contrib/ofed/opensm/include/complib/cl_qlist.h
diff --git a/contrib/ofed/management/opensm/include/complib/cl_qmap.h b/contrib/ofed/opensm/include/complib/cl_qmap.h
index 130c2ef..130c2ef 100644
--- a/contrib/ofed/management/opensm/include/complib/cl_qmap.h
+++ b/contrib/ofed/opensm/include/complib/cl_qmap.h
diff --git a/contrib/ofed/management/opensm/include/complib/cl_qpool.h b/contrib/ofed/opensm/include/complib/cl_qpool.h
index f144cb3..f144cb3 100644
--- a/contrib/ofed/management/opensm/include/complib/cl_qpool.h
+++ b/contrib/ofed/opensm/include/complib/cl_qpool.h
diff --git a/contrib/ofed/opensm/include/complib/cl_spinlock.h b/contrib/ofed/opensm/include/complib/cl_spinlock.h
new file mode 100644
index 0000000..4de6f26
--- /dev/null
+++ b/contrib/ofed/opensm/include/complib/cl_spinlock.h
@@ -0,0 +1,217 @@
+/*
+ * Copyright (c) 2004, 2005 Voltaire, Inc. All rights reserved.
+ * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved.
+ * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+/*
+ * Abstract:
+ * Declaration of spin lock object.
+ */
+
+#ifndef _CL_SPINLOCK_H_
+#define _CL_SPINLOCK_H_
+
+#include <complib/cl_spinlock_osd.h>
+
+#ifdef __cplusplus
+# define BEGIN_C_DECLS extern "C" {
+# define END_C_DECLS }
+#else /* !__cplusplus */
+# define BEGIN_C_DECLS
+# define END_C_DECLS
+#endif /* __cplusplus */
+
+BEGIN_C_DECLS
+/****h* Public/Spinlock
+* NAME
+* Spinlock
+*
+* DESCRIPTION
+* Spinlock provides synchronization between threads for exclusive access to
+* a resource.
+*
+* The spinlock functions manipulate a cl_spinlock_t structure which should
+* be treated as opaque and should be manipulated only through the provided
+* functions.
+*
+* SEE ALSO
+* Structures:
+* cl_spinlock_t
+*
+* Initialization:
+* cl_spinlock_construct, cl_spinlock_init, cl_spinlock_destroy
+*
+* Manipulation
+* cl_spinlock_acquire, cl_spinlock_release
+*********/
+/****f* Component Library: Spinlock/cl_spinlock_construct
+* NAME
+* cl_spinlock_construct
+*
+* DESCRIPTION
+* The cl_spinlock_construct function initializes the state of a
+* spin lock.
+*
+* SYNOPSIS
+*/
+void cl_spinlock_construct(IN cl_spinlock_t * const p_spinlock);
+/*
+* PARAMETERS
+* p_spin_lock
+* [in] Pointer to a spin lock structure whose state to initialize.
+*
+* RETURN VALUE
+* This function does not return a value.
+*
+* NOTES
+* Allows calling cl_spinlock_destroy without first calling
+* cl_spinlock_init.
+*
+* Calling cl_spinlock_construct is a prerequisite to calling any other
+* spin lock function except cl_spinlock_init.
+*
+* SEE ALSO
+* Spinlock, cl_spinlock_init, cl_spinlock_destroy
+*********/
+
+/****f* Component Library: Spinlock/cl_spinlock_init
+* NAME
+* cl_spinlock_init
+*
+* DESCRIPTION
+* The cl_spinlock_init function initializes a spin lock for use.
+*
+* SYNOPSIS
+*/
+cl_status_t cl_spinlock_init(IN cl_spinlock_t * const p_spinlock);
+/*
+* PARAMETERS
+* p_spin_lock
+* [in] Pointer to a spin lock structure to initialize.
+*
+* RETURN VALUES
+* CL_SUCCESS if initialization succeeded.
+*
+* CL_ERROR if initialization failed. Callers should call
+* cl_spinlock_destroy to clean up any resources allocated during
+* initialization.
+*
+* NOTES
+* Initialize the spin lock structure. Allows calling cl_spinlock_aquire
+* and cl_spinlock_release.
+*
+* SEE ALSO
+* Spinlock, cl_spinlock_construct, cl_spinlock_destroy,
+* cl_spinlock_acquire, cl_spinlock_release
+*********/
+
+/****f* Component Library: Spinlock/cl_spinlock_destroy
+* NAME
+* cl_spinlock_destroy
+*
+* DESCRIPTION
+* The cl_spinlock_destroy function performs all necessary cleanup of a
+* spin lock.
+*
+* SYNOPSIS
+*/
+void cl_spinlock_destroy(IN cl_spinlock_t * const p_spinlock);
+/*
+* PARAMETERS
+* p_spin_lock
+* [in] Pointer to a spin lock structure to destroy.
+*
+* RETURN VALUE
+* This function does not return a value.
+*
+* NOTES
+* Performs any necessary cleanup of a spin lock. This function must only
+* be called if either cl_spinlock_construct or cl_spinlock_init has been
+* called.
+*
+* SEE ALSO
+* Spinlock, cl_spinlock_construct, cl_spinlock_init
+*********/
+
+/****f* Component Library: Spinlock/cl_spinlock_acquire
+* NAME
+* cl_spinlock_acquire
+*
+* DESCRIPTION
+* The cl_spinlock_acquire function acquires a spin lock.
+* This version of lock does not prevent an interrupt from
+* occuring on the processor on which the code is being
+* executed.
+*
+* SYNOPSIS
+*/
+void cl_spinlock_acquire(IN cl_spinlock_t * const p_spinlock);
+/*
+* PARAMETERS
+* p_spin_lock
+* [in] Pointer to a spin lock structure to acquire.
+*
+* RETURN VALUE
+* This function does not return a value.
+*
+* SEE ALSO
+* Spinlock, cl_spinlock_release
+*********/
+
+/****f* Component Library: Spinlock/cl_spinlock_release
+* NAME
+* cl_spinlock_release
+*
+* DESCRIPTION
+* The cl_spinlock_release function releases a spin lock object.
+*
+* SYNOPSIS
+*/
+void cl_spinlock_release(IN cl_spinlock_t * const p_spinlock);
+/*
+* PARAMETERS
+* p_spin_lock
+* [in] Pointer to a spin lock structure to release.
+*
+* RETURN VALUE
+* This function does not return a value.
+*
+* NOTES
+* Releases a spin lock after a call to cl_spinlock_acquire.
+*
+* SEE ALSO
+* Spinlock, cl_spinlock_acquire
+*********/
+
+END_C_DECLS
+#endif /* _CL_SPINLOCK_H_ */
diff --git a/contrib/ofed/management/opensm/include/complib/cl_spinlock_osd.h b/contrib/ofed/opensm/include/complib/cl_spinlock_osd.h
index beb6405..beb6405 100644
--- a/contrib/ofed/management/opensm/include/complib/cl_spinlock_osd.h
+++ b/contrib/ofed/opensm/include/complib/cl_spinlock_osd.h
diff --git a/contrib/ofed/management/opensm/include/complib/cl_thread.h b/contrib/ofed/opensm/include/complib/cl_thread.h
index 0a622a1..0a622a1 100644
--- a/contrib/ofed/management/opensm/include/complib/cl_thread.h
+++ b/contrib/ofed/opensm/include/complib/cl_thread.h
diff --git a/contrib/ofed/management/opensm/include/complib/cl_thread_osd.h b/contrib/ofed/opensm/include/complib/cl_thread_osd.h
index ad7df90..ad7df90 100644
--- a/contrib/ofed/management/opensm/include/complib/cl_thread_osd.h
+++ b/contrib/ofed/opensm/include/complib/cl_thread_osd.h
diff --git a/contrib/ofed/opensm/include/complib/cl_threadpool.h b/contrib/ofed/opensm/include/complib/cl_threadpool.h
new file mode 100644
index 0000000..3ee6cf4
--- /dev/null
+++ b/contrib/ofed/opensm/include/complib/cl_threadpool.h
@@ -0,0 +1,248 @@
+/*
+ * Copyright (c) 2004-2007 Voltaire, Inc. All rights reserved.
+ * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved.
+ * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+/*
+ * Abstract:
+ * Declaration of thread pool.
+ */
+
+#ifndef _CL_THREAD_POOL_H_
+#define _CL_THREAD_POOL_H_
+
+#include <pthread.h>
+#include <complib/cl_types.h>
+#include <complib/cl_thread.h>
+
+#ifdef __cplusplus
+# define BEGIN_C_DECLS extern "C" {
+# define END_C_DECLS }
+#else /* !__cplusplus */
+# define BEGIN_C_DECLS
+# define END_C_DECLS
+#endif /* __cplusplus */
+
+BEGIN_C_DECLS
+/****h* Component Library/Thread Pool
+* NAME
+* Thread Pool
+*
+* DESCRIPTION
+* The Thread Pool manages a user specified number of threads.
+*
+* Each thread in the thread pool waits for a user initiated signal before
+* invoking a user specified callback function. All threads in the thread
+* pool invoke the same callback function.
+*
+* The thread pool functions operate on a cl_thread_pool_t structure which
+* should be treated as opaque, and should be manipulated only through the
+* provided functions.
+*
+* SEE ALSO
+* Structures:
+* cl_thread_pool_t
+*
+* Initialization:
+* cl_thread_pool_init, cl_thread_pool_destroy
+*
+* Manipulation
+* cl_thread_pool_signal
+*********/
+/****s* Component Library: Thread Pool/cl_thread_pool_t
+* NAME
+* cl_thread_pool_t
+*
+* DESCRIPTION
+* Thread pool structure.
+*
+* The cl_thread_pool_t structure should be treated as opaque, and should be
+* manipulated only through the provided functions.
+*
+* SYNOPSIS
+*/
+typedef struct _cl_thread_pool {
+ void (*pfn_callback) (void *);
+ void *context;
+ unsigned running_count;
+ unsigned events;
+ pthread_cond_t cond;
+ pthread_mutex_t mutex;
+ pthread_t *tid;
+} cl_thread_pool_t;
+/*
+* FIELDS
+* pfn_callback
+* Callback function for the thread to invoke.
+*
+* context
+* Context to pass to the thread callback function.
+*
+* running_count
+* Number of threads running.
+*
+* events
+* events counter
+*
+* mutex
+* mutex for cond variable protection
+*
+* cond
+* conditional variable to signal an event to thread
+*
+* tid
+* array of allocated thread ids.
+*
+* SEE ALSO
+* Thread Pool
+*********/
+
+/****f* Component Library: Thread Pool/cl_thread_pool_init
+* NAME
+* cl_thread_pool_init
+*
+* DESCRIPTION
+* The cl_thread_pool_init function creates the threads to be
+* managed by a thread pool.
+*
+* SYNOPSIS
+*/
+cl_status_t
+cl_thread_pool_init(IN cl_thread_pool_t * const p_thread_pool,
+ IN unsigned count,
+ IN void (*pfn_callback) (void *),
+ IN void *context, IN const char *const name);
+/*
+* PARAMETERS
+* p_thread_pool
+* [in] Pointer to a thread pool structure to initialize.
+*
+* thread_count
+* [in] Number of threads to be managed by the thread pool.
+*
+* pfn_callback
+* [in] Address of a function to be invoked by a thread.
+* See the cl_pfn_thread_callback_t function type definition for
+* details about the callback function.
+*
+* context
+* [in] Value to pass to the callback function.
+*
+* name
+* [in] Name to associate with the threads. The name may be up to 16
+* characters, including a terminating null character. All threads
+* created in the pool have the same name.
+*
+* RETURN VALUES
+* CL_SUCCESS if the thread pool creation succeeded.
+*
+* CL_INSUFFICIENT_MEMORY if there was not enough memory to inititalize
+* the thread pool.
+*
+* CL_ERROR if the threads could not be created.
+*
+* NOTES
+* cl_thread_pool_init creates and starts the specified number of threads.
+* If thread_count is zero, the thread pool creates as many threads as there
+* are processors in the system.
+*
+* SEE ALSO
+* Thread Pool, cl_thread_pool_destroy,
+* cl_thread_pool_signal, cl_pfn_thread_callback_t
+*********/
+
+/****f* Component Library: Thread Pool/cl_thread_pool_destroy
+* NAME
+* cl_thread_pool_destroy
+*
+* DESCRIPTION
+* The cl_thread_pool_destroy function performs any necessary cleanup
+* for a thread pool.
+*
+* SYNOPSIS
+*/
+void cl_thread_pool_destroy(IN cl_thread_pool_t * const p_thread_pool);
+/*
+* PARAMETERS
+* p_thread_pool
+* [in] Pointer to a thread pool structure to destroy.
+*
+* RETURN VALUE
+* This function does not return a value.
+*
+* NOTES
+* This function blocks until all threads exit, and must therefore not
+* be called from any of the thread pool's threads. Because of its blocking
+* nature, callers of cl_thread_pool_destroy must ensure that entering a wait
+* state is valid from the calling thread context.
+*
+* This function should only be called after a call to
+* cl_thread_pool_init.
+*
+* SEE ALSO
+* Thread Pool, cl_thread_pool_init
+*********/
+
+/****f* Component Library: Thread Pool/cl_thread_pool_signal
+* NAME
+* cl_thread_pool_signal
+*
+* DESCRIPTION
+* The cl_thread_pool_signal function signals a single thread of
+* the thread pool to invoke the thread pool's callback function.
+*
+* SYNOPSIS
+*/
+cl_status_t cl_thread_pool_signal(IN cl_thread_pool_t * const p_thread_pool);
+/*
+* PARAMETERS
+* p_thread_pool
+* [in] Pointer to a thread pool structure to signal.
+*
+* RETURN VALUES
+* CL_SUCCESS if the thread pool was successfully signalled.
+*
+* CL_ERROR otherwise.
+*
+* NOTES
+* Each call to this function wakes up at most one waiting thread in
+* the thread pool.
+*
+* If all threads are running, cl_thread_pool_signal has no effect.
+*
+* SEE ALSO
+* Thread Pool
+*********/
+
+END_C_DECLS
+#endif /* _CL_THREAD_POOL_H_ */
diff --git a/contrib/ofed/management/opensm/include/complib/cl_timer.h b/contrib/ofed/opensm/include/complib/cl_timer.h
index 194e374..194e374 100644
--- a/contrib/ofed/management/opensm/include/complib/cl_timer.h
+++ b/contrib/ofed/opensm/include/complib/cl_timer.h
diff --git a/contrib/ofed/management/opensm/include/complib/cl_timer_osd.h b/contrib/ofed/opensm/include/complib/cl_timer_osd.h
index ed36fea..ed36fea 100644
--- a/contrib/ofed/management/opensm/include/complib/cl_timer_osd.h
+++ b/contrib/ofed/opensm/include/complib/cl_timer_osd.h
diff --git a/contrib/ofed/opensm/include/complib/cl_types.h b/contrib/ofed/opensm/include/complib/cl_types.h
new file mode 100644
index 0000000..a773e51
--- /dev/null
+++ b/contrib/ofed/opensm/include/complib/cl_types.h
@@ -0,0 +1,455 @@
+/*
+ * Copyright (c) 2004-2009 Voltaire, Inc. All rights reserved.
+ * Copyright (c) 2002-2010 Mellanox Technologies LTD. All rights reserved.
+ * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+/*
+ * Abstract:
+ * Defines standard return codes, keywords, macros, and debug levels.
+ */
+
+#ifdef __WIN__
+#pragma warning(disable : 4996)
+#endif
+
+#ifndef _CL_TYPES_H_
+#define _CL_TYPES_H_
+
+#ifdef __cplusplus
+# define BEGIN_C_DECLS extern "C" {
+# define END_C_DECLS }
+#else /* !__cplusplus */
+# define BEGIN_C_DECLS
+# define END_C_DECLS
+#endif /* __cplusplus */
+
+BEGIN_C_DECLS
+#include <complib/cl_types_osd.h>
+#include <stddef.h>
+typedef uint16_t net16_t;
+typedef uint32_t net32_t;
+typedef uint64_t net64_t;
+
+/* explicit cast of void* to uint32_t */
+#ifndef ASSERT_VOIDP2UINTN
+#if __WORDSIZE == 64
+#define ASSERT_VOIDP2UINTN(var) \
+ CL_ASSERT( (intptr_t)var <= 0xffffffffffffffffL )
+#else /* __WORDSIZE == 64 */
+#if __WORDSIZE == 32
+ /* need to cast carefully to avoid the warining of un-needed check */
+#define ASSERT_VOIDP2UINTN(var) \
+ CL_ASSERT( (intptr_t)var <= 0x100000000ULL )
+#else /* __WORDSIZE == 32 */
+#error "Need to know WORDSIZE to tell how to cast to unsigned long int"
+#endif /* __WORDSIZE == 32 */
+#endif /* __WORDSIZE == 64 */
+#endif
+
+/* explicit casting of void* to long */
+#ifndef CAST_P2LONG
+#define CAST_P2LONG(var) ((intptr_t)(var))
+#endif
+
+/****d* Component Library: Pointer Manipulation/offsetof
+* NAME
+* offsetof
+*
+* DESCRIPTION
+* The offsetof macro returns the offset of a member within a structure.
+*
+* SYNOPSIS
+* uintptr_t
+* offsetof(
+* IN TYPE,
+* IN MEMBER );
+*
+* PARAMETERS
+* TYPE
+* [in] Name of the structure containing the specified member.
+*
+* MEMBER
+* [in] Name of the member whose offset in the specified structure
+* is to be returned.
+*
+* RETURN VALUE
+* Number of bytes from the beginning of the structure to the
+* specified member.
+*
+* SEE ALSO
+* PARENT_STRUCT
+*********/
+#ifndef offsetof
+#define offsetof(TYPE, MEMBER) ((uintptr_t) &((TYPE *)0)->MEMBER)
+#endif
+
+/****d* Component Library: Pointer Manipulation/PARENT_STRUCT
+* NAME
+* PARENT_STRUCT
+*
+* DESCRIPTION
+* The PARENT_STRUCT macro returns a pointer to a structure
+* given a name and pointer to one of its members.
+*
+* SYNOPSIS
+* PARENT_TYPE*
+* PARENT_STRUCT(
+* IN void* const p_member,
+* IN PARENT_TYPE,
+* IN MEMBER_NAME );
+*
+* PARAMETERS
+* p_member
+* [in] Pointer to the MEMBER_NAME member of a PARENT_TYPE structure.
+*
+* PARENT_TYPE
+* [in] Name of the structure containing the specified member.
+*
+* MEMBER_NAME
+* [in] Name of the member whose address is passed in the p_member
+* parameter.
+*
+* RETURN VALUE
+* Pointer to a structure of type PARENT_TYPE whose MEMBER_NAME member is
+* located at p_member.
+*
+* SEE ALSO
+* offsetof
+*********/
+#define PARENT_STRUCT(p_member, PARENT_TYPE, MEMBER_NAME) \
+ ((PARENT_TYPE*)((uint8_t*)(p_member) - offsetof(PARENT_TYPE, MEMBER_NAME)))
+
+/****d* Component Library/Parameter Keywords
+* NAME
+* Parameter Keywords
+*
+* DESCRIPTION
+* The Parameter Keywords can be used to clarify the usage of function
+* parameters to users.
+*
+* VALUES
+* IN
+* Designates that the parameter is used as input to a function.
+*
+* OUT
+* Designates that the parameter's value will be set by the function.
+*
+* OPTIONAL
+* Designates that the parameter is optional, and may be NULL.
+* The OPTIONAL keyword, if used, follows the parameter name.
+*
+* EXAMPLE
+* // Function declaration.
+* void*
+* my_func(
+* IN void* const p_param1,
+* OUT void** const p_handle OPTIONAL );
+*
+* NOTES
+* Multiple keywords can apply to a single parameter. The IN and OUT
+* keywords precede the parameter type. The OPTIONAL
+* keyword, if used, follows the parameter name.
+*********/
+#ifndef IN
+#define IN /* Function input parameter */
+#endif
+#ifndef OUT
+#define OUT /* Function output parameter */
+#endif
+#ifndef OPTIONAL
+#define OPTIONAL /* Optional function parameter - NULL if not used */
+#endif
+
+/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%% Function Returns And Completion Codes %%
+%% %%
+%% The text for any addition to this enumerated type must be added to the %%
+%% string array defined in <cl_statustext.c>. %%
+%% %%
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
+
+/****d* Component Library/Data Types
+* NAME
+* Data Types
+*
+* DESCRIPTION
+* The component library provides and uses explicitly sized types.
+*
+* VALUES
+* char
+* 8-bit, defined by compiler.
+*
+* void
+* 0-bit, defined by compiler.
+*
+* int8_t
+* 8-bit signed integer.
+*
+* uint8_t
+* 8-bit unsigned integer.
+*
+* int16_t
+* 16-bit signed integer.
+*
+* uint16_t
+* 16-bit unsigned integer.
+*
+* net16_t
+* 16-bit network byte order value.
+*
+* int32_t
+* 32-bit signed integer.
+*
+* uint32_t
+* 32-bit unsigned integer.
+*
+* net32_t
+* 32-bit network byte order value.
+*
+* int64_t
+* 64-bit signed integer.
+*
+* uint64_t
+* 64-bit unsigned integer.
+*
+* net64_t
+* 64-bit network byte order value.
+*
+* boolean_t
+* integral sized. Set to TRUE or FALSE and used in logical expressions.
+*
+* NOTES
+* Pointer types are not defined as these provide no value and can potentially
+* lead to naming confusion.
+*********/
+
+/****d* Component Library: Data Types/cl_status_t
+* NAME
+* cl_status_t
+*
+* DESCRIPTION
+* The cl_status_t return types are used by the component library to
+* provide detailed function return values.
+*
+* SYNOPSIS
+*/
+#define CL_SUCCESS 0
+#define CL_ERROR 1
+#define CL_INVALID_STATE 2
+#define CL_INVALID_OPERATION 3
+#define CL_INVALID_SETTING 4
+#define CL_INVALID_PARAMETER 5
+#define CL_INSUFFICIENT_RESOURCES 6
+#define CL_INSUFFICIENT_MEMORY 7
+#define CL_INVALID_PERMISSION 8
+#define CL_COMPLETED 9
+#define CL_NOT_DONE 10
+#define CL_PENDING 11
+#define CL_TIMEOUT 12
+#define CL_CANCELED 13
+#define CL_REJECT 14
+#define CL_OVERRUN 15
+#define CL_NOT_FOUND 16
+#define CL_UNAVAILABLE 17
+#define CL_BUSY 18
+#define CL_DISCONNECT 19
+#define CL_DUPLICATE 20
+#define CL_STATUS_COUNT 21 /* should be the last value */
+
+typedef int cl_status_t;
+/*
+* SEE ALSO
+* Data Types, CL_STATUS_MSG
+*********/
+
+/* Status values above converted to text for easier printing. */
+extern const char *cl_status_text[];
+
+#ifndef cl_panic
+/****f* Component Library: Error Trapping/cl_panic
+* NAME
+* cl_panic
+*
+* DESCRIPTION
+* Halts execution of the current process. Halts the system if called in
+* from the kernel.
+*
+* SYNOPSIS
+*/
+void cl_panic(IN const char *const message, IN ...);
+/*
+* PARAMETERS
+* message
+* [in] ANSI string formatted identically as for a call to the standard C
+* function printf describing the cause for the panic.
+*
+* ...
+* [in] Extra parameters for string formatting, as defined for the
+* standard C function printf.
+*
+* RETURN VALUE
+* This function does not return.
+*
+* NOTES
+* The formatting of the message string is the same as for printf
+*
+* cl_panic sends the message to the current message logging target.
+*********/
+#endif /* cl_panic */
+
+/****d* Component Library: Data Types/CL_STATUS_MSG
+* NAME
+* CL_STATUS_MSG
+*
+* DESCRIPTION
+* The CL_STATUS_MSG macro returns a textual representation of
+* an cl_status_t code.
+*
+* SYNOPSIS
+* const char*
+* CL_STATUS_MSG(
+* IN cl_status_t errcode );
+*
+* PARAMETERS
+* errcode
+* [in] cl_status_t code for which to return a text representation.
+*
+* RETURN VALUE
+* Pointer to a string containing a textual representation of the errcode
+* parameter.
+*
+* NOTES
+* This function performs boundary checking on the cl_status_t value,
+* masking off the upper 24-bits. If the value is out of bounds, the string
+* "invalid status code" is returned.
+*
+* SEE ALSO
+* cl_status_t
+*********/
+#define CL_STATUS_MSG( errcode ) \
+ ((errcode < CL_STATUS_COUNT)?cl_status_text[errcode]:"invalid status code")
+
+#if !defined( FALSE )
+#define FALSE 0
+#endif /* !defined( FALSE ) */
+
+#if !defined( TRUE )
+#define TRUE (!FALSE)
+#endif /* !defined( TRUE ) */
+
+/****d* Component Library: Unreferenced Parameters/UNUSED_PARAM
+* NAME
+* UNUSED_PARAM
+*
+* DESCRIPTION
+* The UNUSED_PARAM macro can be used to eliminates compiler warnings related
+* to intentionally unused formal parameters in function implementations.
+*
+* SYNOPSIS
+* UNUSED_PARAM( P )
+*
+* EXAMPLE
+* void my_func( int32_t value )
+* {
+* UNUSED_PARAM( value );
+* }
+*********/
+
+/****d* Component Library/Object States
+* NAME
+* Object States
+*
+* DESCRIPTION
+* The object states enumerated type defines the valid states of components.
+*
+* SYNOPSIS
+*/
+typedef enum _cl_state {
+ CL_UNINITIALIZED = 1,
+ CL_INITIALIZED,
+ CL_DESTROYING,
+ CL_DESTROYED
+} cl_state_t;
+/*
+* VALUES
+* CL_UNINITIALIZED
+* Indicates that initialization was not invoked successfully.
+*
+* CL_INITIALIZED
+* Indicates initialization was successful.
+*
+* CL_DESTROYING
+* Indicates that the object is undergoing destruction.
+*
+* CL_DESTROYED
+* Indicates that the object's destructor has already been called. Most
+* objects set their final state to CL_DESTROYED before freeing the
+* memory associated with the object.
+*********/
+
+/****d* Component Library: Object States/cl_is_state_valid
+* NAME
+* cl_is_state_valid
+*
+* DESCRIPTION
+* The cl_is_state_valid function returns whether a state has a valid value.
+*
+* SYNOPSIS
+*/
+static inline boolean_t cl_is_state_valid(IN const cl_state_t state)
+{
+ return ((state == CL_UNINITIALIZED) || (state == CL_INITIALIZED) ||
+ (state == CL_DESTROYING) || (state == CL_DESTROYED));
+}
+
+/*
+* PARAMETERS
+* state
+* State whose value to validate.
+*
+* RETURN VALUES
+* TRUE if the specified state has a valid value.
+*
+* FALSE otherwise.
+*
+* NOTES
+* This function is used in debug builds to check for valid states. If an
+* uninitialized object is passed, the memory for the state may cause the
+* state to have an invalid value.
+*
+* SEE ALSO
+* Object States
+*********/
+
+END_C_DECLS
+#endif /* _DATA_TYPES_H_ */
diff --git a/contrib/ofed/opensm/include/complib/cl_types_osd.h b/contrib/ofed/opensm/include/complib/cl_types_osd.h
new file mode 100644
index 0000000..2538913
--- /dev/null
+++ b/contrib/ofed/opensm/include/complib/cl_types_osd.h
@@ -0,0 +1,97 @@
+/*
+ * Copyright (c) 2004-2009 Voltaire, Inc. All rights reserved.
+ * Copyright (c) 2002-2012 Mellanox Technologies LTD. All rights reserved.
+ * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+/*
+ * Abstract:
+ * Defines sized datatypes for Linux User mode
+ * exported sizes are int8_t, uint8_t, int16_t, uint16_t, int32_t, uint32_t
+ * int64_t, uint64_t.
+ */
+
+#ifndef _CL_TYPES_OSD_H_
+#define _CL_TYPES_OSD_H_
+
+#ifdef __cplusplus
+# define BEGIN_C_DECLS extern "C" {
+# define END_C_DECLS }
+#else /* !__cplusplus */
+# define BEGIN_C_DECLS
+# define END_C_DECLS
+#endif /* __cplusplus */
+
+BEGIN_C_DECLS
+#if defined (_DEBUG_)
+#ifdef __IA64__
+#define cl_break() asm(" break 0")
+#else /* __IA64__ */
+#define cl_break() asm(" int $3")
+#endif /* __IA64__ */
+#else /* _DEBUG_ */
+#define cl_break
+#endif
+#include <inttypes.h>
+#include <assert.h>
+#include <string.h>
+
+/*
+ * Branch prediction hints
+ */
+#if defined(HAVE_BUILTIN_EXPECT)
+#define PT(exp) __builtin_expect( ((uintptr_t)(exp)), 1 )
+#define PF(exp) __builtin_expect( ((uintptr_t)(exp)), 0 )
+#else
+#define PT(exp) (exp)
+#define PF(exp) (exp)
+#endif
+
+#if defined (_DEBUG_)
+#define CL_ASSERT assert
+#else /* _DEBUG_ */
+#define CL_ASSERT( __exp__ )
+#endif /* _DEBUG_ */
+/*
+ * Types not explicitly defined are native to the platform.
+ */
+typedef int boolean_t;
+typedef volatile int32_t atomic32_t;
+
+#ifndef NULL
+#define NULL (void*)0
+#endif
+
+#define UNUSED_PARAM( P )
+
+END_C_DECLS
+#endif /* _CL_TYPES_OSD_H_ */
diff --git a/contrib/ofed/opensm/include/complib/cl_vector.h b/contrib/ofed/opensm/include/complib/cl_vector.h
new file mode 100644
index 0000000..f66172b
--- /dev/null
+++ b/contrib/ofed/opensm/include/complib/cl_vector.h
@@ -0,0 +1,945 @@
+/*
+ * Copyright (c) 2004, 2005 Voltaire, Inc. All rights reserved.
+ * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved.
+ * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+/*
+ * Abstract:
+ * This file contains vector definitions. Vector provides dynmically
+ * resizable array functionality. Objects in a Vector are not relocated
+ * when the array is resized.
+ */
+
+#ifndef _CL_VECTOR_H_
+#define _CL_VECTOR_H_
+
+#include <complib/cl_qlist.h>
+
+#ifdef __cplusplus
+# define BEGIN_C_DECLS extern "C" {
+# define END_C_DECLS }
+#else /* !__cplusplus */
+# define BEGIN_C_DECLS
+# define END_C_DECLS
+#endif /* __cplusplus */
+
+BEGIN_C_DECLS
+/****h* Component Library/Vector
+* NAME
+* Vector
+*
+* DESCRIPTION
+* The Vector is a self-sizing array. Like a traditonal array, a vector
+* allows efficient constant time access to elements with a specified index.
+* A vector grows transparently as the user adds elements to the array.
+*
+* As the vector grows in size, it does not relocate existing elements in
+* memory. This allows using pointers to elements stored in a Vector.
+*
+* Users can supply an initializer functions that allow a vector to ensure
+* that new items added to the vector are properly initialized. A vector
+* calls the initializer function on a per object basis when growing the
+* array. The initializer is optional.
+*
+* The initializer function can fail, and returns a cl_status_t. The vector
+* will call the destructor function, if provided, for an element that
+* failed initialization. If an initializer fails, a vector does not call
+* the initializer for objects in the remainder of the new memory allocation.
+*
+* The cl_vector_t structure should be treated as opaque and should be
+* manipulated only through the provided functions.
+*
+* SEE ALSO
+* Structures:
+* cl_vector_t
+*
+* Callbacks:
+* cl_pfn_vec_init_t, cl_pfn_vec_dtor_t, cl_pfn_vec_apply_t,
+* cl_pfn_vec_find_t
+*
+* Item Manipulation:
+* cl_vector_set_obj, cl_vector_obj
+*
+* Initialization:
+* cl_vector_construct, cl_vector_init, cl_vector_destroy
+*
+* Manipulation:
+* cl_vector_get_capacity, cl_vector_set_capacity,
+* cl_vector_get_size, cl_vector_set_size, cl_vector_set_min_size
+* cl_vector_get_ptr, cl_vector_get, cl_vector_at, cl_vector_set
+*
+* Search:
+* cl_vector_find_from_start, cl_vector_find_from_end
+* cl_vector_apply_func
+*********/
+/****d* Component Library: Vector/cl_pfn_vec_init_t
+* NAME
+* cl_pfn_vec_init_t
+*
+* DESCRIPTION
+* The cl_pfn_vec_init_t function type defines the prototype for functions
+* used as initializer for elements being allocated by a vector.
+*
+* SYNOPSIS
+*/
+typedef cl_status_t
+ (*cl_pfn_vec_init_t) (IN void *const p_element, IN void *context);
+/*
+* PARAMETERS
+* p_element
+* [in] Pointer to an element being added to a vector.
+*
+* context
+* [in] Context provided in a call to cl_vector_init.
+*
+* RETURN VALUES
+* Return CL_SUCCESS to indicate that the element was initialized successfully.
+*
+* Other cl_status_t values will be returned by the cl_vector_init,
+* cl_vector_set_size, and cl_vector_set_min_size functions.
+*
+* In situations where the vector's size needs to grows in order to satisfy
+* a call to cl_vector_set, a non-successful status returned by the
+* initializer callback causes the growth to stop.
+*
+* NOTES
+* This function type is provided as function prototype reference for
+* the initializer function provided by users as an optional parameter to
+* the cl_vector_init function.
+*
+* SEE ALSO
+* Vector, cl_vector_init
+*********/
+
+/****d* Component Library: Vector/cl_pfn_vec_dtor_t
+* NAME
+* cl_pfn_vec_dtor_t
+*
+* DESCRIPTION
+* The cl_pfn_vec_dtor_t function type defines the prototype for functions
+* used as destructor for elements being deallocated from a vector.
+*
+* SYNOPSIS
+*/
+typedef void
+ (*cl_pfn_vec_dtor_t) (IN void *const p_element, IN void *context);
+/*
+* PARAMETERS
+* p_element
+* [in] Pointer to an element being deallocated from a vector.
+*
+* context
+* [in] Context provided in a call to cl_vector_init.
+*
+* RETURN VALUE
+* This function does not return a value.
+*
+* NOTES
+* This function type is provided as function prototype reference for
+* the destructor function provided by users as an optional parameter to
+* the cl_vector_init function.
+*
+* SEE ALSO
+* Vector, cl_vector_init
+*********/
+
+/****d* Component Library: Vector/cl_pfn_vec_apply_t
+* NAME
+* cl_pfn_vec_apply_t
+*
+* DESCRIPTION
+* The cl_pfn_vec_apply_t function type defines the prototype for functions
+* used to iterate elements in a vector.
+*
+* SYNOPSIS
+*/
+typedef void
+ (*cl_pfn_vec_apply_t) (IN const size_t index,
+ IN void *const p_element, IN void *context);
+/*
+* PARAMETERS
+* index
+* [in] Index of the element.
+*
+* p_element
+* [in] Pointer to an element at the specified index in the vector.
+*
+* context
+* [in] Context provided in a call to cl_vector_apply_func.
+*
+* RETURN VALUE
+* This function does not return a value.
+*
+* NOTES
+* This function type is provided as function prototype reference for
+* the function passed by users as a parameter to the cl_vector_apply_func
+* function.
+*
+* SEE ALSO
+* Vector, cl_vector_apply_func
+*********/
+
+/****d* Component Library: Vector/cl_pfn_vec_find_t
+* NAME
+* cl_pfn_vec_find_t
+*
+* DESCRIPTION
+* The cl_pfn_vec_find_t function type defines the prototype for functions
+* used to find elements in a vector.
+*
+* SYNOPSIS
+*/
+typedef cl_status_t
+ (*cl_pfn_vec_find_t) (IN const size_t index,
+ IN const void *const p_element, IN void *context);
+/*
+* PARAMETERS
+* index
+* [in] Index of the element.
+*
+* p_element
+* [in] Pointer to an element at the specified index in the vector.
+*
+* context
+* [in] Context provided in a call to cl_vector_find_from_start or
+* cl_vector_find_from_end.
+*
+* RETURN VALUES
+* Return CL_SUCCESS if the element was found. This stops vector iteration.
+*
+* CL_NOT_FOUND to continue the vector iteration.
+*
+* NOTES
+* This function type is provided as function prototype reference for the
+* function provided by users as a parameter to the cl_vector_find_from_start
+* and cl_vector_find_from_end functions.
+*
+* SEE ALSO
+* Vector, cl_vector_find_from_start, cl_vector_find_from_end
+*********/
+
+/****i* Component Library: Vector/cl_pfn_vec_copy_t
+* NAME
+* cl_pfn_vec_copy_t
+*
+* DESCRIPTION
+* The cl_pfn_vec_copy_t function type defines the prototype for functions
+* used to copy elements in a vector.
+*
+* SYNOPSIS
+*/
+typedef void
+ (*cl_pfn_vec_copy_t) (IN void *const p_dest,
+ IN const void *const p_src, IN const size_t size);
+/*
+* PARAMETERS
+* p_dest
+* [in] Pointer to the destination buffer into which to copy p_src.
+*
+* p_src
+* [in] Pointer to the destination buffer from which to copy.
+*
+* size
+* [in] Number of bytes to copy.
+*
+* RETURN VALUE
+* This function does not return a value.
+*
+* SEE ALSO
+* Vector
+*********/
+
+/****s* Component Library: Vector/cl_vector_t
+* NAME
+* cl_vector_t
+*
+* DESCRIPTION
+* Vector structure.
+*
+* The cl_vector_t structure should be treated as opaque and should be
+* manipulated only through the provided functions.
+*
+* SYNOPSIS
+*/
+typedef struct _cl_vector {
+ size_t size;
+ size_t grow_size;
+ size_t capacity;
+ size_t element_size;
+ cl_pfn_vec_init_t pfn_init;
+ cl_pfn_vec_dtor_t pfn_dtor;
+ cl_pfn_vec_copy_t pfn_copy;
+ const void *context;
+ cl_qlist_t alloc_list;
+ void **p_ptr_array;
+ cl_state_t state;
+} cl_vector_t;
+/*
+* FIELDS
+* size
+* Number of elements successfully initialized in the vector.
+*
+* grow_size
+* Number of elements to allocate when growing.
+*
+* capacity
+* total # of elements allocated.
+*
+* element_size
+* Size of each element.
+*
+* pfn_init
+* User supplied element initializer.
+*
+* pfn_dtor
+* User supplied element destructor.
+*
+* pfn_copy
+* Copy operator.
+*
+* context
+* User context for callbacks.
+*
+* alloc_list
+* List of allocations.
+*
+* p_ptr_array
+* Internal array of pointers to elements.
+*
+* state
+* State of the vector.
+*
+* SEE ALSO
+* Vector
+*********/
+
+/****f* Component Library: Vector/cl_vector_construct
+* NAME
+* cl_vector_construct
+*
+* DESCRIPTION
+* The cl_vector_construct function constructs a vector.
+*
+* SYNOPSIS
+*/
+void cl_vector_construct(IN cl_vector_t * const p_vector);
+/*
+* PARAMETERS
+* p_vector
+* [in] Pointer to a cl_vector_t structure to construct.
+*
+* RETURN VALUE
+* This function does not return a value.
+*
+* NOTES
+* Allows calling cl_vector_destroy without first calling cl_vector_init.
+*
+* Calling cl_vector_construct is a prerequisite to calling any other
+* vector function except cl_vector_init.
+*
+* SEE ALSO
+* Vector, cl_vector_init, cl_vector_destroy
+*********/
+
+/****f* Component Library: Vector/cl_vector_init
+* NAME
+* cl_vector_init
+*
+* DESCRIPTION
+* The cl_vector_init function initializes a vector for use.
+*
+* SYNOPSIS
+*/
+cl_status_t
+cl_vector_init(IN cl_vector_t * const p_vector,
+ IN const size_t min_size,
+ IN const size_t grow_size,
+ IN const size_t element_size,
+ IN cl_pfn_vec_init_t pfn_init OPTIONAL,
+ IN cl_pfn_vec_dtor_t pfn_dtor OPTIONAL,
+ IN const void *const context);
+/*
+* PARAMETERS
+* p_vector
+* [in] Pointer to a cl_vector_t structure to inititalize.
+*
+* min_size
+* [in] Initial number of elements.
+*
+* grow_size
+* [in] Number of elements to allocate when incrementally growing
+* the vector. A value of zero disables automatic growth.
+*
+* element_size
+* [in] Size of each element.
+*
+* pfn_init
+* [in] Initializer callback to invoke for every new element.
+* See the cl_pfn_vec_init_t function type declaration for details about
+* the callback function.
+*
+* pfn_dtor
+* [in] Destructor callback to invoke for elements being deallocated.
+* See the cl_pfn_vec_dtor_t function type declaration for details about
+* the callback function.
+*
+* context
+* [in] Value to pass to the callback functions to provide context.
+*
+* RETURN VALUES
+* CL_SUCCESS if the vector was initialized successfully.
+*
+* CL_INSUFFICIENT_MEMORY if the initialization failed.
+*
+* cl_status_t value returned by optional initializer function specified by
+* the pfn_init parameter.
+*
+* NOTES
+* The constructor and initializer functions, if any, are invoked for every
+* new element in the array.
+*
+* SEE ALSO
+* Vector, cl_vector_construct, cl_vector_destroy, cl_vector_set,
+* cl_vector_get, cl_vector_get_ptr, cl_vector_at
+*********/
+
+/****f* Component Library: Vector/cl_vector_destroy
+* NAME
+* cl_vector_destroy
+*
+* DESCRIPTION
+* The cl_vector_destroy function destroys a vector.
+*
+* SYNOPSIS
+*/
+void cl_vector_destroy(IN cl_vector_t * const p_vector);
+/*
+* PARAMETERS
+* p_vector
+* [in] Pointer to a cl_vector_t structure to destroy.
+*
+* RETURN VALUE
+* This function does not return a value.
+*
+* NOTES
+* cl_vector_destroy frees all memory allocated for the vector. The vector
+* is left initialized to a zero capacity and size.
+*
+* This function should only be called after a call to cl_vector_construct
+* or cl_vector_init.
+*
+* SEE ALSO
+* Vector, cl_vector_construct, cl_vector_init
+*********/
+
+/****f* Component Library: Vector/cl_vector_get_capacity
+* NAME
+* cl_vector_get_capacity
+*
+* DESCRIPTION
+* The cl_vector_get_capacity function returns the capacity of a vector.
+*
+* SYNOPSIS
+*/
+static inline size_t
+cl_vector_get_capacity(IN const cl_vector_t * const p_vector)
+{
+ CL_ASSERT(p_vector);
+ CL_ASSERT(p_vector->state == CL_INITIALIZED);
+
+ return (p_vector->capacity);
+}
+
+/*
+* PARAMETERS
+* p_vector
+* [in] Pointer to a cl_vector_t structure whose capacity to return.
+*
+* RETURN VALUE
+* Capacity, in elements, of the vector.
+*
+* NOTES
+* The capacity is the number of elements that the vector can store, and
+* can be greater than the number of elements stored. To get the number of
+* elements stored in the vector, use cl_vector_get_size.
+*
+* SEE ALSO
+* Vector, cl_vector_set_capacity, cl_vector_get_size
+*********/
+
+/****f* Component Library: Vector/cl_vector_get_size
+* NAME
+* cl_vector_get_size
+*
+* DESCRIPTION
+* The cl_vector_get_size function returns the size of a vector.
+*
+* SYNOPSIS
+*/
+static inline size_t cl_vector_get_size(IN const cl_vector_t * const p_vector)
+{
+ CL_ASSERT(p_vector);
+ CL_ASSERT(p_vector->state == CL_INITIALIZED);
+
+ return (p_vector->size);
+}
+
+/*
+* PARAMETERS
+* p_vector
+* [in] Pointer to a cl_vector_t structure whose size to return.
+*
+* RETURN VALUE
+* Size, in elements, of the vector.
+*
+* SEE ALSO
+* Vector, cl_vector_set_size, cl_vector_get_capacity
+*********/
+
+/****f* Component Library: Vector/cl_vector_get_ptr
+* NAME
+* cl_vector_get_ptr
+*
+* DESCRIPTION
+* The cl_vector_get_ptr function returns a pointer to an element
+* stored in a vector at a specified index.
+*
+* SYNOPSIS
+*/
+static inline void *cl_vector_get_ptr(IN const cl_vector_t * const p_vector,
+ IN const size_t index)
+{
+ CL_ASSERT(p_vector);
+ CL_ASSERT(p_vector->state == CL_INITIALIZED);
+
+ return (p_vector->p_ptr_array[index]);
+}
+
+/*
+* PARAMETERS
+* p_vector
+* [in] Pointer to a cl_vector_t structure from which to get a
+* pointer to an element.
+*
+* index
+* [in] Index of the element.
+*
+* RETURN VALUE
+* Pointer to the element stored at specified index.
+*
+* NOTES
+* cl_vector_get_ptr provides constant access times regardless of the index.
+*
+* cl_vector_get_ptr does not perform boundary checking. Callers are
+* responsible for providing an index that is within the range of the vector.
+*
+* SEE ALSO
+* Vector, cl_vector_get, cl_vector_at, cl_vector_set, cl_vector_get_size
+*********/
+
+/****f* Component Library: Vector/cl_vector_get
+* NAME
+* cl_vector_get
+*
+* DESCRIPTION
+* The cl_vector_get function copies an element stored in a vector at a
+* specified index.
+*
+* SYNOPSIS
+*/
+static inline void
+cl_vector_get(IN const cl_vector_t * const p_vector,
+ IN const size_t index, OUT void *const p_element)
+{
+ void *p_src;
+
+ CL_ASSERT(p_vector);
+ CL_ASSERT(p_vector->state == CL_INITIALIZED);
+ CL_ASSERT(p_element);
+
+ /* Get a pointer to the element. */
+ p_src = cl_vector_get_ptr(p_vector, index);
+ p_vector->pfn_copy(p_src, p_element, p_vector->element_size);
+}
+
+/*
+* PARAMETERS
+* p_vector
+* [in] Pointer to a cl_vector_t structure from which to get a copy of
+* an element.
+*
+* index
+* [in] Index of the element.
+*
+* p_element
+* [out] Pointer to storage for the element. Contains a copy of the
+* desired element upon successful completion of the call.
+*
+* RETURN VALUE
+* This function does not return a value.
+*
+* NOTES
+* cl_vector_get provides constant time access regardless of the index.
+*
+* cl_vector_get does not perform boundary checking on the vector, and
+* callers are responsible for providing an index that is within the range
+* of the vector. To access elements after performing boundary checks,
+* use cl_vector_at.
+*
+* The p_element parameter contains a copy of the desired element upon
+* return from this function.
+*
+* SEE ALSO
+* Vector, cl_vector_get_ptr, cl_vector_at
+*********/
+
+/****f* Component Library: Vector/cl_vector_at
+* NAME
+* cl_vector_at
+*
+* DESCRIPTION
+* The cl_vector_at function copies an element stored in a vector at a
+* specified index, performing boundary checks.
+*
+* SYNOPSIS
+*/
+cl_status_t
+cl_vector_at(IN const cl_vector_t * const p_vector,
+ IN const size_t index, OUT void *const p_element);
+/*
+* PARAMETERS
+* p_vector
+* [in] Pointer to a cl_vector_t structure from which to get a copy of
+* an element.
+*
+* index
+* [in] Index of the element.
+*
+* p_element
+* [out] Pointer to storage for the element. Contains a copy of the
+* desired element upon successful completion of the call.
+*
+* RETURN VALUES
+* CL_SUCCESS if an element was found at the specified index.
+*
+* CL_INVALID_SETTING if the index was out of range.
+*
+* NOTES
+* cl_vector_at provides constant time access regardless of the index, and
+* performs boundary checking on the vector.
+*
+* Upon success, the p_element parameter contains a copy of the desired element.
+*
+* SEE ALSO
+* Vector, cl_vector_get, cl_vector_get_ptr
+*********/
+
+/****f* Component Library: Vector/cl_vector_set
+* NAME
+* cl_vector_set
+*
+* DESCRIPTION
+* The cl_vector_set function sets the element at the specified index.
+*
+* SYNOPSIS
+*/
+cl_status_t
+cl_vector_set(IN cl_vector_t * const p_vector,
+ IN const size_t index, IN void *const p_element);
+/*
+* PARAMETERS
+* p_vector
+* [in] Pointer to a cl_vector_t structure into which to store
+* an element.
+*
+* index
+* [in] Index of the element.
+*
+* p_element
+* [in] Pointer to an element to store in the vector.
+*
+* RETURN VALUES
+* CL_SUCCESS if the element was successfully set.
+*
+* CL_INSUFFICIENT_MEMORY if the vector could not be resized to accommodate
+* the new element.
+*
+* NOTES
+* cl_vector_set grows the vector as needed to accommodate the new element,
+* unless the grow_size parameter passed into the cl_vector_init function
+* was zero.
+*
+* SEE ALSO
+* Vector, cl_vector_get
+*********/
+
+/****f* Component Library: Vector/cl_vector_set_capacity
+* NAME
+* cl_vector_set_capacity
+*
+* DESCRIPTION
+* The cl_vector_set_capacity function reserves memory in a vector for a
+* specified number of elements.
+*
+* SYNOPSIS
+*/
+cl_status_t
+cl_vector_set_capacity(IN cl_vector_t * const p_vector,
+ IN const size_t new_capacity);
+/*
+* PARAMETERS
+* p_vector
+* [in] Pointer to a cl_vector_t structure whose capacity to set.
+*
+* new_capacity
+* [in] Total number of elements for which the vector should
+* allocate memory.
+*
+* RETURN VALUES
+* CL_SUCCESS if the capacity was successfully set.
+*
+* CL_INSUFFICIENT_MEMORY if there was not enough memory to satisfy the
+* operation. The vector is left unchanged.
+*
+* NOTES
+* cl_vector_set_capacity increases the capacity of the vector. It does
+* not change the size of the vector. If the requested capacity is less
+* than the current capacity, the vector is left unchanged.
+*
+* SEE ALSO
+* Vector, cl_vector_get_capacity, cl_vector_set_size,
+* cl_vector_set_min_size
+*********/
+
+/****f* Component Library: Vector/cl_vector_set_size
+* NAME
+* cl_vector_set_size
+*
+* DESCRIPTION
+* The cl_vector_set_size function resizes a vector, either increasing or
+* decreasing its size.
+*
+* SYNOPSIS
+*/
+cl_status_t
+cl_vector_set_size(IN cl_vector_t * const p_vector, IN const size_t size);
+/*
+* PARAMETERS
+* p_vector
+* [in] Pointer to a cl_vector_t structure whose size to set.
+*
+* size
+* [in] Number of elements desired in the vector.
+*
+* RETURN VALUES
+* CL_SUCCESS if the size of the vector was set successfully.
+*
+* CL_INSUFFICIENT_MEMORY if there was not enough memory to complete the
+* operation. The vector is left unchanged.
+*
+* NOTES
+* cl_vector_set_size sets the vector to the specified size. If size is
+* smaller than the current size of the vector, the size is reduced.
+* The destructor function, if any, will be invoked for all elements that
+* are above size. Likewise, the constructor and initializer, if any, will
+* be invoked for all new elements.
+*
+* This function can only fail if size is larger than the current capacity.
+*
+* SEE ALSO
+* Vector, cl_vector_get_size, cl_vector_set_min_size,
+* cl_vector_set_capacity
+*********/
+
+/****f* Component Library: Vector/cl_vector_set_min_size
+* NAME
+* cl_vector_set_min_size
+*
+* DESCRIPTION
+* The cl_vector_set_min_size function resizes a vector to a specified size
+* if the vector is smaller than the specified size.
+*
+* SYNOPSIS
+*/
+cl_status_t
+cl_vector_set_min_size(IN cl_vector_t * const p_vector,
+ IN const size_t min_size);
+/*
+* PARAMETERS
+* p_vector
+* [in] Pointer to a cl_vector_t structure whose minimum size to set.
+*
+* min_size
+* [in] Minimum number of elements that the vector should contain.
+*
+* RETURN VALUES
+* CL_SUCCESS if the vector size is greater than or equal to min_size. This
+* could indicate that the vector's capacity was increased to min_size or
+* that the vector was already of sufficient size.
+*
+* CL_INSUFFICIENT_MEMORY if there was not enough memory to resize the vector.
+* The vector is left unchanged.
+*
+* NOTES
+* If min_size is smaller than the current size of the vector, the vector is
+* unchanged. The vector is unchanged if the size could not be changed due
+* to insufficient memory being available to perform the operation.
+*
+* SEE ALSO
+* Vector, cl_vector_get_size, cl_vector_set_size, cl_vector_set_capacity
+*********/
+
+/****f* Component Library: Vector/cl_vector_apply_func
+* NAME
+* cl_vector_apply_func
+*
+* DESCRIPTION
+* The cl_vector_apply_func function invokes a specified function for every
+* element in a vector.
+*
+* SYNOPSIS
+*/
+void
+cl_vector_apply_func(IN const cl_vector_t * const p_vector,
+ IN cl_pfn_vec_apply_t pfn_callback,
+ IN const void *const context);
+/*
+* PARAMETERS
+* p_vector
+* [in] Pointer to a cl_vector_t structure whose elements to iterate.
+*
+* pfn_callback
+* [in] Function invoked for every element in the array.
+* See the cl_pfn_vec_apply_t function type declaration for details
+* about the callback function.
+*
+* context
+* [in] Value to pass to the callback function.
+*
+* RETURN VALUE
+* This function does not return a value.
+*
+* NOTES
+* cl_vector_apply_func invokes the specified function for every element
+* in the vector, starting from the beginning of the vector.
+*
+* SEE ALSO
+* Vector, cl_vector_find_from_start, cl_vector_find_from_end,
+* cl_pfn_vec_apply_t
+*********/
+
+/****f* Component Library: Vector/cl_vector_find_from_start
+* NAME
+* cl_vector_find_from_start
+*
+* DESCRIPTION
+* The cl_vector_find_from_start function uses a specified function to
+* search for elements in a vector starting from the lowest index.
+*
+* SYNOPSIS
+*/
+size_t
+cl_vector_find_from_start(IN const cl_vector_t * const p_vector,
+ IN cl_pfn_vec_find_t pfn_callback,
+ IN const void *const context);
+/*
+* PARAMETERS
+* p_vector
+* [in] Pointer to a cl_vector_t structure to inititalize.
+*
+* pfn_callback
+* [in] Function invoked to determine if a match was found.
+* See the cl_pfn_vec_find_t function type declaration for details
+* about the callback function.
+*
+* context
+* [in] Value to pass to the callback function.
+*
+* RETURN VALUES
+* Index of the element, if found.
+*
+* Size of the vector if the element was not found.
+*
+* NOTES
+* cl_vector_find_from_start does not remove the found element from
+* the vector. The index of the element is returned when the function
+* provided by the pfn_callback parameter returns CL_SUCCESS.
+*
+* SEE ALSO
+* Vector, cl_vector_find_from_end, cl_vector_apply_func, cl_pfn_vec_find_t
+*********/
+
+/****f* Component Library: Vector/cl_vector_find_from_end
+* NAME
+* cl_vector_find_from_end
+*
+* DESCRIPTION
+* The cl_vector_find_from_end function uses a specified function to search
+* for elements in a vector starting from the highest index.
+*
+* SYNOPSIS
+*/
+size_t
+cl_vector_find_from_end(IN const cl_vector_t * const p_vector,
+ IN cl_pfn_vec_find_t pfn_callback,
+ IN const void *const context);
+/*
+* PARAMETERS
+* p_vector
+* [in] Pointer to a cl_vector_t structure to inititalize.
+*
+* pfn_callback
+* [in] Function invoked to determine if a match was found.
+* See the cl_pfn_vec_find_t function type declaration for details
+* about the callback function.
+*
+* context
+* [in] Value to pass to the callback function.
+*
+* RETURN VALUES
+* Index of the element, if found.
+*
+* Size of the vector if the element was not found.
+*
+* NOTES
+* cl_vector_find_from_end does not remove the found element from
+* the vector. The index of the element is returned when the function
+* provided by the pfn_callback parameter returns CL_SUCCESS.
+*
+* SEE ALSO
+* Vector, cl_vector_find_from_start, cl_vector_apply_func,
+* cl_pfn_vec_find_t
+*********/
+
+END_C_DECLS
+#endif /* _CL_VECTOR_H_ */
diff --git a/contrib/ofed/opensm/include/iba/ib_cm_types.h b/contrib/ofed/opensm/include/iba/ib_cm_types.h
new file mode 100644
index 0000000..061f47b
--- /dev/null
+++ b/contrib/ofed/opensm/include/iba/ib_cm_types.h
@@ -0,0 +1,203 @@
+/*
+ * Copyright (c) 2004-2007 Voltaire, Inc. All rights reserved.
+ * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved.
+ * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+#if !defined(__IB_CM_TYPES_H__)
+#define __IB_CM_TYPES_H__
+
+#ifndef __WIN__
+
+#include <iba/ib_types.h>
+
+#ifdef __cplusplus
+# define BEGIN_C_DECLS extern "C" {
+# define END_C_DECLS }
+#else /* !__cplusplus */
+# define BEGIN_C_DECLS
+# define END_C_DECLS
+#endif /* __cplusplus */
+
+BEGIN_C_DECLS
+/*
+ * Defines known Communication management class versions
+ */
+#define IB_MCLASS_CM_VER_2 2
+#define IB_MCLASS_CM_VER_1 1
+/*
+ * Defines the size of user available data in communication management MADs
+ */
+#define IB_REQ_PDATA_SIZE_VER2 92
+#define IB_MRA_PDATA_SIZE_VER2 222
+#define IB_REJ_PDATA_SIZE_VER2 148
+#define IB_REP_PDATA_SIZE_VER2 196
+#define IB_RTU_PDATA_SIZE_VER2 224
+#define IB_LAP_PDATA_SIZE_VER2 168
+#define IB_APR_PDATA_SIZE_VER2 148
+#define IB_DREQ_PDATA_SIZE_VER2 220
+#define IB_DREP_PDATA_SIZE_VER2 224
+#define IB_SIDR_REQ_PDATA_SIZE_VER2 216
+#define IB_SIDR_REP_PDATA_SIZE_VER2 136
+#define IB_REQ_PDATA_SIZE_VER1 92
+#define IB_MRA_PDATA_SIZE_VER1 222
+#define IB_REJ_PDATA_SIZE_VER1 148
+#define IB_REP_PDATA_SIZE_VER1 204
+#define IB_RTU_PDATA_SIZE_VER1 224
+#define IB_LAP_PDATA_SIZE_VER1 168
+#define IB_APR_PDATA_SIZE_VER1 151
+#define IB_DREQ_PDATA_SIZE_VER1 220
+#define IB_DREP_PDATA_SIZE_VER1 224
+#define IB_SIDR_REQ_PDATA_SIZE_VER1 216
+#define IB_SIDR_REP_PDATA_SIZE_VER1 140
+#define IB_ARI_SIZE 72 // redefine
+#define IB_APR_INFO_SIZE 72
+/****d* Access Layer/ib_rej_status_t
+* NAME
+* ib_rej_status_t
+*
+* DESCRIPTION
+* Rejection reasons.
+*
+* SYNOPSIS
+*/
+typedef ib_net16_t ib_rej_status_t;
+/*
+* SEE ALSO
+* ib_cm_rej, ib_cm_rej_rec_t
+*
+* SOURCE
+*/
+#define IB_REJ_INSUF_QP CL_HTON16(1)
+#define IB_REJ_INSUF_EEC CL_HTON16(2)
+#define IB_REJ_INSUF_RESOURCES CL_HTON16(3)
+#define IB_REJ_TIMEOUT CL_HTON16(4)
+#define IB_REJ_UNSUPPORTED CL_HTON16(5)
+#define IB_REJ_INVALID_COMM_ID CL_HTON16(6)
+#define IB_REJ_INVALID_COMM_INSTANCE CL_HTON16(7)
+#define IB_REJ_INVALID_SID CL_HTON16(8)
+#define IB_REJ_INVALID_XPORT CL_HTON16(9)
+#define IB_REJ_STALE_CONN CL_HTON16(10)
+#define IB_REJ_RDC_NOT_EXIST CL_HTON16(11)
+#define IB_REJ_INVALID_GID CL_HTON16(12)
+#define IB_REJ_INVALID_LID CL_HTON16(13)
+#define IB_REJ_INVALID_SL CL_HTON16(14)
+#define IB_REJ_INVALID_TRAFFIC_CLASS CL_HTON16(15)
+#define IB_REJ_INVALID_HOP_LIMIT CL_HTON16(16)
+#define IB_REJ_INVALID_PKT_RATE CL_HTON16(17)
+#define IB_REJ_INVALID_ALT_GID CL_HTON16(18)
+#define IB_REJ_INVALID_ALT_LID CL_HTON16(19)
+#define IB_REJ_INVALID_ALT_SL CL_HTON16(20)
+#define IB_REJ_INVALID_ALT_TRAFFIC_CLASS CL_HTON16(21)
+#define IB_REJ_INVALID_ALT_HOP_LIMIT CL_HTON16(22)
+#define IB_REJ_INVALID_ALT_PKT_RATE CL_HTON16(23)
+#define IB_REJ_PORT_REDIRECT CL_HTON16(24)
+#define IB_REJ_INVALID_MTU CL_HTON16(26)
+#define IB_REJ_INSUFFICIENT_RESP_RES CL_HTON16(27)
+#define IB_REJ_USER_DEFINED CL_HTON16(28)
+#define IB_REJ_INVALID_RNR_RETRY CL_HTON16(29)
+#define IB_REJ_DUPLICATE_LOCAL_COMM_ID CL_HTON16(30)
+#define IB_REJ_INVALID_CLASS_VER CL_HTON16(31)
+#define IB_REJ_INVALID_FLOW_LBL CL_HTON16(32)
+#define IB_REJ_INVALID_ALT_FLOW_LBL CL_HTON16(33)
+
+#define IB_REJ_SERVICE_HANDOFF CL_HTON16(65535)
+/******/
+
+/****d* Access Layer/ib_apr_status_t
+* NAME
+* ib_apr_status_t
+*
+* DESCRIPTION
+* Automatic path migration status information.
+*
+* SYNOPSIS
+*/
+typedef uint8_t ib_apr_status_t;
+/*
+* SEE ALSO
+* ib_cm_apr, ib_cm_apr_rec_t
+*
+* SOURCE
+ */
+#define IB_AP_SUCCESS 0
+#define IB_AP_INVALID_COMM_ID 1
+#define IB_AP_UNSUPPORTED 2
+#define IB_AP_REJECT 3
+#define IB_AP_REDIRECT 4
+#define IB_AP_IS_CURRENT 5
+#define IB_AP_INVALID_QPN_EECN 6
+#define IB_AP_INVALID_LID 7
+#define IB_AP_INVALID_GID 8
+#define IB_AP_INVALID_FLOW_LBL 9
+#define IB_AP_INVALID_TCLASS 10
+#define IB_AP_INVALID_HOP_LIMIT 11
+#define IB_AP_INVALID_PKT_RATE 12
+#define IB_AP_INVALID_SL 13
+/******/
+
+/****d* Access Layer/ib_cm_cap_mask_t
+* NAME
+* ib_cm_cap_mask_t
+*
+* DESCRIPTION
+* Capability mask values in ClassPortInfo.
+*
+* SYNOPSIS
+*/
+#define IB_CM_RELIABLE_CONN_CAPABLE CL_HTON16(9)
+#define IB_CM_RELIABLE_DGRM_CAPABLE CL_HTON16(10)
+#define IB_CM_RDGRM_CAPABLE CL_HTON16(11)
+#define IB_CM_UNRELIABLE_CONN_CAPABLE CL_HTON16(12)
+#define IB_CM_SIDR_CAPABLE CL_HTON16(13)
+/*
+* SEE ALSO
+* ib_cm_rep, ib_class_port_info_t
+*
+* SOURCE
+*
+*******/
+
+/*
+ * Service ID resolution status
+ */
+typedef uint16_t ib_sidr_status_t;
+#define IB_SIDR_SUCCESS 0
+#define IB_SIDR_UNSUPPORTED 1
+#define IB_SIDR_REJECT 2
+#define IB_SIDR_NO_QP 3
+#define IB_SIDR_REDIRECT 4
+#define IB_SIDR_UNSUPPORTED_VER 5
+
+END_C_DECLS
+#endif /* ndef __WIN__ */
+#endif /* __IB_CM_TYPES_H__ */
diff --git a/contrib/ofed/opensm/include/iba/ib_types.h b/contrib/ofed/opensm/include/iba/ib_types.h
new file mode 100644
index 0000000..604dd1d
--- /dev/null
+++ b/contrib/ofed/opensm/include/iba/ib_types.h
@@ -0,0 +1,12047 @@
+/*
+ * Copyright (c) 2004-2009 Voltaire, Inc. All rights reserved.
+ * Copyright (c) 2002-2011 Mellanox Technologies LTD. All rights reserved.
+ * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
+ * Copyright (c) 2009 HNR Consulting. All rights reserved.
+ * Copyright (c) 2013 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+#if !defined(__IB_TYPES_H__)
+#define __IB_TYPES_H__
+
+#include <string.h>
+#include <complib/cl_types.h>
+#include <complib/cl_byteswap.h>
+
+#ifdef __cplusplus
+# define BEGIN_C_DECLS extern "C" {
+# define END_C_DECLS }
+#else /* !__cplusplus */
+# define BEGIN_C_DECLS
+# define END_C_DECLS
+#endif /* __cplusplus */
+
+BEGIN_C_DECLS
+#if defined( __WIN__ )
+#if defined( EXPORT_AL_SYMBOLS )
+#define OSM_EXPORT __declspec(dllexport)
+#else
+#define OSM_EXPORT __declspec(dllimport)
+#endif
+#define OSM_API __stdcall
+#define OSM_CDECL __cdecl
+#else
+#define OSM_EXPORT extern
+#define OSM_API
+#define OSM_CDECL
+#define __ptr64
+#endif
+/****h* IBA Base/Constants
+* NAME
+* Constants
+*
+* DESCRIPTION
+* The following constants are used throughout the IBA code base.
+*
+* Definitions are from the InfiniBand Architecture Specification v1.3.1
+*
+*********/
+/****d* IBA Base: Constants/MAD_BLOCK_SIZE
+* NAME
+* MAD_BLOCK_SIZE
+*
+* DESCRIPTION
+* Size of a non-RMPP MAD datagram.
+*
+* SOURCE
+*/
+#define MAD_BLOCK_SIZE 256
+/**********/
+/****d* IBA Base: Constants/MAD_RMPP_HDR_SIZE
+* NAME
+* MAD_RMPP_HDR_SIZE
+*
+* DESCRIPTION
+* Size of an RMPP header, including the common MAD header.
+*
+* SOURCE
+*/
+#define MAD_RMPP_HDR_SIZE 36
+/**********/
+/****d* IBA Base: Constants/MAD_RMPP_DATA_SIZE
+* NAME
+* MAD_RMPP_DATA_SIZE
+*
+* DESCRIPTION
+* Size of an RMPP transaction data section.
+*
+* SOURCE
+*/
+#define MAD_RMPP_DATA_SIZE (MAD_BLOCK_SIZE - MAD_RMPP_HDR_SIZE)
+/**********/
+/****d* IBA Base: Constants/MAD_BLOCK_GRH_SIZE
+* NAME
+* MAD_BLOCK_GRH_SIZE
+*
+* DESCRIPTION
+* Size of a MAD datagram, including the GRH.
+*
+* SOURCE
+*/
+#define MAD_BLOCK_GRH_SIZE 296
+/**********/
+/****d* IBA Base: Constants/IB_LID_PERMISSIVE
+* NAME
+* IB_LID_PERMISSIVE
+*
+* DESCRIPTION
+* Permissive LID
+*
+* SOURCE
+*/
+#define IB_LID_PERMISSIVE 0xFFFF
+/**********/
+/****d* IBA Base: Constants/IB_DEFAULT_PKEY
+* NAME
+* IB_DEFAULT_PKEY
+*
+* DESCRIPTION
+* P_Key value for the default partition.
+*
+* SOURCE
+*/
+#define IB_DEFAULT_PKEY 0xFFFF
+/**********/
+/****d* IBA Base: Constants/IB_QP1_WELL_KNOWN_Q_KEY
+* NAME
+* IB_QP1_WELL_KNOWN_Q_KEY
+*
+* DESCRIPTION
+* Well-known Q_Key for QP1 privileged mode access (15.4.2).
+*
+* SOURCE
+*/
+#define IB_QP1_WELL_KNOWN_Q_KEY CL_HTON32(0x80010000)
+/*********/
+#define IB_QP0 0
+#define IB_QP1 CL_HTON32(1)
+#define IB_QP_PRIVILEGED_Q_KEY CL_HTON32(0x80000000)
+/****d* IBA Base: Constants/IB_LID_UCAST_START
+* NAME
+* IB_LID_UCAST_START
+*
+* DESCRIPTION
+* Lowest valid unicast LID value.
+*
+* SOURCE
+*/
+#define IB_LID_UCAST_START_HO 0x0001
+#define IB_LID_UCAST_START (CL_HTON16(IB_LID_UCAST_START_HO))
+/**********/
+/****d* IBA Base: Constants/IB_LID_UCAST_END
+* NAME
+* IB_LID_UCAST_END
+*
+* DESCRIPTION
+* Highest valid unicast LID value.
+*
+* SOURCE
+*/
+#define IB_LID_UCAST_END_HO 0xBFFF
+#define IB_LID_UCAST_END (CL_HTON16(IB_LID_UCAST_END_HO))
+/**********/
+/****d* IBA Base: Constants/IB_LID_MCAST_START
+* NAME
+* IB_LID_MCAST_START
+*
+* DESCRIPTION
+* Lowest valid multicast LID value.
+*
+* SOURCE
+*/
+#define IB_LID_MCAST_START_HO 0xC000
+#define IB_LID_MCAST_START (CL_HTON16(IB_LID_MCAST_START_HO))
+/**********/
+/****d* IBA Base: Constants/IB_LID_MCAST_END
+* NAME
+* IB_LID_MCAST_END
+*
+* DESCRIPTION
+* Highest valid multicast LID value.
+*
+* SOURCE
+*/
+#define IB_LID_MCAST_END_HO 0xFFFE
+#define IB_LID_MCAST_END (CL_HTON16(IB_LID_MCAST_END_HO))
+/**********/
+/****d* IBA Base: Constants/IB_DEFAULT_SUBNET_PREFIX
+* NAME
+* IB_DEFAULT_SUBNET_PREFIX
+*
+* DESCRIPTION
+* Default subnet GID prefix.
+*
+* SOURCE
+*/
+#define IB_DEFAULT_SUBNET_PREFIX (CL_HTON64(0xFE80000000000000ULL))
+#define IB_DEFAULT_SUBNET_PREFIX_HO (0xFE80000000000000ULL)
+/**********/
+/****d* IBA Base: Constants/IB_NODE_NUM_PORTS_MAX
+* NAME
+* IB_NODE_NUM_PORTS_MAX
+*
+* DESCRIPTION
+* Maximum number of ports in a single node (14.2.5.7).
+* SOURCE
+*/
+#define IB_NODE_NUM_PORTS_MAX 0xFE
+/**********/
+/****d* IBA Base: Constants/IB_INVALID_PORT_NUM
+* NAME
+* IB_INVALID_PORT_NUM
+*
+* DESCRIPTION
+* Value used to indicate an invalid port number (14.2.5.10).
+*
+* SOURCE
+*/
+#define IB_INVALID_PORT_NUM 0xFF
+/*********/
+/****d* IBA Base: Constants/IB_SUBNET_PATH_HOPS_MAX
+* NAME
+* IB_SUBNET_PATH_HOPS_MAX
+*
+* DESCRIPTION
+* Maximum number of directed route switch hops in a subnet (14.2.1.2).
+*
+* SOURCE
+*/
+#define IB_SUBNET_PATH_HOPS_MAX 64
+/*********/
+/****d* IBA Base: Constants/IB_HOPLIMIT_MAX
+* NAME
+* IB_HOPLIMIT_MAX
+*
+* DESCRIPTION
+* Maximum number of router hops allowed.
+*
+* SOURCE
+*/
+#define IB_HOPLIMIT_MAX 255
+/*********/
+/****d* IBA Base: Constants/IB_MC_SCOPE_*
+* NAME
+* IB_MC_SCOPE_*
+*
+* DESCRIPTION
+* Scope component definitions from IBA 1.2.1 (Table 3 p. 148)
+*/
+#define IB_MC_SCOPE_LINK_LOCAL 0x2
+#define IB_MC_SCOPE_SITE_LOCAL 0x5
+#define IB_MC_SCOPE_ORG_LOCAL 0x8
+#define IB_MC_SCOPE_GLOBAL 0xE
+/*********/
+/****d* IBA Base: Constants/IB_PKEY_MAX_BLOCKS
+* NAME
+* IB_PKEY_MAX_BLOCKS
+*
+* DESCRIPTION
+* Maximum number of PKEY blocks (14.2.5.7).
+*
+* SOURCE
+*/
+#define IB_PKEY_MAX_BLOCKS 2048
+/*********/
+/****d* IBA Base: Constants/IB_MCAST_MAX_BLOCK_ID
+* NAME
+* IB_MCAST_MAX_BLOCK_ID
+*
+* DESCRIPTION
+* Maximum number of Multicast port mask blocks
+*
+* SOURCE
+*/
+#define IB_MCAST_MAX_BLOCK_ID 511
+/*********/
+/****d* IBA Base: Constants/IB_MCAST_BLOCK_ID_MASK_HO
+* NAME
+* IB_MCAST_BLOCK_ID_MASK_HO
+*
+* DESCRIPTION
+* Mask (host order) to recover the Multicast block ID.
+*
+* SOURCE
+*/
+#define IB_MCAST_BLOCK_ID_MASK_HO 0x000001FF
+/*********/
+/****d* IBA Base: Constants/IB_MCAST_BLOCK_SIZE
+* NAME
+* IB_MCAST_BLOCK_SIZE
+*
+* DESCRIPTION
+* Number of port mask entries in a multicast forwarding table block.
+*
+* SOURCE
+*/
+#define IB_MCAST_BLOCK_SIZE 32
+/*********/
+/****d* IBA Base: Constants/IB_MCAST_MASK_SIZE
+* NAME
+* IB_MCAST_MASK_SIZE
+*
+* DESCRIPTION
+* Number of port mask bits in each entry in the multicast forwarding table.
+*
+* SOURCE
+*/
+#define IB_MCAST_MASK_SIZE 16
+/*********/
+/****d* IBA Base: Constants/IB_MCAST_POSITION_MASK_HO
+* NAME
+* IB_MCAST_POSITION_MASK_HO
+*
+* DESCRIPTION
+* Mask (host order) to recover the multicast block position.
+*
+* SOURCE
+*/
+#define IB_MCAST_POSITION_MASK_HO 0xF0000000
+/*********/
+/****d* IBA Base: Constants/IB_MCAST_POSITION_MAX
+* NAME
+* IB_MCAST_POSITION_MAX
+*
+* DESCRIPTION
+* Maximum value for the multicast block position.
+*
+* SOURCE
+*/
+#define IB_MCAST_POSITION_MAX 0xF
+/*********/
+/****d* IBA Base: Constants/IB_MCAST_POSITION_SHIFT
+* NAME
+* IB_MCAST_POSITION_SHIFT
+*
+* DESCRIPTION
+* Shift value to normalize the multicast block position value.
+*
+* SOURCE
+*/
+#define IB_MCAST_POSITION_SHIFT 28
+/*********/
+/****d* IBA Base: Constants/IB_PKEY_ENTRIES_MAX
+* NAME
+* IB_PKEY_ENTRIES_MAX
+*
+* DESCRIPTION
+* Maximum number of PKEY entries per port (14.2.5.7).
+*
+* SOURCE
+*/
+#define IB_PKEY_ENTRIES_MAX (IB_PKEY_MAX_BLOCKS * IB_NUM_PKEY_ELEMENTS_IN_BLOCK)
+/*********/
+/****d* IBA Base: Constants/IB_PKEY_BASE_MASK
+* NAME
+* IB_PKEY_BASE_MASK
+*
+* DESCRIPTION
+* Masks for the base P_Key value given a P_Key Entry.
+*
+* SOURCE
+*/
+#define IB_PKEY_BASE_MASK (CL_HTON16(0x7FFF))
+/*********/
+/****d* IBA Base: Constants/IB_PKEY_TYPE_MASK
+* NAME
+* IB_PKEY_TYPE_MASK
+*
+* DESCRIPTION
+* Masks for the P_Key membership type given a P_Key Entry.
+*
+* SOURCE
+*/
+#define IB_PKEY_TYPE_MASK (CL_HTON16(0x8000))
+/*********/
+/****d* IBA Base: Constants/IB_DEFAULT_PARTIAL_PKEY
+* NAME
+* IB_DEFAULT_PARTIAL_PKEY
+*
+* DESCRIPTION
+* 0x7FFF in network order
+*
+* SOURCE
+*/
+#define IB_DEFAULT_PARTIAL_PKEY (CL_HTON16(0x7FFF))
+/**********/
+/****d* IBA Base: Constants/IB_MCLASS_SUBN_LID
+* NAME
+* IB_MCLASS_SUBN_LID
+*
+* DESCRIPTION
+* Subnet Management Class, Subnet Manager LID routed (13.4.4)
+*
+* SOURCE
+*/
+#define IB_MCLASS_SUBN_LID 0x01
+/**********/
+/****d* IBA Base: Constants/IB_MCLASS_SUBN_DIR
+* NAME
+* IB_MCLASS_SUBN_DIR
+*
+* DESCRIPTION
+* Subnet Management Class, Subnet Manager directed route (13.4.4)
+*
+* SOURCE
+*/
+#define IB_MCLASS_SUBN_DIR 0x81
+/**********/
+/****d* IBA Base: Constants/IB_MCLASS_SUBN_ADM
+* NAME
+* IB_MCLASS_SUBN_ADM
+*
+* DESCRIPTION
+* Management Class, Subnet Administration (13.4.4)
+*
+* SOURCE
+*/
+#define IB_MCLASS_SUBN_ADM 0x03
+/**********/
+/****d* IBA Base: Constants/IB_MCLASS_PERF
+* NAME
+* IB_MCLASS_PERF
+*
+* DESCRIPTION
+* Management Class, Performance Management (13.4.4)
+*
+* SOURCE
+*/
+#define IB_MCLASS_PERF 0x04
+/**********/
+/****d* IBA Base: Constants/IB_MCLASS_BM
+* NAME
+* IB_MCLASS_BM
+*
+* DESCRIPTION
+* Management Class, Baseboard Management (13.4.4)
+*
+* SOURCE
+*/
+#define IB_MCLASS_BM 0x05
+/**********/
+/****d* IBA Base: Constants/IB_MCLASS_DEV_MGMT
+* NAME
+* IB_MCLASS_DEV_MGMT
+*
+* DESCRIPTION
+* Management Class, Device Management (13.4.4)
+*
+* SOURCE
+*/
+#define IB_MCLASS_DEV_MGMT 0x06
+/**********/
+/****d* IBA Base: Constants/IB_MCLASS_COMM_MGMT
+* NAME
+* IB_MCLASS_COMM_MGMT
+*
+* DESCRIPTION
+* Management Class, Communication Management (13.4.4)
+*
+* SOURCE
+*/
+#define IB_MCLASS_COMM_MGMT 0x07
+/**********/
+/****d* IBA Base: Constants/IB_MCLASS_SNMP
+* NAME
+* IB_MCLASS_SNMP
+*
+* DESCRIPTION
+* Management Class, SNMP Tunneling (13.4.4)
+*
+* SOURCE
+*/
+#define IB_MCLASS_SNMP 0x08
+/**********/
+/****d* IBA Base: Constants/IB_MCLASS_VENDOR_LOW_RANGE_MIN
+* NAME
+* IB_MCLASS_VENDOR_LOW_RANGE_MIN
+*
+* DESCRIPTION
+* Management Class, Vendor Specific Low Range Start
+*
+* SOURCE
+*/
+#define IB_MCLASS_VENDOR_LOW_RANGE_MIN 0x09
+/**********/
+/****d* IBA Base: Constants/IB_MCLASS_VENDOR_LOW_RANGE_MAX
+* NAME
+* IB_MCLASS_VENDOR_LOW_RANGE_MAX
+*
+* DESCRIPTION
+* Management Class, Vendor Specific Low Range End
+*
+* SOURCE
+*/
+#define IB_MCLASS_VENDOR_LOW_RANGE_MAX 0x0F
+/**********/
+/****d* IBA Base: Constants/IB_MCLASS_DEV_ADM
+* NAME
+* IB_MCLASS_DEV_ADM
+*
+* DESCRIPTION
+* Management Class, Device Administration
+*
+* SOURCE
+*/
+#define IB_MCLASS_DEV_ADM 0x10
+/**********/
+/****d* IBA Base: Constants/IB_MCLASS_BIS
+* NAME
+* IB_MCLASS_BIS
+*
+* DESCRIPTION
+* Management Class, BIS
+*
+* SOURCE
+*/
+#define IB_MCLASS_BIS 0x12
+/**********/
+/****d* IBA Base: Constants/IB_MCLASS_CC
+* NAME
+* IB_MCLASS_CC
+*
+* DESCRIPTION
+* Management Class, Congestion Control (A10.4.1)
+*
+* SOURCE
+*/
+#define IB_MCLASS_CC 0x21
+/**********/
+/****d* IBA Base: Constants/IB_MCLASS_VENDOR_HIGH_RANGE_MIN
+* NAME
+* IB_MCLASS_VENDOR_HIGH_RANGE_MIN
+*
+* DESCRIPTION
+* Management Class, Vendor Specific High Range Start
+*
+* SOURCE
+*/
+#define IB_MCLASS_VENDOR_HIGH_RANGE_MIN 0x30
+/**********/
+/****d* IBA Base: Constants/IB_MCLASS_VENDOR_HIGH_RANGE_MAX
+* NAME
+* IB_MCLASS_VENDOR_HIGH_RANGE_MAX
+*
+* DESCRIPTION
+* Management Class, Vendor Specific High Range End
+*
+* SOURCE
+*/
+#define IB_MCLASS_VENDOR_HIGH_RANGE_MAX 0x4F
+/**********/
+/****f* IBA Base: Types/ib_class_is_vendor_specific_low
+* NAME
+* ib_class_is_vendor_specific_low
+*
+* DESCRIPTION
+* Indicates if the Class Code if a vendor specific class from
+* the low range
+*
+* SYNOPSIS
+*/
+static inline boolean_t OSM_API
+ib_class_is_vendor_specific_low(IN const uint8_t class_code)
+{
+ return ((class_code >= IB_MCLASS_VENDOR_LOW_RANGE_MIN) &&
+ (class_code <= IB_MCLASS_VENDOR_LOW_RANGE_MAX));
+}
+
+/*
+* PARAMETERS
+* class_code
+* [in] The Management Datagram Class Code
+*
+* RETURN VALUE
+* TRUE if the class is in the Low range of Vendor Specific MADs
+* FALSE otherwise.
+*
+* NOTES
+*
+* SEE ALSO
+* IB_MCLASS_VENDOR_LOW_RANGE_MIN, IB_MCLASS_VENDOR_LOW_RANGE_MAX
+*********/
+
+/****f* IBA Base: Types/ib_class_is_vendor_specific_high
+* NAME
+* ib_class_is_vendor_specific_high
+*
+* DESCRIPTION
+* Indicates if the Class Code if a vendor specific class from
+* the high range
+*
+* SYNOPSIS
+*/
+static inline boolean_t OSM_API
+ib_class_is_vendor_specific_high(IN const uint8_t class_code)
+{
+ return ((class_code >= IB_MCLASS_VENDOR_HIGH_RANGE_MIN) &&
+ (class_code <= IB_MCLASS_VENDOR_HIGH_RANGE_MAX));
+}
+
+/*
+* PARAMETERS
+* class_code
+* [in] The Management Datagram Class Code
+*
+* RETURN VALUE
+* TRUE if the class is in the High range of Vendor Specific MADs
+* FALSE otherwise.
+*
+* NOTES
+*
+* SEE ALSO
+* IB_MCLASS_VENDOR_HIGH_RANGE_MIN, IB_MCLASS_VENDOR_HIGH_RANGE_MAX
+*********/
+
+/****f* IBA Base: Types/ib_class_is_vendor_specific
+* NAME
+* ib_class_is_vendor_specific
+*
+* DESCRIPTION
+* Indicates if the Class Code if a vendor specific class
+*
+* SYNOPSIS
+*/
+static inline boolean_t OSM_API
+ib_class_is_vendor_specific(IN const uint8_t class_code)
+{
+ return (ib_class_is_vendor_specific_low(class_code) ||
+ ib_class_is_vendor_specific_high(class_code));
+}
+
+/*
+* PARAMETERS
+* class_code
+* [in] The Management Datagram Class Code
+*
+* RETURN VALUE
+* TRUE if the class is a Vendor Specific MAD
+* FALSE otherwise.
+*
+* NOTES
+*
+* SEE ALSO
+* ib_class_is_vendor_specific_low, ib_class_is_vendor_specific_high
+*********/
+
+/****f* IBA Base: Types/ib_class_is_rmpp
+* NAME
+* ib_class_is_rmpp
+*
+* DESCRIPTION
+* Indicates if the Class Code supports RMPP
+*
+* SYNOPSIS
+*/
+static inline boolean_t OSM_API ib_class_is_rmpp(IN const uint8_t class_code)
+{
+ return ((class_code == IB_MCLASS_SUBN_ADM) ||
+ (class_code == IB_MCLASS_DEV_MGMT) ||
+ (class_code == IB_MCLASS_DEV_ADM) ||
+ (class_code == IB_MCLASS_BIS) ||
+ ib_class_is_vendor_specific_high(class_code));
+}
+
+/*
+* PARAMETERS
+* class_code
+* [in] The Management Datagram Class Code
+*
+* RETURN VALUE
+* TRUE if the class supports RMPP
+* FALSE otherwise.
+*
+* NOTES
+*
+*********/
+
+/*
+ * MAD methods
+ */
+
+/****d* IBA Base: Constants/IB_MAX_METHOD
+* NAME
+* IB_MAX_METHOD
+*
+* DESCRIPTION
+* Total number of methods available to a class, not including the R-bit.
+*
+* SOURCE
+*/
+#define IB_MAX_METHODS 128
+/**********/
+
+/****d* IBA Base: Constants/IB_MAD_METHOD_RESP_MASK
+* NAME
+* IB_MAD_METHOD_RESP_MASK
+*
+* DESCRIPTION
+* Response mask to extract 'R' bit from the method field. (13.4.5)
+*
+* SOURCE
+*/
+#define IB_MAD_METHOD_RESP_MASK 0x80
+/**********/
+
+/****d* IBA Base: Constants/IB_MAD_METHOD_GET
+* NAME
+* IB_MAD_METHOD_GET
+*
+* DESCRIPTION
+* Get() Method (13.4.5)
+*
+* SOURCE
+*/
+#define IB_MAD_METHOD_GET 0x01
+/**********/
+
+/****d* IBA Base: Constants/IB_MAD_METHOD_SET
+* NAME
+* IB_MAD_METHOD_SET
+*
+* DESCRIPTION
+* Set() Method (13.4.5)
+*
+* SOURCE
+*/
+#define IB_MAD_METHOD_SET 0x02
+/**********/
+
+/****d* IBA Base: Constants/IB_MAD_METHOD_GET_RESP
+* NAME
+* IB_MAD_METHOD_GET_RESP
+*
+* DESCRIPTION
+* GetResp() Method (13.4.5)
+*
+* SOURCE
+*/
+#define IB_MAD_METHOD_GET_RESP 0x81
+/**********/
+
+#define IB_MAD_METHOD_DELETE 0x15
+
+/****d* IBA Base: Constants/IB_MAD_METHOD_GETTABLE
+* NAME
+* IB_MAD_METHOD_GETTABLE
+*
+* DESCRIPTION
+* SubnAdmGetTable() Method (15.2.2)
+*
+* SOURCE
+*/
+#define IB_MAD_METHOD_GETTABLE 0x12
+/**********/
+
+/****d* IBA Base: Constants/IB_MAD_METHOD_GETTABLE_RESP
+* NAME
+* IB_MAD_METHOD_GETTABLE_RESP
+*
+* DESCRIPTION
+* SubnAdmGetTableResp() Method (15.2.2)
+*
+* SOURCE
+*/
+#define IB_MAD_METHOD_GETTABLE_RESP 0x92
+
+/**********/
+
+#define IB_MAD_METHOD_GETTRACETABLE 0x13
+#define IB_MAD_METHOD_GETMULTI 0x14
+#define IB_MAD_METHOD_GETMULTI_RESP 0x94
+
+/****d* IBA Base: Constants/IB_MAD_METHOD_SEND
+* NAME
+* IB_MAD_METHOD_SEND
+*
+* DESCRIPTION
+* Send() Method (13.4.5)
+*
+* SOURCE
+*/
+#define IB_MAD_METHOD_SEND 0x03
+/**********/
+
+/****d* IBA Base: Constants/IB_MAD_METHOD_TRAP
+* NAME
+* IB_MAD_METHOD_TRAP
+*
+* DESCRIPTION
+* Trap() Method (13.4.5)
+*
+* SOURCE
+*/
+#define IB_MAD_METHOD_TRAP 0x05
+/**********/
+
+/****d* IBA Base: Constants/IB_MAD_METHOD_REPORT
+* NAME
+* IB_MAD_METHOD_REPORT
+*
+* DESCRIPTION
+* Report() Method (13.4.5)
+*
+* SOURCE
+*/
+#define IB_MAD_METHOD_REPORT 0x06
+/**********/
+
+/****d* IBA Base: Constants/IB_MAD_METHOD_REPORT_RESP
+* NAME
+* IB_MAD_METHOD_REPORT_RESP
+*
+* DESCRIPTION
+* ReportResp() Method (13.4.5)
+*
+* SOURCE
+*/
+#define IB_MAD_METHOD_REPORT_RESP 0x86
+/**********/
+
+/****d* IBA Base: Constants/IB_MAD_METHOD_TRAP_REPRESS
+* NAME
+* IB_MAD_METHOD_TRAP_REPRESS
+*
+* DESCRIPTION
+* TrapRepress() Method (13.4.5)
+*
+* SOURCE
+*/
+#define IB_MAD_METHOD_TRAP_REPRESS 0x07
+/**********/
+
+/****d* IBA Base: Constants/IB_MAD_STATUS_BUSY
+* NAME
+* IB_MAD_STATUS_BUSY
+*
+* DESCRIPTION
+* Temporarily busy, MAD discarded (13.4.7)
+*
+* SOURCE
+*/
+#define IB_MAD_STATUS_BUSY (CL_HTON16(0x0001))
+/**********/
+
+/****d* IBA Base: Constants/IB_MAD_STATUS_REDIRECT
+* NAME
+* IB_MAD_STATUS_REDIRECT
+*
+* DESCRIPTION
+* QP Redirection required (13.4.7)
+*
+* SOURCE
+*/
+#define IB_MAD_STATUS_REDIRECT (CL_HTON16(0x0002))
+/**********/
+
+/****d* IBA Base: Constants/IB_MAD_STATUS_UNSUP_CLASS_VER
+* NAME
+* IB_MAD_STATUS_UNSUP_CLASS_VER
+*
+* DESCRIPTION
+* Unsupported class version (13.4.7)
+*
+* SOURCE
+*/
+#define IB_MAD_STATUS_UNSUP_CLASS_VER (CL_HTON16(0x0004))
+/**********/
+
+/****d* IBA Base: Constants/IB_MAD_STATUS_UNSUP_METHOD
+* NAME
+* IB_MAD_STATUS_UNSUP_METHOD
+*
+* DESCRIPTION
+* Unsupported method (13.4.7)
+*
+* SOURCE
+*/
+#define IB_MAD_STATUS_UNSUP_METHOD (CL_HTON16(0x0008))
+/**********/
+
+/****d* IBA Base: Constants/IB_MAD_STATUS_UNSUP_METHOD_ATTR
+* NAME
+* IB_MAD_STATUS_UNSUP_METHOD_ATTR
+*
+* DESCRIPTION
+* Unsupported method/attribute combination (13.4.7)
+*
+* SOURCE
+*/
+#define IB_MAD_STATUS_UNSUP_METHOD_ATTR (CL_HTON16(0x000C))
+/**********/
+
+/****d* IBA Base: Constants/IB_MAD_STATUS_INVALID_FIELD
+* NAME
+* IB_MAD_STATUS_INVALID_FIELD
+*
+* DESCRIPTION
+* Attribute contains one or more invalid fields (13.4.7)
+*
+* SOURCE
+*/
+#define IB_MAD_STATUS_INVALID_FIELD (CL_HTON16(0x001C))
+/**********/
+
+#define IB_MAD_STATUS_CLASS_MASK (CL_HTON16(0xFF00))
+
+#define IB_SA_MAD_STATUS_SUCCESS (CL_HTON16(0x0000))
+#define IB_SA_MAD_STATUS_NO_RESOURCES (CL_HTON16(0x0100))
+#define IB_SA_MAD_STATUS_REQ_INVALID (CL_HTON16(0x0200))
+#define IB_SA_MAD_STATUS_NO_RECORDS (CL_HTON16(0x0300))
+#define IB_SA_MAD_STATUS_TOO_MANY_RECORDS (CL_HTON16(0x0400))
+#define IB_SA_MAD_STATUS_INVALID_GID (CL_HTON16(0x0500))
+#define IB_SA_MAD_STATUS_INSUF_COMPS (CL_HTON16(0x0600))
+#define IB_SA_MAD_STATUS_DENIED (CL_HTON16(0x0700))
+#define IB_SA_MAD_STATUS_PRIO_SUGGESTED (CL_HTON16(0x0800))
+
+#define IB_DM_MAD_STATUS_NO_IOC_RESP (CL_HTON16(0x0100))
+#define IB_DM_MAD_STATUS_NO_SVC_ENTRIES (CL_HTON16(0x0200))
+#define IB_DM_MAD_STATUS_IOC_FAILURE (CL_HTON16(0x8000))
+
+/****d* IBA Base: Constants/IB_MAD_ATTR_CLASS_PORT_INFO
+* NAME
+* IB_MAD_ATTR_CLASS_PORT_INFO
+*
+* DESCRIPTION
+* ClassPortInfo attribute (13.4.8)
+*
+* SOURCE
+*/
+#define IB_MAD_ATTR_CLASS_PORT_INFO (CL_HTON16(0x0001))
+/**********/
+
+/****d* IBA Base: Constants/IB_MAD_ATTR_NOTICE
+* NAME
+* IB_MAD_ATTR_NOTICE
+*
+* DESCRIPTION
+* Notice attribute (13.4.8)
+*
+* SOURCE
+*/
+#define IB_MAD_ATTR_NOTICE (CL_HTON16(0x0002))
+/**********/
+
+/****d* IBA Base: Constants/IB_MAD_ATTR_INFORM_INFO
+* NAME
+* IB_MAD_ATTR_INFORM_INFO
+*
+* DESCRIPTION
+* InformInfo attribute (13.4.8)
+*
+* SOURCE
+*/
+#define IB_MAD_ATTR_INFORM_INFO (CL_HTON16(0x0003))
+/**********/
+
+/****d* IBA Base: Constants/IB_MAD_ATTR_NODE_DESC
+* NAME
+* IB_MAD_ATTR_NODE_DESC
+*
+* DESCRIPTION
+* NodeDescription attribute (14.2.5)
+*
+* SOURCE
+*/
+#define IB_MAD_ATTR_NODE_DESC (CL_HTON16(0x0010))
+
+/****d* IBA Base: Constants/IB_MAD_ATTR_PORT_SMPL_CTRL
+* NAME
+* IB_MAD_ATTR_PORT_SMPL_CTRL
+*
+* DESCRIPTION
+* PortSamplesControl attribute (16.1.3)
+*
+* SOURCE
+*/
+#define IB_MAD_ATTR_PORT_SMPL_CTRL (CL_HTON16(0x0010))
+/**********/
+
+/****d* IBA Base: Constants/IB_MAD_ATTR_NODE_INFO
+* NAME
+* IB_MAD_ATTR_NODE_INFO
+*
+* DESCRIPTION
+* NodeInfo attribute (14.2.5)
+*
+* SOURCE
+*/
+#define IB_MAD_ATTR_NODE_INFO (CL_HTON16(0x0011))
+/**********/
+
+/****d* IBA Base: Constants/IB_MAD_ATTR_PORT_SMPL_RSLT
+* NAME
+* IB_MAD_ATTR_PORT_SMPL_RSLT
+*
+* DESCRIPTION
+* PortSamplesResult attribute (16.1.3)
+*
+* SOURCE
+*/
+#define IB_MAD_ATTR_PORT_SMPL_RSLT (CL_HTON16(0x0011))
+/**********/
+
+/****d* IBA Base: Constants/IB_MAD_ATTR_SWITCH_INFO
+* NAME
+* IB_MAD_ATTR_SWITCH_INFO
+*
+* DESCRIPTION
+* SwitchInfo attribute (14.2.5)
+*
+* SOURCE
+*/
+#define IB_MAD_ATTR_SWITCH_INFO (CL_HTON16(0x0012))
+/**********/
+
+/****d* IBA Base: Constants/IB_MAD_ATTR_PORT_CNTRS
+* NAME
+* IB_MAD_ATTR_PORT_CNTRS
+*
+* DESCRIPTION
+* PortCounters attribute (16.1.3)
+*
+* SOURCE
+*/
+#define IB_MAD_ATTR_PORT_CNTRS (CL_HTON16(0x0012))
+/**********/
+
+/****d* IBA Base: Constants/IB_MAD_ATTR_PORT_CNTRS_EXT
+* NAME
+* IB_MAD_ATTR_PORT_CNTRS_EXT
+*
+* DESCRIPTION
+* PortCountersExtended attribute (16.1.4)
+*
+* SOURCE
+*/
+#define IB_MAD_ATTR_PORT_CNTRS_EXT (CL_HTON16(0x001D))
+/**********/
+
+/****d* IBA Base: Constants/IB_MAD_ATTR_PORT_XMIT_DATA_SL
+* NAME
+* IB_MAD_ATTR_PORT_XMIT_DATA_SL
+*
+* DESCRIPTION
+* PortXmitDataSL attribute (A13.6.4)
+*
+* SOURCE
+*/
+#define IB_MAD_ATTR_PORT_XMIT_DATA_SL (CL_HTON16(0x0036))
+/**********/
+
+/****d* IBA Base: Constants/IB_MAD_ATTR_PORT_RCV_DATA_SL
+* NAME
+* IB_MAD_ATTR_PORT_RCV_DATA_SL
+*
+* DESCRIPTION
+* PortRcvDataSL attribute (A13.6.4)
+*
+* SOURCE
+*/
+#define IB_MAD_ATTR_PORT_RCV_DATA_SL (CL_HTON16(0x0037))
+/**********/
+
+/****d* IBA Base: Constants/IB_MAD_ATTR_GUID_INFO
+* NAME
+* IB_MAD_ATTR_GUID_INFO
+*
+* DESCRIPTION
+* GUIDInfo attribute (14.2.5)
+*
+* SOURCE
+*/
+#define IB_MAD_ATTR_GUID_INFO (CL_HTON16(0x0014))
+/**********/
+
+/****d* IBA Base: Constants/IB_MAD_ATTR_PORT_INFO
+* NAME
+* IB_MAD_ATTR_PORT_INFO
+*
+* DESCRIPTION
+* PortInfo attribute (14.2.5)
+*
+* SOURCE
+*/
+#define IB_MAD_ATTR_PORT_INFO (CL_HTON16(0x0015))
+/**********/
+
+/****d* IBA Base: Constants/IB_MAD_ATTR_P_KEY_TABLE
+* NAME
+* IB_MAD_ATTR_P_KEY_TABLE
+*
+* DESCRIPTION
+* PartitionTable attribute (14.2.5)
+*
+* SOURCE
+*/
+#define IB_MAD_ATTR_P_KEY_TABLE (CL_HTON16(0x0016))
+/**********/
+
+/****d* IBA Base: Constants/IB_MAD_ATTR_SLVL_TABLE
+* NAME
+* IB_MAD_ATTR_SLVL_TABLE
+*
+* DESCRIPTION
+* SL VL Mapping Table attribute (14.2.5)
+*
+* SOURCE
+*/
+#define IB_MAD_ATTR_SLVL_TABLE (CL_HTON16(0x0017))
+/**********/
+
+/****d* IBA Base: Constants/IB_MAD_ATTR_VL_ARBITRATION
+* NAME
+* IB_MAD_ATTR_VL_ARBITRATION
+*
+* DESCRIPTION
+* VL Arbitration Table attribute (14.2.5)
+*
+* SOURCE
+*/
+#define IB_MAD_ATTR_VL_ARBITRATION (CL_HTON16(0x0018))
+/**********/
+
+/****d* IBA Base: Constants/IB_MAD_ATTR_LIN_FWD_TBL
+* NAME
+* IB_MAD_ATTR_LIN_FWD_TBL
+*
+* DESCRIPTION
+* Switch linear forwarding table
+*
+* SOURCE
+*/
+#define IB_MAD_ATTR_LIN_FWD_TBL (CL_HTON16(0x0019))
+/**********/
+
+/****d* IBA Base: Constants/IB_MAD_ATTR_RND_FWD_TBL
+* NAME
+* IB_MAD_ATTR_RND_FWD_TBL
+*
+* DESCRIPTION
+* Switch random forwarding table
+*
+* SOURCE
+*/
+#define IB_MAD_ATTR_RND_FWD_TBL (CL_HTON16(0x001A))
+/**********/
+
+/****d* IBA Base: Constants/IB_MAD_ATTR_MCAST_FWD_TBL
+* NAME
+* IB_MAD_ATTR_MCAST_FWD_TBL
+*
+* DESCRIPTION
+* Switch multicast forwarding table
+*
+* SOURCE
+*/
+#define IB_MAD_ATTR_MCAST_FWD_TBL (CL_HTON16(0x001B))
+/**********/
+
+/****d* IBA Base: Constants/IB_MAD_ATTR_NODE_RECORD
+* NAME
+* IB_MAD_ATTR_NODE_RECORD
+*
+* DESCRIPTION
+* NodeRecord attribute (15.2.5)
+*
+* SOURCE
+*/
+#define IB_MAD_ATTR_NODE_RECORD (CL_HTON16(0x0011))
+/**********/
+
+/****d* IBA Base: Constants/IB_MAD_ATTR_PORTINFO_RECORD
+* NAME
+* IB_MAD_ATTR_PORTINFO_RECORD
+*
+* DESCRIPTION
+* PortInfoRecord attribute (15.2.5)
+*
+* SOURCE
+*/
+#define IB_MAD_ATTR_PORTINFO_RECORD (CL_HTON16(0x0012))
+/**********/
+
+/****d* IBA Base: Constants/IB_MAD_ATTR_SWITCH_INFO_RECORD
+* NAME
+* IB_MAD_ATTR_SWITCH_INFO_RECORD
+*
+* DESCRIPTION
+* SwitchInfoRecord attribute (15.2.5)
+*
+* SOURCE
+*/
+#define IB_MAD_ATTR_SWITCH_INFO_RECORD (CL_HTON16(0x0014))
+/**********/
+
+/****d* IBA Base: Constants/IB_MAD_ATTR_LINK_RECORD
+* NAME
+* IB_MAD_ATTR_LINK_RECORD
+*
+* DESCRIPTION
+* LinkRecord attribute (15.2.5)
+*
+* SOURCE
+*/
+#define IB_MAD_ATTR_LINK_RECORD (CL_HTON16(0x0020))
+/**********/
+
+/****d* IBA Base: Constants/IB_MAD_ATTR_SM_INFO
+* NAME
+* IB_MAD_ATTR_SM_INFO
+*
+* DESCRIPTION
+* SMInfo attribute (14.2.5)
+*
+* SOURCE
+*/
+#define IB_MAD_ATTR_SM_INFO (CL_HTON16(0x0020))
+/**********/
+
+/****d* IBA Base: Constants/IB_MAD_ATTR_SMINFO_RECORD
+* NAME
+* IB_MAD_ATTR_SMINFO_RECORD
+*
+* DESCRIPTION
+* SMInfoRecord attribute (15.2.5)
+*
+* SOURCE
+*/
+#define IB_MAD_ATTR_SMINFO_RECORD (CL_HTON16(0x0018))
+/**********/
+
+/****d* IBA Base: Constants/IB_MAD_ATTR_GUIDINFO_RECORD
+* NAME
+* IB_MAD_ATTR_GUIDINFO_RECORD
+*
+* DESCRIPTION
+* GuidInfoRecord attribute (15.2.5)
+*
+* SOURCE
+*/
+#define IB_MAD_ATTR_GUIDINFO_RECORD (CL_HTON16(0x0030))
+/**********/
+
+/****d* IBA Base: Constants/IB_MAD_ATTR_VENDOR_DIAG
+* NAME
+* IB_MAD_ATTR_VENDOR_DIAG
+*
+* DESCRIPTION
+* VendorDiag attribute (14.2.5)
+*
+* SOURCE
+*/
+#define IB_MAD_ATTR_VENDOR_DIAG (CL_HTON16(0x0030))
+/**********/
+
+/****d* IBA Base: Constants/IB_MAD_ATTR_LED_INFO
+* NAME
+* IB_MAD_ATTR_LED_INFO
+*
+* DESCRIPTION
+* LedInfo attribute (14.2.5)
+*
+* SOURCE
+*/
+#define IB_MAD_ATTR_LED_INFO (CL_HTON16(0x0031))
+/**********/
+
+/****d* IBA Base: Constants/IB_MAD_ATTR_MLNX_EXTENDED_PORT_INFO
+* NAME
+* IB_MAD_ATTR_MLNX_EXTENDED_PORT_INFO
+*
+* DESCRIPTION
+* Vendor specific SM attribute (14.2.5)
+*
+* SOURCE
+*/
+#define IB_MAD_ATTR_MLNX_EXTENDED_PORT_INFO (CL_HTON16(0xFF90))
+/**********/
+
+/****d* IBA Base: Constants/IB_MAD_ATTR_SERVICE_RECORD
+* NAME
+* IB_MAD_ATTR_SERVICE_RECORD
+*
+* DESCRIPTION
+* ServiceRecord attribute (15.2.5)
+*
+* SOURCE
+*/
+#define IB_MAD_ATTR_SERVICE_RECORD (CL_HTON16(0x0031))
+/**********/
+
+/****d* IBA Base: Constants/IB_MAD_ATTR_LFT_RECORD
+* NAME
+* IB_MAD_ATTR_LFT_RECORD
+*
+* DESCRIPTION
+* LinearForwardingTableRecord attribute (15.2.5.6)
+*
+* SOURCE
+*/
+#define IB_MAD_ATTR_LFT_RECORD (CL_HTON16(0x0015))
+/**********/
+
+/****d* IBA Base: Constants/IB_MAD_ATTR_MFT_RECORD
+* NAME
+* IB_MAD_ATTR_MFT_RECORD
+*
+* DESCRIPTION
+* MulticastForwardingTableRecord attribute (15.2.5.8)
+*
+* SOURCE
+*/
+#define IB_MAD_ATTR_MFT_RECORD (CL_HTON16(0x0017))
+/**********/
+
+/****d* IBA Base: Constants/IB_MAD_ATTR_PKEYTBL_RECORD
+* NAME
+* IB_MAD_ATTR_PKEYTBL_RECORD
+*
+* DESCRIPTION
+* PKEY Table Record attribute (15.2.5)
+*
+* SOURCE
+*/
+#define IB_MAD_ATTR_PKEY_TBL_RECORD (CL_HTON16(0x0033))
+/**********/
+
+/****d* IBA Base: Constants/IB_MAD_ATTR_PATH_RECORD
+* NAME
+* IB_MAD_ATTR_PATH_RECORD
+*
+* DESCRIPTION
+* PathRecord attribute (15.2.5)
+*
+* SOURCE
+*/
+#define IB_MAD_ATTR_PATH_RECORD (CL_HTON16(0x0035))
+/**********/
+
+/****d* IBA Base: Constants/IB_MAD_ATTR_VLARB_RECORD
+* NAME
+* IB_MAD_ATTR_VLARB_RECORD
+*
+* DESCRIPTION
+* VL Arbitration Table Record attribute (15.2.5)
+*
+* SOURCE
+*/
+#define IB_MAD_ATTR_VLARB_RECORD (CL_HTON16(0x0036))
+/**********/
+
+/****d* IBA Base: Constants/IB_MAD_ATTR_SLVL_RECORD
+* NAME
+* IB_MAD_ATTR_SLVL_RECORD
+*
+* DESCRIPTION
+* SLtoVL Mapping Table Record attribute (15.2.5)
+*
+* SOURCE
+*/
+#define IB_MAD_ATTR_SLVL_RECORD (CL_HTON16(0x0013))
+/**********/
+
+/****d* IBA Base: Constants/IB_MAD_ATTR_MCMEMBER_RECORD
+* NAME
+* IB_MAD_ATTR_MCMEMBER_RECORD
+*
+* DESCRIPTION
+* MCMemberRecord attribute (15.2.5)
+*
+* SOURCE
+*/
+#define IB_MAD_ATTR_MCMEMBER_RECORD (CL_HTON16(0x0038))
+/**********/
+
+/****d* IBA Base: Constants/IB_MAD_ATTR_TRACE_RECORD
+* NAME
+* IB_MAD_ATTR_TRACE_RECORD
+*
+* DESCRIPTION
+* TraceRecord attribute (15.2.5)
+*
+* SOURCE
+*/
+#define IB_MAD_ATTR_TRACE_RECORD (CL_HTON16(0x0039))
+/**********/
+
+/****d* IBA Base: Constants/IB_MAD_ATTR_MULTIPATH_RECORD
+* NAME
+* IB_MAD_ATTR_MULTIPATH_RECORD
+*
+* DESCRIPTION
+* MultiPathRecord attribute (15.2.5)
+*
+* SOURCE
+*/
+#define IB_MAD_ATTR_MULTIPATH_RECORD (CL_HTON16(0x003A))
+/**********/
+
+/****d* IBA Base: Constants/IB_MAD_ATTR_SVC_ASSOCIATION_RECORD
+* NAME
+* IB_MAD_ATTR_SVC_ASSOCIATION_RECORD
+*
+* DESCRIPTION
+* Service Association Record attribute (15.2.5)
+*
+* SOURCE
+*/
+#define IB_MAD_ATTR_SVC_ASSOCIATION_RECORD (CL_HTON16(0x003B))
+/**********/
+
+/****d* IBA Base: Constants/IB_MAD_ATTR_INFORM_INFO_RECORD
+* NAME
+* IB_MAD_ATTR_INFORM_INFO_RECORD
+*
+* DESCRIPTION
+* InformInfo Record attribute (15.2.5)
+*
+* SOURCE
+*/
+#define IB_MAD_ATTR_INFORM_INFO_RECORD (CL_HTON16(0x00F3))
+
+/****d* IBA Base: Constants/IB_MAD_ATTR_IO_UNIT_INFO
+* NAME
+* IB_MAD_ATTR_IO_UNIT_INFO
+*
+* DESCRIPTION
+* IOUnitInfo attribute (16.3.3)
+*
+* SOURCE
+*/
+#define IB_MAD_ATTR_IO_UNIT_INFO (CL_HTON16(0x0010))
+/**********/
+
+/****d* IBA Base: Constants/IB_MAD_ATTR_IO_CONTROLLER_PROFILE
+* NAME
+* IB_MAD_ATTR_IO_CONTROLLER_PROFILE
+*
+* DESCRIPTION
+* IOControllerProfile attribute (16.3.3)
+*
+* SOURCE
+*/
+#define IB_MAD_ATTR_IO_CONTROLLER_PROFILE (CL_HTON16(0x0011))
+/**********/
+
+/****d* IBA Base: Constants/IB_MAD_ATTR_SERVICE_ENTRIES
+* NAME
+* IB_MAD_ATTR_SERVICE_ENTRIES
+*
+* DESCRIPTION
+* ServiceEntries attribute (16.3.3)
+*
+* SOURCE
+*/
+#define IB_MAD_ATTR_SERVICE_ENTRIES (CL_HTON16(0x0012))
+/**********/
+
+/****d* IBA Base: Constants/IB_MAD_ATTR_DIAGNOSTIC_TIMEOUT
+* NAME
+* IB_MAD_ATTR_DIAGNOSTIC_TIMEOUT
+*
+* DESCRIPTION
+* DiagnosticTimeout attribute (16.3.3)
+*
+* SOURCE
+*/
+#define IB_MAD_ATTR_DIAGNOSTIC_TIMEOUT (CL_HTON16(0x0020))
+/**********/
+
+/****d* IBA Base: Constants/IB_MAD_ATTR_PREPARE_TO_TEST
+* NAME
+* IB_MAD_ATTR_PREPARE_TO_TEST
+*
+* DESCRIPTION
+* PrepareToTest attribute (16.3.3)
+*
+* SOURCE
+*/
+#define IB_MAD_ATTR_PREPARE_TO_TEST (CL_HTON16(0x0021))
+/**********/
+
+/****d* IBA Base: Constants/IB_MAD_ATTR_TEST_DEVICE_ONCE
+* NAME
+* IB_MAD_ATTR_TEST_DEVICE_ONCE
+*
+* DESCRIPTION
+* TestDeviceOnce attribute (16.3.3)
+*
+* SOURCE
+*/
+#define IB_MAD_ATTR_TEST_DEVICE_ONCE (CL_HTON16(0x0022))
+/**********/
+
+/****d* IBA Base: Constants/IB_MAD_ATTR_TEST_DEVICE_LOOP
+* NAME
+* IB_MAD_ATTR_TEST_DEVICE_LOOP
+*
+* DESCRIPTION
+* TestDeviceLoop attribute (16.3.3)
+*
+* SOURCE
+*/
+#define IB_MAD_ATTR_TEST_DEVICE_LOOP (CL_HTON16(0x0023))
+/**********/
+
+/****d* IBA Base: Constants/IB_MAD_ATTR_DIAG_CODE
+* NAME
+* IB_MAD_ATTR_DIAG_CODE
+*
+* DESCRIPTION
+* DiagCode attribute (16.3.3)
+*
+* SOURCE
+*/
+#define IB_MAD_ATTR_DIAG_CODE (CL_HTON16(0x0024))
+/**********/
+
+/****d* IBA Base: Constants/IB_MAD_ATTR_SVC_ASSOCIATION_RECORD
+* NAME
+* IB_MAD_ATTR_SVC_ASSOCIATION_RECORD
+*
+* DESCRIPTION
+* Service Association Record attribute (15.2.5)
+*
+* SOURCE
+*/
+#define IB_MAD_ATTR_SVC_ASSOCIATION_RECORD (CL_HTON16(0x003B))
+/**********/
+
+/****d* IBA Base: Constants/IB_MAD_ATTR_CONG_INFO
+* NAME
+* IB_MAD_ATTR_CONG_INFO
+*
+* DESCRIPTION
+* CongestionInfo attribute (A10.4.3)
+*
+* SOURCE
+*/
+#define IB_MAD_ATTR_CONG_INFO (CL_HTON16(0x0011))
+/**********/
+
+/****d* IBA Base: Constants/IB_MAD_ATTR_CONG_KEY_INFO
+* NAME
+* IB_MAD_ATTR_CONG_KEY_INFO
+*
+* DESCRIPTION
+* CongestionKeyInfo attribute (A10.4.3)
+*
+* SOURCE
+*/
+#define IB_MAD_ATTR_CONG_KEY_INFO (CL_HTON16(0x0012))
+/**********/
+
+/****d* IBA Base: Constants/IB_MAD_ATTR_CONG_LOG
+* NAME
+* IB_MAD_ATTR_CONG_LOG
+*
+* DESCRIPTION
+* CongestionLog attribute (A10.4.3)
+*
+* SOURCE
+*/
+#define IB_MAD_ATTR_CONG_LOG (CL_HTON16(0x0013))
+/**********/
+
+/****d* IBA Base: Constants/IB_MAD_ATTR_SW_CONG_SETTING
+* NAME
+* IB_MAD_ATTR_SW_CONG_SETTING
+*
+* DESCRIPTION
+* SwitchCongestionSetting attribute (A10.4.3)
+*
+* SOURCE
+*/
+#define IB_MAD_ATTR_SW_CONG_SETTING (CL_HTON16(0x0014))
+/**********/
+
+/****d* IBA Base: Constants/IB_MAD_ATTR_SW_PORT_CONG_SETTING
+* NAME
+* IB_MAD_ATTR_SW_PORT_CONG_SETTING
+*
+* DESCRIPTION
+* SwitchPortCongestionSetting attribute (A10.4.3)
+*
+* SOURCE
+*/
+#define IB_MAD_ATTR_SW_PORT_CONG_SETTING (CL_HTON16(0x0015))
+/**********/
+
+/****d* IBA Base: Constants/IB_MAD_ATTR_CA_CONG_SETTING
+* NAME
+* IB_MAD_ATTR_CA_CONG_SETTING
+*
+* DESCRIPTION
+* CACongestionSetting attribute (A10.4.3)
+*
+* SOURCE
+*/
+#define IB_MAD_ATTR_CA_CONG_SETTING (CL_HTON16(0x0016))
+/**********/
+
+/****d* IBA Base: Constants/IB_MAD_ATTR_CC_TBL
+* NAME
+* IB_MAD_ATTR_CC_TBL
+*
+* DESCRIPTION
+* CongestionControlTable attribute (A10.4.3)
+*
+* SOURCE
+*/
+#define IB_MAD_ATTR_CC_TBL (CL_HTON16(0x0017))
+/**********/
+
+/****d* IBA Base: Constants/IB_MAD_ATTR_TIME_STAMP
+* NAME
+* IB_MAD_ATTR_TIME_STAMP
+*
+* DESCRIPTION
+* TimeStamp attribute (A10.4.3)
+*
+* SOURCE
+*/
+#define IB_MAD_ATTR_TIME_STAMP (CL_HTON16(0x0018))
+/**********/
+
+/****d* IBA Base: Constants/IB_NODE_TYPE_CA
+* NAME
+* IB_NODE_TYPE_CA
+*
+* DESCRIPTION
+* Encoded generic node type used in MAD attributes (13.4.8.2)
+*
+* SOURCE
+*/
+#define IB_NODE_TYPE_CA 0x01
+/**********/
+
+/****d* IBA Base: Constants/IB_NODE_TYPE_SWITCH
+* NAME
+* IB_NODE_TYPE_SWITCH
+*
+* DESCRIPTION
+* Encoded generic node type used in MAD attributes (13.4.8.2)
+*
+* SOURCE
+*/
+#define IB_NODE_TYPE_SWITCH 0x02
+/**********/
+
+/****d* IBA Base: Constants/IB_NODE_TYPE_ROUTER
+* NAME
+* IB_NODE_TYPE_ROUTER
+*
+* DESCRIPTION
+* Encoded generic node type used in MAD attributes (13.4.8.2)
+*
+* SOURCE
+*/
+#define IB_NODE_TYPE_ROUTER 0x03
+/**********/
+
+/****d* IBA Base: Constants/IB_NOTICE_PRODUCER_TYPE_CA
+* NAME
+* IB_NOTICE_PRODUCER_TYPE_CA
+*
+* DESCRIPTION
+* Encoded generic producer type used in Notice attribute (13.4.8.2)
+*
+* SOURCE
+*/
+#define IB_NOTICE_PRODUCER_TYPE_CA (CL_HTON32(0x000001))
+/**********/
+
+/****d* IBA Base: Constants/IB_NOTICE_PRODUCER_TYPE_SWITCH
+* NAME
+* IB_NOTICE_PRODUCER_TYPE_SWITCH
+*
+* DESCRIPTION
+* Encoded generic producer type used in Notice attribute (13.4.8.2)
+*
+* SOURCE
+*/
+#define IB_NOTICE_PRODUCER_TYPE_SWITCH (CL_HTON32(0x000002))
+/**********/
+
+/****d* IBA Base: Constants/IB_NOTICE_PRODUCER_TYPE_ROUTER
+* NAME
+* IB_NOTICE_PRODUCER_TYPE_ROUTER
+*
+* DESCRIPTION
+* Encoded generic producer type used in Notice attribute (13.4.8.2)
+*
+* SOURCE
+*/
+#define IB_NOTICE_PRODUCER_TYPE_ROUTER (CL_HTON32(0x000003))
+/**********/
+
+/****d* IBA Base: Constants/IB_NOTICE_PRODUCER_TYPE_CLASS_MGR
+* NAME
+* IB_NOTICE_PRODUCER_TYPE_CLASS_MGR
+*
+* DESCRIPTION
+* Encoded generic producer type used in Notice attribute (13.4.8.2)
+*
+* SOURCE
+*/
+#define IB_NOTICE_PRODUCER_TYPE_CLASS_MGR (CL_HTON32(0x000004))
+/**********/
+
+/****d* IBA Base: Constants/IB_MTU_LEN_TYPE
+* NAME
+* IB_MTU_LEN_TYPE
+*
+* DESCRIPTION
+* Encoded path MTU.
+* 1: 256
+* 2: 512
+* 3: 1024
+* 4: 2048
+* 5: 4096
+* others: reserved
+*
+* SOURCE
+*/
+#define IB_MTU_LEN_256 1
+#define IB_MTU_LEN_512 2
+#define IB_MTU_LEN_1024 3
+#define IB_MTU_LEN_2048 4
+#define IB_MTU_LEN_4096 5
+
+#define IB_MIN_MTU IB_MTU_LEN_256
+#define IB_MAX_MTU IB_MTU_LEN_4096
+
+/**********/
+
+/****d* IBA Base: Constants/IB_PATH_SELECTOR_TYPE
+* NAME
+* IB_PATH_SELECTOR_TYPE
+*
+* DESCRIPTION
+* Path selector.
+* 0: greater than specified
+* 1: less than specified
+* 2: exactly the specified
+* 3: largest available
+*
+* SOURCE
+*/
+#define IB_PATH_SELECTOR_GREATER_THAN 0
+#define IB_PATH_SELECTOR_LESS_THAN 1
+#define IB_PATH_SELECTOR_EXACTLY 2
+#define IB_PATH_SELECTOR_LARGEST 3
+/**********/
+
+/****d* IBA Base: Constants/IB_SMINFO_STATE_NOTACTIVE
+* NAME
+* IB_SMINFO_STATE_NOTACTIVE
+*
+* DESCRIPTION
+* Encoded state value used in the SMInfo attribute.
+*
+* SOURCE
+*/
+#define IB_SMINFO_STATE_NOTACTIVE 0
+/**********/
+
+/****d* IBA Base: Constants/IB_SMINFO_STATE_DISCOVERING
+* NAME
+* IB_SMINFO_STATE_DISCOVERING
+*
+* DESCRIPTION
+* Encoded state value used in the SMInfo attribute.
+*
+* SOURCE
+*/
+#define IB_SMINFO_STATE_DISCOVERING 1
+/**********/
+
+/****d* IBA Base: Constants/IB_SMINFO_STATE_STANDBY
+* NAME
+* IB_SMINFO_STATE_STANDBY
+*
+* DESCRIPTION
+* Encoded state value used in the SMInfo attribute.
+*
+* SOURCE
+*/
+#define IB_SMINFO_STATE_STANDBY 2
+/**********/
+
+/****d* IBA Base: Constants/IB_SMINFO_STATE_MASTER
+* NAME
+* IB_SMINFO_STATE_MASTER
+*
+* DESCRIPTION
+* Encoded state value used in the SMInfo attribute.
+*
+* SOURCE
+*/
+#define IB_SMINFO_STATE_MASTER 3
+/**********/
+
+/****d* IBA Base: Constants/IB_PATH_REC_SL_MASK
+* NAME
+* IB_PATH_REC_SL_MASK
+*
+* DESCRIPTION
+* Mask for the sl field for path record
+*
+* SOURCE
+*/
+#define IB_PATH_REC_SL_MASK 0x000F
+
+/****d* IBA Base: Constants/IB_MULTIPATH_REC_SL_MASK
+* NAME
+* IB_MULTIPATH_REC_SL_MASK
+*
+* DESCRIPTION
+* Mask for the sl field for MultiPath record
+*
+* SOURCE
+*/
+#define IB_MULTIPATH_REC_SL_MASK 0x000F
+
+/****d* IBA Base: Constants/IB_PATH_REC_QOS_CLASS_MASK
+* NAME
+* IB_PATH_REC_QOS_CLASS_MASK
+*
+* DESCRIPTION
+* Mask for the QoS class field for path record
+*
+* SOURCE
+*/
+#define IB_PATH_REC_QOS_CLASS_MASK 0xFFF0
+
+/****d* IBA Base: Constants/IB_MULTIPATH_REC_QOS_CLASS_MASK
+* NAME
+* IB_MULTIPATH_REC_QOS_CLASS_MASK
+*
+* DESCRIPTION
+* Mask for the QoS class field for MultiPath record
+*
+* SOURCE
+*/
+#define IB_MULTIPATH_REC_QOS_CLASS_MASK 0xFFF0
+
+/****d* IBA Base: Constants/IB_PATH_REC_SELECTOR_MASK
+* NAME
+* IB_PATH_REC_SELECTOR_MASK
+*
+* DESCRIPTION
+* Mask for the selector field for path record MTU, rate,
+* and packet lifetime.
+*
+* SOURCE
+*/
+#define IB_PATH_REC_SELECTOR_MASK 0xC0
+
+/****d* IBA Base: Constants/IB_MULTIPATH_REC_SELECTOR_MASK
+* NAME
+* IB_MULTIPATH_REC_SELECTOR_MASK
+*
+* DESCRIPTION
+* Mask for the selector field for multipath record MTU, rate,
+* and packet lifetime.
+*
+* SOURCE
+*/
+#define IB_MULTIPATH_REC_SELECTOR_MASK 0xC0
+/**********/
+
+/****d* IBA Base: Constants/IB_PATH_REC_BASE_MASK
+* NAME
+* IB_PATH_REC_BASE_MASK
+*
+* DESCRIPTION
+* Mask for the base value field for path record MTU, rate,
+* and packet lifetime.
+*
+* SOURCE
+*/
+#define IB_PATH_REC_BASE_MASK 0x3F
+/**********/
+
+/****d* IBA Base: Constants/IB_MULTIPATH_REC_BASE_MASK
+* NAME
+* IB_MULTIPATH_REC_BASE_MASK
+*
+* DESCRIPTION
+* Mask for the base value field for multipath record MTU, rate,
+* and packet lifetime.
+*
+* SOURCE
+*/
+#define IB_MULTIPATH_REC_BASE_MASK 0x3F
+/**********/
+
+/****h* IBA Base/Type Definitions
+* NAME
+* Type Definitions
+*
+* DESCRIPTION
+* Definitions are from the InfiniBand Architecture Specification v1.2
+*
+*********/
+
+/****d* IBA Base: Types/ib_net16_t
+* NAME
+* ib_net16_t
+*
+* DESCRIPTION
+* Defines the network ordered type for 16-bit values.
+*
+* SOURCE
+*/
+typedef uint16_t ib_net16_t;
+/**********/
+
+/****d* IBA Base: Types/ib_net32_t
+* NAME
+* ib_net32_t
+*
+* DESCRIPTION
+* Defines the network ordered type for 32-bit values.
+*
+* SOURCE
+*/
+typedef uint32_t ib_net32_t;
+/**********/
+
+/****d* IBA Base: Types/ib_net64_t
+* NAME
+* ib_net64_t
+*
+* DESCRIPTION
+* Defines the network ordered type for 64-bit values.
+*
+* SOURCE
+*/
+typedef uint64_t ib_net64_t;
+/**********/
+
+/****d* IBA Base: Types/ib_gid_prefix_t
+* NAME
+* ib_gid_prefix_t
+*
+* DESCRIPTION
+*
+* SOURCE
+*/
+typedef ib_net64_t ib_gid_prefix_t;
+/**********/
+
+/****d* IBA Base: Constants/ib_link_states_t
+* NAME
+* ib_link_states_t
+*
+* DESCRIPTION
+* Defines the link states of a port.
+*
+* SOURCE
+*/
+#define IB_LINK_NO_CHANGE 0
+#define IB_LINK_DOWN 1
+#define IB_LINK_INIT 2
+#define IB_LINK_ARMED 3
+#define IB_LINK_ACTIVE 4
+#define IB_LINK_ACT_DEFER 5
+/**********/
+
+static const char *const __ib_node_type_str[] = {
+ "UNKNOWN",
+ "Channel Adapter",
+ "Switch",
+ "Router"
+};
+
+/****f* IBA Base: Types/ib_get_node_type_str
+* NAME
+* ib_get_node_type_str
+*
+* DESCRIPTION
+* Returns a string for the specified node type.
+* 14.2.5.3 NodeInfo
+*
+* SYNOPSIS
+*/
+static inline const char *OSM_API ib_get_node_type_str(IN uint8_t node_type)
+{
+ if (node_type > IB_NODE_TYPE_ROUTER)
+ node_type = 0;
+ return (__ib_node_type_str[node_type]);
+}
+
+/*
+* PARAMETERS
+* node_type
+* [in] Encoded node type as returned in the NodeInfo attribute.
+
+* RETURN VALUES
+* Pointer to the node type string.
+*
+* NOTES
+*
+* SEE ALSO
+* ib_node_info_t
+*********/
+
+static const char *const __ib_producer_type_str[] = {
+ "UNKNOWN",
+ "Channel Adapter",
+ "Switch",
+ "Router",
+ "Class Manager"
+};
+
+/****f* IBA Base: Types/ib_get_producer_type_str
+* NAME
+* ib_get_producer_type_str
+*
+* DESCRIPTION
+* Returns a string for the specified producer type
+* 13.4.8.2 Notice
+* 13.4.8.3 InformInfo
+*
+* SYNOPSIS
+*/
+static inline const char *OSM_API
+ib_get_producer_type_str(IN ib_net32_t producer_type)
+{
+ if (cl_ntoh32(producer_type) >
+ CL_NTOH32(IB_NOTICE_PRODUCER_TYPE_CLASS_MGR))
+ producer_type = 0;
+ return (__ib_producer_type_str[cl_ntoh32(producer_type)]);
+}
+
+/*
+* PARAMETERS
+* producer_type
+* [in] Encoded producer type from the Notice attribute
+
+* RETURN VALUES
+* Pointer to the producer type string.
+*
+* NOTES
+*
+* SEE ALSO
+* ib_notice_get_prod_type
+*********/
+
+static const char *const __ib_port_state_str[] = {
+ "No State Change (NOP)",
+ "DOWN",
+ "INIT",
+ "ARMED",
+ "ACTIVE",
+ "ACTDEFER",
+ "UNKNOWN"
+};
+
+/****f* IBA Base: Types/ib_get_port_state_str
+* NAME
+* ib_get_port_state_str
+*
+* DESCRIPTION
+* Returns a string for the specified port state.
+*
+* SYNOPSIS
+*/
+static inline const char *OSM_API ib_get_port_state_str(IN uint8_t port_state)
+{
+ if (port_state > IB_LINK_ACTIVE)
+ port_state = IB_LINK_ACTIVE + 1;
+ return (__ib_port_state_str[port_state]);
+}
+
+/*
+* PARAMETERS
+* port_state
+* [in] Encoded port state as returned in the PortInfo attribute.
+
+* RETURN VALUES
+* Pointer to the port state string.
+*
+* NOTES
+*
+* SEE ALSO
+* ib_port_info_t
+*********/
+
+/****f* IBA Base: Types/ib_get_port_state_from_str
+* NAME
+* ib_get_port_state_from_str
+*
+* DESCRIPTION
+* Returns a string for the specified port state.
+*
+* SYNOPSIS
+*/
+static inline uint8_t OSM_API
+ib_get_port_state_from_str(IN char *p_port_state_str)
+{
+ if (!strncmp(p_port_state_str, "No State Change (NOP)", 12))
+ return (0);
+ else if (!strncmp(p_port_state_str, "DOWN", 4))
+ return (1);
+ else if (!strncmp(p_port_state_str, "INIT", 4))
+ return (2);
+ else if (!strncmp(p_port_state_str, "ARMED", 5))
+ return (3);
+ else if (!strncmp(p_port_state_str, "ACTIVE", 6))
+ return (4);
+ else if (!strncmp(p_port_state_str, "ACTDEFER", 8))
+ return (5);
+ return (6);
+}
+
+/*
+* PARAMETERS
+* p_port_state_str
+* [in] A string matching one returned by ib_get_port_state_str
+*
+* RETURN VALUES
+* The appropriate code.
+*
+* NOTES
+*
+* SEE ALSO
+* ib_port_info_t
+*********/
+
+/****d* IBA Base: Constants/Join States
+* NAME
+* Join States
+*
+* DESCRIPTION
+* Defines the join state flags for multicast group management.
+*
+* SOURCE
+*/
+#define IB_JOIN_STATE_FULL 1
+#define IB_JOIN_STATE_NON 2
+#define IB_JOIN_STATE_SEND_ONLY 4
+/**********/
+
+/****f* IBA Base: Types/ib_pkey_get_base
+* NAME
+* ib_pkey_get_base
+*
+* DESCRIPTION
+* Returns the base P_Key value with the membership bit stripped.
+*
+* SYNOPSIS
+*/
+static inline ib_net16_t OSM_API ib_pkey_get_base(IN const ib_net16_t pkey)
+{
+ return ((ib_net16_t) (pkey & IB_PKEY_BASE_MASK));
+}
+
+/*
+* PARAMETERS
+* pkey
+* [in] P_Key value
+*
+* RETURN VALUE
+* Returns the base P_Key value with the membership bit stripped.
+*
+* NOTES
+*
+* SEE ALSO
+*********/
+
+/****f* IBA Base: Types/ib_pkey_is_full_member
+* NAME
+* ib_pkey_is_full_member
+*
+* DESCRIPTION
+* Indicates if the port is a full member of the partition.
+*
+* SYNOPSIS
+*/
+static inline boolean_t OSM_API ib_pkey_is_full_member(IN const ib_net16_t pkey)
+{
+ return ((pkey & IB_PKEY_TYPE_MASK) == IB_PKEY_TYPE_MASK);
+}
+
+/*
+* PARAMETERS
+* pkey
+* [in] P_Key value
+*
+* RETURN VALUE
+* TRUE if the port is a full member of the partition.
+* FALSE otherwise.
+*
+* NOTES
+*
+* SEE ALSO
+* ib_pkey_get_base, ib_net16_t
+*********/
+
+/****f* IBA Base: Types/ib_pkey_is_invalid
+* NAME
+* ib_pkey_is_invalid
+*
+* DESCRIPTION
+* Returns TRUE if the given P_Key is an invalid P_Key
+* C10-116: the CI shall regard a P_Key as invalid if its low-order
+* 15 bits are all zero...
+*
+* SYNOPSIS
+*/
+static inline boolean_t OSM_API ib_pkey_is_invalid(IN const ib_net16_t pkey)
+{
+ return ib_pkey_get_base(pkey) == 0x0000 ? TRUE : FALSE;
+}
+
+/*
+* PARAMETERS
+* pkey
+* [in] P_Key value
+*
+* RETURN VALUE
+* Returns the base P_Key value with the membership bit stripped.
+*
+* NOTES
+*
+* SEE ALSO
+*********/
+
+/****d* IBA Base: Types/ib_gid_t
+* NAME
+* ib_gid_t
+*
+* DESCRIPTION
+*
+* SYNOPSIS
+*/
+#include <complib/cl_packon.h>
+typedef union _ib_gid {
+ uint8_t raw[16];
+ struct _ib_gid_unicast {
+ ib_gid_prefix_t prefix;
+ ib_net64_t interface_id;
+ } PACK_SUFFIX unicast;
+ struct _ib_gid_multicast {
+ uint8_t header[2];
+ uint8_t raw_group_id[14];
+ } PACK_SUFFIX multicast;
+} PACK_SUFFIX ib_gid_t;
+#include <complib/cl_packoff.h>
+/*
+* FIELDS
+* raw
+* GID represented as an unformated byte array.
+*
+* unicast
+* Typical unicast representation with subnet prefix and
+* port GUID.
+*
+* multicast
+* Representation for multicast use.
+*
+* SEE ALSO
+*********/
+
+/****f* IBA Base: Types/ib_gid_is_multicast
+* NAME
+* ib_gid_is_multicast
+*
+* DESCRIPTION
+* Returns a boolean indicating whether a GID is a multicast GID.
+*
+* SYNOPSIS
+*/
+static inline boolean_t OSM_API ib_gid_is_multicast(IN const ib_gid_t * p_gid)
+{
+ return (p_gid->raw[0] == 0xFF);
+}
+
+/****f* IBA Base: Types/ib_gid_get_scope
+* NAME
+* ib_gid_get_scope
+*
+* DESCRIPTION
+* Returns scope of (assumed) multicast GID.
+*
+* SYNOPSIS
+*/
+static inline uint8_t OSM_API ib_mgid_get_scope(IN const ib_gid_t * p_gid)
+{
+ return (p_gid->raw[1] & 0x0F);
+}
+
+/****f* IBA Base: Types/ib_gid_set_scope
+* NAME
+* ib_gid_set_scope
+*
+* DESCRIPTION
+* Sets scope of (assumed) multicast GID.
+*
+* SYNOPSIS
+*/
+static inline void OSM_API
+ib_mgid_set_scope(IN ib_gid_t * const p_gid, IN const uint8_t scope)
+{
+ p_gid->raw[1] &= 0xF0;
+ p_gid->raw[1] |= scope & 0x0F;
+}
+
+/****f* IBA Base: Types/ib_gid_set_default
+* NAME
+* ib_gid_set_default
+*
+* DESCRIPTION
+* Sets a GID to the default value.
+*
+* SYNOPSIS
+*/
+static inline void OSM_API
+ib_gid_set_default(IN ib_gid_t * const p_gid, IN const ib_net64_t interface_id)
+{
+ p_gid->unicast.prefix = IB_DEFAULT_SUBNET_PREFIX;
+ p_gid->unicast.interface_id = interface_id;
+}
+
+/*
+* PARAMETERS
+* p_gid
+* [in] Pointer to the GID object.
+*
+* interface_id
+* [in] Manufacturer assigned EUI64 value of a port.
+*
+* RETURN VALUES
+* None.
+*
+* NOTES
+*
+* SEE ALSO
+* ib_gid_t
+*********/
+
+/****f* IBA Base: Types/ib_gid_get_subnet_prefix
+* NAME
+* ib_gid_get_subnet_prefix
+*
+* DESCRIPTION
+* Gets the subnet prefix from a GID.
+*
+* SYNOPSIS
+*/
+static inline ib_net64_t OSM_API
+ib_gid_get_subnet_prefix(IN const ib_gid_t * const p_gid)
+{
+ return (p_gid->unicast.prefix);
+}
+
+/*
+* PARAMETERS
+* p_gid
+* [in] Pointer to the GID object.
+*
+* RETURN VALUES
+* 64-bit subnet prefix value.
+*
+* NOTES
+*
+* SEE ALSO
+* ib_gid_t
+*********/
+
+/****f* IBA Base: Types/ib_gid_is_link_local
+* NAME
+* ib_gid_is_link_local
+*
+* DESCRIPTION
+* Returns TRUE if the unicast GID scoping indicates link local,
+* FALSE otherwise.
+*
+* SYNOPSIS
+*/
+static inline boolean_t OSM_API
+ib_gid_is_link_local(IN const ib_gid_t * const p_gid)
+{
+ return ((ib_gid_get_subnet_prefix(p_gid) &
+ CL_HTON64(0xFFC0000000000000ULL)) == IB_DEFAULT_SUBNET_PREFIX);
+}
+
+/*
+* PARAMETERS
+* p_gid
+* [in] Pointer to the GID object.
+*
+* RETURN VALUES
+* Returns TRUE if the unicast GID scoping indicates link local,
+* FALSE otherwise.
+*
+* NOTES
+*
+* SEE ALSO
+* ib_gid_t
+*********/
+
+/****f* IBA Base: Types/ib_gid_is_site_local
+* NAME
+* ib_gid_is_site_local
+*
+* DESCRIPTION
+* Returns TRUE if the unicast GID scoping indicates site local,
+* FALSE otherwise.
+*
+* SYNOPSIS
+*/
+static inline boolean_t OSM_API
+ib_gid_is_site_local(IN const ib_gid_t * const p_gid)
+{
+ return ((ib_gid_get_subnet_prefix(p_gid) &
+ CL_HTON64(0xFFFFFFFFFFFF0000ULL)) ==
+ CL_HTON64(0xFEC0000000000000ULL));
+}
+
+/*
+* PARAMETERS
+* p_gid
+* [in] Pointer to the GID object.
+*
+* RETURN VALUES
+* Returns TRUE if the unicast GID scoping indicates site local,
+* FALSE otherwise.
+*
+* NOTES
+*
+* SEE ALSO
+* ib_gid_t
+*********/
+
+/****f* IBA Base: Types/ib_gid_get_guid
+* NAME
+* ib_gid_get_guid
+*
+* DESCRIPTION
+* Gets the guid from a GID.
+*
+* SYNOPSIS
+*/
+static inline ib_net64_t OSM_API
+ib_gid_get_guid(IN const ib_gid_t * const p_gid)
+{
+ return (p_gid->unicast.interface_id);
+}
+
+/*
+* PARAMETERS
+* p_gid
+* [in] Pointer to the GID object.
+*
+* RETURN VALUES
+* 64-bit GUID value.
+*
+* NOTES
+*
+* SEE ALSO
+* ib_gid_t
+*********/
+
+/****s* IBA Base: Types/ib_path_rec_t
+* NAME
+* ib_path_rec_t
+*
+* DESCRIPTION
+* Path records encapsulate the properties of a given
+* route between two end-points on a subnet.
+*
+* SYNOPSIS
+*/
+#include <complib/cl_packon.h>
+typedef struct _ib_path_rec {
+ ib_net64_t service_id;
+ ib_gid_t dgid;
+ ib_gid_t sgid;
+ ib_net16_t dlid;
+ ib_net16_t slid;
+ ib_net32_t hop_flow_raw;
+ uint8_t tclass;
+ uint8_t num_path;
+ ib_net16_t pkey;
+ ib_net16_t qos_class_sl;
+ uint8_t mtu;
+ uint8_t rate;
+ uint8_t pkt_life;
+ uint8_t preference;
+ uint8_t resv2[6];
+} PACK_SUFFIX ib_path_rec_t;
+#include <complib/cl_packoff.h>
+/*
+* FIELDS
+* service_id
+* Service ID for QoS.
+*
+* dgid
+* GID of destination port.
+*
+* sgid
+* GID of source port.
+*
+* dlid
+* LID of destination port.
+*
+* slid
+* LID of source port.
+*
+* hop_flow_raw
+* Global routing parameters: hop count, flow label and raw bit.
+*
+* tclass
+* Another global routing parameter.
+*
+* num_path
+* Reversible path - 1 bit to say if path is reversible.
+* num_path [6:0] In queries, maximum number of paths to return.
+* In responses, undefined.
+*
+* pkey
+* Partition key (P_Key) to use on this path.
+*
+* qos_class_sl
+* QoS class and service level to use on this path.
+*
+* mtu
+* MTU and MTU selector fields to use on this path
+*
+* rate
+* Rate and rate selector fields to use on this path.
+*
+* pkt_life
+* Packet lifetime
+*
+* preference
+* Indicates the relative merit of this path versus other path
+* records returned from the SA. Lower numbers are better.
+*
+* resv2
+* Reserved bytes.
+* SEE ALSO
+*********/
+
+/* Path Record Component Masks */
+#define IB_PR_COMPMASK_SERVICEID_MSB (CL_HTON64(((uint64_t)1)<<0))
+#define IB_PR_COMPMASK_SERVICEID_LSB (CL_HTON64(((uint64_t)1)<<1))
+#define IB_PR_COMPMASK_DGID (CL_HTON64(((uint64_t)1)<<2))
+#define IB_PR_COMPMASK_SGID (CL_HTON64(((uint64_t)1)<<3))
+#define IB_PR_COMPMASK_DLID (CL_HTON64(((uint64_t)1)<<4))
+#define IB_PR_COMPMASK_SLID (CL_HTON64(((uint64_t)1)<<5))
+#define IB_PR_COMPMASK_RAWTRAFFIC (CL_HTON64(((uint64_t)1)<<6))
+#define IB_PR_COMPMASK_RESV0 (CL_HTON64(((uint64_t)1)<<7))
+#define IB_PR_COMPMASK_FLOWLABEL (CL_HTON64(((uint64_t)1)<<8))
+#define IB_PR_COMPMASK_HOPLIMIT (CL_HTON64(((uint64_t)1)<<9))
+#define IB_PR_COMPMASK_TCLASS (CL_HTON64(((uint64_t)1)<<10))
+#define IB_PR_COMPMASK_REVERSIBLE (CL_HTON64(((uint64_t)1)<<11))
+#define IB_PR_COMPMASK_NUMBPATH (CL_HTON64(((uint64_t)1)<<12))
+#define IB_PR_COMPMASK_PKEY (CL_HTON64(((uint64_t)1)<<13))
+#define IB_PR_COMPMASK_QOS_CLASS (CL_HTON64(((uint64_t)1)<<14))
+#define IB_PR_COMPMASK_SL (CL_HTON64(((uint64_t)1)<<15))
+#define IB_PR_COMPMASK_MTUSELEC (CL_HTON64(((uint64_t)1)<<16))
+#define IB_PR_COMPMASK_MTU (CL_HTON64(((uint64_t)1)<<17))
+#define IB_PR_COMPMASK_RATESELEC (CL_HTON64(((uint64_t)1)<<18))
+#define IB_PR_COMPMASK_RATE (CL_HTON64(((uint64_t)1)<<19))
+#define IB_PR_COMPMASK_PKTLIFETIMESELEC (CL_HTON64(((uint64_t)1)<<20))
+#define IB_PR_COMPMASK_PKTLIFETIME (CL_HTON64(((uint64_t)1)<<21))
+
+#define IB_PR_COMPMASK_SERVICEID (IB_PR_COMPMASK_SERVICEID_MSB | \
+ IB_PR_COMPMASK_SERVICEID_LSB)
+
+/* Link Record Component Masks */
+#define IB_LR_COMPMASK_FROM_LID (CL_HTON64(((uint64_t)1)<<0))
+#define IB_LR_COMPMASK_FROM_PORT (CL_HTON64(((uint64_t)1)<<1))
+#define IB_LR_COMPMASK_TO_PORT (CL_HTON64(((uint64_t)1)<<2))
+#define IB_LR_COMPMASK_TO_LID (CL_HTON64(((uint64_t)1)<<3))
+
+/* VL Arbitration Record Masks */
+#define IB_VLA_COMPMASK_LID (CL_HTON64(((uint64_t)1)<<0))
+#define IB_VLA_COMPMASK_OUT_PORT (CL_HTON64(((uint64_t)1)<<1))
+#define IB_VLA_COMPMASK_BLOCK (CL_HTON64(((uint64_t)1)<<2))
+
+/* SLtoVL Mapping Record Masks */
+#define IB_SLVL_COMPMASK_LID (CL_HTON64(((uint64_t)1)<<0))
+#define IB_SLVL_COMPMASK_IN_PORT (CL_HTON64(((uint64_t)1)<<1))
+#define IB_SLVL_COMPMASK_OUT_PORT (CL_HTON64(((uint64_t)1)<<2))
+
+/* P_Key Table Record Masks */
+#define IB_PKEY_COMPMASK_LID (CL_HTON64(((uint64_t)1)<<0))
+#define IB_PKEY_COMPMASK_BLOCK (CL_HTON64(((uint64_t)1)<<1))
+#define IB_PKEY_COMPMASK_PORT (CL_HTON64(((uint64_t)1)<<2))
+
+/* Switch Info Record Masks */
+#define IB_SWIR_COMPMASK_LID (CL_HTON64(((uint64_t)1)<<0))
+#define IB_SWIR_COMPMASK_RESERVED1 (CL_HTON64(((uint64_t)1)<<1))
+
+/* LFT Record Masks */
+#define IB_LFTR_COMPMASK_LID (CL_HTON64(((uint64_t)1)<<0))
+#define IB_LFTR_COMPMASK_BLOCK (CL_HTON64(((uint64_t)1)<<1))
+
+/* MFT Record Masks */
+#define IB_MFTR_COMPMASK_LID (CL_HTON64(((uint64_t)1)<<0))
+#define IB_MFTR_COMPMASK_POSITION (CL_HTON64(((uint64_t)1)<<1))
+#define IB_MFTR_COMPMASK_RESERVED1 (CL_HTON64(((uint64_t)1)<<2))
+#define IB_MFTR_COMPMASK_BLOCK (CL_HTON64(((uint64_t)1)<<3))
+#define IB_MFTR_COMPMASK_RESERVED2 (CL_HTON64(((uint64_t)1)<<4))
+
+/* NodeInfo Record Masks */
+#define IB_NR_COMPMASK_LID (CL_HTON64(((uint64_t)1)<<0))
+#define IB_NR_COMPMASK_RESERVED1 (CL_HTON64(((uint64_t)1)<<1))
+#define IB_NR_COMPMASK_BASEVERSION (CL_HTON64(((uint64_t)1)<<2))
+#define IB_NR_COMPMASK_CLASSVERSION (CL_HTON64(((uint64_t)1)<<3))
+#define IB_NR_COMPMASK_NODETYPE (CL_HTON64(((uint64_t)1)<<4))
+#define IB_NR_COMPMASK_NUMPORTS (CL_HTON64(((uint64_t)1)<<5))
+#define IB_NR_COMPMASK_SYSIMAGEGUID (CL_HTON64(((uint64_t)1)<<6))
+#define IB_NR_COMPMASK_NODEGUID (CL_HTON64(((uint64_t)1)<<7))
+#define IB_NR_COMPMASK_PORTGUID (CL_HTON64(((uint64_t)1)<<8))
+#define IB_NR_COMPMASK_PARTCAP (CL_HTON64(((uint64_t)1)<<9))
+#define IB_NR_COMPMASK_DEVID (CL_HTON64(((uint64_t)1)<<10))
+#define IB_NR_COMPMASK_REV (CL_HTON64(((uint64_t)1)<<11))
+#define IB_NR_COMPMASK_PORTNUM (CL_HTON64(((uint64_t)1)<<12))
+#define IB_NR_COMPMASK_VENDID (CL_HTON64(((uint64_t)1)<<13))
+#define IB_NR_COMPMASK_NODEDESC (CL_HTON64(((uint64_t)1)<<14))
+
+/* Service Record Component Masks Sec 15.2.5.14 Ver 1.1*/
+#define IB_SR_COMPMASK_SID (CL_HTON64(((uint64_t)1)<<0))
+#define IB_SR_COMPMASK_SGID (CL_HTON64(((uint64_t)1)<<1))
+#define IB_SR_COMPMASK_SPKEY (CL_HTON64(((uint64_t)1)<<2))
+#define IB_SR_COMPMASK_RES1 (CL_HTON64(((uint64_t)1)<<3))
+#define IB_SR_COMPMASK_SLEASE (CL_HTON64(((uint64_t)1)<<4))
+#define IB_SR_COMPMASK_SKEY (CL_HTON64(((uint64_t)1)<<5))
+#define IB_SR_COMPMASK_SNAME (CL_HTON64(((uint64_t)1)<<6))
+#define IB_SR_COMPMASK_SDATA8_0 (CL_HTON64(((uint64_t)1)<<7))
+#define IB_SR_COMPMASK_SDATA8_1 (CL_HTON64(((uint64_t)1)<<8))
+#define IB_SR_COMPMASK_SDATA8_2 (CL_HTON64(((uint64_t)1)<<9))
+#define IB_SR_COMPMASK_SDATA8_3 (CL_HTON64(((uint64_t)1)<<10))
+#define IB_SR_COMPMASK_SDATA8_4 (CL_HTON64(((uint64_t)1)<<11))
+#define IB_SR_COMPMASK_SDATA8_5 (CL_HTON64(((uint64_t)1)<<12))
+#define IB_SR_COMPMASK_SDATA8_6 (CL_HTON64(((uint64_t)1)<<13))
+#define IB_SR_COMPMASK_SDATA8_7 (CL_HTON64(((uint64_t)1)<<14))
+#define IB_SR_COMPMASK_SDATA8_8 (CL_HTON64(((uint64_t)1)<<15))
+#define IB_SR_COMPMASK_SDATA8_9 (CL_HTON64(((uint64_t)1)<<16))
+#define IB_SR_COMPMASK_SDATA8_10 (CL_HTON64(((uint64_t)1)<<17))
+#define IB_SR_COMPMASK_SDATA8_11 (CL_HTON64(((uint64_t)1)<<18))
+#define IB_SR_COMPMASK_SDATA8_12 (CL_HTON64(((uint64_t)1)<<19))
+#define IB_SR_COMPMASK_SDATA8_13 (CL_HTON64(((uint64_t)1)<<20))
+#define IB_SR_COMPMASK_SDATA8_14 (CL_HTON64(((uint64_t)1)<<21))
+#define IB_SR_COMPMASK_SDATA8_15 (CL_HTON64(((uint64_t)1)<<22))
+#define IB_SR_COMPMASK_SDATA16_0 (CL_HTON64(((uint64_t)1)<<23))
+#define IB_SR_COMPMASK_SDATA16_1 (CL_HTON64(((uint64_t)1)<<24))
+#define IB_SR_COMPMASK_SDATA16_2 (CL_HTON64(((uint64_t)1)<<25))
+#define IB_SR_COMPMASK_SDATA16_3 (CL_HTON64(((uint64_t)1)<<26))
+#define IB_SR_COMPMASK_SDATA16_4 (CL_HTON64(((uint64_t)1)<<27))
+#define IB_SR_COMPMASK_SDATA16_5 (CL_HTON64(((uint64_t)1)<<28))
+#define IB_SR_COMPMASK_SDATA16_6 (CL_HTON64(((uint64_t)1)<<29))
+#define IB_SR_COMPMASK_SDATA16_7 (CL_HTON64(((uint64_t)1)<<30))
+#define IB_SR_COMPMASK_SDATA32_0 (CL_HTON64(((uint64_t)1)<<31))
+#define IB_SR_COMPMASK_SDATA32_1 (CL_HTON64(((uint64_t)1)<<32))
+#define IB_SR_COMPMASK_SDATA32_2 (CL_HTON64(((uint64_t)1)<<33))
+#define IB_SR_COMPMASK_SDATA32_3 (CL_HTON64(((uint64_t)1)<<34))
+#define IB_SR_COMPMASK_SDATA64_0 (CL_HTON64(((uint64_t)1)<<35))
+#define IB_SR_COMPMASK_SDATA64_1 (CL_HTON64(((uint64_t)1)<<36))
+
+/* Port Info Record Component Masks */
+#define IB_PIR_COMPMASK_LID (CL_HTON64(((uint64_t)1)<<0))
+#define IB_PIR_COMPMASK_PORTNUM (CL_HTON64(((uint64_t)1)<<1))
+#define IB_PIR_COMPMASK_OPTIONS (CL_HTON64(((uint64_t)1)<<2))
+#define IB_PIR_COMPMASK_MKEY (CL_HTON64(((uint64_t)1)<<3))
+#define IB_PIR_COMPMASK_GIDPRE (CL_HTON64(((uint64_t)1)<<4))
+#define IB_PIR_COMPMASK_BASELID (CL_HTON64(((uint64_t)1)<<5))
+#define IB_PIR_COMPMASK_SMLID (CL_HTON64(((uint64_t)1)<<6))
+#define IB_PIR_COMPMASK_CAPMASK (CL_HTON64(((uint64_t)1)<<7))
+#define IB_PIR_COMPMASK_DIAGCODE (CL_HTON64(((uint64_t)1)<<8))
+#define IB_PIR_COMPMASK_MKEYLEASEPRD (CL_HTON64(((uint64_t)1)<<9))
+#define IB_PIR_COMPMASK_LOCALPORTNUM (CL_HTON64(((uint64_t)1)<<10))
+#define IB_PIR_COMPMASK_LINKWIDTHENABLED (CL_HTON64(((uint64_t)1)<<11))
+#define IB_PIR_COMPMASK_LNKWIDTHSUPPORT (CL_HTON64(((uint64_t)1)<<12))
+#define IB_PIR_COMPMASK_LNKWIDTHACTIVE (CL_HTON64(((uint64_t)1)<<13))
+#define IB_PIR_COMPMASK_LNKSPEEDSUPPORT (CL_HTON64(((uint64_t)1)<<14))
+#define IB_PIR_COMPMASK_PORTSTATE (CL_HTON64(((uint64_t)1)<<15))
+#define IB_PIR_COMPMASK_PORTPHYSTATE (CL_HTON64(((uint64_t)1)<<16))
+#define IB_PIR_COMPMASK_LINKDWNDFLTSTATE (CL_HTON64(((uint64_t)1)<<17))
+#define IB_PIR_COMPMASK_MKEYPROTBITS (CL_HTON64(((uint64_t)1)<<18))
+#define IB_PIR_COMPMASK_RESV2 (CL_HTON64(((uint64_t)1)<<19))
+#define IB_PIR_COMPMASK_LMC (CL_HTON64(((uint64_t)1)<<20))
+#define IB_PIR_COMPMASK_LINKSPEEDACTIVE (CL_HTON64(((uint64_t)1)<<21))
+#define IB_PIR_COMPMASK_LINKSPEEDENABLE (CL_HTON64(((uint64_t)1)<<22))
+#define IB_PIR_COMPMASK_NEIGHBORMTU (CL_HTON64(((uint64_t)1)<<23))
+#define IB_PIR_COMPMASK_MASTERSMSL (CL_HTON64(((uint64_t)1)<<24))
+#define IB_PIR_COMPMASK_VLCAP (CL_HTON64(((uint64_t)1)<<25))
+#define IB_PIR_COMPMASK_INITTYPE (CL_HTON64(((uint64_t)1)<<26))
+#define IB_PIR_COMPMASK_VLHIGHLIMIT (CL_HTON64(((uint64_t)1)<<27))
+#define IB_PIR_COMPMASK_VLARBHIGHCAP (CL_HTON64(((uint64_t)1)<<28))
+#define IB_PIR_COMPMASK_VLARBLOWCAP (CL_HTON64(((uint64_t)1)<<29))
+#define IB_PIR_COMPMASK_INITTYPEREPLY (CL_HTON64(((uint64_t)1)<<30))
+#define IB_PIR_COMPMASK_MTUCAP (CL_HTON64(((uint64_t)1)<<31))
+#define IB_PIR_COMPMASK_VLSTALLCNT (CL_HTON64(((uint64_t)1)<<32))
+#define IB_PIR_COMPMASK_HOQLIFE (CL_HTON64(((uint64_t)1)<<33))
+#define IB_PIR_COMPMASK_OPVLS (CL_HTON64(((uint64_t)1)<<34))
+#define IB_PIR_COMPMASK_PARENFIN (CL_HTON64(((uint64_t)1)<<35))
+#define IB_PIR_COMPMASK_PARENFOUT (CL_HTON64(((uint64_t)1)<<36))
+#define IB_PIR_COMPMASK_FILTERRAWIN (CL_HTON64(((uint64_t)1)<<37))
+#define IB_PIR_COMPMASK_FILTERRAWOUT (CL_HTON64(((uint64_t)1)<<38))
+#define IB_PIR_COMPMASK_MKEYVIO (CL_HTON64(((uint64_t)1)<<39))
+#define IB_PIR_COMPMASK_PKEYVIO (CL_HTON64(((uint64_t)1)<<40))
+#define IB_PIR_COMPMASK_QKEYVIO (CL_HTON64(((uint64_t)1)<<41))
+#define IB_PIR_COMPMASK_GUIDCAP (CL_HTON64(((uint64_t)1)<<42))
+#define IB_PIR_COMPMASK_CLIENTREREG (CL_HTON64(((uint64_t)1)<<43))
+#define IB_PIR_COMPMASK_RESV3 (CL_HTON64(((uint64_t)1)<<44))
+#define IB_PIR_COMPMASK_SUBNTO (CL_HTON64(((uint64_t)1)<<45))
+#define IB_PIR_COMPMASK_RESV4 (CL_HTON64(((uint64_t)1)<<46))
+#define IB_PIR_COMPMASK_RESPTIME (CL_HTON64(((uint64_t)1)<<47))
+#define IB_PIR_COMPMASK_LOCALPHYERR (CL_HTON64(((uint64_t)1)<<48))
+#define IB_PIR_COMPMASK_OVERRUNERR (CL_HTON64(((uint64_t)1)<<49))
+#define IB_PIR_COMPMASK_MAXCREDHINT (CL_HTON64(((uint64_t)1)<<50))
+#define IB_PIR_COMPMASK_RESV5 (CL_HTON64(((uint64_t)1)<<51))
+#define IB_PIR_COMPMASK_LINKRTLAT (CL_HTON64(((uint64_t)1)<<52))
+#define IB_PIR_COMPMASK_CAPMASK2 (CL_HTON64(((uint64_t)1)<<53))
+#define IB_PIR_COMPMASK_LINKSPDEXTACT (CL_HTON64(((uint64_t)1)<<54))
+#define IB_PIR_COMPMASK_LINKSPDEXTSUPP (CL_HTON64(((uint64_t)1)<<55))
+#define IB_PIR_COMPMASK_RESV7 (CL_HTON64(((uint64_t)1)<<56))
+#define IB_PIR_COMPMASK_LINKSPDEXTENAB (CL_HTON64(((uint64_t)1)<<57))
+
+/* Multicast Member Record Component Masks */
+#define IB_MCR_COMPMASK_GID (CL_HTON64(((uint64_t)1)<<0))
+#define IB_MCR_COMPMASK_MGID (CL_HTON64(((uint64_t)1)<<0))
+#define IB_MCR_COMPMASK_PORT_GID (CL_HTON64(((uint64_t)1)<<1))
+#define IB_MCR_COMPMASK_QKEY (CL_HTON64(((uint64_t)1)<<2))
+#define IB_MCR_COMPMASK_MLID (CL_HTON64(((uint64_t)1)<<3))
+#define IB_MCR_COMPMASK_MTU_SEL (CL_HTON64(((uint64_t)1)<<4))
+#define IB_MCR_COMPMASK_MTU (CL_HTON64(((uint64_t)1)<<5))
+#define IB_MCR_COMPMASK_TCLASS (CL_HTON64(((uint64_t)1)<<6))
+#define IB_MCR_COMPMASK_PKEY (CL_HTON64(((uint64_t)1)<<7))
+#define IB_MCR_COMPMASK_RATE_SEL (CL_HTON64(((uint64_t)1)<<8))
+#define IB_MCR_COMPMASK_RATE (CL_HTON64(((uint64_t)1)<<9))
+#define IB_MCR_COMPMASK_LIFE_SEL (CL_HTON64(((uint64_t)1)<<10))
+#define IB_MCR_COMPMASK_LIFE (CL_HTON64(((uint64_t)1)<<11))
+#define IB_MCR_COMPMASK_SL (CL_HTON64(((uint64_t)1)<<12))
+#define IB_MCR_COMPMASK_FLOW (CL_HTON64(((uint64_t)1)<<13))
+#define IB_MCR_COMPMASK_HOP (CL_HTON64(((uint64_t)1)<<14))
+#define IB_MCR_COMPMASK_SCOPE (CL_HTON64(((uint64_t)1)<<15))
+#define IB_MCR_COMPMASK_JOIN_STATE (CL_HTON64(((uint64_t)1)<<16))
+#define IB_MCR_COMPMASK_PROXY (CL_HTON64(((uint64_t)1)<<17))
+
+/* GUID Info Record Component Masks */
+#define IB_GIR_COMPMASK_LID (CL_HTON64(((uint64_t)1)<<0))
+#define IB_GIR_COMPMASK_BLOCKNUM (CL_HTON64(((uint64_t)1)<<1))
+#define IB_GIR_COMPMASK_RESV1 (CL_HTON64(((uint64_t)1)<<2))
+#define IB_GIR_COMPMASK_RESV2 (CL_HTON64(((uint64_t)1)<<3))
+#define IB_GIR_COMPMASK_GID0 (CL_HTON64(((uint64_t)1)<<4))
+#define IB_GIR_COMPMASK_GID1 (CL_HTON64(((uint64_t)1)<<5))
+#define IB_GIR_COMPMASK_GID2 (CL_HTON64(((uint64_t)1)<<6))
+#define IB_GIR_COMPMASK_GID3 (CL_HTON64(((uint64_t)1)<<7))
+#define IB_GIR_COMPMASK_GID4 (CL_HTON64(((uint64_t)1)<<8))
+#define IB_GIR_COMPMASK_GID5 (CL_HTON64(((uint64_t)1)<<9))
+#define IB_GIR_COMPMASK_GID6 (CL_HTON64(((uint64_t)1)<<10))
+#define IB_GIR_COMPMASK_GID7 (CL_HTON64(((uint64_t)1)<<11))
+
+/* MultiPath Record Component Masks */
+#define IB_MPR_COMPMASK_RAWTRAFFIC (CL_HTON64(((uint64_t)1)<<0))
+#define IB_MPR_COMPMASK_RESV0 (CL_HTON64(((uint64_t)1)<<1))
+#define IB_MPR_COMPMASK_FLOWLABEL (CL_HTON64(((uint64_t)1)<<2))
+#define IB_MPR_COMPMASK_HOPLIMIT (CL_HTON64(((uint64_t)1)<<3))
+#define IB_MPR_COMPMASK_TCLASS (CL_HTON64(((uint64_t)1)<<4))
+#define IB_MPR_COMPMASK_REVERSIBLE (CL_HTON64(((uint64_t)1)<<5))
+#define IB_MPR_COMPMASK_NUMBPATH (CL_HTON64(((uint64_t)1)<<6))
+#define IB_MPR_COMPMASK_PKEY (CL_HTON64(((uint64_t)1)<<7))
+#define IB_MPR_COMPMASK_QOS_CLASS (CL_HTON64(((uint64_t)1)<<8))
+#define IB_MPR_COMPMASK_SL (CL_HTON64(((uint64_t)1)<<9))
+#define IB_MPR_COMPMASK_MTUSELEC (CL_HTON64(((uint64_t)1)<<10))
+#define IB_MPR_COMPMASK_MTU (CL_HTON64(((uint64_t)1)<<11))
+#define IB_MPR_COMPMASK_RATESELEC (CL_HTON64(((uint64_t)1)<<12))
+#define IB_MPR_COMPMASK_RATE (CL_HTON64(((uint64_t)1)<<13))
+#define IB_MPR_COMPMASK_PKTLIFETIMESELEC (CL_HTON64(((uint64_t)1)<<14))
+#define IB_MPR_COMPMASK_PKTLIFETIME (CL_HTON64(((uint64_t)1)<<15))
+#define IB_MPR_COMPMASK_SERVICEID_MSB (CL_HTON64(((uint64_t)1)<<16))
+#define IB_MPR_COMPMASK_INDEPSELEC (CL_HTON64(((uint64_t)1)<<17))
+#define IB_MPR_COMPMASK_RESV3 (CL_HTON64(((uint64_t)1)<<18))
+#define IB_MPR_COMPMASK_SGIDCOUNT (CL_HTON64(((uint64_t)1)<<19))
+#define IB_MPR_COMPMASK_DGIDCOUNT (CL_HTON64(((uint64_t)1)<<20))
+#define IB_MPR_COMPMASK_SERVICEID_LSB (CL_HTON64(((uint64_t)1)<<21))
+
+#define IB_MPR_COMPMASK_SERVICEID (IB_MPR_COMPMASK_SERVICEID_MSB | \
+ IB_MPR_COMPMASK_SERVICEID_LSB)
+
+/* SMInfo Record Component Masks */
+#define IB_SMIR_COMPMASK_LID (CL_HTON64(((uint64_t)1)<<0))
+#define IB_SMIR_COMPMASK_RESV0 (CL_HTON64(((uint64_t)1)<<1))
+#define IB_SMIR_COMPMASK_GUID (CL_HTON64(((uint64_t)1)<<2))
+#define IB_SMIR_COMPMASK_SMKEY (CL_HTON64(((uint64_t)1)<<3))
+#define IB_SMIR_COMPMASK_ACTCOUNT (CL_HTON64(((uint64_t)1)<<4))
+#define IB_SMIR_COMPMASK_PRIORITY (CL_HTON64(((uint64_t)1)<<5))
+#define IB_SMIR_COMPMASK_SMSTATE (CL_HTON64(((uint64_t)1)<<6))
+
+/* InformInfo Record Component Masks */
+#define IB_IIR_COMPMASK_SUBSCRIBERGID (CL_HTON64(((uint64_t)1)<<0))
+#define IB_IIR_COMPMASK_ENUM (CL_HTON64(((uint64_t)1)<<1))
+#define IB_IIR_COMPMASK_RESV0 (CL_HTON64(((uint64_t)1)<<2))
+#define IB_IIR_COMPMASK_GID (CL_HTON64(((uint64_t)1)<<3))
+#define IB_IIR_COMPMASK_LIDRANGEBEGIN (CL_HTON64(((uint64_t)1)<<4))
+#define IB_IIR_COMPMASK_LIDRANGEEND (CL_HTON64(((uint64_t)1)<<5))
+#define IB_IIR_COMPMASK_RESV1 (CL_HTON64(((uint64_t)1)<<6))
+#define IB_IIR_COMPMASK_ISGENERIC (CL_HTON64(((uint64_t)1)<<7))
+#define IB_IIR_COMPMASK_SUBSCRIBE (CL_HTON64(((uint64_t)1)<<8))
+#define IB_IIR_COMPMASK_TYPE (CL_HTON64(((uint64_t)1)<<9))
+#define IB_IIR_COMPMASK_TRAPNUMB (CL_HTON64(((uint64_t)1)<<10))
+#define IB_IIR_COMPMASK_DEVICEID (CL_HTON64(((uint64_t)1)<<10))
+#define IB_IIR_COMPMASK_QPN (CL_HTON64(((uint64_t)1)<<11))
+#define IB_IIR_COMPMASK_RESV2 (CL_HTON64(((uint64_t)1)<<12))
+#define IB_IIR_COMPMASK_RESPTIME (CL_HTON64(((uint64_t)1)<<13))
+#define IB_IIR_COMPMASK_RESV3 (CL_HTON64(((uint64_t)1)<<14))
+#define IB_IIR_COMPMASK_PRODTYPE (CL_HTON64(((uint64_t)1)<<15))
+#define IB_IIR_COMPMASK_VENDID (CL_HTON64(((uint64_t)1)<<15))
+
+/****f* IBA Base: Types/ib_path_rec_init_local
+* NAME
+* ib_path_rec_init_local
+*
+* DESCRIPTION
+* Initializes a subnet local path record.
+*
+* SYNOPSIS
+*/
+static inline void OSM_API
+ib_path_rec_init_local(IN ib_path_rec_t * const p_rec,
+ IN ib_gid_t * const p_dgid,
+ IN ib_gid_t * const p_sgid,
+ IN ib_net16_t dlid,
+ IN ib_net16_t slid,
+ IN uint8_t num_path,
+ IN ib_net16_t pkey,
+ IN uint8_t sl,
+ IN uint16_t qos_class,
+ IN uint8_t mtu_selector,
+ IN uint8_t mtu,
+ IN uint8_t rate_selector,
+ IN uint8_t rate,
+ IN uint8_t pkt_life_selector,
+ IN uint8_t pkt_life, IN uint8_t preference)
+{
+ p_rec->dgid = *p_dgid;
+ p_rec->sgid = *p_sgid;
+ p_rec->dlid = dlid;
+ p_rec->slid = slid;
+ p_rec->num_path = num_path;
+ p_rec->pkey = pkey;
+ p_rec->qos_class_sl = cl_hton16((sl & IB_PATH_REC_SL_MASK) |
+ (qos_class << 4));
+ p_rec->mtu = (uint8_t) ((mtu & IB_PATH_REC_BASE_MASK) |
+ (uint8_t) (mtu_selector << 6));
+ p_rec->rate = (uint8_t) ((rate & IB_PATH_REC_BASE_MASK) |
+ (uint8_t) (rate_selector << 6));
+ p_rec->pkt_life = (uint8_t) ((pkt_life & IB_PATH_REC_BASE_MASK) |
+ (uint8_t) (pkt_life_selector << 6));
+ p_rec->preference = preference;
+
+ /* Clear global routing fields for local path records */
+ p_rec->hop_flow_raw = 0;
+ p_rec->tclass = 0;
+ p_rec->service_id = 0;
+
+ memset(p_rec->resv2, 0, sizeof(p_rec->resv2));
+}
+
+/*
+* PARAMETERS
+* p_rec
+* [in] Pointer to the path record object.
+*
+* dgid
+* [in] GID of destination port.
+*
+* sgid
+* [in] GID of source port.
+*
+* dlid
+* [in] LID of destination port.
+*
+* slid
+* [in] LID of source port.
+*
+* num_path
+* [in] Reversible path - 1 bit to say if path is reversible.
+* num_path [6:0] In queries, maximum number of paths to return.
+* In responses, undefined.
+*
+* pkey
+* [in] Partition key (P_Key) to use on this path.
+*
+* qos_class
+* [in] QoS class to use on this path. Lower 12-bits are valid.
+*
+* sl
+* [in] Service level to use on this path. Lower 4-bits are valid.
+*
+* mtu_selector
+* [in] Encoded MTU selector value to use on this path
+*
+* mtu
+* [in] Encoded MTU to use on this path
+*
+* rate_selector
+* [in] Encoded rate selector value to use on this path.
+*
+* rate
+* [in] Encoded rate to use on this path.
+*
+* pkt_life_selector
+* [in] Encoded Packet selector value lifetime for this path.
+*
+* pkt_life
+* [in] Encoded Packet lifetime for this path.
+*
+* preference
+* [in] Indicates the relative merit of this path versus other path
+* records returned from the SA. Lower numbers are better.
+*
+* RETURN VALUES
+* None.
+*
+* NOTES
+*
+* SEE ALSO
+* ib_gid_t
+*********/
+
+/****f* IBA Base: Types/ib_path_rec_num_path
+* NAME
+* ib_path_rec_num_path
+*
+* DESCRIPTION
+* Get max number of paths to return.
+*
+* SYNOPSIS
+*/
+static inline uint8_t OSM_API
+ib_path_rec_num_path(IN const ib_path_rec_t * const p_rec)
+{
+ return (p_rec->num_path & 0x7F);
+}
+
+/*
+* PARAMETERS
+* p_rec
+* [in] Pointer to the path record object.
+*
+* RETURN VALUES
+* Maximum number of paths to return for each unique SGID_DGID combination.
+*
+* NOTES
+*
+* SEE ALSO
+* ib_path_rec_t
+*********/
+
+/****f* IBA Base: Types/ib_path_rec_set_sl
+* NAME
+* ib_path_rec_set_sl
+*
+* DESCRIPTION
+* Set path service level.
+*
+* SYNOPSIS
+*/
+static inline void OSM_API
+ib_path_rec_set_sl(IN ib_path_rec_t * const p_rec, IN const uint8_t sl)
+{
+ p_rec->qos_class_sl =
+ (p_rec->qos_class_sl & CL_HTON16(IB_PATH_REC_QOS_CLASS_MASK)) |
+ cl_hton16(sl & IB_PATH_REC_SL_MASK);
+}
+
+/*
+* PARAMETERS
+* p_rec
+* [in] Pointer to the path record object.
+*
+* sl
+* [in] Service level to set.
+*
+* RETURN VALUES
+* None
+*
+* NOTES
+*
+* SEE ALSO
+* ib_path_rec_t
+*********/
+
+/****f* IBA Base: Types/ib_path_rec_sl
+* NAME
+* ib_path_rec_sl
+*
+* DESCRIPTION
+* Get path service level.
+*
+* SYNOPSIS
+*/
+static inline uint8_t OSM_API
+ib_path_rec_sl(IN const ib_path_rec_t * const p_rec)
+{
+ return (uint8_t)(cl_ntoh16(p_rec->qos_class_sl) & IB_PATH_REC_SL_MASK);
+}
+
+/*
+* PARAMETERS
+* p_rec
+* [in] Pointer to the path record object.
+*
+* RETURN VALUES
+* SL.
+*
+* NOTES
+*
+* SEE ALSO
+* ib_path_rec_t
+*********/
+
+/****f* IBA Base: Types/ib_path_rec_set_qos_class
+* NAME
+* ib_path_rec_set_qos_class
+*
+* DESCRIPTION
+* Set path QoS class.
+*
+* SYNOPSIS
+*/
+static inline void OSM_API
+ib_path_rec_set_qos_class(IN ib_path_rec_t * const p_rec,
+ IN const uint16_t qos_class)
+{
+ p_rec->qos_class_sl =
+ (p_rec->qos_class_sl & CL_HTON16(IB_PATH_REC_SL_MASK)) |
+ cl_hton16(qos_class << 4);
+}
+
+/*
+* PARAMETERS
+* p_rec
+* [in] Pointer to the path record object.
+*
+* qos_class
+* [in] QoS class to set.
+*
+* RETURN VALUES
+* None
+*
+* NOTES
+*
+* SEE ALSO
+* ib_path_rec_t
+*********/
+
+/****f* IBA Base: Types/ib_path_rec_qos_class
+* NAME
+* ib_path_rec_qos_class
+*
+* DESCRIPTION
+* Get QoS class.
+*
+* SYNOPSIS
+*/
+static inline uint16_t OSM_API
+ib_path_rec_qos_class(IN const ib_path_rec_t * const p_rec)
+{
+ return (cl_ntoh16(p_rec->qos_class_sl) >> 4);
+}
+
+/*
+* PARAMETERS
+* p_rec
+* [in] Pointer to the path record object.
+*
+* RETURN VALUES
+* QoS class of the path record.
+*
+* NOTES
+*
+* SEE ALSO
+* ib_path_rec_t
+*********/
+
+/****f* IBA Base: Types/ib_path_rec_mtu
+* NAME
+* ib_path_rec_mtu
+*
+* DESCRIPTION
+* Get encoded path MTU.
+*
+* SYNOPSIS
+*/
+static inline uint8_t OSM_API
+ib_path_rec_mtu(IN const ib_path_rec_t * const p_rec)
+{
+ return ((uint8_t) (p_rec->mtu & IB_PATH_REC_BASE_MASK));
+}
+
+/*
+* PARAMETERS
+* p_rec
+* [in] Pointer to the path record object.
+*
+* RETURN VALUES
+* Encoded path MTU.
+* 1: 256
+* 2: 512
+* 3: 1024
+* 4: 2048
+* 5: 4096
+* others: reserved
+*
+* NOTES
+*
+* SEE ALSO
+* ib_path_rec_t
+*********/
+
+/****f* IBA Base: Types/ib_path_rec_mtu_sel
+* NAME
+* ib_path_rec_mtu_sel
+*
+* DESCRIPTION
+* Get encoded path MTU selector.
+*
+* SYNOPSIS
+*/
+static inline uint8_t OSM_API
+ib_path_rec_mtu_sel(IN const ib_path_rec_t * const p_rec)
+{
+ return ((uint8_t) ((p_rec->mtu & IB_PATH_REC_SELECTOR_MASK) >> 6));
+}
+
+/*
+* PARAMETERS
+* p_rec
+* [in] Pointer to the path record object.
+*
+* RETURN VALUES
+* Encoded path MTU selector value (for queries).
+* 0: greater than MTU specified
+* 1: less than MTU specified
+* 2: exactly the MTU specified
+* 3: largest MTU available
+*
+* NOTES
+*
+* SEE ALSO
+* ib_path_rec_t
+*********/
+
+/****f* IBA Base: Types/ib_path_rec_rate
+* NAME
+* ib_path_rec_rate
+*
+* DESCRIPTION
+* Get encoded path rate.
+*
+* SYNOPSIS
+*/
+static inline uint8_t OSM_API
+ib_path_rec_rate(IN const ib_path_rec_t * const p_rec)
+{
+ return ((uint8_t) (p_rec->rate & IB_PATH_REC_BASE_MASK));
+}
+
+/*
+* PARAMETERS
+* p_rec
+* [in] Pointer to the path record object.
+*
+* RETURN VALUES
+* Encoded path rate.
+* 2: 2.5 Gb/sec.
+* 3: 10 Gb/sec.
+* 4: 30 Gb/sec.
+* 5: 5 Gb/sec.
+* 6: 20 Gb/sec.
+* 7: 40 Gb/sec.
+* 8: 60 Gb/sec.
+* 9: 80 Gb/sec.
+* 10: 120 Gb/sec.
+* 11: 14 Gb/sec.
+* 12: 56 Gb/sec.
+* 13: 112 Gb/sec.
+* 14: 168 Gb/sec.
+* 15: 25 Gb/sec.
+* 16: 100 Gb/sec.
+* 17: 200 Gb/sec.
+* 18: 300 Gb/sec.
+* others: reserved
+*
+* NOTES
+*
+* SEE ALSO
+* ib_path_rec_t
+*********/
+
+/****f* IBA Base: Types/ib_path_rec_rate_sel
+* NAME
+* ib_path_rec_rate_sel
+*
+* DESCRIPTION
+* Get encoded path rate selector.
+*
+* SYNOPSIS
+*/
+static inline uint8_t OSM_API
+ib_path_rec_rate_sel(IN const ib_path_rec_t * const p_rec)
+{
+ return ((uint8_t) ((p_rec->rate & IB_PATH_REC_SELECTOR_MASK) >> 6));
+}
+
+/*
+* PARAMETERS
+* p_rec
+* [in] Pointer to the path record object.
+*
+* RETURN VALUES
+* Encoded path rate selector value (for queries).
+* 0: greater than rate specified
+* 1: less than rate specified
+* 2: exactly the rate specified
+* 3: largest rate available
+*
+* NOTES
+*
+* SEE ALSO
+* ib_path_rec_t
+*********/
+
+/****f* IBA Base: Types/ib_path_rec_pkt_life
+* NAME
+* ib_path_rec_pkt_life
+*
+* DESCRIPTION
+* Get encoded path pkt_life.
+*
+* SYNOPSIS
+*/
+static inline uint8_t OSM_API
+ib_path_rec_pkt_life(IN const ib_path_rec_t * const p_rec)
+{
+ return ((uint8_t) (p_rec->pkt_life & IB_PATH_REC_BASE_MASK));
+}
+
+/*
+* PARAMETERS
+* p_rec
+* [in] Pointer to the path record object.
+*
+* RETURN VALUES
+* Encoded path pkt_life = 4.096 usec * 2 ** PacketLifeTime.
+*
+* NOTES
+*
+* SEE ALSO
+* ib_path_rec_t
+*********/
+
+/****f* IBA Base: Types/ib_path_rec_pkt_life_sel
+* NAME
+* ib_path_rec_pkt_life_sel
+*
+* DESCRIPTION
+* Get encoded path pkt_lifetime selector.
+*
+* SYNOPSIS
+*/
+static inline uint8_t OSM_API
+ib_path_rec_pkt_life_sel(IN const ib_path_rec_t * const p_rec)
+{
+ return ((uint8_t) ((p_rec->pkt_life & IB_PATH_REC_SELECTOR_MASK) >> 6));
+}
+
+/*
+* PARAMETERS
+* p_rec
+* [in] Pointer to the path record object.
+*
+* RETURN VALUES
+* Encoded path pkt_lifetime selector value (for queries).
+* 0: greater than rate specified
+* 1: less than rate specified
+* 2: exactly the rate specified
+* 3: smallest packet lifetime available
+*
+* NOTES
+*
+* SEE ALSO
+* ib_path_rec_t
+*********/
+
+/****f* IBA Base: Types/ib_path_rec_flow_lbl
+* NAME
+* ib_path_rec_flow_lbl
+*
+* DESCRIPTION
+* Get flow label.
+*
+* SYNOPSIS
+*/
+static inline uint32_t OSM_API
+ib_path_rec_flow_lbl(IN const ib_path_rec_t * const p_rec)
+{
+ return (((cl_ntoh32(p_rec->hop_flow_raw) >> 8) & 0x000FFFFF));
+}
+
+/*
+* PARAMETERS
+* p_rec
+* [in] Pointer to the path record object.
+*
+* RETURN VALUES
+* Flow label of the path record.
+*
+* NOTES
+*
+* SEE ALSO
+* ib_path_rec_t
+*********/
+
+/****f* IBA Base: Types/ib_path_rec_hop_limit
+* NAME
+* ib_path_rec_hop_limit
+*
+* DESCRIPTION
+* Get hop limit.
+*
+* SYNOPSIS
+*/
+static inline uint8_t OSM_API
+ib_path_rec_hop_limit(IN const ib_path_rec_t * const p_rec)
+{
+ return ((uint8_t) (cl_ntoh32(p_rec->hop_flow_raw) & 0x000000FF));
+}
+
+/*
+* PARAMETERS
+* p_rec
+* [in] Pointer to the path record object.
+*
+* RETURN VALUES
+* Hop limit of the path record.
+*
+* NOTES
+*
+* SEE ALSO
+* ib_path_rec_t
+*********/
+
+/****s* IBA Base: Constants/IB_CLASS_CAP_TRAP
+* NAME
+* IB_CLASS_CAP_TRAP
+*
+* DESCRIPTION
+* ClassPortInfo CapabilityMask bits. This bit will be set
+* if the class supports Trap() MADs (13.4.8.1).
+*
+* SEE ALSO
+* ib_class_port_info_t, IB_CLASS_CAP_GETSET, IB_CLASS_CAP_CAPMASK2
+*
+* SOURCE
+*/
+#define IB_CLASS_CAP_TRAP 0x0001
+/*********/
+
+/****s* IBA Base: Constants/IB_CLASS_CAP_GETSET
+* NAME
+* IB_CLASS_CAP_GETSET
+*
+* DESCRIPTION
+* ClassPortInfo CapabilityMask bits. This bit will be set
+* if the class supports Get(Notice) and Set(Notice) MADs (13.4.8.1).
+*
+* SEE ALSO
+* ib_class_port_info_t, IB_CLASS_CAP_TRAP, IB_CLASS_CAP_CAPMASK2
+*
+* SOURCE
+*/
+#define IB_CLASS_CAP_GETSET 0x0002
+/*********/
+
+/****s* IBA Base: Constants/IB_CLASS_CAP_CAPMASK2
+* NAME
+* IB_CLASS_CAP_CAPMASK2
+*
+* DESCRIPTION
+* ClassPortInfo CapabilityMask bits.
+* This bit will be set of the class supports additional class specific
+* capabilities (CapabilityMask2) (13.4.8.1).
+*
+* SEE ALSO
+* ib_class_port_info_t, IB_CLASS_CAP_TRAP, IB_CLASS_CAP_GETSET
+*
+* SOURCE
+*/
+#define IB_CLASS_CAP_CAPMASK2 0x0004
+/*********/
+
+/****s* IBA Base: Constants/IB_CLASS_ENH_PORT0_CC_MASK
+* NAME
+* IB_CLASS_ENH_PORT0_CC_MASK
+*
+* DESCRIPTION
+* ClassPortInfo CapabilityMask bits.
+* Switch only: This bit will be set if the EnhancedPort0
+* supports CA Congestion Control (A10.4.3.1).
+*
+* SEE ALSO
+* ib_class_port_info_t
+*
+* SOURCE
+*/
+#define IB_CLASS_ENH_PORT0_CC_MASK 0x0100
+/*********/
+
+/****s* IBA Base: Constants/IB_CLASS_RESP_TIME_MASK
+* NAME
+* IB_CLASS_RESP_TIME_MASK
+*
+* DESCRIPTION
+* Mask bits to extract the response time value from the
+* cap_mask2_resp_time field of ib_class_port_info_t.
+*
+* SEE ALSO
+* ib_class_port_info_t
+*
+* SOURCE
+*/
+#define IB_CLASS_RESP_TIME_MASK 0x1F
+/*********/
+
+/****s* IBA Base: Constants/IB_CLASS_CAPMASK2_SHIFT
+* NAME
+* IB_CLASS_CAPMASK2_SHIFT
+*
+* DESCRIPTION
+* Number of bits to shift to extract the capability mask2
+* from the cap_mask2_resp_time field of ib_class_port_info_t.
+*
+* SEE ALSO
+* ib_class_port_info_t
+*
+* SOURCE
+*/
+#define IB_CLASS_CAPMASK2_SHIFT 5
+/*********/
+
+/****s* IBA Base: Types/ib_class_port_info_t
+* NAME
+* ib_class_port_info_t
+*
+* DESCRIPTION
+* IBA defined ClassPortInfo attribute (13.4.8.1)
+*
+* SYNOPSIS
+*/
+#include <complib/cl_packon.h>
+typedef struct _ib_class_port_info {
+ uint8_t base_ver;
+ uint8_t class_ver;
+ ib_net16_t cap_mask;
+ ib_net32_t cap_mask2_resp_time;
+ ib_gid_t redir_gid;
+ ib_net32_t redir_tc_sl_fl;
+ ib_net16_t redir_lid;
+ ib_net16_t redir_pkey;
+ ib_net32_t redir_qp;
+ ib_net32_t redir_qkey;
+ ib_gid_t trap_gid;
+ ib_net32_t trap_tc_sl_fl;
+ ib_net16_t trap_lid;
+ ib_net16_t trap_pkey;
+ ib_net32_t trap_hop_qp;
+ ib_net32_t trap_qkey;
+} PACK_SUFFIX ib_class_port_info_t;
+#include <complib/cl_packoff.h>
+/*
+* FIELDS
+* base_ver
+* Maximum supported MAD Base Version.
+*
+* class_ver
+* Maximum supported management class version.
+*
+* cap_mask
+* Supported capabilities of this management class.
+*
+* cap_mask2_resp_time
+* Maximum expected response time and additional
+* supported capabilities of this management class.
+*
+* redir_gid
+* GID to use for redirection, or zero
+*
+* redir_tc_sl_fl
+* Traffic class, service level and flow label the requester
+* should use if the service is redirected.
+*
+* redir_lid
+* LID used for redirection, or zero
+*
+* redir_pkey
+* P_Key used for redirection
+*
+* redir_qp
+* QP number used for redirection
+*
+* redir_qkey
+* Q_Key associated with the redirected QP. This shall be the
+* well known Q_Key value.
+*
+* trap_gid
+* GID value used for trap messages from this service.
+*
+* trap_tc_sl_fl
+* Traffic class, service level and flow label used for
+* trap messages originated by this service.
+*
+* trap_lid
+* LID used for trap messages, or zero
+*
+* trap_pkey
+* P_Key used for trap messages
+*
+* trap_hop_qp
+* Hop limit (upper 8 bits) and QP number used for trap messages
+*
+* trap_qkey
+* Q_Key associated with the trap messages QP.
+*
+* SEE ALSO
+* IB_CLASS_CAP_GETSET, IB_CLASS_CAP_TRAP
+*
+*********/
+
+#define IB_PM_ALL_PORT_SELECT (CL_HTON16(((uint16_t)1)<<8))
+#define IB_PM_EXT_WIDTH_SUPPORTED (CL_HTON16(((uint16_t)1)<<9))
+#define IB_PM_EXT_WIDTH_NOIETF_SUP (CL_HTON16(((uint16_t)1)<<10))
+#define IB_PM_SAMPLES_ONLY_SUP (CL_HTON16(((uint16_t)1)<<11))
+#define IB_PM_PC_XMIT_WAIT_SUP (CL_HTON16(((uint16_t)1)<<12))
+#define IS_PM_INH_LMTD_PKEY_MC_CONSTR_ERR (CL_HTON16(((uint16_t)1)<<13))
+#define IS_PM_RSFEC_COUNTERS_SUP (CL_HTON16(((uint16_t)1)<<14))
+#define IB_PM_IS_QP1_DROP_SUP (CL_HTON16(((uint16_t)1)<<15))
+/* CapabilityMask2 */
+#define IB_PM_IS_PM_KEY_SUPPORTED (CL_HTON32(((uint32_t)1)<<0))
+#define IB_PM_IS_ADDL_PORT_CTRS_EXT_SUP (CL_HTON32(((uint32_t)1)<<1))
+
+/****f* IBA Base: Types/ib_class_set_resp_time_val
+* NAME
+* ib_class_set_resp_time_val
+*
+* DESCRIPTION
+* Set maximum expected response time.
+*
+* SYNOPSIS
+*/
+static inline void OSM_API
+ib_class_set_resp_time_val(IN ib_class_port_info_t * const p_cpi,
+ IN const uint8_t val)
+{
+ p_cpi->cap_mask2_resp_time =
+ (p_cpi->cap_mask2_resp_time & CL_HTON32(~IB_CLASS_RESP_TIME_MASK)) |
+ cl_hton32(val & IB_CLASS_RESP_TIME_MASK);
+}
+
+/*
+* PARAMETERS
+* p_cpi
+* [in] Pointer to the class port info object.
+*
+* val
+* [in] Response time value to set.
+*
+* RETURN VALUES
+* None
+*
+* NOTES
+*
+* SEE ALSO
+* ib_class_port_info_t
+*********/
+
+/****f* IBA Base: Types/ib_class_resp_time_val
+* NAME
+* ib_class_resp_time_val
+*
+* DESCRIPTION
+* Get response time value.
+*
+* SYNOPSIS
+*/
+static inline uint8_t OSM_API
+ib_class_resp_time_val(IN ib_class_port_info_t * const p_cpi)
+{
+ return (uint8_t)(cl_ntoh32(p_cpi->cap_mask2_resp_time) &
+ IB_CLASS_RESP_TIME_MASK);
+}
+
+/*
+* PARAMETERS
+* p_cpi
+* [in] Pointer to the class port info object.
+*
+* RETURN VALUES
+* Response time value.
+*
+* NOTES
+*
+* SEE ALSO
+* ib_class_port_info_t
+*********/
+
+/****f* IBA Base: Types/ib_class_set_cap_mask2
+* NAME
+* ib_class_set_cap_mask2
+*
+* DESCRIPTION
+* Set ClassPortInfo:CapabilityMask2.
+*
+* SYNOPSIS
+*/
+static inline void OSM_API
+ib_class_set_cap_mask2(IN ib_class_port_info_t * const p_cpi,
+ IN const uint32_t cap_mask2)
+{
+ p_cpi->cap_mask2_resp_time = (p_cpi->cap_mask2_resp_time &
+ CL_HTON32(IB_CLASS_RESP_TIME_MASK)) |
+ cl_hton32(cap_mask2 << IB_CLASS_CAPMASK2_SHIFT);
+}
+
+/*
+* PARAMETERS
+* p_cpi
+* [in] Pointer to the class port info object.
+*
+* cap_mask2
+* [in] CapabilityMask2 value to set.
+*
+* RETURN VALUES
+* None
+*
+* NOTES
+*
+* SEE ALSO
+* ib_class_port_info_t
+*********/
+
+/****f* IBA Base: Types/ib_class_cap_mask2
+* NAME
+* ib_class_cap_mask2
+*
+* DESCRIPTION
+* Get ClassPortInfo:CapabilityMask2.
+*
+* SYNOPSIS
+*/
+static inline uint32_t OSM_API
+ib_class_cap_mask2(IN const ib_class_port_info_t * const p_cpi)
+{
+ return (cl_ntoh32(p_cpi->cap_mask2_resp_time) >> IB_CLASS_CAPMASK2_SHIFT);
+}
+
+/*
+* PARAMETERS
+* p_cpi
+* [in] Pointer to the class port info object.
+*
+* RETURN VALUES
+* CapabilityMask2 of the ClassPortInfo.
+*
+* NOTES
+*
+* SEE ALSO
+* ib_class_port_info_t
+*********/
+
+/****s* IBA Base: Types/ib_sm_info_t
+* NAME
+* ib_sm_info_t
+*
+* DESCRIPTION
+* SMInfo structure (14.2.5.13).
+*
+* SYNOPSIS
+*/
+#include <complib/cl_packon.h>
+typedef struct _ib_sm_info {
+ ib_net64_t guid;
+ ib_net64_t sm_key;
+ ib_net32_t act_count;
+ uint8_t pri_state;
+} PACK_SUFFIX ib_sm_info_t;
+#include <complib/cl_packoff.h>
+/*
+* FIELDS
+* guid
+* Port GUID for this SM.
+*
+* sm_key
+* SM_Key of this SM.
+*
+* act_count
+* Activity counter used as a heartbeat.
+*
+* pri_state
+* Priority and State information
+*
+* SEE ALSO
+*********/
+
+/****f* IBA Base: Types/ib_sminfo_get_priority
+* NAME
+* ib_sminfo_get_priority
+*
+* DESCRIPTION
+* Returns the priority value.
+*
+* SYNOPSIS
+*/
+static inline uint8_t OSM_API
+ib_sminfo_get_priority(IN const ib_sm_info_t * const p_smi)
+{
+ return ((uint8_t) ((p_smi->pri_state & 0xF0) >> 4));
+}
+
+/*
+* PARAMETERS
+* p_smi
+* [in] Pointer to the SMInfo Attribute.
+*
+* RETURN VALUES
+* Returns the priority value.
+*
+* NOTES
+*
+* SEE ALSO
+*********/
+
+/****f* IBA Base: Types/ib_sminfo_get_state
+* NAME
+* ib_sminfo_get_state
+*
+* DESCRIPTION
+* Returns the state value.
+*
+* SYNOPSIS
+*/
+static inline uint8_t OSM_API
+ib_sminfo_get_state(IN const ib_sm_info_t * const p_smi)
+{
+ return ((uint8_t) (p_smi->pri_state & 0x0F));
+}
+
+/*
+* PARAMETERS
+* p_smi
+* [in] Pointer to the SMInfo Attribute.
+*
+* RETURN VALUES
+* Returns the state value.
+*
+* NOTES
+*
+* SEE ALSO
+*********/
+
+/****s* IBA Base: Types/ib_mad_t
+* NAME
+* ib_mad_t
+*
+* DESCRIPTION
+* IBA defined MAD header (13.4.3)
+*
+* SYNOPSIS
+*/
+#include <complib/cl_packon.h>
+typedef struct _ib_mad {
+ uint8_t base_ver;
+ uint8_t mgmt_class;
+ uint8_t class_ver;
+ uint8_t method;
+ ib_net16_t status;
+ ib_net16_t class_spec;
+ ib_net64_t trans_id;
+ ib_net16_t attr_id;
+ ib_net16_t resv;
+ ib_net32_t attr_mod;
+} PACK_SUFFIX ib_mad_t;
+#include <complib/cl_packoff.h>
+/*
+* FIELDS
+* base_ver
+* MAD base format.
+*
+* mgmt_class
+* Class of operation.
+*
+* class_ver
+* Version of MAD class-specific format.
+*
+* method
+* Method to perform, including 'R' bit.
+*
+* status
+* Status of operation.
+*
+* class_spec
+* Reserved for subnet management.
+*
+* trans_id
+* Transaction ID.
+*
+* attr_id
+* Attribute ID.
+*
+* resv
+* Reserved field.
+*
+* attr_mod
+* Attribute modifier.
+*
+* SEE ALSO
+*********/
+
+/****s* IBA Base: Types/ib_rmpp_mad_t
+* NAME
+* ib_rmpp_mad_t
+*
+* DESCRIPTION
+* IBA defined MAD RMPP header (13.6.2.1)
+*
+* SYNOPSIS
+*/
+#include <complib/cl_packon.h>
+typedef struct _ib_rmpp_mad {
+ ib_mad_t common_hdr;
+ uint8_t rmpp_version;
+ uint8_t rmpp_type;
+ uint8_t rmpp_flags;
+ uint8_t rmpp_status;
+ ib_net32_t seg_num;
+ ib_net32_t paylen_newwin;
+} PACK_SUFFIX ib_rmpp_mad_t;
+#include <complib/cl_packoff.h>
+/*
+* SEE ALSO
+* ib_mad_t
+*********/
+
+/****f* IBA Base: Types/ib_mad_init_new
+* NAME
+* ib_mad_init_new
+*
+* DESCRIPTION
+* Initializes a MAD common header.
+*
+* SYNOPSIS
+*/
+static inline void OSM_API
+ib_mad_init_new(IN ib_mad_t * const p_mad,
+ IN const uint8_t mgmt_class,
+ IN const uint8_t class_ver,
+ IN const uint8_t method,
+ IN const ib_net64_t trans_id,
+ IN const ib_net16_t attr_id, IN const ib_net32_t attr_mod)
+{
+ CL_ASSERT(p_mad);
+ p_mad->base_ver = 1;
+ p_mad->mgmt_class = mgmt_class;
+ p_mad->class_ver = class_ver;
+ p_mad->method = method;
+ p_mad->status = 0;
+ p_mad->class_spec = 0;
+ p_mad->trans_id = trans_id;
+ p_mad->attr_id = attr_id;
+ p_mad->resv = 0;
+ p_mad->attr_mod = attr_mod;
+}
+
+/*
+* PARAMETERS
+* p_mad
+* [in] Pointer to the MAD common header.
+*
+* mgmt_class
+* [in] Class of operation.
+*
+* class_ver
+* [in] Version of MAD class-specific format.
+*
+* method
+* [in] Method to perform, including 'R' bit.
+*
+* trans_Id
+* [in] Transaction ID.
+*
+* attr_id
+* [in] Attribute ID.
+*
+* attr_mod
+* [in] Attribute modifier.
+*
+* RETURN VALUES
+* None.
+*
+* NOTES
+*
+* SEE ALSO
+* ib_mad_t
+*********/
+
+/****f* IBA Base: Types/ib_mad_init_response
+* NAME
+* ib_mad_init_response
+*
+* DESCRIPTION
+* Initializes a MAD common header as a response.
+*
+* SYNOPSIS
+*/
+static inline void OSM_API
+ib_mad_init_response(IN const ib_mad_t * const p_req_mad,
+ IN ib_mad_t * const p_mad, IN const ib_net16_t status)
+{
+ CL_ASSERT(p_req_mad);
+ CL_ASSERT(p_mad);
+ *p_mad = *p_req_mad;
+ p_mad->status = status;
+ if (p_mad->method == IB_MAD_METHOD_SET)
+ p_mad->method = IB_MAD_METHOD_GET;
+ p_mad->method |= IB_MAD_METHOD_RESP_MASK;
+}
+
+/*
+* PARAMETERS
+* p_req_mad
+* [in] Pointer to the MAD common header in the original request MAD.
+*
+* p_mad
+* [in] Pointer to the MAD common header to initialize.
+*
+* status
+* [in] MAD Status value to return;
+*
+* RETURN VALUES
+* None.
+*
+* NOTES
+* p_req_mad and p_mad may point to the same MAD.
+*
+* SEE ALSO
+* ib_mad_t
+*********/
+
+/****f* IBA Base: Types/ib_mad_is_response
+* NAME
+* ib_mad_is_response
+*
+* DESCRIPTION
+* Returns TRUE if the MAD is a response ('R' bit set)
+* or if the MAD is a TRAP REPRESS,
+* FALSE otherwise.
+*
+* SYNOPSIS
+*/
+static inline boolean_t OSM_API
+ib_mad_is_response(IN const ib_mad_t * const p_mad)
+{
+ CL_ASSERT(p_mad);
+ return (p_mad->method & IB_MAD_METHOD_RESP_MASK ||
+ p_mad->method == IB_MAD_METHOD_TRAP_REPRESS);
+}
+
+/*
+* PARAMETERS
+* p_mad
+* [in] Pointer to the MAD.
+*
+* RETURN VALUES
+* Returns TRUE if the MAD is a response ('R' bit set),
+* FALSE otherwise.
+*
+* NOTES
+*
+* SEE ALSO
+* ib_mad_t
+*********/
+
+#define IB_RMPP_TYPE_DATA 1
+#define IB_RMPP_TYPE_ACK 2
+#define IB_RMPP_TYPE_STOP 3
+#define IB_RMPP_TYPE_ABORT 4
+
+#define IB_RMPP_NO_RESP_TIME 0x1F
+#define IB_RMPP_FLAG_ACTIVE 0x01
+#define IB_RMPP_FLAG_FIRST 0x02
+#define IB_RMPP_FLAG_LAST 0x04
+
+#define IB_RMPP_STATUS_SUCCESS 0
+#define IB_RMPP_STATUS_RESX 1 /* resources exhausted */
+#define IB_RMPP_STATUS_T2L 118 /* time too long */
+#define IB_RMPP_STATUS_BAD_LEN 119 /* incon. last and payload len */
+#define IB_RMPP_STATUS_BAD_SEG 120 /* incon. first and segment no */
+#define IB_RMPP_STATUS_BADT 121 /* bad rmpp type */
+#define IB_RMPP_STATUS_W2S 122 /* newwindowlast too small */
+#define IB_RMPP_STATUS_S2B 123 /* segment no too big */
+#define IB_RMPP_STATUS_BAD_STATUS 124 /* illegal status */
+#define IB_RMPP_STATUS_UNV 125 /* unsupported version */
+#define IB_RMPP_STATUS_TMR 126 /* too many retries */
+#define IB_RMPP_STATUS_UNSPEC 127 /* unspecified */
+
+/****f* IBA Base: Types/ib_rmpp_is_flag_set
+* NAME
+* ib_rmpp_is_flag_set
+*
+* DESCRIPTION
+* Returns TRUE if the MAD has the given RMPP flag set.
+*
+* SYNOPSIS
+*/
+static inline boolean_t OSM_API
+ib_rmpp_is_flag_set(IN const ib_rmpp_mad_t * const p_rmpp_mad,
+ IN const uint8_t flag)
+{
+ CL_ASSERT(p_rmpp_mad);
+ return ((p_rmpp_mad->rmpp_flags & flag) == flag);
+}
+
+/*
+* PARAMETERS
+* ib_rmpp_mad_t
+* [in] Pointer to a MAD with an RMPP header.
+*
+* flag
+* [in] The RMPP flag being examined.
+*
+* RETURN VALUES
+* Returns TRUE if the MAD has the given RMPP flag set.
+*
+* NOTES
+*
+* SEE ALSO
+* ib_mad_t, ib_rmpp_mad_t
+*********/
+
+static inline void OSM_API
+ib_rmpp_set_resp_time(IN ib_rmpp_mad_t * const p_rmpp_mad,
+ IN const uint8_t resp_time)
+{
+ CL_ASSERT(p_rmpp_mad);
+ p_rmpp_mad->rmpp_flags |= (resp_time << 3);
+}
+
+static inline uint8_t OSM_API
+ib_rmpp_get_resp_time(IN const ib_rmpp_mad_t * const p_rmpp_mad)
+{
+ CL_ASSERT(p_rmpp_mad);
+ return ((uint8_t) (p_rmpp_mad->rmpp_flags >> 3));
+}
+
+/****d* IBA Base: Constants/IB_SMP_DIRECTION
+* NAME
+* IB_SMP_DIRECTION
+*
+* DESCRIPTION
+* The Direction bit for directed route SMPs.
+*
+* SOURCE
+*/
+#define IB_SMP_DIRECTION_HO 0x8000
+#define IB_SMP_DIRECTION (CL_HTON16(IB_SMP_DIRECTION_HO))
+/**********/
+
+/****d* IBA Base: Constants/IB_SMP_STATUS_MASK
+* NAME
+* IB_SMP_STATUS_MASK
+*
+* DESCRIPTION
+* Mask value for extracting status from a directed route SMP.
+*
+* SOURCE
+*/
+#define IB_SMP_STATUS_MASK_HO 0x7FFF
+#define IB_SMP_STATUS_MASK (CL_HTON16(IB_SMP_STATUS_MASK_HO))
+/**********/
+
+/****s* IBA Base: Types/ib_smp_t
+* NAME
+* ib_smp_t
+*
+* DESCRIPTION
+* IBA defined SMP. (14.2.1.2)
+*
+* SYNOPSIS
+*/
+#define IB_SMP_DATA_SIZE 64
+#include <complib/cl_packon.h>
+typedef struct _ib_smp {
+ uint8_t base_ver;
+ uint8_t mgmt_class;
+ uint8_t class_ver;
+ uint8_t method;
+ ib_net16_t status;
+ uint8_t hop_ptr;
+ uint8_t hop_count;
+ ib_net64_t trans_id;
+ ib_net16_t attr_id;
+ ib_net16_t resv;
+ ib_net32_t attr_mod;
+ ib_net64_t m_key;
+ ib_net16_t dr_slid;
+ ib_net16_t dr_dlid;
+ uint32_t resv1[7];
+ uint8_t data[IB_SMP_DATA_SIZE];
+ uint8_t initial_path[IB_SUBNET_PATH_HOPS_MAX];
+ uint8_t return_path[IB_SUBNET_PATH_HOPS_MAX];
+} PACK_SUFFIX ib_smp_t;
+#include <complib/cl_packoff.h>
+/*
+* FIELDS
+* base_ver
+* MAD base format.
+*
+* mgmt_class
+* Class of operation.
+*
+* class_ver
+* Version of MAD class-specific format.
+*
+* method
+* Method to perform, including 'R' bit.
+*
+* status
+* Status of operation.
+*
+* hop_ptr
+* Hop pointer for directed route MADs.
+*
+* hop_count
+* Hop count for directed route MADs.
+*
+* trans_Id
+* Transaction ID.
+*
+* attr_id
+* Attribute ID.
+*
+* resv
+* Reserved field.
+*
+* attr_mod
+* Attribute modifier.
+*
+* m_key
+* Management key value.
+*
+* dr_slid
+* Directed route source LID.
+*
+* dr_dlid
+* Directed route destination LID.
+*
+* resv0
+* Reserved for 64 byte alignment.
+*
+* data
+* MAD data payload.
+*
+* initial_path
+* Outbound port list.
+*
+* return_path
+* Inbound port list.
+*
+* SEE ALSO
+*********/
+
+/****f* IBA Base: Types/ib_smp_get_status
+* NAME
+* ib_smp_get_status
+*
+* DESCRIPTION
+* Returns the SMP status value in network order.
+*
+* SYNOPSIS
+*/
+static inline ib_net16_t OSM_API
+ib_smp_get_status(IN const ib_smp_t * const p_smp)
+{
+ return ((ib_net16_t) (p_smp->status & IB_SMP_STATUS_MASK));
+}
+
+/*
+* PARAMETERS
+* p_smp
+* [in] Pointer to the SMP packet.
+*
+* RETURN VALUES
+* Returns the SMP status value in network order.
+*
+* NOTES
+*
+* SEE ALSO
+* ib_smp_t
+*********/
+
+/****f* IBA Base: Types/ib_smp_is_response
+* NAME
+* ib_smp_is_response
+*
+* DESCRIPTION
+* Returns TRUE if the SMP is a response MAD, FALSE otherwise.
+*
+* SYNOPSIS
+*/
+static inline boolean_t OSM_API
+ib_smp_is_response(IN const ib_smp_t * const p_smp)
+{
+ return (ib_mad_is_response((const ib_mad_t *)p_smp));
+}
+
+/*
+* PARAMETERS
+* p_smp
+* [in] Pointer to the SMP packet.
+*
+* RETURN VALUES
+* Returns TRUE if the SMP is a response MAD, FALSE otherwise.
+*
+* NOTES
+*
+* SEE ALSO
+* ib_smp_t
+*********/
+
+/****f* IBA Base: Types/ib_smp_is_d
+* NAME
+* ib_smp_is_d
+*
+* DESCRIPTION
+* Returns TRUE if the SMP 'D' (direction) bit is set.
+*
+* SYNOPSIS
+*/
+static inline boolean_t OSM_API ib_smp_is_d(IN const ib_smp_t * const p_smp)
+{
+ return ((p_smp->status & IB_SMP_DIRECTION) == IB_SMP_DIRECTION);
+}
+
+/*
+* PARAMETERS
+* p_smp
+* [in] Pointer to the SMP packet.
+*
+* RETURN VALUES
+* Returns TRUE if the SMP 'D' (direction) bit is set.
+*
+* NOTES
+*
+* SEE ALSO
+* ib_smp_t
+*********/
+
+/****f* IBA Base: Types/ib_smp_init_new
+* NAME
+* ib_smp_init_new
+*
+* DESCRIPTION
+* Initializes a MAD common header.
+*
+* TODO
+* This is too big for inlining, but leave it here for now
+* since there is not yet another convenient spot.
+*
+* SYNOPSIS
+*/
+static inline void OSM_API
+ib_smp_init_new(IN ib_smp_t * const p_smp,
+ IN const uint8_t method,
+ IN const ib_net64_t trans_id,
+ IN const ib_net16_t attr_id,
+ IN const ib_net32_t attr_mod,
+ IN const uint8_t hop_count,
+ IN const ib_net64_t m_key,
+ IN const uint8_t * path_out,
+ IN const ib_net16_t dr_slid, IN const ib_net16_t dr_dlid)
+{
+ CL_ASSERT(p_smp);
+ CL_ASSERT(hop_count < IB_SUBNET_PATH_HOPS_MAX);
+ p_smp->base_ver = 1;
+ p_smp->mgmt_class = IB_MCLASS_SUBN_DIR;
+ p_smp->class_ver = 1;
+ p_smp->method = method;
+ p_smp->status = 0;
+ p_smp->hop_ptr = 0;
+ p_smp->hop_count = hop_count;
+ p_smp->trans_id = trans_id;
+ p_smp->attr_id = attr_id;
+ p_smp->resv = 0;
+ p_smp->attr_mod = attr_mod;
+ p_smp->m_key = m_key;
+ p_smp->dr_slid = dr_slid;
+ p_smp->dr_dlid = dr_dlid;
+
+ memset(p_smp->resv1, 0,
+ sizeof(p_smp->resv1) +
+ sizeof(p_smp->data) +
+ sizeof(p_smp->initial_path) + sizeof(p_smp->return_path));
+
+ /* copy the path */
+ memcpy(&p_smp->initial_path, path_out, sizeof(p_smp->initial_path));
+}
+
+/*
+* PARAMETERS
+* p_smp
+* [in] Pointer to the SMP packet.
+*
+* method
+* [in] Method to perform, including 'R' bit.
+*
+* trans_Id
+* [in] Transaction ID.
+*
+* attr_id
+* [in] Attribute ID.
+*
+* attr_mod
+* [in] Attribute modifier.
+*
+* hop_count
+* [in] Number of hops in the path.
+*
+* m_key
+* [in] Management key for this SMP.
+*
+* path_out
+* [in] Port array for outbound path.
+*
+*
+* RETURN VALUES
+* None.
+*
+* NOTES
+* Payload area is initialized to zero.
+*
+*
+* SEE ALSO
+* ib_mad_t
+*********/
+
+/****f* IBA Base: Types/ib_smp_get_payload_ptr
+* NAME
+* ib_smp_get_payload_ptr
+*
+* DESCRIPTION
+* Gets a pointer to the SMP payload area.
+*
+* SYNOPSIS
+*/
+static inline void *OSM_API
+ib_smp_get_payload_ptr(IN const ib_smp_t * const p_smp)
+{
+ return ((void *)p_smp->data);
+}
+
+/*
+* PARAMETERS
+* p_smp
+* [in] Pointer to the SMP packet.
+*
+* RETURN VALUES
+* Pointer to SMP payload area.
+*
+* NOTES
+*
+* SEE ALSO
+* ib_mad_t
+*********/
+
+/****s* IBA Base: Types/ib_node_info_t
+* NAME
+* ib_node_info_t
+*
+* DESCRIPTION
+* IBA defined NodeInfo. (14.2.5.3)
+*
+* SYNOPSIS
+*/
+#include <complib/cl_packon.h>
+typedef struct _ib_node_info {
+ uint8_t base_version;
+ uint8_t class_version;
+ uint8_t node_type;
+ uint8_t num_ports;
+ ib_net64_t sys_guid;
+ ib_net64_t node_guid;
+ ib_net64_t port_guid;
+ ib_net16_t partition_cap;
+ ib_net16_t device_id;
+ ib_net32_t revision;
+ ib_net32_t port_num_vendor_id;
+} PACK_SUFFIX ib_node_info_t;
+#include <complib/cl_packoff.h>
+/************/
+
+/****s* IBA Base: Types/ib_sa_mad_t
+* NAME
+* ib_sa_mad_t
+*
+* DESCRIPTION
+* IBA defined SA MAD format. (15.2.1)
+*
+* SYNOPSIS
+*/
+#define IB_SA_DATA_SIZE 200
+
+#include <complib/cl_packon.h>
+typedef struct _ib_sa_mad {
+ uint8_t base_ver;
+ uint8_t mgmt_class;
+ uint8_t class_ver;
+ uint8_t method;
+ ib_net16_t status;
+ ib_net16_t resv;
+ ib_net64_t trans_id;
+ ib_net16_t attr_id;
+ ib_net16_t resv1;
+ ib_net32_t attr_mod;
+ uint8_t rmpp_version;
+ uint8_t rmpp_type;
+ uint8_t rmpp_flags;
+ uint8_t rmpp_status;
+ ib_net32_t seg_num;
+ ib_net32_t paylen_newwin;
+ ib_net64_t sm_key;
+ ib_net16_t attr_offset;
+ ib_net16_t resv3;
+ ib_net64_t comp_mask;
+ uint8_t data[IB_SA_DATA_SIZE];
+} PACK_SUFFIX ib_sa_mad_t;
+#include <complib/cl_packoff.h>
+/**********/
+#define IB_SA_MAD_HDR_SIZE (sizeof(ib_sa_mad_t) - IB_SA_DATA_SIZE)
+
+static inline uint32_t OSM_API ib_get_attr_size(IN const ib_net16_t attr_offset)
+{
+ return (((uint32_t) cl_ntoh16(attr_offset)) << 3);
+}
+
+static inline ib_net16_t OSM_API ib_get_attr_offset(IN const uint32_t attr_size)
+{
+ return (cl_hton16((uint16_t) (attr_size >> 3)));
+}
+
+/****f* IBA Base: Types/ib_sa_mad_get_payload_ptr
+* NAME
+* ib_sa_mad_get_payload_ptr
+*
+* DESCRIPTION
+* Gets a pointer to the SA MAD's payload area.
+*
+* SYNOPSIS
+*/
+static inline void *OSM_API
+ib_sa_mad_get_payload_ptr(IN const ib_sa_mad_t * const p_sa_mad)
+{
+ return ((void *)p_sa_mad->data);
+}
+
+/*
+* PARAMETERS
+* p_sa_mad
+* [in] Pointer to the SA MAD packet.
+*
+* RETURN VALUES
+* Pointer to SA MAD payload area.
+*
+* NOTES
+*
+* SEE ALSO
+* ib_mad_t
+*********/
+
+#define IB_NODE_INFO_PORT_NUM_MASK (CL_HTON32(0xFF000000))
+#define IB_NODE_INFO_VEND_ID_MASK (CL_HTON32(0x00FFFFFF))
+#if CPU_LE
+#define IB_NODE_INFO_PORT_NUM_SHIFT 0
+#else
+#define IB_NODE_INFO_PORT_NUM_SHIFT 24
+#endif
+
+/****f* IBA Base: Types/ib_node_info_get_local_port_num
+* NAME
+* ib_node_info_get_local_port_num
+*
+* DESCRIPTION
+* Gets the local port number from the NodeInfo attribute.
+*
+* SYNOPSIS
+*/
+static inline uint8_t OSM_API
+ib_node_info_get_local_port_num(IN const ib_node_info_t * const p_ni)
+{
+ return ((uint8_t) ((p_ni->port_num_vendor_id &
+ IB_NODE_INFO_PORT_NUM_MASK)
+ >> IB_NODE_INFO_PORT_NUM_SHIFT));
+}
+
+/*
+* PARAMETERS
+* p_ni
+* [in] Pointer to a NodeInfo attribute.
+*
+* RETURN VALUES
+* Local port number that returned the attribute.
+*
+* NOTES
+*
+* SEE ALSO
+* ib_node_info_t
+*********/
+
+/****f* IBA Base: Types/ib_node_info_get_vendor_id
+* NAME
+* ib_node_info_get_vendor_id
+*
+* DESCRIPTION
+* Gets the VendorID from the NodeInfo attribute.
+*
+* SYNOPSIS
+*/
+static inline ib_net32_t OSM_API
+ib_node_info_get_vendor_id(IN const ib_node_info_t * const p_ni)
+{
+ return ((ib_net32_t) (p_ni->port_num_vendor_id &
+ IB_NODE_INFO_VEND_ID_MASK));
+}
+
+/*
+* PARAMETERS
+* p_ni
+* [in] Pointer to a NodeInfo attribute.
+*
+* RETURN VALUES
+* VendorID that returned the attribute.
+*
+* NOTES
+*
+* SEE ALSO
+* ib_node_info_t
+*********/
+
+#define IB_NODE_DESCRIPTION_SIZE 64
+
+#include <complib/cl_packon.h>
+typedef struct _ib_node_desc {
+ // Node String is an array of UTF-8 characters
+ // that describe the node in text format
+ // Note that this string is NOT NULL TERMINATED!
+ uint8_t description[IB_NODE_DESCRIPTION_SIZE];
+} PACK_SUFFIX ib_node_desc_t;
+#include <complib/cl_packoff.h>
+
+#include <complib/cl_packon.h>
+typedef struct _ib_node_record_t {
+ ib_net16_t lid;
+ ib_net16_t resv;
+ ib_node_info_t node_info;
+ ib_node_desc_t node_desc;
+ uint8_t pad[4];
+} PACK_SUFFIX ib_node_record_t;
+#include <complib/cl_packoff.h>
+
+/****s* IBA Base: Types/ib_port_info_t
+* NAME
+* ib_port_info_t
+*
+* DESCRIPTION
+* IBA defined PortInfo. (14.2.5.6)
+*
+* SYNOPSIS
+*/
+#include <complib/cl_packon.h>
+typedef struct _ib_port_info {
+ ib_net64_t m_key;
+ ib_net64_t subnet_prefix;
+ ib_net16_t base_lid;
+ ib_net16_t master_sm_base_lid;
+ ib_net32_t capability_mask;
+ ib_net16_t diag_code;
+ ib_net16_t m_key_lease_period;
+ uint8_t local_port_num;
+ uint8_t link_width_enabled;
+ uint8_t link_width_supported;
+ uint8_t link_width_active;
+ uint8_t state_info1; /* LinkSpeedSupported and PortState */
+ uint8_t state_info2; /* PortPhysState and LinkDownDefaultState */
+ uint8_t mkey_lmc; /* M_KeyProtectBits and LMC */
+ uint8_t link_speed; /* LinkSpeedEnabled and LinkSpeedActive */
+ uint8_t mtu_smsl;
+ uint8_t vl_cap; /* VLCap and InitType */
+ uint8_t vl_high_limit;
+ uint8_t vl_arb_high_cap;
+ uint8_t vl_arb_low_cap;
+ uint8_t mtu_cap;
+ uint8_t vl_stall_life;
+ uint8_t vl_enforce;
+ ib_net16_t m_key_violations;
+ ib_net16_t p_key_violations;
+ ib_net16_t q_key_violations;
+ uint8_t guid_cap;
+ uint8_t subnet_timeout; /* cli_rereg(1b), mcast_pkey_trap_suppr(1b), reserv(1b), timeout(5b) */
+ uint8_t resp_time_value; /* reserv(3b), rtv(5b) */
+ uint8_t error_threshold; /* local phy errors(4b), overrun errors(4b) */
+ ib_net16_t max_credit_hint;
+ ib_net32_t link_rt_latency; /* reserv(8b), link round trip lat(24b) */
+ ib_net16_t capability_mask2;
+ uint8_t link_speed_ext; /* LinkSpeedExtActive and LinkSpeedExtSupported */
+ uint8_t link_speed_ext_enabled; /* reserv(3b), LinkSpeedExtEnabled(5b) */
+} PACK_SUFFIX ib_port_info_t;
+#include <complib/cl_packoff.h>
+/************/
+
+#define IB_PORT_STATE_MASK 0x0F
+#define IB_PORT_LMC_MASK 0x07
+#define IB_PORT_LMC_MAX 0x07
+#define IB_PORT_MPB_MASK 0xC0
+#define IB_PORT_MPB_SHIFT 6
+#define IB_PORT_LINK_SPEED_SHIFT 4
+#define IB_PORT_LINK_SPEED_SUPPORTED_MASK 0xF0
+#define IB_PORT_LINK_SPEED_ACTIVE_MASK 0xF0
+#define IB_PORT_LINK_SPEED_ENABLED_MASK 0x0F
+#define IB_PORT_PHYS_STATE_MASK 0xF0
+#define IB_PORT_PHYS_STATE_SHIFT 4
+#define IB_PORT_PHYS_STATE_NO_CHANGE 0
+#define IB_PORT_PHYS_STATE_SLEEP 1
+#define IB_PORT_PHYS_STATE_POLLING 2
+#define IB_PORT_PHYS_STATE_DISABLED 3
+#define IB_PORT_PHYS_STATE_PORTCONFTRAIN 4
+#define IB_PORT_PHYS_STATE_LINKUP 5
+#define IB_PORT_PHYS_STATE_LINKERRRECOVER 6
+#define IB_PORT_PHYS_STATE_PHYTEST 7
+#define IB_PORT_LNKDWNDFTSTATE_MASK 0x0F
+
+#define IB_PORT_CAP_RESV0 (CL_HTON32(0x00000001))
+#define IB_PORT_CAP_IS_SM (CL_HTON32(0x00000002))
+#define IB_PORT_CAP_HAS_NOTICE (CL_HTON32(0x00000004))
+#define IB_PORT_CAP_HAS_TRAP (CL_HTON32(0x00000008))
+#define IB_PORT_CAP_HAS_IPD (CL_HTON32(0x00000010))
+#define IB_PORT_CAP_HAS_AUTO_MIG (CL_HTON32(0x00000020))
+#define IB_PORT_CAP_HAS_SL_MAP (CL_HTON32(0x00000040))
+#define IB_PORT_CAP_HAS_NV_MKEY (CL_HTON32(0x00000080))
+#define IB_PORT_CAP_HAS_NV_PKEY (CL_HTON32(0x00000100))
+#define IB_PORT_CAP_HAS_LED_INFO (CL_HTON32(0x00000200))
+#define IB_PORT_CAP_SM_DISAB (CL_HTON32(0x00000400))
+#define IB_PORT_CAP_HAS_SYS_IMG_GUID (CL_HTON32(0x00000800))
+#define IB_PORT_CAP_HAS_PKEY_SW_EXT_PORT_TRAP (CL_HTON32(0x00001000))
+#define IB_PORT_CAP_HAS_CABLE_INFO (CL_HTON32(0x00002000))
+#define IB_PORT_CAP_HAS_EXT_SPEEDS (CL_HTON32(0x00004000))
+#define IB_PORT_CAP_HAS_CAP_MASK2 (CL_HTON32(0x00008000))
+#define IB_PORT_CAP_HAS_COM_MGT (CL_HTON32(0x00010000))
+#define IB_PORT_CAP_HAS_SNMP (CL_HTON32(0x00020000))
+#define IB_PORT_CAP_REINIT (CL_HTON32(0x00040000))
+#define IB_PORT_CAP_HAS_DEV_MGT (CL_HTON32(0x00080000))
+#define IB_PORT_CAP_HAS_VEND_CLS (CL_HTON32(0x00100000))
+#define IB_PORT_CAP_HAS_DR_NTC (CL_HTON32(0x00200000))
+#define IB_PORT_CAP_HAS_CAP_NTC (CL_HTON32(0x00400000))
+#define IB_PORT_CAP_HAS_BM (CL_HTON32(0x00800000))
+#define IB_PORT_CAP_HAS_LINK_RT_LATENCY (CL_HTON32(0x01000000))
+#define IB_PORT_CAP_HAS_CLIENT_REREG (CL_HTON32(0x02000000))
+#define IB_PORT_CAP_HAS_OTHER_LOCAL_CHANGES_NTC (CL_HTON32(0x04000000))
+#define IB_PORT_CAP_HAS_LINK_SPEED_WIDTH_PAIRS_TBL (CL_HTON32(0x08000000))
+#define IB_PORT_CAP_HAS_VEND_MADS (CL_HTON32(0x10000000))
+#define IB_PORT_CAP_HAS_MCAST_PKEY_TRAP_SUPPRESS (CL_HTON32(0x20000000))
+#define IB_PORT_CAP_HAS_MCAST_FDB_TOP (CL_HTON32(0x40000000))
+#define IB_PORT_CAP_HAS_HIER_INFO (CL_HTON32(0x80000000))
+
+#define IB_PORT_CAP2_IS_SET_NODE_DESC_SUPPORTED (CL_HTON16(0x0001))
+#define IB_PORT_CAP2_IS_PORT_INFO_EXT_SUPPORTED (CL_HTON16(0x0002))
+#define IB_PORT_CAP2_IS_VIRT_SUPPORTED (CL_HTON16(0x0004))
+#define IB_PORT_CAP2_IS_SWITCH_PORT_STATE_TBL_SUPP (CL_HTON16(0x0008))
+#define IB_PORT_CAP2_IS_LINK_WIDTH_2X_SUPPORTED (CL_HTON16(0x0010))
+
+/****s* IBA Base: Types/ib_port_info_ext_t
+* NAME
+* ib_port_info_ext_t
+*
+* DESCRIPTION
+* IBA defined PortInfoExtended. (14.2.5.19)
+*
+* SYNOPSIS
+*/
+#include <complib/cl_packon.h>
+typedef struct _ib_port_info_ext {
+ ib_net32_t cap_mask;
+ ib_net16_t fec_mode_active;
+ ib_net16_t fdr_fec_mode_sup;
+ ib_net16_t fdr_fec_mode_enable;
+ ib_net16_t edr_fec_mode_sup;
+ ib_net16_t edr_fec_mode_enable;
+ uint8_t reserved[50];
+} PACK_SUFFIX ib_port_info_ext_t;
+#include <complib/cl_packoff.h>
+/************/
+
+#define IB_PORT_EXT_NO_FEC_MODE_ACTIVE 0
+#define IB_PORT_EXT_FIRE_CODE_FEC_MODE_ACTIVE (CL_HTON16(0x0001))
+#define IB_PORT_EXT_RS_FEC_MODE_ACTIVE (CL_HTON16(0x0002))
+#define IB_PORT_EXT_LOW_LATENCY_RS_FEC_MODE_ACTIVE (CL_HTON16(0x0003))
+
+#define IB_PORT_EXT_CAP_IS_FEC_MODE_SUPPORTED (CL_HTON32(0x00000001))
+/****f* IBA Base: Types/ib_port_info_get_port_state
+* NAME
+* ib_port_info_get_port_state
+*
+* DESCRIPTION
+* Returns the port state.
+*
+* SYNOPSIS
+*/
+static inline uint8_t OSM_API
+ib_port_info_get_port_state(IN const ib_port_info_t * const p_pi)
+{
+ return ((uint8_t) (p_pi->state_info1 & IB_PORT_STATE_MASK));
+}
+
+/*
+* PARAMETERS
+* p_pi
+* [in] Pointer to a PortInfo attribute.
+*
+* RETURN VALUES
+* Port state.
+*
+* NOTES
+*
+* SEE ALSO
+*********/
+
+/****f* IBA Base: Types/ib_port_info_set_port_state
+* NAME
+* ib_port_info_set_port_state
+*
+* DESCRIPTION
+* Sets the port state.
+*
+* SYNOPSIS
+*/
+static inline void OSM_API
+ib_port_info_set_port_state(IN ib_port_info_t * const p_pi,
+ IN const uint8_t port_state)
+{
+ p_pi->state_info1 = (uint8_t) ((p_pi->state_info1 & 0xF0) | port_state);
+}
+
+/*
+* PARAMETERS
+* p_pi
+* [in] Pointer to a PortInfo attribute.
+*
+* port_state
+* [in] Port state value to set.
+*
+* RETURN VALUES
+* None.
+*
+* NOTES
+*
+* SEE ALSO
+*********/
+
+/****f* IBA Base: Types/ib_port_info_get_vl_cap
+* NAME
+* ib_port_info_get_vl_cap
+*
+* DESCRIPTION
+* Gets the VL Capability of a port.
+*
+* SYNOPSIS
+*/
+static inline uint8_t OSM_API
+ib_port_info_get_vl_cap(IN const ib_port_info_t * const p_pi)
+{
+ return ((p_pi->vl_cap >> 4) & 0x0F);
+}
+
+/*
+* PARAMETERS
+* p_pi
+* [in] Pointer to a PortInfo attribute.
+*
+* RETURN VALUES
+* VL_CAP field
+*
+* NOTES
+*
+* SEE ALSO
+*********/
+
+/****f* IBA Base: Types/ib_port_info_get_init_type
+* NAME
+* ib_port_info_get_init_type
+*
+* DESCRIPTION
+* Gets the init type of a port.
+*
+* SYNOPSIS
+*/
+static inline uint8_t OSM_API
+ib_port_info_get_init_type(IN const ib_port_info_t * const p_pi)
+{
+ return (uint8_t) (p_pi->vl_cap & 0x0F);
+}
+
+/*
+* PARAMETERS
+* p_pi
+* [in] Pointer to a PortInfo attribute.
+*
+* RETURN VALUES
+* InitType field
+*
+* NOTES
+*
+* SEE ALSO
+*********/
+
+/****f* IBA Base: Types/ib_port_info_get_op_vls
+* NAME
+* ib_port_info_get_op_vls
+*
+* DESCRIPTION
+* Gets the operational VLs on a port.
+*
+* SYNOPSIS
+*/
+static inline uint8_t OSM_API
+ib_port_info_get_op_vls(IN const ib_port_info_t * const p_pi)
+{
+ return ((p_pi->vl_enforce >> 4) & 0x0F);
+}
+
+/*
+* PARAMETERS
+* p_pi
+* [in] Pointer to a PortInfo attribute.
+*
+* RETURN VALUES
+* OP_VLS field
+*
+* NOTES
+*
+* SEE ALSO
+*********/
+
+/****f* IBA Base: Types/ib_port_info_set_op_vls
+* NAME
+* ib_port_info_set_op_vls
+*
+* DESCRIPTION
+* Sets the operational VLs on a port.
+*
+* SYNOPSIS
+*/
+static inline void OSM_API
+ib_port_info_set_op_vls(IN ib_port_info_t * const p_pi, IN const uint8_t op_vls)
+{
+ p_pi->vl_enforce =
+ (uint8_t) ((p_pi->vl_enforce & 0x0F) | (op_vls << 4));
+}
+
+/*
+* PARAMETERS
+* p_pi
+* [in] Pointer to a PortInfo attribute.
+*
+* op_vls
+* [in] Encoded operation VLs value.
+*
+* RETURN VALUES
+* None.
+*
+* NOTES
+*
+* SEE ALSO
+*********/
+
+/****f* IBA Base: Types/ib_port_info_set_state_no_change
+* NAME
+* ib_port_info_set_state_no_change
+*
+* DESCRIPTION
+* Sets the port state fields to the value for "no change".
+*
+* SYNOPSIS
+*/
+static inline void OSM_API
+ib_port_info_set_state_no_change(IN ib_port_info_t * const p_pi)
+{
+ ib_port_info_set_port_state(p_pi, IB_LINK_NO_CHANGE);
+ p_pi->state_info2 = 0;
+}
+
+/*
+* PARAMETERS
+* p_pi
+* [in] Pointer to a PortInfo attribute.
+*
+* RETURN VALUES
+* None.
+*
+* NOTES
+*
+* SEE ALSO
+*********/
+
+/****f* IBA Base: Types/ib_port_info_get_link_speed_sup
+* NAME
+* ib_port_info_get_link_speed_sup
+*
+* DESCRIPTION
+* Returns the encoded value for the link speed supported.
+*
+* SYNOPSIS
+*/
+static inline uint8_t OSM_API
+ib_port_info_get_link_speed_sup(IN const ib_port_info_t * const p_pi)
+{
+ return ((uint8_t) ((p_pi->state_info1 &
+ IB_PORT_LINK_SPEED_SUPPORTED_MASK) >>
+ IB_PORT_LINK_SPEED_SHIFT));
+}
+
+/*
+* PARAMETERS
+* p_pi
+* [in] Pointer to a PortInfo attribute.
+*
+* RETURN VALUES
+* Returns the encoded value for the link speed supported.
+*
+* NOTES
+*
+* SEE ALSO
+*********/
+
+/****f* IBA Base: Types/ib_port_info_set_link_speed_sup
+* NAME
+* ib_port_info_set_link_speed_sup
+*
+* DESCRIPTION
+* Given an integer of the supported link speed supported.
+* Set the appropriate bits in state_info1
+*
+* SYNOPSIS
+*/
+static inline void OSM_API
+ib_port_info_set_link_speed_sup(IN uint8_t const speed,
+ IN ib_port_info_t * p_pi)
+{
+ p_pi->state_info1 =
+ (~IB_PORT_LINK_SPEED_SUPPORTED_MASK & p_pi->state_info1) |
+ (IB_PORT_LINK_SPEED_SUPPORTED_MASK &
+ (speed << IB_PORT_LINK_SPEED_SHIFT));
+}
+
+/*
+* PARAMETERS
+* speed
+* [in] Supported Speeds Code.
+*
+* p_pi
+* [in] Pointer to a PortInfo attribute.
+*
+* RETURN VALUES
+* This function does not return a value.
+*
+* NOTES
+*
+* SEE ALSO
+*********/
+
+/****f* IBA Base: Types/ib_port_info_get_port_phys_state
+* NAME
+* ib_port_info_get_port_phys_state
+*
+* DESCRIPTION
+* Returns the encoded value for the port physical state.
+*
+* SYNOPSIS
+*/
+static inline uint8_t OSM_API
+ib_port_info_get_port_phys_state(IN const ib_port_info_t * const p_pi)
+{
+ return ((uint8_t) ((p_pi->state_info2 &
+ IB_PORT_PHYS_STATE_MASK) >>
+ IB_PORT_PHYS_STATE_SHIFT));
+}
+
+/*
+* PARAMETERS
+* p_pi
+* [in] Pointer to a PortInfo attribute.
+*
+* RETURN VALUES
+* Returns the encoded value for the port physical state.
+*
+* NOTES
+*
+* SEE ALSO
+*********/
+
+/****f* IBA Base: Types/ib_port_info_set_port_phys_state
+* NAME
+* ib_port_info_set_port_phys_state
+*
+* DESCRIPTION
+* Given an integer of the port physical state,
+* Set the appropriate bits in state_info2
+*
+* SYNOPSIS
+*/
+static inline void OSM_API
+ib_port_info_set_port_phys_state(IN uint8_t const phys_state,
+ IN ib_port_info_t * p_pi)
+{
+ p_pi->state_info2 =
+ (~IB_PORT_PHYS_STATE_MASK & p_pi->state_info2) |
+ (IB_PORT_PHYS_STATE_MASK &
+ (phys_state << IB_PORT_PHYS_STATE_SHIFT));
+}
+
+/*
+* PARAMETERS
+* phys_state
+* [in] port physical state.
+*
+* p_pi
+* [in] Pointer to a PortInfo attribute.
+*
+* RETURN VALUES
+* This function does not return a value.
+*
+* NOTES
+*
+* SEE ALSO
+*********/
+
+/****f* IBA Base: Types/ib_port_info_get_link_down_def_state
+* NAME
+* ib_port_info_get_link_down_def_state
+*
+* DESCRIPTION
+* Returns the link down default state.
+*
+* SYNOPSIS
+*/
+static inline uint8_t OSM_API
+ib_port_info_get_link_down_def_state(IN const ib_port_info_t * const p_pi)
+{
+ return ((uint8_t) (p_pi->state_info2 & IB_PORT_LNKDWNDFTSTATE_MASK));
+}
+
+/*
+* PARAMETERS
+* p_pi
+* [in] Pointer to a PortInfo attribute.
+*
+* RETURN VALUES
+* link down default state of the port.
+*
+* NOTES
+*
+* SEE ALSO
+*********/
+
+/****f* IBA Base: Types/ib_port_info_set_link_down_def_state
+* NAME
+* ib_port_info_set_link_down_def_state
+*
+* DESCRIPTION
+* Sets the link down default state of the port.
+*
+* SYNOPSIS
+*/
+static inline void OSM_API
+ib_port_info_set_link_down_def_state(IN ib_port_info_t * const p_pi,
+ IN const uint8_t link_dwn_state)
+{
+ p_pi->state_info2 =
+ (uint8_t) ((p_pi->state_info2 & 0xF0) | link_dwn_state);
+}
+
+/*
+* PARAMETERS
+* p_pi
+* [in] Pointer to a PortInfo attribute.
+*
+* link_dwn_state
+* [in] Link down default state of the port.
+*
+* RETURN VALUES
+* None.
+*
+* NOTES
+*
+* SEE ALSO
+*********/
+
+/****f* IBA Base: Types/ib_port_info_get_link_speed_active
+* NAME
+* ib_port_info_get_link_speed_active
+*
+* DESCRIPTION
+* Returns the Link Speed Active value assigned to this port.
+*
+* SYNOPSIS
+*/
+static inline uint8_t OSM_API
+ib_port_info_get_link_speed_active(IN const ib_port_info_t * const p_pi)
+{
+ return ((uint8_t) ((p_pi->link_speed &
+ IB_PORT_LINK_SPEED_ACTIVE_MASK) >>
+ IB_PORT_LINK_SPEED_SHIFT));
+}
+
+/*
+* PARAMETERS
+* p_pi
+* [in] Pointer to a PortInfo attribute.
+*
+* RETURN VALUES
+* Returns the link speed active value assigned to this port.
+*
+* NOTES
+*
+* SEE ALSO
+*********/
+
+#define IB_LINK_WIDTH_ACTIVE_1X 1
+#define IB_LINK_WIDTH_ACTIVE_4X 2
+#define IB_LINK_WIDTH_ACTIVE_8X 4
+#define IB_LINK_WIDTH_ACTIVE_12X 8
+#define IB_LINK_WIDTH_ACTIVE_2X 16
+#define IB_LINK_SPEED_ACTIVE_EXTENDED 0
+#define IB_LINK_SPEED_ACTIVE_2_5 1
+#define IB_LINK_SPEED_ACTIVE_5 2
+#define IB_LINK_SPEED_ACTIVE_10 4
+#define IB_LINK_SPEED_EXT_ACTIVE_NONE 0
+#define IB_LINK_SPEED_EXT_ACTIVE_14 1
+#define IB_LINK_SPEED_EXT_ACTIVE_25 2
+#define IB_LINK_SPEED_EXT_DISABLE 30
+#define IB_LINK_SPEED_EXT_SET_LSES 31
+
+/* following v1 ver1.3 p984 */
+#define IB_PATH_RECORD_RATE_2_5_GBS 2
+#define IB_PATH_RECORD_RATE_10_GBS 3
+#define IB_PATH_RECORD_RATE_30_GBS 4
+#define IB_PATH_RECORD_RATE_5_GBS 5
+#define IB_PATH_RECORD_RATE_20_GBS 6
+#define IB_PATH_RECORD_RATE_40_GBS 7
+#define IB_PATH_RECORD_RATE_60_GBS 8
+#define IB_PATH_RECORD_RATE_80_GBS 9
+#define IB_PATH_RECORD_RATE_120_GBS 10
+#define IB_PATH_RECORD_RATE_14_GBS 11
+#define IB_PATH_RECORD_RATE_56_GBS 12
+#define IB_PATH_RECORD_RATE_112_GBS 13
+#define IB_PATH_RECORD_RATE_168_GBS 14
+#define IB_PATH_RECORD_RATE_25_GBS 15
+#define IB_PATH_RECORD_RATE_100_GBS 16
+#define IB_PATH_RECORD_RATE_200_GBS 17
+#define IB_PATH_RECORD_RATE_300_GBS 18
+#define IB_PATH_RECORD_RATE_28_GBS 19
+#define IB_PATH_RECORD_RATE_50_GBS 20
+
+#define IB_MIN_RATE IB_PATH_RECORD_RATE_2_5_GBS
+#define IB_MAX_RATE IB_PATH_RECORD_RATE_50_GBS
+
+static inline uint8_t OSM_API
+ib_port_info_get_link_speed_ext_active(IN const ib_port_info_t * const p_pi);
+
+/****f* IBA Base: Types/ib_port_info_compute_rate
+* NAME
+* ib_port_info_compute_rate
+*
+* DESCRIPTION
+* Returns the encoded value for the path rate.
+*
+* SYNOPSIS
+*/
+static inline uint8_t OSM_API
+ib_port_info_compute_rate(IN const ib_port_info_t * const p_pi,
+ IN const int extended)
+{
+ uint8_t rate = 0;
+
+ if (extended) {
+ switch (ib_port_info_get_link_speed_ext_active(p_pi)) {
+ case IB_LINK_SPEED_EXT_ACTIVE_14:
+ switch (p_pi->link_width_active) {
+ case IB_LINK_WIDTH_ACTIVE_1X:
+ rate = IB_PATH_RECORD_RATE_14_GBS;
+ break;
+
+ case IB_LINK_WIDTH_ACTIVE_4X:
+ rate = IB_PATH_RECORD_RATE_56_GBS;
+ break;
+
+ case IB_LINK_WIDTH_ACTIVE_8X:
+ rate = IB_PATH_RECORD_RATE_112_GBS;
+ break;
+
+ case IB_LINK_WIDTH_ACTIVE_12X:
+ rate = IB_PATH_RECORD_RATE_168_GBS;
+ break;
+
+ case IB_LINK_WIDTH_ACTIVE_2X:
+ rate = IB_PATH_RECORD_RATE_28_GBS;
+ break;
+
+ default:
+ rate = IB_PATH_RECORD_RATE_14_GBS;
+ break;
+ }
+ break;
+ case IB_LINK_SPEED_EXT_ACTIVE_25:
+ switch (p_pi->link_width_active) {
+ case IB_LINK_WIDTH_ACTIVE_1X:
+ rate = IB_PATH_RECORD_RATE_25_GBS;
+ break;
+
+ case IB_LINK_WIDTH_ACTIVE_4X:
+ rate = IB_PATH_RECORD_RATE_100_GBS;
+ break;
+
+ case IB_LINK_WIDTH_ACTIVE_8X:
+ rate = IB_PATH_RECORD_RATE_200_GBS;
+ break;
+
+ case IB_LINK_WIDTH_ACTIVE_12X:
+ rate = IB_PATH_RECORD_RATE_300_GBS;
+ break;
+
+ case IB_LINK_WIDTH_ACTIVE_2X:
+ rate = IB_PATH_RECORD_RATE_50_GBS;
+ break;
+
+ default:
+ rate = IB_PATH_RECORD_RATE_25_GBS;
+ break;
+ }
+ break;
+ /* IB_LINK_SPEED_EXT_ACTIVE_NONE and any others */
+ default:
+ break;
+ }
+ if (rate)
+ return rate;
+ }
+
+ switch (ib_port_info_get_link_speed_active(p_pi)) {
+ case IB_LINK_SPEED_ACTIVE_2_5:
+ switch (p_pi->link_width_active) {
+ case IB_LINK_WIDTH_ACTIVE_1X:
+ rate = IB_PATH_RECORD_RATE_2_5_GBS;
+ break;
+
+ case IB_LINK_WIDTH_ACTIVE_4X:
+ rate = IB_PATH_RECORD_RATE_10_GBS;
+ break;
+
+ case IB_LINK_WIDTH_ACTIVE_8X:
+ rate = IB_PATH_RECORD_RATE_20_GBS;
+ break;
+
+ case IB_LINK_WIDTH_ACTIVE_12X:
+ rate = IB_PATH_RECORD_RATE_30_GBS;
+ break;
+
+ case IB_LINK_WIDTH_ACTIVE_2X:
+ rate = IB_PATH_RECORD_RATE_5_GBS;
+ break;
+
+ default:
+ rate = IB_PATH_RECORD_RATE_2_5_GBS;
+ break;
+ }
+ break;
+ case IB_LINK_SPEED_ACTIVE_5:
+ switch (p_pi->link_width_active) {
+ case IB_LINK_WIDTH_ACTIVE_1X:
+ rate = IB_PATH_RECORD_RATE_5_GBS;
+ break;
+
+ case IB_LINK_WIDTH_ACTIVE_4X:
+ rate = IB_PATH_RECORD_RATE_20_GBS;
+ break;
+
+ case IB_LINK_WIDTH_ACTIVE_8X:
+ rate = IB_PATH_RECORD_RATE_40_GBS;
+ break;
+
+ case IB_LINK_WIDTH_ACTIVE_12X:
+ rate = IB_PATH_RECORD_RATE_60_GBS;
+ break;
+
+ case IB_LINK_WIDTH_ACTIVE_2X:
+ rate = IB_PATH_RECORD_RATE_10_GBS;
+ break;
+
+ default:
+ rate = IB_PATH_RECORD_RATE_5_GBS;
+ break;
+ }
+ break;
+ case IB_LINK_SPEED_ACTIVE_10:
+ switch (p_pi->link_width_active) {
+ case IB_LINK_WIDTH_ACTIVE_1X:
+ rate = IB_PATH_RECORD_RATE_10_GBS;
+ break;
+
+ case IB_LINK_WIDTH_ACTIVE_4X:
+ rate = IB_PATH_RECORD_RATE_40_GBS;
+ break;
+
+ case IB_LINK_WIDTH_ACTIVE_8X:
+ rate = IB_PATH_RECORD_RATE_80_GBS;
+ break;
+
+ case IB_LINK_WIDTH_ACTIVE_12X:
+ rate = IB_PATH_RECORD_RATE_120_GBS;
+ break;
+
+ case IB_LINK_WIDTH_ACTIVE_2X:
+ rate = IB_PATH_RECORD_RATE_20_GBS;
+ break;
+
+ default:
+ rate = IB_PATH_RECORD_RATE_10_GBS;
+ break;
+ }
+ break;
+ default:
+ rate = IB_PATH_RECORD_RATE_2_5_GBS;
+ break;
+ }
+
+ return rate;
+}
+
+/*
+* PARAMETERS
+* p_pi
+* [in] Pointer to a PortInfo attribute.
+*
+* extended
+* [in] Indicates whether or not to use extended link speeds.
+*
+* RETURN VALUES
+* Returns the encoded value for the link speed supported.
+*
+* NOTES
+*
+* SEE ALSO
+*********/
+
+/****f* IBA Base: Types/ib_path_get_ipd
+* NAME
+* ib_path_get_ipd
+*
+* DESCRIPTION
+* Returns the encoded value for the inter packet delay.
+*
+* SYNOPSIS
+*/
+static inline uint8_t OSM_API
+ib_path_get_ipd(IN uint8_t local_link_width_supported, IN uint8_t path_rec_rate)
+{
+ uint8_t ipd = 0;
+
+ switch (local_link_width_supported) {
+ /* link_width_supported = 1: 1x */
+ case 1:
+ break;
+
+ /* link_width_supported = 3: 1x or 4x */
+ case 3:
+ switch (path_rec_rate & 0x3F) {
+ case IB_PATH_RECORD_RATE_2_5_GBS:
+ ipd = 3;
+ break;
+ default:
+ break;
+ }
+ break;
+
+ /* link_width_supported = 11: 1x or 4x or 12x */
+ case 11:
+ switch (path_rec_rate & 0x3F) {
+ case IB_PATH_RECORD_RATE_2_5_GBS:
+ ipd = 11;
+ break;
+ case IB_PATH_RECORD_RATE_10_GBS:
+ ipd = 2;
+ break;
+ default:
+ break;
+ }
+ break;
+
+ default:
+ break;
+ }
+
+ return ipd;
+}
+
+/*
+* PARAMETERS
+* local_link_width_supported
+* [in] link with supported for this port
+*
+* path_rec_rate
+* [in] rate field of the path record
+*
+* RETURN VALUES
+* Returns the ipd
+*
+* NOTES
+*
+* SEE ALSO
+*********/
+
+/****f* IBA Base: Types/ib_port_info_get_mtu_cap
+* NAME
+* ib_port_info_get_mtu_cap
+*
+* DESCRIPTION
+* Returns the encoded value for the maximum MTU supported by this port.
+*
+* SYNOPSIS
+*/
+static inline uint8_t OSM_API
+ib_port_info_get_mtu_cap(IN const ib_port_info_t * const p_pi)
+{
+ return ((uint8_t) (p_pi->mtu_cap & 0x0F));
+}
+
+/*
+* PARAMETERS
+* p_pi
+* [in] Pointer to a PortInfo attribute.
+*
+* RETURN VALUES
+* Returns the encooded value for the maximum MTU supported by this port.
+*
+* NOTES
+*
+* SEE ALSO
+*********/
+
+/****f* IBA Base: Types/ib_port_info_get_neighbor_mtu
+* NAME
+* ib_port_info_get_neighbor_mtu
+*
+* DESCRIPTION
+* Returns the encoded value for the neighbor MTU supported by this port.
+*
+* SYNOPSIS
+*/
+static inline uint8_t OSM_API
+ib_port_info_get_neighbor_mtu(IN const ib_port_info_t * const p_pi)
+{
+ return ((uint8_t) ((p_pi->mtu_smsl & 0xF0) >> 4));
+}
+
+/*
+* PARAMETERS
+* p_pi
+* [in] Pointer to a PortInfo attribute.
+*
+* RETURN VALUES
+* Returns the encoded value for the neighbor MTU at this port.
+*
+* NOTES
+*
+* SEE ALSO
+*********/
+
+/****f* IBA Base: Types/ib_port_info_set_neighbor_mtu
+* NAME
+* ib_port_info_set_neighbor_mtu
+*
+* DESCRIPTION
+* Sets the Neighbor MTU value in the PortInfo attribute.
+*
+* SYNOPSIS
+*/
+static inline void OSM_API
+ib_port_info_set_neighbor_mtu(IN ib_port_info_t * const p_pi,
+ IN const uint8_t mtu)
+{
+ CL_ASSERT(mtu <= 5);
+ CL_ASSERT(mtu != 0);
+ p_pi->mtu_smsl = (uint8_t) ((p_pi->mtu_smsl & 0x0F) | (mtu << 4));
+}
+
+/*
+* PARAMETERS
+* p_pi
+* [in] Pointer to a PortInfo attribute.
+*
+* mtu
+* [in] Encoded MTU value to set
+*
+* RETURN VALUES
+* None.
+*
+* NOTES
+*
+* SEE ALSO
+*********/
+
+/****f* IBA Base: Types/ib_port_info_get_master_smsl
+* NAME
+* ib_port_info_get_master_smsl
+*
+* DESCRIPTION
+* Returns the encoded value for the Master SMSL at this port.
+*
+* SYNOPSIS
+*/
+static inline uint8_t OSM_API
+ib_port_info_get_master_smsl(IN const ib_port_info_t * const p_pi)
+{
+ return (uint8_t) (p_pi->mtu_smsl & 0x0F);
+}
+
+/*
+* PARAMETERS
+* p_pi
+* [in] Pointer to a PortInfo attribute.
+*
+* RETURN VALUES
+* Returns the encoded value for the Master SMSL at this port.
+*
+* NOTES
+*
+* SEE ALSO
+*********/
+
+/****f* IBA Base: Types/ib_port_info_set_master_smsl
+* NAME
+* ib_port_info_set_master_smsl
+*
+* DESCRIPTION
+* Sets the Master SMSL value in the PortInfo attribute.
+*
+* SYNOPSIS
+*/
+static inline void OSM_API
+ib_port_info_set_master_smsl(IN ib_port_info_t * const p_pi,
+ IN const uint8_t smsl)
+{
+ p_pi->mtu_smsl = (uint8_t) ((p_pi->mtu_smsl & 0xF0) | smsl);
+}
+
+/*
+* PARAMETERS
+* p_pi
+* [in] Pointer to a PortInfo attribute.
+*
+* mtu
+* [in] Encoded Master SMSL value to set
+*
+* RETURN VALUES
+* None.
+*
+* NOTES
+*
+* SEE ALSO
+*********/
+
+/****f* IBA Base: Types/ib_port_info_set_timeout
+* NAME
+* ib_port_info_set_timeout
+*
+* DESCRIPTION
+* Sets the encoded subnet timeout value in the PortInfo attribute.
+*
+* SYNOPSIS
+*/
+static inline void OSM_API
+ib_port_info_set_timeout(IN ib_port_info_t * const p_pi,
+ IN const uint8_t timeout)
+{
+ CL_ASSERT(timeout <= 0x1F);
+ p_pi->subnet_timeout =
+ (uint8_t) ((p_pi->subnet_timeout & 0xE0) | (timeout & 0x1F));
+}
+
+/*
+* PARAMETERS
+* p_pi
+* [in] Pointer to a PortInfo attribute.
+*
+* timeout
+* [in] Encoded timeout value to set
+*
+* RETURN VALUES
+* None.
+*
+* NOTES
+*
+* SEE ALSO
+*********/
+
+/****f* IBA Base: Types/ib_port_info_set_client_rereg
+* NAME
+* ib_port_info_set_client_rereg
+*
+* DESCRIPTION
+* Sets the encoded client reregistration bit value in the PortInfo attribute.
+*
+* SYNOPSIS
+*/
+static inline void OSM_API
+ib_port_info_set_client_rereg(IN ib_port_info_t * const p_pi,
+ IN const uint8_t client_rereg)
+{
+ CL_ASSERT(client_rereg <= 0x1);
+ p_pi->subnet_timeout =
+ (uint8_t) ((p_pi->subnet_timeout & 0x7F) | (client_rereg << 7));
+}
+
+/*
+* PARAMETERS
+* p_pi
+* [in] Pointer to a PortInfo attribute.
+*
+* client_rereg
+* [in] Client reregistration value to set (either 1 or 0).
+*
+* RETURN VALUES
+* None.
+*
+* NOTES
+*
+* SEE ALSO
+*********/
+
+/****f* IBA Base: Types/ib_port_info_set_mcast_pkey_trap_suppress
+* NAME
+* ib_port_info_set_mcast_pkey_trap_suppress
+*
+* DESCRIPTION
+* Sets the encoded multicast pkey trap suppression enabled bit value
+* in the PortInfo attribute.
+*
+* SYNOPSIS
+*/
+static inline void OSM_API
+ib_port_info_set_mcast_pkey_trap_suppress(IN ib_port_info_t * const p_pi,
+ IN const uint8_t trap_suppress)
+{
+ CL_ASSERT(trap_suppress <= 0x1);
+ p_pi->subnet_timeout =
+ (uint8_t) ((p_pi->subnet_timeout & 0xBF) | (trap_suppress << 6));
+}
+
+/*
+* PARAMETERS
+* p_pi
+* [in] Pointer to a PortInfo attribute.
+*
+* trap_suppress
+* [in] Multicast pkey trap suppression enabled value to set
+* (either 1 or 0).
+*
+* RETURN VALUES
+* None.
+*
+* NOTES
+*
+* SEE ALSO
+*********/
+
+/****f* IBA Base: Types/ib_port_info_get_timeout
+* NAME
+* ib_port_info_get_timeout
+*
+* DESCRIPTION
+* Gets the encoded subnet timeout value in the PortInfo attribute.
+*
+* SYNOPSIS
+*/
+static inline uint8_t OSM_API
+ib_port_info_get_timeout(IN ib_port_info_t const *p_pi)
+{
+ return (p_pi->subnet_timeout & 0x1F);
+}
+
+/*
+* PARAMETERS
+* p_pi
+* [in] Pointer to a PortInfo attribute.
+*
+* RETURN VALUES
+* The encoded timeout value
+*
+* NOTES
+*
+* SEE ALSO
+*********/
+
+/****f* IBA Base: Types/ib_port_info_get_link_speed_ext_active
+* NAME
+* ib_port_info_get_link_speed_ext_active
+*
+* DESCRIPTION
+* Gets the encoded LinkSpeedExtActive value in the PortInfo attribute.
+*
+* SYNOPSIS
+*/
+static inline uint8_t OSM_API
+ib_port_info_get_link_speed_ext_active(IN const ib_port_info_t * const p_pi)
+{
+ return ((p_pi->link_speed_ext & 0xF0) >> 4);
+}
+
+/*
+* PARAMETERS
+* p_pi
+* [in] Pointer to a PortInfo attribute.
+*
+* RETURN VALUES
+* The encoded LinkSpeedExtActive value
+*
+* NOTES
+*
+* SEE ALSO
+*********/
+
+/****f* IBA Base: Types/ib_port_info_get_link_speed_ext_sup
+* NAME
+* ib_port_info_get_link_speed_ext_sup
+*
+* DESCRIPTION
+* Returns the encoded value for the link speed extended supported.
+*
+* SYNOPSIS
+*/
+static inline uint8_t OSM_API
+ib_port_info_get_link_speed_ext_sup(IN const ib_port_info_t * const p_pi)
+{
+ return (p_pi->link_speed_ext & 0x0F);
+}
+
+/*
+* PARAMETERS
+* p_pi
+* [in] Pointer to a PortInfo attribute.
+*
+* RETURN VALUES
+* The encoded LinkSpeedExtSupported value
+*
+* NOTES
+*
+* SEE ALSO
+*********/
+
+/****f* IBA Base: Types/ib_port_info_get_link_speed_ext_enabled
+* NAME
+* ib_port_info_get_link_speed_ext_enabled
+*
+* DESCRIPTION
+* Gets the encoded LinkSpeedExtEnabled value in the PortInfo attribute.
+*
+* SYNOPSIS
+*/
+static inline uint8_t OSM_API
+ib_port_info_get_link_speed_ext_enabled(IN const ib_port_info_t * const p_pi)
+{
+ return (p_pi->link_speed_ext_enabled & 0x1F);
+}
+
+/*
+* PARAMETERS
+* p_pi
+* [in] Pointer to a PortInfo attribute.
+*
+* RETURN VALUES
+* The encoded LinkSpeedExtEnabled value
+*
+* NOTES
+*
+* SEE ALSO
+*********/
+
+/****f* IBA Base: Types/ib_port_info_set_link_speed_ext_enabled
+* NAME
+* ib_port_info_set_link_speed_ext_enabled
+*
+* DESCRIPTION
+* Sets the link speed extended enabled value in the PortInfo attribute.
+*
+* SYNOPSIS
+*/
+static inline void OSM_API
+ib_port_info_set_link_speed_ext_enabled(IN ib_port_info_t * const p_pi,
+ IN const uint8_t link_speed_ext_enabled)
+{
+ CL_ASSERT(link_speed_ext_enabled <= 0x1F);
+ p_pi->link_speed_ext_enabled = link_speed_ext_enabled & 0x1F;
+}
+
+/*
+* PARAMETERS
+* p_pi
+* [in] Pointer to a PortInfo attribute.
+*
+* link_speed_ext_enabled
+* [in] link speed extehded enabled value to set.
+*
+* RETURN VALUES
+* The encoded LinkSpeedExtEnabled value
+*
+* NOTES
+*
+* SEE ALSO
+*********/
+
+/****f* IBA Base: Types/ib_port_info_get_resp_time_value
+* NAME
+* ib_port_info_get_resp_time_value
+*
+* DESCRIPTION
+* Gets the encoded resp time value in the PortInfo attribute.
+*
+* SYNOPSIS
+*/
+static inline uint8_t OSM_API
+ib_port_info_get_resp_time_value(IN const ib_port_info_t * const p_pi)
+{
+ return (p_pi->resp_time_value & 0x1F);
+}
+
+/*
+* PARAMETERS
+* p_pi
+* [in] Pointer to a PortInfo attribute.
+*
+* RETURN VALUES
+* The encoded resp time value
+*
+* NOTES
+*
+* SEE ALSO
+*********/
+
+/****f* IBA Base: Types/ib_port_info_get_client_rereg
+* NAME
+* ib_port_info_get_client_rereg
+*
+* DESCRIPTION
+* Gets the encoded client reregistration bit value in the PortInfo attribute.
+*
+* SYNOPSIS
+*/
+static inline uint8_t OSM_API
+ib_port_info_get_client_rereg(IN ib_port_info_t const *p_pi)
+{
+ return ((p_pi->subnet_timeout & 0x80) >> 7);
+}
+
+/*
+* PARAMETERS
+* p_pi
+* [in] Pointer to a PortInfo attribute.
+*
+* RETURN VALUES
+* Client reregistration value (either 1 or 0).
+*
+* NOTES
+*
+* SEE ALSO
+*********/
+
+/****f* IBA Base: Types/ib_port_info_get_mcast_pkey_trap_suppress
+* NAME
+* ib_port_info_get_mcast_pkey_trap_suppress
+*
+* DESCRIPTION
+* Gets the encoded multicast pkey trap suppression enabled bit value
+* in the PortInfo attribute.
+*
+* SYNOPSIS
+*/
+static inline uint8_t OSM_API
+ib_port_info_get_mcast_pkey_trap_suppress(IN ib_port_info_t const *p_pi)
+{
+ return ((p_pi->subnet_timeout & 0x40) >> 6);
+}
+
+/*
+* PARAMETERS
+* p_pi
+* [in] Pointer to a PortInfo attribute.
+*
+* RETURN VALUES
+* Multicast PKey trap suppression enabled value (either 1 or 0).
+*
+* NOTES
+*
+* SEE ALSO
+*********/
+
+/****f* IBA Base: Types/ib_port_info_set_hoq_lifetime
+* NAME
+* ib_port_info_set_hoq_lifetime
+*
+* DESCRIPTION
+* Sets the Head of Queue Lifetime for which a packet can live in the head
+* of VL queue
+*
+* SYNOPSIS
+*/
+static inline void OSM_API
+ib_port_info_set_hoq_lifetime(IN ib_port_info_t * const p_pi,
+ IN const uint8_t hoq_life)
+{
+ p_pi->vl_stall_life = (uint8_t) ((hoq_life & 0x1f) |
+ (p_pi->vl_stall_life & 0xe0));
+}
+
+/*
+* PARAMETERS
+* p_pi
+* [in] Pointer to a PortInfo attribute.
+*
+* hoq_life
+* [in] Encoded lifetime value to set
+*
+* RETURN VALUES
+* None.
+*
+* NOTES
+*
+* SEE ALSO
+*********/
+
+/****f* IBA Base: Types/ib_port_info_get_hoq_lifetime
+* NAME
+* ib_port_info_get_hoq_lifetime
+*
+* DESCRIPTION
+* Gets the Head of Queue Lifetime for which a packet can live in the head
+* of VL queue
+*
+* SYNOPSIS
+*/
+static inline uint8_t OSM_API
+ib_port_info_get_hoq_lifetime(IN const ib_port_info_t * const p_pi)
+{
+ return ((uint8_t) (p_pi->vl_stall_life & 0x1f));
+}
+
+/*
+* PARAMETERS
+* p_pi
+* [in] Pointer to a PortInfo attribute.
+*
+* RETURN VALUES
+* Encoded lifetime value
+*
+* NOTES
+*
+* SEE ALSO
+*********/
+
+/****f* IBA Base: Types/ib_port_info_set_vl_stall_count
+* NAME
+* ib_port_info_set_vl_stall_count
+*
+* DESCRIPTION
+* Sets the VL Stall Count which define the number of contiguous
+* HLL (hoq) drops that will put the VL into stalled mode.
+*
+* SYNOPSIS
+*/
+static inline void OSM_API
+ib_port_info_set_vl_stall_count(IN ib_port_info_t * const p_pi,
+ IN const uint8_t vl_stall_count)
+{
+ p_pi->vl_stall_life = (uint8_t) ((p_pi->vl_stall_life & 0x1f) |
+ ((vl_stall_count << 5) & 0xe0));
+}
+
+/*
+* PARAMETERS
+* p_pi
+* [in] Pointer to a PortInfo attribute.
+*
+* vl_stall_count
+* [in] value to set
+*
+* RETURN VALUES
+* None.
+*
+* NOTES
+*
+* SEE ALSO
+*********/
+
+/****f* IBA Base: Types/ib_port_info_get_vl_stall_count
+* NAME
+* ib_port_info_get_vl_stall_count
+*
+* DESCRIPTION
+* Gets the VL Stall Count which define the number of contiguous
+* HLL (hoq) drops that will put the VL into stalled mode
+*
+* SYNOPSIS
+*/
+static inline uint8_t OSM_API
+ib_port_info_get_vl_stall_count(IN const ib_port_info_t * const p_pi)
+{
+ return ((uint8_t) (p_pi->vl_stall_life & 0xe0) >> 5);
+}
+
+/*
+* PARAMETERS
+* p_pi
+* [in] Pointer to a PortInfo attribute.
+*
+* RETURN VALUES
+* vl stall count
+*
+* NOTES
+*
+* SEE ALSO
+*********/
+
+/****f* IBA Base: Types/ib_port_info_get_lmc
+* NAME
+* ib_port_info_get_lmc
+*
+* DESCRIPTION
+* Returns the LMC value assigned to this port.
+*
+* SYNOPSIS
+*/
+static inline uint8_t OSM_API
+ib_port_info_get_lmc(IN const ib_port_info_t * const p_pi)
+{
+ return ((uint8_t) (p_pi->mkey_lmc & IB_PORT_LMC_MASK));
+}
+
+/*
+* PARAMETERS
+* p_pi
+* [in] Pointer to a PortInfo attribute.
+*
+* RETURN VALUES
+* Returns the LMC value assigned to this port.
+*
+* NOTES
+*
+* SEE ALSO
+*********/
+
+/****f* IBA Base: Types/ib_port_info_set_lmc
+* NAME
+* ib_port_info_set_lmc
+*
+* DESCRIPTION
+* Sets the LMC value in the PortInfo attribute.
+*
+* SYNOPSIS
+*/
+static inline void OSM_API
+ib_port_info_set_lmc(IN ib_port_info_t * const p_pi, IN const uint8_t lmc)
+{
+ CL_ASSERT(lmc <= IB_PORT_LMC_MAX);
+ p_pi->mkey_lmc = (uint8_t) ((p_pi->mkey_lmc & 0xF8) | lmc);
+}
+
+/*
+* PARAMETERS
+* p_pi
+* [in] Pointer to a PortInfo attribute.
+*
+* lmc
+* [in] LMC value to set, must be less than 7.
+*
+* RETURN VALUES
+* None.
+*
+* NOTES
+*
+* SEE ALSO
+*********/
+
+/****f* IBA Base: Types/ib_port_info_get_link_speed_enabled
+* NAME
+* ib_port_info_get_link_speed_enabled
+*
+* DESCRIPTION
+* Returns the link speed enabled value assigned to this port.
+*
+* SYNOPSIS
+*/
+static inline uint8_t OSM_API
+ib_port_info_get_link_speed_enabled(IN const ib_port_info_t * const p_pi)
+{
+ return ((uint8_t) (p_pi->link_speed & IB_PORT_LINK_SPEED_ENABLED_MASK));
+}
+
+/*
+* PARAMETERS
+* p_pi
+* [in] Pointer to a PortInfo attribute.
+*
+* RETURN VALUES
+* Port state.
+*
+* NOTES
+*
+* SEE ALSO
+*********/
+
+/****f* IBA Base: Types/ib_port_info_set_link_speed_enabled
+* NAME
+* ib_port_info_set_link_speed_enabled
+*
+* DESCRIPTION
+* Sets the link speed enabled value in the PortInfo attribute.
+*
+* SYNOPSIS
+*/
+static inline void OSM_API
+ib_port_info_set_link_speed_enabled(IN ib_port_info_t * const p_pi,
+ IN const uint8_t link_speed_enabled)
+{
+ p_pi->link_speed =
+ (uint8_t) ((p_pi->link_speed & 0xF0) | link_speed_enabled);
+}
+
+/*
+* PARAMETERS
+* p_pi
+* [in] Pointer to a PortInfo attribute.
+*
+* link_speed_enabled
+* [in] link speed enabled value to set.
+*
+* RETURN VALUES
+* None.
+*
+* NOTES
+*
+* SEE ALSO
+*********/
+
+/****f* IBA Base: Types/ib_port_info_get_mpb
+* NAME
+* ib_port_info_get_mpb
+*
+* DESCRIPTION
+* Returns the M_Key protect bits assigned to this port.
+*
+* SYNOPSIS
+*/
+static inline uint8_t OSM_API
+ib_port_info_get_mpb(IN const ib_port_info_t * const p_pi)
+{
+ return ((uint8_t) ((p_pi->mkey_lmc & IB_PORT_MPB_MASK) >>
+ IB_PORT_MPB_SHIFT));
+}
+
+/*
+* PARAMETERS
+* p_ni
+* [in] Pointer to a PortInfo attribute.
+*
+* RETURN VALUES
+* Returns the M_Key protect bits assigned to this port.
+*
+* NOTES
+*
+* SEE ALSO
+*********/
+
+/****f* IBA Base: Types/ib_port_info_set_mpb
+* NAME
+* ib_port_info_set_mpb
+*
+* DESCRIPTION
+* Set the M_Key protect bits of this port.
+*
+* SYNOPSIS
+*/
+static inline void OSM_API
+ib_port_info_set_mpb(IN ib_port_info_t * p_pi, IN uint8_t mpb)
+{
+ p_pi->mkey_lmc =
+ (~IB_PORT_MPB_MASK & p_pi->mkey_lmc) |
+ (IB_PORT_MPB_MASK & (mpb << IB_PORT_MPB_SHIFT));
+}
+
+/*
+* PARAMETERS
+* mpb
+* [in] M_Key protect bits
+* p_ni
+* [in] Pointer to a PortInfo attribute.
+*
+* RETURN VALUES
+*
+* NOTES
+*
+* SEE ALSO
+*********/
+
+/****f* IBA Base: Types/ib_port_info_get_local_phy_err_thd
+* NAME
+* ib_port_info_get_local_phy_err_thd
+*
+* DESCRIPTION
+* Returns the Phy Link Threshold
+*
+* SYNOPSIS
+*/
+static inline uint8_t OSM_API
+ib_port_info_get_local_phy_err_thd(IN const ib_port_info_t * const p_pi)
+{
+ return (uint8_t) ((p_pi->error_threshold & 0xF0) >> 4);
+}
+
+/*
+* PARAMETERS
+* p_pi
+* [in] Pointer to a PortInfo attribute.
+*
+* RETURN VALUES
+* Returns the Phy Link error threshold assigned to this port.
+*
+* NOTES
+*
+* SEE ALSO
+*********/
+
+/****f* IBA Base: Types/ib_port_info_get_overrun_err_thd
+* NAME
+* ib_port_info_get_local_overrun_err_thd
+*
+* DESCRIPTION
+* Returns the Credits Overrun Errors Threshold
+*
+* SYNOPSIS
+*/
+static inline uint8_t OSM_API
+ib_port_info_get_overrun_err_thd(IN const ib_port_info_t * const p_pi)
+{
+ return (uint8_t) (p_pi->error_threshold & 0x0F);
+}
+
+/*
+* PARAMETERS
+* p_pi
+* [in] Pointer to a PortInfo attribute.
+*
+* RETURN VALUES
+* Returns the Credits Overrun errors threshold assigned to this port.
+*
+* NOTES
+*
+* SEE ALSO
+*********/
+
+/****f* IBA Base: Types/ib_port_info_set_phy_and_overrun_err_thd
+* NAME
+* ib_port_info_set_phy_and_overrun_err_thd
+*
+* DESCRIPTION
+* Sets the Phy Link and Credits Overrun Errors Threshold
+*
+* SYNOPSIS
+*/
+static inline void OSM_API
+ib_port_info_set_phy_and_overrun_err_thd(IN ib_port_info_t * const p_pi,
+ IN uint8_t phy_threshold,
+ IN uint8_t overrun_threshold)
+{
+ p_pi->error_threshold =
+ (uint8_t) (((phy_threshold & 0x0F) << 4) |
+ (overrun_threshold & 0x0F));
+}
+
+/*
+* PARAMETERS
+* p_pi
+* [in] Pointer to a PortInfo attribute.
+*
+* phy_threshold
+* [in] Physical Link Errors Threshold above which Trap 129 is generated
+*
+* overrun_threshold
+* [in] Credits overrun Errors Threshold above which Trap 129 is generated
+*
+* RETURN VALUES
+* None.
+*
+* NOTES
+*
+* SEE ALSO
+*********/
+
+/****f* IBA Base: Types/ib_port_info_get_m_key
+* NAME
+* ib_port_info_get_m_key
+*
+* DESCRIPTION
+* Gets the M_Key
+*
+* SYNOPSIS
+*/
+static inline ib_net64_t OSM_API
+ib_port_info_get_m_key(IN const ib_port_info_t * const p_pi)
+{
+ return p_pi->m_key;
+}
+
+/*
+* PARAMETERS
+* p_pi
+* [in] Pointer to a PortInfo attribute.
+*
+* RETURN VALUES
+* M_Key.
+*
+* NOTES
+*
+* SEE ALSO
+*********/
+
+/****f* IBA Base: Types/ib_port_info_set_m_key
+* NAME
+* ib_port_info_set_m_key
+*
+* DESCRIPTION
+* Sets the M_Key value
+*
+* SYNOPSIS
+*/
+static inline void OSM_API
+ib_port_info_set_m_key(IN ib_port_info_t * const p_pi, IN ib_net64_t m_key)
+{
+ p_pi->m_key = m_key;
+}
+
+/*
+* PARAMETERS
+* p_pi
+* [in] Pointer to a PortInfo attribute.
+* m_key
+* [in] M_Key value.
+*
+* RETURN VALUES
+* None.
+*
+* NOTES
+*
+* SEE ALSO
+*********/
+
+
+/****s* IBA Base: Types/ib_mlnx_ext_port_info_t
+* NAME
+* ib_mlnx_ext_port_info_t
+*
+* DESCRIPTION
+* Mellanox ExtendedPortInfo (Vendor specific SM class attribute).
+*
+* SYNOPSIS
+*/
+#include <complib/cl_packon.h>
+typedef struct _ib_mlnx_ext_port_info {
+ uint8_t resvd1[3];
+ uint8_t state_change_enable;
+ uint8_t resvd2[3];
+ uint8_t link_speed_supported;
+ uint8_t resvd3[3];
+ uint8_t link_speed_enabled;
+ uint8_t resvd4[3];
+ uint8_t link_speed_active;
+ uint8_t resvd5[48];
+} PACK_SUFFIX ib_mlnx_ext_port_info_t;
+#include <complib/cl_packoff.h>
+/************/
+
+#define FDR10 0x01
+
+typedef uint8_t ib_svc_name_t[64];
+
+#include <complib/cl_packon.h>
+typedef struct _ib_service_record {
+ ib_net64_t service_id;
+ ib_gid_t service_gid;
+ ib_net16_t service_pkey;
+ ib_net16_t resv;
+ ib_net32_t service_lease;
+ uint8_t service_key[16];
+ ib_svc_name_t service_name;
+ uint8_t service_data8[16];
+ ib_net16_t service_data16[8];
+ ib_net32_t service_data32[4];
+ ib_net64_t service_data64[2];
+} PACK_SUFFIX ib_service_record_t;
+#include <complib/cl_packoff.h>
+
+#include <complib/cl_packon.h>
+typedef struct _ib_portinfo_record {
+ ib_net16_t lid;
+ uint8_t port_num;
+ uint8_t options;
+ ib_port_info_t port_info;
+ uint8_t pad[4];
+} PACK_SUFFIX ib_portinfo_record_t;
+#include <complib/cl_packoff.h>
+
+#include <complib/cl_packon.h>
+typedef struct _ib_portinfoext_record {
+ ib_net16_t lid;
+ uint8_t port_num;
+ uint8_t options;
+ ib_port_info_ext_t port_info_ext;
+} PACK_SUFFIX ib_portinfoext_record_t;
+#include <complib/cl_packoff.h>
+
+#include <complib/cl_packon.h>
+typedef struct _ib_link_record {
+ ib_net16_t from_lid;
+ uint8_t from_port_num;
+ uint8_t to_port_num;
+ ib_net16_t to_lid;
+ uint8_t pad[2];
+} PACK_SUFFIX ib_link_record_t;
+#include <complib/cl_packoff.h>
+
+#include <complib/cl_packon.h>
+typedef struct _ib_sminfo_record {
+ ib_net16_t lid;
+ uint16_t resv0;
+ ib_sm_info_t sm_info;
+ uint8_t pad[7];
+} PACK_SUFFIX ib_sminfo_record_t;
+#include <complib/cl_packoff.h>
+
+/****s* IBA Base: Types/ib_lft_record_t
+* NAME
+* ib_lft_record_t
+*
+* DESCRIPTION
+* IBA defined LinearForwardingTableRecord (15.2.5.6)
+*
+* SYNOPSIS
+*/
+#include <complib/cl_packon.h>
+typedef struct _ib_lft_record {
+ ib_net16_t lid;
+ ib_net16_t block_num;
+ uint32_t resv0;
+ uint8_t lft[64];
+} PACK_SUFFIX ib_lft_record_t;
+#include <complib/cl_packoff.h>
+/************/
+
+/****s* IBA Base: Types/ib_mft_record_t
+* NAME
+* ib_mft_record_t
+*
+* DESCRIPTION
+* IBA defined MulticastForwardingTableRecord (15.2.5.8)
+*
+* SYNOPSIS
+*/
+#include <complib/cl_packon.h>
+typedef struct _ib_mft_record {
+ ib_net16_t lid;
+ ib_net16_t position_block_num;
+ uint32_t resv0;
+ ib_net16_t mft[IB_MCAST_BLOCK_SIZE];
+} PACK_SUFFIX ib_mft_record_t;
+#include <complib/cl_packoff.h>
+/************/
+
+/****s* IBA Base: Types/ib_switch_info_t
+* NAME
+* ib_switch_info_t
+*
+* DESCRIPTION
+* IBA defined SwitchInfo. (14.2.5.4)
+*
+* SYNOPSIS
+*/
+#include <complib/cl_packon.h>
+typedef struct _ib_switch_info {
+ ib_net16_t lin_cap;
+ ib_net16_t rand_cap;
+ ib_net16_t mcast_cap;
+ ib_net16_t lin_top;
+ uint8_t def_port;
+ uint8_t def_mcast_pri_port;
+ uint8_t def_mcast_not_port;
+ uint8_t life_state;
+ ib_net16_t lids_per_port;
+ ib_net16_t enforce_cap;
+ uint8_t flags;
+ uint8_t resvd;
+ ib_net16_t mcast_top;
+} PACK_SUFFIX ib_switch_info_t;
+#include <complib/cl_packoff.h>
+/************/
+
+#include <complib/cl_packon.h>
+typedef struct _ib_switch_info_record {
+ ib_net16_t lid;
+ uint16_t resv0;
+ ib_switch_info_t switch_info;
+} PACK_SUFFIX ib_switch_info_record_t;
+#include <complib/cl_packoff.h>
+
+#define IB_SWITCH_PSC 0x04
+
+/****f* IBA Base: Types/ib_switch_info_get_state_change
+* NAME
+* ib_switch_info_get_state_change
+*
+* DESCRIPTION
+* Returns the value of the state change flag.
+*
+* SYNOPSIS
+*/
+static inline boolean_t OSM_API
+ib_switch_info_get_state_change(IN const ib_switch_info_t * const p_si)
+{
+ return ((p_si->life_state & IB_SWITCH_PSC) == IB_SWITCH_PSC);
+}
+
+/*
+* PARAMETERS
+* p_si
+* [in] Pointer to a SwitchInfo attribute.
+*
+* RETURN VALUES
+* Returns the value of the state change flag.
+*
+* NOTES
+*
+* SEE ALSO
+*********/
+
+/****f* IBA Base: Types/ib_switch_info_clear_state_change
+* NAME
+* ib_switch_info_clear_state_change
+*
+* DESCRIPTION
+* Clears the switch's state change bit.
+*
+* SYNOPSIS
+*/
+static inline void OSM_API
+ib_switch_info_clear_state_change(IN ib_switch_info_t * const p_si)
+{
+ p_si->life_state = (uint8_t) (p_si->life_state & 0xFB);
+}
+
+/*
+* PARAMETERS
+* p_si
+* [in] Pointer to a SwitchInfo attribute.
+*
+* RETURN VALUES
+* None
+*
+* NOTES
+*
+* SEE ALSO
+*********/
+
+/****f* IBA Base: Types/ib_switch_info_state_change_set
+* NAME
+* ib_switch_info_state_change_set
+*
+* DESCRIPTION
+* Clears the switch's state change bit.
+*
+* SYNOPSIS
+*/
+static inline void OSM_API
+ib_switch_info_state_change_set(IN ib_switch_info_t * const p_si)
+{
+ p_si->life_state = (uint8_t) ((p_si->life_state & ~IB_SWITCH_PSC) | IB_SWITCH_PSC);
+}
+
+/*
+* PARAMETERS
+* p_si
+* [in] Pointer to a SwitchInfo attribute.
+*
+* RETURN VALUES
+* None
+*
+* NOTES
+*
+* SEE ALSO
+*********/
+
+/****f* IBA Base: Types/ib_switch_info_get_opt_sl2vlmapping
+* NAME
+* ib_switch_info_get_state_opt_sl2vlmapping
+*
+* DESCRIPTION
+* Returns the value of the optimized SLtoVLMapping programming flag.
+*
+* SYNOPSIS
+*/
+static inline boolean_t OSM_API
+ib_switch_info_get_opt_sl2vlmapping(IN const ib_switch_info_t * const p_si)
+{
+ return ((p_si->life_state & 0x01) == 0x01);
+}
+
+/*
+* PARAMETERS
+* p_si
+* [in] Pointer to a SwitchInfo attribute.
+*
+* RETURN VALUES
+* Returns the value of the optimized SLtoVLMapping programming flag.
+*
+* NOTES
+*
+* SEE ALSO
+*********/
+
+/****f* IBA Base: Types/ib_switch_info_set_life_time
+* NAME
+* ib_switch_info_set_life_time
+*
+* DESCRIPTION
+* Sets the value of LifeTimeValue.
+*
+* SYNOPSIS
+*/
+static inline void OSM_API
+ib_switch_info_set_life_time(IN ib_switch_info_t * const p_si,
+ IN const uint8_t life_time_val)
+{
+ p_si->life_state = (p_si->life_state & 0x1f) |
+ (life_time_val << 3);
+}
+
+/*
+* PARAMETERS
+* p_si
+* [in] Pointer to a SwitchInfo attribute.
+* life_time_val
+* [in] LiveTimeValue.
+*
+* RETURN VALUES
+* None.
+*
+* NOTES
+*
+* SEE ALSO
+*********/
+
+/****f* IBA Base: Types/ib_switch_info_is_enhanced_port0
+* NAME
+* ib_switch_info_is_enhanced_port0
+*
+* DESCRIPTION
+* Returns TRUE if the enhancedPort0 bit is on (meaning the switch
+* port zero supports enhanced functions).
+* Returns FALSE otherwise.
+*
+* SYNOPSIS
+*/
+static inline boolean_t OSM_API
+ib_switch_info_is_enhanced_port0(IN const ib_switch_info_t * const p_si)
+{
+ return ((p_si->flags & 0x08) == 0x08);
+}
+
+/*
+* PARAMETERS
+* p_si
+* [in] Pointer to a SwitchInfo attribute.
+*
+* RETURN VALUES
+* Returns TRUE if the switch supports enhanced port 0. FALSE otherwise.
+*
+* NOTES
+*
+* SEE ALSO
+*********/
+
+/****s* IBA Base: Types/ib_guid_info_t
+* NAME
+* ib_guid_info_t
+*
+* DESCRIPTION
+* IBA defined GuidInfo. (14.2.5.5)
+*
+* SYNOPSIS
+*/
+#define GUID_TABLE_MAX_ENTRIES 8
+
+#include <complib/cl_packon.h>
+typedef struct _ib_guid_info {
+ ib_net64_t guid[GUID_TABLE_MAX_ENTRIES];
+} PACK_SUFFIX ib_guid_info_t;
+#include <complib/cl_packoff.h>
+/************/
+
+#include <complib/cl_packon.h>
+typedef struct _ib_guidinfo_record {
+ ib_net16_t lid;
+ uint8_t block_num;
+ uint8_t resv;
+ uint32_t reserved;
+ ib_guid_info_t guid_info;
+} PACK_SUFFIX ib_guidinfo_record_t;
+#include <complib/cl_packoff.h>
+
+#define IB_MULTIPATH_MAX_GIDS 11 /* Support max that can fit into first MAD (for now) */
+
+#include <complib/cl_packon.h>
+typedef struct _ib_multipath_rec_t {
+ ib_net32_t hop_flow_raw;
+ uint8_t tclass;
+ uint8_t num_path;
+ ib_net16_t pkey;
+ ib_net16_t qos_class_sl;
+ uint8_t mtu;
+ uint8_t rate;
+ uint8_t pkt_life;
+ uint8_t service_id_8msb;
+ uint8_t independence; /* formerly resv2 */
+ uint8_t sgid_count;
+ uint8_t dgid_count;
+ uint8_t service_id_56lsb[7];
+ ib_gid_t gids[IB_MULTIPATH_MAX_GIDS];
+} PACK_SUFFIX ib_multipath_rec_t;
+#include <complib/cl_packoff.h>
+/*
+* FIELDS
+* hop_flow_raw
+* Global routing parameters: hop count, flow label and raw bit.
+*
+* tclass
+* Another global routing parameter.
+*
+* num_path
+* Reversible path - 1 bit to say if path is reversible.
+* num_path [6:0] In queries, maximum number of paths to return.
+* In responses, undefined.
+*
+* pkey
+* Partition key (P_Key) to use on this path.
+*
+* qos_class_sl
+* QoS class and service level to use on this path.
+*
+* mtu
+* MTU and MTU selector fields to use on this path
+* rate
+* Rate and rate selector fields to use on this path.
+*
+* pkt_life
+* Packet lifetime
+*
+* service_id_8msb
+* 8 most significant bits of Service ID
+*
+* service_id_56lsb
+* 56 least significant bits of Service ID
+*
+* preference
+* Indicates the relative merit of this path versus other path
+* records returned from the SA. Lower numbers are better.
+*
+* SEE ALSO
+*********/
+
+/****f* IBA Base: Types/ib_multipath_rec_num_path
+* NAME
+* ib_multipath_rec_num_path
+*
+* DESCRIPTION
+* Get max number of paths to return.
+*
+* SYNOPSIS
+*/
+static inline uint8_t OSM_API
+ib_multipath_rec_num_path(IN const ib_multipath_rec_t * const p_rec)
+{
+ return (p_rec->num_path & 0x7F);
+}
+
+/*
+* PARAMETERS
+* p_rec
+* [in] Pointer to the multipath record object.
+*
+* RETURN VALUES
+* Maximum number of paths to return for each unique SGID_DGID combination.
+*
+* NOTES
+*
+* SEE ALSO
+* ib_multipath_rec_t
+*********/
+
+/****f* IBA Base: Types/ib_multipath_rec_set_sl
+* NAME
+* ib_multipath_rec_set_sl
+*
+* DESCRIPTION
+* Set path service level.
+*
+* SYNOPSIS
+*/
+static inline void OSM_API
+ib_multipath_rec_set_sl(
+ IN ib_multipath_rec_t* const p_rec,
+ IN const uint8_t sl )
+{
+ p_rec->qos_class_sl =
+ (p_rec->qos_class_sl & CL_HTON16(IB_MULTIPATH_REC_QOS_CLASS_MASK)) |
+ cl_hton16(sl & IB_MULTIPATH_REC_SL_MASK);
+}
+/*
+* PARAMETERS
+* p_rec
+* [in] Pointer to the MultiPath record object.
+*
+* sl
+* [in] Service level to set.
+*
+* RETURN VALUES
+* None
+*
+* NOTES
+*
+* SEE ALSO
+* ib_multipath_rec_t
+*********/
+
+/****f* IBA Base: Types/ib_multipath_rec_sl
+* NAME
+* ib_multipath_rec_sl
+*
+* DESCRIPTION
+* Get multipath service level.
+*
+* SYNOPSIS
+*/
+static inline uint8_t OSM_API
+ib_multipath_rec_sl(IN const ib_multipath_rec_t * const p_rec)
+{
+ return ((uint8_t) ((cl_ntoh16(p_rec->qos_class_sl)) & IB_MULTIPATH_REC_SL_MASK));
+}
+
+/*
+* PARAMETERS
+* p_rec
+* [in] Pointer to the multipath record object.
+*
+* RETURN VALUES
+* SL.
+*
+* NOTES
+*
+* SEE ALSO
+* ib_multipath_rec_t
+*********/
+
+/****f* IBA Base: Types/ib_multipath_rec_set_qos_class
+* NAME
+* ib_multipath_rec_set_qos_class
+*
+* DESCRIPTION
+* Set path QoS class.
+*
+* SYNOPSIS
+*/
+static inline void OSM_API
+ib_multipath_rec_set_qos_class(
+ IN ib_multipath_rec_t* const p_rec,
+ IN const uint16_t qos_class )
+{
+ p_rec->qos_class_sl =
+ (p_rec->qos_class_sl & CL_HTON16(IB_MULTIPATH_REC_SL_MASK)) |
+ cl_hton16(qos_class << 4);
+}
+/*
+* PARAMETERS
+* p_rec
+* [in] Pointer to the MultiPath record object.
+*
+* qos_class
+* [in] QoS class to set.
+*
+* RETURN VALUES
+* None
+*
+* NOTES
+*
+* SEE ALSO
+* ib_multipath_rec_t
+*********/
+
+/****f* IBA Base: Types/ib_multipath_rec_qos_class
+* NAME
+* ib_multipath_rec_qos_class
+*
+* DESCRIPTION
+* Get QoS class.
+*
+* SYNOPSIS
+*/
+static inline uint16_t OSM_API
+ib_multipath_rec_qos_class(
+ IN const ib_multipath_rec_t* const p_rec )
+{
+ return (cl_ntoh16( p_rec->qos_class_sl ) >> 4);
+}
+/*
+* PARAMETERS
+* p_rec
+* [in] Pointer to the MultiPath record object.
+*
+* RETURN VALUES
+* QoS class of the MultiPath record.
+*
+* NOTES
+*
+* SEE ALSO
+* ib_multipath_rec_t
+*********/
+
+/****f* IBA Base: Types/ib_multipath_rec_mtu
+* NAME
+* ib_multipath_rec_mtu
+*
+* DESCRIPTION
+* Get encoded path MTU.
+*
+* SYNOPSIS
+*/
+static inline uint8_t OSM_API
+ib_multipath_rec_mtu(IN const ib_multipath_rec_t * const p_rec)
+{
+ return ((uint8_t) (p_rec->mtu & IB_MULTIPATH_REC_BASE_MASK));
+}
+
+/*
+* PARAMETERS
+* p_rec
+* [in] Pointer to the multipath record object.
+*
+* RETURN VALUES
+* Encoded path MTU.
+* 1: 256
+* 2: 512
+* 3: 1024
+* 4: 2048
+* 5: 4096
+* others: reserved
+*
+* NOTES
+*
+* SEE ALSO
+* ib_multipath_rec_t
+*********/
+
+/****f* IBA Base: Types/ib_multipath_rec_mtu_sel
+* NAME
+* ib_multipath_rec_mtu_sel
+*
+* DESCRIPTION
+* Get encoded multipath MTU selector.
+*
+* SYNOPSIS
+*/
+static inline uint8_t OSM_API
+ib_multipath_rec_mtu_sel(IN const ib_multipath_rec_t * const p_rec)
+{
+ return ((uint8_t) ((p_rec->mtu & IB_MULTIPATH_REC_SELECTOR_MASK) >> 6));
+}
+
+/*
+* PARAMETERS
+* p_rec
+* [in] Pointer to the multipath record object.
+*
+* RETURN VALUES
+* Encoded path MTU selector value (for queries).
+* 0: greater than MTU specified
+* 1: less than MTU specified
+* 2: exactly the MTU specified
+* 3: largest MTU available
+*
+* NOTES
+*
+* SEE ALSO
+* ib_multipath_rec_t
+*********/
+
+/****f* IBA Base: Types/ib_multipath_rec_rate
+* NAME
+* ib_multipath_rec_rate
+*
+* DESCRIPTION
+* Get encoded multipath rate.
+*
+* SYNOPSIS
+*/
+static inline uint8_t OSM_API
+ib_multipath_rec_rate(IN const ib_multipath_rec_t * const p_rec)
+{
+ return ((uint8_t) (p_rec->rate & IB_MULTIPATH_REC_BASE_MASK));
+}
+
+/*
+* PARAMETERS
+* p_rec
+* [in] Pointer to the multipath record object.
+*
+* RETURN VALUES
+* Encoded multipath rate.
+* 2: 2.5 Gb/sec.
+* 3: 10 Gb/sec.
+* 4: 30 Gb/sec.
+* 5: 5 Gb/sec.
+* 6: 20 Gb/sec.
+* 7: 40 Gb/sec.
+* 8: 60 Gb/sec.
+* 9: 80 Gb/sec.
+* 10: 120 Gb/sec.
+* 11: 14 Gb/sec.
+* 12: 56 Gb/sec.
+* 13: 112 Gb/sec.
+* 14: 168 Gb/sec.
+* 15: 25 Gb/sec.
+* 16: 100 Gb/sec.
+* 17: 200 Gb/sec.
+* 18: 300 Gb/sec.
+* others: reserved
+*
+* NOTES
+*
+* SEE ALSO
+* ib_multipath_rec_t
+*********/
+
+/****f* IBA Base: Types/ib_multipath_rec_rate_sel
+* NAME
+* ib_multipath_rec_rate_sel
+*
+* DESCRIPTION
+* Get encoded multipath rate selector.
+*
+* SYNOPSIS
+*/
+static inline uint8_t OSM_API
+ib_multipath_rec_rate_sel(IN const ib_multipath_rec_t * const p_rec)
+{
+ return ((uint8_t)
+ ((p_rec->rate & IB_MULTIPATH_REC_SELECTOR_MASK) >> 6));
+}
+
+/*
+* PARAMETERS
+* p_rec
+* [in] Pointer to the multipath record object.
+*
+* RETURN VALUES
+* Encoded path rate selector value (for queries).
+* 0: greater than rate specified
+* 1: less than rate specified
+* 2: exactly the rate specified
+* 3: largest rate available
+*
+* NOTES
+*
+* SEE ALSO
+* ib_multipath_rec_t
+*********/
+
+/****f* IBA Base: Types/ib_multipath_rec_pkt_life
+* NAME
+* ib_multipath_rec_pkt_life
+*
+* DESCRIPTION
+* Get encoded multipath pkt_life.
+*
+* SYNOPSIS
+*/
+static inline uint8_t OSM_API
+ib_multipath_rec_pkt_life(IN const ib_multipath_rec_t * const p_rec)
+{
+ return ((uint8_t) (p_rec->pkt_life & IB_MULTIPATH_REC_BASE_MASK));
+}
+
+/*
+* PARAMETERS
+* p_rec
+* [in] Pointer to the multipath record object.
+*
+* RETURN VALUES
+* Encoded multipath pkt_life = 4.096 usec * 2 ** PacketLifeTime.
+*
+* NOTES
+*
+* SEE ALSO
+* ib_multipath_rec_t
+*********/
+
+/****f* IBA Base: Types/ib_multipath_rec_pkt_life_sel
+* NAME
+* ib_multipath_rec_pkt_life_sel
+*
+* DESCRIPTION
+* Get encoded multipath pkt_lifetime selector.
+*
+* SYNOPSIS
+*/
+static inline uint8_t OSM_API
+ib_multipath_rec_pkt_life_sel(IN const ib_multipath_rec_t * const p_rec)
+{
+ return ((uint8_t)
+ ((p_rec->pkt_life & IB_MULTIPATH_REC_SELECTOR_MASK) >> 6));
+}
+
+/*
+* PARAMETERS
+* p_rec
+* [in] Pointer to the multipath record object.
+*
+* RETURN VALUES
+* Encoded path pkt_lifetime selector value (for queries).
+* 0: greater than rate specified
+* 1: less than rate specified
+* 2: exactly the rate specified
+* 3: smallest packet lifetime available
+*
+* NOTES
+*
+* SEE ALSO
+* ib_multipath_rec_t
+*********/
+
+/****f* IBA Base: Types/ib_multipath_rec_service_id
+* NAME
+* ib_multipath_rec_service_id
+*
+* DESCRIPTION
+* Get multipath service id.
+*
+* SYNOPSIS
+*/
+static inline ib_net64_t OSM_API
+ib_multipath_rec_service_id(IN const ib_multipath_rec_t * const p_rec)
+{
+ union {
+ ib_net64_t sid;
+ uint8_t sid_arr[8];
+ } sid_union;
+ sid_union.sid_arr[0] = p_rec->service_id_8msb;
+ memcpy(&sid_union.sid_arr[1], p_rec->service_id_56lsb, 7);
+ return sid_union.sid;
+}
+
+/*
+* PARAMETERS
+* p_rec
+* [in] Pointer to the multipath record object.
+*
+* RETURN VALUES
+* Service ID
+*
+* NOTES
+*
+* SEE ALSO
+* ib_multipath_rec_t
+*********/
+
+#define IB_NUM_PKEY_ELEMENTS_IN_BLOCK 32
+/****s* IBA Base: Types/ib_pkey_table_t
+* NAME
+* ib_pkey_table_t
+*
+* DESCRIPTION
+* IBA defined PKey table. (14.2.5.7)
+*
+* SYNOPSIS
+*/
+
+#include <complib/cl_packon.h>
+typedef struct _ib_pkey_table {
+ ib_net16_t pkey_entry[IB_NUM_PKEY_ELEMENTS_IN_BLOCK];
+} PACK_SUFFIX ib_pkey_table_t;
+#include <complib/cl_packoff.h>
+/************/
+
+/****s* IBA Base: Types/ib_pkey_table_record_t
+* NAME
+* ib_pkey_table_record_t
+*
+* DESCRIPTION
+* IBA defined P_Key Table Record for SA Query. (15.2.5.11)
+*
+* SYNOPSIS
+*/
+#include <complib/cl_packon.h>
+typedef struct _ib_pkey_table_record {
+ ib_net16_t lid; // for CA: lid of port, for switch lid of port 0
+ ib_net16_t block_num;
+ uint8_t port_num; // for switch: port number, for CA: reserved
+ uint8_t reserved1;
+ uint16_t reserved2;
+ ib_pkey_table_t pkey_tbl;
+} PACK_SUFFIX ib_pkey_table_record_t;
+#include <complib/cl_packoff.h>
+/************/
+
+#define IB_DROP_VL 15
+#define IB_MAX_NUM_VLS 16
+/****s* IBA Base: Types/ib_slvl_table_t
+* NAME
+* ib_slvl_table_t
+*
+* DESCRIPTION
+* IBA defined SL2VL Mapping Table Attribute. (14.2.5.8)
+*
+* SYNOPSIS
+*/
+#include <complib/cl_packon.h>
+typedef struct _ib_slvl_table {
+ uint8_t raw_vl_by_sl[IB_MAX_NUM_VLS / 2];
+} PACK_SUFFIX ib_slvl_table_t;
+#include <complib/cl_packoff.h>
+/************/
+
+/****s* IBA Base: Types/ib_slvl_table_record_t
+* NAME
+* ib_slvl_table_record_t
+*
+* DESCRIPTION
+* IBA defined SL to VL Mapping Table Record for SA Query. (15.2.5.4)
+*
+* SYNOPSIS
+*/
+#include <complib/cl_packon.h>
+typedef struct _ib_slvl_table_record {
+ ib_net16_t lid; // for CA: lid of port, for switch lid of port 0
+ uint8_t in_port_num; // reserved for CAs
+ uint8_t out_port_num; // reserved for CAs
+ uint32_t resv;
+ ib_slvl_table_t slvl_tbl;
+} PACK_SUFFIX ib_slvl_table_record_t;
+#include <complib/cl_packoff.h>
+/************/
+
+/****f* IBA Base: Types/ib_slvl_table_set
+* NAME
+* ib_slvl_table_set
+*
+* DESCRIPTION
+* Set slvl table entry.
+*
+* SYNOPSIS
+*/
+static inline void OSM_API
+ib_slvl_table_set(IN ib_slvl_table_t * p_slvl_tbl,
+ IN uint8_t sl_index, IN uint8_t vl)
+{
+ uint8_t idx = sl_index / 2;
+ CL_ASSERT(vl <= 15);
+ CL_ASSERT(sl_index <= 15);
+
+ if (sl_index % 2)
+ /* this is an odd sl. Need to update the ls bits */
+ p_slvl_tbl->raw_vl_by_sl[idx] =
+ (p_slvl_tbl->raw_vl_by_sl[idx] & 0xF0) | vl;
+ else
+ /* this is an even sl. Need to update the ms bits */
+ p_slvl_tbl->raw_vl_by_sl[idx] =
+ (vl << 4) | (p_slvl_tbl->raw_vl_by_sl[idx] & 0x0F);
+}
+
+/*
+* PARAMETERS
+* p_slvl_tbl
+* [in] pointer to ib_slvl_table_t object.
+*
+* sl_index
+* [in] the sl index in the table to be updated.
+*
+* vl
+* [in] the vl value to update for that sl.
+*
+* RETURN VALUES
+* None
+*
+* NOTES
+*
+* SEE ALSO
+* ib_slvl_table_t
+*********/
+
+/****f* IBA Base: Types/ib_slvl_table_get
+* NAME
+* ib_slvl_table_get
+*
+* DESCRIPTION
+* Get slvl table entry.
+*
+* SYNOPSIS
+*/
+static inline uint8_t OSM_API
+ib_slvl_table_get(IN const ib_slvl_table_t * p_slvl_tbl, IN uint8_t sl_index)
+{
+ uint8_t idx = sl_index / 2;
+ CL_ASSERT(sl_index <= 15);
+
+ if (sl_index % 2)
+ /* this is an odd sl. Need to return the ls bits. */
+ return (p_slvl_tbl->raw_vl_by_sl[idx] & 0x0F);
+ else
+ /* this is an even sl. Need to return the ms bits. */
+ return ((p_slvl_tbl->raw_vl_by_sl[idx] & 0xF0) >> 4);
+}
+
+/*
+* PARAMETERS
+* p_slvl_tbl
+* [in] pointer to ib_slvl_table_t object.
+*
+* sl_index
+* [in] the sl index in the table whose value should be returned.
+*
+* RETURN VALUES
+* vl for the requested sl_index.
+*
+* NOTES
+*
+* SEE ALSO
+* ib_slvl_table_t
+*********/
+
+/****s* IBA Base: Types/ib_vl_arb_element_t
+* NAME
+* ib_vl_arb_element_t
+*
+* DESCRIPTION
+* IBA defined VL Arbitration Table Element. (14.2.5.9)
+*
+* SYNOPSIS
+*/
+#include <complib/cl_packon.h>
+typedef struct _ib_vl_arb_element {
+ uint8_t vl;
+ uint8_t weight;
+} PACK_SUFFIX ib_vl_arb_element_t;
+#include <complib/cl_packoff.h>
+/************/
+
+#define IB_NUM_VL_ARB_ELEMENTS_IN_BLOCK 32
+
+/****s* IBA Base: Types/ib_vl_arb_table_t
+* NAME
+* ib_vl_arb_table_t
+*
+* DESCRIPTION
+* IBA defined VL Arbitration Table. (14.2.5.9)
+*
+* SYNOPSIS
+*/
+#include <complib/cl_packon.h>
+typedef struct _ib_vl_arb_table {
+ ib_vl_arb_element_t vl_entry[IB_NUM_VL_ARB_ELEMENTS_IN_BLOCK];
+} PACK_SUFFIX ib_vl_arb_table_t;
+#include <complib/cl_packoff.h>
+/************/
+
+/****s* IBA Base: Types/ib_vl_arb_table_record_t
+* NAME
+* ib_vl_arb_table_record_t
+*
+* DESCRIPTION
+* IBA defined VL Arbitration Table Record for SA Query. (15.2.5.9)
+*
+* SYNOPSIS
+*/
+#include <complib/cl_packon.h>
+typedef struct _ib_vl_arb_table_record {
+ ib_net16_t lid; // for CA: lid of port, for switch lid of port 0
+ uint8_t port_num;
+ uint8_t block_num;
+ uint32_t reserved;
+ ib_vl_arb_table_t vl_arb_tbl;
+} PACK_SUFFIX ib_vl_arb_table_record_t;
+#include <complib/cl_packoff.h>
+/************/
+
+/*
+ * Global route header information received with unreliable datagram messages
+ */
+#include <complib/cl_packon.h>
+typedef struct _ib_grh {
+ ib_net32_t ver_class_flow;
+ ib_net16_t resv1;
+ uint8_t resv2;
+ uint8_t hop_limit;
+ ib_gid_t src_gid;
+ ib_gid_t dest_gid;
+} PACK_SUFFIX ib_grh_t;
+#include <complib/cl_packoff.h>
+
+/****f* IBA Base: Types/ib_grh_get_ver_class_flow
+* NAME
+* ib_grh_get_ver_class_flow
+*
+* DESCRIPTION
+* Get encoded version, traffic class and flow label in grh
+*
+* SYNOPSIS
+*/
+static inline void OSM_API
+ib_grh_get_ver_class_flow(IN const ib_net32_t ver_class_flow,
+ OUT uint8_t * const p_ver,
+ OUT uint8_t * const p_tclass,
+ OUT uint32_t * const p_flow_lbl)
+{
+ ib_net32_t tmp_ver_class_flow;
+
+ if (p_ver)
+ *p_ver = (uint8_t) (ver_class_flow & 0x0f);
+
+ tmp_ver_class_flow = ver_class_flow >> 4;
+
+ if (p_tclass)
+ *p_tclass = (uint8_t) (tmp_ver_class_flow & 0xff);
+
+ tmp_ver_class_flow = tmp_ver_class_flow >> 8;
+
+ if (p_flow_lbl)
+ *p_flow_lbl = tmp_ver_class_flow & 0xfffff;
+}
+
+/*
+* PARAMETERS
+* ver_class_flow
+* [in] the version, traffic class and flow label info.
+*
+* RETURN VALUES
+* p_ver
+* [out] pointer to the version info.
+*
+* p_tclass
+* [out] pointer to the traffic class info.
+*
+* p_flow_lbl
+* [out] pointer to the flow label info
+*
+* NOTES
+*
+* SEE ALSO
+* ib_grh_t
+*********/
+
+/****f* IBA Base: Types/ib_grh_set_ver_class_flow
+* NAME
+* ib_grh_set_ver_class_flow
+*
+* DESCRIPTION
+* Set encoded version, traffic class and flow label in grh
+*
+* SYNOPSIS
+*/
+static inline ib_net32_t OSM_API
+ib_grh_set_ver_class_flow(IN const uint8_t ver,
+ IN const uint8_t tclass, IN const uint32_t flow_lbl)
+{
+ ib_net32_t ver_class_flow;
+
+ ver_class_flow = flow_lbl;
+ ver_class_flow = ver_class_flow << 8;
+ ver_class_flow = ver_class_flow | tclass;
+ ver_class_flow = ver_class_flow << 4;
+ ver_class_flow = ver_class_flow | ver;
+ return (ver_class_flow);
+}
+
+/*
+* PARAMETERS
+* ver
+* [in] the version info.
+*
+* tclass
+* [in] the traffic class info.
+*
+* flow_lbl
+* [in] the flow label info
+*
+* RETURN VALUES
+* ver_class_flow
+* [out] the version, traffic class and flow label info.
+*
+* NOTES
+*
+* SEE ALSO
+* ib_grh_t
+*********/
+
+/****s* IBA Base: Types/ib_member_rec_t
+* NAME
+* ib_member_rec_t
+*
+* DESCRIPTION
+* Multicast member record, used to create, join, and leave multicast
+* groups.
+*
+* SYNOPSIS
+*/
+#include <complib/cl_packon.h>
+typedef struct _ib_member_rec {
+ ib_gid_t mgid;
+ ib_gid_t port_gid;
+ ib_net32_t qkey;
+ ib_net16_t mlid;
+ uint8_t mtu;
+ uint8_t tclass;
+ ib_net16_t pkey;
+ uint8_t rate;
+ uint8_t pkt_life;
+ ib_net32_t sl_flow_hop;
+ uint8_t scope_state;
+ uint8_t proxy_join:1;
+ uint8_t reserved[2];
+ uint8_t pad[4];
+} PACK_SUFFIX ib_member_rec_t;
+#include <complib/cl_packoff.h>
+/*
+* FIELDS
+* mgid
+* Multicast GID address for this multicast group.
+*
+* port_gid
+* Valid GID of the endpoint joining this multicast group.
+*
+* qkey
+* Q_Key to be sued by this multicast group.
+*
+* mlid
+* Multicast LID for this multicast group.
+*
+* mtu
+* MTU and MTU selector fields to use on this path
+*
+* tclass
+* Another global routing parameter.
+*
+* pkey
+* Partition key (P_Key) to use for this member.
+*
+* rate
+* Rate and rate selector fields to use on this path.
+*
+* pkt_life
+* Packet lifetime
+*
+* sl_flow_hop
+* Global routing parameters: service level, hop count, and flow label.
+*
+* scope_state
+* MGID scope and JoinState of multicast request.
+*
+* proxy_join
+* Enables others in the Partition to proxy add/remove from the group
+*
+* SEE ALSO
+*********/
+
+/****f* IBA Base: Types/ib_member_get_sl_flow_hop
+* NAME
+* ib_member_get_sl_flow_hop
+*
+* DESCRIPTION
+* Get encoded sl, flow label, and hop limit
+*
+* SYNOPSIS
+*/
+static inline void OSM_API
+ib_member_get_sl_flow_hop(IN const ib_net32_t sl_flow_hop,
+ OUT uint8_t * const p_sl,
+ OUT uint32_t * const p_flow_lbl,
+ OUT uint8_t * const p_hop)
+{
+ uint32_t tmp;
+
+ tmp = cl_ntoh32(sl_flow_hop);
+ if (p_hop)
+ *p_hop = (uint8_t) tmp;
+ tmp >>= 8;
+
+ if (p_flow_lbl)
+ *p_flow_lbl = (uint32_t) (tmp & 0xfffff);
+ tmp >>= 20;
+
+ if (p_sl)
+ *p_sl = (uint8_t) tmp;
+}
+
+/*
+* PARAMETERS
+* sl_flow_hop
+* [in] the sl, flow label, and hop limit of MC Group
+*
+* RETURN VALUES
+* p_sl
+* [out] pointer to the service level
+*
+* p_flow_lbl
+* [out] pointer to the flow label info
+*
+* p_hop
+* [out] pointer to the hop count limit.
+*
+* NOTES
+*
+* SEE ALSO
+* ib_member_rec_t
+*********/
+
+/****f* IBA Base: Types/ib_member_set_sl_flow_hop
+* NAME
+* ib_member_set_sl_flow_hop
+*
+* DESCRIPTION
+* Set encoded sl, flow label, and hop limit
+*
+* SYNOPSIS
+*/
+static inline ib_net32_t OSM_API
+ib_member_set_sl_flow_hop(IN const uint8_t sl,
+ IN const uint32_t flow_label,
+ IN const uint8_t hop_limit)
+{
+ uint32_t tmp;
+
+ tmp = (sl << 28) | ((flow_label & 0xfffff) << 8) | hop_limit;
+ return cl_hton32(tmp);
+}
+
+/*
+* PARAMETERS
+* sl
+* [in] the service level.
+*
+* flow_lbl
+* [in] the flow label info
+*
+* hop_limit
+* [in] the hop limit.
+*
+* RETURN VALUES
+* sl_flow_hop
+* [out] the encoded sl, flow label, and hop limit
+*
+* NOTES
+*
+* SEE ALSO
+* ib_member_rec_t
+*********/
+
+/****f* IBA Base: Types/ib_member_get_scope_state
+* NAME
+* ib_member_get_scope_state
+*
+* DESCRIPTION
+* Get encoded MGID scope and JoinState
+*
+* SYNOPSIS
+*/
+static inline void OSM_API
+ib_member_get_scope_state(IN const uint8_t scope_state,
+ OUT uint8_t * const p_scope,
+ OUT uint8_t * const p_state)
+{
+ uint8_t tmp_scope_state;
+
+ if (p_state)
+ *p_state = (uint8_t) (scope_state & 0x0f);
+
+ tmp_scope_state = scope_state >> 4;
+
+ if (p_scope)
+ *p_scope = (uint8_t) (tmp_scope_state & 0x0f);
+
+}
+
+/*
+* PARAMETERS
+* scope_state
+* [in] the scope and state
+*
+* RETURN VALUES
+* p_scope
+* [out] pointer to the MGID scope
+*
+* p_state
+* [out] pointer to the join state
+*
+* NOTES
+*
+* SEE ALSO
+* ib_member_rec_t
+*********/
+
+/****f* IBA Base: Types/ib_member_set_scope_state
+* NAME
+* ib_member_set_scope_state
+*
+* DESCRIPTION
+* Set encoded version, MGID scope and JoinState
+*
+* SYNOPSIS
+*/
+static inline uint8_t OSM_API
+ib_member_set_scope_state(IN const uint8_t scope, IN const uint8_t state)
+{
+ uint8_t scope_state;
+
+ scope_state = scope;
+ scope_state = scope_state << 4;
+ scope_state = scope_state | state;
+ return (scope_state);
+}
+
+/*
+* PARAMETERS
+* scope
+* [in] the MGID scope
+*
+* state
+* [in] the JoinState
+*
+* RETURN VALUES
+* scope_state
+* [out] the encoded one
+*
+* NOTES
+*
+* SEE ALSO
+* ib_member_rec_t
+*********/
+
+/****f* IBA Base: Types/ib_member_set_join_state
+* NAME
+* ib_member_set_join_state
+*
+* DESCRIPTION
+* Set JoinState
+*
+* SYNOPSIS
+*/
+static inline void OSM_API
+ib_member_set_join_state(IN OUT ib_member_rec_t * p_mc_rec,
+ IN const uint8_t state)
+{
+ /* keep the scope as it is */
+ p_mc_rec->scope_state = (p_mc_rec->scope_state & 0xF0) | (0x0f & state);
+}
+
+/*
+* PARAMETERS
+* p_mc_rec
+* [in] pointer to the member record
+*
+* state
+* [in] the JoinState
+*
+* RETURN VALUES
+* NONE
+*
+* NOTES
+*
+* SEE ALSO
+* ib_member_rec_t
+*********/
+
+/*
+ * Join State Codes:
+ */
+#define IB_MC_REC_STATE_FULL_MEMBER 0x01
+#define IB_MC_REC_STATE_NON_MEMBER 0x02
+#define IB_MC_REC_STATE_SEND_ONLY_NON_MEMBER 0x04
+
+/*
+ * Generic MAD notice types
+ */
+#define IB_NOTICE_TYPE_FATAL 0x00
+#define IB_NOTICE_TYPE_URGENT 0x01
+#define IB_NOTICE_TYPE_SECURITY 0x02
+#define IB_NOTICE_TYPE_SUBN_MGMT 0x03
+#define IB_NOTICE_TYPE_INFO 0x04
+#define IB_NOTICE_TYPE_EMPTY 0x7F
+
+#define SM_GID_IN_SERVICE_TRAP 64
+#define SM_GID_OUT_OF_SERVICE_TRAP 65
+#define SM_MGID_CREATED_TRAP 66
+#define SM_MGID_DESTROYED_TRAP 67
+#define SM_UNPATH_TRAP 68
+#define SM_REPATH_TRAP 69
+#define SM_LINK_STATE_CHANGED_TRAP 128
+#define SM_LINK_INTEGRITY_THRESHOLD_TRAP 129
+#define SM_BUFFER_OVERRUN_THRESHOLD_TRAP 130
+#define SM_WATCHDOG_TIMER_EXPIRED_TRAP 131
+#define SM_LOCAL_CHANGES_TRAP 144
+#define SM_SYS_IMG_GUID_CHANGED_TRAP 145
+#define SM_BAD_MKEY_TRAP 256
+#define SM_BAD_PKEY_TRAP 257
+#define SM_BAD_QKEY_TRAP 258
+#define SM_BAD_SWITCH_PKEY_TRAP 259
+
+#include <complib/cl_packon.h>
+typedef struct _ib_mad_notice_attr // Total Size calc Accumulated
+{
+ uint8_t generic_type; // 1 1
+ union _notice_g_or_v {
+ struct _notice_generic // 5 6
+ {
+ uint8_t prod_type_msb;
+ ib_net16_t prod_type_lsb;
+ ib_net16_t trap_num;
+ } PACK_SUFFIX generic;
+ struct _notice_vend {
+ uint8_t vend_id_msb;
+ ib_net16_t vend_id_lsb;
+ ib_net16_t dev_id;
+ } PACK_SUFFIX vend;
+ } g_or_v;
+ ib_net16_t issuer_lid; // 2 8
+ ib_net16_t toggle_count; // 2 10
+ union _data_details // 54 64
+ {
+ struct _raw_data {
+ uint8_t details[54];
+ } PACK_SUFFIX raw_data;
+ struct _ntc_64_67 {
+ uint8_t res[6];
+ ib_gid_t gid; // the Node or Multicast Group that came in/out
+ } PACK_SUFFIX ntc_64_67;
+ struct _ntc_128 {
+ ib_net16_t sw_lid; // the sw lid of which link state changed
+ } PACK_SUFFIX ntc_128;
+ struct _ntc_129_131 {
+ ib_net16_t pad;
+ ib_net16_t lid; // lid and port number of the violation
+ uint8_t port_num;
+ } PACK_SUFFIX ntc_129_131;
+ struct _ntc_144 {
+ ib_net16_t pad1;
+ ib_net16_t lid; // lid where change occured
+ uint8_t pad2; // reserved
+ uint8_t local_changes; // 7b reserved 1b local changes
+ ib_net32_t new_cap_mask; // new capability mask
+ ib_net16_t change_flgs; // 10b reserved 6b change flags
+ ib_net16_t cap_mask2;
+ } PACK_SUFFIX ntc_144;
+ struct _ntc_145 {
+ ib_net16_t pad1;
+ ib_net16_t lid; // lid where sys guid changed
+ ib_net16_t pad2;
+ ib_net64_t new_sys_guid; // new system image guid
+ } PACK_SUFFIX ntc_145;
+ struct _ntc_256 { // total: 54
+ ib_net16_t pad1; // 2
+ ib_net16_t lid; // 2
+ ib_net16_t dr_slid; // 2
+ uint8_t method; // 1
+ uint8_t pad2; // 1
+ ib_net16_t attr_id; // 2
+ ib_net32_t attr_mod; // 4
+ ib_net64_t mkey; // 8
+ uint8_t pad3; // 1
+ uint8_t dr_trunc_hop; // 1
+ uint8_t dr_rtn_path[30]; // 30
+ } PACK_SUFFIX ntc_256;
+ struct _ntc_257_258 // violation of p/q_key // 49
+ {
+ ib_net16_t pad1; // 2
+ ib_net16_t lid1; // 2
+ ib_net16_t lid2; // 2
+ ib_net32_t key; // 4
+ ib_net32_t qp1; // 4b sl, 4b pad, 24b qp1
+ ib_net32_t qp2; // 8b pad, 24b qp2
+ ib_gid_t gid1; // 16
+ ib_gid_t gid2; // 16
+ } PACK_SUFFIX ntc_257_258;
+ struct _ntc_259 // pkey violation from switch 51
+ {
+ ib_net16_t data_valid; // 2
+ ib_net16_t lid1; // 2
+ ib_net16_t lid2; // 2
+ ib_net16_t pkey; // 2
+ ib_net32_t sl_qp1; // 4b sl, 4b pad, 24b qp1
+ ib_net32_t qp2; // 8b pad, 24b qp2
+ ib_gid_t gid1; // 16
+ ib_gid_t gid2; // 16
+ ib_net16_t sw_lid; // 2
+ uint8_t port_no; // 1
+ } PACK_SUFFIX ntc_259;
+ struct _ntc_bkey_259 // bkey violation
+ {
+ ib_net16_t lidaddr;
+ uint8_t method;
+ uint8_t reserved;
+ ib_net16_t attribute_id;
+ ib_net32_t attribute_modifier;
+ ib_net32_t qp; // qp is low 24 bits
+ ib_net64_t bkey;
+ ib_gid_t gid;
+ } PACK_SUFFIX ntc_bkey_259;
+ struct _ntc_cckey_0 // CC key violation
+ {
+ ib_net16_t slid; // source LID from offending packet LRH
+ uint8_t method; // method, from common MAD header
+ uint8_t resv0;
+ ib_net16_t attribute_id; // Attribute ID, from common MAD header
+ ib_net16_t resv1;
+ ib_net32_t attribute_modifier; // Attribute Modif, from common MAD header
+ ib_net32_t qp; // 8b pad, 24b dest QP from BTH
+ ib_net64_t cc_key; // CC key of the offending packet
+ ib_gid_t source_gid; // GID from GRH of the offending packet
+ uint8_t padding[14]; // Padding - ignored on read
+ } PACK_SUFFIX ntc_cckey_0;
+ } data_details;
+ ib_gid_t issuer_gid; // 16 80
+} PACK_SUFFIX ib_mad_notice_attr_t;
+#include <complib/cl_packoff.h>
+
+/**
+ * Trap 259 masks
+ */
+#define TRAP_259_MASK_SL (CL_HTON32(0xF0000000))
+#define TRAP_259_MASK_QP (CL_HTON32(0x00FFFFFF))
+
+/**
+ * Trap 144 masks
+ */
+#define TRAP_144_MASK_OTHER_LOCAL_CHANGES 0x01
+#define TRAP_144_MASK_CAPABILITY_MASK2_CHANGE (CL_HTON16(0x0020))
+#define TRAP_144_MASK_HIERARCHY_INFO_CHANGE (CL_HTON16(0x0010))
+#define TRAP_144_MASK_SM_PRIORITY_CHANGE (CL_HTON16(0x0008))
+#define TRAP_144_MASK_LINK_SPEED_ENABLE_CHANGE (CL_HTON16(0x0004))
+#define TRAP_144_MASK_LINK_WIDTH_ENABLE_CHANGE (CL_HTON16(0x0002))
+#define TRAP_144_MASK_NODE_DESCRIPTION_CHANGE (CL_HTON16(0x0001))
+
+/****f* IBA Base: Types/ib_notice_is_generic
+* NAME
+* ib_notice_is_generic
+*
+* DESCRIPTION
+* Check if the notice is generic
+*
+* SYNOPSIS
+*/
+static inline boolean_t OSM_API
+ib_notice_is_generic(IN const ib_mad_notice_attr_t * p_ntc)
+{
+ return (p_ntc->generic_type & 0x80);
+}
+
+/*
+* PARAMETERS
+* p_ntc
+* [in] Pointer to the notice MAD attribute
+*
+* RETURN VALUES
+* TRUE if notice MAD is generic
+*
+* SEE ALSO
+* ib_mad_notice_attr_t
+*********/
+
+/****f* IBA Base: Types/ib_notice_get_type
+* NAME
+* ib_notice_get_type
+*
+* DESCRIPTION
+* Get the notice type
+*
+* SYNOPSIS
+*/
+static inline uint8_t OSM_API
+ib_notice_get_type(IN const ib_mad_notice_attr_t * p_ntc)
+{
+ return p_ntc->generic_type & 0x7f;
+}
+
+/*
+* PARAMETERS
+* p_ntc
+* [in] Pointer to the notice MAD attribute
+*
+* RETURN VALUES
+* TRUE if mad is generic
+*
+* SEE ALSO
+* ib_mad_notice_attr_t
+*********/
+
+/****f* IBA Base: Types/ib_notice_get_prod_type
+* NAME
+* ib_notice_get_prod_type
+*
+* DESCRIPTION
+* Get the notice Producer Type of Generic Notice
+*
+* SYNOPSIS
+*/
+static inline ib_net32_t OSM_API
+ib_notice_get_prod_type(IN const ib_mad_notice_attr_t * p_ntc)
+{
+ uint32_t pt;
+
+ pt = cl_ntoh16(p_ntc->g_or_v.generic.prod_type_lsb) |
+ (p_ntc->g_or_v.generic.prod_type_msb << 16);
+ return cl_hton32(pt);
+}
+
+/*
+* PARAMETERS
+* p_ntc
+* [in] Pointer to the notice MAD attribute
+*
+* RETURN VALUES
+* The producer type
+*
+* SEE ALSO
+* ib_mad_notice_attr_t
+*********/
+
+/****f* IBA Base: Types/ib_notice_set_prod_type
+* NAME
+* ib_notice_set_prod_type
+*
+* DESCRIPTION
+* Set the notice Producer Type of Generic Notice
+*
+* SYNOPSIS
+*/
+static inline void OSM_API
+ib_notice_set_prod_type(IN ib_mad_notice_attr_t * p_ntc,
+ IN ib_net32_t prod_type_val)
+{
+ uint32_t ptv = cl_ntoh32(prod_type_val);
+ p_ntc->g_or_v.generic.prod_type_lsb =
+ cl_hton16((uint16_t) (ptv & 0x0000ffff));
+ p_ntc->g_or_v.generic.prod_type_msb =
+ (uint8_t) ((ptv & 0x00ff0000) >> 16);
+}
+
+/*
+* PARAMETERS
+* p_ntc
+* [in] Pointer to the notice MAD attribute
+*
+* prod_type
+* [in] The producer Type code
+*
+* RETURN VALUES
+* None
+*
+* SEE ALSO
+* ib_mad_notice_attr_t
+*********/
+
+/****f* IBA Base: Types/ib_notice_set_prod_type_ho
+* NAME
+* ib_notice_set_prod_type_ho
+*
+* DESCRIPTION
+* Set the notice Producer Type of Generic Notice given Host Order
+*
+* SYNOPSIS
+*/
+static inline void OSM_API
+ib_notice_set_prod_type_ho(IN ib_mad_notice_attr_t * p_ntc,
+ IN uint32_t prod_type_val_ho)
+{
+ p_ntc->g_or_v.generic.prod_type_lsb =
+ cl_hton16((uint16_t) (prod_type_val_ho & 0x0000ffff));
+ p_ntc->g_or_v.generic.prod_type_msb =
+ (uint8_t) ((prod_type_val_ho & 0x00ff0000) >> 16);
+}
+
+/*
+* PARAMETERS
+* p_ntc
+* [in] Pointer to the notice MAD attribute
+*
+* prod_type
+* [in] The producer Type code in host order
+*
+* RETURN VALUES
+* None
+*
+* SEE ALSO
+* ib_mad_notice_attr_t
+*********/
+
+/****f* IBA Base: Types/ib_notice_get_vend_id
+* NAME
+* ib_notice_get_vend_id
+*
+* DESCRIPTION
+* Get the Vendor Id of Vendor type Notice
+*
+* SYNOPSIS
+*/
+static inline ib_net32_t OSM_API
+ib_notice_get_vend_id(IN const ib_mad_notice_attr_t * p_ntc)
+{
+ uint32_t vi;
+
+ vi = cl_ntoh16(p_ntc->g_or_v.vend.vend_id_lsb) |
+ (p_ntc->g_or_v.vend.vend_id_msb << 16);
+ return cl_hton32(vi);
+}
+
+/*
+* PARAMETERS
+* p_ntc
+* [in] Pointer to the notice MAD attribute
+*
+* RETURN VALUES
+* The Vendor Id of Vendor type Notice
+*
+* SEE ALSO
+* ib_mad_notice_attr_t
+*********/
+
+/****f* IBA Base: Types/ib_notice_set_vend_id
+* NAME
+* ib_notice_set_vend_id
+*
+* DESCRIPTION
+* Set the notice Producer Type of Generic Notice
+*
+* SYNOPSIS
+*/
+static inline void OSM_API
+ib_notice_set_vend_id(IN ib_mad_notice_attr_t * p_ntc, IN ib_net32_t vend_id)
+{
+ uint32_t vi = cl_ntoh32(vend_id);
+ p_ntc->g_or_v.vend.vend_id_lsb =
+ cl_hton16((uint16_t) (vi & 0x0000ffff));
+ p_ntc->g_or_v.vend.vend_id_msb = (uint8_t) ((vi & 0x00ff0000) >> 16);
+}
+
+/*
+* PARAMETERS
+* p_ntc
+* [in] Pointer to the notice MAD attribute
+*
+* vend_id
+* [in] The producer Type code
+*
+* RETURN VALUES
+* None
+*
+* SEE ALSO
+* ib_mad_notice_attr_t
+*********/
+
+/****f* IBA Base: Types/ib_notice_set_vend_id_ho
+* NAME
+* ib_notice_set_vend_id_ho
+*
+* DESCRIPTION
+* Set the notice Producer Type of Generic Notice given a host order value
+*
+* SYNOPSIS
+*/
+static inline void OSM_API
+ib_notice_set_vend_id_ho(IN ib_mad_notice_attr_t * p_ntc,
+ IN uint32_t vend_id_ho)
+{
+ p_ntc->g_or_v.vend.vend_id_lsb =
+ cl_hton16((uint16_t) (vend_id_ho & 0x0000ffff));
+ p_ntc->g_or_v.vend.vend_id_msb =
+ (uint8_t) ((vend_id_ho & 0x00ff0000) >> 16);
+}
+
+/*
+* PARAMETERS
+* p_ntc
+* [in] Pointer to the notice MAD attribute
+*
+* vend_id_ho
+* [in] The producer Type code in host order
+*
+* RETURN VALUES
+* None
+*
+* SEE ALSO
+* ib_mad_notice_attr_t
+*********/
+
+#include <complib/cl_packon.h>
+typedef struct _ib_inform_info {
+ ib_gid_t gid;
+ ib_net16_t lid_range_begin;
+ ib_net16_t lid_range_end;
+ ib_net16_t reserved1;
+ uint8_t is_generic;
+ uint8_t subscribe;
+ ib_net16_t trap_type;
+ union _inform_g_or_v {
+ struct _inform_generic {
+ ib_net16_t trap_num;
+ ib_net32_t qpn_resp_time_val;
+ uint8_t reserved2;
+ uint8_t node_type_msb;
+ ib_net16_t node_type_lsb;
+ } PACK_SUFFIX generic;
+ struct _inform_vend {
+ ib_net16_t dev_id;
+ ib_net32_t qpn_resp_time_val;
+ uint8_t reserved2;
+ uint8_t vendor_id_msb;
+ ib_net16_t vendor_id_lsb;
+ } PACK_SUFFIX vend;
+ } PACK_SUFFIX g_or_v;
+} PACK_SUFFIX ib_inform_info_t;
+#include <complib/cl_packoff.h>
+
+/****f* IBA Base: Types/ib_inform_info_get_qpn_resp_time
+* NAME
+* ib_inform_info_get_qpn_resp_time
+*
+* DESCRIPTION
+* Get QPN of the inform info
+*
+* SYNOPSIS
+*/
+static inline void OSM_API
+ib_inform_info_get_qpn_resp_time(IN const ib_net32_t qpn_resp_time_val,
+ OUT ib_net32_t * const p_qpn,
+ OUT uint8_t * const p_resp_time_val)
+{
+ uint32_t tmp = cl_ntoh32(qpn_resp_time_val);
+
+ if (p_qpn)
+ *p_qpn = cl_hton32((tmp & 0xffffff00) >> 8);
+ if (p_resp_time_val)
+ *p_resp_time_val = (uint8_t) (tmp & 0x0000001f);
+}
+
+/*
+* PARAMETERS
+* qpn_resp_time_val
+* [in] the qpn and resp time val from the mad
+*
+* RETURN VALUES
+* p_qpn
+* [out] pointer to the qpn
+*
+* p_state
+* [out] pointer to the resp time val
+*
+* NOTES
+*
+* SEE ALSO
+* ib_inform_info_t
+*********/
+
+/****f* IBA Base: Types/ib_inform_info_set_qpn
+* NAME
+* ib_inform_info_set_qpn
+*
+* DESCRIPTION
+* Set the QPN of the inform info
+*
+* SYNOPSIS
+*/
+static inline void OSM_API
+ib_inform_info_set_qpn(IN ib_inform_info_t * p_ii, IN ib_net32_t const qpn)
+{
+ uint32_t tmp = cl_ntoh32(p_ii->g_or_v.generic.qpn_resp_time_val);
+ uint32_t qpn_h = cl_ntoh32(qpn);
+
+ p_ii->g_or_v.generic.qpn_resp_time_val =
+ cl_hton32((tmp & 0x000000ff) | ((qpn_h << 8) & 0xffffff00)
+ );
+}
+
+/*
+* PARAMETERS
+*
+* NOTES
+*
+* SEE ALSO
+* ib_inform_info_t
+*********/
+
+/****f* IBA Base: Types/ib_inform_info_get_prod_type
+* NAME
+* ib_inform_info_get_prod_type
+*
+* DESCRIPTION
+* Get Producer Type of the Inform Info
+* 13.4.8.3 InformInfo
+*
+* SYNOPSIS
+*/
+static inline ib_net32_t OSM_API
+ib_inform_info_get_prod_type(IN const ib_inform_info_t * p_inf)
+{
+ uint32_t nt;
+
+ nt = cl_ntoh16(p_inf->g_or_v.generic.node_type_lsb) |
+ (p_inf->g_or_v.generic.node_type_msb << 16);
+ return cl_hton32(nt);
+}
+
+/*
+* PARAMETERS
+* p_inf
+* [in] pointer to an inform info
+*
+* RETURN VALUES
+* The producer type
+*
+* NOTES
+*
+* SEE ALSO
+* ib_inform_info_t
+*********/
+
+/****f* IBA Base: Types/ib_inform_info_get_vend_id
+* NAME
+* ib_inform_info_get_vend_id
+*
+* DESCRIPTION
+* Get Node Type of the Inform Info
+*
+* SYNOPSIS
+*/
+static inline ib_net32_t OSM_API
+ib_inform_info_get_vend_id(IN const ib_inform_info_t * p_inf)
+{
+ uint32_t vi;
+
+ vi = cl_ntoh16(p_inf->g_or_v.vend.vendor_id_lsb) |
+ (p_inf->g_or_v.vend.vendor_id_msb << 16);
+ return cl_hton32(vi);
+}
+
+/*
+* PARAMETERS
+* p_inf
+* [in] pointer to an inform info
+*
+* RETURN VALUES
+* The node type
+*
+* NOTES
+*
+* SEE ALSO
+* ib_inform_info_t
+*********/
+
+/****s* IBA Base: Types/ib_inform_info_record_t
+* NAME
+* ib_inform_info_record_t
+*
+* DESCRIPTION
+* IBA defined InformInfo Record. (15.2.5.12)
+*
+* SYNOPSIS
+*/
+#include <complib/cl_packon.h>
+typedef struct _ib_inform_info_record {
+ ib_gid_t subscriber_gid;
+ ib_net16_t subscriber_enum;
+ uint8_t reserved[6];
+ ib_inform_info_t inform_info;
+ uint8_t pad[4];
+} PACK_SUFFIX ib_inform_info_record_t;
+#include <complib/cl_packoff.h>
+
+/****s* IBA Base: Types/ib_perfmgt_mad_t
+* NAME
+* ib_perfmgt_mad_t
+*
+* DESCRIPTION
+* IBA defined Perf Management MAD (16.3.1)
+*
+* SYNOPSIS
+*/
+#include <complib/cl_packon.h>
+typedef struct _ib_perfmgt_mad {
+ ib_mad_t header;
+ uint8_t resv[40];
+#define IB_PM_DATA_SIZE 192
+ uint8_t data[IB_PM_DATA_SIZE];
+} PACK_SUFFIX ib_perfmgt_mad_t;
+#include <complib/cl_packoff.h>
+/*
+* FIELDS
+* header
+* Common MAD header.
+*
+* resv
+* Reserved.
+*
+* data
+* Performance Management payload. The structure and content of this field
+* depends upon the method, attr_id, and attr_mod fields in the header.
+*
+* SEE ALSO
+* ib_mad_t
+*********/
+
+/****s* IBA Base: Types/ib_port_counters
+* NAME
+* ib_port_counters_t
+*
+* DESCRIPTION
+* IBA defined PortCounters Attribute. (16.1.3.5)
+*
+* SYNOPSIS
+*/
+#include <complib/cl_packon.h>
+typedef struct _ib_port_counters {
+ uint8_t reserved;
+ uint8_t port_select;
+ ib_net16_t counter_select;
+ ib_net16_t symbol_err_cnt;
+ uint8_t link_err_recover;
+ uint8_t link_downed;
+ ib_net16_t rcv_err;
+ ib_net16_t rcv_rem_phys_err;
+ ib_net16_t rcv_switch_relay_err;
+ ib_net16_t xmit_discards;
+ uint8_t xmit_constraint_err;
+ uint8_t rcv_constraint_err;
+ uint8_t counter_select2;
+ uint8_t link_int_buffer_overrun;
+ ib_net16_t qp1_dropped;
+ ib_net16_t vl15_dropped;
+ ib_net32_t xmit_data;
+ ib_net32_t rcv_data;
+ ib_net32_t xmit_pkts;
+ ib_net32_t rcv_pkts;
+ ib_net32_t xmit_wait;
+} PACK_SUFFIX ib_port_counters_t;
+#include <complib/cl_packoff.h>
+
+#define PC_LINK_INT(integ_buf_over) ((integ_buf_over & 0xF0) >> 4)
+#define PC_BUF_OVERRUN(integ_buf_over) (integ_buf_over & 0x0F)
+
+/****s* IBA Base: Types/ib_port_counters_ext
+* NAME
+* ib_port_counters_ext_t
+*
+* DESCRIPTION
+* IBA defined PortCounters Extended Attribute. (16.1.4.11)
+*
+* SYNOPSIS
+*/
+#include <complib/cl_packon.h>
+typedef struct _ib_port_counters_ext {
+ uint8_t reserved;
+ uint8_t port_select;
+ ib_net16_t counter_select;
+ ib_net32_t counter_select2;
+ ib_net64_t xmit_data;
+ ib_net64_t rcv_data;
+ ib_net64_t xmit_pkts;
+ ib_net64_t rcv_pkts;
+ ib_net64_t unicast_xmit_pkts;
+ ib_net64_t unicast_rcv_pkts;
+ ib_net64_t multicast_xmit_pkts;
+ ib_net64_t multicast_rcv_pkts;
+ ib_net64_t symbol_err_cnt;
+ ib_net64_t link_err_recover;
+ ib_net64_t link_downed;
+ ib_net64_t rcv_err;
+ ib_net64_t rcv_rem_phys_err;
+ ib_net64_t rcv_switch_relay_err;
+ ib_net64_t xmit_discards;
+ ib_net64_t xmit_constraint_err;
+ ib_net64_t rcv_constraint_err;
+ ib_net64_t link_integrity_err;
+ ib_net64_t buffer_overrun;
+ ib_net64_t vl15_dropped;
+ ib_net64_t xmit_wait;
+ ib_net64_t qp1_dropped;
+} PACK_SUFFIX ib_port_counters_ext_t;
+#include <complib/cl_packoff.h>
+
+/****s* IBA Base: Types/ib_port_samples_control
+* NAME
+* ib_port_samples_control_t
+*
+* DESCRIPTION
+* IBA defined PortSamplesControl Attribute. (16.1.3.2)
+*
+* SYNOPSIS
+*/
+#include <complib/cl_packon.h>
+typedef struct _ib_port_samples_control {
+ uint8_t op_code;
+ uint8_t port_select;
+ uint8_t tick;
+ uint8_t counter_width; /* 5 bits res : 3bits counter_width */
+ ib_net32_t counter_mask; /* 2 bits res : 3 bits counter_mask : 27 bits counter_masks_1to9 */
+ ib_net16_t counter_mask_10to14; /* 1 bits res : 15 bits counter_masks_10to14 */
+ uint8_t sample_mech;
+ uint8_t sample_status; /* 6 bits res : 2 bits sample_status */
+ ib_net64_t option_mask;
+ ib_net64_t vendor_mask;
+ ib_net32_t sample_start;
+ ib_net32_t sample_interval;
+ ib_net16_t tag;
+ ib_net16_t counter_select0;
+ ib_net16_t counter_select1;
+ ib_net16_t counter_select2;
+ ib_net16_t counter_select3;
+ ib_net16_t counter_select4;
+ ib_net16_t counter_select5;
+ ib_net16_t counter_select6;
+ ib_net16_t counter_select7;
+ ib_net16_t counter_select8;
+ ib_net16_t counter_select9;
+ ib_net16_t counter_select10;
+ ib_net16_t counter_select11;
+ ib_net16_t counter_select12;
+ ib_net16_t counter_select13;
+ ib_net16_t counter_select14;
+} PACK_SUFFIX ib_port_samples_control_t;
+#include <complib/cl_packoff.h>
+
+/****d* IBA Base: Types/CounterSelect values
+* NAME
+* Counter select values
+*
+* DESCRIPTION
+* Mandatory counter select values (16.1.3.3)
+*
+* SYNOPSIS
+*/
+#define IB_CS_PORT_XMIT_DATA (CL_HTON16(0x0001))
+#define IB_CS_PORT_RCV_DATA (CL_HTON16(0x0002))
+#define IB_CS_PORT_XMIT_PKTS (CL_HTON16(0x0003))
+#define IB_CS_PORT_RCV_PKTS (CL_HTON16(0x0004))
+#define IB_CS_PORT_XMIT_WAIT (CL_HTON16(0x0005))
+
+/****s* IBA Base: Types/ib_port_samples_result
+* NAME
+* ib_port_samples_result_t
+*
+* DESCRIPTION
+* IBA defined PortSamplesControl Attribute. (16.1.3.2)
+*
+* SYNOPSIS
+*/
+#include <complib/cl_packon.h>
+typedef struct _ib_port_samples_result {
+ ib_net16_t tag;
+ ib_net16_t sample_status; /* 14 bits res : 2 bits sample_status */
+ ib_net32_t counter0;
+ ib_net32_t counter1;
+ ib_net32_t counter2;
+ ib_net32_t counter3;
+ ib_net32_t counter4;
+ ib_net32_t counter5;
+ ib_net32_t counter6;
+ ib_net32_t counter7;
+ ib_net32_t counter8;
+ ib_net32_t counter9;
+ ib_net32_t counter10;
+ ib_net32_t counter11;
+ ib_net32_t counter12;
+ ib_net32_t counter13;
+ ib_net32_t counter14;
+} PACK_SUFFIX ib_port_samples_result_t;
+#include <complib/cl_packoff.h>
+
+/****s* IBA Base: Types/ib_port_xmit_data_sl
+* NAME
+* ib_port_xmit_data_sl_t
+*
+* DESCRIPTION
+* IBA defined PortXmitDataSL Attribute. (A13.6.4)
+*
+* SYNOPSIS
+*/
+#include <complib/cl_packon.h>
+typedef struct _ib_port_xmit_data_sl {
+ uint8_t reserved;
+ uint8_t port_select;
+ ib_net16_t counter_select;
+ ib_net32_t port_xmit_data_sl[16];
+ uint8_t resv[124];
+} PACK_SUFFIX ib_port_xmit_data_sl_t;
+#include <complib/cl_packoff.h>
+
+/****s* IBA Base: Types/ib_port_rcv_data_sl
+* NAME
+* ib_port_rcv_data_sl_t
+*
+* DESCRIPTION
+* IBA defined PortRcvDataSL Attribute. (A13.6.4)
+*
+* SYNOPSIS
+*/
+#include <complib/cl_packon.h>
+typedef struct _ib_port_rcv_data_sl {
+ uint8_t reserved;
+ uint8_t port_select;
+ ib_net16_t counter_select;
+ ib_net32_t port_rcv_data_sl[16];
+ uint8_t resv[124];
+} PACK_SUFFIX ib_port_rcv_data_sl_t;
+#include <complib/cl_packoff.h>
+
+/****d* IBA Base: Types/DM_SVC_NAME
+* NAME
+* DM_SVC_NAME
+*
+* DESCRIPTION
+* IBA defined Device Management service name (16.3)
+*
+* SYNOPSIS
+*/
+#define DM_SVC_NAME "DeviceManager.IBTA"
+/*
+* SEE ALSO
+*********/
+
+/****s* IBA Base: Types/ib_dm_mad_t
+* NAME
+* ib_dm_mad_t
+*
+* DESCRIPTION
+* IBA defined Device Management MAD (16.3.1)
+*
+* SYNOPSIS
+*/
+#include <complib/cl_packon.h>
+typedef struct _ib_dm_mad {
+ ib_mad_t header;
+ uint8_t resv[40];
+#define IB_DM_DATA_SIZE 192
+ uint8_t data[IB_DM_DATA_SIZE];
+} PACK_SUFFIX ib_dm_mad_t;
+#include <complib/cl_packoff.h>
+/*
+* FIELDS
+* header
+* Common MAD header.
+*
+* resv
+* Reserved.
+*
+* data
+* Device Management payload. The structure and content of this field
+* depend upon the method, attr_id, and attr_mod fields in the header.
+*
+* SEE ALSO
+* ib_mad_t
+*********/
+
+/****s* IBA Base: Types/ib_iou_info_t
+* NAME
+* ib_iou_info_t
+*
+* DESCRIPTION
+* IBA defined IO Unit information structure (16.3.3.3)
+*
+* SYNOPSIS
+*/
+#include <complib/cl_packon.h>
+typedef struct _ib_iou_info {
+ ib_net16_t change_id;
+ uint8_t max_controllers;
+ uint8_t diag_rom;
+#define IB_DM_CTRL_LIST_SIZE 128
+ uint8_t controller_list[IB_DM_CTRL_LIST_SIZE];
+#define IOC_NOT_INSTALLED 0x0
+#define IOC_INSTALLED 0x1
+// Reserved values 0x02-0xE
+#define SLOT_DOES_NOT_EXIST 0xF
+} PACK_SUFFIX ib_iou_info_t;
+#include <complib/cl_packoff.h>
+/*
+* FIELDS
+* change_id
+* Value incremented, with rollover, by any change to the controller_list.
+*
+* max_controllers
+* Number of slots in controller_list.
+*
+* diag_rom
+* A byte containing two fields: DiagDeviceID and OptionROM.
+* These fields may be read using the ib_iou_info_diag_dev_id
+* and ib_iou_info_option_rom functions.
+*
+* controller_list
+* A series of 4-bit nibbles, with each nibble representing a slot
+* in the IO Unit. Individual nibbles may be read using the
+* ioc_at_slot function.
+*
+* SEE ALSO
+* ib_dm_mad_t, ib_iou_info_diag_dev_id, ib_iou_info_option_rom, ioc_at_slot
+*********/
+
+/****f* IBA Base: Types/ib_iou_info_diag_dev_id
+* NAME
+* ib_iou_info_diag_dev_id
+*
+* DESCRIPTION
+* Returns the DiagDeviceID.
+*
+* SYNOPSIS
+*/
+static inline uint8_t OSM_API
+ib_iou_info_diag_dev_id(IN const ib_iou_info_t * const p_iou_info)
+{
+ return ((uint8_t) (p_iou_info->diag_rom >> 6 & 1));
+}
+
+/*
+* PARAMETERS
+* p_iou_info
+* [in] Pointer to the IO Unit information structure.
+*
+* RETURN VALUES
+* DiagDeviceID field of the IO Unit information.
+*
+* NOTES
+*
+* SEE ALSO
+* ib_iou_info_t
+*********/
+
+/****f* IBA Base: Types/ib_iou_info_option_rom
+* NAME
+* ib_iou_info_option_rom
+*
+* DESCRIPTION
+* Returns the OptionROM.
+*
+* SYNOPSIS
+*/
+static inline uint8_t OSM_API
+ib_iou_info_option_rom(IN const ib_iou_info_t * const p_iou_info)
+{
+ return ((uint8_t) (p_iou_info->diag_rom >> 7));
+}
+
+/*
+* PARAMETERS
+* p_iou_info
+* [in] Pointer to the IO Unit information structure.
+*
+* RETURN VALUES
+* OptionROM field of the IO Unit information.
+*
+* NOTES
+*
+* SEE ALSO
+* ib_iou_info_t
+*********/
+
+/****f* IBA Base: Types/ioc_at_slot
+* NAME
+* ioc_at_slot
+*
+* DESCRIPTION
+* Returns the IOC value at the specified slot.
+*
+* SYNOPSIS
+*/
+static inline uint8_t OSM_API
+ioc_at_slot(IN const ib_iou_info_t * const p_iou_info, IN uint8_t slot)
+{
+ if (slot >= IB_DM_CTRL_LIST_SIZE)
+ return SLOT_DOES_NOT_EXIST;
+ else
+ return (int8_t)
+ ((slot % 2) ?
+ ((p_iou_info->controller_list[slot / 2] & 0xf0) >> 4) :
+ (p_iou_info->controller_list[slot / 2] & 0x0f));
+}
+
+/*
+* PARAMETERS
+* p_iou_info
+* [in] Pointer to the IO Unit information structure.
+*
+* slot
+* [in] Pointer to the IO Unit information structure.
+*
+* RETURN VALUES
+* OptionROM field of the IO Unit information.
+*
+* NOTES
+*
+* SEE ALSO
+* ib_iou_info_t
+*********/
+
+/****s* IBA Base: Types/ib_ioc_profile_t
+* NAME
+* ib_ioc_profile_t
+*
+* DESCRIPTION
+* IBA defined IO Controller profile structure (16.3.3.4)
+*
+* SYNOPSIS
+*/
+#include <complib/cl_packon.h>
+typedef struct _ib_ioc_profile {
+ ib_net64_t ioc_guid;
+ ib_net32_t vend_id;
+ ib_net32_t dev_id;
+ ib_net16_t dev_ver;
+ ib_net16_t resv2;
+ ib_net32_t subsys_vend_id;
+ ib_net32_t subsys_id;
+ ib_net16_t io_class;
+ ib_net16_t io_subclass;
+ ib_net16_t protocol;
+ ib_net16_t protocol_ver;
+ ib_net32_t resv3;
+ ib_net16_t send_msg_depth;
+ uint8_t resv4;
+ uint8_t rdma_read_depth;
+ ib_net32_t send_msg_size;
+ ib_net32_t rdma_size;
+ uint8_t ctrl_ops_cap;
+#define CTRL_OPS_CAP_ST 0x01
+#define CTRL_OPS_CAP_SF 0x02
+#define CTRL_OPS_CAP_RT 0x04
+#define CTRL_OPS_CAP_RF 0x08
+#define CTRL_OPS_CAP_WT 0x10
+#define CTRL_OPS_CAP_WF 0x20
+#define CTRL_OPS_CAP_AT 0x40
+#define CTRL_OPS_CAP_AF 0x80
+ uint8_t resv5;
+ uint8_t num_svc_entries;
+#define MAX_NUM_SVC_ENTRIES 0xff
+ uint8_t resv6[9];
+#define CTRL_ID_STRING_LEN 64
+ char id_string[CTRL_ID_STRING_LEN];
+} PACK_SUFFIX ib_ioc_profile_t;
+#include <complib/cl_packoff.h>
+/*
+* FIELDS
+* ioc_guid
+* An EUI-64 GUID used to uniquely identify the IO controller.
+*
+* vend_id
+* IO controller vendor ID, IEEE format.
+*
+* dev_id
+* A number assigned by the vendor to identify the type of controller.
+*
+* dev_ver
+* A number assigned by the vendor to identify the divice version.
+*
+* subsys_vend_id
+* ID of the vendor of the enclosure, if any, in which the IO controller
+* resides in IEEE format; otherwise zero.
+*
+* subsys_id
+* A number identifying the subsystem where the controller resides.
+*
+* io_class
+* 0x0000 - 0xfffe = reserved for IO classes encompased by InfiniBand
+* Architecture. 0xffff = Vendor specific.
+*
+* io_subclass
+* 0x0000 - 0xfffe = reserved for IO subclasses encompased by InfiniBand
+* Architecture. 0xffff = Vendor specific. This shall be set to 0xfff
+* if the io_class component is 0xffff.
+*
+* protocol
+* 0x0000 - 0xfffe = reserved for IO subclasses encompased by InfiniBand
+* Architecture. 0xffff = Vendor specific. This shall be set to 0xfff
+* if the io_class component is 0xffff.
+*
+* protocol_ver
+* Protocol specific.
+*
+* send_msg_depth
+* Maximum depth of the send message queue.
+*
+* rdma_read_depth
+* Maximum depth of the per-channel RDMA read queue.
+*
+* send_msg_size
+* Maximum size of send messages.
+*
+* ctrl_ops_cap
+* Supported operation types of this IO controller. A bit set to one
+* for affirmation of supported capability.
+*
+* num_svc_entries
+* Number of entries in the service entries table.
+*
+* id_string
+* UTF-8 encoded string for identifying the controller to an operator.
+*
+* SEE ALSO
+* ib_dm_mad_t
+*********/
+
+static inline uint32_t OSM_API
+ib_ioc_profile_get_vend_id(IN const ib_ioc_profile_t * const p_ioc_profile)
+{
+ return (cl_ntoh32(p_ioc_profile->vend_id) >> 8);
+}
+
+static inline void OSM_API
+ib_ioc_profile_set_vend_id(IN ib_ioc_profile_t * const p_ioc_profile,
+ IN const uint32_t vend_id)
+{
+ p_ioc_profile->vend_id = (cl_hton32(vend_id) << 8);
+}
+
+/****s* IBA Base: Types/ib_svc_entry_t
+* NAME
+* ib_svc_entry_t
+*
+* DESCRIPTION
+* IBA defined IO Controller service entry structure (16.3.3.5)
+*
+* SYNOPSIS
+*/
+#include <complib/cl_packon.h>
+typedef struct _ib_svc_entry {
+#define MAX_SVC_ENTRY_NAME_LEN 40
+ char name[MAX_SVC_ENTRY_NAME_LEN];
+ ib_net64_t id;
+} PACK_SUFFIX ib_svc_entry_t;
+#include <complib/cl_packoff.h>
+/*
+* FIELDS
+* name
+* UTF-8 encoded, null-terminated name of the service.
+*
+* id
+* An identifier of the associated Service.
+*
+* SEE ALSO
+* ib_svc_entries_t
+*********/
+
+/****s* IBA Base: Types/ib_svc_entries_t
+* NAME
+* ib_svc_entries_t
+*
+* DESCRIPTION
+* IBA defined IO Controller service entry array (16.3.3.5)
+*
+* SYNOPSIS
+*/
+#include <complib/cl_packon.h>
+typedef struct _ib_svc_entries {
+#define SVC_ENTRY_COUNT 4
+ ib_svc_entry_t service_entry[SVC_ENTRY_COUNT];
+} PACK_SUFFIX ib_svc_entries_t;
+#include <complib/cl_packoff.h>
+/*
+* FIELDS
+* service_entry
+* An array of IO controller service entries.
+*
+* SEE ALSO
+* ib_dm_mad_t, ib_svc_entry_t
+*********/
+
+static inline void OSM_API
+ib_dm_get_slot_lo_hi(IN const ib_net32_t slot_lo_hi,
+ OUT uint8_t * const p_slot,
+ OUT uint8_t * const p_lo, OUT uint8_t * const p_hi)
+{
+ ib_net32_t tmp_slot_lo_hi = CL_NTOH32(slot_lo_hi);
+
+ if (p_slot)
+ *p_slot = (uint8_t) ((tmp_slot_lo_hi >> 16) & 0x0f);
+ if (p_hi)
+ *p_hi = (uint8_t) ((tmp_slot_lo_hi >> 8) & 0xff);
+ if (p_lo)
+ *p_lo = (uint8_t) ((tmp_slot_lo_hi >> 0) & 0xff);
+}
+
+/*
+ * IBA defined information describing an I/O controller
+ */
+#include <complib/cl_packon.h>
+typedef struct _ib_ioc_info {
+ ib_net64_t module_guid;
+ ib_net64_t iou_guid;
+ ib_ioc_profile_t ioc_profile;
+ ib_net64_t access_key;
+ uint16_t initiators_conf;
+ uint8_t resv[38];
+} PACK_SUFFIX ib_ioc_info_t;
+#include <complib/cl_packoff.h>
+
+/*
+ * The following definitions are shared between the Access Layer and VPD
+ */
+typedef struct _ib_ca *__ptr64 ib_ca_handle_t;
+typedef struct _ib_pd *__ptr64 ib_pd_handle_t;
+typedef struct _ib_rdd *__ptr64 ib_rdd_handle_t;
+typedef struct _ib_mr *__ptr64 ib_mr_handle_t;
+typedef struct _ib_mw *__ptr64 ib_mw_handle_t;
+typedef struct _ib_qp *__ptr64 ib_qp_handle_t;
+typedef struct _ib_eec *__ptr64 ib_eec_handle_t;
+typedef struct _ib_cq *__ptr64 ib_cq_handle_t;
+typedef struct _ib_av *__ptr64 ib_av_handle_t;
+typedef struct _ib_mcast *__ptr64 ib_mcast_handle_t;
+
+/* Currently for windows branch, use the extended version of ib special verbs struct
+ in order to be compliant with Infinicon ib_types; later we'll change it to support
+ OpenSM ib_types.h */
+
+#ifndef __WIN__
+/****d* Access Layer/ib_api_status_t
+* NAME
+* ib_api_status_t
+*
+* DESCRIPTION
+* Function return codes indicating the success or failure of an API call.
+* Note that success is indicated by the return value IB_SUCCESS, which
+* is always zero.
+*
+* NOTES
+* IB_VERBS_PROCESSING_DONE is used by UVP library to terminate a verbs call
+* in the pre-ioctl step itself.
+*
+* SYNOPSIS
+*/
+typedef enum _ib_api_status_t {
+ IB_SUCCESS,
+ IB_INSUFFICIENT_RESOURCES,
+ IB_INSUFFICIENT_MEMORY,
+ IB_INVALID_PARAMETER,
+ IB_INVALID_SETTING,
+ IB_NOT_FOUND,
+ IB_TIMEOUT,
+ IB_CANCELED,
+ IB_INTERRUPTED,
+ IB_INVALID_PERMISSION,
+ IB_UNSUPPORTED,
+ IB_OVERFLOW,
+ IB_MAX_MCAST_QPS_REACHED,
+ IB_INVALID_QP_STATE,
+ IB_INVALID_EEC_STATE,
+ IB_INVALID_APM_STATE,
+ IB_INVALID_PORT_STATE,
+ IB_INVALID_STATE,
+ IB_RESOURCE_BUSY,
+ IB_INVALID_PKEY,
+ IB_INVALID_LKEY,
+ IB_INVALID_RKEY,
+ IB_INVALID_MAX_WRS,
+ IB_INVALID_MAX_SGE,
+ IB_INVALID_CQ_SIZE,
+ IB_INVALID_SERVICE_TYPE,
+ IB_INVALID_GID,
+ IB_INVALID_LID,
+ IB_INVALID_GUID,
+ IB_INVALID_CA_HANDLE,
+ IB_INVALID_AV_HANDLE,
+ IB_INVALID_CQ_HANDLE,
+ IB_INVALID_EEC_HANDLE,
+ IB_INVALID_QP_HANDLE,
+ IB_INVALID_PD_HANDLE,
+ IB_INVALID_MR_HANDLE,
+ IB_INVALID_MW_HANDLE,
+ IB_INVALID_RDD_HANDLE,
+ IB_INVALID_MCAST_HANDLE,
+ IB_INVALID_CALLBACK,
+ IB_INVALID_AL_HANDLE, /* InfiniBand Access Layer */
+ IB_INVALID_HANDLE, /* InfiniBand Access Layer */
+ IB_ERROR, /* InfiniBand Access Layer */
+ IB_REMOTE_ERROR, /* Infiniband Access Layer */
+ IB_VERBS_PROCESSING_DONE, /* See Notes above */
+ IB_INVALID_WR_TYPE,
+ IB_QP_IN_TIMEWAIT,
+ IB_EE_IN_TIMEWAIT,
+ IB_INVALID_PORT,
+ IB_NOT_DONE,
+ IB_UNKNOWN_ERROR /* ALWAYS LAST ENUM VALUE! */
+} ib_api_status_t;
+/*****/
+
+OSM_EXPORT const char *ib_error_str[];
+
+/****f* IBA Base: Types/ib_get_err_str
+* NAME
+* ib_get_err_str
+*
+* DESCRIPTION
+* Returns a string for the specified status value.
+*
+* SYNOPSIS
+*/
+static inline const char *OSM_API ib_get_err_str(IN ib_api_status_t status)
+{
+ if (status > IB_UNKNOWN_ERROR)
+ status = IB_UNKNOWN_ERROR;
+ return (ib_error_str[status]);
+}
+
+/*
+* PARAMETERS
+* status
+* [in] status value
+*
+* RETURN VALUES
+* Pointer to the status description string.
+*
+* NOTES
+*
+* SEE ALSO
+*********/
+
+/****d* Verbs/ib_async_event_t
+* NAME
+* ib_async_event_t -- Async event types
+*
+* DESCRIPTION
+* This type indicates the reason the async callback was called.
+* The context in the ib_event_rec_t indicates the resource context
+* that associated with the callback. For example, for IB_AE_CQ_ERROR
+* the context provided during the ib_create_cq is returned in the event.
+*
+* SYNOPSIS
+*/
+typedef enum _ib_async_event_t {
+ IB_AE_SQ_ERROR = 1,
+ IB_AE_SQ_DRAINED,
+ IB_AE_RQ_ERROR,
+ IB_AE_CQ_ERROR,
+ IB_AE_QP_FATAL,
+ IB_AE_QP_COMM,
+ IB_AE_QP_APM,
+ IB_AE_EEC_FATAL,
+ IB_AE_EEC_COMM,
+ IB_AE_EEC_APM,
+ IB_AE_LOCAL_FATAL,
+ IB_AE_PKEY_TRAP,
+ IB_AE_QKEY_TRAP,
+ IB_AE_MKEY_TRAP,
+ IB_AE_PORT_TRAP,
+ IB_AE_SYSIMG_GUID_TRAP,
+ IB_AE_BUF_OVERRUN,
+ IB_AE_LINK_INTEGRITY,
+ IB_AE_FLOW_CTRL_ERROR,
+ IB_AE_BKEY_TRAP,
+ IB_AE_QP_APM_ERROR,
+ IB_AE_EEC_APM_ERROR,
+ IB_AE_WQ_REQ_ERROR,
+ IB_AE_WQ_ACCESS_ERROR,
+ IB_AE_PORT_ACTIVE,
+ IB_AE_PORT_DOWN,
+ IB_AE_UNKNOWN /* ALWAYS LAST ENUM VALUE */
+} ib_async_event_t;
+/*
+* VALUES
+* IB_AE_SQ_ERROR
+* An error occurred when accessing the send queue of the QP or EEC.
+* This event is optional.
+*
+* IB_AE_SQ_DRAINED
+* The send queue of the specified QP has completed the outstanding
+* messages in progress when the state change was requested and, if
+* applicable, has received all acknowledgements for those messages.
+*
+* IB_AE_RQ_ERROR
+* An error occurred when accessing the receive queue of the QP or EEC.
+* This event is optional.
+*
+* IB_AE_CQ_ERROR
+* An error occurred when writing an entry to the CQ.
+*
+* IB_AE_QP_FATAL
+* A catastrophic error occurred while accessing or processing the
+* work queue that prevents reporting of completions.
+*
+* IB_AE_QP_COMM
+* The first packet has arrived for the receive work queue where the
+* QP is still in the RTR state.
+*
+* IB_AE_QP_APM
+* If alternate path migration is supported, this event indicates that
+* the QP connection has migrated to the alternate path.
+*
+* IB_AE_EEC_FATAL
+* If reliable datagram service is supported, this event indicates that
+* a catastrophic error occurred while accessing or processing the EEC
+* that prevents reporting of completions.
+*
+* IB_AE_EEC_COMM
+* If reliable datagram service is supported, this event indicates that
+* the first packet has arrived for the receive work queue where the
+* EEC is still in the RTR state.
+*
+* IB_AE_EEC_APM
+* If reliable datagram service and alternate path migration is supported,
+* this event indicates that the EEC connection has migrated to the
+* alternate path.
+*
+* IB_AE_LOCAL_FATAL
+* A catastrophic HCA error occurred which cannot be attributed to
+* any resource; behavior is indeterminate.
+*
+* IB_AE_PKEY_TRAP
+* A PKEY violation was detected. This event is optional.
+*
+* IB_AE_QKEY_TRAP
+* A QKEY violation was detected. This event is optional.
+*
+* IB_AE_MKEY_TRAP
+* A MKEY violation was detected. This event is optional.
+*
+* IB_AE_PORT_TRAP
+* A port capability change was detected. This event is optional.
+*
+* IB_AE_SYSIMG_GUID_TRAP
+* If the system image GUID is supported, this event indicates that
+* the system image GUID of this HCA has been changed. This event
+* is optional.
+*
+* IB_AE_BUF_OVERRUN
+* The number of consecutive flow control update periods with at least
+* one overrun error in each period has exceeded the threshold specified
+* in the port info attributes. This event is optional.
+*
+* IB_AE_LINK_INTEGRITY
+* The detection of excessively frequent local physical errors has
+* exceeded the threshold specified in the port info attributes. This
+* event is optional.
+*
+* IB_AE_FLOW_CTRL_ERROR
+* An HCA watchdog timer monitoring the arrival of flow control updates
+* has expired without receiving an update. This event is optional.
+*
+* IB_AE_BKEY_TRAP
+* An BKEY violation was detected. This event is optional.
+*
+* IB_AE_QP_APM_ERROR
+* If alternate path migration is supported, this event indicates that
+* an incoming path migration request to this QP was not accepted.
+*
+* IB_AE_EEC_APM_ERROR
+* If reliable datagram service and alternate path migration is supported,
+* this event indicates that an incoming path migration request to this
+* EEC was not accepted.
+*
+* IB_AE_WQ_REQ_ERROR
+* An OpCode violation was detected at the responder.
+*
+* IB_AE_WQ_ACCESS_ERROR
+* An access violation was detected at the responder.
+*
+* IB_AE_PORT_ACTIVE
+* If the port active event is supported, this event is generated
+* when the link becomes active: IB_LINK_ACTIVE.
+*
+* IB_AE_PORT_DOWN
+* The link is declared unavailable: IB_LINK_INIT, IB_LINK_ARMED,
+* IB_LINK_DOWN.
+*
+* IB_AE_UNKNOWN
+* An unknown error occurred which cannot be attributed to any
+* resource; behavior is indeterminate.
+*
+*****/
+
+OSM_EXPORT const char *ib_async_event_str[];
+
+/****f* IBA Base: Types/ib_get_async_event_str
+* NAME
+* ib_get_async_event_str
+*
+* DESCRIPTION
+* Returns a string for the specified asynchronous event.
+*
+* SYNOPSIS
+*/
+static inline const char *OSM_API
+ib_get_async_event_str(IN ib_async_event_t event)
+{
+ if (event > IB_AE_UNKNOWN)
+ event = IB_AE_UNKNOWN;
+ return (ib_async_event_str[event]);
+}
+
+/*
+* PARAMETERS
+* event
+* [in] event value
+*
+* RETURN VALUES
+* Pointer to the asynchronous event description string.
+*
+* NOTES
+*
+* SEE ALSO
+*********/
+
+/****s* Verbs/ib_event_rec_t
+* NAME
+* ib_event_rec_t -- Async event notification record
+*
+* DESCRIPTION
+* When an async event callback is made, this structure is passed to indicate
+* the type of event, the source of event that caused it, and the context
+* associated with this event.
+*
+* context -- Context of the resource that caused the event.
+* -- ca_context if this is a port/adapter event.
+* -- qp_context if the source is a QP event
+* -- cq_context if the source is a CQ event.
+* -- ee_context if the source is an EE event.
+*
+* SYNOPSIS
+*/
+typedef struct _ib_event_rec {
+ void *context;
+ ib_async_event_t type;
+ /* HCA vendor specific event information. */
+ uint64_t vendor_specific;
+ /* The following structures are valid only for trap types. */
+ union _trap {
+ struct {
+ uint16_t lid;
+ ib_net64_t port_guid;
+ uint8_t port_num;
+ /*
+ * The following structure is valid only for
+ * P_KEY, Q_KEY, and M_KEY violation traps.
+ */
+ struct {
+ uint8_t sl;
+ uint16_t src_lid;
+ uint16_t dest_lid;
+ union _key {
+ uint16_t pkey;
+ uint32_t qkey;
+ uint64_t mkey;
+ } key;
+ uint32_t src_qp;
+ uint32_t dest_qp;
+ ib_gid_t src_gid;
+ ib_gid_t dest_gid;
+ } violation;
+ } info;
+ ib_net64_t sysimg_guid;
+ } trap;
+} ib_event_rec_t;
+/*******/
+
+/****d* Access Layer/ib_atomic_t
+* NAME
+* ib_atomic_t
+*
+* DESCRIPTION
+* Indicates atomicity levels supported by an adapter.
+*
+* SYNOPSIS
+*/
+typedef enum _ib_atomic_t {
+ IB_ATOMIC_NONE,
+ IB_ATOMIC_LOCAL,
+ IB_ATOMIC_GLOBAL
+} ib_atomic_t;
+/*
+* VALUES
+* IB_ATOMIC_NONE
+* Atomic operations not supported.
+*
+* IB_ATOMIC_LOCAL
+* Atomic operations guaranteed between QPs of a single CA.
+*
+* IB_ATOMIC_GLOBAL
+* Atomic operations are guaranteed between CA and any other entity
+* in the system.
+*****/
+
+/****s* Access Layer/ib_port_cap_t
+* NAME
+* ib_port_cap_t
+*
+* DESCRIPTION
+* Indicates which management agents are currently available on the specified
+* port.
+*
+* SYNOPSIS
+*/
+typedef struct _ib_port_cap {
+ boolean_t cm;
+ boolean_t snmp;
+ boolean_t dev_mgmt;
+ boolean_t vend;
+ boolean_t sm;
+ boolean_t sm_disable;
+ boolean_t qkey_ctr;
+ boolean_t pkey_ctr;
+ boolean_t notice;
+ boolean_t trap;
+ boolean_t apm;
+ boolean_t slmap;
+ boolean_t pkey_nvram;
+ boolean_t mkey_nvram;
+ boolean_t sysguid;
+ boolean_t dr_notice;
+ boolean_t boot_mgmt;
+ boolean_t capm_notice;
+ boolean_t reinit;
+ boolean_t ledinfo;
+ boolean_t port_active;
+} ib_port_cap_t;
+/*****/
+
+/****d* Access Layer/ib_init_type_t
+* NAME
+* ib_init_type_t
+*
+* DESCRIPTION
+* If supported by the HCA, the type of initialization requested by
+* this port before SM moves it to the active or armed state. If the
+* SM implements reinitialization, it shall set these bits to indicate
+* the type of initialization performed prior to activating the port.
+* Otherwise, these bits shall be set to 0.
+*
+* SYNOPSIS
+*/
+typedef uint8_t ib_init_type_t;
+#define IB_INIT_TYPE_NO_LOAD 0x01
+#define IB_INIT_TYPE_PRESERVE_CONTENT 0x02
+#define IB_INIT_TYPE_PRESERVE_PRESENCE 0x04
+#define IB_INIT_TYPE_DO_NOT_RESUSCITATE 0x08
+/*****/
+
+/****s* Access Layer/ib_port_attr_mod_t
+* NAME
+* ib_port_attr_mod_t
+*
+* DESCRIPTION
+* Port attributes that may be modified.
+*
+* SYNOPSIS
+*/
+typedef struct _ib_port_attr_mod {
+ ib_port_cap_t cap;
+ uint16_t pkey_ctr;
+ uint16_t qkey_ctr;
+ ib_init_type_t init_type;
+ ib_net64_t system_image_guid;
+} ib_port_attr_mod_t;
+/*
+* SEE ALSO
+* ib_port_cap_t
+*****/
+
+/****s* Access Layer/ib_port_attr_t
+* NAME
+* ib_port_attr_t
+*
+* DESCRIPTION
+* Information about a port on a given channel adapter.
+*
+* SYNOPSIS
+*/
+typedef struct _ib_port_attr {
+ ib_net64_t port_guid;
+ uint8_t port_num;
+ uint8_t mtu;
+ uint64_t max_msg_size;
+ ib_net16_t lid;
+ uint8_t lmc;
+ /*
+ * LinkWidthSupported as defined in PortInfo. Required to calculate
+ * inter-packet delay (a.k.a. static rate).
+ */
+ uint8_t link_width_supported;
+ uint16_t max_vls;
+ ib_net16_t sm_lid;
+ uint8_t sm_sl;
+ uint8_t link_state;
+ ib_init_type_t init_type_reply; /* Optional */
+ /*
+ * subnet_timeout:
+ * The maximum expected subnet propagation delay to reach any port on
+ * the subnet. This value also determines the rate at which traps can
+ * be generated from this node.
+ *
+ * timeout = 4.096 microseconds * 2^subnet_timeout
+ */
+ uint8_t subnet_timeout;
+ ib_port_cap_t cap;
+ uint16_t pkey_ctr;
+ uint16_t qkey_ctr;
+ uint16_t num_gids;
+ uint16_t num_pkeys;
+ /*
+ * Pointers at the end of the structure to allow doing a simple
+ * memory comparison of contents up to the first pointer.
+ */
+ ib_gid_t *p_gid_table;
+ ib_net16_t *p_pkey_table;
+} ib_port_attr_t;
+/*
+* SEE ALSO
+* uint8_t, ib_port_cap_t, ib_link_states_t
+*****/
+
+/****s* Access Layer/ib_ca_attr_t
+* NAME
+* ib_ca_attr_t
+*
+* DESCRIPTION
+* Information about a channel adapter.
+*
+* SYNOPSIS
+*/
+typedef struct _ib_ca_attr {
+ ib_net64_t ca_guid;
+ uint32_t vend_id;
+ uint16_t dev_id;
+ uint16_t revision;
+ uint64_t fw_ver;
+ /*
+ * Total size of the ca attributes in bytes
+ */
+ uint32_t size;
+ uint32_t max_qps;
+ uint32_t max_wrs;
+ uint32_t max_sges;
+ uint32_t max_rd_sges;
+ uint32_t max_cqs;
+ uint32_t max_cqes;
+ uint32_t max_pds;
+ uint32_t init_regions;
+ uint64_t init_region_size;
+ uint32_t init_windows;
+ uint32_t max_addr_handles;
+ uint32_t max_partitions;
+ ib_atomic_t atomicity;
+ uint8_t max_qp_resp_res;
+ uint8_t max_eec_resp_res;
+ uint8_t max_resp_res;
+ uint8_t max_qp_init_depth;
+ uint8_t max_eec_init_depth;
+ uint32_t max_eecs;
+ uint32_t max_rdds;
+ uint32_t max_ipv6_qps;
+ uint32_t max_ether_qps;
+ uint32_t max_mcast_grps;
+ uint32_t max_mcast_qps;
+ uint32_t max_qps_per_mcast_grp;
+ uint32_t max_fmr;
+ uint32_t max_map_per_fmr;
+ /*
+ * local_ack_delay:
+ * Specifies the maximum time interval between the local CA receiving
+ * a message and the transmission of the associated ACK or NAK.
+ *
+ * timeout = 4.096 microseconds * 2^local_ack_delay
+ */
+ uint8_t local_ack_delay;
+ boolean_t bad_pkey_ctr_support;
+ boolean_t bad_qkey_ctr_support;
+ boolean_t raw_mcast_support;
+ boolean_t apm_support;
+ boolean_t av_port_check;
+ boolean_t change_primary_port;
+ boolean_t modify_wr_depth;
+ boolean_t current_qp_state_support;
+ boolean_t shutdown_port_capability;
+ boolean_t init_type_support;
+ boolean_t port_active_event_support;
+ boolean_t system_image_guid_support;
+ boolean_t hw_agents;
+ ib_net64_t system_image_guid;
+ uint32_t num_page_sizes;
+ uint8_t num_ports;
+ uint32_t *p_page_size;
+ ib_port_attr_t *p_port_attr;
+} ib_ca_attr_t;
+/*
+* FIELDS
+* ca_guid
+* GUID for this adapter.
+*
+* vend_id
+* IEEE vendor ID for this adapter
+*
+* dev_id
+* Device ID of this adapter. (typically from PCI device ID)
+*
+* revision
+* Revision ID of this adapter
+*
+* fw_ver
+* Device Firmware version.
+*
+* size
+* Total size in bytes for the HCA attributes. This size includes total
+* size required for all the variable members of the structure. If a
+* vendor requires to pass vendor specific fields beyond this structure,
+* the HCA vendor can choose to report a larger size. If a vendor is
+* reporting extended vendor specific features, they should also provide
+* appropriate access functions to aid with the required interpretation.
+*
+* max_qps
+* Maximum number of QP's supported by this HCA.
+*
+* max_wrs
+* Maximum number of work requests supported by this HCA.
+*
+* max_sges
+* Maximum number of scatter gather elements supported per work request.
+*
+* max_rd_sges
+* Maximum number of scatter gather elements supported for READ work
+* requests for a Reliable Datagram QP. This value must be zero if RD
+* service is not supported.
+*
+* max_cqs
+* Maximum number of Completion Queues supported.
+*
+* max_cqes
+* Maximum number of CQ elements supported per CQ.
+*
+* max_pds
+* Maximum number of protection domains supported.
+*
+* init_regions
+* Initial number of memory regions supported. These are only informative
+* values. HCA vendors can extended and grow these limits on demand.
+*
+* init_region_size
+* Initial limit on the size of the registered memory region.
+*
+* init_windows
+* Initial number of window entries supported.
+*
+* max_addr_handles
+* Maximum number of address handles supported.
+*
+* max_partitions
+* Maximum number of partitions supported.
+*
+* atomicity
+* Indicates level of atomic operations supported by this HCA.
+*
+* max_qp_resp_res
+* max_eec_resp_res
+* Maximum limit on number of responder resources for incoming RDMA
+* operations, on QPs and EEC's respectively.
+*
+* max_resp_res
+* Maximum number of responder resources per HCA, with this HCA used as
+* the target.
+*
+* max_qp_init_depth
+* max_eec_init_depth
+* Maximimum initiator depth per QP or EEC for initiating RDMA reads and
+* atomic operations.
+*
+* max_eecs
+* Maximimum number of EEC's supported by the HCA.
+*
+* max_rdds
+* Maximum number of Reliable datagram domains supported.
+*
+* max_ipv6_qps
+* max_ether_qps
+* Maximum number of IPV6 and raw ether QP's supported by this HCA.
+*
+* max_mcast_grps
+* Maximum number of multicast groups supported.
+*
+* max_mcast_qps
+* Maximum number of QP's that can support multicast operations.
+*
+* max_qps_per_mcast_grp
+* Maximum number of multicast QP's per multicast group.
+*
+* local_ack_delay
+* Specifies the maximum time interval between the local CA receiving
+* a message and the transmission of the associated ACK or NAK.
+* timeout = 4.096 microseconds * 2^local_ack_delay
+*
+* bad_pkey_ctr_support
+* bad_qkey_ctr_support
+* Indicates support for the bad pkey and qkey counters.
+*
+* raw_mcast_support
+* Indicates support for raw packet multicast.
+*
+* apm_support
+* Indicates support for Automatic Path Migration.
+*
+* av_port_check
+* Indicates ability to check port number in address handles.
+*
+* change_primary_port
+* Indicates ability to change primary port for a QP or EEC during a
+* SQD->RTS transition.
+*
+* modify_wr_depth
+* Indicates ability to modify QP depth during a modify QP operation.
+* Check the verb specification for permitted states.
+*
+* current_qp_state_support
+* Indicates ability of the HCA to support the current QP state modifier
+* during a modify QP operation.
+*
+* shutdown_port_capability
+* Shutdown port capability support indicator.
+*
+* init_type_support
+* Indicates init_type_reply and ability to set init_type is supported.
+*
+* port_active_event_support
+* Port active event support indicator.
+*
+* system_image_guid_support
+* System image GUID support indicator.
+*
+* hw_agents
+* Indicates SMA is implemented in HW.
+*
+* system_image_guid
+* Optional system image GUID. This field is valid only if the
+* system_image_guid_support flag is set.
+*
+* num_page_sizes
+* Indicates support for different page sizes supported by the HCA.
+* The variable size array can be obtained from p_page_size.
+*
+* num_ports
+* Number of physical ports supported on this HCA.
+*
+* p_page_size
+* Array holding different page size supported.
+*
+* p_port_attr
+* Array holding port attributes.
+*
+* NOTES
+* This structure contains the attributes of a channel adapter. Users must
+* call ib_copy_ca_attr to copy the contents of this structure to a new
+* memory region.
+*
+* SEE ALSO
+* ib_port_attr_t, ib_atomic_t, ib_copy_ca_attr
+*****/
+
+/****f* Access layer/ib_copy_ca_attr
+* NAME
+* ib_copy_ca_attr
+*
+* DESCRIPTION
+* Copies CA attributes.
+*
+* SYNOPSIS
+*/
+ib_ca_attr_t *ib_copy_ca_attr(IN ib_ca_attr_t * const p_dest,
+ IN const ib_ca_attr_t * const p_src);
+/*
+* PARAMETERS
+* p_dest
+* Pointer to the buffer that is the destination of the copy.
+*
+* p_src
+* Pointer to the CA attributes to copy.
+*
+* RETURN VALUE
+* Pointer to the copied CA attributes.
+*
+* NOTES
+* The buffer pointed to by the p_dest parameter must be at least the size
+* specified in the size field of the buffer pointed to by p_src.
+*
+* SEE ALSO
+* ib_ca_attr_t, ib_dup_ca_attr, ib_free_ca_attr
+*****/
+
+/****s* Access Layer/ib_av_attr_t
+* NAME
+* ib_av_attr_t
+*
+* DESCRIPTION
+* IBA address vector.
+*
+* SYNOPSIS
+*/
+typedef struct _ib_av_attr {
+ uint8_t port_num;
+ uint8_t sl;
+ ib_net16_t dlid;
+ boolean_t grh_valid;
+ ib_grh_t grh;
+ uint8_t static_rate;
+ uint8_t path_bits;
+ struct _av_conn {
+ uint8_t path_mtu;
+ uint8_t local_ack_timeout;
+ uint8_t seq_err_retry_cnt;
+ uint8_t rnr_retry_cnt;
+ } conn;
+} ib_av_attr_t;
+/*
+* SEE ALSO
+* ib_gid_t
+*****/
+
+/****d* Access Layer/ib_qp_type_t
+* NAME
+* ib_qp_type_t
+*
+* DESCRIPTION
+* Indicates the type of queue pair being created.
+*
+* SYNOPSIS
+*/
+typedef enum _ib_qp_type {
+ IB_QPT_RELIABLE_CONN = 0, /* Matches CM REQ transport type */
+ IB_QPT_UNRELIABLE_CONN = 1, /* Matches CM REQ transport type */
+ IB_QPT_RELIABLE_DGRM = 2, /* Matches CM REQ transport type */
+ IB_QPT_UNRELIABLE_DGRM,
+ IB_QPT_QP0,
+ IB_QPT_QP1,
+ IB_QPT_RAW_IPV6,
+ IB_QPT_RAW_ETHER,
+ IB_QPT_MAD, /* InfiniBand Access Layer */
+ IB_QPT_QP0_ALIAS, /* InfiniBand Access Layer */
+ IB_QPT_QP1_ALIAS /* InfiniBand Access Layer */
+} ib_qp_type_t;
+/*
+* VALUES
+* IB_QPT_RELIABLE_CONN
+* Reliable, connected queue pair.
+*
+* IB_QPT_UNRELIABLE_CONN
+* Unreliable, connected queue pair.
+*
+* IB_QPT_RELIABLE_DGRM
+* Reliable, datagram queue pair.
+*
+* IB_QPT_UNRELIABLE_DGRM
+* Unreliable, datagram queue pair.
+*
+* IB_QPT_QP0
+* Queue pair 0.
+*
+* IB_QPT_QP1
+* Queue pair 1.
+*
+* IB_QPT_RAW_DGRM
+* Raw datagram queue pair.
+*
+* IB_QPT_RAW_IPV6
+* Raw IP version 6 queue pair.
+*
+* IB_QPT_RAW_ETHER
+* Raw Ethernet queue pair.
+*
+* IB_QPT_MAD
+* Unreliable, datagram queue pair that will send and receive management
+* datagrams with assistance from the access layer.
+*
+* IB_QPT_QP0_ALIAS
+* Alias to queue pair 0. Aliased QPs can only be created on an aliased
+* protection domain.
+*
+* IB_QPT_QP1_ALIAS
+* Alias to queue pair 1. Aliased QPs can only be created on an aliased
+* protection domain.
+*****/
+
+/****d* Access Layer/ib_access_t
+* NAME
+* ib_access_t
+*
+* DESCRIPTION
+* Indicates the type of access is permitted on resources such as QPs,
+* memory regions and memory windows.
+*
+* SYNOPSIS
+*/
+typedef uint32_t ib_access_t;
+#define IB_AC_RDMA_READ 0x00000001
+#define IB_AC_RDMA_WRITE 0x00000002
+#define IB_AC_ATOMIC 0x00000004
+#define IB_AC_LOCAL_WRITE 0x00000008
+#define IB_AC_MW_BIND 0x00000010
+/*
+* NOTES
+* Users may combine access rights using a bit-wise or operation to specify
+* additional access. For example: IB_AC_RDMA_READ | IB_AC_RDMA_WRITE grants
+* RDMA read and write access.
+*****/
+
+/****d* Access Layer/ib_qp_state_t
+* NAME
+* ib_qp_state_t
+*
+* DESCRIPTION
+* Indicates or sets the state of a queue pair. The current state of a queue
+* pair is returned through the ib_qp_query call and set via the
+* ib_qp_modify call.
+*
+* SYNOPSIS
+*/
+typedef uint32_t ib_qp_state_t;
+#define IB_QPS_RESET 0x00000001
+#define IB_QPS_INIT 0x00000002
+#define IB_QPS_RTR 0x00000004
+#define IB_QPS_RTS 0x00000008
+#define IB_QPS_SQD 0x00000010
+#define IB_QPS_SQD_DRAINING 0x00000030
+#define IB_QPS_SQD_DRAINED 0x00000050
+#define IB_QPS_SQERR 0x00000080
+#define IB_QPS_ERROR 0x00000100
+#define IB_QPS_TIME_WAIT 0xDEAD0000 /* InfiniBand Access Layer */
+/*****/
+
+/****d* Access Layer/ib_apm_state_t
+* NAME
+* ib_apm_state_t
+*
+* DESCRIPTION
+* The current automatic path migration state of a queue pair
+*
+* SYNOPSIS
+*/
+typedef enum _ib_apm_state {
+ IB_APM_MIGRATED = 1,
+ IB_APM_REARM,
+ IB_APM_ARMED
+} ib_apm_state_t;
+/*****/
+
+/****s* Access Layer/ib_qp_create_t
+* NAME
+* ib_qp_create_t
+*
+* DESCRIPTION
+* Attributes used to initialize a queue pair at creation time.
+*
+* SYNOPSIS
+*/
+typedef struct _ib_qp_create {
+ ib_qp_type_t qp_type;
+ ib_rdd_handle_t h_rdd;
+ uint32_t sq_depth;
+ uint32_t rq_depth;
+ uint32_t sq_sge;
+ uint32_t rq_sge;
+ ib_cq_handle_t h_sq_cq;
+ ib_cq_handle_t h_rq_cq;
+ boolean_t sq_signaled;
+} ib_qp_create_t;
+/*
+* FIELDS
+* type
+* Specifies the type of queue pair to create.
+*
+* h_rdd
+* A handle to a reliable datagram domain to associate with the queue
+* pair. This field is ignored if the queue pair is not a reliable
+* datagram type queue pair.
+*
+* sq_depth
+* Indicates the requested maximum number of work requests that may be
+* outstanding on the queue pair's send queue. This value must be less
+* than or equal to the maximum reported by the channel adapter associated
+* with the queue pair.
+*
+* rq_depth
+* Indicates the requested maximum number of work requests that may be
+* outstanding on the queue pair's receive queue. This value must be less
+* than or equal to the maximum reported by the channel adapter associated
+* with the queue pair.
+*
+* sq_sge
+* Indicates the maximum number scatter-gather elements that may be
+* given in a send work request. This value must be less
+* than or equal to the maximum reported by the channel adapter associated
+* with the queue pair.
+*
+* rq_sge
+* Indicates the maximum number scatter-gather elements that may be
+* given in a receive work request. This value must be less
+* than or equal to the maximum reported by the channel adapter associated
+* with the queue pair.
+*
+* h_sq_cq
+* A handle to the completion queue that will be used to report send work
+* request completions. This handle must be NULL if the type is
+* IB_QPT_MAD, IB_QPT_QP0_ALIAS, or IB_QPT_QP1_ALIAS.
+*
+* h_rq_cq
+* A handle to the completion queue that will be used to report receive
+* work request completions. This handle must be NULL if the type is
+* IB_QPT_MAD, IB_QPT_QP0_ALIAS, or IB_QPT_QP1_ALIAS.
+*
+* sq_signaled
+* A flag that is used to indicate whether the queue pair will signal
+* an event upon completion of a send work request. If set to
+* TRUE, send work requests will always generate a completion
+* event. If set to FALSE, a completion event will only be
+* generated if the send_opt field of the send work request has the
+* IB_SEND_OPT_SIGNALED flag set.
+*
+* SEE ALSO
+* ib_qp_type_t, ib_qp_attr_t
+*****/
+
+/****s* Access Layer/ib_qp_attr_t
+* NAME
+* ib_qp_attr_t
+*
+* DESCRIPTION
+* Queue pair attributes returned through ib_query_qp.
+*
+* SYNOPSIS
+*/
+typedef struct _ib_qp_attr {
+ ib_pd_handle_t h_pd;
+ ib_qp_type_t qp_type;
+ ib_access_t access_ctrl;
+ uint16_t pkey_index;
+ uint32_t sq_depth;
+ uint32_t rq_depth;
+ uint32_t sq_sge;
+ uint32_t rq_sge;
+ uint8_t init_depth;
+ uint8_t resp_res;
+ ib_cq_handle_t h_sq_cq;
+ ib_cq_handle_t h_rq_cq;
+ ib_rdd_handle_t h_rdd;
+ boolean_t sq_signaled;
+ ib_qp_state_t state;
+ ib_net32_t num;
+ ib_net32_t dest_num;
+ ib_net32_t qkey;
+ ib_net32_t sq_psn;
+ ib_net32_t rq_psn;
+ uint8_t primary_port;
+ uint8_t alternate_port;
+ ib_av_attr_t primary_av;
+ ib_av_attr_t alternate_av;
+ ib_apm_state_t apm_state;
+} ib_qp_attr_t;
+/*
+* FIELDS
+* h_pd
+* This is a handle to a protection domain associated with the queue
+* pair, or NULL if the queue pair is type IB_QPT_RELIABLE_DGRM.
+*
+* NOTES
+* Other fields are defined by the Infiniband specification.
+*
+* SEE ALSO
+* ib_qp_type_t, ib_access_t, ib_qp_state_t, ib_av_attr_t, ib_apm_state_t
+*****/
+
+/****d* Access Layer/ib_qp_opts_t
+* NAME
+* ib_qp_opts_t
+*
+* DESCRIPTION
+* Optional fields supplied in the modify QP operation.
+*
+* SYNOPSIS
+*/
+typedef uint32_t ib_qp_opts_t;
+#define IB_MOD_QP_ALTERNATE_AV 0x00000001
+#define IB_MOD_QP_PKEY 0x00000002
+#define IB_MOD_QP_APM_STATE 0x00000004
+#define IB_MOD_QP_PRIMARY_AV 0x00000008
+#define IB_MOD_QP_RNR_NAK_TIMEOUT 0x00000010
+#define IB_MOD_QP_RESP_RES 0x00000020
+#define IB_MOD_QP_INIT_DEPTH 0x00000040
+#define IB_MOD_QP_PRIMARY_PORT 0x00000080
+#define IB_MOD_QP_ACCESS_CTRL 0x00000100
+#define IB_MOD_QP_QKEY 0x00000200
+#define IB_MOD_QP_SQ_DEPTH 0x00000400
+#define IB_MOD_QP_RQ_DEPTH 0x00000800
+#define IB_MOD_QP_CURRENT_STATE 0x00001000
+#define IB_MOD_QP_RETRY_CNT 0x00002000
+#define IB_MOD_QP_LOCAL_ACK_TIMEOUT 0x00004000
+#define IB_MOD_QP_RNR_RETRY_CNT 0x00008000
+/*
+* SEE ALSO
+* ib_qp_mod_t
+*****/
+
+/****s* Access Layer/ib_qp_mod_t
+* NAME
+* ib_qp_mod_t
+*
+* DESCRIPTION
+* Information needed to change the state of a queue pair through the
+* ib_modify_qp call.
+*
+* SYNOPSIS
+*/
+typedef struct _ib_qp_mod {
+ ib_qp_state_t req_state;
+ union _qp_state {
+ struct _qp_reset {
+ /*
+ * Time, in milliseconds, that the QP needs to spend in
+ * the time wait state before being reused.
+ */
+ uint32_t timewait;
+ } reset;
+ struct _qp_init {
+ ib_qp_opts_t opts;
+ uint8_t primary_port;
+ ib_net32_t qkey;
+ uint16_t pkey_index;
+ ib_access_t access_ctrl;
+ } init;
+ struct _qp_rtr {
+ ib_net32_t rq_psn;
+ ib_net32_t dest_qp;
+ ib_av_attr_t primary_av;
+ uint8_t resp_res;
+ ib_qp_opts_t opts;
+ ib_av_attr_t alternate_av;
+ ib_net32_t qkey;
+ uint16_t pkey_index;
+ ib_access_t access_ctrl;
+ uint32_t sq_depth;
+ uint32_t rq_depth;
+ uint8_t rnr_nak_timeout;
+ } rtr;
+ struct _qp_rts {
+ ib_net32_t sq_psn;
+ uint8_t retry_cnt;
+ uint8_t rnr_retry_cnt;
+ uint8_t rnr_nak_timeout;
+ uint8_t local_ack_timeout;
+ uint8_t init_depth;
+ ib_qp_opts_t opts;
+ ib_qp_state_t current_state;
+ ib_net32_t qkey;
+ ib_access_t access_ctrl;
+ uint8_t resp_res;
+ ib_av_attr_t primary_av;
+ ib_av_attr_t alternate_av;
+ uint32_t sq_depth;
+ uint32_t rq_depth;
+ ib_apm_state_t apm_state;
+ uint8_t primary_port;
+ uint16_t pkey_index;
+ } rts;
+ struct _qp_sqd {
+ boolean_t sqd_event;
+ } sqd;
+ } state;
+} ib_qp_mod_t;
+/*
+* SEE ALSO
+* ib_qp_state_t, ib_access_t, ib_av_attr_t, ib_apm_state_t
+*****/
+
+/****s* Access Layer/ib_eec_attr_t
+* NAME
+* ib_eec_attr_t
+*
+* DESCRIPTION
+* Information about an end-to-end context.
+*
+* SYNOPSIS
+*/
+typedef struct _ib_eec_attr {
+ ib_qp_state_t state;
+ ib_rdd_handle_t h_rdd;
+ ib_net32_t local_eecn;
+ ib_net32_t sq_psn;
+ ib_net32_t rq_psn;
+ uint8_t primary_port;
+ uint16_t pkey_index;
+ uint32_t resp_res;
+ ib_net32_t remote_eecn;
+ uint32_t init_depth;
+ uint32_t dest_num; // ??? What is this?
+ ib_av_attr_t primary_av;
+ ib_av_attr_t alternate_av;
+ ib_apm_state_t apm_state;
+} ib_eec_attr_t;
+/*
+* SEE ALSO
+* ib_qp_state_t, ib_av_attr_t, ib_apm_state_t
+*****/
+
+/****d* Access Layer/ib_eec_opts_t
+* NAME
+* ib_eec_opts_t
+*
+* DESCRIPTION
+* Optional fields supplied in the modify EEC operation.
+*
+* SYNOPSIS
+*/
+typedef uint32_t ib_eec_opts_t;
+#define IB_MOD_EEC_ALTERNATE_AV 0x00000001
+#define IB_MOD_EEC_PKEY 0x00000002
+#define IB_MOD_EEC_APM_STATE 0x00000004
+#define IB_MOD_EEC_PRIMARY_AV 0x00000008
+#define IB_MOD_EEC_RNR 0x00000010
+#define IB_MOD_EEC_RESP_RES 0x00000020
+#define IB_MOD_EEC_OUTSTANDING 0x00000040
+#define IB_MOD_EEC_PRIMARY_PORT 0x00000080
+/*
+* NOTES
+*
+*
+*****/
+
+/****s* Access Layer/ib_eec_mod_t
+* NAME
+* ib_eec_mod_t
+*
+* DESCRIPTION
+* Information needed to change the state of an end-to-end context through
+* the ib_modify_eec function.
+*
+* SYNOPSIS
+*/
+typedef struct _ib_eec_mod {
+ ib_qp_state_t req_state;
+ union _eec_state {
+ struct _eec_init {
+ uint8_t primary_port;
+ uint16_t pkey_index;
+ } init;
+ struct _eec_rtr {
+ ib_net32_t rq_psn;
+ ib_net32_t remote_eecn;
+ ib_av_attr_t primary_av;
+ uint8_t resp_res;
+ ib_eec_opts_t opts;
+ ib_av_attr_t alternate_av;
+ uint16_t pkey_index;
+ } rtr;
+ struct _eec_rts {
+ ib_net32_t sq_psn;
+ uint8_t retry_cnt;
+ uint8_t rnr_retry_cnt;
+ uint8_t local_ack_timeout;
+ uint8_t init_depth;
+ ib_eec_opts_t opts;
+ ib_av_attr_t alternate_av;
+ ib_apm_state_t apm_state;
+ ib_av_attr_t primary_av;
+ uint16_t pkey_index;
+ uint8_t primary_port;
+ } rts;
+ struct _eec_sqd {
+ boolean_t sqd_event;
+ } sqd;
+ } state;
+} ib_eec_mod_t;
+/*
+* SEE ALSO
+* ib_qp_state_t, ib_av_attr_t, ib_apm_state_t
+*****/
+
+/****d* Access Layer/ib_wr_type_t
+* NAME
+* ib_wr_type_t
+*
+* DESCRIPTION
+* Identifies the type of work request posted to a queue pair.
+*
+* SYNOPSIS
+*/
+typedef enum _ib_wr_type_t {
+ WR_SEND = 1,
+ WR_RDMA_WRITE,
+ WR_RDMA_READ,
+ WR_COMPARE_SWAP,
+ WR_FETCH_ADD
+} ib_wr_type_t;
+/*****/
+
+/****s* Access Layer/ib_local_ds_t
+* NAME
+* ib_local_ds_t
+*
+* DESCRIPTION
+* Local data segment information referenced by send and receive work
+* requests. This is used to specify local data buffers used as part of a
+* work request.
+*
+* SYNOPSIS
+*/
+typedef struct _ib_local_ds {
+ void *vaddr;
+ uint32_t length;
+ uint32_t lkey;
+} ib_local_ds_t;
+/*****/
+
+/****d* Access Layer/ib_send_opt_t
+* NAME
+* ib_send_opt_t
+*
+* DESCRIPTION
+* Optional flags used when posting send work requests. These flags
+* indicate specific processing for the send operation.
+*
+* SYNOPSIS
+*/
+typedef uint32_t ib_send_opt_t;
+#define IB_SEND_OPT_IMMEDIATE 0x00000001
+#define IB_SEND_OPT_FENCE 0x00000002
+#define IB_SEND_OPT_SIGNALED 0x00000004
+#define IB_SEND_OPT_SOLICITED 0x00000008
+#define IB_SEND_OPT_INLINE 0x00000010
+#define IB_SEND_OPT_LOCAL 0x00000020
+#define IB_SEND_OPT_VEND_MASK 0xFFFF0000
+/*
+* VALUES
+* The following flags determine the behavior of a work request when
+* posted to the send side.
+*
+* IB_SEND_OPT_IMMEDIATE
+* Send immediate data with the given request.
+*
+* IB_SEND_OPT_FENCE
+* The operation is fenced. Complete all pending send operations
+* before processing this request.
+*
+* IB_SEND_OPT_SIGNALED
+* If the queue pair is configured for signaled completion, then
+* generate a completion queue entry when this request completes.
+*
+* IB_SEND_OPT_SOLICITED
+* Set the solicited bit on the last packet of this request.
+*
+* IB_SEND_OPT_INLINE
+* Indicates that the requested send data should be copied into a VPD
+* owned data buffer. This flag permits the user to issue send operations
+* without first needing to register the buffer(s) associated with the
+* send operation. Verb providers that support this operation may place
+* vendor specific restrictions on the size of send operation that may
+* be performed as inline.
+*
+*
+* IB_SEND_OPT_LOCAL
+* Indicates that a sent MAD request should be given to the local VPD for
+* processing. MADs sent using this option are not placed on the wire.
+* This send option is only valid for MAD send operations.
+*
+*
+* IB_SEND_OPT_VEND_MASK
+* This mask indicates bits reserved in the send options that may be used
+* by the verbs provider to indicate vendor specific options. Bits set
+* in this area of the send options are ignored by the Access Layer, but
+* may have specific meaning to the underlying VPD.
+*
+*****/
+
+/****s* Access Layer/ib_send_wr_t
+* NAME
+* ib_send_wr_t
+*
+* DESCRIPTION
+* Information used to submit a work request to the send queue of a queue
+* pair.
+*
+* SYNOPSIS
+*/
+typedef struct _ib_send_wr {
+ struct _ib_send_wr *p_next;
+ uint64_t wr_id;
+ ib_wr_type_t wr_type;
+ ib_send_opt_t send_opt;
+ uint32_t num_ds;
+ ib_local_ds_t *ds_array;
+ ib_net32_t immediate_data;
+ union _send_dgrm {
+ struct _send_ud {
+ ib_net32_t remote_qp;
+ ib_net32_t remote_qkey;
+ ib_av_handle_t h_av;
+ } ud;
+ struct _send_rd {
+ ib_net32_t remote_qp;
+ ib_net32_t remote_qkey;
+ ib_net32_t eecn;
+ } rd;
+ struct _send_raw_ether {
+ ib_net16_t dest_lid;
+ uint8_t path_bits;
+ uint8_t sl;
+ uint8_t max_static_rate;
+ ib_net16_t ether_type;
+ } raw_ether;
+ struct _send_raw_ipv6 {
+ ib_net16_t dest_lid;
+ uint8_t path_bits;
+ uint8_t sl;
+ uint8_t max_static_rate;
+ } raw_ipv6;
+ } dgrm;
+ struct _send_remote_ops {
+ uint64_t vaddr;
+ uint32_t rkey;
+ ib_net64_t atomic1;
+ ib_net64_t atomic2;
+ } remote_ops;
+} ib_send_wr_t;
+/*
+* FIELDS
+* p_next
+* A pointer used to chain work requests together. This permits multiple
+* work requests to be posted to a queue pair through a single function
+* call. This value is set to NULL to mark the end of the chain.
+*
+* wr_id
+* A 64-bit work request identifier that is returned to the consumer
+* as part of the work completion.
+*
+* wr_type
+* The type of work request being submitted to the send queue.
+*
+* send_opt
+* Optional send control parameters.
+*
+* num_ds
+* Number of local data segments specified by this work request.
+*
+* ds_array
+* A reference to an array of local data segments used by the send
+* operation.
+*
+* immediate_data
+* 32-bit field sent as part of a message send or RDMA write operation.
+* This field is only valid if the send_opt flag IB_SEND_OPT_IMMEDIATE
+* has been set.
+*
+* dgrm.ud.remote_qp
+* Identifies the destination queue pair of an unreliable datagram send
+* operation.
+*
+* dgrm.ud.remote_qkey
+* The qkey for the destination queue pair.
+*
+* dgrm.ud.h_av
+* An address vector that specifies the path information used to route
+* the outbound datagram to the destination queue pair.
+*
+* dgrm.rd.remote_qp
+* Identifies the destination queue pair of a reliable datagram send
+* operation.
+*
+* dgrm.rd.remote_qkey
+* The qkey for the destination queue pair.
+*
+* dgrm.rd.eecn
+* The local end-to-end context number to use with the reliable datagram
+* send operation.
+*
+* dgrm.raw_ether.dest_lid
+* The destination LID that will receive this raw ether send.
+*
+* dgrm.raw_ether.path_bits
+* path bits...
+*
+* dgrm.raw_ether.sl
+* service level...
+*
+* dgrm.raw_ether.max_static_rate
+* static rate...
+*
+* dgrm.raw_ether.ether_type
+* ether type...
+*
+* dgrm.raw_ipv6.dest_lid
+* The destination LID that will receive this raw ether send.
+*
+* dgrm.raw_ipv6.path_bits
+* path bits...
+*
+* dgrm.raw_ipv6.sl
+* service level...
+*
+* dgrm.raw_ipv6.max_static_rate
+* static rate...
+*
+* remote_ops.vaddr
+* The registered virtual memory address of the remote memory to access
+* with an RDMA or atomic operation.
+*
+* remote_ops.rkey
+* The rkey associated with the specified remote vaddr. This data must
+* be presented exactly as obtained from the remote node. No swapping
+* of data must be performed.
+*
+* atomic1
+* The first operand for an atomic operation.
+*
+* atomic2
+* The second operand for an atomic operation.
+*
+* NOTES
+* The format of data sent over the fabric is user-defined and is considered
+* opaque to the access layer. The sole exception to this are MADs posted
+* to a MAD QP service. MADs are expected to match the format defined by
+* the Infiniband specification and must be in network-byte order when posted
+* to the MAD QP service.
+*
+* SEE ALSO
+* ib_wr_type_t, ib_local_ds_t, ib_send_opt_t
+*****/
+
+/****s* Access Layer/ib_recv_wr_t
+* NAME
+* ib_recv_wr_t
+*
+* DESCRIPTION
+* Information used to submit a work request to the receive queue of a queue
+* pair.
+*
+* SYNOPSIS
+*/
+typedef struct _ib_recv_wr {
+ struct _ib_recv_wr *p_next;
+ uint64_t wr_id;
+ uint32_t num_ds;
+ ib_local_ds_t *ds_array;
+} ib_recv_wr_t;
+/*
+* FIELDS
+* p_next
+* A pointer used to chain work requests together. This permits multiple
+* work requests to be posted to a queue pair through a single function
+* call. This value is set to NULL to mark the end of the chain.
+*
+* wr_id
+* A 64-bit work request identifier that is returned to the consumer
+* as part of the work completion.
+*
+* num_ds
+* Number of local data segments specified by this work request.
+*
+* ds_array
+* A reference to an array of local data segments used by the send
+* operation.
+*
+* SEE ALSO
+* ib_local_ds_t
+*****/
+
+/****s* Access Layer/ib_bind_wr_t
+* NAME
+* ib_bind_wr_t
+*
+* DESCRIPTION
+* Information used to submit a memory window bind work request to the send
+* queue of a queue pair.
+*
+* SYNOPSIS
+*/
+typedef struct _ib_bind_wr {
+ uint64_t wr_id;
+ ib_send_opt_t send_opt;
+ ib_mr_handle_t h_mr;
+ ib_access_t access_ctrl;
+ uint32_t current_rkey;
+ ib_local_ds_t local_ds;
+} ib_bind_wr_t;
+/*
+* FIELDS
+* wr_id
+* A 64-bit work request identifier that is returned to the consumer
+* as part of the work completion.
+*
+* send_opt
+* Optional send control parameters.
+*
+* h_mr
+* Handle to the memory region to which this window is being bound.
+*
+* access_ctrl
+* Access rights for this memory window.
+*
+* current_rkey
+* The current rkey assigned to this window for remote access.
+*
+* local_ds
+* A reference to a local data segment used by the bind operation.
+*
+* SEE ALSO
+* ib_send_opt_t, ib_access_t, ib_local_ds_t
+*****/
+
+/****d* Access Layer/ib_wc_status_t
+* NAME
+* ib_wc_status_t
+*
+* DESCRIPTION
+* Indicates the status of a completed work request. These VALUES are
+* returned to the user when retrieving completions. Note that success is
+* identified as IB_WCS_SUCCESS, which is always zero.
+*
+* SYNOPSIS
+*/
+typedef enum _ib_wc_status_t {
+ IB_WCS_SUCCESS,
+ IB_WCS_LOCAL_LEN_ERR,
+ IB_WCS_LOCAL_OP_ERR,
+ IB_WCS_LOCAL_EEC_OP_ERR,
+ IB_WCS_LOCAL_PROTECTION_ERR,
+ IB_WCS_WR_FLUSHED_ERR,
+ IB_WCS_MEM_WINDOW_BIND_ERR,
+ IB_WCS_REM_ACCESS_ERR,
+ IB_WCS_REM_OP_ERR,
+ IB_WCS_RNR_RETRY_ERR,
+ IB_WCS_TIMEOUT_RETRY_ERR,
+ IB_WCS_REM_INVALID_REQ_ERR,
+ IB_WCS_REM_INVALID_RD_REQ_ERR,
+ IB_WCS_INVALID_EECN,
+ IB_WCS_INVALID_EEC_STATE,
+ IB_WCS_UNMATCHED_RESPONSE, /* InfiniBand Access Layer */
+ IB_WCS_CANCELED, /* InfiniBand Access Layer */
+ IB_WCS_UNKNOWN /* Must be last. */
+} ib_wc_status_t;
+/*
+* VALUES
+* IB_WCS_SUCCESS
+* Work request completed successfully.
+*
+* IB_WCS_MAD
+* The completed work request was associated with a managmenet datagram
+* that requires post processing. The MAD will be returned to the user
+* through a callback once all post processing has completed.
+*
+* IB_WCS_LOCAL_LEN_ERR
+* Generated for a work request posted to the send queue when the
+* total of the data segment lengths exceeds the message length of the
+* channel. Generated for a work request posted to the receive queue when
+* the total of the data segment lengths is too small for a
+* valid incoming message.
+*
+* IB_WCS_LOCAL_OP_ERR
+* An internal QP consistency error was generated while processing this
+* work request. This may indicate that the QP was in an incorrect state
+* for the requested operation.
+*
+* IB_WCS_LOCAL_EEC_OP_ERR
+* An internal EEC consistency error was generated while processing
+* this work request. This may indicate that the EEC was in an incorrect
+* state for the requested operation.
+*
+* IB_WCS_LOCAL_PROTECTION_ERR
+* The data segments of the locally posted work request did not refer to
+* a valid memory region. The memory may not have been properly
+* registered for the requested operation.
+*
+* IB_WCS_WR_FLUSHED_ERR
+* The work request was flushed from the QP before being completed.
+*
+* IB_WCS_MEM_WINDOW_BIND_ERR
+* A memory window bind operation failed due to insufficient access
+* rights.
+*
+* IB_WCS_REM_ACCESS_ERR,
+* A protection error was detected at the remote node for a RDMA or atomic
+* operation.
+*
+* IB_WCS_REM_OP_ERR,
+* The operation could not be successfully completed at the remote node.
+* This may indicate that the remote QP was in an invalid state or
+* contained an invalid work request.
+*
+* IB_WCS_RNR_RETRY_ERR,
+* The RNR retry count was exceeded while trying to send this message.
+*
+* IB_WCS_TIMEOUT_RETRY_ERR
+* The local transport timeout counter expired while trying to send this
+* message.
+*
+* IB_WCS_REM_INVALID_REQ_ERR,
+* The remote node detected an invalid message on the channel. This error
+* is usually a result of one of the following:
+* - The operation was not supported on receive queue.
+* - There was insufficient buffers to receive a new RDMA request.
+* - There was insufficient buffers to receive a new atomic operation.
+* - An RDMA request was larger than 2^31 bytes.
+*
+* IB_WCS_REM_INVALID_RD_REQ_ERR,
+* Responder detected an invalid RD message. This may be the result of an
+* invalid qkey or an RDD mismatch.
+*
+* IB_WCS_INVALID_EECN
+* An invalid EE context number was detected.
+*
+* IB_WCS_INVALID_EEC_STATE
+* The EEC was in an invalid state for the specified request.
+*
+* IB_WCS_UNMATCHED_RESPONSE
+* A response MAD was received for which there was no matching send. The
+* send operation may have been canceled by the user or may have timed
+* out.
+*
+* IB_WCS_CANCELED
+* The completed work request was canceled by the user.
+*****/
+
+OSM_EXPORT const char *ib_wc_status_str[];
+
+/****f* IBA Base: Types/ib_get_wc_status_str
+* NAME
+* ib_get_wc_status_str
+*
+* DESCRIPTION
+* Returns a string for the specified work completion status.
+*
+* SYNOPSIS
+*/
+static inline const char *OSM_API
+ib_get_wc_status_str(IN ib_wc_status_t wc_status)
+{
+ if (wc_status > IB_WCS_UNKNOWN)
+ wc_status = IB_WCS_UNKNOWN;
+ return (ib_wc_status_str[wc_status]);
+}
+
+/*
+* PARAMETERS
+* wc_status
+* [in] work completion status value
+*
+* RETURN VALUES
+* Pointer to the work completion status description string.
+*
+* NOTES
+*
+* SEE ALSO
+*********/
+
+/****d* Access Layer/ib_wc_type_t
+* NAME
+* ib_wc_type_t
+*
+* DESCRIPTION
+* Indicates the type of work completion.
+*
+* SYNOPSIS
+*/
+typedef enum _ib_wc_type_t {
+ IB_WC_SEND,
+ IB_WC_RDMA_WRITE,
+ IB_WC_RECV,
+ IB_WC_RDMA_READ,
+ IB_WC_MW_BIND,
+ IB_WC_FETCH_ADD,
+ IB_WC_COMPARE_SWAP,
+ IB_WC_RECV_RDMA_WRITE
+} ib_wc_type_t;
+/*****/
+
+/****d* Access Layer/ib_recv_opt_t
+* NAME
+* ib_recv_opt_t
+*
+* DESCRIPTION
+* Indicates optional fields valid in a receive work completion.
+*
+* SYNOPSIS
+*/
+typedef uint32_t ib_recv_opt_t;
+#define IB_RECV_OPT_IMMEDIATE 0x00000001
+#define IB_RECV_OPT_FORWARD 0x00000002
+#define IB_RECV_OPT_GRH_VALID 0x00000004
+#define IB_RECV_OPT_VEND_MASK 0xFFFF0000
+/*
+* VALUES
+* IB_RECV_OPT_IMMEDIATE
+* Indicates that immediate data is valid for this work completion.
+*
+* IB_RECV_OPT_FORWARD
+* Indicates that the received trap should be forwarded to the SM.
+*
+* IB_RECV_OPT_GRH_VALID
+* Indicates presence of the global route header. When set, the
+* first 40 bytes received are the GRH.
+*
+* IB_RECV_OPT_VEND_MASK
+* This mask indicates bits reserved in the receive options that may be
+* used by the verbs provider to indicate vendor specific options. Bits
+* set in this area of the receive options are ignored by the Access Layer,
+* but may have specific meaning to the underlying VPD.
+*****/
+
+/****s* Access Layer/ib_wc_t
+* NAME
+* ib_wc_t
+*
+* DESCRIPTION
+* Work completion information.
+*
+* SYNOPSIS
+*/
+typedef struct _ib_wc {
+ struct _ib_wc *p_next;
+ uint64_t wr_id;
+ ib_wc_type_t wc_type;
+ uint32_t length;
+ ib_wc_status_t status;
+ uint64_t vendor_specific;
+ union _wc_recv {
+ struct _wc_conn {
+ ib_recv_opt_t recv_opt;
+ ib_net32_t immediate_data;
+ } conn;
+ struct _wc_ud {
+ ib_recv_opt_t recv_opt;
+ ib_net32_t immediate_data;
+ ib_net32_t remote_qp;
+ uint16_t pkey_index;
+ ib_net16_t remote_lid;
+ uint8_t remote_sl;
+ uint8_t path_bits;
+ } ud;
+ struct _wc_rd {
+ ib_net32_t remote_eecn;
+ ib_net32_t remote_qp;
+ ib_net16_t remote_lid;
+ uint8_t remote_sl;
+ uint32_t free_cnt;
+
+ } rd;
+ struct _wc_raw_ipv6 {
+ ib_net16_t remote_lid;
+ uint8_t remote_sl;
+ uint8_t path_bits;
+ } raw_ipv6;
+ struct _wc_raw_ether {
+ ib_net16_t remote_lid;
+ uint8_t remote_sl;
+ uint8_t path_bits;
+ ib_net16_t ether_type;
+ } raw_ether;
+ } recv;
+} ib_wc_t;
+/*
+* FIELDS
+* p_next
+* A pointer used to chain work completions. This permits multiple
+* work completions to be retrieved from a completion queue through a
+* single function call. This value is set to NULL to mark the end of
+* the chain.
+*
+* wr_id
+* The 64-bit work request identifier that was specified when posting the
+* work request.
+*
+* wc_type
+* Indicates the type of work completion.
+*
+*
+* length
+* The total length of the data sent or received with the work request.
+*
+* status
+* The result of the work request.
+*
+* vendor_specific
+* HCA vendor specific information returned as part of the completion.
+*
+* recv.conn.recv_opt
+* Indicates optional fields valid as part of a work request that
+* completed on a connected (reliable or unreliable) queue pair.
+*
+* recv.conn.immediate_data
+* 32-bit field received as part of an inbound message on a connected
+* queue pair. This field is only valid if the recv_opt flag
+* IB_RECV_OPT_IMMEDIATE has been set.
+*
+* recv.ud.recv_opt
+* Indicates optional fields valid as part of a work request that
+* completed on an unreliable datagram queue pair.
+*
+* recv.ud.immediate_data
+* 32-bit field received as part of an inbound message on a unreliable
+* datagram queue pair. This field is only valid if the recv_opt flag
+* IB_RECV_OPT_IMMEDIATE has been set.
+*
+* recv.ud.remote_qp
+* Identifies the source queue pair of a received datagram.
+*
+* recv.ud.pkey_index
+* The pkey index for the source queue pair. This is valid only for
+* GSI type QP's.
+*
+* recv.ud.remote_lid
+* The source LID of the received datagram.
+*
+* recv.ud.remote_sl
+* The service level used by the source of the received datagram.
+*
+* recv.ud.path_bits
+* path bits...
+*
+* recv.rd.remote_eecn
+* The remote end-to-end context number that sent the received message.
+*
+* recv.rd.remote_qp
+* Identifies the source queue pair of a received message.
+*
+* recv.rd.remote_lid
+* The source LID of the received message.
+*
+* recv.rd.remote_sl
+* The service level used by the source of the received message.
+*
+* recv.rd.free_cnt
+* The number of available entries in the completion queue. Reliable
+* datagrams may complete out of order, so this field may be used to
+* determine the number of additional completions that may occur.
+*
+* recv.raw_ipv6.remote_lid
+* The source LID of the received message.
+*
+* recv.raw_ipv6.remote_sl
+* The service level used by the source of the received message.
+*
+* recv.raw_ipv6.path_bits
+* path bits...
+*
+* recv.raw_ether.remote_lid
+* The source LID of the received message.
+*
+* recv.raw_ether.remote_sl
+* The service level used by the source of the received message.
+*
+* recv.raw_ether.path_bits
+* path bits...
+*
+* recv.raw_ether.ether_type
+* ether type...
+* NOTES
+* When the work request completes with error, the only values that the
+* consumer can depend on are the wr_id field, and the status of the
+* operation.
+*
+* If the consumer is using the same CQ for completions from more than
+* one type of QP (i.e Reliable Connected, Datagram etc), then the consumer
+* must have additional information to decide what fields of the union are
+* valid.
+* SEE ALSO
+* ib_wc_type_t, ib_qp_type_t, ib_wc_status_t, ib_recv_opt_t
+*****/
+
+/****s* Access Layer/ib_mr_create_t
+* NAME
+* ib_mr_create_t
+*
+* DESCRIPTION
+* Information required to create a registered memory region.
+*
+* SYNOPSIS
+*/
+typedef struct _ib_mr_create {
+ void *vaddr;
+ uint64_t length;
+ ib_access_t access_ctrl;
+} ib_mr_create_t;
+/*
+* FIELDS
+* vaddr
+* Starting virtual address of the region being registered.
+*
+* length
+* Length of the buffer to register.
+*
+* access_ctrl
+* Access rights of the registered region.
+*
+* SEE ALSO
+* ib_access_t
+*****/
+
+/****s* Access Layer/ib_phys_create_t
+* NAME
+* ib_phys_create_t
+*
+* DESCRIPTION
+* Information required to create a physical memory region.
+*
+* SYNOPSIS
+*/
+typedef struct _ib_phys_create {
+ uint64_t length;
+ uint32_t num_bufs;
+ uint64_t *buf_array;
+ uint32_t buf_offset;
+ uint32_t page_size;
+ ib_access_t access_ctrl;
+} ib_phys_create_t;
+/*
+* length
+* The length of the memory region in bytes.
+*
+* num_bufs
+* Number of buffers listed in the specified buffer array.
+*
+* buf_array
+* An array of physical buffers to be registered as a single memory
+* region.
+*
+* buf_offset
+* The offset into the first physical page of the specified memory
+* region to start the virtual address.
+*
+* page_size
+* The physical page size of the memory being registered.
+*
+* access_ctrl
+* Access rights of the registered region.
+*
+* SEE ALSO
+* ib_access_t
+*****/
+
+/****s* Access Layer/ib_mr_attr_t
+* NAME
+* ib_mr_attr_t
+*
+* DESCRIPTION
+* Attributes of a registered memory region.
+*
+* SYNOPSIS
+*/
+typedef struct _ib_mr_attr {
+ ib_pd_handle_t h_pd;
+ void *local_lb;
+ void *local_ub;
+ void *remote_lb;
+ void *remote_ub;
+ ib_access_t access_ctrl;
+ uint32_t lkey;
+ uint32_t rkey;
+} ib_mr_attr_t;
+/*
+* DESCRIPTION
+* h_pd
+* Handle to the protection domain for this memory region.
+*
+* local_lb
+* The virtual address of the lower bound of protection for local
+* memory access.
+*
+* local_ub
+* The virtual address of the upper bound of protection for local
+* memory access.
+*
+* remote_lb
+* The virtual address of the lower bound of protection for remote
+* memory access.
+*
+* remote_ub
+* The virtual address of the upper bound of protection for remote
+* memory access.
+*
+* access_ctrl
+* Access rights for the specified memory region.
+*
+* lkey
+* The lkey associated with this memory region.
+*
+* rkey
+* The rkey associated with this memory region.
+*
+* NOTES
+* The remote_lb, remote_ub, and rkey are only valid if remote memory access
+* is enabled for this memory region.
+*
+* SEE ALSO
+* ib_access_t
+*****/
+
+/****d* Access Layer/ib_ca_mod_t
+* NAME
+* ib_ca_mod_t -- Modify port attributes and error counters
+*
+* DESCRIPTION
+* Specifies modifications to the port attributes of a channel adapter.
+*
+* SYNOPSIS
+*/
+typedef uint32_t ib_ca_mod_t;
+#define IB_CA_MOD_IS_CM_SUPPORTED 0x00000001
+#define IB_CA_MOD_IS_SNMP_SUPPORTED 0x00000002
+#define IB_CA_MOD_IS_DEV_MGMT_SUPPORTED 0x00000004
+#define IB_CA_MOD_IS_VEND_SUPPORTED 0x00000008
+#define IB_CA_MOD_IS_SM 0x00000010
+#define IB_CA_MOD_IS_SM_DISABLED 0x00000020
+#define IB_CA_MOD_QKEY_CTR 0x00000040
+#define IB_CA_MOD_PKEY_CTR 0x00000080
+#define IB_CA_MOD_IS_NOTICE_SUPPORTED 0x00000100
+#define IB_CA_MOD_IS_TRAP_SUPPORTED 0x00000200
+#define IB_CA_MOD_IS_APM_SUPPORTED 0x00000400
+#define IB_CA_MOD_IS_SLMAP_SUPPORTED 0x00000800
+#define IB_CA_MOD_IS_PKEY_NVRAM_SUPPORTED 0x00001000
+#define IB_CA_MOD_IS_MKEY_NVRAM_SUPPORTED 0x00002000
+#define IB_CA_MOD_IS_SYSGUID_SUPPORTED 0x00004000
+#define IB_CA_MOD_IS_DR_NOTICE_SUPPORTED 0x00008000
+#define IB_CA_MOD_IS_BOOT_MGMT_SUPPORTED 0x00010000
+#define IB_CA_MOD_IS_CAPM_NOTICE_SUPPORTED 0x00020000
+#define IB_CA_MOD_IS_REINIT_SUPORTED 0x00040000
+#define IB_CA_MOD_IS_LEDINFO_SUPPORTED 0x00080000
+#define IB_CA_MOD_SHUTDOWN_PORT 0x00100000
+#define IB_CA_MOD_INIT_TYPE_VALUE 0x00200000
+#define IB_CA_MOD_SYSTEM_IMAGE_GUID 0x00400000
+/*
+* VALUES
+* IB_CA_MOD_IS_CM_SUPPORTED
+* Indicates if there is a communication manager accessible through
+* the port.
+*
+* IB_CA_MOD_IS_SNMP_SUPPORTED
+* Indicates if there is an SNMP agent accessible through the port.
+*
+* IB_CA_MOD_IS_DEV_MGMT_SUPPORTED
+* Indicates if there is a device management agent accessible
+* through the port.
+*
+* IB_CA_MOD_IS_VEND_SUPPORTED
+* Indicates if there is a vendor supported agent accessible
+* through the port.
+*
+* IB_CA_MOD_IS_SM
+* Indicates if there is a subnet manager accessible through
+* the port.
+*
+* IB_CA_MOD_IS_SM_DISABLED
+* Indicates if the port has been disabled for configuration by the
+* subnet manager.
+*
+* IB_CA_MOD_QKEY_CTR
+* Used to reset the qkey violation counter associated with the
+* port.
+*
+* IB_CA_MOD_PKEY_CTR
+* Used to reset the pkey violation counter associated with the
+* port.
+*
+* IB_CA_MOD_IS_NOTICE_SUPPORTED
+* Indicates that this CA supports ability to generate Notices for
+* Port State changes. (only applicable to switches)
+*
+* IB_CA_MOD_IS_TRAP_SUPPORTED
+* Indicates that this management port supports ability to generate
+* trap messages. (only applicable to switches)
+*
+* IB_CA_MOD_IS_APM_SUPPORTED
+* Indicates that this port is capable of performing Automatic
+* Path Migration.
+*
+* IB_CA_MOD_IS_SLMAP_SUPPORTED
+* Indicates this port supports SLMAP capability.
+*
+* IB_CA_MOD_IS_PKEY_NVRAM_SUPPORTED
+* Indicates that PKEY is supported in NVRAM
+*
+* IB_CA_MOD_IS_MKEY_NVRAM_SUPPORTED
+* Indicates that MKEY is supported in NVRAM
+*
+* IB_CA_MOD_IS_SYSGUID_SUPPORTED
+* Indicates System Image GUID support.
+*
+* IB_CA_MOD_IS_DR_NOTICE_SUPPORTED
+* Indicate support for generating Direct Routed Notices
+*
+* IB_CA_MOD_IS_BOOT_MGMT_SUPPORTED
+* Indicates support for Boot Management
+*
+* IB_CA_MOD_IS_CAPM_NOTICE_SUPPORTED
+* Indicates capability to generate notices for changes to CAPMASK
+*
+* IB_CA_MOD_IS_REINIT_SUPORTED
+* Indicates type of node init supported. Refer to Chapter 14 for
+* Initialization actions.
+*
+* IB_CA_MOD_IS_LEDINFO_SUPPORTED
+* Indicates support for LED info.
+*
+* IB_CA_MOD_SHUTDOWN_PORT
+* Used to modify the port active indicator.
+*
+* IB_CA_MOD_INIT_TYPE_VALUE
+* Used to modify the init_type value for the port.
+*
+* IB_CA_MOD_SYSTEM_IMAGE_GUID
+* Used to modify the system image GUID for the port.
+*****/
+
+/****d* Access Layer/ib_mr_mod_t
+* NAME
+* ib_mr_mod_t
+*
+* DESCRIPTION
+* Mask used to specify which attributes of a registered memory region are
+* being modified.
+*
+* SYNOPSIS
+*/
+typedef uint32_t ib_mr_mod_t;
+#define IB_MR_MOD_ADDR 0x00000001
+#define IB_MR_MOD_PD 0x00000002
+#define IB_MR_MOD_ACCESS 0x00000004
+/*
+* PARAMETERS
+* IB_MEM_MOD_ADDR
+* The address of the memory region is being modified.
+*
+* IB_MEM_MOD_PD
+* The protection domain associated with the memory region is being
+* modified.
+*
+* IB_MEM_MOD_ACCESS
+* The access rights the memory region are being modified.
+*****/
+
+/****d* IBA Base: Constants/IB_SMINFO_ATTR_MOD_HANDOVER
+* NAME
+* IB_SMINFO_ATTR_MOD_HANDOVER
+*
+* DESCRIPTION
+* Encoded attribute modifier value used on SubnSet(SMInfo) SMPs.
+*
+* SOURCE
+*/
+#define IB_SMINFO_ATTR_MOD_HANDOVER (CL_HTON32(0x000001))
+/**********/
+
+/****d* IBA Base: Constants/IB_SMINFO_ATTR_MOD_ACKNOWLEDGE
+* NAME
+* IB_SMINFO_ATTR_MOD_ACKNOWLEDGE
+*
+* DESCRIPTION
+* Encoded attribute modifier value used on SubnSet(SMInfo) SMPs.
+*
+* SOURCE
+*/
+#define IB_SMINFO_ATTR_MOD_ACKNOWLEDGE (CL_HTON32(0x000002))
+/**********/
+
+/****d* IBA Base: Constants/IB_SMINFO_ATTR_MOD_DISABLE
+* NAME
+* IB_SMINFO_ATTR_MOD_DISABLE
+*
+* DESCRIPTION
+* Encoded attribute modifier value used on SubnSet(SMInfo) SMPs.
+*
+* SOURCE
+*/
+#define IB_SMINFO_ATTR_MOD_DISABLE (CL_HTON32(0x000003))
+/**********/
+
+/****d* IBA Base: Constants/IB_SMINFO_ATTR_MOD_STANDBY
+* NAME
+* IB_SMINFO_ATTR_MOD_STANDBY
+*
+* DESCRIPTION
+* Encoded attribute modifier value used on SubnSet(SMInfo) SMPs.
+*
+* SOURCE
+*/
+#define IB_SMINFO_ATTR_MOD_STANDBY (CL_HTON32(0x000004))
+/**********/
+
+/****d* IBA Base: Constants/IB_SMINFO_ATTR_MOD_DISCOVER
+* NAME
+* IB_SMINFO_ATTR_MOD_DISCOVER
+*
+* DESCRIPTION
+* Encoded attribute modifier value used on SubnSet(SMInfo) SMPs.
+*
+* SOURCE
+*/
+#define IB_SMINFO_ATTR_MOD_DISCOVER (CL_HTON32(0x000005))
+/**********/
+
+/****s* Access Layer/ib_ci_op_t
+* NAME
+* ib_ci_op_t
+*
+* DESCRIPTION
+* A structure used for vendor specific CA interface communication.
+*
+* SYNOPSIS
+*/
+typedef struct _ib_ci_op {
+ IN uint32_t command;
+ IN OUT void *p_buf OPTIONAL;
+ IN uint32_t buf_size;
+ IN OUT uint32_t num_bytes_ret;
+ IN OUT int32_t status;
+} ib_ci_op_t;
+/*
+* FIELDS
+* command
+* A command code that is understood by the verbs provider.
+*
+* p_buf
+* A reference to a buffer containing vendor specific data. The verbs
+* provider must not access pointers in the p_buf between user-mode and
+* kernel-mode. Any pointers embedded in the p_buf are invalidated by
+* the user-mode/kernel-mode transition.
+*
+* buf_size
+* The size of the buffer in bytes.
+*
+* num_bytes_ret
+* The size in bytes of the vendor specific data returned in the buffer.
+* This field is set by the verbs provider. The verbs provider should
+* verify that the buffer size is sufficient to hold the data being
+* returned.
+*
+* status
+* The completion status from the verbs provider. This field should be
+* initialize to indicate an error to allow detection and cleanup in
+* case a communication error occurs between user-mode and kernel-mode.
+*
+* NOTES
+* This structure is provided to allow the exchange of vendor specific
+* data between the originator and the verbs provider. Users of this
+* structure are expected to know the format of data in the p_buf based
+* on the structure command field or the usage context.
+*****/
+
+/****s* IBA Base: Types/ib_cc_mad_t
+* NAME
+* ib_cc_mad_t
+*
+* DESCRIPTION
+* IBA defined Congestion Control MAD format. (A10.4.1)
+*
+* SYNOPSIS
+*/
+#define IB_CC_LOG_DATA_SIZE 32
+#define IB_CC_MGT_DATA_SIZE 192
+#define IB_CC_MAD_HDR_SIZE (sizeof(ib_sa_mad_t) - IB_CC_LOG_DATA_SIZE \
+ - IB_CC_MGT_DATA_SIZE)
+
+#include <complib/cl_packon.h>
+typedef struct _ib_cc_mad {
+ ib_mad_t header;
+ ib_net64_t cc_key;
+ uint8_t log_data[IB_CC_LOG_DATA_SIZE];
+ uint8_t mgt_data[IB_CC_MGT_DATA_SIZE];
+} PACK_SUFFIX ib_cc_mad_t;
+#include <complib/cl_packoff.h>
+/*
+* FIELDS
+* header
+* Common MAD header.
+*
+* cc_key
+* CC_Key of the Congestion Control MAD.
+*
+* log_data
+* Congestion Control log data of the CC MAD.
+*
+* mgt_data
+* Congestion Control management data of the CC MAD.
+*
+* SEE ALSO
+* ib_mad_t
+*********/
+
+/****f* IBA Base: Types/ib_cc_mad_get_cc_key
+* NAME
+* ib_cc_mad_get_cc_key
+*
+* DESCRIPTION
+* Gets a CC_Key of the CC MAD.
+*
+* SYNOPSIS
+*/
+static inline ib_net64_t OSM_API
+ib_cc_mad_get_cc_key(IN const ib_cc_mad_t * const p_cc_mad)
+{
+ return p_cc_mad->cc_key;
+}
+/*
+* PARAMETERS
+* p_cc_mad
+* [in] Pointer to the CC MAD packet.
+*
+* RETURN VALUES
+* CC_Key of the provided CC MAD packet.
+*
+* NOTES
+*
+* SEE ALSO
+* ib_cc_mad_t
+*********/
+
+/****f* IBA Base: Types/ib_cc_mad_get_log_data_ptr
+* NAME
+* ib_cc_mad_get_log_data_ptr
+*
+* DESCRIPTION
+* Gets a pointer to the CC MAD's log data area.
+*
+* SYNOPSIS
+*/
+static inline void * OSM_API
+ib_cc_mad_get_log_data_ptr(IN const ib_cc_mad_t * const p_cc_mad)
+{
+ return ((void *)p_cc_mad->log_data);
+}
+/*
+* PARAMETERS
+* p_cc_mad
+* [in] Pointer to the CC MAD packet.
+*
+* RETURN VALUES
+* Pointer to CC MAD log data area.
+*
+* NOTES
+*
+* SEE ALSO
+* ib_cc_mad_t
+*********/
+
+/****f* IBA Base: Types/ib_cc_mad_get_mgt_data_ptr
+* NAME
+* ib_cc_mad_get_mgt_data_ptr
+*
+* DESCRIPTION
+* Gets a pointer to the CC MAD's management data area.
+*
+* SYNOPSIS
+*/
+static inline void * OSM_API
+ib_cc_mad_get_mgt_data_ptr(IN const ib_cc_mad_t * const p_cc_mad)
+{
+ return ((void *)p_cc_mad->mgt_data);
+}
+/*
+* PARAMETERS
+* p_cc_mad
+* [in] Pointer to the CC MAD packet.
+*
+* RETURN VALUES
+* Pointer to CC MAD management data area.
+*
+* NOTES
+*
+* SEE ALSO
+* ib_cc_mad_t
+*********/
+
+/****s* IBA Base: Types/ib_cong_info_t
+* NAME
+* ib_cong_info_t
+*
+* DESCRIPTION
+* IBA defined CongestionInfo attribute (A10.4.3.3)
+*
+* SYNOPSIS
+*/
+#include <complib/cl_packon.h>
+typedef struct _ib_cong_info {
+ uint8_t cong_info;
+ uint8_t resv;
+ uint8_t ctrl_table_cap;
+} PACK_SUFFIX ib_cong_info_t;
+#include <complib/cl_packoff.h>
+/*
+* FIELDS
+* cong_info
+* Congestion control capabilities of the node.
+*
+* ctrl_table_cap
+* Number of 64 entry blocks in the CongestionControlTable.
+*
+* SEE ALSO
+* ib_cc_mad_t
+*********/
+
+/****s* IBA Base: Types/ib_cong_key_info_t
+* NAME
+* ib_cong_key_info_t
+*
+* DESCRIPTION
+* IBA defined CongestionKeyInfo attribute (A10.4.3.4)
+*
+* SYNOPSIS
+*/
+#include <complib/cl_packon.h>
+typedef struct _ib_cong_key_info {
+ ib_net64_t cc_key;
+ ib_net16_t protect_bit;
+ ib_net16_t lease_period;
+ ib_net16_t violations;
+} PACK_SUFFIX ib_cong_key_info_t;
+#include <complib/cl_packoff.h>
+/*
+* FIELDS
+* cc_key
+* 8-byte CC Key.
+*
+* protect_bit
+* Bit 0 is a CC Key Protect Bit, other 15 bits are reserved.
+*
+* lease_period
+* How long the CC Key protect bit is to remain non-zero.
+*
+* violations
+* Number of received MADs that violated CC Key.
+*
+* SEE ALSO
+* ib_cc_mad_t
+*********/
+
+/****s* IBA Base: Types/ib_cong_log_event_sw_t
+* NAME
+* ib_cong_log_event_sw_t
+*
+* DESCRIPTION
+* IBA defined CongestionLogEvent (SW) entry (A10.4.3.5)
+*
+* SYNOPSIS
+*/
+#include <complib/cl_packon.h>
+typedef struct _ib_cong_log_event_sw {
+ ib_net16_t slid;
+ ib_net16_t dlid;
+ ib_net32_t sl;
+ ib_net32_t time_stamp;
+} PACK_SUFFIX ib_cong_log_event_sw_t;
+#include <complib/cl_packoff.h>
+/*
+* FIELDS
+* slid
+* Source LID of congestion event.
+*
+* dlid
+* Destination LID of congestion event.
+*
+* sl
+* 4 bits - SL of congestion event.
+* rest of the bits are reserved.
+*
+* time_stamp
+* Timestamp of congestion event.
+*
+* SEE ALSO
+* ib_cc_mad_t, ib_cong_log_t
+*********/
+
+/****s* IBA Base: Types/ib_cong_log_event_ca_t
+* NAME
+* ib_cong_log_event_ca_t
+*
+* DESCRIPTION
+* IBA defined CongestionLogEvent (CA) entry (A10.4.3.5)
+*
+* SYNOPSIS
+*/
+#include <complib/cl_packon.h>
+typedef struct _ib_cong_log_event_ca {
+ ib_net32_t local_qp_resv0;
+ ib_net32_t remote_qp_sl_service_type;
+ ib_net16_t remote_lid;
+ ib_net16_t resv1;
+ ib_net32_t time_stamp;
+} PACK_SUFFIX ib_cong_log_event_ca_t;
+#include <complib/cl_packoff.h>
+/*
+* FIELDS
+* resv0_local_qp
+* bits [31:8] local QP that reached CN threshold.
+* bits [7:0] reserved.
+*
+* remote_qp_sl_service_type
+* bits [31:8] remote QP that is connected to local QP.
+* bits [7:4] SL of the local QP.
+* bits [3:0] Service Type of the local QP.
+*
+* remote_lid
+* LID of the remote port that is connected to local QP.
+*
+* time_stamp
+* Timestamp when threshold reached.
+*
+* SEE ALSO
+* ib_cc_mad_t, ib_cong_log_t
+*********/
+
+/****s* IBA Base: Types/ib_cong_log_t
+* NAME
+* ib_cong_log_t
+*
+* DESCRIPTION
+* IBA defined CongestionLog attribute (A10.4.3.5)
+*
+* SYNOPSIS
+*/
+#include <complib/cl_packon.h>
+typedef struct _ib_cong_log {
+ uint8_t log_type;
+ union _log_details
+ {
+ struct _log_sw {
+ uint8_t cong_flags;
+ ib_net16_t event_counter;
+ ib_net32_t time_stamp;
+ uint8_t port_map[32];
+ ib_cong_log_event_sw_t entry_list[15];
+ } PACK_SUFFIX log_sw;
+
+ struct _log_ca {
+ uint8_t cong_flags;
+ ib_net16_t event_counter;
+ ib_net16_t event_map;
+ ib_net16_t resv;
+ ib_net32_t time_stamp;
+ ib_cong_log_event_ca_t log_event[13];
+ } PACK_SUFFIX log_ca;
+
+ } log_details;
+} PACK_SUFFIX ib_cong_log_t;
+#include <complib/cl_packoff.h>
+/*
+* FIELDS
+*
+* log_{sw,ca}.log_type
+* Log type: 0x1 is for Switch, 0x2 is for CA
+*
+* log_{sw,ca}.cong_flags
+* Congestion Flags.
+*
+* log_{sw,ca}.event_counter
+* Number of events since log last sent.
+*
+* log_{sw,ca}.time_stamp
+* Timestamp when log sent.
+*
+* log_sw.port_map
+* If a bit set to 1, then the corresponding port
+* has marked packets with a FECN.
+* bits 0 and 255 - reserved
+* bits [254..1] - ports [254..1].
+*
+* log_sw.entry_list
+* Array of 13 most recent congestion log events.
+*
+* log_ca.event_map
+* array 16 bits, one for each SL.
+*
+* log_ca.log_event
+* Array of 13 most recent congestion log events.
+*
+* SEE ALSO
+* ib_cc_mad_t, ib_cong_log_event_sw_t, ib_cong_log_event_ca_t
+*********/
+
+/****s* IBA Base: Types/ib_sw_cong_setting_t
+* NAME
+* ib_sw_cong_setting_t
+*
+* DESCRIPTION
+* IBA defined SwitchCongestionSetting attribute (A10.4.3.6)
+*
+* SYNOPSIS
+*/
+#define IB_CC_PORT_MASK_DATA_SIZE 32
+#include <complib/cl_packon.h>
+typedef struct _ib_sw_cong_setting {
+ ib_net32_t control_map;
+ uint8_t victim_mask[IB_CC_PORT_MASK_DATA_SIZE];
+ uint8_t credit_mask[IB_CC_PORT_MASK_DATA_SIZE];
+ uint8_t threshold_resv;
+ uint8_t packet_size;
+ ib_net16_t cs_threshold_resv;
+ ib_net16_t cs_return_delay;
+ ib_net16_t marking_rate;
+} PACK_SUFFIX ib_sw_cong_setting_t;
+#include <complib/cl_packoff.h>
+/*
+* FIELDS
+*
+* control_map
+* Indicates which components of this attribute are valid
+*
+* victim_mask
+* If the bit set to 1, then the port corresponding to
+* that bit shall mark packets that encounter congestion
+* with a FECN, whether they are the source or victim
+* of congestion. (See A10.2.1.1.1)
+* bit 0: port 0 (enhanced port 0 only)
+* bits [254..1]: ports [254..1]
+* bit 255: reserved
+*
+* credit_mask
+* If the bit set to 1, then the port corresponding
+* to that bit shall apply Credit Starvation.
+* bit 0: port 0 (enhanced port 0 only)
+* bits [254..1]: ports [254..1]
+* bit 255: reserved
+*
+* threshold_resv
+* bits [7..4] Indicates how aggressive cong. marking should be
+* bits [3..0] Reserved
+*
+* packet_size
+* Any packet less than this size won't be marked with FECN
+*
+* cs_threshold_resv
+* bits [15..12] How aggressive Credit Starvation should be
+* bits [11..0] Reserved
+*
+* cs_return_delay
+* Value that controls credit return rate.
+*
+* marking_rate
+* The value that provides the mean number of packets
+* between marking eligible packets with FECN.
+*
+* SEE ALSO
+* ib_cc_mad_t
+*********/
+
+/****s* IBA Base: Types/ib_sw_port_cong_setting_element_t
+* NAME
+* ib_sw_port_cong_setting_element_t
+*
+* DESCRIPTION
+* IBA defined SwitchPortCongestionSettingElement (A10.4.3.7)
+*
+* SYNOPSIS
+*/
+#include <complib/cl_packon.h>
+typedef struct _ib_sw_port_cong_setting_element {
+ uint8_t valid_ctrl_type_res_threshold;
+ uint8_t packet_size;
+ ib_net16_t cong_param;
+} PACK_SUFFIX ib_sw_port_cong_setting_element_t;
+#include <complib/cl_packoff.h>
+/*
+* FIELDS
+*
+* valid_ctrl_type_res_threshold
+* bit 7: "Valid"
+* when set to 1, indicates this switch
+* port congestion setting element is valid.
+* bit 6: "Control Type"
+* Indicates which type of attribute is being set:
+* 0b = Congestion Control parameters are being set.
+* 1b = Credit Starvation parameters are being set.
+* bits [5..4]: reserved
+* bits [3..0]: "Threshold"
+* When Control Type is 0, contains the congestion
+* threshold value (Threshold) for this port.
+* When Control Type is 1, contains the credit
+* starvation threshold (CS_Threshold) value for
+* this port.
+*
+* packet_size
+* When Control Type is 0, this field contains the minimum
+* size of packets that may be marked with a FECN.
+* When Control Type is 1, this field is reserved.
+*
+* cong_parm
+* When Control Type is 0, this field contains the port
+* marking_rate.
+* When Control Type is 1, this field is reserved.
+*
+* SEE ALSO
+* ib_cc_mad_t, ib_sw_port_cong_setting_t
+*********/
+
+/****d* IBA Base: Types/ib_sw_port_cong_setting_block_t
+* NAME
+* ib_sw_port_cong_setting_block_t
+*
+* DESCRIPTION
+* Defines the SwitchPortCongestionSetting Block (A10.4.3.7).
+*
+* SOURCE
+*/
+#define IB_CC_SW_PORT_SETTING_ELEMENTS 32
+typedef ib_sw_port_cong_setting_element_t ib_sw_port_cong_setting_block_t[IB_CC_SW_PORT_SETTING_ELEMENTS];
+/**********/
+
+/****s* IBA Base: Types/ib_sw_port_cong_setting_t
+* NAME
+* ib_sw_port_cong_setting_t
+*
+* DESCRIPTION
+* IBA defined SwitchPortCongestionSetting attribute (A10.4.3.7)
+*
+* SYNOPSIS
+*/
+
+#include <complib/cl_packon.h>
+typedef struct _ib_sw_port_cong_setting {
+ ib_sw_port_cong_setting_block_t block;
+} PACK_SUFFIX ib_sw_port_cong_setting_t;
+#include <complib/cl_packoff.h>
+/*
+* FIELDS
+*
+* block
+* SwitchPortCongestionSetting block.
+*
+* SEE ALSO
+* ib_cc_mad_t, ib_sw_port_cong_setting_element_t
+*********/
+
+/****s* IBA Base: Types/ib_ca_cong_entry_t
+* NAME
+* ib_ca_cong_entry_t
+*
+* DESCRIPTION
+* IBA defined CACongestionEntry (A10.4.3.8)
+*
+* SYNOPSIS
+*/
+#include <complib/cl_packon.h>
+typedef struct _ib_ca_cong_entry {
+ ib_net16_t ccti_timer;
+ uint8_t ccti_increase;
+ uint8_t trigger_threshold;
+ uint8_t ccti_min;
+ uint8_t resv0;
+ ib_net16_t resv1;
+} PACK_SUFFIX ib_ca_cong_entry_t;
+#include <complib/cl_packoff.h>
+/*
+* FIELDS
+*
+* ccti_timer
+* When the timer expires it will be reset to its specified
+* value, and 1 will be decremented from the CCTI.
+*
+* ccti_increase
+* The number to be added to the table Index (CCTI)
+* on the receipt of a BECN.
+*
+* trigger_threshold
+* When the CCTI is equal to this value, an event
+* is logged in the CAs cyclic event log.
+*
+* ccti_min
+* The minimum value permitted for the CCTI.
+*
+* SEE ALSO
+* ib_cc_mad_t
+*********/
+
+/****s* IBA Base: Types/ib_ca_cong_setting_t
+* NAME
+* ib_ca_cong_setting_t
+*
+* DESCRIPTION
+* IBA defined CACongestionSetting attribute (A10.4.3.8)
+*
+* SYNOPSIS
+*/
+#define IB_CA_CONG_ENTRY_DATA_SIZE 16
+#include <complib/cl_packon.h>
+typedef struct _ib_ca_cong_setting {
+ ib_net16_t port_control;
+ ib_net16_t control_map;
+ ib_ca_cong_entry_t entry_list[IB_CA_CONG_ENTRY_DATA_SIZE];
+} PACK_SUFFIX ib_ca_cong_setting_t;
+#include <complib/cl_packoff.h>
+/*
+* FIELDS
+*
+* port_control
+* Congestion attributes for this port:
+* bit0 = 0: QP based CC
+* bit0 = 1: SL/Port based CC
+* All other bits are reserved
+*
+* control_map
+* An array of sixteen bits, one for each SL. Each bit indicates
+* whether or not the corresponding entry is to be modified.
+*
+* entry_list
+* List of 16 CACongestionEntries, one per SL.
+*
+* SEE ALSO
+* ib_cc_mad_t
+*********/
+
+/****s* IBA Base: Types/ib_cc_tbl_entry_t
+* NAME
+* ib_cc_tbl_entry_t
+*
+* DESCRIPTION
+* IBA defined CongestionControlTableEntry (A10.4.3.9)
+*
+* SYNOPSIS
+*/
+#include <complib/cl_packon.h>
+typedef struct _ib_cc_tbl_entry {
+ ib_net16_t shift_multiplier;
+} PACK_SUFFIX ib_cc_tbl_entry_t;
+#include <complib/cl_packoff.h>
+/*
+* FIELDS
+*
+* shift_multiplier
+* bits [15..14] - CCT Shift
+* used when calculating the injection rate delay
+* bits [13..0] - CCT Multiplier
+* used when calculating the injection rate delay
+*
+* SEE ALSO
+* ib_cc_mad_t
+*********/
+
+/****s* IBA Base: Types/ib_cc_tbl_t
+* NAME
+* ib_cc_tbl_t
+*
+* DESCRIPTION
+* IBA defined CongestionControlTable attribute (A10.4.3.9)
+*
+* SYNOPSIS
+*/
+#define IB_CC_TBL_ENTRY_LIST_MAX 64
+#include <complib/cl_packon.h>
+typedef struct _ib_cc_tbl {
+ ib_net16_t ccti_limit;
+ ib_net16_t resv;
+ ib_cc_tbl_entry_t entry_list[IB_CC_TBL_ENTRY_LIST_MAX];
+} PACK_SUFFIX ib_cc_tbl_t;
+#include <complib/cl_packoff.h>
+/*
+* FIELDS
+*
+* ccti_limit
+* Maximum valid CCTI for this table.
+*
+* entry_list
+* List of up to 64 CongestionControlTableEntries.
+*
+* SEE ALSO
+* ib_cc_mad_t
+*********/
+
+/****s* IBA Base: Types/ib_time_stamp_t
+* NAME
+* ib_time_stamp_t
+*
+* DESCRIPTION
+* IBA defined TimeStamp attribute (A10.4.3.10)
+*
+* SOURCE
+*/
+#include <complib/cl_packon.h>
+typedef struct _ib_time_stamp {
+ ib_net32_t value;
+} PACK_SUFFIX ib_time_stamp_t;
+#include <complib/cl_packoff.h>
+/*
+* FIELDS
+*
+* value
+* Free running clock that provides relative time info
+* for a device. Time is kept in 1.024 usec units.
+*
+* SEE ALSO
+* ib_cc_mad_t
+*********/
+
+END_C_DECLS
+#else /* ndef __WIN__ */
+#include <iba/ib_types_extended.h>
+#endif
+#endif /* __IB_TYPES_H__ */
diff --git a/contrib/ofed/opensm/include/opensm/osm_attrib_req.h b/contrib/ofed/opensm/include/opensm/osm_attrib_req.h
new file mode 100644
index 0000000..c9c4886
--- /dev/null
+++ b/contrib/ofed/opensm/include/opensm/osm_attrib_req.h
@@ -0,0 +1,108 @@
+/*
+ * Copyright (c) 2004-2008 Voltaire, Inc. All rights reserved.
+ * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved.
+ * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+#ifndef _OSM_ATTRIB_REQ_H_
+#define _OSM_ATTRIB_REQ_H_
+
+#include <opensm/osm_path.h>
+
+#ifdef __cplusplus
+# define BEGIN_C_DECLS extern "C" {
+# define END_C_DECLS }
+#else /* !__cplusplus */
+# define BEGIN_C_DECLS
+# define END_C_DECLS
+#endif /* __cplusplus */
+
+BEGIN_C_DECLS
+/*
+ * Abstract:
+ * Declaration of the attribute request object. This object
+ * encapsulates information needed by the generic request controller
+ * to request an attribute from a node.
+ * These objects are part of the OpenSM family of objects.
+ */
+/****h* OpenSM/Attribute Request
+* NAME
+* Attribute Request
+*
+* DESCRIPTION
+* The Attribute Request structure encapsulates
+* encapsulates information needed by the generic request controller
+* to request an attribute from a node.
+*
+* This structure allows direct access to member variables.
+*
+* AUTHOR
+* Steve King, Intel
+*
+*********/
+/****s* OpenSM: Attribute Request/osm_attrib_req_t
+* NAME
+* osm_attrib_req_t
+*
+* DESCRIPTION
+* Attribute request structure.
+*
+* This structure allows direct access to member variables.
+*
+* SYNOPSIS
+*/
+typedef struct osm_attrib_req {
+ uint16_t attrib_id;
+ uint32_t attrib_mod;
+ osm_madw_context_t context;
+ osm_dr_path_t path;
+ cl_disp_msgid_t err_msg;
+} osm_attrib_req_t;
+/*
+* FIELDS
+* attrib_id
+* Attribute ID for this request.
+*
+* attrib_mod
+* Attribute modifier for this request.
+*
+* context
+* Context to insert in outbound mad wrapper context.
+*
+* path
+* The directed route path to the node.
+*
+* SEE ALSO
+*********/
+
+END_C_DECLS
+#endif /* _OSM_ATTRIB_REQ_H_ */
diff --git a/contrib/ofed/opensm/include/opensm/osm_base.h b/contrib/ofed/opensm/include/opensm/osm_base.h
new file mode 100644
index 0000000..65a43e2
--- /dev/null
+++ b/contrib/ofed/opensm/include/opensm/osm_base.h
@@ -0,0 +1,1034 @@
+/*
+ * Copyright (c) 2004-2009 Voltaire, Inc. All rights reserved.
+ * Copyright (c) 2002-2011 Mellanox Technologies LTD. All rights reserved.
+ * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
+ * Copyright (c) 2009 Sun Microsystems, Inc. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+/*
+ * Abstract:
+ * Basic OpenSM definitions and structures.
+ * This object represents an OpenSM "base class".
+ * This object is part of the OpenSM family of objects.
+ */
+
+#ifndef _OSM_BASE_H_
+#define _OSM_BASE_H_
+
+#if HAVE_CONFIG_H
+# include <config.h>
+#endif /* HAVE_CONFIG_H */
+
+#ifdef __WIN__
+#include <vendor/winosm_common.h>
+#endif
+
+#include <complib/cl_types.h>
+#include <iba/ib_types.h>
+
+#ifdef __cplusplus
+# define BEGIN_C_DECLS extern "C" {
+# define END_C_DECLS }
+#else /* !__cplusplus */
+# define BEGIN_C_DECLS
+# define END_C_DECLS
+#endif /* __cplusplus */
+
+BEGIN_C_DECLS
+/****h* OpenSM/Constants
+* NAME
+* Constants
+*
+* DESCRIPTION
+* The following constants are used throughout the OpenSM.
+*
+* AUTHOR
+* Steve King, Intel
+*
+*********/
+/****h* OpenSM/Base
+* NAME
+* Base
+*
+* DESCRIPTION
+* The Base object encapsulates basic information needed by the
+* OpenSM to manage objects. Each OpenSM object includes the
+* Base object as the first member.
+*
+* This object should be treated as opaque and should be
+* manipulated only through the provided functions.
+*
+* AUTHOR
+* Steve King, Intel
+*
+*********/
+/****s* OpenSM: Base/OSM_DEFAULT_M_KEY
+* NAME
+* OSM_DEFAULT_M_KEY
+*
+* DESCRIPTION
+* Managment key value used by the OpenSM.
+*
+* SYNOPSIS
+*/
+#define OSM_DEFAULT_M_KEY 0
+/********/
+/****s* OpenSM: Base/OSM_DEFAULT_SM_KEY
+* NAME
+* OSM_DEFAULT_SM_KEY
+*
+* DESCRIPTION
+* Subnet Manager key value used by the OpenSM.
+*
+* SYNOPSIS
+*/
+#define OSM_DEFAULT_SM_KEY CL_HTON64(1)
+/********/
+/****s* OpenSM: Base/OSM_DEFAULT_SA_KEY
+* NAME
+* OSM_DEFAULT_SA_KEY
+*
+* DESCRIPTION
+* Subnet Adminstration key value.
+*
+* SYNOPSIS
+*/
+#define OSM_DEFAULT_SA_KEY OSM_DEFAULT_SM_KEY
+/********/
+/****s* OpenSM: Base/OSM_DEFAULT_LMC
+* NAME
+* OSM_DEFAULT_LMC
+*
+* DESCRIPTION
+* Default LMC value used by the OpenSM.
+*
+* SYNOPSIS
+*/
+#define OSM_DEFAULT_LMC 0
+/********/
+/****s* OpenSM: Base/OSM_DEFAULT_MAX_OP_VLS
+* NAME
+* OSM_DEFAULT_MAX_OP_VLS
+*
+* DESCRIPTION
+* Default Maximal Operational VLs to be initialized on
+* the link ports PortInfo by the OpenSM.
+* Default value provides backward compatibility.
+*
+* SYNOPSIS
+*/
+#define OSM_DEFAULT_MAX_OP_VLS 5
+/********/
+/****s* OpenSM: Base/OSM_DEFAULT_SL
+* NAME
+* OSM_DEFAULT_SL
+*
+* DESCRIPTION
+* Default SL value used by the OpenSM.
+*
+* SYNOPSIS
+*/
+#define OSM_DEFAULT_SL 0
+/********/
+/****s* OpenSM: Base/OSM_DEFAULT_SCATTER_PORTS
+* NAME
+* OSM_DEFAULT_SCATTER_PORTS
+*
+* DESCRIPTION
+* Default Scatter Ports value used by OpenSM.
+*
+* SYNOPSIS
+*/
+#define OSM_DEFAULT_SCATTER_PORTS 0
+/********/
+/****s* OpenSM: Base/OSM_DEFAULT_SM_PRIORITY
+* NAME
+* OSM_DEFAULT_SM_PRIORITY
+*
+* DESCRIPTION
+* Default SM priority value used by the OpenSM,
+* as defined in the SMInfo attribute. 0 is the lowest priority.
+*
+* SYNOPSIS
+*/
+#define OSM_DEFAULT_SM_PRIORITY 0
+/********/
+/****d* OpenSM: Base/OSM_DEFAULT_TMP_DIR
+* NAME
+* OSM_DEFAULT_TMP_DIR
+*
+* DESCRIPTION
+* Specifies the default temporary directory for the log file,
+* osm-subnet.lst, and other log files.
+*
+* SYNOPSIS
+*/
+#ifdef __WIN__
+#define OSM_DEFAULT_TMP_DIR "%TEMP%\\"
+#else
+#define OSM_DEFAULT_TMP_DIR "/var/log/"
+#endif
+/***********/
+/****d* OpenSM: Base/OSM_DEFAULT_CACHE_DIR
+* NAME
+* OSM_DEFAULT_CACHE_DIR
+*
+* DESCRIPTION
+* Specifies the default cache directory for the db files.
+*
+* SYNOPSIS
+*/
+#ifdef __WIN__
+#define OSM_DEFAULT_CACHE_DIR "%TEMP%"
+#else
+#define OSM_DEFAULT_CACHE_DIR "/var/cache/opensm"
+#endif
+/***********/
+/****d* OpenSM: Base/OSM_DEFAULT_LOG_FILE
+* NAME
+* OSM_DEFAULT_LOG_FILE
+*
+* DESCRIPTION
+* Specifies the default log file name
+*
+* SYNOPSIS
+*/
+#ifdef __WIN__
+#define OSM_DEFAULT_LOG_FILE OSM_DEFAULT_TMP_DIR "osm.log"
+#else
+#define OSM_DEFAULT_LOG_FILE "/var/log/opensm.log"
+#endif
+/***********/
+
+/****d* OpenSM: Base/OSM_DEFAULT_CONFIG_FILE
+* NAME
+* OSM_DEFAULT_CONFIG_FILE
+*
+* DESCRIPTION
+* Specifies the default OpenSM config file name
+*
+* SYNOPSIS
+*/
+#if defined(HAVE_DEFAULT_OPENSM_CONFIG_FILE)
+#define OSM_DEFAULT_CONFIG_FILE HAVE_DEFAULT_OPENSM_CONFIG_FILE
+#elif defined (OPENSM_CONFIG_DIR)
+#define OSM_DEFAULT_CONFIG_FILE OPENSM_CONFIG_DIR "/opensm.conf"
+#else
+#define OSM_DEFAULT_CONFIG_FILE "/etc/opensm/opensm.conf"
+#endif
+/***********/
+
+/****d* OpenSM: Base/OSM_DEFAULT_PARTITION_CONFIG_FILE
+* NAME
+* OSM_DEFAULT_PARTITION_CONFIG_FILE
+*
+* DESCRIPTION
+* Specifies the default partition config file name
+*
+* SYNOPSIS
+*/
+#if defined(HAVE_DEFAULT_PARTITION_CONFIG_FILE)
+#define OSM_DEFAULT_PARTITION_CONFIG_FILE HAVE_DEFAULT_PARTITION_CONFIG_FILE
+#elif defined(OPENSM_CONFIG_DIR)
+#define OSM_DEFAULT_PARTITION_CONFIG_FILE OPENSM_CONFIG_DIR "/partitions.conf"
+#else
+#define OSM_DEFAULT_PARTITION_CONFIG_FILE "/etc/opensm/partitions.conf"
+#endif
+/***********/
+
+/****d* OpenSM: Base/OSM_DEFAULT_QOS_POLICY_FILE
+* NAME
+* OSM_DEFAULT_QOS_POLICY_FILE
+*
+* DESCRIPTION
+* Specifies the default QoS policy file name
+*
+* SYNOPSIS
+*/
+#if defined(HAVE_DEFAULT_QOS_POLICY_FILE)
+#define OSM_DEFAULT_QOS_POLICY_FILE HAVE_DEFAULT_QOS_POLICY_FILE
+#elif defined(OPENSM_CONFIG_DIR)
+#define OSM_DEFAULT_QOS_POLICY_FILE OPENSM_CONFIG_DIR "/qos-policy.conf"
+#else
+#define OSM_DEFAULT_QOS_POLICY_FILE "/etc/opensm/qos-policy.conf"
+#endif
+/***********/
+
+/****d* OpenSM: Base/OSM_DEFAULT_TORUS_CONF_FILE
+* NAME
+* OSM_DEFAULT_TORUS_CONF_FILE
+*
+* DESCRIPTION
+* Specifies the default file name for extra torus-2QoS configuration
+*
+* SYNOPSIS
+*/
+#ifdef __WIN__
+#define OSM_DEFAULT_TORUS_CONF_FILE strcat(GetOsmCachePath(), "osm-torus-2QoS.conf")
+#elif defined(OPENSM_CONFIG_DIR)
+#define OSM_DEFAULT_TORUS_CONF_FILE OPENSM_CONFIG_DIR "/torus-2QoS.conf"
+#else
+#define OSM_DEFAULT_TORUS_CONF_FILE "/etc/opensm/torus-2QoS.conf"
+#endif /* __WIN__ */
+/***********/
+
+/****d* OpenSM: Base/OSM_DEFAULT_PREFIX_ROUTES_FILE
+* NAME
+* OSM_DEFAULT_PREFIX_ROUTES_FILE
+*
+* DESCRIPTION
+* Specifies the default prefix routes file name
+*
+* SYNOPSIS
+*/
+#if defined(HAVE_DEFAULT_PREFIX_ROUTES_FILE)
+#define OSM_DEFAULT_PREFIX_ROUTES_FILE HAVE_DEFAULT_PREFIX_ROUTES_FILE
+#elif defined(OPENSM_CONFIG_DIR)
+#define OSM_DEFAULT_PREFIX_ROUTES_FILE OPENSM_CONFIG_DIR "/prefix-routes.conf"
+#else
+#define OSM_DEFAULT_PREFIX_ROUTES_FILE "/etc/opensm/prefix-routes.conf"
+#endif
+/***********/
+
+/****d* OpenSM: Base/OSM_DEFAULT_PER_MOD_LOGGING_CONF_FILE
+* NAME
+* OSM_DEFAULT_PER_MOD_LOGGING_CONF_FILE
+*
+* DESCRIPTION
+* Specifies the default file name for per module logging configuration
+*
+* SYNOPSIS
+*/
+#ifdef __WIN__
+#define OSM_DEFAULT_PER_MOD_LOGGING_CONF_FILE strcat(GetOsmCachePath(), "per-module-logging.conf")
+#elif defined(OPENSM_CONFIG_DIR)
+#define OSM_DEFAULT_PER_MOD_LOGGING_CONF_FILE OPENSM_CONFIG_DIR "/per-module-logging.conf"
+#else
+#define OSM_DEFAULT_PER_MOD_LOGGING_CONF_FILE "/etc/opensm/per-module-logging.conf"
+#endif /* __WIN__ */
+/***********/
+
+/****d* OpenSM: Base/OSM_DEFAULT_SWEEP_INTERVAL_SECS
+* NAME
+* OSM_DEFAULT_SWEEP_INTERVAL_SECS
+*
+* DESCRIPTION
+* Specifies the default number of seconds between subnet sweeps.
+*
+* SYNOPSIS
+*/
+#define OSM_DEFAULT_SWEEP_INTERVAL_SECS 10
+/***********/
+/****d* OpenSM: Base/OSM_DEFAULT_TRANS_TIMEOUT_MILLISEC
+* NAME
+* OSM_DEFAULT_TRANS_TIMEOUT_MILLISEC
+*
+* DESCRIPTION
+* Specifies the default transaction timeout in milliseconds.
+*
+* SYNOPSIS
+*/
+#define OSM_DEFAULT_TRANS_TIMEOUT_MILLISEC 200
+/***********/
+/****d* OpenSM: Base/OSM_DEFAULT_SUBNET_TIMEOUT
+* NAME
+* OSM_DEFAULT_SUBNET_TIMEOUT
+*
+* DESCRIPTION
+* Specifies the default subnet timeout.
+* timeout time = 4us * 2^timeout.
+* We use here ~1sec.
+*
+* SYNOPSIS
+*/
+#define OSM_DEFAULT_SUBNET_TIMEOUT 0x12
+/***********/
+/****d* OpenSM: Base/OSM_DEFAULT_SWITCH_PACKET_LIFE
+* NAME
+* OSM_DEFAULT_SWITCH_PACKET_LIFE
+*
+* DESCRIPTION
+* Specifies the default max life time for a pcket on the switch.
+* timeout time = 4us * 2^timeout.
+* We use here the value of ~1sec
+* A Value > 19dec disables this mechanism.
+*
+* SYNOPSIS
+*/
+#define OSM_DEFAULT_SWITCH_PACKET_LIFE 0x12
+/***********/
+/****d* OpenSM: Base/OSM_DEFAULT_HEAD_OF_QUEUE_LIFE
+* NAME
+* OSM_DEFAULT_HEAD_OF_QUEUE_LIFE
+*
+* DESCRIPTION
+* Sets the time a packet can live in the head of the VL Queue
+* We use here the value of ~1sec
+* A Value > 19dec disables this mechanism.
+*
+* SYNOPSIS
+*/
+#define OSM_DEFAULT_HEAD_OF_QUEUE_LIFE 0x12
+/***********/
+/****d* OpenSM: Base/OSM_DEFAULT_LEAF_HEAD_OF_QUEUE_LIFE
+* NAME
+* OSM_DEFAULT_LEAF_HEAD_OF_QUEUE_LIFE
+*
+* DESCRIPTION
+* Sets the time a packet can live in the head of the VL Queue
+* of a port that drives a CA port.
+* We use here the value of ~256msec
+*
+* SYNOPSIS
+*/
+#define OSM_DEFAULT_LEAF_HEAD_OF_QUEUE_LIFE 0x10
+/***********/
+/****d* OpenSM: Base/OSM_DEFAULT_VL_STALL_COUNT
+* NAME
+* OSM_DEFAULT_LEAF_VL_COUNT
+*
+* DESCRIPTION
+* Sets the number of consecutive head of queue life time drops that
+* puts the VL into stalled state. In stalled state, the port is supposed
+* to drop everything for 8*(head of queue lifetime)
+*
+* SYNOPSIS
+*/
+#define OSM_DEFAULT_VL_STALL_COUNT 0x7
+/***********/
+/****d* OpenSM: Base/OSM_DEFAULT_LEAF_VL_STALL_COUNT
+* NAME
+* OSM_DEFAULT_LEAF_VL_STALL_COUNT
+*
+* DESCRIPTION
+* Sets the number of consecutive head of queue life time drops that
+* puts the VL into stalled state. In stalled state, the port is supposed
+* to drop everything for 8*(head of queue lifetime). This value is for
+* switch ports driving a CA port.
+*
+* SYNOPSIS
+*/
+#define OSM_DEFAULT_LEAF_VL_STALL_COUNT 0x7
+/***********/
+/****d* OpenSM: Base/OSM_DEFAULT_TRAP_SUPRESSION_TIMEOUT
+* NAME
+* OSM_DEFAULT_TRAP_SUPRESSION_TIMEOUT
+*
+* DESCRIPTION
+* Specifies the default timeout for ignoring same trap.
+* timeout time = 5000000us
+* We use here ~5sec.
+*
+* SYNOPSIS
+*/
+#define OSM_DEFAULT_TRAP_SUPRESSION_TIMEOUT 5000000
+/***********/
+/****d* OpenSM: Base/OSM_DEFAULT_UNHEALTHY_TIMEOUT
+* NAME
+* OSM_DEFAULT_UNHEALTHY_TIMEOUT
+*
+* DESCRIPTION
+* Specifies the default timeout for setting port as unhealthy.
+* timeout time = 60000000us
+* We use here ~60sec.
+*
+* SYNOPSIS
+*/
+#define OSM_DEFAULT_UNHEALTHY_TIMEOUT 60000000
+/***********/
+/****d* OpenSM: Base/OSM_DEFAULT_ERROR_THRESHOLD
+* NAME
+* OSM_DEFAULT_ERROR_THRESHOLD
+*
+* DESCRIPTION
+* Specifies default link error threshold to be set by SubnSet(PortInfo).
+*
+* SYNOPSIS
+*/
+#define OSM_DEFAULT_ERROR_THRESHOLD 0x08
+/***********/
+/****d* OpenSM: Base/OSM_DEFAULT_SMP_MAX_ON_WIRE
+* NAME
+* OSM_DEFAULT_SMP_MAX_ON_WIRE
+*
+* DESCRIPTION
+* Specifies the default number of VL15 SMP MADs allowed on
+* the wire at any one time.
+*
+* SYNOPSIS
+*/
+#define OSM_DEFAULT_SMP_MAX_ON_WIRE 4
+/***********/
+/****d* OpenSM: Base/OSM_SM_DEFAULT_QP0_RCV_SIZE
+* NAME
+* OSM_SM_DEFAULT_QP0_RCV_SIZE
+*
+* DESCRIPTION
+* Specifies the default size (in MADs) of the QP0 receive queue
+*
+* SYNOPSIS
+*/
+#define OSM_SM_DEFAULT_QP0_RCV_SIZE 256
+/***********/
+/****d* OpenSM: Base/OSM_SM_DEFAULT_QP0_SEND_SIZE
+* NAME
+* OSM_SM_DEFAULT_QP0_SEND_SIZE
+*
+* DESCRIPTION
+* Specifies the default size (in MADs) of the QP0 send queue
+*
+* SYNOPSIS
+*/
+#define OSM_SM_DEFAULT_QP0_SEND_SIZE 256
+/***********/
+/****d* OpenSM: Base/OSM_SM_DEFAULT_QP1_RCV_SIZE
+* NAME
+* OSM_SM_DEFAULT_QP1_RCV_SIZE
+*
+* DESCRIPTION
+* Specifies the default size (in MADs) of the QP1 receive queue
+*
+* SYNOPSIS
+*/
+#define OSM_SM_DEFAULT_QP1_RCV_SIZE 256
+/***********/
+/****d* OpenSM: Base/OSM_SM_DEFAULT_QP1_SEND_SIZE
+* NAME
+* OSM_SM_DEFAULT_QP1_SEND_SIZE
+*
+* DESCRIPTION
+* Specifies the default size (in MADs) of the QP1 send queue
+*
+* SYNOPSIS
+*/
+#define OSM_SM_DEFAULT_QP1_SEND_SIZE 256
+/****d* OpenSM: Base/OSM_PM_DEFAULT_QP1_RCV_SIZE
+* NAME
+* OSM_PM_DEFAULT_QP1_RCV_SIZE
+*
+* DESCRIPTION
+* Specifies the default size (in MADs) of the QP1 receive queue
+*
+* SYNOPSIS
+*/
+#define OSM_PM_DEFAULT_QP1_RCV_SIZE 256
+/***********/
+/****d* OpenSM: Base/OSM_PM_DEFAULT_QP1_SEND_SIZE
+* NAME
+* OSM_PM_DEFAULT_QP1_SEND_SIZE
+*
+* DESCRIPTION
+* Specifies the default size (in MADs) of the QP1 send queue
+*
+* SYNOPSIS
+*/
+#define OSM_PM_DEFAULT_QP1_SEND_SIZE 256
+/****d* OpenSM: Base/OSM_SM_DEFAULT_POLLING_TIMEOUT_MILLISECS
+* NAME
+* OSM_SM_DEFAULT_POLLING_TIMEOUT_MILLISECS
+*
+* DESCRIPTION
+* Specifies the polling timeout (in miliseconds) - the timeout
+* between one poll to another.
+*
+* SYNOPSIS
+*/
+#define OSM_SM_DEFAULT_POLLING_TIMEOUT_MILLISECS 10000
+/**********/
+/****d* OpenSM: Base/OSM_SM_DEFAULT_POLLING_RETRY_NUMBER
+* NAME
+* OSM_SM_DEFAULT_POLLING_RETRY_NUMBER
+*
+* DESCRIPTION
+* Specifies the number of polling retries before the SM goes back
+* to DISCOVERY stage. So the default total time for handoff is 40 sec.
+*
+* SYNOPSIS
+*/
+#define OSM_SM_DEFAULT_POLLING_RETRY_NUMBER 4
+/**********/
+/****d* OpenSM: MC Member Record Receiver/OSM_DEFAULT_MGRP_MTU
+* Name
+* OSM_DEFAULT_MGRP_MTU
+*
+* DESCRIPTION
+* Default MTU used for new MGRP creation (2048 bytes)
+* Note it includes the MTUSelector which is set to "Greater Than"
+*
+* SYNOPSIS
+*/
+#define OSM_DEFAULT_MGRP_MTU 0x04
+/***********/
+/****d* OpenSM: MC Member Record Receiver/OSM_DEFAULT_MGRP_RATE
+* Name
+* OSM_DEFAULT_MGRP_RATE
+*
+* DESCRIPTION
+* Default RATE used for new MGRP creation (10Gb/sec)
+* Note it includes the RateSelector which is set to "Greater Than"
+*
+* SYNOPSIS
+*/
+#define OSM_DEFAULT_MGRP_RATE 0x03
+/***********/
+/****d* OpenSM: MC Member Record Receiver/OSM_DEFAULT_MGRP_SCOPE
+* Name
+* OSM_DEFAULT_MGRP_SCOPE
+*
+* DESCRIPTION
+* Default SCOPE used for new MGRP creation (link local)
+*
+* SYNOPSIS
+*/
+#define OSM_DEFAULT_MGRP_SCOPE IB_MC_SCOPE_LINK_LOCAL
+/***********/
+/****d* OpenSM: Base/OSM_DEFAULT_QOS_MAX_VLS
+ * Name
+ * OSM_DEFAULT_QOS_MAX_VLS
+ *
+ * DESCRIPTION
+ * Default Maximum VLs used by the OpenSM.
+ *
+ * SYNOPSIS
+ */
+#define OSM_DEFAULT_QOS_MAX_VLS 15
+/***********/
+/****d* OpenSM: Base/OSM_DEFAULT_QOS_HIGH_LIMIT
+ * Name
+ * OSM_DEFAULT_QOS_HIGH_LIMIT
+ *
+ * DESCRIPTION
+ * Default Limit of High Priority in VL Arbitration used by OpenSM.
+ *
+ * SYNOPSIS
+ */
+#define OSM_DEFAULT_QOS_HIGH_LIMIT 0
+/***********/
+/****d* OpenSM: Base/OSM_DEFAULT_QOS_VLARB_HIGH
+ * Name
+ * OSM_DEFAULT_QOS_VLARB_HIGH
+ *
+ * DESCRIPTION
+ * Default High Priority VL Arbitration table used by the OpenSM.
+ *
+ * SYNOPSIS
+ */
+#define OSM_DEFAULT_QOS_VLARB_HIGH "0:4,1:0,2:0,3:0,4:0,5:0,6:0,7:0,8:0,9:0,10:0,11:0,12:0,13:0,14:0"
+/***********/
+/****d* OpenSM: Base/OSM_DEFAULT_QOS_VLARB_LOW
+ * Name
+ * OSM_DEFAULT_QOS_VLARB_LOW
+ *
+ * DESCRIPTION
+ * Default Low Priority VL Arbitration table used by the OpenSM.
+ *
+ * SYNOPSIS
+ */
+#define OSM_DEFAULT_QOS_VLARB_LOW "0:0,1:4,2:4,3:4,4:4,5:4,6:4,7:4,8:4,9:4,10:4,11:4,12:4,13:4,14:4"
+/***********/
+/****d* OpenSM: Base/OSM_DEFAULT_QOS_SL2VL
+ * Name
+ * OSM_DEFAULT_QOS_SL2VL
+ *
+ * DESCRIPTION
+ * Default QoS SL2VL Mapping Table used by the OpenSM.
+ *
+ * SYNOPSIS
+ */
+#define OSM_DEFAULT_QOS_SL2VL "0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,7"
+/***********/
+/****d* OpenSM: Base/OSM_NO_PATH
+* NAME
+* OSM_NO_PATH
+*
+* DESCRIPTION
+* Value indicating there is no path to the given LID.
+*
+* SYNOPSIS
+*/
+#define OSM_NO_PATH 0xFF
+/**********/
+/****d* OpenSM: Base/OSM_NODE_DESC_UNKNOWN
+* NAME
+* OSM_NODE_DESC_UNKNOWN
+*
+* DESCRIPTION
+* Value indicating the Node Description is not set and is "unknown"
+*
+* SYNOPSIS
+*/
+#define OSM_NODE_DESC_UNKNOWN "<unknown>"
+/**********/
+/****d* OpenSM: Base/osm_thread_state_t
+* NAME
+* osm_thread_state_t
+*
+* DESCRIPTION
+* Enumerates the possible states of worker threads, such
+* as the subnet sweeper.
+*
+* SYNOPSIS
+*/
+typedef enum _osm_thread_state {
+ OSM_THREAD_STATE_NONE = 0,
+ OSM_THREAD_STATE_INIT,
+ OSM_THREAD_STATE_RUN,
+ OSM_THREAD_STATE_EXIT
+} osm_thread_state_t;
+/***********/
+
+/*
+ * OSM_CAP are from IBA 1.2.1 Table 117 and Table 188
+ */
+
+/****d* OpenSM: Base/OSM_CAP_IS_TRAP_SUP
+* Name
+* OSM_CAP_IS_SUBN_TRAP_SUP
+*
+* DESCRIPTION
+* Management class generates Trap() MADs
+*
+* SYNOPSIS
+*/
+#define OSM_CAP_IS_SUBN_TRAP_SUP (1 << 0)
+/***********/
+
+/****d* OpenSM: Base/OSM_CAP_IS_GET_SET_NOTICE_SUP
+* Name
+* OSM_CAP_IS_GET_SET_NOTICE_SUP
+*
+* DESCRIPTION
+* Management class supports Get/Set(Notice)
+*
+* SYNOPSIS
+*/
+#define OSM_CAP_IS_SUBN_GET_SET_NOTICE_SUP (1 << 1)
+/***********/
+
+/****d* OpenSM: Base/OSM_CAP_IS_SUBN_OPT_RECS_SUP
+* Name
+* OSM_CAP_IS_SUBN_OPT_RECS_SUP
+*
+* DESCRIPTION
+* Support all optional attributes except:
+* MCMemberRecord, TraceRecord, MultiPathRecord
+*
+* SYNOPSIS
+*/
+#define OSM_CAP_IS_SUBN_OPT_RECS_SUP (1 << 8)
+/***********/
+
+/****d* OpenSM: Base/OSM_CAP_IS_UD_MCAST_SUP
+* Name
+* OSM_CAP_IS_UD_MCAST_SUP
+*
+* DESCRIPTION
+* Multicast is supported
+*
+* SYNOPSIS
+*/
+#define OSM_CAP_IS_UD_MCAST_SUP (1 << 9)
+/***********/
+
+/****d* OpenSM: Base/OSM_CAP_IS_MULTIPATH_SUP
+* Name
+* OSM_CAP_IS_MULTIPATH_SUP
+*
+* DESCRIPTION
+* MultiPathRecord and TraceRecord are supported
+*
+* SYNOPSIS
+*/
+#define OSM_CAP_IS_MULTIPATH_SUP (1 << 10)
+/***********/
+
+/****d* OpenSM: Base/OSM_CAP_IS_REINIT_SUP
+* Name
+* OSM_CAP_IS_REINIT_SUP
+*
+* DESCRIPTION
+* SM/SA supports re-initialization supported
+*
+* SYNOPSIS
+*/
+#define OSM_CAP_IS_REINIT_SUP (1 << 11)
+/***********/
+
+/****d* OpenSM: Base/OSM_CAP_IS_PORT_INFO_CAPMASK_MATCH_SUPPORTED
+* Name
+* OSM_CAP_IS_PORT_INFO_CAPMASK_MATCH_SUPPORTED
+*
+* DESCRIPTION
+* SM/SA supports enhanced SA PortInfoRecord searches per 1.2 Errata:
+* ClassPortInfo:CapabilityMask.IsPortInfoCapMaskMatchSupported is 1,
+* then the AttributeModifier of the SubnAdmGet() and SubnAdmGetTable()
+* methods affects the matching behavior on the PortInfo:CapabilityMask
+* component. If the high-order bit (bit 31) of the AttributeModifier
+* is set to 1, matching on the CapabilityMask component will not be an
+* exact bitwise match as described in <ref to 15.4.4>. Instead,
+* matching will only be performed on those bits which are set to 1 in
+* the PortInfo:CapabilityMask embedded in the query.
+*
+* SYNOPSIS
+*/
+#define OSM_CAP_IS_PORT_INFO_CAPMASK_MATCH_SUPPORTED (1 << 13)
+/***********/
+
+/****d* OpenSM: Base/OSM_CAP2_IS_QOS_SUPPORTED
+* Name
+* OSM_CAP2_IS_QOS_SUPPORTED
+*
+* DESCRIPTION
+* QoS is supported
+*
+* SYNOPSIS
+*/
+#define OSM_CAP2_IS_QOS_SUPPORTED (1 << 1)
+/***********/
+
+/****d* OpenSM: Base/OSM_CAP2_IS_REVERSE_PATH_PKEY_SUPPPORTED
+* Name
+* OSM_CAP2_IS_REVERSE_PATH_PKEY_SUPPPORTED
+*
+* DESCRIPTION
+* Reverse path PKeys indicate in PathRecord responses
+*
+* SYNOPSIS
+*/
+#define OSM_CAP2_IS_REVERSE_PATH_PKEY_SUPPPORTED (1 << 2)
+/***********/
+
+/****d* OpenSM: Base/OSM_CAP2_IS_MCAST_TOP_SUPPORTED
+* Name
+* OSM_CAP2_IS_MCAST_TOP_SUPPORTED
+*
+* DESCRIPTION
+* SwitchInfo.MulticastFDBTop is supported
+*
+* SYNOPSIS
+*/
+#define OSM_CAP2_IS_MCAST_TOP_SUPPORTED (1 << 3)
+/***********/
+
+/****d* OpenSM: Base/OSM_CAP2_IS_HIERARCHY_SUPPORTED
+* Name
+*
+* DESCRIPTION
+* Hierarchy info supported
+*
+* SYNOPSIS
+*/
+#define OSM_CAP2_IS_HIERARCHY_SUPPORTED (1 << 4)
+/***********/
+
+/****d* OpenSM: Base/OSM_CAP2_IS_ALIAS_GUIDS_SUPPORTED
+* Name
+*
+* DESCRIPTION
+* Alias GUIDs supported
+*
+* SYNOPSIS
+*/
+#define OSM_CAP2_IS_ALIAS_GUIDS_SUPPORTED (1 << 5)
+/***********/
+
+/****d* OpenSM: Base/OSM_CAP2_IS_FULL_PORTINFO_REC_SUPPORTED
+* Name
+* OSM_CAP2_IS_FULL_PORTINFO_REC_SUPPORTED
+*
+* DESCRIPTION
+* Full PortInfoRecords supported
+*
+* SYNOPSIS
+*/
+#define OSM_CAP2_IS_FULL_PORTINFO_REC_SUPPORTED (1 << 6)
+/***********/
+
+/****d* OpenSM: Base/OSM_CAP2_IS_EXTENDED_SPEEDS_SUPPORTED
+* Name
+* OSM_CAP2_IS_EXTENDED_SPEEDS_SUPPORTED
+*
+* DESCRIPTION
+* Extended Link Speeds supported
+*
+* SYNOPSIS
+*/
+#define OSM_CAP2_IS_EXTENDED_SPEEDS_SUPPORTED (1 << 7)
+/***********/
+
+/****d* OpenSM: Base/OSM_CAP2_IS_MULTICAST_SERVICE_RECS_SUPPORTED
+ * Name
+ * OSM_CAP2_IS_MULTICAST_SERVICE_RECS_SUPPORTED
+ *
+ * DESCRIPTION
+ * Multicast Service Records supported
+ *
+ * SYNOPSIS
+ */
+#define OSM_CAP2_IS_MULTICAST_SERVICE_RECS_SUPPORTED (1 << 8)
+
+/****d* OpenSM: Base/OSM_CAP2_IS_PORT_INFO_CAPMASK2_MATCH_SUPPORTED
+ * Name
+ * OSM_CAP2_IS_PORT_INFO_CAPMASK2_MATCH_SUPPORTED
+ *
+ * DESCRIPTION
+ * CapMask2 matching for PortInfoRecord supported
+ *
+ * SYNOPSIS
+ */
+#define OSM_CAP2_IS_PORT_INFO_CAPMASK2_MATCH_SUPPORTED (1 << 10)
+
+/****d* OpenSM: Base/OSM_CAP2_IS_LINK_WIDTH_2X_SUPPORTED
+ * Name
+ * OSM_CAP2_IS_LINK_WIDTH_2X_SUPPORTED
+ *
+ * DESCRIPTION
+ * 2x link widths supported
+ *
+ * SYNOPSIS
+ */
+#define OSM_CAP2_IS_LINK_WIDTH_2X_SUPPORTED (1 << 13)
+
+/****d* OpenSM: Base/osm_signal_t
+* NAME
+* osm_signal_t
+*
+* DESCRIPTION
+* Enumerates the possible signal codes used by the OSM managers
+* This cannot be an enum type, since conversion to and from
+* integral types is necessary when passing signals through
+* the dispatcher.
+*
+* SYNOPSIS
+*/
+#define OSM_SIGNAL_NONE 0
+#define OSM_SIGNAL_SWEEP 1
+#define OSM_SIGNAL_IDLE_TIME_PROCESS_REQUEST 2
+#define OSM_SIGNAL_PERFMGR_SWEEP 3
+#define OSM_SIGNAL_GUID_PROCESS_REQUEST 4
+#define OSM_SIGNAL_MAX 5
+
+typedef unsigned int osm_signal_t;
+/***********/
+
+/****d* OpenSM: Base/osm_sm_signal_t
+* NAME
+* osm_sm_signal_t
+*
+* DESCRIPTION
+* Enumerates the possible signals used by the OSM_SM_MGR
+*
+* SYNOPSIS
+*/
+typedef enum _osm_sm_signal {
+ OSM_SM_SIGNAL_NONE = 0,
+ OSM_SM_SIGNAL_DISCOVERY_COMPLETED,
+ OSM_SM_SIGNAL_POLLING_TIMEOUT,
+ OSM_SM_SIGNAL_DISCOVER,
+ OSM_SM_SIGNAL_DISABLE,
+ OSM_SM_SIGNAL_HANDOVER,
+ OSM_SM_SIGNAL_HANDOVER_SENT,
+ OSM_SM_SIGNAL_ACKNOWLEDGE,
+ OSM_SM_SIGNAL_STANDBY,
+ OSM_SM_SIGNAL_MASTER_OR_HIGHER_SM_DETECTED,
+ OSM_SM_SIGNAL_WAIT_FOR_HANDOVER,
+ OSM_SM_SIGNAL_MAX
+} osm_sm_signal_t;
+/***********/
+
+/****s* OpenSM: Base/MAX_GUID_FILE_LINE_LENGTH
+* NAME
+* MAX_GUID_FILE_LINE_LENGTH
+*
+* DESCRIPTION
+* The maximum line number when reading guid file
+*
+* SYNOPSIS
+*/
+#define MAX_GUID_FILE_LINE_LENGTH 120
+/**********/
+
+/****s* OpenSM: Base/VendorOUIs
+* NAME
+* VendorOUIs
+*
+* DESCRIPTION
+* Known device vendor ID and GUID OUIs
+*
+* SYNOPSIS
+*/
+#define OSM_VENDOR_ID_INTEL 0x00D0B7
+#define OSM_VENDOR_ID_MELLANOX 0x0002C9
+#define OSM_VENDOR_ID_REDSWITCH 0x000617
+#define OSM_VENDOR_ID_SILVERSTORM 0x00066A
+#define OSM_VENDOR_ID_TOPSPIN 0x0005AD
+#define OSM_VENDOR_ID_FUJITSU 0x00E000
+#define OSM_VENDOR_ID_FUJITSU2 0x000B5D
+#define OSM_VENDOR_ID_VOLTAIRE 0x0008F1
+#define OSM_VENDOR_ID_YOTTAYOTTA 0x000453
+#define OSM_VENDOR_ID_PATHSCALE 0x001175
+#define OSM_VENDOR_ID_IBM 0x000255
+#define OSM_VENDOR_ID_DIVERGENET 0x00084E
+#define OSM_VENDOR_ID_FLEXTRONICS 0x000B8C
+#define OSM_VENDOR_ID_AGILENT 0x0030D3
+#define OSM_VENDOR_ID_OBSIDIAN 0x001777
+#define OSM_VENDOR_ID_BAYMICRO 0x000BC1
+#define OSM_VENDOR_ID_LSILOGIC 0x00A0B8
+#define OSM_VENDOR_ID_DDN 0x0001FF
+#define OSM_VENDOR_ID_PANTA 0x001393
+#define OSM_VENDOR_ID_HP 0x001708
+#define OSM_VENDOR_ID_RIOWORKS 0x005045
+#define OSM_VENDOR_ID_SUN 0x0003BA
+#define OSM_VENDOR_ID_SUN2 0x002128
+#define OSM_VENDOR_ID_3LEAFNTWKS 0x0016A1
+#define OSM_VENDOR_ID_XSIGO 0x001397
+#define OSM_VENDOR_ID_HP2 0x0018FE
+#define OSM_VENDOR_ID_DELL 0x00188B
+#define OSM_VENDOR_ID_SUPERMICRO 0x003048
+#define OSM_VENDOR_ID_HP3 0x0019BB
+#define OSM_VENDOR_ID_HP4 0x00237D
+#define OSM_VENDOR_ID_OPENIB 0x001405
+#define OSM_VENDOR_ID_IBM2 0x5CF3FC
+#define OSM_VENDOR_ID_MELLANOX2 0xF45214
+#define OSM_VENDOR_ID_MELLANOX3 0x00258B
+#define OSM_VENDOR_ID_MELLANOX4 0xE41D2D
+#define OSM_VENDOR_ID_MELLANOX5 0x7CFE90
+#define OSM_VENDOR_ID_BULL 0x080038
+
+/* IPoIB Broadcast Defaults */
+#define OSM_IPOIB_BROADCAST_MGRP_QKEY 0x0b1b
+extern const ib_gid_t osm_ipoib_broadcast_mgid;
+
+/**********/
+
+END_C_DECLS
+#endif /* _OSM_BASE_H_ */
diff --git a/contrib/ofed/opensm/include/opensm/osm_config.h b/contrib/ofed/opensm/include/opensm/osm_config.h
new file mode 100644
index 0000000..54da585a
--- /dev/null
+++ b/contrib/ofed/opensm/include/opensm/osm_config.h
@@ -0,0 +1,69 @@
+/* include/opensm/osm_config.h. Generated from osm_config.h.in by configure. */
+/* include/osm_config.h.in
+ *
+ * Defines various OpenSM configuration parameters to be used by various
+ * plugins and third party tools.
+ *
+ * NOTE: Defines used in header files MUST be included here to ensure plugin
+ * compatibility.
+ */
+
+#ifndef _OSM_CONFIG_H_
+#define _OSM_CONFIG_H_ 1
+
+/* define 1 if OpenSM build is in a debug mode */
+/* #undef OSM_DEBUG */
+/* #undef _DEBUG_ */
+
+/* Define as 1 if you want Dual Sided RMPP Support */
+#define DUAL_SIDED_RMPP 1
+
+/* Define as 1 if you want to enable a console on a socket connection */
+/* #undef ENABLE_OSM_CONSOLE_SOCKET */
+
+/* Define as 1 if you want to enable the event plugin */
+/* #undef ENABLE_OSM_DEFAULT_EVENT_PLUGIN */
+
+/* Define as 1 if you want to enable the performance manager */
+#define ENABLE_OSM_PERF_MGR 1
+
+/* Define as 1 if you want to enable the performance manager profiling code */
+/* #undef ENABLE_OSM_PERF_MGR_PROFILE */
+
+/* Define a default node name map file */
+#define HAVE_DEFAULT_NODENAME_MAP "/etc/opensm/ib-node-name-map"
+
+/* Define a default OpenSM config file */
+#define HAVE_DEFAULT_OPENSM_CONFIG_FILE "/etc/opensm/opensm.conf"
+
+/* Define a Partition config file */
+#define HAVE_DEFAULT_PARTITION_CONFIG_FILE "/etc/opensm/partitions.conf"
+
+/* Define a Prefix Routes config file */
+#define HAVE_DEFAULT_PREFIX_ROUTES_FILE "/etc/opensm/prefix-routes.conf"
+
+/* Define a QOS policy config file */
+#define HAVE_DEFAULT_QOS_POLICY_FILE "/etc/opensm/qos-policy.conf"
+
+/* Define OpenSM config directory */
+#define OPENSM_CONFIG_DIR "/etc/opensm"
+
+/* Define as 1 for vapi vendor */
+/* #undef OSM_VENDOR_INTF_MTL */
+
+/* Define as 1 for OpenIB vendor */
+#define OSM_VENDOR_INTF_OPENIB 1
+
+/* Define as 1 for sim vendor */
+/* #undef OSM_VENDOR_INTF_SIM */
+
+/* Define as 1 for ts vendor */
+/* #undef OSM_VENDOR_INTF_TS */
+
+/* Define as 1 if you want Vendor RMPP Support */
+#define VENDOR_RMPP_SUPPORT 1
+
+/* Define to 1 if you have the `pthread' library (-lpthread). */
+#define HAVE_LIBPTHREAD 1
+
+#endif /* _OSM_CONFIG_H_ */
diff --git a/contrib/ofed/opensm/include/opensm/osm_congestion_control.h b/contrib/ofed/opensm/include/opensm/osm_congestion_control.h
new file mode 100644
index 0000000..78e4a64
--- /dev/null
+++ b/contrib/ofed/opensm/include/opensm/osm_congestion_control.h
@@ -0,0 +1,134 @@
+/*
+ * Copyright (c) 2004-2009 Voltaire, Inc. All rights reserved.
+ * Copyright (c) 2002-2008 Mellanox Technologies LTD. All rights reserved.
+ * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
+ * Copyright (c) 2012 Lawrence Livermore National Lab. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+/*
+ * Abstract:
+ * OSM Congestion Control types and prototypes
+ *
+ * Author:
+ * Albert Chu, LLNL
+ */
+
+#ifndef OSM_CONGESTION_CONTROL_H
+#define OSM_CONGESTION_CONTROL_H
+
+#include <iba/ib_types.h>
+#include <complib/cl_types_osd.h>
+#include <complib/cl_dispatcher.h>
+#include <opensm/osm_subnet.h>
+#include <opensm/osm_log.h>
+#include <opensm/osm_sm.h>
+#include <opensm/osm_opensm.h>
+#include <opensm/osm_base.h>
+
+/****s* OpenSM: Base/OSM_DEFAULT_CC_KEY
+ * NAME
+ * OSM_DEFAULT_CC_KEY
+ *
+ * DESCRIPTION
+ * Congestion Control Key used by OpenSM.
+ *
+ * SYNOPSIS
+ */
+#define OSM_DEFAULT_CC_KEY 0
+
+#define OSM_CC_DEFAULT_MAX_OUTSTANDING_QUERIES 500
+
+#define OSM_CC_TIMEOUT_COUNT_THRESHOLD 3
+
+/****s* OpenSM: CongestionControl/osm_congestion_control_t
+* This object should be treated as opaque and should
+* be manipulated only through the provided functions.
+*/
+typedef struct osm_congestion_control {
+ struct osm_opensm *osm;
+ osm_subn_t *subn;
+ osm_sm_t *sm;
+ osm_log_t *log;
+ osm_mad_pool_t *mad_pool;
+ atomic32_t trans_id;
+ osm_vendor_t *vendor;
+ osm_bind_handle_t bind_handle;
+ cl_disp_reg_handle_t cc_disp_h;
+ ib_net64_t port_guid;
+ atomic32_t outstanding_mads;
+ atomic32_t outstanding_mads_on_wire;
+ cl_qlist_t mad_queue;
+ cl_spinlock_t mad_queue_lock;
+ cl_event_t cc_poller_wakeup;
+ cl_event_t outstanding_mads_done_event;
+ cl_event_t sig_mads_on_wire_continue;
+ cl_thread_t cc_poller;
+ osm_thread_state_t thread_state;
+ ib_sw_cong_setting_t sw_cong_setting;
+ ib_ca_cong_setting_t ca_cong_setting;
+ ib_cc_tbl_t cc_tbl[OSM_CCT_ENTRY_MAD_BLOCKS];
+ unsigned int cc_tbl_mads;
+} osm_congestion_control_t;
+/*
+* FIELDS
+* subn
+* Subnet object for this subnet.
+*
+* log
+* Pointer to the log object.
+*
+* mad_pool
+* Pointer to the MAD pool.
+*
+* mad_ctrl
+* Mad Controller
+*********/
+
+struct osm_opensm;
+
+int osm_congestion_control_setup(struct osm_opensm *osm);
+
+int osm_congestion_control_wait_pending_transactions(struct osm_opensm *osm);
+
+ib_api_status_t osm_congestion_control_init(osm_congestion_control_t * p_cc,
+ struct osm_opensm *osm,
+ const osm_subn_opt_t * p_opt);
+
+ib_api_status_t osm_congestion_control_bind(osm_congestion_control_t * p_cc,
+ ib_net64_t port_guid);
+
+void osm_congestion_control_shutdown(osm_congestion_control_t * p_cc);
+
+void osm_congestion_control_destroy(osm_congestion_control_t * p_cc);
+
+
+#endif /* ifndef OSM_CONGESTION_CONTROL_H */
diff --git a/contrib/ofed/opensm/include/opensm/osm_console.h b/contrib/ofed/opensm/include/opensm/osm_console.h
new file mode 100644
index 0000000..9144ae1
--- /dev/null
+++ b/contrib/ofed/opensm/include/opensm/osm_console.h
@@ -0,0 +1,50 @@
+/*
+ * Copyright (c) 2005-2007 Voltaire, Inc. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+#ifndef _OSM_CONSOLE_H_
+#define _OSM_CONSOLE_H_
+
+#include <opensm/osm_opensm.h>
+
+#ifdef __cplusplus
+# define BEGIN_C_DECLS extern "C" {
+# define END_C_DECLS }
+#else /* !__cplusplus */
+# define BEGIN_C_DECLS
+# define END_C_DECLS
+#endif /* __cplusplus */
+
+BEGIN_C_DECLS
+int osm_console(osm_opensm_t * p_osm);
+END_C_DECLS
+#endif /* _OSM_CONSOLE_H_ */
diff --git a/contrib/ofed/opensm/include/opensm/osm_console_io.h b/contrib/ofed/opensm/include/opensm/osm_console_io.h
new file mode 100644
index 0000000..7bf1313
--- /dev/null
+++ b/contrib/ofed/opensm/include/opensm/osm_console_io.h
@@ -0,0 +1,97 @@
+/*
+ * Copyright (c) 2005-2007 Voltaire, Inc. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+/*
+ * Abstract:
+ * Declaration of osm_console_t.
+ * This object represents the OpenSM Console object.
+ * This object is part of the OpenSM family of objects.
+ */
+
+#ifndef _OSM_CONSOLE_IO_H_
+#define _OSM_CONSOLE_IO_H_
+
+#include <opensm/osm_subnet.h>
+#include <opensm/osm_log.h>
+
+#define OSM_DISABLE_CONSOLE "off"
+#define OSM_LOCAL_CONSOLE "local"
+#ifdef ENABLE_OSM_CONSOLE_SOCKET
+#define OSM_REMOTE_CONSOLE "socket"
+#endif
+#ifdef ENABLE_OSM_CONSOLE_LOOPBACK
+#define OSM_LOOPBACK_CONSOLE "loopback"
+#endif
+#define OSM_CONSOLE_NAME "OSM Console"
+
+#define OSM_DEFAULT_CONSOLE OSM_DISABLE_CONSOLE
+#define OSM_DEFAULT_CONSOLE_PORT 10000
+#define OSM_DAEMON_NAME "opensm"
+
+#define OSM_COMMAND_PROMPT "$ "
+
+#ifdef __cplusplus
+# define BEGIN_C_DECLS extern "C" {
+# define END_C_DECLS }
+#else /* !__cplusplus */
+# define BEGIN_C_DECLS
+# define END_C_DECLS
+#endif /* __cplusplus */
+
+BEGIN_C_DECLS
+typedef struct osm_console {
+ int socket;
+ int in_fd;
+ int out_fd;
+ int authorized;
+ FILE *in;
+ FILE *out;
+ char client_type[32];
+ char client_ip[64];
+ char client_hn[128];
+} osm_console_t;
+
+void osm_console_prompt(FILE * out);
+int osm_console_init(osm_subn_opt_t * opt, osm_console_t * p_oct, osm_log_t * p_log);
+void osm_console_exit(osm_console_t * p_oct, osm_log_t * p_log);
+int is_console_enabled(osm_subn_opt_t *p_opt);
+
+#ifdef ENABLE_OSM_CONSOLE_LOOPBACK
+int cio_open(osm_console_t * p_oct, int new_fd, osm_log_t * p_log);
+int cio_close(osm_console_t * p_oct, osm_log_t * p_log);
+int is_authorized(osm_console_t * p_oct);
+#else
+#define cio_close(c, log)
+#endif
+
+END_C_DECLS
+#endif /* _OSM_CONSOLE_IO_H_ */
diff --git a/contrib/ofed/opensm/include/opensm/osm_db.h b/contrib/ofed/opensm/include/opensm/osm_db.h
new file mode 100644
index 0000000..e8860f3
--- /dev/null
+++ b/contrib/ofed/opensm/include/opensm/osm_db.h
@@ -0,0 +1,430 @@
+/*
+ * Copyright (c) 2004-2009 Voltaire, Inc. All rights reserved.
+ * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved.
+ * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+#ifndef _OSM_DB_H_
+#define _OSM_DB_H_
+
+/*
+ * Abstract:
+ * Declaration of the DB interface.
+ */
+
+#include <complib/cl_list.h>
+#include <complib/cl_spinlock.h>
+
+struct osm_log;
+
+#ifdef __cplusplus
+# define BEGIN_C_DECLS extern "C" {
+# define END_C_DECLS }
+#else /* !__cplusplus */
+# define BEGIN_C_DECLS
+# define END_C_DECLS
+#endif /* __cplusplus */
+
+BEGIN_C_DECLS
+/****h* OpenSM/Database
+* NAME
+* Database
+*
+* DESCRIPTION
+* The OpenSM database interface provide the means to restore persistent
+* data, query, modify, delete and eventually commit it back to the
+* persistent media.
+*
+* The interface is defined such that it can is not "data dependent":
+* All keys and data items are texts.
+*
+* The DB implementation should be thread safe, thus callers do not need to
+* provide serialization.
+*
+* This object should be treated as opaque and should be
+* manipulated only through the provided functions.
+*
+* AUTHOR
+* Eitan Zahavi, Mellanox Technologies LTD
+*
+*********/
+/****s* OpenSM: Database/osm_db_domain_t
+* NAME
+* osm_db_domain_t
+*
+* DESCRIPTION
+* A domain of the database. Can be viewed as a database table.
+*
+* The osm_db_domain_t object should be treated as opaque and should
+* be manipulated only through the provided functions.
+*
+* SYNOPSIS
+*/
+typedef struct osm_db_domain {
+ struct osm_db *p_db;
+ void *p_domain_imp;
+} osm_db_domain_t;
+/*
+* FIELDS
+* p_db
+* Pointer to the parent database object.
+*
+* p_domain_imp
+* Pointer to the db implementation object
+*
+* SEE ALSO
+* osm_db_t
+*********/
+
+/****s* OpenSM: Database/osm_db_t
+* NAME
+* osm_db_t
+*
+* DESCRIPTION
+* The main database object.
+*
+* The osm_db_t object should be treated as opaque and should
+* be manipulated only through the provided functions.
+*
+* SYNOPSIS
+*/
+typedef struct osm_db {
+ void *p_db_imp;
+ struct osm_log *p_log;
+ cl_list_t domains;
+} osm_db_t;
+/*
+* FIELDS
+* p_db_imp
+* Pointer to the database implementation object
+*
+* p_log
+* Pointer to the OSM logging facility
+*
+* domains
+* List of initialize domains
+*
+* SEE ALSO
+*********/
+
+/****f* OpenSM: Database/osm_db_construct
+* NAME
+* osm_db_construct
+*
+* DESCRIPTION
+* Construct a database.
+*
+* SYNOPSIS
+*/
+void osm_db_construct(IN osm_db_t * p_db);
+/*
+* PARAMETERS
+* p_db
+* [in] Pointer to the database object to construct
+*
+* RETURN VALUES
+* NONE
+*
+* SEE ALSO
+* Database, osm_db_init, osm_db_destroy
+*********/
+
+/****f* OpenSM: Database/osm_db_destroy
+* NAME
+* osm_db_destroy
+*
+* DESCRIPTION
+* Destroys the osm_db_t structure.
+*
+* SYNOPSIS
+*/
+void osm_db_destroy(IN osm_db_t * p_db);
+/*
+* PARAMETERS
+* p_db
+* [in] Pointer to osm_db_t structure to destroy
+*
+* SEE ALSO
+* Database, osm_db_construct, osm_db_init
+*********/
+
+/****f* OpenSM: Database/osm_db_init
+* NAME
+* osm_db_init
+*
+* DESCRIPTION
+* Initializes the osm_db_t structure.
+*
+* SYNOPSIS
+*/
+int osm_db_init(IN osm_db_t * p_db, IN struct osm_log * p_log);
+/*
+* PARAMETERS
+*
+* p_db
+* [in] Pointer to the database object to initialize
+*
+* p_log
+* [in] Pointer to the OSM logging facility
+*
+* RETURN VALUES
+* 0 on success 1 otherwise
+*
+* SEE ALSO
+* Database, osm_db_construct, osm_db_destroy
+*********/
+
+/****f* OpenSM: Database/osm_db_domain_init
+* NAME
+* osm_db_domain_init
+*
+* DESCRIPTION
+* Initializes the osm_db_domain_t structure.
+*
+* SYNOPSIS
+*/
+osm_db_domain_t *osm_db_domain_init(IN osm_db_t * p_db, IN const char *domain_name);
+/*
+* PARAMETERS
+*
+* p_db
+* [in] Pointer to the database object to initialize
+*
+* domain_name
+* [in] a char array with the domain name.
+*
+* RETURN VALUES
+* pointer to the new domain object or NULL if failed.
+*
+* SEE ALSO
+* Database, osm_db_construct, osm_db_destroy
+*********/
+
+/****f* OpenSM: Database/osm_db_restore
+* NAME
+* osm_db_restore
+*
+* DESCRIPTION
+* Reads the entire domain from persistent storage - overrides all
+* existing cached data (if any).
+*
+* SYNOPSIS
+*/
+int osm_db_restore(IN osm_db_domain_t * p_domain);
+/*
+* PARAMETERS
+*
+* p_domain
+* [in] Pointer to the database domain object to restore
+* from persistent db
+*
+* RETURN VALUES
+* 0 if successful 1 otherwize
+*
+* SEE ALSO
+* Database, osm_db_domain_init, osm_db_clear, osm_db_store,
+* osm_db_keys, osm_db_lookup, osm_db_update, osm_db_delete
+*********/
+
+/****f* OpenSM: Database/osm_db_clear
+* NAME
+* osm_db_clear
+*
+* DESCRIPTION
+* Clears the entire domain values from/in the cache
+*
+* SYNOPSIS
+*/
+int osm_db_clear(IN osm_db_domain_t * p_domain);
+/*
+* PARAMETERS
+*
+* p_domain
+* [in] Pointer to the database domain object to clear
+*
+* RETURN VALUES
+* 0 if successful 1 otherwize
+*
+* SEE ALSO
+* Database, osm_db_domain_init, osm_db_restore, osm_db_store,
+* osm_db_keys, osm_db_lookup, osm_db_update, osm_db_delete
+*********/
+
+/****f* OpenSM: Database/osm_db_store
+* NAME
+* osm_db_store
+*
+* DESCRIPTION
+* Store the domain cache back to the database (commit)
+*
+* SYNOPSIS
+*/
+int osm_db_store(IN osm_db_domain_t * p_domain,
+ IN boolean_t fsync_high_avail_files);
+/*
+* PARAMETERS
+*
+* p_domain
+* [in] Pointer to the database domain object to restore from
+* persistent db
+*
+* fsync_high_avail_files
+* [in] Boolean that indicates whether or not to synchronize
+* in-memory high availability files with storage
+*
+* RETURN VALUES
+* 0 if successful 1 otherwize
+*
+* SEE ALSO
+* Database, osm_db_domain_init, osm_db_restore, osm_db_clear,
+* osm_db_keys, osm_db_lookup, osm_db_update, osm_db_delete
+*********/
+
+/****f* OpenSM: Database/osm_db_keys
+* NAME
+* osm_db_keys
+*
+* DESCRIPTION
+* Retrive all keys of the domain
+*
+* SYNOPSIS
+*/
+int osm_db_keys(IN osm_db_domain_t * p_domain, OUT cl_list_t * p_key_list);
+/*
+* PARAMETERS
+*
+* p_domain
+* [in] Pointer to the database domain object
+*
+* p_key_list
+* [out] List of key values. It should be PRE constructed and initialized.
+*
+* RETURN VALUES
+* 0 if successful 1 otherwize
+*
+* NOTE: the caller needs to free and destruct the list,
+* the keys returned are intrnal to the hash and should NOT be free'ed
+*
+* SEE ALSO
+* Database, osm_db_domain_init, osm_db_restore, osm_db_clear, osm_db_store,
+* osm_db_lookup, osm_db_update, osm_db_delete
+*********/
+
+/****f* OpenSM: Database/osm_db_lookup
+* NAME
+* osm_db_lookup
+*
+* DESCRIPTION
+* Lookup an entry in the domain by the given key
+*
+* SYNOPSIS
+*/
+/* lookup value by key */
+char *osm_db_lookup(IN osm_db_domain_t * p_domain, IN char *p_key);
+/*
+* PARAMETERS
+*
+* p_domain
+* [in] Pointer to the database domain object
+*
+* key
+* [in] The key to look for
+*
+* RETURN VALUES
+* the value as char * or NULL if not found
+*
+* SEE ALSO
+* Database, osm_db_domain_init, osm_db_restore, osm_db_clear, osm_db_store,
+* osm_db_keys, osm_db_update, osm_db_delete
+*********/
+
+/****f* OpenSM: Database/osm_db_update
+* NAME
+* osm_db_update
+*
+* DESCRIPTION
+* Set the value of the given key
+*
+* SYNOPSIS
+*/
+int osm_db_update(IN osm_db_domain_t * p_domain, IN char *p_key, IN char *p_val);
+/*
+* PARAMETERS
+*
+* p_domain
+* [in] Pointer to the database domain object
+*
+* p_key
+* [in] The key to update
+*
+* p_val
+* [in] The value to update
+*
+* RETURN VALUES
+* 0 on success
+*
+* NOTE: the value will be duplicated so can be free'ed
+*
+* SEE ALSO
+* Database, osm_db_domain_init, osm_db_restore, osm_db_clear, osm_db_store,
+* osm_db_keys, osm_db_lookup, osm_db_delete
+*********/
+
+/****f* OpenSM: Database/osm_db_delete
+* NAME
+* osm_db_delete
+*
+* DESCRIPTION
+* Delete an entry by the given key
+*
+* SYNOPSIS
+*/
+int osm_db_delete(IN osm_db_domain_t * p_domain, IN char *p_key);
+/*
+* PARAMETERS
+*
+* p_domain
+* [in] Pointer to the database domain object
+*
+* p_key
+* [in] The key to look for
+*
+* RETURN VALUES
+* 0 on success
+*
+* SEE ALSO
+* Database, osm_db_domain_init, osm_db_restore, osm_db_clear, osm_db_store,
+* osm_db_keys, osm_db_lookup, osm_db_update
+*********/
+
+END_C_DECLS
+#endif /* _OSM_DB_H_ */
diff --git a/contrib/ofed/opensm/include/opensm/osm_db_pack.h b/contrib/ofed/opensm/include/opensm/osm_db_pack.h
new file mode 100644
index 0000000..f2d7af2
--- /dev/null
+++ b/contrib/ofed/opensm/include/opensm/osm_db_pack.h
@@ -0,0 +1,568 @@
+/*
+ * Copyright (c) 2004-2009 Voltaire, Inc. All rights reserved.
+ * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved.
+ * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+/****h* OpenSM/DB-Pack
+* NAME
+* Database Types
+*
+* DESCRIPTION
+* This module provides packing and unpacking of the database
+* storage into specific types.
+*
+* The following domains/conversions are supported:
+* guid2lid - key is a guid and data is a lid.
+*
+* AUTHOR
+* Eitan Zahavi, Mellanox Technologies LTD
+*
+*********/
+
+#ifndef _OSM_DB_PACK_H_
+#define _OSM_DB_PACK_H_
+
+#include <opensm/osm_db.h>
+
+#ifdef __cplusplus
+# define BEGIN_C_DECLS extern "C" {
+# define END_C_DECLS }
+#else /* !__cplusplus */
+# define BEGIN_C_DECLS
+# define END_C_DECLS
+#endif /* __cplusplus */
+
+BEGIN_C_DECLS
+/****f* OpenSM: DB-Pack/osm_db_guid2lid_init
+* NAME
+* osm_db_guid2lid_init
+*
+* DESCRIPTION
+* Initialize a domain for the guid2lid table
+*
+* SYNOPSIS
+*/
+static inline osm_db_domain_t *osm_db_guid2lid_init(IN osm_db_t * p_db)
+{
+ return (osm_db_domain_init(p_db, "guid2lid"));
+}
+
+/*
+* PARAMETERS
+* p_db
+* [in] Pointer to the database object to construct
+*
+* RETURN VALUES
+* The pointer to the new allocated domain object or NULL.
+*
+* NOTE: DB domains are destroyed by the osm_db_destroy
+*
+* SEE ALSO
+* Database, osm_db_init, osm_db_destroy
+*********/
+
+/****f* OpenSM: DB-Pack/osm_db_guid2lid_init
+* NAME
+* osm_db_guid2lid_init
+*
+* DESCRIPTION
+* Initialize a domain for the guid2lid table
+*
+* SYNOPSIS
+*/
+typedef struct osm_db_guid_elem {
+ cl_list_item_t item;
+ uint64_t guid;
+} osm_db_guid_elem_t;
+/*
+* FIELDS
+* item
+* required for list manipulations
+*
+* guid
+*
+************/
+
+/****f* OpenSM: DB-Pack/osm_db_guid2lid_guids
+* NAME
+* osm_db_guid2lid_guids
+*
+* DESCRIPTION
+* Provides back a list of guid elements.
+*
+* SYNOPSIS
+*/
+int osm_db_guid2lid_guids(IN osm_db_domain_t * p_g2l,
+ OUT cl_qlist_t * p_guid_list);
+/*
+* PARAMETERS
+* p_g2l
+* [in] Pointer to the guid2lid domain
+*
+* p_guid_list
+* [out] A quick list of guid elements of type osm_db_guid_elem_t
+*
+* RETURN VALUES
+* 0 if successful
+*
+* NOTE: the output qlist should be initialized and each item freed
+* by the caller, then destroyed.
+*
+* SEE ALSO
+* osm_db_guid2lid_init, osm_db_guid2lid_guids, osm_db_guid2lid_get
+* osm_db_guid2lid_set, osm_db_guid2lid_delete
+*********/
+
+/****f* OpenSM: DB-Pack/osm_db_guid2lid_get
+* NAME
+* osm_db_guid2lid_get
+*
+* DESCRIPTION
+* Get a lid range by given guid.
+*
+* SYNOPSIS
+*/
+int osm_db_guid2lid_get(IN osm_db_domain_t * p_g2l, IN uint64_t guid,
+ OUT uint16_t * p_min_lid, OUT uint16_t * p_max_lid);
+/*
+* PARAMETERS
+* p_g2l
+* [in] Pointer to the guid2lid domain
+*
+* guid
+* [in] The guid to look for
+*
+* p_min_lid
+* [out] Pointer to the resulting min lid in host order.
+*
+* p_max_lid
+* [out] Pointer to the resulting max lid in host order.
+*
+* RETURN VALUES
+* 0 if successful. The lid will be set to 0 if not found.
+*
+* SEE ALSO
+* osm_db_guid2lid_init, osm_db_guid2lid_guids
+* osm_db_guid2lid_set, osm_db_guid2lid_delete
+*********/
+
+/****f* OpenSM: DB-Pack/osm_db_guid2lid_set
+* NAME
+* osm_db_guid2lid_set
+*
+* DESCRIPTION
+* Set a lid range for the given guid.
+*
+* SYNOPSIS
+*/
+int osm_db_guid2lid_set(IN osm_db_domain_t * p_g2l, IN uint64_t guid,
+ IN uint16_t min_lid, IN uint16_t max_lid);
+/*
+* PARAMETERS
+* p_g2l
+* [in] Pointer to the guid2lid domain
+*
+* guid
+* [in] The guid to look for
+*
+* min_lid
+* [in] The min lid value to set
+*
+* max_lid
+* [in] The max lid value to set
+*
+* RETURN VALUES
+* 0 if successful
+*
+* SEE ALSO
+* osm_db_guid2lid_init, osm_db_guid2lid_guids
+* osm_db_guid2lid_get, osm_db_guid2lid_delete
+*********/
+
+/****f* OpenSM: DB-Pack/osm_db_guid2lid_delete
+* NAME
+* osm_db_guid2lid_delete
+*
+* DESCRIPTION
+* Delete the entry by the given guid
+*
+* SYNOPSIS
+*/
+int osm_db_guid2lid_delete(IN osm_db_domain_t * p_g2l, IN uint64_t guid);
+/*
+* PARAMETERS
+* p_g2l
+* [in] Pointer to the guid2lid domain
+*
+* guid
+* [in] The guid to look for
+*
+* RETURN VALUES
+* 0 if successful otherwise 1
+*
+* SEE ALSO
+* osm_db_guid2lid_init, osm_db_guid2lid_guids
+* osm_db_guid2lid_get, osm_db_guid2lid_set
+*********/
+
+/****f* OpenSM: DB-Pack/osm_db_guid2mkey_init
+* NAME
+* osm_db_guid2mkey_init
+*
+* DESCRIPTION
+* Initialize a domain for the guid2mkey table
+*
+* SYNOPSIS
+*/
+static inline osm_db_domain_t *osm_db_guid2mkey_init(IN osm_db_t * p_db)
+{
+ return osm_db_domain_init(p_db, "guid2mkey");
+}
+
+/*
+* PARAMETERS
+* p_db
+* [in] Pointer to the database object to construct
+*
+* RETURN VALUES
+* The pointer to the new allocated domain object or NULL.
+*
+* NOTE: DB domains are destroyed by the osm_db_destroy
+*
+* SEE ALSO
+* Database, osm_db_init, osm_db_destroy
+*********/
+
+/****f* OpenSM: DB-Pack/osm_db_guid2mkey_guids
+* NAME
+* osm_db_guid2mkey_guids
+*
+* DESCRIPTION
+* Provides back a list of guid elements.
+*
+* SYNOPSIS
+*/
+int osm_db_guid2mkey_guids(IN osm_db_domain_t * p_g2m,
+ OUT cl_qlist_t * p_guid_list);
+/*
+* PARAMETERS
+* p_g2l
+* [in] Pointer to the guid2mkey domain
+*
+* p_guid_list
+* [out] A quick list of guid elements of type osm_db_guid_elem_t
+*
+* RETURN VALUES
+* 0 if successful
+*
+* NOTE: the output qlist should be initialized and each item freed
+* by the caller, then destroyed.
+*
+* SEE ALSO
+* osm_db_guid2mkey_init, osm_db_guid2mkey_guids, osm_db_guid2mkey_get
+* osm_db_guid2mkey_set, osm_db_guid2mkey_delete
+*********/
+
+/****f* OpenSM: DB-Pack/osm_db_guid2mkey_get
+* NAME
+* osm_db_guid2mkey_get
+*
+* DESCRIPTION
+* Get the mkey for the given guid.
+*
+* SYNOPSIS
+*/
+int osm_db_guid2mkey_get(IN osm_db_domain_t * p_g2m, IN uint64_t guid,
+ OUT uint64_t * p_mkey);
+/*
+* PARAMETERS
+* p_g2m
+* [in] Pointer to the guid2mkey domain
+*
+* guid
+* [in] The guid to look for
+*
+* p_mkey
+* [out] Pointer to the resulting mkey in host order.
+*
+* RETURN VALUES
+* 0 if successful. The lid will be set to 0 if not found.
+*
+* SEE ALSO
+* osm_db_guid2mkey_init, osm_db_guid2mkey_guids
+* osm_db_guid2mkey_set, osm_db_guid2mkey_delete
+*********/
+
+/****f* OpenSM: DB-Pack/osm_db_guid2mkey_set
+* NAME
+* osm_db_guid2mkey_set
+*
+* DESCRIPTION
+* Set the mkey for the given guid.
+*
+* SYNOPSIS
+*/
+int osm_db_guid2mkey_set(IN osm_db_domain_t * p_g2m, IN uint64_t guid,
+ IN uint64_t mkey);
+/*
+* PARAMETERS
+* p_g2m
+* [in] Pointer to the guid2mkey domain
+*
+* guid
+* [in] The guid to look for
+*
+* mkey
+* [in] The mkey value to set, in host order
+*
+* RETURN VALUES
+* 0 if successful
+*
+* SEE ALSO
+* osm_db_guid2mkey_init, osm_db_guid2mkey_guids
+* osm_db_guid2mkey_get, osm_db_guid2mkey_delete
+*********/
+
+/****f* OpenSM: DB-Pack/osm_db_guid2mkey_delete
+* NAME
+* osm_db_guid2mkey_delete
+*
+* DESCRIPTION
+* Delete the entry by the given guid
+*
+* SYNOPSIS
+*/
+int osm_db_guid2mkey_delete(IN osm_db_domain_t * p_g2m, IN uint64_t guid);
+/*
+* PARAMETERS
+* p_g2m
+* [in] Pointer to the guid2mkey domain
+*
+* guid
+* [in] The guid to look for
+*
+* RETURN VALUES
+* 0 if successful otherwise 1
+*
+* SEE ALSO
+* osm_db_guid2mkey_init, osm_db_guid2mkey_guids
+* osm_db_guid2mkey_get, osm_db_guid2mkey_set
+*********/
+
+/****f* OpenSM: DB-Pack/osm_db_neighbor_init
+* NAME
+* osm_db_neighbor_init
+*
+* DESCRIPTION
+* Initialize a domain for the neighbors table
+*
+* SYNOPSIS
+*/
+static inline osm_db_domain_t *osm_db_neighbor_init(IN osm_db_t * p_db)
+{
+ return osm_db_domain_init(p_db, "neighbors");
+}
+
+/*
+* PARAMETERS
+* p_db
+* [in] Pointer to the database object to construct
+*
+* RETURN VALUES
+* The pointer to the new allocated domain object or NULL.
+*
+* NOTE: DB domains are destroyed by the osm_db_destroy
+*
+* SEE ALSO
+* Database, osm_db_init, osm_db_destroy
+*********/
+
+/****f* OpenSM: DB-Pack/osm_db_neighbor_elem
+* NAME
+* osm_db_neighbor_elem
+*
+* DESCRIPTION
+* Initialize a domain for the neighbor table
+*
+* SYNOPSIS
+*/
+typedef struct osm_db_neighbor_elem {
+ cl_list_item_t item;
+ uint64_t guid;
+ uint8_t portnum;
+} osm_db_neighbor_elem_t;
+/*
+* FIELDS
+* item
+* required for list manipulations
+*
+* guid
+* portnum
+*
+************/
+
+/****f* OpenSM: DB-Pack/osm_db_neighbor_guids
+* NAME
+* osm_db_neighbor_guids
+*
+* DESCRIPTION
+* Provides back a list of neighbor elements.
+*
+* SYNOPSIS
+*/
+int osm_db_neighbor_guids(IN osm_db_domain_t * p_neighbor,
+ OUT cl_qlist_t * p_guid_list);
+/*
+* PARAMETERS
+* p_neighbor
+* [in] Pointer to the neighbor domain
+*
+* p_guid_list
+* [out] A quick list of neighbor elements of type osm_db_neighbor_elem_t
+*
+* RETURN VALUES
+* 0 if successful
+*
+* NOTE: the output qlist should be initialized and each item freed
+* by the caller, then destroyed.
+*
+* SEE ALSO
+* osm_db_neighbor_init, osm_db_neighbor_guids, osm_db_neighbor_get
+* osm_db_neighbor_set, osm_db_neighbor_delete
+*********/
+
+/****f* OpenSM: DB-Pack/osm_db_neighbor_get
+* NAME
+* osm_db_neighbor_get
+*
+* DESCRIPTION
+* Get a neighbor's guid by given guid/port.
+*
+* SYNOPSIS
+*/
+int osm_db_neighbor_get(IN osm_db_domain_t * p_neighbor, IN uint64_t guid1,
+ IN uint8_t port1, OUT uint64_t * p_guid2,
+ OUT uint8_t * p_port2);
+/*
+* PARAMETERS
+* p_neighbor
+* [in] Pointer to the neighbor domain
+*
+* guid1
+* [in] The guid to look for
+*
+* port1
+* [in] The port to look for
+*
+* p_guid2
+* [out] Pointer to the resulting guid of the neighboring port.
+*
+* p_port2
+* [out] Pointer to the resulting port of the neighboring port.
+*
+* RETURN VALUES
+* 0 if successful. The lid will be set to 0 if not found.
+*
+* SEE ALSO
+* osm_db_neighbor_init, osm_db_neighbor_guids
+* osm_db_neighbor_set, osm_db_neighbor_delete
+*********/
+
+/****f* OpenSM: DB-Pack/osm_db_neighbor_set
+* NAME
+* osm_db_neighbor_set
+*
+* DESCRIPTION
+* Set up a relationship between two ports
+*
+* SYNOPSIS
+*/
+int osm_db_neighbor_set(IN osm_db_domain_t * p_neighbor, IN uint64_t guid1,
+ IN uint8_t port1, IN uint64_t guid2, IN uint8_t port2);
+/*
+* PARAMETERS
+* p_neighbor
+* [in] Pointer to the neighbor domain
+*
+* guid1
+* [in] The first guid in the relationship
+*
+* port1
+* [in] The first port in the relationship
+*
+* guid2
+* [in] The second guid in the relationship
+*
+* port2
+* [in] The second port in the relationship
+*
+* RETURN VALUES
+* 0 if successful
+*
+* SEE ALSO
+* osm_db_neighbor_init, osm_db_neighbor_guids
+* osm_db_neighbor_get, osm_db_neighbor_delete
+*********/
+
+/****f* OpenSM: DB-Pack/osm_db_neighbor_delete
+* NAME
+* osm_db_neighbor_delete
+*
+* DESCRIPTION
+* Delete the relationship between two ports
+*
+* SYNOPSIS
+*/
+int osm_db_neighbor_delete(IN osm_db_domain_t * p_neighbor,
+ IN uint64_t guid, IN uint8_t port);
+/*
+* PARAMETERS
+* p_neighbor
+* [in] Pointer to the neighbor domain
+*
+* guid
+* [in] The guid to look for
+*
+* port
+* [in] The port to look for
+*
+* RETURN VALUES
+* 0 if successful otherwise 1
+*
+* SEE ALSO
+* osm_db_neighbor_init, osm_db_neighbor_guids
+* osm_db_neighbor_get, osm_db_neighbor_set
+*********/
+
+END_C_DECLS
+#endif /* _OSM_DB_PACK_H_ */
diff --git a/contrib/ofed/management/opensm/include/opensm/osm_errors.h b/contrib/ofed/opensm/include/opensm/osm_errors.h
index aff4300..aff4300 100644
--- a/contrib/ofed/management/opensm/include/opensm/osm_errors.h
+++ b/contrib/ofed/opensm/include/opensm/osm_errors.h
diff --git a/contrib/ofed/opensm/include/opensm/osm_event_plugin.h b/contrib/ofed/opensm/include/opensm/osm_event_plugin.h
new file mode 100644
index 0000000..db5ebca
--- /dev/null
+++ b/contrib/ofed/opensm/include/opensm/osm_event_plugin.h
@@ -0,0 +1,207 @@
+/*
+ * Copyright (c) 2013 Mellanox Technologies LTD. All rights reserved.
+ * Copyright (c) 2008 Voltaire, Inc. All rights reserved.
+ * Copyright (c) 2007 The Regents of the University of California.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+#ifndef _OSM_EVENT_PLUGIN_H_
+#define _OSM_EVENT_PLUGIN_H_
+
+#include <time.h>
+#include <iba/ib_types.h>
+#include <complib/cl_qlist.h>
+#include <opensm/osm_config.h>
+#include <opensm/osm_switch.h>
+
+#ifdef __cplusplus
+# define BEGIN_C_DECLS extern "C" {
+# define END_C_DECLS }
+#else /* !__cplusplus */
+# define BEGIN_C_DECLS
+# define END_C_DECLS
+#endif /* __cplusplus */
+
+BEGIN_C_DECLS
+/****h* OpenSM Event plugin interface
+* DESCRIPTION
+* Database interface to record subnet events
+*
+* Implementations of this object _MUST_ be thread safe.
+*
+* AUTHOR
+* Ira Weiny, LLNL
+*
+*********/
+
+#define OSM_EPI_NODE_NAME_LEN (65)
+
+struct osm_opensm;
+/** =========================================================================
+ * Event types
+ */
+typedef enum {
+ OSM_EVENT_ID_PORT_ERRORS = 0,
+ OSM_EVENT_ID_PORT_DATA_COUNTERS,
+ OSM_EVENT_ID_PORT_SELECT,
+ OSM_EVENT_ID_TRAP,
+ OSM_EVENT_ID_SUBNET_UP,
+ OSM_EVENT_ID_HEAVY_SWEEP_START,
+ OSM_EVENT_ID_HEAVY_SWEEP_DONE,
+ OSM_EVENT_ID_UCAST_ROUTING_DONE,
+ OSM_EVENT_ID_STATE_CHANGE,
+ OSM_EVENT_ID_SA_DB_DUMPED,
+ OSM_EVENT_ID_LFT_CHANGE,
+ OSM_EVENT_ID_MAX
+} osm_epi_event_id_t;
+
+typedef struct osm_epi_port_id {
+ uint64_t node_guid;
+ uint8_t port_num;
+ char node_name[OSM_EPI_NODE_NAME_LEN];
+} osm_epi_port_id_t;
+
+typedef enum {
+ LFT_CHANGED_LFT_TOP = (1 << 0),
+ LFT_CHANGED_BLOCK = (1 << 1)
+} osm_epi_lft_change_flags_t;
+
+typedef enum {
+ UCAST_ROUTING_NONE,
+ UCAST_ROUTING_HEAVY_SWEEP,
+ UCAST_ROUTING_REROUTE
+} osm_epi_ucast_routing_flags_t;
+
+typedef struct osm_epi_lft_change_event {
+ osm_switch_t *p_sw;
+ osm_epi_lft_change_flags_t flags;
+ uint16_t lft_top;
+ uint32_t block_num;
+} osm_epi_lft_change_event_t;
+
+/** =========================================================================
+ * Port error event
+ * OSM_EVENT_ID_PORT_COUNTER
+ * This is a difference from the last reading. NOT an absolute reading.
+ */
+typedef struct osm_epi_pe_event {
+ osm_epi_port_id_t port_id;
+ uint64_t symbol_err_cnt;
+ uint64_t link_err_recover;
+ uint64_t link_downed;
+ uint64_t rcv_err;
+ uint64_t rcv_rem_phys_err;
+ uint64_t rcv_switch_relay_err;
+ uint64_t xmit_discards;
+ uint64_t xmit_constraint_err;
+ uint64_t rcv_constraint_err;
+ uint64_t link_integrity;
+ uint64_t buffer_overrun;
+ uint64_t vl15_dropped;
+ uint64_t xmit_wait;
+ time_t time_diff_s;
+} osm_epi_pe_event_t;
+
+/** =========================================================================
+ * Port data counter event
+ * This is a difference from the last reading. NOT an absolute reading.
+ */
+typedef struct osm_epi_dc_event {
+ osm_epi_port_id_t port_id;
+ uint64_t xmit_data;
+ uint64_t rcv_data;
+ uint64_t xmit_pkts;
+ uint64_t rcv_pkts;
+ uint64_t unicast_xmit_pkts;
+ uint64_t unicast_rcv_pkts;
+ uint64_t multicast_xmit_pkts;
+ uint64_t multicast_rcv_pkts;
+ time_t time_diff_s;
+} osm_epi_dc_event_t;
+
+/** =========================================================================
+ * Port select event
+ * This is a difference from the last reading. NOT an absolute reading.
+ */
+typedef struct osm_api_ps_event {
+ osm_epi_port_id_t port_id;
+ uint64_t xmit_wait;
+ time_t time_diff_s;
+} osm_epi_ps_event_t;
+
+/** =========================================================================
+ * Plugin creators should allocate an object of this type
+ * (named OSM_EVENT_PLUGIN_IMPL_NAME)
+ * The version should be set to OSM_EVENT_PLUGIN_INTERFACE_VER
+ */
+#define OSM_EVENT_PLUGIN_IMPL_NAME "osm_event_plugin"
+#define OSM_ORIG_EVENT_PLUGIN_INTERFACE_VER 1
+#define OSM_EVENT_PLUGIN_INTERFACE_VER 2
+typedef struct osm_event_plugin {
+ const char *osm_version;
+ void *(*create) (struct osm_opensm *osm);
+ void (*delete) (void *plugin_data);
+ void (*report) (void *plugin_data, osm_epi_event_id_t event_id,
+ void *event_data);
+} osm_event_plugin_t;
+
+/** =========================================================================
+ * The plugin structure should be considered opaque
+ */
+typedef struct osm_epi_plugin {
+ cl_list_item_t list;
+ void *handle;
+ osm_event_plugin_t *impl;
+ void *plugin_data;
+ char *plugin_name;
+} osm_epi_plugin_t;
+
+/**
+ * functions
+ */
+osm_epi_plugin_t *osm_epi_construct(struct osm_opensm *osm, char *plugin_name);
+void osm_epi_destroy(osm_epi_plugin_t * plugin);
+
+/** =========================================================================
+ * Helper functions
+ */
+static inline void
+osm_epi_create_port_id(osm_epi_port_id_t * port_id, uint64_t node_guid,
+ uint8_t port_num, char *node_name)
+{
+ port_id->node_guid = node_guid;
+ port_id->port_num = port_num;
+ strncpy(port_id->node_name, node_name, OSM_EPI_NODE_NAME_LEN);
+ port_id->node_name[OSM_EPI_NODE_NAME_LEN - 1] = '\0';
+}
+
+END_C_DECLS
+#endif /* _OSM_EVENT_PLUGIN_H_ */
diff --git a/contrib/ofed/opensm/include/opensm/osm_file_ids.h b/contrib/ofed/opensm/include/opensm/osm_file_ids.h
new file mode 100644
index 0000000..e23710c
--- /dev/null
+++ b/contrib/ofed/opensm/include/opensm/osm_file_ids.h
@@ -0,0 +1,157 @@
+/*
+ * Copyright (c) 2012 Mellanox Technologies LTD. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+/*
+ * Abstract:
+ * Declaration of osm_file_ids_enum.
+ * This object is part of the OpenSM family of objects.
+ */
+
+#ifndef _OSM_FILE_ID_H_
+#define _OSM_FILE_ID_H_
+
+#ifdef __cplusplus
+# define BEGIN_C_DECLS extern "C" {
+# define END_C_DECLS }
+#else /* !__cplusplus */
+# define BEGIN_C_DECLS
+# define END_C_DECLS
+#endif /* __cplusplus */
+
+BEGIN_C_DECLS
+
+/****d* OpenSM: osm_file_ids_enum
+* NAME
+* osm_file_ids_enum
+*
+* DESCRIPTION
+* Enumerates all FILE_IDs used for logging support.
+*
+* SYNOPSIS
+*/
+typedef enum _osm_file_ids_enum {
+ OSM_FILE_MAIN_C = 0,
+ OSM_FILE_CONSOLE_C,
+ OSM_FILE_CONSOLE_IO_C,
+ OSM_FILE_DB_FILES_C,
+ OSM_FILE_DB_PACK_C,
+ OSM_FILE_DROP_MGR_C,
+ OSM_FILE_DUMP_C,
+ OSM_FILE_EVENT_PLUGIN_C,
+ OSM_FILE_GUID_INFO_RCV_C,
+ OSM_FILE_GUID_MGR_C,
+ OSM_FILE_HELPER_C,
+ OSM_FILE_INFORM_C,
+ OSM_FILE_LID_MGR_C,
+ OSM_FILE_LIN_FWD_RCV_C,
+ OSM_FILE_LINK_MGR_C,
+ OSM_FILE_LOG_C,
+ OSM_FILE_MAD_POOL_C,
+ OSM_FILE_MCAST_FWD_RCV_C,
+ OSM_FILE_MCAST_MGR_C,
+ OSM_FILE_MCAST_TBL_C,
+ OSM_FILE_MCM_PORT_C,
+ OSM_FILE_MESH_C,
+ OSM_FILE_MLNX_EXT_PORT_INFO_RCV_C,
+ OSM_FILE_MTREE_C,
+ OSM_FILE_MULTICAST_C,
+ OSM_FILE_NODE_C,
+ OSM_FILE_NODE_DESC_RCV_C,
+ OSM_FILE_NODE_INFO_RCV_C,
+ OSM_FILE_OPENSM_C,
+ OSM_FILE_PERFMGR_C,
+ OSM_FILE_PERFMGR_DB_C,
+ OSM_FILE_PKEY_C,
+ OSM_FILE_PKEY_MGR_C,
+ OSM_FILE_PKEY_RCV_C,
+ OSM_FILE_PORT_C,
+ OSM_FILE_PORT_INFO_RCV_C,
+ OSM_FILE_PRTN_C,
+ OSM_FILE_PRTN_CONFIG_C,
+ OSM_FILE_QOS_C,
+ OSM_FILE_QOS_PARSER_L_L,
+ OSM_FILE_QOS_PARSER_Y_Y,
+ OSM_FILE_QOS_POLICY_C,
+ OSM_FILE_REMOTE_SM_C,
+ OSM_FILE_REQ_C,
+ OSM_FILE_RESP_C,
+ OSM_FILE_ROUTER_C,
+ OSM_FILE_SA_C,
+ OSM_FILE_SA_CLASS_PORT_INFO_C,
+ OSM_FILE_SA_GUIDINFO_RECORD_C,
+ OSM_FILE_SA_INFORMINFO_C,
+ OSM_FILE_SA_LFT_RECORD_C,
+ OSM_FILE_SA_LINK_RECORD_C,
+ OSM_FILE_SA_MAD_CTRL_C,
+ OSM_FILE_SA_MCMEMBER_RECORD_C,
+ OSM_FILE_SA_MFT_RECORD_C,
+ OSM_FILE_SA_MULTIPATH_RECORD_C,
+ OSM_FILE_SA_NODE_RECORD_C,
+ OSM_FILE_SA_PATH_RECORD_C,
+ OSM_FILE_SA_PKEY_RECORD_C,
+ OSM_FILE_SA_PORTINFO_RECORD_C,
+ OSM_FILE_SA_SERVICE_RECORD_C,
+ OSM_FILE_SA_SLVL_RECORD_C,
+ OSM_FILE_SA_SMINFO_RECORD_C,
+ OSM_FILE_SA_SW_INFO_RECORD_C,
+ OSM_FILE_SA_VLARB_RECORD_C,
+ OSM_FILE_SERVICE_C,
+ OSM_FILE_SLVL_MAP_RCV_C,
+ OSM_FILE_SM_C,
+ OSM_FILE_SMINFO_RCV_C,
+ OSM_FILE_SM_MAD_CTRL_C,
+ OSM_FILE_SM_STATE_MGR_C,
+ OSM_FILE_STATE_MGR_C,
+ OSM_FILE_SUBNET_C,
+ OSM_FILE_SW_INFO_RCV_C,
+ OSM_FILE_SWITCH_C,
+ OSM_FILE_TORUS_C,
+ OSM_FILE_TRAP_RCV_C,
+ OSM_FILE_UCAST_CACHE_C,
+ OSM_FILE_UCAST_DNUP_C,
+ OSM_FILE_UCAST_FILE_C,
+ OSM_FILE_UCAST_FTREE_C,
+ OSM_FILE_UCAST_LASH_C,
+ OSM_FILE_UCAST_MGR_C,
+ OSM_FILE_UCAST_UPDN_C,
+ OSM_FILE_VENDOR_IBUMAD_C,
+ OSM_FILE_VL15INTF_C,
+ OSM_FILE_VL_ARB_RCV_C,
+ OSM_FILE_ST_C,
+ OSM_FILE_UCAST_DFSSSP_C,
+ OSM_FILE_CONGESTION_CONTROL_C,
+} osm_file_ids_enum;
+/***********/
+
+END_C_DECLS
+#endif /* _OSM_FILE_ID_H_ */
diff --git a/contrib/ofed/opensm/include/opensm/osm_guid.h b/contrib/ofed/opensm/include/opensm/osm_guid.h
new file mode 100644
index 0000000..2fa5f7f
--- /dev/null
+++ b/contrib/ofed/opensm/include/opensm/osm_guid.h
@@ -0,0 +1,66 @@
+/*
+ * Copyright (c) 2011 Mellanox Technologies LTD. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+#ifndef _OSM_GUID_H_
+#define _OSM_GUID_H_
+
+#include <iba/ib_types.h>
+#include <complib/cl_list.h>
+#include <opensm/osm_sa.h>
+
+#ifdef __cplusplus
+# define BEGIN_C_DECLS extern "C" {
+# define END_C_DECLS }
+#else /* !__cplusplus */
+# define BEGIN_C_DECLS
+# define END_C_DECLS
+#endif /* __cplusplus */
+
+BEGIN_C_DECLS
+
+typedef struct osm_guidinfo_work_obj {
+ cl_list_item_t list_item;
+ osm_port_t *p_port;
+ uint8_t block_num;
+} osm_guidinfo_work_obj_t;
+
+osm_guidinfo_work_obj_t *osm_guid_work_obj_new(IN osm_port_t * p_port,
+ IN uint8_t block_num);
+
+void osm_guid_work_obj_delete(IN osm_guidinfo_work_obj_t * p_wobj);
+
+int osm_queue_guidinfo(IN osm_sa_t *sa, IN osm_port_t *p_port,
+ IN uint8_t block_num);
+
+END_C_DECLS
+#endif /* _OSM_GUID_H_ */
diff --git a/contrib/ofed/opensm/include/opensm/osm_helper.h b/contrib/ofed/opensm/include/opensm/osm_helper.h
new file mode 100644
index 0000000..8bfc15d
--- /dev/null
+++ b/contrib/ofed/opensm/include/opensm/osm_helper.h
@@ -0,0 +1,877 @@
+/*
+ * Copyright (c) 2004-2009 Voltaire, Inc. All rights reserved.
+ * Copyright (c) 2002-2011 Mellanox Technologies LTD. All rights reserved.
+ * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
+ * Copyright (c) 2009 HNR Consulting. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+#ifndef _OSM_HELPER_H_
+#define _OSM_HELPER_H_
+
+#include <iba/ib_types.h>
+#include <complib/cl_dispatcher.h>
+#include <opensm/osm_base.h>
+#include <opensm/osm_log.h>
+#include <opensm/osm_msgdef.h>
+#include <opensm/osm_path.h>
+
+#ifdef __cplusplus
+# define BEGIN_C_DECLS extern "C" {
+# define END_C_DECLS }
+#else /* !__cplusplus */
+# define BEGIN_C_DECLS
+# define END_C_DECLS
+#endif /* __cplusplus */
+
+BEGIN_C_DECLS
+/*
+ * Abstract:
+ * Declaration of helpful functions.
+ */
+/****f* OpenSM: Helper/ib_get_sa_method_str
+ * NAME
+ * ib_get_sa_method_str
+ *
+ * DESCRIPTION
+ * Returns a string for the specified SA Method value.
+ *
+ * SYNOPSIS
+ */
+const char *ib_get_sa_method_str(IN uint8_t method);
+/*
+ * PARAMETERS
+ * method
+ * [in] Network order METHOD ID value.
+ *
+ * RETURN VALUES
+ * Pointer to the method string.
+ *
+ * NOTES
+ *
+ * SEE ALSO
+ *********/
+
+/****f* OpenSM: Helper/ib_get_sm_method_str
+* NAME
+* ib_get_sm_method_str
+*
+* DESCRIPTION
+* Returns a string for the specified SM Method value.
+*
+* SYNOPSIS
+*/
+const char *ib_get_sm_method_str(IN uint8_t method);
+/*
+* PARAMETERS
+* method
+* [in] Network order METHOD ID value.
+*
+* RETURN VALUES
+* Pointer to the method string.
+*
+* NOTES
+*
+* SEE ALSO
+*********/
+
+/****f* OpenSM: Helper/ib_get_sm_attr_str
+* NAME
+* ib_get_sm_attr_str
+*
+* DESCRIPTION
+* Returns a string for the specified SM attribute value.
+*
+* SYNOPSIS
+*/
+const char *ib_get_sm_attr_str(IN ib_net16_t attr);
+/*
+* PARAMETERS
+* attr
+* [in] Network order attribute ID value.
+*
+* RETURN VALUES
+* Pointer to the attribute string.
+*
+* NOTES
+*
+* SEE ALSO
+*********/
+
+/****f* OpenSM: Helper/ib_get_sa_attr_str
+* NAME
+* ib_get_sa_attr_str
+*
+* DESCRIPTION
+* Returns a string for the specified SA attribute value.
+*
+* SYNOPSIS
+*/
+const char *ib_get_sa_attr_str(IN ib_net16_t attr);
+/*
+* PARAMETERS
+* attr
+* [in] Network order attribute ID value.
+*
+* RETURN VALUES
+* Pointer to the attribute string.
+*
+* NOTES
+*
+* SEE ALSO
+*********/
+
+/****f* OpenSM: Helper/ib_get_trap_str
+* NAME
+* ib_get_trap_str
+*
+* DESCRIPTION
+* Returns a name for the specified trap.
+*
+* SYNOPSIS
+*/
+const char *ib_get_trap_str(uint16_t trap_num);
+/*
+* PARAMETERS
+* trap_num
+* [in] Network order trap number.
+*
+* RETURN VALUES
+* Name of the trap.
+*
+*********/
+
+extern const ib_gid_t ib_zero_gid;
+
+/****f* IBA Base: Types/ib_gid_is_notzero
+* NAME
+* ib_gid_is_notzero
+*
+* DESCRIPTION
+* Returns a boolean indicating whether or not the GID is zero.
+*
+* SYNOPSIS
+*/
+static inline boolean_t ib_gid_is_notzero(IN const ib_gid_t * p_gid)
+{
+ return memcmp(p_gid, &ib_zero_gid, sizeof(*p_gid));
+}
+
+/*
+* PARAMETERS
+* p_gid
+* [in] Pointer to the GID object.
+*
+* RETURN VALUES
+* Returns TRUE if GID is not zero.
+* FALSE otherwise.
+*
+* NOTES
+*
+* SEE ALSO
+* ib_gid_t
+*********/
+
+/****f* OpenSM: Helper/osm_dump_port_info
+* NAME
+* osm_dump_port_info
+*
+* DESCRIPTION
+* Dumps the PortInfo attribute to the log.
+*
+* SYNOPSIS
+*/
+void osm_dump_port_info(IN osm_log_t * p_log, IN ib_net64_t node_guid,
+ IN ib_net64_t port_guid, IN uint8_t port_num,
+ IN const ib_port_info_t * p_pi,
+ IN osm_log_level_t log_level);
+
+void osm_dump_port_info_v2(IN osm_log_t * p_log, IN ib_net64_t node_guid,
+ IN ib_net64_t port_guid, IN uint8_t port_num,
+ IN const ib_port_info_t * p_pi,
+ IN const int file_id,
+ IN osm_log_level_t log_level);
+
+/*
+* PARAMETERS
+* p_log
+* [in] Pointer to the osm_log_t object
+*
+* node_guid
+* [in] Node GUID that owns this port.
+*
+* port_guid
+* [in] Port GUID for this port.
+*
+* port_num
+* [in] Port number for this port.
+*
+* p_pi
+* [in] Pointer to the PortInfo attribute
+*
+* log_level
+* [in] Log verbosity level with which to dump the data.
+*
+* RETURN VALUES
+* None.
+*
+* NOTES
+*
+* SEE ALSO
+*********/
+
+/****f* OpenSM: Helper/osm_dump_guid_info
+* NAME
+* osm_dump_guid_info
+*
+* DESCRIPTION
+* Dumps the GUIDInfo attribute to the log.
+*
+* SYNOPSIS
+*/
+void osm_dump_guid_info(IN osm_log_t * p_log, IN ib_net64_t node_guid,
+ IN ib_net64_t port_guid, IN uint8_t block_num,
+ IN const ib_guid_info_t * p_gi,
+ IN osm_log_level_t log_level);
+
+void osm_dump_guid_info_v2(IN osm_log_t * p_log, IN ib_net64_t node_guid,
+ IN ib_net64_t port_guid, IN uint8_t block_num,
+ IN const ib_guid_info_t * p_gi,
+ IN const int file_id,
+ IN osm_log_level_t log_level);
+/*
+* PARAMETERS
+* p_log
+* [in] Pointer to the osm_log_t object.
+*
+* node_guid
+* [in] Node GUID that owns this port.
+*
+* port_guid
+* [in] Port GUID for this port.
+*
+* block_num
+* [in] Block number.
+*
+* p_gi
+* [in] Pointer to the GUIDInfo attribute.
+*
+* log_level
+* [in] Log verbosity level with which to dump the data.
+*
+* RETURN VALUES
+* None.
+*
+* NOTES
+*
+* SEE ALSO
+*********/
+
+void osm_dump_mlnx_ext_port_info(IN osm_log_t * p_log, IN ib_net64_t node_guid,
+ IN ib_net64_t port_guid, IN uint8_t port_num,
+ IN const ib_mlnx_ext_port_info_t * p_pi,
+ IN osm_log_level_t log_level);
+
+void osm_dump_mlnx_ext_port_info_v2(IN osm_log_t * p_log, IN ib_net64_t node_guid,
+ IN ib_net64_t port_guid, IN uint8_t port_num,
+ IN const ib_mlnx_ext_port_info_t * p_pi,
+ IN const int file_id,
+ IN osm_log_level_t log_level);
+
+void osm_dump_path_record(IN osm_log_t * p_log, IN const ib_path_rec_t * p_pr,
+ IN osm_log_level_t log_level);
+
+void osm_dump_path_record_v2(IN osm_log_t * p_log, IN const ib_path_rec_t * p_pr,
+ IN const int file_id, IN osm_log_level_t log_level);
+
+void osm_dump_multipath_record(IN osm_log_t * p_log,
+ IN const ib_multipath_rec_t * p_mpr,
+ IN osm_log_level_t log_level);
+
+void osm_dump_multipath_record_v2(IN osm_log_t * p_log,
+ IN const ib_multipath_rec_t * p_mpr,
+ IN const int file_id, IN osm_log_level_t log_level);
+
+void osm_dump_node_record(IN osm_log_t * p_log,
+ IN const ib_node_record_t * p_nr,
+ IN osm_log_level_t log_level);
+
+void osm_dump_node_record_v2(IN osm_log_t * p_log,
+ IN const ib_node_record_t * p_nr,
+ IN const int file_id, IN osm_log_level_t log_level);
+
+void osm_dump_mc_record(IN osm_log_t * p_log, IN const ib_member_rec_t * p_mcmr,
+ IN osm_log_level_t log_level);
+
+void osm_dump_mc_record_v2(IN osm_log_t * p_log, IN const ib_member_rec_t * p_mcmr,
+ IN const int file_id, IN osm_log_level_t log_level);
+
+void osm_dump_link_record(IN osm_log_t * p_log,
+ IN const ib_link_record_t * p_lr,
+ IN osm_log_level_t log_level);
+
+void osm_dump_link_record_v2(IN osm_log_t * p_log,
+ IN const ib_link_record_t * p_lr,
+ IN const int file_id, IN osm_log_level_t log_level);
+
+void osm_dump_service_record(IN osm_log_t * p_log,
+ IN const ib_service_record_t * p_sr,
+ IN osm_log_level_t log_level);
+
+void osm_dump_service_record_v2(IN osm_log_t * p_log,
+ IN const ib_service_record_t * p_sr,
+ IN const int file_id, IN osm_log_level_t log_level);
+
+void osm_dump_portinfo_record(IN osm_log_t * p_log,
+ IN const ib_portinfo_record_t * p_pir,
+ IN osm_log_level_t log_level);
+
+void osm_dump_portinfo_record_v2(IN osm_log_t * p_log,
+ IN const ib_portinfo_record_t * p_pir,
+ IN const int file_id, IN osm_log_level_t log_level);
+
+void osm_dump_guidinfo_record(IN osm_log_t * p_log,
+ IN const ib_guidinfo_record_t * p_gir,
+ IN osm_log_level_t log_level);
+
+void osm_dump_guidinfo_record_v2(IN osm_log_t * p_log,
+ IN const ib_guidinfo_record_t * p_gir,
+ IN const int file_id, IN osm_log_level_t log_level);
+
+void osm_dump_inform_info(IN osm_log_t * p_log,
+ IN const ib_inform_info_t * p_ii,
+ IN osm_log_level_t log_level);
+
+void osm_dump_inform_info_v2(IN osm_log_t * p_log,
+ IN const ib_inform_info_t * p_ii,
+ IN const int file_id, IN osm_log_level_t log_level);
+
+void osm_dump_inform_info_record(IN osm_log_t * p_log,
+ IN const ib_inform_info_record_t * p_iir,
+ IN osm_log_level_t log_level);
+
+void osm_dump_inform_info_record_v2(IN osm_log_t * p_log,
+ IN const ib_inform_info_record_t * p_iir,
+ IN const int file_id, IN osm_log_level_t log_level);
+
+void osm_dump_switch_info_record(IN osm_log_t * p_log,
+ IN const ib_switch_info_record_t * p_sir,
+ IN osm_log_level_t log_level);
+
+void osm_dump_switch_info_record_v2(IN osm_log_t * p_log,
+ IN const ib_switch_info_record_t * p_sir,
+ IN const int file_id, IN osm_log_level_t log_level);
+
+void osm_dump_sm_info_record(IN osm_log_t * p_log,
+ IN const ib_sminfo_record_t * p_smir,
+ IN osm_log_level_t log_level);
+
+void osm_dump_sm_info_record_v2(IN osm_log_t * p_log,
+ IN const ib_sminfo_record_t * p_smir,
+ IN const int file_id, IN osm_log_level_t log_level);
+
+void osm_dump_pkey_block(IN osm_log_t * p_log, IN uint64_t port_guid,
+ IN uint16_t block_num, IN uint8_t port_num,
+ IN const ib_pkey_table_t * p_pkey_tbl,
+ IN osm_log_level_t log_level);
+
+void osm_dump_pkey_block_v2(IN osm_log_t * p_log, IN uint64_t port_guid,
+ IN uint16_t block_num, IN uint8_t port_num,
+ IN const ib_pkey_table_t * p_pkey_tbl,
+ IN const int file_id,
+ IN osm_log_level_t log_level);
+
+void osm_dump_slvl_map_table(IN osm_log_t * p_log, IN uint64_t port_guid,
+ IN uint8_t in_port_num, IN uint8_t out_port_num,
+ IN const ib_slvl_table_t * p_slvl_tbl,
+ IN osm_log_level_t log_level);
+
+void osm_dump_slvl_map_table_v2(IN osm_log_t * p_log, IN uint64_t port_guid,
+ IN uint8_t in_port_num, IN uint8_t out_port_num,
+ IN const ib_slvl_table_t * p_slvl_tbl,
+ IN const int file_id,
+ IN osm_log_level_t log_level);
+
+
+void osm_dump_vl_arb_table(IN osm_log_t * p_log, IN uint64_t port_guid,
+ IN uint8_t block_num, IN uint8_t port_num,
+ IN const ib_vl_arb_table_t * p_vla_tbl,
+ IN osm_log_level_t log_level);
+
+void osm_dump_vl_arb_table_v2(IN osm_log_t * p_log, IN uint64_t port_guid,
+ IN uint8_t block_num, IN uint8_t port_num,
+ IN const ib_vl_arb_table_t * p_vla_tbl,
+ IN const int file_id,
+ IN osm_log_level_t log_level);
+
+/****f* OpenSM: Helper/osm_dump_port_info
+* NAME
+* osm_dump_port_info
+*
+* DESCRIPTION
+* Dumps the PortInfo attribute to the log.
+*
+* SYNOPSIS
+*/
+void osm_dump_node_info(IN osm_log_t * p_log,
+ IN const ib_node_info_t * p_ni,
+ IN osm_log_level_t log_level);
+
+void osm_dump_node_info_v2(IN osm_log_t * p_log,
+ IN const ib_node_info_t * p_ni,
+ IN const int file_id,
+ IN osm_log_level_t log_level);
+/*
+* PARAMETERS
+* p_log
+* [in] Pointer to the osm_log_t object
+*
+* p_ni
+* [in] Pointer to the NodeInfo attribute
+*
+* log_level
+* [in] Log verbosity level with which to dump the data.
+*
+* RETURN VALUES
+* None.
+*
+* NOTES
+*
+* SEE ALSO
+*********/
+
+/****f* OpenSM: Helper/osm_dump_sm_info
+* NAME
+* osm_dump_sm_info
+*
+* DESCRIPTION
+* Dumps the SMInfo attribute to the log.
+*
+* SYNOPSIS
+*/
+void osm_dump_sm_info(IN osm_log_t * p_log, IN const ib_sm_info_t * p_smi,
+ IN osm_log_level_t log_level);
+
+void osm_dump_sm_info_v2(IN osm_log_t * p_log, IN const ib_sm_info_t * p_smi,
+ IN const int file_id, IN osm_log_level_t log_level);
+
+/*
+* PARAMETERS
+* p_log
+* [in] Pointer to the osm_log_t object
+*
+* p_smi
+* [in] Pointer to the SMInfo attribute
+*
+* log_level
+* [in] Log verbosity level with which to dump the data.
+*
+* RETURN VALUES
+* None.
+*
+* NOTES
+*
+* SEE ALSO
+*********/
+
+/****f* OpenSM: Helper/osm_dump_switch_info
+* NAME
+* osm_dump_switch_info
+*
+* DESCRIPTION
+* Dumps the SwitchInfo attribute to the log.
+*
+* SYNOPSIS
+*/
+void osm_dump_switch_info(IN osm_log_t * p_log,
+ IN const ib_switch_info_t * p_si,
+ IN osm_log_level_t log_level);
+
+void osm_dump_switch_info_v2(IN osm_log_t * p_log,
+ IN const ib_switch_info_t * p_si,
+ IN const int file_id,
+ IN osm_log_level_t log_level);
+/*
+* PARAMETERS
+* p_log
+* [in] Pointer to the osm_log_t object
+*
+* p_si
+* [in] Pointer to the SwitchInfo attribute
+*
+* log_level
+* [in] Log verbosity level with which to dump the data.
+*
+* RETURN VALUES
+* None.
+*
+* NOTES
+*
+* SEE ALSO
+*********/
+
+/****f* OpenSM: Helper/osm_dump_notice
+* NAME
+* osm_dump_notice
+*
+* DESCRIPTION
+* Dumps the Notice attribute to the log.
+*
+* SYNOPSIS
+*/
+void osm_dump_notice(IN osm_log_t * p_log,
+ IN const ib_mad_notice_attr_t * p_ntci,
+ IN osm_log_level_t log_level);
+
+void osm_dump_notice_v2(IN osm_log_t * p_log,
+ IN const ib_mad_notice_attr_t * p_ntci,
+ IN const int file_id,
+ IN osm_log_level_t log_level);
+/*
+* PARAMETERS
+* p_log
+* [in] Pointer to the osm_log_t object
+*
+* p_ntci
+* [in] Pointer to the Notice attribute
+*
+* log_level
+* [in] Log verbosity level with which to dump the data.
+*
+* RETURN VALUES
+* None.
+*
+* NOTES
+*
+* SEE ALSO
+*********/
+
+/****f* IBA Base: Types/osm_get_disp_msg_str
+* NAME
+* osm_get_disp_msg_str
+*
+* DESCRIPTION
+* Returns a string for the specified Dispatcher message.
+*
+* SYNOPSIS
+*/
+const char *osm_get_disp_msg_str(IN cl_disp_msgid_t msg);
+/*
+* PARAMETERS
+* msg
+* [in] Dispatcher message ID value.
+*
+* RETURN VALUES
+* Pointer to the message description string.
+*
+* NOTES
+*
+* SEE ALSO
+*********/
+
+void osm_dump_dr_path(IN osm_log_t * p_log, IN const osm_dr_path_t * p_path,
+ IN osm_log_level_t level);
+
+void osm_dump_dr_path_v2(IN osm_log_t * p_log, IN const osm_dr_path_t * p_path,
+ IN const int file_id, IN osm_log_level_t level);
+
+
+void osm_dump_smp_dr_path(IN osm_log_t * p_log, IN const ib_smp_t * p_smp,
+ IN osm_log_level_t level);
+
+void osm_dump_smp_dr_path_v2(IN osm_log_t * p_log, IN const ib_smp_t * p_smp,
+ IN const int file_id, IN osm_log_level_t level);
+
+void osm_dump_dr_smp(IN osm_log_t * p_log, IN const ib_smp_t * p_smp,
+ IN osm_log_level_t level);
+
+void osm_dump_dr_smp_v2(IN osm_log_t * p_log, IN const ib_smp_t * p_smp,
+ IN const int file_id, IN osm_log_level_t level);
+
+void osm_dump_sa_mad(IN osm_log_t * p_log, IN const ib_sa_mad_t * p_smp,
+ IN osm_log_level_t level);
+
+void osm_dump_sa_mad_v2(IN osm_log_t * p_log, IN const ib_sa_mad_t * p_smp,
+ IN const int file_id, IN osm_log_level_t level);
+
+void osm_dump_dr_path_as_buf(IN size_t max_len, IN const osm_dr_path_t * p_path,
+ OUT char* buf);
+
+
+/****f* IBA Base: Types/osm_get_sm_signal_str
+* NAME
+* osm_get_sm_signal_str
+*
+* DESCRIPTION
+* Returns a string for the specified SM state.
+*
+* SYNOPSIS
+*/
+const char *osm_get_sm_signal_str(IN osm_signal_t signal);
+/*
+* PARAMETERS
+* state
+* [in] Signal value
+*
+* RETURN VALUES
+* Pointer to the signal description string.
+*
+* NOTES
+*
+* SEE ALSO
+*********/
+
+const char *osm_get_port_state_str_fixed_width(IN uint8_t port_state);
+
+const char *osm_get_node_type_str_fixed_width(IN uint8_t node_type);
+
+const char *osm_get_manufacturer_str(IN uint64_t guid_ho);
+
+const char *osm_get_mtu_str(IN uint8_t mtu);
+
+const char *osm_get_lwa_str(IN uint8_t lwa);
+
+const char *osm_get_lsa_str(IN uint8_t lsa, IN uint8_t lsea, IN uint8_t state,
+ IN uint8_t fdr10);
+
+/****f* IBA Base: Types/osm_get_sm_mgr_signal_str
+* NAME
+* osm_get_sm_mgr_signal_str
+*
+* DESCRIPTION
+* Returns a string for the specified SM manager signal.
+*
+* SYNOPSIS
+*/
+const char *osm_get_sm_mgr_signal_str(IN osm_sm_signal_t signal);
+/*
+* PARAMETERS
+* signal
+* [in] SM manager signal
+*
+* RETURN VALUES
+* Pointer to the signal description string.
+*
+* NOTES
+*
+* SEE ALSO
+*********/
+
+/****f* IBA Base: Types/osm_get_sm_mgr_state_str
+* NAME
+* osm_get_sm_mgr_state_str
+*
+* DESCRIPTION
+* Returns a string for the specified SM manager state.
+*
+* SYNOPSIS
+*/
+const char *osm_get_sm_mgr_state_str(IN uint16_t state);
+/*
+* PARAMETERS
+* state
+* [in] SM manager state
+*
+* RETURN VALUES
+* Pointer to the state description string.
+*
+* NOTES
+*
+* SEE ALSO
+*********/
+
+/****f* IBA Base: Types/ib_mtu_is_valid
+* NAME
+* ib_mtu_is_valid
+*
+* DESCRIPTION
+* Validates encoded MTU
+*
+* SYNOPSIS
+*/
+int ib_mtu_is_valid(IN const int mtu);
+/*
+* PARAMETERS
+* mtu
+* [in] Encoded path mtu.
+*
+* RETURN VALUES
+* Returns an int indicating mtu is valid (1)
+* or invalid (0).
+*
+* NOTES
+*
+* SEE ALSO
+*********/
+
+/****f* IBA Base: Types/ib_rate_is_valid
+* NAME
+* ib_rate_is_valid
+*
+* DESCRIPTION
+* Validates encoded rate
+*
+* SYNOPSIS
+*/
+int ib_rate_is_valid(IN const int rate);
+/*
+* PARAMETERS
+* rate
+* [in] Encoded path rate.
+*
+* RETURN VALUES
+* Returns an int indicating rate is valid (1)
+* or invalid (0).
+*
+* NOTES
+*
+* SEE ALSO
+*********/
+
+/****f* IBA Base: Types/ib_path_compare_rates
+* NAME
+* ib_path_compare_rates
+*
+* DESCRIPTION
+* Compares the encoded values for two path rates and
+* return value is based on the ordered comparison of
+* the path rates (or path rate equivalents).
+*
+* SYNOPSIS
+*/
+int ib_path_compare_rates(IN const int rate1, IN const int rate2);
+
+/*
+* PARAMETERS
+* rate1
+* [in] Encoded path rate 1.
+*
+* rate2
+* [in] Encoded path rate 2.
+*
+* RETURN VALUES
+* Returns an int indicating less than (-1), equal to (0), or
+* greater than (1) rate1 as compared with rate2.
+*
+* NOTES
+*
+* SEE ALSO
+*********/
+
+/****f* IBA Base: Types/ib_path_rate_get_prev
+* NAME
+* ib_path_rate_get_prev
+*
+* DESCRIPTION
+* Obtains encoded rate for the rate previous to the one requested.
+*
+* SYNOPSIS
+*/
+int ib_path_rate_get_prev(IN const int rate);
+
+/*
+* PARAMETERS
+* rate
+* [in] Encoded path rate.
+*
+* RETURN VALUES
+* Returns an int indicating encoded rate or
+* 0 if none can be found.
+*
+* NOTES
+*
+* SEE ALSO
+*********/
+
+/****f* IBA Base: Types/ib_path_rate_get_next
+* NAME
+* ib_path_rate_get_next
+*
+* DESCRIPTION
+* Obtains encoded rate for the rate subsequent to the one requested.
+*
+* SYNOPSIS
+*/
+int ib_path_rate_get_next(IN const int rate);
+
+/*
+* PARAMETERS
+* rate
+* [in] Encoded path rate.
+*
+* RETURN VALUES
+* Returns an int indicating encoded rate or
+* 0 if none can be found.
+*
+* NOTES
+*
+* SEE ALSO
+*********/
+
+/****f* OpenSM: Helper/sprint_uint8_arr
+* NAME
+* sprint_uint8_arr
+*
+* DESCRIPTION
+* Create the comma-separated string of numbers
+* from input array of uint8 numbers
+* (e.g. "1,2,3,4")
+*
+* SYNOPSIS
+*/
+int sprint_uint8_arr(IN char *buf, IN size_t size,
+ IN const uint8_t * arr, IN size_t len);
+
+/*
+* PARAMETERS
+* buf
+* [in] Pointer to the output buffer
+*
+* size
+* [in] Size of the output buffer
+*
+* arr
+* [in] Pointer to the input array of uint8
+*
+* len
+* [in] Size of the input array
+*
+* RETURN VALUES
+* Return the number of characters printed to the buffer
+*
+* NOTES
+*
+* SEE ALSO
+*********/
+
+
+END_C_DECLS
+#endif /* _OSM_HELPER_H_ */
diff --git a/contrib/ofed/opensm/include/opensm/osm_inform.h b/contrib/ofed/opensm/include/opensm/osm_inform.h
new file mode 100644
index 0000000..8cefc20
--- /dev/null
+++ b/contrib/ofed/opensm/include/opensm/osm_inform.h
@@ -0,0 +1,265 @@
+/*
+ * Copyright (c) 2004-2009 Voltaire, Inc. All rights reserved.
+ * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved.
+ * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
+ * Copyright (c) 2013 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+/*
+ * Abstract:
+ * Declaration of osm_inform_rec_t.
+ * This object represents an IBA Inform Record.
+ * This object is part of the OpenSM family of objects.
+ *
+ * Author:
+ * Eitan Zahavi, Mellanox
+ */
+
+#ifndef _OSM_INFR_H_
+#define _OSM_INFR_H_
+
+#include <iba/ib_types.h>
+#include <complib/cl_qmap.h>
+#include <complib/cl_spinlock.h>
+#include <opensm/osm_subnet.h>
+#include <opensm/osm_madw.h>
+#include <opensm/osm_log.h>
+#include <opensm/osm_sa.h>
+
+#ifdef __cplusplus
+# define BEGIN_C_DECLS extern "C" {
+# define END_C_DECLS }
+#else /* !__cplusplus */
+# define BEGIN_C_DECLS
+# define END_C_DECLS
+#endif /* __cplusplus */
+
+BEGIN_C_DECLS
+/****h* OpenSM/Inform Record
+* NAME
+* Inform Record
+*
+* DESCRIPTION
+* The Inform record encapsulates the information needed by the
+* SA to manage InformInfo registrations and sending Reports(Notice)
+* when SM receives Traps for registered LIDs.
+*
+* The inform records is not thread safe, thus callers must provide
+* serialization.
+*
+* This object should be treated as opaque and should be
+* manipulated only through the provided functions.
+*
+* AUTHOR
+* Eitan Zahavi, Mellanox
+*
+*********/
+/****s* OpenSM: Inform Record/osm_infr_t
+* NAME
+* osm_infr_t
+*
+* DESCRIPTION
+* Inform Record structure.
+*
+* The osm_infr_t object should be treated as opaque and should
+* be manipulated only through the provided functions.
+*
+* SYNOPSIS
+*/
+typedef struct osm_infr {
+ cl_list_item_t list_item;
+ osm_bind_handle_t h_bind;
+ osm_sa_t *sa;
+ osm_mad_addr_t report_addr;
+ ib_inform_info_record_t inform_record;
+} osm_infr_t;
+/*
+* FIELDS
+* list_item
+* List Item for qlist linkage. Must be first element!!
+*
+* h_bind
+* A handle of lower level mad srvc
+*
+* sa
+* A pointer to osm_sa object
+*
+* report_addr
+* Report address
+*
+* inform_record
+* The Inform Info Record
+*
+* SEE ALSO
+*********/
+
+/****f* OpenSM: Inform Record/osm_infr_new
+* NAME
+* osm_infr_new
+*
+* DESCRIPTION
+* Allocates and initializes a Inform Record for use.
+*
+* SYNOPSIS
+*/
+osm_infr_t *osm_infr_new(IN const osm_infr_t * p_infr_rec);
+/*
+* PARAMETERS
+* p_inf_rec
+* [in] Pointer to IB Inform Record
+*
+* RETURN VALUES
+* pointer to osm_infr_t structure.
+*
+* NOTES
+* Allows calling other inform record methods.
+*
+* SEE ALSO
+* Inform Record, osm_infr_delete
+*********/
+
+/****f* OpenSM: Inform Record/osm_infr_delete
+* NAME
+* osm_infr_delete
+*
+* DESCRIPTION
+* Destroys and deallocates the osm_infr_t structure.
+*
+* SYNOPSIS
+*/
+void osm_infr_delete(IN osm_infr_t * p_infr);
+/*
+* PARAMETERS
+* p_infr
+* [in] Pointer to osm_infr_t structure
+*
+* SEE ALSO
+* Inform Record, osm_infr_new
+*********/
+
+/****f* OpenSM: Inform Record/osm_infr_get_by_rec
+* NAME
+* osm_infr_get_by_rec
+*
+* DESCRIPTION
+* Find a matching osm_infr_t in the subnet DB by inform_info_record
+*
+* SYNOPSIS
+*/
+osm_infr_t *osm_infr_get_by_rec(IN osm_subn_t const *p_subn,
+ IN osm_log_t * p_log,
+ IN osm_infr_t * p_infr_rec);
+/*
+* PARAMETERS
+* p_subn
+* [in] Pointer to the subnet object
+*
+* p_log
+* [in] Pointer to the log object
+*
+* p_inf_rec
+* [in] Pointer to an inform_info record
+*
+* RETURN
+* The matching osm_infr_t
+* SEE ALSO
+* Inform Record, osm_infr_new, osm_infr_delete
+*********/
+
+void osm_infr_insert_to_db(IN osm_subn_t * p_subn, IN osm_log_t * p_log,
+ IN osm_infr_t * p_infr);
+
+void osm_infr_remove_from_db(IN osm_subn_t * p_subn, IN osm_log_t * p_log,
+ IN osm_infr_t * p_infr);
+
+/****f* OpenSM: Inform Record/osm_infr_remove_subscriptions
+* NAME
+* osm_infr_remove_subscriptions
+*
+* DESCRIPTION
+* Remove all event subscriptions of a port
+*
+* SYNOPSIS
+*/
+ib_api_status_t
+osm_infr_remove_subscriptions(IN osm_subn_t * p_subn, IN osm_log_t * p_log,
+ IN ib_net64_t port_guid);
+/*
+* PARAMETERS
+* p_subn
+* [in] Pointer to the subnet object
+*
+* p_log
+* [in] Pointer to the log object
+*
+* port_guid
+* [in] PortGUID of the subscriber that should be removed
+*
+* RETURN
+* CL_SUCCESS if port_guid had any subscriptions being removed
+* CL_NOT_FOUND if port_guid did not have any active subscriptions
+* SEE ALSO
+*********/
+
+/****f* OpenSM: Inform Record/osm_report_notice
+* NAME
+* osm_report_notice
+*
+* DESCRIPTION
+* Once a Trap was received by the osm_trap_rcv, or a Trap sourced in
+* the SM was sent (Traps 64-67) this routine is called with a copy of
+* the notice data.
+* Given a notice attribute - compare and see if it matches the InformInfo
+* Element and if it does - call the Report(Notice) for the
+* target QP registered by the address stored in the InformInfo element
+*
+* SYNOPSIS
+*/
+ib_api_status_t osm_report_notice(IN osm_log_t * p_log, IN osm_subn_t * p_subn,
+ IN ib_mad_notice_attr_t * p_ntc);
+/*
+* PARAMETERS
+* p_rcv
+* [in] Pointer to the trap receiver
+*
+* p_ntc
+* [in] Pointer to a copy of the incoming trap notice attribute.
+*
+* RETURN
+* IB_SUCCESS on good completion
+*
+* SEE ALSO
+* Inform Record, osm_trap_rcv
+*********/
+
+END_C_DECLS
+#endif /* _OSM_INFR_H_ */
diff --git a/contrib/ofed/opensm/include/opensm/osm_lid_mgr.h b/contrib/ofed/opensm/include/opensm/osm_lid_mgr.h
new file mode 100644
index 0000000..f95a2a1
--- /dev/null
+++ b/contrib/ofed/opensm/include/opensm/osm_lid_mgr.h
@@ -0,0 +1,283 @@
+/*
+ * Copyright (c) 2004-2009 Voltaire, Inc. All rights reserved.
+ * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved.
+ * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+/*
+ * Abstract:
+ * Declaration of osm_lid_mgr_t.
+ * This object represents the LID Manager object.
+ * This object is part of the OpenSM family of objects.
+ */
+
+#ifndef _OSM_LID_MGR_H_
+#define _OSM_LID_MGR_H_
+
+#include <complib/cl_passivelock.h>
+#include <opensm/osm_base.h>
+#include <opensm/osm_madw.h>
+#include <opensm/osm_subnet.h>
+#include <opensm/osm_db.h>
+#include <opensm/osm_log.h>
+
+#ifdef __cplusplus
+# define BEGIN_C_DECLS extern "C" {
+# define END_C_DECLS }
+#else /* !__cplusplus */
+# define BEGIN_C_DECLS
+# define END_C_DECLS
+#endif /* __cplusplus */
+
+BEGIN_C_DECLS
+#define OSM_LID_MGR_LIST_SIZE_MIN 256
+/****h* OpenSM/LID Manager
+* NAME
+* LID Manager
+*
+* DESCRIPTION
+* The LID Manager object encapsulates the information
+* needed to control LID assignments on the subnet.
+*
+* The LID Manager object is thread safe.
+*
+* This object should be treated as opaque and should be
+* manipulated only through the provided functions.
+*
+* AUTHOR
+* Steve King, Intel
+*
+*********/
+struct osm_sm;
+/****s* OpenSM: LID Manager/osm_lid_mgr_t
+* NAME
+* osm_lid_mgr_t
+*
+* DESCRIPTION
+* LID Manager structure.
+*
+* This object should be treated as opaque and should
+* be manipulated only through the provided functions.
+*
+* SYNOPSIS
+*/
+typedef struct osm_lid_mgr {
+ struct osm_sm *sm;
+ osm_subn_t *p_subn;
+ osm_db_t *p_db;
+ osm_log_t *p_log;
+ cl_plock_t *p_lock;
+ osm_db_domain_t *p_g2l;
+ cl_qlist_t free_ranges;
+ boolean_t dirty;
+ uint8_t used_lids[IB_LID_UCAST_END_HO + 1];
+} osm_lid_mgr_t;
+/*
+* FIELDS
+* sm
+* Pointer to the SM object.
+*
+* p_subn
+* Pointer to the Subnet object for this subnet.
+*
+* p_db
+* Pointer to the database (persistency) object
+*
+* p_log
+* Pointer to the log object.
+*
+* p_lock
+* Pointer to the serializing lock.
+*
+* p_g2l
+* Pointer to the database domain storing guid to lid mapping.
+*
+* free_ranges
+* A list of available free lid ranges. The list is initialized
+* by the code that initializes the lid assignment and is consumed
+* by the procedure that finds a free range. It holds elements of
+* type osm_lid_mgr_range_t
+*
+* dirty
+* Indicates that lid table was updated
+*
+* used_lids
+* An array of used lids. keeps track of
+* existing and non existing mapping of guid->lid
+*
+* SEE ALSO
+* LID Manager object
+*********/
+
+/****f* OpenSM: LID Manager/osm_lid_mgr_construct
+* NAME
+* osm_lid_mgr_construct
+*
+* DESCRIPTION
+* This function constructs a LID Manager object.
+*
+* SYNOPSIS
+*/
+void osm_lid_mgr_construct(IN osm_lid_mgr_t * p_mgr);
+/*
+* PARAMETERS
+* p_mgr
+* [in] Pointer to a LID Manager object to construct.
+*
+* RETURN VALUE
+* This function does not return a value.
+*
+* NOTES
+* Allows osm_lid_mgr_destroy
+*
+* Calling osm_lid_mgr_construct is a prerequisite to calling any other
+* method except osm_lid_mgr_init.
+*
+* SEE ALSO
+* LID Manager object, osm_lid_mgr_init,
+* osm_lid_mgr_destroy
+*********/
+
+/****f* OpenSM: LID Manager/osm_lid_mgr_destroy
+* NAME
+* osm_lid_mgr_destroy
+*
+* DESCRIPTION
+* The osm_lid_mgr_destroy function destroys the object, releasing
+* all resources.
+*
+* SYNOPSIS
+*/
+void osm_lid_mgr_destroy(IN osm_lid_mgr_t * p_mgr);
+/*
+* PARAMETERS
+* p_mgr
+* [in] Pointer to the object to destroy.
+*
+* RETURN VALUE
+* This function does not return a value.
+*
+* NOTES
+* Performs any necessary cleanup of the specified
+* LID Manager object.
+* Further operations should not be attempted on the destroyed object.
+* This function should only be called after a call to
+* osm_lid_mgr_construct or osm_lid_mgr_init.
+*
+* SEE ALSO
+* LID Manager object, osm_lid_mgr_construct,
+* osm_lid_mgr_init
+*********/
+
+/****f* OpenSM: LID Manager/osm_lid_mgr_init
+* NAME
+* osm_lid_mgr_init
+*
+* DESCRIPTION
+* The osm_lid_mgr_init function initializes a
+* LID Manager object for use.
+*
+* SYNOPSIS
+*/
+ib_api_status_t
+osm_lid_mgr_init(IN osm_lid_mgr_t * p_mgr, IN struct osm_sm * sm);
+/*
+* PARAMETERS
+* p_mgr
+* [in] Pointer to an osm_lid_mgr_t object to initialize.
+*
+* sm
+* [in] Pointer to the SM object for this subnet.
+*
+* RETURN VALUES
+* CL_SUCCESS if the LID Manager object was initialized
+* successfully.
+*
+* NOTES
+* Allows calling other LID Manager methods.
+*
+* SEE ALSO
+* LID Manager object, osm_lid_mgr_construct,
+* osm_lid_mgr_destroy
+*********/
+
+/****f* OpenSM: LID Manager/osm_lid_mgr_process_sm
+* NAME
+* osm_lid_mgr_process_sm
+*
+* DESCRIPTION
+* Configures the SM's port with its designated LID values.
+*
+* SYNOPSIS
+*/
+int osm_lid_mgr_process_sm(IN osm_lid_mgr_t * p_mgr);
+/*
+* PARAMETERS
+* p_mgr
+* [in] Pointer to an osm_lid_mgr_t object.
+*
+* RETURN VALUES
+* Returns 0 on success and non-zero value otherwise.
+*
+* NOTES
+*
+* SEE ALSO
+* LID Manager
+*********/
+
+/****f* OpenSM: LID Manager/osm_lid_mgr_process_subnet
+* NAME
+* osm_lid_mgr_process_subnet
+*
+* DESCRIPTION
+* Configures subnet ports (except the SM port itself) with their
+* designated LID values.
+*
+* SYNOPSIS
+*/
+int osm_lid_mgr_process_subnet(IN osm_lid_mgr_t * p_mgr);
+/*
+* PARAMETERS
+* p_mgr
+* [in] Pointer to an osm_lid_mgr_t object.
+*
+* RETURN VALUES
+* Returns 0 on success and non-zero value otherwise.
+*
+* NOTES
+*
+* SEE ALSO
+* LID Manager
+*********/
+
+END_C_DECLS
+#endif /* _OSM_LID_MGR_H_ */
diff --git a/contrib/ofed/opensm/include/opensm/osm_log.h b/contrib/ofed/opensm/include/opensm/osm_log.h
new file mode 100644
index 0000000..61ba750
--- /dev/null
+++ b/contrib/ofed/opensm/include/opensm/osm_log.h
@@ -0,0 +1,592 @@
+/*
+ * Copyright (c) 2004-2009 Voltaire, Inc. All rights reserved.
+ * Copyright (c) 2002-2012 Mellanox Technologies LTD. All rights reserved.
+ * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+/*
+ * Abstract:
+ * Declaration of osm_log_t.
+ * This object represents the log file.
+ * This object is part of the OpenSM family of objects.
+ */
+
+#ifndef _OSM_LOG_H_
+#define _OSM_LOG_H_
+
+#ifndef __WIN__
+#include <syslog.h>
+#endif
+#include <complib/cl_spinlock.h>
+#include <opensm/osm_base.h>
+#include <iba/ib_types.h>
+#include <stdio.h>
+
+#ifdef __GNUC__
+#define STRICT_OSM_LOG_FORMAT __attribute__((format(printf, 3, 4)))
+#define STRICT_OSM_LOG_V2_FORMAT __attribute__((format(printf, 4, 5)))
+#else
+#define STRICT_OSM_LOG_FORMAT
+#define STRICT_OSM_LOG_V2_FORMAT
+#endif
+
+#ifdef __cplusplus
+# define BEGIN_C_DECLS extern "C" {
+# define END_C_DECLS }
+#else /* !__cplusplus */
+# define BEGIN_C_DECLS
+# define END_C_DECLS
+#endif /* __cplusplus */
+
+BEGIN_C_DECLS
+#define LOG_ENTRY_SIZE_MAX 4096
+#define BUF_SIZE LOG_ENTRY_SIZE_MAX
+#define __func__ __FUNCTION__
+#ifdef FILE_ID
+#define OSM_LOG_ENTER( OSM_LOG_PTR ) \
+ osm_log_v2( OSM_LOG_PTR, OSM_LOG_FUNCS, FILE_ID, \
+ "%s: [\n", __func__);
+#define OSM_LOG_EXIT( OSM_LOG_PTR ) \
+ osm_log_v2( OSM_LOG_PTR, OSM_LOG_FUNCS, FILE_ID, \
+ "%s: ]\n", __func__);
+#define OSM_LOG_IS_ACTIVE_V2( OSM_LOG_PTR, OSM_LOG_FUNCS ) \
+ osm_log_is_active_v2( OSM_LOG_PTR, OSM_LOG_FUNCS, FILE_ID)
+#else
+#define OSM_LOG_ENTER( OSM_LOG_PTR ) \
+ osm_log( OSM_LOG_PTR, OSM_LOG_FUNCS, \
+ "%s: [\n", __func__);
+#define OSM_LOG_EXIT( OSM_LOG_PTR ) \
+ osm_log( OSM_LOG_PTR, OSM_LOG_FUNCS, \
+ "%s: ]\n", __func__);
+#endif
+
+/****h* OpenSM/Log
+* NAME
+* Log
+*
+* DESCRIPTION
+*
+* AUTHOR
+*
+*********/
+typedef uint8_t osm_log_level_t;
+
+#define OSM_LOG_NONE 0x00
+#define OSM_LOG_ERROR 0x01
+#define OSM_LOG_INFO 0x02
+#define OSM_LOG_VERBOSE 0x04
+#define OSM_LOG_DEBUG 0x08
+#define OSM_LOG_FUNCS 0x10
+#define OSM_LOG_FRAMES 0x20
+#define OSM_LOG_ROUTING 0x40
+#define OSM_LOG_ALL 0x7f
+#define OSM_LOG_SYS 0x80
+
+/*
+ DEFAULT - turn on ERROR and INFO only
+*/
+#define OSM_LOG_DEFAULT_LEVEL OSM_LOG_ERROR | OSM_LOG_INFO
+
+/****s* OpenSM: Log/osm_log_t
+* NAME
+* osm_log_t
+*
+* DESCRIPTION
+*
+* SYNOPSIS
+*/
+typedef struct osm_log {
+ osm_log_level_t level;
+ cl_spinlock_t lock;
+ unsigned long count;
+ unsigned long max_size;
+ boolean_t flush;
+ FILE *out_port;
+ boolean_t accum_log_file;
+ boolean_t daemon;
+ char *log_file_name;
+ char *log_prefix;
+ osm_log_level_t per_mod_log_tbl[256];
+} osm_log_t;
+/*********/
+
+#define OSM_LOG_MOD_NAME_MAX 32
+
+/****f* OpenSM: Log/osm_get_log_per_module
+ * NAME
+ * osm_get_log_per_module
+ *
+ * DESCRIPTION
+ * This looks up the given file ID in the per module log table.
+ * NOTE: this code is not thread safe. Need to grab the lock before
+ * calling it.
+ *
+ * SYNOPSIS
+ */
+osm_log_level_t osm_get_log_per_module(IN osm_log_t * p_log,
+ IN const int file_id);
+/*
+ * PARAMETERS
+ * p_log
+ * [in] Pointer to a Log object to construct.
+ *
+ * file_id
+ * [in] File ID for module
+ *
+ * RETURN VALUES
+ * The log level from the per module logging structure for this file ID.
+ *********/
+
+/****f* OpenSM: Log/osm_set_log_per_module
+ * NAME
+ * osm_set_log_per_module
+ *
+ * DESCRIPTION
+ * This sets log level for the given file ID in the per module log table.
+ * NOTE: this code is not thread safe. Need to grab the lock before
+ * calling it.
+ *
+ * SYNOPSIS
+ */
+void osm_set_log_per_module(IN osm_log_t * p_log, IN const int file_id,
+ IN osm_log_level_t level);
+/*
+ * PARAMETERS
+ * p_log
+ * [in] Pointer to a Log object to construct.
+ *
+ * file_id
+ * [in] File ID for module
+ *
+ * level
+ * [in] Log level of the module
+ *
+ * RETURN VALUES
+ * This function does not return a value.
+ *********/
+
+/****f* OpenSM: Log/osm_reset_log_per_module
+ * NAME
+ * osm_reset_log_per_module
+ *
+ * DESCRIPTION
+ * This resets log level for the entire per module log table.
+ * NOTE: this code is not thread safe. Need to grab the lock before
+ * calling it.
+ *
+ * SYNOPSIS
+ */
+void osm_reset_log_per_module(IN osm_log_t * p_log);
+/*
+ * PARAMETERS
+ * p_log
+ * [in] Pointer to a Log object to construct.
+ *
+ * RETURN VALUES
+ * This function does not return a value.
+ *********/
+
+/****f* OpenSM: Log/osm_log_construct
+* NAME
+* osm_log_construct
+*
+* DESCRIPTION
+* This function constructs a Log object.
+*
+* SYNOPSIS
+*/
+static inline void osm_log_construct(IN osm_log_t * p_log)
+{
+ cl_spinlock_construct(&p_log->lock);
+}
+
+/*
+* PARAMETERS
+* p_log
+* [in] Pointer to a Log object to construct.
+*
+* RETURN VALUE
+* This function does not return a value.
+*
+* NOTES
+* Allows calling osm_log_init, osm_log_init_v2, osm_log_destroy
+*
+* Calling osm_log_construct is a prerequisite to calling any other
+* method except osm_log_init or osm_log_init_v2.
+*
+* SEE ALSO
+* Log object, osm_log_init, osm_log_init_v2,
+* osm_log_destroy
+*********/
+
+/****f* OpenSM: Log/osm_log_destroy
+* NAME
+* osm_log_destroy
+*
+* DESCRIPTION
+* The osm_log_destroy function destroys the object, releasing
+* all resources.
+*
+* SYNOPSIS
+*/
+static inline void osm_log_destroy(IN osm_log_t * p_log)
+{
+ cl_spinlock_destroy(&p_log->lock);
+ if (p_log->out_port != stdout) {
+ fclose(p_log->out_port);
+ p_log->out_port = stdout;
+ }
+ closelog();
+}
+
+/*
+* PARAMETERS
+* p_log
+* [in] Pointer to the object to destroy.
+*
+* RETURN VALUE
+* This function does not return a value.
+*
+* NOTES
+* Performs any necessary cleanup of the specified
+* Log object.
+* Further operations should not be attempted on the destroyed object.
+* This function should only be called after a call to
+* osm_log_construct, osm_log_init, or osm_log_init_v2.
+*
+* SEE ALSO
+* Log object, osm_log_construct,
+* osm_log_init, osm_log_init_v2
+*********/
+
+/****f* OpenSM: Log/osm_log_init_v2
+* NAME
+* osm_log_init_v2
+*
+* DESCRIPTION
+* The osm_log_init_v2 function initializes a
+* Log object for use.
+*
+* SYNOPSIS
+*/
+ib_api_status_t osm_log_init_v2(IN osm_log_t * p_log, IN boolean_t flush,
+ IN uint8_t log_flags, IN const char *log_file,
+ IN unsigned long max_size,
+ IN boolean_t accum_log_file);
+/*
+* PARAMETERS
+* p_log
+* [in] Pointer to the log object.
+*
+* flush
+* [in] Set to TRUE directs the log to flush all log messages
+* immediately. This severely degrades log performance,
+* and is normally used for debugging only.
+*
+* log_flags
+* [in] The log verbosity level to be used.
+*
+* log_file
+* [in] if not NULL defines the name of the log file. Otherwise
+* it is stdout.
+*
+* RETURN VALUES
+* CL_SUCCESS if the Log object was initialized
+* successfully.
+*
+* NOTES
+* Allows calling other Log methods.
+*
+* SEE ALSO
+* Log object, osm_log_construct,
+* osm_log_destroy
+*********/
+
+/****f* OpenSM: Log/osm_log_reopen_file
+* NAME
+* osm_log_reopen_file
+*
+* DESCRIPTION
+* The osm_log_reopen_file function reopens the log file
+*
+* SYNOPSIS
+*/
+int osm_log_reopen_file(osm_log_t * p_log);
+/*
+* PARAMETERS
+* p_log
+* [in] Pointer to the log object.
+*
+* RETURN VALUES
+* 0 on success or nonzero value otherwise.
+*********/
+
+/****f* OpenSM: Log/osm_log_init
+* NAME
+* osm_log_init
+*
+* DESCRIPTION
+* The osm_log_init function initializes a
+* Log object for use. It is a wrapper for osm_log_init_v2().
+*
+* SYNOPSIS
+*/
+ib_api_status_t osm_log_init(IN osm_log_t * p_log, IN boolean_t flush,
+ IN uint8_t log_flags, IN const char *log_file,
+ IN boolean_t accum_log_file);
+/*
+ * Same as osm_log_init_v2() but without max_size parameter
+ */
+
+void osm_log(IN osm_log_t * p_log, IN osm_log_level_t verbosity,
+ IN const char *p_str, ...) STRICT_OSM_LOG_FORMAT;
+
+void osm_log_v2(IN osm_log_t * p_log, IN osm_log_level_t verbosity,
+ IN const int file_id, IN const char *p_str, ...) STRICT_OSM_LOG_V2_FORMAT;
+
+/****f* OpenSM: Log/osm_log_get_level
+* NAME
+* osm_log_get_level
+*
+* DESCRIPTION
+* Returns the current log level.
+*
+* SYNOPSIS
+*/
+static inline osm_log_level_t osm_log_get_level(IN const osm_log_t * p_log)
+{
+ return p_log->level;
+}
+
+/*
+* PARAMETERS
+* p_log
+* [in] Pointer to the log object.
+*
+* RETURN VALUES
+* Returns the current log level.
+*
+* NOTES
+*
+* SEE ALSO
+* Log object, osm_log_construct,
+* osm_log_destroy
+*********/
+
+/****f* OpenSM: Log/osm_log_set_level
+* NAME
+* osm_log_set_level
+*
+* DESCRIPTION
+* Sets the current log level.
+*
+* SYNOPSIS
+*/
+static inline void osm_log_set_level(IN osm_log_t * p_log,
+ IN osm_log_level_t level)
+{
+ p_log->level = level;
+ osm_log(p_log, OSM_LOG_ALL, "Setting log level to: 0x%02x\n", level);
+}
+
+/*
+* PARAMETERS
+* p_log
+* [in] Pointer to the log object.
+*
+* level
+* [in] New level to set.
+*
+* RETURN VALUES
+* This function does not return a value.
+*
+* NOTES
+*
+* SEE ALSO
+* Log object, osm_log_construct,
+* osm_log_destroy
+*********/
+
+/****f* OpenSM: Log/osm_log_is_active
+* NAME
+* osm_log_is_active
+*
+* DESCRIPTION
+* Returns TRUE if the specified log level would be logged.
+* FALSE otherwise.
+*
+* SYNOPSIS
+*/
+static inline boolean_t osm_log_is_active(IN const osm_log_t * p_log,
+ IN osm_log_level_t level)
+{
+ return ((p_log->level & level) != 0);
+}
+
+/*
+* PARAMETERS
+* p_log
+* [in] Pointer to the log object.
+*
+* level
+* [in] Level to check.
+*
+* RETURN VALUES
+* Returns TRUE if the specified log level would be logged.
+* FALSE otherwise.
+*
+* NOTES
+*
+* SEE ALSO
+* Log object, osm_log_construct,
+* osm_log_destroy
+*********/
+
+static inline boolean_t osm_log_is_active_v2(IN const osm_log_t * p_log,
+ IN osm_log_level_t level,
+ IN const int file_id)
+{
+ if ((p_log->level & level) != 0)
+ return 1;
+ if ((level & p_log->per_mod_log_tbl[file_id]))
+ return 1;
+ return 0;
+}
+
+extern void osm_log_msg_box(osm_log_t *log, osm_log_level_t level,
+ const char *func_name, const char *msg);
+extern void osm_log_msg_box_v2(osm_log_t *log, osm_log_level_t level,
+ const int file_id, const char *func_name,
+ const char *msg);
+extern void osm_log_raw(IN osm_log_t * p_log, IN osm_log_level_t verbosity,
+ IN const char *p_buf);
+
+#ifdef FILE_ID
+#define OSM_LOG(log, level, fmt, ...) do { \
+ if (osm_log_is_active_v2(log, (level), FILE_ID)) \
+ osm_log_v2(log, level, FILE_ID, "%s: " fmt, __func__, ## __VA_ARGS__); \
+ } while (0)
+
+#define OSM_LOG_MSG_BOX(log, level, msg) \
+ osm_log_msg_box_v2(log, level, FILE_ID, __func__, msg)
+#else
+#define OSM_LOG(log, level, fmt, ...) do { \
+ if (osm_log_is_active(log, (level))) \
+ osm_log(log, level, "%s: " fmt, __func__, ## __VA_ARGS__); \
+ } while (0)
+
+#define OSM_LOG_MSG_BOX(log, level, msg) \
+ osm_log_msg_box(log, level, __func__, msg)
+#endif
+
+#define DBG_CL_LOCK 0
+
+#define CL_PLOCK_EXCL_ACQUIRE( __exp__ ) \
+{ \
+ if (DBG_CL_LOCK) \
+ printf("cl_plock_excl_acquire: Acquiring %p file %s, line %d\n", \
+ __exp__,__FILE__, __LINE__); \
+ cl_plock_excl_acquire( __exp__ ); \
+ if (DBG_CL_LOCK) \
+ printf("cl_plock_excl_acquire: Acquired %p file %s, line %d\n", \
+ __exp__,__FILE__, __LINE__); \
+}
+
+#define CL_PLOCK_ACQUIRE( __exp__ ) \
+{ \
+ if (DBG_CL_LOCK) \
+ printf("cl_plock_acquire: Acquiring %p file %s, line %d\n", \
+ __exp__,__FILE__, __LINE__); \
+ cl_plock_acquire( __exp__ ); \
+ if (DBG_CL_LOCK) \
+ printf("cl_plock_acquire: Acquired %p file %s, line %d\n", \
+ __exp__,__FILE__, __LINE__); \
+}
+
+#define CL_PLOCK_RELEASE( __exp__ ) \
+{ \
+ if (DBG_CL_LOCK) \
+ printf("cl_plock_release: Releasing %p file %s, line %d\n", \
+ __exp__,__FILE__, __LINE__); \
+ cl_plock_release( __exp__ ); \
+ if (DBG_CL_LOCK) \
+ printf("cl_plock_release: Released %p file %s, line %d\n", \
+ __exp__,__FILE__, __LINE__); \
+}
+
+#define DBG_CL_SPINLOCK 0
+#define CL_SPINLOCK_RELEASE( __exp__ ) \
+{ \
+ if (DBG_CL_SPINLOCK) \
+ printf("cl_spinlock_release: Releasing %p file %s, line %d\n", \
+ __exp__,__FILE__, __LINE__); \
+ cl_spinlock_release( __exp__ ); \
+ if (DBG_CL_SPINLOCK) \
+ printf("cl_spinlock_release: Released %p file %s, line %d\n", \
+ __exp__,__FILE__, __LINE__); \
+}
+
+#define CL_SPINLOCK_ACQUIRE( __exp__ ) \
+{ \
+ if (DBG_CL_SPINLOCK) \
+ printf("cl_spinlock_acquire: Acquiring %p file %s, line %d\n", \
+ __exp__,__FILE__, __LINE__); \
+ cl_spinlock_acquire( __exp__ ); \
+ if (DBG_CL_SPINLOCK) \
+ printf("cl_spinlock_acquire: Acquired %p file %s, line %d\n", \
+ __exp__,__FILE__, __LINE__); \
+}
+
+/****f* OpenSM: Helper/osm_is_debug
+* NAME
+* osm_is_debug
+*
+* DESCRIPTION
+* The osm_is_debug function returns TRUE if the opensm was compiled
+* in debug mode, and FALSE otherwise.
+*
+* SYNOPSIS
+*/
+boolean_t osm_is_debug(void);
+/*
+* PARAMETERS
+* None
+*
+* RETURN VALUE
+* TRUE if compiled in debug version. FALSE otherwise.
+*
+* NOTES
+*
+*********/
+
+END_C_DECLS
+#endif /* _OSM_LOG_H_ */
diff --git a/contrib/ofed/opensm/include/opensm/osm_mad_pool.h b/contrib/ofed/opensm/include/opensm/osm_mad_pool.h
new file mode 100644
index 0000000..ccfdd6e
--- /dev/null
+++ b/contrib/ofed/opensm/include/opensm/osm_mad_pool.h
@@ -0,0 +1,370 @@
+/*
+ * Copyright (c) 2004-2009 Voltaire, Inc. All rights reserved.
+ * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved.
+ * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+/*
+ * Abstract:
+ * Declaration of osm_mad_pool_t.
+ * This object represents a pool of management datagram (MAD) objects.
+ * This object is part of the OpenSM family of objects.
+ */
+
+#ifndef _OSM_MAD_POOL_H_
+#define _OSM_MAD_POOL_H_
+
+#include <iba/ib_types.h>
+#include <complib/cl_atomic.h>
+#include <opensm/osm_base.h>
+#include <opensm/osm_madw.h>
+#include <vendor/osm_vendor.h>
+
+#ifdef __cplusplus
+# define BEGIN_C_DECLS extern "C" {
+# define END_C_DECLS }
+#else /* !__cplusplus */
+# define BEGIN_C_DECLS
+# define END_C_DECLS
+#endif /* __cplusplus */
+
+BEGIN_C_DECLS
+/****h* OpenSM/MAD Pool
+* NAME
+* MAD Pool
+*
+* DESCRIPTION
+* The MAD Pool encapsulates the information needed by the
+* OpenSM to manage a pool of MAD objects. The OpenSM allocates
+* one MAD Pool per IBA subnet.
+*
+* The MAD Pool is thread safe.
+*
+* This object should be treated as opaque and should be
+* manipulated only through the provided functions.
+*
+* AUTHOR
+* Steve King, Intel
+*
+*********/
+/****s* OpenSM: MAD Pool/osm_mad_pool_t
+* NAME
+* osm_mad_pool_t
+*
+* DESCRIPTION
+* MAD Pool structure.
+*
+* This object should be treated as opaque and should
+* be manipulated only through the provided functions.
+*
+* SYNOPSIS
+*/
+typedef struct osm_mad_pool {
+ atomic32_t mads_out;
+} osm_mad_pool_t;
+/*
+* FIELDS
+* mads_out
+* Running total of the number of MADs outstanding.
+*
+* SEE ALSO
+* MAD Pool
+*********/
+
+/****f* OpenSM: MAD Pool/osm_mad_pool_construct
+* NAME
+* osm_mad_pool_construct
+*
+* DESCRIPTION
+* This function constructs a MAD Pool.
+*
+* SYNOPSIS
+*/
+void osm_mad_pool_construct(IN osm_mad_pool_t * p_pool);
+/*
+* PARAMETERS
+* p_pool
+* [in] Pointer to a MAD Pool to construct.
+*
+* RETURN VALUE
+* This function does not return a value.
+*
+* NOTES
+* Allows calling osm_mad_pool_init, osm_mad_pool_destroy
+*
+* Calling osm_mad_pool_construct is a prerequisite to calling any other
+* method except osm_mad_pool_init.
+*
+* SEE ALSO
+* MAD Pool, osm_mad_pool_init, osm_mad_pool_destroy
+*********/
+
+/****f* OpenSM: MAD Pool/osm_mad_pool_destroy
+* NAME
+* osm_mad_pool_destroy
+*
+* DESCRIPTION
+* The osm_mad_pool_destroy function destroys a node, releasing
+* all resources.
+*
+* SYNOPSIS
+*/
+void osm_mad_pool_destroy(IN osm_mad_pool_t * p_pool);
+/*
+* PARAMETERS
+* p_pool
+* [in] Pointer to a MAD Pool to destroy.
+*
+* RETURN VALUE
+* This function does not return a value.
+*
+* NOTES
+* Performs any necessary cleanup of the specified MAD Pool.
+* Further operations should not be attempted on the destroyed object.
+* This function should only be called after a call to osm_mad_pool_construct or
+* osm_mad_pool_init.
+*
+* SEE ALSO
+* MAD Pool, osm_mad_pool_construct, osm_mad_pool_init
+*********/
+
+/****f* OpenSM: MAD Pool/osm_mad_pool_init
+* NAME
+* osm_mad_pool_init
+*
+* DESCRIPTION
+* The osm_mad_pool_init function initializes a MAD Pool for use.
+*
+* SYNOPSIS
+*/
+ib_api_status_t osm_mad_pool_init(IN osm_mad_pool_t * p_pool);
+/*
+* PARAMETERS
+* p_pool
+* [in] Pointer to an osm_mad_pool_t object to initialize.
+*
+* RETURN VALUES
+* CL_SUCCESS if the MAD Pool was initialized successfully.
+*
+* NOTES
+* Allows calling other MAD Pool methods.
+*
+* SEE ALSO
+* MAD Pool, osm_mad_pool_construct, osm_mad_pool_destroy
+*********/
+
+/****f* OpenSM: MAD Pool/osm_mad_pool_get
+* NAME
+* osm_mad_pool_get
+*
+* DESCRIPTION
+* Gets a MAD wrapper and wire MAD from the pool.
+*
+* SYNOPSIS
+*/
+osm_madw_t *osm_mad_pool_get(IN osm_mad_pool_t * p_pool,
+ IN osm_bind_handle_t h_bind,
+ IN uint32_t total_size,
+ IN const osm_mad_addr_t * p_mad_addr);
+/*
+* PARAMETERS
+* p_pool
+* [in] Pointer to an osm_mad_pool_t object.
+*
+* h_bind
+* [in] Handle returned from osm_vendor_bind() call to the
+* port over which this mad will be sent.
+*
+* total_size
+* [in] Total size, including MAD header of the requested MAD.
+*
+* p_mad_addr
+* [in] Pointer to the MAD address structure. This parameter
+* may be NULL for directed route MADs.
+*
+* RETURN VALUES
+* Returns a pointer to a MAD wrapper containing the MAD.
+* A return value of NULL means no MADs are available.
+*
+* NOTES
+* The MAD must eventually be returned to the pool with a call to
+* osm_mad_pool_put.
+*
+* The osm_mad_pool_construct or osm_mad_pool_init must be called before
+* using this function.
+*
+* SEE ALSO
+* MAD Pool, osm_mad_pool_put
+*********/
+
+/****f* OpenSM: MAD Pool/osm_mad_pool_put
+* NAME
+* osm_mad_pool_put
+*
+* DESCRIPTION
+* Returns a MAD to the pool.
+*
+* SYNOPSIS
+*/
+void osm_mad_pool_put(IN osm_mad_pool_t * p_pool, IN osm_madw_t * p_madw);
+/*
+* PARAMETERS
+* p_pool
+* [in] Pointer to an osm_mad_pool_t object.
+*
+* p_madw
+* [in] Pointer to a MAD Wrapper for a MAD that was previously
+* retrieved from the pool.
+*
+* RETURN VALUES
+* This function does not return a value.
+*
+* NOTES
+* The osm_mad_pool_construct or osm_mad_pool_init must be called before
+* using this function.
+*
+* SEE ALSO
+* MAD Pool, osm_mad_pool_get
+*********/
+
+/****f* OpenSM: MAD Pool/osm_mad_pool_get_wrapper
+* NAME
+* osm_mad_pool_get_wrapper
+*
+* DESCRIPTION
+* Gets a only MAD wrapper from the pool (no wire MAD).
+*
+* SYNOPSIS
+*/
+osm_madw_t *osm_mad_pool_get_wrapper(IN osm_mad_pool_t * p_pool,
+ IN osm_bind_handle_t h_bind,
+ IN uint32_t total_size,
+ IN const ib_mad_t * p_mad,
+ IN const osm_mad_addr_t * p_mad_addr);
+/*
+* PARAMETERS
+* p_pool
+* [in] Pointer to an osm_mad_pool_t object.
+*
+* h_bind
+* [in] Handle returned from osm_vendor_bind() call to the
+* port for which this mad wrapper will be used.
+*
+* total_size
+* [in] Total size, including MAD header of the MAD that will
+* be attached to this wrapper.
+*
+* p_mad
+* [in] Pointer to the MAD to attach to this wrapper.
+*
+* p_mad_addr
+* [in] Pointer to the MAD address structure. This parameter
+* may be NULL for directed route MADs.
+*
+* RETURN VALUES
+* Returns a pointer to a MAD wrapper.
+* A return value of NULL means no MAD wrappers are available.
+*
+* NOTES
+* The MAD must eventually be returned to the pool with a call to
+* osm_mad_pool_put.
+*
+* The osm_mad_pool_construct or osm_mad_pool_init must be called before
+* using this function.
+*
+* SEE ALSO
+* MAD Pool, osm_mad_pool_put
+*********/
+
+/****f* OpenSM: MAD Pool/osm_mad_pool_get_wrapper_raw
+* NAME
+* osm_mad_pool_get_wrapper_raw
+*
+* DESCRIPTION
+* Gets a only an uninitialized MAD wrapper from the pool (no wire MAD).
+*
+* SYNOPSIS
+*/
+osm_madw_t *osm_mad_pool_get_wrapper_raw(IN osm_mad_pool_t * p_pool);
+/*
+* PARAMETERS
+* p_pool
+* [in] Pointer to an osm_mad_pool_t object.
+*
+* RETURN VALUES
+* Returns a pointer to a MAD wrapper.
+* A return value of NULL means no MAD wrappers are available.
+*
+* NOTES
+* The MAD must eventually be returned to the pool with a call to
+* osm_mad_pool_put.
+*
+* The osm_mad_pool_construct or osm_mad_pool_init must be called before
+* using this function.
+*
+* SEE ALSO
+* MAD Pool, osm_mad_pool_put
+*********/
+
+/****f* OpenSM: MAD Pool/osm_mad_pool_get_outstanding
+* NAME
+* osm_mad_pool_get_count
+*
+* DESCRIPTION
+* Returns the running count of MADs currently outstanding from the pool.
+*
+* SYNOPSIS
+*/
+static inline uint32_t
+osm_mad_pool_get_outstanding(IN const osm_mad_pool_t * p_pool)
+{
+ return p_pool->mads_out;
+}
+
+/*
+* PARAMETERS
+* p_pool
+* [in] Pointer to an osm_mad_pool_t object.
+*
+* RETURN VALUES
+* Returns the running count of MADs currently outstanding from the pool.
+*
+* NOTES
+* The osm_mad_pool_construct or osm_mad_pool_init must be called before
+* using this function.
+*
+* SEE ALSO
+* MAD Pool, osm_mad_pool_get
+*********/
+
+END_C_DECLS
+#endif /* _OSM_MAD_POOL_H_ */
diff --git a/contrib/ofed/opensm/include/opensm/osm_madw.h b/contrib/ofed/opensm/include/opensm/osm_madw.h
new file mode 100644
index 0000000..9fb7d5d
--- /dev/null
+++ b/contrib/ofed/opensm/include/opensm/osm_madw.h
@@ -0,0 +1,1209 @@
+/*
+ * Copyright (c) 2004-2009 Voltaire, Inc. All rights reserved.
+ * Copyright (c) 2002-2012 Mellanox Technologies LTD. All rights reserved.
+ * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
+ * Copyright (c) 2009 HNR Consulting. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+/*
+ * Abstract:
+ * Declaration of osm_mad_wrapper_t.
+ * This object represents the context wrapper for OpenSM MAD processing.
+ * This object is part of the OpenSM family of objects.
+ */
+
+#ifndef _OSM_MADW_H_
+#define _OSM_MADW_H_
+
+#include <string.h>
+#include <iba/ib_types.h>
+#include <complib/cl_qlist.h>
+#include <complib/cl_dispatcher.h>
+#include <opensm/osm_base.h>
+#include <vendor/osm_vendor.h>
+
+#ifdef __cplusplus
+# define BEGIN_C_DECLS extern "C" {
+# define END_C_DECLS }
+#else /* !__cplusplus */
+# define BEGIN_C_DECLS
+# define END_C_DECLS
+#endif /* __cplusplus */
+
+BEGIN_C_DECLS
+/****s* OpenSM: MAD Wrapper/osm_bind_info_t
+* NAME
+* osm_bind_info_t
+*
+* DESCRIPTION
+*
+* SYNOPSIS
+*/
+typedef struct osm_bind_info {
+ ib_net64_t port_guid;
+ uint8_t mad_class;
+ uint8_t class_version;
+ boolean_t is_responder;
+ boolean_t is_trap_processor;
+ boolean_t is_report_processor;
+ uint32_t send_q_size;
+ uint32_t recv_q_size;
+ uint32_t timeout;
+ uint32_t retries;
+} osm_bind_info_t;
+/*
+* FIELDS
+* portguid
+* PortGuid of local port
+*
+* mad_class
+* Mgmt Class ID
+*
+* class_version
+* Mgmt Class version
+*
+* is_responder
+* True if this is a GSI Agent
+*
+* is_trap_processor
+* True if GSI Trap msgs are handled
+*
+* is_report_processor
+* True if GSI Report msgs are handled
+*
+* send_q_size
+* SendQueueSize
+*
+* recv_q_size
+* Receive Queue Size
+*
+* timeout
+* Transaction timeout
+*
+* retries
+* Number of retries for transaction
+*
+* SEE ALSO
+*********/
+
+/****h* OpenSM/MAD Wrapper
+* NAME
+* MAD Wrapper
+*
+* DESCRIPTION
+* The MAD Wrapper object encapsulates the information needed by the
+* OpenSM to manage individual MADs. The OpenSM allocates one MAD Wrapper
+* per MAD.
+*
+* The MAD Wrapper is not thread safe, thus callers must provide
+* serialization.
+*
+* This object should be treated as opaque and should be
+* manipulated only through the provided functions.
+*
+* AUTHOR
+* Steve King, Intel
+*
+*********/
+
+/****s* OpenSM: MAD Wrapper/osm_ni_context_t
+* NAME
+* osm_ni_context_t
+*
+* DESCRIPTION
+* Context needed by recipient of NodeInfo attribute.
+*
+* SYNOPSIS
+*/
+typedef struct osm_ni_context {
+ ib_net64_t node_guid;
+ uint8_t port_num;
+ ib_net64_t dup_node_guid;
+ uint8_t dup_port_num;
+ unsigned dup_count;
+} osm_ni_context_t;
+/*
+* FIELDS
+* p_node
+* Pointer to the node thru which we got to this node.
+*
+* p_sw
+* Pointer to the switch object (if any) of the switch
+* thru which we got to this node.
+*
+* port_num
+* Port number on the node or switch thru which we got
+* to this node.
+*
+* SEE ALSO
+*********/
+
+/****s* OpenSM: MAD Wrapper/osm_pi_context_t
+* NAME
+* osm_pi_context_t
+*
+* DESCRIPTION
+* Context needed by recipient of PortInfo attribute.
+*
+* SYNOPSIS
+*/
+typedef struct osm_pi_context {
+ ib_net64_t node_guid;
+ ib_net64_t port_guid;
+ boolean_t set_method;
+ boolean_t light_sweep;
+ boolean_t active_transition;
+ boolean_t client_rereg;
+} osm_pi_context_t;
+/*********/
+
+/****s* OpenSM: MAD Wrapper/osm_gi_context_t
+* NAME
+* osm_gi_context_t
+*
+* DESCRIPTION
+* Context needed by recipient of GUIDInfo attribute.
+*
+* SYNOPSIS
+*/
+typedef struct osm_gi_context {
+ ib_net64_t node_guid;
+ ib_net64_t port_guid;
+ boolean_t set_method;
+ uint8_t port_num;
+} osm_gi_context_t;
+/*********/
+
+/****s* OpenSM: MAD Wrapper/osm_nd_context_t
+* NAME
+* osm_nd_context_t
+*
+* DESCRIPTION
+* Context needed by recipient of NodeDescription attribute.
+*
+* SYNOPSIS
+*/
+typedef struct osm_nd_context {
+ ib_net64_t node_guid;
+} osm_nd_context_t;
+/*********/
+
+/****s* OpenSM: MAD Wrapper/osm_si_context_t
+* NAME
+* osm_si_context_t
+*
+* DESCRIPTION
+* Context needed by recipient of SwitchInfo attribute.
+*
+* SYNOPSIS
+*/
+typedef struct osm_si_context {
+ ib_net64_t node_guid;
+ boolean_t set_method;
+ boolean_t light_sweep;
+ boolean_t lft_top_change;
+} osm_si_context_t;
+/*********/
+
+/****s* OpenSM: MAD Wrapper/osm_lft_context_t
+* NAME
+* osm_lft_context_t
+*
+* DESCRIPTION
+* Context needed by recipient of LinearForwardingTable attribute.
+*
+* SYNOPSIS
+*/
+typedef struct osm_lft_context {
+ ib_net64_t node_guid;
+ boolean_t set_method;
+} osm_lft_context_t;
+/*********/
+
+/****s* OpenSM: MAD Wrapper/osm_mft_context_t
+* NAME
+* osm_mft_context_t
+*
+* DESCRIPTION
+* Context needed by recipient of MulticastForwardingTable attribute.
+*
+* SYNOPSIS
+*/
+typedef struct osm_mft_context {
+ ib_net64_t node_guid;
+ boolean_t set_method;
+} osm_mft_context_t;
+/*********/
+
+/****s* OpenSM: MAD Wrapper/osm_smi_context_t
+* NAME
+* osm_smi_context_t
+*
+* DESCRIPTION
+* Context needed by recipient of SMInfo attribute.
+*
+* SYNOPSIS
+*/
+typedef struct osm_smi_context {
+ ib_net64_t port_guid;
+ boolean_t set_method;
+ boolean_t light_sweep;
+} osm_smi_context_t;
+/*********/
+
+/****s* OpenSM: MAD Wrapper/osm_pkey_context_t
+* NAME
+* osm_pkey_context_t
+*
+* DESCRIPTION
+* Context needed by recipient of P_Key attribute.
+*
+* SYNOPSIS
+*/
+typedef struct osm_pkey_context {
+ ib_net64_t node_guid;
+ ib_net64_t port_guid;
+ boolean_t set_method;
+} osm_pkey_context_t;
+/*********/
+
+/****s* OpenSM: MAD Wrapper/osm_slvl_context_t
+* NAME
+* osm_slvl_context_t
+*
+* DESCRIPTION
+* Context needed by recipient of PortInfo attribute.
+*
+* SYNOPSIS
+*/
+typedef struct osm_slvl_context {
+ ib_net64_t node_guid;
+ ib_net64_t port_guid;
+ boolean_t set_method;
+} osm_slvl_context_t;
+/*********/
+
+/****s* OpenSM: MAD Wrapper/osm_vla_context_t
+* NAME
+* osm_vla_context_t
+*
+* DESCRIPTION
+* Context needed by recipient of VL Arb attribute.
+*
+* SYNOPSIS
+*/
+typedef struct osm_vla_context {
+ ib_net64_t node_guid;
+ ib_net64_t port_guid;
+ boolean_t set_method;
+} osm_vla_context_t;
+/*********/
+
+/****s* OpenSM: MAD Wrapper/osm_perfmgr_context_t
+* DESCRIPTION
+* Context for Performance manager queries
+*/
+typedef struct osm_perfmgr_context {
+ uint64_t node_guid;
+ uint16_t port;
+ uint8_t mad_method; /* was this a get or a set */
+ ib_net16_t mad_attr_id;
+#ifdef ENABLE_OSM_PERF_MGR_PROFILE
+ struct timeval query_start;
+#endif
+} osm_perfmgr_context_t;
+/*********/
+
+/****s* OpenSM: MAD Wrapper/osm_cc_context_t
+* DESCRIPTION
+* Context for Congestion Control MADs
+*/
+typedef struct osm_cc_context {
+ ib_net64_t node_guid;
+ ib_net64_t port_guid;
+ uint8_t port;
+ uint8_t mad_method; /* was this a get or a set */
+ ib_net32_t attr_mod;
+} osm_cc_context_t;
+/*********/
+
+#ifndef OSM_VENDOR_INTF_OPENIB
+/****s* OpenSM: MAD Wrapper/osm_arbitrary_context_t
+* NAME
+* osm_arbitrary_context_t
+*
+* DESCRIPTION
+* Context needed by arbitrary recipient.
+*
+* SYNOPSIS
+*/
+typedef struct osm_arbitrary_context {
+ void *context1;
+ void *context2;
+} osm_arbitrary_context_t;
+/*********/
+#endif
+
+/****s* OpenSM: MAD Wrapper/osm_madw_context_t
+* NAME
+* osm_madw_context_t
+*
+* DESCRIPTION
+* Context needed by recipients of MAD responses.
+*
+* SYNOPSIS
+*/
+typedef union _osm_madw_context {
+ osm_ni_context_t ni_context;
+ osm_pi_context_t pi_context;
+ osm_gi_context_t gi_context;
+ osm_nd_context_t nd_context;
+ osm_si_context_t si_context;
+ osm_lft_context_t lft_context;
+ osm_mft_context_t mft_context;
+ osm_smi_context_t smi_context;
+ osm_slvl_context_t slvl_context;
+ osm_pkey_context_t pkey_context;
+ osm_vla_context_t vla_context;
+ osm_perfmgr_context_t perfmgr_context;
+ osm_cc_context_t cc_context;
+#ifndef OSM_VENDOR_INTF_OPENIB
+ osm_arbitrary_context_t arb_context;
+#endif
+} osm_madw_context_t;
+/*********/
+
+/****s* OpenSM: MAD Wrapper/osm_mad_addr_t
+* NAME
+* osm_mad_addr_t
+*
+* DESCRIPTION
+*
+* SYNOPSIS
+*/
+typedef struct osm_mad_addr {
+ ib_net16_t dest_lid;
+ uint8_t path_bits;
+ uint8_t static_rate;
+ union addr_type {
+ struct _smi {
+ ib_net16_t source_lid;
+ uint8_t port_num;
+ } smi;
+
+ struct _gsi {
+ ib_net32_t remote_qp;
+ ib_net32_t remote_qkey;
+ uint16_t pkey_ix;
+ uint8_t service_level;
+ boolean_t global_route;
+ ib_grh_t grh_info;
+ } gsi;
+ } addr_type;
+} osm_mad_addr_t;
+/*
+* FIELDS
+*
+* SEE ALSO
+*********/
+
+/****s* OpenSM: MAD Wrapper/osm_madw_t
+* NAME
+* osm_madw_t
+*
+* DESCRIPTION
+* Context needed for processing individual MADs
+*
+* SYNOPSIS
+*/
+typedef struct osm_madw {
+ cl_list_item_t list_item;
+ osm_bind_handle_t h_bind;
+ osm_vend_wrap_t vend_wrap;
+ osm_mad_addr_t mad_addr;
+ osm_bind_info_t bind_info;
+ osm_madw_context_t context;
+ uint32_t mad_size;
+ ib_api_status_t status;
+ cl_disp_msgid_t fail_msg;
+ boolean_t resp_expected;
+ const ib_mad_t *p_mad;
+} osm_madw_t;
+/*
+* FIELDS
+* list_item
+* List linkage for lists. MUST BE FIRST MEMBER!
+*
+* h_bind
+* Bind handle for the port on which this MAD will be sent
+* or was received.
+*
+* vend_wrap
+* Transport vendor specific context. This structure is not
+* used outside MAD transport vendor specific code.
+*
+* context
+* Union of controller specific contexts needed for this MAD.
+* This structure allows controllers to indirectly communicate
+* with each other through the dispatcher.
+*
+* mad_size
+* Size of this MAD in bytes.
+*
+* status
+* Status of completed operation on the MAD.
+* CL_SUCCESS if the operation was successful.
+*
+* fail_msg
+* Dispatcher message with which to post this MAD on failure.
+* This value is set by the originator of the MAD.
+* If an operation on this MAD fails, for example due to a timeout,
+* then the transport layer will dispose of the MAD by sending
+* it through the Dispatcher with this message type. Presumably,
+* there is a controller listening for the failure message that can
+* properly clean up.
+*
+* resp_expected
+* TRUE if a response is expected to this MAD.
+* FALSE otherwise.
+*
+* p_mad
+* Pointer to the wire MAD. The MAD itself cannot be part of the
+* wrapper, since wire MADs typically reside in special memory
+* registered with the local HCA.
+*
+* SEE ALSO
+*********/
+
+/****f* OpenSM: MAD Wrapper/osm_madw_init
+* NAME
+* osm_madw_init
+*
+* DESCRIPTION
+* Initializes a MAD Wrapper object for use.
+*
+* SYNOPSIS
+*/
+static inline void osm_madw_init(IN osm_madw_t * p_madw,
+ IN osm_bind_handle_t h_bind,
+ IN uint32_t mad_size,
+ IN const osm_mad_addr_t * p_mad_addr)
+{
+ memset(p_madw, 0, sizeof(*p_madw));
+ p_madw->h_bind = h_bind;
+ p_madw->fail_msg = CL_DISP_MSGID_NONE;
+ p_madw->mad_size = mad_size;
+ if (p_mad_addr)
+ p_madw->mad_addr = *p_mad_addr;
+ p_madw->resp_expected = FALSE;
+}
+
+/*
+* PARAMETERS
+* p_madw
+* [in] Pointer to an osm_madw_t object to initialize.
+*
+* h_bind
+* [in] Pointer to the wire MAD.
+*
+* p_mad_addr
+* [in] Pointer to the MAD address structure. This parameter may
+* be NULL for directed route MADs.
+*
+* RETURN VALUES
+* None.
+*
+* NOTES
+*
+* SEE ALSO
+*********/
+
+/****f* OpenSM: MAD Wrapper/osm_madw_get_smp_ptr
+* NAME
+* osm_madw_get_smp_ptr
+*
+* DESCRIPTION
+* Gets a pointer to the SMP in this MAD.
+*
+* SYNOPSIS
+*/
+static inline ib_smp_t *osm_madw_get_smp_ptr(IN const osm_madw_t * p_madw)
+{
+ return ((ib_smp_t *) p_madw->p_mad);
+}
+
+/*
+* PARAMETERS
+* p_madw
+* [in] Pointer to an osm_madw_t object to initialize.
+*
+* RETURN VALUES
+* Pointer to the start of the SMP MAD.
+*
+* NOTES
+*
+* SEE ALSO
+* MAD Wrapper object
+*********/
+
+/****f* OpenSM: MAD Wrapper/osm_madw_get_sa_mad_ptr
+* NAME
+* osm_madw_get_sa_mad_ptr
+*
+* DESCRIPTION
+* Gets a pointer to the SA MAD in this MAD wrapper.
+*
+* SYNOPSIS
+*/
+static inline ib_sa_mad_t *osm_madw_get_sa_mad_ptr(IN const osm_madw_t * p_madw)
+{
+ return ((ib_sa_mad_t *) p_madw->p_mad);
+}
+
+/*
+* PARAMETERS
+* p_madw
+* [in] Pointer to an osm_madw_t object.
+*
+* RETURN VALUES
+* Pointer to the start of the SA MAD.
+*
+* NOTES
+*
+* SEE ALSO
+* MAD Wrapper object
+*********/
+
+/****f* OpenSM: MAD Wrapper/osm_madw_get_perfmgt_mad_ptr
+* DESCRIPTION
+* Gets a pointer to the PerfMgt MAD in this MAD wrapper.
+*
+* SYNOPSIS
+*/
+static inline ib_perfmgt_mad_t *osm_madw_get_perfmgt_mad_ptr(IN const osm_madw_t
+ * p_madw)
+{
+ return ((ib_perfmgt_mad_t *) p_madw->p_mad);
+}
+
+/*
+* PARAMETERS
+* p_madw
+* [in] Pointer to an osm_madw_t object.
+*
+* RETURN VALUES
+* Pointer to the start of the PerfMgt MAD.
+*
+* NOTES
+*
+* SEE ALSO
+* MAD Wrapper object
+*********/
+
+/****f* OpenSM: MAD Wrapper/osm_madw_get_cc_mad_ptr
+* DESCRIPTION
+* Gets a pointer to the Congestion Control MAD in this MAD wrapper.
+*
+* SYNOPSIS
+*/
+static inline ib_cc_mad_t *osm_madw_get_cc_mad_ptr(IN const osm_madw_t
+ * p_madw)
+{
+ return ((ib_cc_mad_t *) p_madw->p_mad);
+}
+
+/*
+* PARAMETERS
+* p_madw
+* [in] Pointer to an osm_madw_t object.
+*
+* RETURN VALUES
+* Pointer to the start of the Congestion Control MAD.
+*
+* NOTES
+*
+* SEE ALSO
+* MAD Wrapper object
+*********/
+
+/****f* OpenSM: MAD Wrapper/osm_madw_get_ni_context_ptr
+* NAME
+* osm_madw_get_ni_context_ptr
+*
+* DESCRIPTION
+* Gets a pointer to the NodeInfo context in this MAD.
+*
+* SYNOPSIS
+*/
+static inline osm_ni_context_t *osm_madw_get_ni_context_ptr(IN const osm_madw_t
+ * p_madw)
+{
+ return ((osm_ni_context_t *) & p_madw->context);
+}
+
+/*
+* PARAMETERS
+* p_madw
+* [in] Pointer to an osm_madw_t object.
+*
+* RETURN VALUES
+* Pointer to the start of the context structure.
+*
+* NOTES
+*
+* SEE ALSO
+*********/
+
+/****f* OpenSM: MAD Wrapper/osm_madw_get_pi_context_ptr
+* NAME
+* osm_madw_get_pi_context_ptr
+*
+* DESCRIPTION
+* Gets a pointer to the PortInfo context in this MAD.
+*
+* SYNOPSIS
+*/
+static inline osm_pi_context_t *osm_madw_get_pi_context_ptr(IN const osm_madw_t
+ * p_madw)
+{
+ return ((osm_pi_context_t *) & p_madw->context);
+}
+
+/*
+* PARAMETERS
+* p_madw
+* [in] Pointer to an osm_madw_t object.
+*
+* RETURN VALUES
+* Pointer to the start of the context structure.
+*
+* NOTES
+*
+* SEE ALSO
+*********/
+
+/****f* OpenSM: MAD Wrapper/osm_madw_get_gi_context_ptr
+* NAME
+* osm_madw_get_gi_context_ptr
+*
+* DESCRIPTION
+* Gets a pointer to the GUIDInfo context in this MAD.
+*
+* SYNOPSIS
+*/
+static inline osm_gi_context_t *osm_madw_get_gi_context_ptr(IN const osm_madw_t
+ * p_madw)
+{
+ return ((osm_gi_context_t *) & p_madw->context);
+}
+
+/*
+* PARAMETERS
+* p_madw
+* [in] Pointer to an osm_madw_t object.
+*
+* RETURN VALUES
+* Pointer to the start of the context structure.
+*
+* NOTES
+*
+* SEE ALSO
+*********/
+
+/****f* OpenSM: MAD Wrapper/osm_madw_get_nd_context_ptr
+* NAME
+* osm_madw_get_nd_context_ptr
+*
+* DESCRIPTION
+* Gets a pointer to the NodeDescription context in this MAD.
+*
+* SYNOPSIS
+*/
+static inline osm_nd_context_t *osm_madw_get_nd_context_ptr(IN const osm_madw_t
+ * p_madw)
+{
+ return ((osm_nd_context_t *) & p_madw->context);
+}
+
+/*
+* PARAMETERS
+* p_madw
+* [in] Pointer to an osm_madw_t object.
+*
+* RETURN VALUES
+* Pointer to the start of the context structure.
+*
+* NOTES
+*
+* SEE ALSO
+*********/
+
+/****f* OpenSM: MAD Wrapper/osm_madw_get_lft_context_ptr
+* NAME
+* osm_madw_get_lft_context_ptr
+*
+* DESCRIPTION
+* Gets a pointer to the LFT context in this MAD.
+*
+* SYNOPSIS
+*/
+static inline osm_lft_context_t *osm_madw_get_lft_context_ptr(IN const
+ osm_madw_t *
+ p_madw)
+{
+ return ((osm_lft_context_t *) & p_madw->context);
+}
+
+/*
+* PARAMETERS
+* p_madw
+* [in] Pointer to an osm_madw_t object.
+*
+* RETURN VALUES
+* Pointer to the start of the context structure.
+*
+* NOTES
+*
+* SEE ALSO
+*********/
+
+/****f* OpenSM: MAD Wrapper/osm_madw_get_mft_context_ptr
+* NAME
+* osm_madw_get_mft_context_ptr
+*
+* DESCRIPTION
+* Gets a pointer to the MFT context in this MAD.
+*
+* SYNOPSIS
+*/
+static inline osm_mft_context_t *osm_madw_get_mft_context_ptr(IN const
+ osm_madw_t *
+ p_madw)
+{
+ return ((osm_mft_context_t *) & p_madw->context);
+}
+
+/*
+* PARAMETERS
+* p_madw
+* [in] Pointer to an osm_madw_t object.
+*
+* RETURN VALUES
+* Pointer to the start of the context structure.
+*
+* NOTES
+*
+* SEE ALSO
+*********/
+
+/****f* OpenSM: MAD Wrapper/osm_madw_get_si_context_ptr
+* NAME
+* osm_madw_get_si_context_ptr
+*
+* DESCRIPTION
+* Gets a pointer to the SwitchInfo context in this MAD.
+*
+* SYNOPSIS
+*/
+static inline osm_si_context_t *osm_madw_get_si_context_ptr(IN const osm_madw_t
+ * p_madw)
+{
+ return ((osm_si_context_t *) & p_madw->context);
+}
+
+/*
+* PARAMETERS
+* p_madw
+* [in] Pointer to an osm_madw_t object.
+*
+* RETURN VALUES
+* Pointer to the start of the context structure.
+*
+* NOTES
+*
+* SEE ALSO
+*********/
+
+/****f* OpenSM: MAD Wrapper/osm_madw_get_smi_context_ptr
+* NAME
+* osm_madw_get_smi_context_ptr
+*
+* DESCRIPTION
+* Gets a pointer to the SMInfo context in this MAD.
+*
+* SYNOPSIS
+*/
+static inline osm_smi_context_t *osm_madw_get_smi_context_ptr(IN const
+ osm_madw_t *
+ p_madw)
+{
+ return ((osm_smi_context_t *) & p_madw->context);
+}
+
+/*
+* PARAMETERS
+* p_madw
+* [in] Pointer to an osm_madw_t object.
+*
+* RETURN VALUES
+* Pointer to the start of the context structure.
+*
+* NOTES
+*
+* SEE ALSO
+*********/
+
+/****f* OpenSM: MAD Wrapper/osm_madw_get_pkey_context_ptr
+* NAME
+* osm_madw_get_pkey_context_ptr
+*
+* DESCRIPTION
+* Gets a pointer to the P_Key context in this MAD.
+*
+* SYNOPSIS
+*/
+static inline osm_pkey_context_t *osm_madw_get_pkey_context_ptr(IN const
+ osm_madw_t *
+ p_madw)
+{
+ return ((osm_pkey_context_t *) & p_madw->context);
+}
+
+/*
+* PARAMETERS
+* p_madw
+* [in] Pointer to an osm_madw_t object.
+*
+* RETURN VALUES
+* Pointer to the start of the context structure.
+*
+* NOTES
+*
+* SEE ALSO
+*********/
+
+/****f* OpenSM: MAD Wrapper/osm_madw_get_slvl_context_ptr
+* NAME
+* osm_madw_get_slvl_context_ptr
+*
+* DESCRIPTION
+* Gets a pointer to the PortInfo context in this MAD.
+*
+* SYNOPSIS
+*/
+static inline osm_slvl_context_t *osm_madw_get_slvl_context_ptr(IN const
+ osm_madw_t *
+ p_madw)
+{
+ return ((osm_slvl_context_t *) & p_madw->context);
+}
+
+/*
+* PARAMETERS
+* p_madw
+* [in] Pointer to an osm_madw_t object.
+*
+* RETURN VALUES
+* Pointer to the start of the context structure.
+*
+* NOTES
+*
+* SEE ALSO
+*********/
+
+/****f* OpenSM: MAD Wrapper/osm_madw_get_vla_context_ptr
+* NAME
+* osm_madw_get_vla_context_ptr
+*
+* DESCRIPTION
+* Gets a pointer to the Vl Arb context in this MAD.
+*
+* SYNOPSIS
+*/
+static inline osm_vla_context_t *osm_madw_get_vla_context_ptr(IN const
+ osm_madw_t *
+ p_madw)
+{
+ return ((osm_vla_context_t *) & p_madw->context);
+}
+
+/*
+* PARAMETERS
+* p_madw
+* [in] Pointer to an osm_madw_t object.
+*
+* RETURN VALUES
+* Pointer to the start of the context structure.
+*
+* NOTES
+*
+* SEE ALSO
+*********/
+
+#ifndef OSM_VENDOR_INTF_OPENIB
+/****f* OpenSM: MAD Wrapper/osm_madw_get_arbitrary_context_ptr
+* NAME
+* osm_madw_get_arbitrary_context_ptr
+*
+* DESCRIPTION
+* Gets a pointer to the arbitrary context in this MAD.
+*
+* SYNOPSIS
+*/
+static inline osm_arbitrary_context_t *osm_madw_get_arbitrary_context_ptr(IN
+ const
+ osm_madw_t
+ *
+ const
+ p_madw)
+{
+ return ((osm_arbitrary_context_t *) & p_madw->context);
+}
+
+/*
+* PARAMETERS
+* p_madw
+* [in] Pointer to an osm_madw_t object.
+*
+* RETURN VALUES
+* Pointer to the start of the context structure.
+*
+* NOTES
+*
+* SEE ALSO
+*********/
+#endif
+
+/****f* OpenSM: MAD Wrapper/osm_madw_get_vend_ptr
+* NAME
+* osm_madw_get_vend_ptr
+*
+* DESCRIPTION
+* Gets a pointer to the vendor specific MAD wrapper component.
+*
+* SYNOPSIS
+*/
+static inline osm_vend_wrap_t *osm_madw_get_vend_ptr(IN const osm_madw_t *
+ p_madw)
+{
+ return ((osm_vend_wrap_t *) & p_madw->vend_wrap);
+}
+
+/*
+* PARAMETERS
+* p_madw
+* [in] Pointer to an osm_madw_t object.
+*
+* RETURN VALUES
+* Gets a pointer to the vendor specific MAD wrapper component.
+*
+* NOTES
+*
+* SEE ALSO
+*********/
+
+/****f* OpenSM: MAD Wrapper/osm_madw_get_bind_handle
+* NAME
+* osm_madw_get_bind_handle
+*
+* DESCRIPTION
+* Returns the bind handle associated with this MAD.
+*
+* SYNOPSIS
+*/
+static inline osm_bind_handle_t
+osm_madw_get_bind_handle(IN const osm_madw_t * p_madw)
+{
+ return ((osm_bind_handle_t) p_madw->h_bind);
+}
+
+/*
+* PARAMETERS
+* p_madw
+* [in] Pointer to an osm_madw_t object.
+*
+* RETURN VALUES
+* Returns the bind handle associated with this MAD.
+*
+* NOTES
+*
+* SEE ALSO
+*********/
+
+/****f* OpenSM: MAD Wrapper/osm_madw_get_mad_addr_ptr
+* NAME
+* osm_madw_get_mad_addr_ptr
+*
+* DESCRIPTION
+* Returns the mad address structure associated with this MAD.
+*
+* SYNOPSIS
+*/
+static inline osm_mad_addr_t *osm_madw_get_mad_addr_ptr(IN const osm_madw_t *
+ p_madw)
+{
+ return ((osm_mad_addr_t *) & p_madw->mad_addr);
+}
+
+/*
+* PARAMETERS
+* p_madw
+* [in] Pointer to an osm_madw_t object.
+*
+* RETURN VALUES
+* Returns the mad address structure associated with this MAD.
+*
+* NOTES
+*
+* SEE ALSO
+*********/
+
+/****f* OpenSM: MAD Wrapper/osm_madw_get_mad_ptr
+* NAME
+* osm_madw_get_mad_ptr
+*
+* DESCRIPTION
+* Returns the mad address structure associated with this MAD.
+*
+* SYNOPSIS
+*/
+static inline ib_mad_t *osm_madw_get_mad_ptr(IN const osm_madw_t * p_madw)
+{
+ return ((ib_mad_t *) p_madw->p_mad);
+}
+
+/*
+* PARAMETERS
+* p_madw
+* [in] Pointer to an osm_madw_t object.
+*
+* RETURN VALUES
+* Returns the mad address structure associated with this MAD.
+*
+* NOTES
+*
+* SEE ALSO
+*********/
+
+/****f* OpenSM: MAD Wrapper/osm_madw_get_err_msg
+* NAME
+* osm_madw_get_err_msg
+*
+* DESCRIPTION
+* Returns the message with which to post this mad wrapper if
+* an error occurs during processing the mad.
+*
+* SYNOPSIS
+*/
+static inline cl_disp_msgid_t osm_madw_get_err_msg(IN const osm_madw_t * p_madw)
+{
+ return ((cl_disp_msgid_t) p_madw->fail_msg);
+}
+
+/*
+* PARAMETERS
+* p_madw
+* [in] Pointer to an osm_madw_t object.
+*
+* RETURN VALUES
+* Returns the message with which to post this mad wrapper if
+* an error occurs during processing the mad.
+*
+* NOTES
+*
+* SEE ALSO
+*********/
+
+/****f* OpenSM: MAD Wrapper/osm_madw_set_mad
+* NAME
+* osm_madw_set_mad
+*
+* DESCRIPTION
+* Associates a wire MAD with this MAD Wrapper object.
+*
+* SYNOPSIS
+*/
+static inline void osm_madw_set_mad(IN osm_madw_t * p_madw,
+ IN const ib_mad_t * p_mad)
+{
+ p_madw->p_mad = p_mad;
+}
+
+/*
+* PARAMETERS
+* p_madw
+* [in] Pointer to an osm_madw_t object.
+*
+* p_mad
+* [in] Pointer to the wire MAD to attach to this wrapper.
+*
+* RETURN VALUES
+* None.
+*
+* NOTES
+*
+* SEE ALSO
+*********/
+
+/****f* OpenSM: MAD Wrapper/osm_madw_copy_context
+* NAME
+* osm_madw_copy_context
+*
+* DESCRIPTION
+* Copies the controller context from one MAD Wrapper to another.
+*
+* SYNOPSIS
+*/
+static inline void osm_madw_copy_context(IN osm_madw_t * p_dest,
+ IN const osm_madw_t * p_src)
+{
+ p_dest->context = p_src->context;
+}
+
+/*
+* PARAMETERS
+* p_dest
+* [in] Pointer to the destination osm_madw_t object.
+*
+* p_src
+* [in] Pointer to the source osm_madw_t object.
+*
+* RETURN VALUES
+* None.
+*
+* NOTES
+*
+* SEE ALSO
+*********/
+
+END_C_DECLS
+#endif /* _OSM_MADW_H_ */
diff --git a/contrib/ofed/opensm/include/opensm/osm_mcast_mgr.h b/contrib/ofed/opensm/include/opensm/osm_mcast_mgr.h
new file mode 100644
index 0000000..291a478
--- /dev/null
+++ b/contrib/ofed/opensm/include/opensm/osm_mcast_mgr.h
@@ -0,0 +1,72 @@
+/*
+ * Copyright (c) 2004-2009 Voltaire, Inc. All rights reserved.
+ * Copyright (c) 2002-2009 Mellanox Technologies LTD. All rights reserved.
+ * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
+ * Copyright (c) 2009-2011 ZIH, TU Dresden, Federal Republic of Germany. All rights reserved.
+ * Copyright (C) 2012-2013 Tokyo Institute of Technology. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+/*
+ * Abstract:
+ * Declaration of osm_mcast_work_obj_t.
+ * Provide access to a mcast function which searches the root swicth for
+ * a spanning tree.
+ */
+
+#ifndef _OSM_MCAST_MGR_H_
+#define _OSM_MCAST_MGR_H_
+
+#ifdef __cplusplus
+# define BEGIN_C_DECLS extern "C" {
+# define END_C_DECLS }
+#else /* !__cplusplus */
+# define BEGIN_C_DECLS
+# define END_C_DECLS
+#endif /* __cplusplus */
+
+BEGIN_C_DECLS
+
+typedef struct osm_mcast_work_obj {
+ cl_list_item_t list_item;
+ osm_port_t *p_port;
+ cl_map_item_t map_item;
+} osm_mcast_work_obj_t;
+
+int osm_mcast_make_port_list_and_map(cl_qlist_t * list, cl_qmap_t * map,
+ osm_mgrp_box_t * mbox);
+
+void osm_mcast_drop_port_list(cl_qlist_t * list);
+
+osm_switch_t * osm_mcast_mgr_find_root_switch(osm_sm_t * sm, cl_qlist_t * list);
+
+END_C_DECLS
+#endif /* _OSM_MCAST_MGR_H_ */
diff --git a/contrib/ofed/opensm/include/opensm/osm_mcast_tbl.h b/contrib/ofed/opensm/include/opensm/osm_mcast_tbl.h
new file mode 100644
index 0000000..37e2c26
--- /dev/null
+++ b/contrib/ofed/opensm/include/opensm/osm_mcast_tbl.h
@@ -0,0 +1,486 @@
+/*
+ * Copyright (c) 2004-2009 Voltaire, Inc. All rights reserved.
+ * Copyright (c) 2002-2009 Mellanox Technologies LTD. All rights reserved.
+ * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
+ * Copyright (c) 2009 HNR Consulting. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+/*
+ * Abstract:
+ * Declaration of osm_mcast_tbl_t.
+ * This object represents a multicast forwarding table.
+ * This object is part of the OpenSM family of objects.
+ */
+
+#ifndef _OSM_MCAST_TBL_H_
+#define _OSM_MCAST_TBL_H_
+
+#include <iba/ib_types.h>
+#include <complib/cl_qmap.h>
+#include <opensm/osm_base.h>
+
+#ifdef __cplusplus
+# define BEGIN_C_DECLS extern "C" {
+# define END_C_DECLS }
+#else /* !__cplusplus */
+# define BEGIN_C_DECLS
+# define END_C_DECLS
+#endif /* __cplusplus */
+
+BEGIN_C_DECLS
+/****s* OpenSM: Forwarding Table/osm_mcast_tbl_t
+* NAME
+* osm_mcast_tbl_t
+*
+* DESCRIPTION
+* Multicast Forwarding Table structure.
+*
+* Callers may directly access this object.
+*
+* SYNOPSIS
+*/
+typedef struct osm_mcast_fwdbl {
+ uint8_t num_ports;
+ uint8_t max_position;
+ uint16_t max_block;
+ int16_t max_block_in_use;
+ uint16_t num_entries;
+ uint16_t max_mlid_ho;
+ uint16_t mft_depth;
+ uint16_t(*p_mask_tbl)[][IB_MCAST_POSITION_MAX + 1];
+} osm_mcast_tbl_t;
+/*
+* FIELDS
+* num_ports
+* The number of ports in the port mask. This value
+* is the same as the number of ports on the switch
+*
+* max_position
+* Maximum bit mask position for this table. This value
+* is computed from the number of ports on the switch.
+*
+* max_block
+* Maximum block number supported in the table. This value
+* is approximately the number of MLID entries divided by the
+* number of MLIDs per block
+*
+* num_entries
+* Number of entries in the table (aka number of MLIDs supported).
+*
+* max_mlid_ho
+* Maximum MLID (host order) for the currently allocated multicast
+* port mask table.
+*
+* mft_depth
+* Number of MLIDs in the currently allocated multicast port mask
+* table.
+*
+* p_mask_tbl
+* Pointer to a two dimensional array of port_masks for this switch.
+* The first dimension is MLID offset, second dimension is mask position.
+* This pointer is null for switches that do not support multicast.
+*
+* SEE ALSO
+*********/
+
+/****f* OpenSM: Forwarding Table/osm_mcast_tbl_init
+* NAME
+* osm_mcast_tbl_init
+*
+* DESCRIPTION
+* This function initializes a Multicast Forwarding Table object.
+*
+* SYNOPSIS
+*/
+void osm_mcast_tbl_init(IN osm_mcast_tbl_t * p_tbl, IN uint8_t num_ports,
+ IN uint16_t capacity);
+/*
+* PARAMETERS
+* num_ports
+* [in] Number of ports in the switch owning this table.
+*
+* capacity
+* [in] The number of MLID entries (starting at 0xC000) supported
+* by this switch.
+*
+* RETURN VALUE
+* None.
+*
+* NOTES
+*
+* SEE ALSO
+*********/
+
+/****f* OpenSM: Forwarding Table/osm_mcast_tbl_delete
+* NAME
+* osm_mcast_tbl_delete
+*
+* DESCRIPTION
+* This destroys and deallocates a Multicast Forwarding Table object.
+*
+* SYNOPSIS
+*/
+void osm_mcast_tbl_delete(IN osm_mcast_tbl_t ** pp_tbl);
+/*
+* PARAMETERS
+* pp_tbl
+* [in] Pointer a Pointer to the Multicast Forwarding Table object.
+*
+* RETURN VALUE
+* On success, returns a pointer to a new Multicast Forwarding Table object
+* of the specified size.
+* NULL otherwise.
+*
+* NOTES
+*
+* SEE ALSO
+*********/
+
+/****f* OpenSM: Forwarding Table/osm_mcast_tbl_realloc
+* NAME
+* osm_mcast_tbl_realloc
+*
+* DESCRIPTION
+* This function reallocates the multicast port mask table if necessary.
+*
+* SYNOPSIS
+*/
+int osm_mcast_tbl_realloc(IN osm_mcast_tbl_t * p_tbl, IN unsigned mlid_offset);
+/*
+* PARAMETERS
+*
+* p_tbl
+* [in] Pointer to the Multicast Forwarding Table object.
+*
+* mlid_offset
+* [in] Offset of MLID being accessed.
+*
+* RETURN VALUE
+* Returns 0 on success and non-zero value otherwise.
+*
+* NOTES
+*
+* SEE ALSO
+*/
+
+/****f* OpenSM: Forwarding Table/osm_mcast_tbl_destroy
+* NAME
+* osm_mcast_tbl_destroy
+*
+* DESCRIPTION
+* This destroys and deallocates a Multicast Forwarding Table object.
+*
+* SYNOPSIS
+*/
+void osm_mcast_tbl_destroy(IN osm_mcast_tbl_t * p_tbl);
+/*
+* PARAMETERS
+* p_tbl
+* [in] Pointer to the Multicast Forwarding Table object.
+*
+* RETURN VALUE
+* None
+*
+* NOTES
+*
+* SEE ALSO
+*********/
+
+/****f* OpenSM: Forwarding Table/osm_mcast_tbl_set
+* NAME
+* osm_mcast_tbl_set
+*
+* DESCRIPTION
+* Adds the port to the multicast group.
+*
+* SYNOPSIS
+*/
+void osm_mcast_tbl_set(IN osm_mcast_tbl_t * p_tbl, IN uint16_t mlid_ho,
+ IN uint8_t port_num);
+/*
+* PARAMETERS
+* p_tbl
+* [in] Pointer to the Multicast Forwarding Table object.
+*
+* mlid_ho
+* [in] MLID value (host order) for which to set the route.
+*
+* port_num
+* [in] Port to add to the multicast group.
+*
+* RETURN VALUE
+* None.
+*
+* NOTES
+*
+* SEE ALSO
+*********/
+
+/****f* OpenSM: Forwarding Table/osm_mcast_tbl_clear_mlid
+* NAME
+* osm_mcast_tbl_clear_mlid
+*
+* DESCRIPTION
+* Removes all multicast paths for the specified MLID.
+*
+* SYNOPSIS
+*/
+void osm_mcast_tbl_clear_mlid(IN osm_mcast_tbl_t * p_tbl, IN uint16_t mlid_ho);
+/*
+* PARAMETERS
+* p_tbl
+* [in] Pointer to the Multicast Forwarding Table object.
+*
+* mlid_ho
+* [in] MLID value (host order) for which to clear.
+*
+* RETURN VALUE
+* None.
+*
+* NOTES
+*
+* SEE ALSO
+*********/
+
+/****f* OpenSM: Forwarding Table/osm_mcast_tbl_is_port
+* NAME
+* osm_mcast_tbl_is_port
+*
+* DESCRIPTION
+* Returns TRUE if the port is in the multicast group.
+*
+* SYNOPSIS
+*/
+boolean_t osm_mcast_tbl_is_port(IN const osm_mcast_tbl_t * p_tbl,
+ IN uint16_t mlid_ho, IN uint8_t port_num);
+/*
+* PARAMETERS
+* p_tbl
+* [in] Pointer to the Multicast Forwarding Table object.
+*
+* mlid_ho
+* [in] MLID value (host order).
+*
+* port_num
+* [in] Port number on the switch
+*
+* RETURN VALUE
+* Returns the port that routes the specified LID.
+*
+* NOTES
+*
+* SEE ALSO
+*********/
+
+/****f* OpenSM: Forwarding Table/osm_mcast_tbl_is_any_port
+* NAME
+* osm_mcast_tbl_is_any_port
+*
+* DESCRIPTION
+* Returns TRUE if any port is in the multicast group.
+*
+* SYNOPSIS
+*/
+boolean_t osm_mcast_tbl_is_any_port(IN const osm_mcast_tbl_t * p_tbl,
+ IN uint16_t mlid_ho);
+/*
+* PARAMETERS
+* p_tbl
+* [in] Pointer to the Multicast Forwarding Table object.
+*
+* mlid_ho
+* [in] MLID value (host order).
+*
+* RETURN VALUE
+* Returns TRUE if any port is in the multicast group.
+*
+* NOTES
+*
+* SEE ALSO
+*********/
+
+/****f* OpenSM: Forwarding Table/osm_mcast_tbl_set_block
+* NAME
+* osm_mcast_tbl_set_block
+*
+* DESCRIPTION
+* Copies the specified block into the Multicast Forwarding Table.
+*
+* SYNOPSIS
+*/
+ib_api_status_t osm_mcast_tbl_set_block(IN osm_mcast_tbl_t * p_tbl,
+ IN const ib_net16_t * p_block,
+ IN int16_t block_num,
+ IN uint8_t position);
+/*
+* PARAMETERS
+* p_tbl
+* [in] Pointer to the Multicast Forwarding Table object.
+*
+* p_block
+* [in] Pointer to the Forwarding Table block.
+*
+* block_num
+* [in] Block number of this block.
+*
+* RETURN VALUE
+* None.
+*
+* NOTES
+*
+* SEE ALSO
+*********/
+
+/****f* OpenSM: Forwarding Table/osm_mcast_get_tbl_block
+* NAME
+* osm_mcast_get_tbl_block
+*
+* DESCRIPTION
+* Retrieve a multicast forwarding table block.
+*
+* SYNOPSIS
+*/
+boolean_t osm_mcast_tbl_get_block(IN osm_mcast_tbl_t * p_tbl,
+ IN int16_t block_num, IN uint8_t position,
+ OUT ib_net16_t * p_block);
+/*
+* PARAMETERS
+* p_tbl
+* [in] Pointer to an osm_mcast_tbl_t object.
+*
+* p_block
+* [in] Pointer to the Forwarding Table block.
+*
+* block_num
+* [in] Block number of this block.
+*
+* p_block
+* [out] Pointer to the 32 entry array to store the
+* forwarding table clock specified by block_id.
+*
+* RETURN VALUES
+* Returns true if there are more blocks necessary to
+* configure all the MLIDs reachable from this switch.
+* FALSE otherwise.
+*
+* NOTES
+*
+* SEE ALSO
+*********/
+
+/****f* OpenSM: Forwarding Table/osm_mcast_tbl_get_max_block
+* NAME
+* osm_mcast_tbl_get_max_block
+*
+* DESCRIPTION
+* Returns the maximum block ID in this table.
+*
+* SYNOPSIS
+*/
+static inline uint16_t osm_mcast_tbl_get_max_block(IN osm_mcast_tbl_t * p_tbl)
+{
+ return p_tbl->max_block;
+}
+
+/*
+* PARAMETERS
+* p_tbl
+* [in] Pointer to an osm_mcast_tbl_t object.
+*
+* RETURN VALUES
+* Returns the maximum block ID in this table.
+*
+* NOTES
+*
+* SEE ALSO
+*********/
+
+/****f* OpenSM: Forwarding Table/osm_mcast_tbl_get_max_block_in_use
+* NAME
+* osm_mcast_tbl_get_max_block_in_use
+*
+* DESCRIPTION
+* Returns the maximum block ID in use in this table.
+* A value of -1 indicates no blocks are in use.
+*
+* SYNOPSIS
+*/
+static inline int16_t
+osm_mcast_tbl_get_max_block_in_use(IN osm_mcast_tbl_t * p_tbl)
+{
+ return (p_tbl->max_block_in_use);
+}
+
+/*
+* PARAMETERS
+* p_tbl
+* [in] Pointer to an osm_mcast_tbl_t object.
+*
+* RETURN VALUES
+* Returns the maximum block ID in use in this table.
+* A value of -1 indicates no blocks are in use.
+*
+* NOTES
+*
+* SEE ALSO
+*********/
+
+/****f* OpenSM: Forwarding Table/osm_mcast_tbl_get_max_position
+* NAME
+* osm_mcast_tbl_get_max_position
+*
+* DESCRIPTION
+* Returns the maximum position in this table.
+*
+* SYNOPSIS
+*/
+static inline uint8_t
+osm_mcast_tbl_get_max_position(IN osm_mcast_tbl_t * p_tbl)
+{
+ return (p_tbl->max_position);
+}
+
+/*
+* PARAMETERS
+* p_tbl
+* [in] Pointer to an osm_mcast_tbl_t object.
+*
+* RETURN VALUES
+* Returns the maximum position in this table.
+*
+* NOTES
+*
+* SEE ALSO
+*********/
+
+END_C_DECLS
+#endif /* _OSM_MCAST_TBL_H_ */
diff --git a/contrib/ofed/opensm/include/opensm/osm_mcm_port.h b/contrib/ofed/opensm/include/opensm/osm_mcm_port.h
new file mode 100644
index 0000000..ae0f44f
--- /dev/null
+++ b/contrib/ofed/opensm/include/opensm/osm_mcm_port.h
@@ -0,0 +1,259 @@
+/*
+ * Copyright (c) 2004-2009 Voltaire, Inc. All rights reserved.
+ * Copyright (c) 2002-2012 Mellanox Technologies LTD. All rights reserved.
+ * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+/*
+ * Abstract:
+ * Declaration of osm_mcm_port_t.
+ * This object represents the membership of a port in a multicast group.
+ * This object is part of the OpenSM family of objects.
+ */
+
+#ifndef _OSM_MCM_PORT_H_
+#define _OSM_MCM_PORT_H_
+
+#include <iba/ib_types.h>
+#include <complib/cl_qmap.h>
+#include <opensm/osm_base.h>
+#include <opensm/osm_port.h>
+
+#ifdef __cplusplus
+# define BEGIN_C_DECLS extern "C" {
+# define END_C_DECLS }
+#else /* !__cplusplus */
+# define BEGIN_C_DECLS
+# define END_C_DECLS
+#endif /* __cplusplus */
+
+BEGIN_C_DECLS
+
+struct osm_mgrp;
+
+/****s* OpenSM: MCM Port Object/osm_mcm_port_t
+* NAME
+* osm_mcm_port_t
+*
+* DESCRIPTION
+* This object represents a particular port as a member of a
+* multicast group.
+*
+* This object should be treated as opaque and should
+* be manipulated only through the provided functions.
+*
+* SYNOPSIS
+*/
+typedef struct osm_mcm_port {
+ cl_map_item_t map_item;
+ cl_list_item_t list_item;
+ osm_port_t *port;
+ struct osm_mgrp *mgrp;
+} osm_mcm_port_t;
+/*
+* FIELDS
+* map_item
+* Map Item for qmap linkage. Must be first element!!
+*
+* list_item
+* Linkage structure for cl_qlist.
+*
+* port
+* Reference to the parent port
+*
+* mgrp
+* The pointer to multicast group where this port is member of
+*
+* SEE ALSO
+* MCM Port Object
+*********/
+
+/****f* OpenSM: MCM Port Object/osm_mcm_port_new
+* NAME
+* osm_mcm_port_new
+*
+* DESCRIPTION
+* The osm_mcm_port_new function allocates and initializes a
+* MCM Port Object for use.
+*
+* SYNOPSIS
+*/
+osm_mcm_port_t *osm_mcm_port_new(IN osm_port_t * port, IN struct osm_mgrp *mgrp);
+/*
+* PARAMETERS
+* port
+* [in] Pointer to the port object
+*
+* mgrp
+* [in] Pointer to multicast group where this port is joined
+*
+* RETURN VALUES
+* Pointer to the allocated and initialized MCM Port object.
+*
+* NOTES
+*
+* SEE ALSO
+* MCM Port Object, osm_mcm_port_delete,
+*********/
+
+/****f* OpenSM: MCM Port Object/osm_mcm_port_delete
+* NAME
+* osm_mcm_port_delete
+*
+* DESCRIPTION
+* The osm_mcm_port_delete function destroys and dellallocates an
+* MCM Port Object, releasing all resources.
+*
+* SYNOPSIS
+*/
+void osm_mcm_port_delete(IN osm_mcm_port_t * p_mcm);
+/*
+* PARAMETERS
+* p_mcm
+* [in] Pointer to a MCM Port Object to delete.
+*
+* RETURN VALUE
+* This function does not return a value.
+*
+* NOTES
+*
+* SEE ALSO
+* MCM Port Object, osm_mcm_port_new
+*********/
+
+/****s* OpenSM: MCM Port Object/osm_mcm_alias_guid_t
+* NAME
+* osm_mcm_alias_guid_t
+*
+* DESCRIPTION
+* This object represents an alias guid for a mcm port.
+*
+* The osm_mcm_alias_guid_t object should be treated as opaque and should
+* be manipulated only through the provided functions.
+*
+* SYNOPSIS
+*/
+typedef struct osm_mcm_alias_guid {
+ cl_map_item_t map_item;
+ ib_net64_t alias_guid;
+ osm_mcm_port_t *p_base_mcm_port;
+ ib_gid_t port_gid;
+ uint8_t scope_state;
+ boolean_t proxy_join;
+} osm_mcm_alias_guid_t;
+/*
+* FIELDS
+* map_item
+* Linkage structure for cl_qmap. MUST BE FIRST MEMBER!
+*
+* alias_guid
+* Alias GUID for port obtained from SM GUIDInfo attribute
+*
+* p_base_mcm_port
+* Pointer to osm_mcm_port_t for base port GUID
+*
+* port_gid
+* GID of the member port
+*
+* scope_state
+*
+* proxy_join
+* If FALSE - Join was performed by the endport identified
+* by PortGID. If TRUE - Join was performed on behalf of
+* the endport identified by PortGID by another port within
+* the same partition.
+*
+* SEE ALSO
+* MCM Port, Physical Port, Physical Port Table
+*/
+
+/****f* OpenSM: MCM Port Object/osm_mcm_alias_guid_new
+* NAME
+* osm_mcm_alias_guid_new
+*
+* DESCRIPTION
+* This function allocates and initializes an mcm alias guid object.
+*
+* SYNOPSIS
+*/
+osm_mcm_alias_guid_t *osm_mcm_alias_guid_new(IN osm_mcm_port_t *p_base_mcm_port,
+ IN ib_member_rec_t *mcmr,
+ IN boolean_t proxy);
+/*
+* PARAMETERS
+* p_base_mcm_port
+* [in] Pointer to the mcm port for this base GUID
+*
+* mcmr
+* [in] Pointer to MCMember record of the join request
+*
+* proxy
+* [in] proxy_join state analyzed from the request
+*
+* RETURN VALUE
+* Pointer to the initialized mcm alias guid object.
+*
+* NOTES
+* Allows calling other mcm alias guid methods.
+*
+* SEE ALSO
+* MCM Port Object
+*********/
+
+/****f* OpenSM: MCM Port Object/osm_mcm_alias_guid_delete
+* NAME
+* osm_mcm_alias_guid_delete
+*
+* DESCRIPTION
+* This function destroys and deallocates an mcm alias guid object.
+*
+* SYNOPSIS
+*/
+void osm_mcm_alias_guid_delete(IN OUT osm_mcm_alias_guid_t ** pp_mcm_alias_guid);
+/*
+* PARAMETERS
+* pp_mcm_alias_guid
+* [in][out] Pointer to a pointer to an mcm alias guid object to
+* delete. On return, this pointer is NULL.
+*
+* RETURN VALUE
+* This function does not return a value.
+*
+* NOTES
+* Performs any necessary cleanup of the specified mcm alias guid object.
+*
+* SEE ALSO
+* MCM Port Object
+*********/
+
+END_C_DECLS
+#endif /* _OSM_MCM_PORT_H_ */
diff --git a/contrib/ofed/opensm/include/opensm/osm_mesh.h b/contrib/ofed/opensm/include/opensm/osm_mesh.h
new file mode 100644
index 0000000..b9e85bb
--- /dev/null
+++ b/contrib/ofed/opensm/include/opensm/osm_mesh.h
@@ -0,0 +1,77 @@
+/*
+ * Copyright (c) 2008 Voltaire, Inc. All rights reserved.
+ * Copyright (c) 2008,2009 System Fabric Works, Inc. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+/*
+ * Abstract:
+ * Declarations for mesh analysis
+ */
+
+#ifndef OSM_MESH_H
+#define OSM_MESH_H
+
+struct _lash;
+struct _switch;
+
+/*
+ * per switch to switch link info
+ */
+typedef struct _link {
+ int switch_id;
+ int link_id;
+ int next_port;
+ int num_ports;
+ int ports[0];
+} link_t;
+
+/*
+ * per switch node mesh info
+ */
+typedef struct _mesh_node {
+ int *axes; /* used to hold and reorder assigned axes */
+ int *coord; /* mesh coordinates of switch */
+ int **matrix; /* distances between adjacant switches */
+ int *poly; /* characteristic polynomial of matrix */
+ /* used as an invariant classification */
+ int dimension; /* apparent dimension of mesh around node */
+ int temp; /* temporary holder for distance info */
+ int type; /* index of node type in mesh_info array */
+ unsigned int num_links; /* number of 'links' to adjacent switches */
+ link_t *links[0]; /* per link information */
+} mesh_node_t;
+
+void osm_mesh_node_delete(struct _lash *p_lash, struct _switch *sw);
+int osm_mesh_node_create(struct _lash *p_lash, struct _switch *sw);
+int osm_do_mesh_analysis(struct _lash *p_lash);
+
+#endif
diff --git a/contrib/ofed/opensm/include/opensm/osm_msgdef.h b/contrib/ofed/opensm/include/opensm/osm_msgdef.h
new file mode 100644
index 0000000..b0d92e0
--- /dev/null
+++ b/contrib/ofed/opensm/include/opensm/osm_msgdef.h
@@ -0,0 +1,170 @@
+/*
+ * Copyright (c) 2004-2006 Voltaire, Inc. All rights reserved.
+ * Copyright (c) 2002-2011 Mellanox Technologies LTD. All rights reserved.
+ * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+/*
+ * Abstract:
+ * Declaration of Dispatcher message values.
+ */
+
+#ifndef _OSM_MSGDEF_H_
+#define _OSM_MSGDEF_H_
+
+#ifdef __cplusplus
+# define BEGIN_C_DECLS extern "C" {
+# define END_C_DECLS }
+#else /* !__cplusplus */
+# define BEGIN_C_DECLS
+# define END_C_DECLS
+#endif /* __cplusplus */
+
+BEGIN_C_DECLS
+/****h* OpenSM/Dispatcher Messages
+* NAME
+* Dispatcher Messages
+*
+* DESCRIPTION
+* These constants define the messages sent between OpenSM controllers
+* attached to the Dispatcher.
+*
+* Each message description contains the following information:
+* Sent by: which controller(s) send this message
+* Received by: which controller receives this message
+* Delivery notice: Indicates if the sender requires confirmation
+* that the message has been delivered. Typically a "yes" here
+* means that some resources associated with sending the
+* message must be freed.
+*
+* AUTHOR
+* Steve King, Intel
+*
+*********/
+/****s* OpenSM: Dispatcher Messages/OSM_MSG_MAD_NODE_INFO
+* NAME
+* OSM_MSG_MAD_NODE_INFO
+*
+* DESCRIPTION
+* Message for received NodeInfo MADs.
+*
+* NOTES
+* Sent by: osm_mad_ctrl_t
+* Received by: osm_ni_rcv_ctrl_t
+* Delivery notice: yes
+*
+*
+***********/
+/****s* OpenSM: Dispatcher Messages/OSM_MSG_MAD_PORT_INFO
+* NAME
+* OSM_MSG_MAD_PORT_INFO
+*
+* DESCRIPTION
+* Message for received PortInfo MADs.
+*
+* NOTES
+* Sent by: osm_mad_ctrl_t
+* Received by: osm_pi_rcv_ctrl_t
+* Delivery notice: yes
+*
+*
+***********/
+/****s* OpenSM: Dispatcher Messages/OSM_MSG_MAD_SWITCH_INFO
+* NAME
+* OSM_MSG_MAD_SWITCH_INFO
+*
+* DESCRIPTION
+* Message for received SwitchInfo MADs.
+*
+* NOTES
+* Sent by: osm_mad_ctrl_t
+* Received by: osm_si_rcv_ctrl_t
+* Delivery notice: yes
+*
+***********/
+/****s* OpenSM: Dispatcher Messages/OSM_MSG_MAD_NODE_DESC
+* NAME
+* OSM_MSG_MAD_NODE_DESC
+*
+* DESCRIPTION
+* Message for received NodeDescription MADs.
+*
+* NOTES
+* Sent by: osm_mad_ctrl_t
+* Received by: osm_nd_rcv_ctrl_t
+* Delivery notice: yes
+*
+* SOURCE
+***********/
+enum {
+ OSM_MSG_NONE = 0,
+ OSM_MSG_MAD_NODE_INFO,
+ OSM_MSG_MAD_PORT_INFO,
+ OSM_MSG_MAD_SWITCH_INFO,
+ OSM_MSG_MAD_GUID_INFO,
+ OSM_MSG_MAD_NODE_DESC,
+ OSM_MSG_MAD_NODE_RECORD,
+ OSM_MSG_MAD_PORTINFO_RECORD,
+ OSM_MSG_MAD_SERVICE_RECORD,
+ OSM_MSG_MAD_PATH_RECORD,
+ OSM_MSG_MAD_MCMEMBER_RECORD,
+ OSM_MSG_MAD_LINK_RECORD,
+ OSM_MSG_MAD_SMINFO_RECORD,
+ OSM_MSG_MAD_CLASS_PORT_INFO,
+ OSM_MSG_MAD_INFORM_INFO,
+ OSM_MSG_MAD_LFT_RECORD,
+ OSM_MSG_MAD_LFT,
+ OSM_MSG_MAD_SM_INFO,
+ OSM_MSG_MAD_NOTICE,
+ OSM_MSG_LIGHT_SWEEP_FAIL,
+ OSM_MSG_MAD_MFT,
+ OSM_MSG_MAD_PKEY_TBL_RECORD,
+ OSM_MSG_MAD_VL_ARB_RECORD,
+ OSM_MSG_MAD_SLVL_TBL_RECORD,
+ OSM_MSG_MAD_PKEY,
+ OSM_MSG_MAD_VL_ARB,
+ OSM_MSG_MAD_SLVL,
+ OSM_MSG_MAD_GUIDINFO_RECORD,
+ OSM_MSG_MAD_INFORM_INFO_RECORD,
+ OSM_MSG_MAD_SWITCH_INFO_RECORD,
+ OSM_MSG_MAD_MFT_RECORD,
+#if defined (VENDOR_RMPP_SUPPORT) && defined (DUAL_SIDED_RMPP)
+ OSM_MSG_MAD_MULTIPATH_RECORD,
+#endif
+ OSM_MSG_MAD_PORT_COUNTERS,
+ OSM_MSG_MAD_MLNX_EXT_PORT_INFO,
+ OSM_MSG_MAD_CC,
+ OSM_MSG_MAX
+};
+
+END_C_DECLS
+#endif /* _OSM_MSGDEF_H_ */
diff --git a/contrib/ofed/opensm/include/opensm/osm_mtree.h b/contrib/ofed/opensm/include/opensm/osm_mtree.h
new file mode 100644
index 0000000..32f5179
--- /dev/null
+++ b/contrib/ofed/opensm/include/opensm/osm_mtree.h
@@ -0,0 +1,274 @@
+/*
+ * Copyright (c) 2004-2009 Voltaire, Inc. All rights reserved.
+ * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved.
+ * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+/*
+ * Abstract:
+ * Declaration of osm_mtree_t.
+ * This object represents multicast spanning tree.
+ * This object is part of the OpenSM family of objects.
+ */
+
+#ifndef _OSM_MTREE_H_
+#define _OSM_MTREE_H_
+
+#include <iba/ib_types.h>
+#include <complib/cl_qmap.h>
+#include <opensm/osm_base.h>
+#include <opensm/osm_switch.h>
+
+#ifdef __cplusplus
+# define BEGIN_C_DECLS extern "C" {
+# define END_C_DECLS }
+#else /* !__cplusplus */
+# define BEGIN_C_DECLS
+# define END_C_DECLS
+#endif /* __cplusplus */
+
+BEGIN_C_DECLS
+#define OSM_MTREE_LEAF ((void*)-1)
+/****h* OpenSM/Multicast Tree
+* NAME
+* Multicast Tree
+*
+* DESCRIPTION
+* The Multicast Tree object encapsulates the information needed by the
+* OpenSM to manage multicast fabric routes. It is a tree structure
+* in which each node in the tree represents a switch, and may have a
+* varying number of children.
+*
+* Multicast trees do not contain loops.
+*
+* The Multicast Tree is not thread safe, thus callers must provide
+* serialization.
+*
+* This object should be treated as opaque and should be
+* manipulated only through the provided functions.
+*
+* AUTHOR
+* Steve King, Intel
+*
+*********/
+/****s* OpenSM: Multicast Tree/osm_mtree_node_t
+* NAME
+* osm_mtree_node_t
+*
+* DESCRIPTION
+* The MTree Node object encapsulates the information needed by the
+* OpenSM for a particular switch in the multicast tree.
+*
+* The MTree Node object is not thread safe, thus callers must provide
+* serialization.
+*
+* This object should be treated as opaque and should be
+* manipulated only through the provided functions.
+*
+* SYNOPSIS
+*/
+typedef struct osm_mtree_node {
+ cl_map_item_t map_item;
+ const osm_switch_t *p_sw;
+ uint8_t max_children;
+ struct osm_mtree_node *p_up;
+ struct osm_mtree_node *child_array[1];
+} osm_mtree_node_t;
+/*
+* FIELDS
+* map_item
+* Linkage for quick map. MUST BE FIRST ELEMENT!!!
+*
+* p_sw
+* Pointer to the switch represented by this tree node.
+*
+* max_children
+* Maximum number of child nodes of this node. Equal to the
+* the number of ports on the switch if the switch supports
+* multicast. Equal to 1 (default route) if the switch does
+* not support multicast.
+*
+* p_up
+* Pointer to the parent of this node. If this pointer is
+* NULL, the node is at the root of the tree.
+*
+* child_array
+* Array (indexed by port number) of pointers to the
+* child osm_mtree_node_t objects of this tree node, if any.
+*
+* SEE ALSO
+*********/
+
+/****f* OpenSM: Multicast Tree/osm_mtree_node_new
+* NAME
+* osm_mtree_node_new
+*
+* DESCRIPTION
+* Returns an initialized a Multicast Tree object for use.
+*
+* SYNOPSIS
+*/
+osm_mtree_node_t *osm_mtree_node_new(IN const osm_switch_t * p_sw);
+/*
+* PARAMETERS
+* p_sw
+* [in] Pointer to the switch represented by this node.
+*
+* RETURN VALUES
+* Pointer to an initialized tree node.
+*
+* NOTES
+*
+* SEE ALSO
+*********/
+
+/****f* OpenSM: Multicast Tree/osm_mtree_destroy
+* NAME
+* osm_mtree_destroy
+*
+* DESCRIPTION
+* Destroys a Multicast Tree object given by the p_mtn
+*
+* SYNOPSIS
+*/
+void osm_mtree_destroy(IN osm_mtree_node_t * p_mtn);
+/*
+* PARAMETERS
+* p_mtn
+* [in] Pointer to an osm_mtree_node_t object to destroy.
+*
+* RETURN VALUES
+* None.
+*
+* NOTES
+*
+* SEE ALSO
+*********/
+
+/****f* OpenSM: Multicast Tree/osm_mtree_node_get_max_children
+* NAME
+* osm_mtree_node_get_max_children
+*
+* DESCRIPTION
+* Returns the number maximum number of children of this node.
+* The return value is 1 greater than the highest valid port
+* number on the switch.
+*
+*
+* SYNOPSIS
+*/
+static inline uint8_t
+osm_mtree_node_get_max_children(IN const osm_mtree_node_t * p_mtn)
+{
+ return (p_mtn->max_children);
+}
+/*
+* PARAMETERS
+* p_mtn
+* [in] Pointer to the multicast tree node.
+*
+* RETURN VALUES
+* See description.
+*
+* NOTES
+*
+* SEE ALSO
+*********/
+
+/****f* OpenSM: Multicast Tree/osm_mtree_node_get_child
+* NAME
+* osm_mtree_node_get_child
+*
+* DESCRIPTION
+* Returns the specified child node of this node.
+*
+* SYNOPSIS
+*/
+static inline osm_mtree_node_t *osm_mtree_node_get_child(IN const
+ osm_mtree_node_t *
+ p_mtn,
+ IN uint8_t child)
+{
+ CL_ASSERT(child < p_mtn->max_children);
+ return (p_mtn->child_array[child]);
+}
+/*
+* PARAMETERS
+* p_mtn
+* [in] Pointer to the multicast tree node.
+*
+* child
+* [in] Index of the child to retrieve.
+*
+* RETURN VALUES
+* Returns the specified child node of this node.
+*
+*
+* NOTES
+*
+* SEE ALSO
+*********/
+
+/****f* OpenSM: Multicast Tree/osm_mtree_node_get_switch_ptr
+* NAME
+* osm_mtree_node_get_switch_ptr
+*
+* DESCRIPTION
+* Returns a pointer to the switch object represented by this tree node.
+*
+* SYNOPSIS
+*/
+static inline const osm_switch_t *osm_mtree_node_get_switch_ptr(IN const
+ osm_mtree_node_t *
+ p_mtn)
+{
+ return p_mtn->p_sw;
+}
+/*
+* PARAMETERS
+* p_mtn
+* [in] Pointer to the multicast tree node.
+*
+* child
+* [in] Index of the child to retrieve.
+*
+* RETURN VALUES
+* Returns a pointer to the switch object represented by this tree node.
+*
+*
+* NOTES
+*
+* SEE ALSO
+*********/
+
+END_C_DECLS
+#endif /* _OSM_MTREE_H_ */
diff --git a/contrib/ofed/opensm/include/opensm/osm_multicast.h b/contrib/ofed/opensm/include/opensm/osm_multicast.h
new file mode 100644
index 0000000..e192a72
--- /dev/null
+++ b/contrib/ofed/opensm/include/opensm/osm_multicast.h
@@ -0,0 +1,458 @@
+/*
+ * Copyright (c) 2004-2009 Voltaire, Inc. All rights reserved.
+ * Copyright (c) 2002-2012 Mellanox Technologies LTD. All rights reserved.
+ * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
+ * Copyright (c) 2013 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+/*
+ * Abstract:
+ * Declaration of osm_mgrp_t.
+ * This object represents an IBA Multicast Group.
+ * This object is part of the OpenSM family of objects.
+ */
+
+#ifndef _OSM_MULTICAST_H_
+#define _OSM_MULTICAST_H_
+
+#include <iba/ib_types.h>
+#include <complib/cl_qmap.h>
+#include <complib/cl_fleximap.h>
+#include <complib/cl_qlist.h>
+#include <complib/cl_spinlock.h>
+#include <opensm/osm_base.h>
+#include <opensm/osm_mtree.h>
+#include <opensm/osm_mcm_port.h>
+#include <opensm/osm_subnet.h>
+#include <opensm/osm_log.h>
+#include <opensm/osm_sm.h>
+
+#ifdef __cplusplus
+# define BEGIN_C_DECLS extern "C" {
+# define END_C_DECLS }
+#else /* !__cplusplus */
+# define BEGIN_C_DECLS
+# define END_C_DECLS
+#endif /* __cplusplus */
+
+BEGIN_C_DECLS
+/****h* OpenSM/Multicast Group
+* NAME
+* Multicast Group
+*
+* DESCRIPTION
+* The Multicast Group encapsulates the information needed by the
+* OpenSM to manage Multicast Groups. The OpenSM allocates one
+* Multicast Group object per Multicast Group in the IBA subnet.
+*
+* The Multicast Group is not thread safe, thus callers must provide
+* serialization.
+*
+* This object should be treated as opaque and should be
+* manipulated only through the provided functions.
+*
+* AUTHOR
+* Steve King, Intel
+*
+*********/
+
+/****s* OpenSM: Multicast Group/osm_mgrp_t
+* NAME
+* osm_mgrp_t
+*
+* DESCRIPTION
+* Multicast Group structure.
+*
+* The osm_mgrp_t object should be treated as opaque and should
+* be manipulated only through the provided functions.
+*
+* SYNOPSIS
+*/
+typedef struct osm_mgrp {
+ cl_fmap_item_t map_item;
+ cl_list_item_t list_item;
+ ib_net16_t mlid;
+ cl_qmap_t mcm_port_tbl;
+ cl_qmap_t mcm_alias_port_tbl;
+ ib_member_rec_t mcmember_rec;
+ boolean_t well_known;
+ unsigned full_members;
+} osm_mgrp_t;
+/*
+* FIELDS
+* map_item
+* Map Item for fmap linkage. Must be first element!!
+*
+* list_item
+* List item for linkage in osm_mgrp_box's mgrp_list qlist.
+*
+* mlid
+* The network ordered LID of this Multicast Group (must be
+* >= 0xC000).
+*
+* mcm_port_tbl
+* Table (sorted by port GUID) of osm_mcm_port_t objects
+* representing the member ports of this multicast group.
+*
+* mcm_alias_port_tbl
+* Table (sorted by port alias GUID) of osm_mcm_port_t
+* objects representing the member ports of this multicast
+* group.
+*
+* mcmember_rec
+* Holds the parameters of the Multicast Group.
+*
+* well_known
+* Indicates that this is the wellknown multicast group which
+* is created during the initialization of SM/SA and will be
+* present even if there are no ports for this group
+*
+* SEE ALSO
+*********/
+
+/****s* OpenSM: Multicast Group/osm_mgrp_box_t
+* NAME
+* osm_mgrp_box_t
+*
+* DESCRIPTION
+* Multicast structure which holds all multicast groups with same MLID.
+*
+* SYNOPSIS
+*/
+typedef struct osm_mgrp_box {
+ uint16_t mlid;
+ cl_qlist_t mgrp_list;
+ osm_mtree_node_t *root;
+} osm_mgrp_box_t;
+/*
+* FIELDS
+* mlid
+* The host ordered LID of this Multicast Group (must be
+* >= 0xC000).
+*
+* p_root
+* Pointer to the root "tree node" in the single spanning tree
+* for this multicast group. The nodes of the tree represent
+* switches. Member ports are not represented in the tree.
+*
+* mgrp_list
+* List of multicast groups (mpgr object) having same MLID value.
+*
+* SEE ALSO
+*********/
+
+/****f* OpenSM: Multicast Group/osm_mgrp_new
+* NAME
+* osm_mgrp_new
+*
+* DESCRIPTION
+* Allocates and initializes a Multicast Group for use.
+*
+* SYNOPSIS
+*/
+osm_mgrp_t *osm_mgrp_new(IN osm_subn_t * subn, IN ib_net16_t mlid,
+ IN ib_member_rec_t * mcmr);
+/*
+* PARAMETERS
+* subn
+* [in] Pointer to osm_subn_t object.
+*
+* mlid
+* [in] Multicast LID for this multicast group.
+*
+* mcmr
+* [in] MCMember Record for this multicast group.
+*
+* RETURN VALUES
+* IB_SUCCESS if initialization was successful.
+*
+* NOTES
+* Allows calling other Multicast Group methods.
+*
+* SEE ALSO
+* Multicast Group, osm_mgrp_delete
+*********/
+
+/*
+ * Need a forward declaration to work around include loop:
+ * osm_sm.h <- osm_multicast.h
+ */
+struct osm_sm;
+
+/****f* OpenSM: Multicast Tree/osm_purge_mtree
+* NAME
+* osm_purge_mtree
+*
+* DESCRIPTION
+* Frees all the nodes in a multicast spanning tree
+*
+* SYNOPSIS
+*/
+void osm_purge_mtree(IN struct osm_sm * sm, IN osm_mgrp_box_t * mgb);
+/*
+* PARAMETERS
+* sm
+* [in] Pointer to osm_sm_t object.
+* mgb
+* [in] Pointer to an osm_mgrp_box_t object.
+*
+* RETURN VALUES
+* None.
+*
+*
+* NOTES
+*
+* SEE ALSO
+*********/
+
+/****f* OpenSM: Multicast Group/osm_mgrp_is_guid
+* NAME
+* osm_mgrp_is_guid
+*
+* DESCRIPTION
+* Indicates if the specified port GUID is a member of the Multicast Group.
+*
+* SYNOPSIS
+*/
+static inline boolean_t osm_mgrp_is_guid(IN const osm_mgrp_t * p_mgrp,
+ IN ib_net64_t port_guid)
+{
+ return (cl_qmap_get(&p_mgrp->mcm_port_tbl, port_guid) !=
+ cl_qmap_end(&p_mgrp->mcm_port_tbl));
+}
+
+/*
+* PARAMETERS
+* p_mgrp
+* [in] Pointer to an osm_mgrp_t object.
+*
+* port_guid
+* [in] Port GUID.
+*
+* RETURN VALUES
+* TRUE if the port GUID is a member of the group,
+* FALSE otherwise.
+*
+* NOTES
+*
+* SEE ALSO
+* Multicast Group
+*********/
+
+/****f* OpenSM: Multicast Group/osm_mgrp_is_empty
+* NAME
+* osm_mgrp_is_empty
+*
+* DESCRIPTION
+* Indicates if the multicast group has any member ports.
+*
+* SYNOPSIS
+*/
+static inline boolean_t osm_mgrp_is_empty(IN const osm_mgrp_t * p_mgrp)
+{
+ return (cl_qmap_count(&p_mgrp->mcm_port_tbl) == 0);
+}
+
+/*
+* PARAMETERS
+* p_mgrp
+* [in] Pointer to an osm_mgrp_t object.
+*
+* RETURN VALUES
+* TRUE if there are no ports in the multicast group.
+* FALSE otherwise.
+*
+* NOTES
+*
+* SEE ALSO
+* Multicast Group
+*********/
+
+/****f* OpenSM: Multicast Group/osm_mgrp_get_mlid
+* NAME
+* osm_mgrp_get_mlid
+*
+* DESCRIPTION
+* The osm_mgrp_get_mlid function returns the multicast LID of this group.
+*
+* SYNOPSIS
+*/
+static inline ib_net16_t osm_mgrp_get_mlid(IN const osm_mgrp_t * p_mgrp)
+{
+ return p_mgrp->mlid;
+}
+
+/*
+* PARAMETERS
+* p_mgrp
+* [in] Pointer to an osm_mgrp_t object.
+*
+* RETURN VALUES
+* MLID of the Multicast Group.
+*
+* NOTES
+*
+* SEE ALSO
+* Multicast Group
+*********/
+
+/****f* OpenSM: Multicast Group/osm_mgrp_add_port
+* NAME
+* osm_mgrp_add_port
+*
+* DESCRIPTION
+* Adds a port to the multicast group.
+*
+* SYNOPSIS
+*/
+osm_mcm_port_t *osm_mgrp_add_port(osm_subn_t *subn, osm_log_t *log,
+ IN osm_mgrp_t * mgrp, IN osm_port_t *port,
+ IN ib_member_rec_t *mcmr, IN boolean_t proxy);
+/*
+* PARAMETERS
+* mgrp
+* [in] Pointer to an osm_mgrp_t object to initialize.
+*
+* port
+* [in] Pointer to an osm_port_t object
+*
+* mcmr
+* [in] Pointer to MCMember record received for the join
+*
+* proxy
+* [in] The proxy join state for this port in the group.
+*
+* RETURN VALUES
+* IB_SUCCESS
+* IB_INSUFFICIENT_MEMORY
+*
+* NOTES
+*
+* SEE ALSO
+*********/
+
+/****f* OpenSM: Multicast Group/osm_mgrp_get_mcm_port
+* NAME
+* osm_mgrp_get_mcm_port
+*
+* DESCRIPTION
+* Finds a port in the multicast group.
+*
+* SYNOPSIS
+*/
+osm_mcm_port_t *osm_mgrp_get_mcm_port(IN const osm_mgrp_t * p_mgrp,
+ IN ib_net64_t port_guid);
+/*
+* PARAMETERS
+* p_mgrp
+* [in] Pointer to an osm_mgrp_t object.
+*
+* port_guid
+* [in] Port guid.
+*
+* RETURN VALUES
+* Pointer to the mcm port object when present or NULL otherwise.
+*
+* NOTES
+*
+* SEE ALSO
+*********/
+
+/****f* OpenSM: Multicast Group/osm_mgrp_get_mcm_alias_guid
+* NAME
+* osm_mgrp_get_mcm_alias_guid
+*
+* DESCRIPTION
+* Finds an mcm alias GUID in the multicast group based on an alias GUID.
+*
+* SYNOPSIS
+*/
+osm_mcm_alias_guid_t *osm_mgrp_get_mcm_alias_guid(IN const osm_mgrp_t * p_mgrp,
+ IN ib_net64_t port_guid);
+/*
+* PARAMETERS
+* p_mgrp
+* [in] Pointer to an osm_mgrp_t object.
+*
+* port_guid
+* [in] Alias port guid.
+*
+* RETURN VALUES
+* Pointer to the mcm alias GUID object when present or NULL otherwise.
+*
+* NOTES
+*
+* SEE ALSO
+*********/
+
+/****f* OpenSM: Multicast Group/osm_mgrp_delete_port
+* NAME
+* osm_mgrp_delete_port
+*
+* DESCRIPTION
+* Removes a port from the multicast group.
+*
+* SYNOPSIS
+*/
+void osm_mgrp_delete_port(IN osm_subn_t * subn, IN osm_log_t * log,
+ IN osm_mgrp_t * mgrp, IN osm_port_t * port);
+/*
+* PARAMETERS
+*
+* subn
+* [in] Pointer to the subnet object
+*
+* log
+* [in] The log object pointer
+*
+* mgrp
+* [in] Pointer to an osm_mgrp_t object.
+*
+* port
+* [in] Pointer to an osm_port_t object for the the departing port.
+*
+* RETURN VALUES
+* None.
+*
+* NOTES
+*
+* SEE ALSO
+*********/
+
+boolean_t osm_mgrp_remove_port(osm_subn_t * subn, osm_log_t * log, osm_mgrp_t * mgrp,
+ osm_mcm_alias_guid_t * mcm_alias_guid,
+ ib_member_rec_t * mcmr);
+void osm_mgrp_cleanup(osm_subn_t * subn, osm_mgrp_t * mpgr);
+void osm_mgrp_box_delete(osm_mgrp_box_t *mbox);
+
+END_C_DECLS
+#endif /* _OSM_MULTICAST_H_ */
diff --git a/contrib/ofed/opensm/include/opensm/osm_node.h b/contrib/ofed/opensm/include/opensm/osm_node.h
new file mode 100644
index 0000000..1d34904
--- /dev/null
+++ b/contrib/ofed/opensm/include/opensm/osm_node.h
@@ -0,0 +1,674 @@
+/*
+ * Copyright (c) 2004-2009 Voltaire, Inc. All rights reserved.
+ * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved.
+ * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+/*
+ * Abstract:
+ * Declaration of osm_node_t.
+ * This object represents an IBA node.
+ * This object is part of the OpenSM family of objects.
+ */
+
+#ifndef _OSM_NODE_H_
+#define _OSM_NODE_H_
+
+#include <complib/cl_qmap.h>
+#include <iba/ib_types.h>
+#include <opensm/osm_base.h>
+#include <opensm/osm_port.h>
+#include <opensm/osm_path.h>
+#include <opensm/osm_madw.h>
+
+#ifdef __cplusplus
+# define BEGIN_C_DECLS extern "C" {
+# define END_C_DECLS }
+#else /* !__cplusplus */
+# define BEGIN_C_DECLS
+# define END_C_DECLS
+#endif /* __cplusplus */
+
+BEGIN_C_DECLS
+
+struct osm_switch;
+
+/****h* OpenSM/Node
+* NAME
+* Node
+*
+* DESCRIPTION
+* The Node object encapsulates the information needed by the
+* OpenSM to manage nodes. The OpenSM allocates one Node object
+* per node in the IBA subnet.
+*
+* The Node object is not thread safe, thus callers must provide
+* serialization.
+*
+* This object should be treated as opaque and should be
+* manipulated only through the provided functions.
+*
+* AUTHOR
+* Steve King, Intel
+*
+*********/
+
+/****s* OpenSM: Node/osm_node_t
+* NAME
+* osm_node_t
+*
+* DESCRIPTION
+* Node structure.
+*
+* This object should be treated as opaque and should
+* be manipulated only through the provided functions.
+*
+* SYNOPSIS
+*/
+typedef struct osm_node {
+ cl_map_item_t map_item;
+ struct osm_switch *sw;
+ ib_node_info_t node_info;
+ ib_node_desc_t node_desc;
+ uint32_t discovery_count;
+ uint32_t physp_tbl_size;
+ char *print_desc;
+ uint8_t *physp_discovered;
+ osm_physp_t physp_table[1];
+} osm_node_t;
+/*
+* FIELDS
+* map_item
+* Linkage structure for cl_qmap. MUST BE FIRST MEMBER!
+*
+* sw
+* For switch node contains pointer to appropriate osm_switch
+* structure. NULL for non-switch nodes. Can be used for fast
+* access to switch object and for simple node type detection
+*
+* node_info
+* The IBA defined NodeInfo data for this node.
+*
+* node_desc
+* The IBA defined NodeDescription data for this node.
+*
+* discovery_count
+* The number of times this node has been discovered
+* during the current fabric sweep. This number is reset
+* to zero at the start of a sweep.
+*
+* physp_tbl_size
+* The size of the physp_table array. This value is one greater
+* than the number of ports in the node, since port numbers
+* start with 1 for some bizarre reason.
+*
+* print_desc
+* A printable version of the node description.
+*
+* physp_discovered
+* Array of physp_discovered objects for all ports of this node.
+* Each object indiactes whether the port has been discovered
+* during the sweep or not. 1 means that the port had been discovered.
+*
+* physp_table
+* Array of physical port objects belonging to this node.
+* Index is contiguous by local port number.
+* For switches, port 0 is the always the management port (14.2.5.6).
+* MUST BE LAST MEMBER! - Since it grows !!!!
+*
+* SEE ALSO
+* Node object
+*********/
+
+/****f* OpenSM: Node/osm_node_delete
+* NAME
+* osm_node_delete
+*
+* DESCRIPTION
+* The osm_node_delete function destroys a node, releasing
+* all resources.
+*
+* SYNOPSIS
+*/
+void osm_node_delete(IN OUT osm_node_t ** p_node);
+/*
+* PARAMETERS
+* p_node
+* [in][out] Pointer to a Pointer a Node object to destroy.
+* On return, the pointer to set to NULL.
+*
+* RETURN VALUE
+* This function does not return a value.
+*
+* NOTES
+* Performs any necessary cleanup of the specified Node object.
+* This function should only be called after a call to osm_node_new.
+*
+* SEE ALSO
+* Node object, osm_node_new
+*********/
+
+/****f* OpenSM: Node/osm_node_new
+* NAME
+* osm_node_new
+*
+* DESCRIPTION
+* The osm_node_new function initializes a Node object for use.
+*
+* SYNOPSIS
+*/
+osm_node_t *osm_node_new(IN const osm_madw_t * p_madw);
+/*
+* PARAMETERS
+* p_madw
+* [in] Pointer to a osm_madw_t object containing a mad with
+* the node's NodeInfo attribute. The caller may discard the
+* osm_madw_t structure after calling osm_node_new.
+*
+* RETURN VALUES
+* On success, a pointer to the new initialized osm_node_t structure.
+* NULL otherwise.
+*
+* NOTES
+*
+* SEE ALSO
+* Node object
+*********/
+
+/****f* OpenSM: Node/osm_node_get_physp_ptr
+* NAME
+* osm_node_get_physp_ptr
+*
+* DESCRIPTION
+* Returns a pointer to the physical port object at the
+* specified local port number.
+*
+* SYNOPSIS
+*/
+static inline osm_physp_t *osm_node_get_physp_ptr(IN osm_node_t * p_node,
+ IN uint32_t port_num)
+{
+
+ CL_ASSERT(port_num < p_node->physp_tbl_size);
+ return osm_physp_is_valid(&p_node->physp_table[port_num]) ?
+ &p_node->physp_table[port_num] : NULL;
+}
+
+/*
+* PARAMETERS
+* p_node
+* [in] Pointer to an osm_node_t object.
+*
+* port_num
+* [in] Local port number.
+*
+* RETURN VALUES
+* Returns a pointer to the physical port object at the
+* specified local port number.
+* A return value of zero means the port number was out of range.
+*
+* NOTES
+*
+* SEE ALSO
+* Node object
+*********/
+
+/****f* OpenSM: Node/osm_node_get_type
+* NAME
+* osm_node_get_type
+*
+* DESCRIPTION
+* Returns the type of this node.
+*
+* SYNOPSIS
+*/
+static inline uint8_t osm_node_get_type(IN const osm_node_t * p_node)
+{
+ return p_node->node_info.node_type;
+}
+
+/*
+* PARAMETERS
+* p_node
+* [in] Pointer to an osm_node_t object.
+*
+* RETURN VALUES
+* Returns the IBA defined type of this node.
+*
+* NOTES
+*
+* SEE ALSO
+* Node object
+*********/
+
+/****f* OpenSM: Node/osm_node_get_num_physp
+* NAME
+* osm_node_get_num_physp
+*
+* DESCRIPTION
+* Returns the number of osm_physp ports allocated for this node.
+* For switches, it is the number of external physical ports plus
+* port 0. For CAs and routers, it is the number of external physical
+* ports plus 1.
+*
+* SYNOPSIS
+*/
+static inline uint8_t osm_node_get_num_physp(IN const osm_node_t * p_node)
+{
+ return (uint8_t) p_node->physp_tbl_size;
+}
+
+/*
+* PARAMETERS
+* p_node
+* [in] Pointer to an osm_node_t object.
+*
+* RETURN VALUES
+* Returns the IBA defined type of this node.
+*
+* NOTES
+*
+* SEE ALSO
+* Node object
+*********/
+
+/****f* OpenSM: Node/osm_node_get_remote_node
+* NAME
+* osm_node_get_remote_node
+*
+* DESCRIPTION
+* Returns a pointer to the node on the other end of the
+* specified port.
+* Returns NULL if no remote node exists.
+*
+* SYNOPSIS
+*/
+osm_node_t *osm_node_get_remote_node(IN osm_node_t * p_node,
+ IN uint8_t port_num,
+ OUT uint8_t * p_remote_port_num);
+/*
+* PARAMETERS
+* p_node
+* [in] Pointer to an osm_node_t object.
+*
+* port_num
+* [in] Port number in p_node through which to get the remote node.
+*
+* p_remote_port_num
+* [out] Port number in the remote's node through which this
+* link exists. The caller may specify NULL for this pointer
+* if the port number isn't needed.
+*
+* RETURN VALUES
+* Returns a pointer to the node on the other end of the
+* specified port.
+* Returns NULL if no remote node exists.
+*
+* NOTES
+*
+* SEE ALSO
+* Node object
+*********/
+
+/****f* OpenSM: Node/osm_node_get_base_lid
+* NAME
+* osm_node_get_base_lid
+*
+* DESCRIPTION
+* Returns the LID value of the specified port on this node.
+*
+* SYNOPSIS
+*/
+static inline ib_net16_t osm_node_get_base_lid(IN const osm_node_t * p_node,
+ IN uint32_t port_num)
+{
+ CL_ASSERT(port_num < p_node->physp_tbl_size);
+ return osm_physp_get_base_lid(&p_node->physp_table[port_num]);
+}
+
+/*
+* PARAMETERS
+* p_node
+* [in] Pointer to an osm_node_t object.
+*
+* port_num
+* [in] Local port number.
+*
+* RETURN VALUES
+* Returns a pointer to the physical port object at the
+* specified local port number.
+* A return value of zero means the port number was out of range.
+*
+* NOTES
+*
+* SEE ALSO
+* Node object
+*********/
+
+/****f* OpenSM: Node/osm_node_get_remote_base_lid
+* NAME
+* osm_node_get_remote_base_lid
+*
+* DESCRIPTION
+* Returns the base LID value of the port on the other side
+* of the wire from the specified port on this node.
+*
+* SYNOPSIS
+*/
+ib_net16_t osm_node_get_remote_base_lid(IN osm_node_t * p_node,
+ IN uint32_t port_num);
+/*
+* PARAMETERS
+* p_node
+* [in] Pointer to an osm_node_t object.
+*
+* port_num
+* [in] Local port number.
+*
+* RETURN VALUES
+* Returns a pointer to the physical port object at the
+* specified local port number.
+* A return value of zero means the port number was out of range.
+*
+* NOTES
+*
+* SEE ALSO
+* Node object
+*********/
+
+/****f* OpenSM: Node/osm_node_get_lmc
+* NAME
+* osm_node_get_lmc
+*
+* DESCRIPTION
+* Returns the LMC value of the specified port on this node.
+*
+* SYNOPSIS
+*/
+static inline uint8_t osm_node_get_lmc(IN const osm_node_t * p_node,
+ IN uint32_t port_num)
+{
+ CL_ASSERT(port_num < p_node->physp_tbl_size);
+ return osm_physp_get_lmc(&p_node->physp_table[port_num]);
+}
+
+/*
+* PARAMETERS
+* p_node
+* [in] Pointer to an osm_node_t object.
+*
+* port_num
+* [in] Local port number.
+*
+* RETURN VALUES
+* Returns the LMC value of the specified port on this node.
+*
+* NOTES
+*
+* SEE ALSO
+* Node object
+*********/
+
+/****f* OpenSM: Node/osm_node_init_physp
+* NAME
+* osm_node_init_physp
+*
+* DESCRIPTION
+* Initializes a physical port for the given node.
+*
+* SYNOPSIS
+*/
+void osm_node_init_physp(IN osm_node_t * p_node, uint8_t port_num,
+ IN const osm_madw_t * p_madw);
+/*
+* PARAMETERS
+* p_node
+* [in] Pointer to an osm_node_t object.
+*
+* p_madw
+* [in] Pointer to a osm_madw_t object containing a mad with
+* the node's NodeInfo attribute as discovered through the
+* Physical Port to add to the node. The caller may discard the
+* osm_madw_t structure after calling osm_node_new.
+*
+* RETURN VALUES
+* None.
+*
+* NOTES
+*
+* SEE ALSO
+* Node object, Physical Port object.
+*********/
+
+/****f* OpenSM: Node/osm_node_get_node_guid
+* NAME
+* osm_node_get_node_guid
+*
+* DESCRIPTION
+* Returns the node GUID of this node.
+*
+* SYNOPSIS
+*/
+static inline ib_net64_t osm_node_get_node_guid(IN const osm_node_t * p_node)
+{
+ return p_node->node_info.node_guid;
+}
+
+/*
+* PARAMETERS
+* p_node
+* [in] Pointer to an osm_node_t object.
+*
+* RETURN VALUES
+* Returns the node GUID of this node.
+*
+* NOTES
+*
+* SEE ALSO
+* Node object
+*********/
+
+/****f* OpenSM: Node/osm_node_link
+* NAME
+* osm_node_link
+*
+* DESCRIPTION
+* Logically connects a node to another node through the specified port.
+*
+* SYNOPSIS
+*/
+void osm_node_link(IN osm_node_t * p_node, IN uint8_t port_num,
+ IN osm_node_t * p_remote_node, IN uint8_t remote_port_num);
+/*
+* PARAMETERS
+* p_node
+* [in] Pointer to an osm_node_t object.
+*
+* port_num
+* [in] Port number in p_node through which to create the link.
+*
+* p_remote_node
+* [in] Pointer to the remote port object.
+*
+* remote_port_num
+* [in] Port number in the remote's node through which to
+* create this link.
+*
+* RETURN VALUES
+* None.
+*
+* NOTES
+*
+* SEE ALSO
+* Node object
+*********/
+
+/****f* OpenSM: Node/osm_node_unlink
+* NAME
+* osm_node_unlink
+*
+* DESCRIPTION
+* Logically disconnects a node from another node through
+* the specified port.
+*
+* SYNOPSIS
+*/
+void osm_node_unlink(IN osm_node_t * p_node, IN uint8_t port_num,
+ IN osm_node_t * p_remote_node, IN uint8_t remote_port_num);
+/*
+* PARAMETERS
+* p_node
+* [in] Pointer to an osm_node_t object.
+*
+* port_num
+* [in] Port number in p_node through which to unlink.
+*
+* p_remote_node
+* [in] Pointer to the remote port object.
+*
+* remote_port_num
+* [in] Port number in the remote's node through which to unlink.
+*
+* RETURN VALUES
+* None.
+*
+* NOTES
+*
+* SEE ALSO
+* Node object
+*********/
+
+/****f* OpenSM: Node/osm_node_link_exists
+* NAME
+* osm_node_link_exists
+*
+* DESCRIPTION
+* Return TRUE if a link exists between the specified nodes on
+* the specified ports.
+* Returns FALSE otherwise.
+*
+* SYNOPSIS
+*/
+boolean_t osm_node_link_exists(IN osm_node_t * p_node, IN uint8_t port_num,
+ IN osm_node_t * p_remote_node,
+ IN uint8_t remote_port_num);
+/*
+* PARAMETERS
+* p_node
+* [in] Pointer to an osm_node_t object.
+*
+* port_num
+* [in] Port number in p_node through which to check the link.
+*
+* p_remote_node
+* [in] Pointer to the remote port object.
+*
+* remote_port_num
+* [in] Port number in the remote's node through which to
+* check this link.
+*
+* RETURN VALUES
+* Return TRUE if a link exists between the specified nodes on
+* the specified ports.
+* Returns FALSE otherwise.
+*
+* NOTES
+*
+* SEE ALSO
+* Node object
+*********/
+
+/****f* OpenSM: Node/osm_node_has_any_link
+* NAME
+* osm_node_has_any_link
+*
+* DESCRIPTION
+* Return TRUE if a any link exists from the specified nodes on
+* the specified port.
+* Returns FALSE otherwise.
+*
+* SYNOPSIS
+*/
+boolean_t osm_node_has_any_link(IN osm_node_t * p_node, IN uint8_t port_num);
+/*
+* PARAMETERS
+* p_node
+* [in] Pointer to an osm_node_t object.
+*
+* port_num
+* [in] Port number in p_node through which to check the link.
+*
+* RETURN VALUES
+* Return TRUE if a any link exists from the specified nodes on
+* the specified port.
+* Returns FALSE otherwise.
+*
+* NOTES
+*
+* SEE ALSO
+* Node object
+*********/
+
+/****f* OpenSM: Node/osm_node_link_has_valid_ports
+* NAME
+* osm_node_link_has_valid_ports
+*
+* DESCRIPTION
+* Return TRUE if both ports in the link are valid (initialized).
+* Returns FALSE otherwise.
+*
+* SYNOPSIS
+*/
+boolean_t osm_node_link_has_valid_ports(IN osm_node_t * p_node,
+ IN uint8_t port_num,
+ IN osm_node_t * p_remote_node,
+ IN uint8_t remote_port_num);
+/*
+* PARAMETERS
+* p_node
+* [in] Pointer to an osm_node_t object.
+*
+* port_num
+* [in] Port number in p_node through which to check the link.
+*
+* RETURN VALUES
+* Return TRUE if both ports in the link are valid (initialized).
+* Returns FALSE otherwise.
+*
+* NOTES
+*
+* SEE ALSO
+* Node object
+*********/
+
+END_C_DECLS
+#endif /* _OSM_NODE_H_ */
diff --git a/contrib/ofed/opensm/include/opensm/osm_opensm.h b/contrib/ofed/opensm/include/opensm/osm_opensm.h
new file mode 100644
index 0000000..7768881
--- /dev/null
+++ b/contrib/ofed/opensm/include/opensm/osm_opensm.h
@@ -0,0 +1,670 @@
+/*
+ * Copyright (c) 2004-2009 Voltaire, Inc. All rights reserved.
+ * Copyright (c) 2002-2006 Mellanox Technologies LTD. All rights reserved.
+ * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
+ * Copyright (c) 2009-2011 ZIH, TU Dresden, Federal Republic of Germany. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+/*
+ * Abstract:
+ * Declaration of osm_opensm_t.
+ * This object represents the OpenSM super object.
+ * This object is part of the OpenSM family of objects.
+ */
+
+#ifndef _OSM_OPENSM_H_
+#define _OSM_OPENSM_H_
+
+#include <stdio.h>
+#include <complib/cl_qlist.h>
+#include <complib/cl_dispatcher.h>
+#include <complib/cl_passivelock.h>
+#include <complib/cl_atomic.h>
+#include <complib/cl_nodenamemap.h>
+#include <opensm/osm_console_io.h>
+#include <opensm/osm_stats.h>
+#include <opensm/osm_log.h>
+#include <opensm/osm_sm.h>
+#include <opensm/osm_sa.h>
+#include <opensm/osm_perfmgr.h>
+#include <opensm/osm_event_plugin.h>
+#include <opensm/osm_db.h>
+#include <opensm/osm_subnet.h>
+#include <opensm/osm_mad_pool.h>
+#include <opensm/osm_vl15intf.h>
+#include <opensm/osm_congestion_control.h>
+
+#ifdef __cplusplus
+# define BEGIN_C_DECLS extern "C" {
+# define END_C_DECLS }
+#else /* !__cplusplus */
+# define BEGIN_C_DECLS
+# define END_C_DECLS
+#endif /* __cplusplus */
+
+BEGIN_C_DECLS
+/****h* OpenSM/OpenSM
+* NAME
+* OpenSM
+*
+* DESCRIPTION
+* The OpenSM object encapsulates the information needed by the
+* OpenSM to govern itself. The OpenSM is one OpenSM object.
+*
+* The OpenSM object is thread safe.
+*
+* This object should be treated as opaque and should
+* be manipulated only through the provided functions.
+*
+* AUTHOR
+* Steve King, Intel
+*
+*********/
+/****d* OpenSM: OpenSM/osm_routing_engine_type_t
+* NAME
+* osm_routing_engine_type_t
+*
+* DESCRIPTION
+* Enumerates the possible routing engines that
+* could be used to route a subnet.
+*
+* SYNOPSIS
+*/
+typedef enum _osm_routing_engine_type {
+ OSM_ROUTING_ENGINE_TYPE_NONE = 0,
+ OSM_ROUTING_ENGINE_TYPE_MINHOP,
+ OSM_ROUTING_ENGINE_TYPE_UPDN,
+ OSM_ROUTING_ENGINE_TYPE_DNUP,
+ OSM_ROUTING_ENGINE_TYPE_FILE,
+ OSM_ROUTING_ENGINE_TYPE_FTREE,
+ OSM_ROUTING_ENGINE_TYPE_LASH,
+ OSM_ROUTING_ENGINE_TYPE_DOR,
+ OSM_ROUTING_ENGINE_TYPE_TORUS_2QOS,
+ OSM_ROUTING_ENGINE_TYPE_SSSP,
+ OSM_ROUTING_ENGINE_TYPE_DFSSSP,
+ OSM_ROUTING_ENGINE_TYPE_UNKNOWN
+} osm_routing_engine_type_t;
+/***********/
+
+/****s* OpenSM: OpenSM/osm_routing_engine
+* NAME
+* struct osm_routing_engine
+*
+* DESCRIPTION
+* OpenSM routing engine module definition.
+* NOTES
+* routing engine structure - multicast callbacks may be
+* added later.
+*/
+struct osm_routing_engine {
+ osm_routing_engine_type_t type;
+ const char *name;
+ void *context;
+ int (*build_lid_matrices) (void *context);
+ int (*ucast_build_fwd_tables) (void *context);
+ void (*ucast_dump_tables) (void *context);
+ void (*update_sl2vl)(void *context, IN osm_physp_t *port,
+ IN uint8_t in_port_num, IN uint8_t out_port_num,
+ IN OUT ib_slvl_table_t *t);
+ void (*update_vlarb)(void *context, IN osm_physp_t *port,
+ IN uint8_t port_num,
+ IN OUT ib_vl_arb_table_t *block,
+ unsigned block_length, unsigned block_num);
+ uint8_t (*path_sl)(void *context, IN uint8_t path_sl_hint,
+ IN const ib_net16_t slid, IN const ib_net16_t dlid);
+ ib_api_status_t (*mcast_build_stree)(void *context,
+ IN OUT osm_mgrp_box_t *mgb);
+ void (*destroy) (void *context);
+ struct osm_routing_engine *next;
+};
+/*
+* FIELDS
+* name
+* The routing engine name (will be used in logs).
+*
+* context
+* The routing engine context. Will be passed as parameter
+* to the callback functions.
+*
+* build_lid_matrices
+* The callback for lid matrices generation.
+*
+* ucast_build_fwd_tables
+* The callback for unicast forwarding table generation.
+*
+* ucast_dump_tables
+* The callback for dumping unicast routing tables.
+*
+* update_sl2vl(void *context, IN osm_physp_t *port,
+* IN uint8_t in_port_num, IN uint8_t out_port_num,
+* OUT ib_slvl_table_t *t)
+* The callback to allow routing engine input for SL2VL maps.
+* *port is the physical port for which the SL2VL map is to be
+* updated. For switches, in_port_num/out_port_num identify
+* which part of the SL2VL map to update. For router/HCA ports,
+* in_port_num/out_port_num should be ignored.
+*
+* update_vlarb(void *context, IN osm_physp_t *port,
+* IN uint8_t port_num,
+* IN OUT ib_vl_arb_table_t *block,
+* unsigned block_length, unsigned block_num)
+* The callback to allow routing engine input for VLArbitration.
+* *port is the physical port for which the VLArb table is to be
+* updated.
+*
+* path_sl
+* The callback for computing path SL.
+*
+* mcast_build_stree
+* The callback for building the spanning tree for multicast
+* forwarding, called per MLID.
+*
+* destroy
+* The destroy method, may be used for routing engine
+* internals cleanup.
+*
+* next
+* Pointer to next routing engine in the list.
+*/
+
+/****s* OpenSM: OpenSM/osm_opensm_t
+* NAME
+* osm_opensm_t
+*
+* DESCRIPTION
+* OpenSM structure.
+*
+* This object should be treated as opaque and should
+* be manipulated only through the provided functions.
+*
+* SYNOPSIS
+*/
+typedef struct osm_opensm {
+ const char *osm_version;
+ osm_subn_t subn;
+ osm_sm_t sm;
+ osm_sa_t sa;
+#ifdef ENABLE_OSM_PERF_MGR
+ osm_perfmgr_t perfmgr;
+#endif /* ENABLE_OSM_PERF_MGR */
+ osm_congestion_control_t cc;
+ cl_qlist_t plugin_list;
+ osm_db_t db;
+ boolean_t mad_pool_constructed;
+ osm_mad_pool_t mad_pool;
+ osm_vendor_t *p_vendor;
+ boolean_t vl15_constructed;
+ osm_vl15_t vl15;
+ osm_log_t log;
+ cl_dispatcher_t disp;
+ cl_dispatcher_t sa_set_disp;
+ boolean_t sa_set_disp_initialized;
+ cl_plock_t lock;
+ struct osm_routing_engine *routing_engine_list;
+ struct osm_routing_engine *routing_engine_used;
+ struct osm_routing_engine *default_routing_engine;
+ boolean_t no_fallback_routing_engine;
+ osm_stats_t stats;
+ osm_console_t console;
+ nn_map_t *node_name_map;
+} osm_opensm_t;
+/*
+* FIELDS
+* osm_version
+* OpenSM version (as generated in osm_version.h)
+*
+* subn
+* Subnet object for this subnet.
+*
+* sm
+* The Subnet Manager (SM) object for this subnet.
+*
+* sa
+* The Subnet Administration (SA) object for this subnet.
+*
+* db
+* Persistant storage of some data required between sessions.
+*
+* mad_pool
+* Pool of Management Datagram (MAD) objects.
+*
+* p_vendor
+* Pointer to the Vendor specific adapter for various
+* transport interfaces, such as UMADT, AL, etc. The
+* particular interface is set at compile time.
+*
+* vl15
+* The VL15 interface.
+*
+* log
+* Log facility used by all OpenSM components.
+*
+* disp
+* Central dispatcher containing the OpenSM worker threads.
+*
+* sa_set_disp
+* Dispatcher for SA Set and Delete requests.
+*
+* sa_set_disp_initialized.
+* Indicator that sa_set_disp dispatcher was initialized.
+*
+* lock
+* Shared lock guarding most OpenSM structures.
+*
+* routing_engine_list
+* List of routing engines that should be tried for use.
+*
+* routing_engine_used
+* Indicates which routing engine was used to route a subnet.
+*
+* no_fallback_routing_engine
+* Indicates if default routing engine should not be used.
+*
+* stats
+* Open SM statistics block
+*
+* SEE ALSO
+*********/
+
+/****f* OpenSM: OpenSM/osm_opensm_construct
+* NAME
+* osm_opensm_construct
+*
+* DESCRIPTION
+* This function constructs an OpenSM object.
+*
+* SYNOPSIS
+*/
+void osm_opensm_construct(IN osm_opensm_t * p_osm);
+/*
+* PARAMETERS
+* p_osm
+* [in] Pointer to a OpenSM object to construct.
+*
+* RETURN VALUE
+* This function does not return a value.
+*
+* NOTES
+* Allows calling osm_opensm_init, osm_opensm_destroy
+*
+* Calling osm_opensm_construct is a prerequisite to calling any other
+* method except osm_opensm_init.
+*
+* SEE ALSO
+* SM object, osm_opensm_init, osm_opensm_destroy
+*********/
+
+/****f* OpenSM: OpenSM/osm_opensm_construct_finish
+* NAME
+* osm_opensm_construct_finish
+*
+* DESCRIPTION
+* The osm_opensm_construct_finish function completes
+* the second phase of constucting an OpenSM object.
+*
+* SYNOPSIS
+*/
+void osm_opensm_construct_finish(IN osm_opensm_t * p_osm);
+/*
+* PARAMETERS
+* p_osm
+* [in] Pointer to a OpenSM object to construct.
+*
+* RETURN VALUE
+* This function does not return a value.
+*
+* NOTES
+* Calling osm_opensm_construct/osm_construct_finish is a prerequisite
+* to calling any other method except osm_opensm_init/osm_opensm_init_finish.
+*
+* SEE ALSO
+* SM object, osm_opensm_init, osm_opensm_construct_finish,
+* osm_opensm_destroy, osm_opensm_destroy_finish
+*********/
+
+/****f* OpenSM: OpenSM/osm_opensm_destroy
+* NAME
+* osm_opensm_destroy
+*
+* DESCRIPTION
+* The osm_opensm_destroy function destroys an SM, releasing
+* all resources.
+*
+* SYNOPSIS
+*/
+void osm_opensm_destroy(IN osm_opensm_t * p_osm);
+/*
+* PARAMETERS
+* p_osm
+* [in] Pointer to a OpenSM object to destroy.
+*
+* RETURN VALUE
+* This function does not return a value.
+*
+* NOTES
+* Performs any necessary cleanup of the specified OpenSM object.
+* Further operations should not be attempted on the destroyed object.
+* This function should only be called after a call to osm_opensm_construct or
+* osm_opensm_init.
+*
+* SEE ALSO
+* SM object, osm_opensm_construct, osm_opensm_init
+*********/
+
+/****f* OpenSM: OpenSM/osm_opensm_destroy_finish
+* NAME
+* osm_opensm_destroy_finish
+*
+* DESCRIPTION
+* The osm_opensm_destroy_finish function handles the second phase
+* of destroying an SM, releasing all resources.
+*
+* SYNOPSIS
+*/
+void osm_opensm_destroy_finish(IN osm_opensm_t * p_osm);
+/*
+* PARAMETERS
+* p_osm
+* [in] Pointer to a OpenSM object to destroy.
+*
+* RETURN VALUE
+* This function does not return a value.
+*
+* NOTES
+* Performs second phase of any necessary cleanup of the specified OpenSM object.
+* Further operations should not be attempted on the destroyed object.
+* This function should only be called after a call to
+* osm_opensm_construct_finish or osm_opensm_init_finish.
+*
+* SEE ALSO
+* SM object, osm_opensm_construct, osm_opensm_construct_finish,
+* osm_opensm_init, osm_opensm_init_finish
+*********/
+
+/****f* OpenSM: OpenSM/osm_opensm_init
+* NAME
+* osm_opensm_init
+*
+* DESCRIPTION
+* The osm_opensm_init function initializes a OpenSM object for use.
+*
+* SYNOPSIS
+*/
+ib_api_status_t osm_opensm_init(IN osm_opensm_t * p_osm,
+ IN const osm_subn_opt_t * p_opt);
+/*
+* PARAMETERS
+* p_osm
+* [in] Pointer to an osm_opensm_t object to initialize.
+*
+* p_opt
+* [in] Pointer to the subnet options structure.
+*
+* RETURN VALUES
+* IB_SUCCESS if the OpenSM object was initialized successfully.
+*
+* NOTES
+* Allows calling other OpenSM methods.
+*
+* SEE ALSO
+* SM object, osm_opensm_construct, osm_opensm_destroy
+*********/
+
+/****f* OpenSM: OpenSM/osm_opensm_init_finish
+* NAME
+* osm_opensm_init_finish
+*
+* DESCRIPTION
+* The osm_opensm_init_finish function performs the second phase
+* of initialization of an OpenSM object.
+*
+* SYNOPSIS
+*/
+ib_api_status_t osm_opensm_init_finish(IN osm_opensm_t * p_osm,
+ IN const osm_subn_opt_t * p_opt);
+/*
+* PARAMETERS
+* p_osm
+* [in] Pointer to an osm_opensm_t object to initialize.
+*
+* p_opt
+* [in] Pointer to the subnet options structure.
+*
+* RETURN VALUES
+* IB_SUCCESS if the OpenSM object was initialized successfully.
+*
+* NOTES
+* Allows calling other OpenSM methods.
+*
+* SEE ALSO
+* SM object, osm_opensm_construct, osm_opensm_construct_finish,
+* osm_opensm_destroy, osm_opensm_destroy_finish
+*********/
+
+/****f* OpenSM: OpenSM/osm_opensm_sweep
+* NAME
+* osm_opensm_sweep
+*
+* DESCRIPTION
+* Initiates a subnet sweep.
+*
+* SYNOPSIS
+*/
+static inline void osm_opensm_sweep(IN osm_opensm_t * p_osm)
+{
+ osm_sm_sweep(&p_osm->sm);
+}
+
+/*
+* PARAMETERS
+* p_osm
+* [in] Pointer to an osm_opensm_t object on which to
+* initiate a sweep.
+*
+* RETURN VALUES
+* None
+*
+* NOTES
+* If the OpenSM object is not bound to a port, this function
+* does nothing.
+*
+* SEE ALSO
+*********/
+
+/****f* OpenSM: OpenSM/osm_opensm_set_log_flags
+* NAME
+* osm_opensm_set_log_flags
+*
+* DESCRIPTION
+* Sets the log level.
+*
+* SYNOPSIS
+*/
+static inline void osm_opensm_set_log_flags(IN osm_opensm_t * p_osm,
+ IN osm_log_level_t log_flags)
+{
+ osm_log_set_level(&p_osm->log, log_flags);
+}
+
+/*
+* PARAMETERS
+* p_osm
+* [in] Pointer to an osm_opensm_t object.
+*
+* log_flags
+* [in] Log level flags to set.
+*
+* RETURN VALUES
+* None
+*
+* NOTES
+*
+* SEE ALSO
+*********/
+
+/****f* OpenSM: OpenSM/osm_opensm_bind
+* NAME
+* osm_opensm_bind
+*
+* DESCRIPTION
+* Binds the opensm object to a port guid.
+*
+* SYNOPSIS
+*/
+ib_api_status_t osm_opensm_bind(IN osm_opensm_t * p_osm, IN ib_net64_t guid);
+/*
+* PARAMETERS
+* p_osm
+* [in] Pointer to an osm_opensm_t object to bind.
+*
+* guid
+* [in] Local port GUID with which to bind.
+*
+* RETURN VALUES
+* None
+*
+* NOTES
+* A given opensm object can only be bound to one port at a time.
+*
+* SEE ALSO
+*********/
+
+/****f* OpenSM: OpenSM/osm_opensm_wait_for_subnet_up
+* NAME
+* osm_opensm_wait_for_subnet_up
+*
+* DESCRIPTION
+* Blocks the calling thread until the subnet is up.
+*
+* SYNOPSIS
+*/
+static inline cl_status_t
+osm_opensm_wait_for_subnet_up(IN osm_opensm_t * p_osm, IN uint32_t wait_us,
+ IN boolean_t interruptible)
+{
+ return osm_sm_wait_for_subnet_up(&p_osm->sm, wait_us, interruptible);
+}
+
+/*
+* PARAMETERS
+* p_osm
+* [in] Pointer to an osm_opensm_t object.
+*
+* wait_us
+* [in] Number of microseconds to wait.
+*
+* interruptible
+* [in] Indicates whether the wait operation can be interrupted
+* by external signals.
+*
+* RETURN VALUES
+* CL_SUCCESS if the wait operation succeeded in response to the event
+* being set.
+*
+* CL_TIMEOUT if the specified time period elapses.
+*
+* CL_NOT_DONE if the wait was interrupted by an external signal.
+*
+* CL_ERROR if the wait operation failed.
+*
+* NOTES
+*
+* SEE ALSO
+*********/
+
+/****f* OpenSM: OpenSM/osm_routing_engine_type_str
+* NAME
+* osm_routing_engine_type_str
+*
+* DESCRIPTION
+* Returns a string for the specified routing engine type.
+*
+* SYNOPSIS
+*/
+const char *osm_routing_engine_type_str(IN osm_routing_engine_type_t type);
+/*
+* PARAMETERS
+* type
+* [in] routing engine type.
+*
+* RETURN VALUES
+* Pointer to routing engine name.
+*
+* NOTES
+*
+* SEE ALSO
+*********/
+
+/****f* OpenSM: OpenSM/osm_routing_engine_type
+* NAME
+* osm_routing_engine_type
+*
+* DESCRIPTION
+* Returns a routing engine type specified routing engine name string.
+*
+* SYNOPSIS
+*/
+osm_routing_engine_type_t osm_routing_engine_type(IN const char *str);
+/*
+* PARAMETERS
+* str
+* [in] routing engine name string.
+*
+* RETURN VALUES
+* Routing engine type.
+*
+* NOTES
+*
+* SEE ALSO
+*********/
+
+void osm_opensm_report_event(osm_opensm_t *osm, osm_epi_event_id_t event_id,
+ void *event_data);
+
+/* dump helpers */
+void osm_dump_mcast_routes(osm_opensm_t * osm);
+void osm_dump_all(osm_opensm_t * osm);
+void osm_dump_qmap_to_file(osm_opensm_t * p_osm, const char *file_name,
+ cl_qmap_t * map,
+ void (*func) (cl_map_item_t *, FILE *, void *),
+ void *cxt);
+
+/****v* OpenSM/osm_exit_flag
+*/
+extern volatile unsigned int osm_exit_flag;
+/*
+* DESCRIPTION
+* Set to one to cause all threads to leave
+*********/
+
+END_C_DECLS
+#endif /* _OSM_OPENSM_H_ */
diff --git a/contrib/ofed/opensm/include/opensm/osm_partition.h b/contrib/ofed/opensm/include/opensm/osm_partition.h
new file mode 100644
index 0000000..515e8d5
--- /dev/null
+++ b/contrib/ofed/opensm/include/opensm/osm_partition.h
@@ -0,0 +1,279 @@
+/*
+ * Copyright (c) 2004-2009 Voltaire, Inc. All rights reserved.
+ * Copyright (c) 2002-2008 Mellanox Technologies LTD. All rights reserved.
+ * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+/*
+ * Abstract:
+ * Declaration of osm_prtn_t.
+ * This object represents an IBA Partition.
+ * This object is part of the OpenSM family of objects.
+ */
+
+#ifndef _OSM_PARTITION_H_
+#define _OSM_PARTITION_H_
+
+#include <iba/ib_types.h>
+#include <complib/cl_qmap.h>
+#include <complib/cl_map.h>
+#include <opensm/osm_log.h>
+#include <opensm/osm_subnet.h>
+#include <opensm/osm_multicast.h>
+
+#ifdef __cplusplus
+# define BEGIN_C_DECLS extern "C" {
+# define END_C_DECLS }
+#else /* !__cplusplus */
+# define BEGIN_C_DECLS
+# define END_C_DECLS
+#endif /* __cplusplus */
+
+BEGIN_C_DECLS
+/****h* OpenSM/Partition
+* NAME
+* Partition
+*
+* DESCRIPTION
+* The Partition object encapsulates the information needed by the
+* OpenSM to manage Partitions. The OpenSM allocates one Partition
+* object per Partition in the IBA subnet.
+*
+* The Partition is not thread safe, thus callers must provide
+* serialization.
+*
+* This object should be treated as opaque and should be
+* manipulated only through the provided functions.
+*
+* AUTHOR
+* Steve King, Intel
+*
+*********/
+/****s* OpenSM: Partition/osm_prtn_t
+* NAME
+* osm_prtn_t
+*
+* DESCRIPTION
+* Partition structure.
+*
+* The osm_prtn_t object should be treated as opaque and should
+* be manipulated only through the provided functions.
+*
+* SYNOPSIS
+*/
+typedef struct osm_prtn {
+ cl_map_item_t map_item;
+ ib_net16_t pkey;
+ uint8_t sl;
+ cl_map_t full_guid_tbl;
+ cl_map_t part_guid_tbl;
+ char name[32];
+ osm_mgrp_t **mgrps;
+ int nmgrps;
+} osm_prtn_t;
+/*
+* FIELDS
+* map_item
+* Linkage structure for cl_qmap. MUST BE FIRST MEMBER!
+*
+* pkey
+* The IBA defined P_KEY of this Partition.
+*
+* sl
+* The Service Level (SL) associated with this Partiton.
+*
+* full_guid_tbl
+* Container of pointers to all Port objects in the Partition
+* with full membership, indexed by port GUID.
+*
+* part_guid_tbl
+* Container of pointers to all Port objects in the Partition
+* with limited membership, indexed by port GUID.
+*
+* name
+* Name of the Partition as specified in partition
+* configuration.
+*
+* mgrps
+* List of well known Multicast Groups
+* that were created for this partition (when configured).
+* This includes the IPoIB broadcast group.
+*
+* nmgrps
+* Number of known Multicast Groups.
+*
+* SEE ALSO
+* Partition
+*********/
+
+/****f* OpenSM: Partition/osm_prtn_delete
+* NAME
+* osm_prtn_delete
+*
+* DESCRIPTION
+* This function destroys and deallocates a Partition object.
+*
+* SYNOPSIS
+*/
+void osm_prtn_delete(IN osm_subn_t * p_subn, IN OUT osm_prtn_t ** pp_prtn);
+/*
+* PARAMETERS
+* pp_prtn
+* [in][out] Pointer to a pointer to a Partition object to
+* delete. On return, this pointer is NULL.
+*
+* RETURN VALUE
+* This function does not return a value.
+*
+* NOTES
+* Performs any necessary cleanup of the specified Partition object.
+*
+* SEE ALSO
+* Partition, osm_prtn_new
+*********/
+
+/****f* OpenSM: Partition/osm_prtn_new
+* NAME
+* osm_prtn_new
+*
+* DESCRIPTION
+* This function allocates and initializes a Partition object.
+*
+* SYNOPSIS
+*/
+osm_prtn_t *osm_prtn_new(IN const char *name, IN uint16_t pkey);
+/*
+* PARAMETERS
+* name
+* [in] Partition name string
+*
+* pkey
+* [in] Partition P_Key value
+*
+* RETURN VALUE
+* Pointer to the initialize Partition object.
+*
+* NOTES
+* Allows calling other partition methods.
+*
+* SEE ALSO
+* Partition
+*********/
+
+/****f* OpenSM: Partition/osm_prtn_is_guid
+* NAME
+* osm_prtn_is_guid
+*
+* DESCRIPTION
+* Indicates if a port is a member of the partition.
+*
+* SYNOPSIS
+*/
+static inline boolean_t osm_prtn_is_guid(IN const osm_prtn_t * p_prtn,
+ IN ib_net64_t guid)
+{
+ return (cl_map_get(&p_prtn->full_guid_tbl, guid) != NULL) ||
+ (cl_map_get(&p_prtn->part_guid_tbl, guid) != NULL);
+}
+
+/*
+* PARAMETERS
+* p_prtn
+* [in] Pointer to an osm_prtn_t object.
+*
+* guid
+* [in] Port GUID.
+*
+* RETURN VALUES
+* TRUE if the specified port GUID is a member of the partition,
+* FALSE otherwise.
+*
+* NOTES
+*
+* SEE ALSO
+*********/
+
+/****f* OpenSM: Partition/osm_prtn_make_partitions
+* NAME
+* osm_prtn_make_partitions
+*
+* DESCRIPTION
+* Makes all partitions in subnet.
+*
+* SYNOPSIS
+*/
+ib_api_status_t osm_prtn_make_partitions(IN osm_log_t * p_log,
+ IN osm_subn_t * p_subn);
+/*
+* PARAMETERS
+* p_log
+* [in] Pointer to a log object.
+*
+* p_subn
+* [in] Pointer to subnet object.
+*
+* RETURN VALUES
+* IB_SUCCESS value on success.
+*
+* NOTES
+*
+* SEE ALSO
+*********/
+
+/****f* OpenSM: Partition/osm_prtn_find_by_name
+* NAME
+* osm_prtn_find_by_name
+*
+* DESCRIPTION
+* Fides partition by name.
+*
+* SYNOPSIS
+*/
+osm_prtn_t *osm_prtn_find_by_name(IN osm_subn_t * p_subn, IN const char *name);
+/*
+* PARAMETERS
+* p_subn
+* [in] Pointer to a subnet object.
+*
+* name
+* [in] Required partition name.
+*
+* RETURN VALUES
+* Pointer to the partition object on success.
+*
+* NOTES
+*
+* SEE ALSO
+*********/
+
+END_C_DECLS
+#endif /* _OSM_PARTITION_H_ */
diff --git a/contrib/ofed/opensm/include/opensm/osm_path.h b/contrib/ofed/opensm/include/opensm/osm_path.h
new file mode 100644
index 0000000..b69e5f9
--- /dev/null
+++ b/contrib/ofed/opensm/include/opensm/osm_path.h
@@ -0,0 +1,219 @@
+/*
+ * Copyright (c) 2004-2009 Voltaire, Inc. All rights reserved.
+ * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved.
+ * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
+ * Copyright (c) 2009 HNR Consulting. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+#ifndef _OSM_PATH_H_
+#define _OSM_PATH_H_
+
+#include <string.h>
+#include <opensm/osm_base.h>
+#include <vendor/osm_vendor_api.h>
+
+#ifdef __cplusplus
+# define BEGIN_C_DECLS extern "C" {
+# define END_C_DECLS }
+#else /* !__cplusplus */
+# define BEGIN_C_DECLS
+# define END_C_DECLS
+#endif /* __cplusplus */
+
+BEGIN_C_DECLS
+/*
+ * Abstract:
+ * Declaration of path related objects.
+ * These objects are part of the OpenSM family of objects.
+ */
+/****h* OpenSM/DR Path
+* NAME
+* DR Path
+*
+* DESCRIPTION
+* The DR Path structure encapsulates a directed route through the subnet.
+*
+* This structure allows direct access to member variables.
+*
+* AUTHOR
+* Steve King, Intel
+*
+*********/
+/****s* OpenSM: DR Path/osm_dr_path_t
+* NAME
+* osm_dr_path_t
+*
+* DESCRIPTION
+* Directed Route structure.
+*
+* This structure allows direct access to member variables.
+*
+* SYNOPSIS
+*/
+typedef struct osm_dr_path {
+ uint8_t hop_count;
+ uint8_t path[IB_SUBNET_PATH_HOPS_MAX];
+} osm_dr_path_t;
+/*
+* FIELDS
+* h_bind
+* Bind handle for port to which this path applies.
+*
+* hop_count
+* The number of hops in this path.
+*
+* path
+* The array of port numbers that comprise this path.
+*
+* SEE ALSO
+* DR Path structure
+*********/
+/****f* OpenSM: DR Path/osm_dr_path_construct
+* NAME
+* osm_dr_path_construct
+*
+* DESCRIPTION
+* This function constructs a directed route path object.
+*
+* SYNOPSIS
+*/
+static inline void osm_dr_path_construct(IN osm_dr_path_t * p_path)
+{
+ /* The first location in the path array is reserved. */
+ memset(p_path, 0, sizeof(*p_path));
+}
+
+/*
+* PARAMETERS
+* p_path
+* [in] Pointer to a directed route path object to initialize.
+*
+* h_bind
+* [in] Bind handle for the port on which this path applies.
+*
+* hop_count
+* [in] Hop count needed to reach this node.
+*
+* path
+* [in] Directed route path to reach this node.
+*
+* RETURN VALUE
+* None.
+*
+* NOTES
+*
+* SEE ALSO
+*********/
+
+/****f* OpenSM: DR Path/osm_dr_path_init
+* NAME
+* osm_dr_path_init
+*
+* DESCRIPTION
+* This function initializes a directed route path object.
+*
+* SYNOPSIS
+*/
+static inline void
+osm_dr_path_init(IN osm_dr_path_t * p_path, IN uint8_t hop_count,
+ IN const uint8_t path[IB_SUBNET_PATH_HOPS_MAX])
+{
+ /* The first location in the path array is reserved. */
+ CL_ASSERT(path[0] == 0);
+ CL_ASSERT(hop_count < IB_SUBNET_PATH_HOPS_MAX);
+ p_path->hop_count = hop_count;
+ memcpy(p_path->path, path, hop_count + 1);
+}
+
+/*
+* PARAMETERS
+* p_path
+* [in] Pointer to a directed route path object to initialize.
+*
+* h_bind
+* [in] Bind handle for the port on which this path applies.
+*
+* hop_count
+* [in] Hop count needed to reach this node.
+*
+* path
+* [in] Directed route path to reach this node.
+*
+* RETURN VALUE
+* None.
+*
+* NOTES
+*
+* SEE ALSO
+*********/
+/****f* OpenSM: DR Path/osm_dr_path_extend
+* NAME
+* osm_dr_path_extend
+*
+* DESCRIPTION
+* Adds a new hop to a path.
+*
+* SYNOPSIS
+*/
+static inline int osm_dr_path_extend(IN osm_dr_path_t * p_path,
+ IN uint8_t port_num)
+{
+ p_path->hop_count++;
+
+ if (p_path->hop_count >= IB_SUBNET_PATH_HOPS_MAX)
+ return -1;
+ /*
+ Location 0 in the path array is reserved per IB spec.
+ */
+ p_path->path[p_path->hop_count] = port_num;
+ return 0;
+}
+
+/*
+* PARAMETERS
+* p_path
+* [in] Pointer to a directed route path object to initialize.
+*
+* port_num
+* [in] Additional port to add to the DR path.
+*
+* RETURN VALUES
+* 0 indicates path was extended.
+* Other than 0 indicates path was not extended.
+*
+* NOTES
+*
+* SEE ALSO
+*********/
+
+END_C_DECLS
+#endif /* _OSM_PATH_H_ */
diff --git a/contrib/ofed/opensm/include/opensm/osm_perfmgr.h b/contrib/ofed/opensm/include/opensm/osm_perfmgr.h
new file mode 100644
index 0000000..ec12eb6
--- /dev/null
+++ b/contrib/ofed/opensm/include/opensm/osm_perfmgr.h
@@ -0,0 +1,312 @@
+/*
+ * Copyright (c) 2007 The Regents of the University of California.
+ * Copyright (c) 2007-2009 Voltaire, Inc. All rights reserved.
+ * Copyright (c) 2009,2010 HNR Consulting. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+#ifndef _OSM_PERFMGR_H_
+#define _OSM_PERFMGR_H_
+
+#if HAVE_CONFIG_H
+# include <config.h>
+#endif /* HAVE_CONFIG_H */
+
+#ifdef ENABLE_OSM_PERF_MGR
+
+#include <iba/ib_types.h>
+#include <complib/cl_passivelock.h>
+#include <complib/cl_event.h>
+#include <complib/cl_timer.h>
+#include <opensm/osm_subnet.h>
+#include <opensm/osm_log.h>
+#include <opensm/osm_perfmgr_db.h>
+#include <opensm/osm_sm.h>
+#include <opensm/osm_base.h>
+#include <opensm/osm_event_plugin.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+/****h* OpenSM/PerfMgr
+* NAME
+* PerfMgr
+*
+* DESCRIPTION
+* Performance manager thread which takes care of polling the fabric for
+* Port counters values.
+*
+* The PerfMgr object is thread safe.
+*
+* AUTHOR
+* Ira Weiny, LLNL
+*
+*********/
+
+#define OSM_PERFMGR_DEFAULT_SWEEP_TIME_S 180
+#define OSM_PERFMGR_DEFAULT_DUMP_FILE "opensm_port_counters.log"
+#define OSM_PERFMGR_DEFAULT_MAX_OUTSTANDING_QUERIES 500
+#define OSM_PERFMGR_DEFAULT_XMIT_WAIT_THRESHOLD 0x0000FFFF
+
+/****s* OpenSM: PerfMgr/osm_perfmgr_state_t */
+typedef enum {
+ PERFMGR_STATE_DISABLE,
+ PERFMGR_STATE_ENABLED,
+ PERFMGR_STATE_NO_DB
+} osm_perfmgr_state_t;
+
+/****s* OpenSM: PerfMgr/osm_perfmgr_sweep_state_t */
+typedef enum {
+ PERFMGR_SWEEP_SLEEP,
+ PERFMGR_SWEEP_ACTIVE,
+ PERFMGR_SWEEP_SUSPENDED,
+ PERFMGR_SWEEP_POST_PROCESSING
+} osm_perfmgr_sweep_state_t;
+
+typedef struct monitored_port {
+ uint16_t pkey_ix;
+ ib_net16_t orig_lid;
+ boolean_t redirection;
+ boolean_t valid;
+ /* Redirection fields from ClassPortInfo */
+ ib_gid_t gid;
+ ib_net16_t lid;
+ ib_net16_t pkey;
+ ib_net32_t qp;
+ /* ClassPortInfo fields */
+ boolean_t cpi_valid;
+ ib_net16_t cap_mask;
+ /* Remote end connected to */
+ boolean_t remote_valid;
+ uint64_t remote_guid;
+ char *remote_name;
+ uint8_t remote_port;
+} monitored_port_t;
+
+/* Node to store information about nodes being monitored */
+typedef struct monitored_node {
+ cl_map_item_t map_item;
+ struct monitored_node *next;
+ uint64_t guid;
+ uint8_t node_type;
+ boolean_t esp0;
+ char *name;
+ uint32_t num_ports;
+ monitored_port_t port[1];
+} monitored_node_t;
+
+struct osm_opensm;
+
+/****s* OpenSM: PerfMgr/osm_perfmgr_t
+* This object should be treated as opaque and should
+* be manipulated only through the provided functions.
+*/
+typedef struct osm_perfmgr {
+ cl_timer_t sweep_timer;
+ struct osm_opensm *osm;
+ osm_subn_t *subn;
+ osm_sm_t *sm;
+ osm_log_t *log;
+ osm_mad_pool_t *mad_pool;
+ atomic32_t trans_id;
+ osm_vendor_t *vendor;
+ osm_bind_handle_t bind_handle;
+ cl_disp_reg_handle_t pc_disp_h;
+ osm_perfmgr_state_t state;
+ osm_perfmgr_sweep_state_t sweep_state;
+ cl_spinlock_t lock;
+ uint16_t sweep_time_s;
+ perfmgr_db_t *db;
+ atomic32_t outstanding_queries; /* this along with sig_query */
+ cl_event_t sig_query; /* will throttle our queries */
+ uint32_t max_outstanding_queries;
+ boolean_t ignore_cas;
+ cl_qmap_t monitored_map; /* map the nodes being tracked */
+ monitored_node_t *remove_list;
+ ib_net64_t port_guid;
+ int16_t local_port;
+ int rm_nodes;
+ boolean_t query_cpi;
+ boolean_t xmit_wait_log;
+ uint32_t xmit_wait_threshold;
+} osm_perfmgr_t;
+/*
+* FIELDS
+* subn
+* Subnet object for this subnet.
+*
+* log
+* Pointer to the log object.
+*
+* mad_pool
+* Pointer to the MAD pool.
+*
+* mad_ctrl
+* Mad Controller
+*********/
+
+/****f* OpenSM: Creation Functions */
+void osm_perfmgr_shutdown(osm_perfmgr_t * p_perfmgr);
+void osm_perfmgr_destroy(osm_perfmgr_t * p_perfmgr);
+
+/****f* OpenSM: Inline accessor functions */
+inline static void osm_perfmgr_set_state(osm_perfmgr_t * p_perfmgr,
+ osm_perfmgr_state_t state)
+{
+ p_perfmgr->state = state;
+ if (state == PERFMGR_STATE_ENABLED) {
+ cl_timer_start(&p_perfmgr->sweep_timer, p_perfmgr->sweep_time_s * 1000);
+ } else {
+ cl_timer_stop(&p_perfmgr->sweep_timer);
+ }
+}
+
+inline static osm_perfmgr_state_t osm_perfmgr_get_state(osm_perfmgr_t * perfmgr)
+{
+ return perfmgr->state;
+}
+
+inline static void osm_perfmgr_set_rm_nodes(osm_perfmgr_t *perfmgr,
+ int rm_nodes)
+{
+ perfmgr->rm_nodes = rm_nodes;
+}
+
+inline static int osm_perfmgr_get_rm_nodes(osm_perfmgr_t *perfmgr)
+{
+ return perfmgr->rm_nodes;
+}
+
+inline static void osm_perfmgr_set_query_cpi(osm_perfmgr_t *perfmgr,
+ int query_cpi)
+{
+ perfmgr->query_cpi = query_cpi;
+}
+
+inline static int osm_perfmgr_get_query_cpi(osm_perfmgr_t *perfmgr)
+{
+ return perfmgr->query_cpi;
+}
+
+inline static const char *osm_perfmgr_get_state_str(osm_perfmgr_t * p_perfmgr)
+{
+ switch (p_perfmgr->state) {
+ case PERFMGR_STATE_DISABLE:
+ return "Disabled";
+ break;
+ case PERFMGR_STATE_ENABLED:
+ return "Enabled";
+ break;
+ case PERFMGR_STATE_NO_DB:
+ return "No Database";
+ break;
+ }
+ return "UNKNOWN";
+}
+
+inline static const char *osm_perfmgr_get_sweep_state_str(osm_perfmgr_t * perfmgr)
+{
+ switch (perfmgr->sweep_state) {
+ case PERFMGR_SWEEP_SLEEP:
+ return "Sleeping";
+ break;
+ case PERFMGR_SWEEP_ACTIVE:
+ return "Active";
+ break;
+ case PERFMGR_SWEEP_SUSPENDED:
+ return "Suspended";
+ break;
+ case PERFMGR_SWEEP_POST_PROCESSING:
+ return "PostProcessing";
+ break;
+ }
+ return "UNKNOWN";
+}
+
+inline static void osm_perfmgr_set_sweep_time_s(osm_perfmgr_t * p_perfmgr,
+ uint16_t time_s)
+{
+ p_perfmgr->sweep_time_s = time_s;
+ osm_sm_signal(p_perfmgr->sm, OSM_SIGNAL_PERFMGR_SWEEP);
+}
+
+inline static uint16_t osm_perfmgr_get_sweep_time_s(osm_perfmgr_t * p_perfmgr)
+{
+ return p_perfmgr->sweep_time_s;
+}
+
+inline static unsigned osm_perfmgr_delete_inactive(osm_perfmgr_t * pm)
+{
+ unsigned rc;
+ perfmgr_db_delete_inactive(pm->db, &rc);
+ return (rc);
+}
+
+void osm_perfmgr_clear_counters(osm_perfmgr_t * p_perfmgr);
+void osm_perfmgr_dump_counters(osm_perfmgr_t * p_perfmgr,
+ perfmgr_db_dump_t dump_type);
+void osm_perfmgr_print_counters(osm_perfmgr_t *pm, char *nodename, FILE *fp,
+ char *port, int err_only);
+void osm_perfmgr_update_nodename(osm_perfmgr_t *pm, uint64_t node_guid,
+ char *nodename);
+
+ib_api_status_t osm_perfmgr_bind(osm_perfmgr_t * p_perfmgr,
+ ib_net64_t port_guid);
+
+void osm_perfmgr_process(osm_perfmgr_t * pm);
+
+/****f* OpenSM: PerfMgr/osm_perfmgr_init */
+ib_api_status_t osm_perfmgr_init(osm_perfmgr_t * perfmgr,
+ struct osm_opensm *osm,
+ const osm_subn_opt_t * p_opt);
+/*
+* PARAMETERS
+* perfmgr
+* [in] Pointer to an osm_perfmgr_t object to initialize.
+*
+* osm
+* [in] Pointer to the OpenSM object.
+*
+* p_opt
+* [in] Pointer to the subnet options structure.
+*
+* RETURN VALUES
+* IB_SUCCESS if the PerfMgr object was initialized successfully.
+*********/
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* ENABLE_OSM_PERF_MGR */
+
+#endif /* _OSM_PERFMGR_H_ */
diff --git a/contrib/ofed/opensm/include/opensm/osm_perfmgr_db.h b/contrib/ofed/opensm/include/opensm/osm_perfmgr_db.h
new file mode 100644
index 0000000..25d9c58
--- /dev/null
+++ b/contrib/ofed/opensm/include/opensm/osm_perfmgr_db.h
@@ -0,0 +1,221 @@
+/*
+ * Copyright (c) 2008 Voltaire, Inc. All rights reserved.
+ * Copyright (c) 2007 The Regents of the University of California.
+ * Copyright (c) 2009 HNR Consulting. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+#ifndef _PERFMGR_EVENT_DB_H_
+#define _PERFMGR_EVENT_DB_H_
+
+#ifdef ENABLE_OSM_PERF_MGR
+
+#include <stdio.h>
+#include <time.h>
+#include <iba/ib_types.h>
+#include <complib/cl_qmap.h>
+#include <complib/cl_passivelock.h>
+
+#ifdef __cplusplus
+# define BEGIN_C_DECLS extern "C" {
+# define END_C_DECLS }
+#else /* !__cplusplus */
+# define BEGIN_C_DECLS
+# define END_C_DECLS
+#endif /* __cplusplus */
+
+BEGIN_C_DECLS
+
+struct osm_perfmgr;
+/****h* OpenSM/PerfMgr Event Database
+* DESCRIPTION
+* Database interface to record subnet events
+*
+* Implementations of this object _MUST_ be thread safe.
+*
+* AUTHOR
+* Ira Weiny, LLNL
+*
+*********/
+typedef enum {
+ PERFMGR_EVENT_DB_SUCCESS = 0,
+ PERFMGR_EVENT_DB_FAIL,
+ PERFMGR_EVENT_DB_NOMEM,
+ PERFMGR_EVENT_DB_GUIDNOTFOUND,
+ PERFMGR_EVENT_DB_PORTNOTFOUND,
+ PERFMGR_EVENT_DB_NOT_IMPL
+} perfmgr_db_err_t;
+
+/** =========================================================================
+ * Port error reading
+ */
+typedef struct {
+ uint64_t symbol_err_cnt;
+ uint64_t link_err_recover;
+ uint64_t link_downed;
+ uint64_t rcv_err;
+ uint64_t rcv_rem_phys_err;
+ uint64_t rcv_switch_relay_err;
+ uint64_t xmit_discards;
+ uint64_t xmit_constraint_err;
+ uint64_t rcv_constraint_err;
+ uint64_t link_integrity;
+ uint64_t buffer_overrun;
+ uint64_t vl15_dropped;
+ uint64_t xmit_wait;
+ time_t time;
+} perfmgr_db_err_reading_t;
+
+/** =========================================================================
+ * Port data count reading
+ */
+typedef struct {
+ uint64_t xmit_data; /* can be used for std or extended */
+ uint64_t rcv_data; /* can be used for std or extended */
+ uint64_t xmit_pkts; /* can be used for std or extended */
+ uint64_t rcv_pkts; /* can be used for std or extended */
+ uint64_t unicast_xmit_pkts;
+ uint64_t unicast_rcv_pkts;
+ uint64_t multicast_xmit_pkts;
+ uint64_t multicast_rcv_pkts;
+ time_t time;
+} perfmgr_db_data_cnt_reading_t;
+
+/** =========================================================================
+ * Dump output options
+ */
+typedef enum {
+ PERFMGR_EVENT_DB_DUMP_HR = 0, /* Human readable */
+ PERFMGR_EVENT_DB_DUMP_MR /* Machine readable */
+} perfmgr_db_dump_t;
+
+/** =========================================================================
+ * Port counter object.
+ * Store all the port counters for a single port.
+ */
+typedef struct db_port {
+ perfmgr_db_err_reading_t err_total;
+ perfmgr_db_err_reading_t err_previous;
+ perfmgr_db_data_cnt_reading_t dc_total;
+ perfmgr_db_data_cnt_reading_t dc_previous;
+ time_t last_reset;
+ boolean_t valid;
+} db_port_t;
+
+/** =========================================================================
+ * group port counters for ports into the nodes
+ */
+#define NODE_NAME_SIZE (IB_NODE_DESCRIPTION_SIZE + 1)
+typedef struct db_node {
+ cl_map_item_t map_item; /* must be first */
+ uint64_t node_guid;
+ boolean_t active; /* activly being monitored */
+ boolean_t esp0;
+ db_port_t *ports;
+ uint8_t num_ports;
+ char node_name[NODE_NAME_SIZE];
+} db_node_t;
+
+/** =========================================================================
+ * all nodes in the subnet.
+ */
+typedef struct perfmgr_db {
+ cl_qmap_t pc_data; /* stores type (db_node_t *) */
+ cl_plock_t lock;
+ struct osm_perfmgr *perfmgr;
+} perfmgr_db_t;
+
+/**
+ * functions
+ */
+perfmgr_db_t *perfmgr_db_construct(struct osm_perfmgr *perfmgr);
+void perfmgr_db_destroy(perfmgr_db_t * db);
+
+perfmgr_db_err_t perfmgr_db_create_entry(perfmgr_db_t * db, uint64_t guid,
+ boolean_t esp0, uint8_t num_ports,
+ char *node_name);
+perfmgr_db_err_t perfmgr_db_delete_entry(perfmgr_db_t * db, uint64_t guid);
+perfmgr_db_err_t perfmgr_db_delete_inactive(perfmgr_db_t * db, unsigned *cnt);
+
+perfmgr_db_err_t perfmgr_db_update_name(perfmgr_db_t * db, uint64_t node_guid,
+ char *name);
+
+perfmgr_db_err_t perfmgr_db_add_err_reading(perfmgr_db_t * db, uint64_t guid,
+ uint8_t port,
+ perfmgr_db_err_reading_t * reading);
+perfmgr_db_err_t perfmgr_db_get_prev_err(perfmgr_db_t * db, uint64_t guid,
+ uint8_t port,
+ perfmgr_db_err_reading_t * reading);
+perfmgr_db_err_t perfmgr_db_clear_prev_err(perfmgr_db_t * db, uint64_t guid,
+ uint8_t port);
+
+perfmgr_db_err_t perfmgr_db_add_dc_reading(perfmgr_db_t * db, uint64_t guid,
+ uint8_t port,
+ perfmgr_db_data_cnt_reading_t *
+ reading,
+ int ietf_sup);
+perfmgr_db_err_t perfmgr_db_get_prev_dc(perfmgr_db_t * db, uint64_t guid,
+ uint8_t port,
+ perfmgr_db_data_cnt_reading_t *
+ reading);
+perfmgr_db_err_t perfmgr_db_clear_prev_dc(perfmgr_db_t * db, uint64_t guid,
+ uint8_t port);
+
+perfmgr_db_err_t perfmgr_db_mark_active(perfmgr_db_t *db, uint64_t guid,
+ boolean_t active);
+
+void perfmgr_db_clear_counters(perfmgr_db_t * db);
+perfmgr_db_err_t perfmgr_db_dump(perfmgr_db_t * db, char *file,
+ perfmgr_db_dump_t dump_type);
+void perfmgr_db_print_all(perfmgr_db_t * db, FILE *fp, int err_only);
+void perfmgr_db_print_by_name(perfmgr_db_t * db, char *nodename, FILE *fp,
+ char *port, int err_only);
+void perfmgr_db_print_by_guid(perfmgr_db_t * db, uint64_t guid, FILE *fp,
+ char *port, int err_only);
+
+/** =========================================================================
+ * helper functions to fill in the various db objects from wire objects
+ */
+
+void perfmgr_db_fill_err_read(ib_port_counters_t * wire_read,
+ perfmgr_db_err_reading_t * reading,
+ boolean_t xmit_wait_sup);
+void perfmgr_db_fill_data_cnt_read_pc(ib_port_counters_t * wire_read,
+ perfmgr_db_data_cnt_reading_t * reading);
+void perfmgr_db_fill_data_cnt_read_pce(ib_port_counters_ext_t * wire_read,
+ perfmgr_db_data_cnt_reading_t * reading,
+ int ietf_sup);
+
+END_C_DECLS
+
+#endif /* ENABLE_OSM_PERF_MGR */
+
+#endif /* _PERFMGR_PM_DB_H_ */
diff --git a/contrib/ofed/opensm/include/opensm/osm_pkey.h b/contrib/ofed/opensm/include/opensm/osm_pkey.h
new file mode 100644
index 0000000..de4f2f9
--- /dev/null
+++ b/contrib/ofed/opensm/include/opensm/osm_pkey.h
@@ -0,0 +1,730 @@
+/*
+ * Copyright (c) 2010 Sun Microsystems, Inc. All rights reserved.
+ * Copyright (c) 2004-2009 Voltaire, Inc. All rights reserved.
+ * Copyright (c) 2002-2012 Mellanox Technologies LTD. All rights reserved.
+ * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+#ifndef _OSM_PKEY_H_
+#define _OSM_PKEY_H_
+
+#include <iba/ib_types.h>
+#include <complib/cl_dispatcher.h>
+#include <complib/cl_map.h>
+#include <opensm/osm_base.h>
+#include <opensm/osm_log.h>
+#include <opensm/osm_msgdef.h>
+
+#ifdef __cplusplus
+# define BEGIN_C_DECLS extern "C" {
+# define END_C_DECLS }
+#else /* !__cplusplus */
+# define BEGIN_C_DECLS
+# define END_C_DECLS
+#endif /* __cplusplus */
+
+BEGIN_C_DECLS
+/*
+ Forward references.
+*/
+struct osm_physp;
+struct osm_port;
+struct osm_subn;
+struct osm_node;
+struct osm_physp;
+
+/*
+ * Abstract:
+ * Declaration of pkey manipulation functions.
+ */
+
+/****s* OpenSM: osm_pkey_tbl_t
+* NAME
+* osm_pkey_tbl_t
+*
+* DESCRIPTION
+* This object represents a pkey table. The need for a special object
+* is required to optimize search performance of a PKey in the IB standard
+* non sorted table.
+*
+* The osm_pkey_tbl_t object should be treated as opaque and should
+* be manipulated only through the provided functions.
+*
+* SYNOPSIS
+*/
+typedef struct osm_pkeybl {
+ cl_map_t accum_pkeys;
+ cl_ptr_vector_t blocks;
+ cl_ptr_vector_t new_blocks;
+ cl_map_t keys;
+ cl_qlist_t pending;
+ uint16_t last_pkey_idx;
+ uint16_t used_blocks;
+ uint16_t max_blocks;
+ uint16_t rcv_blocks_cnt;
+ uint16_t indx0_pkey;
+} osm_pkey_tbl_t;
+/*
+* FIELDS
+* accum_pkeys
+* Accumulated pkeys with pkey index. Used to
+* preserve pkey index.
+*
+* blocks
+* The IBA defined blocks of pkey values, updated from the subnet
+*
+* new_blocks
+* The blocks of pkey values, will be used for updates by SM
+*
+* keys
+* A set holding all keys
+*
+* pending
+* A list of osm_pending_pkey structs that is temporarily set by
+* the pkey mgr and used during pkey mgr algorithm only
+*
+* used_blocks
+* Tracks the number of blocks having non-zero pkeys
+*
+* max_blocks
+* The maximal number of blocks this partition table might hold
+* this value is based on node_info (for port 0 or CA) or
+* switch_info updated on receiving the node_info or switch_info
+* GetResp
+*
+* rcv_blocks_cnt
+* Counter for the received GetPKeyTable mads.
+* For every GetPKeyTable mad we send, increase the counter,
+* and for every GetRespPKeyTable we decrease the counter.
+*
+* indx0_pkey
+* stores the pkey to be inserted at block 0 index 0.
+* if this field is 0, the default pkey will be inserted.
+*
+* NOTES
+* 'blocks' vector should be used to store pkey values obtained from
+* the port and SM pkey manager should not change it directly, for this
+* purpose 'new_blocks' should be used.
+*
+* The only pkey values stored in 'blocks' vector will be mapped with
+* 'keys' map
+*
+*********/
+
+/****s* OpenSM: osm_pending_pkey_t
+* NAME
+* osm_pending_pkey_t
+*
+* DESCRIPTION
+* This objects stores temporary information on pkeys, their target block,
+* and index during the pkey manager operation
+*
+* SYNOPSIS
+*/
+typedef struct osm_pending_pkey {
+ cl_list_item_t list_item;
+ uint16_t pkey;
+ uint16_t block;
+ uint8_t index;
+ boolean_t is_new;
+} osm_pending_pkey_t;
+/*
+* FIELDS
+* pkey
+* The actual P_Key
+*
+* block
+* The block index based on the previous table extracted from the
+* device
+*
+* index
+* The index of the pkey within the block
+*
+* is_new
+* TRUE for new P_Keys such that the block and index are invalid
+* in that case
+*
+*********/
+
+/****f* OpenSM: osm_pkey_tbl_construct
+* NAME
+* osm_pkey_tbl_construct
+*
+* DESCRIPTION
+* Constructs the PKey table object
+*
+* SYNOPSIS
+*/
+void osm_pkey_tbl_construct(IN osm_pkey_tbl_t * p_pkey_tbl);
+/*
+* p_pkey_tbl
+* [in] Pointer to osm_pkey_tbl_t object.
+*
+* NOTES
+*
+*********/
+
+/****f* OpenSM: osm_pkey_tbl_init
+* NAME
+* osm_pkey_tbl_init
+*
+* DESCRIPTION
+* Inits the PKey table object
+*
+* SYNOPSIS
+*/
+ib_api_status_t osm_pkey_tbl_init(IN osm_pkey_tbl_t * p_pkey_tbl);
+/*
+* p_pkey_tbl
+* [in] Pointer to osm_pkey_tbl_t object.
+*
+* NOTES
+*
+*********/
+
+/****f* OpenSM: osm_pkey_tbl_destroy
+* NAME
+* osm_pkey_tbl_destroy
+*
+* DESCRIPTION
+* Destroys the PKey table object
+*
+* SYNOPSIS
+*/
+void osm_pkey_tbl_destroy(IN osm_pkey_tbl_t * p_pkey_tbl);
+/*
+* p_pkey_tbl
+* [in] Pointer to osm_pkey_tbl_t object.
+*
+* NOTES
+*
+*********/
+
+/****f* OpenSM: osm_pkey_tbl_get_num_blocks
+* NAME
+* osm_pkey_tbl_get_num_blocks
+*
+* DESCRIPTION
+* Obtain the number of blocks in IB PKey table
+*
+* SYNOPSIS
+*/
+static inline uint16_t
+osm_pkey_tbl_get_num_blocks(IN const osm_pkey_tbl_t * p_pkey_tbl)
+{
+ return ((uint16_t) (cl_ptr_vector_get_size(&p_pkey_tbl->blocks)));
+}
+
+/*
+* p_pkey_tbl
+* [in] Pointer to osm_pkey_tbl_t object.
+*
+* RETURN VALUES
+* The IB pkey table of that pkey table element
+*
+* NOTES
+*
+*********/
+
+/****f* OpenSM: osm_pkey_tbl_block_get
+* NAME
+* osm_pkey_tbl_block_get
+*
+* DESCRIPTION
+* Obtain the pointer to the IB PKey table block stored in the object
+*
+* SYNOPSIS
+*/
+static inline ib_pkey_table_t *osm_pkey_tbl_block_get(const osm_pkey_tbl_t *
+ p_pkey_tbl,
+ uint16_t block)
+{
+ return ((block < cl_ptr_vector_get_size(&p_pkey_tbl->blocks)) ?
+ (ib_pkey_table_t *)cl_ptr_vector_get(
+ &p_pkey_tbl->blocks, block) : NULL);
+};
+
+/*
+* p_pkey_tbl
+* [in] Pointer to osm_pkey_tbl_t object.
+*
+* block
+* [in] The block number to get
+*
+* RETURN VALUES
+* The IB pkey table of that pkey table element
+*
+* NOTES
+*
+*********/
+
+/****f* OpenSM: osm_pkey_tbl_new_block_get
+* NAME
+* osm_pkey_tbl_new_block_get
+*
+* DESCRIPTION
+* The same as above but for new block
+*
+* SYNOPSIS
+*/
+static inline ib_pkey_table_t *osm_pkey_tbl_new_block_get(const osm_pkey_tbl_t *
+ p_pkey_tbl,
+ uint16_t block)
+{
+ return ((block < cl_ptr_vector_get_size(&p_pkey_tbl->new_blocks)) ?
+ (ib_pkey_table_t *)cl_ptr_vector_get(
+ &p_pkey_tbl->new_blocks, block) : NULL);
+};
+
+/****f* OpenSM: osm_pkey_find_last_accum_pkey_index
+ * NAME
+ * osm_pkey_find_last_accum_pkey_index
+ *
+ * DESCRIPTION
+ * Finds the next last accumulated pkey
+ *
+ * SYNOPSIS
+ */
+void osm_pkey_find_last_accum_pkey_index(IN osm_pkey_tbl_t * p_pkey_tbl);
+
+
+/****f* OpenSM: osm_pkey_tbl_set_accum_pkeys
+* NAME
+* osm_pkey_tbl_set_accum_pkeys
+*
+* DESCRIPTION
+* Stores the given pkey and pkey index in the "accum_pkeys" array
+*
+* SYNOPSIS
+*/
+cl_status_t
+osm_pkey_tbl_set_accum_pkeys(IN osm_pkey_tbl_t * p_pkey_tbl,
+ IN uint16_t pkey, IN uint16_t pkey_idx);
+/*
+* p_pkey_tbl
+* [in] Pointer to the PKey table
+*
+* pkey
+* [in] PKey to store
+*
+* pkey_idx
+* [in] The overall index
+*
+* RETURN VALUES
+* CL_SUCCESS if OK
+* CL_INSUFFICIENT_MEMORY if failed
+*
+*********/
+
+/****f* OpenSM: osm_pkey_tbl_set_new_entry
+* NAME
+* osm_pkey_tbl_set_new_entry
+*
+* DESCRIPTION
+* Stores the given pkey in the "new" blocks array and update
+* the "map" to show that on the "old" blocks
+*
+* SYNOPSIS
+*/
+ib_api_status_t
+osm_pkey_tbl_set_new_entry(IN osm_pkey_tbl_t * p_pkey_tbl,
+ IN uint16_t block_idx,
+ IN uint8_t pkey_idx, IN uint16_t pkey);
+/*
+* p_pkey_tbl
+* [in] Pointer to the PKey table
+*
+* block_idx
+* [in] The block index to use
+*
+* pkey_idx
+* [in] The index within the block
+*
+* pkey
+* [in] PKey to store
+*
+* RETURN VALUES
+* IB_SUCCESS if OK
+* IB_ERROR if failed
+*
+*********/
+
+/****f* OpenSM: osm_pkey_find_next_free_entry
+* NAME
+* osm_pkey_find_next_free_entry
+*
+* DESCRIPTION
+* Find the next free entry in the PKey table starting at the given
+* index and block number. The user should increment pkey_idx before
+* next call
+* Inspect the "new" blocks array for empty space.
+*
+* SYNOPSIS
+*/
+boolean_t
+osm_pkey_find_next_free_entry(IN osm_pkey_tbl_t * p_pkey_tbl,
+ OUT uint16_t * p_block_idx,
+ OUT uint8_t * p_pkey_idx);
+/*
+* p_pkey_tbl
+* [in] Pointer to the PKey table
+*
+* p_block_idx
+* [out] The block index to use
+*
+* p_pkey_idx
+* [out] The index within the block to use
+*
+* RETURN VALUES
+* TRUE if found
+* FALSE if did not find
+*
+*********/
+
+/****f* OpenSM: osm_pkey_tbl_init_new_blocks
+* NAME
+* osm_pkey_tbl_init_new_blocks
+*
+* DESCRIPTION
+* Initializes new_blocks vector content (allocate and clear)
+*
+* SYNOPSIS
+*/
+void osm_pkey_tbl_init_new_blocks(const osm_pkey_tbl_t * p_pkey_tbl);
+/*
+* p_pkey_tbl
+* [in] Pointer to osm_pkey_tbl_t object.
+*
+* NOTES
+*
+*********/
+
+/****f* OpenSM: osm_pkey_tbl_get_block_and_idx
+* NAME
+* osm_pkey_tbl_get_block_and_idx
+*
+* DESCRIPTION
+* Set the block index and pkey index the given
+* pkey is found in. Return IB_NOT_FOUND if could
+* not find it, IB_SUCCESS if OK
+*
+* SYNOPSIS
+*/
+ib_api_status_t
+osm_pkey_tbl_get_block_and_idx(IN osm_pkey_tbl_t * p_pkey_tbl,
+ IN uint16_t * p_pkey,
+ OUT uint16_t * block_idx,
+ OUT uint8_t * pkey_index);
+/*
+* p_pkey_tbl
+* [in] Pointer to osm_pkey_tbl_t object.
+*
+* p_pkey
+* [in] Pointer to the P_Key entry searched
+*
+* p_block_idx
+* [out] Pointer to the block index to be updated
+*
+* p_pkey_idx
+* [out] Pointer to the pkey index (in the block) to be updated
+*
+* NOTES
+*
+*********/
+
+/****f* OpenSM: osm_pkey_tbl_set
+* NAME
+* osm_pkey_tbl_set
+*
+* DESCRIPTION
+* Set the PKey table block provided in the PKey object.
+*
+* SYNOPSIS
+*/
+ib_api_status_t
+osm_pkey_tbl_set(IN osm_pkey_tbl_t * p_pkey_tbl,
+ IN uint16_t block, IN ib_pkey_table_t * p_tbl,
+ IN boolean_t allow_both_pkeys);
+/*
+* p_pkey_tbl
+* [in] Pointer to osm_pkey_tbl_t object
+*
+* block
+* [in] The block number to set
+*
+* p_tbl
+* [in] The IB PKey block to copy to the object
+*
+* allow_both_pkeys
+* [in] Whether both full and limited membership on same partition
+* are allowed
+*
+* RETURN VALUES
+* IB_SUCCESS or IB_ERROR
+*
+* NOTES
+*
+*********/
+
+/****f* OpenSM: osm_physp_share_this_pkey
+* NAME
+* osm_physp_share_this_pkey
+*
+* DESCRIPTION
+* Checks if the given physical ports share the specified pkey.
+*
+* SYNOPSIS
+*/
+boolean_t osm_physp_share_this_pkey(IN const struct osm_physp * p_physp1,
+ IN const struct osm_physp * p_physp2,
+ IN ib_net16_t pkey,
+ IN boolean_t allow_both_pkeys);
+/*
+* PARAMETERS
+*
+* p_physp1
+* [in] Pointer to an osm_physp_t object.
+*
+* p_physp2
+* [in] Pointer to an osm_physp_t object.
+*
+* pkey
+* [in] value of P_Key to check.
+*
+* allow_both_pkeys
+* [in] whether both pkeys allowed policy is being used.
+*
+* RETURN VALUES
+* Returns TRUE if the two ports are matching.
+* FALSE otherwise.
+*
+* NOTES
+*
+*********/
+
+/****f* OpenSM: osm_physp_find_common_pkey
+* NAME
+* osm_physp_find_common_pkey
+*
+* DESCRIPTION
+* Returns first matching P_Key values for specified physical ports.
+*
+* SYNOPSIS
+*/
+ib_net16_t osm_physp_find_common_pkey(IN const struct osm_physp *p_physp1,
+ IN const struct osm_physp *p_physp2,
+ IN boolean_t allow_both_pkeys);
+/*
+* PARAMETERS
+*
+* p_physp1
+* [in] Pointer to an osm_physp_t object.
+*
+* p_physp2
+* [in] Pointer to an osm_physp_t object.
+*
+* allow_both_pkeys
+* [in] Whether both full and limited membership on same partition
+* are allowed
+*
+* RETURN VALUES
+* Returns value of first shared P_Key or INVALID P_Key (0x0) if not
+* found.
+*
+* NOTES
+*
+*********/
+
+/****f* OpenSM: osm_physp_share_pkey
+* NAME
+* osm_physp_share_pkey
+*
+* DESCRIPTION
+* Checks if the given physical ports share a pkey.
+* The meaning P_Key matching:
+* 10.9.3 :
+* In the following, let M_P_Key(Message P_Key) be the P_Key in the incoming
+* packet and E_P_Key(Endnode P_Key) be the P_Key it is being compared against
+* in the packet's destination endnode.
+*
+* If:
+* * neither M_P_Key nor E_P_Key are the invalid P_Key
+* * and the low-order 15 bits of the M_P_Key match the low order 15
+* bits of the E_P_Key
+* * and the high order bit(membership type) of both the M_P_Key and
+* E_P_Key are not both 0 (i.e., both are not Limited members of
+* the partition)
+*
+* then the P_Keys are said to match.
+*
+* SYNOPSIS
+*/
+boolean_t osm_physp_share_pkey(IN osm_log_t * p_log,
+ IN const struct osm_physp * p_physp_1,
+ IN const struct osm_physp * p_physp_2,
+ IN boolean_t allow_both_pkeys);
+
+/*
+* PARAMETERS
+* p_log
+* [in] Pointer to a log object.
+*
+* p_physp_1
+* [in] Pointer to an osm_physp_t object.
+*
+* p_physp_2
+* [in] Pointer to an osm_physp_t object.
+*
+* allow_both_pkeys
+* [in] Whether both full and limited membership on same partition
+* are allowed
+*
+* RETURN VALUES
+* Returns TRUE if the 2 physical ports are matching.
+* FALSE otherwise.
+*
+* NOTES
+*
+*********/
+
+/****f* OpenSM: osm_port_share_pkey
+* NAME
+* osm_port_share_pkey
+*
+* DESCRIPTION
+* Checks if the given ports (on their default physical port) share a pkey.
+* The meaning P_Key matching:
+* 10.9.3 :
+* In the following, let M_P_Key(Message P_Key) be the P_Key in the incoming
+* packet and E_P_Key(Endnode P_Key) be the P_Key it is being compared against
+* in the packet's destination endnode.
+*
+* If:
+* * neither M_P_Key nor E_P_Key are the invalid P_Key
+* * and the low-order 15 bits of the M_P_Key match the low order 15
+* bits of the E_P_Key
+* * and the high order bit(membership type) of both the M_P_Key and
+* E_P_Key are not both 0 (i.e., both are not Limited members of
+* the partition)
+*
+* then the P_Keys are said to match.
+*
+* SYNOPSIS
+*/
+boolean_t osm_port_share_pkey(IN osm_log_t * p_log,
+ IN const struct osm_port * p_port_1,
+ IN const struct osm_port * p_port_2,
+ IN boolean_t allow_both_pkeys);
+
+/*
+* PARAMETERS
+* p_log
+* [in] Pointer to a log object.
+*
+* p_port_1
+* [in] Pointer to an osm_port_t object.
+*
+* p_port_2
+* [in] Pointer to an osm_port_t object.
+*
+* RETURN VALUES
+* Returns TRUE if the 2 ports are matching.
+* FALSE otherwise.
+*
+* NOTES
+*
+*********/
+
+/****f* OpenSM: osm_physp_has_pkey
+* NAME
+* osm_physp_has_pkey
+*
+* DESCRIPTION
+* Given a physp and a pkey, check if pkey exists in physp pkey table
+*
+* SYNOPSIS
+*/
+boolean_t osm_physp_has_pkey(IN osm_log_t * p_log, IN ib_net16_t pkey,
+ IN const struct osm_physp *p_physp);
+
+/*
+* PARAMETERS
+* p_log
+* [in] Pointer to a log object.
+*
+* pkey
+* [in] pkey number to look for.
+*
+* p_physp
+* [in] Pointer to osm_physp_t object.
+*
+* RETURN VALUES
+* Returns TRUE if the p_physp has the pkey given. False otherwise.
+*
+* NOTES
+*
+*********/
+
+/****f* OpenSM: osm_pkey_tbl_set_indx0_pkey
+* NAME
+* osm_pkey_tbl_set_indx0_pkey
+*
+* DESCRIPTION
+* Sets given pkey at index0 in given pkey_tbl.
+*
+* SYNOPSIS
+*/
+void osm_pkey_tbl_set_indx0_pkey(IN osm_log_t * p_log, IN ib_net16_t pkey,
+ IN boolean_t full,
+ OUT osm_pkey_tbl_t * p_pkey_tbl);
+/*
+* PARAMETERS
+* p_log
+* [in] Pointer to a log object.
+*
+* pkey
+* [in] P_Key.
+*
+* full
+* [in] Indication if this is a full/limited membership pkey.
+*
+* p_pkey_tbl
+* [out] Pointer to osm_pkey_tbl_t object in which to set indx0 pkey.
+*
+* RETURN VALUES
+* None
+*
+* NOTES
+*
+*********/
+END_C_DECLS
+#endif /* _OSM_PKEY_H_ */
diff --git a/contrib/ofed/opensm/include/opensm/osm_port.h b/contrib/ofed/opensm/include/opensm/osm_port.h
new file mode 100644
index 0000000..5ef4453
--- /dev/null
+++ b/contrib/ofed/opensm/include/opensm/osm_port.h
@@ -0,0 +1,1701 @@
+/*
+ * Copyright (c) 2004-2009 Voltaire, Inc. All rights reserved.
+ * Copyright (c) 2002-2011 Mellanox Technologies LTD. All rights reserved.
+ * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+/*
+ * Abstract:
+ * Declaration of port related objects.
+ * These objects comprise an IBA port.
+ * These objects are part of the OpenSM family of objects.
+ */
+
+#ifndef _OSM_PORT_H_
+#define _OSM_PORT_H_
+
+#include <complib/cl_qmap.h>
+#include <iba/ib_types.h>
+#include <opensm/osm_base.h>
+#include <opensm/osm_subnet.h>
+#include <opensm/osm_madw.h>
+#include <opensm/osm_path.h>
+#include <opensm/osm_pkey.h>
+
+#ifdef __cplusplus
+# define BEGIN_C_DECLS extern "C" {
+# define END_C_DECLS }
+#else /* !__cplusplus */
+# define BEGIN_C_DECLS
+# define END_C_DECLS
+#endif /* __cplusplus */
+
+BEGIN_C_DECLS
+/*
+ Forward references.
+*/
+struct osm_port;
+struct osm_node;
+struct osm_mgrp;
+struct osm_sm;
+
+/****h* OpenSM/Physical Port
+* NAME
+* Physical Port
+*
+* DESCRIPTION
+* The Physical Port object encapsulates the information needed by the
+* OpenSM to manage physical ports. The OpenSM allocates one Physical Port
+* per physical port in the IBA subnet.
+*
+* In a switch, one multiple Physical Port objects share the same port GUID.
+* In an end-point, Physical Ports do not share GUID values.
+*
+* The Physical Port is not thread safe, thus callers must provide
+* serialization.
+*
+* These objects should be treated as opaque and should be
+* manipulated only through the provided functions.
+*
+* AUTHOR
+* Steve King, Intel
+*
+*********/
+
+/****s* OpenSM: Physical Port/osm_physp_t
+* NAME
+* osm_physp_t
+*
+* DESCRIPTION
+* This object represents a physical port on a switch, router or end-point.
+*
+* The osm_physp_t object should be treated as opaque and should
+* be manipulated only through the provided functions.
+*
+* SYNOPSIS
+*/
+typedef struct osm_physp {
+ ib_port_info_t port_info;
+ ib_mlnx_ext_port_info_t ext_port_info;
+ ib_net64_t port_guid;
+ ib_net64_t (*p_guids)[];
+ uint8_t port_num;
+ struct osm_node *p_node;
+ struct osm_physp *p_remote_physp;
+ boolean_t healthy;
+ uint8_t vl_high_limit;
+ unsigned need_update;
+ unsigned is_prof_ignored;
+ osm_dr_path_t dr_path;
+ osm_pkey_tbl_t pkeys;
+ ib_vl_arb_table_t vl_arb[4];
+ cl_ptr_vector_t slvl_by_port;
+ uint8_t hop_wf;
+ union {
+ struct {
+ ib_sw_cong_setting_t sw_cong_setting;
+ } sw;
+ struct {
+ ib_ca_cong_setting_t ca_cong_setting;
+ ib_cc_tbl_t cc_tbl[OSM_CCT_ENTRY_MAD_BLOCKS];
+ } ca;
+ } cc;
+} osm_physp_t;
+/*
+* FIELDS
+* port_info
+* The IBA defined PortInfo data for this port.
+*
+* ext_port_info
+* Mellanox vendor specific ExtendedPortInfo data for this port.
+*
+* port_guid
+* Port GUID value of this port. For switches,
+* all ports share the same GUID value.
+*
+* p_guids
+* Pointer to array of GUIDs obtained from GUIDInfo.
+* This pointer is null for switch physical/external ports
+* (used for endports only).
+*
+* port_num
+* The port number of this port. The PortInfo also
+* contains a port_number, but that number is not
+* the port number of this port, but rather the number
+* of the port that received the SMP during discovery.
+* Therefore, we must keep a separate record for this
+* port's port number.
+*
+* p_node
+* Pointer to the parent Node object of this Physical Port.
+*
+* p_remote_physp
+* Pointer to the Physical Port on the other side of the wire.
+* If this pointer is NULL no link exists at this port.
+*
+* healthy
+* Tracks the health of the port. Normally should be TRUE but
+* might change as a result of incoming traps indicating the port
+* healthy is questionable.
+*
+* vl_high_limit
+* PortInfo:VLHighLimit value which installed by QoS manager
+* and should be uploaded to port's PortInfo
+*
+* need_update
+* When set indicates that port was probably reset and port
+* related tables (PKey, SL2VL, VLArb) require refreshing.
+*
+* is_prof_ignored
+* When set indicates that switch port will be ignored by
+* the link load equalization algorithm.
+*
+* dr_path
+* The directed route path to this port.
+*
+* pkeys
+* osm_pkey_tbl_t object holding the port PKeys.
+*
+* vl_arb[]
+* Each Physical Port has 4 sections of VL Arbitration table.
+*
+* slvl_by_port
+* A vector of pointers to the sl2vl tables (ordered by input port).
+* Switches have an entry for every other input port (inc SMA=0).
+* On CAs only one per port.
+*
+* hop_wf
+* Hop weighting factor to be used in the routing.
+*
+* sw_cong_setting
+* Physical port switch congestion settings (switches only)
+*
+* ca_cong_setting
+* Physical port ca congestion settings (cas only)
+*
+* cc_tbl
+* Physical port ca congestion control table (cas only)
+*
+* SEE ALSO
+* Port
+*********/
+
+/****f* OpenSM: Physical Port/osm_physp_construct
+* NAME
+* osm_physp_construct
+*
+* DESCRIPTION
+* Constructs a Physical Port.
+*
+* SYNOPSIS
+*/
+void osm_physp_construct(IN osm_physp_t * p_physp);
+/*
+* PARAMETERS
+* p_physp
+* [in] Pointer to an osm_physp_t object to initialize.
+*
+* RETURN VALUES
+* This function does not return a value.
+*
+* NOTES
+*
+* SEE ALSO
+* Port, Physical Port
+*********/
+
+/****f* OpenSM: Physical Port/osm_physp_init
+* NAME
+* osm_physp_init
+*
+* DESCRIPTION
+* Initializes a Physical Port for use.
+*
+* SYNOPSIS
+*/
+void osm_physp_init(IN osm_physp_t * p_physp, IN ib_net64_t port_guid,
+ IN uint8_t port_num, IN const struct osm_node *p_node,
+ IN osm_bind_handle_t h_bind, IN uint8_t hop_count,
+ IN const uint8_t * p_initial_path);
+/*
+* PARAMETERS
+* p_physp
+* [in] Pointer to an osm_physp_t object to initialize.
+*
+* port_guid
+* [in] GUID value of this port. Switch ports all share
+* the same value.
+* Caller should use 0 if the guid is unknown.
+*
+* port_num
+* [in] The port number of this port.
+*
+* p_node
+* [in] Pointer to the parent Node object of this Physical Port.
+*
+* h_bind
+* [in] Bind handle on which this port is accessed.
+* Caller should use OSM_BIND_INVALID_HANDLE if the bind
+* handle to this port is unknown.
+*
+* hop_count
+* [in] Directed route hop count to reach this port.
+* Caller should use 0 if the hop count is unknown.
+*
+* p_initial_path
+* [in] Pointer to the directed route path to reach this node.
+* Caller should use NULL if the path is unknown.
+*
+* RETURN VALUES
+* This function does not return a value.
+*
+* NOTES
+*
+* SEE ALSO
+* Port, Physical Port
+*********/
+
+/****f* OpenSM: Port/void osm_physp_destroy
+* NAME
+* osm_physp_destroy
+*
+* DESCRIPTION
+* This function destroys a Port object.
+*
+* SYNOPSIS
+*/
+void osm_physp_destroy(IN osm_physp_t * p_physp);
+/*
+* PARAMETERS
+* p_port
+* [in] Pointer to a PhysPort object to destroy.
+*
+* RETURN VALUE
+* This function does not return a value.
+*
+* NOTES
+* Performs any necessary cleanup of the specified PhysPort object.
+* Further operations should not be attempted on the destroyed object.
+* This function should only be called after a call to osm_physp_construct or
+* osm_physp_init.
+*
+* SEE ALSO
+* Port
+*********/
+
+/****f* OpenSM: Physical Port/osm_physp_is_valid
+* NAME
+* osm_physp_is_valid
+*
+* DESCRIPTION
+* Returns TRUE if the Physical Port has been successfully initialized.
+* FALSE otherwise.
+*
+* SYNOPSIS
+*/
+static inline boolean_t osm_physp_is_valid(IN const osm_physp_t * p_physp)
+{
+ CL_ASSERT(p_physp);
+ return (p_physp->port_guid != 0);
+}
+
+/*
+* PARAMETERS
+* p_physp
+* [in] Pointer to an osm_physp_t object.
+*
+* RETURN VALUES
+* Returns TRUE if the Physical Port has been successfully initialized.
+* FALSE otherwise.
+*
+* NOTES
+*
+* SEE ALSO
+* Port, Physical Port
+*********/
+
+/****f* OpenSM: Physical Port/osm_physp_is_healthy
+* NAME
+* osm_physp_is_healthy
+*
+* DESCRIPTION
+* Returns TRUE if the Physical Port has been maked as healthy
+* FALSE otherwise.
+*
+* SYNOPSIS
+*/
+static inline boolean_t osm_physp_is_healthy(IN const osm_physp_t * p_physp)
+{
+ CL_ASSERT(p_physp);
+ return p_physp->healthy;
+}
+
+/*
+* PARAMETERS
+* p_physp
+* [in] Pointer to an osm_physp_t object.
+*
+* RETURN VALUES
+* Returns TRUE if the Physical Port has been maked as healthy
+* FALSE otherwise.
+* All physical ports are initialized as "healthy" but may be marked
+* otherwise if a received trap claims otherwise.
+*
+* NOTES
+*
+* SEE ALSO
+* Port, Physical Port
+*********/
+
+/****f* OpenSM: Physical Port/osm_link_is_healthy
+* NAME
+* osm_link_is_healthy
+*
+* DESCRIPTION
+* Returns TRUE if the link given by the physical port is health,
+* and FALSE otherwise. Link is healthy if both its physical ports are
+* healthy
+*
+* SYNOPSIS
+*/
+boolean_t osm_link_is_healthy(IN const osm_physp_t * p_physp);
+/*
+* PARAMETERS
+* p_physp
+* [in] Pointer to an osm_physp_t object.
+*
+* RETURN VALUES
+* TRUE if both physical ports on the link are healthy, and FALSE otherwise.
+* All physical ports are initialized as "healthy" but may be marked
+* otherwise if a received trap claiming otherwise.
+*
+* NOTES
+*
+* SEE ALSO
+* Port, Physical Port
+*********/
+
+/****f* OpenSM: Physical Port/osm_physp_set_health
+* NAME
+* osm_physp_set_health
+*
+* DESCRIPTION
+* Sets the port health flag. TRUE means the port is healthy and
+* should be used for packet routing. FALSE means it should be avoided.
+*
+* SYNOPSIS
+*/
+static inline void osm_physp_set_health(IN osm_physp_t * p_physp,
+ IN boolean_t is_healthy)
+{
+ CL_ASSERT(p_physp);
+ p_physp->healthy = is_healthy;
+}
+
+/*
+* PARAMETERS
+* p_physp
+* [in] Pointer to an osm_physp_t object.
+*
+* is_healthy
+* [in] The health value to be assigned to the port.
+* TRUE if the Physical Port should been maked as healthy
+* FALSE otherwise.
+*
+* RETURN VALUES
+* NONE
+*
+* NOTES
+*
+* SEE ALSO
+* Port, Physical Port
+*********/
+
+/****f* OpenSM: Physical Port/osm_physp_set_port_info
+* NAME
+* osm_physp_set_port_info
+*
+* DESCRIPTION
+* Copies the PortInfo attribute into the Physical Port object
+* based on the PortState.
+*
+* SYNOPSIS
+*/
+void osm_physp_set_port_info(IN osm_physp_t * p_physp,
+ IN const ib_port_info_t * p_pi,
+ IN const struct osm_sm * p_sm);
+
+/*
+* PARAMETERS
+* p_physp
+* [in] Pointer to an osm_physp_t object.
+*
+* p_pi
+* [in] Pointer to the IBA defined PortInfo at this port number.
+*
+* p_sm
+* [in] Pointer to an osm_sm_t object.
+*
+* RETURN VALUES
+* This function does not return a value.
+*
+* NOTES
+*
+* SEE ALSO
+* Port, Physical Port
+*********/
+
+/****f* OpenSM: Physical Port/osm_physp_set_base_lid
+* NAME
+* osm_physp_set_base_lid
+*
+* DESCRIPTION
+* Sets the base lid for this Physical Port.
+*
+* SYNOPSIS
+*/
+static inline void osm_physp_set_base_lid(IN osm_physp_t * p_physp,
+ IN ib_net16_t base_lid)
+{
+ CL_ASSERT(p_physp);
+ CL_ASSERT(osm_physp_is_valid(p_physp));
+ p_physp->port_info.base_lid = base_lid;
+}
+
+/*
+* PARAMETERS
+* p_physp
+* [in] Pointer to an osm_physp_t object.
+*
+* base_lid
+* [in] Lid to set.
+*
+* NOTES
+*
+* SEE ALSO
+*********/
+
+/****f* OpenSM: Physical Port/osm_physp_set_pkey_tbl
+* NAME
+* osm_physp_set_pkey_tbl
+*
+* DESCRIPTION
+* Copies the P_Key table into the Physical Port object.
+*
+* SYNOPSIS
+*/
+void osm_physp_set_pkey_tbl(IN osm_log_t * p_log, IN const osm_subn_t * p_subn,
+ IN osm_physp_t * p_physp,
+ IN ib_pkey_table_t * p_pkey_tbl,
+ IN uint16_t block_num,
+ IN boolean_t is_set);
+/*
+* PARAMETERS
+* p_log
+* [in] Pointer to a log object.
+*
+* p_subn
+* [in] Pointer to the subnet data structure.
+*
+* p_physp
+* [in] Pointer to an osm_physp_t object.
+*
+* p_pkey_tbl
+* [in] Pointer to the IBA defined P_Key table for this port
+* number.
+*
+* block_num
+* [in] The part of the P_Key table as defined in the IBA
+* (valid values 0-2047, and is further limited by the
+* partitionCap).
+*
+* RETURN VALUES
+* This function does not return a value.
+*
+* NOTES
+*
+* SEE ALSO
+* Port, Physical Port
+*********/
+
+/****f* OpenSM: Physical Port/osm_physp_get_pkey_tbl
+* NAME
+* osm_physp_get_pkey_tbl
+*
+* DESCRIPTION
+* Returns a pointer to the P_Key table object of the Physical Port object.
+*
+* SYNOPSIS
+*/
+static inline const osm_pkey_tbl_t *osm_physp_get_pkey_tbl(IN const osm_physp_t
+ * p_physp)
+{
+ CL_ASSERT(osm_physp_is_valid(p_physp));
+ /*
+ (14.2.5.7) - the block number valid values are 0-2047, and are
+ further limited by the size of the P_Key table specified by the
+ PartitionCap on the node.
+ */
+ return &p_physp->pkeys;
+};
+
+/*
+* PARAMETERS
+* p_physp
+* [in] Pointer to an osm_physp_t object.
+*
+* RETURN VALUES
+* The pointer to the P_Key table object.
+*
+* NOTES
+*
+* SEE ALSO
+* Port, Physical Port
+*********/
+
+/****f* OpenSM: Physical Port/osm_physp_set_slvl_tbl
+* NAME
+* osm_physp_set_slvl_tbl
+*
+* DESCRIPTION
+* Copies the SLtoVL attribute into the Physical Port object.
+*
+* SYNOPSIS
+*/
+static inline void osm_physp_set_slvl_tbl(IN osm_physp_t * p_physp,
+ IN ib_slvl_table_t * p_slvl_tbl,
+ IN uint8_t in_port_num)
+{
+ ib_slvl_table_t *p_tbl;
+
+ CL_ASSERT(p_slvl_tbl);
+ CL_ASSERT(osm_physp_is_valid(p_physp));
+ p_tbl = (ib_slvl_table_t *)cl_ptr_vector_get(&p_physp->slvl_by_port, in_port_num);
+ *p_tbl = *p_slvl_tbl;
+}
+
+/*
+* PARAMETERS
+* p_physp
+* [in] Pointer to an osm_physp_t object.
+*
+* p_slvl_tbl
+* [in] Pointer to the IBA defined SLtoVL map table for this
+* port number.
+*
+* in_port_num
+* [in] Input Port Number for this SLtoVL.
+*
+* RETURN VALUES
+* This function does not return a value.
+*
+* NOTES
+*
+* SEE ALSO
+* Port, Physical Port
+*********/
+
+/****f* OpenSM: Physical Port/osm_physp_get_slvl_tbl
+* NAME
+* osm_physp_get_slvl_tbl
+*
+* DESCRIPTION
+* Returns a pointer to the SLtoVL attribute of the Physical Port object.
+*
+* SYNOPSIS
+*/
+static inline ib_slvl_table_t *osm_physp_get_slvl_tbl(IN const osm_physp_t *
+ p_physp,
+ IN uint8_t in_port_num)
+{
+ ib_slvl_table_t *p_tbl;
+
+ CL_ASSERT(osm_physp_is_valid(p_physp));
+ p_tbl = (ib_slvl_table_t *)cl_ptr_vector_get(&p_physp->slvl_by_port, in_port_num);
+ return p_tbl;
+}
+
+/*
+* PARAMETERS
+* p_physp
+* [in] Pointer to an osm_physp_t object.
+*
+* in_port_num
+* [in] Input Port Number for this SLtoVL.
+*
+* RETURN VALUES
+* The pointer to the slvl table
+*
+* NOTES
+*
+* SEE ALSO
+* Port, Physical Port
+*********/
+
+/****f* OpenSM: Physical Port/osm_physp_set_vla_tbl
+* NAME
+* osm_physp_set_vla_tbl
+*
+* DESCRIPTION
+* Copies the VL Arbitration attribute into the Physical Port object.
+*
+* SYNOPSIS
+*/
+static inline void osm_physp_set_vla_tbl(IN osm_physp_t * p_physp,
+ IN ib_vl_arb_table_t * p_vla_tbl,
+ IN uint8_t block_num)
+{
+ CL_ASSERT(p_vla_tbl);
+ CL_ASSERT(osm_physp_is_valid(p_physp));
+ CL_ASSERT((1 <= block_num) && (block_num <= 4));
+ p_physp->vl_arb[block_num - 1] = *p_vla_tbl;
+}
+
+/*
+* PARAMETERS
+* p_physp
+* [in] Pointer to an osm_physp_t object.
+*
+* p_vla_tbl
+* [in] Pointer to the IBA defined VL Arbitration table for this
+* port number.
+*
+* block_num
+* [in] The part of the VL arbitration as defined in the IBA
+* (valid values 1-4)
+*
+* RETURN VALUES
+* This function does not return a value.
+*
+* NOTES
+*
+* SEE ALSO
+* Port, Physical Port
+*********/
+
+/****f* OpenSM: Physical Port/osm_physp_get_vla_tbl
+* NAME
+* osm_physp_get_vla_tbl
+*
+* DESCRIPTION
+* Returns a pointer to the VL Arbitration table of the Physical Port object.
+*
+* SYNOPSIS
+*/
+static inline ib_vl_arb_table_t *osm_physp_get_vla_tbl(IN osm_physp_t * p_physp,
+ IN uint8_t block_num)
+{
+ CL_ASSERT(osm_physp_is_valid(p_physp));
+ CL_ASSERT((1 <= block_num) && (block_num <= 4));
+ return &(p_physp->vl_arb[block_num - 1]);
+}
+
+/*
+* PARAMETERS
+* p_physp
+* [in] Pointer to an osm_physp_t object.
+*
+* block_num
+* [in] The part of the VL arbitration as defined in the IBA
+* (valid values 1-4)
+*
+* RETURN VALUES
+* The pointer to the VL Arbitration table
+*
+* NOTES
+*
+* SEE ALSO
+* Port, Physical Port
+*********/
+
+/****f* OpenSM: Physical Port/osm_physp_get_remote
+* NAME
+* osm_physp_get_remote
+*
+* DESCRIPTION
+* Returns a pointer to the Physical Port on the other side the wire.
+*
+* SYNOPSIS
+*/
+static inline osm_physp_t *osm_physp_get_remote(IN const osm_physp_t * p_physp)
+{
+ CL_ASSERT(osm_physp_is_valid(p_physp));
+ return p_physp->p_remote_physp;
+}
+
+/*
+* PARAMETERS
+* p_physp
+* [in] Pointer to an osm_physp_t object.
+*
+* RETURN VALUES
+* Returns a pointer to the Physical Port on the other side of
+* the wire. A return value of NULL means there is no link at this port.
+*
+* NOTES
+*
+* SEE ALSO
+* Port, Physical Port
+*********/
+
+/****f* OpenSM: Physical Port/osm_physp_get_port_guid
+* NAME
+* osm_physp_get_port_guid
+*
+* DESCRIPTION
+* Returns the port guid of this physical port.
+*
+* SYNOPSIS
+*/
+static inline ib_net64_t osm_physp_get_port_guid(IN const osm_physp_t * p_physp)
+{
+ CL_ASSERT(osm_physp_is_valid(p_physp));
+ return p_physp->port_guid;
+}
+
+/*
+* PARAMETERS
+* p_physp
+* [in] Pointer to an osm_physp_t object.
+*
+* RETURN VALUES
+* Returns the port guid of this physical port.
+*
+* NOTES
+*
+* SEE ALSO
+* Port, Physical Port
+*********/
+
+/****f* OpenSM: Physical Port/osm_physp_get_subnet_prefix
+* NAME
+* osm_physp_get_subnet_prefix
+*
+* DESCRIPTION
+* Returns the subnet prefix for this physical port.
+*
+* SYNOPSIS
+*/
+static inline ib_net64_t
+osm_physp_get_subnet_prefix(IN const osm_physp_t * p_physp)
+{
+ CL_ASSERT(osm_physp_is_valid(p_physp));
+ return p_physp->port_info.subnet_prefix;
+}
+
+/*
+* PARAMETERS
+* p_physp
+* [in] Pointer to an osm_physp_t object.
+*
+* RETURN VALUES
+* Returns the subnet prefix for this physical port.
+*
+* NOTES
+*
+* SEE ALSO
+* Port, Physical Port
+*********/
+
+/****f* OpenSM: Physical Port/osm_physp_link_exists
+* NAME
+* osm_physp_link_exists
+*
+* DESCRIPTION
+* Returns TRUE if the Physical Port has a link to the specified port.
+* FALSE otherwise.
+*
+* SYNOPSIS
+*/
+static inline boolean_t osm_physp_link_exists(IN const osm_physp_t * p_physp,
+ IN const osm_physp_t * p_remote_physp)
+{
+ CL_ASSERT(p_physp);
+ CL_ASSERT(osm_physp_is_valid(p_physp));
+ CL_ASSERT(p_remote_physp);
+ CL_ASSERT(osm_physp_is_valid(p_remote_physp));
+ return ((p_physp->p_remote_physp == p_remote_physp) &&
+ (p_remote_physp->p_remote_physp == p_physp));
+}
+
+/*
+* PARAMETERS
+* p_physp
+* [in] Pointer to an osm_physp_t object.
+*
+* p_remote_physp
+* [in] Pointer to an osm_physp_t object.
+*
+* RETURN VALUES
+* Returns TRUE if the Physical Port has a link to another port.
+* FALSE otherwise.
+*
+* NOTES
+*
+* SEE ALSO
+* Port, Physical Port
+*********/
+
+/****f* OpenSM: Physical Port/osm_physp_link
+* NAME
+* osm_physp_link
+*
+* DESCRIPTION
+* Sets the pointers to the Physical Ports on the other side the wire.
+*
+* SYNOPSIS
+*/
+static inline void osm_physp_link(IN osm_physp_t * p_physp,
+ IN osm_physp_t * p_remote_physp)
+{
+ CL_ASSERT(p_physp);
+ CL_ASSERT(p_remote_physp);
+ p_physp->p_remote_physp = p_remote_physp;
+ p_remote_physp->p_remote_physp = p_physp;
+}
+
+/*
+* PARAMETERS
+* p_physp
+* [in] Pointer to an osm_physp_t object to link.
+*
+* p_remote_physp
+* [in] Pointer to the adjacent osm_physp_t object to link.
+*
+* RETURN VALUES
+* None.
+*
+* NOTES
+*
+* SEE ALSO
+* Port, Physical Port
+*********/
+
+/****f* OpenSM: Physical Port/osm_physp_unlink
+* NAME
+* osm_physp_unlink
+*
+* DESCRIPTION
+* Clears the pointers to the Physical Port on the other side the wire.
+*
+* SYNOPSIS
+*/
+static inline void osm_physp_unlink(IN osm_physp_t * p_physp,
+ IN osm_physp_t * p_remote_physp)
+{
+ CL_ASSERT(p_physp);
+ CL_ASSERT(p_remote_physp);
+ CL_ASSERT(osm_physp_link_exists(p_physp, p_remote_physp));
+ p_physp->p_remote_physp = NULL;
+ p_remote_physp->p_remote_physp = NULL;
+}
+
+/*
+* PARAMETERS
+* p_physp
+* [in] Pointer to an osm_physp_t object to link.
+*
+* p_remote_physp
+* [in] Pointer to the adjacent osm_physp_t object to link.
+*
+* RETURN VALUES
+* None.
+*
+* NOTES
+*
+* SEE ALSO
+* Port, Physical Port
+*********/
+
+/****f* OpenSM: Physical Port/osm_physp_has_any_link
+* NAME
+* osm_physp_has_any_link
+*
+* DESCRIPTION
+* Returns TRUE if the Physical Port has a link to another port.
+* FALSE otherwise.
+*
+* SYNOPSIS
+*/
+static inline boolean_t osm_physp_has_any_link(IN const osm_physp_t * p_physp)
+{
+ CL_ASSERT(p_physp);
+ if (osm_physp_is_valid(p_physp))
+ return (p_physp->p_remote_physp != NULL);
+ else
+ return FALSE;
+}
+
+/*
+* PARAMETERS
+* p_physp
+* [in] Pointer to an osm_physp_t object.
+*
+* RETURN VALUES
+* Returns TRUE if the Physical Port has a link to another port.
+* FALSE otherwise.
+*
+* NOTES
+*
+* SEE ALSO
+* Port, Physical Port
+*********/
+
+/****f* OpenSM: Physical Port/osm_physp_get_port_num
+* NAME
+* osm_physp_get_port_num
+*
+* DESCRIPTION
+* Returns the local port number of this Physical Port.
+*
+* SYNOPSIS
+*/
+static inline uint8_t osm_physp_get_port_num(IN const osm_physp_t * p_physp)
+{
+ CL_ASSERT(p_physp);
+ CL_ASSERT(osm_physp_is_valid(p_physp));
+ return p_physp->port_num;
+}
+
+/*
+* PARAMETERS
+* p_physp
+* [in] Pointer to an osm_physp_t object.
+*
+* RETURN VALUES
+* Returns the local port number of this Physical Port.
+*
+* NOTES
+*
+* SEE ALSO
+*********/
+
+/****f* OpenSM: Physical Port/osm_physp_get_node_ptr
+* NAME
+* osm_physp_get_node_ptr
+*
+* DESCRIPTION
+* Returns a pointer to the parent Node object for this port.
+*
+* SYNOPSIS
+*/
+static inline struct osm_node *osm_physp_get_node_ptr(IN const osm_physp_t *
+ p_physp)
+{
+ CL_ASSERT(p_physp);
+ CL_ASSERT(osm_physp_is_valid(p_physp));
+ return p_physp->p_node;
+}
+
+/*
+* PARAMETERS
+* p_physp
+* [in] Pointer to an osm_physp_t object.
+*
+* RETURN VALUES
+* Returns a pointer to the parent Node object for this port.
+*
+* NOTES
+*
+* SEE ALSO
+*********/
+
+/****f* OpenSM: Physical Port/osm_physp_get_port_state
+* NAME
+* osm_physp_get_port_state
+*
+* DESCRIPTION
+* Returns the port state of this Physical Port.
+*
+* SYNOPSIS
+*/
+static inline uint8_t osm_physp_get_port_state(IN const osm_physp_t * p_physp)
+{
+ CL_ASSERT(p_physp);
+ CL_ASSERT(osm_physp_is_valid(p_physp));
+ return ib_port_info_get_port_state(&p_physp->port_info);
+}
+
+/*
+* PARAMETERS
+* p_physp
+* [in] Pointer to an osm_physp_t object.
+*
+* RETURN VALUES
+* Returns the local port number of this Physical Port.
+*
+* NOTES
+*
+* SEE ALSO
+*********/
+
+/****f* OpenSM: Physical Port/osm_physp_get_base_lid
+* NAME
+* osm_physp_get_base_lid
+*
+* DESCRIPTION
+* Returns the base lid of this Physical Port.
+*
+* SYNOPSIS
+*/
+static inline ib_net16_t osm_physp_get_base_lid(IN const osm_physp_t * p_physp)
+{
+ CL_ASSERT(p_physp);
+ CL_ASSERT(osm_physp_is_valid(p_physp));
+ return p_physp->port_info.base_lid;
+}
+
+/*
+* PARAMETERS
+* p_physp
+* [in] Pointer to an osm_physp_t object.
+*
+* RETURN VALUES
+* Returns the base lid of this Physical Port.
+*
+* NOTES
+*
+* SEE ALSO
+*********/
+
+/****f* OpenSM: Physical Port/osm_physp_get_lmc
+* NAME
+* osm_physp_get_lmc
+*
+* DESCRIPTION
+* Returns the LMC value of this Physical Port.
+*
+* SYNOPSIS
+*/
+static inline uint8_t osm_physp_get_lmc(IN const osm_physp_t * p_physp)
+{
+ CL_ASSERT(p_physp);
+ CL_ASSERT(osm_physp_is_valid(p_physp));
+ return ib_port_info_get_lmc(&p_physp->port_info);
+}
+
+/*
+* PARAMETERS
+* p_physp
+* [in] Pointer to an osm_physp_t object.
+*
+* RETURN VALUES
+* Returns the LMC value of this Physical Port.
+*
+* NOTES
+*
+* SEE ALSO
+*********/
+
+/****f* OpenSM: Physical Port/osm_physp_get_dr_path_ptr
+* NAME
+* osm_physp_get_dr_path_ptr
+*
+* DESCRIPTION
+* Returns a pointer to the directed route path for this port.
+*
+* SYNOPSIS
+*/
+static inline osm_dr_path_t *osm_physp_get_dr_path_ptr(IN const osm_physp_t *
+ p_physp)
+{
+ CL_ASSERT(p_physp);
+ CL_ASSERT(osm_physp_is_valid(p_physp));
+ return (osm_dr_path_t *) & p_physp->dr_path;
+}
+
+/*
+* PARAMETERS
+* p_physp
+* [in] Pointer to a Physical Port object.
+*
+* RETURN VALUES
+* Returns a pointer to the directed route path for this port.
+*
+* NOTES
+*
+* SEE ALSO
+* Physical Port object
+*********/
+
+/****h* OpenSM/Port
+* NAME
+* Port
+*
+* DESCRIPTION
+* The Port object encapsulates the information needed by the
+* OpenSM to manage ports. The OpenSM allocates one Port object
+* per port in the IBA subnet.
+*
+* Each Port object is associated with a single port GUID. A Port object
+* contains 1 or more Physical Port objects. An end point node has
+* one Physical Port per Port. A switch node has more than
+* one Physical Port per Port.
+*
+* The Port object is not thread safe, thus callers must provide
+* serialization.
+*
+* These objects should be treated as opaque and should be
+* manipulated only through the provided functions.
+*
+* AUTHOR
+* Steve King, Intel
+*
+*********/
+
+/****s* OpenSM: Port/osm_port_t
+* NAME
+* osm_port_t
+*
+* DESCRIPTION
+* This object represents a logical port on a switch, router, or CA.
+*
+* The osm_port_t object should be treated as opaque and should
+* be manipulated only through the provided functions.
+*
+* SYNOPSIS
+*/
+typedef struct osm_port {
+ cl_map_item_t map_item;
+ cl_list_item_t list_item;
+ struct osm_node *p_node;
+ ib_net64_t guid;
+ uint32_t discovery_count;
+ unsigned is_new;
+ osm_physp_t *p_physp;
+ cl_qlist_t mcm_list;
+ int flag;
+ int use_scatter;
+ unsigned int cc_timeout_count;
+ int cc_unavailable_flag;
+ void *priv;
+ ib_net16_t lid;
+} osm_port_t;
+/*
+* FIELDS
+* map_item
+* Linkage structure for cl_qmap. MUST BE FIRST MEMBER!
+*
+* list_item
+* Linkage structure for cl_qlist. Used by ucast mgr during
+* LFT calculation.
+*
+* p_node
+* Points to the Node object that owns this port.
+*
+* guid
+* Manufacturer assigned GUID for this port.
+*
+* discovery_count
+* The number of times this port has been discovered
+* during the current fabric sweep. This number is reset
+* to zero at the start of a sweep.
+*
+* p_physp
+* The pointer to physical port used when physical
+* characteristics contained in the Physical Port are needed.
+*
+* mcm_list
+* Multicast member list
+*
+* flag
+* Utility flag for port management
+*
+* cc_timeout_count
+* Count number of times congestion control config times out.
+*
+* cc_unavailable_flag
+* Flag indicating if congestion control is not supported.
+*
+* SEE ALSO
+* Port, Physical Port, Physical Port Table
+*********/
+
+/****f* OpenSM: Port/osm_port_delete
+* NAME
+* osm_port_delete
+*
+* DESCRIPTION
+* This function destroys and deallocates a Port object.
+*
+* SYNOPSIS
+*/
+void osm_port_delete(IN OUT osm_port_t ** pp_port);
+/*
+* PARAMETERS
+* pp_port
+* [in][out] Pointer to a pointer to a Port object to delete.
+* On return, this pointer is NULL.
+*
+* RETURN VALUE
+* This function does not return a value.
+*
+* NOTES
+* Performs any necessary cleanup of the specified Port object.
+*
+* SEE ALSO
+* Port
+*********/
+
+/****f* OpenSM: Port/osm_port_new
+* NAME
+* osm_port_new
+*
+* DESCRIPTION
+* This function allocates and initializes a Port object.
+*
+* SYNOPSIS
+*/
+osm_port_t *osm_port_new(IN const ib_node_info_t * p_ni,
+ IN struct osm_node *p_parent_node);
+/*
+* PARAMETERS
+* p_ni
+* [in] Pointer to the NodeInfo attribute relevant for this port.
+*
+* p_parent_node
+* [in] Pointer to the initialized parent osm_node_t object
+* that owns this port.
+*
+* RETURN VALUE
+* Pointer to the initialize Port object.
+*
+* NOTES
+* Allows calling other port methods.
+*
+* SEE ALSO
+* Port
+*********/
+
+/****f* OpenSM: Port/osm_port_get_base_lid
+* NAME
+* osm_port_get_base_lid
+*
+* DESCRIPTION
+* Gets the base LID of a port.
+*
+* SYNOPSIS
+*/
+static inline ib_net16_t osm_port_get_base_lid(IN const osm_port_t * p_port)
+{
+ CL_ASSERT(p_port->p_physp && osm_physp_is_valid(p_port->p_physp));
+ return osm_physp_get_base_lid(p_port->p_physp);
+}
+
+/*
+* PARAMETERS
+* p_port
+* [in] Pointer to a Port object.
+*
+* RETURN VALUE
+* Base LID of the port.
+* If the return value is 0, then this port has no assigned LID.
+*
+* NOTES
+*
+* SEE ALSO
+* Port
+*********/
+
+/****f* OpenSM: Port/osm_port_get_lmc
+* NAME
+* osm_port_get_lmc
+*
+* DESCRIPTION
+* Gets the LMC value of a port.
+*
+* SYNOPSIS
+*/
+static inline uint8_t osm_port_get_lmc(IN const osm_port_t * p_port)
+{
+ CL_ASSERT(p_port->p_physp && osm_physp_is_valid(p_port->p_physp));
+ return osm_physp_get_lmc(p_port->p_physp);
+}
+
+/*
+* PARAMETERS
+* p_port
+* [in] Pointer to a Port object.
+*
+* RETURN VALUE
+* Gets the LMC value of a port.
+*
+* NOTES
+*
+* SEE ALSO
+* Port
+*********/
+
+/****f* OpenSM: Port/osm_port_get_guid
+* NAME
+* osm_port_get_guid
+*
+* DESCRIPTION
+* Gets the GUID of a port.
+*
+* SYNOPSIS
+*/
+static inline ib_net64_t osm_port_get_guid(IN const osm_port_t * p_port)
+{
+ return p_port->guid;
+}
+
+/*
+* PARAMETERS
+* p_port
+* [in] Pointer to a Port object.
+*
+* RETURN VALUE
+* Manufacturer assigned GUID of the port.
+*
+* NOTES
+*
+* SEE ALSO
+* Port
+*********/
+
+/****f* OpenSM: Port/osm_port_get_lid_range_ho
+* NAME
+* osm_port_get_lid_range_ho
+*
+* DESCRIPTION
+* Returns the HOST ORDER lid min and max values for this port,
+* based on the lmc value.
+*
+* SYNOPSIS
+*/
+void osm_port_get_lid_range_ho(IN const osm_port_t * p_port,
+ OUT uint16_t * p_min_lid,
+ OUT uint16_t * p_max_lid);
+/*
+* PARAMETERS
+* p_port
+* [in] Pointer to a Port object.
+*
+* p_min_lid
+* [out] Pointer to the minimum LID value occupied by this port.
+*
+* p_max_lid
+* [out] Pointer to the maximum LID value occupied by this port.
+*
+* RETURN VALUE
+* None.
+*
+* NOTES
+*
+* SEE ALSO
+* Port
+*********/
+
+/****f* OpenSM: Physical Port/osm_physp_calc_link_mtu
+* NAME
+* osm_physp_calc_link_mtu
+*
+* DESCRIPTION
+* Calculate the Port MTU based on current and remote
+* physical ports MTU CAP values.
+*
+* SYNOPSIS
+*/
+uint8_t osm_physp_calc_link_mtu(IN osm_log_t * p_log,
+ IN const osm_physp_t * p_physp,
+ IN uint8_t current_mtu);
+/*
+* PARAMETERS
+* p_log
+* [in] Pointer to a log object.
+*
+* p_physp
+* [in] Pointer to an osm_physp_t object.
+*
+* current_mtu
+* [in] Current neighbor mtu on this port
+*
+* RETURN VALUES
+* The MTU of the link to be used.
+*
+* NOTES
+*
+* SEE ALSO
+* PhysPort object
+*********/
+
+/****f* OpenSM: Physical Port/osm_physp_calc_link_op_vls
+* NAME
+* osm_physp_calc_link_op_vls
+*
+* DESCRIPTION
+* Calculate the Port OP_VLS based on current and remote
+* physical ports VL CAP values. Allowing user option for a max limit.
+*
+* SYNOPSIS
+*/
+uint8_t osm_physp_calc_link_op_vls(IN osm_log_t * p_log,
+ IN const osm_subn_t * p_subn,
+ IN const osm_physp_t * p_physp,
+ IN uint8_t current_op_vls);
+/*
+* PARAMETERS
+* p_log
+* [in] Pointer to a log object.
+*
+* p_subn
+* [in] Pointer to the subnet object for accessing of the options.
+*
+* p_physp
+* [in] Pointer to an osm_physp_t object.
+*
+* current_op_vls
+* [in] Current operational VL on the port
+*
+* RETURN VALUES
+* The OP_VLS of the link to be used.
+*
+* NOTES
+*
+* SEE ALSO
+* PhysPort object
+*********/
+
+/****f* OpenSM: Physical Port/osm_physp_replace_dr_path_with_alternate_dr_path
+* NAME
+* osm_physp_replace_dr_path_with_alternate_dr_path
+*
+* DESCRIPTION
+* Replace the direct route path for the given phys port with an
+* alternate path going through forien set of phys port.
+*
+* SYNOPSIS
+*/
+void
+osm_physp_replace_dr_path_with_alternate_dr_path(IN osm_log_t * p_log,
+ IN osm_subn_t const *p_subn,
+ IN osm_physp_t const *p_physp,
+ IN osm_bind_handle_t * h_bind);
+/*
+* PARAMETERS
+* p_log
+* [in] Pointer to a log object.
+*
+* p_subn
+* [in] Pointer to the subnet object for accessing of the options.
+*
+* p_physp
+* [in] Pointer to an osm_physp_t object.
+*
+* h_bind
+* [in] Pointer to osm_bind_handle_t object.
+*
+* RETURN VALUES
+* NONE
+*
+* NOTES
+*
+* SEE ALSO
+* PhysPort object
+*********/
+
+/****s* OpenSM: Port/osm_alias_guid_t
+* NAME
+* osm_alias_guid_t
+*
+* DESCRIPTION
+* This object represents an alias guid for an endport.
+*
+* The osm_alias_guid_t object should be treated as opaque and should
+* be manipulated only through the provided functions.
+*
+* SYNOPSIS
+*/
+typedef struct osm_alias_guid {
+ cl_map_item_t map_item;
+ ib_net64_t alias_guid;
+ osm_port_t *p_base_port;
+} osm_alias_guid_t;
+/*
+* FIELDS
+* map_item
+* Linkage structure for cl_qmap. MUST BE FIRST MEMBER!
+*
+* alias_guid
+* Alias GUID for port obtained from SM GUIDInfo attribute
+*
+* p_base_port
+* Pointer to osm_port_t for base port GUID
+*
+* SEE ALSO
+* Port, Physical Port, Physical Port Table
+*/
+
+/****f* OpenSM: Port/osm_alias_guid_new
+* NAME
+* osm_alias_guid_new
+*
+* DESCRIPTION
+* This function allocates and initializes an alias guid object.
+*
+* SYNOPSIS
+*/
+osm_alias_guid_t *osm_alias_guid_new(IN const ib_net64_t alias_guid,
+ IN osm_port_t *p_base_port);
+/*
+* PARAMETERS
+* alias_guid
+* [in] Alias GUID in network order
+*
+* p_base_port
+* [in] Pointer to the port for this base GUID
+*
+* RETURN VALUE
+* Pointer to the initialized alias guid object.
+*
+* NOTES
+* Allows calling other alias guid methods.
+*
+* SEE ALSO
+* Port
+*********/
+
+/****f* OpenSM: Port/osm_alias_guid_delete
+* NAME
+* osm_alias_guid_delete
+*
+* DESCRIPTION
+* This function destroys and deallocates an alias guid object.
+*
+* SYNOPSIS
+*/
+void osm_alias_guid_delete(IN OUT osm_alias_guid_t ** pp_alias_guid);
+/*
+* PARAMETERS
+* pp_alias_guid
+* [in][out] Pointer to a pointer to an alias guid object to delete.
+* On return, this pointer is NULL.
+*
+* RETURN VALUE
+* This function does not return a value.
+*
+* NOTES
+* Performs any necessary cleanup of the specified alias guid object.
+*
+* SEE ALSO
+* Port
+*********/
+
+/****f* OpenSM: Port/osm_alias_guid_get_alias_guid
+* NAME
+* osm_alias_guid_get_alias_guid
+*
+* DESCRIPTION
+* This function retrieves alias guid from alias guid object.
+*
+* SYNOPSIS
+*/
+static inline ib_net64_t osm_alias_guid_get_alias_guid(IN osm_alias_guid_t *p_alias_guid)
+{
+ CL_ASSERT(p_alias_guid);
+ return p_alias_guid->alias_guid;
+}
+/*
+* PARAMETERS
+* p_alias_guid
+* [in] Pointer to a pointer to an alias guid object.
+*
+* RETURN VALUE
+* This function returns the alias guid or NULL if fails.
+*
+* NOTES
+*
+* SEE ALSO
+* Port
+*********/
+
+/****f* OpenSM: Port/osm_alias_guid_get_base_guid
+* NAME
+* osm_alias_guid_get_base_guid
+*
+* DESCRIPTION
+* This function retrieves base guid from alias guid object.
+*
+* SYNOPSIS
+*/
+static inline ib_net64_t osm_alias_guid_get_base_guid(IN osm_alias_guid_t *p_alias_guid)
+{
+ CL_ASSERT(p_alias_guid);
+ return osm_port_get_guid(p_alias_guid->p_base_port);
+}
+/*
+* PARAMETERS
+* p_alias_guid
+* [in] Pointer to a pointer to an alias guid object.
+*
+* RETURN VALUE
+* This function returns the base guid or NULL if fails.
+*
+* NOTES
+*
+* SEE ALSO
+* Port
+*********/
+
+/****f* OpenSM: Port/osm_port_clear_base_lid
+* NAME
+* osm_port_clear_base_lid
+*
+* DESCRIPTION
+* Clear the base lid of a given port.
+*
+* SYNOPSIS
+*/
+static inline void osm_port_clear_base_lid(OUT osm_port_t * p_port)
+{
+ CL_ASSERT(p_port);
+ p_port->lid = 0;
+ osm_physp_set_base_lid(p_port->p_physp, 0);
+}
+
+/*
+* PARAMETERS
+* p_port
+* [out] Pointer to a Port object.
+*
+* RETURN VALUE
+* None
+*
+* NOTES
+*
+* SEE ALSO
+* Port
+*********/
+
+END_C_DECLS
+#endif /* _OSM_PORT_H_ */
diff --git a/contrib/ofed/opensm/include/opensm/osm_port_profile.h b/contrib/ofed/opensm/include/opensm/osm_port_profile.h
new file mode 100644
index 0000000..dc5b426
--- /dev/null
+++ b/contrib/ofed/opensm/include/opensm/osm_port_profile.h
@@ -0,0 +1,206 @@
+/*
+ * Copyright (c) 2004-2009 Voltaire, Inc. All rights reserved.
+ * Copyright (c) 2002-2005,2008 Mellanox Technologies LTD. All rights reserved.
+ * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
+ * Copyright (c) 2008 Xsigo Systems Inc. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+/*
+ * Abstract:
+ * Declaration of Switch/osm_port_profile_t.
+ * This object represents a port profile for an IBA switch.
+ * This object is part of the OpenSM family of objects.
+ */
+
+#ifndef _OSM_PORT_PROFILE_H_
+#define _OSM_PORT_PROFILE_H_
+
+#include <string.h>
+#include <iba/ib_types.h>
+#include <opensm/osm_base.h>
+#include <opensm/osm_madw.h>
+#include <opensm/osm_subnet.h>
+#include <opensm/osm_node.h>
+#include <opensm/osm_port.h>
+#include <opensm/osm_mcast_tbl.h>
+
+#ifdef __cplusplus
+# define BEGIN_C_DECLS extern "C" {
+# define END_C_DECLS }
+#else /* !__cplusplus */
+# define BEGIN_C_DECLS
+# define END_C_DECLS
+#endif /* __cplusplus */
+
+BEGIN_C_DECLS
+/****h* OpenSM/Port Profile
+* NAME
+* Port Profile
+*
+* DESCRIPTION
+* The Port Profile object contains profiling information for
+* each Physical Port on a switch. The profile information
+* may be used to optimize path selection.
+*
+* AUTHOR
+* Steve King, Intel
+*
+*********/
+/****s* OpenSM: Switch/osm_port_profile_t
+* NAME
+* osm_port_profile_t
+*
+* DESCRIPTION
+* The Port Profile object contains profiling information for
+* each Physical Port on the switch. The profile information
+* may be used to optimize path selection.
+*
+* This object should be treated as opaque and should be
+* be manipulated only through the provided functions.
+*
+* SYNOPSIS
+*/
+typedef struct osm_port_profile {
+ uint32_t num_paths;
+} osm_port_profile_t;
+/*
+* FIELDS
+* num_paths
+* The number of paths using this port.
+*
+* SEE ALSO
+*********/
+
+/****s* OpenSM: Switch/osm_port_mask_t
+* NAME
+* osm_port_mask_t
+*
+* DESCRIPTION
+* The Port Mask object contains a port numbered bit mask
+* for whether the port should be ignored by the link load
+* equalization algorithm.
+*
+* SYNOPSIS
+*/
+typedef long osm_port_mask_t[32 / sizeof(long)];
+/*
+* FIELDS
+* osm_port_mask_t
+* Bit mask by port number
+*
+* SEE ALSO
+*********/
+
+/****f* OpenSM: Port Profile/osm_port_prof_construct
+* NAME
+* osm_port_prof_construct
+*
+* DESCRIPTION
+*
+*
+* SYNOPSIS
+*/
+static inline void osm_port_prof_construct(IN osm_port_profile_t * p_prof)
+{
+ CL_ASSERT(p_prof);
+ memset(p_prof, 0, sizeof(*p_prof));
+}
+/*
+* PARAMETERS
+* p_prof
+* [in] Pointer to the Port Profile object to construct.
+*
+* RETURN VALUE
+* None.
+*
+* NOTES
+*
+* SEE ALSO
+*********/
+
+/****f* OpenSM: Port Profile/osm_port_prof_path_count_inc
+* NAME
+* osm_port_prof_path_count_inc
+*
+* DESCRIPTION
+* Increments the count of the number of paths going through this port.
+*
+*
+* SYNOPSIS
+*/
+static inline void osm_port_prof_path_count_inc(IN osm_port_profile_t * p_prof)
+{
+ CL_ASSERT(p_prof);
+ p_prof->num_paths++;
+}
+/*
+* PARAMETERS
+* p_prof
+* [in] Pointer to the Port Profile object.
+*
+* RETURN VALUE
+* None.
+*
+* NOTES
+*
+* SEE ALSO
+*********/
+
+/****f* OpenSM: Port Profile/osm_port_prof_path_count_get
+* NAME
+* osm_port_prof_path_count_get
+*
+* DESCRIPTION
+* Returns the count of the number of paths going through this port.
+*
+* SYNOPSIS
+*/
+static inline uint32_t
+osm_port_prof_path_count_get(IN const osm_port_profile_t * p_prof)
+{
+ return p_prof->num_paths;
+}
+/*
+* PARAMETERS
+* p_prof
+* [in] Pointer to the Port Profile object.
+*
+* RETURN VALUE
+* None.
+*
+* NOTES
+*
+* SEE ALSO
+*********/
+
+END_C_DECLS
+#endif /* _OSM_PORT_PROFILE_H_ */
diff --git a/contrib/ofed/management/opensm/include/opensm/osm_prefix_route.h b/contrib/ofed/opensm/include/opensm/osm_prefix_route.h
index 829a9ff..829a9ff 100644
--- a/contrib/ofed/management/opensm/include/opensm/osm_prefix_route.h
+++ b/contrib/ofed/opensm/include/opensm/osm_prefix_route.h
diff --git a/contrib/ofed/opensm/include/opensm/osm_qos_policy.h b/contrib/ofed/opensm/include/opensm/osm_qos_policy.h
new file mode 100644
index 0000000..53d56cd
--- /dev/null
+++ b/contrib/ofed/opensm/include/opensm/osm_qos_policy.h
@@ -0,0 +1,205 @@
+/*
+ * Copyright (c) 2004-2009 Voltaire, Inc. All rights reserved.
+ * Copyright (c) 2002-2012 Mellanox Technologies LTD. All rights reserved.
+ * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+/*
+ * Abstract:
+ * Declaration of OSM QoS Policy data types and functions.
+ *
+ * Author:
+ * Yevgeny Kliteynik, Mellanox
+ */
+
+#ifndef OSM_QOS_POLICY_H
+#define OSM_QOS_POLICY_H
+
+#include <iba/ib_types.h>
+#include <complib/cl_list.h>
+#include <opensm/st.h>
+#include <opensm/osm_port.h>
+#include <opensm/osm_partition.h>
+
+#define YYSTYPE char *
+#define OSM_QOS_POLICY_MAX_PORTS_ON_SWITCH 128
+#define OSM_QOS_POLICY_DEFAULT_LEVEL_NAME "default"
+
+#define OSM_QOS_POLICY_ULP_SDP_SERVICE_ID 0x0000000000010000ULL
+#define OSM_QOS_POLICY_ULP_RDS_SERVICE_ID 0x0000000001060000ULL
+#define OSM_QOS_POLICY_ULP_RDS_PORT 0x48CA
+#define OSM_QOS_POLICY_ULP_ISER_SERVICE_ID 0x0000000001060000ULL
+#define OSM_QOS_POLICY_ULP_ISER_PORT 0x0CBC
+
+#define OSM_QOS_POLICY_NODE_TYPE_CA (((uint8_t)1)<<IB_NODE_TYPE_CA)
+#define OSM_QOS_POLICY_NODE_TYPE_SWITCH (((uint8_t)1)<<IB_NODE_TYPE_SWITCH)
+#define OSM_QOS_POLICY_NODE_TYPE_ROUTER (((uint8_t)1)<<IB_NODE_TYPE_ROUTER)
+
+/***************************************************/
+
+typedef struct osm_qos_port {
+ cl_map_item_t map_item;
+ osm_physp_t * p_physp;
+} osm_qos_port_t;
+
+typedef struct osm_qos_port_group {
+ char *name; /* single string (this port group name) */
+ char *use; /* single string (description) */
+ uint8_t node_types; /* node types bitmask */
+ cl_qmap_t port_map;
+} osm_qos_port_group_t;
+
+/***************************************************/
+
+typedef struct osm_qos_vlarb_scope {
+ cl_list_t group_list; /* list of group names (strings) */
+ cl_list_t across_list; /* list of 'across' group names (strings) */
+ cl_list_t vlarb_high_list; /* list of num pairs (n:m,...), 32-bit values */
+ cl_list_t vlarb_low_list; /* list of num pairs (n:m,...), 32-bit values */
+ uint32_t vl_high_limit; /* single integer */
+ boolean_t vl_high_limit_set;
+} osm_qos_vlarb_scope_t;
+
+/***************************************************/
+
+typedef struct osm_qos_sl2vl_scope {
+ cl_list_t group_list; /* list of strings (port group names) */
+ boolean_t from[OSM_QOS_POLICY_MAX_PORTS_ON_SWITCH];
+ boolean_t to[OSM_QOS_POLICY_MAX_PORTS_ON_SWITCH];
+ cl_list_t across_from_list; /* list of strings (port group names) */
+ cl_list_t across_to_list; /* list of strings (port group names) */
+ uint8_t sl2vl_table[16]; /* array of sl2vl values */
+ boolean_t sl2vl_table_set;
+} osm_qos_sl2vl_scope_t;
+
+/***************************************************/
+
+typedef struct osm_qos_level {
+ char *use;
+ char *name;
+ uint8_t sl;
+ boolean_t sl_set;
+ uint8_t mtu_limit;
+ boolean_t mtu_limit_set;
+ uint8_t rate_limit;
+ boolean_t rate_limit_set;
+ uint8_t pkt_life;
+ boolean_t pkt_life_set;
+ uint64_t **path_bits_range_arr; /* array of bit ranges (real values are 32bits) */
+ unsigned path_bits_range_len; /* num of bit ranges in the array */
+ uint64_t **pkey_range_arr; /* array of PKey ranges (real values are 16bits) */
+ unsigned pkey_range_len;
+} osm_qos_level_t;
+
+
+/***************************************************/
+
+typedef struct osm_qos_match_rule {
+ char *use;
+ cl_list_t source_list; /* list of strings */
+ cl_list_t source_group_list; /* list of pointers to relevant port-group */
+ cl_list_t destination_list; /* list of strings */
+ cl_list_t destination_group_list; /* list of pointers to relevant port-group */
+ char *qos_level_name;
+ osm_qos_level_t *p_qos_level;
+ uint64_t **service_id_range_arr; /* array of SID ranges (64-bit values) */
+ unsigned service_id_range_len;
+ uint64_t **qos_class_range_arr; /* array of QoS Class ranges (real values are 16bits) */
+ unsigned qos_class_range_len;
+ uint64_t **pkey_range_arr; /* array of PKey ranges (real values are 16bits) */
+ unsigned pkey_range_len;
+} osm_qos_match_rule_t;
+
+/***************************************************/
+
+typedef struct osm_qos_policy {
+ cl_list_t port_groups; /* list of osm_qos_port_group_t */
+ cl_list_t sl2vl_tables; /* list of osm_qos_sl2vl_scope_t */
+ cl_list_t vlarb_tables; /* list of osm_qos_vlarb_scope_t */
+ cl_list_t qos_levels; /* list of osm_qos_level_t */
+ cl_list_t qos_match_rules; /* list of osm_qos_match_rule_t */
+ osm_qos_level_t *p_default_qos_level; /* default QoS level */
+ osm_subn_t *p_subn; /* osm subnet object */
+ st_table * p_node_hash; /* node by name hash */
+} osm_qos_policy_t;
+
+/***************************************************/
+
+osm_qos_port_t *osm_qos_policy_port_create(osm_physp_t * p_physp);
+osm_qos_port_group_t * osm_qos_policy_port_group_create();
+void osm_qos_policy_port_group_destroy(osm_qos_port_group_t * p_port_group);
+
+osm_qos_vlarb_scope_t * osm_qos_policy_vlarb_scope_create();
+void osm_qos_policy_vlarb_scope_destroy(osm_qos_vlarb_scope_t * p_vlarb_scope);
+
+osm_qos_sl2vl_scope_t * osm_qos_policy_sl2vl_scope_create();
+void osm_qos_policy_sl2vl_scope_destroy(osm_qos_sl2vl_scope_t * p_sl2vl_scope);
+
+osm_qos_level_t * osm_qos_policy_qos_level_create();
+void osm_qos_policy_qos_level_destroy(osm_qos_level_t * p_qos_level);
+
+boolean_t osm_qos_level_has_pkey(IN const osm_qos_level_t * p_qos_level,
+ IN ib_net16_t pkey);
+
+ib_net16_t osm_qos_level_get_shared_pkey(IN const osm_qos_level_t * p_qos_level,
+ IN const osm_physp_t * p_src_physp,
+ IN const osm_physp_t * p_dest_physp,
+ IN const boolean_t allow_both_pkeys);
+
+osm_qos_match_rule_t * osm_qos_policy_match_rule_create();
+void osm_qos_policy_match_rule_destroy(osm_qos_match_rule_t * p_match_rule);
+
+osm_qos_policy_t * osm_qos_policy_create(osm_subn_t * p_subn);
+void osm_qos_policy_destroy(osm_qos_policy_t * p_qos_policy);
+int osm_qos_policy_validate(osm_qos_policy_t * p_qos_policy, osm_log_t * p_log);
+
+osm_qos_level_t * osm_qos_policy_get_qos_level_by_pr(
+ IN const osm_qos_policy_t * p_qos_policy,
+ IN const ib_path_rec_t * p_pr,
+ IN const osm_physp_t * p_src_physp,
+ IN const osm_physp_t * p_dest_physp,
+ IN ib_net64_t comp_mask);
+
+osm_qos_level_t * osm_qos_policy_get_qos_level_by_mpr(
+ IN const osm_qos_policy_t * p_qos_policy,
+ IN const ib_multipath_rec_t * p_mpr,
+ IN const osm_physp_t * p_src_physp,
+ IN const osm_physp_t * p_dest_physp,
+ IN ib_net64_t comp_mask);
+
+/***************************************************/
+
+int osm_qos_parse_policy_file(IN osm_subn_t * p_subn);
+
+/***************************************************/
+
+#endif /* ifndef OSM_QOS_POLICY_H */
diff --git a/contrib/ofed/opensm/include/opensm/osm_remote_sm.h b/contrib/ofed/opensm/include/opensm/osm_remote_sm.h
new file mode 100644
index 0000000..e7d52fa
--- /dev/null
+++ b/contrib/ofed/opensm/include/opensm/osm_remote_sm.h
@@ -0,0 +1,194 @@
+/*
+ * Copyright (c) 2004-2009 Voltaire, Inc. All rights reserved.
+ * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved.
+ * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+/*
+ * Abstract:
+ * Declaration of osm_sm_t, osm_remote_sm_t.
+ * This object represents an IBA subnet.
+ * This object is part of the OpenSM family of objects.
+ */
+
+#ifndef _OSM_REMOTE_SM_H_
+#define _OSM_REMOTE_SM_H_
+
+#include <iba/ib_types.h>
+#include <opensm/osm_base.h>
+#include <opensm/osm_port.h>
+
+#ifdef __cplusplus
+# define BEGIN_C_DECLS extern "C" {
+# define END_C_DECLS }
+#else /* !__cplusplus */
+# define BEGIN_C_DECLS
+# define END_C_DECLS
+#endif /* __cplusplus */
+
+BEGIN_C_DECLS
+/****h* OpenSM/Remote SM
+* NAME
+* Remote SM
+*
+* DESCRIPTION
+* The Remote SM object encapsulates the information tracked for
+* other SM ports on the subnet.
+*
+* The Remote SM object is thread safe.
+*
+* This object should be treated as opaque and should
+* be manipulated only through the provided functions.
+*
+* AUTHOR
+* Steve King, Intel
+*
+*********/
+/****s* OpenSM: Remote SM/osm_remote_sm_t
+* NAME
+* osm_remote_sm_t
+*
+* DESCRIPTION
+* Remote Subnet Manager structure.
+*
+* This object should be treated as opaque and should
+* be manipulated only through the provided functions.
+*
+* SYNOPSIS
+*/
+typedef struct osm_remote_sm {
+ cl_map_item_t map_item;
+ ib_sm_info_t smi;
+} osm_remote_sm_t;
+/*
+* FIELDS
+* map_item
+* Linkage for the cl_qmap container. MUST BE FIRST ELEMENT!!
+* p_port
+* Pointer to the port object for this SM.
+*
+* smi
+* The SMInfo attribute for this SM.
+*
+* SEE ALSO
+*********/
+
+/****f* OpenSM: SM/osm_remote_sm_construct
+* NAME
+* osm_remote_sm_construct
+*
+* DESCRIPTION
+* This function constructs an Remote SM object.
+*
+* SYNOPSIS
+*/
+void osm_remote_sm_construct(IN osm_remote_sm_t * p_sm);
+/*
+* PARAMETERS
+* p_sm
+* [in] Pointer to an Remote SM object to construct.
+*
+* RETURN VALUE
+* This function does not return a value.
+*
+* NOTES
+* Allows calling osm_remote_sm_init, osm_remote_sm_destroy
+*
+* Calling osm_remote_sm_construct is a prerequisite to calling any other
+* method except osm_remote_sm_init.
+*
+* SEE ALSO
+* SM object, osm_remote_sm_init, osm_remote_sm_destroy
+*********/
+
+/****f* OpenSM: SM/osm_remote_sm_destroy
+* NAME
+* osm_remote_sm_destroy
+*
+* DESCRIPTION
+* The osm_remote_sm_destroy function destroys an SM, releasing
+* all resources.
+*
+* SYNOPSIS
+*/
+void osm_remote_sm_destroy(IN osm_remote_sm_t * p_sm);
+/*
+* PARAMETERS
+* p_sm
+* [in] Pointer to an Remote SM object to destroy.
+*
+* RETURN VALUE
+* This function does not return a value.
+*
+* NOTES
+* Performs any necessary cleanup of the specified Remote SM object.
+* Further operations should not be attempted on the destroyed object.
+* This function should only be called after a call to
+* osm_remote_sm_construct or osm_remote_sm_init.
+*
+* SEE ALSO
+* Remote SM object, osm_remote_sm_construct, osm_remote_sm_init
+*********/
+
+/****f* OpenSM: SM/osm_remote_sm_init
+* NAME
+* osm_remote_sm_init
+*
+* DESCRIPTION
+* The osm_remote_sm_init function initializes an Remote SM object for use.
+*
+* SYNOPSIS
+*/
+void osm_remote_sm_init(IN osm_remote_sm_t * p_sm, IN const ib_sm_info_t * p_smi);
+/*
+* PARAMETERS
+* p_sm
+* [in] Pointer to an osm_remote_sm_t object to initialize.
+*
+* p_port
+* [in] Pointer to the Remote SM's port object.
+*
+* p_smi
+* [in] Pointer to the SMInfo attribute for this SM.
+*
+* RETURN VALUES
+* This function does not return a value.
+*
+* NOTES
+* Allows calling other Remote SM methods.
+*
+* SEE ALSO
+* Remote SM object, osm_remote_sm_construct, osm_remote_sm_destroy
+*********/
+
+END_C_DECLS
+#endif /* _OSM_REMOTE_SM_H_ */
diff --git a/contrib/ofed/opensm/include/opensm/osm_router.h b/contrib/ofed/opensm/include/opensm/osm_router.h
new file mode 100644
index 0000000..b551221
--- /dev/null
+++ b/contrib/ofed/opensm/include/opensm/osm_router.h
@@ -0,0 +1,215 @@
+/*
+ * Copyright (c) 2004-2009 Voltaire, Inc. All rights reserved.
+ * Copyright (c) 2002-2005,2008 Mellanox Technologies LTD. All rights reserved.
+ * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+/*
+ * Abstract:
+ * Declaration of osm_router_t.
+ * This object represents an IBA router.
+ * This object is part of the OpenSM family of objects.
+ */
+
+#ifndef _OSM_ROUTER_H_
+#define _OSM_ROUTER_H_
+
+#include <iba/ib_types.h>
+#include <opensm/osm_base.h>
+#include <opensm/osm_madw.h>
+#include <opensm/osm_node.h>
+#include <opensm/osm_port.h>
+#include <opensm/osm_mcast_tbl.h>
+#include <opensm/osm_port_profile.h>
+
+#ifdef __cplusplus
+# define BEGIN_C_DECLS extern "C" {
+# define END_C_DECLS }
+#else /* !__cplusplus */
+# define BEGIN_C_DECLS
+# define END_C_DECLS
+#endif /* __cplusplus */
+
+BEGIN_C_DECLS
+/****h* OpenSM/Router
+* NAME
+* Router
+*
+* DESCRIPTION
+* The Router object encapsulates the information needed by the
+* OpenSM to manage routers. The OpenSM allocates one router object
+* per router in the IBA subnet.
+*
+* The Router object is not thread safe, thus callers must provide
+* serialization.
+*
+* This object should be treated as opaque and should be
+* manipulated only through the provided functions.
+*
+* AUTHOR
+* Hal Rosenstock, Voltaire
+*
+*********/
+/****s* OpenSM: Router/osm_router_t
+* NAME
+* osm_router_t
+*
+* DESCRIPTION
+* Router structure.
+*
+* This object should be treated as opaque and should
+* be manipulated only through the provided functions.
+*
+* SYNOPSIS
+*/
+typedef struct osm_router {
+ cl_map_item_t map_item;
+ osm_port_t *p_port;
+} osm_router_t;
+/*
+* FIELDS
+* map_item
+* Linkage structure for cl_qmap. MUST BE FIRST MEMBER!
+*
+* p_port
+* Pointer to the Port object for this router.
+*
+* SEE ALSO
+* Router object
+*********/
+
+/****f* OpenSM: Router/osm_router_delete
+* NAME
+* osm_router_delete
+*
+* DESCRIPTION
+* Destroys and deallocates the object.
+*
+* SYNOPSIS
+*/
+void osm_router_delete(IN OUT osm_router_t ** pp_rtr);
+/*
+* PARAMETERS
+* p_rtr
+* [in] Pointer to the object to destroy.
+*
+* RETURN VALUE
+* None.
+*
+* NOTES
+*
+* SEE ALSO
+* Router object, osm_router_new
+*********/
+
+/****f* OpenSM: Router/osm_router_new
+* NAME
+* osm_router_new
+*
+* DESCRIPTION
+* The osm_router_new function initializes a Router object for use.
+*
+* SYNOPSIS
+*/
+osm_router_t *osm_router_new(IN osm_port_t * p_port);
+/*
+* PARAMETERS
+* p_node
+* [in] Pointer to the node object of this router
+*
+* RETURN VALUES
+* Pointer to the new initialized router object.
+*
+* NOTES
+*
+* SEE ALSO
+* Router object, osm_router_new
+*********/
+
+/****f* OpenSM: Router/osm_router_get_port_ptr
+* NAME
+* osm_router_get_port_ptr
+*
+* DESCRIPTION
+* Returns a pointer to the Port object for this router.
+*
+* SYNOPSIS
+*/
+static inline osm_port_t *osm_router_get_port_ptr(IN const osm_router_t * p_rtr)
+{
+ return p_rtr->p_port;
+}
+
+/*
+* PARAMETERS
+* p_rtr
+* [in] Pointer to an osm_router_t object.
+*
+* RETURN VALUES
+* Returns a pointer to the Port object for this router.
+*
+* NOTES
+*
+* SEE ALSO
+* Router object
+*********/
+
+/****f* OpenSM: Router/osm_router_get_node_ptr
+* NAME
+* osm_router_get_node_ptr
+*
+* DESCRIPTION
+* Returns a pointer to the Node object for this router.
+*
+* SYNOPSIS
+*/
+static inline osm_node_t *osm_router_get_node_ptr(IN const osm_router_t * p_rtr)
+{
+ return p_rtr->p_port->p_node;
+}
+
+/*
+* PARAMETERS
+* p_rtr
+* [in] Pointer to an osm_router_t object.
+*
+* RETURN VALUES
+* Returns a pointer to the Node object for this router.
+*
+* NOTES
+*
+* SEE ALSO
+* Router object
+*********/
+
+END_C_DECLS
+#endif /* _OSM_ROUTER_H_ */
diff --git a/contrib/ofed/opensm/include/opensm/osm_sa.h b/contrib/ofed/opensm/include/opensm/osm_sa.h
new file mode 100644
index 0000000..aeeaa02
--- /dev/null
+++ b/contrib/ofed/opensm/include/opensm/osm_sa.h
@@ -0,0 +1,617 @@
+/*
+ * Copyright (c) 2004-2009 Voltaire, Inc. All rights reserved.
+ * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved.
+ * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+/*
+ * Abstract:
+ * Declaration of osm_sa_t.
+ * This object represents an IBA subnet.
+ * This object is part of the OpenSM family of objects.
+ */
+
+#ifndef _OSM_SA_H_
+#define _OSM_SA_H_
+
+#include <iba/ib_types.h>
+#include <complib/cl_passivelock.h>
+#include <complib/cl_event.h>
+#include <complib/cl_thread.h>
+#include <complib/cl_timer.h>
+#include <complib/cl_dispatcher.h>
+#include <opensm/osm_stats.h>
+#include <opensm/osm_subnet.h>
+#include <vendor/osm_vendor_api.h>
+#include <opensm/osm_mad_pool.h>
+#include <opensm/osm_log.h>
+#include <opensm/osm_sa_mad_ctrl.h>
+#include <opensm/osm_sm.h>
+#include <opensm/osm_multicast.h>
+
+#ifdef __cplusplus
+# define BEGIN_C_DECLS extern "C" {
+# define END_C_DECLS }
+#else /* !__cplusplus */
+# define BEGIN_C_DECLS
+# define END_C_DECLS
+#endif /* __cplusplus */
+
+BEGIN_C_DECLS
+/****h* OpenSM/SA
+* NAME
+* SA
+*
+* DESCRIPTION
+* The SA object encapsulates the information needed by the
+* OpenSM to instantiate subnet administration. The OpenSM
+* allocates one SA object per subnet manager.
+*
+* The SA object is thread safe.
+*
+* This object should be treated as opaque and should
+* be manipulated only through the provided functions.
+*
+* AUTHOR
+* Ranjit Pandit, Intel
+* Anil Keshavamurthy, Intel
+*
+*********/
+
+/****d* OpenSM: SA/osm_sa_state_t
+* NAME
+* osm_sa_state_t
+*
+* DESCRIPTION
+* Enumerates the possible states of SA object.
+*
+* SYNOPSIS
+*/
+typedef enum _osm_sa_state {
+ OSM_SA_STATE_INIT = 0,
+ OSM_SA_STATE_READY
+} osm_sa_state_t;
+/***********/
+
+/****d* OpenSM: SA/osm_mpr_rec_t
+* NAME
+* osm_mpr_rec_t
+*
+* DESCRIPTION
+* SA MultiPathRecord response.
+*
+* SYNOPSIS
+*/
+typedef struct osm_mpr_rec {
+ ib_path_rec_t path_rec;
+ const osm_port_t *p_src_port;
+ const osm_port_t *p_dest_port;
+ int hops;
+} osm_mpr_rec_t;
+/***********/
+
+/****d* OpenSM: SA/osm_sa_item_t
+* NAME
+* osm_sa_item_t
+*
+* DESCRIPTION
+* SA response item.
+*
+* SYNOPSIS
+*/
+typedef struct osm_sa_item {
+ cl_list_item_t list_item;
+ union {
+ char data[0];
+ ib_guidinfo_record_t guid_rec;
+ ib_inform_info_t inform;
+ ib_inform_info_record_t inform_rec;
+ ib_lft_record_t lft_rec;
+ ib_link_record_t link_rec;
+ ib_member_rec_t mc_rec;
+ ib_mft_record_t mft_rec;
+ osm_mpr_rec_t mpr_rec;
+ ib_node_record_t node_rec;
+ ib_path_rec_t path_rec;
+ ib_pkey_table_record_t pkey_rec;
+ ib_portinfo_record_t port_rec;
+ ib_service_record_t service_rec;
+ ib_slvl_table_record_t slvl_rec;
+ ib_sminfo_record_t sminfo_rec;
+ ib_switch_info_record_t swinfo_rec;
+ ib_vl_arb_table_record_t vlarb_rec;
+ } resp;
+} osm_sa_item_t;
+/*
+* NOTES
+* Actual structure allocated is based on SA attribute
+* type. As such, it is variable sized. The allocation
+* occurs in the SA attribute handling code.
+* Note also that the size is specified external
+* to this structure (It's passed as a parameter to
+* osm_sa_respond). The SA_ITEM_RESP_SIZE macro
+* facilitates determining the size required.
+*
+***********/
+
+#define SA_ITEM_RESP_SIZE(_m) offsetof(osm_sa_item_t, resp._m) + \
+ sizeof(((osm_sa_item_t *)NULL)->resp._m)
+
+/****s* OpenSM: SM/osm_sa_t
+* NAME
+* osm_sa_t
+*
+* DESCRIPTION
+* Subnet Administration structure.
+*
+* This object should be treated as opaque and should
+* be manipulated only through the provided functions.
+*
+* SYNOPSIS
+*/
+typedef struct osm_sa {
+ osm_sa_state_t state;
+ osm_sm_t *sm;
+ osm_subn_t *p_subn;
+ osm_vendor_t *p_vendor;
+ osm_log_t *p_log;
+ osm_mad_pool_t *p_mad_pool;
+ cl_dispatcher_t *p_disp;
+ cl_dispatcher_t *p_set_disp;
+ cl_plock_t *p_lock;
+ atomic32_t sa_trans_id;
+ osm_sa_mad_ctrl_t mad_ctrl;
+ cl_timer_t sr_timer;
+ boolean_t dirty;
+ cl_disp_reg_handle_t cpi_disp_h;
+ cl_disp_reg_handle_t nr_disp_h;
+ cl_disp_reg_handle_t pir_disp_h;
+ cl_disp_reg_handle_t gir_disp_h;
+ cl_disp_reg_handle_t lr_disp_h;
+ cl_disp_reg_handle_t pr_disp_h;
+ cl_disp_reg_handle_t smir_disp_h;
+ cl_disp_reg_handle_t mcmr_disp_h;
+ cl_disp_reg_handle_t sr_disp_h;
+#if defined (VENDOR_RMPP_SUPPORT) && defined (DUAL_SIDED_RMPP)
+ cl_disp_reg_handle_t mpr_disp_h;
+#endif
+ cl_disp_reg_handle_t infr_disp_h;
+ cl_disp_reg_handle_t infir_disp_h;
+ cl_disp_reg_handle_t vlarb_disp_h;
+ cl_disp_reg_handle_t slvl_disp_h;
+ cl_disp_reg_handle_t pkey_disp_h;
+ cl_disp_reg_handle_t lft_disp_h;
+ cl_disp_reg_handle_t sir_disp_h;
+ cl_disp_reg_handle_t mft_disp_h;
+ cl_disp_reg_handle_t infr_set_disp_h;
+ cl_disp_reg_handle_t gir_set_disp_h;
+ cl_disp_reg_handle_t mcmr_set_disp_h;
+ cl_disp_reg_handle_t sr_set_disp_h;
+} osm_sa_t;
+/*
+* FIELDS
+* state
+* State of this SA object
+*
+* sm
+* Pointer to the Subnet Manager object.
+*
+* p_subn
+* Pointer to the Subnet object for this subnet.
+*
+* p_vendor
+* Pointer to the vendor specific interfaces object.
+*
+* p_log
+* Pointer to the log object.
+*
+* p_mad_pool
+* Pointer to the MAD pool.
+*
+* p_disp
+* Pointer to dispatcher
+*
+* p_set_disp
+* Pointer to dispatcher for Set requests.
+*
+* p_lock
+* Pointer to Lock for serialization
+*
+* sa_trans_id
+* Transaction ID
+*
+* mad_ctrl
+* Mad Controller
+*
+* dirty
+* A flag that denotes that SA DB is dirty and needs
+* to be written to the dump file (if dumping is enabled)
+*
+* SEE ALSO
+* SM object
+*********/
+
+/****f* OpenSM: SA/osm_sa_construct
+* NAME
+* osm_sa_construct
+*
+* DESCRIPTION
+* This function constructs an SA object.
+*
+* SYNOPSIS
+*/
+void osm_sa_construct(IN osm_sa_t * p_sa);
+/*
+* PARAMETERS
+* p_sa
+* [in] Pointer to a SA object to construct.
+*
+* RETURN VALUE
+* This function does not return a value.
+*
+* NOTES
+* Allows calling osm_sa_destroy.
+*
+* Calling osm_sa_construct is a prerequisite to calling any other
+* method except osm_sa_init.
+*
+* SEE ALSO
+* SA object, osm_sa_init, osm_sa_destroy
+*********/
+
+/****f* OpenSM: SA/osm_sa_shutdown
+* NAME
+* osm_sa_shutdown
+*
+* DESCRIPTION
+* The osm_sa_shutdown function shutdowns an SA, unregistering from all
+* dispatcher messages and unbinding the QP1 mad service
+*
+* SYNOPSIS
+*/
+void osm_sa_shutdown(IN osm_sa_t * p_sa);
+/*
+* PARAMETERS
+* p_sa
+* [in] Pointer to a SA object to shutdown.
+*
+* RETURN VALUE
+* This function does not return a value.
+*
+* SEE ALSO
+* SA object, osm_sa_construct, osm_sa_init
+*********/
+
+/****f* OpenSM: SA/osm_sa_destroy
+* NAME
+* osm_sa_destroy
+*
+* DESCRIPTION
+* The osm_sa_destroy function destroys an SA, releasing
+* all resources.
+*
+* SYNOPSIS
+*/
+void osm_sa_destroy(IN osm_sa_t * p_sa);
+/*
+* PARAMETERS
+* p_sa
+* [in] Pointer to a SA object to destroy.
+*
+* RETURN VALUE
+* This function does not return a value.
+*
+* NOTES
+* Performs any necessary cleanup of the specified SA object.
+* Further operations should not be attempted on the destroyed object.
+* This function should only be called after a call to osm_sa_construct or
+* osm_sa_init.
+*
+* SEE ALSO
+* SA object, osm_sa_construct, osm_sa_init
+*********/
+
+/****f* OpenSM: SA/osm_sa_init
+* NAME
+* osm_sa_init
+*
+* DESCRIPTION
+* The osm_sa_init function initializes a SA object for use.
+*
+* SYNOPSIS
+*/
+ib_api_status_t osm_sa_init(IN osm_sm_t * p_sm, IN osm_sa_t * p_sa,
+ IN osm_subn_t * p_subn, IN osm_vendor_t * p_vendor,
+ IN osm_mad_pool_t * p_mad_pool,
+ IN osm_log_t * p_log, IN osm_stats_t * p_stats,
+ IN cl_dispatcher_t * p_disp,
+ IN cl_dispatcher_t * p_set_disp,
+ IN cl_plock_t * p_lock);
+/*
+* PARAMETERS
+* p_sa
+* [in] Pointer to an osm_sa_t object to initialize.
+*
+* p_subn
+* [in] Pointer to the Subnet object for this subnet.
+*
+* p_vendor
+* [in] Pointer to the vendor specific interfaces object.
+*
+* p_mad_pool
+* [in] Pointer to the MAD pool.
+*
+* p_log
+* [in] Pointer to the log object.
+*
+* p_stats
+* [in] Pointer to the statistics object.
+*
+* p_disp
+* [in] Pointer to the OpenSM central Dispatcher.
+*
+* p_set_disp
+* [in] Pointer to the OpenSM Dispatcher for Set requests.
+*
+* p_lock
+* [in] Pointer to the OpenSM serializing lock.
+*
+* RETURN VALUES
+* CL_SUCCESS if the SA object was initialized successfully.
+*
+* NOTES
+* Allows calling other SA methods.
+*
+* SEE ALSO
+* SA object, osm_sa_construct, osm_sa_destroy
+*********/
+
+/****f* OpenSM: SA/osm_sa_bind
+* NAME
+* osm_sa_bind
+*
+* DESCRIPTION
+* Binds the SA object to a port guid.
+*
+* SYNOPSIS
+*/
+ib_api_status_t osm_sa_bind(IN osm_sa_t * p_sa, IN ib_net64_t port_guid);
+/*
+* PARAMETERS
+* p_sa
+* [in] Pointer to an osm_sa_t object to bind.
+*
+* port_guid
+* [in] Local port GUID with which to bind.
+*
+*
+* RETURN VALUES
+* None
+*
+* NOTES
+* A given SA object can only be bound to one port at a time.
+*
+* SEE ALSO
+*********/
+
+/****f* OpenSM: SA/osm_sa_send
+* NAME
+* osm_sa_send
+*
+* DESCRIPTION
+* Sends SA MAD via osm_vendor_send and maintains the QP1 sent statistic
+*
+* SYNOPSIS
+*/
+ib_api_status_t osm_sa_send(osm_sa_t *sa, IN osm_madw_t * p_madw,
+ IN boolean_t resp_expected);
+
+/****f* IBA Base: Types/osm_sa_send_error
+* NAME
+* osm_sa_send_error
+*
+* DESCRIPTION
+* Sends a generic SA response with the specified error status.
+* The payload is simply replicated from the request MAD.
+*
+* SYNOPSIS
+*/
+void osm_sa_send_error(IN osm_sa_t * sa, IN const osm_madw_t * p_madw,
+ IN ib_net16_t sa_status);
+/*
+* PARAMETERS
+* sa
+* [in] Pointer to an osm_sa_t object.
+*
+* p_madw
+* [in] Original MAD to which the response must be sent.
+*
+* sa_status
+* [in] Status to send in the response.
+*
+* RETURN VALUES
+* None.
+*
+* SEE ALSO
+* SA object
+*********/
+
+/****f* OpenSM: SA/osm_sa_respond
+* NAME
+* osm_sa_respond
+*
+* DESCRIPTION
+* Sends SA MAD response
+*/
+void osm_sa_respond(osm_sa_t *sa, osm_madw_t *madw, size_t attr_size,
+ cl_qlist_t *list);
+/*
+* PARAMETERS
+* sa
+* [in] Pointer to an osm_sa_t object.
+*
+* p_madw
+* [in] Original MAD to which the response must be sent.
+*
+* attr_size
+* [in] Size of this SA attribute.
+*
+* list
+* [in] List of attribute to respond - it will be freed after
+* sending.
+*
+* RETURN VALUES
+* None.
+*
+* SEE ALSO
+* SA object
+*********/
+
+struct osm_opensm;
+/****f* OpenSM: SA/osm_sa_db_file_dump
+* NAME
+* osm_sa_db_file_dump
+*
+* DESCRIPTION
+* Dumps the SA DB to the dump file.
+*
+* SYNOPSIS
+*/
+int osm_sa_db_file_dump(struct osm_opensm *p_osm);
+/*
+* PARAMETERS
+* p_osm
+* [in] Pointer to an osm_opensm_t object.
+*
+* RETURN VALUES
+* 0 if the SA DB was actually dumped
+* >0 if there was no need to dump the SA DB
+* <0 if some error occurred.
+*
+*********/
+
+/****f* OpenSM: SA/osm_sa_db_file_load
+* NAME
+* osm_sa_db_file_load
+*
+* DESCRIPTION
+* Loads SA DB from the file.
+*
+* SYNOPSIS
+*/
+int osm_sa_db_file_load(struct osm_opensm *p_osm);
+/*
+* PARAMETERS
+* p_osm
+* [in] Pointer to an osm_opensm_t object.
+*
+* RETURN VALUES
+* 0 on success, other value on failure.
+*
+*********/
+
+/****f* OpenSM: MC Member Record Receiver/osm_mcmr_rcv_find_or_create_new_mgrp
+* NAME
+* osm_mcmr_rcv_find_or_create_new_mgrp
+*
+* DESCRIPTION
+* Create new Multicast group
+*
+* SYNOPSIS
+*/
+
+osm_mgrp_t *osm_mcmr_rcv_find_or_create_new_mgrp(IN osm_sa_t * sa,
+ IN ib_net64_t comp_mask,
+ IN ib_member_rec_t *
+ p_recvd_mcmember_rec);
+/*
+* PARAMETERS
+* p_sa
+* [in] Pointer to an osm_sa_t object.
+* comp_mask
+* [in] SA query component mask
+* p_recvd_mcmember_rec
+* [in] Received Multicast member record
+*
+* RETURN VALUES
+* The pointer to MC group object found or created, NULL in case of errors
+*
+*********/
+
+/**
+ * The following expose functionality of osm_sa_path_record.c for internal use
+ * by sub managers
+ */
+typedef struct osm_path_parms {
+ ib_net16_t pkey;
+ uint8_t mtu;
+ uint8_t rate;
+ uint8_t sl;
+ uint8_t pkt_life;
+ boolean_t reversible;
+ int hops;
+} osm_path_parms_t;
+
+ib_api_status_t osm_get_path_params(IN osm_sa_t * sa,
+ IN const osm_port_t * p_src_port,
+ IN const uint16_t slid_ho,
+ IN const osm_port_t * p_dest_port,
+ IN const uint16_t dlid_ho,
+ OUT osm_path_parms_t * p_parms);
+
+ib_net16_t osm_pr_get_end_points(IN osm_sa_t * sa,
+ IN const ib_sa_mad_t *sa_mad,
+ OUT const osm_alias_guid_t ** pp_src_alias_guid,
+ OUT const osm_alias_guid_t ** pp_dest_alias_guid,
+ OUT const osm_port_t ** pp_src_port,
+ OUT const osm_port_t ** pp_dest_port,
+ OUT const ib_gid_t ** pp_sgid,
+ OUT const ib_gid_t ** pp_dgid);
+
+void osm_pr_process_pair(IN osm_sa_t * sa, IN const ib_sa_mad_t * sa_mad,
+ IN const osm_port_t * requester_port,
+ IN const osm_alias_guid_t * p_src_alias_guid,
+ IN const osm_alias_guid_t * p_dest_alias_guid,
+ IN const ib_gid_t * p_sgid,
+ IN const ib_gid_t * p_dgid,
+ IN cl_qlist_t * p_list);
+
+void osm_pr_process_half(IN osm_sa_t * sa, IN const ib_sa_mad_t * sa_mad,
+ IN const osm_port_t * requester_port,
+ IN const osm_alias_guid_t * p_src_alias_guid,
+ IN const osm_alias_guid_t * p_dest_alias_guid,
+ IN const ib_gid_t * p_sgid,
+ IN const ib_gid_t * p_dgid,
+ IN cl_qlist_t * p_list);
+
+END_C_DECLS
+#endif /* _OSM_SA_H_ */
diff --git a/contrib/ofed/opensm/include/opensm/osm_sa_mad_ctrl.h b/contrib/ofed/opensm/include/opensm/osm_sa_mad_ctrl.h
new file mode 100644
index 0000000..2c2513b
--- /dev/null
+++ b/contrib/ofed/opensm/include/opensm/osm_sa_mad_ctrl.h
@@ -0,0 +1,349 @@
+/*
+ * Copyright (c) 2004-2009 Voltaire, Inc. All rights reserved.
+ * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved.
+ * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+/*
+ * Abstract:
+ * Declaration of osm_sa_mad_ctrl_t.
+ * This object represents a controller that receives the IBA SA
+ * attributes from a node.
+ * This object is part of the OpenSM family of objects.
+ */
+
+#ifndef _OSM_SA_MAD_CTRL_H_
+#define _OSM_SA_MAD_CTRL_H_
+
+#include <complib/cl_dispatcher.h>
+#include <opensm/osm_stats.h>
+#include <opensm/osm_subnet.h>
+#include <opensm/osm_madw.h>
+#include <opensm/osm_mad_pool.h>
+#include <opensm/osm_log.h>
+
+#ifdef __cplusplus
+# define BEGIN_C_DECLS extern "C" {
+# define END_C_DECLS }
+#else /* !__cplusplus */
+# define BEGIN_C_DECLS
+# define END_C_DECLS
+#endif /* __cplusplus */
+
+BEGIN_C_DECLS
+/****h* OpenSM/SA MAD Controller
+* NAME
+* SA MAD Controller
+*
+* DESCRIPTION
+* The SA MAD Controller object encapsulates
+* the information needed to receive MADs from the transport layer.
+*
+* The SA MAD Controller object is thread safe.
+*
+* This object should be treated as opaque and should be
+* manipulated only through the provided functions.
+*
+* AUTHOR
+* Ranjit Pandit, Intel
+*
+*********/
+
+struct osm_sa;
+/****s* OpenSM: SA MAD Controller/osm_sa_mad_ctrl_t
+* NAME
+* osm_sa_mad_ctrl_t
+*
+* DESCRIPTION
+* SA MAD Controller structure.
+*
+* This object should be treated as opaque and should
+* be manipulated only through the provided functions.
+*
+* SYNOPSIS
+*/
+typedef struct osm_sa_mad_ctrl {
+ struct osm_sa *sa;
+ osm_log_t *p_log;
+ osm_mad_pool_t *p_mad_pool;
+ osm_vendor_t *p_vendor;
+ osm_bind_handle_t h_bind;
+ cl_dispatcher_t *p_disp;
+ cl_dispatcher_t *p_set_disp;
+ cl_disp_reg_handle_t h_disp;
+ cl_disp_reg_handle_t h_set_disp;
+ osm_stats_t *p_stats;
+ osm_subn_t *p_subn;
+} osm_sa_mad_ctrl_t;
+/*
+* FIELDS
+* sa
+* Pointer to the SA object.
+*
+* p_log
+* Pointer to the log object.
+*
+* p_mad_pool
+* Pointer to the MAD pool.
+*
+* p_vendor
+* Pointer to the vendor specific interfaces object.
+*
+* h_bind
+* Bind handle returned by the transport layer.
+*
+* p_disp
+* Pointer to the Dispatcher.
+*
+* p_set_disp
+* Pointer to the Dispatcher for Set requests.
+*
+* h_disp
+* Handle returned from dispatcher registration.
+*
+* h_set_disp
+* Handle returned from Set requests dispatcher registration.
+*
+* p_stats
+* Pointer to the OpenSM statistics block.
+*
+* SEE ALSO
+* SA MAD Controller object
+* SA MADr object
+*********/
+
+/****f* OpenSM: SA MAD Controller/osm_sa_mad_ctrl_construct
+* NAME
+* osm_sa_mad_ctrl_construct
+*
+* DESCRIPTION
+* This function constructs a SA MAD Controller object.
+*
+* SYNOPSIS
+*/
+void osm_sa_mad_ctrl_construct(IN osm_sa_mad_ctrl_t * p_ctrl);
+/*
+* PARAMETERS
+* p_ctrl
+* [in] Pointer to a SA MAD Controller
+* object to construct.
+*
+* RETURN VALUE
+* This function does not return a value.
+*
+* NOTES
+* Allows calling osm_sa_mad_ctrl_init, and osm_sa_mad_ctrl_destroy.
+*
+* Calling osm_sa_mad_ctrl_construct is a prerequisite to calling any other
+* method except osm_sa_mad_ctrl_init.
+*
+* SEE ALSO
+* SA MAD Controller object, osm_sa_mad_ctrl_init,
+* osm_sa_mad_ctrl_destroy
+*********/
+
+/****f* OpenSM: SA MAD Controller/osm_sa_mad_ctrl_destroy
+* NAME
+* osm_sa_mad_ctrl_destroy
+*
+* DESCRIPTION
+* The osm_sa_mad_ctrl_destroy function destroys the object, releasing
+* all resources.
+*
+* SYNOPSIS
+*/
+void osm_sa_mad_ctrl_destroy(IN osm_sa_mad_ctrl_t * p_ctrl);
+/*
+* PARAMETERS
+* p_ctrl
+* [in] Pointer to the object to destroy.
+*
+* RETURN VALUE
+* This function does not return a value.
+*
+* NOTES
+* Performs any necessary cleanup of the specified
+* SA MAD Controller object.
+* Further operations should not be attempted on the destroyed object.
+* This function should only be called after a call to
+* osm_sa_mad_ctrl_construct or osm_sa_mad_ctrl_init.
+*
+* SEE ALSO
+* SA MAD Controller object, osm_sa_mad_ctrl_construct,
+* osm_sa_mad_ctrl_init
+*********/
+
+/****f* OpenSM: SA MAD Controller/osm_sa_mad_ctrl_init
+* NAME
+* osm_sa_mad_ctrl_init
+*
+* DESCRIPTION
+* The osm_sa_mad_ctrl_init function initializes a
+* SA MAD Controller object for use.
+*
+* SYNOPSIS
+*/
+ib_api_status_t osm_sa_mad_ctrl_init(IN osm_sa_mad_ctrl_t * p_ctrl,
+ IN struct osm_sa * sa,
+ IN osm_mad_pool_t * p_mad_pool,
+ IN osm_vendor_t * p_vendor,
+ IN osm_subn_t * p_subn,
+ IN osm_log_t * p_log,
+ IN osm_stats_t * p_stats,
+ IN cl_dispatcher_t * p_disp,
+ IN cl_dispatcher_t * p_set_disp);
+/*
+* PARAMETERS
+* p_ctrl
+* [in] Pointer to an osm_sa_mad_ctrl_t object to initialize.
+*
+* sa
+* [in] Pointer to the SA object.
+*
+* p_mad_pool
+* [in] Pointer to the MAD pool.
+*
+* p_vendor
+* [in] Pointer to the vendor specific interfaces object.
+*
+* p_log
+* [in] Pointer to the log object.
+*
+* p_stats
+* [in] Pointer to the OpenSM stastics block.
+*
+* p_disp
+* [in] Pointer to the OpenSM central Dispatcher.
+*
+* p_set_disp
+* [in] Pointer to the OpenSM Dispatcher for Set requests.
+*
+* RETURN VALUES
+* IB_SUCCESS if the SA MAD Controller object was initialized
+* successfully.
+*
+* NOTES
+* Allows calling other SA MAD Controller methods.
+*
+* SEE ALSO
+* SA MAD Controller object, osm_sa_mad_ctrl_construct,
+* osm_sa_mad_ctrl_destroy
+*********/
+
+/****f* OpenSM: SA/osm_sa_mad_ctrl_bind
+* NAME
+* osm_sa_mad_ctrl_bind
+*
+* DESCRIPTION
+* Binds the SA MAD Controller object to a port guid.
+*
+* SYNOPSIS
+*/
+ib_api_status_t osm_sa_mad_ctrl_bind(IN osm_sa_mad_ctrl_t * p_ctrl,
+ IN ib_net64_t port_guid);
+/*
+* PARAMETERS
+* p_ctrl
+* [in] Pointer to an osm_sa_mad_ctrl_t object to initialize.
+*
+* port_guid
+* [in] Local port GUID with which to bind.
+*
+*
+* RETURN VALUES
+* None
+*
+* NOTES
+* A given SA MAD Controller object can only be bound to one
+* port at a time.
+*
+* SEE ALSO
+*********/
+
+/****f* OpenSM: SA/osm_sa_mad_ctrl_unbind
+* NAME
+* osm_sa_mad_ctrl_unbind
+*
+* DESCRIPTION
+* Un-Binds the SA MAD Controller object from the IB port
+*
+* SYNOPSIS
+*/
+ib_api_status_t osm_sa_mad_ctrl_unbind(IN osm_sa_mad_ctrl_t * p_ctrl);
+/*
+* PARAMETERS
+* p_ctrl
+* [in] Pointer to an osm_sa_mad_ctrl_t object to initialize.
+*
+* RETURN VALUES
+* None
+*
+* NOTES
+* A given SA MAD Controller should be previously bound to IB
+* port.
+*
+* SEE ALSO
+*********/
+
+/****f* OpenSM: SA/osm_sa_mad_ctrl_get_bind_handle
+* NAME
+* osm_sa_mad_ctrl_get_bind_handle
+*
+* DESCRIPTION
+* Returns the bind handle.
+*
+* SYNOPSIS
+*/
+static inline osm_bind_handle_t
+osm_sa_mad_ctrl_get_bind_handle(IN const osm_sa_mad_ctrl_t * p_ctrl)
+{
+ return p_ctrl->h_bind;
+}
+
+/*
+* PARAMETERS
+* p_ctrl
+* [in] Pointer to an osm_sa_mad_ctrl_t object.
+*
+* RETURN VALUES
+* Returns the bind handle, which may be OSM_BIND_INVALID_HANDLE
+* if no port has been bound.
+*
+* NOTES
+* A given SA MAD Controller object can only be bound to one
+* port at a time.
+*
+* SEE ALSO
+*********/
+
+END_C_DECLS
+#endif /* _OSM_SA_MAD_CTRL_H_ */
diff --git a/contrib/ofed/opensm/include/opensm/osm_service.h b/contrib/ofed/opensm/include/opensm/osm_service.h
new file mode 100644
index 0000000..446b888
--- /dev/null
+++ b/contrib/ofed/opensm/include/opensm/osm_service.h
@@ -0,0 +1,191 @@
+/*
+ * Copyright (c) 2004-2009 Voltaire, Inc. All rights reserved.
+ * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved.
+ * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+#ifndef _OSM_SVCR_H_
+#define _OSM_SVCR_H_
+
+/*
+ * Abstract:
+ * Declaration of osm_service_rec_t.
+ * This object represents an IBA Service Record.
+ * This object is part of the OpenSM family of objects.
+ */
+
+#include <iba/ib_types.h>
+#include <complib/cl_qmap.h>
+#include <complib/cl_spinlock.h>
+#include <opensm/osm_subnet.h>
+#include <opensm/osm_log.h>
+
+#ifdef __cplusplus
+# define BEGIN_C_DECLS extern "C" {
+# define END_C_DECLS }
+#else /* !__cplusplus */
+# define BEGIN_C_DECLS
+# define END_C_DECLS
+#endif /* __cplusplus */
+
+BEGIN_C_DECLS
+/****h* OpenSM/Service Record
+* NAME
+* Service Record
+*
+* DESCRIPTION
+* The service record encapsulates the information needed by the
+* SA to manage service registrations.
+*
+* The service records is not thread safe, thus callers must provide
+* serialization.
+*
+* This object should be treated as opaque and should be
+* manipulated only through the provided functions.
+*
+* AUTHOR
+* Anil S Keshavamurthy, Intel
+*
+*********/
+/****s* OpenSM: Service Record/osm_svcr_t
+* NAME
+* osm_svcr_t
+*
+* DESCRIPTION
+* Service Record structure.
+*
+* The osm_svcr_t object should be treated as opaque and should
+* be manipulated only through the provided functions.
+*
+* SYNOPSIS
+*/
+typedef struct osm_svcr {
+ cl_list_item_t list_item;
+ ib_service_record_t service_record;
+ uint32_t modified_time;
+ uint32_t lease_period;
+} osm_svcr_t;
+/*
+* FIELDS
+* map_item
+* Map Item for qmap linkage. Must be first element!!
+*
+* svc_rec
+* IB Service record structure
+*
+* modified_time
+* Last modified time of this record in milliseconds
+*
+* lease_period
+* Remaining lease period for this record
+*
+*
+* SEE ALSO
+*********/
+
+/****f* OpenSM: Service Record/osm_svcr_new
+* NAME
+* osm_svcr_new
+*
+* DESCRIPTION
+* Allocates and initializes a Service Record for use.
+*
+* SYNOPSIS
+*/
+osm_svcr_t *osm_svcr_new(IN const ib_service_record_t * p_svc_rec);
+/*
+* PARAMETERS
+* p_svc_rec
+* [in] Pointer to IB Service Record
+*
+* RETURN VALUES
+* pointer to osm_svcr_t structure.
+*
+* NOTES
+* Allows calling other service record methods.
+*
+* SEE ALSO
+* Service Record, osm_svcr_delete
+*********/
+
+/****f* OpenSM: Service Record/osm_svcr_init
+* NAME
+* osm_svcr_init
+*
+* DESCRIPTION
+* Initializes the osm_svcr_t structure.
+*
+* SYNOPSIS
+*/
+void osm_svcr_init(IN osm_svcr_t * p_svcr,
+ IN const ib_service_record_t * p_svc_rec);
+/*
+* PARAMETERS
+* p_svc_rec
+* [in] Pointer to osm_svcr_t structure
+* p_svc_rec
+* [in] Pointer to the ib_service_record_t
+*
+* SEE ALSO
+* Service Record
+*********/
+
+/****f* OpenSM: Service Record/osm_svcr_delete
+* NAME
+* osm_svcr_delete
+*
+* DESCRIPTION
+* Deallocates the osm_svcr_t structure.
+*
+* SYNOPSIS
+*/
+void osm_svcr_delete(IN osm_svcr_t * p_svcr);
+/*
+* PARAMETERS
+* p_svc_rec
+* [in] Pointer to osm_svcr_t structure
+*
+* SEE ALSO
+* Service Record, osm_svcr_new
+*********/
+
+osm_svcr_t *osm_svcr_get_by_rid(IN osm_subn_t const *p_subn,
+ IN osm_log_t * p_log,
+ IN ib_service_record_t * p_svc_rec);
+
+void osm_svcr_insert_to_db(IN osm_subn_t * p_subn, IN osm_log_t * p_log,
+ IN osm_svcr_t * p_svcr);
+void osm_svcr_remove_from_db(IN osm_subn_t * p_subn, IN osm_log_t * p_log,
+ IN osm_svcr_t * p_svcr);
+
+END_C_DECLS
+#endif /* _OSM_SVCR_H_ */
diff --git a/contrib/ofed/opensm/include/opensm/osm_sm.h b/contrib/ofed/opensm/include/opensm/osm_sm.h
new file mode 100644
index 0000000..94d1831
--- /dev/null
+++ b/contrib/ofed/opensm/include/opensm/osm_sm.h
@@ -0,0 +1,834 @@
+/*
+ * Copyright (c) 2004-2009 Voltaire, Inc. All rights reserved.
+ * Copyright (c) 2002-2011 Mellanox Technologies LTD. All rights reserved.
+ * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+/*
+ * Abstract:
+ * Declaration of osm_sm_t.
+ * This object represents an IBA subnet.
+ * This object is part of the OpenSM family of objects.
+ */
+
+#ifndef _OSM_SM_H_
+#define _OSM_SM_H_
+
+#include <iba/ib_types.h>
+#include <complib/cl_passivelock.h>
+#include <complib/cl_event.h>
+#include <complib/cl_thread.h>
+#include <complib/cl_dispatcher.h>
+#include <complib/cl_event_wheel.h>
+#include <vendor/osm_vendor_api.h>
+#include <opensm/osm_stats.h>
+#include <opensm/osm_subnet.h>
+#include <opensm/osm_vl15intf.h>
+#include <opensm/osm_mad_pool.h>
+#include <opensm/osm_log.h>
+#include <opensm/osm_sm_mad_ctrl.h>
+#include <opensm/osm_lid_mgr.h>
+#include <opensm/osm_ucast_mgr.h>
+#include <opensm/osm_port.h>
+#include <opensm/osm_db.h>
+#include <opensm/osm_remote_sm.h>
+#include <opensm/osm_multicast.h>
+
+#ifdef __cplusplus
+# define BEGIN_C_DECLS extern "C" {
+# define END_C_DECLS }
+#else /* !__cplusplus */
+# define BEGIN_C_DECLS
+# define END_C_DECLS
+#endif /* __cplusplus */
+
+BEGIN_C_DECLS
+/****h* OpenSM/SM
+* NAME
+* SM
+*
+* DESCRIPTION
+* The SM object encapsulates the information needed by the
+* OpenSM to instantiate a subnet manager. The OpenSM allocates
+* one SM object per subnet manager.
+*
+* The SM object is thread safe.
+*
+* This object should be treated as opaque and should
+* be manipulated only through the provided functions.
+*
+* AUTHOR
+* Steve King, Intel
+*
+*********/
+/****s* OpenSM: SM/osm_sm_t
+* NAME
+* osm_sm_t
+*
+* DESCRIPTION
+* Subnet Manager structure.
+*
+* This object should be treated as opaque and should
+* be manipulated only through the provided functions.
+*
+* SYNOPSIS
+*/
+typedef struct osm_sm {
+ osm_thread_state_t thread_state;
+ unsigned signal_mask;
+ cl_spinlock_t signal_lock;
+ cl_spinlock_t state_lock;
+ cl_event_t signal_event;
+ cl_event_t subnet_up_event;
+ cl_timer_t sweep_timer;
+ cl_timer_t polling_timer;
+ cl_event_wheel_t trap_aging_tracker;
+ cl_thread_t sweeper;
+ unsigned master_sm_found;
+ uint32_t retry_number;
+ ib_net64_t master_sm_guid;
+ ib_net64_t polling_sm_guid;
+ osm_subn_t *p_subn;
+ osm_db_t *p_db;
+ osm_vendor_t *p_vendor;
+ osm_log_t *p_log;
+ osm_mad_pool_t *p_mad_pool;
+ osm_vl15_t *p_vl15;
+ cl_dispatcher_t *p_disp;
+ cl_plock_t *p_lock;
+ atomic32_t sm_trans_id;
+ uint16_t mlids_init_max;
+ unsigned mlids_req_max;
+ uint8_t *mlids_req;
+ osm_sm_mad_ctrl_t mad_ctrl;
+ osm_lid_mgr_t lid_mgr;
+ osm_ucast_mgr_t ucast_mgr;
+ cl_disp_reg_handle_t sweep_fail_disp_h;
+ cl_disp_reg_handle_t ni_disp_h;
+ cl_disp_reg_handle_t pi_disp_h;
+ cl_disp_reg_handle_t gi_disp_h;
+ cl_disp_reg_handle_t nd_disp_h;
+ cl_disp_reg_handle_t si_disp_h;
+ cl_disp_reg_handle_t lft_disp_h;
+ cl_disp_reg_handle_t mft_disp_h;
+ cl_disp_reg_handle_t sm_info_disp_h;
+ cl_disp_reg_handle_t trap_disp_h;
+ cl_disp_reg_handle_t slvl_disp_h;
+ cl_disp_reg_handle_t vla_disp_h;
+ cl_disp_reg_handle_t pkey_disp_h;
+ cl_disp_reg_handle_t mlnx_epi_disp_h;
+} osm_sm_t;
+/*
+* FIELDS
+* p_subn
+* Pointer to the Subnet object for this subnet.
+*
+* p_db
+* Pointer to the database (persistency) object
+*
+* p_vendor
+* Pointer to the vendor specific interfaces object.
+*
+* p_log
+* Pointer to the log object.
+*
+* p_mad_pool
+* Pointer to the MAD pool.
+*
+* p_vl15
+* Pointer to the VL15 interface.
+*
+* mad_ctrl
+* MAD Controller.
+*
+* p_disp
+* Pointer to the Dispatcher.
+*
+* p_lock
+* Pointer to the serializing lock.
+*
+* SEE ALSO
+* SM object
+*********/
+
+/****f* OpenSM: SM/osm_sm_construct
+* NAME
+* osm_sm_construct
+*
+* DESCRIPTION
+* This function constructs an SM object.
+*
+* SYNOPSIS
+*/
+void osm_sm_construct(IN osm_sm_t * p_sm);
+/*
+* PARAMETERS
+* p_sm
+* [in] Pointer to a SM object to construct.
+*
+* RETURN VALUE
+* This function does not return a value.
+*
+* NOTES
+* Allows calling osm_sm_init, osm_sm_destroy
+*
+* Calling osm_sm_construct is a prerequisite to calling any other
+* method except osm_sm_init.
+*
+* SEE ALSO
+* SM object, osm_sm_init, osm_sm_destroy
+*********/
+
+/****f* OpenSM: SM/osm_sm_shutdown
+* NAME
+* osm_sm_shutdown
+*
+* DESCRIPTION
+* The osm_sm_shutdown function shutdowns an SM, stopping the sweeper
+* and unregistering all messages from the dispatcher
+*
+* SYNOPSIS
+*/
+void osm_sm_shutdown(IN osm_sm_t * p_sm);
+/*
+* PARAMETERS
+* p_sm
+* [in] Pointer to a SM object to shutdown.
+*
+* RETURN VALUE
+* This function does not return a value.
+*
+* SEE ALSO
+* SM object, osm_sm_construct, osm_sm_init
+*********/
+
+/****f* OpenSM: SM/osm_sm_destroy
+* NAME
+* osm_sm_destroy
+*
+* DESCRIPTION
+* The osm_sm_destroy function destroys an SM, releasing
+* all resources.
+*
+* SYNOPSIS
+*/
+void osm_sm_destroy(IN osm_sm_t * p_sm);
+/*
+* PARAMETERS
+* p_sm
+* [in] Pointer to a SM object to destroy.
+*
+* RETURN VALUE
+* This function does not return a value.
+*
+* NOTES
+* Performs any necessary cleanup of the specified SM object.
+* Further operations should not be attempted on the destroyed object.
+* This function should only be called after a call to osm_sm_construct or
+* osm_sm_init.
+*
+* SEE ALSO
+* SM object, osm_sm_construct, osm_sm_init
+*********/
+
+/****f* OpenSM: SM/osm_sm_init
+* NAME
+* osm_sm_init
+*
+* DESCRIPTION
+* The osm_sm_init function initializes a SM object for use.
+*
+* SYNOPSIS
+*/
+ib_api_status_t osm_sm_init(IN osm_sm_t * p_sm, IN osm_subn_t * p_subn,
+ IN osm_db_t * p_db, IN osm_vendor_t * p_vendor,
+ IN osm_mad_pool_t * p_mad_pool,
+ IN osm_vl15_t * p_vl15, IN osm_log_t * p_log,
+ IN osm_stats_t * p_stats,
+ IN cl_dispatcher_t * p_disp, IN cl_plock_t * p_lock);
+/*
+* PARAMETERS
+* p_sm
+* [in] Pointer to an osm_sm_t object to initialize.
+*
+* p_subn
+* [in] Pointer to the Subnet object for this subnet.
+*
+* p_vendor
+* [in] Pointer to the vendor specific interfaces object.
+*
+* p_mad_pool
+* [in] Pointer to the MAD pool.
+*
+* p_vl15
+* [in] Pointer to the VL15 interface.
+*
+* p_log
+* [in] Pointer to the log object.
+*
+* p_stats
+* [in] Pointer to the statistics object.
+*
+* p_disp
+* [in] Pointer to the OpenSM central Dispatcher.
+*
+* p_lock
+* [in] Pointer to the OpenSM serializing lock.
+*
+* RETURN VALUES
+* IB_SUCCESS if the SM object was initialized successfully.
+*
+* NOTES
+* Allows calling other SM methods.
+*
+* SEE ALSO
+* SM object, osm_sm_construct, osm_sm_destroy
+*********/
+
+/****f* OpenSM: SM/osm_sm_signal
+* NAME
+* osm_sm_signal
+*
+* DESCRIPTION
+* Signal event to SM
+*
+* SYNOPSIS
+*/
+void osm_sm_signal(IN osm_sm_t * p_sm, osm_signal_t signal);
+/*
+* PARAMETERS
+* p_sm
+* [in] Pointer to an osm_sm_t object.
+*
+* signal
+* [in] sm signal number.
+*
+* NOTES
+*
+* SEE ALSO
+* SM object
+*********/
+
+/****f* OpenSM: SM/osm_sm_sweep
+* NAME
+* osm_sm_sweep
+*
+* DESCRIPTION
+* Initiates a subnet sweep.
+*
+* SYNOPSIS
+*/
+void osm_sm_sweep(IN osm_sm_t * p_sm);
+/*
+* PARAMETERS
+* p_sm
+* [in] Pointer to an osm_sm_t object.
+*
+* RETURN VALUES
+* IB_SUCCESS if the sweep completed successfully.
+*
+* NOTES
+*
+* SEE ALSO
+* SM object
+*********/
+
+/****f* OpenSM: SM/osm_sm_bind
+* NAME
+* osm_sm_bind
+*
+* DESCRIPTION
+* Binds the sm object to a port guid.
+*
+* SYNOPSIS
+*/
+ib_api_status_t osm_sm_bind(IN osm_sm_t * p_sm, IN ib_net64_t port_guid);
+/*
+* PARAMETERS
+* p_sm
+* [in] Pointer to an osm_sm_t object to bind.
+*
+* port_guid
+* [in] Local port GUID with which to bind.
+*
+*
+* RETURN VALUES
+* None
+*
+* NOTES
+* A given SM object can only be bound to one port at a time.
+*
+* SEE ALSO
+*********/
+
+/****f* OpenSM: SM/osm_req_get
+* NAME
+* osm_req_get
+*
+* DESCRIPTION
+* Starts the process to transmit a directed route request for
+* the attribute.
+*
+* SYNOPSIS
+*/
+ib_api_status_t osm_req_get(IN osm_sm_t * sm, IN const osm_dr_path_t * p_path,
+ IN ib_net16_t attr_id, IN ib_net32_t attr_mod,
+ IN boolean_t find_mkey, ib_net64_t m_key,
+ IN cl_disp_msgid_t err_msg,
+ IN const osm_madw_context_t * p_context);
+/*
+* PARAMETERS
+* sm
+* [in] Pointer to an osm_sm_t object.
+*
+* p_path
+* [in] Pointer to the directed route path to the node
+* from which to retrieve the attribute.
+*
+* attr_id
+* [in] Attribute ID to request.
+*
+* attr_mod
+* [in] Attribute modifier for this request.
+*
+* find_mkey
+* [in] Flag to indicate whether the M_Key should be looked up for
+* this MAD.
+* m_key
+* [in] M_Key value to be send with this MAD. Applied, only when
+* find_mkey is FALSE.
+*
+* err_msg
+* [in] Message id with which to post this MAD if an error occurs.
+*
+* p_context
+* [in] Mad wrapper context structure to be copied into the wrapper
+* context, and thus visible to the recipient of the response.
+*
+* RETURN VALUES
+* IB_SUCCESS if the request was successful.
+*
+* NOTES
+* This function asynchronously requests the specified attribute.
+* The response from the node will be routed through the Dispatcher
+* to the appropriate receive controller object.
+*********/
+
+/****f* OpenSM: SM/osm_send_req_mad
+* NAME
+* osm_send_req_mad
+*
+* DESCRIPTION
+* Starts the process to transmit a preallocated/predefined directed route
+* Set() request.
+*
+* SYNOPSIS
+*/
+void osm_send_req_mad(IN osm_sm_t * sm, IN osm_madw_t *p_madw);
+/*
+* PARAMETERS
+* sm
+* [in] Pointer to an osm_sm_t object.
+* p_madw
+* [in] Pointer to a preallocated MAD buffer
+*
+*********/
+
+/***f* OpenSM: SM/osm_prepare_req_set
+* NAME
+* osm_prepare_req_set
+*
+* DESCRIPTION
+* Preallocate and fill a directed route Set() MAD w/o sending it.
+*
+* SYNOPSIS
+*/
+osm_madw_t *osm_prepare_req_set(IN osm_sm_t * sm, IN const osm_dr_path_t * p_path,
+ IN const uint8_t * p_payload,
+ IN size_t payload_size, IN ib_net16_t attr_id,
+ IN ib_net32_t attr_mod, IN boolean_t find_mkey,
+ IN ib_net64_t m_key, IN cl_disp_msgid_t err_msg,
+ IN const osm_madw_context_t * p_context);
+/*
+* PARAMETERS
+* sm
+* [in] Pointer to an osm_sm_t object.
+*
+* p_path
+* [in] Pointer to the directed route path of the recipient.
+*
+* p_payload
+* [in] Pointer to the SMP payload to send.
+*
+* payload_size
+* [in] The size of the payload to be copied to the SMP data field.
+*
+* attr_id
+* [in] Attribute ID to request.
+*
+* attr_mod
+* [in] Attribute modifier for this request.
+*
+* find_mkey
+* [in] Flag to indicate whether the M_Key should be looked up for
+* this MAD.
+* m_key
+* [in] M_Key value to be send with this MAD. Applied, only when
+* find_mkey is FALSE.
+*
+* err_msg
+* [in] Message id with which to post this MAD if an error occurs.
+*
+* p_context
+* [in] Mad wrapper context structure to be copied into the wrapper
+* context, and thus visible to the recipient of the response.
+*
+* RETURN VALUES
+* Pointer the MAD buffer in case of success and NULL in case of failure.
+*
+*********/
+
+/****f* OpenSM: SM/osm_req_set
+* NAME
+* osm_req_set
+*
+* DESCRIPTION
+* Starts the process to transmit a directed route Set() request.
+*
+* SYNOPSIS
+*/
+ib_api_status_t osm_req_set(IN osm_sm_t * sm, IN const osm_dr_path_t * p_path,
+ IN const uint8_t * p_payload,
+ IN size_t payload_size, IN ib_net16_t attr_id,
+ IN ib_net32_t attr_mod, IN boolean_t find_mkey,
+ IN ib_net64_t m_key, IN cl_disp_msgid_t err_msg,
+ IN const osm_madw_context_t * p_context);
+/*
+* PARAMETERS
+* sm
+* [in] Pointer to an osm_sm_t object.
+*
+* p_path
+* [in] Pointer to the directed route path of the recipient.
+*
+* p_payload
+* [in] Pointer to the SMP payload to send.
+*
+* payload_size
+* [in] The size of the payload to be copied to the SMP data field.
+*
+* attr_id
+* [in] Attribute ID to request.
+*
+* attr_mod
+* [in] Attribute modifier for this request.
+*
+* find_mkey
+* [in] Flag to indicate whether the M_Key should be looked up for
+* this MAD.
+*
+* m_key
+* [in] M_Key value to be send with this MAD. Applied, only when
+* find_mkey is FALSE.
+*
+* err_msg
+* [in] Message id with which to post this MAD if an error occurs.
+*
+* p_context
+* [in] Mad wrapper context structure to be copied into the wrapper
+* context, and thus visible to the recipient of the response.
+*
+* RETURN VALUES
+* IB_SUCCESS if the request was successful.
+*
+* NOTES
+* This function asynchronously requests the specified attribute.
+* The response from the node will be routed through the Dispatcher
+* to the appropriate receive controller object.
+*********/
+/****f* OpenSM: SM/osm_resp_send
+* NAME
+* osm_resp_send
+*
+* DESCRIPTION
+* Starts the process to transmit a directed route response.
+*
+* SYNOPSIS
+*/
+ib_api_status_t osm_resp_send(IN osm_sm_t * sm,
+ IN const osm_madw_t * p_req_madw,
+ IN ib_net16_t status,
+ IN const uint8_t * p_payload);
+/*
+* PARAMETERS
+* p_resp
+* [in] Pointer to an osm_resp_t object.
+*
+* p_madw
+* [in] Pointer to the MAD Wrapper object for the requesting MAD
+* to which this response is generated.
+*
+* status
+* [in] Status for this response.
+*
+* p_payload
+* [in] Pointer to the payload of the response MAD.
+*
+* RETURN VALUES
+* IB_SUCCESS if the response was successful.
+*
+*********/
+
+/****f* OpenSM: SM/osm_sm_reroute_mlid
+* NAME
+* osm_sm_reroute_mlid
+*
+* DESCRIPTION
+* Requests (schedules) MLID rerouting
+*
+* SYNOPSIS
+*/
+void osm_sm_reroute_mlid(osm_sm_t * sm, ib_net16_t mlid);
+
+/*
+* PARAMETERS
+* sm
+* [in] Pointer to an osm_sm_t object.
+*
+* mlid
+* [in] MLID value
+*
+* RETURN VALUES
+* None
+*
+* NOTES
+*
+* SEE ALSO
+*********/
+
+/****f* OpenSM: OpenSM/osm_sm_wait_for_subnet_up
+* NAME
+* osm_sm_wait_for_subnet_up
+*
+* DESCRIPTION
+* Blocks the calling thread until the subnet is up.
+*
+* SYNOPSIS
+*/
+static inline cl_status_t osm_sm_wait_for_subnet_up(IN osm_sm_t * p_sm,
+ IN uint32_t wait_us,
+ IN boolean_t interruptible)
+{
+ return cl_event_wait_on(&p_sm->subnet_up_event, wait_us, interruptible);
+}
+
+/*
+* PARAMETERS
+* p_sm
+* [in] Pointer to an osm_sm_t object.
+*
+* wait_us
+* [in] Number of microseconds to wait.
+*
+* interruptible
+* [in] Indicates whether the wait operation can be interrupted
+* by external signals.
+*
+* RETURN VALUES
+* CL_SUCCESS if the wait operation succeeded in response to the event
+* being set.
+*
+* CL_TIMEOUT if the specified time period elapses.
+*
+* CL_NOT_DONE if the wait was interrupted by an external signal.
+*
+* CL_ERROR if the wait operation failed.
+*
+* NOTES
+*
+* SEE ALSO
+*********/
+
+/****f* OpenSM: State Manager/osm_sm_is_greater_than
+* NAME
+* osm_sm_is_greater_than
+*
+* DESCRIPTION
+* Compares two SM's (14.4.1.2)
+*
+* SYNOPSIS
+*/
+static inline boolean_t osm_sm_is_greater_than(IN uint8_t l_priority,
+ IN ib_net64_t l_guid,
+ IN uint8_t r_priority,
+ IN ib_net64_t r_guid)
+{
+ return (l_priority > r_priority
+ || (l_priority == r_priority
+ && cl_ntoh64(l_guid) < cl_ntoh64(r_guid)));
+}
+
+/*
+* PARAMETERS
+* l_priority
+* [in] Priority of the SM on the "left"
+*
+* l_guid
+* [in] GUID of the SM on the "left"
+*
+* r_priority
+* [in] Priority of the SM on the "right"
+*
+* r_guid
+* [in] GUID of the SM on the "right"
+*
+* RETURN VALUES
+* Return TRUE if an sm with l_priority and l_guid is higher than an sm
+* with r_priority and r_guid, return FALSE otherwise.
+*
+* NOTES
+*
+* SEE ALSO
+* State Manager
+*********/
+
+/****f* OpenSM: SM State Manager/osm_sm_state_mgr_process
+* NAME
+* osm_sm_state_mgr_process
+*
+* DESCRIPTION
+* Processes and maintains the states of the SM.
+*
+* SYNOPSIS
+*/
+ib_api_status_t osm_sm_state_mgr_process(IN osm_sm_t *sm,
+ IN osm_sm_signal_t signal);
+/*
+* PARAMETERS
+* sm
+* [in] Pointer to an osm_sm_t object.
+*
+* signal
+* [in] Signal to the state SM engine.
+*
+* RETURN VALUES
+* None.
+*
+* NOTES
+*
+* SEE ALSO
+* State Manager
+*********/
+
+/****f* OpenSM: SM State Manager/osm_sm_state_mgr_signal_master_is_alive
+* NAME
+* osm_sm_state_mgr_signal_master_is_alive
+*
+* DESCRIPTION
+* Signals that the remote Master SM is alive.
+* Need to clear the retry_number variable.
+*
+* SYNOPSIS
+*/
+void osm_sm_state_mgr_signal_master_is_alive(IN osm_sm_t *sm);
+/*
+* PARAMETERS
+* sm
+* [in] Pointer to an osm_sm_t object.
+*
+* RETURN VALUES
+* None.
+*
+* NOTES
+*
+* SEE ALSO
+* State Manager
+*********/
+
+/****f* OpenSM: SM State Manager/osm_sm_state_mgr_check_legality
+* NAME
+* osm_sm_state_mgr_check_legality
+*
+* DESCRIPTION
+* Checks the legality of the signal received, according to the
+* current state of the SM state machine.
+*
+* SYNOPSIS
+*/
+ib_api_status_t osm_sm_state_mgr_check_legality(IN osm_sm_t *sm,
+ IN osm_sm_signal_t signal);
+/*
+* PARAMETERS
+* sm
+* [in] Pointer to an osm_sm_t object.
+*
+* signal
+* [in] Signal to the state SM engine.
+*
+* RETURN VALUES
+* None.
+*
+* NOTES
+*
+* SEE ALSO
+* State Manager
+*********/
+
+void osm_report_sm_state(osm_sm_t *sm);
+
+/****f* OpenSM: SM State Manager/osm_send_trap144
+* NAME
+* osm_send_trap144
+*
+* DESCRIPTION
+* Send trap 144 to the master SM.
+*
+* SYNOPSIS
+*/
+int osm_send_trap144(osm_sm_t *sm, ib_net16_t local);
+/*
+* PARAMETERS
+* sm
+* [in] Pointer to an osm_sm_t object.
+*
+* local
+* [in] OtherLocalChanges mask in network byte order.
+*
+* RETURN VALUES
+* 0 on success, non-zero value otherwise.
+*
+*********/
+
+void osm_set_sm_priority(osm_sm_t *sm, uint8_t priority);
+
+END_C_DECLS
+#endif /* _OSM_SM_H_ */
diff --git a/contrib/ofed/opensm/include/opensm/osm_sm_mad_ctrl.h b/contrib/ofed/opensm/include/opensm/osm_sm_mad_ctrl.h
new file mode 100644
index 0000000..8969835
--- /dev/null
+++ b/contrib/ofed/opensm/include/opensm/osm_sm_mad_ctrl.h
@@ -0,0 +1,321 @@
+/*
+ * Copyright (c) 2004-2009 Voltaire, Inc. All rights reserved.
+ * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved.
+ * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+/*
+ * Abstract:
+ * Declaration of osm_sm_mad_ctrl_t.
+ * This object represents a controller that receives the IBA NodeInfo
+ * attribute from a node.
+ * This object is part of the OpenSM family of objects.
+ */
+
+#ifndef _OSM_SM_MAD_CTRL_H_
+#define _OSM_SM_MAD_CTRL_H_
+
+#include <complib/cl_passivelock.h>
+#include <complib/cl_dispatcher.h>
+#include <opensm/osm_base.h>
+#include <opensm/osm_stats.h>
+#include <opensm/osm_madw.h>
+#include <opensm/osm_mad_pool.h>
+#include <opensm/osm_subnet.h>
+#include <opensm/osm_log.h>
+#include <opensm/osm_vl15intf.h>
+
+#ifdef __cplusplus
+# define BEGIN_C_DECLS extern "C" {
+# define END_C_DECLS }
+#else /* !__cplusplus */
+# define BEGIN_C_DECLS
+# define END_C_DECLS
+#endif /* __cplusplus */
+
+BEGIN_C_DECLS
+/****h* OpenSM/SM MAD Controller
+* NAME
+* SM MAD Controller
+*
+* DESCRIPTION
+* The SM MAD Controller object encapsulates
+* the information needed to receive MADs from the transport layer.
+*
+* The SM MAD Controller object is thread safe.
+*
+* This object should be treated as opaque and should be
+* manipulated only through the provided functions.
+*
+* AUTHOR
+* Steve King, Intel
+*
+*********/
+/****s* OpenSM: SM MAD Controller/osm_sm_mad_ctrl_t
+* NAME
+* osm_sm_mad_ctrl_t
+*
+* DESCRIPTION
+* SM MAD Controller structure.
+*
+* This object should be treated as opaque and should
+* be manipulated only through the provided functions.
+*
+* SYNOPSIS
+*/
+typedef struct osm_sm_mad_ctrl {
+ osm_log_t *p_log;
+ osm_subn_t *p_subn;
+ osm_mad_pool_t *p_mad_pool;
+ osm_vl15_t *p_vl15;
+ osm_vendor_t *p_vendor;
+ osm_bind_handle_t h_bind;
+ cl_plock_t *p_lock;
+ cl_dispatcher_t *p_disp;
+ cl_disp_reg_handle_t h_disp;
+ osm_stats_t *p_stats;
+} osm_sm_mad_ctrl_t;
+/*
+* FIELDS
+* p_log
+* Pointer to the log object.
+*
+* p_subn
+* Pointer to the subnet object.
+*
+* p_mad_pool
+* Pointer to the MAD pool.
+*
+* p_vendor
+* Pointer to the vendor specific interfaces object.
+*
+* h_bind
+* Bind handle returned by the transport layer.
+*
+* p_lock
+* Pointer to the serializing lock.
+*
+* p_disp
+* Pointer to the Dispatcher.
+*
+* h_disp
+* Handle returned from dispatcher registration.
+*
+* p_stats
+* Pointer to the OpenSM statistics block.
+*
+* SEE ALSO
+* SM MAD Controller object
+* SM MADr object
+*********/
+
+/****f* OpenSM: SM MAD Controller/osm_sm_mad_ctrl_construct
+* NAME
+* osm_sm_mad_ctrl_construct
+*
+* DESCRIPTION
+* This function constructs a SM MAD Controller object.
+*
+* SYNOPSIS
+*/
+void osm_sm_mad_ctrl_construct(IN osm_sm_mad_ctrl_t * p_ctrl);
+/*
+* PARAMETERS
+* p_ctrl
+* [in] Pointer to a SM MAD Controller
+* object to construct.
+*
+* RETURN VALUE
+* This function does not return a value.
+*
+* NOTES
+* Allows calling osm_sm_mad_ctrl_init, and osm_sm_mad_ctrl_destroy.
+*
+* Calling osm_sm_mad_ctrl_construct is a prerequisite to calling any other
+* method except osm_sm_mad_ctrl_init.
+*
+* SEE ALSO
+* SM MAD Controller object, osm_sm_mad_ctrl_init,
+* osm_sm_mad_ctrl_destroy
+*********/
+
+/****f* OpenSM: SM MAD Controller/osm_sm_mad_ctrl_destroy
+* NAME
+* osm_sm_mad_ctrl_destroy
+*
+* DESCRIPTION
+* The osm_sm_mad_ctrl_destroy function destroys the object, releasing
+* all resources.
+*
+* SYNOPSIS
+*/
+void osm_sm_mad_ctrl_destroy(IN osm_sm_mad_ctrl_t * p_ctrl);
+/*
+* PARAMETERS
+* p_ctrl
+* [in] Pointer to the object to destroy.
+*
+* RETURN VALUE
+* This function does not return a value.
+*
+* NOTES
+* Performs any necessary cleanup of the specified
+* SM MAD Controller object.
+* Further operations should not be attempted on the destroyed object.
+* This function should only be called after a call to
+* osm_sm_mad_ctrl_construct or osm_sm_mad_ctrl_init.
+*
+* SEE ALSO
+* SM MAD Controller object, osm_sm_mad_ctrl_construct,
+* osm_sm_mad_ctrl_init
+*********/
+
+/****f* OpenSM: SM MAD Controller/osm_sm_mad_ctrl_init
+* NAME
+* osm_sm_mad_ctrl_init
+*
+* DESCRIPTION
+* The osm_sm_mad_ctrl_init function initializes a
+* SM MAD Controller object for use.
+*
+* SYNOPSIS
+*/
+ib_api_status_t osm_sm_mad_ctrl_init(IN osm_sm_mad_ctrl_t * p_ctrl,
+ IN osm_subn_t * p_subn,
+ IN osm_mad_pool_t * p_mad_pool,
+ IN osm_vl15_t * p_vl15,
+ IN osm_vendor_t * p_vendor,
+ IN osm_log_t * p_log,
+ IN osm_stats_t * p_stats,
+ IN cl_plock_t * p_lock,
+ IN cl_dispatcher_t * p_disp);
+/*
+* PARAMETERS
+* p_ctrl
+* [in] Pointer to an osm_sm_mad_ctrl_t object to initialize.
+*
+* p_mad_pool
+* [in] Pointer to the MAD pool.
+*
+* p_vl15
+* [in] Pointer to the VL15 interface object.
+*
+* p_vendor
+* [in] Pointer to the vendor specific interfaces object.
+*
+* p_log
+* [in] Pointer to the log object.
+*
+* p_stats
+* [in] Pointer to the OpenSM stastics block.
+*
+* p_lock
+* [in] Pointer to the OpenSM serializing lock.
+*
+* p_disp
+* [in] Pointer to the OpenSM central Dispatcher.
+*
+* RETURN VALUES
+* IB_SUCCESS if the SM MAD Controller object was initialized
+* successfully.
+*
+* NOTES
+* Allows calling other SM MAD Controller methods.
+*
+* SEE ALSO
+* SM MAD Controller object, osm_sm_mad_ctrl_construct,
+* osm_sm_mad_ctrl_destroy
+*********/
+
+/****f* OpenSM: SM/osm_sm_mad_ctrl_bind
+* NAME
+* osm_sm_mad_ctrl_bind
+*
+* DESCRIPTION
+* Binds the SM MAD Controller object to a port guid.
+*
+* SYNOPSIS
+*/
+ib_api_status_t osm_sm_mad_ctrl_bind(IN osm_sm_mad_ctrl_t * p_ctrl,
+ IN ib_net64_t port_guid);
+/*
+* PARAMETERS
+* p_ctrl
+* [in] Pointer to an osm_sm_mad_ctrl_t object to initialize.
+*
+* port_guid
+* [in] Local port GUID with which to bind.
+*
+*
+* RETURN VALUES
+* None
+*
+* NOTES
+* A given SM MAD Controller object can only be bound to one
+* port at a time.
+*
+* SEE ALSO
+*********/
+
+/****f* OpenSM: SM/osm_sm_mad_ctrl_get_bind_handle
+* NAME
+* osm_sm_mad_ctrl_get_bind_handle
+*
+* DESCRIPTION
+* Returns the bind handle.
+*
+* SYNOPSIS
+*/
+static inline osm_bind_handle_t
+osm_sm_mad_ctrl_get_bind_handle(IN const osm_sm_mad_ctrl_t * p_ctrl)
+{
+ return p_ctrl->h_bind;
+}
+
+/*
+* PARAMETERS
+* p_ctrl
+* [in] Pointer to an osm_sm_mad_ctrl_t object.
+*
+* RETURN VALUES
+* Returns the bind handle, which may be OSM_BIND_INVALID_HANDLE
+* if no port has been bound.
+*
+* NOTES
+* A given SM MAD Controller object can only be bound to one
+* port at a time.
+*
+* SEE ALSO
+*********/
+
+END_C_DECLS
+#endif /* _OSM_SM_MAD_CTRL_H_ */
diff --git a/contrib/ofed/management/opensm/include/opensm/osm_stats.h b/contrib/ofed/opensm/include/opensm/osm_stats.h
index 4331cfa..4331cfa 100644
--- a/contrib/ofed/management/opensm/include/opensm/osm_stats.h
+++ b/contrib/ofed/opensm/include/opensm/osm_stats.h
diff --git a/contrib/ofed/opensm/include/opensm/osm_subnet.h b/contrib/ofed/opensm/include/opensm/osm_subnet.h
new file mode 100644
index 0000000..b9643ec
--- /dev/null
+++ b/contrib/ofed/opensm/include/opensm/osm_subnet.h
@@ -0,0 +1,1623 @@
+/*
+ * Copyright (c) 2004-2009 Voltaire, Inc. All rights reserved.
+ * Copyright (c) 2002-2015 Mellanox Technologies LTD. All rights reserved.
+ * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
+ * Copyright (c) 2008 Xsigo Systems Inc. All rights reserved.
+ * Copyright (c) 2009 System Fabric Works, Inc. All rights reserved.
+ * Copyright (c) 2009 HNR Consulting. All rights reserved.
+ * Copyright (c) 2013 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2009-2015 ZIH, TU Dresden, Federal Republic of Germany. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+/*
+ * Abstract:
+ * Declaration of osm_subn_t.
+ * This object represents an IBA subnet.
+ * This object is part of the OpenSM family of objects.
+ */
+
+#ifndef _OSM_SUBNET_H_
+#define _OSM_SUBNET_H_
+
+#include <iba/ib_types.h>
+#include <complib/cl_qmap.h>
+#include <complib/cl_fleximap.h>
+#include <complib/cl_map.h>
+#include <complib/cl_ptr_vector.h>
+#include <complib/cl_list.h>
+#include <opensm/osm_base.h>
+#include <opensm/osm_prefix_route.h>
+#include <opensm/osm_db.h>
+#include <stdio.h>
+
+#ifdef __cplusplus
+# define BEGIN_C_DECLS extern "C" {
+# define END_C_DECLS }
+#else /* !__cplusplus */
+# define BEGIN_C_DECLS
+# define END_C_DECLS
+#endif /* __cplusplus */
+
+BEGIN_C_DECLS
+#define OSM_SUBNET_VECTOR_MIN_SIZE 0
+#define OSM_SUBNET_VECTOR_GROW_SIZE 1
+#define OSM_SUBNET_VECTOR_CAPACITY 256
+
+#define OSM_PARTITION_ENFORCE_BOTH "both"
+#define OSM_PARTITION_ENFORCE_IN "in"
+#define OSM_PARTITION_ENFORCE_OUT "out"
+#define OSM_PARTITION_ENFORCE_OFF "off"
+
+typedef enum _osm_partition_enforce_type_enum {
+ OSM_PARTITION_ENFORCE_TYPE_BOTH,
+ OSM_PARTITION_ENFORCE_TYPE_IN,
+ OSM_PARTITION_ENFORCE_TYPE_OUT,
+ OSM_PARTITION_ENFORCE_TYPE_OFF
+} osm_partition_enforce_type_enum;
+
+/* XXX: not actual max, max we're currently going to support */
+#define OSM_CCT_ENTRY_MAX 128
+#define OSM_CCT_ENTRY_MAD_BLOCKS (OSM_CCT_ENTRY_MAX/64)
+
+struct osm_opensm;
+struct osm_qos_policy;
+
+/****h* OpenSM/Subnet
+* NAME
+* Subnet
+*
+* DESCRIPTION
+* The Subnet object encapsulates the information needed by the
+* OpenSM to manage a subnet. The OpenSM allocates one Subnet object
+* per IBA subnet.
+*
+* The Subnet object is not thread safe, thus callers must provide
+* serialization.
+*
+* This object is essentially a container for the various components
+* of a subnet. Callers may directly access the member variables.
+*
+* AUTHOR
+* Steve King, Intel
+*
+*********/
+
+/****s* OpenSM: Subnet/osm_qos_options_t
+* NAME
+* osm_qos_options_t
+*
+* DESCRIPTION
+* Subnet QoS options structure. This structure contains the various
+* QoS specific configuration parameters for the subnet.
+*
+* SYNOPSIS
+*/
+typedef struct osm_qos_options {
+ unsigned max_vls;
+ int high_limit;
+ char *vlarb_high;
+ char *vlarb_low;
+ char *sl2vl;
+} osm_qos_options_t;
+/*
+* FIELDS
+*
+* max_vls
+* The number of maximum VLs on the Subnet (0 == use default)
+*
+* high_limit
+* The limit of High Priority component of VL Arbitration
+* table (IBA 7.6.9) (-1 == use default)
+*
+* vlarb_high
+* High priority VL Arbitration table template. (NULL == use default)
+*
+* vlarb_low
+* Low priority VL Arbitration table template. (NULL == use default)
+*
+* sl2vl
+* SL2VL Mapping table (IBA 7.6.6) template. (NULL == use default)
+*
+*********/
+
+/****s* OpenSM: Subnet/osm_cct_entry_t
+* NAME
+* osm_cct_entry_t
+*
+* DESCRIPTION
+* Subnet Congestion Control Table entry. See A10.2.2.1.1 for format details.
+*
+* SYNOPSIS
+*/
+typedef struct osm_cct_entry {
+ uint8_t shift; //Alex: shift 2 bits
+ uint16_t multiplier; //Alex multiplier 14 bits
+} osm_cct_entry_t;
+/*
+* FIELDS
+*
+* shift
+* shift field in CCT entry. See A10.2.2.1.1.
+*
+* multiplier
+* multiplier field in CCT entry. See A10.2.2.1.1.
+*
+*********/
+
+/****s* OpenSM: Subnet/osm_cacongestion_entry_t
+* NAME
+* osm_cacongestion_entry_t
+*
+* DESCRIPTION
+* Subnet CA Congestion entry. See A10.4.3.8.4 for format details.
+*
+* SYNOPSIS
+*/
+typedef struct osm_cacongestion_entry {
+ ib_net16_t ccti_timer; //Alex: ccti_timer and ccti_increase should be replaced
+ uint8_t ccti_increase;
+ uint8_t trigger_threshold;
+ uint8_t ccti_min;
+} osm_cacongestion_entry_t;
+/*
+* FIELDS
+*
+* ccti_timer
+* CCTI Timer
+*
+* ccti_increase
+* CCTI Increase
+*
+* trigger_threshold
+* CCTI trigger for log message
+*
+* ccti_min
+* CCTI Minimum
+*
+*********/
+
+/****s* OpenSM: Subnet/osm_cct_t
+* NAME
+* osm_cct_t
+*
+* DESCRIPTION
+* Subnet CongestionControlTable. See A10.4.3.9 for format details.
+*
+* SYNOPSIS
+*/
+typedef struct osm_cct {
+ osm_cct_entry_t entries[OSM_CCT_ENTRY_MAX];
+ unsigned int entries_len;
+ char *input_str;
+} osm_cct_t;
+/*
+* FIELDS
+*
+* entries
+* Entries in CCT
+*
+* entries_len
+* Length of entries
+*
+* input_str
+* Original str input
+*
+*********/
+
+
+/****s* OpenSM: Subnet/osm_subn_opt_t
+* NAME
+* osm_subn_opt_t
+*
+* DESCRIPTION
+* Subnet options structure. This structure contains the various
+* site specific configuration parameters for the subnet.
+*
+* SYNOPSIS
+*/
+typedef struct osm_subn_opt {
+ const char *config_file;
+ ib_net64_t guid;
+ ib_net64_t m_key;
+ ib_net64_t sm_key;
+ ib_net64_t sa_key;
+ ib_net64_t subnet_prefix;
+ ib_net16_t m_key_lease_period;
+ uint8_t m_key_protect_bits;
+ boolean_t m_key_lookup;
+ uint32_t sweep_interval;
+ uint32_t max_wire_smps;
+ uint32_t max_wire_smps2;
+ uint32_t max_smps_timeout;
+ uint32_t transaction_timeout;
+ uint32_t transaction_retries;
+ uint8_t sm_priority;
+ uint8_t lmc;
+ boolean_t lmc_esp0;
+ uint8_t max_op_vls;
+ uint8_t force_link_speed;
+ uint8_t force_link_speed_ext;
+ uint8_t fdr10;
+ boolean_t reassign_lids;
+ boolean_t ignore_other_sm;
+ boolean_t single_thread;
+ boolean_t disable_multicast;
+ boolean_t force_log_flush;
+ uint8_t subnet_timeout;
+ uint8_t packet_life_time;
+ uint8_t vl_stall_count;
+ uint8_t leaf_vl_stall_count;
+ uint8_t head_of_queue_lifetime;
+ uint8_t leaf_head_of_queue_lifetime;
+ uint8_t local_phy_errors_threshold;
+ uint8_t overrun_errors_threshold;
+ boolean_t use_mfttop;
+ uint32_t sminfo_polling_timeout;
+ uint32_t polling_retry_number;
+ uint32_t max_msg_fifo_timeout;
+ boolean_t force_heavy_sweep;
+ uint8_t log_flags;
+ char *dump_files_dir;
+ char *log_file;
+ uint32_t log_max_size;
+ char *partition_config_file;
+ boolean_t no_partition_enforcement;
+ char *part_enforce;
+ osm_partition_enforce_type_enum part_enforce_enum;
+ boolean_t allow_both_pkeys;
+ uint8_t sm_assigned_guid;
+ boolean_t qos;
+ char *qos_policy_file;
+ boolean_t suppress_sl2vl_mad_status_errors;
+ boolean_t accum_log_file;
+ char *console;
+ uint16_t console_port;
+ char *port_prof_ignore_file;
+ char *hop_weights_file;
+ char *port_search_ordering_file;
+ boolean_t port_profile_switch_nodes;
+ boolean_t sweep_on_trap;
+ char *routing_engine_names;
+ boolean_t use_ucast_cache;
+ boolean_t connect_roots;
+ char *lid_matrix_dump_file;
+ char *lfts_file;
+ char *root_guid_file;
+ char *cn_guid_file;
+ char *io_guid_file;
+ boolean_t port_shifting;
+ uint32_t scatter_ports;
+ uint16_t max_reverse_hops;
+ char *ids_guid_file;
+ char *guid_routing_order_file;
+ boolean_t guid_routing_order_no_scatter;
+ char *sa_db_file;
+ boolean_t sa_db_dump;
+ char *torus_conf_file;
+ boolean_t do_mesh_analysis;
+ boolean_t exit_on_fatal;
+ boolean_t honor_guid2lid_file;
+ boolean_t daemon;
+ boolean_t sm_inactive;
+ boolean_t babbling_port_policy;
+ boolean_t drop_event_subscriptions;
+ boolean_t ipoib_mcgroup_creation_validation;
+ boolean_t mcgroup_join_validation;
+ boolean_t use_optimized_slvl;
+ boolean_t fsync_high_avail_files;
+ osm_qos_options_t qos_options;
+ osm_qos_options_t qos_ca_options;
+ osm_qos_options_t qos_sw0_options;
+ osm_qos_options_t qos_swe_options;
+ osm_qos_options_t qos_rtr_options;
+ boolean_t congestion_control;
+ ib_net64_t cc_key;
+ uint32_t cc_max_outstanding_mads;
+ ib_net32_t cc_sw_cong_setting_control_map;
+ uint8_t cc_sw_cong_setting_victim_mask[IB_CC_PORT_MASK_DATA_SIZE];
+ uint8_t cc_sw_cong_setting_credit_mask[IB_CC_PORT_MASK_DATA_SIZE];
+ uint8_t cc_sw_cong_setting_threshold;
+ uint8_t cc_sw_cong_setting_packet_size;
+ uint8_t cc_sw_cong_setting_credit_starvation_threshold;
+ osm_cct_entry_t cc_sw_cong_setting_credit_starvation_return_delay;
+ ib_net16_t cc_sw_cong_setting_marking_rate;
+ ib_net16_t cc_ca_cong_setting_port_control;
+ ib_net16_t cc_ca_cong_setting_control_map;
+ osm_cacongestion_entry_t cc_ca_cong_entries[IB_CA_CONG_ENTRY_DATA_SIZE];
+ osm_cct_t cc_cct;
+ boolean_t enable_quirks;
+ boolean_t no_clients_rereg;
+#ifdef ENABLE_OSM_PERF_MGR
+ boolean_t perfmgr;
+ boolean_t perfmgr_redir;
+ uint16_t perfmgr_sweep_time_s;
+ uint32_t perfmgr_max_outstanding_queries;
+ boolean_t perfmgr_ignore_cas;
+ char *event_db_dump_file;
+ int perfmgr_rm_nodes;
+ boolean_t perfmgr_log_errors;
+ boolean_t perfmgr_query_cpi;
+ boolean_t perfmgr_xmit_wait_log;
+ uint32_t perfmgr_xmit_wait_threshold;
+#endif /* ENABLE_OSM_PERF_MGR */
+ char *event_plugin_name;
+ char *event_plugin_options;
+ char *node_name_map_name;
+ char *prefix_routes_file;
+ char *log_prefix;
+ boolean_t consolidate_ipv6_snm_req;
+ struct osm_subn_opt *file_opts; /* used for update */
+ uint8_t lash_start_vl; /* starting vl to use in lash */
+ uint8_t sm_sl; /* which SL to use for SM/SA communication */
+ char *per_module_logging_file;
+ boolean_t quasi_ftree_indexing;
+} osm_subn_opt_t;
+/*
+* FIELDS
+*
+* config_file
+* The name of the config file.
+*
+* guid
+* The port guid that the SM is binding to.
+*
+* m_key
+* M_Key value sent to all ports qualifying all Set(PortInfo).
+*
+* sm_key
+* SM_Key value of the SM used for SM authentication.
+*
+* sa_key
+* SM_Key value to qualify rcv SA queries as "trusted".
+*
+* subnet_prefix
+* Subnet prefix used on this subnet.
+*
+* m_key_lease_period
+* The lease period used for the M_Key on this subnet.
+*
+* sweep_interval
+* The number of seconds between subnet sweeps. A value of 0
+* disables sweeping.
+*
+* max_wire_smps
+* The maximum number of SMPs sent in parallel. Default is 4.
+*
+* max_wire_smps2
+* The maximum number of timeout SMPs allowed to be outstanding.
+* Default is same as max_wire_smps which disables the timeout
+* mechanism.
+*
+* max_smps_timeout
+* The wait time in usec for timeout based SMPs. Default is
+* timeout * retries.
+*
+* transaction_timeout
+* The maximum time in milliseconds allowed for a transaction
+* to complete. Default is 200.
+*
+* transaction_retries
+* The number of retries for a transaction. Default is 3.
+*
+* sm_priority
+* The priority of this SM as specified by the user. This
+* value is made available in the SMInfo attribute.
+*
+* lmc
+* The LMC value used on this subnet.
+*
+* lmc_esp0
+* Whether LMC value used on subnet should be used for
+* enhanced switch port 0 or not. If TRUE, it is used.
+* Otherwise (the default), LMC is set to 0 for ESP0.
+*
+* max_op_vls
+* Limit the maximal operational VLs. default is 1.
+*
+* reassign_lids
+* If TRUE cause all lids to be re-assigend.
+* Otherwise (the default),
+* OpenSM always tries to preserve as LIDs as much as possible.
+*
+* ignore_other_sm_option
+* This flag is TRUE if other SMs on the subnet should be ignored.
+*
+* disable_multicast
+* This flag is TRUE if OpenSM should disable multicast support.
+*
+* max_msg_fifo_timeout
+* The maximal time a message can stay in the incoming message
+* queue. If there is more than one message in the queue and the
+* last message stayed in the queue more than this value the SA
+* request will be immediately returned with a BUSY status.
+*
+* subnet_timeout
+* The subnet_timeout that will be set for all the ports in the
+* design SubnSet(PortInfo.vl_stall_life))
+*
+* vl_stall_count
+* The number of sequential packets dropped that cause the port
+* to enter the VLStalled state.
+*
+* leaf_vl_stall_count
+* The number of sequential packets dropped that cause the port
+* to enter the VLStalled state. This is for switch ports driving
+* a CA or router port.
+*
+* head_of_queue_lifetime
+* The maximal time a packet can live at the head of a VL queue
+* on any port not driving a CA or router port.
+*
+* leaf_head_of_queue_lifetime
+* The maximal time a packet can live at the head of a VL queue
+* on switch ports driving a CA or router.
+*
+* local_phy_errors_threshold
+* Threshold of local phy errors for sending Trap 129
+*
+* overrun_errors_threshold
+* Threshold of credits overrun errors for sending Trap 129
+*
+* sminfo_polling_timeout
+* Specifies the polling timeout (in milliseconds) - the timeout
+* between one poll to another.
+*
+* packet_life_time
+* The maximal time a packet can stay in a switch.
+* The value is send to all switches as
+* SubnSet(SwitchInfo.life_state)
+*
+* dump_files_dir
+* The directory to be used for opensm-subnet.lst, opensm.fdbs,
+* opensm.mcfdbs, and default log file (the latter for Windows,
+* not Linux).
+*
+* log_file
+* Name of the log file (or NULL) for stdout.
+*
+* log_max_size
+* This option defines maximal log file size in MB. When
+* specified the log file will be truncated upon reaching
+* this limit.
+*
+* qos
+* Boolean that specifies whether the OpenSM QoS functionality
+* should be off or on.
+*
+* qos_policy_file
+* Name of the QoS policy file.
+*
+* accum_log_file
+* If TRUE (default) - the log file will be accumulated.
+* If FALSE - the log file will be erased before starting
+* current opensm run.
+*
+* port_prof_ignore_file
+* Name of file with port guids to be ignored by port profiling.
+*
+* port_profile_switch_nodes
+* If TRUE will count the number of switch nodes routed through
+* the link. If FALSE - only CA/RT nodes are counted.
+*
+* sweep_on_trap
+* Received traps will initiate a new sweep.
+*
+* routing_engine_names
+* Name of routing engine(s) to use.
+*
+* connect_roots
+* The option which will enforce root to root connectivity with
+* up/down and fat-tree routing engines (even if this violates
+* "pure" deadlock free up/down or fat-tree algorithm)
+*
+* use_ucast_cache
+* When TRUE enables unicast routing cache.
+*
+* lid_matrix_dump_file
+* Name of the lid matrix dump file from where switch
+* lid matrices (min hops tables) will be loaded
+*
+* lfts_file
+* Name of the unicast LFTs routing file from where switch
+* forwarding tables will be loaded
+*
+* root_guid_file
+* Name of the file that contains list of root guids that
+* will be used by fat-tree or up/dn routing (provided by User)
+*
+* cn_guid_file
+* Name of the file that contains list of compute node guids that
+* will be used by fat-tree routing (provided by User)
+*
+* io_guid_file
+* Name of the file that contains list of I/O node guids that
+* will be used by fat-tree routing (provided by User)
+*
+* port_shifting
+* This option will turn on port_shifting in routing.
+*
+* ids_guid_file
+* Name of the file that contains list of ids which should be
+* used by Up/Down algorithm instead of node GUIDs
+*
+* guid_routing_order_file
+* Name of the file that contains list of guids for routing order
+* that will be used by minhop and up/dn routing (provided by User).
+*
+* sa_db_file
+* Name of the SA database file.
+*
+* sa_db_dump
+* When TRUE causes OpenSM to dump SA DB at the end of every
+* light sweep regardless the current verbosity level.
+*
+* torus_conf_file
+* Name of the file with extra configuration info for torus-2QoS
+* routing engine.
+*
+* exit_on_fatal
+* If TRUE (default) - SM will exit on fatal subnet initialization
+* issues.
+* If FALSE - SM will not exit.
+* Fatal initialization issues:
+* a. SM recognizes 2 different nodes with the same guid, or
+* 12x link with lane reversal badly configured.
+*
+* honor_guid2lid_file
+* Always honor the guid2lid file if it exists and is valid. This
+* means that the file will be honored when SM is coming out of
+* STANDBY. By default this is FALSE.
+*
+* daemon
+* OpenSM will run in daemon mode.
+*
+* sm_inactive
+* OpenSM will start with SM in not active state.
+*
+* babbling_port_policy
+* OpenSM will enforce its "babbling" port policy.
+*
+* drop_event_subscriptions
+* OpenSM will drop event subscriptions if the port goes away.
+*
+* ipoib_mcgroup_creation_validation
+* OpenSM will validate IPoIB non-broadcast group parameters
+* against IPoIB broadcast group.
+*
+* mcgroup_join_validation
+* OpenSM will validate multicast join parameters against
+* multicast group parameters when MC group already exists.
+*
+* use_optimized_slvl
+* Use optimized SLtoVLMappingTable programming if
+* device indicates it supports this.
+*
+* fsync_high_avail_files
+* Synchronize high availability in memory files
+* with storage.
+*
+* perfmgr
+* Enable or disable the performance manager
+*
+* perfmgr_redir
+* Enable or disable the saving of redirection by PerfMgr
+*
+* perfmgr_sweep_time_s
+* Define the period (in seconds) of PerfMgr sweeps
+*
+* event_db_dump_file
+* File to dump the event database to
+*
+* event_plugin_name
+* Specify the name(s) of the event plugin(s)
+*
+* event_plugin_options
+* Options string that would be passed to the plugin(s)
+*
+* qos_options
+* Default set of QoS options
+*
+* qos_ca_options
+* QoS options for CA ports
+*
+* qos_sw0_options
+* QoS options for switches' port 0
+*
+* qos_swe_options
+* QoS options for switches' external ports
+*
+* qos_rtr_options
+* QoS options for router ports
+*
+* congestion_control
+* Boolean that specifies whether OpenSM congestion control configuration
+* should be off or no.
+*
+* cc_key
+* CCkey to use when configuring congestion control.
+*
+* cc_max_outstanding_mads
+* Max number of outstanding CC mads that can be on the wire.
+*
+* cc_sw_cong_setting_control_map
+* Congestion Control Switch Congestion Setting Control Map
+* configuration setting.
+*
+* cc_sw_cong_setting_victim_mask
+* Congestion Control Switch Congestion Setting Victim Mask
+* configuration setting.
+*
+* cc_sw_cong_setting_credit_mask
+* Congestion Control Switch Congestion Setting Credit Mask
+* configuration setting.
+*
+* cc_sw_cong_setting_threshold
+* Congestion Control Switch Congestion Setting Threshold
+* configuration setting.
+*
+* cc_sw_cong_setting_packet_size
+* Congestion Control Switch Congestion Setting Packet Size
+* configuration setting.
+*
+* cc_sw_cong_setting_credit_starvation_threshold
+* Congestion Control Switch Congestion Setting Credit Starvation Threshold
+* configuration setting.
+*
+* cc_sw_cong_setting_credit_starvation_return_delay
+* Congestion Control Switch Congestion Setting Credit Starvation Return Delay
+* configuration setting.
+*
+* cc_sw_cong_setting_marking_rate
+* Congestion Control Switch Congestion Setting Marking Rate
+* configuration setting.
+*
+* cc_ca_cong_setting_port_control
+* Congestion Control CA Congestion Setting Port Control
+*
+* cc_ca_cong_setting_control_map
+* Congestion Control CA Congestion Setting Control Map
+
+* cc_ca_cong_entries
+* Congestion Control CA Congestion Setting Entries
+*
+* cc_cct
+* Congestion Control Table array of entries
+*
+* enable_quirks
+* Enable high risk new features and not fully qualified
+* hardware specific work arounds
+*
+* no_clients_rereg
+* When TRUE disables clients reregistration request
+*
+* scatter_ports
+* When not zero, randomize best possible ports chosen
+* for a route. The value is used as a random key seed.
+*
+* per_module_logging_file
+* File name of per module logging configuration.
+*
+* SEE ALSO
+* Subnet object
+*********/
+
+/****s* OpenSM: Subnet/osm_subn_t
+* NAME
+* osm_subn_t
+*
+* DESCRIPTION
+* Subnet structure. Callers may directly access member components,
+* after grabbing a lock.
+*
+* TO DO
+* This structure should probably be volatile.
+*
+* SYNOPSIS
+*/
+typedef struct osm_subn {
+ struct osm_opensm *p_osm;
+ cl_qmap_t sw_guid_tbl;
+ cl_qmap_t node_guid_tbl;
+ cl_qmap_t port_guid_tbl;
+ cl_qmap_t alias_port_guid_tbl;
+ cl_qmap_t assigned_guids_tbl;
+ cl_qmap_t rtr_guid_tbl;
+ cl_qlist_t prefix_routes_list;
+ cl_qmap_t prtn_pkey_tbl;
+ cl_qmap_t sm_guid_tbl;
+ cl_qlist_t sa_sr_list;
+ cl_qlist_t sa_infr_list;
+ cl_qlist_t alias_guid_list;
+ cl_ptr_vector_t port_lid_tbl;
+ ib_net16_t master_sm_base_lid;
+ ib_net16_t sm_base_lid;
+ ib_net64_t sm_port_guid;
+ uint8_t last_sm_port_state;
+ uint8_t sm_state;
+ osm_subn_opt_t opt;
+ struct osm_qos_policy *p_qos_policy;
+ uint16_t max_ucast_lid_ho;
+ uint16_t max_mcast_lid_ho;
+ uint8_t min_ca_mtu;
+ uint8_t min_ca_rate;
+ uint8_t min_data_vls;
+ uint8_t min_sw_data_vls;
+ boolean_t ignore_existing_lfts;
+ boolean_t subnet_initialization_error;
+ boolean_t force_heavy_sweep;
+ boolean_t force_reroute;
+ boolean_t in_sweep_hop_0;
+ boolean_t force_first_time_master_sweep;
+ boolean_t first_time_master_sweep;
+ boolean_t coming_out_of_standby;
+ boolean_t sweeping_enabled;
+ unsigned need_update;
+ cl_fmap_t mgrp_mgid_tbl;
+ osm_db_domain_t *p_g2m;
+ osm_db_domain_t *p_neighbor;
+ void *mboxes[IB_LID_MCAST_END_HO - IB_LID_MCAST_START_HO + 1];
+} osm_subn_t;
+/*
+* FIELDS
+* sw_guid_tbl
+* Container of pointers to all Switch objects in the subnet.
+* Indexed by node GUID.
+*
+* node_guid_tbl
+* Container of pointers to all Node objects in the subnet.
+* Indexed by node GUID.
+*
+* port_guid_tbl
+* Container of pointers to all Port objects in the subnet.
+* Indexed by port GUID.
+*
+* rtr_guid_tbl
+* Container of pointers to all Router objects in the subnet.
+* Indexed by node GUID.
+*
+* prtn_pkey_tbl
+* Container of pointers to all Partition objects in the subnet.
+* Indexed by P_KEY.
+*
+* sm_guid_tbl
+* Container of pointers to SM objects representing other SMs
+* on the subnet.
+*
+* port_lid_tbl
+* Container of pointers to all Port objects in the subnet.
+* Indexed by port LID.
+*
+* master_sm_base_lid
+* The base LID owned by the subnet's master SM.
+*
+* sm_base_lid
+* The base LID of the local port where the SM is.
+*
+* sm_port_guid
+* This SM's own port GUID.
+*
+* last_sm_port_state
+* Last state of this SM's port.
+* 0 is down and 1 is up.
+*
+* sm_state
+* The high-level state of the SM. This value is made available
+* in the SMInfo attribute.
+*
+* opt
+* Subnet options structure contains site specific configuration.
+*
+* p_qos_policy
+* Subnet QoS policy structure.
+*
+* max_ucast_lid_ho
+* The minimal max unicast lid reported by all switches
+*
+* max_mcast_lid_ho
+* The minimal max multicast lid reported by all switches
+*
+* min_ca_mtu
+* The minimal MTU reported by all CAs ports on the subnet
+*
+* min_ca_rate
+* The minimal rate reported by all CA ports on the subnet
+*
+* ignore_existing_lfts
+* This flag is a dynamic flag to instruct the LFT assignment to
+* ignore existing legal LFT settings.
+* The value will be set according to :
+* - Any change to the list of switches will set it to high
+* - Coming out of STANDBY it will be cleared (other SM worked)
+* - Set to FALSE upon end of all lft assignments.
+*
+* subnet_initalization_error
+* Similar to the force_heavy_sweep flag. If TRUE - means that
+* we had errors during initialization (due to SubnSet requests
+* that failed). We want to declare the subnet as unhealthy, and
+* force another heavy sweep.
+*
+* force_heavy_sweep
+* If TRUE - we want to force a heavy sweep. This can be done
+* either due to receiving of trap - meaning there is some change
+* on the subnet, or we received a handover from a remote sm.
+* In this case we want to sweep and reconfigure the entire
+* subnet. This will cause another heavy sweep to occure when
+* the current sweep is done.
+*
+* force_reroute
+* If TRUE - we want to force switches in the fabric to be
+* rerouted.
+*
+* in_sweep_hop_0
+* When in_sweep_hop_0 flag is set to TRUE - this means we are
+* in sweep_hop_0 - meaning we do not want to continue beyond
+* the current node.
+* This is relevant for the case of SM on switch, since in the
+* switch info we need to signal somehow not to continue
+* the sweeping.
+*
+* force_first_time_master_sweep
+* This flag is used to avoid race condition when Master SM being
+* in the middle of very long configuration stage of the heavy sweep,
+* receives HANDOVER from another MASTER SM. When the current heavy sweep
+* is finished, new heavy sweep will be started immediately.
+* At the beginning of the sweep, opensm will set first_time_master_sweep,
+* force_heavy_sweep and coming_out_of_standby flags in order to allow full
+* reconfiguration of the fabric. This is required as another MASTER SM could
+* change configuration of the fabric before sending HANDOVER to MASTER SM.
+*
+* first_time_master_sweep
+* This flag is used for the PortInfo setting. On the first
+* sweep as master (meaning after moving from Standby|Discovering
+* state), the SM must send a PortInfoSet to all ports. After
+* that - we want to minimize the number of PortInfoSet requests
+* sent, and to send only requests that change the value from
+* what is updated in the port (or send a first request if this
+* is a new port). We will set this flag to TRUE when entering
+* the master state, and set it back to FALSE at the end of the
+* drop manager. This is done since at the end of the drop manager
+* we have updated all the ports that are reachable, and from now
+* on these are the only ports we have data of. We don't want
+* to send extra set requests to these ports anymore.
+*
+* coming_out_of_standby
+* TRUE on the first sweep after the SM was in standby.
+* Used for nulling any cache of LID and Routing.
+* The flag is set true if the SM state was standby and now
+* changed to MASTER it is reset at the end of the sweep.
+*
+* sweeping_enabled
+* FALSE - sweeping is administratively disabled, all
+* sweeping is inhibited, TRUE - sweeping is done
+* normally
+*
+* need_update
+* This flag should be on during first non-master heavy
+* (including pre-master discovery stage)
+*
+* mgrp_mgid_tbl
+* Container of pointers to all Multicast group objects in
+* the subnet. Indexed by MGID.
+*
+* mboxes
+* Array of pointers to all Multicast MLID box objects in the
+* subnet. Indexed by MLID offset from base MLID.
+*
+* SEE ALSO
+* Subnet object
+*********/
+
+/****s* OpenSM: Subnet/osm_assigned_guids_t
+* NAME
+* osm_assigned_guids_t
+*
+* DESCRIPTION
+* SA assigned GUIDs structure.
+*
+* SYNOPSIS
+*/
+typedef struct osm_assigned_guids {
+ cl_map_item_t map_item;
+ ib_net64_t port_guid;
+ ib_net64_t assigned_guid[1];
+} osm_assigned_guids_t;
+/*
+* FIELDS
+* map_item
+* Linkage structure for cl_qmap. MUST BE FIRST MEMBER!
+*
+* port_guid
+* Base port GUID.
+*
+* assigned_guids
+* Table of persistent SA assigned GUIDs.
+*
+* SEE ALSO
+* Subnet object
+*********/
+
+/****f* OpenSM: Subnet/osm_subn_construct
+* NAME
+* osm_subn_construct
+*
+* DESCRIPTION
+* This function constructs a Subnet object.
+*
+* SYNOPSIS
+*/
+void osm_subn_construct(IN osm_subn_t * p_subn);
+/*
+* PARAMETERS
+* p_subn
+* [in] Pointer to a Subnet object to construct.
+*
+* RETURN VALUE
+* This function does not return a value.
+*
+* NOTES
+* Allows calling osm_subn_init, and osm_subn_destroy.
+*
+* Calling osm_subn_construct is a prerequisite to calling any other
+* method except osm_subn_init.
+*
+* SEE ALSO
+* Subnet object, osm_subn_init, osm_subn_destroy
+*********/
+
+/****f* OpenSM: Subnet/osm_subn_destroy
+* NAME
+* osm_subn_destroy
+*
+* DESCRIPTION
+* The osm_subn_destroy function destroys a subnet, releasing
+* all resources.
+*
+* SYNOPSIS
+*/
+void osm_subn_destroy(IN osm_subn_t * p_subn);
+/*
+* PARAMETERS
+* p_subn
+* [in] Pointer to a Subnet object to destroy.
+*
+* RETURN VALUE
+* This function does not return a value.
+*
+* NOTES
+* Performs any necessary cleanup of the specified Subnet object.
+* Further operations should not be attempted on the destroyed object.
+* This function should only be called after a call to osm_subn_construct
+* or osm_subn_init.
+*
+* SEE ALSO
+* Subnet object, osm_subn_construct, osm_subn_init
+*********/
+
+/****f* OpenSM: Subnet/osm_subn_init
+* NAME
+* osm_subn_init
+*
+* DESCRIPTION
+* The osm_subn_init function initializes a Subnet object for use.
+*
+* SYNOPSIS
+*/
+ib_api_status_t osm_subn_init(IN osm_subn_t * p_subn,
+ IN struct osm_opensm *p_osm,
+ IN const osm_subn_opt_t * p_opt);
+/*
+* PARAMETERS
+* p_subn
+* [in] Pointer to an osm_subn_t object to initialize.
+*
+* p_opt
+* [in] Pointer to the subnet options structure.
+*
+* RETURN VALUES
+* IB_SUCCESS if the Subnet object was initialized successfully.
+*
+* NOTES
+* Allows calling other Subnet methods.
+*
+* SEE ALSO
+* Subnet object, osm_subn_construct, osm_subn_destroy
+*********/
+
+/*
+ Forward references.
+*/
+struct osm_mad_addr;
+struct osm_log;
+struct osm_switch;
+struct osm_physp;
+struct osm_port;
+struct osm_mgrp;
+
+/****f* OpenSM: Helper/osm_get_gid_by_mad_addr
+* NAME
+* osm_get_gid_by_mad_addr
+*
+* DESCRIPTION
+* Looks for the requester gid in the mad address.
+*
+* Note: This code is not thread safe. Need to grab the lock before
+* calling it.
+*
+* SYNOPSIS
+*/
+ib_api_status_t osm_get_gid_by_mad_addr(IN struct osm_log *p_log,
+ IN const osm_subn_t * p_subn,
+ IN struct osm_mad_addr *p_mad_addr,
+ OUT ib_gid_t * p_gid);
+/*
+* PARAMETERS
+* p_log
+* [in] Pointer to a log object.
+*
+* p_subn
+* [in] Pointer to subnet object.
+*
+* p_mad_addr
+* [in] Pointer to mad address object.
+*
+* p_gid
+* [out] Pointer to the GID structure to fill in.
+*
+* RETURN VALUES
+* IB_SUCCESS if able to find the GID by address given.
+*
+* NOTES
+*
+* SEE ALSO
+*********/
+
+/****f* OpenSM: Helper/osm_get_physp_by_mad_addr
+* NAME
+* osm_get_physp_by_mad_addr
+*
+* DESCRIPTION
+* Looks for the requester physical port in the mad address.
+*
+* Note: This code is not thread safe. Need to grab the lock before
+* calling it.
+*
+* SYNOPSIS
+*/
+struct osm_physp *osm_get_physp_by_mad_addr(IN struct osm_log *p_log,
+ IN const osm_subn_t * p_subn,
+ IN struct osm_mad_addr
+ *p_mad_addr);
+/*
+* PARAMETERS
+* p_log
+* [in] Pointer to a log object.
+*
+* p_subn
+* [in] Pointer to subnet object.
+*
+* p_mad_addr
+* [in] Pointer to mad address object.
+*
+* RETURN VALUES
+* Pointer to requester physical port object if found. Null otherwise.
+*
+* NOTES
+*
+* SEE ALSO
+*********/
+
+/****f* OpenSM: Helper/osm_get_port_by_mad_addr
+* NAME
+* osm_get_port_by_mad_addr
+*
+* DESCRIPTION
+* Looks for the requester port in the mad address.
+*
+* Note: This code is not thread safe. Need to grab the lock before
+* calling it.
+*
+* SYNOPSIS
+*/
+struct osm_port *osm_get_port_by_mad_addr(IN struct osm_log *p_log,
+ IN const osm_subn_t * p_subn,
+ IN struct osm_mad_addr *p_mad_addr);
+/*
+* PARAMETERS
+* p_log
+* [in] Pointer to a log object.
+*
+* p_subn
+* [in] Pointer to subnet object.
+*
+* p_mad_addr
+* [in] Pointer to mad address object.
+*
+* RETURN VALUES
+* Pointer to requester port object if found. Null otherwise.
+*
+* NOTES
+*
+* SEE ALSO
+*********/
+
+/****f* OpenSM: Subnet/osm_get_switch_by_guid
+* NAME
+* osm_get_switch_by_guid
+*
+* DESCRIPTION
+* Looks for the given switch guid in the subnet table of switches by guid.
+* NOTE: this code is not thread safe. Need to grab the lock before
+* calling it.
+*
+* SYNOPSIS
+*/
+struct osm_switch *osm_get_switch_by_guid(IN const osm_subn_t * p_subn,
+ IN ib_net64_t guid);
+/*
+* PARAMETERS
+* p_subn
+* [in] Pointer to an osm_subn_t object
+*
+* guid
+* [in] The node guid in network byte order
+*
+* RETURN VALUES
+* The switch structure pointer if found. NULL otherwise.
+*
+* SEE ALSO
+* Subnet object, osm_subn_construct, osm_subn_destroy,
+* osm_switch_t
+*********/
+
+/****f* OpenSM: Subnet/osm_get_node_by_guid
+* NAME
+* osm_get_node_by_guid
+*
+* DESCRIPTION
+* This looks for the given node guid in the subnet table of nodes by guid.
+* NOTE: this code is not thread safe. Need to grab the lock before
+* calling it.
+*
+* SYNOPSIS
+*/
+struct osm_node *osm_get_node_by_guid(IN osm_subn_t const *p_subn,
+ IN ib_net64_t guid);
+/*
+* PARAMETERS
+* p_subn
+* [in] Pointer to an osm_subn_t object
+*
+* guid
+* [in] The node guid in network byte order
+*
+* RETURN VALUES
+* The node structure pointer if found. NULL otherwise.
+*
+* SEE ALSO
+* Subnet object, osm_subn_construct, osm_subn_destroy,
+* osm_node_t
+*********/
+
+/****f* OpenSM: Subnet/osm_get_port_by_guid
+* NAME
+* osm_get_port_by_guid
+*
+* DESCRIPTION
+* This looks for the given port guid in the subnet table of ports by guid.
+* NOTE: this code is not thread safe. Need to grab the lock before
+* calling it.
+*
+* SYNOPSIS
+*/
+struct osm_port *osm_get_port_by_guid(IN osm_subn_t const *p_subn,
+ IN ib_net64_t guid);
+/*
+* PARAMETERS
+* p_subn
+* [in] Pointer to an osm_subn_t object
+*
+* guid
+* [in] The port guid in network order
+*
+* RETURN VALUES
+* The port structure pointer if found. NULL otherwise.
+*
+* SEE ALSO
+* Subnet object, osm_subn_construct, osm_subn_destroy,
+* osm_port_t
+*********/
+
+/****f* OpenSM: Port/osm_get_port_by_lid_ho
+* NAME
+* osm_get_port_by_lid_ho
+*
+* DESCRIPTION
+* Returns a pointer of the port object for given lid value.
+*
+* SYNOPSIS
+*/
+struct osm_port *osm_get_port_by_lid_ho(const osm_subn_t * subn, uint16_t lid);
+/*
+* PARAMETERS
+* subn
+* [in] Pointer to the subnet data structure.
+*
+* lid
+* [in] LID requested in host byte order.
+*
+* RETURN VALUES
+* The port structure pointer if found. NULL otherwise.
+*
+* SEE ALSO
+* Subnet object, osm_port_t
+*********/
+
+/****f* OpenSM: Subnet/osm_get_alias_guid_by_guid
+* NAME
+* osm_get_alias_guid_by_guid
+*
+* DESCRIPTION
+* This looks for the given port guid in the subnet table of ports by
+* alias guid.
+* NOTE: this code is not thread safe. Need to grab the lock before
+* calling it.
+*
+* SYNOPSIS
+*/
+struct osm_alias_guid *osm_get_alias_guid_by_guid(IN osm_subn_t const *p_subn,
+ IN ib_net64_t guid);
+/*
+* PARAMETERS
+* p_subn
+* [in] Pointer to an osm_subn_t object
+*
+* guid
+* [in] The alias port guid in network order
+*
+* RETURN VALUES
+* The alias guid structure pointer if found. NULL otherwise.
+*
+* SEE ALSO
+* Subnet object, osm_subn_construct, osm_subn_destroy,
+* osm_alias_guid_t
+*********/
+
+/****f* OpenSM: Subnet/osm_get_port_by_alias_guid
+* NAME
+* osm_get_port_by_alias_guid
+*
+* DESCRIPTION
+* This looks for the given port guid in the subnet table of ports by
+* alias guid.
+* NOTE: this code is not thread safe. Need to grab the lock before
+* calling it.
+*
+* SYNOPSIS
+*/
+struct osm_port *osm_get_port_by_alias_guid(IN osm_subn_t const *p_subn,
+ IN ib_net64_t guid);
+/*
+* PARAMETERS
+* p_subn
+* [in] Pointer to an osm_subn_t object
+*
+* guid
+* [in] The alias port guid in network order
+*
+* RETURN VALUES
+* The port structure pointer if found. NULL otherwise.
+*
+* SEE ALSO
+* Subnet object, osm_subn_construct, osm_subn_destroy,
+* osm_port_t
+*********/
+
+/****f* OpenSM: Port/osm_assigned_guids_new
+* NAME
+* osm_assigned_guids_new
+*
+* DESCRIPTION
+* This function allocates and initializes an assigned guids object.
+*
+* SYNOPSIS
+*/
+osm_assigned_guids_t *osm_assigned_guids_new(IN const ib_net64_t port_guid,
+ IN const uint32_t num_guids);
+/*
+* PARAMETERS
+* port_guid
+* [in] Base port GUID in network order
+*
+* RETURN VALUE
+* Pointer to the initialized assigned alias guid object.
+*
+* SEE ALSO
+* Subnet object, osm_assigned_guids_t, osm_assigned_guids_delete,
+* osm_get_assigned_guids_by_guid
+*********/
+
+/****f* OpenSM: Port/osm_assigned_guids_delete
+* NAME
+* osm_assigned_guids_delete
+*
+* DESCRIPTION
+* This function destroys and deallocates an assigned guids object.
+*
+* SYNOPSIS
+*/
+void osm_assigned_guids_delete(IN OUT osm_assigned_guids_t ** pp_assigned_guids);
+/*
+* PARAMETERS
+* pp_assigned_guids
+* [in][out] Pointer to a pointer to an assigned guids object to delete.
+* On return, this pointer is NULL.
+*
+* RETURN VALUE
+* This function does not return a value.
+*
+* NOTES
+* Performs any necessary cleanup of the specified assigned guids object.
+*
+* SEE ALSO
+* Subnet object, osm_assigned_guids_new, osm_get_assigned_guids_by_guid
+*********/
+
+/****f* OpenSM: Subnet/osm_get_assigned_guids_by_guid
+* NAME
+* osm_get_assigned_guids_by_guid
+*
+* DESCRIPTION
+* This looks for the given port guid and returns a pointer
+* to the guid table of SA assigned alias guids for that port.
+*
+* SYNOPSIS
+*/
+osm_assigned_guids_t *osm_get_assigned_guids_by_guid(IN osm_subn_t const *p_subn,
+ IN ib_net64_t port_guid);
+/*
+* PARAMETERS
+* p_subn
+* [in] Pointer to an osm_subn_t object
+*
+* port_guid
+* [in] The base port guid in network order
+*
+* RETURN VALUES
+* The osm_assigned_guids structure pointer if found. NULL otherwise.
+*
+* SEE ALSO
+* Subnet object, osm_assigned_guids_new, osm_assigned_guids_delete,
+* osm_assigned_guids_t
+*********/
+
+/****f* OpenSM: Port/osm_get_port_by_lid
+* NAME
+* osm_get_port_by_lid
+*
+* DESCRIPTION
+* Returns a pointer of the port object for given lid value.
+*
+* SYNOPSIS
+*/
+static inline struct osm_port *osm_get_port_by_lid(IN osm_subn_t const * subn,
+ IN ib_net16_t lid)
+{
+ return osm_get_port_by_lid_ho(subn, cl_ntoh16(lid));
+}
+/*
+* PARAMETERS
+* subn
+* [in] Pointer to the subnet data structure.
+*
+* lid
+* [in] LID requested in network byte order.
+*
+* RETURN VALUES
+* The port structure pointer if found. NULL otherwise.
+*
+* SEE ALSO
+* Subnet object, osm_port_t
+*********/
+
+/****f* OpenSM: Subnet/osm_get_mgrp_by_mgid
+* NAME
+* osm_get_mgrp_by_mgid
+*
+* DESCRIPTION
+* This looks for the given multicast group in the subnet table by mgid.
+* NOTE: this code is not thread safe. Need to grab the lock before
+* calling it.
+*
+* SYNOPSIS
+*/
+struct osm_mgrp *osm_get_mgrp_by_mgid(IN osm_subn_t * subn, IN ib_gid_t * mgid);
+/*
+* PARAMETERS
+* subn
+* [in] Pointer to an osm_subn_t object
+*
+* mgid
+* [in] The multicast group MGID value
+*
+* RETURN VALUES
+* The multicast group structure pointer if found. NULL otherwise.
+*********/
+
+/****f* OpenSM: Subnet/osm_get_mbox_by_mlid
+* NAME
+* osm_get_mbox_by_mlid
+*
+* DESCRIPTION
+* This looks for the given multicast group in the subnet table by mlid.
+* NOTE: this code is not thread safe. Need to grab the lock before
+* calling it.
+*
+* SYNOPSIS
+*/
+static inline struct osm_mgrp_box *osm_get_mbox_by_mlid(osm_subn_t const *p_subn, ib_net16_t mlid)
+{
+ return (struct osm_mgrp_box *)p_subn->mboxes[cl_ntoh16(mlid) - IB_LID_MCAST_START_HO];
+}
+/*
+* PARAMETERS
+* p_subn
+* [in] Pointer to an osm_subn_t object
+*
+* mlid
+* [in] The multicast group mlid in network order
+*
+* RETURN VALUES
+* The multicast group structure pointer if found. NULL otherwise.
+*********/
+
+int is_mlnx_ext_port_info_supported(ib_net32_t vendid, ib_net16_t devid);
+
+/****f* OpenSM: Subnet/osm_subn_set_default_opt
+* NAME
+* osm_subn_set_default_opt
+*
+* DESCRIPTION
+* The osm_subn_set_default_opt function sets the default options.
+*
+* SYNOPSIS
+*/
+void osm_subn_set_default_opt(IN osm_subn_opt_t * p_opt);
+/*
+* PARAMETERS
+*
+* p_opt
+* [in] Pointer to the subnet options structure.
+*
+* RETURN VALUES
+* None
+*
+* NOTES
+*
+* SEE ALSO
+* Subnet object, osm_subn_construct, osm_subn_destroy
+*********/
+
+/****f* OpenSM: Subnet/osm_subn_parse_conf_file
+* NAME
+* osm_subn_parse_conf_file
+*
+* DESCRIPTION
+* The osm_subn_parse_conf_file function parses the configuration file
+* and sets the defaults accordingly.
+*
+* SYNOPSIS
+*/
+int osm_subn_parse_conf_file(const char *conf_file, osm_subn_opt_t * p_opt);
+/*
+* PARAMETERS
+*
+* p_opt
+* [in] Pointer to the subnet options structure.
+*
+* RETURN VALUES
+* 0 on success, positive value if file doesn't exist,
+* negative value otherwise
+*********/
+
+/****f* OpenSM: Subnet/osm_subn_rescan_conf_files
+* NAME
+* osm_subn_rescan_conf_files
+*
+* DESCRIPTION
+* The osm_subn_rescan_conf_files function parses the configuration
+* files and update selected subnet options
+*
+* SYNOPSIS
+*/
+int osm_subn_rescan_conf_files(IN osm_subn_t * p_subn);
+/*
+* PARAMETERS
+*
+* p_subn
+* [in] Pointer to the subnet structure.
+*
+* RETURN VALUES
+* 0 on success, positive value if file doesn't exist,
+* negative value otherwise
+*
+*********/
+
+/****f* OpenSM: Subnet/osm_subn_output_conf
+* NAME
+* osm_subn_output_conf
+*
+* DESCRIPTION
+* Output configuration info
+*
+* SYNOPSIS
+*/
+void osm_subn_output_conf(FILE *out, IN osm_subn_opt_t * p_opt);
+/*
+* PARAMETERS
+*
+* out
+* [in] File stream to output to.
+*
+* p_opt
+* [in] Pointer to the subnet options structure.
+*
+* RETURN VALUES
+* This method does not return a value
+*********/
+
+/****f* OpenSM: Subnet/osm_subn_write_conf_file
+* NAME
+* osm_subn_write_conf_file
+*
+* DESCRIPTION
+* Write the configuration file into the cache
+*
+* SYNOPSIS
+*/
+int osm_subn_write_conf_file(char *file_name, IN osm_subn_opt_t * p_opt);
+/*
+* PARAMETERS
+*
+* p_opt
+* [in] Pointer to the subnet options structure.
+*
+* RETURN VALUES
+* 0 on success, negative value otherwise
+*
+* NOTES
+* Assumes the conf file is part of the cache dir which defaults to
+* OSM_DEFAULT_CACHE_DIR or OSM_CACHE_DIR the name is opensm.opts
+*********/
+int osm_subn_verify_config(osm_subn_opt_t * p_opt);
+
+END_C_DECLS
+#endif /* _OSM_SUBNET_H_ */
diff --git a/contrib/ofed/opensm/include/opensm/osm_switch.h b/contrib/ofed/opensm/include/opensm/osm_switch.h
new file mode 100644
index 0000000..72bda06
--- /dev/null
+++ b/contrib/ofed/opensm/include/opensm/osm_switch.h
@@ -0,0 +1,1189 @@
+/*
+ * Copyright (c) 2004-2009 Voltaire, Inc. All rights reserved.
+ * Copyright (c) 2002-2009 Mellanox Technologies LTD. All rights reserved.
+ * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+/*
+ * Abstract:
+ * Declaration of osm_switch_t.
+ * This object represents an IBA switch.
+ * This object is part of the OpenSM family of objects.
+ */
+
+#ifndef _OSM_SWITCH_H_
+#define _OSM_SWITCH_H_
+
+#include <iba/ib_types.h>
+#include <opensm/osm_base.h>
+#include <opensm/osm_madw.h>
+#include <opensm/osm_node.h>
+#include <opensm/osm_port.h>
+#include <opensm/osm_mcast_tbl.h>
+#include <opensm/osm_port_profile.h>
+
+#ifdef __cplusplus
+# define BEGIN_C_DECLS extern "C" {
+# define END_C_DECLS }
+#else /* !__cplusplus */
+# define BEGIN_C_DECLS
+# define END_C_DECLS
+#endif /* __cplusplus */
+
+BEGIN_C_DECLS
+/****h* OpenSM/Switch
+* NAME
+* Switch
+*
+* DESCRIPTION
+* The Switch object encapsulates the information needed by the
+* OpenSM to manage switches. The OpenSM allocates one switch object
+* per switch in the IBA subnet.
+*
+* The Switch object is not thread safe, thus callers must provide
+* serialization.
+*
+* This object should be treated as opaque and should be
+* manipulated only through the provided functions.
+*
+* AUTHOR
+* Steve King, Intel
+*
+*********/
+/****s* OpenSM: Switch/osm_switch_t
+* NAME
+* osm_switch_t
+*
+* DESCRIPTION
+* Switch structure.
+*
+* This object should be treated as opaque and should
+* be manipulated only through the provided functions.
+*
+* SYNOPSIS
+*/
+typedef struct osm_switch {
+ cl_map_item_t map_item;
+ osm_node_t *p_node;
+ ib_switch_info_t switch_info;
+ uint16_t max_lid_ho;
+ uint8_t num_ports;
+ uint16_t num_hops;
+ uint8_t **hops;
+ osm_port_profile_t *p_prof;
+ uint8_t *search_ordering_ports;
+ uint8_t *lft;
+ uint8_t *new_lft;
+ uint16_t lft_size;
+ osm_mcast_tbl_t mcast_tbl;
+ int32_t mft_block_num;
+ uint32_t mft_position;
+ unsigned endport_links;
+ unsigned need_update;
+ void *priv;
+ cl_map_item_t mgrp_item;
+ uint32_t num_of_mcm;
+ uint8_t is_mc_member;
+} osm_switch_t;
+/*
+* FIELDS
+* map_item
+* Linkage structure for cl_qmap. MUST BE FIRST MEMBER!
+*
+* p_node
+* Pointer to the Node object for this switch.
+*
+* switch_info
+* IBA defined SwitchInfo structure for this switch.
+*
+* max_lid_ho
+* Max LID that is accessible from this switch.
+*
+* num_ports
+* Number of ports for this switch.
+*
+* num_hops
+* Size of hops table for this switch.
+*
+* hops
+* LID Matrix for this switch containing the hop count
+* to every LID from every port.
+*
+* p_prof
+* Pointer to array of Port Profile objects for this switch.
+*
+* lft
+* This switch's linear forwarding table.
+*
+* new_lft
+* This switch's linear forwarding table, as was
+* calculated by the last routing engine execution.
+*
+* mcast_tbl
+* Multicast forwarding table for this switch.
+*
+* need_update
+* When set indicates that switch was probably reset, so
+* fwd tables and rest cached data should be flushed
+*
+* mgrp_item
+* map item for switch in building mcast tree
+*
+* num_of_mcm
+* number of mcast members(ports) connected to switch
+*
+* is_mc_member
+* whether switch is a mcast member itself
+*
+* SEE ALSO
+* Switch object
+*********/
+
+/****s* OpenSM: Switch/struct osm_remote_guids_count
+* NAME
+* struct osm_remote_guids_count
+*
+* DESCRIPTION
+* Stores array of pointers to remote node and the numbers of
+* times a switch has forwarded to it.
+*
+* SYNOPSIS
+*/
+struct osm_remote_guids_count {
+ unsigned count;
+ struct osm_remote_node {
+ osm_node_t *node;
+ unsigned forwarded_to;
+ uint8_t port;
+ } guids[0];
+};
+/*
+* FIELDS
+* count
+* A number of used entries in array.
+*
+* node
+* A pointer to node.
+*
+* forwarded_to
+* A count of lids forwarded to this node.
+*
+* port
+* Port number on the node.
+*********/
+
+/****f* OpenSM: Switch/osm_switch_delete
+* NAME
+* osm_switch_delete
+*
+* DESCRIPTION
+* Destroys and deallocates the object.
+*
+* SYNOPSIS
+*/
+void osm_switch_delete(IN OUT osm_switch_t ** pp_sw);
+/*
+* PARAMETERS
+* p_sw
+* [in] Pointer to the object to destroy.
+*
+* RETURN VALUE
+* None.
+*
+* NOTES
+*
+* SEE ALSO
+* Switch object, osm_switch_new
+*********/
+
+/****f* OpenSM: Switch/osm_switch_new
+* NAME
+* osm_switch_new
+*
+* DESCRIPTION
+* The osm_switch_new function initializes a Switch object for use.
+*
+* SYNOPSIS
+*/
+osm_switch_t *osm_switch_new(IN osm_node_t * p_node,
+ IN const osm_madw_t * p_madw);
+/*
+* PARAMETERS
+* p_node
+* [in] Pointer to the node object of this switch
+*
+* p_madw
+* [in] Pointer to the MAD Wrapper containing the switch's
+* SwitchInfo attribute.
+*
+* RETURN VALUES
+* Pointer to the new initialized switch object.
+*
+* NOTES
+*
+* SEE ALSO
+* Switch object, osm_switch_delete
+*********/
+
+/****f* OpenSM: Switch/osm_switch_get_hop_count
+* NAME
+* osm_switch_get_hop_count
+*
+* DESCRIPTION
+* Returns the hop count at the specified LID/Port intersection.
+*
+* SYNOPSIS
+*/
+static inline uint8_t osm_switch_get_hop_count(IN const osm_switch_t * p_sw,
+ IN uint16_t lid_ho,
+ IN uint8_t port_num)
+{
+ return (lid_ho > p_sw->max_lid_ho || !p_sw->hops[lid_ho]) ?
+ OSM_NO_PATH : p_sw->hops[lid_ho][port_num];
+}
+/*
+* PARAMETERS
+* p_sw
+* [in] Pointer to a Switch object.
+*
+* lid_ho
+* [in] LID value (host order) for which to return the hop count
+*
+* port_num
+* [in] Port number in the switch
+*
+* RETURN VALUES
+* Returns the hop count at the specified LID/Port intersection.
+*
+* NOTES
+*
+* SEE ALSO
+*********/
+
+/****f* OpenSM: Switch/osm_switch_set_hops
+* NAME
+* osm_switch_set_hops
+*
+* DESCRIPTION
+* Sets the hop count at the specified LID/Port intersection.
+*
+* SYNOPSIS
+*/
+cl_status_t osm_switch_set_hops(IN osm_switch_t * p_sw, IN uint16_t lid_ho,
+ IN uint8_t port_num, IN uint8_t num_hops);
+/*
+* PARAMETERS
+* p_sw
+* [in] Pointer to a Switch object.
+*
+* lid_ho
+* [in] LID value (host order) for which to set the count.
+*
+* port_num
+* [in] port number for which to set the count.
+*
+* num_hops
+* [in] value to assign to this entry.
+*
+* RETURN VALUES
+* Returns 0 if successful. -1 if it failed
+*
+* NOTES
+*
+* SEE ALSO
+*********/
+
+/****f* OpenSM: Switch/osm_switch_clear_hops
+* NAME
+* osm_switch_clear_hops
+*
+* DESCRIPTION
+* Cleanup existing hops tables (lid matrix)
+*
+* SYNOPSIS
+*/
+void osm_switch_clear_hops(IN osm_switch_t * p_sw);
+/*
+* PARAMETERS
+* p_sw
+* [in] Pointer to a Switch object.
+*
+* NOTES
+*
+* SEE ALSO
+*********/
+
+/****f* OpenSM: Switch/osm_switch_get_least_hops
+* NAME
+* osm_switch_get_least_hops
+*
+* DESCRIPTION
+* Returns the number of hops in the short path to this lid from
+* any port on the switch.
+*
+* SYNOPSIS
+*/
+static inline uint8_t osm_switch_get_least_hops(IN const osm_switch_t * p_sw,
+ IN uint16_t lid_ho)
+{
+ return (lid_ho > p_sw->max_lid_ho || !p_sw->hops[lid_ho]) ?
+ OSM_NO_PATH : p_sw->hops[lid_ho][0];
+}
+/*
+* PARAMETERS
+* p_sw
+* [in] Pointer to an osm_switch_t object.
+*
+* lid_ho
+* [in] LID (host order) for which to retrieve the shortest hop count.
+*
+* RETURN VALUES
+* Returns the number of hops in the short path to this lid from
+* any port on the switch.
+*
+* NOTES
+*
+* SEE ALSO
+* Switch object
+*********/
+
+/****f* OpenSM: Switch/osm_switch_get_port_least_hops
+* NAME
+* osm_switch_get_port_least_hops
+*
+* DESCRIPTION
+* Returns the number of hops in the short path to this port from
+* any port on the switch.
+*
+* SYNOPSIS
+*/
+uint8_t osm_switch_get_port_least_hops(IN const osm_switch_t * p_sw,
+ IN const osm_port_t * p_port);
+/*
+* PARAMETERS
+* p_sw
+* [in] Pointer to an osm_switch_t object.
+*
+* p_port
+* [in] Pointer to an osm_port_t object for which to
+* retrieve the shortest hop count.
+*
+* RETURN VALUES
+* Returns the number of hops in the short path to this lid from
+* any port on the switch.
+*
+* NOTES
+*
+* SEE ALSO
+* Switch object
+*********/
+
+/****d* OpenSM: osm_lft_type_enum
+* NAME
+* osm_lft_type_enum
+*
+* DESCRIPTION
+* Enumerates LFT sets types of a switch.
+*
+* SYNOPSIS
+*/
+typedef enum osm_lft_type_enum {
+ OSM_LFT = 0,
+ OSM_NEW_LFT
+} osm_lft_type_enum;
+/***********/
+
+/****f* OpenSM: Switch/osm_switch_get_port_by_lid
+* NAME
+* osm_switch_get_port_by_lid
+*
+* DESCRIPTION
+* Returns the switch port number on which the specified LID is routed.
+*
+* SYNOPSIS
+*/
+static inline uint8_t osm_switch_get_port_by_lid(IN const osm_switch_t * p_sw,
+ IN uint16_t lid_ho,
+ IN osm_lft_type_enum lft_enum)
+{
+ if (lid_ho == 0 || lid_ho > p_sw->max_lid_ho)
+ return OSM_NO_PATH;
+ return lft_enum == OSM_LFT ? p_sw->lft[lid_ho] : p_sw->new_lft[lid_ho];
+}
+/*
+* PARAMETERS
+* p_sw
+* [in] Pointer to an osm_switch_t object.
+*
+* lid_ho
+* [in] LID (host order) for which to retrieve the shortest hop count.
+*
+* lft_enum
+* [in] Use LFT that was calculated by routing engine, or
+* current LFT on the switch.
+*
+* RETURN VALUES
+* Returns the switch port on which the specified LID is routed.
+*
+* NOTES
+*
+* SEE ALSO
+* Switch object
+*********/
+
+/****f* OpenSM: Switch/osm_switch_get_route_by_lid
+* NAME
+* osm_switch_get_route_by_lid
+*
+* DESCRIPTION
+* Gets the physical port object that routes the specified LID.
+*
+* SYNOPSIS
+*/
+static inline osm_physp_t *osm_switch_get_route_by_lid(IN const osm_switch_t *
+ p_sw, IN ib_net16_t lid)
+{
+ uint8_t port_num;
+
+ CL_ASSERT(p_sw);
+ CL_ASSERT(lid);
+
+ port_num = osm_switch_get_port_by_lid(p_sw, cl_ntoh16(lid),
+ OSM_NEW_LFT);
+
+ /*
+ In order to avoid holes in the subnet (usually happens when
+ running UPDN algorithm), i.e. cases where port is
+ unreachable through a switch (we put an OSM_NO_PATH value at
+ the port entry, we do not assert on unreachable lid entries
+ at the fwd table but return NULL
+ */
+ if (port_num != OSM_NO_PATH)
+ return (osm_node_get_physp_ptr(p_sw->p_node, port_num));
+ else
+ return NULL;
+}
+/*
+* PARAMETERS
+* p_sw
+* [in] Pointer to an osm_switch_t object.
+*
+* lid
+* [in] LID for which to find a route. This must be a unicast
+* LID value < 0xC000.
+*
+* RETURN VALUES
+* Returns a pointer to the Physical Port Object object that
+* routes the specified LID. A return value of zero means
+* there is no route for the lid through this switch.
+* The lid value must be a unicast LID.
+*
+* NOTES
+*
+* SEE ALSO
+* Switch object
+*********/
+
+/****f* OpenSM: Switch/osm_switch_sp0_is_lmc_capable
+* NAME
+* osm_switch_sp0_is_lmc_capable
+*
+* DESCRIPTION
+* Returns whether switch port 0 (SP0) can support LMC
+*
+*/
+static inline unsigned
+osm_switch_sp0_is_lmc_capable(IN const osm_switch_t * p_sw,
+ IN osm_subn_t * p_subn)
+{
+ return (p_subn->opt.lmc_esp0 &&
+ ib_switch_info_is_enhanced_port0(&p_sw->switch_info)) ? 1 : 0;
+}
+/*
+* PARAMETERS
+* p_sw
+* [in] Pointer to an osm_switch_t object.
+*
+* p_subn
+* [in] Pointer to an osm_subn_t object.
+*
+* RETURN VALUES
+* TRUE if SP0 is enhanced and globally enabled. FALSE otherwise.
+*
+* NOTES
+* This is workaround function, it takes into account user defined
+* p_subn->opt.lmc_esp0 parameter.
+*
+* SEE ALSO
+*********/
+
+/****f* OpenSM: Switch/osm_switch_get_max_block_id_in_use
+* NAME
+* osm_switch_get_max_block_id_in_use
+*
+* DESCRIPTION
+* Returns the maximum block ID (host order) of this switch that
+* is used for unicast routing.
+*
+* SYNOPSIS
+*/
+static inline uint16_t
+osm_switch_get_max_block_id_in_use(IN const osm_switch_t * p_sw)
+{
+ return cl_ntoh16(p_sw->switch_info.lin_top) / IB_SMP_DATA_SIZE;
+}
+/*
+* PARAMETERS
+* p_sw
+* [in] Pointer to an osm_switch_t object.
+*
+* RETURN VALUES
+* Returns the maximum block ID (host order) of this switch.
+*
+* NOTES
+*
+* SEE ALSO
+* Switch object
+*********/
+
+/****f* OpenSM: Switch/osm_switch_get_lft_block
+* NAME
+* osm_switch_get_lft_block
+*
+* DESCRIPTION
+* Retrieve a linear forwarding table block.
+*
+* SYNOPSIS
+*/
+boolean_t osm_switch_get_lft_block(IN const osm_switch_t * p_sw,
+ IN uint16_t block_id, OUT uint8_t * p_block);
+/*
+* PARAMETERS
+* p_sw
+* [in] Pointer to an osm_switch_t object.
+*
+* block_id
+* [in] The block_id to retrieve.
+*
+* p_block
+* [out] Pointer to the 64 byte array to store the
+* forwarding table block specified by block_id.
+*
+* RETURN VALUES
+* Returns true if there are more blocks necessary to
+* configure all the LIDs reachable from this switch.
+* FALSE otherwise.
+*
+* NOTES
+*
+* SEE ALSO
+*********/
+
+/****f* OpenSM: Switch/osm_switch_supports_mcast
+* NAME
+* osm_switch_supports_mcast
+*
+* DESCRIPTION
+* Indicates if a switch supports multicast.
+*
+* SYNOPSIS
+*/
+static inline boolean_t osm_switch_supports_mcast(IN const osm_switch_t * p_sw)
+{
+ return (p_sw->switch_info.mcast_cap != 0);
+}
+/*
+* PARAMETERS
+* p_sw
+* [in] Pointer to an osm_switch_t object.
+*
+* RETURN VALUES
+* Returns TRUE if the switch supports multicast.
+* FALSE otherwise.
+*
+* NOTES
+*
+* SEE ALSO
+*********/
+
+/****f* OpenSM: Switch/osm_switch_set_switch_info
+* NAME
+* osm_switch_set_switch_info
+*
+* DESCRIPTION
+* Updates the switch info attribute of this switch.
+*
+* SYNOPSIS
+*/
+static inline void osm_switch_set_switch_info(IN osm_switch_t * p_sw,
+ IN const ib_switch_info_t * p_si)
+{
+ CL_ASSERT(p_sw);
+ CL_ASSERT(p_si);
+ p_sw->switch_info = *p_si;
+}
+/*
+* PARAMETERS
+* p_sw
+* [in] Pointer to a Switch object.
+*
+* p_si
+* [in] Pointer to the SwitchInfo attribute for this switch.
+*
+* RETURN VALUES
+* None.
+*
+* NOTES
+*
+* SEE ALSO
+*********/
+
+/****f* OpenSM: Switch/osm_switch_count_path
+* NAME
+* osm_switch_count_path
+*
+* DESCRIPTION
+* Counts this path in port profile.
+*
+* SYNOPSIS
+*/
+static inline void osm_switch_count_path(IN osm_switch_t * p_sw,
+ IN uint8_t port)
+{
+ osm_port_prof_path_count_inc(&p_sw->p_prof[port]);
+}
+/*
+* PARAMETERS
+* p_sw
+* [in] Pointer to the switch object.
+*
+* port
+* [in] Port to count path.
+*
+* RETURN VALUE
+* None.
+*
+* NOTES
+*
+* SEE ALSO
+*********/
+
+/****f* OpenSM: Switch/osm_switch_set_lft_block
+* NAME
+* osm_switch_set_lft_block
+*
+* DESCRIPTION
+* Copies in the specified block into
+* the switch's Linear Forwarding Table.
+*
+* SYNOPSIS
+*/
+static inline ib_api_status_t
+osm_switch_set_lft_block(IN osm_switch_t * p_sw, IN const uint8_t * p_block,
+ IN uint32_t block_num)
+{
+ uint16_t lid_start =
+ (uint16_t) (block_num * IB_SMP_DATA_SIZE);
+ CL_ASSERT(p_sw);
+
+ if (lid_start + IB_SMP_DATA_SIZE > p_sw->lft_size)
+ return IB_INVALID_PARAMETER;
+
+ memcpy(&p_sw->lft[lid_start], p_block, IB_SMP_DATA_SIZE);
+ return IB_SUCCESS;
+}
+/*
+* PARAMETERS
+* p_sw
+* [in] Pointer to the switch object.
+*
+* p_block
+* [in] Pointer to the forwarding table block.
+*
+* block_num
+* [in] Block number for this block
+*
+* RETURN VALUE
+* None.
+*
+* NOTES
+*
+* SEE ALSO
+*********/
+
+/****f* OpenSM: Switch/osm_switch_set_mft_block
+* NAME
+* osm_switch_set_mft_block
+*
+* DESCRIPTION
+* Sets a block of multicast port masks into the multicast table.
+*
+* SYNOPSIS
+*/
+static inline ib_api_status_t
+osm_switch_set_mft_block(IN osm_switch_t * p_sw, IN const ib_net16_t * p_block,
+ IN uint16_t block_num, IN uint8_t position)
+{
+ CL_ASSERT(p_sw);
+ return osm_mcast_tbl_set_block(&p_sw->mcast_tbl, p_block, block_num,
+ position);
+}
+/*
+* PARAMETERS
+* p_sw
+* [in] Pointer to the switch object.
+*
+* p_block
+* [in] Pointer to the block of port masks to set.
+*
+* block_num
+* [in] Block number (0-511) to set.
+*
+* position
+* [in] Port mask position (0-15) to set.
+*
+* RETURN VALUE
+* IB_SUCCESS on success.
+*
+* NOTES
+*
+* SEE ALSO
+*********/
+
+/****f* OpenSM: Switch/osm_switch_get_mft_block
+* NAME
+* osm_switch_get_mft_block
+*
+* DESCRIPTION
+* Retrieve a block of multicast port masks from the multicast table.
+*
+* SYNOPSIS
+*/
+static inline boolean_t osm_switch_get_mft_block(IN osm_switch_t * p_sw,
+ IN uint16_t block_num,
+ IN uint8_t position,
+ OUT ib_net16_t * p_block)
+{
+ CL_ASSERT(p_sw);
+ return osm_mcast_tbl_get_block(&p_sw->mcast_tbl, block_num, position,
+ p_block);
+}
+/*
+* PARAMETERS
+* p_sw
+* [in] Pointer to the switch object.
+*
+* block_num
+* [in] Block number (0-511) to set.
+*
+* position
+* [in] Port mask position (0-15) to set.
+*
+* p_block
+* [out] Pointer to the block of port masks stored.
+*
+* RETURN VALUES
+* Returns true if there are more blocks necessary to
+* configure all the MLIDs reachable from this switch.
+* FALSE otherwise.
+*
+* NOTES
+*
+* SEE ALSO
+*********/
+
+/****f* OpenSM: Switch/osm_switch_get_mft_max_block
+* NAME
+* osm_switch_get_mft_max_block
+*
+* DESCRIPTION
+* Get the max_block from the associated multicast table.
+*
+* SYNOPSIS
+*/
+static inline uint16_t osm_switch_get_mft_max_block(IN osm_switch_t * p_sw)
+{
+ CL_ASSERT(p_sw);
+ return osm_mcast_tbl_get_max_block(&p_sw->mcast_tbl);
+}
+/*
+* PARAMETERS
+* p_sw
+* [in] Pointer to the switch object.
+*
+* RETURN VALUE
+*/
+
+/****f* OpenSM: Switch/osm_switch_get_mft_max_block_in_use
+* NAME
+* osm_switch_get_mft_max_block_in_use
+*
+* DESCRIPTION
+* Get the max_block_in_use from the associated multicast table.
+*
+* SYNOPSIS
+*/
+static inline int16_t osm_switch_get_mft_max_block_in_use(IN osm_switch_t * p_sw)
+{
+ CL_ASSERT(p_sw);
+ return osm_mcast_tbl_get_max_block_in_use(&p_sw->mcast_tbl);
+}
+/*
+* PARAMETERS
+* p_sw
+* [in] Pointer to the switch object.
+*
+* RETURN VALUES
+* Returns the maximum block ID in use in this switch's mcast table.
+* A value of -1 indicates no blocks are in use.
+*
+* NOTES
+*
+* SEE ALSO
+*/
+
+/****f* OpenSM: Switch/osm_switch_get_mft_max_position
+* NAME
+* osm_switch_get_mft_max_position
+*
+* DESCRIPTION
+* Get the max_position from the associated multicast table.
+*
+* SYNOPSIS
+*/
+static inline uint8_t osm_switch_get_mft_max_position(IN osm_switch_t * p_sw)
+{
+ CL_ASSERT(p_sw);
+ return osm_mcast_tbl_get_max_position(&p_sw->mcast_tbl);
+}
+/*
+* PARAMETERS
+* p_sw
+* [in] Pointer to the switch object.
+*
+* RETURN VALUE
+*/
+
+/****f* OpenSM: Switch/osm_switch_get_dimn_port
+* NAME
+* osm_switch_get_dimn_port
+*
+* DESCRIPTION
+* Get the routing ordered port
+*
+* SYNOPSIS
+*/
+static inline uint8_t osm_switch_get_dimn_port(IN const osm_switch_t * p_sw,
+ IN uint8_t port_num)
+{
+ CL_ASSERT(p_sw);
+ if (p_sw->search_ordering_ports == NULL)
+ return port_num;
+ return p_sw->search_ordering_ports[port_num];
+}
+/*
+* PARAMETERS
+* p_sw
+* [in] Pointer to the switch object.
+*
+* port_num
+* [in] Port number in the switch
+*
+* RETURN VALUES
+* Returns the port number ordered for routing purposes.
+*/
+
+/****f* OpenSM: Switch/osm_switch_recommend_path
+* NAME
+* osm_switch_recommend_path
+*
+* DESCRIPTION
+* Returns the recommended port on which to route this LID.
+* In cases where LMC > 0, the remote side system and node
+* used for the routing are tracked in the provided arrays
+* (and counts) such that other lid for the same port will
+* try and avoid going through the same remote system/node.
+*
+* SYNOPSIS
+*/
+uint8_t osm_switch_recommend_path(IN const osm_switch_t * p_sw,
+ IN osm_port_t * p_port, IN uint16_t lid_ho,
+ IN unsigned start_from,
+ IN boolean_t ignore_existing,
+ IN boolean_t routing_for_lmc,
+ IN boolean_t dor,
+ IN boolean_t port_shifting,
+ IN uint32_t scatter_ports,
+ IN osm_lft_type_enum lft_enum);
+/*
+* PARAMETERS
+* p_sw
+* [in] Pointer to the switch object.
+*
+* p_port
+* [in] Pointer to the port object for which to get a path
+* advisory.
+*
+* lid_ho
+* [in] LID value (host order) for which to get a path advisory.
+*
+* start_from
+* [in] Port number from where to start balance counting.
+*
+* ignore_existing
+* [in] Set to cause the switch to choose the optimal route
+* regardless of existing paths.
+* If false, the switch will choose an existing route if one
+* exists, otherwise will choose the optimal route.
+*
+* routing_for_lmc
+* [in] We support an enhanced LMC aware routing mode:
+* In the case of LMC > 0, we can track the remote side
+* system and node for all of the lids of the target
+* and try and avoid routing again through the same
+* system / node.
+*
+* Assume if routing_for_lmc is TRUE that this procedure
+* was provided with the tracking array and counter via
+* p_port->priv, and we can conduct this algorithm.
+*
+* dor
+* [in] If TRUE, Dimension Order Routing will be done.
+*
+* port_shifting
+* [in] If TRUE, port_shifting will be done.
+*
+* scatter_ports
+* [in] If not zero, randomize the selection of the best ports.
+*
+* lft_enum
+* [in] Use LFT that was calculated by routing engine, or
+* current LFT on the switch.
+*
+* RETURN VALUE
+* Returns the recommended port on which to route this LID.
+*
+* NOTES
+*
+* SEE ALSO
+*********/
+
+/****f* OpenSM: Switch/osm_switch_recommend_mcast_path
+* NAME
+* osm_switch_recommend_mcast_path
+*
+* DESCRIPTION
+* Returns the recommended port on which to route this LID.
+*
+* SYNOPSIS
+*/
+uint8_t osm_switch_recommend_mcast_path(IN osm_switch_t * p_sw,
+ IN osm_port_t * p_port,
+ IN uint16_t mlid_ho,
+ IN boolean_t ignore_existing);
+/*
+* PARAMETERS
+* p_sw
+* [in] Pointer to the switch object.
+*
+* p_port
+* [in] Pointer to the port object for which to get
+* the multicast path.
+*
+* mlid_ho
+* [in] MLID for the multicast group in question.
+*
+* ignore_existing
+* [in] Set to cause the switch to choose the optimal route
+* regardless of existing paths.
+* If false, the switch will choose an existing route if one exists,
+* otherwise will choose the optimal route.
+*
+* RETURN VALUE
+* Returns the recommended port on which to route this LID.
+*
+* NOTES
+*
+* SEE ALSO
+*********/
+
+/****f* OpenSM: Switch/osm_switch_get_mcast_fwd_tbl_size
+* NAME
+* osm_switch_get_mcast_fwd_tbl_size
+*
+* DESCRIPTION
+* Returns the number of entries available in the multicast forwarding table.
+*
+* SYNOPSIS
+*/
+static inline uint16_t
+osm_switch_get_mcast_fwd_tbl_size(IN const osm_switch_t * p_sw)
+{
+ return cl_ntoh16(p_sw->switch_info.mcast_cap);
+}
+/*
+* PARAMETERS
+* p_sw
+* [in] Pointer to the switch.
+*
+* RETURN VALUE
+* Returns the number of entries available in the multicast forwarding table.
+*
+* NOTES
+*
+* SEE ALSO
+*********/
+
+/****f* OpenSM: Switch/osm_switch_path_count_get
+* NAME
+* osm_switch_path_count_get
+*
+* DESCRIPTION
+* Returns the count of the number of paths going through this port.
+*
+* SYNOPSIS
+*/
+static inline uint32_t osm_switch_path_count_get(IN const osm_switch_t * p_sw,
+ IN uint8_t port_num)
+{
+ return osm_port_prof_path_count_get(&p_sw->p_prof[port_num]);
+}
+/*
+* PARAMETERS
+* p_sw
+* [in] Pointer to the Switch object.
+*
+* port_num
+* [in] Port number for which to get path count.
+*
+* RETURN VALUE
+* Returns the count of the number of paths going through this port.
+*
+* NOTES
+*
+* SEE ALSO
+*********/
+
+/****f* OpenSM: Switch/osm_switch_prepare_path_rebuild
+* NAME
+* osm_switch_prepare_path_rebuild
+*
+* DESCRIPTION
+* Prepares a switch to rebuild pathing information.
+*
+* SYNOPSIS
+*/
+int osm_switch_prepare_path_rebuild(IN osm_switch_t * p_sw,
+ IN uint16_t max_lids);
+/*
+* PARAMETERS
+* p_sw
+* [in] Pointer to the Switch object.
+*
+* max_lids
+* [in] Max number of lids in the subnet.
+*
+* RETURN VALUE
+* Returns zero on success, or negative value if an error occurred.
+*
+* NOTES
+*
+* SEE ALSO
+*********/
+
+/****f* OpenSM: Switch/osm_switch_get_mcast_tbl_ptr
+* NAME
+* osm_switch_get_mcast_tbl_ptr
+*
+* DESCRIPTION
+* Returns a pointer to the switch's multicast table.
+*
+* SYNOPSIS
+*/
+static inline osm_mcast_tbl_t *osm_switch_get_mcast_tbl_ptr(IN const
+ osm_switch_t * p_sw)
+{
+ return (osm_mcast_tbl_t *) & p_sw->mcast_tbl;
+}
+/*
+* PARAMETERS
+* p_sw
+* [in] Pointer to the switch.
+*
+* RETURN VALUE
+* Returns a pointer to the switch's multicast table.
+*
+* NOTES
+*
+* SEE ALSO
+*********/
+
+/****f* OpenSM: Switch/osm_switch_is_in_mcast_tree
+* NAME
+* osm_switch_is_in_mcast_tree
+*
+* DESCRIPTION
+* Returns true if this switch already belongs in the tree for the specified
+* multicast group.
+*
+* SYNOPSIS
+*/
+static inline boolean_t
+osm_switch_is_in_mcast_tree(IN const osm_switch_t * p_sw, IN uint16_t mlid_ho)
+{
+ const osm_mcast_tbl_t *p_tbl;
+
+ p_tbl = &p_sw->mcast_tbl;
+ if (p_tbl)
+ return osm_mcast_tbl_is_any_port(&p_sw->mcast_tbl, mlid_ho);
+ else
+ return FALSE;
+}
+/*
+* PARAMETERS
+* p_sw
+* [in] Pointer to the switch.
+*
+* mlid_ho
+* [in] MLID (host order) of the multicast tree to check.
+*
+* RETURN VALUE
+* Returns true if this switch already belongs in the tree for the specified
+* multicast group.
+*
+* NOTES
+*
+* SEE ALSO
+*********/
+
+END_C_DECLS
+#endif /* _OSM_SWITCH_H_ */
diff --git a/contrib/ofed/opensm/include/opensm/osm_ucast_cache.h b/contrib/ofed/opensm/include/opensm/osm_ucast_cache.h
new file mode 100644
index 0000000..e186590
--- /dev/null
+++ b/contrib/ofed/opensm/include/opensm/osm_ucast_cache.h
@@ -0,0 +1,241 @@
+/*
+ * Copyright (c) 2008 Voltaire, Inc. All rights reserved.
+ * Copyright (c) 2008 Mellanox Technologies LTD. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+/*
+ * Abstract:
+ * Header file that describes Unicast Cache functions.
+ *
+ * Environment:
+ * Linux User Mode
+ *
+ * $Revision: 1.4 $
+ */
+
+#ifndef _OSM_UCAST_CACHE_H_
+#define _OSM_UCAST_CACHE_H_
+
+#include <iba/ib_types.h>
+#include <complib/cl_qmap.h>
+#include <opensm/osm_switch.h>
+
+#ifdef __cplusplus
+# define BEGIN_C_DECLS extern "C" {
+# define END_C_DECLS }
+#else /* !__cplusplus */
+# define BEGIN_C_DECLS
+# define END_C_DECLS
+#endif /* __cplusplus */
+
+BEGIN_C_DECLS
+
+struct osm_ucast_mgr;
+
+/****h* OpenSM/Unicast Manager/Unicast Cache
+* NAME
+* Unicast Cache
+*
+* DESCRIPTION
+* The Unicast Cache object encapsulates the information
+* needed to cache and write unicast routing of the subnet.
+*
+* The Unicast Cache object is NOT thread safe.
+*
+* This object should be treated as opaque and should be
+* manipulated only through the provided functions.
+*
+* AUTHOR
+* Yevgeny Kliteynik, Mellanox
+*
+*********/
+
+/****f* OpenSM: Unicast Cache/osm_ucast_cache_invalidate
+* NAME
+* osm_ucast_cache_invalidate
+*
+* DESCRIPTION
+* The osm_ucast_cache_invalidate function purges the
+* unicast cache and marks the cache as invalid.
+*
+* SYNOPSIS
+*/
+void osm_ucast_cache_invalidate(struct osm_ucast_mgr *p_mgr);
+/*
+* PARAMETERS
+* p_mgr
+* [in] Pointer to the ucast mgr object.
+*
+* RETURN VALUE
+* This function does not return any value.
+*
+* NOTES
+*
+* SEE ALSO
+* Unicast Manager object
+*********/
+
+/****f* OpenSM: Unicast Cache/osm_ucast_cache_check_new_link
+* NAME
+* osm_ucast_cache_check_new_link
+*
+* DESCRIPTION
+* The osm_ucast_cache_check_new_link checks whether
+* the newly discovered link still allows us to use
+* cached unicast routing.
+*
+* SYNOPSIS
+*/
+void osm_ucast_cache_check_new_link(struct osm_ucast_mgr *p_mgr,
+ osm_node_t * p_node_1, uint8_t port_num_1,
+ osm_node_t * p_node_2, uint8_t port_num_2);
+/*
+* PARAMETERS
+* p_mgr
+* [in] Pointer to the unicast manager object.
+*
+* physp1
+* [in] Pointer to the first physical port of the link.
+*
+* physp2
+* [in] Pointer to the second physical port of the link.
+*
+* RETURN VALUE
+* This function does not return any value.
+*
+* NOTES
+* The function checks whether the link was previously
+* cached/dropped or is this a completely new link.
+* If it decides that the new link makes cached routing
+* invalid, the cache is purged and marked as invalid.
+*
+* SEE ALSO
+* Unicast Cache object
+*********/
+
+/****f* OpenSM: Unicast Cache/osm_ucast_cache_add_link
+* NAME
+* osm_ucast_cache_add_link
+*
+* DESCRIPTION
+* The osm_ucast_cache_add_link adds link to the cache.
+*
+* SYNOPSIS
+*/
+void osm_ucast_cache_add_link(struct osm_ucast_mgr *p_mgr,
+ osm_physp_t * physp1, osm_physp_t * physp2);
+/*
+* PARAMETERS
+* p_mgr
+* [in] Pointer to the unicast manager object.
+*
+* physp1
+* [in] Pointer to the first physical port of the link.
+*
+* physp2
+* [in] Pointer to the second physical port of the link.
+*
+* RETURN VALUE
+* This function does not return any value.
+*
+* NOTES
+* Since the cache operates with ports and not links,
+* the function adds two port entries (both sides of the
+* link) to the cache.
+* If it decides that the dropped link makes cached routing
+* invalid, the cache is purged and marked as invalid.
+*
+* SEE ALSO
+* Unicast Manager object
+*********/
+
+/****f* OpenSM: Unicast Cache/osm_ucast_cache_add_node
+* NAME
+* osm_ucast_cache_add_node
+*
+* DESCRIPTION
+* The osm_ucast_cache_add_node adds node and all
+* its links to the cache.
+*
+* SYNOPSIS
+*/
+void osm_ucast_cache_add_node(struct osm_ucast_mgr *p_mgr, osm_node_t * p_node);
+/*
+* PARAMETERS
+* p_mgr
+* [in] Pointer to the unicast manager object.
+*
+* p_node
+* [in] Pointer to the node object that should be cached.
+*
+* RETURN VALUE
+* This function does not return any value.
+*
+* NOTES
+* If the function decides that the dropped node makes cached
+* routing invalid, the cache is purged and marked as invalid.
+*
+* SEE ALSO
+* Unicast Manager object
+*********/
+
+/****f* OpenSM: Unicast Cache/osm_ucast_cache_process
+* NAME
+* osm_ucast_cache_process
+*
+* DESCRIPTION
+* The osm_ucast_cache_process function writes the
+* cached unicast routing on the subnet switches.
+*
+* SYNOPSIS
+*/
+int osm_ucast_cache_process(struct osm_ucast_mgr *p_mgr);
+/*
+* PARAMETERS
+* p_mgr
+* [in] Pointer to the unicast manager object.
+*
+* RETURN VALUE
+* This function returns zero on sucess and non-zero
+* value otherwise.
+*
+* NOTES
+* Iterates through all the subnet switches and writes
+* the LFTs that were calculated during the last routing
+* engine execution to the switches.
+*
+* SEE ALSO
+* Unicast Manager object
+*********/
+
+END_C_DECLS
+#endif /* _OSM_UCAST_CACHE_H_ */
diff --git a/contrib/ofed/opensm/include/opensm/osm_ucast_lash.h b/contrib/ofed/opensm/include/opensm/osm_ucast_lash.h
new file mode 100644
index 0000000..dd90d5d
--- /dev/null
+++ b/contrib/ofed/opensm/include/opensm/osm_ucast_lash.h
@@ -0,0 +1,97 @@
+/*
+ * Copyright (c) 2008,2009 System Fabric Works, Inc. All rights reserved.
+ * Copyright (c) 2004-2008 Voltaire, Inc. All rights reserved.
+ * Copyright (c) 2002-2006 Mellanox Technologies LTD. All rights reserved.
+ * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
+ * Copyright (c) 2007 Simula Research Laboratory. All rights reserved.
+ * Copyright (c) 2007 Silicon Graphics Inc. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+/*
+ * Abstract:
+ * Declarations for LASH algorithm
+ */
+
+#ifndef OSM_UCAST_LASH_H
+#define OSM_UCAST_LASH_H
+
+#include <opensm/osm_mesh.h>
+
+enum {
+ UNQUEUED,
+ Q_MEMBER,
+ MST_MEMBER,
+ MAX_INT = 9999,
+ NONE = MAX_INT
+};
+
+typedef struct _cdg_vertex {
+ int from;
+ int to;
+ int seen;
+ int temp;
+ int visiting_number;
+ struct _cdg_vertex *next;
+ int num_temp_depend;
+ int num_using_vertex;
+ int num_deps;
+ struct vertex_deps {
+ struct _cdg_vertex *v;
+ int num_used;
+ } deps[0];
+} cdg_vertex_t;
+
+typedef struct _switch {
+ osm_switch_t *p_sw;
+ int id;
+ int used_channels;
+ int *dij_channels;
+ int q_state;
+ mesh_node_t *node;
+ struct routing_table {
+ unsigned out_link;
+ unsigned lane;
+ } routing_table[0];
+} switch_t;
+
+typedef struct _lash {
+ osm_opensm_t *p_osm;
+ int num_switches;
+ uint8_t vl_min;
+ int balance_limit;
+ switch_t **switches;
+ cdg_vertex_t ****cdg_vertex_matrix;
+ int num_mst_in_lane[IB_MAX_NUM_VLS];
+ int ***virtual_location;
+} lash_t;
+
+#endif
diff --git a/contrib/ofed/opensm/include/opensm/osm_ucast_mgr.h b/contrib/ofed/opensm/include/opensm/osm_ucast_mgr.h
new file mode 100644
index 0000000..b9c1ca1
--- /dev/null
+++ b/contrib/ofed/opensm/include/opensm/osm_ucast_mgr.h
@@ -0,0 +1,302 @@
+/*
+ * Copyright (c) 2004-2009 Voltaire, Inc. All rights reserved.
+ * Copyright (c) 2002-2009 Mellanox Technologies LTD. All rights reserved.
+ * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+/*
+ * Abstract:
+ * Declaration of osm_ucast_mgr_t.
+ * This object represents the Unicast Manager object.
+ * This object is part of the OpenSM family of objects.
+ */
+
+#ifndef _OSM_UCAST_MGR_H_
+#define _OSM_UCAST_MGR_H_
+
+#include <complib/cl_passivelock.h>
+#include <complib/cl_qlist.h>
+#include <opensm/osm_madw.h>
+#include <opensm/osm_subnet.h>
+#include <opensm/osm_switch.h>
+#include <opensm/osm_log.h>
+#include <opensm/osm_ucast_cache.h>
+
+#ifdef __cplusplus
+# define BEGIN_C_DECLS extern "C" {
+# define END_C_DECLS }
+#else /* !__cplusplus */
+# define BEGIN_C_DECLS
+# define END_C_DECLS
+#endif /* __cplusplus */
+
+BEGIN_C_DECLS
+/****h* OpenSM/Unicast Manager
+* NAME
+* Unicast Manager
+*
+* DESCRIPTION
+* The Unicast Manager object encapsulates the information
+* needed to control unicast LID forwarding on the subnet.
+*
+* The Unicast Manager object is thread safe.
+*
+* This object should be treated as opaque and should be
+* manipulated only through the provided functions.
+*
+* AUTHOR
+* Steve King, Intel
+*
+*********/
+struct osm_sm;
+/****s* OpenSM: Unicast Manager/osm_ucast_mgr_t
+* NAME
+* osm_ucast_mgr_t
+*
+* DESCRIPTION
+* Unicast Manager structure.
+*
+* This object should be treated as opaque and should
+* be manipulated only through the provided functions.
+*
+* SYNOPSIS
+*/
+typedef struct osm_ucast_mgr {
+ struct osm_sm *sm;
+ osm_subn_t *p_subn;
+ osm_log_t *p_log;
+ cl_plock_t *p_lock;
+ uint16_t max_lid;
+ cl_qlist_t port_order_list;
+ boolean_t is_dor;
+ boolean_t some_hop_count_set;
+ cl_qmap_t cache_sw_tbl;
+ boolean_t cache_valid;
+} osm_ucast_mgr_t;
+/*
+* FIELDS
+* sm
+* Pointer to the SM object.
+*
+* p_subn
+* Pointer to the Subnet object for this subnet.
+*
+* p_log
+* Pointer to the log object.
+*
+* p_lock
+* Pointer to the serializing lock.
+*
+* is_dor
+* Dimension Order Routing (DOR) will be done
+*
+* port_order_list
+* List of ports ordered for routing.
+*
+* some_hop_count_set
+* Initialized to FALSE at the beginning of each the min hop
+* tables calculation iteration cycle, set to TRUE to indicate
+* that some hop count changes were done.
+*
+* cache_sw_tbl
+* Cached switches table.
+*
+* cache_valid
+* TRUE if the unicast cache is valid.
+*
+* SEE ALSO
+* Unicast Manager object
+*********/
+
+/****f* OpenSM: Unicast Manager/osm_ucast_mgr_construct
+* NAME
+* osm_ucast_mgr_construct
+*
+* DESCRIPTION
+* This function constructs a Unicast Manager object.
+*
+* SYNOPSIS
+*/
+void osm_ucast_mgr_construct(IN osm_ucast_mgr_t * p_mgr);
+/*
+* PARAMETERS
+* p_mgr
+* [in] Pointer to a Unicast Manager object to construct.
+*
+* RETURN VALUE
+* This function does not return a value.
+*
+* NOTES
+* Allows osm_ucast_mgr_destroy
+*
+* Calling osm_ucast_mgr_construct is a prerequisite to calling any other
+* method except osm_ucast_mgr_init.
+*
+* SEE ALSO
+* Unicast Manager object, osm_ucast_mgr_init,
+* osm_ucast_mgr_destroy
+*********/
+
+/****f* OpenSM: Unicast Manager/osm_ucast_mgr_destroy
+* NAME
+* osm_ucast_mgr_destroy
+*
+* DESCRIPTION
+* The osm_ucast_mgr_destroy function destroys the object, releasing
+* all resources.
+*
+* SYNOPSIS
+*/
+void osm_ucast_mgr_destroy(IN osm_ucast_mgr_t * p_mgr);
+/*
+* PARAMETERS
+* p_mgr
+* [in] Pointer to the object to destroy.
+*
+* RETURN VALUE
+* This function does not return a value.
+*
+* NOTES
+* Performs any necessary cleanup of the specified
+* Unicast Manager object.
+* Further operations should not be attempted on the destroyed object.
+* This function should only be called after a call to
+* osm_ucast_mgr_construct or osm_ucast_mgr_init.
+*
+* SEE ALSO
+* Unicast Manager object, osm_ucast_mgr_construct,
+* osm_ucast_mgr_init
+*********/
+
+/****f* OpenSM: Unicast Manager/osm_ucast_mgr_init
+* NAME
+* osm_ucast_mgr_init
+*
+* DESCRIPTION
+* The osm_ucast_mgr_init function initializes a
+* Unicast Manager object for use.
+*
+* SYNOPSIS
+*/
+ib_api_status_t osm_ucast_mgr_init(IN osm_ucast_mgr_t * p_mgr,
+ IN struct osm_sm * sm);
+/*
+* PARAMETERS
+* p_mgr
+* [in] Pointer to an osm_ucast_mgr_t object to initialize.
+*
+* sm
+* [in] Pointer to the SM object.
+*
+* RETURN VALUES
+* IB_SUCCESS if the Unicast Manager object was initialized
+* successfully.
+*
+* NOTES
+* Allows calling other Unicast Manager methods.
+*
+* SEE ALSO
+* Unicast Manager object, osm_ucast_mgr_construct,
+* osm_ucast_mgr_destroy
+*********/
+
+/****f* OpenSM: Unicast Manager/osm_ucast_mgr_set_fwd_tables
+* NAME
+* osm_ucast_mgr_set_fwd_tables
+*
+* DESCRIPTION
+* Setup forwarding table for the switch (from prepared new_lft).
+*
+* SYNOPSIS
+*/
+void osm_ucast_mgr_set_fwd_tables(IN osm_ucast_mgr_t * p_mgr);
+/*
+* PARAMETERS
+* p_mgr
+* [in] Pointer to an osm_ucast_mgr_t object.
+*
+* SEE ALSO
+* Unicast Manager
+*********/
+
+/****f* OpenSM: Unicast Manager/osm_ucast_mgr_build_lid_matrices
+* NAME
+* osm_ucast_mgr_build_lid_matrices
+*
+* DESCRIPTION
+* Build switches's lid matrices.
+*
+* SYNOPSIS
+*/
+int osm_ucast_mgr_build_lid_matrices(IN osm_ucast_mgr_t * p_mgr);
+/*
+* PARAMETERS
+* p_mgr
+* [in] Pointer to an osm_ucast_mgr_t object.
+*
+* NOTES
+* This function processes the subnet, configuring switches'
+* min hops tables (aka lid matrices).
+*
+* SEE ALSO
+* Unicast Manager
+*********/
+
+/****f* OpenSM: Unicast Manager/osm_ucast_mgr_process
+* NAME
+* osm_ucast_mgr_process
+*
+* DESCRIPTION
+* Process and configure the subnet's unicast forwarding tables.
+*
+* SYNOPSIS
+*/
+int osm_ucast_mgr_process(IN osm_ucast_mgr_t * p_mgr);
+/*
+* PARAMETERS
+* p_mgr
+* [in] Pointer to an osm_ucast_mgr_t object.
+*
+* RETURN VALUES
+* Returns zero on success and negative value on failure.
+*
+* NOTES
+* This function processes the subnet, configuring switch
+* unicast forwarding tables.
+*
+* SEE ALSO
+* Unicast Manager, Node Info Response Controller
+*********/
+
+int ucast_dummy_build_lid_matrices(void *context);
+END_C_DECLS
+#endif /* _OSM_UCAST_MGR_H_ */
diff --git a/contrib/ofed/opensm/include/opensm/osm_version.h b/contrib/ofed/opensm/include/opensm/osm_version.h
new file mode 100644
index 0000000..8a27a00
--- /dev/null
+++ b/contrib/ofed/opensm/include/opensm/osm_version.h
@@ -0,0 +1,51 @@
+/*
+ * Copyright (c) 2004-2008 Voltaire, Inc. All rights reserved.
+ * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved.
+ * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+#ifndef _OSM_VERSION_H_
+#define _OSM_VERSION_H_
+
+/****s* OpenSM: Base/OSM_VERSION
+* NAME
+* OSM_VERSION
+*
+* DESCRIPTION
+* The version string for OpenSM
+*
+* SYNOPSIS
+*/
+#define OSM_VERSION "OpenSM 3.3.20"
+/********/
+
+#endif /* _OSM_VERSION_H_ */
diff --git a/contrib/ofed/opensm/include/opensm/osm_vl15intf.h b/contrib/ofed/opensm/include/opensm/osm_vl15intf.h
new file mode 100644
index 0000000..b024b23
--- /dev/null
+++ b/contrib/ofed/opensm/include/opensm/osm_vl15intf.h
@@ -0,0 +1,388 @@
+/*
+ * Copyright (c) 2004-2009 Voltaire, Inc. All rights reserved.
+ * Copyright (c) 2002-2010 Mellanox Technologies LTD. All rights reserved.
+ * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+/*
+ * Abstract:
+ * Declaration of osm_vl15_t.
+ * This object represents a VL15 interface object.
+ * This object is part of the OpenSM family of objects.
+ */
+
+#ifndef _OSM_VL15INTF_H_
+#define _OSM_VL15INTF_H_
+
+#include <iba/ib_types.h>
+#include <complib/cl_spinlock.h>
+#include <complib/cl_event.h>
+#include <complib/cl_thread.h>
+#include <complib/cl_qlist.h>
+#include <opensm/osm_stats.h>
+#include <opensm/osm_log.h>
+#include <opensm/osm_madw.h>
+#include <opensm/osm_mad_pool.h>
+#include <vendor/osm_vendor_api.h>
+#include <opensm/osm_subnet.h>
+
+#ifdef __cplusplus
+# define BEGIN_C_DECLS extern "C" {
+# define END_C_DECLS }
+#else /* !__cplusplus */
+# define BEGIN_C_DECLS
+# define END_C_DECLS
+#endif /* __cplusplus */
+
+BEGIN_C_DECLS
+/****h* OpenSM/VL15
+* NAME
+* VL15
+*
+* DESCRIPTION
+* The VL15 object encapsulates the information needed by the
+* OpenSM to instantiate the VL15 interface. The OpenSM allocates
+* one VL15 object per subnet.
+*
+* The VL15 object transmits MADs to the wire at a throttled rate,
+* so as to not overload the VL15 buffering of subnet components.
+* OpenSM modules may post VL15 MADs to the VL15 interface as fast
+* as possible.
+*
+* The VL15 object is thread safe.
+*
+* This object should be treated as opaque and should
+* be manipulated only through the provided functions.
+*
+* AUTHOR
+* Steve King, Intel
+*
+*********/
+/****d* OpenSM: SM/osm_vl15_state_t
+* NAME
+* osm_vl15_state_t
+*
+* DESCRIPTION
+* Enumerates the possible states of SM object.
+*
+* SYNOPSIS
+*/
+typedef enum _osm_vl15_state {
+ OSM_VL15_STATE_INIT = 0,
+ OSM_VL15_STATE_READY
+} osm_vl15_state_t;
+/***********/
+
+/****s* OpenSM: VL15/osm_vl15_t
+* NAME
+* osm_vl15_t
+*
+* DESCRIPTION
+* VL15 structure.
+*
+* This object should be treated as opaque and should
+* be manipulated only through the provided functions.
+*
+* SYNOPSIS
+*/
+typedef struct osm_vl15 {
+ osm_thread_state_t thread_state;
+ osm_vl15_state_t state;
+ uint32_t max_wire_smps;
+ uint32_t max_wire_smps2;
+ uint32_t max_smps_timeout;
+ cl_event_t signal;
+ cl_thread_t poller;
+ cl_qlist_t rfifo;
+ cl_qlist_t ufifo;
+ cl_spinlock_t lock;
+ osm_vendor_t *p_vend;
+ osm_log_t *p_log;
+ osm_stats_t *p_stats;
+ osm_subn_t *p_subn;
+} osm_vl15_t;
+/*
+* FIELDS
+* thread_state
+* Tracks the thread state of the poller thread.
+*
+* state
+* Tracks the state of the VL15 interface itself.
+*
+* max_wire_smps
+* Maximum number of VL15 MADs allowed on the wire at one time.
+*
+* max_wire_smps2
+* Maximum number of timeout based SMPs allowed to be outstanding.
+*
+* max_smps_timeout
+* Wait time in usec for timeout based SMPs.
+*
+* signal
+* Event on which the poller sleeps.
+*
+* rfifo
+* First-in First-out queue for outbound VL15 MADs for which
+* a response is expected, aka the "response fifo"
+*
+* ufifo
+* First-in First-out queue for outbound VL15 MADs for which
+* no response is expected, aka the "unicast fifo".
+*
+* poller
+* Worker thread pool that services the fifo to transmit VL15 MADs
+*
+* lock
+* Spinlock guarding the FIFO.
+*
+* p_vend
+* Pointer to the vendor transport object.
+*
+* p_log
+* Pointer to the log object.
+*
+* p_stats
+* Pointer to the OpenSM statistics block.
+*
+* p_subn
+* Pointer to the OpenSM subnet object.
+*
+* SEE ALSO
+* VL15 object
+*********/
+
+/****f* OpenSM: VL15/osm_vl15_construct
+* NAME
+* osm_vl15_construct
+*
+* DESCRIPTION
+* This function constructs an VL15 object.
+*
+* SYNOPSIS
+*/
+void osm_vl15_construct(IN osm_vl15_t * p_vl15);
+/*
+* PARAMETERS
+* p_vl15
+* [in] Pointer to a VL15 object to construct.
+*
+* RETURN VALUE
+* This function does not return a value.
+*
+* NOTES
+* Allows calling osm_vl15_destroy.
+*
+* Calling osm_vl15_construct is a prerequisite to calling any other
+* method except osm_vl15_init.
+*
+* SEE ALSO
+* VL15 object, osm_vl15_init, osm_vl15_destroy
+*********/
+
+/****f* OpenSM: VL15/osm_vl15_destroy
+* NAME
+* osm_vl15_destroy
+*
+* DESCRIPTION
+* The osm_vl15_destroy function destroys the object, releasing
+* all resources.
+*
+* SYNOPSIS
+*/
+void osm_vl15_destroy(IN osm_vl15_t * p_vl15, IN struct osm_mad_pool *p_pool);
+/*
+* PARAMETERS
+* p_vl15
+* [in] Pointer to a VL15 object to destroy.
+*
+* p_pool
+* [in] The pointer to the mad pool to return outstanding mads to
+*
+* RETURN VALUE
+* This function does not return a value.
+*
+* NOTES
+* Performs any necessary cleanup of the specified VL15 object.
+* Further operations should not be attempted on the destroyed object.
+* This function should only be called after a call to osm_vl15_construct or
+* osm_vl15_init.
+*
+* SEE ALSO
+* VL15 object, osm_vl15_construct, osm_vl15_init
+*********/
+
+/*
+ Initialization.
+ Rate specifies the minimum number of microseconds between transmissions
+ on VL15.
+*/
+/****f* OpenSM: VL15/osm_vl15_init
+* NAME
+* osm_vl15_init
+*
+* DESCRIPTION
+* The osm_vl15_init function initializes a VL15 object for use.
+*
+* SYNOPSIS
+*/
+ib_api_status_t osm_vl15_init(IN osm_vl15_t * p_vl15, IN osm_vendor_t * p_vend,
+ IN osm_log_t * p_log, IN osm_stats_t * p_stats,
+ IN osm_subn_t * p_subn,
+ IN int32_t max_wire_smps,
+ IN int32_t max_wire_smps2,
+ IN uint32_t max_smps_timeout);
+/*
+* PARAMETERS
+* p_vl15
+* [in] Pointer to an osm_vl15_t object to initialize.
+*
+* p_vend
+* [in] Pointer to the vendor transport object.
+*
+* p_log
+* [in] Pointer to the log object.
+*
+* p_stats
+* [in] Pointer to the OpenSM statistics block.
+*
+* p_subn
+* [in] Pointer to the OpenSM subnet object.
+*
+* max_wire_smps
+* [in] Maximum number of SMPs allowed on the wire at one time.
+*
+* max_wire_smps2
+* [in] Maximum number of timeout based SMPs allowed to be
+* outstanding.
+*
+* max_smps_timeout
+* [in] Wait time in usec for timeout based SMPs.
+*
+*
+* RETURN VALUES
+* IB_SUCCESS if the VL15 object was initialized successfully.
+*
+* NOTES
+* Allows calling other VL15 methods.
+*
+* SEE ALSO
+* VL15 object, osm_vl15_construct, osm_vl15_destroy
+*********/
+
+/****f* OpenSM: VL15/osm_vl15_post
+* NAME
+* osm_vl15_post
+*
+* DESCRIPTION
+* Posts a MAD to the VL15 interface for transmission.
+*
+* SYNOPSIS
+*/
+void osm_vl15_post(IN osm_vl15_t * p_vl15, IN osm_madw_t * p_madw);
+/*
+* PARAMETERS
+* p_vl15
+* [in] Pointer to an osm_vl15_t object.
+*
+* p_madw
+* [in] Pointer to a MAD wrapper structure containing the MAD.
+*
+* RETURN VALUES
+* This function does not return a value.
+*
+* NOTES
+* The osm_vl15_construct or osm_vl15_init must be called before using
+* this function.
+*
+* SEE ALSO
+* VL15 object, osm_vl15_construct, osm_vl15_init
+*********/
+
+/****f* OpenSM: VL15/osm_vl15_poll
+* NAME
+* osm_vl15_poll
+*
+* DESCRIPTION
+* Causes the VL15 Interface to consider sending another QP0 MAD.
+*
+* SYNOPSIS
+*/
+void osm_vl15_poll(IN osm_vl15_t * p_vl);
+/*
+* PARAMETERS
+* p_vl15
+* [in] Pointer to an osm_vl15_t object.
+*
+* RETURN VALUES
+* None.
+*
+* NOTES
+* This function signals the VL15 that it may be possible to send
+* a SMP. This function checks three criteria before sending a SMP:
+* 1) The VL15 worker is IDLE
+* 2) There are no QP0 SMPs currently outstanding
+* 3) There is something on the VL15 FIFO to send
+*
+* SEE ALSO
+* VL15 object, osm_vl15_construct, osm_vl15_init
+*********/
+
+/****f* OpenSM: VL15/osm_vl15_shutdown
+* NAME
+* osm_vl15_shutdown
+*
+* DESCRIPTION
+* Cleanup all outstanding MADs on both fifo's.
+* This is required to return all outstanding MAD resources.
+*
+* SYNOPSIS
+*/
+void osm_vl15_shutdown(IN osm_vl15_t * p_vl, IN osm_mad_pool_t * p_mad_pool);
+/*
+* PARAMETERS
+* p_vl15
+* [in] Pointer to an osm_vl15_t object.
+*
+* p_mad_pool
+* [in] The MAD pool owning the mads.
+*
+* RETURN VALUES
+* None.
+*
+* NOTES
+*
+* SEE ALSO
+* VL15 object, osm_vl15_construct, osm_vl15_init
+*********/
+
+END_C_DECLS
+#endif /* _OSM_VL15INTF_H_ */
diff --git a/contrib/ofed/opensm/include/opensm/st.h b/contrib/ofed/opensm/include/opensm/st.h
new file mode 100644
index 0000000..ad6c289
--- /dev/null
+++ b/contrib/ofed/opensm/include/opensm/st.h
@@ -0,0 +1,103 @@
+/*
+ * Copyright (c) 2004-2006 Voltaire, Inc. All rights reserved.
+ * Copyright (c) 2002-2006 Mellanox Technologies LTD. All rights reserved.
+ * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+/* @(#) st.h 5.1 89/12/14 */
+
+#ifndef ST_INCLUDED
+#define ST_INCLUDED
+
+#include <stdlib.h>
+#include <inttypes.h>
+
+#ifdef __cplusplus
+# define BEGIN_C_DECLS extern "C" {
+# define END_C_DECLS }
+#else /* !__cplusplus */
+# define BEGIN_C_DECLS
+# define END_C_DECLS
+#endif /* __cplusplus */
+
+BEGIN_C_DECLS
+#define st_ptr_t uintptr_t
+typedef st_ptr_t st_data_t;
+
+#define ST_DATA_T_DEFINED
+
+typedef struct st_table st_table;
+
+struct st_hash_type {
+ int (*compare) (void *, void *);
+ st_ptr_t(*hash) (void *);
+};
+
+struct st_table {
+ struct st_hash_type *type;
+ int num_bins;
+ int num_entries;
+ struct st_table_entry **bins;
+};
+
+#define st_is_member(table,key) st_lookup(table,key,(st_data_t *)0)
+
+enum st_retval { ST_CONTINUE, ST_STOP, ST_DELETE };
+
+st_table *st_init_table(struct st_hash_type *);
+st_table *st_init_table_with_size(struct st_hash_type *, size_t);
+st_table *st_init_numtable(void);
+st_table *st_init_numtable_with_size(size_t);
+st_table *st_init_strtable(void);
+st_table *st_init_strtable_with_size(size_t);
+int st_delete(st_table *, st_data_t *, st_data_t *);
+int st_delete_safe(st_table *, st_data_t *, st_data_t *, st_data_t);
+int st_insert(st_table *, st_data_t, st_data_t);
+int st_lookup(st_table *, st_data_t, st_data_t *);
+void st_foreach(st_table *,
+ int (*)(st_data_t key, st_data_t val, st_data_t arg),
+ st_data_t);
+void st_add_direct(st_table *, st_data_t, st_data_t);
+void st_free_table(st_table *);
+void st_cleanup_safe(st_table *, st_data_t);
+st_table *st_copy(st_table *);
+
+#define ST_NUMCMP ((int (*)()) 0)
+#define ST_NUMHASH ((int (*)()) -2)
+
+#define st_numcmp ST_NUMCMP
+#define st_numhash ST_NUMHASH
+
+/* int st_strhash(void); */
+
+END_C_DECLS
+#endif /* ST_INCLUDED */
diff --git a/contrib/ofed/management/opensm/include/vendor/osm_mtl_bind.h b/contrib/ofed/opensm/include/vendor/osm_mtl_bind.h
index 3994d59..3994d59 100644
--- a/contrib/ofed/management/opensm/include/vendor/osm_mtl_bind.h
+++ b/contrib/ofed/opensm/include/vendor/osm_mtl_bind.h
diff --git a/contrib/ofed/management/opensm/include/vendor/osm_pkt_randomizer.h b/contrib/ofed/opensm/include/vendor/osm_pkt_randomizer.h
index 5a8ef5f..5a8ef5f 100644
--- a/contrib/ofed/management/opensm/include/vendor/osm_pkt_randomizer.h
+++ b/contrib/ofed/opensm/include/vendor/osm_pkt_randomizer.h
diff --git a/contrib/ofed/management/opensm/include/vendor/osm_ts_useraccess.h b/contrib/ofed/opensm/include/vendor/osm_ts_useraccess.h
index d68c924..d68c924 100644
--- a/contrib/ofed/management/opensm/include/vendor/osm_ts_useraccess.h
+++ b/contrib/ofed/opensm/include/vendor/osm_ts_useraccess.h
diff --git a/contrib/ofed/management/opensm/include/vendor/osm_umadt.h b/contrib/ofed/opensm/include/vendor/osm_umadt.h
index 129627d..129627d 100644
--- a/contrib/ofed/management/opensm/include/vendor/osm_umadt.h
+++ b/contrib/ofed/opensm/include/vendor/osm_umadt.h
diff --git a/contrib/ofed/opensm/include/vendor/osm_vendor.h b/contrib/ofed/opensm/include/vendor/osm_vendor.h
new file mode 100644
index 0000000..31b8eb8
--- /dev/null
+++ b/contrib/ofed/opensm/include/vendor/osm_vendor.h
@@ -0,0 +1,71 @@
+/*
+ * Copyright (c) 2004-2008 Voltaire, Inc. All rights reserved.
+ * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved.
+ * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+/*
+ * Abstract:
+ * Include file used by OpenSM to pull in the correct vendor file.
+ */
+
+/*
+ this is the generic include file which includes
+ the proper vendor specific file
+*/
+#include <opensm/osm_config.h>
+
+#if defined( OSM_VENDOR_INTF_TEST )
+#include <vendor/osm_vendor_test.h>
+#elif defined( OSM_VENDOR_INTF_UMADT )
+#include <vendor/osm_vendor_umadt.h>
+#elif defined( OSM_VENDOR_INTF_MTL )
+/* HACK - I do not know how to prevent complib from loading kernel H files */
+#undef __init
+#include <vendor/osm_vendor_mlx.h>
+#elif defined( OSM_VENDOR_INTF_TS )
+#undef __init
+#include <vendor/osm_vendor_mlx.h>
+#elif defined( OSM_VENDOR_INTF_ANAFA )
+#undef __init
+#include <vendor/osm_vendor_mlx.h>
+#elif defined( OSM_VENDOR_INTF_SIM )
+#undef __init
+#include <vendor/osm_vendor_mlx.h>
+#elif defined( OSM_VENDOR_INTF_OPENIB )
+#include <vendor/osm_vendor_ibumad.h>
+#elif defined( OSM_VENDOR_INTF_AL )
+#include <vendor/osm_vendor_al.h>
+#else
+#error No MAD Interface selected!
+#error Choose an interface in osm_config.h
+#endif
diff --git a/contrib/ofed/management/opensm/include/vendor/osm_vendor_al.h b/contrib/ofed/opensm/include/vendor/osm_vendor_al.h
index e7371c9..e7371c9 100644
--- a/contrib/ofed/management/opensm/include/vendor/osm_vendor_al.h
+++ b/contrib/ofed/opensm/include/vendor/osm_vendor_al.h
diff --git a/contrib/ofed/opensm/include/vendor/osm_vendor_api.h b/contrib/ofed/opensm/include/vendor/osm_vendor_api.h
new file mode 100644
index 0000000..4973417
--- /dev/null
+++ b/contrib/ofed/opensm/include/vendor/osm_vendor_api.h
@@ -0,0 +1,487 @@
+/*
+ * Copyright (c) 2004, 2005 Voltaire, Inc. All rights reserved.
+ * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved.
+ * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+/*
+ * Abstract:
+ * Specification of the OpenSM transport API. This API is OpenSM's view
+ * of the Infiniband transport.
+ */
+
+#ifndef _OSM_VENDOR_API_H_
+#define _OSM_VENDOR_API_H_
+
+#include <opensm/osm_madw.h>
+#include <opensm/osm_mad_pool.h>
+#include <vendor/osm_vendor.h>
+
+#ifdef __cplusplus
+# define BEGIN_C_DECLS extern "C" {
+# define END_C_DECLS }
+#else /* !__cplusplus */
+# define BEGIN_C_DECLS
+# define END_C_DECLS
+#endif /* __cplusplus */
+
+BEGIN_C_DECLS
+/****s* OpenSM Vendor API/osm_vend_mad_recv_callback_t
+* NAME
+* osm_vend_mad_recv_callback_t
+*
+* DESCRIPTION
+* Function prototype for the vendor MAD receive callback.
+* The vendor layer calls this function for MAD receives.
+*
+* SYNOPSIS
+*/
+typedef void (*osm_vend_mad_recv_callback_t) (IN osm_madw_t * p_madw,
+ IN void *bind_context,
+ IN osm_madw_t * p_req_madw);
+/*
+* PARAMETERS
+* p_madw
+* [in] The received MAD wrapper.
+*
+* bind_context
+* [in] User context supplied during the bind call.
+*
+* p_req_madw
+* [in] Pointer to the request mad wrapper that generated this response.
+* If the inbound MAD is not a response, this field is NULL.
+*
+* RETURN VALUES
+* None.
+*
+* NOTES
+*
+* SEE ALSO
+*********/
+
+/****s* OpenSM Vendor API/osm_vend_mad_send_err_callback_t
+* NAME
+* osm_vend_mad_send_err_callback_t
+*
+* DESCRIPTION
+* Function prototype for the vendor send failure callback.
+* The vendor layer calls this function when MADs expecting
+* a response are completed in error, most likely due to a
+* timeout.
+*
+* SYNOPSIS
+*/
+typedef void (*osm_vend_mad_send_err_callback_t) (IN void *bind_context,
+ IN osm_madw_t * p_madw);
+/*
+* PARAMETERS
+* bind_context
+* [in] User context supplied during the bind call.
+*
+* p_madw
+* [in] Pointer to the request mad that failed.
+*
+* RETURN VALUES
+* None.
+*
+* NOTES
+* The vendor layer does not call this function (or any other)
+* for MADs that were not expecting a response.
+*
+* SEE ALSO
+*********/
+
+/****f* OpenSM Vendor API/osm_vendor_new
+* NAME
+* osm_vendor_new
+*
+* DESCRIPTION
+* Allocates and initializes a new osm_vendor_t object.
+* OpenSM calls this function before any other in the vendor API.
+* This object is passed as a parameter to all other vendor functions.
+*
+* SYNOPSIS
+*/
+osm_vendor_t *osm_vendor_new(IN osm_log_t * const p_log,
+ IN const uint32_t timeout);
+/*
+* PARAMETERS
+* p_log
+* [in] Pointer to the log object to use.
+*
+* timeout
+* [in] transaction timeout
+*
+* RETURN VALUES
+* Returns a pointer to the vendor object.
+*
+* NOTES
+*
+* SEE ALSO
+*********/
+
+/****s* OpenSM Vendor API/osm_vendor_delete
+* NAME
+* osm_vendor_delete
+*
+* DESCRIPTION
+* Dealocate the vendor object.
+*
+* SYNOPSIS
+*/
+void osm_vendor_delete(IN osm_vendor_t ** const pp_vend);
+/*
+* PARAMETERS
+* pp_vend
+* [in/out] pointer to pointer to vendor objcet to be deleted
+*
+* RETURN VALUES
+* None
+*
+* NOTES
+*
+* SEE ALSO
+*********/
+
+/****f* OpenSM Vendor API/osm_vendor_get_all_port_attr
+* NAME
+* osm_vendor_get_all_port_attr
+*
+* DESCRIPTION
+* Returns an array of available port attribute structures.
+*
+* SYNOPSIS
+*/
+ib_api_status_t
+osm_vendor_get_all_port_attr(IN osm_vendor_t * const p_vend,
+ IN ib_port_attr_t * const p_attr_array,
+ IN uint32_t * const p_num_ports);
+/*
+* PARAMETERS
+* p_vend
+* [in] Pointer to the vendor object to initialize.
+*
+* p_attr_array
+* [in/out] Pointer to pre-allocated array of port attributes.
+* If it is NULL - then the command only updates the p_num_ports,
+* and return IB_INSUFFICIENT_MEMORY.
+*
+* p_num_ports
+* [in/out] Pointer to a variable to hold the total number of ports
+* available on the local machine.
+*
+* RETURN VALUES
+* IB_SUCCESS on success.
+* IB_INSUFFICIENT_MEMORY if the attribute array was not large enough.
+* The number of attributes needed is returned in num_guids.
+*
+* NOTES
+*
+* SEE ALSO
+*********/
+
+/****f* OpenSM Vendor API/osm_vendor_init
+* NAME
+* osm_vendor_init
+*
+* DESCRIPTION
+* The osm_vendor_init function initializes the vendor transport layer.
+*
+* SYNOPSIS
+*/
+ib_api_status_t
+osm_vendor_init(IN osm_vendor_t * const p_vend, IN osm_log_t * const p_log,
+ IN const uint32_t timeout);
+/*
+* PARAMETERS
+* p_vend
+* [in] Pointer to the vendor object to initialize.
+*
+* p_log
+* [in] Pointer to OpenSM's log object. Vendor code may
+* use the log object to send messages to OpenSM's log.
+*
+* timeout
+* [in] Transaction timeout value in milliseconds.
+* A value of 0 disables timeouts.
+*
+* RETURN VALUE
+*
+* NOTES
+*
+* SEE ALSO
+*********/
+
+/****f* OpenSM Vendor API/osm_vendor_bind
+* NAME
+* osm_vendor_bind
+*
+* DESCRIPTION
+* The osm_vendor_bind function registers with the vendor transport layer
+* per Mad Class per PortGuid for mad transport capability.
+*
+* SYNOPSIS
+*/
+osm_bind_handle_t
+osm_vendor_bind(IN osm_vendor_t * const p_vend,
+ IN osm_bind_info_t * const p_bind_info,
+ IN osm_mad_pool_t * const p_mad_pool,
+ IN osm_vend_mad_recv_callback_t mad_recv_callback,
+ IN osm_vend_mad_send_err_callback_t send_err_callback,
+ IN void *context);
+/*
+* PARAMETERS
+* p_vend
+* [in] pointer to the vendor object
+*
+* p_osm_bind_info
+* [in] pointer to a struct defining the type of bind to perform.
+*
+* p_mad_pool
+* [in] pointer to a mad wrappers pool to be used for allocating
+* mad wrappers on send and receive.
+*
+* mad_recv_callback
+* [in] the callback function to be invoked on mad receive.
+*
+* send_err_callback
+* [in] the callback function to be invoked on mad transaction errors.
+*
+* context
+* [in] the context to be provided to the callbacks as bind_ctx.
+*
+* RETURN VALUE
+* On success, a valid bind handle.
+* OSM_BIND_INVALID_HANDLE otherwise.
+*
+* NOTES
+*
+* SEE ALSO
+*********/
+
+/****f* OpenSM Vendor API/osm_vendor_unbind
+* NAME
+* osm_vendor_unbind
+*
+* DESCRIPTION
+* Unbind the given bind handle (obtained by osm_vendor_bind).
+*
+* SYNOPSIS
+*/
+void osm_vendor_unbind(IN osm_bind_handle_t h_bind);
+/*
+* PARAMETERS
+* h_bind
+* [in] the bind handle to release.
+*
+* RETURN VALUE
+* NONE.
+*
+* NOTES
+*
+* SEE ALSO
+*********/
+
+/****f* OpenSM Vendor API/osm_vendor_get
+* NAME
+* osm_vendor_get
+*
+* DESCRIPTION
+* Obtain a mad wrapper holding actual mad buffer to be sent via
+* the transport.
+*
+* SYNOPSIS
+*/
+ib_mad_t *osm_vendor_get(IN osm_bind_handle_t h_bind,
+ IN const uint32_t mad_size,
+ IN osm_vend_wrap_t * const p_vend_wrap);
+/*
+* PARAMETERS
+* h_bind
+* [in] the bind handle obtained by calling osm_vendor_bind
+*
+* mad_size
+* [in] the actual mad size required
+*
+* p_vend_wrap
+* [out] the returned mad vendor wrapper
+*
+* RETURN VALUE
+* IB_SUCCESS on succesful completion.
+*
+* NOTES
+*
+* SEE ALSO
+*********/
+
+/****f* OpenSM Vendor API/osm_vendor_send
+* NAME
+* osm_vendor_send
+*
+* DESCRIPTION
+*
+* SYNOPSIS
+*/
+ib_api_status_t
+osm_vendor_send(IN osm_bind_handle_t h_bind,
+ IN osm_madw_t * const p_madw, IN boolean_t const resp_expected);
+/*
+* PARAMETERS
+* h_bind
+* [in] the bind handle obtained by calling osm_vendor_bind
+*
+* p_madw
+* [in] pointer to the Mad Wrapper structure for the MAD to be sent.
+*
+* resp_expected
+* [in] boolean value declaring the mad as a request (expecting a response).
+*
+* RETURN VALUE
+* IB_SUCCESS on succesful completion.
+*
+* NOTES
+* 1. Only mads that expect a response are tracked for transaction competion.
+* 2. A mad that does not expect a response is being put back immediately
+* after being sent.
+*
+* SEE ALSO
+*********/
+
+/****f* OpenSM Vendor API/osm_vendor_put
+* NAME
+* osm_vendor_put
+*
+* DESCRIPTION
+* Return a mad vendor wrapper to the mad pool. It also means that the
+* mad buffer is returned to the transport.
+*
+* SYNOPSIS
+*/
+void
+osm_vendor_put(IN osm_bind_handle_t h_bind,
+ IN osm_vend_wrap_t * const p_vend_wrap);
+/*
+* PARAMETERS
+* h_bind
+* [in] the bind handle obtained by calling osm_vendor_bind
+*
+* p_vend_wrap
+* [in] pointer to the mad vendor wrapper to put back into the pool.
+*
+* RETURN VALUE
+* None.
+*
+* NOTES
+*
+* SEE ALSO
+*********/
+
+/****i* OpenSM Vendor API/osm_vendor_local_lid_change
+* NAME
+* osm_vendor_local_lid_change
+*
+* DESCRIPTION
+* Notifies the vendor transport layer that the local address
+* has changed. This allows the vendor layer to perform housekeeping
+* functions such as address vector updates.
+*
+* SYNOPSIS
+*/
+ib_api_status_t osm_vendor_local_lid_change(IN osm_bind_handle_t h_bind);
+/*
+* PARAMETERS
+* h_bind
+* [in] the bind handle obtained by calling osm_vendor_bind
+*
+* RETURN VALUE
+*
+* NOTES
+*
+* SEE ALSO
+*********/
+
+/****f* OpenSM Vendor API/osm_vendor_set_sm
+* NAME
+* osm_vendor_set_sm
+*
+* DESCRIPTION
+* Modifies the port info for the bound port to set the "IS_SM" bit
+* according to the value given (TRUE or FALSE).
+*
+* SYNOPSIS
+*/
+void osm_vendor_set_sm(IN osm_bind_handle_t h_bind, IN boolean_t is_sm_val);
+/*
+* PARAMETERS
+* h_bind
+* [in] bind handle for this port.
+*
+* is_sm_val
+* [in] If TRUE - will set the is_sm to TRUE, if FALSE - will set the
+* the is_sm to FALSE.
+*
+* RETURN VALUE
+* None.
+*
+* NOTES
+*
+* SEE ALSO
+*********/
+
+/****f* OpenSM Vendor API/osm_vendor_set_debug
+* NAME
+* osm_vendor_set_debug
+*
+* DESCRIPTION
+* Modifies the vendor specific debug level.
+*
+* SYNOPSIS
+*/
+void osm_vendor_set_debug(IN osm_vendor_t * const p_vend, IN int32_t level);
+/*
+* PARAMETERS
+* p_vend
+* [in] vendor handle.
+*
+* level
+* [in] vendor specific debug level.
+*
+* RETURN VALUE
+* None.
+*
+* NOTES
+*
+* SEE ALSO
+*********/
+
+END_C_DECLS
+#endif /* _OSM_VENDOR_API_H_ */
diff --git a/contrib/ofed/opensm/include/vendor/osm_vendor_ibumad.h b/contrib/ofed/opensm/include/vendor/osm_vendor_ibumad.h
new file mode 100644
index 0000000..847ef8a
--- /dev/null
+++ b/contrib/ofed/opensm/include/vendor/osm_vendor_ibumad.h
@@ -0,0 +1,183 @@
+/*
+ * Copyright (c) 2004-2008 Voltaire, Inc. All rights reserved.
+ * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved.
+ * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+#ifndef _OSM_VENDOR_UMAD_H_
+#define _OSM_VENDOR_UMAD_H_
+
+#include <iba/ib_types.h>
+#include <complib/cl_qlist.h>
+#include <opensm/osm_base.h>
+#include <opensm/osm_log.h>
+
+#include <infiniband/umad.h>
+
+#ifdef __cplusplus
+# define BEGIN_C_DECLS extern "C" {
+# define END_C_DECLS }
+#else /* !__cplusplus */
+# define BEGIN_C_DECLS
+# define END_C_DECLS
+#endif /* __cplusplus */
+
+BEGIN_C_DECLS
+/****h* OpenSM/Vendor Access Layer (UMAD)
+* NAME
+* Vendor UMAD
+*
+* DESCRIPTION
+* This file is the vendor specific file for the UMAD Infiniband API.
+*
+* AUTHOR
+*
+*
+*********/
+#define OSM_DEFAULT_RETRY_COUNT 3
+#define OSM_UMAD_MAX_CAS UMAD_MAX_DEVICES
+#define OSM_UMAD_MAX_PORTS_PER_CA 2
+#define OSM_UMAD_MAX_AGENTS 32
+
+/****s* OpenSM: Vendor UMAD/osm_ca_info_t
+* NAME
+* osm_ca_info_t
+*
+* DESCRIPTION
+* Structure containing information about local Channel Adapters.
+*
+* SYNOPSIS
+*/
+typedef struct _osm_ca_info {
+ ib_net64_t guid;
+ size_t attr_size;
+ ib_ca_attr_t *p_attr;
+} osm_ca_info_t;
+/*
+* FIELDS
+* guid
+* Node GUID of the local CA.
+*
+* attr_size
+* Size of the CA attributes for this CA.
+*
+* p_attr
+* Pointer to dynamicly allocated CA Attribute structure.
+*
+* SEE ALSO
+*********/
+
+/****f* OpenSM: CA Info/osm_ca_info_get_num_ports
+* NAME
+* osm_ca_info_get_num_ports
+*
+* DESCRIPTION
+* Returns the number of ports owned by this CA.
+*
+* SYNOPSIS
+*/
+static inline uint8_t
+osm_ca_info_get_num_ports(IN const osm_ca_info_t * const p_ca_info)
+{
+ return (p_ca_info->p_attr->num_ports);
+}
+
+/*
+* PARAMETERS
+* p_ca_info
+* [in] Pointer to a CA Info object.
+*
+* RETURN VUMADUE
+* Returns the number of ports owned by this CA.
+*
+* NOTES
+*
+* SEE ALSO
+*********/
+
+/****s* OpenSM: Vendor UMAD/osm_bind_handle_t
+* NAME
+* osm_bind_handle_t
+*
+* DESCRIPTION
+* handle returned by the vendor transport bind call.
+*
+* SYNOPSIS
+*/
+typedef void *osm_bind_handle_t;
+/***********/
+
+typedef struct _umad_match {
+ ib_net64_t tid;
+ void *v;
+ uint32_t version;
+ uint8_t mgmt_class;
+} umad_match_t;
+
+#define DEFAULT_OSM_UMAD_MAX_PENDING 1000
+
+typedef struct vendor_match_tbl {
+ uint32_t last_version;
+ int max;
+ umad_match_t *tbl;
+} vendor_match_tbl_t;
+
+typedef struct _osm_vendor {
+ osm_log_t *p_log;
+ uint32_t ca_count;
+ osm_ca_info_t *p_ca_info;
+ uint32_t timeout;
+ int max_retries;
+ osm_bind_handle_t agents[OSM_UMAD_MAX_AGENTS];
+ char ca_names[OSM_UMAD_MAX_CAS][UMAD_CA_NAME_LEN];
+ vendor_match_tbl_t mtbl;
+ umad_port_t umad_port;
+ pthread_mutex_t cb_mutex;
+ pthread_mutex_t match_tbl_mutex;
+ int umad_port_id;
+ void *receiver;
+ int issmfd;
+ char issm_path[256];
+} osm_vendor_t;
+
+#define OSM_BIND_INVALID_HANDLE 0
+
+typedef struct _osm_vend_wrap {
+ int agent;
+ int size;
+ int retries;
+ void *umad;
+ osm_bind_handle_t h_bind;
+} osm_vend_wrap_t;
+
+END_C_DECLS
+#endif /* _OSM_VENDOR_UMAD_H_ */
diff --git a/contrib/ofed/opensm/include/vendor/osm_vendor_mlx.h b/contrib/ofed/opensm/include/vendor/osm_vendor_mlx.h
new file mode 100644
index 0000000..bc0847b
--- /dev/null
+++ b/contrib/ofed/opensm/include/vendor/osm_vendor_mlx.h
@@ -0,0 +1,99 @@
+/*
+ * Copyright (c) 2004, 2005 Voltaire, Inc. All rights reserved.
+ * Copyright (c) 2002-2007,2009 Mellanox Technologies LTD. All rights reserved.
+ * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+#ifndef _OSMV_H_
+#define _OSMV_H_
+
+#include <sys/types.h>
+#include <opensm/osm_log.h>
+#include <complib/cl_qlist.h>
+
+#ifdef __cplusplus
+# define BEGIN_C_DECLS extern "C" {
+# define END_C_DECLS }
+#else /* !__cplusplus */
+# define BEGIN_C_DECLS
+# define END_C_DECLS
+#endif /* __cplusplus */
+
+BEGIN_C_DECLS
+/*
+ Forward reference
+*/
+struct _osm_pkt_randomizer;
+
+/* The structure behind the OSM Vendor handle */
+
+typedef struct _osm_vendor {
+
+ /* for holding common transport info - useful at ibmgt transport */
+ void *p_transport_info;
+
+ osm_log_t *p_log;
+
+ /* Uniform timeout for every ACK/single MAD */
+ uint32_t resp_timeout;
+
+ /* Uniform timeout for every rmpp transaction */
+ uint32_t ttime_timeout;
+
+ /* All the bind handles associated with the vendor */
+ cl_qlist_t bind_handles;
+
+ /* run randomizer flag */
+ boolean_t run_randomizer;
+
+ /* Packet Randomizer object */
+ struct _osm_pkt_randomizer *p_pkt_randomizer;
+
+} osm_vendor_t;
+
+/* Repeating the definitions in osm_vendor_api.h */
+
+typedef void *osm_bind_handle_t;
+
+typedef struct _osm_vend_wrap {
+ ib_mad_t *p_mad;
+} osm_vend_wrap_t;
+
+#ifndef OSM_BIND_INVALID_HANDLE
+#define OSM_BIND_INVALID_HANDLE NULL
+#endif
+
+/* The maximum number of retransmissions of the same MAD */
+#define OSM_DEFAULT_RETRY_COUNT 3
+
+END_C_DECLS
+#endif
diff --git a/contrib/ofed/opensm/include/vendor/osm_vendor_mlx_defs.h b/contrib/ofed/opensm/include/vendor/osm_vendor_mlx_defs.h
new file mode 100644
index 0000000..c4ee053
--- /dev/null
+++ b/contrib/ofed/opensm/include/vendor/osm_vendor_mlx_defs.h
@@ -0,0 +1,101 @@
+/*
+ * Copyright (c) 2004, 2005 Voltaire, Inc. All rights reserved.
+ * Copyright (c) 2002-2005,2009 Mellanox Technologies LTD. All rights reserved.
+ * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+#ifndef _OSMV_DEFS_H_
+#define _OSMV_DEFS_H_
+
+#include <vendor/osm_vendor_mlx_inout.h>
+#include <opensm/osm_log.h>
+#include <vendor/osm_vendor_api.h>
+#include <vendor/osm_vendor_mlx_txn.h>
+
+#ifdef __cplusplus
+# define BEGIN_C_DECLS extern "C" {
+# define END_C_DECLS }
+#else /* !__cplusplus */
+# define BEGIN_C_DECLS
+# define END_C_DECLS
+#endif /* __cplusplus */
+
+BEGIN_C_DECLS
+/* The maximum number of outstanding MADs an RMPP sender can transmit */
+#define OSMV_RMPP_RECV_WIN 16
+/* Transaction Timeout = OSMV_TXN_TIMEOUT_FACTOR * Response Timeout */
+#define OSMV_TXN_TIMEOUT_FACTOR 128
+/************/
+/****s* OSM Vendor: Types/osmv_bind_obj_t
+* NAME
+* osmv_bind_obj_t
+*
+* DESCRIPTION
+* The object managing a single bind context.
+* The bind handle is a direct pointer to it.
+*
+* SYNOPSIS
+*/
+typedef struct _osmv_bind_obj {
+ /* Used to signal when the struct is being destroyed */
+ struct _osmv_bind_obj *magic_ptr;
+
+ osm_vendor_t /*const */ * p_vendor;
+
+ uint32_t hca_hndl;
+ uint32_t port_num;
+
+ /* Atomic access protector */
+ cl_spinlock_t lock;
+
+ /* is_closing == TRUE --> the handle is being unbound */
+ boolean_t is_closing;
+
+ /* Event callbacks */
+ osm_vend_mad_recv_callback_t recv_cb;
+ osm_vend_mad_send_err_callback_t send_err_cb;
+ /* ... and their context */
+ void *cb_context;
+
+ /* A pool to manage MAD wrappers */
+ osm_mad_pool_t *p_osm_pool;
+
+ /* each subvendor implements its own transport mgr */
+ void *p_transp_mgr;
+
+ /* The transaction DB */
+ osmv_txn_mgr_t txn_mgr;
+
+} osmv_bind_obj_t;
+
+END_C_DECLS
+#endif /* _OSMV_DEFS_H_ */
diff --git a/contrib/ofed/management/opensm/include/vendor/osm_vendor_mlx_dispatcher.h b/contrib/ofed/opensm/include/vendor/osm_vendor_mlx_dispatcher.h
index ba83f30..ba83f30 100644
--- a/contrib/ofed/management/opensm/include/vendor/osm_vendor_mlx_dispatcher.h
+++ b/contrib/ofed/opensm/include/vendor/osm_vendor_mlx_dispatcher.h
diff --git a/contrib/ofed/management/opensm/include/vendor/osm_vendor_mlx_hca.h b/contrib/ofed/opensm/include/vendor/osm_vendor_mlx_hca.h
index 9b56943..9b56943 100644
--- a/contrib/ofed/management/opensm/include/vendor/osm_vendor_mlx_hca.h
+++ b/contrib/ofed/opensm/include/vendor/osm_vendor_mlx_hca.h
diff --git a/contrib/ofed/management/opensm/include/vendor/osm_vendor_mlx_inout.h b/contrib/ofed/opensm/include/vendor/osm_vendor_mlx_inout.h
index 868639b..868639b 100644
--- a/contrib/ofed/management/opensm/include/vendor/osm_vendor_mlx_inout.h
+++ b/contrib/ofed/opensm/include/vendor/osm_vendor_mlx_inout.h
diff --git a/contrib/ofed/management/opensm/include/vendor/osm_vendor_mlx_rmpp_ctx.h b/contrib/ofed/opensm/include/vendor/osm_vendor_mlx_rmpp_ctx.h
index dac1f13..dac1f13 100644
--- a/contrib/ofed/management/opensm/include/vendor/osm_vendor_mlx_rmpp_ctx.h
+++ b/contrib/ofed/opensm/include/vendor/osm_vendor_mlx_rmpp_ctx.h
diff --git a/contrib/ofed/management/opensm/include/vendor/osm_vendor_mlx_sar.h b/contrib/ofed/opensm/include/vendor/osm_vendor_mlx_sar.h
index a65b4f2..a65b4f2 100644
--- a/contrib/ofed/management/opensm/include/vendor/osm_vendor_mlx_sar.h
+++ b/contrib/ofed/opensm/include/vendor/osm_vendor_mlx_sar.h
diff --git a/contrib/ofed/management/opensm/include/vendor/osm_vendor_mlx_sender.h b/contrib/ofed/opensm/include/vendor/osm_vendor_mlx_sender.h
index e849744..e849744 100644
--- a/contrib/ofed/management/opensm/include/vendor/osm_vendor_mlx_sender.h
+++ b/contrib/ofed/opensm/include/vendor/osm_vendor_mlx_sender.h
diff --git a/contrib/ofed/opensm/include/vendor/osm_vendor_mlx_svc.h b/contrib/ofed/opensm/include/vendor/osm_vendor_mlx_svc.h
new file mode 100644
index 0000000..43a83e3
--- /dev/null
+++ b/contrib/ofed/opensm/include/vendor/osm_vendor_mlx_svc.h
@@ -0,0 +1,195 @@
+/*
+ * Copyright (c) 2004, 2005 Voltaire, Inc. All rights reserved.
+ * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved.
+ * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+#ifndef _OSMV_SVC_H_
+#define _OSMV_SVC_H_
+
+#include <stdlib.h>
+#include <string.h>
+#include <iba/ib_types.h>
+#include <vendor/osm_vendor_mlx_defs.h>
+
+#ifdef __cplusplus
+# define BEGIN_C_DECLS extern "C" {
+# define END_C_DECLS }
+#else /* !__cplusplus */
+# define BEGIN_C_DECLS
+# define END_C_DECLS
+#endif /* __cplusplus */
+
+BEGIN_C_DECLS
+inline static uint8_t osmv_invert_method(IN uint8_t req_method)
+{
+ switch (req_method) {
+ case IB_MAD_METHOD_GET_RESP:
+ /* Not a 1-1 mapping! */
+ return IB_MAD_METHOD_GET;
+
+ case IB_MAD_METHOD_GET:
+ return IB_MAD_METHOD_GET_RESP;
+
+ case IB_MAD_METHOD_SET:
+ return IB_MAD_METHOD_GET_RESP;
+
+ case IB_MAD_METHOD_GETTABLE_RESP:
+ return IB_MAD_METHOD_GETTABLE;
+
+ case IB_MAD_METHOD_GETTABLE:
+ return IB_MAD_METHOD_GETTABLE_RESP;
+
+ case IB_MAD_METHOD_GETMULTI_RESP:
+ /* Not a 1-1 mapping! */
+ return IB_MAD_METHOD_GETMULTI;
+
+ case IB_MAD_METHOD_GETTRACETABLE:
+ case IB_MAD_METHOD_GETMULTI:
+ return IB_MAD_METHOD_GETMULTI_RESP;
+
+ case IB_MAD_METHOD_TRAP:
+ return IB_MAD_METHOD_TRAP_REPRESS;
+
+ case IB_MAD_METHOD_TRAP_REPRESS:
+ return IB_MAD_METHOD_TRAP;
+
+ case IB_MAD_METHOD_REPORT:
+ return IB_MAD_METHOD_REPORT_RESP;
+
+ case IB_MAD_METHOD_REPORT_RESP:
+ return IB_MAD_METHOD_REPORT;
+
+ /* IB_MAD_METHOD_SEND does not have a response */
+ case IB_MAD_METHOD_SEND:
+ return IB_MAD_METHOD_SEND;
+
+ default:
+ CL_ASSERT(FALSE);
+ }
+
+ return 0; /* Just make the compiler happy */
+}
+
+inline static boolean_t osmv_mad_is_rmpp(IN const ib_mad_t * p_mad)
+{
+ uint8_t rmpp_flags;
+ CL_ASSERT(NULL != p_mad);
+
+ rmpp_flags = ((ib_rmpp_mad_t *) p_mad)->rmpp_flags;
+ /* HACK - JUST SA and DevMgt for now - need to add BIS and DevAdm */
+ if ((p_mad->mgmt_class != IB_MCLASS_SUBN_ADM) &&
+ (p_mad->mgmt_class != IB_MCLASS_DEV_MGMT))
+ return (0);
+ return (0 != (rmpp_flags & IB_RMPP_FLAG_ACTIVE));
+}
+
+inline static boolean_t osmv_mad_is_multi_resp(IN const ib_mad_t * p_mad)
+{
+ CL_ASSERT(NULL != p_mad);
+ return (IB_MAD_METHOD_GETMULTI == p_mad->method
+ || IB_MAD_METHOD_GETTRACETABLE == p_mad->method);
+}
+
+inline static boolean_t osmv_mad_is_sa(IN const ib_mad_t * p_mad)
+{
+ CL_ASSERT(NULL != p_mad);
+ return (IB_MCLASS_SUBN_ADM == p_mad->mgmt_class);
+}
+
+inline static boolean_t osmv_rmpp_is_abort_stop(IN const ib_mad_t * p_mad)
+{
+ uint8_t rmpp_type;
+ CL_ASSERT(p_mad);
+
+ rmpp_type = ((ib_rmpp_mad_t *) p_mad)->rmpp_type;
+ return (IB_RMPP_TYPE_STOP == rmpp_type
+ || IB_RMPP_TYPE_ABORT == rmpp_type);
+}
+
+inline static boolean_t osmv_rmpp_is_data(IN const ib_mad_t * p_mad)
+{
+ CL_ASSERT(p_mad);
+ return (IB_RMPP_TYPE_DATA == ((ib_rmpp_mad_t *) p_mad)->rmpp_type);
+}
+
+inline static boolean_t osmv_rmpp_is_ack(IN const ib_mad_t * p_mad)
+{
+ CL_ASSERT(p_mad);
+ return (IB_RMPP_TYPE_ACK == ((ib_rmpp_mad_t *) p_mad)->rmpp_type);
+}
+
+inline static boolean_t osmv_rmpp_is_first(IN const ib_mad_t * p_mad)
+{
+ uint8_t rmpp_flags;
+ CL_ASSERT(NULL != p_mad);
+
+ rmpp_flags = ((ib_rmpp_mad_t *) p_mad)->rmpp_flags;
+ return (0 != (IB_RMPP_FLAG_FIRST & rmpp_flags));
+}
+
+inline static boolean_t osmv_rmpp_is_last(IN const ib_mad_t * p_mad)
+{
+ uint8_t rmpp_flags;
+ CL_ASSERT(NULL != p_mad);
+
+ rmpp_flags = ((ib_rmpp_mad_t *) p_mad)->rmpp_flags;
+ return (0 != (IB_RMPP_FLAG_LAST & rmpp_flags));
+}
+
+inline static uint8_t *osmv_mad_copy(IN const ib_mad_t * p_mad)
+{
+ uint8_t *p_copy;
+
+ CL_ASSERT(p_mad);
+ p_copy = malloc(MAD_BLOCK_SIZE);
+
+ if (NULL != p_copy) {
+ memset(p_copy, 0, MAD_BLOCK_SIZE);
+ memcpy(p_copy, p_mad, MAD_BLOCK_SIZE);
+ }
+
+ return p_copy;
+}
+
+/* Should be passed externally from the Makefile */
+/* #define OSMV_RANDOM_DROP 1 */
+#define OSMV_DROP_RATE 0.3
+
+inline static boolean_t osmv_random_drop(void)
+{
+ srand(1); /* Pick a new base */
+ return (rand() / (double)RAND_MAX < OSMV_DROP_RATE);
+}
+
+END_C_DECLS
+#endif /* _OSMV_SVC_H_ */
diff --git a/contrib/ofed/management/opensm/include/vendor/osm_vendor_mlx_transport.h b/contrib/ofed/opensm/include/vendor/osm_vendor_mlx_transport.h
index 2840e49..2840e49 100644
--- a/contrib/ofed/management/opensm/include/vendor/osm_vendor_mlx_transport.h
+++ b/contrib/ofed/opensm/include/vendor/osm_vendor_mlx_transport.h
diff --git a/contrib/ofed/management/opensm/include/vendor/osm_vendor_mlx_transport_anafa.h b/contrib/ofed/opensm/include/vendor/osm_vendor_mlx_transport_anafa.h
index dac26ed..dac26ed 100644
--- a/contrib/ofed/management/opensm/include/vendor/osm_vendor_mlx_transport_anafa.h
+++ b/contrib/ofed/opensm/include/vendor/osm_vendor_mlx_transport_anafa.h
diff --git a/contrib/ofed/management/opensm/include/vendor/osm_vendor_mlx_txn.h b/contrib/ofed/opensm/include/vendor/osm_vendor_mlx_txn.h
index ce59191..ce59191 100644
--- a/contrib/ofed/management/opensm/include/vendor/osm_vendor_mlx_txn.h
+++ b/contrib/ofed/opensm/include/vendor/osm_vendor_mlx_txn.h
diff --git a/contrib/ofed/management/opensm/include/vendor/osm_vendor_mtl.h b/contrib/ofed/opensm/include/vendor/osm_vendor_mtl.h
index df48260..df48260 100644
--- a/contrib/ofed/management/opensm/include/vendor/osm_vendor_mtl.h
+++ b/contrib/ofed/opensm/include/vendor/osm_vendor_mtl.h
diff --git a/contrib/ofed/management/opensm/include/vendor/osm_vendor_mtl_hca_guid.h b/contrib/ofed/opensm/include/vendor/osm_vendor_mtl_hca_guid.h
index 1b3da88..1b3da88 100644
--- a/contrib/ofed/management/opensm/include/vendor/osm_vendor_mtl_hca_guid.h
+++ b/contrib/ofed/opensm/include/vendor/osm_vendor_mtl_hca_guid.h
diff --git a/contrib/ofed/management/opensm/include/vendor/osm_vendor_mtl_transaction_mgr.h b/contrib/ofed/opensm/include/vendor/osm_vendor_mtl_transaction_mgr.h
index 6ec5b86..6ec5b86 100644
--- a/contrib/ofed/management/opensm/include/vendor/osm_vendor_mtl_transaction_mgr.h
+++ b/contrib/ofed/opensm/include/vendor/osm_vendor_mtl_transaction_mgr.h
diff --git a/contrib/ofed/opensm/include/vendor/osm_vendor_sa_api.h b/contrib/ofed/opensm/include/vendor/osm_vendor_sa_api.h
new file mode 100644
index 0000000..d5f9376
--- /dev/null
+++ b/contrib/ofed/opensm/include/vendor/osm_vendor_sa_api.h
@@ -0,0 +1,874 @@
+/*
+ * Copyright (c) 2004-2006 Voltaire, Inc. All rights reserved.
+ * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved.
+ * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+/*
+ * Abstract:
+ * Specification of the OpenSM SA Client API. This API uses the basic osm
+ * vendor API to provide SA Client interface.
+ */
+
+#ifndef _OSM_VENDOR_SA_API_H_
+#define _OSM_VENDOR_SA_API_H_
+
+#include <iba/ib_types.h>
+
+#ifdef __cplusplus
+# define BEGIN_C_DECLS extern "C" {
+# define END_C_DECLS }
+#else /* !__cplusplus */
+# define BEGIN_C_DECLS
+# define END_C_DECLS
+#endif /* __cplusplus */
+
+BEGIN_C_DECLS
+/****d* OpenSM Vendor SA Client/osmv_flags_t
+* NAME
+* osmv_flags_t
+*
+* DESCRIPTION
+* Access layer flags used to direct the operation of various calls.
+*
+* SYNOPSIS
+*/
+typedef uint32_t osmv_flags_t;
+#define OSM_SA_FLAGS_SYNC 0x00000001
+/*
+* VALUES
+* OSM_SA_FLAGS_SYNC
+* Indicates that the given operation should be performed synchronously.
+* The call will block until it completes. Callbacks will still be
+* invoked.
+*
+* SEE ALSO
+* osmv_query_sa
+*****/
+
+/****d* OpenSM Vendor SA Client/osmv_query_type_t
+* NAME
+* osmv_query_type_t
+*
+* DESCRIPTION
+* Abstracted queries supported by the access layer.
+*
+* SYNOPSIS
+*/
+typedef enum _osmv_query_type {
+ OSMV_QUERY_USER_DEFINED,
+
+ OSMV_QUERY_ALL_SVC_RECS,
+ OSMV_QUERY_SVC_REC_BY_NAME,
+ OSMV_QUERY_SVC_REC_BY_ID,
+
+ OSMV_QUERY_CLASS_PORT_INFO,
+
+ OSMV_QUERY_NODE_REC_BY_NODE_GUID,
+ OSMV_QUERY_PORT_REC_BY_LID,
+ OSMV_QUERY_PORT_REC_BY_LID_AND_NUM,
+
+ OSMV_QUERY_VLARB_BY_LID_PORT_BLOCK,
+ OSMV_QUERY_SLVL_BY_LID_AND_PORTS,
+
+ OSMV_QUERY_PATH_REC_BY_PORT_GUIDS,
+ OSMV_QUERY_PATH_REC_BY_GIDS,
+ OSMV_QUERY_PATH_REC_BY_LIDS,
+
+ OSMV_QUERY_UD_MULTICAST_SET,
+ OSMV_QUERY_UD_MULTICAST_DELETE,
+
+ OSMV_QUERY_MULTIPATH_REC,
+
+} osmv_query_type_t;
+/*
+* VALUES
+* OSMV_QUERY_USER_DEFINED
+* Query the SA based on user-defined input. Queries of this type
+* should reference an osmv_user_query_t structure as input to the
+* query.
+*
+* OSMV_QUERY_SVC_REC_BY_NAME
+* Query for service records based on the service name. Queries of
+* this type should reference an ib_svc_name_t structure as input
+* to the query.
+*
+* OSMV_QUERY_SVC_REC_BY_ID
+* Query for service records based on the service ID. Queries of
+* this type should reference an ib_net64_t value that indicates
+* the ID of the service being requested.
+*
+* OSMV_QUERY_NODE_REC_BY_NODE_GUID
+* Query for node information based on the node's GUID. Queries of
+* this type should reference an ib_net64_t value that indicates
+* the GUID of the node being requested.
+*
+* OSMV_QUERY_PORT_REC_BY_LID
+* Query for port information based on the port's base LID. Queries
+* of this type should reference an ib_net16_t value that indicates
+* the base LID of the port being requested.
+*
+* OSMV_QUERY_PORT_REC_BY_LID_AND_NUM
+* Query for port information based on the port's LID and port num.
+* Queries of this type should reference an osmv_user_query_t
+* structure as input to the query. The port num and lid should
+* be provided by it.
+*
+* OSMV_QUERY_PATH_REC_BY_PORT_GUIDS
+* Query for path records between the specified pair of port GUIDs.
+* Queries of this type should reference an osmv_guid_pair_t
+* structure that indicates the GUIDs of the path being requested.
+*
+* OSMV_QUERY_PATH_REC_BY_GIDS
+* Query for path records between the specified pair of port GIDs.
+* Queries of this type should reference an osmv_gid_pair_t
+* structure that indicates the GIDs of the path being requested.
+*
+* OSMV_QUERY_PATH_REC_BY_LIDS
+* Query for path records between the specified pair of port LIDs.
+* Queries of this type should reference an osmv_lid_pair_t
+* structure that indicates the LIDs of the path being requested.
+*
+* NOTES
+* This enum is used to define abstracted queries provided by the access
+* layer. Users may issue queries not listed here by sending MADs directly
+* to subnet administration or a class manager. These queries are
+* intended to represent those most often used by clients.
+*
+* SEE ALSO
+* osmv_query, osmv_query_req_t, osmv_user_query_t, osmv_gid_pair_t,
+* osmv_lid_pair_t osmv_guid_pair_t
+*****/
+
+/****s* OpenSM Vendor SA Client/osmv_user_query_t
+* NAME
+* osmv_user_query_t
+*
+* DESCRIPTION
+* User-defined query information.
+*
+* SYNOPSIS
+*/
+typedef struct _osmv_user_query {
+ uint8_t method;
+ ib_net16_t attr_id;
+ ib_net16_t attr_offset;
+ ib_net32_t attr_mod;
+ ib_net64_t comp_mask;
+ void *p_attr;
+} osmv_user_query_t;
+/*
+* FIELDS
+*
+* method
+* Method to be used
+*
+* attr_id
+* Attribute identifier of query data.
+*
+* attr_offset
+* Size of the query attribute, in 8-byte words. Users can set
+* this value by passing in the sizeof( attribute ) into the
+* ib_get_attr_offset() routine.
+*
+* attr_mod
+* Attribute modifier for query request.
+*
+* comp_mask
+* Indicates the attribute components that are specified for the
+* query.
+*
+* p_attr
+* References the attribute structure used as input into the query.
+* This field is ignored if comp_mask is set to 0.
+*
+* NOTES
+* This structure is used to describe a user-defined query. The attribute
+* ID, attribute offset, component mask, and attribute structure must match
+* those defined by the IBA specification. Users should refer to chapter
+* 15 of the IBA specification for additional details.
+*
+* SEE ALSO
+* osmv_query_type_t, ib_get_attr_offset, ib_get_attr_size, osmv_query_sa
+*****/
+
+/****s* OpenSM Vendor SA Client/osmv_gid_pair_t
+* NAME
+* osmv_gid_pair_t
+*
+* DESCRIPTION
+* Source and destination GIDs.
+*
+* SYNOPSIS
+*/
+typedef struct _osmv_gid_pair {
+ ib_gid_t src_gid;
+ ib_gid_t dest_gid;
+} osmv_gid_pair_t;
+/*
+* FIELDS
+* src_gid
+* Source GID of a path.
+*
+* dest_gid
+* Destination GID of a path.
+*
+* NOTES
+* This structure is used to describe the endpoints of a path.
+*
+* SEE ALSO
+* ib_gid_t
+*****/
+
+/****s* OpenSM Vendor SA Client/osmv_lid_pair_t
+* NAME
+* osmv_lid_pair_t
+*
+* DESCRIPTION
+* Source and destination LIDs.
+*
+* SYNOPSIS
+*/
+typedef struct _osmv_lid_pair {
+ ib_net16_t src_lid;
+ ib_net16_t dest_lid;
+} osmv_lid_pair_t;
+/*
+* FIELDS
+* src_lid
+* Source LID of a path.
+*
+* dest_lid
+* Destination LID of a path.
+*
+* NOTES
+* This structure is used to describe the endpoints of a path.
+*****/
+
+/****s* OpenSM Vendor SA Client/osmv_guid_pair_t
+* NAME
+* osmv_guid_pair_t
+*
+* DESCRIPTION
+* Source and destination GUIDs. These may be port or channel adapter
+* GUIDs, depending on the context in which this structure is used.
+*
+* SYNOPSIS
+*/
+typedef struct _osmv_guid_pair {
+ ib_net64_t src_guid;
+ ib_net64_t dest_guid;
+} osmv_guid_pair_t;
+/*
+* FIELDS
+* src_guid
+* Source GUID of a path.
+*
+* dest_guid
+* Destination GUID of a path.
+*
+* NOTES
+* This structure is used to describe the endpoints of a path. The given
+* GUID pair may belong to either ports or channel adapters.
+*
+* SEE ALSO
+* ib_guid_t
+*****/
+
+/****s* OpenSM Vendor SA Client/osmv_multipath_req_t
+* NAME
+* osmv_multipath_req_t
+*
+* DESCRIPTION
+* Fields from which to generate a MultiPathRecord request.
+*
+* SYNOPSIS
+*/
+typedef struct _osmv_multipath_req_t {
+ ib_net64_t comp_mask;
+ uint16_t pkey;
+ boolean_t reversible;
+ uint8_t num_path;
+ uint8_t sl;
+ uint8_t independence;
+ uint8_t sgid_count;
+ uint8_t dgid_count;
+ ib_gid_t gids[IB_MULTIPATH_MAX_GIDS];
+} osmv_multipath_req_t;
+/*
+* FIELDS
+*
+* NOTES
+* This structure is used to describe a multipath request.
+*
+* SEE ALSO
+*****/
+
+/****s* OpenSM Vendor SA Client/osmv_query_res_t
+* NAME
+* osmv_query_res_t
+*
+* DESCRIPTION
+* Contains the results of a subnet administration query.
+*
+* SYNOPSIS
+*/
+typedef struct _osmv_query_res {
+ const void *query_context;
+ ib_api_status_t status;
+ osmv_query_type_t query_type;
+ uint32_t result_cnt;
+ osm_madw_t *p_result_madw;
+} osmv_query_res_t;
+/*
+* FIELDS
+* query_context
+* User-defined context information associated with the query
+* through the osm_vendor_query_sa call.
+*
+* status
+* Indicates the success of the query operation.
+*
+* query_type
+* Indicates the type of query for which the results are being
+* returned. This matches the query_type specified through the
+* osm_vendor_query_sa call.
+*
+* result_cnt
+* The number of result structures that were returned by the query.
+*
+* p_result_madw
+* For queries returning IB_SUCCESS or IB_REMOTE_ERROR, this
+* references the MAD wrapper returned by subnet administration
+* containing the list of results or the returned error code.
+*
+* NOTES
+* A query result structure is returned to a client through their
+* osmv_pfn_query_cb_t routine to notify them of the results of a subnet
+* administration query. If the query was successful or received an error
+* from subnet administration, p_result_madw will reference a MAD wrapper
+* containing the results. The MAD referenced by p_result_madw is owned by
+* the user and remains available even after their callback returns. Users
+* must call osm_mad_pool_put() to return the MAD wrapper back to the
+* mad pool when they are done accessing the results.
+*
+* To retrieve individual result structures from the p_result_madw, users
+* may call osmv_get_query_result().
+*
+* SEE ALSO
+* osmv_query_sa, osmv_pfn_query_cb_t, ib_api_status_t,
+* osmv_query_status_t, osmv_query_type_t,
+* osmv_get_query_result
+*****/
+
+/****f* OpenSM Vendor SA Client/osmv_get_query_result
+* NAME
+* osmv_get_query_result
+*
+* DESCRIPTION
+* Retrieves a result structure from a MADW returned by a call to
+* osmv_query_sa().
+*
+* SYNOPSIS
+*/
+static inline void *osmv_get_query_result(IN osm_madw_t * p_result_madw,
+ IN uint32_t result_index)
+{
+ ib_sa_mad_t *p_sa_mad;
+
+ CL_ASSERT(p_result_madw);
+ p_sa_mad = (ib_sa_mad_t *) osm_madw_get_mad_ptr(p_result_madw);
+ CL_ASSERT(p_sa_mad);
+ CL_ASSERT(ib_get_attr_size(p_sa_mad->attr_offset) * (result_index + 1) +
+ IB_SA_MAD_HDR_SIZE <= p_result_madw->mad_size);
+
+ return (p_sa_mad->data +
+ (ib_get_attr_size(p_sa_mad->attr_offset) * result_index));
+}
+
+/*
+* PARAMETERS
+* p_result_madw
+* [in] This is a reference to the MAD returned as a result of the
+* query.
+*
+* result_index
+* [in] A zero-based index indicating which result to return.
+*
+* NOTES
+* This call returns a pointer to the start of a result structure from a
+* call to osmv_query_sa(). The type of result structure must be known to
+* the user either through the user's context or the query_type returned as
+* part of the osmv_query_res_t structure.
+*
+* SEE ALSO
+* osmv_query_res_t, osm_madw_t
+*****/
+
+/****f* OpenSM Vendor SA Client/osmv_get_query_path_rec
+* NAME
+* osmv_get_query_path_rec
+*
+* DESCRIPTION
+* Retrieves a path record result from a MAD returned by a call to
+* osmv_query_sa().
+*
+* SYNOPSIS
+*/
+static inline ib_path_rec_t *osmv_get_query_path_rec(IN osm_madw_t *
+ p_result_madw,
+ IN uint32_t result_index)
+{
+ ib_sa_mad_t __attribute__((__unused__)) *p_sa_mad;
+
+ CL_ASSERT(p_result_madw);
+ p_sa_mad = (ib_sa_mad_t *) osm_madw_get_mad_ptr(p_result_madw);
+ CL_ASSERT(p_sa_mad && p_sa_mad->attr_id == IB_MAD_ATTR_PATH_RECORD);
+
+ return ((ib_path_rec_t *)
+ osmv_get_query_result(p_result_madw, result_index));
+}
+
+/*
+* PARAMETERS
+* p_result_madw
+* [in] This is a reference to the MAD returned as a result of the
+* query.
+*
+* result_index
+* [in] A zero-based index indicating which result to return.
+*
+* NOTES
+* This call returns a pointer to the start of a path record result from
+* a call to osmv_query_sa().
+*
+* SEE ALSO
+* osmv_query_res_t, osm_madw_t, osmv_get_query_result, ib_path_rec_t
+*****/
+
+/****f* OpenSM Vendor SA Client/osmv_get_query_portinfo_rec
+* NAME
+* osmv_get_query_portinfo_rec
+*
+* DESCRIPTION
+* Retrieves a port info record result from a MAD returned by a call to
+* osmv_query_sa().
+*
+* SYNOPSIS
+*/
+static inline ib_portinfo_record_t *osmv_get_query_portinfo_rec(IN osm_madw_t *
+ p_result_madw,
+ IN uint32_t
+ result_index)
+{
+ ib_sa_mad_t __attribute__((__unused__)) *p_sa_mad;
+
+ CL_ASSERT(p_result_madw);
+ p_sa_mad = (ib_sa_mad_t *) osm_madw_get_mad_ptr(p_result_madw);
+ CL_ASSERT(p_sa_mad && p_sa_mad->attr_id == IB_MAD_ATTR_PORTINFO_RECORD);
+
+ return ((ib_portinfo_record_t *) osmv_get_query_result(p_result_madw,
+ result_index));
+}
+
+/*
+* PARAMETERS
+* p_result_madw
+* [in] This is a reference to the MAD returned as a result of the
+* query.
+*
+* result_index
+* [in] A zero-based index indicating which result to return.
+*
+* NOTES
+* This call returns a pointer to the start of a port info record result
+* from a call to osmv_query_sa().
+*
+* SEE ALSO
+* osmv_query_res_t, osm_madw_t, osmv_get_query_result, ib_portinfo_record_t
+*****/
+
+/****f* OpenSM Vendor SA Client/osmv_get_query_node_rec
+* NAME
+* osmv_get_query_node_rec
+*
+* DESCRIPTION
+* Retrieves a node record result from a MAD returned by a call to
+* osmv_query_sa().
+*
+* SYNOPSIS
+*/
+static inline ib_node_record_t *osmv_get_query_node_rec(IN osm_madw_t *
+ p_result_madw,
+ IN uint32_t
+ result_index)
+{
+ ib_sa_mad_t __attribute__((__unused__)) *p_sa_mad;
+
+ CL_ASSERT(p_result_madw);
+ p_sa_mad = (ib_sa_mad_t *) osm_madw_get_mad_ptr(p_result_madw);
+ CL_ASSERT(p_sa_mad && p_sa_mad->attr_id == IB_MAD_ATTR_NODE_RECORD);
+
+ return ((ib_node_record_t *) osmv_get_query_result(p_result_madw,
+ result_index));
+}
+
+/*
+* PARAMETERS
+* p_result_madw
+* [in] This is a reference to the MAD returned as a result of the
+* query.
+*
+* result_index
+* [in] A zero-based index indicating which result to return.
+*
+* NOTES
+* This call returns a pointer to the start of a node record result from
+* a call to osmv_query_sa().
+*
+* SEE ALSO
+* osmv_query_res_t, osm_madw_t, osmv_get_query_result, ib_node_record_t
+*****/
+
+/****f* OpenSM Vendor SA Client/osmv_get_query_svc_rec
+* NAME
+* osmv_get_query_svc_rec
+*
+* DESCRIPTION
+* Retrieves a service record result from a MAD returned by a call to
+* osmv_query_sa().
+*
+* SYNOPSIS
+*/
+static inline ib_service_record_t *osmv_get_query_svc_rec(IN osm_madw_t *
+ p_result_madw,
+ IN uint32_t
+ result_index)
+{
+ ib_sa_mad_t __attribute__((__unused__)) *p_sa_mad;
+
+ CL_ASSERT(p_result_madw);
+ p_sa_mad = (ib_sa_mad_t *) osm_madw_get_mad_ptr(p_result_madw);
+ CL_ASSERT(p_sa_mad && p_sa_mad->attr_id == IB_MAD_ATTR_SERVICE_RECORD);
+
+ return ((ib_service_record_t *) osmv_get_query_result(p_result_madw,
+ result_index));
+}
+
+/*
+* PARAMETERS
+* p_result_madw
+* [in] This is a reference to the MAD returned as a result of the
+* query.
+*
+* result_index
+* [in] A zero-based index indicating which result to return.
+*
+* NOTES
+* This call returns a pointer to the start of a service record result from
+* a call to osmv_query_sa().
+*
+* SEE ALSO
+* osmv_query_res_t, osm_madw_t, osmv_get_query_result, ib_service_record_t
+*****/
+
+/****f* OpenSM Vendor SA Client/osmv_get_query_mc_rec
+* NAME
+* osmv_get_query_mc_rec
+*
+* DESCRIPTION
+* Retrieves a multicast record result from a MAD returned by a call to
+* osmv_query_sa().
+*
+* SYNOPSIS
+*/
+static inline ib_member_rec_t *osmv_get_query_mc_rec(IN osm_madw_t *
+ p_result_madw,
+ IN uint32_t result_index)
+{
+ ib_sa_mad_t __attribute__((__unused__)) *p_sa_mad;
+
+ CL_ASSERT(p_result_madw);
+ p_sa_mad = (ib_sa_mad_t *) osm_madw_get_mad_ptr(p_result_madw);
+ CL_ASSERT(p_sa_mad && p_sa_mad->attr_id == IB_MAD_ATTR_MCMEMBER_RECORD);
+
+ return ((ib_member_rec_t *) osmv_get_query_result(p_result_madw,
+ result_index));
+}
+
+/*
+* PARAMETERS
+* p_result_madw
+* [in] This is a reference to the MAD returned as a result of the
+* query.
+*
+* result_index
+* [in] A zero-based index indicating which result to return.
+*
+* NOTES
+* This call returns a pointer to the start of a service record result from
+* a call to osmv_query_sa().
+*
+* SEE ALSO
+* osmv_query_res_t, osm_madw_t, osmv_get_query_result, ib_member_rec_t
+*****/
+
+/****f* OpenSM Vendor SA Client/osmv_get_query_inform_info_rec
+* NAME
+* osmv_get_query_inform_info_rec
+*
+* DESCRIPTION
+* Retrieves an InformInfo record result from a MAD returned by
+* a call to osmv_query_sa().
+*
+* SYNOPSIS
+*/
+static inline ib_inform_info_record_t *osmv_get_query_inform_info_rec(IN
+ osm_madw_t
+ *
+ p_result_madw,
+ IN
+ uint32_t
+ result_index)
+{
+ ib_sa_mad_t __attribute__((__unused__)) *p_sa_mad;
+
+ CL_ASSERT(p_result_madw);
+ p_sa_mad = (ib_sa_mad_t *) osm_madw_get_mad_ptr(p_result_madw);
+ CL_ASSERT(p_sa_mad
+ && p_sa_mad->attr_id == IB_MAD_ATTR_INFORM_INFO_RECORD);
+
+ return ((ib_inform_info_record_t *) osmv_get_query_result(p_result_madw,
+ result_index));
+}
+
+/*
+* PARAMETERS
+* p_result_madw
+* [in] This is a reference to the MAD returned as a result of the
+* query.
+*
+* result_index
+* [in] A zero-based index indicating which result to return.
+*
+* NOTES
+* This call returns a pointer to the start of a service record result from
+* a call to osmv_query_sa().
+*
+* SEE ALSO
+* osmv_query_res_t, osm_madw_t, osmv_get_query_result, ib_inform_info_record_t
+*****/
+
+/****f* OpenSM Vendor SA Client/osmv_pfn_query_cb_t
+* NAME
+* osmv_pfn_query_cb_t
+*
+* DESCRIPTION
+* User-defined callback invoked on completion of subnet administration
+* query.
+*
+* SYNOPSIS
+*/
+typedef void
+ (*osmv_pfn_query_cb_t) (IN osmv_query_res_t * p_query_res);
+/*
+* PARAMETERS
+* p_query_res
+* [in] This is a reference to a structure containing the result of
+* the query.
+*
+* NOTES
+* This routine is invoked to notify a client of the result of a subnet
+* administration query. The p_query_rec parameter references the result
+* of the query and, in the case of a successful query, any information
+* returned by subnet administration.
+*
+* In the kernel, this callback is usually invoked using a tasklet,
+* dependent on the implementation of the underlying verbs provider driver.
+*
+* SEE ALSO
+* osmv_query_res_t
+*****/
+
+/****s* OpenSM Vendor SA Client/osmv_query_req_t
+* NAME
+* osmv_query_req_t
+*
+* DESCRIPTION
+* Information used to request an access layer provided query of subnet
+* administration.
+*
+* SYNOPSIS
+*/
+typedef struct _osmv_query_req {
+ osmv_query_type_t query_type;
+ const void *p_query_input;
+ ib_net64_t sm_key;
+
+ uint32_t timeout_ms;
+ uint32_t retry_cnt;
+ osmv_flags_t flags;
+
+ const void *query_context;
+ osmv_pfn_query_cb_t pfn_query_cb;
+ int with_grh;
+ ib_gid_t gid;
+} osmv_query_req_t;
+/*
+* FIELDS
+* query_type
+* Indicates the type of query that the access layer should
+* perform.
+*
+* p_query_input
+* A pointer to the input for the query. The data referenced by
+* this structure is dependent on the type of query being requested
+* and is determined by the specified query_type.
+*
+* sm_key
+* The SM_Key to be provided with the SA MAD for authentication.
+* Normally 0 is used.
+*
+* timeout_ms
+* Specifies the number of milliseconds to wait for a response for
+* this query until retrying or timing out the request.
+*
+* retry_cnt
+* Specifies the number of times that the query will be retried
+* before failing the request.
+*
+* flags
+* Used to describe the mode of operation. Set to IB_FLAGS_SYNC to
+* process the called routine synchronously.
+*
+* query_context
+* User-defined context information associated with this query.
+* The context data is returned to the user as a part of their
+* query callback.
+*
+* pfn_query_cb
+* A user-defined callback that is invoked upon completion of the
+* query.
+*
+* with_grh
+* Indicates that SA queries should be sent with GRH.
+*
+* gid
+* Used to store the SM/SA GID.
+*
+* NOTES
+* This structure is used when requesting an osm vendor provided query
+* of subnet administration. Clients specify the type of query through
+* the query_type field. Based on the type of query, the p_query_input
+* field is set to reference the appropriate data structure.
+*
+* The information referenced by the p_query_input field is one of the
+* following:
+*
+* -- a NULL terminated service name
+* -- a service id
+* -- a single GUID
+* -- a pair of GUIDs specified through an osmv_guid_pair_t structure
+* -- a pair of GIDs specified through an osmv_gid_pair_t structure
+*
+* SEE ALSO
+* osmv_query_type_t, osmv_pfn_query_cb_t, osmv_guid_pair_t,
+* osmv_gid_pair_t
+*****/
+
+/****f* OpenSM Vendor SA Client/osmv_bind_sa
+* NAME
+* osmv_bind_sa
+*
+* DESCRIPTION
+* Bind to the SA service and return a handle to be used for later
+* queries.
+*
+*
+* SYNOPSIS
+*/
+osm_bind_handle_t
+osmv_bind_sa(IN osm_vendor_t * const p_vend,
+ IN osm_mad_pool_t * const p_mad_pool, IN ib_net64_t port_guid);
+/*
+* PARAMETERS
+* p_vend
+* [in] an osm_vendor object to work with
+*
+* p_mad_pool
+* [in] mad pool to obtain madw from
+*
+* port_guid
+* [in] the port guid to attach to.
+*
+* RETURN VALUE
+* Bind handle to be used for later SA queries or OSM_BIND_INVALID_HANDLE
+*
+* NOTES
+*
+* SEE ALSO
+* osmv_query_sa
+*********/
+
+/****f* OpenSM Vendor SA Client/osmv_query_sa
+* NAME
+* osmv_query_sa
+*
+* DESCRIPTION
+* Query the SA given an SA query request (similar to IBAL ib_query).
+*
+* SYNOPSIS
+*/
+ib_api_status_t
+osmv_query_sa(IN osm_bind_handle_t h_bind,
+ IN const osmv_query_req_t * const p_query_req);
+/*
+* PARAMETERS
+* h_bind
+* [in] bind handle for this port. Should be previously
+* obtained by calling osmv_bind_sa
+*
+* p_query_req
+* [in] an SA query request structure.
+*
+* RETURN VALUE
+* IB_SUCCESS if completed successfuly (or in ASYNC mode
+* if the request was sent).
+*
+* NOTES
+*
+* SEE ALSO
+* osmv_bind_sa
+*********/
+
+END_C_DECLS
+#endif /* _OSM_VENDOR_SA_API_H_ */
diff --git a/contrib/ofed/management/opensm/include/vendor/osm_vendor_test.h b/contrib/ofed/opensm/include/vendor/osm_vendor_test.h
index a1ae1eb..a1ae1eb 100644
--- a/contrib/ofed/management/opensm/include/vendor/osm_vendor_test.h
+++ b/contrib/ofed/opensm/include/vendor/osm_vendor_test.h
diff --git a/contrib/ofed/management/opensm/include/vendor/osm_vendor_ts.h b/contrib/ofed/opensm/include/vendor/osm_vendor_ts.h
index a43f4e4..a43f4e4 100644
--- a/contrib/ofed/management/opensm/include/vendor/osm_vendor_ts.h
+++ b/contrib/ofed/opensm/include/vendor/osm_vendor_ts.h
diff --git a/contrib/ofed/management/opensm/include/vendor/osm_vendor_umadt.h b/contrib/ofed/opensm/include/vendor/osm_vendor_umadt.h
index 8cdb631..8cdb631 100644
--- a/contrib/ofed/management/opensm/include/vendor/osm_vendor_umadt.h
+++ b/contrib/ofed/opensm/include/vendor/osm_vendor_umadt.h
diff --git a/contrib/ofed/opensm/libopensm/Makefile b/contrib/ofed/opensm/libopensm/Makefile
new file mode 100644
index 0000000..6e6b688
--- /dev/null
+++ b/contrib/ofed/opensm/libopensm/Makefile
@@ -0,0 +1,20 @@
+# $FreeBSD$
+
+.PATH: ${.CURDIR}/../opensm
+
+SHLIBDIR?= /usr/lib
+LIB= opensm
+SHLIB_MAJOR= 5
+MK_PROFILE= no
+
+SRCS= \
+osm_log.c \
+osm_mad_pool.c \
+osm_helper.c
+
+LIBADD= pthread
+CFLAGS+= -I${.CURDIR}/.. -DHAVE_CONFIG_H=1
+CFLAGS+= -I${SYSROOT:U${DESTDIR}}/${INCLUDEDIR}/infiniband
+VERSION_MAP= ${.CURDIR}/../opensm/libopensm.map
+
+.include <bsd.lib.mk>
diff --git a/contrib/ofed/opensm/libvendor/Makefile b/contrib/ofed/opensm/libvendor/Makefile
new file mode 100644
index 0000000..9a90fac
--- /dev/null
+++ b/contrib/ofed/opensm/libvendor/Makefile
@@ -0,0 +1,19 @@
+# $FreeBSD$
+
+.PATH: ${.CURDIR}
+
+SHLIBDIR?= /usr/lib
+LIB= osmvendor
+SHLIB_MAJOR= 4
+MK_PROFILE= no
+
+SRCS= \
+osm_vendor_ibumad.c \
+osm_vendor_ibumad_sa.c
+
+LIBADD= ibumad pthread
+CFLAGS+= -I${.CURDIR}/.. -DHAVE_CONFIG_H=1
+CFLAGS+= -I${SYSROOT:U${DESTDIR}}/${INCLUDEDIR}/infiniband
+VERSION_MAP= ${.CURDIR}/libosmvendor.map
+
+.include <bsd.lib.mk>
diff --git a/contrib/ofed/management/opensm/libvendor/libosmvendor.map b/contrib/ofed/opensm/libvendor/libosmvendor.map
index 17416b3..17416b3 100644
--- a/contrib/ofed/management/opensm/libvendor/libosmvendor.map
+++ b/contrib/ofed/opensm/libvendor/libosmvendor.map
diff --git a/contrib/ofed/opensm/libvendor/libosmvendor.ver b/contrib/ofed/opensm/libvendor/libosmvendor.ver
new file mode 100644
index 0000000..0455aa3
--- /dev/null
+++ b/contrib/ofed/opensm/libvendor/libosmvendor.ver
@@ -0,0 +1,9 @@
+# In this file we track the current API version
+# of the vendor interface (and libraries)
+# The version is built of the following
+# tree numbers:
+# API_REV:RUNNING_REV:AGE
+# API_REV - advance on any added API
+# RUNNING_REV - advance any change to the vendor files
+# AGE - number of backward versions the API still supports
+LIBVERSION=4:2:0
diff --git a/contrib/ofed/opensm/libvendor/osm_pkt_randomizer.c b/contrib/ofed/opensm/libvendor/osm_pkt_randomizer.c
new file mode 100644
index 0000000..5ea1f4a
--- /dev/null
+++ b/contrib/ofed/opensm/libvendor/osm_pkt_randomizer.c
@@ -0,0 +1,322 @@
+/*
+ * Copyright (c) 2004-2008 Voltaire, Inc. All rights reserved.
+ * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved.
+ * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+/*
+ * Abstract:
+ * Implementation of osm_pkt_randomizer_t.
+ *
+ */
+
+#if HAVE_CONFIG_H
+# include <config.h>
+#endif /* HAVE_CONFIG_H */
+
+#include <vendor/osm_pkt_randomizer.h>
+#include <stdlib.h>
+#include <string.h>
+
+#ifndef __WIN__
+#include <sys/time.h>
+#include <unistd.h>
+#endif
+
+/**********************************************************************
+ * Return TRUE if the path is in a fault path, and FALSE otherwise.
+ * By in a fault path the meaning is that there is a path in the fault
+ * paths that the given path includes it.
+ * E.g: if there is a fault path: 0,1,4
+ * For the given path: 0,1,4,7 the return value will be TRUE, also for
+ * the given path: 0,1,4 the return value will be TRUE, but for
+ * the given paths: 0,1 or 0,3,1,4 - the return value will be FALSE.
+ **********************************************************************/
+boolean_t
+__osm_pkt_randomizer_is_path_in_fault_paths(IN osm_log_t * p_log,
+ IN osm_dr_path_t * p_dr_path,
+ IN osm_pkt_randomizer_t *
+ p_pkt_rand)
+{
+ boolean_t res = FALSE, found_path;
+ osm_dr_path_t *p_found_dr_path;
+ uint8_t ind1, ind2;
+
+ OSM_LOG_ENTER(p_log);
+
+ for (ind1 = 0; ind1 < p_pkt_rand->num_paths_initialized; ind1++) {
+ found_path = TRUE;
+ p_found_dr_path = &(p_pkt_rand->fault_dr_paths[ind1]);
+ /* if the hop count of the found path is greater than the
+ hop count of the input path - then it is not part of it.
+ Check the next path. */
+ if (p_found_dr_path->hop_count > p_dr_path->hop_count)
+ continue;
+
+ /* go over all the ports in the found path and see if they match
+ the ports in the input path */
+ for (ind2 = 0; ind2 <= p_found_dr_path->hop_count; ind2++)
+ if (p_found_dr_path->path[ind2] !=
+ p_dr_path->path[ind2])
+ found_path = FALSE;
+
+ /* If found_path is TRUE then there is a full match of the path */
+ if (found_path == TRUE) {
+ OSM_LOG(p_log, OSM_LOG_VERBOSE,
+ "Given path is in a fault path\n");
+ res = TRUE;
+ break;
+ }
+ }
+
+ OSM_LOG_EXIT(p_log);
+ return res;
+}
+
+/**********************************************************************
+ * For a given dr_path - return TRUE if the path should be dropped,
+ * return FALSE otherwise.
+ * The check uses random criteria in order to determine whether or not
+ * the path should be dropped.
+ * First - if not all paths are initialized, it randomally chooses if
+ * to use this path as a fault path or not.
+ * Second - if the path is in the fault paths (meaning - it is equal
+ * to or includes one of the fault paths) - then it randomally chooses
+ * if to drop it or not.
+ **********************************************************************/
+boolean_t
+__osm_pkt_randomizer_process_path(IN osm_log_t * p_log,
+ IN osm_pkt_randomizer_t * p_pkt_rand,
+ IN osm_dr_path_t * p_dr_path)
+{
+ boolean_t res = FALSE;
+ static boolean_t rand_value_init = FALSE;
+ static int rand_value;
+ boolean_t in_fault_paths;
+ uint8_t i;
+ char buf[BUF_SIZE];
+ char line[BUF_SIZE];
+
+ OSM_LOG_ENTER(p_log);
+
+ if (rand_value_init == FALSE) {
+ int seed;
+#ifdef __WIN__
+ SYSTEMTIME st;
+#else
+ struct timeval tv;
+ struct timezone tz;
+#endif /* __WIN__ */
+
+ /* initiate the rand_value according to timeofday */
+ rand_value_init = TRUE;
+
+#ifdef __WIN__
+ GetLocalTime(&st);
+ seed = st.wMilliseconds;
+#else
+ gettimeofday(&tv, &tz);
+ seed = tv.tv_usec;
+#endif /* __WIN__ */
+
+ srand(seed);
+ }
+
+ /* If the hop_count is 1 - then this is a mad down to our local port - don't drop it */
+ if (p_dr_path->hop_count <= 1)
+ goto Exit;
+
+ rand_value = rand();
+
+ sprintf(buf, "Path: ");
+ /* update the dr_path into the buf */
+ for (i = 0; i <= p_dr_path->hop_count; i++) {
+ sprintf(line, "[%X]", p_dr_path->path[i]);
+ strcat(buf, line);
+ }
+
+ /* Check if the path given is in one of the fault paths */
+ in_fault_paths =
+ __osm_pkt_randomizer_is_path_in_fault_paths(p_log, p_dr_path,
+ p_pkt_rand);
+
+ /* Check if all paths are initialized */
+ if (p_pkt_rand->num_paths_initialized <
+ p_pkt_rand->osm_pkt_num_unstable_links) {
+ /* Not all packets are initialized. */
+ if (in_fault_paths == FALSE) {
+ /* the path is not in the false paths. Check using the rand value
+ if to update it there or not. */
+ if (rand_value %
+ (p_pkt_rand->osm_pkt_unstable_link_rate) == 0) {
+ OSM_LOG(p_log, OSM_LOG_VERBOSE,
+ "%s added to the fault_dr_paths list\n"
+ "\t\t\t rand_value:%u, unstable_link_rate:%u \n",
+ buf, rand_value,
+ p_pkt_rand->osm_pkt_unstable_link_rate);
+
+ /* update the path in the fault paths */
+ memcpy(&
+ (p_pkt_rand->
+ fault_dr_paths[p_pkt_rand->
+ num_paths_initialized]),
+ p_dr_path, sizeof(osm_dr_path_t));
+ p_pkt_rand->num_paths_initialized++;
+ in_fault_paths = TRUE;
+ }
+ }
+ }
+
+ if (in_fault_paths == FALSE) {
+ /* If in_fault_paths is FALSE - just ignore the path */
+ OSM_LOG(p_log, OSM_LOG_VERBOSE, "%s not in fault paths\n", buf);
+ goto Exit;
+ }
+
+ /* The path is in the fault paths. Need to choose (randomally if to drop it
+ or not. */
+ rand_value = rand();
+
+ if (rand_value % (p_pkt_rand->osm_pkt_drop_rate) == 0) {
+ /* drop the current packet */
+ res = TRUE;
+ OSM_LOG(p_log, OSM_LOG_VERBOSE, "Dropping path:%s\n", buf);
+ }
+
+Exit:
+ OSM_LOG_EXIT(p_log);
+ return res;
+}
+
+boolean_t
+osm_pkt_randomizer_mad_drop(IN osm_log_t * p_log,
+ IN osm_pkt_randomizer_t * p_pkt_randomizer,
+ IN const ib_mad_t * p_mad)
+{
+ const ib_smp_t *p_smp;
+ boolean_t res = FALSE;
+ osm_dr_path_t dr_path;
+
+ OSM_LOG_ENTER(p_log);
+
+ p_smp = (ib_smp_t *) p_mad;
+
+ if (p_smp->mgmt_class != IB_MCLASS_SUBN_DIR)
+ /* This is a lid route mad. Don't drop it */
+ goto Exit;
+
+ osm_dr_path_init(&dr_path, p_smp->hop_count, p_smp->initial_path);
+
+ if (__osm_pkt_randomizer_process_path
+ (p_log, p_pkt_randomizer, &dr_path)) {
+ /* the mad should be dropped o */
+ OSM_LOG(p_log, OSM_LOG_VERBOSE,
+ "mad TID: 0x%" PRIx64 " is being dropped\n",
+ cl_ntoh64(p_smp->trans_id));
+ res = TRUE;
+ }
+
+Exit:
+ OSM_LOG_EXIT(p_log);
+ return res;
+}
+
+ib_api_status_t
+osm_pkt_randomizer_init(IN OUT osm_pkt_randomizer_t ** pp_pkt_randomizer,
+ IN osm_log_t * p_log)
+{
+ uint8_t tmp;
+ ib_api_status_t res = IB_SUCCESS;
+
+ OSM_LOG_ENTER(p_log);
+
+ *pp_pkt_randomizer = malloc(sizeof(osm_pkt_randomizer_t));
+ if (*pp_pkt_randomizer == NULL) {
+ res = IB_INSUFFICIENT_MEMORY;
+ goto Exit;
+ }
+ memset(*pp_pkt_randomizer, 0, sizeof(osm_pkt_randomizer_t));
+ (*pp_pkt_randomizer)->num_paths_initialized = 0;
+
+ tmp = atol(getenv("OSM_PKT_DROP_RATE"));
+ (*pp_pkt_randomizer)->osm_pkt_drop_rate = tmp;
+
+ if (getenv("OSM_PKT_NUM_UNSTABLE_LINKS") != NULL
+ && (tmp = atol(getenv("OSM_PKT_NUM_UNSTABLE_LINKS"))) > 0)
+ (*pp_pkt_randomizer)->osm_pkt_num_unstable_links = tmp;
+ else
+ (*pp_pkt_randomizer)->osm_pkt_num_unstable_links = 1;
+
+ if (getenv("OSM_PKT_UNSTABLE_LINK_RATE") != NULL
+ && (tmp = atol(getenv("OSM_PKT_UNSTABLE_LINK_RATE"))) > 0)
+ (*pp_pkt_randomizer)->osm_pkt_unstable_link_rate = tmp;
+ else
+ (*pp_pkt_randomizer)->osm_pkt_unstable_link_rate = 20;
+
+ OSM_LOG(p_log, OSM_LOG_VERBOSE, "Using OSM_PKT_DROP_RATE=%u \n"
+ "\t\t\t\t OSM_PKT_NUM_UNSTABLE_LINKS=%u \n"
+ "\t\t\t\t OSM_PKT_UNSTABLE_LINK_RATE=%u \n",
+ (*pp_pkt_randomizer)->osm_pkt_drop_rate,
+ (*pp_pkt_randomizer)->osm_pkt_num_unstable_links,
+ (*pp_pkt_randomizer)->osm_pkt_unstable_link_rate);
+
+ /* allocate the fault_dr_paths variable */
+ /* It is the number of the paths that will be saved as fault = osm_pkt_num_unstable_links */
+ (*pp_pkt_randomizer)->fault_dr_paths = malloc(sizeof(osm_dr_path_t) *
+ (*pp_pkt_randomizer)->
+ osm_pkt_num_unstable_links);
+ if ((*pp_pkt_randomizer)->fault_dr_paths == NULL) {
+ res = IB_INSUFFICIENT_MEMORY;
+ goto Exit;
+ }
+
+ memset((*pp_pkt_randomizer)->fault_dr_paths, 0,
+ sizeof(osm_dr_path_t) *
+ (*pp_pkt_randomizer)->osm_pkt_num_unstable_links);
+
+Exit:
+ OSM_LOG_EXIT(p_log);
+ return (res);
+}
+
+void
+osm_pkt_randomizer_destroy(IN OUT osm_pkt_randomizer_t ** pp_pkt_randomizer,
+ IN osm_log_t * p_log)
+{
+ OSM_LOG_ENTER(p_log);
+
+ if (*pp_pkt_randomizer != NULL) {
+ free((*pp_pkt_randomizer)->fault_dr_paths);
+ free(*pp_pkt_randomizer);
+ }
+ OSM_LOG_EXIT(p_log);
+}
diff --git a/contrib/ofed/opensm/libvendor/osm_vendor_al.c b/contrib/ofed/opensm/libvendor/osm_vendor_al.c
new file mode 100644
index 0000000..a0c24df
--- /dev/null
+++ b/contrib/ofed/opensm/libvendor/osm_vendor_al.c
@@ -0,0 +1,1270 @@
+/*
+ * Copyright (c) 2004-2009 Voltaire, Inc. All rights reserved.
+ * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved.
+ * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+/*
+ * Abstract:
+ * Implementation of osm_req_t.
+ * This object represents the generic attribute requester.
+ * This object is part of the opensm family of objects.
+ *
+ */
+
+/*
+ Next available error code: 0x300
+*/
+
+#if HAVE_CONFIG_H
+# include <config.h>
+#endif /* HAVE_CONFIG_H */
+
+#ifdef OSM_VENDOR_INTF_AL
+
+#include <stdlib.h>
+#include <string.h>
+#include <complib/cl_qlist.h>
+#include <complib/cl_thread.h>
+#include <complib/cl_math.h>
+#include <complib/cl_debug.h>
+#include <iba/ib_types.h>
+#include <opensm/osm_madw.h>
+#include <opensm/osm_log.h>
+#include <opensm/osm_mad_pool.h>
+#include <vendor/osm_vendor_api.h>
+
+/****s* OpenSM: Vendor AL/osm_al_bind_info_t
+ * NAME
+ * osm_al_bind_info_t
+ *
+ * DESCRIPTION
+ * Structure containing bind information.
+ *
+ * SYNOPSIS
+ */
+typedef struct _osm_al_bind_info {
+ osm_vendor_t *p_vend;
+ void *client_context;
+ ib_qp_handle_t h_qp;
+ ib_mad_svc_handle_t h_svc;
+ uint8_t port_num;
+ ib_pool_key_t pool_key;
+ osm_vend_mad_recv_callback_t rcv_callback;
+ osm_vend_mad_send_err_callback_t send_err_callback;
+ osm_mad_pool_t *p_osm_pool;
+ ib_av_handle_t h_dr_av;
+
+} osm_al_bind_info_t;
+/*
+ * FIELDS
+ * p_vend
+ * Pointer to the vendor object.
+ *
+ * client_context
+ * User's context passed during osm_bind
+ *
+ * h_qp
+ * Handle the QP for this bind.
+ *
+ * h_qp_svc
+ * Handle the QP mad service for this bind.
+ *
+ * port_num
+ * Port number (within the HCA) of the bound port.
+ *
+ * pool_key
+ * Pool key returned by all for this QP.
+ *
+ * h_dr_av
+ * Address vector handle used for all directed route SMPs.
+ *
+ * SEE ALSO
+ *********/
+
+inline static ib_api_status_t
+__osm_al_convert_wcs(IN ib_wc_status_t const wc_status)
+{
+ switch (wc_status) {
+ case IB_WCS_SUCCESS:
+ return (IB_SUCCESS);
+
+ case IB_WCS_TIMEOUT_RETRY_ERR:
+ return (IB_TIMEOUT);
+
+ default:
+ return (IB_ERROR);
+ }
+}
+
+static void __osm_al_ca_err_callback(IN ib_async_event_rec_t * p_async_rec)
+{
+ osm_vendor_t *p_vend = (osm_vendor_t *) p_async_rec->context;
+ OSM_LOG_ENTER(p_vend->p_log);
+
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "__osm_al_ca_err_callback: ERR 3B01: "
+ "Event on channel adapter (%s).\n",
+ ib_get_async_event_str(p_async_rec->code));
+
+ OSM_LOG_EXIT(p_vend->p_log);
+}
+
+static void __osm_al_ca_destroy_callback(IN void *context)
+{
+ osm_al_bind_info_t *p_bind = (osm_al_bind_info_t *) context;
+ osm_vendor_t *p_vend = p_bind->p_vend;
+ OSM_LOG_ENTER(p_vend->p_log);
+
+ osm_log(p_vend->p_log, OSM_LOG_INFO,
+ "__osm_al_ca_destroy_callback: "
+ "Closing local channel adapter.\n");
+
+ OSM_LOG_EXIT(p_vend->p_log);
+}
+
+static void __osm_al_err_callback(IN ib_async_event_rec_t * p_async_rec)
+{
+ osm_al_bind_info_t *p_bind =
+ (osm_al_bind_info_t *) p_async_rec->context;
+ osm_vendor_t *p_vend = p_bind->p_vend;
+ OSM_LOG_ENTER(p_vend->p_log);
+
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "__osm_al_err_callback: ERR 3B02: "
+ "Error on QP (%s).\n",
+ ib_get_async_event_str(p_async_rec->code));
+
+ OSM_LOG_EXIT(p_vend->p_log);
+}
+
+static void
+__osm_al_send_callback(IN void *mad_svc_context, IN ib_mad_element_t * p_elem)
+{
+ osm_al_bind_info_t *const p_bind =
+ (osm_al_bind_info_t *) mad_svc_context;
+ osm_vendor_t *const p_vend = p_bind->p_vend;
+ osm_madw_t *const p_madw = (osm_madw_t *) p_elem->context1;
+ osm_vend_wrap_t *const p_vw = osm_madw_get_vend_ptr(p_madw);
+ ib_mad_t *p_mad;
+
+ OSM_LOG_ENTER(p_vend->p_log);
+
+ CL_ASSERT(p_vw);
+ CL_ASSERT(p_vw->h_av);
+
+ /*
+ Destroy the address vector as necessary.
+ */
+ if (p_vw->h_av != p_bind->h_dr_av) {
+ if (osm_log_is_active(p_vend->p_log, OSM_LOG_DEBUG)) {
+ osm_log(p_vend->p_log, OSM_LOG_DEBUG,
+ "__osm_al_send_callback: "
+ "Destroying av handle %p.\n", p_vw->h_av);
+ }
+
+ ib_destroy_av(p_vw->h_av);
+ }
+
+ p_mad = ib_get_mad_buf(p_elem);
+
+ if (p_elem->resp_expected) {
+ /*
+ If the send was unsuccessful, notify the user
+ for MADs that were expecting a response.
+ A NULL mad wrapper parameter is the user's clue
+ that the transaction turned sour.
+
+ Otherwise, do nothing for successful sends when a
+ reponse is expected. The mad will be returned to the
+ pool later.
+ */
+ p_madw->status = __osm_al_convert_wcs(p_elem->status);
+ if (p_elem->status != IB_WCS_SUCCESS) {
+ osm_log(p_vend->p_log, OSM_LOG_DEBUG,
+ "__osm_al_send_callback: "
+ "MAD completed with work queue error: %s.\n",
+ ib_get_wc_status_str(p_elem->status));
+ /*
+ Return any wrappers to the pool that may have been
+ pre-emptively allocated to handle a receive.
+ */
+ if (p_vw->p_resp_madw) {
+ osm_mad_pool_put(p_bind->p_osm_pool,
+ p_vw->p_resp_madw);
+ p_vw->p_resp_madw = NULL;
+ }
+
+ p_bind->send_err_callback(p_bind->client_context,
+ p_madw);
+ }
+ } else {
+ osm_log(p_vend->p_log, OSM_LOG_DEBUG,
+ "__osm_al_send_callback: "
+ "Returning MAD to pool, TID = 0x%" PRIx64 ".\n",
+ cl_ntoh64(p_mad->trans_id));
+ osm_mad_pool_put(p_bind->p_osm_pool, p_madw);
+ goto Exit;
+ }
+
+Exit:
+ OSM_LOG_EXIT(p_vend->p_log);
+}
+
+static void
+__osm_al_rcv_callback(IN void *mad_svc_context, IN ib_mad_element_t * p_elem)
+{
+ osm_al_bind_info_t *const p_bind =
+ (osm_al_bind_info_t *) mad_svc_context;
+ osm_vendor_t *const p_vend = p_bind->p_vend;
+ osm_madw_t *p_old_madw;
+ osm_madw_t *p_new_madw;
+ osm_vend_wrap_t *p_old_vw;
+ osm_vend_wrap_t *p_new_vw;
+ ib_mad_t *p_new_mad;
+ osm_mad_addr_t mad_addr;
+
+ OSM_LOG_ENTER(p_vend->p_log);
+
+ CL_ASSERT(p_elem->context1 == NULL);
+ CL_ASSERT(p_elem->context2 == NULL);
+
+ p_new_mad = ib_get_mad_buf(p_elem);
+
+ /*
+ In preperation for initializing the new mad wrapper,
+ Initialize the mad_addr structure for the received wire MAD.
+ */
+ mad_addr.dest_lid = p_elem->remote_lid;
+ mad_addr.path_bits = p_elem->path_bits;
+
+ /* TO DO - figure out which #define to use for the 2.5 Gb rate... */
+ mad_addr.static_rate = 0;
+
+ if (p_new_mad->mgmt_class == IB_MCLASS_SUBN_LID ||
+ p_new_mad->mgmt_class == IB_MCLASS_SUBN_DIR) {
+ mad_addr.addr_type.smi.source_lid = p_elem->remote_lid;
+ } else {
+ mad_addr.addr_type.gsi.remote_qp = p_elem->remote_qp;
+ mad_addr.addr_type.gsi.remote_qkey = p_elem->remote_qkey;
+ mad_addr.addr_type.gsi.pkey_ix = p_elem->pkey_index;
+ mad_addr.addr_type.gsi.service_level = p_elem->remote_sl;
+ mad_addr.addr_type.gsi.global_route = FALSE;
+ }
+
+ /*
+ If this MAD is a response to a previous request,
+ then grab our pre-allocated MAD wrapper.
+ Otherwise, allocate a new MAD wrapper.
+ */
+ if (ib_mad_is_response(p_new_mad)) {
+ CL_ASSERT(p_elem->send_context1 != NULL);
+ CL_ASSERT(p_elem->send_context2 == NULL);
+
+ p_old_madw = (osm_madw_t *) p_elem->send_context1;
+ p_old_vw = osm_madw_get_vend_ptr(p_old_madw);
+ p_new_madw = p_old_vw->p_resp_madw;
+
+ CL_ASSERT(p_new_madw);
+
+ osm_madw_init(p_new_madw, p_bind, p_elem->size, &mad_addr);
+ osm_madw_set_mad(p_new_madw, p_new_mad);
+ } else {
+ CL_ASSERT(p_elem->send_context1 == NULL);
+ CL_ASSERT(p_elem->send_context2 == NULL);
+
+ p_new_madw = osm_mad_pool_get_wrapper(p_bind->p_osm_pool,
+ p_bind, p_elem->size,
+ p_new_mad, &mad_addr);
+ }
+
+ CL_ASSERT(p_new_madw);
+ p_new_vw = osm_madw_get_vend_ptr(p_new_madw);
+
+ p_new_vw->h_bind = p_bind;
+ p_new_vw->size = p_elem->size;
+ p_new_vw->p_elem = p_elem;
+ p_new_vw->h_av = 0;
+ p_new_vw->p_resp_madw = NULL;
+
+ osm_log(p_vend->p_log, OSM_LOG_DEBUG,
+ "__osm_al_rcv_callback: "
+ "Calling receive callback function %p.\n",
+ p_bind->rcv_callback);
+
+ p_bind->rcv_callback(p_new_madw, p_bind->client_context,
+ p_elem->send_context1);
+
+ OSM_LOG_EXIT(p_vend->p_log);
+}
+
+ib_api_status_t
+osm_vendor_init(IN osm_vendor_t * const p_vend,
+ IN osm_log_t * const p_log, IN const uint32_t timeout)
+{
+ ib_api_status_t status;
+ OSM_LOG_ENTER(p_log);
+
+ p_vend->p_log = p_log;
+
+ /*
+ Open our instance of AL.
+ */
+ status = ib_open_al(&p_vend->h_al);
+ if (status != IB_SUCCESS) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "osm_vendor_init: ERR 3B03: "
+ "Error opening AL (%s).\n", ib_get_err_str(status));
+
+ goto Exit;
+ }
+
+ p_vend->timeout = timeout;
+
+Exit:
+ OSM_LOG_EXIT(p_log);
+ return (status);
+}
+
+osm_vendor_t *osm_vendor_new(IN osm_log_t * const p_log,
+ IN const uint32_t timeout)
+{
+ ib_api_status_t status;
+ osm_vendor_t *p_vend;
+
+ OSM_LOG_ENTER(p_log);
+
+ p_vend = malloc(sizeof(*p_vend));
+ if (p_vend == NULL) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "osm_vendor_new: ERR 3B04: "
+ "Unable to allocate vendor object.\n");
+ goto Exit;
+ }
+
+ memset(p_vend, 0, sizeof(*p_vend));
+
+ status = osm_vendor_init(p_vend, p_log, timeout);
+ if (status != IB_SUCCESS) {
+ free(p_vend);
+ p_vend = NULL;
+ }
+
+Exit:
+ OSM_LOG_EXIT(p_log);
+ return (p_vend);
+}
+
+void osm_vendor_delete(IN osm_vendor_t ** const pp_vend)
+{
+ /* TO DO - fill this in */
+ ib_close_al((*pp_vend)->h_al);
+ free(*pp_vend);
+ *pp_vend = NULL;
+}
+
+static ib_api_status_t
+__osm_ca_info_init(IN osm_vendor_t * const p_vend,
+ IN osm_ca_info_t * const p_ca_info,
+ IN const ib_net64_t ca_guid)
+{
+ ib_api_status_t status;
+
+ OSM_LOG_ENTER(p_vend->p_log);
+
+ p_ca_info->guid = ca_guid;
+
+ if (osm_log_is_active(p_vend->p_log, OSM_LOG_VERBOSE)) {
+ osm_log(p_vend->p_log, OSM_LOG_VERBOSE,
+ "__osm_ca_info_init: "
+ "Querying CA 0x%" PRIx64 ".\n", cl_ntoh64(ca_guid));
+ }
+
+ status = ib_query_ca_by_guid(p_vend->h_al, ca_guid, NULL,
+ &p_ca_info->attr_size);
+ if ((status != IB_INSUFFICIENT_MEMORY) && (status != IB_SUCCESS)) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "__osm_ca_info_init: ERR 3B05: "
+ "Unexpected status getting CA attributes (%s).\n",
+ ib_get_err_str(status));
+ goto Exit;
+ }
+
+ CL_ASSERT(p_ca_info->attr_size);
+
+ p_ca_info->p_attr = malloc(p_ca_info->attr_size);
+ if (p_ca_info->p_attr == NULL) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "__osm_ca_info_init: ERR 3B06: "
+ "Unable to allocate attribute storage.\n");
+ goto Exit;
+ }
+
+ status = ib_query_ca_by_guid(p_vend->h_al, ca_guid, p_ca_info->p_attr,
+ &p_ca_info->attr_size);
+ if (status != IB_SUCCESS) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "__osm_ca_info_init: ERR 3B07: "
+ "Unexpected status getting CA attributes (%s).\n",
+ ib_get_err_str(status));
+ goto Exit;
+ }
+
+Exit:
+ OSM_LOG_EXIT(p_vend->p_log);
+ return (status);
+}
+
+void
+osm_ca_info_destroy(IN osm_vendor_t * const p_vend,
+ IN osm_ca_info_t * const p_ca_info)
+{
+ OSM_LOG_ENTER(p_vend->p_log);
+
+ if (p_ca_info->p_attr)
+ free(p_ca_info->p_attr);
+
+ free(p_ca_info);
+
+ OSM_LOG_EXIT(p_vend->p_log);
+}
+
+osm_ca_info_t *osm_ca_info_new(IN osm_vendor_t * const p_vend,
+ IN const ib_net64_t ca_guid)
+{
+ ib_api_status_t status;
+ osm_ca_info_t *p_ca_info;
+
+ OSM_LOG_ENTER(p_vend->p_log);
+
+ CL_ASSERT(ca_guid);
+
+ p_ca_info = malloc(sizeof(*p_ca_info));
+ if (p_ca_info == NULL)
+ goto Exit;
+
+ memset(p_ca_info, 0, sizeof(*p_ca_info));
+
+ status = __osm_ca_info_init(p_vend, p_ca_info, ca_guid);
+ if (status != IB_SUCCESS) {
+ osm_ca_info_destroy(p_vend, p_ca_info);
+ p_ca_info = NULL;
+ goto Exit;
+ }
+
+Exit:
+ OSM_LOG_EXIT(p_vend->p_log);
+ return (p_ca_info);
+}
+
+static ib_api_status_t
+__osm_vendor_get_ca_guids(IN osm_vendor_t * const p_vend,
+ IN ib_net64_t ** const p_guids,
+ IN unsigned * const p_num_guids)
+{
+ ib_api_status_t status;
+
+ OSM_LOG_ENTER(p_vend->p_log);
+
+ CL_ASSERT(p_guids);
+ CL_ASSERT(p_num_guids);
+
+ status = ib_get_ca_guids(p_vend->h_al, NULL, p_num_guids);
+ if ((status != IB_INSUFFICIENT_MEMORY) && (status != IB_SUCCESS)) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "__osm_vendor_get_ca_guids: ERR 3B08: "
+ "Unexpected status getting CA GUID array (%s).\n",
+ ib_get_err_str(status));
+ goto Exit;
+ }
+
+ if (*p_num_guids == 0) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "__osm_vendor_get_ca_guids: ERR 3B09: "
+ "No available channel adapters.\n");
+ status = IB_INSUFFICIENT_RESOURCES;
+ goto Exit;
+ }
+
+ *p_guids = malloc(*p_num_guids * sizeof(**p_guids));
+ if (*p_guids == NULL) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "__osm_vendor_get_ca_guids: ERR 3B10: "
+ "Unable to allocate CA GUID array.\n");
+ goto Exit;
+ }
+
+ status = ib_get_ca_guids(p_vend->h_al, *p_guids, p_num_guids);
+ CL_ASSERT(*p_num_guids);
+
+ if (osm_log_is_active(p_vend->p_log, OSM_LOG_VERBOSE)) {
+ osm_log(p_vend->p_log, OSM_LOG_VERBOSE,
+ "__osm_vendor_get_ca_guids: "
+ "Detected %u local channel adapters.\n", *p_num_guids);
+ }
+
+Exit:
+ OSM_LOG_EXIT(p_vend->p_log);
+ return (status);
+}
+
+/****f* OpenSM: CA Info/osm_ca_info_get_pi_ptr
+ * NAME
+ * osm_ca_info_get_pi_ptr
+ *
+ * DESCRIPTION
+ * Returns a pointer to the port attribute of the specified port
+ * owned by this CA.
+ *
+ * SYNOPSIS
+ */
+static ib_port_attr_t *__osm_ca_info_get_port_attr_ptr(IN const osm_ca_info_t *
+ const p_ca_info,
+ IN const uint8_t index)
+{
+ return (&p_ca_info->p_attr->p_port_attr[index]);
+}
+
+/*
+ * PARAMETERS
+ * p_ca_info
+ * [in] Pointer to a CA Info object.
+ *
+ * index
+ * [in] Port "index" for which to retrieve the port attribute.
+ * The index is the offset into the ca's internal array
+ * of port attributes.
+ *
+ * RETURN VALUE
+ * Returns a pointer to the port attribute of the specified port
+ * owned by this CA.
+ *
+ * NOTES
+ *
+ * SEE ALSO
+ *********/
+
+ib_api_status_t
+osm_vendor_get_all_port_attr(IN osm_vendor_t * const p_vend,
+ IN ib_port_attr_t * const p_attr_array,
+ IN uint32_t * const p_num_ports)
+{
+ ib_api_status_t status;
+
+ uint32_t ca;
+ unsigned ca_count;
+ uint32_t port_count = 0;
+ uint8_t port_num;
+ uint32_t total_ports = 0;
+ ib_net64_t *p_ca_guid = NULL;
+ osm_ca_info_t *p_ca_info;
+
+ OSM_LOG_ENTER(p_vend->p_log);
+
+ CL_ASSERT(p_vend);
+ CL_ASSERT(p_vend->p_ca_info == NULL);
+
+ /*
+ 1) Determine the number of CA's
+ 2) Allocate an array big enough to hold the ca info objects.
+ 3) Call again to retrieve the guids.
+ */
+ status = __osm_vendor_get_ca_guids(p_vend, &p_ca_guid, &ca_count);
+
+ p_vend->p_ca_info = malloc(ca_count * sizeof(*p_vend->p_ca_info));
+ if (p_vend->p_ca_info == NULL) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "osm_vendor_get_all_port_attr: ERR 3B11: "
+ "Unable to allocate CA information array.\n");
+ goto Exit;
+ }
+
+ memset(p_vend->p_ca_info, 0, ca_count * sizeof(*p_vend->p_ca_info));
+ p_vend->ca_count = ca_count;
+
+ /*
+ For each CA, retrieve the port info attributes
+ */
+ for (ca = 0; ca < ca_count; ca++) {
+ p_ca_info = &p_vend->p_ca_info[ca];
+
+ status = __osm_ca_info_init(p_vend, p_ca_info, p_ca_guid[ca]);
+
+ if (status != IB_SUCCESS) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "osm_vendor_get_all_port_attr: ERR 3B12: "
+ "Unable to initialize CA Info object (%s).\n",
+ ib_get_err_str(status));
+ }
+
+ total_ports += osm_ca_info_get_num_ports(p_ca_info);
+ }
+
+ /*
+ If the user supplied enough storage, return the port guids,
+ otherwise, return the appropriate error.
+ */
+ if (*p_num_ports >= total_ports) {
+ for (ca = 0; ca < ca_count; ca++) {
+ uint32_t num_ports;
+
+ p_ca_info = &p_vend->p_ca_info[ca];
+
+ num_ports = osm_ca_info_get_num_ports(p_ca_info);
+
+ for (port_num = 0; port_num < num_ports; port_num++) {
+ p_attr_array[port_count] =
+ *__osm_ca_info_get_port_attr_ptr(p_ca_info,
+ port_num);
+ port_count++;
+ }
+ }
+ } else {
+ status = IB_INSUFFICIENT_MEMORY;
+ }
+
+ *p_num_ports = total_ports;
+
+Exit:
+ if (p_ca_guid)
+ free(p_ca_guid);
+
+ OSM_LOG_EXIT(p_vend->p_log);
+ return (status);
+}
+
+ib_net64_t
+osm_vendor_get_ca_guid(IN osm_vendor_t * const p_vend,
+ IN const ib_net64_t port_guid)
+{
+ uint8_t index;
+ uint8_t num_ports;
+ uint32_t num_guids = 0;
+ osm_ca_info_t *p_ca_info;
+ uint32_t ca;
+
+ OSM_LOG_ENTER(p_vend->p_log);
+
+ CL_ASSERT(port_guid);
+ /*
+ First, locate the HCA that owns this port.
+ */
+ if (p_vend->p_ca_info == NULL) {
+ /*
+ Initialize the osm_ca_info_t array which allows
+ us to match port GUID to CA.
+ */
+ osm_vendor_get_all_port_attr(p_vend, NULL, &num_guids);
+ }
+
+ CL_ASSERT(p_vend->p_ca_info);
+ CL_ASSERT(p_vend->ca_count);
+
+ for (ca = 0; ca < p_vend->ca_count; ca++) {
+ p_ca_info = &p_vend->p_ca_info[ca];
+
+ num_ports = osm_ca_info_get_num_ports(p_ca_info);
+ CL_ASSERT(num_ports);
+
+ for (index = 0; index < num_ports; index++) {
+ if (port_guid ==
+ osm_ca_info_get_port_guid(p_ca_info, index)) {
+ OSM_LOG_EXIT(p_vend->p_log);
+ return (osm_ca_info_get_ca_guid(p_ca_info));
+ }
+ }
+ }
+
+ /*
+ No local CA owns this guid!
+ */
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "osm_vendor_get_ca_guid: ERR 3B13: "
+ "Unable to determine CA guid.\n");
+
+ OSM_LOG_EXIT(p_vend->p_log);
+ return (0);
+}
+
+uint8_t
+osm_vendor_get_port_num(IN osm_vendor_t * const p_vend,
+ IN const ib_net64_t port_guid)
+{
+ uint8_t index;
+ uint8_t num_ports;
+ uint32_t num_guids = 0;
+ osm_ca_info_t *p_ca_info;
+ uint32_t ca;
+
+ OSM_LOG_ENTER(p_vend->p_log);
+
+ CL_ASSERT(port_guid);
+ /*
+ First, locate the HCA that owns this port.
+ */
+ if (p_vend->p_ca_info == NULL) {
+ /*
+ Initialize the osm_ca_info_t array which allows
+ us to match port GUID to CA.
+ */
+ osm_vendor_get_all_port_attr(p_vend, NULL, &num_guids);
+ }
+
+ CL_ASSERT(p_vend->p_ca_info);
+ CL_ASSERT(p_vend->ca_count);
+
+ for (ca = 0; ca < p_vend->ca_count; ca++) {
+ p_ca_info = &p_vend->p_ca_info[ca];
+
+ num_ports = osm_ca_info_get_num_ports(p_ca_info);
+ CL_ASSERT(num_ports);
+
+ for (index = 0; index < num_ports; index++) {
+ if (port_guid ==
+ osm_ca_info_get_port_guid(p_ca_info, index)) {
+ OSM_LOG_EXIT(p_vend->p_log);
+ return (osm_ca_info_get_port_num
+ (p_ca_info, index));
+ }
+ }
+ }
+
+ /*
+ No local CA owns this guid!
+ */
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "osm_vendor_get_port_num: ERR 3B30: "
+ "Unable to determine CA guid.\n");
+
+ OSM_LOG_EXIT(p_vend->p_log);
+ return (0);
+}
+
+static ib_api_status_t
+__osm_vendor_open_ca(IN osm_vendor_t * const p_vend,
+ IN const ib_net64_t port_guid)
+{
+ ib_net64_t ca_guid;
+ ib_api_status_t status;
+
+ OSM_LOG_ENTER(p_vend->p_log);
+
+ ca_guid = osm_vendor_get_ca_guid(p_vend, port_guid);
+ if (ca_guid == 0) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "__osm_vendor_open_ca: ERR 3B31: "
+ "Bad port GUID value 0x%" PRIx64 ".\n",
+ cl_ntoh64(port_guid));
+ status = IB_ERROR;
+ goto Exit;
+ }
+
+ osm_log(p_vend->p_log, OSM_LOG_VERBOSE,
+ "__osm_vendor_open_ca: "
+ "Opening HCA 0x%" PRIx64 ".\n", cl_ntoh64(ca_guid));
+
+ status = ib_open_ca(p_vend->h_al,
+ ca_guid,
+ __osm_al_ca_err_callback, p_vend, &p_vend->h_ca);
+
+ if (status != IB_SUCCESS) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "__osm_vendor_open_ca: ERR 3B15: "
+ "Unable to open CA (%s).\n", ib_get_err_str(status));
+ goto Exit;
+ }
+
+ CL_ASSERT(p_vend->h_ca);
+
+ status = ib_alloc_pd(p_vend->h_ca, IB_PDT_ALIAS, p_vend, &p_vend->h_pd);
+
+ if (status != IB_SUCCESS) {
+ ib_close_ca(p_vend->h_ca, __osm_al_ca_destroy_callback);
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "__osm_vendor_open_ca: ERR 3B16: "
+ "Unable to allocate protection domain (%s).\n",
+ ib_get_err_str(status));
+ goto Exit;
+ }
+
+ CL_ASSERT(p_vend->h_pd);
+
+Exit:
+ OSM_LOG_EXIT(p_vend->p_log);
+ return (status);
+}
+
+static void
+__osm_vendor_init_av(IN const osm_al_bind_info_t * p_bind,
+ IN ib_av_attr_t * p_av)
+{
+ memset(p_av, 0, sizeof(*p_av));
+ p_av->port_num = p_bind->port_num;
+ p_av->dlid = IB_LID_PERMISSIVE;
+}
+
+osm_bind_handle_t
+osm_vendor_bind(IN osm_vendor_t * const p_vend,
+ IN osm_bind_info_t * const p_user_bind,
+ IN osm_mad_pool_t * const p_mad_pool,
+ IN osm_vend_mad_recv_callback_t mad_recv_callback,
+ IN osm_vend_mad_send_err_callback_t send_err_callback,
+ IN void *context)
+{
+ ib_net64_t port_guid;
+ osm_al_bind_info_t *p_bind = 0;
+ ib_api_status_t status;
+ ib_qp_create_t qp_create;
+ ib_mad_svc_t mad_svc;
+ ib_av_attr_t av;
+
+ OSM_LOG_ENTER(p_vend->p_log);
+
+ CL_ASSERT(p_user_bind);
+ CL_ASSERT(p_mad_pool);
+ CL_ASSERT(mad_recv_callback);
+ CL_ASSERT(send_err_callback);
+
+ port_guid = p_user_bind->port_guid;
+
+ osm_log(p_vend->p_log, OSM_LOG_INFO,
+ "osm_vendor_bind: "
+ "Binding to port 0x%" PRIx64 ".\n", cl_ntoh64(port_guid));
+
+ if (p_vend->h_ca == 0) {
+ osm_log(p_vend->p_log, OSM_LOG_DEBUG,
+ "osm_vendor_bind: "
+ "Opening CA that owns port 0x%" PRIx64 ".\n",
+ port_guid);
+
+ status = __osm_vendor_open_ca(p_vend, port_guid);
+ if (status != IB_SUCCESS) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "osm_vendor_bind: ERR 3B17: "
+ "Unable to Open CA (%s).\n",
+ ib_get_err_str(status));
+ goto Exit;
+ }
+ }
+
+ p_bind = malloc(sizeof(*p_bind));
+ if (p_bind == NULL) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "osm_vendor_bind: ERR 3B18: "
+ "Unable to allocate internal bind object.\n");
+ goto Exit;
+ }
+
+ memset(p_bind, 0, sizeof(*p_bind));
+ p_bind->p_vend = p_vend;
+ p_bind->client_context = context;
+ p_bind->port_num = osm_vendor_get_port_num(p_vend, port_guid);
+ p_bind->rcv_callback = mad_recv_callback;
+ p_bind->send_err_callback = send_err_callback;
+ p_bind->p_osm_pool = p_mad_pool;
+
+ CL_ASSERT(p_bind->port_num);
+
+ /*
+ Get the proper QP.
+ */
+ memset(&qp_create, 0, sizeof(qp_create));
+
+ switch (p_user_bind->mad_class) {
+ case IB_MCLASS_SUBN_LID:
+ case IB_MCLASS_SUBN_DIR:
+ qp_create.qp_type = IB_QPT_QP0_ALIAS;
+ break;
+
+ case IB_MCLASS_SUBN_ADM:
+ default:
+ qp_create.qp_type = IB_QPT_QP1_ALIAS;
+ break;
+ }
+
+ qp_create.sq_depth = p_user_bind->send_q_size;
+ qp_create.rq_depth = p_user_bind->recv_q_size;
+ qp_create.sq_sge = OSM_AL_SQ_SGE;
+ qp_create.rq_sge = OSM_AL_RQ_SGE;
+
+ status = ib_get_spl_qp(p_vend->h_pd,
+ port_guid,
+ &qp_create,
+ p_bind,
+ __osm_al_err_callback,
+ &p_bind->pool_key, &p_bind->h_qp);
+
+ if (status != IB_SUCCESS) {
+ free(p_bind);
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "osm_vendor_bind: ERR 3B19: "
+ "Unable to get QP handle (%s).\n",
+ ib_get_err_str(status));
+ goto Exit;
+ }
+
+ CL_ASSERT(p_bind->h_qp);
+ CL_ASSERT(p_bind->pool_key);
+
+ memset(&mad_svc, 0, sizeof(mad_svc));
+
+ mad_svc.mad_svc_context = p_bind;
+ mad_svc.pfn_mad_send_cb = __osm_al_send_callback;
+ mad_svc.pfn_mad_recv_cb = __osm_al_rcv_callback;
+ mad_svc.mgmt_class = p_user_bind->mad_class;
+ mad_svc.mgmt_version = p_user_bind->class_version;
+ mad_svc.support_unsol = p_user_bind->is_responder;
+ mad_svc.method_array[IB_MAD_METHOD_GET] = TRUE;
+ mad_svc.method_array[IB_MAD_METHOD_SET] = TRUE;
+ mad_svc.method_array[IB_MAD_METHOD_DELETE] = TRUE;
+ mad_svc.method_array[IB_MAD_METHOD_TRAP] = TRUE;
+ mad_svc.method_array[IB_MAD_METHOD_GETTABLE] = TRUE;
+
+ status = ib_reg_mad_svc(p_bind->h_qp, &mad_svc, &p_bind->h_svc);
+
+ if (status != IB_SUCCESS) {
+ free(p_bind);
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "osm_vendor_bind: ERR 3B21: "
+ "Unable to register QP0 MAD service (%s).\n",
+ ib_get_err_str(status));
+ goto Exit;
+ }
+
+ __osm_vendor_init_av(p_bind, &av);
+
+ status = ib_create_av(p_vend->h_pd, &av, &p_bind->h_dr_av);
+ if (status != IB_SUCCESS) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "osm_vendor_bind: ERR 3B22: "
+ "Unable to create address vector (%s).\n",
+ ib_get_err_str(status));
+
+ goto Exit;
+ }
+
+ if (osm_log_is_active(p_vend->p_log, OSM_LOG_DEBUG)) {
+ osm_log(p_vend->p_log, OSM_LOG_DEBUG,
+ "osm_vendor_bind: "
+ "Allocating av handle %p.\n", p_bind->h_dr_av);
+ }
+
+Exit:
+ OSM_LOG_EXIT(p_vend->p_log);
+ return ((osm_bind_handle_t) p_bind);
+}
+
+ib_mad_t *osm_vendor_get(IN osm_bind_handle_t h_bind,
+ IN const uint32_t mad_size,
+ IN osm_vend_wrap_t * const p_vw)
+{
+ ib_mad_t *p_mad;
+ osm_al_bind_info_t *p_bind = (osm_al_bind_info_t *) h_bind;
+ osm_vendor_t *p_vend = p_bind->p_vend;
+ ib_api_status_t status;
+
+ OSM_LOG_ENTER(p_vend->p_log);
+
+ CL_ASSERT(p_vw);
+
+ p_vw->size = mad_size;
+ p_vw->h_bind = h_bind;
+
+ /*
+ Retrieve a MAD element from the pool and give the user direct
+ access to its buffer.
+ */
+ status = ib_get_mad(p_bind->pool_key, mad_size, &p_vw->p_elem);
+ if (status != IB_SUCCESS) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "osm_vendor_get: ERR 3B25: "
+ "Unable to acquire MAD (%s).\n",
+ ib_get_err_str(status));
+
+ p_mad = NULL;
+ goto Exit;
+ }
+
+ CL_ASSERT(p_vw->p_elem);
+ p_mad = ib_get_mad_buf(p_vw->p_elem);
+
+ if (osm_log_get_level(p_vend->p_log) >= OSM_LOG_DEBUG) {
+ osm_log(p_vend->p_log, OSM_LOG_DEBUG,
+ "osm_vendor_get: "
+ "Acquired MAD %p, size = %u.\n", p_mad, mad_size);
+ }
+
+Exit:
+ OSM_LOG_EXIT(p_vend->p_log);
+ return (p_mad);
+}
+
+void
+osm_vendor_put(IN osm_bind_handle_t h_bind, IN osm_vend_wrap_t * const p_vw)
+{
+ osm_al_bind_info_t *p_bind = (osm_al_bind_info_t *) h_bind;
+ osm_vendor_t *p_vend = p_bind->p_vend;
+ ib_api_status_t status;
+
+ OSM_LOG_ENTER(p_vend->p_log);
+
+ CL_ASSERT(p_vw);
+ CL_ASSERT(p_vw->p_elem);
+ CL_ASSERT(p_vw->h_bind == h_bind);
+
+ if (osm_log_get_level(p_vend->p_log) >= OSM_LOG_DEBUG) {
+ osm_log(p_vend->p_log, OSM_LOG_DEBUG,
+ "osm_vendor_put: "
+ "Retiring MAD %p.\n", ib_get_mad_buf(p_vw->p_elem));
+ }
+
+ status = ib_put_mad(p_vw->p_elem);
+ if (status != IB_SUCCESS) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "osm_vendor_put: ERR 3B26: "
+ "Unable to retire MAD (%s).\n", ib_get_err_str(status));
+ }
+
+ OSM_LOG_EXIT(p_vend->p_log);
+}
+
+ib_api_status_t
+osm_vendor_send(IN osm_bind_handle_t h_bind,
+ IN osm_madw_t * const p_madw, IN boolean_t const resp_expected)
+{
+ osm_al_bind_info_t *const p_bind = h_bind;
+ osm_vendor_t *const p_vend = p_bind->p_vend;
+ osm_vend_wrap_t *const p_vw = osm_madw_get_vend_ptr(p_madw);
+ osm_mad_addr_t *const p_mad_addr = osm_madw_get_mad_addr_ptr(p_madw);
+ ib_mad_t *const p_mad = osm_madw_get_mad_ptr(p_madw);
+ ib_api_status_t status;
+ ib_mad_element_t *p_elem;
+ ib_av_attr_t av;
+
+ OSM_LOG_ENTER(p_vend->p_log);
+
+ CL_ASSERT(p_vw->h_bind == h_bind);
+ CL_ASSERT(p_vw->p_elem);
+
+ p_elem = p_vw->p_elem;
+
+ /*
+ If a response is expected to this MAD, then preallocate
+ a mad wrapper to contain the wire MAD received in the
+ response. Allocating a wrapper here allows for easier
+ failure paths than after we already received the wire mad.
+ */
+ if (resp_expected) {
+ p_vw->p_resp_madw =
+ osm_mad_pool_get_wrapper_raw(p_bind->p_osm_pool);
+ if (p_vw->p_resp_madw == NULL) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "osm_vendor_send: ERR 3B27: "
+ "Unable to allocate MAD wrapper.\n");
+ status = IB_INSUFFICIENT_RESOURCES;
+ goto Exit;
+ }
+ } else
+ p_vw->p_resp_madw = NULL;
+
+ /*
+ For all sends other than directed route SM MADs,
+ acquire an address vector for the destination.
+ */
+ if (p_mad->mgmt_class != IB_MCLASS_SUBN_DIR) {
+ memset(&av, 0, sizeof(av));
+ av.port_num = p_bind->port_num;
+ av.dlid = p_mad_addr->dest_lid;
+ av.static_rate = p_mad_addr->static_rate;
+ av.path_bits = p_mad_addr->path_bits;
+
+ if ((p_mad->mgmt_class != IB_MCLASS_SUBN_LID) &&
+ (p_mad->mgmt_class != IB_MCLASS_SUBN_DIR)) {
+ av.sl = p_mad_addr->addr_type.gsi.service_level;
+
+ if (p_mad_addr->addr_type.gsi.global_route) {
+ av.grh_valid = TRUE;
+ /* ANIL */
+ /* av.grh = p_mad_addr->addr_type.gsi.grh_info; */
+ }
+ }
+
+ if (osm_log_is_active(p_vend->p_log, OSM_LOG_DEBUG)) {
+ osm_log(p_vend->p_log, OSM_LOG_DEBUG,
+ "osm_vendor_send: "
+ "av.port_num 0x%X, "
+ "av.dlid 0x%X, "
+ "av.static_rate %d, "
+ "av.path_bits %d.\n",
+ av.port_num, cl_ntoh16(av.dlid),
+ av.static_rate, av.path_bits);
+ }
+
+ status = ib_create_av(p_vend->h_pd, &av, &p_vw->h_av);
+ if (status != IB_SUCCESS) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "osm_vendor_send: ERR 3B28: "
+ "Unable to create address vector (%s).\n",
+ ib_get_err_str(status));
+
+ if (p_vw->p_resp_madw)
+ osm_mad_pool_put(p_bind->p_osm_pool,
+ p_vw->p_resp_madw);
+ goto Exit;
+ }
+
+ if (osm_log_is_active(p_vend->p_log, OSM_LOG_DEBUG)) {
+ osm_log(p_vend->p_log, OSM_LOG_DEBUG,
+ "osm_vendor_send: "
+ "Allocating av handle %p.\n", p_vw->h_av);
+ }
+ } else {
+ p_vw->h_av = p_bind->h_dr_av;
+ }
+
+ p_elem->h_av = p_vw->h_av;
+
+ p_elem->context1 = p_madw;
+ p_elem->context2 = NULL;
+
+ p_elem->immediate_data = 0;
+ p_elem->p_grh = NULL;
+ p_elem->resp_expected = resp_expected;
+ p_elem->retry_cnt = OSM_DEFAULT_RETRY_COUNT;
+
+ p_elem->send_opt = IB_SEND_OPT_SIGNALED;
+ p_elem->timeout_ms = p_vend->timeout;
+
+ /* Completion information. */
+ p_elem->status = 0; /* Not trusting AL */
+
+ if ((p_mad->mgmt_class == IB_MCLASS_SUBN_LID) ||
+ (p_mad->mgmt_class == IB_MCLASS_SUBN_DIR)) {
+ p_elem->remote_qp = 0;
+ p_elem->remote_qkey = 0;
+ } else {
+ p_elem->remote_qp = p_mad_addr->addr_type.gsi.remote_qp;
+ p_elem->remote_qkey = p_mad_addr->addr_type.gsi.remote_qkey;
+ osm_log(p_vend->p_log, OSM_LOG_DEBUG,
+ "osm_vendor_send: "
+ "remote qp = 0x%X, remote qkey = 0x%X.\n",
+ cl_ntoh32(p_elem->remote_qp),
+ cl_ntoh32(p_elem->remote_qkey));
+ }
+
+ status = ib_send_mad(p_bind->h_svc, p_elem, NULL);
+ if (status != IB_SUCCESS) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "osm_vendor_send: ERR 3B29: "
+ "Send failed (%s).\n", ib_get_err_str(status));
+ if (p_vw->p_resp_madw)
+ osm_mad_pool_put(p_bind->p_osm_pool, p_vw->p_resp_madw);
+ goto Exit;
+ }
+
+Exit:
+ OSM_LOG_EXIT(p_vend->p_log);
+ return (status);
+}
+
+ib_api_status_t osm_vendor_local_lid_change(IN osm_bind_handle_t h_bind)
+{
+ osm_al_bind_info_t *p_bind = (osm_al_bind_info_t *) h_bind;
+ osm_vendor_t *p_vend = p_bind->p_vend;
+ ib_av_attr_t av;
+ ib_api_status_t status;
+
+ OSM_LOG_ENTER(p_vend->p_log);
+
+ /*
+ The only thing we need to do is refresh the directed
+ route address vector.
+ */
+ __osm_vendor_init_av(p_bind, &av);
+
+ status = ib_destroy_av(p_bind->h_dr_av);
+ if (status != IB_SUCCESS) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "osm_vendor_local_lid_change: ERR 3B32: "
+ "Unable to destroy address vector (%s).\n",
+ ib_get_err_str(status));
+
+ goto Exit;
+ }
+
+ status = ib_create_av(p_vend->h_pd, &av, &p_bind->h_dr_av);
+ if (status != IB_SUCCESS) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "osm_vendor_local_lid_change: ERR 3B33: "
+ "Unable to create address vector (%s).\n",
+ ib_get_err_str(status));
+
+ goto Exit;
+ }
+
+Exit:
+ OSM_LOG_EXIT(p_vend->p_log);
+ return (status);
+}
+
+void osm_vendor_set_sm(IN osm_bind_handle_t h_bind, IN boolean_t is_sm_val)
+{
+ osm_al_bind_info_t *p_bind = (osm_al_bind_info_t *) h_bind;
+ osm_vendor_t *p_vend = p_bind->p_vend;
+ ib_api_status_t status;
+ ib_port_attr_mod_t attr_mod;
+
+ OSM_LOG_ENTER(p_vend->p_log);
+
+ memset(&attr_mod, 0, sizeof(attr_mod));
+
+ attr_mod.cap.sm = is_sm_val;
+
+ status = ib_modify_ca(p_vend->h_ca, p_bind->port_num,
+ IB_CA_MOD_IS_SM, &attr_mod);
+
+ if (status != IB_SUCCESS) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "osm_vendor_set_sm: ERR 3B34: "
+ "Unable set 'IS_SM' bit to:%u in port attributes (%s).\n",
+ is_sm_val, ib_get_err_str(status));
+ }
+
+ OSM_LOG_EXIT(p_vend->p_log);
+}
+
+void osm_vendor_set_debug(IN osm_vendor_t * const p_vend, IN int32_t level)
+{
+
+}
+
+#endif /* OSM_VENDOR_INTF_AL */
diff --git a/contrib/ofed/opensm/libvendor/osm_vendor_ibumad.c b/contrib/ofed/opensm/libvendor/osm_vendor_ibumad.c
new file mode 100644
index 0000000..6708a78
--- /dev/null
+++ b/contrib/ofed/opensm/libvendor/osm_vendor_ibumad.c
@@ -0,0 +1,1266 @@
+/*
+ * Copyright (c) 2004-2009 Voltaire, Inc. All rights reserved.
+ * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved.
+ * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
+ * Copyright (c) 2009 HNR Consulting. All rights reserved.
+ * Copyright (c) 2009 Sun Microsystems, Inc. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+/*
+ * Abstract:
+ * Implementation of osm_vendor_t (for umad).
+ * This object represents the OpenIB vendor layer.
+ * This object is part of the opensm family of objects.
+ *
+ * Environment:
+ * Linux User Mode
+ *
+ */
+
+#if HAVE_CONFIG_H
+# include <config.h>
+#endif /* HAVE_CONFIG_H */
+
+#ifdef OSM_VENDOR_INTF_OPENIB
+
+#include <unistd.h>
+#include <stdlib.h>
+#include <fcntl.h>
+#include <errno.h>
+
+#include <iba/ib_types.h>
+#include <complib/cl_qlist.h>
+#include <complib/cl_math.h>
+#include <complib/cl_debug.h>
+#include <opensm/osm_file_ids.h>
+#define FILE_ID OSM_FILE_VENDOR_IBUMAD_C
+#include <opensm/osm_madw.h>
+#include <opensm/osm_log.h>
+#include <opensm/osm_mad_pool.h>
+#include <opensm/osm_helper.h>
+#include <vendor/osm_vendor_api.h>
+
+/****s* OpenSM: Vendor UMAD/osm_umad_bind_info_t
+ * NAME
+ * osm_umad_bind_info_t
+ *
+ * DESCRIPTION
+ * Structure containing bind information.
+ *
+ * SYNOPSIS
+ */
+typedef struct _osm_umad_bind_info {
+ osm_vendor_t *p_vend;
+ void *client_context;
+ osm_mad_pool_t *p_mad_pool;
+ osm_vend_mad_recv_callback_t mad_recv_callback;
+ osm_vend_mad_send_err_callback_t send_err_callback;
+ ib_net64_t port_guid;
+ int port_id;
+ int agent_id;
+ int agent_id1; /* SMI requires two agents */
+ int timeout;
+ int max_retries;
+} osm_umad_bind_info_t;
+
+typedef struct _umad_receiver {
+ pthread_t tid;
+ osm_vendor_t *p_vend;
+ osm_log_t *p_log;
+} umad_receiver_t;
+
+static void osm_vendor_close_port(osm_vendor_t * const p_vend);
+
+static void log_send_error(osm_vendor_t * const p_vend, osm_madw_t *p_madw)
+{
+ if (p_madw->p_mad->mgmt_class != IB_MCLASS_SUBN_DIR) {
+ /* LID routed */
+ OSM_LOG(p_vend->p_log, OSM_LOG_ERROR, "ERR 5410: "
+ "Send completed with error (%s) -- dropping\n"
+ "\t\t\tClass 0x%x, Method 0x%X, Attr 0x%X, "
+ "TID 0x%" PRIx64 ", LID %u\n",
+ ib_get_err_str(p_madw->status),
+ p_madw->p_mad->mgmt_class, p_madw->p_mad->method,
+ cl_ntoh16(p_madw->p_mad->attr_id),
+ cl_ntoh64(p_madw->p_mad->trans_id),
+ cl_ntoh16(p_madw->mad_addr.dest_lid));
+ } else {
+ ib_smp_t *p_smp;
+
+ /* Direct routed SMP */
+ p_smp = osm_madw_get_smp_ptr(p_madw);
+ OSM_LOG(p_vend->p_log, OSM_LOG_ERROR, "ERR 5411: "
+ "DR SMP Send completed with error (%s) -- dropping\n"
+ "\t\t\tMethod 0x%X, Attr 0x%X, TID 0x%" PRIx64 "\n",
+ ib_get_err_str(p_madw->status),
+ p_madw->p_mad->method,
+ cl_ntoh16(p_madw->p_mad->attr_id),
+ cl_ntoh64(p_madw->p_mad->trans_id));
+ osm_dump_smp_dr_path(p_vend->p_log, p_smp, OSM_LOG_ERROR);
+ }
+}
+
+static void clear_madw(osm_vendor_t * p_vend)
+{
+ umad_match_t *m, *e, *old_m;
+ ib_net64_t old_tid;
+ uint8_t old_mgmt_class;
+
+ OSM_LOG_ENTER(p_vend->p_log);
+ pthread_mutex_lock(&p_vend->match_tbl_mutex);
+ for (m = p_vend->mtbl.tbl, e = m + p_vend->mtbl.max; m < e; m++) {
+ if (m->tid) {
+ old_m = m;
+ old_tid = m->tid;
+ old_mgmt_class = m->mgmt_class;
+ m->tid = 0;
+ osm_mad_pool_put(((osm_umad_bind_info_t
+ *) ((osm_madw_t *) m->v)->h_bind)->
+ p_mad_pool, m->v);
+ pthread_mutex_unlock(&p_vend->match_tbl_mutex);
+ OSM_LOG(p_vend->p_log, OSM_LOG_ERROR, "ERR 5401: "
+ "evicting entry %p (tid was 0x%" PRIx64
+ " mgmt class 0x%x)\n",
+ old_m, cl_ntoh64(old_tid), old_mgmt_class);
+ goto Exit;
+ }
+ }
+ pthread_mutex_unlock(&p_vend->match_tbl_mutex);
+
+Exit:
+ OSM_LOG_EXIT(p_vend->p_log);
+}
+
+static osm_madw_t *get_madw(osm_vendor_t * p_vend, ib_net64_t * tid,
+ uint8_t mgmt_class)
+{
+ umad_match_t *m, *e;
+ ib_net64_t mtid = (*tid & CL_HTON64(0x00000000ffffffffULL));
+ osm_madw_t *res;
+
+ /*
+ * Since mtid == 0 is the empty key, we should not
+ * waste time looking for it
+ */
+ if (mtid == 0 || mgmt_class == 0)
+ return 0;
+
+ pthread_mutex_lock(&p_vend->match_tbl_mutex);
+ for (m = p_vend->mtbl.tbl, e = m + p_vend->mtbl.max; m < e; m++) {
+ if (m->tid == mtid && m->mgmt_class == mgmt_class) {
+ m->tid = 0;
+ m->mgmt_class = 0;
+ *tid = mtid;
+ res = m->v;
+ pthread_mutex_unlock(&p_vend->match_tbl_mutex);
+ return res;
+ }
+ }
+
+ pthread_mutex_unlock(&p_vend->match_tbl_mutex);
+ return 0;
+}
+
+/*
+ * If match table full, evict LRU (least recently used) transaction.
+ * Maintain 2 LRUs: one for SMPs, and one for others (GS).
+ * Evict LRU GS transaction if one is available and only evict LRU SMP
+ * transaction if no other choice.
+ */
+static void
+put_madw(osm_vendor_t * p_vend, osm_madw_t * p_madw, ib_net64_t tid,
+ uint8_t mgmt_class)
+{
+ umad_match_t *m, *e, *old_lru, *lru = 0, *lru_smp = 0;
+ osm_madw_t *p_req_madw;
+ osm_umad_bind_info_t *p_bind;
+ ib_net64_t old_tid;
+ uint32_t oldest = ~0, oldest_smp = ~0;
+ uint8_t old_mgmt_class;
+
+ pthread_mutex_lock(&p_vend->match_tbl_mutex);
+ for (m = p_vend->mtbl.tbl, e = m + p_vend->mtbl.max; m < e; m++) {
+ if (m->tid == 0 && m->mgmt_class == 0) {
+ m->tid = tid;
+ m->mgmt_class = mgmt_class;
+ m->v = p_madw;
+ m->version =
+ cl_atomic_inc((atomic32_t *) & p_vend->mtbl.
+ last_version);
+ pthread_mutex_unlock(&p_vend->match_tbl_mutex);
+ return;
+ }
+ if (m->mgmt_class == IB_MCLASS_SUBN_DIR ||
+ m->mgmt_class == IB_MCLASS_SUBN_LID) {
+ if (oldest_smp >= m->version) {
+ oldest_smp = m->version;
+ lru_smp = m;
+ }
+ } else {
+ if (oldest >= m->version) {
+ oldest = m->version;
+ lru = m;
+ }
+ }
+ }
+
+ if (oldest != ~0) {
+ old_lru = lru;
+ old_tid = lru->tid;
+ old_mgmt_class = lru->mgmt_class;
+ } else {
+ CL_ASSERT(oldest_smp != ~0);
+ old_lru = lru_smp;
+ old_tid = lru_smp->tid;
+ old_mgmt_class = lru_smp->mgmt_class;
+ }
+ p_req_madw = old_lru->v;
+ p_bind = p_req_madw->h_bind;
+ p_req_madw->status = IB_CANCELED;
+ log_send_error(p_vend, p_req_madw);
+ pthread_mutex_lock(&p_vend->cb_mutex);
+ (*p_bind->send_err_callback) (p_bind->client_context, p_req_madw);
+ pthread_mutex_unlock(&p_vend->cb_mutex);
+ if (mgmt_class == IB_MCLASS_SUBN_DIR ||
+ mgmt_class == IB_MCLASS_SUBN_LID) {
+ lru_smp->tid = tid;
+ lru_smp->mgmt_class = mgmt_class;
+ lru_smp->v = p_madw;
+ lru_smp->version =
+ cl_atomic_inc((atomic32_t *) & p_vend->mtbl.last_version);
+ } else {
+ lru->tid = tid;
+ lru->mgmt_class = mgmt_class;
+ lru->v = p_madw;
+ lru->version =
+ cl_atomic_inc((atomic32_t *) & p_vend->mtbl.last_version);
+ }
+ pthread_mutex_unlock(&p_vend->match_tbl_mutex);
+ OSM_LOG(p_vend->p_log, OSM_LOG_ERROR, "ERR 5402: "
+ "evicting entry %p (tid was 0x%" PRIx64
+ " mgmt class 0x%x)\n", old_lru,
+ cl_ntoh64(old_tid), old_mgmt_class);
+}
+
+static void
+ib_mad_addr_conv(ib_user_mad_t * umad, osm_mad_addr_t * osm_mad_addr,
+ int is_smi)
+{
+ ib_mad_addr_t *ib_mad_addr = umad_get_mad_addr(umad);
+
+ memset(osm_mad_addr, 0, sizeof(osm_mad_addr_t));
+ osm_mad_addr->dest_lid = ib_mad_addr->lid;
+ osm_mad_addr->path_bits = ib_mad_addr->path_bits;
+
+ if (is_smi) {
+ osm_mad_addr->addr_type.smi.source_lid = osm_mad_addr->dest_lid;
+ osm_mad_addr->addr_type.smi.port_num = 255; /* not used */
+ return;
+ }
+
+ osm_mad_addr->addr_type.gsi.remote_qp = ib_mad_addr->qpn;
+ osm_mad_addr->addr_type.gsi.remote_qkey = ib_mad_addr->qkey;
+ osm_mad_addr->addr_type.gsi.pkey_ix = umad_get_pkey(umad);
+ osm_mad_addr->addr_type.gsi.service_level = ib_mad_addr->sl;
+ if (ib_mad_addr->grh_present) {
+ osm_mad_addr->addr_type.gsi.global_route = 1;
+ osm_mad_addr->addr_type.gsi.grh_info.hop_limit = ib_mad_addr->hop_limit;
+ osm_mad_addr->addr_type.gsi.grh_info.ver_class_flow =
+ ib_grh_set_ver_class_flow(6, /* GRH version */
+ ib_mad_addr->traffic_class,
+ ib_mad_addr->flow_label);
+ memcpy(&osm_mad_addr->addr_type.gsi.grh_info.dest_gid,
+ &ib_mad_addr->gid, 16);
+ }
+}
+
+static void *swap_mad_bufs(osm_madw_t * p_madw, void *umad)
+{
+ void *old;
+
+ old = p_madw->vend_wrap.umad;
+ p_madw->vend_wrap.umad = umad;
+ p_madw->p_mad = umad_get_mad(umad);
+
+ return old;
+}
+
+static void unlock_mutex(void *arg)
+{
+ pthread_mutex_unlock(arg);
+}
+
+static void *umad_receiver(void *p_ptr)
+{
+ umad_receiver_t *const p_ur = (umad_receiver_t *) p_ptr;
+ osm_vendor_t *p_vend = p_ur->p_vend;
+ osm_umad_bind_info_t *p_bind;
+ osm_mad_addr_t osm_addr;
+ osm_madw_t *p_madw, *p_req_madw;
+ ib_mad_t *p_mad, *p_req_mad;
+ void *umad = 0;
+ int mad_agent, length;
+
+ OSM_LOG_ENTER(p_ur->p_log);
+
+ for (;;) {
+ if (!umad &&
+ !(umad = umad_alloc(1, umad_size() + MAD_BLOCK_SIZE))) {
+ OSM_LOG(p_ur->p_log, OSM_LOG_ERROR, "ERR 5403: "
+ "can't alloc MAD sized umad\n");
+ break;
+ }
+
+ length = MAD_BLOCK_SIZE;
+ if ((mad_agent = umad_recv(p_vend->umad_port_id, umad,
+ &length, -1)) < 0) {
+ if (length <= MAD_BLOCK_SIZE) {
+ OSM_LOG(p_ur->p_log, OSM_LOG_ERROR, "ERR 5404: "
+ "recv error on MAD sized umad (%m)\n");
+ continue;
+ } else {
+ umad_free(umad);
+ /* Need a larger buffer for RMPP */
+ umad = umad_alloc(1, umad_size() + length);
+ if (!umad) {
+ OSM_LOG(p_ur->p_log, OSM_LOG_ERROR,
+ "ERR 5405: "
+ "can't alloc umad length %d\n",
+ length);
+ continue;
+ }
+
+ if ((mad_agent = umad_recv(p_vend->umad_port_id,
+ umad, &length,
+ -1)) < 0) {
+ OSM_LOG(p_ur->p_log, OSM_LOG_ERROR,
+ "ERR 5406: "
+ "recv error on umad length %d (%m)\n",
+ length);
+ continue;
+ }
+ }
+ }
+
+ if (mad_agent >= OSM_UMAD_MAX_AGENTS ||
+ !(p_bind = p_vend->agents[mad_agent])) {
+ OSM_LOG(p_ur->p_log, OSM_LOG_ERROR, "ERR 5407: "
+ "invalid mad agent %d - dropping\n", mad_agent);
+ continue;
+ }
+
+ p_mad = (ib_mad_t *) umad_get_mad(umad);
+
+ ib_mad_addr_conv(umad, &osm_addr,
+ p_mad->mgmt_class == IB_MCLASS_SUBN_LID ||
+ p_mad->mgmt_class == IB_MCLASS_SUBN_DIR);
+
+ if (!(p_madw = osm_mad_pool_get(p_bind->p_mad_pool,
+ (osm_bind_handle_t) p_bind,
+ MAX(length, MAD_BLOCK_SIZE),
+ &osm_addr))) {
+ OSM_LOG(p_vend->p_log, OSM_LOG_ERROR, "ERR 5408: "
+ "request for a new madw failed -- dropping packet\n");
+ continue;
+ }
+
+ /* Need to fix up MAD size if short RMPP packet */
+ if (length < MAD_BLOCK_SIZE)
+ p_madw->mad_size = length;
+
+ /*
+ * Avoid copying by swapping mad buf pointers.
+ * Do not use umad after this line of code.
+ */
+ umad = swap_mad_bufs(p_madw, umad);
+
+ /* if status != 0 then we are handling recv timeout on send */
+ if (umad_status(p_madw->vend_wrap.umad)) {
+ if (!(p_req_madw = get_madw(p_vend, &p_mad->trans_id,
+ p_mad->mgmt_class))) {
+ OSM_LOG(p_vend->p_log, OSM_LOG_ERROR,
+ "ERR 5412: "
+ "Failed to obtain request madw for timed out MAD"
+ " (class=0x%X method=0x%X attr=0x%X tid=0x%"PRIx64") -- dropping\n",
+ p_mad->mgmt_class, p_mad->method,
+ cl_ntoh16(p_mad->attr_id),
+ cl_ntoh64(p_mad->trans_id));
+ } else {
+ p_req_madw->status = IB_TIMEOUT;
+ log_send_error(p_vend, p_req_madw);
+ /* cb frees req_madw */
+ pthread_mutex_lock(&p_vend->cb_mutex);
+ pthread_cleanup_push(unlock_mutex,
+ &p_vend->cb_mutex);
+ (*p_bind->send_err_callback) (p_bind->
+ client_context,
+ p_req_madw);
+ pthread_cleanup_pop(1);
+ }
+
+ osm_mad_pool_put(p_bind->p_mad_pool, p_madw);
+ continue;
+ }
+
+ p_req_madw = 0;
+ if (ib_mad_is_response(p_mad)) {
+ p_req_madw = get_madw(p_vend, &p_mad->trans_id,
+ p_mad->mgmt_class);
+ if (PF(!p_req_madw)) {
+ OSM_LOG(p_vend->p_log, OSM_LOG_ERROR,
+ "ERR 5413: Failed to obtain request "
+ "madw for received MAD "
+ "(class=0x%X method=0x%X attr=0x%X "
+ "tid=0x%"PRIx64") -- dropping\n",
+ p_mad->mgmt_class, p_mad->method,
+ cl_ntoh16(p_mad->attr_id),
+ cl_ntoh64(p_mad->trans_id));
+ osm_mad_pool_put(p_bind->p_mad_pool, p_madw);
+ continue;
+ }
+
+ /*
+ * Check that request MAD was really a request,
+ * and make sure that attribute ID, attribute
+ * modifier and transaction ID are the same in
+ * request and response.
+ *
+ * Exception for o15-0.2-1.11:
+ * SA response to a SubnAdmGetMulti() containing a
+ * MultiPathRecord shall have PathRecord attribute ID.
+ */
+ p_req_mad = osm_madw_get_mad_ptr(p_req_madw);
+ if (PF(ib_mad_is_response(p_req_mad) ||
+ (p_mad->attr_id != p_req_mad->attr_id &&
+ !(p_mad->mgmt_class == IB_MCLASS_SUBN_ADM &&
+ p_req_mad->attr_id ==
+ IB_MAD_ATTR_MULTIPATH_RECORD &&
+ p_mad->attr_id == IB_MAD_ATTR_PATH_RECORD)) ||
+ p_mad->attr_mod != p_req_mad->attr_mod ||
+ p_mad->trans_id != p_req_mad->trans_id)) {
+ OSM_LOG(p_vend->p_log, OSM_LOG_ERROR,
+ "ERR 541A: "
+ "Response MAD validation failed "
+ "(request attr=0x%X modif=0x%X "
+ "tid=0x%"PRIx64", "
+ "response attr=0x%X modif=0x%X "
+ "tid=0x%"PRIx64") -- dropping\n",
+ cl_ntoh16(p_req_mad->attr_id),
+ cl_ntoh32(p_req_mad->attr_mod),
+ cl_ntoh64(p_req_mad->trans_id),
+ cl_ntoh16(p_mad->attr_id),
+ cl_ntoh32(p_mad->attr_mod),
+ cl_ntoh64(p_mad->trans_id));
+ osm_mad_pool_put(p_bind->p_mad_pool, p_madw);
+ continue;
+ }
+ }
+
+#ifndef VENDOR_RMPP_SUPPORT
+ if ((p_mad->mgmt_class != IB_MCLASS_SUBN_DIR) &&
+ (p_mad->mgmt_class != IB_MCLASS_SUBN_LID) &&
+ (ib_rmpp_is_flag_set((ib_rmpp_mad_t *) p_mad,
+ IB_RMPP_FLAG_ACTIVE))) {
+ OSM_LOG(p_vend->p_log, OSM_LOG_ERROR, "ERR 5414: "
+ "class 0x%x method 0x%x RMPP version %d type "
+ "%d flags 0x%x received -- dropping\n",
+ p_mad->mgmt_class, p_mad->method,
+ ((ib_rmpp_mad_t *) p_mad)->rmpp_version,
+ ((ib_rmpp_mad_t *) p_mad)->rmpp_type,
+ ((ib_rmpp_mad_t *) p_mad)->rmpp_flags);
+ osm_mad_pool_put(p_bind->p_mad_pool, p_madw);
+ continue;
+ }
+#endif
+
+ /* call the CB */
+ pthread_mutex_lock(&p_vend->cb_mutex);
+ pthread_cleanup_push(unlock_mutex, &p_vend->cb_mutex);
+ (*p_bind->mad_recv_callback) (p_madw, p_bind->client_context,
+ p_req_madw);
+ pthread_cleanup_pop(1);
+ }
+
+ OSM_LOG_EXIT(p_vend->p_log);
+ return NULL;
+}
+
+static int umad_receiver_start(osm_vendor_t * p_vend)
+{
+ umad_receiver_t *p_ur = p_vend->receiver;
+
+ p_ur->p_vend = p_vend;
+ p_ur->p_log = p_vend->p_log;
+
+ if (pthread_create(&p_ur->tid, NULL, umad_receiver, p_ur) != 0)
+ return -1;
+
+ return 0;
+}
+
+static void umad_receiver_stop(umad_receiver_t * p_ur)
+{
+ pthread_cancel(p_ur->tid);
+ pthread_join(p_ur->tid, NULL);
+ p_ur->tid = 0;
+ p_ur->p_vend = NULL;
+ p_ur->p_log = NULL;
+}
+
+ib_api_status_t
+osm_vendor_init(IN osm_vendor_t * const p_vend,
+ IN osm_log_t * const p_log, IN const uint32_t timeout)
+{
+ char *max = NULL;
+ int r, n_cas;
+
+ OSM_LOG_ENTER(p_log);
+
+ p_vend->p_log = p_log;
+ p_vend->timeout = timeout;
+ p_vend->max_retries = OSM_DEFAULT_RETRY_COUNT;
+ pthread_mutex_init(&p_vend->cb_mutex, NULL);
+ pthread_mutex_init(&p_vend->match_tbl_mutex, NULL);
+ p_vend->umad_port_id = -1;
+ p_vend->issmfd = -1;
+
+ /*
+ * Open our instance of UMAD.
+ */
+ if ((r = umad_init()) < 0) {
+ OSM_LOG(p_vend->p_log, OSM_LOG_ERROR,
+ "ERR 5415: Error opening UMAD\n");
+ }
+
+ if ((n_cas = umad_get_cas_names(p_vend->ca_names,
+ OSM_UMAD_MAX_CAS)) < 0) {
+ OSM_LOG(p_vend->p_log, OSM_LOG_ERROR,
+ "ERR 5416: umad_get_cas_names failed\n");
+ r = n_cas;
+ goto Exit;
+ }
+
+ p_vend->ca_count = n_cas;
+ p_vend->mtbl.max = DEFAULT_OSM_UMAD_MAX_PENDING;
+
+ if ((max = getenv("OSM_UMAD_MAX_PENDING")) != NULL) {
+ int tmp = strtol(max, NULL, 0);
+ if (tmp > 0)
+ p_vend->mtbl.max = tmp;
+ else
+ OSM_LOG(p_vend->p_log, OSM_LOG_ERROR, "Error:"
+ "OSM_UMAD_MAX_PENDING=%d is invalid\n",
+ tmp);
+ }
+
+ OSM_LOG(p_vend->p_log, OSM_LOG_INFO, "%d pending umads specified\n",
+ p_vend->mtbl.max);
+
+ p_vend->mtbl.tbl = calloc(p_vend->mtbl.max, sizeof(*(p_vend->mtbl.tbl)));
+ if (!p_vend->mtbl.tbl) {
+ OSM_LOG(p_vend->p_log, OSM_LOG_ERROR, "Error:"
+ "failed to allocate vendor match table\n");
+ r = IB_INSUFFICIENT_MEMORY;
+ goto Exit;
+ }
+
+Exit:
+ OSM_LOG_EXIT(p_log);
+ return (r);
+}
+
+osm_vendor_t *osm_vendor_new(IN osm_log_t * const p_log,
+ IN const uint32_t timeout)
+{
+ osm_vendor_t *p_vend = NULL;
+
+ OSM_LOG_ENTER(p_log);
+
+ if (!timeout) {
+ OSM_LOG(p_log, OSM_LOG_ERROR, "ERR 5433: "
+ "transaction timeout cannot be 0\n");
+ goto Exit;
+ }
+
+ p_vend = malloc(sizeof(*p_vend));
+ if (p_vend == NULL) {
+ OSM_LOG(p_log, OSM_LOG_ERROR, "ERR 5417: "
+ "Unable to allocate vendor object\n");
+ goto Exit;
+ }
+
+ memset(p_vend, 0, sizeof(*p_vend));
+
+ if (osm_vendor_init(p_vend, p_log, timeout) != IB_SUCCESS) {
+ free(p_vend);
+ p_vend = NULL;
+ }
+
+Exit:
+ OSM_LOG_EXIT(p_log);
+ return (p_vend);
+}
+
+void osm_vendor_delete(IN osm_vendor_t ** const pp_vend)
+{
+ osm_vendor_close_port(*pp_vend);
+
+ clear_madw(*pp_vend);
+ /* make sure all ports are closed */
+ umad_done();
+
+ pthread_mutex_destroy(&(*pp_vend)->cb_mutex);
+ pthread_mutex_destroy(&(*pp_vend)->match_tbl_mutex);
+ free((*pp_vend)->mtbl.tbl);
+ free(*pp_vend);
+ *pp_vend = NULL;
+}
+
+ib_api_status_t
+osm_vendor_get_all_port_attr(IN osm_vendor_t * const p_vend,
+ IN ib_port_attr_t * const p_attr_array,
+ IN uint32_t * const p_num_ports)
+{
+ umad_ca_t ca;
+ ib_port_attr_t *attr = p_attr_array;
+ unsigned done = 0;
+ int r = 0, i, j, k;
+
+ OSM_LOG_ENTER(p_vend->p_log);
+
+ CL_ASSERT(p_vend && p_num_ports);
+
+ if (!*p_num_ports) {
+ r = IB_INVALID_PARAMETER;
+ OSM_LOG(p_vend->p_log, OSM_LOG_ERROR, "ERR 5418: "
+ "Ports in should be > 0\n");
+ goto Exit;
+ }
+
+ if (!p_attr_array) {
+ r = IB_INSUFFICIENT_MEMORY;
+ *p_num_ports = 0;
+ goto Exit;
+ }
+
+ for (i = 0; i < p_vend->ca_count && !done; i++) {
+ /* For each CA, retrieve the port attributes */
+ if (umad_get_ca(p_vend->ca_names[i], &ca) == 0) {
+ if (ca.node_type < 1 || ca.node_type > 3)
+ continue;
+ for (j = 0; j <= ca.numports; j++) {
+ if (!ca.ports[j])
+ continue;
+ attr->port_guid = ca.ports[j]->port_guid;
+ attr->lid = ca.ports[j]->base_lid;
+ attr->port_num = ca.ports[j]->portnum;
+ attr->sm_lid = ca.ports[j]->sm_lid;
+ attr->sm_sl = ca.ports[j]->sm_sl;
+ attr->link_state = ca.ports[j]->state;
+ if (attr->num_pkeys && attr->p_pkey_table) {
+ if (attr->num_pkeys > ca.ports[j]->pkeys_size)
+ attr->num_pkeys = ca.ports[j]->pkeys_size;
+ for (k = 0; k < attr->num_pkeys; k++)
+ attr->p_pkey_table[k] =
+ cl_hton16(ca.ports[j]->pkeys[k]);
+ }
+ attr->num_pkeys = ca.ports[j]->pkeys_size;
+ if (attr->num_gids && attr->p_gid_table) {
+ attr->p_gid_table[0].unicast.prefix = cl_hton64(ca.ports[j]->gid_prefix);
+ attr->p_gid_table[0].unicast.interface_id = cl_hton64(ca.ports[j]->port_guid);
+ attr->num_gids = 1;
+ }
+ attr++;
+ if (attr - p_attr_array > *p_num_ports) {
+ done = 1;
+ break;
+ }
+ }
+ umad_release_ca(&ca);
+ }
+ }
+
+ *p_num_ports = attr - p_attr_array;
+
+Exit:
+ OSM_LOG_EXIT(p_vend->p_log);
+ return r;
+}
+
+static int
+osm_vendor_open_port(IN osm_vendor_t * const p_vend,
+ IN const ib_net64_t port_guid)
+{
+ ib_net64_t portguids[OSM_UMAD_MAX_PORTS_PER_CA + 1];
+ umad_ca_t umad_ca;
+ int i = 0, umad_port_id = -1;
+ char *name;
+ int ca, r;
+
+ CL_ASSERT(p_vend);
+
+ OSM_LOG_ENTER(p_vend->p_log);
+
+ if (p_vend->umad_port_id >= 0) {
+ umad_port_id = p_vend->umad_port_id;
+ goto Exit;
+ }
+
+ if (!port_guid) {
+ name = NULL;
+ i = 0;
+ goto _found;
+ }
+
+ for (ca = 0; ca < p_vend->ca_count; ca++) {
+ if ((r = umad_get_ca_portguids(p_vend->ca_names[ca], portguids,
+ OSM_UMAD_MAX_PORTS_PER_CA + 1)) < 0) {
+#ifdef __WIN__
+ OSM_LOG(p_vend->p_log, OSM_LOG_VERBOSE,
+#else
+ OSM_LOG(p_vend->p_log, OSM_LOG_ERROR, "ERR 5421: "
+#endif
+ "Unable to get CA %s port guids (%s)\n",
+ p_vend->ca_names[ca], strerror(r));
+ continue;
+ }
+ for (i = 0; i < r; i++)
+ if (port_guid == portguids[i]) {
+ name = p_vend->ca_names[ca];
+ goto _found;
+ }
+ }
+
+ /*
+ * No local CA owns this guid!
+ */
+ OSM_LOG(p_vend->p_log, OSM_LOG_ERROR, "ERR 5422: "
+ "Unable to find requested CA guid 0x%" PRIx64 "\n",
+ cl_ntoh64(port_guid));
+ goto Exit;
+
+_found:
+ /* Validate that node is an IB node type (not iWARP) */
+ if (umad_get_ca(name, &umad_ca) < 0) {
+ OSM_LOG(p_vend->p_log, OSM_LOG_ERROR, "ERR 542A: "
+ "umad_get_ca() failed\n");
+ goto Exit;
+ }
+
+ if (umad_ca.node_type < 1 || umad_ca.node_type > 3) {
+ OSM_LOG(p_vend->p_log, OSM_LOG_ERROR, "ERR 542D: "
+ "Type %d of node \'%s\' is not an IB node type\n",
+ umad_ca.node_type, umad_ca.ca_name);
+ fprintf(stderr,
+ "Type %d of node \'%s\' is not an IB node type\n",
+ umad_ca.node_type, umad_ca.ca_name);
+ umad_release_ca(&umad_ca);
+ goto Exit;
+ }
+ umad_release_ca(&umad_ca);
+
+ /* Port found, try to open it */
+ if (umad_get_port(name, i, &p_vend->umad_port) < 0) {
+ OSM_LOG(p_vend->p_log, OSM_LOG_ERROR, "ERR 542B: "
+ "umad_get_port() failed\n");
+ goto Exit;
+ }
+
+ if ((umad_port_id = umad_open_port(p_vend->umad_port.ca_name,
+ p_vend->umad_port.portnum)) < 0) {
+ OSM_LOG(p_vend->p_log, OSM_LOG_ERROR, "ERR 542C: "
+ "umad_open_port() failed\n");
+ goto Exit;
+ }
+
+ p_vend->umad_port_id = umad_port_id;
+
+ /* start receiver thread */
+ if (!(p_vend->receiver = calloc(1, sizeof(umad_receiver_t)))) {
+ OSM_LOG(p_vend->p_log, OSM_LOG_ERROR, "ERR 5423: "
+ "Unable to alloc receiver struct\n");
+ umad_close_port(umad_port_id);
+ umad_release_port(&p_vend->umad_port);
+ p_vend->umad_port.port_guid = 0;
+ p_vend->umad_port_id = umad_port_id = -1;
+ goto Exit;
+ }
+ if (umad_receiver_start(p_vend) != 0) {
+ OSM_LOG(p_vend->p_log, OSM_LOG_ERROR, "ERR 5420: "
+ "umad_receiver_init failed\n");
+ umad_close_port(umad_port_id);
+ umad_release_port(&p_vend->umad_port);
+ p_vend->umad_port.port_guid = 0;
+ p_vend->umad_port_id = umad_port_id = -1;
+ }
+
+Exit:
+ OSM_LOG_EXIT(p_vend->p_log);
+ return umad_port_id;
+}
+
+static void osm_vendor_close_port(osm_vendor_t * const p_vend)
+{
+ umad_receiver_t *p_ur;
+ int i;
+
+ p_ur = p_vend->receiver;
+ p_vend->receiver = NULL;
+ if (p_ur) {
+ umad_receiver_stop(p_ur);
+ free(p_ur);
+ }
+
+ if (p_vend->umad_port_id >= 0) {
+ for (i = 0; i < OSM_UMAD_MAX_AGENTS; i++)
+ if (p_vend->agents[i])
+ umad_unregister(p_vend->umad_port_id, i);
+ umad_close_port(p_vend->umad_port_id);
+ umad_release_port(&p_vend->umad_port);
+ p_vend->umad_port.port_guid = 0;
+ p_vend->umad_port_id = -1;
+ }
+}
+
+static int set_bit(int nr, void *method_mask)
+{
+ long mask, *addr = method_mask;
+ int retval;
+
+ addr += nr / (8 * sizeof(long));
+ mask = 1L << (nr % (8 * sizeof(long)));
+ retval = (mask & *addr) != 0;
+ *addr |= mask;
+ return retval;
+}
+
+osm_bind_handle_t
+osm_vendor_bind(IN osm_vendor_t * const p_vend,
+ IN osm_bind_info_t * const p_user_bind,
+ IN osm_mad_pool_t * const p_mad_pool,
+ IN osm_vend_mad_recv_callback_t mad_recv_callback,
+ IN osm_vend_mad_send_err_callback_t send_err_callback,
+ IN void *context)
+{
+ ib_net64_t port_guid;
+ osm_umad_bind_info_t *p_bind = 0;
+ long method_mask[16 / sizeof(long)];
+ int umad_port_id;
+ uint8_t rmpp_version;
+
+ OSM_LOG_ENTER(p_vend->p_log);
+
+ CL_ASSERT(p_user_bind);
+ CL_ASSERT(p_mad_pool);
+ CL_ASSERT(mad_recv_callback);
+ CL_ASSERT(send_err_callback);
+
+ port_guid = p_user_bind->port_guid;
+
+ OSM_LOG(p_vend->p_log, OSM_LOG_INFO,
+ "Mgmt class 0x%02x binding to port GUID 0x%" PRIx64 "\n",
+ p_user_bind->mad_class, cl_ntoh64(port_guid));
+
+ if ((umad_port_id = osm_vendor_open_port(p_vend, port_guid)) < 0) {
+ OSM_LOG(p_vend->p_log, OSM_LOG_ERROR, "ERR 5424: "
+ "Unable to open port 0x%" PRIx64 "\n",
+ cl_ntoh64(port_guid));
+ goto Exit;
+ }
+
+ if (umad_get_issm_path(p_vend->umad_port.ca_name,
+ p_vend->umad_port.portnum,
+ p_vend->issm_path,
+ sizeof(p_vend->issm_path)) < 0) {
+ OSM_LOG(p_vend->p_log, OSM_LOG_ERROR, "ERR 542E: "
+ "Cannot resolve issm path for port %s:%u\n",
+ p_vend->umad_port.ca_name, p_vend->umad_port.portnum);
+ goto Exit;
+ }
+
+ if (!(p_bind = malloc(sizeof(*p_bind)))) {
+ OSM_LOG(p_vend->p_log, OSM_LOG_ERROR, "ERR 5425: "
+ "Unable to allocate internal bind object\n");
+ goto Exit;
+ }
+
+ memset(p_bind, 0, sizeof(*p_bind));
+ p_bind->p_vend = p_vend;
+ p_bind->port_id = umad_port_id;
+ p_bind->client_context = context;
+ p_bind->mad_recv_callback = mad_recv_callback;
+ p_bind->send_err_callback = send_err_callback;
+ p_bind->p_mad_pool = p_mad_pool;
+ p_bind->port_guid = port_guid;
+ p_bind->timeout = p_user_bind->timeout ? p_user_bind->timeout :
+ p_vend->timeout;
+ p_bind->max_retries = p_user_bind->retries ? p_user_bind->retries :
+ p_vend->max_retries;
+
+ memset(method_mask, 0, sizeof method_mask);
+ if (p_user_bind->is_responder) {
+ set_bit(IB_MAD_METHOD_GET, &method_mask);
+ set_bit(IB_MAD_METHOD_SET, &method_mask);
+ if (p_user_bind->mad_class == IB_MCLASS_SUBN_ADM) {
+ set_bit(IB_MAD_METHOD_GETTABLE, &method_mask);
+ set_bit(IB_MAD_METHOD_DELETE, &method_mask);
+#ifdef DUAL_SIDED_RMPP
+ set_bit(IB_MAD_METHOD_GETMULTI, &method_mask);
+#endif
+ /* Add in IB_MAD_METHOD_GETTRACETABLE */
+ /* when supported by OpenSM */
+ }
+ }
+ if (p_user_bind->is_report_processor)
+ set_bit(IB_MAD_METHOD_REPORT, &method_mask);
+ if (p_user_bind->is_trap_processor) {
+ set_bit(IB_MAD_METHOD_TRAP, &method_mask);
+ set_bit(IB_MAD_METHOD_TRAP_REPRESS, &method_mask);
+ }
+#ifndef VENDOR_RMPP_SUPPORT
+ rmpp_version = 0;
+#else
+ /* If SA class, set rmpp_version */
+ if (p_user_bind->mad_class == IB_MCLASS_SUBN_ADM)
+ rmpp_version = 1;
+ else
+ rmpp_version = 0;
+#endif
+
+ if ((p_bind->agent_id = umad_register(p_vend->umad_port_id,
+ p_user_bind->mad_class,
+ p_user_bind->class_version,
+ rmpp_version, method_mask)) < 0) {
+ OSM_LOG(p_vend->p_log, OSM_LOG_ERROR, "ERR 5426: "
+ "Unable to register class %u version %u\n",
+ p_user_bind->mad_class, p_user_bind->class_version);
+ free(p_bind);
+ p_bind = 0;
+ goto Exit;
+ }
+
+ if (p_bind->agent_id >= OSM_UMAD_MAX_AGENTS ||
+ p_vend->agents[p_bind->agent_id]) {
+ OSM_LOG(p_vend->p_log, OSM_LOG_ERROR, "ERR 5427: "
+ "bad agent id %u or duplicate agent for class %u vers %u\n",
+ p_bind->agent_id, p_user_bind->mad_class,
+ p_user_bind->class_version);
+ free(p_bind);
+ p_bind = 0;
+ goto Exit;
+ }
+
+ p_vend->agents[p_bind->agent_id] = p_bind;
+
+ /* If Subn Directed Route class, register Subn LID routed class */
+ if (p_user_bind->mad_class == IB_MCLASS_SUBN_DIR) {
+ if ((p_bind->agent_id1 = umad_register(p_vend->umad_port_id,
+ IB_MCLASS_SUBN_LID,
+ p_user_bind->
+ class_version, 0,
+ method_mask)) < 0) {
+ OSM_LOG(p_vend->p_log, OSM_LOG_ERROR, "ERR 5428: "
+ "Unable to register class 1 version %u\n",
+ p_user_bind->class_version);
+ free(p_bind);
+ p_bind = 0;
+ goto Exit;
+ }
+
+ if (p_bind->agent_id1 >= OSM_UMAD_MAX_AGENTS ||
+ p_vend->agents[p_bind->agent_id1]) {
+ OSM_LOG(p_vend->p_log, OSM_LOG_ERROR, "ERR 5429: "
+ "bad agent id %u or duplicate agent for class 1 vers %u\n",
+ p_bind->agent_id1, p_user_bind->class_version);
+ free(p_bind);
+ p_bind = 0;
+ goto Exit;
+ }
+
+ p_vend->agents[p_bind->agent_id1] = p_bind;
+ }
+
+Exit:
+ OSM_LOG_EXIT(p_vend->p_log);
+ return ((osm_bind_handle_t) p_bind);
+}
+
+static void
+__osm_vendor_recv_dummy_cb(IN osm_madw_t * p_madw,
+ IN void *bind_context, IN osm_madw_t * p_req_madw)
+{
+#ifdef _DEBUG_
+ fprintf(stderr,
+ "__osm_vendor_recv_dummy_cb: Ignoring received MAD after osm_vendor_unbind\n");
+#endif
+}
+
+static void
+__osm_vendor_send_err_dummy_cb(IN void *bind_context,
+ IN osm_madw_t * p_req_madw)
+{
+#ifdef _DEBUG_
+ fprintf(stderr,
+ "__osm_vendor_send_err_dummy_cb: Ignoring send error after osm_vendor_unbind\n");
+#endif
+}
+
+void osm_vendor_unbind(IN osm_bind_handle_t h_bind)
+{
+ osm_umad_bind_info_t *p_bind = (osm_umad_bind_info_t *) h_bind;
+ osm_vendor_t *p_vend = p_bind->p_vend;
+
+ OSM_LOG_ENTER(p_vend->p_log);
+
+ pthread_mutex_lock(&p_vend->cb_mutex);
+ p_bind->mad_recv_callback = __osm_vendor_recv_dummy_cb;
+ p_bind->send_err_callback = __osm_vendor_send_err_dummy_cb;
+ pthread_mutex_unlock(&p_vend->cb_mutex);
+
+ OSM_LOG_EXIT(p_vend->p_log);
+}
+
+ib_mad_t *osm_vendor_get(IN osm_bind_handle_t h_bind,
+ IN const uint32_t mad_size,
+ IN osm_vend_wrap_t * const p_vw)
+{
+ osm_umad_bind_info_t *p_bind = (osm_umad_bind_info_t *) h_bind;
+ osm_vendor_t *p_vend = p_bind->p_vend;
+
+ OSM_LOG_ENTER(p_vend->p_log);
+
+ OSM_LOG(p_vend->p_log, OSM_LOG_DEBUG,
+ "Acquiring UMAD for p_madw = %p, size = %u\n", p_vw, mad_size);
+ CL_ASSERT(p_vw);
+ p_vw->size = mad_size;
+ p_vw->umad = umad_alloc(1, mad_size + umad_size());
+
+ /* track locally */
+ p_vw->h_bind = h_bind;
+
+ OSM_LOG(p_vend->p_log, OSM_LOG_DEBUG,
+ "Acquired UMAD %p, size = %u\n", p_vw->umad, p_vw->size);
+
+ OSM_LOG_EXIT(p_vend->p_log);
+ return (p_vw->umad ? umad_get_mad(p_vw->umad) : NULL);
+}
+
+void
+osm_vendor_put(IN osm_bind_handle_t h_bind, IN osm_vend_wrap_t * const p_vw)
+{
+ osm_umad_bind_info_t *p_bind = (osm_umad_bind_info_t *) h_bind;
+ osm_vendor_t *p_vend = p_bind->p_vend;
+ osm_madw_t *p_madw;
+
+ OSM_LOG_ENTER(p_vend->p_log);
+
+ CL_ASSERT(p_vw);
+
+ OSM_LOG(p_vend->p_log, OSM_LOG_DEBUG, "Retiring UMAD %p\n", p_vw->umad);
+
+ /*
+ * We moved the removal of the transaction to immediately after
+ * it was looked up.
+ */
+
+ /* free the mad but the wrapper is part of the madw object */
+ umad_free(p_vw->umad);
+ p_vw->umad = 0;
+ p_madw = PARENT_STRUCT(p_vw, osm_madw_t, vend_wrap);
+ p_madw->p_mad = NULL;
+
+ OSM_LOG_EXIT(p_vend->p_log);
+}
+
+ib_api_status_t
+osm_vendor_send(IN osm_bind_handle_t h_bind,
+ IN osm_madw_t * const p_madw, IN boolean_t const resp_expected)
+{
+ osm_umad_bind_info_t *const p_bind = h_bind;
+ osm_vendor_t *const p_vend = p_bind->p_vend;
+ osm_vend_wrap_t *const p_vw = osm_madw_get_vend_ptr(p_madw);
+ osm_mad_addr_t *const p_mad_addr = osm_madw_get_mad_addr_ptr(p_madw);
+ ib_mad_t *const p_mad = osm_madw_get_mad_ptr(p_madw);
+ ib_sa_mad_t *const p_sa = (ib_sa_mad_t *) p_mad;
+ ib_mad_addr_t mad_addr;
+ int ret = -1;
+ int __attribute__((__unused__)) is_rmpp = 0;
+ uint32_t sent_mad_size;
+ uint64_t tid;
+#ifndef VENDOR_RMPP_SUPPORT
+ uint32_t paylen = 0;
+#endif
+
+ OSM_LOG_ENTER(p_vend->p_log);
+
+ CL_ASSERT(p_vw->h_bind == h_bind);
+ CL_ASSERT(p_mad == umad_get_mad(p_vw->umad));
+
+ if (p_mad->mgmt_class == IB_MCLASS_SUBN_DIR) {
+ umad_set_addr_net(p_vw->umad, 0xffff, 0, 0, 0);
+ umad_set_grh(p_vw->umad, NULL);
+ goto Resp;
+ }
+ if (p_mad->mgmt_class == IB_MCLASS_SUBN_LID) {
+ umad_set_addr_net(p_vw->umad, p_mad_addr->dest_lid, 0, 0, 0);
+ umad_set_grh(p_vw->umad, NULL);
+ goto Resp;
+ }
+ /* GS classes */
+ umad_set_addr_net(p_vw->umad, p_mad_addr->dest_lid,
+ p_mad_addr->addr_type.gsi.remote_qp,
+ p_mad_addr->addr_type.gsi.service_level,
+ IB_QP1_WELL_KNOWN_Q_KEY);
+ if (p_mad_addr->addr_type.gsi.global_route) {
+ mad_addr.grh_present = 1;
+ mad_addr.gid_index = 0;
+ mad_addr.hop_limit = p_mad_addr->addr_type.gsi.grh_info.hop_limit;
+ ib_grh_get_ver_class_flow(p_mad_addr->addr_type.gsi.grh_info.ver_class_flow,
+ NULL, &mad_addr.traffic_class,
+ &mad_addr.flow_label);
+ memcpy(&mad_addr.gid, &p_mad_addr->addr_type.gsi.grh_info.dest_gid, 16);
+ umad_set_grh(p_vw->umad, &mad_addr);
+ } else
+ umad_set_grh(p_vw->umad, NULL);
+ umad_set_pkey(p_vw->umad, p_mad_addr->addr_type.gsi.pkey_ix);
+ if (ib_class_is_rmpp(p_mad->mgmt_class)) { /* RMPP GS classes */
+ if (!ib_rmpp_is_flag_set((ib_rmpp_mad_t *) p_sa,
+ IB_RMPP_FLAG_ACTIVE)) {
+ /* Clear RMPP header when RMPP not ACTIVE */
+ p_sa->rmpp_version = 0;
+ p_sa->rmpp_type = 0;
+ p_sa->rmpp_flags = 0;
+ p_sa->rmpp_status = 0;
+#ifdef VENDOR_RMPP_SUPPORT
+ } else
+ is_rmpp = 1;
+ OSM_LOG(p_vend->p_log, OSM_LOG_DEBUG, "RMPP %d length %d\n",
+ ib_rmpp_is_flag_set((ib_rmpp_mad_t *) p_sa,
+ IB_RMPP_FLAG_ACTIVE),
+ p_madw->mad_size);
+#else
+ } else {
+ p_sa->rmpp_version = 1;
+ p_sa->seg_num = cl_ntoh32(1); /* first DATA is seg 1 */
+ p_sa->rmpp_flags |= (uint8_t) 0x70; /* RRespTime of 14 (high 5 bits) */
+ p_sa->rmpp_status = 0;
+ paylen = p_madw->mad_size - IB_SA_MAD_HDR_SIZE;
+ paylen += (IB_SA_MAD_HDR_SIZE - MAD_RMPP_HDR_SIZE);
+ p_sa->paylen_newwin = cl_ntoh32(paylen);
+ }
+#endif
+ }
+
+Resp:
+ if (resp_expected)
+ put_madw(p_vend, p_madw, p_mad->trans_id, p_mad->mgmt_class);
+
+#ifdef VENDOR_RMPP_SUPPORT
+ sent_mad_size = p_madw->mad_size;
+#else
+ sent_mad_size = is_rmpp ? p_madw->mad_size - IB_SA_MAD_HDR_SIZE :
+ p_madw->mad_size;
+#endif
+ tid = cl_ntoh64(p_mad->trans_id);
+ if ((ret = umad_send(p_bind->port_id, p_bind->agent_id, p_vw->umad,
+ sent_mad_size,
+ resp_expected ? p_bind->timeout : 0,
+ p_bind->max_retries)) < 0) {
+ OSM_LOG(p_vend->p_log, OSM_LOG_ERROR, "ERR 5430: "
+ "Send p_madw = %p of size %d, Class 0x%x, Method 0x%X, "
+ "Attr 0x%X, TID 0x%" PRIx64 " failed %d (%m)\n",
+ p_madw, sent_mad_size, p_mad->mgmt_class,
+ p_mad->method, cl_ntoh16(p_mad->attr_id), tid, ret);
+ if (resp_expected) {
+ get_madw(p_vend, &p_mad->trans_id,
+ p_mad->mgmt_class); /* remove from aging table */
+ p_madw->status = IB_ERROR;
+ pthread_mutex_lock(&p_vend->cb_mutex);
+ (*p_bind->send_err_callback) (p_bind->client_context, p_madw); /* cb frees madw */
+ pthread_mutex_unlock(&p_vend->cb_mutex);
+ } else
+ osm_mad_pool_put(p_bind->p_mad_pool, p_madw);
+ goto Exit;
+ }
+
+ if (!resp_expected)
+ osm_mad_pool_put(p_bind->p_mad_pool, p_madw);
+
+ OSM_LOG(p_vend->p_log, OSM_LOG_DEBUG, "Completed sending %s TID 0x%" PRIx64 "\n",
+ resp_expected ? "request" : "response or unsolicited", tid);
+Exit:
+ OSM_LOG_EXIT(p_vend->p_log);
+ return (ret);
+}
+
+ib_api_status_t osm_vendor_local_lid_change(IN osm_bind_handle_t h_bind)
+{
+ osm_umad_bind_info_t *p_bind = (osm_umad_bind_info_t *) h_bind;
+ osm_vendor_t *p_vend = p_bind->p_vend;
+
+ OSM_LOG_ENTER(p_vend->p_log);
+ ;
+ OSM_LOG_EXIT(p_vend->p_log);
+ return (0);
+}
+
+void osm_vendor_set_sm(IN osm_bind_handle_t h_bind, IN boolean_t is_sm_val)
+{
+ osm_umad_bind_info_t *p_bind = (osm_umad_bind_info_t *) h_bind;
+ osm_vendor_t *p_vend = p_bind->p_vend;
+
+ OSM_LOG_ENTER(p_vend->p_log);
+ if (TRUE == is_sm_val) {
+ p_vend->issmfd = open(p_vend->issm_path, O_NONBLOCK);
+ if (p_vend->issmfd < 0) {
+ OSM_LOG(p_vend->p_log, OSM_LOG_ERROR, "ERR 5431: "
+ "setting IS_SM capmask: cannot open file "
+ "\'%s\': %s\n",
+ p_vend->issm_path, strerror(errno));
+ p_vend->issmfd = -1;
+ }
+ } else if (p_vend->issmfd != -1) {
+ if (0 != close(p_vend->issmfd))
+ OSM_LOG(p_vend->p_log, OSM_LOG_ERROR, "ERR 5432: "
+ "clearing IS_SM capmask: cannot close: %s\n",
+ strerror(errno));
+ p_vend->issmfd = -1;
+ }
+ OSM_LOG_EXIT(p_vend->p_log);
+}
+
+void osm_vendor_set_debug(IN osm_vendor_t * const p_vend, IN int32_t level)
+{
+ umad_debug(level);
+}
+
+#endif /* OSM_VENDOR_INTF_OPENIB */
diff --git a/contrib/ofed/opensm/libvendor/osm_vendor_ibumad_sa.c b/contrib/ofed/opensm/libvendor/osm_vendor_ibumad_sa.c
new file mode 100644
index 0000000..8c884b1
--- /dev/null
+++ b/contrib/ofed/opensm/libvendor/osm_vendor_ibumad_sa.c
@@ -0,0 +1,725 @@
+/*
+ * Copyright (c) 2004-2009 Voltaire, Inc. All rights reserved.
+ * Copyright (c) 2002-2007,2009 Mellanox Technologies LTD. All rights reserved.
+ * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
+ * Copyright (c) 2009,2010 HNR Consulting. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+#if HAVE_CONFIG_H
+# include <config.h>
+#endif /* HAVE_CONFIG_H */
+
+#include <stdlib.h>
+#include <string.h>
+#include <sys/time.h>
+#include <vendor/osm_vendor_api.h>
+#include <vendor/osm_vendor_sa_api.h>
+#include <complib/cl_event.h>
+
+/* this struct is the internal rep of the bind handle */
+typedef struct _osmv_sa_bind_info {
+ osm_bind_handle_t h_bind;
+ osm_log_t *p_log;
+ osm_vendor_t *p_vendor;
+ osm_mad_pool_t *p_mad_pool;
+ cl_event_t sync_event;
+ time_t last_lids_update_sec;
+} osmv_sa_bind_info_t;
+
+/*
+ Call back on new mad received:
+
+ We basically only need to set the context of the query.
+ Or report an error.
+
+ A pointer to the actual context of the request (a copy of the oriignal
+ request structure) is attached as the p_madw->context.ni_context.node_guid
+*/
+static void
+__osmv_sa_mad_rcv_cb(IN osm_madw_t * p_madw,
+ IN void *bind_context, IN osm_madw_t * p_req_madw)
+{
+ osmv_sa_bind_info_t *p_bind = (osmv_sa_bind_info_t *) bind_context;
+ osmv_query_req_t *p_query_req_copy = NULL;
+ osmv_query_res_t query_res;
+ ib_sa_mad_t *p_sa_mad;
+ ib_net16_t mad_status;
+
+ OSM_LOG_ENTER(p_bind->p_log);
+
+ if (!p_req_madw) {
+ OSM_LOG(p_bind->p_log, OSM_LOG_DEBUG,
+ "Ignoring a non-response mad\n");
+ osm_mad_pool_put(p_bind->p_mad_pool, p_madw);
+ goto Exit;
+ }
+
+ /* obtain the sent context since we store it during send in the ni_ctx */
+ p_query_req_copy = (osmv_query_req_t *)
+ (uintptr_t)(osm_madw_get_ni_context_ptr(p_req_madw)->node_guid);
+
+ /* provide the context of the original request in the result */
+ query_res.query_context = p_query_req_copy->query_context;
+
+ /* provide the resulting madw */
+ query_res.p_result_madw = p_madw;
+
+ /* update the req fields */
+ p_sa_mad = (ib_sa_mad_t *) p_madw->p_mad;
+
+ /* if we got a remote error track it in the status */
+ mad_status = (ib_net16_t) (p_sa_mad->status & IB_SMP_STATUS_MASK);
+ if (mad_status != IB_SUCCESS) {
+ OSM_LOG(p_bind->p_log, OSM_LOG_ERROR, "ERR 5501: "
+ "Remote error: 0x%04X\n", cl_ntoh16(mad_status));
+ query_res.status = IB_REMOTE_ERROR;
+ } else
+ query_res.status = IB_SUCCESS;
+
+ /* what if we have got back an empty mad ? */
+ if (!p_madw->mad_size) {
+ OSM_LOG(p_bind->p_log, OSM_LOG_ERROR, "ERR 5502: "
+ "Got an empty mad\n");
+ query_res.status = IB_ERROR;
+ }
+
+ if (IB_SUCCESS == mad_status) {
+
+ /* if we are in not in a method response of an rmpp nature we must get only 1 */
+ /* HACK: in the future we might need to be smarter for other methods... */
+ if (p_sa_mad->method != IB_MAD_METHOD_GETTABLE_RESP) {
+ query_res.result_cnt = 1;
+ } else {
+#ifndef VENDOR_RMPP_SUPPORT
+ if (mad_status != IB_SUCCESS)
+ query_res.result_cnt = 0;
+ else
+ query_res.result_cnt = 1;
+#else
+ if (ib_get_attr_size(p_sa_mad->attr_offset)) {
+ /* we used the offset value to calculate the
+ number of records in here */
+ query_res.result_cnt =
+ (p_madw->mad_size - IB_SA_MAD_HDR_SIZE) /
+ ib_get_attr_size(p_sa_mad->attr_offset);
+ OSM_LOG(p_bind->p_log, OSM_LOG_DEBUG,
+ "Count = %u = %zu / %u (%zu)\n",
+ query_res.result_cnt,
+ p_madw->mad_size - IB_SA_MAD_HDR_SIZE,
+ ib_get_attr_size(p_sa_mad->attr_offset),
+ (p_madw->mad_size -
+ IB_SA_MAD_HDR_SIZE) %
+ ib_get_attr_size(p_sa_mad->attr_offset));
+ } else
+ query_res.result_cnt = 0;
+#endif
+ }
+ }
+
+ query_res.query_type = p_query_req_copy->query_type;
+
+ p_query_req_copy->pfn_query_cb(&query_res);
+
+ if ((p_query_req_copy->flags & OSM_SA_FLAGS_SYNC) == OSM_SA_FLAGS_SYNC)
+ cl_event_signal(&p_bind->sync_event);
+
+Exit:
+
+ /* free the copied query request if found */
+ if (p_query_req_copy)
+ free(p_query_req_copy);
+
+ /* put back the request madw */
+ if (p_req_madw)
+ osm_mad_pool_put(p_bind->p_mad_pool, p_req_madw);
+
+ OSM_LOG_EXIT(p_bind->p_log);
+}
+
+/*
+ Send Error Callback:
+
+ Only report the error and get rid of the mad wrapper
+*/
+static void __osmv_sa_mad_err_cb(IN void *bind_context, IN osm_madw_t * p_madw)
+{
+ osmv_sa_bind_info_t *p_bind = (osmv_sa_bind_info_t *) bind_context;
+ osmv_query_req_t *p_query_req_copy = NULL;
+ osmv_query_res_t query_res;
+
+ OSM_LOG_ENTER(p_bind->p_log);
+
+ /* Obtain the sent context etc */
+ p_query_req_copy = (osmv_query_req_t *)
+ (uintptr_t)(osm_madw_get_ni_context_ptr(p_madw)->node_guid);
+
+ /* provide the context of the original request in the result */
+ query_res.query_context = p_query_req_copy->query_context;
+
+ query_res.p_result_madw = p_madw;
+
+ query_res.status = IB_TIMEOUT;
+ query_res.result_cnt = 0;
+
+ query_res.query_type = p_query_req_copy->query_type;
+
+ p_query_req_copy->pfn_query_cb(&query_res);
+
+ if ((p_query_req_copy->flags & OSM_SA_FLAGS_SYNC) == OSM_SA_FLAGS_SYNC)
+ cl_event_signal(&p_bind->sync_event);
+
+ free(p_query_req_copy);
+ OSM_LOG_EXIT(p_bind->p_log);
+}
+
+/*****************************************************************************
+ Update lids of vendor umad_port.
+ *****************************************************************************/
+static ib_api_status_t update_umad_port(osm_vendor_t * p_vend)
+{
+ umad_port_t port;
+ if (umad_get_port(p_vend->umad_port.ca_name,
+ p_vend->umad_port.portnum, &port) < 0)
+ return IB_ERROR;
+ p_vend->umad_port.base_lid = port.base_lid;
+ p_vend->umad_port.sm_lid = port.sm_lid;
+ umad_release_port(&port);
+ return IB_SUCCESS;
+}
+
+osm_bind_handle_t
+osmv_bind_sa(IN osm_vendor_t * const p_vend,
+ IN osm_mad_pool_t * const p_mad_pool, IN ib_net64_t port_guid)
+{
+ osm_bind_info_t bind_info;
+ osm_log_t *p_log = p_vend->p_log;
+ osmv_sa_bind_info_t *p_sa_bind_info;
+ cl_status_t cl_status;
+
+ OSM_LOG_ENTER(p_log);
+
+ OSM_LOG(p_log, OSM_LOG_DEBUG,
+ "Binding to port 0x%" PRIx64 "\n", cl_ntoh64(port_guid));
+
+ bind_info.port_guid = port_guid;
+ bind_info.mad_class = IB_MCLASS_SUBN_ADM;
+ bind_info.class_version = 2;
+ bind_info.is_responder = FALSE;
+ bind_info.is_trap_processor = FALSE;
+ bind_info.is_report_processor = FALSE;
+ bind_info.send_q_size = OSM_SM_DEFAULT_QP1_RCV_SIZE;
+ bind_info.recv_q_size = OSM_SM_DEFAULT_QP1_SEND_SIZE;
+ bind_info.timeout = p_vend->timeout;
+ bind_info.retries = OSM_DEFAULT_RETRY_COUNT;
+
+ /* allocate the new sa bind info */
+ p_sa_bind_info =
+ (osmv_sa_bind_info_t *) malloc(sizeof(osmv_sa_bind_info_t));
+ if (!p_sa_bind_info) {
+ OSM_LOG(p_log, OSM_LOG_ERROR, "ERR 5505: "
+ "Failed to allocate new bind structure\n");
+ p_sa_bind_info = OSM_BIND_INVALID_HANDLE;
+ goto Exit;
+ }
+
+ /* store some important context */
+ p_sa_bind_info->p_log = p_log;
+ p_sa_bind_info->p_mad_pool = p_mad_pool;
+ p_sa_bind_info->p_vendor = p_vend;
+
+ /* Bind to the lower level */
+ p_sa_bind_info->h_bind = osm_vendor_bind(p_vend, &bind_info, p_mad_pool, __osmv_sa_mad_rcv_cb, __osmv_sa_mad_err_cb, p_sa_bind_info); /* context provided to CBs */
+
+ if (p_sa_bind_info->h_bind == OSM_BIND_INVALID_HANDLE) {
+ free(p_sa_bind_info);
+ p_sa_bind_info = OSM_BIND_INVALID_HANDLE;
+ OSM_LOG(p_log, OSM_LOG_ERROR, "ERR 5506: "
+ "Failed to bind to vendor GSI\n");
+ goto Exit;
+ }
+
+ /* update time umad_port is initialized now */
+ p_sa_bind_info->last_lids_update_sec = time(NULL);
+
+ /* initialize the sync_event */
+ cl_event_construct(&p_sa_bind_info->sync_event);
+ cl_status = cl_event_init(&p_sa_bind_info->sync_event, TRUE);
+ if (cl_status != CL_SUCCESS) {
+ OSM_LOG(p_log, OSM_LOG_ERROR, "ERR 5508: "
+ "cl_init_event failed: %s\n", ib_get_err_str(cl_status));
+ free(p_sa_bind_info);
+ p_sa_bind_info = OSM_BIND_INVALID_HANDLE;
+ }
+
+Exit:
+ OSM_LOG_EXIT(p_log);
+ return (p_sa_bind_info);
+}
+
+/****t* OSM Vendor SA Client/osmv_sa_mad_data
+ * NAME
+ * osmv_sa_mad_data
+ *
+ * DESCRIPTION
+ * Extra fields required to perform a mad query
+ * This struct is passed to the actual send method
+ *
+ * SYNOPSIS
+ */
+typedef struct _osmv_sa_mad_data {
+ /* MAD data. */
+ uint8_t method;
+ ib_net16_t attr_id;
+ ib_net16_t attr_offset;
+ ib_net32_t attr_mod;
+ ib_net64_t comp_mask;
+ void *p_attr;
+} osmv_sa_mad_data_t;
+/*
+ * method
+ * The method of the mad to be sent
+ *
+ * attr_id
+ * Attribute ID
+ *
+ * attr_offset
+ * Offset as defined by RMPP
+ *
+ * attr_mod
+ * Attribute modifier
+ *
+ * comp_mask
+ * The component mask of the query
+ *
+ * p_attr
+ * A pointer to the record of the attribute to be sent.
+ *
+ *****/
+
+/* Send a MAD out on the GSI interface */
+static ib_api_status_t
+__osmv_send_sa_req(IN osmv_sa_bind_info_t * p_bind,
+ IN const osmv_sa_mad_data_t * const p_sa_mad_data,
+ IN const osmv_query_req_t * const p_query_req)
+{
+ ib_api_status_t status;
+ ib_mad_t *p_mad_hdr;
+ ib_sa_mad_t *p_sa_mad;
+ osm_madw_t *p_madw;
+ osm_log_t *p_log = p_bind->p_log;
+ static atomic32_t trans_id;
+ boolean_t sync;
+ osmv_query_req_t *p_query_req_copy;
+ uint32_t sa_size;
+
+ OSM_LOG_ENTER(p_log);
+
+ /*
+ since the sm_lid might change we obtain it every send
+ (actually it is cached in the bind object and refreshed
+ every 30sec by this proc)
+ */
+ if (time(NULL) > p_bind->last_lids_update_sec + 30) {
+ status = update_umad_port(p_bind->p_vendor);
+ if (status != IB_SUCCESS) {
+ OSM_LOG(p_log, OSM_LOG_ERROR, "ERR 5509: "
+ "Failed to obtain the SM lid\n");
+ goto Exit;
+ }
+ p_bind->last_lids_update_sec = time(NULL);
+ }
+
+ /* Get a MAD wrapper for the send */
+ p_madw = osm_mad_pool_get(p_bind->p_mad_pool,
+ p_bind->h_bind, MAD_BLOCK_SIZE, NULL);
+
+ if (p_madw == NULL) {
+ OSM_LOG(p_log, OSM_LOG_ERROR, "ERR 5510: "
+ "Unable to acquire MAD\n");
+ status = IB_INSUFFICIENT_RESOURCES;
+ goto Exit;
+ }
+
+ /* Initialize the Sent MAD: */
+
+ /* Initialize the MAD buffer for the send operation. */
+ p_mad_hdr = osm_madw_get_mad_ptr(p_madw);
+ p_sa_mad = osm_madw_get_sa_mad_ptr(p_madw);
+
+ /* Get a new transaction Id */
+ cl_atomic_inc(&trans_id);
+
+ /* Cleanup the MAD from any residue */
+ memset(p_sa_mad, 0, MAD_BLOCK_SIZE);
+
+ /* Initialize the standard MAD header. */
+ ib_mad_init_new(p_mad_hdr, /* mad pointer */
+ IB_MCLASS_SUBN_ADM, /* class */
+ (uint8_t) 2, /* version */
+ p_sa_mad_data->method, /* method */
+ cl_hton64((uint64_t) trans_id), /* tid */
+ p_sa_mad_data->attr_id, /* attr id */
+ p_sa_mad_data->attr_mod /* attr mod */);
+
+ /* Set the query information. */
+ p_sa_mad->sm_key = p_query_req->sm_key;
+ p_sa_mad->attr_offset = 0;
+ p_sa_mad->comp_mask = p_sa_mad_data->comp_mask;
+#ifdef DUAL_SIDED_RMPP
+ if (p_sa_mad->method == IB_MAD_METHOD_GETMULTI)
+ p_sa_mad->rmpp_flags = IB_RMPP_FLAG_ACTIVE;
+#endif
+ if (p_sa_mad->comp_mask) {
+ p_sa_mad_data->attr_offset ? (sa_size = ib_get_attr_size(p_sa_mad_data->attr_offset)) : (sa_size = IB_SA_DATA_SIZE);
+ memcpy(p_sa_mad->data, p_sa_mad_data->p_attr, sa_size);
+ }
+
+ /*
+ Provide the address to send to
+ */
+ p_madw->mad_addr.dest_lid =
+ cl_hton16(p_bind->p_vendor->umad_port.sm_lid);
+ p_madw->mad_addr.addr_type.smi.source_lid =
+ cl_hton16(p_bind->p_vendor->umad_port.base_lid);
+ p_madw->mad_addr.addr_type.gsi.remote_qp = CL_HTON32(1);
+ p_madw->resp_expected = TRUE;
+ p_madw->fail_msg = CL_DISP_MSGID_NONE;
+
+ /*
+ add grh
+ */
+ if (p_query_req->with_grh) {
+ OSM_LOG(p_log, OSM_LOG_DEBUG, "sending sa query with GRH "
+ "GID 0x%016" PRIx64 " 0x%016" PRIx64 "\n",
+ cl_ntoh64(p_query_req->gid.unicast.prefix),
+ cl_ntoh64(p_query_req->gid.unicast.interface_id));
+ p_madw->mad_addr.addr_type.gsi.global_route = 1;
+ memset(&p_madw->mad_addr.addr_type.gsi.grh_info, 0,
+ sizeof(p_madw->mad_addr.addr_type.gsi.grh_info));
+ memcpy(&p_madw->mad_addr.addr_type.gsi.grh_info.dest_gid, &(p_query_req->gid), 16);
+ }
+
+ /*
+ Provide MAD context such that the call back will know what to do.
+ We have to keep the entire request structure so we know the CB.
+ Since we can not rely on the client to keep it around until
+ the response - we duplicate it and will later dispose it (in CB).
+ To store on the MADW we cast it into what opensm has:
+ p_madw->context.ni_context.node_guid
+ */
+ p_query_req_copy = malloc(sizeof(*p_query_req_copy));
+ if (!p_query_req_copy) {
+ OSM_LOG(p_log, OSM_LOG_ERROR, "ERR 5511: "
+ "Unable to acquire memory for query copy\n");
+ osm_mad_pool_put(p_bind->p_mad_pool, p_madw);
+ status = IB_INSUFFICIENT_RESOURCES;
+ goto Exit;
+ }
+ *p_query_req_copy = *p_query_req;
+ osm_madw_get_ni_context_ptr(p_madw)->node_guid =
+ (ib_net64_t) (uintptr_t)p_query_req_copy;
+
+ /* we can support async as well as sync calls */
+ sync = ((p_query_req->flags & OSM_SA_FLAGS_SYNC) == OSM_SA_FLAGS_SYNC);
+
+ /* send the mad asynchronously */
+ status = osm_vendor_send(osm_madw_get_bind_handle(p_madw),
+ p_madw, p_madw->resp_expected);
+
+ /* if synchronous - wait on the event */
+ if (sync) {
+ OSM_LOG(p_log, OSM_LOG_DEBUG, "Waiting for async event\n");
+ cl_event_wait_on(&p_bind->sync_event, EVENT_NO_TIMEOUT, FALSE);
+ cl_event_reset(&p_bind->sync_event);
+ status = p_madw->status;
+ }
+
+Exit:
+ OSM_LOG_EXIT(p_log);
+ return status;
+}
+
+/*
+ * Query the SA based on the user's request.
+ */
+ib_api_status_t
+osmv_query_sa(IN osm_bind_handle_t h_bind,
+ IN const osmv_query_req_t * const p_query_req)
+{
+ union {
+ ib_service_record_t svc_rec;
+ ib_node_record_t node_rec;
+ ib_portinfo_record_t port_info;
+ ib_path_rec_t path_rec;
+#ifdef DUAL_SIDED_RMPP
+ ib_multipath_rec_t multipath_rec;
+#endif
+ ib_class_port_info_t class_port_info;
+ } u;
+ osmv_sa_mad_data_t sa_mad_data;
+ osmv_sa_bind_info_t *p_bind = (osmv_sa_bind_info_t *) h_bind;
+ osmv_user_query_t *p_user_query;
+#ifdef DUAL_SIDED_RMPP
+ osmv_multipath_req_t *p_mpr_req;
+ int i, j;
+#endif
+ osm_log_t *p_log = p_bind->p_log;
+ ib_api_status_t status;
+
+ OSM_LOG_ENTER(p_log);
+
+ /* Set the request information. */
+ sa_mad_data.method = IB_MAD_METHOD_GETTABLE;
+ sa_mad_data.attr_mod = 0;
+ sa_mad_data.attr_offset = 0;
+
+ /* Set the MAD attributes and component mask correctly. */
+ switch (p_query_req->query_type) {
+
+ case OSMV_QUERY_USER_DEFINED:
+ OSM_LOG(p_log, OSM_LOG_DEBUG, "DBG:001 USER_DEFINED\n");
+ p_user_query = (osmv_user_query_t *) p_query_req->p_query_input;
+ if (p_user_query->method)
+ sa_mad_data.method = p_user_query->method;
+#ifdef DUAL_SIDED_RMPP
+ if (sa_mad_data.method == IB_MAD_METHOD_GETMULTI ||
+ sa_mad_data.method == IB_MAD_METHOD_GETTRACETABLE)
+ sa_mad_data.attr_offset = p_user_query->attr_offset;
+#endif
+ sa_mad_data.attr_id = p_user_query->attr_id;
+ sa_mad_data.attr_mod = p_user_query->attr_mod;
+ sa_mad_data.comp_mask = p_user_query->comp_mask;
+ sa_mad_data.p_attr = p_user_query->p_attr;
+ break;
+
+ case OSMV_QUERY_ALL_SVC_RECS:
+ OSM_LOG(p_log, OSM_LOG_DEBUG, "DBG:001 SVC_REC_BY_NAME\n");
+ sa_mad_data.attr_id = IB_MAD_ATTR_SERVICE_RECORD;
+ sa_mad_data.comp_mask = 0;
+ sa_mad_data.p_attr = &u.svc_rec;
+ break;
+
+ case OSMV_QUERY_SVC_REC_BY_NAME:
+ OSM_LOG(p_log, OSM_LOG_DEBUG, "DBG:001 SVC_REC_BY_NAME\n");
+ sa_mad_data.method = IB_MAD_METHOD_GET;
+ sa_mad_data.attr_id = IB_MAD_ATTR_SERVICE_RECORD;
+ sa_mad_data.comp_mask = IB_SR_COMPMASK_SNAME;
+ sa_mad_data.p_attr = &u.svc_rec;
+ memcpy(u.svc_rec.service_name, p_query_req->p_query_input,
+ sizeof(ib_svc_name_t));
+ break;
+
+ case OSMV_QUERY_SVC_REC_BY_ID:
+ OSM_LOG(p_log, OSM_LOG_DEBUG, "DBG:001 SVC_REC_BY_ID\n");
+ sa_mad_data.attr_id = IB_MAD_ATTR_SERVICE_RECORD;
+ sa_mad_data.comp_mask = IB_SR_COMPMASK_SID;
+ sa_mad_data.p_attr = &u.svc_rec;
+ u.svc_rec.service_id =
+ *(ib_net64_t *) (p_query_req->p_query_input);
+ break;
+
+ case OSMV_QUERY_CLASS_PORT_INFO:
+ OSM_LOG(p_log, OSM_LOG_DEBUG, "DBG:001 CLASS_PORT_INFO\n");
+ sa_mad_data.method = IB_MAD_METHOD_GET;
+ sa_mad_data.attr_id = IB_MAD_ATTR_CLASS_PORT_INFO;
+ sa_mad_data.comp_mask = 0;
+ sa_mad_data.p_attr = &u.class_port_info;
+ break;
+
+ case OSMV_QUERY_NODE_REC_BY_NODE_GUID:
+ OSM_LOG(p_log, OSM_LOG_DEBUG, "DBG:001 NODE_REC_BY_NODE_GUID\n");
+ sa_mad_data.attr_id = IB_MAD_ATTR_NODE_RECORD;
+ sa_mad_data.comp_mask = IB_NR_COMPMASK_NODEGUID;
+ sa_mad_data.p_attr = &u.node_rec;
+ u.node_rec.node_info.node_guid =
+ *(ib_net64_t *) (p_query_req->p_query_input);
+ break;
+
+ case OSMV_QUERY_PORT_REC_BY_LID:
+ OSM_LOG(p_log, OSM_LOG_DEBUG, "DBG:001 PORT_REC_BY_LID\n");
+ sa_mad_data.attr_id = IB_MAD_ATTR_PORTINFO_RECORD;
+ sa_mad_data.comp_mask = IB_PIR_COMPMASK_LID;
+ sa_mad_data.p_attr = &u.port_info;
+ u.port_info.lid = *(ib_net16_t *) (p_query_req->p_query_input);
+ break;
+
+ case OSMV_QUERY_PORT_REC_BY_LID_AND_NUM:
+ sa_mad_data.method = IB_MAD_METHOD_GET;
+ p_user_query = (osmv_user_query_t *) p_query_req->p_query_input;
+ OSM_LOG(p_log, OSM_LOG_DEBUG, "DBG:001 PORT_REC_BY_LID_AND_NUM\n");
+ sa_mad_data.attr_id = IB_MAD_ATTR_PORTINFO_RECORD;
+ sa_mad_data.comp_mask =
+ IB_PIR_COMPMASK_LID | IB_PIR_COMPMASK_PORTNUM;
+ sa_mad_data.p_attr = p_user_query->p_attr;
+ break;
+
+ case OSMV_QUERY_VLARB_BY_LID_PORT_BLOCK:
+ sa_mad_data.method = IB_MAD_METHOD_GET;
+ p_user_query = (osmv_user_query_t *) p_query_req->p_query_input;
+ OSM_LOG(p_log, OSM_LOG_DEBUG, "DBG:001 OSMV_QUERY_VLARB_BY_LID_PORT_BLOCK\n");
+ sa_mad_data.attr_id = IB_MAD_ATTR_VLARB_RECORD;
+ sa_mad_data.comp_mask =
+ IB_VLA_COMPMASK_LID | IB_VLA_COMPMASK_OUT_PORT |
+ IB_VLA_COMPMASK_BLOCK;
+ sa_mad_data.p_attr = p_user_query->p_attr;
+ break;
+
+ case OSMV_QUERY_SLVL_BY_LID_AND_PORTS:
+ sa_mad_data.method = IB_MAD_METHOD_GET;
+ p_user_query = (osmv_user_query_t *) p_query_req->p_query_input;
+ OSM_LOG(p_log, OSM_LOG_DEBUG, "DBG:001 OSMV_QUERY_VLARB_BY_LID_PORT_BLOCK\n");
+ sa_mad_data.attr_id = IB_MAD_ATTR_SLVL_RECORD;
+ sa_mad_data.comp_mask =
+ IB_SLVL_COMPMASK_LID | IB_SLVL_COMPMASK_OUT_PORT |
+ IB_SLVL_COMPMASK_IN_PORT;
+ sa_mad_data.p_attr = p_user_query->p_attr;
+ break;
+
+ case OSMV_QUERY_PATH_REC_BY_PORT_GUIDS:
+ OSM_LOG(p_log, OSM_LOG_DEBUG, "DBG:001 PATH_REC_BY_PORT_GUIDS\n");
+ memset(&u.path_rec, 0, sizeof(ib_path_rec_t));
+ sa_mad_data.attr_id = IB_MAD_ATTR_PATH_RECORD;
+ sa_mad_data.comp_mask =
+ (IB_PR_COMPMASK_DGID | IB_PR_COMPMASK_SGID | IB_PR_COMPMASK_NUMBPATH);
+ u.path_rec.num_path = 0x7f;
+ sa_mad_data.p_attr = &u.path_rec;
+ ib_gid_set_default(&u.path_rec.dgid,
+ ((osmv_guid_pair_t *) (p_query_req->
+ p_query_input))->
+ dest_guid);
+ ib_gid_set_default(&u.path_rec.sgid,
+ ((osmv_guid_pair_t *) (p_query_req->
+ p_query_input))->
+ src_guid);
+ break;
+
+ case OSMV_QUERY_PATH_REC_BY_GIDS:
+ OSM_LOG(p_log, OSM_LOG_DEBUG, "DBG:001 PATH_REC_BY_GIDS\n");
+ memset(&u.path_rec, 0, sizeof(ib_path_rec_t));
+ sa_mad_data.attr_id = IB_MAD_ATTR_PATH_RECORD;
+ sa_mad_data.comp_mask =
+ (IB_PR_COMPMASK_DGID | IB_PR_COMPMASK_SGID | IB_PR_COMPMASK_NUMBPATH);
+ u.path_rec.num_path = 0x7f;
+ sa_mad_data.p_attr = &u.path_rec;
+ memcpy(&u.path_rec.dgid,
+ &((osmv_gid_pair_t *) (p_query_req->p_query_input))->
+ dest_gid,
+ sizeof(ib_gid_t));
+ memcpy(&u.path_rec.sgid,
+ &((osmv_gid_pair_t *) (p_query_req->p_query_input))->
+ src_gid,
+ sizeof(ib_gid_t));
+ break;
+
+ case OSMV_QUERY_PATH_REC_BY_LIDS:
+ OSM_LOG(p_log, OSM_LOG_DEBUG, "DBG:001 PATH_REC_BY_LIDS\n");
+ memset(&u.path_rec, 0, sizeof(ib_path_rec_t));
+ sa_mad_data.method = IB_MAD_METHOD_GET;
+ sa_mad_data.attr_id = IB_MAD_ATTR_PATH_RECORD;
+ sa_mad_data.comp_mask =
+ (IB_PR_COMPMASK_DLID | IB_PR_COMPMASK_SLID);
+ sa_mad_data.p_attr = &u.path_rec;
+ u.path_rec.dlid =
+ ((osmv_lid_pair_t *) (p_query_req->p_query_input))->dest_lid;
+ u.path_rec.slid =
+ ((osmv_lid_pair_t *) (p_query_req->p_query_input))->src_lid;
+ break;
+
+ case OSMV_QUERY_UD_MULTICAST_SET:
+ sa_mad_data.method = IB_MAD_METHOD_SET;
+ p_user_query = (osmv_user_query_t *) p_query_req->p_query_input;
+ OSM_LOG(p_log, OSM_LOG_DEBUG, "DBG:001 OSMV_QUERY_UD_MULTICAST_SET\n");
+ sa_mad_data.attr_id = IB_MAD_ATTR_MCMEMBER_RECORD;
+ sa_mad_data.comp_mask = p_user_query->comp_mask;
+ sa_mad_data.p_attr = p_user_query->p_attr;
+ break;
+
+ case OSMV_QUERY_UD_MULTICAST_DELETE:
+ sa_mad_data.method = IB_MAD_METHOD_DELETE;
+ p_user_query = (osmv_user_query_t *) p_query_req->p_query_input;
+ OSM_LOG(p_log, OSM_LOG_DEBUG, "DBG:001 OSMV_QUERY_UD_MULTICAST_DELETE\n");
+ sa_mad_data.attr_id = IB_MAD_ATTR_MCMEMBER_RECORD;
+ sa_mad_data.comp_mask = p_user_query->comp_mask;
+ sa_mad_data.p_attr = p_user_query->p_attr;
+ break;
+
+#ifdef DUAL_SIDED_RMPP
+ case OSMV_QUERY_MULTIPATH_REC:
+ OSM_LOG(p_log, OSM_LOG_DEBUG, "DBG:001 MULTIPATH_REC\n");
+ /* Validate sgid/dgid counts against SA client limit */
+ p_mpr_req = (osmv_multipath_req_t *) p_query_req->p_query_input;
+ if (p_mpr_req->sgid_count + p_mpr_req->dgid_count >
+ IB_MULTIPATH_MAX_GIDS) {
+ OSM_LOG(p_log, OSM_LOG_ERROR, "DBG:001 MULTIPATH_REC "
+ "SGID count %d DGID count %d max count %d\n",
+ p_mpr_req->sgid_count, p_mpr_req->dgid_count,
+ IB_MULTIPATH_MAX_GIDS);
+ CL_ASSERT(0);
+ return IB_ERROR;
+ }
+ memset(&u.multipath_rec, 0, sizeof(ib_multipath_rec_t));
+ sa_mad_data.method = IB_MAD_METHOD_GETMULTI;
+ sa_mad_data.attr_id = IB_MAD_ATTR_MULTIPATH_RECORD;
+ sa_mad_data.attr_offset =
+ ib_get_attr_offset(sizeof(ib_multipath_rec_t));
+ sa_mad_data.p_attr = &u.multipath_rec;
+ sa_mad_data.comp_mask = p_mpr_req->comp_mask;
+ u.multipath_rec.num_path = p_mpr_req->num_path;
+ if (p_mpr_req->reversible)
+ u.multipath_rec.num_path |= 0x80;
+ else
+ u.multipath_rec.num_path &= ~0x80;
+ u.multipath_rec.pkey = p_mpr_req->pkey;
+ ib_multipath_rec_set_sl(&u.multipath_rec, p_mpr_req->sl);
+ ib_multipath_rec_set_qos_class(&u.multipath_rec, 0);
+ u.multipath_rec.independence = p_mpr_req->independence;
+ u.multipath_rec.sgid_count = p_mpr_req->sgid_count;
+ u.multipath_rec.dgid_count = p_mpr_req->dgid_count;
+ j = 0;
+ for (i = 0; i < p_mpr_req->sgid_count; i++, j++)
+ u.multipath_rec.gids[j] = p_mpr_req->gids[j];
+ for (i = 0; i < p_mpr_req->dgid_count; i++, j++)
+ u.multipath_rec.gids[j] = p_mpr_req->gids[j];
+ break;
+#endif
+
+ default:
+ OSM_LOG(p_log, OSM_LOG_ERROR, "DBG:001 UNKNOWN\n");
+ CL_ASSERT(0);
+ return IB_ERROR;
+ }
+
+ status = __osmv_send_sa_req(h_bind, &sa_mad_data, p_query_req);
+
+ OSM_LOG_EXIT(p_log);
+ return status;
+}
diff --git a/contrib/ofed/opensm/libvendor/osm_vendor_mlx.c b/contrib/ofed/opensm/libvendor/osm_vendor_mlx.c
new file mode 100644
index 0000000..7a40fa5
--- /dev/null
+++ b/contrib/ofed/opensm/libvendor/osm_vendor_mlx.c
@@ -0,0 +1,768 @@
+/*
+ * Copyright (c) 2004-2008 Voltaire, Inc. All rights reserved.
+ * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved.
+ * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+#if HAVE_CONFIG_H
+# include <config.h>
+#endif /* HAVE_CONFIG_H */
+
+#include <stdlib.h>
+#include <string.h>
+#include <vendor/osm_vendor_mlx.h>
+#include <vendor/osm_vendor_mlx_transport.h>
+#include <vendor/osm_vendor_mlx_svc.h>
+#include <vendor/osm_vendor_mlx_sender.h>
+#include <vendor/osm_vendor_mlx_hca.h>
+#include <vendor/osm_pkt_randomizer.h>
+
+/**
+ * FORWARD REFERENCES
+ */
+static ib_api_status_t
+__osmv_get_send_txn(IN osm_bind_handle_t h_bind,
+ IN osm_madw_t * const p_madw,
+ IN boolean_t is_rmpp,
+ IN boolean_t resp_expected, OUT osmv_txn_ctx_t ** pp_txn);
+
+static void __osm_vendor_internal_unbind(osm_bind_handle_t h_bind);
+
+/*
+ * NAME osm_vendor_new
+ *
+ * DESCRIPTION Create and Initialize the osm_vendor_t Object
+ */
+
+osm_vendor_t *osm_vendor_new(IN osm_log_t * const p_log,
+ IN const uint32_t timeout)
+{
+ ib_api_status_t status;
+ osm_vendor_t *p_vend;
+
+ OSM_LOG_ENTER(p_log);
+
+ CL_ASSERT(p_log);
+
+ p_vend = malloc(sizeof(*p_vend));
+ if (p_vend != NULL) {
+ memset(p_vend, 0, sizeof(*p_vend));
+
+ status = osm_vendor_init(p_vend, p_log, timeout);
+ if (status != IB_SUCCESS) {
+ osm_vendor_delete(&p_vend);
+ }
+ } else {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "osm_vendor_new: ERR 7301: "
+ "Fail to allocate vendor object.\n");
+ }
+
+ OSM_LOG_EXIT(p_log);
+ return (p_vend);
+}
+
+/*
+ * NAME osm_vendor_delete
+ *
+ * DESCRIPTION Delete all the binds behind the vendor + free the vendor object
+ */
+
+void osm_vendor_delete(IN osm_vendor_t ** const pp_vend)
+{
+ cl_list_item_t *p_item;
+ cl_list_obj_t *p_obj;
+ osm_bind_handle_t bind_h;
+ osm_log_t *p_log;
+
+ OSM_LOG_ENTER((*pp_vend)->p_log);
+ p_log = (*pp_vend)->p_log;
+
+ /* go over the bind handles , unbind them and remove from list */
+ p_item = cl_qlist_remove_head(&((*pp_vend)->bind_handles));
+ while (p_item != cl_qlist_end(&((*pp_vend)->bind_handles))) {
+
+ p_obj = PARENT_STRUCT(p_item, cl_list_obj_t, list_item);
+ bind_h = (osm_bind_handle_t *) cl_qlist_obj(p_obj);
+ osm_log(p_log, OSM_LOG_DEBUG,
+ "osm_vendor_delete: unbinding bind_h:%p \n", bind_h);
+
+ __osm_vendor_internal_unbind(bind_h);
+
+ free(p_obj);
+ /*removing from list */
+ p_item = cl_qlist_remove_head(&((*pp_vend)->bind_handles));
+ }
+
+ if (NULL != ((*pp_vend)->p_transport_info)) {
+ free((*pp_vend)->p_transport_info);
+ (*pp_vend)->p_transport_info = NULL;
+ }
+
+ /* remove the packet randomizer object */
+ if ((*pp_vend)->run_randomizer == TRUE)
+ osm_pkt_randomizer_destroy(&((*pp_vend)->p_pkt_randomizer),
+ p_log);
+
+ free(*pp_vend);
+ *pp_vend = NULL;
+
+ OSM_LOG_EXIT(p_log);
+}
+
+/*
+ * NAME osm_vendor_init
+ *
+ * DESCRIPTION Initialize the vendor object
+ */
+
+ib_api_status_t
+osm_vendor_init(IN osm_vendor_t * const p_vend,
+ IN osm_log_t * const p_log, IN const uint32_t timeout)
+{
+ ib_api_status_t status = IB_SUCCESS;
+
+ OSM_LOG_ENTER(p_log);
+
+ p_vend->p_transport_info = NULL;
+ p_vend->p_log = p_log;
+ p_vend->resp_timeout = timeout;
+ p_vend->ttime_timeout = timeout * OSMV_TXN_TIMEOUT_FACTOR;
+
+ cl_qlist_init(&p_vend->bind_handles);
+
+ /* update the run_randomizer flag */
+ if (getenv("OSM_PKT_DROP_RATE") != NULL
+ && atol(getenv("OSM_PKT_DROP_RATE")) != 0) {
+ /* if the OSM_PKT_DROP_RATE global variable is defined to a non-zero value -
+ then the randomizer should be called.
+ Need to create the packet randomizer object */
+ p_vend->run_randomizer = TRUE;
+ status =
+ osm_pkt_randomizer_init(&(p_vend->p_pkt_randomizer), p_log);
+ if (status != IB_SUCCESS)
+ return status;
+ } else {
+ p_vend->run_randomizer = FALSE;
+ p_vend->p_pkt_randomizer = NULL;
+ }
+
+ OSM_LOG_EXIT(p_log);
+ return (IB_SUCCESS);
+}
+
+/*
+ * NAME osm_vendor_bind
+ *
+ * DESCRIPTION Create a new bind object under the vendor object
+ */
+
+osm_bind_handle_t
+osm_vendor_bind(IN osm_vendor_t * const p_vend,
+ IN osm_bind_info_t * const p_bind_info,
+ IN osm_mad_pool_t * const p_mad_pool,
+ IN osm_vend_mad_recv_callback_t mad_recv_callback,
+ IN osm_vend_mad_send_err_callback_t send_err_callback,
+ IN void *context)
+{
+ osmv_bind_obj_t *p_bo;
+ ib_api_status_t status;
+ char hca_id[32];
+ cl_status_t cl_st;
+ cl_list_obj_t *p_obj;
+ uint8_t hca_index;
+
+ if (NULL == p_vend || NULL == p_bind_info || NULL == p_mad_pool
+ || NULL == mad_recv_callback || NULL == send_err_callback) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "osm_vendor_bind: ERR 7302: "
+ "NULL parameter passed in: p_vend=%p p_bind_info=%p p_mad_pool=%p recv_cb=%p send_err_cb=%p\n",
+ p_vend, p_bind_info, p_mad_pool, mad_recv_callback,
+ send_err_callback);
+
+ return OSM_BIND_INVALID_HANDLE;
+ }
+
+ p_bo = malloc(sizeof(osmv_bind_obj_t));
+ if (NULL == p_bo) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "osm_vendor_bind: ERR 7303: could not allocate the bind object\n");
+ return OSM_BIND_INVALID_HANDLE;
+ }
+
+ memset(p_bo, 0, sizeof(osmv_bind_obj_t));
+ p_bo->p_vendor = p_vend;
+ p_bo->recv_cb = mad_recv_callback;
+ p_bo->send_err_cb = send_err_callback;
+ p_bo->cb_context = context;
+ p_bo->p_osm_pool = p_mad_pool;
+
+ /* obtain the hca name and port num from the guid */
+ osm_log(p_bo->p_vendor->p_log, OSM_LOG_DEBUG,
+ "osm_vendor_bind: "
+ "Finding CA and Port that owns port guid 0x%" PRIx64 ".\n",
+ cl_ntoh64(p_bind_info->port_guid));
+
+ status = osm_vendor_get_guid_ca_and_port(p_bo->p_vendor,
+ p_bind_info->port_guid,
+ &(p_bo->hca_hndl),
+ hca_id,
+ &hca_index, &(p_bo->port_num));
+ if (status != IB_SUCCESS) {
+ osm_log(p_bo->p_vendor->p_log, OSM_LOG_ERROR,
+ "osm_vendor_bind: ERR 7304: "
+ "Fail to find port number of port guid:0x%016" PRIx64
+ "\n", p_bind_info->port_guid);
+ free(p_bo);
+ return OSM_BIND_INVALID_HANDLE;
+ }
+
+ /* Initialize the magic_ptr to the pointer of the p_bo info.
+ This will be used to signal when the object is being destroyed, so no
+ real action will be done then. */
+ p_bo->magic_ptr = p_bo;
+
+ p_bo->is_closing = FALSE;
+
+ cl_spinlock_construct(&(p_bo->lock));
+ cl_st = cl_spinlock_init(&(p_bo->lock));
+ if (cl_st != CL_SUCCESS) {
+ osm_log(p_bo->p_vendor->p_log, OSM_LOG_ERROR,
+ "osm_vendor_bind: ERR 7305: "
+ "could not initialize the spinlock ...\n");
+ free(p_bo);
+ return OSM_BIND_INVALID_HANDLE;
+ }
+
+ osm_log(p_bo->p_vendor->p_log, OSM_LOG_DEBUG,
+ "osm_vendor_bind: osmv_txnmgr_init ... \n");
+ if (osmv_txnmgr_init(&p_bo->txn_mgr, p_vend->p_log, &(p_bo->lock)) !=
+ IB_SUCCESS) {
+ osm_log(p_bo->p_vendor->p_log, OSM_LOG_ERROR,
+ "osm_vendor_bind: ERR 7306: "
+ "osmv_txnmgr_init failed \n");
+ cl_spinlock_destroy(&p_bo->lock);
+ free(p_bo);
+ return OSM_BIND_INVALID_HANDLE;
+ }
+
+ /* Do the real job! (Transport-dependent) */
+ if (IB_SUCCESS !=
+ osmv_transport_init(p_bind_info, hca_id, hca_index, p_bo)) {
+ osm_log(p_bo->p_vendor->p_log, OSM_LOG_ERROR,
+ "osm_vendor_bind: ERR 7307: "
+ "osmv_transport_init failed \n");
+ osmv_txnmgr_done((osm_bind_handle_t) p_bo);
+ cl_spinlock_destroy(&p_bo->lock);
+ free(p_bo);
+ return OSM_BIND_INVALID_HANDLE;
+ }
+
+ /* insert bind handle into db */
+ p_obj = malloc(sizeof(cl_list_obj_t));
+ if (NULL == p_obj) {
+
+ osm_log(p_bo->p_vendor->p_log, OSM_LOG_ERROR,
+ "osm_vendor_bind: ERR 7308: "
+ "osm_vendor_bind: could not allocate the list object\n");
+
+ osmv_transport_done(p_bo->p_transp_mgr);
+ osmv_txnmgr_done((osm_bind_handle_t) p_bo);
+ cl_spinlock_destroy(&p_bo->lock);
+ free(p_bo);
+ return OSM_BIND_INVALID_HANDLE;
+ }
+ memset(p_obj, 0, sizeof(cl_list_obj_t));
+ cl_qlist_set_obj(p_obj, p_bo);
+
+ cl_qlist_insert_head(&p_vend->bind_handles, &p_obj->list_item);
+
+ return (osm_bind_handle_t) p_bo;
+}
+
+/*
+ * NAME osm_vendor_unbind
+ *
+ * DESCRIPTION Destroy the bind object and remove it from the vendor's list
+ */
+
+void osm_vendor_unbind(IN osm_bind_handle_t h_bind)
+{
+ osmv_bind_obj_t *p_bo = (osmv_bind_obj_t *) h_bind;
+ osm_log_t *p_log = p_bo->p_vendor->p_log;
+ cl_list_obj_t *p_obj = NULL;
+ cl_list_item_t *p_item, *p_item_tmp;
+ cl_qlist_t *const p_bh_list =
+ (cl_qlist_t * const)&p_bo->p_vendor->bind_handles;
+
+ OSM_LOG_ENTER(p_log);
+
+ /* go over all the items in the list and remove the specific item */
+ p_item = cl_qlist_head(p_bh_list);
+ while (p_item != cl_qlist_end(p_bh_list)) {
+ p_obj = PARENT_STRUCT(p_item, cl_list_obj_t, list_item);
+ if (cl_qlist_obj(p_obj) == h_bind) {
+ break;
+ }
+ p_item_tmp = cl_qlist_next(p_item);
+ p_item = p_item_tmp;
+ }
+
+ CL_ASSERT(p_item != cl_qlist_end(p_bh_list));
+
+ cl_qlist_remove_item(p_bh_list, p_item);
+ if (p_obj)
+ free(p_obj);
+
+ if (h_bind != 0) {
+ __osm_vendor_internal_unbind(h_bind);
+ }
+
+ OSM_LOG_EXIT(p_log);
+}
+
+/*
+ * NAME osm_vendor_get
+ *
+ * DESCRIPTION Allocate the space for a new MAD
+ */
+
+ib_mad_t *osm_vendor_get(IN osm_bind_handle_t h_bind,
+ IN const uint32_t mad_size,
+ IN osm_vend_wrap_t * const p_vw)
+{
+ ib_mad_t *p_mad;
+ osmv_bind_obj_t *p_bo = (osmv_bind_obj_t *) h_bind;
+ osm_vendor_t const *p_vend = p_bo->p_vendor;
+ uint32_t act_mad_size;
+
+ OSM_LOG_ENTER(p_vend->p_log);
+
+ CL_ASSERT(p_vw);
+
+ if (mad_size < MAD_BLOCK_SIZE) {
+ /* Stupid, but the applications want that! */
+ act_mad_size = MAD_BLOCK_SIZE;
+ } else {
+ act_mad_size = mad_size;
+ }
+
+ /* allocate it */
+ p_mad = (ib_mad_t *) malloc(act_mad_size);
+ if (p_mad == NULL) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "osm_vendor_get: ERR 7309: "
+ "Error Obtaining MAD buffer.\n");
+ goto Exit;
+ }
+
+ memset(p_mad, 0, act_mad_size);
+
+ if (osm_log_get_level(p_vend->p_log) >= OSM_LOG_DEBUG) {
+ osm_log(p_vend->p_log, OSM_LOG_DEBUG,
+ "osm_vendor_get: "
+ "Allocated MAD %p, size = %u.\n", p_mad, act_mad_size);
+ }
+ p_vw->p_mad = p_mad;
+
+Exit:
+ OSM_LOG_EXIT(p_vend->p_log);
+ return (p_mad);
+}
+
+/*
+ * NAME osm_vendor_send
+ *
+ * DESCRIPTION Send a MAD buffer (RMPP or simple send).
+ *
+ * Semantics:
+ * (1) The RMPP send completes when every segment
+ * is acknowledged (synchronous)
+ * (2) The simple send completes when the send completion
+ * is received (asynchronous)
+ */
+
+ib_api_status_t
+osm_vendor_send(IN osm_bind_handle_t h_bind,
+ IN osm_madw_t * const p_madw, IN boolean_t const resp_expected)
+{
+ ib_api_status_t ret = IB_SUCCESS;
+ osmv_bind_obj_t *p_bo = (osmv_bind_obj_t *) h_bind;
+ boolean_t is_rmpp = FALSE, is_rmpp_ds = FALSE;
+ osmv_txn_ctx_t *p_txn = NULL;
+ ib_mad_t *p_mad;
+ osm_log_t *p_log = p_bo->p_vendor->p_log;
+ osm_mad_pool_t *p_mad_pool = p_bo->p_osm_pool;
+ OSM_LOG_ENTER(p_log);
+
+ if (NULL == h_bind || NULL == p_madw ||
+ NULL == (p_mad = osm_madw_get_mad_ptr(p_madw)) ||
+ NULL == osm_madw_get_mad_addr_ptr(p_madw)) {
+
+ return IB_INVALID_PARAMETER;
+ }
+
+ is_rmpp = (p_madw->mad_size > MAD_BLOCK_SIZE
+ || osmv_mad_is_rmpp(p_mad));
+ /* is this rmpp double sided? This means we expect a response that can be
+ an rmpp or not */
+ is_rmpp_ds = (TRUE == is_rmpp && TRUE == resp_expected);
+
+ /* Make our operations with the send context atomic */
+ osmv_txn_lock(p_bo);
+
+ if (TRUE == p_bo->is_closing) {
+
+ osm_log(p_log, OSM_LOG_ERROR,
+ "osm_vendor_send: ERR 7310: "
+ "The handle %p is being unbound, cannot send.\n",
+ h_bind);
+ ret = IB_INTERRUPTED;
+ /* When closing p_bo could be detroyed or is going to , thus could not refer to it */
+ goto send_done;
+ }
+
+ if (TRUE == resp_expected || TRUE == is_rmpp) {
+
+ /* We must run under a transaction framework.
+ * Get the transaction object (old or new) */
+ ret = __osmv_get_send_txn(h_bind, p_madw, is_rmpp,
+ resp_expected, &p_txn);
+ if (IB_SUCCESS != ret) {
+ goto send_done;
+ }
+ }
+
+ if (TRUE == is_rmpp) {
+ /* Do the job - RMPP!
+ * The call returns as all the packets are ACK'ed/upon error
+ * The txn lock will be released each time the function sleeps
+ * and re-acquired when it wakes up
+ */
+ ret = osmv_rmpp_send_madw(h_bind, p_madw, p_txn, is_rmpp_ds);
+ } else {
+
+ /* Do the job - single MAD!
+ * The call returns as soon as the MAD is put on the wire
+ */
+ ret = osmv_simple_send_madw(h_bind, p_madw, p_txn, FALSE);
+ }
+
+ if (IB_SUCCESS == ret) {
+
+ if ((TRUE == is_rmpp) && (FALSE == is_rmpp_ds)) {
+ /* For double-sided sends, the txn continues to live */
+ osmv_txn_done(h_bind, osmv_txn_get_key(p_txn),
+ FALSE /*not in callback */ );
+ }
+
+ if (FALSE == resp_expected) {
+ osm_mad_pool_put(p_mad_pool, p_madw);
+ }
+ } else if (IB_INTERRUPTED != ret) {
+ if (NULL != p_txn) {
+ osmv_txn_done(h_bind, osmv_txn_get_key(p_txn),
+ FALSE /*not in callback */ );
+ }
+
+ osm_log(p_log, OSM_LOG_ERROR,
+ "osm_vendor_send: ERR 7311: failed to send MADW %p\n",
+ p_madw);
+
+ if (TRUE == resp_expected) {
+ /* Change the status on the p_madw */
+ p_madw->status = ret;
+ /* Only the requester expects the error callback */
+ p_bo->send_err_cb(p_bo->cb_context, p_madw);
+ } else {
+ /* put back the mad - it is useless ... */
+ osm_mad_pool_put(p_mad_pool, p_madw);
+ }
+ } else { /* the transaction was aborted due to p_bo exit */
+
+ osm_mad_pool_put(p_mad_pool, p_madw);
+ goto aborted;
+ }
+send_done:
+
+ osmv_txn_unlock(p_bo);
+aborted:
+ OSM_LOG_EXIT(p_log);
+ return ret;
+}
+
+/*
+ * NAME osm_vendor_put
+ *
+ * DESCRIPTION Free the MAD's memory
+ */
+
+void
+osm_vendor_put(IN osm_bind_handle_t h_bind, IN osm_vend_wrap_t * const p_vw)
+{
+
+ osmv_bind_obj_t *p_bo = (osmv_bind_obj_t *) h_bind;
+ osm_vendor_t const *p_vend = p_bo->p_vendor;
+
+ if (p_bo->is_closing != TRUE) {
+ OSM_LOG_ENTER(p_vend->p_log);
+
+ CL_ASSERT(p_vw);
+ CL_ASSERT(p_vw->p_mad);
+
+ if (osm_log_get_level(p_vend->p_log) >= OSM_LOG_DEBUG) {
+ osm_log(p_vend->p_log, OSM_LOG_DEBUG,
+ "osm_vendor_put: " "Retiring MAD %p.\n",
+ p_vw->p_mad);
+ }
+
+ free(p_vw->p_mad);
+ p_vw->p_mad = NULL;
+
+ OSM_LOG_EXIT(p_vend->p_log);
+ }
+}
+
+/*
+ * NAME osm_vendor_local_lid_change
+ *
+ * DESCRIPTION Notifies the vendor transport layer that the local address
+ * has changed. This allows the vendor layer to perform
+ * housekeeping functions such as address vector updates.
+ */
+
+ib_api_status_t osm_vendor_local_lid_change(IN osm_bind_handle_t h_bind)
+{
+ osm_vendor_t const *p_vend = ((osmv_bind_obj_t *) h_bind)->p_vendor;
+ OSM_LOG_ENTER(p_vend->p_log);
+
+ osm_log(p_vend->p_log, OSM_LOG_DEBUG,
+ "osm_vendor_local_lid_change: " "Change of LID.\n");
+
+ OSM_LOG_EXIT(p_vend->p_log);
+
+ return (IB_SUCCESS);
+
+}
+
+/*
+ * NAME osm_vendor_set_sm
+ *
+ * DESCRIPTION Modifies the port info for the bound port to set the "IS_SM" bit
+ * according to the value given (TRUE or FALSE).
+ */
+#if !(defined(OSM_VENDOR_INTF_TS_NO_VAPI) || defined(OSM_VENDOR_INTF_SIM) || defined(OSM_VENDOR_INTF_TS))
+void osm_vendor_set_sm(IN osm_bind_handle_t h_bind, IN boolean_t is_sm_val)
+{
+ osmv_bind_obj_t *p_bo = (osmv_bind_obj_t *) h_bind;
+ osm_vendor_t const *p_vend = p_bo->p_vendor;
+ VAPI_ret_t status;
+ VAPI_hca_attr_t attr_mod;
+ VAPI_hca_attr_mask_t attr_mask;
+
+ OSM_LOG_ENTER(p_vend->p_log);
+
+ memset(&attr_mod, 0, sizeof(attr_mod));
+ memset(&attr_mask, 0, sizeof(attr_mask));
+
+ attr_mod.is_sm = is_sm_val;
+ attr_mask = HCA_ATTR_IS_SM;
+
+ status =
+ VAPI_modify_hca_attr(p_bo->hca_hndl, p_bo->port_num, &attr_mod,
+ &attr_mask);
+ if (status != VAPI_OK) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "osm_vendor_set_sm: ERR 7312: "
+ "Unable set 'IS_SM' bit to:%u in port attributes (%d).\n",
+ is_sm_val, status);
+ }
+
+ OSM_LOG_EXIT(p_vend->p_log);
+}
+
+#endif
+
+/*
+ * NAME __osm_vendor_internal_unbind
+ *
+ * DESCRIPTION Destroying a bind:
+ * (1) Wait for the completion of the sends in flight
+ * (2) Destroy the associated data structures
+ */
+
+static void __osm_vendor_internal_unbind(osm_bind_handle_t h_bind)
+{
+ osmv_bind_obj_t *p_bo = (osmv_bind_obj_t *) h_bind;
+ osm_log_t *p_log = p_bo->p_vendor->p_log;
+
+ OSM_LOG_ENTER(p_log);
+
+ /* "notifying" all that from now on no new sends can be done */
+ p_bo->txn_mgr.p_event_wheel->closing = TRUE;
+
+ osmv_txn_lock(p_bo);
+
+ /*
+ the is_closing is set under lock we we know we only need to
+ check for it after obtaining the lock
+ */
+ p_bo->is_closing = TRUE;
+
+ /* notifying all sleeping rmpp sends to exit */
+ osmv_txn_abort_rmpp_txns(h_bind);
+
+ /* unlock the bo to allow for any residual mads to be dispatched */
+ osmv_txn_unlock(p_bo);
+ osm_log(p_log, OSM_LOG_DEBUG,
+ "__osm_vendor_internal_unbind: destroying transport mgr.. \n");
+ /* wait for the receiver thread to exit */
+ osmv_transport_done(h_bind);
+
+ /* lock to avoid any collissions while we cleanup the structs */
+ osmv_txn_lock(p_bo);
+ osm_log(p_log, OSM_LOG_DEBUG,
+ "__osm_vendor_internal_unbind: destroying txn mgr.. \n");
+ osmv_txnmgr_done(h_bind);
+ osm_log(p_log, OSM_LOG_DEBUG,
+ "__osm_vendor_internal_unbind: destroying bind lock.. \n");
+ osmv_txn_unlock(p_bo);
+
+ /*
+ we intentionally let the p_bo and its lock leak -
+ as we did not implement a way to track active bind handles provided to
+ the client - and the client might use them
+
+ cl_spinlock_destroy(&p_bo->lock);
+ free(p_bo);
+ */
+
+ OSM_LOG_EXIT(p_log);
+}
+
+/*
+ * NAME __osmv_get_send_txn
+ *
+ * DESCRIPTION Return a transaction object that corresponds to this MAD.
+ * Optionally, create it, if the new request (query) is sent or received.
+ */
+
+static ib_api_status_t
+__osmv_get_send_txn(IN osm_bind_handle_t h_bind,
+ IN osm_madw_t * const p_madw,
+ IN boolean_t is_rmpp,
+ IN boolean_t resp_expected, OUT osmv_txn_ctx_t ** pp_txn)
+{
+ ib_api_status_t ret;
+ uint64_t tid, key;
+ osmv_bind_obj_t *p_bo = (osmv_bind_obj_t *) h_bind;
+ ib_mad_t *p_mad = osm_madw_get_mad_ptr(p_madw);
+
+ OSM_LOG_ENTER(p_bo->p_vendor->p_log);
+ CL_ASSERT(NULL != pp_txn);
+
+ key = tid = cl_ntoh64(p_mad->trans_id);
+ if (TRUE == resp_expected) {
+ /* Create a unique identifier at the requester side */
+ key = osmv_txn_uniq_key(tid);
+ }
+
+ /* We must run under a transaction framework */
+ ret = osmv_txn_lookup(h_bind, key, pp_txn);
+ if (IB_NOT_FOUND == ret) {
+ /* Generally, we start a new transaction */
+ ret = osmv_txn_init(h_bind, tid, key, pp_txn);
+ if (IB_SUCCESS != ret) {
+ osm_log(p_bo->p_vendor->p_log, OSM_LOG_ERROR,
+ "__osmv_get_send_txn: ERR 7313: "
+ "The transaction id=0x%" PRIx64 " failed to init.\n",
+ tid);
+ goto get_send_txn_done;
+ }
+ } else {
+ CL_ASSERT(NULL != *pp_txn);
+ /* The transaction context exists.
+ * This is legal only if I am going to return an
+ * (RMPP?) reply to an RMPP request sent by the other part
+ * (double-sided RMPP transfer)
+ */
+ if (FALSE == is_rmpp
+ || FALSE == osmv_txn_is_rmpp_init_by_peer(*pp_txn)) {
+ osm_log(p_bo->p_vendor->p_log, OSM_LOG_ERROR,
+ "__osmv_get_send_txn: ERR 7314: "
+ "The transaction id=0x%" PRIx64 " is not unique. Send failed.\n",
+ tid);
+
+ ret = IB_INVALID_SETTING;
+ goto get_send_txn_done;
+ }
+
+ if (TRUE == resp_expected) {
+ osm_log(p_bo->p_vendor->p_log, OSM_LOG_ERROR,
+ "__osmv_get_send_txn: ERR 7315: "
+ "The transaction id=0x%" PRIx64 " can't expect a response. Send failed.\n",
+ tid);
+
+ ret = IB_INVALID_PARAMETER;
+ goto get_send_txn_done;
+ }
+ }
+
+ if (TRUE == is_rmpp) {
+ ret = osmv_txn_init_rmpp_sender(h_bind, *pp_txn, p_madw);
+ if (IB_SUCCESS != ret) {
+ osm_log(p_bo->p_vendor->p_log, OSM_LOG_ERROR,
+ "__osmv_get_send_txn: ERR 7316: "
+ "The transaction id=0x%" PRIx64 " failed to init the rmpp mad. Send failed.\n",
+ tid);
+ osmv_txn_done(h_bind, tid, FALSE);
+ goto get_send_txn_done;
+ }
+ }
+
+ /* Save a reference to the MAD in the txn context
+ * We'll need to match it in two cases:
+ * (1) When the response is returned, if I am the requester
+ * (2) In RMPP retransmissions
+ */
+ osmv_txn_set_madw(*pp_txn, p_madw);
+
+get_send_txn_done:
+ OSM_LOG_EXIT(p_bo->p_vendor->p_log);
+
+ return ret;
+}
+
+void osm_vendor_set_debug(IN osm_vendor_t * const p_vend, IN int32_t level)
+{
+
+}
diff --git a/contrib/ofed/opensm/libvendor/osm_vendor_mlx_anafa.c b/contrib/ofed/opensm/libvendor/osm_vendor_mlx_anafa.c
new file mode 100644
index 0000000..fbaab1d
--- /dev/null
+++ b/contrib/ofed/opensm/libvendor/osm_vendor_mlx_anafa.c
@@ -0,0 +1,751 @@
+/*
+ * Copyright (c) 2004-2008 Voltaire, Inc. All rights reserved.
+ * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved.
+ * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+#if HAVE_CONFIG_H
+# include <config.h>
+#endif /* HAVE_CONFIG_H */
+
+#include <sys/ioctl.h>
+#include <stdlib.h>
+#include <stddef.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <errno.h>
+
+#include <vendor/osm_vendor_mlx.h>
+#include <vendor/osm_vendor_mlx_transport.h>
+#include <vendor/osm_vendor_mlx_transport_anafa.h>
+#include <vendor/osm_vendor_mlx_svc.h>
+#include <vendor/osm_vendor_mlx_sender.h>
+#include <vendor/osm_pkt_randomizer.h>
+#include <vendor/osm_ts_useraccess.h>
+
+/**
+ * FORWARD REFERENCES
+ */
+static ib_api_status_t
+__osmv_get_send_txn(IN osm_bind_handle_t h_bind,
+ IN osm_madw_t * const p_madw,
+ IN boolean_t is_rmpp,
+ IN boolean_t resp_expected, OUT osmv_txn_ctx_t ** pp_txn);
+
+static void __osm_vendor_internal_unbind(osm_bind_handle_t h_bind);
+
+/*
+ * NAME osm_vendor_new
+ *
+ * DESCRIPTION Create and Initialize the osm_vendor_t Object
+ */
+
+osm_vendor_t *osm_vendor_new(IN osm_log_t * const p_log,
+ IN const uint32_t timeout)
+{
+ ib_api_status_t status;
+ osm_vendor_t *p_vend;
+
+ OSM_LOG_ENTER(p_log);
+
+ CL_ASSERT(p_log);
+
+ p_vend = malloc(sizeof(*p_vend));
+ if (p_vend != NULL) {
+ memset(p_vend, 0, sizeof(*p_vend));
+ status = osm_vendor_init(p_vend, p_log, timeout);
+ if (status != IB_SUCCESS) {
+ osm_vendor_delete(&p_vend);
+ }
+ } else {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "osm_vendor_new: ERR 7401: "
+ "Fail to allocate vendor object.\n");
+ }
+
+ OSM_LOG_EXIT(p_log);
+ return (p_vend);
+}
+
+/*
+ * NAME osm_vendor_delete
+ *
+ * DESCRIPTION Delete all the binds behind the vendor + free the vendor object
+ */
+
+void osm_vendor_delete(IN osm_vendor_t ** const pp_vend)
+{
+ cl_list_item_t *p_item;
+ cl_list_obj_t *p_obj;
+ osm_bind_handle_t bind_h;
+ osm_log_t *p_log;
+
+ OSM_LOG_ENTER((*pp_vend)->p_log);
+ p_log = (*pp_vend)->p_log;
+
+ /* go over the bind handles , unbind them and remove from list */
+ /* Note that if we reached here due to problem in the init, then
+ the bind_handles list is not initialized yet */
+ if ((*pp_vend)->bind_handles.state == CL_INITIALIZED) {
+ p_item = cl_qlist_remove_head(&((*pp_vend)->bind_handles));
+ while (p_item != cl_qlist_end(&((*pp_vend)->bind_handles))) {
+
+ p_obj = PARENT_STRUCT(p_item, cl_list_obj_t, list_item);
+ bind_h = (osm_bind_handle_t *) cl_qlist_obj(p_obj);
+ osm_log(p_log, OSM_LOG_DEBUG,
+ "osm_vendor_delete: unbinding bind_h:%p \n",
+ bind_h);
+
+ __osm_vendor_internal_unbind(bind_h);
+
+ free(p_obj);
+ /* removing from list */
+ p_item =
+ cl_qlist_remove_head(&((*pp_vend)->bind_handles));
+ }
+ }
+
+ if (NULL != ((*pp_vend)->p_transport_info)) {
+ free((*pp_vend)->p_transport_info);
+ (*pp_vend)->p_transport_info = NULL;
+ }
+
+ /* remove the packet randomizer object */
+ if ((*pp_vend)->run_randomizer == TRUE)
+ osm_pkt_randomizer_destroy(&((*pp_vend)->p_pkt_randomizer),
+ p_log);
+
+ free(*pp_vend);
+ *pp_vend = NULL;
+
+ OSM_LOG_EXIT(p_log);
+}
+
+/*
+ * NAME osm_vendor_init
+ *
+ * DESCRIPTION Initialize the vendor object
+ */
+
+ib_api_status_t
+osm_vendor_init(IN osm_vendor_t * const p_vend,
+ IN osm_log_t * const p_log, IN const uint32_t timeout)
+{
+ ib_api_status_t status = IB_SUCCESS;
+ char device_file[16];
+ int device_fd;
+
+ OSM_LOG_ENTER(p_log);
+
+ p_vend->p_log = p_log;
+ p_vend->resp_timeout = timeout;
+ p_vend->ttime_timeout = timeout * OSMV_TXN_TIMEOUT_FACTOR;
+
+ p_vend->p_transport_info = (osmv_TOPSPIN_ANAFA_transport_info_t *)
+ malloc(sizeof(osmv_TOPSPIN_ANAFA_transport_info_t));
+ if (!p_vend->p_transport_info) {
+ return IB_ERROR;
+ }
+
+ memset(p_vend->p_transport_info, 0,
+ sizeof(osmv_TOPSPIN_ANAFA_transport_info_t));
+
+ /* update the run_randomizer flag */
+ if (getenv("OSM_PKT_DROP_RATE") != NULL
+ && atol(getenv("OSM_PKT_DROP_RATE")) != 0) {
+ /* if the OSM_PKT_DROP_RATE global variable is defined
+ to a non-zero value -
+ then the randomizer should be called.
+ Need to create the packet randomizer object */
+ p_vend->run_randomizer = TRUE;
+ status =
+ osm_pkt_randomizer_init(&(p_vend->p_pkt_randomizer), p_log);
+ if (status != IB_SUCCESS)
+ return status;
+ } else {
+ p_vend->run_randomizer = FALSE;
+ p_vend->p_pkt_randomizer = NULL;
+ }
+
+ /* open TopSpin file device */
+ sprintf(device_file, "/dev/ts_ua0");
+ device_fd = open("/dev/ts_ua0", O_RDWR);
+ if (device_fd < 0) {
+ fprintf(stderr, "Fatal: Fail to open the file:%s(%d)\n",
+ device_file, errno);
+ return IB_ERROR;
+ }
+
+ ((osmv_TOPSPIN_ANAFA_transport_info_t *) p_vend->p_transport_info)->
+ device_fd = device_fd;
+
+ cl_qlist_init(&p_vend->bind_handles);
+
+ OSM_LOG_EXIT(p_log);
+ return (IB_SUCCESS);
+}
+
+/*
+ * NAME osm_vendor_bind
+ *
+ * DESCRIPTION Create a new bind object under the vendor object
+ */
+
+osm_bind_handle_t
+osm_vendor_bind(IN osm_vendor_t * const p_vend,
+ IN osm_bind_info_t * const p_bind_info,
+ IN osm_mad_pool_t * const p_mad_pool,
+ IN osm_vend_mad_recv_callback_t mad_recv_callback,
+ IN osm_vend_mad_send_err_callback_t send_err_callback,
+ IN void *context)
+{
+ osmv_bind_obj_t *p_bo;
+ cl_status_t cl_st;
+ cl_list_obj_t *p_obj;
+ uint8_t hca_idx = 0;
+
+ if (NULL == p_vend || NULL == p_bind_info || NULL == p_mad_pool
+ || NULL == mad_recv_callback || NULL == send_err_callback) {
+ osm_log(p_bo->p_vendor->p_log, OSM_LOG_ERROR,
+ "osm_vendor_bind: ERR 7402: "
+ "NULL parameter passed in: p_vend=%p p_bind_info=%p p_mad_pool=%p recv_cb=%p send_err_cb=%p\n",
+ p_vend, p_bind_info, p_mad_pool, mad_recv_callback,
+ send_err_callback);
+
+ return OSM_BIND_INVALID_HANDLE;
+ }
+
+ p_bo = malloc(sizeof(osmv_bind_obj_t));
+ if (NULL == p_bo) {
+ osm_log(p_bo->p_vendor->p_log, OSM_LOG_ERROR,
+ "osm_vendor_bind: ERR 7403: "
+ "could not allocate the bind object\n");
+ return OSM_BIND_INVALID_HANDLE;
+ }
+
+ memset(p_bo, 0, sizeof(osmv_bind_obj_t));
+ p_bo->p_vendor = p_vend;
+ p_bo->recv_cb = mad_recv_callback;
+ p_bo->send_err_cb = send_err_callback;
+ p_bo->cb_context = context;
+ p_bo->p_osm_pool = p_mad_pool;
+ p_bo->port_num = 1; /* anafa2 has one port */
+ p_bo->hca_hndl = 0; /* only one ca on anafa system */
+
+ /* obtain the hca name and port num from the guid */
+ osm_log(p_bo->p_vendor->p_log, OSM_LOG_DEBUG,
+ "osm_vendor_bind: "
+ "Finding CA and Port that owns port guid 0x%" PRIx64 ".\n",
+ cl_ntoh64(p_bind_info->port_guid));
+
+ p_bo->is_closing = FALSE;
+ cl_spinlock_construct(&(p_bo->lock));
+ cl_st = cl_spinlock_init(&(p_bo->lock));
+ if (cl_st != CL_SUCCESS) {
+ osm_log(p_bo->p_vendor->p_log, OSM_LOG_ERROR,
+ "osm_vendor_bind: ERR 7405: "
+ "could not initialize the spinlock ...\n");
+ free(p_bo);
+ return OSM_BIND_INVALID_HANDLE;
+ }
+
+ osm_log(p_bo->p_vendor->p_log, OSM_LOG_DEBUG,
+ "osm_vendor_bind: osmv_txnmgr_init ... \n");
+ if (osmv_txnmgr_init(&p_bo->txn_mgr, p_vend->p_log, &(p_bo->lock)) !=
+ IB_SUCCESS) {
+ osm_log(p_bo->p_vendor->p_log, OSM_LOG_ERROR,
+ "osm_vendor_bind: ERR 7406: "
+ "osmv_txnmgr_init failed \n");
+ cl_spinlock_destroy(&p_bo->lock);
+ free(p_bo);
+ return OSM_BIND_INVALID_HANDLE;
+ }
+
+ /* Do the real job! (Transport-dependent) */
+ if (IB_SUCCESS !=
+ osmv_transport_init(p_bind_info, OSMV_ANAFA_ID, hca_idx, p_bo)) {
+ osm_log(p_bo->p_vendor->p_log, OSM_LOG_ERROR,
+ "osm_vendor_bind: ERR 7407: "
+ "osmv_transport_init failed \n");
+ osmv_txnmgr_done((osm_bind_handle_t) p_bo);
+ cl_spinlock_destroy(&p_bo->lock);
+ free(p_bo);
+ return OSM_BIND_INVALID_HANDLE;
+ }
+
+ /* insert bind handle into db */
+ p_obj = malloc(sizeof(cl_list_obj_t));
+ if (NULL == p_obj) {
+
+ osm_log(p_bo->p_vendor->p_log, OSM_LOG_ERROR,
+ "osm_vendor_bind: ERR 7408: "
+ "osm_vendor_bind: could not allocate the list object\n");
+
+ osmv_transport_done(p_bo->p_transp_mgr);
+ osmv_txnmgr_done((osm_bind_handle_t) p_bo);
+ cl_spinlock_destroy(&p_bo->lock);
+ free(p_bo);
+ return OSM_BIND_INVALID_HANDLE;
+ }
+ if (p_obj)
+ memset(p_obj, 0, sizeof(cl_list_obj_t));
+ cl_qlist_set_obj(p_obj, p_bo);
+
+ cl_qlist_insert_head(&p_vend->bind_handles, &p_obj->list_item);
+
+ return (osm_bind_handle_t) p_bo;
+}
+
+/*
+ * NAME osm_vendor_unbind
+ *
+ * DESCRIPTION Destroy the bind object and remove it from the vendor's list
+ */
+
+void osm_vendor_unbind(IN osm_bind_handle_t h_bind)
+{
+ osmv_bind_obj_t *p_bo = (osmv_bind_obj_t *) h_bind;
+ osm_log_t *p_log = p_bo->p_vendor->p_log;
+ cl_list_obj_t *p_obj;
+ cl_list_item_t *p_item, *p_item_tmp;
+ cl_qlist_t *const p_bh_list =
+ (cl_qlist_t * const)&p_bo->p_vendor->bind_handles;
+
+ OSM_LOG_ENTER(p_log);
+
+ /* go over all the items in the list and remove the specific item */
+ p_item = cl_qlist_head(&p_bo->p_vendor->bind_handles);
+ while (p_item != cl_qlist_end(&p_bo->p_vendor->bind_handles)) {
+ p_obj = PARENT_STRUCT(p_item, cl_list_obj_t, list_item);
+ if (cl_qlist_obj(p_obj) == h_bind) {
+ break;
+ }
+ p_item_tmp = cl_qlist_next(p_item);
+ p_item = p_item_tmp;
+ }
+
+ CL_ASSERT(p_item != cl_qlist_end(p_bh_list));
+
+ cl_qlist_remove_item(p_bh_list, p_item);
+ free(p_obj);
+
+ __osm_vendor_internal_unbind(h_bind);
+
+ OSM_LOG_EXIT(p_bo->p_vendor->p_log);
+}
+
+/*
+ * NAME osm_vendor_get
+ *
+ * DESCRIPTION Allocate the space for a new MAD
+ */
+
+ib_mad_t *osm_vendor_get(IN osm_bind_handle_t h_bind,
+ IN const uint32_t mad_size,
+ IN osm_vend_wrap_t * const p_vw)
+{
+ ib_mad_t *p_mad;
+ osmv_bind_obj_t *p_bo = (osmv_bind_obj_t *) h_bind;
+ osm_vendor_t const *p_vend = p_bo->p_vendor;
+ uint32_t act_mad_size;
+
+ OSM_LOG_ENTER(p_vend->p_log);
+
+ CL_ASSERT(p_vw);
+
+ if (mad_size < MAD_BLOCK_SIZE) {
+ /* Stupid, but the applications want that! */
+ act_mad_size = MAD_BLOCK_SIZE;
+ } else {
+ act_mad_size = mad_size;
+ }
+
+ /* allocate it */
+ p_mad = (ib_mad_t *) malloc(act_mad_size);
+ if (p_mad == NULL) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "osm_vendor_get: ERR 7409: "
+ "Error Obtaining MAD buffer.\n");
+ goto Exit;
+ }
+
+ memset(p_mad, 0, act_mad_size);
+
+ if (osm_log_get_level(p_vend->p_log) >= OSM_LOG_DEBUG) {
+ osm_log(p_vend->p_log, OSM_LOG_DEBUG,
+ "osm_vendor_get: "
+ "Allocated MAD %p, size = %u.\n", p_mad, act_mad_size);
+ }
+ p_vw->p_mad = p_mad;
+
+Exit:
+ OSM_LOG_EXIT(p_vend->p_log);
+ return (p_mad);
+}
+
+/*
+ * NAME osm_vendor_send
+ *
+ * DESCRIPTION Send a MAD buffer (RMPP or simple send).
+ *
+ * Semantics:
+ * (1) The RMPP send completes when every segment
+ * is acknowledged (synchronous)
+ * (2) The simple send completes when the send completion
+ * is received (asynchronous)
+ */
+
+ib_api_status_t
+osm_vendor_send(IN osm_bind_handle_t h_bind,
+ IN osm_madw_t * const p_madw, IN boolean_t const resp_expected)
+{
+ ib_api_status_t ret = IB_SUCCESS;
+ osmv_bind_obj_t *p_bo = (osmv_bind_obj_t *) h_bind;
+ boolean_t is_rmpp = FALSE, is_rmpp_ds = FALSE;
+ osmv_txn_ctx_t *p_txn = NULL;
+ ib_mad_t *p_mad;
+
+ OSM_LOG_ENTER(p_bo->p_vendor->p_log);
+
+ if (NULL == h_bind || NULL == p_madw ||
+ NULL == (p_mad = osm_madw_get_mad_ptr(p_madw)) ||
+ NULL == osm_madw_get_mad_addr_ptr(p_madw)) {
+
+ return IB_INVALID_PARAMETER;
+ }
+
+ is_rmpp = (p_madw->mad_size > MAD_BLOCK_SIZE
+ || osmv_mad_is_rmpp(p_mad));
+ is_rmpp_ds = (TRUE == is_rmpp && TRUE == resp_expected);
+
+ /* Make our operations with the send context atomic */
+ osmv_txn_lock(p_bo);
+
+ if (TRUE == p_bo->is_closing) {
+ osm_log(p_bo->p_vendor->p_log, OSM_LOG_ERROR,
+ "osm_vendor_send: ERR 7410: "
+ "The handle %p is being unbound, cannot send.\n",
+ h_bind);
+ ret = IB_INTERRUPTED;
+ goto send_done;
+ }
+
+ if (TRUE == resp_expected || TRUE == is_rmpp) {
+
+ /* We must run under a transaction framework.
+ * Get the transaction object (old or new) */
+ ret = __osmv_get_send_txn(h_bind, p_madw, is_rmpp,
+ resp_expected, &p_txn);
+ if (IB_SUCCESS != ret) {
+ goto send_done;
+ }
+ }
+
+ if (TRUE == is_rmpp) {
+ /* Do the job - RMPP!
+ * The call returns as all the packets are ACK'ed/upon error
+ * The txn lock will be released each time the function sleeps
+ * and re-acquired when it wakes up
+ */
+ ret = osmv_rmpp_send_madw(h_bind, p_madw, p_txn, is_rmpp_ds);
+ } else {
+
+ /* Do the job - single MAD!
+ * The call returns as soon as the MAD is put on the wire
+ */
+ ret = osmv_simple_send_madw(h_bind, p_madw, p_txn, FALSE); /* anafa2 */
+ }
+
+ if (IB_SUCCESS == ret) {
+
+ if ((TRUE == is_rmpp) && (FALSE == is_rmpp_ds)) {
+ /* For double-sided sends, the txn continues to live */
+ osmv_txn_done(h_bind, osmv_txn_get_key(p_txn),
+ FALSE /*not in callback */ );
+ }
+
+ if (FALSE == resp_expected) {
+ osm_mad_pool_put(p_bo->p_osm_pool, p_madw);
+ }
+ } else {
+ if (NULL != p_txn) {
+ osmv_txn_done(h_bind, osmv_txn_get_key(p_txn),
+ FALSE /*not in callback */ );
+ }
+
+ osm_log(p_bo->p_vendor->p_log, OSM_LOG_ERROR,
+ "osm_vendor_send: ERR 7411: failed to send MADW %p\n",
+ p_madw);
+
+ if (TRUE == resp_expected) {
+ /* Change the status on the p_madw */
+ p_madw->status = ret;
+ /* Only the requester expects the error callback */
+ p_bo->send_err_cb(p_bo->cb_context, p_madw);
+ } else {
+ /* put back the mad - it is useless ... */
+ osm_mad_pool_put(p_bo->p_osm_pool, p_madw);
+ }
+ }
+
+send_done:
+
+ osmv_txn_unlock(p_bo);
+
+ OSM_LOG_EXIT(p_bo->p_vendor->p_log);
+ return ret;
+}
+
+/*
+ * NAME osm_vendor_put
+ *
+ * DESCRIPTION Free the MAD's memory
+ */
+
+void
+osm_vendor_put(IN osm_bind_handle_t h_bind, IN osm_vend_wrap_t * const p_vw)
+{
+
+ osmv_bind_obj_t *p_bo = (osmv_bind_obj_t *) h_bind;
+ osm_vendor_t const *p_vend = p_bo->p_vendor;
+
+ OSM_LOG_ENTER(p_vend->p_log);
+
+ CL_ASSERT(p_vw);
+ CL_ASSERT(p_vw->p_mad);
+
+ if (osm_log_get_level(p_vend->p_log) >= OSM_LOG_DEBUG) {
+ osm_log(p_vend->p_log, OSM_LOG_DEBUG,
+ "osm_vendor_put: " "Retiring MAD %p.\n", p_vw->p_mad);
+ }
+
+ free(p_vw->p_mad);
+ p_vw->p_mad = NULL;
+
+ OSM_LOG_EXIT(p_vend->p_log);
+}
+
+/*
+ * NAME osm_vendor_local_lid_change
+ *
+ * DESCRIPTION Notifies the vendor transport layer that the local address
+ * has changed. This allows the vendor layer to perform
+ * housekeeping functions such as address vector updates.
+ */
+
+ib_api_status_t osm_vendor_local_lid_change(IN osm_bind_handle_t h_bind)
+{
+ osm_vendor_t const *p_vend = ((osmv_bind_obj_t *) h_bind)->p_vendor;
+ OSM_LOG_ENTER(p_vend->p_log);
+
+ osm_log(p_vend->p_log, OSM_LOG_DEBUG,
+ "osm_vendor_local_lid_change: " "Change of LID.\n");
+
+ OSM_LOG_EXIT(p_vend->p_log);
+
+ return (IB_SUCCESS);
+
+}
+
+/*
+ * NAME osm_vendor_set_sm
+ *
+ * DESCRIPTION Modifies the port info for the bound port to set the "IS_SM" bit.
+ */
+
+void osm_vendor_set_sm(IN osm_bind_handle_t h_bind, IN boolean_t is_sm_val)
+{
+ osmv_bind_obj_t *p_bo = (osmv_bind_obj_t *) h_bind;
+ osm_vendor_t const *p_vend = p_bo->p_vendor;
+ osmv_TOPSPIN_ANAFA_transport_mgr_t *p_mgr;
+ int ioctl_ret;
+ osm_ts_set_port_info_ioctl port_info;
+
+ OSM_LOG_ENTER(p_vend->p_log);
+
+ port_info.port = 0; /* anafa has only 1 port */
+ port_info.port_info.valid_fields = IB_PORT_IS_SM;
+ port_info.port_info.is_sm = is_sm_val;
+
+ p_mgr = (osmv_TOPSPIN_ANAFA_transport_mgr_t *) p_bo->p_transp_mgr;
+ ioctl_ret = ioctl(p_mgr->device_fd, TS_IB_IOCSPORTINFO, &port_info);
+
+ if (ioctl_ret < 0) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "osm_vendor_set_sm: ERR 7412: "
+ "Unable set 'IS_SM' bit to:%u in port attributes (%d). errno=%d\n",
+ is_sm_val, ioctl_ret, errno);
+ }
+
+ OSM_LOG_EXIT(p_vend->p_log);
+}
+
+/*
+ * NAME __osm_vendor_internal_unbind
+ *
+ * DESCRIPTION Destroying a bind:
+ * (1) Wait for the completion of the sends in flight
+ * (2) Destroy the associated data structures
+ */
+
+static void __osm_vendor_internal_unbind(osm_bind_handle_t h_bind)
+{
+ osmv_bind_obj_t *p_bo = (osmv_bind_obj_t *) h_bind;
+ osm_log_t *p_log = p_bo->p_vendor->p_log;
+
+ OSM_LOG_ENTER(p_log);
+
+ /* "notifying" all that from now on no new sends can be done */
+ p_bo->txn_mgr.p_event_wheel->closing = TRUE;
+
+ osmv_txn_lock(p_bo);
+ p_bo->is_closing = TRUE;
+
+ /* notifying all sleeping rmpp sends to exit */
+ osmv_txn_abort_rmpp_txns(h_bind);
+
+ /* frees all data in bind handle */
+ osm_log(p_log, OSM_LOG_DEBUG,
+ "__osm_vendor_internal_unbind: destroying transport mgr.. \n");
+ osmv_txn_unlock(p_bo);
+
+ osmv_transport_done(h_bind);
+ osm_log(p_log, OSM_LOG_DEBUG,
+ "__osm_vendor_internal_unbind: destroying txn mgr.. \n");
+ osmv_txn_lock(p_bo);
+ osmv_txnmgr_done(h_bind);
+ osm_log(p_log, OSM_LOG_DEBUG,
+ "__osm_vendor_internal_unbind: destroying bind lock.. \n");
+
+ osmv_txn_unlock(p_bo);
+ /*
+ we intentionally let the p_bo and its lock leak -
+ as we did not implement a way to track active bind handles provided to
+ the client - and the client might use them
+
+ cl_spinlock_destroy(&p_bo->lock);
+ free(p_bo);
+ */
+
+ OSM_LOG_EXIT(p_log);
+}
+
+/*
+ * NAME __osmv_get_send_txn
+ *
+ * DESCRIPTION Return a transaction object that corresponds to this MAD.
+ * Optionally, create it, if the new request (query) is sent or received.
+ */
+
+static ib_api_status_t
+__osmv_get_send_txn(IN osm_bind_handle_t h_bind,
+ IN osm_madw_t * const p_madw,
+ IN boolean_t is_rmpp,
+ IN boolean_t resp_expected, OUT osmv_txn_ctx_t ** pp_txn)
+{
+ ib_api_status_t ret;
+ uint64_t tid, key;
+ osmv_bind_obj_t *p_bo = (osmv_bind_obj_t *) h_bind;
+ ib_mad_t *p_mad = osm_madw_get_mad_ptr(p_madw);
+
+ OSM_LOG_ENTER(p_bo->p_vendor->p_log);
+ CL_ASSERT(NULL != pp_txn);
+
+ key = tid = cl_ntoh64(p_mad->trans_id);
+ if (TRUE == resp_expected) {
+ /* Create a unique identifier at the requester side */
+ key = osmv_txn_uniq_key(tid);
+ }
+
+ /* We must run under a transaction framework */
+ ret = osmv_txn_lookup(h_bind, key, pp_txn);
+ if (IB_NOT_FOUND == ret) {
+ /* Generally, we start a new transaction */
+ ret = osmv_txn_init(h_bind, tid, key, pp_txn);
+ if (IB_SUCCESS != ret) {
+ goto get_send_txn_done;
+ }
+ } else {
+ CL_ASSERT(NULL != *pp_txn);
+ /* The transaction context exists.
+ * This is legal only if I am going to return an
+ * (RMPP?) reply to an RMPP request sent by the other part
+ * (double-sided RMPP transfer)
+ */
+ if (FALSE == is_rmpp
+ || FALSE == osmv_txn_is_rmpp_init_by_peer(*pp_txn)) {
+ osm_log(p_bo->p_vendor->p_log, OSM_LOG_ERROR,
+ "__osmv_get_send_txn: ERR 7413: "
+ "The transaction id=0x%llX is not unique. Send failed.\n",
+ tid);
+
+ ret = IB_INVALID_SETTING;
+ goto get_send_txn_done;
+ }
+
+ if (TRUE == resp_expected) {
+ osm_log(p_bo->p_vendor->p_log, OSM_LOG_ERROR,
+ "__osmv_get_send_txn: ERR 7414: "
+ "The transaction id=%llX can\'t expect a response. Send failed.\n",
+ tid);
+
+ ret = IB_INVALID_PARAMETER;
+ goto get_send_txn_done;
+ }
+ }
+
+ if (TRUE == is_rmpp) {
+ ret = osmv_txn_init_rmpp_sender(h_bind, *pp_txn, p_madw);
+ if (IB_SUCCESS != ret) {
+ osmv_txn_done(h_bind, tid, FALSE);
+ goto get_send_txn_done;
+ }
+ }
+
+ /* Save a reference to the MAD in the txn context
+ * We'll need to match it in two cases:
+ * (1) When the response is returned, if I am the requester
+ * (2) In RMPP retransmissions
+ */
+ osmv_txn_set_madw(*pp_txn, p_madw);
+
+get_send_txn_done:
+ OSM_LOG_EXIT(p_bo->p_vendor->p_log);
+
+ return ret;
+}
+
+void osm_vendor_set_debug(IN osm_vendor_t * const p_vend, IN int32_t level)
+{
+
+}
diff --git a/contrib/ofed/opensm/libvendor/osm_vendor_mlx_dispatcher.c b/contrib/ofed/opensm/libvendor/osm_vendor_mlx_dispatcher.c
new file mode 100644
index 0000000..ba6c4e8
--- /dev/null
+++ b/contrib/ofed/opensm/libvendor/osm_vendor_mlx_dispatcher.c
@@ -0,0 +1,710 @@
+/*
+ * Copyright (c) 2004-2008 Voltaire, Inc. All rights reserved.
+ * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved.
+ * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+#if HAVE_CONFIG_H
+# include <config.h>
+#endif /* HAVE_CONFIG_H */
+
+#include <string.h>
+#include <vendor/osm_vendor_mlx.h>
+#include <vendor/osm_vendor_mlx_defs.h>
+#include <vendor/osm_vendor_mlx_svc.h>
+#include <vendor/osm_vendor_mlx_transport.h>
+#include <vendor/osm_vendor_mlx_sender.h>
+#include <vendor/osm_pkt_randomizer.h>
+
+typedef enum _osmv_disp_route {
+
+ OSMV_ROUTE_DROP,
+ OSMV_ROUTE_SIMPLE,
+ OSMV_ROUTE_RMPP,
+
+} osmv_disp_route_t;
+
+/**
+ * FORWARD REFERENCES TO PRIVATE FUNCTIONS
+ */
+
+static osmv_disp_route_t
+__osmv_dispatch_route(IN osm_bind_handle_t h_bind,
+ IN const ib_mad_t * p_mad, OUT osmv_txn_ctx_t ** pp_txn);
+
+static void
+__osmv_dispatch_simple_mad(IN osm_bind_handle_t h_bind,
+ IN const ib_mad_t * p_mad,
+ IN osmv_txn_ctx_t * p_txn,
+ IN const osm_mad_addr_t * p_mad_addr);
+
+static void
+__osmv_dispatch_rmpp_mad(IN osm_bind_handle_t h_bind,
+ IN const ib_mad_t * p_mad,
+ IN osmv_txn_ctx_t * p_txn,
+ IN const osm_mad_addr_t * p_mad_addr);
+
+static void
+__osmv_dispatch_rmpp_snd(IN osm_bind_handle_t h_bind,
+ IN const ib_mad_t * p_mad,
+ IN osmv_txn_ctx_t * p_txn,
+ IN const osm_mad_addr_t * p_mad_addr);
+
+static ib_api_status_t
+__osmv_dispatch_rmpp_rcv(IN osm_bind_handle_t h_bind,
+ IN const ib_mad_t * p_mad,
+ IN osmv_txn_ctx_t * p_txn,
+ IN const osm_mad_addr_t * p_mad_addr);
+
+static ib_api_status_t
+__osmv_dispatch_accept_seg(IN osm_bind_handle_t h_bind,
+ IN osmv_txn_ctx_t * p_txn,
+ IN const ib_mad_t * p_mad);
+static void
+__osmv_dispatch_send_ack(IN osm_bind_handle_t h_bind,
+ IN const ib_mad_t * p_req_mad,
+ IN osmv_txn_ctx_t * p_txn,
+ IN const osm_mad_addr_t * p_mad_addr);
+
+/*
+ * NAME
+ * osmv_dispatch_mad
+ *
+ * DESCRIPTION
+ * Lower-level MAD dispatcher.
+ * Implements a switch between the following MAD consumers:
+ * (1) Non-RMPP consumer (DATA)
+ * (2) RMPP receiver (DATA/ABORT/STOP)
+ * (3) RMPP sender (ACK/ABORT/STOP)
+ *
+ * PARAMETERS
+ * h_bind The bind handle
+ * p_mad_buf The 256 byte buffer of individual MAD
+ * p_mad_addr The MAD originator's address
+ */
+
+ib_api_status_t
+osmv_dispatch_mad(IN osm_bind_handle_t h_bind,
+ IN const void *p_mad_buf,
+ IN const osm_mad_addr_t * p_mad_addr)
+{
+ ib_api_status_t ret = IB_SUCCESS;
+ const ib_mad_t *p_mad = (ib_mad_t *) p_mad_buf;
+ osmv_bind_obj_t *p_bo = (osmv_bind_obj_t *) h_bind;
+ osmv_txn_ctx_t *p_txn = NULL;
+ osm_log_t *p_log = p_bo->p_vendor->p_log;
+
+ OSM_LOG_ENTER(p_bo->p_vendor->p_log);
+
+ CL_ASSERT(NULL != h_bind && NULL != p_mad && NULL != p_mad_addr);
+
+ osmv_txn_lock(p_bo);
+
+ if (TRUE == p_bo->is_closing) {
+
+ osm_log(p_bo->p_vendor->p_log, OSM_LOG_DEBUG,
+ "The bind handle %p is being closed. "
+ "The MAD will not be dispatched.\n", p_bo);
+
+ ret = IB_INTERRUPTED;
+ goto dispatch_mad_done;
+ }
+
+ /*
+ Add call for packet drop randomizer.
+ This is a testing feature. If run_randomizer flag is set to TRUE,
+ the randomizer will be called, and randomally will drop
+ a packet. This is used for simulating unstable fabric.
+ */
+ if (p_bo->p_vendor->run_randomizer == TRUE) {
+ /* Try the randomizer */
+ if (osm_pkt_randomizer_mad_drop(p_bo->p_vendor->p_log,
+ p_bo->p_vendor->
+ p_pkt_randomizer,
+ p_mad) == TRUE) {
+ osm_log(p_bo->p_vendor->p_log, OSM_LOG_DEBUG,
+ "The MAD will not be dispatched.\n");
+ goto dispatch_mad_done;
+ }
+ }
+
+ switch (__osmv_dispatch_route(h_bind, p_mad, &p_txn)) {
+
+ case OSMV_ROUTE_DROP:
+ break; /* Do nothing */
+
+ case OSMV_ROUTE_SIMPLE:
+ __osmv_dispatch_simple_mad(h_bind, p_mad, p_txn, p_mad_addr);
+ break;
+
+ case OSMV_ROUTE_RMPP:
+ __osmv_dispatch_rmpp_mad(h_bind, p_mad, p_txn, p_mad_addr);
+ break;
+
+ default:
+ CL_ASSERT(FALSE);
+ }
+
+dispatch_mad_done:
+ osmv_txn_unlock(p_bo);
+
+ OSM_LOG_EXIT(p_log);
+ return ret;
+}
+
+/*
+ * NAME __osmv_dispatch_route()
+ *
+ * DESCRIPTION Decide which way to handle the received MAD: simple txn/RMPP/drop
+ */
+
+static osmv_disp_route_t
+__osmv_dispatch_route(IN osm_bind_handle_t h_bind,
+ IN const ib_mad_t * p_mad, OUT osmv_txn_ctx_t ** pp_txn)
+{
+ ib_api_status_t ret;
+ osmv_bind_obj_t *p_bo = (osmv_bind_obj_t *) h_bind;
+ boolean_t is_resp = ib_mad_is_response(p_mad);
+ boolean_t is_txn;
+ uint64_t key = cl_ntoh64(p_mad->trans_id);
+
+ CL_ASSERT(NULL != pp_txn);
+
+ ret = osmv_txn_lookup(h_bind, key, pp_txn);
+ is_txn = (IB_SUCCESS == ret);
+
+ if (FALSE == is_txn && TRUE == is_resp) {
+ osm_log(p_bo->p_vendor->p_log, OSM_LOG_DEBUG,
+ "Received a response to a non-started/aged-out transaction (tid=0x%" PRIx64 "). "
+ "Dropping the MAD.\n", key);
+ return OSMV_ROUTE_DROP;
+ }
+
+ if (TRUE == osmv_mad_is_rmpp(p_mad)) {
+ /* An RMPP transaction. The filtering is more delicate there */
+ return OSMV_ROUTE_RMPP;
+ }
+
+ if (TRUE == is_txn && FALSE == is_resp) {
+ /* Does this MAD try to start a transaction with duplicate tid? */
+ osm_log(p_bo->p_vendor->p_log, OSM_LOG_DEBUG,
+ "Duplicate TID 0x%" PRIx64 " received (not a response). "
+ "Dropping the MAD.\n", key);
+
+ return OSMV_ROUTE_DROP;
+ }
+
+ return OSMV_ROUTE_SIMPLE;
+}
+
+/*
+ * NAME __osmv_dispatch_simple_mad()
+ *
+ * DESCRIPTION Handle a MAD that is part of non-RMPP transfer
+ */
+
+static void
+__osmv_dispatch_simple_mad(IN osm_bind_handle_t h_bind,
+ IN const ib_mad_t * p_mad,
+ IN osmv_txn_ctx_t * p_txn,
+ IN const osm_mad_addr_t * p_mad_addr)
+{
+ osm_madw_t *p_madw;
+ ib_mad_t *p_mad_buf;
+ osm_madw_t *p_req_madw = NULL;
+ osmv_bind_obj_t *p_bo = (osmv_bind_obj_t *) h_bind;
+
+ OSM_LOG_ENTER(p_bo->p_vendor->p_log);
+
+ /* Build the MAD wrapper to be returned to the user.
+ * The actual storage for the MAD is allocated there.
+ */
+ p_madw =
+ osm_mad_pool_get(p_bo->p_osm_pool, h_bind, MAD_BLOCK_SIZE,
+ p_mad_addr);
+
+ if (NULL == p_madw) {
+ osm_log(p_bo->p_vendor->p_log, OSM_LOG_ERROR,
+ "__osmv_dispatch_simple_mad: ERR 6501: "
+ "Out Of Memory - could not allocate a buffer of size %d\n",
+ MAD_BLOCK_SIZE);
+
+ goto dispatch_simple_mad_done;
+ }
+
+ p_mad_buf = osm_madw_get_mad_ptr(p_madw);
+ /* Copy the payload to the MAD buffer */
+ memcpy((void *)p_mad_buf, (void *)p_mad, MAD_BLOCK_SIZE);
+
+ if (NULL != p_txn) {
+ /* This is a RESPONSE MAD. Pair it with the REQUEST MAD, pass upstream */
+ p_req_madw = p_txn->p_madw;
+ CL_ASSERT(NULL != p_req_madw);
+
+ p_mad_buf->trans_id = cl_hton64(osmv_txn_get_tid(p_txn));
+ osm_log(p_bo->p_vendor->p_log, OSM_LOG_DEBUG,
+ "Restoring the original TID to 0x%" PRIx64 "\n",
+ cl_ntoh64(p_mad_buf->trans_id));
+
+ /* Reply matched, transaction complete */
+ osmv_txn_done(h_bind, osmv_txn_get_key(p_txn), FALSE);
+ } else {
+ /* This is a REQUEST MAD. Don't create a context, pass upstream */
+ }
+
+ /* Do the job ! */
+ p_bo->recv_cb(p_madw, p_bo->cb_context, p_req_madw);
+
+dispatch_simple_mad_done:
+ OSM_LOG_EXIT(p_bo->p_vendor->p_log);
+}
+
+/*
+ * NAME __osmv_dispatch_rmpp_mad()
+ *
+ * DESCRIPTION Handle a MAD that is part of RMPP transfer
+ */
+
+static void
+__osmv_dispatch_rmpp_mad(IN osm_bind_handle_t h_bind,
+ IN const ib_mad_t * p_mad,
+ IN osmv_txn_ctx_t * p_txn,
+ IN const osm_mad_addr_t * p_mad_addr)
+{
+ ib_api_status_t status = IB_SUCCESS;
+ uint64_t key = cl_ntoh64(p_mad->trans_id);
+ boolean_t is_init_by_peer = FALSE;
+ osmv_bind_obj_t *p_bo = (osmv_bind_obj_t *) h_bind;
+ osm_madw_t *p_madw;
+
+ OSM_LOG_ENTER(p_bo->p_vendor->p_log);
+
+ if (NULL == p_txn) {
+ if (FALSE == osmv_rmpp_is_data(p_mad)
+ || FALSE == osmv_rmpp_is_first(p_mad)) {
+ osm_log(p_bo->p_vendor->p_log, OSM_LOG_DEBUG,
+ "The MAD does not match any transaction "
+ "and does not start a sender-initiated RMPP transfer.\n");
+ goto dispatch_rmpp_mad_done;
+ }
+
+ /* IB Spec 13.6.2.2. This is a Sender Initiated Transfer.
+ My peer is the requester and RMPP Sender. I am the RMPP Receiver.
+ */
+ status = osmv_txn_init(h_bind, /*tid==key */ key, key, &p_txn);
+ if (IB_SUCCESS != status) {
+ goto dispatch_rmpp_mad_done;
+ }
+
+ is_init_by_peer = TRUE;
+ osm_log(p_bo->p_vendor->p_log, OSM_LOG_DEBUG,
+ "A new sender-initiated transfer (TID=0x%" PRIx64 ") started\n",
+ key);
+ }
+
+ if (OSMV_TXN_RMPP_NONE == osmv_txn_get_rmpp_state(p_txn)) {
+ /* Case 1: Fall through from above.
+ * Case 2: When the transaction was initiated by me
+ * (a single request MAD), there was an uncertainty
+ * whether the reply will be RMPP. Now it's resolved,
+ * since the reply is RMPP!
+ */
+ status =
+ osmv_txn_init_rmpp_receiver(h_bind, p_txn, is_init_by_peer);
+ if (IB_SUCCESS != status) {
+ goto dispatch_rmpp_mad_done;
+ }
+ }
+
+ switch (osmv_txn_get_rmpp_state(p_txn)) {
+
+ case OSMV_TXN_RMPP_RECEIVER:
+ status =
+ __osmv_dispatch_rmpp_rcv(h_bind, p_mad, p_txn, p_mad_addr);
+ if (IB_SUCCESS != status) {
+ if (FALSE == osmv_txn_is_rmpp_init_by_peer(p_txn)) {
+ /* This is a requester, still waiting for the reply. Apply the callback */
+ /* update the status of the p_madw */
+ p_madw = osmv_txn_get_madw(p_txn);
+ p_madw->status = status;
+ p_bo->send_err_cb(p_bo->cb_context, p_madw);
+ }
+
+ /* ABORT/STOP/LOCAL ERROR */
+ osmv_txn_done(h_bind, osmv_txn_get_key(p_txn), FALSE);
+ }
+ break;
+
+ case OSMV_TXN_RMPP_SENDER:
+ __osmv_dispatch_rmpp_snd(h_bind, p_mad, p_txn, p_mad_addr);
+ /* If an error happens here, it's the sender thread to cleanup the txn */
+ break;
+
+ default:
+ CL_ASSERT(FALSE);
+ }
+
+dispatch_rmpp_mad_done:
+ OSM_LOG_EXIT(p_bo->p_vendor->p_log);
+}
+
+/*
+ * NAME __osmv_dispatch_rmpp_snd()
+ *
+ * DESCRIPTION MAD handling by an RMPP sender (ACK/ABORT/STOP)
+ */
+
+static void
+__osmv_dispatch_rmpp_snd(IN osm_bind_handle_t h_bind,
+ IN const ib_mad_t * p_mad,
+ IN osmv_txn_ctx_t * p_txn,
+ IN const osm_mad_addr_t * p_mad_addr)
+{
+ osmv_rmpp_send_ctx_t *p_send_ctx = osmv_txn_get_rmpp_send_ctx(p_txn);
+
+ uint32_t old_wl = p_send_ctx->window_last;
+ uint32_t total_segs = osmv_rmpp_send_ctx_get_num_segs(p_send_ctx);
+ uint32_t seg_num = cl_ntoh32(((ib_rmpp_mad_t *) p_mad)->seg_num);
+ uint32_t new_wl = cl_ntoh32(((ib_rmpp_mad_t *) p_mad)->paylen_newwin);
+ osmv_bind_obj_t *p_bo = (osmv_bind_obj_t *) h_bind;
+
+ OSM_LOG_ENTER(p_bo->p_vendor->p_log);
+
+ if (TRUE == osmv_rmpp_is_abort_stop(p_mad)) {
+
+ osm_log(p_bo->p_vendor->p_log, OSM_LOG_ERROR,
+ "__osmv_dispatch_rmpp_snd: ERR 6502: "
+ "The remote side sent an ABORT/STOP indication.\n");
+ osmv_rmpp_snd_error(p_send_ctx, IB_REMOTE_ERROR);
+ goto dispatch_rmpp_snd_done;
+ }
+
+ if (FALSE == osmv_rmpp_is_ack(p_mad)) {
+
+ osm_log(p_bo->p_vendor->p_log, OSM_LOG_DEBUG,
+ "Not supposed to receive DATA packets --> dropping the MAD\n");
+ goto dispatch_rmpp_snd_done;
+ }
+
+ /* Continue processing the ACK */
+ if (seg_num > old_wl) {
+
+ osm_log(p_bo->p_vendor->p_log, OSM_LOG_ERROR,
+ "__osmv_dispatch_rmpp_snd: ERR 6503: "
+ "ACK received for a non-sent segment %d\n", seg_num);
+
+ osmv_rmpp_send_nak(h_bind, p_mad, p_mad_addr,
+ IB_RMPP_TYPE_ABORT, IB_RMPP_STATUS_S2B);
+
+ osmv_rmpp_snd_error(p_send_ctx, IB_REMOTE_ERROR);
+ goto dispatch_rmpp_snd_done;
+ }
+
+ osm_log(p_bo->p_vendor->p_log, OSM_LOG_DEBUG,
+ "__osmv_dispatch_rmpp_snd: "
+ "New WL = %u Old WL = %u Total Segs = %u\n",
+ new_wl, old_wl, total_segs);
+
+ if (new_wl < old_wl) {
+ osm_log(p_bo->p_vendor->p_log, OSM_LOG_ERROR,
+ "__osmv_dispatch_rmpp_snd: ERR 6508: "
+ "The receiver requests a smaller WL (%d) than before (%d)\n",
+ new_wl, old_wl);
+
+ osmv_rmpp_send_nak(h_bind, p_mad, p_mad_addr,
+ IB_RMPP_TYPE_ABORT, IB_RMPP_STATUS_W2S);
+
+ osmv_rmpp_snd_error(p_send_ctx, IB_REMOTE_ERROR);
+ goto dispatch_rmpp_snd_done;
+ }
+
+ /* Update the sender's window, and optionally wake up the sender thread
+ * Note! A single ACK can acknowledge a whole range of segments: [WF..SEG_NUM]
+ */
+ osm_log(p_bo->p_vendor->p_log, OSM_LOG_DEBUG,
+ "ACK for seg_num #%d accepted.\n", seg_num);
+
+ if (seg_num == old_wl) {
+
+ osm_log(p_bo->p_vendor->p_log, OSM_LOG_DEBUG,
+ "The send window [%d:%d] is totally acknowledged.\n",
+ p_send_ctx->window_first, old_wl);
+
+ p_send_ctx->window_first = seg_num + 1;
+ p_send_ctx->window_last =
+ (new_wl < total_segs) ? new_wl : total_segs;
+
+ /* Remove the response timeout event for the window */
+ osmv_txn_remove_timeout_ev(h_bind, osmv_txn_get_key(p_txn));
+
+ /* Wake up the sending thread */
+ cl_event_signal(&p_send_ctx->event);
+ }
+
+dispatch_rmpp_snd_done:
+ OSM_LOG_EXIT(p_bo->p_vendor->p_log);
+}
+
+/*
+ * NAME __osmv_dispatch_rmpp_rcv()
+ *
+ * DESCRIPTION MAD handling by an RMPP receiver (DATA/ABORT/STOP)
+ */
+
+static ib_api_status_t
+__osmv_dispatch_rmpp_rcv(IN osm_bind_handle_t h_bind,
+ IN const ib_mad_t * p_mad,
+ IN osmv_txn_ctx_t * p_txn,
+ IN const osm_mad_addr_t * p_mad_addr)
+{
+ ib_api_status_t status = IB_SUCCESS;
+ osmv_rmpp_recv_ctx_t *p_recv_ctx = osmv_txn_get_rmpp_recv_ctx(p_txn);
+ osmv_bind_obj_t *p_bo = (osmv_bind_obj_t *) h_bind;
+ boolean_t is_last1 = FALSE, is_last2 = FALSE;
+ osm_madw_t *p_new_madw = NULL, *p_req_madw = NULL;
+ ib_mad_t *p_mad_buf;
+ uint32_t size = 0;
+ uint64_t key = osmv_txn_get_key(p_txn);
+ uint64_t tid = osmv_txn_get_tid(p_txn);
+
+ OSM_LOG_ENTER(p_bo->p_vendor->p_log);
+
+ if (TRUE == osmv_rmpp_is_ack(p_mad)) {
+ osm_log(p_bo->p_vendor->p_log, OSM_LOG_DEBUG,
+ "Not supposed to receive ACK's --> dropping the MAD\n");
+
+ goto dispatch_rmpp_rcv_done;
+ }
+
+ if (TRUE == osmv_rmpp_is_abort_stop(p_mad)) {
+ osm_log(p_bo->p_vendor->p_log, OSM_LOG_DEBUG,
+ "__osmv_dispatch_rmpp_rcv: ERR 6504: "
+ "The Remote Side stopped sending\n");
+
+ status = IB_REMOTE_ERROR;
+ goto dispatch_rmpp_rcv_done;
+ }
+
+ status = __osmv_dispatch_accept_seg(h_bind, p_txn, p_mad);
+ switch (status) {
+
+ case IB_SUCCESS:
+
+ /* Check wheter this is the legal last MAD */
+ /* Criteria #1: the received MAD is marked last */
+ is_last1 = osmv_rmpp_is_last(p_mad);
+
+ /* Criteria #2: the total accumulated length hits the advertised one */
+ is_last2 = is_last1;
+
+ size = osmv_rmpp_recv_ctx_get_byte_num_from_first(p_recv_ctx);
+ if (size > 0) {
+ is_last2 =
+ (osmv_rmpp_recv_ctx_get_cur_byte_num(p_recv_ctx) >=
+ size);
+ }
+
+ if (is_last1 != is_last2) {
+
+ osmv_rmpp_send_nak(h_bind, p_mad, p_mad_addr,
+ IB_RMPP_TYPE_ABORT,
+ IB_RMPP_STATUS_BAD_LEN);
+
+ status = IB_ERROR;
+ goto dispatch_rmpp_rcv_done;
+ }
+
+ /* TBD Consider an optimization - sending an ACK
+ * only for the last segment in the window
+ */
+ __osmv_dispatch_send_ack(h_bind, p_mad, p_txn, p_mad_addr);
+ break;
+
+ case IB_INSUFFICIENT_RESOURCES:
+ /* An out-of-order segment received. Send the ACK anyway */
+ __osmv_dispatch_send_ack(h_bind, p_mad, p_txn, p_mad_addr);
+ status = IB_SUCCESS;
+ goto dispatch_rmpp_rcv_done;
+
+ case IB_INSUFFICIENT_MEMORY:
+ osmv_rmpp_send_nak(h_bind, p_mad, p_mad_addr,
+ IB_RMPP_TYPE_STOP, IB_RMPP_STATUS_RESX);
+ goto dispatch_rmpp_rcv_done;
+
+ default:
+ /* Illegal return code */
+ CL_ASSERT(FALSE);
+ }
+
+ if (TRUE != is_last1) {
+ osm_log(p_bo->p_vendor->p_log, OSM_LOG_DEBUG,
+ "RMPP MADW assembly continues, TID=0x%" PRIx64 "\n", tid);
+ goto dispatch_rmpp_rcv_done;
+ }
+
+ /* This is the last packet. */
+ if (0 == size) {
+ /* The total size was not advertised in the first packet */
+ size = osmv_rmpp_recv_ctx_get_byte_num_from_last(p_recv_ctx);
+ }
+
+ /*
+ NOTE: the received mad might not be >= 256 bytes.
+ some MADs might contain several SA records but still be
+ less then a full MAD.
+ We have to use RMPP to send them over since on a regular
+ "simple" MAD there is no way to know how many records were sent
+ */
+
+ /* Build the MAD wrapper to be returned to the user.
+ * The actual storage for the MAD is allocated there.
+ */
+ p_new_madw =
+ osm_mad_pool_get(p_bo->p_osm_pool, h_bind, size, p_mad_addr);
+ if (NULL == p_new_madw) {
+ osm_log(p_bo->p_vendor->p_log, OSM_LOG_ERROR,
+ "__osmv_dispatch_rmpp_rcv: ERR 6506: "
+ "Out Of Memory - could not allocate %d bytes for the MADW\n",
+ size);
+
+ status = IB_INSUFFICIENT_MEMORY;
+ goto dispatch_rmpp_rcv_done;
+ }
+
+ p_req_madw = osmv_txn_get_madw(p_txn);
+ p_mad_buf = osm_madw_get_mad_ptr(p_new_madw);
+ status = osmv_rmpp_recv_ctx_reassemble_arbt_mad(p_recv_ctx, size,
+ (uint8_t *) p_mad_buf);
+ if (IB_SUCCESS != status) {
+ osm_log(p_bo->p_vendor->p_log, OSM_LOG_ERROR,
+ "__osmv_dispatch_rmpp_rcv: ERR 6507: "
+ "Internal error - could not reassemble the result MAD\n");
+ goto dispatch_rmpp_rcv_done; /* What can happen here? */
+ }
+
+ /* The MAD is assembled, we are about to apply the callback.
+ * Delete the transaction context, unless the transaction is double sided */
+ if (FALSE == osmv_txn_is_rmpp_init_by_peer(p_txn)
+ || FALSE == osmv_mad_is_multi_resp(p_mad)) {
+
+ osmv_txn_done(h_bind, key, FALSE);
+ }
+
+ osm_log(p_bo->p_vendor->p_log, OSM_LOG_DEBUG,
+ "RMPP MADW %p assembly complete, TID=0x%" PRIx64 "\n", p_new_madw,
+ tid);
+
+ p_mad_buf->trans_id = cl_hton64(tid);
+ osm_log(p_bo->p_vendor->p_log, OSM_LOG_DEBUG,
+ "Restoring the original TID to 0x%" PRIx64 "\n",
+ cl_ntoh64(p_mad_buf->trans_id));
+
+ /* Finally, do the job! */
+ p_bo->recv_cb(p_new_madw, p_bo->cb_context, p_req_madw);
+
+dispatch_rmpp_rcv_done:
+ OSM_LOG_EXIT(p_bo->p_vendor->p_log);
+ return status;
+}
+
+/*
+ * NAME __osmv_dispatch_accept_seg()
+ *
+ * DESCRIPTION Store a DATA segment at the RMPP receiver side,
+ * if one is received in order.
+ */
+
+static ib_api_status_t
+__osmv_dispatch_accept_seg(IN osm_bind_handle_t h_bind,
+ IN osmv_txn_ctx_t * p_txn, IN const ib_mad_t * p_mad)
+{
+ ib_api_status_t ret = IB_SUCCESS;
+ uint32_t seg_num = cl_ntoh32(((ib_rmpp_mad_t *) p_mad)->seg_num);
+ osmv_rmpp_recv_ctx_t *p_recv_ctx = osmv_txn_get_rmpp_recv_ctx(p_txn);
+ osmv_bind_obj_t *p_bo = (osmv_bind_obj_t *) h_bind;
+ uint64_t tid = osmv_txn_get_tid(p_txn);
+
+ OSM_LOG_ENTER(p_bo->p_vendor->p_log);
+
+ if (seg_num != p_recv_ctx->expected_seg) {
+ osm_log(p_bo->p_vendor->p_log, OSM_LOG_DEBUG,
+ "TID 0x%" PRIx64 ": can't accept this segment (%d) - "
+ "this is a Go-Back-N implementation\n", tid, seg_num);
+ return IB_INSUFFICIENT_RESOURCES;
+ }
+
+ /* Store the packet's copy in the reassembly list.
+ * Promote the expected segment counter.
+ */
+ ret = osmv_rmpp_recv_ctx_store_mad_seg(p_recv_ctx, (uint8_t *) p_mad);
+ if (IB_SUCCESS != ret) {
+ return ret;
+ }
+
+ osm_log(p_bo->p_vendor->p_log, OSM_LOG_DEBUG,
+ "TID 0x%" PRIx64 ": segment %d accepted\n", tid, seg_num);
+ p_recv_ctx->expected_seg = seg_num + 1;
+
+ OSM_LOG_EXIT(p_bo->p_vendor->p_log);
+ return IB_SUCCESS;
+}
+
+/*
+ * NAME __osmv_dispatch_send_ack()
+ *
+ * DESCRIPTION
+ *
+ * ISSUES
+ * Consider sending the ACK from an async thread
+ * if problems with the receiving side processing arise.
+ */
+
+static void
+__osmv_dispatch_send_ack(IN osm_bind_handle_t h_bind,
+ IN const ib_mad_t * p_req_mad,
+ IN osmv_txn_ctx_t * p_txn,
+ IN const osm_mad_addr_t * p_mad_addr)
+{
+ osmv_rmpp_recv_ctx_t *p_recv_ctx = osmv_txn_get_rmpp_recv_ctx(p_txn);
+
+ /* ACK the segment # that was accepted */
+ uint32_t seg_num = cl_ntoh32(((ib_rmpp_mad_t *) p_req_mad)->seg_num);
+
+ /* NOTE! The receiver can publish the New Window Last (NWL) value
+ * that is greater than the total number of segments to be sent.
+ * It's the sender's responsibility to compute the correct number
+ * of segments to send in the next burst.
+ */
+ uint32_t nwl = p_recv_ctx->expected_seg + OSMV_RMPP_RECV_WIN - 1;
+
+ osmv_rmpp_send_ack(h_bind, p_req_mad, seg_num, nwl, p_mad_addr);
+}
diff --git a/contrib/ofed/opensm/libvendor/osm_vendor_mlx_hca.c b/contrib/ofed/opensm/libvendor/osm_vendor_mlx_hca.c
new file mode 100644
index 0000000..910e81b
--- /dev/null
+++ b/contrib/ofed/opensm/libvendor/osm_vendor_mlx_hca.c
@@ -0,0 +1,522 @@
+/*
+ * Copyright (c) 2004-2008 Voltaire, Inc. All rights reserved.
+ * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved.
+ * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+#if HAVE_CONFIG_H
+# include <config.h>
+#endif /* HAVE_CONFIG_H */
+
+#include <stdlib.h>
+#include <string.h>
+#if defined(OSM_VENDOR_INTF_MTL) | defined(OSM_VENDOR_INTF_TS)
+#undef IN
+#undef OUT
+#include <vapi_types.h>
+#include <evapi.h>
+#include <vendor/osm_vendor_api.h>
+#include <opensm/osm_log.h>
+#include <stdlib.h>
+#include <stdio.h>
+
+/********************************************************************************
+ *
+ * Provide the functionality for selecting an HCA Port and Obtaining it's guid.
+ *
+ ********************************************************************************/
+
+typedef struct _osm_ca_info {
+ ib_net64_t guid;
+ size_t attr_size;
+ ib_ca_attr_t *p_attr;
+} osm_ca_info_t;
+
+/**********************************************************************
+ * Convert the given GID to GUID by copy of it's upper 8 bytes
+ **********************************************************************/
+ib_api_status_t
+__osm_vendor_gid_to_guid(IN u_int8_t * gid, OUT VAPI_gid_t * guid)
+{
+ memcpy(guid, gid + 8, 8);
+ return (IB_SUCCESS);
+}
+
+/**********************************************************************
+ * Returns a pointer to the port attribute of the specified port
+ * owned by this CA.
+ ************************************************************************/
+static ib_port_attr_t *__osm_ca_info_get_port_attr_ptr(IN const osm_ca_info_t *
+ const p_ca_info,
+ IN const uint8_t index)
+{
+ return (&p_ca_info->p_attr->p_port_attr[index]);
+}
+
+/********************************************************************************
+ * get the CA names available on the system
+ * NOTE: user of this function needs to deallocate p_hca_ids after usage.
+ ********************************************************************************/
+static ib_api_status_t
+__osm_vendor_get_ca_ids(IN osm_vendor_t * const p_vend,
+ IN VAPI_hca_id_t ** const p_hca_ids,
+ IN uint32_t * const p_num_guids)
+{
+ ib_api_status_t status;
+ VAPI_ret_t vapi_res;
+
+ OSM_LOG_ENTER(p_vend->p_log);
+
+ CL_ASSERT(p_hca_ids);
+ CL_ASSERT(p_num_guids);
+
+ /* first call is just to get the number */
+ vapi_res = EVAPI_list_hcas(0, p_num_guids, NULL);
+
+ /* fail ? */
+ if (vapi_res == VAPI_EINVAL_PARAM) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "__osm_vendor_get_ca_ids: ERR 3D08: : "
+ "Bad parameter in calling: EVAPI_list_hcas. (%d)\n",
+ vapi_res);
+ status = IB_ERROR;
+ goto Exit;
+ }
+
+ /* NO HCA ? */
+ if (*p_num_guids == 0) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "__osm_vendor_get_ca_ids: ERR 3D09: "
+ "No available channel adapters.\n");
+ status = IB_INSUFFICIENT_RESOURCES;
+ goto Exit;
+ }
+
+ /* allocate and really call - user of this function needs to deallocate it */
+ *p_hca_ids =
+ (VAPI_hca_id_t *) malloc(*p_num_guids * sizeof(VAPI_hca_id_t));
+
+ /* now call it really */
+ vapi_res = EVAPI_list_hcas(*p_num_guids, p_num_guids, *p_hca_ids);
+
+ /* too many ? */
+ if (vapi_res == VAPI_EAGAIN) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "__osm_vendor_get_ca_ids: ERR 3D10: "
+ "More CA GUIDs than allocated array (%d).\n",
+ *p_num_guids);
+ status = IB_ERROR;
+ goto Exit;
+ }
+
+ /* fail ? */
+ if (vapi_res != VAPI_OK) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "__osm_vendor_get_ca_ids: ERR 3D11: : "
+ "Bad parameter in calling: EVAPI_list_hcas.\n");
+ status = IB_ERROR;
+ goto Exit;
+ }
+
+ if (osm_log_is_active(p_vend->p_log, OSM_LOG_DEBUG)) {
+ osm_log(p_vend->p_log, OSM_LOG_DEBUG,
+ "__osm_vendor_get_ca_ids: "
+ "Detected %u local channel adapters.\n", *p_num_guids);
+ }
+
+ status = IB_SUCCESS;
+
+Exit:
+ OSM_LOG_EXIT(p_vend->p_log);
+ return (status);
+}
+
+/**********************************************************************
+ * Initialize an Info Struct for the Given HCA by its Id
+ **********************************************************************/
+static ib_api_status_t
+__osm_ca_info_init(IN osm_vendor_t * const p_vend,
+ IN VAPI_hca_id_t ca_id, OUT osm_ca_info_t * const p_ca_info)
+{
+ ib_api_status_t status = IB_ERROR;
+ VAPI_ret_t vapi_res;
+ VAPI_hca_hndl_t hca_hndl;
+ VAPI_hca_vendor_t hca_vendor;
+ VAPI_hca_cap_t hca_cap;
+ VAPI_hca_port_t hca_port;
+ uint8_t port_num;
+ IB_gid_t *p_port_gid;
+ uint16_t maxNumGids;
+
+ OSM_LOG_ENTER(p_vend->p_log);
+
+ /* get the HCA handle */
+ vapi_res = EVAPI_get_hca_hndl(ca_id, &hca_hndl);
+ if (vapi_res != VAPI_OK) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "__osm_ca_info_init: ERR 3D05: "
+ "Fail to get HCA handle (%u).\n", vapi_res);
+ goto Exit;
+ }
+
+ if (osm_log_is_active(p_vend->p_log, OSM_LOG_DEBUG)) {
+ osm_log(p_vend->p_log, OSM_LOG_DEBUG,
+ "__osm_ca_info_init: " "Querying CA %s.\n", ca_id);
+ }
+
+ /* query and get the HCA capability */
+ vapi_res = VAPI_query_hca_cap(hca_hndl, &hca_vendor, &hca_cap);
+ if (vapi_res != VAPI_OK) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "__osm_ca_info_init: ERR 3D06: "
+ "Fail to get HCA Capabilities (%u).\n", vapi_res);
+ goto Exit;
+ }
+
+ /* get the guid of the HCA */
+ memcpy(&(p_ca_info->guid), hca_cap.node_guid, 8 * sizeof(u_int8_t));
+ p_ca_info->attr_size = 1;
+ p_ca_info->p_attr = (ib_ca_attr_t *) malloc(sizeof(ib_ca_attr_t));
+ memcpy(&(p_ca_info->p_attr->ca_guid), hca_cap.node_guid,
+ 8 * sizeof(u_int8_t));
+
+ /* now obtain the attributes of the ports */
+ p_ca_info->p_attr->num_ports = hca_cap.phys_port_num;
+ p_ca_info->p_attr->p_port_attr =
+ (ib_port_attr_t *) malloc(hca_cap.phys_port_num *
+ sizeof(ib_port_attr_t));
+
+ for (port_num = 0; port_num < p_ca_info->p_attr->num_ports; port_num++) {
+
+ /* query the port attributes */
+ vapi_res =
+ VAPI_query_hca_port_prop(hca_hndl, port_num + 1, &hca_port);
+ if (vapi_res != VAPI_OK) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "__osm_ca_info_init: ERR 3D07: "
+ "Fail to get HCA Port Attributes (%d).\n",
+ vapi_res);
+ goto Exit;
+ }
+
+ /* first call to know the size of the gid table */
+ vapi_res =
+ VAPI_query_hca_gid_tbl(hca_hndl, port_num + 1, 0,
+ &maxNumGids, NULL);
+ p_port_gid = (IB_gid_t *) malloc(maxNumGids * sizeof(IB_gid_t));
+
+ vapi_res =
+ VAPI_query_hca_gid_tbl(hca_hndl, port_num + 1, maxNumGids,
+ &maxNumGids, p_port_gid);
+ if (vapi_res != VAPI_OK) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "__osm_ca_info_init: ERR 3D12: "
+ "Fail to get HCA Port GID (%d).\n", vapi_res);
+ goto Exit;
+ }
+
+ __osm_vendor_gid_to_guid(p_port_gid[0],
+ (IB_gid_t *) & p_ca_info->p_attr->
+ p_port_attr[port_num].port_guid);
+ p_ca_info->p_attr->p_port_attr[port_num].lid = hca_port.lid;
+ p_ca_info->p_attr->p_port_attr[port_num].link_state =
+ hca_port.state;
+ p_ca_info->p_attr->p_port_attr[port_num].sm_lid =
+ hca_port.sm_lid;
+
+ free(p_port_gid);
+ }
+
+ status = IB_SUCCESS;
+Exit:
+ OSM_LOG_EXIT(p_vend->p_log);
+ return (status);
+}
+
+void
+osm_ca_info_destroy(IN osm_vendor_t * const p_vend,
+ IN osm_ca_info_t * const p_ca_info, IN uint8_t num_ca)
+{
+ osm_ca_info_t *p_ca;
+ uint8_t i;
+
+ OSM_LOG_ENTER(p_vend->p_log);
+
+ for (i = 0; i < num_ca; i++) {
+ p_ca = &p_ca_info[i];
+
+ if (NULL != p_ca->p_attr) {
+ if (0 != p_ca->p_attr->num_ports) {
+ free(p_ca->p_attr->p_port_attr);
+ }
+
+ free(p_ca->p_attr);
+ }
+ }
+
+ free(p_ca_info);
+
+ OSM_LOG_EXIT(p_vend->p_log);
+}
+
+/**********************************************************************
+ * Fill in the array of port_attr with all available ports on ALL the
+ * avilable CAs on this machine.
+ * ALSO -
+ * Update the vendor object list of ca_info structs
+ **********************************************************************/
+ib_api_status_t
+osm_vendor_get_all_port_attr(IN osm_vendor_t * const p_vend,
+ IN ib_port_attr_t * const p_attr_array,
+ IN uint32_t * const p_num_ports)
+{
+ ib_api_status_t status;
+
+ uint32_t ca;
+ uint32_t ca_count = 0;
+ uint32_t port_count = 0;
+ uint8_t port_num;
+ uint32_t total_ports = 0;
+ VAPI_hca_id_t *p_ca_ids = NULL;
+ osm_ca_info_t *p_ca_infos = NULL;
+ uint32_t attr_array_sz = *p_num_ports;
+
+ OSM_LOG_ENTER(p_vend->p_log);
+
+ CL_ASSERT(p_vend);
+
+ /* determine the number of CA's */
+ status = __osm_vendor_get_ca_ids(p_vend, &p_ca_ids, &ca_count);
+ if (status != IB_SUCCESS) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "osm_vendor_get_all_port_attr: ERR 3D13: "
+ "Fail to get CA Ids.\n");
+ goto Exit;
+ }
+
+ /* Allocate an array big enough to hold the ca info objects */
+ p_ca_infos = malloc(ca_count * sizeof(osm_ca_info_t));
+ if (p_ca_infos == NULL) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "osm_vendor_get_all_port_attr: ERR 3D14: "
+ "Unable to allocate CA information array.\n");
+ goto Exit;
+ }
+
+ memset(p_ca_infos, 0, ca_count * sizeof(osm_ca_info_t));
+
+ /*
+ * For each CA, retrieve the CA info attributes
+ */
+ for (ca = 0; ca < ca_count; ca++) {
+ status =
+ __osm_ca_info_init(p_vend, p_ca_ids[ca], &p_ca_infos[ca]);
+ if (status != IB_SUCCESS) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "osm_vendor_get_all_port_attr: ERR 3D15: "
+ "Unable to initialize CA Info object (%s).\n",
+ ib_get_err_str(status));
+ goto Exit;
+ }
+ total_ports += p_ca_infos[ca].p_attr->num_ports;
+ }
+
+ *p_num_ports = total_ports;
+ osm_log(p_vend->p_log, OSM_LOG_DEBUG,
+ "osm_vendor_get_all_port_attr: total ports:%u \n", total_ports);
+
+ /*
+ * If the user supplied enough storage, return the port guids,
+ * otherwise, return the appropriate error.
+ */
+ if (attr_array_sz >= total_ports) {
+ for (ca = 0; ca < ca_count; ca++) {
+ uint32_t num_ports;
+
+ num_ports = p_ca_infos[ca].p_attr->num_ports;
+
+ for (port_num = 0; port_num < num_ports; port_num++) {
+ p_attr_array[port_count] =
+ *__osm_ca_info_get_port_attr_ptr(&p_ca_infos
+ [ca],
+ port_num);
+ port_count++;
+ }
+ }
+ } else {
+ status = IB_INSUFFICIENT_MEMORY;
+ goto Exit;
+ }
+
+ status = IB_SUCCESS;
+
+Exit:
+ if (p_ca_ids)
+ free(p_ca_ids);
+
+ if (p_ca_infos) {
+ osm_ca_info_destroy(p_vend, p_ca_infos, ca_count);
+ }
+
+ OSM_LOG_EXIT(p_vend->p_log);
+ return (status);
+}
+
+/**********************************************************************
+ * Given the vendor obj and a guid
+ * return the ca id and port number that have that guid
+ **********************************************************************/
+
+ib_api_status_t
+osm_vendor_get_guid_ca_and_port(IN osm_vendor_t * const p_vend,
+ IN ib_net64_t const guid,
+ OUT VAPI_hca_hndl_t * p_hca_hndl,
+ OUT VAPI_hca_id_t * p_hca_id,
+ OUT uint8_t * p_hca_idx,
+ OUT uint32_t * p_port_num)
+{
+
+ ib_api_status_t status;
+ VAPI_hca_id_t *p_ca_ids = NULL;
+ VAPI_ret_t vapi_res;
+ VAPI_hca_hndl_t hca_hndl;
+ VAPI_hca_vendor_t hca_vendor;
+ VAPI_hca_cap_t hca_cap;
+ IB_gid_t *p_port_gid = NULL;
+ uint16_t maxNumGids;
+ ib_net64_t port_guid;
+ uint32_t ca, portIdx, ca_count;
+
+ OSM_LOG_ENTER(p_vend->p_log);
+
+ CL_ASSERT(p_vend);
+
+ /*
+ * 1) Determine the number of CA's
+ * 2) Allocate an array big enough to hold the ca info objects.
+ * 3) Call again to retrieve the guids.
+ */
+ status = __osm_vendor_get_ca_ids(p_vend, &p_ca_ids, &ca_count);
+ if (status != IB_SUCCESS) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "osm_vendor_get_guid_ca_and_port: ERR 3D16: "
+ "Fail to get CA Ids.\n");
+ goto Exit;
+ }
+
+ /*
+ * For each CA, retrieve the CA info attributes
+ */
+ for (ca = 0; ca < ca_count; ca++) {
+ /* get the HCA handle */
+ vapi_res = EVAPI_get_hca_hndl(p_ca_ids[ca], &hca_hndl);
+ if (vapi_res != VAPI_OK) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "osm_vendor_get_guid_ca_and_port: ERR 3D17: "
+ "Fail to get HCA handle (%u).\n", vapi_res);
+ goto Exit;
+ }
+
+ /* get the CA attributes - to know how many ports it has: */
+ if (osm_log_is_active(p_vend->p_log, OSM_LOG_DEBUG)) {
+ osm_log(p_vend->p_log, OSM_LOG_DEBUG,
+ "osm_vendor_get_guid_ca_and_port: "
+ "Querying CA %s.\n", p_ca_ids[ca]);
+ }
+
+ /* query and get the HCA capability */
+ vapi_res = VAPI_query_hca_cap(hca_hndl, &hca_vendor, &hca_cap);
+ if (vapi_res != VAPI_OK) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "osm_vendor_get_guid_ca_and_port: ERR 3D18: "
+ "Fail to get HCA Capabilities (%u).\n",
+ vapi_res);
+ goto Exit;
+ }
+
+ /* go over all ports - to obtail their guids */
+ for (portIdx = 0; portIdx < hca_cap.phys_port_num; portIdx++) {
+ vapi_res =
+ VAPI_query_hca_gid_tbl(hca_hndl, portIdx + 1, 0,
+ &maxNumGids, NULL);
+ p_port_gid =
+ (IB_gid_t *) malloc(maxNumGids * sizeof(IB_gid_t));
+
+ /* get the port guid */
+ vapi_res =
+ VAPI_query_hca_gid_tbl(hca_hndl, portIdx + 1,
+ maxNumGids, &maxNumGids,
+ p_port_gid);
+ if (vapi_res != VAPI_OK) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "osm_vendor_get_guid_ca_and_port: ERR 3D19: "
+ "Fail to get HCA Port GID (%d).\n",
+ vapi_res);
+ goto Exit;
+ }
+
+ /* convert to SF style */
+ __osm_vendor_gid_to_guid(p_port_gid[0],
+ (VAPI_gid_t *) & port_guid);
+
+ /* finally did we find it ? */
+ if (port_guid == guid) {
+ *p_hca_hndl = hca_hndl;
+ memcpy(p_hca_id, p_ca_ids[ca],
+ sizeof(VAPI_hca_id_t));
+ *p_hca_idx = ca;
+ *p_port_num = portIdx + 1;
+ status = IB_SUCCESS;
+ goto Exit;
+ }
+
+ free(p_port_gid);
+ p_port_gid = NULL;
+ } /* ALL PORTS */
+ } /* all HCAs */
+
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "osm_vendor_get_guid_ca_and_port: ERR 3D20: "
+ "Fail to find HCA and Port for Port Guid 0x%" PRIx64 "\n",
+ cl_ntoh64(guid));
+ status = IB_INVALID_GUID;
+
+Exit:
+ if (p_ca_ids != NULL)
+ free(p_ca_ids);
+ if (p_port_gid != NULL)
+ free(p_port_gid);
+ OSM_LOG_EXIT(p_vend->p_log);
+ return (status);
+}
+
+#endif
diff --git a/contrib/ofed/opensm/libvendor/osm_vendor_mlx_hca_anafa.c b/contrib/ofed/opensm/libvendor/osm_vendor_mlx_hca_anafa.c
new file mode 100644
index 0000000..a12ed2b
--- /dev/null
+++ b/contrib/ofed/opensm/libvendor/osm_vendor_mlx_hca_anafa.c
@@ -0,0 +1,192 @@
+/*
+ * Copyright (c) 2004-2008 Voltaire, Inc. All rights reserved.
+ * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved.
+ * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+#if HAVE_CONFIG_H
+# include <config.h>
+#endif /* HAVE_CONFIG_H */
+
+#if defined(OSM_VENDOR_INTF_ANAFA)
+#undef IN
+#undef OUT
+
+#include <stdlib.h>
+#include <stddef.h>
+#include <string.h>
+
+#include <vendor/osm_vendor_api.h>
+#include <opensm/osm_log.h>
+#include <sys/ioctl.h>
+
+#include <vendor/osm_vendor_mlx_transport_anafa.h>
+#include <vendor/osm_ts_useraccess.h>
+
+/********************************************************************************
+ *
+ * Provide the functionality for selecting an HCA Port and Obtaining it's guid.
+ *
+ ********************************************************************************/
+
+typedef struct _osm_ca_info {
+ /* ib_net64_t guid; ?? */
+ /* size_t attr_size; ?? */
+ ib_ca_attr_t attr;
+} osm_ca_info_t;
+
+/**********************************************************************
+ * Convert the given GID to GUID by copy of it's upper 8 bytes
+ **********************************************************************/
+ib_api_status_t
+__osm_vendor_gid_to_guid(IN tTS_IB_GID gid, OUT ib_net64_t * p_guid)
+{
+ memcpy(p_guid, gid + 8, 8);
+ return (IB_SUCCESS);
+}
+
+/**********************************************************************
+ * Initialize an Info Struct for the Given HCA by its Id
+ **********************************************************************/
+static ib_api_status_t
+__osm_ca_info_init(IN osm_vendor_t * const p_vend,
+ OUT osm_ca_info_t * const p_ca_info)
+{
+ ib_api_status_t status = IB_ERROR;
+ int ioctl_ret = 0;
+ osmv_TOPSPIN_ANAFA_transport_info_t *p_tpot_info =
+ p_vend->p_transport_info;
+ osm_ts_gid_entry_ioctl gid_ioctl;
+ osm_ts_get_port_info_ioctl port_info;
+ struct ib_get_dev_info_ioctl dev_info;
+
+ OSM_LOG_ENTER(p_vend->p_log);
+
+ /* query HCA guid */
+ ioctl_ret = ioctl(p_tpot_info->device_fd, TS_IB_IOCGDEVINFO, &dev_info);
+ if (ioctl_ret != 0) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "__osm_ca_info_init: ERR 7001: "
+ "Fail to get HCA Capabilities (%d).\n", ioctl_ret);
+ goto Exit;
+ }
+
+ memcpy(&(p_ca_info->attr.ca_guid), dev_info.dev_info.node_guid,
+ 8 * sizeof(uint8_t));
+
+/* now obtain the attributes of the ports - on our case port 1*/
+
+ p_ca_info->attr.num_ports = 1;
+ p_ca_info->attr.p_port_attr =
+ (ib_port_attr_t *) malloc(1 * sizeof(ib_port_attr_t));
+
+ port_info.port = 1;
+ ioctl_ret =
+ ioctl(p_tpot_info->device_fd, TS_IB_IOCGPORTINFO, &port_info);
+ if (ioctl_ret) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "__osm_ca_info_init: ERR 7002: "
+ "Fail to get HCA Port Attributes (%d).\n", ioctl_ret);
+ goto Exit;
+ }
+
+ gid_ioctl.port = 1;
+ gid_ioctl.index = 0;
+ ioctl_ret =
+ ioctl(p_tpot_info->device_fd, TS_IB_IOCGGIDENTRY, &gid_ioctl);
+ if (ioctl_ret) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "__osm_ca_info_init: ERR 7003: "
+ "Fail to get HCA Port GID (%d).\n", ioctl_ret);
+ goto Exit;
+ }
+
+ __osm_vendor_gid_to_guid(gid_ioctl.gid_entry,
+ &(p_ca_info->attr.p_port_attr[0].port_guid));
+ p_ca_info->attr.p_port_attr[0].lid = port_info.port_info.lid;
+ p_ca_info->attr.p_port_attr[0].link_state =
+ port_info.port_info.port_state;
+ p_ca_info->attr.p_port_attr[0].sm_lid = port_info.port_info.sm_lid;
+
+ status = IB_SUCCESS;
+Exit:
+ OSM_LOG_EXIT(p_vend->p_log);
+ return (status);
+}
+
+/**********************************************************************
+ * Fill in port_attr
+ * ALSO -
+ * Update the vendor object list of ca_info structs
+ **********************************************************************/
+ib_api_status_t
+osm_vendor_get_all_port_attr(IN osm_vendor_t * const p_vend,
+ IN ib_port_attr_t * const p_attr_array,
+ IN uint32_t * const p_num_ports)
+{
+ ib_api_status_t status;
+ osm_ca_info_t ca_info;
+ uint32_t attr_array_sz = *p_num_ports;
+
+ OSM_LOG_ENTER(p_vend->p_log);
+ CL_ASSERT(p_vend);
+
+ /* anafa has one port - the user didnt supply enough storage space */
+ if (attr_array_sz < 1) {
+ status = IB_INSUFFICIENT_MEMORY;
+ goto Exit;
+ }
+
+ /*
+ * retrieve the CA info attributes
+ */
+ status = __osm_ca_info_init(p_vend, &ca_info);
+ if (status != IB_SUCCESS) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "osm_vendor_get_all_port_attr: ERR 7004: "
+ "Unable to initialize CA Info object (%s).\n",
+ ib_get_err_str(status));
+ goto Exit;
+ }
+
+ *p_num_ports = 1;
+
+ p_attr_array[0] = ca_info.attr.p_port_attr[0]; /* anafa has only one port */
+ status = IB_SUCCESS;
+
+Exit:
+
+ OSM_LOG_EXIT(p_vend->p_log);
+ return (status);
+}
+
+#endif
diff --git a/contrib/ofed/opensm/libvendor/osm_vendor_mlx_hca_pfs.c b/contrib/ofed/opensm/libvendor/osm_vendor_mlx_hca_pfs.c
new file mode 100644
index 0000000..1190e9c
--- /dev/null
+++ b/contrib/ofed/opensm/libvendor/osm_vendor_mlx_hca_pfs.c
@@ -0,0 +1,749 @@
+/*
+ * Copyright (c) 2004-2008 Voltaire, Inc. All rights reserved.
+ * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved.
+ * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+#if HAVE_CONFIG_H
+# include <config.h>
+#endif /* HAVE_CONFIG_H */
+
+#if defined(OSM_VENDOR_INTF_MTL) | defined(OSM_VENDOR_INTF_TS)
+#undef IN
+#undef OUT
+#include <vendor/osm_vendor_api.h>
+#include <opensm/osm_log.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <sys/types.h>
+#include <dirent.h>
+#include <stdio.h>
+#include <sys/stat.h>
+#include <stdint.h>
+#include <fcntl.h>
+
+/********************************************************************************
+ *
+ * Provides the functionality for selecting an HCA Port and Obtaining it's guid.
+ * This version is based on /proc/infiniband file system. So it is limited to
+ * The gen1 of openib.org stack.
+ *
+ ********************************************************************************/
+
+typedef struct _osm_ca_info {
+ ib_net64_t guid;
+ size_t attr_size;
+ ib_ca_attr_t *p_attr;
+
+} osm_ca_info_t;
+
+/**********************************************************************
+ * Returns a pointer to the port attribute of the specified port
+ * owned by this CA.
+ ************************************************************************/
+static ib_port_attr_t *__osm_ca_info_get_port_attr_ptr(IN const osm_ca_info_t *
+ const p_ca_info,
+ IN const uint8_t index)
+{
+ return (&p_ca_info->p_attr->p_port_attr[index]);
+}
+
+/**********************************************************************
+ * Obtain the number of local CAs by scanning /proc/infiniband/core
+ **********************************************************************/
+int __hca_pfs_get_num_cas()
+{
+ int num_cas = 0;
+ DIR *dp;
+ struct dirent *ep;
+
+ dp = opendir("/proc/infiniband/core");
+ if (dp != NULL) {
+ while ((ep = readdir(dp))) {
+ /* CAs are directories with the format ca[1-9][0-9]* */
+ if ((ep->d_type == DT_DIR)
+ && !strncmp(ep->d_name, "ca", 2)) {
+ num_cas++;
+ }
+ }
+ closedir(dp);
+ }
+ return num_cas;
+}
+
+/*
+ name: InfiniHost0
+ provider: tavor
+ node GUID: 0002:c900:0120:3470
+ ports: 2
+ vendor ID: 0x2c9
+ device ID: 0x5a44
+ HW revision: 0xa1
+ FW revision: 0x300020080
+*/
+typedef struct _pfs_ca_info {
+ char name[32];
+ char provider[32];
+ uint64_t guid;
+ uint8_t num_ports;
+ uint32_t vend_id;
+ uint16_t dev_id;
+ uint16_t rev_id;
+ uint64_t fw_rev;
+} pfs_ca_info_t;
+
+/**********************************************************************
+ * Parse the CA Info file available in /proc/infiniband/core/caN/info
+ **********************************************************************/
+static ib_api_status_t
+__parse_ca_info_file(IN osm_vendor_t * const p_vend,
+ IN uint32_t idx, OUT pfs_ca_info_t * pfs_ca_info)
+{
+ ib_api_status_t status = IB_ERROR;
+ int info_file;
+ char file_name[256];
+ char file_buffer[3200];
+ char *p_ch;
+ int g1, g2, g3, g4;
+ int num_ports;
+ uint32_t len;
+
+ OSM_LOG_ENTER(p_vend->p_log);
+
+ osm_log(p_vend->p_log, OSM_LOG_DEBUG,
+ "__parse_ca_info_file: " "Querying CA %d.\n", idx);
+
+ /* we use the proc file system so we must be able to open the info file .. */
+ sprintf(file_name, "/proc/infiniband/core/ca%d/info", idx);
+ info_file = open(file_name, O_RDONLY);
+ if (!info_file) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "__parse_ca_info_file: ERR 5205: "
+ "Fail to open HCA:%d info file:(%s).\n", idx,
+ file_name);
+ goto Exit;
+ }
+
+ /* read in the file */
+ len = read(info_file, file_buffer, 3200);
+ close(info_file);
+ file_buffer[len] = '\0';
+
+ /*
+ parse the file ...
+ name: InfiniHost0
+ provider: tavor
+ node GUID: 0002:c900:0120:3470
+ ports: 2
+ vendor ID: 0x2c9
+ device ID: 0x5a44
+ HW revision: 0xa1
+ FW revision: 0x300020080
+ */
+ if (!(p_ch = strstr(file_buffer, "name:"))) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "__parse_ca_info_file: ERR 5206: "
+ "Fail to obtain HCA name. In info file:(%s).\n",
+ file_buffer);
+ goto Exit;
+ }
+ if (sscanf(p_ch, "name: %s", pfs_ca_info->name) != 1) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "__parse_ca_info_file: ERR 5207: "
+ "Fail to parse name in info file:(%s).\n", p_ch);
+ goto Exit;
+ }
+
+ /* get the guid of the HCA */
+ if (!(p_ch = strstr(file_buffer, "node GUID:"))) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "__parse_ca_info_file: ERR 5208: "
+ "Fail to obtain GUID in info file:(%s).\n",
+ file_buffer);
+ goto Exit;
+ }
+ if (sscanf(p_ch, "node GUID: %x:%x:%x:%x", &g1, &g2, &g3, &g4) != 4) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "__parse_ca_info_file: ERR 5209: "
+ "Fail to parse GUID in info file:(%s).\n", p_ch);
+ goto Exit;
+ }
+ pfs_ca_info->guid = (uint64_t) g1 << 48 | (uint64_t) g1 << 32
+ | (uint64_t) g1 << 16 | (uint64_t) g3;
+
+ /* obtain number of ports */
+ if (!(p_ch = strstr(file_buffer, "ports:"))) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "__parse_ca_info_file: ERR 5210: "
+ "Fail to obtain number of ports in info file:(%s).\n",
+ file_buffer);
+ goto Exit;
+ }
+ if (sscanf(p_ch, "ports: %d", &num_ports) != 1) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "__parse_ca_info_file: ERR 5211: "
+ "Fail to parse num ports in info file:(%s).\n", p_ch);
+ goto Exit;
+ }
+ pfs_ca_info->num_ports = num_ports;
+
+ osm_log(p_vend->p_log, OSM_LOG_DEBUG,
+ "__parse_ca_info_file: "
+ "CA1 = name:%s guid:0x%016llx ports:%d\n",
+ pfs_ca_info->name, pfs_ca_info->guid, pfs_ca_info->num_ports);
+
+ status = IB_SUCCESS;
+Exit:
+ OSM_LOG_EXIT(p_vend->p_log);
+ return status;
+}
+
+/*
+ state: ACTIVE
+ LID: 0x0001
+ LMC: 0x0000
+ SM LID: 0x0001
+ SM SL: 0x0000
+ Capabilities: IsSM
+ IsTrapSupported
+ IsAutomaticMigrationSupported
+ IsSLMappingSupported
+ IsLEDInfoSupported
+ IsSystemImageGUIDSupported
+ IsVendorClassSupported
+ IsCapabilityMaskNoticeSupported
+*/
+typedef struct _pfs_port_info {
+ uint8_t state;
+ uint16_t lid;
+ uint8_t lmc;
+ uint16_t sm_lid;
+ uint8_t sm_sl;
+} pfs_port_info_t;
+
+/**********************************************************************
+ * Parse the Port Info file available in /proc/infiniband/core/caN/portM/info
+ * Port num is 1..N
+ **********************************************************************/
+static ib_api_status_t
+__parse_port_info_file(IN osm_vendor_t * const p_vend,
+ IN uint32_t hca_idx,
+ IN uint8_t port_num, OUT pfs_port_info_t * pfs_port_info)
+{
+ ib_api_status_t status = IB_ERROR;
+ int info_file;
+ char file_name[256];
+ char file_buffer[3200];
+ char state[12];
+ char *p_ch;
+ int lid, sm_lid, lmc, sm_sl;
+ uint32_t len;
+
+ OSM_LOG_ENTER(p_vend->p_log);
+
+ osm_log(p_vend->p_log, OSM_LOG_DEBUG,
+ "__parse_port_info_file: "
+ "Parsing Proc File System Port Info CA %d Port %d.\n", hca_idx,
+ port_num);
+
+ /* we use the proc file system so we must be able to open the info file .. */
+ sprintf(file_name, "/proc/infiniband/core/ca%d/port%d/info", hca_idx,
+ port_num);
+ info_file = open(file_name, O_RDONLY);
+ if (!info_file) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "__parse_port_info_file: ERR 5212: "
+ "Fail to open HCA:%d Port:%d info file:(%s).\n",
+ hca_idx, port_num, file_name);
+ goto Exit;
+ }
+
+ /* read in the file */
+ len = read(info_file, file_buffer, 3200);
+ close(info_file);
+ file_buffer[len] = '\0';
+
+ /*
+ parse the file ...
+ state: ACTIVE
+ LID: 0x0001
+ LMC: 0x0000
+ SM LID: 0x0001
+ SM SL: 0x0000
+ ...
+ */
+ if (!(p_ch = strstr(file_buffer, "state:"))) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "__parse_port_info_file: ERR 5213: "
+ "Fail to obtain port state. In info file:(%s).\n",
+ file_buffer);
+ goto Exit;
+ }
+ if (sscanf(p_ch, "state: %s", state) != 1) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "__parse_port_info_file: ERR 5214: "
+ "Fail to parse state from info file:(%s).\n", p_ch);
+ goto Exit;
+ }
+
+ if (!strcmp(state, "ACTIVE"))
+ pfs_port_info->state = IB_LINK_ACTIVE;
+ else if (!strcmp(state, "DOWN"))
+ pfs_port_info->state = IB_LINK_DOWN;
+ else if (!strcmp(state, "INIT"))
+ pfs_port_info->state = IB_LINK_INIT;
+ else if (!strcmp(state, "ARMED"))
+ pfs_port_info->state = IB_LINK_ARMED;
+ else
+ pfs_port_info->state = 0;
+
+ /* get lid */
+ if (!(p_ch = strstr(file_buffer, "LID:"))) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "__parse_port_info_file: ERR 5215: "
+ "Fail to obtain port lid. In info file:(%s).\n",
+ file_buffer);
+ goto Exit;
+ }
+ if (sscanf(p_ch, "LID: %x", &lid) != 1) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "__parse_port_info_file: ERR 5216: "
+ "Fail to parse lid from info file:(%s).\n", p_ch);
+ goto Exit;
+ }
+ pfs_port_info->lid = lid;
+ /* get LMC */
+ if (!(p_ch = strstr(file_buffer, "LMC:"))) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "__parse_port_info_file: ERR 5217: "
+ "Fail to obtain port LMC. In info file:(%s).\n",
+ file_buffer);
+ goto Exit;
+ }
+ if (sscanf(p_ch, "LMC: %x", &lmc) != 1) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "__parse_port_info_file: ERR 5218: "
+ "Fail to parse LMC from info file:(%s).\n", p_ch);
+ goto Exit;
+ }
+ pfs_port_info->lmc = lmc;
+
+ /* get SM LID */
+ if (!(p_ch = strstr(file_buffer, "SM LID:"))) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "__parse_port_info_file: ERR 5219: "
+ "Fail to obtain port SM LID. In info file:(%s).\n",
+ file_buffer);
+ goto Exit;
+ }
+ if (sscanf(p_ch, "SM LID: %x", &sm_lid) != 1) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "__parse_port_info_file: ERR 5220: "
+ "Fail to parse SM LID from info file:(%s).\n", p_ch);
+ goto Exit;
+ }
+ pfs_port_info->sm_lid = sm_lid;
+
+ /* get SM LID */
+ if (!(p_ch = strstr(file_buffer, "SM SL:"))) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "__parse_port_info_file: ERR 5221: "
+ "Fail to obtain port SM SL. In info file:(%s).\n",
+ file_buffer);
+ goto Exit;
+ }
+ if (sscanf(p_ch, "SM SL: %x", &sm_sl) != 1) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "__parse_port_info_file: ERR 5222: "
+ "Fail to parse SM SL from info file:(%s).\n", p_ch);
+ goto Exit;
+ }
+ pfs_port_info->sm_sl = sm_sl;
+ osm_log(p_vend->p_log, OSM_LOG_DEBUG,
+ "__parse_port_info_file: "
+ "Obtained Port:%d = state:%d, lid:0x%04X, lmc:%d, sm_lid:0x%04X, sm_sl:%d\n",
+ port_num, pfs_port_info->state, pfs_port_info->lid,
+ pfs_port_info->lmc, pfs_port_info->sm_lid,
+ pfs_port_info->sm_sl);
+
+ status = IB_SUCCESS;
+Exit:
+ OSM_LOG_EXIT(p_vend->p_log);
+ return status;
+}
+
+/**********************************************************************
+ * Parse the port guid_tbl file to obtain the port guid.
+ * File format is:
+ * [ 0] fe80:0000:0000:0000:0002:c900:0120:3472
+ **********************************************************************/
+static ib_api_status_t
+__get_port_guid_from_port_gid_tbl(IN osm_vendor_t * const p_vend,
+ IN uint32_t hca_idx,
+ IN uint8_t port_num, OUT uint64_t * port_guid)
+{
+ ib_api_status_t status = IB_ERROR;
+ int info_file;
+ char file_name[256];
+ char file_buffer[3200];
+ char *p_ch;
+ int g[8];
+ uint32_t len;
+
+ OSM_LOG_ENTER(p_vend->p_log);
+
+ osm_log(p_vend->p_log, OSM_LOG_DEBUG,
+ "__get_port_guid_from_port_gid_tbl: "
+ "Parsing Proc File System Port Guid Table CA %d Port %d.\n",
+ hca_idx, port_num);
+
+ /* we use the proc file system so we must be able to open the info file .. */
+ sprintf(file_name, "/proc/infiniband/core/ca%d/port%d/gid_table",
+ hca_idx, port_num);
+ info_file = open(file_name, O_RDONLY);
+ if (!info_file) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "__get_port_guid_from_port_gid_tbl: ERR 5223: "
+ "Fail to open HCA:%d Port:%d gid_table file:(%s).\n",
+ hca_idx, port_num, file_name);
+ goto Exit;
+ }
+
+ /* read in the file */
+ len = read(info_file, file_buffer, 3200);
+ close(info_file);
+ file_buffer[len] = '\0';
+
+ /*
+ parse the file ...
+ [ 0] fe80:0000:0000:0000:0002:c900:0120:3472
+ ...
+ */
+ if (!(p_ch = strstr(file_buffer, "[ 0]"))) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "__get_port_guid_from_port_gid_tbl: ERR 5224: "
+ "Fail to obtain first gid index. In gid_table file:(%s).\n",
+ file_buffer);
+ goto Exit;
+ }
+ if (sscanf(p_ch + 6, "%x:%x:%x:%x:%x:%x:%x:%x",
+ &g[7], &g[6], &g[5], &g[4], &g[3], &g[2], &g[1], &g[0]) != 8)
+ {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "__get_port_guid_from_port_gid_tbl: ERR 5225: "
+ "Fail to parse gid from gid_table file:(%s).\n", p_ch);
+ goto Exit;
+ }
+
+ *port_guid =
+ (uint64_t) g[3] << 48 | (uint64_t) g[2] << 32 | (uint64_t) g[1] <<
+ 16 | g[0];
+ status = IB_SUCCESS;
+Exit:
+ OSM_LOG_EXIT(p_vend->p_log);
+ return status;
+}
+
+/**********************************************************************
+ * Initialize an Info Struct for the Given HCA by its index 1..N
+ **********************************************************************/
+static ib_api_status_t
+__osm_ca_info_init(IN osm_vendor_t * const p_vend,
+ IN uint32_t const idx, OUT osm_ca_info_t * const p_ca_info)
+{
+ ib_api_status_t status = IB_ERROR;
+ uint8_t port_num;
+ uint64_t port_guid;
+
+ pfs_ca_info_t pfs_ca_info;
+
+ OSM_LOG_ENTER(p_vend->p_log);
+
+ /* parse the CA info file */
+ if (__parse_ca_info_file(p_vend, idx, &pfs_ca_info) != IB_SUCCESS)
+ goto Exit;
+
+ p_ca_info->guid = cl_hton64(pfs_ca_info.guid);
+
+ /* set size of attributes and allocate them */
+ p_ca_info->attr_size = 1;
+ p_ca_info->p_attr = (ib_ca_attr_t *) malloc(sizeof(ib_ca_attr_t));
+
+ p_ca_info->p_attr->ca_guid = p_ca_info->guid;
+ p_ca_info->p_attr->num_ports = pfs_ca_info.num_ports;
+
+ /* now obtain the attributes of the ports */
+ p_ca_info->p_attr->p_port_attr =
+ (ib_port_attr_t *) malloc(pfs_ca_info.num_ports *
+ sizeof(ib_port_attr_t));
+
+ /* get all the ports info */
+ for (port_num = 1; port_num <= pfs_ca_info.num_ports; port_num++) {
+ pfs_port_info_t pfs_port_info;
+ /* query the port attributes */
+ if (__parse_port_info_file
+ (p_vend, idx, port_num, &pfs_port_info)) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "__osm_ca_info_init: ERR 5226: "
+ "Fail to get HCA:%d Port:%d Attributes.\n", idx,
+ port_num);
+ goto Exit;
+ }
+
+ /* HACK: the lids should have been converted to network but the rest of the code
+ is wrong and provdes them as is (host order) - so we stick with it. */
+ p_ca_info->p_attr->p_port_attr[port_num - 1].lid =
+ pfs_port_info.lid;
+ p_ca_info->p_attr->p_port_attr[port_num - 1].link_state =
+ pfs_port_info.state;
+ p_ca_info->p_attr->p_port_attr[port_num - 1].sm_lid =
+ pfs_port_info.sm_lid;
+
+ /* get the port guid */
+ if (__get_port_guid_from_port_gid_tbl
+ (p_vend, idx, port_num, &port_guid)) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "__osm_ca_info_init: ERR 5227: "
+ "Fail to get HCA:%d Port:%d Guid.\n", idx,
+ port_num);
+ goto Exit;
+ }
+ p_ca_info->p_attr->p_port_attr[port_num - 1].port_guid =
+ cl_hton64(port_guid);
+ }
+
+ status = IB_SUCCESS;
+Exit:
+ OSM_LOG_EXIT(p_vend->p_log);
+ return (status);
+}
+
+void
+osm_ca_info_destroy(IN osm_vendor_t * const p_vend,
+ IN osm_ca_info_t * const p_ca_info, IN uint8_t num_ca)
+{
+ osm_ca_info_t *p_ca;
+ uint8_t i;
+
+ OSM_LOG_ENTER(p_vend->p_log);
+
+ for (i = 0; i < num_ca; i++) {
+ p_ca = &p_ca_info[i];
+
+ if (NULL != p_ca->p_attr) {
+ if (0 != p_ca->p_attr->num_ports) {
+ free(p_ca->p_attr->p_port_attr);
+ }
+
+ free(p_ca->p_attr);
+ }
+ }
+
+ free(p_ca_info);
+
+ OSM_LOG_EXIT(p_vend->p_log);
+}
+
+/**********************************************************************
+ * Fill in the array of port_attr with all available ports on ALL the
+ * avilable CAs on this machine.
+ **********************************************************************/
+ib_api_status_t
+osm_vendor_get_all_port_attr(IN osm_vendor_t * const p_vend,
+ IN ib_port_attr_t * const p_attr_array,
+ IN uint32_t * const p_num_ports)
+{
+ ib_api_status_t status = IB_SUCCESS;
+
+ uint32_t caIdx;
+ uint32_t ca_count = 0;
+ uint32_t port_count = 0;
+ uint8_t port_num;
+ uint32_t total_ports = 0;
+ osm_ca_info_t *p_ca_infos = NULL;
+ uint32_t attr_array_sz = *p_num_ports;
+
+ OSM_LOG_ENTER(p_vend->p_log);
+
+ CL_ASSERT(p_vend);
+
+ /* determine the number of CA's */
+ ca_count = __hca_pfs_get_num_cas();
+ if (!ca_count) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "osm_vendor_get_all_port_attr: ERR 5228: "
+ "Fail to get Any CA Ids.\n");
+ goto Exit;
+ }
+
+ /* Allocate an array big enough to hold the ca info objects */
+ p_ca_infos = malloc(ca_count * sizeof(osm_ca_info_t));
+ if (p_ca_infos == NULL) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "osm_vendor_get_all_port_attr: ERR 5229: "
+ "Unable to allocate CA information array.\n");
+ goto Exit;
+ }
+
+ memset(p_ca_infos, 0, ca_count * sizeof(osm_ca_info_t));
+
+ /*
+ * For each CA, retrieve the CA info attributes
+ */
+ for (caIdx = 1; caIdx <= ca_count; caIdx++) {
+ status =
+ __osm_ca_info_init(p_vend, caIdx, &p_ca_infos[caIdx - 1]);
+ if (status != IB_SUCCESS) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "osm_vendor_get_all_port_attr: ERR 5230: "
+ "Unable to initialize CA Info object (%s).\n",
+ ib_get_err_str(status));
+ goto Exit;
+ }
+ total_ports += p_ca_infos[caIdx - 1].p_attr->num_ports;
+ }
+
+ *p_num_ports = total_ports;
+ osm_log(p_vend->p_log, OSM_LOG_DEBUG,
+ "osm_vendor_get_all_port_attr: total ports:%u \n", total_ports);
+
+ /*
+ * If the user supplied enough storage, return the port guids,
+ * otherwise, return the appropriate error.
+ */
+ if (attr_array_sz >= total_ports) {
+ for (caIdx = 1; caIdx <= ca_count; caIdx++) {
+ uint32_t num_ports;
+
+ num_ports = p_ca_infos[caIdx - 1].p_attr->num_ports;
+
+ for (port_num = 0; port_num < num_ports; port_num++) {
+ p_attr_array[port_count] =
+ *__osm_ca_info_get_port_attr_ptr(&p_ca_infos
+ [caIdx -
+ 1],
+ port_num);
+ port_count++;
+ }
+ }
+ } else {
+ status = IB_INSUFFICIENT_MEMORY;
+ goto Exit;
+ }
+
+ status = IB_SUCCESS;
+
+Exit:
+ if (p_ca_infos) {
+ osm_ca_info_destroy(p_vend, p_ca_infos, ca_count);
+ }
+
+ OSM_LOG_EXIT(p_vend->p_log);
+ return (status);
+}
+
+/**********************************************************************
+ * Given the vendor obj and a port guid
+ * return the ca id and port number that have that guid
+ **********************************************************************/
+
+ib_api_status_t
+osm_vendor_get_guid_ca_and_port(IN osm_vendor_t * const p_vend,
+ IN ib_net64_t const guid,
+ OUT uint32_t * p_hca_hndl,
+ OUT char *p_hca_id,
+ OUT uint8_t * p_hca_idx,
+ OUT uint32_t * p_port_num)
+{
+ uint32_t caIdx;
+ uint32_t ca_count = 0;
+ uint8_t port_num;
+ ib_api_status_t status = IB_ERROR;
+
+ OSM_LOG_ENTER(p_vend->p_log);
+
+ CL_ASSERT(p_vend);
+
+ /* determine the number of CA's */
+ ca_count = __hca_pfs_get_num_cas();
+ if (!ca_count) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "osm_vendor_get_guid_ca_and_port: ERR 5231: "
+ "Fail to get Any CA Ids.\n");
+ goto Exit;
+ }
+
+ /*
+ * For each CA, retrieve the CA info attributes
+ */
+ for (caIdx = 1; caIdx <= ca_count; caIdx++) {
+ pfs_ca_info_t pfs_ca_info;
+ if (__parse_ca_info_file(p_vend, caIdx, &pfs_ca_info) ==
+ IB_SUCCESS) {
+ /* get all the ports info */
+ for (port_num = 1; port_num <= pfs_ca_info.num_ports;
+ port_num++) {
+ uint64_t port_guid;
+ if (!__get_port_guid_from_port_gid_tbl
+ (p_vend, caIdx, port_num, &port_guid)) {
+ if (cl_hton64(port_guid) == guid) {
+ osm_log(p_vend->p_log,
+ OSM_LOG_DEBUG,
+ "osm_vendor_get_guid_ca_and_port: "
+ "Found Matching guid on HCA:%d Port:%d.\n",
+ caIdx, port_num);
+ strcpy(p_hca_id,
+ pfs_ca_info.name);
+ *p_port_num = port_num;
+ *p_hca_idx = caIdx - 1;
+ *p_hca_hndl = 0;
+ status = IB_SUCCESS;
+ goto Exit;
+ }
+ }
+ }
+ }
+ }
+
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "osm_vendor_get_guid_ca_and_port: ERR 5232: "
+ "Fail to find HCA and Port for Port Guid 0x%" PRIx64 "\n",
+ cl_ntoh64(guid));
+ status = IB_INVALID_GUID;
+
+Exit:
+
+ OSM_LOG_EXIT(p_vend->p_log);
+ return (status);
+}
+
+#endif
diff --git a/contrib/ofed/opensm/libvendor/osm_vendor_mlx_hca_sim.c b/contrib/ofed/opensm/libvendor/osm_vendor_mlx_hca_sim.c
new file mode 100644
index 0000000..15df23e
--- /dev/null
+++ b/contrib/ofed/opensm/libvendor/osm_vendor_mlx_hca_sim.c
@@ -0,0 +1,862 @@
+/*
+ * Copyright (c) 2004-2008 Voltaire, Inc. All rights reserved.
+ * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved.
+ * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+#if HAVE_CONFIG_H
+# include <config.h>
+#endif /* HAVE_CONFIG_H */
+
+#if defined(OSM_VENDOR_INTF_SIM)
+#undef IN
+#undef OUT
+
+#include <unistd.h>
+#include <vendor/osm_vendor_api.h>
+#include <opensm/osm_log.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <sys/types.h>
+#include <dirent.h>
+#include <stdlib.h>
+#include <sys/stat.h>
+#include <stdint.h>
+#include <fcntl.h>
+
+/******************************************************************************
+*
+* Provides the functionality for selecting an HCA Port and Obtaining it's guid.
+* This version is based on $IBMGTSIM_DIR/$IBMGTSIM_NODE file system.
+* This is a mimic of the OpenIB gen1 file system
+*
+******************************************************************************/
+
+char *__get_simulator_dir(void)
+{
+ static char *ibmgtSimDir = NULL;
+ static char *defaultIbmgtSimDir = "/tmp/ibmgtsim";
+ static char *ibmgtSimNode = NULL;
+ static char dirName[1024];
+
+ /* we use the first pointer to know if we were here */
+ if (ibmgtSimDir == NULL) {
+ /* obtain the simulator directory */
+ ibmgtSimDir = getenv("IBMGTSIM_DIR");
+ if (ibmgtSimDir == NULL) {
+ printf
+ ("-W- Environment variable: IBMGTSIM_DIR does not exist.\n");
+ printf
+ (" Please create one used by the simulator.\n");
+ printf(" Using /tmp/ibmgtsim as default.\n");
+ ibmgtSimDir = defaultIbmgtSimDir;
+ }
+
+ /* obtain the node name we simulate */
+ ibmgtSimNode = getenv("IBMGTSIM_NODE");
+ if (ibmgtSimNode == NULL) {
+ printf
+ ("-W- Environment variable: IBMGTSIM_NODE does not exist.\n");
+ printf
+ (" This variable should be the name of the node you wish to simulate.\n");
+ printf(" Using H-1 as default.\n");
+ ibmgtSimNode = "H-1";
+ }
+ sprintf(dirName, "%s/%s", ibmgtSimDir, ibmgtSimNode);
+ }
+
+ return dirName;
+}
+
+typedef struct _osm_ca_info {
+ ib_net64_t guid;
+ size_t attr_size;
+ ib_ca_attr_t *p_attr;
+
+} osm_ca_info_t;
+
+/**********************************************************************
+ * Returns a pointer to the port attribute of the specified port
+ * owned by this CA.
+ ************************************************************************/
+static ib_port_attr_t *__osm_ca_info_get_port_attr_ptr(IN const osm_ca_info_t *
+ const p_ca_info,
+ IN const uint8_t index)
+{
+ return (&p_ca_info->p_attr->p_port_attr[index]);
+}
+
+/**********************************************************************
+ * Obtain the number of local CAs by scanning /proc/infiniband/core
+ **********************************************************************/
+int __hca_sim_get_num_cas(void)
+{
+ int num_cas = 0;
+ DIR *dp;
+ struct dirent *ep;
+
+ dp = opendir(__get_simulator_dir());
+
+ if (dp != NULL) {
+ while ((ep = readdir(dp))) {
+ /* CAs are directories with the format ca[1-9][0-9]* */
+ /* if ((ep->d_type == DT_DIR) && !strncmp(ep->d_name, "ca", 2)) */
+ if (!strncmp(ep->d_name, "ca", 2)) {
+ num_cas++;
+ }
+ }
+ closedir(dp);
+ } else {
+ printf("__hca_sim_get_num_cas: ERROR : ail to open dir %s\n",
+ __get_simulator_dir());
+ exit(1);
+ }
+
+ if (!num_cas)
+ exit(1);
+ return num_cas;
+}
+
+/*
+ name: InfiniHost0
+ provider: tavor
+ node GUID: 0002:c900:0120:3470
+ ports: 2
+ vendor ID: 0x2c9
+ device ID: 0x5a44
+ HW revision: 0xa1
+ FW revision: 0x300020080
+*/
+typedef struct _sim_ca_info {
+ char name[32];
+ char provider[32];
+ uint64_t guid;
+ uint8_t num_ports;
+ uint32_t vend_id;
+ uint16_t dev_id;
+ uint16_t rev_id;
+ uint64_t fw_rev;
+} sim_ca_info_t;
+
+/**********************************************************************
+ * Parse the CA Info file available in ibmgtSimDir/caN/info
+ **********************************************************************/
+static ib_api_status_t
+__parse_ca_info_file(IN osm_vendor_t * const p_vend,
+ IN uint32_t idx, OUT sim_ca_info_t * sim_ca_info)
+{
+ ib_api_status_t status = IB_ERROR;
+ int info_file;
+ char file_name[256];
+ char file_buffer[3200];
+ char *p_ch;
+ int g1, g2, g3, g4;
+ int num_ports;
+ uint32_t len;
+
+ OSM_LOG_ENTER(p_vend->p_log);
+
+ osm_log(p_vend->p_log, OSM_LOG_DEBUG,
+ "__parse_ca_info_file: " "Querying CA %d.\n", idx);
+
+ /* we use the proc file system so we must be able to open the info file .. */
+ sprintf(file_name, "%s/ca%d/info", __get_simulator_dir(), idx);
+ info_file = open(file_name, O_RDONLY);
+ if (!info_file) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "__parse_ca_info_file: ERR 5105: "
+ "Fail to open HCA:%d info file:(%s).\n", idx,
+ file_name);
+ goto Exit;
+ }
+
+ /* read in the file */
+ len = read(info_file, file_buffer, 3200);
+ close(info_file);
+ file_buffer[len] = '\0';
+
+ /*
+ parse the file ...
+ name: InfiniHost0
+ provider: tavor
+ node GUID: 0002:c900:0120:3470
+ ports: 2
+ vendor ID: 0x2c9
+ device ID: 0x5a44
+ HW revision: 0xa1
+ FW revision: 0x300020080
+ */
+ if (!(p_ch = strstr(file_buffer, "name:"))) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "__parse_ca_info_file: ERR 5106: "
+ "Fail to obtain HCA name. In info file:(%s).\n",
+ file_buffer);
+ goto Exit;
+ }
+ if (sscanf(p_ch, "name: %s", sim_ca_info->name) != 1) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "__parse_ca_info_file: ERR 5107: "
+ "Fail to parse name in info file:(%s).\n", p_ch);
+ goto Exit;
+ }
+
+ /* get the guid of the HCA */
+ if (!(p_ch = strstr(file_buffer, "node GUID:"))) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "__parse_ca_info_file: ERR 5108: "
+ "Fail to obtain GUID in info file:(%s).\n",
+ file_buffer);
+ goto Exit;
+ }
+ if (sscanf(p_ch, "node GUID: %x:%x:%x:%x", &g1, &g2, &g3, &g4) != 4) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "__parse_ca_info_file: ERR 5109: "
+ "Fail to parse GUID in info file:(%s).\n", p_ch);
+ goto Exit;
+ }
+ sim_ca_info->guid = (uint64_t) g1 << 48 | (uint64_t) g1 << 32
+ | (uint64_t) g1 << 16 | (uint64_t) g3;
+
+ /* obtain number of ports */
+ if (!(p_ch = strstr(file_buffer, "ports:"))) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "__parse_ca_info_file: ERR 5110: "
+ "Fail to obtain number of ports in info file:(%s).\n",
+ file_buffer);
+ goto Exit;
+ }
+ if (sscanf(p_ch, "ports: %d", &num_ports) != 1) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "__parse_ca_info_file: ERR 5111: "
+ "Fail to parse num ports in info file:(%s).\n", p_ch);
+ goto Exit;
+ }
+ sim_ca_info->num_ports = num_ports;
+
+ osm_log(p_vend->p_log, OSM_LOG_DEBUG,
+ "__parse_ca_info_file: "
+ "CA1 = name:%s guid:0x%" PRIx64 " ports:%d\n",
+ sim_ca_info->name, sim_ca_info->guid, sim_ca_info->num_ports);
+
+ status = IB_SUCCESS;
+Exit:
+ OSM_LOG_EXIT(p_vend->p_log);
+ return status;
+}
+
+/*
+ state: ACTIVE
+ LID: 0x0001
+ LMC: 0x0000
+ SM LID: 0x0001
+ SM SL: 0x0000
+ Capabilities: IsSM
+ IsTrapSupported
+ IsAutomaticMigrationSupported
+ IsSLMappingSupported
+ IsLEDInfoSupported
+ IsSystemImageGUIDSupported
+ IsVendorClassSupported
+ IsCapabilityMaskNoticeSupported
+*/
+typedef struct _sim_port_info {
+ uint8_t state;
+ uint16_t lid;
+ uint8_t lmc;
+ uint16_t sm_lid;
+ uint8_t sm_sl;
+} sim_port_info_t;
+
+/**********************************************************************
+ * Parse the Port Info file available in ibmgtSimDir/caN/portM/info
+ * Port num is 1..N
+ **********************************************************************/
+static ib_api_status_t
+__parse_port_info_file(IN osm_vendor_t * const p_vend,
+ IN uint32_t hca_idx,
+ IN uint8_t port_num, OUT sim_port_info_t * sim_port_info)
+{
+ ib_api_status_t status = IB_ERROR;
+ int info_file;
+ char file_name[256];
+ char file_buffer[3200];
+ char state[12];
+ char *p_ch;
+ int lid, sm_lid, lmc, sm_sl;
+ uint32_t len;
+
+ OSM_LOG_ENTER(p_vend->p_log);
+
+ osm_log(p_vend->p_log, OSM_LOG_DEBUG,
+ "__parse_port_info_file: "
+ "Parsing Proc File System Port Info CA %d Port %d.\n", hca_idx,
+ port_num);
+
+ /* we use the proc file system so we must be able to open the info file .. */
+ sprintf(file_name, "%s/ca%d/port%d/info", __get_simulator_dir(),
+ hca_idx, port_num);
+ info_file = open(file_name, O_RDONLY);
+ if (!info_file) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "__parse_port_info_file: ERR 5112: "
+ "Fail to open HCA:%d Port:%d info file:(%s).\n",
+ hca_idx, port_num, file_name);
+ goto Exit;
+ }
+
+ /* read in the file */
+ len = read(info_file, file_buffer, 3200);
+ close(info_file);
+ file_buffer[len] = '\0';
+
+ /*
+ parse the file ...
+ state: ACTIVE
+ LID: 0x0001
+ LMC: 0x0000
+ SM LID: 0x0001
+ SM SL: 0x0000
+ ...
+ */
+ if (!(p_ch = strstr(file_buffer, "state:"))) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "__parse_port_info_file: ERR 5113: "
+ "Fail to obtain port state. In info file:(%s).\n",
+ file_buffer);
+ goto Exit;
+ }
+ if (sscanf(p_ch, "state: %s", state) != 1) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "__parse_port_info_file: ERR 5114: "
+ "Fail to parse state from info file:(%s).\n", p_ch);
+ goto Exit;
+ }
+
+ if (!strcmp(state, "ACTIVE"))
+ sim_port_info->state = IB_LINK_ACTIVE;
+ else if (!strcmp(state, "DOWN"))
+ sim_port_info->state = IB_LINK_DOWN;
+ else if (!strcmp(state, "INIT"))
+ sim_port_info->state = IB_LINK_INIT;
+ else if (!strcmp(state, "ARMED"))
+ sim_port_info->state = IB_LINK_ARMED;
+ else
+ sim_port_info->state = 0;
+
+ /* get lid */
+ if (!(p_ch = strstr(file_buffer, "LID:"))) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "__parse_port_info_file: ERR 5115: "
+ "Fail to obtain port lid. In info file:(%s).\n",
+ file_buffer);
+ goto Exit;
+ }
+ if (sscanf(p_ch, "LID: %x", &lid) != 1) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "__parse_port_info_file: ERR 5116: "
+ "Fail to parse lid from info file:(%s).\n", p_ch);
+ goto Exit;
+ }
+ sim_port_info->lid = lid;
+ /* get LMC */
+ if (!(p_ch = strstr(file_buffer, "LMC:"))) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "__parse_port_info_file: ERR 5117: "
+ "Fail to obtain port LMC. In info file:(%s).\n",
+ file_buffer);
+ goto Exit;
+ }
+ if (sscanf(p_ch, "LMC: %x", &lmc) != 1) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "__parse_port_info_file: ERR 5118: "
+ "Fail to parse LMC from info file:(%s).\n", p_ch);
+ goto Exit;
+ }
+ sim_port_info->lmc = lmc;
+
+ /* get SM LID */
+ if (!(p_ch = strstr(file_buffer, "SM LID:"))) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "__parse_port_info_file: ERR 5119: "
+ "Fail to obtain port SM LID. In info file:(%s).\n",
+ file_buffer);
+ goto Exit;
+ }
+ if (sscanf(p_ch, "SM LID: %x", &sm_lid) != 1) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "__parse_port_info_file: ERR 5120: "
+ "Fail to parse SM LID from info file:(%s).\n", p_ch);
+ goto Exit;
+ }
+ sim_port_info->sm_lid = sm_lid;
+
+ /* get SM LID */
+ if (!(p_ch = strstr(file_buffer, "SM SL:"))) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "__parse_port_info_file: ERR 5121: "
+ "Fail to obtain port SM SL. In info file:(%s).\n",
+ file_buffer);
+ goto Exit;
+ }
+ if (sscanf(p_ch, "SM SL: %x", &sm_sl) != 1) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "__parse_port_info_file: ERR 5122: "
+ "Fail to parse SM SL from info file:(%s).\n", p_ch);
+ goto Exit;
+ }
+ sim_port_info->sm_sl = sm_sl;
+ osm_log(p_vend->p_log, OSM_LOG_DEBUG,
+ "__parse_port_info_file: "
+ "Obtained Port:%d = state:%d, lid:0x%04X, lmc:%d, sm_lid:0x%04X, sm_sl:%d\n",
+ port_num, sim_port_info->state, sim_port_info->lid,
+ sim_port_info->lmc, sim_port_info->sm_lid,
+ sim_port_info->sm_sl);
+
+ status = IB_SUCCESS;
+Exit:
+ OSM_LOG_EXIT(p_vend->p_log);
+ return status;
+}
+
+/**********************************************************************
+ * Parse the port guid_tbl file to obtain the port guid.
+ * File format is:
+ * [ 0] fe80:0000:0000:0000:0002:c900:0120:3472
+ **********************************************************************/
+static ib_api_status_t
+__get_port_guid_from_port_gid_tbl(IN osm_vendor_t * const p_vend,
+ IN uint32_t hca_idx,
+ IN uint8_t port_num, OUT uint64_t * port_guid)
+{
+ ib_api_status_t status = IB_ERROR;
+ int info_file;
+ char file_name[256];
+ char file_buffer[3200];
+ char *p_ch;
+ int g[8];
+ uint32_t len;
+
+ OSM_LOG_ENTER(p_vend->p_log);
+
+ osm_log(p_vend->p_log, OSM_LOG_DEBUG,
+ "__get_port_guid_from_port_gid_tbl: "
+ "Parsing Proc File System Port Guid Table CA %d Port %d.\n",
+ hca_idx, port_num);
+
+ /* we use the proc file system so we must be able to open the info file .. */
+ sprintf(file_name, "%s/ca%d/port%d/gid_table",
+ __get_simulator_dir(), hca_idx, port_num);
+ info_file = open(file_name, O_RDONLY);
+ if (!info_file) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "__get_port_guid_from_port_gid_tbl: ERR 5123: "
+ "Fail to open HCA:%d Port:%d gid_table file:(%s).\n",
+ hca_idx, port_num, file_name);
+ goto Exit;
+ }
+
+ /* read in the file */
+ len = read(info_file, file_buffer, 3200);
+ close(info_file);
+ file_buffer[len] = '\0';
+
+ /*
+ parse the file ...
+ [ 0] fe80:0000:0000:0000:0002:c900:0120:3472
+ ...
+ */
+ if (!(p_ch = strstr(file_buffer, "[ 0]"))) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "__get_port_guid_from_port_gid_tbl: ERR 5124: "
+ "Fail to obtain first gid index. In gid_table file:(%s).\n",
+ file_buffer);
+ goto Exit;
+ }
+ if (sscanf(p_ch + 6, "%x:%x:%x:%x:%x:%x:%x:%x",
+ &g[7], &g[6], &g[5], &g[4], &g[3], &g[2], &g[1], &g[0]) != 8)
+ {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "__get_port_guid_from_port_gid_tbl: ERR 5125: "
+ "Fail to parse gid from gid_table file:(%s).\n", p_ch);
+ goto Exit;
+ }
+
+ *port_guid =
+ (uint64_t) g[3] << 48 | (uint64_t) g[2] << 32 | (uint64_t) g[1] <<
+ 16 | g[0];
+ status = IB_SUCCESS;
+Exit:
+ OSM_LOG_EXIT(p_vend->p_log);
+ return status;
+}
+
+/**********************************************************************
+ * Initialize an Info Struct for the Given HCA by its index 1..N
+ **********************************************************************/
+static ib_api_status_t
+__osm_ca_info_init(IN osm_vendor_t * const p_vend,
+ IN uint32_t const idx, OUT osm_ca_info_t * const p_ca_info)
+{
+ ib_api_status_t status = IB_ERROR;
+ uint8_t port_num;
+ uint64_t port_guid;
+
+ sim_ca_info_t sim_ca_info;
+
+ OSM_LOG_ENTER(p_vend->p_log);
+
+ /* parse the CA info file */
+ if (__parse_ca_info_file(p_vend, idx, &sim_ca_info) != IB_SUCCESS)
+ goto Exit;
+
+ p_ca_info->guid = cl_hton64(sim_ca_info.guid);
+
+ /* set size of attributes and allocate them */
+ p_ca_info->attr_size = 1;
+ p_ca_info->p_attr = (ib_ca_attr_t *) malloc(sizeof(ib_ca_attr_t));
+
+ p_ca_info->p_attr->ca_guid = p_ca_info->guid;
+ p_ca_info->p_attr->num_ports = sim_ca_info.num_ports;
+
+ /* now obtain the attributes of the ports */
+ p_ca_info->p_attr->p_port_attr =
+ (ib_port_attr_t *) malloc(sim_ca_info.num_ports *
+ sizeof(ib_port_attr_t));
+
+ /* get all the ports info */
+ for (port_num = 1; port_num <= sim_ca_info.num_ports; port_num++) {
+ sim_port_info_t sim_port_info;
+ /* query the port attributes */
+ if (__parse_port_info_file
+ (p_vend, idx, port_num, &sim_port_info)) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "__osm_ca_info_init: ERR 5126: "
+ "Fail to get HCA:%d Port:%d Attributes.\n", idx,
+ port_num);
+ goto Exit;
+ }
+
+ /* HACK: the lids should have been converted to network but the rest of the code
+ is wrong and provdes them as is (host order) - so we stick with it. */
+ p_ca_info->p_attr->p_port_attr[port_num - 1].lid =
+ sim_port_info.lid;
+ p_ca_info->p_attr->p_port_attr[port_num - 1].link_state =
+ sim_port_info.state;
+ p_ca_info->p_attr->p_port_attr[port_num - 1].sm_lid =
+ sim_port_info.sm_lid;
+
+ /* get the port guid */
+ if (__get_port_guid_from_port_gid_tbl
+ (p_vend, idx, port_num, &port_guid)) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "__osm_ca_info_init: ERR 5127: "
+ "Fail to get HCA:%d Port:%d Guid.\n", idx,
+ port_num);
+ goto Exit;
+ }
+ p_ca_info->p_attr->p_port_attr[port_num - 1].port_guid =
+ cl_hton64(port_guid);
+ }
+
+ status = IB_SUCCESS;
+Exit:
+ OSM_LOG_EXIT(p_vend->p_log);
+ return (status);
+}
+
+void
+osm_ca_info_destroy(IN osm_vendor_t * const p_vend,
+ IN osm_ca_info_t * const p_ca_info, IN uint8_t num_ca)
+{
+ osm_ca_info_t *p_ca;
+ uint8_t i;
+
+ OSM_LOG_ENTER(p_vend->p_log);
+
+ for (i = 0; i < num_ca; i++) {
+ p_ca = &p_ca_info[i];
+
+ if (NULL != p_ca->p_attr) {
+ if (0 != p_ca->p_attr->num_ports) {
+ free(p_ca->p_attr->p_port_attr);
+ }
+
+ free(p_ca->p_attr);
+ }
+ }
+
+ free(p_ca_info);
+
+ OSM_LOG_EXIT(p_vend->p_log);
+}
+
+/**********************************************************************
+ * Fill in the array of port_attr with all available ports on ALL the
+ * avilable CAs on this machine.
+ **********************************************************************/
+ib_api_status_t
+osm_vendor_get_all_port_attr(IN osm_vendor_t * const p_vend,
+ IN ib_port_attr_t * const p_attr_array,
+ IN uint32_t * const p_num_ports)
+{
+ ib_api_status_t status = IB_SUCCESS;
+
+ uint32_t caIdx;
+ uint32_t ca_count = 0;
+ uint32_t port_count = 0;
+ uint8_t port_num;
+ uint32_t total_ports = 0;
+ osm_ca_info_t *p_ca_infos = NULL;
+ uint32_t attr_array_sz = *p_num_ports;
+
+ OSM_LOG_ENTER(p_vend->p_log);
+
+ CL_ASSERT(p_vend);
+
+ /* determine the number of CA's */
+ ca_count = __hca_sim_get_num_cas();
+ if (!ca_count) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "osm_vendor_get_all_port_attr: ERR 5128: "
+ "Fail to get Any CA Ids.\n");
+ goto Exit;
+ }
+
+ /* Allocate an array big enough to hold the ca info objects */
+ p_ca_infos = malloc(ca_count * sizeof(osm_ca_info_t));
+ if (p_ca_infos == NULL) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "osm_vendor_get_all_port_attr: ERR 5129: "
+ "Unable to allocate CA information array.\n");
+ goto Exit;
+ }
+
+ memset(p_ca_infos, 0, ca_count * sizeof(osm_ca_info_t));
+
+ /*
+ * For each CA, retrieve the CA info attributes
+ */
+ for (caIdx = 1; caIdx <= ca_count; caIdx++) {
+ status =
+ __osm_ca_info_init(p_vend, caIdx, &p_ca_infos[caIdx - 1]);
+ if (status != IB_SUCCESS) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "osm_vendor_get_all_port_attr: ERR 5130: "
+ "Unable to initialize CA Info object (%s).\n",
+ ib_get_err_str(status));
+ goto Exit;
+ }
+ total_ports += p_ca_infos[caIdx - 1].p_attr->num_ports;
+ }
+
+ *p_num_ports = total_ports;
+ osm_log(p_vend->p_log, OSM_LOG_DEBUG,
+ "osm_vendor_get_all_port_attr: total ports:%u \n", total_ports);
+
+ /*
+ * If the user supplied enough storage, return the port guids,
+ * otherwise, return the appropriate error.
+ */
+ if (attr_array_sz >= total_ports) {
+ for (caIdx = 1; caIdx <= ca_count; caIdx++) {
+ uint32_t num_ports;
+
+ num_ports = p_ca_infos[caIdx - 1].p_attr->num_ports;
+
+ for (port_num = 0; port_num < num_ports; port_num++) {
+ p_attr_array[port_count] =
+ *__osm_ca_info_get_port_attr_ptr(&p_ca_infos
+ [caIdx -
+ 1],
+ port_num);
+ port_count++;
+ }
+ }
+ } else {
+ status = IB_INSUFFICIENT_MEMORY;
+ goto Exit;
+ }
+
+ status = IB_SUCCESS;
+
+Exit:
+ if (p_ca_infos) {
+ osm_ca_info_destroy(p_vend, p_ca_infos, ca_count);
+ }
+
+ OSM_LOG_EXIT(p_vend->p_log);
+ return (status);
+}
+
+/**********************************************************************
+ * Given the vendor obj and a port guid
+ * return the ca id and port number that have that guid
+ **********************************************************************/
+
+ib_api_status_t
+osm_vendor_get_guid_ca_and_port(IN osm_vendor_t * const p_vend,
+ IN ib_net64_t const guid,
+ OUT uint32_t * p_hca_hndl,
+ OUT char *p_hca_id,
+ OUT uint8_t * p_hca_idx,
+ OUT uint32_t * p_port_num)
+{
+ uint32_t caIdx;
+ uint32_t ca_count = 0;
+ uint8_t port_num;
+ ib_api_status_t status = IB_ERROR;
+
+ OSM_LOG_ENTER(p_vend->p_log);
+
+ CL_ASSERT(p_vend);
+
+ /* determine the number of CA's */
+ ca_count = __hca_sim_get_num_cas();
+ if (!ca_count) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "osm_vendor_get_guid_ca_and_port: ERR 5131: "
+ "Fail to get Any CA Ids.\n");
+ goto Exit;
+ }
+
+ /*
+ * For each CA, retrieve the CA info attributes
+ */
+ for (caIdx = 1; caIdx <= ca_count; caIdx++) {
+ sim_ca_info_t sim_ca_info;
+ if (__parse_ca_info_file(p_vend, caIdx, &sim_ca_info) ==
+ IB_SUCCESS) {
+ /* get all the ports info */
+ for (port_num = 1; port_num <= sim_ca_info.num_ports;
+ port_num++) {
+ uint64_t port_guid;
+ if (!__get_port_guid_from_port_gid_tbl
+ (p_vend, caIdx, port_num, &port_guid)) {
+ if (cl_hton64(port_guid) == guid) {
+ osm_log(p_vend->p_log,
+ OSM_LOG_DEBUG,
+ "osm_vendor_get_guid_ca_and_port: "
+ "Found Matching guid on HCA:%d Port:%d.\n",
+ caIdx, port_num);
+ strcpy(p_hca_id,
+ sim_ca_info.name);
+ *p_port_num = port_num;
+ *p_hca_idx = caIdx - 1;
+ *p_hca_hndl = 0;
+ status = IB_SUCCESS;
+ goto Exit;
+ }
+ }
+ }
+ }
+ }
+
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "osm_vendor_get_guid_ca_and_port: ERR 5132: "
+ "Fail to find HCA and Port for Port Guid 0x%" PRIx64 "\n",
+ cl_ntoh64(guid));
+ status = IB_INVALID_GUID;
+
+Exit:
+
+ OSM_LOG_EXIT(p_vend->p_log);
+ return (status);
+}
+
+/**********************************************************************
+ * Given the vendor obj HCA ID and Port Num
+ * update the given port guid if found. Return 0 on success.
+ **********************************************************************/
+
+ib_api_status_t
+osm_vendor_get_guid_by_ca_and_port(IN osm_vendor_t * const p_vend,
+ IN char *hca_id,
+ IN uint32_t port_num,
+ OUT uint64_t * p_port_guid)
+{
+ uint32_t caIdx;
+ uint32_t ca_count = 0;
+ ib_api_status_t status = IB_ERROR;
+
+ OSM_LOG_ENTER(p_vend->p_log);
+
+ CL_ASSERT(p_vend);
+
+ /* determine the number of CA's */
+ ca_count = __hca_sim_get_num_cas();
+ if (!ca_count) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "osm_vendor_get_guid_by_ca_and_port: ERR 5133: "
+ "Fail to get Any CA Ids.\n");
+ goto Exit;
+ }
+
+ /*
+ * For each CA, retrieve the CA info attributes
+ */
+ for (caIdx = 1; caIdx <= ca_count; caIdx++) {
+ sim_ca_info_t sim_ca_info;
+ if (__parse_ca_info_file(p_vend, caIdx, &sim_ca_info) ==
+ IB_SUCCESS) {
+ /* if not identical by id - go to next one */
+ if (strcmp(sim_ca_info.name, hca_id))
+ continue;
+
+ if ((port_num < 1)
+ || (port_num > sim_ca_info.num_ports)) {
+ return 1;
+ }
+
+ if (!__get_port_guid_from_port_gid_tbl
+ (p_vend, caIdx, port_num, p_port_guid)) {
+ osm_log(p_vend->p_log, OSM_LOG_DEBUG,
+ "osm_vendor_get_guid_by_ca_and_port: "
+ "Found Matching guid on HCA:%d Port:%d.\n",
+ caIdx, port_num);
+ status = IB_SUCCESS;
+ goto Exit;
+ }
+ }
+ }
+
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "osm_vendor_get_guid_by_ca_and_port: ERR 5134: "
+ "Fail to find HCA:%s\n", hca_id);
+ status = IB_INVALID_GUID;
+
+Exit:
+
+ OSM_LOG_EXIT(p_vend->p_log);
+ return (status);
+}
+
+#endif
diff --git a/contrib/ofed/management/opensm/libvendor/osm_vendor_mlx_ibmgt.c b/contrib/ofed/opensm/libvendor/osm_vendor_mlx_ibmgt.c
index 9df6624..9df6624 100644
--- a/contrib/ofed/management/opensm/libvendor/osm_vendor_mlx_ibmgt.c
+++ b/contrib/ofed/opensm/libvendor/osm_vendor_mlx_ibmgt.c
diff --git a/contrib/ofed/opensm/libvendor/osm_vendor_mlx_rmpp_ctx.c b/contrib/ofed/opensm/libvendor/osm_vendor_mlx_rmpp_ctx.c
new file mode 100644
index 0000000..f59620e
--- /dev/null
+++ b/contrib/ofed/opensm/libvendor/osm_vendor_mlx_rmpp_ctx.c
@@ -0,0 +1,361 @@
+/*
+ * Copyright (c) 2004-2008 Voltaire, Inc. All rights reserved.
+ * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved.
+ * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+#if HAVE_CONFIG_H
+# include <config.h>
+#endif /* HAVE_CONFIG_H */
+
+#include <stdlib.h>
+#include <string.h>
+#include <iba/ib_types.h>
+#include <complib/cl_qlist.h>
+
+#include <vendor/osm_vendor_mlx_rmpp_ctx.h>
+#include <vendor/osm_vendor_mlx_svc.h>
+
+ib_api_status_t
+osmv_rmpp_send_ctx_init(osmv_rmpp_send_ctx_t * p_ctx, void *p_arbt_mad,
+ uint32_t mad_sz, osm_log_t * p_log)
+{
+ ib_api_status_t st = IB_SUCCESS;
+ cl_status_t cl_st;
+
+ CL_ASSERT(p_ctx);
+ if (NULL == p_arbt_mad) {
+ return IB_INVALID_PARAMETER;
+ }
+
+ if (osmv_mad_is_sa((ib_mad_t *) p_arbt_mad)) {
+ p_ctx->is_sa_mad = TRUE;
+ } else
+ p_ctx->is_sa_mad = FALSE;
+
+ p_ctx->mad_sz = mad_sz;
+
+ cl_event_construct(&p_ctx->event);
+ cl_st = cl_event_init(&p_ctx->event, FALSE);
+ if (cl_st != CL_SUCCESS) {
+ return IB_ERROR;
+ }
+
+ st = osmv_rmpp_sar_init(&p_ctx->sar, p_arbt_mad, p_ctx->mad_sz,
+ p_ctx->is_sa_mad);
+ if (st == IB_SUCCESS) {
+ p_ctx->window_first = 1;
+ p_ctx->window_last = 1;
+ }
+
+ p_ctx->p_log = p_log;
+ return st;
+}
+
+void osmv_rmpp_send_ctx_done(IN osmv_rmpp_send_ctx_t * p_ctx)
+{
+ CL_ASSERT(p_ctx);
+ cl_event_destroy(&p_ctx->event);
+ osmv_rmpp_sar_done(&p_ctx->sar);
+ free(p_ctx);
+}
+
+uint32_t osmv_rmpp_send_ctx_get_num_segs(IN osmv_rmpp_send_ctx_t * p_send_ctx)
+{
+ uint32_t data_len, data_sz, num;
+
+ CL_ASSERT(p_send_ctx);
+
+ if (p_send_ctx->is_sa_mad) {
+ data_len = p_send_ctx->mad_sz - IB_SA_MAD_HDR_SIZE;
+ data_sz = IB_SA_DATA_SIZE;
+ } else {
+ data_len = p_send_ctx->mad_sz - MAD_RMPP_HDR_SIZE;
+ data_sz = MAD_RMPP_DATA_SIZE;
+ }
+
+ num = data_len / data_sz;
+ if (0 == data_len || (data_len % data_sz) > 0) {
+ num++;
+ }
+
+ return num;
+}
+
+ib_api_status_t
+osmv_rmpp_send_ctx_get_seg(IN osmv_rmpp_send_ctx_t * p_send_ctx,
+ IN uint32_t seg_idx,
+ IN uint32_t resp_timeout, OUT void *p_buf)
+{
+ ib_api_status_t st = IB_SUCCESS;
+ uint32_t num_segs, paylen = 0;
+ ib_rmpp_mad_t *p_rmpp_mad;
+
+ OSM_LOG_ENTER(p_send_ctx->p_log);
+ CL_ASSERT(p_send_ctx);
+
+ st = osmv_rmpp_sar_get_mad_seg(&p_send_ctx->sar, seg_idx, p_buf);
+ if (st != IB_SUCCESS) {
+ goto Exit;
+ }
+
+ p_rmpp_mad = (ib_rmpp_mad_t *) p_buf;
+ /* Set the relevant bits in the RMPP hdr */
+ p_rmpp_mad->rmpp_status = IB_RMPP_STATUS_SUCCESS;
+ p_rmpp_mad->rmpp_flags |= IB_RMPP_FLAG_ACTIVE;
+ p_rmpp_mad->rmpp_flags |= resp_timeout << 3;
+
+ num_segs = osmv_rmpp_send_ctx_get_num_segs(p_send_ctx);
+
+ if (1 == seg_idx) {
+ p_rmpp_mad->rmpp_flags |= IB_RMPP_FLAG_FIRST;
+
+ /* This is the first segment -
+ the reported paylen is the total amount of data.
+ */
+ if (p_send_ctx->is_sa_mad) {
+ /* sa mad hdr sz */
+ paylen = p_send_ctx->mad_sz - IB_SA_MAD_HDR_SIZE;
+ paylen +=
+ num_segs * (IB_SA_MAD_HDR_SIZE - MAD_RMPP_HDR_SIZE);
+ } else {
+ /* mad hdr sz */
+ paylen = p_send_ctx->mad_sz - MAD_RMPP_HDR_SIZE;
+ }
+ }
+
+ if (seg_idx == num_segs) {
+ p_rmpp_mad->rmpp_flags |= IB_RMPP_FLAG_LAST;
+
+ /*
+ This is the last segment -
+ the reported paylen is only the amount of data left on this segment.
+ */
+ if (p_send_ctx->is_sa_mad) {
+ paylen = p_send_ctx->mad_sz - IB_SA_MAD_HDR_SIZE;
+ paylen -= (num_segs - 1) * IB_SA_DATA_SIZE;
+ paylen += (IB_SA_MAD_HDR_SIZE - MAD_RMPP_HDR_SIZE);
+ } else {
+ paylen = p_send_ctx->mad_sz - MAD_RMPP_HDR_SIZE;
+ paylen -=
+ (num_segs - 1) * (MAD_BLOCK_SIZE -
+ MAD_RMPP_HDR_SIZE);
+ }
+ }
+
+ p_rmpp_mad->rmpp_type = IB_RMPP_TYPE_DATA;
+ p_rmpp_mad->rmpp_version = 1;
+ p_rmpp_mad->paylen_newwin = cl_ntoh32(paylen);
+ p_rmpp_mad->seg_num = cl_ntoh32(seg_idx);
+
+Exit:
+ OSM_LOG_EXIT(p_send_ctx->p_log);
+ return st;
+}
+
+ib_api_status_t
+osmv_rmpp_recv_ctx_init(osmv_rmpp_recv_ctx_t * p_ctx, osm_log_t * p_log)
+{
+ ib_api_status_t st = IB_SUCCESS;
+
+ CL_ASSERT(p_ctx);
+
+ p_ctx->is_sa_mad = FALSE;
+
+ p_ctx->p_rbuf = malloc(sizeof(cl_qlist_t));
+ if (p_ctx->p_rbuf) {
+ memset(p_ctx->p_rbuf, 0, sizeof(cl_qlist_t));
+ cl_qlist_init(p_ctx->p_rbuf);
+ p_ctx->expected_seg = 1;
+ } else
+ st = IB_INSUFFICIENT_MEMORY;
+
+ p_ctx->p_log = p_log;
+
+ return st;
+}
+
+void osmv_rmpp_recv_ctx_done(IN osmv_rmpp_recv_ctx_t * p_ctx)
+{
+ cl_list_item_t *p_list_item;
+ cl_list_obj_t *p_obj;
+
+ CL_ASSERT(p_ctx);
+
+ /* go over all the items in the list and remove them */
+ p_list_item = cl_qlist_remove_head(p_ctx->p_rbuf);
+ while (p_list_item != cl_qlist_end(p_ctx->p_rbuf)) {
+
+ p_obj = PARENT_STRUCT(p_list_item, cl_list_obj_t, list_item);
+
+ free(cl_qlist_obj(p_obj));
+ free(p_obj);
+
+ p_list_item = cl_qlist_remove_head(p_ctx->p_rbuf);
+ }
+
+ osmv_rmpp_sar_done(&p_ctx->sar);
+
+ free(p_ctx->p_rbuf);
+ free(p_ctx);
+}
+
+ib_api_status_t
+osmv_rmpp_recv_ctx_store_mad_seg(IN osmv_rmpp_recv_ctx_t * p_recv_ctx,
+ IN void *p_mad)
+{
+ cl_list_obj_t *p_obj = NULL;
+ void *p_list_mad;
+
+ OSM_LOG_ENTER(p_recv_ctx->p_log);
+
+ CL_ASSERT(p_recv_ctx);
+ p_list_mad = malloc(MAD_BLOCK_SIZE);
+ if (NULL == p_list_mad) {
+ return IB_INSUFFICIENT_MEMORY;
+ }
+ memset(p_list_mad, 0, MAD_BLOCK_SIZE);
+ memcpy(p_list_mad, p_mad, MAD_BLOCK_SIZE);
+
+ p_obj = malloc(sizeof(cl_list_obj_t));
+ if (NULL == p_obj) {
+ free(p_list_mad);
+ return IB_INSUFFICIENT_MEMORY;
+ }
+ memset(p_obj, 0, sizeof(cl_list_obj_t));
+ cl_qlist_set_obj(p_obj, p_list_mad);
+
+ cl_qlist_insert_tail(p_recv_ctx->p_rbuf, &p_obj->list_item);
+
+ if (osmv_mad_is_sa((ib_mad_t *) p_mad)) {
+ p_recv_ctx->is_sa_mad = TRUE;
+ }
+
+ return IB_SUCCESS;
+
+}
+
+uint32_t
+osmv_rmpp_recv_ctx_get_cur_byte_num(IN osmv_rmpp_recv_ctx_t * p_recv_ctx)
+{
+ uint32_t num_segs;
+
+ num_segs = cl_qlist_count(p_recv_ctx->p_rbuf);
+ if (p_recv_ctx->is_sa_mad)
+ return ((num_segs * IB_SA_DATA_SIZE) + IB_SA_MAD_HDR_SIZE);
+ else
+ return ((num_segs * MAD_RMPP_DATA_SIZE) + MAD_RMPP_HDR_SIZE);
+}
+
+uint32_t
+osmv_rmpp_recv_ctx_get_byte_num_from_first(IN osmv_rmpp_recv_ctx_t * p_recv_ctx)
+{
+ cl_list_item_t *p_item;
+ cl_list_obj_t *p_obj;
+ void *p_list_mad;
+ uint32_t num_bytes, num_segs;
+
+ p_item = cl_qlist_head(p_recv_ctx->p_rbuf);
+ p_obj = PARENT_STRUCT(p_item, cl_list_obj_t, list_item);
+ p_list_mad = cl_qlist_obj(p_obj);
+
+ /* mad data sz */
+ num_bytes = cl_ntoh32(((ib_rmpp_mad_t *) p_list_mad)->paylen_newwin);
+ if (0 != num_bytes) {
+ if (p_recv_ctx->is_sa_mad) {
+ /* sa mad hdr sz */
+ num_segs = cl_qlist_count(p_recv_ctx->p_rbuf);
+ num_bytes -=
+ num_segs * (IB_SA_MAD_HDR_SIZE - MAD_RMPP_HDR_SIZE);
+ num_bytes += IB_SA_MAD_HDR_SIZE;
+ } else {
+ /* mad hdr sz */
+ num_bytes += MAD_RMPP_HDR_SIZE;
+ }
+ }
+
+ return num_bytes;
+}
+
+uint32_t
+osmv_rmpp_recv_ctx_get_byte_num_from_last(IN osmv_rmpp_recv_ctx_t * p_recv_ctx)
+{
+ cl_list_item_t *p_item;
+ cl_list_obj_t *p_obj;
+ void *p_list_mad;
+ uint32_t num_bytes, num_segs;
+
+ p_item = cl_qlist_tail(p_recv_ctx->p_rbuf);
+ p_obj = PARENT_STRUCT(p_item, cl_list_obj_t, list_item);
+ p_list_mad = cl_qlist_obj(p_obj);
+
+ /* mad data sz */
+ num_segs = cl_qlist_count(p_recv_ctx->p_rbuf);
+ num_bytes = cl_ntoh32(((ib_rmpp_mad_t *) p_list_mad)->paylen_newwin);
+
+ if (0 != num_bytes) {
+ if (p_recv_ctx->is_sa_mad) {
+ /* sa mad hdr sz */
+ num_bytes += MAD_RMPP_HDR_SIZE;
+ num_bytes += (num_segs - 1) * IB_SA_DATA_SIZE;
+ } else {
+ /* mad hdr sz */
+ num_bytes += MAD_RMPP_HDR_SIZE;
+ num_bytes += (num_segs - 1) * MAD_RMPP_DATA_SIZE;
+ }
+ }
+
+ return num_bytes;
+}
+
+/* assuming that the last rmpp pkt arrived so that data member: total_bytes has the right value */
+ib_api_status_t
+osmv_rmpp_recv_ctx_reassemble_arbt_mad(IN osmv_rmpp_recv_ctx_t * p_recv_ctx,
+ IN uint32_t size, IN void *p_arbt_mad)
+{
+ ib_api_status_t st = IB_SUCCESS;
+
+ CL_ASSERT(p_recv_ctx);
+
+ st = osmv_rmpp_sar_init(&p_recv_ctx->sar, p_arbt_mad, size,
+ p_recv_ctx->is_sa_mad);
+ if (st != IB_SUCCESS) {
+ return st;
+ }
+
+ st = osmv_rmpp_sar_reassemble_arbt_mad(&p_recv_ctx->sar,
+ p_recv_ctx->p_rbuf);
+
+ osmv_rmpp_sar_done(&p_recv_ctx->sar);
+
+ return st;
+}
diff --git a/contrib/ofed/opensm/libvendor/osm_vendor_mlx_sa.c b/contrib/ofed/opensm/libvendor/osm_vendor_mlx_sa.c
new file mode 100644
index 0000000..bfc643e
--- /dev/null
+++ b/contrib/ofed/opensm/libvendor/osm_vendor_mlx_sa.c
@@ -0,0 +1,800 @@
+/*
+ * Copyright (c) 2004-2009 Voltaire, Inc. All rights reserved.
+ * Copyright (c) 2002-2005,2008 Mellanox Technologies LTD. All rights reserved.
+ * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
+ * Copyright (c) 2009,2010 HNR Consulting. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+#if HAVE_CONFIG_H
+# include <config.h>
+#endif /* HAVE_CONFIG_H */
+
+#include <stdlib.h>
+#include <string.h>
+#include <complib/cl_debug.h>
+#include <complib/cl_timer.h>
+#include <complib/cl_event.h>
+#include <vendor/osm_vendor_api.h>
+#include <vendor/osm_vendor_sa_api.h>
+
+/* this struct is the internal rep of the bind handle */
+typedef struct _osmv_sa_bind_info {
+ osm_bind_handle_t h_bind;
+ osm_log_t *p_log;
+ osm_vendor_t *p_vendor;
+ osm_mad_pool_t *p_mad_pool;
+ uint64_t port_guid;
+ cl_event_t sync_event;
+ uint64_t last_lids_update_sec;
+ uint16_t lid;
+ uint16_t sm_lid;
+} osmv_sa_bind_info_t;
+
+/*
+ Call back on new mad received:
+
+ We basically only need to set the context of the query.
+ Or report an error.
+
+ A pointer to the actual context of the request (a copy of the oriignal
+ request structure) is attached as the p_madw->context.ni_context.node_guid
+*/
+static void
+__osmv_sa_mad_rcv_cb(IN osm_madw_t * p_madw,
+ IN void *bind_context, IN osm_madw_t * p_req_madw)
+{
+ osmv_sa_bind_info_t *p_bind = (osmv_sa_bind_info_t *) bind_context;
+ osmv_query_req_t *p_query_req_copy = NULL;
+ osmv_query_res_t query_res;
+ ib_sa_mad_t *p_sa_mad;
+ ib_net16_t mad_status;
+
+ OSM_LOG_ENTER(p_bind->p_log);
+
+ if (!p_req_madw) {
+ OSM_LOG(p_bind->p_log, OSM_LOG_DEBUG,
+ "Ignoring a non-response mad\n");
+ osm_mad_pool_put(p_bind->p_mad_pool, p_madw);
+ goto Exit;
+ }
+
+ /* obtain the sent context */
+ p_query_req_copy =
+ (osmv_query_req_t *) (p_req_madw->context.arb_context.context1);
+
+ /* provide the context of the original request in the result */
+ query_res.query_context = p_query_req_copy->query_context;
+
+ /* provide the resulting madw */
+ query_res.p_result_madw = p_madw;
+
+ /* update the req fields */
+ p_sa_mad = (ib_sa_mad_t *) p_madw->p_mad;
+
+ /* if we got a remote error track it in the status */
+ mad_status = (ib_net16_t) (p_sa_mad->status & IB_SMP_STATUS_MASK);
+ if (mad_status != IB_SUCCESS) {
+ OSM_LOG(p_bind->p_log, OSM_LOG_ERROR, "ERR 0501: "
+ "Remote error:0x%04X\n", cl_ntoh16(mad_status));
+ query_res.status = IB_REMOTE_ERROR;
+ } else
+ query_res.status = IB_SUCCESS;
+
+ /* what if we have got back an empty mad ? */
+ if (!p_madw->mad_size) {
+ OSM_LOG(p_bind->p_log, OSM_LOG_ERROR, "ERR 0502: "
+ "Got an empty mad\n");
+ query_res.status = IB_ERROR;
+ }
+
+ if (IB_SUCCESS == mad_status) {
+
+ /* if we are in not in a method response of an rmpp nature we must get only 1 */
+ /* HACK: in the future we might need to be smarter for other methods... */
+ if (p_sa_mad->method != IB_MAD_METHOD_GETTABLE_RESP) {
+ query_res.result_cnt = 1;
+ } else {
+#ifndef VENDOR_RMPP_SUPPORT
+ if (mad_status != IB_SUCCESS)
+ query_res.result_cnt = 0;
+ else
+ query_res.result_cnt = 1;
+#else
+ /* we used the offset value to calculate the number of
+ records in here */
+ if (ib_get_attr_size(p_sa_mad->attr_offset) == 0) {
+ query_res.result_cnt = 0;
+ OSM_LOG(p_bind->p_log, OSM_LOG_DEBUG,
+ "Count = 0\n");
+ }
+ else {
+ query_res.result_cnt =
+ (p_madw->mad_size - IB_SA_MAD_HDR_SIZE) /
+ ib_get_attr_size(p_sa_mad->attr_offset);
+ OSM_LOG(p_bind->p_log, OSM_LOG_DEBUG,
+ "Count = %u = %zu / %u (%zu)\n",
+ query_res.result_cnt,
+ p_madw->mad_size - IB_SA_MAD_HDR_SIZE,
+ ib_get_attr_size(p_sa_mad->attr_offset),
+ (p_madw->mad_size - IB_SA_MAD_HDR_SIZE) %
+ ib_get_attr_size(p_sa_mad->attr_offset));
+ }
+#endif
+ }
+ }
+
+ query_res.query_type = p_query_req_copy->query_type;
+
+ p_query_req_copy->pfn_query_cb(&query_res);
+
+ if ((p_query_req_copy->flags & OSM_SA_FLAGS_SYNC) == OSM_SA_FLAGS_SYNC)
+ cl_event_signal(&p_bind->sync_event);
+
+Exit:
+
+ /* free the copied query request if found */
+ if (p_query_req_copy)
+ free(p_query_req_copy);
+
+ /* put back the request madw */
+ if (p_req_madw)
+ osm_mad_pool_put(p_bind->p_mad_pool, p_req_madw);
+
+ OSM_LOG_EXIT(p_bind->p_log);
+}
+
+/*
+ Send Error Callback:
+
+ Only report the error and get rid of the mad wrapper
+*/
+static void __osmv_sa_mad_err_cb(IN void *bind_context, IN osm_madw_t * p_madw)
+{
+ osmv_sa_bind_info_t *p_bind = (osmv_sa_bind_info_t *) bind_context;
+ osmv_query_req_t *p_query_req_copy = NULL;
+ osmv_query_res_t query_res;
+
+ OSM_LOG_ENTER(p_bind->p_log);
+
+ /* Obtain the sent context etc */
+ p_query_req_copy =
+ (osmv_query_req_t *) (p_madw->context.arb_context.context1);
+
+ /* provide the context of the original request in the result */
+ query_res.query_context = p_query_req_copy->query_context;
+
+ query_res.p_result_madw = p_madw;
+
+ query_res.status = IB_TIMEOUT;
+ query_res.result_cnt = 0;
+ query_res.p_result_madw->status = IB_TIMEOUT;
+ p_madw->status = IB_TIMEOUT;
+ query_res.query_type = p_query_req_copy->query_type;
+
+ p_query_req_copy->pfn_query_cb(&query_res);
+
+ if ((p_query_req_copy->flags & OSM_SA_FLAGS_SYNC) == OSM_SA_FLAGS_SYNC)
+ cl_event_signal(&p_bind->sync_event);
+
+ free(p_query_req_copy);
+ OSM_LOG_EXIT(p_bind->p_log);
+}
+
+/*****************************************************************************
+ This routine needs to be invoked on every send - since the SM LID and Local
+ lid might change. To do that without any major perfoermance impact we cache
+ the results and time they were obtained. Refresh only twice a minute.
+ To avoid the need to use statics and risk a race - we require the refresh time
+ to be stored in the context of the results. Also this coveres cases were
+ we query for multiple guids.
+ *****************************************************************************/
+static ib_api_status_t
+__osmv_get_lid_and_sm_lid_by_port_guid(IN osm_vendor_t * const p_vend,
+ IN ib_net64_t port_guid,
+ IN OUT uint64_t * p_lids_update_time_sec,
+ OUT uint16_t * lid,
+ OUT uint16_t * sm_lid)
+{
+
+ ib_api_status_t status;
+ ib_port_attr_t *p_attr_array;
+ uint32_t num_ports;
+ uint32_t port_num;
+
+ OSM_LOG_ENTER(p_vend->p_log);
+
+ /* use prevous values if current time is close enough to previous query */
+ if (cl_get_time_stamp_sec() <= *p_lids_update_time_sec + 30) {
+ OSM_LOG(p_vend->p_log, OSM_LOG_DEBUG,
+ "Using previously stored lid:0x%04x sm_lid:0x%04x\n",
+ *lid, *sm_lid);
+ status = IB_SUCCESS;
+ goto Exit;
+ }
+
+ /* obtain the number of available ports */
+ num_ports = 0;
+ status = osm_vendor_get_all_port_attr(p_vend, NULL, &num_ports);
+ if (status != IB_INSUFFICIENT_MEMORY) {
+ OSM_LOG(p_vend->p_log, OSM_LOG_ERROR, "ERR 0503: "
+ "Expected to get the IB_INSUFFICIENT_MEMORY but got: %s\n",
+ ib_get_err_str(status));
+ status = IB_ERROR;
+ goto Exit;
+ }
+
+ OSM_LOG(p_vend->p_log, OSM_LOG_DEBUG,
+ "Found total of %u ports. Looking for guid:0x%016" PRIx64 "\n",
+ num_ports, cl_ntoh64(port_guid));
+
+ /* allocate the attributes */
+ p_attr_array =
+ (ib_port_attr_t *) malloc(sizeof(ib_port_attr_t) * num_ports);
+
+ /* obtain the attributes */
+ status = osm_vendor_get_all_port_attr(p_vend, p_attr_array, &num_ports);
+ if (status != IB_SUCCESS) {
+ OSM_LOG(p_vend->p_log, OSM_LOG_ERROR, "ERR 0504: "
+ "Failed to get port attributes (error: %s)\n",
+ ib_get_err_str(status));
+ free(p_attr_array);
+ goto Exit;
+ }
+
+ status = IB_ERROR;
+ /* find the port requested in the list */
+ for (port_num = 0; (port_num < num_ports) && (status == IB_ERROR);
+ port_num++) {
+ if (p_attr_array[port_num].port_guid == port_guid) {
+ *lid = p_attr_array[port_num].lid;
+ *sm_lid = p_attr_array[port_num].sm_lid;
+ *p_lids_update_time_sec = cl_get_time_stamp_sec();
+ status = IB_SUCCESS;
+ OSM_LOG(p_vend->p_log, OSM_LOG_DEBUG,
+ "Found guid:0x%016" PRIx64 " with idx:%d\n",
+ cl_ntoh64(port_guid), port_num);
+ }
+ }
+
+ free(p_attr_array);
+
+Exit:
+ OSM_LOG_EXIT(p_vend->p_log);
+ return (status);
+}
+
+osm_bind_handle_t
+osmv_bind_sa(IN osm_vendor_t * const p_vend,
+ IN osm_mad_pool_t * const p_mad_pool, IN ib_net64_t port_guid)
+{
+ osm_bind_info_t bind_info;
+ osm_log_t *p_log = p_vend->p_log;
+ ib_api_status_t status = IB_SUCCESS;
+ osmv_sa_bind_info_t *p_sa_bind_info;
+ cl_status_t cl_status;
+
+ OSM_LOG_ENTER(p_log);
+
+ OSM_LOG(p_log, OSM_LOG_DEBUG,
+ "Binding to port 0x%" PRIx64 "\n", cl_ntoh64(port_guid));
+
+ bind_info.port_guid = port_guid;
+ bind_info.mad_class = IB_MCLASS_SUBN_ADM;
+ bind_info.class_version = 2;
+ bind_info.is_responder = FALSE;
+ bind_info.is_trap_processor = FALSE;
+ bind_info.is_report_processor = FALSE;
+ bind_info.send_q_size = 256;
+ bind_info.recv_q_size = 256;
+
+ /* allocate the new sa bind info */
+ p_sa_bind_info =
+ (osmv_sa_bind_info_t *) malloc(sizeof(osmv_sa_bind_info_t));
+ if (!p_sa_bind_info) {
+ OSM_LOG(p_log, OSM_LOG_ERROR, "ERR 0505: "
+ "Failed to allocate new bind structure\n");
+ p_sa_bind_info = OSM_BIND_INVALID_HANDLE;
+ goto Exit;
+ }
+
+ /* store some important context */
+ p_sa_bind_info->p_log = p_log;
+ p_sa_bind_info->port_guid = port_guid;
+ p_sa_bind_info->p_mad_pool = p_mad_pool;
+ p_sa_bind_info->p_vendor = p_vend;
+ p_sa_bind_info->last_lids_update_sec = 0;
+
+ /* Bind to the lower level */
+ p_sa_bind_info->h_bind = osm_vendor_bind(p_vend, &bind_info, p_mad_pool, __osmv_sa_mad_rcv_cb, __osmv_sa_mad_err_cb, p_sa_bind_info); /* context provided to CBs */
+
+ if (p_sa_bind_info->h_bind == OSM_BIND_INVALID_HANDLE) {
+ free(p_sa_bind_info);
+ p_sa_bind_info = OSM_BIND_INVALID_HANDLE;
+ OSM_LOG(p_log, OSM_LOG_ERROR, "ERR 0506: "
+ "Failed to bind to vendor GSI\n");
+ goto Exit;
+ }
+
+ /* obtain the sm_lid from the vendor */
+ status =
+ __osmv_get_lid_and_sm_lid_by_port_guid(p_vend, port_guid,
+ &p_sa_bind_info->
+ last_lids_update_sec,
+ &p_sa_bind_info->lid,
+ &p_sa_bind_info->sm_lid);
+ if (status != IB_SUCCESS) {
+ free(p_sa_bind_info);
+ p_sa_bind_info = OSM_BIND_INVALID_HANDLE;
+ OSM_LOG(p_log, OSM_LOG_ERROR, "ERR 0507: "
+ "Failed to obtain the SM lid\n");
+ goto Exit;
+ }
+
+ /* initialize the sync_event */
+ cl_event_construct(&p_sa_bind_info->sync_event);
+ cl_status = cl_event_init(&p_sa_bind_info->sync_event, TRUE);
+ if (cl_status != CL_SUCCESS) {
+ OSM_LOG(p_log, OSM_LOG_ERROR, "ERR 0508: "
+ "cl_init_event failed: %s\n", ib_get_err_str(cl_status));
+ free(p_sa_bind_info);
+ p_sa_bind_info = OSM_BIND_INVALID_HANDLE;
+ }
+
+Exit:
+ OSM_LOG_EXIT(p_log);
+ return (p_sa_bind_info);
+}
+
+/****t* OSM Vendor SA Client/osmv_sa_mad_data
+ * NAME
+ * osmv_sa_mad_data
+ *
+ * DESCRIPTION
+ * Extra fields required to perform a mad query
+ * This struct is passed to the actual send method
+ *
+ * SYNOPSIS
+ */
+typedef struct _osmv_sa_mad_data {
+ /* MAD data. */
+ uint8_t method;
+ ib_net16_t attr_id;
+ ib_net16_t attr_offset;
+ ib_net32_t attr_mod;
+ ib_net64_t comp_mask;
+ void *p_attr;
+} osmv_sa_mad_data_t;
+/*
+ * method
+ * The method of the mad to be sent
+ *
+ * attr_id
+ * Attribute ID
+ *
+ * attr_offset
+ * Offset as defined by RMPP
+ *
+ * attr_mod
+ * Attribute modifier
+ *
+ * comp_mask
+ * The component mask of the query
+ *
+ * p_attr
+ * A pointer to the record of the attribute to be sent.
+ *
+ *****/
+
+/* Send a MAD out on the GSI interface */
+static ib_api_status_t
+__osmv_send_sa_req(IN osmv_sa_bind_info_t * p_bind,
+ IN const osmv_sa_mad_data_t * const p_sa_mad_data,
+ IN const osmv_query_req_t * const p_query_req)
+{
+ ib_api_status_t status;
+ ib_mad_t *p_mad_hdr;
+ ib_sa_mad_t *p_sa_mad;
+ osm_madw_t *p_madw;
+ osm_log_t *p_log = p_bind->p_log;
+ static atomic32_t trans_id;
+ boolean_t sync;
+ osmv_query_req_t *p_query_req_copy;
+ uint32_t sa_size;
+
+ OSM_LOG_ENTER(p_log);
+
+ /*
+ since the sm_lid might change we obtain it every send
+ (actually it is cached in the bind object and refreshed
+ every 30sec by this proc)
+ */
+ status =
+ __osmv_get_lid_and_sm_lid_by_port_guid(p_bind->p_vendor,
+ p_bind->port_guid,
+ &p_bind->
+ last_lids_update_sec,
+ &p_bind->lid,
+ &p_bind->sm_lid);
+ if (status != IB_SUCCESS) {
+ OSM_LOG(p_log, OSM_LOG_ERROR, "ERR 0509: "
+ "Failed to obtain the SM lid\n");
+ goto Exit;
+ }
+
+ /* Get a MAD wrapper for the send */
+ p_madw = osm_mad_pool_get(p_bind->p_mad_pool,
+ p_bind->h_bind, MAD_BLOCK_SIZE, NULL);
+
+ if (p_madw == NULL) {
+ OSM_LOG(p_log, OSM_LOG_ERROR, "ERR 0510: "
+ "Unable to acquire MAD\n");
+ status = IB_INSUFFICIENT_RESOURCES;
+ goto Exit;
+ }
+
+ /* Initialize the Sent MAD: */
+
+ /* Initialize the MAD buffer for the send operation. */
+ p_mad_hdr = osm_madw_get_mad_ptr(p_madw);
+ p_sa_mad = osm_madw_get_sa_mad_ptr(p_madw);
+
+ /* Get a new transaction Id */
+ cl_atomic_inc(&trans_id);
+
+ /* Cleanup the MAD from any residue */
+ memset(p_sa_mad, 0, MAD_BLOCK_SIZE);
+
+ /* Initialize the standard MAD header. */
+ ib_mad_init_new(p_mad_hdr, /* mad pointer */
+ IB_MCLASS_SUBN_ADM, /* class */
+ (uint8_t) 2, /* version */
+ p_sa_mad_data->method, /* method */
+ cl_hton64((uint64_t) trans_id), /* tid */
+ p_sa_mad_data->attr_id, /* attr id */
+ p_sa_mad_data->attr_mod /* attr mod */);
+
+ /* Set the query information. */
+ p_sa_mad->sm_key = p_query_req->sm_key;
+ p_sa_mad->attr_offset = 0;
+ p_sa_mad->comp_mask = p_sa_mad_data->comp_mask;
+ if (p_sa_mad->comp_mask) {
+ p_sa_mad_data->attr_offset ? (sa_size = ib_get_attr_size(p_sa_mad_data->attr_offset)) : (sa_size = IB_SA_DATA_SIZE);
+ memcpy(p_sa_mad->data, p_sa_mad_data->p_attr, sa_size);
+ }
+
+ /*
+ Provide the address to send to
+ */
+ /* Patch to handle IBAL - host order , where it should take destination lid in network order */
+#ifdef OSM_VENDOR_INTF_AL
+ p_madw->mad_addr.dest_lid = p_bind->sm_lid;
+#else
+ p_madw->mad_addr.dest_lid = cl_hton16(p_bind->sm_lid);
+#endif
+ p_madw->mad_addr.addr_type.smi.source_lid = cl_hton16(p_bind->lid);
+ p_madw->mad_addr.addr_type.gsi.remote_qp = CL_HTON32(1);
+ p_madw->resp_expected = TRUE;
+ p_madw->fail_msg = CL_DISP_MSGID_NONE;
+
+ /*
+ Provide MAD context such that the call back will know what to do.
+ We have to keep the entire request structure so we know the CB.
+ Since we can not rely on the client to keep it around until
+ the response - we duplicate it and will later dispose it (in CB).
+ To store on the MADW we cast it into what opensm has:
+ p_madw->context.arb_context.context1
+ */
+ p_query_req_copy = malloc(sizeof(*p_query_req_copy));
+ if (!p_query_req_copy) {
+ OSM_LOG(p_log, OSM_LOG_ERROR, "ERR 0511: "
+ "Unable to acquire memory for query copy\n");
+ osm_mad_pool_put(p_bind->p_mad_pool, p_madw);
+ status = IB_INSUFFICIENT_RESOURCES;
+ goto Exit;
+ }
+ *p_query_req_copy = *p_query_req;
+ p_madw->context.arb_context.context1 = p_query_req_copy;
+
+ /* we can support async as well as sync calls */
+ sync = ((p_query_req->flags & OSM_SA_FLAGS_SYNC) == OSM_SA_FLAGS_SYNC);
+
+ /* send the mad asynchronously */
+ status = osm_vendor_send(osm_madw_get_bind_handle(p_madw),
+ p_madw, p_madw->resp_expected);
+
+ /* if synchronous - wait on the event */
+ if (sync) {
+ OSM_LOG(p_log, OSM_LOG_DEBUG, "Waiting for async event\n");
+ cl_event_wait_on(&p_bind->sync_event, EVENT_NO_TIMEOUT, FALSE);
+ cl_event_reset(&p_bind->sync_event);
+ status = p_madw->status;
+ }
+
+Exit:
+ OSM_LOG_EXIT(p_log);
+ return status;
+}
+
+/*
+ * Query the SA based on the user's request.
+ */
+ib_api_status_t
+osmv_query_sa(IN osm_bind_handle_t h_bind,
+ IN const osmv_query_req_t * const p_query_req)
+{
+ union {
+ ib_service_record_t svc_rec;
+ ib_node_record_t node_rec;
+ ib_portinfo_record_t port_info;
+ ib_path_rec_t path_rec;
+#ifdef DUAL_SIDED_RMPP
+ ib_multipath_rec_t multipath_rec;
+#endif
+ ib_class_port_info_t class_port_info;
+ } u;
+ osmv_sa_mad_data_t sa_mad_data;
+ osmv_sa_bind_info_t *p_bind = (osmv_sa_bind_info_t *) h_bind;
+ osmv_user_query_t *p_user_query;
+#ifdef DUAL_SIDED_RMPP
+ osmv_multipath_req_t *p_mpr_req;
+ int i, j;
+#endif
+ osm_log_t *p_log = p_bind->p_log;
+ ib_api_status_t status;
+
+ OSM_LOG_ENTER(p_log);
+
+ /* Set the request information. */
+ sa_mad_data.method = IB_MAD_METHOD_GETTABLE;
+ sa_mad_data.attr_mod = 0;
+ sa_mad_data.attr_offset = 0;
+
+ /* Set the MAD attributes and component mask correctly. */
+ switch (p_query_req->query_type) {
+
+ case OSMV_QUERY_USER_DEFINED:
+ OSM_LOG(p_log, OSM_LOG_DEBUG, "DBG:001 USER_DEFINED\n");
+ p_user_query = (osmv_user_query_t *) p_query_req->p_query_input;
+ if (p_user_query->method)
+ sa_mad_data.method = p_user_query->method;
+#ifdef DUAL_SIDED_RMPP
+ if (sa_mad_data.method == IB_MAD_METHOD_GETMULTI ||
+ sa_mad_data.method == IB_MAD_METHOD_GETTRACETABLE)
+ sa_mad_data.attr_offset = p_user_query->attr_offset;
+#endif
+ sa_mad_data.attr_id = p_user_query->attr_id;
+ sa_mad_data.attr_mod = p_user_query->attr_mod;
+ sa_mad_data.comp_mask = p_user_query->comp_mask;
+ sa_mad_data.p_attr = p_user_query->p_attr;
+ break;
+
+ case OSMV_QUERY_ALL_SVC_RECS:
+ OSM_LOG(p_log, OSM_LOG_DEBUG, "DBG:001 SVC_REC_BY_NAME\n");
+ sa_mad_data.attr_id = IB_MAD_ATTR_SERVICE_RECORD;
+ sa_mad_data.comp_mask = 0;
+ sa_mad_data.p_attr = &u.svc_rec;
+ break;
+
+ case OSMV_QUERY_SVC_REC_BY_NAME:
+ OSM_LOG(p_log, OSM_LOG_DEBUG, "DBG:001 SVC_REC_BY_NAME\n");
+ sa_mad_data.method = IB_MAD_METHOD_GET;
+ sa_mad_data.attr_id = IB_MAD_ATTR_SERVICE_RECORD;
+ sa_mad_data.comp_mask = IB_SR_COMPMASK_SNAME;
+ sa_mad_data.p_attr = &u.svc_rec;
+ memcpy(u.svc_rec.service_name, p_query_req->p_query_input,
+ sizeof(ib_svc_name_t));
+ break;
+
+ case OSMV_QUERY_SVC_REC_BY_ID:
+ OSM_LOG(p_log, OSM_LOG_DEBUG, "DBG:001 SVC_REC_BY_ID\n");
+ sa_mad_data.attr_id = IB_MAD_ATTR_SERVICE_RECORD;
+ sa_mad_data.comp_mask = IB_SR_COMPMASK_SID;
+ sa_mad_data.p_attr = &u.svc_rec;
+ u.svc_rec.service_id =
+ *(ib_net64_t *) (p_query_req->p_query_input);
+ break;
+
+ case OSMV_QUERY_CLASS_PORT_INFO:
+ OSM_LOG(p_log, OSM_LOG_DEBUG, "DBG:001 CLASS_PORT_INFO\n");
+ sa_mad_data.method = IB_MAD_METHOD_GET;
+ sa_mad_data.attr_id = IB_MAD_ATTR_CLASS_PORT_INFO;
+ sa_mad_data.comp_mask = 0;
+ sa_mad_data.p_attr = &u.class_port_info;
+ break;
+
+ case OSMV_QUERY_NODE_REC_BY_NODE_GUID:
+ OSM_LOG(p_log, OSM_LOG_DEBUG, "DBG:001 NODE_REC_BY_NODE_GUID\n");
+ sa_mad_data.attr_id = IB_MAD_ATTR_NODE_RECORD;
+ sa_mad_data.comp_mask = IB_NR_COMPMASK_NODEGUID;
+ sa_mad_data.p_attr = &u.node_rec;
+ u.node_rec.node_info.node_guid =
+ *(ib_net64_t *) (p_query_req->p_query_input);
+ break;
+
+ case OSMV_QUERY_PORT_REC_BY_LID:
+ OSM_LOG(p_log, OSM_LOG_DEBUG, "DBG:001 PORT_REC_BY_LID\n");
+ sa_mad_data.attr_id = IB_MAD_ATTR_PORTINFO_RECORD;
+ sa_mad_data.comp_mask = IB_PIR_COMPMASK_LID;
+ sa_mad_data.p_attr = &u.port_info;
+ u.port_info.lid = *(ib_net16_t *) (p_query_req->p_query_input);
+ break;
+
+ case OSMV_QUERY_PORT_REC_BY_LID_AND_NUM:
+ sa_mad_data.method = IB_MAD_METHOD_GET;
+ p_user_query = (osmv_user_query_t *) p_query_req->p_query_input;
+ OSM_LOG(p_log, OSM_LOG_DEBUG, "DBG:001 PORT_REC_BY_LID_AND_NUM\n");
+ sa_mad_data.attr_id = IB_MAD_ATTR_PORTINFO_RECORD;
+ sa_mad_data.comp_mask =
+ IB_PIR_COMPMASK_LID | IB_PIR_COMPMASK_PORTNUM;
+ sa_mad_data.p_attr = p_user_query->p_attr;
+ break;
+
+ case OSMV_QUERY_VLARB_BY_LID_PORT_BLOCK:
+ sa_mad_data.method = IB_MAD_METHOD_GET;
+ p_user_query = (osmv_user_query_t *) p_query_req->p_query_input;
+ OSM_LOG(p_log, OSM_LOG_DEBUG, "DBG:001 OSMV_QUERY_VLARB_BY_LID_PORT_BLOCK\n");
+ sa_mad_data.attr_id = IB_MAD_ATTR_VLARB_RECORD;
+ sa_mad_data.comp_mask =
+ IB_VLA_COMPMASK_LID | IB_VLA_COMPMASK_OUT_PORT |
+ IB_VLA_COMPMASK_BLOCK;
+ sa_mad_data.p_attr = p_user_query->p_attr;
+ break;
+
+ case OSMV_QUERY_SLVL_BY_LID_AND_PORTS:
+ sa_mad_data.method = IB_MAD_METHOD_GET;
+ p_user_query = (osmv_user_query_t *) p_query_req->p_query_input;
+ OSM_LOG(p_log, OSM_LOG_DEBUG, "DBG:001 OSMV_QUERY_VLARB_BY_LID_PORT_BLOCK\n");
+ sa_mad_data.attr_id = IB_MAD_ATTR_SLVL_RECORD;
+ sa_mad_data.comp_mask =
+ IB_SLVL_COMPMASK_LID | IB_SLVL_COMPMASK_OUT_PORT |
+ IB_SLVL_COMPMASK_IN_PORT;
+ sa_mad_data.p_attr = p_user_query->p_attr;
+ break;
+
+ case OSMV_QUERY_PATH_REC_BY_PORT_GUIDS:
+ OSM_LOG(p_log, OSM_LOG_DEBUG, "DBG:001 PATH_REC_BY_PORT_GUIDS\n");
+ memset(&u.path_rec, 0, sizeof(ib_path_rec_t));
+ sa_mad_data.attr_id = IB_MAD_ATTR_PATH_RECORD;
+ sa_mad_data.comp_mask =
+ (IB_PR_COMPMASK_DGID | IB_PR_COMPMASK_SGID | IB_PR_COMPMASK_NUMBPATH);
+ u.path_rec.num_path = 0x7f;
+ sa_mad_data.p_attr = &u.path_rec;
+ ib_gid_set_default(&u.path_rec.dgid,
+ ((osmv_guid_pair_t *) (p_query_req->
+ p_query_input))->
+ dest_guid);
+ ib_gid_set_default(&u.path_rec.sgid,
+ ((osmv_guid_pair_t *) (p_query_req->
+ p_query_input))->
+ src_guid);
+ break;
+
+ case OSMV_QUERY_PATH_REC_BY_GIDS:
+ OSM_LOG(p_log, OSM_LOG_DEBUG, "DBG:001 PATH_REC_BY_GIDS\n");
+ memset(&u.path_rec, 0, sizeof(ib_path_rec_t));
+ sa_mad_data.attr_id = IB_MAD_ATTR_PATH_RECORD;
+ sa_mad_data.comp_mask =
+ (IB_PR_COMPMASK_DGID | IB_PR_COMPMASK_SGID | IB_PR_COMPMASK_NUMBPATH);
+ u.path_rec.num_path = 0x7f;
+ sa_mad_data.p_attr = &u.path_rec;
+ memcpy(&u.path_rec.dgid,
+ &((osmv_gid_pair_t *) (p_query_req->p_query_input))->
+ dest_gid, sizeof(ib_gid_t));
+ memcpy(&u.path_rec.sgid,
+ &((osmv_gid_pair_t *) (p_query_req->p_query_input))->
+ src_gid, sizeof(ib_gid_t));
+ break;
+
+ case OSMV_QUERY_PATH_REC_BY_LIDS:
+ OSM_LOG(p_log, OSM_LOG_DEBUG, "DBG:001 PATH_REC_BY_LIDS\n");
+ memset(&u.path_rec, 0, sizeof(ib_path_rec_t));
+ sa_mad_data.method = IB_MAD_METHOD_GET;
+ sa_mad_data.attr_id = IB_MAD_ATTR_PATH_RECORD;
+ sa_mad_data.comp_mask =
+ (IB_PR_COMPMASK_DLID | IB_PR_COMPMASK_SLID);
+ sa_mad_data.p_attr = &u.path_rec;
+ u.path_rec.dlid =
+ ((osmv_lid_pair_t *) (p_query_req->p_query_input))->
+ dest_lid;
+ u.path_rec.slid =
+ ((osmv_lid_pair_t *) (p_query_req->p_query_input))->src_lid;
+ break;
+
+ case OSMV_QUERY_UD_MULTICAST_SET:
+ sa_mad_data.method = IB_MAD_METHOD_SET;
+ p_user_query = (osmv_user_query_t *) p_query_req->p_query_input;
+ OSM_LOG(p_log, OSM_LOG_DEBUG, "DBG:001 OSMV_QUERY_UD_MULTICAST_SET\n");
+ sa_mad_data.attr_id = IB_MAD_ATTR_MCMEMBER_RECORD;
+ sa_mad_data.comp_mask = p_user_query->comp_mask;
+ sa_mad_data.p_attr = p_user_query->p_attr;
+ break;
+
+ case OSMV_QUERY_UD_MULTICAST_DELETE:
+ sa_mad_data.method = IB_MAD_METHOD_DELETE;
+ p_user_query = (osmv_user_query_t *) p_query_req->p_query_input;
+ OSM_LOG(p_log, OSM_LOG_DEBUG, "DBG:001 OSMV_QUERY_UD_MULTICAST_DELETE\n");
+ sa_mad_data.attr_id = IB_MAD_ATTR_MCMEMBER_RECORD;
+ sa_mad_data.comp_mask = p_user_query->comp_mask;
+ sa_mad_data.p_attr = p_user_query->p_attr;
+ break;
+
+#ifdef DUAL_SIDED_RMPP
+ case OSMV_QUERY_MULTIPATH_REC:
+ OSM_LOG(p_log, OSM_LOG_DEBUG, "DBG:001 MULTIPATH_REC\n");
+ /* Validate sgid/dgid counts against SA client limit */
+ p_mpr_req = (osmv_multipath_req_t *) p_query_req->p_query_input;
+ if (p_mpr_req->sgid_count + p_mpr_req->dgid_count >
+ IB_MULTIPATH_MAX_GIDS) {
+ OSM_LOG(p_log, OSM_LOG_ERROR, "DBG:001 MULTIPATH_REC "
+ "SGID count %d DGID count %d max count %d\n",
+ p_mpr_req->sgid_count, p_mpr_req->dgid_count,
+ IB_MULTIPATH_MAX_GIDS);
+ CL_ASSERT(0);
+ return IB_ERROR;
+ }
+ memset(&u.multipath_rec, 0, sizeof(ib_multipath_rec_t));
+ sa_mad_data.method = IB_MAD_METHOD_GETMULTI;
+ sa_mad_data.attr_id = IB_MAD_ATTR_MULTIPATH_RECORD;
+ sa_mad_data.attr_offset =
+ ib_get_attr_offset(sizeof(ib_multipath_rec_t));
+ sa_mad_data.p_attr = &u.multipath_rec;
+ sa_mad_data.comp_mask = p_mpr_req->comp_mask;
+ u.multipath_rec.num_path = p_mpr_req->num_path;
+ if (p_mpr_req->reversible)
+ u.multipath_rec.num_path |= 0x80;
+ else
+ u.multipath_rec.num_path &= ~0x80;
+ u.multipath_rec.pkey = p_mpr_req->pkey;
+ ib_multipath_rec_set_sl(&u.multipath_rec, p_mpr_req->sl);
+ ib_multipath_rec_set_qos_class(&u.multipath_rec, 0);
+ u.multipath_rec.independence = p_mpr_req->independence;
+ u.multipath_rec.sgid_count = p_mpr_req->sgid_count;
+ u.multipath_rec.dgid_count = p_mpr_req->dgid_count;
+ j = 0;
+ for (i = 0; i < p_mpr_req->sgid_count; i++, j++)
+ u.multipath_rec.gids[j] = p_mpr_req->gids[j];
+ for (i = 0; i < p_mpr_req->dgid_count; i++, j++)
+ u.multipath_rec.gids[j] = p_mpr_req->gids[j];
+ break;
+#endif
+
+ default:
+ OSM_LOG(p_log, OSM_LOG_ERROR, "DBG:001 UNKNOWN\n");
+ CL_ASSERT(0);
+ return IB_ERROR;
+ }
+
+ status = __osmv_send_sa_req(h_bind, &sa_mad_data, p_query_req);
+
+ OSM_LOG_EXIT(p_log);
+ return status;
+}
diff --git a/contrib/ofed/management/opensm/libvendor/osm_vendor_mlx_sar.c b/contrib/ofed/opensm/libvendor/osm_vendor_mlx_sar.c
index 5523284..5523284 100644
--- a/contrib/ofed/management/opensm/libvendor/osm_vendor_mlx_sar.c
+++ b/contrib/ofed/opensm/libvendor/osm_vendor_mlx_sar.c
diff --git a/contrib/ofed/opensm/libvendor/osm_vendor_mlx_sender.c b/contrib/ofed/opensm/libvendor/osm_vendor_mlx_sender.c
new file mode 100644
index 0000000..319a54e
--- /dev/null
+++ b/contrib/ofed/opensm/libvendor/osm_vendor_mlx_sender.c
@@ -0,0 +1,390 @@
+/*
+ * Copyright (c) 2004-2008 Voltaire, Inc. All rights reserved.
+ * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved.
+ * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+#if HAVE_CONFIG_H
+# include <config.h>
+#endif /* HAVE_CONFIG_H */
+
+#include <string.h>
+#include <vendor/osm_vendor_mlx_sender.h>
+#include <vendor/osm_vendor_mlx_transport.h>
+#include <vendor/osm_vendor_mlx_svc.h>
+#include <vendor/osm_pkt_randomizer.h>
+
+static ib_api_status_t
+__osmv_rmpp_send_segment(IN osm_bind_handle_t h_bind,
+ IN osmv_txn_ctx_t * p_txn, IN uint32_t seg_num);
+
+/****d* OSM Vendor/osmv_simple_send_madw
+ * NAME
+ * osmv_simple_send_madw
+ *
+ * DESCRIPTION
+ * Send a single MAD (256 bytes).
+ *
+ * If this MAD requires a response, set the timeout event.
+ * The function call returns when the MAD's send completion is received.
+ *
+ */
+
+ib_api_status_t
+osmv_simple_send_madw(IN osm_bind_handle_t h_bind,
+ IN osm_madw_t * const p_madw,
+ IN osmv_txn_ctx_t * p_txn, IN boolean_t is_retry)
+{
+ ib_api_status_t ret;
+ osmv_bind_obj_t *p_bo = (osmv_bind_obj_t *) h_bind;
+ osm_mad_addr_t *p_mad_addr = osm_madw_get_mad_addr_ptr(p_madw);
+ uint8_t mad_buf[MAD_BLOCK_SIZE];
+ ib_mad_t *p_mad = (ib_mad_t *) mad_buf;
+ uint64_t key = 0;
+
+ OSM_LOG_ENTER(p_bo->p_vendor->p_log);
+
+ CL_ASSERT(p_madw->mad_size <= MAD_BLOCK_SIZE);
+
+ memset(p_mad, 0, MAD_BLOCK_SIZE);
+ memcpy(p_mad, osm_madw_get_mad_ptr(p_madw), p_madw->mad_size);
+
+ if (NULL != p_txn) {
+ /* Push a fake txn id to the MAD */
+ key = osmv_txn_get_key(p_txn);
+ p_mad->trans_id = cl_hton64(key);
+ }
+
+ /*
+ Add call for packet drop randomizer.
+ This is a testing feature. If run_randomizer flag is set to TRUE,
+ the randomizer will be called, and randomally will drop
+ a packet. This is used for simulating unstable fabric.
+ */
+ if (p_bo->p_vendor->run_randomizer == TRUE) {
+ /* Try the randomizer */
+ if (osm_pkt_randomizer_mad_drop(p_bo->p_vendor->p_log,
+ p_bo->p_vendor->
+ p_pkt_randomizer,
+ p_mad) == TRUE) {
+ osm_log(p_bo->p_vendor->p_log, OSM_LOG_DEBUG,
+ "The MAD will not be sent. \n");
+ ret = IB_SUCCESS;
+ } else {
+ ret =
+ osmv_transport_mad_send(h_bind, p_mad, p_mad_addr);
+ }
+ } else {
+ ret = osmv_transport_mad_send(h_bind, p_mad, p_mad_addr);
+ }
+
+ if ((IB_SUCCESS == ret) && (NULL != p_txn) && (!is_retry)) {
+ /* Set the timeout for receiving the response MAD */
+ ret = osmv_txn_set_timeout_ev(h_bind, key,
+ p_bo->p_vendor->resp_timeout);
+ }
+
+ OSM_LOG_EXIT(p_bo->p_vendor->p_log);
+ return ret;
+}
+
+/***** OSM Vendor/osmv_rmpp_send_madw
+ * NAME
+ * osmv_rmpp_send_madw
+ *
+ * DESCRIPTION
+ * Send a single message (MAD wrapper of arbitrary length).
+ * Follow the RMPP semantics
+ * (segmentation, send window, timeouts etc).
+ *
+ * The function call returns either when the whole message
+ * has been acknowledged, or upon error.
+ *
+ * ASSUMPTIONS
+ * The RMPP sender context is set up
+ */
+
+ib_api_status_t
+osmv_rmpp_send_madw(IN osm_bind_handle_t h_bind,
+ IN osm_madw_t * const p_madw,
+ IN osmv_txn_ctx_t * p_txn, IN boolean_t is_rmpp_ds)
+{
+ ib_api_status_t ret = IB_SUCCESS;
+ uint32_t i, total_segs;
+
+ osmv_rmpp_send_ctx_t *p_send_ctx = osmv_txn_get_rmpp_send_ctx(p_txn);
+ osmv_bind_obj_t *p_bo = (osmv_bind_obj_t *) h_bind;
+
+ OSM_LOG_ENTER(p_bo->p_vendor->p_log);
+
+ total_segs = osmv_rmpp_send_ctx_get_num_segs(p_send_ctx);
+ CL_ASSERT(total_segs >= 1);
+
+ /* In the double-sided transfer, wait for ACK 0 */
+
+ for (;;) {
+
+ if (p_send_ctx->window_first > total_segs) {
+
+ /* Every segment is acknowledged */
+ break;
+ }
+
+ /* Send the next burst. */
+ for (i = p_send_ctx->window_first; i <= p_send_ctx->window_last;
+ i++) {
+
+ /* Send a segment and setup a timeout timer */
+ ret = __osmv_rmpp_send_segment(h_bind, p_txn, i);
+ if (IB_SUCCESS != ret) {
+ goto send_done;
+ }
+ }
+
+ /* Set the Response Timeout for the ACK on the last DATA segment */
+ ret = osmv_txn_set_timeout_ev(h_bind, osmv_txn_get_key(p_txn),
+ p_bo->p_vendor->resp_timeout);
+ if (IB_SUCCESS != ret) {
+ goto send_done;
+ }
+
+ /* Going to sleep. Let the others access the transaction DB */
+ osmv_txn_unlock(p_bo);
+
+ osm_log(p_bo->p_vendor->p_log, OSM_LOG_DEBUG,
+ "RMPP Sender thread (madw=%p) going to sleep ...\n",
+ p_madw);
+
+ /* Await the next event to happen */
+ cl_event_wait_on(&p_send_ctx->event,
+ EVENT_NO_TIMEOUT, TRUE /* interruptible */ );
+
+ /* Got a signal from the MAD dispatcher/timeout handler */
+ osm_log(p_bo->p_vendor->p_log, OSM_LOG_DEBUG,
+ "RMPP Sender thread (madw=%p) waking up on a signal ...\n",
+ p_madw);
+
+ /* Let's see what changed... Make this atomic - re-acquire the lock. */
+ osmv_txn_lock(p_bo);
+
+ if (TRUE == p_bo->is_closing) {
+ osm_log(p_bo->p_vendor->p_log, OSM_LOG_ERROR,
+ "osmv_rmpp_send_madw: ERR 6601: "
+ "The bind handle %p is being closed. "
+ "Stopping the RMPP Send of MADW %p\n",
+ h_bind, p_madw);
+
+ ret = IB_TIMEOUT;
+ return IB_INTERRUPTED;
+ }
+
+ /* STOP? ABORT? TIMEOUT? */
+ if (IB_SUCCESS != p_send_ctx->status) {
+ osm_log(p_bo->p_vendor->p_log, OSM_LOG_ERROR,
+ "osmv_rmpp_send_madw: ERR 6602: "
+ "An error (%s) happened during the RMPP send of %p. Bailing out.\n",
+ ib_get_err_str(p_send_ctx->status), p_madw);
+ ret = p_send_ctx->status;
+ goto send_done;
+ }
+ }
+
+ if (TRUE == is_rmpp_ds) {
+ osm_log(p_bo->p_vendor->p_log, OSM_LOG_DEBUG,
+ "Double-sided RMPP - switching to be the receiver.\n");
+
+ ret = osmv_txn_init_rmpp_receiver(h_bind, p_txn, FALSE
+ /*Send was initiated by me */
+ );
+
+ if (IB_SUCCESS == ret) {
+ /* Send ACK on the 0 segment */
+ ret = __osmv_rmpp_send_segment(h_bind, p_txn, 0);
+ }
+ }
+
+send_done:
+ OSM_LOG_EXIT(p_bo->p_vendor->p_log);
+ return ret;
+}
+
+/*
+ * NAME osmv_rmpp_send_ack
+ *
+ * DESCRIPTION
+ *
+ */
+
+ib_api_status_t
+osmv_rmpp_send_ack(IN osm_bind_handle_t h_bind,
+ IN const ib_mad_t * p_req_mad,
+ IN uint32_t seg_num,
+ IN uint32_t nwl, IN const osm_mad_addr_t * p_mad_addr)
+{
+ uint8_t resp_mad[MAD_BLOCK_SIZE];
+ ib_rmpp_mad_t *p_resp_mad = (ib_rmpp_mad_t *) resp_mad;
+
+#ifdef OSMV_RANDOM_DROP
+ if (TRUE == osmv_random_drop()) {
+ osm_log(((osmv_bind_obj_t *) h_bind)->p_vendor->p_log,
+ OSM_LOG_DEBUG,
+ "Error injection - dropping the RMPP ACK\n");
+ return IB_SUCCESS;
+ }
+#endif
+
+ memcpy(p_resp_mad, p_req_mad, MAD_BLOCK_SIZE);
+
+ p_resp_mad->common_hdr.method = osmv_invert_method(p_req_mad->method);
+ p_resp_mad->rmpp_type = IB_RMPP_TYPE_ACK;
+ p_resp_mad->seg_num = cl_hton32(seg_num);
+ p_resp_mad->paylen_newwin = cl_hton32(nwl);
+ p_resp_mad->rmpp_flags = IB_RMPP_FLAG_ACTIVE;
+
+ return osmv_transport_mad_send(h_bind, p_resp_mad, p_mad_addr);
+}
+
+/*
+ * NAME osmv_rmpp_send_nak
+ *
+ * DESCRIPTION Send the RMPP ABORT or STOP packet
+ */
+
+ib_api_status_t
+osmv_rmpp_send_nak(IN osm_bind_handle_t h_bind,
+ IN const ib_mad_t * p_req_mad,
+ IN const osm_mad_addr_t * p_mad_addr,
+ IN uint8_t nak_type, IN uint8_t status)
+{
+ uint8_t resp_mad[MAD_BLOCK_SIZE];
+ ib_rmpp_mad_t *p_resp_mad = (ib_rmpp_mad_t *) resp_mad;
+
+ memcpy(p_resp_mad, p_req_mad, MAD_BLOCK_SIZE);
+
+ p_resp_mad->common_hdr.method = osmv_invert_method(p_req_mad->method);
+ p_resp_mad->rmpp_type = nak_type;
+ p_resp_mad->rmpp_status = status;
+
+ return osmv_transport_mad_send(h_bind, p_resp_mad, p_mad_addr);
+}
+
+/*
+ * NAME __osmv_rmpp_send_segment
+ *
+ * DESCRIPTION Build a MAD for a specific segment and send it
+ */
+
+static ib_api_status_t
+__osmv_rmpp_send_segment(IN osm_bind_handle_t h_bind,
+ IN osmv_txn_ctx_t * p_txn, IN uint32_t seg_num)
+{
+ ib_api_status_t ret;
+ osmv_rmpp_send_ctx_t *p_send_ctx;
+ uint8_t mad_buf[MAD_BLOCK_SIZE];
+ ib_mad_t *p_mad = (ib_mad_t *) mad_buf;
+ osmv_bind_obj_t *p_bo = (osmv_bind_obj_t *) h_bind;
+ osm_mad_addr_t *p_mad_addr =
+ osm_madw_get_mad_addr_ptr(osmv_txn_get_madw(p_txn));
+ uint32_t timeout = p_bo->p_vendor->resp_timeout;
+ uint64_t key;
+
+ OSM_LOG_ENTER(p_bo->p_vendor->p_log);
+
+#ifdef OSMV_RANDOM_DROP
+ if (TRUE == osmv_random_drop()) {
+
+ osm_log(p_bo->p_vendor->p_log, OSM_LOG_DEBUG,
+ "Error injection - simulating the RMPP segment drop\n");
+ return IB_SUCCESS;
+ }
+#endif
+
+ p_send_ctx = osmv_txn_get_rmpp_send_ctx(p_txn);
+ key = osmv_txn_get_key(p_txn);
+
+ if (0 != seg_num) {
+ ret =
+ osmv_rmpp_send_ctx_get_seg(p_send_ctx, seg_num, timeout,
+ p_mad);
+ CL_ASSERT(IB_SUCCESS == ret);
+
+ /* Put the segment to the wire ! */
+ p_mad->trans_id = cl_hton64(key);
+
+ osm_log(p_bo->p_vendor->p_log, OSM_LOG_DEBUG,
+ "Sending RMPP segment #%d, on-wire TID=0x%" PRIx64 "\n",
+ seg_num, p_mad->trans_id);
+
+ /*
+ Add call for packet drop randomizer.
+ This is a testing feature. If run_randomizer flag is set to TRUE,
+ the randomizer will be called, and randomally will drop
+ a packet. This is used for simulating unstable fabric.
+ */
+ if (p_bo->p_vendor->run_randomizer == TRUE) {
+ /* Try the randomizer */
+ if (osm_pkt_randomizer_mad_drop(p_bo->p_vendor->p_log,
+ p_bo->p_vendor->
+ p_pkt_randomizer,
+ p_mad) == TRUE) {
+ osm_log(p_bo->p_vendor->p_log, OSM_LOG_DEBUG,
+ "The MAD will not be sent. \n");
+ ret = IB_SUCCESS;
+ } else {
+ ret =
+ osmv_transport_mad_send((osm_bind_handle_t)
+ p_bo, p_mad,
+ p_mad_addr);
+ }
+ } else {
+ ret =
+ osmv_transport_mad_send((osm_bind_handle_t) p_bo,
+ p_mad, p_mad_addr);
+ }
+ } else {
+ /* This is an ACK for double-sided handshake. Give it a special treatment. */
+
+ /* It doesn't really matter which data to put. Only the header matters. */
+ ret = osmv_rmpp_send_ctx_get_seg(p_send_ctx, 1, timeout, p_mad);
+ CL_ASSERT(IB_SUCCESS == ret);
+
+ p_mad->trans_id = cl_hton64(key);
+ ret =
+ osmv_rmpp_send_ack((osm_bind_handle_t) p_bo, p_mad,
+ 0 /* segnum */ ,
+ OSMV_RMPP_RECV_WIN /* NWL */ ,
+ p_mad_addr);
+ }
+
+ OSM_LOG_EXIT(p_bo->p_vendor->p_log);
+ return ret;
+}
diff --git a/contrib/ofed/management/opensm/libvendor/osm_vendor_mlx_sim.c b/contrib/ofed/opensm/libvendor/osm_vendor_mlx_sim.c
index c02c4de..c02c4de 100644
--- a/contrib/ofed/management/opensm/libvendor/osm_vendor_mlx_sim.c
+++ b/contrib/ofed/opensm/libvendor/osm_vendor_mlx_sim.c
diff --git a/contrib/ofed/management/opensm/libvendor/osm_vendor_mlx_ts.c b/contrib/ofed/opensm/libvendor/osm_vendor_mlx_ts.c
index d7ab3b3..d7ab3b3 100644
--- a/contrib/ofed/management/opensm/libvendor/osm_vendor_mlx_ts.c
+++ b/contrib/ofed/opensm/libvendor/osm_vendor_mlx_ts.c
diff --git a/contrib/ofed/management/opensm/libvendor/osm_vendor_mlx_ts_anafa.c b/contrib/ofed/opensm/libvendor/osm_vendor_mlx_ts_anafa.c
index b88ac64..b88ac64 100644
--- a/contrib/ofed/management/opensm/libvendor/osm_vendor_mlx_ts_anafa.c
+++ b/contrib/ofed/opensm/libvendor/osm_vendor_mlx_ts_anafa.c
diff --git a/contrib/ofed/opensm/libvendor/osm_vendor_mlx_txn.c b/contrib/ofed/opensm/libvendor/osm_vendor_mlx_txn.c
new file mode 100644
index 0000000..72b6435
--- /dev/null
+++ b/contrib/ofed/opensm/libvendor/osm_vendor_mlx_txn.c
@@ -0,0 +1,680 @@
+/*
+ * Copyright (c) 2004-2008 Voltaire, Inc. All rights reserved.
+ * Copyright (c) 2002-2005,2009 Mellanox Technologies LTD. All rights reserved.
+ * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+#if HAVE_CONFIG_H
+# include <config.h>
+#endif /* HAVE_CONFIG_H */
+
+#include <stdlib.h>
+
+#include <vendor/osm_vendor_mlx.h>
+#include <vendor/osm_vendor_mlx_defs.h>
+#include <vendor/osm_vendor_mlx_txn.h>
+#include <vendor/osm_vendor_mlx_svc.h>
+#include <vendor/osm_vendor_mlx_sender.h>
+
+static ib_api_status_t
+__osmv_txnmgr_lookup(IN osmv_txn_mgr_t * p_tx_mgr,
+ IN uint64_t key, OUT osmv_txn_ctx_t ** pp_txn);
+
+static ib_api_status_t
+__osmv_txnmgr_insert_txn(IN osmv_txn_mgr_t * p_tx_mgr,
+ IN osmv_txn_ctx_t * p_txn, IN uint64_t key);
+
+static ib_api_status_t
+__osmv_txnmgr_remove_txn(IN osmv_txn_mgr_t * p_tx_mgr,
+ IN uint64_t key, OUT osmv_txn_ctx_t ** pp_txn);
+
+static void __osmv_txn_all_done(osm_bind_handle_t h_bind);
+
+static uint64_t
+__osmv_txn_timeout_cb(IN uint64_t key,
+ IN uint32_t num_regs, IN void *cb_context);
+
+ib_api_status_t
+osmv_txn_init(IN osm_bind_handle_t h_bind,
+ IN uint64_t tid, IN uint64_t key, OUT osmv_txn_ctx_t ** pp_txn)
+{
+ ib_api_status_t st;
+ osmv_txn_ctx_t *p_txn;
+ osmv_bind_obj_t *p_bo = (osmv_bind_obj_t *) h_bind;
+
+ OSM_LOG_ENTER(p_bo->p_vendor->p_log);
+
+ CL_ASSERT(NULL != h_bind && NULL != pp_txn);
+
+ osm_log(p_bo->p_vendor->p_log, OSM_LOG_DEBUG,
+ "Starting transaction 0x%016" PRIx64
+ " (key=0x%016" PRIx64 ")\n", tid, key);
+
+ p_txn = malloc(sizeof(osmv_txn_ctx_t));
+ if (!p_txn) {
+ return IB_INSUFFICIENT_MEMORY;
+ }
+
+ memset(p_txn, 0, sizeof(osmv_txn_ctx_t));
+ p_txn->p_log = p_bo->txn_mgr.p_log;
+ p_txn->tid = tid;
+ p_txn->key = key;
+ p_txn->p_madw = NULL;
+ p_txn->rmpp_txfr.rmpp_state = OSMV_TXN_RMPP_NONE;
+
+ /* insert into transaction manager DB */
+ st = __osmv_txnmgr_insert_txn(&p_bo->txn_mgr, p_txn, key);
+ if (IB_SUCCESS != st) {
+ osm_log(p_bo->p_vendor->p_log, OSM_LOG_ERROR,
+ "osmv_txn_init: ERR 6703: "
+ "Failed to insert to transaction 0x%016" PRIx64
+ " (key=0x%016" PRIx64 ") to manager DB\n",
+ tid, key);
+ goto insert_txn_failed;
+ }
+
+ *pp_txn = p_txn;
+ OSM_LOG_EXIT(p_bo->p_vendor->p_log);
+ return IB_SUCCESS;
+
+insert_txn_failed:
+ free(p_txn);
+
+ OSM_LOG_EXIT(p_bo->p_vendor->p_log);
+ return st;
+}
+
+ib_api_status_t
+osmv_txn_init_rmpp_sender(IN osm_bind_handle_t h_bind,
+ IN osmv_txn_ctx_t * p_txn, IN osm_madw_t * p_madw)
+{
+ ib_api_status_t st;
+
+ CL_ASSERT(p_txn);
+
+ /* Double-Sided RMPP Direction Switch */
+ osmv_txn_remove_timeout_ev(h_bind, osmv_txn_get_key(p_txn));
+
+ p_txn->rmpp_txfr.rmpp_state = OSMV_TXN_RMPP_SENDER;
+ p_txn->rmpp_txfr.p_rmpp_send_ctx = malloc(sizeof(osmv_rmpp_send_ctx_t));
+
+ if (!p_txn->rmpp_txfr.p_rmpp_send_ctx) {
+ return IB_INSUFFICIENT_MEMORY;
+ }
+
+ memset(p_txn->rmpp_txfr.p_rmpp_send_ctx, 0,
+ sizeof(osmv_rmpp_send_ctx_t));
+
+ st = osmv_rmpp_send_ctx_init(p_txn->rmpp_txfr.p_rmpp_send_ctx,
+ (void *)p_madw->p_mad,
+ p_madw->mad_size, p_txn->p_log);
+ return st;
+}
+
+ib_api_status_t
+osmv_txn_init_rmpp_receiver(IN osm_bind_handle_t h_bind,
+ IN osmv_txn_ctx_t * p_txn,
+ IN boolean_t is_init_by_peer)
+{
+ ib_api_status_t st;
+ osmv_bind_obj_t *p_bo = (osmv_bind_obj_t *) h_bind;
+ uint64_t key = osmv_txn_get_key(p_txn);
+
+ CL_ASSERT(p_txn);
+
+ /* Double-Sided RMPP Direction Switch */
+ osmv_txn_remove_timeout_ev(h_bind, key);
+
+ /* Set the Transaction Timeout value */
+ st = osmv_txn_set_timeout_ev(h_bind, key,
+ p_bo->p_vendor->ttime_timeout);
+ if (IB_SUCCESS != st) {
+
+ return st;
+ }
+
+ p_txn->rmpp_txfr.rmpp_state = OSMV_TXN_RMPP_RECEIVER;
+ p_txn->rmpp_txfr.is_rmpp_init_by_peer = is_init_by_peer;
+
+ p_txn->rmpp_txfr.p_rmpp_recv_ctx = malloc(sizeof(osmv_rmpp_recv_ctx_t));
+
+ if (!p_txn->rmpp_txfr.p_rmpp_recv_ctx) {
+
+ osmv_txn_remove_timeout_ev(h_bind, key);
+ return IB_INSUFFICIENT_MEMORY;
+ }
+
+ memset(p_txn->rmpp_txfr.p_rmpp_recv_ctx, 0,
+ sizeof(osmv_rmpp_recv_ctx_t));
+
+ st = osmv_rmpp_recv_ctx_init(p_txn->rmpp_txfr.p_rmpp_recv_ctx,
+ p_txn->p_log);
+
+ return st;
+}
+
+/*
+ * NAME
+ * osmv_txn_set_timeout_ev
+ *
+ * DESCRIPTION
+ *
+ * SEE ALSO
+ *
+ */
+ib_api_status_t
+osmv_txn_set_timeout_ev(IN osm_bind_handle_t h_bind,
+ IN uint64_t key, IN uint64_t msec)
+{
+ osmv_bind_obj_t *p_bo = (osmv_bind_obj_t *) h_bind;
+ cl_event_wheel_t *p_event_wheel = p_bo->txn_mgr.p_event_wheel;
+ cl_status_t status;
+
+ status = cl_event_wheel_reg(p_event_wheel, key, cl_get_time_stamp() + 1000 * msec, /* TTL */
+ __osmv_txn_timeout_cb,
+ p_bo /* The context */ );
+
+ return (ib_api_status_t) status;
+}
+
+/*
+ * NAME
+ * osmv_txn_remove_timeout_ev
+ *
+ * DESCRIPTION
+
+ * SEE ALSO
+ *
+ */
+void osmv_txn_remove_timeout_ev(IN osm_bind_handle_t h_bind, IN uint64_t key)
+{
+ cl_event_wheel_t *p_event_wheel =
+ ((osmv_bind_obj_t *) h_bind)->txn_mgr.p_event_wheel;
+ cl_event_wheel_unreg(p_event_wheel, key);
+}
+
+void
+osmv_txn_done(IN osm_bind_handle_t h_bind,
+ IN uint64_t key, IN boolean_t is_in_cb)
+{
+ osmv_txn_ctx_t *p_ctx;
+ osmv_bind_obj_t *const p_bo = (osmv_bind_obj_t *) h_bind;
+
+ OSM_LOG_ENTER(p_bo->p_vendor->p_log);
+
+ CL_ASSERT(h_bind);
+
+ /* Cancel the (single) timeout possibly outstanding for this txn
+ * Don't do this if you are in the callback context, for 2 reasons:
+ * (1) The event wheel will remove the context itself.
+ * (2) If we try to, there is a deadlock in the event wheel
+ */
+ if (FALSE == is_in_cb) {
+ osmv_txn_remove_timeout_ev(h_bind, key);
+ }
+
+ /* Remove from DB */
+ if (IB_NOT_FOUND ==
+ __osmv_txnmgr_remove_txn(&p_bo->txn_mgr, key, &p_ctx)) {
+ return;
+ }
+
+ /* Destroy the transaction's RMPP contexts
+ * (can be more than one in the case of double sided transfer)
+ */
+
+ if (p_ctx->rmpp_txfr.p_rmpp_send_ctx) {
+ osmv_rmpp_send_ctx_done(p_ctx->rmpp_txfr.p_rmpp_send_ctx);
+ }
+
+ if (p_ctx->rmpp_txfr.p_rmpp_recv_ctx) {
+ osmv_rmpp_recv_ctx_done(p_ctx->rmpp_txfr.p_rmpp_recv_ctx);
+ }
+
+ free(p_ctx);
+
+ OSM_LOG_EXIT(p_bo->p_vendor->p_log);
+}
+
+ib_api_status_t
+osmv_txn_lookup(IN osm_bind_handle_t h_bind,
+ IN uint64_t key, OUT osmv_txn_ctx_t ** pp_txn)
+{
+ return __osmv_txnmgr_lookup(&(((osmv_bind_obj_t *) h_bind)->txn_mgr),
+ key, pp_txn);
+}
+
+void osmv_txn_abort_rmpp_txns(osm_bind_handle_t h_bind)
+{
+ osmv_bind_obj_t *p_bo = (osmv_bind_obj_t *) h_bind;
+ cl_map_item_t *p_item;
+ cl_map_obj_t *p_obj;
+ osmv_txn_ctx_t *p_txn;
+ osmv_rmpp_send_ctx_t *p_send_ctx;
+ cl_qmap_t *p_map = p_bo->txn_mgr.p_txn_map;
+
+ OSM_LOG_ENTER(p_bo->p_vendor->p_log);
+
+ while (FALSE == cl_is_qmap_empty(p_map)) {
+
+ p_item = cl_qmap_head(p_map);
+ p_obj = PARENT_STRUCT(p_item, cl_map_obj_t, item);
+ p_txn = (osmv_txn_ctx_t *) cl_qmap_obj(p_obj);
+ p_send_ctx = osmv_txn_get_rmpp_send_ctx(p_txn);
+
+ if (NULL != p_send_ctx) {
+
+ p_send_ctx->status = IB_INTERRUPTED;
+
+ /* Wake up the sender thread to let it break out */
+ cl_event_signal(&p_send_ctx->event);
+ }
+
+ cl_qmap_remove_item(p_map, p_item);
+ }
+
+ OSM_LOG_EXIT(p_bo->p_vendor->p_log);
+}
+
+ib_api_status_t
+osmv_txnmgr_init(IN osmv_txn_mgr_t * p_tx_mgr,
+ IN osm_log_t * p_log, IN cl_spinlock_t * p_lock)
+{
+ cl_status_t cl_st = CL_SUCCESS;
+
+ p_tx_mgr->p_event_wheel = malloc(sizeof(cl_event_wheel_t));
+ if (!p_tx_mgr->p_event_wheel) {
+ return IB_INSUFFICIENT_MEMORY;
+ }
+
+ memset(p_tx_mgr->p_event_wheel, 0, sizeof(cl_event_wheel_t));
+
+ cl_event_wheel_construct(p_tx_mgr->p_event_wheel);
+
+ /* NOTE! We are using an extended constructor.
+ * We tell the Event Wheel run in a non-protected manner in the reg/unreg calls,
+ * and acquire an external lock in the asynchronous callback.
+ */
+ cl_st = cl_event_wheel_init_ex(p_tx_mgr->p_event_wheel, p_lock);
+ if (cl_st != CL_SUCCESS) {
+ free(p_tx_mgr->p_event_wheel);
+ return (ib_api_status_t) cl_st;
+ }
+
+ p_tx_mgr->p_txn_map = malloc(sizeof(cl_qmap_t));
+ if (!p_tx_mgr->p_txn_map) {
+ cl_event_wheel_destroy(p_tx_mgr->p_event_wheel);
+ free(p_tx_mgr->p_event_wheel);
+ return IB_INSUFFICIENT_MEMORY;
+ }
+
+ memset(p_tx_mgr->p_txn_map, 0, sizeof(cl_qmap_t));
+
+ cl_qmap_init(p_tx_mgr->p_txn_map);
+ p_tx_mgr->p_log = p_log;
+
+ return cl_st;
+}
+
+void osmv_txnmgr_done(IN osm_bind_handle_t h_bind)
+{
+ osmv_bind_obj_t *p_bo = (osmv_bind_obj_t *) h_bind;
+
+ __osmv_txn_all_done(h_bind);
+ free(p_bo->txn_mgr.p_txn_map);
+
+ cl_event_wheel_destroy(p_bo->txn_mgr.p_event_wheel);
+ free(p_bo->txn_mgr.p_event_wheel);
+}
+
+ib_api_status_t
+__osmv_txnmgr_lookup(IN osmv_txn_mgr_t * p_tx_mgr,
+ IN uint64_t key, OUT osmv_txn_ctx_t ** pp_txn)
+{
+ ib_api_status_t status = IB_SUCCESS;
+ cl_map_item_t *p_item;
+ cl_map_obj_t *p_obj;
+
+ uint64_t tmp_key;
+
+ OSM_LOG_ENTER(p_tx_mgr->p_log);
+
+ CL_ASSERT(p_tx_mgr);
+ CL_ASSERT(pp_txn);
+
+ osm_log(p_tx_mgr->p_log, OSM_LOG_DEBUG,
+ "__osmv_txnmgr_lookup: "
+ "Looking for key: 0x%016" PRIx64 " in map ptr:%p\n", key,
+ p_tx_mgr->p_txn_map);
+
+ p_item = cl_qmap_head(p_tx_mgr->p_txn_map);
+ while (p_item != cl_qmap_end(p_tx_mgr->p_txn_map)) {
+ tmp_key = cl_qmap_key(p_item);
+ osm_log(p_tx_mgr->p_log, OSM_LOG_DEBUG,
+ "__osmv_txnmgr_lookup: "
+ "Found key 0x%016" PRIx64 "\n", tmp_key);
+ p_item = cl_qmap_next(p_item);
+ }
+
+ p_item = cl_qmap_get(p_tx_mgr->p_txn_map, key);
+ if (cl_qmap_end(p_tx_mgr->p_txn_map) == p_item) {
+ status = IB_NOT_FOUND;
+ } else {
+ p_obj = PARENT_STRUCT(p_item, cl_map_obj_t, item);
+ *pp_txn = cl_qmap_obj(p_obj);
+ }
+
+ OSM_LOG_EXIT(p_tx_mgr->p_log);
+ return status;
+}
+
+ib_api_status_t
+__osmv_txnmgr_insert_txn(IN osmv_txn_mgr_t * p_tx_mgr,
+ IN osmv_txn_ctx_t * p_txn, IN uint64_t key)
+{
+ cl_map_obj_t *p_obj = NULL;
+ cl_map_item_t *p_item;
+ uint64_t tmp_key;
+
+ CL_ASSERT(p_tx_mgr);
+ CL_ASSERT(p_txn);
+
+ key = osmv_txn_get_key(p_txn);
+ p_obj = malloc(sizeof(cl_map_obj_t));
+ if (NULL == p_obj)
+ return IB_INSUFFICIENT_MEMORY;
+
+ osm_log(p_tx_mgr->p_log, OSM_LOG_DEBUG,
+ "__osmv_txnmgr_insert_txn: "
+ "Inserting key: 0x%016" PRIx64 " to map ptr:%p\n", key,
+ p_tx_mgr->p_txn_map);
+
+ memset(p_obj, 0, sizeof(cl_map_obj_t));
+
+ cl_qmap_set_obj(p_obj, p_txn);
+ /* assuming lookup with this key was made and the result was IB_NOT_FOUND */
+ cl_qmap_insert(p_tx_mgr->p_txn_map, key, &p_obj->item);
+
+ p_item = cl_qmap_head(p_tx_mgr->p_txn_map);
+ while (p_item != cl_qmap_end(p_tx_mgr->p_txn_map)) {
+ tmp_key = cl_qmap_key(p_item);
+ osm_log(p_tx_mgr->p_log, OSM_LOG_DEBUG,
+ "__osmv_txnmgr_insert_txn: "
+ "Found key 0x%016" PRIx64 "\n", tmp_key);
+ p_item = cl_qmap_next(p_item);
+ }
+
+ return IB_SUCCESS;
+}
+
+ib_api_status_t
+__osmv_txnmgr_remove_txn(IN osmv_txn_mgr_t * p_tx_mgr,
+ IN uint64_t key, OUT osmv_txn_ctx_t ** pp_txn)
+{
+ cl_map_obj_t *p_obj;
+ cl_map_item_t *p_item;
+
+ OSM_LOG_ENTER(p_tx_mgr->p_log);
+
+ CL_ASSERT(p_tx_mgr);
+ CL_ASSERT(pp_txn);
+
+ p_item = cl_qmap_remove(p_tx_mgr->p_txn_map, key);
+
+ if (p_item == cl_qmap_end(p_tx_mgr->p_txn_map)) {
+
+ osm_log(p_tx_mgr->p_log, OSM_LOG_ERROR,
+ "__osmv_txnmgr_remove_txn: ERR 6701: "
+ "Could not remove the transaction 0x%016" PRIx64 " - "
+ "something is really wrong!\n", key);
+ OSM_LOG_EXIT(p_tx_mgr->p_log);
+ return IB_NOT_FOUND;
+ }
+
+ p_obj = PARENT_STRUCT(p_item, cl_map_obj_t, item);
+ *pp_txn = cl_qmap_obj(p_obj);
+
+ free(p_obj);
+
+ OSM_LOG_EXIT(p_tx_mgr->p_log);
+ return IB_SUCCESS;
+}
+
+void __osmv_txn_all_done(osm_bind_handle_t h_bind)
+{
+ osmv_bind_obj_t *p_bo = (osmv_bind_obj_t *) h_bind;
+ cl_map_item_t *p_item;
+ cl_map_obj_t *p_obj;
+ osmv_txn_ctx_t *p_txn;
+
+ OSM_LOG_ENTER(p_bo->p_vendor->p_log);
+
+ p_item = cl_qmap_head(p_bo->txn_mgr.p_txn_map);
+ while (p_item != cl_qmap_end(p_bo->txn_mgr.p_txn_map)) {
+
+ p_obj = PARENT_STRUCT(p_item, cl_map_obj_t, item);
+ p_txn = (osmv_txn_ctx_t *) cl_qmap_obj(p_obj);
+ osmv_txn_done(h_bind, osmv_txn_get_key(p_txn), FALSE);
+ free(p_obj);
+ /* assuming osmv_txn_done has removed the txn from the map */
+ p_item = cl_qmap_head(p_bo->txn_mgr.p_txn_map);
+ }
+
+ OSM_LOG_EXIT(p_bo->p_vendor->p_log);
+}
+
+/******************************************************************************/
+
+void osmv_txn_lock(IN osm_bind_handle_t h_bind)
+{
+ osmv_bind_obj_t *p_bo = (osmv_bind_obj_t *) h_bind;
+
+ osm_log(p_bo->p_vendor->p_log, OSM_LOG_DEBUG,
+ "--> Acquiring lock %p on bind handle %p\n", &p_bo->lock, p_bo);
+
+ cl_spinlock_acquire(&p_bo->lock);
+
+ osm_log(p_bo->p_vendor->p_log, OSM_LOG_DEBUG,
+ "--> Acquired lock %p on bind handle %p\n", &p_bo->lock, p_bo);
+}
+
+void osmv_txn_unlock(IN osm_bind_handle_t h_bind)
+{
+ osmv_bind_obj_t *p_bo = (osmv_bind_obj_t *) h_bind;
+ cl_spinlock_t *p_lock = &p_bo->lock;
+ osm_log_t *p_log = p_bo->p_vendor->p_log;
+
+ osm_log(p_log, OSM_LOG_DEBUG,
+ "<-- Releasing lock %p on bind handle %p\n", p_lock, p_bo);
+
+ cl_spinlock_release(&p_bo->lock);
+
+ /* We'll use the saved ptrs, since now the p_bo can be destroyed already */
+ osm_log(p_log, OSM_LOG_DEBUG,
+ "<-- Released lock %p on bind handle %p\n", p_lock, p_bo);
+
+}
+
+static uint64_t
+__osmv_txn_timeout_cb(IN uint64_t key,
+ IN uint32_t num_regs, IN void *cb_context)
+{
+ osmv_bind_obj_t *p_bo = (osmv_bind_obj_t *) cb_context;
+ uint64_t ret = 0;
+ osmv_txn_ctx_t *p_txn;
+ osmv_rmpp_send_ctx_t *p_send_ctx;
+ osm_madw_t *p_madw = NULL;
+ ib_mad_t *p_mad;
+ osm_mad_addr_t *p_mad_addr;
+ boolean_t invoke_err_cb = FALSE;
+
+ OSM_LOG_ENTER(p_bo->p_vendor->p_log);
+
+ /* Don't try to acquire a lock on the Bind Object -
+ * it's taken by the mechanism that drives the timeout based events!
+ * (Recall the special constructor that the Event Wheel is applied with)
+ */
+ if (p_bo->is_closing) {
+ goto txn_done;
+ }
+
+ ret = osmv_txn_lookup(p_bo, key, &p_txn);
+ if (IB_NOT_FOUND == ret) {
+ /* Prevent a race - the transaction is already destroyed */
+ goto txn_done;
+ }
+
+ p_madw = p_txn->p_madw;
+
+ switch (osmv_txn_get_rmpp_state(p_txn)) {
+
+ case OSMV_TXN_RMPP_NONE:
+ if (num_regs <= OSM_DEFAULT_RETRY_COUNT) {
+ /* We still did not exceed the limit of retransmissions.
+ * Set the next timeout's value.
+ */
+ osm_log(p_bo->p_vendor->p_log, OSM_LOG_DEBUG,
+ "__osmv_txn_timeout_cb: "
+ "The transaction request (tid=0x%016" PRIx64 ")"
+ " timed out %d times. Retrying the send.\n",
+ osmv_txn_get_tid(p_txn), num_regs);
+
+ /* resend this mad */
+ ret = osmv_simple_send_madw((osm_bind_handle_t *) p_bo,
+ p_madw, p_txn, TRUE);
+ if (ret != IB_SUCCESS) {
+ osm_log(p_bo->p_vendor->p_log, OSM_LOG_ERROR,
+ "__osmv_txn_timeout_cb: "
+ "Fail to send retry for transaction"
+ "request (tid=0x%016" PRIx64 ").\n",
+ osmv_txn_get_tid(p_txn));
+
+ osmv_txn_done((osm_bind_handle_t) p_bo, key,
+ TRUE /*in timeout callback */ );
+
+ /* This is a requester. Always apply the callback */
+ invoke_err_cb = TRUE;
+ } else {
+ uint64_t next_timeout_ms;
+ next_timeout_ms =
+ p_bo->p_vendor->resp_timeout * (num_regs +
+ 1) *
+ (num_regs + 1);
+ /* when do we need to timeout again */
+ ret =
+ cl_get_time_stamp() +
+ (uint64_t) (1000 * next_timeout_ms);
+
+ osm_log(p_bo->p_vendor->p_log, OSM_LOG_DEBUG,
+ "__osmv_txn_timeout_cb: "
+ "Retry request timout in : %lu [msec].\n",
+ next_timeout_ms);
+ }
+ } else {
+ osm_log(p_bo->p_vendor->p_log, OSM_LOG_ERROR,
+ "__osmv_txn_timeout_cb: ERR 6702: "
+ "The transaction request (0x%016" PRIx64 ") "
+ "timed out (after %d retries). "
+ "Invoking the error callback.\n",
+ osmv_txn_get_tid(p_txn), num_regs);
+
+ osmv_txn_done((osm_bind_handle_t) p_bo, key,
+ TRUE /*in timeout callback */ );
+
+ /* This is a requester. Always apply the callback */
+ invoke_err_cb = TRUE;
+ }
+ break;
+
+ case OSMV_TXN_RMPP_SENDER:
+ osm_log(p_bo->p_vendor->p_log, OSM_LOG_DEBUG,
+ "RMPP sender (tid=0x%016" PRIx64 ") did not receive ACK "
+ "on every segment in the current send window.\n",
+ osmv_txn_get_tid(p_txn));
+
+ p_send_ctx = osmv_txn_get_rmpp_send_ctx(p_txn);
+ if (num_regs <= OSM_DEFAULT_RETRY_COUNT) {
+ /* We still did not exceed the limit of retransmissions.
+ * Set the next timeout's value.
+ */
+ ret =
+ cl_get_time_stamp() +
+ 1000 * p_bo->p_vendor->resp_timeout;
+ } else {
+ p_send_ctx->status = IB_TIMEOUT;
+
+ p_mad = osm_madw_get_mad_ptr(p_madw);
+ p_mad_addr = osm_madw_get_mad_addr_ptr(p_madw);
+
+ /* Send an ABORT to the other side */
+ osmv_rmpp_send_nak((osm_bind_handle_t) p_bo, p_mad,
+ p_mad_addr, IB_RMPP_TYPE_ABORT,
+ IB_RMPP_STATUS_T2L);
+ }
+
+ /* Wake the RMPP sender thread up */
+ cl_event_signal(&p_send_ctx->event);
+ break;
+
+ case OSMV_TXN_RMPP_RECEIVER:
+ osm_log(p_bo->p_vendor->p_log, OSM_LOG_DEBUG,
+ "Transaction timeout on an RMPP receiver "
+ "(tid=0x%016" PRIx64 "). Dropping the transaction.\n",
+ osmv_txn_get_tid(p_txn));
+
+ osmv_txn_done((osm_bind_handle_t) p_bo, key,
+ TRUE /*in timeout callback */ );
+
+ if (FALSE == osmv_txn_is_rmpp_init_by_peer(p_txn)) {
+ /* This is a requester, still waiting for the reply. Apply the callback */
+ invoke_err_cb = TRUE;
+ }
+
+ break;
+
+ default:
+ CL_ASSERT(FALSE);
+ }
+
+ if (TRUE == invoke_err_cb) {
+ CL_ASSERT(NULL != p_madw);
+ /* update the status in the p_madw */
+ p_madw->status = IB_TIMEOUT;
+ p_bo->send_err_cb(p_bo->cb_context, p_madw);
+ /* no re-registration */
+ ret = 0;
+ }
+
+txn_done:
+ OSM_LOG_EXIT(p_bo->p_vendor->p_log);
+ return ret;
+}
diff --git a/contrib/ofed/opensm/libvendor/osm_vendor_mtl.c b/contrib/ofed/opensm/libvendor/osm_vendor_mtl.c
new file mode 100644
index 0000000..ede3c71
--- /dev/null
+++ b/contrib/ofed/opensm/libvendor/osm_vendor_mtl.c
@@ -0,0 +1,1098 @@
+/*
+ * Copyright (c) 2004-2008 Voltaire, Inc. All rights reserved.
+ * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved.
+ * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+#if HAVE_CONFIG_H
+# include <config.h>
+#endif /* HAVE_CONFIG_H */
+
+#ifdef OSM_VENDOR_INTF_MTL
+
+#include <stdlib.h>
+#include <string.h>
+#include <opensm/osm_helper.h>
+#include <opensm/osm_log.h>
+/* HACK - I do not know how to prevent complib from loading kernel H files */
+#undef __init
+#include <vendor/osm_vendor_mtl.h>
+#include <vendor/osm_vendor_api.h>
+#include <opensm/osm_subnet.h>
+#include <opensm/osm_opensm.h>
+#include <vendor/osm_vendor_mtl_transaction_mgr.h>
+#include <vendor/osm_mtl_bind.h>
+
+/*
+ Since a race can accure on requests. Meaning - a response is received before
+ the send_callback is called - we will save both the madw_p and the fact
+ whether or not it is a response. A race can occure only on requests that did
+ not fail, and then the madw_p will be put back in the pool before the callback.
+*/
+uint64_t __osm_set_wrid_by_p_madw(IN osm_madw_t * p_madw)
+{
+ uint64_t wrid = 0;
+
+ CL_ASSERT(p_madw->p_mad);
+
+ memcpy(&wrid, &p_madw, sizeof(osm_madw_t *));
+ wrid = (wrid << 1) |
+ ib_mad_is_response(p_madw->p_mad);
+ return wrid;
+}
+
+void
+__osm_set_p_madw_and_resp_by_wrid(IN uint64_t wrid,
+ OUT uint8_t * is_resp,
+ OUT osm_madw_t ** pp_madw)
+{
+ *is_resp = wrid & 0x0000000000000001;
+ wrid = wrid >> 1;
+ memcpy(pp_madw, &wrid, sizeof(osm_madw_t *));
+}
+
+/**********************************************************************
+ * IB_MGT to OSM ADDRESS VECTOR
+ **********************************************************************/
+void
+__osm_mtl_conv_ibmgt_rcv_desc_to_osm_addr(IN osm_vendor_t * const p_vend,
+ IN IB_MGT_mad_rcv_desc_t * p_rcv_desc,
+ IN uint8_t is_smi,
+ OUT osm_mad_addr_t * p_mad_addr)
+{
+ /* p_mad_addr->dest_lid = p_osm->subn.sm_base_lid; - for resp we use the dest lid ... */
+ p_mad_addr->dest_lid = cl_hton16(p_rcv_desc->remote_lid);
+ p_mad_addr->static_rate = 0; /* HACK - we do not know the rate ! */
+ p_mad_addr->path_bits = p_rcv_desc->local_path_bits;
+ if (is_smi) {
+ /* SMI */
+ p_mad_addr->addr_type.smi.source_lid =
+ cl_hton16(p_rcv_desc->remote_lid);
+ p_mad_addr->addr_type.smi.port_num = 99; /* HACK - if used - should fail */
+ } else {
+ /* GSI */
+ /* seems to me there is a IBMGT bug reversing the QPN ... */
+ /* Does IBMGT supposed to provide the QPN is network or HOST ? */
+ p_mad_addr->addr_type.gsi.remote_qp = cl_hton32(p_rcv_desc->qp);
+
+ p_mad_addr->addr_type.gsi.remote_qkey = IB_QP1_WELL_KNOWN_Q_KEY;
+ /* we do have the p_mad_addr->pkey_ix but how to get the PKey by index ? */
+ /* the only way seems to be to use VAPI_query_hca_pkey_tbl and obtain */
+ /* the full PKey table - than go by the index. */
+ /* since this does not seem reasonable to me I simply use the default */
+ /* There is a TAVOR limitation that only one P_KEY is supported per */
+ /* QP - so QP1 must use IB_DEFAULT_PKEY */
+ p_mad_addr->addr_type.gsi.pkey_ix = 0;
+ p_mad_addr->addr_type.gsi.service_level = p_rcv_desc->sl;
+
+ p_mad_addr->addr_type.gsi.global_route = p_rcv_desc->grh_flag;
+ /* copy the GRH data if relevant */
+ if (p_mad_addr->addr_type.gsi.global_route) {
+ p_mad_addr->addr_type.gsi.grh_info.ver_class_flow =
+ ib_grh_set_ver_class_flow(p_rcv_desc->grh.
+ IP_version,
+ p_rcv_desc->grh.
+ traffic_class,
+ p_rcv_desc->grh.
+ flow_label);
+ p_mad_addr->addr_type.gsi.grh_info.hop_limit =
+ p_rcv_desc->grh.hop_limit;
+ memcpy(&p_mad_addr->addr_type.gsi.grh_info.src_gid.raw,
+ &p_rcv_desc->grh.sgid, sizeof(ib_net64_t));
+ memcpy(&p_mad_addr->addr_type.gsi.grh_info.dest_gid.raw,
+ p_rcv_desc->grh.dgid, sizeof(ib_net64_t));
+ }
+ }
+}
+
+/**********************************************************************
+ * OSM ADDR VECTOR TO IB_MGT
+ **********************************************************************/
+void
+__osm_mtl_conv_osm_addr_to_ibmgt_addr(IN osm_mad_addr_t * p_mad_addr,
+ IN uint8_t is_smi, OUT IB_ud_av_t * p_av)
+{
+
+ /* For global destination or Multicast address: */
+ u_int8_t ver;
+
+ memset(p_av, 0, sizeof(IB_ud_av_t));
+
+ p_av->src_path_bits = p_mad_addr->path_bits;
+ p_av->static_rate = p_mad_addr->static_rate;
+ p_av->dlid = cl_ntoh16(p_mad_addr->dest_lid);
+
+ if (is_smi) {
+ p_av->sl = 0; /* Just to note we use 0 here. */
+ } else {
+ p_av->sl = p_mad_addr->addr_type.gsi.service_level;
+ p_av->grh_flag = p_mad_addr->addr_type.gsi.global_route;
+
+ if (p_mad_addr->addr_type.gsi.global_route) {
+ ib_grh_get_ver_class_flow(p_mad_addr->addr_type.gsi.
+ grh_info.ver_class_flow, &ver,
+ &p_av->traffic_class,
+ &p_av->flow_label);
+ p_av->hop_limit =
+ p_mad_addr->addr_type.gsi.grh_info.hop_limit;
+ p_av->sgid_index = 0; /* we always use source GID 0 */
+ memcpy(&p_av->dgid,
+ &p_mad_addr->addr_type.gsi.grh_info.dest_gid.raw,
+ sizeof(ib_net64_t));
+
+ }
+ }
+}
+
+void __osm_vendor_clear_sm(IN osm_bind_handle_t h_bind)
+{
+ osm_mtl_bind_info_t *p_bind = (osm_mtl_bind_info_t *) h_bind;
+ osm_vendor_t *p_vend = p_bind->p_vend;
+ VAPI_ret_t status;
+ VAPI_hca_attr_t attr_mod;
+ VAPI_hca_attr_mask_t attr_mask;
+
+ OSM_LOG_ENTER(p_vend->p_log);
+
+ memset(&attr_mod, 0, sizeof(attr_mod));
+ memset(&attr_mask, 0, sizeof(attr_mask));
+
+ attr_mod.is_sm = FALSE;
+ attr_mask = HCA_ATTR_IS_SM;
+
+ status =
+ VAPI_modify_hca_attr(p_bind->hca_hndl, p_bind->port_num, &attr_mod,
+ &attr_mask);
+ if (status != VAPI_OK) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "__osm_vendor_clear_sm: ERR 3C21: "
+ "Unable set 'IS_SM' bit in port attributes (%d).\n",
+ status);
+ }
+
+ OSM_LOG_EXIT(p_vend->p_log);
+}
+
+/**********************************************************************
+ * ANY CONSTRUCTION OF THE osm_vendor_t OBJECT
+ **********************************************************************/
+void osm_vendor_construct(IN osm_vendor_t * const p_vend)
+{
+ memset(p_vend, 0, sizeof(*p_vend));
+}
+
+/**********************************************************************
+ * DEALOCATE osm_vendor_t
+ **********************************************************************/
+void osm_vendor_destroy(IN osm_vendor_t * const p_vend)
+{
+ osm_vendor_mgt_bind_t *vendor_mgt_bind_p;
+ IB_MGT_ret_t mgt_ret;
+ OSM_LOG_ENTER(p_vend->p_log);
+
+ if (p_vend->h_al != NULL) {
+ vendor_mgt_bind_p = (osm_vendor_mgt_bind_t *) p_vend->h_al;
+ if (vendor_mgt_bind_p->gsi_init) {
+
+ /* un register the class */
+ /* HACK WE ASSUME WE ONLY GOT SA CLASS REGISTERD ON GSI !!! */
+ mgt_ret =
+ IB_MGT_unbind_gsi_class(vendor_mgt_bind_p->
+ gsi_mads_hdl,
+ IB_MCLASS_SUBN_ADM);
+ if (mgt_ret != IB_MGT_OK) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "osm_vendor_destroy: ERR 3C03: "
+ "Fail to unbind the SA class.\n");
+ }
+
+ /* un bind the handle */
+ if (IB_MGT_release_handle
+ (vendor_mgt_bind_p->gsi_mads_hdl) != IB_MGT_OK) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "osm_vendor_destroy: ERR 3C02: "
+ "Fail to unbind the SA GSI handle.\n");
+ }
+ osm_log(p_vend->p_log, OSM_LOG_DEBUG,
+ "osm_vendor_destroy: DBG 1002: "
+ "Unbind the GSI handles.\n");
+ }
+ if (vendor_mgt_bind_p->smi_init) {
+ /* first - clear the IS_SM in the capability mask */
+ __osm_vendor_clear_sm((osm_bind_handle_t)
+ (vendor_mgt_bind_p->smi_p_bind));
+
+ /* un register the class */
+ mgt_ret =
+ IB_MGT_unbind_sm(vendor_mgt_bind_p->smi_mads_hdl);
+ if (mgt_ret != IB_MGT_OK) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "osm_vendor_destroy: ERR 3C04: "
+ "Fail to unbind the SM class.\n");
+ }
+
+ /* un bind the handle */
+ if (IB_MGT_release_handle
+ (vendor_mgt_bind_p->smi_mads_hdl) != IB_MGT_OK) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "osm_vendor_destroy: ERR 3C05: "
+ "Fail to unbind the SMI handle.\n");
+ }
+ osm_log(p_vend->p_log, OSM_LOG_DEBUG,
+ "osm_vendor_destroy: DBG 1003: "
+ "Unbind the SMI handles.\n");
+
+ }
+ }
+ osm_transaction_mgr_destroy(p_vend);
+ /* __osm_mtl_destroy_tid_mad_map( p_vend ); */
+ OSM_LOG_EXIT(p_vend->p_log);
+}
+
+/**********************************************************************
+DEALLOCATE A POINTER TO osm_vendor_t
+**********************************************************************/
+void osm_vendor_delete(IN osm_vendor_t ** const pp_vend)
+{
+ CL_ASSERT(pp_vend);
+
+ osm_vendor_destroy(*pp_vend);
+ free(*pp_vend);
+ *pp_vend = NULL;
+}
+
+/**********************************************************************
+ * This proc actuall binds the handle to the lower level.
+ *
+ * We might have here as a result a casting of our struct to the ib_al_handle_t
+ *
+ * Q: Do we need 2 of those - one for MSI and one for GSI ?
+ * A: Yes! We should be able to do the SA too. So we need a struct!
+ *
+ **********************************************************************/
+
+ib_api_status_t
+osm_vendor_init(IN osm_vendor_t * const p_vend,
+ IN osm_log_t * const p_log, IN const uint32_t timeout)
+{
+ osm_vendor_mgt_bind_t *ib_mgt_hdl_p;
+ ib_api_status_t status = IB_SUCCESS;
+
+ OSM_LOG_ENTER(p_log);
+
+ p_vend->p_log = p_log;
+
+ /*
+ * HACK: We need no handle. Assuming the driver is up.
+ */
+ ib_mgt_hdl_p = (osm_vendor_mgt_bind_t *)
+ malloc(sizeof(osm_vendor_mgt_bind_t));
+ if (ib_mgt_hdl_p == NULL) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "osm_vendor_init: ERR 3C06: "
+ "Fail to allocate vendor mgt handle.\n");
+ goto Exit;
+ }
+
+ ib_mgt_hdl_p->smi_init = FALSE;
+ ib_mgt_hdl_p->gsi_init = FALSE;
+ /* cast it into the ib_al_handle_t h_al */
+ p_vend->h_al = (ib_al_handle_t) ib_mgt_hdl_p;
+ p_vend->p_transaction_mgr = NULL;
+ osm_transaction_mgr_init(p_vend);
+ /* p_vend->madw_by_tid_map_p = NULL; */
+ /* __osm_mtl_init_tid_mad_map( p_vend ); */
+ p_vend->timeout = timeout;
+
+Exit:
+ OSM_LOG_EXIT(p_log);
+ return (status);
+}
+
+/**********************************************************************
+ * Create and Initialize osm_vendor_t Object
+ **********************************************************************/
+osm_vendor_t *osm_vendor_new(IN osm_log_t * const p_log,
+ IN const uint32_t timeout)
+{
+ ib_api_status_t status;
+ osm_vendor_t *p_vend;
+
+ OSM_LOG_ENTER(p_log);
+
+ CL_ASSERT(p_log);
+
+ p_vend = malloc(sizeof(*p_vend));
+ if (p_vend != NULL) {
+ memset(p_vend, 0, sizeof(*p_vend));
+ status = osm_vendor_init(p_vend, p_log, timeout);
+ if (status != IB_SUCCESS) {
+ osm_vendor_delete(&p_vend);
+ }
+ } else {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "osm_vendor_new: ERR 3C07: "
+ "Fail to allocate vendor object.\n");
+ }
+
+ OSM_LOG_EXIT(p_log);
+ return (p_vend);
+}
+
+/**********************************************************************
+ * IB_MGT RCV callback
+ *
+ **********************************************************************/
+void
+__osm_mtl_rcv_callback(IN IB_MGT_mad_hndl_t mad_hndl,
+ IN void *private_ctx_p,
+ IN void *payload_p,
+ IN IB_MGT_mad_rcv_desc_t * rcv_remote_info_p)
+{
+ IB_MGT_ret_t status;
+ osm_mtl_bind_info_t *bind_info_p = private_ctx_p;
+ osm_madw_t *req_madw_p = NULL;
+ osm_madw_t *madw_p;
+ osm_vend_wrap_t *p_new_vw;
+ osm_mad_addr_t mad_addr;
+ ib_mad_t *mad_buf_p;
+ osm_log_t *const p_log = bind_info_p->p_vend->p_log;
+
+ OSM_LOG_ENTER(p_log);
+
+ /* if it is a response MAD we mustbe able to get the request */
+ if (ib_mad_is_response((ib_mad_t *) payload_p)) {
+ /* can we find a matching madw by this payload TID */
+ status =
+ osm_transaction_mgr_get_madw_for_tid(bind_info_p->p_vend,
+ (ib_mad_t *) payload_p,
+ &req_madw_p);
+ if (status != IB_MGT_OK) {
+ osm_log(p_log, OSM_LOG_ERROR,
+ "__osm_mtl_rcv_callback: ERR 3C08: "
+ "Error obtaining request madw by TID (%d).\n",
+ status);
+ req_madw_p = NULL;
+ }
+
+ if (req_madw_p == NULL) {
+ osm_log(p_log, OSM_LOG_ERROR,
+ "__osm_mtl_rcv_callback: ERR 3C09: "
+ "Fail to obtain request madw for received MAD.(method=%X attr=%X) Aborting CB.\n",
+ ((ib_mad_t *) payload_p)->method,
+ cl_ntoh16(((ib_mad_t *) payload_p)->attr_id)
+
+ );
+ goto Exit;
+ }
+ }
+
+ /* do we have a request ??? */
+ if (req_madw_p == NULL) {
+
+ /* first arrange an address */
+ __osm_mtl_conv_ibmgt_rcv_desc_to_osm_addr(bind_info_p->p_vend,
+ rcv_remote_info_p,
+ (((ib_mad_t *)
+ payload_p)->
+ mgmt_class ==
+ IB_MCLASS_SUBN_LID)
+ || (((ib_mad_t *)
+ payload_p)->
+ mgmt_class ==
+ IB_MCLASS_SUBN_DIR),
+ &mad_addr);
+
+ osm_log(p_log, OSM_LOG_ERROR,
+ "__osm_mtl_rcv_callback: : "
+ "Received MAD from QP:%X.\n",
+ cl_ntoh32(mad_addr.addr_type.gsi.remote_qp)
+ );
+
+ /* if not - get new osm_madw and arrange it. */
+ /* create the new madw in the pool */
+ madw_p = osm_mad_pool_get(bind_info_p->p_osm_pool,
+ (osm_bind_handle_t) bind_info_p,
+ MAD_BLOCK_SIZE, &mad_addr);
+ if (madw_p == NULL) {
+ osm_log(p_log, OSM_LOG_ERROR,
+ "__osm_mtl_rcv_callback: ERR 3C10: "
+ "Error request for a new madw.\n");
+ goto Exit;
+ }
+ /* HACK: we cust to avoid the const ??? */
+ mad_buf_p = (void *)madw_p->p_mad;
+ } else {
+ /* we have the madw defined during the send and stored in the vend_wrap */
+ /* we need to make sure the wrapper is correctly init there */
+ CL_ASSERT(req_madw_p->vend_wrap.p_resp_madw != 0);
+ madw_p = req_madw_p->vend_wrap.p_resp_madw;
+
+ /* HACK: we do not Support RMPP */
+ CL_ASSERT(madw_p->h_bind);
+ mad_buf_p =
+ osm_vendor_get(madw_p->h_bind, MAD_BLOCK_SIZE,
+ &madw_p->vend_wrap);
+
+ if (mad_buf_p == NULL) {
+ osm_log(p_log, OSM_LOG_ERROR,
+ "__osm_mtl_rcv_callback: ERR 3C11: "
+ "Unable to acquire wire MAD.\n");
+
+ goto Exit;
+ }
+
+ /*
+ Finally, attach the wire MAD to this wrapper.
+ */
+ osm_madw_set_mad(madw_p, mad_buf_p);
+
+ /* also we need to handle the size of the mad since we did not init ... */
+ madw_p->mad_size = MAD_BLOCK_SIZE;
+ }
+
+ /* init some fields of the vendor wrapper */
+ p_new_vw = osm_madw_get_vend_ptr(madw_p);
+ p_new_vw->h_bind = bind_info_p;
+ p_new_vw->size = MAD_BLOCK_SIZE;
+ p_new_vw->p_resp_madw = NULL;
+ p_new_vw->mad_buf_p = mad_buf_p;
+
+ /* HACK: We do not support RMPP in receiving MADS */
+ memcpy(p_new_vw->mad_buf_p, payload_p, MAD_BLOCK_SIZE);
+
+ /* attach the buffer to the wrapper */
+ madw_p->p_mad = mad_buf_p;
+
+ /* we can also make sure we marked the size and bind on the returned madw */
+ madw_p->h_bind = p_new_vw->h_bind;
+
+ /* call the CB */
+ (*bind_info_p->rcv_callback) (madw_p, bind_info_p->client_context,
+ req_madw_p);
+
+Exit:
+ OSM_LOG_EXIT(p_log);
+}
+
+/**********************************************************************
+ * IB_MGT Send callback : invoked after each send
+ *
+ **********************************************************************/
+void
+__osm_mtl_send_callback(IN IB_MGT_mad_hndl_t mad_hndl,
+ IN u_int64_t wrid,
+ IN IB_comp_status_t status, IN void *private_ctx_p)
+{
+ osm_madw_t *madw_p;
+ osm_mtl_bind_info_t *bind_info_p =
+ (osm_mtl_bind_info_t *) private_ctx_p;
+ osm_log_t *const p_log = bind_info_p->p_vend->p_log;
+ osm_vend_wrap_t *p_vw;
+ uint8_t is_resp;
+
+ OSM_LOG_ENTER(p_log);
+
+ /* obtain the madp from the wrid */
+ __osm_set_p_madw_and_resp_by_wrid(wrid, &is_resp, &madw_p);
+
+ osm_log(p_log, OSM_LOG_DEBUG,
+ "__osm_mtl_send_callback: INFO 1008: "
+ "Handling Send of MADW:%p Is Resp:%d.\n", madw_p, is_resp);
+
+ /* we need to handle requests and responses differently */
+ if (is_resp) {
+ if (status != IB_COMP_SUCCESS) {
+ osm_log(p_log, OSM_LOG_ERROR,
+ "__osm_mtl_send_callback: ERR 3C12: "
+ "Error Sending Response MADW:%p.\n", madw_p);
+ } else {
+ osm_log(p_log, OSM_LOG_DEBUG,
+ "__osm_mtl_send_callback: DBG 1008: "
+ "Completed Sending Response MADW:%p.\n",
+ madw_p);
+ }
+
+ /* if we are a response - we need to clean it up */
+ osm_mad_pool_put(bind_info_p->p_osm_pool, madw_p);
+ } else {
+
+ /* this call back is invoked on completion of send - error or not */
+ if (status != IB_COMP_SUCCESS) {
+
+ osm_log(p_log, OSM_LOG_ERROR,
+ "__osm_mtl_send_callback: ERR 3C13: "
+ "Received an Error from IB_MGT Send (%d).\n",
+ status);
+
+ p_vw = osm_madw_get_vend_ptr(madw_p);
+ CL_ASSERT(p_vw);
+
+ /*
+ Return any wrappers to the pool that may have been
+ pre-emptively allocated to handle a receive.
+ */
+ if (p_vw->p_resp_madw) {
+ osm_mad_pool_put(bind_info_p->p_osm_pool,
+ p_vw->p_resp_madw);
+ p_vw->p_resp_madw = NULL;
+ }
+
+ /* invoke the CB */
+ (*bind_info_p->send_err_callback) (bind_info_p->
+ client_context,
+ madw_p);
+ } else {
+ /* successful request send - do nothing - the response will need the
+ out mad */
+ osm_log(p_log, OSM_LOG_DEBUG,
+ "__osm_mtl_send_callback: DBG 1008: "
+ "Completed Sending Request MADW:%p.\n", madw_p);
+ }
+ }
+
+ OSM_LOG_EXIT(p_log);
+}
+
+/**********************************************************************
+ * BINDs a callback (rcv and send error) for a given class and method
+ * defined by the given: osm_bind_info_t
+ **********************************************************************/
+osm_bind_handle_t
+osm_vendor_bind(IN osm_vendor_t * const p_vend,
+ IN osm_bind_info_t * const p_user_bind,
+ IN osm_mad_pool_t * const p_mad_pool,
+ IN osm_vend_mad_recv_callback_t mad_recv_callback,
+ IN osm_vend_mad_send_err_callback_t send_err_callback,
+ IN void *context)
+{
+ ib_net64_t port_guid;
+ osm_mtl_bind_info_t *p_bind = NULL;
+ VAPI_hca_hndl_t hca_hndl;
+ VAPI_hca_id_t hca_id;
+ IB_MGT_mad_type_t mad_type;
+ uint32_t port_num;
+ osm_vendor_mgt_bind_t *ib_mgt_hdl_p;
+ IB_MGT_ret_t mgt_ret;
+
+ OSM_LOG_ENTER(p_vend->p_log);
+
+ CL_ASSERT(p_user_bind);
+ CL_ASSERT(p_mad_pool);
+ CL_ASSERT(mad_recv_callback);
+ CL_ASSERT(send_err_callback);
+
+ /* cast back the AL handle to vendor mgt bind */
+ ib_mgt_hdl_p = (osm_vendor_mgt_bind_t *) p_vend->h_al;
+
+ port_guid = p_user_bind->port_guid;
+
+ osm_log(p_vend->p_log, OSM_LOG_INFO,
+ "osm_vendor_bind: "
+ "Binding to port 0x%" PRIx64 ".\n", cl_ntoh64(port_guid));
+
+ /* obtain the hca name and port num from the guid */
+ osm_log(p_vend->p_log, OSM_LOG_DEBUG,
+ "osm_vendor_bind: "
+ "Finding CA and Port that owns port guid 0x%" PRIx64 ".\n",
+ port_guid);
+
+ mgt_ret =
+ osm_vendor_get_guid_ca_and_port(p_vend, port_guid, &hca_hndl,
+ &hca_id, &port_num);
+ if (mgt_ret != IB_MGT_OK) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "osm_vendor_bind: ERR 3C14: "
+ "Unable to obtain CA and port (%d).\n");
+ goto Exit;
+ }
+
+ /* create the bind object tracking this binding */
+ p_bind = (osm_mtl_bind_info_t *) malloc(sizeof(osm_mtl_bind_info_t));
+ memset(p_bind, 0, sizeof(osm_mtl_bind_info_t));
+ if (p_bind == NULL) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "osm_vendor_bind: ERR 3C15: "
+ "Unable to allocate internal bind object.\n");
+ goto Exit;
+ }
+
+ /* track this bind request info */
+ memcpy(p_bind->hca_id, hca_id, sizeof(VAPI_hca_id_t));
+ p_bind->port_num = port_num;
+ p_bind->p_vend = p_vend;
+ p_bind->client_context = context;
+ p_bind->rcv_callback = mad_recv_callback;
+ p_bind->send_err_callback = send_err_callback;
+ p_bind->p_osm_pool = p_mad_pool;
+
+ CL_ASSERT(p_bind->port_num);
+
+ /*
+ * Get the proper CLASS
+ */
+
+ switch (p_user_bind->mad_class) {
+ case IB_MCLASS_SUBN_LID:
+ case IB_MCLASS_SUBN_DIR:
+ mad_type = IB_MGT_SMI;
+ break;
+
+ case IB_MCLASS_SUBN_ADM:
+ default:
+ mad_type = IB_MGT_GSI;
+ break;
+ }
+
+ /* we split here - based on the type of MADS GSI / SMI */
+ /* HACK: we only support one class registration per SMI/GSI !!! */
+ if (mad_type == IB_MGT_SMI) {
+ /*
+ * SMI CASE
+ */
+
+ /* we do not need to bind the handle if already available */
+ if (ib_mgt_hdl_p->smi_init == FALSE) {
+
+ /* First we have to reg and get the handle for the mad */
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "osm_vendor_bind: "
+ "Binding to IB_MGT SMI of %s port %u\n", hca_id,
+ port_num);
+
+ mgt_ret =
+ IB_MGT_get_handle(hca_id, port_num, IB_MGT_SMI,
+ &(ib_mgt_hdl_p->smi_mads_hdl));
+ if (IB_MGT_OK != mgt_ret) {
+ free(p_bind);
+ p_bind = NULL;
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "osm_vendor_bind: ERR 3C16: "
+ "Error obtaining IB_MGT handle to SMI.\n");
+ goto Exit;
+ }
+
+ /* bind it */
+ mgt_ret = IB_MGT_bind_sm(ib_mgt_hdl_p->smi_mads_hdl);
+ if (IB_MGT_OK != mgt_ret) {
+ free(p_bind);
+ p_bind = NULL;
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "osm_vendor_bind: ERR 3C17: "
+ "Error binding IB_MGT handle to SM.\n");
+ goto Exit;
+ }
+
+ ib_mgt_hdl_p->smi_init = TRUE;
+
+ }
+
+ /* attach to this bind info */
+ p_bind->mad_hndl = ib_mgt_hdl_p->smi_mads_hdl;
+ ib_mgt_hdl_p->smi_p_bind = p_bind;
+
+ /* now register the callback */
+ mgt_ret = IB_MGT_reg_cb(p_bind->mad_hndl,
+ &__osm_mtl_rcv_callback,
+ p_bind,
+ &__osm_mtl_send_callback,
+ p_bind,
+ IB_MGT_RCV_CB_MASK |
+ IB_MGT_SEND_CB_MASK);
+
+ } else {
+ /*
+ * GSI CASE
+ */
+
+ if (ib_mgt_hdl_p->gsi_init == FALSE) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "osm_vendor_bind: " "Binding to IB_MGT GSI\n");
+
+ /* First we have to reg and get the handle for the mad */
+ mgt_ret =
+ IB_MGT_get_handle(hca_id, port_num, IB_MGT_GSI,
+ &(ib_mgt_hdl_p->gsi_mads_hdl));
+ if (IB_MGT_OK != mgt_ret) {
+ free(p_bind);
+ p_bind = NULL;
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "osm_vendor_bind: ERR 3C20: "
+ "Error obtaining IB_MGT handle to GSI.\n");
+ goto Exit;
+ }
+
+ /* bind it */
+ mgt_ret =
+ IB_MGT_bind_gsi_class(ib_mgt_hdl_p->gsi_mads_hdl,
+ p_user_bind->mad_class);
+ if (IB_MGT_OK != mgt_ret) {
+ free(p_bind);
+ p_bind = NULL;
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "osm_vendor_bind: ERR 3C22: "
+ "Error binding IB_MGT handle to GSI.\n");
+ goto Exit;
+ }
+
+ ib_mgt_hdl_p->gsi_init = TRUE;
+
+ /* attach to this bind info */
+ p_bind->mad_hndl = ib_mgt_hdl_p->gsi_mads_hdl;
+
+ /* now register the callback */
+ mgt_ret = IB_MGT_reg_cb(p_bind->mad_hndl,
+ &__osm_mtl_rcv_callback,
+ p_bind,
+ &__osm_mtl_send_callback,
+ p_bind,
+ IB_MGT_RCV_CB_MASK |
+ IB_MGT_SEND_CB_MASK);
+
+ } else {
+ /* we can use the existing handle */
+ p_bind->mad_hndl = ib_mgt_hdl_p->gsi_mads_hdl;
+ mgt_ret = IB_MGT_OK;
+ }
+
+ }
+
+ if (IB_MGT_OK != mgt_ret) {
+ free(p_bind);
+ p_bind = NULL;
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "osm_vendor_bind: ERR 3C23: "
+ "Error binding IB_MGT CB (%d).\n", mgt_ret);
+ goto Exit;
+ }
+
+ /* HACK: Do we need to initialize an address vector ???? */
+
+Exit:
+ OSM_LOG_EXIT(p_vend->p_log);
+ return ((osm_bind_handle_t) p_bind);
+}
+
+/**********************************************************************
+Get a mad from the lower level.
+The osm_vend_wrap_t is a wrapper used to connect the mad to the response.
+**********************************************************************/
+ib_mad_t *osm_vendor_get(IN osm_bind_handle_t h_bind,
+ IN const uint32_t mad_size,
+ IN osm_vend_wrap_t * const p_vw)
+{
+ ib_mad_t *mad_p;
+ osm_mtl_bind_info_t *p_bind = (osm_mtl_bind_info_t *) h_bind;
+ osm_vendor_t *p_vend = p_bind->p_vend;
+
+ OSM_LOG_ENTER(p_vend->p_log);
+
+ CL_ASSERT(p_vw);
+ /* HACK: We know we can not send through IB_MGT */
+ CL_ASSERT(mad_size <= MAD_BLOCK_SIZE);
+
+ /* IB_MGT assumes it is 256 - we must follow */
+ p_vw->size = MAD_BLOCK_SIZE;
+
+ /* allocate it */
+ mad_p = (ib_mad_t *) malloc(p_vw->size);
+ if (mad_p == NULL) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "osm_vendor_get: ERR 3C24: "
+ "Error Obtaining MAD buffer.\n");
+ goto Exit;
+ }
+
+ memset(mad_p, 0, p_vw->size);
+
+ /* track locally */
+ p_vw->mad_buf_p = mad_p;
+ p_vw->h_bind = h_bind;
+ p_vw->p_resp_madw = NULL;
+
+ if (osm_log_get_level(p_vend->p_log) >= OSM_LOG_DEBUG) {
+ osm_log(p_vend->p_log, OSM_LOG_DEBUG,
+ "osm_vendor_get: "
+ "Acquired MAD %p, size = %u.\n", mad_p, p_vw->size);
+ }
+
+Exit:
+ OSM_LOG_EXIT(p_vend->p_log);
+ return (mad_p);
+}
+
+/**********************************************************************
+ * Return a MAD by providing it's wrapper object.
+ **********************************************************************/
+void
+osm_vendor_put(IN osm_bind_handle_t h_bind, IN osm_vend_wrap_t * const p_vw)
+{
+ osm_mtl_bind_info_t *p_bind = (osm_mtl_bind_info_t *) h_bind;
+ osm_vendor_t *p_vend = p_bind->p_vend;
+ osm_madw_t *p_madw;
+
+ OSM_LOG_ENTER(p_vend->p_log);
+
+ CL_ASSERT(p_vw);
+ CL_ASSERT(p_vw->mad_buf_p);
+
+ if (osm_log_get_level(p_vend->p_log) >= OSM_LOG_DEBUG) {
+ osm_log(p_vend->p_log, OSM_LOG_DEBUG,
+ "osm_vendor_put: " "Retiring MAD %p.\n",
+ p_vw->mad_buf_p);
+ }
+
+ /*
+ * We moved the removal of the transaction to immediatly after
+ * it was looked up.
+ */
+
+ /* free the mad but the wrapper is part of the madw object */
+ free(p_vw->mad_buf_p);
+ p_vw->mad_buf_p = NULL;
+ p_madw = PARENT_STRUCT(p_vw, osm_madw_t, vend_wrap);
+ p_madw->p_mad = NULL;
+
+ OSM_LOG_EXIT(p_vend->p_log);
+}
+
+/**********************************************************************
+Actually Send a MAD
+
+This is for internal use by osm_vendor_send and the transaction mgr
+retry too.
+**********************************************************************/
+ib_api_status_t
+osm_mtl_send_mad(IN osm_mtl_bind_info_t * p_bind, IN osm_madw_t * const p_madw)
+{
+ osm_vendor_t *const p_vend = p_bind->p_vend;
+ osm_vend_wrap_t *const p_vw = osm_madw_get_vend_ptr(p_madw);
+ osm_mad_addr_t *const p_mad_addr = osm_madw_get_mad_addr_ptr(p_madw);
+ ib_mad_t *const p_mad = osm_madw_get_mad_ptr(p_madw);
+ ib_api_status_t status;
+ IB_MGT_ret_t mgt_res;
+ IB_ud_av_t av;
+ uint64_t wrid;
+ uint32_t qpn;
+
+ OSM_LOG_ENTER(p_vend->p_log);
+
+ /*
+ * For all sends other than directed route SM MADs,
+ * acquire an address vector for the destination.
+ */
+ if (p_mad->mgmt_class != IB_MCLASS_SUBN_DIR) {
+ __osm_mtl_conv_osm_addr_to_ibmgt_addr(p_mad_addr,
+ p_mad->mgmt_class ==
+ IB_MCLASS_SUBN_LID, &av);
+ } else {
+ /* is a directed route - we need to construct a permissive address */
+ memset(&av, 0, sizeof(av));
+ /* we do not need port number since it is part of the mad_hndl */
+ av.dlid = IB_LID_PERMISSIVE;
+ }
+
+ wrid = __osm_set_wrid_by_p_madw(p_madw);
+
+ /* send it */
+ if ((p_mad->mgmt_class == IB_MCLASS_SUBN_DIR) ||
+ (p_mad->mgmt_class == IB_MCLASS_SUBN_LID)) {
+
+ /* SMI CASE */
+ if (osm_log_is_active(p_vend->p_log, OSM_LOG_DEBUG)) {
+ osm_log(p_vend->p_log, OSM_LOG_DEBUG,
+ "osm_mtl_send_mad: "
+ "av.dlid 0x%X, "
+ "av.static_rate %d, "
+ "av.path_bits %d.\n",
+ cl_ntoh16(av.dlid), av.static_rate,
+ av.src_path_bits);
+ }
+
+ mgt_res = IB_MGT_send_mad(p_bind->mad_hndl, p_mad, /* actual payload */
+ &av, /* address vector */
+ wrid, /* casting the mad wrapper pointer for err cb */
+ p_vend->timeout);
+
+ } else {
+ /* GSI CASE - Support Remote QP */
+ if (osm_log_is_active(p_vend->p_log, OSM_LOG_DEBUG)) {
+ osm_log(p_vend->p_log, OSM_LOG_DEBUG,
+ "osm_mtl_send_mad: "
+ "av.dlid 0x%X, av.static_rate %d, "
+ "av.path_bits %d, remote qp: 0x%06X \n",
+ av.dlid,
+ av.static_rate,
+ av.src_path_bits,
+ cl_ntoh32(p_mad_addr->addr_type.gsi.remote_qp)
+ );
+ }
+
+ /* IBMGT have a bug sending to a QP not 1 -
+ the QPN must be in network order except when it qpn 1 ... */
+ qpn = cl_ntoh32(p_mad_addr->addr_type.gsi.remote_qp);
+
+ mgt_res = IB_MGT_send_mad_to_qp(p_bind->mad_hndl, p_mad, /* actual payload */
+ &av, /* address vector */
+ wrid, /* casting the mad wrapper pointer for err cb */
+ p_vend->timeout, qpn);
+ }
+
+ if (mgt_res != IB_MGT_OK) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "osm_mtl_send_mad: ERR 3C26: "
+ "Error sending mad (%d).\n", mgt_res);
+ if (p_vw->p_resp_madw)
+ osm_mad_pool_put(p_bind->p_osm_pool, p_vw->p_resp_madw);
+ status = IB_ERROR;
+ goto Exit;
+ }
+
+ status = IB_SUCCESS;
+
+Exit:
+ OSM_LOG_EXIT(p_vend->p_log);
+ return (status);
+}
+
+/**********************************************************************
+Send a MAD through.
+
+What is unclear to me is the need for the setting of all the MAD Wrapper
+fields. Seems like the OSM uses these values during it's processing...
+**********************************************************************/
+ib_api_status_t
+osm_vendor_send(IN osm_bind_handle_t h_bind,
+ IN osm_madw_t * const p_madw, IN boolean_t const resp_expected)
+{
+ osm_mtl_bind_info_t *const p_bind = (osm_mtl_bind_info_t *) h_bind;
+ osm_vendor_t *const p_vend = p_bind->p_vend;
+ osm_vend_wrap_t *const p_vw = osm_madw_get_vend_ptr(p_madw);
+ ib_api_status_t status;
+
+ OSM_LOG_ENTER(p_vend->p_log);
+
+ /*
+ * If a response is expected to this MAD, then preallocate
+ * a mad wrapper to contain the wire MAD received in the
+ * response. Allocating a wrapper here allows for easier
+ * failure paths than after we already received the wire mad.
+ */
+ if (resp_expected == TRUE) {
+ /* we track it in the vendor wrapper */
+ p_vw->p_resp_madw =
+ osm_mad_pool_get_wrapper_raw(p_bind->p_osm_pool);
+ if (p_vw->p_resp_madw == NULL) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "osm_vendor_send: ERR 3C27: "
+ "Unable to allocate MAD wrapper.\n");
+ status = IB_INSUFFICIENT_RESOURCES;
+ goto Exit;
+ }
+
+ /* put some minimal info on that wrapper */
+ ((osm_madw_t *) (p_vw->p_resp_madw))->h_bind = h_bind;
+
+ /* we also want to track it in the TID based map */
+ status = osm_transaction_mgr_insert_madw((osm_bind_handle_t)
+ p_bind, p_madw);
+ if (status != IB_SUCCESS) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "osm_vendor_send: ERR 3C25: "
+ "Error inserting request madw by TID (%d).\n",
+ status);
+ }
+
+ } else
+ p_vw->p_resp_madw = NULL;
+
+ /* do the actual send */
+ status = osm_mtl_send_mad(p_bind, p_madw);
+
+Exit:
+ OSM_LOG_EXIT(p_vend->p_log);
+ return (status);
+}
+
+/**********************************************************************
+ * the idea here is to change the content of the bind such that it
+ * will hold the local address used for sending directed route by the SMA.
+ **********************************************************************/
+ib_api_status_t osm_vendor_local_lid_change(IN osm_bind_handle_t h_bind)
+{
+ osm_vendor_t *p_vend = ((osm_mtl_bind_info_t *) h_bind)->p_vend;
+
+ OSM_LOG_ENTER(p_vend->p_log);
+
+ osm_log(p_vend->p_log, OSM_LOG_DEBUG,
+ "osm_vendor_local_lid_change: DEBUG 2202: " "Change of LID.\n");
+
+ OSM_LOG_EXIT(p_vend->p_log);
+
+ return (IB_SUCCESS);
+}
+
+void osm_vendor_set_sm(IN osm_bind_handle_t h_bind, IN boolean_t is_sm_val)
+{
+ osm_mtl_bind_info_t *p_bind = (osm_mtl_bind_info_t *) h_bind;
+ osm_vendor_t *p_vend = p_bind->p_vend;
+ VAPI_ret_t status;
+ VAPI_hca_attr_t attr_mod;
+ VAPI_hca_attr_mask_t attr_mask;
+
+ OSM_LOG_ENTER(p_vend->p_log);
+
+ memset(&attr_mod, 0, sizeof(attr_mod));
+ memset(&attr_mask, 0, sizeof(attr_mask));
+
+ attr_mod.is_sm = is_sm_val;
+ attr_mask = HCA_ATTR_IS_SM;
+
+ status =
+ VAPI_modify_hca_attr(p_bind->hca_hndl, p_bind->port_num, &attr_mod,
+ &attr_mask);
+ if (status != VAPI_OK) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "osm_vendor_set_sm: ERR 3C28: "
+ "Unable set 'IS_SM' bit to:%u in port attributes (%d).\n",
+ is_sm_val, status);
+ }
+
+ OSM_LOG_EXIT(p_vend->p_log);
+}
+
+void osm_vendor_set_debug(IN osm_vendor_t * const p_vend, IN int32_t level)
+{
+
+}
+
+#endif /* OSM_VENDOR_INTF_TEST */
diff --git a/contrib/ofed/opensm/libvendor/osm_vendor_mtl_hca_guid.c b/contrib/ofed/opensm/libvendor/osm_vendor_mtl_hca_guid.c
new file mode 100644
index 0000000..0b0b23c
--- /dev/null
+++ b/contrib/ofed/opensm/libvendor/osm_vendor_mtl_hca_guid.c
@@ -0,0 +1,631 @@
+/*
+ * Copyright (c) 2004-2008 Voltaire, Inc. All rights reserved.
+ * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved.
+ * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+#if HAVE_CONFIG_H
+# include <config.h>
+#endif /* HAVE_CONFIG_H */
+
+#if defined(OSM_VENDOR_INTF_MTL) | defined(OSM_VENDOR_INTF_TS)
+#undef IN
+#undef OUT
+#include <stdlib.h>
+#include <vapi_types.h>
+#include <evapi.h>
+#include <vendor/osm_vendor_api.h>
+#include <opensm/osm_log.h>
+#include <stdio.h>
+
+/********************************************************************************
+ *
+ * Provide the functionality for selecting an HCA Port and Obtaining it's guid.
+ *
+ ********************************************************************************/
+
+/**********************************************************************
+ * Convert the given GID to GUID by copy of it's upper 8 bytes
+ *
+ *
+ **********************************************************************/
+
+ib_api_status_t
+__osm_vendor_gid_to_guid(IN u_int8_t * gid, OUT VAPI_gid_t * guid)
+{
+ memcpy(guid, gid + 8, 8);
+ return (IB_SUCCESS);
+}
+
+/****f* OpenSM: CA Info/osm_ca_info_get_pi_ptr
+ * NAME
+ * osm_ca_info_get_pi_ptr
+ *
+ * DESCRIPTION
+ * Returns a pointer to the port attribute of the specified port
+ * owned by this CA.
+ *
+ * SYNOPSIS
+ */
+static ib_port_attr_t *__osm_ca_info_get_port_attr_ptr(IN const osm_ca_info_t *
+ const p_ca_info,
+ IN const uint8_t index)
+{
+ return (&p_ca_info->p_attr->p_port_attr[index]);
+}
+
+/*
+ * PARAMETERS
+ * p_ca_info
+ * [in] Pointer to a CA Info object.
+ *
+ * index
+ * [in] Port "index" for which to retrieve the port attribute.
+ * The index is the offset into the ca's internal array
+ * of port attributes.
+ *
+ * RETURN VALUE
+ * Returns a pointer to the port attribute of the specified port
+ * owned by this CA.
+ *
+ * NOTES
+ *
+ * SEE ALSO
+ *********/
+
+/********************************************************************************
+ * get the CA names ava`ilable on the system
+ * NOTE: user of this function needs to deallocate p_hca_ids after usage.
+ ********************************************************************************/
+static ib_api_status_t
+__osm_vendor_get_ca_ids(IN osm_vendor_t * const p_vend,
+ IN VAPI_hca_id_t ** const p_hca_ids,
+ IN uint32_t * const p_num_guids)
+{
+ ib_api_status_t status;
+ VAPI_ret_t vapi_res;
+
+ OSM_LOG_ENTER(p_vend->p_log);
+
+ CL_ASSERT(p_hca_ids);
+ CL_ASSERT(p_num_guids);
+
+ /* first call is just to get the number */
+ vapi_res = EVAPI_list_hcas(0, p_num_guids, NULL);
+
+ /* fail ? */
+ if (vapi_res == VAPI_EINVAL_PARAM) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "__osm_vendor_get_ca_ids: ERR 7101: "
+ "Bad parameter in calling: EVAPI_list_hcas. (%d)\n",
+ vapi_res);
+ status = IB_ERROR;
+ goto Exit;
+ }
+
+ /* NO HCA ? */
+ if (*p_num_guids == 0) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "__osm_vendor_get_ca_ids: ERR 7102: "
+ "No available channel adapters.\n");
+ status = IB_INSUFFICIENT_RESOURCES;
+ goto Exit;
+ }
+
+ /* allocate and really call - user of this function needs to deallocate it */
+ *p_hca_ids =
+ (VAPI_hca_id_t *) malloc(*p_num_guids * sizeof(VAPI_hca_id_t));
+
+ /* now call it really */
+ vapi_res = EVAPI_list_hcas(*p_num_guids, p_num_guids, *p_hca_ids);
+
+ /* too many ? */
+ if (vapi_res == VAPI_EAGAIN) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "__osm_vendor_get_ca_ids: ERR 7103: "
+ "More CA GUIDs than allocated array (%d).\n",
+ *p_num_guids);
+ status = IB_ERROR;
+ goto Exit;
+ }
+
+ /* fail ? */
+ if (vapi_res != VAPI_OK) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "__osm_vendor_get_ca_ids: ERR 7104: "
+ "Bad parameter in calling: EVAPI_list_hcas.\n");
+ status = IB_ERROR;
+ goto Exit;
+ }
+
+ if (osm_log_is_active(p_vend->p_log, OSM_LOG_DEBUG)) {
+ osm_log(p_vend->p_log, OSM_LOG_DEBUG,
+ "__osm_vendor_get_ca_ids: "
+ "Detected %u local channel adapters.\n", *p_num_guids);
+ }
+
+ status = IB_SUCCESS;
+
+Exit:
+ OSM_LOG_EXIT(p_vend->p_log);
+ return (status);
+}
+
+/**********************************************************************
+ * Initialize an Info Struct for the Given HCA by its Id
+ **********************************************************************/
+static ib_api_status_t
+__osm_ca_info_init(IN osm_vendor_t * const p_vend,
+ IN VAPI_hca_id_t ca_id, OUT osm_ca_info_t * const p_ca_info)
+{
+ ib_api_status_t status = IB_ERROR;
+ VAPI_ret_t vapi_res;
+ VAPI_hca_hndl_t hca_hndl;
+ VAPI_hca_vendor_t hca_vendor;
+ VAPI_hca_cap_t hca_cap;
+ VAPI_hca_port_t hca_port;
+ uint8_t port_num;
+ IB_gid_t *p_port_gid;
+ uint16_t maxNumGids;
+
+ OSM_LOG_ENTER(p_vend->p_log);
+
+ /* get the HCA handle */
+ vapi_res = EVAPI_get_hca_hndl(ca_id, &hca_hndl);
+ if (vapi_res != VAPI_OK) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "__osm_ca_info_init: ERR 7105: "
+ "Fail to get HCA handle (%u).\n", vapi_res);
+ goto Exit;
+ }
+
+ if (osm_log_is_active(p_vend->p_log, OSM_LOG_DEBUG)) {
+ osm_log(p_vend->p_log, OSM_LOG_DEBUG,
+ "__osm_ca_info_init: " "Querying CA %s.\n", ca_id);
+ }
+
+ /* query and get the HCA capability */
+ vapi_res = VAPI_query_hca_cap(hca_hndl, &hca_vendor, &hca_cap);
+ if (vapi_res != VAPI_OK) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "__osm_ca_info_init: ERR 7106: "
+ "Fail to get HCA Capabilities (%u).\n", vapi_res);
+ goto Exit;
+ }
+
+ /* get the guid of the HCA */
+ memcpy(&(p_ca_info->guid), hca_cap.node_guid, 8 * sizeof(u_int8_t));
+ p_ca_info->attr_size = 1;
+ p_ca_info->p_attr = (ib_ca_attr_t *) malloc(sizeof(ib_ca_attr_t));
+ memcpy(&(p_ca_info->p_attr->ca_guid), hca_cap.node_guid,
+ 8 * sizeof(u_int8_t));
+
+ /* now obtain the attributes of the ports */
+ p_ca_info->p_attr->num_ports = hca_cap.phys_port_num;
+ p_ca_info->p_attr->p_port_attr =
+ (ib_port_attr_t *) malloc(hca_cap.phys_port_num *
+ sizeof(ib_port_attr_t));
+
+ for (port_num = 0; port_num < p_ca_info->p_attr->num_ports; port_num++) {
+
+ /* query the port attributes */
+ vapi_res =
+ VAPI_query_hca_port_prop(hca_hndl, port_num + 1, &hca_port);
+ if (vapi_res != VAPI_OK) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "__osm_ca_info_init: ERR 7107: "
+ "Fail to get HCA Port Attributes (%d).\n",
+ vapi_res);
+ goto Exit;
+ }
+
+ /* first call to know the size of the gid table */
+ vapi_res =
+ VAPI_query_hca_gid_tbl(hca_hndl, port_num + 1, 0,
+ &maxNumGids, NULL);
+ p_port_gid = (IB_gid_t *) malloc(maxNumGids * sizeof(IB_gid_t));
+
+ vapi_res =
+ VAPI_query_hca_gid_tbl(hca_hndl, port_num + 1, maxNumGids,
+ &maxNumGids, p_port_gid);
+ if (vapi_res != VAPI_OK) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "__osm_ca_info_init: ERR 7108: "
+ "Fail to get HCA Port GID (%d).\n", vapi_res);
+ goto Exit;
+ }
+
+ __osm_vendor_gid_to_guid(p_port_gid[0],
+ (IB_gid_t *) & p_ca_info->p_attr->
+ p_port_attr[port_num].port_guid);
+ p_ca_info->p_attr->p_port_attr[port_num].lid = hca_port.lid;
+ p_ca_info->p_attr->p_port_attr[port_num].link_state =
+ hca_port.state;
+ p_ca_info->p_attr->p_port_attr[port_num].sm_lid =
+ hca_port.sm_lid;
+
+ free(p_port_gid);
+ }
+
+ status = IB_SUCCESS;
+Exit:
+ OSM_LOG_EXIT(p_vend->p_log);
+ return (status);
+}
+
+void
+osm_ca_info_destroy(IN osm_vendor_t * const p_vend,
+ IN osm_ca_info_t * const p_ca_info)
+{
+ OSM_LOG_ENTER(p_vend->p_log);
+
+ if (p_ca_info->p_attr) {
+ if (p_ca_info->p_attr->num_ports) {
+ free(p_ca_info->p_attr->p_port_attr);
+ }
+ free(p_ca_info->p_attr);
+ }
+
+ free(p_ca_info);
+
+ OSM_LOG_EXIT(p_vend->p_log);
+}
+
+/**********************************************************************
+ * Fill in the array of port_attr with all available ports on ALL the
+ * avilable CAs on this machine.
+ * ALSO -
+ * UPDATE THE VENDOR OBJECT LIST OF CA_INFO STRUCTS
+ **********************************************************************/
+ib_api_status_t
+osm_vendor_get_all_port_attr(IN osm_vendor_t * const p_vend,
+ IN ib_port_attr_t * const p_attr_array,
+ IN uint32_t * const p_num_ports)
+{
+ ib_api_status_t status;
+
+ uint32_t ca;
+ uint32_t ca_count;
+ uint32_t port_count = 0;
+ uint8_t port_num;
+ uint32_t total_ports = 0;
+ VAPI_hca_id_t *p_ca_ids = NULL;
+ osm_ca_info_t *p_ca_info;
+
+ OSM_LOG_ENTER(p_vend->p_log);
+
+ CL_ASSERT(p_vend);
+
+ /*
+ * 1) Determine the number of CA's
+ * 2) Allocate an array big enough to hold the ca info objects.
+ * 3) Call again to retrieve the guids.
+ */
+ status = __osm_vendor_get_ca_ids(p_vend, &p_ca_ids, &ca_count);
+ if (status != IB_SUCCESS) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "osm_vendor_get_all_port_attr: ERR 7109: "
+ "Fail to get CA Ids.\n");
+ goto Exit;
+ }
+
+ /* we keep track of all the CAs in this info array */
+ p_vend->p_ca_info = malloc(ca_count * sizeof(*p_vend->p_ca_info));
+ if (p_vend->p_ca_info == NULL) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "osm_vendor_get_all_port_attr: ERR 7110: "
+ "Unable to allocate CA information array.\n");
+ goto Exit;
+ }
+
+ memset(p_vend->p_ca_info, 0, ca_count * sizeof(*p_vend->p_ca_info));
+ p_vend->ca_count = ca_count;
+
+ /*
+ * For each CA, retrieve the CA info attributes
+ */
+ for (ca = 0; ca < ca_count; ca++) {
+ p_ca_info = &p_vend->p_ca_info[ca];
+
+ status = __osm_ca_info_init(p_vend, p_ca_ids[ca], p_ca_info);
+
+ if (status != IB_SUCCESS) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "osm_vendor_get_all_port_attr: ERR 7111: "
+ "Unable to initialize CA Info object (%s).\n",
+ ib_get_err_str(status));
+ }
+
+ total_ports += osm_ca_info_get_num_ports(p_ca_info);
+
+ osm_log(p_vend->p_log, OSM_LOG_DEBUG,
+ "osm_vendor_get_all_port_attr: "
+ "osm_vendor_get_all_port_attr: %u got %u ports total:%u\n",
+ ca, osm_ca_info_get_num_ports(p_ca_info), total_ports);
+
+ }
+
+ /*
+ * If the user supplied enough storage, return the port guids,
+ * otherwise, return the appropriate error.
+ */
+ if (*p_num_ports >= total_ports) {
+ for (ca = 0; ca < ca_count; ca++) {
+ uint32_t num_ports;
+
+ p_ca_info = &p_vend->p_ca_info[ca];
+
+ num_ports = osm_ca_info_get_num_ports(p_ca_info);
+
+ for (port_num = 0; port_num < num_ports; port_num++) {
+ p_attr_array[port_count] =
+ *__osm_ca_info_get_port_attr_ptr(p_ca_info,
+ port_num);
+ port_count++;
+ }
+ }
+ } else {
+ status = IB_INSUFFICIENT_MEMORY;
+ goto Exit;
+ }
+
+ status = IB_SUCCESS;
+
+Exit:
+ *p_num_ports = total_ports;
+
+ if (p_ca_ids)
+ free(p_ca_ids);
+
+ OSM_LOG_EXIT(p_vend->p_log);
+ return (status);
+}
+
+/**********************************************************************
+ * Given the vendor obj and a guid
+ * return the ca id and port number that have that guid
+ **********************************************************************/
+
+ib_api_status_t
+osm_vendor_get_guid_ca_and_port(IN osm_vendor_t * const p_vend,
+ IN ib_net64_t const guid,
+ OUT VAPI_hca_hndl_t * p_hca_hndl,
+ OUT VAPI_hca_id_t * p_hca_id,
+ OUT uint32_t * p_port_num)
+{
+
+ ib_api_status_t status;
+ VAPI_hca_id_t *p_ca_ids = NULL;
+ VAPI_ret_t vapi_res;
+ VAPI_hca_hndl_t hca_hndl;
+ VAPI_hca_vendor_t hca_vendor;
+ VAPI_hca_cap_t hca_cap;
+ IB_gid_t *p_port_gid = NULL;
+ uint16_t maxNumGids;
+ ib_net64_t port_guid;
+ uint32_t ca, portIdx, ca_count;
+
+ OSM_LOG_ENTER(p_vend->p_log);
+
+ CL_ASSERT(p_vend);
+
+ /*
+ * 1) Determine the number of CA's
+ * 2) Allocate an array big enough to hold the ca info objects.
+ * 3) Call again to retrieve the guids.
+ */
+ status = __osm_vendor_get_ca_ids(p_vend, &p_ca_ids, &ca_count);
+ if (status != IB_SUCCESS) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "osm_vendor_get_guid_ca_and_port: ERR 7112: "
+ "Fail to get CA Ids.\n");
+ goto Exit;
+ }
+
+ /*
+ * For each CA, retrieve the CA info attributes
+ */
+ for (ca = 0; ca < ca_count; ca++) {
+ /* get the HCA handle */
+ vapi_res = EVAPI_get_hca_hndl(p_ca_ids[ca], &hca_hndl);
+ if (vapi_res != VAPI_OK) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "osm_vendor_get_guid_ca_and_port: ERR 7113: "
+ "Fail to get HCA handle (%u).\n", vapi_res);
+ goto Exit;
+ }
+
+ /* get the CA attributes - to know how many ports it has: */
+ if (osm_log_is_active(p_vend->p_log, OSM_LOG_DEBUG)) {
+ osm_log(p_vend->p_log, OSM_LOG_DEBUG,
+ "osm_vendor_get_guid_ca_and_port: "
+ "Querying CA %s.\n", p_ca_ids[ca]);
+ }
+
+ /* query and get the HCA capability */
+ vapi_res = VAPI_query_hca_cap(hca_hndl, &hca_vendor, &hca_cap);
+ if (vapi_res != VAPI_OK) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "osm_vendor_get_guid_ca_and_port: ERR 7114: "
+ "Fail to get HCA Capabilities (%u).\n",
+ vapi_res);
+ goto Exit;
+ }
+
+ /* go over all ports - to obtail their guids */
+ for (portIdx = 0; portIdx < hca_cap.phys_port_num; portIdx++) {
+ vapi_res =
+ VAPI_query_hca_gid_tbl(hca_hndl, portIdx + 1, 0,
+ &maxNumGids, NULL);
+ p_port_gid =
+ (IB_gid_t *) malloc(maxNumGids * sizeof(IB_gid_t));
+
+ /* get the port guid */
+ vapi_res =
+ VAPI_query_hca_gid_tbl(hca_hndl, portIdx + 1,
+ maxNumGids, &maxNumGids,
+ p_port_gid);
+ if (vapi_res != VAPI_OK) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "osm_vendor_get_guid_ca_and_port: ERR 7115: "
+ "Fail to get HCA Port GID (%d).\n",
+ vapi_res);
+ goto Exit;
+ }
+
+ /* convert to SF style */
+ __osm_vendor_gid_to_guid(p_port_gid[0],
+ (VAPI_gid_t *) & port_guid);
+
+ /* finally did we find it ? */
+ if (port_guid == guid) {
+ *p_hca_hndl = hca_hndl;
+ memcpy(p_hca_id, p_ca_ids[ca],
+ sizeof(VAPI_hca_id_t));
+ *p_port_num = portIdx + 1;
+ status = IB_SUCCESS;
+ goto Exit;
+ }
+
+ free(p_port_gid);
+ p_port_gid = NULL;
+ } /* ALL PORTS */
+ } /* all HCAs */
+
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "osm_vendor_get_guid_ca_and_port: ERR 7116: "
+ "Fail to find HCA and Port for Port Guid 0x%" PRIx64 "\n",
+ cl_ntoh64(guid));
+ status = IB_INVALID_GUID;
+
+Exit:
+ if (p_ca_ids != NULL)
+ free(p_ca_ids);
+ if (p_port_gid != NULL)
+ free(p_port_gid);
+ OSM_LOG_EXIT(p_vend->p_log);
+ return (status);
+}
+
+#ifdef __TEST_HCA_GUID__
+
+#define GUID_ARRAY_SIZE 64
+
+#include <stdio.h>
+
+ib_net64_t get_port_guid()
+{
+ uint32_t i;
+ uint32_t choice = 0;
+ boolean_t done_flag = FALSE;
+ ib_api_status_t status;
+ uint32_t num_ports = GUID_ARRAY_SIZE;
+ ib_port_attr_t attr_array[GUID_ARRAY_SIZE];
+ VAPI_hca_id_t ca_id;
+ uint32_t portNum;
+ osm_vendor_t vend;
+ osm_vendor_t *p_vend;
+ osm_log_t *p_osm_log, tlog;
+
+ p_osm_log = &tlog;
+
+ status = osm_log_init(p_osm_log, FALSE);
+ if (status != IB_SUCCESS)
+ return (status);
+
+ osm_log(p_osm_log, OSM_LOG_FUNCS, "get_port_guid: [\n");
+
+ p_vend = &vend;
+ p_vend->p_log = p_osm_log;
+
+ /*
+ * Call the transport layer for a list of local port
+ * GUID values.
+ */
+ status = osm_vendor_get_all_port_attr(p_vend, attr_array, &num_ports);
+ if (status != IB_SUCCESS) {
+ printf("\nError from osm_opensm_init (%x)\n", status);
+ return (0);
+ }
+
+ if (num_ports == 0) {
+ printf("\nNo local ports detected!\n");
+ return (0);
+ }
+
+ while (done_flag == FALSE) {
+ printf("\nChoose a local port number with which to bind:\n\n");
+ for (i = 0; i < num_ports; i++) {
+ /*
+ * Print the index + 1 since by convention, port numbers
+ * start with 1 on host channel adapters.
+ */
+
+ printf("\t%u: GUID = 0x%8" PRIx64
+ ", lid = 0x%04X, state = %s\n", i + 1,
+ cl_ntoh64(attr_array[i].port_guid),
+ cl_ntoh16(attr_array[i].lid),
+ ib_get_port_state_str(attr_array[i].link_state));
+ }
+
+ printf("\nEnter choice (1-%u): ", i);
+ fflush(stdout);
+ scanf("%u", &choice);
+ if (choice > num_ports)
+ printf("\nError: Lame choice!\n");
+ else
+ done_flag = TRUE;
+ }
+
+ status =
+ osm_vendor_get_guid_ca_and_port(p_vend,
+ attr_array[choice - 1].port_guid,
+ &ca_id, &portNum);
+ if (status != IB_SUCCESS) {
+ printf("Error obtaining back the HCA and Port\n");
+ return (0);
+ }
+
+ printf("Selected: CA:%s Port:%d\n", ca_id, portNum);
+
+ return (attr_array[choice - 1].port_guid);
+}
+
+int main(int argc, char **argv)
+{
+ get_port_guid();
+ return (0);
+}
+
+#endif
+
+#endif
diff --git a/contrib/ofed/opensm/libvendor/osm_vendor_mtl_transaction_mgr.c b/contrib/ofed/opensm/libvendor/osm_vendor_mtl_transaction_mgr.c
new file mode 100644
index 0000000..5ddfe84
--- /dev/null
+++ b/contrib/ofed/opensm/libvendor/osm_vendor_mtl_transaction_mgr.c
@@ -0,0 +1,546 @@
+/*
+ * Copyright (c) 2004-2008 Voltaire, Inc. All rights reserved.
+ * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved.
+ * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+#if HAVE_CONFIG_H
+# include <config.h>
+#endif /* HAVE_CONFIG_H */
+
+#include <math.h>
+#include <stdlib.h>
+#include <opensm/osm_helper.h>
+#include <opensm/osm_log.h>
+#include <vendor/osm_vendor.h>
+#include <vendor/osm_vendor_api.h>
+#include <opensm/osm_mad_pool.h>
+
+#if defined(OSM_VENDOR_INTF_MTL) | defined(OSM_VENDOR_INTF_TS)
+
+#include <vendor/osm_vendor_mtl_transaction_mgr.h>
+#ifdef OSM_VENDOR_INTF_MTL
+#include <vendor/osm_mtl_bind.h>
+#endif
+
+/* this is the callback function of the timer */
+void __osm_transaction_mgr_callback(IN void *context)
+{
+ osm_transaction_mgr_t *trans_mgr_p;
+ osm_vendor_t *p_vend = (osm_vendor_t *) context;
+ cl_list_item_t *p_list_item;
+ cl_list_item_t *p_list_next_item;
+ osm_madw_req_t *osm_madw_req_p;
+ uint64_t current_time; /* [usec] */
+ uint32_t new_timeout; /* [msec] */
+ cl_status_t cl_status;
+ ib_mad_t *p_mad;
+#ifdef OSM_VENDOR_INTF_MTL
+ osm_mtl_bind_info_t *p_bind;
+#else
+ osm_ts_bind_info_t *p_bind;
+#endif
+ cl_list_t tmp_madw_p_list; /* this list will include all the madw_p that should be removed. */
+ cl_list_t retry_madw_p_list; /* this list will include all the madw_p that were retried and need to be removed. */
+ osm_madw_t *madw_p;
+
+ OSM_LOG_ENTER(p_vend->p_log);
+
+ trans_mgr_p = (osm_transaction_mgr_t *) p_vend->p_transaction_mgr;
+
+ /* initialize the tmp_madw_p_list */
+ cl_list_construct(&tmp_madw_p_list);
+ cl_status = cl_list_init(&tmp_madw_p_list, 50);
+ if (cl_status != CL_SUCCESS) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "__osm_transaction_mgr_callback : ERROR 1000: "
+ "Failed to create tmp_madw_p_list\n");
+ }
+
+ cl_list_construct(&retry_madw_p_list);
+ cl_status = cl_list_init(&retry_madw_p_list, 50);
+ if (cl_status != CL_SUCCESS) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "__osm_transaction_mgr_callback : ERROR 1000: "
+ "Failed to create retry_madw_p_list\n");
+ }
+
+ current_time = cl_get_time_stamp();
+ cl_spinlock_acquire(&(trans_mgr_p->transaction_mgr_lock));
+ p_list_item = cl_qlist_head(trans_mgr_p->madw_reqs_list_p);
+ if (p_list_item == cl_qlist_end(trans_mgr_p->madw_reqs_list_p)) {
+ /* the list is empty - nothing to do */
+ cl_spinlock_release(&trans_mgr_p->transaction_mgr_lock);
+ osm_log(p_vend->p_log, OSM_LOG_DEBUG,
+ "__osm_transaction_mgr_callback : Nothing to do\n");
+ goto Exit;
+ }
+
+ /* non empty list: */
+
+ /* get the osm_madw_req_p */
+ osm_madw_req_p = PARENT_STRUCT(p_list_item, osm_madw_req_t, list_item);
+
+ while (osm_madw_req_p->waking_time <= current_time) {
+ /* this object was supposed to have gotten a response */
+ /* we need to decide if we need to retry or done with it. */
+ if (osm_madw_req_p->retry_cnt > 0) {
+ /* add to the list of the retrys : */
+ cl_list_insert_tail(&retry_madw_p_list, osm_madw_req_p);
+
+ /* update wakeup time and retry count */
+ osm_madw_req_p->waking_time =
+ p_vend->timeout * 1000 + cl_get_time_stamp();
+ osm_madw_req_p->retry_cnt--;
+
+ /* make sure we will get some timer call if not earlier */
+ osm_log(p_vend->p_log, OSM_LOG_DEBUG,
+ "__osm_transaction_mgr_callback : Timer restart:%u\n",
+ p_vend->timeout);
+
+ cl_status =
+ cl_timer_start(&trans_mgr_p->madw_list_timer,
+ p_vend->timeout);
+
+ /* go to the next object and check if it also needs to be removed - didn't receive response */
+ /* we need to do it before we move current item to the end of the list */
+ p_list_next_item = cl_qlist_next(p_list_item);
+
+ /* remove from the head */
+ cl_qlist_remove_item(trans_mgr_p->madw_reqs_list_p,
+ &(osm_madw_req_p->list_item));
+
+ /* insert the object to the qlist and the qmap */
+ cl_qlist_insert_tail(trans_mgr_p->madw_reqs_list_p,
+ &(osm_madw_req_p->list_item));
+
+ } else {
+ /* go to the next object and check if it also needs to be removed - didn't receive response */
+ p_list_next_item = cl_qlist_next(p_list_item);
+
+ /* remove from the head */
+ cl_qlist_remove_item(trans_mgr_p->madw_reqs_list_p,
+ &(osm_madw_req_p->list_item));
+
+ /* add it to the tmp_madw_p_list to be removed */
+ cl_list_insert_tail(&tmp_madw_p_list,
+ osm_madw_req_p->p_madw);
+ osm_log(p_vend->p_log, OSM_LOG_DEBUG,
+ "__osm_transaction_mgr_callback : Found failed transaction madw: %p\n",
+ osm_madw_req_p->p_madw);
+ }
+
+ /* Advance */
+ p_list_item = p_list_next_item;
+ if (p_list_item == cl_qlist_end(trans_mgr_p->madw_reqs_list_p)) {
+ /* the list is empty - nothing to do */
+ break;
+ }
+
+ /* get the osm_madw_req_p */
+ osm_madw_req_p =
+ PARENT_STRUCT(p_list_item, osm_madw_req_t, list_item);
+ }
+
+ /* look at the current p_list_item. If it is not the end item - then we need to */
+ /* re-start the timer */
+ if (p_list_item != cl_qlist_end(trans_mgr_p->madw_reqs_list_p)) {
+ /* get the osm_madw_req_p */
+ osm_madw_req_p =
+ PARENT_STRUCT(p_list_item, osm_madw_req_t, list_item);
+
+ /* we have the object that still didn't get response - re-start the timer */
+ /* start the timer to the timeout (in miliseconds) */
+ new_timeout =
+ (osm_madw_req_p->waking_time - cl_get_time_stamp()) / 1000 +
+ 1;
+ cl_status =
+ cl_timer_start(&trans_mgr_p->madw_list_timer, new_timeout);
+ osm_log(p_vend->p_log, OSM_LOG_DEBUG,
+ "__osm_transaction_mgr_callback : Timer restart:%u\n",
+ new_timeout);
+
+ if (cl_status != CL_SUCCESS) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "__osm_transaction_mgr_callback : ERROR 1000: "
+ "Failed to start timer\n");
+ }
+ }
+ /* if not empty - retry on retry list: */
+ if (!cl_is_list_empty(&retry_madw_p_list)) {
+
+ /* remove all elements that were retried: */
+ osm_madw_req_p =
+ (osm_madw_req_t
+ *) (cl_list_remove_head(&retry_madw_p_list));
+ while (osm_madw_req_p != NULL) {
+
+ /* resend: */
+ osm_log(p_vend->p_log, OSM_LOG_DEBUG,
+ "__osm_transaction_mgr_callback : "
+ "Retry %d of madw %p\n",
+ OSM_DEFAULT_RETRY_COUNT -
+ osm_madw_req_p->retry_cnt,
+ osm_madw_req_p->p_madw);
+
+ /* actually send it */
+#ifdef OSM_VENDOR_INTF_MTL
+ osm_mtl_send_mad((osm_mtl_bind_info_t *)
+ osm_madw_req_p->p_bind,
+ osm_madw_req_p->p_madw);
+#else
+ ib_api_status_t
+ osm_ts_send_mad(osm_ts_bind_info_t * p_bind,
+ osm_madw_t * const p_madw);
+ osm_ts_send_mad((osm_ts_bind_info_t *) osm_madw_req_p->
+ p_bind, osm_madw_req_p->p_madw);
+#endif
+ /* next one */
+ osm_madw_req_p =
+ (osm_madw_req_t
+ *) (cl_list_remove_head(&retry_madw_p_list));
+ }
+ }
+
+ /* if the tmp_madw_p_list has elements - need to call the send_err_callback */
+ madw_p = (osm_madw_t *) (cl_list_remove_head(&tmp_madw_p_list));
+ while (madw_p != NULL) {
+ /* need to remove it from pool */
+
+ /* obtain the madw_p stored as the wrid in the send call */
+ p_mad = osm_madw_get_mad_ptr(madw_p);
+ p_bind = madw_p->h_bind;
+ /*
+ Return any wrappers to the pool that may have been
+ pre-emptively allocated to handle a receive.
+ */
+ if (madw_p->vend_wrap.p_resp_madw) {
+#ifdef OSM_VENDOR_INTF_MTL
+ osm_mad_pool_put(p_bind->p_osm_pool,
+ madw_p->vend_wrap.p_resp_madw);
+#else
+ osm_mad_pool_put(p_bind->p_osm_pool,
+ madw_p->vend_wrap.p_resp_madw);
+#endif
+ madw_p->vend_wrap.p_resp_madw = NULL;
+ }
+
+ /* invoke the CB */
+ (*(osm_vend_mad_send_err_callback_t)
+ (p_bind->send_err_callback)) (p_bind->client_context, madw_p);
+ madw_p = (osm_madw_t *) (cl_list_remove_head(&tmp_madw_p_list));
+ }
+
+Exit:
+ OSM_LOG_EXIT(p_vend->p_log);
+
+}
+
+/*
+ * Construct and Initialize
+ */
+
+void osm_transaction_mgr_init(IN osm_vendor_t * const p_vend)
+{
+ cl_status_t cl_status;
+ osm_transaction_mgr_t *trans_mgr_p;
+ OSM_LOG_ENTER(p_vend->p_log);
+
+ CL_ASSERT(p_vend->p_transaction_mgr == NULL);
+
+ (osm_transaction_mgr_t *) p_vend->p_transaction_mgr =
+ (osm_transaction_mgr_t *) malloc(sizeof(osm_transaction_mgr_t));
+
+ trans_mgr_p = (osm_transaction_mgr_t *) p_vend->p_transaction_mgr;
+
+ /* construct lock object */
+ cl_spinlock_construct(&(trans_mgr_p->transaction_mgr_lock));
+ CL_ASSERT(cl_spinlock_init(&(trans_mgr_p->transaction_mgr_lock)) ==
+ CL_SUCCESS);
+
+ /* initialize the qlist */
+ trans_mgr_p->madw_reqs_list_p =
+ (cl_qlist_t *) malloc(sizeof(cl_qlist_t));
+ cl_qlist_init(trans_mgr_p->madw_reqs_list_p);
+
+ /* initialize the qmap */
+ trans_mgr_p->madw_by_tid_map_p =
+ (cl_qmap_t *) malloc(sizeof(cl_qmap_t));
+ cl_qmap_init(trans_mgr_p->madw_by_tid_map_p);
+
+ /* create the timer used by the madw_req_list */
+ cl_timer_construct(&(trans_mgr_p->madw_list_timer));
+
+ /* init the timer with timeout. */
+ cl_status = cl_timer_init(&trans_mgr_p->madw_list_timer,
+ __osm_transaction_mgr_callback, p_vend);
+
+ if (cl_status != CL_SUCCESS) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "osm_transaction_mgr_init : ERROR 1000: "
+ "Failed to initialize madw_reqs_list timer\n");
+ }
+ OSM_LOG_EXIT(p_vend->p_log);
+}
+
+void osm_transaction_mgr_destroy(IN osm_vendor_t * const p_vend)
+{
+ osm_transaction_mgr_t *trans_mgr_p;
+ cl_list_item_t *p_list_item;
+ cl_map_item_t *p_map_item;
+ osm_madw_req_t *osm_madw_req_p;
+
+ OSM_LOG_ENTER(p_vend->p_log);
+
+ trans_mgr_p = (osm_transaction_mgr_t *) p_vend->p_transaction_mgr;
+
+ if (p_vend->p_transaction_mgr != NULL) {
+ /* we need to get a lock */
+ cl_spinlock_acquire(&trans_mgr_p->transaction_mgr_lock);
+
+ /* go over all the items in the list and remove them */
+ p_list_item =
+ cl_qlist_remove_head(trans_mgr_p->madw_reqs_list_p);
+ while (p_list_item !=
+ cl_qlist_end(trans_mgr_p->madw_reqs_list_p)) {
+ osm_madw_req_p = (osm_madw_req_t *) p_list_item;
+
+ if (osm_madw_req_p->p_madw->p_mad)
+ osm_log(p_vend->p_log, OSM_LOG_DEBUG,
+ "osm_transaction_mgr_destroy: "
+ "Found outstanding MADW:%p TID:<0x%"
+ PRIx64 ">.\n", osm_madw_req_p->p_madw,
+ osm_madw_req_p->p_madw->p_mad->
+ trans_id);
+ else
+ osm_log(p_vend->p_log, OSM_LOG_DEBUG,
+ "osm_transaction_mgr_destroy: "
+ "Found outstanding MADW:%p TID:UNDEFINED.\n",
+ osm_madw_req_p->p_madw);
+
+ /* each item - remove it from the map */
+ p_map_item = &(osm_madw_req_p->map_item);
+ cl_qmap_remove_item(trans_mgr_p->madw_by_tid_map_p,
+ p_map_item);
+ /* free the item */
+ free(osm_madw_req_p);
+ p_list_item =
+ cl_qlist_remove_head(trans_mgr_p->madw_reqs_list_p);
+ }
+ /* free the qlist and qmap */
+ free(trans_mgr_p->madw_reqs_list_p);
+ free(trans_mgr_p->madw_by_tid_map_p);
+ /* reliease and destroy the lock */
+ cl_spinlock_release(&trans_mgr_p->transaction_mgr_lock);
+ cl_spinlock_destroy(&(trans_mgr_p->transaction_mgr_lock));
+ /* destroy the timer */
+ cl_timer_trim(&trans_mgr_p->madw_list_timer, 1);
+ cl_timer_destroy(&trans_mgr_p->madw_list_timer);
+ /* free the transaction_manager object */
+ free(trans_mgr_p);
+ trans_mgr_p = NULL;
+ }
+
+ OSM_LOG_EXIT(p_vend->p_log);
+}
+
+ib_api_status_t
+osm_transaction_mgr_insert_madw(IN osm_bind_handle_t * const p_bind,
+ IN osm_madw_t * p_madw)
+{
+#ifdef OSM_VENDOR_INTF_MTL
+ osm_vendor_t *const p_vend = ((osm_mtl_bind_info_t *) p_bind)->p_vend;
+#else
+ osm_vendor_t *const p_vend = ((osm_ts_bind_info_t *) p_bind)->p_vend;
+#endif
+ osm_transaction_mgr_t *trans_mgr_p;
+ osm_madw_req_t *osm_madw_req_p;
+ uint64_t timeout;
+ uint64_t waking_time;
+ cl_status_t cl_status;
+ uint64_t key;
+ const ib_mad_t *mad_p = p_madw->p_mad;
+
+ OSM_LOG_ENTER(p_vend->p_log);
+
+ CL_ASSERT(mad_p);
+
+ trans_mgr_p = (osm_transaction_mgr_t *) p_vend->p_transaction_mgr;
+
+ timeout = (uint64_t) (p_vend->timeout) * 1000; /* change the miliseconds value of timeout to microseconds. */
+ waking_time = timeout + cl_get_time_stamp();
+
+ osm_madw_req_p = (osm_madw_req_t *) malloc(sizeof(osm_madw_req_t));
+
+ osm_madw_req_p->p_madw = p_madw;
+ osm_madw_req_p->waking_time = waking_time;
+ osm_madw_req_p->retry_cnt = OSM_DEFAULT_RETRY_COUNT;
+ osm_madw_req_p->p_bind = p_bind;
+
+ osm_log(p_vend->p_log, OSM_LOG_DEBUG,
+ "osm_transaction_mgr_insert_madw: "
+ "Inserting MADW:%p with waking_time: <0x%" PRIx64 "> TID:<0x%"
+ PRIx64 ">.\n", p_madw, waking_time, p_madw->p_mad->trans_id);
+
+ /* Get the lock on the manager */
+ cl_spinlock_acquire(&(trans_mgr_p->transaction_mgr_lock));
+ /* If the list is empty - need to start the timer with timer of timeout (in miliseconds) */
+ if (cl_is_qlist_empty(trans_mgr_p->madw_reqs_list_p)) {
+ /* stop the timer if it is running */
+ cl_timer_stop(&trans_mgr_p->madw_list_timer);
+
+ /* start the timer to the timeout (in miliseconds) */
+ cl_status = cl_timer_start(&trans_mgr_p->madw_list_timer,
+ p_vend->timeout);
+ if (cl_status != CL_SUCCESS) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "osm_transaction_mgr_insert_madw : ERROR 1000: "
+ "Failed to start timer\n");
+ }
+ }
+
+ /* insert the object to the qlist and the qmap */
+ cl_qlist_insert_tail(trans_mgr_p->madw_reqs_list_p,
+ &(osm_madw_req_p->list_item));
+ /* get the key */
+ key = (uint64_t) mad_p->trans_id;
+ cl_qmap_insert(trans_mgr_p->madw_by_tid_map_p, key,
+ &(osm_madw_req_p->map_item));
+ cl_spinlock_release(&trans_mgr_p->transaction_mgr_lock);
+
+ OSM_LOG_EXIT(p_vend->p_log);
+
+ return (IB_SUCCESS);
+}
+
+ib_api_status_t
+osm_transaction_mgr_erase_madw(IN osm_vendor_t * const p_vend,
+ IN ib_mad_t * p_mad)
+{
+ osm_transaction_mgr_t *trans_mgr_p;
+ osm_madw_req_t *osm_madw_req_p;
+ uint64_t key;
+ cl_map_item_t *p_map_item;
+ OSM_LOG_ENTER(p_vend->p_log);
+
+ trans_mgr_p = (osm_transaction_mgr_t *) p_vend->p_transaction_mgr;
+
+ key = (uint64_t) p_mad->trans_id;
+ osm_log(p_vend->p_log, OSM_LOG_DEBUG,
+ "osm_transaction_mgr_erase_madw: "
+ "Removing TID:<0x%" PRIx64 ">.\n", p_mad->trans_id);
+
+ cl_spinlock_acquire(&trans_mgr_p->transaction_mgr_lock);
+ p_map_item = cl_qmap_get(trans_mgr_p->madw_by_tid_map_p, key);
+ if (p_map_item != cl_qmap_end(trans_mgr_p->madw_by_tid_map_p)) {
+ /* we found such an item. */
+ /* get the osm_madw_req_p */
+ osm_madw_req_p =
+ PARENT_STRUCT(p_map_item, osm_madw_req_t, map_item);
+
+ /* remove the item from the qlist */
+ cl_qlist_remove_item(trans_mgr_p->madw_reqs_list_p,
+ &(osm_madw_req_p->list_item));
+ /* remove the item from the qmap */
+ cl_qmap_remove_item(trans_mgr_p->madw_by_tid_map_p,
+ &(osm_madw_req_p->map_item));
+
+ osm_log(p_vend->p_log, OSM_LOG_DEBUG,
+ "osm_transaction_mgr_erase_madw: "
+ "Removed TID:<0x%" PRIx64 ">.\n", p_mad->trans_id);
+
+ /* free the item */
+ free(osm_madw_req_p);
+ } else {
+ osm_log(p_vend->p_log, OSM_LOG_DEBUG,
+ "osm_transaction_mgr_erase_madw: "
+ "osm_transaction_mgr_erase_madw:<0x%" PRIx64
+ "> NOT FOUND.\n", p_mad->trans_id);
+ }
+ cl_spinlock_release(&trans_mgr_p->transaction_mgr_lock);
+ OSM_LOG_EXIT(p_vend->p_log);
+
+ return (IB_SUCCESS);
+}
+
+ib_api_status_t
+osm_transaction_mgr_get_madw_for_tid(IN osm_vendor_t * const p_vend,
+ IN ib_mad_t * const p_mad,
+ OUT osm_madw_t ** req_madw_p)
+{
+ osm_transaction_mgr_t *trans_mgr_p;
+ osm_madw_req_t *osm_madw_req_p;
+ cl_map_item_t *p_map_item;
+ uint64_t key;
+ OSM_LOG_ENTER(p_vend->p_log);
+
+ trans_mgr_p = (osm_transaction_mgr_t *) p_vend->p_transaction_mgr;
+
+ *req_madw_p = NULL;
+
+ osm_log(p_vend->p_log, OSM_LOG_DEBUG,
+ "osm_transaction_mgr_get_madw_for_tid: "
+ "Looking for TID:<0x%" PRIx64 ">.\n", p_mad->trans_id);
+
+ key = (uint64_t) p_mad->trans_id;
+ cl_spinlock_acquire(&(trans_mgr_p->transaction_mgr_lock));
+ p_map_item = cl_qmap_get(trans_mgr_p->madw_by_tid_map_p, key);
+ if (p_map_item != cl_qmap_end(trans_mgr_p->madw_by_tid_map_p)) {
+ /* we found such an item. */
+ /* get the osm_madw_req_p */
+ osm_madw_req_p =
+ PARENT_STRUCT(p_map_item, osm_madw_req_t, map_item);
+
+ /* Since the Transaction was looked up and provided for */
+ /* processing we retire it */
+ cl_qlist_remove_item(trans_mgr_p->madw_reqs_list_p,
+ &(osm_madw_req_p->list_item));
+ /* remove the item from the qmap */
+ cl_qmap_remove_item(trans_mgr_p->madw_by_tid_map_p,
+ &(osm_madw_req_p->map_item));
+
+ osm_log(p_vend->p_log, OSM_LOG_DEBUG,
+ "osm_transaction_mgr_get_madw_for_tid: "
+ "Removed TID:<0x%" PRIx64 ">.\n", p_mad->trans_id);
+
+ *req_madw_p = osm_madw_req_p->p_madw;
+ }
+
+ cl_spinlock_release(&(trans_mgr_p->transaction_mgr_lock));
+ osm_log(p_vend->p_log, OSM_LOG_DEBUG,
+ "osm_transaction_mgr_get_madw_for_tid: "
+ "Got MADW:%p.\n", *req_madw_p);
+ OSM_LOG_EXIT(p_vend->p_log);
+ return (IB_SUCCESS);
+}
+
+#endif
diff --git a/contrib/ofed/opensm/libvendor/osm_vendor_test.c b/contrib/ofed/opensm/libvendor/osm_vendor_test.c
new file mode 100644
index 0000000..9f7b104
--- /dev/null
+++ b/contrib/ofed/opensm/libvendor/osm_vendor_test.c
@@ -0,0 +1,258 @@
+/*
+ * Copyright (c) 2004-2008 Voltaire, Inc. All rights reserved.
+ * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved.
+ * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+/*
+ * Abstract:
+ * Implementation of vendor specific transport interface.
+ * This is the "Test" vendor which allows compilation and some
+ * testing without a real vendor interface.
+ * These objects are part of the opensm family of objects.
+ *
+ */
+
+#if HAVE_CONFIG_H
+# include <config.h>
+#endif /* HAVE_CONFIG_H */
+
+#ifdef OSM_VENDOR_INTF_TEST
+
+#include <stdlib.h>
+#include <string.h>
+#include <opensm/osm_log.h>
+#include <vendor/osm_vendor_test.h>
+#include <vendor/osm_vendor_api.h>
+
+void osm_vendor_construct(IN osm_vendor_t * const p_vend)
+{
+ memset(p_vend, 0, sizeof(*p_vend));
+}
+
+void osm_vendor_destroy(IN osm_vendor_t * const p_vend)
+{
+ UNUSED_PARAM(p_vend);
+}
+
+void osm_vendor_delete(IN osm_vendor_t ** const pp_vend)
+{
+ CL_ASSERT(pp_vend);
+
+ osm_vendor_destroy(*pp_vend);
+ free(*pp_vend);
+ *pp_vend = NULL;
+}
+
+ib_api_status_t
+osm_vendor_init(IN osm_vendor_t * const p_vend,
+ IN osm_log_t * const p_log, IN const uint32_t timeout)
+{
+ OSM_LOG_ENTER(p_log);
+
+ CL_ASSERT(p_vend);
+ CL_ASSERT(p_log);
+
+ p_vend->p_log = p_log;
+ p_vend->timeout = timeout;
+ OSM_LOG_EXIT(p_log);
+ return (IB_SUCCESS);
+}
+
+osm_vendor_t *osm_vendor_new(IN osm_log_t * const p_log,
+ IN const uint32_t timeout)
+{
+ ib_api_status_t status;
+ osm_vendor_t *p_vend;
+ OSM_LOG_ENTER(p_log);
+
+ CL_ASSERT(p_log);
+
+ p_vend = malloc(sizeof(*p_vend));
+ if (p_vend != NULL) {
+ memset(p_vend, 0, sizeof(*p_vend));
+
+ status = osm_vendor_init(p_vend, p_log, timeout);
+ if (status != IB_SUCCESS) {
+ osm_vendor_delete(&p_vend);
+ }
+ }
+
+ OSM_LOG_EXIT(p_log);
+ return (p_vend);
+}
+
+ib_mad_t *osm_vendor_get(IN osm_bind_handle_t h_bind,
+ IN const uint32_t size,
+ IN osm_vend_wrap_t * const p_vend_wrap)
+{
+ osm_vendor_t *p_vend;
+ ib_mad_t *p_mad;
+ OSM_LOG_ENTER(h_bind->p_vend->p_log);
+
+ UNUSED_PARAM(p_vend_wrap);
+
+ p_vend = h_bind->p_vend;
+
+ /*
+ Simply malloc the MAD off the heap.
+ */
+ p_mad = (ib_mad_t *) malloc(size);
+
+ osm_log(p_vend->p_log, OSM_LOG_VERBOSE,
+ "osm_vendor_get: " "MAD %p.\n", p_mad);
+
+ if (p_mad)
+ memset(p_mad, 0, size);
+
+ OSM_LOG_EXIT(p_vend->p_log);
+ return (p_mad);
+}
+
+void
+osm_vendor_put(IN osm_bind_handle_t h_bind,
+ IN osm_vend_wrap_t * const p_vend_wrap,
+ IN ib_mad_t * const p_mad)
+{
+ osm_vendor_t *p_vend;
+
+ OSM_LOG_ENTER(h_bind->p_vend->p_log);
+
+ UNUSED_PARAM(p_vend_wrap);
+
+ p_vend = h_bind->p_vend;
+
+ osm_log(p_vend->p_log, OSM_LOG_VERBOSE,
+ "osm_vendor_put: " "MAD %p.\n", p_mad);
+
+ /*
+ Return the MAD to the heap.
+ */
+ free(p_mad);
+
+ OSM_LOG_EXIT(p_vend->p_log);
+}
+
+ib_api_status_t
+osm_vendor_send(IN osm_bind_handle_t h_bind,
+ IN osm_vend_wrap_t * const p_vend_wrap,
+ IN osm_mad_addr_t * const p_mad_addr,
+ IN ib_mad_t * const p_mad,
+ IN void *transaction_context, IN boolean_t const resp_expected)
+{
+ osm_vendor_t *p_vend = h_bind->p_vend;
+
+ OSM_LOG_ENTER(p_vend->p_log);
+
+ UNUSED_PARAM(p_vend_wrap);
+ UNUSED_PARAM(p_mad_addr);
+ UNUSED_PARAM(transaction_context);
+ UNUSED_PARAM(resp_expected);
+
+ osm_log(p_vend->p_log, OSM_LOG_VERBOSE,
+ "osm_vendor_send: " "MAD %p.\n", p_mad);
+
+ OSM_LOG_EXIT(p_vend->p_log);
+ return (IB_SUCCESS);
+}
+
+osm_bind_handle_t
+osm_vendor_bind(IN osm_vendor_t * const p_vend,
+ IN osm_bind_info_t * const p_bind_info,
+ IN osm_mad_pool_t * const p_mad_pool,
+ IN osm_vend_mad_recv_callback_t mad_recv_callback,
+ IN void *context)
+{
+ osm_bind_handle_t h_bind;
+
+ OSM_LOG_ENTER(p_vend->p_log);
+
+ CL_ASSERT(p_vend);
+ CL_ASSERT(p_bind_info);
+ CL_ASSERT(p_mad_pool);
+ CL_ASSERT(mad_recv_callback);
+ CL_ASSERT(context);
+
+ UNUSED_PARAM(p_vend);
+ UNUSED_PARAM(p_mad_pool);
+ UNUSED_PARAM(mad_recv_callback);
+ UNUSED_PARAM(context);
+
+ h_bind = (osm_bind_handle_t) malloc(sizeof(*h_bind));
+ if (h_bind != NULL) {
+ memset(h_bind, 0, sizeof(*h_bind));
+ h_bind->p_vend = p_vend;
+ h_bind->port_guid = p_bind_info->port_guid;
+ h_bind->mad_class = p_bind_info->mad_class;
+ h_bind->class_version = p_bind_info->class_version;
+ h_bind->is_responder = p_bind_info->is_responder;
+ h_bind->is_trap_processor = p_bind_info->is_trap_processor;
+ h_bind->is_report_processor = p_bind_info->is_report_processor;
+ h_bind->send_q_size = p_bind_info->send_q_size;
+ h_bind->recv_q_size = p_bind_info->recv_q_size;
+ }
+
+ OSM_LOG_EXIT(p_vend->p_log);
+ return (h_bind);
+}
+
+ib_api_status_t
+osm_vendor_get_ports(IN osm_vendor_t * const p_vend,
+ IN ib_net64_t * const p_guids,
+ IN uint32_t * const num_guids)
+{
+ OSM_LOG_ENTER(p_vend->p_log);
+
+ *p_guids = CL_NTOH64(0x0000000000001234);
+ *num_guids = 1;
+
+ OSM_LOG_EXIT(p_vend->p_log);
+ return (IB_SUCCESS);
+}
+
+ib_api_status_t osm_vendor_local_lid_change(IN osm_bind_handle_t h_bind)
+{
+ osm_vendor_t *p_vend = h_bind->p_vend;
+
+ OSM_LOG_ENTER(p_vend->p_log);
+
+ OSM_LOG_EXIT(p_vend->p_log);
+
+ return (IB_SUCCESS);
+}
+
+void osm_vendor_set_debug(IN osm_vendor_t * const p_vend, IN int32_t level)
+{
+
+}
+
+#endif /* OSM_VENDOR_INTF_TEST */
diff --git a/contrib/ofed/opensm/libvendor/osm_vendor_ts.c b/contrib/ofed/opensm/libvendor/osm_vendor_ts.c
new file mode 100644
index 0000000..f4f1df1
--- /dev/null
+++ b/contrib/ofed/opensm/libvendor/osm_vendor_ts.c
@@ -0,0 +1,897 @@
+/*
+ * Copyright (c) 2004-2008 Voltaire, Inc. All rights reserved.
+ * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved.
+ * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+#undef __init
+#if HAVE_CONFIG_H
+# include <config.h>
+#endif /* HAVE_CONFIG_H */
+
+#include <stdlib.h>
+#include <string.h>
+#include <vendor/osm_vendor_ts.h>
+#include <vendor/osm_vendor_api.h>
+#include <vendor/osm_ts_useraccess.h>
+#include <opensm/osm_subnet.h>
+#include <opensm/osm_opensm.h>
+
+/*
+ Since a race can accure on requests. Meaning - a response is received before
+ the send_callback is called - we will save both the madw_p and the fact
+ whether or not it is a response. A race can occure only on requests that did
+ not fail, and then the madw_p will be put back in the pool before the
+ callback.
+*/
+uint64_t __osm_set_wrid_by_p_madw(IN osm_madw_t * p_madw)
+{
+ uint64_t wrid = 0;
+
+ CL_ASSERT(p_madw->p_mad);
+
+ memcpy(&wrid, &p_madw, sizeof(osm_madw_t *));
+ wrid = (wrid << 1) |
+ ib_mad_is_response(p_madw->p_mad);
+ return wrid;
+}
+
+void
+__osm_set_p_madw_and_resp_by_wrid(IN uint64_t wrid,
+ OUT uint8_t * is_resp,
+ OUT osm_madw_t ** pp_madw)
+{
+ *is_resp = wrid & 0x0000000000000001;
+ wrid = wrid >> 1;
+ memcpy(pp_madw, &wrid, sizeof(osm_madw_t *));
+}
+
+/**********************************************************************
+ * TS MAD to OSM ADDRESS VECTOR
+ **********************************************************************/
+void
+__osm_ts_conv_mad_rcv_desc_to_osm_addr(IN osm_vendor_t * const p_vend,
+ IN struct ib_mad *p_mad,
+ IN uint8_t is_smi,
+ OUT osm_mad_addr_t * p_mad_addr)
+{
+ p_mad_addr->dest_lid = cl_hton16(p_mad->slid);
+ p_mad_addr->static_rate = 0; /* HACK - we do not know the rate ! */
+ p_mad_addr->path_bits = 0; /* HACK - no way to know in TS */
+ if (is_smi) {
+ /* SMI */
+ p_mad_addr->addr_type.smi.source_lid = cl_hton16(p_mad->slid);
+ p_mad_addr->addr_type.smi.port_num = p_mad->port;
+ } else {
+ /* GSI */
+ p_mad_addr->addr_type.gsi.remote_qp = p_mad->sqpn;
+ p_mad_addr->addr_type.gsi.remote_qkey = IB_QP1_WELL_KNOWN_Q_KEY;
+ p_mad_addr->addr_type.gsi.pkey_ix = p_mad->pkey_index;
+ p_mad_addr->addr_type.gsi.service_level = 0; /* HACK no way to know */
+
+ p_mad_addr->addr_type.gsi.global_route = FALSE; /* HACK no way to know */
+ /* copy the GRH data if relevant */
+ /*
+ if (p_mad_addr->addr_type.gsi.global_route)
+ {
+ p_mad_addr->addr_type.gsi.grh_info.ver_class_flow =
+ ib_grh_set_ver_class_flow(p_rcv_desc->grh.IP_version,
+ p_rcv_desc->grh.traffic_class,
+ p_rcv_desc->grh.flow_label);
+ p_mad_addr->addr_type.gsi.grh_info.hop_limit = p_rcv_desc->grh.hop_limit;
+ memcpy(&p_mad_addr->addr_type.gsi.grh_info.src_gid.raw,
+ &p_rcv_desc->grh.sgid, sizeof(ib_net64_t));
+ memcpy(&p_mad_addr->addr_type.gsi.grh_info.dest_gid.raw,
+ p_rcv_desc->grh.dgid, sizeof(ib_net64_t));
+ }
+ */
+ }
+}
+
+/**********************************************************************
+ * OSM ADDR VECTOR TO TS MAD:
+ **********************************************************************/
+void
+__osm_ts_conv_osm_addr_to_ts_addr(IN osm_mad_addr_t * p_mad_addr,
+ IN uint8_t is_smi, OUT struct ib_mad *p_mad)
+{
+
+ /* For global destination or Multicast address: */
+ p_mad->dlid = cl_ntoh16(p_mad_addr->dest_lid);
+ p_mad->sl = 0;
+ if (is_smi) {
+ p_mad->sqpn = 0;
+ p_mad->dqpn = 0;
+ } else {
+ p_mad->sqpn = 1;
+ p_mad->dqpn = p_mad_addr->addr_type.gsi.remote_qp;
+ }
+}
+
+void __osm_vendor_clear_sm(IN osm_bind_handle_t h_bind)
+{
+ osm_ts_bind_info_t *p_bind = (osm_ts_bind_info_t *) h_bind;
+ osm_vendor_t *p_vend = p_bind->p_vend;
+ VAPI_ret_t status;
+ VAPI_hca_attr_t attr_mod;
+ VAPI_hca_attr_mask_t attr_mask;
+
+ OSM_LOG_ENTER(p_vend->p_log);
+
+ memset(&attr_mod, 0, sizeof(attr_mod));
+ memset(&attr_mask, 0, sizeof(attr_mask));
+
+ attr_mod.is_sm = FALSE;
+ attr_mask = HCA_ATTR_IS_SM;
+
+ status =
+ VAPI_modify_hca_attr(p_bind->hca_hndl, p_bind->port_num, &attr_mod,
+ &attr_mask);
+ if (status != VAPI_OK) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "__osm_vendor_clear_sm: ERR 5021: "
+ "Unable set 'IS_SM' bit in port attributes (%d).\n",
+ status);
+ }
+
+ OSM_LOG_EXIT(p_vend->p_log);
+}
+
+/**********************************************************************
+ * ANY CONSTRUCTION OF THE osm_vendor_t OBJECT
+ **********************************************************************/
+void osm_vendor_construct(IN osm_vendor_t * const p_vend)
+{
+ memset(p_vend, 0, sizeof(*p_vend));
+ cl_thread_construct(&(p_vend->smi_bind.poller));
+ cl_thread_construct(&(p_vend->gsi_bind.poller));
+}
+
+/**********************************************************************
+ * DEALOCATE osm_vendor_t
+ **********************************************************************/
+void osm_vendor_destroy(IN osm_vendor_t * const p_vend)
+{
+ OSM_LOG_ENTER(p_vend->p_log);
+ osm_transaction_mgr_destroy(p_vend);
+
+ /* Destroy the poller threads */
+ /* HACK: can you destroy an un-initialized thread ? */
+ pthread_cancel(p_vend->smi_bind.poller.osd.id);
+ pthread_cancel(p_vend->gsi_bind.poller.osd.id);
+ cl_thread_destroy(&(p_vend->smi_bind.poller));
+ cl_thread_destroy(&(p_vend->gsi_bind.poller));
+ OSM_LOG_EXIT(p_vend->p_log);
+}
+
+/**********************************************************************
+DEALLOCATE A POINTER TO osm_vendor_t
+**********************************************************************/
+void osm_vendor_delete(IN osm_vendor_t ** const pp_vend)
+{
+ CL_ASSERT(pp_vend);
+
+ osm_vendor_destroy(*pp_vend);
+ free(*pp_vend);
+ *pp_vend = NULL;
+}
+
+/**********************************************************************
+ Initializes the vendor:
+**********************************************************************/
+
+ib_api_status_t
+osm_vendor_init(IN osm_vendor_t * const p_vend,
+ IN osm_log_t * const p_log, IN const uint32_t timeout)
+{
+ ib_api_status_t status = IB_SUCCESS;
+
+ OSM_LOG_ENTER(p_log);
+
+ p_vend->p_log = p_log;
+ p_vend->p_transaction_mgr = NULL;
+ osm_transaction_mgr_init(p_vend);
+ p_vend->timeout = timeout;
+
+ /* we use the file handle to track the binding */
+ p_vend->smi_bind.ul_dev_fd = -1;
+ p_vend->gsi_bind.ul_dev_fd = -1;
+
+ OSM_LOG_EXIT(p_log);
+ return (status);
+}
+
+/**********************************************************************
+ * Create and Initialize osm_vendor_t Object
+ **********************************************************************/
+osm_vendor_t *osm_vendor_new(IN osm_log_t * const p_log,
+ IN const uint32_t timeout)
+{
+ ib_api_status_t status;
+ osm_vendor_t *p_vend;
+
+ OSM_LOG_ENTER(p_log);
+
+ CL_ASSERT(p_log);
+
+ p_vend = malloc(sizeof(*p_vend));
+ if (p_vend != NULL) {
+ memset(p_vend, 0, sizeof(*p_vend));
+
+ status = osm_vendor_init(p_vend, p_log, timeout);
+ if (status != IB_SUCCESS) {
+ osm_vendor_delete(&p_vend);
+ }
+ } else {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "osm_vendor_new: ERR 5007: "
+ "Fail to allocate vendor object.\n");
+ }
+
+ OSM_LOG_EXIT(p_log);
+ return (p_vend);
+}
+
+/**********************************************************************
+ * TS RCV Thread callback
+ * HACK: - we need to make this support arbitrary size mads.
+ **********************************************************************/
+void
+__osm_ts_rcv_callback(IN osm_ts_bind_info_t * p_bind,
+ IN osm_mad_addr_t * p_mad_addr,
+ IN uint32_t mad_size, IN void *p_mad)
+{
+ ib_api_status_t status;
+ osm_madw_t *p_req_madw = NULL;
+ osm_madw_t *p_madw;
+ osm_vend_wrap_t *p_new_vw;
+ ib_mad_t *p_mad_buf;
+ osm_log_t *const p_log = p_bind->p_vend->p_log;
+
+ OSM_LOG_ENTER(p_log);
+
+ /* if it is a response MAD we mustbe able to get the request */
+ if (ib_mad_is_response((ib_mad_t *) p_mad)) {
+ /* can we find a matching madw by this payload TID */
+ status =
+ osm_transaction_mgr_get_madw_for_tid(p_bind->p_vend,
+ (ib_mad_t *) p_mad,
+ &p_req_madw);
+ if (status != IB_SUCCESS) {
+ osm_log(p_log, OSM_LOG_ERROR,
+ "__osm_ts_rcv_callback: ERR 5008: "
+ "Error obtaining request madw by TID (%d).\n",
+ status);
+ p_req_madw = NULL;
+ }
+
+ if (p_req_madw == NULL) {
+ osm_log(p_log, OSM_LOG_ERROR,
+ "__osm_ts_rcv_callback: ERR 5009: "
+ "Fail to obtain request madw for receined MAD. Aborting CB.\n");
+ goto Exit;
+ }
+ }
+
+ /* do we have a request ??? */
+ if (p_req_madw == NULL) {
+
+ /* if not - get new osm_madw and arrange it. */
+ /* create the new madw in the pool */
+ p_madw = osm_mad_pool_get(p_bind->p_osm_pool,
+ (osm_bind_handle_t) p_bind,
+ mad_size, p_mad_addr);
+ if (p_madw == NULL) {
+ osm_log(p_log, OSM_LOG_ERROR,
+ "__osm_ts_rcv_callback: ERR 5010: "
+ "Error request for a new madw.\n");
+ goto Exit;
+ }
+ /* HACK: we cust to avoid the const ??? */
+ p_mad_buf = (void *)p_madw->p_mad;
+ } else {
+ /* we have the madw defined during the send and stored in the vend_wrap */
+ /* we need to make sure the wrapper is correctly init there */
+ CL_ASSERT(p_req_madw->vend_wrap.p_resp_madw != 0);
+ p_madw = p_req_madw->vend_wrap.p_resp_madw;
+
+ CL_ASSERT(p_madw->h_bind);
+ p_mad_buf =
+ osm_vendor_get(p_madw->h_bind, mad_size,
+ &p_madw->vend_wrap);
+
+ if (p_mad_buf == NULL) {
+ osm_log(p_log, OSM_LOG_ERROR,
+ "__osm_ts_rcv_callback: ERR 5011: "
+ "Unable to acquire wire MAD.\n");
+
+ goto Exit;
+ }
+
+ /*
+ Finally, attach the wire MAD to this wrapper.
+ */
+ osm_madw_set_mad(p_madw, p_mad_buf);
+ }
+
+ /* init some fields of the vendor wrapper */
+ p_new_vw = osm_madw_get_vend_ptr(p_madw);
+ p_new_vw->h_bind = p_bind;
+ p_new_vw->size = mad_size;
+ p_new_vw->p_resp_madw = NULL;
+ p_new_vw->p_mad_buf = p_mad_buf;
+
+ memcpy(p_new_vw->p_mad_buf, p_mad, mad_size);
+
+ /* attach the buffer to the wrapper */
+ p_madw->p_mad = p_mad_buf;
+
+ /* we can also make sure we marked the size and bind on the returned madw */
+ p_madw->h_bind = p_new_vw->h_bind;
+
+ /* call the CB */
+ (*(osm_vend_mad_recv_callback_t) p_bind->rcv_callback)
+ (p_madw, p_bind->client_context, p_req_madw);
+
+Exit:
+ OSM_LOG_EXIT(p_log);
+}
+
+/**********************************************************************
+ * TS Send callback : invoked after each send
+ *
+ **********************************************************************/
+void
+__osm_ts_send_callback(IN osm_ts_bind_info_t * bind_info_p,
+ IN boolean_t is_resp,
+ IN osm_madw_t * madw_p, IN IB_comp_status_t status)
+{
+ osm_log_t *const p_log = bind_info_p->p_vend->p_log;
+ osm_vend_wrap_t *p_vw;
+
+ OSM_LOG_ENTER(p_log);
+
+ osm_log(p_log, OSM_LOG_DEBUG,
+ "__osm_ts_send_callback: INFO 1008: "
+ "Handling Send of MADW:%p Is Resp:%d.\n", madw_p, is_resp);
+
+ /* we need to handle requests and responses differently */
+ if (is_resp) {
+ if (status != IB_COMP_SUCCESS) {
+ osm_log(p_log, OSM_LOG_ERROR,
+ "__osm_ts_send_callback: ERR 5012: "
+ "Error Sending Response MADW:%p.\n", madw_p);
+ } else {
+ osm_log(p_log, OSM_LOG_DEBUG,
+ "__osm_ts_send_callback: DBG 1008: "
+ "Completed Sending Response MADW:%p.\n",
+ madw_p);
+ }
+
+ /* if we are a response - we need to clean it up */
+ osm_mad_pool_put(bind_info_p->p_osm_pool, madw_p);
+ } else {
+
+ /* this call back is invoked on completion of send - error or not */
+ if (status != IB_COMP_SUCCESS) {
+
+ osm_log(p_log, OSM_LOG_ERROR,
+ "__osm_ts_send_callback: ERR 5013: "
+ "Received an Error from IB_MGT Send (%d).\n",
+ status);
+
+ p_vw = osm_madw_get_vend_ptr(madw_p);
+ CL_ASSERT(p_vw);
+
+ /*
+ Return any wrappers to the pool that may have been
+ pre-emptively allocated to handle a receive.
+ */
+ if (p_vw->p_resp_madw) {
+ osm_mad_pool_put(bind_info_p->p_osm_pool,
+ p_vw->p_resp_madw);
+ p_vw->p_resp_madw = NULL;
+ }
+
+ /* invoke the CB */
+ (*(osm_vend_mad_send_err_callback_t) bind_info_p->
+ send_err_callback)
+ (bind_info_p->client_context, madw_p);
+ } else {
+ /* successful request send - do nothing - the response will need the
+ out mad */
+ osm_log(p_log, OSM_LOG_DEBUG,
+ "__osm_ts_send_callback: DBG 1008: "
+ "Completed Sending Request MADW:%p.\n", madw_p);
+ }
+ }
+
+ OSM_LOG_EXIT(p_log);
+}
+
+/**********************************************************************
+ * Poller thread:
+ * Always receive 256byte mads from the devcie file
+ **********************************************************************/
+void __osm_vendor_ts_poller(IN void *p_ptr)
+{
+ int ts_ret_code;
+ struct ib_mad mad;
+ osm_mad_addr_t mad_addr;
+ osm_ts_bind_info_t *const p_bind = (osm_ts_bind_info_t *) p_ptr;
+
+ OSM_LOG_ENTER(p_bind->p_vend->p_log);
+ /* we set the type of cancelation for this thread */
+ pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, NULL);
+
+ while (1) {
+ /* we read one mad at a time and pass it to the read callback function */
+ ts_ret_code = read(p_bind->ul_dev_fd, &mad, sizeof(mad));
+ if (ts_ret_code != sizeof(mad)) {
+ osm_log(p_bind->p_vend->p_log, OSM_LOG_ERROR,
+ "__osm_vendor_ts_poller: ERR 5003: "
+ "error with read, bytes = %d, errno = %d\n",
+ ts_ret_code, errno);
+ } else {
+ osm_log(p_bind->p_vend->p_log, OSM_LOG_DEBUG,
+ "__osm_vendor_ts_poller: "
+ "MAD QPN:%d SLID:0x%04x class:0x%02x "
+ "__osm_vendor_ts_poller:0x%02x attr:0x%04x status:0x%04x "
+ "__osm_vendor_ts_poller:0x%016" PRIx64 "\n",
+ cl_ntoh32(mad.dqpn),
+ cl_ntoh16(mad.slid),
+ mad.mgmt_class,
+ mad.r_method,
+ cl_ntoh16(mad.attribute_id),
+ cl_ntoh16(mad.status),
+ cl_ntoh64(mad.transaction_id));
+
+ /* first arrange an address */
+ __osm_ts_conv_mad_rcv_desc_to_osm_addr(p_bind->p_vend,
+ &mad,
+ (((ib_mad_t *) &
+ mad)->
+ mgmt_class ==
+ IB_MCLASS_SUBN_LID)
+ ||
+ (((ib_mad_t *) &
+ mad)->
+ mgmt_class ==
+ IB_MCLASS_SUBN_DIR),
+ &mad_addr);
+
+ /* call the receiver callback */
+ /* HACK: this should be replaced with a call to the RMPP Assembly ... */
+ __osm_ts_rcv_callback(p_bind, &mad_addr, 256, &mad);
+ }
+ }
+
+ OSM_LOG_EXIT(p_bind->p_vend->p_log);
+}
+
+/**********************************************************************
+ * BINDs a callback (rcv and send error) for a given class and method
+ * defined by the given: osm_bind_info_t
+ **********************************************************************/
+osm_bind_handle_t
+osm_vendor_bind(IN osm_vendor_t * const p_vend,
+ IN osm_bind_info_t * const p_user_bind,
+ IN osm_mad_pool_t * const p_mad_pool,
+ IN osm_vend_mad_recv_callback_t mad_recv_callback,
+ IN osm_vend_mad_send_err_callback_t send_err_callback,
+ IN void *context)
+{
+ ib_net64_t port_guid;
+ osm_ts_bind_info_t *p_bind = NULL;
+ VAPI_hca_hndl_t hca_hndl;
+ VAPI_hca_id_t hca_id;
+ uint32_t port_num;
+ ib_api_status_t status;
+ int device_fd;
+ char device_file[16];
+ osm_ts_user_mad_filter filter;
+ int ts_ioctl_ret;
+ int qpn;
+
+ OSM_LOG_ENTER(p_vend->p_log);
+
+ CL_ASSERT(p_mad_pool);
+
+ port_guid = p_user_bind->port_guid;
+
+ osm_log(p_vend->p_log, OSM_LOG_INFO,
+ "osm_vendor_bind: "
+ "Binding to port 0x%" PRIx64 ".\n", cl_ntoh64(port_guid));
+
+ switch (p_user_bind->mad_class) {
+ case IB_MCLASS_SUBN_LID:
+ case IB_MCLASS_SUBN_DIR:
+ p_bind = &(p_vend->smi_bind);
+ qpn = 0;
+ break;
+
+ case IB_MCLASS_SUBN_ADM:
+ default:
+ p_bind = &(p_vend->gsi_bind);
+ qpn = 1;
+ break;
+ }
+
+ /* Make sure we did not previously opened the file */
+ if (p_bind->ul_dev_fd >= 0) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "osm_vendor_bind: ERR 5004: "
+ "Already binded to port %u\n", p_bind->port_num);
+ goto Exit;
+ }
+
+ /*
+ We need to figure out what is the TS file name to attach to.
+ I guess it is following the index of the port in the table of
+ ports.
+ */
+
+ /* obtain the hca name and port num from the guid */
+ osm_log(p_vend->p_log, OSM_LOG_DEBUG,
+ "osm_vendor_bind: "
+ "Finding CA and Port that owns port guid 0x%" PRIx64 ".\n",
+ cl_ntoh64(port_guid));
+ status =
+ osm_vendor_get_guid_ca_and_port(p_vend, port_guid, &hca_hndl,
+ &hca_id, &port_num);
+ if (status != IB_SUCCESS) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "osm_vendor_bind: ERR 5005: "
+ "Fail to find port number of port guid:0x%016" PRIx64
+ "\n", port_guid);
+ goto Exit;
+ }
+
+ /* the file name is just /dev/ts_ua0: */
+ strcpy(device_file, "/dev/ts_ua0");
+
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "osm_vendor_bind: " "Opening TS UL dev file:%s\n", device_file);
+
+ /* Open the file ... */
+ device_fd = open(device_file, O_RDWR);
+ if (device_fd < 0) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "osm_vendor_bind: ERR 5006: "
+ "Fail to open TS UL dev file:%s\n", device_file);
+ goto Exit;
+ }
+
+ /* track this bind request info */
+ p_bind->ul_dev_fd = device_fd;
+ p_bind->port_num = port_num;
+ p_bind->p_vend = p_vend;
+ p_bind->client_context = context;
+ p_bind->rcv_callback = mad_recv_callback;
+ p_bind->send_err_callback = send_err_callback;
+ p_bind->p_osm_pool = p_mad_pool;
+ p_bind->hca_hndl = hca_hndl;
+
+ /*
+ * Create the MAD filter on this file handle.
+ */
+ filter.port = port_num;
+
+ filter.qpn = qpn;
+ filter.mgmt_class = p_user_bind->mad_class;
+ filter.direction = TS_IB_MAD_DIRECTION_IN;
+ filter.mask =
+ TS_IB_MAD_FILTER_DIRECTION |
+ TS_IB_MAD_FILTER_PORT |
+ TS_IB_MAD_FILTER_QPN | TS_IB_MAD_FILTER_MGMT_CLASS;
+
+ ts_ioctl_ret = ioctl(device_fd, TS_IB_IOCSMADFILTADD, &filter);
+ if (ts_ioctl_ret < 0) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "osm_vendor_bind: ERR 5014: "
+ "Fail to register MAD filter with err:%u\n",
+ ts_ioctl_ret);
+ goto Exit;
+ }
+
+ /* Initialize the listener thread for this port */
+ status = cl_thread_init(&p_bind->poller,
+ __osm_vendor_ts_poller, p_bind,
+ "osm ts poller");
+ if (status != IB_SUCCESS)
+ goto Exit;
+
+Exit:
+ OSM_LOG_EXIT(p_vend->p_log);
+ return ((osm_bind_handle_t) p_bind);
+}
+
+/**********************************************************************
+Get a mad from the lower level.
+The osm_vend_wrap_t is a wrapper used to connect the mad to the response.
+**********************************************************************/
+ib_mad_t *osm_vendor_get(IN osm_bind_handle_t h_bind,
+ IN const uint32_t mad_size,
+ IN osm_vend_wrap_t * const p_vw)
+{
+ ib_mad_t *p_mad;
+ osm_ts_bind_info_t *p_bind = (osm_ts_bind_info_t *) h_bind;
+ osm_vendor_t *p_vend = p_bind->p_vend;
+
+ OSM_LOG_ENTER(p_vend->p_log);
+
+ CL_ASSERT(p_vw);
+
+ p_vw->size = mad_size;
+
+ /* allocate it */
+ p_mad = (ib_mad_t *) malloc(p_vw->size);
+ if (p_mad == NULL) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "osm_vendor_get: ERR 5022: "
+ "Error Obtaining MAD buffer.\n");
+ goto Exit;
+ }
+
+ memset(p_mad, 0, p_vw->size);
+
+ /* track locally */
+ p_vw->p_mad_buf = p_mad;
+ p_vw->h_bind = h_bind;
+ p_vw->p_resp_madw = NULL;
+
+ if (osm_log_get_level(p_vend->p_log) >= OSM_LOG_DEBUG) {
+ osm_log(p_vend->p_log, OSM_LOG_DEBUG,
+ "osm_vendor_get: "
+ "Acquired MAD %p, size = %u.\n", p_mad, p_vw->size);
+ }
+
+Exit:
+ OSM_LOG_EXIT(p_vend->p_log);
+ return (p_mad);
+}
+
+/**********************************************************************
+ * Return a MAD by providing it's wrapper object.
+ **********************************************************************/
+void
+osm_vendor_put(IN osm_bind_handle_t h_bind, IN osm_vend_wrap_t * const p_vw)
+{
+ osm_ts_bind_info_t *p_bind = (osm_ts_bind_info_t *) h_bind;
+ osm_vendor_t *p_vend = p_bind->p_vend;
+ osm_madw_t *p_madw;
+
+ OSM_LOG_ENTER(p_vend->p_log);
+
+ CL_ASSERT(p_vw);
+ CL_ASSERT(p_vw->p_mad_buf);
+
+ if (osm_log_get_level(p_vend->p_log) >= OSM_LOG_DEBUG) {
+ osm_log(p_vend->p_log, OSM_LOG_DEBUG,
+ "osm_vendor_put: " "Retiring MAD %p.\n",
+ p_vw->p_mad_buf);
+ }
+
+ /*
+ * We moved the removal of the transaction to immediatly after
+ * it was looked up.
+ */
+
+ /* free the mad but the wrapper is part of the madw object */
+ free(p_vw->p_mad_buf);
+ p_vw->p_mad_buf = NULL;
+ p_madw = PARENT_STRUCT(p_vw, osm_madw_t, vend_wrap);
+ p_madw->p_mad = NULL;
+
+ OSM_LOG_EXIT(p_vend->p_log);
+}
+
+/**********************************************************************
+Actually Send a MAD
+
+MADs are buffers of type: struct ib_mad - so they are limited by size.
+This is for internal use by osm_vendor_send and the transaction mgr
+retry too.
+**********************************************************************/
+ib_api_status_t
+osm_ts_send_mad(IN osm_ts_bind_info_t * p_bind, IN osm_madw_t * const p_madw)
+{
+ osm_vendor_t *const p_vend = p_bind->p_vend;
+ osm_mad_addr_t *const p_mad_addr = osm_madw_get_mad_addr_ptr(p_madw);
+ ib_mad_t *const p_mad = osm_madw_get_mad_ptr(p_madw);
+ struct ib_mad ts_mad;
+ int ret;
+ ib_api_status_t status;
+
+ OSM_LOG_ENTER(p_vend->p_log);
+
+ /*
+ * Copy the MAD over to the sent mad
+ */
+ memcpy(&ts_mad, p_mad, 256);
+
+ /*
+ * For all sends other than directed route SM MADs,
+ * acquire an address vector for the destination.
+ */
+ if (p_mad->mgmt_class != IB_MCLASS_SUBN_DIR) {
+ __osm_ts_conv_osm_addr_to_ts_addr(p_mad_addr,
+ p_mad->mgmt_class ==
+ IB_MCLASS_SUBN_LID, &ts_mad);
+ } else {
+ /* is a directed route - we need to construct a permissive address */
+ /* we do not need port number since it is part of the mad_hndl */
+ ts_mad.dlid = IB_LID_PERMISSIVE;
+ ts_mad.slid = IB_LID_PERMISSIVE;
+ }
+ if ((p_mad->mgmt_class == IB_MCLASS_SUBN_DIR) ||
+ (p_mad->mgmt_class == IB_MCLASS_SUBN_LID)) {
+ ts_mad.sqpn = 0;
+ ts_mad.dqpn = 0;
+ } else {
+ ts_mad.sqpn = 1;
+ ts_mad.dqpn = 1;
+ }
+ ts_mad.port = p_bind->port_num;
+
+ /* send it */
+ ret = write(p_bind->ul_dev_fd, &ts_mad, sizeof(ts_mad));
+
+ if (ret != sizeof(ts_mad)) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "osm_ts_send_mad: ERR 5026: "
+ "Error sending mad (%d).\n", ret);
+ status = IB_ERROR;
+ goto Exit;
+ }
+
+ status = IB_SUCCESS;
+
+Exit:
+ OSM_LOG_EXIT(p_vend->p_log);
+ return (status);
+}
+
+/**********************************************************************
+Send a MAD through.
+
+What is unclear to me is the need for the setting of all the MAD Wrapper
+fields. Seems like the OSM uses these values during it's processing...
+**********************************************************************/
+ib_api_status_t
+osm_vendor_send(IN osm_bind_handle_t h_bind,
+ IN osm_madw_t * const p_madw, IN boolean_t const resp_expected)
+{
+ osm_ts_bind_info_t *p_bind = (osm_ts_bind_info_t *) h_bind;
+ osm_vendor_t *const p_vend = p_bind->p_vend;
+ osm_vend_wrap_t *const p_vw = osm_madw_get_vend_ptr(p_madw);
+ ib_api_status_t status;
+
+ OSM_LOG_ENTER(p_vend->p_log);
+
+ /*
+ * If a response is expected to this MAD, then preallocate
+ * a mad wrapper to contain the wire MAD received in the
+ * response. Allocating a wrapper here allows for easier
+ * failure paths than after we already received the wire mad.
+ */
+ if (resp_expected == TRUE) {
+ /* we track it in the vendor wrapper */
+ p_vw->p_resp_madw =
+ osm_mad_pool_get_wrapper_raw(p_bind->p_osm_pool);
+ if (p_vw->p_resp_madw == NULL) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "osm_vendor_send: ERR 5024: "
+ "Unable to allocate MAD wrapper.\n");
+ status = IB_INSUFFICIENT_RESOURCES;
+ goto Exit;
+ }
+
+ /* put some minimal info on that wrapper */
+ ((osm_madw_t *) (p_vw->p_resp_madw))->h_bind = h_bind;
+
+ /* we also want to track it in the TID based map */
+ status = osm_transaction_mgr_insert_madw((osm_bind_handle_t *)
+ p_bind, p_madw);
+ if (status != IB_SUCCESS) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "osm_vendor_send: ERR 5025: "
+ "Error inserting request madw by TID (%d).\n",
+ status);
+ }
+ } else
+ p_vw->p_resp_madw = NULL;
+
+ /* do the actual send */
+ /* HACK: to be replaced by call to RMPP Segmentation */
+ status = osm_ts_send_mad(p_bind, p_madw);
+
+ /* we do not get an asycn callback so call it ourselves */
+ /* this will handle all cleanup if neccessary */
+ __osm_ts_send_callback(p_bind, !resp_expected, p_madw, status);
+
+Exit:
+ OSM_LOG_EXIT(p_vend->p_log);
+ return (status);
+}
+
+/**********************************************************************
+ * the idea here is to change the content of the bind such that it
+ * will hold the local address used for sending directed route by the SMA.
+ **********************************************************************/
+ib_api_status_t osm_vendor_local_lid_change(IN osm_bind_handle_t h_bind)
+{
+ osm_vendor_t *p_vend = ((osm_ts_bind_info_t *) h_bind)->p_vend;
+
+ OSM_LOG_ENTER(p_vend->p_log);
+
+ osm_log(p_vend->p_log, OSM_LOG_DEBUG,
+ "osm_vendor_local_lid_change: DEBUG 2202: " "Change of LID.\n");
+
+ OSM_LOG_EXIT(p_vend->p_log);
+
+ return (IB_SUCCESS);
+}
+
+void osm_vendor_set_sm(IN osm_bind_handle_t h_bind, IN boolean_t is_sm_val)
+{
+ osm_ts_bind_info_t *p_bind = (osm_ts_bind_info_t *) h_bind;
+ osm_vendor_t *p_vend = p_bind->p_vend;
+ VAPI_ret_t status;
+ VAPI_hca_attr_t attr_mod;
+ VAPI_hca_attr_mask_t attr_mask;
+
+ OSM_LOG_ENTER(p_vend->p_log);
+
+ memset(&attr_mod, 0, sizeof(attr_mod));
+ memset(&attr_mask, 0, sizeof(attr_mask));
+
+ attr_mod.is_sm = is_sm_val;
+ attr_mask = HCA_ATTR_IS_SM;
+
+ status =
+ VAPI_modify_hca_attr(p_bind->hca_hndl, p_bind->port_num, &attr_mod,
+ &attr_mask);
+ if (status != VAPI_OK) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "osm_vendor_set_sm: ERR 5027: "
+ "Unable set 'IS_SM' bit to:%u in port attributes (%d).\n",
+ is_sm_val, status);
+ }
+
+ OSM_LOG_EXIT(p_vend->p_log);
+}
+
+void osm_vendor_set_debug(IN osm_vendor_t * const p_vend, IN int32_t level)
+{
+
+}
diff --git a/contrib/ofed/opensm/libvendor/osm_vendor_umadt.c b/contrib/ofed/opensm/libvendor/osm_vendor_umadt.c
new file mode 100644
index 0000000..b4d707d
--- /dev/null
+++ b/contrib/ofed/opensm/libvendor/osm_vendor_umadt.c
@@ -0,0 +1,1107 @@
+/*
+ * Copyright (c) 2004-2008 Voltaire, Inc. All rights reserved.
+ * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved.
+ * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+/*
+ * Abstract:
+ * Implementation of osm_req_t.
+ * This object represents the generic attribute requester.
+ * This object is part of the opensm family of objects.
+ *
+ */
+
+/*
+ Next available error code: 0x300
+*/
+
+#if HAVE_CONFIG_H
+# include <config.h>
+#endif /* HAVE_CONFIG_H */
+
+#ifdef OSM_VENDOR_INTF_UMADT
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <dlfcn.h>
+#include <string.h>
+
+#include <complib/cl_qlist.h>
+#include <complib/cl_thread.h>
+#include <complib/cl_timer.h>
+#include <iba/ib_types.h>
+#include <opensm/osm_madw.h>
+#include <opensm/osm_log.h>
+#include <opensm/osm_mad_pool.h>
+
+#include <vendor/osm_vendor_umadt.h>
+#include <vendor/osm_umadt.h>
+
+/* GEN1 includes */
+#include "umadt_so.h"
+#include "ibt.h"
+#include "statustext.h"
+
+/* //////////////////////////////////////////////////////////////////////// */
+/* //////////////////////////////////////////////////////////////////////// */
+/* //////////////////////////////////////////////////////////////////////// */
+/* //////////////////////////////////////////////////////////////////////// */
+/* //////////////////////////////////////////////////////////////////////// */
+/* */
+/* VENDOR_MAD_INTF */
+/* */
+/* //////////////////////////////////////////////////////////////////////// */
+/* //////////////////////////////////////////////////////////////////////// */
+/* //////////////////////////////////////////////////////////////////////// */
+/* //////////////////////////////////////////////////////////////////////// */
+/* //////////////////////////////////////////////////////////////////////// */
+
+/* //////////////////// */
+/* Globals // */
+/* //////////////////// */
+typedef struct _ib_sa_mad_vM3 {
+ uint8_t base_ver;
+ uint8_t mgmt_class;
+ uint8_t class_ver;
+ uint8_t method;
+ ib_net16_t status;
+ ib_net16_t resv;
+ ib_net64_t trans_id;
+ ib_net16_t attr_id;
+ ib_net16_t resv1;
+ ib_net32_t attr_mod;
+ ib_net64_t resv2;
+ ib_net64_t sm_key;
+
+ ib_net32_t seg_num;
+ ib_net32_t payload_len;
+ uint8_t frag_flag;
+ uint8_t edit_mod;
+ ib_net16_t window;
+ ib_net16_t attr_offset;
+ ib_net16_t resv3;
+
+ ib_net64_t comp_mask;
+
+ uint8_t data[IB_SA_DATA_SIZE];
+} ib_sa_mad_t_vM3;
+#define DEFAULT_TIMER_INTERVAL_MSEC 500 /* 500msec timer interval */
+
+void __mad_recv_processor(void *context);
+
+boolean_t __valid_mad_handle(IN mad_bind_info_t * p_mad_bind_info);
+
+cl_status_t
+__match_tid_context(const cl_list_item_t * const p_list_item, void *context);
+void __osm_vendor_timer_callback(IN void *context);
+
+osm_vendor_t *osm_vendor_new(IN osm_log_t * const p_log,
+ IN const uint32_t timeout)
+{
+ ib_api_status_t status;
+ umadt_obj_t *p_umadt_obj;
+
+ OSM_LOG_ENTER(p_log);
+
+ p_umadt_obj = malloc(sizeof(umadt_obj_t));
+ if (p_umadt_obj) {
+ memset(p_umadt_obj, 0, sizeof(umadt_obj_t));
+
+ status = osm_vendor_init((osm_vendor_t *) p_umadt_obj, p_log,
+ timeout);
+ if (status != IB_SUCCESS) {
+ osm_vendor_delete((osm_vendor_t **) & p_umadt_obj);
+ }
+ } else {
+ printf
+ ("osm_vendor_construct: ERROR! Unable to create Umadt object!\n");
+ }
+
+ OSM_LOG_EXIT(p_log);
+
+ return ((osm_vendor_t *) p_umadt_obj);
+}
+
+void osm_vendor_delete(IN osm_vendor_t ** const pp_vend)
+{
+ umadt_obj_t *p_umadt_obj = (umadt_obj_t *) * pp_vend;
+ cl_list_item_t *p_list_item;
+ uint32_t count, i;
+ mad_bind_info_t *p_mad_bind_info;
+
+ OSM_LOG_ENTER(p_umadt_obj->p_log);
+
+ cl_spinlock_acquire(&p_umadt_obj->register_lock);
+ p_mad_bind_info =
+ (mad_bind_info_t *) cl_qlist_head(&p_umadt_obj->register_list);
+ count = cl_qlist_count(&p_umadt_obj->register_list);
+ cl_spinlock_release(&p_umadt_obj->register_lock);
+ for (i = 0; i < count; i++) {
+ cl_spinlock_acquire(&p_umadt_obj->register_lock);
+ p_list_item = cl_qlist_next(&p_mad_bind_info->list_item);
+ cl_spinlock_release(&p_umadt_obj->register_lock);
+ /* Unbind this handle */
+ /* osm_vendor_ubind also removesd the item from the list */
+ /* osm_vendor_unbind takes the list lock so release it here */
+ osm_vendor_unbind((osm_bind_handle_t) p_mad_bind_info);
+ p_mad_bind_info = (mad_bind_info_t *) p_list_item;
+ }
+ dlclose(p_umadt_obj->umadt_handle);
+ free(p_umadt_obj);
+ *pp_vend = NULL;
+
+ OSM_LOG_EXIT(p_umadt_obj->p_log);
+}
+
+/* //////////////////////////////////////////////////////////////////////// */
+/* See VendorAbstractMadIntf.h for info */
+/* //////////////////////////////////////////////////////////////////////// */
+/* */
+ib_api_status_t
+osm_vendor_init(IN osm_vendor_t * const p_vend,
+ IN osm_log_t * const p_log, IN const uint32_t timeout)
+{
+ FSTATUS Status;
+ PUMADT_GET_INTERFACE uMadtGetInterface;
+ char *error;
+ umadt_obj_t *p_umadt_obj = (umadt_obj_t *) p_vend;
+
+ OSM_LOG_ENTER(p_log);
+
+ p_umadt_obj->p_log = p_log;
+ p_umadt_obj->timeout = timeout;
+
+ p_umadt_obj->umadt_handle = dlopen("libibt.so", RTLD_NOW);
+
+ if (!p_umadt_obj->umadt_handle) {
+ printf("Could not load libibt.so <%s>\n", dlerror());
+ return IB_ERROR;
+ }
+ uMadtGetInterface =
+ dlsym(p_umadt_obj->umadt_handle, "uMadtGetInterface");
+ if ((error = dlerror()) != NULL) {
+ printf("Could not resolve symbol uMadtGetInterface ERROR<%s>\n",
+ error);
+ return IB_ERROR;
+ }
+
+ Status = (*uMadtGetInterface) (&p_umadt_obj->uMadtInterface);
+ if (Status != FSUCCESS) {
+ printf(" Error in getting uMADT interface ERROR<%d>\n", Status);
+ return IB_ERROR;
+ }
+
+ /* Initialize the register list and register list lock */
+ cl_qlist_init(&p_umadt_obj->register_list);
+
+ cl_spinlock_construct(&p_umadt_obj->register_lock);
+ CL_ASSERT(cl_spinlock_init(&p_umadt_obj->register_lock) == CL_SUCCESS);
+ p_umadt_obj->init_done = TRUE;
+ printf("*****SUCCESS*****\n");
+
+ OSM_LOG_EXIT(p_log);
+ return IB_SUCCESS;
+
+}
+
+/* //////////////////////////////////////////////////////////////////////// */
+/* See VendorAbstractMadIntf.h for info */
+/* //////////////////////////////////////////////////////////////////////// */
+ib_api_status_t
+osm_vendor_get_ports(IN osm_vendor_t * const p_vend,
+ IN ib_net64_t * const p_guids,
+ IN uint32_t * const p_num_guids)
+{
+ char *error = NULL;
+ PIBT_GET_INTERFACE pfnIbtGetInterface;
+ PIBT_INIT pfnIbtInitFunc;
+
+ FSTATUS Status;
+ uint32_t caCount, caGuidCount;
+ IB_CA_ATTRIBUTES caAttributes;
+ IB_HANDLE caHandle;
+ uint32_t i;
+ IB_PORT_ATTRIBUTES *pPortAttributesList;
+ EUI64 CaGuidArray[8];
+ void *context;
+ uint64_t *p_port_guid;
+ uint32_t free_guids;
+
+ umadt_obj_t *p_umadt_obj = (umadt_obj_t *) p_vend;
+
+ OSM_LOG_ENTER(p_umadt_obj->p_log);
+
+ CL_ASSERT(p_guids);
+ CL_ASSERT(p_num_guids);
+
+ pfnIbtInitFunc =
+ (PIBT_INIT) dlsym(p_umadt_obj->umadt_handle, "IbtInit");
+
+ if (!pfnIbtInitFunc) {
+ printf("Error getting IbtInit function address.\n");
+ return IB_ERROR;
+ }
+
+ (*pfnIbtInitFunc) ();
+
+ pfnIbtGetInterface =
+ (PIBT_GET_INTERFACE) dlsym(p_umadt_obj->umadt_handle,
+ "IbtGetInterface");
+
+ if (!pfnIbtGetInterface || (error = dlerror()) != NULL) {
+ printf("Error getting IbtGetInterface function address.<%s>\n",
+ error);
+ return FALSE;
+ }
+ (*pfnIbtGetInterface) (&p_umadt_obj->IbtInterface);
+
+ caGuidCount = 8;
+ Status =
+ p_umadt_obj->IbtInterface.GetCaGuidArray(&caGuidCount,
+ &CaGuidArray[0]);
+
+ if ((Status != FSUCCESS) || (caGuidCount == 0)) {
+ return FALSE;
+ }
+
+ free_guids = *p_num_guids;
+ p_port_guid = p_guids;
+
+ /* query each ca & copy its info into callers buffer */
+ for (caCount = 0; caCount < caGuidCount; caCount++) {
+ memset(&caAttributes, 0, sizeof(IB_CA_ATTRIBUTES));
+
+ /* Open the CA */
+ Status = p_umadt_obj->IbtInterface.Vpi.OpenCA(CaGuidArray[caCount], NULL, /* CACompletionCallback */
+ NULL, /* AsyncEventCallback */
+ NULL, &caHandle);
+ if (Status != FSUCCESS) {
+ return IB_ERROR;
+ }
+
+ Status = p_umadt_obj->IbtInterface.Vpi.QueryCA(caHandle,
+ &caAttributes,
+ &context);
+
+ if (Status != FSUCCESS) {
+ p_umadt_obj->IbtInterface.Vpi.CloseCA(caHandle);
+ return IB_ERROR;
+ }
+
+ if (caAttributes.Ports > free_guids) {
+ *p_num_guids = 0;
+ memset(p_guids, 0, (*p_num_guids) * sizeof(uint64_t));
+ return IB_INSUFFICIENT_MEMORY;
+ }
+
+ pPortAttributesList =
+ (IB_PORT_ATTRIBUTES *) malloc(caAttributes.
+ PortAttributesListSize);
+
+ if (pPortAttributesList == NULL) {
+ p_umadt_obj->IbtInterface.Vpi.CloseCA(caHandle);
+ *p_num_guids = 0;
+ memset(p_guids, 0, (*p_num_guids) * sizeof(uint64_t));
+ return IB_INSUFFICIENT_MEMORY;
+ }
+
+ memset(pPortAttributesList, 0,
+ caAttributes.PortAttributesListSize);
+
+ caAttributes.PortAttributesList = pPortAttributesList;
+
+ Status = p_umadt_obj->IbtInterface.Vpi.QueryCA(caHandle,
+ &caAttributes,
+ &context);
+
+ if (Status != FSUCCESS) {
+ p_umadt_obj->IbtInterface.Vpi.CloseCA(caHandle);
+ *p_num_guids = 0;
+ memset(p_guids, 0, (*p_num_guids) * sizeof(uint64_t));
+ return IB_ERROR;
+ }
+
+ pPortAttributesList = caAttributes.PortAttributesList;
+
+ for (i = 0; i < caAttributes.Ports; i++) {
+ *(p_port_guid) =
+ cl_hton64((uint64_t) pPortAttributesList->GUID);
+ pPortAttributesList = pPortAttributesList->Next;
+ p_port_guid++;
+ }
+ free(caAttributes.PortAttributesList);
+ p_umadt_obj->IbtInterface.Vpi.CloseCA(caHandle);
+
+ free_guids = free_guids - caAttributes.Ports;
+
+ }
+ *p_num_guids = *p_num_guids - free_guids;
+ return IB_SUCCESS;
+}
+
+/* //////////////////////////////////////////////////////////////////////// */
+/* See VendorAbstractMadIntf.h for info */
+/* //////////////////////////////////////////////////////////////////////// */
+ib_mad_t *osm_vendor_get(IN osm_bind_handle_t h_bind,
+ IN const uint32_t mad_size,
+ IN osm_vend_wrap_t * p_vend_wrap)
+{
+ /* FSTATUS Status; */
+ /* uint32_t mad_count = 0; */
+ /* MadtStruct *p_madt_struct; */
+ mad_bind_info_t *p_mad_bind_info = (mad_bind_info_t *) h_bind;
+ umadt_obj_t *p_umadt_obj = p_mad_bind_info->p_umadt_obj;
+ ib_mad_t *p_mad;
+ OSM_LOG_ENTER(p_umadt_obj->p_log);
+
+ CL_ASSERT(h_bind);
+
+ p_umadt_obj = p_mad_bind_info->p_umadt_obj;
+
+ /* Sanity check */
+ CL_ASSERT(p_umadt_obj->init_done);
+ CL_ASSERT(p_vend_wrap);
+ CL_ASSERT(__valid_mad_handle(p_mad_bind_info));
+
+#if 0
+ mad_count = 1;
+ Status =
+ p_umadt_obj->uMadtInterface.uMadtGetSendMad(p_mad_bind_info->
+ umadt_handle,
+ &mad_count,
+ &p_madt_struct);
+
+ if (Status != FSUCCESS || p_madt_struct == NULL) {
+ p_vend_wrap->p_madt_struct = NULL;
+ return NULL;
+ }
+ p_vend_wrap->p_madt_struct = p_madt_struct;
+ p_vend_wrap->direction = SEND;
+ return ((ib_mad_t *) & p_madt_struct->IBMad);
+#endif /* 0 */
+ p_mad = (ib_mad_t *) malloc(mad_size);
+ if (!p_mad) {
+ p_vend_wrap->p_madt_struct = NULL;
+ return NULL;
+ }
+
+ memset(p_mad, 0, mad_size);
+
+ p_vend_wrap->p_madt_struct = NULL;
+ p_vend_wrap->direction = SEND;
+ p_vend_wrap->size = mad_size;
+ return (p_mad);
+
+}
+
+/* //////////////////////////////////////////////////////////////////////// */
+/* See VendorAbstractMadIntf.h for info */
+/* //////////////////////////////////////////////////////////////////////// */
+void
+osm_vendor_put(IN osm_bind_handle_t h_bind,
+ IN osm_vend_wrap_t * const p_vend_wrap,
+ IN ib_mad_t * const p_mad)
+{
+
+ FSTATUS Status;
+
+ mad_bind_info_t *p_mad_bind_info;
+ umadt_obj_t *p_umadt_obj;
+
+ /* */
+ /* Validate the vendor mad transport handle */
+ /* */
+ CL_ASSERT(h_bind);
+ p_mad_bind_info = (mad_bind_info_t *) h_bind;
+ p_umadt_obj = p_mad_bind_info->p_umadt_obj;
+
+ /* sanity check */
+ CL_ASSERT(p_umadt_obj->init_done);
+ CL_ASSERT(h_bind);
+ CL_ASSERT(__valid_mad_handle(p_mad_bind_info));
+ CL_ASSERT(p_vend_wrap);
+ /* CL_ASSERT( (ib_mad_t*)&p_vend_wrap->p_madt_struct->IBMad == p_mad ); */
+
+ /* Release the MAD based on the direction of the MAD */
+ if (p_vend_wrap->direction == SEND) {
+ /* */
+ /* For a send the PostSend released the MAD with Umadt. Simply dealloacte the */
+ /* local memory that was allocated on the osm_vendor_get() call. */
+ /* */
+ free(p_mad);
+#if 0
+ Status =
+ p_umadt_obj->uMadtInterface.
+ uMadtReleaseSendMad(p_mad_bind_info->umadt_handle,
+ p_vend_wrap->p_madt_struct);
+ if (Status != FSUCCESS) {
+ /* printf("uMadtReleaseSendMad: Status = <%d>\n", Status); */
+ return;
+ }
+#endif
+ } else if (p_vend_wrap->direction == RECEIVE) {
+ CL_ASSERT((ib_mad_t *) & p_vend_wrap->p_madt_struct->IBMad ==
+ p_mad);
+ Status =
+ p_umadt_obj->uMadtInterface.
+ uMadtReleaseRecvMad(p_mad_bind_info->umadt_handle,
+ p_vend_wrap->p_madt_struct);
+ if (Status != FSUCCESS) {
+ /* printf("uMadtReleaseRecvMad Status=<%d>\n", Status); */
+ return;
+ }
+ } else {
+ return;
+ }
+ return;
+}
+
+/* //////////////////////////////////////////////////////////////////////// */
+/* See VendorAbstractMadIntf.h for info */
+/* //////////////////////////////////////////////////////////////////////// */
+ib_api_status_t
+osm_vendor_send(IN osm_bind_handle_t h_bind,
+ IN osm_vend_wrap_t * const p_vend_wrap,
+ IN osm_mad_addr_t * const p_mad_addr,
+ IN ib_mad_t * const p_mad,
+ IN void *transaction_context, IN boolean_t const resp_expected)
+{
+ FSTATUS Status;
+
+ MadAddrStruct destAddr = { 0 };
+
+ mad_bind_info_t *p_mad_bind_info;
+ trans_context_t *p_trans_context;
+
+ umadt_obj_t *p_umadt_obj = NULL;
+
+ uint32_t mad_count = 0;
+ MadtStruct *p_madt_struct = NULL;
+ uint32_t i;
+ uint32_t num_mads = 0;
+ uint32_t seg_num = 0;
+ uint8_t *p_frag_data = NULL;
+ ib_sa_mad_t_vM3 *p_sa_mad = NULL;
+
+ CL_ASSERT(h_bind);
+ p_mad_bind_info = (mad_bind_info_t *) h_bind;
+ p_umadt_obj = p_mad_bind_info->p_umadt_obj;
+
+ /* sanity check */
+ CL_ASSERT(p_umadt_obj);
+ CL_ASSERT(p_umadt_obj->init_done);
+ CL_ASSERT(__valid_mad_handle(p_mad_bind_info));
+ CL_ASSERT(p_vend_wrap);
+ CL_ASSERT(p_mad_addr);
+ CL_ASSERT(p_mad);
+ /* CL_ASSERT( (ib_mad_t*)&p_vend_wrap->p_madt_struct->IBMad == p_mad ); */
+
+ /* */
+ /* based on the class, fill out the address info */
+ /* */
+ destAddr.DestLid = p_mad_addr->dest_lid;
+ destAddr.PathBits = p_mad_addr->path_bits;
+ destAddr.StaticRate = p_mad_addr->static_rate;
+
+ if (p_mad_bind_info->umadt_reg_class.ClassId == IB_MCLASS_SUBN_LID ||
+ p_mad_bind_info->umadt_reg_class.ClassId == IB_MCLASS_SUBN_DIR) {
+ CL_ASSERT(p_mad_addr->addr_type.smi.source_lid);
+ destAddr.AddrType.Smi.SourceLid =
+ p_mad_addr->addr_type.smi.source_lid;
+ } else {
+ destAddr.AddrType.Gsi.RemoteQpNumber =
+ p_mad_addr->addr_type.gsi.remote_qp;
+ destAddr.AddrType.Gsi.RemoteQkey =
+ p_mad_addr->addr_type.gsi.remote_qkey;
+ destAddr.AddrType.Gsi.PKey = OSM_DEFAULT_PKEY;
+ destAddr.AddrType.Gsi.ServiceLevel =
+ p_mad_addr->addr_type.gsi.service_level;
+ destAddr.AddrType.Gsi.GlobalRoute =
+ p_mad_addr->addr_type.gsi.global_route;
+ /* destAddr.AddrType.Gsi.GRHInfo = p_mad_addr->addr_type.gsi.grh_info; */
+ }
+ p_mad->trans_id = cl_ntoh64(p_mad->trans_id) << 24;
+
+ /* */
+ /* Create a transaction context for this send and save the TID and client context. */
+ /* */
+
+ if (resp_expected) {
+ p_trans_context = malloc(sizeof(trans_context_t));
+ CL_ASSERT(p_trans_context);
+
+ memset(p_trans_context, 0, sizeof(trans_context_t));
+ p_trans_context->trans_id = p_mad->trans_id;
+ p_trans_context->context = transaction_context;
+ p_trans_context->sent_time = cl_get_time_stamp();
+
+ cl_spinlock_acquire(&p_mad_bind_info->trans_ctxt_lock);
+ cl_qlist_insert_tail(&p_mad_bind_info->trans_ctxt_list,
+ &p_trans_context->list_item);
+ cl_spinlock_release(&p_mad_bind_info->trans_ctxt_lock);
+ }
+
+ if (p_mad_bind_info->umadt_reg_class.ClassId == IB_MCLASS_SUBN_LID ||
+ p_mad_bind_info->umadt_reg_class.ClassId == IB_MCLASS_SUBN_DIR) {
+ /* Get one mad from uMadt */
+ mad_count = 1;
+ Status =
+ p_umadt_obj->uMadtInterface.
+ uMadtGetSendMad(p_mad_bind_info->umadt_handle, &mad_count,
+ &p_madt_struct);
+
+ if (Status != FSUCCESS || p_madt_struct == NULL) {
+ return IB_ERROR;
+ }
+
+ /* No Segmentation required */
+ memcpy(&p_madt_struct->IBMad, p_mad, MAD_BLOCK_SIZE);
+
+ /* Post the MAD */
+
+ Status =
+ p_umadt_obj->uMadtInterface.uMadtPostSend(p_mad_bind_info->
+ umadt_handle,
+ p_madt_struct,
+ &destAddr);
+ if (Status != FSUCCESS) {
+ printf("uMadtPostSendMad: Status = <%d>\n", Status);
+ return IB_ERROR;
+ }
+
+ /* Release send MAD */
+ Status =
+ p_umadt_obj->uMadtInterface.
+ uMadtReleaseSendMad(p_mad_bind_info->umadt_handle,
+ p_madt_struct);
+ if (Status != FSUCCESS) {
+ printf("uMadtReleaseSendMad: Status = <%d>\n", Status);
+ return IB_ERROR;
+ }
+ } else {
+
+ /* */
+ /* Segment the MAD, get the required send mads from uMadt and post the MADs. */
+ /* */
+ uint32_t payload_len;
+
+ payload_len =
+ cl_ntoh32(((ib_sa_mad_t_vM3 *) p_mad)->payload_len);
+ num_mads = payload_len / IB_SA_DATA_SIZE;
+ if (payload_len % IB_SA_DATA_SIZE != 0) {
+ num_mads++; /* Get one additional mad for the remainder */
+ }
+ for (i = 0; i < num_mads; i++) {
+ /* Get one mad from uMadt */
+ mad_count = 1;
+ Status =
+ p_umadt_obj->uMadtInterface.
+ uMadtGetSendMad(p_mad_bind_info->umadt_handle,
+ &mad_count, &p_madt_struct);
+
+ if (Status != FSUCCESS || p_madt_struct == NULL) {
+ return IB_ERROR;
+ }
+ /* Copy client MAD into uMadt's MAD. */
+ if (i == 0) { /* First Packet */
+ /* Since this is the first MAD, copy the entire MAD_SIZE */
+ memcpy(&p_madt_struct->IBMad, p_mad,
+ MAD_BLOCK_SIZE);
+
+ p_frag_data =
+ (uint8_t *) p_mad + MAD_BLOCK_SIZE;
+
+ p_sa_mad =
+ (ib_sa_mad_t_vM3 *) & p_madt_struct->IBMad;
+ if (num_mads == 1) { /* Only one Packet */
+ p_sa_mad->seg_num = 0;
+ p_sa_mad->frag_flag = 5; /* Set bit 0 for first pkt and b4 for last pkt */
+ /* the payload length gets copied with the mad header above */
+ } else { /* More than one packet in this response */
+
+ seg_num = 1;
+ p_sa_mad->seg_num =
+ cl_ntoh32(seg_num++);
+ p_sa_mad->frag_flag = 1; /* Set bit 0 for first pkt */
+ /* the payload length gets copied with the mad header above */
+ }
+
+ } else if (i < num_mads - 1) { /* Not last packet */
+ /* First copy only the header */
+ memcpy(&p_madt_struct->IBMad, p_mad,
+ IB_SA_MAD_HDR_SIZE);
+ /* Set the relevant fields in the SA_MAD_HEADER */
+ p_sa_mad =
+ (ib_sa_mad_t_vM3 *) & p_madt_struct->IBMad;
+ p_sa_mad->payload_len =
+ cl_ntoh32(IB_SA_DATA_SIZE);
+ p_sa_mad->seg_num = cl_ntoh32(seg_num++);
+ p_sa_mad->frag_flag = 0;
+ /* Now copy the fragmented data */
+ memcpy(((uint8_t *) & p_madt_struct->IBMad) +
+ IB_SA_MAD_HDR_SIZE, p_frag_data,
+ IB_SA_DATA_SIZE);
+ p_frag_data = p_frag_data + IB_SA_DATA_SIZE;
+
+ } else if (i == num_mads - 1) { /* Last packet */
+ /* First copy only the header */
+ memcpy(&p_madt_struct->IBMad, p_mad,
+ IB_SA_MAD_HDR_SIZE);
+ /* Set the relevant fields in the SA_MAD_HEADER */
+ p_sa_mad =
+ (ib_sa_mad_t_vM3 *) & p_madt_struct->IBMad;
+ p_sa_mad->seg_num = cl_ntoh32(seg_num++);
+ p_sa_mad->frag_flag = 4; /* Set Bit 2 for last pkt */
+ p_sa_mad->payload_len =
+ cl_ntoh32(cl_ntoh32
+ (((ib_sa_mad_t_vM3 *) p_mad)->
+ payload_len) % IB_SA_DATA_SIZE);
+ /* Now copy the fragmented data */
+ memcpy((((uint8_t *) & p_madt_struct->IBMad)) +
+ IB_SA_MAD_HDR_SIZE, p_frag_data,
+ cl_ntoh32(p_sa_mad->payload_len));
+ p_frag_data = p_frag_data + IB_SA_DATA_SIZE;
+
+ }
+ /* Post the MAD */
+ Status =
+ p_umadt_obj->uMadtInterface.
+ uMadtPostSend(p_mad_bind_info->umadt_handle,
+ p_madt_struct, &destAddr);
+ if (Status != FSUCCESS) {
+ printf("uMadtPostSendMad: Status = <%d>\n",
+ Status);
+ return IB_ERROR;
+ }
+
+ /* Release send MAD */
+ Status =
+ p_umadt_obj->uMadtInterface.
+ uMadtReleaseSendMad(p_mad_bind_info->umadt_handle,
+ p_madt_struct);
+ if (Status != FSUCCESS) {
+ printf("uMadtReleaseSendMad: Status = <%d>\n",
+ Status);
+ return IB_ERROR;
+ }
+ }
+ }
+ return (IB_SUCCESS);
+}
+
+/* //////////////////////////////////////////////////////////////////////// */
+/* See VendorAbstractMadIntf.h for info */
+/* //////////////////////////////////////////////////////////////////////// */
+
+osm_bind_handle_t
+osm_vendor_bind(IN osm_vendor_t * const p_vend,
+ IN osm_bind_info_t * const p_osm_bind_info,
+ IN osm_mad_pool_t * const p_mad_pool,
+ IN osm_vend_mad_recv_callback_t mad_recv_callback,
+ IN void *context)
+{
+ cl_status_t cl_status;
+ FSTATUS Status; /* GEN1 Status for Umadt */
+
+ mad_bind_info_t *p_mad_bind_info;
+ RegisterClassStruct *p_umadt_reg_class;
+
+ umadt_obj_t *p_umadt_obj;
+ OSM_LOG_ENTER(((umadt_obj_t *) p_vend)->p_log);
+
+ CL_ASSERT(p_vend);
+
+ p_umadt_obj = (umadt_obj_t *) p_vend;
+
+ /* Sanity check */
+ CL_ASSERT(p_umadt_obj->init_done);
+ CL_ASSERT(p_osm_bind_info);
+ CL_ASSERT(p_mad_pool);
+ CL_ASSERT(mad_recv_callback);
+
+ /* Allocate memory for registering the handle. */
+ p_mad_bind_info = (mad_bind_info_t *) malloc(sizeof(*p_mad_bind_info));
+ if (p_mad_bind_info) {
+ memset(p_mad_bind_info, 0, sizeof(*p_mad_bind_info));
+ p_umadt_reg_class = &p_mad_bind_info->umadt_reg_class;
+ }
+ p_umadt_reg_class->PortGuid = cl_ntoh64(p_osm_bind_info->port_guid);
+ p_umadt_reg_class->ClassId = p_osm_bind_info->mad_class;
+ p_umadt_reg_class->ClassVersion = p_osm_bind_info->class_version;
+ p_umadt_reg_class->isResponder = p_osm_bind_info->is_responder;
+ p_umadt_reg_class->isTrapProcessor = p_osm_bind_info->is_trap_processor;
+ p_umadt_reg_class->isReportProcessor =
+ p_osm_bind_info->is_report_processor;
+ p_umadt_reg_class->SendQueueSize = p_osm_bind_info->send_q_size;
+ p_umadt_reg_class->RecvQueueSize = p_osm_bind_info->recv_q_size;
+ p_umadt_reg_class->NotifySendCompletion = TRUE;
+
+ p_mad_bind_info->p_umadt_obj = p_umadt_obj;
+ p_mad_bind_info->p_mad_pool = p_mad_pool;
+ p_mad_bind_info->mad_recv_callback = mad_recv_callback;
+ p_mad_bind_info->client_context = context;
+
+ /* register with Umadt for MAD interface */
+ Status = p_umadt_obj->uMadtInterface.uMadtRegister(p_umadt_reg_class,
+ &p_mad_bind_info->
+ umadt_handle);
+ if (Status != FSUCCESS) {
+ free(p_mad_bind_info);
+ OSM_LOG_EXIT(p_umadt_obj->p_log);
+ return (OSM_BIND_INVALID_HANDLE);
+ }
+ CL_ASSERT(p_mad_bind_info->umadt_handle);
+ /* */
+ /* Start a worker thread to process receives. */
+ /* */
+ cl_thread_construct(&p_mad_bind_info->recv_processor_thread);
+ cl_status = cl_thread_init(&p_mad_bind_info->recv_processor_thread,
+ __mad_recv_processor,
+ (void *)p_mad_bind_info, "mad_recv_worker");
+ CL_ASSERT(cl_status == CL_SUCCESS);
+
+ cl_qlist_init(&p_mad_bind_info->trans_ctxt_list);
+ cl_spinlock_construct(&p_mad_bind_info->trans_ctxt_lock);
+ cl_spinlock_init(&p_mad_bind_info->trans_ctxt_lock);
+ cl_spinlock_construct(&p_mad_bind_info->timeout_list_lock);
+ cl_spinlock_init(&p_mad_bind_info->timeout_list_lock);
+
+ cl_status = cl_timer_init(&p_mad_bind_info->timeout_timer,
+ __osm_vendor_timer_callback,
+ (void *)p_mad_bind_info);
+ CL_ASSERT(cl_status == CL_SUCCESS);
+ cl_qlist_init(&p_mad_bind_info->timeout_list);
+ /* */
+ /* Insert the mad_reg_struct in list and return pointer to it as the handle */
+ /* */
+ cl_spinlock_acquire(&p_umadt_obj->register_lock);
+
+ cl_qlist_insert_head(&p_umadt_obj->register_list,
+ &p_mad_bind_info->list_item);
+
+ cl_spinlock_release(&p_umadt_obj->register_lock);
+
+ /*
+ A timeout value of 0 means disable timeouts.
+ */
+ if (p_umadt_obj->timeout) {
+ cl_timer_start(&p_mad_bind_info->timeout_timer,
+ DEFAULT_TIMER_INTERVAL_MSEC);
+ }
+
+ OSM_LOG_EXIT(p_umadt_obj->p_log);
+ return ((osm_bind_handle_t) p_mad_bind_info);
+}
+
+void osm_vendor_unbind(IN osm_bind_handle_t h_bind)
+{
+ mad_bind_info_t *p_mad_bind_info;
+ umadt_obj_t *p_umadt_obj;
+ cl_list_item_t *p_list_item, *p_next_list_item;
+
+ CL_ASSERT(h_bind);
+ p_mad_bind_info = (mad_bind_info_t *) h_bind;
+ p_umadt_obj = p_mad_bind_info->p_umadt_obj;
+
+ /* sanity check */
+ CL_ASSERT(p_umadt_obj);
+ CL_ASSERT(p_umadt_obj->init_done);
+ CL_ASSERT(__valid_mad_handle(p_mad_bind_info));
+
+ p_umadt_obj->uMadtInterface.uMadtDestroy(&p_mad_bind_info->
+ umadt_handle);
+ cl_timer_destroy(&p_mad_bind_info->timeout_timer);
+ cl_thread_destroy(&p_mad_bind_info->recv_processor_thread);
+
+ cl_spinlock_acquire(&p_mad_bind_info->trans_ctxt_lock);
+ p_list_item = cl_qlist_head(&p_mad_bind_info->trans_ctxt_list);
+ while (p_list_item != cl_qlist_end(&p_mad_bind_info->trans_ctxt_list)) {
+ p_next_list_item = cl_qlist_next(p_list_item);
+ cl_qlist_remove_item(&p_mad_bind_info->trans_ctxt_list,
+ p_list_item);
+ free(p_list_item);
+ p_list_item = p_next_list_item;
+ }
+ cl_spinlock_release(&p_mad_bind_info->trans_ctxt_lock);
+
+ cl_spinlock_acquire(&p_mad_bind_info->timeout_list_lock);
+ p_list_item = cl_qlist_head(&p_mad_bind_info->timeout_list);
+ while (p_list_item != cl_qlist_end(&p_mad_bind_info->timeout_list)) {
+ p_next_list_item = cl_qlist_next(p_list_item);
+ cl_qlist_remove_item(&p_mad_bind_info->timeout_list,
+ p_list_item);
+ free(p_list_item);
+ p_list_item = p_next_list_item;
+ }
+ cl_spinlock_release(&p_mad_bind_info->timeout_list_lock);
+
+ free(p_mad_bind_info);
+}
+
+void __mad_recv_processor(IN void *context)
+{
+ mad_bind_info_t *p_mad_bind_info = (mad_bind_info_t *) context;
+ umadt_obj_t *p_umadt_obj;
+ osm_madw_t *p_osm_madw = NULL;
+ osm_vend_wrap_t *p_vend_wrap = NULL;
+ osm_mad_addr_t osm_mad_addr = { 0 };
+ cl_list_item_t *p_list_item;
+ void *transaction_context;
+
+ FSTATUS Status;
+ MadtStruct *pRecvMad = NULL;
+ MadWorkCompletion *pRecvCmp = NULL;
+
+ CL_ASSERT(context);
+
+ p_mad_bind_info = (mad_bind_info_t *) context;
+ p_umadt_obj = p_mad_bind_info->p_umadt_obj;
+ /* PollFor a completion */
+ /* if FNOTFOND, then wait for a completion then again poll and return the MAD */
+ while (1) {
+ Status =
+ p_umadt_obj->uMadtInterface.
+ uMadtPollForRecvCompletion(p_mad_bind_info->umadt_handle,
+ &pRecvMad, &pRecvCmp);
+ if (Status != FSUCCESS) {
+ if (Status == FNOT_FOUND) {
+ /* Wait for a completion */
+ Status = p_umadt_obj->uMadtInterface.uMadtWaitForAnyCompletion(p_mad_bind_info->umadt_handle, RECV_COMPLETION, 0x5000); /* 5 sec timeout */
+
+ if (Status == FTIMEOUT) {
+ continue;
+ }
+ CL_ASSERT(Status == FSUCCESS);
+
+ Status =
+ p_umadt_obj->uMadtInterface.
+ uMadtPollForRecvCompletion(p_mad_bind_info->
+ umadt_handle,
+ &pRecvMad,
+ &pRecvCmp);
+ if (Status != FSUCCESS) {
+ printf
+ (" mad_recv_worker: Error in PollForRecv returning <%x>\n",
+ Status);
+ CL_ASSERT(0);
+ }
+ } else {
+ printf
+ ("uMadtPollForRecvCompletion Status=<%x>\n",
+ Status);
+ CL_ASSERT(0);
+ }
+ }
+ CL_ASSERT(pRecvMad);
+ CL_ASSERT(pRecvCmp);
+
+ if (((ib_sa_mad_t_vM3 *) (&pRecvMad->IBMad))->frag_flag & 0x20) {
+ /* Ignore the ACK packet */
+ Status =
+ p_umadt_obj->uMadtInterface.
+ uMadtReleaseRecvMad(p_mad_bind_info->umadt_handle,
+ pRecvMad);
+ continue;
+ }
+ /* */
+ /* Extract the return address to pass it on to the client */
+ /* */
+ osm_mad_addr.dest_lid = pRecvCmp->AddressInfo.DestLid;
+ osm_mad_addr.path_bits = pRecvCmp->AddressInfo.PathBits;
+ osm_mad_addr.static_rate = pRecvCmp->AddressInfo.StaticRate;
+
+ if (p_mad_bind_info->umadt_reg_class.ClassId ==
+ IB_MCLASS_SUBN_LID
+ || p_mad_bind_info->umadt_reg_class.ClassId ==
+ IB_MCLASS_SUBN_DIR) {
+ osm_mad_addr.addr_type.smi.source_lid =
+ pRecvCmp->AddressInfo.AddrType.Smi.SourceLid;
+ /* osm_mad_addr.addr_type.smi.port_num = pRecvCmp->AddressInfo.AddrType.Smi.PortNumber; */
+ } else {
+ osm_mad_addr.addr_type.gsi.remote_qp =
+ pRecvCmp->AddressInfo.AddrType.Gsi.RemoteQpNumber;
+ osm_mad_addr.addr_type.gsi.remote_qkey =
+ pRecvCmp->AddressInfo.AddrType.Gsi.RemoteQkey;
+ osm_mad_addr.addr_type.gsi.pkey_ix = 0;
+ osm_mad_addr.addr_type.gsi.service_level =
+ pRecvCmp->AddressInfo.AddrType.Gsi.ServiceLevel;
+ osm_mad_addr.addr_type.gsi.global_route =
+ pRecvCmp->AddressInfo.AddrType.Gsi.GlobalRoute;
+ /* osm_mad_addr.addr_type.gsi.grh_info = pRecvCmp->AddressInfo.AddrType.Gsi.GRHInfo; */
+ }
+ p_osm_madw =
+ osm_mad_pool_get_wrapper(p_mad_bind_info->p_mad_pool,
+ p_mad_bind_info, MAD_BLOCK_SIZE,
+ (ib_mad_t *) & pRecvMad->IBMad,
+ &osm_mad_addr);
+ CL_ASSERT(p_osm_madw);
+ p_vend_wrap = osm_madw_get_vend_ptr(p_osm_madw);
+ CL_ASSERT(p_vend_wrap);
+ p_vend_wrap->p_madt_struct = pRecvMad;
+ p_vend_wrap->direction = RECEIVE;
+
+ osm_log(p_mad_bind_info->p_umadt_obj->p_log, OSM_LOG_DEBUG,
+ "__mad_recv_processor: "
+ "Received data p_osm_madw[0x%p].\n", p_osm_madw);
+
+ /* */
+ /* Do TID Processing. */
+ /* */
+ /* If R bit is set swap the TID */
+
+ cl_spinlock_acquire(&p_mad_bind_info->trans_ctxt_lock);
+ p_list_item =
+ cl_qlist_find_from_head(&p_mad_bind_info->trans_ctxt_list,
+ __match_tid_context,
+ &p_osm_madw->p_mad->trans_id);
+
+ if (p_list_item ==
+ cl_qlist_end(&p_mad_bind_info->trans_ctxt_list)) {
+ transaction_context = NULL;
+ } else {
+ transaction_context =
+ ((trans_context_t *) p_list_item)->context;
+ cl_qlist_remove_item(&p_mad_bind_info->trans_ctxt_list,
+ p_list_item);
+ free(p_list_item);
+ }
+ cl_spinlock_release(&p_mad_bind_info->trans_ctxt_lock);
+ ((ib_mad_t *) p_osm_madw->p_mad)->trans_id =
+ cl_ntoh64(p_osm_madw->p_mad->trans_id >> 24);
+ osm_log(p_mad_bind_info->p_umadt_obj->p_log, OSM_LOG_DEBUG,
+ "__mad_recv_processor: "
+ "Received data p_osm_madw [0x%p]" "\n\t\t\t\tTID[0x%"
+ PRIx64 ", context[%p]. \n", p_osm_madw,
+ ((ib_mad_t *) p_osm_madw->p_mad)->trans_id,
+ transaction_context);
+
+ (*(p_mad_bind_info->mad_recv_callback)) (p_osm_madw,
+ p_mad_bind_info->
+ client_context,
+ transaction_context);
+
+ }
+}
+
+cl_status_t
+__match_tid_context(const cl_list_item_t * const p_list_item, void *context)
+{
+ if (((trans_context_t *) p_list_item)->trans_id ==
+ *((uint64_t *) context))
+ return CL_SUCCESS;
+ return CL_NOT_FOUND;
+}
+
+boolean_t __valid_mad_handle(IN mad_bind_info_t * p_mad_bind_info)
+{
+
+ umadt_obj_t *p_umadt_obj;
+
+ p_umadt_obj = p_mad_bind_info->p_umadt_obj;
+
+ cl_spinlock_acquire(&p_umadt_obj->register_lock);
+ if (!cl_is_item_in_qlist(&p_umadt_obj->register_list,
+ &p_mad_bind_info->list_item)) {
+ cl_spinlock_release(&p_umadt_obj->register_lock);
+ return FALSE;
+ }
+ cl_spinlock_release(&p_umadt_obj->register_lock);
+ return TRUE;
+}
+
+void __osm_vendor_timer_callback(IN void *context)
+{
+ uint64_t current_time;
+ mad_bind_info_t *p_mad_bind_info;
+ umadt_obj_t *p_umadt_obj;
+ uint32_t timeout;
+
+ cl_list_item_t *p_list_item, *p_next_list_item;
+
+ CL_ASSERT(context);
+
+ p_mad_bind_info = (mad_bind_info_t *) context;
+ p_umadt_obj = p_mad_bind_info->p_umadt_obj;
+ timeout = p_umadt_obj->timeout * 1000;
+
+ current_time = cl_get_time_stamp();
+
+ cl_spinlock_acquire(&p_mad_bind_info->trans_ctxt_lock);
+
+ p_list_item = cl_qlist_head(&p_mad_bind_info->trans_ctxt_list);
+ while (p_list_item != cl_qlist_end(&p_mad_bind_info->trans_ctxt_list)) {
+
+ p_next_list_item = cl_qlist_next(p_list_item);
+
+ /* DEFAULT_PKT_TIMEOUT is in milli seconds */
+ if (current_time - ((trans_context_t *) p_list_item)->sent_time
+ > timeout) {
+ /* Add this transaction to the timeout_list */
+ cl_qlist_remove_item(&p_mad_bind_info->trans_ctxt_list,
+ p_list_item);
+ cl_qlist_insert_tail(&p_mad_bind_info->timeout_list,
+ p_list_item);
+ }
+
+ p_list_item = p_next_list_item;
+ }
+
+ cl_spinlock_release(&p_mad_bind_info->trans_ctxt_lock);
+
+ p_list_item = cl_qlist_head(&p_mad_bind_info->timeout_list);
+ while (p_list_item != cl_qlist_end(&p_mad_bind_info->timeout_list)) {
+ osm_log(p_mad_bind_info->p_umadt_obj->p_log, OSM_LOG_DEBUG,
+ "__osm_vendor_timer_callback: "
+ "Timing out transaction context [0x%p].\n",
+ ((trans_context_t *) p_list_item)->context);
+
+ (*(p_mad_bind_info->mad_recv_callback)) (NULL,
+ p_mad_bind_info->
+ client_context,
+ ((trans_context_t *)
+ p_list_item)->
+ context);
+
+ p_next_list_item = cl_qlist_next(p_list_item);
+ cl_qlist_remove_item(&p_mad_bind_info->timeout_list,
+ p_list_item);
+ free(p_list_item);
+ p_list_item = p_next_list_item;
+ }
+
+ cl_timer_start(&p_mad_bind_info->timeout_timer,
+ DEFAULT_TIMER_INTERVAL_MSEC);
+
+}
+
+#endif /* OSM_VENDOR_INTF_UMADT */
diff --git a/contrib/ofed/opensm/man/opensm.8 b/contrib/ofed/opensm/man/opensm.8
new file mode 100644
index 0000000..811f82d
--- /dev/null
+++ b/contrib/ofed/opensm/man/opensm.8
@@ -0,0 +1,1561 @@
+.TH OPENSM 8 "Sept 15, 2014" "OpenIB" "OpenIB Management"
+
+.SH NAME
+opensm \- InfiniBand subnet manager and administration (SM/SA)
+
+.SH SYNOPSIS
+.B opensm
+[\-\-version]]
+[\-F | \-\-config <file_name>]
+[\-c(reate-config) <file_name>]
+[\-g(uid) <GUID in hex>]
+[\-l(mc) <LMC>]
+[\-p(riority) <PRIORITY>]
+[\-\-smkey <SM_Key>]
+[\-\-sm_sl <SL number>]
+[\-r(eassign_lids)]
+[\-R <engine name(s)> | \-\-routing_engine <engine name(s)>]
+[\-\-do_mesh_analysis]
+[\-\-lash_start_vl <vl number>]
+[\-A | \-\-ucast_cache]
+[\-z | \-\-connect_roots]
+[\-M <file name> | \-\-lid_matrix_file <file name>]
+[\-U <file name> | \-\-lfts_file <file name>]
+[\-S | \-\-sadb_file <file name>]
+[\-a | \-\-root_guid_file <path to file>]
+[\-u | \-\-cn_guid_file <path to file>]
+[\-G | \-\-io_guid_file <path to file>]
+[\-\-port\-shifting]
+[\-\-scatter\-ports <random seed>]
+[\-H | \-\-max_reverse_hops <max reverse hops allowed>]
+[\-X | \-\-guid_routing_order_file <path to file>]
+[\-m | \-\-ids_guid_file <path to file>]
+[\-o(nce)]
+[\-s(weep) <interval>]
+[\-t(imeout) <milliseconds>]
+[\-\-retries <number>]
+[\-\-maxsmps <number>]
+[\-\-console [off | local | socket | loopback]]
+[\-\-console-port <port>]
+[\-i | \-\-ignore_guids <equalize-ignore-guids-file>]
+[\-w | \-\-hop_weights_file <path to file>]
+[\-O | \-\-port_search_ordering_file <path to file>]
+[\-O | \-\-dimn_ports_file <path to file>] (DEPRECATED)
+[\-f <log file path> | \-\-log_file <log file path> ]
+[\-L | \-\-log_limit <size in MB>] [\-e(rase_log_file)]
+[\-P(config) <partition config file> ]
+[\-N | \-\-no_part_enforce] (DEPRECATED)
+[\-Z | \-\-part_enforce [both | in | out | off]]
+[\-W | \-\-allow_both_pkeys]
+[\-Q | \-\-qos [\-Y | \-\-qos_policy_file <file name>]]
+[\-\-congestion\-control]
+[\-\-cckey <key>]
+[\-y | \-\-stay_on_fatal]
+[\-B | \-\-daemon]
+[\-J | \-\-pidfile <file_name>]
+[\-I | \-\-inactive]
+[\-\-perfmgr]
+[\-\-perfmgr_sweep_time_s <seconds>]
+[\-\-prefix_routes_file <path>]
+[\-\-consolidate_ipv6_snm_req]
+[\-\-log_prefix <prefix text>]
+[\-\-torus_config <path to file>]
+[\-v(erbose)] [\-V] [\-D <flags>] [\-d(ebug) <number>]
+[\-h(elp)] [\-?]
+
+.SH DESCRIPTION
+.PP
+opensm is an InfiniBand compliant Subnet Manager and Administration,
+and runs on top of OpenIB.
+
+opensm provides an implementation of an InfiniBand Subnet Manager and
+Administration. Such a software entity is required to run for in order
+to initialize the InfiniBand hardware (at least one per each
+InfiniBand subnet).
+
+opensm also now contains an experimental version of a performance
+manager as well.
+
+opensm defaults were designed to meet the common case usage on clusters with up to a few hundred nodes. Thus, in this default mode, opensm will scan the IB
+fabric, initialize it, and sweep occasionally for changes.
+
+opensm attaches to a specific IB port on the local machine and configures only
+the fabric connected to it. (If the local machine has other IB ports,
+opensm will ignore the fabrics connected to those other ports). If no port is
+specified, it will select the first "best" available port.
+
+opensm can present the available ports and prompt for a port number to
+attach to.
+
+By default, the run is logged to two files: /var/log/messages and /var/log/opensm.log.
+The first file will register only general major events, whereas the second
+will include details of reported errors. All errors reported in this second
+file should be treated as indicators of IB fabric health issues.
+(Note that when a fatal and non-recoverable error occurs, opensm will exit.)
+Both log files should include the message "SUBNET UP" if opensm was able to
+setup the subnet correctly.
+
+.SH OPTIONS
+
+.PP
+.TP
+\fB\-\-version\fR
+Prints OpenSM version and exits.
+.TP
+\fB\-F\fR, \fB\-\-config\fR <config file>
+The name of the OpenSM config file. When not specified
+\fB\% /etc/opensm/opensm.conf\fP will be used (if exists).
+.TP
+\fB\-c\fR, \fB\-\-create-config\fR <file name>
+OpenSM will dump its configuration to the specified file and exit.
+This is a way to generate OpenSM configuration file template.
+.TP
+\fB\-g\fR, \fB\-\-guid\fR <GUID in hex>
+This option specifies the local port GUID value
+with which OpenSM should bind. OpenSM may be
+bound to 1 port at a time.
+If GUID given is 0, OpenSM displays a list
+of possible port GUIDs and waits for user input.
+Without -g, OpenSM tries to use the default port.
+.TP
+\fB\-l\fR, \fB\-\-lmc\fR <LMC value>
+This option specifies the subnet's LMC value.
+The number of LIDs assigned to each port is 2^LMC.
+The LMC value must be in the range 0-7.
+LMC values > 0 allow multiple paths between ports.
+LMC values > 0 should only be used if the subnet
+topology actually provides multiple paths between
+ports, i.e. multiple interconnects between switches.
+Without -l, OpenSM defaults to LMC = 0, which allows
+one path between any two ports.
+.TP
+\fB\-p\fR, \fB\-\-priority\fR <Priority value>
+This option specifies the SM\'s PRIORITY.
+This will effect the handover cases, where master
+is chosen by priority and GUID. Range goes from 0
+(default and lowest priority) to 15 (highest).
+.TP
+\fB\-\-smkey\fR <SM_Key value>
+This option specifies the SM\'s SM_Key (64 bits).
+This will effect SM authentication.
+Note that OpenSM version 3.2.1 and below used the default value '1'
+in a host byte order, it is fixed now but you may need this option to
+interoperate with old OpenSM running on a little endian machine.
+.TP
+\fB\-\-sm_sl\fR <SL number>
+This option sets the SL to use for communication with the SM/SA.
+Defaults to 0.
+.TP
+\fB\-r\fR, \fB\-\-reassign_lids\fR
+This option causes OpenSM to reassign LIDs to all
+end nodes. Specifying -r on a running subnet
+may disrupt subnet traffic.
+Without -r, OpenSM attempts to preserve existing
+LID assignments resolving multiple use of same LID.
+.TP
+\fB\-R\fR, \fB\-\-routing_engine\fR <Routing engine names>
+This option chooses routing engine(s) to use instead of Min Hop
+algorithm (default). Multiple routing engines can be specified
+separated by commas so that specific ordering of routing algorithms
+will be tried if earlier routing engines fail. If all configured
+routing engines fail, OpenSM will always attempt to route with Min Hop
+unless 'no_fallback' is included in the list of routing engines.
+Supported engines: minhop, updn, dnup, file, ftree, lash, dor, torus-2QoS,
+dfsssp, sssp.
+.TP
+\fB\-\-do_mesh_analysis\fR
+This option enables additional analysis for the lash routing engine to
+precondition switch port assignments in regular cartesian meshes which
+may reduce the number of SLs required to give a deadlock free routing.
+.TP
+\fB\-\-lash_start_vl\fR <vl number>
+This option sets the starting VL to use for the lash routing algorithm.
+Defaults to 0.
+.TP
+\fB\-A\fR, \fB\-\-ucast_cache\fR
+This option enables unicast routing cache and prevents routing
+recalculation (which is a heavy task in a large cluster) when
+there was no topology change detected during the heavy sweep, or
+when the topology change does not require new routing calculation,
+e.g. when one or more CAs/RTRs/leaf switches going down, or one or
+more of these nodes coming back after being down.
+A very common case that is handled by the unicast routing cache
+is host reboot, which otherwise would cause two full routing
+recalculations: one when the host goes down, and the other when
+the host comes back online.
+.TP
+\fB\-z\fR, \fB\-\-connect_roots\fR
+This option enforces routing engines (up/down and
+fat-tree) to make connectivity between root switches and in
+this way to be fully IBA compliant. In many cases this can
+violate "pure" deadlock free algorithm, so use it carefully.
+.TP
+\fB\-M\fR, \fB\-\-lid_matrix_file\fR <file name>
+This option specifies the name of the lid matrix dump file
+from where switch lid matrices (min hops tables) will be
+loaded.
+.TP
+\fB\-U\fR, \fB\-\-lfts_file\fR <file name>
+This option specifies the name of the LFTs file
+from where switch forwarding tables will be loaded when using "file" routing
+engine.
+.TP
+\fB\-S\fR, \fB\-\-sadb_file\fR <file name>
+This option specifies the name of the SA DB dump file
+from where SA database will be loaded.
+.TP
+\fB\-a\fR, \fB\-\-root_guid_file\fR <file name>
+Set the root nodes for the Up/Down or Fat-Tree routing
+algorithm to the guids provided in the given file (one to a line).
+.TP
+\fB\-u\fR, \fB\-\-cn_guid_file\fR <file name>
+Set the compute nodes for the Fat-Tree or DFSSSP/SSSP routing algorithms
+to the port GUIDs provided in the given file (one to a line).
+.TP
+\fB\-G\fR, \fB\-\-io_guid_file\fR <file name>
+Set the I/O nodes for the Fat-Tree or DFSSSP/SSSP routing algorithms
+to the port GUIDs provided in the given file (one to a line).
+.br
+In the case of Fat-Tree routing:
+.br
+I/O nodes are non-CN nodes allowed to use up to max_reverse_hops switches
+the wrong way around to improve connectivity.
+.br
+In the case of (DF)SSSP routing:
+.br
+Providing guids of compute and/or I/O nodes will ensure that paths towards
+those nodes are as much separated as possible within their node category,
+i.e., I/O traffic will not share the same link if multiple links are available.
+.TP
+\fB\-\-port\-shifting\fR
+This option enables a feature called \fBport shifting\fR. In some
+fabrics, particularly cluster environments, routes commonly align and
+congest with other routes due to algorithmically unchanging traffic
+patterns. This routing option will "shift" routing around in an
+attempt to alleviate this problem.
+.TP
+\fB\-\-scatter\-ports\fR <random seed>
+This option is used to randomize port selection in routing rather than
+using a round-robin algorithm (which is the default). Value supplied
+with option is used as a random seed. If value is 0,
+which is the default, the scatter ports option is disabled.
+.TP
+\fB\-H\fR, \fB\-\-max_reverse_hops\fR <max reverse hops allowed>
+Set the maximum number of reverse hops an I/O node is allowed
+to make. A reverse hop is the use of a switch the wrong way around.
+.TP
+\fB\-m\fR, \fB\-\-ids_guid_file\fR <file name>
+Name of the map file with set of the IDs which will be used
+by Up/Down routing algorithm instead of node GUIDs
+(format: <guid> <id> per line).
+.TP
+\fB\-X\fR, \fB\-\-guid_routing_order_file\fR <file name>
+Set the order port guids will be routed for the MinHop
+and Up/Down routing algorithms to the guids provided in the
+given file (one to a line).
+.TP
+\fB\-o\fR, \fB\-\-once\fR
+This option causes OpenSM to configure the subnet
+once, then exit. Ports remain in the ACTIVE state.
+.TP
+\fB\-s\fR, \fB\-\-sweep\fR <interval value>
+This option specifies the number of seconds between
+subnet sweeps. Specifying -s 0 disables sweeping.
+Without -s, OpenSM defaults to a sweep interval of
+10 seconds.
+.TP
+\fB\-t\fR, \fB\-\-timeout\fR <value>
+This option specifies the time in milliseconds
+used for transaction timeouts.
+Timeout values should be > 0.
+Without -t, OpenSM defaults to a timeout value of
+200 milliseconds.
+.TP
+\fB\-\-retries\fR <number>
+This option specifies the number of retries used
+for transactions.
+Without --retries, OpenSM defaults to 3 retries
+for transactions.
+.TP
+\fB\-\-maxsmps\fR <number>
+This option specifies the number of VL15 SMP MADs
+allowed on the wire at any one time.
+Specifying \-\-maxsmps 0 allows unlimited outstanding
+SMPs.
+Without \-\-maxsmps, OpenSM defaults to a maximum of
+4 outstanding SMPs.
+.TP
+\fB\-\-console [off | local | loopback | socket]\fR
+This option brings up the OpenSM console (default off). Note, loopback and
+socket open a socket which can be connected to WITHOUT CREDENTIALS. Loopback
+is safer if access to your SM host is controlled. tcp_wrappers
+(hosts.[allow|deny]) is used with loopback and socket. loopback and socket
+will only be available if OpenSM was built with --enable-console-loopback
+(default yes) and --enable-console-socket (default no) respectively.
+.TP
+\fB\-\-console-port\fR <port>
+Specify an alternate telnet port for the socket console (default 10000).
+Note that this option only appears if OpenSM was built with
+--enable-console-socket.
+.TP
+\fB\-i\fR, \fB\-\-ignore_guids\fR <equalize-ignore-guids-file>
+This option provides the means to define a set of ports
+(by node guid and port number) that will be ignored by the link load
+equalization algorithm.
+.TP
+\fB\-w\fR, \fB\-\-hop_weights_file\fR <path to file>
+This option provides weighting factors per port representing a hop cost in
+computing the lid matrix. The file consists of lines containing a switch port
+GUID (specified as a 64 bit hex number, with leading 0x), output port number,
+and weighting factor. Any port not listed in the file defaults to a weighting
+factor of 1. Lines starting with # are comments. Weights affect only the
+output route from the port, so many useful configurations will require weights
+to be specified in pairs.
+.TP
+\fB\-O\fR, \fB\-\-port_search_ordering_file\fR <path to file>
+This option tweaks the routing. It suitable for two cases:
+1. While using DOR routing algorithm.
+This option provides a mapping between hypercube dimensions and ports
+on a per switch basis for the DOR routing engine. The file consists
+of lines containing a switch node GUID (specified as a 64 bit hex
+number, with leading 0x) followed by a list of non-zero port numbers,
+separated by spaces, one switch per line. The order for the port
+numbers is in one to one correspondence to the dimensions. Ports not
+listed on a line are assigned to the remaining dimensions, in port
+order. Anything after a # is a comment.
+2. While using general routing algorithm.
+This option provides the order of the ports that would be chosen for routing,
+from each switch rather than searching for an appropriate port from port 1 to N.
+The file consists of lines containing a switch node GUID (specified as a 64 bit
+hex number, with leading 0x) followed by a list of non-zero port numbers,
+separated by spaces, one switch per line. In case of DOR, the order for the
+port numbers is in one to one correspondence to the dimensions. Ports not
+listed on a line are assigned to the remaining dimensions, in port
+order. Anything after a # is a comment.
+.TP
+\fB\-O\fR, \fB\-\-dimn_ports_file\fR <path to file> \fB(DEPRECATED)\fR
+This is a deprecated flag. Please use \fB\-\-port_search_ordering_file\fR instead.
+This option provides a mapping between hypercube dimensions and ports
+on a per switch basis for the DOR routing engine. The file consists
+of lines containing a switch node GUID (specified as a 64 bit hex
+number, with leading 0x) followed by a list of non-zero port numbers,
+separated by spaces, one switch per line. The order for the port
+numbers is in one to one correspondence to the dimensions. Ports not
+listed on a line are assigned to the remaining dimensions, in port
+order. Anything after a # is a comment.
+.TP
+\fB\-x\fR, \fB\-\-honor_guid2lid\fR
+This option forces OpenSM to honor the guid2lid file,
+when it comes out of Standby state, if such file exists
+under OSM_CACHE_DIR, and is valid.
+By default, this is FALSE.
+.TP
+\fB\-f\fR, \fB\-\-log_file\fR <file name>
+This option defines the log to be the given file.
+By default, the log goes to /var/log/opensm.log.
+For the log to go to standard output use -f stdout.
+.TP
+\fB\-L\fR, \fB\-\-log_limit\fR <size in MB>
+This option defines maximal log file size in MB. When
+specified the log file will be truncated upon reaching
+this limit.
+.TP
+\fB\-e\fR, \fB\-\-erase_log_file\fR
+This option will cause deletion of the log file
+(if it previously exists). By default, the log file
+is accumulative.
+.TP
+\fB\-P\fR, \fB\-\-Pconfig\fR <partition config file>
+This option defines the optional partition configuration file.
+The default name is \fB\%/etc/opensm/partitions.conf\fP.
+.TP
+\fB\-\-prefix_routes_file\fR <file name>
+Prefix routes control how the SA responds to path record queries for
+off-subnet DGIDs. By default, the SA fails such queries. The
+.B PREFIX ROUTES
+section below describes the format of the configuration file.
+The default path is \fB\%/etc/opensm/prefix\-routes.conf\fP.
+.TP
+\fB\-Q\fR, \fB\-\-qos\fR
+This option enables QoS setup. It is disabled by default.
+.TP
+\fB\-Y\fR, \fB\-\-qos_policy_file\fR <file name>
+This option defines the optional QoS policy file. The default
+name is \fB\%/etc/opensm/qos-policy.conf\fP. See
+QoS_management_in_OpenSM.txt in opensm doc for more information on
+configuring QoS policy via this file.
+.TP
+\fB\-\-congestion_control\fR
+(EXPERIMENTAL) This option enables congestion control configuration.
+It is disabled by default. See config file for congestion control
+configuration options.
+\fB\-\-cc_key\fR <key>
+(EXPERIMENTAL) This option configures the CCkey to use when configuring
+congestion control. Note that this option does not configure a new
+CCkey into switches and CAs. Defaults to 0.
+.TP
+\fB\-N\fR, \fB\-\-no_part_enforce\fR \fB(DEPRECATED)\fR
+This is a deprecated flag. Please use \fB\-\-part_enforce\fR instead.
+This option disables partition enforcement on switch external ports.
+.TP
+\fB\-Z\fR, \fB\-\-part_enforce\fR [both | in | out | off]
+This option indicates the partition enforcement type (for switches).
+Enforcement type can be inbound only (in), outbound only (out),
+both or disabled (off). Default is both.
+.TP
+\fB\-W\fR, \fB\-\-allow_both_pkeys\fR
+This option indicates whether both full and limited membership on the
+same partition can be configured in the PKeyTable. Default is not
+to allow both pkeys.
+.TP
+\fB\-y\fR, \fB\-\-stay_on_fatal\fR
+This option will cause SM not to exit on fatal initialization
+issues: if SM discovers duplicated guids or a 12x link with
+lane reversal badly configured.
+By default, the SM will exit on these errors.
+.TP
+\fB\-B\fR, \fB\-\-daemon\fR
+Run in daemon mode - OpenSM will run in the background.
+.TP
+\fB\-J\fR, \fB\-\-pidfile <file_name>\fR
+Makes the SM write its own PID to the specified file when started in daemon
+mode.
+.TP
+\fB\-I\fR, \fB\-\-inactive\fR
+Start SM in inactive rather than init SM state. This
+option can be used in conjunction with the perfmgr so as to
+run a standalone performance manager without SM/SA. However,
+this is NOT currently implemented in the performance manager.
+.TP
+\fB\-\-perfmgr\fR
+Enable the perfmgr. Only takes effect if --enable-perfmgr was specified at
+configure time. See performance-manager-HOWTO.txt in opensm doc for
+more information on running perfmgr.
+.TP
+\fB\-\-perfmgr_sweep_time_s\fR <seconds>
+Specify the sweep time for the performance manager in seconds
+(default is 180 seconds). Only takes
+effect if --enable-perfmgr was specified at configure time.
+.TP
+.BI --consolidate_ipv6_snm_req
+Use shared MLID for IPv6 Solicited Node Multicast groups per MGID scope
+and P_Key.
+.TP
+\fB\-\-log_prefix\fR <prefix text>
+This option specifies the prefix to the syslog messages from OpenSM.
+A suitable prefix can be used to identify the IB subnet in syslog messages
+when two or more instances of OpenSM run in a single node to manage multiple
+fabrics. For example, in a dual-fabric (or dual-rail) IB cluster, the prefix
+for the first fabric could be "mpi" and the other fabric could be "storage".
+.TP
+\fB\-\-torus_config\fR <path to torus\-2QoS config file>
+This option defines the file name for the extra configuration
+information needed for the torus-2QoS routing engine. The default
+name is \fB\%/etc/opensm/torus-2QoS.conf\fP
+.TP
+\fB\-v\fR, \fB\-\-verbose\fR
+This option increases the log verbosity level.
+The -v option may be specified multiple times
+to further increase the verbosity level.
+See the -D option for more information about
+log verbosity.
+.TP
+\fB\-V\fR
+This option sets the maximum verbosity level and
+forces log flushing.
+The -V option is equivalent to \'-D 0xFF -d 2\'.
+See the -D option for more information about
+log verbosity.
+.TP
+\fB\-D\fR <value>
+This option sets the log verbosity level.
+A flags field must follow the -D option.
+A bit set/clear in the flags enables/disables a
+specific log level as follows:
+
+ BIT LOG LEVEL ENABLED
+ ---- -----------------
+ 0x01 - ERROR (error messages)
+ 0x02 - INFO (basic messages, low volume)
+ 0x04 - VERBOSE (interesting stuff, moderate volume)
+ 0x08 - DEBUG (diagnostic, high volume)
+ 0x10 - FUNCS (function entry/exit, very high volume)
+ 0x20 - FRAMES (dumps all SMP and GMP frames)
+ 0x40 - ROUTING (dump FDB routing information)
+ 0x80 - SYS (syslog at LOG_INFO level in addition to OpenSM logging)
+
+Without -D, OpenSM defaults to ERROR + INFO (0x3).
+Specifying -D 0 disables all messages.
+Specifying -D 0xFF enables all messages (see -V).
+High verbosity levels may require increasing
+the transaction timeout with the -t option.
+.TP
+\fB\-d\fR, \fB\-\-debug\fR <value>
+This option specifies a debug option.
+These options are not normally needed.
+The number following -d selects the debug
+option to enable as follows:
+
+ OPT Description
+ --- -----------------
+ -d0 - Ignore other SM nodes
+ -d1 - Force single threaded dispatching
+ -d2 - Force log flushing after each log message
+ -d3 - Disable multicast support
+.TP
+\fB\-h\fR, \fB\-\-help\fR
+Display this usage info then exit.
+.TP
+\fB\-?\fR
+Display this usage info then exit.
+
+.SH ENVIRONMENT VARIABLES
+.PP
+The following environment variables control opensm behavior:
+
+OSM_TMP_DIR - controls the directory in which the temporary files generated by
+opensm are created. These files are: opensm-subnet.lst, opensm.fdbs, and
+opensm.mcfdbs. By default, this directory is /var/log.
+
+OSM_CACHE_DIR - opensm stores certain data to the disk such that subsequent
+runs are consistent. The default directory used is /var/cache/opensm.
+The following files are included in it:
+
+ guid2lid - stores the LID range assigned to each GUID
+ guid2mkey - stores the MKey previously assiged to each GUID
+ neighbors - stores a map of the GUIDs at either end of each link
+ in the fabric
+
+.SH NOTES
+.PP
+When opensm receives a HUP signal, it starts a new heavy sweep as if a trap was received or a topology change was found.
+.PP
+Also, SIGUSR1 can be used to trigger a reopen of /var/log/opensm.log for
+logrotate purposes.
+
+.SH PARTITION CONFIGURATION
+.PP
+The default name of OpenSM partitions configuration file is
+\fB\%/etc/opensm/partitions.conf\fP. The default may be changed
+by using the --Pconfig (-P) option with OpenSM.
+
+The default partition will be created by OpenSM unconditionally even
+when partition configuration file does not exist or cannot be accessed.
+
+The default partition has P_Key value 0x7fff. OpenSM\'s port will always
+have full membership in default partition. All other end ports will have
+full membership if the partition configuration file is not found or cannot
+be accessed, or limited membership if the file exists and can be accessed
+but there is no rule for the Default partition.
+
+Effectively, this amounts to the same as if one of the following rules
+below appear in the partition configuration file.
+
+In the case of no rule for the Default partition:
+
+Default=0x7fff : ALL=limited, SELF=full ;
+
+In the case of no partition configuration file or file cannot be accessed:
+
+Default=0x7fff : ALL=full ;
+
+
+File Format
+
+Comments:
+
+Line content followed after \'#\' character is comment and ignored by
+parser.
+
+General file format:
+
+<Partition Definition>:[<newline>]<Partition Properties>;
+
+ Partition Definition:
+ [PartitionName][=PKey][,indx0][,ipoib_bc_flags][,defmember=full|limited]
+
+ PartitionName - string, will be used with logging. When
+ omitted, empty string will be used.
+ PKey - P_Key value for this partition. Only low 15
+ bits will be used. When omitted will be
+ autogenerated.
+ indx0 - indicates that this pkey should be inserted in
+ block 0 index 0.
+ ipoib_bc_flags - used to indicate/specify IPoIB capability of
+ this partition.
+
+ defmember=full|limited|both - specifies default membership for
+ port guid list. Default is limited.
+
+ ipoib_bc_flags:
+ ipoib_flag|[mgroup_flag]*
+
+ ipoib_flag:
+ ipoib - indicates that this partition may be used for
+ IPoIB, as a result the IPoIB broadcast group will
+ be created with the mgroup_flag flags given,
+ if any.
+
+ Partition Properties:
+ [<Port list>|<MCast Group>]* | <Port list>
+
+ Port list:
+ <Port Specifier>[,<Port Specifier>]
+
+ Port Specifier:
+ <PortGUID>[=[full|limited|both]]
+
+ PortGUID - GUID of partition member EndPort.
+ Hexadecimal numbers should start from
+ 0x, decimal numbers are accepted too.
+ full, limited, - indicates full and/or limited membership for
+ both this port. When omitted (or unrecognized)
+ limited membership is assumed. Both
+ indicates both full and limited membership
+ for this port.
+
+ MCast Group:
+ mgid=gid[,mgroup_flag]*<newline>
+
+ - gid specified is verified to be a Multicast
+ address. IP groups are verified to match
+ the rate and mtu of the broadcast group.
+ The P_Key bits of the mgid for IP groups are
+ verified to either match the P_Key specified
+ in by "Partition Definition" or if they are
+ 0x0000 the P_Key will be copied into those
+ bits.
+
+ mgroup_flag:
+ rate=<val> - specifies rate for this MC group
+ (default is 3 (10GBps))
+ mtu=<val> - specifies MTU for this MC group
+ (default is 4 (2048))
+ sl=<val> - specifies SL for this MC group
+ (default is 0)
+ scope=<val> - specifies scope for this MC group
+ (default is 2 (link local)). Multiple scope
+ settings are permitted for a partition.
+ NOTE: This overwrites the scope nibble of the
+ specified mgid. Furthermore specifying
+ multiple scope settings will result in
+ multiple MC groups being created.
+ Q_Key=<val> - specifies the Q_Key for this MC group
+ (default: 0x0b1b for IP groups, 0 for other
+ groups)
+ WARNING: changing this for the broadcast
+ group may break IPoIB on client
+ nodes!!
+ TClass=<val> - specifies tclass for this MC group
+ (default is 0)
+ FlowLabel=<val> - specifies FlowLabel for this MC group
+ (default is 0)
+
+Note that values for rate, mtu, and scope, for both partitions and multicast
+groups, should be specified as defined in the IBTA specification (for example,
+mtu=4 for 2048).
+
+There are several useful keywords for PortGUID definition:
+
+ - 'ALL' means all end ports in this subnet.
+ - 'ALL_CAS' means all Channel Adapter end ports in this subnet.
+ - 'ALL_SWITCHES' means all Switch end ports in this subnet.
+ - 'ALL_ROUTERS' means all Router end ports in this subnet.
+ - 'SELF' means subnet manager's port.
+
+Empty list means no ports in this partition.
+
+Notes:
+
+White space is permitted between delimiters ('=', ',',':',';').
+
+PartitionName does not need to be unique, PKey does need to be unique.
+If PKey is repeated then those partition configurations will be merged
+and first PartitionName will be used (see also next note).
+
+It is possible to split partition configuration in more than one
+definition, but then PKey should be explicitly specified (otherwise
+different PKey values will be generated for those definitions).
+
+Examples:
+
+ Default=0x7fff : ALL, SELF=full ;
+ Default=0x7fff : ALL, ALL_SWITCHES=full, SELF=full ;
+
+ NewPartition , ipoib : 0x123456=full, 0x3456789034=limi, 0x2134af2306 ;
+
+ YetAnotherOne = 0x300 : SELF=full ;
+ YetAnotherOne = 0x300 : ALL=limited ;
+
+ ShareIO = 0x80 , defmember=full : 0x123451, 0x123452;
+ # 0x123453, 0x123454 will be limited
+ ShareIO = 0x80 : 0x123453, 0x123454, 0x123455=full;
+ # 0x123456, 0x123457 will be limited
+ ShareIO = 0x80 : defmember=limited : 0x123456, 0x123457, 0x123458=full;
+ ShareIO = 0x80 , defmember=full : 0x123459, 0x12345a;
+ ShareIO = 0x80 , defmember=full : 0x12345b, 0x12345c=limited, 0x12345d;
+
+ # multicast groups added to default
+ Default=0x7fff,ipoib:
+ mgid=ff12:401b::0707,sl=1 # random IPv4 group
+ mgid=ff12:601b::16 # MLDv2-capable routers
+ mgid=ff12:401b::16 # IGMP
+ mgid=ff12:601b::2 # All routers
+ mgid=ff12::1,sl=1,Q_Key=0xDEADBEEF,rate=3,mtu=2 # random group
+ ALL=full;
+
+
+Note:
+
+The following rule is equivalent to how OpenSM used to run prior to the
+partition manager:
+
+ Default=0x7fff,ipoib:ALL=full;
+
+.SH QOS CONFIGURATION
+.PP
+There are a set of QoS related low-level configuration parameters.
+All these parameter names are prefixed by "qos_" string. Here is a full
+list of these parameters:
+
+ qos_max_vls - The maximum number of VLs that will be on the subnet
+ qos_high_limit - The limit of High Priority component of VL
+ Arbitration table (IBA 7.6.9)
+ qos_vlarb_low - Low priority VL Arbitration table (IBA 7.6.9)
+ template
+ qos_vlarb_high - High priority VL Arbitration table (IBA 7.6.9)
+ template
+ Both VL arbitration templates are pairs of
+ VL and weight
+ qos_sl2vl - SL2VL Mapping table (IBA 7.6.6) template. It is
+ a list of VLs corresponding to SLs 0-15 (Note
+ that VL15 used here means drop this SL)
+
+Typical default values (hard-coded in OpenSM initialization) are:
+
+ qos_max_vls 15
+ qos_high_limit 0
+ qos_vlarb_low 0:0,1:4,2:4,3:4,4:4,5:4,6:4,7:4,8:4,9:4,10:4,11:4,12:4,13:4,14:4
+ qos_vlarb_high 0:4,1:0,2:0,3:0,4:0,5:0,6:0,7:0,8:0,9:0,10:0,11:0,12:0,13:0,14:0
+ qos_sl2vl 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,7
+
+The syntax is compatible with rest of OpenSM configuration options and
+values may be stored in OpenSM config file (cached options file).
+
+In addition to the above, we may define separate QoS configuration
+parameters sets for various target types. As targets, we currently support
+CAs, routers, switch external ports, and switch's enhanced port 0. The
+names of such specialized parameters are prefixed by "qos_<type>_"
+string. Here is a full list of the currently supported sets:
+
+ qos_ca_ - QoS configuration parameters set for CAs.
+ qos_rtr_ - parameters set for routers.
+ qos_sw0_ - parameters set for switches' port 0.
+ qos_swe_ - parameters set for switches' external ports.
+
+Examples:
+ qos_sw0_max_vls=2
+ qos_ca_sl2vl=0,1,2,3,5,5,5,12,12,0,
+ qos_swe_high_limit=0
+
+.SH PREFIX ROUTES
+.PP
+Prefix routes control how the SA responds to path record queries for
+off-subnet DGIDs. By default, the SA fails such queries.
+Note that IBA does not specify how the SA should obtain off-subnet path
+record information.
+The prefix routes configuration is meant as a stop-gap until the
+specification is completed.
+.PP
+Each line in the configuration file is a 64-bit prefix followed by a
+64-bit GUID, separated by white space.
+The GUID specifies the router port on the local subnet that will
+handle the prefix.
+Blank lines are ignored, as is anything between a \fB#\fP character
+and the end of the line.
+The prefix and GUID are both in hex, the leading 0x is optional.
+Either, or both, can be wild-carded by specifying an
+asterisk instead of an explicit prefix or GUID.
+.PP
+When responding to a path record query for an off-subnet DGID,
+opensm searches for the first prefix match in the configuration file.
+Therefore, the order of the lines in the configuration file is important:
+a wild-carded prefix at the beginning of the configuration file renders
+all subsequent lines useless.
+If there is no match, then opensm fails the query.
+It is legal to repeat prefixes in the configuration file,
+opensm will return the path to the first available matching router.
+A configuration file with a single line where both prefix and GUID
+are wild-carded means that a path record query specifying any
+off-subnet DGID should return a path to the first available router.
+This configuration yields the same behavior formerly achieved by
+compiling opensm with -DROUTER_EXP which has been obsoleted.
+
+.SH MKEY CONFIGURATION
+.PP
+OpenSM supports configuring a single management key (MKey) for use across
+the subnet.
+
+The following configuration options are available:
+
+ m_key - the 64-bit MKey to be used on the subnet
+ (IBA 14.2.4)
+ m_key_protection_level - the numeric value of the MKey ProtectBits
+ (IBA 14.2.4.1)
+ m_key_lease_period - the number of seconds a CA will wait for a
+ response from the SM before resetting the
+ protection level to 0 (IBA 14.2.4.2).
+
+OpenSM will configure all ports with the MKey specified by m_key, defaulting
+to a value of 0. A m_key value of 0 disables MKey protection on the subnet.
+Switches and HCAs with a non-zero MKey will not accept requests to change
+their configuration unless the request includes the proper MKey.
+
+MKey Protection Levels
+
+MKey protection levels modify how switches and CAs respond to SMPs lacking
+a valid MKey.
+OpenSM will configure each port's ProtectBits to support the level defined by
+the m_key_protection_level parameter. If no parameter is specified, OpenSM
+defaults to operating at protection level 0.
+
+There are currently 4 protection levels defined by the IBA:
+
+ 0 - Queries return valid data, including MKey. Configuration changes
+ are not allowed unless the request contains a valid MKey.
+ 1 - Like level 0, but the MKey is set to 0 (0x00000000) in queries,
+ unless the request contains a valid MKey.
+ 2 - Neither queries nor configuration changes are allowed, unless the
+ request contains a valid MKey.
+ 3 - Identical to 2. Maintained for backwards compatibility.
+
+MKey Lease Period
+
+InfiniBand supports a MKey lease timeout, which is intended to allow
+administrators or a new SM to recover/reset lost MKeys on a fabric.
+
+If MKeys are enabled on the subnet and a switch or CA receives a request that
+requires a valid MKey but does not contain one, it warns the SM by sending a trap
+(Bad M_Key, Trap 256). If the MKey lease period is non-zero, it also starts a
+countdown timer for the time specified by the lease period.
+If a SM (or other agent) responds with the correct MKey, the timer is stopped
+and reset. Should the timer reach zero, the switch or CA will reset its MKey
+protection level to 0, exposing the MKey and allowing recovery.
+
+OpenSM will initialize all ports to use a mkey lease period of the number of
+seconds specified in the config file. If no mkey_lease_period is specified,
+a default of 0 will be used.
+
+OpenSM normally quickly responds to all Bad_M_Key traps, resetting the lease
+timers. Additionally, OpenSM's subnet sweeps will also cancel
+any running timers. For maximum protection against accidentally-exposed MKeys,
+the MKey lease time should be a few multiples of the subnet sweep time.
+If OpenSM detects at startup that your sweep interval is greater than your
+MKey lease period, it will reset the lease period to be greater than the
+sweep interval. Similarly, if sweeping is disabled at startup, it will be
+re-enabled with an interval less than the Mkey lease period.
+
+If OpenSM is required to recover a subnet for which it is missing mkeys,
+it must do so one switch level at a time. As such, the total time to
+recover the subnet may be as long as the mkey lease period multiplied by
+the maximum number of hops between the SM and an endpoint, plus one.
+
+MKey Effects on Diagnostic Utilities
+
+Setting a MKey may have a detrimental effect on diagnostic software run on
+the subnet, unless your diagnostic software is able to retrieve MKeys from the
+SA or can be explicitly configured with the proper MKey. This is particularly
+true at protection level 2, where CAs will ignore queries for management
+information that do not contain the proper MKey.
+
+.SH ROUTING
+.PP
+OpenSM now offers nine routing engines:
+
+1. Min Hop Algorithm - based on the minimum hops to each node where the
+path length is optimized.
+
+2. UPDN Unicast routing algorithm - also based on the minimum hops to each
+node, but it is constrained to ranking rules. This algorithm should be chosen
+if the subnet is not a pure Fat Tree, and deadlock may occur due to a
+loop in the subnet.
+
+3. DNUP Unicast routing algorithm - similar to UPDN but allows routing in
+fabrics which have some CA nodes attached closer to the roots than some switch
+nodes.
+
+4. Fat Tree Unicast routing algorithm - this algorithm optimizes routing
+for congestion-free "shift" communication pattern.
+It should be chosen if a subnet is a symmetrical or almost symmetrical
+fat-tree of various types, not just K-ary-N-Trees: non-constant K, not
+fully staffed, any Constant Bisectional Bandwidth (CBB) ratio.
+Similar to UPDN, Fat Tree routing is constrained to ranking rules.
+
+5. LASH unicast routing algorithm - uses Infiniband virtual layers
+(SL) to provide deadlock-free shortest-path routing while also
+distributing the paths between layers. LASH is an alternative
+deadlock-free topology-agnostic routing algorithm to the non-minimal
+UPDN algorithm avoiding the use of a potentially congested root node.
+
+6. DOR Unicast routing algorithm - based on the Min Hop algorithm, but
+avoids port equalization except for redundant links between the same
+two switches. This provides deadlock free routes for hypercubes when
+the fabric is cabled as a hypercube and for meshes when cabled as a
+mesh (see details below).
+
+7. Torus-2QoS unicast routing algorithm - a DOR-based routing algorithm
+specialized for 2D/3D torus topologies. Torus-2QoS provides deadlock-free
+routing while supporting two quality of service (QoS) levels. In addition
+it is able to route around multiple failed fabric links or a single failed
+fabric switch without introducing deadlocks, and without changing path SL
+values granted before the failure.
+
+8. DFSSSP unicast routing algorithm - a deadlock-free
+single-source-shortest-path routing, which uses the SSSP algorithm
+(see algorithm 9.) as the base to optimize link utilization and uses
+Infiniband virtual lanes (SL) to provide deadlock-freedom.
+
+9. SSSP unicast routing algorithm - a single-source-shortest-path routing
+algorithm, which globally balances the number of routes per link to
+optimize link utilization. This routing algorithm has no restrictions
+in terms of the underlying topology.
+
+OpenSM also supports a file method which
+can load routes from a table. See \'Modular Routing Engine\' for more
+information on this.
+
+The basic routing algorithm is comprised of two stages:
+
+1. MinHop matrix calculation
+ How many hops are required to get from each port to each LID ?
+ The algorithm to fill these tables is different if you run standard
+(min hop) or Up/Down.
+ For standard routing, a "relaxation" algorithm is used to propagate
+min hop from every destination LID through neighbor switches
+ For Up/Down routing, a BFS from every target is used. The BFS tracks link
+direction (up or down) and avoid steps that will perform up after a down
+step was used.
+
+2. Once MinHop matrices exist, each switch is visited and for each target LID a
+decision is made as to what port should be used to get to that LID.
+ This step is common to standard and Up/Down routing. Each port has a
+counter counting the number of target LIDs going through it.
+ When there are multiple alternative ports with same MinHop to a LID,
+the one with less previously assigned LIDs is selected.
+ If LMC > 0, more checks are added: Within each group of LIDs assigned to
+same target port,
+ a. use only ports which have same MinHop
+ b. first prefer the ones that go to different systemImageGuid (then
+the previous LID of the same LMC group)
+ c. if none - prefer those which go through another NodeGuid
+ d. fall back to the number of paths method (if all go to same node).
+
+Effect of Topology Changes
+
+OpenSM will preserve existing routing in any case where there is no change in
+the fabric switches unless the -r (--reassign_lids) option is specified.
+
+-r
+.br
+--reassign_lids
+ This option causes OpenSM to reassign LIDs to all
+ end nodes. Specifying -r on a running subnet
+ may disrupt subnet traffic.
+ Without -r, OpenSM attempts to preserve existing
+ LID assignments resolving multiple use of same LID.
+
+If a link is added or removed, OpenSM does not recalculate
+the routes that do not have to change. A route has to change
+if the port is no longer UP or no longer the MinHop. When routing changes
+are performed, the same algorithm for balancing the routes is invoked.
+
+In the case of using the file based routing, any topology changes are
+currently ignored The 'file' routing engine just loads the LFTs from the file
+specified, with no reaction to real topology. Obviously, this will not be able
+to recheck LIDs (by GUID) for disconnected nodes, and LFTs for non-existent
+switches will be skipped. Multicast is not affected by 'file' routing engine
+(this uses min hop tables).
+
+
+Min Hop Algorithm
+
+The Min Hop algorithm is invoked by default if no routing algorithm is
+specified. It can also be invoked by specifying '-R minhop'.
+
+The Min Hop algorithm is divided into two stages: computation of
+min-hop tables on every switch and LFT output port assignment. Link
+subscription is also equalized with the ability to override based on
+port GUID. The latter is supplied by:
+
+-i <equalize-ignore-guids-file>
+.br
+\-\-ignore_guids <equalize-ignore-guids-file>
+ This option provides the means to define a set of ports
+ (by guid) that will be ignored by the link load
+ equalization algorithm. Note that only endports (CA,
+ switch port 0, and router ports) and not switch external
+ ports are supported.
+
+LMC awareness routes based on (remote) system or switch basis.
+
+
+Purpose of UPDN Algorithm
+
+The UPDN algorithm is designed to prevent deadlocks from occurring in loops
+of the subnet. A loop-deadlock is a situation in which it is no longer
+possible to send data between any two hosts connected through the loop. As
+such, the UPDN routing algorithm should be used if the subnet is not a pure
+Fat Tree, and one of its loops may experience a deadlock (due, for example,
+to high pressure).
+
+The UPDN algorithm is based on the following main stages:
+
+1. Auto-detect root nodes - based on the CA hop length from any switch in
+the subnet, a statistical histogram is built for each switch (hop num vs
+number of occurrences). If the histogram reflects a specific column (higher
+than others) for a certain node, then it is marked as a root node. Since
+the algorithm is statistical, it may not find any root nodes. The list of
+the root nodes found by this auto-detect stage is used by the ranking
+process stage.
+
+ Note 1: The user can override the node list manually.
+ Note 2: If this stage cannot find any root nodes, and the user did
+ not specify a guid list file, OpenSM defaults back to the
+ Min Hop routing algorithm.
+
+2. Ranking process - All root switch nodes (found in stage 1) are assigned
+a rank of 0. Using the BFS algorithm, the rest of the switch nodes in the
+subnet are ranked incrementally. This ranking aids in the process of enforcing
+rules that ensure loop-free paths.
+
+3. Min Hop Table setting - after ranking is done, a BFS algorithm is run from
+each (CA or switch) node in the subnet. During the BFS process, the FDB table
+of each switch node traversed by BFS is updated, in reference to the starting
+node, based on the ranking rules and guid values.
+
+At the end of the process, the updated FDB tables ensure loop-free paths
+through the subnet.
+
+Note: Up/Down routing does not allow LID routing communication between
+switches that are located inside spine "switch systems".
+The reason is that there is no way to allow a LID route between them
+that does not break the Up/Down rule.
+One ramification of this is that you cannot run SM on switches other
+than the leaf switches of the fabric.
+
+
+UPDN Algorithm Usage
+
+Activation through OpenSM
+
+Use '-R updn' option (instead of old '-u') to activate the UPDN algorithm.
+Use '-a <root_guid_file>' for adding an UPDN guid file that contains the
+root nodes for ranking.
+If the `-a' option is not used, OpenSM uses its auto-detect root nodes
+algorithm.
+
+Notes on the guid list file:
+
+1. A valid guid file specifies one guid in each line. Lines with an invalid
+format will be discarded.
+.br
+2. The user should specify the root switch guids. However, it is also
+possible to specify CA guids; OpenSM will use the guid of the switch (if
+it exists) that connects the CA to the subnet as a root node.
+
+Purpose of DNUP Algorithm
+
+The DNUP algorithm is designed to serve a similar purpose to UPDN. However
+it is intended to work in network topologies which are unsuited to
+UPDN due to nodes being connected closer to the roots than some of
+the switches. An example would be a fabric which contains nodes and
+uplinks connected to the same switch. The operation of DNUP is the
+same as UPDN with the exception of the ranking process. In DNUP all
+switch nodes are ranked based solely on their distance from CA Nodes,
+all switch nodes directly connected to at least one CA are assigned a
+value of 1 all other switch nodes are assigned a value of one more than
+the minimum rank of all neighbor switch nodes.
+
+Fat-tree Routing Algorithm
+
+The fat-tree algorithm optimizes routing for "shift" communication pattern.
+It should be chosen if a subnet is a symmetrical or almost symmetrical
+fat-tree of various types.
+It supports not just K-ary-N-Trees, by handling for non-constant K,
+cases where not all leafs (CAs) are present, any CBB ratio.
+As in UPDN, fat-tree also prevents credit-loop-deadlocks.
+
+If the root guid file is not provided ('-a' or '--root_guid_file' options),
+the topology has to be pure fat-tree that complies with the following rules:
+ - Tree rank should be between two and eight (inclusively)
+ - Switches of the same rank should have the same number
+ of UP-going port groups*, unless they are root switches,
+ in which case the shouldn't have UP-going ports at all.
+ - Switches of the same rank should have the same number
+ of DOWN-going port groups, unless they are leaf switches.
+ - Switches of the same rank should have the same number
+ of ports in each UP-going port group.
+ - Switches of the same rank should have the same number
+ of ports in each DOWN-going port group.
+ - All the CAs have to be at the same tree level (rank).
+
+If the root guid file is provided, the topology doesn't have to be pure
+fat-tree, and it should only comply with the following rules:
+ - Tree rank should be between two and eight (inclusively)
+ - All the Compute Nodes** have to be at the same tree level (rank).
+ Note that non-compute node CAs are allowed here to be at different
+ tree ranks.
+
+* ports that are connected to the same remote switch are referenced as
+\'port group\'.
+
+** list of compute nodes (CNs) can be specified by \'-u\' or \'--cn_guid_file\'
+OpenSM options.
+
+Topologies that do not comply cause a fallback to min hop routing.
+Note that this can also occur on link failures which cause the topology
+to no longer be "pure" fat-tree.
+
+Note that although fat-tree algorithm supports trees with non-integer CBB
+ratio, the routing will not be as balanced as in case of integer CBB ratio.
+In addition to this, although the algorithm allows leaf switches to have any
+number of CAs, the closer the tree is to be fully populated, the more
+effective the "shift" communication pattern will be.
+In general, even if the root list is provided, the closer the topology to a
+pure and symmetrical fat-tree, the more optimal the routing will be.
+
+The algorithm also dumps compute node ordering file (opensm-ftree-ca-order.dump)
+in the same directory where the OpenSM log resides. This ordering file provides
+the CN order that may be used to create efficient communication pattern, that
+will match the routing tables.
+
+Routing between non-CN nodes
+
+The use of the cn_guid_file option allows non-CN nodes to be located on different levels in the fat tree.
+In such case, it is not guaranteed that the Fat Tree algorithm will route between two non-CN nodes.
+To solve this problem, a list of non-CN nodes can be specified by \'-G\' or \'--io_guid_file\' option.
+Theses nodes will be allowed to use switches the wrong way round a specific number of times (specified by \'-H\' or \'--max_reverse_hops\'.
+With the proper max_reverse_hops and io_guid_file values, you can ensure full connectivity in the Fat Tree.
+
+Please note that using max_reverse_hops creates routes that use the switch in a counter-stream way.
+This option should never be used to connect nodes with high bandwidth traffic between them ! It should only be used
+to allow connectivity for HA purposes or similar.
+Also having routes the other way around can in theory cause credit loops.
+
+Use these options with extreme care !
+
+Activation through OpenSM
+
+Use '-R ftree' option to activate the fat-tree algorithm.
+Use '-a <root_guid_file>' to provide root nodes for ranking. If the `-a' option
+is not used, routing algorithm will detect roots automatically.
+Use '-u <root_cn_file>' to provide the list of compute nodes. If the `-u' option
+is not used, all the CAs are considered as compute nodes.
+
+Note: LMC > 0 is not supported by fat-tree routing. If this is
+specified, the default routing algorithm is invoked instead.
+
+
+LASH Routing Algorithm
+
+LASH is an acronym for LAyered SHortest Path Routing. It is a
+deterministic shortest path routing algorithm that enables topology
+agnostic deadlock-free routing within communication networks.
+
+When computing the routing function, LASH analyzes the network
+topology for the shortest-path routes between all pairs of sources /
+destinations and groups these paths into virtual layers in such a way
+as to avoid deadlock.
+
+Note LASH analyzes routes and ensures deadlock freedom between switch
+pairs. The link from HCA between and switch does not need virtual
+layers as deadlock will not arise between switch and HCA.
+
+In more detail, the algorithm works as follows:
+
+1) LASH determines the shortest-path between all pairs of source /
+destination switches. Note, LASH ensures the same SL is used for all
+SRC/DST - DST/SRC pairs and there is no guarantee that the return
+path for a given DST/SRC will be the reverse of the route SRC/DST.
+
+2) LASH then begins an SL assignment process where a route is assigned
+to a layer (SL) if the addition of that route does not cause deadlock
+within that layer. This is achieved by maintaining and analysing a
+channel dependency graph for each layer. Once the potential addition
+of a path could lead to deadlock, LASH opens a new layer and continues
+the process.
+
+3) Once this stage has been completed, it is highly likely that the
+first layers processed will contain more paths than the latter ones.
+To better balance the use of layers, LASH moves paths from one layer
+to another so that the number of paths in each layer averages out.
+
+Note, the implementation of LASH in opensm attempts to use as few layers
+as possible. This number can be less than the number of actual layers
+available.
+
+In general LASH is a very flexible algorithm. It can, for example,
+reduce to Dimension Order Routing in certain topologies, it is topology
+agnostic and fares well in the face of faults.
+
+It has been shown that for both regular and irregular topologies, LASH
+outperforms Up/Down. The reason for this is that LASH distributes the
+traffic more evenly through a network, avoiding the bottleneck issues
+related to a root node and always routes shortest-path.
+
+The algorithm was developed by Simula Research Laboratory.
+
+
+Use '-R lash -Q ' option to activate the LASH algorithm.
+
+Note: QoS support has to be turned on in order that SL/VL mappings are
+used.
+
+Note: LMC > 0 is not supported by the LASH routing. If this is
+specified, the default routing algorithm is invoked instead.
+
+For open regular cartesian meshes the DOR algorithm is the ideal
+routing algorithm. For toroidal meshes on the other hand there
+are routing loops that can cause deadlocks. LASH can be used to
+route these cases. The performance of LASH can be improved by
+preconditioning the mesh in cases where there are multiple links
+connecting switches and also in cases where the switches are not
+cabled consistently. An option exists for LASH to do this. To
+invoke this use '-R lash -Q --do_mesh_analysis'. This will
+add an additional phase that analyses the mesh to try to determine
+the dimension and size of a mesh. If it determines that the mesh
+looks like an open or closed cartesian mesh it reorders the ports
+in dimension order before the rest of the LASH algorithm runs.
+
+DOR Routing Algorithm
+
+The Dimension Order Routing algorithm is based on the Min Hop
+algorithm and so uses shortest paths. Instead of spreading traffic
+out across different paths with the same shortest distance, it chooses
+among the available shortest paths based on an ordering of dimensions.
+Each port must be consistently cabled to represent a hypercube
+dimension or a mesh dimension. Alternatively, the -O option can be
+used to assign a custom mapping between the ports on a given switch,
+and the associated dimension. Paths are grown from a destination back
+to a source using the lowest dimension (port) of available paths at
+each step. This provides the ordering necessary to avoid deadlock.
+When there are multiple links between any two switches, they still
+represent only one dimension and traffic is balanced across them
+unless port equalization is turned off. In the case of hypercubes,
+the same port must be used throughout the fabric to represent the
+hypercube dimension and match on both ends of the cable, or the -O
+option used to accomplish the alignment. In the case of meshes, the
+dimension should consistently use the same pair of ports, one port on
+one end of the cable, and the other port on the other end, continuing
+along the mesh dimension, or the -O option used as an override.
+
+Use '-R dor' option to activate the DOR algorithm.
+
+DFSSSP and SSSP Routing Algorithm
+
+The (Deadlock-Free) Single-Source-Shortest-Path routing algorithm is
+designed to optimize link utilization thru global balancing of routes,
+while supporting arbitrary topologies. The DFSSSP routing algorithm
+uses Infiniband virtual lanes (SL) to provide deadlock-freedom.
+
+The DFSSSP algorithm consists of five major steps:
+.br
+1) It discovers the subnet and models the subnet as a directed
+multigraph in which each node represents a node of the physical
+network and each edge represents one direction of the full-duplex
+links used to connect the nodes.
+.br
+2) A loop, which iterates over all CA and switches of the subnet, will
+perform three steps to generate the linear forwarding tables for
+each switch:
+.br
+2.1) use Dijkstra's algorithm to find the shortest path from all
+nodes to the current selected destination;
+.br
+2.2) update the edge weights in the graph, i.e. add the number of
+routes, which use a link to reach the destination,
+to the link/edge;
+.br
+2.3) update the LFT of each switch with the outgoing port which was
+used in the current step to route the traffic to the
+destination node.
+.br
+3) After the number of available virtual lanes or layers in the subnet
+is detected and a channel dependency graph is initialized for each
+layer, the algorithm will put each possible route of the subnet into
+the first layer.
+.br
+4) A loop iterates over all channel dependency graphs (CDG) and performs
+the following substeps:
+.br
+4.1) search for a cycle in the current CDG;
+.br
+4.2) when a cycle is found, i.e. a possible deadlock is present,
+one edge is selected and all routes, which induced this edge,
+are moved to the "next higher" virtual layer (CDG[i+1]);
+.br
+4.3) the cycle search is continued until all cycles are broken and
+routes are moved "up".
+.br
+5) When the number of needed layers does not exceeds the number of
+available SL/VL to remove all cycles in all CDGs, the rounting is
+deadlock-free and an relation table is generated, which contains
+the assignment of routes from source to destination to a SL
+
+Note on SSSP:
+.br
+This algorithm does not perform the steps 3)-5) and can not be
+considered to be deadlock-free for all topologies. But on the one
+hand, you can choose this algorithm for really large networks
+(5,000+ CAs and deadlock-free by design) to reduce
+the runtime of the algorithm. On the other hand, you might use
+the SSSP routing algorithm as an alternative, when all deadlock-free
+routing algorithms fail to route the network for whatever reason.
+In the last case, SSSP was designed to deliver an equal or higher
+bandwidth due to better congestion avoidance than the Min Hop
+routing algorithm.
+
+Notes for usage:
+.br
+a) running DFSSSP: '-R dfsssp -Q'
+.br
+a.1) QoS has to be configured to equally spread the load on the
+available SL or virtual lanes
+.br
+a.2) applications must perform a path record query to get path SL for
+each route, which the application will use to transmite packages
+.br
+b) running SSSP: '-R sssp'
+.br
+c) both algorithms support LMC > 0
+
+Hints for optimizing I/O traffic:
+.br
+Having more nodes (I/O and compute) connected to a switch than incoming links
+can result in a 'bad' routing of the I/O traffic as long as (DF)SSSP routing
+is not aware of the dedicated I/O nodes, i.e., in the following network
+configuration CN1-CN3 might send all I/O traffic via Link2 to IO1,IO2:
+
+ CN1 Link1 IO1
+.br
+ \\ /----\\ /
+.br
+ CN2 -- Switch1 Switch2 -- CN4
+.br
+ / \\----/ \\
+.br
+ CN3 Link2 IO2
+
+To prevent this from happening (DF)SSSP can use both the compute node guid
+file and the I/O guid file specified by the \'-u\' or \'--cn_guid_file\' and
+\'-G\' or \'--io_guid_file\' options (similar to the Fat-Tree routing).
+This ensures that traffic towards compute nodes and I/O nodes is balanced
+separately and therefore distributed as much as possible across the available
+links. Port GUIDs, as listed by ibstat, must be specified (not Node GUIDs).
+.br
+The priority for the optimization is as follows:
+.br
+ compute nodes -> I/O nodes -> other nodes
+.br
+Possible use case szenarios:
+.br
+a) neither \'-u\' nor \'-G\' are specified: all nodes a treated as \'other nodes\'
+and therefore balanced equally;
+.br
+b) \'-G\' is specified: traffic towards I/O nodes will be balanced optimally;
+.br
+c) the system has three node types, such as login/admin, compute and I/O,
+but the balancing focus should be I/O, then one has to use \'-u\' and \'-G\'
+with I/O guids listed in cn_guid_file and compute node guids listed in
+io_guid_file;
+.br
+d) ...
+
+Torus-2QoS Routing Algorithm
+
+Torus-2QoS is routing algorithm designed for large-scale 2D/3D torus fabrics;
+see torus-2QoS(8) for full documentation.
+
+Use '-R torus-2QoS -Q' or '-R torus-2QoS,no_fallback -Q'
+to activate the torus-2QoS algorithm.
+
+
+Routing References
+
+To learn more about deadlock-free routing, see the article
+"Deadlock Free Message Routing in Multiprocessor Interconnection Networks"
+by William J Dally and Charles L Seitz (1985).
+
+To learn more about the up/down algorithm, see the article
+"Effective Strategy to Compute Forwarding Tables for InfiniBand Networks"
+by Jose Carlos Sancho, Antonio Robles, and Jose Duato at the
+Universidad Politecnica de Valencia.
+
+To learn more about LASH and the flexibility behind it, the requirement
+for layers, performance comparisons to other algorithms, see the
+following articles:
+
+"Layered Routing in Irregular Networks", Lysne et al, IEEE
+Transactions on Parallel and Distributed Systems, VOL.16, No12,
+December 2005.
+
+"Routing for the ASI Fabric Manager", Solheim et al. IEEE
+Communications Magazine, Vol.44, No.7, July 2006.
+
+"Layered Shortest Path (LASH) Routing in Irregular System Area
+Networks", Skeie et al. IEEE Computer Society Communication
+Architecture for Clusters 2002.
+
+To learn more about the DFSSSP and SSSP routing algorithm,
+see the articles:
+.br
+J. Domke, T. Hoefler and W. Nagel: Deadlock-Free Oblivious Routing
+for Arbitrary Topologies, In Proceedings of the 25th IEEE International
+Parallel & Distributed Processing Symposium (IPDPS 2011)
+.br
+T. Hoefler, T. Schneider and A. Lumsdaine: Optimized Routing for
+Large-Scale InfiniBand Networks, In 17th Annual IEEE Symposium on High
+Performance Interconnects (HOTI 2009)
+
+Modular Routine Engine
+
+Modular routing engine structure allows for the ease of
+"plugging" new routing modules.
+
+Currently, only unicast callbacks are supported. Multicast
+can be added later.
+
+One existing routing module is up-down "updn", which may be
+activated with '-R updn' option (instead of old '-u').
+
+General usage is:
+$ opensm -R 'module-name'
+
+There is also a trivial routing module which is able
+to load LFT tables from a file.
+
+Main features:
+
+ - this will load switch LFTs and/or LID matrices (min hops tables)
+ - this will load switch LFTs according to the path entries introduced
+ in the file
+ - no additional checks will be performed (such as "is port connected",
+ etc.)
+ - in case when fabric LIDs were changed this will try to reconstruct
+ LFTs correctly if endport GUIDs are represented in the file
+ (in order to disable this, GUIDs may be removed from the file
+ or zeroed)
+
+The file format is compatible with output of 'ibroute' util and for
+whole fabric can be generated with dump_lfts.sh script.
+
+To activate file based routing module, use:
+
+ opensm -R file -U /path/to/lfts_file
+
+If the lfts_file is not found or is in error, the default routing
+algorithm is utilized.
+
+The ability to dump switch lid matrices (aka min hops tables) to file and
+later to load these is also supported.
+
+The usage is similar to unicast forwarding tables loading from a lfts
+file (introduced by 'file' routing engine), but new lid matrix file
+name should be specified by -M or --lid_matrix_file option. For example:
+
+ opensm -R file -M ./opensm-lid-matrix.dump
+
+The dump file is named \'opensm-lid-matrix.dump\' and will be generated
+in standard opensm dump directory (/var/log by default) when
+OSM_LOG_ROUTING logging flag is set.
+
+When routing engine 'file' is activated, but the lfts file is not specified
+or not cannot be open default lid matrix algorithm will be used.
+
+There is also a switch forwarding tables dumper which generates
+a file compatible with dump_lfts.sh output. This file can be used
+as input for forwarding tables loading by 'file' routing engine.
+Both or one of options -U and -M can be specified together with \'-R file\'.
+
+.SH PER MODULE LOGGING CONFIGURATION
+.PP
+To enable per module logging, configure per_module_logging_file to
+the per module logging config file name in the opensm options
+file. To disable, configure per_module_logging_file to (null)
+there.
+
+The per module logging config file format is a set of lines with module
+name and logging level as follows:
+
+ <module name><separator><logging level>
+
+ <module name> is the file name including .c
+ <separator> is either = , space, or tab
+ <logging level> is the same levels as used in the coarse/overall
+ logging as follows:
+
+ BIT LOG LEVEL ENABLED
+ ---- -----------------
+ 0x01 - ERROR (error messages)
+ 0x02 - INFO (basic messages, low volume)
+ 0x04 - VERBOSE (interesting stuff, moderate volume)
+ 0x08 - DEBUG (diagnostic, high volume)
+ 0x10 - FUNCS (function entry/exit, very high volume)
+ 0x20 - FRAMES (dumps all SMP and GMP frames)
+ 0x40 - ROUTING (dump FDB routing information)
+ 0x80 - SYS (syslog at LOG_INFO level in addition to OpenSM logging)
+
+.SH FILES
+.TP
+.B /etc/opensm/opensm.conf
+default OpenSM config file.
+
+.TP
+.B /etc/opensm/ib-node-name-map
+default node name map file. See ibnetdiscover for more information on format.
+
+.TP
+.B /etc/opensm/partitions.conf
+default partition config file
+
+.TP
+.B /etc/opensm/qos-policy.conf
+default QOS policy config file
+
+.TP
+.B /etc/opensm/prefix-routes.conf
+default prefix routes file
+
+.TP
+.B /etc/opensm/per-module-logging.conf
+default per module logging config file
+
+.TP
+.B /etc/opensm/torus-2QoS.conf
+default torus-2QoS config file
+
+.SH AUTHORS
+.TP
+Hal Rosenstock
+.RI < hal@mellanox.com >
+.TP
+Sasha Khapyorsky
+.RI < sashak@voltaire.com >
+.TP
+Eitan Zahavi
+.RI < eitan@mellanox.co.il >
+.TP
+Yevgeny Kliteynik
+.RI < kliteyn@mellanox.co.il >
+.TP
+Thomas Sodring
+.RI < tsodring@simula.no >
+.TP
+Ira Weiny
+.RI < weiny2@llnl.gov >
+.TP
+Dale Purdy
+.RI < purdy@sgi.com >
+
+.SH SEE ALSO
+torus-2QoS(8), torus-2QoS.conf(5).
diff --git a/contrib/ofed/opensm/opensm/Makefile b/contrib/ofed/opensm/opensm/Makefile
new file mode 100644
index 0000000..a22d2fb
--- /dev/null
+++ b/contrib/ofed/opensm/opensm/Makefile
@@ -0,0 +1,101 @@
+# $FreeBSD$
+
+.PATH: ${.CURDIR} ${.CURDIR}/../man
+
+BINDIR?= /usr/bin
+PROG= opensm
+
+SRCS= \
+main.c \
+osm_congestion_control.c \
+osm_console.c \
+osm_console_io.c \
+osm_db_files.c \
+osm_db_pack.c \
+osm_drop_mgr.c \
+osm_dump.c \
+osm_event_plugin.c \
+osm_guid_info_rcv.c \
+osm_guid_mgr.c \
+osm_inform.c \
+osm_lid_mgr.c \
+osm_lin_fwd_rcv.c \
+osm_link_mgr.c \
+osm_mcast_fwd_rcv.c \
+osm_mcast_mgr.c \
+osm_mcast_tbl.c \
+osm_mcm_port.c \
+osm_mesh.c \
+osm_mlnx_ext_port_info_rcv.c \
+osm_mtree.c \
+osm_multicast.c \
+osm_node.c \
+osm_node_desc_rcv.c \
+osm_node_info_rcv.c \
+osm_opensm.c \
+osm_perfmgr.c \
+osm_perfmgr_db.c \
+osm_pkey.c \
+osm_pkey_mgr.c \
+osm_pkey_rcv.c \
+osm_port.c \
+osm_port_info_rcv.c \
+osm_prtn.c \
+osm_prtn_config.c \
+osm_qos.c \
+osm_qos_parser_l.l \
+osm_qos_parser_y.y \
+osm_qos_policy.c \
+osm_remote_sm.c \
+osm_req.c \
+osm_resp.c \
+osm_router.c \
+osm_sa.c \
+osm_sa_class_port_info.c \
+osm_sa_guidinfo_record.c \
+osm_sa_informinfo.c \
+osm_sa_lft_record.c \
+osm_sa_link_record.c \
+osm_sa_mad_ctrl.c \
+osm_sa_mcmember_record.c \
+osm_sa_mft_record.c \
+osm_sa_multipath_record.c \
+osm_sa_node_record.c \
+osm_sa_path_record.c \
+osm_sa_pkey_record.c \
+osm_sa_portinfo_record.c \
+osm_sa_service_record.c \
+osm_sa_slvl_record.c \
+osm_sa_sminfo_record.c \
+osm_sa_sw_info_record.c \
+osm_sa_vlarb_record.c \
+osm_service.c \
+osm_slvl_map_rcv.c \
+osm_sm.c \
+osm_sm_mad_ctrl.c \
+osm_sm_state_mgr.c \
+osm_sminfo_rcv.c \
+osm_state_mgr.c \
+osm_subnet.c \
+osm_sw_info_rcv.c \
+osm_switch.c \
+osm_torus.c \
+osm_trap_rcv.c \
+osm_ucast_cache.c \
+osm_ucast_dfsssp.c \
+osm_ucast_dnup.c \
+osm_ucast_file.c \
+osm_ucast_ftree.c \
+osm_ucast_lash.c \
+osm_ucast_mgr.c \
+osm_ucast_updn.c \
+osm_vl15intf.c \
+osm_vl_arb_rcv.c \
+st.c
+
+MAN= opensm.8
+CFLAGS+= -I${.CURDIR}/.. -DHAVE_CONFIG_H=1
+CFLAGS+= -I${SYSROOT:U${DESTDIR}}/${INCLUDEDIR}/infiniband
+LIBADD= opensm osmvendor osmcomp wrap pthread
+
+.include <bsd.prog.mk>
diff --git a/contrib/ofed/opensm/opensm/libopensm.map b/contrib/ofed/opensm/opensm/libopensm.map
new file mode 100644
index 0000000..087e69a
--- /dev/null
+++ b/contrib/ofed/opensm/opensm/libopensm.map
@@ -0,0 +1,100 @@
+OPENSM_1.5 {
+ global:
+ osm_log;
+ osm_log_msg_box;
+ osm_is_debug;
+ osm_log_init;
+ osm_log_init_v2;
+ osm_log_reopen_file;
+ osm_mad_pool_construct;
+ osm_mad_pool_destroy;
+ osm_mad_pool_init;
+ osm_mad_pool_get;
+ osm_mad_pool_put;
+ osm_mad_pool_get_wrapper;
+ osm_mad_pool_get_wrapper_raw;
+ ib_get_sa_method_str;
+ ib_get_sm_method_str;
+ ib_get_sm_attr_str;
+ ib_get_sa_attr_str;
+ ib_get_trap_str;
+ ib_zero_gid;
+ osm_dump_port_info;
+ osm_dump_port_info_v2;
+ osm_dump_portinfo_record;
+ osm_dump_portinfo_record_v2;
+ osm_dump_guid_info;
+ osm_dump_guid_info_v2;
+ osm_dump_guidinfo_record;
+ osm_dump_guidinfo_record_v2;
+ osm_dump_node_info;
+ osm_dump_node_info_v2;
+ osm_dump_node_record;
+ osm_dump_node_record_v2;
+ osm_dump_path_record;
+ osm_dump_path_record_v2;
+ osm_dump_multipath_record;
+ osm_dump_multipath_record_v2;
+ osm_dump_mc_record;
+ osm_dump_mc_record_v2;
+ osm_dump_service_record;
+ osm_dump_service_record_v2;
+ osm_dump_inform_info;
+ osm_dump_inform_info_v2;
+ osm_dump_inform_info_record;
+ osm_dump_inform_info_record_v2;
+ osm_dump_link_record;
+ osm_dump_link_record_v2;
+ osm_dump_switch_info;
+ osm_dump_switch_info_v2;
+ osm_dump_switch_info_record;
+ osm_dump_switch_info_record_v2;
+ osm_dump_slvl_map_table;
+ osm_dump_slvl_map_table_v2;
+ osm_dump_vl_arb_table;
+ osm_dump_vl_arb_table_v2;
+ osm_dump_sm_info;
+ osm_dump_sm_info_v2;
+ osm_dump_sm_info_record;
+ osm_dump_sm_info_record_v2;
+ osm_dump_notice;
+ osm_dump_notice_v2;
+ osm_dump_dr_smp;
+ osm_dump_dr_smp_v2;
+ osm_dump_sa_mad;
+ osm_dump_sa_mad_v2;
+ osm_dump_dr_path;
+ osm_dump_dr_path_v2;
+ osm_dump_dr_path_as_buf;
+ osm_dump_smp_dr_path;
+ osm_dump_smp_dr_path_v2;
+ osm_dump_pkey_block;
+ osm_dump_pkey_block_v2;
+ osm_log_raw;
+ osm_get_sm_state_str;
+ osm_get_sm_signal_str;
+ osm_get_disp_msg_str;
+ osm_get_port_state_str_fixed_width;
+ osm_get_node_type_str_fixed_width;
+ osm_get_manufacturer_str;
+ osm_get_mtu_str;
+ osm_get_lwa_str;
+ osm_get_lsa_str;
+ osm_get_sm_mgr_signal_str;
+ osm_get_sm_mgr_state_str;
+ ib_mtu_is_valid;
+ ib_rate_is_valid;
+ ib_path_compare_rates;
+ ib_path_rate_get_prev;
+ ib_path_rate_get_next;
+ osm_dump_mlnx_ext_port_info;
+ osm_dump_mlnx_ext_port_info_v2;
+ osm_log_v2;
+ osm_log_msg_box_v2;
+ osm_log_is_active_v2;
+ osm_get_log_per_module;
+ osm_set_log_per_module;
+ osm_reset_log_per_module;
+ sprint_uint8_arr;
+ local: *;
+};
diff --git a/contrib/ofed/opensm/opensm/libopensm.ver b/contrib/ofed/opensm/opensm/libopensm.ver
new file mode 100644
index 0000000..b456ab5
--- /dev/null
+++ b/contrib/ofed/opensm/opensm/libopensm.ver
@@ -0,0 +1,9 @@
+# In this file we track the current API version
+# of the opensm common interface (and libraries)
+# The version is built of the following
+# tree numbers:
+# API_REV:RUNNING_REV:AGE
+# API_REV - advance on any added API
+# RUNNING_REV - advance any change to the vendor files
+# AGE - number of backward versions the API still supports
+LIBVERSION=7:3:2
diff --git a/contrib/ofed/opensm/opensm/main.c b/contrib/ofed/opensm/opensm/main.c
new file mode 100644
index 0000000..8419e68
--- /dev/null
+++ b/contrib/ofed/opensm/opensm/main.c
@@ -0,0 +1,1266 @@
+/*
+ * Copyright (c) 2004-2009 Voltaire, Inc. All rights reserved.
+ * Copyright (c) 2002-2011 Mellanox Technologies LTD. All rights reserved.
+ * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
+ * Copyright (c) 2009 HNR Consulting. All rights reserved.
+ * Copyright (c) 2009 System Fabric Works, Inc. All rights reserved.
+ * Copyright (c) 2009-2011 ZIH, TU Dresden, Federal Republic of Germany. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+/*
+ * Abstract:
+ * Command line interface for opensm.
+ */
+
+#if HAVE_CONFIG_H
+# include <config.h>
+#endif /* HAVE_CONFIG_H */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <getopt.h>
+#include <unistd.h>
+#include <signal.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <complib/cl_types.h>
+#include <complib/cl_debug.h>
+#include <opensm/osm_file_ids.h>
+#define FILE_ID OSM_FILE_MAIN_C
+#include <vendor/osm_vendor_api.h>
+#include <opensm/osm_version.h>
+#include <opensm/osm_opensm.h>
+#include <opensm/osm_console.h>
+#include <opensm/osm_console_io.h>
+#include <opensm/osm_perfmgr.h>
+
+volatile unsigned int osm_exit_flag = 0;
+
+static volatile unsigned int osm_hup_flag = 0;
+static volatile unsigned int osm_usr1_flag = 0;
+static char *pidfile;
+
+#define MAX_LOCAL_IBPORTS 64
+#define INVALID_GUID (0xFFFFFFFFFFFFFFFFULL)
+
+static void mark_exit_flag(int signum)
+{
+ if (!osm_exit_flag)
+ printf("OpenSM: Got signal %d - exiting...\n", signum);
+ osm_exit_flag = 1;
+}
+
+static void mark_hup_flag(int signum)
+{
+ osm_hup_flag = 1;
+}
+
+static void mark_usr1_flag(int signum)
+{
+ osm_usr1_flag = 1;
+}
+
+static sigset_t saved_sigset;
+
+static void block_signals()
+{
+ sigset_t set;
+
+ sigemptyset(&set);
+ sigaddset(&set, SIGINT);
+ sigaddset(&set, SIGTERM);
+ sigaddset(&set, SIGHUP);
+#ifndef HAVE_OLD_LINUX_THREADS
+ sigaddset(&set, SIGUSR1);
+#endif
+ pthread_sigmask(SIG_SETMASK, &set, &saved_sigset);
+}
+
+static void setup_signals()
+{
+ struct sigaction act;
+
+ sigemptyset(&act.sa_mask);
+ act.sa_handler = mark_exit_flag;
+ act.sa_flags = 0;
+ sigaction(SIGINT, &act, NULL);
+ sigaction(SIGTERM, &act, NULL);
+ act.sa_handler = mark_hup_flag;
+ sigaction(SIGHUP, &act, NULL);
+ sigaction(SIGCONT, &act, NULL);
+#ifndef HAVE_OLD_LINUX_THREADS
+ act.sa_handler = mark_usr1_flag;
+ sigaction(SIGUSR1, &act, NULL);
+#endif
+ pthread_sigmask(SIG_SETMASK, &saved_sigset, NULL);
+}
+
+static void show_usage(void)
+{
+ printf("\n------- OpenSM - Usage and options ----------------------\n");
+ printf("Usage: opensm [options]\n");
+ printf("Options:\n");
+ printf("--version\n Prints OpenSM version and exits.\n\n");
+ printf("--config, -F <file-name>\n"
+ " The name of the OpenSM config file. When not specified\n"
+ " " OSM_DEFAULT_CONFIG_FILE
+ " will be used (if exists).\n\n");
+ printf("--create-config, -c <file-name>\n"
+ " OpenSM will dump its configuration to the specified file and exit.\n"
+ " This is a way to generate OpenSM configuration file template.\n\n");
+ printf("--guid, -g <GUID in hex>\n"
+ " This option specifies the local port GUID value\n"
+ " with which OpenSM should bind. OpenSM may be\n"
+ " bound to 1 port at a time.\n"
+ " If GUID given is 0, OpenSM displays a list\n"
+ " of possible port GUIDs and waits for user input.\n"
+ " Without -g, OpenSM tries to use the default port.\n\n");
+ printf("--lmc, -l <LMC>\n"
+ " This option specifies the subnet's LMC value.\n"
+ " The number of LIDs assigned to each port is 2^LMC.\n"
+ " The LMC value must be in the range 0-7.\n"
+ " LMC values > 0 allow multiple paths between ports.\n"
+ " LMC values > 0 should only be used if the subnet\n"
+ " topology actually provides multiple paths between\n"
+ " ports, i.e. multiple interconnects between switches.\n"
+ " Without -l, OpenSM defaults to LMC = 0, which allows\n"
+ " one path between any two ports.\n\n");
+ printf("--priority, -p <PRIORITY>\n"
+ " This option specifies the SM's PRIORITY.\n"
+ " This will effect the handover cases, where master\n"
+ " is chosen by priority and GUID. Range goes\n"
+ " from 0 (lowest priority) to 15 (highest).\n\n");
+ printf("--smkey, -k <SM_Key>\n"
+ " This option specifies the SM's SM_Key (64 bits).\n"
+ " This will effect SM authentication.\n"
+ " Note that OpenSM version 3.2.1 and below used the\n"
+ " default value '1' in a host byte order, it is fixed\n"
+ " now but you may need this option to interoperate\n"
+ " with old OpenSM running on a little endian machine.\n\n");
+ printf("--reassign_lids, -r\n"
+ " This option causes OpenSM to reassign LIDs to all\n"
+ " end nodes. Specifying -r on a running subnet\n"
+ " may disrupt subnet traffic.\n"
+ " Without -r, OpenSM attempts to preserve existing\n"
+ " LID assignments resolving multiple use of same LID.\n\n");
+ printf("--routing_engine, -R <engine name>\n"
+ " This option chooses routing engine(s) to use instead of default\n"
+ " Min Hop algorithm. Multiple routing engines can be specified\n"
+ " separated by commas so that specific ordering of routing\n"
+ " algorithms will be tried if earlier routing engines fail.\n"
+ " If all configured routing engines fail, OpenSM will always\n"
+ " attempt to route with Min Hop unless 'no_fallback' is\n"
+ " included in the list of routing engines.\n"
+ " Supported engines: updn, dnup, file, ftree, lash, dor, torus-2QoS, dfsssp, sssp\n\n");
+ printf("--do_mesh_analysis\n"
+ " This option enables additional analysis for the lash\n"
+ " routing engine to precondition switch port assignments\n"
+ " in regular cartesian meshes which may reduce the number\n"
+ " of SLs required to give a deadlock free routing\n\n");
+ printf("--lash_start_vl <vl number>\n"
+ " Sets the starting VL to use for the lash routing algorithm.\n"
+ " Defaults to 0.\n");
+ printf("--sm_sl <sl number>\n"
+ " Sets the SL to use to communicate with the SM/SA. Defaults to 0.\n\n");
+ printf("--connect_roots, -z\n"
+ " This option enforces routing engines (up/down and \n"
+ " fat-tree) to make connectivity between root switches\n"
+ " and in this way be IBA compliant. In many cases,\n"
+ " this can violate \"pure\" deadlock free algorithm, so\n"
+ " use it carefully.\n\n");
+ printf("--ucast_cache, -A\n"
+ " This option enables unicast routing cache to prevent\n"
+ " routing recalculation (which is a heavy task in a\n"
+ " large cluster) when there was no topology change\n"
+ " detected during the heavy sweep, or when the topology\n"
+ " change does not require new routing calculation,\n"
+ " e.g. in case of host reboot.\n"
+ " This option becomes very handy when the cluster size\n"
+ " is thousands of nodes.\n\n");
+ printf("--lid_matrix_file, -M <file name>\n"
+ " This option specifies the name of the lid matrix dump file\n"
+ " from where switch lid matrices (min hops tables will be\n"
+ " loaded.\n\n");
+ printf("--lfts_file, -U <file name>\n"
+ " This option specifies the name of the LFTs file\n"
+ " from where switch forwarding tables will be loaded when using \"file\"\n"
+ " routing engine.\n\n");
+ printf("--sadb_file, -S <file name>\n"
+ " This option specifies the name of the SA DB dump file\n"
+ " from where SA database will be loaded.\n\n");
+ printf("--root_guid_file, -a <path to file>\n"
+ " Set the root nodes for the Up/Down or Fat-Tree routing\n"
+ " algorithm to the guids provided in the given file (one\n"
+ " to a line)\n" "\n");
+ printf("--cn_guid_file, -u <path to file>\n"
+ " Set the compute nodes for the Fat-Tree or DFSSSP/SSSP routing algorithms\n"
+ " to the port GUIDs provided in the given file (one to a line)\n\n");
+ printf("--io_guid_file, -G <path to file>\n"
+ " Set the I/O nodes for the Fat-Tree or DFSSSP/SSSP routing algorithms\n"
+ " to the port GUIDs provided in the given file (one to a line)\n\n");
+ printf("--port-shifting\n"
+ " Attempt to shift port routes around to remove alignment problems\n"
+ " in routing tables\n\n");
+ printf("--scatter-ports <random seed>\n"
+ " Randomize best port chosen for a route\n"
+ " Assign ports in a random order instead of round-robin\n"
+ " If zero disable (default), otherwise use the value as a random seed\n\n");
+ printf("--max_reverse_hops, -H <hop_count>\n"
+ " Set the max number of hops the wrong way around\n"
+ " an I/O node is allowed to do (connectivity for I/O nodes on top swithces)\n\n");
+ printf("--ids_guid_file, -m <path to file>\n"
+ " Name of the map file with set of the IDs which will be used\n"
+ " by Up/Down routing algorithm instead of node GUIDs\n"
+ " (format: <guid> <id> per line)\n\n");
+ printf("--guid_routing_order_file, -X <path to file>\n"
+ " Set the order port guids will be routed for the MinHop\n"
+ " and Up/Down routing algorithms to the guids provided in the\n"
+ " given file (one to a line)\n\n");
+ printf("--torus_config <path to file>\n"
+ " This option defines the file name for the extra configuration\n"
+ " info needed for the torus-2QoS routing engine. The default\n"
+ " name is \'"OSM_DEFAULT_TORUS_CONF_FILE"\'\n\n");
+ printf("--once, -o\n"
+ " This option causes OpenSM to configure the subnet\n"
+ " once, then exit. Ports remain in the ACTIVE state.\n\n");
+ printf("--sweep, -s <interval>\n"
+ " This option specifies the number of seconds between\n"
+ " subnet sweeps. Specifying -s 0 disables sweeping.\n"
+ " Without -s, OpenSM defaults to a sweep interval of\n"
+ " 10 seconds.\n\n");
+ printf("--timeout, -t <milliseconds>\n"
+ " This option specifies the time in milliseconds\n"
+ " used for transaction timeouts.\n"
+ " Timeout values should be > 0.\n"
+ " Without -t, OpenSM defaults to a timeout value of\n"
+ " 200 milliseconds.\n\n");
+ printf("--retries <number>\n"
+ " This option specifies the number of retries used\n"
+ " for transactions.\n"
+ " Without --retries, OpenSM defaults to %u retries\n"
+ " for transactions.\n\n", OSM_DEFAULT_RETRY_COUNT);
+ printf("--maxsmps, -n <number>\n"
+ " This option specifies the number of VL15 SMP MADs\n"
+ " allowed on the wire at any one time.\n"
+ " Specifying --maxsmps 0 allows unlimited outstanding\n"
+ " SMPs.\n"
+ " Without --maxsmps, OpenSM defaults to a maximum of\n"
+ " 4 outstanding SMPs.\n\n");
+ printf("--console, -q [off|local"
+#ifdef ENABLE_OSM_CONSOLE_LOOPBACK
+ "|loopback"
+#endif
+#ifdef ENABLE_OSM_CONSOLE_SOCKET
+ "|socket"
+#endif
+ "]\n This option activates the OpenSM console (default off).\n\n");
+#ifdef ENABLE_OSM_CONSOLE_LOOPBACK
+ printf("--console-port, -C <port>\n"
+ " Specify an alternate telnet port for the console (default %d).\n\n",
+ OSM_DEFAULT_CONSOLE_PORT);
+#endif
+ printf("--ignore_guids, -i <equalize-ignore-guids-file>\n"
+ " This option provides the means to define a set of ports\n"
+ " (by guid) that will be ignored by the link load\n"
+ " equalization algorithm.\n\n");
+ printf("--hop_weights_file, -w <path to file>\n"
+ " This option provides the means to define a weighting\n"
+ " factor per port for customizing the least weight\n"
+ " hops for the routing.\n\n");
+ printf("--port_search_ordering_file, -O <path to file>\n"
+ " This option provides the means to define a mapping\n"
+ " between ports and dimension (Order) for controlling\n"
+ " Dimension Order Routing (DOR).\n"
+ " Moreover this option provides the means to define non\n"
+ " default routing port order.\n\n");
+ printf("--dimn_ports_file, -O <path to file> (DEPRECATED)\n"
+ " Use --port_search_ordering_file instead.\n"
+ " This option provides the means to define a mapping\n"
+ " between ports and dimension (Order) for controlling\n"
+ " Dimension Order Routing (DOR).\n\n");
+ printf("--honor_guid2lid, -x\n"
+ " This option forces OpenSM to honor the guid2lid file,\n"
+ " when it comes out of Standby state, if such file exists\n"
+ " under OSM_CACHE_DIR, and is valid. By default, this is FALSE.\n\n");
+ printf("--log_file, -f <log-file-name>\n"
+ " This option defines the log to be the given file.\n"
+ " By default, the log goes to /var/log/opensm.log.\n"
+ " For the log to go to standard output use -f stdout.\n\n");
+ printf("--log_limit, -L <size in MB>\n"
+ " This option defines maximal log file size in MB. When\n"
+ " specified the log file will be truncated upon reaching\n"
+ " this limit.\n\n");
+ printf("--erase_log_file, -e\n"
+ " This option will cause deletion of the log file\n"
+ " (if it previously exists). By default, the log file\n"
+ " is accumulative.\n\n");
+ printf("--Pconfig, -P <partition-config-file>\n"
+ " This option defines the optional partition configuration file.\n"
+ " The default name is \'"
+ OSM_DEFAULT_PARTITION_CONFIG_FILE "\'.\n\n");
+ printf("--no_part_enforce, -N (DEPRECATED)\n"
+ " Use --part_enforce instead.\n"
+ " This option disables partition enforcement on switch external ports.\n\n");
+ printf("--part_enforce, -Z [both, in, out, off]\n"
+ " This option indicates the partition enforcement type (for switches)\n"
+ " Enforcement type can be outbound only (out), inbound only (in), both or\n"
+ " disabled (off). Default is both.\n\n");
+ printf("--allow_both_pkeys, -W\n"
+ " This option indicates whether both full and limited membership\n"
+ " on the same partition can be configured in the PKeyTable.\n"
+ " Default is not to allow both pkeys.\n\n");
+ printf("--qos, -Q\n" " This option enables QoS setup.\n\n");
+ printf("--qos_policy_file, -Y <QoS-policy-file>\n"
+ " This option defines the optional QoS policy file.\n"
+ " The default name is \'" OSM_DEFAULT_QOS_POLICY_FILE
+ "\'.\n\n");
+ printf("--congestion_control\n"
+ " (EXPERIMENTAL) This option enables congestion control configuration.\n\n");
+ printf("--cc_key <key>\n"
+ " (EXPERIMENTAL) This option configures the CCkey to use when configuring\n"
+ " congestion control.\n\n");
+ printf("--stay_on_fatal, -y\n"
+ " This option will cause SM not to exit on fatal initialization\n"
+ " issues: if SM discovers duplicated guids or 12x link with\n"
+ " lane reversal badly configured.\n"
+ " By default, the SM will exit on these errors.\n\n");
+ printf("--daemon, -B\n"
+ " Run in daemon mode - OpenSM will run in the background.\n\n");
+ printf("--inactive, -I\n"
+ " Start SM in inactive rather than normal init SM state.\n\n");
+#ifdef ENABLE_OSM_PERF_MGR
+ printf("--perfmgr\n" " Start with PerfMgr enabled.\n\n");
+ printf("--perfmgr_sweep_time_s <sec.>\n"
+ " PerfMgr sweep interval in seconds.\n\n");
+#endif
+ printf("--prefix_routes_file <path to file>\n"
+ " This option specifies the prefix routes file.\n"
+ " Prefix routes control how the SA responds to path record\n"
+ " queries for off-subnet DGIDs. Default file is:\n"
+ " " OSM_DEFAULT_PREFIX_ROUTES_FILE "\n\n");
+ printf("--consolidate_ipv6_snm_req\n"
+ " Use shared MLID for IPv6 Solicited Node Multicast groups\n"
+ " per MGID scope and P_Key.\n\n");
+ printf("--guid_routing_order_no_scatter\n"
+ " Don't use scatter for ports defined in guid_routing_order file\n\n");
+ printf("--log_prefix <prefix text>\n"
+ " Prefix to syslog messages from OpenSM.\n\n");
+ printf("--verbose, -v\n"
+ " This option increases the log verbosity level.\n"
+ " The -v option may be specified multiple times\n"
+ " to further increase the verbosity level.\n"
+ " See the -D option for more information about\n"
+ " log verbosity.\n\n");
+ printf("--V, -V\n"
+ " This option sets the maximum verbosity level and\n"
+ " forces log flushing.\n"
+ " The -V is equivalent to '-D 0xFF -d 2'.\n"
+ " See the -D option for more information about\n"
+ " log verbosity.\n\n");
+ printf("--D, -D <flags>\n"
+ " This option sets the log verbosity level.\n"
+ " A flags field must follow the -D option.\n"
+ " A bit set/clear in the flags enables/disables a\n"
+ " specific log level as follows:\n"
+ " BIT LOG LEVEL ENABLED\n"
+ " ---- -----------------\n"
+ " 0x01 - ERROR (error messages)\n"
+ " 0x02 - INFO (basic messages, low volume)\n"
+ " 0x04 - VERBOSE (interesting stuff, moderate volume)\n"
+ " 0x08 - DEBUG (diagnostic, high volume)\n"
+ " 0x10 - FUNCS (function entry/exit, very high volume)\n"
+ " 0x20 - FRAMES (dumps all SMP and GMP frames)\n"
+ " 0x40 - ROUTING (dump FDB routing information)\n"
+ " 0x80 - currently unused.\n"
+ " Without -D, OpenSM defaults to ERROR + INFO (0x3).\n"
+ " Specifying -D 0 disables all messages.\n"
+ " Specifying -D 0xFF enables all messages (see -V).\n"
+ " High verbosity levels may require increasing\n"
+ " the transaction timeout with the -t option.\n\n");
+ printf("--debug, -d <number>\n"
+ " This option specifies a debug option.\n"
+ " These options are not normally needed.\n"
+ " The number following -d selects the debug\n"
+ " option to enable as follows:\n"
+ " OPT Description\n"
+ " --- -----------------\n"
+ " -d0 - Ignore other SM nodes\n"
+ " -d1 - Force single threaded dispatching\n"
+ " -d2 - Force log flushing after each log message\n"
+ " -d3 - Disable multicast support\n"
+ " -d10 - Put OpenSM in testability mode\n"
+ " Without -d, no debug options are enabled\n\n");
+ printf("--help, -h, -?\n"
+ " Display this usage info then exit.\n\n");
+ fflush(stdout);
+ exit(2);
+}
+
+static ib_net64_t get_port_guid(IN osm_opensm_t * p_osm, uint64_t port_guid)
+{
+ ib_port_attr_t attr_array[MAX_LOCAL_IBPORTS];
+ uint32_t num_ports = MAX_LOCAL_IBPORTS;
+ uint32_t i, choice = 0;
+ ib_api_status_t status;
+
+ for (i = 0; i < num_ports; i++) {
+ attr_array[i].num_pkeys = 0;
+ attr_array[i].p_pkey_table = NULL;
+ attr_array[i].num_gids = 0;
+ attr_array[i].p_gid_table = NULL;
+ }
+
+ /* Call the transport layer for a list of local port GUID values */
+ status = osm_vendor_get_all_port_attr(p_osm->p_vendor, attr_array,
+ &num_ports);
+ if (status != IB_SUCCESS) {
+ printf("\nError from osm_vendor_get_all_port_attr (%x)\n",
+ status);
+ return 0;
+ }
+
+ /* if num_ports is 0 - return 0 */
+ if (num_ports == 0) {
+ printf("\nNo local ports detected!\n");
+ return 0;
+ }
+ /* If num_ports is 1, then there is only one possible port to use.
+ * Use it. */
+ if (num_ports == 1) {
+ printf("Using default GUID 0x%" PRIx64 "\n",
+ cl_hton64(attr_array[0].port_guid));
+ return attr_array[0].port_guid;
+ }
+ /* If port_guid is 0 - use the first connected port */
+ if (port_guid == 0) {
+ for (i = 0; i < num_ports; i++)
+ if (attr_array[i].link_state > IB_LINK_DOWN)
+ break;
+ if (i == num_ports)
+ i = 0;
+ printf("Using default GUID 0x%" PRIx64 "\n",
+ cl_hton64(attr_array[i].port_guid));
+ return attr_array[i].port_guid;
+ }
+
+ if (p_osm->subn.opt.daemon)
+ return 0;
+
+ /* More than one possible port - list all ports and let the user
+ * to choose. */
+ while (1) {
+ printf("\nChoose a local port number with which to bind:\n\n");
+ for (i = 0; i < num_ports; i++)
+ /* Print the index + 1 since by convention, port
+ * numbers start with 1 on host channel adapters. */
+ printf("\t%u: GUID 0x%" PRIx64 ", lid %u, state %s\n",
+ i + 1, cl_ntoh64(attr_array[i].port_guid),
+ attr_array[i].lid,
+ ib_get_port_state_str(attr_array[i].link_state));
+ printf("\n\t0: Exit\n");
+ printf("\nEnter choice (0-%u): ", i);
+ fflush(stdout);
+ if (scanf("%u", &choice) <= 0) {
+ char junk[128];
+ if (scanf("%s", junk) <= 0)
+ printf("\nError: Cannot scan!\n");
+ } else if (choice == 0)
+ return 0;
+ else if (choice <= num_ports)
+ break;
+ printf("\nError: Lame choice! Please try again.\n");
+ }
+ choice--;
+ printf("Choice guid=0x%" PRIx64 "\n",
+ cl_ntoh64(attr_array[choice].port_guid));
+ return attr_array[choice].port_guid;
+}
+
+static void remove_pidfile(void)
+{
+ if (pidfile)
+ unlink(pidfile);
+}
+
+static int daemonize(osm_opensm_t * osm)
+{
+ pid_t pid;
+ int fd;
+ FILE *f;
+
+ fd = open("/dev/null", O_WRONLY);
+ if (fd < 0) {
+ perror("open");
+ return -1;
+ }
+
+ if ((pid = fork()) < 0) {
+ perror("fork");
+ exit(-1);
+ } else if (pid > 0)
+ exit(0);
+
+ setsid();
+
+ if ((pid = fork()) < 0) {
+ perror("fork");
+ exit(-1);
+ } else if (pid > 0)
+ exit(0);
+
+ if (pidfile) {
+ remove_pidfile();
+ f = fopen(pidfile, "w");
+ if (f) {
+ fprintf(f, "%d\n", getpid());
+ fclose(f);
+ } else {
+ perror("fopen");
+ exit(1);
+ }
+ }
+
+ close(0);
+ close(1);
+ close(2);
+
+ dup2(fd, 0);
+ dup2(fd, 1);
+ dup2(fd, 2);
+
+ return 0;
+}
+
+int osm_manager_loop(osm_subn_opt_t * p_opt, osm_opensm_t * p_osm)
+{
+ int console_init_flag = 0;
+
+ if (is_console_enabled(p_opt)) {
+ if (!osm_console_init(p_opt, &p_osm->console, &p_osm->log))
+ console_init_flag = 1;
+ }
+
+ /*
+ Sit here forever - dwell or do console i/o & cmds
+ */
+ while (!osm_exit_flag) {
+ if (console_init_flag) {
+ if (osm_console(p_osm))
+ console_init_flag = 0;
+ } else
+ cl_thread_suspend(10000);
+
+ if (osm_usr1_flag) {
+ osm_usr1_flag = 0;
+ osm_log_reopen_file(&(p_osm->log));
+ }
+ if (osm_hup_flag) {
+ osm_hup_flag = 0;
+ /* a HUP signal should only start a new heavy sweep */
+ p_osm->subn.force_heavy_sweep = TRUE;
+ osm_opensm_sweep(p_osm);
+ }
+ }
+ if (is_console_enabled(p_opt))
+ osm_console_exit(&p_osm->console, &p_osm->log);
+ return 0;
+}
+
+#define SET_STR_OPT(opt, val) do { \
+ opt = val ? strdup(val) : NULL ; \
+} while (0)
+
+int main(int argc, char *argv[])
+{
+ osm_opensm_t osm;
+ osm_subn_opt_t opt;
+ ib_net64_t sm_key = 0;
+ ib_api_status_t status;
+ uint32_t temp, dbg_lvl;
+ boolean_t run_once_flag = FALSE;
+ int32_t vendor_debug = 0;
+ int next_option;
+ char *conf_template = NULL;
+ const char *config_file = NULL;
+ uint32_t val;
+ const char *const short_option =
+ "F:c:i:w:O:f:ed:D:g:l:L:s:t:a:u:m:X:R:zM:U:S:P:Y:ANZ:WBIQvVhoryxp:n:q:k:C:G:H:";
+
+ /*
+ In the array below, the 2nd parameter specifies the number
+ of arguments as follows:
+ 0: no arguments
+ 1: argument
+ 2: optional
+ */
+ const struct option long_option[] = {
+ {"version", 0, NULL, 12},
+ {"config", 1, NULL, 'F'},
+ {"create-config", 1, NULL, 'c'},
+ {"debug", 1, NULL, 'd'},
+ {"guid", 1, NULL, 'g'},
+ {"ignore_guids", 1, NULL, 'i'},
+ {"hop_weights_file", 1, NULL, 'w'},
+ {"dimn_ports_file", 1, NULL, 'O'},
+ {"port_search_ordering_file", 1, NULL, 'O'},
+ {"lmc", 1, NULL, 'l'},
+ {"sweep", 1, NULL, 's'},
+ {"timeout", 1, NULL, 't'},
+ {"verbose", 0, NULL, 'v'},
+ {"D", 1, NULL, 'D'},
+ {"log_file", 1, NULL, 'f'},
+ {"log_limit", 1, NULL, 'L'},
+ {"erase_log_file", 0, NULL, 'e'},
+ {"Pconfig", 1, NULL, 'P'},
+ {"no_part_enforce", 0, NULL, 'N'},
+ {"part_enforce", 1, NULL, 'Z'},
+ {"allow_both_pkeys", 0, NULL, 'W'},
+ {"qos", 0, NULL, 'Q'},
+ {"qos_policy_file", 1, NULL, 'Y'},
+ {"congestion_control", 0, NULL, 128},
+ {"cc_key", 1, NULL, 129},
+ {"maxsmps", 1, NULL, 'n'},
+ {"console", 1, NULL, 'q'},
+ {"V", 0, NULL, 'V'},
+ {"help", 0, NULL, 'h'},
+ {"once", 0, NULL, 'o'},
+ {"reassign_lids", 0, NULL, 'r'},
+ {"priority", 1, NULL, 'p'},
+ {"smkey", 1, NULL, 'k'},
+ {"routing_engine", 1, NULL, 'R'},
+ {"ucast_cache", 0, NULL, 'A'},
+ {"connect_roots", 0, NULL, 'z'},
+ {"lid_matrix_file", 1, NULL, 'M'},
+ {"lfts_file", 1, NULL, 'U'},
+ {"sadb_file", 1, NULL, 'S'},
+ {"root_guid_file", 1, NULL, 'a'},
+ {"cn_guid_file", 1, NULL, 'u'},
+ {"io_guid_file", 1, NULL, 'G'},
+ {"port-shifting", 0, NULL, 11},
+ {"scatter-ports", 1, NULL, 14},
+ {"max_reverse_hops", 1, NULL, 'H'},
+ {"ids_guid_file", 1, NULL, 'm'},
+ {"guid_routing_order_file", 1, NULL, 'X'},
+ {"stay_on_fatal", 0, NULL, 'y'},
+ {"honor_guid2lid", 0, NULL, 'x'},
+#ifdef ENABLE_OSM_CONSOLE_LOOPBACK
+ {"console-port", 1, NULL, 'C'},
+#endif
+ {"daemon", 0, NULL, 'B'},
+ {"pidfile", 1, NULL, 'J'},
+ {"inactive", 0, NULL, 'I'},
+#ifdef ENABLE_OSM_PERF_MGR
+ {"perfmgr", 0, NULL, 1},
+ {"perfmgr_sweep_time_s", 1, NULL, 2},
+#endif
+ {"prefix_routes_file", 1, NULL, 3},
+ {"consolidate_ipv6_snm_req", 0, NULL, 4},
+ {"do_mesh_analysis", 0, NULL, 5},
+ {"lash_start_vl", 1, NULL, 6},
+ {"sm_sl", 1, NULL, 7},
+ {"retries", 1, NULL, 8},
+ {"log_prefix", 1, NULL, 9},
+ {"torus_config", 1, NULL, 10},
+ {"guid_routing_order_no_scatter", 0, NULL, 13},
+ {NULL, 0, NULL, 0} /* Required at the end of the array */
+ };
+
+ /* force stdout to be line-buffered */
+ setvbuf(stdout, NULL, _IOLBF, BUFSIZ);
+
+ /* Make sure that the opensm and complib were compiled using
+ same modes (debug/free) */
+ if (osm_is_debug() != cl_is_debug()) {
+ fprintf(stderr,
+ "ERROR: OpenSM and Complib were compiled using different modes\n");
+ fprintf(stderr, "ERROR: OpenSM debug:%d Complib debug:%d \n",
+ osm_is_debug(), cl_is_debug());
+ exit(1);
+ }
+
+ printf("-------------------------------------------------\n");
+ printf("%s\n", OSM_VERSION);
+
+ do {
+ next_option = getopt_long_only(argc, argv, short_option,
+ long_option, NULL);
+ switch (next_option) {
+ case 'F':
+ config_file = optarg;
+ printf("Config file is `%s`:\n", config_file);
+ break;
+ default:
+ break;
+ }
+ } while (next_option != -1);
+
+ optind = 0; /* reset command line */
+
+ if (!config_file)
+ config_file = OSM_DEFAULT_CONFIG_FILE;
+
+ osm_subn_set_default_opt(&opt);
+
+ if (osm_subn_parse_conf_file(config_file, &opt) < 0)
+ printf("\nFail to parse config file \'%s\'\n", config_file);
+
+ printf("Command Line Arguments:\n");
+ do {
+ next_option = getopt_long_only(argc, argv, short_option,
+ long_option, NULL);
+ switch (next_option) {
+ case 12: /* --version - already printed above */
+ exit(0);
+ break;
+ case 'F':
+ break;
+ case 'c':
+ conf_template = optarg;
+ printf(" Creating config file template \'%s\'.\n",
+ conf_template);
+ break;
+ case 'o':
+ /*
+ Run once option.
+ */
+ run_once_flag = TRUE;
+ printf(" Run Once\n");
+ break;
+
+ case 'r':
+ /*
+ Reassign LIDs subnet option.
+ */
+ opt.reassign_lids = TRUE;
+ printf(" Reassign LIDs\n");
+ break;
+
+ case 'i':
+ /*
+ Specifies ignore guids file.
+ */
+ SET_STR_OPT(opt.port_prof_ignore_file, optarg);
+ printf(" Ignore Guids File = %s\n",
+ opt.port_prof_ignore_file);
+ break;
+
+ case 'w':
+ SET_STR_OPT(opt.hop_weights_file, optarg);
+ printf(" Hop Weights File = %s\n",
+ opt.hop_weights_file);
+ break;
+
+ case 'O':
+ SET_STR_OPT(opt.port_search_ordering_file, optarg);
+ printf(" Port Search Ordering/Dimension Ports File = %s\n",
+ opt.port_search_ordering_file);
+ break;
+
+ case 'g':
+ /*
+ Specifies port guid with which to bind.
+ */
+ opt.guid = cl_hton64(strtoull(optarg, NULL, 16));
+ if (!opt.guid)
+ /* If guid is 0 - need to display the
+ * guid list */
+ opt.guid = INVALID_GUID;
+ else
+ printf(" Guid <0x%" PRIx64 ">\n",
+ cl_hton64(opt.guid));
+ break;
+
+ case 's':
+ val = strtol(optarg, NULL, 0);
+ /* Check that the number is not too large */
+ if (((uint32_t) (val * 1000000)) / 1000000 != val)
+ fprintf(stderr,
+ "ERROR: sweep interval given is too large. Ignoring it.\n");
+ else {
+ opt.sweep_interval = val;
+ printf(" sweep interval = %d\n",
+ opt.sweep_interval);
+ }
+ break;
+
+ case 't':
+ val = strtoul(optarg, NULL, 0);
+ opt.transaction_timeout = strtoul(optarg, NULL, 0);
+ if (val == 0)
+ fprintf(stderr, "ERROR: timeout value 0 is invalid. Ignoring it.\n");
+ else {
+ opt.transaction_timeout = val;
+ printf(" Transaction timeout = %u\n",
+ opt.transaction_timeout);
+ }
+ break;
+
+ case 'n':
+ opt.max_wire_smps = strtoul(optarg, NULL, 0);
+ if (opt.max_wire_smps == 0 ||
+ opt.max_wire_smps > 0x7FFFFFFF)
+ opt.max_wire_smps = 0x7FFFFFFF;
+ printf(" Max wire smp's = %d\n", opt.max_wire_smps);
+ break;
+
+ case 'q':
+ /*
+ * OpenSM interactive console
+ */
+ if (strcmp(optarg, OSM_DISABLE_CONSOLE) == 0
+ || strcmp(optarg, OSM_LOCAL_CONSOLE) == 0
+#ifdef ENABLE_OSM_CONSOLE_SOCKET
+ || strcmp(optarg, OSM_REMOTE_CONSOLE) == 0
+#endif
+#ifdef ENABLE_OSM_CONSOLE_LOOPBACK
+ || strcmp(optarg, OSM_LOOPBACK_CONSOLE) == 0
+#endif
+ )
+ SET_STR_OPT(opt.console, optarg);
+ else
+ printf("-console %s option not understood\n",
+ optarg);
+ break;
+
+#ifdef ENABLE_OSM_CONSOLE_LOOPBACK
+ case 'C':
+ opt.console_port = strtol(optarg, NULL, 0);
+ break;
+#endif
+
+ case 'd':
+ dbg_lvl = strtol(optarg, NULL, 0);
+ printf(" d level = 0x%x\n", dbg_lvl);
+ if (dbg_lvl == 0) {
+ printf(" Debug mode: Ignore Other SMs\n");
+ opt.ignore_other_sm = TRUE;
+ } else if (dbg_lvl == 1) {
+ printf(" Debug mode: Forcing Single Thread\n");
+ opt.single_thread = TRUE;
+ } else if (dbg_lvl == 2) {
+ printf(" Debug mode: Force Log Flush\n");
+ opt.force_log_flush = TRUE;
+ } else if (dbg_lvl == 3) {
+ printf
+ (" Debug mode: Disable multicast support\n");
+ opt.disable_multicast = TRUE;
+ }
+ /*
+ * NOTE: Debug level 4 used to be used for memory
+ * tracking but this is now deprecated
+ */
+ else if (dbg_lvl == 5)
+ vendor_debug++;
+ else
+ printf(" OpenSM: Unknown debug option %d"
+ " ignored\n", dbg_lvl);
+ break;
+
+ case 'l':
+ temp = strtoul(optarg, NULL, 0);
+ if (temp > 7) {
+ fprintf(stderr,
+ "ERROR: LMC must be 7 or less.\n");
+ return -1;
+ }
+ opt.lmc = (uint8_t) temp;
+ printf(" LMC = %d\n", temp);
+ break;
+
+ case 'D':
+ opt.log_flags = strtol(optarg, NULL, 0);
+ printf(" verbose option -D = 0x%x\n", opt.log_flags);
+ break;
+
+ case 'f':
+ SET_STR_OPT(opt.log_file, optarg);
+ break;
+
+ case 'L':
+ opt.log_max_size = strtoul(optarg, NULL, 0);
+ printf(" Log file max size is %u MBytes\n",
+ opt.log_max_size);
+ break;
+
+ case 'e':
+ opt.accum_log_file = FALSE;
+ printf(" Creating new log file\n");
+ break;
+
+ case 'J':
+ pidfile = optarg;
+ break;
+
+ case 'P':
+ SET_STR_OPT(opt.partition_config_file, optarg);
+ break;
+
+ case 'N':
+ opt.no_partition_enforcement = TRUE;
+ break;
+
+ case 'Z':
+ if (strcmp(optarg, OSM_PARTITION_ENFORCE_BOTH) == 0
+ || strcmp(optarg, OSM_PARTITION_ENFORCE_IN) == 0
+ || strcmp(optarg, OSM_PARTITION_ENFORCE_OUT) == 0
+ || strcmp(optarg, OSM_PARTITION_ENFORCE_OFF) == 0) {
+ SET_STR_OPT(opt.part_enforce, optarg);
+ if (strcmp(optarg, OSM_PARTITION_ENFORCE_BOTH) == 0)
+ opt.part_enforce_enum = OSM_PARTITION_ENFORCE_TYPE_BOTH;
+ else if (strcmp(optarg, OSM_PARTITION_ENFORCE_IN) == 0)
+ opt.part_enforce_enum = OSM_PARTITION_ENFORCE_TYPE_IN;
+ else if (strcmp(optarg, OSM_PARTITION_ENFORCE_OUT) == 0)
+ opt.part_enforce_enum = OSM_PARTITION_ENFORCE_TYPE_OUT;
+ else
+ opt.part_enforce_enum = OSM_PARTITION_ENFORCE_TYPE_OFF;
+ } else
+ printf("-part_enforce %s option not understood\n",
+ optarg);
+ break;
+
+ case 'W':
+ opt.allow_both_pkeys = TRUE;
+ break;
+
+ case 'Q':
+ opt.qos = TRUE;
+ break;
+
+ case 'Y':
+ SET_STR_OPT(opt.qos_policy_file, optarg);
+ printf(" QoS policy file \'%s\'\n", optarg);
+ break;
+
+ case 128:
+ opt.congestion_control = TRUE;
+ break;
+
+ case 129:
+ opt.cc_key = strtoull(optarg, NULL, 0);
+ printf(" CC Key 0x%" PRIx64 "\n", opt.cc_key);
+ break;
+
+ case 'y':
+ opt.exit_on_fatal = FALSE;
+ printf(" Staying on fatal initialization errors\n");
+ break;
+
+ case 'v':
+ opt.log_flags = (opt.log_flags << 1) | 1;
+ printf(" Verbose option -v (log flags = 0x%X)\n",
+ opt.log_flags);
+ break;
+
+ case 'V':
+ opt.log_flags = 0xFF;
+ opt.force_log_flush = TRUE;
+ printf(" Big V selected\n");
+ break;
+
+ case 'p':
+ temp = strtoul(optarg, NULL, 0);
+ if (temp > 15) {
+ fprintf(stderr,
+ "ERROR: priority must be between 0 and 15\n");
+ return -1;
+ }
+ opt.sm_priority = (uint8_t) temp;
+ printf(" Priority = %d\n", temp);
+ break;
+
+ case 'k':
+ sm_key = cl_hton64(strtoull(optarg, NULL, 16));
+ printf(" SM Key <0x%" PRIx64 ">\n", cl_hton64(sm_key));
+ opt.sm_key = sm_key;
+ break;
+
+ case 'R':
+ SET_STR_OPT(opt.routing_engine_names, optarg);
+ printf(" Activate \'%s\' routing engine(s)\n", optarg);
+ break;
+
+ case 'z':
+ opt.connect_roots = TRUE;
+ printf(" Connect roots option is on\n");
+ break;
+
+ case 'A':
+ opt.use_ucast_cache = TRUE;
+ printf(" Unicast routing cache option is on\n");
+ break;
+
+ case 'M':
+ SET_STR_OPT(opt.lid_matrix_dump_file, optarg);
+ printf(" Lid matrix dump file is \'%s\'\n", optarg);
+ break;
+
+ case 'U':
+ SET_STR_OPT(opt.lfts_file, optarg);
+ printf(" LFTs file is \'%s\'\n", optarg);
+ break;
+
+ case 'S':
+ SET_STR_OPT(opt.sa_db_file, optarg);
+ printf(" SA DB file is \'%s\'\n", optarg);
+ break;
+
+ case 'a':
+ SET_STR_OPT(opt.root_guid_file, optarg);
+ printf(" Root Guid File: %s\n", opt.root_guid_file);
+ break;
+
+ case 'u':
+ SET_STR_OPT(opt.cn_guid_file, optarg);
+ printf(" Compute Node Guid File: %s\n",
+ opt.cn_guid_file);
+ break;
+
+ case 'G':
+ SET_STR_OPT(opt.io_guid_file, optarg);
+ printf(" I/O Node Guid File: %s\n", opt.io_guid_file);
+ break;
+ case 11:
+ opt.port_shifting = TRUE;
+ printf(" Port Shifting is on\n");
+ break;
+ case 14:
+ opt.scatter_ports = strtol(optarg, NULL, 0);
+ printf(" Scatter Ports is on\n");
+ break;
+ case 'H':
+ opt.max_reverse_hops = atoi(optarg);
+ printf(" Max Reverse Hops: %d\n", opt.max_reverse_hops);
+ break;
+ case 'm':
+ SET_STR_OPT(opt.ids_guid_file, optarg);
+ printf(" IDs Guid File: %s\n", opt.ids_guid_file);
+ break;
+
+ case 'X':
+ SET_STR_OPT(opt.guid_routing_order_file, optarg);
+ printf(" GUID Routing Order File: %s\n",
+ opt.guid_routing_order_file);
+ break;
+
+ case 'x':
+ opt.honor_guid2lid_file = TRUE;
+ printf(" Honor guid2lid file, if possible\n");
+ break;
+
+ case 'B':
+ opt.daemon = TRUE;
+ printf(" Daemon mode\n");
+ break;
+
+ case 'I':
+ opt.sm_inactive = TRUE;
+ printf(" SM started in inactive state\n");
+ break;
+
+#ifdef ENABLE_OSM_PERF_MGR
+ case 1:
+ opt.perfmgr = TRUE;
+ break;
+ case 2:
+ opt.perfmgr_sweep_time_s = atoi(optarg);
+ break;
+#endif /* ENABLE_OSM_PERF_MGR */
+
+ case 3:
+ SET_STR_OPT(opt.prefix_routes_file, optarg);
+ break;
+ case 4:
+ opt.consolidate_ipv6_snm_req = TRUE;
+ break;
+ case 5:
+ opt.do_mesh_analysis = TRUE;
+ break;
+ case 6:
+ temp = strtoul(optarg, NULL, 0);
+ if (temp >= IB_MAX_NUM_VLS) {
+ fprintf(stderr,
+ "ERROR: starting lash vl must be between 0 and 15\n");
+ return -1;
+ }
+ opt.lash_start_vl = (uint8_t) temp;
+ printf(" LASH starting VL = %d\n", opt.lash_start_vl);
+ break;
+ case 7:
+ temp = strtoul(optarg, NULL, 0);
+ if (temp > 15) {
+ fprintf(stderr,
+ "ERROR: SM's SL must be between 0 and 15\n");
+ return -1;
+ }
+ opt.sm_sl = (uint8_t) temp;
+ printf(" SMSL = %d\n", opt.sm_sl);
+ break;
+ case 8:
+ opt.transaction_retries = strtoul(optarg, NULL, 0);
+ printf(" Transaction retries = %u\n",
+ opt.transaction_retries);
+ break;
+ case 9:
+ SET_STR_OPT(opt.log_prefix, optarg);
+ printf("Log prefix = %s\n", opt.log_prefix);
+ break;
+ case 10:
+ SET_STR_OPT(opt.torus_conf_file, optarg);
+ printf("Torus-2QoS config file = %s\n", opt.torus_conf_file);
+ break;
+ case 13:
+ opt.guid_routing_order_no_scatter = TRUE;
+ break;
+ case 'h':
+ case '?':
+ case ':':
+ show_usage();
+ break;
+
+ case -1:
+ break; /* done with option */
+ default: /* something wrong */
+ abort();
+ }
+ } while (next_option != -1);
+
+ if (opt.log_file != NULL)
+ printf(" Log File: %s\n", opt.log_file);
+ /* Done with options description */
+ printf("-------------------------------------------------\n");
+
+ if (conf_template) {
+ status = osm_subn_write_conf_file(conf_template, &opt);
+ if (status)
+ printf("\nosm_subn_write_conf_file failed!\n");
+ exit(status);
+ }
+
+ osm_subn_verify_config(&opt);
+
+ if (vendor_debug)
+ osm_vendor_set_debug(osm.p_vendor, vendor_debug);
+
+ block_signals();
+
+ if (opt.daemon) {
+ if (INVALID_GUID == opt.guid) {
+ fprintf(stderr,
+ "ERROR: Invalid GUID specified; exiting because of daemon mode\n");
+ return -1;
+ }
+ daemonize(&osm);
+ }
+
+ complib_init();
+
+ status = osm_opensm_init(&osm, &opt);
+ if (status != IB_SUCCESS) {
+ const char *err_str = ib_get_err_str(status);
+ if (err_str == NULL)
+ err_str = "Unknown Error Type";
+ printf("\nError from osm_opensm_init: %s.\n", err_str);
+ /* We will just exit, and not go to Exit, since we don't
+ want the destroy to be called. */
+ complib_exit();
+ return status;
+ }
+
+ /*
+ If the user didn't specify a GUID on the command line,
+ then get a port GUID value with which to bind.
+ */
+ if (opt.guid == 0 || cl_hton64(opt.guid) == CL_HTON64(INVALID_GUID))
+ opt.guid = get_port_guid(&osm, opt.guid);
+
+ if (opt.guid == 0)
+ goto Exit2;
+
+ status = osm_opensm_init_finish(&osm, &opt);
+ if (status != IB_SUCCESS) {
+ const char *err_str = ib_get_err_str(status);
+ if (err_str == NULL)
+ err_str = "Unknown Error Type";
+ printf("\nError from osm_opensm_init_finish: %s.\n", err_str);
+ goto Exit2;
+ }
+
+ status = osm_opensm_bind(&osm, opt.guid);
+ if (status != IB_SUCCESS) {
+ printf("\nError from osm_opensm_bind (0x%X)\n", status);
+ printf
+ ("Perhaps another instance of OpenSM is already running\n");
+ goto Exit;
+ }
+
+ setup_signals();
+
+ osm_opensm_sweep(&osm);
+
+ if (run_once_flag == TRUE) {
+ while (!osm_exit_flag) {
+ status =
+ osm_opensm_wait_for_subnet_up(&osm,
+ osm.subn.opt.
+ sweep_interval *
+ 1000000, TRUE);
+ if (!status)
+ osm_exit_flag = 1;
+ }
+ } else {
+ /*
+ * Sit here until signaled to exit
+ */
+ osm_manager_loop(&opt, &osm);
+ }
+
+ if (osm.mad_pool.mads_out) {
+ fprintf(stdout,
+ "There are still %u MADs out. Forcing the exit of the OpenSM application...\n",
+ osm.mad_pool.mads_out);
+#ifdef HAVE_LIBPTHREAD
+ pthread_cond_signal(&osm.stats.cond);
+#else
+ cl_event_signal(&osm.stats.event);
+#endif
+ }
+
+Exit:
+ osm_opensm_destroy(&osm);
+Exit2:
+ osm_opensm_destroy_finish(&osm);
+ complib_exit();
+ remove_pidfile();
+
+ exit(0);
+}
diff --git a/contrib/ofed/opensm/opensm/osm_congestion_control.c b/contrib/ofed/opensm/opensm/osm_congestion_control.c
new file mode 100644
index 0000000..bfcd8a5
--- /dev/null
+++ b/contrib/ofed/opensm/opensm/osm_congestion_control.c
@@ -0,0 +1,807 @@
+/*
+ * Copyright (c) 2006-2009 Voltaire, Inc. All rights reserved.
+ * Copyright (c) 2009 HNR Consulting. All rights reserved.
+ * Copyright (c) 2012 Lawrence Livermore National Lab. All rights reserved.
+ * Copyright (c) 2014 Mellanox Technologies LTD. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+/*
+ * Abstract:
+ * OSM Congestion Control configuration implementation
+ *
+ * Author:
+ * Albert Chu, LLNL
+ */
+
+#if HAVE_CONFIG_H
+# include <config.h>
+#endif /* HAVE_CONFIG_H */
+
+#include <stdlib.h>
+#include <string.h>
+
+#include <iba/ib_types.h>
+#include <complib/cl_debug.h>
+#include <opensm/osm_file_ids.h>
+#define FILE_ID OSM_FILE_CONGESTION_CONTROL_C
+#include <opensm/osm_subnet.h>
+#include <opensm/osm_opensm.h>
+#include <opensm/osm_log.h>
+#include <opensm/osm_subnet.h>
+#include <opensm/osm_congestion_control.h>
+
+#define CONGESTION_CONTROL_INITIAL_TID_VALUE 0x7A93
+
+static void cc_mad_post(osm_congestion_control_t *p_cc,
+ osm_madw_t *p_madw,
+ osm_node_t *p_node,
+ osm_physp_t *p_physp,
+ ib_net16_t attr_id,
+ ib_net32_t attr_mod)
+{
+ osm_subn_opt_t *p_opt = &p_cc->subn->opt;
+ ib_cc_mad_t *p_cc_mad;
+ uint8_t port;
+
+ OSM_LOG_ENTER(p_cc->log);
+
+ port = osm_physp_get_port_num(p_physp);
+
+ p_cc_mad = osm_madw_get_cc_mad_ptr(p_madw);
+
+ p_cc_mad->header.base_ver = 1;
+ p_cc_mad->header.mgmt_class = IB_MCLASS_CC;
+ p_cc_mad->header.class_ver = 2;
+ p_cc_mad->header.method = IB_MAD_METHOD_SET;
+ p_cc_mad->header.status = 0;
+ p_cc_mad->header.class_spec = 0;
+ p_cc_mad->header.trans_id =
+ cl_hton64((uint64_t) cl_atomic_inc(&p_cc->trans_id) &
+ (uint64_t) (0xFFFFFFFF));
+ if (p_cc_mad->header.trans_id == 0)
+ p_cc_mad->header.trans_id =
+ cl_hton64((uint64_t) cl_atomic_inc(&p_cc->trans_id) &
+ (uint64_t) (0xFFFFFFFF));
+ p_cc_mad->header.attr_id = attr_id;
+ p_cc_mad->header.resv = 0;
+ p_cc_mad->header.attr_mod = attr_mod;
+
+ p_cc_mad->cc_key = p_opt->cc_key;
+
+ memset(p_cc_mad->log_data, '\0', IB_CC_LOG_DATA_SIZE);
+
+ p_madw->mad_addr.dest_lid = osm_node_get_base_lid(p_node, port);
+ p_madw->mad_addr.addr_type.gsi.remote_qp = IB_QP1;
+ p_madw->mad_addr.addr_type.gsi.remote_qkey =
+ cl_hton32(IB_QP1_WELL_KNOWN_Q_KEY);
+ p_madw->resp_expected = TRUE;
+ p_madw->fail_msg = CL_DISP_MSGID_NONE;
+
+ p_madw->context.cc_context.node_guid = osm_node_get_node_guid(p_node);
+ p_madw->context.cc_context.port_guid = osm_physp_get_port_guid(p_physp);
+ p_madw->context.cc_context.port = port;
+ p_madw->context.cc_context.mad_method = IB_MAD_METHOD_SET;
+ p_madw->context.cc_context.attr_mod = attr_mod;
+
+ cl_spinlock_acquire(&p_cc->mad_queue_lock);
+ cl_atomic_inc(&p_cc->outstanding_mads);
+ cl_qlist_insert_tail(&p_cc->mad_queue, &p_madw->list_item);
+ cl_spinlock_release(&p_cc->mad_queue_lock);
+
+ cl_event_signal(&p_cc->cc_poller_wakeup);
+
+ OSM_LOG_EXIT(p_cc->log);
+}
+
+static void cc_setup_mad_data(osm_sm_t * p_sm)
+{
+ osm_congestion_control_t *p_cc = &p_sm->p_subn->p_osm->cc;
+ osm_subn_opt_t *p_opt = &p_sm->p_subn->opt;
+ uint16_t ccti_limit;
+ int i;
+
+ /* Switch Congestion Setting */
+ p_cc->sw_cong_setting.control_map = p_opt->cc_sw_cong_setting_control_map;
+
+ memcpy(p_cc->sw_cong_setting.victim_mask,
+ p_opt->cc_sw_cong_setting_victim_mask,
+ IB_CC_PORT_MASK_DATA_SIZE);
+
+ memcpy(p_cc->sw_cong_setting.credit_mask,
+ p_opt->cc_sw_cong_setting_credit_mask,
+ IB_CC_PORT_MASK_DATA_SIZE);
+
+ /* threshold is 4 bits, takes up upper nibble of byte */
+ p_cc->sw_cong_setting.threshold_resv = (p_opt->cc_sw_cong_setting_threshold << 4);
+
+ p_cc->sw_cong_setting.packet_size = p_opt->cc_sw_cong_setting_packet_size;
+
+ /* cs threshold is 4 bits, takes up upper nibble of short */
+ p_cc->sw_cong_setting.cs_threshold_resv =
+ cl_hton16(p_opt->cc_sw_cong_setting_credit_starvation_threshold << 12);
+
+ p_cc->sw_cong_setting.cs_return_delay =
+ cl_hton16(p_opt->cc_sw_cong_setting_credit_starvation_return_delay.shift << 14
+ | p_opt->cc_sw_cong_setting_credit_starvation_return_delay.multiplier);
+
+ p_cc->sw_cong_setting.marking_rate = p_opt->cc_sw_cong_setting_marking_rate;
+
+ /* CA Congestion Setting */
+ p_cc->ca_cong_setting.port_control = p_opt->cc_ca_cong_setting_port_control;
+ p_cc->ca_cong_setting.control_map = p_opt->cc_ca_cong_setting_control_map;
+
+ for (i = 0; i < IB_CA_CONG_ENTRY_DATA_SIZE; i++) {
+ ib_ca_cong_entry_t *p_entry;
+
+ p_entry = &p_cc->ca_cong_setting.entry_list[i];
+
+ p_entry->ccti_timer = p_opt->cc_ca_cong_entries[i].ccti_timer;
+ p_entry->ccti_increase = p_opt->cc_ca_cong_entries[i].ccti_increase;
+ p_entry->trigger_threshold = p_opt->cc_ca_cong_entries[i].trigger_threshold;
+ p_entry->ccti_min = p_opt->cc_ca_cong_entries[i].ccti_min;
+ p_entry->resv0 = 0;
+ p_entry->resv1 = 0;
+ }
+
+ /* Congestion Control Table */
+
+ /* if no entries, we will always send at least 1 mad to set ccti_limit = 0 */
+ if (!p_opt->cc_cct.entries_len)
+ p_cc->cc_tbl_mads = 1;
+ else {
+ p_cc->cc_tbl_mads = p_opt->cc_cct.entries_len - 1;
+ p_cc->cc_tbl_mads /= IB_CC_TBL_ENTRY_LIST_MAX;
+ p_cc->cc_tbl_mads += 1;
+ }
+
+ CL_ASSERT(p_cc->cc_tbl_mads <= OSM_CCT_ENTRY_MAD_BLOCKS);
+
+ if (!p_opt->cc_cct.entries_len)
+ ccti_limit = 0;
+ else
+ ccti_limit = p_opt->cc_cct.entries_len - 1;
+
+ for (i = 0; i < p_cc->cc_tbl_mads; i++) {
+ int j;
+
+ p_cc->cc_tbl[i].ccti_limit = cl_hton16(ccti_limit);
+ p_cc->cc_tbl[i].resv = 0;
+
+ memset(p_cc->cc_tbl[i].entry_list,
+ '\0',
+ sizeof(p_cc->cc_tbl[i].entry_list));
+
+ if (!ccti_limit)
+ break;
+
+ for (j = 0; j < IB_CC_TBL_ENTRY_LIST_MAX; j++) {
+ int k;
+
+ k = (i * IB_CC_TBL_ENTRY_LIST_MAX) + j;
+ p_cc->cc_tbl[i].entry_list[j].shift_multiplier =
+ cl_hton16(p_opt->cc_cct.entries[k].shift << 14
+ | p_opt->cc_cct.entries[k].multiplier);
+ }
+ }
+}
+
+static ib_api_status_t cc_send_sw_cong_setting(osm_sm_t * p_sm,
+ osm_node_t *p_node)
+{
+ osm_congestion_control_t *p_cc = &p_sm->p_subn->p_osm->cc;
+ unsigned force_update;
+ osm_physp_t *p_physp;
+ osm_madw_t *p_madw = NULL;
+ ib_cc_mad_t *p_cc_mad = NULL;
+ ib_sw_cong_setting_t *p_sw_cong_setting = NULL;
+
+ OSM_LOG_ENTER(p_sm->p_log);
+
+ p_physp = osm_node_get_physp_ptr(p_node, 0);
+
+ force_update = p_physp->need_update || p_sm->p_subn->need_update;
+
+ if (!force_update
+ && !memcmp(&p_cc->sw_cong_setting,
+ &p_physp->cc.sw.sw_cong_setting,
+ sizeof(p_cc->sw_cong_setting)))
+ return IB_SUCCESS;
+
+ p_madw = osm_mad_pool_get(p_cc->mad_pool, p_cc->bind_handle,
+ MAD_BLOCK_SIZE, NULL);
+ if (p_madw == NULL) {
+ OSM_LOG(p_sm->p_log, OSM_LOG_ERROR, "ERR C101: "
+ "failed to allocate mad\n");
+ return IB_INSUFFICIENT_MEMORY;
+ }
+
+ p_cc_mad = osm_madw_get_cc_mad_ptr(p_madw);
+
+ p_sw_cong_setting = ib_cc_mad_get_mgt_data_ptr(p_cc_mad);
+
+ memcpy(p_sw_cong_setting,
+ &p_cc->sw_cong_setting,
+ sizeof(p_cc->sw_cong_setting));
+
+ cc_mad_post(p_cc, p_madw, p_node, p_physp,
+ IB_MAD_ATTR_SW_CONG_SETTING, 0);
+
+ OSM_LOG_EXIT(p_sm->p_log);
+
+ return IB_SUCCESS;
+}
+
+static ib_api_status_t cc_send_ca_cong_setting(osm_sm_t * p_sm,
+ osm_node_t *p_node,
+ osm_physp_t *p_physp)
+{
+ osm_congestion_control_t *p_cc = &p_sm->p_subn->p_osm->cc;
+ unsigned force_update;
+ osm_madw_t *p_madw = NULL;
+ ib_cc_mad_t *p_cc_mad = NULL;
+ ib_ca_cong_setting_t *p_ca_cong_setting = NULL;
+
+ OSM_LOG_ENTER(p_sm->p_log);
+
+ force_update = p_physp->need_update || p_sm->p_subn->need_update;
+
+ if (!force_update
+ && !memcmp(&p_cc->ca_cong_setting,
+ &p_physp->cc.ca.ca_cong_setting,
+ sizeof(p_cc->ca_cong_setting)))
+ return IB_SUCCESS;
+
+ p_madw = osm_mad_pool_get(p_cc->mad_pool, p_cc->bind_handle,
+ MAD_BLOCK_SIZE, NULL);
+ if (p_madw == NULL) {
+ OSM_LOG(p_sm->p_log, OSM_LOG_ERROR, "ERR C102: "
+ "failed to allocate mad\n");
+ return IB_INSUFFICIENT_MEMORY;
+ }
+
+ p_cc_mad = osm_madw_get_cc_mad_ptr(p_madw);
+
+ p_ca_cong_setting = ib_cc_mad_get_mgt_data_ptr(p_cc_mad);
+
+ memcpy(p_ca_cong_setting,
+ &p_cc->ca_cong_setting,
+ sizeof(p_cc->ca_cong_setting));
+
+ cc_mad_post(p_cc, p_madw, p_node, p_physp,
+ IB_MAD_ATTR_CA_CONG_SETTING, 0);
+
+ OSM_LOG_EXIT(p_sm->p_log);
+
+ return IB_SUCCESS;
+}
+
+static ib_api_status_t cc_send_cct(osm_sm_t * p_sm,
+ osm_node_t *p_node,
+ osm_physp_t *p_physp)
+{
+ osm_congestion_control_t *p_cc = &p_sm->p_subn->p_osm->cc;
+ unsigned force_update;
+ osm_madw_t *p_madw = NULL;
+ ib_cc_mad_t *p_cc_mad = NULL;
+ ib_cc_tbl_t *p_cc_tbl = NULL;
+ unsigned int index = 0;
+
+ OSM_LOG_ENTER(p_sm->p_log);
+
+ force_update = p_physp->need_update || p_sm->p_subn->need_update;
+
+ for (index = 0; index < p_cc->cc_tbl_mads; index++) {
+ if (!force_update
+ && !memcmp(&p_cc->cc_tbl[index],
+ &p_physp->cc.ca.cc_tbl[index],
+ sizeof(p_cc->cc_tbl[index])))
+ continue;
+
+ p_madw = osm_mad_pool_get(p_cc->mad_pool, p_cc->bind_handle,
+ MAD_BLOCK_SIZE, NULL);
+ if (p_madw == NULL) {
+ OSM_LOG(p_sm->p_log, OSM_LOG_ERROR, "ERR C103: "
+ "failed to allocate mad\n");
+ return IB_INSUFFICIENT_MEMORY;
+ }
+
+ p_cc_mad = osm_madw_get_cc_mad_ptr(p_madw);
+
+ p_cc_tbl = (ib_cc_tbl_t *)ib_cc_mad_get_mgt_data_ptr(p_cc_mad);
+
+ memcpy(p_cc_tbl,
+ &p_cc->cc_tbl[index],
+ sizeof(p_cc->cc_tbl[index]));
+
+ cc_mad_post(p_cc, p_madw, p_node, p_physp,
+ IB_MAD_ATTR_CC_TBL, cl_hton32(index));
+ }
+
+ OSM_LOG_EXIT(p_sm->p_log);
+
+ return IB_SUCCESS;
+}
+
+int osm_congestion_control_setup(struct osm_opensm *p_osm)
+{
+ cl_qmap_t *p_tbl;
+ cl_map_item_t *p_next;
+ int ret = 0;
+
+ if (!p_osm->subn.opt.congestion_control)
+ return 0;
+
+ OSM_LOG_ENTER(&p_osm->log);
+
+ /*
+ * Do nothing unless the most recent routing attempt was successful.
+ */
+ if (!p_osm->routing_engine_used)
+ return 0;
+
+ cc_setup_mad_data(&p_osm->sm);
+
+ cl_plock_acquire(&p_osm->lock);
+
+ p_tbl = &p_osm->subn.port_guid_tbl;
+ p_next = cl_qmap_head(p_tbl);
+ while (p_next != cl_qmap_end(p_tbl)) {
+ osm_port_t *p_port = (osm_port_t *) p_next;
+ osm_node_t *p_node = p_port->p_node;
+ ib_api_status_t status;
+
+ p_next = cl_qmap_next(p_next);
+
+ if (p_port->cc_unavailable_flag)
+ continue;
+
+ if (osm_node_get_type(p_node) == IB_NODE_TYPE_SWITCH) {
+ status = cc_send_sw_cong_setting(&p_osm->sm, p_node);
+ if (status != IB_SUCCESS)
+ ret = -1;
+ } else if (osm_node_get_type(p_node) == IB_NODE_TYPE_CA) {
+ status = cc_send_ca_cong_setting(&p_osm->sm,
+ p_node,
+ p_port->p_physp);
+ if (status != IB_SUCCESS)
+ ret = -1;
+
+ status = cc_send_cct(&p_osm->sm,
+ p_node,
+ p_port->p_physp);
+ if (status != IB_SUCCESS)
+ ret = -1;
+ }
+ }
+
+ cl_plock_release(&p_osm->lock);
+
+ OSM_LOG_EXIT(&p_osm->log);
+
+ return ret;
+}
+
+int osm_congestion_control_wait_pending_transactions(struct osm_opensm *p_osm)
+{
+ osm_congestion_control_t *cc = &p_osm->cc;
+
+ if (!p_osm->subn.opt.congestion_control)
+ return 0;
+
+ while (1) {
+ unsigned count = cc->outstanding_mads;
+ if (!count || osm_exit_flag)
+ break;
+ cl_event_wait_on(&cc->outstanding_mads_done_event,
+ EVENT_NO_TIMEOUT,
+ TRUE);
+ }
+
+ return osm_exit_flag;
+}
+
+static inline void decrement_outstanding_mads(osm_congestion_control_t *p_cc)
+{
+ uint32_t outstanding;
+
+ outstanding = cl_atomic_dec(&p_cc->outstanding_mads);
+ if (!outstanding)
+ cl_event_signal(&p_cc->outstanding_mads_done_event);
+
+ cl_atomic_dec(&p_cc->outstanding_mads_on_wire);
+ cl_event_signal(&p_cc->sig_mads_on_wire_continue);
+}
+
+static void cc_rcv_mad(void *context, void *data)
+{
+ osm_congestion_control_t *p_cc = context;
+ osm_opensm_t *p_osm = p_cc->osm;
+ osm_madw_t *p_madw = data;
+ ib_cc_mad_t *p_cc_mad;
+ osm_madw_context_t *p_mad_context = &p_madw->context;
+ ib_mad_t *p_mad = osm_madw_get_mad_ptr(p_madw);
+ ib_net64_t node_guid = p_mad_context->cc_context.node_guid;
+ ib_net64_t port_guid = p_mad_context->cc_context.port_guid;
+ uint8_t port = p_mad_context->cc_context.port;
+ osm_port_t *p_port;
+
+ OSM_LOG_ENTER(p_cc->log);
+
+ OSM_LOG(p_cc->log, OSM_LOG_VERBOSE,
+ "Processing received MAD status 0x%x for "
+ "attr ID %u mod 0x%x node 0x%" PRIx64 " port %u\n",
+ cl_ntoh16(p_mad->status), cl_ntoh16(p_mad->attr_id),
+ cl_ntoh32(p_mad_context->cc_context.attr_mod),
+ cl_ntoh64(node_guid), port);
+
+ p_cc_mad = osm_madw_get_cc_mad_ptr(p_madw);
+
+ cl_plock_acquire(&p_osm->lock);
+
+ p_port = osm_get_port_by_guid(p_cc->subn, port_guid);
+ if (!p_port) {
+ OSM_LOG(p_cc->log, OSM_LOG_ERROR, "ERR C109: "
+ "Port GUID 0x%" PRIx64 " not in table\n",
+ cl_ntoh64(port_guid));
+ cl_plock_release(&p_osm->lock);
+ goto Exit;
+ }
+
+ p_port->cc_timeout_count = 0;
+
+ if (p_cc_mad->header.status) {
+ if (p_cc_mad->header.status & IB_MAD_STATUS_UNSUP_CLASS_VER
+ || p_cc_mad->header.status & IB_MAD_STATUS_UNSUP_METHOD
+ || p_cc_mad->header.status & IB_MAD_STATUS_UNSUP_METHOD_ATTR)
+ p_port->cc_unavailable_flag = TRUE;
+ cl_plock_release(&p_osm->lock);
+ goto Exit;
+ }
+ else
+ p_port->cc_unavailable_flag = FALSE;
+
+ if (p_cc_mad->header.attr_id == IB_MAD_ATTR_SW_CONG_SETTING) {
+ ib_sw_cong_setting_t *p_sw_cong_setting;
+
+ p_sw_cong_setting = ib_cc_mad_get_mgt_data_ptr(p_cc_mad);
+ p_port->p_physp->cc.sw.sw_cong_setting = *p_sw_cong_setting;
+ }
+ else if (p_cc_mad->header.attr_id == IB_MAD_ATTR_CA_CONG_SETTING) {
+ ib_ca_cong_setting_t *p_ca_cong_setting;
+
+ p_ca_cong_setting = ib_cc_mad_get_mgt_data_ptr(p_cc_mad);
+ p_port->p_physp->cc.ca.ca_cong_setting = *p_ca_cong_setting;
+ }
+ else if (p_cc_mad->header.attr_id == IB_MAD_ATTR_CC_TBL) {
+ ib_net32_t attr_mod = p_mad_context->cc_context.attr_mod;
+ uint32_t index = cl_ntoh32(attr_mod);
+ ib_cc_tbl_t *p_cc_tbl;
+
+ p_cc_tbl = ib_cc_mad_get_mgt_data_ptr(p_cc_mad);
+ p_port->p_physp->cc.ca.cc_tbl[index] = *p_cc_tbl;
+ }
+ else
+ OSM_LOG(p_cc->log, OSM_LOG_ERROR, "ERR C10A: "
+ "Unexpected MAD attribute ID %u received\n",
+ cl_ntoh16(p_cc_mad->header.attr_id));
+
+ cl_plock_release(&p_osm->lock);
+
+Exit:
+ decrement_outstanding_mads(p_cc);
+ osm_mad_pool_put(p_cc->mad_pool, p_madw);
+ OSM_LOG_EXIT(p_cc->log);
+}
+
+static void cc_poller_send(osm_congestion_control_t *p_cc,
+ osm_madw_t *p_madw)
+{
+ osm_subn_opt_t *p_opt = &p_cc->subn->opt;
+ ib_api_status_t status;
+ cl_status_t sts;
+ osm_madw_context_t mad_context = p_madw->context;
+
+ status = osm_vendor_send(p_cc->bind_handle, p_madw, TRUE);
+ if (status == IB_SUCCESS) {
+ cl_atomic_inc(&p_cc->outstanding_mads_on_wire);
+ while (p_cc->outstanding_mads_on_wire >
+ (int32_t)p_opt->cc_max_outstanding_mads) {
+wait:
+ sts = cl_event_wait_on(&p_cc->sig_mads_on_wire_continue,
+ EVENT_NO_TIMEOUT, TRUE);
+ if (sts != CL_SUCCESS)
+ goto wait;
+ }
+ } else
+ OSM_LOG(p_cc->log, OSM_LOG_ERROR, "ERR C104: "
+ "send failed to node 0x%" PRIx64 "port %u\n",
+ cl_ntoh64(mad_context.cc_context.node_guid),
+ mad_context.cc_context.port);
+}
+
+static void cc_poller(void *p_ptr)
+{
+ osm_congestion_control_t *p_cc = p_ptr;
+ osm_madw_t *p_madw;
+
+ OSM_LOG_ENTER(p_cc->log);
+
+ if (p_cc->thread_state == OSM_THREAD_STATE_NONE)
+ p_cc->thread_state = OSM_THREAD_STATE_RUN;
+
+ while (p_cc->thread_state == OSM_THREAD_STATE_RUN) {
+ cl_spinlock_acquire(&p_cc->mad_queue_lock);
+
+ p_madw = (osm_madw_t *) cl_qlist_remove_head(&p_cc->mad_queue);
+
+ cl_spinlock_release(&p_cc->mad_queue_lock);
+
+ if (p_madw != (osm_madw_t *) cl_qlist_end(&p_cc->mad_queue))
+ cc_poller_send(p_cc, p_madw);
+ else
+ cl_event_wait_on(&p_cc->cc_poller_wakeup,
+ EVENT_NO_TIMEOUT, TRUE);
+ }
+
+ OSM_LOG_EXIT(p_cc->log);
+}
+
+ib_api_status_t osm_congestion_control_init(osm_congestion_control_t * p_cc,
+ struct osm_opensm *p_osm,
+ const osm_subn_opt_t * p_opt)
+{
+ ib_api_status_t status = IB_SUCCESS;
+
+ OSM_LOG_ENTER(&p_osm->log);
+
+ memset(p_cc, 0, sizeof(*p_cc));
+
+ p_cc->osm = p_osm;
+ p_cc->subn = &p_osm->subn;
+ p_cc->sm = &p_osm->sm;
+ p_cc->log = &p_osm->log;
+ p_cc->mad_pool = &p_osm->mad_pool;
+ p_cc->trans_id = CONGESTION_CONTROL_INITIAL_TID_VALUE;
+ p_cc->vendor = p_osm->p_vendor;
+
+ p_cc->cc_disp_h = cl_disp_register(&p_osm->disp, OSM_MSG_MAD_CC,
+ cc_rcv_mad, p_cc);
+ if (p_cc->cc_disp_h == CL_DISP_INVALID_HANDLE)
+ goto Exit;
+
+ cl_qlist_init(&p_cc->mad_queue);
+
+ status = cl_spinlock_init(&p_cc->mad_queue_lock);
+ if (status != IB_SUCCESS)
+ goto Exit;
+
+ cl_event_construct(&p_cc->cc_poller_wakeup);
+ status = cl_event_init(&p_cc->cc_poller_wakeup, FALSE);
+ if (status != IB_SUCCESS)
+ goto Exit;
+
+ cl_event_construct(&p_cc->outstanding_mads_done_event);
+ status = cl_event_init(&p_cc->outstanding_mads_done_event, FALSE);
+ if (status != IB_SUCCESS)
+ goto Exit;
+
+ cl_event_construct(&p_cc->sig_mads_on_wire_continue);
+ status = cl_event_init(&p_cc->sig_mads_on_wire_continue, FALSE);
+ if (status != IB_SUCCESS)
+ goto Exit;
+
+ p_cc->thread_state = OSM_THREAD_STATE_NONE;
+
+ status = cl_thread_init(&p_cc->cc_poller, cc_poller, p_cc,
+ "cc poller");
+ if (status != IB_SUCCESS)
+ goto Exit;
+
+ status = IB_SUCCESS;
+Exit:
+ OSM_LOG_EXIT(p_cc->log);
+ return status;
+}
+
+static void cc_mad_recv_callback(osm_madw_t * p_madw, void *bind_context,
+ osm_madw_t * p_req_madw)
+{
+ osm_congestion_control_t *p_cc = bind_context;
+
+ OSM_LOG_ENTER(p_cc->log);
+
+ CL_ASSERT(p_madw);
+
+ /* HACK - should be extended when supporting CC traps */
+ CL_ASSERT(p_req_madw != NULL);
+
+ osm_madw_copy_context(p_madw, p_req_madw);
+ osm_mad_pool_put(p_cc->mad_pool, p_req_madw);
+
+ /* Do not decrement outstanding mads here, do it in the dispatcher */
+
+ if (cl_disp_post(p_cc->cc_disp_h, OSM_MSG_MAD_CC,
+ p_madw, NULL, NULL) != CL_SUCCESS) {
+ OSM_LOG(p_cc->log, OSM_LOG_ERROR, "ERR C105: "
+ "Congestion Control Dispatcher post failed\n");
+ osm_mad_pool_put(p_cc->mad_pool, p_madw);
+ }
+
+ OSM_LOG_EXIT(p_cc->log);
+}
+
+static void cc_mad_send_err_callback(void *bind_context,
+ osm_madw_t * p_madw)
+{
+ osm_congestion_control_t *p_cc = bind_context;
+ osm_madw_context_t *p_madw_context = &p_madw->context;
+ osm_opensm_t *p_osm = p_cc->osm;
+ uint64_t node_guid = p_madw_context->cc_context.node_guid;
+ uint64_t port_guid = p_madw_context->cc_context.port_guid;
+ uint8_t port = p_madw_context->cc_context.port;
+ osm_port_t *p_port;
+ int log_flag = 1;
+
+ OSM_LOG_ENTER(p_cc->log);
+
+ cl_plock_acquire(&p_osm->lock);
+
+ p_port = osm_get_port_by_guid(p_cc->subn, port_guid);
+ if (!p_port) {
+ OSM_LOG(p_cc->log, OSM_LOG_ERROR, "ERR C10B: "
+ "Port GUID 0x%" PRIx64 " not in table\n",
+ cl_ntoh64(port_guid));
+ cl_plock_release(&p_osm->lock);
+ goto Exit;
+ }
+
+ /* If timed out before, don't bothering logging again
+ * we assume no CC support
+ */
+ if (p_madw->status == IB_TIMEOUT
+ && p_port->cc_timeout_count)
+ log_flag = 0;
+
+ if (log_flag)
+ OSM_LOG(p_cc->log, OSM_LOG_ERROR, "ERR C106: MAD Error (%s): "
+ "attr id = %u LID %u GUID 0x%016" PRIx64 " port %u "
+ "TID 0x%" PRIx64 "\n",
+ ib_get_err_str(p_madw->status),
+ p_madw->p_mad->attr_id,
+ cl_ntoh16(p_madw->mad_addr.dest_lid),
+ cl_ntoh64(node_guid),
+ port,
+ cl_ntoh64(p_madw->p_mad->trans_id));
+
+ if (p_madw->status == IB_TIMEOUT) {
+ p_port->cc_timeout_count++;
+ if (p_port->cc_timeout_count > OSM_CC_TIMEOUT_COUNT_THRESHOLD
+ && !p_port->cc_unavailable_flag) {
+ p_port->cc_unavailable_flag = TRUE;
+ p_port->cc_timeout_count = 0;
+ }
+ } else
+ p_cc->subn->subnet_initialization_error = TRUE;
+
+ cl_plock_release(&p_osm->lock);
+
+Exit:
+ osm_mad_pool_put(p_cc->mad_pool, p_madw);
+
+ decrement_outstanding_mads(p_cc);
+
+ OSM_LOG_EXIT(p_cc->log);
+}
+
+ib_api_status_t osm_congestion_control_bind(osm_congestion_control_t * p_cc,
+ ib_net64_t port_guid)
+{
+ osm_bind_info_t bind_info;
+ ib_api_status_t status = IB_SUCCESS;
+
+ OSM_LOG_ENTER(p_cc->log);
+
+ bind_info.port_guid = p_cc->port_guid = port_guid;
+ bind_info.mad_class = IB_MCLASS_CC;
+ bind_info.class_version = 2;
+ bind_info.is_responder = FALSE;
+ bind_info.is_report_processor = FALSE;
+ bind_info.is_trap_processor = FALSE;
+ bind_info.recv_q_size = OSM_SM_DEFAULT_QP1_RCV_SIZE;
+ bind_info.send_q_size = OSM_SM_DEFAULT_QP1_SEND_SIZE;
+ bind_info.timeout = p_cc->subn->opt.transaction_timeout;
+ bind_info.retries = p_cc->subn->opt.transaction_retries;
+
+ OSM_LOG(p_cc->log, OSM_LOG_VERBOSE,
+ "Binding to port GUID 0x%" PRIx64 "\n", cl_ntoh64(port_guid));
+
+ p_cc->bind_handle = osm_vendor_bind(p_cc->vendor, &bind_info,
+ p_cc->mad_pool,
+ cc_mad_recv_callback,
+ cc_mad_send_err_callback, p_cc);
+
+ if (p_cc->bind_handle == OSM_BIND_INVALID_HANDLE) {
+ status = IB_ERROR;
+ OSM_LOG(p_cc->log, OSM_LOG_ERROR,
+ "ERR C107: Vendor specific bind failed (%s)\n",
+ ib_get_err_str(status));
+ goto Exit;
+ }
+
+Exit:
+ OSM_LOG_EXIT(p_cc->log);
+ return status;
+}
+
+void osm_congestion_control_shutdown(osm_congestion_control_t * p_cc)
+{
+ OSM_LOG_ENTER(p_cc->log);
+ if (p_cc->bind_handle == OSM_BIND_INVALID_HANDLE) {
+ OSM_LOG(p_cc->log, OSM_LOG_ERROR,
+ "ERR C108: No previous bind\n");
+ goto Exit;
+ }
+ cl_disp_unregister(p_cc->cc_disp_h);
+Exit:
+ OSM_LOG_EXIT(p_cc->log);
+}
+
+void osm_congestion_control_destroy(osm_congestion_control_t * p_cc)
+{
+ osm_madw_t *p_madw;
+
+ OSM_LOG_ENTER(p_cc->log);
+
+ p_cc->thread_state = OSM_THREAD_STATE_EXIT;
+
+ cl_event_signal(&p_cc->sig_mads_on_wire_continue);
+ cl_event_signal(&p_cc->cc_poller_wakeup);
+
+ cl_thread_destroy(&p_cc->cc_poller);
+
+ cl_spinlock_acquire(&p_cc->mad_queue_lock);
+
+ while (!cl_is_qlist_empty(&p_cc->mad_queue)) {
+ p_madw = (osm_madw_t *) cl_qlist_remove_head(&p_cc->mad_queue);
+ osm_mad_pool_put(p_cc->mad_pool, p_madw);
+ }
+
+ cl_spinlock_release(&p_cc->mad_queue_lock);
+
+ cl_spinlock_destroy(&p_cc->mad_queue_lock);
+
+ cl_event_destroy(&p_cc->cc_poller_wakeup);
+ cl_event_destroy(&p_cc->outstanding_mads_done_event);
+ cl_event_destroy(&p_cc->sig_mads_on_wire_continue);
+
+ OSM_LOG_EXIT(p_cc->log);
+}
diff --git a/contrib/ofed/opensm/opensm/osm_console.c b/contrib/ofed/opensm/opensm/osm_console.c
new file mode 100644
index 0000000..48ee2a4
--- /dev/null
+++ b/contrib/ofed/opensm/opensm/osm_console.c
@@ -0,0 +1,1936 @@
+/*
+ * Copyright (c) 2005-2009 Voltaire, Inc. All rights reserved.
+ * Copyright (c) 2009,2010 HNR Consulting. All rights reserved.
+ * Copyright (c) 2010,2011 Mellanox Technologies LTD. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+#if HAVE_CONFIG_H
+# include <config.h>
+#endif /* HAVE_CONFIG_H */
+
+#define _WITH_GETLINE /* for getline */
+#include <stdio.h>
+#include <stdlib.h>
+#include <sys/poll.h>
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <netdb.h>
+#include <regex.h>
+#ifdef ENABLE_OSM_CONSOLE_LOOPBACK
+#include <arpa/inet.h>
+#include <netinet/in.h>
+#include <sys/socket.h>
+#endif
+#include <unistd.h>
+#include <errno.h>
+#include <ctype.h>
+#include <sys/time.h>
+#include <opensm/osm_file_ids.h>
+#define FILE_ID OSM_FILE_CONSOLE_C
+#include <opensm/osm_console.h>
+#include <complib/cl_passivelock.h>
+#include <opensm/osm_perfmgr.h>
+#include <opensm/osm_subnet.h>
+
+extern void osm_update_node_desc(IN osm_opensm_t *osm);
+
+struct command {
+ const char *name;
+ void (*help_function) (FILE * out, int detail);
+ void (*parse_function) (char **p_last, osm_opensm_t * p_osm,
+ FILE * out);
+};
+
+static struct {
+ int on;
+ int delay_s;
+ time_t previous;
+ void (*loop_function) (osm_opensm_t * p_osm, FILE * out);
+} loop_command = {
+.on = 0, .delay_s = 2, .loop_function = NULL};
+
+static const struct command console_cmds[];
+
+static char *next_token(char **p_last)
+{
+ return strtok_r(NULL, " \t\n\r", p_last);
+}
+
+#ifdef ENABLE_OSM_PERF_MGR
+static char *name_token(char **p_last)
+{
+ return strtok_r(NULL, "\t\n\r", p_last);
+}
+#endif
+
+static void help_command(FILE * out, int detail)
+{
+ int i;
+
+ fprintf(out, "Supported commands and syntax:\n");
+ fprintf(out, "help [<command>]\n");
+ /* skip help command */
+ for (i = 1; console_cmds[i].name; i++)
+ console_cmds[i].help_function(out, 0);
+}
+
+static void help_quit(FILE * out, int detail)
+{
+ fprintf(out, "quit (not valid in local mode; use ctl-c)\n");
+}
+
+static void help_loglevel(FILE * out, int detail)
+{
+ fprintf(out, "loglevel [<log-level>]\n");
+ if (detail) {
+ fprintf(out, " log-level is OR'ed from the following\n");
+ fprintf(out, " OSM_LOG_NONE 0x%02X\n",
+ OSM_LOG_NONE);
+ fprintf(out, " OSM_LOG_ERROR 0x%02X\n",
+ OSM_LOG_ERROR);
+ fprintf(out, " OSM_LOG_INFO 0x%02X\n",
+ OSM_LOG_INFO);
+ fprintf(out, " OSM_LOG_VERBOSE 0x%02X\n",
+ OSM_LOG_VERBOSE);
+ fprintf(out, " OSM_LOG_DEBUG 0x%02X\n",
+ OSM_LOG_DEBUG);
+ fprintf(out, " OSM_LOG_FUNCS 0x%02X\n",
+ OSM_LOG_FUNCS);
+ fprintf(out, " OSM_LOG_FRAMES 0x%02X\n",
+ OSM_LOG_FRAMES);
+ fprintf(out, " OSM_LOG_ROUTING 0x%02X\n",
+ OSM_LOG_ROUTING);
+ fprintf(out, " OSM_LOG_SYS 0x%02X\n",
+ OSM_LOG_SYS);
+ fprintf(out, "\n");
+ fprintf(out, " OSM_LOG_DEFAULT_LEVEL 0x%02X\n",
+ OSM_LOG_DEFAULT_LEVEL);
+ }
+}
+
+static void help_permodlog(FILE * out, int detail)
+{
+ fprintf(out, "permodlog\n");
+}
+
+static void help_priority(FILE * out, int detail)
+{
+ fprintf(out, "priority [<sm-priority>]\n");
+}
+
+static void help_resweep(FILE * out, int detail)
+{
+ fprintf(out, "resweep [heavy|light]\n");
+}
+
+static void help_reroute(FILE * out, int detail)
+{
+ fprintf(out, "reroute\n");
+ if (detail) {
+ fprintf(out, "reroute the fabric\n");
+ }
+}
+
+static void help_sweep(FILE * out, int detail)
+{
+ fprintf(out, "sweep [on|off]\n");
+ if (detail) {
+ fprintf(out, "enable or disable sweeping\n");
+ fprintf(out, " [on] sweep normally\n");
+ fprintf(out, " [off] inhibit all sweeping\n");
+ }
+}
+
+static void help_status(FILE * out, int detail)
+{
+ fprintf(out, "status [loop]\n");
+ if (detail) {
+ fprintf(out, " loop -- type \"q<ret>\" to quit\n");
+ }
+}
+
+static void help_logflush(FILE * out, int detail)
+{
+ fprintf(out, "logflush [on|off] -- toggle opensm.log file flushing\n");
+}
+
+static void help_querylid(FILE * out, int detail)
+{
+ fprintf(out,
+ "querylid lid -- print internal information about the lid specified\n");
+}
+
+static void help_portstatus(FILE * out, int detail)
+{
+ fprintf(out, "portstatus [ca|switch|router]\n");
+ if (detail) {
+ fprintf(out, "summarize port status\n");
+ fprintf(out,
+ " [ca|switch|router] -- limit the results to the node type specified\n");
+ }
+
+}
+
+static void help_switchbalance(FILE * out, int detail)
+{
+ fprintf(out, "switchbalance [verbose] [guid]\n");
+ if (detail) {
+ fprintf(out, "output switch balancing information\n");
+ fprintf(out,
+ " [verbose] -- verbose output\n"
+ " [guid] -- limit results to specified guid\n");
+ }
+}
+
+static void help_lidbalance(FILE * out, int detail)
+{
+ fprintf(out, "lidbalance [switchguid]\n");
+ if (detail) {
+ fprintf(out, "output lid balanced forwarding information\n");
+ fprintf(out,
+ " [switchguid] -- limit results to specified switch guid\n");
+ }
+}
+
+static void help_dump_conf(FILE *out, int detail)
+{
+ fprintf(out, "dump_conf\n");
+ if (detail) {
+ fprintf(out, "dump current opensm configuration\n");
+ }
+}
+
+static void help_update_desc(FILE *out, int detail)
+{
+ fprintf(out, "update_desc\n");
+ if (detail) {
+ fprintf(out, "update node description for all nodes\n");
+ }
+}
+
+#ifdef ENABLE_OSM_PERF_MGR
+static void help_perfmgr(FILE * out, int detail)
+{
+ fprintf(out,
+ "perfmgr(pm) [enable|disable\n"
+ " |clear_counters|dump_counters|print_counters(pc)|print_errors(pe)\n"
+ " |set_rm_nodes|clear_rm_nodes|clear_inactive\n"
+ " |set_query_cpi|clear_query_cpi\n"
+ " |dump_redir|clear_redir\n"
+ " |sweep|sweep_time[seconds]]\n");
+ if (detail) {
+ fprintf(out,
+ "perfmgr -- print the performance manager state\n");
+ fprintf(out,
+ " [enable|disable] -- change the perfmgr state\n");
+ fprintf(out,
+ " [sweep] -- Initiate a sweep of the fabric\n");
+ fprintf(out,
+ " [sweep_time] -- change the perfmgr sweep time (requires [seconds] option)\n");
+ fprintf(out,
+ " [clear_counters] -- clear the counters stored\n");
+ fprintf(out,
+ " [dump_counters [mach]] -- dump the counters (optionally in [mach]ine readable format)\n");
+ fprintf(out,
+ " [print_counters [<nodename|nodeguid>][:<port>]] -- print the internal counters\n"
+ " Optionally limit output by name, guid, or port\n");
+ fprintf(out,
+ " [pc [<nodename|nodeguid>][:<port>]] -- same as print_counters\n");
+ fprintf(out,
+ " [print_errors [<nodename|nodeguid>]] -- print only ports with errors\n"
+ " Optionally limit output by name or guid\n");
+ fprintf(out,
+ " [pe [<nodename|nodeguid>]] -- same as print_errors\n");
+ fprintf(out,
+ " [dump_redir [<nodename|nodeguid>]] -- dump the redirection table\n");
+ fprintf(out,
+ " [clear_redir [<nodename|nodeguid>]] -- clear the redirection table\n");
+ fprintf(out,
+ " [[set|clear]_rm_nodes] -- enable/disable the removal of \"inactive\" nodes from the DB\n"
+ " Inactive nodes are those which no longer appear on the fabric\n");
+ fprintf(out,
+ " [[set|clear]_query_cpi] -- enable/disable PerfMgrGet(ClassPortInfo)\n"
+ " ClassPortInfo indicates hardware support for extended attributes such as PortCountersExtended\n");
+ fprintf(out,
+ " [clear_inactive] -- Delete inactive nodes from the DB\n");
+ }
+}
+static void help_pm(FILE *out, int detail)
+{
+ if (detail)
+ help_perfmgr(out, detail);
+}
+#endif /* ENABLE_OSM_PERF_MGR */
+
+/* more help routines go here */
+
+static void help_parse(char **p_last, osm_opensm_t * p_osm, FILE * out)
+{
+ char *p_cmd;
+ int i, found = 0;
+
+ p_cmd = next_token(p_last);
+ if (!p_cmd)
+ help_command(out, 0);
+ else {
+ for (i = 1; console_cmds[i].name; i++) {
+ if (!strcmp(p_cmd, console_cmds[i].name)) {
+ found = 1;
+ console_cmds[i].help_function(out, 1);
+ break;
+ }
+ }
+ if (!found) {
+ fprintf(out, "%s : Command not found\n\n", p_cmd);
+ help_command(out, 0);
+ }
+ }
+}
+
+static void loglevel_parse(char **p_last, osm_opensm_t * p_osm, FILE * out)
+{
+ char *p_cmd;
+ int level;
+
+ p_cmd = next_token(p_last);
+ if (!p_cmd)
+ fprintf(out, "Current log level is 0x%x\n",
+ osm_log_get_level(&p_osm->log));
+ else {
+ /* Handle x, 0x, and decimal specification of log level */
+ if (!strncmp(p_cmd, "x", 1)) {
+ p_cmd++;
+ level = strtoul(p_cmd, NULL, 16);
+ } else {
+ if (!strncmp(p_cmd, "0x", 2)) {
+ p_cmd += 2;
+ level = strtoul(p_cmd, NULL, 16);
+ } else
+ level = strtol(p_cmd, NULL, 10);
+ }
+ if ((level >= 0) && (level < 256)) {
+ fprintf(out, "Setting log level to 0x%x\n", level);
+ osm_log_set_level(&p_osm->log, level);
+ } else
+ fprintf(out, "Invalid log level 0x%x\n", level);
+ }
+}
+
+static void permodlog_parse(char **p_last, osm_opensm_t * p_osm, FILE * out)
+{
+ FILE *fp;
+ char buf[1024];
+
+ if (p_osm->subn.opt.per_module_logging_file != NULL) {
+ fp = fopen(p_osm->subn.opt.per_module_logging_file, "r");
+ if (!fp) {
+ if (errno == ENOENT)
+ return;
+ fprintf(out, "fopen(%s) failed: %s\n",
+ p_osm->subn.opt.per_module_logging_file,
+ strerror(errno));
+ return;
+ }
+
+ fprintf(out, "Per module logging file: %s\n",
+ p_osm->subn.opt.per_module_logging_file);
+ while (fgets(buf, sizeof buf, fp) != NULL)
+ fprintf(out, "%s", buf);
+ fclose(fp);
+ fprintf(out, "\n");
+ }
+}
+
+static void priority_parse(char **p_last, osm_opensm_t * p_osm, FILE * out)
+{
+ char *p_cmd;
+ int priority;
+
+ p_cmd = next_token(p_last);
+ if (!p_cmd)
+ fprintf(out, "Current sm-priority is %d\n",
+ p_osm->subn.opt.sm_priority);
+ else {
+ priority = strtol(p_cmd, NULL, 0);
+ if (0 > priority || 15 < priority)
+ fprintf(out,
+ "Invalid sm-priority %d; must be between 0 and 15\n",
+ priority);
+ else {
+ fprintf(out, "Setting sm-priority to %d\n", priority);
+ osm_set_sm_priority(&p_osm->sm, (uint8_t)priority);
+ }
+ }
+}
+
+static const char *sm_state_str(int state)
+{
+ switch (state) {
+ case IB_SMINFO_STATE_DISCOVERING:
+ return "Discovering";
+ case IB_SMINFO_STATE_STANDBY:
+ return "Standby ";
+ case IB_SMINFO_STATE_NOTACTIVE:
+ return "Not Active ";
+ case IB_SMINFO_STATE_MASTER:
+ return "Master ";
+ }
+ return "UNKNOWN ";
+}
+
+static const char *sa_state_str(osm_sa_state_t state)
+{
+ switch (state) {
+ case OSM_SA_STATE_INIT:
+ return "Init";
+ case OSM_SA_STATE_READY:
+ return "Ready";
+ }
+ return "UNKNOWN";
+}
+
+static void dump_sms(osm_opensm_t * p_osm, FILE * out)
+{
+ osm_subn_t *p_subn = &p_osm->subn;
+ osm_remote_sm_t *p_rsm;
+
+ fprintf(out, "\n Known SMs\n"
+ " ---------\n");
+ fprintf(out, " Port GUID SM State Priority\n");
+ fprintf(out, " --------- -------- --------\n");
+ fprintf(out, " 0x%" PRIx64 " %s %d SELF\n",
+ cl_ntoh64(p_subn->sm_port_guid),
+ sm_state_str(p_subn->sm_state),
+ p_subn->opt.sm_priority);
+
+ CL_PLOCK_ACQUIRE(p_osm->sm.p_lock);
+ p_rsm = (osm_remote_sm_t *) cl_qmap_head(&p_subn->sm_guid_tbl);
+ while (p_rsm != (osm_remote_sm_t *) cl_qmap_end(&p_subn->sm_guid_tbl)) {
+ fprintf(out, " 0x%" PRIx64 " %s %d\n",
+ cl_ntoh64(p_rsm->smi.guid),
+ sm_state_str(ib_sminfo_get_state(&p_rsm->smi)),
+ ib_sminfo_get_priority(&p_rsm->smi));
+ p_rsm = (osm_remote_sm_t *) cl_qmap_next(&p_rsm->map_item);
+ }
+ CL_PLOCK_RELEASE(p_osm->sm.p_lock);
+}
+
+static void print_status(osm_opensm_t * p_osm, FILE * out)
+{
+ cl_list_item_t *item;
+
+ if (out) {
+ const char *re_str;
+
+ cl_plock_acquire(&p_osm->lock);
+ fprintf(out, " OpenSM Version : %s\n", p_osm->osm_version);
+ fprintf(out, " SM State : %s\n",
+ sm_state_str(p_osm->subn.sm_state));
+ fprintf(out, " SM Priority : %d\n",
+ p_osm->subn.opt.sm_priority);
+ fprintf(out, " SA State : %s\n",
+ sa_state_str(p_osm->sa.state));
+
+ re_str = p_osm->routing_engine_used ?
+ osm_routing_engine_type_str(p_osm->routing_engine_used->type) :
+ osm_routing_engine_type_str(OSM_ROUTING_ENGINE_TYPE_NONE);
+ fprintf(out, " Routing Engine : %s\n", re_str);
+
+ fprintf(out, " Loaded event plugins :");
+ if (cl_qlist_head(&p_osm->plugin_list) ==
+ cl_qlist_end(&p_osm->plugin_list)) {
+ fprintf(out, " <none>");
+ }
+ for (item = cl_qlist_head(&p_osm->plugin_list);
+ item != cl_qlist_end(&p_osm->plugin_list);
+ item = cl_qlist_next(item))
+ fprintf(out, " %s",
+ ((osm_epi_plugin_t *)item)->plugin_name);
+ fprintf(out, "\n");
+
+#ifdef ENABLE_OSM_PERF_MGR
+ fprintf(out, "\n PerfMgr state/sweep state : %s/%s\n",
+ osm_perfmgr_get_state_str(&p_osm->perfmgr),
+ osm_perfmgr_get_sweep_state_str(&p_osm->perfmgr));
+#endif
+ fprintf(out, "\n MAD stats\n"
+ " ---------\n"
+ " QP0 MADs outstanding : %u\n"
+ " QP0 MADs outstanding (on wire) : %u\n"
+ " QP0 MADs rcvd : %u\n"
+ " QP0 MADs sent : %u\n"
+ " QP0 unicasts sent : %u\n"
+ " QP0 unknown MADs rcvd : %u\n"
+ " SA MADs outstanding : %u\n"
+ " SA MADs rcvd : %u\n"
+ " SA MADs sent : %u\n"
+ " SA unknown MADs rcvd : %u\n"
+ " SA MADs ignored : %u\n",
+ (uint32_t)p_osm->stats.qp0_mads_outstanding,
+ (uint32_t)p_osm->stats.qp0_mads_outstanding_on_wire,
+ (uint32_t)p_osm->stats.qp0_mads_rcvd,
+ (uint32_t)p_osm->stats.qp0_mads_sent,
+ (uint32_t)p_osm->stats.qp0_unicasts_sent,
+ (uint32_t)p_osm->stats.qp0_mads_rcvd_unknown,
+ (uint32_t)p_osm->stats.sa_mads_outstanding,
+ (uint32_t)p_osm->stats.sa_mads_rcvd,
+ (uint32_t)p_osm->stats.sa_mads_sent,
+ (uint32_t)p_osm->stats.sa_mads_rcvd_unknown,
+ (uint32_t)p_osm->stats.sa_mads_ignored);
+ fprintf(out, "\n Subnet flags\n"
+ " ------------\n"
+ " Sweeping enabled : %d\n"
+ " Sweep interval (seconds) : %u\n"
+ " Ignore existing lfts : %d\n"
+ " Subnet Init errors : %d\n"
+ " In sweep hop 0 : %d\n"
+ " First time master sweep : %d\n"
+ " Coming out of standby : %d\n",
+ p_osm->subn.sweeping_enabled,
+ p_osm->subn.opt.sweep_interval,
+ p_osm->subn.ignore_existing_lfts,
+ p_osm->subn.subnet_initialization_error,
+ p_osm->subn.in_sweep_hop_0,
+ p_osm->subn.first_time_master_sweep,
+ p_osm->subn.coming_out_of_standby);
+ dump_sms(p_osm, out);
+ fprintf(out, "\n");
+ cl_plock_release(&p_osm->lock);
+ }
+}
+
+static int loop_command_check_time(void)
+{
+ time_t cur = time(NULL);
+ if ((loop_command.previous + loop_command.delay_s) < cur) {
+ loop_command.previous = cur;
+ return 1;
+ }
+ return 0;
+}
+
+static void status_parse(char **p_last, osm_opensm_t * p_osm, FILE * out)
+{
+ char *p_cmd;
+
+ p_cmd = next_token(p_last);
+ if (p_cmd) {
+ if (strcmp(p_cmd, "loop") == 0) {
+ fprintf(out, "Looping on status command...\n");
+ fflush(out);
+ loop_command.on = 1;
+ loop_command.previous = time(NULL);
+ loop_command.loop_function = print_status;
+ } else {
+ help_status(out, 1);
+ return;
+ }
+ }
+ print_status(p_osm, out);
+}
+
+static void resweep_parse(char **p_last, osm_opensm_t * p_osm, FILE * out)
+{
+ char *p_cmd;
+
+ p_cmd = next_token(p_last);
+ if (!p_cmd ||
+ (strcmp(p_cmd, "heavy") != 0 && strcmp(p_cmd, "light") != 0)) {
+ fprintf(out, "Invalid resweep command\n");
+ help_resweep(out, 1);
+ } else {
+ if (strcmp(p_cmd, "heavy") == 0)
+ p_osm->subn.force_heavy_sweep = TRUE;
+ osm_opensm_sweep(p_osm);
+ }
+}
+
+static void reroute_parse(char **p_last, osm_opensm_t * p_osm, FILE * out)
+{
+ p_osm->subn.force_reroute = TRUE;
+ osm_opensm_sweep(p_osm);
+}
+
+static void sweep_parse(char **p_last, osm_opensm_t * p_osm, FILE * out)
+{
+ char *p_cmd;
+
+ p_cmd = next_token(p_last);
+ if (!p_cmd ||
+ (strcmp(p_cmd, "on") != 0 && strcmp(p_cmd, "off") != 0)) {
+ fprintf(out, "Invalid sweep command\n");
+ help_sweep(out, 1);
+ } else {
+ if (strcmp(p_cmd, "on") == 0)
+ p_osm->subn.sweeping_enabled = TRUE;
+ else
+ p_osm->subn.sweeping_enabled = FALSE;
+ }
+}
+
+static void logflush_parse(char **p_last, osm_opensm_t * p_osm, FILE * out)
+{
+ char *p_cmd;
+
+ p_cmd = next_token(p_last);
+ if (!p_cmd ||
+ (strcmp(p_cmd, "on") != 0 && strcmp(p_cmd, "off") != 0)) {
+ fprintf(out, "Invalid logflush command\n");
+ help_sweep(out, 1);
+ } else {
+ if (strcmp(p_cmd, "on") == 0) {
+ p_osm->log.flush = TRUE;
+ fflush(p_osm->log.out_port);
+ } else
+ p_osm->log.flush = FALSE;
+ }
+}
+
+static void querylid_parse(char **p_last, osm_opensm_t * p_osm, FILE * out)
+{
+ unsigned int p = 0;
+ uint16_t lid = 0;
+ osm_port_t *p_port = NULL;
+ char *p_cmd = next_token(p_last);
+
+ if (!p_cmd) {
+ fprintf(out, "no LID specified\n");
+ help_querylid(out, 1);
+ return;
+ }
+
+ lid = (uint16_t) strtoul(p_cmd, NULL, 0);
+ cl_plock_acquire(&p_osm->lock);
+ p_port = osm_get_port_by_lid_ho(&p_osm->subn, lid);
+ if (!p_port)
+ goto invalid_lid;
+
+ fprintf(out, "Query results for LID %u\n", lid);
+ fprintf(out,
+ " GUID : 0x%016" PRIx64 "\n"
+ " Node Desc : %s\n"
+ " Node Type : %s\n"
+ " Num Ports : %d\n",
+ cl_ntoh64(p_port->guid),
+ p_port->p_node->print_desc,
+ ib_get_node_type_str(osm_node_get_type(p_port->p_node)),
+ p_port->p_node->node_info.num_ports);
+
+ if (p_port->p_node->sw)
+ p = 0;
+ else
+ p = 1;
+ for ( /* see above */ ; p < p_port->p_node->physp_tbl_size; p++) {
+ fprintf(out,
+ " Port %u health : %s\n",
+ p,
+ p_port->p_node->physp_table[p].
+ healthy ? "OK" : "ERROR");
+ }
+
+ cl_plock_release(&p_osm->lock);
+ return;
+
+invalid_lid:
+ cl_plock_release(&p_osm->lock);
+ fprintf(out, "Invalid lid %d\n", lid);
+ return;
+}
+
+/**
+ * Data structures for the portstatus command
+ */
+typedef struct _port_report {
+ struct _port_report *next;
+ uint64_t node_guid;
+ uint8_t port_num;
+ char print_desc[IB_NODE_DESCRIPTION_SIZE + 1];
+} port_report_t;
+
+static void
+__tag_port_report(port_report_t ** head, uint64_t node_guid,
+ uint8_t port_num, char *print_desc)
+{
+ port_report_t *rep = malloc(sizeof(*rep));
+ if (!rep)
+ return;
+
+ rep->node_guid = node_guid;
+ rep->port_num = port_num;
+ memcpy(rep->print_desc, print_desc, IB_NODE_DESCRIPTION_SIZE + 1);
+ rep->next = NULL;
+ if (*head) {
+ rep->next = *head;
+ *head = rep;
+ } else
+ *head = rep;
+}
+
+static void __print_port_report(FILE * out, port_report_t * head)
+{
+ port_report_t *item = head;
+ while (item != NULL) {
+ fprintf(out, " 0x%016" PRIx64 " %d (%s)\n",
+ item->node_guid, item->port_num, item->print_desc);
+ port_report_t *next = item->next;
+ free(item);
+ item = next;
+ }
+}
+
+typedef struct {
+ uint8_t node_type_lim; /* limit the results; 0 == ALL */
+ uint64_t total_nodes;
+ uint64_t total_ports;
+ uint64_t ports_down;
+ uint64_t ports_active;
+ uint64_t ports_disabled;
+ port_report_t *disabled_ports;
+ uint64_t ports_1X;
+ uint64_t ports_4X;
+ uint64_t ports_8X;
+ uint64_t ports_12X;
+ uint64_t ports_2X;
+ uint64_t ports_unknown_width;
+ port_report_t *unknown_width_ports;
+ uint64_t ports_unenabled_width;
+ port_report_t *unenabled_width_ports;
+ uint64_t ports_reduced_width;
+ port_report_t *reduced_width_ports;
+ uint64_t ports_sdr;
+ uint64_t ports_ddr;
+ uint64_t ports_qdr;
+ uint64_t ports_fdr10;
+ uint64_t ports_fdr;
+ uint64_t ports_edr;
+ uint64_t ports_unknown_speed;
+ port_report_t *unknown_speed_ports;
+ uint64_t ports_unenabled_speed;
+ port_report_t *unenabled_speed_ports;
+ uint64_t ports_reduced_speed;
+ port_report_t *reduced_speed_ports;
+} fabric_stats_t;
+
+/**
+ * iterator function to get portstatus on each node
+ */
+static void __get_stats(cl_map_item_t * const p_map_item, void *context)
+{
+ fabric_stats_t *fs = (fabric_stats_t *) context;
+ osm_node_t *node = (osm_node_t *) p_map_item;
+ osm_physp_t *physp0;
+ ib_port_info_t *pi0;
+ uint8_t num_ports = osm_node_get_num_physp(node);
+ uint8_t port = 0;
+
+ /* Skip nodes we are not interested in */
+ if (fs->node_type_lim != 0
+ && fs->node_type_lim != node->node_info.node_type)
+ return;
+
+ fs->total_nodes++;
+
+ if (osm_node_get_type(node) == IB_NODE_TYPE_SWITCH) {
+ physp0 = osm_node_get_physp_ptr(node, 0);
+ pi0 = &physp0->port_info;
+ } else
+ pi0 = NULL;
+
+ for (port = 1; port < num_ports; port++) {
+ osm_physp_t *phys = osm_node_get_physp_ptr(node, port);
+ ib_port_info_t *pi = NULL;
+ ib_mlnx_ext_port_info_t *epi = NULL;
+ uint8_t active_speed = 0;
+ uint8_t enabled_speed = 0;
+ uint8_t active_width = 0;
+ uint8_t enabled_width = 0;
+ uint8_t port_state = 0;
+ uint8_t port_phys_state = 0;
+
+ if (!phys)
+ continue;
+
+ pi = &phys->port_info;
+ epi = &phys->ext_port_info;
+ if (!pi0)
+ pi0 = pi;
+ active_speed = ib_port_info_get_link_speed_active(pi);
+ enabled_speed = ib_port_info_get_link_speed_enabled(pi);
+ active_width = pi->link_width_active;
+ enabled_width = pi->link_width_enabled;
+ port_state = ib_port_info_get_port_state(pi);
+ port_phys_state = ib_port_info_get_port_phys_state(pi);
+
+ if (port_state == IB_LINK_DOWN)
+ fs->ports_down++;
+ else if (port_state == IB_LINK_ACTIVE)
+ fs->ports_active++;
+ if (port_phys_state == IB_PORT_PHYS_STATE_DISABLED) {
+ __tag_port_report(&(fs->disabled_ports),
+ cl_ntoh64(node->node_info.node_guid),
+ port, node->print_desc);
+ fs->ports_disabled++;
+ }
+
+ fs->total_ports++;
+
+ if (port_state == IB_LINK_DOWN)
+ continue;
+
+ if (!(active_width & enabled_width)) {
+ __tag_port_report(&(fs->unenabled_width_ports),
+ cl_ntoh64(node->node_info.node_guid),
+ port, node->print_desc);
+ fs->ports_unenabled_width++;
+ }
+ else if ((enabled_width ^ active_width) > active_width) {
+ __tag_port_report(&(fs->reduced_width_ports),
+ cl_ntoh64(node->node_info.node_guid),
+ port, node->print_desc);
+ fs->ports_reduced_width++;
+ }
+
+ /* unenabled speed usually due to problems with force_link_speed */
+ if (!(active_speed & enabled_speed)) {
+ __tag_port_report(&(fs->unenabled_speed_ports),
+ cl_ntoh64(node->node_info.node_guid),
+ port, node->print_desc);
+ fs->ports_unenabled_speed++;
+ }
+ else if ((enabled_speed ^ active_speed) > active_speed) {
+ __tag_port_report(&(fs->reduced_speed_ports),
+ cl_ntoh64(node->node_info.node_guid),
+ port, node->print_desc);
+ fs->ports_reduced_speed++;
+ }
+
+ switch (active_speed) {
+ case IB_LINK_SPEED_ACTIVE_2_5:
+ fs->ports_sdr++;
+ break;
+ case IB_LINK_SPEED_ACTIVE_5:
+ fs->ports_ddr++;
+ break;
+ case IB_LINK_SPEED_ACTIVE_10:
+ if (!(pi0->capability_mask & IB_PORT_CAP_HAS_EXT_SPEEDS) ||
+ !ib_port_info_get_link_speed_ext_active(pi)) {
+ if (epi->link_speed_active & FDR10)
+ fs->ports_fdr10++;
+ else {
+ fs->ports_qdr++;
+ /* check for speed reduced from FDR10 */
+ if (epi->link_speed_enabled & FDR10) {
+ __tag_port_report(&(fs->reduced_speed_ports),
+ cl_ntoh64(node->node_info.node_guid),
+ port, node->print_desc);
+ fs->ports_reduced_speed++;
+ }
+ }
+ }
+ break;
+ case IB_LINK_SPEED_ACTIVE_EXTENDED:
+ break;
+ default:
+ __tag_port_report(&(fs->unknown_speed_ports),
+ cl_ntoh64(node->node_info.node_guid),
+ port, node->print_desc);
+ fs->ports_unknown_speed++;
+ break;
+ }
+ if (pi0->capability_mask & IB_PORT_CAP_HAS_EXT_SPEEDS &&
+ ib_port_info_get_link_speed_ext_sup(pi) &&
+ (enabled_speed = ib_port_info_get_link_speed_ext_enabled(pi)) != IB_LINK_SPEED_EXT_DISABLE &&
+ active_speed == IB_LINK_SPEED_ACTIVE_10) {
+ active_speed = ib_port_info_get_link_speed_ext_active(pi);
+ if (!(active_speed & enabled_speed)) {
+ __tag_port_report(&(fs->unenabled_speed_ports),
+ cl_ntoh64(node->node_info.node_guid),
+ port, node->print_desc);
+ fs->ports_unenabled_speed++;
+ }
+ else if ((enabled_speed ^ active_speed) > active_speed) {
+ __tag_port_report(&(fs->reduced_speed_ports),
+ cl_ntoh64(node->node_info.node_guid),
+ port, node->print_desc);
+ fs->ports_reduced_speed++;
+ }
+ switch (active_speed) {
+ case IB_LINK_SPEED_EXT_ACTIVE_14:
+ fs->ports_fdr++;
+ break;
+ case IB_LINK_SPEED_EXT_ACTIVE_25:
+ fs->ports_edr++;
+ break;
+ case IB_LINK_SPEED_EXT_ACTIVE_NONE:
+ break;
+ default:
+ __tag_port_report(&(fs->unknown_speed_ports),
+ cl_ntoh64(node->node_info.node_guid),
+ port, node->print_desc);
+ fs->ports_unknown_speed++;
+ break;
+ }
+ }
+ switch (active_width) {
+ case IB_LINK_WIDTH_ACTIVE_1X:
+ fs->ports_1X++;
+ break;
+ case IB_LINK_WIDTH_ACTIVE_4X:
+ fs->ports_4X++;
+ break;
+ case IB_LINK_WIDTH_ACTIVE_8X:
+ fs->ports_8X++;
+ break;
+ case IB_LINK_WIDTH_ACTIVE_12X:
+ fs->ports_12X++;
+ break;
+ case IB_LINK_WIDTH_ACTIVE_2X:
+ fs->ports_2X++;
+ break;
+ default:
+ __tag_port_report(&(fs->unknown_width_ports),
+ cl_ntoh64(node->node_info.node_guid),
+ port, node->print_desc);
+ fs->ports_unknown_width++;
+ break;
+ }
+ }
+}
+
+static void portstatus_parse(char **p_last, osm_opensm_t * p_osm, FILE * out)
+{
+ fabric_stats_t fs;
+ struct timeval before, after;
+ char *p_cmd;
+
+ memset(&fs, 0, sizeof(fs));
+
+ p_cmd = next_token(p_last);
+ if (p_cmd) {
+ if (strcmp(p_cmd, "ca") == 0) {
+ fs.node_type_lim = IB_NODE_TYPE_CA;
+ } else if (strcmp(p_cmd, "switch") == 0) {
+ fs.node_type_lim = IB_NODE_TYPE_SWITCH;
+ } else if (strcmp(p_cmd, "router") == 0) {
+ fs.node_type_lim = IB_NODE_TYPE_ROUTER;
+ } else {
+ fprintf(out, "Node type not understood\n");
+ help_portstatus(out, 1);
+ return;
+ }
+ }
+
+ gettimeofday(&before, NULL);
+
+ /* for each node in the system gather the stats */
+ cl_plock_acquire(&p_osm->lock);
+ cl_qmap_apply_func(&(p_osm->subn.node_guid_tbl), __get_stats,
+ (void *)&fs);
+ cl_plock_release(&p_osm->lock);
+
+ gettimeofday(&after, NULL);
+
+ /* report the stats */
+ fprintf(out, "\"%s\" port status:\n",
+ fs.node_type_lim ? ib_get_node_type_str(fs.
+ node_type_lim) : "ALL");
+ fprintf(out,
+ " %" PRIu64 " port(s) scanned on %" PRIu64
+ " nodes in %lu us\n", fs.total_ports, fs.total_nodes,
+ after.tv_usec - before.tv_usec);
+
+ if (fs.ports_down)
+ fprintf(out, " %" PRIu64 " down\n", fs.ports_down);
+ if (fs.ports_active)
+ fprintf(out, " %" PRIu64 " active\n", fs.ports_active);
+ if (fs.ports_1X)
+ fprintf(out, " %" PRIu64 " at 1X\n", fs.ports_1X);
+ if (fs.ports_4X)
+ fprintf(out, " %" PRIu64 " at 4X\n", fs.ports_4X);
+ if (fs.ports_8X)
+ fprintf(out, " %" PRIu64 " at 8X\n", fs.ports_8X);
+ if (fs.ports_12X)
+ fprintf(out, " %" PRIu64 " at 12X\n", fs.ports_12X);
+
+ if (fs.ports_sdr)
+ fprintf(out, " %" PRIu64 " at 2.5 Gbps\n", fs.ports_sdr);
+ if (fs.ports_ddr)
+ fprintf(out, " %" PRIu64 " at 5.0 Gbps\n", fs.ports_ddr);
+ if (fs.ports_qdr)
+ fprintf(out, " %" PRIu64 " at 10.0 Gbps\n", fs.ports_qdr);
+ if (fs.ports_fdr10)
+ fprintf(out, " %" PRIu64 " at 10.0 Gbps (FDR10)\n", fs.ports_fdr10);
+ if (fs.ports_fdr)
+ fprintf(out, " %" PRIu64 " at 14.0625 Gbps\n", fs.ports_fdr);
+ if (fs.ports_edr)
+ fprintf(out, " %" PRIu64 " at 25.78125 Gbps\n", fs.ports_edr);
+
+ if (fs.ports_disabled + fs.ports_reduced_speed + fs.ports_reduced_width
+ + fs.ports_unenabled_width + fs.ports_unenabled_speed
+ + fs.ports_unknown_width + fs.ports_unknown_speed > 0) {
+ fprintf(out, "\nPossible issues:\n");
+ }
+ if (fs.ports_disabled) {
+ fprintf(out, " %" PRIu64 " disabled\n", fs.ports_disabled);
+ __print_port_report(out, fs.disabled_ports);
+ }
+ if (fs.ports_unenabled_speed) {
+ fprintf(out, " %" PRIu64 " with unenabled speed\n",
+ fs.ports_unenabled_speed);
+ __print_port_report(out, fs.unenabled_speed_ports);
+ }
+ if (fs.ports_reduced_speed) {
+ fprintf(out, " %" PRIu64 " with reduced speed\n",
+ fs.ports_reduced_speed);
+ __print_port_report(out, fs.reduced_speed_ports);
+ }
+ if (fs.ports_unknown_speed) {
+ fprintf(out, " %" PRIu64 " with unknown speed\n",
+ fs.ports_unknown_speed);
+ __print_port_report(out, fs.unknown_speed_ports);
+ }
+ if (fs.ports_unenabled_width) {
+ fprintf(out, " %" PRIu64 " with unenabled width\n",
+ fs.ports_unenabled_width);
+ __print_port_report(out, fs.unenabled_width_ports);
+ }
+ if (fs.ports_reduced_width) {
+ fprintf(out, " %" PRIu64 " with reduced width\n",
+ fs.ports_reduced_width);
+ __print_port_report(out, fs.reduced_width_ports);
+ }
+ if (fs.ports_unknown_width) {
+ fprintf(out, " %" PRIu64 " with unknown width\n",
+ fs.ports_unknown_width);
+ __print_port_report(out, fs.unknown_width_ports);
+ }
+ fprintf(out, "\n");
+}
+
+static void switchbalance_check(osm_opensm_t * p_osm,
+ osm_switch_t * p_sw, FILE * out, int verbose)
+{
+ uint8_t port_num;
+ uint8_t num_ports;
+ const cl_qmap_t *p_port_tbl;
+ osm_port_t *p_port;
+ osm_physp_t *p_physp;
+ osm_physp_t *p_rem_physp;
+ osm_node_t *p_rem_node;
+ uint32_t count[255]; /* max ports is a uint8_t */
+ uint8_t output_ports[255];
+ uint8_t output_ports_count = 0;
+ uint32_t min_count = 0xFFFFFFFF;
+ uint32_t max_count = 0;
+ unsigned int i;
+
+ memset(count, '\0', sizeof(uint32_t) * 255);
+
+ /* Count port usage */
+ p_port_tbl = &p_osm->subn.port_guid_tbl;
+ for (p_port = (osm_port_t *) cl_qmap_head(p_port_tbl);
+ p_port != (osm_port_t *) cl_qmap_end(p_port_tbl);
+ p_port = (osm_port_t *) cl_qmap_next(&p_port->map_item)) {
+ uint16_t min_lid_ho;
+ uint16_t max_lid_ho;
+ uint16_t lid_ho;
+
+ /* Don't count switches in port usage */
+ if (osm_node_get_type(p_port->p_node) == IB_NODE_TYPE_SWITCH)
+ continue;
+
+ osm_port_get_lid_range_ho(p_port, &min_lid_ho, &max_lid_ho);
+
+ if (min_lid_ho == 0 || max_lid_ho == 0)
+ continue;
+
+ for (lid_ho = min_lid_ho; lid_ho <= max_lid_ho; lid_ho++) {
+ port_num = osm_switch_get_port_by_lid(p_sw, lid_ho,
+ OSM_NEW_LFT);
+ if (port_num == OSM_NO_PATH)
+ continue;
+
+ count[port_num]++;
+ }
+ }
+
+ num_ports = p_sw->num_ports;
+ for (port_num = 1; port_num < num_ports; port_num++) {
+ p_physp = osm_node_get_physp_ptr(p_sw->p_node, port_num);
+
+ /* if port is down/unhealthy, don't consider it in
+ * min/max calculations
+ */
+ if (!p_physp || !osm_physp_is_healthy(p_physp)
+ || !osm_physp_get_remote(p_physp))
+ continue;
+
+ p_rem_physp = osm_physp_get_remote(p_physp);
+ p_rem_node = osm_physp_get_node_ptr(p_rem_physp);
+
+ /* If we are directly connected to a CA/router, its not really
+ * up for balancing consideration.
+ */
+ if (osm_node_get_type(p_rem_node) != IB_NODE_TYPE_SWITCH)
+ continue;
+
+ output_ports[output_ports_count] = port_num;
+ output_ports_count++;
+
+ if (count[port_num] < min_count)
+ min_count = count[port_num];
+ if (count[port_num] > max_count)
+ max_count = count[port_num];
+ }
+
+ if (verbose || ((max_count - min_count) > 1)) {
+ if ((max_count - min_count) > 1)
+ fprintf(out,
+ "Unbalanced Switch: 0x%016" PRIx64 " (%s)\n",
+ cl_ntoh64(p_sw->p_node->node_info.node_guid),
+ p_sw->p_node->print_desc);
+ else
+ fprintf(out,
+ "Switch: 0x%016" PRIx64 " (%s)\n",
+ cl_ntoh64(p_sw->p_node->node_info.node_guid),
+ p_sw->p_node->print_desc);
+
+ for (i = 0; i < output_ports_count; i++) {
+ fprintf(out,
+ "Port %d: %d\n",
+ output_ports[i], count[output_ports[i]]);
+ }
+ }
+}
+
+static void switchbalance_parse(char **p_last, osm_opensm_t * p_osm, FILE * out)
+{
+ char *p_cmd;
+ uint64_t guid = 0;
+ osm_switch_t *p_sw;
+ int verbose = 0;
+
+ p_cmd = next_token(p_last);
+ if (p_cmd) {
+ char *p_end;
+
+ if (strcmp(p_cmd, "verbose") == 0) {
+ verbose++;
+ p_cmd = next_token(p_last);
+ }
+
+ if (p_cmd) {
+ guid = strtoull(p_cmd, &p_end, 0);
+ if (!guid || *p_end != '\0') {
+ fprintf(out, "Invalid guid specified\n");
+ help_switchbalance(out, 1);
+ return;
+ }
+ }
+ }
+
+ cl_plock_acquire(&p_osm->lock);
+ if (guid) {
+ p_sw = osm_get_switch_by_guid(&p_osm->subn, cl_hton64(guid));
+ if (!p_sw) {
+ fprintf(out, "guid not found\n");
+ goto lock_exit;
+ }
+
+ switchbalance_check(p_osm, p_sw, out, verbose);
+ } else {
+ cl_qmap_t *p_sw_guid_tbl = &p_osm->subn.sw_guid_tbl;
+ for (p_sw = (osm_switch_t *) cl_qmap_head(p_sw_guid_tbl);
+ p_sw != (osm_switch_t *) cl_qmap_end(p_sw_guid_tbl);
+ p_sw = (osm_switch_t *) cl_qmap_next(&p_sw->map_item))
+ switchbalance_check(p_osm, p_sw, out, verbose);
+ }
+lock_exit:
+ cl_plock_release(&p_osm->lock);
+ return;
+}
+
+static void lidbalance_check(osm_opensm_t * p_osm,
+ osm_switch_t * p_sw, FILE * out)
+{
+ uint8_t port_num;
+ const cl_qmap_t *p_port_tbl;
+ osm_port_t *p_port;
+
+ p_port_tbl = &p_osm->subn.port_guid_tbl;
+ for (p_port = (osm_port_t *) cl_qmap_head(p_port_tbl);
+ p_port != (osm_port_t *) cl_qmap_end(p_port_tbl);
+ p_port = (osm_port_t *) cl_qmap_next(&p_port->map_item)) {
+ uint32_t port_count[255]; /* max ports is a uint8_t */
+ osm_node_t *rem_node[255];
+ uint32_t rem_node_count;
+ uint32_t rem_count[255];
+ osm_physp_t *p_physp;
+ osm_physp_t *p_rem_physp;
+ osm_node_t *p_rem_node;
+ uint32_t port_min_count = 0xFFFFFFFF;
+ uint32_t port_max_count = 0;
+ uint32_t rem_min_count = 0xFFFFFFFF;
+ uint32_t rem_max_count = 0;
+ uint16_t min_lid_ho;
+ uint16_t max_lid_ho;
+ uint16_t lid_ho;
+ uint8_t num_ports;
+ unsigned int i;
+
+ /* we only care about non-switches */
+ if (osm_node_get_type(p_port->p_node) == IB_NODE_TYPE_SWITCH)
+ continue;
+
+ osm_port_get_lid_range_ho(p_port, &min_lid_ho, &max_lid_ho);
+
+ if (min_lid_ho == 0 || max_lid_ho == 0)
+ continue;
+
+ memset(port_count, '\0', sizeof(uint32_t) * 255);
+ memset(rem_node, '\0', sizeof(osm_node_t *) * 255);
+ rem_node_count = 0;
+ memset(rem_count, '\0', sizeof(uint32_t) * 255);
+
+ for (lid_ho = min_lid_ho; lid_ho <= max_lid_ho; lid_ho++) {
+ boolean_t rem_node_found = FALSE;
+ unsigned int indx = 0;
+
+ port_num = osm_switch_get_port_by_lid(p_sw, lid_ho,
+ OSM_NEW_LFT);
+ if (port_num == OSM_NO_PATH)
+ continue;
+
+ p_physp =
+ osm_node_get_physp_ptr(p_sw->p_node, port_num);
+
+ /* if port is down/unhealthy, can't calculate */
+ if (!p_physp || !osm_physp_is_healthy(p_physp)
+ || !osm_physp_get_remote(p_physp))
+ continue;
+
+ p_rem_physp = osm_physp_get_remote(p_physp);
+ p_rem_node = osm_physp_get_node_ptr(p_rem_physp);
+
+ /* determine if we've seen this remote node before.
+ * If not, store it. If yes, update the counter
+ */
+ for (i = 0; i < rem_node_count; i++) {
+ if (rem_node[i] == p_rem_node) {
+ rem_node_found = TRUE;
+ indx = i;
+ break;
+ }
+ }
+
+ if (!rem_node_found) {
+ rem_node[rem_node_count] = p_rem_node;
+ rem_count[rem_node_count]++;
+ indx = rem_node_count;
+ rem_node_count++;
+ } else
+ rem_count[indx]++;
+
+ port_count[port_num]++;
+ }
+
+ if (!rem_node_count)
+ continue;
+
+ for (i = 0; i < rem_node_count; i++) {
+ if (rem_count[i] < rem_min_count)
+ rem_min_count = rem_count[i];
+ if (rem_count[i] > rem_max_count)
+ rem_max_count = rem_count[i];
+ }
+
+ num_ports = p_sw->num_ports;
+ for (i = 0; i < num_ports; i++) {
+ if (!port_count[i])
+ continue;
+ if (port_count[i] < port_min_count)
+ port_min_count = port_count[i];
+ if (port_count[i] > port_max_count)
+ port_max_count = port_count[i];
+ }
+
+ /* Output if this CA/router is being forwarded an unbalanced number of
+ * times to a destination.
+ */
+ if ((rem_max_count - rem_min_count) > 1) {
+ fprintf(out,
+ "Unbalanced Remote Forwarding: Switch 0x%016"
+ PRIx64 " (%s): ",
+ cl_ntoh64(p_sw->p_node->node_info.node_guid),
+ p_sw->p_node->print_desc);
+ if (osm_node_get_type(p_port->p_node) ==
+ IB_NODE_TYPE_CA)
+ fprintf(out, "CA");
+ else if (osm_node_get_type(p_port->p_node) ==
+ IB_NODE_TYPE_ROUTER)
+ fprintf(out, "Router");
+ fprintf(out, " 0x%016" PRIx64 " (%s): ",
+ cl_ntoh64(p_port->p_node->node_info.node_guid),
+ p_port->p_node->print_desc);
+ for (i = 0; i < rem_node_count; i++) {
+ fprintf(out,
+ "Dest 0x%016" PRIx64 "(%s) - %u ",
+ cl_ntoh64(rem_node[i]->node_info.
+ node_guid),
+ rem_node[i]->print_desc, rem_count[i]);
+ }
+ fprintf(out, "\n");
+ }
+
+ /* Output if this CA/router is being forwarded through a port
+ * an unbalanced number of times.
+ */
+ if ((port_max_count - port_min_count) > 1) {
+ fprintf(out,
+ "Unbalanced Port Forwarding: Switch 0x%016"
+ PRIx64 " (%s): ",
+ cl_ntoh64(p_sw->p_node->node_info.node_guid),
+ p_sw->p_node->print_desc);
+ if (osm_node_get_type(p_port->p_node) ==
+ IB_NODE_TYPE_CA)
+ fprintf(out, "CA");
+ else if (osm_node_get_type(p_port->p_node) ==
+ IB_NODE_TYPE_ROUTER)
+ fprintf(out, "Router");
+ fprintf(out, " 0x%016" PRIx64 " (%s): ",
+ cl_ntoh64(p_port->p_node->node_info.node_guid),
+ p_port->p_node->print_desc);
+ for (i = 0; i < num_ports; i++) {
+ if (!port_count[i])
+ continue;
+ fprintf(out, "Port %u - %u: ", i,
+ port_count[i]);
+ }
+ fprintf(out, "\n");
+ }
+ }
+}
+
+static void lidbalance_parse(char **p_last, osm_opensm_t * p_osm, FILE * out)
+{
+ char *p_cmd;
+ uint64_t guid = 0;
+ osm_switch_t *p_sw;
+
+ p_cmd = next_token(p_last);
+ if (p_cmd) {
+ char *p_end;
+
+ guid = strtoull(p_cmd, &p_end, 0);
+ if (!guid || *p_end != '\0') {
+ fprintf(out, "Invalid switchguid specified\n");
+ help_lidbalance(out, 1);
+ return;
+ }
+ }
+
+ cl_plock_acquire(&p_osm->lock);
+ if (guid) {
+ p_sw = osm_get_switch_by_guid(&p_osm->subn, cl_hton64(guid));
+ if (!p_sw) {
+ fprintf(out, "switchguid not found\n");
+ goto lock_exit;
+ }
+ lidbalance_check(p_osm, p_sw, out);
+ } else {
+ cl_qmap_t *p_sw_guid_tbl = &p_osm->subn.sw_guid_tbl;
+ for (p_sw = (osm_switch_t *) cl_qmap_head(p_sw_guid_tbl);
+ p_sw != (osm_switch_t *) cl_qmap_end(p_sw_guid_tbl);
+ p_sw = (osm_switch_t *) cl_qmap_next(&p_sw->map_item))
+ lidbalance_check(p_osm, p_sw, out);
+ }
+
+lock_exit:
+ cl_plock_release(&p_osm->lock);
+ return;
+}
+
+static void dump_conf_parse(char **p_last, osm_opensm_t * p_osm, FILE * out)
+{
+ osm_subn_output_conf(out, &p_osm->subn.opt);
+}
+
+static void update_desc_parse(char **p_last, osm_opensm_t * p_osm, FILE * out)
+{
+ osm_update_node_desc(p_osm);
+}
+
+#ifdef ENABLE_OSM_PERF_MGR
+static monitored_node_t *find_node_by_name(osm_opensm_t * p_osm,
+ char *nodename)
+{
+ cl_map_item_t *item;
+ monitored_node_t *node;
+
+ item = cl_qmap_head(&p_osm->perfmgr.monitored_map);
+ while (item != cl_qmap_end(&p_osm->perfmgr.monitored_map)) {
+ node = (monitored_node_t *)item;
+ if (strcmp(node->name, nodename) == 0)
+ return node;
+ item = cl_qmap_next(item);
+ }
+
+ return NULL;
+}
+
+static monitored_node_t *find_node_by_guid(osm_opensm_t * p_osm,
+ uint64_t guid)
+{
+ cl_map_item_t *node;
+
+ node = cl_qmap_get(&p_osm->perfmgr.monitored_map, guid);
+ if (node != cl_qmap_end(&p_osm->perfmgr.monitored_map))
+ return (monitored_node_t *)node;
+
+ return NULL;
+}
+
+static void dump_redir_entry(monitored_node_t *p_mon_node, FILE * out)
+{
+ int port, redir;
+
+ /* only display monitored nodes with redirection info */
+ redir = 0;
+ for (port = (p_mon_node->esp0) ? 0 : 1;
+ port < p_mon_node->num_ports; port++) {
+ if (p_mon_node->port[port].redirection) {
+ if (!redir) {
+ fprintf(out, " Node GUID ESP0 Name\n");
+ fprintf(out, " --------- ---- ----\n");
+ fprintf(out, " 0x%" PRIx64 " %d %s\n",
+ p_mon_node->guid, p_mon_node->esp0,
+ p_mon_node->name);
+ fprintf(out, "\n Port Valid LIDs PKey QP PKey Index\n");
+ fprintf(out, " ---- ----- ---- ---- -- ----------\n");
+ redir = 1;
+ }
+ fprintf(out, " %d %d %u->%u 0x%x 0x%x %d\n",
+ port, p_mon_node->port[port].valid,
+ cl_ntoh16(p_mon_node->port[port].orig_lid),
+ cl_ntoh16(p_mon_node->port[port].lid),
+ cl_ntoh16(p_mon_node->port[port].pkey),
+ cl_ntoh32(p_mon_node->port[port].qp),
+ p_mon_node->port[port].pkey_ix);
+ }
+ }
+ if (redir)
+ fprintf(out, "\n");
+}
+
+static void dump_redir(osm_opensm_t * p_osm, char *nodename, FILE * out)
+{
+ monitored_node_t *p_mon_node;
+ uint64_t guid;
+
+ if (!p_osm->subn.opt.perfmgr_redir)
+ fprintf(out, "Perfmgr redirection not enabled\n");
+
+ fprintf(out, "\nRedirection Table\n");
+ fprintf(out, "-----------------\n");
+ cl_plock_acquire(&p_osm->lock);
+ if (nodename) {
+ guid = strtoull(nodename, NULL, 0);
+ if (guid == 0 && errno)
+ p_mon_node = find_node_by_name(p_osm, nodename);
+ else
+ p_mon_node = find_node_by_guid(p_osm, guid);
+ if (p_mon_node)
+ dump_redir_entry(p_mon_node, out);
+ else {
+ if (guid == 0 && errno)
+ fprintf(out, "Node %s not found...\n", nodename);
+ else
+ fprintf(out, "Node 0x%" PRIx64 " not found...\n", guid);
+ }
+ } else {
+ p_mon_node = (monitored_node_t *) cl_qmap_head(&p_osm->perfmgr.monitored_map);
+ while (p_mon_node != (monitored_node_t *) cl_qmap_end(&p_osm->perfmgr.monitored_map)) {
+ dump_redir_entry(p_mon_node, out);
+ p_mon_node = (monitored_node_t *) cl_qmap_next((const cl_map_item_t *)p_mon_node);
+ }
+ }
+ cl_plock_release(&p_osm->lock);
+}
+
+static void clear_redir_entry(monitored_node_t *p_mon_node)
+{
+ int port;
+ ib_net16_t orig_lid;
+
+ for (port = (p_mon_node->esp0) ? 0 : 1;
+ port < p_mon_node->num_ports; port++) {
+ if (p_mon_node->port[port].redirection) {
+ orig_lid = p_mon_node->port[port].orig_lid;
+ memset(&p_mon_node->port[port], 0,
+ sizeof(monitored_port_t));
+ p_mon_node->port[port].valid = TRUE;
+ p_mon_node->port[port].orig_lid = orig_lid;
+ }
+ }
+}
+
+static void clear_redir(osm_opensm_t * p_osm, char *nodename, FILE * out)
+{
+ monitored_node_t *p_mon_node;
+ uint64_t guid;
+
+ if (!p_osm->subn.opt.perfmgr_redir)
+ fprintf(out, "Perfmgr redirection not enabled\n");
+
+ cl_plock_acquire(&p_osm->lock);
+ if (nodename) {
+ guid = strtoull(nodename, NULL, 0);
+ if (guid == 0 && errno)
+ p_mon_node = find_node_by_name(p_osm, nodename);
+ else
+ p_mon_node = find_node_by_guid(p_osm, guid);
+ if (p_mon_node)
+ clear_redir_entry(p_mon_node);
+ else {
+ if (guid == 0 && errno)
+ fprintf(out, "Node %s not found...\n", nodename);
+ else
+ fprintf(out, "Node 0x%" PRIx64 " not found...\n", guid);
+ }
+ } else {
+ p_mon_node = (monitored_node_t *) cl_qmap_head(&p_osm->perfmgr.monitored_map);
+ while (p_mon_node != (monitored_node_t *) cl_qmap_end(&p_osm->perfmgr.monitored_map)) {
+ clear_redir_entry(p_mon_node);
+ p_mon_node = (monitored_node_t *) cl_qmap_next((const cl_map_item_t *)p_mon_node);
+ }
+ }
+ cl_plock_release(&p_osm->lock);
+}
+
+static void perfmgr_parse(char **p_last, osm_opensm_t * p_osm, FILE * out)
+{
+ char *p_cmd;
+
+ p_cmd = next_token(p_last);
+ if (p_cmd) {
+ if (strcmp(p_cmd, "enable") == 0) {
+ osm_perfmgr_set_state(&p_osm->perfmgr,
+ PERFMGR_STATE_ENABLED);
+ } else if (strcmp(p_cmd, "disable") == 0) {
+ osm_perfmgr_set_state(&p_osm->perfmgr,
+ PERFMGR_STATE_DISABLE);
+ } else if (strcmp(p_cmd, "clear_counters") == 0) {
+ osm_perfmgr_clear_counters(&p_osm->perfmgr);
+ } else if (strcmp(p_cmd, "set_rm_nodes") == 0) {
+ osm_perfmgr_set_rm_nodes(&p_osm->perfmgr, 1);
+ } else if (strcmp(p_cmd, "clear_rm_nodes") == 0) {
+ osm_perfmgr_set_rm_nodes(&p_osm->perfmgr, 0);
+ } else if (strcmp(p_cmd, "set_query_cpi") == 0) {
+ osm_perfmgr_set_query_cpi(&p_osm->perfmgr, 1);
+ } else if (strcmp(p_cmd, "clear_query_cpi") == 0) {
+ osm_perfmgr_set_query_cpi(&p_osm->perfmgr, 0);
+ } else if (strcmp(p_cmd, "dump_counters") == 0) {
+ p_cmd = next_token(p_last);
+ if (p_cmd && (strcmp(p_cmd, "mach") == 0)) {
+ osm_perfmgr_dump_counters(&p_osm->perfmgr,
+ PERFMGR_EVENT_DB_DUMP_MR);
+ } else {
+ osm_perfmgr_dump_counters(&p_osm->perfmgr,
+ PERFMGR_EVENT_DB_DUMP_HR);
+ }
+ } else if (strcmp(p_cmd, "clear_inactive") == 0) {
+ unsigned cnt = osm_perfmgr_delete_inactive(&p_osm->perfmgr);
+ fprintf(out, "Removed %u nodes from Database\n", cnt);
+ } else if (strcmp(p_cmd, "print_counters") == 0 ||
+ strcmp(p_cmd, "pc") == 0) {
+ char *port = NULL;
+ p_cmd = name_token(p_last);
+ if (p_cmd) {
+ port = strchr(p_cmd, ':');
+ if (port) {
+ *port = '\0';
+ port++;
+ }
+ }
+ osm_perfmgr_print_counters(&p_osm->perfmgr, p_cmd,
+ out, port, 0);
+ } else if (strcmp(p_cmd, "print_errors") == 0 ||
+ strcmp(p_cmd, "pe") == 0) {
+ p_cmd = name_token(p_last);
+ osm_perfmgr_print_counters(&p_osm->perfmgr, p_cmd,
+ out, NULL, 1);
+ } else if (strcmp(p_cmd, "dump_redir") == 0) {
+ p_cmd = name_token(p_last);
+ dump_redir(p_osm, p_cmd, out);
+ } else if (strcmp(p_cmd, "clear_redir") == 0) {
+ p_cmd = name_token(p_last);
+ clear_redir(p_osm, p_cmd, out);
+ } else if (strcmp(p_cmd, "sweep_time") == 0) {
+ p_cmd = next_token(p_last);
+ if (p_cmd) {
+ uint16_t time_s = atoi(p_cmd);
+ if (time_s < 1)
+ fprintf(out,
+ "sweep_time requires a "
+ "positive time period "
+ "(in seconds) to be "
+ "specified\n");
+ else
+ osm_perfmgr_set_sweep_time_s(
+ &p_osm->perfmgr,
+ time_s);
+ } else {
+ fprintf(out,
+ "sweep_time requires a time period "
+ "(in seconds) to be specified\n");
+ }
+ } else if (strcmp(p_cmd, "sweep") == 0) {
+ osm_sm_signal(&p_osm->sm, OSM_SIGNAL_PERFMGR_SWEEP);
+ fprintf(out, "sweep initiated...\n");
+ } else {
+ fprintf(out, "\"%s\" option not found\n", p_cmd);
+ }
+ } else {
+ fprintf(out, "Performance Manager status:\n"
+ "state : %s\n"
+ "sweep state : %s\n"
+ "sweep time : %us\n"
+ "outstanding queries/max : %d/%u\n"
+ "remove missing nodes from DB : %s\n"
+ "query ClassPortInfo : %s\n",
+ osm_perfmgr_get_state_str(&p_osm->perfmgr),
+ osm_perfmgr_get_sweep_state_str(&p_osm->perfmgr),
+ osm_perfmgr_get_sweep_time_s(&p_osm->perfmgr),
+ p_osm->perfmgr.outstanding_queries,
+ p_osm->perfmgr.max_outstanding_queries,
+ osm_perfmgr_get_rm_nodes(&p_osm->perfmgr)
+ ? "TRUE" : "FALSE",
+ osm_perfmgr_get_query_cpi(&p_osm->perfmgr)
+ ? "TRUE" : "FALSE");
+ }
+}
+#endif /* ENABLE_OSM_PERF_MGR */
+
+static void quit_parse(char **p_last, osm_opensm_t * p_osm, FILE * out)
+{
+ cio_close(&p_osm->console, &p_osm->log);
+}
+
+static void help_version(FILE * out, int detail)
+{
+ fprintf(out, "version -- print the OSM version\n");
+}
+
+static void version_parse(char **p_last, osm_opensm_t * p_osm, FILE * out)
+{
+ fprintf(out, "%s build %s %s\n", p_osm->osm_version, __DATE__, __TIME__);
+}
+
+/* more parse routines go here */
+typedef struct _regexp_list {
+ regex_t exp;
+ struct _regexp_list *next;
+} regexp_list_t;
+
+static void dump_portguid_parse(char **p_last, osm_opensm_t * p_osm, FILE * out)
+{
+ cl_qmap_t *p_alias_port_guid_tbl;
+ osm_alias_guid_t *p_alias_guid, *p_next_alias_guid;
+ regexp_list_t *p_regexp, *p_head_regexp = NULL;
+ FILE *output = out;
+
+ while (1) {
+ char *p_cmd = next_token(p_last);
+ if (!p_cmd)
+ break;
+
+ if (strcmp(p_cmd, "file") == 0) {
+ p_cmd = next_token(p_last);
+ if (p_cmd) {
+ output = fopen(p_cmd, "w+");
+ if (output == NULL) {
+ fprintf(out,
+ "Could not open file %s: %s\n",
+ p_cmd, strerror(errno));
+ output = out;
+ }
+ } else
+ fprintf(out, "No file name passed\n");
+ } else if (!(p_regexp = malloc(sizeof(*p_regexp)))) {
+ fprintf(out, "No memory\n");
+ break;
+ } else if (regcomp(&p_regexp->exp, p_cmd,
+ REG_NOSUB | REG_EXTENDED) != 0) {
+ fprintf(out, "Cannot parse regular expression \'%s\'."
+ " Skipping\n", p_cmd);
+ free(p_regexp);
+ continue;
+ } else {
+ p_regexp->next = p_head_regexp;
+ p_head_regexp = p_regexp;
+ }
+ }
+
+ /* Check we have at least one expression to match */
+ if (p_head_regexp == NULL) {
+ fprintf(out, "No valid expression provided. Aborting\n");
+ goto Exit;
+ }
+
+ if (p_osm->sm.p_subn->need_update != 0) {
+ fprintf(out, "Subnet is not ready yet. Try again later\n");
+ goto Free_and_exit;
+ }
+
+ /* Subnet doesn't need to be updated so we can carry on */
+
+ p_alias_port_guid_tbl = &(p_osm->sm.p_subn->alias_port_guid_tbl);
+ CL_PLOCK_ACQUIRE(p_osm->sm.p_lock);
+
+ p_next_alias_guid = (osm_alias_guid_t *) cl_qmap_head(p_alias_port_guid_tbl);
+ while (p_next_alias_guid != (osm_alias_guid_t *) cl_qmap_end(p_alias_port_guid_tbl)) {
+
+ p_alias_guid = p_next_alias_guid;
+ p_next_alias_guid =
+ (osm_alias_guid_t *) cl_qmap_next(&p_next_alias_guid->map_item);
+
+ for (p_regexp = p_head_regexp; p_regexp != NULL;
+ p_regexp = p_regexp->next)
+ if (regexec(&p_regexp->exp,
+ p_alias_guid->p_base_port->p_node->print_desc,
+ 0, NULL, 0) == 0) {
+ fprintf(output, "0x%" PRIxLEAST64 "\n",
+ cl_ntoh64(p_alias_guid->alias_guid));
+ break;
+ }
+ }
+
+ CL_PLOCK_RELEASE(p_osm->sm.p_lock);
+
+Free_and_exit:
+ for (; p_head_regexp; p_head_regexp = p_regexp) {
+ p_regexp = p_head_regexp->next;
+ regfree(&p_head_regexp->exp);
+ free(p_head_regexp);
+ }
+Exit:
+ if (output != out)
+ fclose(output);
+}
+
+static void help_dump_portguid(FILE * out, int detail)
+{
+ fprintf(out,
+ "dump_portguid [file filename] regexp1 [regexp2 [regexp3 ...]] -- Dump port GUID matching a regexp \n");
+ if (detail) {
+ fprintf(out,
+ "getguidgetguid -- Dump all the port GUID whom node_desc matches one of the provided regexp\n");
+ fprintf(out,
+ " [file filename] -- Send the port GUID list to the specified file instead of regular output\n");
+ }
+
+}
+
+static const struct command console_cmds[] = {
+ {"help", &help_command, &help_parse},
+ {"quit", &help_quit, &quit_parse},
+ {"loglevel", &help_loglevel, &loglevel_parse},
+ {"permodlog", &help_permodlog, &permodlog_parse},
+ {"priority", &help_priority, &priority_parse},
+ {"resweep", &help_resweep, &resweep_parse},
+ {"reroute", &help_reroute, &reroute_parse},
+ {"sweep", &help_sweep, &sweep_parse},
+ {"status", &help_status, &status_parse},
+ {"logflush", &help_logflush, &logflush_parse},
+ {"querylid", &help_querylid, &querylid_parse},
+ {"portstatus", &help_portstatus, &portstatus_parse},
+ {"switchbalance", &help_switchbalance, &switchbalance_parse},
+ {"lidbalance", &help_lidbalance, &lidbalance_parse},
+ {"dump_conf", &help_dump_conf, &dump_conf_parse},
+ {"update_desc", &help_update_desc, &update_desc_parse},
+ {"version", &help_version, &version_parse},
+#ifdef ENABLE_OSM_PERF_MGR
+ {"perfmgr", &help_perfmgr, &perfmgr_parse},
+ {"pm", &help_pm, &perfmgr_parse},
+#endif /* ENABLE_OSM_PERF_MGR */
+ {"dump_portguid", &help_dump_portguid, &dump_portguid_parse},
+ {NULL, NULL, NULL} /* end of array */
+};
+
+static void parse_cmd_line(char *line, osm_opensm_t * p_osm)
+{
+ char *p_cmd, *p_last;
+ int i, found = 0;
+ FILE *out = p_osm->console.out;
+
+ while (isspace(*line))
+ line++;
+ if (!*line)
+ return;
+
+ /* find first token which is the command */
+ p_cmd = strtok_r(line, " \t\n\r", &p_last);
+ if (p_cmd) {
+ for (i = 0; console_cmds[i].name; i++) {
+ if (loop_command.on) {
+ if (!strcmp(p_cmd, "q")) {
+ loop_command.on = 0;
+ }
+ found = 1;
+ break;
+ }
+ if (!strcmp(p_cmd, console_cmds[i].name)) {
+ found = 1;
+ console_cmds[i].parse_function(&p_last, p_osm,
+ out);
+ break;
+ }
+ }
+ if (!found) {
+ fprintf(out, "%s : Command not found\n\n", p_cmd);
+ help_command(out, 0);
+ }
+ } else {
+ fprintf(out, "Error parsing command line: `%s'\n", line);
+ }
+ if (loop_command.on) {
+ fprintf(out, "use \"q<ret>\" to quit loop\n");
+ fflush(out);
+ }
+}
+
+int osm_console(osm_opensm_t * p_osm)
+{
+ struct pollfd pollfd[2];
+ char *p_line;
+ size_t len;
+ ssize_t n;
+ struct pollfd *fds;
+ nfds_t nfds;
+ osm_console_t *p_oct = &p_osm->console;
+
+ pollfd[0].fd = p_oct->socket;
+ pollfd[0].events = POLLIN;
+ pollfd[0].revents = 0;
+
+ pollfd[1].fd = p_oct->in_fd;
+ pollfd[1].events = POLLIN;
+ pollfd[1].revents = 0;
+
+ fds = p_oct->socket < 0 ? &pollfd[1] : pollfd;
+ nfds = p_oct->socket < 0 || pollfd[1].fd < 0 ? 1 : 2;
+
+ if (loop_command.on && loop_command_check_time() &&
+ loop_command.loop_function) {
+ if (p_oct->out) {
+ loop_command.loop_function(p_osm, p_oct->out);
+ fflush(p_oct->out);
+ } else {
+ loop_command.on = 0;
+ }
+ }
+
+ if (poll(fds, nfds, 1000) <= 0)
+ return 0;
+
+#ifdef ENABLE_OSM_CONSOLE_LOOPBACK
+ if (pollfd[0].revents & POLLIN) {
+ int new_fd = 0;
+ struct sockaddr_in sin;
+ socklen_t len = sizeof(sin);
+ struct hostent *hent;
+ if ((new_fd = accept(p_oct->socket, (struct sockaddr *)&sin, &len)) < 0) {
+ OSM_LOG(&p_osm->log, OSM_LOG_ERROR,
+ "ERR 4B04: Failed to accept console socket: %s\n",
+ strerror(errno));
+ p_oct->in_fd = -1;
+ return 0;
+ }
+ if (inet_ntop
+ (AF_INET, &sin.sin_addr, p_oct->client_ip,
+ sizeof(p_oct->client_ip)) == NULL) {
+ snprintf(p_oct->client_ip, sizeof(p_oct->client_ip),
+ "STRING_UNKNOWN");
+ }
+ if ((hent = gethostbyaddr((const char *)&sin.sin_addr,
+ sizeof(struct in_addr),
+ AF_INET)) == NULL) {
+ snprintf(p_oct->client_hn, sizeof(p_oct->client_hn),
+ "STRING_UNKNOWN");
+ } else {
+ snprintf(p_oct->client_hn, sizeof(p_oct->client_hn),
+ "%s", hent->h_name);
+ }
+ if (is_authorized(p_oct)) {
+ cio_open(p_oct, new_fd, &p_osm->log);
+ } else {
+ OSM_LOG(&p_osm->log, OSM_LOG_ERROR,
+ "ERR 4B05: Console connection denied: %s (%s)\n",
+ p_oct->client_hn, p_oct->client_ip);
+ close(new_fd);
+ }
+ return 0;
+ }
+#endif
+
+ if (pollfd[1].revents & POLLIN) {
+ p_line = NULL;
+ /* Get input line */
+ n = getline(&p_line, &len, p_oct->in);
+ if (n > 0) {
+ /* Parse and act on input */
+ parse_cmd_line(p_line, p_osm);
+ if (!loop_command.on) {
+ osm_console_prompt(p_oct->out);
+ }
+ } else
+ cio_close(p_oct, &p_osm->log);
+ if (p_line)
+ free(p_line);
+ return 0;
+ }
+ /* input fd is closed (hanged up) */
+ if (pollfd[1].revents & POLLHUP) {
+#ifdef ENABLE_OSM_CONSOLE_LOOPBACK
+ /* If we are using a socket, we close the current connection */
+ if (p_oct->socket >= 0) {
+ cio_close(p_oct, &p_osm->log);
+ return 0;
+ }
+#endif
+ /* If we use a local console, stdin is closed (most probable is pipe ended)
+ * so we close the local console */
+ return -1;
+ }
+
+ return 0;
+}
diff --git a/contrib/ofed/opensm/opensm/osm_console_io.c b/contrib/ofed/opensm/opensm/osm_console_io.c
new file mode 100644
index 0000000..0e91a66
--- /dev/null
+++ b/contrib/ofed/opensm/opensm/osm_console_io.c
@@ -0,0 +1,266 @@
+/*
+ * Copyright (c) 2005-2009 Voltaire, Inc. All rights reserved.
+ * Copyright (c) 2008 HNR Consulting. All rights reserved.
+ * Copyright (c) 2013 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+/*
+ * Abstract:
+ * Provide a framework for the Console which decouples the connection
+ * or I/O from the functionality, or commands.
+ *
+ * Extensible - allows a variety of connection methods independent of
+ * the console commands.
+ */
+
+#if HAVE_CONFIG_H
+# include <config.h>
+#endif /* HAVE_CONFIG_H */
+
+#define _WITH_GETLINE /* for getline */
+#ifdef ENABLE_OSM_CONSOLE_LOOPBACK
+#include <tcpd.h>
+#include <arpa/inet.h>
+#include <netinet/in.h>
+#include <sys/socket.h>
+#endif
+
+#include <unistd.h>
+#include <errno.h>
+#include <signal.h>
+#include <opensm/osm_file_ids.h>
+#define FILE_ID OSM_FILE_CONSOLE_IO_C
+#include <opensm/osm_console_io.h>
+#include <stdlib.h>
+
+static int is_local(char *str)
+{
+ /* convenience - checks if just stdin/stdout */
+ if (str)
+ return (strcmp(str, OSM_LOCAL_CONSOLE) == 0);
+ return 0;
+}
+
+#ifdef ENABLE_OSM_CONSOLE_LOOPBACK
+static int is_loopback(char *str)
+{
+ /* convenience - checks if socket based connection */
+ if (str)
+ return (strcmp(str, OSM_LOOPBACK_CONSOLE) == 0);
+ return 0;
+}
+#else
+#define is_loopback is_local
+#endif
+
+#ifdef ENABLE_OSM_CONSOLE_SOCKET
+static int is_remote(char *str)
+{
+ /* convenience - checks if socket based connection */
+ if (str)
+ return strcmp(str, OSM_REMOTE_CONSOLE) == 0 || is_loopback(str);
+ return 0;
+}
+#else
+#define is_remote is_loopback
+#endif
+
+int is_console_enabled(osm_subn_opt_t * p_opt)
+{
+ /* checks for a variety of types of consoles - default is off or 0 */
+ if (p_opt)
+ return is_local(p_opt->console) || is_loopback(p_opt->console)
+ || is_remote(p_opt->console);
+ return 0;
+}
+
+
+#ifdef ENABLE_OSM_CONSOLE_LOOPBACK
+int cio_close(osm_console_t * p_oct, osm_log_t * p_log)
+{
+ int rtnval = -1;
+ if (p_oct && p_oct->in_fd > 0) {
+ OSM_LOG(p_log, OSM_LOG_VERBOSE,
+ "Console connection closed: %s (%s)\n",
+ p_oct->client_hn, p_oct->client_ip);
+ rtnval = fclose(p_oct->in);
+ p_oct->in_fd = -1;
+ p_oct->out_fd = -1;
+ p_oct->in = NULL;
+ p_oct->out = NULL;
+ }
+ return rtnval;
+}
+
+int cio_open(osm_console_t * p_oct, int new_fd, osm_log_t * p_log)
+{
+ /* returns zero if opened fine, -1 otherwise */
+ char *p_line;
+ size_t len;
+ ssize_t n;
+
+ if (p_oct->in_fd >= 0) {
+ FILE *file = fdopen(new_fd, "w+");
+
+ fprintf(file, "OpenSM Console connection already in use\n"
+ " kill other session (y/n)? ");
+ fflush(file);
+ p_line = NULL;
+ n = getline(&p_line, &len, file);
+ if (n > 0 && (p_line[0] == 'y' || p_line[0] == 'Y'))
+ cio_close(p_oct, p_log);
+ else {
+ OSM_LOG(p_log, OSM_LOG_INFO,
+ "Console connection aborted: %s (%s) - "
+ "already in use\n",
+ p_oct->client_hn, p_oct->client_ip);
+ fclose(file);
+ free(p_line);
+ return -1;
+ }
+ free(p_line);
+ }
+ p_oct->in_fd = new_fd;
+ p_oct->out_fd = p_oct->in_fd;
+ p_oct->in = fdopen(p_oct->in_fd, "w+");
+ p_oct->out = p_oct->in;
+ osm_console_prompt(p_oct->out);
+ OSM_LOG(p_log, OSM_LOG_VERBOSE, "Console connection accepted: %s (%s)\n",
+ p_oct->client_hn, p_oct->client_ip);
+
+ return (p_oct->in == NULL) ? -1 : 0;
+}
+
+/**********************************************************************
+ * Do authentication & authorization check
+ **********************************************************************/
+int is_authorized(osm_console_t * p_oct)
+{
+ /* allowed to use the console? */
+ p_oct->authorized = !is_remote(p_oct->client_type) ||
+ hosts_ctl((char *)OSM_DAEMON_NAME, p_oct->client_hn, p_oct->client_ip,
+ (char *)STRING_UNKNOWN);
+ return p_oct->authorized;
+}
+#endif
+
+void osm_console_prompt(FILE * out)
+{
+ if (out) {
+ fprintf(out, "OpenSM %s", OSM_COMMAND_PROMPT);
+ fflush(out);
+ }
+}
+
+int osm_console_init(osm_subn_opt_t * opt, osm_console_t * p_oct, osm_log_t * p_log)
+{
+ p_oct->socket = -1;
+ strncpy(p_oct->client_type, opt->console, sizeof(p_oct->client_type));
+
+ /* set up the file descriptors for the console */
+ if (strcmp(opt->console, OSM_LOCAL_CONSOLE) == 0) {
+ p_oct->in = stdin;
+ p_oct->out = stdout;
+ p_oct->in_fd = fileno(stdin);
+ p_oct->out_fd = fileno(stdout);
+
+ osm_console_prompt(p_oct->out);
+#ifdef ENABLE_OSM_CONSOLE_LOOPBACK
+ } else if (strcmp(opt->console, OSM_LOOPBACK_CONSOLE) == 0
+#ifdef ENABLE_OSM_CONSOLE_SOCKET
+ || strcmp(opt->console, OSM_REMOTE_CONSOLE) == 0
+#endif
+ ) {
+ struct sockaddr_in sin;
+ int optval = 1;
+
+ if ((p_oct->socket = socket(AF_INET, SOCK_STREAM, 0)) < 0) {
+ OSM_LOG(p_log, OSM_LOG_ERROR,
+ "ERR 4B01: Failed to open console socket: %s\n",
+ strerror(errno));
+ return -1;
+ }
+
+ if (setsockopt(p_oct->socket, SOL_SOCKET, SO_REUSEADDR,
+ &optval, sizeof(optval))) {
+ OSM_LOG(p_log, OSM_LOG_ERROR,
+ "ERR 4B06: Failed to set socket option: %s\n",
+ strerror(errno));
+ return -1;
+ }
+
+ sin.sin_family = AF_INET;
+ sin.sin_port = htons(opt->console_port);
+#ifdef ENABLE_OSM_CONSOLE_SOCKET
+ if (strcmp(opt->console, OSM_REMOTE_CONSOLE) == 0)
+ sin.sin_addr.s_addr = htonl(INADDR_ANY);
+ else
+#endif
+ sin.sin_addr.s_addr = htonl(INADDR_LOOPBACK);
+ if (bind(p_oct->socket, (struct sockaddr *)&sin, sizeof(sin)) < 0) {
+ OSM_LOG(p_log, OSM_LOG_ERROR,
+ "ERR 4B02: Failed to bind console socket: %s\n",
+ strerror(errno));
+ return -1;
+ }
+ if (listen(p_oct->socket, 1) < 0) {
+ OSM_LOG(p_log, OSM_LOG_ERROR,
+ "ERR 4B03: Failed to listen on console socket: %s\n",
+ strerror(errno));
+ return -1;
+ }
+
+ signal(SIGPIPE, SIG_IGN); /* protect ourselves from closed pipes */
+ p_oct->in = NULL;
+ p_oct->out = NULL;
+ p_oct->in_fd = -1;
+ p_oct->out_fd = -1;
+ OSM_LOG(p_log, OSM_LOG_INFO,
+ "Console listening on port %d\n", opt->console_port);
+#endif
+ }
+
+ return 0;
+}
+
+/* clean up and release resources */
+void osm_console_exit(osm_console_t * p_oct, osm_log_t * p_log)
+{
+#ifdef ENABLE_OSM_CONSOLE_LOOPBACK
+ cio_close(p_oct, p_log);
+ if (p_oct->socket > 0) {
+ OSM_LOG(p_log, OSM_LOG_INFO, "Closing console socket\n");
+ close(p_oct->socket);
+ p_oct->socket = -1;
+ }
+#endif
+}
diff --git a/contrib/ofed/opensm/opensm/osm_db_files.c b/contrib/ofed/opensm/opensm/osm_db_files.c
new file mode 100644
index 0000000..7be976b
--- /dev/null
+++ b/contrib/ofed/opensm/opensm/osm_db_files.c
@@ -0,0 +1,771 @@
+/*
+ * Copyright (c) 2004-2009 Voltaire, Inc. All rights reserved.
+ * Copyright (c) 2002-2007 Mellanox Technologies LTD. All rights reserved.
+ * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
+ * Copyright (c) 2013 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+/*
+ * Abstract:
+ * Implementation of the osm_db interface using simple text files
+ */
+
+#if HAVE_CONFIG_H
+# include <config.h>
+#endif /* HAVE_CONFIG_H */
+
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <errno.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <opensm/osm_file_ids.h>
+#define FILE_ID OSM_FILE_DB_FILES_C
+#include <opensm/st.h>
+#include <opensm/osm_db.h>
+#include <opensm/osm_log.h>
+
+/****d* Database/OSM_DB_MAX_LINE_LEN
+ * NAME
+ * OSM_DB_MAX_LINE_LEN
+ *
+ * DESCRIPTION
+ * The Maximal line length allowed for the file
+ *
+ * SYNOPSIS
+ */
+#define OSM_DB_MAX_LINE_LEN 1024
+/**********/
+
+/****d* Database/OSM_DB_MAX_GUID_LEN
+ * NAME
+ * OSM_DB_MAX_GUID_LEN
+ *
+ * DESCRIPTION
+ * The Maximal word length allowed for the file (guid or lid)
+ *
+ * SYNOPSIS
+ */
+#define OSM_DB_MAX_GUID_LEN 32
+/**********/
+
+/****s* OpenSM: Database/osm_db_domain_imp
+ * NAME
+ * osm_db_domain_imp
+ *
+ * DESCRIPTION
+ * An implementation for domain of the database based on text files and
+ * hash tables.
+ *
+ * SYNOPSIS
+ */
+typedef struct osm_db_domain_imp {
+ char *file_name;
+ st_table *p_hash;
+ cl_spinlock_t lock;
+ boolean_t dirty;
+} osm_db_domain_imp_t;
+/*
+ * FIELDS
+ *
+ * SEE ALSO
+ * osm_db_domain_t
+ *********/
+
+/****s* OpenSM: Database/osm_db_imp_t
+ * NAME
+ * osm_db_imp_t
+ *
+ * DESCRIPTION
+ * An implementation for file based database
+ *
+ * SYNOPSIS
+ */
+typedef struct osm_db_imp {
+ const char *db_dir_name;
+} osm_db_imp_t;
+/*
+ * FIELDS
+ *
+ * db_dir_name
+ * The directory holding the database
+ *
+ * SEE ALSO
+ * osm_db_t
+ *********/
+
+void osm_db_construct(IN osm_db_t * p_db)
+{
+ memset(p_db, 0, sizeof(osm_db_t));
+ cl_list_construct(&p_db->domains);
+}
+
+void osm_db_domain_destroy(IN osm_db_domain_t * p_db_domain)
+{
+ osm_db_domain_imp_t *p_domain_imp;
+ p_domain_imp = (osm_db_domain_imp_t *) p_db_domain->p_domain_imp;
+
+ osm_db_clear(p_db_domain);
+
+ cl_spinlock_destroy(&p_domain_imp->lock);
+
+ st_free_table(p_domain_imp->p_hash);
+ free(p_domain_imp->file_name);
+ free(p_domain_imp);
+}
+
+void osm_db_destroy(IN osm_db_t * p_db)
+{
+ osm_db_domain_t *p_domain;
+
+ while ((p_domain = cl_list_remove_head(&p_db->domains)) != NULL) {
+ osm_db_domain_destroy(p_domain);
+ free(p_domain);
+ }
+ cl_list_destroy(&p_db->domains);
+ free(p_db->p_db_imp);
+}
+
+int osm_db_init(IN osm_db_t * p_db, IN osm_log_t * p_log)
+{
+ osm_db_imp_t *p_db_imp;
+ struct stat dstat;
+
+ OSM_LOG_ENTER(p_log);
+
+ p_db_imp = malloc(sizeof(osm_db_imp_t));
+ if (!p_db_imp) {
+ OSM_LOG(p_log, OSM_LOG_ERROR, "ERR 6100: "
+ "Failed to allocate db memory\n");
+ return -1;
+ }
+
+ p_db_imp->db_dir_name = getenv("OSM_CACHE_DIR");
+ if (!p_db_imp->db_dir_name || !(*p_db_imp->db_dir_name))
+ p_db_imp->db_dir_name = OSM_DEFAULT_CACHE_DIR;
+
+ /* Create the directory if it doesn't exist */
+ /* There is a difference in creating directory between windows and linux */
+#ifdef __WIN__
+ {
+ int ret;
+
+ ret = SHCreateDirectoryEx(NULL, p_db_imp->db_dir_name, NULL);
+ if (ret != ERROR_SUCCESS && ret != ERROR_ALREADY_EXISTS &&
+ ret != ERROR_FILE_EXISTS)
+ goto err;
+ }
+#else /* __WIN__ */
+ /* make sure the directory exists */
+ if (lstat(p_db_imp->db_dir_name, &dstat)) {
+ if (mkdir(p_db_imp->db_dir_name, 0755))
+ goto err;
+ }
+#endif
+
+ p_db->p_log = p_log;
+ p_db->p_db_imp = (void *)p_db_imp;
+
+ cl_list_init(&p_db->domains, 5);
+
+ OSM_LOG_EXIT(p_log);
+
+ return 0;
+
+err:
+ OSM_LOG(p_log, OSM_LOG_ERROR, "ERR 6101: "
+ "Failed to create the db directory:%s\n",
+ p_db_imp->db_dir_name);
+ free(p_db_imp);
+ OSM_LOG_EXIT(p_log);
+ return 1;
+}
+
+osm_db_domain_t *osm_db_domain_init(IN osm_db_t * p_db, IN const char *domain_name)
+{
+ osm_db_domain_t *p_domain;
+ osm_db_domain_imp_t *p_domain_imp;
+ size_t path_len;
+ osm_log_t *p_log = p_db->p_log;
+ FILE *p_file;
+
+ OSM_LOG_ENTER(p_log);
+
+ /* allocate a new domain object */
+ p_domain = malloc(sizeof(osm_db_domain_t));
+ if (p_domain == NULL) {
+ OSM_LOG(p_log, OSM_LOG_ERROR, "ERR 610C: "
+ "Failed to allocate domain memory\n");
+ goto Exit;
+ }
+
+ p_domain_imp = malloc(sizeof(osm_db_domain_imp_t));
+ if (p_domain_imp == NULL) {
+ OSM_LOG(p_log, OSM_LOG_ERROR, "ERR 610D: "
+ "Failed to allocate domain_imp memory\n");
+ free(p_domain);
+ p_domain = NULL;
+ goto Exit;
+ }
+
+ path_len = strlen(((osm_db_imp_t *) p_db->p_db_imp)->db_dir_name)
+ + strlen(domain_name) + 2;
+
+ /* set the domain file name */
+ p_domain_imp->file_name = malloc(path_len);
+ if (p_domain_imp->file_name == NULL) {
+ OSM_LOG(p_log, OSM_LOG_ERROR, "ERR 610E: "
+ "Failed to allocate file_name memory\n");
+ free(p_domain_imp);
+ free(p_domain);
+ p_domain = NULL;
+ goto Exit;
+ }
+ snprintf(p_domain_imp->file_name, path_len, "%s/%s",
+ ((osm_db_imp_t *) p_db->p_db_imp)->db_dir_name, domain_name);
+
+ /* make sure the file exists - or exit if not writable */
+ p_file = fopen(p_domain_imp->file_name, "a+");
+ if (!p_file) {
+ OSM_LOG(p_log, OSM_LOG_ERROR, "ERR 6102: "
+ "Failed to open the db file:%s\n",
+ p_domain_imp->file_name);
+ free(p_domain_imp);
+ free(p_domain);
+ p_domain = NULL;
+ goto Exit;
+ }
+ fclose(p_file);
+
+ /* initialize the hash table object */
+ p_domain_imp->p_hash = st_init_strtable();
+ CL_ASSERT(p_domain_imp->p_hash != NULL);
+ p_domain_imp->dirty = FALSE;
+
+ p_domain->p_db = p_db;
+ cl_list_insert_tail(&p_db->domains, p_domain);
+ p_domain->p_domain_imp = p_domain_imp;
+ cl_spinlock_construct(&p_domain_imp->lock);
+ cl_spinlock_init(&p_domain_imp->lock);
+
+Exit:
+ OSM_LOG_EXIT(p_log);
+ return p_domain;
+}
+
+int osm_db_restore(IN osm_db_domain_t * p_domain)
+{
+
+ osm_log_t *p_log = p_domain->p_db->p_log;
+ osm_db_domain_imp_t *p_domain_imp =
+ (osm_db_domain_imp_t *) p_domain->p_domain_imp;
+ FILE *p_file;
+ int status;
+ char sLine[OSM_DB_MAX_LINE_LEN];
+ boolean_t before_key;
+ char *p_first_word, *p_rest_of_line, *p_last;
+ char *p_key = NULL;
+ char *p_prev_val = NULL, *p_accum_val = NULL;
+ char *endptr = NULL;
+ unsigned int line_num;
+
+ OSM_LOG_ENTER(p_log);
+
+ /* take the lock on the domain */
+ cl_spinlock_acquire(&p_domain_imp->lock);
+
+ /* open the file - read mode */
+ p_file = fopen(p_domain_imp->file_name, "r");
+
+ if (!p_file) {
+ OSM_LOG(p_log, OSM_LOG_ERROR, "ERR 6103: "
+ "Failed to open the db file:%s\n",
+ p_domain_imp->file_name);
+ status = 1;
+ goto Exit;
+ }
+
+ /* parse the file allocating new hash tables as required */
+ /*
+ states:
+ before_key (0) -> in_key (1)
+
+ before_key: if a word on the first byte - it is the key. state=in_key
+ the rest of the line is start of the value.
+ in_key: unless the line is empty - add it (with newlines) to the value.
+ if empty: state=before_key
+ */
+ status = 0;
+ before_key = TRUE;
+ line_num = 0;
+ /* if we got to EOF in the middle of a key we add a last newline */
+ while ((fgets(sLine, OSM_DB_MAX_LINE_LEN, p_file) != NULL) ||
+ ((before_key == FALSE) && strcpy(sLine, "\n"))
+ ) {
+ line_num++;
+ if (before_key) {
+ if ((sLine[0] != ' ') && (sLine[0] != '\t')
+ && (sLine[0] != '\n')) {
+ /* we got a new key */
+ before_key = FALSE;
+
+ /* handle the key */
+ p_first_word =
+ strtok_r(sLine, " \t\n", &p_last);
+ if (!p_first_word) {
+ OSM_LOG(p_log, OSM_LOG_ERROR,
+ "ERR 6104: "
+ "Failed to get key from line:%u : %s (file:%s)\n",
+ line_num, sLine,
+ p_domain_imp->file_name);
+ status = 1;
+ goto EndParsing;
+ }
+ if (strlen(p_first_word) > OSM_DB_MAX_GUID_LEN) {
+ OSM_LOG(p_log, OSM_LOG_ERROR,
+ "ERR 610A: "
+ "Illegal key from line:%u : %s (file:%s)\n",
+ line_num, sLine,
+ p_domain_imp->file_name);
+ status = 1;
+ goto EndParsing;
+ }
+
+ p_key = malloc(sizeof(char) *
+ (strlen(p_first_word) + 1));
+ strcpy(p_key, p_first_word);
+
+ p_rest_of_line = strtok_r(NULL, "\n", &p_last);
+ if (p_rest_of_line != NULL) {
+ p_accum_val = malloc(sizeof(char) *
+ (strlen(p_rest_of_line) + 1));
+ strcpy(p_accum_val, p_rest_of_line);
+ } else {
+ p_accum_val = malloc(2);
+ strcpy(p_accum_val, "\0");
+ }
+ } else if (sLine[0] != '\n') {
+ OSM_LOG(p_log, OSM_LOG_ERROR, "ERR 6105: "
+ "How did we get here? line:%u : %s (file:%s)\n",
+ line_num, sLine,
+ p_domain_imp->file_name);
+ status = 1;
+ goto EndParsing;
+ }
+ } /* before key */
+ else {
+ /* we already have a key */
+
+ if (sLine[0] == '\n') {
+ /* got an end of key */
+ before_key = TRUE;
+
+ /* make sure the key was not previously used */
+ if (st_lookup(p_domain_imp->p_hash,
+ (st_data_t) p_key,
+ (void *)&p_prev_val)) {
+ /* if previously used we ignore this guid */
+ OSM_LOG(p_log, OSM_LOG_ERROR,
+ "ERR 6106: "
+ "Key:%s already exists in:%s with value:%s."
+ " Removing it\n", p_key,
+ p_domain_imp->file_name,
+ p_prev_val);
+ free(p_key);
+ p_key = NULL;
+ free(p_accum_val);
+ p_accum_val = NULL;
+ continue;
+ } else {
+ p_prev_val = NULL;
+ }
+
+ OSM_LOG(p_log, OSM_LOG_DEBUG,
+ "Got key:%s value:%s\n", p_key,
+ p_accum_val);
+
+ /* check that the key is a number */
+ if (!strtouq(p_key, &endptr, 0)
+ && *endptr != '\0') {
+ OSM_LOG(p_log, OSM_LOG_ERROR,
+ "ERR 610B: "
+ "Key:%s is invalid\n", p_key);
+ free(p_key);
+ p_key = NULL;
+ free(p_accum_val);
+ p_accum_val = NULL;
+ } else {
+ /* store our key and value */
+ st_insert(p_domain_imp->p_hash,
+ (st_data_t) p_key,
+ (st_data_t) p_accum_val);
+ }
+ } else {
+ /* accumulate into the value */
+ p_prev_val = p_accum_val;
+ p_accum_val = malloc(strlen(p_prev_val) +
+ strlen(sLine) + 1);
+ strcpy(p_accum_val, p_prev_val);
+ free(p_prev_val);
+ p_prev_val = NULL;
+ strcat(p_accum_val, sLine);
+ }
+ } /* in key */
+ } /* while lines or last line */
+
+EndParsing:
+ fclose(p_file);
+
+Exit:
+ cl_spinlock_release(&p_domain_imp->lock);
+ OSM_LOG_EXIT(p_log);
+ return status;
+}
+
+static int dump_tbl_entry(st_data_t key, st_data_t val, st_data_t arg)
+{
+ FILE *p_file = (FILE *) arg;
+ char *p_key = (char *)key;
+ char *p_val = (char *)val;
+
+ fprintf(p_file, "%s %s\n\n", p_key, p_val);
+ return ST_CONTINUE;
+}
+
+int osm_db_store(IN osm_db_domain_t * p_domain,
+ IN boolean_t fsync_high_avail_files)
+{
+ osm_log_t *p_log = p_domain->p_db->p_log;
+ osm_db_domain_imp_t *p_domain_imp;
+ FILE *p_file = NULL;
+ int fd, status = 0;
+ char *p_tmp_file_name = NULL;
+
+ OSM_LOG_ENTER(p_log);
+
+ p_domain_imp = (osm_db_domain_imp_t *) p_domain->p_domain_imp;
+
+ p_tmp_file_name = malloc(sizeof(char) *
+ (strlen(p_domain_imp->file_name) + 8));
+ if (!p_tmp_file_name) {
+ OSM_LOG(p_log, OSM_LOG_ERROR, "ERR 6113: "
+ "Failed to allocate memory for temporary file name\n");
+ goto Exit2;
+ }
+ strcpy(p_tmp_file_name, p_domain_imp->file_name);
+ strcat(p_tmp_file_name, ".tmp");
+
+ cl_spinlock_acquire(&p_domain_imp->lock);
+
+ if (p_domain_imp->dirty == FALSE)
+ goto Exit;
+
+ /* open up the output file */
+ p_file = fopen(p_tmp_file_name, "w");
+ if (!p_file) {
+ OSM_LOG(p_log, OSM_LOG_ERROR, "ERR 6107: "
+ "Failed to open the db file:%s for writing: err:%s\n",
+ p_domain_imp->file_name, strerror(errno));
+ status = 1;
+ goto Exit;
+ }
+
+ st_foreach(p_domain_imp->p_hash, dump_tbl_entry, (st_data_t) p_file);
+
+ if (fsync_high_avail_files) {
+ if (fflush(p_file) == 0) {
+ fd = fileno(p_file);
+ if (fd != -1) {
+ if (fsync(fd) == -1)
+ OSM_LOG(p_log, OSM_LOG_ERROR,
+ "ERR 6110: fsync() failed (%s) for %s\n",
+ strerror(errno),
+ p_domain_imp->file_name);
+ } else
+ OSM_LOG(p_log, OSM_LOG_ERROR, "ERR 6111: "
+ "fileno() failed for %s\n",
+ p_domain_imp->file_name);
+ } else
+ OSM_LOG(p_log, OSM_LOG_ERROR, "ERR 6112: "
+ "fflush() failed (%s) for %s\n",
+ strerror(errno), p_domain_imp->file_name);
+ }
+
+ fclose(p_file);
+
+ status = rename(p_tmp_file_name, p_domain_imp->file_name);
+ if (status) {
+ OSM_LOG(p_log, OSM_LOG_ERROR, "ERR 6108: "
+ "Failed to rename the db file to:%s (err:%s)\n",
+ p_domain_imp->file_name, strerror(errno));
+ goto Exit;
+ }
+ p_domain_imp->dirty = FALSE;
+Exit:
+ cl_spinlock_release(&p_domain_imp->lock);
+ free(p_tmp_file_name);
+Exit2:
+ OSM_LOG_EXIT(p_log);
+ return status;
+}
+
+/* simply de-allocate the key and the value and return the code
+ that makes the st_foreach delete the entry */
+static int clear_tbl_entry(st_data_t key, st_data_t val, st_data_t arg)
+{
+ free((char *)key);
+ free((char *)val);
+ return ST_DELETE;
+}
+
+int osm_db_clear(IN osm_db_domain_t * p_domain)
+{
+ osm_db_domain_imp_t *p_domain_imp =
+ (osm_db_domain_imp_t *) p_domain->p_domain_imp;
+
+ cl_spinlock_acquire(&p_domain_imp->lock);
+ st_foreach(p_domain_imp->p_hash, clear_tbl_entry, (st_data_t) NULL);
+ cl_spinlock_release(&p_domain_imp->lock);
+
+ return 0;
+}
+
+static int get_key_of_tbl_entry(st_data_t key, st_data_t val, st_data_t arg)
+{
+ cl_list_t *p_list = (cl_list_t *) arg;
+ cl_list_insert_tail(p_list, (void *)key);
+ return ST_CONTINUE;
+}
+
+int osm_db_keys(IN osm_db_domain_t * p_domain, OUT cl_list_t * p_key_list)
+{
+ osm_db_domain_imp_t *p_domain_imp =
+ (osm_db_domain_imp_t *) p_domain->p_domain_imp;
+
+ cl_spinlock_acquire(&p_domain_imp->lock);
+
+ st_foreach(p_domain_imp->p_hash, get_key_of_tbl_entry,
+ (st_data_t) p_key_list);
+
+ cl_spinlock_release(&p_domain_imp->lock);
+
+ return 0;
+}
+
+char *osm_db_lookup(IN osm_db_domain_t * p_domain, IN char *p_key)
+{
+ osm_db_domain_imp_t *p_domain_imp =
+ (osm_db_domain_imp_t *) p_domain->p_domain_imp;
+ char *p_val = NULL;
+
+ cl_spinlock_acquire(&p_domain_imp->lock);
+
+ if (!st_lookup(p_domain_imp->p_hash, (st_data_t) p_key, (void *)&p_val))
+ p_val = NULL;
+
+ cl_spinlock_release(&p_domain_imp->lock);
+
+ return p_val;
+}
+
+int osm_db_update(IN osm_db_domain_t * p_domain, IN char *p_key, IN char *p_val)
+{
+ osm_log_t *p_log = p_domain->p_db->p_log;
+ osm_db_domain_imp_t *p_domain_imp =
+ (osm_db_domain_imp_t *) p_domain->p_domain_imp;
+ char *p_prev_val = NULL;
+ char *p_new_key;
+ char *p_new_val;
+
+ cl_spinlock_acquire(&p_domain_imp->lock);
+
+ if (st_lookup(p_domain_imp->p_hash,
+ (st_data_t) p_key, (void *)&p_prev_val)) {
+ OSM_LOG(p_log, OSM_LOG_DEBUG,
+ "Key:%s previously exists in:%s with value:%s\n",
+ p_key, p_domain_imp->file_name, p_prev_val);
+ p_new_key = p_key;
+ /* same key, same value - nothing to update */
+ if (p_prev_val && !strcmp(p_val, p_prev_val))
+ goto Exit;
+ } else {
+ /* need to allocate the key */
+ p_new_key = malloc(sizeof(char) * (strlen(p_key) + 1));
+ strcpy(p_new_key, p_key);
+ }
+
+ /* need to arange a new copy of the value */
+ p_new_val = malloc(sizeof(char) * (strlen(p_val) + 1));
+ strcpy(p_new_val, p_val);
+
+ st_insert(p_domain_imp->p_hash, (st_data_t) p_new_key,
+ (st_data_t) p_new_val);
+
+ if (p_prev_val)
+ free(p_prev_val);
+
+ p_domain_imp->dirty = TRUE;
+
+Exit:
+ cl_spinlock_release(&p_domain_imp->lock);
+
+ return 0;
+}
+
+int osm_db_delete(IN osm_db_domain_t * p_domain, IN char *p_key)
+{
+ osm_log_t *p_log = p_domain->p_db->p_log;
+ osm_db_domain_imp_t *p_domain_imp =
+ (osm_db_domain_imp_t *) p_domain->p_domain_imp;
+ char *p_prev_val = NULL;
+ int res;
+
+ OSM_LOG_ENTER(p_log);
+
+ cl_spinlock_acquire(&p_domain_imp->lock);
+ if (st_delete(p_domain_imp->p_hash,
+ (void *)&p_key, (void *)&p_prev_val)) {
+ if (st_lookup(p_domain_imp->p_hash,
+ (st_data_t) p_key, (void *)&p_prev_val)) {
+ OSM_LOG(p_log, OSM_LOG_ERROR,
+ "key:%s still exists in:%s with value:%s\n",
+ p_key, p_domain_imp->file_name, p_prev_val);
+ res = 1;
+ } else {
+ free(p_key);
+ free(p_prev_val);
+ p_domain_imp->dirty = TRUE;
+ res = 0;
+ }
+ } else {
+ OSM_LOG(p_log, OSM_LOG_DEBUG,
+ "fail to find key:%s. delete failed\n", p_key);
+ res = 1;
+ }
+ cl_spinlock_release(&p_domain_imp->lock);
+
+ OSM_LOG_EXIT(p_log);
+ return res;
+}
+
+#ifdef TEST_OSMDB
+#include <stdlib.h>
+#include <math.h>
+
+int main(int argc, char **argv)
+{
+ osm_db_t db;
+ osm_log_t log;
+ osm_db_domain_t *p_dbd;
+ cl_list_t keys;
+ cl_list_iterator_t kI;
+ char *p_key;
+ char *p_val;
+ int i;
+
+ cl_list_construct(&keys);
+ cl_list_init(&keys, 10);
+
+ osm_log_init_v2(&log, TRUE, 0xff, "/var/log/osm_db_test.log", 0, FALSE);
+
+ osm_db_construct(&db);
+ if (osm_db_init(&db, &log)) {
+ printf("db init failed\n");
+ exit(1);
+ }
+
+ p_dbd = osm_db_domain_init(&db, "lid_by_guid");
+ if (!p_dbd) {
+ printf("db domain init failed\n");
+ exit(1);
+ }
+
+ if (osm_db_restore(p_dbd)) {
+ printf("failed to restore\n");
+ }
+
+ if (osm_db_keys(p_dbd, &keys)) {
+ printf("failed to get keys\n");
+ } else {
+ kI = cl_list_head(&keys);
+ while (kI != cl_list_end(&keys)) {
+ p_key = cl_list_obj(kI);
+ kI = cl_list_next(kI);
+
+ p_val = osm_db_lookup(p_dbd, p_key);
+ printf("key = %s val = %s\n", p_key, p_val);
+ }
+ }
+
+ cl_list_remove_all(&keys);
+
+ /* randomly add and remove numbers */
+ for (i = 0; i < 10; i++) {
+ int k;
+ float v;
+ int is_add;
+ char val_buf[16];
+ char key_buf[16];
+
+ k = floor(1.0 * rand() / RAND_MAX * 100);
+ v = rand();
+ sprintf(key_buf, "%u", k);
+ sprintf(val_buf, "%u", v);
+
+ is_add = (rand() < RAND_MAX / 2);
+
+ if (is_add) {
+ osm_db_update(p_dbd, key_buf, val_buf);
+ } else {
+ osm_db_delete(p_dbd, key_buf);
+ }
+ }
+ if (osm_db_keys(p_dbd, &keys)) {
+ printf("failed to get keys\n");
+ } else {
+ kI = cl_list_head(&keys);
+ while (kI != cl_list_end(&keys)) {
+ p_key = cl_list_obj(kI);
+ kI = cl_list_next(kI);
+
+ p_val = osm_db_lookup(p_dbd, p_key);
+ printf("key = %s val = %s\n", p_key, p_val);
+ }
+ }
+ if (osm_db_store(p_dbd, FALSE))
+ printf("failed to store\n");
+
+ osm_db_destroy(&db);
+ cl_list_destroy(&keys);
+}
+#endif
diff --git a/contrib/ofed/opensm/opensm/osm_db_pack.c b/contrib/ofed/opensm/opensm/osm_db_pack.c
new file mode 100644
index 0000000..59ac1d5
--- /dev/null
+++ b/contrib/ofed/opensm/opensm/osm_db_pack.c
@@ -0,0 +1,333 @@
+/*
+ * Copyright (c) 2004-2009 Voltaire, Inc. All rights reserved.
+ * Copyright (c) 2002-2006 Mellanox Technologies LTD. All rights reserved.
+ * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+#if HAVE_CONFIG_H
+# include <config.h>
+#endif /* HAVE_CONFIG_H */
+
+#include <stdlib.h>
+#include <complib/cl_debug.h>
+#include <opensm/osm_file_ids.h>
+#define FILE_ID OSM_FILE_DB_PACK_C
+#include <opensm/osm_db_pack.h>
+
+static inline void pack_guid(uint64_t guid, char *p_guid_str)
+{
+ sprintf(p_guid_str, "0x%016" PRIx64, guid);
+}
+
+static inline uint64_t unpack_guid(char *p_guid_str)
+{
+ return strtoull(p_guid_str, NULL, 0);
+}
+
+static inline void pack_lids(uint16_t min_lid, uint16_t max_lid, char *lid_str)
+{
+ sprintf(lid_str, "0x%04x 0x%04x", min_lid, max_lid);
+}
+
+static inline int unpack_lids(IN char *p_lid_str, OUT uint16_t * p_min_lid,
+ OUT uint16_t * p_max_lid)
+{
+ unsigned long tmp;
+ char *p_next;
+ char *p_num;
+ char lids_str[24];
+
+ strncpy(lids_str, p_lid_str, 23);
+ lids_str[23] = '\0';
+ p_num = strtok_r(lids_str, " \t", &p_next);
+ if (!p_num)
+ return 1;
+ tmp = strtoul(p_num, NULL, 0);
+ if (tmp >= 0xC000)
+ return 1;
+
+ *p_min_lid = (uint16_t) tmp;
+
+ p_num = strtok_r(NULL, " \t", &p_next);
+ if (!p_num)
+ return 1;
+ tmp = strtoul(p_num, NULL, 0);
+ if (tmp >= 0xC000)
+ return 1;
+
+ *p_max_lid = (uint16_t) tmp;
+
+ return 0;
+}
+
+static inline void pack_mkey(uint64_t mkey, char *p_mkey_str)
+{
+ sprintf(p_mkey_str, "0x%016" PRIx64, mkey);
+}
+
+static inline uint64_t unpack_mkey(char *p_mkey_str)
+{
+ return strtoull(p_mkey_str, NULL, 0);
+}
+
+static inline void pack_neighbor(uint64_t guid, uint8_t portnum, char *p_str)
+{
+ sprintf(p_str, "0x%016" PRIx64 ":%u", guid, portnum);
+}
+
+static inline int unpack_neighbor(char *p_str, uint64_t *guid,
+ uint8_t *portnum)
+{
+ char tmp_str[24];
+ char *p_num, *p_next;
+ unsigned long tmp_port;
+
+ strncpy(tmp_str, p_str, 23);
+ tmp_str[23] = '\0';
+ p_num = strtok_r(tmp_str, ":", &p_next);
+ if (!p_num)
+ return 1;
+ if (guid)
+ *guid = strtoull(p_num, NULL, 0);
+
+ p_num = strtok_r(NULL, ":", &p_next);
+ if (!p_num)
+ return 1;
+ if (portnum) {
+ tmp_port = strtoul(p_num, NULL, 0);
+ CL_ASSERT(tmp_port < 0x100);
+ *portnum = (uint8_t) tmp_port;
+ }
+
+ return 0;
+}
+
+int osm_db_guid2lid_guids(IN osm_db_domain_t * p_g2l,
+ OUT cl_qlist_t * p_guid_list)
+{
+ char *p_key;
+ cl_list_t keys;
+ osm_db_guid_elem_t *p_guid_elem;
+
+ cl_list_construct(&keys);
+ cl_list_init(&keys, 10);
+
+ if (osm_db_keys(p_g2l, &keys))
+ return 1;
+
+ while ((p_key = cl_list_remove_head(&keys)) != NULL) {
+ p_guid_elem =
+ (osm_db_guid_elem_t *) malloc(sizeof(osm_db_guid_elem_t));
+ CL_ASSERT(p_guid_elem != NULL);
+
+ p_guid_elem->guid = unpack_guid(p_key);
+ cl_qlist_insert_head(p_guid_list, &p_guid_elem->item);
+ }
+
+ cl_list_destroy(&keys);
+ return 0;
+}
+
+int osm_db_guid2lid_get(IN osm_db_domain_t * p_g2l, IN uint64_t guid,
+ OUT uint16_t * p_min_lid, OUT uint16_t * p_max_lid)
+{
+ char guid_str[20];
+ char *p_lid_str;
+ uint16_t min_lid, max_lid;
+
+ pack_guid(guid, guid_str);
+ p_lid_str = osm_db_lookup(p_g2l, guid_str);
+ if (!p_lid_str)
+ return 1;
+ if (unpack_lids(p_lid_str, &min_lid, &max_lid))
+ return 1;
+
+ if (p_min_lid)
+ *p_min_lid = min_lid;
+ if (p_max_lid)
+ *p_max_lid = max_lid;
+
+ return 0;
+}
+
+int osm_db_guid2lid_set(IN osm_db_domain_t * p_g2l, IN uint64_t guid,
+ IN uint16_t min_lid, IN uint16_t max_lid)
+{
+ char guid_str[20];
+ char lid_str[16];
+
+ pack_guid(guid, guid_str);
+ pack_lids(min_lid, max_lid, lid_str);
+
+ return osm_db_update(p_g2l, guid_str, lid_str);
+}
+
+int osm_db_guid2lid_delete(IN osm_db_domain_t * p_g2l, IN uint64_t guid)
+{
+ char guid_str[20];
+ pack_guid(guid, guid_str);
+ return osm_db_delete(p_g2l, guid_str);
+}
+
+int osm_db_guid2mkey_guids(IN osm_db_domain_t * p_g2m,
+ OUT cl_qlist_t * p_guid_list)
+{
+ char *p_key;
+ cl_list_t keys;
+ osm_db_guid_elem_t *p_guid_elem;
+
+ cl_list_construct(&keys);
+ cl_list_init(&keys, 10);
+
+ if (osm_db_keys(p_g2m, &keys))
+ return 1;
+
+ while ((p_key = cl_list_remove_head(&keys)) != NULL) {
+ p_guid_elem =
+ (osm_db_guid_elem_t *) malloc(sizeof(osm_db_guid_elem_t));
+ CL_ASSERT(p_guid_elem != NULL);
+
+ p_guid_elem->guid = unpack_guid(p_key);
+ cl_qlist_insert_head(p_guid_list, &p_guid_elem->item);
+ }
+
+ cl_list_destroy(&keys);
+ return 0;
+}
+
+int osm_db_guid2mkey_get(IN osm_db_domain_t * p_g2m, IN uint64_t guid,
+ OUT uint64_t * p_mkey)
+{
+ char guid_str[20];
+ char *p_mkey_str;
+
+ pack_guid(guid, guid_str);
+ p_mkey_str = osm_db_lookup(p_g2m, guid_str);
+ if (!p_mkey_str)
+ return 1;
+
+ if (p_mkey)
+ *p_mkey = unpack_mkey(p_mkey_str);
+
+ return 0;
+}
+
+int osm_db_guid2mkey_set(IN osm_db_domain_t * p_g2m, IN uint64_t guid,
+ IN uint64_t mkey)
+{
+ char guid_str[20];
+ char mkey_str[20];
+
+ pack_guid(guid, guid_str);
+ pack_mkey(mkey, mkey_str);
+
+ return osm_db_update(p_g2m, guid_str, mkey_str);
+}
+
+int osm_db_guid2mkey_delete(IN osm_db_domain_t * p_g2m, IN uint64_t guid)
+{
+ char guid_str[20];
+ pack_guid(guid, guid_str);
+ return osm_db_delete(p_g2m, guid_str);
+}
+
+int osm_db_neighbor_guids(IN osm_db_domain_t * p_neighbor,
+ OUT cl_qlist_t * p_neighbor_list)
+{
+ char *p_key;
+ cl_list_t keys;
+ osm_db_neighbor_elem_t *p_neighbor_elem;
+
+ cl_list_construct(&keys);
+ cl_list_init(&keys, 10);
+
+ if (osm_db_keys(p_neighbor, &keys))
+ return 1;
+
+ while ((p_key = cl_list_remove_head(&keys)) != NULL) {
+ p_neighbor_elem =
+ (osm_db_neighbor_elem_t *) malloc(sizeof(osm_db_neighbor_elem_t));
+ CL_ASSERT(p_neighbor_elem != NULL);
+
+ unpack_neighbor(p_key, &p_neighbor_elem->guid,
+ &p_neighbor_elem->portnum);
+ cl_qlist_insert_head(p_neighbor_list, &p_neighbor_elem->item);
+ }
+
+ cl_list_destroy(&keys);
+ return 0;
+}
+
+int osm_db_neighbor_get(IN osm_db_domain_t * p_neighbor, IN uint64_t guid1,
+ IN uint8_t portnum1, OUT uint64_t * p_guid2,
+ OUT uint8_t * p_portnum2)
+{
+ char neighbor_str[24];
+ char *p_other_str;
+ uint64_t temp_guid;
+ uint8_t temp_portnum;
+
+ pack_neighbor(guid1, portnum1, neighbor_str);
+ p_other_str = osm_db_lookup(p_neighbor, neighbor_str);
+ if (!p_other_str)
+ return 1;
+ if (unpack_neighbor(p_other_str, &temp_guid, &temp_portnum))
+ return 1;
+
+ if (p_guid2)
+ *p_guid2 = temp_guid;
+ if (p_portnum2)
+ *p_portnum2 = temp_portnum;
+
+ return 0;
+}
+
+int osm_db_neighbor_set(IN osm_db_domain_t * p_neighbor, IN uint64_t guid1,
+ IN uint8_t portnum1, IN uint64_t guid2,
+ IN uint8_t portnum2)
+{
+ char n1_str[24], n2_str[24];
+
+ pack_neighbor(guid1, portnum1, n1_str);
+ pack_neighbor(guid2, portnum2, n2_str);
+
+ return osm_db_update(p_neighbor, n1_str, n2_str);
+}
+
+int osm_db_neighbor_delete(IN osm_db_domain_t * p_neighbor, IN uint64_t guid,
+ IN uint8_t portnum)
+{
+ char n_str[24];
+
+ pack_neighbor(guid, portnum, n_str);
+ return osm_db_delete(p_neighbor, n_str);
+}
diff --git a/contrib/ofed/opensm/opensm/osm_drop_mgr.c b/contrib/ofed/opensm/opensm/osm_drop_mgr.c
new file mode 100644
index 0000000..f7ff0c1d
--- /dev/null
+++ b/contrib/ofed/opensm/opensm/osm_drop_mgr.c
@@ -0,0 +1,611 @@
+/*
+ * Copyright (c) 2004-2009 Voltaire, Inc. All rights reserved.
+ * Copyright (c) 2002-2015 Mellanox Technologies LTD. All rights reserved.
+ * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
+ * Copyright (c) 2008 Xsigo Systems Inc. All rights reserved.
+ * Copyright (c) 2013 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+/*
+ * Abstract:
+ * Implementation of osm_drop_mgr_t.
+ * This object represents the Drop Manager object.
+ * This object is part of the opensm family of objects.
+ */
+
+#if HAVE_CONFIG_H
+# include <config.h>
+#endif /* HAVE_CONFIG_H */
+
+#include <stdlib.h>
+#include <string.h>
+#include <iba/ib_types.h>
+#include <complib/cl_qmap.h>
+#include <complib/cl_passivelock.h>
+#include <complib/cl_debug.h>
+#include <complib/cl_ptr_vector.h>
+#include <opensm/osm_file_ids.h>
+#define FILE_ID OSM_FILE_DROP_MGR_C
+#include <opensm/osm_sm.h>
+#include <opensm/osm_router.h>
+#include <opensm/osm_switch.h>
+#include <opensm/osm_node.h>
+#include <opensm/osm_guid.h>
+#include <opensm/osm_helper.h>
+#include <opensm/osm_multicast.h>
+#include <opensm/osm_remote_sm.h>
+#include <opensm/osm_inform.h>
+#include <opensm/osm_ucast_mgr.h>
+
+static void drop_mgr_remove_router(osm_sm_t * sm, IN const ib_net64_t portguid)
+{
+ osm_router_t *p_rtr;
+ cl_qmap_t *p_rtr_guid_tbl;
+
+ p_rtr_guid_tbl = &sm->p_subn->rtr_guid_tbl;
+ p_rtr = (osm_router_t *) cl_qmap_remove(p_rtr_guid_tbl, portguid);
+ if (p_rtr != (osm_router_t *) cl_qmap_end(p_rtr_guid_tbl)) {
+ OSM_LOG(sm->p_log, OSM_LOG_VERBOSE,
+ "Cleaned router for port guid 0x%016" PRIx64 "\n",
+ cl_ntoh64(portguid));
+ osm_router_delete(&p_rtr);
+ }
+}
+
+static void drop_mgr_clean_physp(osm_sm_t * sm, IN osm_physp_t * p_physp)
+{
+ osm_physp_t *p_remote_physp;
+ osm_port_t *p_remote_port;
+
+ p_remote_physp = osm_physp_get_remote(p_physp);
+ if (p_remote_physp) {
+ p_remote_port = osm_get_port_by_guid(sm->p_subn,
+ p_remote_physp->port_guid);
+
+ if (p_remote_port) {
+ /* Let's check if this is a case of link that is lost
+ (both ports weren't recognized), or a "hiccup" in the
+ subnet - in which case the remote port was
+ recognized, and its state is ACTIVE.
+ If this is just a "hiccup" - force a heavy sweep in
+ the next sweep. We don't want to lose that part of
+ the subnet. */
+ if (p_remote_port->discovery_count &&
+ osm_physp_get_port_state(p_remote_physp) ==
+ IB_LINK_ACTIVE) {
+ OSM_LOG(sm->p_log, OSM_LOG_VERBOSE,
+ "Forcing new heavy sweep. Remote "
+ "port 0x%016" PRIx64 " port num: %u "
+ "was recognized in ACTIVE state\n",
+ cl_ntoh64(p_remote_physp->port_guid),
+ p_remote_physp->port_num);
+ sm->p_subn->force_heavy_sweep = TRUE;
+ }
+
+ /* If the remote node is ca or router - need to remove
+ the remote port, since it is no longer reachable.
+ This can be done if we reset the discovery count
+ of the remote port. */
+ if (!p_remote_physp->p_node->sw &&
+ p_remote_physp->port_guid != sm->p_subn->sm_port_guid) {
+ p_remote_port->discovery_count = 0;
+ OSM_LOG(sm->p_log, OSM_LOG_DEBUG,
+ "Resetting discovery count of node: "
+ "0x%016" PRIx64 " port num:%u\n",
+ cl_ntoh64(osm_node_get_node_guid
+ (p_remote_physp->p_node)),
+ p_remote_physp->port_num);
+ }
+ }
+
+ OSM_LOG(sm->p_log, OSM_LOG_VERBOSE,
+ "Unlinking local node 0x%016" PRIx64 ", port %u"
+ "\n\t\t\t\tand remote node 0x%016" PRIx64
+ ", port %u\n",
+ cl_ntoh64(osm_node_get_node_guid(p_physp->p_node)),
+ p_physp->port_num,
+ cl_ntoh64(osm_node_get_node_guid
+ (p_remote_physp->p_node)),
+ p_remote_physp->port_num);
+
+ if (sm->ucast_mgr.cache_valid)
+ osm_ucast_cache_add_link(&sm->ucast_mgr, p_physp,
+ p_remote_physp);
+
+ osm_physp_unlink(p_physp, p_remote_physp);
+
+ }
+
+ /* Make port as undiscovered */
+ p_physp->p_node->physp_discovered[p_physp->port_num] = 0;
+
+ OSM_LOG(sm->p_log, OSM_LOG_DEBUG,
+ "Clearing node 0x%016" PRIx64 " physical port number %u\n",
+ cl_ntoh64(osm_node_get_node_guid(p_physp->p_node)),
+ p_physp->port_num);
+
+ osm_physp_destroy(p_physp);
+}
+
+static void drop_mgr_remove_port(osm_sm_t * sm, IN osm_port_t * p_port)
+{
+ ib_net64_t port_guid;
+ osm_port_t *p_port_check;
+ cl_qmap_t *p_alias_guid_tbl;
+ cl_qmap_t *p_sm_guid_tbl;
+ osm_mcm_port_t *mcm_port;
+ cl_ptr_vector_t *p_port_lid_tbl;
+ uint16_t min_lid_ho;
+ uint16_t max_lid_ho;
+ uint16_t lid_ho;
+ osm_node_t *p_node;
+ osm_remote_sm_t *p_sm;
+ osm_alias_guid_t *p_alias_guid, *p_alias_guid_check;
+ osm_guidinfo_work_obj_t *wobj;
+ cl_list_item_t *item, *next_item;
+ ib_gid_t port_gid;
+ ib_mad_notice_attr_t notice;
+ ib_api_status_t status;
+
+ OSM_LOG_ENTER(sm->p_log);
+
+ port_guid = osm_port_get_guid(p_port);
+ OSM_LOG(sm->p_log, OSM_LOG_VERBOSE,
+ "Unreachable port 0x%016" PRIx64 "\n", cl_ntoh64(port_guid));
+
+ p_port_check =
+ (osm_port_t *) cl_qmap_get(&sm->p_subn->port_guid_tbl, port_guid);
+ if (p_port_check != p_port) {
+ OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR 0101: "
+ "Port 0x%016" PRIx64 " not in guid table\n",
+ cl_ntoh64(port_guid));
+ goto Exit;
+ }
+
+ /* issue a notice - trap 65 (SM_GID_OUT_OF_SERVICE_TRAP) */
+ /* details of the notice */
+ notice.generic_type = 0x80 | IB_NOTICE_TYPE_SUBN_MGMT; /* is generic subn mgt type */
+ ib_notice_set_prod_type_ho(&notice, 4); /* A class manager generator */
+ /* endport ceases to be reachable */
+ notice.g_or_v.generic.trap_num = CL_HTON16(SM_GID_OUT_OF_SERVICE_TRAP); /* 65 */
+ /* The sm_base_lid is saved in network order already. */
+ notice.issuer_lid = sm->p_subn->sm_base_lid;
+ /* following C14-72.1.2 and table 119 p725 */
+ /* we need to provide the GID */
+ port_gid.unicast.prefix = sm->p_subn->opt.subnet_prefix;
+ port_gid.unicast.interface_id = port_guid;
+ memcpy(&(notice.data_details.ntc_64_67.gid),
+ &(port_gid), sizeof(ib_gid_t));
+
+ /* According to page 653 - the issuer gid in this case of trap
+ is the SM gid, since the SM is the initiator of this trap. */
+ notice.issuer_gid.unicast.prefix = sm->p_subn->opt.subnet_prefix;
+ notice.issuer_gid.unicast.interface_id = sm->p_subn->sm_port_guid;
+
+ status = osm_report_notice(sm->p_log, sm->p_subn, &notice);
+ if (status != IB_SUCCESS) {
+ OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR 0103: "
+ "Error sending trap reports (%s)\n",
+ ib_get_err_str(status));
+ }
+
+ next_item = cl_qlist_head(&sm->p_subn->alias_guid_list);
+ while (next_item != cl_qlist_end(&sm->p_subn->alias_guid_list)) {
+ item = next_item;
+ next_item = cl_qlist_next(item);
+ wobj = cl_item_obj(item, wobj, list_item);
+ if (wobj->p_port == p_port) {
+ cl_qlist_remove_item(&sm->p_subn->alias_guid_list,
+ &wobj->list_item);
+ osm_guid_work_obj_delete(wobj);
+ }
+ }
+
+ while (!cl_is_qlist_empty(&p_port->mcm_list)) {
+ mcm_port = cl_item_obj(cl_qlist_head(&p_port->mcm_list),
+ mcm_port, list_item);
+ osm_mgrp_delete_port(sm->p_subn, sm->p_log, mcm_port->mgrp,
+ p_port);
+ }
+
+ p_alias_guid_tbl = &sm->p_subn->alias_port_guid_tbl;
+ p_alias_guid_check = (osm_alias_guid_t *) cl_qmap_head(p_alias_guid_tbl);
+ while (p_alias_guid_check != (osm_alias_guid_t *) cl_qmap_end(p_alias_guid_tbl)) {
+ if (p_alias_guid_check->p_base_port == p_port)
+ p_alias_guid = p_alias_guid_check;
+ else
+ p_alias_guid = NULL;
+ p_alias_guid_check = (osm_alias_guid_t *) cl_qmap_next(&p_alias_guid_check->map_item);
+ if (p_alias_guid) {
+ cl_qmap_remove_item(p_alias_guid_tbl,
+ &p_alias_guid->map_item);
+ osm_alias_guid_delete(&p_alias_guid);
+ }
+ }
+
+ cl_qmap_remove(&sm->p_subn->port_guid_tbl, port_guid);
+
+ p_sm_guid_tbl = &sm->p_subn->sm_guid_tbl;
+ p_sm = (osm_remote_sm_t *) cl_qmap_remove(p_sm_guid_tbl, port_guid);
+ if (p_sm != (osm_remote_sm_t *) cl_qmap_end(p_sm_guid_tbl)) {
+ /* need to remove this item */
+ OSM_LOG(sm->p_log, OSM_LOG_VERBOSE,
+ "Cleaned SM for port guid 0x%016" PRIx64 "\n",
+ cl_ntoh64(port_guid));
+ free(p_sm);
+ }
+
+ drop_mgr_remove_router(sm, port_guid);
+
+ osm_port_get_lid_range_ho(p_port, &min_lid_ho, &max_lid_ho);
+
+ OSM_LOG(sm->p_log, OSM_LOG_VERBOSE,
+ "Clearing abandoned LID range [%u,%u]\n",
+ min_lid_ho, max_lid_ho);
+
+ p_port_lid_tbl = &sm->p_subn->port_lid_tbl;
+ for (lid_ho = min_lid_ho; lid_ho <= max_lid_ho; lid_ho++)
+ cl_ptr_vector_set(p_port_lid_tbl, lid_ho, NULL);
+
+ drop_mgr_clean_physp(sm, p_port->p_physp);
+
+ /* Delete event forwarding subscriptions */
+ if (sm->p_subn->opt.drop_event_subscriptions) {
+ if (osm_infr_remove_subscriptions(sm->p_subn, sm->p_log, port_guid)
+ == CL_SUCCESS)
+ OSM_LOG(sm->p_log, OSM_LOG_DEBUG,
+ "Removed event subscriptions for port 0x%016" PRIx64 "\n",
+ cl_ntoh64(port_guid));
+ }
+
+ /* initialize the p_node - may need to get node_desc later */
+ p_node = p_port->p_node;
+
+ osm_port_delete(&p_port);
+
+ OSM_LOG(sm->p_log, OSM_LOG_INFO,
+ "Removed port with GUID:0x%016" PRIx64
+ " LID range [%u, %u] of node:%s\n",
+ cl_ntoh64(port_gid.unicast.interface_id),
+ min_lid_ho, max_lid_ho,
+ p_node ? p_node->print_desc : "UNKNOWN");
+
+Exit:
+ OSM_LOG_EXIT(sm->p_log);
+}
+
+static void drop_mgr_remove_switch(osm_sm_t * sm, IN osm_node_t * p_node)
+{
+ osm_switch_t *p_sw;
+ cl_qmap_t *p_sw_guid_tbl;
+ ib_net64_t node_guid;
+
+ OSM_LOG_ENTER(sm->p_log);
+
+ node_guid = osm_node_get_node_guid(p_node);
+ p_sw_guid_tbl = &sm->p_subn->sw_guid_tbl;
+
+ p_sw = (osm_switch_t *) cl_qmap_remove(p_sw_guid_tbl, node_guid);
+ if (p_sw == (osm_switch_t *) cl_qmap_end(p_sw_guid_tbl)) {
+ OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR 0102: "
+ "Node 0x%016" PRIx64 " not in switch table\n",
+ cl_ntoh64(osm_node_get_node_guid(p_node)));
+ } else {
+ p_node->sw = NULL;
+ osm_switch_delete(&p_sw);
+ }
+
+ OSM_LOG_EXIT(sm->p_log);
+}
+
+static boolean_t drop_mgr_process_node(osm_sm_t * sm, IN osm_node_t * p_node)
+{
+ osm_physp_t *p_physp;
+ osm_port_t *p_port;
+ osm_node_t *p_node_check;
+ uint32_t port_num;
+ uint32_t max_ports;
+ ib_net64_t port_guid;
+ boolean_t return_val = FALSE;
+
+ OSM_LOG_ENTER(sm->p_log);
+
+ OSM_LOG(sm->p_log, OSM_LOG_VERBOSE,
+ "Unreachable node 0x%016" PRIx64 "\n",
+ cl_ntoh64(osm_node_get_node_guid(p_node)));
+
+ if (sm->ucast_mgr.cache_valid)
+ osm_ucast_cache_add_node(&sm->ucast_mgr, p_node);
+
+ /*
+ Delete all the logical and physical port objects
+ associated with this node.
+ */
+ max_ports = osm_node_get_num_physp(p_node);
+ for (port_num = 0; port_num < max_ports; port_num++) {
+ p_physp = osm_node_get_physp_ptr(p_node, port_num);
+ if (p_physp) {
+ port_guid = osm_physp_get_port_guid(p_physp);
+
+ p_port = osm_get_port_by_guid(sm->p_subn, port_guid);
+
+ if (p_port)
+ drop_mgr_remove_port(sm, p_port);
+ else
+ drop_mgr_clean_physp(sm, p_physp);
+ }
+ }
+
+ return_val = TRUE;
+
+ if (p_node->sw)
+ drop_mgr_remove_switch(sm, p_node);
+
+ p_node_check =
+ (osm_node_t *) cl_qmap_remove(&sm->p_subn->node_guid_tbl,
+ osm_node_get_node_guid(p_node));
+ if (p_node_check != p_node) {
+ OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR 0105: "
+ "Node 0x%016" PRIx64 " not in guid table\n",
+ cl_ntoh64(osm_node_get_node_guid(p_node)));
+ }
+
+ /* free memory allocated to node */
+ osm_node_delete(&p_node);
+
+ OSM_LOG_EXIT(sm->p_log);
+ return return_val;
+}
+
+static void drop_mgr_check_switch_node(osm_sm_t * sm, IN osm_node_t * p_node)
+{
+ ib_net64_t node_guid;
+ osm_physp_t *p_physp, *p_remote_physp;
+ osm_node_t *p_remote_node;
+ osm_port_t *p_port;
+ ib_net64_t port_guid;
+ uint8_t port_num, remote_port_num;
+
+ OSM_LOG_ENTER(sm->p_log);
+
+ node_guid = osm_node_get_node_guid(p_node);
+
+ /* Make sure we have a switch object for this node */
+ if (!p_node->sw) {
+ /* We do not have switch info for this node */
+ OSM_LOG(sm->p_log, OSM_LOG_VERBOSE,
+ "Node 0x%016" PRIx64 " no switch in table\n",
+ cl_ntoh64(node_guid));
+
+ drop_mgr_process_node(sm, p_node);
+ goto Exit;
+ }
+
+ /* Make sure we have a port object for port zero */
+ p_physp = osm_node_get_physp_ptr(p_node, 0);
+ if (!p_physp) {
+ OSM_LOG(sm->p_log, OSM_LOG_VERBOSE,
+ "Node 0x%016" PRIx64 " no valid physical port 0\n",
+ cl_ntoh64(node_guid));
+
+ drop_mgr_process_node(sm, p_node);
+ goto Exit;
+ }
+
+ port_guid = osm_physp_get_port_guid(p_physp);
+
+ p_port = osm_get_port_by_guid(sm->p_subn, port_guid);
+
+ if (!p_port) {
+ OSM_LOG(sm->p_log, OSM_LOG_VERBOSE,
+ "Node 0x%016" PRIx64 " has no port object\n",
+ cl_ntoh64(node_guid));
+
+ drop_mgr_process_node(sm, p_node);
+ goto Exit;
+ }
+
+ if (!p_node->physp_discovered[0]) {
+ OSM_LOG(sm->p_log, OSM_LOG_VERBOSE,
+ "Node 0x%016" PRIx64 " port has discovery count zero\n",
+ cl_ntoh64(node_guid));
+
+ drop_mgr_process_node(sm, p_node);
+ goto Exit;
+ }
+
+ /*
+ * Unlink all ports that havn't been discovered during the last sweep.
+ * Optimization: Skip the check if discovered all the ports of the switch.
+ */
+ if (p_port->discovery_count < p_node->physp_tbl_size) {
+ for (port_num = 1; port_num < p_node->physp_tbl_size; port_num++) {
+ if (!p_node->physp_discovered[port_num]) {
+ p_physp = osm_node_get_physp_ptr(p_node, port_num);
+ if (!p_physp)
+ continue;
+ p_remote_physp = osm_physp_get_remote(p_physp);
+ if (!p_remote_physp)
+ continue;
+
+ p_remote_node =
+ osm_physp_get_node_ptr(p_remote_physp);
+ remote_port_num =
+ osm_physp_get_port_num(p_remote_physp);
+
+ OSM_LOG(sm->p_log, OSM_LOG_VERBOSE,
+ "Unlinking local node 0x%" PRIx64
+ ", port %u"
+ "\n\t\t\t\tand remote node 0x%" PRIx64
+ ", port %u due to missing PortInfo\n",
+ cl_ntoh64(osm_node_get_node_guid
+ (p_node)), port_num,
+ cl_ntoh64(osm_node_get_node_guid
+ (p_remote_node)),
+ remote_port_num);
+
+ if (sm->ucast_mgr.cache_valid)
+ osm_ucast_cache_add_link(&sm->ucast_mgr,
+ p_physp,
+ p_remote_physp);
+
+ osm_node_unlink(p_node, (uint8_t) port_num,
+ p_remote_node,
+ (uint8_t) remote_port_num);
+ }
+ }
+ }
+Exit:
+ OSM_LOG_EXIT(sm->p_log);
+ return;
+}
+
+void osm_drop_mgr_process(osm_sm_t * sm)
+{
+ cl_qmap_t *p_node_guid_tbl, *p_port_guid_tbl;
+ osm_port_t *p_port, *p_next_port;
+ osm_node_t *p_node, *p_next_node;
+ int max_ports, port_num;
+ osm_physp_t *p_physp;
+ ib_net64_t port_guid;
+
+ CL_ASSERT(sm);
+
+ OSM_LOG_ENTER(sm->p_log);
+
+ p_node_guid_tbl = &sm->p_subn->node_guid_tbl;
+ p_port_guid_tbl = &sm->p_subn->port_guid_tbl;
+
+ CL_PLOCK_EXCL_ACQUIRE(sm->p_lock);
+
+ p_next_node = (osm_node_t *) cl_qmap_head(p_node_guid_tbl);
+ while (p_next_node != (osm_node_t *) cl_qmap_end(p_node_guid_tbl)) {
+ p_node = p_next_node;
+ p_next_node =
+ (osm_node_t *) cl_qmap_next(&p_next_node->map_item);
+
+ CL_ASSERT(cl_qmap_key(&p_node->map_item) ==
+ osm_node_get_node_guid(p_node));
+
+ OSM_LOG(sm->p_log, OSM_LOG_DEBUG,
+ "Checking node 0x%016" PRIx64 "\n",
+ cl_ntoh64(osm_node_get_node_guid(p_node)));
+
+ /*
+ Check if this node was discovered during the last sweep.
+ If not, it is unreachable in the current subnet, and
+ should therefore be removed from the subnet object.
+ */
+ if (p_node->discovery_count == 0)
+ drop_mgr_process_node(sm, p_node);
+ else {
+ /*
+ * We want to preserve the configured pkey indexes,
+ * so if we don't receive GetResp P_KeyTable for some block,
+ * do the following:
+ * 1. Drop node if the node is sw and got timeout for port 0.
+ * 2. Drop node if node is HCA/RTR.
+ * 3. Drop only physp if got timeout for sw when the port isn't 0.
+ * We'll set error during initialization in order to
+ * cause an immediate heavy sweep and try to get the
+ * configured P_KeyTable again.
+ */
+ if (osm_node_get_type(p_node) == IB_NODE_TYPE_SWITCH)
+ port_num = 0;
+ else
+ port_num = 1;
+ max_ports = osm_node_get_num_physp(p_node);
+ for (; port_num < max_ports; port_num++) {
+ p_physp = osm_node_get_physp_ptr(p_node, port_num);
+ if (!p_physp || p_physp->pkeys.rcv_blocks_cnt == 0)
+ continue;
+ p_physp->pkeys.rcv_blocks_cnt = 0;
+ p_physp->need_update = 2;
+ sm->p_subn->subnet_initialization_error = TRUE;
+ port_guid = osm_physp_get_port_guid(p_physp);
+ p_port = osm_get_port_by_guid(sm->p_subn, port_guid);
+ CL_ASSERT(p_port);
+ if (p_node->physp_discovered[port_num]) {
+ p_node->physp_discovered[port_num] = 0;
+ p_port->discovery_count--;
+ }
+ }
+ }
+ }
+
+ /*
+ Go over all the nodes. If the node is a switch - make sure
+ there is also a switch record for it, and a portInfo record for
+ port zero of of the node.
+ If not - this means that there was some error in getting the data
+ of this node. Drop the node.
+ */
+ p_next_node = (osm_node_t *) cl_qmap_head(p_node_guid_tbl);
+ while (p_next_node != (osm_node_t *) cl_qmap_end(p_node_guid_tbl)) {
+ p_node = p_next_node;
+ p_next_node =
+ (osm_node_t *) cl_qmap_next(&p_next_node->map_item);
+
+ OSM_LOG(sm->p_log, OSM_LOG_DEBUG,
+ "Checking full discovery of node 0x%016" PRIx64 "\n",
+ cl_ntoh64(osm_node_get_node_guid(p_node)));
+
+ if (osm_node_get_type(p_node) != IB_NODE_TYPE_SWITCH)
+ continue;
+
+ /* We are handling a switch node */
+ drop_mgr_check_switch_node(sm, p_node);
+ }
+
+ p_next_port = (osm_port_t *) cl_qmap_head(p_port_guid_tbl);
+ while (p_next_port != (osm_port_t *) cl_qmap_end(p_port_guid_tbl)) {
+ p_port = p_next_port;
+ p_next_port =
+ (osm_port_t *) cl_qmap_next(&p_next_port->map_item);
+
+ CL_ASSERT(cl_qmap_key(&p_port->map_item) ==
+ osm_port_get_guid(p_port));
+
+ OSM_LOG(sm->p_log, OSM_LOG_DEBUG,
+ "Checking port 0x%016" PRIx64 "\n",
+ cl_ntoh64(osm_port_get_guid(p_port)));
+
+ /*
+ If the port is unreachable, remove it from the guid table.
+ */
+ if (p_port->discovery_count == 0)
+ drop_mgr_remove_port(sm, p_port);
+ }
+
+ CL_PLOCK_RELEASE(sm->p_lock);
+ OSM_LOG_EXIT(sm->p_log);
+}
diff --git a/contrib/ofed/opensm/opensm/osm_dump.c b/contrib/ofed/opensm/opensm/osm_dump.c
new file mode 100644
index 0000000..82136c5
--- /dev/null
+++ b/contrib/ofed/opensm/opensm/osm_dump.c
@@ -0,0 +1,750 @@
+/*
+ * Copyright (c) 2009 Sun Microsystems, Inc. All rights reserved.
+ * Copyright (c) 2004-2009 Voltaire, Inc. All rights reserved.
+ * Copyright (c) 2002-2015 Mellanox Technologies LTD. All rights reserved.
+ * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+/*
+ * Abstract:
+ * Various OpenSM dumpers
+ */
+
+#if HAVE_CONFIG_H
+# include <config.h>
+#endif /* HAVE_CONFIG_H */
+
+#include <unistd.h>
+#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
+#include <iba/ib_types.h>
+#include <complib/cl_qmap.h>
+#include <complib/cl_debug.h>
+#include <opensm/osm_file_ids.h>
+#define FILE_ID OSM_FILE_DUMP_C
+#include <opensm/osm_opensm.h>
+#include <opensm/osm_log.h>
+#include <opensm/osm_node.h>
+#include <opensm/osm_switch.h>
+#include <opensm/osm_helper.h>
+#include <opensm/osm_msgdef.h>
+#include <opensm/osm_opensm.h>
+
+static void dump_ucast_path_distribution(cl_map_item_t * item, FILE * file,
+ void *cxt)
+{
+ osm_node_t *p_node;
+ osm_node_t *p_remote_node;
+ uint8_t i;
+ uint8_t num_ports;
+ uint32_t num_paths;
+ ib_net64_t remote_guid_ho;
+ osm_switch_t *p_sw = (osm_switch_t *) item;
+
+ p_node = p_sw->p_node;
+ num_ports = p_sw->num_ports;
+
+ fprintf(file, "dump_ucast_path_distribution: Switch 0x%" PRIx64 "\n"
+ "Port : Path Count Through Port",
+ cl_ntoh64(osm_node_get_node_guid(p_node)));
+
+ for (i = 0; i < num_ports; i++) {
+ num_paths = osm_switch_path_count_get(p_sw, i);
+ fprintf(file, "\n %03u : %u", i, num_paths);
+ if (i == 0) {
+ fprintf(file, " (switch management port)");
+ continue;
+ }
+
+ p_remote_node = osm_node_get_remote_node(p_node, i, NULL);
+ if (p_remote_node == NULL)
+ continue;
+
+ remote_guid_ho =
+ cl_ntoh64(osm_node_get_node_guid(p_remote_node));
+
+ switch (osm_node_get_type(p_remote_node)) {
+ case IB_NODE_TYPE_SWITCH:
+ fprintf(file, " (link to switch");
+ break;
+ case IB_NODE_TYPE_ROUTER:
+ fprintf(file, " (link to router");
+ break;
+ case IB_NODE_TYPE_CA:
+ fprintf(file, " (link to CA");
+ break;
+ default:
+ fprintf(file, " (link to unknown node type");
+ break;
+ }
+
+ fprintf(file, " 0x%" PRIx64 ")", remote_guid_ho);
+ }
+
+ fprintf(file, "\n");
+}
+
+static void dump_ucast_routes(cl_map_item_t * item, FILE * file, void *cxt)
+{
+ const osm_node_t *p_node;
+ osm_port_t *p_port;
+ uint8_t port_num;
+ uint8_t num_hops;
+ uint8_t best_hops;
+ uint8_t best_port;
+ uint16_t max_lid_ho;
+ uint16_t lid_ho, base_lid;
+ boolean_t direct_route_exists = FALSE;
+ boolean_t dor;
+ osm_switch_t *p_sw = (osm_switch_t *) item;
+ osm_opensm_t *p_osm = cxt;
+
+ p_node = p_sw->p_node;
+
+ max_lid_ho = p_sw->max_lid_ho;
+
+ fprintf(file, "dump_ucast_routes: "
+ "Switch 0x%016" PRIx64 "\nLID : Port : Hops : Optimal\n",
+ cl_ntoh64(osm_node_get_node_guid(p_node)));
+
+ dor = (p_osm->routing_engine_used &&
+ p_osm->routing_engine_used->type == OSM_ROUTING_ENGINE_TYPE_DOR);
+
+ for (lid_ho = 1; lid_ho <= max_lid_ho; lid_ho++) {
+ fprintf(file, "0x%04X : ", lid_ho);
+
+ p_port = osm_get_port_by_lid_ho(&p_osm->subn, lid_ho);
+ if (!p_port) {
+ fprintf(file, "UNREACHABLE\n");
+ continue;
+ }
+
+ port_num = osm_switch_get_port_by_lid(p_sw, lid_ho,
+ OSM_NEW_LFT);
+ if (port_num == OSM_NO_PATH) {
+ /*
+ This may occur if there are 'holes' in the existing
+ LID assignments. Running SM with --reassign_lids
+ will reassign and compress the LID range. The
+ subnet should work fine either way.
+ */
+ fprintf(file, "UNREACHABLE\n");
+ continue;
+ }
+ /*
+ Switches can lie about which port routes a given
+ lid due to a recent reconfiguration of the subnet.
+ Therefore, ensure that the hop count is better than
+ OSM_NO_PATH.
+ */
+ if (p_port->p_node->sw) {
+ /* Target LID is switch.
+ Get its base lid and check hop count for this base LID only. */
+ base_lid = osm_node_get_base_lid(p_port->p_node, 0);
+ base_lid = cl_ntoh16(base_lid);
+ num_hops =
+ osm_switch_get_hop_count(p_sw, base_lid, port_num);
+ } else {
+ /* Target LID is not switch (CA or router).
+ Check if we have route to this target from current switch. */
+ num_hops =
+ osm_switch_get_hop_count(p_sw, lid_ho, port_num);
+ if (num_hops != OSM_NO_PATH) {
+ direct_route_exists = TRUE;
+ base_lid = lid_ho;
+ } else {
+ osm_physp_t *p_physp = p_port->p_physp;
+
+ if (!p_physp || !p_physp->p_remote_physp ||
+ !p_physp->p_remote_physp->p_node->sw)
+ num_hops = OSM_NO_PATH;
+ else {
+ base_lid =
+ osm_node_get_base_lid(p_physp->
+ p_remote_physp->
+ p_node, 0);
+ base_lid = cl_ntoh16(base_lid);
+ num_hops =
+ p_physp->p_remote_physp->p_node->
+ sw ==
+ p_sw ? 0 :
+ osm_switch_get_hop_count(p_sw,
+ base_lid,
+ port_num);
+ }
+ }
+ }
+
+ if (num_hops == OSM_NO_PATH) {
+ fprintf(file, "%03u : HOPS UNKNOWN\n", port_num);
+ continue;
+ }
+
+ best_hops = osm_switch_get_least_hops(p_sw, base_lid);
+ if (!p_port->p_node->sw && !direct_route_exists) {
+ best_hops++;
+ num_hops++;
+ }
+
+ fprintf(file, "%03u : %02u : ", port_num, num_hops);
+
+ if (best_hops == num_hops)
+ fprintf(file, "yes");
+ else {
+ /* No LMC Optimization */
+ best_port = osm_switch_recommend_path(p_sw, p_port,
+ lid_ho, 1, TRUE,
+ FALSE, dor,
+ p_osm->subn.opt.port_shifting,
+ p_osm->subn.opt.scatter_ports,
+ OSM_NEW_LFT);
+ fprintf(file, "No %u hop path possible via port %u!",
+ best_hops, best_port);
+ }
+
+ fprintf(file, "\n");
+ }
+}
+
+static void dump_mcast_routes(cl_map_item_t * item, FILE * file, void *cxt)
+{
+ osm_switch_t *p_sw = (osm_switch_t *) item;
+ osm_mcast_tbl_t *p_tbl;
+ int16_t mlid_ho = 0;
+ int16_t mlid_start_ho;
+ uint8_t position = 0;
+ int16_t block_num = 0;
+ boolean_t first_mlid;
+ boolean_t first_port;
+ const osm_node_t *p_node;
+ uint16_t i, j;
+ uint16_t mask_entry;
+ char sw_hdr[256];
+ char mlid_hdr[32];
+
+ p_node = p_sw->p_node;
+
+ p_tbl = osm_switch_get_mcast_tbl_ptr(p_sw);
+
+ sprintf(sw_hdr, "\nSwitch 0x%016" PRIx64 "\nLID : Out Port(s)\n",
+ cl_ntoh64(osm_node_get_node_guid(p_node)));
+ first_mlid = TRUE;
+ while (block_num <= p_tbl->max_block_in_use) {
+ mlid_start_ho = (uint16_t) (block_num * IB_MCAST_BLOCK_SIZE);
+ for (i = 0; i < IB_MCAST_BLOCK_SIZE; i++) {
+ mlid_ho = mlid_start_ho + i;
+ position = 0;
+ first_port = TRUE;
+ sprintf(mlid_hdr, "0x%04X :",
+ mlid_ho + IB_LID_MCAST_START_HO);
+ while (position <= p_tbl->max_position) {
+ mask_entry =
+ cl_ntoh16((*p_tbl->
+ p_mask_tbl)[mlid_ho][position]);
+ if (mask_entry == 0) {
+ position++;
+ continue;
+ }
+ for (j = 0; j < 16; j++) {
+ if ((1 << j) & mask_entry) {
+ if (first_mlid) {
+ fprintf(file, "%s",
+ sw_hdr);
+ first_mlid = FALSE;
+ }
+ if (first_port) {
+ fprintf(file, "%s",
+ mlid_hdr);
+ first_port = FALSE;
+ }
+ fprintf(file, " 0x%03X ",
+ j + (position * 16));
+ }
+ }
+ position++;
+ }
+ if (first_port == FALSE)
+ fprintf(file, "\n");
+ }
+ block_num++;
+ }
+}
+
+static void dump_lid_matrix(cl_map_item_t * item, FILE * file, void *cxt)
+{
+ osm_switch_t *p_sw = (osm_switch_t *) item;
+ osm_opensm_t *p_osm = cxt;
+ osm_node_t *p_node = p_sw->p_node;
+ unsigned max_lid = p_sw->max_lid_ho;
+ unsigned max_port = p_sw->num_ports;
+ uint16_t lid;
+ uint8_t port;
+
+ fprintf(file, "Switch: guid 0x%016" PRIx64 "\n",
+ cl_ntoh64(osm_node_get_node_guid(p_node)));
+ for (lid = 1; lid <= max_lid; lid++) {
+ osm_port_t *p_port;
+ if (osm_switch_get_least_hops(p_sw, lid) == OSM_NO_PATH)
+ continue;
+ fprintf(file, "0x%04x:", lid);
+ for (port = 0; port < max_port; port++)
+ fprintf(file, " %02x",
+ osm_switch_get_hop_count(p_sw, lid, port));
+ p_port = osm_get_port_by_lid_ho(&p_osm->subn, lid);
+ if (p_port)
+ fprintf(file, " # portguid 0x%016" PRIx64,
+ cl_ntoh64(osm_port_get_guid(p_port)));
+ fprintf(file, "\n");
+ }
+}
+
+static void dump_ucast_lfts(cl_map_item_t * item, FILE * file, void *cxt)
+{
+ osm_switch_t *p_sw = (osm_switch_t *) item;
+ osm_opensm_t *p_osm = cxt;
+ osm_node_t *p_node = p_sw->p_node;
+ unsigned max_lid = p_sw->max_lid_ho;
+ unsigned max_port = p_sw->num_ports;
+ uint16_t lid;
+ uint8_t port;
+
+ fprintf(file, "Unicast lids [0-%u] of switch Lid %u guid 0x%016"
+ PRIx64 " (\'%s\'):\n",
+ max_lid, cl_ntoh16(osm_node_get_base_lid(p_node, 0)),
+ cl_ntoh64(osm_node_get_node_guid(p_node)), p_node->print_desc);
+ for (lid = 0; lid <= max_lid; lid++) {
+ osm_port_t *p_port;
+ port = osm_switch_get_port_by_lid(p_sw, lid, OSM_NEW_LFT);
+
+ if (port >= max_port)
+ continue;
+
+ fprintf(file, "0x%04x %03u # ", lid, port);
+
+ p_port = osm_get_port_by_lid_ho(&p_osm->subn, lid);
+ if (p_port) {
+ p_node = p_port->p_node;
+ fprintf(file, "%s portguid 0x%016" PRIx64 ": \'%s\'",
+ ib_get_node_type_str(osm_node_get_type(p_node)),
+ cl_ntoh64(osm_port_get_guid(p_port)),
+ p_node->print_desc);
+ } else
+ fprintf(file, "unknown node and type");
+ fprintf(file, "\n");
+ }
+ fprintf(file, "%u lids dumped\n", max_lid);
+}
+
+static void dump_topology_node(cl_map_item_t * item, FILE * file, void *cxt)
+{
+ osm_node_t *p_node = (osm_node_t *) item;
+ uint32_t cPort;
+ osm_node_t *p_nbnode;
+ osm_physp_t *p_physp, *p_default_physp, *p_rphysp;
+ uint8_t link_speed_act;
+ const char *link_speed_act_str, *link_width_act_str;
+
+ if (!p_node->node_info.num_ports)
+ return;
+
+ for (cPort = 1; cPort < osm_node_get_num_physp(p_node); cPort++) {
+ uint8_t port_state;
+
+ p_physp = osm_node_get_physp_ptr(p_node, cPort);
+ if (!p_physp)
+ continue;
+
+ p_rphysp = p_physp->p_remote_physp;
+ if (!p_rphysp)
+ continue;
+
+ CL_ASSERT(cPort == p_physp->port_num);
+
+ if (p_node->node_info.node_type == IB_NODE_TYPE_SWITCH)
+ p_default_physp = osm_node_get_physp_ptr(p_node, 0);
+ else
+ p_default_physp = p_physp;
+
+ fprintf(file, "{ %s%s Ports:%02X SystemGUID:%016" PRIx64
+ " NodeGUID:%016" PRIx64 " PortGUID:%016" PRIx64
+ " VenID:%06X DevID:%04X Rev:%08X {%s} LID:%04X PN:%02X } ",
+ p_node->node_info.node_type == IB_NODE_TYPE_SWITCH ?
+ "SW" : p_node->node_info.node_type ==
+ IB_NODE_TYPE_CA ? "CA" : p_node->node_info.node_type ==
+ IB_NODE_TYPE_ROUTER ? "Rt" : "**",
+ p_default_physp->port_info.base_lid ==
+ p_default_physp->port_info.
+ master_sm_base_lid ? "-SM" : "",
+ p_node->node_info.num_ports,
+ cl_ntoh64(p_node->node_info.sys_guid),
+ cl_ntoh64(p_node->node_info.node_guid),
+ cl_ntoh64(p_physp->port_guid),
+ cl_ntoh32(ib_node_info_get_vendor_id
+ (&p_node->node_info)),
+ cl_ntoh16(p_node->node_info.device_id),
+ cl_ntoh32(p_node->node_info.revision),
+ p_node->print_desc,
+ cl_ntoh16(p_default_physp->port_info.base_lid), cPort);
+
+ p_nbnode = p_rphysp->p_node;
+
+ if (p_nbnode->node_info.node_type == IB_NODE_TYPE_SWITCH)
+ p_default_physp = osm_node_get_physp_ptr(p_nbnode, 0);
+ else
+ p_default_physp = p_rphysp;
+
+ fprintf(file, "{ %s%s Ports:%02X SystemGUID:%016" PRIx64
+ " NodeGUID:%016" PRIx64 " PortGUID:%016" PRIx64
+ " VenID:%08X DevID:%04X Rev:%08X {%s} LID:%04X PN:%02X } ",
+ p_nbnode->node_info.node_type == IB_NODE_TYPE_SWITCH ?
+ "SW" : p_nbnode->node_info.node_type ==
+ IB_NODE_TYPE_CA ? "CA" :
+ p_nbnode->node_info.node_type == IB_NODE_TYPE_ROUTER ?
+ "Rt" : "**",
+ p_default_physp->port_info.base_lid ==
+ p_default_physp->port_info.
+ master_sm_base_lid ? "-SM" : "",
+ p_nbnode->node_info.num_ports,
+ cl_ntoh64(p_nbnode->node_info.sys_guid),
+ cl_ntoh64(p_nbnode->node_info.node_guid),
+ cl_ntoh64(p_rphysp->port_guid),
+ cl_ntoh32(ib_node_info_get_vendor_id
+ (&p_nbnode->node_info)),
+ cl_ntoh32(p_nbnode->node_info.device_id),
+ cl_ntoh32(p_nbnode->node_info.revision),
+ p_nbnode->print_desc,
+ cl_ntoh16(p_default_physp->port_info.base_lid),
+ p_rphysp->port_num);
+
+ port_state = ib_port_info_get_port_state(&p_physp->port_info);
+ link_speed_act =
+ ib_port_info_get_link_speed_active(&p_physp->port_info);
+ if (link_speed_act == IB_LINK_SPEED_ACTIVE_2_5)
+ link_speed_act_str = "2.5";
+ else if (link_speed_act == IB_LINK_SPEED_ACTIVE_5)
+ link_speed_act_str = "5";
+ else if (link_speed_act == IB_LINK_SPEED_ACTIVE_10)
+ link_speed_act_str = "10";
+ else
+ link_speed_act_str = "??";
+
+ if (p_physp->ext_port_info.link_speed_active & FDR10)
+ link_speed_act_str = "FDR10";
+
+ if (p_default_physp->port_info.capability_mask & IB_PORT_CAP_HAS_EXT_SPEEDS) {
+ link_speed_act =
+ ib_port_info_get_link_speed_ext_active(&p_physp->port_info);
+ if (link_speed_act == IB_LINK_SPEED_EXT_ACTIVE_14)
+ link_speed_act_str = "14";
+ else if (link_speed_act == IB_LINK_SPEED_EXT_ACTIVE_25)
+ link_speed_act_str = "25";
+ else if (link_speed_act != IB_LINK_SPEED_EXT_ACTIVE_NONE)
+ link_speed_act_str = "??";
+ }
+
+ if (p_physp->port_info.link_width_active == 1)
+ link_width_act_str = "1x";
+ else if (p_physp->port_info.link_width_active == 2)
+ link_width_act_str = "4x";
+ else if (p_physp->port_info.link_width_active == 4)
+ link_width_act_str = "8x";
+ else if (p_physp->port_info.link_width_active == 8)
+ link_width_act_str = "12x";
+ else link_width_act_str = "??";
+
+ if (p_default_physp->port_info.capability_mask2 &
+ IB_PORT_CAP2_IS_LINK_WIDTH_2X_SUPPORTED) {
+ if (p_physp->port_info.link_width_active == 16)
+ link_width_act_str = "2x";
+ }
+
+ fprintf(file, "PHY=%s LOG=%s SPD=%s\n",
+ link_width_act_str,
+ port_state == IB_LINK_ACTIVE ? "ACT" :
+ port_state == IB_LINK_ARMED ? "ARM" :
+ port_state == IB_LINK_INIT ? "INI" : "DWN",
+ link_speed_act_str);
+ }
+}
+
+static void dump_sl2vl_tbl(cl_map_item_t * item, FILE * file, void *cxt)
+{
+ osm_port_t *p_port = (osm_port_t *) item;
+ osm_node_t *p_node = p_port->p_node;
+ uint32_t in_port, out_port,
+ num_ports = p_node->node_info.num_ports;
+ ib_net16_t base_lid = osm_port_get_base_lid(p_port);
+ osm_physp_t *p_physp;
+ ib_slvl_table_t *p_tbl;
+ int i, n;
+ char buf[1024];
+ const char * header_line = "#in out : 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15";
+ const char * separator_line = "#--------------------------------------------------------";
+
+ if (!num_ports)
+ return;
+
+ fprintf(file, "%s 0x%016" PRIx64 ", base LID %d, "
+ "\"%s\"\n%s\n%s\n",
+ ib_get_node_type_str(p_node->node_info.node_type),
+ cl_ntoh64(p_port->guid), cl_ntoh16(base_lid),
+ p_node->print_desc, header_line, separator_line);
+
+ if (p_node->node_info.node_type == IB_NODE_TYPE_SWITCH) {
+ for (out_port = 0; out_port <= num_ports; out_port++){
+ p_physp = osm_node_get_physp_ptr(p_node, out_port);
+
+ /* no need to print SL2VL table for port that is down */
+ if (!p_physp || !p_physp->p_remote_physp)
+ continue;
+
+ for (in_port = 0; in_port <= num_ports; in_port++) {
+ p_tbl = osm_physp_get_slvl_tbl(p_physp, in_port);
+ for (i = 0, n = 0; i < 16; i++)
+ n += sprintf(buf + n, " %-2d",
+ ib_slvl_table_get(p_tbl, i));
+ fprintf(file, "%-3d %-3d :%s\n",
+ in_port, out_port, buf);
+ }
+ }
+ } else {
+ p_physp = p_port->p_physp;
+ p_tbl = osm_physp_get_slvl_tbl(p_physp, 0);
+ for (i = 0, n = 0; i < 16; i++)
+ n += sprintf(buf + n, " %-2d",
+ ib_slvl_table_get(p_tbl, i));
+ fprintf(file, "%-3d %-3d :%s\n", 0, 0, buf);
+ }
+
+ fprintf(file, "%s\n\n", separator_line);
+}
+
+static void print_node_report(cl_map_item_t * item, FILE * file, void *cxt)
+{
+ osm_node_t *p_node = (osm_node_t *) item;
+ osm_opensm_t *osm = cxt;
+ const osm_physp_t *p_physp, *p_remote_physp;
+ const ib_port_info_t *p_pi;
+ uint8_t port_num;
+ uint32_t num_ports;
+ uint8_t node_type;
+
+ node_type = osm_node_get_type(p_node);
+
+ num_ports = osm_node_get_num_physp(p_node);
+ port_num = node_type == IB_NODE_TYPE_SWITCH ? 0 : 1;
+ for (; port_num < num_ports; port_num++) {
+ p_physp = osm_node_get_physp_ptr(p_node, port_num);
+ if (!p_physp)
+ continue;
+
+ fprintf(file, "%-11s : %s : %02X :",
+ osm_get_manufacturer_str(cl_ntoh64
+ (osm_node_get_node_guid
+ (p_node))),
+ osm_get_node_type_str_fixed_width(node_type), port_num);
+
+ p_pi = &p_physp->port_info;
+
+ /*
+ * Port state is not defined for base switch port 0
+ */
+ if (port_num == 0 &&
+ ib_switch_info_is_enhanced_port0(&p_node->sw->switch_info) == FALSE)
+ fprintf(file, " :");
+ else
+ fprintf(file, " %s :",
+ osm_get_port_state_str_fixed_width
+ (ib_port_info_get_port_state(p_pi)));
+
+ /*
+ * LID values are only meaningful in select cases.
+ */
+ if (ib_port_info_get_port_state(p_pi) != IB_LINK_DOWN
+ && ((node_type == IB_NODE_TYPE_SWITCH && port_num == 0)
+ || node_type != IB_NODE_TYPE_SWITCH))
+ fprintf(file, " %04X : %01X :",
+ cl_ntoh16(p_pi->base_lid),
+ ib_port_info_get_lmc(p_pi));
+ else
+ fprintf(file, " : :");
+
+ if (port_num == 0 &&
+ ib_switch_info_is_enhanced_port0(&p_node->sw->switch_info) == FALSE)
+ fprintf(file, " : : ");
+ else
+ fprintf(file, " %s : %s : %s ",
+ osm_get_mtu_str
+ (ib_port_info_get_neighbor_mtu(p_pi)),
+ osm_get_lwa_str(p_pi->link_width_active),
+ osm_get_lsa_str
+ (ib_port_info_get_link_speed_active(p_pi),
+ ib_port_info_get_link_speed_ext_active(p_pi),
+ ib_port_info_get_port_state(p_pi),
+ p_physp->ext_port_info.link_speed_active & FDR10));
+
+ if (osm_physp_get_port_guid(p_physp) == osm->subn.sm_port_guid)
+ fprintf(file, "* %016" PRIx64 " *",
+ cl_ntoh64(osm_physp_get_port_guid(p_physp)));
+ else
+ fprintf(file, ": %016" PRIx64 " :",
+ cl_ntoh64(osm_physp_get_port_guid(p_physp)));
+
+ if (port_num
+ && (ib_port_info_get_port_state(p_pi) != IB_LINK_DOWN)) {
+ p_remote_physp = osm_physp_get_remote(p_physp);
+ if (p_remote_physp)
+ fprintf(file, " %016" PRIx64 " (%02X)",
+ cl_ntoh64(osm_physp_get_port_guid
+ (p_remote_physp)),
+ osm_physp_get_port_num(p_remote_physp));
+ else
+ fprintf(file, " UNKNOWN");
+ }
+
+ fprintf(file, "\n");
+ }
+
+ fprintf(file, "------------------------------------------------------"
+ "------------------------------------------------\n");
+}
+
+struct dump_context {
+ osm_opensm_t *p_osm;
+ FILE *file;
+ void (*func) (cl_map_item_t *, FILE *, void *);
+ void *cxt;
+};
+
+static void dump_item(cl_map_item_t * item, void *cxt)
+{
+ ((struct dump_context *)cxt)->func(item,
+ ((struct dump_context *)cxt)->file,
+ ((struct dump_context *)cxt)->cxt);
+}
+
+static void dump_qmap(FILE * file, cl_qmap_t * map,
+ void (*func) (cl_map_item_t *, FILE *, void *), void *cxt)
+{
+ struct dump_context dump_context;
+
+ dump_context.file = file;
+ dump_context.func = func;
+ dump_context.cxt = cxt;
+
+ cl_qmap_apply_func(map, dump_item, &dump_context);
+}
+
+void osm_dump_qmap_to_file(osm_opensm_t * p_osm, const char *file_name,
+ cl_qmap_t * map,
+ void (*func) (cl_map_item_t *, FILE *, void *),
+ void *cxt)
+{
+ char path[1024];
+ FILE *file;
+
+ snprintf(path, sizeof(path), "%s/%s",
+ p_osm->subn.opt.dump_files_dir, file_name);
+
+ file = fopen(path, "w");
+ if (!file) {
+ OSM_LOG(&p_osm->log, OSM_LOG_ERROR,
+ "cannot create file \'%s\': %s\n",
+ path, strerror(errno));
+ return;
+ }
+
+ dump_qmap(file, map, func, cxt);
+
+ fclose(file);
+}
+
+
+static void print_report(osm_opensm_t * osm, FILE * file)
+{
+ fprintf(file, "\n==================================================="
+ "====================================================\n"
+ "Vendor : Ty : # : Sta : LID : LMC : MTU : LWA :"
+ " LSA : Port GUID : Neighbor Port (Port #)\n");
+ dump_qmap(stdout, &osm->subn.node_guid_tbl, print_node_report, osm);
+}
+
+void osm_dump_mcast_routes(osm_opensm_t * osm)
+{
+ if (OSM_LOG_IS_ACTIVE_V2(&osm->log, OSM_LOG_ROUTING))
+ /* multicast routes */
+ osm_dump_qmap_to_file(osm, "opensm.mcfdbs",
+ &osm->subn.sw_guid_tbl,
+ dump_mcast_routes, osm);
+}
+
+void osm_dump_all(osm_opensm_t * osm)
+{
+ if (OSM_LOG_IS_ACTIVE_V2(&osm->log, OSM_LOG_ROUTING)) {
+ /* unicast routes */
+ osm_dump_qmap_to_file(osm, "opensm-lid-matrix.dump",
+ &osm->subn.sw_guid_tbl, dump_lid_matrix,
+ osm);
+ osm_dump_qmap_to_file(osm, "opensm-lfts.dump",
+ &osm->subn.sw_guid_tbl, dump_ucast_lfts,
+ osm);
+ if (OSM_LOG_IS_ACTIVE_V2(&osm->log, OSM_LOG_DEBUG))
+ dump_qmap(stdout, &osm->subn.sw_guid_tbl,
+ dump_ucast_path_distribution, osm);
+
+ /* An attempt to get osm_switch_recommend_path to report the
+ same routes that a sweep would assign. */
+ if (osm->subn.opt.scatter_ports)
+ srandom(osm->subn.opt.scatter_ports);
+
+ osm_dump_qmap_to_file(osm, "opensm.fdbs",
+ &osm->subn.sw_guid_tbl,
+ dump_ucast_routes, osm);
+ /* multicast routes */
+ osm_dump_qmap_to_file(osm, "opensm.mcfdbs",
+ &osm->subn.sw_guid_tbl,
+ dump_mcast_routes, osm);
+ /* SL2VL tables */
+ if (osm->subn.opt.qos ||
+ (osm->routing_engine_used &&
+ osm->routing_engine_used->update_sl2vl))
+ osm_dump_qmap_to_file(osm, "opensm-sl2vl.dump",
+ &osm->subn.port_guid_tbl,
+ dump_sl2vl_tbl, osm);
+ }
+ osm_dump_qmap_to_file(osm, "opensm-subnet.lst",
+ &osm->subn.node_guid_tbl, dump_topology_node,
+ osm);
+ if (OSM_LOG_IS_ACTIVE_V2(&osm->log, OSM_LOG_VERBOSE))
+ print_report(osm, stdout);
+}
diff --git a/contrib/ofed/opensm/opensm/osm_event_plugin.c b/contrib/ofed/opensm/opensm/osm_event_plugin.c
new file mode 100644
index 0000000..ae73783
--- /dev/null
+++ b/contrib/ofed/opensm/opensm/osm_event_plugin.c
@@ -0,0 +1,152 @@
+/*
+ * Copyright (c) 2008-2009 Voltaire, Inc. All rights reserved.
+ * Copyright (c) 2007 The Regents of the University of California.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+/****h* OpenSM Event plugin interface
+* DESCRIPTION
+* Database interface to record subnet events
+*
+* Implementations of this object _MUST_ be thread safe.
+*
+* AUTHOR
+* Ira Weiny, LLNL
+*
+*********/
+
+#if HAVE_CONFIG_H
+# include <config.h>
+#endif /* HAVE_CONFIG_H */
+
+#include <stdlib.h>
+#include <dlfcn.h>
+#include <opensm/osm_file_ids.h>
+#define FILE_ID OSM_FILE_EVENT_PLUGIN_C
+#include <opensm/osm_event_plugin.h>
+#include <opensm/osm_opensm.h>
+
+#if defined(PATH_MAX)
+#define OSM_PATH_MAX (PATH_MAX + 1)
+#elif defined (_POSIX_PATH_MAX)
+#define OSM_PATH_MAX (_POSIX_PATH_MAX + 1)
+#else
+#define OSM_PATH_MAX 256
+#endif
+
+/**
+ * functions
+ */
+osm_epi_plugin_t *osm_epi_construct(osm_opensm_t *osm, char *plugin_name)
+{
+ char lib_name[OSM_PATH_MAX];
+ struct old_if { unsigned ver; } *old_impl;
+ osm_epi_plugin_t *rc = NULL;
+
+ if (!plugin_name || !*plugin_name)
+ return NULL;
+
+ /* find the plugin */
+ snprintf(lib_name, sizeof(lib_name), "lib%s.so", plugin_name);
+
+ rc = malloc(sizeof(*rc));
+ if (!rc)
+ return NULL;
+
+ rc->handle = dlopen(lib_name, RTLD_LAZY);
+ if (!rc->handle) {
+ OSM_LOG(&osm->log, OSM_LOG_ERROR,
+ "Failed to open event plugin \"%s\" : \"%s\"\n",
+ lib_name, dlerror());
+ goto DLOPENFAIL;
+ }
+
+ rc->impl =
+ (osm_event_plugin_t *) dlsym(rc->handle,
+ OSM_EVENT_PLUGIN_IMPL_NAME);
+ if (!rc->impl) {
+ OSM_LOG(&osm->log, OSM_LOG_ERROR,
+ "Failed to find \"%s\" symbol in \"%s\" : \"%s\"\n",
+ OSM_EVENT_PLUGIN_IMPL_NAME, lib_name, dlerror());
+ goto Exit;
+ }
+
+ /* check for old interface */
+ old_impl = (struct old_if *) rc->impl;
+ if (old_impl->ver == OSM_ORIG_EVENT_PLUGIN_INTERFACE_VER) {
+ OSM_LOG(&osm->log, OSM_LOG_ERROR, "Error loading plugin: "
+ "\'%s\' contains a depricated interface version %d\n"
+ " Please recompile with the new interface.\n",
+ plugin_name, old_impl->ver);
+ goto Exit;
+ }
+
+ /* Check the version to make sure this module will work with us */
+ if (strcmp(rc->impl->osm_version, osm->osm_version)) {
+ OSM_LOG(&osm->log, OSM_LOG_ERROR, "Error loading plugin"
+ " \'%s\': OpenSM version mismatch - plugin was built"
+ " against %s version of OpenSM. Skip loading.\n",
+ plugin_name, rc->impl->osm_version);
+ goto Exit;
+ }
+
+ if (!rc->impl->create) {
+ OSM_LOG(&osm->log, OSM_LOG_ERROR,
+ "Error loading plugin \'%s\': no create() method.\n",
+ plugin_name);
+ goto Exit;
+ }
+
+ rc->plugin_data = rc->impl->create(osm);
+
+ if (!rc->plugin_data)
+ goto Exit;
+
+ rc->plugin_name = strdup(plugin_name);
+ return rc;
+
+Exit:
+ dlclose(rc->handle);
+DLOPENFAIL:
+ free(rc);
+ return NULL;
+}
+
+void osm_epi_destroy(osm_epi_plugin_t * plugin)
+{
+ if (plugin) {
+ if (plugin->impl->delete)
+ plugin->impl->delete(plugin->plugin_data);
+ dlclose(plugin->handle);
+ free(plugin->plugin_name);
+ free(plugin);
+ }
+}
diff --git a/contrib/ofed/opensm/opensm/osm_guid_info_rcv.c b/contrib/ofed/opensm/opensm/osm_guid_info_rcv.c
new file mode 100644
index 0000000..f4d0592
--- /dev/null
+++ b/contrib/ofed/opensm/opensm/osm_guid_info_rcv.c
@@ -0,0 +1,124 @@
+/*
+ * Copyright (c) 2004-2009 Voltaire, Inc. All rights reserved.
+ * Copyright (c) 2002-2012 Mellanox Technologies LTD. All rights reserved.
+ * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+/*
+ * Abstract:
+ * Implementation of osm_gi_rcv_t.
+ * This object represents the GUIDInfo Receiver object.
+ * This object is part of the opensm family of objects.
+ */
+
+#if HAVE_CONFIG_H
+# include <config.h>
+#endif /* HAVE_CONFIG_H */
+
+#include <string.h>
+#include <stdlib.h>
+#include <iba/ib_types.h>
+#include <complib/cl_qmap.h>
+#include <complib/cl_passivelock.h>
+#include <complib/cl_debug.h>
+#include <opensm/osm_file_ids.h>
+#define FILE_ID OSM_FILE_GUID_INFO_RCV_C
+#include <vendor/osm_vendor_api.h>
+#include <opensm/osm_madw.h>
+#include <opensm/osm_log.h>
+#include <opensm/osm_node.h>
+#include <opensm/osm_subnet.h>
+#include <opensm/osm_mad_pool.h>
+#include <opensm/osm_msgdef.h>
+#include <opensm/osm_helper.h>
+#include <opensm/osm_remote_sm.h>
+#include <opensm/osm_opensm.h>
+
+void osm_gi_rcv_process(IN void *context, IN void *data)
+{
+ osm_sm_t *sm = context;
+ osm_madw_t *p_madw = data;
+ ib_guid_info_t *p_gi;
+ ib_smp_t *p_smp;
+ osm_port_t *p_port;
+ osm_gi_context_t *p_context;
+ ib_net64_t port_guid, node_guid;
+ uint8_t block_num;
+
+ CL_ASSERT(sm);
+
+ OSM_LOG_ENTER(sm->p_log);
+
+ CL_ASSERT(p_madw);
+
+ p_smp = osm_madw_get_smp_ptr(p_madw);
+ p_context = osm_madw_get_gi_context_ptr(p_madw);
+ p_gi = ib_smp_get_payload_ptr(p_smp);
+
+ CL_ASSERT(p_smp->attr_id == IB_MAD_ATTR_GUID_INFO);
+
+ block_num = (uint8_t) cl_ntoh32(p_smp->attr_mod);
+
+ port_guid = p_context->port_guid;
+ node_guid = p_context->node_guid;
+
+ osm_dump_guid_info_v2(sm->p_log, node_guid, port_guid, block_num, p_gi,
+ FILE_ID, OSM_LOG_DEBUG);
+
+ if (ib_smp_get_status(p_smp)) {
+ OSM_LOG(sm->p_log, OSM_LOG_DEBUG,
+ "MAD status 0x%x received\n",
+ cl_ntoh16(ib_smp_get_status(p_smp)));
+ goto Exit;
+ }
+
+ CL_PLOCK_EXCL_ACQUIRE(sm->p_lock);
+ p_port = osm_get_port_by_guid(sm->p_subn, port_guid);
+ if (!p_port) {
+ CL_PLOCK_RELEASE(sm->p_lock);
+ OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR 4701: "
+ "No port object for port with GUID 0x%" PRIx64
+ "\n\t\t\t\tfor parent node GUID 0x%" PRIx64
+ ", TID 0x%" PRIx64 "\n",
+ cl_ntoh64(port_guid), cl_ntoh64(node_guid),
+ cl_ntoh64(p_smp->trans_id));
+ goto Exit;
+ }
+
+ CL_PLOCK_RELEASE(sm->p_lock);
+
+Exit:
+ /*
+ Release the lock before jumping here!!
+ */
+ OSM_LOG_EXIT(sm->p_log);
+}
diff --git a/contrib/ofed/opensm/opensm/osm_guid_mgr.c b/contrib/ofed/opensm/opensm/osm_guid_mgr.c
new file mode 100644
index 0000000..e4d1de7
--- /dev/null
+++ b/contrib/ofed/opensm/opensm/osm_guid_mgr.c
@@ -0,0 +1,145 @@
+/*
+ * Copyright (c) 2006-2009 Voltaire, Inc. All rights reserved.
+ * Copyright (c) 2002-2012 Mellanox Technologies LTD. All rights reserved.
+ * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+/*
+ * Abstract:
+ * Implementation of osm_guid_mgr_t.
+ * This object implements the GUID manager object.
+ * This object is part of the opensm family of objects.
+ */
+
+#if HAVE_CONFIG_H
+# include <config.h>
+#endif /* HAVE_CONFIG_H */
+
+#include <string.h>
+#include <iba/ib_types.h>
+#include <complib/cl_debug.h>
+#include <complib/cl_qlist.h>
+#include <opensm/osm_file_ids.h>
+#define FILE_ID OSM_FILE_GUID_MGR_C
+#include <opensm/osm_port.h>
+#include <opensm/osm_node.h>
+#include <opensm/osm_guid.h>
+#include <opensm/osm_opensm.h>
+
+static void guidinfo_set(IN osm_sa_t *sa, IN osm_port_t *p_port,
+ IN uint8_t block_num)
+{
+ uint8_t payload[IB_SMP_DATA_SIZE];
+ osm_madw_context_t context;
+ ib_api_status_t status;
+
+ memcpy(payload,
+ &((*p_port->p_physp->p_guids)[block_num * GUID_TABLE_MAX_ENTRIES]),
+ sizeof(ib_guid_info_t));
+
+ context.gi_context.node_guid = osm_node_get_node_guid(p_port->p_node);
+ context.gi_context.port_guid = osm_physp_get_port_guid(p_port->p_physp);
+ context.gi_context.set_method = TRUE;
+ context.gi_context.port_num = osm_physp_get_port_num(p_port->p_physp);
+
+ status = osm_req_set(sa->sm, osm_physp_get_dr_path_ptr(p_port->p_physp),
+ payload, sizeof(payload), IB_MAD_ATTR_GUID_INFO,
+ cl_hton32((uint32_t)block_num), FALSE,
+ ib_port_info_get_m_key(&p_port->p_physp->port_info),
+ CL_DISP_MSGID_NONE, &context);
+ if (status != IB_SUCCESS)
+ OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 5109: "
+ "Failure initiating GUIDInfo request (%s)\n",
+ ib_get_err_str(status));
+}
+
+osm_guidinfo_work_obj_t *osm_guid_work_obj_new(IN osm_port_t * p_port,
+ IN uint8_t block_num)
+{
+ osm_guidinfo_work_obj_t *p_obj;
+
+ /*
+ clean allocated memory to avoid assertion when trying to insert to
+ qlist.
+ see cl_qlist_insert_tail(): CL_ASSERT(p_list_item->p_list != p_list)
+ */
+ p_obj = calloc(1, sizeof(*p_obj));
+ if (p_obj) {
+ p_obj->p_port = p_port;
+ p_obj->block_num = block_num;
+ }
+
+ return p_obj;
+}
+
+void osm_guid_work_obj_delete(IN osm_guidinfo_work_obj_t * p_wobj)
+{
+ free(p_wobj);
+}
+
+int osm_queue_guidinfo(IN osm_sa_t *sa, IN osm_port_t *p_port,
+ IN uint8_t block_num)
+{
+ osm_guidinfo_work_obj_t *p_obj;
+ int status = 1;
+
+ p_obj = osm_guid_work_obj_new(p_port, block_num);
+ if (p_obj)
+ cl_qlist_insert_tail(&sa->p_subn->alias_guid_list,
+ &p_obj->list_item);
+ else {
+ OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 510F: "
+ "Memory allocation of guid work object failed\n");
+ status = 0;
+ }
+
+ return status;
+}
+
+void osm_guid_mgr_process(IN osm_sm_t * sm) {
+ osm_guidinfo_work_obj_t *p_obj;
+
+ OSM_LOG_ENTER(sm->p_log);
+
+ OSM_LOG(sm->p_log, OSM_LOG_DEBUG, "Processing alias guid list\n");
+
+ CL_PLOCK_EXCL_ACQUIRE(sm->p_lock);
+ while (cl_qlist_count(&sm->p_subn->alias_guid_list)) {
+ p_obj = (osm_guidinfo_work_obj_t *) cl_qlist_remove_head(&sm->p_subn->alias_guid_list);
+ guidinfo_set(&sm->p_subn->p_osm->sa, p_obj->p_port,
+ p_obj->block_num);
+ osm_guid_work_obj_delete(p_obj);
+ }
+
+ CL_PLOCK_RELEASE(sm->p_lock);
+ OSM_LOG_EXIT(sm->p_log);
+}
diff --git a/contrib/ofed/opensm/opensm/osm_helper.c b/contrib/ofed/opensm/opensm/osm_helper.c
new file mode 100644
index 0000000..58e68b7
--- /dev/null
+++ b/contrib/ofed/opensm/opensm/osm_helper.c
@@ -0,0 +1,3332 @@
+/*
+ * Copyright (c) 2004-2009 Voltaire, Inc. All rights reserved.
+ * Copyright (c) 2002-2015 Mellanox Technologies LTD. All rights reserved.
+ * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
+ * Copyright (c) 2009 HNR Consulting. All rights reserved.
+ * Copyright (c) 2009 Sun Microsystems, Inc. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+/*
+ * Abstract:
+ * Implementation of opensm helper functions.
+ */
+
+#if HAVE_CONFIG_H
+# include <config.h>
+#endif /* HAVE_CONFIG_H */
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <arpa/inet.h>
+#include <sys/socket.h>
+#include <complib/cl_debug.h>
+#include <iba/ib_types.h>
+#include <opensm/osm_file_ids.h>
+#define FILE_ID OSM_FILE_HELPER_C
+#include <opensm/osm_helper.h>
+#include <opensm/osm_log.h>
+
+#define LINE_LENGTH 256
+
+#define ARR_SIZE(a) (sizeof(a)/sizeof((a)[0]))
+
+/* we use two tables - one for queries and one for responses */
+static const char *ib_sa_method_str[] = {
+ "RESERVED", /* 0 */
+ "SubnAdmGet", /* 1 */
+ "SubnAdmSet", /* 2 */
+ "RESERVED", /* 3 */
+ "RESERVED", /* 4 */
+ "RESERVED", /* 5 */
+ "SubnAdmReport", /* 6 */
+ "RESERVED", /* 7 */
+ "RESERVED", /* 8 */
+ "RESERVED", /* 9 */
+ "RESERVED", /* A */
+ "RESERVED", /* B */
+ "RESERVED", /* C */
+ "RESERVED", /* D */
+ "RESERVED", /* E */
+ "RESERVED", /* F */
+ "RESERVED", /* 10 */
+ "RESERVED", /* 11 */
+ "SubnAdmGetTable", /* 12 */
+ "SubnAdmGetTraceTable", /* 13 */
+ "SubnAdmGetMulti", /* 14 */
+ "SubnAdmDelete", /* 15 */
+ "UNKNOWN" /* 16 */
+};
+
+#define OSM_SA_METHOD_STR_UNKNOWN_VAL (ARR_SIZE(ib_sa_method_str) - 1)
+
+static const char *ib_sa_resp_method_str[] = {
+ "RESERVED", /* 80 */
+ "SubnAdmGetResp", /* 81 */
+ "RESERVED (SetResp?)", /* 82 */
+ "RESERVED", /* 83 */
+ "RESERVED", /* 84 */
+ "RESERVED", /* 85 */
+ "SubnAdmReportResp", /* 86 */
+ "RESERVED", /* 87 */
+ "RESERVED", /* 88 */
+ "RESERVED", /* 89 */
+ "RESERVED", /* 8A */
+ "RESERVED", /* 8B */
+ "RESERVED", /* 8C */
+ "RESERVED", /* 8D */
+ "RESERVED", /* 8E */
+ "RESERVED", /* 8F */
+ "RESERVED", /* 90 */
+ "RESERVED", /* 91 */
+ "SubnAdmGetTableResp", /* 92 */
+ "RESERVED", /* 93 */
+ "SubnAdmGetMultiResp", /* 94 */
+ "SubnAdmDeleteResp", /* 95 */
+ "UNKNOWN"
+};
+
+static const char *ib_sm_method_str[] = {
+ "RESERVED0", /* 0 */
+ "SubnGet", /* 1 */
+ "SubnSet", /* 2 */
+ "RESERVED3", /* 3 */
+ "RESERVED4", /* 4 */
+ "SubnTrap", /* 5 */
+ "RESERVED6", /* 6 */
+ "SubnTrapRepress", /* 7 */
+ "RESERVED8", /* 8 */
+ "RESERVED9", /* 9 */
+ "RESERVEDA", /* A */
+ "RESERVEDB", /* B */
+ "RESERVEDC", /* C */
+ "RESERVEDD", /* D */
+ "RESERVEDE", /* E */
+ "RESERVEDF", /* F */
+ "RESERVED10", /* 10 */
+ "SubnGetResp", /* 11 */
+ "RESERVED12", /* 12 */
+ "RESERVED13", /* 13 */
+ "RESERVED14", /* 14 */
+ "RESERVED15", /* 15 */
+ "RESERVED16", /* 16 */
+ "RESERVED17", /* 17 */
+ "RESERVED18", /* 18 */
+ "RESERVED19", /* 19 */
+ "RESERVED1A", /* 1A */
+ "RESERVED1B", /* 1B */
+ "RESERVED1C", /* 1C */
+ "RESERVED1D", /* 1D */
+ "RESERVED1E", /* 1E */
+ "RESERVED1F", /* 1F */
+ "UNKNOWN" /* 20 */
+};
+
+#define OSM_SM_METHOD_STR_UNKNOWN_VAL (ARR_SIZE(ib_sm_method_str) - 1)
+
+static const char *ib_sm_attr_str[] = {
+ "RESERVED", /* 0 */
+ "ClassPortInfo", /* 1 */
+ "Notice", /* 2 */
+ "InformInfo", /* 3 */
+ "RESERVED", /* 4 */
+ "RESERVED", /* 5 */
+ "RESERVED", /* 6 */
+ "RESERVED", /* 7 */
+ "RESERVED", /* 8 */
+ "RESERVED", /* 9 */
+ "RESERVED", /* A */
+ "RESERVED", /* B */
+ "RESERVED", /* C */
+ "RESERVED", /* D */
+ "RESERVED", /* E */
+ "RESERVED", /* F */
+ "NodeDescription", /* 10 */
+ "NodeInfo", /* 11 */
+ "SwitchInfo", /* 12 */
+ "UNKNOWN", /* 13 */
+ "GUIDInfo", /* 14 */
+ "PortInfo", /* 15 */
+ "P_KeyTable", /* 16 */
+ "SLtoVLMappingTable", /* 17 */
+ "VLArbitrationTable", /* 18 */
+ "LinearForwardingTable", /* 19 */
+ "RandomForwardingTable", /* 1A */
+ "MulticastForwardingTable", /* 1B */
+ "UNKNOWN", /* 1C */
+ "UNKNOWN", /* 1D */
+ "UNKNOWN", /* 1E */
+ "UNKNOWN", /* 1F */
+ "SMInfo", /* 20 */
+ "UNKNOWN" /* 21 - always highest value */
+};
+
+#define OSM_SM_ATTR_STR_UNKNOWN_VAL (ARR_SIZE(ib_sm_attr_str) - 1)
+
+static const char *ib_sa_attr_str[] = {
+ "RESERVED", /* 0 */
+ "ClassPortInfo", /* 1 */
+ "Notice", /* 2 */
+ "InformInfo", /* 3 */
+ "RESERVED", /* 4 */
+ "RESERVED", /* 5 */
+ "RESERVED", /* 6 */
+ "RESERVED", /* 7 */
+ "RESERVED", /* 8 */
+ "RESERVED", /* 9 */
+ "RESERVED", /* A */
+ "RESERVED", /* B */
+ "RESERVED", /* C */
+ "RESERVED", /* D */
+ "RESERVED", /* E */
+ "RESERVED", /* F */
+ "RESERVED", /* 10 */
+ "NodeRecord", /* 11 */
+ "PortInfoRecord", /* 12 */
+ "SLtoVLMappingTableRecord", /* 13 */
+ "SwitchInfoRecord", /* 14 */
+ "LinearForwardingTableRecord", /* 15 */
+ "RandomForwardingTableRecord", /* 16 */
+ "MulticastForwardingTableRecord", /* 17 */
+ "SMInfoRecord", /* 18 */
+ "RESERVED", /* 19 */
+ "RandomForwardingTable", /* 1A */
+ "MulticastForwardingTable", /* 1B */
+ "UNKNOWN", /* 1C */
+ "UNKNOWN", /* 1D */
+ "UNKNOWN", /* 1E */
+ "UNKNOWN", /* 1F */
+ "LinkRecord", /* 20 */
+ "UNKNOWN", /* 21 */
+ "UNKNOWN", /* 22 */
+ "UNKNOWN", /* 23 */
+ "UNKNOWN", /* 24 */
+ "UNKNOWN", /* 25 */
+ "UNKNOWN", /* 26 */
+ "UNKNOWN", /* 27 */
+ "UNKNOWN", /* 28 */
+ "UNKNOWN", /* 29 */
+ "UNKNOWN", /* 2A */
+ "UNKNOWN", /* 2B */
+ "UNKNOWN", /* 2C */
+ "UNKNOWN", /* 2D */
+ "UNKNOWN", /* 2E */
+ "UNKNOWN", /* 2F */
+ "GuidInfoRecord", /* 30 */
+ "ServiceRecord", /* 31 */
+ "UNKNOWN", /* 32 */
+ "P_KeyTableRecord", /* 33 */
+ "UNKNOWN", /* 34 */
+ "PathRecord", /* 35 */
+ "VLArbitrationTableRecord", /* 36 */
+ "UNKNOWN", /* 37 */
+ "MCMemberRecord", /* 38 */
+ "TraceRecord", /* 39 */
+ "MultiPathRecord", /* 3A */
+ "ServiceAssociationRecord", /* 3B */
+ "UNKNOWN", /* 3C */
+ "UNKNOWN", /* 3D */
+ "UNKNOWN", /* 3E */
+ "UNKNOWN", /* 3F */
+ "UNKNOWN", /* 40 */
+ "UNKNOWN", /* 41 */
+ "UNKNOWN", /* 42 */
+ "UNKNOWN", /* 43 */
+ "UNKNOWN", /* 44 */
+ "UNKNOWN", /* 45 */
+ "UNKNOWN", /* 46 */
+ "UNKNOWN", /* 47 */
+ "UNKNOWN", /* 48 */
+ "UNKNOWN", /* 49 */
+ "UNKNOWN", /* 4A */
+ "UNKNOWN", /* 4B */
+ "UNKNOWN", /* 4C */
+ "UNKNOWN", /* 4D */
+ "UNKNOWN", /* 4E */
+ "UNKNOWN", /* 4F */
+ "UNKNOWN", /* 50 */
+ "UNKNOWN", /* 51 */
+ "UNKNOWN", /* 52 */
+ "UNKNOWN", /* 53 */
+ "UNKNOWN", /* 54 */
+ "UNKNOWN", /* 55 */
+ "UNKNOWN", /* 56 */
+ "UNKNOWN", /* 57 */
+ "UNKNOWN", /* 58 */
+ "UNKNOWN", /* 59 */
+ "UNKNOWN", /* 5A */
+ "UNKNOWN", /* 5B */
+ "UNKNOWN", /* 5C */
+ "UNKNOWN", /* 5D */
+ "UNKNOWN", /* 5E */
+ "UNKNOWN", /* 5F */
+ "UNKNOWN", /* 60 */
+ "UNKNOWN", /* 61 */
+ "UNKNOWN", /* 62 */
+ "UNKNOWN", /* 63 */
+ "UNKNOWN", /* 64 */
+ "UNKNOWN", /* 65 */
+ "UNKNOWN", /* 66 */
+ "UNKNOWN", /* 67 */
+ "UNKNOWN", /* 68 */
+ "UNKNOWN", /* 69 */
+ "UNKNOWN", /* 6A */
+ "UNKNOWN", /* 6B */
+ "UNKNOWN", /* 6C */
+ "UNKNOWN", /* 6D */
+ "UNKNOWN", /* 6E */
+ "UNKNOWN", /* 6F */
+ "UNKNOWN", /* 70 */
+ "UNKNOWN", /* 71 */
+ "UNKNOWN", /* 72 */
+ "UNKNOWN", /* 73 */
+ "UNKNOWN", /* 74 */
+ "UNKNOWN", /* 75 */
+ "UNKNOWN", /* 76 */
+ "UNKNOWN", /* 77 */
+ "UNKNOWN", /* 78 */
+ "UNKNOWN", /* 79 */
+ "UNKNOWN", /* 7A */
+ "UNKNOWN", /* 7B */
+ "UNKNOWN", /* 7C */
+ "UNKNOWN", /* 7D */
+ "UNKNOWN", /* 7E */
+ "UNKNOWN", /* 7F */
+ "UNKNOWN", /* 80 */
+ "UNKNOWN", /* 81 */
+ "UNKNOWN", /* 82 */
+ "UNKNOWN", /* 83 */
+ "UNKNOWN", /* 84 */
+ "UNKNOWN", /* 85 */
+ "UNKNOWN", /* 86 */
+ "UNKNOWN", /* 87 */
+ "UNKNOWN", /* 88 */
+ "UNKNOWN", /* 89 */
+ "UNKNOWN", /* 8A */
+ "UNKNOWN", /* 8B */
+ "UNKNOWN", /* 8C */
+ "UNKNOWN", /* 8D */
+ "UNKNOWN", /* 8E */
+ "UNKNOWN", /* 8F */
+ "UNKNOWN", /* 90 */
+ "UNKNOWN", /* 91 */
+ "UNKNOWN", /* 92 */
+ "UNKNOWN", /* 93 */
+ "UNKNOWN", /* 94 */
+ "UNKNOWN", /* 95 */
+ "UNKNOWN", /* 96 */
+ "UNKNOWN", /* 97 */
+ "UNKNOWN", /* 98 */
+ "UNKNOWN", /* 99 */
+ "UNKNOWN", /* 9A */
+ "UNKNOWN", /* 9B */
+ "UNKNOWN", /* 9C */
+ "UNKNOWN", /* 9D */
+ "UNKNOWN", /* 9E */
+ "UNKNOWN", /* 9F */
+ "UNKNOWN", /* A0 */
+ "UNKNOWN", /* A1 */
+ "UNKNOWN", /* A2 */
+ "UNKNOWN", /* A3 */
+ "UNKNOWN", /* A4 */
+ "UNKNOWN", /* A5 */
+ "UNKNOWN", /* A6 */
+ "UNKNOWN", /* A7 */
+ "UNKNOWN", /* A8 */
+ "UNKNOWN", /* A9 */
+ "UNKNOWN", /* AA */
+ "UNKNOWN", /* AB */
+ "UNKNOWN", /* AC */
+ "UNKNOWN", /* AD */
+ "UNKNOWN", /* AE */
+ "UNKNOWN", /* AF */
+ "UNKNOWN", /* B0 */
+ "UNKNOWN", /* B1 */
+ "UNKNOWN", /* B2 */
+ "UNKNOWN", /* B3 */
+ "UNKNOWN", /* B4 */
+ "UNKNOWN", /* B5 */
+ "UNKNOWN", /* B6 */
+ "UNKNOWN", /* B7 */
+ "UNKNOWN", /* B8 */
+ "UNKNOWN", /* B9 */
+ "UNKNOWN", /* BA */
+ "UNKNOWN", /* BB */
+ "UNKNOWN", /* BC */
+ "UNKNOWN", /* BD */
+ "UNKNOWN", /* BE */
+ "UNKNOWN", /* BF */
+ "UNKNOWN", /* C0 */
+ "UNKNOWN", /* C1 */
+ "UNKNOWN", /* C2 */
+ "UNKNOWN", /* C3 */
+ "UNKNOWN", /* C4 */
+ "UNKNOWN", /* C5 */
+ "UNKNOWN", /* C6 */
+ "UNKNOWN", /* C7 */
+ "UNKNOWN", /* C8 */
+ "UNKNOWN", /* C9 */
+ "UNKNOWN", /* CA */
+ "UNKNOWN", /* CB */
+ "UNKNOWN", /* CC */
+ "UNKNOWN", /* CD */
+ "UNKNOWN", /* CE */
+ "UNKNOWN", /* CF */
+ "UNKNOWN", /* D0 */
+ "UNKNOWN", /* D1 */
+ "UNKNOWN", /* D2 */
+ "UNKNOWN", /* D3 */
+ "UNKNOWN", /* D4 */
+ "UNKNOWN", /* D5 */
+ "UNKNOWN", /* D6 */
+ "UNKNOWN", /* D7 */
+ "UNKNOWN", /* D8 */
+ "UNKNOWN", /* D9 */
+ "UNKNOWN", /* DA */
+ "UNKNOWN", /* DB */
+ "UNKNOWN", /* DC */
+ "UNKNOWN", /* DD */
+ "UNKNOWN", /* DE */
+ "UNKNOWN", /* DF */
+ "UNKNOWN", /* E0 */
+ "UNKNOWN", /* E1 */
+ "UNKNOWN", /* E2 */
+ "UNKNOWN", /* E3 */
+ "UNKNOWN", /* E4 */
+ "UNKNOWN", /* E5 */
+ "UNKNOWN", /* E6 */
+ "UNKNOWN", /* E7 */
+ "UNKNOWN", /* E8 */
+ "UNKNOWN", /* E9 */
+ "UNKNOWN", /* EA */
+ "UNKNOWN", /* EB */
+ "UNKNOWN", /* EC */
+ "UNKNOWN", /* ED */
+ "UNKNOWN", /* EE */
+ "UNKNOWN", /* EF */
+ "UNKNOWN", /* F0 */
+ "UNKNOWN", /* F1 */
+ "UNKNOWN", /* F2 */
+ "InformInfoRecord", /* F3 */
+ "UNKNOWN" /* F4 - always highest value */
+};
+
+#define OSM_SA_ATTR_STR_UNKNOWN_VAL (ARR_SIZE(ib_sa_attr_str) - 1)
+
+static int ordered_rates[] = {
+ 0, 0, /* 0, 1 - reserved */
+ 1, /* 2 - 2.5 Gbps */
+ 3, /* 3 - 10 Gbps */
+ 6, /* 4 - 30 Gbps */
+ 2, /* 5 - 5 Gbps */
+ 5, /* 6 - 20 Gbps */
+ 9, /* 7 - 40 Gbps */
+ 10, /* 8 - 60 Gbps */
+ 13, /* 9 - 80 Gbps */
+ 14, /* 10 - 120 Gbps */
+ 4, /* 11 - 14 Gbps (17 Gbps equiv) */
+ 12, /* 12 - 56 Gbps (68 Gbps equiv) */
+ 16, /* 13 - 112 Gbps (136 Gbps equiv) */
+ 17, /* 14 - 168 Gbps (204 Gbps equiv) */
+ 7, /* 15 - 25 Gbps (31.25 Gbps equiv) */
+ 15, /* 16 - 100 Gbps (125 Gbps equiv) */
+ 18, /* 17 - 200 Gbps (250 Gbps equiv) */
+ 19, /* 18 - 300 Gbps (375 Gbps equiv) */
+ 8, /* 19 - 28 Gbps (35 Gbps equiv) */
+ 11, /* 20 - 50 Gbps (62.5 Gbps equiv) */
+};
+
+int sprint_uint8_arr(char *buf, size_t size,
+ const uint8_t * arr, size_t len)
+{
+ int n;
+ unsigned int i;
+ for (i = 0, n = 0; i < len; i++) {
+ n += snprintf(buf + n, size - n, "%s%u", i == 0 ? "" : ",",
+ arr[i]);
+ if (n >= size)
+ break;
+ }
+ return n;
+}
+
+const char *ib_get_sa_method_str(IN uint8_t method)
+{
+ if (method & 0x80) {
+ method = method & 0x7f;
+ if (method > OSM_SA_METHOD_STR_UNKNOWN_VAL)
+ method = OSM_SA_METHOD_STR_UNKNOWN_VAL;
+ /* it is a response - use the response table */
+ return ib_sa_resp_method_str[method];
+ } else {
+ if (method > OSM_SA_METHOD_STR_UNKNOWN_VAL)
+ method = OSM_SA_METHOD_STR_UNKNOWN_VAL;
+ return ib_sa_method_str[method];
+ }
+}
+
+const char *ib_get_sm_method_str(IN uint8_t method)
+{
+ if (method & 0x80)
+ method = (method & 0x0F) | 0x10;
+ if (method > OSM_SM_METHOD_STR_UNKNOWN_VAL)
+ method = OSM_SM_METHOD_STR_UNKNOWN_VAL;
+ return ib_sm_method_str[method];
+}
+
+const char *ib_get_sm_attr_str(IN ib_net16_t attr)
+{
+ uint16_t host_attr = cl_ntoh16(attr);
+
+ if (attr == IB_MAD_ATTR_MLNX_EXTENDED_PORT_INFO)
+ return "MLNXExtendedPortInfo";
+
+ if (host_attr > OSM_SM_ATTR_STR_UNKNOWN_VAL)
+ host_attr = OSM_SM_ATTR_STR_UNKNOWN_VAL;
+
+ return ib_sm_attr_str[host_attr];
+}
+
+const char *ib_get_sa_attr_str(IN ib_net16_t attr)
+{
+ uint16_t host_attr = cl_ntoh16(attr);
+
+ if (host_attr > OSM_SA_ATTR_STR_UNKNOWN_VAL)
+ host_attr = OSM_SA_ATTR_STR_UNKNOWN_VAL;
+
+ return ib_sa_attr_str[host_attr];
+}
+
+const char *ib_get_trap_str(ib_net16_t trap_num)
+{
+ switch (cl_ntoh16(trap_num)) {
+ case SM_GID_IN_SERVICE_TRAP: /* 64 */
+ return "GID in service";
+ case SM_GID_OUT_OF_SERVICE_TRAP: /* 65 */
+ return "GID out of service";
+ case SM_MGID_CREATED_TRAP: /* 66 */
+ return "New mcast group created";
+ case SM_MGID_DESTROYED_TRAP: /* 67 */
+ return "Mcast group deleted";
+ case SM_UNPATH_TRAP: /* 68 */
+ return "UnPath, Path no longer valid";
+ case SM_REPATH_TRAP: /* 69 */
+ return "RePath, Path recomputed";
+ case SM_LINK_STATE_CHANGED_TRAP: /* 128 */
+ return "Link state change";
+ case SM_LINK_INTEGRITY_THRESHOLD_TRAP: /* 129 */
+ return "Local Link integrity threshold reached";
+ case SM_BUFFER_OVERRUN_THRESHOLD_TRAP: /* 130 */
+ return "Excessive Buffer Overrun Threshold reached";
+ case SM_WATCHDOG_TIMER_EXPIRED_TRAP: /* 131 */
+ return "Flow Control Update watchdog timer expired";
+ case SM_LOCAL_CHANGES_TRAP: /* 144 */
+ return
+ "CapabilityMask, NodeDescription, Link [Width|Speed] Enabled, SM priority changed";
+ case SM_SYS_IMG_GUID_CHANGED_TRAP: /* 145 */
+ return "System Image GUID changed";
+ case SM_BAD_MKEY_TRAP: /* 256 */
+ return "Bad M_Key";
+ case SM_BAD_PKEY_TRAP: /* 257 */
+ return "Bad P_Key";
+ case SM_BAD_QKEY_TRAP: /* 258 */
+ return "Bad Q_Key";
+ case SM_BAD_SWITCH_PKEY_TRAP: /* 259 */
+ return "Bad P_Key (switch external port)";
+ default:
+ break;
+ }
+ return "Unknown";
+}
+
+const ib_gid_t ib_zero_gid = { {0} };
+
+static ib_api_status_t dbg_do_line(IN char **pp_local, IN uint32_t buf_size,
+ IN const char *p_prefix_str,
+ IN const char *p_new_str,
+ IN uint32_t * p_total_len)
+{
+ char line[LINE_LENGTH];
+ uint32_t len;
+
+ sprintf(line, "%s%s", p_prefix_str, p_new_str);
+ len = (uint32_t) strlen(line);
+ *p_total_len += len;
+ if (*p_total_len + sizeof('\0') > buf_size)
+ return IB_INSUFFICIENT_MEMORY;
+
+ strcpy(*pp_local, line);
+ *pp_local += len;
+ return IB_SUCCESS;
+}
+
+static void dbg_get_capabilities_str(IN char *p_buf, IN uint32_t buf_size,
+ IN const char *p_prefix_str,
+ IN const ib_port_info_t * p_pi)
+{
+ uint32_t total_len = 0;
+ char *p_local = p_buf;
+
+ strcpy(p_local, "Capability Mask:\n");
+ p_local += strlen(p_local);
+
+ if (p_pi->capability_mask & IB_PORT_CAP_RESV0) {
+ if (dbg_do_line(&p_local, buf_size, p_prefix_str,
+ "IB_PORT_CAP_RESV0\n",
+ &total_len) != IB_SUCCESS)
+ return;
+ }
+ if (p_pi->capability_mask & IB_PORT_CAP_IS_SM) {
+ if (dbg_do_line(&p_local, buf_size, p_prefix_str,
+ "IB_PORT_CAP_IS_SM\n",
+ &total_len) != IB_SUCCESS)
+ return;
+ }
+ if (p_pi->capability_mask & IB_PORT_CAP_HAS_NOTICE) {
+ if (dbg_do_line(&p_local, buf_size, p_prefix_str,
+ "IB_PORT_CAP_HAS_NOTICE\n",
+ &total_len) != IB_SUCCESS)
+ return;
+ }
+ if (p_pi->capability_mask & IB_PORT_CAP_HAS_TRAP) {
+ if (dbg_do_line(&p_local, buf_size, p_prefix_str,
+ "IB_PORT_CAP_HAS_TRAP\n",
+ &total_len) != IB_SUCCESS)
+ return;
+ }
+ if (p_pi->capability_mask & IB_PORT_CAP_HAS_IPD) {
+ if (dbg_do_line(&p_local, buf_size, p_prefix_str,
+ "IB_PORT_CAP_HAS_IPD\n",
+ &total_len) != IB_SUCCESS)
+ return;
+ }
+ if (p_pi->capability_mask & IB_PORT_CAP_HAS_AUTO_MIG) {
+ if (dbg_do_line(&p_local, buf_size, p_prefix_str,
+ "IB_PORT_CAP_HAS_AUTO_MIG\n",
+ &total_len) != IB_SUCCESS)
+ return;
+ }
+ if (p_pi->capability_mask & IB_PORT_CAP_HAS_SL_MAP) {
+ if (dbg_do_line(&p_local, buf_size, p_prefix_str,
+ "IB_PORT_CAP_HAS_SL_MAP\n",
+ &total_len) != IB_SUCCESS)
+ return;
+ }
+ if (p_pi->capability_mask & IB_PORT_CAP_HAS_NV_MKEY) {
+ if (dbg_do_line(&p_local, buf_size, p_prefix_str,
+ "IB_PORT_CAP_HAS_NV_MKEY\n",
+ &total_len) != IB_SUCCESS)
+ return;
+ }
+ if (p_pi->capability_mask & IB_PORT_CAP_HAS_NV_PKEY) {
+ if (dbg_do_line(&p_local, buf_size, p_prefix_str,
+ "IB_PORT_CAP_HAS_NV_PKEY\n",
+ &total_len) != IB_SUCCESS)
+ return;
+ }
+ if (p_pi->capability_mask & IB_PORT_CAP_HAS_LED_INFO) {
+ if (dbg_do_line(&p_local, buf_size, p_prefix_str,
+ "IB_PORT_CAP_HAS_LED_INFO\n",
+ &total_len) != IB_SUCCESS)
+ return;
+ }
+ if (p_pi->capability_mask & IB_PORT_CAP_SM_DISAB) {
+ if (dbg_do_line(&p_local, buf_size, p_prefix_str,
+ "IB_PORT_CAP_SM_DISAB\n",
+ &total_len) != IB_SUCCESS)
+ return;
+ }
+ if (p_pi->capability_mask & IB_PORT_CAP_HAS_SYS_IMG_GUID) {
+ if (dbg_do_line(&p_local, buf_size, p_prefix_str,
+ "IB_PORT_CAP_HAS_SYS_IMG_GUID\n",
+ &total_len) != IB_SUCCESS)
+ return;
+ }
+ if (p_pi->capability_mask & IB_PORT_CAP_HAS_PKEY_SW_EXT_PORT_TRAP) {
+ if (dbg_do_line(&p_local, buf_size, p_prefix_str,
+ "IB_PORT_CAP_PKEY_SW_EXT_PORT_TRAP\n",
+ &total_len) != IB_SUCCESS)
+ return;
+ }
+ if (p_pi->capability_mask & IB_PORT_CAP_HAS_CABLE_INFO) {
+ if (dbg_do_line(&p_local, buf_size, p_prefix_str,
+ "IB_PORT_CAP_HAS_CABLE_INFO\n",
+ &total_len) != IB_SUCCESS)
+ return;
+ }
+ if (p_pi->capability_mask & IB_PORT_CAP_HAS_EXT_SPEEDS) {
+ if (dbg_do_line(&p_local, buf_size, p_prefix_str,
+ "IB_PORT_CAP_HAS_EXT_SPEEDS\n",
+ &total_len) != IB_SUCCESS)
+ return;
+ }
+ if (p_pi->capability_mask & IB_PORT_CAP_HAS_CAP_MASK2) {
+ if (dbg_do_line(&p_local, buf_size, p_prefix_str,
+ "IB_PORT_CAP_HAS_CAP_MASK2\n",
+ &total_len) != IB_SUCCESS)
+ return;
+ }
+ if (p_pi->capability_mask & IB_PORT_CAP_HAS_COM_MGT) {
+ if (dbg_do_line(&p_local, buf_size, p_prefix_str,
+ "IB_PORT_CAP_HAS_COM_MGT\n",
+ &total_len) != IB_SUCCESS)
+ return;
+ }
+ if (p_pi->capability_mask & IB_PORT_CAP_HAS_SNMP) {
+ if (dbg_do_line(&p_local, buf_size, p_prefix_str,
+ "IB_PORT_CAP_HAS_SNMP\n",
+ &total_len) != IB_SUCCESS)
+ return;
+ }
+ if (p_pi->capability_mask & IB_PORT_CAP_REINIT) {
+ if (dbg_do_line(&p_local, buf_size, p_prefix_str,
+ "IB_PORT_CAP_REINIT\n",
+ &total_len) != IB_SUCCESS)
+ return;
+ }
+ if (p_pi->capability_mask & IB_PORT_CAP_HAS_DEV_MGT) {
+ if (dbg_do_line(&p_local, buf_size, p_prefix_str,
+ "IB_PORT_CAP_HAS_DEV_MGT\n",
+ &total_len) != IB_SUCCESS)
+ return;
+ }
+ if (p_pi->capability_mask & IB_PORT_CAP_HAS_VEND_CLS) {
+ if (dbg_do_line(&p_local, buf_size, p_prefix_str,
+ "IB_PORT_CAP_HAS_VEND_CLS\n",
+ &total_len) != IB_SUCCESS)
+ return;
+ }
+ if (p_pi->capability_mask & IB_PORT_CAP_HAS_DR_NTC) {
+ if (dbg_do_line(&p_local, buf_size, p_prefix_str,
+ "IB_PORT_CAP_HAS_DR_NTC\n",
+ &total_len) != IB_SUCCESS)
+ return;
+ }
+ if (p_pi->capability_mask & IB_PORT_CAP_HAS_CAP_NTC) {
+ if (dbg_do_line(&p_local, buf_size, p_prefix_str,
+ "IB_PORT_CAP_HAS_CAP_NTC\n",
+ &total_len) != IB_SUCCESS)
+ return;
+ }
+ if (p_pi->capability_mask & IB_PORT_CAP_HAS_BM) {
+ if (dbg_do_line(&p_local, buf_size, p_prefix_str,
+ "IB_PORT_CAP_HAS_BM\n",
+ &total_len) != IB_SUCCESS)
+ return;
+ }
+ if (p_pi->capability_mask & IB_PORT_CAP_HAS_LINK_RT_LATENCY) {
+ if (dbg_do_line(&p_local, buf_size, p_prefix_str,
+ "IB_PORT_CAP_HAS_LINK_RT_LATENCY\n",
+ &total_len) != IB_SUCCESS)
+ return;
+ }
+ if (p_pi->capability_mask & IB_PORT_CAP_HAS_CLIENT_REREG) {
+ if (dbg_do_line(&p_local, buf_size, p_prefix_str,
+ "IB_PORT_CAP_HAS_CLIENT_REREG\n",
+ &total_len) != IB_SUCCESS)
+ return;
+ }
+ if (p_pi->capability_mask & IB_PORT_CAP_HAS_OTHER_LOCAL_CHANGES_NTC) {
+ if (dbg_do_line(&p_local, buf_size, p_prefix_str,
+ "IB_PORT_CAP_HAS_OTHER_LOCAL_CHANGES_NTC\n",
+ &total_len) != IB_SUCCESS)
+ return;
+ }
+ if (p_pi->capability_mask & IB_PORT_CAP_HAS_LINK_SPEED_WIDTH_PAIRS_TBL) {
+ if (dbg_do_line(&p_local, buf_size, p_prefix_str,
+ "IB_PORT_CAP_HAS_LINK_SPEED_WIDTH_PAIRS_TBL\n",
+ &total_len) != IB_SUCCESS)
+ return;
+ }
+ if (p_pi->capability_mask & IB_PORT_CAP_HAS_VEND_MADS) {
+ if (dbg_do_line(&p_local, buf_size, p_prefix_str,
+ "IB_PORT_CAP_HAS_VEND_MADS\n",
+ &total_len) != IB_SUCCESS)
+ return;
+ }
+ if (p_pi->capability_mask & IB_PORT_CAP_HAS_MCAST_PKEY_TRAP_SUPPRESS) {
+ if (dbg_do_line(&p_local, buf_size, p_prefix_str,
+ "IB_PORT_CAP_HAS_MCAST_PKEY_TRAP_SUPPRESS\n",
+ &total_len) != IB_SUCCESS)
+ return;
+ }
+ if (p_pi->capability_mask & IB_PORT_CAP_HAS_MCAST_FDB_TOP) {
+ if (dbg_do_line(&p_local, buf_size, p_prefix_str,
+ "IB_PORT_CAP_HAS_MCAST_FDB_TOP\n",
+ &total_len) != IB_SUCCESS)
+ return;
+ }
+ if (p_pi->capability_mask & IB_PORT_CAP_HAS_HIER_INFO) {
+ if (dbg_do_line(&p_local, buf_size, p_prefix_str,
+ "IB_PORT_CAP_HAS_HIER_INFO\n",
+ &total_len) != IB_SUCCESS)
+ return;
+ }
+}
+
+static void dbg_get_capabilities2_str(IN char *p_buf, IN uint32_t buf_size,
+ IN const char *p_prefix_str,
+ IN const ib_port_info_t * p_pi)
+{
+ uint32_t total_len = 0;
+ char *p_local = p_buf;
+
+ strcpy(p_local, "Capability Mask2:\n");
+ p_local += strlen(p_local);
+
+ if (p_pi->capability_mask2 & IB_PORT_CAP2_IS_SET_NODE_DESC_SUPPORTED) {
+ if (dbg_do_line(&p_local, buf_size, p_prefix_str,
+ "IB_PORT_CAP2_IS_SET_NODE_DESC_SUPPORTED\n",
+ &total_len) != IB_SUCCESS)
+ return;
+ }
+ if (p_pi->capability_mask2 & IB_PORT_CAP2_IS_PORT_INFO_EXT_SUPPORTED) {
+ if (dbg_do_line(&p_local, buf_size, p_prefix_str,
+ "IB_PORT_CAP2_IS_PORT_INFO_EXT_SUPPORTED\n",
+ &total_len) != IB_SUCCESS)
+ return;
+ }
+ if (p_pi->capability_mask2 & IB_PORT_CAP2_IS_VIRT_SUPPORTED) {
+ if (dbg_do_line(&p_local, buf_size, p_prefix_str,
+ "IB_PORT_CAP2_IS_VIRT_SUPPORTED\n",
+ &total_len) != IB_SUCCESS)
+ return;
+ }
+ if (p_pi->capability_mask2 & IB_PORT_CAP2_IS_SWITCH_PORT_STATE_TBL_SUPP) {
+ if (dbg_do_line(&p_local, buf_size, p_prefix_str,
+ "IB_PORT_CAP2_IS_SWITCH_PORT_STATE_TBL_SUPP\n",
+ &total_len) != IB_SUCCESS)
+ return;
+ }
+ if (p_pi->capability_mask2 & IB_PORT_CAP2_IS_LINK_WIDTH_2X_SUPPORTED) {
+ if (dbg_do_line(&p_local, buf_size, p_prefix_str,
+ "IB_PORT_CAP2_IS_LINK_WIDTH_2X_SUPPORTED\n",
+ &total_len) != IB_SUCCESS)
+ return;
+ }
+}
+
+static void osm_dump_port_info_to_buf(IN ib_net64_t node_guid,
+ IN ib_net64_t port_guid,
+ IN uint8_t port_num,
+ IN const ib_port_info_t * p_pi,
+ OUT char * buf)
+{
+ if (!buf || !p_pi)
+ return;
+ else {
+ sprintf(buf,
+ "PortInfo dump:\n"
+ "\t\t\t\tport number..............%u\n"
+ "\t\t\t\tnode_guid................0x%016" PRIx64 "\n"
+ "\t\t\t\tport_guid................0x%016" PRIx64 "\n"
+ "\t\t\t\tm_key....................0x%016" PRIx64 "\n"
+ "\t\t\t\tsubnet_prefix............0x%016" PRIx64 "\n"
+ "\t\t\t\tbase_lid.................%u\n"
+ "\t\t\t\tmaster_sm_base_lid.......%u\n"
+ "\t\t\t\tcapability_mask..........0x%X\n"
+ "\t\t\t\tdiag_code................0x%X\n"
+ "\t\t\t\tm_key_lease_period.......0x%X\n"
+ "\t\t\t\tlocal_port_num...........%u\n"
+ "\t\t\t\tlink_width_enabled.......0x%X\n"
+ "\t\t\t\tlink_width_supported.....0x%X\n"
+ "\t\t\t\tlink_width_active........0x%X\n"
+ "\t\t\t\tlink_speed_supported.....0x%X\n"
+ "\t\t\t\tport_state...............%s\n"
+ "\t\t\t\tstate_info2..............0x%X\n"
+ "\t\t\t\tm_key_protect_bits.......0x%X\n"
+ "\t\t\t\tlmc......................0x%X\n"
+ "\t\t\t\tlink_speed...............0x%X\n"
+ "\t\t\t\tmtu_smsl.................0x%X\n"
+ "\t\t\t\tvl_cap_init_type.........0x%X\n"
+ "\t\t\t\tvl_high_limit............0x%X\n"
+ "\t\t\t\tvl_arb_high_cap..........0x%X\n"
+ "\t\t\t\tvl_arb_low_cap...........0x%X\n"
+ "\t\t\t\tinit_rep_mtu_cap.........0x%X\n"
+ "\t\t\t\tvl_stall_life............0x%X\n"
+ "\t\t\t\tvl_enforce...............0x%X\n"
+ "\t\t\t\tm_key_violations.........0x%X\n"
+ "\t\t\t\tp_key_violations.........0x%X\n"
+ "\t\t\t\tq_key_violations.........0x%X\n"
+ "\t\t\t\tguid_cap.................0x%X\n"
+ "\t\t\t\tclient_reregister........0x%X\n"
+ "\t\t\t\tmcast_pkey_trap_suppr....0x%X\n"
+ "\t\t\t\tsubnet_timeout...........0x%X\n"
+ "\t\t\t\tresp_time_value..........0x%X\n"
+ "\t\t\t\terror_threshold..........0x%X\n"
+ "\t\t\t\tmax_credit_hint..........0x%X\n"
+ "\t\t\t\tlink_round_trip_latency..0x%X\n"
+ "\t\t\t\tcapability_mask2.........0x%X\n"
+ "\t\t\t\tlink_speed_ext_active....0x%X\n"
+ "\t\t\t\tlink_speed_ext_supported.0x%X\n"
+ "\t\t\t\tlink_speed_ext_enabled...0x%X\n",
+ port_num, cl_ntoh64(node_guid), cl_ntoh64(port_guid),
+ cl_ntoh64(p_pi->m_key), cl_ntoh64(p_pi->subnet_prefix),
+ cl_ntoh16(p_pi->base_lid),
+ cl_ntoh16(p_pi->master_sm_base_lid),
+ cl_ntoh32(p_pi->capability_mask),
+ cl_ntoh16(p_pi->diag_code),
+ cl_ntoh16(p_pi->m_key_lease_period),
+ p_pi->local_port_num, p_pi->link_width_enabled,
+ p_pi->link_width_supported, p_pi->link_width_active,
+ ib_port_info_get_link_speed_sup(p_pi),
+ ib_get_port_state_str(ib_port_info_get_port_state
+ (p_pi)), p_pi->state_info2,
+ ib_port_info_get_mpb(p_pi), ib_port_info_get_lmc(p_pi),
+ p_pi->link_speed, p_pi->mtu_smsl, p_pi->vl_cap,
+ p_pi->vl_high_limit, p_pi->vl_arb_high_cap,
+ p_pi->vl_arb_low_cap, p_pi->mtu_cap,
+ p_pi->vl_stall_life, p_pi->vl_enforce,
+ cl_ntoh16(p_pi->m_key_violations),
+ cl_ntoh16(p_pi->p_key_violations),
+ cl_ntoh16(p_pi->q_key_violations), p_pi->guid_cap,
+ ib_port_info_get_client_rereg(p_pi),
+ ib_port_info_get_mcast_pkey_trap_suppress(p_pi),
+ ib_port_info_get_timeout(p_pi),
+ ib_port_info_get_resp_time_value(p_pi),
+ p_pi->error_threshold, cl_ntoh16(p_pi->max_credit_hint),
+ cl_ntoh32(p_pi->link_rt_latency),
+ cl_ntoh16(p_pi->capability_mask2),
+ ib_port_info_get_link_speed_ext_active(p_pi),
+ ib_port_info_get_link_speed_ext_sup(p_pi),
+ p_pi->link_speed_ext_enabled);
+ }
+}
+
+void osm_dump_port_info(IN osm_log_t * p_log, IN ib_net64_t node_guid,
+ IN ib_net64_t port_guid, IN uint8_t port_num,
+ IN const ib_port_info_t * p_pi,
+ IN osm_log_level_t log_level)
+{
+ if (osm_log_is_active(p_log, log_level)) {
+ char buf[BUF_SIZE];
+
+ osm_dump_port_info_to_buf(node_guid, port_guid,
+ port_num, p_pi, buf);
+
+ osm_log(p_log, log_level, "%s", buf);
+
+ /* show the capabilities masks */
+ if (p_pi->capability_mask) {
+ dbg_get_capabilities_str(buf, BUF_SIZE, "\t\t\t\t",
+ p_pi);
+ osm_log(p_log, log_level, "%s", buf);
+ }
+ if ((p_pi->capability_mask & IB_PORT_CAP_HAS_CAP_MASK2) &&
+ p_pi->capability_mask2) {
+ dbg_get_capabilities2_str(buf, BUF_SIZE, "\t\t\t\t",
+ p_pi);
+ osm_log(p_log, log_level, "%s", buf);
+ }
+ }
+}
+
+void osm_dump_port_info_v2(IN osm_log_t * p_log, IN ib_net64_t node_guid,
+ IN ib_net64_t port_guid, IN uint8_t port_num,
+ IN const ib_port_info_t * p_pi, IN const int file_id,
+ IN osm_log_level_t log_level)
+{
+ if (osm_log_is_active_v2(p_log, log_level, file_id)) {
+ char buf[BUF_SIZE];
+
+ osm_dump_port_info_to_buf(node_guid, port_guid,
+ port_num, p_pi, buf);
+
+ osm_log_v2(p_log, log_level, file_id, "%s", buf);
+
+ /* show the capabilities masks */
+ if (p_pi->capability_mask) {
+ dbg_get_capabilities_str(buf, BUF_SIZE, "\t\t\t\t",
+ p_pi);
+ osm_log_v2(p_log, log_level, file_id, "%s", buf);
+ }
+ if ((p_pi->capability_mask & IB_PORT_CAP_HAS_CAP_MASK2) &&
+ p_pi->capability_mask2) {
+ dbg_get_capabilities2_str(buf, BUF_SIZE, "\t\t\t\t",
+ p_pi);
+ osm_log(p_log, log_level, "%s", buf);
+ }
+ }
+}
+
+static void osm_dump_mlnx_ext_port_info_to_buf(IN ib_net64_t node_guid,
+ IN ib_net64_t port_guid, IN uint8_t port_num,
+ IN const ib_mlnx_ext_port_info_t * p_pi,
+ OUT char * buf)
+{
+ if (!buf || !p_pi)
+ return;
+ else {
+ sprintf(buf,
+ "MLNX ExtendedPortInfo dump:\n"
+ "\t\t\t\tport number..............%u\n"
+ "\t\t\t\tnode_guid................0x%016" PRIx64 "\n"
+ "\t\t\t\tport_guid................0x%016" PRIx64 "\n"
+ "\t\t\t\tStateChangeEnable........0x%X\n"
+ "\t\t\t\tLinkSpeedSupported.......0x%X\n"
+ "\t\t\t\tLinkSpeedEnabled.........0x%X\n"
+ "\t\t\t\tLinkSpeedActive..........0x%X\n",
+ port_num, cl_ntoh64(node_guid), cl_ntoh64(port_guid),
+ p_pi->state_change_enable, p_pi->link_speed_supported,
+ p_pi->link_speed_enabled, p_pi->link_speed_active);
+ }
+}
+
+void osm_dump_mlnx_ext_port_info(IN osm_log_t * p_log, IN ib_net64_t node_guid,
+ IN ib_net64_t port_guid, IN uint8_t port_num,
+ IN const ib_mlnx_ext_port_info_t * p_pi,
+ IN osm_log_level_t log_level)
+{
+ if (osm_log_is_active(p_log, log_level)) {
+ char buf[BUF_SIZE];
+
+ osm_dump_mlnx_ext_port_info_to_buf(node_guid, port_guid,
+ port_num, p_pi, buf);
+
+ osm_log(p_log, log_level, "%s", buf);
+ }
+}
+
+void osm_dump_mlnx_ext_port_info_v2(IN osm_log_t * p_log, IN ib_net64_t node_guid,
+ IN ib_net64_t port_guid, IN uint8_t port_num,
+ IN const ib_mlnx_ext_port_info_t * p_pi,
+ IN const int file_id, IN osm_log_level_t log_level)
+{
+ if (osm_log_is_active_v2(p_log, log_level, file_id)) {
+ char buf[BUF_SIZE];
+
+ osm_dump_mlnx_ext_port_info_to_buf(node_guid, port_guid,
+ port_num, p_pi, buf);
+
+ osm_log_v2(p_log, log_level, file_id, "%s", buf);
+ }
+}
+
+static void osm_dump_portinfo_record_to_buf(IN const ib_portinfo_record_t * p_pir,
+ OUT char * buf)
+{
+ if (!buf || !p_pir)
+ return;
+ else {
+ const ib_port_info_t *p_pi = &p_pir->port_info;
+
+ sprintf(buf,
+ "PortInfo Record dump:\n"
+ "\t\t\t\tRID\n"
+ "\t\t\t\tEndPortLid...............%u\n"
+ "\t\t\t\tPortNum..................%u\n"
+ "\t\t\t\tOptions..................0x%X\n"
+ "\t\t\t\tPortInfo dump:\n"
+ "\t\t\t\tm_key....................0x%016" PRIx64 "\n"
+ "\t\t\t\tsubnet_prefix............0x%016" PRIx64 "\n"
+ "\t\t\t\tbase_lid.................%u\n"
+ "\t\t\t\tmaster_sm_base_lid.......%u\n"
+ "\t\t\t\tcapability_mask..........0x%X\n"
+ "\t\t\t\tdiag_code................0x%X\n"
+ "\t\t\t\tm_key_lease_period.......0x%X\n"
+ "\t\t\t\tlocal_port_num...........%u\n"
+ "\t\t\t\tlink_width_enabled.......0x%X\n"
+ "\t\t\t\tlink_width_supported.....0x%X\n"
+ "\t\t\t\tlink_width_active........0x%X\n"
+ "\t\t\t\tlink_speed_supported.....0x%X\n"
+ "\t\t\t\tport_state...............%s\n"
+ "\t\t\t\tstate_info2..............0x%X\n"
+ "\t\t\t\tm_key_protect_bits.......0x%X\n"
+ "\t\t\t\tlmc......................0x%X\n"
+ "\t\t\t\tlink_speed...............0x%X\n"
+ "\t\t\t\tmtu_smsl.................0x%X\n"
+ "\t\t\t\tvl_cap_init_type.........0x%X\n"
+ "\t\t\t\tvl_high_limit............0x%X\n"
+ "\t\t\t\tvl_arb_high_cap..........0x%X\n"
+ "\t\t\t\tvl_arb_low_cap...........0x%X\n"
+ "\t\t\t\tinit_rep_mtu_cap.........0x%X\n"
+ "\t\t\t\tvl_stall_life............0x%X\n"
+ "\t\t\t\tvl_enforce...............0x%X\n"
+ "\t\t\t\tm_key_violations.........0x%X\n"
+ "\t\t\t\tp_key_violations.........0x%X\n"
+ "\t\t\t\tq_key_violations.........0x%X\n"
+ "\t\t\t\tguid_cap.................0x%X\n"
+ "\t\t\t\tclient_reregister........0x%X\n"
+ "\t\t\t\tmcast_pkey_trap_suppr....0x%X\n"
+ "\t\t\t\tsubnet_timeout...........0x%X\n"
+ "\t\t\t\tresp_time_value..........0x%X\n"
+ "\t\t\t\terror_threshold..........0x%X\n"
+ "\t\t\t\tmax_credit_hint..........0x%X\n"
+ "\t\t\t\tlink_round_trip_latency..0x%X\n"
+ "\t\t\t\tcapability_mask2.........0x%X\n"
+ "\t\t\t\tlink_speed_ext_active....0x%X\n"
+ "\t\t\t\tlink_speed_ext_supported.0x%X\n"
+ "\t\t\t\tlink_speed_ext_enabled...0x%X\n",
+ cl_ntoh16(p_pir->lid), p_pir->port_num, p_pir->options,
+ cl_ntoh64(p_pi->m_key), cl_ntoh64(p_pi->subnet_prefix),
+ cl_ntoh16(p_pi->base_lid),
+ cl_ntoh16(p_pi->master_sm_base_lid),
+ cl_ntoh32(p_pi->capability_mask),
+ cl_ntoh16(p_pi->diag_code),
+ cl_ntoh16(p_pi->m_key_lease_period),
+ p_pi->local_port_num, p_pi->link_width_enabled,
+ p_pi->link_width_supported, p_pi->link_width_active,
+ ib_port_info_get_link_speed_sup(p_pi),
+ ib_get_port_state_str(ib_port_info_get_port_state
+ (p_pi)), p_pi->state_info2,
+ ib_port_info_get_mpb(p_pi), ib_port_info_get_lmc(p_pi),
+ p_pi->link_speed, p_pi->mtu_smsl, p_pi->vl_cap,
+ p_pi->vl_high_limit, p_pi->vl_arb_high_cap,
+ p_pi->vl_arb_low_cap, p_pi->mtu_cap,
+ p_pi->vl_stall_life, p_pi->vl_enforce,
+ cl_ntoh16(p_pi->m_key_violations),
+ cl_ntoh16(p_pi->p_key_violations),
+ cl_ntoh16(p_pi->q_key_violations), p_pi->guid_cap,
+ ib_port_info_get_client_rereg(p_pi),
+ ib_port_info_get_mcast_pkey_trap_suppress(p_pi),
+ ib_port_info_get_timeout(p_pi),
+ ib_port_info_get_resp_time_value(p_pi),
+ p_pi->error_threshold, cl_ntoh16(p_pi->max_credit_hint),
+ cl_ntoh32(p_pi->link_rt_latency),
+ cl_ntoh16(p_pi->capability_mask2),
+ ib_port_info_get_link_speed_ext_active(p_pi),
+ ib_port_info_get_link_speed_ext_sup(p_pi),
+ p_pi->link_speed_ext_enabled);
+ }
+}
+
+void osm_dump_portinfo_record(IN osm_log_t * p_log,
+ IN const ib_portinfo_record_t * p_pir,
+ IN osm_log_level_t log_level)
+{
+ if (osm_log_is_active(p_log, log_level)) {
+ char buf[BUF_SIZE];
+ const ib_port_info_t *p_pi = &p_pir->port_info;
+
+ osm_dump_portinfo_record_to_buf(p_pir, buf);
+
+ osm_log(p_log, log_level, "%s", buf);
+
+ /* show the capabilities masks */
+ if (p_pi->capability_mask) {
+ dbg_get_capabilities_str(buf, BUF_SIZE, "\t\t\t\t",
+ p_pi);
+ osm_log(p_log, log_level, "%s", buf);
+ }
+ if ((p_pi->capability_mask & IB_PORT_CAP_HAS_CAP_MASK2) &&
+ p_pi->capability_mask2) {
+ dbg_get_capabilities2_str(buf, BUF_SIZE, "\t\t\t\t",
+ p_pi);
+ osm_log(p_log, log_level, "%s", buf);
+ }
+ }
+}
+
+void osm_dump_portinfo_record_v2(IN osm_log_t * p_log,
+ IN const ib_portinfo_record_t * p_pir,
+ IN const int file_id,
+ IN osm_log_level_t log_level)
+{
+ if (osm_log_is_active_v2(p_log, log_level, file_id)) {
+ char buf[BUF_SIZE];
+ const ib_port_info_t *p_pi = &p_pir->port_info;
+
+ osm_dump_portinfo_record_to_buf(p_pir, buf);
+
+ osm_log_v2(p_log, log_level, file_id, "%s", buf);
+
+ /* show the capabilities masks */
+ if (p_pi->capability_mask) {
+ dbg_get_capabilities_str(buf, BUF_SIZE, "\t\t\t\t",
+ p_pi);
+ osm_log_v2(p_log, log_level, file_id, "%s", buf);
+ }
+ if ((p_pi->capability_mask & IB_PORT_CAP_HAS_CAP_MASK2) &&
+ p_pi->capability_mask2) {
+ dbg_get_capabilities2_str(buf, BUF_SIZE, "\t\t\t\t",
+ p_pi);
+ osm_log(p_log, log_level, "%s", buf);
+ }
+ }
+}
+
+static void osm_dump_guid_info_to_buf(IN ib_net64_t node_guid,
+ IN ib_net64_t port_guid,
+ IN uint8_t block_num,
+ IN const ib_guid_info_t * p_gi,
+ OUT char * buf)
+{
+ if (!buf || !p_gi)
+ return;
+ else {
+ sprintf(buf,
+ "GUIDInfo dump:\n"
+ "\t\t\t\tblock number............%u\n"
+ "\t\t\t\tnode_guid...............0x%016" PRIx64 "\n"
+ "\t\t\t\tport_guid...............0x%016" PRIx64 "\n"
+ "\t\t\t\tGUID 0..................0x%016" PRIx64 "\n"
+ "\t\t\t\tGUID 1..................0x%016" PRIx64 "\n"
+ "\t\t\t\tGUID 2..................0x%016" PRIx64 "\n"
+ "\t\t\t\tGUID 3..................0x%016" PRIx64 "\n"
+ "\t\t\t\tGUID 4..................0x%016" PRIx64 "\n"
+ "\t\t\t\tGUID 5..................0x%016" PRIx64 "\n"
+ "\t\t\t\tGUID 6..................0x%016" PRIx64 "\n"
+ "\t\t\t\tGUID 7..................0x%016" PRIx64 "\n",
+ block_num, cl_ntoh64(node_guid), cl_ntoh64(port_guid),
+ cl_ntoh64(p_gi->guid[0]), cl_ntoh64(p_gi->guid[1]),
+ cl_ntoh64(p_gi->guid[2]), cl_ntoh64(p_gi->guid[3]),
+ cl_ntoh64(p_gi->guid[4]), cl_ntoh64(p_gi->guid[5]),
+ cl_ntoh64(p_gi->guid[6]), cl_ntoh64(p_gi->guid[7]));
+ }
+}
+
+void osm_dump_guid_info(IN osm_log_t * p_log, IN ib_net64_t node_guid,
+ IN ib_net64_t port_guid, IN uint8_t block_num,
+ IN const ib_guid_info_t * p_gi,
+ IN osm_log_level_t log_level)
+{
+ if (osm_log_is_active(p_log, log_level)) {
+ char buf[BUF_SIZE];
+
+ osm_dump_guid_info_to_buf(node_guid, port_guid,
+ block_num, p_gi, buf);
+
+ osm_log(p_log, log_level, "%s", buf);
+ }
+}
+
+void osm_dump_guid_info_v2(IN osm_log_t * p_log, IN ib_net64_t node_guid,
+ IN ib_net64_t port_guid, IN uint8_t block_num,
+ IN const ib_guid_info_t * p_gi,
+ IN const int file_id,
+ IN osm_log_level_t log_level)
+{
+ if (osm_log_is_active_v2(p_log, log_level, file_id)) {
+ char buf[BUF_SIZE];
+
+ osm_dump_guid_info_to_buf(node_guid, port_guid,
+ block_num, p_gi, buf);
+
+ osm_log_v2(p_log, log_level, file_id, "%s", buf);
+ }
+}
+
+static void osm_dump_guidinfo_record_to_buf(IN const ib_guidinfo_record_t * p_gir,
+ OUT char * buf)
+{
+ if (!buf || !p_gir)
+ return;
+ else {
+ const ib_guid_info_t *p_gi = &p_gir->guid_info;
+
+ sprintf(buf,
+ "GUIDInfo Record dump:\n"
+ "\t\t\t\tRID\n"
+ "\t\t\t\tLid.....................%u\n"
+ "\t\t\t\tBlockNum................0x%X\n"
+ "\t\t\t\tReserved................0x%X\n"
+ "\t\t\t\tGUIDInfo dump:\n"
+ "\t\t\t\tReserved................0x%X\n"
+ "\t\t\t\tGUID 0..................0x%016" PRIx64 "\n"
+ "\t\t\t\tGUID 1..................0x%016" PRIx64 "\n"
+ "\t\t\t\tGUID 2..................0x%016" PRIx64 "\n"
+ "\t\t\t\tGUID 3..................0x%016" PRIx64 "\n"
+ "\t\t\t\tGUID 4..................0x%016" PRIx64 "\n"
+ "\t\t\t\tGUID 5..................0x%016" PRIx64 "\n"
+ "\t\t\t\tGUID 6..................0x%016" PRIx64 "\n"
+ "\t\t\t\tGUID 7..................0x%016" PRIx64 "\n",
+ cl_ntoh16(p_gir->lid), p_gir->block_num, p_gir->resv,
+ cl_ntoh32(p_gir->reserved),
+ cl_ntoh64(p_gi->guid[0]), cl_ntoh64(p_gi->guid[1]),
+ cl_ntoh64(p_gi->guid[2]), cl_ntoh64(p_gi->guid[3]),
+ cl_ntoh64(p_gi->guid[4]), cl_ntoh64(p_gi->guid[5]),
+ cl_ntoh64(p_gi->guid[6]), cl_ntoh64(p_gi->guid[7]));
+ }
+}
+void osm_dump_guidinfo_record(IN osm_log_t * p_log,
+ IN const ib_guidinfo_record_t * p_gir,
+ IN osm_log_level_t log_level)
+{
+ if (osm_log_is_active(p_log, log_level)) {
+ char buf[BUF_SIZE];
+
+ osm_dump_guidinfo_record_to_buf(p_gir, buf);
+
+ osm_log(p_log, log_level, "%s", buf);
+ }
+}
+
+void osm_dump_guidinfo_record_v2(IN osm_log_t * p_log,
+ IN const ib_guidinfo_record_t * p_gir,
+ IN const int file_id,
+ IN osm_log_level_t log_level)
+{
+ if (osm_log_is_active_v2(p_log, log_level, file_id)) {
+ char buf[BUF_SIZE];
+
+ osm_dump_guidinfo_record_to_buf(p_gir, buf);
+
+ osm_log_v2(p_log, log_level, file_id, "%s", buf);
+ }
+}
+
+static void osm_dump_node_info_to_buf(IN const ib_node_info_t * p_ni,
+ OUT char * buf)
+{
+ if (!buf || !p_ni)
+ return;
+ else {
+ sprintf(buf,
+ "NodeInfo dump:\n"
+ "\t\t\t\tbase_version............0x%X\n"
+ "\t\t\t\tclass_version...........0x%X\n"
+ "\t\t\t\tnode_type...............%s\n"
+ "\t\t\t\tnum_ports...............%u\n"
+ "\t\t\t\tsys_guid................0x%016" PRIx64 "\n"
+ "\t\t\t\tnode_guid...............0x%016" PRIx64 "\n"
+ "\t\t\t\tport_guid...............0x%016" PRIx64 "\n"
+ "\t\t\t\tpartition_cap...........0x%X\n"
+ "\t\t\t\tdevice_id...............0x%X\n"
+ "\t\t\t\trevision................0x%X\n"
+ "\t\t\t\tport_num................%u\n"
+ "\t\t\t\tvendor_id...............0x%X\n",
+ p_ni->base_version, p_ni->class_version,
+ ib_get_node_type_str(p_ni->node_type), p_ni->num_ports,
+ cl_ntoh64(p_ni->sys_guid), cl_ntoh64(p_ni->node_guid),
+ cl_ntoh64(p_ni->port_guid),
+ cl_ntoh16(p_ni->partition_cap),
+ cl_ntoh16(p_ni->device_id), cl_ntoh32(p_ni->revision),
+ ib_node_info_get_local_port_num(p_ni),
+ cl_ntoh32(ib_node_info_get_vendor_id(p_ni)));
+ }
+}
+
+void osm_dump_node_info(IN osm_log_t * p_log, IN const ib_node_info_t * p_ni,
+ IN osm_log_level_t log_level)
+{
+ if (osm_log_is_active(p_log, log_level)) {
+ char buf[BUF_SIZE];
+
+ osm_dump_node_info_to_buf(p_ni, buf);
+
+ osm_log(p_log, log_level, "%s", buf);
+ }
+}
+
+void osm_dump_node_info_v2(IN osm_log_t * p_log, IN const ib_node_info_t * p_ni,
+ IN const int file_id, IN osm_log_level_t log_level)
+{
+ if (osm_log_is_active_v2(p_log, log_level, file_id)) {
+ char buf[BUF_SIZE];
+
+ osm_dump_node_info_to_buf(p_ni, buf);
+
+ osm_log_v2(p_log, log_level, file_id, "%s", buf);
+ }
+}
+
+static void osm_dump_node_record_to_buf(IN const ib_node_record_t * p_nr,
+ OUT char * buf)
+{
+ if (!buf || !p_nr)
+ return;
+ else {
+ char desc[sizeof(p_nr->node_desc.description) + 1];
+ const ib_node_info_t *p_ni = &p_nr->node_info;
+
+ memcpy(desc, p_nr->node_desc.description,
+ sizeof(p_nr->node_desc.description));
+ desc[sizeof(desc) - 1] = '\0';
+ sprintf(buf,
+ "Node Record dump:\n"
+ "\t\t\t\tRID\n"
+ "\t\t\t\tLid.....................%u\n"
+ "\t\t\t\tReserved................0x%X\n"
+ "\t\t\t\tNodeInfo dump:\n"
+ "\t\t\t\tbase_version............0x%X\n"
+ "\t\t\t\tclass_version...........0x%X\n"
+ "\t\t\t\tnode_type...............%s\n"
+ "\t\t\t\tnum_ports...............%u\n"
+ "\t\t\t\tsys_guid................0x%016" PRIx64 "\n"
+ "\t\t\t\tnode_guid...............0x%016" PRIx64 "\n"
+ "\t\t\t\tport_guid...............0x%016" PRIx64 "\n"
+ "\t\t\t\tpartition_cap...........0x%X\n"
+ "\t\t\t\tdevice_id...............0x%X\n"
+ "\t\t\t\trevision................0x%X\n"
+ "\t\t\t\tport_num................%u\n"
+ "\t\t\t\tvendor_id...............0x%X\n"
+ "\t\t\t\tNodeDescription\n"
+ "\t\t\t\t%s\n",
+ cl_ntoh16(p_nr->lid), cl_ntoh16(p_nr->resv),
+ p_ni->base_version, p_ni->class_version,
+ ib_get_node_type_str(p_ni->node_type), p_ni->num_ports,
+ cl_ntoh64(p_ni->sys_guid), cl_ntoh64(p_ni->node_guid),
+ cl_ntoh64(p_ni->port_guid),
+ cl_ntoh16(p_ni->partition_cap),
+ cl_ntoh16(p_ni->device_id), cl_ntoh32(p_ni->revision),
+ ib_node_info_get_local_port_num(p_ni),
+ cl_ntoh32(ib_node_info_get_vendor_id(p_ni)), desc);
+ }
+}
+
+void osm_dump_node_record(IN osm_log_t * p_log,
+ IN const ib_node_record_t * p_nr,
+ IN osm_log_level_t log_level)
+{
+ if (osm_log_is_active(p_log, log_level)) {
+ char buf[BUF_SIZE];
+
+ osm_dump_node_record_to_buf(p_nr, buf);
+
+ osm_log(p_log, log_level, "%s", buf);
+ }
+}
+
+void osm_dump_node_record_v2(IN osm_log_t * p_log,
+ IN const ib_node_record_t * p_nr,
+ IN const int file_id,
+ IN osm_log_level_t log_level)
+{
+ if (osm_log_is_active_v2(p_log, log_level, file_id)) {
+ char buf[BUF_SIZE];
+
+ osm_dump_node_record_to_buf(p_nr, buf);
+
+ osm_log_v2(p_log, log_level, file_id, "%s", buf);
+ }
+}
+
+static void osm_dump_path_record_to_buf(IN const ib_path_rec_t * p_pr,
+ OUT char * buf)
+{
+ if (!buf || !p_pr)
+ return;
+ else {
+ char gid_str[INET6_ADDRSTRLEN];
+ char gid_str2[INET6_ADDRSTRLEN];
+
+ sprintf(buf,
+ "PathRecord dump:\n"
+ "\t\t\t\tservice_id..............0x%016" PRIx64 "\n"
+ "\t\t\t\tdgid....................%s\n"
+ "\t\t\t\tsgid....................%s\n"
+ "\t\t\t\tdlid....................%u\n"
+ "\t\t\t\tslid....................%u\n"
+ "\t\t\t\thop_flow_raw............0x%X\n"
+ "\t\t\t\ttclass..................0x%X\n"
+ "\t\t\t\tnum_path_revers.........0x%X\n"
+ "\t\t\t\tpkey....................0x%X\n"
+ "\t\t\t\tqos_class...............0x%X\n"
+ "\t\t\t\tsl......................0x%X\n"
+ "\t\t\t\tmtu.....................0x%X\n"
+ "\t\t\t\trate....................0x%X\n"
+ "\t\t\t\tpkt_life................0x%X\n"
+ "\t\t\t\tpreference..............0x%X\n"
+ "\t\t\t\tresv2...................0x%02X%02X%02X%02X%02X%02X\n",
+ cl_ntoh64(p_pr->service_id),
+ inet_ntop(AF_INET6, p_pr->dgid.raw, gid_str,
+ sizeof gid_str),
+ inet_ntop(AF_INET6, p_pr->sgid.raw, gid_str2,
+ sizeof gid_str2),
+ cl_ntoh16(p_pr->dlid), cl_ntoh16(p_pr->slid),
+ cl_ntoh32(p_pr->hop_flow_raw), p_pr->tclass,
+ p_pr->num_path, cl_ntoh16(p_pr->pkey),
+ ib_path_rec_qos_class(p_pr), ib_path_rec_sl(p_pr),
+ p_pr->mtu, p_pr->rate, p_pr->pkt_life, p_pr->preference,
+ p_pr->resv2[0], p_pr->resv2[1], p_pr->resv2[2],
+ p_pr->resv2[3], p_pr->resv2[4], p_pr->resv2[5]);
+ }
+}
+
+void osm_dump_path_record(IN osm_log_t * p_log, IN const ib_path_rec_t * p_pr,
+ IN osm_log_level_t log_level)
+{
+ if (osm_log_is_active(p_log, log_level)) {
+ char buf[BUF_SIZE];
+
+ osm_dump_path_record_to_buf(p_pr, buf);
+
+ osm_log(p_log, log_level, "%s", buf);
+ }
+}
+
+void osm_dump_path_record_v2(IN osm_log_t * p_log, IN const ib_path_rec_t * p_pr,
+ IN const int file_id, IN osm_log_level_t log_level)
+{
+ if (osm_log_is_active_v2(p_log, log_level, file_id)) {
+ char buf[BUF_SIZE];
+
+ osm_dump_path_record_to_buf(p_pr, buf);
+
+ osm_log_v2(p_log, log_level, file_id, "%s", buf);
+ }
+}
+
+static void osm_dump_multipath_record_to_buf(IN const ib_multipath_rec_t * p_mpr,
+ OUT char * buf)
+{
+ if (!buf || !p_mpr)
+ return;
+ else {
+ char gid_str[INET6_ADDRSTRLEN];
+ char buf_line[1024];
+ ib_gid_t const *p_gid = p_mpr->gids;
+ int i, n = 0;
+
+ if (p_mpr->sgid_count) {
+ for (i = 0; i < p_mpr->sgid_count; i++) {
+ n += sprintf(buf_line + n,
+ "\t\t\t\tsgid%02d.................."
+ "%s\n", i + 1,
+ inet_ntop(AF_INET6, p_gid->raw,
+ gid_str,
+ sizeof gid_str));
+ p_gid++;
+ }
+ }
+ if (p_mpr->dgid_count) {
+ for (i = 0; i < p_mpr->dgid_count; i++) {
+ n += sprintf(buf_line + n,
+ "\t\t\t\tdgid%02d.................."
+ "%s\n", i + 1,
+ inet_ntop(AF_INET6, p_gid->raw,
+ gid_str,
+ sizeof gid_str));
+ p_gid++;
+ }
+ }
+ sprintf(buf,
+ "MultiPath Record dump:\n"
+ "\t\t\t\thop_flow_raw............0x%X\n"
+ "\t\t\t\ttclass..................0x%X\n"
+ "\t\t\t\tnum_path_revers.........0x%X\n"
+ "\t\t\t\tpkey....................0x%X\n"
+ "\t\t\t\tqos_class...............0x%X\n"
+ "\t\t\t\tsl......................0x%X\n"
+ "\t\t\t\tmtu.....................0x%X\n"
+ "\t\t\t\trate....................0x%X\n"
+ "\t\t\t\tpkt_life................0x%X\n"
+ "\t\t\t\tindependence............0x%X\n"
+ "\t\t\t\tsgid_count..............0x%X\n"
+ "\t\t\t\tdgid_count..............0x%X\n"
+ "\t\t\t\tservice_id..............0x%016" PRIx64 "\n"
+ "%s\n",
+ cl_ntoh32(p_mpr->hop_flow_raw), p_mpr->tclass,
+ p_mpr->num_path, cl_ntoh16(p_mpr->pkey),
+ ib_multipath_rec_qos_class(p_mpr),
+ ib_multipath_rec_sl(p_mpr), p_mpr->mtu, p_mpr->rate,
+ p_mpr->pkt_life, p_mpr->independence,
+ p_mpr->sgid_count, p_mpr->dgid_count,
+ cl_ntoh64(ib_multipath_rec_service_id(p_mpr)),
+ buf_line);
+ }
+}
+
+void osm_dump_multipath_record(IN osm_log_t * p_log,
+ IN const ib_multipath_rec_t * p_mpr,
+ IN osm_log_level_t log_level)
+{
+ if (osm_log_is_active(p_log, log_level)) {
+ char buf[BUF_SIZE];
+
+ osm_dump_multipath_record_to_buf(p_mpr, buf);
+
+ osm_log(p_log, log_level, "%s", buf);
+ }
+}
+
+void osm_dump_multipath_record_v2(IN osm_log_t * p_log,
+ IN const ib_multipath_rec_t * p_mpr,
+ IN const int file_id,
+ IN osm_log_level_t log_level)
+{
+ if (osm_log_is_active_v2(p_log, log_level, file_id)) {
+ char buf[BUF_SIZE];
+
+ osm_dump_multipath_record_to_buf(p_mpr, buf);
+
+ osm_log_v2(p_log, log_level, file_id, "%s", buf);
+ }
+}
+
+static void osm_dump_mc_record_to_buf(IN const ib_member_rec_t * p_mcmr,
+ OUT char * buf)
+{
+ if(!buf || !p_mcmr)
+ return;
+ else {
+ char gid_str[INET6_ADDRSTRLEN];
+ char gid_str2[INET6_ADDRSTRLEN];
+
+ sprintf(buf,
+ "MCMember Record dump:\n"
+ "\t\t\t\tMGID....................%s\n"
+ "\t\t\t\tPortGid.................%s\n"
+ "\t\t\t\tqkey....................0x%X\n"
+ "\t\t\t\tmlid....................0x%X\n"
+ "\t\t\t\tmtu.....................0x%X\n"
+ "\t\t\t\tTClass..................0x%X\n"
+ "\t\t\t\tpkey....................0x%X\n"
+ "\t\t\t\trate....................0x%X\n"
+ "\t\t\t\tpkt_life................0x%X\n"
+ "\t\t\t\tSLFlowLabelHopLimit.....0x%X\n"
+ "\t\t\t\tScopeState..............0x%X\n"
+ "\t\t\t\tProxyJoin...............0x%X\n",
+ inet_ntop(AF_INET6, p_mcmr->mgid.raw, gid_str,
+ sizeof gid_str),
+ inet_ntop(AF_INET6, p_mcmr->port_gid.raw, gid_str2,
+ sizeof gid_str2),
+ cl_ntoh32(p_mcmr->qkey), cl_ntoh16(p_mcmr->mlid),
+ p_mcmr->mtu, p_mcmr->tclass, cl_ntoh16(p_mcmr->pkey),
+ p_mcmr->rate, p_mcmr->pkt_life,
+ cl_ntoh32(p_mcmr->sl_flow_hop),
+ p_mcmr->scope_state, p_mcmr->proxy_join);
+ }
+}
+
+void osm_dump_mc_record(IN osm_log_t * p_log, IN const ib_member_rec_t * p_mcmr,
+ IN osm_log_level_t log_level)
+{
+ if (osm_log_is_active(p_log, log_level)) {
+ char buf[BUF_SIZE];
+
+ osm_dump_mc_record_to_buf(p_mcmr, buf);
+
+ osm_log(p_log, log_level, "%s", buf);
+ }
+}
+
+void osm_dump_mc_record_v2(IN osm_log_t * p_log, IN const ib_member_rec_t * p_mcmr,
+ IN const int file_id, IN osm_log_level_t log_level)
+{
+ if (osm_log_is_active_v2(p_log, log_level, file_id)) {
+ char buf[BUF_SIZE];
+
+ osm_dump_mc_record_to_buf(p_mcmr, buf);
+
+ osm_log_v2(p_log, log_level, file_id, "%s", buf);
+ }
+}
+
+static void osm_dump_service_record_to_buf(IN const ib_service_record_t * p_sr,
+ OUT char * buf)
+{
+ if (!buf || !p_sr)
+ return;
+ else {
+ char gid_str[INET6_ADDRSTRLEN];
+ char buf_service_key[35];
+ char buf_service_name[65];
+
+ sprintf(buf_service_key,
+ "0x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x",
+ p_sr->service_key[0], p_sr->service_key[1],
+ p_sr->service_key[2], p_sr->service_key[3],
+ p_sr->service_key[4], p_sr->service_key[5],
+ p_sr->service_key[6], p_sr->service_key[7],
+ p_sr->service_key[8], p_sr->service_key[9],
+ p_sr->service_key[10], p_sr->service_key[11],
+ p_sr->service_key[12], p_sr->service_key[13],
+ p_sr->service_key[14], p_sr->service_key[15]);
+ strncpy(buf_service_name, (char *)p_sr->service_name, 64);
+ buf_service_name[64] = '\0';
+
+ sprintf(buf,
+ "Service Record dump:\n"
+ "\t\t\t\tServiceID...............0x%016" PRIx64 "\n"
+ "\t\t\t\tServiceGID..............%s\n"
+ "\t\t\t\tServiceP_Key............0x%X\n"
+ "\t\t\t\tServiceLease............0x%X\n"
+ "\t\t\t\tServiceKey..............%s\n"
+ "\t\t\t\tServiceName.............%s\n"
+ "\t\t\t\tServiceData8.1..........0x%X\n"
+ "\t\t\t\tServiceData8.2..........0x%X\n"
+ "\t\t\t\tServiceData8.3..........0x%X\n"
+ "\t\t\t\tServiceData8.4..........0x%X\n"
+ "\t\t\t\tServiceData8.5..........0x%X\n"
+ "\t\t\t\tServiceData8.6..........0x%X\n"
+ "\t\t\t\tServiceData8.7..........0x%X\n"
+ "\t\t\t\tServiceData8.8..........0x%X\n"
+ "\t\t\t\tServiceData8.9..........0x%X\n"
+ "\t\t\t\tServiceData8.10.........0x%X\n"
+ "\t\t\t\tServiceData8.11.........0x%X\n"
+ "\t\t\t\tServiceData8.12.........0x%X\n"
+ "\t\t\t\tServiceData8.13.........0x%X\n"
+ "\t\t\t\tServiceData8.14.........0x%X\n"
+ "\t\t\t\tServiceData8.15.........0x%X\n"
+ "\t\t\t\tServiceData8.16.........0x%X\n"
+ "\t\t\t\tServiceData16.1.........0x%X\n"
+ "\t\t\t\tServiceData16.2.........0x%X\n"
+ "\t\t\t\tServiceData16.3.........0x%X\n"
+ "\t\t\t\tServiceData16.4.........0x%X\n"
+ "\t\t\t\tServiceData16.5.........0x%X\n"
+ "\t\t\t\tServiceData16.6.........0x%X\n"
+ "\t\t\t\tServiceData16.7.........0x%X\n"
+ "\t\t\t\tServiceData16.8.........0x%X\n"
+ "\t\t\t\tServiceData32.1.........0x%X\n"
+ "\t\t\t\tServiceData32.2.........0x%X\n"
+ "\t\t\t\tServiceData32.3.........0x%X\n"
+ "\t\t\t\tServiceData32.4.........0x%X\n"
+ "\t\t\t\tServiceData64.1.........0x%016" PRIx64 "\n"
+ "\t\t\t\tServiceData64.2.........0x%016" PRIx64 "\n",
+ cl_ntoh64(p_sr->service_id),
+ inet_ntop(AF_INET6, p_sr->service_gid.raw, gid_str,
+ sizeof gid_str),
+ cl_ntoh16(p_sr->service_pkey),
+ cl_ntoh32(p_sr->service_lease),
+ buf_service_key, buf_service_name,
+ p_sr->service_data8[0], p_sr->service_data8[1],
+ p_sr->service_data8[2], p_sr->service_data8[3],
+ p_sr->service_data8[4], p_sr->service_data8[5],
+ p_sr->service_data8[6], p_sr->service_data8[7],
+ p_sr->service_data8[8], p_sr->service_data8[9],
+ p_sr->service_data8[10], p_sr->service_data8[11],
+ p_sr->service_data8[12], p_sr->service_data8[13],
+ p_sr->service_data8[14], p_sr->service_data8[15],
+ cl_ntoh16(p_sr->service_data16[0]),
+ cl_ntoh16(p_sr->service_data16[1]),
+ cl_ntoh16(p_sr->service_data16[2]),
+ cl_ntoh16(p_sr->service_data16[3]),
+ cl_ntoh16(p_sr->service_data16[4]),
+ cl_ntoh16(p_sr->service_data16[5]),
+ cl_ntoh16(p_sr->service_data16[6]),
+ cl_ntoh16(p_sr->service_data16[7]),
+ cl_ntoh32(p_sr->service_data32[0]),
+ cl_ntoh32(p_sr->service_data32[1]),
+ cl_ntoh32(p_sr->service_data32[2]),
+ cl_ntoh32(p_sr->service_data32[3]),
+ cl_ntoh64(p_sr->service_data64[0]),
+ cl_ntoh64(p_sr->service_data64[1]));
+ }
+}
+
+void osm_dump_service_record(IN osm_log_t * p_log,
+ IN const ib_service_record_t * p_sr,
+ IN osm_log_level_t log_level)
+{
+ if (osm_log_is_active(p_log, log_level)) {
+ char buf[BUF_SIZE];
+
+ osm_dump_service_record_to_buf(p_sr, buf);
+
+ osm_log(p_log, log_level, "%s", buf);
+ }
+}
+
+void osm_dump_service_record_v2(IN osm_log_t * p_log,
+ IN const ib_service_record_t * p_sr,
+ IN const int file_id,
+ IN osm_log_level_t log_level)
+{
+ if (osm_log_is_active_v2(p_log, log_level, file_id)) {
+ char buf[BUF_SIZE];
+
+ osm_dump_service_record_to_buf(p_sr, buf);
+
+ osm_log_v2(p_log, log_level, file_id, "%s", buf);
+ }
+}
+
+static void osm_dump_inform_info_to_buf_generic(IN const ib_inform_info_t * p_ii,
+ OUT char * buf)
+{
+ if (!buf || !p_ii)
+ return;
+ else {
+ uint32_t qpn;
+ uint8_t resp_time_val;
+ char gid_str[INET6_ADDRSTRLEN];
+
+ ib_inform_info_get_qpn_resp_time(p_ii->g_or_v.generic.
+ qpn_resp_time_val, &qpn,
+ &resp_time_val);
+ sprintf(buf,
+ "InformInfo dump:\n"
+ "\t\t\t\tgid.....................%s\n"
+ "\t\t\t\tlid_range_begin.........%u\n"
+ "\t\t\t\tlid_range_end...........%u\n"
+ "\t\t\t\tis_generic..............0x%X\n"
+ "\t\t\t\tsubscribe...............0x%X\n"
+ "\t\t\t\ttrap_type...............0x%X\n"
+ "\t\t\t\ttrap_num................%u\n"
+ "\t\t\t\tqpn.....................0x%06X\n"
+ "\t\t\t\tresp_time_val...........0x%X\n"
+ "\t\t\t\tnode_type...............0x%06X\n" "",
+ inet_ntop(AF_INET6, p_ii->gid.raw, gid_str,
+ sizeof gid_str),
+ cl_ntoh16(p_ii->lid_range_begin),
+ cl_ntoh16(p_ii->lid_range_end),
+ p_ii->is_generic, p_ii->subscribe,
+ cl_ntoh16(p_ii->trap_type),
+ cl_ntoh16(p_ii->g_or_v.generic.trap_num),
+ cl_ntoh32(qpn), resp_time_val,
+ cl_ntoh32(ib_inform_info_get_prod_type(p_ii)));
+ }
+}
+
+static void osm_dump_inform_info_to_buf(IN const ib_inform_info_t * p_ii,
+ OUT char * buf)
+{
+ if (!buf || !p_ii)
+ return;
+ else {
+ uint32_t qpn;
+ uint8_t resp_time_val;
+ char gid_str[INET6_ADDRSTRLEN];
+
+ ib_inform_info_get_qpn_resp_time(p_ii->g_or_v.generic.
+ qpn_resp_time_val, &qpn,
+ &resp_time_val);
+ sprintf(buf,
+ "InformInfo dump:\n"
+ "\t\t\t\tgid.....................%s\n"
+ "\t\t\t\tlid_range_begin.........%u\n"
+ "\t\t\t\tlid_range_end...........%u\n"
+ "\t\t\t\tis_generic..............0x%X\n"
+ "\t\t\t\tsubscribe...............0x%X\n"
+ "\t\t\t\ttrap_type...............0x%X\n"
+ "\t\t\t\tdev_id..................0x%X\n"
+ "\t\t\t\tqpn.....................0x%06X\n"
+ "\t\t\t\tresp_time_val...........0x%X\n"
+ "\t\t\t\tvendor_id...............0x%06X\n" "",
+ inet_ntop(AF_INET6, p_ii->gid.raw, gid_str,
+ sizeof gid_str),
+ cl_ntoh16(p_ii->lid_range_begin),
+ cl_ntoh16(p_ii->lid_range_end),
+ p_ii->is_generic, p_ii->subscribe,
+ cl_ntoh16(p_ii->trap_type),
+ cl_ntoh16(p_ii->g_or_v.vend.dev_id),
+ cl_ntoh32(qpn), resp_time_val,
+ cl_ntoh32(ib_inform_info_get_prod_type(p_ii)));
+ }
+}
+
+void osm_dump_inform_info(IN osm_log_t * p_log,
+ IN const ib_inform_info_t * p_ii,
+ IN osm_log_level_t log_level)
+{
+ if (osm_log_is_active(p_log, log_level)) {
+ char buf[BUF_SIZE];
+
+ if (p_ii->is_generic)
+ osm_dump_inform_info_to_buf_generic(p_ii, buf);
+ else
+ osm_dump_inform_info_to_buf(p_ii, buf);
+
+ osm_log(p_log, log_level, "%s", buf);
+ }
+}
+
+void osm_dump_inform_info_v2(IN osm_log_t * p_log,
+ IN const ib_inform_info_t * p_ii,
+ IN const int file_id,
+ IN osm_log_level_t log_level)
+{
+ if (osm_log_is_active_v2(p_log, log_level, file_id)) {
+ char buf[BUF_SIZE];
+
+ if (p_ii->is_generic)
+ osm_dump_inform_info_to_buf_generic(p_ii, buf);
+ else
+ osm_dump_inform_info_to_buf(p_ii, buf);
+
+ osm_log_v2(p_log, log_level, file_id, "%s", buf);
+ }
+}
+
+static void osm_dump_inform_info_record_to_buf_generic(IN const ib_inform_info_record_t * p_iir,
+ OUT char * buf)
+{
+ if (!buf || p_iir)
+ return;
+ else {
+ char gid_str[INET6_ADDRSTRLEN];
+ char gid_str2[INET6_ADDRSTRLEN];
+ uint32_t qpn;
+ uint8_t resp_time_val;
+
+ ib_inform_info_get_qpn_resp_time(p_iir->inform_info.g_or_v.
+ generic.qpn_resp_time_val,
+ &qpn, &resp_time_val);
+ sprintf(buf,
+ "InformInfo Record dump:\n"
+ "\t\t\t\tRID\n"
+ "\t\t\t\tSubscriberGID...........%s\n"
+ "\t\t\t\tSubscriberEnum..........0x%X\n"
+ "\t\t\t\tInformInfo dump:\n"
+ "\t\t\t\tgid.....................%s\n"
+ "\t\t\t\tlid_range_begin.........%u\n"
+ "\t\t\t\tlid_range_end...........%u\n"
+ "\t\t\t\tis_generic..............0x%X\n"
+ "\t\t\t\tsubscribe...............0x%X\n"
+ "\t\t\t\ttrap_type...............0x%X\n"
+ "\t\t\t\ttrap_num................%u\n"
+ "\t\t\t\tqpn.....................0x%06X\n"
+ "\t\t\t\tresp_time_val...........0x%X\n"
+ "\t\t\t\tnode_type...............0x%06X\n" "",
+ inet_ntop(AF_INET6, p_iir->subscriber_gid.raw,
+ gid_str, sizeof gid_str),
+ cl_ntoh16(p_iir->subscriber_enum),
+ inet_ntop(AF_INET6, p_iir->inform_info.gid.raw,
+ gid_str2, sizeof gid_str2),
+ cl_ntoh16(p_iir->inform_info.lid_range_begin),
+ cl_ntoh16(p_iir->inform_info.lid_range_end),
+ p_iir->inform_info.is_generic,
+ p_iir->inform_info.subscribe,
+ cl_ntoh16(p_iir->inform_info.trap_type),
+ cl_ntoh16(p_iir->inform_info.g_or_v.generic.
+ trap_num), cl_ntoh32(qpn),
+ resp_time_val,
+ cl_ntoh32(ib_inform_info_get_prod_type
+ (&p_iir->inform_info)));
+ }
+}
+
+static void osm_dump_inform_info_record_to_buf(IN const ib_inform_info_record_t * p_iir,
+ OUT char * buf)
+{
+ if(!buf || p_iir)
+ return;
+ else {
+ char gid_str[INET6_ADDRSTRLEN];
+ char gid_str2[INET6_ADDRSTRLEN];
+ uint32_t qpn;
+ uint8_t resp_time_val;
+
+ ib_inform_info_get_qpn_resp_time(p_iir->inform_info.g_or_v.
+ generic.qpn_resp_time_val,
+ &qpn, &resp_time_val);
+ sprintf(buf,
+ "InformInfo Record dump:\n"
+ "\t\t\t\tRID\n"
+ "\t\t\t\tSubscriberGID...........%s\n"
+ "\t\t\t\tSubscriberEnum..........0x%X\n"
+ "\t\t\t\tInformInfo dump:\n"
+ "\t\t\t\tgid.....................%s\n"
+ "\t\t\t\tlid_range_begin.........%u\n"
+ "\t\t\t\tlid_range_end...........%u\n"
+ "\t\t\t\tis_generic..............0x%X\n"
+ "\t\t\t\tsubscribe...............0x%X\n"
+ "\t\t\t\ttrap_type...............0x%X\n"
+ "\t\t\t\tdev_id..................0x%X\n"
+ "\t\t\t\tqpn.....................0x%06X\n"
+ "\t\t\t\tresp_time_val...........0x%X\n"
+ "\t\t\t\tvendor_id...............0x%06X\n" "",
+ inet_ntop(AF_INET6, p_iir->subscriber_gid.raw,
+ gid_str, sizeof gid_str),
+ cl_ntoh16(p_iir->subscriber_enum),
+ inet_ntop(AF_INET6, p_iir->inform_info.gid.raw,
+ gid_str2, sizeof gid_str2),
+ cl_ntoh16(p_iir->inform_info.lid_range_begin),
+ cl_ntoh16(p_iir->inform_info.lid_range_end),
+ p_iir->inform_info.is_generic,
+ p_iir->inform_info.subscribe,
+ cl_ntoh16(p_iir->inform_info.trap_type),
+ cl_ntoh16(p_iir->inform_info.g_or_v.vend.
+ dev_id), cl_ntoh32(qpn),
+ resp_time_val,
+ cl_ntoh32(ib_inform_info_get_prod_type
+ (&p_iir->inform_info)));
+ }
+}
+
+void osm_dump_inform_info_record(IN osm_log_t * p_log,
+ IN const ib_inform_info_record_t * p_iir,
+ IN osm_log_level_t log_level)
+{
+ if (osm_log_is_active(p_log, log_level)) {
+ char buf[BUF_SIZE];
+
+ if (p_iir->inform_info.is_generic)
+ osm_dump_inform_info_record_to_buf_generic(p_iir, buf);
+ else
+ osm_dump_inform_info_record_to_buf(p_iir, buf);
+
+ osm_log(p_log, log_level, "%s", buf);
+ }
+}
+
+void osm_dump_inform_info_record_v2(IN osm_log_t * p_log,
+ IN const ib_inform_info_record_t * p_iir,
+ IN const int file_id,
+ IN osm_log_level_t log_level)
+{
+ if (osm_log_is_active_v2(p_log, log_level, file_id)) {
+ char buf[BUF_SIZE];
+
+ if (p_iir->inform_info.is_generic)
+ osm_dump_inform_info_record_to_buf_generic(p_iir, buf);
+ else
+ osm_dump_inform_info_record_to_buf(p_iir, buf);
+
+ osm_log_v2(p_log, log_level, file_id, "%s", buf);
+ }
+}
+
+static void osm_dump_link_record_to_buf(IN const ib_link_record_t * p_lr,
+ OUT char * buf)
+{
+ if (!buf || !p_lr)
+ return;
+ else {
+ sprintf(buf,
+ "Link Record dump:\n"
+ "\t\t\t\tfrom_lid................%u\n"
+ "\t\t\t\tfrom_port_num...........%u\n"
+ "\t\t\t\tto_port_num.............%u\n"
+ "\t\t\t\tto_lid..................%u\n",
+ cl_ntoh16(p_lr->from_lid),
+ p_lr->from_port_num,
+ p_lr->to_port_num, cl_ntoh16(p_lr->to_lid));
+ }
+}
+
+void osm_dump_link_record(IN osm_log_t * p_log,
+ IN const ib_link_record_t * p_lr,
+ IN osm_log_level_t log_level)
+{
+ if (osm_log_is_active(p_log, log_level)) {
+ char buf[BUF_SIZE];
+
+ osm_dump_link_record_to_buf(p_lr, buf);
+
+ osm_log(p_log, log_level, "%s", buf);
+ }
+}
+
+void osm_dump_link_record_v2(IN osm_log_t * p_log,
+ IN const ib_link_record_t * p_lr,
+ IN const int file_id,
+ IN osm_log_level_t log_level)
+{
+ if (osm_log_is_active_v2(p_log, log_level, file_id)) {
+ char buf[BUF_SIZE];
+
+ osm_dump_link_record_to_buf(p_lr, buf);
+
+ osm_log_v2(p_log, log_level, file_id, "%s", buf);
+ }
+}
+
+static void osm_dump_switch_info_to_buf(IN const ib_switch_info_t * p_si,
+ OUT char * buf)
+{
+ if (!buf || !p_si)
+ return;
+ else {
+ sprintf(buf,
+ "SwitchInfo dump:\n"
+ "\t\t\t\tlin_cap.................0x%X\n"
+ "\t\t\t\trand_cap................0x%X\n"
+ "\t\t\t\tmcast_cap...............0x%X\n"
+ "\t\t\t\tlin_top.................0x%X\n"
+ "\t\t\t\tdef_port................%u\n"
+ "\t\t\t\tdef_mcast_pri_port......%u\n"
+ "\t\t\t\tdef_mcast_not_port......%u\n"
+ "\t\t\t\tlife_state..............0x%X\n"
+ "\t\t\t\tlids_per_port...........%u\n"
+ "\t\t\t\tpartition_enf_cap.......0x%X\n"
+ "\t\t\t\tflags...................0x%X\n"
+ "\t\t\t\tmcast_top...............0x%X\n",
+ cl_ntoh16(p_si->lin_cap), cl_ntoh16(p_si->rand_cap),
+ cl_ntoh16(p_si->mcast_cap), cl_ntoh16(p_si->lin_top),
+ p_si->def_port, p_si->def_mcast_pri_port,
+ p_si->def_mcast_not_port, p_si->life_state,
+ cl_ntoh16(p_si->lids_per_port),
+ cl_ntoh16(p_si->enforce_cap), p_si->flags,
+ cl_ntoh16(p_si->mcast_top));
+ }
+}
+
+void osm_dump_switch_info(IN osm_log_t * p_log,
+ IN const ib_switch_info_t * p_si,
+ IN osm_log_level_t log_level)
+{
+ if (osm_log_is_active(p_log, log_level)) {
+ char buf[BUF_SIZE];
+
+ osm_dump_switch_info_to_buf(p_si, buf);
+
+ osm_log(p_log, OSM_LOG_VERBOSE, "%s", buf);
+ }
+}
+
+void osm_dump_switch_info_v2(IN osm_log_t * p_log,
+ IN const ib_switch_info_t * p_si,
+ IN const int file_id,
+ IN osm_log_level_t log_level)
+{
+ if (osm_log_is_active_v2(p_log, log_level, file_id)) {
+ char buf[BUF_SIZE];
+
+ osm_dump_switch_info_to_buf(p_si, buf);
+
+ osm_log_v2(p_log, OSM_LOG_VERBOSE, file_id, "%s", buf);
+ }
+}
+
+static void osm_dump_switch_info_record_to_buf(IN const ib_switch_info_record_t * p_sir,
+ OUT char * buf)
+{
+ if (!buf || !p_sir)
+ return;
+ else {
+ sprintf(buf,
+ "SwitchInfo Record dump:\n"
+ "\t\t\t\tRID\n"
+ "\t\t\t\tlid.....................%u\n"
+ "\t\t\t\tSwitchInfo dump:\n"
+ "\t\t\t\tlin_cap.................0x%X\n"
+ "\t\t\t\trand_cap................0x%X\n"
+ "\t\t\t\tmcast_cap...............0x%X\n"
+ "\t\t\t\tlin_top.................0x%X\n"
+ "\t\t\t\tdef_port................%u\n"
+ "\t\t\t\tdef_mcast_pri_port......%u\n"
+ "\t\t\t\tdef_mcast_not_port......%u\n"
+ "\t\t\t\tlife_state..............0x%X\n"
+ "\t\t\t\tlids_per_port...........%u\n"
+ "\t\t\t\tpartition_enf_cap.......0x%X\n"
+ "\t\t\t\tflags...................0x%X\n",
+ cl_ntoh16(p_sir->lid),
+ cl_ntoh16(p_sir->switch_info.lin_cap),
+ cl_ntoh16(p_sir->switch_info.rand_cap),
+ cl_ntoh16(p_sir->switch_info.mcast_cap),
+ cl_ntoh16(p_sir->switch_info.lin_top),
+ p_sir->switch_info.def_port,
+ p_sir->switch_info.def_mcast_pri_port,
+ p_sir->switch_info.def_mcast_not_port,
+ p_sir->switch_info.life_state,
+ cl_ntoh16(p_sir->switch_info.lids_per_port),
+ cl_ntoh16(p_sir->switch_info.enforce_cap),
+ p_sir->switch_info.flags);
+ }
+}
+
+void osm_dump_switch_info_record(IN osm_log_t * p_log,
+ IN const ib_switch_info_record_t * p_sir,
+ IN osm_log_level_t log_level)
+{
+ if (osm_log_is_active(p_log, log_level)) {
+ char buf[BUF_SIZE];
+
+ osm_dump_switch_info_record_to_buf(p_sir, buf);
+
+ osm_log(p_log, log_level, "%s", buf);
+ }
+}
+
+void osm_dump_switch_info_record_v2(IN osm_log_t * p_log,
+ IN const ib_switch_info_record_t * p_sir,
+ IN const int file_id,
+ IN osm_log_level_t log_level)
+{
+ if (osm_log_is_active_v2(p_log, log_level, file_id)) {
+ char buf[BUF_SIZE];
+
+ osm_dump_switch_info_record_to_buf(p_sir, buf);
+
+ osm_log_v2(p_log, log_level, file_id, "%s", buf);
+ }
+}
+
+static void osm_dump_pkey_block_to_buf(IN uint64_t port_guid,
+ IN uint16_t block_num,
+ IN uint8_t port_num,
+ IN const ib_pkey_table_t * p_pkey_tbl,
+ OUT char * buf)
+{
+ if (!buf || !p_pkey_tbl)
+ return;
+ else {
+ char buf_line[1024];
+ int i, n;
+
+ for (i = 0, n = 0; i < 32; i++)
+ n += sprintf(buf_line + n, " 0x%04x |",
+ cl_ntoh16(p_pkey_tbl->pkey_entry[i]));
+
+ sprintf(buf,
+ "P_Key table dump:\n"
+ "\t\t\tport_guid...........0x%016" PRIx64 "\n"
+ "\t\t\tblock_num...........0x%X\n"
+ "\t\t\tport_num............%u\n\tP_Key Table: %s\n",
+ cl_ntoh64(port_guid), block_num, port_num, buf_line);
+ }
+}
+
+void osm_dump_pkey_block(IN osm_log_t * p_log, IN uint64_t port_guid,
+ IN uint16_t block_num, IN uint8_t port_num,
+ IN const ib_pkey_table_t * p_pkey_tbl,
+ IN osm_log_level_t log_level)
+{
+ if (osm_log_is_active(p_log, log_level)) {
+ char buf[BUF_SIZE];
+
+ osm_dump_pkey_block_to_buf(port_guid, block_num, port_num,
+ p_pkey_tbl, buf);
+
+ osm_log(p_log, log_level, "%s", buf);
+ }
+}
+
+void osm_dump_pkey_block_v2(IN osm_log_t * p_log, IN uint64_t port_guid,
+ IN uint16_t block_num, IN uint8_t port_num,
+ IN const ib_pkey_table_t * p_pkey_tbl,
+ IN const int file_id,
+ IN osm_log_level_t log_level)
+{
+ if (osm_log_is_active_v2(p_log, log_level, file_id)) {
+ char buf[BUF_SIZE];
+
+ osm_dump_pkey_block_to_buf(port_guid, block_num,
+ port_num, p_pkey_tbl, buf);
+
+ osm_log_v2(p_log, log_level, file_id, "%s", buf);
+ }
+}
+
+static void osm_dump_slvl_map_table_to_buf(IN uint64_t port_guid,
+ IN uint8_t in_port_num,
+ IN uint8_t out_port_num,
+ IN const ib_slvl_table_t * p_slvl_tbl,
+ OUT char * buf)
+{
+ if (!buf || !p_slvl_tbl)
+ return;
+ else {
+ char buf_line1[1024], buf_line2[1024];
+ int n;
+ uint8_t i;
+
+ for (i = 0, n = 0; i < 16; i++)
+ n += sprintf(buf_line1 + n, " %-2u |", i);
+ for (i = 0, n = 0; i < 16; i++)
+ n += sprintf(buf_line2 + n, "0x%01X |",
+ ib_slvl_table_get(p_slvl_tbl, i));
+ sprintf(buf,
+ "SLtoVL dump:\n"
+ "\t\t\tport_guid............0x%016" PRIx64 "\n"
+ "\t\t\tin_port_num..........%u\n"
+ "\t\t\tout_port_num.........%u\n\tSL: | %s\n\tVL: | %s\n",
+ cl_ntoh64(port_guid), in_port_num, out_port_num,
+ buf_line1, buf_line2);
+ }
+}
+
+void osm_dump_slvl_map_table(IN osm_log_t * p_log, IN uint64_t port_guid,
+ IN uint8_t in_port_num, IN uint8_t out_port_num,
+ IN const ib_slvl_table_t * p_slvl_tbl,
+ IN osm_log_level_t log_level)
+{
+ if (osm_log_is_active(p_log, log_level)) {
+ char buf[BUF_SIZE];
+
+ osm_dump_slvl_map_table_to_buf(port_guid, in_port_num,
+ out_port_num, p_slvl_tbl, buf);
+
+ osm_log(p_log, log_level, "%s", buf);
+ }
+}
+
+void osm_dump_slvl_map_table_v2(IN osm_log_t * p_log, IN uint64_t port_guid,
+ IN uint8_t in_port_num, IN uint8_t out_port_num,
+ IN const ib_slvl_table_t * p_slvl_tbl,
+ IN const int file_id,
+ IN osm_log_level_t log_level)
+{
+ if (osm_log_is_active_v2(p_log, log_level, file_id)) {
+ char buf[BUF_SIZE];
+
+ osm_dump_slvl_map_table_to_buf(port_guid, in_port_num,
+ out_port_num, p_slvl_tbl, buf);
+
+ osm_log_v2(p_log, log_level, file_id, "%s", buf);
+ }
+}
+
+static void osm_dump_vl_arb_table_to_buf(IN uint64_t port_guid,
+ IN uint8_t block_num,
+ IN uint8_t port_num,
+ IN const ib_vl_arb_table_t * p_vla_tbl,
+ OUT char * buf)
+{
+ if (!buf || !p_vla_tbl)
+ return;
+ else {
+ char buf_line1[1024], buf_line2[1024];
+ int i, n;
+
+ for (i = 0, n = 0; i < 32; i++)
+ n += sprintf(buf_line1 + n, " 0x%01X |",
+ p_vla_tbl->vl_entry[i].vl);
+ for (i = 0, n = 0; i < 32; i++)
+ n += sprintf(buf_line2 + n, " 0x%01X |",
+ p_vla_tbl->vl_entry[i].weight);
+ sprintf(buf,
+ "VLArb dump:\n" "\t\t\tport_guid...........0x%016"
+ PRIx64 "\n" "\t\t\tblock_num...........0x%X\n"
+ "\t\t\tport_num............%u\n\tVL : | %s\n\tWEIGHT:| %s\n",
+ cl_ntoh64(port_guid), block_num, port_num, buf_line1,
+ buf_line2);
+ }
+}
+
+void osm_dump_vl_arb_table(IN osm_log_t * p_log, IN uint64_t port_guid,
+ IN uint8_t block_num, IN uint8_t port_num,
+ IN const ib_vl_arb_table_t * p_vla_tbl,
+ IN osm_log_level_t log_level)
+{
+ if (osm_log_is_active(p_log, log_level)) {
+ char buf[BUF_SIZE];
+
+ osm_dump_vl_arb_table_to_buf(port_guid, block_num,
+ port_num, p_vla_tbl, buf);
+
+ osm_log(p_log, log_level, "%s", buf);
+ }
+}
+
+void osm_dump_vl_arb_table_v2(IN osm_log_t * p_log, IN uint64_t port_guid,
+ IN uint8_t block_num, IN uint8_t port_num,
+ IN const ib_vl_arb_table_t * p_vla_tbl,
+ IN const int file_id,
+ IN osm_log_level_t log_level)
+{
+ if (osm_log_is_active_v2(p_log, log_level, file_id)) {
+ char buf[BUF_SIZE];
+
+ osm_dump_vl_arb_table_to_buf(port_guid, block_num,
+ port_num, p_vla_tbl, buf);
+
+ osm_log_v2(p_log, log_level, file_id, "%s", buf);
+ }
+}
+
+static void osm_dump_sm_info_to_buf(IN const ib_sm_info_t * p_smi,
+ OUT char * buf)
+{
+ if (!buf || !p_smi)
+ return;
+ else {
+ sprintf(buf,
+ "SMInfo dump:\n"
+ "\t\t\t\tguid....................0x%016" PRIx64 "\n"
+ "\t\t\t\tsm_key..................0x%016" PRIx64 "\n"
+ "\t\t\t\tact_count...............%u\n"
+ "\t\t\t\tpriority................%u\n"
+ "\t\t\t\tsm_state................%u\n",
+ cl_ntoh64(p_smi->guid), cl_ntoh64(p_smi->sm_key),
+ cl_ntoh32(p_smi->act_count),
+ ib_sminfo_get_priority(p_smi),
+ ib_sminfo_get_state(p_smi));
+ }
+}
+
+void osm_dump_sm_info(IN osm_log_t * p_log, IN const ib_sm_info_t * p_smi,
+ IN osm_log_level_t log_level)
+{
+ if (osm_log_is_active(p_log, log_level)) {
+ char buf[BUF_SIZE];
+
+ osm_dump_sm_info_to_buf(p_smi, buf);
+
+ osm_log(p_log, OSM_LOG_DEBUG, "%s", buf);
+ }
+}
+
+void osm_dump_sm_info_v2(IN osm_log_t * p_log, IN const ib_sm_info_t * p_smi,
+ IN const int file_id, IN osm_log_level_t log_level)
+{
+ if (osm_log_is_active_v2(p_log, log_level, file_id)) {
+ char buf[BUF_SIZE];
+
+ osm_dump_sm_info_to_buf(p_smi, buf);
+
+ osm_log_v2(p_log, OSM_LOG_DEBUG, file_id, "%s", buf);
+ }
+}
+
+static void osm_dump_sm_info_record_to_buf(IN const ib_sminfo_record_t * p_smir,
+ OUT char * buf)
+{
+ if (!buf || !p_smir)
+ return;
+ else {
+ sprintf(buf,
+ "SMInfo Record dump:\n"
+ "\t\t\t\tRID\n"
+ "\t\t\t\tLid.....................%u\n"
+ "\t\t\t\tReserved................0x%X\n"
+ "\t\t\t\tSMInfo dump:\n"
+ "\t\t\t\tguid....................0x%016" PRIx64 "\n"
+ "\t\t\t\tsm_key..................0x%016" PRIx64 "\n"
+ "\t\t\t\tact_count...............%u\n"
+ "\t\t\t\tpriority................%u\n"
+ "\t\t\t\tsm_state................%u\n",
+ cl_ntoh16(p_smir->lid), cl_ntoh16(p_smir->resv0),
+ cl_ntoh64(p_smir->sm_info.guid),
+ cl_ntoh64(p_smir->sm_info.sm_key),
+ cl_ntoh32(p_smir->sm_info.act_count),
+ ib_sminfo_get_priority(&p_smir->sm_info),
+ ib_sminfo_get_state(&p_smir->sm_info));
+ }
+}
+
+void osm_dump_sm_info_record(IN osm_log_t * p_log,
+ IN const ib_sminfo_record_t * p_smir,
+ IN osm_log_level_t log_level)
+{
+ if (osm_log_is_active(p_log, log_level)) {
+ char buf[BUF_SIZE];
+
+ osm_dump_sm_info_record_to_buf(p_smir, buf);
+
+ osm_log(p_log, OSM_LOG_DEBUG, "%s", buf);
+ }
+}
+
+void osm_dump_sm_info_record_v2(IN osm_log_t * p_log,
+ IN const ib_sminfo_record_t * p_smir,
+ IN const int file_id,
+ IN osm_log_level_t log_level)
+{
+ if (osm_log_is_active_v2(p_log, log_level, file_id)) {
+ char buf[BUF_SIZE];
+
+ osm_dump_sm_info_record_to_buf(p_smir, buf);
+
+ osm_log_v2(p_log, OSM_LOG_DEBUG, file_id, "%s", buf);
+ }
+}
+
+static void osm_dump_notice_to_buf_generic(IN const ib_mad_notice_attr_t * p_ntci,
+ OUT char * log_buf)
+{
+ if (!log_buf || !p_ntci)
+ return;
+ else {
+ char gid_str[INET6_ADDRSTRLEN];
+ char gid_str2[INET6_ADDRSTRLEN];
+ char buff[1024];
+ int n;
+
+ buff[0] = '\0';
+
+ /* immediate data based on the trap */
+ switch (cl_ntoh16(p_ntci->g_or_v.generic.trap_num)) {
+ case SM_GID_IN_SERVICE_TRAP: /* 64 */
+ case SM_GID_OUT_OF_SERVICE_TRAP: /* 65 */
+ case SM_MGID_CREATED_TRAP: /* 66 */
+ case SM_MGID_DESTROYED_TRAP: /* 67 */
+ sprintf(buff,
+ "\t\t\t\tsrc_gid..................%s\n",
+ inet_ntop(AF_INET6, p_ntci->data_details.
+ ntc_64_67.gid.raw, gid_str,
+ sizeof gid_str));
+ break;
+ case SM_LINK_STATE_CHANGED_TRAP: /* 128 */
+ sprintf(buff,
+ "\t\t\t\tsw_lid...................%u\n",
+ cl_ntoh16(p_ntci->data_details.ntc_128.sw_lid));
+ break;
+ case SM_LINK_INTEGRITY_THRESHOLD_TRAP: /* 129 */
+ case SM_BUFFER_OVERRUN_THRESHOLD_TRAP: /* 130 */
+ case SM_WATCHDOG_TIMER_EXPIRED_TRAP: /* 131 */
+ sprintf(buff,
+ "\t\t\t\tlid......................%u\n"
+ "\t\t\t\tport_num.................%u\n",
+ cl_ntoh16(p_ntci->data_details.
+ ntc_129_131.lid),
+ p_ntci->data_details.ntc_129_131.port_num);
+ break;
+ case SM_LOCAL_CHANGES_TRAP: /* 144 */
+ sprintf(buff,
+ "\t\t\t\tlid......................%u\n"
+ "\t\t\t\tlocal_changes............%u\n"
+ "\t\t\t\tnew_cap_mask.............0x%08x\n"
+ "\t\t\t\tchange_flags.............0x%x\n"
+ "\t\t\t\tcap_mask2................0x%x\n",
+ cl_ntoh16(p_ntci->data_details.ntc_144.lid),
+ p_ntci->data_details.ntc_144.local_changes,
+ cl_ntoh32(p_ntci->data_details.ntc_144.
+ new_cap_mask),
+ cl_ntoh16(p_ntci->data_details.ntc_144.
+ change_flgs),
+ cl_ntoh16(p_ntci->data_details.ntc_144.
+ cap_mask2));
+ break;
+ case SM_SYS_IMG_GUID_CHANGED_TRAP: /* 145 */
+ sprintf(buff,
+ "\t\t\t\tlid......................%u\n"
+ "\t\t\t\tnew_sys_guid.............0x%016"
+ PRIx64 "\n",
+ cl_ntoh16(p_ntci->data_details.ntc_145.
+ lid),
+ cl_ntoh64(p_ntci->data_details.ntc_145.
+ new_sys_guid));
+ break;
+ case SM_BAD_MKEY_TRAP: /* 256 */
+ n = sprintf(buff,
+ "\t\t\t\tlid......................%u\n"
+ "\t\t\t\tdrslid...................%u\n"
+ "\t\t\t\tmethod...................0x%x\n"
+ "\t\t\t\tattr_id..................0x%x\n"
+ "\t\t\t\tattr_mod.................0x%x\n"
+ "\t\t\t\tm_key....................0x%016"
+ PRIx64 "\n"
+ "\t\t\t\tdr_notice................%d\n"
+ "\t\t\t\tdr_path_truncated........%d\n"
+ "\t\t\t\tdr_hop_count.............%u\n",
+ cl_ntoh16(p_ntci->data_details.ntc_256.lid),
+ cl_ntoh16(p_ntci->data_details.ntc_256.
+ dr_slid),
+ p_ntci->data_details.ntc_256.method,
+ cl_ntoh16(p_ntci->data_details.ntc_256.
+ attr_id),
+ cl_ntoh32(p_ntci->data_details.ntc_256.
+ attr_mod),
+ cl_ntoh64(p_ntci->data_details.ntc_256.
+ mkey),
+ p_ntci->data_details.ntc_256.
+ dr_trunc_hop >> 7,
+ p_ntci->data_details.ntc_256.
+ dr_trunc_hop >> 6,
+ p_ntci->data_details.ntc_256.
+ dr_trunc_hop & 0x3f);
+ n += snprintf(buff + n, sizeof(buff) - n,
+ "Directed Path Dump of %u hop path:"
+ "\n\t\t\t\tPath = ",
+ p_ntci->data_details.ntc_256.
+ dr_trunc_hop & 0x3f);
+ n += sprint_uint8_arr(buff + n, sizeof(buff) - n,
+ p_ntci->data_details.ntc_256.
+ dr_rtn_path,
+ (p_ntci->data_details.ntc_256.
+ dr_trunc_hop & 0x3f) + 1);
+ if (n >= sizeof(buff)) {
+ n = sizeof(buff) - 2;
+ break;
+ }
+ snprintf(buff + n, sizeof(buff) - n, "\n");
+ break;
+ case SM_BAD_PKEY_TRAP: /* 257 */
+ case SM_BAD_QKEY_TRAP: /* 258 */
+ sprintf(buff,
+ "\t\t\t\tlid1.....................%u\n"
+ "\t\t\t\tlid2.....................%u\n"
+ "\t\t\t\tkey......................0x%x\n"
+ "\t\t\t\tsl.......................%d\n"
+ "\t\t\t\tqp1......................0x%x\n"
+ "\t\t\t\tqp2......................0x%x\n"
+ "\t\t\t\tgid1.....................%s\n"
+ "\t\t\t\tgid2.....................%s\n",
+ cl_ntoh16(p_ntci->data_details.ntc_257_258.
+ lid1),
+ cl_ntoh16(p_ntci->data_details.ntc_257_258.
+ lid2),
+ cl_ntoh32(p_ntci->data_details.ntc_257_258.key),
+ cl_ntoh32(p_ntci->data_details.ntc_257_258.
+ qp1) >> 28,
+ cl_ntoh32(p_ntci->data_details.ntc_257_258.
+ qp1) & 0xffffff,
+ cl_ntoh32(p_ntci->data_details.ntc_257_258.
+ qp2) & 0xffffff,
+ inet_ntop(AF_INET6, p_ntci->data_details.
+ ntc_257_258.gid1.raw, gid_str,
+ sizeof gid_str),
+ inet_ntop(AF_INET6, p_ntci->data_details.
+ ntc_257_258.gid2.raw, gid_str2,
+ sizeof gid_str2));
+ break;
+ case SM_BAD_SWITCH_PKEY_TRAP: /* 259 */
+ sprintf(buff,
+ "\t\t\t\tdata_valid...............0x%x\n"
+ "\t\t\t\tlid1.....................%u\n"
+ "\t\t\t\tlid2.....................%u\n"
+ "\t\t\t\tpkey.....................0x%x\n"
+ "\t\t\t\tsl.......................%d\n"
+ "\t\t\t\tqp1......................0x%x\n"
+ "\t\t\t\tqp2......................0x%x\n"
+ "\t\t\t\tgid1.....................%s\n"
+ "\t\t\t\tgid2.....................%s\n"
+ "\t\t\t\tsw_lid...................%u\n"
+ "\t\t\t\tport_no..................%u\n",
+ cl_ntoh16(p_ntci->data_details.ntc_259.
+ data_valid),
+ cl_ntoh16(p_ntci->data_details.ntc_259.lid1),
+ cl_ntoh16(p_ntci->data_details.ntc_259.lid2),
+ cl_ntoh16(p_ntci->data_details.ntc_259.pkey),
+ cl_ntoh32(p_ntci->data_details.ntc_259.
+ sl_qp1) >> 24,
+ cl_ntoh32(p_ntci->data_details.ntc_259.
+ sl_qp1) & 0xffffff,
+ cl_ntoh32(p_ntci->data_details.ntc_259.qp2),
+ inet_ntop(AF_INET6, p_ntci->data_details.
+ ntc_259.gid1.raw, gid_str,
+ sizeof gid_str),
+ inet_ntop(AF_INET6, p_ntci->data_details.
+ ntc_259.gid2.raw, gid_str2,
+ sizeof gid_str2),
+ cl_ntoh16(p_ntci->data_details.ntc_259.sw_lid),
+ p_ntci->data_details.ntc_259.port_no);
+ break;
+ }
+
+ sprintf(log_buf,
+ "Generic Notice dump:\n"
+ "\t\t\t\ttype.....................%u\n"
+ "\t\t\t\tprod_type................%u (%s)\n"
+ "\t\t\t\ttrap_num.................%u\n%s",
+ ib_notice_get_type(p_ntci),
+ cl_ntoh32(ib_notice_get_prod_type(p_ntci)),
+ ib_get_producer_type_str(ib_notice_get_prod_type
+ (p_ntci)),
+ cl_ntoh16(p_ntci->g_or_v.generic.trap_num), buff);
+ }
+}
+
+static void osm_dump_notice_to_buf(IN const ib_mad_notice_attr_t * p_ntci,
+ OUT char * buf)
+{
+ if (!buf || !p_ntci)
+ return;
+ else {
+ sprintf(buf,
+ "Vendor Notice dump:\n"
+ "\t\t\t\ttype.....................%u\n"
+ "\t\t\t\tvendor...................%u\n"
+ "\t\t\t\tdevice_id................%u\n",
+ cl_ntoh16(ib_notice_get_type(p_ntci)),
+ cl_ntoh32(ib_notice_get_vend_id(p_ntci)),
+ cl_ntoh16(p_ntci->g_or_v.vend.dev_id));
+ }
+}
+
+void osm_dump_notice(IN osm_log_t * p_log,
+ IN const ib_mad_notice_attr_t * p_ntci,
+ IN osm_log_level_t log_level)
+{
+ if (osm_log_is_active(p_log, log_level)) {
+ char buf[BUF_SIZE];
+
+ if (ib_notice_is_generic(p_ntci))
+ osm_dump_notice_to_buf_generic(p_ntci, buf);
+ else
+ osm_dump_notice_to_buf(p_ntci, buf);
+
+ osm_log(p_log, log_level, "%s", buf);
+ }
+}
+
+void osm_dump_notice_v2(IN osm_log_t * p_log,
+ IN const ib_mad_notice_attr_t * p_ntci,
+ IN const int file_id, IN osm_log_level_t log_level)
+{
+ if (osm_log_is_active_v2(p_log, log_level, file_id)) {
+ char buf[BUF_SIZE];
+
+ if (ib_notice_is_generic(p_ntci))
+ osm_dump_notice_to_buf_generic(p_ntci, buf);
+ else
+ osm_dump_notice_to_buf(p_ntci, buf);
+
+ osm_log_v2(p_log, log_level, file_id, "%s", buf);
+ }
+}
+
+static void osm_dump_dr_smp_to_buf(IN const ib_smp_t * p_smp, OUT char * buf,
+ IN size_t buf_size)
+{
+ if (!buf || !p_smp)
+ return;
+ else {
+ unsigned n;
+
+ n = sprintf(buf,
+ "SMP dump:\n"
+ "\t\t\t\tbase_ver................0x%X\n"
+ "\t\t\t\tmgmt_class..............0x%X\n"
+ "\t\t\t\tclass_ver...............0x%X\n"
+ "\t\t\t\tmethod..................0x%X (%s)\n",
+ p_smp->base_ver, p_smp->mgmt_class,
+ p_smp->class_ver, p_smp->method,
+ ib_get_sm_method_str(p_smp->method));
+
+ if (p_smp->mgmt_class == IB_MCLASS_SUBN_DIR) {
+ n += snprintf(buf + n, buf_size - n,
+ "\t\t\t\tD bit...................0x%X\n"
+ "\t\t\t\tstatus..................0x%X\n",
+ ib_smp_is_d(p_smp),
+ cl_ntoh16(ib_smp_get_status(p_smp)));
+ } else {
+ n += snprintf(buf + n, buf_size - n,
+ "\t\t\t\tstatus..................0x%X\n",
+ cl_ntoh16(p_smp->status));
+ }
+
+ n += snprintf(buf + n, buf_size - n,
+ "\t\t\t\thop_ptr.................0x%X\n"
+ "\t\t\t\thop_count...............0x%X\n"
+ "\t\t\t\ttrans_id................0x%" PRIx64 "\n"
+ "\t\t\t\tattr_id.................0x%X (%s)\n"
+ "\t\t\t\tresv....................0x%X\n"
+ "\t\t\t\tattr_mod................0x%X\n"
+ "\t\t\t\tm_key...................0x%016" PRIx64
+ "\n", p_smp->hop_ptr, p_smp->hop_count,
+ cl_ntoh64(p_smp->trans_id),
+ cl_ntoh16(p_smp->attr_id),
+ ib_get_sm_attr_str(p_smp->attr_id),
+ cl_ntoh16(p_smp->resv),
+ cl_ntoh32(p_smp->attr_mod),
+ cl_ntoh64(p_smp->m_key));
+
+ if (p_smp->mgmt_class == IB_MCLASS_SUBN_DIR) {
+ uint32_t i;
+ n += snprintf(buf + n, buf_size - n,
+ "\t\t\t\tdr_slid.................%u\n"
+ "\t\t\t\tdr_dlid.................%u\n",
+ cl_ntoh16(p_smp->dr_slid),
+ cl_ntoh16(p_smp->dr_dlid));
+
+ n += snprintf(buf + n, buf_size - n,
+ "\n\t\t\t\tInitial path: ");
+ n += sprint_uint8_arr(buf + n, buf_size - n,
+ p_smp->initial_path,
+ p_smp->hop_count + 1);
+
+ n += snprintf(buf + n, buf_size - n,
+ "\n\t\t\t\tReturn path: ");
+ n += sprint_uint8_arr(buf + n, buf_size - n,
+ p_smp->return_path,
+ p_smp->hop_count + 1);
+
+ n += snprintf(buf + n, buf_size - n,
+ "\n\t\t\t\tReserved: ");
+ for (i = 0; i < 7; i++) {
+ n += snprintf(buf + n, buf_size - n,
+ "[%0X]", p_smp->resv1[i]);
+ }
+ n += snprintf(buf + n, buf_size - n, "\n");
+
+ for (i = 0; i < 64; i += 16) {
+ n += snprintf(buf + n, buf_size - n,
+ "\n\t\t\t\t%02X %02X %02X %02X "
+ "%02X %02X %02X %02X"
+ " %02X %02X %02X %02X %02X %02X %02X %02X\n",
+ p_smp->data[i],
+ p_smp->data[i + 1],
+ p_smp->data[i + 2],
+ p_smp->data[i + 3],
+ p_smp->data[i + 4],
+ p_smp->data[i + 5],
+ p_smp->data[i + 6],
+ p_smp->data[i + 7],
+ p_smp->data[i + 8],
+ p_smp->data[i + 9],
+ p_smp->data[i + 10],
+ p_smp->data[i + 11],
+ p_smp->data[i + 12],
+ p_smp->data[i + 13],
+ p_smp->data[i + 14],
+ p_smp->data[i + 15]);
+ }
+ } else {
+ /* not a Direct Route so provide source and destination lids */
+ n += snprintf(buf + n, buf_size - n,
+ "\t\t\t\tMAD IS LID ROUTED\n");
+ }
+ }
+}
+
+void osm_dump_dr_smp(IN osm_log_t * p_log, IN const ib_smp_t * p_smp,
+ IN osm_log_level_t log_level)
+{
+ if (osm_log_is_active(p_log, log_level)) {
+ char buf[BUF_SIZE];
+
+ osm_dump_dr_smp_to_buf(p_smp, buf, BUF_SIZE);
+
+ osm_log(p_log, log_level, "%s", buf);
+ }
+}
+
+void osm_dump_dr_smp_v2(IN osm_log_t * p_log, IN const ib_smp_t * p_smp,
+ IN const int file_id, IN osm_log_level_t log_level)
+{
+ if (osm_log_is_active_v2(p_log, log_level, file_id)) {
+ char buf[BUF_SIZE];
+
+ osm_dump_dr_smp_to_buf(p_smp, buf, BUF_SIZE);
+
+ osm_log_v2(p_log, log_level, file_id, "%s", buf);
+ }
+}
+
+static void osm_dump_sa_mad_to_buf(IN const ib_sa_mad_t * p_mad, OUT char * buf)
+{
+ if (!buf || !p_mad)
+ return;
+ else {
+ /* make sure the mad is valid */
+ if (p_mad == NULL) {
+ sprintf(buf, "NULL MAD POINTER\n");
+ return;
+ }
+
+ sprintf(buf,
+ "SA MAD dump:\n"
+ "\t\t\t\tbase_ver................0x%X\n"
+ "\t\t\t\tmgmt_class..............0x%X\n"
+ "\t\t\t\tclass_ver...............0x%X\n"
+ "\t\t\t\tmethod..................0x%X (%s)\n"
+ "\t\t\t\tstatus..................0x%X\n"
+ "\t\t\t\tresv....................0x%X\n"
+ "\t\t\t\ttrans_id................0x%" PRIx64 "\n"
+ "\t\t\t\tattr_id.................0x%X (%s)\n"
+ "\t\t\t\tresv1...................0x%X\n"
+ "\t\t\t\tattr_mod................0x%X\n"
+ "\t\t\t\trmpp_version............0x%X\n"
+ "\t\t\t\trmpp_type...............0x%X\n"
+ "\t\t\t\trmpp_flags..............0x%X\n"
+ "\t\t\t\trmpp_status.............0x%X\n"
+ "\t\t\t\tseg_num.................0x%X\n"
+ "\t\t\t\tpayload_len/new_win.....0x%X\n"
+ "\t\t\t\tsm_key..................0x%016" PRIx64 "\n"
+ "\t\t\t\tattr_offset.............0x%X\n"
+ "\t\t\t\tresv2...................0x%X\n"
+ "\t\t\t\tcomp_mask...............0x%016" PRIx64 "\n",
+ p_mad->base_ver, p_mad->mgmt_class, p_mad->class_ver,
+ p_mad->method, ib_get_sa_method_str(p_mad->method),
+ cl_ntoh16(p_mad->status), cl_ntoh16(p_mad->resv),
+ cl_ntoh64(p_mad->trans_id), cl_ntoh16(p_mad->attr_id),
+ ib_get_sa_attr_str(p_mad->attr_id),
+ cl_ntoh16(p_mad->resv1), cl_ntoh32(p_mad->attr_mod),
+ p_mad->rmpp_version, p_mad->rmpp_type,
+ p_mad->rmpp_flags, p_mad->rmpp_status,
+ cl_ntoh32(p_mad->seg_num),
+ cl_ntoh32(p_mad->paylen_newwin),
+ cl_ntoh64(p_mad->sm_key), cl_ntoh16(p_mad->attr_offset),
+ cl_ntoh16(p_mad->resv3), cl_ntoh64(p_mad->comp_mask));
+
+ strcat(buf, "\n");
+ }
+}
+
+void osm_dump_sa_mad(IN osm_log_t * p_log, IN const ib_sa_mad_t * p_mad,
+ IN osm_log_level_t log_level)
+{
+ if (osm_log_is_active(p_log, log_level)) {
+ char buf[BUF_SIZE];
+
+ osm_dump_sa_mad_to_buf(p_mad, buf);
+
+ osm_log(p_log, log_level, "%s\n", buf);
+ }
+}
+
+void osm_dump_sa_mad_v2(IN osm_log_t * p_log, IN const ib_sa_mad_t * p_mad,
+ IN const int file_id, IN osm_log_level_t log_level)
+{
+ if (osm_log_is_active_v2(p_log, log_level, file_id)) {
+ char buf[BUF_SIZE];
+
+ osm_dump_sa_mad_to_buf(p_mad, buf);
+
+ osm_log_v2(p_log, log_level, file_id, "%s", buf);
+ }
+}
+
+static void osm_dump_dr_path_to_buf(IN const osm_dr_path_t * p_path,
+ OUT char * buf, IN size_t buf_size)
+{
+ if (!buf || !p_path)
+ return;
+ else {
+ unsigned n = 0;
+
+ n = sprintf(buf, "Directed Path Dump of %u hop path: "
+ "Path = ", p_path->hop_count);
+
+ sprint_uint8_arr(buf + n, buf_size - n, p_path->path,
+ p_path->hop_count + 1);
+ }
+}
+
+void osm_dump_dr_path(IN osm_log_t * p_log, IN const osm_dr_path_t * p_path,
+ IN osm_log_level_t log_level)
+{
+ if (osm_log_is_active(p_log, log_level)) {
+ char buf[BUF_SIZE];
+
+ osm_dump_dr_path_to_buf(p_path, buf, BUF_SIZE);
+
+ osm_log(p_log, log_level, "%s\n", buf);
+ }
+}
+
+void osm_dump_dr_path_v2(IN osm_log_t * p_log, IN const osm_dr_path_t * p_path,
+ IN const int file_id, IN osm_log_level_t log_level)
+{
+ if (osm_log_is_active_v2(p_log, log_level, file_id)) {
+ char buf[BUF_SIZE];
+
+ osm_dump_dr_path_to_buf(p_path, buf, BUF_SIZE);
+
+ osm_log_v2(p_log, log_level, file_id, "%s\n", buf);
+ }
+}
+
+static void osm_dump_smp_dr_path_to_buf(IN const ib_smp_t * p_smp,
+ OUT char * buf, IN size_t buf_size)
+{
+ if (!buf || !p_smp)
+ return;
+ else {
+ unsigned n;
+
+ n = sprintf(buf, "Received SMP on a %u hop path: "
+ "Initial path = ", p_smp->hop_count);
+ n += sprint_uint8_arr(buf + n, buf_size - n,
+ p_smp->initial_path,
+ p_smp->hop_count + 1);
+
+ n += snprintf(buf + n, buf_size - n, ", Return path = ");
+ n += sprint_uint8_arr(buf + n, buf_size - n,
+ p_smp->return_path, p_smp->hop_count + 1);
+ }
+}
+
+void osm_dump_smp_dr_path(IN osm_log_t * p_log, IN const ib_smp_t * p_smp,
+ IN osm_log_level_t log_level)
+{
+ if (osm_log_is_active(p_log, log_level)) {
+ char buf[BUF_SIZE];
+
+ osm_dump_smp_dr_path_to_buf(p_smp, buf, BUF_SIZE);
+
+ osm_log(p_log, log_level, "%s\n", buf);
+ }
+}
+
+void osm_dump_smp_dr_path_v2(IN osm_log_t * p_log, IN const ib_smp_t * p_smp,
+ IN const int file_id, IN osm_log_level_t log_level)
+{
+ if (osm_log_is_active_v2(p_log, log_level, file_id)) {
+ char buf[BUF_SIZE];
+
+ osm_dump_smp_dr_path_to_buf(p_smp, buf, BUF_SIZE);
+
+ osm_log_v2(p_log, log_level, file_id, "%s\n", buf);
+ }
+}
+
+void osm_dump_dr_path_as_buf(IN size_t max_len,
+ IN const osm_dr_path_t * p_path,
+ OUT char* buf)
+{
+ sprint_uint8_arr(buf, max_len, p_path->path, p_path->hop_count + 1);
+}
+
+static const char *sm_signal_str[] = {
+ "OSM_SIGNAL_NONE", /* 0 */
+ "OSM_SIGNAL_SWEEP", /* 1 */
+ "OSM_SIGNAL_IDLE_TIME_PROCESS_REQUEST", /* 2 */
+ "OSM_SIGNAL_PERFMGR_SWEEP", /* 3 */
+ "OSM_SIGNAL_GUID_PROCESS_REQUEST", /* 4 */
+ "UNKNOWN SIGNAL!!" /* 5 */
+};
+
+const char *osm_get_sm_signal_str(IN osm_signal_t signal)
+{
+ if (signal > OSM_SIGNAL_MAX)
+ signal = OSM_SIGNAL_MAX;
+ return sm_signal_str[signal];
+}
+
+static const char *disp_msg_str[] = {
+ "OSM_MSG_NONE",
+ "OSM_MSG_MAD_NODE_INFO",
+ "OSM_MSG_MAD_PORT_INFO",
+ "OSM_MSG_MAD_SWITCH_INFO",
+ "OSM_MSG_MAD_GUID_INFO",
+ "OSM_MSG_MAD_NODE_DESC",
+ "OSM_MSG_MAD_NODE_RECORD",
+ "OSM_MSG_MAD_PORTINFO_RECORD",
+ "OSM_MSG_MAD_SERVICE_RECORD",
+ "OSM_MSG_MAD_PATH_RECORD",
+ "OSM_MSG_MAD_MCMEMBER_RECORD",
+ "OSM_MSG_MAD_LINK_RECORD",
+ "OSM_MSG_MAD_SMINFO_RECORD",
+ "OSM_MSG_MAD_CLASS_PORT_INFO",
+ "OSM_MSG_MAD_INFORM_INFO",
+ "OSM_MSG_MAD_LFT_RECORD",
+ "OSM_MSG_MAD_LFT",
+ "OSM_MSG_MAD_SM_INFO",
+ "OSM_MSG_MAD_NOTICE",
+ "OSM_MSG_LIGHT_SWEEP_FAIL",
+ "OSM_MSG_MAD_MFT",
+ "OSM_MSG_MAD_PKEY_TBL_RECORD",
+ "OSM_MSG_MAD_VL_ARB_RECORD",
+ "OSM_MSG_MAD_SLVL_TBL_RECORD",
+ "OSM_MSG_MAD_PKEY",
+ "OSM_MSG_MAD_VL_ARB",
+ "OSM_MSG_MAD_SLVL",
+ "OSM_MSG_MAD_GUIDINFO_RECORD",
+ "OSM_MSG_MAD_INFORM_INFO_RECORD",
+ "OSM_MSG_MAD_SWITCH_INFO_RECORD",
+ "OSM_MSG_MAD_MFT_RECORD",
+#if defined (VENDOR_RMPP_SUPPORT) && defined (DUAL_SIDED_RMPP)
+ "OSM_MSG_MAD_MULTIPATH_RECORD",
+#endif
+ "OSM_MSG_MAD_PORT_COUNTERS",
+ "OSM_MSG_MAD_MLNX_EXT_PORT_INFO",
+ "UNKNOWN!!"
+};
+
+const char *osm_get_disp_msg_str(IN cl_disp_msgid_t msg)
+{
+ if (msg >= OSM_MSG_MAX)
+ msg = OSM_MSG_MAX-1;
+ return disp_msg_str[msg];
+}
+
+static const char *port_state_str_fixed_width[] = {
+ "NOC",
+ "DWN",
+ "INI",
+ "ARM",
+ "ACT",
+ "???"
+};
+
+const char *osm_get_port_state_str_fixed_width(IN uint8_t port_state)
+{
+ if (port_state > IB_LINK_ACTIVE)
+ port_state = IB_LINK_ACTIVE + 1;
+ return port_state_str_fixed_width[port_state];
+}
+
+static const char *node_type_str_fixed_width[] = {
+ "??",
+ "CA",
+ "SW",
+ "RT",
+};
+
+const char *osm_get_node_type_str_fixed_width(IN uint8_t node_type)
+{
+ if (node_type > IB_NODE_TYPE_ROUTER)
+ node_type = 0;
+ return node_type_str_fixed_width[node_type];
+}
+
+const char *osm_get_manufacturer_str(IN uint64_t guid_ho)
+{
+ /* note that the max vendor string length is 11 */
+ static const char *intel_str = "Intel";
+ static const char *mellanox_str = "Mellanox";
+ static const char *redswitch_str = "Redswitch";
+ static const char *silverstorm_str = "SilverStorm";
+ static const char *topspin_str = "Topspin";
+ static const char *fujitsu_str = "Fujitsu";
+ static const char *voltaire_str = "Voltaire";
+ static const char *yotta_str = "YottaYotta";
+ static const char *pathscale_str = "PathScale";
+ static const char *ibm_str = "IBM";
+ static const char *divergenet_str = "DivergeNet";
+ static const char *flextronics_str = "Flextronics";
+ static const char *agilent_str = "Agilent";
+ static const char *obsidian_str = "Obsidian";
+ static const char *baymicro_str = "BayMicro";
+ static const char *lsilogic_str = "LSILogic";
+ static const char *ddn_str = "DataDirect";
+ static const char *panta_str = "Panta";
+ static const char *hp_str = "HP";
+ static const char *rioworks_str = "Rioworks";
+ static const char *sun_str = "Sun";
+ static const char *leafntwks_str = "3LeafNtwks";
+ static const char *xsigo_str = "Xsigo";
+ static const char *dell_str = "Dell";
+ static const char *supermicro_str = "SuperMicro";
+ static const char *openib_str = "OpenIB";
+ static const char *unknown_str = "Unknown";
+ static const char *bull_str = "Bull";
+
+ switch ((uint32_t) (guid_ho >> (5 * 8))) {
+ case OSM_VENDOR_ID_INTEL:
+ return intel_str;
+ case OSM_VENDOR_ID_MELLANOX:
+ case OSM_VENDOR_ID_MELLANOX2:
+ case OSM_VENDOR_ID_MELLANOX3:
+ case OSM_VENDOR_ID_MELLANOX4:
+ case OSM_VENDOR_ID_MELLANOX5:
+ return mellanox_str;
+ case OSM_VENDOR_ID_REDSWITCH:
+ return redswitch_str;
+ case OSM_VENDOR_ID_SILVERSTORM:
+ return silverstorm_str;
+ case OSM_VENDOR_ID_TOPSPIN:
+ return topspin_str;
+ case OSM_VENDOR_ID_FUJITSU:
+ case OSM_VENDOR_ID_FUJITSU2:
+ return fujitsu_str;
+ case OSM_VENDOR_ID_VOLTAIRE:
+ return voltaire_str;
+ case OSM_VENDOR_ID_YOTTAYOTTA:
+ return yotta_str;
+ case OSM_VENDOR_ID_PATHSCALE:
+ return pathscale_str;
+ case OSM_VENDOR_ID_IBM:
+ case OSM_VENDOR_ID_IBM2:
+ return ibm_str;
+ case OSM_VENDOR_ID_DIVERGENET:
+ return divergenet_str;
+ case OSM_VENDOR_ID_FLEXTRONICS:
+ return flextronics_str;
+ case OSM_VENDOR_ID_AGILENT:
+ return agilent_str;
+ case OSM_VENDOR_ID_OBSIDIAN:
+ return obsidian_str;
+ case OSM_VENDOR_ID_BAYMICRO:
+ return baymicro_str;
+ case OSM_VENDOR_ID_LSILOGIC:
+ return lsilogic_str;
+ case OSM_VENDOR_ID_DDN:
+ return ddn_str;
+ case OSM_VENDOR_ID_PANTA:
+ return panta_str;
+ case OSM_VENDOR_ID_HP:
+ case OSM_VENDOR_ID_HP2:
+ case OSM_VENDOR_ID_HP3:
+ case OSM_VENDOR_ID_HP4:
+ return hp_str;
+ case OSM_VENDOR_ID_RIOWORKS:
+ return rioworks_str;
+ case OSM_VENDOR_ID_SUN:
+ case OSM_VENDOR_ID_SUN2:
+ return sun_str;
+ case OSM_VENDOR_ID_3LEAFNTWKS:
+ return leafntwks_str;
+ case OSM_VENDOR_ID_XSIGO:
+ return xsigo_str;
+ case OSM_VENDOR_ID_DELL:
+ return dell_str;
+ case OSM_VENDOR_ID_SUPERMICRO:
+ return supermicro_str;
+ case OSM_VENDOR_ID_OPENIB:
+ return openib_str;
+ case OSM_VENDOR_ID_BULL:
+ return bull_str;
+ default:
+ return unknown_str;
+ }
+}
+
+static const char *mtu_str_fixed_width[] = {
+ "??? ",
+ "256 ",
+ "512 ",
+ "1024",
+ "2048",
+ "4096"
+};
+
+const char *osm_get_mtu_str(IN uint8_t mtu)
+{
+ if (mtu > IB_MTU_LEN_4096)
+ return mtu_str_fixed_width[0];
+ else
+ return mtu_str_fixed_width[mtu];
+}
+
+static const char *lwa_str_fixed_width[] = {
+ "???",
+ "1x ",
+ "4x ",
+ "???",
+ "8x ",
+ "???",
+ "???",
+ "???",
+ "12x",
+ "???",
+ "???",
+ "???",
+ "???",
+ "???",
+ "???",
+ "???",
+ "2x "
+};
+
+const char *osm_get_lwa_str(IN uint8_t lwa)
+{
+ if (lwa > 16)
+ return lwa_str_fixed_width[0];
+ else
+ return lwa_str_fixed_width[lwa];
+}
+
+static const char *lsa_str_fixed_width[] = {
+ "Ext ",
+ "2.5 ",
+ "5 ",
+ "????",
+ "10 "
+};
+
+static const char *lsea_str_fixed_width[] = {
+ "Std ",
+ "14 ",
+ "25 "
+};
+
+const char *osm_get_lsa_str(IN uint8_t lsa, IN uint8_t lsea, IN uint8_t state,
+ IN uint8_t fdr10)
+{
+ if (lsa > IB_LINK_SPEED_ACTIVE_10 || state == IB_LINK_DOWN)
+ return lsa_str_fixed_width[3];
+ if (lsea == IB_LINK_SPEED_EXT_ACTIVE_NONE) {
+ if (fdr10)
+ return "FDR10";
+ else
+ return lsa_str_fixed_width[lsa];
+ }
+ if (lsea > IB_LINK_SPEED_EXT_ACTIVE_25)
+ return lsa_str_fixed_width[3];
+ return lsea_str_fixed_width[lsea];
+}
+
+static const char *sm_mgr_signal_str[] = {
+ "OSM_SM_SIGNAL_NONE", /* 0 */
+ "OSM_SM_SIGNAL_DISCOVERY_COMPLETED", /* 1 */
+ "OSM_SM_SIGNAL_POLLING_TIMEOUT", /* 2 */
+ "OSM_SM_SIGNAL_DISCOVER", /* 3 */
+ "OSM_SM_SIGNAL_DISABLE", /* 4 */
+ "OSM_SM_SIGNAL_HANDOVER", /* 5 */
+ "OSM_SM_SIGNAL_HANDOVER_SENT", /* 6 */
+ "OSM_SM_SIGNAL_ACKNOWLEDGE", /* 7 */
+ "OSM_SM_SIGNAL_STANDBY", /* 8 */
+ "OSM_SM_SIGNAL_MASTER_OR_HIGHER_SM_DETECTED", /* 9 */
+ "OSM_SM_SIGNAL_WAIT_FOR_HANDOVER", /* 10 */
+ "UNKNOWN STATE!!" /* 11 */
+};
+
+const char *osm_get_sm_mgr_signal_str(IN osm_sm_signal_t signal)
+{
+ if (signal > OSM_SM_SIGNAL_MAX)
+ signal = OSM_SM_SIGNAL_MAX;
+ return sm_mgr_signal_str[signal];
+}
+
+static const char *sm_mgr_state_str[] = {
+ "NOTACTIVE", /* 0 */
+ "DISCOVERING", /* 1 */
+ "STANDBY", /* 2 */
+ "MASTER", /* 3 */
+ "UNKNOWN STATE!!" /* 4 */
+};
+
+const char *osm_get_sm_mgr_state_str(IN uint16_t state)
+{
+ return state < ARR_SIZE(sm_mgr_state_str) ?
+ sm_mgr_state_str[state] :
+ sm_mgr_state_str[ARR_SIZE(sm_mgr_state_str) - 1];
+}
+
+int ib_mtu_is_valid(IN const int mtu)
+{
+ if (mtu < IB_MIN_MTU || mtu > IB_MAX_MTU)
+ return 0;
+ return 1;
+}
+
+int ib_rate_is_valid(IN const int rate)
+{
+ if (rate < IB_MIN_RATE || rate > IB_MAX_RATE)
+ return 0;
+ return 1;
+}
+
+int ib_path_compare_rates(IN const int rate1, IN const int rate2)
+{
+ int orate1 = 0, orate2 = 0;
+
+ CL_ASSERT(rate1 >= IB_MIN_RATE && rate1 <= IB_MAX_RATE);
+ CL_ASSERT(rate2 >= IB_MIN_RATE && rate2 <= IB_MAX_RATE);
+
+ if (rate1 <= IB_MAX_RATE)
+ orate1 = ordered_rates[rate1];
+ if (rate2 <= IB_MAX_RATE)
+ orate2 = ordered_rates[rate2];
+ if (orate1 < orate2)
+ return -1;
+ if (orate1 == orate2)
+ return 0;
+ return 1;
+}
+
+static int find_ordered_rate(IN const int rate)
+{
+ int i;
+
+ for (i = IB_MIN_RATE; i <= IB_MAX_RATE; i++) {
+ if (ordered_rates[i] == rate)
+ return i;
+ }
+ return 0;
+}
+
+int ib_path_rate_get_prev(IN const int rate)
+{
+ int orate;
+
+ CL_ASSERT(rate >= IB_MIN_RATE && rate <= IB_MAX_RATE);
+
+ if (rate <= IB_MIN_RATE)
+ return 0;
+ if (rate > IB_MAX_RATE)
+ return 0;
+ orate = ordered_rates[rate];
+ orate--;
+ return find_ordered_rate(orate);
+}
+
+int ib_path_rate_get_next(IN const int rate)
+{
+ int orate;
+
+ CL_ASSERT(rate >= IB_MIN_RATE && rate <= IB_MAX_RATE);
+
+ if (rate < IB_MIN_RATE)
+ return 0;
+ if (rate >= IB_MAX_RATE)
+ return 0;
+ orate = ordered_rates[rate];
+ orate++;
+ return find_ordered_rate(orate);
+}
diff --git a/contrib/ofed/opensm/opensm/osm_inform.c b/contrib/ofed/opensm/opensm/osm_inform.c
new file mode 100644
index 0000000..f0c22eb
--- /dev/null
+++ b/contrib/ofed/opensm/opensm/osm_inform.c
@@ -0,0 +1,822 @@
+/*
+ * Copyright (c) 2004-2009 Voltaire, Inc. All rights reserved.
+ * Copyright (c) 2002-2015 Mellanox Technologies LTD. All rights reserved.
+ * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
+ * Copyright (c) 2009 HNR Consulting. All rights reserved.
+ * Copyright (c) 2013 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+/*
+ * Abstract:
+ * Implementation of inform record functions.
+ */
+
+#if HAVE_CONFIG_H
+# include <config.h>
+#endif /* HAVE_CONFIG_H */
+
+#include <stdlib.h>
+#include <string.h>
+#include <arpa/inet.h>
+#include <sys/socket.h>
+#include <complib/cl_debug.h>
+#include <opensm/osm_file_ids.h>
+#define FILE_ID OSM_FILE_INFORM_C
+#include <opensm/osm_helper.h>
+#include <opensm/osm_inform.h>
+#include <vendor/osm_vendor_api.h>
+#include <opensm/osm_pkey.h>
+#include <opensm/osm_sa.h>
+#include <opensm/osm_opensm.h>
+
+typedef struct osm_infr_match_ctxt {
+ cl_list_t *p_remove_infr_list;
+ ib_mad_notice_attr_t *p_ntc;
+} osm_infr_match_ctxt_t;
+
+void osm_infr_delete(IN osm_infr_t * p_infr)
+{
+ free(p_infr);
+}
+
+osm_infr_t *osm_infr_new(IN const osm_infr_t * p_infr_rec)
+{
+ osm_infr_t *p_infr;
+
+ CL_ASSERT(p_infr_rec);
+
+ p_infr = (osm_infr_t *) malloc(sizeof(osm_infr_t));
+ if (p_infr)
+ memcpy(p_infr, p_infr_rec, sizeof(osm_infr_t));
+
+ return p_infr;
+}
+
+static void dump_all_informs(IN const osm_subn_t * p_subn, IN osm_log_t * p_log)
+{
+ cl_list_item_t *p_list_item;
+
+ if (!OSM_LOG_IS_ACTIVE_V2(p_log, OSM_LOG_DEBUG))
+ return;
+
+ p_list_item = cl_qlist_head(&p_subn->sa_infr_list);
+ while (p_list_item != cl_qlist_end(&p_subn->sa_infr_list)) {
+ osm_dump_inform_info_v2(p_log,
+ &((osm_infr_t *) p_list_item)->
+ inform_record.inform_info, FILE_ID, OSM_LOG_DEBUG);
+ p_list_item = cl_qlist_next(p_list_item);
+ }
+}
+
+/**********************************************************************
+ * Match an infr by the InformInfo and Address vector
+ **********************************************************************/
+static cl_status_t match_inf_rec(IN const cl_list_item_t * p_list_item,
+ IN void *context)
+{
+ osm_infr_t *p_infr_rec = (osm_infr_t *) context;
+ osm_infr_t *p_infr = (osm_infr_t *) p_list_item;
+ ib_inform_info_t *p_ii_rec = &p_infr_rec->inform_record.inform_info;
+ ib_inform_info_t *p_ii = &p_infr->inform_record.inform_info;
+ osm_log_t *p_log = p_infr_rec->sa->p_log;
+ cl_status_t status = CL_NOT_FOUND;
+
+ OSM_LOG_ENTER(p_log);
+
+ if (memcmp(&p_infr->report_addr, &p_infr_rec->report_addr,
+ sizeof(p_infr_rec->report_addr))) {
+ OSM_LOG(p_log, OSM_LOG_DEBUG, "Differ by Address\n");
+ goto Exit;
+ }
+
+ /* if inform_info.gid is not zero, ignore lid range */
+ if (ib_gid_is_notzero(&p_ii_rec->gid)) {
+ if (memcmp(&p_ii->gid, &p_ii_rec->gid, sizeof(p_ii->gid))) {
+ OSM_LOG(p_log, OSM_LOG_DEBUG,
+ "Differ by InformInfo.gid\n");
+ goto Exit;
+ }
+ } else {
+ if ((p_ii->lid_range_begin != p_ii_rec->lid_range_begin) ||
+ (p_ii->lid_range_end != p_ii_rec->lid_range_end)) {
+ OSM_LOG(p_log, OSM_LOG_DEBUG,
+ "Differ by InformInfo.LIDRange\n");
+ goto Exit;
+ }
+ }
+
+ if (p_ii->trap_type != p_ii_rec->trap_type) {
+ OSM_LOG(p_log, OSM_LOG_DEBUG,
+ "Differ by InformInfo.TrapType\n");
+ goto Exit;
+ }
+
+ if (p_ii->is_generic != p_ii_rec->is_generic) {
+ OSM_LOG(p_log, OSM_LOG_DEBUG,
+ "Differ by InformInfo.IsGeneric\n");
+ goto Exit;
+ }
+
+ if (p_ii->is_generic) {
+ if (p_ii->g_or_v.generic.trap_num !=
+ p_ii_rec->g_or_v.generic.trap_num)
+ OSM_LOG(p_log, OSM_LOG_DEBUG,
+ "Differ by InformInfo.Generic.TrapNumber\n");
+ else if (p_ii->g_or_v.generic.qpn_resp_time_val !=
+ p_ii_rec->g_or_v.generic.qpn_resp_time_val)
+ OSM_LOG(p_log, OSM_LOG_DEBUG,
+ "Differ by InformInfo.Generic.QPNRespTimeVal\n");
+ else if (p_ii->g_or_v.generic.node_type_msb !=
+ p_ii_rec->g_or_v.generic.node_type_msb)
+ OSM_LOG(p_log, OSM_LOG_DEBUG,
+ "Differ by InformInfo.Generic.NodeTypeMSB\n");
+ else if (p_ii->g_or_v.generic.node_type_lsb !=
+ p_ii_rec->g_or_v.generic.node_type_lsb)
+ OSM_LOG(p_log, OSM_LOG_DEBUG,
+ "Differ by InformInfo.Generic.NodeTypeLSB\n");
+ else
+ status = CL_SUCCESS;
+ } else {
+ if (p_ii->g_or_v.vend.dev_id != p_ii_rec->g_or_v.vend.dev_id)
+ OSM_LOG(p_log, OSM_LOG_DEBUG,
+ "Differ by InformInfo.Vendor.DeviceID\n");
+ else if (p_ii->g_or_v.vend.qpn_resp_time_val !=
+ p_ii_rec->g_or_v.vend.qpn_resp_time_val)
+ OSM_LOG(p_log, OSM_LOG_DEBUG,
+ "Differ by InformInfo.Vendor.QPNRespTimeVal\n");
+ else if (p_ii->g_or_v.vend.vendor_id_msb !=
+ p_ii_rec->g_or_v.vend.vendor_id_msb)
+ OSM_LOG(p_log, OSM_LOG_DEBUG,
+ "Differ by InformInfo.Vendor.VendorIdMSB\n");
+ else if (p_ii->g_or_v.vend.vendor_id_lsb !=
+ p_ii_rec->g_or_v.vend.vendor_id_lsb)
+ OSM_LOG(p_log, OSM_LOG_DEBUG,
+ "Differ by InformInfo.Vendor.VendorIdLSB\n");
+ else
+ status = CL_SUCCESS;
+ }
+
+Exit:
+ OSM_LOG_EXIT(p_log);
+ return status;
+}
+
+osm_infr_t *osm_infr_get_by_rec(IN osm_subn_t const *p_subn,
+ IN osm_log_t * p_log,
+ IN osm_infr_t * p_infr_rec)
+{
+ cl_list_item_t *p_list_item;
+
+ OSM_LOG_ENTER(p_log);
+
+ dump_all_informs(p_subn, p_log);
+
+ OSM_LOG(p_log, OSM_LOG_DEBUG, "Looking for Inform Record\n");
+ osm_dump_inform_info_v2(p_log, &(p_infr_rec->inform_record.inform_info),
+ FILE_ID, OSM_LOG_DEBUG);
+ OSM_LOG(p_log, OSM_LOG_DEBUG, "InformInfo list size %d\n",
+ cl_qlist_count(&p_subn->sa_infr_list));
+
+ p_list_item = cl_qlist_find_from_head(&p_subn->sa_infr_list,
+ match_inf_rec, p_infr_rec);
+
+ if (p_list_item == cl_qlist_end(&p_subn->sa_infr_list))
+ p_list_item = NULL;
+
+ OSM_LOG_EXIT(p_log);
+ return (osm_infr_t *) p_list_item;
+}
+
+void osm_infr_insert_to_db(IN osm_subn_t * p_subn, IN osm_log_t * p_log,
+ IN osm_infr_t * p_infr)
+{
+ OSM_LOG_ENTER(p_log);
+
+ OSM_LOG(p_log, OSM_LOG_DEBUG,
+ "Inserting new InformInfo Record into Database\n");
+ OSM_LOG(p_log, OSM_LOG_DEBUG, "Dump before insertion (size %d)\n",
+ cl_qlist_count(&p_subn->sa_infr_list));
+ dump_all_informs(p_subn, p_log);
+
+#if 0
+ osm_dump_inform_info_v2(p_log,
+ &(p_infr->inform_record.inform_info),
+ FILE_ID, OSM_LOG_DEBUG);
+#endif
+
+ cl_qlist_insert_head(&p_subn->sa_infr_list, &p_infr->list_item);
+ p_subn->p_osm->sa.dirty = TRUE;
+
+ OSM_LOG(p_log, OSM_LOG_DEBUG, "Dump after insertion (size %d)\n",
+ cl_qlist_count(&p_subn->sa_infr_list));
+ dump_all_informs(p_subn, p_log);
+ OSM_LOG_EXIT(p_log);
+}
+
+void osm_infr_remove_from_db(IN osm_subn_t * p_subn, IN osm_log_t * p_log,
+ IN osm_infr_t * p_infr)
+{
+ char gid_str[INET6_ADDRSTRLEN];
+ OSM_LOG_ENTER(p_log);
+
+ OSM_LOG(p_log, OSM_LOG_DEBUG, "Removing InformInfo Subscribing GID:%s"
+ " Enum:0x%X from Database\n",
+ inet_ntop(AF_INET6, p_infr->inform_record.subscriber_gid.raw,
+ gid_str, sizeof gid_str),
+ p_infr->inform_record.subscriber_enum);
+
+ osm_dump_inform_info_v2(p_log, &(p_infr->inform_record.inform_info),
+ FILE_ID, OSM_LOG_DEBUG);
+
+ cl_qlist_remove_item(&p_subn->sa_infr_list, &p_infr->list_item);
+ p_subn->p_osm->sa.dirty = TRUE;
+
+ osm_infr_delete(p_infr);
+
+ OSM_LOG_EXIT(p_log);
+}
+
+ib_api_status_t osm_infr_remove_subscriptions(IN osm_subn_t * p_subn,
+ IN osm_log_t * p_log,
+ IN ib_net64_t port_guid)
+{
+ cl_list_item_t *p_list_item;
+ osm_infr_t *p_infr;
+ ib_api_status_t status = CL_NOT_FOUND;
+
+ OSM_LOG_ENTER(p_log);
+
+ /* go over all inform info available at the subnet */
+ /* match to the given GID and delete subscriptions if match */
+ p_list_item = cl_qlist_head(&p_subn->sa_infr_list);
+ while (p_list_item != cl_qlist_end(&p_subn->sa_infr_list)) {
+
+ p_infr = (osm_infr_t *)p_list_item;
+ p_list_item = cl_qlist_next(p_list_item);
+
+ if (port_guid != p_infr->inform_record.subscriber_gid.unicast.interface_id)
+ continue;
+
+ /* Remove this event subscription */
+ osm_infr_remove_from_db(p_subn, p_log, p_infr);
+
+ status = CL_SUCCESS;
+ }
+
+ OSM_LOG_EXIT(p_log);
+ return (status);
+}
+
+/**********************************************************************
+ * Send a report:
+ * Given a target address to send to and the notice.
+ * We need to send SubnAdmReport
+ **********************************************************************/
+static ib_api_status_t send_report(IN osm_infr_t * p_infr_rec, /* the informinfo */
+ IN ib_mad_notice_attr_t * p_ntc /* notice to send */
+ )
+{
+ osm_madw_t *p_report_madw;
+ ib_mad_notice_attr_t *p_report_ntc;
+ ib_mad_t *p_mad;
+ ib_sa_mad_t *p_sa_mad;
+ static atomic32_t trap_fwd_trans_id = 0x02DAB000;
+ ib_api_status_t status = IB_SUCCESS;
+ osm_log_t *p_log = p_infr_rec->sa->p_log;
+ ib_net64_t tid;
+
+ OSM_LOG_ENTER(p_log);
+
+ /* HACK: who switches or uses the src and dest GIDs in the grh_info ?? */
+
+ /* it is better to use LIDs since the GIDs might not be there for SMI traps */
+ OSM_LOG(p_log, OSM_LOG_DEBUG, "Forwarding Notice Event from LID %u"
+ " to InformInfo LID %u GUID 0x%" PRIx64 ", TID 0x%X\n",
+ cl_ntoh16(p_ntc->issuer_lid),
+ cl_ntoh16(p_infr_rec->report_addr.dest_lid),
+ cl_ntoh64(p_infr_rec->inform_record.subscriber_gid.unicast.interface_id),
+ trap_fwd_trans_id);
+
+ /* get the MAD to send */
+ p_report_madw = osm_mad_pool_get(p_infr_rec->sa->p_mad_pool,
+ p_infr_rec->h_bind, MAD_BLOCK_SIZE,
+ &(p_infr_rec->report_addr));
+
+ if (!p_report_madw) {
+ OSM_LOG(p_log, OSM_LOG_ERROR, "ERR 0203: "
+ "Cannot send report to LID %u, osm_mad_pool_get failed\n",
+ cl_ntoh16(p_infr_rec->report_addr.dest_lid));
+ status = IB_ERROR;
+ goto Exit;
+ }
+
+ p_report_madw->resp_expected = TRUE;
+
+ /* advance trap trans id (cant simply ++ on some systems inside ntoh) */
+ tid = cl_hton64((uint64_t) cl_atomic_inc(&trap_fwd_trans_id) &
+ (uint64_t) (0xFFFFFFFF));
+ if (trap_fwd_trans_id == 0)
+ tid = cl_hton64((uint64_t) cl_atomic_inc(&trap_fwd_trans_id) &
+ (uint64_t) (0xFFFFFFFF));
+ p_mad = osm_madw_get_mad_ptr(p_report_madw);
+ ib_mad_init_new(p_mad, IB_MCLASS_SUBN_ADM, 2, IB_MAD_METHOD_REPORT,
+ tid, IB_MAD_ATTR_NOTICE, 0);
+
+ p_sa_mad = osm_madw_get_sa_mad_ptr(p_report_madw);
+
+ p_report_ntc = (ib_mad_notice_attr_t *) & (p_sa_mad->data);
+
+ /* copy the notice */
+ *p_report_ntc = *p_ntc;
+
+ /* The TRUE is for: response is expected */
+ osm_sa_send(p_infr_rec->sa, p_report_madw, TRUE);
+
+Exit:
+ OSM_LOG_EXIT(p_log);
+ return status;
+}
+
+static int is_access_permitted(osm_infr_t *p_infr_rec,
+ osm_infr_match_ctxt_t *p_infr_match )
+{
+ cl_list_t *p_infr_to_remove_list = p_infr_match->p_remove_infr_list;
+ ib_inform_info_t *p_ii = &(p_infr_rec->inform_record.inform_info);
+ ib_mad_notice_attr_t *p_ntc = p_infr_match->p_ntc;
+ uint16_t trap_num = cl_ntoh16(p_ntc->g_or_v.generic.trap_num);
+ osm_subn_t *p_subn = p_infr_rec->sa->p_subn;
+ osm_log_t *p_log = p_infr_rec->sa->p_log;
+ osm_mgrp_t *p_mgrp;
+ ib_gid_t source_gid;
+ osm_port_t *p_src_port;
+ osm_port_t *p_dest_port;
+
+ /* In case of SM_GID_IN_SERVICE_TRAP(64) or SM_GID_OUT_OF_SERVICE_TRAP(65) traps
+ the source gid comparison should be done on the trap source (saved
+ as the gid in the data details field).
+ For traps SM_MGID_CREATED_TRAP(66) or SM_MGID_DESTROYED_TRAP(67)
+ the data details gid is the MGID.
+ We need to check whether the subscriber has a compatible
+ pkey with MC group.
+ In all other cases the issuer gid is the trap source.
+ */
+ if (trap_num >= SM_GID_IN_SERVICE_TRAP &&
+ trap_num <= SM_MGID_DESTROYED_TRAP)
+ /* The issuer of these traps is the SM so source_gid
+ is the gid saved on the data details */
+ source_gid = p_ntc->data_details.ntc_64_67.gid;
+ else
+ source_gid = p_ntc->issuer_gid;
+
+ p_dest_port = osm_get_port_by_lid(p_subn,
+ p_infr_rec->report_addr.dest_lid);
+ if (!p_dest_port) {
+ OSM_LOG(p_log, OSM_LOG_INFO,
+ "Cannot find destination port with LID:%u\n",
+ cl_ntoh16(p_infr_rec->report_addr.dest_lid));
+ goto Exit;
+ }
+
+ /* Check if there is a pkey match. o13-17.1.1 */
+ switch (trap_num) {
+ case SM_MGID_CREATED_TRAP:
+ case SM_MGID_DESTROYED_TRAP:
+ p_mgrp = osm_get_mgrp_by_mgid(p_subn, &source_gid);
+ if (!p_mgrp) {
+ char gid_str[INET6_ADDRSTRLEN];
+ OSM_LOG(p_log, OSM_LOG_INFO,
+ "Cannot find MGID %s\n",
+ inet_ntop(AF_INET6, source_gid.raw, gid_str, sizeof gid_str));
+ goto Exit;
+ }
+
+ if (!osm_physp_has_pkey(p_log,
+ p_mgrp->mcmember_rec.pkey,
+ p_dest_port->p_physp)) {
+ char gid_str[INET6_ADDRSTRLEN];
+ OSM_LOG(p_log, OSM_LOG_INFO,
+ "MGID %s and port GUID:0x%016" PRIx64 " do not share same pkey\n",
+ inet_ntop(AF_INET6, source_gid.raw, gid_str, sizeof gid_str),
+ cl_ntoh64(p_dest_port->guid));
+ goto Exit;
+ }
+ break;
+
+ default:
+ p_src_port =
+ osm_get_port_by_guid(p_subn, source_gid.unicast.interface_id);
+ if (!p_src_port) {
+ OSM_LOG(p_log, OSM_LOG_INFO,
+ "Cannot find source port with GUID:0x%016" PRIx64 "\n",
+ cl_ntoh64(source_gid.unicast.interface_id));
+ goto Exit;
+ }
+
+
+ if (osm_port_share_pkey(p_log, p_src_port, p_dest_port,
+ p_subn->opt.allow_both_pkeys) == FALSE) {
+ OSM_LOG(p_log, OSM_LOG_DEBUG, "Mismatch by Pkey\n");
+ /* According to o13-17.1.2 - If this informInfo
+ does not have lid_range_begin of 0xFFFF,
+ then this informInfo request should be
+ removed from database */
+ if (p_ii->lid_range_begin != 0xFFFF) {
+ OSM_LOG(p_log, OSM_LOG_VERBOSE,
+ "Pkey mismatch on lid_range_begin != 0xFFFF. "
+ "Need to remove this informInfo from db\n");
+ /* add the informInfo record to the remove_infr list */
+ cl_list_insert_tail(p_infr_to_remove_list, p_infr_rec);
+ }
+ goto Exit;
+ }
+ break;
+ }
+
+ return 1;
+Exit:
+ return 0;
+}
+
+
+/**********************************************************************
+ * This routine compares a given Notice and a ListItem of InformInfo type.
+ * PREREQUISITE:
+ * The Notice.GID should be pre-filled with the trap generator GID
+ **********************************************************************/
+static void match_notice_to_inf_rec(IN cl_list_item_t * p_list_item,
+ IN void *context)
+{
+ osm_infr_match_ctxt_t *p_infr_match = (osm_infr_match_ctxt_t *) context;
+ ib_mad_notice_attr_t *p_ntc = p_infr_match->p_ntc;
+ osm_infr_t *p_infr_rec = (osm_infr_t *) p_list_item;
+ ib_inform_info_t *p_ii = &(p_infr_rec->inform_record.inform_info);
+ osm_log_t *p_log = p_infr_rec->sa->p_log;
+
+ OSM_LOG_ENTER(p_log);
+
+ /* matching rules
+ * InformInfo Notice
+ * GID IssuerGID if non zero must match the trap
+ * LIDRange IssuerLID apply only if GID=0
+ * IsGeneric IsGeneric is compulsory and must match the trap
+ * Type Type if not 0xFFFF must match
+ * TrapNumber TrapNumber if not 0xFFFF must match
+ * DeviceId DeviceID if not 0xFFFF must match
+ * QPN dont care
+ * ProducerType ProducerType match or 0xFFFFFF // EZ: actually my interpretation
+ * VendorID VendorID match or 0xFFFFFF
+ */
+
+ /* GID IssuerGID if non zero must match the trap */
+ if (p_ii->gid.unicast.prefix != 0
+ || p_ii->gid.unicast.interface_id != 0) {
+ /* match by GID */
+ if (memcmp(&(p_ii->gid), &(p_ntc->issuer_gid),
+ sizeof(ib_gid_t))) {
+ OSM_LOG(p_log, OSM_LOG_DEBUG, "Mismatch by GID\n");
+ goto Exit;
+ }
+ } else {
+ /* LIDRange IssuerLID apply only if GID=0 */
+ /* If lid_range_begin of the informInfo is 0xFFFF - then it should be ignored. */
+ if (p_ii->lid_range_begin != 0xFFFF) {
+ /* a real lid range is given - check it */
+ if ((cl_hton16(p_ii->lid_range_begin) >
+ cl_hton16(p_ntc->issuer_lid))
+ || (cl_hton16(p_ntc->issuer_lid) >
+ cl_hton16(p_ii->lid_range_end))) {
+ OSM_LOG(p_log, OSM_LOG_DEBUG,
+ "Mismatch by LID Range. Needed: %u <= %u <= %u\n",
+ cl_hton16(p_ii->lid_range_begin),
+ cl_hton16(p_ntc->issuer_lid),
+ cl_hton16(p_ii->lid_range_end));
+ goto Exit;
+ }
+ }
+ }
+
+ /* IsGeneric IsGeneric is compulsory and must match the trap */
+ if ((p_ii->is_generic && !ib_notice_is_generic(p_ntc)) ||
+ (!p_ii->is_generic && ib_notice_is_generic(p_ntc))) {
+ OSM_LOG(p_log, OSM_LOG_DEBUG, "Mismatch by Generic/Vendor\n");
+ goto Exit;
+ }
+
+ /* Type Type if not 0xFFFF must match */
+ if ((p_ii->trap_type != 0xFFFF) &&
+ (cl_ntoh16(p_ii->trap_type) != ib_notice_get_type(p_ntc))) {
+ OSM_LOG(p_log, OSM_LOG_DEBUG, "Mismatch by Type\n");
+ goto Exit;
+ }
+
+ /* based on generic type */
+ if (p_ii->is_generic) {
+ /* TrapNumber TrapNumber if not 0xFFFF must match */
+ if ((p_ii->g_or_v.generic.trap_num != 0xFFFF) &&
+ (p_ii->g_or_v.generic.trap_num !=
+ p_ntc->g_or_v.generic.trap_num)) {
+ OSM_LOG(p_log, OSM_LOG_DEBUG, "Mismatch by Trap Num\n");
+ goto Exit;
+ }
+
+ /* ProducerType ProducerType match or 0xFFFFFF */
+ if ((cl_ntoh32(ib_inform_info_get_prod_type(p_ii)) != 0xFFFFFF)
+ && (ib_inform_info_get_prod_type(p_ii) !=
+ ib_notice_get_prod_type(p_ntc))) {
+ OSM_LOG(p_log, OSM_LOG_DEBUG,
+ "Mismatch by Node Type: II=0x%06X (%s) Trap=0x%06X (%s)\n",
+ cl_ntoh32(ib_inform_info_get_prod_type(p_ii)),
+ ib_get_producer_type_str
+ (ib_inform_info_get_prod_type(p_ii)),
+ cl_ntoh32(ib_notice_get_prod_type(p_ntc)),
+ ib_get_producer_type_str(ib_notice_get_prod_type
+ (p_ntc)));
+ goto Exit;
+ }
+ } else {
+ /* DeviceId DeviceID if not 0xFFFF must match */
+ if ((p_ii->g_or_v.vend.dev_id != 0xFFFF) &&
+ (p_ii->g_or_v.vend.dev_id != p_ntc->g_or_v.vend.dev_id)) {
+ OSM_LOG(p_log, OSM_LOG_DEBUG, "Mismatch by Dev Id\n");
+ goto Exit;
+ }
+
+ /* VendorID VendorID match or 0xFFFFFF */
+ if ((ib_inform_info_get_vend_id(p_ii) != CL_HTON32(0xFFFFFF)) &&
+ (ib_inform_info_get_vend_id(p_ii) !=
+ ib_notice_get_vend_id(p_ntc))) {
+ OSM_LOG(p_log, OSM_LOG_DEBUG,
+ "Mismatch by Vendor ID\n");
+ goto Exit;
+ }
+ }
+
+ if (!is_access_permitted(p_infr_rec, p_infr_match))
+ goto Exit;
+
+ /* send the report to the address provided in the inform record */
+ OSM_LOG(p_log, OSM_LOG_DEBUG, "MATCH! Sending Report...\n");
+ send_report(p_infr_rec, p_ntc);
+
+Exit:
+ OSM_LOG_EXIT(p_log);
+}
+
+/**********************************************************************
+ * Once a Trap was received by osm_trap_rcv, or a Trap sourced by
+ * the SM was sent (Traps 64-67), this routine is called with a copy of
+ * the notice data.
+ * Given a notice attribute - compare and see if it matches the InformInfo
+ * element and if it does - call the Report(Notice) for the
+ * target QP registered by the address stored in the InformInfo element
+ **********************************************************************/
+static void log_notice(osm_log_t * log, osm_log_level_t level,
+ ib_mad_notice_attr_t * ntc)
+{
+ char gid_str[INET6_ADDRSTRLEN], gid_str2[INET6_ADDRSTRLEN];
+ ib_gid_t *gid;
+ ib_gid_t *gid1, *gid2;
+
+ /* an official Event information log */
+ if (ib_notice_is_generic(ntc)) {
+ if ((ntc->g_or_v.generic.trap_num == CL_HTON16(SM_GID_IN_SERVICE_TRAP)) ||
+ (ntc->g_or_v.generic.trap_num == CL_HTON16(SM_GID_OUT_OF_SERVICE_TRAP)) ||
+ (ntc->g_or_v.generic.trap_num == CL_HTON16(SM_MGID_CREATED_TRAP)) ||
+ (ntc->g_or_v.generic.trap_num == CL_HTON16(SM_MGID_DESTROYED_TRAP)))
+ gid = &ntc->data_details.ntc_64_67.gid;
+ else
+ gid = &ntc->issuer_gid;
+
+ switch (cl_ntoh16(ntc->g_or_v.generic.trap_num)) {
+ case SM_GID_IN_SERVICE_TRAP:
+ case SM_GID_OUT_OF_SERVICE_TRAP:
+ OSM_LOG(log, level,
+ "Reporting Informational Notice \"%s\", GID:%s\n",
+ ib_get_trap_str(ntc->g_or_v.generic.trap_num),
+ inet_ntop(AF_INET6, gid->raw, gid_str, sizeof gid_str));
+ break;
+ case SM_MGID_CREATED_TRAP:
+ case SM_MGID_DESTROYED_TRAP:
+ OSM_LOG(log, level,
+ "Reporting Informational Notice \"%s\", MGID:%s\n",
+ ib_get_trap_str(ntc->g_or_v.generic.trap_num),
+ inet_ntop(AF_INET6, gid->raw, gid_str, sizeof gid_str));
+ break;
+ case SM_UNPATH_TRAP:
+ case SM_REPATH_TRAP:
+ /* TODO: Fill in details once SM starts to use these traps */
+ OSM_LOG(log, level,
+ "Reporting Informational Notice \"%s\"n",
+ ib_get_trap_str(ntc->g_or_v.generic.trap_num));
+ break;
+ case SM_LINK_STATE_CHANGED_TRAP:
+ OSM_LOG(log, level,
+ "Reporting Urgent Notice \"%s\" from switch LID %u, "
+ "GUID 0x%016" PRIx64 "\n",
+ ib_get_trap_str(ntc->g_or_v.generic.trap_num),
+ cl_ntoh16(ntc->issuer_lid),
+ cl_ntoh64(gid->unicast.interface_id));
+ break;
+ case SM_LINK_INTEGRITY_THRESHOLD_TRAP:
+ case SM_BUFFER_OVERRUN_THRESHOLD_TRAP:
+ case SM_WATCHDOG_TIMER_EXPIRED_TRAP:
+ OSM_LOG(log, level,
+ "Reporting Urgent Notice \"%s\" from LID %u, "
+ "GUID 0x%016" PRIx64 ", port %u\n",
+ ib_get_trap_str(ntc->g_or_v.generic.trap_num),
+ cl_ntoh16(ntc->issuer_lid),
+ cl_ntoh64(gid->unicast.interface_id),
+ ntc->data_details.ntc_129_131.port_num);
+ break;
+ case SM_LOCAL_CHANGES_TRAP:
+ if (ntc->data_details.ntc_144.local_changes == 1)
+ OSM_LOG(log, level,
+ "Reporting Informational Notice \"%s\" from LID %u, "
+ "GUID 0x%016" PRIx64 ", ChangeFlags 0x%04x, "
+ "CapabilityMask2 0x%04x\n",
+ ib_get_trap_str(ntc->g_or_v.generic.trap_num),
+ cl_ntoh16(ntc->issuer_lid),
+ cl_ntoh64(gid->unicast.interface_id),
+ cl_ntoh16(ntc->data_details.ntc_144.change_flgs),
+ cl_ntoh16(ntc->data_details.ntc_144.cap_mask2));
+ else
+ OSM_LOG(log, level,
+ "Reporting Informational Notice \"%s\" from LID %u, "
+ "GUID 0x%016" PRIx64 ", new CapabilityMask 0x%08x\n",
+ ib_get_trap_str(ntc->g_or_v.generic.trap_num),
+ cl_ntoh16(ntc->issuer_lid),
+ cl_ntoh64(gid->unicast.interface_id),
+ cl_ntoh32(ntc->data_details.ntc_144.new_cap_mask));
+ break;
+ case SM_SYS_IMG_GUID_CHANGED_TRAP:
+ OSM_LOG(log, level,
+ "Reporting Informational Notice \"%s\" from LID %u, "
+ "GUID 0x%016" PRIx64 ", new SysImageGUID 0x%016" PRIx64 "\n",
+ ib_get_trap_str(ntc->g_or_v.generic.trap_num),
+ cl_ntoh16(ntc->issuer_lid),
+ cl_ntoh64(gid->unicast.interface_id),
+ cl_ntoh64(ntc->data_details.ntc_145.new_sys_guid));
+ break;
+ case SM_BAD_MKEY_TRAP:
+ OSM_LOG(log, level,
+ "Reporting Security Notice \"%s\" from LID %u, "
+ "GUID 0x%016" PRIx64 ", Method 0x%x, Attribute 0x%x, "
+ "AttrMod 0x%x, M_Key 0x%016" PRIx64 "\n",
+ ib_get_trap_str(ntc->g_or_v.generic.trap_num),
+ cl_ntoh16(ntc->issuer_lid),
+ cl_ntoh64(gid->unicast.interface_id),
+ ntc->data_details.ntc_256.method,
+ cl_ntoh16(ntc->data_details.ntc_256.attr_id),
+ cl_ntoh32(ntc->data_details.ntc_256.attr_mod),
+ cl_ntoh64(ntc->data_details.ntc_256.mkey));
+ break;
+ case SM_BAD_PKEY_TRAP:
+ case SM_BAD_QKEY_TRAP:
+ gid1 = &ntc->data_details.ntc_257_258.gid1;
+ gid2 = &ntc->data_details.ntc_257_258.gid2;
+ OSM_LOG(log, level,
+ "Reporting Security Notice \"%s\" from LID %u, "
+ "GUID 0x%016" PRIx64 " : LID1 %u, LID2 %u, %s 0x%x, "
+ "SL %d, QP1 0x%x, QP2 0x%x, GID1 %s, GID2 %s\n",
+ ib_get_trap_str(ntc->g_or_v.generic.trap_num),
+ cl_ntoh16(ntc->issuer_lid),
+ cl_ntoh64(gid->unicast.interface_id),
+ cl_ntoh16(ntc->data_details.ntc_257_258.lid1),
+ cl_ntoh16(ntc->data_details.ntc_257_258.lid2),
+ cl_ntoh16(ntc->g_or_v.generic.trap_num) == SM_BAD_QKEY_TRAP ?
+ "Q_Key" : "P_Key",
+ cl_ntoh32(ntc->data_details.ntc_257_258.key),
+ cl_ntoh32(ntc->data_details.ntc_257_258.qp1) >> 28,
+ cl_ntoh32(ntc->data_details.ntc_257_258.qp1) & 0xffffff,
+ cl_ntoh32(ntc->data_details.ntc_257_258.qp2) & 0xffffff,
+ inet_ntop(AF_INET6, gid1->raw, gid_str, sizeof gid_str),
+ inet_ntop(AF_INET6, gid2->raw, gid_str2, sizeof gid_str2));
+ break;
+ case SM_BAD_SWITCH_PKEY_TRAP:
+ gid1 = &ntc->data_details.ntc_259.gid1;
+ gid2 = &ntc->data_details.ntc_259.gid2;
+ OSM_LOG(log, level,
+ "Reporting Security Notice \"%s\" from switch LID %u, "
+ "GUID 0x%016" PRIx64 " port %d : data_valid 0x%04x, "
+ "LID1 %u, LID2 %u, PKey 0x%04x, "
+ "SL %d, QP1 0x%x, QP2 0x%x, GID1 %s, GID2 %s\n",
+ ib_get_trap_str(ntc->g_or_v.generic.trap_num),
+ cl_ntoh16(ntc->issuer_lid),
+ cl_ntoh64(gid->unicast.interface_id),
+ ntc->data_details.ntc_259.port_no,
+ cl_ntoh16(ntc->data_details.ntc_259.data_valid),
+ cl_ntoh16(ntc->data_details.ntc_259.lid1),
+ cl_ntoh16(ntc->data_details.ntc_259.lid2),
+ cl_ntoh16(ntc->data_details.ntc_257_258.key),
+ cl_ntoh32(ntc->data_details.ntc_259.sl_qp1) >> 28,
+ cl_ntoh32(ntc->data_details.ntc_259.sl_qp1) & 0xffffff,
+ cl_ntoh32(ntc->data_details.ntc_259.qp2),
+ inet_ntop(AF_INET6, gid1->raw, gid_str, sizeof gid_str),
+ inet_ntop(AF_INET6, gid2->raw, gid_str2, sizeof gid_str2));
+ break;
+ default:
+ OSM_LOG(log, level,
+ "Reporting Generic Notice type:%u num:%u (%s)"
+ " from LID:%u GID:%s\n",
+ ib_notice_get_type(ntc),
+ cl_ntoh16(ntc->g_or_v.generic.trap_num),
+ ib_get_trap_str(ntc->g_or_v.generic.trap_num),
+ cl_ntoh16(ntc->issuer_lid),
+ inet_ntop(AF_INET6, gid->raw, gid_str, sizeof gid_str));
+ break;
+ }
+ } else
+ OSM_LOG(log, level,
+ "Reporting Vendor Notice type:%u vend:%u dev:%u"
+ " from LID:%u GID:%s\n",
+ ib_notice_get_type(ntc),
+ cl_ntoh32(ib_notice_get_vend_id(ntc)),
+ cl_ntoh16(ntc->g_or_v.vend.dev_id),
+ cl_ntoh16(ntc->issuer_lid),
+ inet_ntop(AF_INET6, ntc->issuer_gid.raw, gid_str,
+ sizeof gid_str));
+}
+
+ib_api_status_t osm_report_notice(IN osm_log_t * p_log, IN osm_subn_t * p_subn,
+ IN ib_mad_notice_attr_t * p_ntc)
+{
+ osm_infr_match_ctxt_t context;
+ cl_list_t infr_to_remove_list;
+ osm_infr_t *p_infr_rec;
+ osm_infr_t *p_next_infr_rec;
+
+ OSM_LOG_ENTER(p_log);
+
+ /*
+ * we must make sure we are ready for this...
+ * note that the trap receivers might be initialized before
+ * the osm_infr_init call is performed.
+ */
+ if (p_subn->sa_infr_list.state != CL_INITIALIZED) {
+ OSM_LOG(p_log, OSM_LOG_DEBUG,
+ "Ignoring Notice Reports since Inform List is not initialized yet!\n");
+ return IB_ERROR;
+ }
+
+ if (OSM_LOG_IS_ACTIVE_V2(p_log, OSM_LOG_INFO))
+ log_notice(p_log, OSM_LOG_INFO, p_ntc);
+
+ /* Create a list that will hold all the infr records that should
+ be removed due to violation. o13-17.1.2 */
+ cl_list_construct(&infr_to_remove_list);
+ cl_list_init(&infr_to_remove_list, 5);
+ context.p_remove_infr_list = &infr_to_remove_list;
+ context.p_ntc = p_ntc;
+
+ /* go over all inform info available at the subnet */
+ /* try match to the given notice and send if match */
+ cl_qlist_apply_func(&p_subn->sa_infr_list, match_notice_to_inf_rec,
+ &context);
+
+ /* If we inserted items into the infr_to_remove_list - we need to
+ remove them */
+ p_infr_rec = (osm_infr_t *) cl_list_remove_head(&infr_to_remove_list);
+ while (p_infr_rec != NULL) {
+ p_next_infr_rec =
+ (osm_infr_t *) cl_list_remove_head(&infr_to_remove_list);
+ osm_infr_remove_from_db(p_subn, p_log, p_infr_rec);
+ p_infr_rec = p_next_infr_rec;
+ }
+ cl_list_destroy(&infr_to_remove_list);
+
+ /* report IB traps to plugin */
+ osm_opensm_report_event(p_subn->p_osm, OSM_EVENT_ID_TRAP, p_ntc);
+
+ OSM_LOG_EXIT(p_log);
+
+ return IB_SUCCESS;
+}
diff --git a/contrib/ofed/opensm/opensm/osm_lid_mgr.c b/contrib/ofed/opensm/opensm/osm_lid_mgr.c
new file mode 100644
index 0000000..9c0c07d
--- /dev/null
+++ b/contrib/ofed/opensm/opensm/osm_lid_mgr.c
@@ -0,0 +1,1253 @@
+/*
+ * Copyright (c) 2004-2009 Voltaire, Inc. All rights reserved.
+ * Copyright (c) 2002-2008 Mellanox Technologies LTD. All rights reserved.
+ * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+/*
+ * Abstract:
+ * Implementation of osm_lid_mgr_t.
+ * This file implements the LID Manager object which is responsible for
+ * assigning LIDs to all ports on the subnet.
+ *
+ * DATA STRUCTURES:
+ * p_subn->port_lid_tbl : a vector pointing from lid to its port.
+ * osm db guid2lid domain : a hash from guid to lid (min lid).
+ * p_subn->port_guid_tbl : a map from guid to discovered port obj.
+ *
+ * ALGORITHM:
+ *
+ * 0. we define a function to obtain the correct port lid:
+ * lid_mgr_get_port_lid( p_mgr, port, &min_lid, &max_lid ):
+ * 0.1 if the port info lid matches the guid2lid return 0
+ * 0.2 if the port info has a lid and that range is empty in
+ * port_lid_tbl, return 0 and update the port_lid_tbl and
+ * guid2lid
+ * 0.3 else find an empty space in port_lid_tbl, update the
+ * port_lid_tbl and guid2lid, return 1 to flag a change required.
+ *
+ * 1. During initialization:
+ * 1.1 initialize the guid2lid database domain.
+ * 1.2 if reassign_lid is not set:
+ * 1.2.1 read the persistent data for the domain.
+ * 1.2.2 validate no duplicate use of lids and lids are 2^(lmc-1)
+ *
+ * 2. During SM port lid assignment:
+ * 2.1 if reassign_lids is set, make it 2^lmc
+ * 2.2 cleanup all port_lid_tbl and re-fill it according to guid2lid
+ * 2.3 call lid_mgr_get_port_lid for the SM port
+ * 2.4 set the port info
+ *
+ * 3. During all other ports lid assignment:
+ * 3.1 go through all ports in the subnet
+ * 3.1.1 call lid_mgr_get_port_lid
+ * 3.1.2 if a change required send the port info
+ * 3.2 if any change send the signal PENDING...
+ *
+ * 4. Store the guid2lid
+ */
+
+#if HAVE_CONFIG_H
+# include <config.h>
+#endif /* HAVE_CONFIG_H */
+
+#include <stdlib.h>
+#include <string.h>
+#include <iba/ib_types.h>
+#include <complib/cl_qmap.h>
+#include <complib/cl_debug.h>
+#include <opensm/osm_file_ids.h>
+#define FILE_ID OSM_FILE_LID_MGR_C
+#include <opensm/osm_lid_mgr.h>
+#include <opensm/osm_sm.h>
+#include <opensm/osm_log.h>
+#include <opensm/osm_node.h>
+#include <opensm/osm_switch.h>
+#include <opensm/osm_helper.h>
+#include <opensm/osm_msgdef.h>
+#include <vendor/osm_vendor_api.h>
+#include <opensm/osm_db_pack.h>
+
+/**********************************************************************
+ lid range item of qlist
+ **********************************************************************/
+typedef struct osm_lid_mgr_range {
+ cl_list_item_t item;
+ uint16_t min_lid;
+ uint16_t max_lid;
+} osm_lid_mgr_range_t;
+
+void osm_lid_mgr_construct(IN osm_lid_mgr_t * p_mgr)
+{
+ memset(p_mgr, 0, sizeof(*p_mgr));
+}
+
+void osm_lid_mgr_destroy(IN osm_lid_mgr_t * p_mgr)
+{
+ cl_list_item_t *p_item;
+
+ OSM_LOG_ENTER(p_mgr->p_log);
+
+ while ((p_item = cl_qlist_remove_head(&p_mgr->free_ranges)) !=
+ cl_qlist_end(&p_mgr->free_ranges))
+ free((osm_lid_mgr_range_t *) p_item);
+ OSM_LOG_EXIT(p_mgr->p_log);
+}
+
+/**********************************************************************
+Validate the guid to lid data by making sure that under the current
+LMC we did not get duplicates. If we do flag them as errors and remove
+the entry.
+**********************************************************************/
+static void lid_mgr_validate_db(IN osm_lid_mgr_t * p_mgr)
+{
+ cl_qlist_t guids;
+ osm_db_guid_elem_t *p_item;
+ uint16_t lid;
+ uint16_t min_lid;
+ uint16_t max_lid;
+ uint16_t lmc_mask;
+ boolean_t lids_ok;
+ uint8_t lmc_num_lids = (uint8_t) (1 << p_mgr->p_subn->opt.lmc);
+
+ OSM_LOG_ENTER(p_mgr->p_log);
+
+ lmc_mask = ~(lmc_num_lids - 1);
+
+ cl_qlist_init(&guids);
+
+ if (osm_db_guid2lid_guids(p_mgr->p_g2l, &guids)) {
+ OSM_LOG(p_mgr->p_log, OSM_LOG_ERROR, "ERR 0310: "
+ "could not get guid list\n");
+ goto Exit;
+ }
+
+ while ((p_item = (osm_db_guid_elem_t *) cl_qlist_remove_head(&guids))
+ != (osm_db_guid_elem_t *) cl_qlist_end(&guids)) {
+ if (osm_db_guid2lid_get(p_mgr->p_g2l, p_item->guid,
+ &min_lid, &max_lid))
+ OSM_LOG(p_mgr->p_log, OSM_LOG_ERROR, "ERR 0311: "
+ "could not get lid for guid:0x%016" PRIx64 "\n",
+ p_item->guid);
+ else {
+ lids_ok = TRUE;
+
+ if (min_lid > max_lid || min_lid == 0
+ || p_item->guid == 0
+ || max_lid > p_mgr->p_subn->max_ucast_lid_ho) {
+ OSM_LOG(p_mgr->p_log, OSM_LOG_ERROR,
+ "ERR 0312: "
+ "Illegal LID range [%u:%u] for "
+ "guid:0x%016" PRIx64 "\n", min_lid,
+ max_lid, p_item->guid);
+ lids_ok = FALSE;
+ } else if (min_lid != max_lid
+ && (min_lid & lmc_mask) != min_lid) {
+ /* check that if the lids define a range that is
+ valid for the current LMC mask */
+ OSM_LOG(p_mgr->p_log, OSM_LOG_ERROR,
+ "ERR 0313: "
+ "LID range [%u:%u] for guid:0x%016"
+ PRIx64
+ " is not aligned according to mask:0x%04x\n",
+ min_lid, max_lid, p_item->guid,
+ lmc_mask);
+ lids_ok = FALSE;
+ } else {
+ /* check if the lids were not previously assigned */
+ for (lid = min_lid; lid <= max_lid; lid++) {
+ if (p_mgr->used_lids[lid]) {
+ OSM_LOG(p_mgr->p_log,
+ OSM_LOG_ERROR,
+ "ERR 0314: "
+ "0x%04x for guid:0x%016"
+ PRIx64
+ " was previously used\n",
+ lid, p_item->guid);
+ lids_ok = FALSE;
+ }
+ }
+ }
+
+ if (lids_ok)
+ /* mark that it was visited */
+ for (lid = min_lid; lid <= max_lid; lid++) {
+ if (lid < min_lid + lmc_num_lids)
+ p_mgr->used_lids[lid] = 1;
+ }
+ else if (osm_db_guid2lid_delete(p_mgr->p_g2l,
+ p_item->guid))
+ OSM_LOG(p_mgr->p_log, OSM_LOG_ERROR,
+ "ERR 0315: failed to delete entry for "
+ "guid:0x%016" PRIx64 "\n",
+ p_item->guid);
+ } /* got a lid */
+ free(p_item);
+ } /* all guids */
+Exit:
+ OSM_LOG_EXIT(p_mgr->p_log);
+}
+
+ib_api_status_t osm_lid_mgr_init(IN osm_lid_mgr_t * p_mgr, IN osm_sm_t * sm)
+{
+ ib_api_status_t status = IB_SUCCESS;
+
+ OSM_LOG_ENTER(sm->p_log);
+
+ osm_lid_mgr_construct(p_mgr);
+
+ p_mgr->sm = sm;
+ p_mgr->p_log = sm->p_log;
+ p_mgr->p_subn = sm->p_subn;
+ p_mgr->p_db = sm->p_db;
+ p_mgr->p_lock = sm->p_lock;
+
+ /* we initialize and restore the db domain of guid to lid map */
+ p_mgr->p_g2l = osm_db_domain_init(p_mgr->p_db, "guid2lid");
+ if (!p_mgr->p_g2l) {
+ OSM_LOG(p_mgr->p_log, OSM_LOG_ERROR, "ERR 0316: "
+ "Error initializing Guid-to-Lid persistent database\n");
+ status = IB_ERROR;
+ goto Exit;
+ }
+
+ cl_qlist_init(&p_mgr->free_ranges);
+
+ /* we use the stored guid to lid table if not forced to reassign */
+ if (!p_mgr->p_subn->opt.reassign_lids) {
+ if (osm_db_restore(p_mgr->p_g2l)) {
+#ifndef __WIN__
+ /*
+ * When Windows is BSODing, it might corrupt files that
+ * were previously opened for writing, even if the files
+ * are closed, so we might see corrupted guid2lid file.
+ */
+ if (p_mgr->p_subn->opt.exit_on_fatal) {
+ osm_log_v2(p_mgr->p_log, OSM_LOG_SYS, FILE_ID,
+ "FATAL: Error restoring Guid-to-Lid "
+ "persistent database\n");
+ status = IB_ERROR;
+ goto Exit;
+ } else
+#endif
+ OSM_LOG(p_mgr->p_log, OSM_LOG_ERROR,
+ "ERR 0317: Error restoring Guid-to-Lid "
+ "persistent database\n");
+ }
+
+ /* we need to make sure we did not get duplicates with
+ current lmc */
+ lid_mgr_validate_db(p_mgr);
+ }
+
+Exit:
+ OSM_LOG_EXIT(p_mgr->p_log);
+ return status;
+}
+
+static uint16_t trim_lid(IN uint16_t lid)
+{
+ if (lid > IB_LID_UCAST_END_HO || lid < IB_LID_UCAST_START_HO)
+ return 0;
+ return lid;
+}
+
+/**********************************************************************
+ initialize the manager for a new sweep:
+ scans the known persistent assignment and port_lid_tbl
+ re-calculate all empty ranges.
+ cleanup invalid port_lid_tbl entries
+**********************************************************************/
+static int lid_mgr_init_sweep(IN osm_lid_mgr_t * p_mgr)
+{
+ cl_ptr_vector_t *p_discovered_vec = &p_mgr->p_subn->port_lid_tbl;
+ uint16_t max_defined_lid, max_persistent_lid, max_discovered_lid;
+ uint16_t disc_min_lid, disc_max_lid, db_min_lid, db_max_lid;
+ int status = 0;
+ cl_list_item_t *p_item;
+ boolean_t is_free;
+ osm_lid_mgr_range_t *p_range = NULL;
+ osm_port_t *p_port;
+ cl_qmap_t *p_port_guid_tbl;
+ uint8_t lmc_num_lids = (uint8_t) (1 << p_mgr->p_subn->opt.lmc);
+ uint16_t lmc_mask, req_lid, num_lids, lid;
+
+ OSM_LOG_ENTER(p_mgr->p_log);
+
+ lmc_mask = ~((1 << p_mgr->p_subn->opt.lmc) - 1);
+
+ /* We must discard previous guid2lid db if this is the first master
+ * sweep and reassign_lids option is TRUE.
+ * If we came out of standby and honor_guid2lid_file option is TRUE, we
+ * must restore guid2lid db. Otherwise if honor_guid2lid_file option is
+ * FALSE we must discard previous guid2lid db.
+ */
+ if (p_mgr->p_subn->first_time_master_sweep == TRUE &&
+ p_mgr->p_subn->opt.reassign_lids == TRUE) {
+ osm_db_clear(p_mgr->p_g2l);
+ memset(p_mgr->used_lids, 0, sizeof(p_mgr->used_lids));
+ } else if (p_mgr->p_subn->coming_out_of_standby == TRUE) {
+ osm_db_clear(p_mgr->p_g2l);
+ memset(p_mgr->used_lids, 0, sizeof(p_mgr->used_lids));
+ if (p_mgr->p_subn->opt.honor_guid2lid_file == FALSE)
+ OSM_LOG(p_mgr->p_log, OSM_LOG_DEBUG,
+ "Ignore guid2lid file when coming out of standby\n");
+ else {
+ OSM_LOG(p_mgr->p_log, OSM_LOG_DEBUG,
+ "Honor current guid2lid file when coming out "
+ "of standby\n");
+ if (osm_db_restore(p_mgr->p_g2l))
+ OSM_LOG(p_mgr->p_log, OSM_LOG_ERROR,
+ "ERR 0306: "
+ "Error restoring Guid-to-Lid "
+ "persistent database. Ignoring it\n");
+ lid_mgr_validate_db(p_mgr);
+ }
+ }
+
+ /* we need to cleanup the empty ranges list */
+ while ((p_item = cl_qlist_remove_head(&p_mgr->free_ranges)) !=
+ cl_qlist_end(&p_mgr->free_ranges))
+ free((osm_lid_mgr_range_t *) p_item);
+
+ /* first clean up the port_by_lid_tbl */
+ for (lid = 0; lid < cl_ptr_vector_get_size(p_discovered_vec); lid++)
+ cl_ptr_vector_set(p_discovered_vec, lid, NULL);
+
+ /* we if are in the first sweep and in reassign lids mode
+ we should ignore all the available info and simply define one
+ huge empty range */
+ if (p_mgr->p_subn->first_time_master_sweep == TRUE &&
+ p_mgr->p_subn->opt.reassign_lids == TRUE) {
+ OSM_LOG(p_mgr->p_log, OSM_LOG_DEBUG,
+ "Skipping all lids as we are reassigning them\n");
+ p_range = malloc(sizeof(osm_lid_mgr_range_t));
+ if (p_range)
+ p_range->min_lid = 1;
+ goto AfterScanningLids;
+ }
+
+ /* go over all discovered ports and mark their entries */
+ p_port_guid_tbl = &p_mgr->p_subn->port_guid_tbl;
+
+ for (p_port = (osm_port_t *) cl_qmap_head(p_port_guid_tbl);
+ p_port != (osm_port_t *) cl_qmap_end(p_port_guid_tbl);
+ p_port = (osm_port_t *) cl_qmap_next(&p_port->map_item)) {
+ osm_port_get_lid_range_ho(p_port, &disc_min_lid, &disc_max_lid);
+ disc_min_lid = trim_lid(disc_min_lid);
+ disc_max_lid = trim_lid(disc_max_lid);
+ for (lid = disc_min_lid; lid <= disc_max_lid; lid++) {
+ if (lid < disc_min_lid + lmc_num_lids)
+ cl_ptr_vector_set(p_discovered_vec, lid, p_port);
+ else
+ cl_ptr_vector_set(p_discovered_vec, lid, NULL);
+ }
+ /* make sure the guid2lid entry is valid. If not, clean it. */
+ if (osm_db_guid2lid_get(p_mgr->p_g2l,
+ cl_ntoh64(osm_port_get_guid(p_port)),
+ &db_min_lid, &db_max_lid))
+ continue;
+
+ if (!p_port->p_node->sw ||
+ osm_switch_sp0_is_lmc_capable(p_port->p_node->sw,
+ p_mgr->p_subn))
+ num_lids = lmc_num_lids;
+ else
+ num_lids = 1;
+
+ if (num_lids != 1 &&
+ ((db_min_lid & lmc_mask) != db_min_lid ||
+ db_max_lid - db_min_lid + 1 < num_lids)) {
+ /* Not aligned, or not wide enough, then remove the entry */
+ OSM_LOG(p_mgr->p_log, OSM_LOG_DEBUG,
+ "Cleaning persistent entry for guid:"
+ "0x%016" PRIx64 " illegal range:[0x%x:0x%x]\n",
+ cl_ntoh64(osm_port_get_guid(p_port)),
+ db_min_lid, db_max_lid);
+ osm_db_guid2lid_delete(p_mgr->p_g2l,
+ cl_ntoh64
+ (osm_port_get_guid(p_port)));
+ for (lid = db_min_lid; lid <= db_max_lid; lid++)
+ p_mgr->used_lids[lid] = 0;
+ }
+ }
+
+ /*
+ Our task is to find free lid ranges.
+ A lid can be used if
+ 1. a persistent assignment exists
+ 2. the lid is used by a discovered port that does not have a
+ persistent assignment.
+
+ scan through all lid values of both the persistent table and
+ discovered table.
+ If the lid has an assigned port in the discovered table:
+ * make sure the lid matches the persistent table, or
+ * there is no other persistent assignment for that lid.
+ * else cleanup the port_by_lid_tbl, mark this as empty range.
+ Else if the lid does not have an entry in the persistent table
+ mark it as free.
+ */
+
+ /* find the range of lids to scan */
+ max_discovered_lid =
+ (uint16_t) cl_ptr_vector_get_size(p_discovered_vec);
+ max_persistent_lid = sizeof(p_mgr->used_lids) - 1;
+
+ /* but the vectors have one extra entry for lid=0 */
+ if (max_discovered_lid)
+ max_discovered_lid--;
+
+ if (max_persistent_lid > max_discovered_lid)
+ max_defined_lid = max_persistent_lid;
+ else
+ max_defined_lid = max_discovered_lid;
+
+ for (lid = 1; lid <= max_defined_lid; lid++) {
+ is_free = TRUE;
+ /* first check to see if the lid is used by a persistent assignment */
+ if (lid <= max_persistent_lid && p_mgr->used_lids[lid]) {
+ OSM_LOG(p_mgr->p_log, OSM_LOG_DEBUG,
+ "0x%04x is not free as its mapped by the "
+ "persistent db\n", lid);
+ is_free = FALSE;
+ /* check this is a discovered port */
+ } else if (lid <= max_discovered_lid &&
+ (p_port = cl_ptr_vector_get(p_discovered_vec,
+ lid))) {
+ /* we have a port. Now lets see if we can preserve its lid range. */
+ /* For that, we need to make sure:
+ 1. The port has a (legal) persistency entry. Then the
+ local lid is free (we will use the persistency value).
+ 2. Can the port keep its local assignment?
+ a. Make sure the lid is aligned.
+ b. Make sure all needed lids (for the lmc) are free
+ according to persistency table.
+ */
+ /* qualify the guid of the port is not persistently
+ mapped to another range */
+ if (!osm_db_guid2lid_get(p_mgr->p_g2l,
+ cl_ntoh64
+ (osm_port_get_guid(p_port)),
+ &db_min_lid, &db_max_lid)) {
+ OSM_LOG(p_mgr->p_log, OSM_LOG_DEBUG,
+ "0x%04x is free as it was "
+ "discovered but mapped by the "
+ "persistent db to [0x%04x:0x%04x]\n",
+ lid, db_min_lid, db_max_lid);
+ } else {
+ /* can the port keep its assignment ? */
+ /* get the lid range of that port, and the
+ required number of lids we are about to
+ assign to it */
+ osm_port_get_lid_range_ho(p_port,
+ &disc_min_lid,
+ &disc_max_lid);
+ if (!p_port->p_node->sw ||
+ osm_switch_sp0_is_lmc_capable
+ (p_port->p_node->sw, p_mgr->p_subn)) {
+ disc_max_lid =
+ disc_min_lid + lmc_num_lids - 1;
+ num_lids = lmc_num_lids;
+ } else
+ num_lids = 1;
+
+ /* Make sure the lid is aligned */
+ if (num_lids != 1
+ && (disc_min_lid & lmc_mask) !=
+ disc_min_lid) {
+ /* The lid cannot be used */
+ OSM_LOG(p_mgr->p_log, OSM_LOG_DEBUG,
+ "0x%04x is free as it was "
+ "discovered but not aligned\n",
+ lid);
+ } else {
+ /* check that all needed lids are not persistently mapped */
+ is_free = FALSE;
+ for (req_lid = disc_min_lid + 1;
+ req_lid <= disc_max_lid;
+ req_lid++) {
+ if (req_lid <=
+ max_persistent_lid &&
+ p_mgr->used_lids[req_lid]) {
+ OSM_LOG(p_mgr->p_log,
+ OSM_LOG_DEBUG,
+ "0x%04x is free as it was discovered "
+ "but mapped\n",
+ lid);
+ is_free = TRUE;
+ break;
+ }
+ }
+
+ if (is_free == FALSE) {
+ /* This port will use its local lid, and consume the entire required lid range.
+ Thus we can skip that range. */
+ /* If the disc_max_lid is greater then lid, we can skip right to it,
+ since we've done all neccessary checks on the lids in between. */
+ if (disc_max_lid > lid)
+ lid = disc_max_lid;
+ }
+ }
+ }
+ }
+
+ if (is_free) {
+ if (p_range)
+ p_range->max_lid = lid;
+ else {
+ p_range = malloc(sizeof(osm_lid_mgr_range_t));
+ if (p_range) {
+ p_range->min_lid = lid;
+ p_range->max_lid = lid;
+ }
+ }
+ /* this lid is used so we need to finalize the previous free range */
+ } else if (p_range) {
+ cl_qlist_insert_tail(&p_mgr->free_ranges,
+ &p_range->item);
+ OSM_LOG(p_mgr->p_log, OSM_LOG_DEBUG,
+ "new free lid range [%u:%u]\n",
+ p_range->min_lid, p_range->max_lid);
+ p_range = NULL;
+ }
+ }
+
+AfterScanningLids:
+ /* after scanning all known lids we need to extend the last range
+ to the max allowed lid */
+ if (!p_range) {
+ p_range = malloc(sizeof(osm_lid_mgr_range_t));
+ /*
+ The p_range can be NULL in one of 2 cases:
+ 1. If max_defined_lid == 0. In this case, we want the
+ entire range.
+ 2. If all lids discovered in the loop where mapped. In this
+ case, no free range exists and we want to define it after the
+ last mapped lid.
+ */
+ if (p_range)
+ p_range->min_lid = lid;
+ }
+ if (p_range) {
+ p_range->max_lid = p_mgr->p_subn->max_ucast_lid_ho;
+ cl_qlist_insert_tail(&p_mgr->free_ranges, &p_range->item);
+ OSM_LOG(p_mgr->p_log, OSM_LOG_DEBUG,
+ "final free lid range [%u:%u]\n",
+ p_range->min_lid, p_range->max_lid);
+ }
+
+ OSM_LOG_EXIT(p_mgr->p_log);
+ return status;
+}
+
+/**********************************************************************
+ check if the given range of lids is free
+**********************************************************************/
+static boolean_t lid_mgr_is_range_not_persistent(IN osm_lid_mgr_t * p_mgr,
+ IN uint16_t lid,
+ IN uint16_t num_lids)
+{
+ uint16_t i;
+
+ for (i = lid; i < lid + num_lids; i++)
+ if (p_mgr->used_lids[i])
+ return FALSE;
+
+ return TRUE;
+}
+
+/**********************************************************************
+find a free lid range
+**********************************************************************/
+static void lid_mgr_find_free_lid_range(IN osm_lid_mgr_t * p_mgr,
+ IN uint8_t num_lids,
+ OUT uint16_t * p_min_lid,
+ OUT uint16_t * p_max_lid)
+{
+ uint16_t lid;
+ cl_list_item_t *p_item;
+ cl_list_item_t *p_next_item;
+ osm_lid_mgr_range_t *p_range = NULL;
+ uint8_t lmc_num_lids;
+ uint16_t lmc_mask;
+
+ OSM_LOG(p_mgr->p_log, OSM_LOG_DEBUG, "LMC = %u, number LIDs = %u\n",
+ p_mgr->p_subn->opt.lmc, num_lids);
+
+ lmc_num_lids = (1 << p_mgr->p_subn->opt.lmc);
+ lmc_mask = ~((1 << p_mgr->p_subn->opt.lmc) - 1);
+
+ /*
+ Search the list of free lid ranges for a range which is big enough
+ */
+ p_item = cl_qlist_head(&p_mgr->free_ranges);
+ while (p_item != cl_qlist_end(&p_mgr->free_ranges)) {
+ p_next_item = cl_qlist_next(p_item);
+ p_range = (osm_lid_mgr_range_t *) p_item;
+
+ lid = p_range->min_lid;
+
+ /* if we require more then one lid we must align to LMC */
+ if (num_lids > 1) {
+ if ((lid & lmc_mask) != lid)
+ lid = (lid + lmc_num_lids) & lmc_mask;
+ }
+
+ /* but we can be out of the range */
+ if (lid + num_lids - 1 <= p_range->max_lid) {
+ /* ok let us use that range */
+ if (lid + num_lids - 1 == p_range->max_lid) {
+ /* we consumed the entire range */
+ cl_qlist_remove_item(&p_mgr->free_ranges,
+ p_item);
+ free(p_item);
+ } else
+ /* only update the available range */
+ p_range->min_lid = lid + num_lids;
+
+ *p_min_lid = lid;
+ *p_max_lid = (uint16_t) (lid + num_lids - 1);
+ return;
+ }
+ p_item = p_next_item;
+ }
+
+ /*
+ Couldn't find a free range of lids.
+ */
+ *p_min_lid = *p_max_lid = 0;
+ /* if we run out of lids, give an error and abort! */
+ OSM_LOG(p_mgr->p_log, OSM_LOG_ERROR, "ERR 0307: "
+ "OPENSM RAN OUT OF LIDS!!!\n");
+ CL_ASSERT(0);
+}
+
+static void lid_mgr_cleanup_discovered_port_lid_range(IN osm_lid_mgr_t * p_mgr,
+ IN osm_port_t * p_port)
+{
+ cl_ptr_vector_t *p_discovered_vec = &p_mgr->p_subn->port_lid_tbl;
+ uint16_t lid, min_lid, max_lid;
+ uint16_t max_tbl_lid =
+ (uint16_t) (cl_ptr_vector_get_size(p_discovered_vec));
+
+ osm_port_get_lid_range_ho(p_port, &min_lid, &max_lid);
+ min_lid = trim_lid(min_lid);
+ max_lid = trim_lid(max_lid);
+ for (lid = min_lid; lid <= max_lid; lid++)
+ if (lid < max_tbl_lid &&
+ p_port == cl_ptr_vector_get(p_discovered_vec, lid))
+ cl_ptr_vector_set(p_discovered_vec, lid, NULL);
+}
+
+/**********************************************************************
+ 0.1 if the port info lid matches the guid2lid return 0
+ 0.2 if the port info has a lid and that range is empty in
+ port_lid_tbl, return 0 and update the port_lid_tbl and
+ guid2lid
+ 0.3 else find an empty space in port_lid_tbl, update the
+ port_lid_tbl and guid2lid, return 1 to flag a change required.
+**********************************************************************/
+static int lid_mgr_get_port_lid(IN osm_lid_mgr_t * p_mgr,
+ IN osm_port_t * p_port,
+ OUT uint16_t * p_min_lid,
+ OUT uint16_t * p_max_lid)
+{
+ uint16_t lid, min_lid, max_lid;
+ uint64_t guid;
+ uint8_t num_lids = (1 << p_mgr->p_subn->opt.lmc);
+ int lid_changed = 0;
+ uint16_t lmc_mask;
+
+ OSM_LOG_ENTER(p_mgr->p_log);
+
+ /* get the lid from the guid2lid */
+ guid = cl_ntoh64(osm_port_get_guid(p_port));
+
+ /* if the port is a base switch port 0 then we only need one lid */
+ if (p_port->p_node->sw &&
+ !osm_switch_sp0_is_lmc_capable(p_port->p_node->sw, p_mgr->p_subn))
+ num_lids = 1;
+
+ if (p_mgr->p_subn->first_time_master_sweep == TRUE &&
+ p_mgr->p_subn->opt.reassign_lids == TRUE)
+ goto AssignLid;
+
+ lmc_mask = ~(num_lids - 1);
+
+ /* if the port matches the guid2lid */
+ if (!osm_db_guid2lid_get(p_mgr->p_g2l, guid, &min_lid, &max_lid)) {
+ *p_min_lid = min_lid;
+ *p_max_lid = min_lid + num_lids - 1;
+ if (min_lid == cl_ntoh16(osm_port_get_base_lid(p_port)))
+ OSM_LOG(p_mgr->p_log, OSM_LOG_DEBUG, "0x%016" PRIx64
+ " matches its known lid:%u\n", guid, min_lid);
+ else {
+ OSM_LOG(p_mgr->p_log, OSM_LOG_DEBUG,
+ "0x%016" PRIx64 " with lid:%u "
+ "does not match its known lid:%u\n",
+ guid, cl_ntoh16(osm_port_get_base_lid(p_port)),
+ min_lid);
+ lid_mgr_cleanup_discovered_port_lid_range(p_mgr,
+ p_port);
+ /* we still need to send the setting to the target port */
+ lid_changed = 1;
+ }
+ goto NewLidSet;
+ } else
+ OSM_LOG(p_mgr->p_log, OSM_LOG_DEBUG,
+ "0x%016" PRIx64 " has no persistent lid assigned\n",
+ guid);
+
+ /* if the port info carries a lid it must be lmc aligned and not mapped
+ by the persistent storage */
+ min_lid = cl_ntoh16(osm_port_get_base_lid(p_port));
+
+ /* we want to ignore the discovered lid if we are also on first sweep of
+ reassign lids flow */
+ if (min_lid) {
+ /* make sure lid is valid */
+ if ((min_lid & lmc_mask) == min_lid) {
+ /* is it free */
+ if (lid_mgr_is_range_not_persistent
+ (p_mgr, min_lid, num_lids)) {
+ *p_min_lid = min_lid;
+ *p_max_lid = min_lid + num_lids - 1;
+ OSM_LOG(p_mgr->p_log, OSM_LOG_DEBUG,
+ "0x%016" PRIx64
+ " lid range:[%u-%u] is free\n",
+ guid, *p_min_lid, *p_max_lid);
+ goto NewLidSet;
+ } else
+ OSM_LOG(p_mgr->p_log, OSM_LOG_DEBUG,
+ "0x%016" PRIx64 " existing lid "
+ "range:[%u:%u] is not free\n",
+ guid, min_lid, min_lid + num_lids - 1);
+ } else
+ OSM_LOG(p_mgr->p_log, OSM_LOG_DEBUG,
+ "0x%016" PRIx64 " existing lid range:"
+ "[%u:%u] is not lmc aligned\n",
+ guid, min_lid, min_lid + num_lids - 1);
+ }
+
+AssignLid:
+ /* first cleanup the existing discovered lid range */
+ lid_mgr_cleanup_discovered_port_lid_range(p_mgr, p_port);
+
+ /* find an empty space */
+ lid_mgr_find_free_lid_range(p_mgr, num_lids, p_min_lid, p_max_lid);
+ OSM_LOG(p_mgr->p_log, OSM_LOG_DEBUG,
+ "0x%016" PRIx64 " assigned a new lid range:[%u-%u]\n",
+ guid, *p_min_lid, *p_max_lid);
+ lid_changed = 1;
+
+NewLidSet:
+ /* update the guid2lid db and used_lids */
+ osm_db_guid2lid_set(p_mgr->p_g2l, guid, *p_min_lid, *p_max_lid);
+ for (lid = *p_min_lid; lid <= *p_max_lid; lid++)
+ p_mgr->used_lids[lid] = 1;
+
+ /* make sure the assigned lids are marked in port_lid_tbl */
+ for (lid = *p_min_lid; lid <= *p_max_lid; lid++)
+ cl_ptr_vector_set(&p_mgr->p_subn->port_lid_tbl, lid, p_port);
+
+ OSM_LOG_EXIT(p_mgr->p_log);
+ return lid_changed;
+}
+
+/**********************************************************************
+ Set to INIT the remote port of the given physical port
+ **********************************************************************/
+static void lid_mgr_set_remote_pi_state_to_init(IN osm_lid_mgr_t * p_mgr,
+ IN osm_physp_t * p_physp)
+{
+ osm_physp_t *p_rem_physp = osm_physp_get_remote(p_physp);
+
+ if (p_rem_physp == NULL)
+ return;
+
+ /* but in some rare cases the remote side might be non responsive */
+ ib_port_info_set_port_state(&p_rem_physp->port_info, IB_LINK_INIT);
+}
+
+static int lid_mgr_set_physp_pi(IN osm_lid_mgr_t * p_mgr,
+ IN osm_port_t * p_port,
+ IN osm_physp_t * p_physp, IN ib_net16_t lid)
+{
+ uint8_t payload[IB_SMP_DATA_SIZE];
+ ib_port_info_t *p_pi = (ib_port_info_t *) payload;
+ const ib_port_info_t *p_old_pi;
+ osm_madw_context_t context;
+ osm_node_t *p_node;
+ ib_api_status_t status;
+ uint8_t mtu;
+ uint8_t op_vls;
+ uint8_t port_num;
+ boolean_t send_set = FALSE;
+ boolean_t send_client_rereg = FALSE;
+ boolean_t update_mkey = FALSE;
+ int ret = 0;
+
+ OSM_LOG_ENTER(p_mgr->p_log);
+
+ /*
+ Don't bother doing anything if this Physical Port is not valid.
+ This allows simplified code in the caller.
+ */
+ if (!p_physp)
+ goto Exit;
+
+ port_num = osm_physp_get_port_num(p_physp);
+ p_node = osm_physp_get_node_ptr(p_physp);
+
+ if (osm_node_get_type(p_node) == IB_NODE_TYPE_SWITCH && port_num != 0) {
+ /*
+ Switch ports that are not numbered 0 should not be set
+ with the following attributes as they are set later
+ (during NO_CHANGE state in link mgr).
+ */
+ OSM_LOG(p_mgr->p_log, OSM_LOG_DEBUG,
+ "Skipping switch port %u, GUID 0x%016" PRIx64 "\n",
+ port_num, cl_ntoh64(osm_physp_get_port_guid(p_physp)));
+ goto Exit;
+ }
+
+ p_old_pi = &p_physp->port_info;
+
+ /*
+ First, copy existing parameters from the PortInfo attribute we
+ already have for this node.
+
+ Second, update with default values that we know must be set for
+ every Physical Port and the LID and set the neighbor MTU field
+ appropriately.
+
+ Third, send the SMP to this physical port.
+ */
+
+ memcpy(payload, p_old_pi, sizeof(ib_port_info_t));
+
+ /*
+ Should never write back a value that is bigger then 3 in
+ the PortPhysicalState field, so cannot simply copy!
+
+ Actually we want to write there:
+ port physical state - no change
+ link down default state = polling
+ port state - no change
+ */
+ p_pi->state_info2 = 0x02;
+ ib_port_info_set_port_state(p_pi, IB_LINK_NO_CHANGE);
+
+ if (ib_port_info_get_link_down_def_state(p_pi) !=
+ ib_port_info_get_link_down_def_state(p_old_pi))
+ send_set = TRUE;
+
+ /* didn't get PortInfo before */
+ if (!ib_port_info_get_port_state(p_old_pi))
+ send_set = TRUE;
+
+ p_pi->m_key = p_mgr->p_subn->opt.m_key;
+ if (memcmp(&p_pi->m_key, &p_old_pi->m_key, sizeof(p_pi->m_key))) {
+ update_mkey = TRUE;
+ send_set = TRUE;
+ }
+
+ p_pi->subnet_prefix = p_mgr->p_subn->opt.subnet_prefix;
+ if (memcmp(&p_pi->subnet_prefix, &p_old_pi->subnet_prefix,
+ sizeof(p_pi->subnet_prefix)))
+ send_set = TRUE;
+
+ p_port->lid = lid;
+ p_pi->base_lid = lid;
+ if (memcmp(&p_pi->base_lid, &p_old_pi->base_lid,
+ sizeof(p_pi->base_lid))) {
+ /*
+ * Reset stored base_lid.
+ * On successful send, we'll update it when we'll get a reply.
+ */
+ osm_physp_set_base_lid(p_physp, 0);
+ send_set = TRUE;
+ p_mgr->dirty = TRUE;
+ }
+
+ /*
+ We are updating the ports with our local sm_base_lid
+ if for some reason currently received SM LID is different from our SM LID,
+ need to send client reregister to this port
+ */
+ p_pi->master_sm_base_lid = p_mgr->p_subn->sm_base_lid;
+ if (memcmp(&p_pi->master_sm_base_lid, &p_old_pi->master_sm_base_lid,
+ sizeof(p_pi->master_sm_base_lid))) {
+ send_client_rereg = TRUE;
+ send_set = TRUE;
+ }
+
+ p_pi->m_key_lease_period = p_mgr->p_subn->opt.m_key_lease_period;
+ if (memcmp(&p_pi->m_key_lease_period, &p_old_pi->m_key_lease_period,
+ sizeof(p_pi->m_key_lease_period)))
+ send_set = TRUE;
+
+ p_pi->mkey_lmc = 0;
+ ib_port_info_set_mpb(p_pi, p_mgr->p_subn->opt.m_key_protect_bits);
+ if (ib_port_info_get_mpb(p_pi) != ib_port_info_get_mpb(p_old_pi))
+ send_set = TRUE;
+
+ /*
+ we want to set the timeout for both the switch port 0
+ and the CA ports
+ */
+ ib_port_info_set_timeout(p_pi, p_mgr->p_subn->opt.subnet_timeout);
+ if (ib_port_info_get_timeout(p_pi) !=
+ ib_port_info_get_timeout(p_old_pi))
+ send_set = TRUE;
+
+ if (port_num != 0) {
+ /*
+ CAs don't have a port 0, and for switch port 0,
+ the state bits are ignored.
+ This is not the switch management port
+ */
+ p_pi->link_width_enabled = p_old_pi->link_width_supported;
+ if (p_pi->link_width_enabled != p_old_pi->link_width_enabled)
+ send_set = TRUE;
+
+ /* p_pi->mkey_lmc is initialized earlier */
+ ib_port_info_set_lmc(p_pi, p_mgr->p_subn->opt.lmc);
+ if (ib_port_info_get_lmc(p_pi) !=
+ ib_port_info_get_lmc(p_old_pi))
+ send_set = TRUE;
+
+ /* calc new op_vls and mtu */
+ op_vls = osm_physp_calc_link_op_vls(p_mgr->p_log, p_mgr->p_subn,
+ p_physp,
+ ib_port_info_get_op_vls(p_old_pi));
+ mtu = osm_physp_calc_link_mtu(p_mgr->p_log, p_physp,
+ ib_port_info_get_neighbor_mtu(p_old_pi));
+
+ ib_port_info_set_neighbor_mtu(p_pi, mtu);
+
+ if (ib_port_info_get_neighbor_mtu(p_pi) !=
+ ib_port_info_get_neighbor_mtu(p_old_pi))
+ send_set = TRUE;
+
+ ib_port_info_set_op_vls(p_pi, op_vls);
+ if (ib_port_info_get_op_vls(p_pi) !=
+ ib_port_info_get_op_vls(p_old_pi))
+ send_set = TRUE;
+
+ /*
+ Several timeout mechanisms:
+ */
+ ib_port_info_set_phy_and_overrun_err_thd(p_pi,
+ p_mgr->p_subn->opt.
+ local_phy_errors_threshold,
+ p_mgr->p_subn->opt.
+ overrun_errors_threshold);
+
+ if (p_pi->error_threshold != p_old_pi->error_threshold)
+ send_set = TRUE;
+
+ /*
+ To reset the port state machine we can send
+ PortInfo.State = DOWN. (see: 7.2.7 p171 lines:10-19)
+ */
+ if (mtu != ib_port_info_get_neighbor_mtu(p_old_pi) ||
+ op_vls != ib_port_info_get_op_vls(p_old_pi)) {
+ OSM_LOG(p_mgr->p_log, OSM_LOG_DEBUG,
+ "Sending Link Down to GUID 0x%016"
+ PRIx64 " port %d due to op_vls or "
+ "mtu change. MTU:%u,%u VL_CAP:%u,%u\n",
+ cl_ntoh64(osm_physp_get_port_guid(p_physp)),
+ port_num, mtu,
+ ib_port_info_get_neighbor_mtu(p_old_pi),
+ op_vls, ib_port_info_get_op_vls(p_old_pi));
+
+ /*
+ we need to make sure the internal DB will follow the
+ fact that the remote port is also going through
+ "down" state into "init"...
+ */
+ lid_mgr_set_remote_pi_state_to_init(p_mgr, p_physp);
+
+ ib_port_info_set_port_state(p_pi, IB_LINK_DOWN);
+ if (ib_port_info_get_port_state(p_pi) !=
+ ib_port_info_get_port_state(p_old_pi))
+ send_set = TRUE;
+ }
+ } else if (ib_switch_info_is_enhanced_port0(&p_node->sw->switch_info)) {
+ /*
+ * Configure Enh. SP0:
+ * Set MTU according to the mtu_cap.
+ * Set LMC if lmc_esp0 is defined.
+ */
+ ib_port_info_set_neighbor_mtu(p_pi,
+ ib_port_info_get_mtu_cap
+ (p_old_pi));
+ if (ib_port_info_get_neighbor_mtu(p_pi) !=
+ ib_port_info_get_neighbor_mtu(p_old_pi))
+ send_set = TRUE;
+
+ OSM_LOG(p_mgr->p_log, OSM_LOG_DEBUG,
+ "Updating neighbor_mtu on switch GUID 0x%016" PRIx64
+ " port 0 to:%u\n",
+ cl_ntoh64(osm_physp_get_port_guid(p_physp)),
+ ib_port_info_get_neighbor_mtu(p_pi));
+
+ /* Configure LMC on enhanced SP0 */
+ if (p_mgr->p_subn->opt.lmc_esp0) {
+ /* p_pi->mkey_lmc is initialized earlier */
+ ib_port_info_set_lmc(p_pi, p_mgr->p_subn->opt.lmc);
+ if (ib_port_info_get_lmc(p_pi) !=
+ ib_port_info_get_lmc(p_old_pi))
+ send_set = TRUE;
+ }
+ }
+
+ context.pi_context.node_guid = osm_node_get_node_guid(p_node);
+ context.pi_context.port_guid = osm_physp_get_port_guid(p_physp);
+ context.pi_context.set_method = TRUE;
+ context.pi_context.light_sweep = FALSE;
+ context.pi_context.active_transition = FALSE;
+
+ /*
+ For ports supporting the ClientReregistration Vol1 (v1.2) p811 14.4.11:
+ need to set the cli_rereg bit when current SM LID at the Host
+ is different from our SM LID,
+ also if we are in first_time_master_sweep,
+ also if this port was just now discovered, then we should also set
+ the cli_rereg bit (we know that the port was just discovered
+ if its is_new field is set).
+ */
+ if ((send_client_rereg ||
+ p_mgr->p_subn->first_time_master_sweep == TRUE || p_port->is_new)
+ && !p_mgr->p_subn->opt.no_clients_rereg
+ && (p_old_pi->capability_mask & IB_PORT_CAP_HAS_CLIENT_REREG)) {
+ OSM_LOG(p_mgr->p_log, OSM_LOG_DEBUG,
+ "Setting client rereg on %s, port %d\n",
+ p_port->p_node->print_desc, p_port->p_physp->port_num);
+ ib_port_info_set_client_rereg(p_pi, 1);
+ context.pi_context.client_rereg = TRUE;
+ send_set = TRUE;
+ } else {
+ ib_port_info_set_client_rereg(p_pi, 0);
+ context.pi_context.client_rereg = FALSE;
+ }
+
+ /* We need to send the PortInfo Set request with the new sm_lid
+ in the following cases:
+ 1. There is a change in the values (send_set == TRUE)
+ 2. first_time_master_sweep flag on the subnet is TRUE. This means the
+ SM just became master, and it then needs to send a PortInfo Set to
+ every port.
+ */
+ if (p_mgr->p_subn->first_time_master_sweep == TRUE)
+ send_set = TRUE;
+
+ if (!send_set)
+ goto Exit;
+
+ status = osm_req_set(p_mgr->sm, osm_physp_get_dr_path_ptr(p_physp),
+ payload, sizeof(payload), IB_MAD_ATTR_PORT_INFO,
+ cl_hton32(osm_physp_get_port_num(p_physp)),
+ FALSE, ib_port_info_get_m_key(&p_physp->port_info),
+ CL_DISP_MSGID_NONE, &context);
+ if (status != IB_SUCCESS)
+ ret = -1;
+ /* If we sent a new mkey above, update our guid2mkey map
+ now, on the assumption that the SubnSet succeeds
+ */
+ if (update_mkey)
+ osm_db_guid2mkey_set(p_mgr->p_subn->p_g2m,
+ cl_ntoh64(p_physp->port_guid),
+ cl_ntoh64(p_pi->m_key));
+
+Exit:
+ OSM_LOG_EXIT(p_mgr->p_log);
+ return ret;
+}
+
+/**********************************************************************
+ Processes our own node
+ Lock must already be held.
+**********************************************************************/
+static int lid_mgr_process_our_sm_node(IN osm_lid_mgr_t * p_mgr)
+{
+ osm_port_t *p_port;
+ uint16_t min_lid_ho;
+ uint16_t max_lid_ho;
+ int ret;
+
+ OSM_LOG_ENTER(p_mgr->p_log);
+
+ /*
+ Acquire our own port object.
+ */
+ p_port = osm_get_port_by_guid(p_mgr->p_subn,
+ p_mgr->p_subn->sm_port_guid);
+ if (!p_port) {
+ OSM_LOG(p_mgr->p_log, OSM_LOG_ERROR, "ERR 0308: "
+ "Can't acquire SM's port object, GUID 0x%016" PRIx64
+ "\n", cl_ntoh64(p_mgr->p_subn->sm_port_guid));
+ ret = -1;
+ goto Exit;
+ }
+
+ /*
+ Determine the LID this SM will use for its own port.
+ Be careful. With an LMC > 0, the bottom of the LID range becomes
+ unusable, since port hardware will mask off least significant bits,
+ leaving a LID of 0 (invalid). Therefore, make sure that we always
+ configure the SM with a LID that has non-zero bits, even after
+ LMC masking by hardware.
+ */
+ lid_mgr_get_port_lid(p_mgr, p_port, &min_lid_ho, &max_lid_ho);
+ OSM_LOG(p_mgr->p_log, OSM_LOG_DEBUG,
+ "Current base LID is %u\n", min_lid_ho);
+ /*
+ Update subnet object.
+ */
+ p_mgr->p_subn->master_sm_base_lid = cl_hton16(min_lid_ho);
+ p_mgr->p_subn->sm_base_lid = cl_hton16(min_lid_ho);
+
+ OSM_LOG(p_mgr->p_log, OSM_LOG_VERBOSE,
+ "Assigning SM's port 0x%016" PRIx64
+ "\n\t\t\t\tto LID range [%u,%u]\n",
+ cl_ntoh64(osm_port_get_guid(p_port)), min_lid_ho, max_lid_ho);
+
+ /*
+ Set the PortInfo the Physical Port associated with this Port.
+ */
+ ret = lid_mgr_set_physp_pi(p_mgr, p_port, p_port->p_physp,
+ cl_hton16(min_lid_ho));
+
+Exit:
+ OSM_LOG_EXIT(p_mgr->p_log);
+ return ret;
+}
+
+int osm_lid_mgr_process_sm(IN osm_lid_mgr_t * p_mgr)
+{
+ int ret;
+
+ OSM_LOG_ENTER(p_mgr->p_log);
+
+ CL_ASSERT(p_mgr->p_subn->sm_port_guid);
+
+ CL_PLOCK_EXCL_ACQUIRE(p_mgr->p_lock);
+
+ /* initialize the port_lid_tbl and empty ranges list following the
+ persistent db */
+ lid_mgr_init_sweep(p_mgr);
+
+ ret = lid_mgr_process_our_sm_node(p_mgr);
+
+ CL_PLOCK_RELEASE(p_mgr->p_lock);
+
+ OSM_LOG_EXIT(p_mgr->p_log);
+ return ret;
+}
+
+/**********************************************************************
+ 1 go through all ports in the subnet.
+ 1.1 call lid_mgr_get_port_lid
+ 1.2 if a change is required send the port info
+ 2 if any change send the signal PENDING...
+**********************************************************************/
+int osm_lid_mgr_process_subnet(IN osm_lid_mgr_t * p_mgr)
+{
+ cl_qmap_t *p_port_guid_tbl;
+ osm_port_t *p_port;
+ ib_net64_t port_guid;
+ int lid_changed, ret = 0;
+ uint16_t min_lid_ho, max_lid_ho;
+
+ CL_ASSERT(p_mgr);
+
+ OSM_LOG_ENTER(p_mgr->p_log);
+
+ CL_PLOCK_EXCL_ACQUIRE(p_mgr->p_lock);
+
+ CL_ASSERT(p_mgr->p_subn->sm_port_guid);
+
+ p_port_guid_tbl = &p_mgr->p_subn->port_guid_tbl;
+
+ for (p_port = (osm_port_t *) cl_qmap_head(p_port_guid_tbl);
+ p_port != (osm_port_t *) cl_qmap_end(p_port_guid_tbl);
+ p_port = (osm_port_t *) cl_qmap_next(&p_port->map_item)) {
+ port_guid = osm_port_get_guid(p_port);
+
+ /*
+ Our own port is a special case in that we want to
+ assign a LID to ourselves first, since we have to
+ advertise that LID value to the other ports.
+
+ For that reason, our node is treated separately and
+ we will not add it to any of these lists.
+ */
+ if (port_guid == p_mgr->p_subn->sm_port_guid) {
+ OSM_LOG(p_mgr->p_log, OSM_LOG_DEBUG,
+ "Skipping our own port 0x%016" PRIx64 "\n",
+ cl_ntoh64(port_guid));
+ continue;
+ }
+
+ /*
+ get the port lid range - we need to send it on first active
+ sweep or if there was a change (the result of
+ lid_mgr_get_port_lid)
+ */
+ lid_changed = lid_mgr_get_port_lid(p_mgr, p_port,
+ &min_lid_ho, &max_lid_ho);
+
+ /* we can call the function to update the port info as it known
+ to look for any field change and will only send an updated
+ if required */
+ OSM_LOG(p_mgr->p_log, OSM_LOG_VERBOSE,
+ "Assigned port 0x%016" PRIx64 ", %s LID [%u,%u]\n",
+ cl_ntoh64(port_guid), lid_changed ? "new" : "",
+ min_lid_ho, max_lid_ho);
+
+ /* the proc returns the fact it sent a set port info */
+ if (lid_mgr_set_physp_pi(p_mgr, p_port, p_port->p_physp,
+ cl_hton16(min_lid_ho)))
+ ret = -1;
+ } /* all ports */
+
+ /* store the guid to lid table in persistent db */
+ osm_db_store(p_mgr->p_g2l, p_mgr->p_subn->opt.fsync_high_avail_files);
+
+ CL_PLOCK_RELEASE(p_mgr->p_lock);
+
+ OSM_LOG_EXIT(p_mgr->p_log);
+ return ret;
+}
diff --git a/contrib/ofed/opensm/opensm/osm_lin_fwd_rcv.c b/contrib/ofed/opensm/opensm/osm_lin_fwd_rcv.c
new file mode 100644
index 0000000..b798ce5
--- /dev/null
+++ b/contrib/ofed/opensm/opensm/osm_lin_fwd_rcv.c
@@ -0,0 +1,125 @@
+/*
+ * Copyright (c) 2004-2009 Voltaire, Inc. All rights reserved.
+ * Copyright (c) 2002-2005,2008 Mellanox Technologies LTD. All rights reserved.
+ * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
+ * Copyright (c) 2009 Sun Microsystems, Inc. All rights reserved.
+ * Copyright (c) 2013 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+/*
+ * Abstract:
+ * Implementation of osm_lft_rcv_t.
+ * This object represents the Linear Forwarding Table Receiver object.
+ * This object is part of the opensm family of objects.
+ */
+
+#if HAVE_CONFIG_H
+# include <config.h>
+#endif /* HAVE_CONFIG_H */
+
+#include <string.h>
+#include <complib/cl_debug.h>
+#include <opensm/osm_file_ids.h>
+#define FILE_ID OSM_FILE_LIN_FWD_RCV_C
+#include <opensm/osm_switch.h>
+#include <opensm/osm_sm.h>
+#include <opensm/osm_event_plugin.h>
+#include <opensm/osm_opensm.h>
+
+void osm_lft_rcv_process(IN void *context, IN void *data)
+{
+ osm_sm_t *sm = context;
+ osm_madw_t *p_madw = data;
+ ib_smp_t *p_smp;
+ uint32_t block_num;
+ osm_switch_t *p_sw;
+ osm_lft_context_t *p_lft_context;
+ uint8_t *p_block;
+ ib_net64_t node_guid;
+ osm_epi_lft_change_event_t lft_change;
+ ib_api_status_t status;
+
+ CL_ASSERT(sm);
+
+ OSM_LOG_ENTER(sm->p_log);
+
+ CL_ASSERT(p_madw);
+
+ p_smp = osm_madw_get_smp_ptr(p_madw);
+ p_block = ib_smp_get_payload_ptr(p_smp);
+ block_num = cl_ntoh32(p_smp->attr_mod);
+
+ /*
+ Acquire the switch object for this switch.
+ */
+ p_lft_context = osm_madw_get_lft_context_ptr(p_madw);
+ node_guid = p_lft_context->node_guid;
+
+ if (ib_smp_get_status(p_smp)) {
+ OSM_LOG(sm->p_log, OSM_LOG_DEBUG,
+ "MAD status 0x%x received\n",
+ cl_ntoh16(ib_smp_get_status(p_smp)));
+ goto Exit;
+ }
+
+ CL_PLOCK_EXCL_ACQUIRE(sm->p_lock);
+ p_sw = osm_get_switch_by_guid(sm->p_subn, node_guid);
+
+ if (!p_sw) {
+ OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR 0401: "
+ "LFT received for nonexistent node "
+ "0x%" PRIx64 "\n", cl_ntoh64(node_guid));
+ } else {
+ status = osm_switch_set_lft_block(p_sw, p_block, block_num);
+ if (status == IB_SUCCESS) {
+ if (sm->p_subn->first_time_master_sweep == FALSE) {
+ lft_change.p_sw = p_sw;
+ lft_change.flags = LFT_CHANGED_BLOCK;
+ lft_change.lft_top = 0;
+ lft_change.block_num = block_num;
+ osm_opensm_report_event(sm->p_subn->p_osm,
+ OSM_EVENT_ID_LFT_CHANGE,
+ &lft_change);
+ }
+ } else {
+ OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR 0402: "
+ "Setting forwarding table block %u failed (%s)"
+ ", Switch 0x%" PRIx64 " %s\n", block_num,
+ ib_get_err_str(status), cl_ntoh64(node_guid),
+ p_sw->p_node->print_desc);
+ }
+ }
+
+ CL_PLOCK_RELEASE(sm->p_lock);
+Exit:
+ OSM_LOG_EXIT(sm->p_log);
+}
diff --git a/contrib/ofed/opensm/opensm/osm_link_mgr.c b/contrib/ofed/opensm/opensm/osm_link_mgr.c
new file mode 100644
index 0000000..89e9d22
--- /dev/null
+++ b/contrib/ofed/opensm/opensm/osm_link_mgr.c
@@ -0,0 +1,590 @@
+/*
+ * Copyright (c) 2004-2009 Voltaire, Inc. All rights reserved.
+ * Copyright (c) 2002-2011 Mellanox Technologies LTD. All rights reserved.
+ * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
+ * Copyright (c) 2009 Sun Microsystems, Inc. All rights reserved.
+ * Copyright (c) 2009-2011 ZIH, TU Dresden, Federal Republic of Germany. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+/*
+ * Abstract:
+ * Implementation of osm_link_mgr_t.
+ * This file implements the Link Manager object.
+ */
+
+#if HAVE_CONFIG_H
+# include <config.h>
+#endif /* HAVE_CONFIG_H */
+
+#include <string.h>
+#include <iba/ib_types.h>
+#include <complib/cl_debug.h>
+#include <opensm/osm_file_ids.h>
+#define FILE_ID OSM_FILE_LINK_MGR_C
+#include <opensm/osm_sm.h>
+#include <opensm/osm_node.h>
+#include <opensm/osm_switch.h>
+#include <opensm/osm_helper.h>
+#include <opensm/osm_msgdef.h>
+#include <opensm/osm_opensm.h>
+#include <opensm/osm_db_pack.h>
+
+static uint8_t link_mgr_get_smsl(IN osm_sm_t * sm, IN osm_physp_t * p_physp)
+{
+ osm_opensm_t *p_osm = sm->p_subn->p_osm;
+ struct osm_routing_engine *re = p_osm->routing_engine_used;
+ ib_net16_t slid;
+ ib_net16_t smlid;
+ uint8_t sl;
+
+ OSM_LOG_ENTER(sm->p_log);
+
+ if (!(re && re->path_sl &&
+ (slid = osm_physp_get_base_lid(p_physp)))) {
+ /*
+ * Use default SL if routing engine does not provide a
+ * path SL lookup callback.
+ */
+ OSM_LOG_EXIT(sm->p_log);
+ return sm->p_subn->opt.sm_sl;
+ }
+
+ smlid = sm->p_subn->sm_base_lid;
+
+ /* Call into routing engine to find proper SL */
+ sl = re->path_sl(re->context, sm->p_subn->opt.sm_sl,
+ slid, smlid);
+
+ OSM_LOG_EXIT(sm->p_log);
+ return sl;
+}
+
+static int link_mgr_set_physp_pi(osm_sm_t * sm, IN osm_physp_t * p_physp,
+ IN uint8_t port_state)
+{
+ uint8_t payload[IB_SMP_DATA_SIZE], payload2[IB_SMP_DATA_SIZE];
+ ib_port_info_t *p_pi = (ib_port_info_t *) payload;
+ ib_mlnx_ext_port_info_t *p_epi = (ib_mlnx_ext_port_info_t *) payload2;
+ const ib_port_info_t *p_old_pi;
+ const ib_mlnx_ext_port_info_t *p_old_epi;
+ osm_madw_context_t context;
+ osm_node_t *p_node;
+ ib_api_status_t status;
+ uint8_t port_num, mtu, op_vls, smsl = OSM_DEFAULT_SL;
+ boolean_t esp0 = FALSE, send_set = FALSE, send_set2 = FALSE;
+ osm_physp_t *p_remote_physp, *physp0 = NULL;
+ int issue_ext = 0, fdr10_change = 0;
+ int ret = 0;
+ ib_net32_t attr_mod, cap_mask;
+ boolean_t update_mkey = FALSE;
+ ib_net64_t m_key = 0;
+ osm_port_t *p_port;
+
+ OSM_LOG_ENTER(sm->p_log);
+
+ p_node = osm_physp_get_node_ptr(p_physp);
+
+ p_old_pi = &p_physp->port_info;
+
+ port_num = osm_physp_get_port_num(p_physp);
+
+ memcpy(payload, p_old_pi, sizeof(ib_port_info_t));
+
+ if (osm_node_get_type(p_node) != IB_NODE_TYPE_SWITCH ||
+ port_num == 0) {
+ /* Need to make sure LID and SMLID fields in PortInfo are not 0 */
+ if (!p_pi->base_lid) {
+ p_port = osm_get_port_by_guid(sm->p_subn,
+ osm_physp_get_port_guid(p_physp));
+ p_pi->base_lid = p_port->lid;
+ sm->lid_mgr.dirty = TRUE;
+ send_set = TRUE;
+ }
+
+ /* we are initializing the ports with our local sm_base_lid */
+ p_pi->master_sm_base_lid = sm->p_subn->sm_base_lid;
+ if (p_pi->master_sm_base_lid != p_old_pi->master_sm_base_lid)
+ send_set = TRUE;
+ }
+
+ if (osm_node_get_type(p_node) == IB_NODE_TYPE_SWITCH)
+ physp0 = osm_node_get_physp_ptr(p_node, 0);
+
+ if (port_num == 0) {
+ /*
+ CAs don't have a port 0, and for switch port 0,
+ we need to check if this is enhanced or base port 0.
+ For base port 0 the following parameters are not valid
+ (IBA 1.2.1 p.830 table 146).
+ */
+ if (!p_node->sw) {
+ OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR 4201: "
+ "Cannot find switch by guid: 0x%" PRIx64 "\n",
+ cl_ntoh64(p_node->node_info.node_guid));
+ goto Exit;
+ }
+
+ if (ib_switch_info_is_enhanced_port0(&p_node->sw->switch_info)
+ == FALSE) {
+
+ /* Even for base port 0 we might have to set smsl
+ (if we are using lash routing) */
+ smsl = link_mgr_get_smsl(sm, p_physp);
+ if (smsl != ib_port_info_get_master_smsl(p_old_pi)) {
+ send_set = TRUE;
+ OSM_LOG(sm->p_log, OSM_LOG_DEBUG,
+ "Setting SMSL to %d on port 0 GUID 0x%016"
+ PRIx64 "\n", smsl,
+ cl_ntoh64(osm_physp_get_port_guid
+ (p_physp)));
+ /* Enter if base lid and master_sm_lid didn't change */
+ } else if (send_set == FALSE) {
+ /* This means the switch doesn't support
+ enhanced port 0 and we don't need to
+ change SMSL. Can skip it. */
+ OSM_LOG(sm->p_log, OSM_LOG_DEBUG,
+ "Skipping port 0, GUID 0x%016" PRIx64
+ "\n",
+ cl_ntoh64(osm_physp_get_port_guid
+ (p_physp)));
+ goto Exit;
+ }
+ } else
+ esp0 = TRUE;
+ }
+
+ /*
+ Should never write back a value that is bigger then 3 in
+ the PortPhysicalState field - so can not simply copy!
+
+ Actually we want to write there:
+ port physical state - no change,
+ link down default state = polling
+ port state - as requested.
+ */
+ p_pi->state_info2 = 0x02;
+ ib_port_info_set_port_state(p_pi, port_state);
+
+ /* Determine ports' M_Key */
+ if (osm_node_get_type(p_node) == IB_NODE_TYPE_SWITCH &&
+ osm_physp_get_port_num(p_physp) != 0)
+ m_key = ib_port_info_get_m_key(&physp0->port_info);
+ else
+ m_key = ib_port_info_get_m_key(p_pi);
+
+ /* Check whether this is base port0 smsl handling only */
+ if (port_num == 0 && esp0 == FALSE) {
+ ib_port_info_set_master_smsl(p_pi, smsl);
+ goto Send;
+ }
+
+ /*
+ PAST THIS POINT WE ARE HANDLING EITHER A NON PORT 0 OR ENHANCED PORT 0
+ */
+
+ if (ib_port_info_get_link_down_def_state(p_pi) !=
+ ib_port_info_get_link_down_def_state(p_old_pi))
+ send_set = TRUE;
+
+ /* didn't get PortInfo before */
+ if (!ib_port_info_get_port_state(p_old_pi))
+ send_set = TRUE;
+
+ /* we only change port fields if we do not change state */
+ if (port_state == IB_LINK_NO_CHANGE) {
+ /* The following fields are relevant only for CA port, router, or Enh. SP0 */
+ if (osm_node_get_type(p_node) != IB_NODE_TYPE_SWITCH ||
+ port_num == 0) {
+ p_pi->m_key = sm->p_subn->opt.m_key;
+ if (memcmp(&p_pi->m_key, &p_old_pi->m_key,
+ sizeof(p_pi->m_key))) {
+ update_mkey = TRUE;
+ send_set = TRUE;
+ }
+
+ p_pi->subnet_prefix = sm->p_subn->opt.subnet_prefix;
+ if (memcmp(&p_pi->subnet_prefix,
+ &p_old_pi->subnet_prefix,
+ sizeof(p_pi->subnet_prefix)))
+ send_set = TRUE;
+
+ smsl = link_mgr_get_smsl(sm, p_physp);
+ if (smsl != ib_port_info_get_master_smsl(p_old_pi)) {
+
+ ib_port_info_set_master_smsl(p_pi, smsl);
+
+ OSM_LOG(sm->p_log, OSM_LOG_DEBUG,
+ "Setting SMSL to %d on GUID 0x%016"
+ PRIx64 ", port %d\n", smsl,
+ cl_ntoh64(osm_physp_get_port_guid
+ (p_physp)), port_num);
+
+ send_set = TRUE;
+ }
+
+ p_pi->m_key_lease_period =
+ sm->p_subn->opt.m_key_lease_period;
+ if (memcmp(&p_pi->m_key_lease_period,
+ &p_old_pi->m_key_lease_period,
+ sizeof(p_pi->m_key_lease_period)))
+ send_set = TRUE;
+
+ p_pi->mkey_lmc = 0;
+ ib_port_info_set_mpb(p_pi, sm->p_subn->opt.m_key_protect_bits);
+ if (esp0 == FALSE || sm->p_subn->opt.lmc_esp0)
+ ib_port_info_set_lmc(p_pi, sm->p_subn->opt.lmc);
+ if (ib_port_info_get_lmc(p_old_pi) !=
+ ib_port_info_get_lmc(p_pi) ||
+ ib_port_info_get_mpb(p_old_pi) !=
+ ib_port_info_get_mpb(p_pi))
+ send_set = TRUE;
+
+ ib_port_info_set_timeout(p_pi,
+ sm->p_subn->opt.
+ subnet_timeout);
+ if (ib_port_info_get_timeout(p_pi) !=
+ ib_port_info_get_timeout(p_old_pi))
+ send_set = TRUE;
+ }
+
+ /*
+ Several timeout mechanisms:
+ */
+ p_remote_physp = osm_physp_get_remote(p_physp);
+ if (port_num != 0 && p_remote_physp) {
+ if (osm_node_get_type(osm_physp_get_node_ptr(p_physp))
+ == IB_NODE_TYPE_ROUTER) {
+ ib_port_info_set_hoq_lifetime(p_pi,
+ sm->p_subn->
+ opt.
+ leaf_head_of_queue_lifetime);
+ } else
+ if (osm_node_get_type
+ (osm_physp_get_node_ptr(p_physp)) ==
+ IB_NODE_TYPE_SWITCH) {
+ /* Is remote end CA or router (a leaf port) ? */
+ if (osm_node_get_type
+ (osm_physp_get_node_ptr(p_remote_physp)) !=
+ IB_NODE_TYPE_SWITCH) {
+ ib_port_info_set_hoq_lifetime(p_pi,
+ sm->
+ p_subn->
+ opt.
+ leaf_head_of_queue_lifetime);
+ ib_port_info_set_vl_stall_count(p_pi,
+ sm->
+ p_subn->
+ opt.
+ leaf_vl_stall_count);
+ } else {
+ ib_port_info_set_hoq_lifetime(p_pi,
+ sm->
+ p_subn->
+ opt.
+ head_of_queue_lifetime);
+ ib_port_info_set_vl_stall_count(p_pi,
+ sm->
+ p_subn->
+ opt.
+ vl_stall_count);
+ }
+ }
+ if (ib_port_info_get_hoq_lifetime(p_pi) !=
+ ib_port_info_get_hoq_lifetime(p_old_pi) ||
+ ib_port_info_get_vl_stall_count(p_pi) !=
+ ib_port_info_get_vl_stall_count(p_old_pi))
+ send_set = TRUE;
+ }
+
+ ib_port_info_set_phy_and_overrun_err_thd(p_pi,
+ sm->p_subn->opt.
+ local_phy_errors_threshold,
+ sm->p_subn->opt.
+ overrun_errors_threshold);
+ if (p_pi->error_threshold != p_old_pi->error_threshold)
+ send_set = TRUE;
+
+ /*
+ Set the easy common parameters for all port types,
+ then determine the neighbor MTU.
+ */
+ p_pi->link_width_enabled = p_old_pi->link_width_supported;
+ if (p_pi->link_width_enabled != p_old_pi->link_width_enabled)
+ send_set = TRUE;
+
+ if (sm->p_subn->opt.force_link_speed &&
+ (sm->p_subn->opt.force_link_speed != 15 ||
+ ib_port_info_get_link_speed_enabled(p_pi) !=
+ ib_port_info_get_link_speed_sup(p_pi))) {
+ ib_port_info_set_link_speed_enabled(p_pi,
+ sm->p_subn->opt.
+ force_link_speed);
+ if (p_pi->link_speed != p_old_pi->link_speed)
+ send_set = TRUE;
+ }
+
+ if (sm->p_subn->opt.fdr10 &&
+ p_physp->ext_port_info.link_speed_supported & FDR10) {
+ if (sm->p_subn->opt.fdr10 == 1) { /* enable */
+ if (!(p_physp->ext_port_info.link_speed_enabled & FDR10))
+ fdr10_change = 1;
+ } else { /* disable */
+ if (p_physp->ext_port_info.link_speed_enabled & FDR10)
+ fdr10_change = 1;
+ }
+ if (fdr10_change) {
+ p_old_epi = &p_physp->ext_port_info;
+ memcpy(payload2, p_old_epi,
+ sizeof(ib_mlnx_ext_port_info_t));
+ p_epi->state_change_enable = 0x01;
+ if (sm->p_subn->opt.fdr10 == 1)
+ p_epi->link_speed_enabled = FDR10;
+ else
+ p_epi->link_speed_enabled = 0;
+ send_set2 = TRUE;
+ }
+ }
+
+ if (osm_node_get_type(p_physp->p_node) == IB_NODE_TYPE_SWITCH &&
+ osm_physp_get_port_num(p_physp) != 0) {
+ cap_mask = physp0->port_info.capability_mask;
+ } else
+ cap_mask = p_pi->capability_mask;
+
+ if (cap_mask & IB_PORT_CAP_HAS_EXT_SPEEDS)
+ issue_ext = 1;
+
+ /* Do peer ports support extended link speeds ? */
+ if (port_num != 0 && p_remote_physp) {
+ osm_physp_t *rphysp0;
+ ib_net32_t rem_cap_mask;
+
+ if (osm_node_get_type(p_remote_physp->p_node) ==
+ IB_NODE_TYPE_SWITCH) {
+ rphysp0 = osm_node_get_physp_ptr(p_remote_physp->p_node, 0);
+ rem_cap_mask = rphysp0->port_info.capability_mask;
+ } else
+ rem_cap_mask = p_remote_physp->port_info.capability_mask;
+
+ if (cap_mask & IB_PORT_CAP_HAS_EXT_SPEEDS &&
+ rem_cap_mask & IB_PORT_CAP_HAS_EXT_SPEEDS) {
+ if (sm->p_subn->opt.force_link_speed_ext &&
+ (sm->p_subn->opt.force_link_speed_ext != IB_LINK_SPEED_EXT_SET_LSES ||
+ p_pi->link_speed_ext_enabled !=
+ ib_port_info_get_link_speed_ext_sup(p_pi))) {
+ p_pi->link_speed_ext_enabled = sm->p_subn->opt.force_link_speed_ext;
+ if (p_pi->link_speed_ext_enabled !=
+ p_old_pi->link_speed_ext_enabled)
+ send_set = TRUE;
+ }
+ }
+ }
+
+ /* calc new op_vls and mtu */
+ op_vls =
+ osm_physp_calc_link_op_vls(sm->p_log, sm->p_subn, p_physp,
+ ib_port_info_get_op_vls(p_old_pi));
+ mtu = osm_physp_calc_link_mtu(sm->p_log, p_physp,
+ ib_port_info_get_neighbor_mtu(p_old_pi));
+
+ ib_port_info_set_neighbor_mtu(p_pi, mtu);
+ if (ib_port_info_get_neighbor_mtu(p_pi) !=
+ ib_port_info_get_neighbor_mtu(p_old_pi))
+ send_set = TRUE;
+
+ ib_port_info_set_op_vls(p_pi, op_vls);
+ if (ib_port_info_get_op_vls(p_pi) !=
+ ib_port_info_get_op_vls(p_old_pi))
+ send_set = TRUE;
+
+ /* provide the vl_high_limit from the qos mgr */
+ if (sm->p_subn->opt.qos &&
+ p_physp->vl_high_limit != p_old_pi->vl_high_limit) {
+ send_set = TRUE;
+ p_pi->vl_high_limit = p_physp->vl_high_limit;
+ }
+ }
+
+Send:
+ context.pi_context.active_transition = FALSE;
+ if (port_state != IB_LINK_NO_CHANGE &&
+ port_state != ib_port_info_get_port_state(p_old_pi)) {
+ send_set = TRUE;
+ if (port_state == IB_LINK_ACTIVE)
+ context.pi_context.active_transition = TRUE;
+ }
+
+ context.pi_context.node_guid = osm_node_get_node_guid(p_node);
+ context.pi_context.port_guid = osm_physp_get_port_guid(p_physp);
+ context.pi_context.set_method = TRUE;
+ context.pi_context.light_sweep = FALSE;
+ context.pi_context.client_rereg = FALSE;
+
+ /* We need to send the PortInfoSet request with the new sm_lid
+ in the following cases:
+ 1. There is a change in the values (send_set == TRUE)
+ 2. This is a switch external port (so it wasn't handled yet by
+ osm_lid_mgr) and first_time_master_sweep flag on the subnet is TRUE,
+ which means the SM just became master, and it then needs to send at
+ PortInfoSet to every port.
+ */
+ if (osm_node_get_type(p_node) == IB_NODE_TYPE_SWITCH && port_num
+ && sm->p_subn->first_time_master_sweep == TRUE)
+ send_set = TRUE;
+
+ if (!send_set)
+ goto SEND_EPI;
+
+ attr_mod = cl_hton32(port_num);
+ if (issue_ext)
+ attr_mod |= cl_hton32(1 << 31); /* AM SMSupportExtendedSpeeds */
+ status = osm_req_set(sm, osm_physp_get_dr_path_ptr(p_physp),
+ payload, sizeof(payload), IB_MAD_ATTR_PORT_INFO,
+ attr_mod, FALSE, m_key,
+ CL_DISP_MSGID_NONE, &context);
+ if (status)
+ ret = -1;
+
+ /* If we sent a new mkey above, update our guid2mkey map
+ now, on the assumption that the SubnSet succeeds
+ */
+ if (update_mkey)
+ osm_db_guid2mkey_set(sm->p_subn->p_g2m,
+ cl_ntoh64(p_physp->port_guid),
+ cl_ntoh64(p_pi->m_key));
+
+SEND_EPI:
+ if (send_set2) {
+ status = osm_req_set(sm, osm_physp_get_dr_path_ptr(p_physp),
+ payload2, sizeof(payload2),
+ IB_MAD_ATTR_MLNX_EXTENDED_PORT_INFO,
+ cl_hton32(port_num), FALSE, m_key,
+ CL_DISP_MSGID_NONE, &context);
+ if (status)
+ ret = -1;
+ }
+
+Exit:
+ OSM_LOG_EXIT(sm->p_log);
+ return ret;
+}
+
+static int link_mgr_process_node(osm_sm_t * sm, IN osm_node_t * p_node,
+ IN const uint8_t link_state)
+{
+ osm_physp_t *p_physp, *p_physp_remote;
+ uint32_t i, num_physp;
+ int ret = 0;
+ uint8_t current_state;
+
+ OSM_LOG_ENTER(sm->p_log);
+
+ OSM_LOG(sm->p_log, OSM_LOG_DEBUG,
+ "Node 0x%" PRIx64 " going to %s\n",
+ cl_ntoh64(osm_node_get_node_guid(p_node)),
+ ib_get_port_state_str(link_state));
+
+ /*
+ Set the PortInfo for every Physical Port associated
+ with this Port. Start iterating with port 1, since the linkstate
+ is not applicable to the management port on switches.
+ */
+ num_physp = osm_node_get_num_physp(p_node);
+ for (i = 0; i < num_physp; i++) {
+ /*
+ Don't bother doing anything if this Physical Port is not valid.
+ or if the state of the port is already better then the
+ specified state.
+ */
+ p_physp = osm_node_get_physp_ptr(p_node, (uint8_t) i);
+ if (!p_physp)
+ continue;
+
+ current_state = osm_physp_get_port_state(p_physp);
+ if (current_state == IB_LINK_DOWN)
+ continue;
+
+ /*
+ Set PortState to DOWN in case Remote Physical Port is
+ unreachable. We have to check this for all ports, except
+ port zero.
+ */
+ p_physp_remote = osm_physp_get_remote(p_physp);
+ if ((i != 0) && (!p_physp_remote ||
+ !osm_physp_is_valid(p_physp_remote))) {
+ if (current_state != IB_LINK_INIT)
+ link_mgr_set_physp_pi(sm, p_physp, IB_LINK_DOWN);
+ continue;
+ }
+
+ /*
+ Normally we only send state update if state is lower
+ then required state. However, we need to send update if
+ no state change required.
+ */
+ if (link_state != IB_LINK_NO_CHANGE &&
+ link_state <= current_state)
+ OSM_LOG(sm->p_log, OSM_LOG_DEBUG,
+ "Physical port %u already %s. Skipping\n",
+ p_physp->port_num,
+ ib_get_port_state_str(current_state));
+ else if (link_mgr_set_physp_pi(sm, p_physp, link_state))
+ ret = -1;
+ }
+
+ OSM_LOG_EXIT(sm->p_log);
+ return ret;
+}
+
+int osm_link_mgr_process(osm_sm_t * sm, IN const uint8_t link_state)
+{
+ cl_qmap_t *p_node_guid_tbl;
+ osm_node_t *p_node;
+ int ret = 0;
+
+ OSM_LOG_ENTER(sm->p_log);
+
+ p_node_guid_tbl = &sm->p_subn->node_guid_tbl;
+
+ CL_PLOCK_EXCL_ACQUIRE(sm->p_lock);
+
+ for (p_node = (osm_node_t *) cl_qmap_head(p_node_guid_tbl);
+ p_node != (osm_node_t *) cl_qmap_end(p_node_guid_tbl);
+ p_node = (osm_node_t *) cl_qmap_next(&p_node->map_item))
+ if (link_mgr_process_node(sm, p_node, link_state))
+ ret = -1;
+
+ CL_PLOCK_RELEASE(sm->p_lock);
+
+ OSM_LOG_EXIT(sm->p_log);
+ return ret;
+}
diff --git a/contrib/ofed/opensm/opensm/osm_log.c b/contrib/ofed/opensm/opensm/osm_log.c
new file mode 100644
index 0000000..dc72482
--- /dev/null
+++ b/contrib/ofed/opensm/opensm/osm_log.c
@@ -0,0 +1,518 @@
+/*
+ * Copyright (c) 2004-2009 Voltaire, Inc. All rights reserved.
+ * Copyright (c) 2002-2007 Mellanox Technologies LTD. All rights reserved.
+ * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+/*
+ * Abstract:
+ * Implementation of osm_log_t.
+ * This object represents the log file.
+ * This object is part of the opensm family of objects.
+ */
+
+#if HAVE_CONFIG_H
+# include <config.h>
+#endif /* HAVE_CONFIG_H */
+
+#include <opensm/osm_file_ids.h>
+#define FILE_ID OSM_FILE_LOG_C
+#include <opensm/osm_log.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <stdarg.h>
+#include <fcntl.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <errno.h>
+#include <pthread_np.h>
+
+static int log_exit_count = 0;
+
+#ifndef __WIN__
+#include <sys/time.h>
+#include <unistd.h>
+#include <complib/cl_timer.h>
+
+static const char *month_str[] = {
+ "Jan",
+ "Feb",
+ "Mar",
+ "Apr",
+ "May",
+ "Jun",
+ "Jul",
+ "Aug",
+ "Sep",
+ "Oct",
+ "Nov",
+ "Dec"
+};
+#else
+void OsmReportState(IN const char *p_str);
+#endif /* ndef __WIN__ */
+
+#ifndef __WIN__
+
+static void truncate_log_file(osm_log_t * p_log)
+{
+ int fd = fileno(p_log->out_port);
+ if (ftruncate(fd, 0) < 0)
+ fprintf(stderr, "truncate_log_file: cannot truncate: %s\n",
+ strerror(errno));
+ if (lseek(fd, 0, SEEK_SET) < 0)
+ fprintf(stderr, "truncate_log_file: cannot rewind: %s\n",
+ strerror(errno));
+ p_log->count = 0;
+}
+
+#else /* Windows */
+
+static void truncate_log_file(osm_log_t * p_log)
+{
+ int fd = _fileno(p_log->out_port);
+ HANDLE hFile = (HANDLE) _get_osfhandle(fd);
+
+ if (_lseek(fd, 0, SEEK_SET) < 0)
+ fprintf(stderr, "truncate_log_file: cannot rewind: %s\n",
+ strerror(errno));
+ SetEndOfFile(hFile);
+ p_log->count = 0;
+}
+#endif /* ndef __WIN__ */
+
+void osm_log(IN osm_log_t * p_log, IN osm_log_level_t verbosity,
+ IN const char *p_str, ...)
+{
+ char buffer[LOG_ENTRY_SIZE_MAX];
+ va_list args;
+ int ret;
+#ifdef __WIN__
+ SYSTEMTIME st;
+ uint32_t pid = GetCurrentThreadId();
+#else
+ pid_t pid;
+ time_t tim;
+ struct tm result;
+ uint64_t time_usecs;
+ uint32_t usecs;
+#endif /* __WIN__ */
+
+ /* If this is a call to syslog - always print it */
+ if (!(verbosity & p_log->level))
+ return;
+
+ va_start(args, p_str);
+#ifndef __WIN__
+ if (p_log->log_prefix == NULL)
+ vsprintf(buffer, p_str, args);
+ else {
+ int n = snprintf(buffer, sizeof(buffer), "%s: ", p_log->log_prefix);
+ vsprintf(buffer + n, p_str, args);
+ }
+#else
+ if (p_log->log_prefix == NULL)
+ _vsnprintf(buffer, 1024, (LPSTR)p_str, args);
+ else {
+ int n = snprintf(buffer, sizeof(buffer), "%s: ", p_log->log_prefix);
+ _vsnprintf(buffer + n, (1024 - n), (LPSTR)p_str, args);
+ }
+#endif
+ va_end(args);
+
+ /* this is a call to the syslog */
+ if (verbosity & OSM_LOG_SYS) {
+ syslog(LOG_INFO, "%s\n", buffer);
+
+ /* SYSLOG should go to stdout too */
+ if (p_log->out_port != stdout) {
+ printf("%s\n", buffer);
+ fflush(stdout);
+ }
+#ifdef __WIN__
+ OsmReportState(buffer);
+#endif /* __WIN__ */
+ }
+
+ /* regular log to default out_port */
+ cl_spinlock_acquire(&p_log->lock);
+
+ if (p_log->max_size && p_log->count > p_log->max_size) {
+ /* truncate here */
+ fprintf(stderr,
+ "osm_log: log file exceeds the limit %lu. Truncating.\n",
+ p_log->max_size);
+ truncate_log_file(p_log);
+ }
+#ifdef __WIN__
+ GetLocalTime(&st);
+_retry:
+ ret =
+ fprintf(p_log->out_port,
+ "[%02d:%02d:%02d:%03d][%04X] 0x%02x -> %s",
+ st.wHour, st.wMinute, st.wSecond, st.wMilliseconds,
+ pid, verbosity, buffer);
+#else
+ time_usecs = cl_get_time_stamp();
+ tim = time_usecs / 1000000;
+ usecs = time_usecs % 1000000;
+ localtime_r(&tim, &result);
+ pid = pthread_getthreadid_np();
+_retry:
+ ret =
+ fprintf(p_log->out_port,
+ "%s %02d %02d:%02d:%02d %06d [%04X] 0x%02x -> %s",
+ (result.tm_mon <
+ 12 ? month_str[result.tm_mon] : "???"),
+ result.tm_mday, result.tm_hour, result.tm_min,
+ result.tm_sec, usecs, pid, verbosity, buffer);
+#endif
+
+ /* flush log */
+ if (ret > 0 &&
+ (p_log->flush || (verbosity & (OSM_LOG_ERROR | OSM_LOG_SYS)))
+ && fflush(p_log->out_port) < 0)
+ ret = -1;
+
+ if (ret >= 0) {
+ log_exit_count = 0;
+ p_log->count += ret;
+ } else if (log_exit_count < 3) {
+ log_exit_count++;
+ if (errno == ENOSPC && p_log->max_size) {
+ fprintf(stderr,
+ "osm_log: write failed: %s. Truncating log file.\n",
+ strerror(errno));
+ truncate_log_file(p_log);
+ goto _retry;
+ }
+ fprintf(stderr, "osm_log: write failed: %s\n", strerror(errno));
+ }
+
+ cl_spinlock_release(&p_log->lock);
+}
+
+void osm_log_v2(IN osm_log_t * p_log, IN osm_log_level_t verbosity,
+ IN const int file_id, IN const char *p_str, ...)
+{
+ char buffer[LOG_ENTRY_SIZE_MAX];
+ va_list args;
+ int ret;
+#ifdef __WIN__
+ SYSTEMTIME st;
+ uint32_t pid = GetCurrentThreadId();
+#else
+ struct timeval tv;
+ pid_t pid = 0;
+ time_t tim;
+ struct tm result;
+ uint64_t time_usecs;
+ uint32_t usecs;
+#endif /* __WIN__ */
+
+ /* If this is a call to syslog - always print it */
+ if (!(verbosity & p_log->level)) {
+ if (!(verbosity & p_log->per_mod_log_tbl[file_id]))
+ return;
+ }
+
+ va_start(args, p_str);
+#ifndef __WIN__
+ if (p_log->log_prefix == NULL)
+ vsprintf(buffer, p_str, args);
+ else {
+ int n = snprintf(buffer, sizeof(buffer), "%s: ", p_log->log_prefix);
+ vsprintf(buffer + n, p_str, args);
+ }
+#else
+ if (p_log->log_prefix == NULL)
+ _vsnprintf(buffer, 1024, (LPSTR)p_str, args);
+ else {
+ int n = snprintf(buffer, sizeof(buffer), "%s: ", p_log->log_prefix);
+ _vsnprintf(buffer + n, (1024 - n), (LPSTR)p_str, args);
+ }
+#endif
+ va_end(args);
+
+ /* this is a call to the syslog */
+ if (verbosity & OSM_LOG_SYS) {
+ syslog(LOG_INFO, "%s\n", buffer);
+
+ /* SYSLOG should go to stdout too */
+ if (p_log->out_port != stdout) {
+ printf("%s\n", buffer);
+ fflush(stdout);
+ }
+#ifdef __WIN__
+ OsmReportState(buffer);
+#endif /* __WIN__ */
+ }
+
+ /* regular log to default out_port */
+ cl_spinlock_acquire(&p_log->lock);
+
+ if (p_log->max_size && p_log->count > p_log->max_size) {
+ /* truncate here */
+ fprintf(stderr,
+ "osm_log: log file exceeds the limit %lu. Truncating.\n",
+ p_log->max_size);
+ truncate_log_file(p_log);
+ }
+#ifdef __WIN__
+ GetLocalTime(&st);
+_retry:
+ ret =
+ fprintf(p_log->out_port,
+ "[%02d:%02d:%02d:%03d][%04X] 0x%02x -> %s",
+ st.wHour, st.wMinute, st.wSecond, st.wMilliseconds,
+ pid, verbosity, buffer);
+#else
+ gettimeofday(&tv, NULL);
+ /* Convert the time of day into a microsecond timestamp */
+ time_usecs = ((uint64_t) tv.tv_sec * 1000000) + (uint64_t) tv.tv_usec;
+ tim = time_usecs / 1000000;
+ usecs = time_usecs % 1000000;
+ localtime_r(&tim, &result);
+ pid = pthread_getthreadid_np();
+_retry:
+ ret =
+ fprintf(p_log->out_port,
+ "%s %02d %02d:%02d:%02d %06d [%04X] 0x%02x -> %s",
+ (result.tm_mon <
+ 12 ? month_str[result.tm_mon] : "???"),
+ result.tm_mday, result.tm_hour, result.tm_min,
+ result.tm_sec, usecs, pid, verbosity, buffer);
+#endif
+
+ /* flush log */
+ if (ret > 0 &&
+ (p_log->flush || (verbosity & (OSM_LOG_ERROR | OSM_LOG_SYS)))
+ && fflush(p_log->out_port) < 0)
+ ret = -1;
+
+ if (ret >= 0) {
+ log_exit_count = 0;
+ p_log->count += ret;
+ } else if (log_exit_count < 3) {
+ log_exit_count++;
+ if (errno == ENOSPC && p_log->max_size) {
+ fprintf(stderr,
+ "osm_log: write failed: %s. Truncating log file.\n",
+ strerror(errno));
+ truncate_log_file(p_log);
+ goto _retry;
+ }
+ fprintf(stderr, "osm_log: write failed: %s\n", strerror(errno));
+ }
+
+ cl_spinlock_release(&p_log->lock);
+}
+
+void osm_log_raw(IN osm_log_t * p_log, IN osm_log_level_t verbosity,
+ IN const char *p_buf)
+{
+ if (p_log->level & verbosity) {
+ cl_spinlock_acquire(&p_log->lock);
+ printf("%s", p_buf);
+ cl_spinlock_release(&p_log->lock);
+
+ /*
+ Flush log on errors too.
+ */
+ if (p_log->flush || (verbosity & OSM_LOG_ERROR))
+ fflush(stdout);
+ }
+}
+
+void osm_log_msg_box(IN osm_log_t * log, osm_log_level_t level,
+ const char *func_name, const char *msg)
+{
+#define MSG_BOX_LENGTH 66
+ char buf[MSG_BOX_LENGTH + 1];
+ int i, n;
+
+ if (!osm_log_is_active(log, level))
+ return;
+
+ n = (MSG_BOX_LENGTH - strlen(msg)) / 2 - 1;
+ if (n < 0)
+ n = 0;
+ for (i = 0; i < n; i++)
+ sprintf(buf + i, "*");
+ n += snprintf(buf + n, sizeof(buf) - n, " %s ", msg);
+ for (i = n; i < MSG_BOX_LENGTH; i++)
+ buf[i] = '*';
+ buf[i] = '\0';
+
+ osm_log(log, level, "%s:\n\n\n"
+ "*********************************************"
+ "*********************\n%s\n"
+ "*********************************************"
+ "*********************\n\n\n", func_name, buf);
+}
+
+void osm_log_msg_box_v2(IN osm_log_t * log, osm_log_level_t level,
+ const int file_id, const char *func_name,
+ const char *msg)
+{
+#define MSG_BOX_LENGTH 66
+ char buf[MSG_BOX_LENGTH + 1];
+ int i, n;
+
+ if (!osm_log_is_active_v2(log, level, file_id))
+ return;
+
+ n = (MSG_BOX_LENGTH - strlen(msg)) / 2 - 1;
+ if (n < 0)
+ n = 0;
+ for (i = 0; i < n; i++)
+ sprintf(buf + i, "*");
+ n += snprintf(buf + n, sizeof(buf) - n, " %s ", msg);
+ for (i = n; i < MSG_BOX_LENGTH; i++)
+ buf[i] = '*';
+ buf[i] = '\0';
+
+ osm_log_v2(log, level, file_id, "%s:\n\n\n"
+ "*********************************************"
+ "*********************\n%s\n"
+ "*********************************************"
+ "*********************\n\n\n", func_name, buf);
+}
+
+boolean_t osm_is_debug(void)
+{
+#if defined( _DEBUG_ )
+ return TRUE;
+#else
+ return FALSE;
+#endif /* defined( _DEBUG_ ) */
+}
+
+static int open_out_port(IN osm_log_t * p_log)
+{
+ struct stat st;
+
+ if (p_log->accum_log_file)
+ p_log->out_port = fopen(p_log->log_file_name, "a+");
+ else
+ p_log->out_port = fopen(p_log->log_file_name, "w+");
+
+ if (!p_log->out_port) {
+ syslog(LOG_CRIT, "Cannot open file \'%s\' for %s: %s\n",
+ p_log->log_file_name,
+ p_log->accum_log_file ? "appending" : "writing",
+ strerror(errno));
+ fprintf(stderr, "Cannot open file \'%s\': %s\n",
+ p_log->log_file_name, strerror(errno));
+ return -1;
+ }
+
+ if (fstat(fileno(p_log->out_port), &st) == 0)
+ p_log->count = st.st_size;
+
+ syslog(LOG_NOTICE, "%s log file opened\n", p_log->log_file_name);
+
+ if (p_log->daemon) {
+ dup2(fileno(p_log->out_port), 0);
+ dup2(fileno(p_log->out_port), 1);
+ dup2(fileno(p_log->out_port), 2);
+ }
+
+ return 0;
+}
+
+int osm_log_reopen_file(osm_log_t * p_log)
+{
+ int ret;
+
+ if (p_log->out_port == stdout || p_log->out_port == stderr)
+ return 0;
+ cl_spinlock_acquire(&p_log->lock);
+ fclose(p_log->out_port);
+ ret = open_out_port(p_log);
+ cl_spinlock_release(&p_log->lock);
+ return ret;
+}
+
+ib_api_status_t osm_log_init_v2(IN osm_log_t * p_log, IN boolean_t flush,
+ IN uint8_t log_flags, IN const char *log_file,
+ IN unsigned long max_size,
+ IN boolean_t accum_log_file)
+{
+ p_log->level = log_flags | OSM_LOG_SYS;
+ p_log->flush = flush;
+ p_log->count = 0;
+ p_log->max_size = max_size << 20; /* convert size in MB to bytes */
+ p_log->accum_log_file = accum_log_file;
+ p_log->log_file_name = (char *)log_file;
+ memset(p_log->per_mod_log_tbl, 0, sizeof(p_log->per_mod_log_tbl));
+
+ openlog("OpenSM", LOG_CONS | LOG_PID, LOG_USER);
+
+ if (log_file == NULL || !strcmp(log_file, "-") ||
+ !strcmp(log_file, "stdout"))
+ p_log->out_port = stdout;
+ else if (!strcmp(log_file, "stderr"))
+ p_log->out_port = stderr;
+ else if (open_out_port(p_log))
+ return IB_ERROR;
+
+ if (cl_spinlock_init(&p_log->lock) == CL_SUCCESS)
+ return IB_SUCCESS;
+ else
+ return IB_ERROR;
+}
+
+ib_api_status_t osm_log_init(IN osm_log_t * p_log, IN boolean_t flush,
+ IN uint8_t log_flags, IN const char *log_file,
+ IN boolean_t accum_log_file)
+{
+ return osm_log_init_v2(p_log, flush, log_flags, log_file, 0,
+ accum_log_file);
+}
+
+osm_log_level_t osm_get_log_per_module(IN osm_log_t * p_log,
+ IN const int file_id)
+{
+ return p_log->per_mod_log_tbl[file_id];
+}
+
+void osm_set_log_per_module(IN osm_log_t * p_log, IN const int file_id,
+ IN osm_log_level_t level)
+{
+ p_log->per_mod_log_tbl[file_id] = level;
+}
+
+void osm_reset_log_per_module(IN osm_log_t * p_log)
+{
+ memset(p_log->per_mod_log_tbl, 0, sizeof(p_log->per_mod_log_tbl));
+}
diff --git a/contrib/ofed/opensm/opensm/osm_mad_pool.c b/contrib/ofed/opensm/opensm/osm_mad_pool.c
new file mode 100644
index 0000000..9bd9a4b
--- /dev/null
+++ b/contrib/ofed/opensm/opensm/osm_mad_pool.c
@@ -0,0 +1,175 @@
+/*
+ * Copyright (c) 2004-2009 Voltaire, Inc. All rights reserved.
+ * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved.
+ * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+/*
+ * Abstract:
+ * Implementation of osm_mad_pool_t.
+ * This object represents a pool of management datagram (MAD) objects.
+ * This object is part of the opensm family of objects.
+ */
+
+#if HAVE_CONFIG_H
+# include <config.h>
+#endif /* HAVE_CONFIG_H */
+
+#include <stdlib.h>
+#include <string.h>
+#include <opensm/osm_file_ids.h>
+#define FILE_ID OSM_FILE_MAD_POOL_C
+#include <opensm/osm_mad_pool.h>
+#include <opensm/osm_madw.h>
+#include <vendor/osm_vendor_api.h>
+
+void osm_mad_pool_construct(IN osm_mad_pool_t * p_pool)
+{
+ CL_ASSERT(p_pool);
+
+ memset(p_pool, 0, sizeof(*p_pool));
+}
+
+void osm_mad_pool_destroy(IN osm_mad_pool_t * p_pool)
+{
+ CL_ASSERT(p_pool);
+}
+
+ib_api_status_t osm_mad_pool_init(IN osm_mad_pool_t * p_pool)
+{
+ p_pool->mads_out = 0;
+
+ return IB_SUCCESS;
+}
+
+osm_madw_t *osm_mad_pool_get(IN osm_mad_pool_t * p_pool,
+ IN osm_bind_handle_t h_bind,
+ IN uint32_t total_size,
+ IN const osm_mad_addr_t * p_mad_addr)
+{
+ osm_madw_t *p_madw;
+ ib_mad_t *p_mad;
+
+ CL_ASSERT(h_bind != OSM_BIND_INVALID_HANDLE);
+ CL_ASSERT(total_size);
+
+ /*
+ First, acquire a mad wrapper from the mad wrapper pool.
+ */
+ p_madw = malloc(sizeof(*p_madw));
+ if (p_madw == NULL)
+ goto Exit;
+
+ osm_madw_init(p_madw, h_bind, total_size, p_mad_addr);
+
+ /*
+ Next, acquire a wire mad of the specified size.
+ */
+ p_mad = osm_vendor_get(h_bind, total_size, &p_madw->vend_wrap);
+ if (p_mad == NULL) {
+ /* Don't leak wrappers! */
+ free(p_madw);
+ p_madw = NULL;
+ goto Exit;
+ }
+
+ cl_atomic_inc(&p_pool->mads_out);
+ /*
+ Finally, attach the wire MAD to this wrapper.
+ */
+ osm_madw_set_mad(p_madw, p_mad);
+
+Exit:
+ return p_madw;
+}
+
+osm_madw_t *osm_mad_pool_get_wrapper(IN osm_mad_pool_t * p_pool,
+ IN osm_bind_handle_t h_bind,
+ IN uint32_t total_size,
+ IN const ib_mad_t * p_mad,
+ IN const osm_mad_addr_t * p_mad_addr)
+{
+ osm_madw_t *p_madw;
+
+ CL_ASSERT(h_bind != OSM_BIND_INVALID_HANDLE);
+ CL_ASSERT(total_size);
+ CL_ASSERT(p_mad);
+
+ /*
+ First, acquire a mad wrapper from the mad wrapper pool.
+ */
+ p_madw = malloc(sizeof(*p_madw));
+ if (p_madw == NULL)
+ goto Exit;
+
+ /*
+ Finally, initialize the wrapper object.
+ */
+ cl_atomic_inc(&p_pool->mads_out);
+ osm_madw_init(p_madw, h_bind, total_size, p_mad_addr);
+ osm_madw_set_mad(p_madw, p_mad);
+
+Exit:
+ return p_madw;
+}
+
+osm_madw_t *osm_mad_pool_get_wrapper_raw(IN osm_mad_pool_t * p_pool)
+{
+ osm_madw_t *p_madw;
+
+ p_madw = malloc(sizeof(*p_madw));
+ if (!p_madw)
+ return NULL;
+
+ osm_madw_init(p_madw, 0, 0, 0);
+ osm_madw_set_mad(p_madw, 0);
+ cl_atomic_inc(&p_pool->mads_out);
+
+ return p_madw;
+}
+
+void osm_mad_pool_put(IN osm_mad_pool_t * p_pool, IN osm_madw_t * p_madw)
+{
+ CL_ASSERT(p_madw);
+
+ /*
+ First, return the wire mad to the pool
+ */
+ if (p_madw->p_mad)
+ osm_vendor_put(p_madw->h_bind, &p_madw->vend_wrap);
+
+ /*
+ Return the mad wrapper to the wrapper pool
+ */
+ free(p_madw);
+ cl_atomic_dec(&p_pool->mads_out);
+}
diff --git a/contrib/ofed/opensm/opensm/osm_mcast_fwd_rcv.c b/contrib/ofed/opensm/opensm/osm_mcast_fwd_rcv.c
new file mode 100644
index 0000000..6404f8c
--- /dev/null
+++ b/contrib/ofed/opensm/opensm/osm_mcast_fwd_rcv.c
@@ -0,0 +1,130 @@
+/*
+ * Copyright (c) 2004-2009 Voltaire, Inc. All rights reserved.
+ * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved.
+ * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
+ * Copyright (c) 2009 Sun Microsystems, Inc. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+/*
+ * Abstract:
+ * Implementation of osm_mft_rcv_t.
+ * This object represents the Multicast Forwarding Table Receiver object.
+ * This object is part of the opensm family of objects.
+ */
+
+#if HAVE_CONFIG_H
+# include <config.h>
+#endif /* HAVE_CONFIG_H */
+
+#include <string.h>
+#include <iba/ib_types.h>
+#include <complib/cl_qmap.h>
+#include <complib/cl_passivelock.h>
+#include <complib/cl_debug.h>
+#include <opensm/osm_file_ids.h>
+#define FILE_ID OSM_FILE_MCAST_FWD_RCV_C
+#include <opensm/osm_madw.h>
+#include <opensm/osm_log.h>
+#include <opensm/osm_switch.h>
+#include <opensm/osm_subnet.h>
+#include <opensm/osm_sm.h>
+
+void osm_mft_rcv_process(IN void *context, IN void *data)
+{
+ osm_sm_t *sm = context;
+ osm_madw_t *p_madw = data;
+ ib_smp_t *p_smp;
+ uint32_t block_num;
+ uint8_t position;
+ osm_switch_t *p_sw;
+ osm_mft_context_t *p_mft_context;
+ uint16_t *p_block;
+ ib_net64_t node_guid;
+ ib_api_status_t status;
+
+ CL_ASSERT(sm);
+
+ OSM_LOG_ENTER(sm->p_log);
+
+ CL_ASSERT(p_madw);
+
+ p_smp = osm_madw_get_smp_ptr(p_madw);
+ p_block = ib_smp_get_payload_ptr(p_smp);
+ block_num = cl_ntoh32(p_smp->attr_mod) & IB_MCAST_BLOCK_ID_MASK_HO;
+ position = (uint8_t) ((cl_ntoh32(p_smp->attr_mod) &
+ IB_MCAST_POSITION_MASK_HO) >>
+ IB_MCAST_POSITION_SHIFT);
+
+ /*
+ Acquire the switch object for this switch.
+ */
+ p_mft_context = osm_madw_get_mft_context_ptr(p_madw);
+ node_guid = p_mft_context->node_guid;
+
+ OSM_LOG(sm->p_log, OSM_LOG_DEBUG,
+ "Setting MFT block %u, position %u, "
+ "Switch 0x%016" PRIx64 ", TID 0x%" PRIx64 "\n",
+ block_num, position, cl_ntoh64(node_guid),
+ cl_ntoh64(p_smp->trans_id));
+
+ if (ib_smp_get_status(p_smp)) {
+ OSM_LOG(sm->p_log, OSM_LOG_DEBUG,
+ "MAD status 0x%x received\n",
+ cl_ntoh16(ib_smp_get_status(p_smp)));
+ goto Exit;
+ }
+
+ CL_PLOCK_EXCL_ACQUIRE(sm->p_lock);
+ p_sw = osm_get_switch_by_guid(sm->p_subn, node_guid);
+
+ if (!p_sw) {
+ OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR 0801: "
+ "MFT received for nonexistent node "
+ "0x%016" PRIx64 "\n", cl_ntoh64(node_guid));
+ } else {
+ status = osm_switch_set_mft_block(p_sw, p_block,
+ (uint16_t) block_num,
+ position);
+ if (status != IB_SUCCESS) {
+ OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR 0802: "
+ "Setting MFT block failed (%s)"
+ ", Switch 0x%016" PRIx64
+ " (%s), block %u, position %u\n",
+ ib_get_err_str(status), cl_ntoh64(node_guid),
+ p_sw->p_node->print_desc, block_num, position);
+ }
+ }
+
+ CL_PLOCK_RELEASE(sm->p_lock);
+Exit:
+ OSM_LOG_EXIT(sm->p_log);
+}
diff --git a/contrib/ofed/opensm/opensm/osm_mcast_mgr.c b/contrib/ofed/opensm/opensm/osm_mcast_mgr.c
new file mode 100644
index 0000000..be8edb4
--- /dev/null
+++ b/contrib/ofed/opensm/opensm/osm_mcast_mgr.c
@@ -0,0 +1,1225 @@
+/*
+ * Copyright (c) 2004-2009 Voltaire, Inc. All rights reserved.
+ * Copyright (c) 2002-2011 Mellanox Technologies LTD. All rights reserved.
+ * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
+ * Copyright (c) 2008 Xsigo Systems Inc. All rights reserved.
+ * Copyright (c) 2009 Sun Microsystems, Inc. All rights reserved.
+ * Copyright (c) 2010 HNR Consulting. All rights reserved.
+ * Copyright (C) 2012-2013 Tokyo Institute of Technology. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+/*
+ * Abstract:
+ * Implementation of osm_mcast_mgr_t.
+ * This file implements the Multicast Manager object.
+ */
+
+#if HAVE_CONFIG_H
+# include <config.h>
+#endif /* HAVE_CONFIG_H */
+
+#include <stdlib.h>
+#include <string.h>
+#include <iba/ib_types.h>
+#include <complib/cl_debug.h>
+#include <opensm/osm_file_ids.h>
+#define FILE_ID OSM_FILE_MCAST_MGR_C
+#include <opensm/osm_opensm.h>
+#include <opensm/osm_sm.h>
+#include <opensm/osm_multicast.h>
+#include <opensm/osm_node.h>
+#include <opensm/osm_switch.h>
+#include <opensm/osm_helper.h>
+#include <opensm/osm_msgdef.h>
+#include <opensm/osm_mcast_mgr.h>
+
+static osm_mcast_work_obj_t *mcast_work_obj_new(IN osm_port_t * p_port)
+{
+ osm_mcast_work_obj_t *p_obj;
+
+ /*
+ clean allocated memory to avoid assertion when trying to insert to
+ qlist.
+ see cl_qlist_insert_tail(): CL_ASSERT(p_list_item->p_list != p_list)
+ */
+ p_obj = malloc(sizeof(*p_obj));
+ if (p_obj) {
+ memset(p_obj, 0, sizeof(*p_obj));
+ p_obj->p_port = p_port;
+ }
+
+ return p_obj;
+}
+
+static void mcast_work_obj_delete(IN osm_mcast_work_obj_t * p_wobj)
+{
+ free(p_wobj);
+}
+
+int osm_mcast_make_port_list_and_map(cl_qlist_t * list, cl_qmap_t * map,
+ osm_mgrp_box_t * mbox)
+{
+ cl_map_item_t *map_item;
+ cl_list_item_t *list_item;
+ osm_mgrp_t *mgrp;
+ osm_mcm_port_t *mcm_port;
+ osm_mcast_work_obj_t *wobj;
+
+ cl_qmap_init(map);
+ cl_qlist_init(list);
+
+ for (list_item = cl_qlist_head(&mbox->mgrp_list);
+ list_item != cl_qlist_end(&mbox->mgrp_list);
+ list_item = cl_qlist_next(list_item)) {
+ mgrp = cl_item_obj(list_item, mgrp, list_item);
+ for (map_item = cl_qmap_head(&mgrp->mcm_port_tbl);
+ map_item != cl_qmap_end(&mgrp->mcm_port_tbl);
+ map_item = cl_qmap_next(map_item)) {
+ /* Acquire the port object for this port guid, then
+ create the new worker object to build the list. */
+ mcm_port = cl_item_obj(map_item, mcm_port, map_item);
+ if (cl_qmap_get(map, mcm_port->port->guid) !=
+ cl_qmap_end(map))
+ continue;
+ wobj = mcast_work_obj_new(mcm_port->port);
+ if (!wobj)
+ return -1;
+ cl_qlist_insert_tail(list, &wobj->list_item);
+ cl_qmap_insert(map, mcm_port->port->guid,
+ &wobj->map_item);
+ }
+ }
+ return 0;
+}
+
+void osm_mcast_drop_port_list(cl_qlist_t * list)
+{
+ while (cl_qlist_count(list))
+ mcast_work_obj_delete((osm_mcast_work_obj_t *)
+ cl_qlist_remove_head(list));
+}
+
+void osm_purge_mtree(osm_sm_t * sm, IN osm_mgrp_box_t * mbox)
+{
+ OSM_LOG_ENTER(sm->p_log);
+
+ if (mbox->root)
+ osm_mtree_destroy(mbox->root);
+ mbox->root = NULL;
+
+ OSM_LOG_EXIT(sm->p_log);
+}
+
+static void create_mgrp_switch_map(cl_qmap_t * m, cl_qlist_t * port_list)
+{
+ osm_mcast_work_obj_t *wobj;
+ osm_port_t *port;
+ osm_switch_t *sw;
+ ib_net64_t guid;
+ cl_list_item_t *i;
+
+ cl_qmap_init(m);
+ for (i = cl_qlist_head(port_list); i != cl_qlist_end(port_list);
+ i = cl_qlist_next(i)) {
+ wobj = cl_item_obj(i, wobj, list_item);
+ port = wobj->p_port;
+ if (port->p_node->sw) {
+ sw = port->p_node->sw;
+ sw->is_mc_member = 1;
+ } else if (port->p_physp->p_remote_physp) {
+ sw = port->p_physp->p_remote_physp->p_node->sw;
+ sw->num_of_mcm++;
+ } else
+ continue;
+ guid = osm_node_get_node_guid(sw->p_node);
+ if (cl_qmap_get(m, guid) == cl_qmap_end(m))
+ cl_qmap_insert(m, guid, &sw->mgrp_item);
+ }
+}
+
+static void destroy_mgrp_switch_map(cl_qmap_t * m)
+{
+ osm_switch_t *sw;
+ cl_map_item_t *i;
+
+ for (i = cl_qmap_head(m); i != cl_qmap_end(m); i = cl_qmap_next(i)) {
+ sw = cl_item_obj(i, sw, mgrp_item);
+ sw->num_of_mcm = 0;
+ sw->is_mc_member = 0;
+ }
+ cl_qmap_remove_all(m);
+}
+
+/**********************************************************************
+ Calculate the maximal "min hops" from the given switch to any
+ of the group HCAs
+ **********************************************************************/
+#ifdef OSM_VENDOR_INTF_ANAFA
+static float mcast_mgr_compute_avg_hops(osm_sm_t * sm, cl_qmap_t * m,
+ const osm_switch_t * this_sw)
+{
+ float avg_hops = 0;
+ uint32_t hops = 0;
+ uint32_t num_ports = 0;
+ uint16_t lid;
+ uint32_t least_hops;
+ cl_map_item_t *i;
+ osm_switch_t *sw;
+
+ OSM_LOG_ENTER(sm->p_log);
+
+ for (i = cl_qmap_head(m); i != cl_qmap_end(m); i = cl_qmap_next(i)) {
+ sw = cl_item_obj(i, sw, mcast_item);
+ lid = cl_ntoh16(osm_node_get_base_lid(sw->p_node, 0));
+ least_hops = osm_switch_get_least_hops(this_sw, lid);
+ /* for all host that are MC members and attached to the switch,
+ we should add the (least_hops + 1) * number_of_such_hosts.
+ If switch itself is in the MC, we should add the least_hops only */
+ hops += (least_hops + 1) * sw->num_of_mcm +
+ least_hops * sw->is_mc_member;
+ num_ports += sw->num_of_mcm + sw->is_mc_member;
+ }
+
+ /* We shouldn't be here if there aren't any ports in the group. */
+ CL_ASSERT(num_ports);
+
+ avg_hops = (float)(hops / num_ports);
+
+ OSM_LOG_EXIT(sm->p_log);
+ return avg_hops;
+}
+#else
+static float mcast_mgr_compute_max_hops(osm_sm_t * sm, cl_qmap_t * m,
+ const osm_switch_t * this_sw)
+{
+ uint32_t max_hops = 0, hops;
+ uint16_t lid;
+ cl_map_item_t *i;
+ osm_switch_t *sw;
+
+ OSM_LOG_ENTER(sm->p_log);
+
+ /*
+ For each member of the multicast group, compute the
+ number of hops to its base LID.
+ */
+ for (i = cl_qmap_head(m); i != cl_qmap_end(m); i = cl_qmap_next(i)) {
+ sw = cl_item_obj(i, sw, mgrp_item);
+ lid = cl_ntoh16(osm_node_get_base_lid(sw->p_node, 0));
+ hops = osm_switch_get_least_hops(this_sw, lid);
+ if (!sw->is_mc_member)
+ hops += 1;
+ if (hops > max_hops)
+ max_hops = hops;
+ }
+
+ /* Note that at this point we might get (max_hops == 0),
+ which means that there's only one member in the mcast
+ group, and it's the current switch */
+
+ OSM_LOG_EXIT(sm->p_log);
+ return (float)max_hops;
+}
+#endif
+
+/**********************************************************************
+ This function attempts to locate the optimal switch for the
+ center of the spanning tree. The current algorithm chooses
+ a switch with the lowest average hop count to the members
+ of the multicast group.
+**********************************************************************/
+static osm_switch_t *mcast_mgr_find_optimal_switch(osm_sm_t * sm,
+ cl_qlist_t * list)
+{
+ cl_qmap_t mgrp_sw_map;
+ cl_qmap_t *p_sw_tbl;
+ osm_switch_t *p_sw, *p_best_sw = NULL;
+ float hops = 0;
+ float best_hops = 10000; /* any big # will do */
+
+ OSM_LOG_ENTER(sm->p_log);
+
+ p_sw_tbl = &sm->p_subn->sw_guid_tbl;
+
+ create_mgrp_switch_map(&mgrp_sw_map, list);
+ for (p_sw = (osm_switch_t *) cl_qmap_head(p_sw_tbl);
+ p_sw != (osm_switch_t *) cl_qmap_end(p_sw_tbl);
+ p_sw = (osm_switch_t *) cl_qmap_next(&p_sw->map_item)) {
+ if (!osm_switch_supports_mcast(p_sw))
+ continue;
+
+#ifdef OSM_VENDOR_INTF_ANAFA
+ hops = mcast_mgr_compute_avg_hops(sm, &mgrp_sw_map, p_sw);
+#else
+ hops = mcast_mgr_compute_max_hops(sm, &mgrp_sw_map, p_sw);
+#endif
+
+ OSM_LOG(sm->p_log, OSM_LOG_DEBUG,
+ "Switch 0x%016" PRIx64 ", hops = %f\n",
+ cl_ntoh64(osm_node_get_node_guid(p_sw->p_node)), hops);
+
+ if (hops < best_hops) {
+ p_best_sw = p_sw;
+ best_hops = hops;
+ }
+ }
+
+ if (p_best_sw)
+ OSM_LOG(sm->p_log, OSM_LOG_VERBOSE,
+ "Best switch is 0x%" PRIx64 " (%s), hops = %f\n",
+ cl_ntoh64(osm_node_get_node_guid(p_best_sw->p_node)),
+ p_best_sw->p_node->print_desc, best_hops);
+ else
+ OSM_LOG(sm->p_log, OSM_LOG_VERBOSE,
+ "No multicast capable switches detected\n");
+
+ destroy_mgrp_switch_map(&mgrp_sw_map);
+ OSM_LOG_EXIT(sm->p_log);
+ return p_best_sw;
+}
+
+/**********************************************************************
+ This function returns the existing or optimal root switch for the tree.
+**********************************************************************/
+osm_switch_t *osm_mcast_mgr_find_root_switch(osm_sm_t * sm, cl_qlist_t *list)
+{
+ osm_switch_t *p_sw = NULL;
+
+ OSM_LOG_ENTER(sm->p_log);
+
+ /*
+ We always look for the best multicast tree root switch.
+ Otherwise since we always start with a a single join
+ the root will be always on the first switch attached to it.
+ - Very bad ...
+ */
+ p_sw = mcast_mgr_find_optimal_switch(sm, list);
+
+ OSM_LOG_EXIT(sm->p_log);
+ return p_sw;
+}
+
+static int mcast_mgr_set_mft_block(osm_sm_t * sm, IN osm_switch_t * p_sw,
+ uint32_t block_num, uint32_t position)
+{
+ osm_node_t *p_node;
+ osm_physp_t *p_physp;
+ osm_dr_path_t *p_path;
+ osm_madw_context_t context;
+ ib_api_status_t status;
+ uint32_t block_id_ho;
+ osm_mcast_tbl_t *p_tbl;
+ ib_net16_t block[IB_MCAST_BLOCK_SIZE];
+ int ret = 0;
+
+ CL_ASSERT(sm);
+
+ OSM_LOG_ENTER(sm->p_log);
+
+ CL_ASSERT(p_sw);
+
+ p_node = p_sw->p_node;
+
+ CL_ASSERT(p_node);
+
+ p_physp = osm_node_get_physp_ptr(p_node, 0);
+ p_path = osm_physp_get_dr_path_ptr(p_physp);
+
+ /*
+ Send multicast forwarding table blocks to the switch
+ as long as the switch indicates it has blocks needing
+ configuration.
+ */
+
+ context.mft_context.node_guid = osm_node_get_node_guid(p_node);
+ context.mft_context.set_method = TRUE;
+
+ p_tbl = osm_switch_get_mcast_tbl_ptr(p_sw);
+
+ if (osm_mcast_tbl_get_block(p_tbl, (uint16_t) block_num,
+ (uint8_t) position, block)) {
+ block_id_ho = block_num + (position << 28);
+
+ OSM_LOG(sm->p_log, OSM_LOG_DEBUG,
+ "Writing MFT block %u position %u to switch 0x%" PRIx64
+ "\n", block_num, position,
+ cl_ntoh64(context.mft_context.node_guid));
+
+ status = osm_req_set(sm, p_path, (void *)block, sizeof(block),
+ IB_MAD_ATTR_MCAST_FWD_TBL,
+ cl_hton32(block_id_ho), FALSE,
+ ib_port_info_get_m_key(&p_physp->port_info),
+ CL_DISP_MSGID_NONE, &context);
+ if (status != IB_SUCCESS) {
+ OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR 0A02: "
+ "Sending multicast fwd. tbl. block 0x%X to %s "
+ "failed (%s)\n", block_id_ho,
+ p_node->print_desc, ib_get_err_str(status));
+ ret = -1;
+ }
+ }
+
+ OSM_LOG_EXIT(sm->p_log);
+ return ret;
+}
+
+/**********************************************************************
+ This is part of the recursive function to compute the paths in the
+ spanning tree that emanate from this switch. On input, the p_list
+ contains the group members that must be routed from this switch.
+**********************************************************************/
+static void mcast_mgr_subdivide(osm_sm_t * sm, uint16_t mlid_ho,
+ osm_switch_t * p_sw, cl_qlist_t * p_list,
+ cl_qlist_t * list_array, uint8_t array_size)
+{
+ uint8_t port_num;
+ boolean_t ignore_existing;
+ osm_mcast_work_obj_t *p_wobj;
+
+ OSM_LOG_ENTER(sm->p_log);
+
+ /*
+ For Multicast Groups, we don't want to count on previous
+ configurations - since we can easily generate a storm
+ by loops.
+ */
+ ignore_existing = TRUE;
+
+ /*
+ Subdivide the set of ports into non-overlapping subsets
+ that will be routed to other switches.
+ */
+ while ((p_wobj =
+ (osm_mcast_work_obj_t *) cl_qlist_remove_head(p_list)) !=
+ (osm_mcast_work_obj_t *) cl_qlist_end(p_list)) {
+ port_num =
+ osm_switch_recommend_mcast_path(p_sw, p_wobj->p_port,
+ mlid_ho, ignore_existing);
+ if (port_num == OSM_NO_PATH) {
+ /*
+ This typically occurs if the switch does not support
+ multicast and the multicast tree must branch at this
+ switch.
+ */
+ OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR 0A03: "
+ "Error routing MLID 0x%X through switch 0x%"
+ PRIx64 " %s\n"
+ "\t\t\t\tNo multicast paths from this switch "
+ "for port with LID %u\n", mlid_ho,
+ cl_ntoh64(osm_node_get_node_guid(p_sw->p_node)),
+ p_sw->p_node->print_desc,
+ cl_ntoh16(osm_port_get_base_lid
+ (p_wobj->p_port)));
+ mcast_work_obj_delete(p_wobj);
+ continue;
+ }
+
+ if (port_num >= array_size) {
+ OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR 0A04: "
+ "Error routing MLID 0x%X through switch 0x%"
+ PRIx64 " %s\n"
+ "\t\t\t\tNo multicast paths from this switch "
+ "to port with LID %u\n", mlid_ho,
+ cl_ntoh64(osm_node_get_node_guid(p_sw->p_node)),
+ p_sw->p_node->print_desc,
+ cl_ntoh16(osm_port_get_base_lid
+ (p_wobj->p_port)));
+ mcast_work_obj_delete(p_wobj);
+ continue;
+ }
+
+ cl_qlist_insert_tail(&list_array[port_num], &p_wobj->list_item);
+ }
+
+ OSM_LOG_EXIT(sm->p_log);
+}
+
+static void mcast_mgr_purge_list(osm_sm_t * sm, uint16_t mlid, cl_qlist_t * list)
+{
+ if (OSM_LOG_IS_ACTIVE_V2(sm->p_log, OSM_LOG_ERROR)) {
+ osm_mcast_work_obj_t *wobj;
+ cl_list_item_t *i;
+ for (i = cl_qlist_head(list); i != cl_qlist_end(list);
+ i = cl_qlist_next(i)) {
+ wobj = cl_item_obj(i, wobj, list_item);
+ OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR 0A06: "
+ "Unable to route MLID 0x%X for port 0x%" PRIx64 "\n",
+ mlid, cl_ntoh64(osm_port_get_guid(wobj->p_port)));
+ }
+ }
+ osm_mcast_drop_port_list(list);
+}
+
+/**********************************************************************
+ This is the recursive function to compute the paths in the spanning
+ tree that emanate from this switch. On input, the p_list contains
+ the group members that must be routed from this switch.
+
+ The function returns the newly created mtree node element.
+**********************************************************************/
+static osm_mtree_node_t *mcast_mgr_branch(osm_sm_t * sm, uint16_t mlid_ho,
+ osm_switch_t * p_sw,
+ cl_qlist_t * p_list, uint8_t depth,
+ uint8_t upstream_port,
+ uint8_t * p_max_depth)
+{
+ uint8_t max_children;
+ osm_mtree_node_t *p_mtn = NULL;
+ cl_qlist_t *list_array = NULL;
+ uint8_t i;
+ ib_net64_t node_guid;
+ osm_mcast_work_obj_t *p_wobj;
+ cl_qlist_t *p_port_list;
+ size_t count;
+ osm_mcast_tbl_t *p_tbl;
+
+ OSM_LOG_ENTER(sm->p_log);
+
+ CL_ASSERT(p_sw);
+ CL_ASSERT(p_list);
+ CL_ASSERT(p_max_depth);
+
+ node_guid = osm_node_get_node_guid(p_sw->p_node);
+
+ OSM_LOG(sm->p_log, OSM_LOG_VERBOSE,
+ "Routing MLID 0x%X through switch 0x%" PRIx64
+ " %s, %u nodes at depth %u\n",
+ mlid_ho, cl_ntoh64(node_guid), p_sw->p_node->print_desc,
+ cl_qlist_count(p_list), depth);
+
+ CL_ASSERT(cl_qlist_count(p_list) > 0);
+
+ depth++;
+
+ if (depth >= 64) {
+ OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR 0A21: "
+ "Maximal hops number is reached for MLID 0x%x."
+ " Break processing\n", mlid_ho);
+ mcast_mgr_purge_list(sm, mlid_ho, p_list);
+ goto Exit;
+ }
+
+ if (depth > *p_max_depth) {
+ CL_ASSERT(depth == *p_max_depth + 1);
+ *p_max_depth = depth;
+ }
+
+ if (osm_switch_supports_mcast(p_sw) == FALSE) {
+ /*
+ This switch doesn't do multicast. Clean-up.
+ */
+ OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR 0A14: "
+ "Switch 0x%" PRIx64 " %s does not support multicast\n",
+ cl_ntoh64(node_guid), p_sw->p_node->print_desc);
+
+ /*
+ Deallocate all the work objects on this branch of the tree.
+ */
+ mcast_mgr_purge_list(sm, mlid_ho, p_list);
+ goto Exit;
+ }
+
+ p_mtn = osm_mtree_node_new(p_sw);
+ if (p_mtn == NULL) {
+ /*
+ We are unable to continue routing down this
+ leg of the tree. Clean-up.
+ */
+ OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR 0A15: "
+ "Insufficient memory to build multicast tree\n");
+
+ /*
+ Deallocate all the work objects on this branch of the tree.
+ */
+ mcast_mgr_purge_list(sm, mlid_ho, p_list);
+ goto Exit;
+ }
+
+ max_children = osm_mtree_node_get_max_children(p_mtn);
+
+ CL_ASSERT(max_children > 1);
+
+ /*
+ Prepare an empty list for each port in the switch.
+ TO DO - this list array could probably be moved
+ inside the switch element to save on malloc thrashing.
+ */
+ list_array = malloc(sizeof(cl_qlist_t) * max_children);
+ if (list_array == NULL) {
+ OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR 0A16: "
+ "Unable to allocate list array\n");
+ mcast_mgr_purge_list(sm, mlid_ho, p_list);
+ osm_mtree_destroy(p_mtn);
+ p_mtn = NULL;
+ goto Exit;
+ }
+
+ memset(list_array, 0, sizeof(cl_qlist_t) * max_children);
+
+ for (i = 0; i < max_children; i++)
+ cl_qlist_init(&list_array[i]);
+
+ mcast_mgr_subdivide(sm, mlid_ho, p_sw, p_list, list_array, max_children);
+
+ p_tbl = osm_switch_get_mcast_tbl_ptr(p_sw);
+
+ /*
+ Add the upstream port to the forwarding table unless
+ we're at the root of the spanning tree.
+ */
+ if (depth > 1) {
+ OSM_LOG(sm->p_log, OSM_LOG_DEBUG,
+ "Adding upstream port %u\n", upstream_port);
+
+ CL_ASSERT(upstream_port);
+ osm_mcast_tbl_set(p_tbl, mlid_ho, upstream_port);
+ }
+
+ /*
+ For each port that was allocated some routes,
+ recurse into this function to continue building the tree
+ if the node on the other end of that port is another switch.
+ Otherwise, the node is an endpoint, and we've found a leaf
+ of the tree. Mark leaves with our special pointer value.
+ */
+
+ for (i = 0; i < max_children; i++) {
+ const osm_physp_t *p_physp;
+ const osm_physp_t *p_remote_physp;
+ osm_node_t *p_node;
+ const osm_node_t *p_remote_node;
+
+ p_port_list = &list_array[i];
+
+ count = cl_qlist_count(p_port_list);
+
+ /*
+ There should be no children routed through the upstream port!
+ */
+ CL_ASSERT(upstream_port == 0 || i != upstream_port ||
+ (i == upstream_port && count == 0));
+
+ if (count == 0)
+ continue; /* No routes down this port. */
+
+ OSM_LOG(sm->p_log, OSM_LOG_DEBUG,
+ "Routing %zu destinations via switch port %u\n",
+ count, i);
+
+ if (i == 0) {
+ /* This means we are adding the switch to the MC group.
+ We do not need to continue looking at the remote
+ port, just needed to add the port to the table */
+ CL_ASSERT(count == 1);
+
+ osm_mcast_tbl_set(p_tbl, mlid_ho, i);
+
+ p_wobj = (osm_mcast_work_obj_t *)
+ cl_qlist_remove_head(p_port_list);
+ mcast_work_obj_delete(p_wobj);
+ continue;
+ }
+
+ p_node = p_sw->p_node;
+ p_remote_node = osm_node_get_remote_node(p_node, i, NULL);
+ if (!p_remote_node) {
+ /*
+ * If we reached here, it means the minhop table has
+ * invalid entries that leads to disconnected ports.
+ *
+ * A possible reason for the code to reach here is
+ * that ucast cache is enabled, and a leaf switch that
+ * is used as a non-leaf switch in a multicast has been
+ * removed from the fabric.
+ *
+ * When it happens, we should invalidate the cache
+ * and force rerouting of the fabric.
+ */
+
+ OSM_LOG(sm->p_log, OSM_LOG_ERROR,
+ "ERR 0A1E: Tried to route MLID 0x%X through "
+ "disconnected switch 0x%" PRIx64 " port %d\n",
+ mlid_ho, cl_ntoh64(node_guid), i);
+
+ /* Free memory */
+ mcast_mgr_purge_list(sm, mlid_ho, p_port_list);
+
+ /* Invalidate ucast cache */
+ if (sm->ucast_mgr.p_subn->opt.use_ucast_cache &&
+ sm->ucast_mgr.cache_valid) {
+ OSM_LOG(sm->p_log, OSM_LOG_INFO,
+ "Unicast Cache will be invalidated due "
+ "to multicast routing errors\n");
+ osm_ucast_cache_invalidate(&sm->ucast_mgr);
+ sm->p_subn->force_heavy_sweep = TRUE;
+ }
+
+ continue;
+ }
+
+ /*
+ This port routes frames for this mcast group. Therefore,
+ set the appropriate bit in the multicast forwarding
+ table for this switch.
+ */
+ osm_mcast_tbl_set(p_tbl, mlid_ho, i);
+
+ if (osm_node_get_type(p_remote_node) == IB_NODE_TYPE_SWITCH) {
+ /*
+ Acquire a pointer to the remote switch then recurse.
+ */
+ CL_ASSERT(p_remote_node->sw);
+
+ p_physp = osm_node_get_physp_ptr(p_node, i);
+ CL_ASSERT(p_physp);
+
+ p_remote_physp = osm_physp_get_remote(p_physp);
+ CL_ASSERT(p_remote_physp);
+
+ p_mtn->child_array[i] =
+ mcast_mgr_branch(sm, mlid_ho, p_remote_node->sw,
+ p_port_list, depth,
+ osm_physp_get_port_num
+ (p_remote_physp), p_max_depth);
+ } else {
+ /*
+ The neighbor node is not a switch, so this
+ must be a leaf.
+ */
+ CL_ASSERT(count == 1);
+
+ p_mtn->child_array[i] = OSM_MTREE_LEAF;
+ p_wobj = (osm_mcast_work_obj_t *)
+ cl_qlist_remove_head(p_port_list);
+
+ CL_ASSERT(cl_is_qlist_empty(p_port_list));
+
+ OSM_LOG(sm->p_log, OSM_LOG_DEBUG,
+ "Found leaf for port 0x%016" PRIx64
+ " on switch port %u\n",
+ cl_ntoh64(osm_port_get_guid(p_wobj->p_port)),
+ i);
+ mcast_work_obj_delete(p_wobj);
+ }
+ }
+
+ free(list_array);
+Exit:
+ OSM_LOG_EXIT(sm->p_log);
+ return p_mtn;
+}
+
+static ib_api_status_t mcast_mgr_build_spanning_tree(osm_sm_t * sm,
+ osm_mgrp_box_t * mbox)
+{
+ cl_qlist_t port_list;
+ cl_qmap_t port_map;
+ uint32_t num_ports;
+ osm_switch_t *p_sw;
+ ib_api_status_t status = IB_SUCCESS;
+ uint8_t max_depth = 0;
+
+ OSM_LOG_ENTER(sm->p_log);
+
+ /*
+ TO DO - for now, just blow away the old tree.
+ In the future we'll need to construct the tree based
+ on multicast forwarding table information if the user wants to
+ preserve existing multicast routes.
+ */
+ osm_purge_mtree(sm, mbox);
+
+ /* build the first "subset" containing all member ports */
+ if (osm_mcast_make_port_list_and_map(&port_list, &port_map, mbox)) {
+ OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR 0A10: "
+ "Insufficient memory to make port list\n");
+ status = IB_ERROR;
+ goto Exit;
+ }
+
+ num_ports = cl_qlist_count(&port_list);
+ if (num_ports < 2) {
+ OSM_LOG(sm->p_log, OSM_LOG_VERBOSE,
+ "MLID 0x%X has %u members - nothing to do\n",
+ mbox->mlid, num_ports);
+ osm_mcast_drop_port_list(&port_list);
+ goto Exit;
+ }
+
+ /*
+ This function builds the single spanning tree recursively.
+ At each stage, the ports to be reached are divided into
+ non-overlapping subsets of member ports that can be reached through
+ a given switch port. Construction then moves down each
+ branch, and the process starts again with each branch computing
+ for its own subset of the member ports.
+
+ The maximum recursion depth is at worst the maximum hop count in the
+ subnet, which is spec limited to 64.
+ */
+
+ /*
+ Locate the switch around which to create the spanning
+ tree for this multicast group.
+ */
+ p_sw = osm_mcast_mgr_find_root_switch(sm, &port_list);
+ if (p_sw == NULL) {
+ OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR 0A08: "
+ "Unable to locate a suitable switch for group 0x%X\n",
+ mbox->mlid);
+ osm_mcast_drop_port_list(&port_list);
+ status = IB_ERROR;
+ goto Exit;
+ }
+
+ mbox->root = mcast_mgr_branch(sm, mbox->mlid, p_sw, &port_list, 0, 0,
+ &max_depth);
+
+ OSM_LOG(sm->p_log, OSM_LOG_VERBOSE,
+ "Configured MLID 0x%X for %u ports, max tree depth = %u\n",
+ mbox->mlid, num_ports, max_depth);
+Exit:
+ OSM_LOG_EXIT(sm->p_log);
+ return status;
+}
+
+#if 0
+/* unused */
+void osm_mcast_mgr_set_table(osm_sm_t * sm, IN const osm_mgrp_t * p_mgrp,
+ IN const osm_mtree_node_t * p_mtn)
+{
+ uint8_t i;
+ uint8_t max_children;
+ osm_mtree_node_t *p_child_mtn;
+ uint16_t mlid_ho;
+ osm_mcast_tbl_t *p_tbl;
+ osm_switch_t *p_sw;
+
+ OSM_LOG_ENTER(sm->p_log);
+
+ mlid_ho = cl_ntoh16(osm_mgrp_get_mlid(p_mgrp));
+ p_sw = osm_mtree_node_get_switch_ptr(p_mtn);
+
+ CL_ASSERT(p_sw);
+
+ OSM_LOG(sm->p_log, OSM_LOG_VERBOSE,
+ "Configuring MLID 0x%X on switch 0x%" PRIx64 "\n",
+ mlid_ho, osm_node_get_node_guid(p_sw->p_node));
+
+ /*
+ For every child of this tree node, set the corresponding
+ bit in the switch's mcast table.
+ */
+ p_tbl = osm_switch_get_mcast_tbl_ptr(p_sw);
+ max_children = osm_mtree_node_get_max_children(p_mtn);
+
+ CL_ASSERT(max_children <= osm_switch_get_num_ports(p_sw));
+
+ osm_mcast_tbl_clear_mlid(p_tbl, mlid_ho);
+
+ for (i = 0; i < max_children; i++) {
+ p_child_mtn = osm_mtree_node_get_child(p_mtn, i);
+ if (p_child_mtn == NULL)
+ continue;
+
+ osm_mcast_tbl_set(p_tbl, mlid_ho, i);
+ }
+
+ OSM_LOG_EXIT(sm->p_log);
+}
+#endif
+
+static void mcast_mgr_clear(osm_sm_t * sm, uint16_t mlid)
+{
+ osm_switch_t *p_sw;
+ cl_qmap_t *p_sw_tbl;
+ osm_mcast_tbl_t *p_mcast_tbl;
+
+ OSM_LOG_ENTER(sm->p_log);
+
+ /* Walk the switches and clear the routing entries for this MLID. */
+ p_sw_tbl = &sm->p_subn->sw_guid_tbl;
+ p_sw = (osm_switch_t *) cl_qmap_head(p_sw_tbl);
+ while (p_sw != (osm_switch_t *) cl_qmap_end(p_sw_tbl)) {
+ p_mcast_tbl = osm_switch_get_mcast_tbl_ptr(p_sw);
+ osm_mcast_tbl_clear_mlid(p_mcast_tbl, mlid);
+ p_sw = (osm_switch_t *) cl_qmap_next(&p_sw->map_item);
+ }
+
+ OSM_LOG_EXIT(sm->p_log);
+}
+
+#if 0
+/* TO DO - make this real -- at least update spanning tree */
+/**********************************************************************
+ Lock must be held on entry.
+**********************************************************************/
+ib_api_status_t osm_mcast_mgr_process_single(osm_sm_t * sm,
+ IN ib_net16_t const mlid,
+ IN ib_net64_t const port_guid,
+ IN uint8_t const join_state)
+{
+ uint8_t port_num;
+ uint16_t mlid_ho;
+ ib_net64_t sw_guid;
+ osm_port_t *p_port;
+ osm_physp_t *p_physp;
+ osm_physp_t *p_remote_physp;
+ osm_node_t *p_remote_node;
+ osm_mcast_tbl_t *p_mcast_tbl;
+ ib_api_status_t status = IB_SUCCESS;
+
+ OSM_LOG_ENTER(sm->p_log);
+
+ CL_ASSERT(mlid);
+ CL_ASSERT(port_guid);
+
+ mlid_ho = cl_ntoh16(mlid);
+
+ OSM_LOG(sm->p_log, OSM_LOG_DEBUG,
+ "Attempting to add port 0x%" PRIx64 " to MLID 0x%X, "
+ "\n\t\t\t\tjoin state = 0x%X\n",
+ cl_ntoh64(port_guid), mlid_ho, join_state);
+
+ /*
+ Acquire the Port object.
+ */
+ p_port = osm_get_port_by_guid(sm->p_subn, port_guid);
+ if (!p_port) {
+ OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR 0A01: "
+ "Unable to acquire port object for 0x%" PRIx64 "\n",
+ cl_ntoh64(port_guid));
+ status = IB_ERROR;
+ goto Exit;
+ }
+
+ p_physp = p_port->p_physp;
+ if (p_physp == NULL) {
+ OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR 0A05: "
+ "Unable to acquire phsyical port object for 0x%" PRIx64
+ "\n", cl_ntoh64(port_guid));
+ status = IB_ERROR;
+ goto Exit;
+ }
+
+ p_remote_physp = osm_physp_get_remote(p_physp);
+ if (p_remote_physp == NULL) {
+ OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR 0A11: "
+ "Unable to acquire remote phsyical port object "
+ "for 0x%" PRIx64 "\n", cl_ntoh64(port_guid));
+ status = IB_ERROR;
+ goto Exit;
+ }
+
+ p_remote_node = osm_physp_get_node_ptr(p_remote_physp);
+
+ CL_ASSERT(p_remote_node);
+
+ sw_guid = osm_node_get_node_guid(p_remote_node);
+
+ if (osm_node_get_type(p_remote_node) != IB_NODE_TYPE_SWITCH) {
+ OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR 0A22: "
+ "Remote node not a switch node 0x%" PRIx64 "\n",
+ cl_ntoh64(sw_guid));
+ status = IB_ERROR;
+ goto Exit;
+ }
+
+ if (!p_remote_node->sw) {
+ OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR 0A12: "
+ "No switch object 0x%" PRIx64 "\n", cl_ntoh64(sw_guid));
+ status = IB_ERROR;
+ goto Exit;
+ }
+
+ if (osm_switch_is_in_mcast_tree(p_remote_node->sw, mlid_ho)) {
+ /*
+ We're in luck. The switch attached to this port
+ is already in the multicast group, so we can just
+ add the specified port as a new leaf of the tree.
+ */
+ if (join_state & (IB_JOIN_STATE_FULL | IB_JOIN_STATE_NON)) {
+ /*
+ This node wants to receive multicast frames.
+ Get the switch port number to which the new member port
+ is attached, then configure this single mcast table.
+ */
+ port_num = osm_physp_get_port_num(p_remote_physp);
+ CL_ASSERT(port_num);
+
+ p_mcast_tbl =
+ osm_switch_get_mcast_tbl_ptr(p_remote_node->sw);
+ osm_mcast_tbl_set(p_mcast_tbl, mlid_ho, port_num);
+ } else {
+ if (join_state & IB_JOIN_STATE_SEND_ONLY)
+ OSM_LOG(sm->p_log, OSM_LOG_DEBUG,
+ "Success. Nothing to do for send"
+ "only member\n");
+ else {
+ OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR 0A13: "
+ "Unknown join state 0x%X\n",
+ join_state);
+ status = IB_ERROR;
+ goto Exit;
+ }
+ }
+ } else
+ OSM_LOG(sm->p_log, OSM_LOG_DEBUG, "Unable to add port\n");
+
+Exit:
+ OSM_LOG_EXIT(sm->p_log);
+ return status;
+}
+#endif
+
+/**********************************************************************
+ Process the entire group.
+ NOTE : The lock should be held externally!
+ **********************************************************************/
+static ib_api_status_t mcast_mgr_process_mlid(osm_sm_t * sm, uint16_t mlid)
+{
+ ib_api_status_t status = IB_SUCCESS;
+ struct osm_routing_engine *re = sm->p_subn->p_osm->routing_engine_used;
+ osm_mgrp_box_t *mbox;
+
+ OSM_LOG_ENTER(sm->p_log);
+
+ OSM_LOG(sm->p_log, OSM_LOG_DEBUG,
+ "Processing multicast group with mlid 0x%X\n", mlid);
+
+ /* Clear the multicast tables to start clean, then build
+ the spanning tree which sets the mcast table bits for each
+ port in the group. */
+ mcast_mgr_clear(sm, mlid);
+
+ mbox = osm_get_mbox_by_mlid(sm->p_subn, cl_hton16(mlid));
+ if (mbox) {
+ if (re && re->mcast_build_stree)
+ status = re->mcast_build_stree(re->context, mbox);
+ else
+ status = mcast_mgr_build_spanning_tree(sm, mbox);
+
+ if (status != IB_SUCCESS)
+ OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR 0A17: "
+ "Unable to create spanning tree (%s) for mlid "
+ "0x%x\n", ib_get_err_str(status), mlid);
+ }
+
+ OSM_LOG_EXIT(sm->p_log);
+ return status;
+}
+
+static void mcast_mgr_set_mfttop(IN osm_sm_t * sm, IN osm_switch_t * p_sw)
+{
+ osm_node_t *p_node;
+ osm_dr_path_t *p_path;
+ osm_physp_t *p_physp;
+ osm_mcast_tbl_t *p_tbl;
+ osm_madw_context_t context;
+ ib_api_status_t status;
+ ib_switch_info_t si;
+ ib_net16_t mcast_top;
+
+ OSM_LOG_ENTER(sm->p_log);
+
+ CL_ASSERT(p_sw);
+
+ p_node = p_sw->p_node;
+
+ CL_ASSERT(p_node);
+
+ p_physp = osm_node_get_physp_ptr(p_node, 0);
+ p_path = osm_physp_get_dr_path_ptr(p_physp);
+ p_tbl = osm_switch_get_mcast_tbl_ptr(p_sw);
+
+ if (sm->p_subn->opt.use_mfttop &&
+ p_physp->port_info.capability_mask & IB_PORT_CAP_HAS_MCAST_FDB_TOP) {
+ /*
+ Set the top of the multicast forwarding table.
+ */
+ si = p_sw->switch_info;
+ if (sm->p_subn->first_time_master_sweep == TRUE)
+ mcast_top = cl_hton16(sm->mlids_init_max);
+ else {
+ if (p_tbl->max_block_in_use == -1)
+ mcast_top = cl_hton16(IB_LID_MCAST_START_HO - 1);
+ else
+ mcast_top = cl_hton16(IB_LID_MCAST_START_HO +
+ (p_tbl->max_block_in_use + 1) * IB_MCAST_BLOCK_SIZE - 1);
+ }
+ if (mcast_top == si.mcast_top)
+ return;
+
+ si.mcast_top = mcast_top;
+
+ OSM_LOG(sm->p_log, OSM_LOG_DEBUG,
+ "Setting switch MFT top to MLID 0x%x\n",
+ cl_ntoh16(si.mcast_top));
+
+ context.si_context.light_sweep = FALSE;
+ context.si_context.node_guid = osm_node_get_node_guid(p_node);
+ context.si_context.set_method = TRUE;
+ context.si_context.lft_top_change = FALSE;
+
+ status = osm_req_set(sm, p_path, (uint8_t *) & si,
+ sizeof(si), IB_MAD_ATTR_SWITCH_INFO,
+ 0, FALSE,
+ ib_port_info_get_m_key(&p_physp->port_info),
+ CL_DISP_MSGID_NONE, &context);
+
+ if (status != IB_SUCCESS)
+ OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR 0A1B: "
+ "Sending SwitchInfo attribute failed (%s)\n",
+ ib_get_err_str(status));
+ }
+}
+
+static int mcast_mgr_set_mftables(osm_sm_t * sm)
+{
+ cl_qmap_t *p_sw_tbl = &sm->p_subn->sw_guid_tbl;
+ osm_switch_t *p_sw;
+ osm_mcast_tbl_t *p_tbl;
+ int block_notdone, ret = 0;
+ int16_t block_num, max_block = -1;
+
+ p_sw = (osm_switch_t *) cl_qmap_head(p_sw_tbl);
+ while (p_sw != (osm_switch_t *) cl_qmap_end(p_sw_tbl)) {
+ p_sw->mft_block_num = 0;
+ p_sw->mft_position = 0;
+ p_tbl = osm_switch_get_mcast_tbl_ptr(p_sw);
+ if (osm_mcast_tbl_get_max_block_in_use(p_tbl) > max_block)
+ max_block = osm_mcast_tbl_get_max_block_in_use(p_tbl);
+ mcast_mgr_set_mfttop(sm, p_sw);
+ p_sw = (osm_switch_t *) cl_qmap_next(&p_sw->map_item);
+ }
+
+ /* Stripe the MFT blocks across the switches */
+ for (block_num = 0; block_num <= max_block; block_num++) {
+ block_notdone = 1;
+ while (block_notdone) {
+ block_notdone = 0;
+ p_sw = (osm_switch_t *) cl_qmap_head(p_sw_tbl);
+ while (p_sw != (osm_switch_t *) cl_qmap_end(p_sw_tbl)) {
+ if (p_sw->mft_block_num == block_num) {
+ block_notdone = 1;
+ if (mcast_mgr_set_mft_block(sm, p_sw,
+ p_sw->mft_block_num,
+ p_sw->mft_position))
+ ret = -1;
+ p_tbl = osm_switch_get_mcast_tbl_ptr(p_sw);
+ if (++p_sw->mft_position > p_tbl->max_position) {
+ p_sw->mft_position = 0;
+ p_sw->mft_block_num++;
+ }
+ }
+ p_sw = (osm_switch_t *) cl_qmap_next(&p_sw->map_item);
+ }
+ }
+ }
+
+ return ret;
+}
+
+static int alloc_mfts(osm_sm_t * sm)
+{
+ int i;
+ cl_map_item_t *item;
+ osm_switch_t *p_sw;
+
+ for (i = sm->p_subn->max_mcast_lid_ho - IB_LID_MCAST_START_HO; i >= 0;
+ i--)
+ if (sm->p_subn->mboxes[i])
+ break;
+ if (i < 0)
+ return 0;
+
+ /* Now, walk switches and (re)allocate multicast tables */
+ for (item = cl_qmap_head(&sm->p_subn->sw_guid_tbl);
+ item != cl_qmap_end(&sm->p_subn->sw_guid_tbl);
+ item = cl_qmap_next(item)) {
+ p_sw = (osm_switch_t *) item;
+ if (osm_mcast_tbl_realloc(&p_sw->mcast_tbl, i))
+ return -1;
+ }
+ return 0;
+}
+
+/**********************************************************************
+ This is the function that is invoked during idle time and sweep to
+ handle the process request for mcast groups where join/leave/delete
+ was required.
+ **********************************************************************/
+int osm_mcast_mgr_process(osm_sm_t * sm, boolean_t config_all)
+{
+ int ret = 0;
+ unsigned i;
+ unsigned max_mlid;
+
+ OSM_LOG_ENTER(sm->p_log);
+
+ CL_PLOCK_EXCL_ACQUIRE(sm->p_lock);
+
+ /* If there are no switches in the subnet we have nothing to do. */
+ if (cl_qmap_count(&sm->p_subn->sw_guid_tbl) == 0) {
+ OSM_LOG(sm->p_log, OSM_LOG_DEBUG,
+ "No switches in subnet. Nothing to do\n");
+ goto exit;
+ }
+
+ if (alloc_mfts(sm)) {
+ OSM_LOG(sm->p_log, OSM_LOG_ERROR,
+ "ERR 0A09: alloc_mfts failed\n");
+ ret = -1;
+ goto exit;
+ }
+
+ max_mlid = config_all ? sm->p_subn->max_mcast_lid_ho
+ - IB_LID_MCAST_START_HO : sm->mlids_req_max;
+ for (i = 0; i <= max_mlid; i++) {
+ if (sm->mlids_req[i] ||
+ (config_all && sm->p_subn->mboxes[i])) {
+ sm->mlids_req[i] = 0;
+ mcast_mgr_process_mlid(sm, i + IB_LID_MCAST_START_HO);
+ }
+ }
+
+ sm->mlids_req_max = 0;
+
+ ret = mcast_mgr_set_mftables(sm);
+
+ osm_dump_mcast_routes(sm->p_subn->p_osm);
+
+exit:
+ CL_PLOCK_RELEASE(sm->p_lock);
+ OSM_LOG_EXIT(sm->p_log);
+ return ret;
+}
diff --git a/contrib/ofed/opensm/opensm/osm_mcast_tbl.c b/contrib/ofed/opensm/opensm/osm_mcast_tbl.c
new file mode 100644
index 0000000..617fd50
--- /dev/null
+++ b/contrib/ofed/opensm/opensm/osm_mcast_tbl.c
@@ -0,0 +1,265 @@
+/*
+ * Copyright (c) 2004-2009 Voltaire, Inc. All rights reserved.
+ * Copyright (c) 2002-2009 Mellanox Technologies LTD. All rights reserved.
+ * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
+ * Copyright (c) 2009 HNR Consulting. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+/*
+ * Abstract:
+ * Implementation of osm_mcast_tbl_t.
+ * This object represents a multicast forwarding table.
+ * This object is part of the opensm family of objects.
+ */
+
+#if HAVE_CONFIG_H
+# include <config.h>
+#endif /* HAVE_CONFIG_H */
+
+#include <stdlib.h>
+#include <string.h>
+#include <complib/cl_math.h>
+#include <iba/ib_types.h>
+#include <opensm/osm_file_ids.h>
+#define FILE_ID OSM_FILE_MCAST_TBL_C
+#include <opensm/osm_mcast_tbl.h>
+
+void osm_mcast_tbl_init(IN osm_mcast_tbl_t * p_tbl, IN uint8_t num_ports,
+ IN uint16_t capacity)
+{
+ CL_ASSERT(p_tbl);
+ CL_ASSERT(num_ports);
+
+ memset(p_tbl, 0, sizeof(*p_tbl));
+
+ p_tbl->max_block_in_use = -1;
+
+ if (capacity == 0) {
+ /*
+ This switch apparently doesn't support multicast.
+ Everything is initialized to zero already, so return.
+ */
+ return;
+ }
+
+ p_tbl->num_entries = capacity;
+ p_tbl->num_ports = num_ports;
+ p_tbl->max_position =
+ (uint8_t) ((ROUNDUP(num_ports, IB_MCAST_MASK_SIZE) /
+ IB_MCAST_MASK_SIZE) - 1);
+
+ p_tbl->max_block = (uint16_t) ((ROUNDUP(p_tbl->num_entries,
+ IB_MCAST_BLOCK_SIZE) /
+ IB_MCAST_BLOCK_SIZE) - 1);
+}
+
+void osm_mcast_tbl_destroy(IN osm_mcast_tbl_t * p_tbl)
+{
+ free(p_tbl->p_mask_tbl);
+}
+
+void osm_mcast_tbl_set(IN osm_mcast_tbl_t * p_tbl, IN uint16_t mlid_ho,
+ IN uint8_t port)
+{
+ unsigned mlid_offset, mask_offset, bit_mask;
+ int16_t block_num;
+
+ CL_ASSERT(p_tbl && p_tbl->p_mask_tbl);
+ CL_ASSERT(mlid_ho >= IB_LID_MCAST_START_HO);
+ CL_ASSERT(mlid_ho <= p_tbl->max_mlid_ho);
+
+ mlid_offset = mlid_ho - IB_LID_MCAST_START_HO;
+ mask_offset = port / IB_MCAST_MASK_SIZE;
+ bit_mask = cl_ntoh16((uint16_t) (1 << (port % IB_MCAST_MASK_SIZE)));
+ (*p_tbl->p_mask_tbl)[mlid_offset][mask_offset] |= bit_mask;
+
+ block_num = (int16_t) (mlid_offset / IB_MCAST_BLOCK_SIZE);
+
+ if (block_num > p_tbl->max_block_in_use)
+ p_tbl->max_block_in_use = (uint16_t) block_num;
+}
+
+int osm_mcast_tbl_realloc(IN osm_mcast_tbl_t * p_tbl, IN unsigned mlid_offset)
+{
+ size_t mft_depth, size;
+ uint16_t (*p_mask_tbl)[][IB_MCAST_POSITION_MAX + 1];
+
+ if (mlid_offset < p_tbl->mft_depth)
+ goto done;
+
+ /*
+ The number of bytes needed in the mask table is:
+ The (maximum bit mask 'position' + 1) times the
+ number of bytes in each bit mask times the
+ number of MLIDs supported by the table.
+
+ We must always allocate the array with the maximum position
+ since it is (and must be) defined that way the table structure
+ in order to create a pointer to a two dimensional array.
+ */
+ mft_depth = (mlid_offset / IB_MCAST_BLOCK_SIZE + 1) * IB_MCAST_BLOCK_SIZE;
+ size = mft_depth * (IB_MCAST_POSITION_MAX + 1) * IB_MCAST_MASK_SIZE / 8;
+ p_mask_tbl = realloc(p_tbl->p_mask_tbl, size);
+ if (!p_mask_tbl)
+ return -1;
+ memset((uint8_t *)p_mask_tbl + p_tbl->mft_depth * (IB_MCAST_POSITION_MAX + 1) * IB_MCAST_MASK_SIZE / 8,
+ 0,
+ size - p_tbl->mft_depth * (IB_MCAST_POSITION_MAX + 1) * IB_MCAST_MASK_SIZE / 8);
+ p_tbl->p_mask_tbl = p_mask_tbl;
+ p_tbl->mft_depth = mft_depth;
+done:
+ p_tbl->max_mlid_ho = mlid_offset + IB_LID_MCAST_START_HO;
+ return 0;
+}
+
+boolean_t osm_mcast_tbl_is_port(IN const osm_mcast_tbl_t * p_tbl,
+ IN uint16_t mlid_ho, IN uint8_t port_num)
+{
+ unsigned mlid_offset, mask_offset, bit_mask;
+
+ CL_ASSERT(p_tbl);
+
+ if (p_tbl->p_mask_tbl) {
+ CL_ASSERT(port_num <=
+ (p_tbl->max_position + 1) * IB_MCAST_MASK_SIZE);
+ CL_ASSERT(mlid_ho >= IB_LID_MCAST_START_HO);
+ CL_ASSERT(mlid_ho <= p_tbl->max_mlid_ho);
+
+ mlid_offset = mlid_ho - IB_LID_MCAST_START_HO;
+ mask_offset = port_num / IB_MCAST_MASK_SIZE;
+ bit_mask = cl_ntoh16((uint16_t)
+ (1 << (port_num % IB_MCAST_MASK_SIZE)));
+ return (((*p_tbl->
+ p_mask_tbl)[mlid_offset][mask_offset] & bit_mask) ==
+ bit_mask);
+ }
+
+ return FALSE;
+}
+
+boolean_t osm_mcast_tbl_is_any_port(IN const osm_mcast_tbl_t * p_tbl,
+ IN uint16_t mlid_ho)
+{
+ unsigned mlid_offset;
+ uint8_t position;
+ uint16_t result = 0;
+
+ CL_ASSERT(p_tbl);
+
+ if (p_tbl->p_mask_tbl) {
+ CL_ASSERT(mlid_ho >= IB_LID_MCAST_START_HO);
+ CL_ASSERT(mlid_ho <= p_tbl->max_mlid_ho);
+
+ mlid_offset = mlid_ho - IB_LID_MCAST_START_HO;
+
+ for (position = 0; position <= p_tbl->max_position; position++)
+ result |= (*p_tbl->p_mask_tbl)[mlid_offset][position];
+ }
+
+ return (result != 0);
+}
+
+ib_api_status_t osm_mcast_tbl_set_block(IN osm_mcast_tbl_t * p_tbl,
+ IN const ib_net16_t * p_block,
+ IN int16_t block_num,
+ IN uint8_t position)
+{
+ uint32_t i;
+ uint16_t mlid_start_ho;
+
+ CL_ASSERT(p_tbl);
+ CL_ASSERT(p_block);
+
+ if (block_num > p_tbl->max_block)
+ return IB_INVALID_PARAMETER;
+
+ if (position > p_tbl->max_position)
+ return IB_INVALID_PARAMETER;
+
+ mlid_start_ho = (uint16_t) (block_num * IB_MCAST_BLOCK_SIZE);
+
+ if (mlid_start_ho + IB_MCAST_BLOCK_SIZE - 1 > p_tbl->mft_depth)
+ return IB_INVALID_PARAMETER;
+
+ for (i = 0; i < IB_MCAST_BLOCK_SIZE; i++)
+ (*p_tbl->p_mask_tbl)[mlid_start_ho + i][position] = p_block[i];
+
+ if (block_num > p_tbl->max_block_in_use)
+ p_tbl->max_block_in_use = (uint16_t) block_num;
+
+ return IB_SUCCESS;
+}
+
+void osm_mcast_tbl_clear_mlid(IN osm_mcast_tbl_t * p_tbl, IN uint16_t mlid_ho)
+{
+ unsigned mlid_offset;
+
+ CL_ASSERT(p_tbl);
+ CL_ASSERT(mlid_ho >= IB_LID_MCAST_START_HO);
+
+ mlid_offset = mlid_ho - IB_LID_MCAST_START_HO;
+ if (p_tbl->p_mask_tbl && mlid_offset < p_tbl->mft_depth)
+ memset((uint8_t *)p_tbl->p_mask_tbl + mlid_offset * (IB_MCAST_POSITION_MAX + 1) * IB_MCAST_MASK_SIZE / 8,
+ 0,
+ (IB_MCAST_POSITION_MAX + 1) * IB_MCAST_MASK_SIZE / 8);
+}
+
+boolean_t osm_mcast_tbl_get_block(IN osm_mcast_tbl_t * p_tbl,
+ IN int16_t block_num, IN uint8_t position,
+ OUT ib_net16_t * p_block)
+{
+ uint32_t i;
+ uint16_t mlid_start_ho;
+
+ CL_ASSERT(p_tbl);
+ CL_ASSERT(p_block);
+
+ if (block_num > p_tbl->max_block_in_use)
+ return FALSE;
+
+ if (position > p_tbl->max_position) {
+ /*
+ Caller shouldn't do this for efficiency's sake...
+ */
+ memset(p_block, 0, IB_SMP_DATA_SIZE);
+ return TRUE;
+ }
+
+ CL_ASSERT(block_num * IB_MCAST_BLOCK_SIZE <= p_tbl->mft_depth);
+
+ mlid_start_ho = (uint16_t) (block_num * IB_MCAST_BLOCK_SIZE);
+
+ for (i = 0; i < IB_MCAST_BLOCK_SIZE; i++)
+ p_block[i] = (*p_tbl->p_mask_tbl)[mlid_start_ho + i][position];
+
+ return TRUE;
+}
diff --git a/contrib/ofed/opensm/opensm/osm_mcm_port.c b/contrib/ofed/opensm/opensm/osm_mcm_port.c
new file mode 100644
index 0000000..65cef0b
--- /dev/null
+++ b/contrib/ofed/opensm/opensm/osm_mcm_port.c
@@ -0,0 +1,98 @@
+/*
+ * Copyright (c) 2004-2009 Voltaire, Inc. All rights reserved.
+ * Copyright (c) 2002-2012 Mellanox Technologies LTD. All rights reserved.
+ * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+/*
+ * Abstract:
+ * Implementation of osm_mcm_port_t.
+ * This object represents the membership of a port in a multicast group.
+ * This object is part of the OpenSM family of objects.
+ */
+
+#if HAVE_CONFIG_H
+# include <config.h>
+#endif /* HAVE_CONFIG_H */
+
+#include <stdlib.h>
+#include <string.h>
+#include <opensm/osm_file_ids.h>
+#define FILE_ID OSM_FILE_MCM_PORT_C
+#include <opensm/osm_mcm_port.h>
+#include <opensm/osm_multicast.h>
+
+osm_mcm_port_t *osm_mcm_port_new(IN osm_port_t *port, IN osm_mgrp_t *mgrp)
+{
+ osm_mcm_port_t *p_mcm;
+
+ p_mcm = malloc(sizeof(*p_mcm));
+ if (p_mcm) {
+ memset(p_mcm, 0, sizeof(*p_mcm));
+ p_mcm->port = port;
+ p_mcm->mgrp = mgrp;
+ }
+
+ return p_mcm;
+}
+
+void osm_mcm_port_delete(IN osm_mcm_port_t * p_mcm)
+{
+ CL_ASSERT(p_mcm);
+
+ free(p_mcm);
+}
+
+osm_mcm_alias_guid_t *osm_mcm_alias_guid_new(IN osm_mcm_port_t *p_base_mcm_port,
+ IN ib_member_rec_t *mcmr,
+ IN boolean_t proxy)
+{
+ osm_mcm_alias_guid_t *p_mcm_alias_guid;
+
+ p_mcm_alias_guid = calloc(1, sizeof(*p_mcm_alias_guid));
+ if (p_mcm_alias_guid) {
+ p_mcm_alias_guid->alias_guid = mcmr->port_gid.unicast.interface_id;
+ p_mcm_alias_guid->p_base_mcm_port = p_base_mcm_port;
+ p_mcm_alias_guid->port_gid.unicast.prefix = mcmr->port_gid.unicast.prefix;
+ p_mcm_alias_guid->port_gid.unicast.interface_id = mcmr->port_gid.unicast.interface_id;
+ p_mcm_alias_guid->scope_state = mcmr->scope_state;
+ p_mcm_alias_guid->proxy_join = proxy;
+ }
+
+ return p_mcm_alias_guid;
+}
+
+void osm_mcm_alias_guid_delete(IN OUT osm_mcm_alias_guid_t ** pp_mcm_alias_guid)
+{
+ free(*pp_mcm_alias_guid);
+ *pp_mcm_alias_guid = NULL;
+}
diff --git a/contrib/ofed/opensm/opensm/osm_mesh.c b/contrib/ofed/opensm/opensm/osm_mesh.c
new file mode 100644
index 0000000..8f84e53
--- /dev/null
+++ b/contrib/ofed/opensm/opensm/osm_mesh.c
@@ -0,0 +1,1736 @@
+/*
+ * Copyright (c) 2008-2009 Voltaire, Inc. All rights reserved.
+ * Copyright (c) 2008,2009 System Fabric Works, Inc. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+/*
+ * Abstract:
+ * routines to analyze certain meshes
+ */
+
+#if HAVE_CONFIG_H
+# include <config.h>
+#endif /* HAVE_CONFIG_H */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <opensm/osm_file_ids.h>
+#define FILE_ID OSM_FILE_MESH_C
+#include <opensm/osm_switch.h>
+#include <opensm/osm_opensm.h>
+#include <opensm/osm_log.h>
+#include <opensm/osm_mesh.h>
+#include <opensm/osm_ucast_lash.h>
+
+#define MAX_DEGREE (8)
+#define MAX_DIMENSION (8)
+#define LARGE (0x7fffffff)
+
+/*
+ * characteristic polynomials for selected 1d through 8d tori
+ */
+static const struct mesh_info {
+ int dimension; /* dimension of the torus */
+ int size[MAX_DIMENSION]; /* size of the torus */
+ unsigned int degree; /* degree of polynomial */
+ int poly[MAX_DEGREE+1]; /* polynomial */
+} mesh_info[] = {
+ {0, {0}, 0, {0}, },
+
+ {1, {2}, 1, {0, -1}, },
+ {1, {3}, 2, {-1, 0, 1}, },
+ {1, {5}, 2, {-9, 0, 1}, },
+ {1, {6}, 2, {-36, 0, 1}, },
+
+ {2, {2, 2}, 2, {-4, 0, 1}, },
+ {2, {3, 2}, 3, {8, 9, 0, -1}, },
+ {2, {5, 2}, 3, {24, 17, 0, -1}, },
+ {2, {6, 2}, 3, {32, 24, 0, -1}, },
+ {2, {3, 3}, 4, {-15, -32, -18, 0, 1}, },
+ {2, {5, 3}, 4, {-39, -64, -26, 0, 1}, },
+ {2, {6, 3}, 4, {-48, -80, -33, 0, 1}, },
+ {2, {5, 5}, 4, {-63, -96, -34, 0, 1}, },
+ {2, {6, 5}, 4, {-48, -112, -41, 0, 1}, },
+ {2, {6, 6}, 4, {0, -128, -48, 0, 1}, },
+
+ {3, {2, 2, 2}, 3, {16, 12, 0, -1}, },
+ {3, {3, 2, 2}, 4, {-28, -48, -21, 0, 1}, },
+ {3, {5, 2, 2}, 4, {-60, -80, -29, 0, 1}, },
+ {3, {6, 2, 2}, 4, {-64, -96, -36, 0, 1}, },
+ {3, {3, 3, 2}, 5, {48, 127, 112, 34, 0, -1}, },
+ {3, {5, 3, 2}, 5, {96, 215, 160, 42, 0, -1}, },
+ {3, {6, 3, 2}, 5, {96, 232, 184, 49, 0, -1}, },
+ {3, {5, 5, 2}, 5, {144, 303, 208, 50, 0, -1}, },
+ {3, {6, 5, 2}, 5, {96, 296, 232, 57, 0, -1}, },
+ {3, {6, 6, 2}, 5, {0, 256, 256, 64, 0, -1}, },
+ {3, {3, 3, 3}, 6, {-81, -288, -381, -224, -51, 0, 1}, },
+ {3, {5, 3, 3}, 6, {-153, -480, -557, -288, -59, 0, 1}, },
+ {3, {6, 3, 3}, 6, {-144, -480, -591, -320, -66, 0, 1}, },
+ {3, {5, 5, 3}, 6, {-225, -672, -733, -352, -67, 0, 1}, },
+ {3, {6, 5, 3}, 6, {-144, -576, -743, -384, -74, 0, 1}, },
+ {3, {6, 6, 3}, 6, {0, -384, -720, -416, -81, 0, 1}, },
+ {3, {5, 5, 5}, 6, {-297, -864, -909, -416, -75, 0, 1}, },
+ {3, {6, 5, 5}, 6, {-144, -672, -895, -448, -82, 0, 1}, },
+ {3, {6, 6, 5}, 6, {0, -384, -848, -480, -89, 0, 1}, },
+ {3, {6, 6, 6}, 6, {0, 0, -768, -512, -96, 0, 1}, },
+
+ {4, {2, 2, 2, 2}, 4, {-48, -64, -24, 0, 1}, },
+ {4, {3, 2, 2, 2}, 5, {80, 180, 136, 37, 0, -1}, },
+ {4, {5, 2, 2, 2}, 5, {144, 276, 184, 45, 0, -1}, },
+ {4, {6, 2, 2, 2}, 5, {128, 288, 208, 52, 0, -1}, },
+ {4, {3, 3, 2, 2}, 6, {-132, -416, -487, -256, -54, 0, 1}, },
+ {4, {5, 3, 2, 2}, 6, {-228, -640, -671, -320, -62, 0, 1}, },
+ {4, {6, 3, 2, 2}, 6, {-192, -608, -700, -352, -69, 0, 1}, },
+ {4, {5, 5, 2, 2}, 6, {-324, -864, -855, -384, -70, 0, 1}, },
+ {4, {6, 5, 2, 2}, 6, {-192, -736, -860, -416, -77, 0, 1}, },
+ {4, {6, 6, 2, 2}, 6, {0, -512, -832, -448, -84, 0, 1}, },
+ {4, {3, 3, 3, 2}, 7, {216, 873, 1392, 1101, 440, 75, 0, -1}, },
+ {4, {5, 3, 3, 2}, 7, {360, 1329, 1936, 1405, 520, 83, 0, -1}, },
+ {4, {6, 3, 3, 2}, 7, {288, 1176, 1872, 1455, 560, 90, 0, -1}, },
+ {4, {5, 5, 3, 2}, 7, {504, 1785, 2480, 1709, 600, 91, 0, -1}, },
+ {4, {6, 5, 3, 2}, 7, {288, 1368, 2272, 1735, 640, 98, 0, -1}, },
+ {4, {6, 6, 3, 2}, 7, {0, 768, 1920, 1728, 680, 105, 0, -1}, },
+ {4, {5, 5, 5, 2}, 7, {648, 2241, 3024, 2013, 680, 99, 0, -1}, },
+ {4, {6, 5, 5, 2}, 7, {288, 1560, 2672, 2015, 720, 106, 0, -1}, },
+ {4, {6, 6, 5, 2}, 7, {0, 768, 2176, 1984, 760, 113, 0, -1}, },
+ {4, {6, 6, 6, 2}, 7, {0, 0, 1536, 1920, 800, 120, 0, -1}, },
+ {4, {3, 3, 3, 3}, 8, {-351, -1728, -3492, -3712, -2202, -704, -100, 0, 1}, },
+ {4, {5, 3, 3, 3}, 8, {-567, -2592, -4860, -4800, -2658, -800, -108, 0, 1}, },
+ {4, {6, 3, 3, 3}, 8, {-432, -2160, -4401, -4672, -2733, -848, -115, 0, 1}, },
+ {4, {5, 5, 3, 3}, 8, {-783, -3456, -6228, -5888, -3114, -896, -116, 0, 1}, },
+ {4, {6, 5, 3, 3}, 8, {-432, -2448, -5241, -5568, -3165, -944, -123, 0, 1}, },
+ {4, {6, 6, 3, 3}, 8, {0, -1152, -3888, -5056, -3183, -992, -130, 0, 1}, },
+ {4, {5, 5, 5, 3}, 8, {-999, -4320, -7596, -6976, -3570, -992, -124, 0, 1}, },
+ {4, {6, 5, 5, 3}, 8, {-432, -2736, -6081, -6464, -3597, -1040, -131, 0, 1}, },
+ {4, {6, 6, 5, 3}, 8, {0, -1152, -4272, -5760, -3591, -1088, -138, 0, 1}, },
+ {4, {6, 6, 6, 3}, 8, {0, 0, -2304, -4864, -3552, -1136, -145, 0, 1}, },
+
+ {5, {2, 2, 2, 2, 2}, 5, {128, 240, 160, 40, 0, -1}, },
+ {5, {3, 2, 2, 2, 2}, 6, {-208, -576, -600, -288, -57, 0, 1}, },
+ {5, {5, 2, 2, 2, 2}, 6, {-336, -832, -792, -352, -65, 0, 1}, },
+ {5, {6, 2, 2, 2, 2}, 6, {-256, -768, -816, -384, -72, 0, 1}, },
+ {5, {3, 3, 2, 2, 2}, 7, {336, 1228, 1776, 1287, 480, 78, 0, -1}, },
+ {5, {5, 3, 2, 2, 2}, 7, {528, 1772, 2368, 1599, 560, 86, 0, -1}, },
+ {5, {6, 3, 2, 2, 2}, 7, {384, 1504, 2256, 1644, 600, 93, 0, -1}, },
+ {5, {5, 5, 2, 2, 2}, 7, {720, 2316, 2960, 1911, 640, 94, 0, -1}, },
+ {5, {6, 5, 2, 2, 2}, 7, {384, 1760, 2704, 1932, 680, 101, 0, -1}, },
+ {5, {6, 6, 2, 2, 2}, 7, {0, 1024, 2304, 1920, 720, 108, 0, -1}, },
+ {5, {3, 3, 3, 2, 2}, 8, {-540, -2448, -4557, -4480, -2481, -752, -103, 0, 1}, },
+ {5, {5, 3, 3, 2, 2}, 8, {-828, -3504, -6101, -5632, -2945, -848, -111, 0, 1}, },
+ {5, {6, 3, 3, 2, 2}, 8, {-576, -2784, -5412, -5440, -3015, -896, -118, 0, 1}, },
+ {5, {5, 5, 3, 2, 2}, 8, {-1116, -4560, -7645, -6784, -3409, -944, -119, 0, 1}, },
+ {5, {6, 5, 3, 2, 2}, 8, {-576, -3168, -6404, -6400, -3455, -992, -126, 0, 1}, },
+ {5, {6, 6, 3, 2, 2}, 8, {0, -1536, -4800, -5824, -3468, -1040, -133, 0, 1}, },
+ {5, {5, 5, 5, 2, 2}, 8, {-1404, -5616, -9189, -7936, -3873, -1040, -127, 0, 1}, },
+ {5, {6, 5, 5, 2, 2}, 8, {-576, -3552, -7396, -7360, -3895, -1088, -134, 0, 1}, },
+ {5, {6, 6, 5, 2, 2}, 8, {0, -1536, -5312, -6592, -3884, -1136, -141, 0, 1}, },
+ {5, {6, 6, 6, 2, 2}, 8, {0, 0, -3072, -5632, -3840, -1184, -148, 0, 1}, },
+
+ {6, {2, 2, 2, 2, 2, 2}, 6, {-320, -768, -720, -320, -60, 0, 1}, },
+ {6, {3, 2, 2, 2, 2, 2}, 7, {512, 1680, 2208, 1480, 520, 81, 0, -1}, },
+ {6, {5, 2, 2, 2, 2, 2}, 7, {768, 2320, 2848, 1800, 600, 89, 0, -1}, },
+ {6, {6, 2, 2, 2, 2, 2}, 7, {512, 1920, 2688, 1840, 640, 96, 0, -1}, },
+ {6, {3, 3, 2, 2, 2, 2}, 8, {-816, -3392, -5816, -5312, -2767, -800, -106, 0, 1}, },
+ {6, {5, 3, 2, 2, 2, 2}, 8, {-1200, -4672, -7544, -6528, -3239, -896, -114, 0, 1}, },
+ {6, {6, 3, 2, 2, 2, 2}, 8, {-768, -3584, -6608, -6272, -3304, -944, -121, 0, 1}, },
+ {6, {5, 5, 2, 2, 2, 2}, 8, {-1584, -5952, -9272, -7744, -3711, -992, -122, 0, 1}, },
+ {6, {6, 5, 2, 2, 2, 2}, 8, {-768, -4096, -7760, -7296, -3752, -1040, -129, 0, 1}, },
+ {6, {6, 6, 2, 2, 2, 2}, 8, {0, -2048, -5888, -6656, -3760, -1088, -136, 0, 1}, },
+
+ {7, {2, 2, 2, 2, 2, 2, 2}, 7, {768, 2240, 2688, 1680, 560, 84, 0, -1}, },
+ {7, {3, 2, 2, 2, 2, 2, 2}, 8, {-1216, -4608, -7280, -6208, -3060, -848, -109, 0, 1}, },
+ {7, {5, 2, 2, 2, 2, 2, 2}, 8, {-1728, -6144, -9200, -7488, -3540, -944, -117, 0, 1}, },
+ {7, {6, 2, 2, 2, 2, 2, 2}, 8, {-1024, -4608, -8000, -7168, -3600, -992, -124, 0, 1}, },
+
+ {8, {2, 2, 2, 2, 2, 2, 2, 2}, 8, {-1792, -6144, -8960, -7168, -3360, -896, -112, 0, 1}, },
+
+ /*
+ * mesh errors
+ */
+ {2, {6, 6}, 4, {-192, -256, -80, 0, 1}, },
+
+ {-1, {0,}, 0, {0, }, },
+};
+
+/*
+ * per fabric mesh info
+ */
+typedef struct _mesh {
+ int num_class; /* number of switch classes */
+ int *class_type; /* index of first switch found for each class */
+ int *class_count; /* population of each class */
+ int dimension; /* mesh dimension */
+ int *size; /* an array to hold size of mesh */
+ int dim_order[MAX_DIMENSION];
+} mesh_t;
+
+typedef struct sort_ctx {
+ lash_t *p_lash;
+ mesh_t *mesh;
+} sort_ctx_t;
+
+typedef struct comp {
+ int index;
+ sort_ctx_t ctx;
+} comp_t;
+
+/*
+ * poly_alloc
+ *
+ * allocate a polynomial of degree n
+ */
+static int *poly_alloc(lash_t *p_lash, int n)
+{
+ osm_log_t *p_log = &p_lash->p_osm->log;
+ int *p;
+
+ if (!(p = calloc(n+1, sizeof(int))))
+ OSM_LOG(p_log, OSM_LOG_ERROR,
+ "Failed allocating poly - out of memory\n");
+
+ return p;
+}
+
+/*
+ * print a polynomial
+ */
+static char *poly_print(int n, int *coeff)
+{
+ static char str[(MAX_DEGREE+1)*20];
+ char *p = str;
+ int i;
+ int first = 1;
+ int t;
+ int sign;
+
+ str[0] = 0;
+
+ for (i = 0; i <= n; i++) {
+ if (!coeff[i])
+ continue;
+
+ if (coeff[i] < 0) {
+ sign = 1;
+ t = -coeff[i];
+ } else {
+ sign = 0;
+ t = coeff[i];
+ }
+
+ p += sprintf(p, "%s", sign? "-" : (first? "" : "+"));
+ first = 0;
+
+ if (t != 1 || i == 0)
+ p += sprintf(p, "%d", t);
+
+ if (i)
+ p += sprintf(p, "x");
+ if (i > 1)
+ p += sprintf(p, "^%d", i);
+ }
+
+ return str;
+}
+
+/*
+ * poly_diff
+ *
+ * return a nonzero value if polynomials differ else 0
+ */
+static int poly_diff(unsigned int n, const int *p, switch_t *s)
+{
+ if (s->node->num_links != n)
+ return 1;
+
+ return memcmp(p, s->node->poly, n*sizeof(int));
+}
+
+/*
+ * m_free
+ *
+ * free a square matrix of rank l
+ */
+static void m_free(int **m, int l)
+{
+ int i;
+
+ if (m) {
+ for (i = 0; i < l; i++) {
+ if (m[i])
+ free(m[i]);
+ }
+ free(m);
+ }
+}
+
+/*
+ * m_alloc
+ *
+ * allocate a square matrix of rank l
+ */
+static int **m_alloc(lash_t *p_lash, int l)
+{
+ osm_log_t *p_log = &p_lash->p_osm->log;
+ int i;
+ int **m = NULL;
+
+ do {
+ if (!(m = calloc(l, sizeof(int *))))
+ break;
+
+ for (i = 0; i < l; i++) {
+ if (!(m[i] = calloc(l, sizeof(int))))
+ break;
+ }
+ if (i != l)
+ break;
+
+ return m;
+ } while (0);
+
+ OSM_LOG(p_log, OSM_LOG_ERROR,
+ "Failed allocating matrix - out of memory\n");
+
+ m_free(m, l);
+ return NULL;
+}
+
+/*
+ * pm_free
+ *
+ * free a square matrix of rank l of polynomials
+ */
+static void pm_free(int ***m, int l)
+{
+ int i, j;
+
+ if (m) {
+ for (i = 0; i < l; i++) {
+ if (m[i]) {
+ for (j = 0; j < l; j++) {
+ if (m[i][j])
+ free(m[i][j]);
+ }
+ free(m[i]);
+ }
+ }
+ free(m);
+ }
+}
+
+/*
+ * pm_alloc
+ *
+ * allocate a square matrix of rank l of polynomials of degree n
+ */
+static int ***pm_alloc(lash_t *p_lash, int l, int n)
+{
+ osm_log_t *p_log = &p_lash->p_osm->log;
+ int i, j;
+ int ***m = NULL;
+
+ do {
+ if (!(m = calloc(l, sizeof(int **))))
+ break;
+
+ for (i = 0; i < l; i++) {
+ if (!(m[i] = calloc(l, sizeof(int *))))
+ break;
+
+ for (j = 0; j < l; j++) {
+ if (!(m[i][j] = calloc(n+1, sizeof(int))))
+ break;
+ }
+ if (j != l)
+ break;
+ }
+ if (i != l)
+ break;
+
+ return m;
+ } while (0);
+
+ OSM_LOG(p_log, OSM_LOG_ERROR,
+ "Failed allocating matrix - out of memory\n");
+
+ pm_free(m, l);
+ return NULL;
+}
+
+static int determinant(lash_t *p_lash, int n, int rank, int ***m, int *p);
+
+/*
+ * sub_determinant
+ *
+ * compute the determinant of a submatrix of matrix of rank l of polynomials of degree n
+ * with row and col removed in poly. caller must free poly
+ */
+static int sub_determinant(lash_t *p_lash, int n, int l, int row, int col,
+ int ***matrix, int **poly)
+{
+ int ret = -1;
+ int ***m = NULL;
+ int *p = NULL;
+ int i, j, k, x, y;
+ int rank = l - 1;
+
+ do {
+ if (!(p = poly_alloc(p_lash, n))) {
+ break;
+ }
+
+ if (rank <= 0) {
+ p[0] = 1;
+ ret = 0;
+ break;
+ }
+
+ if (!(m = pm_alloc(p_lash, rank, n))) {
+ free(p);
+ p = NULL;
+ break;
+ }
+
+ x = 0;
+ for (i = 0; i < l; i++) {
+ if (i == row)
+ continue;
+
+ y = 0;
+ for (j = 0; j < l; j++) {
+ if (j == col)
+ continue;
+
+ for (k = 0; k <= n; k++)
+ m[x][y][k] = matrix[i][j][k];
+
+ y++;
+ }
+ x++;
+ }
+
+ if (determinant(p_lash, n, rank, m, p)) {
+ free(p);
+ p = NULL;
+ break;
+ }
+
+ ret = 0;
+ } while (0);
+
+ pm_free(m, rank);
+ *poly = p;
+ return ret;
+}
+
+/*
+ * determinant
+ *
+ * compute the determinant of matrix m of rank of polynomials of degree deg
+ * and add the result to polynomial p allocated by caller
+ */
+static int determinant(lash_t *p_lash, int deg, int rank, int ***m, int *p)
+{
+ int i, j, k;
+ int *q;
+ int sign = 1;
+
+ /*
+ * handle simple case of 1x1 matrix
+ */
+ if (rank == 1) {
+ for (i = 0; i <= deg; i++)
+ p[i] += m[0][0][i];
+ }
+
+ /*
+ * handle simple case of 2x2 matrix
+ */
+ else if (rank == 2) {
+ for (i = 0; i <= deg; i++) {
+ if (m[0][0][i] == 0)
+ continue;
+
+ for (j = 0; j <= deg; j++) {
+ if (m[1][1][j] == 0)
+ continue;
+
+ p[i+j] += m[0][0][i]*m[1][1][j];
+ }
+ }
+
+ for (i = 0; i <= deg; i++) {
+ if (m[0][1][i] == 0)
+ continue;
+
+ for (j = 0; j <= deg; j++) {
+ if (m[1][0][j] == 0)
+ continue;
+
+ p[i+j] -= m[0][1][i]*m[1][0][j];
+ }
+ }
+ }
+
+ /*
+ * handle the general case
+ */
+ else {
+ for (i = 0; i < rank; i++) {
+ if (sub_determinant(p_lash, deg, rank, 0, i, m, &q))
+ return -1;
+
+ for (j = 0; j <= deg; j++) {
+ if (m[0][i][j] == 0)
+ continue;
+
+ for (k = 0; k <= deg; k++) {
+ if (q[k] == 0)
+ continue;
+
+ p[j+k] += sign*m[0][i][j]*q[k];
+ }
+ }
+
+ free(q);
+ sign = -sign;
+ }
+ }
+
+ return 0;
+}
+
+/*
+ * char_poly
+ *
+ * compute the characteristic polynomial of matrix of rank
+ * by computing the determinant of m-x*I and return in poly
+ * as an array. caller must free poly
+ */
+static int char_poly(lash_t *p_lash, int rank, int **matrix, int **poly)
+{
+ osm_log_t *p_log = &p_lash->p_osm->log;
+ int ret = -1;
+ int i, j;
+ int ***m = NULL;
+ int *p = NULL;
+ int deg = rank;
+
+ OSM_LOG_ENTER(p_log);
+
+ do {
+ if (!matrix)
+ break;
+
+ if (!(p = poly_alloc(p_lash, deg)))
+ break;
+
+ if (!(m = pm_alloc(p_lash, rank, deg))) {
+ free(p);
+ p = NULL;
+ break;
+ }
+
+ for (i = 0; i < rank; i++) {
+ for (j = 0; j < rank; j++) {
+ m[i][j][0] = matrix[i][j];
+ }
+ m[i][i][1] = -1;
+ }
+
+ if (determinant(p_lash, deg, rank, m, p)) {
+ free(p);
+ p = NULL;
+ break;
+ }
+
+ ret = 0;
+ } while (0);
+
+ pm_free(m, rank);
+ *poly = p;
+
+ OSM_LOG_EXIT(p_log);
+ return ret;
+}
+
+/*
+ * get_switch_metric
+ *
+ * compute the matrix of minimum distances between each of
+ * the adjacent switch nodes to sw along paths
+ * that do not go through sw. do calculation by
+ * relaxation method
+ * allocate space for the matrix and save in node_t structure
+ */
+static int get_switch_metric(lash_t *p_lash, int sw)
+{
+ osm_log_t *p_log = &p_lash->p_osm->log;
+ int ret = -1;
+ unsigned int i, j, change;
+ int sw1, sw2, sw3;
+ switch_t *s = p_lash->switches[sw];
+ switch_t *s1, *s2, *s3;
+ int **m;
+ mesh_node_t *node = s->node;
+ unsigned int num_links = node->num_links;
+
+ OSM_LOG_ENTER(p_log);
+
+ do {
+ if (!(m = m_alloc(p_lash, num_links)))
+ break;
+
+ for (i = 0; i < num_links; i++) {
+ sw1 = node->links[i]->switch_id;
+ s1 = p_lash->switches[sw1];
+
+ /* make all distances big except s1 to itself */
+ for (sw2 = 0; sw2 < p_lash->num_switches; sw2++)
+ p_lash->switches[sw2]->node->temp = LARGE;
+
+ s1->node->temp = 0;
+
+ do {
+ change = 0;
+
+ for (sw2 = 0; sw2 < p_lash->num_switches; sw2++) {
+ s2 = p_lash->switches[sw2];
+ if (s2->node->temp == LARGE)
+ continue;
+ for (j = 0; j < s2->node->num_links; j++) {
+ sw3 = s2->node->links[j]->switch_id;
+ s3 = p_lash->switches[sw3];
+
+ if (sw3 == sw)
+ continue;
+
+ if ((s2->node->temp + 1) < s3->node->temp) {
+ s3->node->temp = s2->node->temp + 1;
+ change++;
+ }
+ }
+ }
+ } while (change);
+
+ for (j = 0; j < num_links; j++) {
+ sw2 = node->links[j]->switch_id;
+ s2 = p_lash->switches[sw2];
+ m[i][j] = s2->node->temp;
+ }
+ }
+
+ if (char_poly(p_lash, num_links, m, &node->poly)) {
+ m_free(m, num_links);
+ m = NULL;
+ break;
+ }
+
+ ret = 0;
+ } while (0);
+
+ node->matrix = m;
+
+ OSM_LOG_EXIT(p_log);
+ return ret;
+}
+
+/*
+ * classify_switch
+ *
+ * add switch to histogram of switch types
+ * we keep a reference to the first switch
+ * found of each type as an exemplar
+ */
+static void classify_switch(lash_t *p_lash, mesh_t *mesh, int sw)
+{
+ osm_log_t *p_log = &p_lash->p_osm->log;
+ int i;
+ switch_t *s = p_lash->switches[sw];
+ switch_t *s1;
+
+ OSM_LOG_ENTER(p_log);
+
+ if (!s->node->poly)
+ goto done;
+
+ for (i = 0; i < mesh->num_class; i++) {
+ s1 = p_lash->switches[mesh->class_type[i]];
+
+ if (poly_diff(s->node->num_links, s->node->poly, s1))
+ continue;
+
+ mesh->class_count[i]++;
+ goto done;
+ }
+
+ mesh->class_type[mesh->num_class] = sw;
+ mesh->class_count[mesh->num_class] = 1;
+ mesh->num_class++;
+
+done:
+ OSM_LOG_EXIT(p_log);
+}
+
+/*
+ * classify_mesh_type
+ *
+ * try to look up node polynomial in table
+ */
+static void classify_mesh_type(lash_t *p_lash, int sw)
+{
+ osm_log_t *p_log = &p_lash->p_osm->log;
+ int i;
+ switch_t *s = p_lash->switches[sw];
+ const struct mesh_info *t;
+
+ OSM_LOG_ENTER(p_log);
+
+ if (!s->node->poly)
+ goto done;
+
+ for (i = 1; (t = &mesh_info[i])->dimension != -1; i++) {
+ if (poly_diff(t->degree, t->poly, s))
+ continue;
+
+ s->node->type = i;
+ s->node->dimension = t->dimension;
+ OSM_LOG_EXIT(p_log);
+ return;
+ }
+
+done:
+ s->node->type = 0;
+ OSM_LOG_EXIT(p_log);
+ return;
+}
+
+/*
+ * remove_edges
+ *
+ * remove type from nodes that have fewer links
+ * than adjacent nodes
+ */
+static void remove_edges(lash_t *p_lash)
+{
+ osm_log_t *p_log = &p_lash->p_osm->log;
+ int sw;
+ mesh_node_t *n, *nn;
+ unsigned i;
+
+ OSM_LOG_ENTER(p_log);
+
+ for (sw = 0; sw < p_lash->num_switches; sw++) {
+ n = p_lash->switches[sw]->node;
+ if (!n->type)
+ continue;
+
+ for (i = 0; i < n->num_links; i++) {
+ nn = p_lash->switches[n->links[i]->switch_id]->node;
+
+ if (nn->num_links > n->num_links) {
+ OSM_LOG(p_log, OSM_LOG_DEBUG,
+ "removed edge switch %s\n",
+ p_lash->switches[sw]->p_sw->p_node->print_desc);
+ n->type = -1;
+ break;
+ }
+ }
+ }
+
+ OSM_LOG_EXIT(p_log);
+}
+
+/*
+ * get_local_geometry
+ *
+ * analyze the local geometry around each switch
+ */
+static int get_local_geometry(lash_t *p_lash, mesh_t *mesh)
+{
+ osm_log_t *p_log = &p_lash->p_osm->log;
+ int sw;
+ int status = 0;
+
+ OSM_LOG_ENTER(p_log);
+
+ for (sw = 0; sw < p_lash->num_switches; sw++) {
+ /*
+ * skip switches with more links than MAX_DEGREE
+ * since they will never match a known case
+ */
+ if (p_lash->switches[sw]->node->num_links > MAX_DEGREE)
+ continue;
+
+ if (get_switch_metric(p_lash, sw)) {
+ status = -1;
+ goto Exit;
+ }
+ classify_mesh_type(p_lash, sw);
+ }
+
+ remove_edges(p_lash);
+
+ for (sw = 0; sw < p_lash->num_switches; sw++) {
+ if (p_lash->switches[sw]->node->type < 0)
+ continue;
+ classify_switch(p_lash, mesh, sw);
+ }
+
+Exit:
+ OSM_LOG_EXIT(p_log);
+ return status;
+}
+
+static void print_axis(lash_t *p_lash, char *p, int sw, int port)
+{
+ mesh_node_t *node = p_lash->switches[sw]->node;
+ char *name = p_lash->switches[sw]->p_sw->p_node->print_desc;
+ int c = node->axes[port];
+
+ p += sprintf(p, "%s[%d] = ", name, port);
+ if (c)
+ p += sprintf(p, "%s%c -> ", ((c - 1) & 1) ? "-" : "+", 'X' + (c - 1)/2);
+ else
+ p += sprintf(p, "N/A -> ");
+ p += sprintf(p, "%s\n",
+ p_lash->switches[node->links[port]->switch_id]->p_sw->p_node->print_desc);
+}
+
+/*
+ * seed_axes
+ *
+ * assign axes to the links of the seed switch
+ * assumes switch is of type cartesian mesh
+ * axes are numbered 1 to n i.e. +x => 1 -x => 2 etc.
+ * this assumes that if all distances are 2 that
+ * an axis has only 2 nodes so +A and -A collapse to +A
+ */
+static void seed_axes(lash_t *p_lash, int sw)
+{
+ osm_log_t *p_log = &p_lash->p_osm->log;
+ mesh_node_t *node = p_lash->switches[sw]->node;
+ int n = node->num_links;
+ int i, j, c;
+
+ OSM_LOG_ENTER(p_log);
+
+ if (!node->matrix || !node->dimension)
+ goto done;
+
+ for (c = 1; c <= 2*node->dimension; c++) {
+ /*
+ * find the next unassigned axis
+ */
+ for (i = 0; i < n; i++) {
+ if (!node->axes[i])
+ break;
+ }
+
+ node->axes[i] = c++;
+
+ /*
+ * find the matching opposite direction
+ */
+ for (j = 0; j < n; j++) {
+ if (node->axes[j] || j == i)
+ continue;
+
+ if (node->matrix[i][j] != 2)
+ break;
+ }
+
+ if (j != n) {
+ node->axes[j] = c;
+ }
+ }
+
+ if (OSM_LOG_IS_ACTIVE_V2(p_log, OSM_LOG_DEBUG)) {
+ char buf[256], *p;
+
+ for (i = 0; i < n; i++) {
+ p = buf;
+ print_axis(p_lash, p, sw, i);
+ OSM_LOG(p_log, OSM_LOG_DEBUG, "%s", buf);
+ }
+ }
+
+done:
+ OSM_LOG_EXIT(p_log);
+}
+
+/*
+ * opposite
+ *
+ * compute the opposite of axis for switch
+ */
+static inline int opposite(switch_t *s, int axis)
+{
+ unsigned i, j;
+ int negaxis = 1 + (1 ^ (axis - 1));
+
+ if (!s->node->matrix)
+ return 0;
+
+ for (i = 0; i < s->node->num_links; i++) {
+ if (s->node->axes[i] == axis) {
+ for (j = 0; j < s->node->num_links; j++) {
+ if (j == i)
+ continue;
+ if (s->node->matrix[i][j] != 2)
+ return negaxis;
+ }
+
+ return axis;
+ }
+ }
+
+ return 0;
+}
+
+/*
+ * make_geometry
+ *
+ * induce a geometry on the switches
+ */
+static void make_geometry(lash_t *p_lash, int sw)
+{
+ osm_log_t *p_log = &p_lash->p_osm->log;
+ int num_switches = p_lash->num_switches;
+ int sw1, sw2;
+ switch_t *s, *s1, *s2, *seed;
+ unsigned int i, j, k, l, n, m;
+ unsigned int change;
+
+ OSM_LOG_ENTER(p_log);
+
+ s = p_lash->switches[sw];
+
+ if (!s->node->matrix)
+ goto done;
+
+ /*
+ * assign axes to seed switch
+ */
+ seed_axes(p_lash, sw);
+ seed = p_lash->switches[sw];
+
+ /*
+ * induce axes in other switches until
+ * there is no more change
+ */
+ do {
+ change = 0;
+
+ /* phase 1 opposites */
+ for (sw1 = 0; sw1 < num_switches; sw1++) {
+ s1 = p_lash->switches[sw1];
+ n = s1->node->num_links;
+
+ /*
+ * ignore chain fragments
+ */
+ if (n < seed->node->num_links && n <= 2)
+ continue;
+
+ /*
+ * only process 'mesh' switches
+ */
+ if (!s1->node->matrix)
+ continue;
+
+ for (i = 0; i < n; i++) {
+ if (!s1->node->axes[i])
+ continue;
+
+ /*
+ * can't tell across if more than one
+ * likely looking link
+ */
+ m = 0;
+ for (j = 0; j < n; j++) {
+ if (j == i)
+ continue;
+
+ if (s1->node->matrix[i][j] != 2)
+ m++;
+ }
+
+ if (m != 1) {
+ continue;
+ }
+
+ for (j = 0; j < n; j++) {
+ if (j == i)
+ continue;
+
+ /* Rule out opposite nodes when distance greater than 4 */
+ if (s1->node->matrix[i][j] != 2 &&
+ s1->node->matrix[i][j] <= 4) {
+ if (s1->node->axes[j]) {
+ if (s1->node->axes[j] != opposite(seed, s1->node->axes[i])) {
+ OSM_LOG(p_log, OSM_LOG_DEBUG,
+ "phase 1 mismatch\n");
+ }
+ } else {
+ s1->node->axes[j] = opposite(seed, s1->node->axes[i]);
+ change++;
+ }
+ }
+ }
+ }
+ }
+
+ /* phase 2 switch to switch */
+ for (sw1 = 0; sw1 < num_switches; sw1++) {
+ s1 = p_lash->switches[sw1];
+ n = s1->node->num_links;
+
+ if (!s1->node->matrix)
+ continue;
+
+ for (i = 0; i < n; i++) {
+ int l2 = s1->node->links[i]->link_id;
+
+ if (!s1->node->axes[i])
+ continue;
+
+ if (l2 == -1) {
+ OSM_LOG(p_log, OSM_LOG_DEBUG,
+ "no reverse link\n");
+ continue;
+ }
+
+ sw2 = s1->node->links[i]->switch_id;
+ s2 = p_lash->switches[sw2];
+
+ if (!s2->node->matrix)
+ continue;
+
+ if (!s2->node->axes[l2]) {
+ /*
+ * set axis to opposite of s1->axes[i]
+ */
+ s2->node->axes[l2] = opposite(seed, s1->node->axes[i]);
+ change++;
+ } else {
+ if (s2->node->axes[l2] != opposite(seed, s1->node->axes[i])) {
+ OSM_LOG(p_log, OSM_LOG_DEBUG,
+ "phase 2 mismatch\n");
+ }
+ }
+ }
+ }
+
+ /* Phase 3 corners */
+ for (sw1 = 0; sw1 < num_switches; sw1++) {
+ s = p_lash->switches[sw1];
+ n = s->node->num_links;
+
+ if (!s->node->matrix)
+ continue;
+
+ for (i = 0; i < n; i++) {
+ if (!s->node->axes[i])
+ continue;
+
+ for (j = 0; j < n; j++) {
+ if (i == j || !s->node->axes[j] || s->node->matrix[i][j] != 2)
+ continue;
+
+ s1 = p_lash->switches[s->node->links[i]->switch_id];
+ s2 = p_lash->switches[s->node->links[j]->switch_id];
+
+ /*
+ * find switch (other than s1) that neighbors i and j
+ * have in common
+ */
+ for (k = 0; k < s1->node->num_links; k++) {
+ if (s1->node->links[k]->switch_id == sw1)
+ continue;
+
+ for (l = 0; l < s2->node->num_links; l++) {
+ if (s2->node->links[l]->switch_id == sw1)
+ continue;
+
+ if (s1->node->links[k]->switch_id == s2->node->links[l]->switch_id) {
+ if (s1->node->axes[k]) {
+ if (s1->node->axes[k] != s->node->axes[j]) {
+ OSM_LOG(p_log, OSM_LOG_DEBUG, "phase 3 mismatch\n");
+ }
+ } else {
+ s1->node->axes[k] = s->node->axes[j];
+ change++;
+ }
+
+ if (s2->node->axes[l]) {
+ if (s2->node->axes[l] != s->node->axes[i]) {
+ OSM_LOG(p_log, OSM_LOG_DEBUG, "phase 3 mismatch\n");
+ }
+ } else {
+ s2->node->axes[l] = s->node->axes[i];
+ change++;
+ }
+ goto next_j;
+ }
+ }
+ }
+next_j:
+ ;
+ }
+ }
+ }
+ } while (change);
+
+done:
+ OSM_LOG_EXIT(p_log);
+}
+
+/*
+ * return |a| < |b|
+ */
+static inline int ltmag(int a, int b)
+{
+ int a1 = (a >= 0)? a : -a;
+ int b1 = (b >= 0)? b : -b;
+
+ return (a1 < b1) || (a1 == b1 && a > b);
+}
+
+/*
+ * reorder_node_links
+ *
+ * reorder the links out of a switch in sign/dimension order
+ */
+static int reorder_node_links(lash_t *p_lash, mesh_t *mesh, int sw)
+{
+ osm_log_t *p_log = &p_lash->p_osm->log;
+ switch_t *s = p_lash->switches[sw];
+ mesh_node_t *node = s->node;
+ int n = node->num_links;
+ link_t **links;
+ int *axes;
+ int i, j, k, l;
+ int c;
+ int next = 0;
+ int dimension = mesh->dimension;
+
+ if (!(links = calloc(n, sizeof(link_t *)))) {
+ OSM_LOG(p_log, OSM_LOG_ERROR,
+ "Failed allocating links array - out of memory\n");
+ return -1;
+ }
+
+ if (!(axes = calloc(n, sizeof(int)))) {
+ free(links);
+ OSM_LOG(p_log, OSM_LOG_ERROR,
+ "Failed allocating axes array - out of memory\n");
+ return -1;
+ }
+
+ /*
+ * find the links with axes
+ */
+ for (i = 0; i < dimension; i++) {
+ j = mesh->dim_order[i];
+ for (k = 1; k <= 2; k++) {
+ c = 2*j + k;
+
+ if (node->coord[j] > 0)
+ c = opposite(s, c);
+
+ for (l = 0; l < n; l++) {
+ if (!node->links[l])
+ continue;
+ if (node->axes[l] == c) {
+ links[next] = node->links[l];
+ axes[next] = node->axes[l];
+ node->links[l] = NULL;
+ next++;
+ }
+ }
+ }
+ }
+
+ /*
+ * get the rest
+ */
+ for (i = 0; i < n; i++) {
+ if (!node->links[i])
+ continue;
+
+ links[next] = node->links[i];
+ axes[next] = node->axes[i];
+ node->links[i] = NULL;
+ next++;
+ }
+
+ for (i = 0; i < n; i++) {
+ node->links[i] = links[i];
+ node->axes[i] = axes[i];
+ }
+
+ free(links);
+ free(axes);
+
+ return 0;
+}
+
+/*
+ * make_coord
+ */
+static int make_coord(lash_t *p_lash, mesh_t *mesh, int seed)
+{
+ osm_log_t *p_log = &p_lash->p_osm->log;
+ unsigned int i, j, k;
+ int sw;
+ switch_t *s, *s1;
+ unsigned int change;
+ unsigned int dimension = mesh->dimension;
+ int num_switches = p_lash->num_switches;
+ int assigned_axes = 0, unassigned_axes = 0;
+
+ OSM_LOG_ENTER(p_log);
+
+ for (sw = 0; sw < num_switches; sw++) {
+ s = p_lash->switches[sw];
+
+ s->node->coord = calloc(dimension, sizeof(int));
+ if (!s->node->coord) {
+ OSM_LOG(p_log, OSM_LOG_ERROR,
+ "Failed allocating coord - out of memory\n");
+ OSM_LOG_EXIT(p_log);
+ return -1;
+ }
+
+ for (i = 0; i < dimension; i++)
+ s->node->coord[i] = (sw == seed) ? 0 : LARGE;
+
+ for (i = 0; i < s->node->num_links; i++)
+ if (s->node->axes[i] == 0)
+ unassigned_axes++;
+ else
+ assigned_axes++;
+ }
+
+ OSM_LOG(p_log, OSM_LOG_DEBUG, "%d/%d unassigned/assigned axes\n",
+ unassigned_axes, assigned_axes);
+
+ do {
+ change = 0;
+
+ for (sw = 0; sw < num_switches; sw++) {
+ s = p_lash->switches[sw];
+
+ if (s->node->coord[0] == LARGE)
+ continue;
+
+ for (j = 0; j < s->node->num_links; j++) {
+ if (!s->node->axes[j])
+ continue;
+
+ s1 = p_lash->switches[s->node->links[j]->switch_id];
+
+ for (k = 0; k < dimension; k++) {
+ int coord = s->node->coord[k];
+ unsigned axis = s->node->axes[j] - 1;
+
+ if (k == axis/2)
+ coord += (axis & 1)? -1 : +1;
+
+ if (ltmag(coord, s1->node->coord[k])) {
+ s1->node->coord[k] = coord;
+ change++;
+ }
+ }
+ }
+ }
+ } while (change);
+
+ OSM_LOG_EXIT(p_log);
+ return 0;
+}
+
+/*
+ * measure geometry
+ */
+static int measure_geometry(lash_t *p_lash, mesh_t *mesh)
+{
+ osm_log_t *p_log = &p_lash->p_osm->log;
+ int i, j;
+ int sw;
+ switch_t *s;
+ int dimension = mesh->dimension;
+ int num_switches = p_lash->num_switches;
+ int max[MAX_DIMENSION];
+ int min[MAX_DIMENSION];
+ int size[MAX_DIMENSION];
+ int max_size;
+ int max_index;
+
+ OSM_LOG_ENTER(p_log);
+
+ mesh->size = calloc(dimension, sizeof(int));
+ if (!mesh->size) {
+ OSM_LOG(p_log, OSM_LOG_ERROR,
+ "Failed allocating size - out of memory\n");
+ OSM_LOG_EXIT(p_log);
+ return -1;
+ }
+
+ for (i = 0; i < dimension; i++) {
+ max[i] = -LARGE;
+ min[i] = LARGE;
+ }
+
+ for (sw = 0; sw < num_switches; sw++) {
+ s = p_lash->switches[sw];
+
+ for (i = 0; i < dimension; i++) {
+ if (s->node->coord[i] == LARGE)
+ continue;
+ if (s->node->coord[i] > max[i])
+ max[i] = s->node->coord[i];
+ if (s->node->coord[i] < min[i])
+ min[i] = s->node->coord[i];
+ }
+ }
+
+ for (i = 0; i < dimension; i++)
+ mesh->size[i] = size[i] = max[i] - min[i] + 1;
+
+ /*
+ * find an order of dimensions that places largest
+ * sizes first since this seems to work best with LASH
+ */
+ for (j = 0; j < dimension; j++) {
+ max_size = -1;
+ max_index = -1;
+
+ for (i = 0; i < dimension; i++) {
+ if (size[i] > max_size) {
+ max_size = size[i];
+ max_index = i;
+ }
+ }
+
+ mesh->dim_order[j] = max_index;
+ size[max_index] = -1;
+ }
+
+ OSM_LOG_EXIT(p_log);
+ return 0;
+}
+
+/*
+ * reorder links
+ */
+static int reorder_links(lash_t *p_lash, mesh_t *mesh)
+{
+ osm_log_t *p_log = &p_lash->p_osm->log;
+ int sw;
+ int num_switches = p_lash->num_switches;
+
+ OSM_LOG_ENTER(p_log);
+
+ for (sw = 0; sw < num_switches; sw++) {
+ if (reorder_node_links(p_lash, mesh, sw)) {
+ OSM_LOG_EXIT(p_log);
+ return -1;
+ }
+ }
+
+ OSM_LOG_EXIT(p_log);
+ return 0;
+}
+
+/*
+ * compare two switches in a sort
+ */
+static int compare_switches(const void *p1, const void *p2)
+{
+ const comp_t *cp1 = p1, *cp2 = p2;
+ const sort_ctx_t *ctx = &cp1->ctx;
+ switch_t *s1 = ctx->p_lash->switches[cp1->index];
+ switch_t *s2 = ctx->p_lash->switches[cp2->index];
+ int i, j;
+ int ret;
+
+ for (i = 0; i < ctx->mesh->dimension; i++) {
+ j = ctx->mesh->dim_order[i];
+ ret = s1->node->coord[j] - s2->node->coord[j];
+ if (ret)
+ return ret;
+ }
+
+ return 0;
+}
+
+/*
+ * sort_switches - reorder switch array
+ */
+static void sort_switches(lash_t *p_lash, mesh_t *mesh)
+{
+ unsigned int i, j;
+ unsigned int num_switches = p_lash->num_switches;
+ comp_t *comp;
+ int *reverse;
+ switch_t *s;
+ switch_t **switches;
+
+ comp = malloc(num_switches * sizeof(comp_t));
+ reverse = malloc(num_switches * sizeof(int));
+ switches = malloc(num_switches * sizeof(switch_t *));
+ if (!comp || !reverse || !switches) {
+ OSM_LOG(&p_lash->p_osm->log, OSM_LOG_ERROR,
+ "Failed memory allocation - switches not sorted!\n");
+ goto Exit;
+ }
+
+ for (i = 0; i < num_switches; i++) {
+ comp[i].index = i;
+ comp[i].ctx.mesh = mesh;
+ comp[i].ctx.p_lash = p_lash;
+ }
+
+ qsort(comp, num_switches, sizeof(comp_t), compare_switches);
+
+ for (i = 0; i < num_switches; i++)
+ reverse[comp[i].index] = i;
+
+ for (i = 0; i < num_switches; i++) {
+ s = p_lash->switches[comp[i].index];
+ switches[i] = s;
+ s->id = i;
+ for (j = 0; j < s->node->num_links; j++)
+ s->node->links[j]->switch_id =
+ reverse[s->node->links[j]->switch_id];
+ }
+
+ for (i = 0; i < num_switches; i++)
+ p_lash->switches[i] = switches[i];
+
+Exit:
+ if (switches)
+ free(switches);
+ if (comp)
+ free(comp);
+ if (reverse)
+ free(reverse);
+}
+
+/*
+ * osm_mesh_delete - free per mesh resources
+ */
+static void mesh_delete(mesh_t *mesh)
+{
+ if (mesh) {
+ if (mesh->class_type)
+ free(mesh->class_type);
+
+ if (mesh->class_count)
+ free(mesh->class_count);
+
+ if (mesh->size)
+ free(mesh->size);
+
+ free(mesh);
+ }
+}
+
+/*
+ * osm_mesh_create - allocate per mesh resources
+ */
+static mesh_t *mesh_create(lash_t *p_lash)
+{
+ osm_log_t *p_log = &p_lash->p_osm->log;
+ mesh_t *mesh;
+
+ if(!(mesh = calloc(1, sizeof(mesh_t))))
+ goto err;
+
+ if (!(mesh->class_type = calloc(p_lash->num_switches, sizeof(int))))
+ goto err;
+
+ if (!(mesh->class_count = calloc(p_lash->num_switches, sizeof(int))))
+ goto err;
+
+ return mesh;
+
+err:
+ mesh_delete(mesh);
+ OSM_LOG(p_log, OSM_LOG_ERROR,
+ "Failed allocating mesh - out of memory\n");
+ return NULL;
+}
+
+/*
+ * osm_mesh_node_delete - cleanup per switch resources
+ */
+void osm_mesh_node_delete(lash_t *p_lash, switch_t *sw)
+{
+ osm_log_t *p_log = &p_lash->p_osm->log;
+ unsigned i;
+ mesh_node_t *node = sw->node;
+ unsigned num_ports = sw->p_sw->num_ports;
+
+ OSM_LOG_ENTER(p_log);
+
+ if (node) {
+ for (i = 0; i < num_ports; i++)
+ if (node->links[i])
+ free(node->links[i]);
+
+ if (node->poly)
+ free(node->poly);
+
+ if (node->matrix) {
+ for (i = 0; i < node->num_links; i++) {
+ if (node->matrix[i])
+ free(node->matrix[i]);
+ }
+ free(node->matrix);
+ }
+
+ if (node->axes)
+ free(node->axes);
+
+ if (node->coord)
+ free(node->coord);
+
+ free(node);
+
+ sw->node = NULL;
+ }
+
+ OSM_LOG_EXIT(p_log);
+}
+
+/*
+ * osm_mesh_node_create - allocate per switch resources
+ */
+int osm_mesh_node_create(lash_t *p_lash, switch_t *sw)
+{
+ osm_log_t *p_log = &p_lash->p_osm->log;
+ unsigned i;
+ mesh_node_t *node;
+ unsigned num_ports = sw->p_sw->num_ports;
+
+ OSM_LOG_ENTER(p_log);
+
+ if (!(node = sw->node = calloc(1, sizeof(mesh_node_t) + num_ports * sizeof(link_t *))))
+ goto err;
+
+ for (i = 0; i < num_ports; i++)
+ if (!(node->links[i] = calloc(1, sizeof(link_t) + num_ports * sizeof(int))))
+ goto err;
+
+ if (!(node->axes = calloc(num_ports, sizeof(int))))
+ goto err;
+
+ for (i = 0; i < num_ports; i++) {
+ node->links[i]->switch_id = NONE;
+ }
+
+ OSM_LOG_EXIT(p_log);
+ return 0;
+
+err:
+ osm_mesh_node_delete(p_lash, sw);
+ OSM_LOG(p_log, OSM_LOG_ERROR,
+ "Failed allocating mesh node - out of memory\n");
+ OSM_LOG_EXIT(p_log);
+ return -1;
+}
+
+static void dump_mesh(lash_t *p_lash)
+{
+ osm_log_t *p_log = &p_lash->p_osm->log;
+ int sw;
+ int num_switches = p_lash->num_switches;
+ int dimension;
+ int i, j, k, n;
+ switch_t *s, *s2;
+ char buf[256];
+
+ OSM_LOG_ENTER(p_log);
+
+ for (sw = 0; sw < num_switches; sw++) {
+ s = p_lash->switches[sw];
+ dimension = s->node->dimension;
+ n = sprintf(buf, "[");
+ for (i = 0; i < dimension; i++) {
+ n += snprintf(buf + n, sizeof(buf) - n,
+ "%2d", s->node->coord[i]);
+ if (n > sizeof(buf))
+ n = sizeof(buf);
+ if (i != dimension - 1) {
+ n += snprintf(buf + n, sizeof(buf) - n, "%s", ",");
+ if (n > sizeof(buf))
+ n = sizeof(buf);
+ }
+ }
+ n += snprintf(buf + n, sizeof(buf) - n, "]");
+ if (n > sizeof(buf))
+ n = sizeof(buf);
+ for (j = 0; j < s->node->num_links; j++) {
+ s2 = p_lash->switches[s->node->links[j]->switch_id];
+ n += snprintf(buf + n, sizeof(buf) - n, " [%d]->[", j);
+ if (n > sizeof(buf))
+ n = sizeof(buf);
+ for (k = 0; k < dimension; k++) {
+ n += snprintf(buf + n, sizeof(buf) - n, "%2d",
+ s2->node->coord[k]);
+ if (n > sizeof(buf))
+ n = sizeof(buf);
+ if (k != dimension - 1) {
+ n += snprintf(buf + n, sizeof(buf) - n,
+ ",");
+ if (n > sizeof(buf))
+ n = sizeof(buf);
+ }
+ }
+ n += snprintf(buf + n, sizeof(buf) - n, "]");
+ if (n > sizeof(buf))
+ n = sizeof(buf);
+ }
+ OSM_LOG(p_log, OSM_LOG_DEBUG, "%s\n", buf);
+ }
+
+ OSM_LOG_EXIT(p_log);
+}
+
+/*
+ * osm_do_mesh_analysis
+ */
+int osm_do_mesh_analysis(lash_t *p_lash)
+{
+ osm_log_t *p_log = &p_lash->p_osm->log;
+ mesh_t *mesh;
+ int max_class_num = 0;
+ int max_class_type = -1;
+ int i;
+ switch_t *s;
+ char buf[256], *p;
+
+ OSM_LOG_ENTER(p_log);
+
+ mesh = mesh_create(p_lash);
+ if (!mesh)
+ goto err;
+
+ if (get_local_geometry(p_lash, mesh))
+ goto err;
+
+ if (mesh->num_class == 0) {
+ OSM_LOG(p_log, OSM_LOG_INFO,
+ "found no likely mesh nodes - done\n");
+ goto done;
+ }
+
+ /*
+ * find dominant switch class
+ */
+ OSM_LOG(p_log, OSM_LOG_INFO, "found %d node class%s\n",
+ mesh->num_class, (mesh->num_class == 1) ? "" : "es");
+ for (i = 0; i < mesh->num_class; i++) {
+ OSM_LOG(p_log, OSM_LOG_INFO,
+ "class[%d] has %d members with type = %d\n",
+ i, mesh->class_count[i],
+ p_lash->switches[mesh->class_type[i]]->node->type);
+ if (mesh->class_count[i] > max_class_num) {
+ max_class_num = mesh->class_count[i];
+ max_class_type = mesh->class_type[i];
+ }
+ }
+
+ s = p_lash->switches[max_class_type];
+
+ p = buf;
+ p += sprintf(p, "%snode shape is ",
+ (mesh->num_class == 1) ? "" : "most common ");
+
+ if (s->node->type) {
+ const struct mesh_info *t = &mesh_info[s->node->type];
+
+ for (i = 0; i < t->dimension; i++) {
+ p += sprintf(p, "%s%d%s", i? " x " : "", t->size[i],
+ (t->size[i] == 6)? "+" : "");
+ }
+ p += sprintf(p, " mesh\n");
+
+ mesh->dimension = t->dimension;
+ } else {
+ p += sprintf(p, "unknown geometry\n");
+ }
+
+ OSM_LOG(p_log, OSM_LOG_INFO, "%s", buf);
+
+ OSM_LOG(p_log, OSM_LOG_INFO, "poly = %s\n",
+ poly_print(s->node->num_links, s->node->poly));
+
+ if (s->node->type) {
+ make_geometry(p_lash, max_class_type);
+
+ if (make_coord(p_lash, mesh, max_class_type))
+ goto err;
+
+ if (measure_geometry(p_lash, mesh))
+ goto err;
+
+ if (reorder_links(p_lash, mesh))
+ goto err;
+
+ sort_switches(p_lash, mesh);
+
+ p = buf;
+ p += sprintf(p, "found ");
+ for (i = 0; i < mesh->dimension; i++)
+ p += sprintf(p, "%s%d", i? " x " : "", mesh->size[i]);
+ p += sprintf(p, " mesh\n");
+
+ OSM_LOG(p_log, OSM_LOG_INFO, "%s", buf);
+ }
+
+ if (OSM_LOG_IS_ACTIVE_V2(p_log, OSM_LOG_DEBUG))
+ dump_mesh(p_lash);
+
+done:
+ mesh_delete(mesh);
+ OSM_LOG_EXIT(p_log);
+ return 0;
+
+err:
+ mesh_delete(mesh);
+ OSM_LOG_EXIT(p_log);
+ return -1;
+}
diff --git a/contrib/ofed/opensm/opensm/osm_mlnx_ext_port_info_rcv.c b/contrib/ofed/opensm/opensm/osm_mlnx_ext_port_info_rcv.c
new file mode 100644
index 0000000..8151bbc
--- /dev/null
+++ b/contrib/ofed/opensm/opensm/osm_mlnx_ext_port_info_rcv.c
@@ -0,0 +1,142 @@
+/*
+ * Copyright (c) 2011 Mellanox Technologies LTD. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+/*
+ * Abstract:
+ * Implementation of osm_mlnx_epi_rcv_t.
+ * This object represents the MLNX ExtendedPortInfo Receiver object.
+ * This object is part of the opensm family of objects.
+ */
+
+#if HAVE_CONFIG_H
+# include <config.h>
+#endif /* HAVE_CONFIG_H */
+
+#include <string.h>
+#include <stdlib.h>
+#include <iba/ib_types.h>
+#include <complib/cl_qmap.h>
+#include <complib/cl_passivelock.h>
+#include <complib/cl_debug.h>
+#include <opensm/osm_file_ids.h>
+#define FILE_ID OSM_FILE_MLNX_EXT_PORT_INFO_RCV_C
+#include <vendor/osm_vendor_api.h>
+#include <opensm/osm_madw.h>
+#include <opensm/osm_log.h>
+#include <opensm/osm_node.h>
+#include <opensm/osm_subnet.h>
+#include <opensm/osm_mad_pool.h>
+#include <opensm/osm_msgdef.h>
+#include <opensm/osm_helper.h>
+#include <opensm/osm_opensm.h>
+
+void osm_mlnx_epi_rcv_process(IN void *context, IN void *data)
+{
+ osm_sm_t *sm = context;
+ osm_madw_t *p_madw = data;
+ ib_mlnx_ext_port_info_t *p_pi;
+ ib_smp_t *p_smp;
+ osm_port_t *p_port;
+ osm_physp_t *p_physp;
+ osm_node_t *p_node;
+ osm_pi_context_t *p_context;
+ ib_net64_t port_guid, node_guid;
+ uint8_t port_num, portnum, start_port = 1;
+
+ OSM_LOG_ENTER(sm->p_log);
+
+ CL_ASSERT(sm);
+ CL_ASSERT(p_madw);
+
+ p_smp = osm_madw_get_smp_ptr(p_madw);
+ p_context = osm_madw_get_pi_context_ptr(p_madw);
+ p_pi = ib_smp_get_payload_ptr(p_smp);
+
+ CL_ASSERT(p_smp->attr_id == IB_MAD_ATTR_MLNX_EXTENDED_PORT_INFO);
+
+ port_num = (uint8_t) cl_ntoh32(p_smp->attr_mod);
+
+ port_guid = p_context->port_guid;
+ node_guid = p_context->node_guid;
+
+ osm_dump_mlnx_ext_port_info_v2(sm->p_log, node_guid, port_guid, port_num,
+ p_pi, FILE_ID, OSM_LOG_DEBUG);
+
+ CL_PLOCK_EXCL_ACQUIRE(sm->p_lock);
+ p_port = osm_get_port_by_guid(sm->p_subn, port_guid);
+ if (!p_port) {
+ CL_PLOCK_RELEASE(sm->p_lock);
+ OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR 0F06: "
+ "No port object for port with GUID 0x%" PRIx64
+ "\n\t\t\t\tfor parent node GUID 0x%" PRIx64
+ ", TID 0x%" PRIx64 "\n",
+ cl_ntoh64(port_guid),
+ cl_ntoh64(node_guid), cl_ntoh64(p_smp->trans_id));
+ goto Exit;
+ }
+
+ p_node = p_port->p_node;
+ CL_ASSERT(p_node);
+
+ if (!(cl_ntoh16(p_smp->status) & 0x7fff)) {
+ if (port_num != 255) {
+ p_physp = osm_node_get_physp_ptr(p_node, port_num);
+ CL_ASSERT(p_physp);
+ p_physp->ext_port_info = *p_pi;
+ } else {
+ /* Handle all ports on set/set resp */
+ if (p_node->sw &&
+ ib_switch_info_is_enhanced_port0(&p_node->sw->switch_info))
+ start_port = 0;
+
+ for (portnum = start_port;
+ portnum < osm_node_get_num_physp(p_node);
+ portnum++) {
+ p_physp = osm_node_get_physp_ptr(p_node, portnum);
+ CL_ASSERT(p_physp);
+ p_physp->ext_port_info = *p_pi;
+ }
+ }
+ } else
+ OSM_LOG(sm->p_log, OSM_LOG_DEBUG,
+ "MAD status 0x%x received\n",
+ cl_ntoh16(p_smp->status) & 0x7fff);
+
+ CL_PLOCK_RELEASE(sm->p_lock);
+
+Exit:
+ /*
+ Release the lock before jumping here!!
+ */
+ OSM_LOG_EXIT(sm->p_log);
+}
diff --git a/contrib/ofed/opensm/opensm/osm_mtree.c b/contrib/ofed/opensm/opensm/osm_mtree.c
new file mode 100644
index 0000000..7cc0422
--- /dev/null
+++ b/contrib/ofed/opensm/opensm/osm_mtree.c
@@ -0,0 +1,106 @@
+/*
+ * Copyright (c) 2004-2009 Voltaire, Inc. All rights reserved.
+ * Copyright (c) 2002-2006 Mellanox Technologies LTD. All rights reserved.
+ * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+/*
+ * Abstract:
+ * Implementation of osm_mtree_node_t.
+ * This file implements the Multicast Tree object.
+ */
+
+#if HAVE_CONFIG_H
+# include <config.h>
+#endif /* HAVE_CONFIG_H */
+
+#include <stdlib.h>
+#include <opensm/osm_file_ids.h>
+#define FILE_ID OSM_FILE_MTREE_C
+#include <complib/cl_debug.h>
+#include <opensm/osm_mtree.h>
+
+osm_mtree_node_t *osm_mtree_node_new(IN const osm_switch_t * p_sw)
+{
+ osm_mtree_node_t *p_mtn;
+ uint32_t i;
+
+ p_mtn = malloc(sizeof(osm_mtree_node_t) +
+ sizeof(void *) * (p_sw->num_ports - 1));
+ if (!p_mtn)
+ return NULL;
+
+ memset(p_mtn, 0, sizeof(*p_mtn));
+ p_mtn->p_sw = p_sw;
+ p_mtn->max_children = p_sw->num_ports;
+ for (i = 0; i < p_mtn->max_children; i++)
+ p_mtn->child_array[i] = NULL;
+
+ return p_mtn;
+}
+
+void osm_mtree_destroy(IN osm_mtree_node_t * p_mtn)
+{
+ uint8_t i;
+
+ if (p_mtn == NULL)
+ return;
+
+ for (i = 0; i < p_mtn->max_children; i++)
+ if ((p_mtn->child_array[i] != NULL) &&
+ (p_mtn->child_array[i] != OSM_MTREE_LEAF))
+ osm_mtree_destroy(p_mtn->child_array[i]);
+
+ free(p_mtn);
+}
+
+#if 0
+static void mtree_dump(IN osm_mtree_node_t * p_mtn)
+{
+ uint32_t i;
+
+ if (p_mtn == NULL)
+ return;
+
+ printf("GUID:0x%016" PRIx64 " max_children:%u\n",
+ cl_ntoh64(p_mtn->p_sw->p_node->node_info.node_guid),
+ p_mtn->max_children);
+ if (p_mtn->child_array != NULL) {
+ for (i = 0; i < p_mtn->max_children; i++) {
+ printf("i=%d\n", i);
+ if ((p_mtn->child_array[i] != NULL)
+ && (p_mtn->child_array[i] != OSM_MTREE_LEAF))
+ mtree_dump(p_mtn->child_array[i]);
+ }
+ }
+}
+#endif
diff --git a/contrib/ofed/opensm/opensm/osm_multicast.c b/contrib/ofed/opensm/opensm/osm_multicast.c
new file mode 100644
index 0000000..b69276d
--- /dev/null
+++ b/contrib/ofed/opensm/opensm/osm_multicast.c
@@ -0,0 +1,460 @@
+/*
+ * Copyright (c) 2004-2009 Voltaire, Inc. All rights reserved.
+ * Copyright (c) 2002-2015 Mellanox Technologies LTD. All rights reserved.
+ * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
+ * Copyright (c) 2013 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+/*
+ * Abstract:
+ * Implementation of multicast functions.
+ */
+
+#if HAVE_CONFIG_H
+# include <config.h>
+#endif /* HAVE_CONFIG_H */
+
+#include <stdlib.h>
+#include <string.h>
+#include <arpa/inet.h>
+#include <sys/socket.h>
+#include <opensm/osm_file_ids.h>
+#define FILE_ID OSM_FILE_MULTICAST_C
+#include <opensm/osm_multicast.h>
+#include <opensm/osm_mcm_port.h>
+#include <opensm/osm_mtree.h>
+#include <opensm/osm_inform.h>
+#include <opensm/osm_opensm.h>
+
+static osm_mgrp_box_t *mgrp_box_new(uint16_t mlid)
+{
+ osm_mgrp_box_t *mbox = malloc(sizeof(*mbox));
+ if (!mbox)
+ return NULL;
+
+ memset(mbox, 0, sizeof(*mbox));
+ mbox->mlid = mlid;
+ cl_qlist_init(&mbox->mgrp_list);
+
+ return mbox;
+}
+
+void mgrp_box_delete(osm_mgrp_box_t *mbox)
+{
+ osm_mtree_destroy(mbox->root);
+ free(mbox);
+}
+
+void mgrp_delete(IN osm_mgrp_t * p_mgrp)
+{
+ osm_mcm_alias_guid_t *p_mcm_alias_guid, *p_next_mcm_alias_guid;
+ osm_mcm_port_t *p_mcm_port, *p_next_mcm_port;
+
+ CL_ASSERT(p_mgrp);
+
+ p_next_mcm_alias_guid =
+ (osm_mcm_alias_guid_t *) cl_qmap_head(&p_mgrp->mcm_alias_port_tbl);
+ while (p_next_mcm_alias_guid !=
+ (osm_mcm_alias_guid_t *) cl_qmap_end(&p_mgrp->mcm_alias_port_tbl)) {
+ p_mcm_alias_guid = p_next_mcm_alias_guid;
+ p_next_mcm_alias_guid =
+ (osm_mcm_alias_guid_t *) cl_qmap_next(&p_mcm_alias_guid->map_item);
+ osm_mcm_alias_guid_delete(&p_mcm_alias_guid);
+ }
+
+ p_next_mcm_port =
+ (osm_mcm_port_t *) cl_qmap_head(&p_mgrp->mcm_port_tbl);
+ while (p_next_mcm_port !=
+ (osm_mcm_port_t *) cl_qmap_end(&p_mgrp->mcm_port_tbl)) {
+ p_mcm_port = p_next_mcm_port;
+ p_next_mcm_port =
+ (osm_mcm_port_t *) cl_qmap_next(&p_mcm_port->map_item);
+ osm_mcm_port_delete(p_mcm_port);
+ }
+
+ free(p_mgrp);
+}
+
+void osm_mgrp_box_delete(osm_mgrp_box_t *mbox)
+{
+ osm_mgrp_t *mgrp;
+
+ while (cl_qlist_count(&mbox->mgrp_list)) {
+ mgrp = cl_item_obj(cl_qlist_remove_head(&mbox->mgrp_list),
+ mgrp, list_item);
+ mgrp_delete(mgrp);
+ }
+ mgrp_box_delete(mbox);
+}
+
+osm_mgrp_t *osm_mgrp_new(IN osm_subn_t * subn, IN ib_net16_t mlid,
+ IN ib_member_rec_t * mcmr)
+{
+ osm_mgrp_t *p_mgrp;
+ osm_mgrp_box_t *mbox;
+
+ p_mgrp = (osm_mgrp_t *) malloc(sizeof(*p_mgrp));
+ if (!p_mgrp)
+ return NULL;
+
+ memset(p_mgrp, 0, sizeof(*p_mgrp));
+ cl_qmap_init(&p_mgrp->mcm_port_tbl);
+ cl_qmap_init(&p_mgrp->mcm_alias_port_tbl);
+ p_mgrp->mlid = mlid;
+ p_mgrp->mcmember_rec = *mcmr;
+
+ mbox = osm_get_mbox_by_mlid(subn, p_mgrp->mlid);
+ if (!mbox && !(mbox = mgrp_box_new(cl_ntoh16(p_mgrp->mlid)))) {
+ free(p_mgrp);
+ return NULL;
+ }
+
+ cl_qlist_insert_tail(&mbox->mgrp_list, &p_mgrp->list_item);
+ subn->mboxes[mbox->mlid - IB_LID_MCAST_START_HO] = mbox;
+
+ cl_fmap_insert(&subn->mgrp_mgid_tbl, &p_mgrp->mcmember_rec.mgid,
+ &p_mgrp->map_item);
+
+ subn->p_osm->sa.dirty = TRUE;
+ return p_mgrp;
+}
+
+void osm_mgrp_cleanup(osm_subn_t * subn, osm_mgrp_t * mgrp)
+{
+ osm_mgrp_box_t *mbox;
+ osm_mcm_alias_guid_t *mcm_alias_guid;
+ osm_mcm_port_t *mcm_port;
+
+ if (mgrp->full_members)
+ return;
+
+ while (cl_qmap_count(&mgrp->mcm_alias_port_tbl)) {
+ mcm_alias_guid = (osm_mcm_alias_guid_t *) cl_qmap_head(&mgrp->mcm_alias_port_tbl);
+ cl_qmap_remove_item(&mgrp->mcm_alias_port_tbl, &mcm_alias_guid->map_item);
+ osm_mcm_alias_guid_delete(&mcm_alias_guid);
+ }
+
+ while (cl_qmap_count(&mgrp->mcm_port_tbl)) {
+ mcm_port = (osm_mcm_port_t *) cl_qmap_head(&mgrp->mcm_port_tbl);
+ cl_qmap_remove_item(&mgrp->mcm_port_tbl, &mcm_port->map_item);
+ cl_qlist_remove_item(&mcm_port->port->mcm_list,
+ &mcm_port->list_item);
+ osm_mcm_port_delete(mcm_port);
+ }
+
+ if (mgrp->well_known)
+ return;
+
+ cl_fmap_remove_item(&subn->mgrp_mgid_tbl, &mgrp->map_item);
+
+ mbox = osm_get_mbox_by_mlid(subn, mgrp->mlid);
+ cl_qlist_remove_item(&mbox->mgrp_list, &mgrp->list_item);
+ if (cl_is_qlist_empty(&mbox->mgrp_list)) {
+ subn->mboxes[cl_ntoh16(mgrp->mlid) - IB_LID_MCAST_START_HO] = NULL;
+ mgrp_box_delete(mbox);
+ }
+ free(mgrp);
+
+ subn->p_osm->sa.dirty = TRUE;
+}
+
+static void mgrp_send_notice(osm_subn_t * subn, osm_log_t * log,
+ osm_mgrp_t * mgrp, unsigned num)
+{
+ ib_mad_notice_attr_t notice;
+ ib_api_status_t status;
+
+ notice.generic_type = 0x80 | IB_NOTICE_TYPE_SUBN_MGMT; /* is generic subn mgt type */
+ ib_notice_set_prod_type_ho(&notice, 4); /* A Class Manager generator */
+ notice.g_or_v.generic.trap_num = CL_HTON16(num);
+ /* The sm_base_lid is saved in network order already. */
+ notice.issuer_lid = subn->sm_base_lid;
+ /* following o14-12.1.11 and table 120 p726 */
+ /* we need to provide the MGID */
+ memcpy(&notice.data_details.ntc_64_67.gid,
+ &mgrp->mcmember_rec.mgid, sizeof(ib_gid_t));
+
+ /* According to page 653 - the issuer gid in this case of trap
+ is the SM gid, since the SM is the initiator of this trap. */
+ notice.issuer_gid.unicast.prefix = subn->opt.subnet_prefix;
+ notice.issuer_gid.unicast.interface_id = subn->sm_port_guid;
+
+ if ((status = osm_report_notice(log, subn, &notice)))
+ OSM_LOG(log, OSM_LOG_ERROR, "ERR 7601: "
+ "Error sending trap reports (%s)\n",
+ ib_get_err_str(status));
+}
+
+static boolean_t is_qmap_empty_for_port(IN const cl_qmap_t * const p_map,
+ IN const osm_port_t *port)
+{
+ size_t count = 0;
+ cl_map_item_t *item;
+ osm_mcm_alias_guid_t *mcm_alias_guid;
+
+ for (item = cl_qmap_head(p_map); item != cl_qmap_end(p_map);
+ item = cl_qmap_next(item)) {
+ mcm_alias_guid = (osm_mcm_alias_guid_t *) item;
+ if (mcm_alias_guid->p_base_mcm_port->port == port) {
+ count++;
+ break;
+ }
+ }
+
+ return (count == 0);
+}
+
+static boolean_t is_qmap_empty_for_mcm_port(IN const cl_qmap_t * const p_map,
+ IN const osm_mcm_port_t *mcm_port)
+{
+ size_t count = 0;
+ cl_map_item_t *item;
+ osm_mcm_alias_guid_t *mcm_alias_guid;
+
+ for (item = cl_qmap_head(p_map); item != cl_qmap_end(p_map);
+ item = cl_qmap_next(item)) {
+ mcm_alias_guid = (osm_mcm_alias_guid_t *) item;
+ if (mcm_alias_guid->p_base_mcm_port == mcm_port) {
+ count++;
+ break;
+ }
+ }
+
+ return (count == 0);
+}
+static osm_mcm_alias_guid_t *insert_alias_guid(IN osm_mgrp_t * mgrp,
+ IN osm_mcm_alias_guid_t * p_mcm_alias_guid)
+{
+ osm_mcm_alias_guid_t *p_mcm_alias_guid_check;
+
+ /* insert into mcm alias guid table */
+ p_mcm_alias_guid_check =
+ (osm_mcm_alias_guid_t *) cl_qmap_insert(&mgrp->mcm_alias_port_tbl,
+ p_mcm_alias_guid->alias_guid,
+ &p_mcm_alias_guid->map_item);
+ if (p_mcm_alias_guid_check != (osm_mcm_alias_guid_t *) &p_mcm_alias_guid->map_item) {
+ /* alias GUID is a duplicate */
+ osm_mcm_alias_guid_delete(&p_mcm_alias_guid);
+ return p_mcm_alias_guid_check;
+ }
+ return NULL;
+}
+
+osm_mcm_port_t *osm_mgrp_add_port(IN osm_subn_t * subn, osm_log_t * log,
+ IN osm_mgrp_t * mgrp, osm_port_t *port,
+ IN ib_member_rec_t *mcmr, IN boolean_t proxy)
+{
+ osm_mcm_port_t *mcm_port;
+ osm_mcm_alias_guid_t *p_mcm_alias_guid, *p_mcm_alias_guid_check;
+ cl_map_item_t *prev_item;
+ uint8_t prev_join_state = 0, join_state = mcmr->scope_state;
+ uint8_t prev_scope;
+
+ if (OSM_LOG_IS_ACTIVE_V2(log, OSM_LOG_VERBOSE)) {
+ char gid_str[INET6_ADDRSTRLEN];
+ OSM_LOG(log, OSM_LOG_VERBOSE, "GUID 0x%016" PRIx64
+ " Port 0x%016" PRIx64 " joining "
+ "MC group %s (mlid 0x%x)\n",
+ cl_ntoh64(mcmr->port_gid.unicast.interface_id),
+ cl_ntoh64(port->guid),
+ inet_ntop(AF_INET6, mgrp->mcmember_rec.mgid.raw,
+ gid_str, sizeof(gid_str)),
+ cl_ntoh16(mgrp->mlid));
+ }
+
+ mcm_port = osm_mcm_port_new(port, mgrp);
+ if (!mcm_port)
+ return NULL;
+
+ p_mcm_alias_guid = osm_mcm_alias_guid_new(mcm_port, mcmr, proxy);
+ if (!p_mcm_alias_guid) {
+ osm_mcm_port_delete(mcm_port);
+ return NULL;
+ }
+
+ /*
+ prev_item = cl_qmap_insert(...)
+ Pointer to the item in the map with the specified key. If insertion
+ was successful, this is the pointer to the item. If an item with the
+ specified key already exists in the map, the pointer to that item is
+ returned.
+ */
+ prev_item = cl_qmap_insert(&mgrp->mcm_port_tbl, port->guid,
+ &mcm_port->map_item);
+
+ if (prev_item != &mcm_port->map_item) { /* mcm port already exists */
+ osm_mcm_port_delete(mcm_port);
+ mcm_port = (osm_mcm_port_t *) prev_item;
+
+ p_mcm_alias_guid->p_base_mcm_port = (osm_mcm_port_t *) prev_item;
+ p_mcm_alias_guid_check = insert_alias_guid(mgrp, p_mcm_alias_guid);
+ if (p_mcm_alias_guid_check) { /* alias GUID already exists */
+ p_mcm_alias_guid = p_mcm_alias_guid_check;
+ ib_member_get_scope_state(p_mcm_alias_guid->scope_state,
+ &prev_scope, &prev_join_state);
+ p_mcm_alias_guid->scope_state =
+ ib_member_set_scope_state(prev_scope,
+ prev_join_state | join_state);
+ }
+ } else {
+ insert_alias_guid(mgrp, p_mcm_alias_guid);
+ cl_qlist_insert_tail(&port->mcm_list, &mcm_port->list_item);
+ osm_sm_reroute_mlid(&subn->p_osm->sm, mgrp->mlid);
+ }
+
+ /* o15.0.1.11: copy the join state */
+ mcmr->scope_state = p_mcm_alias_guid->scope_state;
+
+ if ((join_state & IB_JOIN_STATE_FULL) &&
+ !(prev_join_state & IB_JOIN_STATE_FULL) &&
+ ++mgrp->full_members == 1)
+ mgrp_send_notice(subn, log, mgrp, SM_MGID_CREATED_TRAP); /* 66 */
+
+ subn->p_osm->sa.dirty = TRUE;
+ return mcm_port;
+}
+
+boolean_t osm_mgrp_remove_port(osm_subn_t * subn, osm_log_t * log, osm_mgrp_t * mgrp,
+ osm_mcm_alias_guid_t * mcm_alias_guid,
+ ib_member_rec_t *mcmr)
+{
+ uint8_t join_state = mcmr->scope_state & 0xf;
+ uint8_t port_join_state, new_join_state;
+ boolean_t mgrp_deleted = FALSE;
+
+ /*
+ * according to the same o15-0.1.14 we get the stored
+ * JoinState and the request JoinState and they must be
+ * opposite to leave - otherwise just update it
+ */
+ port_join_state = mcm_alias_guid->scope_state & 0x0F;
+ new_join_state = port_join_state & ~join_state;
+
+ if (OSM_LOG_IS_ACTIVE_V2(log, OSM_LOG_VERBOSE)) {
+ char gid_str[INET6_ADDRSTRLEN];
+ OSM_LOG(log, OSM_LOG_VERBOSE,
+ "GUID 0x%" PRIx64 " Port 0x%" PRIx64
+ " leaving MC group %s (mlid 0x%x)\n",
+ cl_ntoh64(mcm_alias_guid->alias_guid),
+ cl_ntoh64(mcm_alias_guid->p_base_mcm_port->port->guid),
+ inet_ntop(AF_INET6, mgrp->mcmember_rec.mgid.raw,
+ gid_str, sizeof(gid_str)),
+ cl_ntoh16(mgrp->mlid));
+ }
+
+ if (new_join_state & IB_JOIN_STATE_FULL ||
+ (new_join_state &&
+ (mgrp->full_members > (port_join_state & IB_JOIN_STATE_FULL) ? 1 : 0))) {
+ mcm_alias_guid->scope_state =
+ new_join_state | (mcm_alias_guid->scope_state & 0xf0);
+ OSM_LOG(log, OSM_LOG_DEBUG,
+ "updating GUID 0x%" PRIx64 " port 0x%" PRIx64
+ " JoinState 0x%x -> 0x%x\n",
+ cl_ntoh64(mcm_alias_guid->alias_guid),
+ cl_ntoh64(mcm_alias_guid->p_base_mcm_port->port->guid),
+ port_join_state, new_join_state);
+ mcmr->scope_state = mcm_alias_guid->scope_state;
+ } else {
+ mcmr->scope_state = mcm_alias_guid->scope_state & 0xf0;
+ OSM_LOG(log, OSM_LOG_DEBUG, "removing alias GUID 0x%" PRIx64 "\n",
+ cl_ntoh64(mcm_alias_guid->alias_guid));
+ cl_qmap_remove_item(&mgrp->mcm_alias_port_tbl,
+ &mcm_alias_guid->map_item);
+ if (is_qmap_empty_for_port(&mgrp->mcm_alias_port_tbl,
+ mcm_alias_guid->p_base_mcm_port->port)) { /* last alias in mcast group for this port */
+ OSM_LOG(log, OSM_LOG_DEBUG, "removing port 0x%" PRIx64 "\n",
+ cl_ntoh64(mcm_alias_guid->p_base_mcm_port->port->guid));
+ cl_qmap_remove_item(&mgrp->mcm_port_tbl,
+ &mcm_alias_guid->p_base_mcm_port->map_item);
+ cl_qlist_remove_item(&mcm_alias_guid->p_base_mcm_port->port->mcm_list,
+ &mcm_alias_guid->p_base_mcm_port->list_item);
+ if (is_qmap_empty_for_mcm_port(&mgrp->mcm_alias_port_tbl,
+ mcm_alias_guid->p_base_mcm_port)) /* last alias in mcast group for this mcm port */
+ osm_mcm_port_delete(mcm_alias_guid->p_base_mcm_port);
+ osm_sm_reroute_mlid(&subn->p_osm->sm, mgrp->mlid);
+ }
+ osm_mcm_alias_guid_delete(&mcm_alias_guid);
+ }
+
+ /* no more full members so the group will be deleted after re-route
+ but only if it is not a well known group */
+ if ((port_join_state & IB_JOIN_STATE_FULL) &&
+ !(new_join_state & IB_JOIN_STATE_FULL) &&
+ --mgrp->full_members == 0) {
+ mgrp_send_notice(subn, log, mgrp, SM_MGID_DESTROYED_TRAP); /* 67 */
+ osm_mgrp_cleanup(subn, mgrp);
+ mgrp_deleted = TRUE;
+ }
+
+ subn->p_osm->sa.dirty = TRUE;
+
+ return (mgrp_deleted);
+}
+
+void osm_mgrp_delete_port(osm_subn_t * subn, osm_log_t * log, osm_mgrp_t * mgrp,
+ osm_port_t * port)
+{
+ osm_mcm_alias_guid_t *mcm_alias_guid, *next_mcm_alias_guid;
+ ib_member_rec_t mcmrec;
+ boolean_t mgrp_deleted = FALSE;
+
+ next_mcm_alias_guid = (osm_mcm_alias_guid_t *) cl_qmap_head(&mgrp->mcm_alias_port_tbl);
+ while (next_mcm_alias_guid != (osm_mcm_alias_guid_t *) cl_qmap_end(&mgrp->mcm_alias_port_tbl) &&
+ !mgrp_deleted) {
+ mcm_alias_guid = next_mcm_alias_guid;
+ next_mcm_alias_guid = (osm_mcm_alias_guid_t *) cl_qmap_next(&next_mcm_alias_guid->map_item);
+ if (mcm_alias_guid->p_base_mcm_port->port == port) {
+ mcmrec.scope_state = 0xf;
+ mgrp_deleted = osm_mgrp_remove_port(subn, log, mgrp, mcm_alias_guid,
+ &mcmrec);
+ }
+ }
+}
+
+osm_mcm_port_t *osm_mgrp_get_mcm_port(IN const osm_mgrp_t * p_mgrp,
+ IN ib_net64_t port_guid)
+{
+ cl_map_item_t *item = cl_qmap_get(&p_mgrp->mcm_port_tbl, port_guid);
+ if (item != cl_qmap_end(&p_mgrp->mcm_port_tbl))
+ return (osm_mcm_port_t *) item;
+ return NULL;
+}
+
+osm_mcm_alias_guid_t *osm_mgrp_get_mcm_alias_guid(IN const osm_mgrp_t * p_mgrp,
+ IN ib_net64_t port_guid)
+{
+ cl_map_item_t *item = cl_qmap_get(&p_mgrp->mcm_alias_port_tbl,
+ port_guid);
+ if (item != cl_qmap_end(&p_mgrp->mcm_alias_port_tbl))
+ return (osm_mcm_alias_guid_t *) item;
+ return NULL;
+}
diff --git a/contrib/ofed/opensm/opensm/osm_node.c b/contrib/ofed/opensm/opensm/osm_node.c
new file mode 100644
index 0000000..fff5936
--- /dev/null
+++ b/contrib/ofed/opensm/opensm/osm_node.c
@@ -0,0 +1,272 @@
+/*
+ * Copyright (c) 2004-2009 Voltaire, Inc. All rights reserved.
+ * Copyright (c) 2002-2015 Mellanox Technologies LTD. All rights reserved.
+ * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+/*
+ * Abstract:
+ * Implementation of osm_node_t.
+ * This object represents an Infiniband Node.
+ * This object is part of the opensm family of objects.
+ */
+
+#if HAVE_CONFIG_H
+# include <config.h>
+#endif /* HAVE_CONFIG_H */
+
+#include <stdlib.h>
+#include <iba/ib_types.h>
+#include <opensm/osm_file_ids.h>
+#define FILE_ID OSM_FILE_NODE_C
+#include <opensm/osm_node.h>
+#include <opensm/osm_madw.h>
+
+void osm_node_init_physp(IN osm_node_t * p_node, uint8_t port_num,
+ IN const osm_madw_t * p_madw)
+{
+ ib_net64_t port_guid;
+ ib_smp_t *p_smp;
+ ib_node_info_t *p_ni;
+
+ p_smp = osm_madw_get_smp_ptr(p_madw);
+
+ p_ni = ib_smp_get_payload_ptr(p_smp);
+ port_guid = p_ni->port_guid;
+
+ CL_ASSERT(port_num < p_node->physp_tbl_size);
+
+ osm_physp_init(&p_node->physp_table[port_num],
+ port_guid, port_num, p_node,
+ osm_madw_get_bind_handle(p_madw),
+ p_smp->hop_count, p_smp->initial_path);
+}
+
+osm_node_t *osm_node_new(IN const osm_madw_t * p_madw)
+{
+ osm_node_t *p_node;
+ ib_smp_t *p_smp;
+ ib_node_info_t *p_ni;
+ uint8_t i;
+ uint32_t size;
+
+ p_smp = osm_madw_get_smp_ptr(p_madw);
+ p_ni = ib_smp_get_payload_ptr(p_smp);
+
+ /*
+ The node object already contains one physical port object.
+ Therefore, subtract 1 from the number of physical ports
+ used by the switch. This is not done for CA's since they
+ need to occupy 1 more physp than they physically have since
+ we still reserve room for a "port 0".
+ */
+ size = p_ni->num_ports;
+
+ p_node = malloc(sizeof(*p_node) + sizeof(osm_physp_t) * size);
+ if (!p_node)
+ return NULL;
+
+ memset(p_node, 0, sizeof(*p_node) + sizeof(osm_physp_t) * size);
+ p_node->node_info = *p_ni;
+ p_node->physp_tbl_size = size + 1;
+
+ p_node->physp_discovered = malloc(sizeof(uint8_t) * p_node->physp_tbl_size);
+ if (!p_node->physp_discovered) {
+ free(p_node);
+ return NULL;
+ }
+ memset(p_node->physp_discovered, 0, sizeof(uint8_t) * p_node->physp_tbl_size);
+ /*
+ Construct Physical Port objects owned by this Node.
+ Then, initialize the Physical Port through with we
+ discovered this port.
+ For switches, all ports have the same GUID.
+ For CAs and routers, each port has a different GUID, so we only
+ know the GUID for the port that responded to our
+ Get(NodeInfo).
+ */
+ for (i = 0; i < p_node->physp_tbl_size; i++)
+ osm_physp_construct(&p_node->physp_table[i]);
+
+ if (p_ni->node_type == IB_NODE_TYPE_SWITCH)
+ for (i = 0; i <= p_ni->num_ports; i++)
+ osm_node_init_physp(p_node, i, p_madw);
+ else
+ osm_node_init_physp(p_node,
+ ib_node_info_get_local_port_num(p_ni),
+ p_madw);
+ p_node->print_desc = strdup(OSM_NODE_DESC_UNKNOWN);
+
+ return p_node;
+}
+
+static void node_destroy(IN osm_node_t * p_node)
+{
+ uint16_t i;
+
+ /*
+ Cleanup all physports
+ */
+ for (i = 0; i < p_node->physp_tbl_size; i++)
+ osm_physp_destroy(&p_node->physp_table[i]);
+
+ /* cleanup printable node_desc field */
+ if (p_node->print_desc)
+ free(p_node->print_desc);
+
+ /* cleanup physp_discovered array */
+ free(p_node->physp_discovered);
+}
+
+void osm_node_delete(IN OUT osm_node_t ** p_node)
+{
+ CL_ASSERT(p_node && *p_node);
+ node_destroy(*p_node);
+ free(*p_node);
+ *p_node = NULL;
+}
+
+void osm_node_link(IN osm_node_t * p_node, IN uint8_t port_num,
+ IN osm_node_t * p_remote_node, IN uint8_t remote_port_num)
+{
+ osm_physp_t *p_physp;
+ osm_physp_t *p_remote_physp;
+
+ p_physp = osm_node_get_physp_ptr(p_node, port_num);
+ p_remote_physp = osm_node_get_physp_ptr(p_remote_node, remote_port_num);
+
+ if (p_physp->p_remote_physp)
+ p_physp->p_remote_physp->p_remote_physp = NULL;
+ if (p_remote_physp->p_remote_physp)
+ p_remote_physp->p_remote_physp->p_remote_physp = NULL;
+
+ osm_physp_link(p_physp, p_remote_physp);
+}
+
+void osm_node_unlink(IN osm_node_t * p_node, IN uint8_t port_num,
+ IN osm_node_t * p_remote_node, IN uint8_t remote_port_num)
+{
+ osm_physp_t *p_physp;
+ osm_physp_t *p_remote_physp;
+
+ CL_ASSERT(port_num < p_node->physp_tbl_size);
+ CL_ASSERT(remote_port_num < p_remote_node->physp_tbl_size);
+
+ if (osm_node_link_exists(p_node, port_num,
+ p_remote_node, remote_port_num)) {
+
+ p_physp = osm_node_get_physp_ptr(p_node, port_num);
+ p_remote_physp =
+ osm_node_get_physp_ptr(p_remote_node, remote_port_num);
+
+ osm_physp_unlink(p_physp, p_remote_physp);
+ }
+}
+
+boolean_t osm_node_link_exists(IN osm_node_t * p_node, IN uint8_t port_num,
+ IN osm_node_t * p_remote_node,
+ IN uint8_t remote_port_num)
+{
+ osm_physp_t *p_physp;
+ osm_physp_t *p_remote_physp;
+
+ CL_ASSERT(port_num < p_node->physp_tbl_size);
+ CL_ASSERT(remote_port_num < p_remote_node->physp_tbl_size);
+
+ p_physp = osm_node_get_physp_ptr(p_node, port_num);
+ p_remote_physp = osm_node_get_physp_ptr(p_remote_node, remote_port_num);
+
+ return osm_physp_link_exists(p_physp, p_remote_physp);
+}
+
+boolean_t osm_node_link_has_valid_ports(IN osm_node_t * p_node,
+ IN uint8_t port_num,
+ IN osm_node_t * p_remote_node,
+ IN uint8_t remote_port_num)
+{
+ osm_physp_t *p_physp;
+ osm_physp_t *p_remote_physp;
+
+ CL_ASSERT(port_num < p_node->physp_tbl_size);
+ CL_ASSERT(remote_port_num < p_remote_node->physp_tbl_size);
+
+ p_physp = osm_node_get_physp_ptr(p_node, port_num);
+ p_remote_physp = osm_node_get_physp_ptr(p_remote_node, remote_port_num);
+
+ return (p_physp && p_remote_physp);
+}
+
+boolean_t osm_node_has_any_link(IN osm_node_t * p_node, IN uint8_t port_num)
+{
+ osm_physp_t *p_physp;
+ CL_ASSERT(port_num < p_node->physp_tbl_size);
+ p_physp = osm_node_get_physp_ptr(p_node, port_num);
+ return osm_physp_has_any_link(p_physp);
+}
+
+osm_node_t *osm_node_get_remote_node(IN osm_node_t * p_node,
+ IN uint8_t port_num,
+ OUT uint8_t * p_remote_port_num)
+{
+ osm_physp_t *p_physp;
+ osm_physp_t *p_remote_physp;
+
+ p_physp = osm_node_get_physp_ptr(p_node, port_num);
+
+ if (!p_physp || !osm_physp_has_any_link(p_physp))
+ return NULL;
+
+ p_remote_physp = osm_physp_get_remote(p_physp);
+ if (p_remote_port_num)
+ *p_remote_port_num = osm_physp_get_port_num(p_remote_physp);
+
+ return osm_physp_get_node_ptr(p_remote_physp);
+}
+
+/**********************************************************************
+ The lock must be held before calling this function.
+**********************************************************************/
+ib_net16_t osm_node_get_remote_base_lid(IN osm_node_t * p_node,
+ IN uint32_t port_num)
+{
+ osm_physp_t *p_physp;
+ osm_physp_t *p_remote_physp;
+ CL_ASSERT(port_num < p_node->physp_tbl_size);
+
+ p_physp = osm_node_get_physp_ptr(p_node, port_num);
+ if (p_physp) {
+ p_remote_physp = osm_physp_get_remote(p_physp);
+ return osm_physp_get_base_lid(p_remote_physp);
+ }
+
+ return 0;
+}
diff --git a/contrib/ofed/opensm/opensm/osm_node_desc_rcv.c b/contrib/ofed/opensm/opensm/osm_node_desc_rcv.c
new file mode 100644
index 0000000..858ac45
--- /dev/null
+++ b/contrib/ofed/opensm/opensm/osm_node_desc_rcv.c
@@ -0,0 +1,136 @@
+/*
+ * Copyright (c) 2004-2009 Voltaire, Inc. All rights reserved.
+ * Copyright (c) 2002-2007 Mellanox Technologies LTD. All rights reserved.
+ * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
+ * Copyright (c) 2013 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+/*
+ * Abstract:
+ * Implementation of osm_nd_rcv_t.
+ * This object represents the NodeDescription Receiver object.
+ * This object is part of the opensm family of objects.
+ */
+
+#if HAVE_CONFIG_H
+# include <config.h>
+#endif /* HAVE_CONFIG_H */
+
+#include <string.h>
+#include <iba/ib_types.h>
+#include <complib/cl_qmap.h>
+#include <complib/cl_passivelock.h>
+#include <complib/cl_debug.h>
+#include <opensm/osm_file_ids.h>
+#define FILE_ID OSM_FILE_NODE_DESC_RCV_C
+#include <opensm/osm_madw.h>
+#include <opensm/osm_log.h>
+#include <opensm/osm_node.h>
+#include <opensm/osm_opensm.h>
+#include <opensm/osm_subnet.h>
+
+static void nd_rcv_process_nd(IN osm_sm_t * sm, IN osm_node_t * p_node,
+ IN const ib_node_desc_t * p_nd)
+{
+ char *tmp_desc;
+ char print_desc[IB_NODE_DESCRIPTION_SIZE + 1];
+
+ OSM_LOG_ENTER(sm->p_log);
+
+ memcpy(&p_node->node_desc.description, p_nd, sizeof(*p_nd));
+
+ /* also set up a printable version */
+ memcpy(print_desc, p_nd, sizeof(*p_nd));
+ print_desc[IB_NODE_DESCRIPTION_SIZE] = '\0';
+ tmp_desc = remap_node_name(sm->p_subn->p_osm->node_name_map,
+ cl_ntoh64(osm_node_get_node_guid(p_node)),
+ print_desc);
+
+ /* make a copy for this node to "own" */
+ if (p_node->print_desc)
+ free(p_node->print_desc);
+ p_node->print_desc = tmp_desc;
+
+#ifdef ENABLE_OSM_PERF_MGR
+ /* update the perfmgr entry if available */
+ osm_perfmgr_update_nodename(&sm->p_subn->p_osm->perfmgr,
+ cl_ntoh64(osm_node_get_node_guid(p_node)),
+ p_node->print_desc);
+#endif /* ENABLE_OSM_PERF_MGR */
+
+ OSM_LOG(sm->p_log, OSM_LOG_VERBOSE,
+ "Node 0x%" PRIx64 ", Description = %s\n",
+ cl_ntoh64(osm_node_get_node_guid(p_node)), p_node->print_desc);
+
+ OSM_LOG_EXIT(sm->p_log);
+}
+
+void osm_nd_rcv_process(IN void *context, IN void *data)
+{
+ osm_sm_t *sm = context;
+ osm_madw_t *p_madw = data;
+ ib_node_desc_t *p_nd;
+ ib_smp_t *p_smp;
+ osm_node_t *p_node;
+ ib_net64_t node_guid;
+
+ CL_ASSERT(sm);
+
+ OSM_LOG_ENTER(sm->p_log);
+
+ CL_ASSERT(p_madw);
+
+ p_smp = osm_madw_get_smp_ptr(p_madw);
+ if (ib_smp_get_status(p_smp)) {
+ OSM_LOG(sm->p_log, OSM_LOG_DEBUG,
+ "MAD status 0x%x received\n",
+ cl_ntoh16(ib_smp_get_status(p_smp)));
+ goto Exit;
+ }
+
+ p_nd = ib_smp_get_payload_ptr(p_smp);
+
+ /* Acquire the node object and add the node description. */
+ node_guid = osm_madw_get_nd_context_ptr(p_madw)->node_guid;
+ CL_PLOCK_EXCL_ACQUIRE(sm->p_lock);
+ p_node = osm_get_node_by_guid(sm->p_subn, node_guid);
+ if (!p_node)
+ OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR 0B01: "
+ "NodeDescription received for nonexistent node "
+ "0x%" PRIx64 "\n", cl_ntoh64(node_guid));
+ else
+ nd_rcv_process_nd(sm, p_node, p_nd);
+
+ CL_PLOCK_RELEASE(sm->p_lock);
+Exit:
+ OSM_LOG_EXIT(sm->p_log);
+}
diff --git a/contrib/ofed/opensm/opensm/osm_node_info_rcv.c b/contrib/ofed/opensm/opensm/osm_node_info_rcv.c
new file mode 100644
index 0000000..6207ac4
--- /dev/null
+++ b/contrib/ofed/opensm/opensm/osm_node_info_rcv.c
@@ -0,0 +1,972 @@
+/*
+ * Copyright (c) 2004-2009 Voltaire, Inc. All rights reserved.
+ * Copyright (c) 2002-2015 Mellanox Technologies LTD. All rights reserved.
+ * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
+ * Copyright (c) 2009 HNR Consulting. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+/*
+ * Abstract:
+ * Implementation of osm_ni_rcv_t.
+ * This object represents the NodeInfo Receiver object.
+ * This object is part of the opensm family of objects.
+ */
+
+#if HAVE_CONFIG_H
+# include <config.h>
+#endif /* HAVE_CONFIG_H */
+
+#include <stdlib.h>
+#include <string.h>
+#include <iba/ib_types.h>
+#include <complib/cl_qmap.h>
+#include <complib/cl_passivelock.h>
+#include <complib/cl_debug.h>
+#include <opensm/osm_file_ids.h>
+#define FILE_ID OSM_FILE_NODE_INFO_RCV_C
+#include <opensm/osm_madw.h>
+#include <opensm/osm_log.h>
+#include <opensm/osm_node.h>
+#include <opensm/osm_subnet.h>
+#include <opensm/osm_router.h>
+#include <opensm/osm_mad_pool.h>
+#include <opensm/osm_helper.h>
+#include <opensm/osm_msgdef.h>
+#include <opensm/osm_opensm.h>
+#include <opensm/osm_ucast_mgr.h>
+#include <opensm/osm_db_pack.h>
+
+static void report_duplicated_guid(IN osm_sm_t * sm, osm_physp_t * p_physp,
+ osm_node_t * p_neighbor_node,
+ const uint8_t port_num)
+{
+ osm_physp_t *p_old, *p_new;
+ osm_dr_path_t path;
+
+ p_old = p_physp->p_remote_physp;
+ p_new = osm_node_get_physp_ptr(p_neighbor_node, port_num);
+
+ OSM_LOG(sm->p_log, OSM_LOG_SYS | OSM_LOG_ERROR, "ERR 0D01: "
+ "Found duplicated node GUID.\n"
+ "Node 0x%" PRIx64 " port %u is reachable from remote node "
+ "0x%" PRIx64 " port %u and remote node 0x%" PRIx64 " port %u.\n"
+ "Paths are:\n",
+ cl_ntoh64(p_physp->p_node->node_info.node_guid),
+ p_physp->port_num,
+ p_old ? cl_ntoh64(p_old->p_node->node_info.node_guid) : 0,
+ p_old ? p_old->port_num : 0,
+ p_new ? cl_ntoh64(p_new->p_node->node_info.node_guid) : 0,
+ p_new ? p_new->port_num : 0);
+
+ osm_dump_dr_path_v2(sm->p_log, osm_physp_get_dr_path_ptr(p_physp),
+ FILE_ID, OSM_LOG_ERROR);
+
+ path = *osm_physp_get_dr_path_ptr(p_new);
+ if (osm_dr_path_extend(&path, port_num))
+ OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR 0D05: "
+ "DR path with hop count %d couldn't be extended\n",
+ path.hop_count);
+ osm_dump_dr_path_v2(sm->p_log, &path, FILE_ID, OSM_LOG_ERROR);
+}
+
+static void requery_dup_node_info(IN osm_sm_t * sm, osm_physp_t * p_physp,
+ unsigned count)
+{
+ osm_madw_context_t context;
+ osm_dr_path_t path;
+ cl_status_t status;
+
+ if (!p_physp->p_remote_physp) {
+ OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR 0D0D: "
+ "DR path couldn't be extended due to NULL remote physp\n");
+ return;
+ }
+
+ path = *osm_physp_get_dr_path_ptr(p_physp->p_remote_physp);
+ if (osm_dr_path_extend(&path, p_physp->p_remote_physp->port_num)) {
+ OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR 0D08: "
+ "DR path with hop count %d couldn't be extended\n",
+ path.hop_count);
+ return;
+ }
+
+ context.ni_context.node_guid =
+ p_physp->p_remote_physp->p_node->node_info.port_guid;
+ context.ni_context.port_num = p_physp->p_remote_physp->port_num;
+ context.ni_context.dup_node_guid = p_physp->p_node->node_info.node_guid;
+ context.ni_context.dup_port_num = p_physp->port_num;
+ context.ni_context.dup_count = count;
+
+ status = osm_req_get(sm, &path, IB_MAD_ATTR_NODE_INFO, 0,
+ TRUE, 0, CL_DISP_MSGID_NONE, &context);
+
+ if (status != IB_SUCCESS)
+ OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR 0D02: "
+ "Failure initiating NodeInfo request (%s)\n",
+ ib_get_err_str(status));
+}
+
+/**********************************************************************
+ The plock must be held before calling this function.
+**********************************************************************/
+static void ni_rcv_set_links(IN osm_sm_t * sm, osm_node_t * p_node,
+ const uint8_t port_num,
+ const osm_ni_context_t * p_ni_context)
+{
+ osm_node_t *p_neighbor_node;
+ osm_physp_t *p_physp, *p_remote_physp;
+
+ OSM_LOG_ENTER(sm->p_log);
+
+ /*
+ A special case exists in which the node we're trying to
+ link is our own node. In this case, the guid value in
+ the ni_context will be zero.
+ */
+ if (p_ni_context->node_guid == 0) {
+ OSM_LOG(sm->p_log, OSM_LOG_DEBUG,
+ "Nothing to link for our own node 0x%" PRIx64 "\n",
+ cl_ntoh64(osm_node_get_node_guid(p_node)));
+ goto _exit;
+ }
+
+ p_neighbor_node = osm_get_node_by_guid(sm->p_subn,
+ p_ni_context->node_guid);
+ if (PF(!p_neighbor_node)) {
+ OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR 0D10: "
+ "Unexpected removal of neighbor node 0x%" PRIx64 "\n",
+ cl_ntoh64(p_ni_context->node_guid));
+ goto _exit;
+ }
+
+ /* When setting the link, ports on both
+ sides of the link should be initialized */
+ CL_ASSERT(osm_node_link_has_valid_ports(p_node, port_num,
+ p_neighbor_node,
+ p_ni_context->port_num));
+
+ if (osm_node_link_exists(p_node, port_num,
+ p_neighbor_node, p_ni_context->port_num)) {
+ OSM_LOG(sm->p_log, OSM_LOG_DEBUG, "Link already exists\n");
+ goto _exit;
+ }
+
+ p_physp = osm_node_get_physp_ptr(p_node, port_num);
+ if (!p_physp) {
+ OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR OD0E: "
+ "Failed to find physp for port %d of Node GUID 0x%"
+ PRIx64 "\n", port_num,
+ cl_ntoh64(osm_node_get_node_guid(p_node)));
+ goto _exit;
+ }
+
+ /*
+ * If the link went UP, after we already discovered it, we shouldn't
+ * set the link between the ports and resweep.
+ */
+ if (osm_physp_get_port_state(p_physp) == IB_LINK_DOWN &&
+ p_node->physp_discovered[port_num]) {
+ /* Link down on another side. Don't create a link*/
+ p_node->physp_discovered[port_num] = 0;
+ sm->p_subn->force_heavy_sweep = TRUE;
+ goto _exit;
+ }
+
+ if (osm_node_has_any_link(p_node, port_num) &&
+ sm->p_subn->force_heavy_sweep == FALSE &&
+ (!p_ni_context->dup_count ||
+ (p_ni_context->dup_node_guid == osm_node_get_node_guid(p_node) &&
+ p_ni_context->dup_port_num == port_num))) {
+ /*
+ Uh oh...
+ This could be reconnected ports, but also duplicated GUID
+ (2 nodes have the same guid) or a 12x link with lane reversal
+ that is not configured correctly.
+ We will try to recover by querying NodeInfo again.
+ In order to catch even fast port moving to new location(s)
+ and back we will count up to 5.
+ Some crazy reconnections (newly created switch loop right
+ before targeted CA) will not be catched this way. So in worst
+ case - report GUID duplication and request new discovery.
+ When switch node is targeted NodeInfo querying will be done
+ in opposite order, this is much stronger check, unfortunately
+ it is impossible with CAs.
+ */
+ p_physp = osm_node_get_physp_ptr(p_node, port_num);
+ if (!p_physp) {
+ OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR OD0F: "
+ "Failed to find physp for port %d of Node GUID 0x%"
+ PRIx64 "\n", port_num,
+ cl_ntoh64(osm_node_get_node_guid(p_node)));
+ goto _exit;
+ }
+
+ if (p_ni_context->dup_count > 5) {
+ report_duplicated_guid(sm, p_physp, p_neighbor_node,
+ p_ni_context->port_num);
+ sm->p_subn->force_heavy_sweep = TRUE;
+ } else if (p_node->sw)
+ requery_dup_node_info(sm, p_physp->p_remote_physp,
+ p_ni_context->dup_count + 1);
+ else
+ requery_dup_node_info(sm, p_physp,
+ p_ni_context->dup_count + 1);
+ }
+
+ /*
+ When there are only two nodes with exact same guids (connected back
+ to back) - the previous check for duplicated guid will not catch
+ them. But the link will be from the port to itself...
+ Enhanced Port 0 is an exception to this
+ */
+ if (osm_node_get_node_guid(p_node) == p_ni_context->node_guid &&
+ port_num == p_ni_context->port_num &&
+ port_num != 0 && cl_qmap_count(&sm->p_subn->sw_guid_tbl) == 0) {
+ OSM_LOG(sm->p_log, OSM_LOG_VERBOSE,
+ "Duplicate GUID found by link from a port to itself:"
+ "node 0x%" PRIx64 ", port number %u\n",
+ cl_ntoh64(osm_node_get_node_guid(p_node)), port_num);
+ p_physp = osm_node_get_physp_ptr(p_node, port_num);
+ if (!p_physp) {
+ OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR OD1D: "
+ "Failed to find physp for port %d of Node GUID 0x%"
+ PRIx64 "\n", port_num,
+ cl_ntoh64(osm_node_get_node_guid(p_node)));
+ goto _exit;
+ }
+
+ osm_dump_dr_path_v2(sm->p_log, osm_physp_get_dr_path_ptr(p_physp),
+ FILE_ID, OSM_LOG_VERBOSE);
+
+ if (sm->p_subn->opt.exit_on_fatal == TRUE) {
+ osm_log_v2(sm->p_log, OSM_LOG_SYS, FILE_ID,
+ "Errors on subnet. Duplicate GUID found "
+ "by link from a port to itself. "
+ "See verbose opensm.log for more details\n");
+ exit(1);
+ }
+ }
+
+ OSM_LOG(sm->p_log, OSM_LOG_DEBUG,
+ "Creating new link between:\n\t\t\t\tnode 0x%" PRIx64
+ ", port number %u and\n\t\t\t\tnode 0x%" PRIx64
+ ", port number %u\n",
+ cl_ntoh64(osm_node_get_node_guid(p_node)), port_num,
+ cl_ntoh64(p_ni_context->node_guid), p_ni_context->port_num);
+
+ if (sm->ucast_mgr.cache_valid)
+ osm_ucast_cache_check_new_link(&sm->ucast_mgr, p_node, port_num,
+ p_neighbor_node,
+ p_ni_context->port_num);
+
+ p_physp = osm_node_get_physp_ptr(p_node, port_num);
+ p_remote_physp = osm_node_get_physp_ptr(p_neighbor_node,
+ p_ni_context->port_num);
+ if (!p_physp || !p_remote_physp)
+ goto _exit;
+
+ osm_node_link(p_node, port_num, p_neighbor_node, p_ni_context->port_num);
+
+ osm_db_neighbor_set(sm->p_subn->p_neighbor,
+ cl_ntoh64(osm_physp_get_port_guid(p_physp)),
+ port_num,
+ cl_ntoh64(osm_physp_get_port_guid(p_remote_physp)),
+ p_ni_context->port_num);
+ osm_db_neighbor_set(sm->p_subn->p_neighbor,
+ cl_ntoh64(osm_physp_get_port_guid(p_remote_physp)),
+ p_ni_context->port_num,
+ cl_ntoh64(osm_physp_get_port_guid(p_physp)),
+ port_num);
+
+_exit:
+ OSM_LOG_EXIT(sm->p_log);
+}
+
+static void ni_rcv_get_port_info(IN osm_sm_t * sm, IN osm_node_t * node,
+ IN const osm_madw_t * madw)
+{
+ osm_madw_context_t context;
+ osm_physp_t *physp;
+ ib_node_info_t *ni;
+ unsigned port;
+ ib_api_status_t status;
+ int mlnx_epi_supported = 0;
+
+ ni = ib_smp_get_payload_ptr(osm_madw_get_smp_ptr(madw));
+
+ port = ib_node_info_get_local_port_num(ni);
+
+ if (sm->p_subn->opt.fdr10)
+ mlnx_epi_supported = is_mlnx_ext_port_info_supported(
+ ib_node_info_get_vendor_id(ni),
+ ni->device_id);
+
+ physp = osm_node_get_physp_ptr(node, port);
+ if (!physp) {
+ OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR OD1E: "
+ "Failed to find physp for port %d of Node GUID 0x%"
+ PRIx64 "\n", port,
+ cl_ntoh64(osm_node_get_node_guid(node)));
+ return;
+ }
+
+ context.pi_context.node_guid = osm_node_get_node_guid(node);
+ context.pi_context.port_guid = osm_physp_get_port_guid(physp);
+ context.pi_context.set_method = FALSE;
+ context.pi_context.light_sweep = FALSE;
+ context.pi_context.active_transition = FALSE;
+ context.pi_context.client_rereg = FALSE;
+
+ status = osm_req_get(sm, osm_physp_get_dr_path_ptr(physp),
+ IB_MAD_ATTR_PORT_INFO, cl_hton32(port),
+ TRUE, 0, CL_DISP_MSGID_NONE, &context);
+ if (status != IB_SUCCESS)
+ OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR OD02: "
+ "Failure initiating PortInfo request (%s)\n",
+ ib_get_err_str(status));
+ if (mlnx_epi_supported) {
+ status = osm_req_get(sm,
+ osm_physp_get_dr_path_ptr(physp),
+ IB_MAD_ATTR_MLNX_EXTENDED_PORT_INFO,
+ cl_hton32(port),
+ TRUE, 0, CL_DISP_MSGID_NONE, &context);
+ if (status != IB_SUCCESS)
+ OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR 0D0B: "
+ "Failure initiating MLNX ExtPortInfo request (%s)\n",
+ ib_get_err_str(status));
+ }
+}
+
+/**********************************************************************
+ The plock must be held before calling this function.
+**********************************************************************/
+void osm_req_get_node_desc(IN osm_sm_t * sm, osm_physp_t * p_physp)
+{
+ ib_api_status_t status = IB_SUCCESS;
+ osm_madw_context_t context;
+
+ OSM_LOG_ENTER(sm->p_log);
+
+ context.nd_context.node_guid =
+ osm_node_get_node_guid(osm_physp_get_node_ptr(p_physp));
+
+ status = osm_req_get(sm, osm_physp_get_dr_path_ptr(p_physp),
+ IB_MAD_ATTR_NODE_DESC, 0, TRUE, 0,
+ CL_DISP_MSGID_NONE, &context);
+ if (status != IB_SUCCESS)
+ OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR 0D03: "
+ "Failure initiating NodeDescription request (%s)\n",
+ ib_get_err_str(status));
+
+ OSM_LOG_EXIT(sm->p_log);
+}
+
+/**********************************************************************
+ The plock must be held before calling this function.
+**********************************************************************/
+static void ni_rcv_get_node_desc(IN osm_sm_t * sm, IN osm_node_t * p_node,
+ IN const osm_madw_t * p_madw)
+{
+ ib_node_info_t *p_ni;
+ ib_smp_t *p_smp;
+ uint8_t port_num;
+ osm_physp_t *p_physp = NULL;
+
+ OSM_LOG_ENTER(sm->p_log);
+
+ p_smp = osm_madw_get_smp_ptr(p_madw);
+ p_ni = ib_smp_get_payload_ptr(p_smp);
+ port_num = ib_node_info_get_local_port_num(p_ni);
+
+ /*
+ Request PortInfo & NodeDescription attributes for the port
+ that responded to the NodeInfo attribute.
+ Because this is a channel adapter or router, we are
+ not allowed to request PortInfo for the other ports.
+ Set the context union properly, so the recipient
+ knows which node & port are relevant.
+ */
+ p_physp = osm_node_get_physp_ptr(p_node, port_num);
+ if (!p_physp) {
+ OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR OD1F: "
+ "Failed to find physp for port %d of Node GUID 0x%"
+ PRIx64 "\n", port_num,
+ cl_ntoh64(osm_node_get_node_guid(p_node)));
+ return;
+ }
+
+ osm_req_get_node_desc(sm, p_physp);
+
+ OSM_LOG_EXIT(sm->p_log);
+}
+
+/**********************************************************************
+ The plock must be held before calling this function.
+**********************************************************************/
+static void ni_rcv_process_new_ca_or_router(IN osm_sm_t * sm,
+ IN osm_node_t * p_node,
+ IN const osm_madw_t * p_madw)
+{
+ OSM_LOG_ENTER(sm->p_log);
+
+ ni_rcv_get_port_info(sm, p_node, p_madw);
+
+ /*
+ A node guid of 0 is the corner case that indicates
+ we discovered our own node. Initialize the subnet
+ object with the SM's own port guid.
+ */
+ if (osm_madw_get_ni_context_ptr(p_madw)->node_guid == 0)
+ sm->p_subn->sm_port_guid = p_node->node_info.port_guid;
+
+ OSM_LOG_EXIT(sm->p_log);
+}
+
+/**********************************************************************
+ The plock must be held before calling this function.
+**********************************************************************/
+static void ni_rcv_process_existing_ca_or_router(IN osm_sm_t * sm,
+ IN osm_node_t * p_node,
+ IN const osm_madw_t * p_madw)
+{
+ ib_node_info_t *p_ni;
+ ib_smp_t *p_smp;
+ osm_port_t *p_port;
+ osm_port_t *p_port_check;
+ uint8_t port_num;
+ osm_dr_path_t *p_dr_path;
+ osm_alias_guid_t *p_alias_guid, *p_alias_guid_check;
+
+ OSM_LOG_ENTER(sm->p_log);
+
+ p_smp = osm_madw_get_smp_ptr(p_madw);
+ p_ni = ib_smp_get_payload_ptr(p_smp);
+ port_num = ib_node_info_get_local_port_num(p_ni);
+
+ /*
+ Determine if we have encountered this node through a
+ previously undiscovered port. If so, build the new
+ port object.
+ */
+ p_port = osm_get_port_by_guid(sm->p_subn, p_ni->port_guid);
+ if (!p_port) {
+ OSM_LOG(sm->p_log, OSM_LOG_VERBOSE,
+ "Creating new port object with GUID 0x%" PRIx64 "\n",
+ cl_ntoh64(p_ni->port_guid));
+
+ osm_node_init_physp(p_node, port_num, p_madw);
+
+ p_port = osm_port_new(p_ni, p_node);
+ if (PF(p_port == NULL)) {
+ OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR 0D04: "
+ "Unable to create new port object\n");
+ goto Exit;
+ }
+
+ /*
+ Add the new port object to the database.
+ */
+ p_port_check =
+ (osm_port_t *) cl_qmap_insert(&sm->p_subn->port_guid_tbl,
+ p_ni->port_guid,
+ &p_port->map_item);
+ if (PF(p_port_check != p_port)) {
+ /*
+ We should never be here!
+ Somehow, this port GUID already exists in the table.
+ */
+ OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR 0D12: "
+ "Port 0x%" PRIx64 " already in the database!\n",
+ cl_ntoh64(p_ni->port_guid));
+
+ osm_port_delete(&p_port);
+ goto Exit;
+ }
+
+ p_alias_guid = osm_alias_guid_new(p_ni->port_guid,
+ p_port);
+ if (PF(!p_alias_guid)) {
+ OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR 0D11: "
+ "alias guid memory allocation failed"
+ " for port GUID 0x%" PRIx64 "\n",
+ cl_ntoh64(p_ni->port_guid));
+ goto alias_done;
+ }
+
+ /* insert into alias guid table */
+ p_alias_guid_check =
+ (osm_alias_guid_t *) cl_qmap_insert(&sm->p_subn->alias_port_guid_tbl,
+ p_alias_guid->alias_guid,
+ &p_alias_guid->map_item);
+ if (p_alias_guid_check != p_alias_guid) {
+ /* alias GUID is a duplicate */
+ OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR 0D13: "
+ "Duplicate alias port GUID 0x%" PRIx64 "\n",
+ cl_ntoh64(p_ni->port_guid));
+ osm_alias_guid_delete(&p_alias_guid);
+ osm_port_delete(&p_port);
+ goto Exit;
+ }
+
+alias_done:
+ /* If we are a master, then this means the port is new on the subnet.
+ Mark it as new - need to send trap 64 for these ports.
+ The condition that we are master is true, since if we are in discovering
+ state (meaning we woke up from standby or we are just initializing),
+ then these ports may be new to us, but are not new on the subnet.
+ If we are master, then the subnet as we know it is the updated one,
+ and any new ports we encounter should cause trap 64. C14-72.1.1 */
+ if (sm->p_subn->sm_state == IB_SMINFO_STATE_MASTER)
+ p_port->is_new = 1;
+
+ } else {
+ osm_physp_t *p_physp = osm_node_get_physp_ptr(p_node, port_num);
+
+ if (PF(p_physp == NULL)) {
+ OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR 0D1C: "
+ "No physical port found for node GUID 0x%"
+ PRIx64 " port %u. Might be duplicate port GUID\n",
+ cl_ntoh64(p_node->node_info.node_guid),
+ port_num);
+ goto Exit;
+ }
+
+ /*
+ Update the DR Path to the port,
+ in case the old one is no longer available.
+ */
+ p_dr_path = osm_physp_get_dr_path_ptr(p_physp);
+
+ osm_dr_path_init(p_dr_path, p_smp->hop_count,
+ p_smp->initial_path);
+ }
+
+ ni_rcv_get_port_info(sm, p_node, p_madw);
+
+Exit:
+ OSM_LOG_EXIT(sm->p_log);
+}
+
+static void ni_rcv_process_switch(IN osm_sm_t * sm, IN osm_node_t * p_node,
+ IN const osm_madw_t * p_madw)
+{
+ ib_api_status_t status = IB_SUCCESS;
+ osm_physp_t *p_physp;
+ osm_madw_context_t context;
+ osm_dr_path_t *path;
+ ib_smp_t *p_smp;
+
+ OSM_LOG_ENTER(sm->p_log);
+
+ p_smp = osm_madw_get_smp_ptr(p_madw);
+
+ p_physp = osm_node_get_physp_ptr(p_node, 0);
+ /* update DR path of already initialized switch port 0 */
+ path = osm_physp_get_dr_path_ptr(p_physp);
+ osm_dr_path_init(path, p_smp->hop_count, p_smp->initial_path);
+
+ context.si_context.node_guid = osm_node_get_node_guid(p_node);
+ context.si_context.set_method = FALSE;
+ context.si_context.light_sweep = FALSE;
+ context.si_context.lft_top_change = FALSE;
+
+ /* Request a SwitchInfo attribute */
+ status = osm_req_get(sm, path, IB_MAD_ATTR_SWITCH_INFO, 0, TRUE, 0,
+ CL_DISP_MSGID_NONE, &context);
+ if (status != IB_SUCCESS)
+ /* continue despite error */
+ OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR 0D06: "
+ "Failure initiating SwitchInfo request (%s)\n",
+ ib_get_err_str(status));
+
+ OSM_LOG_EXIT(sm->p_log);
+}
+
+/**********************************************************************
+ The plock must be held before calling this function.
+**********************************************************************/
+static void ni_rcv_process_existing_switch(IN osm_sm_t * sm,
+ IN osm_node_t * p_node,
+ IN const osm_madw_t * p_madw)
+{
+ OSM_LOG_ENTER(sm->p_log);
+
+ /*
+ If this switch has already been probed during this sweep,
+ then don't bother reprobing it.
+ */
+ if (p_node->discovery_count == 1)
+ ni_rcv_process_switch(sm, p_node, p_madw);
+
+ OSM_LOG_EXIT(sm->p_log);
+}
+
+/**********************************************************************
+ The plock must be held before calling this function.
+**********************************************************************/
+static void ni_rcv_process_new_switch(IN osm_sm_t * sm, IN osm_node_t * p_node,
+ IN const osm_madw_t * p_madw)
+{
+ OSM_LOG_ENTER(sm->p_log);
+
+ ni_rcv_process_switch(sm, p_node, p_madw);
+
+ /*
+ A node guid of 0 is the corner case that indicates
+ we discovered our own node. Initialize the subnet
+ object with the SM's own port guid.
+ */
+ if (osm_madw_get_ni_context_ptr(p_madw)->node_guid == 0)
+ sm->p_subn->sm_port_guid = p_node->node_info.port_guid;
+
+ OSM_LOG_EXIT(sm->p_log);
+}
+
+/**********************************************************************
+ The plock must NOT be held before calling this function.
+**********************************************************************/
+static void ni_rcv_process_new(IN osm_sm_t * sm, IN const osm_madw_t * p_madw)
+{
+ osm_node_t *p_node;
+ osm_node_t *p_node_check;
+ osm_port_t *p_port;
+ osm_port_t *p_port_check;
+ osm_router_t *p_rtr = NULL;
+ osm_router_t *p_rtr_check;
+ cl_qmap_t *p_rtr_guid_tbl;
+ ib_node_info_t *p_ni;
+ ib_smp_t *p_smp;
+ osm_ni_context_t *p_ni_context;
+ osm_alias_guid_t *p_alias_guid, *p_alias_guid_check;
+ uint8_t port_num;
+
+ OSM_LOG_ENTER(sm->p_log);
+
+ p_smp = osm_madw_get_smp_ptr(p_madw);
+ p_ni = ib_smp_get_payload_ptr(p_smp);
+ p_ni_context = osm_madw_get_ni_context_ptr(p_madw);
+ port_num = ib_node_info_get_local_port_num(p_ni);
+
+ osm_dump_smp_dr_path_v2(sm->p_log, p_smp, FILE_ID, OSM_LOG_VERBOSE);
+
+ OSM_LOG(sm->p_log, OSM_LOG_VERBOSE,
+ "Discovered new %s node,"
+ "\n\t\t\t\tGUID 0x%" PRIx64 ", TID 0x%" PRIx64 "\n",
+ ib_get_node_type_str(p_ni->node_type),
+ cl_ntoh64(p_ni->node_guid), cl_ntoh64(p_smp->trans_id));
+
+ if (PF(port_num > p_ni->num_ports)) {
+ OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR 0D0A: "
+ "New %s node GUID 0x%" PRIx64 "is non-compliant and "
+ "is being ignored since the "
+ "local port num %u > num ports %u\n",
+ ib_get_node_type_str(p_ni->node_type),
+ cl_ntoh64(p_ni->node_guid), port_num,
+ p_ni->num_ports);
+ goto Exit;
+ }
+
+ p_node = osm_node_new(p_madw);
+ if (PF(p_node == NULL)) {
+ OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR 0D07: "
+ "Unable to create new node object\n");
+ goto Exit;
+ }
+
+ /*
+ Create a new port object to represent this node's physical
+ ports in the port table.
+ */
+ p_port = osm_port_new(p_ni, p_node);
+ if (PF(p_port == NULL)) {
+ OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR 0D14: "
+ "Unable to create new port object\n");
+ osm_node_delete(&p_node);
+ goto Exit;
+ }
+
+ /*
+ Add the new port object to the database.
+ */
+ p_port_check =
+ (osm_port_t *) cl_qmap_insert(&sm->p_subn->port_guid_tbl,
+ p_ni->port_guid, &p_port->map_item);
+ if (PF(p_port_check != p_port)) {
+ /*
+ We should never be here!
+ Somehow, this port GUID already exists in the table.
+ */
+ OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR 0D15: "
+ "Duplicate Port GUID 0x%" PRIx64
+ "! Found by the two directed routes:\n",
+ cl_ntoh64(p_ni->port_guid));
+ osm_dump_dr_path_v2(sm->p_log,
+ osm_physp_get_dr_path_ptr(p_port->p_physp),
+ FILE_ID, OSM_LOG_ERROR);
+ osm_dump_dr_path_v2(sm->p_log,
+ osm_physp_get_dr_path_ptr(p_port_check->
+ p_physp),
+ FILE_ID, OSM_LOG_ERROR);
+ osm_port_delete(&p_port);
+ osm_node_delete(&p_node);
+ goto Exit;
+ }
+
+ p_alias_guid = osm_alias_guid_new(p_ni->port_guid,
+ p_port);
+ if (PF(!p_alias_guid)) {
+ OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR 0D18: "
+ "alias guid memory allocation failed"
+ " for port GUID 0x%" PRIx64 "\n",
+ cl_ntoh64(p_ni->port_guid));
+ goto alias_done2;
+ }
+
+ /* insert into alias guid table */
+ p_alias_guid_check =
+ (osm_alias_guid_t *) cl_qmap_insert(&sm->p_subn->alias_port_guid_tbl,
+ p_alias_guid->alias_guid,
+ &p_alias_guid->map_item);
+ if (p_alias_guid_check != p_alias_guid) {
+ /* alias GUID is a duplicate */
+ OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR 0D19: "
+ "Duplicate alias port GUID 0x%" PRIx64 "\n",
+ cl_ntoh64(p_ni->port_guid));
+ osm_alias_guid_delete(&p_alias_guid);
+ }
+
+alias_done2:
+ /* If we are a master, then this means the port is new on the subnet.
+ Mark it as new - need to send trap 64 on these ports.
+ The condition that we are master is true, since if we are in discovering
+ state (meaning we woke up from standby or we are just initializing),
+ then these ports may be new to us, but are not new on the subnet.
+ If we are master, then the subnet as we know it is the updated one,
+ and any new ports we encounter should cause trap 64. C14-72.1.1 */
+ if (sm->p_subn->sm_state == IB_SMINFO_STATE_MASTER)
+ p_port->is_new = 1;
+
+ /* If there were RouterInfo or other router attribute,
+ this would be elsewhere */
+ if (p_ni->node_type == IB_NODE_TYPE_ROUTER) {
+ if (PF((p_rtr = osm_router_new(p_port)) == NULL))
+ OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR 0D1A: "
+ "Unable to create new router object\n");
+ else {
+ p_rtr_guid_tbl = &sm->p_subn->rtr_guid_tbl;
+ p_rtr_check =
+ (osm_router_t *) cl_qmap_insert(p_rtr_guid_tbl,
+ p_ni->port_guid,
+ &p_rtr->map_item);
+ if (PF(p_rtr_check != p_rtr))
+ OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR 0D1B: "
+ "Unable to add port GUID:0x%016" PRIx64
+ " to router table\n",
+ cl_ntoh64(p_ni->port_guid));
+ }
+ }
+
+ p_node_check =
+ (osm_node_t *) cl_qmap_insert(&sm->p_subn->node_guid_tbl,
+ p_ni->node_guid, &p_node->map_item);
+ if (PF(p_node_check != p_node)) {
+ /*
+ This node must have been inserted by another thread.
+ This is unexpected, but is not an error.
+ We can simply clean-up, since the other thread will
+ see this processing through to completion.
+ */
+ OSM_LOG(sm->p_log, OSM_LOG_VERBOSE,
+ "Discovery race detected at node 0x%" PRIx64 "\n",
+ cl_ntoh64(p_ni->node_guid));
+ osm_node_delete(&p_node);
+ p_node = p_node_check;
+ ni_rcv_set_links(sm, p_node, port_num, p_ni_context);
+ goto Exit;
+ } else
+ ni_rcv_set_links(sm, p_node, port_num, p_ni_context);
+
+ p_node->discovery_count++;
+ ni_rcv_get_node_desc(sm, p_node, p_madw);
+
+ switch (p_ni->node_type) {
+ case IB_NODE_TYPE_CA:
+ case IB_NODE_TYPE_ROUTER:
+ ni_rcv_process_new_ca_or_router(sm, p_node, p_madw);
+ break;
+ case IB_NODE_TYPE_SWITCH:
+ ni_rcv_process_new_switch(sm, p_node, p_madw);
+ break;
+ default:
+ OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR 0D16: "
+ "Unknown node type %u with GUID 0x%" PRIx64 "\n",
+ p_ni->node_type, cl_ntoh64(p_ni->node_guid));
+ break;
+ }
+
+Exit:
+ OSM_LOG_EXIT(sm->p_log);
+}
+
+/**********************************************************************
+ The plock must be held before calling this function.
+**********************************************************************/
+static void ni_rcv_process_existing(IN osm_sm_t * sm, IN osm_node_t * p_node,
+ IN const osm_madw_t * p_madw)
+{
+ ib_node_info_t *p_ni;
+ ib_smp_t *p_smp;
+ osm_ni_context_t *p_ni_context;
+ uint8_t port_num;
+
+ OSM_LOG_ENTER(sm->p_log);
+
+ p_smp = osm_madw_get_smp_ptr(p_madw);
+ p_ni = ib_smp_get_payload_ptr(p_smp);
+ p_ni_context = osm_madw_get_ni_context_ptr(p_madw);
+ port_num = ib_node_info_get_local_port_num(p_ni);
+
+ OSM_LOG(sm->p_log, OSM_LOG_VERBOSE,
+ "Rediscovered %s node 0x%" PRIx64 " TID 0x%" PRIx64
+ ", discovered %u times already\n",
+ ib_get_node_type_str(p_ni->node_type),
+ cl_ntoh64(p_ni->node_guid),
+ cl_ntoh64(p_smp->trans_id), p_node->discovery_count);
+
+ if (PF(port_num > p_ni->num_ports)) {
+ OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR 0D0C: "
+ "Existing %s node GUID 0x%" PRIx64 "is non-compliant "
+ "and is being ignored since the "
+ "local port num %u > num ports %u\n",
+ ib_get_node_type_str(p_ni->node_type),
+ cl_ntoh64(p_ni->node_guid), port_num,
+ p_ni->num_ports);
+ goto Exit;
+ }
+
+ /*
+ If we haven't already encountered this existing node
+ on this particular sweep, then process further.
+ */
+ p_node->discovery_count++;
+
+ switch (p_ni->node_type) {
+ case IB_NODE_TYPE_CA:
+ case IB_NODE_TYPE_ROUTER:
+ ni_rcv_process_existing_ca_or_router(sm, p_node, p_madw);
+ break;
+
+ case IB_NODE_TYPE_SWITCH:
+ ni_rcv_process_existing_switch(sm, p_node, p_madw);
+ break;
+
+ default:
+ OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR 0D09: "
+ "Unknown node type %u with GUID 0x%" PRIx64 "\n",
+ p_ni->node_type, cl_ntoh64(p_ni->node_guid));
+ break;
+ }
+
+ if ( p_ni->sys_guid != p_node->node_info.sys_guid) {
+ OSM_LOG(sm->p_log, OSM_LOG_DEBUG, "Updated SysImageGUID: 0x%"
+ PRIx64 " for node 0x%" PRIx64 "\n",
+ cl_ntoh64(p_ni->sys_guid),
+ cl_ntoh64(p_ni->node_guid));
+ }
+ ni_rcv_set_links(sm, p_node, port_num, p_ni_context);
+ p_node->node_info = *p_ni;
+
+Exit:
+ OSM_LOG_EXIT(sm->p_log);
+}
+
+void osm_ni_rcv_process(IN void *context, IN void *data)
+{
+ osm_sm_t *sm = context;
+ osm_madw_t *p_madw = data;
+ ib_node_info_t *p_ni;
+ ib_smp_t *p_smp;
+ osm_node_t *p_node;
+
+ CL_ASSERT(sm);
+
+ OSM_LOG_ENTER(sm->p_log);
+
+ CL_ASSERT(p_madw);
+
+ p_smp = osm_madw_get_smp_ptr(p_madw);
+ p_ni = ib_smp_get_payload_ptr(p_smp);
+
+ CL_ASSERT(p_smp->attr_id == IB_MAD_ATTR_NODE_INFO);
+
+ if (PF(p_ni->node_guid == 0)) {
+ OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR 0D16: "
+ "Got Zero Node GUID! Found on the directed route:\n");
+ osm_dump_smp_dr_path_v2(sm->p_log, p_smp, FILE_ID, OSM_LOG_ERROR);
+ goto Exit;
+ }
+
+ if (PF(p_ni->port_guid == 0)) {
+ OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR 0D17: "
+ "Got Zero Port GUID! Found on the directed route:\n");
+ osm_dump_smp_dr_path_v2(sm->p_log, p_smp, FILE_ID, OSM_LOG_ERROR);
+ goto Exit;
+ }
+
+ if (ib_smp_get_status(p_smp)) {
+ OSM_LOG(sm->p_log, OSM_LOG_DEBUG,
+ "MAD status 0x%x received\n",
+ cl_ntoh16(ib_smp_get_status(p_smp)));
+ goto Exit;
+ }
+
+ /*
+ Determine if this node has already been discovered,
+ and process accordingly.
+ During processing of this node, hold the shared lock.
+ */
+
+ CL_PLOCK_EXCL_ACQUIRE(sm->p_lock);
+ p_node = osm_get_node_by_guid(sm->p_subn, p_ni->node_guid);
+
+ osm_dump_node_info_v2(sm->p_log, p_ni, FILE_ID, OSM_LOG_DEBUG);
+
+ if (!p_node)
+ ni_rcv_process_new(sm, p_madw);
+ else
+ ni_rcv_process_existing(sm, p_node, p_madw);
+
+ CL_PLOCK_RELEASE(sm->p_lock);
+
+Exit:
+ OSM_LOG_EXIT(sm->p_log);
+}
diff --git a/contrib/ofed/opensm/opensm/osm_opensm.c b/contrib/ofed/opensm/opensm/osm_opensm.c
new file mode 100644
index 0000000..f9c96d1
--- /dev/null
+++ b/contrib/ofed/opensm/opensm/osm_opensm.c
@@ -0,0 +1,579 @@
+/*
+ * Copyright (c) 2004-2009 Voltaire, Inc. All rights reserved.
+ * Copyright (c) 2002-2010 Mellanox Technologies LTD. All rights reserved.
+ * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
+ * Copyright (c) 2009-2011 ZIH, TU Dresden, Federal Republic of Germany. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+/*
+ * Abstract:
+ * Implementation of osm_opensm_t.
+ * This object represents the opensm super object.
+ * This object is part of the opensm family of objects.
+ */
+
+#if HAVE_CONFIG_H
+# include <config.h>
+#endif /* HAVE_CONFIG_H */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <complib/cl_dispatcher.h>
+#include <complib/cl_passivelock.h>
+#include <opensm/osm_file_ids.h>
+#define FILE_ID OSM_FILE_OPENSM_C
+#include <vendor/osm_vendor_api.h>
+#include <opensm/osm_version.h>
+#include <opensm/osm_base.h>
+#include <opensm/osm_opensm.h>
+#include <opensm/osm_log.h>
+#include <opensm/osm_subnet.h>
+#include <opensm/osm_sm.h>
+#include <opensm/osm_vl15intf.h>
+#include <opensm/osm_event_plugin.h>
+#include <opensm/osm_congestion_control.h>
+
+struct routing_engine_module {
+ const char *name;
+ int (*setup) (struct osm_routing_engine *, osm_opensm_t *);
+};
+
+extern int osm_ucast_minhop_setup(struct osm_routing_engine *, osm_opensm_t *);
+extern int osm_ucast_updn_setup(struct osm_routing_engine *, osm_opensm_t *);
+extern int osm_ucast_dnup_setup(struct osm_routing_engine *, osm_opensm_t *);
+extern int osm_ucast_file_setup(struct osm_routing_engine *, osm_opensm_t *);
+extern int osm_ucast_ftree_setup(struct osm_routing_engine *, osm_opensm_t *);
+extern int osm_ucast_lash_setup(struct osm_routing_engine *, osm_opensm_t *);
+extern int osm_ucast_dor_setup(struct osm_routing_engine *, osm_opensm_t *);
+extern int osm_ucast_torus2QoS_setup(struct osm_routing_engine *, osm_opensm_t *);
+extern int osm_ucast_sssp_setup(struct osm_routing_engine *, osm_opensm_t *);
+extern int osm_ucast_dfsssp_setup(struct osm_routing_engine *, osm_opensm_t *);
+
+const static struct routing_engine_module routing_modules[] = {
+ {"minhop", osm_ucast_minhop_setup},
+ {"updn", osm_ucast_updn_setup},
+ {"dnup", osm_ucast_dnup_setup},
+ {"file", osm_ucast_file_setup},
+ {"ftree", osm_ucast_ftree_setup},
+ {"lash", osm_ucast_lash_setup},
+ {"dor", osm_ucast_dor_setup},
+ {"torus-2QoS", osm_ucast_torus2QoS_setup},
+ {"dfsssp", osm_ucast_dfsssp_setup},
+ {"sssp", osm_ucast_sssp_setup},
+ {NULL, NULL}
+};
+
+const char *osm_routing_engine_type_str(IN osm_routing_engine_type_t type)
+{
+ switch (type) {
+ case OSM_ROUTING_ENGINE_TYPE_NONE:
+ return "none";
+ case OSM_ROUTING_ENGINE_TYPE_MINHOP:
+ return "minhop";
+ case OSM_ROUTING_ENGINE_TYPE_UPDN:
+ return "updn";
+ case OSM_ROUTING_ENGINE_TYPE_DNUP:
+ return "dnup";
+ case OSM_ROUTING_ENGINE_TYPE_FILE:
+ return "file";
+ case OSM_ROUTING_ENGINE_TYPE_FTREE:
+ return "ftree";
+ case OSM_ROUTING_ENGINE_TYPE_LASH:
+ return "lash";
+ case OSM_ROUTING_ENGINE_TYPE_DOR:
+ return "dor";
+ case OSM_ROUTING_ENGINE_TYPE_TORUS_2QOS:
+ return "torus-2QoS";
+ case OSM_ROUTING_ENGINE_TYPE_DFSSSP:
+ return "dfsssp";
+ case OSM_ROUTING_ENGINE_TYPE_SSSP:
+ return "sssp";
+ default:
+ break;
+ }
+ return "unknown";
+}
+
+osm_routing_engine_type_t osm_routing_engine_type(IN const char *str)
+{
+ /* For legacy reasons, consider a NULL pointer and the string
+ * "null" as the minhop routing engine.
+ */
+ if (!str || !strcasecmp(str, "null")
+ || !strcasecmp(str, "minhop"))
+ return OSM_ROUTING_ENGINE_TYPE_MINHOP;
+ else if (!strcasecmp(str, "none"))
+ return OSM_ROUTING_ENGINE_TYPE_NONE;
+ else if (!strcasecmp(str, "updn"))
+ return OSM_ROUTING_ENGINE_TYPE_UPDN;
+ else if (!strcasecmp(str, "dnup"))
+ return OSM_ROUTING_ENGINE_TYPE_DNUP;
+ else if (!strcasecmp(str, "file"))
+ return OSM_ROUTING_ENGINE_TYPE_FILE;
+ else if (!strcasecmp(str, "ftree"))
+ return OSM_ROUTING_ENGINE_TYPE_FTREE;
+ else if (!strcasecmp(str, "lash"))
+ return OSM_ROUTING_ENGINE_TYPE_LASH;
+ else if (!strcasecmp(str, "dor"))
+ return OSM_ROUTING_ENGINE_TYPE_DOR;
+ else if (!strcasecmp(str, "torus-2QoS"))
+ return OSM_ROUTING_ENGINE_TYPE_TORUS_2QOS;
+ else if (!strcasecmp(str, "sssp"))
+ return OSM_ROUTING_ENGINE_TYPE_SSSP;
+ else if (!strcasecmp(str, "dfsssp"))
+ return OSM_ROUTING_ENGINE_TYPE_DFSSSP;
+ else
+ return OSM_ROUTING_ENGINE_TYPE_UNKNOWN;
+}
+
+static void append_routing_engine(osm_opensm_t *osm,
+ struct osm_routing_engine *routing_engine)
+{
+ struct osm_routing_engine *r;
+
+ routing_engine->next = NULL;
+
+ if (!osm->routing_engine_list) {
+ osm->routing_engine_list = routing_engine;
+ return;
+ }
+
+ r = osm->routing_engine_list;
+ while (r->next)
+ r = r->next;
+
+ r->next = routing_engine;
+}
+
+static struct osm_routing_engine *setup_routing_engine(osm_opensm_t *osm,
+ const char *name)
+{
+ struct osm_routing_engine *re;
+ const struct routing_engine_module *m;
+
+ if (!strcmp(name, "no_fallback")) {
+ osm->no_fallback_routing_engine = TRUE;
+ return NULL;
+ }
+
+ for (m = routing_modules; m->name && *m->name; m++) {
+ if (!strcmp(m->name, name)) {
+ re = malloc(sizeof(struct osm_routing_engine));
+ if (!re) {
+ OSM_LOG(&osm->log, OSM_LOG_VERBOSE,
+ "memory allocation failed\n");
+ return NULL;
+ }
+ memset(re, 0, sizeof(struct osm_routing_engine));
+
+ re->name = m->name;
+ re->type = osm_routing_engine_type(m->name);
+ if (m->setup(re, osm)) {
+ OSM_LOG(&osm->log, OSM_LOG_VERBOSE,
+ "setup of routing"
+ " engine \'%s\' failed\n", name);
+ free(re);
+ return NULL;
+ }
+ OSM_LOG(&osm->log, OSM_LOG_DEBUG,
+ "\'%s\' routing engine set up\n", re->name);
+ if (re->type == OSM_ROUTING_ENGINE_TYPE_MINHOP)
+ osm->default_routing_engine = re;
+ return re;
+ }
+ }
+
+ OSM_LOG(&osm->log, OSM_LOG_ERROR,
+ "cannot find or setup routing engine \'%s\'\n", name);
+ return NULL;
+}
+
+static void setup_routing_engines(osm_opensm_t *osm, const char *engine_names)
+{
+ char *name, *str, *p;
+ struct osm_routing_engine *re;
+
+ if (engine_names && *engine_names) {
+ str = strdup(engine_names);
+ name = strtok_r(str, ", \t\n", &p);
+ while (name && *name) {
+ re = setup_routing_engine(osm, name);
+ if (re)
+ append_routing_engine(osm, re);
+ name = strtok_r(NULL, ", \t\n", &p);
+ }
+ free(str);
+ }
+ if (!osm->default_routing_engine)
+ setup_routing_engine(osm, "minhop");
+}
+
+void osm_opensm_construct(IN osm_opensm_t * p_osm)
+{
+ memset(p_osm, 0, sizeof(*p_osm));
+ p_osm->osm_version = OSM_VERSION;
+ osm_subn_construct(&p_osm->subn);
+ osm_db_construct(&p_osm->db);
+ osm_log_construct(&p_osm->log);
+}
+
+void osm_opensm_construct_finish(IN osm_opensm_t * p_osm)
+{
+ osm_sm_construct(&p_osm->sm);
+ osm_sa_construct(&p_osm->sa);
+ osm_mad_pool_construct(&p_osm->mad_pool);
+ p_osm->mad_pool_constructed = TRUE;
+ osm_vl15_construct(&p_osm->vl15);
+ p_osm->vl15_constructed = TRUE;
+}
+
+static void destroy_routing_engines(osm_opensm_t *osm)
+{
+ struct osm_routing_engine *r, *next;
+
+ next = osm->routing_engine_list;
+ while (next) {
+ r = next;
+ next = r->next;
+ if (r->destroy)
+ r->destroy(r->context);
+ free(r);
+ }
+}
+
+static void destroy_plugins(osm_opensm_t *osm)
+{
+ osm_epi_plugin_t *p;
+ /* remove from the list, and destroy it */
+ while (!cl_is_qlist_empty(&osm->plugin_list)){
+ p = (osm_epi_plugin_t *)cl_qlist_remove_head(&osm->plugin_list);
+ /* plugin is responsible for freeing its own resources */
+ osm_epi_destroy(p);
+ }
+}
+
+void osm_opensm_destroy(IN osm_opensm_t * p_osm)
+{
+ /* in case of shutdown through exit proc - no ^C */
+ osm_exit_flag = TRUE;
+
+ /*
+ * First of all, clear the is_sm bit.
+ */
+ if (p_osm->sm.mad_ctrl.h_bind)
+ osm_vendor_set_sm(p_osm->sm.mad_ctrl.h_bind, FALSE);
+
+#ifdef ENABLE_OSM_PERF_MGR
+ /* Shutdown the PerfMgr */
+ osm_perfmgr_shutdown(&p_osm->perfmgr);
+#endif /* ENABLE_OSM_PERF_MGR */
+
+ osm_congestion_control_shutdown(&p_osm->cc);
+
+ /* shut down the SM
+ * - make sure the SM sweeper thread exited
+ * - unbind from QP0 messages
+ */
+ osm_sm_shutdown(&p_osm->sm);
+
+ /* shut down the SA
+ * - unbind from QP1 messages
+ */
+ osm_sa_shutdown(&p_osm->sa);
+
+ /* cleanup all messages on VL15 fifo that were not sent yet */
+ osm_vl15_shutdown(&p_osm->vl15, &p_osm->mad_pool);
+
+ /* shut down the dispatcher - so no new messages cross */
+ cl_disp_shutdown(&p_osm->disp);
+ if (p_osm->sa_set_disp_initialized)
+ cl_disp_shutdown(&p_osm->sa_set_disp);
+
+ /* dump SA DB */
+ if ((p_osm->sm.p_subn->sm_state == IB_SMINFO_STATE_MASTER) &&
+ p_osm->subn.opt.sa_db_dump)
+ osm_sa_db_file_dump(p_osm);
+
+ /* do the destruction in reverse order as init */
+ destroy_plugins(p_osm);
+ destroy_routing_engines(p_osm);
+ osm_sa_destroy(&p_osm->sa);
+ osm_sm_destroy(&p_osm->sm);
+#ifdef ENABLE_OSM_PERF_MGR
+ osm_perfmgr_destroy(&p_osm->perfmgr);
+#endif /* ENABLE_OSM_PERF_MGR */
+ osm_congestion_control_destroy(&p_osm->cc);
+}
+
+void osm_opensm_destroy_finish(IN osm_opensm_t * p_osm)
+{
+ osm_db_destroy(&p_osm->db);
+ if (p_osm->vl15_constructed && p_osm->mad_pool_constructed)
+ osm_vl15_destroy(&p_osm->vl15, &p_osm->mad_pool);
+ if (p_osm->mad_pool_constructed)
+ osm_mad_pool_destroy(&p_osm->mad_pool);
+ p_osm->vl15_constructed = FALSE;
+ p_osm->mad_pool_constructed = FALSE;
+ osm_vendor_delete(&p_osm->p_vendor);
+ osm_subn_destroy(&p_osm->subn);
+ cl_disp_destroy(&p_osm->disp);
+ if (p_osm->sa_set_disp_initialized)
+ cl_disp_destroy(&p_osm->sa_set_disp);
+#ifdef HAVE_LIBPTHREAD
+ pthread_cond_destroy(&p_osm->stats.cond);
+ pthread_mutex_destroy(&p_osm->stats.mutex);
+#else
+ cl_event_destroy(&p_osm->stats.event);
+#endif
+ if (p_osm->node_name_map)
+ close_node_name_map(p_osm->node_name_map);
+ cl_plock_destroy(&p_osm->lock);
+
+ osm_log_destroy(&p_osm->log);
+}
+
+static void load_plugins(osm_opensm_t *osm, const char *plugin_names)
+{
+ osm_epi_plugin_t *epi;
+ char *p_names, *name, *p;
+
+ p_names = strdup(plugin_names);
+ name = strtok_r(p_names, ", \t\n", &p);
+ while (name && *name) {
+ epi = osm_epi_construct(osm, name);
+ if (!epi)
+ osm_log_v2(&osm->log, OSM_LOG_ERROR, FILE_ID,
+ "ERR 1000: cannot load plugin \'%s\'\n",
+ name);
+ else
+ cl_qlist_insert_tail(&osm->plugin_list, &epi->list);
+ name = strtok_r(NULL, " \t\n", &p);
+ }
+ free(p_names);
+}
+
+ib_api_status_t osm_opensm_init(IN osm_opensm_t * p_osm,
+ IN const osm_subn_opt_t * p_opt)
+{
+ ib_api_status_t status;
+
+ /* Can't use log macros here, since we're initializing the log */
+ osm_opensm_construct(p_osm);
+
+ if (p_opt->daemon)
+ p_osm->log.daemon = 1;
+
+ status = osm_log_init_v2(&p_osm->log, p_opt->force_log_flush,
+ p_opt->log_flags, p_opt->log_file,
+ p_opt->log_max_size, p_opt->accum_log_file);
+ if (status != IB_SUCCESS)
+ return status;
+ p_osm->log.log_prefix = p_opt->log_prefix;
+
+ /* If there is a log level defined - add the OSM_VERSION to it */
+ osm_log_v2(&p_osm->log,
+ osm_log_get_level(&p_osm->log) & (OSM_LOG_SYS ^ 0xFF),
+ FILE_ID, "%s\n", p_osm->osm_version);
+ /* Write the OSM_VERSION to the SYS_LOG */
+ osm_log_v2(&p_osm->log, OSM_LOG_SYS, FILE_ID, "%s\n", p_osm->osm_version); /* Format Waived */
+
+ OSM_LOG(&p_osm->log, OSM_LOG_FUNCS, "[\n"); /* Format Waived */
+
+ status = cl_plock_init(&p_osm->lock);
+ if (status != IB_SUCCESS)
+ goto Exit;
+
+#ifdef HAVE_LIBPTHREAD
+ pthread_mutex_init(&p_osm->stats.mutex, NULL);
+ pthread_cond_init(&p_osm->stats.cond, NULL);
+#else
+ status = cl_event_init(&p_osm->stats.event, FALSE);
+ if (status != IB_SUCCESS)
+ goto Exit;
+#endif
+
+ if (p_opt->single_thread) {
+ OSM_LOG(&p_osm->log, OSM_LOG_INFO,
+ "Forcing single threaded dispatcher\n");
+ status = cl_disp_init(&p_osm->disp, 1, "opensm");
+ } else {
+ /*
+ * Normal behavior is to initialize the dispatcher with
+ * one thread per CPU, as specified by a thread count of '0'.
+ */
+ status = cl_disp_init(&p_osm->disp, 0, "opensm");
+ }
+ if (status != IB_SUCCESS)
+ goto Exit;
+
+ /* Unless OpenSM runs in single threaded mode, we create new single
+ * threaded dispatcher for SA Set and Delete requets.
+ */
+ p_osm->sa_set_disp_initialized = FALSE;
+ if (!p_opt->single_thread) {
+ status = cl_disp_init(&p_osm->sa_set_disp, 1, "subnadmin_set");
+ if (status != IB_SUCCESS)
+ goto Exit;
+ p_osm->sa_set_disp_initialized = TRUE;
+ }
+
+ /* the DB is in use by subn so init before */
+ status = osm_db_init(&p_osm->db, &p_osm->log);
+ if (status != IB_SUCCESS)
+ goto Exit;
+
+ status = osm_subn_init(&p_osm->subn, p_osm, p_opt);
+ if (status != IB_SUCCESS)
+ goto Exit;
+
+ p_osm->p_vendor =
+ osm_vendor_new(&p_osm->log, p_opt->transaction_timeout);
+ if (p_osm->p_vendor == NULL)
+ status = IB_INSUFFICIENT_RESOURCES;
+
+Exit:
+ OSM_LOG(&p_osm->log, OSM_LOG_FUNCS, "]\n"); /* Format Waived */
+ return status;
+}
+
+ib_api_status_t osm_opensm_init_finish(IN osm_opensm_t * p_osm,
+ IN const osm_subn_opt_t * p_opt)
+{
+ ib_api_status_t status;
+
+ osm_opensm_construct_finish(p_osm);
+
+ p_osm->subn.sm_port_guid = p_opt->guid;
+
+ status = osm_mad_pool_init(&p_osm->mad_pool);
+ if (status != IB_SUCCESS)
+ goto Exit;
+
+ status = osm_vl15_init(&p_osm->vl15, p_osm->p_vendor,
+ &p_osm->log, &p_osm->stats, &p_osm->subn,
+ p_opt->max_wire_smps, p_opt->max_wire_smps2,
+ p_opt->max_smps_timeout);
+ if (status != IB_SUCCESS)
+ goto Exit;
+
+ status = osm_sm_init(&p_osm->sm, &p_osm->subn, &p_osm->db,
+ p_osm->p_vendor, &p_osm->mad_pool, &p_osm->vl15,
+ &p_osm->log, &p_osm->stats, &p_osm->disp,
+ &p_osm->lock);
+ if (status != IB_SUCCESS)
+ goto Exit;
+
+ status = osm_sa_init(&p_osm->sm, &p_osm->sa, &p_osm->subn,
+ p_osm->p_vendor, &p_osm->mad_pool, &p_osm->log,
+ &p_osm->stats, &p_osm->disp,
+ p_opt->single_thread ? NULL : &p_osm->sa_set_disp,
+ &p_osm->lock);
+ if (status != IB_SUCCESS)
+ goto Exit;
+
+ cl_qlist_init(&p_osm->plugin_list);
+
+ if (p_opt->event_plugin_name)
+ load_plugins(p_osm, p_opt->event_plugin_name);
+
+#ifdef ENABLE_OSM_PERF_MGR
+ status = osm_perfmgr_init(&p_osm->perfmgr, p_osm, p_opt);
+ if (status != IB_SUCCESS)
+ goto Exit;
+#endif /* ENABLE_OSM_PERF_MGR */
+
+ status = osm_congestion_control_init(&p_osm->cc,
+ p_osm, p_opt);
+ if (status != IB_SUCCESS)
+ goto Exit;
+
+ p_osm->no_fallback_routing_engine = FALSE;
+
+ setup_routing_engines(p_osm, p_opt->routing_engine_names);
+
+ p_osm->routing_engine_used = NULL /* OSM_ROUTING_ENGINE_TYPE_NONE */;
+
+ p_osm->node_name_map = open_node_name_map(p_opt->node_name_map_name);
+
+Exit:
+ OSM_LOG(&p_osm->log, OSM_LOG_FUNCS, "]\n"); /* Format Waived */
+ return status;
+}
+
+ib_api_status_t osm_opensm_bind(IN osm_opensm_t * p_osm, IN ib_net64_t guid)
+{
+ ib_api_status_t status;
+
+ OSM_LOG_ENTER(&p_osm->log);
+
+ status = osm_sm_bind(&p_osm->sm, guid);
+ if (status != IB_SUCCESS)
+ goto Exit;
+
+ status = osm_sa_bind(&p_osm->sa, guid);
+ if (status != IB_SUCCESS)
+ goto Exit;
+
+#ifdef ENABLE_OSM_PERF_MGR
+ status = osm_perfmgr_bind(&p_osm->perfmgr, guid);
+ if (status != IB_SUCCESS)
+ goto Exit;
+#endif /* ENABLE_OSM_PERF_MGR */
+
+ status = osm_congestion_control_bind(&p_osm->cc, guid);
+ if (status != IB_SUCCESS)
+ goto Exit;
+
+ /* setting IS_SM in capability mask */
+ OSM_LOG(&p_osm->log, OSM_LOG_INFO, "Setting IS_SM on port 0x%016" PRIx64 "\n",
+ cl_ntoh64(guid));
+ osm_vendor_set_sm(p_osm->sm.mad_ctrl.h_bind, TRUE);
+
+Exit:
+ OSM_LOG_EXIT(&p_osm->log);
+ return status;
+}
+
+void osm_opensm_report_event(osm_opensm_t *osm, osm_epi_event_id_t event_id,
+ void *event_data)
+{
+ cl_list_item_t *item;
+
+ for (item = cl_qlist_head(&osm->plugin_list);
+ !osm_exit_flag && item != cl_qlist_end(&osm->plugin_list);
+ item = cl_qlist_next(item)) {
+ osm_epi_plugin_t *p = (osm_epi_plugin_t *)item;
+ if (p->impl->report)
+ p->impl->report(p->plugin_data, event_id, event_data);
+ }
+}
diff --git a/contrib/ofed/opensm/opensm/osm_perfmgr.c b/contrib/ofed/opensm/opensm/osm_perfmgr.c
new file mode 100644
index 0000000..3116cb3
--- /dev/null
+++ b/contrib/ofed/opensm/opensm/osm_perfmgr.c
@@ -0,0 +1,2035 @@
+/*
+ * Copyright (c) 2007 The Regents of the University of California.
+ * Copyright (c) 2007-2009 Voltaire, Inc. All rights reserved.
+ * Copyright (c) 2009,2010 HNR Consulting. All rights reserved.
+ * Copyright (c) 2013 Lawrence Livermore National Security. All rights reserved.
+ * Copyright (c) 2011-2014 Mellanox Technologies LTD. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+/*
+ * Abstract:
+ * Implementation of osm_perfmgr_t.
+ * This object implements an IBA performance manager.
+ *
+ * Author:
+ * Ira Weiny, LLNL
+ */
+
+#if HAVE_CONFIG_H
+# include <config.h>
+#endif /* HAVE_CONFIG_H */
+
+#ifdef ENABLE_OSM_PERF_MGR
+#include <stdlib.h>
+#include <stdint.h>
+#include <string.h>
+#include <poll.h>
+#include <errno.h>
+#include <sys/time.h>
+#include <netinet/in.h>
+#include <float.h>
+#include <arpa/inet.h>
+#include <sys/socket.h>
+#include <iba/ib_types.h>
+#include <complib/cl_debug.h>
+#include <complib/cl_thread.h>
+#include <opensm/osm_file_ids.h>
+#define FILE_ID OSM_FILE_PERFMGR_C
+#include <vendor/osm_vendor_api.h>
+#include <opensm/osm_perfmgr.h>
+#include <opensm/osm_log.h>
+#include <opensm/osm_node.h>
+#include <opensm/osm_opensm.h>
+#include <opensm/osm_helper.h>
+
+#define PERFMGR_INITIAL_TID_VALUE 0xcafe
+
+#ifdef ENABLE_OSM_PERF_MGR_PROFILE
+struct {
+ double fastest_us;
+ double slowest_us;
+ double avg_us;
+ uint64_t num;
+} perfmgr_mad_stats = {
+fastest_us: DBL_MAX, slowest_us: DBL_MIN, avg_us: 0, num:0};
+
+/* diff must be something which can fit in a susecond_t */
+static inline void update_mad_stats(struct timeval *diff)
+{
+ double new = (diff->tv_sec * 1000000) + diff->tv_usec;
+ if (new < perfmgr_mad_stats.fastest_us)
+ perfmgr_mad_stats.fastest_us = new;
+ if (new > perfmgr_mad_stats.slowest_us)
+ perfmgr_mad_stats.slowest_us = new;
+
+ perfmgr_mad_stats.avg_us =
+ ((perfmgr_mad_stats.avg_us * perfmgr_mad_stats.num) + new)
+ / (perfmgr_mad_stats.num + 1);
+ perfmgr_mad_stats.num++;
+}
+
+static inline void clear_mad_stats(void)
+{
+ perfmgr_mad_stats.fastest_us = DBL_MAX;
+ perfmgr_mad_stats.slowest_us = DBL_MIN;
+ perfmgr_mad_stats.avg_us = 0;
+ perfmgr_mad_stats.num = 0;
+}
+
+/* after and diff can be the same struct */
+static inline void diff_time(struct timeval *before, struct timeval *after,
+ struct timeval *diff)
+{
+ struct timeval tmp = *after;
+ if (tmp.tv_usec < before->tv_usec) {
+ tmp.tv_sec--;
+ tmp.tv_usec += 1000000;
+ }
+ diff->tv_sec = tmp.tv_sec - before->tv_sec;
+ diff->tv_usec = tmp.tv_usec - before->tv_usec;
+}
+#endif
+
+/**********************************************************************
+ * Internal helper functions
+ **********************************************************************/
+static void init_monitored_nodes(osm_perfmgr_t * pm)
+{
+ cl_qmap_init(&pm->monitored_map);
+ pm->remove_list = NULL;
+ cl_event_construct(&pm->sig_query);
+ cl_event_init(&pm->sig_query, FALSE);
+}
+
+static void mark_for_removal(osm_perfmgr_t * pm, monitored_node_t * node)
+{
+ if (pm->remove_list) {
+ node->next = pm->remove_list;
+ pm->remove_list = node;
+ } else {
+ node->next = NULL;
+ pm->remove_list = node;
+ }
+}
+
+static void remove_marked_nodes(osm_perfmgr_t * pm)
+{
+ while (pm->remove_list) {
+ monitored_node_t *next = pm->remove_list->next;
+ int port;
+
+ cl_qmap_remove_item(&pm->monitored_map,
+ (cl_map_item_t *) (pm->remove_list));
+
+ if (pm->rm_nodes)
+ perfmgr_db_delete_entry(pm->db, pm->remove_list->guid);
+ else
+ perfmgr_db_mark_active(pm->db, pm->remove_list->guid, FALSE);
+
+ if (pm->remove_list->name)
+ free(pm->remove_list->name);
+
+ for (port = pm->remove_list->esp0 ? 0 : 1;
+ port < pm->remove_list->num_ports;
+ port++) {
+ if (pm->remove_list->port[port].remote_name)
+ free(pm->remove_list->port[port].remote_name);
+ }
+
+ free(pm->remove_list);
+ pm->remove_list = next;
+ }
+}
+
+static inline void decrement_outstanding_queries(osm_perfmgr_t * pm)
+{
+ cl_atomic_dec(&pm->outstanding_queries);
+
+ if (!pm->outstanding_queries) {
+ cl_spinlock_acquire(&pm->lock);
+ if (pm->sweep_state == PERFMGR_SWEEP_POST_PROCESSING) {
+ pm->sweep_state = PERFMGR_SWEEP_SLEEP;
+ OSM_LOG(pm->log, OSM_LOG_INFO,
+ "PM sweep state exiting Post Processing\n");
+ }
+ cl_spinlock_release(&pm->lock);
+ }
+
+ cl_event_signal(&pm->sig_query);
+}
+
+/**********************************************************************
+ * Receive the MAD from the vendor layer and post it for processing by
+ * the dispatcher
+ **********************************************************************/
+static void perfmgr_mad_recv_callback(osm_madw_t * p_madw, void *bind_context,
+ osm_madw_t * p_req_madw)
+{
+ osm_perfmgr_t *pm = (osm_perfmgr_t *) bind_context;
+
+ OSM_LOG_ENTER(pm->log);
+
+ CL_ASSERT(p_madw);
+ CL_ASSERT(p_req_madw != NULL);
+
+ osm_madw_copy_context(p_madw, p_req_madw);
+ osm_mad_pool_put(pm->mad_pool, p_req_madw);
+
+ decrement_outstanding_queries(pm);
+
+ /* post this message for later processing. */
+ if (cl_disp_post(pm->pc_disp_h, OSM_MSG_MAD_PORT_COUNTERS,
+ p_madw, NULL, NULL) != CL_SUCCESS) {
+ OSM_LOG(pm->log, OSM_LOG_ERROR, "ERR 5401: "
+ "PerfMgr Dispatcher post failed\n");
+ osm_mad_pool_put(pm->mad_pool, p_madw);
+ }
+ OSM_LOG_EXIT(pm->log);
+}
+
+/**********************************************************************
+ * Process MAD send errors
+ **********************************************************************/
+static void perfmgr_mad_send_err_callback(void *bind_context,
+ osm_madw_t * p_madw)
+{
+ osm_perfmgr_t *pm = (osm_perfmgr_t *) bind_context;
+ osm_madw_context_t *context = &p_madw->context;
+ uint64_t node_guid = context->perfmgr_context.node_guid;
+ uint8_t port = context->perfmgr_context.port;
+ cl_map_item_t *p_node;
+ monitored_node_t *p_mon_node;
+ ib_net16_t orig_lid;
+
+ OSM_LOG_ENTER(pm->log);
+
+ /*
+ * get the monitored node struct to have the printable name
+ * for log messages
+ */
+ if ((p_node = cl_qmap_get(&pm->monitored_map, node_guid)) ==
+ cl_qmap_end(&pm->monitored_map)) {
+ OSM_LOG(pm->log, OSM_LOG_ERROR, "ERR 5415: GUID 0x%016"
+ PRIx64 " not found in monitored map\n", node_guid);
+ goto Exit;
+ }
+ p_mon_node = (monitored_node_t *) p_node;
+
+ OSM_LOG(pm->log, OSM_LOG_ERROR, "ERR 5402: %s (0x%" PRIx64
+ ") port %u LID %u TID 0x%" PRIx64 "\n",
+ p_mon_node->name, p_mon_node->guid, port,
+ cl_ntoh16(p_madw->mad_addr.dest_lid),
+ cl_ntoh64(p_madw->p_mad->trans_id));
+
+ if (pm->subn->opt.perfmgr_redir && p_madw->status == IB_TIMEOUT) {
+ /* First, find the node in the monitored map */
+ cl_plock_acquire(&pm->osm->lock);
+ /* Now, validate port number */
+ if (port >= p_mon_node->num_ports) {
+ cl_plock_release(&pm->osm->lock);
+ OSM_LOG(pm->log, OSM_LOG_ERROR, "ERR 5416: "
+ "Invalid port num %u for %s (GUID 0x%016"
+ PRIx64 ") num ports %u\n", port,
+ p_mon_node->name, p_mon_node->guid,
+ p_mon_node->num_ports);
+ goto Exit;
+ }
+ /* Clear redirection info for this port except orig_lid */
+ orig_lid = p_mon_node->port[port].orig_lid;
+ memset(&p_mon_node->port[port], 0, sizeof(monitored_port_t));
+ p_mon_node->port[port].orig_lid = orig_lid;
+ p_mon_node->port[port].valid = TRUE;
+ cl_plock_release(&pm->osm->lock);
+ }
+
+Exit:
+ osm_mad_pool_put(pm->mad_pool, p_madw);
+
+ decrement_outstanding_queries(pm);
+
+ OSM_LOG_EXIT(pm->log);
+}
+
+/**********************************************************************
+ * Bind the PerfMgr to the vendor layer for MAD sends/receives
+ **********************************************************************/
+ib_api_status_t osm_perfmgr_bind(osm_perfmgr_t * pm, ib_net64_t port_guid)
+{
+ osm_bind_info_t bind_info;
+ ib_api_status_t status = IB_SUCCESS;
+
+ OSM_LOG_ENTER(pm->log);
+
+ if (pm->bind_handle != OSM_BIND_INVALID_HANDLE) {
+ OSM_LOG(pm->log, OSM_LOG_ERROR,
+ "ERR 5403: Multiple binds not allowed\n");
+ status = IB_ERROR;
+ goto Exit;
+ }
+
+ bind_info.port_guid = pm->port_guid = port_guid;
+ bind_info.mad_class = IB_MCLASS_PERF;
+ bind_info.class_version = 1;
+ bind_info.is_responder = FALSE;
+ bind_info.is_report_processor = FALSE;
+ bind_info.is_trap_processor = FALSE;
+ bind_info.recv_q_size = OSM_PM_DEFAULT_QP1_RCV_SIZE;
+ bind_info.send_q_size = OSM_PM_DEFAULT_QP1_SEND_SIZE;
+ bind_info.timeout = pm->subn->opt.transaction_timeout;
+ bind_info.retries = pm->subn->opt.transaction_retries;
+
+ OSM_LOG(pm->log, OSM_LOG_VERBOSE,
+ "Binding to port GUID 0x%" PRIx64 "\n", cl_ntoh64(port_guid));
+
+ pm->bind_handle = osm_vendor_bind(pm->vendor, &bind_info, pm->mad_pool,
+ perfmgr_mad_recv_callback,
+ perfmgr_mad_send_err_callback, pm);
+
+ if (pm->bind_handle == OSM_BIND_INVALID_HANDLE) {
+ status = IB_ERROR;
+ OSM_LOG(pm->log, OSM_LOG_ERROR,
+ "ERR 5404: Vendor specific bind failed (%s)\n",
+ ib_get_err_str(status));
+ }
+
+Exit:
+ OSM_LOG_EXIT(pm->log);
+ return status;
+}
+
+/**********************************************************************
+ * Unbind the PerfMgr from the vendor layer for MAD sends/receives
+ **********************************************************************/
+static void perfmgr_mad_unbind(osm_perfmgr_t * pm)
+{
+ OSM_LOG_ENTER(pm->log);
+ if (pm->bind_handle == OSM_BIND_INVALID_HANDLE) {
+ OSM_LOG(pm->log, OSM_LOG_ERROR, "ERR 5405: No previous bind\n");
+ goto Exit;
+ }
+ osm_vendor_unbind(pm->bind_handle);
+Exit:
+ OSM_LOG_EXIT(pm->log);
+}
+
+/**********************************************************************
+ * Given a monitored node and a port, return the qp
+ **********************************************************************/
+static ib_net32_t get_qp(monitored_node_t * mon_node, uint8_t port)
+{
+ ib_net32_t qp = IB_QP1;
+
+ if (mon_node && mon_node->num_ports && port < mon_node->num_ports &&
+ mon_node->port[port].redirection && mon_node->port[port].qp)
+ qp = mon_node->port[port].qp;
+
+ return qp;
+}
+
+static ib_net16_t get_base_lid(osm_node_t * p_node, uint8_t port)
+{
+ switch (p_node->node_info.node_type) {
+ case IB_NODE_TYPE_CA:
+ case IB_NODE_TYPE_ROUTER:
+ return osm_node_get_base_lid(p_node, port);
+ case IB_NODE_TYPE_SWITCH:
+ return osm_node_get_base_lid(p_node, 0);
+ default:
+ return 0;
+ }
+}
+
+/**********************************************************************
+ * Given a node, a port, and an optional monitored node,
+ * return the lid appropriate to query that port
+ **********************************************************************/
+static ib_net16_t get_lid(osm_node_t * p_node, uint8_t port,
+ monitored_node_t * mon_node)
+{
+ if (mon_node && mon_node->num_ports && port < mon_node->num_ports &&
+ mon_node->port[port].lid)
+ return mon_node->port[port].lid;
+
+ return get_base_lid(p_node, port);
+}
+
+/**********************************************************************
+ * Build a Performance Management class MAD
+ **********************************************************************/
+static osm_madw_t *perfmgr_build_mad(osm_perfmgr_t * perfmgr,
+ ib_net16_t dest_lid,
+ uint8_t sl,
+ ib_net32_t dest_qp,
+ uint16_t pkey_ix,
+ uint8_t mad_method,
+ ib_net16_t attr_id,
+ osm_madw_context_t * p_context,
+ ib_perfmgt_mad_t ** p_pm_mad)
+{
+ ib_perfmgt_mad_t *pm_mad = NULL;
+ osm_madw_t *p_madw = NULL;
+
+ OSM_LOG_ENTER(perfmgr->log);
+
+ p_madw = osm_mad_pool_get(perfmgr->mad_pool, perfmgr->bind_handle,
+ MAD_BLOCK_SIZE, NULL);
+ if (p_madw == NULL)
+ return NULL;
+
+ pm_mad = osm_madw_get_perfmgt_mad_ptr(p_madw);
+
+ /* build the mad */
+ pm_mad->header.base_ver = 1;
+ pm_mad->header.mgmt_class = IB_MCLASS_PERF;
+ pm_mad->header.class_ver = 1;
+ pm_mad->header.method = mad_method;
+ pm_mad->header.status = 0;
+ pm_mad->header.class_spec = 0;
+ pm_mad->header.trans_id =
+ cl_hton64((uint64_t) cl_atomic_inc(&perfmgr->trans_id) &
+ (uint64_t) (0xFFFFFFFF));
+ if (perfmgr->trans_id == 0)
+ pm_mad->header.trans_id =
+ cl_hton64((uint64_t) cl_atomic_inc(&perfmgr->trans_id) &
+ (uint64_t) (0xFFFFFFFF));
+ pm_mad->header.attr_id = attr_id;
+ pm_mad->header.resv = 0;
+ pm_mad->header.attr_mod = 0;
+
+ p_madw->mad_addr.dest_lid = dest_lid;
+ p_madw->mad_addr.addr_type.gsi.remote_qp = dest_qp;
+ p_madw->mad_addr.addr_type.gsi.remote_qkey =
+ cl_hton32(IB_QP1_WELL_KNOWN_Q_KEY);
+ p_madw->mad_addr.addr_type.gsi.pkey_ix = pkey_ix;
+ p_madw->mad_addr.addr_type.gsi.service_level = sl;
+ p_madw->mad_addr.addr_type.gsi.global_route = FALSE;
+ p_madw->resp_expected = TRUE;
+
+ if (p_context)
+ p_madw->context = *p_context;
+
+ if (p_pm_mad)
+ *p_pm_mad = pm_mad;
+
+ OSM_LOG_EXIT(perfmgr->log);
+
+ return (p_madw);
+}
+
+/**********************************************************************
+ * Send a Performance Management class MAD
+ **********************************************************************/
+static ib_api_status_t perfmgr_send_mad(osm_perfmgr_t *perfmgr,
+ osm_madw_t * const p_madw)
+{
+ cl_status_t sts;
+ ib_api_status_t status = osm_vendor_send(perfmgr->bind_handle, p_madw,
+ TRUE);
+ if (status == IB_SUCCESS) {
+ /* pause thread if there are too many outstanding requests */
+ cl_atomic_inc(&(perfmgr->outstanding_queries));
+ while (perfmgr->outstanding_queries >
+ (int32_t)perfmgr->max_outstanding_queries) {
+ cl_spinlock_acquire(&perfmgr->lock);
+ if (perfmgr->sweep_state == PERFMGR_SWEEP_SLEEP) {
+ perfmgr->sweep_state = PERFMGR_SWEEP_POST_PROCESSING;
+ OSM_LOG(perfmgr->log, OSM_LOG_INFO,
+ "PM sweep state going into Post Processing\n");
+ } else if (perfmgr->sweep_state == PERFMGR_SWEEP_ACTIVE)
+ perfmgr->sweep_state = PERFMGR_SWEEP_SUSPENDED;
+ cl_spinlock_release(&perfmgr->lock);
+wait:
+ sts = cl_event_wait_on(&perfmgr->sig_query,
+ EVENT_NO_TIMEOUT, TRUE);
+ if (sts != CL_SUCCESS)
+ goto wait;
+
+ cl_spinlock_acquire(&perfmgr->lock);
+ if (perfmgr->sweep_state == PERFMGR_SWEEP_SUSPENDED)
+ perfmgr->sweep_state = PERFMGR_SWEEP_ACTIVE;
+ cl_spinlock_release(&perfmgr->lock);
+ }
+ }
+ return (status);
+}
+
+
+/**********************************************************************
+ * Form and send the PortCounters MAD for a single port
+ **********************************************************************/
+static ib_api_status_t perfmgr_send_pc_mad(osm_perfmgr_t * perfmgr,
+ ib_net16_t dest_lid,
+ ib_net32_t dest_qp, uint16_t pkey_ix,
+ uint8_t port, uint8_t mad_method,
+ uint16_t counter_select,
+ uint8_t counter_select2,
+ osm_madw_context_t * p_context,
+ uint8_t sl)
+{
+ ib_api_status_t status = IB_SUCCESS;
+ ib_port_counters_t *port_counter = NULL;
+ ib_perfmgt_mad_t *pm_mad = NULL;
+ osm_madw_t *p_madw = NULL;
+
+ OSM_LOG_ENTER(perfmgr->log);
+
+ p_context->perfmgr_context.mad_attr_id = IB_MAD_ATTR_PORT_CNTRS;
+ p_madw = perfmgr_build_mad(perfmgr, dest_lid, sl, dest_qp, pkey_ix,
+ mad_method, IB_MAD_ATTR_PORT_CNTRS, p_context,
+ &pm_mad);
+ if (p_madw == NULL)
+ return IB_INSUFFICIENT_MEMORY;
+
+ port_counter = (ib_port_counters_t *) & pm_mad->data;
+ memset(port_counter, 0, sizeof(*port_counter));
+ port_counter->port_select = port;
+ port_counter->counter_select = cl_hton16(counter_select);
+ port_counter->counter_select2 = counter_select2;
+
+ status = perfmgr_send_mad(perfmgr, p_madw);
+
+ OSM_LOG_EXIT(perfmgr->log);
+ return status;
+}
+
+/**********************************************************************
+ * sweep the node_guid_tbl and collect the node guids to be tracked
+ **********************************************************************/
+static void collect_guids(cl_map_item_t * p_map_item, void *context)
+{
+ osm_node_t *node = (osm_node_t *) p_map_item;
+ uint64_t node_guid = cl_ntoh64(node->node_info.node_guid);
+ osm_perfmgr_t *pm = (osm_perfmgr_t *) context;
+ monitored_node_t *mon_node = NULL;
+ uint32_t num_ports;
+ int port;
+
+ OSM_LOG_ENTER(pm->log);
+
+ if (cl_qmap_get(&pm->monitored_map, node_guid) ==
+ cl_qmap_end(&pm->monitored_map)) {
+
+ if (pm->ignore_cas &&
+ (node->node_info.node_type == IB_NODE_TYPE_CA))
+ goto Exit;
+
+ /* if not already in map add it */
+ num_ports = osm_node_get_num_physp(node);
+ mon_node = malloc(sizeof(*mon_node) +
+ sizeof(monitored_port_t) * num_ports);
+ if (!mon_node) {
+ OSM_LOG(pm->log, OSM_LOG_ERROR, "PerfMgr: ERR 5406: "
+ "malloc failed: not handling node %s"
+ "(GUID 0x%" PRIx64 ")\n", node->print_desc,
+ node_guid);
+ goto Exit;
+ }
+ memset(mon_node, 0,
+ sizeof(*mon_node) + sizeof(monitored_port_t) * num_ports);
+ mon_node->guid = node_guid;
+ mon_node->name = strdup(node->print_desc);
+ mon_node->num_ports = num_ports;
+ mon_node->node_type = node->node_info.node_type;
+ /* check for enhanced switch port 0 */
+ mon_node->esp0 = (node->sw &&
+ ib_switch_info_is_enhanced_port0(&node->sw->
+ switch_info));
+ for (port = mon_node->esp0 ? 0 : 1; port < num_ports; port++) {
+ monitored_port_t *mon_port = &mon_node->port[port];
+ osm_physp_t *p_physp = &node->physp_table[port];
+ osm_physp_t *p_remote_physp = p_physp->p_remote_physp;
+
+ mon_port->orig_lid = 0;
+ mon_port->valid = FALSE;
+ if (osm_physp_is_valid(p_physp)) {
+ mon_port->orig_lid = get_base_lid(node, port);
+ mon_port->valid = TRUE;
+ }
+ mon_port->remote_valid = FALSE;
+ mon_port->remote_name = NULL;
+ if (p_remote_physp && osm_physp_is_valid(p_remote_physp)) {
+ osm_node_t *p_remote_node = p_remote_physp->p_node;
+ mon_port->remote_valid = TRUE;
+ mon_port->remote_guid = p_remote_node->node_info.node_guid;
+ mon_port->remote_name = strdup(p_remote_node->print_desc);
+ mon_port->remote_port = p_remote_physp->port_num;
+ }
+ }
+
+ cl_qmap_insert(&pm->monitored_map, node_guid,
+ (cl_map_item_t *) mon_node);
+ }
+
+Exit:
+ OSM_LOG_EXIT(pm->log);
+}
+
+/**********************************************************************
+ * Form and send the ClassPortInfo MAD for a single port
+ **********************************************************************/
+static ib_api_status_t perfmgr_send_cpi_mad(osm_perfmgr_t * pm,
+ ib_net16_t dest_lid,
+ ib_net32_t dest_qp,
+ uint16_t pkey_ix,
+ uint8_t port,
+ osm_madw_context_t * p_context,
+ uint8_t sl)
+{
+ ib_api_status_t status = IB_SUCCESS;
+ osm_madw_t *p_madw = NULL;
+
+ OSM_LOG_ENTER(pm->log);
+
+ p_context->perfmgr_context.mad_attr_id = IB_MAD_ATTR_CLASS_PORT_INFO;
+ p_madw = perfmgr_build_mad(pm, dest_lid, sl, dest_qp,
+ pkey_ix, IB_MAD_METHOD_GET,
+ IB_MAD_ATTR_CLASS_PORT_INFO, p_context,
+ NULL);
+ if (p_madw == NULL)
+ return IB_INSUFFICIENT_MEMORY;
+
+ status = perfmgr_send_mad(pm, p_madw);
+
+ OSM_LOG_EXIT(pm->log);
+ return status;
+}
+
+/**********************************************************************
+ * return if some form of PortCountersExtended (PCE || PCE NoIETF) are supported
+ **********************************************************************/
+static inline boolean_t pce_supported(monitored_node_t *mon_node, uint8_t port)
+{
+ monitored_port_t *mon_port = &(mon_node->port[port]);
+ return (mon_port->cpi_valid
+ && (mon_port->cap_mask & IB_PM_EXT_WIDTH_SUPPORTED
+ || mon_port->cap_mask & IB_PM_EXT_WIDTH_NOIETF_SUP));
+}
+
+/**********************************************************************
+ * return if CapMask.PortCountersXmitWaitSupported is set
+ **********************************************************************/
+static inline boolean_t xmit_wait_supported(monitored_node_t *mon_node, uint8_t port)
+{
+ monitored_port_t *mon_port = &(mon_node->port[port]);
+ return (mon_port->cpi_valid
+ && (mon_port->cap_mask & IB_PM_PC_XMIT_WAIT_SUP));
+}
+
+/**********************************************************************
+ * return if "full" PortCountersExtended (IETF) is indicated
+ **********************************************************************/
+static inline boolean_t ietf_supported(monitored_node_t *mon_node, uint8_t port)
+{
+ monitored_port_t *mon_port = &(mon_node->port[port]);
+ return (mon_port->cpi_valid
+ && (mon_port->cap_mask & IB_PM_EXT_WIDTH_SUPPORTED));
+}
+
+/**********************************************************************
+ * Form and send the PortCountersExtended MAD for a single port
+ **********************************************************************/
+static ib_api_status_t perfmgr_send_pce_mad(osm_perfmgr_t * perfmgr,
+ ib_net16_t dest_lid,
+ ib_net32_t dest_qp,
+ uint16_t pkey_ix,
+ uint8_t port, uint8_t mad_method,
+ osm_madw_context_t * p_context,
+ uint8_t sl)
+{
+ ib_api_status_t status = IB_SUCCESS;
+ ib_port_counters_ext_t *port_counter_ext = NULL;
+ ib_perfmgt_mad_t *pm_mad = NULL;
+ osm_madw_t *p_madw = NULL;
+
+ OSM_LOG_ENTER(perfmgr->log);
+
+ p_context->perfmgr_context.mad_attr_id = IB_MAD_ATTR_PORT_CNTRS_EXT;
+ p_madw = perfmgr_build_mad(perfmgr, dest_lid, sl, dest_qp, pkey_ix,
+ mad_method, IB_MAD_ATTR_PORT_CNTRS_EXT, p_context,
+ &pm_mad);
+ if (p_madw == NULL)
+ return IB_INSUFFICIENT_MEMORY;
+
+ port_counter_ext = (ib_port_counters_ext_t *) & pm_mad->data;
+ memset(port_counter_ext, 0, sizeof(*port_counter_ext));
+ port_counter_ext->port_select = port;
+ port_counter_ext->counter_select = cl_hton16(0x00FF);
+
+ status = perfmgr_send_mad(perfmgr, p_madw);
+
+ OSM_LOG_EXIT(perfmgr->log);
+ return status;
+}
+
+/**********************************************************************
+ * query the Port Counters of all the nodes in the subnet
+ **********************************************************************/
+static void perfmgr_query_counters(cl_map_item_t * p_map_item, void *context)
+{
+ ib_api_status_t status = IB_SUCCESS;
+ osm_perfmgr_t *pm = context;
+ osm_node_t *node = NULL;
+ monitored_node_t *mon_node = (monitored_node_t *) p_map_item;
+ osm_madw_context_t mad_context;
+ uint64_t node_guid = 0;
+ ib_net32_t remote_qp;
+ uint8_t port, num_ports = 0;
+
+ OSM_LOG_ENTER(pm->log);
+
+ cl_plock_acquire(&pm->osm->lock);
+ node = osm_get_node_by_guid(pm->subn, cl_hton64(mon_node->guid));
+ if (!node) {
+ OSM_LOG(pm->log, OSM_LOG_ERROR,
+ "ERR 5407: Node \"%s\" (guid 0x%" PRIx64
+ ") no longer exists so removing from PerfMgr monitoring\n",
+ mon_node->name, mon_node->guid);
+ mark_for_removal(pm, mon_node);
+ goto Exit;
+ }
+
+ num_ports = osm_node_get_num_physp(node);
+ node_guid = cl_ntoh64(node->node_info.node_guid);
+
+ /* make sure there is a database object ready to store this info */
+ if (perfmgr_db_create_entry(pm->db, node_guid, mon_node->esp0,
+ num_ports, node->print_desc) !=
+ PERFMGR_EVENT_DB_SUCCESS) {
+ OSM_LOG(pm->log, OSM_LOG_ERROR,
+ "ERR 5408: DB create entry failed for 0x%"
+ PRIx64 " (%s) : %s\n", node_guid, node->print_desc,
+ strerror(errno));
+ goto Exit;
+ }
+
+ perfmgr_db_mark_active(pm->db, node_guid, TRUE);
+
+ /* issue the query for each port */
+ for (port = mon_node->esp0 ? 0 : 1; port < num_ports; port++) {
+ ib_net16_t lid;
+
+ if (!osm_node_get_physp_ptr(node, port))
+ continue;
+
+ if (!mon_node->port[port].valid)
+ continue;
+
+ lid = get_lid(node, port, mon_node);
+ if (lid == 0) {
+ OSM_LOG(pm->log, OSM_LOG_DEBUG, "WARN: node 0x%" PRIx64
+ " port %d (%s): port out of range, skipping\n",
+ cl_ntoh64(node->node_info.node_guid), port,
+ node->print_desc);
+ continue;
+ }
+
+ remote_qp = get_qp(mon_node, port);
+
+ mad_context.perfmgr_context.node_guid = node_guid;
+ mad_context.perfmgr_context.port = port;
+ mad_context.perfmgr_context.mad_method = IB_MAD_METHOD_GET;
+
+ if (pm->query_cpi && !mon_node->port[port].cpi_valid) {
+ status = perfmgr_send_cpi_mad(pm, lid, remote_qp,
+ mon_node->port[port].pkey_ix,
+ port, &mad_context,
+ 0); /* FIXME SL != 0 */
+ if (status != IB_SUCCESS)
+ OSM_LOG(pm->log, OSM_LOG_ERROR, "ERR 5410: "
+ "Failed to issue ClassPortInfo query "
+ "for node 0x%" PRIx64
+ " port %d (%s)\n",
+ node->node_info.node_guid, port,
+ node->print_desc);
+ if (mon_node->node_type == IB_NODE_TYPE_SWITCH)
+ goto Exit; /* only need to issue 1 CPI query
+ for switches */
+ } else {
+
+#ifdef ENABLE_OSM_PERF_MGR_PROFILE
+ gettimeofday(&mad_context.perfmgr_context.query_start, NULL);
+#endif
+ OSM_LOG(pm->log, OSM_LOG_VERBOSE, "Getting stats for node 0x%"
+ PRIx64 " port %d (lid %u) (%s)\n",
+ node_guid, port, cl_ntoh16(lid),
+ node->print_desc);
+ status = perfmgr_send_pc_mad(pm, lid, remote_qp,
+ mon_node->port[port].pkey_ix,
+ port, IB_MAD_METHOD_GET,
+ 0xffff,
+ 1,
+ &mad_context,
+ 0); /* FIXME SL != 0 */
+ if (status != IB_SUCCESS)
+ OSM_LOG(pm->log, OSM_LOG_ERROR, "ERR 5409: "
+ "Failed to issue port counter query for node 0x%"
+ PRIx64 " port %d (%s)\n",
+ node->node_info.node_guid, port,
+ node->print_desc);
+
+ if (pce_supported(mon_node, port)) {
+
+#if ENABLE_OSM_PERF_MGR_PROFILE
+ gettimeofday(&mad_context.perfmgr_context.query_start, NULL);
+#endif
+ status = perfmgr_send_pce_mad(pm, lid, remote_qp,
+ mon_node->port[port].pkey_ix,
+ port,
+ IB_MAD_METHOD_GET,
+ &mad_context,
+ 0); /* FIXME SL != 0 */
+ if (status != IB_SUCCESS)
+ OSM_LOG(pm->log, OSM_LOG_ERROR,
+ "ERR 5417: Failed to issue "
+ "port counter query for "
+ "node 0x%" PRIx64 " port "
+ "%d (%s)\n",
+ node->node_info.node_guid,
+ port,
+ node->print_desc);
+ }
+ }
+ }
+Exit:
+ cl_plock_release(&pm->osm->lock);
+ OSM_LOG_EXIT(pm->log);
+}
+
+/**********************************************************************
+ * Discovery stuff
+ * This code should not be here, but merged with main OpenSM
+ **********************************************************************/
+extern int wait_for_pending_transactions(osm_stats_t * stats);
+extern void osm_drop_mgr_process(IN osm_sm_t * sm);
+
+static int sweep_hop_1(osm_sm_t * sm)
+{
+ ib_api_status_t status = IB_SUCCESS;
+ osm_madw_context_t context;
+ osm_node_t *p_node;
+ osm_port_t *p_port;
+ osm_dr_path_t hop_1_path;
+ ib_net64_t port_guid;
+ uint8_t port_num;
+ uint8_t path_array[IB_SUBNET_PATH_HOPS_MAX];
+ uint8_t num_ports;
+ osm_physp_t *p_ext_physp;
+
+ port_guid = sm->p_subn->sm_port_guid;
+
+ p_port = osm_get_port_by_guid(sm->p_subn, port_guid);
+ if (!p_port) {
+ OSM_LOG(sm->p_log, OSM_LOG_ERROR,
+ "ERR 5481: No SM port object\n");
+ return -1;
+ }
+
+ p_node = p_port->p_node;
+ port_num = ib_node_info_get_local_port_num(&p_node->node_info);
+
+ OSM_LOG(sm->p_log, OSM_LOG_DEBUG,
+ "Probing hop 1 on local port %u\n", port_num);
+
+ memset(path_array, 0, sizeof(path_array));
+ /* the hop_1 operations depend on the type of our node.
+ * Currently - legal nodes that can host SM are SW and CA */
+ switch (osm_node_get_type(p_node)) {
+ case IB_NODE_TYPE_CA:
+ case IB_NODE_TYPE_ROUTER:
+ memset(&context, 0, sizeof(context));
+ context.ni_context.node_guid = osm_node_get_node_guid(p_node);
+ context.ni_context.port_num = port_num;
+
+ path_array[1] = port_num;
+
+ osm_dr_path_init(&hop_1_path, 1, path_array);
+ CL_PLOCK_ACQUIRE(sm->p_lock);
+ status = osm_req_get(sm, &hop_1_path, IB_MAD_ATTR_NODE_INFO, 0,
+ TRUE, 0, CL_DISP_MSGID_NONE, &context);
+ CL_PLOCK_RELEASE(sm->p_lock);
+
+ if (status != IB_SUCCESS)
+ OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR 5482: "
+ "Request for NodeInfo failed\n");
+ break;
+
+ case IB_NODE_TYPE_SWITCH:
+ /* Need to go over all the ports of the switch, and send a node_info
+ * from them. This doesn't include the port 0 of the switch, which
+ * hosts the SM.
+ * Note: We'll send another switchInfo on port 0, since if no ports
+ * are connected, we still want to get some response, and have the
+ * subnet come up.
+ */
+ num_ports = osm_node_get_num_physp(p_node);
+ for (port_num = 0; port_num < num_ports; port_num++) {
+ /* go through the port only if the port is not DOWN */
+ p_ext_physp = osm_node_get_physp_ptr(p_node, port_num);
+ if (!p_ext_physp || ib_port_info_get_port_state
+ (&p_ext_physp->port_info) <= IB_LINK_DOWN)
+ continue;
+
+ memset(&context, 0, sizeof(context));
+ context.ni_context.node_guid =
+ osm_node_get_node_guid(p_node);
+ context.ni_context.port_num = port_num;
+
+ path_array[1] = port_num;
+
+ osm_dr_path_init(&hop_1_path, 1, path_array);
+ CL_PLOCK_ACQUIRE(sm->p_lock);
+ status = osm_req_get(sm, &hop_1_path,
+ IB_MAD_ATTR_NODE_INFO, 0, TRUE, 0,
+ CL_DISP_MSGID_NONE, &context);
+ CL_PLOCK_RELEASE(sm->p_lock);
+
+ if (status != IB_SUCCESS)
+ OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR 5484: "
+ "Request for NodeInfo failed\n");
+ }
+ break;
+
+ default:
+ OSM_LOG(sm->p_log, OSM_LOG_ERROR,
+ "ERR 5483: Unknown node type %d\n",
+ osm_node_get_type(p_node));
+ }
+
+ return status;
+}
+
+static unsigned is_sm_port_down(osm_sm_t * sm)
+{
+ ib_net64_t port_guid;
+ osm_port_t *p_port;
+
+ port_guid = sm->p_subn->sm_port_guid;
+ if (port_guid == 0)
+ return 1;
+
+ CL_PLOCK_ACQUIRE(sm->p_lock);
+ p_port = osm_get_port_by_guid(sm->p_subn, port_guid);
+ if (!p_port) {
+ CL_PLOCK_RELEASE(sm->p_lock);
+ OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR 5485: "
+ "SM port with GUID:%016" PRIx64 " is unknown\n",
+ cl_ntoh64(port_guid));
+ return 1;
+ }
+ CL_PLOCK_RELEASE(sm->p_lock);
+
+ if (p_port->p_node->sw &&
+ !ib_switch_info_is_enhanced_port0(&p_port->p_node->sw->switch_info))
+ return 0; /* base SP0 */
+
+ return osm_physp_get_port_state(p_port->p_physp) == IB_LINK_DOWN;
+}
+
+static int sweep_hop_0(osm_sm_t * sm)
+{
+ ib_api_status_t status;
+ osm_dr_path_t dr_path;
+ osm_bind_handle_t h_bind;
+ uint8_t path_array[IB_SUBNET_PATH_HOPS_MAX];
+
+ memset(path_array, 0, sizeof(path_array));
+
+ h_bind = osm_sm_mad_ctrl_get_bind_handle(&sm->mad_ctrl);
+ if (h_bind == OSM_BIND_INVALID_HANDLE) {
+ OSM_LOG(sm->p_log, OSM_LOG_DEBUG, "No bound ports\n");
+ return -1;
+ }
+
+ osm_dr_path_init(&dr_path, 0, path_array);
+ CL_PLOCK_ACQUIRE(sm->p_lock);
+ status = osm_req_get(sm, &dr_path, IB_MAD_ATTR_NODE_INFO, 0,
+ TRUE, 0, CL_DISP_MSGID_NONE, NULL);
+ CL_PLOCK_RELEASE(sm->p_lock);
+
+ if (status != IB_SUCCESS)
+ OSM_LOG(sm->p_log, OSM_LOG_ERROR,
+ "ERR 5486: Request for NodeInfo failed\n");
+
+ return status;
+}
+
+static void reset_node_count(cl_map_item_t * p_map_item, void *cxt)
+{
+ osm_node_t *p_node = (osm_node_t *) p_map_item;
+ p_node->discovery_count = 0;
+
+ memset(p_node->physp_discovered, 0,
+ sizeof(uint8_t) * p_node->physp_tbl_size);
+}
+
+static void reset_port_count(cl_map_item_t * p_map_item, void *cxt)
+{
+ osm_port_t *p_port = (osm_port_t *) p_map_item;
+ p_port->discovery_count = 0;
+}
+
+static void reset_switch_count(cl_map_item_t * p_map_item, void *cxt)
+{
+ osm_switch_t *p_sw = (osm_switch_t *) p_map_item;
+ p_sw->need_update = 0;
+}
+
+static int perfmgr_discovery(osm_opensm_t * osm)
+{
+ int ret;
+
+ CL_PLOCK_ACQUIRE(&osm->lock);
+ cl_qmap_apply_func(&osm->subn.node_guid_tbl, reset_node_count, NULL);
+ cl_qmap_apply_func(&osm->subn.port_guid_tbl, reset_port_count, NULL);
+ cl_qmap_apply_func(&osm->subn.sw_guid_tbl, reset_switch_count, NULL);
+ CL_PLOCK_RELEASE(&osm->lock);
+
+ osm->subn.in_sweep_hop_0 = TRUE;
+
+ ret = sweep_hop_0(&osm->sm);
+ if (ret)
+ goto _exit;
+
+ if (wait_for_pending_transactions(&osm->stats))
+ goto _exit;
+
+ if (is_sm_port_down(&osm->sm)) {
+ OSM_LOG(&osm->log, OSM_LOG_VERBOSE, "SM port is down\n");
+ goto _drop;
+ }
+
+ osm->subn.in_sweep_hop_0 = FALSE;
+
+ ret = sweep_hop_1(&osm->sm);
+ if (ret)
+ goto _exit;
+
+ if (wait_for_pending_transactions(&osm->stats))
+ goto _exit;
+
+_drop:
+ osm_drop_mgr_process(&osm->sm);
+
+_exit:
+ return ret;
+}
+
+/**********************************************************************
+ * Main PerfMgr processor - query the performance counters
+ **********************************************************************/
+void osm_perfmgr_process(osm_perfmgr_t * pm)
+{
+#ifdef ENABLE_OSM_PERF_MGR_PROFILE
+ struct timeval before, after;
+#endif
+
+ if (pm->state != PERFMGR_STATE_ENABLED)
+ return;
+
+ cl_spinlock_acquire(&pm->lock);
+ if (pm->sweep_state == PERFMGR_SWEEP_ACTIVE ||
+ pm->sweep_state == PERFMGR_SWEEP_SUSPENDED ||
+ pm->sweep_state == PERFMGR_SWEEP_POST_PROCESSING) {
+ cl_spinlock_release(&pm->lock);
+ OSM_LOG(pm->log, OSM_LOG_INFO,
+ "PM sweep state %d, skipping sweep\n",
+ pm->sweep_state);
+ return;
+ }
+
+ pm->sweep_state = PERFMGR_SWEEP_ACTIVE;
+ cl_spinlock_release(&pm->lock);
+
+ if (pm->subn->sm_state == IB_SMINFO_STATE_STANDBY ||
+ pm->subn->sm_state == IB_SMINFO_STATE_NOTACTIVE)
+ perfmgr_discovery(pm->subn->p_osm);
+
+ /* if redirection enabled, determine local port */
+ if (pm->subn->opt.perfmgr_redir && pm->local_port == -1) {
+ osm_node_t *p_node;
+ osm_port_t *p_port;
+
+ CL_PLOCK_ACQUIRE(pm->sm->p_lock);
+ p_port = osm_get_port_by_guid(pm->subn, pm->port_guid);
+ if (p_port) {
+ p_node = p_port->p_node;
+ CL_ASSERT(p_node);
+ pm->local_port =
+ ib_node_info_get_local_port_num(&p_node->node_info);
+ } else
+ OSM_LOG(pm->log, OSM_LOG_ERROR,
+ "ERR 5487: No PerfMgr port object for "
+ "port GUID 0x%" PRIx64 "\n",
+ cl_ntoh64(pm->port_guid));
+ CL_PLOCK_RELEASE(pm->sm->p_lock);
+ }
+
+#ifdef ENABLE_OSM_PERF_MGR_PROFILE
+ gettimeofday(&before, NULL);
+#endif
+ /* With the global lock held, collect the node guids */
+ /* FIXME we should be able to track SA notices
+ * and not have to sweep the node_guid_tbl each pass
+ */
+ OSM_LOG(pm->log, OSM_LOG_VERBOSE, "Gathering PerfMgr stats\n");
+ cl_plock_acquire(&pm->osm->lock);
+ cl_qmap_apply_func(&pm->subn->node_guid_tbl, collect_guids, pm);
+ cl_plock_release(&pm->osm->lock);
+
+ /* then for each node query their counters */
+ cl_qmap_apply_func(&pm->monitored_map, perfmgr_query_counters, pm);
+
+ /* clean out any nodes found to be removed during the sweep */
+ remove_marked_nodes(pm);
+
+#ifdef ENABLE_OSM_PERF_MGR_PROFILE
+ gettimeofday(&after, NULL);
+ diff_time(&before, &after, &after);
+ osm_log_v2(pm->log, OSM_LOG_INFO, FILE_ID,
+ "PerfMgr total sweep time : %ld.%06ld s\n"
+ " fastest mad : %g us\n"
+ " slowest mad : %g us\n"
+ " average mad : %g us\n",
+ after.tv_sec, after.tv_usec, perfmgr_mad_stats.fastest_us,
+ perfmgr_mad_stats.slowest_us, perfmgr_mad_stats.avg_us);
+ clear_mad_stats();
+#endif
+
+ cl_spinlock_acquire(&pm->lock);
+ pm->sweep_state = PERFMGR_SWEEP_SLEEP;
+ cl_spinlock_release(&pm->lock);
+}
+
+/**********************************************************************
+ * PerfMgr timer - loop continuously and signal SM to run PerfMgr
+ * processor if enabled
+ **********************************************************************/
+static void perfmgr_sweep(void *arg)
+{
+ osm_perfmgr_t *pm = arg;
+
+ osm_sm_signal(pm->sm, OSM_SIGNAL_PERFMGR_SWEEP);
+ cl_timer_start(&pm->sweep_timer, pm->sweep_time_s * 1000);
+}
+
+void osm_perfmgr_shutdown(osm_perfmgr_t * pm)
+{
+ OSM_LOG_ENTER(pm->log);
+ cl_timer_stop(&pm->sweep_timer);
+ cl_disp_unregister(pm->pc_disp_h);
+ perfmgr_mad_unbind(pm);
+ OSM_LOG_EXIT(pm->log);
+}
+
+void osm_perfmgr_destroy(osm_perfmgr_t * pm)
+{
+ OSM_LOG_ENTER(pm->log);
+ perfmgr_db_destroy(pm->db);
+ cl_timer_destroy(&pm->sweep_timer);
+ OSM_LOG_EXIT(pm->log);
+}
+
+/**********************************************************************
+ * Detect if someone else on the network could have cleared the counters
+ * without us knowing. This is easy to detect because the counters never
+ * wrap but are "sticky".
+ *
+ * The one time this will not work is if the port is getting errors fast
+ * enough to have the reading overtake the previous reading. In this case,
+ * counters will be missed.
+ **********************************************************************/
+static void perfmgr_check_oob_clear(osm_perfmgr_t * pm,
+ monitored_node_t * mon_node, uint8_t port,
+ perfmgr_db_err_reading_t * cr)
+{
+ perfmgr_db_err_reading_t prev_err;
+
+ if (perfmgr_db_get_prev_err(pm->db, mon_node->guid, port, &prev_err)
+ != PERFMGR_EVENT_DB_SUCCESS) {
+ OSM_LOG(pm->log, OSM_LOG_VERBOSE, "Failed to find previous "
+ "error reading for %s (guid 0x%" PRIx64 ") port %u\n",
+ mon_node->name, mon_node->guid, port);
+ return;
+ }
+
+ OSM_LOG(pm->log, OSM_LOG_DEBUG,
+ "Errors vs previous node %s (0x%" PRIx64 ") port %u\n"
+ "SE: %"PRIu64" ?< %"PRIu64"\n"
+ "LE: %"PRIu64" ?< %"PRIu64"\n"
+ "LD: %"PRIu64" ?< %"PRIu64"\n"
+ "RE: %"PRIu64" ?< %"PRIu64"\n"
+ "RPE: %"PRIu64" ?< %"PRIu64"\n"
+ "SRE: %"PRIu64" ?< %"PRIu64"\n"
+ "XD: %"PRIu64" ?< %"PRIu64"\n"
+ "XCE: %"PRIu64" ?< %"PRIu64"\n"
+ "RCE: %"PRIu64" ?< %"PRIu64"\n"
+ "LI: %"PRIu64" ?< %"PRIu64"\n"
+ "BO: %"PRIu64" ?< %"PRIu64"\n"
+ "VL15: %"PRIu64" ?< %"PRIu64"\n"
+ "XW: %"PRIu64" ?< %"PRIu64"\n"
+ ,
+ mon_node->name, mon_node->guid, port,
+ cr->symbol_err_cnt, prev_err.symbol_err_cnt,
+ cr->link_err_recover, prev_err.link_err_recover,
+ cr->link_downed, prev_err.link_downed,
+ cr->rcv_err, prev_err.rcv_err,
+ cr->rcv_rem_phys_err, prev_err.rcv_rem_phys_err,
+ cr->rcv_switch_relay_err, prev_err.rcv_switch_relay_err,
+ cr->xmit_discards, prev_err.xmit_discards,
+ cr->xmit_constraint_err, prev_err.xmit_constraint_err,
+ cr->rcv_constraint_err, prev_err.rcv_constraint_err,
+ cr->link_integrity, prev_err.link_integrity,
+ cr->buffer_overrun, prev_err.buffer_overrun,
+ cr->vl15_dropped, prev_err.vl15_dropped,
+ cr->xmit_wait, prev_err.xmit_wait);
+
+ if (cr->symbol_err_cnt < prev_err.symbol_err_cnt ||
+ cr->link_err_recover < prev_err.link_err_recover ||
+ cr->link_downed < prev_err.link_downed ||
+ cr->rcv_err < prev_err.rcv_err ||
+ cr->rcv_rem_phys_err < prev_err.rcv_rem_phys_err ||
+ cr->rcv_switch_relay_err < prev_err.rcv_switch_relay_err ||
+ cr->xmit_discards < prev_err.xmit_discards ||
+ cr->xmit_constraint_err < prev_err.xmit_constraint_err ||
+ cr->rcv_constraint_err < prev_err.rcv_constraint_err ||
+ cr->link_integrity < prev_err.link_integrity ||
+ cr->buffer_overrun < prev_err.buffer_overrun ||
+ cr->vl15_dropped < prev_err.vl15_dropped ||
+ cr->xmit_wait < prev_err.xmit_wait) {
+ OSM_LOG(pm->log, OSM_LOG_ERROR, "PerfMgr: ERR 540A: "
+ "Detected an out of band error clear "
+ "on %s (0x%" PRIx64 ") port %u\n",
+ mon_node->name, mon_node->guid, port);
+ perfmgr_db_clear_prev_err(pm->db, mon_node->guid, port);
+ }
+}
+
+/**********************************************************************
+ * Return 1 if the value is "close" to overflowing
+ * "close" is defined at 25% for now
+ **********************************************************************/
+static int counter_overflow_4(uint8_t val)
+{
+ return (val >= 10);
+}
+
+static int counter_overflow_8(uint8_t val)
+{
+ return (val >= (UINT8_MAX - (UINT8_MAX / 4)));
+}
+
+static int counter_overflow_16(ib_net16_t val)
+{
+ return (cl_ntoh16(val) >= (UINT16_MAX - (UINT16_MAX / 4)));
+}
+
+static int counter_overflow_32(ib_net32_t val)
+{
+ return (cl_ntoh32(val) >= (UINT32_MAX - (UINT32_MAX / 4)));
+}
+
+static int counter_overflow_64(ib_net64_t val)
+{
+ return (cl_ntoh64(val) >= (UINT64_MAX - (UINT64_MAX / 4)));
+}
+
+/**********************************************************************
+ * Check if the port counters have overflowed and if so issue a clear
+ * MAD to the port
+ **********************************************************************/
+static void perfmgr_check_overflow(osm_perfmgr_t * pm,
+ monitored_node_t * mon_node, int16_t pkey_ix,
+ uint8_t port, ib_port_counters_t * pc,
+ boolean_t xmit_wait_sup)
+{
+ osm_madw_context_t mad_context;
+ ib_api_status_t status;
+ ib_net32_t remote_qp;
+ uint16_t counter_select;
+ uint8_t counter_select2;
+
+ OSM_LOG_ENTER(pm->log);
+
+ if (counter_overflow_16(pc->symbol_err_cnt) ||
+ counter_overflow_8(pc->link_err_recover) ||
+ counter_overflow_8(pc->link_downed) ||
+ counter_overflow_16(pc->rcv_err) ||
+ counter_overflow_16(pc->rcv_rem_phys_err) ||
+ counter_overflow_16(pc->rcv_switch_relay_err) ||
+ counter_overflow_16(pc->xmit_discards) ||
+ counter_overflow_8(pc->xmit_constraint_err) ||
+ counter_overflow_8(pc->rcv_constraint_err) ||
+ counter_overflow_4(PC_LINK_INT(pc->link_int_buffer_overrun)) ||
+ counter_overflow_4(PC_BUF_OVERRUN(pc->link_int_buffer_overrun)) ||
+ counter_overflow_16(pc->vl15_dropped) ||
+ (xmit_wait_sup && counter_overflow_32(pc->xmit_wait)) ||
+ (!pce_supported(mon_node, port) &&
+ (counter_overflow_32(pc->xmit_data) ||
+ counter_overflow_32(pc->rcv_data) ||
+ counter_overflow_32(pc->xmit_pkts) ||
+ counter_overflow_32(pc->rcv_pkts)))) {
+ osm_node_t *p_node = NULL;
+ ib_net16_t lid = 0;
+
+ if (!mon_node->port[port].valid)
+ goto Exit;
+
+ osm_log_v2(pm->log, OSM_LOG_VERBOSE, FILE_ID,
+ "PerfMgr: Counter overflow: %s (0x%" PRIx64
+ ") port %d; clearing counters\n",
+ mon_node->name, mon_node->guid, port);
+
+ cl_plock_acquire(&pm->osm->lock);
+ p_node =
+ osm_get_node_by_guid(pm->subn, cl_hton64(mon_node->guid));
+ lid = get_lid(p_node, port, mon_node);
+ cl_plock_release(&pm->osm->lock);
+ if (lid == 0) {
+ OSM_LOG(pm->log, OSM_LOG_ERROR, "PerfMgr: ERR 540C: "
+ "Failed to clear counters for %s (0x%"
+ PRIx64 ") port %d; failed to get lid\n",
+ mon_node->name, mon_node->guid, port);
+ goto Exit;
+ }
+
+ remote_qp = get_qp(NULL, port);
+
+ mad_context.perfmgr_context.node_guid = mon_node->guid;
+ mad_context.perfmgr_context.port = port;
+ mad_context.perfmgr_context.mad_method = IB_MAD_METHOD_SET;
+
+ /* apparently some HW uses the same counters for the 32 and 64
+ * bit versions and a clear of them in the PortCounters
+ * attribute also clears the ExtendedPortCounters equivalant
+ * counters
+ */
+ if (pce_supported(mon_node, port))
+ counter_select = 0x0fff;
+ else
+ counter_select = 0xffff;
+
+ if (xmit_wait_sup)
+ counter_select2 = 1;
+ else
+ counter_select2 = 0;
+
+ status = perfmgr_send_pc_mad(pm, lid, remote_qp, pkey_ix,
+ port, IB_MAD_METHOD_SET,
+ counter_select,
+ counter_select2,
+ &mad_context,
+ 0); /* FIXME SL != 0 */
+ if (status != IB_SUCCESS)
+ OSM_LOG(pm->log, OSM_LOG_ERROR, "PerfMgr: ERR 5411: "
+ "Failed to send clear counters MAD for %s (0x%"
+ PRIx64 ") port %d\n",
+ mon_node->name, mon_node->guid, port);
+
+ perfmgr_db_clear_prev_err(pm->db, mon_node->guid, port);
+ if (!pce_supported(mon_node, port))
+ perfmgr_db_clear_prev_dc(pm->db, mon_node->guid, port);
+ }
+
+Exit:
+ OSM_LOG_EXIT(pm->log);
+}
+
+/**********************************************************************
+ * Check if the port counters have overflowed and if so issue a clear
+ * MAD to the port
+ **********************************************************************/
+static void perfmgr_check_pce_overflow(osm_perfmgr_t * pm,
+ monitored_node_t * mon_node,
+ int16_t pkey_ix,
+ uint8_t port,
+ ib_port_counters_ext_t * pc)
+{
+ osm_madw_context_t mad_context;
+ ib_api_status_t status;
+ ib_net32_t remote_qp;
+
+ OSM_LOG_ENTER(pm->log);
+
+ if (counter_overflow_64(pc->xmit_data) ||
+ counter_overflow_64(pc->rcv_data) ||
+ counter_overflow_64(pc->xmit_pkts) ||
+ counter_overflow_64(pc->rcv_pkts) ||
+ (ietf_supported(mon_node, port) &&
+ (counter_overflow_64(pc->unicast_xmit_pkts) ||
+ counter_overflow_64(pc->unicast_rcv_pkts) ||
+ counter_overflow_64(pc->multicast_xmit_pkts) ||
+ counter_overflow_64(pc->multicast_rcv_pkts)))) {
+ osm_node_t *p_node = NULL;
+ ib_net16_t lid = 0;
+
+ if (!mon_node->port[port].valid)
+ goto Exit;
+
+ osm_log(pm->log, OSM_LOG_VERBOSE,
+ "PerfMgr: PortCountersExtended overflow: %s (0x%"
+ PRIx64 ") port %d; clearing counters\n",
+ mon_node->name, mon_node->guid, port);
+
+ cl_plock_acquire(&pm->osm->lock);
+ p_node =
+ osm_get_node_by_guid(pm->subn, cl_hton64(mon_node->guid));
+ lid = get_lid(p_node, port, mon_node);
+ cl_plock_release(&pm->osm->lock);
+ if (lid == 0) {
+ OSM_LOG(pm->log, OSM_LOG_ERROR, "PerfMgr: ERR 5418: "
+ "Failed to clear counters for %s (0x%"
+ PRIx64 ") port %d; failed to get lid\n",
+ mon_node->name, mon_node->guid, port);
+ goto Exit;
+ }
+
+ remote_qp = get_qp(NULL, port);
+
+ mad_context.perfmgr_context.node_guid = mon_node->guid;
+ mad_context.perfmgr_context.port = port;
+ mad_context.perfmgr_context.mad_method = IB_MAD_METHOD_SET;
+ /* clear port counters */
+ status = perfmgr_send_pce_mad(pm, lid, remote_qp, pkey_ix,
+ port, IB_MAD_METHOD_SET,
+ &mad_context,
+ 0); /* FIXME SL != 0 */
+ if (status != IB_SUCCESS)
+ OSM_LOG(pm->log, OSM_LOG_ERROR, "PerfMgr: ERR 5419: "
+ "Failed to send clear counters MAD for %s (0x%"
+ PRIx64 ") port %d\n",
+ mon_node->name, mon_node->guid, port);
+
+ perfmgr_db_clear_prev_dc(pm->db, mon_node->guid, port);
+ }
+
+Exit:
+ OSM_LOG_EXIT(pm->log);
+}
+
+/**********************************************************************
+ * Check values for logging of errors
+ **********************************************************************/
+static void perfmgr_log_errors(osm_perfmgr_t * pm,
+ monitored_node_t * mon_node, uint8_t port,
+ perfmgr_db_err_reading_t * reading)
+{
+ perfmgr_db_err_reading_t prev_read;
+ perfmgr_db_err_t err =
+ perfmgr_db_get_prev_err(pm->db, mon_node->guid, port, &prev_read);
+ uint64_t cur, prev;
+
+ if (err != PERFMGR_EVENT_DB_SUCCESS) {
+ OSM_LOG(pm->log, OSM_LOG_VERBOSE, "Failed to find previous "
+ "reading for %s (0x%" PRIx64 ") port %u\n",
+ mon_node->name, mon_node->guid, port);
+ return;
+ }
+
+#define LOG_ERR_CNT(errname, errnum, counter_name) \
+ if (reading->counter_name > prev_read.counter_name) { \
+ if (mon_node->port[port].remote_valid == TRUE) \
+ OSM_LOG(pm->log, OSM_LOG_ERROR, "ERR %s: " \
+ "%s : %" PRIu64 " : node " \
+ "\"%s\" (NodeGUID: 0x%" PRIx64 ") : port %u " \
+ "connected to \"%s\" (NodeGUID: 0x%" PRIx64 ") : port %u\n", \
+ errnum, errname, \
+ reading->counter_name - prev_read.counter_name, \
+ mon_node->name, mon_node->guid, port, \
+ mon_node->port[port].remote_name, \
+ mon_node->port[port].remote_guid, \
+ mon_node->port[port].remote_port); \
+ else \
+ OSM_LOG(pm->log, OSM_LOG_ERROR, "ERR %s: " \
+ "%s : %" PRIu64 " : node " \
+ "\"%s\" (NodeGUID: 0x%" PRIx64 ") : port %u\n", \
+ errnum, errname, \
+ reading->counter_name - prev_read.counter_name, \
+ mon_node->name, mon_node->guid, port); \
+ }
+
+ LOG_ERR_CNT("SymbolErrorCounter", "5431", symbol_err_cnt);
+ LOG_ERR_CNT("LinkErrorRecoveryCounter", "5432", link_err_recover);
+ LOG_ERR_CNT("LinkDownedCounter", "5433", link_downed);
+ LOG_ERR_CNT("PortRcvErrors", "5434", rcv_err);
+ LOG_ERR_CNT("PortRcvRemotePhysicalErrors", "5435", rcv_rem_phys_err);
+ LOG_ERR_CNT("PortRcvSwitchRelayErrors", "5436", rcv_switch_relay_err);
+ LOG_ERR_CNT("PortXmitDiscards", "5437", xmit_discards);
+ LOG_ERR_CNT("PortXmitConstraintErrors", "5438", xmit_constraint_err);
+ LOG_ERR_CNT("PortRcvConstraintErrors", "5439", rcv_constraint_err);
+ LOG_ERR_CNT("LocalLinkIntegrityErrors", "543A", link_integrity);
+ LOG_ERR_CNT("ExcessiveBufferOverrunErrors", "543B", buffer_overrun);
+ LOG_ERR_CNT("VL15Dropped", "543C", vl15_dropped);
+
+ cur = reading->xmit_wait;
+ prev = prev_read.xmit_wait;
+ if (pm->xmit_wait_log && cur > prev &&
+ (cur - prev) >= pm->xmit_wait_threshold) {
+ OSM_LOG(pm->log, OSM_LOG_ERROR, "ERR 543D: XmitWait : %" PRIu64
+ " : node \"%s\" (NodeGUID: 0x%" PRIx64 ") : port %u\n",
+ cur - prev, mon_node->name, mon_node->guid, port);
+ }
+}
+
+static int16_t validate_redir_pkey(osm_perfmgr_t *pm, ib_net16_t pkey)
+{
+ int16_t pkey_ix = -1;
+ osm_port_t *p_port;
+ osm_pkey_tbl_t *p_pkey_tbl;
+ ib_net16_t *p_orig_pkey;
+ uint16_t block;
+ uint8_t index;
+
+ OSM_LOG_ENTER(pm->log);
+
+ CL_PLOCK_ACQUIRE(pm->sm->p_lock);
+ p_port = osm_get_port_by_guid(pm->subn, pm->port_guid);
+ if (!p_port) {
+ CL_PLOCK_RELEASE(pm->sm->p_lock);
+ OSM_LOG(pm->log, OSM_LOG_ERROR,
+ "ERR 541E: No PerfMgr port object\n");
+ goto Exit;
+ }
+ if (p_port->p_physp && osm_physp_is_valid(p_port->p_physp)) {
+ p_pkey_tbl = &p_port->p_physp->pkeys;
+ if (!p_pkey_tbl) {
+ CL_PLOCK_RELEASE(pm->sm->p_lock);
+ OSM_LOG(pm->log, OSM_LOG_VERBOSE,
+ "No PKey table found for PerfMgr port\n");
+ goto Exit;
+ }
+ p_orig_pkey = cl_map_get(&p_pkey_tbl->keys,
+ ib_pkey_get_base(pkey));
+ if (!p_orig_pkey) {
+ CL_PLOCK_RELEASE(pm->sm->p_lock);
+ OSM_LOG(pm->log, OSM_LOG_VERBOSE,
+ "PKey 0x%x not found for PerfMgr port\n",
+ cl_ntoh16(pkey));
+ goto Exit;
+ }
+ if (osm_pkey_tbl_get_block_and_idx(p_pkey_tbl, p_orig_pkey,
+ &block, &index) == IB_SUCCESS) {
+ CL_PLOCK_RELEASE(pm->sm->p_lock);
+ pkey_ix = block * IB_NUM_PKEY_ELEMENTS_IN_BLOCK + index;
+ } else {
+ CL_PLOCK_RELEASE(pm->sm->p_lock);
+ OSM_LOG(pm->log, OSM_LOG_ERROR,
+ "ERR 541F: Failed to obtain P_Key 0x%04x "
+ "block and index for PerfMgr port\n",
+ cl_ntoh16(pkey));
+ }
+ } else {
+ CL_PLOCK_RELEASE(pm->sm->p_lock);
+ OSM_LOG(pm->log, OSM_LOG_ERROR,
+ "ERR 5420: Local PerfMgt port physp invalid\n");
+ }
+
+Exit:
+ OSM_LOG_EXIT(pm->log);
+ return pkey_ix;
+}
+
+static boolean_t handle_redirect(osm_perfmgr_t *pm,
+ ib_class_port_info_t *cpi,
+ monitored_node_t *p_mon_node,
+ uint8_t port,
+ osm_madw_context_t *mad_context)
+{
+ char gid_str[INET6_ADDRSTRLEN];
+ ib_api_status_t status;
+ boolean_t valid = TRUE;
+ int16_t pkey_ix = 0;
+ uint8_t mad_method;
+
+ OSM_LOG(pm->log, OSM_LOG_VERBOSE,
+ "Redirection to LID %u GID %s QP 0x%x received\n",
+ cl_ntoh16(cpi->redir_lid),
+ inet_ntop(AF_INET6, cpi->redir_gid.raw, gid_str,
+ sizeof gid_str), cl_ntoh32(cpi->redir_qp));
+
+ if (!pm->subn->opt.perfmgr_redir) {
+ OSM_LOG(pm->log, OSM_LOG_VERBOSE,
+ "Redirection requested but disabled\n");
+ valid = FALSE;
+ }
+
+ /* valid redirection ? */
+ if (cpi->redir_lid == 0) {
+ if (!ib_gid_is_notzero(&cpi->redir_gid)) {
+ OSM_LOG(pm->log, OSM_LOG_VERBOSE,
+ "Invalid redirection "
+ "(both redirect LID and GID are zero)\n");
+ valid = FALSE;
+ }
+ }
+ if (cpi->redir_qp == 0) {
+ OSM_LOG(pm->log, OSM_LOG_VERBOSE, "Invalid RedirectQP\n");
+ valid = FALSE;
+ }
+ if (cpi->redir_pkey == 0) {
+ OSM_LOG(pm->log, OSM_LOG_VERBOSE, "Invalid RedirectP_Key\n");
+ valid = FALSE;
+ }
+ if (cpi->redir_qkey != IB_QP1_WELL_KNOWN_Q_KEY) {
+ OSM_LOG(pm->log, OSM_LOG_VERBOSE, "Invalid RedirectQ_Key\n");
+ valid = FALSE;
+ }
+
+ pkey_ix = validate_redir_pkey(pm, cpi->redir_pkey);
+ if (pkey_ix == -1) {
+ OSM_LOG(pm->log, OSM_LOG_VERBOSE,
+ "Index for Pkey 0x%x not found\n",
+ cl_ntoh16(cpi->redir_pkey));
+ valid = FALSE;
+ }
+
+ if (cpi->redir_lid == 0) {
+ /* GID redirection: get PathRecord information */
+ OSM_LOG(pm->log, OSM_LOG_VERBOSE,
+ "GID redirection not currently supported\n");
+ goto Exit;
+ }
+
+ if (!valid)
+ goto Exit;
+
+ /* LID redirection support (easier than GID redirection) */
+ cl_plock_acquire(&pm->osm->lock);
+ p_mon_node->port[port].redirection = TRUE;
+ p_mon_node->port[port].valid = valid;
+ memcpy(&p_mon_node->port[port].gid, &cpi->redir_gid,
+ sizeof(ib_gid_t));
+ p_mon_node->port[port].lid = cpi->redir_lid;
+ p_mon_node->port[port].qp = cpi->redir_qp;
+ p_mon_node->port[port].pkey = cpi->redir_pkey;
+ if (pkey_ix != -1)
+ p_mon_node->port[port].pkey_ix = pkey_ix;
+ cl_plock_release(&pm->osm->lock);
+
+ /* either */
+ if (pm->query_cpi)
+ {
+ /* issue a CPI query to the redirected location */
+ mad_method = IB_MAD_METHOD_GET;
+ p_mon_node->port[port].cpi_valid = FALSE;
+ status = perfmgr_send_cpi_mad(pm, cpi->redir_lid,
+ cpi->redir_qp, pkey_ix,
+ port, mad_context,
+ 0); /* FIXME SL != 0 */
+ } else {
+ /* reissue the original query to the redirected location */
+ uint8_t counter_select2;
+
+ if (xmit_wait_supported(p_mon_node, port))
+ counter_select2 = 1;
+ else
+ counter_select2 = 0;
+
+ mad_method = mad_context->perfmgr_context.mad_method;
+ if (mad_context->perfmgr_context.mad_attr_id
+ == IB_MAD_ATTR_PORT_CNTRS) {
+ status = perfmgr_send_pc_mad(pm, cpi->redir_lid,
+ cpi->redir_qp,
+ pkey_ix, port,
+ mad_method,
+ 0xffff,
+ counter_select2,
+ mad_context,
+ 0); /* FIXME SL != 0 */
+ } else {
+ status = perfmgr_send_pce_mad(pm, cpi->redir_lid,
+ cpi->redir_qp,
+ pkey_ix, port,
+ mad_method,
+ mad_context,
+ 0); /* FIXME SL != 0 */
+ }
+ }
+ if (status != IB_SUCCESS)
+ OSM_LOG(pm->log, OSM_LOG_ERROR, "ERR 5414: "
+ "Failed to send redirected MAD "
+ "with method 0x%x for node %s "
+ "(NodeGuid 0x%" PRIx64 ") port %d\n",
+ mad_method, p_mon_node->name, p_mon_node->guid, port);
+Exit:
+ return (valid);
+}
+
+/**********************************************************************
+ * Detect if someone else on the network could have cleared the counters
+ * without us knowing. This is easy to detect because the counters never
+ * wrap but are "sticky" PortCountersExtended version.
+ *
+ * The one time this will not work is if the port is getting errors fast
+ * enough to have the reading overtake the previous reading. In this case,
+ * counters will be missed.
+ **********************************************************************/
+static void perfmgr_check_data_cnt_oob_clear(osm_perfmgr_t * pm,
+ monitored_node_t * mon_node,
+ uint8_t port,
+ perfmgr_db_data_cnt_reading_t * dc)
+{
+ perfmgr_db_data_cnt_reading_t prev_dc;
+
+ if (perfmgr_db_get_prev_dc(pm->db, mon_node->guid, port, &prev_dc)
+ != PERFMGR_EVENT_DB_SUCCESS) {
+ OSM_LOG(pm->log, OSM_LOG_VERBOSE,
+ "Failed to find previous data count "
+ "reading for %s (0x%" PRIx64 ") port %u\n",
+ mon_node->name, mon_node->guid, port);
+ return;
+ }
+
+ OSM_LOG(pm->log, OSM_LOG_DEBUG,
+ "Data vs previous node %s (0x%" PRIx64 ") port %u\n"
+ "TX: %"PRIu64" ?< %"PRIu64"\n"
+ "RX: %"PRIu64" ?< %"PRIu64"\n"
+ "TXP: %"PRIu64" ?< %"PRIu64"\n"
+ "RXP: %"PRIu64" ?< %"PRIu64"\n"
+ "UTXP: %"PRIu64" ?< %"PRIu64"\n"
+ "URXP: %"PRIu64" ?< %"PRIu64"\n"
+ "MTXP: %"PRIu64" ?< %"PRIu64"\n"
+ "MRXP: %"PRIu64" ?< %"PRIu64"\n"
+ ,
+ mon_node->name, mon_node->guid, port,
+ dc->xmit_data, prev_dc.xmit_data,
+ dc->rcv_data, prev_dc.rcv_data,
+ dc->xmit_pkts, prev_dc.xmit_pkts,
+ dc->rcv_pkts, prev_dc.rcv_pkts,
+ dc->unicast_xmit_pkts, prev_dc.unicast_xmit_pkts,
+ dc->unicast_rcv_pkts, prev_dc.unicast_rcv_pkts,
+ dc->multicast_xmit_pkts, prev_dc.multicast_xmit_pkts,
+ dc->multicast_rcv_pkts, prev_dc.multicast_rcv_pkts);
+
+ if (dc->xmit_data < prev_dc.xmit_data ||
+ dc->rcv_data < prev_dc.rcv_data ||
+ dc->xmit_pkts < prev_dc.xmit_pkts ||
+ dc->rcv_pkts < prev_dc.rcv_pkts ||
+ (ietf_supported(mon_node, port) &&
+ (dc->unicast_xmit_pkts < prev_dc.unicast_xmit_pkts ||
+ dc->unicast_rcv_pkts < prev_dc.unicast_rcv_pkts ||
+ dc->multicast_xmit_pkts < prev_dc.multicast_xmit_pkts ||
+ dc->multicast_rcv_pkts < prev_dc.multicast_rcv_pkts))) {
+ OSM_LOG(pm->log, OSM_LOG_ERROR,
+ "PerfMgr: ERR 540B: Detected an out of band data counter "
+ "clear on node %s (0x%" PRIx64 ") port %u\n",
+ mon_node->name, mon_node->guid, port);
+
+ perfmgr_db_clear_prev_dc(pm->db, mon_node->guid, port);
+ }
+}
+
+/**********************************************************************
+ * The dispatcher uses a thread pool which will call this function when
+ * there is a thread available to process the mad received on the wire
+ **********************************************************************/
+static void pc_recv_process(void *context, void *data)
+{
+ osm_perfmgr_t *pm = context;
+ osm_madw_t *p_madw = data;
+ osm_madw_context_t *mad_context = &p_madw->context;
+ ib_mad_t *p_mad = osm_madw_get_mad_ptr(p_madw);
+ uint64_t node_guid = mad_context->perfmgr_context.node_guid;
+ uint8_t port = mad_context->perfmgr_context.port;
+ perfmgr_db_err_reading_t err_reading;
+ perfmgr_db_data_cnt_reading_t data_reading;
+ cl_map_item_t *p_node;
+ monitored_node_t *p_mon_node;
+ ib_class_port_info_t *cpi = NULL;
+
+ OSM_LOG_ENTER(pm->log);
+
+ /*
+ * get the monitored node struct to have the printable name
+ * for log messages
+ */
+ if ((p_node = cl_qmap_get(&pm->monitored_map, node_guid)) ==
+ cl_qmap_end(&pm->monitored_map)) {
+ OSM_LOG(pm->log, OSM_LOG_ERROR, "ERR 5412: GUID 0x%016"
+ PRIx64 " not found in monitored map\n", node_guid);
+ goto Exit;
+ }
+ p_mon_node = (monitored_node_t *) p_node;
+
+ OSM_LOG(pm->log, OSM_LOG_VERBOSE,
+ "Processing received MAD status 0x%x context 0x%"
+ PRIx64 " port %u\n", cl_ntoh16(p_mad->status), node_guid, port);
+
+ CL_ASSERT(p_mad->attr_id == IB_MAD_ATTR_PORT_CNTRS ||
+ p_mad->attr_id == IB_MAD_ATTR_PORT_CNTRS_EXT ||
+ p_mad->attr_id == IB_MAD_ATTR_CLASS_PORT_INFO);
+
+ cl_plock_acquire(&pm->osm->lock);
+ /* validate port number */
+ if (port >= p_mon_node->num_ports) {
+ cl_plock_release(&pm->osm->lock);
+ OSM_LOG(pm->log, OSM_LOG_ERROR, "ERR 5413: "
+ "Invalid port num %d for GUID 0x%016"
+ PRIx64 " num ports %d\n", port, node_guid,
+ p_mon_node->num_ports);
+ goto Exit;
+ }
+ cl_plock_release(&pm->osm->lock);
+
+ /* capture CLASS_PORT_INFO data */
+ if (p_mad->attr_id == IB_MAD_ATTR_CLASS_PORT_INFO) {
+ boolean_t cpi_valid = TRUE;
+
+ cpi = (ib_class_port_info_t *) &
+ (osm_madw_get_perfmgt_mad_ptr(p_madw)->data);
+
+ /* Response could be redirection (IBM eHCA PMA does this) */
+ if (p_mad->status & IB_MAD_STATUS_REDIRECT)
+ cpi_valid = handle_redirect(pm, cpi, p_mon_node, port,
+ mad_context);
+
+ if (pm->query_cpi && cpi_valid) {
+ cl_plock_acquire(&pm->osm->lock);
+ if (p_mon_node->node_type == IB_NODE_TYPE_SWITCH) {
+ int i;
+ for (i = p_mon_node->esp0 ? 0 : 1;
+ i < p_mon_node->num_ports;
+ i++) {
+ p_mon_node->port[i].cap_mask = cpi->cap_mask;
+ p_mon_node->port[i].cpi_valid = cpi_valid;
+ }
+ } else {
+ p_mon_node->port[port].cap_mask = cpi->cap_mask;
+ p_mon_node->port[port].cpi_valid = cpi_valid;
+ }
+ cl_plock_release(&pm->osm->lock);
+ }
+ goto Exit;
+ }
+
+ if (p_mad->attr_id == IB_MAD_ATTR_PORT_CNTRS_EXT) {
+ ib_port_counters_ext_t *ext_wire_read =
+ (ib_port_counters_ext_t *)
+ &osm_madw_get_perfmgt_mad_ptr(p_madw)->data;
+
+ /* convert wire data to perfmgr data counter reading */
+ perfmgr_db_fill_data_cnt_read_pce(ext_wire_read, &data_reading,
+ ietf_supported(p_mon_node,
+ port));
+
+ /* add counter */
+ if (mad_context->perfmgr_context.mad_method
+ == IB_MAD_METHOD_GET) {
+ /* detect an out of band clear on the port */
+ perfmgr_check_data_cnt_oob_clear(pm, p_mon_node, port,
+ &data_reading);
+
+ perfmgr_db_add_dc_reading(pm->db, node_guid, port,
+ &data_reading,
+ ietf_supported(p_mon_node,
+ port));
+ } else {
+ perfmgr_db_clear_prev_dc(pm->db, node_guid, port);
+ }
+
+ perfmgr_check_pce_overflow(pm, p_mon_node,
+ p_mon_node->port[port].pkey_ix,
+ port, ext_wire_read);
+ } else {
+ boolean_t pce_sup = pce_supported(p_mon_node, port);
+ boolean_t xmit_wait_sup = xmit_wait_supported(p_mon_node, port);
+ ib_port_counters_t *wire_read =
+ (ib_port_counters_t *)
+ &osm_madw_get_perfmgt_mad_ptr(p_madw)->data;
+
+ perfmgr_db_fill_err_read(wire_read, &err_reading, xmit_wait_sup);
+ if (!pce_sup)
+ perfmgr_db_fill_data_cnt_read_pc(wire_read, &data_reading);
+
+ if (mad_context->perfmgr_context.mad_method == IB_MAD_METHOD_GET) {
+ /* detect an out of band clear on the port */
+ perfmgr_check_oob_clear(pm, p_mon_node, port, &err_reading);
+ if (!pce_sup)
+ perfmgr_check_data_cnt_oob_clear(pm, p_mon_node, port,
+ &data_reading);
+
+ /* log errors from this reading */
+ if (pm->subn->opt.perfmgr_log_errors)
+ perfmgr_log_errors(pm, p_mon_node, port, &err_reading);
+
+ perfmgr_db_add_err_reading(pm->db, node_guid, port,
+ &err_reading);
+ if (!pce_sup)
+ perfmgr_db_add_dc_reading(pm->db, node_guid, port,
+ &data_reading, 0);
+ } else {
+ perfmgr_db_clear_prev_err(pm->db, node_guid, port);
+ if (!pce_sup)
+ perfmgr_db_clear_prev_dc(pm->db, node_guid, port);
+ }
+
+ perfmgr_check_overflow(pm, p_mon_node, p_mon_node->port[port].pkey_ix,
+ port, wire_read, xmit_wait_sup);
+
+ }
+
+#ifdef ENABLE_OSM_PERF_MGR_PROFILE
+ do {
+ struct timeval proc_time;
+ gettimeofday(&proc_time, NULL);
+ diff_time(&p_madw->context.perfmgr_context.query_start,
+ &proc_time, &proc_time);
+ update_mad_stats(&proc_time);
+ } while (0);
+#endif
+
+Exit:
+ osm_mad_pool_put(pm->mad_pool, p_madw);
+
+ OSM_LOG_EXIT(pm->log);
+}
+
+/**********************************************************************
+ * Initialize the PerfMgr object
+ **********************************************************************/
+ib_api_status_t osm_perfmgr_init(osm_perfmgr_t * pm, osm_opensm_t * osm,
+ const osm_subn_opt_t * p_opt)
+{
+ ib_api_status_t status;
+
+ OSM_LOG_ENTER(&osm->log);
+
+ OSM_LOG(&osm->log, OSM_LOG_VERBOSE, "Initializing PerfMgr\n");
+
+ memset(pm, 0, sizeof(*pm));
+
+ pm->subn = &osm->subn;
+ pm->sm = &osm->sm;
+ pm->log = &osm->log;
+ pm->mad_pool = &osm->mad_pool;
+ pm->vendor = osm->p_vendor;
+ pm->trans_id = PERFMGR_INITIAL_TID_VALUE;
+ pm->state =
+ p_opt->perfmgr ? PERFMGR_STATE_ENABLED : PERFMGR_STATE_DISABLE;
+ pm->sweep_state = PERFMGR_SWEEP_SLEEP;
+ cl_spinlock_init(&pm->lock);
+ pm->sweep_time_s = p_opt->perfmgr_sweep_time_s;
+ pm->max_outstanding_queries = p_opt->perfmgr_max_outstanding_queries;
+ pm->ignore_cas = p_opt->perfmgr_ignore_cas;
+ pm->osm = osm;
+ pm->local_port = -1;
+
+ status = cl_timer_init(&pm->sweep_timer, perfmgr_sweep, pm);
+ if (status != IB_SUCCESS)
+ goto Exit;
+
+ status = IB_INSUFFICIENT_RESOURCES;
+ pm->db = perfmgr_db_construct(pm);
+ if (!pm->db) {
+ pm->state = PERFMGR_STATE_NO_DB;
+ goto Exit;
+ }
+
+ pm->pc_disp_h = cl_disp_register(&osm->disp, OSM_MSG_MAD_PORT_COUNTERS,
+ pc_recv_process, pm);
+ if (pm->pc_disp_h == CL_DISP_INVALID_HANDLE) {
+ perfmgr_db_destroy(pm->db);
+ goto Exit;
+ }
+
+ init_monitored_nodes(pm);
+
+ if (pm->state == PERFMGR_STATE_ENABLED)
+ cl_timer_start(&pm->sweep_timer, pm->sweep_time_s * 1000);
+
+ pm->rm_nodes = p_opt->perfmgr_rm_nodes;
+ pm->query_cpi = p_opt->perfmgr_query_cpi;
+ pm->xmit_wait_log = p_opt->perfmgr_xmit_wait_log;
+ pm->xmit_wait_threshold = p_opt->perfmgr_xmit_wait_threshold;
+ status = IB_SUCCESS;
+Exit:
+ OSM_LOG_EXIT(pm->log);
+ return status;
+}
+
+/**********************************************************************
+ * Clear the counters from the db
+ **********************************************************************/
+void osm_perfmgr_clear_counters(osm_perfmgr_t * pm)
+{
+ /**
+ * FIXME todo issue clear on the fabric?
+ */
+ perfmgr_db_clear_counters(pm->db);
+ osm_log_v2(pm->log, OSM_LOG_INFO, FILE_ID, "PerfMgr counters cleared\n");
+}
+
+/*******************************************************************
+ * Dump the DB information to the file specified
+ *******************************************************************/
+void osm_perfmgr_dump_counters(osm_perfmgr_t * pm, perfmgr_db_dump_t dump_type)
+{
+ char path[256];
+ char *file_name;
+ if (pm->subn->opt.event_db_dump_file)
+ file_name = pm->subn->opt.event_db_dump_file;
+ else {
+ snprintf(path, sizeof(path), "%s/%s",
+ pm->subn->opt.dump_files_dir,
+ OSM_PERFMGR_DEFAULT_DUMP_FILE);
+ file_name = path;
+ }
+ if (perfmgr_db_dump(pm->db, file_name, dump_type) != 0)
+ OSM_LOG(pm->log, OSM_LOG_ERROR, "Failed to dump file %s : %s",
+ file_name, strerror(errno));
+}
+
+/*******************************************************************
+ * Print the DB information to the fp specified
+ *******************************************************************/
+void osm_perfmgr_print_counters(osm_perfmgr_t * pm, char *nodename, FILE * fp,
+ char *port, int err_only)
+{
+ if (nodename) {
+ char *end = NULL;
+ uint64_t guid = strtoull(nodename, &end, 0);
+ if (nodename + strlen(nodename) != end)
+ perfmgr_db_print_by_name(pm->db, nodename, fp, port,
+ err_only);
+ else
+ perfmgr_db_print_by_guid(pm->db, guid, fp, port,
+ err_only);
+ } else
+ perfmgr_db_print_all(pm->db, fp, err_only);
+}
+
+void osm_perfmgr_update_nodename(osm_perfmgr_t *pm, uint64_t node_guid,
+ char *nodename)
+{
+ if (pm->db)
+ perfmgr_db_update_name(pm->db, node_guid, nodename);
+}
+#endif /* ENABLE_OSM_PERF_MGR */
diff --git a/contrib/ofed/opensm/opensm/osm_perfmgr_db.c b/contrib/ofed/opensm/opensm/osm_perfmgr_db.c
new file mode 100644
index 0000000..e57b804
--- /dev/null
+++ b/contrib/ofed/opensm/opensm/osm_perfmgr_db.c
@@ -0,0 +1,1098 @@
+/*
+ * Copyright (c) 2008-2009 Voltaire, Inc. All rights reserved.
+ * Copyright (c) 2007 The Regents of the University of California.
+ * Copyright (c) 2009 HNR Consulting. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+#if HAVE_CONFIG_H
+# include <config.h>
+#endif /* HAVE_CONFIG_H */
+
+#ifdef ENABLE_OSM_PERF_MGR
+
+#include <stdlib.h>
+#include <errno.h>
+#include <limits.h>
+#include <dlfcn.h>
+#include <sys/stat.h>
+
+#include <opensm/osm_file_ids.h>
+#define FILE_ID OSM_FILE_PERFMGR_DB_C
+#include <opensm/osm_perfmgr_db.h>
+#include <opensm/osm_perfmgr.h>
+#include <opensm/osm_opensm.h>
+
+static void free_node(db_node_t * node);
+
+/** =========================================================================
+ */
+perfmgr_db_t *perfmgr_db_construct(osm_perfmgr_t *perfmgr)
+{
+ perfmgr_db_t *db = malloc(sizeof(*db));
+ if (!db)
+ return NULL;
+
+ cl_qmap_init(&db->pc_data);
+ cl_plock_construct(&db->lock);
+ cl_plock_init(&db->lock);
+ db->perfmgr = perfmgr;
+ return db;
+}
+
+/** =========================================================================
+ */
+void perfmgr_db_destroy(perfmgr_db_t * db)
+{
+ cl_map_item_t *item, *next_item;
+
+ if (db) {
+ item = cl_qmap_head(&db->pc_data);
+ while (item != cl_qmap_end(&db->pc_data)) {
+ next_item = cl_qmap_next(item);
+ free_node((db_node_t *)item);
+ item = next_item;
+ }
+ cl_plock_destroy(&db->lock);
+ free(db);
+ }
+}
+
+/**********************************************************************
+ * Internal call db->lock should be held when calling
+ **********************************************************************/
+static inline db_node_t *get(perfmgr_db_t * db, uint64_t guid)
+{
+ cl_map_item_t *rc = cl_qmap_get(&db->pc_data, guid);
+ const cl_map_item_t *end = cl_qmap_end(&db->pc_data);
+
+ if (rc == end)
+ return NULL;
+ return (db_node_t *) rc;
+}
+
+static inline perfmgr_db_err_t bad_node_port(db_node_t * node, uint8_t port)
+{
+ if (!node)
+ return PERFMGR_EVENT_DB_GUIDNOTFOUND;
+ if (port >= node->num_ports || (!node->esp0 && port == 0))
+ return PERFMGR_EVENT_DB_PORTNOTFOUND;
+
+ return PERFMGR_EVENT_DB_SUCCESS;
+}
+
+static inline void mark_port_valid(db_node_t * node, uint8_t port)
+{
+ node->ports[port].valid = TRUE;
+}
+
+/** =========================================================================
+ */
+static db_node_t *malloc_node(uint64_t guid, boolean_t esp0,
+ uint8_t num_ports, char *name)
+{
+ int i = 0;
+ time_t cur_time = 0;
+ db_node_t *rc = malloc(sizeof(*rc));
+ if (!rc)
+ return NULL;
+
+ rc->ports = calloc(num_ports, sizeof(db_port_t));
+ if (!rc->ports)
+ goto free_rc;
+ rc->num_ports = num_ports;
+ rc->node_guid = guid;
+ rc->esp0 = esp0;
+
+ cur_time = time(NULL);
+ for (i = 0; i < num_ports; i++) {
+ rc->ports[i].last_reset = cur_time;
+ rc->ports[i].err_previous.time = cur_time;
+ rc->ports[i].dc_previous.time = cur_time;
+ rc->ports[i].valid = FALSE;
+ }
+ snprintf(rc->node_name, sizeof(rc->node_name), "%s", name);
+ rc->active = FALSE;
+
+ return rc;
+
+free_rc:
+ free(rc);
+ return NULL;
+}
+
+/** =========================================================================
+ */
+static void free_node(db_node_t * node)
+{
+ if (!node)
+ return;
+ if (node->ports)
+ free(node->ports);
+ free(node);
+}
+
+/* insert nodes to the database */
+static perfmgr_db_err_t insert(perfmgr_db_t * db, db_node_t * node)
+{
+ cl_map_item_t *rc = cl_qmap_insert(&db->pc_data, node->node_guid,
+ (cl_map_item_t *) node);
+
+ if ((void *)rc != (void *)node)
+ return PERFMGR_EVENT_DB_FAIL;
+ return PERFMGR_EVENT_DB_SUCCESS;
+}
+
+perfmgr_db_err_t
+perfmgr_db_create_entry(perfmgr_db_t * db, uint64_t guid, boolean_t esp0,
+ uint8_t num_ports, char *name)
+{
+ perfmgr_db_err_t rc = PERFMGR_EVENT_DB_SUCCESS;
+
+ cl_plock_excl_acquire(&db->lock);
+ if (!get(db, guid)) {
+ db_node_t *pc_node = malloc_node(guid, esp0, num_ports,
+ name);
+ if (!pc_node) {
+ rc = PERFMGR_EVENT_DB_NOMEM;
+ goto Exit;
+ }
+ if (insert(db, pc_node)) {
+ free_node(pc_node);
+ rc = PERFMGR_EVENT_DB_FAIL;
+ goto Exit;
+ }
+ }
+Exit:
+ cl_plock_release(&db->lock);
+ return rc;
+}
+
+perfmgr_db_err_t
+perfmgr_db_update_name(perfmgr_db_t * db, uint64_t node_guid, char *name)
+{
+ db_node_t *node = NULL;
+
+ cl_plock_excl_acquire(&db->lock);
+ node = get(db, node_guid);
+ if (node)
+ snprintf(node->node_name, sizeof(node->node_name), "%s", name);
+ cl_plock_release(&db->lock);
+ return (PERFMGR_EVENT_DB_SUCCESS);
+}
+
+perfmgr_db_err_t
+perfmgr_db_delete_entry(perfmgr_db_t * db, uint64_t guid)
+{
+ cl_map_item_t * rc = cl_qmap_remove(&db->pc_data, guid);
+
+ if (rc == cl_qmap_end(&db->pc_data))
+ return(PERFMGR_EVENT_DB_GUIDNOTFOUND);
+
+ db_node_t *pc_node = (db_node_t *)rc;
+ free_node(pc_node);
+ return(PERFMGR_EVENT_DB_SUCCESS);
+}
+
+perfmgr_db_err_t
+perfmgr_db_delete_inactive(perfmgr_db_t * db, unsigned *cnt)
+{
+ perfmgr_db_err_t rc = PERFMGR_EVENT_DB_SUCCESS;
+ int i = 0;
+ int num = 0;
+ uint64_t * guid_list = NULL;
+ cl_map_item_t * p_map_item = cl_qmap_head(&db->pc_data);
+
+ if (p_map_item == cl_qmap_end(&db->pc_data)) {
+ rc = PERFMGR_EVENT_DB_SUCCESS;
+ goto Done;
+ }
+
+ while (p_map_item != cl_qmap_end(&db->pc_data)) {
+ db_node_t *n = (db_node_t *)p_map_item;
+ if (n->active == FALSE) {
+ guid_list = realloc(guid_list,
+ sizeof(*guid_list) * (num+1));
+ if (!guid_list) {
+ num = 0;
+ rc = PERFMGR_EVENT_DB_NOMEM;
+ goto Done;
+ }
+ guid_list[num] = n->node_guid;
+ num++;
+ }
+ p_map_item = cl_qmap_next(p_map_item);
+ }
+
+ for (i = 0 ; i < num; i++)
+ perfmgr_db_delete_entry(db, guid_list[i]);
+
+ free(guid_list);
+
+Done:
+ if (cnt)
+ *cnt = num;
+
+ return(rc);
+}
+
+perfmgr_db_err_t
+perfmgr_db_mark_active(perfmgr_db_t *db, uint64_t guid, boolean_t active)
+{
+ db_node_t *node = NULL;
+
+ cl_plock_excl_acquire(&db->lock);
+ node = get(db, guid);
+ if (node)
+ node->active = active;
+ cl_plock_release(&db->lock);
+ return (PERFMGR_EVENT_DB_SUCCESS);
+}
+
+
+/**********************************************************************
+ * Dump a reading vs the previous reading to stdout
+ **********************************************************************/
+static inline void
+debug_dump_err_reading(perfmgr_db_t * db, uint64_t guid, uint8_t port_num,
+ db_port_t * port, perfmgr_db_err_reading_t * cur)
+{
+ osm_log_t *log = db->perfmgr->log;
+
+ if (!OSM_LOG_IS_ACTIVE_V2(log, OSM_LOG_DEBUG))
+ return; /* optimize this a bit */
+
+ osm_log_v2(log, OSM_LOG_DEBUG, FILE_ID,
+ "GUID 0x%" PRIx64 " Port %u:\n", guid, port_num);
+ osm_log_v2(log, OSM_LOG_DEBUG, FILE_ID,
+ "sym %" PRIu64 " <-- %" PRIu64 " (%" PRIu64 ")\n",
+ cur->symbol_err_cnt, port->err_previous.symbol_err_cnt,
+ port->err_total.symbol_err_cnt);
+ osm_log_v2(log, OSM_LOG_DEBUG, FILE_ID,
+ "ler %" PRIu64 " <-- %" PRIu64 " (%" PRIu64 ")\n",
+ cur->link_err_recover, port->err_previous.link_err_recover,
+ port->err_total.link_err_recover);
+ osm_log_v2(log, OSM_LOG_DEBUG, FILE_ID,
+ "ld %" PRIu64 " <-- %" PRIu64 " (%" PRIu64 ")\n",
+ cur->link_downed, port->err_previous.link_downed,
+ port->err_total.link_downed);
+ osm_log_v2(log, OSM_LOG_DEBUG, FILE_ID,
+ "re %" PRIu64 " <-- %" PRIu64 " (%" PRIu64 ")\n", cur->rcv_err,
+ port->err_previous.rcv_err, port->err_total.rcv_err);
+ osm_log_v2(log, OSM_LOG_DEBUG, FILE_ID,
+ "rrp %" PRIu64 " <-- %" PRIu64 " (%" PRIu64 ")\n",
+ cur->rcv_rem_phys_err, port->err_previous.rcv_rem_phys_err,
+ port->err_total.rcv_rem_phys_err);
+ osm_log_v2(log, OSM_LOG_DEBUG, FILE_ID,
+ "rsr %" PRIu64 " <-- %" PRIu64 " (%" PRIu64 ")\n",
+ cur->rcv_switch_relay_err,
+ port->err_previous.rcv_switch_relay_err,
+ port->err_total.rcv_switch_relay_err);
+ osm_log_v2(log, OSM_LOG_DEBUG, FILE_ID,
+ "xd %" PRIu64 " <-- %" PRIu64 " (%" PRIu64 ")\n",
+ cur->xmit_discards, port->err_previous.xmit_discards,
+ port->err_total.xmit_discards);
+ osm_log_v2(log, OSM_LOG_DEBUG, FILE_ID,
+ "xce %" PRIu64 " <-- %" PRIu64 " (%" PRIu64 ")\n",
+ cur->xmit_constraint_err,
+ port->err_previous.xmit_constraint_err,
+ port->err_total.xmit_constraint_err);
+ osm_log_v2(log, OSM_LOG_DEBUG, FILE_ID,
+ "rce %" PRIu64 " <-- %" PRIu64 " (%" PRIu64 ")\n",
+ cur->rcv_constraint_err, port->err_previous.rcv_constraint_err,
+ port->err_total.rcv_constraint_err);
+ osm_log_v2(log, OSM_LOG_DEBUG, FILE_ID,
+ "li %" PRIu64 " <-- %" PRIu64 " (%" PRIu64 ")\n",
+ cur->link_integrity, port->err_previous.link_integrity,
+ port->err_total.link_integrity);
+ osm_log_v2(log, OSM_LOG_DEBUG, FILE_ID,
+ "bo %" PRIu64 " <-- %" PRIu64 " (%" PRIu64 ")\n",
+ cur->buffer_overrun, port->err_previous.buffer_overrun,
+ port->err_total.buffer_overrun);
+ osm_log_v2(log, OSM_LOG_DEBUG, FILE_ID,
+ "vld %" PRIu64 " <-- %" PRIu64 " (%" PRIu64 ")\n",
+ cur->vl15_dropped, port->err_previous.vl15_dropped,
+ port->err_total.vl15_dropped);
+ osm_log_v2(log, OSM_LOG_DEBUG, FILE_ID,
+ "xw %" PRIu64 " <-- %" PRIu64 " (%" PRIu64 ")\n",
+ cur->xmit_wait, port->err_previous.xmit_wait,
+ port->err_total.xmit_wait);
+}
+
+/**********************************************************************
+ * perfmgr_db_err_reading_t functions
+ **********************************************************************/
+perfmgr_db_err_t
+perfmgr_db_add_err_reading(perfmgr_db_t * db, uint64_t guid, uint8_t port,
+ perfmgr_db_err_reading_t * reading)
+{
+ db_port_t *p_port = NULL;
+ db_node_t *node = NULL;
+ perfmgr_db_err_reading_t *previous = NULL;
+ perfmgr_db_err_t rc = PERFMGR_EVENT_DB_SUCCESS;
+ osm_epi_pe_event_t epi_pe_data;
+
+ cl_plock_excl_acquire(&db->lock);
+ node = get(db, guid);
+ if ((rc = bad_node_port(node, port)) != PERFMGR_EVENT_DB_SUCCESS)
+ goto Exit;
+
+ mark_port_valid(node, port);
+
+ p_port = &(node->ports[port]);
+ previous = &(node->ports[port].err_previous);
+
+ debug_dump_err_reading(db, guid, port, p_port, reading);
+
+ epi_pe_data.time_diff_s = (reading->time - previous->time);
+ osm_epi_create_port_id(&epi_pe_data.port_id, guid, port,
+ node->node_name);
+
+ /* calculate changes from previous reading */
+ epi_pe_data.symbol_err_cnt =
+ (reading->symbol_err_cnt - previous->symbol_err_cnt);
+ p_port->err_total.symbol_err_cnt += epi_pe_data.symbol_err_cnt;
+ epi_pe_data.link_err_recover =
+ (reading->link_err_recover - previous->link_err_recover);
+ p_port->err_total.link_err_recover += epi_pe_data.link_err_recover;
+ epi_pe_data.link_downed =
+ (reading->link_downed - previous->link_downed);
+ p_port->err_total.link_downed += epi_pe_data.link_downed;
+ epi_pe_data.rcv_err = (reading->rcv_err - previous->rcv_err);
+ p_port->err_total.rcv_err += epi_pe_data.rcv_err;
+ epi_pe_data.rcv_rem_phys_err =
+ (reading->rcv_rem_phys_err - previous->rcv_rem_phys_err);
+ p_port->err_total.rcv_rem_phys_err += epi_pe_data.rcv_rem_phys_err;
+ epi_pe_data.rcv_switch_relay_err =
+ (reading->rcv_switch_relay_err - previous->rcv_switch_relay_err);
+ p_port->err_total.rcv_switch_relay_err +=
+ epi_pe_data.rcv_switch_relay_err;
+ epi_pe_data.xmit_discards =
+ (reading->xmit_discards - previous->xmit_discards);
+ p_port->err_total.xmit_discards += epi_pe_data.xmit_discards;
+ epi_pe_data.xmit_constraint_err =
+ (reading->xmit_constraint_err - previous->xmit_constraint_err);
+ p_port->err_total.xmit_constraint_err +=
+ epi_pe_data.xmit_constraint_err;
+ epi_pe_data.rcv_constraint_err =
+ (reading->rcv_constraint_err - previous->rcv_constraint_err);
+ p_port->err_total.rcv_constraint_err += epi_pe_data.rcv_constraint_err;
+ epi_pe_data.link_integrity =
+ (reading->link_integrity - previous->link_integrity);
+ p_port->err_total.link_integrity += epi_pe_data.link_integrity;
+ epi_pe_data.buffer_overrun =
+ (reading->buffer_overrun - previous->buffer_overrun);
+ p_port->err_total.buffer_overrun += epi_pe_data.buffer_overrun;
+ epi_pe_data.vl15_dropped =
+ (reading->vl15_dropped - previous->vl15_dropped);
+ p_port->err_total.vl15_dropped += epi_pe_data.vl15_dropped;
+ epi_pe_data.xmit_wait =
+ (reading->xmit_wait - previous->xmit_wait);
+ p_port->err_total.xmit_wait += epi_pe_data.xmit_wait;
+
+ p_port->err_previous = *reading;
+
+ /* mark the time this total was updated */
+ p_port->err_total.time = reading->time;
+
+ osm_opensm_report_event(db->perfmgr->osm, OSM_EVENT_ID_PORT_ERRORS,
+ &epi_pe_data);
+
+Exit:
+ cl_plock_release(&db->lock);
+ return rc;
+}
+
+perfmgr_db_err_t perfmgr_db_get_prev_err(perfmgr_db_t * db, uint64_t guid,
+ uint8_t port,
+ perfmgr_db_err_reading_t * reading)
+{
+ db_node_t *node = NULL;
+ perfmgr_db_err_t rc = PERFMGR_EVENT_DB_SUCCESS;
+
+ cl_plock_acquire(&db->lock);
+
+ node = get(db, guid);
+ if ((rc = bad_node_port(node, port)) != PERFMGR_EVENT_DB_SUCCESS)
+ goto Exit;
+
+ *reading = node->ports[port].err_previous;
+
+Exit:
+ cl_plock_release(&db->lock);
+ return rc;
+}
+
+perfmgr_db_err_t
+perfmgr_db_clear_prev_err(perfmgr_db_t * db, uint64_t guid, uint8_t port)
+{
+ db_node_t *node = NULL;
+ perfmgr_db_err_reading_t *previous = NULL;
+ perfmgr_db_err_t rc = PERFMGR_EVENT_DB_SUCCESS;
+
+ cl_plock_excl_acquire(&db->lock);
+ node = get(db, guid);
+ if ((rc = bad_node_port(node, port)) != PERFMGR_EVENT_DB_SUCCESS)
+ goto Exit;
+
+ previous = &(node->ports[port].err_previous);
+
+ memset(previous, 0, sizeof(*previous));
+ node->ports[port].err_previous.time = time(NULL);
+
+Exit:
+ cl_plock_release(&db->lock);
+ return rc;
+}
+
+static inline void
+debug_dump_dc_reading(perfmgr_db_t * db, uint64_t guid, uint8_t port_num,
+ db_port_t * port, perfmgr_db_data_cnt_reading_t * cur)
+{
+ osm_log_t *log = db->perfmgr->log;
+ if (!OSM_LOG_IS_ACTIVE_V2(log, OSM_LOG_DEBUG))
+ return;
+
+ osm_log_v2(log, OSM_LOG_DEBUG, FILE_ID,
+ "xd %" PRIu64 " <-- %" PRIu64 " (%" PRIu64 ")\n",
+ cur->xmit_data, port->dc_previous.xmit_data,
+ port->dc_total.xmit_data);
+ osm_log_v2(log, OSM_LOG_DEBUG, FILE_ID,
+ "rd %" PRIu64 " <-- %" PRIu64 " (%" PRIu64 ")\n", cur->rcv_data,
+ port->dc_previous.rcv_data, port->dc_total.rcv_data);
+ osm_log_v2(log, OSM_LOG_DEBUG, FILE_ID,
+ "xp %" PRIu64 " <-- %" PRIu64 " (%" PRIu64 ")\n",
+ cur->xmit_pkts, port->dc_previous.xmit_pkts,
+ port->dc_total.xmit_pkts);
+ osm_log_v2(log, OSM_LOG_DEBUG, FILE_ID,
+ "rp %" PRIu64 " <-- %" PRIu64 " (%" PRIu64 ")\n", cur->rcv_pkts,
+ port->dc_previous.rcv_pkts, port->dc_total.rcv_pkts);
+}
+
+/**********************************************************************
+ * perfmgr_db_data_cnt_reading_t functions
+ **********************************************************************/
+perfmgr_db_err_t
+perfmgr_db_add_dc_reading(perfmgr_db_t * db, uint64_t guid, uint8_t port,
+ perfmgr_db_data_cnt_reading_t * reading,
+ int ietf_sup)
+{
+ db_port_t *p_port = NULL;
+ db_node_t *node = NULL;
+ perfmgr_db_data_cnt_reading_t *previous = NULL;
+ perfmgr_db_err_t rc = PERFMGR_EVENT_DB_SUCCESS;
+ osm_epi_dc_event_t epi_dc_data;
+
+ cl_plock_excl_acquire(&db->lock);
+ node = get(db, guid);
+ if ((rc = bad_node_port(node, port)) != PERFMGR_EVENT_DB_SUCCESS)
+ goto Exit;
+
+ mark_port_valid(node, port);
+
+ p_port = &node->ports[port];
+ previous = &node->ports[port].dc_previous;
+
+ debug_dump_dc_reading(db, guid, port, p_port, reading);
+
+ epi_dc_data.time_diff_s = reading->time - previous->time;
+ osm_epi_create_port_id(&epi_dc_data.port_id, guid, port,
+ node->node_name);
+
+ /* calculate changes from previous reading */
+ epi_dc_data.xmit_data = reading->xmit_data - previous->xmit_data;
+ p_port->dc_total.xmit_data += epi_dc_data.xmit_data;
+ epi_dc_data.rcv_data = reading->rcv_data - previous->rcv_data;
+ p_port->dc_total.rcv_data += epi_dc_data.rcv_data;
+ epi_dc_data.xmit_pkts = reading->xmit_pkts - previous->xmit_pkts;
+ p_port->dc_total.xmit_pkts += epi_dc_data.xmit_pkts;
+ epi_dc_data.rcv_pkts = reading->rcv_pkts - previous->rcv_pkts;
+ p_port->dc_total.rcv_pkts += epi_dc_data.rcv_pkts;
+
+ if (ietf_sup)
+ {
+ epi_dc_data.unicast_xmit_pkts =
+ reading->unicast_xmit_pkts - previous->unicast_xmit_pkts;
+ p_port->dc_total.unicast_xmit_pkts += epi_dc_data.unicast_xmit_pkts;
+ epi_dc_data.unicast_rcv_pkts =
+ reading->unicast_rcv_pkts - previous->unicast_rcv_pkts;
+ p_port->dc_total.unicast_rcv_pkts += epi_dc_data.unicast_rcv_pkts;
+ epi_dc_data.multicast_xmit_pkts =
+ reading->multicast_xmit_pkts - previous->multicast_xmit_pkts;
+ p_port->dc_total.multicast_xmit_pkts += epi_dc_data.multicast_xmit_pkts;
+ epi_dc_data.multicast_rcv_pkts =
+ reading->multicast_rcv_pkts - previous->multicast_rcv_pkts;
+ p_port->dc_total.multicast_rcv_pkts += epi_dc_data.multicast_rcv_pkts;
+ }
+
+ p_port->dc_previous = *reading;
+
+ /* mark the time this total was updated */
+ p_port->dc_total.time = reading->time;
+
+ osm_opensm_report_event(db->perfmgr->osm,
+ OSM_EVENT_ID_PORT_DATA_COUNTERS, &epi_dc_data);
+
+Exit:
+ cl_plock_release(&db->lock);
+ return rc;
+}
+
+perfmgr_db_err_t perfmgr_db_get_prev_dc(perfmgr_db_t * db, uint64_t guid,
+ uint8_t port,
+ perfmgr_db_data_cnt_reading_t * reading)
+{
+ db_node_t *node = NULL;
+ perfmgr_db_err_t rc = PERFMGR_EVENT_DB_SUCCESS;
+
+ cl_plock_acquire(&db->lock);
+
+ node = get(db, guid);
+ if ((rc = bad_node_port(node, port)) != PERFMGR_EVENT_DB_SUCCESS)
+ goto Exit;
+
+ *reading = node->ports[port].dc_previous;
+
+Exit:
+ cl_plock_release(&db->lock);
+ return rc;
+}
+
+perfmgr_db_err_t
+perfmgr_db_clear_prev_dc(perfmgr_db_t * db, uint64_t guid, uint8_t port)
+{
+ db_node_t *node = NULL;
+ perfmgr_db_data_cnt_reading_t *previous = NULL;
+ perfmgr_db_err_t rc = PERFMGR_EVENT_DB_SUCCESS;
+
+ cl_plock_excl_acquire(&db->lock);
+ node = get(db, guid);
+ if ((rc = bad_node_port(node, port)) != PERFMGR_EVENT_DB_SUCCESS)
+ goto Exit;
+
+ previous = &node->ports[port].dc_previous;
+
+ memset(previous, 0, sizeof(*previous));
+ node->ports[port].dc_previous.time = time(NULL);
+
+Exit:
+ cl_plock_release(&db->lock);
+ return rc;
+}
+
+static void clear_counters(cl_map_item_t * const p_map_item, void *context)
+{
+ db_node_t *node = (db_node_t *) p_map_item;
+ int i = 0;
+ time_t ts = time(NULL);
+
+ for (i = 0; i < node->num_ports; i++) {
+ node->ports[i].err_total.symbol_err_cnt = 0;
+ node->ports[i].err_total.link_err_recover = 0;
+ node->ports[i].err_total.link_downed = 0;
+ node->ports[i].err_total.rcv_err = 0;
+ node->ports[i].err_total.rcv_rem_phys_err = 0;
+ node->ports[i].err_total.rcv_switch_relay_err = 0;
+ node->ports[i].err_total.xmit_discards = 0;
+ node->ports[i].err_total.xmit_constraint_err = 0;
+ node->ports[i].err_total.rcv_constraint_err = 0;
+ node->ports[i].err_total.link_integrity = 0;
+ node->ports[i].err_total.buffer_overrun = 0;
+ node->ports[i].err_total.vl15_dropped = 0;
+ node->ports[i].err_total.xmit_wait = 0;
+ node->ports[i].err_total.time = ts;
+
+ node->ports[i].dc_total.xmit_data = 0;
+ node->ports[i].dc_total.rcv_data = 0;
+ node->ports[i].dc_total.xmit_pkts = 0;
+ node->ports[i].dc_total.rcv_pkts = 0;
+ node->ports[i].dc_total.unicast_xmit_pkts = 0;
+ node->ports[i].dc_total.unicast_rcv_pkts = 0;
+ node->ports[i].dc_total.multicast_xmit_pkts = 0;
+ node->ports[i].dc_total.multicast_rcv_pkts = 0;
+ node->ports[i].dc_total.time = ts;
+
+ node->ports[i].last_reset = ts;
+ }
+}
+
+/**********************************************************************
+ * Clear all the counters from the db
+ **********************************************************************/
+void perfmgr_db_clear_counters(perfmgr_db_t * db)
+{
+ cl_plock_excl_acquire(&db->lock);
+ cl_qmap_apply_func(&db->pc_data, clear_counters, (void *)db);
+ cl_plock_release(&db->lock);
+#if 0
+ if (db->db_impl->clear_counters)
+ db->db_impl->clear_counters(db->db_data);
+#endif
+}
+
+/**********************************************************************
+ * Output a tab delimited output of the port counters
+ **********************************************************************/
+static void dump_node_mr(db_node_t * node, FILE * fp)
+{
+ int i = 0;
+
+ fprintf(fp, "\nName\tGUID\tActive\tPort\tLast Reset\t"
+ "Last Error Update\tLast Data Update\t"
+ "%s\t%s\t"
+ "%s\t%s\t%s\t%s\t%s\t%s\t%s\t"
+ "%s\t%s\t%s\t%s\t%s\t%s\t%s\t"
+ "%s\t%s\t%s\t%s\t%s\n",
+ "symbol_err_cnt",
+ "link_err_recover",
+ "link_downed",
+ "rcv_err",
+ "rcv_rem_phys_err",
+ "rcv_switch_relay_err",
+ "xmit_discards",
+ "xmit_constraint_err",
+ "rcv_constraint_err",
+ "link_int_err",
+ "buf_overrun_err",
+ "vl15_dropped",
+ "xmit_wait",
+ "xmit_data",
+ "rcv_data",
+ "xmit_pkts",
+ "rcv_pkts",
+ "unicast_xmit_pkts",
+ "unicast_rcv_pkts",
+ "multicast_xmit_pkts",
+ "multicast_rcv_pkts");
+ for (i = (node->esp0) ? 0 : 1; i < node->num_ports; i++) {
+ char lr[128];
+ char *last_reset = ctime_r(&node->ports[i].last_reset, lr);
+ char leu[128];
+ char *last_err_update = ctime_r(&node->ports[i].err_total.time, leu);
+ char ldu[128];
+ char *last_data_update = ctime_r(&node->ports[i].dc_total.time, ldu);
+
+ if (!node->ports[i].valid)
+ continue;
+
+ last_reset[strlen(last_reset) - 1] = '\0'; /* remove \n */
+ last_err_update[strlen(last_err_update) - 1] = '\0'; /* remove \n */
+ last_data_update[strlen(last_data_update) - 1] = '\0'; /* remove \n */
+
+ fprintf(fp,
+ "%s\t0x%" PRIx64 "\t%s\t%d\t%s\t%s\t%s\t%" PRIu64 "\t%" PRIu64 "\t"
+ "%" PRIu64 "\t%" PRIu64 "\t%" PRIu64 "\t%" PRIu64 "\t"
+ "%" PRIu64 "\t%" PRIu64 "\t%" PRIu64 "\t" "%" PRIu64
+ "\t%" PRIu64 "\t%" PRIu64 "\t" "%" PRIu64 "\t%" PRIu64
+ "\t%" PRIu64 "\t%" PRIu64 "\t" "%" PRIu64 "\t%" PRIu64
+ "\t%" PRIu64 "\t%" PRIu64 "\t%" PRIu64 "\n", node->node_name,
+ node->node_guid,
+ node->active ? "TRUE" : "FALSE",
+ i, last_reset, last_err_update, last_data_update,
+ node->ports[i].err_total.symbol_err_cnt,
+ node->ports[i].err_total.link_err_recover,
+ node->ports[i].err_total.link_downed,
+ node->ports[i].err_total.rcv_err,
+ node->ports[i].err_total.rcv_rem_phys_err,
+ node->ports[i].err_total.rcv_switch_relay_err,
+ node->ports[i].err_total.xmit_discards,
+ node->ports[i].err_total.xmit_constraint_err,
+ node->ports[i].err_total.rcv_constraint_err,
+ node->ports[i].err_total.link_integrity,
+ node->ports[i].err_total.buffer_overrun,
+ node->ports[i].err_total.vl15_dropped,
+ node->ports[i].err_total.xmit_wait,
+ node->ports[i].dc_total.xmit_data,
+ node->ports[i].dc_total.rcv_data,
+ node->ports[i].dc_total.xmit_pkts,
+ node->ports[i].dc_total.rcv_pkts,
+ node->ports[i].dc_total.unicast_xmit_pkts,
+ node->ports[i].dc_total.unicast_rcv_pkts,
+ node->ports[i].dc_total.multicast_xmit_pkts,
+ node->ports[i].dc_total.multicast_rcv_pkts);
+ }
+}
+
+static void dump_hr_dc(FILE *fp, uint64_t val64, int data)
+{
+ const char *unit = "";
+ uint64_t tmp = val64;
+ float val = 0.0;
+ int ui = 0;
+ uint64_t div = 1;
+
+ tmp /= 1024;
+ while (tmp) {
+ ui++;
+ tmp /= 1024;
+ div *= 1024;
+ }
+
+ val = (float)(val64);
+ if (data) {
+ val *= 4;
+ if (val/div > 1024) {
+ ui++;
+ div *= 1024;
+ }
+ }
+ val /= div;
+
+ switch (ui) {
+ case 1:
+ unit = "K";
+ break;
+ case 2:
+ unit = "M";
+ break;
+ case 3:
+ unit = "G";
+ break;
+ case 4:
+ unit = "T";
+ break;
+ case 5:
+ unit = "P";
+ break;
+ case 6:
+ unit = "E";
+ break;
+ }
+
+ fprintf(fp, " (%5.3f%s%s)\n", val, unit, data ? "B" : "");
+}
+
+/**********************************************************************
+ * Output a human readable output of the port counters
+ **********************************************************************/
+static void dump_node_hr(db_node_t * node, FILE * fp, char *port, int err_only)
+{
+ int i = (node->esp0) ? 0 : 1;
+ int num_ports = node->num_ports;
+
+ if (port) {
+ char *end = NULL;
+ int p = strtoul(port, &end, 0);
+ if (port + strlen(port) == end && p >= i && p < num_ports) {
+ i = p;
+ num_ports = p+1;
+ } else {
+ fprintf(fp, "Warning: \"%s\" is not a valid port\n", port);
+ }
+ }
+ for (/* set above */; i < num_ports; i++) {
+ char lr[128];
+ char *last_reset = ctime_r(&node->ports[i].last_reset, lr);
+ char leu[128];
+ char *last_err_update = ctime_r(&node->ports[i].err_total.time, leu);
+ char ldu[128];
+ char *last_data_update = ctime_r(&node->ports[i].dc_total.time, ldu);
+
+ if (!node->ports[i].valid)
+ continue;
+
+ last_reset[strlen(last_reset) - 1] = '\0'; /* remove \n */
+ last_err_update[strlen(last_err_update) - 1] = '\0'; /* remove \n */
+ last_data_update[strlen(last_data_update) - 1] = '\0'; /* remove \n */
+
+ perfmgr_db_err_reading_t *err = &node->ports[i].err_total;
+
+ if (err_only
+ && err->symbol_err_cnt == 0
+ && err->link_err_recover == 0
+ && err->link_downed == 0
+ && err->rcv_err == 0
+ && err->rcv_rem_phys_err == 0
+ && err->rcv_switch_relay_err == 0
+ && err->xmit_discards == 0
+ && err->xmit_constraint_err == 0
+ && err->rcv_constraint_err == 0
+ && err->link_integrity == 0
+ && err->buffer_overrun == 0
+ && err->vl15_dropped == 0
+ && err->xmit_wait == 0)
+ continue;
+
+ fprintf(fp, "\"%s\" 0x%" PRIx64 " active %s port %d\n"
+ " Last Reset : %s\n"
+ " Last Error Update : %s\n",
+ node->node_name, node->node_guid,
+ node->active ? "TRUE":"FALSE", i, last_reset,
+ last_err_update);
+
+ if (!err_only || err->symbol_err_cnt != 0)
+ fprintf(fp, " symbol_err_cnt : %" PRIu64 "\n",
+ err->symbol_err_cnt);
+ if (!err_only || err->link_err_recover != 0)
+ fprintf(fp, " link_err_recover : %" PRIu64 "\n",
+ err->link_err_recover);
+ if (!err_only || err->link_downed != 0)
+ fprintf(fp, " link_downed : %" PRIu64 "\n",
+ err->link_downed);
+ if (!err_only || err->rcv_err != 0)
+ fprintf(fp, " rcv_err : %" PRIu64 "\n",
+ err->rcv_err);
+ if (!err_only || err->rcv_rem_phys_err != 0)
+ fprintf(fp, " rcv_rem_phys_err : %" PRIu64 "\n",
+ err->rcv_rem_phys_err);
+ if (!err_only || err->rcv_switch_relay_err != 0)
+ fprintf(fp, " rcv_switch_relay_err : %" PRIu64 "\n",
+ err->rcv_switch_relay_err);
+ if (!err_only || err->xmit_discards != 0)
+ fprintf(fp, " xmit_discards : %" PRIu64 "\n",
+ err->xmit_discards);
+ if (!err_only || err->xmit_constraint_err != 0)
+ fprintf(fp, " xmit_constraint_err : %" PRIu64 "\n",
+ err->xmit_constraint_err);
+ if (!err_only || err->rcv_constraint_err != 0)
+ fprintf(fp, " rcv_constraint_err : %" PRIu64 "\n",
+ err->rcv_constraint_err);
+ if (!err_only || err->link_integrity != 0)
+ fprintf(fp, " link_integrity_err : %" PRIu64 "\n",
+ err->link_integrity);
+ if (!err_only || err->buffer_overrun != 0)
+ fprintf(fp, " buf_overrun_err : %" PRIu64 "\n",
+ err->buffer_overrun);
+ if (!err_only || err->vl15_dropped != 0)
+ fprintf(fp, " vl15_dropped : %" PRIu64 "\n",
+ err->vl15_dropped);
+ if (!err_only || err->xmit_wait != 0)
+ fprintf(fp, " xmit_wait : %" PRIu64 "\n",
+ err->xmit_wait);
+
+ if (err_only)
+ continue;
+
+ fprintf(fp, " Last Data Update : %s\n",
+ last_data_update);
+ fprintf(fp, " xmit_data : %" PRIu64,
+ node->ports[i].dc_total.xmit_data);
+ dump_hr_dc(fp, node->ports[i].dc_total.xmit_data, 1);
+ fprintf(fp, " rcv_data : %" PRIu64,
+ node->ports[i].dc_total.rcv_data);
+ dump_hr_dc(fp, node->ports[i].dc_total.rcv_data, 1);
+ fprintf(fp, " xmit_pkts : %" PRIu64,
+ node->ports[i].dc_total.xmit_pkts);
+ dump_hr_dc(fp, node->ports[i].dc_total.xmit_pkts, 0);
+ fprintf(fp, " rcv_pkts : %" PRIu64,
+ node->ports[i].dc_total.rcv_pkts);
+ dump_hr_dc(fp, node->ports[i].dc_total.rcv_pkts, 0);
+ fprintf(fp, " unicast_xmit_pkts : %" PRIu64,
+ node->ports[i].dc_total.unicast_xmit_pkts);
+ dump_hr_dc(fp, node->ports[i].dc_total.unicast_xmit_pkts, 0);
+ fprintf(fp, " unicast_rcv_pkts : %" PRIu64,
+ node->ports[i].dc_total.unicast_rcv_pkts);
+ dump_hr_dc(fp, node->ports[i].dc_total.unicast_rcv_pkts, 0);
+ fprintf(fp, " multicast_xmit_pkts : %" PRIu64,
+ node->ports[i].dc_total.multicast_xmit_pkts);
+ dump_hr_dc(fp, node->ports[i].dc_total.multicast_xmit_pkts, 0);
+ fprintf(fp, " multicast_rcv_pkts : %" PRIu64,
+ node->ports[i].dc_total.multicast_rcv_pkts);
+ dump_hr_dc(fp, node->ports[i].dc_total.multicast_rcv_pkts, 0);
+
+ }
+}
+
+/* Define a context for the __db_dump callback */
+typedef struct {
+ FILE *fp;
+ perfmgr_db_dump_t dump_type;
+} dump_context_t;
+
+static void db_dump(cl_map_item_t * const p_map_item, void *context)
+{
+ db_node_t *node = (db_node_t *) p_map_item;
+ dump_context_t *c = (dump_context_t *) context;
+ FILE *fp = c->fp;
+
+ switch (c->dump_type) {
+ case PERFMGR_EVENT_DB_DUMP_MR:
+ dump_node_mr(node, fp);
+ break;
+ case PERFMGR_EVENT_DB_DUMP_HR:
+ default:
+ dump_node_hr(node, fp, NULL, 0);
+ break;
+ }
+}
+
+/**********************************************************************
+ * print all node data to fp
+ **********************************************************************/
+void
+perfmgr_db_print_all(perfmgr_db_t * db, FILE *fp, int err_only)
+{
+ cl_map_item_t *item;
+ db_node_t *node;
+
+ cl_plock_acquire(&db->lock);
+ item = cl_qmap_head(&db->pc_data);
+ while (item != cl_qmap_end(&db->pc_data)) {
+ node = (db_node_t *)item;
+ dump_node_hr(node, fp, NULL, err_only);
+ item = cl_qmap_next(item);
+ }
+ cl_plock_release(&db->lock);
+}
+
+/**********************************************************************
+ * print node data to fp
+ **********************************************************************/
+void
+perfmgr_db_print_by_name(perfmgr_db_t * db, char *nodename, FILE *fp,
+ char *port, int err_only)
+{
+ cl_map_item_t *item;
+ db_node_t *node;
+
+ cl_plock_acquire(&db->lock);
+
+ /* find the node */
+ item = cl_qmap_head(&db->pc_data);
+ while (item != cl_qmap_end(&db->pc_data)) {
+ node = (db_node_t *)item;
+ if (strcmp(node->node_name, nodename) == 0) {
+ dump_node_hr(node, fp, port, err_only);
+ goto done;
+ }
+ item = cl_qmap_next(item);
+ }
+
+ fprintf(fp, "Node %s not found...\n", nodename);
+done:
+ cl_plock_release(&db->lock);
+}
+
+/**********************************************************************
+ * print node data to fp
+ **********************************************************************/
+void
+perfmgr_db_print_by_guid(perfmgr_db_t * db, uint64_t nodeguid, FILE *fp,
+ char *port, int err_only)
+{
+ cl_map_item_t *node;
+
+ cl_plock_acquire(&db->lock);
+
+ node = cl_qmap_get(&db->pc_data, nodeguid);
+ if (node != cl_qmap_end(&db->pc_data))
+ dump_node_hr((db_node_t *)node, fp, port, err_only);
+ else
+ fprintf(fp, "Node 0x%" PRIx64 " not found...\n", nodeguid);
+
+ cl_plock_release(&db->lock);
+}
+
+/**********************************************************************
+ * dump the data to the file "file"
+ **********************************************************************/
+perfmgr_db_err_t
+perfmgr_db_dump(perfmgr_db_t * db, char *file, perfmgr_db_dump_t dump_type)
+{
+ dump_context_t context;
+
+ context.fp = fopen(file, "w+");
+ if (!context.fp)
+ return PERFMGR_EVENT_DB_FAIL;
+ context.dump_type = dump_type;
+
+ cl_plock_acquire(&db->lock);
+ cl_qmap_apply_func(&db->pc_data, db_dump, (void *)&context);
+ cl_plock_release(&db->lock);
+ fclose(context.fp);
+ return PERFMGR_EVENT_DB_SUCCESS;
+}
+
+/**********************************************************************
+ * Fill in the various DB objects from their wire counter parts
+ **********************************************************************/
+void
+perfmgr_db_fill_err_read(ib_port_counters_t * wire_read,
+ perfmgr_db_err_reading_t * reading,
+ boolean_t xmit_wait_sup)
+{
+ reading->symbol_err_cnt = cl_ntoh16(wire_read->symbol_err_cnt);
+ reading->link_err_recover = wire_read->link_err_recover;
+ reading->link_downed = wire_read->link_downed;
+ reading->rcv_err = cl_ntoh16(wire_read->rcv_err);
+ reading->rcv_rem_phys_err = cl_ntoh16(wire_read->rcv_rem_phys_err);
+ reading->rcv_switch_relay_err =
+ cl_ntoh16(wire_read->rcv_switch_relay_err);
+ reading->xmit_discards = cl_ntoh16(wire_read->xmit_discards);
+ reading->xmit_constraint_err = wire_read->xmit_constraint_err;
+ reading->rcv_constraint_err = wire_read->rcv_constraint_err;
+ reading->link_integrity =
+ PC_LINK_INT(wire_read->link_int_buffer_overrun);
+ reading->buffer_overrun =
+ PC_BUF_OVERRUN(wire_read->link_int_buffer_overrun);
+ reading->vl15_dropped = cl_ntoh16(wire_read->vl15_dropped);
+ if (xmit_wait_sup)
+ reading->xmit_wait = cl_ntoh32(wire_read->xmit_wait);
+ else
+ reading->xmit_wait = 0;
+ reading->time = time(NULL);
+}
+
+void
+perfmgr_db_fill_data_cnt_read_pc(ib_port_counters_t * wire_read,
+ perfmgr_db_data_cnt_reading_t * reading)
+{
+ reading->xmit_data = cl_ntoh32(wire_read->xmit_data);
+ reading->rcv_data = cl_ntoh32(wire_read->rcv_data);
+ reading->xmit_pkts = cl_ntoh32(wire_read->xmit_pkts);
+ reading->rcv_pkts = cl_ntoh32(wire_read->rcv_pkts);
+ reading->unicast_xmit_pkts = 0;
+ reading->unicast_rcv_pkts = 0;
+ reading->multicast_xmit_pkts = 0;
+ reading->multicast_rcv_pkts = 0;
+ reading->time = time(NULL);
+}
+
+void
+perfmgr_db_fill_data_cnt_read_pce(ib_port_counters_ext_t * wire_read,
+ perfmgr_db_data_cnt_reading_t * reading,
+ int ietf_sup)
+{
+ reading->xmit_data = cl_ntoh64(wire_read->xmit_data);
+ reading->rcv_data = cl_ntoh64(wire_read->rcv_data);
+ reading->xmit_pkts = cl_ntoh64(wire_read->xmit_pkts);
+ reading->rcv_pkts = cl_ntoh64(wire_read->rcv_pkts);
+ if (ietf_sup)
+ {
+ reading->unicast_xmit_pkts = cl_ntoh64(wire_read->unicast_xmit_pkts);
+ reading->unicast_rcv_pkts = cl_ntoh64(wire_read->unicast_rcv_pkts);
+ reading->multicast_xmit_pkts =
+ cl_ntoh64(wire_read->multicast_xmit_pkts);
+ reading->multicast_rcv_pkts = cl_ntoh64(wire_read->multicast_rcv_pkts);
+ }
+ reading->time = time(NULL);
+}
+#endif /* ENABLE_OSM_PERF_MGR */
diff --git a/contrib/ofed/opensm/opensm/osm_pkey.c b/contrib/ofed/opensm/opensm/osm_pkey.c
new file mode 100644
index 0000000..ba27194
--- /dev/null
+++ b/contrib/ofed/opensm/opensm/osm_pkey.c
@@ -0,0 +1,586 @@
+/*
+ * Copyright (c) 2004-2009 Voltaire, Inc. All rights reserved.
+ * Copyright (c) 2002-2012 Mellanox Technologies LTD. All rights reserved.
+ * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+/*
+ * Abstract:
+ * Implementation of opensm pkey manipulation functions.
+ */
+
+#if HAVE_CONFIG_H
+# include <config.h>
+#endif /* HAVE_CONFIG_H */
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <complib/cl_debug.h>
+#include <iba/ib_types.h>
+#include <opensm/osm_file_ids.h>
+#define FILE_ID OSM_FILE_PKEY_C
+#include <opensm/osm_pkey.h>
+#include <opensm/osm_log.h>
+#include <opensm/osm_port.h>
+#include <opensm/osm_node.h>
+#include <opensm/osm_switch.h>
+#include <opensm/osm_helper.h>
+
+void osm_pkey_tbl_construct(IN osm_pkey_tbl_t * p_pkey_tbl)
+{
+ cl_map_construct(&p_pkey_tbl->accum_pkeys);
+ cl_ptr_vector_construct(&p_pkey_tbl->blocks);
+ cl_ptr_vector_construct(&p_pkey_tbl->new_blocks);
+ cl_map_construct(&p_pkey_tbl->keys);
+}
+
+void osm_pkey_tbl_destroy(IN osm_pkey_tbl_t * p_pkey_tbl)
+{
+ ib_pkey_table_t *p_block;
+ uint16_t num_blocks, i;
+
+ num_blocks = (uint16_t) (cl_ptr_vector_get_size(&p_pkey_tbl->blocks));
+ for (i = 0; i < num_blocks; i++)
+ if ((p_block = cl_ptr_vector_get(&p_pkey_tbl->blocks, i)))
+ free(p_block);
+ cl_ptr_vector_destroy(&p_pkey_tbl->blocks);
+
+ num_blocks =
+ (uint16_t) (cl_ptr_vector_get_size(&p_pkey_tbl->new_blocks));
+ for (i = 0; i < num_blocks; i++)
+ if ((p_block = cl_ptr_vector_get(&p_pkey_tbl->new_blocks, i)))
+ free(p_block);
+ cl_ptr_vector_destroy(&p_pkey_tbl->new_blocks);
+
+ cl_map_remove_all(&p_pkey_tbl->accum_pkeys);
+ cl_map_destroy(&p_pkey_tbl->accum_pkeys);
+
+ cl_map_remove_all(&p_pkey_tbl->keys);
+ cl_map_destroy(&p_pkey_tbl->keys);
+}
+
+ib_api_status_t osm_pkey_tbl_init(IN osm_pkey_tbl_t * p_pkey_tbl)
+{
+ cl_map_init(&p_pkey_tbl->accum_pkeys, 1);
+ cl_ptr_vector_init(&p_pkey_tbl->blocks, 0, 1);
+ cl_ptr_vector_init(&p_pkey_tbl->new_blocks, 0, 1);
+ cl_map_init(&p_pkey_tbl->keys, 1);
+ cl_qlist_init(&p_pkey_tbl->pending);
+ p_pkey_tbl->last_pkey_idx = 0;
+ p_pkey_tbl->used_blocks = 0;
+ p_pkey_tbl->max_blocks = 0;
+ p_pkey_tbl->rcv_blocks_cnt = 0;
+ p_pkey_tbl->indx0_pkey = 0;
+ return IB_SUCCESS;
+}
+
+void osm_pkey_tbl_init_new_blocks(IN const osm_pkey_tbl_t * p_pkey_tbl)
+{
+ ib_pkey_table_t *p_block;
+ size_t b, num_blocks = cl_ptr_vector_get_size(&p_pkey_tbl->new_blocks);
+
+ for (b = 0; b < num_blocks; b++)
+ if ((p_block = cl_ptr_vector_get(&p_pkey_tbl->new_blocks, b)))
+ memset(p_block, 0, sizeof(*p_block));
+}
+
+ib_api_status_t osm_pkey_tbl_set(IN osm_pkey_tbl_t * p_pkey_tbl,
+ IN uint16_t block, IN ib_pkey_table_t * p_tbl,
+ IN boolean_t allow_both_pkeys)
+{
+ uint16_t b, i;
+ ib_pkey_table_t *p_pkey_block;
+ uint16_t *p_prev_pkey;
+ ib_net16_t pkey, pkey_base;
+
+ /* make sure the block is allocated */
+ if (cl_ptr_vector_get_size(&p_pkey_tbl->blocks) > block)
+ p_pkey_block =
+ (ib_pkey_table_t *) cl_ptr_vector_get(&p_pkey_tbl->blocks,
+ block);
+ else
+ p_pkey_block = NULL;
+
+ if (!p_pkey_block) {
+ p_pkey_block =
+ (ib_pkey_table_t *) malloc(sizeof(ib_pkey_table_t));
+ if (!p_pkey_block)
+ return IB_ERROR;
+ memset(p_pkey_block, 0, sizeof(ib_pkey_table_t));
+ cl_ptr_vector_set(&p_pkey_tbl->blocks, block, p_pkey_block);
+ }
+
+ /* sets the block values */
+ memcpy(p_pkey_block, p_tbl, sizeof(ib_pkey_table_t));
+
+ /*
+ NOTE: as the spec does not require uniqueness of PKeys in
+ tables there is no other way but to refresh the entire keys map.
+
+ Moreover, if the same key exists but with full membership it should
+ have precedence over the key with limited membership !
+ */
+ cl_map_remove_all(&p_pkey_tbl->keys);
+
+ for (b = 0; b < cl_ptr_vector_get_size(&p_pkey_tbl->blocks); b++) {
+
+ p_pkey_block = cl_ptr_vector_get(&p_pkey_tbl->blocks, b);
+ if (!p_pkey_block)
+ continue;
+
+ for (i = 0; i < IB_NUM_PKEY_ELEMENTS_IN_BLOCK; i++) {
+ pkey = p_pkey_block->pkey_entry[i];
+ if (ib_pkey_is_invalid(pkey))
+ continue;
+
+ if (allow_both_pkeys)
+ pkey_base = pkey;
+ else
+ pkey_base = ib_pkey_get_base(pkey);
+
+ /*
+ If allow_both_pkeys is FALSE,
+ ignore the PKey Full Member bit in the key but store
+ the pointer to the table element as the map value
+ */
+ p_prev_pkey = cl_map_get(&p_pkey_tbl->keys, pkey_base);
+
+ /* we only insert if no previous or it is not full member and allow_both_pkeys is FALSE */
+ if ((p_prev_pkey == NULL) ||
+ (allow_both_pkeys == FALSE &&
+ cl_ntoh16(*p_prev_pkey) < cl_ntoh16(pkey)))
+ cl_map_insert(&p_pkey_tbl->keys, pkey_base,
+ &(p_pkey_block->pkey_entry[i])
+ );
+ }
+ }
+ return IB_SUCCESS;
+}
+
+/*
+ Store the given pkey (along with it's overall index) in the accum_pkeys array.
+*/
+cl_status_t osm_pkey_tbl_set_accum_pkeys(IN osm_pkey_tbl_t * p_pkey_tbl,
+ IN uint16_t pkey,
+ IN uint16_t pkey_idx)
+{
+ uintptr_t ptr = pkey_idx + 1; /* 0 means not found so bias by 1 */
+ uint16_t *p_prev_pkey_idx;
+ cl_status_t status = CL_SUCCESS;
+
+ if (pkey_idx >= p_pkey_tbl->last_pkey_idx)
+ p_pkey_tbl->last_pkey_idx = pkey_idx + 1;
+
+ p_prev_pkey_idx = (uint16_t *) cl_map_get(&p_pkey_tbl->accum_pkeys, pkey);
+
+ if (p_prev_pkey_idx != NULL)
+ cl_map_remove(&p_pkey_tbl->accum_pkeys, pkey);
+
+ if (cl_map_insert(&p_pkey_tbl->accum_pkeys, pkey, (void *) ptr) == NULL)
+ status = CL_INSUFFICIENT_MEMORY;
+
+ return status;
+
+}
+
+/*
++ * Find the next last pkey index
++*/
+void osm_pkey_find_last_accum_pkey_index(IN osm_pkey_tbl_t * p_pkey_tbl)
+{
+ void *ptr;
+ uintptr_t pkey_idx_ptr;
+ uint16_t pkey_idx, last_pkey_idx = 0;
+ cl_map_iterator_t map_iter = cl_map_head(&p_pkey_tbl->accum_pkeys);
+
+ while (map_iter != cl_map_end(&p_pkey_tbl->accum_pkeys)) {
+ ptr = (uint16_t *) cl_map_obj(map_iter);
+ CL_ASSERT(ptr);
+ pkey_idx_ptr = (uintptr_t) ptr;
+ pkey_idx = pkey_idx_ptr;
+ if (pkey_idx > last_pkey_idx)
+ last_pkey_idx = pkey_idx;
+ map_iter = cl_map_next(map_iter);
+ }
+ p_pkey_tbl->last_pkey_idx = last_pkey_idx;
+}
+
+/*
+ Store the given pkey in the "new" blocks array.
+ Also, make sure the regular block exists.
+*/
+ib_api_status_t osm_pkey_tbl_set_new_entry(IN osm_pkey_tbl_t * p_pkey_tbl,
+ IN uint16_t block_idx,
+ IN uint8_t pkey_idx,
+ IN uint16_t pkey)
+{
+ ib_pkey_table_t *p_block;
+
+ if (!(p_block = osm_pkey_tbl_new_block_get(p_pkey_tbl, block_idx))) {
+ p_block = (ib_pkey_table_t *) malloc(sizeof(ib_pkey_table_t));
+ if (!p_block)
+ return IB_ERROR;
+ memset(p_block, 0, sizeof(ib_pkey_table_t));
+ cl_ptr_vector_set(&p_pkey_tbl->new_blocks, block_idx, p_block);
+ }
+
+ p_block->pkey_entry[pkey_idx] = pkey;
+ if (p_pkey_tbl->used_blocks <= block_idx)
+ p_pkey_tbl->used_blocks = block_idx + 1;
+
+ return IB_SUCCESS;
+}
+
+boolean_t osm_pkey_find_next_free_entry(IN osm_pkey_tbl_t * p_pkey_tbl,
+ OUT uint16_t * p_block_idx,
+ OUT uint8_t * p_pkey_idx)
+{
+ ib_pkey_table_t *p_new_block;
+
+ CL_ASSERT(p_block_idx);
+ CL_ASSERT(p_pkey_idx);
+
+ while (*p_block_idx < p_pkey_tbl->max_blocks) {
+ if (*p_pkey_idx > IB_NUM_PKEY_ELEMENTS_IN_BLOCK - 1) {
+ *p_pkey_idx = 0;
+ (*p_block_idx)++;
+ if (*p_block_idx >= p_pkey_tbl->max_blocks)
+ return FALSE;
+ }
+
+ p_new_block =
+ osm_pkey_tbl_new_block_get(p_pkey_tbl, *p_block_idx);
+
+ if (!p_new_block ||
+ ib_pkey_is_invalid(p_new_block->pkey_entry[*p_pkey_idx]))
+ return TRUE;
+ else
+ (*p_pkey_idx)++;
+ }
+ return FALSE;
+}
+
+ib_api_status_t osm_pkey_tbl_get_block_and_idx(IN osm_pkey_tbl_t * p_pkey_tbl,
+ IN uint16_t * p_pkey,
+ OUT uint16_t * p_block_idx,
+ OUT uint8_t * p_pkey_idx)
+{
+ uint16_t num_of_blocks;
+ uint16_t block_index;
+ ib_pkey_table_t *block;
+
+ CL_ASSERT(p_block_idx != NULL);
+ CL_ASSERT(p_pkey_idx != NULL);
+
+ num_of_blocks = (uint16_t) cl_ptr_vector_get_size(&p_pkey_tbl->blocks);
+ for (block_index = 0; block_index < num_of_blocks; block_index++) {
+ block = osm_pkey_tbl_block_get(p_pkey_tbl, block_index);
+ if ((block->pkey_entry <= p_pkey) &&
+ (p_pkey <
+ block->pkey_entry + IB_NUM_PKEY_ELEMENTS_IN_BLOCK)) {
+ *p_block_idx = block_index;
+ *p_pkey_idx = (uint8_t) (p_pkey - block->pkey_entry);
+ return IB_SUCCESS;
+ }
+ }
+ return IB_NOT_FOUND;
+}
+
+static boolean_t match_pkey(IN const ib_net16_t * pkey1,
+ IN const ib_net16_t * pkey2)
+{
+
+ /* if both pkeys are not full member - this is not a match */
+ if (!(ib_pkey_is_full_member(*pkey1) || ib_pkey_is_full_member(*pkey2)))
+ return FALSE;
+
+ /* compare if the bases are the same. if they are - then
+ this is a match */
+ if (ib_pkey_get_base(*pkey1) != ib_pkey_get_base(*pkey2))
+ return FALSE;
+
+ return TRUE;
+}
+
+boolean_t osm_physp_share_this_pkey(IN const osm_physp_t * p_physp1,
+ IN const osm_physp_t * p_physp2,
+ IN ib_net16_t pkey,
+ IN boolean_t allow_both_pkeys)
+{
+ ib_net16_t *pkey1, *pkey2;
+ ib_net16_t full_pkey, limited_pkey;
+
+ if (allow_both_pkeys) {
+ full_pkey = pkey | IB_PKEY_TYPE_MASK;
+ limited_pkey = pkey & ~IB_PKEY_TYPE_MASK;
+ pkey1 = cl_map_get(&(osm_physp_get_pkey_tbl(p_physp1))->keys,
+ full_pkey);
+ if (!pkey1)
+ pkey1 = cl_map_get(&(osm_physp_get_pkey_tbl(p_physp1))->keys,
+ limited_pkey);
+ pkey2 = cl_map_get(&(osm_physp_get_pkey_tbl(p_physp2))->keys,
+ full_pkey);
+ if (!pkey2)
+ pkey2 = cl_map_get(&(osm_physp_get_pkey_tbl(p_physp2))->keys,
+ limited_pkey);
+ } else {
+ pkey1 = cl_map_get(&(osm_physp_get_pkey_tbl(p_physp1))->keys,
+ ib_pkey_get_base(pkey));
+ pkey2 = cl_map_get(&(osm_physp_get_pkey_tbl(p_physp2))->keys,
+ ib_pkey_get_base(pkey));
+ }
+ return (pkey1 && pkey2 && match_pkey(pkey1, pkey2));
+}
+
+ib_net16_t osm_physp_find_common_pkey(IN const osm_physp_t * p_physp1,
+ IN const osm_physp_t * p_physp2,
+ IN boolean_t allow_both_pkeys)
+{
+ ib_net16_t *pkey1, *pkey2;
+ uint64_t pkey1_base, pkey2_base;
+ const osm_pkey_tbl_t *pkey_tbl1, *pkey_tbl2;
+ cl_map_iterator_t map_iter1, map_iter2;
+
+ pkey_tbl1 = osm_physp_get_pkey_tbl(p_physp1);
+ pkey_tbl2 = osm_physp_get_pkey_tbl(p_physp2);
+
+ map_iter1 = cl_map_head(&pkey_tbl1->keys);
+ map_iter2 = cl_map_head(&pkey_tbl2->keys);
+
+ /* we rely on the fact the map are sorted by pkey */
+ while ((map_iter1 != cl_map_end(&pkey_tbl1->keys)) &&
+ (map_iter2 != cl_map_end(&pkey_tbl2->keys))) {
+ pkey1 = (ib_net16_t *) cl_map_obj(map_iter1);
+ pkey2 = (ib_net16_t *) cl_map_obj(map_iter2);
+
+ if (match_pkey(pkey1, pkey2))
+ return *pkey1;
+
+ /* advance the lower value if they are not equal */
+ pkey1_base = cl_map_key(map_iter1);
+ pkey2_base = cl_map_key(map_iter2);
+ if (pkey2_base == pkey1_base) {
+ map_iter1 = cl_map_next(map_iter1);
+ map_iter2 = cl_map_next(map_iter2);
+ } else if (pkey2_base < pkey1_base)
+ map_iter2 = cl_map_next(map_iter2);
+ else
+ map_iter1 = cl_map_next(map_iter1);
+ }
+
+ if (!allow_both_pkeys)
+ return 0;
+
+ /*
+ When using allow_both_pkeys, the keys in pkey tables are the
+ pkey value including membership bit.
+ Therefore, in order to complete the search, we also need to
+ compare port\s 1 full pkeys with port 2 limited pkeys, and
+ port 2 full pkeys with port 1 full pkeys.
+ */
+
+ map_iter1 = cl_map_head(&pkey_tbl1->keys);
+ map_iter2 = cl_map_head(&pkey_tbl2->keys);
+
+ /* comparing pkey_tbl1 full with pkey_tbl2 limited */
+ while ((map_iter1 != cl_map_end(&pkey_tbl1->keys)) &&
+ (map_iter2 != cl_map_end(&pkey_tbl2->keys))) {
+ pkey1 = (ib_net16_t *) cl_map_obj(map_iter1);
+ pkey2 = (ib_net16_t *) cl_map_obj(map_iter2);
+
+ if (!ib_pkey_is_full_member(*pkey1)) {
+ map_iter1 = cl_map_next(map_iter1);
+ continue;
+ }
+ if (ib_pkey_is_full_member(*pkey2)) {
+ map_iter2 = cl_map_next(map_iter2);
+ continue;
+ }
+
+ if (match_pkey(pkey1, pkey2))
+ return *pkey1;
+
+ /* advance the lower value if they are not equal */
+ pkey1_base = ib_pkey_get_base(cl_map_key(map_iter1));
+ pkey2_base = ib_pkey_get_base(cl_map_key(map_iter2));
+ if (pkey2_base == pkey1_base) {
+ map_iter1 = cl_map_next(map_iter1);
+ map_iter2 = cl_map_next(map_iter2);
+ } else if (pkey2_base < pkey1_base)
+ map_iter2 = cl_map_next(map_iter2);
+ else
+ map_iter1 = cl_map_next(map_iter1);
+ }
+
+ map_iter1 = cl_map_head(&pkey_tbl1->keys);
+ map_iter2 = cl_map_head(&pkey_tbl2->keys);
+
+ /* comparing pkey_tbl1 limited with pkey_tbl2 full */
+ while ((map_iter1 != cl_map_end(&pkey_tbl1->keys)) &&
+ (map_iter2 != cl_map_end(&pkey_tbl2->keys))) {
+ pkey1 = (ib_net16_t *) cl_map_obj(map_iter1);
+ pkey2 = (ib_net16_t *) cl_map_obj(map_iter2);
+
+ if (ib_pkey_is_full_member(*pkey1)) {
+ map_iter1 = cl_map_next(map_iter1);
+ continue;
+ }
+ if (!ib_pkey_is_full_member(*pkey2)) {
+ map_iter2 = cl_map_next(map_iter2);
+ continue;
+ }
+
+ if (match_pkey(pkey1, pkey2))
+ return *pkey1;
+
+ /* advance the lower value if they are not equal */
+ pkey1_base = ib_pkey_get_base(cl_map_key(map_iter1));
+ pkey2_base = ib_pkey_get_base(cl_map_key(map_iter2));
+ if (pkey2_base == pkey1_base) {
+ map_iter1 = cl_map_next(map_iter1);
+ map_iter2 = cl_map_next(map_iter2);
+ } else if (pkey2_base < pkey1_base)
+ map_iter2 = cl_map_next(map_iter2);
+ else
+ map_iter1 = cl_map_next(map_iter1);
+ }
+
+ return 0;
+}
+
+boolean_t osm_physp_share_pkey(IN osm_log_t * p_log,
+ IN const osm_physp_t * p_physp_1,
+ IN const osm_physp_t * p_physp_2,
+ IN boolean_t allow_both_pkeys)
+{
+ const osm_pkey_tbl_t *pkey_tbl1, *pkey_tbl2;
+
+ if (p_physp_1 == p_physp_2)
+ return TRUE;
+
+ pkey_tbl1 = osm_physp_get_pkey_tbl(p_physp_1);
+ pkey_tbl2 = osm_physp_get_pkey_tbl(p_physp_2);
+
+ /*
+ The spec: 10.9.2 does not require each phys port to have PKey Table.
+ So actually if it does not, we need to use the default port instead.
+
+ HACK: meanwhile we will ignore the check
+ */
+ if (cl_is_map_empty(&pkey_tbl1->keys)
+ || cl_is_map_empty(&pkey_tbl2->keys))
+ return TRUE;
+
+ return
+ !ib_pkey_is_invalid(osm_physp_find_common_pkey
+ (p_physp_1, p_physp_2, allow_both_pkeys));
+}
+
+boolean_t osm_port_share_pkey(IN osm_log_t * p_log,
+ IN const osm_port_t * p_port_1,
+ IN const osm_port_t * p_port_2,
+ IN boolean_t allow_both_pkeys)
+{
+
+ osm_physp_t *p_physp1, *p_physp2;
+ boolean_t ret;
+
+ OSM_LOG_ENTER(p_log);
+
+ if (!p_port_1 || !p_port_2) {
+ ret = FALSE;
+ goto Exit;
+ }
+
+ p_physp1 = p_port_1->p_physp;
+ p_physp2 = p_port_2->p_physp;
+
+ if (!p_physp1 || !p_physp2) {
+ ret = FALSE;
+ goto Exit;
+ }
+
+ ret = osm_physp_share_pkey(p_log, p_physp1, p_physp2, allow_both_pkeys);
+
+Exit:
+ OSM_LOG_EXIT(p_log);
+ return ret;
+}
+
+boolean_t osm_physp_has_pkey(IN osm_log_t * p_log, IN ib_net16_t pkey,
+ IN const osm_physp_t * p_physp)
+{
+ ib_net16_t *p_pkey, pkey_base;
+ const osm_pkey_tbl_t *pkey_tbl;
+ boolean_t res = FALSE;
+
+ OSM_LOG_ENTER(p_log);
+
+ OSM_LOG(p_log, OSM_LOG_DEBUG,
+ "Search for PKey: 0x%04x\n", cl_ntoh16(pkey));
+
+ /* if the pkey given is an invalid pkey - return TRUE. */
+ if (ib_pkey_is_invalid(pkey)) {
+ OSM_LOG(p_log, OSM_LOG_DEBUG,
+ "Given invalid PKey - we treat it loosely and allow it\n");
+ res = TRUE;
+ goto Exit;
+ }
+
+ pkey_base = ib_pkey_get_base(pkey);
+
+ pkey_tbl = osm_physp_get_pkey_tbl(p_physp);
+
+ p_pkey = cl_map_get(&pkey_tbl->keys, pkey_base);
+ if (p_pkey) {
+ res = TRUE;
+ OSM_LOG(p_log, OSM_LOG_DEBUG,
+ "PKey 0x%04x was found\n", cl_ntoh16(pkey));
+ } else
+ OSM_LOG(p_log, OSM_LOG_DEBUG,
+ "PKey 0x%04x was not found\n", cl_ntoh16(pkey));
+
+Exit:
+ OSM_LOG_EXIT(p_log);
+ return res;
+}
+
+void osm_pkey_tbl_set_indx0_pkey(IN osm_log_t * p_log, IN ib_net16_t pkey,
+ IN boolean_t full,
+ OUT osm_pkey_tbl_t * p_pkey_tbl)
+{
+ p_pkey_tbl->indx0_pkey = (full == TRUE) ?
+ pkey | cl_hton16(0x8000) : pkey;
+ OSM_LOG(p_log, OSM_LOG_DEBUG, "pkey 0x%04x set at indx0\n",
+ cl_ntoh16(p_pkey_tbl->indx0_pkey));
+}
diff --git a/contrib/ofed/opensm/opensm/osm_pkey_mgr.c b/contrib/ofed/opensm/opensm/osm_pkey_mgr.c
new file mode 100644
index 0000000..4e7ae3e
--- /dev/null
+++ b/contrib/ofed/opensm/opensm/osm_pkey_mgr.c
@@ -0,0 +1,890 @@
+/*
+ * Copyright (c) 2004-2009 Voltaire, Inc. All rights reserved.
+ * Copyright (c) 2002-2011 Mellanox Technologies LTD. All rights reserved.
+ * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
+ * Copyright (c) 2009 Sun Microsystems, Inc. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+/*
+ * Abstract:
+ * Implementation of the P_Key Manager (Partition Manager).
+ * This is part of the OpenSM.
+ */
+
+#if HAVE_CONFIG_H
+# include <config.h>
+#endif /* HAVE_CONFIG_H */
+
+#include <string.h>
+#include <iba/ib_types.h>
+#include <complib/cl_qmap.h>
+#include <complib/cl_debug.h>
+#include <opensm/osm_file_ids.h>
+#define FILE_ID OSM_FILE_PKEY_MGR_C
+#include <opensm/osm_node.h>
+#include <opensm/osm_switch.h>
+#include <opensm/osm_partition.h>
+#include <opensm/osm_opensm.h>
+
+static void clear_accum_pkey_index(osm_pkey_tbl_t * p_pkey_tbl,
+ uint16_t pkey_index);
+
+/*
+ The max number of pkeys/pkey blocks for a physical port is located
+ in a different place for switch external ports (SwitchInfo) and the
+ rest of the ports (NodeInfo).
+*/
+static uint16_t
+pkey_mgr_get_physp_max_pkeys(IN const osm_physp_t * p_physp)
+{
+ osm_node_t *p_node = osm_physp_get_node_ptr(p_physp);
+ uint16_t num_pkeys = 0;
+
+ if (!p_node->sw || (osm_physp_get_port_num(p_physp) == 0))
+ num_pkeys = cl_ntoh16(p_node->node_info.partition_cap);
+ else
+ num_pkeys = cl_ntoh16(p_node->sw->switch_info.enforce_cap);
+ return num_pkeys;
+}
+
+static uint16_t
+pkey_mgr_get_physp_max_blocks(IN const osm_physp_t * p_physp)
+{
+ return ((pkey_mgr_get_physp_max_pkeys(p_physp) + 31) / 32);
+}
+
+/*
+ * Insert new pending pkey entry to the specific port pkey table
+ * pending pkeys. New entries are inserted at the back.
+ */
+static void
+pkey_mgr_process_physical_port(IN osm_log_t * p_log,
+ IN osm_sm_t * sm,
+ IN const ib_net16_t pkey,
+ IN osm_physp_t * p_physp)
+{
+ osm_node_t *p_node = osm_physp_get_node_ptr(p_physp);
+ osm_pkey_tbl_t *p_pkey_tbl;
+ ib_net16_t *p_orig_pkey;
+ osm_pending_pkey_t *p_pending;
+
+ p_pkey_tbl = &p_physp->pkeys;
+ p_pending = (osm_pending_pkey_t *) calloc(1, sizeof(osm_pending_pkey_t));
+ if (!p_pending) {
+ OSM_LOG(p_log, OSM_LOG_ERROR, "ERR 0502: "
+ "Failed to allocate new pending pkey entry for node "
+ "0x%016" PRIx64 " port %u\n",
+ cl_ntoh64(osm_node_get_node_guid(p_node)),
+ osm_physp_get_port_num(p_physp));
+ return;
+ }
+ p_pending->pkey = pkey;
+ if (sm->p_subn->opt.allow_both_pkeys)
+ p_orig_pkey = cl_map_get(&p_pkey_tbl->keys, pkey);
+ else
+ p_orig_pkey = cl_map_get(&p_pkey_tbl->keys,
+ ib_pkey_get_base(pkey));
+
+ if (!p_orig_pkey) {
+ p_pending->is_new = TRUE;
+ } else {
+ CL_ASSERT(ib_pkey_get_base(*p_orig_pkey) ==
+ ib_pkey_get_base(pkey));
+ p_pending->is_new = FALSE;
+ if (osm_pkey_tbl_get_block_and_idx(p_pkey_tbl, p_orig_pkey,
+ &p_pending->block,
+ &p_pending->index) !=
+ IB_SUCCESS) {
+ OSM_LOG(p_log, OSM_LOG_ERROR, "ERR 0503: "
+ "Failed to obtain P_Key 0x%04x block and index "
+ "for node 0x%016" PRIx64 " port %u\n",
+ cl_ntoh16(ib_pkey_get_base(pkey)),
+ cl_ntoh64(osm_node_get_node_guid(p_node)),
+ osm_physp_get_port_num(p_physp));
+ free(p_pending);
+ return;
+ }
+ if (p_physp->pkeys.indx0_pkey) {
+ /*
+ * Remove the pkey that should be at index 0 from
+ * accum pkey if current position is not index 0
+ */
+ if (((sm->p_subn->opt.allow_both_pkeys &&
+ pkey == p_physp->pkeys.indx0_pkey) ||
+ (!sm->p_subn->opt.allow_both_pkeys &&
+ ib_pkey_get_base(pkey) == ib_pkey_get_base(p_physp->pkeys.indx0_pkey))) &&
+ (p_pending->block != 0 || p_pending->index != 0)) {
+ p_pending->is_new = TRUE;
+ clear_accum_pkey_index(p_pkey_tbl,
+ p_pending->block *
+ IB_NUM_PKEY_ELEMENTS_IN_BLOCK +
+ p_pending->index);
+ }
+
+ if (p_pending->block == 0 && p_pending->index == 0) {
+ /* Move the pkey away from index 0 */
+ if ((sm->p_subn->opt.allow_both_pkeys &&
+ pkey != p_physp->pkeys.indx0_pkey) ||
+ (!sm->p_subn->opt.allow_both_pkeys &&
+ ib_pkey_get_base(pkey) != ib_pkey_get_base(p_physp->pkeys.indx0_pkey))) {
+ p_pending->is_new = TRUE;
+ clear_accum_pkey_index(p_pkey_tbl, 0);
+ }
+ }
+ } else {
+ /* If index 0 is occupied by non-default, it should reoccupied by pkey 0x7FFF */
+ if (p_pending->block == 0 && p_pending->index == 0) {
+ if (ib_pkey_get_base(pkey) != IB_DEFAULT_PARTIAL_PKEY) {
+ p_pending->is_new = TRUE;
+ clear_accum_pkey_index(p_pkey_tbl, 0);
+ }
+ /* Need to move default pkey to index 0 */
+ } else if ((sm->p_subn->opt.allow_both_pkeys &&
+ pkey == IB_DEFAULT_PKEY) ||
+ (!sm->p_subn->opt.allow_both_pkeys &&
+ ib_pkey_get_base(pkey) == IB_DEFAULT_PARTIAL_PKEY)) {
+ p_pending->is_new = TRUE;
+ clear_accum_pkey_index(p_pkey_tbl,
+ p_pending->block *
+ IB_NUM_PKEY_ELEMENTS_IN_BLOCK +
+ p_pending->index);
+ }
+ }
+
+ }
+ if (p_pending->is_new == TRUE)
+ cl_qlist_insert_tail(&p_pkey_tbl->pending,
+ (cl_list_item_t *) p_pending);
+ else
+ cl_qlist_insert_head(&p_pkey_tbl->pending,
+ (cl_list_item_t *) p_pending);
+
+ OSM_LOG(p_log, OSM_LOG_DEBUG,
+ "pkey 0x%04x was %s for node 0x%016" PRIx64 " port %u\n",
+ cl_ntoh16(pkey), p_pending->is_new ? "inserted" : "updated",
+ cl_ntoh64(osm_node_get_node_guid(p_node)),
+ osm_physp_get_port_num(p_physp));
+}
+
+static void
+pkey_mgr_process_partition_table(osm_log_t * p_log, osm_sm_t * sm,
+ const osm_prtn_t * p_prtn,
+ const boolean_t full)
+{
+ const cl_map_t *p_tbl =
+ full ? &p_prtn->full_guid_tbl : &p_prtn->part_guid_tbl;
+ cl_map_iterator_t i, i_next;
+ ib_net16_t pkey = p_prtn->pkey;
+ osm_physp_t *p_physp;
+
+ if (full)
+ pkey |= cl_hton16(0x8000);
+
+ i_next = cl_map_head(p_tbl);
+ while (i_next != cl_map_end(p_tbl)) {
+ i = i_next;
+ i_next = cl_map_next(i);
+ p_physp = cl_map_obj(i);
+ if (p_physp)
+ pkey_mgr_process_physical_port(p_log, sm, pkey,
+ p_physp);
+ }
+}
+
+static ib_api_status_t
+pkey_mgr_update_pkey_entry(IN osm_sm_t * sm,
+ IN const osm_physp_t * p_physp,
+ IN const ib_pkey_table_t * block,
+ IN const uint16_t block_index)
+{
+ osm_madw_context_t context;
+ osm_node_t *p_node = osm_physp_get_node_ptr(p_physp);
+ osm_physp_t *physp0;
+ uint32_t attr_mod;
+ ib_net64_t m_key;
+
+ context.pkey_context.node_guid = osm_node_get_node_guid(p_node);
+ context.pkey_context.port_guid = osm_physp_get_port_guid(p_physp);
+ context.pkey_context.set_method = TRUE;
+ attr_mod = block_index;
+ if (osm_node_get_type(p_node) == IB_NODE_TYPE_SWITCH &&
+ osm_physp_get_port_num(p_physp) != 0) {
+ attr_mod |= osm_physp_get_port_num(p_physp) << 16;
+ physp0 = osm_node_get_physp_ptr(p_node, 0);
+ m_key = ib_port_info_get_m_key(&physp0->port_info);
+ } else
+ m_key = ib_port_info_get_m_key(&p_physp->port_info);
+ return osm_req_set(sm, osm_physp_get_dr_path_ptr(p_physp),
+ (uint8_t *) block, sizeof(*block),
+ IB_MAD_ATTR_P_KEY_TABLE,
+ cl_hton32(attr_mod), FALSE, m_key,
+ CL_DISP_MSGID_NONE, &context);
+}
+
+static ib_api_status_t
+pkey_mgr_enforce_partition(IN osm_log_t * p_log, osm_sm_t * sm,
+ IN osm_physp_t * p_physp,
+ IN osm_partition_enforce_type_enum enforce_type)
+{
+ osm_madw_context_t context;
+ uint8_t payload[IB_SMP_DATA_SIZE];
+ ib_port_info_t *p_pi;
+ ib_net64_t m_key;
+ osm_physp_t *physp0;
+ ib_api_status_t status;
+ uint8_t enforce_bits;
+
+ p_pi = &p_physp->port_info;
+
+ if (enforce_type == OSM_PARTITION_ENFORCE_TYPE_BOTH)
+ enforce_bits = 0xc;
+ else if (enforce_type == OSM_PARTITION_ENFORCE_TYPE_IN)
+ enforce_bits = 0x8;
+ else
+ enforce_bits = 0x4;
+
+ if ((p_pi->vl_enforce & 0xc) == enforce_bits *
+ (enforce_type != OSM_PARTITION_ENFORCE_TYPE_OFF)) {
+ OSM_LOG(p_log, OSM_LOG_DEBUG,
+ "No need to update PortInfo for "
+ "node 0x%016" PRIx64 " port %u (%s)\n",
+ cl_ntoh64(osm_node_get_node_guid
+ (osm_physp_get_node_ptr(p_physp))),
+ osm_physp_get_port_num(p_physp),
+ p_physp->p_node->print_desc);
+ return IB_SUCCESS;
+ }
+
+ memcpy(payload, p_pi, sizeof(ib_port_info_t));
+
+ p_pi = (ib_port_info_t *) payload;
+ p_pi->vl_enforce &= ~0xc;
+ if (enforce_type != OSM_PARTITION_ENFORCE_TYPE_OFF)
+ p_pi->vl_enforce |= enforce_bits;
+
+ p_pi->state_info2 = 0;
+ ib_port_info_set_port_state(p_pi, IB_LINK_NO_CHANGE);
+
+ physp0 = osm_node_get_physp_ptr(p_physp->p_node, 0);
+ m_key = ib_port_info_get_m_key(&physp0->port_info);
+
+ context.pi_context.node_guid =
+ osm_node_get_node_guid(osm_physp_get_node_ptr(p_physp));
+ context.pi_context.port_guid = osm_physp_get_port_guid(p_physp);
+ context.pi_context.set_method = TRUE;
+ context.pi_context.light_sweep = FALSE;
+ context.pi_context.active_transition = FALSE;
+ context.pi_context.client_rereg = FALSE;
+
+ status = osm_req_set(sm, osm_physp_get_dr_path_ptr(p_physp),
+ payload, sizeof(payload),
+ IB_MAD_ATTR_PORT_INFO,
+ cl_hton32(osm_physp_get_port_num(p_physp)),
+ FALSE, m_key,
+ CL_DISP_MSGID_NONE, &context);
+ if (status != IB_SUCCESS)
+ OSM_LOG(p_log, OSM_LOG_ERROR, "ERR 0511: "
+ "Failed to set PortInfo for "
+ "node 0x%016" PRIx64 " port %u (%s)\n",
+ cl_ntoh64(osm_node_get_node_guid
+ (osm_physp_get_node_ptr(p_physp))),
+ osm_physp_get_port_num(p_physp),
+ p_physp->p_node->print_desc);
+ else
+ OSM_LOG(p_log, OSM_LOG_DEBUG,
+ "Set PortInfo for node 0x%016" PRIx64 " port %u (%s)\n",
+ cl_ntoh64(osm_node_get_node_guid
+ (osm_physp_get_node_ptr(p_physp))),
+ osm_physp_get_port_num(p_physp),
+ p_physp->p_node->print_desc);
+ return status;
+}
+
+static void clear_accum_pkey_index(osm_pkey_tbl_t * p_pkey_tbl,
+ uint16_t pkey_index)
+{
+ uint16_t pkey_idx_bias, pkey_idx;
+ void *ptr;
+ uintptr_t pkey_idx_ptr;
+ cl_map_iterator_t map_iter, map_iter_temp;
+
+ map_iter = cl_map_head(&p_pkey_tbl->accum_pkeys);
+
+ pkey_idx_bias = pkey_index + 1; // adjust for pkey index bias in accum_pkeys
+
+ while (map_iter != cl_map_end(&p_pkey_tbl->accum_pkeys)) {
+ map_iter_temp = cl_map_next(map_iter);
+ ptr = (uint16_t *) cl_map_obj(map_iter);
+ CL_ASSERT(ptr);
+ pkey_idx_ptr = (uintptr_t) ptr;
+ pkey_idx = pkey_idx_ptr;
+ if (pkey_idx == pkey_idx_bias) {
+ cl_map_remove_item(&p_pkey_tbl->accum_pkeys, map_iter);
+ if (p_pkey_tbl->last_pkey_idx == pkey_idx)
+ osm_pkey_find_last_accum_pkey_index(p_pkey_tbl);
+ break;
+ }
+ map_iter = map_iter_temp;
+ }
+}
+
+static int last_accum_pkey_index(osm_pkey_tbl_t * p_pkey_tbl,
+ uint16_t * p_block_idx,
+ uint8_t * p_pkey_idx)
+{
+ if (p_pkey_tbl->last_pkey_idx) {
+ *p_block_idx = (p_pkey_tbl->last_pkey_idx - 1) / IB_NUM_PKEY_ELEMENTS_IN_BLOCK;
+ *p_pkey_idx = (p_pkey_tbl->last_pkey_idx - 1) % IB_NUM_PKEY_ELEMENTS_IN_BLOCK;
+ return 1;
+ }
+
+ return 0;
+}
+
+static int pkey_mgr_update_port(osm_log_t * p_log, osm_sm_t * sm,
+ const osm_port_t * const p_port)
+{
+ osm_physp_t *p_physp;
+ osm_node_t *p_node;
+ ib_pkey_table_t *block, *new_block;
+ osm_pkey_tbl_t *p_pkey_tbl;
+ uint16_t block_index;
+ uint8_t pkey_index;
+ uint16_t last_free_block_index = 0;
+ uint8_t last_free_pkey_index = 0;
+ uint16_t num_of_blocks;
+ uint16_t max_num_of_blocks;
+ ib_api_status_t status;
+ osm_pending_pkey_t *p_pending;
+ boolean_t found;
+ ib_pkey_table_t empty_block;
+ int ret = 0, full = 0;
+ void *ptr;
+ uintptr_t pkey_idx_ptr;
+ uint16_t pkey_idx;
+
+ p_physp = p_port->p_physp;
+ if (!p_physp)
+ return FALSE;
+
+ memset(&empty_block, 0, sizeof(ib_pkey_table_t));
+
+ p_node = osm_physp_get_node_ptr(p_physp);
+ p_pkey_tbl = &p_physp->pkeys;
+ num_of_blocks = osm_pkey_tbl_get_num_blocks(p_pkey_tbl);
+ max_num_of_blocks = pkey_mgr_get_physp_max_blocks(p_physp);
+ if (p_pkey_tbl->max_blocks > max_num_of_blocks) {
+ OSM_LOG(p_log, OSM_LOG_INFO,
+ "Max number of blocks reduced from %u to %u "
+ "for node 0x%016" PRIx64 " port %u (%s)\n",
+ p_pkey_tbl->max_blocks, max_num_of_blocks,
+ cl_ntoh64(osm_node_get_node_guid(p_node)),
+ osm_physp_get_port_num(p_physp),
+ p_physp->p_node->print_desc);
+ }
+ p_pkey_tbl->max_blocks = max_num_of_blocks;
+
+ osm_pkey_tbl_init_new_blocks(p_pkey_tbl);
+ p_pkey_tbl->used_blocks = 0;
+
+ /*
+ process every pending pkey in order -
+ first must be "updated" last are "new"
+ */
+ p_pending =
+ (osm_pending_pkey_t *) cl_qlist_remove_head(&p_pkey_tbl->pending);
+ while (p_pending !=
+ (osm_pending_pkey_t *) cl_qlist_end(&p_pkey_tbl->pending)) {
+
+ found = FALSE;
+ ptr = NULL;
+
+ if (p_pending->is_new == FALSE) {
+ block_index = p_pending->block;
+ pkey_index = p_pending->index;
+ found = TRUE;
+ } else {
+ ptr = cl_map_get(&p_pkey_tbl->accum_pkeys,p_pending->pkey);
+ if (ptr != NULL) {
+ pkey_idx_ptr = (uintptr_t) ptr;
+ pkey_idx = pkey_idx_ptr;
+ pkey_idx--; /* adjust pkey index for bias */
+ block_index = pkey_idx / IB_NUM_PKEY_ELEMENTS_IN_BLOCK;
+ pkey_index = pkey_idx % IB_NUM_PKEY_ELEMENTS_IN_BLOCK;
+
+ if (((sm->p_subn->opt.allow_both_pkeys &&
+ p_pending->pkey == p_physp->pkeys.indx0_pkey) ||
+ (!sm->p_subn->opt.allow_both_pkeys &&
+ ib_pkey_get_base(p_pending->pkey) == ib_pkey_get_base(p_physp->pkeys.indx0_pkey))) ||
+ ((p_pending->pkey != p_physp->pkeys.indx0_pkey &&
+ pkey_idx == 0))) {
+ clear_accum_pkey_index(p_pkey_tbl, pkey_idx);
+ cl_qlist_insert_tail(&p_pkey_tbl->pending,
+ (cl_list_item_t *)p_pending);
+ p_pending =
+ (osm_pending_pkey_t *) cl_qlist_remove_head(&p_pkey_tbl->pending);
+ continue;
+ } else
+ found = TRUE;
+ }
+
+ if (!found) {
+ if (!p_pkey_tbl->indx0_pkey &&
+ ((sm->p_subn->opt.allow_both_pkeys &&
+ p_pending->pkey == IB_DEFAULT_PKEY) ||
+ (!sm->p_subn->opt.allow_both_pkeys &&
+ ib_pkey_get_base(p_pending->pkey) == IB_DEFAULT_PARTIAL_PKEY))) {
+ block_index = 0;
+ pkey_index = 0;
+ } else if ((sm->p_subn->opt.allow_both_pkeys &&
+ p_pending->pkey == p_pkey_tbl->indx0_pkey) ||
+ (!sm->p_subn->opt.allow_both_pkeys &&
+ ib_pkey_get_base(p_pending->pkey) ==
+ ib_pkey_get_base(p_pkey_tbl->indx0_pkey))) {
+ block_index = 0;
+ pkey_index = 0;
+ } else if (last_accum_pkey_index(p_pkey_tbl,
+ &last_free_block_index,
+ &last_free_pkey_index)) {
+ block_index = last_free_block_index;
+ pkey_index = last_free_pkey_index + 1;
+ if (pkey_index >= IB_NUM_PKEY_ELEMENTS_IN_BLOCK) {
+ block_index++;
+ pkey_index -= IB_NUM_PKEY_ELEMENTS_IN_BLOCK;
+ }
+ } else {
+ block_index = 0;
+ pkey_index = 1;
+ }
+
+ if (block_index * IB_NUM_PKEY_ELEMENTS_IN_BLOCK + pkey_index >= pkey_mgr_get_physp_max_pkeys(p_physp)) {
+ if ((sm->p_subn->opt.allow_both_pkeys &&
+ p_pending->pkey != IB_DEFAULT_PKEY) ||
+ (!sm->p_subn->opt.allow_both_pkeys &&
+ ib_pkey_get_base(p_pending->pkey) != IB_DEFAULT_PARTIAL_PKEY)) {
+ last_free_block_index = 0;
+ last_free_pkey_index = 1;
+ found = osm_pkey_find_next_free_entry(p_pkey_tbl, &last_free_block_index, &last_free_pkey_index);
+ } else
+ found = FALSE;
+ if (!found)
+ full = 1;
+ else {
+ block_index = last_free_block_index;
+ pkey_index = last_free_pkey_index;
+ if (block_index * IB_NUM_PKEY_ELEMENTS_IN_BLOCK + pkey_index >= pkey_mgr_get_physp_max_pkeys(p_physp)) {
+ full = 1;
+ found = FALSE;
+ } else {
+ OSM_LOG(p_log, OSM_LOG_INFO,
+ "Reusing PKeyTable block index %u pkey index %u "
+ "for pkey 0x%x on 0x%016" PRIx64 " port %u (%s)\n",
+ block_index,
+ pkey_index,
+ cl_ntoh16(p_pending->pkey),
+ cl_ntoh64(osm_node_get_node_guid(p_node)),
+ osm_physp_get_port_num(p_physp),
+ p_physp->p_node->print_desc);
+
+ clear_accum_pkey_index(p_pkey_tbl, block_index * IB_NUM_PKEY_ELEMENTS_IN_BLOCK + pkey_index);
+ }
+ }
+ if (full)
+ OSM_LOG(p_log, OSM_LOG_ERROR,
+ "ERR 0512: "
+ "Failed to set PKey 0x%04x because Pkey table is full "
+ "for node 0x%016" PRIx64 " port %u (%s)\n",
+ cl_ntoh16(p_pending->pkey),
+ cl_ntoh64(osm_node_get_node_guid(p_node)),
+ osm_physp_get_port_num(p_physp),
+ p_physp->p_node->print_desc);
+ } else
+ found = TRUE;
+ }
+ }
+
+ if (found) {
+ if (IB_SUCCESS !=
+ osm_pkey_tbl_set_new_entry(p_pkey_tbl, block_index,
+ pkey_index,
+ p_pending->pkey)) {
+ OSM_LOG(p_log, OSM_LOG_ERROR, "ERR 0505: "
+ "Failed to set PKey 0x%04x in block %u idx %u "
+ "for node 0x%016" PRIx64 " port %u (%s)\n",
+ cl_ntoh16(p_pending->pkey), block_index,
+ pkey_index,
+ cl_ntoh64(osm_node_get_node_guid
+ (p_node)),
+ osm_physp_get_port_num(p_physp),
+ p_physp->p_node->print_desc);
+ }
+ if (ptr == NULL &&
+ CL_SUCCESS !=
+ osm_pkey_tbl_set_accum_pkeys(p_pkey_tbl,
+ p_pending->pkey,
+ block_index * IB_NUM_PKEY_ELEMENTS_IN_BLOCK + pkey_index)) {
+ OSM_LOG(p_log, OSM_LOG_ERROR, "ERR 0508: "
+ "Failed to set accum_pkeys PKey 0x%04x "
+ "in block %u idx %u for node 0x%016"
+ PRIx64 " port %u (%s)\n",
+ cl_ntoh16(p_pending->pkey), block_index,
+ pkey_index,
+ cl_ntoh64(osm_node_get_node_guid(p_node)),
+ osm_physp_get_port_num(p_physp),
+ p_physp->p_node->print_desc);
+ }
+ }
+ free(p_pending);
+ p_pending =
+ (osm_pending_pkey_t *) cl_qlist_remove_head(&p_pkey_tbl->
+ pending);
+ }
+
+ p_pkey_tbl->indx0_pkey = 0;
+ /* now look for changes and store */
+ for (block_index = 0; block_index < num_of_blocks; block_index++) {
+ block = osm_pkey_tbl_block_get(p_pkey_tbl, block_index);
+ new_block = osm_pkey_tbl_new_block_get(p_pkey_tbl, block_index);
+ if (!new_block)
+ new_block = &empty_block;
+ if (block && !memcmp(new_block, block, sizeof(*block)))
+ continue;
+
+ status =
+ pkey_mgr_update_pkey_entry(sm, p_physp, new_block,
+ block_index);
+ if (status == IB_SUCCESS)
+ OSM_LOG(p_log, OSM_LOG_DEBUG,
+ "Updated pkey table block %u for node 0x%016"
+ PRIx64 " port %u (%s)\n", block_index,
+ cl_ntoh64(osm_node_get_node_guid(p_node)),
+ osm_physp_get_port_num(p_physp),
+ p_physp->p_node->print_desc);
+ else {
+ OSM_LOG(p_log, OSM_LOG_ERROR, "ERR 0506: "
+ "pkey_mgr_update_pkey_entry() failed to update "
+ "pkey table block %u for node 0x%016" PRIx64
+ " port %u (%s)\n", block_index,
+ cl_ntoh64(osm_node_get_node_guid(p_node)),
+ osm_physp_get_port_num(p_physp),
+ p_physp->p_node->print_desc);
+ ret = -1;
+ }
+ }
+
+ return ret;
+}
+
+static int last_used_pkey_index(const osm_port_t * const p_port,
+ const osm_pkey_tbl_t * p_pkey_tbl,
+ uint16_t * p_last_index)
+{
+ ib_pkey_table_t *last_block;
+ uint16_t index, last_index = 0;
+
+ CL_ASSERT(p_last_index);
+
+ last_block = osm_pkey_tbl_new_block_get(p_pkey_tbl,
+ p_pkey_tbl->used_blocks - 1);
+ if (!last_block)
+ return 1;
+
+ if (p_pkey_tbl->used_blocks == p_pkey_tbl->max_blocks)
+ last_index = cl_ntoh16(p_port->p_node->node_info.partition_cap) % IB_NUM_PKEY_ELEMENTS_IN_BLOCK;
+ if (last_index == 0)
+ last_index = IB_NUM_PKEY_ELEMENTS_IN_BLOCK;
+ index = last_index;
+ do {
+ index--;
+ if (!ib_pkey_is_invalid(last_block->pkey_entry[index]))
+ break;
+ } while (index != 0);
+
+ *p_last_index = index;
+ return 0;
+}
+
+static int update_peer_block(osm_log_t * p_log, osm_sm_t * sm,
+ osm_physp_t * peer,
+ osm_pkey_tbl_t * p_peer_pkey_tbl,
+ ib_pkey_table_t * new_peer_block,
+ uint16_t peer_block_idx, osm_node_t * p_node)
+{
+ int ret = 0;
+ ib_pkey_table_t *peer_block;
+
+ peer_block = osm_pkey_tbl_block_get(p_peer_pkey_tbl, peer_block_idx);
+ if (!peer_block ||
+ memcmp(peer_block, new_peer_block, sizeof(*peer_block))) {
+ if (pkey_mgr_update_pkey_entry(sm, peer, new_peer_block,
+ peer_block_idx) != IB_SUCCESS) {
+ OSM_LOG(p_log, OSM_LOG_ERROR, "ERR 0509: "
+ "pkey_mgr_update_pkey_entry() failed to update "
+ "pkey table block %u for node 0x%016"
+ PRIx64 " port %u (%s)\n",
+ peer_block_idx,
+ cl_ntoh64(osm_node_get_node_guid(p_node)),
+ osm_physp_get_port_num(peer),
+ p_node->print_desc);
+ ret = -1;
+ }
+ }
+
+ return ret;
+}
+
+static int new_pkey_exists(osm_pkey_tbl_t * p_pkey_tbl, ib_net16_t pkey)
+{
+ uint16_t num_blocks;
+ uint16_t block_index;
+ ib_pkey_table_t *block;
+ uint16_t pkey_idx;
+
+ num_blocks = (uint16_t) cl_ptr_vector_get_size(&p_pkey_tbl->new_blocks);
+ for (block_index = 0; block_index < num_blocks; block_index++) {
+ block = osm_pkey_tbl_new_block_get(p_pkey_tbl, block_index);
+ if (!block)
+ continue;
+
+ for (pkey_idx = 0; pkey_idx < IB_NUM_PKEY_ELEMENTS_IN_BLOCK;
+ pkey_idx++) {
+ if (block->pkey_entry[pkey_idx] == pkey)
+ return 1;
+ }
+ }
+ return 0;
+}
+
+static int pkey_mgr_update_peer_port(osm_log_t * p_log, osm_sm_t * sm,
+ const osm_subn_t * p_subn,
+ const osm_port_t * const p_port,
+ osm_partition_enforce_type_enum enforce_type)
+{
+ osm_physp_t *p_physp, *peer;
+ osm_node_t *p_node;
+ ib_pkey_table_t *block;
+ const osm_pkey_tbl_t *p_pkey_tbl;
+ osm_pkey_tbl_t *p_peer_pkey_tbl;
+ uint16_t block_index, peer_block_idx;
+ uint16_t peer_max_blocks;
+ uint16_t last_index;
+ ib_pkey_table_t new_peer_block;
+ uint16_t pkey_idx, peer_pkey_idx;
+ ib_net16_t pkey, full_pkey;
+ int ret = 0, loop_exit = 0;
+
+ p_physp = p_port->p_physp;
+ if (!p_physp)
+ return -1;
+ peer = osm_physp_get_remote(p_physp);
+ if (!peer)
+ return -1;
+ p_node = osm_physp_get_node_ptr(peer);
+ if (!p_node->sw || !p_node->sw->switch_info.enforce_cap)
+ return 0;
+
+ if (enforce_type == OSM_PARTITION_ENFORCE_TYPE_OFF) {
+ pkey_mgr_enforce_partition(p_log, sm, peer, OSM_PARTITION_ENFORCE_TYPE_OFF);
+ return ret;
+ }
+
+ p_pkey_tbl = osm_physp_get_pkey_tbl(p_physp);
+ peer_max_blocks = pkey_mgr_get_physp_max_blocks(peer);
+ p_peer_pkey_tbl = &peer->pkeys;
+ peer_block_idx = 0;
+ peer_pkey_idx = 0;
+ for (block_index = 0; block_index < p_pkey_tbl->used_blocks;
+ block_index++) {
+ if (loop_exit)
+ break;
+ block = osm_pkey_tbl_new_block_get(p_pkey_tbl, block_index);
+ if (!block)
+ continue;
+ for (pkey_idx = 0; pkey_idx < IB_NUM_PKEY_ELEMENTS_IN_BLOCK;
+ pkey_idx++) {
+ pkey = block->pkey_entry[pkey_idx];
+ if (ib_pkey_is_invalid(pkey))
+ continue;
+ if (!ib_pkey_is_full_member(pkey)) {
+ full_pkey = pkey | IB_PKEY_TYPE_MASK;
+ if (new_pkey_exists(&p_physp->pkeys, full_pkey))
+ continue;
+ }
+ new_peer_block.pkey_entry[peer_pkey_idx] = pkey;
+ if (peer_block_idx >= peer_max_blocks) {
+ loop_exit = 1;
+ break;
+ }
+ if (++peer_pkey_idx == IB_NUM_PKEY_ELEMENTS_IN_BLOCK) {
+ if (update_peer_block(p_log, sm, peer,
+ p_peer_pkey_tbl,
+ &new_peer_block,
+ peer_block_idx, p_node))
+ ret = -1;
+ peer_pkey_idx = 0;
+ peer_block_idx++;
+ }
+ }
+ }
+
+ if (peer_block_idx < peer_max_blocks) {
+ if (peer_pkey_idx) {
+ /* Handle partial last block */
+ for (; peer_pkey_idx < IB_NUM_PKEY_ELEMENTS_IN_BLOCK;
+ peer_pkey_idx++)
+ new_peer_block.pkey_entry[peer_pkey_idx] = 0;
+ if (update_peer_block(p_log, sm, peer, p_peer_pkey_tbl,
+ &new_peer_block, peer_block_idx,
+ p_node))
+ ret = -1;
+ } else
+ peer_block_idx--;
+
+ p_peer_pkey_tbl->used_blocks = peer_block_idx + 1;
+ if (p_peer_pkey_tbl->used_blocks == peer_max_blocks) {
+ /* Is last used pkey index beyond switch peer port capacity ? */
+ if (!last_used_pkey_index(p_port, p_peer_pkey_tbl,
+ &last_index)) {
+ last_index += peer_block_idx * IB_NUM_PKEY_ELEMENTS_IN_BLOCK;
+ if (cl_ntoh16(p_node->sw->switch_info.enforce_cap) <= last_index) {
+ OSM_LOG(p_log, OSM_LOG_ERROR, "ERR 0507: "
+ "Not enough pkey entries (%u <= %u) on switch 0x%016"
+ PRIx64 " port %u (%s). Clearing Enforcement bit\n",
+ cl_ntoh16(p_node->sw->switch_info.enforce_cap),
+ last_index,
+ cl_ntoh64(osm_node_get_node_guid(p_node)),
+ osm_physp_get_port_num(peer),
+ p_node->print_desc);
+ enforce_type = OSM_PARTITION_ENFORCE_TYPE_OFF;
+ ret = -1;
+ }
+ }
+ }
+ } else {
+ p_peer_pkey_tbl->used_blocks = peer_max_blocks;
+ enforce_type = OSM_PARTITION_ENFORCE_TYPE_OFF;
+ }
+
+ if (!ret)
+ OSM_LOG(p_log, OSM_LOG_DEBUG,
+ "Pkey table was successfully updated for node 0x%016"
+ PRIx64 " port %u (%s)\n",
+ cl_ntoh64(osm_node_get_node_guid(p_node)),
+ osm_physp_get_port_num(peer), p_node->print_desc);
+
+ if (pkey_mgr_enforce_partition(p_log, sm, peer, enforce_type))
+ ret = -1;
+
+ return ret;
+}
+
+int osm_pkey_mgr_process(IN osm_opensm_t * p_osm)
+{
+ cl_qmap_t *p_tbl;
+ cl_map_item_t *p_next;
+ osm_prtn_t *p_prtn;
+ osm_port_t *p_port;
+ osm_switch_t *p_sw;
+ osm_physp_t *p_physp;
+ osm_node_t *p_remote_node;
+ uint8_t i;
+ int ret = 0;
+
+ CL_ASSERT(p_osm);
+
+ OSM_LOG_ENTER(&p_osm->log);
+
+ CL_PLOCK_EXCL_ACQUIRE(&p_osm->lock);
+
+ if (osm_prtn_make_partitions(&p_osm->log, &p_osm->subn) != IB_SUCCESS) {
+ OSM_LOG(&p_osm->log, OSM_LOG_ERROR, "ERR 0510: "
+ "osm_prtn_make_partitions() failed\n");
+ ret = -1;
+ goto _err;
+ }
+
+ /* populate the pending pkey entries by scanning all partitions */
+ p_tbl = &p_osm->subn.prtn_pkey_tbl;
+ p_next = cl_qmap_head(p_tbl);
+ while (p_next != cl_qmap_end(p_tbl)) {
+ p_prtn = (osm_prtn_t *) p_next;
+ p_next = cl_qmap_next(p_next);
+ pkey_mgr_process_partition_table(&p_osm->log, &p_osm->sm,
+ p_prtn, FALSE);
+ pkey_mgr_process_partition_table(&p_osm->log, &p_osm->sm,
+ p_prtn, TRUE);
+ }
+
+ /* calculate and set new pkey tables */
+ p_tbl = &p_osm->subn.port_guid_tbl;
+ p_next = cl_qmap_head(p_tbl);
+ while (p_next != cl_qmap_end(p_tbl)) {
+ p_port = (osm_port_t *) p_next;
+ p_next = cl_qmap_next(p_next);
+ if (pkey_mgr_update_port(&p_osm->log, &p_osm->sm, p_port))
+ ret = -1;
+ if ((osm_node_get_type(p_port->p_node) != IB_NODE_TYPE_SWITCH)
+ && pkey_mgr_update_peer_port(&p_osm->log, &p_osm->sm,
+ &p_osm->subn, p_port,
+ p_osm->subn.opt.part_enforce_enum))
+ ret = -1;
+ }
+
+ /* clear partition enforcement on inter-switch links */
+ p_tbl = &p_osm->subn.sw_guid_tbl;
+ p_next = cl_qmap_head(p_tbl);
+ while (p_next != cl_qmap_end(p_tbl)) {
+ p_sw = (osm_switch_t *) p_next;
+ p_next = cl_qmap_next(p_next);
+ for (i = 1; i < p_sw->num_ports; i++) {
+ p_physp = osm_node_get_physp_ptr(p_sw->p_node, i);
+ if (p_physp && p_physp->p_remote_physp)
+ p_remote_node = p_physp->p_remote_physp->p_node;
+ else
+ continue;
+
+ if (osm_node_get_type(p_remote_node) != IB_NODE_TYPE_SWITCH)
+ continue;
+
+ if(! (p_physp->port_info.vl_enforce & 0xc ))
+ continue;
+
+ /* clear partition enforcement */
+ if (pkey_mgr_enforce_partition(&p_osm->log, &p_osm->sm, p_physp, OSM_PARTITION_ENFORCE_TYPE_OFF))
+ ret = -1;
+ }
+ }
+_err:
+ CL_PLOCK_RELEASE(&p_osm->lock);
+ OSM_LOG_EXIT(&p_osm->log);
+ return ret;
+}
diff --git a/contrib/ofed/opensm/opensm/osm_pkey_rcv.c b/contrib/ofed/opensm/opensm/osm_pkey_rcv.c
new file mode 100644
index 0000000..b64ed7b
--- /dev/null
+++ b/contrib/ofed/opensm/opensm/osm_pkey_rcv.c
@@ -0,0 +1,152 @@
+/*
+ * Copyright (c) 2004-2009 Voltaire, Inc. All rights reserved.
+ * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved.
+ * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+#if HAVE_CONFIG_H
+# include <config.h>
+#endif /* HAVE_CONFIG_H */
+
+#include <string.h>
+#include <iba/ib_types.h>
+#include <complib/cl_passivelock.h>
+#include <complib/cl_debug.h>
+#include <opensm/osm_file_ids.h>
+#define FILE_ID OSM_FILE_PKEY_RCV_C
+#include <opensm/osm_madw.h>
+#include <opensm/osm_log.h>
+#include <opensm/osm_node.h>
+#include <opensm/osm_subnet.h>
+#include <opensm/osm_helper.h>
+#include <opensm/osm_sm.h>
+
+/*
+ * WE ONLY RECEIVE GET or SET responses
+ */
+void osm_pkey_rcv_process(IN void *context, IN void *data)
+{
+ osm_sm_t *sm = context;
+ osm_madw_t *p_madw = data;
+ ib_pkey_table_t *p_pkey_tbl;
+ ib_smp_t *p_smp;
+ osm_port_t *p_port;
+ osm_physp_t *p_physp;
+ osm_node_t *p_node;
+ osm_pkey_context_t *p_context;
+ ib_net64_t port_guid;
+ ib_net64_t node_guid;
+ uint8_t port_num;
+ uint16_t block_num;
+
+ CL_ASSERT(sm);
+
+ OSM_LOG_ENTER(sm->p_log);
+
+ CL_ASSERT(p_madw);
+
+ p_smp = osm_madw_get_smp_ptr(p_madw);
+
+ p_context = osm_madw_get_pkey_context_ptr(p_madw);
+ p_pkey_tbl = ib_smp_get_payload_ptr(p_smp);
+
+ port_guid = p_context->port_guid;
+ node_guid = p_context->node_guid;
+
+ CL_ASSERT(p_smp->attr_id == IB_MAD_ATTR_P_KEY_TABLE);
+
+ if (ib_smp_get_status(p_smp)) {
+ OSM_LOG(sm->p_log, OSM_LOG_DEBUG,
+ "MAD status 0x%x received\n",
+ cl_ntoh16(ib_smp_get_status(p_smp)));
+ goto Exit2;
+ }
+
+ cl_plock_excl_acquire(sm->p_lock);
+ p_port = osm_get_port_by_guid(sm->p_subn, port_guid);
+ if (!p_port) {
+ OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR 4806: "
+ "No port object for port with GUID 0x%" PRIx64
+ "\n\t\t\t\tfor parent node GUID 0x%" PRIx64
+ ", TID 0x%" PRIx64 "\n", cl_ntoh64(port_guid),
+ cl_ntoh64(node_guid), cl_ntoh64(p_smp->trans_id));
+ goto Exit;
+ }
+
+ p_node = p_port->p_node;
+ CL_ASSERT(p_node);
+
+ block_num = (uint16_t) ((cl_ntoh32(p_smp->attr_mod)) & 0x0000FFFF);
+ /* in case of a non switch node the attr modifier should be ignored */
+ if (osm_node_get_type(p_node) == IB_NODE_TYPE_SWITCH) {
+ port_num =
+ (uint8_t) (((cl_ntoh32(p_smp->attr_mod)) & 0x00FF0000) >>
+ 16);
+ p_physp = osm_node_get_physp_ptr(p_node, port_num);
+ } else {
+ p_physp = p_port->p_physp;
+ port_num = p_physp->port_num;
+ }
+
+ /*
+ We do not care if this is a result of a set or get -
+ all we want is to update the subnet.
+ */
+ OSM_LOG(sm->p_log, OSM_LOG_VERBOSE,
+ "Got GetResp(PKey) block:%u port_num %u with GUID 0x%"
+ PRIx64 " for parent node GUID 0x%" PRIx64 ", TID 0x%"
+ PRIx64 "\n", block_num, port_num, cl_ntoh64(port_guid),
+ cl_ntoh64(node_guid), cl_ntoh64(p_smp->trans_id));
+
+ /*
+ Determine if we encountered a new Physical Port.
+ If so, ignore it.
+ */
+ if (!p_physp) {
+ OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR 4807: "
+ "Got invalid port number %u\n", port_num);
+ goto Exit;
+ }
+
+ osm_dump_pkey_block_v2(sm->p_log, port_guid, block_num, port_num,
+ p_pkey_tbl, FILE_ID, OSM_LOG_DEBUG);
+
+ osm_physp_set_pkey_tbl(sm->p_log, sm->p_subn,
+ p_physp, p_pkey_tbl, block_num,
+ p_context->set_method);
+
+Exit:
+ cl_plock_release(sm->p_lock);
+
+Exit2:
+ OSM_LOG_EXIT(sm->p_log);
+}
diff --git a/contrib/ofed/opensm/opensm/osm_port.c b/contrib/ofed/opensm/opensm/osm_port.c
new file mode 100644
index 0000000..35010e3
--- /dev/null
+++ b/contrib/ofed/opensm/opensm/osm_port.c
@@ -0,0 +1,700 @@
+/*
+ * Copyright (c) 2004-2009 Voltaire, Inc. All rights reserved.
+ * Copyright (c) 2002-2015 Mellanox Technologies LTD. All rights reserved.
+ * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+/*
+ * Abstract:
+ * Implementation of osm_physp_t.
+ * This object represents an Infiniband Port.
+ * This object is part of the opensm family of objects.
+ */
+
+#if HAVE_CONFIG_H
+# include <config.h>
+#endif /* HAVE_CONFIG_H */
+
+#include <stdlib.h>
+#include <string.h>
+#include <complib/cl_debug.h>
+#include <iba/ib_types.h>
+#include <opensm/osm_file_ids.h>
+#define FILE_ID OSM_FILE_PORT_C
+#include <opensm/osm_port.h>
+#include <opensm/osm_node.h>
+#include <opensm/osm_madw.h>
+#include <opensm/osm_switch.h>
+#include <opensm/osm_db_pack.h>
+#include <opensm/osm_sm.h>
+
+void osm_physp_construct(IN osm_physp_t * p_physp)
+{
+ memset(p_physp, 0, sizeof(*p_physp));
+ osm_dr_path_construct(&p_physp->dr_path);
+ cl_ptr_vector_construct(&p_physp->slvl_by_port);
+ osm_pkey_tbl_construct(&p_physp->pkeys);
+}
+
+void osm_physp_destroy(IN osm_physp_t * p_physp)
+{
+ size_t num_slvl, i;
+
+ /* the physp might be uninitialized */
+ if (p_physp->port_guid) {
+ if (p_physp->p_guids)
+ free(p_physp->p_guids);
+
+ /* free the SL2VL Tables */
+ num_slvl = cl_ptr_vector_get_size(&p_physp->slvl_by_port);
+ for (i = 0; i < num_slvl; i++)
+ free(cl_ptr_vector_get(&p_physp->slvl_by_port, i));
+ cl_ptr_vector_destroy(&p_physp->slvl_by_port);
+
+ /* free the P_Key Tables */
+ osm_pkey_tbl_destroy(&p_physp->pkeys);
+
+ memset(p_physp, 0, sizeof(*p_physp));
+ osm_dr_path_construct(&p_physp->dr_path); /* clear dr_path */
+ }
+}
+
+void osm_physp_init(IN osm_physp_t * p_physp, IN ib_net64_t port_guid,
+ IN uint8_t port_num, IN const struct osm_node *p_node,
+ IN osm_bind_handle_t h_bind, IN uint8_t hop_count,
+ IN const uint8_t * p_initial_path)
+{
+ uint16_t num_slvl, i;
+ ib_slvl_table_t *p_slvl;
+
+ CL_ASSERT(p_node);
+
+ osm_physp_construct(p_physp);
+ p_physp->port_guid = port_guid;
+ p_physp->port_num = port_num;
+ p_physp->healthy = TRUE;
+ p_physp->need_update = 2;
+ p_physp->p_node = (struct osm_node *)p_node;
+
+ osm_dr_path_init(&p_physp->dr_path, hop_count, p_initial_path);
+
+ /* allocate enough SL2VL tables */
+ if (osm_node_get_type(p_node) == IB_NODE_TYPE_SWITCH)
+ /* we need node num ports + 1 SL2VL tables */
+ num_slvl = osm_node_get_num_physp(p_node) + 1;
+ else
+ /* An end node - we need only one SL2VL */
+ num_slvl = 1;
+
+ cl_ptr_vector_init(&p_physp->slvl_by_port, num_slvl, 1);
+ for (i = 0; i < num_slvl; i++) {
+ p_slvl = (ib_slvl_table_t *) malloc(sizeof(ib_slvl_table_t));
+ if (!p_slvl)
+ break;
+ memset(p_slvl, 0, sizeof(ib_slvl_table_t));
+ cl_ptr_vector_set(&p_physp->slvl_by_port, i, p_slvl);
+ }
+
+ /* initialize the pkey table */
+ osm_pkey_tbl_init(&p_physp->pkeys);
+}
+
+void osm_port_delete(IN OUT osm_port_t ** pp_port)
+{
+ free(*pp_port);
+ *pp_port = NULL;
+}
+
+osm_port_t *osm_port_new(IN const ib_node_info_t * p_ni,
+ IN osm_node_t * p_parent_node)
+{
+ osm_port_t *p_port;
+ ib_net64_t port_guid;
+ osm_physp_t *p_physp;
+ uint8_t port_num;
+
+ p_port = malloc(sizeof(*p_port));
+ if (!p_port)
+ return NULL;
+
+ memset(p_port, 0, sizeof(*p_port));
+ cl_qlist_init(&p_port->mcm_list);
+ p_port->p_node = (struct osm_node *)p_parent_node;
+ port_guid = p_ni->port_guid;
+ p_port->guid = port_guid;
+ port_num = p_ni->node_type == IB_NODE_TYPE_SWITCH ?
+ 0 : ib_node_info_get_local_port_num(p_ni);
+
+ /*
+ Get the pointers to the physical node objects "owned" by this
+ logical port GUID.
+ For switches, port '0' is owned; for HCA's and routers,
+ only the singular part that has this GUID is owned.
+ */
+ p_physp = osm_node_get_physp_ptr(p_parent_node, port_num);
+ if (!p_physp)
+ return NULL;
+
+ CL_ASSERT(port_guid == osm_physp_get_port_guid(p_physp));
+ p_port->p_physp = p_physp;
+
+ return p_port;
+}
+
+void osm_port_get_lid_range_ho(IN const osm_port_t * p_port,
+ IN uint16_t * p_min_lid, IN uint16_t * p_max_lid)
+{
+ uint8_t lmc;
+
+ *p_min_lid = cl_ntoh16(osm_port_get_base_lid(p_port));
+ lmc = osm_port_get_lmc(p_port);
+ *p_max_lid = (uint16_t) (*p_min_lid + (1 << lmc) - 1);
+}
+
+uint8_t osm_physp_calc_link_mtu(IN osm_log_t * p_log,
+ IN const osm_physp_t * p_physp,
+ IN uint8_t current_mtu)
+{
+ const osm_physp_t *p_remote_physp;
+ uint8_t mtu;
+ uint8_t remote_mtu;
+
+ OSM_LOG_ENTER(p_log);
+
+ p_remote_physp = osm_physp_get_remote(p_physp);
+ if (p_remote_physp) {
+ /* use the available MTU */
+ mtu = ib_port_info_get_mtu_cap(&p_physp->port_info);
+
+ remote_mtu =
+ ib_port_info_get_mtu_cap(&p_remote_physp->port_info);
+
+ OSM_LOG(p_log, OSM_LOG_DEBUG,
+ "Remote port 0x%016" PRIx64 " port = %u : "
+ "MTU = %u. This Port MTU: %u\n",
+ cl_ntoh64(osm_physp_get_port_guid(p_remote_physp)),
+ osm_physp_get_port_num(p_remote_physp),
+ remote_mtu, mtu);
+
+ if (mtu != remote_mtu) {
+ if (mtu > remote_mtu)
+ mtu = remote_mtu;
+ if (mtu != current_mtu)
+ OSM_LOG(p_log, OSM_LOG_VERBOSE,
+ "MTU mismatch between ports."
+ "\n\t\t\t\tPort 0x%016" PRIx64 ", port %u"
+ " and port 0x%016" PRIx64 ", port %u."
+ "\n\t\t\t\tUsing lower MTU of %u\n",
+ cl_ntoh64(osm_physp_get_port_guid(p_physp)),
+ osm_physp_get_port_num(p_physp),
+ cl_ntoh64(osm_physp_get_port_guid
+ (p_remote_physp)),
+ osm_physp_get_port_num(p_remote_physp), mtu);
+ }
+ } else
+ mtu = ib_port_info_get_neighbor_mtu(&p_physp->port_info);
+
+ if (mtu == 0) {
+ OSM_LOG(p_log, OSM_LOG_DEBUG, "ERR 4101: "
+ "Invalid MTU = 0. Forcing correction to 256\n");
+ mtu = 1;
+ }
+
+ OSM_LOG_EXIT(p_log);
+ return mtu;
+}
+
+uint8_t osm_physp_calc_link_op_vls(IN osm_log_t * p_log,
+ IN const osm_subn_t * p_subn,
+ IN const osm_physp_t * p_physp,
+ IN uint8_t current_op_vls)
+{
+ const osm_physp_t *p_remote_physp;
+ uint8_t op_vls;
+ uint8_t remote_op_vls;
+
+ OSM_LOG_ENTER(p_log);
+
+ p_remote_physp = osm_physp_get_remote(p_physp);
+ if (p_remote_physp) {
+ /* use the available VLCap */
+ op_vls = ib_port_info_get_vl_cap(&p_physp->port_info);
+
+ remote_op_vls =
+ ib_port_info_get_vl_cap(&p_remote_physp->port_info);
+
+ OSM_LOG(p_log, OSM_LOG_DEBUG,
+ "Remote port 0x%016" PRIx64 " port = 0x%X : "
+ "VL_CAP = %u. This port VL_CAP = %u\n",
+ cl_ntoh64(osm_physp_get_port_guid(p_remote_physp)),
+ osm_physp_get_port_num(p_remote_physp),
+ remote_op_vls, op_vls);
+
+ if (op_vls != remote_op_vls) {
+ if (op_vls > remote_op_vls)
+ op_vls = remote_op_vls;
+ if (op_vls != current_op_vls)
+ OSM_LOG(p_log, OSM_LOG_VERBOSE,
+ "OP_VLS mismatch between ports."
+ "\n\t\t\t\tPort 0x%016" PRIx64 ", port 0x%X"
+ " and port 0x%016" PRIx64 ", port 0x%X."
+ "\n\t\t\t\tUsing lower OP_VLS of %u\n",
+ cl_ntoh64(osm_physp_get_port_guid(p_physp)),
+ osm_physp_get_port_num(p_physp),
+ cl_ntoh64(osm_physp_get_port_guid
+ (p_remote_physp)),
+ osm_physp_get_port_num(p_remote_physp), op_vls);
+ }
+ } else
+ op_vls = ib_port_info_get_op_vls(&p_physp->port_info);
+
+ if (op_vls == 0) {
+ /* for non compliant implementations */
+ OSM_LOG(p_log, OSM_LOG_VERBOSE,
+ "Invalid OP_VLS = 0. Forcing correction to 1 (VL0)\n");
+ op_vls = 1;
+ }
+
+ /* support user limitation of max_op_vls */
+ if (op_vls > p_subn->opt.max_op_vls)
+ op_vls = p_subn->opt.max_op_vls;
+
+ OSM_LOG_EXIT(p_log);
+ return op_vls;
+}
+
+static inline uint64_t ptr_to_key(void const *p)
+{
+ uint64_t k = 0;
+
+ memcpy(&k, p, sizeof(void *));
+ return k;
+}
+
+static inline void *key_to_ptr(uint64_t k)
+{
+ void *p = 0;
+
+ memcpy(&p, &k, sizeof(void *));
+ return p;
+}
+
+/**********************************************************************
+ Traverse the fabric from the SM node following the DR path given and
+ add every phys port traversed to the map. Avoid tracking the first and
+ last phys ports (going into the first switch and into the target port).
+ **********************************************************************/
+static cl_status_t physp_get_dr_physp_set(IN osm_log_t * p_log,
+ IN osm_subn_t const *p_subn,
+ IN osm_dr_path_t const *p_path,
+ OUT cl_map_t * p_physp_map)
+{
+ osm_port_t *p_port;
+ osm_physp_t *p_physp;
+ osm_node_t *p_node;
+ uint8_t hop;
+ cl_status_t status = CL_SUCCESS;
+
+ OSM_LOG_ENTER(p_log);
+
+ /* find the OSM node */
+ p_port = osm_get_port_by_guid(p_subn, p_subn->sm_port_guid);
+ if (!p_port) {
+ OSM_LOG(p_log, OSM_LOG_ERROR, "ERR 4103: "
+ "Failed to find the SM own port by guid\n");
+ status = CL_ERROR;
+ goto Exit;
+ }
+
+ /* get the node of the SM */
+ p_node = p_port->p_node;
+
+ /*
+ traverse the path adding the nodes to the table
+ start after the first dummy hop and stop just before the
+ last one
+ */
+ for (hop = 1; hop < p_path->hop_count - 1; hop++) {
+ /* go out using the phys port of the path */
+ p_physp = osm_node_get_physp_ptr(p_node, p_path->path[hop]);
+
+ /* make sure we got a valid port and it has a remote port */
+ if (!p_physp) {
+ OSM_LOG(p_log, OSM_LOG_ERROR, "ERR 4104: "
+ "DR Traversal stopped on invalid port at hop:%u\n",
+ hop);
+ status = CL_ERROR;
+ goto Exit;
+ }
+
+ /* we track the ports we go out along the path */
+ if (hop > 1)
+ cl_map_insert(p_physp_map, ptr_to_key(p_physp), NULL);
+
+ OSM_LOG(p_log, OSM_LOG_DEBUG,
+ "Traversed through node: 0x%016" PRIx64
+ " port:%u\n",
+ cl_ntoh64(p_node->node_info.node_guid),
+ p_path->path[hop]);
+
+ if (!(p_physp = osm_physp_get_remote(p_physp))) {
+ OSM_LOG(p_log, OSM_LOG_ERROR, "ERR 4106: "
+ "DR Traversal stopped on missing remote physp at hop:%u\n",
+ hop);
+ status = CL_ERROR;
+ goto Exit;
+ }
+
+ p_node = osm_physp_get_node_ptr(p_physp);
+ }
+
+Exit:
+ OSM_LOG_EXIT(p_log);
+ return status;
+}
+
+static void physp_update_new_dr_path(IN osm_physp_t const *p_dest_physp,
+ IN cl_map_t * p_visited_map,
+ IN osm_bind_handle_t * h_bind)
+{
+ cl_list_t tmpPortsList;
+ osm_physp_t *p_physp, *p_src_physp = NULL;
+ uint8_t path_array[IB_SUBNET_PATH_HOPS_MAX];
+ uint8_t i = 0;
+ osm_dr_path_t *p_dr_path;
+
+ cl_list_construct(&tmpPortsList);
+ cl_list_init(&tmpPortsList, 10);
+
+ cl_list_insert_head(&tmpPortsList, p_dest_physp);
+ /* get the output port where we need to come from */
+ p_physp = (osm_physp_t *) cl_map_get(p_visited_map,
+ ptr_to_key(p_dest_physp));
+ while (p_physp != NULL) {
+ cl_list_insert_head(&tmpPortsList, p_physp);
+ /* get the input port through where we reached the output port */
+ p_src_physp = p_physp;
+ p_physp = (osm_physp_t *) cl_map_get(p_visited_map,
+ ptr_to_key(p_physp));
+ /* if we reached a null p_physp - this means we are at the begining
+ of the path. Break. */
+ if (p_physp == NULL)
+ break;
+ /* get the output port */
+ p_physp = (osm_physp_t *) cl_map_get(p_visited_map,
+ ptr_to_key(p_physp));
+ }
+
+ memset(path_array, 0, sizeof(path_array));
+ p_physp = (osm_physp_t *) cl_list_remove_head(&tmpPortsList);
+ while (p_physp != NULL) {
+ i++;
+ path_array[i] = p_physp->port_num;
+ p_physp = (osm_physp_t *) cl_list_remove_head(&tmpPortsList);
+ }
+ if (p_src_physp) {
+ p_dr_path = osm_physp_get_dr_path_ptr(p_src_physp);
+ osm_dr_path_init(p_dr_path, i, path_array);
+ }
+
+ cl_list_destroy(&tmpPortsList);
+}
+
+void osm_physp_replace_dr_path_with_alternate_dr_path(IN osm_log_t * p_log,
+ IN osm_subn_t const
+ *p_subn, IN osm_physp_t const
+ *p_dest_physp,
+ IN osm_bind_handle_t *
+ h_bind)
+{
+ cl_map_t physp_map;
+ cl_map_t visited_map;
+ osm_dr_path_t *p_dr_path;
+ cl_list_t *p_currPortsList;
+ cl_list_t *p_nextPortsList;
+ osm_port_t *p_port;
+ osm_physp_t *p_physp, *p_remote_physp;
+ ib_net64_t port_guid;
+ boolean_t next_list_is_full = TRUE, reached_dest = FALSE;
+ uint8_t num_ports, port_num;
+
+ p_nextPortsList = (cl_list_t *) malloc(sizeof(cl_list_t));
+ if (!p_nextPortsList)
+ return;
+
+ /*
+ initialize the map of all port participating in current dr path
+ not including first and last switches
+ */
+ cl_map_construct(&physp_map);
+ cl_map_init(&physp_map, 4);
+ cl_map_construct(&visited_map);
+ cl_map_init(&visited_map, 4);
+ p_dr_path = osm_physp_get_dr_path_ptr(p_dest_physp);
+ physp_get_dr_physp_set(p_log, p_subn, p_dr_path, &physp_map);
+
+ /*
+ BFS from OSM port until we find the target physp but avoid
+ going through mapped ports
+ */
+ cl_list_construct(p_nextPortsList);
+ cl_list_init(p_nextPortsList, 10);
+
+ port_guid = p_subn->sm_port_guid;
+
+ CL_ASSERT(port_guid);
+
+ p_port = osm_get_port_by_guid(p_subn, port_guid);
+ if (!p_port) {
+ OSM_LOG(p_log, OSM_LOG_ERROR, "ERR 4105: No SM port object\n");
+ goto Exit;
+ }
+
+ /*
+ HACK: We are assuming SM is running on HCA, so when getting the default
+ port we'll get the port connected to the rest of the subnet. If SM is
+ running on SWITCH - we should try to get a dr path from all switch ports.
+ */
+ p_physp = p_port->p_physp;
+
+ CL_ASSERT(p_physp);
+
+ cl_list_insert_tail(p_nextPortsList, p_physp);
+
+ while (next_list_is_full == TRUE) {
+ next_list_is_full = FALSE;
+ p_currPortsList = p_nextPortsList;
+ p_nextPortsList = (cl_list_t *) malloc(sizeof(cl_list_t));
+ if (!p_nextPortsList) {
+ p_nextPortsList = p_currPortsList;
+ goto Exit;
+ }
+ cl_list_construct(p_nextPortsList);
+ cl_list_init(p_nextPortsList, 10);
+ p_physp = (osm_physp_t *) cl_list_remove_head(p_currPortsList);
+ while (p_physp != NULL) {
+ /* If we are in a switch - need to go out through all
+ the other physical ports of the switch */
+ num_ports = osm_node_get_num_physp(p_physp->p_node);
+
+ for (port_num = 1; port_num < num_ports; port_num++) {
+ if (osm_node_get_type(p_physp->p_node) ==
+ IB_NODE_TYPE_SWITCH)
+ p_remote_physp =
+ osm_node_get_physp_ptr(p_physp->
+ p_node,
+ port_num);
+ else
+ /* this is HCA or router - the remote port is just the port connected
+ on the other side */
+ p_remote_physp =
+ p_physp->p_remote_physp;
+
+ /*
+ make sure that all of the following occurred:
+ 1. The port isn't NULL
+ 2. This is not the port we came from
+ 3. The port is not in the physp_map
+ 4. This port haven't been visited before
+ */
+ if (p_remote_physp &&
+ p_remote_physp != p_physp &&
+ cl_map_get(&physp_map,
+ ptr_to_key(p_remote_physp))
+ == NULL
+ && cl_map_get(&visited_map,
+ ptr_to_key
+ (p_remote_physp)) == NULL) {
+ /* Insert the port into the visited_map, and save its source port */
+ cl_map_insert(&visited_map,
+ ptr_to_key
+ (p_remote_physp),
+ p_physp);
+
+ /* Is this the p_dest_physp? */
+ if (p_remote_physp == p_dest_physp) {
+ /* update the new dr path */
+ physp_update_new_dr_path
+ (p_dest_physp, &visited_map,
+ h_bind);
+ reached_dest = TRUE;
+ break;
+ }
+
+ /* add the p_remote_physp to the nextPortsList */
+ cl_list_insert_tail(p_nextPortsList,
+ p_remote_physp);
+ next_list_is_full = TRUE;
+ }
+ }
+
+ p_physp = (osm_physp_t *)
+ cl_list_remove_head(p_currPortsList);
+ if (reached_dest == TRUE) {
+ /* free the rest of the currPortsList */
+ while (p_physp != NULL)
+ p_physp = (osm_physp_t *)
+ cl_list_remove_head
+ (p_currPortsList);
+ /* free the nextPortsList, if items were added to it */
+ p_physp = (osm_physp_t *)
+ cl_list_remove_head(p_nextPortsList);
+ while (p_physp != NULL)
+ p_physp = (osm_physp_t *)
+ cl_list_remove_head
+ (p_nextPortsList);
+ next_list_is_full = FALSE;
+ }
+ }
+ cl_list_destroy(p_currPortsList);
+ free(p_currPortsList);
+ }
+
+ /* cleanup */
+Exit:
+ cl_list_destroy(p_nextPortsList);
+ free(p_nextPortsList);
+ cl_map_destroy(&physp_map);
+ cl_map_destroy(&visited_map);
+}
+
+boolean_t osm_link_is_healthy(IN const osm_physp_t * p_physp)
+{
+ osm_physp_t *p_remote_physp;
+
+ CL_ASSERT(p_physp);
+ p_remote_physp = p_physp->p_remote_physp;
+ if (p_remote_physp != NULL)
+ return ((p_physp->healthy) & (p_remote_physp->healthy));
+ /* the other side is not known - consider the link as healthy */
+ return TRUE;
+}
+
+void osm_physp_set_pkey_tbl(IN osm_log_t * p_log, IN const osm_subn_t * p_subn,
+ IN osm_physp_t * p_physp,
+ IN ib_pkey_table_t * p_pkey_tbl,
+ IN uint16_t block_num,
+ IN boolean_t is_set)
+{
+ uint16_t max_blocks;
+
+ CL_ASSERT(p_pkey_tbl);
+ /*
+ (14.2.5.7) - the block number valid values are 0-2047, and are
+ further limited by the size of the P_Key table specified by
+ the PartitionCap on the node.
+ */
+ if (!p_physp->p_node->sw || p_physp->port_num == 0)
+ /*
+ The maximum blocks is defined in the node info: partition cap
+ for CA, router, and switch management ports.
+ */
+ max_blocks =
+ (cl_ntoh16(p_physp->p_node->node_info.partition_cap) +
+ IB_NUM_PKEY_ELEMENTS_IN_BLOCK - 1)
+ / IB_NUM_PKEY_ELEMENTS_IN_BLOCK;
+ else
+ /*
+ This is a switch, and not a management port. The maximum
+ blocks is defined in the switch info: partition enforcement
+ cap.
+ */
+ max_blocks =
+ (cl_ntoh16(p_physp->p_node->sw->switch_info.enforce_cap) +
+ IB_NUM_PKEY_ELEMENTS_IN_BLOCK -
+ 1) / IB_NUM_PKEY_ELEMENTS_IN_BLOCK;
+
+ if (block_num >= max_blocks) {
+ OSM_LOG(p_log, OSM_LOG_ERROR, "ERR 4108: "
+ "Got illegal update for block number:%u max:%u "
+ "for GUID: %" PRIx64 " port number:%u\n",
+ block_num, max_blocks,
+ cl_ntoh64(p_physp->p_node->node_info.node_guid),
+ p_physp->port_num);
+ return;
+ }
+
+ /* decrement block received counter */
+ if(!is_set)
+ p_physp->pkeys.rcv_blocks_cnt--;
+ osm_pkey_tbl_set(&p_physp->pkeys, block_num, p_pkey_tbl,
+ p_subn->opt.allow_both_pkeys);
+}
+
+osm_alias_guid_t *osm_alias_guid_new(IN const ib_net64_t alias_guid,
+ IN osm_port_t *p_base_port)
+{
+ osm_alias_guid_t *p_alias_guid;
+
+ p_alias_guid = calloc(1, sizeof(*p_alias_guid));
+ if (p_alias_guid) {
+ p_alias_guid->alias_guid = alias_guid;
+ p_alias_guid->p_base_port = p_base_port;
+ }
+ return p_alias_guid;
+}
+
+void osm_alias_guid_delete(IN OUT osm_alias_guid_t ** pp_alias_guid)
+{
+ free(*pp_alias_guid);
+ *pp_alias_guid = NULL;
+}
+
+void osm_physp_set_port_info(IN osm_physp_t * p_physp,
+ IN const ib_port_info_t * p_pi,
+ IN const struct osm_sm * p_sm)
+{
+ CL_ASSERT(p_pi);
+ CL_ASSERT(osm_physp_is_valid(p_physp));
+
+ if (ib_port_info_get_port_state(p_pi) == IB_LINK_DOWN) {
+ /* If PortState is down, only copy PortState */
+ /* and PortPhysicalState per C14-24-2.1 */
+ ib_port_info_set_port_state(&p_physp->port_info, IB_LINK_DOWN);
+ ib_port_info_set_port_phys_state
+ (ib_port_info_get_port_phys_state(p_pi),
+ &p_physp->port_info);
+ } else {
+ p_physp->port_info = *p_pi;
+
+ /* The MKey in p_pi can only be considered valid if it's
+ * for a HCA/router or switch port 0, and it's either
+ * non-zero or the MKeyProtect bits are also zero.
+ */
+ if ((osm_node_get_type(p_physp->p_node) !=
+ IB_NODE_TYPE_SWITCH || p_physp->port_num == 0) &&
+ (p_pi->m_key != 0 || ib_port_info_get_mpb(p_pi) == 0))
+ osm_db_guid2mkey_set(p_sm->p_subn->p_g2m,
+ cl_ntoh64(p_physp->port_guid),
+ cl_ntoh64(p_pi->m_key));
+ }
+}
diff --git a/contrib/ofed/opensm/opensm/osm_port_info_rcv.c b/contrib/ofed/opensm/opensm/osm_port_info_rcv.c
new file mode 100644
index 0000000..fcc80f2
--- /dev/null
+++ b/contrib/ofed/opensm/opensm/osm_port_info_rcv.c
@@ -0,0 +1,820 @@
+/*
+ * Copyright (c) 2004-2009 Voltaire, Inc. All rights reserved.
+ * Copyright (c) 2002-2012 Mellanox Technologies LTD. All rights reserved.
+ * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
+ * Copyright (c) 2009 HNR Consulting. All rights reserved.
+ * Copyright (c) 2013 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+/*
+ * Abstract:
+ * Implementation of osm_pi_rcv_t.
+ * This object represents the PortInfo Receiver object.
+ * This object is part of the opensm family of objects.
+ */
+
+#if HAVE_CONFIG_H
+# include <config.h>
+#endif /* HAVE_CONFIG_H */
+
+#include <string.h>
+#include <stdlib.h>
+#include <iba/ib_types.h>
+#include <complib/cl_qmap.h>
+#include <complib/cl_passivelock.h>
+#include <complib/cl_debug.h>
+#include <opensm/osm_file_ids.h>
+#define FILE_ID OSM_FILE_PORT_INFO_RCV_C
+#include <vendor/osm_vendor_api.h>
+#include <opensm/osm_madw.h>
+#include <opensm/osm_log.h>
+#include <opensm/osm_node.h>
+#include <opensm/osm_subnet.h>
+#include <opensm/osm_mad_pool.h>
+#include <opensm/osm_msgdef.h>
+#include <opensm/osm_helper.h>
+#include <opensm/osm_pkey.h>
+#include <opensm/osm_remote_sm.h>
+#include <opensm/osm_opensm.h>
+#include <opensm/osm_ucast_mgr.h>
+
+static void pi_rcv_check_and_fix_lid(osm_log_t * log, ib_port_info_t * pi,
+ osm_physp_t * p)
+{
+ if (PF(cl_ntoh16(pi->base_lid) > IB_LID_UCAST_END_HO)) {
+ OSM_LOG(log, OSM_LOG_ERROR, "ERR 0F04: "
+ "Got invalid base LID %u from the network. "
+ "Corrected to %u\n", cl_ntoh16(pi->base_lid),
+ cl_ntoh16(p->port_info.base_lid));
+ pi->base_lid = p->port_info.base_lid;
+ }
+}
+
+static void pi_rcv_process_endport(IN osm_sm_t * sm, IN osm_physp_t * p_physp,
+ IN const ib_port_info_t * p_pi)
+{
+ osm_madw_context_t context;
+ ib_api_status_t status;
+ ib_net64_t port_guid;
+ int extended;
+ uint8_t rate, mtu, mpb;
+ unsigned data_vls;
+ cl_qmap_t *p_sm_tbl;
+ osm_remote_sm_t *p_sm;
+
+ OSM_LOG_ENTER(sm->p_log);
+
+ port_guid = osm_physp_get_port_guid(p_physp);
+
+ /* HACK extended port 0 should be handled too! */
+ if (osm_physp_get_port_num(p_physp) != 0 &&
+ ib_port_info_get_port_state(p_pi) != IB_LINK_DOWN) {
+ /* track the minimal endport MTU, rate, and operational VLs */
+ mtu = ib_port_info_get_mtu_cap(p_pi);
+ if (mtu < sm->p_subn->min_ca_mtu) {
+ OSM_LOG(sm->p_log, OSM_LOG_VERBOSE,
+ "Setting endport minimal MTU to:%u defined by port:0x%"
+ PRIx64 "\n", mtu, cl_ntoh64(port_guid));
+ sm->p_subn->min_ca_mtu = mtu;
+ }
+
+ extended = p_pi->capability_mask & IB_PORT_CAP_HAS_EXT_SPEEDS;
+ rate = ib_port_info_compute_rate(p_pi, extended);
+ if (ib_path_compare_rates(rate, sm->p_subn->min_ca_rate) < 0) {
+ OSM_LOG(sm->p_log, OSM_LOG_VERBOSE,
+ "Setting endport minimal rate to:%u defined by port:0x%"
+ PRIx64 "\n", rate, cl_ntoh64(port_guid));
+ sm->p_subn->min_ca_rate = rate;
+ }
+
+ data_vls = 1U << (ib_port_info_get_vl_cap(p_pi) - 1);
+ if (data_vls > 1U << (sm->p_subn->opt.max_op_vls - 1))
+ data_vls = 1U << (sm->p_subn->opt.max_op_vls - 1);
+ if (data_vls >= IB_MAX_NUM_VLS)
+ data_vls = IB_MAX_NUM_VLS - 1;
+ if ((uint8_t)data_vls < sm->p_subn->min_data_vls) {
+ OSM_LOG(sm->p_log, OSM_LOG_VERBOSE,
+ "Setting endport minimal data VLs to:%u defined by port:0x%"
+ PRIx64 "\n", data_vls, cl_ntoh64(port_guid));
+ sm->p_subn->min_data_vls = data_vls;
+ }
+ }
+
+ /* Check M_Key vs M_Key protect, can we control the port ? */
+ mpb = ib_port_info_get_mpb(p_pi);
+ if (mpb > 0 && p_pi->m_key == 0) {
+ OSM_LOG(sm->p_log, OSM_LOG_INFO,
+ "Port 0x%" PRIx64 " has unknown M_Key, protection level %u\n",
+ cl_ntoh64(port_guid), mpb);
+ }
+
+ if (port_guid != sm->p_subn->sm_port_guid) {
+ p_sm_tbl = &sm->p_subn->sm_guid_tbl;
+ if (p_pi->capability_mask & IB_PORT_CAP_IS_SM) {
+ /*
+ * Before querying the SM - we want to make sure we
+ * clean its state, so if the querying fails we
+ * recognize that this SM is not active.
+ */
+ p_sm =
+ (osm_remote_sm_t *) cl_qmap_get(p_sm_tbl,
+ port_guid);
+ if (p_sm != (osm_remote_sm_t *) cl_qmap_end(p_sm_tbl))
+ /* clean it up */
+ p_sm->smi.pri_state =
+ 0xF0 & p_sm->smi.pri_state;
+ if (sm->p_subn->opt.ignore_other_sm)
+ OSM_LOG(sm->p_log, OSM_LOG_VERBOSE,
+ "Ignoring SM on port 0x%" PRIx64 "\n",
+ cl_ntoh64(port_guid));
+ else {
+ OSM_LOG(sm->p_log, OSM_LOG_VERBOSE,
+ "Detected another SM. Requesting SMInfo "
+ "from port 0x%" PRIx64 "\n",
+ cl_ntoh64(port_guid));
+
+ /*
+ This port indicates it's an SM and
+ it's not our own port.
+ Acquire the SMInfo Attribute.
+ */
+ memset(&context, 0, sizeof(context));
+ context.smi_context.set_method = FALSE;
+ context.smi_context.port_guid = port_guid;
+ status = osm_req_get(sm,
+ osm_physp_get_dr_path_ptr
+ (p_physp),
+ IB_MAD_ATTR_SM_INFO, 0,
+ FALSE,
+ ib_port_info_get_m_key(&p_physp->port_info),
+ CL_DISP_MSGID_NONE,
+ &context);
+
+ if (status != IB_SUCCESS)
+ OSM_LOG(sm->p_log, OSM_LOG_ERROR,
+ "ERR 0F05: "
+ "Failure requesting SMInfo (%s) "
+ "from port 0x%" PRIx64 "\n",
+ ib_get_err_str(status),
+ cl_ntoh64(port_guid));
+ }
+ } else {
+ p_sm =
+ (osm_remote_sm_t *) cl_qmap_remove(p_sm_tbl,
+ port_guid);
+ if (p_sm != (osm_remote_sm_t *) cl_qmap_end(p_sm_tbl))
+ free(p_sm);
+ }
+ }
+
+ OSM_LOG_EXIT(sm->p_log);
+}
+
+/**********************************************************************
+ The plock must be held before calling this function.
+**********************************************************************/
+static void pi_rcv_process_switch_port0(IN osm_sm_t * sm,
+ IN osm_node_t * p_node,
+ IN osm_physp_t * p_physp,
+ IN ib_port_info_t * p_pi)
+{
+ ib_api_status_t status;
+ osm_madw_context_t context;
+ uint8_t port, num_ports;
+
+ OSM_LOG_ENTER(sm->p_log);
+
+ if (p_physp->need_update)
+ sm->p_subn->ignore_existing_lfts = TRUE;
+
+ pi_rcv_check_and_fix_lid(sm->p_log, p_pi, p_physp);
+
+ /* Update the PortInfo attribute */
+ osm_physp_set_port_info(p_physp, p_pi, sm);
+
+ /* Determine if base switch port 0 */
+ if (p_node->sw &&
+ !ib_switch_info_is_enhanced_port0(&p_node->sw->switch_info))
+ /* PortState is not used on BSP0 but just in case it is DOWN */
+ p_physp->port_info = *p_pi;
+
+ /* Now, query PortInfo for the switch external ports */
+ num_ports = osm_node_get_num_physp(p_node);
+
+ context.pi_context.node_guid = osm_node_get_node_guid(p_node);
+ context.pi_context.port_guid = osm_physp_get_port_guid(p_physp);
+ context.pi_context.set_method = FALSE;
+ context.pi_context.light_sweep = FALSE;
+ context.pi_context.active_transition = FALSE;
+ context.pi_context.client_rereg = FALSE;
+
+ for (port = 1; port < num_ports; port++) {
+ status = osm_req_get(sm, osm_physp_get_dr_path_ptr(p_physp),
+ IB_MAD_ATTR_PORT_INFO, cl_hton32(port),
+ FALSE,
+ ib_port_info_get_m_key(&p_physp->port_info),
+ CL_DISP_MSGID_NONE, &context);
+ if (status != IB_SUCCESS)
+ OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR 0F16: "
+ "Failure initiating PortInfo request (%s)\n",
+ ib_get_err_str(status));
+ }
+
+ pi_rcv_process_endport(sm, p_physp, p_pi);
+ OSM_LOG_EXIT(sm->p_log);
+}
+
+/**********************************************************************
+ The plock must be held before calling this function.
+**********************************************************************/
+static void pi_rcv_process_switch_ext_port(IN osm_sm_t * sm,
+ IN osm_node_t * p_node,
+ IN osm_physp_t * p_physp,
+ IN ib_port_info_t * p_pi)
+{
+ ib_api_status_t status = IB_SUCCESS;
+ osm_madw_context_t context;
+ osm_physp_t *p_remote_physp, *physp0;
+ osm_node_t *p_remote_node;
+ ib_net64_t m_key;
+ unsigned data_vls;
+ uint8_t port_num;
+ uint8_t remote_port_num;
+ osm_dr_path_t path;
+ int mlnx_epi_supported = 0;
+
+ OSM_LOG_ENTER(sm->p_log);
+
+ /*
+ Check the state of the physical port.
+ If there appears to be something on the other end of the wire,
+ then ask for NodeInfo. Ignore the switch management port.
+ */
+ port_num = osm_physp_get_port_num(p_physp);
+
+ if (sm->p_subn->opt.fdr10)
+ mlnx_epi_supported = is_mlnx_ext_port_info_supported(
+ ib_node_info_get_vendor_id(&p_node->node_info),
+ p_node->node_info.device_id);
+
+ /* if in_sweep_hop_0 is TRUE, then this means the SM is on the switch,
+ and we got switchInfo of our local switch. Do not continue
+ probing through the switch. */
+ switch (ib_port_info_get_port_state(p_pi)) {
+ case IB_LINK_DOWN:
+ p_remote_physp = osm_physp_get_remote(p_physp);
+ if (p_remote_physp) {
+ p_remote_node =
+ osm_physp_get_node_ptr(p_remote_physp);
+ remote_port_num =
+ osm_physp_get_port_num(p_remote_physp);
+
+ OSM_LOG(sm->p_log, OSM_LOG_VERBOSE,
+ "Unlinking local node 0x%" PRIx64
+ ", port %u"
+ "\n\t\t\t\tand remote node 0x%" PRIx64
+ ", port %u\n",
+ cl_ntoh64(osm_node_get_node_guid
+ (p_node)), port_num,
+ cl_ntoh64(osm_node_get_node_guid
+ (p_remote_node)),
+ remote_port_num);
+
+ if (sm->ucast_mgr.cache_valid)
+ osm_ucast_cache_add_link(&sm->ucast_mgr,
+ p_physp,
+ p_remote_physp);
+
+ osm_node_unlink(p_node, (uint8_t) port_num,
+ p_remote_node,
+ (uint8_t) remote_port_num);
+
+ }
+ break;
+
+ case IB_LINK_INIT:
+ case IB_LINK_ARMED:
+ case IB_LINK_ACTIVE:
+ physp0 = osm_node_get_physp_ptr(p_node, 0);
+ if (mlnx_epi_supported) {
+ m_key = ib_port_info_get_m_key(&physp0->port_info);
+
+ context.pi_context.node_guid = osm_node_get_node_guid(p_node);
+ context.pi_context.port_guid = osm_physp_get_port_guid(p_physp);
+ context.pi_context.set_method = FALSE;
+ context.pi_context.light_sweep = FALSE;
+ context.pi_context.active_transition = FALSE;
+ context.pi_context.client_rereg = FALSE;
+ status = osm_req_get(sm,
+ osm_physp_get_dr_path_ptr(p_physp),
+ IB_MAD_ATTR_MLNX_EXTENDED_PORT_INFO,
+ cl_hton32(port_num), FALSE, m_key,
+ CL_DISP_MSGID_NONE, &context);
+ if (status != IB_SUCCESS)
+ OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR 0F11: "
+ "Failure initiating MLNX ExtPortInfo request (%s)\n",
+ ib_get_err_str(status));
+ }
+ if (sm->p_subn->in_sweep_hop_0 == FALSE) {
+ /*
+ To avoid looping forever, only probe the port if it
+ is NOT the port that responded to the SMP.
+
+ Request node info from the other end of this link:
+ 1) Copy the current path from the parent node.
+ 2) Extend the path to the next hop thru this port.
+ 3) Request node info with the new path
+
+ */
+ if (p_pi->local_port_num !=
+ osm_physp_get_port_num(p_physp)) {
+ path = *osm_physp_get_dr_path_ptr(p_physp);
+
+ if (osm_dr_path_extend(&path,
+ osm_physp_get_port_num
+ (p_physp))) {
+ OSM_LOG(sm->p_log, OSM_LOG_ERROR,
+ "ERR 0F08: "
+ "DR path with hop count %d couldn't be extended\n",
+ path.hop_count);
+ break;
+ }
+
+ memset(&context, 0, sizeof(context));
+ context.ni_context.node_guid =
+ osm_node_get_node_guid(p_node);
+ context.ni_context.port_num =
+ osm_physp_get_port_num(p_physp);
+
+ status = osm_req_get(sm, &path,
+ IB_MAD_ATTR_NODE_INFO, 0,
+ TRUE, 0,
+ CL_DISP_MSGID_NONE,
+ &context);
+
+ if (status != IB_SUCCESS)
+ OSM_LOG(sm->p_log, OSM_LOG_ERROR,
+ "ERR 0F02: "
+ "Failure initiating NodeInfo request (%s)\n",
+ ib_get_err_str(status));
+ } else
+ OSM_LOG(sm->p_log, OSM_LOG_DEBUG,
+ "Skipping SMP responder port %u\n",
+ p_pi->local_port_num);
+ }
+ break;
+
+ default:
+ OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR 0F03: "
+ "Unknown link state = %u, port = %u\n",
+ ib_port_info_get_port_state(p_pi),
+ p_pi->local_port_num);
+ break;
+ }
+
+ if (ib_port_info_get_port_state(p_pi) > IB_LINK_INIT && p_node->sw &&
+ !ib_switch_info_get_state_change(&p_node->sw->switch_info) &&
+ p_node->sw->need_update == 1)
+ p_node->sw->need_update = 0;
+
+ if (p_physp->need_update)
+ sm->p_subn->ignore_existing_lfts = TRUE;
+
+ /*
+ Update the PortInfo attribute.
+ */
+ osm_physp_set_port_info(p_physp, p_pi, sm);
+
+ if (ib_port_info_get_port_state(p_pi) == IB_LINK_DOWN)
+ goto Exit;
+
+ p_remote_physp = osm_physp_get_remote(p_physp);
+ if (p_remote_physp) {
+ p_remote_node = osm_physp_get_node_ptr(p_remote_physp);
+ if (p_remote_node->sw) {
+ data_vls = 1U << (ib_port_info_get_vl_cap(p_pi) - 1);
+ if (data_vls > 1U << (sm->p_subn->opt.max_op_vls - 1))
+ data_vls = 1U << (sm->p_subn->opt.max_op_vls - 1);
+ if (data_vls >= IB_MAX_NUM_VLS)
+ data_vls = IB_MAX_NUM_VLS - 1;
+ if ((uint8_t)data_vls < sm->p_subn->min_sw_data_vls) {
+ OSM_LOG(sm->p_log, OSM_LOG_VERBOSE,
+ "Setting switch port minimal data VLs "
+ "to:%u defined by node:0x%"
+ PRIx64 ", port:%u\n", data_vls,
+ cl_ntoh64(osm_node_get_node_guid(p_node)),
+ port_num);
+ sm->p_subn->min_sw_data_vls = data_vls;
+ }
+ }
+ }
+
+Exit:
+ OSM_LOG_EXIT(sm->p_log);
+}
+
+static void pi_rcv_process_ca_or_router_port(IN osm_sm_t * sm,
+ IN osm_node_t * p_node,
+ IN osm_physp_t * p_physp,
+ IN ib_port_info_t * p_pi)
+{
+ OSM_LOG_ENTER(sm->p_log);
+
+ UNUSED_PARAM(p_node);
+
+ pi_rcv_check_and_fix_lid(sm->p_log, p_pi, p_physp);
+
+ osm_physp_set_port_info(p_physp, p_pi, sm);
+
+ pi_rcv_process_endport(sm, p_physp, p_pi);
+
+ OSM_LOG_EXIT(sm->p_log);
+}
+
+#define IBM_VENDOR_ID (0x5076)
+static void get_pkey_table(IN osm_log_t * p_log, IN osm_sm_t * sm,
+ IN osm_node_t * p_node, IN osm_physp_t * p_physp)
+{
+
+ osm_madw_context_t context;
+ ib_api_status_t status;
+ osm_dr_path_t path;
+ osm_physp_t *physp0;
+ ib_net64_t m_key;
+ uint8_t port_num;
+ uint16_t block_num, max_blocks;
+ uint32_t attr_mod_ho;
+
+ OSM_LOG_ENTER(p_log);
+
+ path = *osm_physp_get_dr_path_ptr(p_physp);
+
+ context.pkey_context.node_guid = osm_node_get_node_guid(p_node);
+ context.pkey_context.port_guid = osm_physp_get_port_guid(p_physp);
+ context.pkey_context.set_method = FALSE;
+
+ port_num = p_physp->port_num;
+
+ if (!p_node->sw || port_num == 0)
+ /* The maximum blocks is defined by the node info partition cap
+ for CA, router, and switch management ports. */
+ max_blocks =
+ (cl_ntoh16(p_node->node_info.partition_cap) +
+ IB_NUM_PKEY_ELEMENTS_IN_BLOCK - 1)
+ / IB_NUM_PKEY_ELEMENTS_IN_BLOCK;
+ else {
+ /* This is a switch, and not a management port. The maximum blocks
+ is defined in the switch info partition enforcement cap. */
+
+ /* Check for IBM eHCA firmware defect in reporting partition enforcement cap */
+ if (cl_ntoh32(ib_node_info_get_vendor_id(&p_node->node_info)) ==
+ IBM_VENDOR_ID)
+ p_node->sw->switch_info.enforce_cap = 0;
+
+ /* Bail out if this is a switch with no partition enforcement capability */
+ if (cl_ntoh16(p_node->sw->switch_info.enforce_cap) == 0)
+ goto Exit;
+
+ max_blocks = (cl_ntoh16(p_node->sw->switch_info.enforce_cap) +
+ IB_NUM_PKEY_ELEMENTS_IN_BLOCK -
+ 1) / IB_NUM_PKEY_ELEMENTS_IN_BLOCK;
+ }
+
+ p_physp->pkeys.rcv_blocks_cnt = max_blocks;
+ for (block_num = 0; block_num < max_blocks; block_num++) {
+ if (osm_node_get_type(p_node) != IB_NODE_TYPE_SWITCH ||
+ osm_physp_get_port_num(p_physp) == 0) {
+ attr_mod_ho = block_num;
+ m_key = ib_port_info_get_m_key(&p_physp->port_info);
+ } else {
+ attr_mod_ho = block_num | (port_num << 16);
+ physp0 = osm_node_get_physp_ptr(p_node, 0);
+ m_key = ib_port_info_get_m_key(&physp0->port_info);
+ }
+ status = osm_req_get(sm, &path, IB_MAD_ATTR_P_KEY_TABLE,
+ cl_hton32(attr_mod_ho), FALSE,
+ m_key, CL_DISP_MSGID_NONE, &context);
+
+ if (status != IB_SUCCESS) {
+ OSM_LOG(p_log, OSM_LOG_ERROR, "ERR 0F12: "
+ "Failure initiating PKeyTable request (%s)\n",
+ ib_get_err_str(status));
+ goto Exit;
+ }
+ }
+
+Exit:
+ OSM_LOG_EXIT(p_log);
+}
+
+static void pi_rcv_get_pkey_slvl_vla_tables(IN osm_sm_t * sm,
+ IN osm_node_t * p_node,
+ IN osm_physp_t * p_physp)
+{
+ OSM_LOG_ENTER(sm->p_log);
+
+ get_pkey_table(sm->p_log, sm, p_node, p_physp);
+
+ OSM_LOG_EXIT(sm->p_log);
+}
+
+static int osm_pi_rcv_update_self(IN osm_sm_t *sm, IN osm_physp_t *p_physp,
+ IN ib_port_info_t *p_pi)
+{
+ if (ib_port_info_get_port_state(p_pi) == IB_LINK_DOWN)
+ return 0;
+
+ if (sm->p_subn->need_update || p_physp->need_update > 1 ||
+ ib_port_info_get_port_state(p_pi) == IB_LINK_INIT)
+ return 1;
+
+ return 0;
+}
+
+static void pi_rcv_process_set(IN osm_sm_t * sm, IN osm_node_t * p_node,
+ IN uint8_t port_num, IN osm_madw_t * p_madw)
+{
+ osm_physp_t *p_physp;
+ ib_net64_t port_guid;
+ ib_smp_t *p_smp;
+ ib_port_info_t *p_pi;
+ osm_pi_context_t *p_context;
+ osm_log_level_t level;
+
+ OSM_LOG_ENTER(sm->p_log);
+
+ p_context = osm_madw_get_pi_context_ptr(p_madw);
+
+ CL_ASSERT(p_node);
+
+ p_physp = osm_node_get_physp_ptr(p_node, port_num);
+ CL_ASSERT(p_physp);
+
+ port_guid = osm_physp_get_port_guid(p_physp);
+
+ p_smp = osm_madw_get_smp_ptr(p_madw);
+ p_pi = ib_smp_get_payload_ptr(p_smp);
+
+ /* check for error */
+ if (cl_ntoh16(p_smp->status) & 0x7fff) {
+ /* If port already ACTIVE, don't treat status 7 as error */
+ if (p_context->active_transition &&
+ (cl_ntoh16(p_smp->status) & 0x7fff) == 0x1c) {
+ level = OSM_LOG_INFO;
+ OSM_LOG(sm->p_log, OSM_LOG_INFO,
+ "Received error status 0x%x for SetResp() during ACTIVE transition\n",
+ cl_ntoh16(p_smp->status) & 0x7fff);
+ /* Should there be a subsequent Get to validate that port is ACTIVE ? */
+ } else {
+ level = OSM_LOG_ERROR;
+ OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR 0F10: "
+ "Received error status for SetResp()\n");
+ }
+ osm_dump_port_info_v2(sm->p_log, osm_node_get_node_guid(p_node),
+ port_guid, port_num, p_pi, FILE_ID, level);
+ } else
+ osm_physp_set_port_info(p_physp, p_pi, sm);
+
+ OSM_LOG(sm->p_log, OSM_LOG_DEBUG,
+ "Received logical SetResp() for GUID 0x%" PRIx64
+ ", port num %u"
+ "\n\t\t\t\tfor parent node GUID 0x%" PRIx64
+ " TID 0x%" PRIx64 "\n",
+ cl_ntoh64(port_guid), port_num,
+ cl_ntoh64(osm_node_get_node_guid(p_node)),
+ cl_ntoh64(p_smp->trans_id));
+
+
+ OSM_LOG_EXIT(sm->p_log);
+}
+
+static int osm_pi_rcv_update_neighbor(IN osm_physp_t *p_physp)
+{
+ osm_physp_t *p_rem_physp = p_physp->p_remote_physp;
+ osm_node_t *p_node;
+
+ /*
+ * Our own port - this is the only case where CA port
+ * is discovered before its' neighbor port
+ */
+ if (!p_rem_physp)
+ return p_physp->need_update;
+
+ p_node = osm_physp_get_node_ptr(p_rem_physp);
+ CL_ASSERT(p_node);
+
+ /* CA/RTR to CA/RTR connection */
+ if (!p_node->sw)
+ return p_physp->need_update;
+
+ return (ib_switch_info_get_state_change(&p_node->sw->switch_info) ? 1 : p_physp->need_update);
+}
+
+void osm_pi_rcv_process(IN void *context, IN void *data)
+{
+ osm_sm_t *sm = context;
+ osm_madw_t *p_madw = data;
+ ib_port_info_t *p_pi;
+ ib_smp_t *p_smp;
+ osm_port_t *p_port;
+ osm_physp_t *p_physp;
+ osm_dr_path_t *p_dr_path;
+ osm_node_t *p_node;
+ osm_pi_context_t *p_context;
+ ib_net64_t port_guid, node_guid;
+ uint8_t port_num;
+
+ CL_ASSERT(sm);
+
+ OSM_LOG_ENTER(sm->p_log);
+
+ CL_ASSERT(p_madw);
+
+ p_smp = osm_madw_get_smp_ptr(p_madw);
+ p_context = osm_madw_get_pi_context_ptr(p_madw);
+ p_pi = ib_smp_get_payload_ptr(p_smp);
+
+ CL_ASSERT(p_smp->attr_id == IB_MAD_ATTR_PORT_INFO);
+
+ /*
+ * Attribute modifier has already been validated upon MAD receive,
+ * which means that port_num has to be valid - it originated from
+ * the request attribute modifier.
+ */
+ port_num = (uint8_t) cl_ntoh32(p_smp->attr_mod);
+
+ port_guid = p_context->port_guid;
+ node_guid = p_context->node_guid;
+
+ osm_dump_port_info_v2(sm->p_log, node_guid, port_guid, port_num, p_pi,
+ FILE_ID, OSM_LOG_DEBUG);
+
+ /* On receipt of client reregister, clear the reregister bit so
+ reregistering won't be sent again and again */
+ if (p_context->set_method &&
+ (ib_port_info_get_client_rereg(p_pi) || p_context->client_rereg)) {
+ OSM_LOG(sm->p_log, OSM_LOG_DEBUG,
+ "Client reregister received on response\n");
+ ib_port_info_set_client_rereg(p_pi, 0);
+ p_context->client_rereg = FALSE;
+ }
+
+ /*
+ we might get a response during a light sweep looking for a change in
+ the status of a remote port that did not respond in earlier sweeps.
+ So if the context of the Get was light_sweep - we do not need to
+ do anything with the response - just flag that we need a heavy sweep
+ */
+ if (p_context->light_sweep == TRUE) {
+ OSM_LOG(sm->p_log, OSM_LOG_VERBOSE,
+ "Got light sweep response from remote port of parent node "
+ "GUID 0x%" PRIx64 " port 0x%016" PRIx64
+ ", Commencing heavy sweep\n",
+ cl_ntoh64(node_guid), cl_ntoh64(port_guid));
+ sm->p_subn->force_heavy_sweep = TRUE;
+ sm->p_subn->ignore_existing_lfts = TRUE;
+ goto Exit;
+ }
+
+ CL_PLOCK_EXCL_ACQUIRE(sm->p_lock);
+ p_port = osm_get_port_by_guid(sm->p_subn, port_guid);
+ if (PF(!p_port)) {
+ CL_PLOCK_RELEASE(sm->p_lock);
+ OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR 0F06: "
+ "No port object for port with GUID 0x%" PRIx64
+ "\n\t\t\t\tfor parent node GUID 0x%" PRIx64
+ ", TID 0x%" PRIx64 "\n",
+ cl_ntoh64(port_guid),
+ cl_ntoh64(node_guid), cl_ntoh64(p_smp->trans_id));
+ goto Exit;
+ }
+
+ p_node = p_port->p_node;
+ CL_ASSERT(p_node);
+
+ if (PF(p_pi->local_port_num > p_node->node_info.num_ports)) {
+ CL_PLOCK_RELEASE(sm->p_lock);
+ OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR 0F15: "
+ "Received PortInfo for port GUID 0x%" PRIx64 " is "
+ "non-compliant and is being ignored since the "
+ "local port num %u > num ports %u\n",
+ cl_ntoh64(port_guid), p_pi->local_port_num,
+ p_node->node_info.num_ports);
+ goto Exit;
+ }
+
+ /*
+ If we were setting the PortInfo, then receiving
+ this attribute was not part of sweeping the subnet.
+ In this case, just update the PortInfo attribute.
+
+ In an unfortunate blunder, the IB spec defines the
+ return method for Set() as a GetResp(). Thus, we can't
+ use the method (what would have been SetResp()) to determine
+ our course of action. So, we have to carry this extra
+ boolean around to determine if we were doing Get() or Set().
+ */
+ if (p_context->set_method)
+ pi_rcv_process_set(sm, p_node, port_num, p_madw);
+ else {
+
+ /*
+ This PortInfo arrived because we did a Get() method,
+ most likely due to a subnet sweep in progress.
+ */
+ OSM_LOG(sm->p_log, OSM_LOG_VERBOSE,
+ "Discovered port num %u with GUID 0x%" PRIx64
+ " for parent node GUID 0x%" PRIx64
+ ", TID 0x%" PRIx64 "\n",
+ port_num, cl_ntoh64(port_guid),
+ cl_ntoh64(node_guid), cl_ntoh64(p_smp->trans_id));
+
+ p_physp = osm_node_get_physp_ptr(p_node, port_num);
+
+ CL_ASSERT(p_physp);
+
+ /* Update the directed route path to this port
+ in case the old path is no longer usable. */
+ p_dr_path = osm_physp_get_dr_path_ptr(p_physp);
+ osm_dr_path_init(p_dr_path, p_smp->hop_count,
+ p_smp->initial_path);
+
+ p_physp->need_update = osm_pi_rcv_update_self(sm, p_physp, p_pi);
+
+ switch (osm_node_get_type(p_node)) {
+ case IB_NODE_TYPE_CA:
+ case IB_NODE_TYPE_ROUTER:
+ if (!p_node->physp_discovered[port_num]) {
+ p_port->discovery_count++;
+ p_node->physp_discovered[port_num] = 1;
+ }
+ p_physp->need_update = osm_pi_rcv_update_neighbor(p_physp);
+ pi_rcv_process_ca_or_router_port(sm, p_node, p_physp,
+ p_pi);
+ break;
+ case IB_NODE_TYPE_SWITCH:
+ if (!p_node->physp_discovered[port_num]) {
+ p_port->discovery_count++;
+ p_node->physp_discovered[port_num] = 1;
+ }
+ if (port_num == 0)
+ pi_rcv_process_switch_port0(sm, p_node,
+ p_physp, p_pi);
+ else
+ pi_rcv_process_switch_ext_port(sm, p_node,
+ p_physp, p_pi);
+ break;
+ default:
+ OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR 0F07: "
+ "Unknown node type %u with GUID 0x%" PRIx64
+ "\n", osm_node_get_type(p_node),
+ cl_ntoh64(node_guid));
+ break;
+ }
+
+ /*
+ Get the tables on the physp.
+ */
+ if (p_physp->need_update || (p_node->sw &&
+ p_node->sw->need_update))
+ pi_rcv_get_pkey_slvl_vla_tables(sm, p_node, p_physp);
+
+ }
+
+ CL_PLOCK_RELEASE(sm->p_lock);
+
+Exit:
+ /*
+ Release the lock before jumping here!!
+ */
+ OSM_LOG_EXIT(sm->p_log);
+}
diff --git a/contrib/ofed/opensm/opensm/osm_prtn.c b/contrib/ofed/opensm/opensm/osm_prtn.c
new file mode 100644
index 0000000..6288a35
--- /dev/null
+++ b/contrib/ofed/opensm/opensm/osm_prtn.c
@@ -0,0 +1,449 @@
+/*
+ * Copyright (c) 2006-2009 Voltaire, Inc. All rights reserved.
+ * Copyright (c) 2012 Mellanox Technologies LTD. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+/*
+ * Abstract:
+ * Implementation of osm_prtn_t.
+ * This object represents an IBA partition.
+ * This object is part of the opensm family of objects.
+ */
+
+#if HAVE_CONFIG_H
+# include <config.h>
+#endif /* HAVE_CONFIG_H */
+
+#include <stdlib.h>
+#include <string.h>
+#include <stdio.h>
+#include <sys/stat.h>
+#include <complib/cl_debug.h>
+#include <iba/ib_types.h>
+#include <opensm/osm_file_ids.h>
+#define FILE_ID OSM_FILE_PRTN_C
+#include <opensm/osm_opensm.h>
+#include <opensm/osm_partition.h>
+#include <opensm/osm_node.h>
+#include <opensm/osm_sa.h>
+#include <opensm/osm_multicast.h>
+#include <arpa/inet.h>
+#include <sys/socket.h>
+#include <errno.h>
+
+extern int osm_prtn_config_parse_file(osm_log_t * p_log, osm_subn_t * p_subn,
+ const char *file_name);
+
+static uint16_t global_pkey_counter;
+
+osm_prtn_t *osm_prtn_new(IN const char *name, IN uint16_t pkey)
+{
+ osm_prtn_t *p = malloc(sizeof(*p));
+ if (!p)
+ return NULL;
+
+ memset(p, 0, sizeof(*p));
+ p->pkey = pkey;
+ p->sl = OSM_DEFAULT_SL;
+ p->mgrps = NULL;
+ p->nmgrps = 0;
+ cl_map_construct(&p->full_guid_tbl);
+ cl_map_init(&p->full_guid_tbl, 32);
+ cl_map_construct(&p->part_guid_tbl);
+ cl_map_init(&p->part_guid_tbl, 32);
+
+ if (name && *name)
+ strncpy(p->name, name, sizeof(p->name));
+ else
+ snprintf(p->name, sizeof(p->name), "%04x", cl_ntoh16(pkey));
+
+ return p;
+}
+
+void osm_prtn_delete(IN osm_subn_t * p_subn, IN OUT osm_prtn_t ** pp_prtn)
+{
+ char gid_str[INET6_ADDRSTRLEN];
+ int i = 0;
+ osm_prtn_t *p = *pp_prtn;
+
+ cl_map_remove_all(&p->full_guid_tbl);
+ cl_map_destroy(&p->full_guid_tbl);
+ cl_map_remove_all(&p->part_guid_tbl);
+ cl_map_destroy(&p->part_guid_tbl);
+
+ if (p->mgrps) {
+ /* Clean up mgrps */
+ for (i = 0; i < p->nmgrps; i++) {
+ /* osm_mgrp_cleanup will not delete
+ * "well_known" groups */
+ p->mgrps[i]->well_known = FALSE;
+ OSM_LOG(&p_subn->p_osm->log, OSM_LOG_DEBUG,
+ "removing mgroup %s from partition (0x%x)\n",
+ inet_ntop(AF_INET6,
+ p->mgrps[i]->mcmember_rec.mgid.raw,
+ gid_str, sizeof gid_str),
+ cl_hton16(p->pkey));
+ osm_mgrp_cleanup(p_subn, p->mgrps[i]);
+ }
+
+ free(p->mgrps);
+ }
+
+ free(p);
+ *pp_prtn = NULL;
+}
+
+ib_api_status_t osm_prtn_add_port(osm_log_t * p_log, osm_subn_t * p_subn,
+ osm_prtn_t * p, ib_net64_t guid,
+ boolean_t full, boolean_t indx0)
+{
+ ib_api_status_t status = IB_SUCCESS;
+ cl_map_t *p_tbl;
+ osm_port_t *p_port;
+ osm_physp_t *p_physp;
+
+ p_port = osm_get_port_by_guid(p_subn, guid);
+ if (!p_port) {
+ OSM_LOG(p_log, OSM_LOG_VERBOSE,
+ "port 0x%" PRIx64 " not found\n", cl_ntoh64(guid));
+ return status;
+ }
+
+ p_physp = p_port->p_physp;
+ if (!p_physp) {
+ OSM_LOG(p_log, OSM_LOG_VERBOSE,
+ "no physical for port 0x%" PRIx64 "\n",
+ cl_ntoh64(guid));
+ return status;
+ }
+ /* Set the pkey to be inserted to block 0 index 0 */
+ if (indx0) {
+ OSM_LOG(p_log, OSM_LOG_VERBOSE, "Setting pkey 0x%04x at indx0 "
+ "for port 0x%" PRIx64 "\n",
+ cl_ntoh16(p->pkey), cl_ntoh64(guid));
+ osm_pkey_tbl_set_indx0_pkey(p_log, p->pkey, full,
+ &p_physp->pkeys);
+ } else if (ib_pkey_get_base(p_physp->pkeys.indx0_pkey) ==
+ ib_pkey_get_base(p->pkey))
+ p_physp->pkeys.indx0_pkey = 0;
+
+ p_tbl = (full == TRUE) ? &p->full_guid_tbl : &p->part_guid_tbl;
+
+ if (p_subn->opt.allow_both_pkeys) {
+ if (cl_map_remove(p_tbl, guid))
+ OSM_LOG(p_log, OSM_LOG_VERBOSE, "port 0x%" PRIx64
+ " already in partition \'%s\' (0x%04x) full %d."
+ " Will overwrite\n",
+ cl_ntoh64(guid), p->name, cl_ntoh16(p->pkey),
+ full);
+ } else {
+ if (cl_map_remove(&p->part_guid_tbl, guid) ||
+ cl_map_remove(&p->full_guid_tbl, guid))
+ OSM_LOG(p_log, OSM_LOG_VERBOSE, "port 0x%" PRIx64
+ " already in partition \'%s\' (0x%04x)."
+ " Will overwrite\n",
+ cl_ntoh64(guid), p->name, cl_ntoh16(p->pkey));
+ }
+
+ if (cl_map_insert(p_tbl, guid, p_physp) == NULL)
+ return IB_INSUFFICIENT_MEMORY;
+
+ return status;
+}
+
+ib_api_status_t osm_prtn_add_all(osm_log_t * p_log, osm_subn_t * p_subn,
+ osm_prtn_t * p, unsigned type,
+ boolean_t full, boolean_t indx0)
+{
+ cl_qmap_t *p_port_tbl = &p_subn->port_guid_tbl;
+ cl_map_item_t *p_item;
+ osm_port_t *p_port;
+ ib_api_status_t status = IB_SUCCESS;
+
+ p_item = cl_qmap_head(p_port_tbl);
+ while (p_item != cl_qmap_end(p_port_tbl)) {
+ p_port = (osm_port_t *) p_item;
+ p_item = cl_qmap_next(p_item);
+ if (!type || osm_node_get_type(p_port->p_node) == type) {
+ status = osm_prtn_add_port(p_log, p_subn, p,
+ osm_port_get_guid(p_port),
+ full, indx0);
+ if (status != IB_SUCCESS)
+ goto _err;
+ }
+ }
+
+_err:
+ return status;
+}
+
+static ib_api_status_t
+track_mgrp_w_partition(osm_log_t *p_log, osm_prtn_t *p, osm_mgrp_t *mgrp,
+ osm_subn_t *p_subn, const ib_gid_t *mgid,
+ ib_net16_t pkey)
+{
+ char gid_str[INET6_ADDRSTRLEN];
+ osm_mgrp_t **tmp;
+ int i = 0;
+
+ /* check if we are already tracking this group */
+ for (i = 0; i < p->nmgrps; i++)
+ if (p->mgrps[i] == mgrp)
+ return (IB_SUCCESS);
+
+ /* otherwise add it to our list */
+ tmp = realloc(p->mgrps, (p->nmgrps +1) * sizeof(*p->mgrps));
+ if (tmp) {
+ p->mgrps = tmp;
+ p->mgrps[p->nmgrps] = mgrp;
+ p->nmgrps++;
+ } else {
+ OSM_LOG(p_log, OSM_LOG_ERROR,
+ "realloc error to create MC group (%s) in "
+ "partition (pkey 0x%04x)\n",
+ inet_ntop(AF_INET6, mgid->raw,
+ gid_str, sizeof gid_str),
+ cl_ntoh16(pkey));
+ mgrp->well_known = FALSE;
+ osm_mgrp_cleanup(p_subn, mgrp);
+ return (IB_ERROR);
+ }
+ mgrp->well_known = TRUE;
+ return (IB_SUCCESS);
+}
+
+ib_api_status_t osm_prtn_add_mcgroup(osm_log_t * p_log, osm_subn_t * p_subn,
+ osm_prtn_t * p, uint8_t rate, uint8_t mtu,
+ uint8_t sl, uint8_t scope, uint32_t Q_Key,
+ uint8_t tclass, uint32_t FlowLabel,
+ const ib_gid_t *mgid)
+{
+ char gid_str[INET6_ADDRSTRLEN];
+ ib_member_rec_t mc_rec;
+ ib_net64_t comp_mask;
+ ib_net16_t pkey;
+ osm_mgrp_t *mgrp;
+ osm_sa_t *p_sa = &p_subn->p_osm->sa;
+ uint8_t hop_limit;
+
+ pkey = p->pkey | cl_hton16(0x8000);
+ if (!scope)
+ scope = OSM_DEFAULT_MGRP_SCOPE;
+ hop_limit = (scope == IB_MC_SCOPE_LINK_LOCAL) ? 0 : IB_HOPLIMIT_MAX;
+
+ memset(&mc_rec, 0, sizeof(mc_rec));
+
+ mc_rec.mgid = *mgid;
+
+ mc_rec.qkey = CL_HTON32(Q_Key);
+ mc_rec.mtu = mtu | (IB_PATH_SELECTOR_EXACTLY << 6);
+ mc_rec.tclass = tclass;
+ mc_rec.pkey = pkey;
+ mc_rec.rate = rate | (IB_PATH_SELECTOR_EXACTLY << 6);
+ mc_rec.pkt_life = p_subn->opt.subnet_timeout;
+ mc_rec.sl_flow_hop = ib_member_set_sl_flow_hop(sl, FlowLabel, hop_limit);
+ /* Scope in MCMemberRecord (if present) needs to be consistent with MGID */
+ mc_rec.scope_state =
+ ib_member_set_scope_state(scope, IB_MC_REC_STATE_FULL_MEMBER);
+ ib_mgid_set_scope(&mc_rec.mgid, scope);
+
+ /* don't update rate, mtu */
+ comp_mask = IB_MCR_COMPMASK_MTU | IB_MCR_COMPMASK_MTU_SEL |
+ IB_MCR_COMPMASK_RATE | IB_MCR_COMPMASK_RATE_SEL;
+ mgrp = osm_mcmr_rcv_find_or_create_new_mgrp(p_sa, comp_mask, &mc_rec);
+ if (!mgrp) {
+ OSM_LOG(p_log, OSM_LOG_ERROR,
+ "Failed to create MC group (%s) with pkey 0x%04x\n",
+ inet_ntop(AF_INET6, mgid->raw, gid_str, sizeof gid_str),
+ cl_ntoh16(pkey));
+ return IB_ERROR;
+ }
+
+ return (track_mgrp_w_partition(p_log, p, mgrp, p_subn, mgid, pkey));
+}
+
+static uint16_t generate_pkey(osm_subn_t * p_subn)
+{
+ uint16_t pkey;
+
+ cl_qmap_t *m = &p_subn->prtn_pkey_tbl;
+ while (global_pkey_counter < cl_ntoh16(IB_DEFAULT_PARTIAL_PKEY) - 1) {
+ pkey = ++global_pkey_counter;
+ pkey = cl_hton16(pkey);
+ if (cl_qmap_get(m, pkey) == cl_qmap_end(m))
+ return pkey;
+ }
+ return 0;
+}
+
+osm_prtn_t *osm_prtn_find_by_name(osm_subn_t * p_subn, const char *name)
+{
+ cl_map_item_t *p_next;
+ osm_prtn_t *p;
+
+ p_next = cl_qmap_head(&p_subn->prtn_pkey_tbl);
+ while (p_next != cl_qmap_end(&p_subn->prtn_pkey_tbl)) {
+ p = (osm_prtn_t *) p_next;
+ p_next = cl_qmap_next(&p->map_item);
+ if (!strncmp(p->name, name, sizeof(p->name)))
+ return p;
+ }
+
+ return NULL;
+}
+
+osm_prtn_t *osm_prtn_make_new(osm_log_t * p_log, osm_subn_t * p_subn,
+ const char *name, uint16_t pkey)
+{
+ osm_prtn_t *p = NULL, *p_check;
+
+ pkey &= cl_hton16((uint16_t) ~ 0x8000);
+ if (!pkey) {
+ if (name && (p = osm_prtn_find_by_name(p_subn, name)))
+ return p;
+ if (!(pkey = generate_pkey(p_subn)))
+ return NULL;
+ }
+
+ p = osm_prtn_new(name, pkey);
+ if (!p) {
+ OSM_LOG(p_log, OSM_LOG_ERROR, "Unable to create"
+ " partition \'%s\' (0x%04x)\n", name, cl_ntoh16(pkey));
+ return NULL;
+ }
+
+ p_check = (osm_prtn_t *) cl_qmap_insert(&p_subn->prtn_pkey_tbl,
+ p->pkey, &p->map_item);
+ if (p != p_check) {
+ OSM_LOG(p_log, OSM_LOG_VERBOSE, "Duplicated partition"
+ " definition: \'%s\' (0x%04x) prev name \'%s\'"
+ ". Will use it\n",
+ name, cl_ntoh16(pkey), p_check->name);
+ osm_prtn_delete(p_subn, &p);
+ p = p_check;
+ }
+
+ return p;
+}
+
+static ib_api_status_t prtn_make_default(osm_log_t * p_log, osm_subn_t * p_subn,
+ boolean_t no_config)
+{
+ ib_api_status_t status = IB_UNKNOWN_ERROR;
+ osm_prtn_t *p;
+
+ p = osm_prtn_make_new(p_log, p_subn, "Default",
+ IB_DEFAULT_PARTIAL_PKEY);
+ if (!p)
+ goto _err;
+ status = osm_prtn_add_all(p_log, p_subn, p, 0, no_config, FALSE);
+ if (status != IB_SUCCESS)
+ goto _err;
+ cl_map_remove(&p->part_guid_tbl, p_subn->sm_port_guid);
+ status =
+ osm_prtn_add_port(p_log, p_subn, p, p_subn->sm_port_guid, TRUE, FALSE);
+
+ /* ipv4 broadcast group */
+ if (no_config)
+ osm_prtn_add_mcgroup(p_log, p_subn, p, OSM_DEFAULT_MGRP_RATE,
+ OSM_DEFAULT_MGRP_MTU, OSM_DEFAULT_SL,
+ 0, OSM_IPOIB_BROADCAST_MGRP_QKEY, 0, 0,
+ &osm_ipoib_broadcast_mgid);
+
+_err:
+ return status;
+}
+
+ib_api_status_t osm_prtn_make_partitions(osm_log_t * p_log, osm_subn_t * p_subn)
+{
+ struct stat statbuf;
+ const char *file_name;
+ boolean_t is_config = TRUE;
+ boolean_t is_wrong_config = FALSE;
+ ib_api_status_t status = IB_SUCCESS;
+ cl_map_item_t *p_next;
+ osm_prtn_t *p;
+
+ file_name = p_subn->opt.partition_config_file ?
+ p_subn->opt.partition_config_file : OSM_DEFAULT_PARTITION_CONFIG_FILE;
+ if (stat(file_name, &statbuf)) {
+ OSM_LOG(p_log, OSM_LOG_VERBOSE, "Partition configuration "
+ "%s is not accessible (%s)\n", file_name,
+ strerror(errno));
+ is_config = FALSE;
+ }
+
+retry_default:
+ /* clean up current port maps */
+ p_next = cl_qmap_head(&p_subn->prtn_pkey_tbl);
+ while (p_next != cl_qmap_end(&p_subn->prtn_pkey_tbl)) {
+ p = (osm_prtn_t *) p_next;
+ p_next = cl_qmap_next(&p->map_item);
+ cl_map_remove_all(&p->part_guid_tbl);
+ cl_map_remove_all(&p->full_guid_tbl);
+ }
+
+ global_pkey_counter = 0;
+
+ status = prtn_make_default(p_log, p_subn, !is_config);
+ if (status != IB_SUCCESS)
+ goto _err;
+
+ if (is_config && osm_prtn_config_parse_file(p_log, p_subn, file_name)) {
+ OSM_LOG(p_log, OSM_LOG_VERBOSE, "Partition configuration "
+ "was not fully processed\n");
+ is_wrong_config = TRUE;
+ }
+
+ /* and now clean up empty partitions */
+ p_next = cl_qmap_head(&p_subn->prtn_pkey_tbl);
+ while (p_next != cl_qmap_end(&p_subn->prtn_pkey_tbl)) {
+ p = (osm_prtn_t *) p_next;
+ p_next = cl_qmap_next(&p->map_item);
+ if (cl_map_count(&p->part_guid_tbl) == 0 &&
+ cl_map_count(&p->full_guid_tbl) == 0) {
+ cl_qmap_remove_item(&p_subn->prtn_pkey_tbl,
+ (cl_map_item_t *) p);
+ osm_prtn_delete(p_subn, &p);
+ }
+ }
+
+ if (is_config && is_wrong_config) {
+ OSM_LOG(p_log, OSM_LOG_ERROR, "Partition configuration "
+ "in error; retrying with default config\n");
+ is_config = FALSE;
+ goto retry_default;
+ }
+
+_err:
+ return status;
+}
diff --git a/contrib/ofed/opensm/opensm/osm_prtn_config.c b/contrib/ofed/opensm/opensm/osm_prtn_config.c
new file mode 100644
index 0000000..5b3fb9f
--- /dev/null
+++ b/contrib/ofed/opensm/opensm/osm_prtn_config.c
@@ -0,0 +1,841 @@
+/*
+ * Copyright (c) 2006-2008 Voltaire, Inc. All rights reserved.
+ * Copyright (c) 2012-2015 Mellanox Technologies LTD. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+/*
+ * Abstract:
+ * Implementation of opensm partition management configuration
+ */
+
+#if HAVE_CONFIG_H
+# include <config.h>
+#endif /* HAVE_CONFIG_H */
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <errno.h>
+#include <ctype.h>
+
+#include <iba/ib_types.h>
+#include <opensm/osm_file_ids.h>
+#define FILE_ID OSM_FILE_PRTN_CONFIG_C
+#include <opensm/osm_base.h>
+#include <opensm/osm_partition.h>
+#include <opensm/osm_subnet.h>
+#include <opensm/osm_log.h>
+#include <arpa/inet.h>
+#include <sys/socket.h>
+
+typedef enum {
+ LIMITED,
+ FULL,
+ BOTH
+} membership_t;
+
+const ib_gid_t osm_ipoib_broadcast_mgid = {
+ {
+ 0xff, /* multicast field */
+ 0x12, /* non-permanent bit, link local scope */
+ 0x40, 0x1b, /* IPv4 signature */
+ 0xff, 0xff, /* 16 bits of P_Key (to be filled in) */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 48 bits of zeros */
+ 0xff, 0xff, 0xff, 0xff, /* 32 bit IPv4 broadcast address */
+ },
+};
+
+struct group_flags {
+ unsigned mtu, rate, sl, scope_mask;
+ uint32_t Q_Key;
+ uint8_t TClass;
+ uint32_t FlowLabel;
+};
+
+struct precreate_mgroup {
+ ib_gid_t mgid;
+ struct group_flags flags;
+};
+
+struct part_conf {
+ osm_log_t *p_log;
+ osm_subn_t *p_subn;
+ osm_prtn_t *p_prtn;
+ unsigned is_ipoib;
+ struct group_flags flags;
+ membership_t membership;
+ boolean_t indx0;
+};
+
+extern osm_prtn_t *osm_prtn_make_new(osm_log_t * p_log, osm_subn_t * p_subn,
+ const char *name, uint16_t pkey);
+extern ib_api_status_t osm_prtn_add_all(osm_log_t * p_log, osm_subn_t * p_subn,
+ osm_prtn_t * p, unsigned type,
+ boolean_t full, boolean_t indx0);
+extern ib_api_status_t osm_prtn_add_port(osm_log_t * p_log,
+ osm_subn_t * p_subn, osm_prtn_t * p,
+ ib_net64_t guid, boolean_t full,
+ boolean_t indx0);
+
+ib_api_status_t osm_prtn_add_mcgroup(osm_log_t * p_log, osm_subn_t * p_subn,
+ osm_prtn_t * p, uint8_t rate, uint8_t mtu,
+ uint8_t sl, uint8_t scope, uint32_t Q_Key,
+ uint8_t TClass, uint32_t FlowLabel,
+ const ib_gid_t *mgid);
+
+
+static inline boolean_t mgid_is_broadcast(const ib_gid_t *mgid)
+{
+ return (memcmp(mgid, &osm_ipoib_broadcast_mgid,
+ sizeof(osm_ipoib_broadcast_mgid)) == 0);
+}
+
+static inline boolean_t mgid_is_ip(const ib_gid_t *mgid)
+{
+ ib_net16_t ipsig = *(ib_net16_t *)&mgid->raw[2];
+ return (ipsig == cl_hton16(0x401b) || ipsig == cl_hton16(0x601b));
+}
+
+static inline boolean_t ip_mgroup_pkey_ok(struct part_conf *conf,
+ struct precreate_mgroup *group)
+{
+ ib_net16_t mpkey = *(ib_net16_t *)&group->mgid.raw[4];
+ char gid_str[INET6_ADDRSTRLEN];
+
+ if (mgid_is_broadcast(&group->mgid)
+ /* user requested "wild card" of pkey */
+ || mpkey == 0x0000
+ /* user was smart enough to match */
+ || mpkey == (conf->p_prtn->pkey | cl_hton16(0x8000)))
+ return (TRUE);
+
+ OSM_LOG(conf->p_log, OSM_LOG_ERROR,
+ "IP MC group (%s) specified with invalid pkey 0x%04x "
+ "for partition pkey = 0x%04x (%s)\n",
+ inet_ntop(AF_INET6, group->mgid.raw, gid_str, sizeof gid_str),
+ cl_ntoh16(mpkey), cl_ntoh16(conf->p_prtn->pkey), conf->p_prtn->name);
+ return (FALSE);
+}
+
+static inline boolean_t ip_mgroup_rate_ok(struct part_conf *conf,
+ struct precreate_mgroup *group)
+{
+ char gid_str[INET6_ADDRSTRLEN];
+
+ if (group->flags.rate == conf->flags.rate)
+ return (TRUE);
+
+ OSM_LOG(conf->p_log, OSM_LOG_ERROR,
+ "IP MC group (%s) specified with invalid rate (%d): "
+ "partition pkey = 0x%04x (%s) "
+ "[Partition broadcast group rate = %d]\n",
+ inet_ntop(AF_INET6, group->mgid.raw, gid_str, sizeof gid_str),
+ group->flags.rate, cl_ntoh16(conf->p_prtn->pkey),
+ conf->p_prtn->name, conf->flags.rate);
+ return (FALSE);
+}
+
+static inline boolean_t ip_mgroup_mtu_ok(struct part_conf *conf,
+ struct precreate_mgroup *group)
+{
+ char gid_str[INET6_ADDRSTRLEN];
+
+ if (group->flags.mtu == conf->flags.mtu)
+ return (TRUE);
+
+ OSM_LOG(conf->p_log, OSM_LOG_ERROR,
+ "IP MC group (%s) specified with invalid mtu (%d): "
+ "partition pkey = 0x%04x (%s) "
+ "[Partition broadcast group mtu = %d]\n",
+ inet_ntop(AF_INET6, group->mgid.raw, gid_str, sizeof gid_str),
+ group->flags.mtu, cl_ntoh16(conf->p_prtn->pkey),
+ conf->p_prtn->name, conf->flags.mtu);
+ return (FALSE);
+}
+
+static void __create_mgrp(struct part_conf *conf, struct precreate_mgroup *group)
+{
+ unsigned int scope;
+
+ if (!group->flags.scope_mask) {
+ osm_prtn_add_mcgroup(conf->p_log, conf->p_subn, conf->p_prtn,
+ (uint8_t) group->flags.rate,
+ (uint8_t) group->flags.mtu,
+ group->flags.sl,
+ 0,
+ group->flags.Q_Key,
+ group->flags.TClass,
+ group->flags.FlowLabel,
+ &group->mgid);
+ } else {
+ for (scope = 0; scope < 16; scope++) {
+ if (((1<<scope) & group->flags.scope_mask) == 0)
+ continue;
+
+ osm_prtn_add_mcgroup(conf->p_log, conf->p_subn, conf->p_prtn,
+ (uint8_t)group->flags.rate,
+ (uint8_t)group->flags.mtu,
+ (uint8_t)group->flags.sl,
+ (uint8_t)scope,
+ group->flags.Q_Key,
+ group->flags.TClass,
+ group->flags.FlowLabel,
+ &group->mgid);
+ }
+ }
+}
+
+static int partition_create(unsigned lineno, struct part_conf *conf,
+ char *name, char *id, char *flag, char *flag_val)
+{
+ ib_net16_t pkey;
+
+ if (!id && name && isdigit(*name)) {
+ id = name;
+ name = NULL;
+ }
+
+ if (id) {
+ char *end;
+
+ pkey = cl_hton16((uint16_t)strtoul(id, &end, 0));
+ if (end == id || *end)
+ return -1;
+ } else
+ pkey = 0;
+
+ conf->p_prtn = osm_prtn_make_new(conf->p_log, conf->p_subn,
+ name, pkey);
+ if (!conf->p_prtn)
+ return -1;
+
+ if (!conf->p_subn->opt.qos && conf->flags.sl != OSM_DEFAULT_SL) {
+ OSM_LOG(conf->p_log, OSM_LOG_DEBUG, "Overriding SL %d"
+ " to default SL %d on partition %s"
+ " as QoS is not enabled.\n",
+ conf->flags.sl, OSM_DEFAULT_SL, name);
+ conf->flags.sl = OSM_DEFAULT_SL;
+ }
+ conf->p_prtn->sl = (uint8_t) conf->flags.sl;
+
+ if (conf->is_ipoib) {
+ struct precreate_mgroup broadcast_mgroup;
+ memset(&broadcast_mgroup, 0, sizeof(broadcast_mgroup));
+ broadcast_mgroup.mgid = osm_ipoib_broadcast_mgid;
+ pkey = CL_HTON16(0x8000) | conf->p_prtn->pkey;
+ memcpy(&broadcast_mgroup.mgid.raw[4], &pkey , sizeof(pkey));
+ broadcast_mgroup.flags.mtu = conf->flags.mtu;
+ broadcast_mgroup.flags.rate = conf->flags.rate;
+ broadcast_mgroup.flags.sl = conf->flags.sl;
+ broadcast_mgroup.flags.Q_Key = conf->flags.Q_Key ?
+ conf->flags.Q_Key :
+ OSM_IPOIB_BROADCAST_MGRP_QKEY;
+ broadcast_mgroup.flags.TClass = conf->flags.TClass;
+ broadcast_mgroup.flags.FlowLabel = conf->flags.FlowLabel;
+ __create_mgrp(conf, &broadcast_mgroup);
+ }
+
+ return 0;
+}
+
+/* returns 1 if processed 0 if _not_ */
+static int parse_group_flag(unsigned lineno, osm_log_t * p_log,
+ struct group_flags *flags,
+ char *flag, char *val)
+{
+ int rc = 0;
+ int len = strlen(flag);
+ if (!strncmp(flag, "mtu", len)) {
+ rc = 1;
+ if (!val || (flags->mtu = strtoul(val, NULL, 0)) == 0)
+ OSM_LOG(p_log, OSM_LOG_VERBOSE,
+ "PARSE WARN: line %d: "
+ "flag \'mtu\' requires valid value"
+ " - skipped\n", lineno);
+ } else if (!strncmp(flag, "rate", len)) {
+ rc = 1;
+ if (!val || (flags->rate = strtoul(val, NULL, 0)) == 0)
+ OSM_LOG(p_log, OSM_LOG_VERBOSE,
+ "PARSE WARN: line %d: "
+ "flag \'rate\' requires valid value"
+ " - skipped\n", lineno);
+ } else if (!strncmp(flag, "scope", len)) {
+ unsigned int scope;
+ rc = 1;
+ if (!val || (scope = strtoul(val, NULL, 0)) == 0 || scope > 0xF)
+ OSM_LOG(p_log, OSM_LOG_VERBOSE,
+ "PARSE WARN: line %d: "
+ "flag \'scope\' requires valid value"
+ " - skipped\n", lineno);
+ else
+ flags->scope_mask |= (1<<scope);
+ } else if (!strncmp(flag, "Q_Key", strlen(flag))) {
+ rc = 1;
+ if (!val || (flags->Q_Key = strtoul(val, NULL, 0)) == 0)
+ OSM_LOG(p_log, OSM_LOG_VERBOSE,
+ "PARSE WARN: line %d: "
+ "flag \'Q_Key\' requires valid value"
+ " - using '0'\n", lineno);
+ } else if (!strncmp(flag, "TClass", strlen(flag))) {
+ rc =1;
+ if (!val || (flags->TClass = strtoul(val, NULL, 0)) == 0)
+ OSM_LOG(p_log, OSM_LOG_VERBOSE,
+ "PARSE WARN: line %d: "
+ "flag \'TClass\' requires valid value"
+ " - using '0'\n", lineno);
+ } else if (!strncmp(flag, "sl", len)) {
+ unsigned sl;
+ char *end;
+ rc = 1;
+
+ if (!val || !*val || (sl = strtoul(val, &end, 0)) > 15 ||
+ (*end && !isspace(*end)))
+ OSM_LOG(p_log, OSM_LOG_VERBOSE,
+ "PARSE WARN: line %d: "
+ "flag \'sl\' requires valid value"
+ " - skipped\n", lineno);
+ else
+ flags->sl = sl;
+ } else if (!strncmp(flag, "FlowLabel", len)) {
+ uint32_t FlowLabel;
+ char *end;
+ rc = 1;
+
+ if (!val || !*val ||
+ (FlowLabel = strtoul(val, &end, 0)) > 0xFFFFF ||
+ (*end && !isspace(*end)))
+ OSM_LOG(p_log, OSM_LOG_VERBOSE,
+ "PARSE WARN: line %d: "
+ "flag \'FlowLabel\' requires valid value"
+ " - skipped\n", lineno);
+ else
+ flags->FlowLabel = FlowLabel;
+ }
+
+ return rc;
+}
+
+static int partition_add_flag(unsigned lineno, struct part_conf *conf,
+ char *flag, char *val)
+{
+ int len = strlen(flag);
+
+ /* ipoib gc group flags are processed here. */
+ if (parse_group_flag(lineno, conf->p_log, &conf->flags, flag, val))
+ return 0;
+
+ /* partition flags go here. */
+ if (!strncmp(flag, "ipoib", len)) {
+ conf->is_ipoib = 1;
+ } else if (!strncmp(flag, "defmember", len)) {
+ if (!val || (strncmp(val, "limited", strlen(val))
+ && strncmp(val, "both", strlen(val))
+ && strncmp(val, "full", strlen(val))))
+ OSM_LOG(conf->p_log, OSM_LOG_VERBOSE,
+ "PARSE WARN: line %d: "
+ "flag \'defmember\' requires valid value (limited or full or both)"
+ " - skipped\n", lineno);
+ else {
+ if (!strncmp(val, "full", strlen(val)))
+ conf->membership = FULL;
+ else if (!strncmp(val, "both", strlen(val)))
+ conf->membership = BOTH;
+ else
+ conf->membership = LIMITED;
+ }
+ } else if (!strcmp(flag, "indx0"))
+ conf->indx0 = TRUE;
+ else {
+ OSM_LOG(conf->p_log, OSM_LOG_VERBOSE,
+ "PARSE WARN: line %d: "
+ "unrecognized partition flag \'%s\'"
+ " - ignored\n", lineno, flag);
+ }
+ return 0;
+}
+static void manage_membership_change(struct part_conf *conf, osm_prtn_t * p,
+ unsigned type, membership_t membership,
+ ib_net64_t guid)
+{
+ cl_map_t *p_tbl;
+ cl_map_iterator_t p_next, p_item;
+ osm_physp_t *p_physp;
+
+ /* In allow_both_pkeys mode */
+ /* if membership of the PKEY is set to FULL */
+ /* need to clean up the part_guid_tbl table entry for this guid */
+ /* if membership of the PKEY is set to LIMITED */
+ /* need to clean up the full_guid_tbl table entry for this guid */
+ /* as it could be populated because of previous definitions */
+
+ if (!conf->p_subn->opt.allow_both_pkeys || membership == BOTH)
+ return;
+
+ switch (type){
+ /* ALL = 0 */
+ case 0:
+ cl_map_remove_all(membership == LIMITED ?
+ &p->full_guid_tbl : &p->part_guid_tbl);
+ break;
+ /* specific GUID */
+ case 0xFF:
+ cl_map_remove(membership == LIMITED ?
+ &p->full_guid_tbl : &p->part_guid_tbl,
+ cl_hton64(guid));
+ break;
+
+ case IB_NODE_TYPE_CA:
+ case IB_NODE_TYPE_SWITCH:
+ case IB_NODE_TYPE_ROUTER:
+ p_tbl = (membership == LIMITED) ?
+ &p->full_guid_tbl : &p->part_guid_tbl;
+
+ p_next = cl_map_head(p_tbl);
+ while (p_next != cl_map_end(p_tbl)) {
+ p_item = p_next;
+ p_next = cl_map_next(p_item);
+ p_physp = (osm_physp_t *) cl_map_obj(p_item);
+ if (osm_node_get_type(p_physp->p_node) == type)
+ cl_map_remove_item(p_tbl, p_item);
+ }
+ break;
+ default:
+ break;
+
+ }
+}
+static int partition_add_all(struct part_conf *conf, osm_prtn_t * p,
+ unsigned type, membership_t membership)
+{
+ manage_membership_change(conf, p, type, membership, 0);
+
+ if (membership != LIMITED &&
+ osm_prtn_add_all(conf->p_log, conf->p_subn, p, type, TRUE, conf->indx0) != IB_SUCCESS)
+ return -1;
+ if ((membership == LIMITED ||
+ (membership == BOTH && conf->p_subn->opt.allow_both_pkeys)) &&
+ osm_prtn_add_all(conf->p_log, conf->p_subn, p, type, FALSE, conf->indx0) != IB_SUCCESS)
+ return -1;
+ return 0;
+}
+
+static int partition_add_port(unsigned lineno, struct part_conf *conf,
+ char *name, char *flag)
+{
+ osm_prtn_t *p = conf->p_prtn;
+ ib_net64_t guid;
+ membership_t membership = conf->membership;
+
+ if (!name || !*name || !strncmp(name, "NONE", strlen(name)))
+ return 0;
+
+ if (flag) {
+ /* reset default membership to limited */
+ membership = LIMITED;
+ if (!strncmp(flag, "full", strlen(flag)))
+ membership = FULL;
+ else if (!strncmp(flag, "both", strlen(flag)))
+ membership = BOTH;
+ else if (strncmp(flag, "limited", strlen(flag))) {
+ OSM_LOG(conf->p_log, OSM_LOG_VERBOSE,
+ "PARSE WARN: line %d: "
+ "unrecognized port flag \'%s\'."
+ " Assume \'limited\'\n", lineno, flag);
+ }
+ }
+
+ if (!strncmp(name, "ALL", strlen(name)))
+ return partition_add_all(conf, p, 0, membership);
+ else if (!strncmp(name, "ALL_CAS", strlen(name)))
+ return partition_add_all(conf, p, IB_NODE_TYPE_CA, membership);
+ else if (!strncmp(name, "ALL_SWITCHES", strlen(name)))
+ return partition_add_all(conf, p, IB_NODE_TYPE_SWITCH,
+ membership);
+ else if (!strncmp(name, "ALL_ROUTERS", strlen(name)))
+ return partition_add_all(conf, p, IB_NODE_TYPE_ROUTER,
+ membership);
+ else if (!strncmp(name, "SELF", strlen(name))) {
+ guid = cl_ntoh64(conf->p_subn->sm_port_guid);
+ } else {
+ char *end;
+ guid = strtoull(name, &end, 0);
+ if (!guid || *end)
+ return -1;
+ }
+
+ manage_membership_change(conf, p, 0xFF, membership, guid);
+ if (membership != LIMITED &&
+ osm_prtn_add_port(conf->p_log, conf->p_subn, p,
+ cl_hton64(guid), TRUE, conf->indx0) != IB_SUCCESS)
+ return -1;
+ if ((membership == LIMITED ||
+ (membership == BOTH && conf->p_subn->opt.allow_both_pkeys)) &&
+ osm_prtn_add_port(conf->p_log, conf->p_subn, p,
+ cl_hton64(guid), FALSE, conf->indx0) != IB_SUCCESS)
+ return -1;
+ return 0;
+}
+
+/* conf file parser */
+
+#define STRIP_HEAD_SPACES(p) while (*(p) == ' ' || *(p) == '\t' || \
+ *(p) == '\n') { (p)++; }
+#define STRIP_TAIL_SPACES(p) { char *q = (p) + strlen(p); \
+ while ( q != (p) && ( *q == '\0' || \
+ *q == ' ' || *q == '\t' || \
+ *q == '\n')) { *q-- = '\0'; }; }
+
+static int parse_name_token(char *str, char **name, char **val)
+{
+ int len = 0;
+ char *p, *q;
+
+ *name = *val = NULL;
+
+ p = str;
+
+ while (*p == ' ' || *p == '\t' || *p == '\n')
+ p++;
+
+ q = strchr(p, '=');
+ if (q)
+ *q++ = '\0';
+
+ len = strlen(str) + 1;
+ str = q;
+
+ q = p + strlen(p);
+ while (q != p && (*q == '\0' || *q == ' ' || *q == '\t' || *q == '\n'))
+ *q-- = '\0';
+
+ *name = p;
+
+ p = str;
+ if (!p)
+ return len;
+
+ while (*p == ' ' || *p == '\t' || *p == '\n')
+ p++;
+
+ q = p + strlen(p);
+ len += (int)(q - str) + 1;
+ while (q != p && (*q == '\0' || *q == ' ' || *q == '\t' || *q == '\n'))
+ *q-- = '\0';
+ *val = p;
+
+ return len;
+}
+
+static int parse_mgroup_flags(osm_log_t * p_log,
+ struct precreate_mgroup *mgroup,
+ char *p, unsigned lineno)
+{
+ int ret, len = 0;
+ char *flag, *val, *q;
+ do {
+ flag = val = NULL;
+ q = strchr(p, ',');
+ if (q)
+ *q++ = '\0';
+
+ ret = parse_name_token(p, &flag, &val);
+
+ if (!parse_group_flag(lineno, p_log, &mgroup->flags,
+ flag, val)) {
+ OSM_LOG(p_log, OSM_LOG_VERBOSE,
+ "PARSE WARN: line %d: "
+ "unrecognized mgroup flag \'%s\'"
+ " - ignored\n", lineno, flag);
+ }
+ p += ret;
+ len += ret;
+ } while (q);
+
+ return (len);
+}
+
+static int mgroup_create(char *p, char *mgid, unsigned lineno, struct part_conf *conf)
+{
+ int ret = 0;
+ struct precreate_mgroup mgroup;
+
+ memset(&mgroup, 0, sizeof(mgroup));
+
+ if (inet_pton(AF_INET6, mgid, &mgroup.mgid) != 1
+ || mgroup.mgid.raw[0] != 0xff) {
+ OSM_LOG(conf->p_log, OSM_LOG_ERROR,
+ "PARSE ERROR partition conf file line %d: "
+ "mgid \"%s\": gid is not multicast\n", lineno, mgid);
+ return 0;
+ }
+
+ /* inherit partition flags */
+ mgroup.flags.mtu = conf->flags.mtu;
+ mgroup.flags.rate = conf->flags.rate;
+ mgroup.flags.sl = conf->flags.sl;
+ mgroup.flags.Q_Key = conf->flags.Q_Key;
+ mgroup.flags.FlowLabel = conf->flags.FlowLabel;
+ mgroup.flags.scope_mask = conf->flags.scope_mask;
+
+ /* override with user specified flags */
+ ret = parse_mgroup_flags(conf->p_log, &mgroup, p, lineno);
+
+ /* check/verify special IP group parameters */
+ if (mgid_is_ip(&mgroup.mgid)) {
+ ib_net16_t pkey = conf->p_prtn->pkey | cl_hton16(0x8000);
+
+ if (!ip_mgroup_pkey_ok(conf, &mgroup)
+ || !ip_mgroup_rate_ok(conf, &mgroup)
+ || !ip_mgroup_mtu_ok(conf, &mgroup))
+ goto error;
+
+ /* set special IP settings */
+ memcpy(&mgroup.mgid.raw[4], &pkey, sizeof(pkey));
+
+ if (mgroup.flags.Q_Key == 0)
+ mgroup.flags.Q_Key = OSM_IPOIB_BROADCAST_MGRP_QKEY;
+ }
+
+ /* don't create multiple copies of the group */
+ if (osm_get_mgrp_by_mgid(conf->p_subn, &mgroup.mgid))
+ goto error;
+
+ /* create the group */
+ __create_mgrp(conf, &mgroup);
+
+error:
+ return ret;
+}
+
+static struct part_conf *new_part_conf(osm_log_t * p_log, osm_subn_t * p_subn)
+{
+ static struct part_conf part;
+ struct part_conf *conf = &part;
+
+ memset(conf, 0, sizeof(*conf));
+ conf->p_log = p_log;
+ conf->p_subn = p_subn;
+ conf->p_prtn = NULL;
+ conf->is_ipoib = 0;
+ conf->flags.sl = OSM_DEFAULT_SL;
+ conf->flags.rate = OSM_DEFAULT_MGRP_RATE;
+ conf->flags.mtu = OSM_DEFAULT_MGRP_MTU;
+ conf->membership = LIMITED;
+ conf->indx0 = FALSE;
+ return conf;
+}
+
+static int flush_part_conf(struct part_conf *conf)
+{
+ memset(conf, 0, sizeof(*conf));
+ return 0;
+}
+
+static int parse_part_conf(struct part_conf *conf, char *str, int lineno)
+{
+ int ret, len = 0;
+ char *name, *id, *flag, *flval;
+ char *q, *p;
+
+ p = str;
+ if (*p == '\t' || *p == '\0' || *p == '\n')
+ p++;
+
+ len += (int)(p - str);
+ str = p;
+
+ if (conf->p_prtn)
+ goto skip_header;
+
+ q = strchr(p, ':');
+ if (!q) {
+ OSM_LOG(conf->p_log, OSM_LOG_ERROR, "PARSE ERROR: line %d: "
+ "no partition definition found\n", lineno);
+ fprintf(stderr, "\nPARSE ERROR: line %d: "
+ "no partition definition found\n", lineno);
+ return -1;
+ }
+
+ *q++ = '\0';
+ str = q;
+
+ name = id = flag = flval = NULL;
+
+ q = strchr(p, ',');
+ if (q)
+ *q = '\0';
+
+ ret = parse_name_token(p, &name, &id);
+ p += ret;
+ len += ret;
+
+ while (q) {
+ flag = flval = NULL;
+ q = strchr(p, ',');
+ if (q)
+ *q++ = '\0';
+ ret = parse_name_token(p, &flag, &flval);
+ if (!flag) {
+ OSM_LOG(conf->p_log, OSM_LOG_ERROR,
+ "PARSE ERROR: line %d: "
+ "bad partition flags\n", lineno);
+ fprintf(stderr, "\nPARSE ERROR: line %d: "
+ "bad partition flags\n", lineno);
+ return -1;
+ }
+ p += ret;
+ len += ret;
+ partition_add_flag(lineno, conf, flag, flval);
+ }
+
+ if (p != str || (partition_create(lineno, conf,
+ name, id, flag, flval) < 0)) {
+ OSM_LOG(conf->p_log, OSM_LOG_ERROR, "PARSE ERROR: line %d: "
+ "bad partition definition\n", lineno);
+ fprintf(stderr, "\nPARSE ERROR: line %d: "
+ "bad partition definition\n", lineno);
+ return -1;
+ }
+
+skip_header:
+ do {
+ name = flag = NULL;
+ q = strchr(p, ',');
+ if (q)
+ *q++ = '\0';
+ ret = parse_name_token(p, &name, &flag);
+ len += ret;
+
+ if (strcmp(name, "mgid") == 0) {
+ /* parse an mgid line if specified. */
+ len += mgroup_create(p+ret, flag, lineno, conf);
+ goto done; /* We're done: this consumes the line */
+ }
+ if (partition_add_port(lineno, conf, name, flag) < 0) {
+ OSM_LOG(conf->p_log, OSM_LOG_ERROR,
+ "PARSE ERROR: line %d: "
+ "bad PortGUID\n", lineno);
+ fprintf(stderr, "PARSE ERROR: line %d: "
+ "bad PortGUID\n", lineno);
+ return -1;
+ }
+ p += ret;
+ } while (q);
+
+done:
+ return len;
+}
+
+/**
+ * @return 1 on error, 0 on success
+ */
+int osm_prtn_config_parse_file(osm_log_t * p_log, osm_subn_t * p_subn,
+ const char *file_name)
+{
+ char line[4096];
+ struct part_conf *conf = NULL;
+ FILE *file;
+ int lineno;
+ int is_parse_success;
+
+ line[0] = '\0';
+ file = fopen(file_name, "r");
+ if (!file) {
+ OSM_LOG(p_log, OSM_LOG_VERBOSE,
+ "Cannot open config file \'%s\': %s\n",
+ file_name, strerror(errno));
+ return -1;
+ }
+
+ lineno = 0;
+
+ is_parse_success = 0;
+
+ while (fgets(line, sizeof(line) - 1, file) != NULL) {
+ char *q, *p = line;
+
+ lineno++;
+
+ p = line;
+
+ q = strchr(p, '#');
+ if (q)
+ *q = '\0';
+
+ do {
+ int len;
+ while (*p == ' ' || *p == '\t' || *p == '\n')
+ p++;
+ if (*p == '\0')
+ break;
+
+ if (!conf && !(conf = new_part_conf(p_log, p_subn))) {
+ OSM_LOG(p_log, OSM_LOG_ERROR,
+ "PARSE ERROR: line %d: "
+ "internal: cannot create config\n",
+ lineno);
+ fprintf(stderr,
+ "PARSE ERROR: line %d: "
+ "internal: cannot create config\n",
+ lineno);
+ is_parse_success = -1;
+ break;
+ }
+
+ q = strchr(p, ';');
+ if (q)
+ *q = '\0';
+
+ len = parse_part_conf(conf, p, lineno);
+ if (len < 0) {
+ is_parse_success = -1;
+ break;
+ }
+
+ is_parse_success = 1;
+
+ p += len;
+
+ if (q) {
+ flush_part_conf(conf);
+ conf = NULL;
+ }
+ } while (q);
+
+ if (is_parse_success == -1)
+ break;
+ }
+
+ fclose(file);
+
+ return (is_parse_success == 1) ? 0 : 1;
+}
diff --git a/contrib/ofed/opensm/opensm/osm_qos.c b/contrib/ofed/opensm/opensm/osm_qos.c
new file mode 100644
index 0000000..b4f6041
--- /dev/null
+++ b/contrib/ofed/opensm/opensm/osm_qos.c
@@ -0,0 +1,661 @@
+/*
+ * Copyright (c) 2006-2009 Voltaire, Inc. All rights reserved.
+ * Copyright (c) 2010-2015 Mellanox Technologies LTD. All rights reserved.
+ * Copyright (c) 2009 HNR Consulting. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+/*
+ * Abstract:
+ * Implementation of OpenSM QoS infrastructure primitives
+ */
+
+#if HAVE_CONFIG_H
+# include <config.h>
+#endif /* HAVE_CONFIG_H */
+
+#include <stdlib.h>
+#include <string.h>
+
+#include <iba/ib_types.h>
+#include <complib/cl_qmap.h>
+#include <complib/cl_debug.h>
+#include <opensm/osm_file_ids.h>
+#define FILE_ID OSM_FILE_QOS_C
+#include <opensm/osm_opensm.h>
+#include <opensm/osm_subnet.h>
+#include <opensm/osm_qos_policy.h>
+
+struct qos_config {
+ uint8_t max_vls;
+ uint8_t vl_high_limit;
+ ib_vl_arb_table_t vlarb_high[2];
+ ib_vl_arb_table_t vlarb_low[2];
+ ib_slvl_table_t sl2vl;
+};
+
+typedef struct qos_mad_item {
+ cl_list_item_t list_item;
+ osm_madw_t *p_madw;
+} qos_mad_item_t;
+
+typedef struct qos_mad_list {
+ cl_list_item_t list_item;
+ cl_qlist_t port_mad_list;
+} qos_mad_list_t;
+
+static void qos_build_config(struct qos_config *cfg,
+ osm_qos_options_t * opt,
+ osm_qos_options_t * dflt);
+
+/*
+ * QoS primitives
+ */
+
+static qos_mad_item_t *osm_qos_mad_create(IN osm_sm_t * sm,
+ IN osm_physp_t * p,
+ IN uint32_t data_size,
+ IN uint8_t * p_data,
+ IN ib_net16_t attr_id,
+ IN uint32_t attr_mod)
+
+{
+ qos_mad_item_t *p_mad;
+ osm_madw_context_t context;
+ osm_madw_t *p_madw;
+ osm_node_t *p_node;
+ osm_physp_t *physp0;
+ ib_net64_t m_key;
+
+ p_node = osm_physp_get_node_ptr(p);
+ if (osm_node_get_type(p_node) == IB_NODE_TYPE_SWITCH &&
+ osm_physp_get_port_num(p) != 0) {
+ physp0 = osm_node_get_physp_ptr(p_node, 0);
+ m_key = ib_port_info_get_m_key(&physp0->port_info);
+ } else
+ m_key = ib_port_info_get_m_key(&p->port_info);
+
+ switch (attr_id){
+ case IB_MAD_ATTR_SLVL_TABLE:
+ context.slvl_context.node_guid = osm_node_get_node_guid(p_node);
+ context.slvl_context.port_guid = osm_physp_get_port_guid(p);
+ context.slvl_context.set_method = TRUE;
+ break;
+ case IB_MAD_ATTR_VL_ARBITRATION:
+ context.vla_context.node_guid = osm_node_get_node_guid(p_node);
+ context.vla_context.port_guid = osm_physp_get_port_guid(p);
+ context.vla_context.set_method = TRUE;
+ break;
+ default:
+ return NULL;
+ }
+
+ p_mad = (qos_mad_item_t *) malloc(sizeof(*p_mad));
+ if (!p_mad)
+ return NULL;
+
+ memset(p_mad, 0, sizeof(*p_mad));
+
+ p_madw = osm_prepare_req_set(sm, osm_physp_get_dr_path_ptr(p),
+ p_data, data_size,
+ attr_id, cl_hton32(attr_mod),
+ FALSE, m_key,
+ CL_DISP_MSGID_NONE, &context);
+
+ if (p_madw == NULL) {
+ free(p_mad);
+ return NULL;
+ }
+ p_mad->p_madw = p_madw;
+ return p_mad;
+}
+
+static void osm_qos_mad_delete(qos_mad_item_t ** p_item)
+{
+ free(*p_item);
+ *p_item = NULL;
+}
+
+static ib_api_status_t vlarb_update_table_block(osm_sm_t * sm,
+ osm_physp_t * p,
+ uint8_t port_num,
+ unsigned force_update,
+ const ib_vl_arb_table_t *
+ table_block,
+ unsigned block_length,
+ unsigned block_num,
+ cl_qlist_t *mad_list)
+{
+ struct osm_routing_engine *re = sm->p_subn->p_osm->routing_engine_used;
+ ib_vl_arb_table_t block;
+ uint32_t attr_mod;
+ unsigned vl_mask, i;
+ qos_mad_item_t *p_mad;
+ vl_mask = (1 << (ib_port_info_get_op_vls(&p->port_info) - 1)) - 1;
+
+ memset(&block, 0, sizeof(block));
+ memcpy(&block, table_block, block_length * sizeof(block.vl_entry[0]));
+
+ if (re && re->update_vlarb)
+ re->update_vlarb(re->context, p, port_num, &block,
+ block_length, block_num);
+
+ for (i = 0; i < block_length; i++)
+ block.vl_entry[i].vl &= vl_mask;
+
+ if (!force_update &&
+ !memcmp(&p->vl_arb[block_num], &block,
+ block_length * sizeof(block.vl_entry[0])))
+ return IB_SUCCESS;
+
+ attr_mod = ((block_num + 1) << 16) | port_num;
+
+ p_mad = osm_qos_mad_create(sm,p,sizeof(block),(uint8_t *) & block,
+ IB_MAD_ATTR_VL_ARBITRATION, attr_mod);
+
+ if (!p_mad)
+ return IB_INSUFFICIENT_MEMORY;
+
+ /*
+ * Zero the stored VL Arbitration block, so in case the MAD will
+ * end up with error, we will resend it in the next sweep.
+ */
+ memset(&p->vl_arb[block_num], 0,
+ block_length * sizeof(block.vl_entry[0]));
+
+ cl_qlist_insert_tail(mad_list, &p_mad->list_item);
+
+ return IB_SUCCESS;
+}
+
+static ib_api_status_t vlarb_update(osm_sm_t * sm, osm_physp_t * p,
+ uint8_t port_num, unsigned force_update,
+ const struct qos_config *qcfg,
+ cl_qlist_t *mad_list)
+{
+ ib_api_status_t status = IB_SUCCESS;
+ ib_port_info_t *p_pi = &p->port_info;
+ unsigned len;
+
+ if (p_pi->vl_arb_low_cap > 0) {
+ len = p_pi->vl_arb_low_cap < IB_NUM_VL_ARB_ELEMENTS_IN_BLOCK ?
+ p_pi->vl_arb_low_cap : IB_NUM_VL_ARB_ELEMENTS_IN_BLOCK;
+ if ((status = vlarb_update_table_block(sm, p, port_num,
+ force_update,
+ &qcfg->vlarb_low[0],
+ len, 0,
+ mad_list)) != IB_SUCCESS)
+ return status;
+ }
+ if (p_pi->vl_arb_low_cap > IB_NUM_VL_ARB_ELEMENTS_IN_BLOCK) {
+ len = p_pi->vl_arb_low_cap % IB_NUM_VL_ARB_ELEMENTS_IN_BLOCK;
+ if ((status = vlarb_update_table_block(sm, p, port_num,
+ force_update,
+ &qcfg->vlarb_low[1],
+ len, 1,
+ mad_list)) != IB_SUCCESS)
+ return status;
+ }
+ if (p_pi->vl_arb_high_cap > 0) {
+ len = p_pi->vl_arb_high_cap < IB_NUM_VL_ARB_ELEMENTS_IN_BLOCK ?
+ p_pi->vl_arb_high_cap : IB_NUM_VL_ARB_ELEMENTS_IN_BLOCK;
+ if ((status = vlarb_update_table_block(sm, p, port_num,
+ force_update,
+ &qcfg->vlarb_high[0],
+ len, 2,
+ mad_list)) != IB_SUCCESS)
+ return status;
+ }
+ if (p_pi->vl_arb_high_cap > IB_NUM_VL_ARB_ELEMENTS_IN_BLOCK) {
+ len = p_pi->vl_arb_high_cap % IB_NUM_VL_ARB_ELEMENTS_IN_BLOCK;
+ if ((status = vlarb_update_table_block(sm, p, port_num,
+ force_update,
+ &qcfg->vlarb_high[1],
+ len, 3,
+ mad_list)) != IB_SUCCESS)
+ return status;
+ }
+
+ return status;
+}
+
+static ib_api_status_t sl2vl_update_table(osm_sm_t * sm, osm_physp_t * p,
+ uint8_t in_port, uint32_t attr_mod,
+ unsigned force_update,
+ const ib_slvl_table_t * sl2vl_table,
+ cl_qlist_t *mad_list)
+{
+ ib_slvl_table_t tbl, *p_tbl;
+ unsigned vl_mask;
+ uint8_t vl1, vl2;
+ int i;
+ qos_mad_item_t *p_mad;
+
+ vl_mask = (1 << (ib_port_info_get_op_vls(&p->port_info) - 1)) - 1;
+
+ for (i = 0; i < IB_MAX_NUM_VLS / 2; i++) {
+ vl1 = sl2vl_table->raw_vl_by_sl[i] >> 4;
+ vl2 = sl2vl_table->raw_vl_by_sl[i] & 0xf;
+ if (vl1 != 15)
+ vl1 &= vl_mask;
+ if (vl2 != 15)
+ vl2 &= vl_mask;
+ tbl.raw_vl_by_sl[i] = (vl1 << 4) | vl2;
+ }
+
+ p_tbl = osm_physp_get_slvl_tbl(p, in_port);
+
+ if (!force_update && !memcmp(p_tbl, &tbl, sizeof(tbl)))
+ return IB_SUCCESS;
+
+ p_mad = osm_qos_mad_create(sm, p, sizeof(tbl), (uint8_t *) & tbl,
+ IB_MAD_ATTR_SLVL_TABLE, attr_mod);
+ if (!p_mad)
+ return IB_INSUFFICIENT_MEMORY;
+
+ /*
+ * Zero the stored SL2VL block, so in case the MAD will
+ * end up with error, we will resend it in the next sweep.
+ */
+ memset(p_tbl, 0, sizeof(tbl));
+
+ cl_qlist_insert_tail(mad_list, &p_mad->list_item);
+ return IB_SUCCESS;
+}
+
+static int qos_extports_setup(osm_sm_t * sm, osm_node_t *node,
+ const struct qos_config *qcfg,
+ cl_qlist_t *port_mad_list)
+
+{
+ osm_physp_t *p0, *p;
+ unsigned force_update;
+ unsigned num_ports = osm_node_get_num_physp(node);
+ struct osm_routing_engine *re = sm->p_subn->p_osm->routing_engine_used;
+ int ret = 0;
+ unsigned in, out;
+ uint8_t op_vl, common_op_vl = 0, max_num = 0;
+ uint8_t op_vl_arr[15];
+
+ /*
+ * Do nothing unless the most recent routing attempt was successful.
+ */
+ if (!re)
+ return ret;
+
+ for (out = 1; out < num_ports; out++) {
+ p = osm_node_get_physp_ptr(node, out);
+ if (!p)
+ continue;
+ if (ib_port_info_get_port_state(&p->port_info) == IB_LINK_DOWN)
+ continue;
+ force_update = p->need_update || sm->p_subn->need_update;
+ p->vl_high_limit = qcfg->vl_high_limit;
+ if (vlarb_update(sm, p, p->port_num, force_update, qcfg,
+ port_mad_list))
+ ret = -1;
+ }
+
+ p0 = osm_node_get_physp_ptr(node, 0);
+ if (!(p0->port_info.capability_mask & IB_PORT_CAP_HAS_SL_MAP))
+ return ret;
+
+ if (ib_switch_info_get_opt_sl2vlmapping(&node->sw->switch_info) &&
+ sm->p_subn->opt.use_optimized_slvl && !re->update_sl2vl) {
+
+ /* we should find the op_vl that is used by majority of ports */
+ memset(&op_vl_arr[0], 0, sizeof(op_vl_arr));
+ p0 = osm_node_get_physp_ptr(node, 1);
+
+ for (out = 1; out < num_ports; out++) {
+ p = osm_node_get_physp_ptr(node, out);
+ if (!p)
+ continue;
+ if (ib_port_info_get_port_state(&p->port_info) ==
+ IB_LINK_DOWN)
+ continue;
+ op_vl = ib_port_info_get_op_vls(&p->port_info);
+ op_vl_arr[op_vl]++;
+ if (op_vl_arr[op_vl] > max_num){
+ max_num = op_vl_arr[op_vl];
+ common_op_vl = op_vl;
+ /* remember the port with most common op_vl */
+ p0 = p;
+ }
+
+ }
+ if (!p0)
+ return -1;
+ force_update = node->sw->need_update || sm->p_subn->need_update;
+ if (sl2vl_update_table(sm, p0, p0->port_num, 0x30000, force_update,
+ &qcfg->sl2vl, port_mad_list))
+ ret = -1;
+ /*
+ * Overwrite default ALL configuration if port's
+ * op_vl is different.
+ */
+ for (out = 1; out < num_ports; out++) {
+ p = osm_node_get_physp_ptr(node, out);
+ if (!p)
+ continue;
+ if (ib_port_info_get_port_state(&p->port_info) ==
+ IB_LINK_DOWN)
+ continue;
+
+ force_update = p->need_update || force_update;
+ if (ib_port_info_get_op_vls(&p->port_info) !=
+ common_op_vl &&
+ sl2vl_update_table(sm, p, p->port_num, 0x20000 | out,
+ force_update, &qcfg->sl2vl,
+ port_mad_list))
+ ret = -1;
+ }
+ return ret;
+ }
+
+ /* non optimized sl2vl configuration */
+ out = ib_switch_info_is_enhanced_port0(&node->sw->switch_info) ? 0 : 1;
+ for (; out < num_ports; out++) {
+ p = osm_node_get_physp_ptr(node, out);
+ if (!p)
+ continue;
+ if (ib_port_info_get_port_state(&p->port_info) == IB_LINK_DOWN)
+ continue;
+ force_update = p->need_update || sm->p_subn->need_update;
+ /* go over all in ports */
+ for (in = 0; in < num_ports; in++) {
+ const ib_slvl_table_t *port_sl2vl = &qcfg->sl2vl;
+ ib_slvl_table_t routing_sl2vl;
+
+ if (re->update_sl2vl) {
+ routing_sl2vl = *port_sl2vl;
+ re->update_sl2vl(re->context,
+ p, in, out, &routing_sl2vl);
+ port_sl2vl = &routing_sl2vl;
+ }
+ if (sl2vl_update_table(sm, p, in, in << 8 | out,
+ force_update, port_sl2vl,
+ port_mad_list))
+ ret = -1;
+ }
+ }
+
+ return ret;
+}
+
+static int qos_endport_setup(osm_sm_t * sm, osm_physp_t * p,
+ const struct qos_config *qcfg, int vlarb_only,
+ cl_qlist_t *port_mad_list)
+{
+ unsigned force_update = p->need_update || sm->p_subn->need_update;
+ struct osm_routing_engine *re = sm->p_subn->p_osm->routing_engine_used;
+ const ib_slvl_table_t *port_sl2vl = &qcfg->sl2vl;
+ ib_slvl_table_t routing_sl2vl;
+
+ p->vl_high_limit = qcfg->vl_high_limit;
+ if (vlarb_update(sm, p, 0, force_update, qcfg, port_mad_list))
+ return -1;
+ if (vlarb_only)
+ return 0;
+
+ if (!(p->port_info.capability_mask & IB_PORT_CAP_HAS_SL_MAP))
+ return 0;
+
+ if (re && re->update_sl2vl) {
+ routing_sl2vl = *port_sl2vl;
+ re->update_sl2vl(re->context, p, 0, 0, &routing_sl2vl);
+ port_sl2vl = &routing_sl2vl;
+ }
+ if (sl2vl_update_table(sm, p, 0, 0, force_update, port_sl2vl,
+ port_mad_list))
+ return -1;
+
+ return 0;
+}
+
+int osm_qos_setup(osm_opensm_t * p_osm)
+{
+ struct qos_config ca_config, sw0_config, swe_config, rtr_config;
+ struct qos_config *cfg;
+ cl_qmap_t *p_tbl;
+ cl_map_item_t *p_next;
+ osm_port_t *p_port;
+ osm_node_t *p_node;
+ int ret = 0;
+ int vlarb_only;
+ qos_mad_list_t *p_list, *p_list_next;
+ qos_mad_item_t *p_port_mad;
+ cl_qlist_t qos_mad_list;
+
+ if (!p_osm->subn.opt.qos)
+ return 0;
+
+ OSM_LOG_ENTER(&p_osm->log);
+
+ qos_build_config(&ca_config, &p_osm->subn.opt.qos_ca_options,
+ &p_osm->subn.opt.qos_options);
+ qos_build_config(&sw0_config, &p_osm->subn.opt.qos_sw0_options,
+ &p_osm->subn.opt.qos_options);
+ qos_build_config(&swe_config, &p_osm->subn.opt.qos_swe_options,
+ &p_osm->subn.opt.qos_options);
+ qos_build_config(&rtr_config, &p_osm->subn.opt.qos_rtr_options,
+ &p_osm->subn.opt.qos_options);
+
+ cl_qlist_init(&qos_mad_list);
+
+ cl_plock_excl_acquire(&p_osm->lock);
+
+ /* read QoS policy config file */
+ osm_qos_parse_policy_file(&p_osm->subn);
+ p_tbl = &p_osm->subn.port_guid_tbl;
+ p_next = cl_qmap_head(p_tbl);
+ while (p_next != cl_qmap_end(p_tbl)) {
+ vlarb_only = 0;
+ p_port = (osm_port_t *) p_next;
+ p_next = cl_qmap_next(p_next);
+
+ p_list = (qos_mad_list_t *) malloc(sizeof(*p_list));
+ if (!p_list) {
+ cl_plock_release(&p_osm->lock);
+ return -1;
+ }
+
+ memset(p_list, 0, sizeof(*p_list));
+
+ cl_qlist_init(&p_list->port_mad_list);
+
+ p_node = p_port->p_node;
+ if (p_node->sw) {
+ if (qos_extports_setup(&p_osm->sm, p_node, &swe_config,
+ &p_list->port_mad_list)) {
+ cl_plock_release(&p_osm->lock);
+ ret = -1;
+ }
+
+ /* skip base port 0 */
+ if (!ib_switch_info_is_enhanced_port0
+ (&p_node->sw->switch_info))
+ goto Continue;
+
+ if (ib_switch_info_get_opt_sl2vlmapping(&p_node->sw->switch_info) &&
+ p_osm->sm.p_subn->opt.use_optimized_slvl &&
+ !memcmp(&swe_config.sl2vl, &sw0_config.sl2vl,
+ sizeof(swe_config.sl2vl)))
+ vlarb_only = 1;
+
+ cfg = &sw0_config;
+ } else if (osm_node_get_type(p_node) == IB_NODE_TYPE_ROUTER)
+ cfg = &rtr_config;
+ else
+ cfg = &ca_config;
+
+ if (qos_endport_setup(&p_osm->sm, p_port->p_physp, cfg,
+ vlarb_only, &p_list->port_mad_list)) {
+ cl_plock_release(&p_osm->lock);
+ ret = -1;
+ }
+Continue:
+ /* if MAD list is not empty, add it to the global MAD list */
+ if (cl_qlist_count(&p_list->port_mad_list)) {
+ cl_qlist_insert_tail(&qos_mad_list, &p_list->list_item);
+ } else {
+ free(p_list);
+ }
+ }
+ while (cl_qlist_count(&qos_mad_list)) {
+ p_list_next = (qos_mad_list_t *) cl_qlist_head(&qos_mad_list);
+ while (p_list_next !=
+ (qos_mad_list_t *) cl_qlist_end(&qos_mad_list)) {
+ p_list = p_list_next;
+ p_list_next = (qos_mad_list_t *)
+ cl_qlist_next(&p_list->list_item);
+ /* next MAD to send*/
+ p_port_mad = (qos_mad_item_t *)
+ cl_qlist_remove_head(&p_list->port_mad_list);
+ osm_send_req_mad(&p_osm->sm, p_port_mad->p_madw);
+ osm_qos_mad_delete(&p_port_mad);
+ /* remove the QoS MAD from global MAD list */
+ if (cl_qlist_count(&p_list->port_mad_list) == 0) {
+ cl_qlist_remove_item(&qos_mad_list, &p_list->list_item);
+ free(p_list);
+ }
+ }
+ }
+
+ cl_plock_release(&p_osm->lock);
+ OSM_LOG_EXIT(&p_osm->log);
+
+ return ret;
+}
+
+/*
+ * QoS config stuff
+ */
+static int parse_one_unsigned(const char *str, char delim, unsigned *val)
+{
+ char *end;
+ *val = strtoul(str, &end, 0);
+ if (*end)
+ end++;
+ return (int)(end - str);
+}
+
+static int parse_vlarb_entry(const char *str, ib_vl_arb_element_t * e)
+{
+ unsigned val;
+ const char *p = str;
+ p += parse_one_unsigned(p, ':', &val);
+ e->vl = val % 15;
+ p += parse_one_unsigned(p, ',', &val);
+ e->weight = (uint8_t) val;
+ return (int)(p - str);
+}
+
+static int parse_sl2vl_entry(const char *str, uint8_t * raw)
+{
+ unsigned val1, val2;
+ const char *p = str;
+ p += parse_one_unsigned(p, ',', &val1);
+ p += parse_one_unsigned(p, ',', &val2);
+ *raw = (val1 << 4) | (val2 & 0xf);
+ return (int)(p - str);
+}
+
+static void qos_build_config(struct qos_config *cfg, osm_qos_options_t * opt,
+ osm_qos_options_t * dflt)
+{
+ int i;
+ const char *p;
+
+ memset(cfg, 0, sizeof(*cfg));
+
+ if (opt->max_vls > 0)
+ cfg->max_vls = opt->max_vls;
+ else {
+ if (dflt->max_vls > 0)
+ cfg->max_vls = dflt->max_vls;
+ else
+ cfg->max_vls = OSM_DEFAULT_QOS_MAX_VLS;
+ }
+
+ if (opt->high_limit >= 0)
+ cfg->vl_high_limit = (uint8_t) opt->high_limit;
+ else {
+ if (dflt->high_limit >= 0)
+ cfg->vl_high_limit = (uint8_t) dflt->high_limit;
+ else
+ cfg->vl_high_limit = (uint8_t) OSM_DEFAULT_QOS_HIGH_LIMIT;
+ }
+
+ if (opt->vlarb_high)
+ p = opt->vlarb_high;
+ else {
+ if (dflt->vlarb_high)
+ p = dflt->vlarb_high;
+ else
+ p = OSM_DEFAULT_QOS_VLARB_HIGH;
+ }
+ for (i = 0; i < 2 * IB_NUM_VL_ARB_ELEMENTS_IN_BLOCK; i++) {
+ p += parse_vlarb_entry(p,
+ &cfg->vlarb_high[i /
+ IB_NUM_VL_ARB_ELEMENTS_IN_BLOCK].
+ vl_entry[i %
+ IB_NUM_VL_ARB_ELEMENTS_IN_BLOCK]);
+ }
+
+ if (opt->vlarb_low)
+ p = opt->vlarb_low;
+ else {
+ if (dflt->vlarb_low)
+ p = dflt->vlarb_low;
+ else
+ p = OSM_DEFAULT_QOS_VLARB_LOW;
+ }
+ for (i = 0; i < 2 * IB_NUM_VL_ARB_ELEMENTS_IN_BLOCK; i++) {
+ p += parse_vlarb_entry(p,
+ &cfg->vlarb_low[i /
+ IB_NUM_VL_ARB_ELEMENTS_IN_BLOCK].
+ vl_entry[i %
+ IB_NUM_VL_ARB_ELEMENTS_IN_BLOCK]);
+ }
+
+ p = opt->sl2vl ? opt->sl2vl : dflt->sl2vl;
+ if (opt->sl2vl)
+ p = opt->sl2vl;
+ else {
+ if (dflt->sl2vl)
+ p = dflt->sl2vl;
+ else
+ p = OSM_DEFAULT_QOS_SL2VL;
+ }
+ for (i = 0; i < IB_MAX_NUM_VLS / 2; i++)
+ p += parse_sl2vl_entry(p, &cfg->sl2vl.raw_vl_by_sl[i]);
+}
diff --git a/contrib/ofed/opensm/opensm/osm_qos_parser_l.l b/contrib/ofed/opensm/opensm/osm_qos_parser_l.l
new file mode 100644
index 0000000..6054397
--- /dev/null
+++ b/contrib/ofed/opensm/opensm/osm_qos_parser_l.l
@@ -0,0 +1,404 @@
+%{
+/*
+ * Copyright (c) 2004-2006 Voltaire, Inc. All rights reserved.
+ * Copyright (c) 2002-2008 Mellanox Technologies LTD. All rights reserved.
+ * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+/*
+ * Abstract:
+ * Lexer of OSM QoS parser.
+ *
+ * Environment:
+ * Linux User Mode
+ *
+ * Author:
+ * Yevgeny Kliteynik, Mellanox
+ */
+
+#include <opensm/osm_file_ids.h>
+#define FILE_ID OSM_FILE_QOS_PARSER_L_L
+#include <opensm/osm_qos_policy.h>
+#include "osm_qos_parser_y.h"
+
+#define HANDLE_IF_IN_DESCRIPTION if (in_description) { yylval = strdup(yytext); return TK_TEXT; }
+
+#define SAVE_POS save_pos()
+static void save_pos();
+
+extern int column_num;
+extern int line_num;
+extern FILE * yyin;
+extern YYSTYPE yylval;
+
+boolean_t in_description = FALSE;
+boolean_t in_list_of_hex_num_ranges = FALSE;
+boolean_t in_node_type = FALSE;
+boolean_t in_list_of_numbers = FALSE;
+boolean_t in_list_of_strings = FALSE;
+boolean_t in_list_of_num_pairs = FALSE;
+boolean_t in_asterisk_or_list_of_numbers = FALSE;
+boolean_t in_list_of_num_ranges = FALSE;
+boolean_t in_single_string = FALSE;
+boolean_t in_single_number = FALSE;
+
+static void reset_new_line_flags();
+#define RESET_NEW_LINE_FLAGS reset_new_line_flags()
+
+#define START_USE {in_description = TRUE;} /* list of strings including whitespace (description) */
+#define START_PORT_GUID {in_list_of_hex_num_ranges = TRUE;} /* comma-separated list of hex num ranges */
+#define START_PORT_NAME {in_list_of_strings = TRUE;} /* comma-separated list of following strings: ../../.. */
+#define START_PARTITION {in_single_string = TRUE;} /* single string w/o whitespaces (partition name) */
+#define START_NAME {in_single_string = TRUE;} /* single string w/o whitespaces (port group name) */
+#define START_QOS_LEVEL_NAME {in_single_string = TRUE;} /* single string w/o whitespaces (qos level name in match rule) */
+
+#define START_NODE_TYPE {in_node_type = TRUE;} /* comma-separated list of node types (ROUTER,CA,...) */
+#define START_SL2VL_TABLE {in_list_of_numbers = TRUE;} /* comma-separated list of hex or dec numbers */
+
+#define START_GROUP {in_list_of_strings = TRUE;} /* list of strings w/o whitespaces (group names) */
+#define START_ACROSS {in_list_of_strings = TRUE;} /* list of strings w/o whitespaces (group names) */
+#define START_ACROSS_TO {in_list_of_strings = TRUE;} /* list of strings w/o whitespaces (group names) */
+#define START_ACROSS_FROM {in_list_of_strings = TRUE;} /* list of strings w/o whitespaces (group names) */
+#define START_SOURCE {in_list_of_strings = TRUE;} /* list of strings w/o whitespaces (group names) */
+#define START_DESTINATION {in_list_of_strings = TRUE;} /* list of strings w/o whitespaces (group names) */
+
+#define START_VLARB_HIGH {in_list_of_num_pairs = TRUE;} /* comma-separated list of hex or dec num pairs: "num1:num2" */
+#define START_VLARB_LOW {in_list_of_num_pairs = TRUE;} /* comma-separated list of hex or dec num pairs: "num1:num2" */
+
+#define START_TO {in_asterisk_or_list_of_numbers = TRUE;} /* (asterisk) or (comma-separated list of hex or dec numbers) */
+#define START_FROM {in_asterisk_or_list_of_numbers = TRUE;} /* (asterisk) or (comma-separated list of hex or dec numbers) */
+
+#define START_PATH_BITS {in_list_of_num_ranges = TRUE;} /* comma-separated list of hex or dec num ranges */
+#define START_QOS_CLASS {in_list_of_num_ranges = TRUE;} /* comma-separated list of hex or dec num ranges */
+#define START_SERVICE_ID {in_list_of_num_ranges = TRUE;} /* comma-separated list of hex or dec num ranges */
+#define START_PKEY {in_list_of_num_ranges = TRUE;} /* comma-separated list of hex or dec num ranges */
+
+#define START_SL {in_single_number = TRUE;} /* single number */
+#define START_VLARB_HIGH_LIMIT {in_single_number = TRUE;} /* single number */
+#define START_MTU_LIMIT {in_single_number = TRUE;} /* single number */
+#define START_RATE_LIMIT {in_single_number = TRUE;} /* single number */
+#define START_PACKET_LIFE {in_single_number = TRUE;} /* single number */
+
+#define START_ULP_DEFAULT {in_single_number = TRUE;} /* single number */
+#define START_ULP_ANY {in_list_of_num_ranges = TRUE;} /* comma-separated list of hex or dec num ranges */
+#define START_ULP_SDP_DEFAULT {in_single_number = TRUE;} /* single number */
+#define START_ULP_SDP_PORT {in_list_of_num_ranges = TRUE;} /* comma-separated list of hex or dec num ranges */
+#define START_ULP_RDS_DEFAULT {in_single_number = TRUE;} /* single number */
+#define START_ULP_RDS_PORT {in_list_of_num_ranges = TRUE;} /* comma-separated list of hex or dec num ranges */
+#define START_ULP_ISER_DEFAULT {in_single_number = TRUE;} /* single number */
+#define START_ULP_ISER_PORT {in_list_of_num_ranges = TRUE;} /* comma-separated list of hex or dec num ranges */
+#define START_ULP_SRP_GUID {in_list_of_num_ranges = TRUE;} /* comma-separated list of hex or dec num ranges */
+#define START_ULP_IPOIB_DEFAULT {in_single_number = TRUE;} /* single number */
+#define START_ULP_IPOIB_PKEY {in_list_of_num_ranges = TRUE;} /* comma-separated list of hex or dec num ranges */
+
+
+%}
+
+%option nounput noinput
+
+QOS_ULPS_START qos\-ulps
+QOS_ULPS_END end\-qos\-ulps
+PORT_GROUPS_START port\-groups
+PORT_GROUPS_END end\-port\-groups
+PORT_GROUP_START port\-group
+PORT_GROUP_END end\-port\-group
+PORT_NUM port\-num
+NAME name
+USE use
+PORT_GUID port\-guid
+TARGET_PORT_GUID target\-port\-guid
+SOURCE_PORT_GUID source\-port\-guid
+SOURCE_TARGET_PORT_GUID source\-target\-port\-guid
+PORT_NAME port\-name
+PARTITION partition
+NODE_TYPE node\-type
+QOS_SETUP_START qos\-setup
+QOS_SETUP_END end\-qos\-setup
+VLARB_TABLES_START vlarb\-tables
+VLARB_TABLES_END end\-vlarb\-tables
+VLARB_SCOPE_START vlarb\-scope
+VLARB_SCOPE_END end\-vlarb\-scope
+GROUP group
+ACROSS across
+VLARB_HIGH vlarb\-high
+VLARB_LOW vlarb\-low
+VLARB_HIGH_LIMIT vl\-high\-limit
+SL2VL_TABLES_START sl2vl\-tables
+SL2VL_TABLES_END end\-sl2vl\-tables
+SL2VL_SCOPE_START sl2vl\-scope
+SL2VL_SCOPE_END end\-sl2vl\-scope
+TO to
+FROM from
+ACROSS_TO across\-to
+ACROSS_FROM across\-from
+SL2VL_TABLE sl2vl\-table
+QOS_LEVELS_START qos\-levels
+QOS_LEVELS_END end\-qos\-levels
+QOS_LEVEL_START qos\-level
+QOS_LEVEL_END end\-qos\-level
+SL sl
+MTU_LIMIT mtu\-limit
+RATE_LIMIT rate\-limit
+PACKET_LIFE packet\-life
+PATH_BITS path\-bits
+QOS_MATCH_RULES_START qos\-match\-rules
+QOS_MATCH_RULES_END end\-qos\-match\-rules
+QOS_MATCH_RULE_START qos\-match\-rule
+QOS_MATCH_RULE_END end\-qos\-match\-rule
+QOS_CLASS qos\-class
+SOURCE source
+DESTINATION destination
+SERVICE_ID service\-id
+PKEY pkey
+QOS_LEVEL_NAME qos\-level\-name
+
+ROUTER [Rr][Oo][Uu][Tt][Ee][Rr]
+CA [Cc][Aa]
+SWITCH [Ss][Ww][Ii][Tt][Cc][Hh]
+SELF [Ss][Ee][Ll][Ff]
+ALL [Aa][Ll][Ll]
+
+ULP_SDP [Ss][Dd][Pp]
+ULP_SRP [Ss][Rr][Pp]
+ULP_RDS [Rr][Dd][Ss]
+ULP_IPOIB [Ii][Pp][Oo][Ii][Bb]
+ULP_ISER [Ii][Ss][Ee][Rr]
+ULP_ANY [Aa][Nn][Yy]
+ULP_DEFAULT [Dd][Ee][Ff][Aa][Uu][Ll][Tt]
+
+WHITE [ \t]+
+NEW_LINE \n
+COMMENT \#.*\n
+WHITE_DOTDOT_WHITE [ \t]*:[ \t]*
+WHITE_COMMA_WHITE [ \t]*,[ \t]*
+QUOTED_TEXT \"[^\"]*\"
+
+%%
+
+
+{COMMENT} { SAVE_POS; RESET_NEW_LINE_FLAGS; } /* swallow comment */
+{WHITE}{NEW_LINE} { SAVE_POS; RESET_NEW_LINE_FLAGS; } /* trailing blanks with new line */
+{WHITE} { SAVE_POS; HANDLE_IF_IN_DESCRIPTION; }
+{NEW_LINE} { SAVE_POS; RESET_NEW_LINE_FLAGS; }
+
+{QOS_ULPS_START} { SAVE_POS; HANDLE_IF_IN_DESCRIPTION; return TK_QOS_ULPS_START; }
+{QOS_ULPS_END} { SAVE_POS; HANDLE_IF_IN_DESCRIPTION; return TK_QOS_ULPS_END; }
+
+{PORT_GROUPS_START} { SAVE_POS; HANDLE_IF_IN_DESCRIPTION; return TK_PORT_GROUPS_START; }
+{PORT_GROUPS_END} { SAVE_POS; HANDLE_IF_IN_DESCRIPTION; return TK_PORT_GROUPS_END; }
+{PORT_GROUP_START} { SAVE_POS; HANDLE_IF_IN_DESCRIPTION; return TK_PORT_GROUP_START; }
+{PORT_GROUP_END} { SAVE_POS; HANDLE_IF_IN_DESCRIPTION; return TK_PORT_GROUP_END; }
+
+{QOS_SETUP_START} { SAVE_POS; HANDLE_IF_IN_DESCRIPTION; return TK_QOS_SETUP_START; }
+{QOS_SETUP_END} { SAVE_POS; HANDLE_IF_IN_DESCRIPTION; return TK_QOS_SETUP_END; }
+{VLARB_TABLES_START} { SAVE_POS; HANDLE_IF_IN_DESCRIPTION; return TK_VLARB_TABLES_START; }
+{VLARB_TABLES_END} { SAVE_POS; HANDLE_IF_IN_DESCRIPTION; return TK_VLARB_TABLES_END; }
+{VLARB_SCOPE_START} { SAVE_POS; HANDLE_IF_IN_DESCRIPTION; return TK_VLARB_SCOPE_START; }
+{VLARB_SCOPE_END} { SAVE_POS; HANDLE_IF_IN_DESCRIPTION; return TK_VLARB_SCOPE_END; }
+
+{SL2VL_TABLES_START} { SAVE_POS; HANDLE_IF_IN_DESCRIPTION; return TK_SL2VL_TABLES_START; }
+{SL2VL_TABLES_END} { SAVE_POS; HANDLE_IF_IN_DESCRIPTION; return TK_SL2VL_TABLES_END; }
+{SL2VL_SCOPE_START} { SAVE_POS; HANDLE_IF_IN_DESCRIPTION; return TK_SL2VL_SCOPE_START; }
+{SL2VL_SCOPE_END} { SAVE_POS; HANDLE_IF_IN_DESCRIPTION; return TK_SL2VL_SCOPE_END; }
+
+{QOS_LEVELS_START} { SAVE_POS; HANDLE_IF_IN_DESCRIPTION; return TK_QOS_LEVELS_START; }
+{QOS_LEVELS_END} { SAVE_POS; HANDLE_IF_IN_DESCRIPTION; return TK_QOS_LEVELS_END; }
+{QOS_LEVEL_START} { SAVE_POS; HANDLE_IF_IN_DESCRIPTION; return TK_QOS_LEVEL_START; }
+{QOS_LEVEL_END} { SAVE_POS; HANDLE_IF_IN_DESCRIPTION; return TK_QOS_LEVEL_END; }
+
+{QOS_MATCH_RULES_START} { SAVE_POS; HANDLE_IF_IN_DESCRIPTION; return TK_QOS_MATCH_RULES_START; }
+{QOS_MATCH_RULES_END} { SAVE_POS; HANDLE_IF_IN_DESCRIPTION; return TK_QOS_MATCH_RULES_END; }
+{QOS_MATCH_RULE_START} { SAVE_POS; HANDLE_IF_IN_DESCRIPTION; return TK_QOS_MATCH_RULE_START; }
+{QOS_MATCH_RULE_END} { SAVE_POS; HANDLE_IF_IN_DESCRIPTION; return TK_QOS_MATCH_RULE_END; }
+
+{PORT_GUID}{WHITE_DOTDOT_WHITE} { SAVE_POS; HANDLE_IF_IN_DESCRIPTION; START_PORT_GUID; return TK_PORT_GUID; }
+{PORT_NAME}{WHITE_DOTDOT_WHITE} { SAVE_POS; HANDLE_IF_IN_DESCRIPTION; START_PORT_NAME; return TK_PORT_NAME; }
+{PARTITION}{WHITE_DOTDOT_WHITE} { SAVE_POS; HANDLE_IF_IN_DESCRIPTION; START_PARTITION; return TK_PARTITION; }
+{NODE_TYPE}{WHITE_DOTDOT_WHITE} { SAVE_POS; HANDLE_IF_IN_DESCRIPTION; START_NODE_TYPE; return TK_NODE_TYPE; }
+{NAME}{WHITE_DOTDOT_WHITE} { SAVE_POS; HANDLE_IF_IN_DESCRIPTION; START_NAME; return TK_NAME; }
+{USE}{WHITE_DOTDOT_WHITE} { SAVE_POS; HANDLE_IF_IN_DESCRIPTION; START_USE; return TK_USE; }
+{GROUP}{WHITE_DOTDOT_WHITE} { SAVE_POS; HANDLE_IF_IN_DESCRIPTION; START_GROUP; return TK_GROUP; }
+{VLARB_HIGH}{WHITE_DOTDOT_WHITE} { SAVE_POS; HANDLE_IF_IN_DESCRIPTION; START_VLARB_HIGH; return TK_VLARB_HIGH; }
+{VLARB_LOW}{WHITE_DOTDOT_WHITE} { SAVE_POS; HANDLE_IF_IN_DESCRIPTION; START_VLARB_LOW; return TK_VLARB_LOW; }
+{VLARB_HIGH_LIMIT}{WHITE_DOTDOT_WHITE} { SAVE_POS; HANDLE_IF_IN_DESCRIPTION; START_VLARB_HIGH_LIMIT; return TK_VLARB_HIGH_LIMIT;}
+{TO}{WHITE_DOTDOT_WHITE} { SAVE_POS; HANDLE_IF_IN_DESCRIPTION; START_TO; return TK_TO; }
+{FROM}{WHITE_DOTDOT_WHITE} { SAVE_POS; HANDLE_IF_IN_DESCRIPTION; START_FROM; return TK_FROM; }
+{ACROSS_TO}{WHITE_DOTDOT_WHITE} { SAVE_POS; HANDLE_IF_IN_DESCRIPTION; START_ACROSS_TO; return TK_ACROSS_TO; }
+{ACROSS_FROM}{WHITE_DOTDOT_WHITE} { SAVE_POS; HANDLE_IF_IN_DESCRIPTION; START_ACROSS_FROM; return TK_ACROSS_FROM;}
+{ACROSS}{WHITE_DOTDOT_WHITE} { SAVE_POS; HANDLE_IF_IN_DESCRIPTION; START_ACROSS; return TK_ACROSS; }
+{SL2VL_TABLE}{WHITE_DOTDOT_WHITE} { SAVE_POS; HANDLE_IF_IN_DESCRIPTION; START_SL2VL_TABLE; return TK_SL2VL_TABLE;}
+{SL}{WHITE_DOTDOT_WHITE} { SAVE_POS; HANDLE_IF_IN_DESCRIPTION; START_SL; return TK_SL; }
+{MTU_LIMIT}{WHITE_DOTDOT_WHITE} { SAVE_POS; HANDLE_IF_IN_DESCRIPTION; START_MTU_LIMIT; return TK_MTU_LIMIT; }
+{RATE_LIMIT}{WHITE_DOTDOT_WHITE} { SAVE_POS; HANDLE_IF_IN_DESCRIPTION; START_RATE_LIMIT; return TK_RATE_LIMIT; }
+{PACKET_LIFE}{WHITE_DOTDOT_WHITE} { SAVE_POS; HANDLE_IF_IN_DESCRIPTION; START_PACKET_LIFE; return TK_PACKET_LIFE;}
+{PATH_BITS}{WHITE_DOTDOT_WHITE} { SAVE_POS; HANDLE_IF_IN_DESCRIPTION; START_PATH_BITS; return TK_PATH_BITS; }
+{QOS_CLASS}{WHITE_DOTDOT_WHITE} { SAVE_POS; HANDLE_IF_IN_DESCRIPTION; START_QOS_CLASS; return TK_QOS_CLASS; }
+{SOURCE}{WHITE_DOTDOT_WHITE} { SAVE_POS; HANDLE_IF_IN_DESCRIPTION; START_SOURCE; return TK_SOURCE; }
+{DESTINATION}{WHITE_DOTDOT_WHITE} { SAVE_POS; HANDLE_IF_IN_DESCRIPTION; START_DESTINATION; return TK_DESTINATION;}
+{SERVICE_ID}{WHITE_DOTDOT_WHITE} { SAVE_POS; HANDLE_IF_IN_DESCRIPTION; START_SERVICE_ID; return TK_SERVICE_ID; }
+{PKEY}{WHITE_DOTDOT_WHITE} { SAVE_POS; HANDLE_IF_IN_DESCRIPTION; START_PKEY; return TK_PKEY; }
+{QOS_LEVEL_NAME}{WHITE_DOTDOT_WHITE} { SAVE_POS; HANDLE_IF_IN_DESCRIPTION; START_QOS_LEVEL_NAME; return TK_QOS_LEVEL_NAME;}
+
+{ROUTER} { SAVE_POS; if (in_node_type) return TK_NODE_TYPE_ROUTER; yylval = strdup(yytext); return TK_TEXT; }
+{CA} { SAVE_POS; if (in_node_type) return TK_NODE_TYPE_CA; yylval = strdup(yytext); return TK_TEXT; }
+{SWITCH} { SAVE_POS; if (in_node_type) return TK_NODE_TYPE_SWITCH; yylval = strdup(yytext); return TK_TEXT; }
+{SELF} { SAVE_POS; if (in_node_type) return TK_NODE_TYPE_SELF; yylval = strdup(yytext); return TK_TEXT; }
+{ALL} { SAVE_POS; if (in_node_type) return TK_NODE_TYPE_ALL; yylval = strdup(yytext); return TK_TEXT; }
+
+{ULP_DEFAULT}{WHITE_DOTDOT_WHITE} { SAVE_POS; HANDLE_IF_IN_DESCRIPTION; START_ULP_DEFAULT; return TK_ULP_DEFAULT; }
+{ULP_ANY}{WHITE_COMMA_WHITE}{SERVICE_ID} { SAVE_POS; HANDLE_IF_IN_DESCRIPTION; START_ULP_ANY; return TK_ULP_ANY_SERVICE_ID; }
+{ULP_ANY}{WHITE_COMMA_WHITE}{PKEY} { SAVE_POS; HANDLE_IF_IN_DESCRIPTION; START_ULP_ANY; return TK_ULP_ANY_PKEY; }
+{ULP_ANY}{WHITE_COMMA_WHITE}{TARGET_PORT_GUID} { SAVE_POS; HANDLE_IF_IN_DESCRIPTION; START_ULP_ANY; return TK_ULP_ANY_TARGET_PORT_GUID; }
+{ULP_ANY}{WHITE_COMMA_WHITE}{SOURCE_PORT_GUID} { SAVE_POS; HANDLE_IF_IN_DESCRIPTION; START_ULP_ANY; return TK_ULP_ANY_SOURCE_PORT_GUID; }
+{ULP_ANY}{WHITE_COMMA_WHITE}{SOURCE_TARGET_PORT_GUID} { SAVE_POS; HANDLE_IF_IN_DESCRIPTION; START_ULP_ANY; return TK_ULP_ANY_SOURCE_TARGET_PORT_GUID; }
+
+{ULP_SDP}{WHITE_DOTDOT_WHITE} { SAVE_POS; HANDLE_IF_IN_DESCRIPTION; START_ULP_SDP_DEFAULT; return TK_ULP_SDP_DEFAULT; }
+{ULP_SDP}{WHITE_COMMA_WHITE}{PORT_NUM} { SAVE_POS; HANDLE_IF_IN_DESCRIPTION; START_ULP_SDP_PORT; return TK_ULP_SDP_PORT; }
+
+{ULP_RDS}{WHITE_DOTDOT_WHITE} { SAVE_POS; HANDLE_IF_IN_DESCRIPTION; START_ULP_RDS_DEFAULT; return TK_ULP_RDS_DEFAULT; }
+{ULP_RDS}{WHITE_COMMA_WHITE}{PORT_NUM} { SAVE_POS; HANDLE_IF_IN_DESCRIPTION; START_ULP_RDS_PORT; return TK_ULP_RDS_PORT; }
+
+{ULP_ISER}{WHITE_DOTDOT_WHITE} { SAVE_POS; HANDLE_IF_IN_DESCRIPTION; START_ULP_SDP_DEFAULT; return TK_ULP_ISER_DEFAULT; }
+{ULP_ISER}{WHITE_COMMA_WHITE}{PORT_NUM} { SAVE_POS; HANDLE_IF_IN_DESCRIPTION; START_ULP_SDP_PORT; return TK_ULP_ISER_PORT; }
+
+{ULP_SRP}{WHITE_COMMA_WHITE}{TARGET_PORT_GUID} { SAVE_POS; HANDLE_IF_IN_DESCRIPTION; START_ULP_SRP_GUID; return TK_ULP_SRP_GUID; }
+
+{ULP_IPOIB}{WHITE_DOTDOT_WHITE} { SAVE_POS; HANDLE_IF_IN_DESCRIPTION; START_ULP_IPOIB_DEFAULT; return TK_ULP_IPOIB_DEFAULT; }
+{ULP_IPOIB}{WHITE_COMMA_WHITE}{PKEY} { SAVE_POS; HANDLE_IF_IN_DESCRIPTION; START_ULP_IPOIB_PKEY; return TK_ULP_IPOIB_PKEY; }
+
+0[xX][0-9a-fA-F]+ {
+ SAVE_POS;
+ yylval = strdup(yytext);
+ if (in_description || in_list_of_strings || in_single_string)
+ return TK_TEXT;
+ return TK_NUMBER;
+ }
+
+[0-9]+ {
+ SAVE_POS;
+ yylval = strdup(yytext);
+ if (in_description || in_list_of_strings || in_single_string)
+ return TK_TEXT;
+ return TK_NUMBER;
+ }
+
+
+- {
+ SAVE_POS;
+ if (in_description || in_list_of_strings || in_single_string)
+ {
+ yylval = strdup(yytext);
+ return TK_TEXT;
+ }
+ return TK_DASH;
+ }
+
+: {
+ SAVE_POS;
+ if (in_description || in_list_of_strings || in_single_string)
+ {
+ yylval = strdup(yytext);
+ return TK_TEXT;
+ }
+ return TK_DOTDOT;
+ }
+
+, {
+ SAVE_POS;
+ if (in_description)
+ {
+ yylval = strdup(yytext);
+ return TK_TEXT;
+ }
+ return TK_COMMA;
+ }
+
+\* {
+ SAVE_POS;
+ if (in_description || in_list_of_strings || in_single_string)
+ {
+ yylval = strdup(yytext);
+ return TK_TEXT;
+ }
+ return TK_ASTERISK;
+ }
+
+{QUOTED_TEXT} {
+ SAVE_POS;
+ yylval = strdup(&yytext[1]);
+ yylval[strlen(yylval)-1] = '\0';
+ return TK_TEXT;
+ }
+
+. { SAVE_POS; yylval = strdup(yytext); return TK_TEXT;}
+
+<<EOF>> {
+ YY_NEW_FILE;
+ yyterminate();
+ }
+%%
+
+
+/*********************************************
+ *********************************************/
+
+static void save_pos()
+{
+ int i;
+ for (i = 0; i < yyleng; i++)
+ {
+ if (yytext[i] == '\n')
+ {
+ line_num ++;
+ column_num = 1;
+ }
+ else
+ column_num ++;
+ }
+}
+
+/*********************************************
+ *********************************************/
+
+static void reset_new_line_flags()
+{
+ in_description = FALSE;
+ in_list_of_hex_num_ranges = FALSE;
+ in_node_type = FALSE;
+ in_list_of_numbers = FALSE;
+ in_list_of_strings = FALSE;
+ in_list_of_num_pairs = FALSE;
+ in_asterisk_or_list_of_numbers = FALSE;
+ in_list_of_num_ranges = FALSE;
+ in_single_string = FALSE;
+ in_single_number = FALSE;
+}
diff --git a/contrib/ofed/opensm/opensm/osm_qos_parser_y.y b/contrib/ofed/opensm/opensm/osm_qos_parser_y.y
new file mode 100644
index 0000000..e0f6580
--- /dev/null
+++ b/contrib/ofed/opensm/opensm/osm_qos_parser_y.y
@@ -0,0 +1,3169 @@
+%{
+/*
+ * Copyright (c) 2004-2009 Voltaire, Inc. All rights reserved.
+ * Copyright (c) 2002-2008 Mellanox Technologies LTD. All rights reserved.
+ * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
+ * Copyright (c) 2008 HNR Consulting. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+/*
+ * Abstract:
+ * Grammar of OSM QoS parser.
+ *
+ * Environment:
+ * Linux User Mode
+ *
+ * Author:
+ * Yevgeny Kliteynik, Mellanox
+ */
+
+#include <stdio.h>
+#include <assert.h>
+#include <stdarg.h>
+#include <stdlib.h>
+#include <string.h>
+#include <ctype.h>
+#include <errno.h>
+#include <opensm/osm_file_ids.h>
+#define FILE_ID OSM_FILE_QOS_PARSER_Y_Y
+#include <opensm/osm_opensm.h>
+#include <opensm/osm_qos_policy.h>
+
+#define OSM_QOS_POLICY_MAX_LINE_LEN 1024*10
+#define OSM_QOS_POLICY_SL2VL_TABLE_LEN IB_MAX_NUM_VLS
+#define OSM_QOS_POLICY_MAX_VL_NUM IB_MAX_NUM_VLS
+#define OSM_QOS_POLICY_MAX_RATE IB_MAX_RATE
+#define OSM_QOS_POLICY_MIN_RATE IB_MIN_RATE
+#define OSM_QOS_POLICY_MAX_MTU IB_MAX_MTU
+#define OSM_QOS_POLICY_MIN_MTU IB_MIN_MTU
+
+typedef struct tmp_parser_struct_t_ {
+ char str[OSM_QOS_POLICY_MAX_LINE_LEN];
+ uint64_t num_pair[2];
+ cl_list_t str_list;
+ cl_list_t num_list;
+ cl_list_t num_pair_list;
+} tmp_parser_struct_t;
+
+static void __parser_tmp_struct_init();
+static void __parser_tmp_struct_reset();
+static void __parser_tmp_struct_destroy();
+
+static char * __parser_strip_white(char * str);
+
+static void __parser_str2uint64(uint64_t * p_val, char * str);
+
+static void __parser_port_group_start();
+static int __parser_port_group_end();
+
+static void __parser_sl2vl_scope_start();
+static int __parser_sl2vl_scope_end();
+
+static void __parser_vlarb_scope_start();
+static int __parser_vlarb_scope_end();
+
+static void __parser_qos_level_start();
+static int __parser_qos_level_end();
+
+static void __parser_match_rule_start();
+static int __parser_match_rule_end();
+
+static void __parser_ulp_match_rule_start();
+static int __parser_ulp_match_rule_end();
+
+static void __pkey_rangelist2rangearr(
+ cl_list_t * p_list,
+ uint64_t ** * p_arr,
+ unsigned * p_arr_len);
+
+static void __rangelist2rangearr(
+ cl_list_t * p_list,
+ uint64_t ** * p_arr,
+ unsigned * p_arr_len);
+
+static void __merge_rangearr(
+ uint64_t ** range_arr_1,
+ unsigned range_len_1,
+ uint64_t ** range_arr_2,
+ unsigned range_len_2,
+ uint64_t ** * p_arr,
+ unsigned * p_arr_len );
+
+static void __parser_add_port_to_port_map(
+ cl_qmap_t * p_map,
+ osm_physp_t * p_physp);
+
+static void __parser_add_guid_range_to_port_map(
+ cl_qmap_t * p_map,
+ uint64_t ** range_arr,
+ unsigned range_len);
+
+static void __parser_add_pkey_range_to_port_map(
+ cl_qmap_t * p_map,
+ uint64_t ** range_arr,
+ unsigned range_len);
+
+static void __parser_add_partition_list_to_port_map(
+ cl_qmap_t * p_map,
+ cl_list_t * p_list);
+
+static void __parser_add_map_to_port_map(
+ cl_qmap_t * p_dmap,
+ cl_map_t * p_smap);
+
+static int __validate_pkeys(
+ uint64_t ** range_arr,
+ unsigned range_len,
+ boolean_t is_ipoib);
+
+static void __setup_simple_qos_levels();
+static void __clear_simple_qos_levels();
+static void __setup_ulp_match_rules();
+static void __process_ulp_match_rules();
+static void yyerror(const char *format, ...);
+
+extern char * yytext;
+extern int yylex (void);
+extern FILE * yyin;
+extern int errno;
+extern void yyrestart(FILE *input_file);
+int yyparse();
+
+#define RESET_BUFFER __parser_tmp_struct_reset()
+
+tmp_parser_struct_t tmp_parser_struct;
+
+int column_num;
+int line_num;
+
+osm_qos_policy_t * p_qos_policy = NULL;
+osm_qos_port_group_t * p_current_port_group = NULL;
+osm_qos_sl2vl_scope_t * p_current_sl2vl_scope = NULL;
+osm_qos_vlarb_scope_t * p_current_vlarb_scope = NULL;
+osm_qos_level_t * p_current_qos_level = NULL;
+osm_qos_match_rule_t * p_current_qos_match_rule = NULL;
+osm_log_t * p_qos_parser_osm_log;
+
+/* 16 Simple QoS Levels - one for each SL */
+static osm_qos_level_t osm_qos_policy_simple_qos_levels[16];
+
+/* Default Simple QoS Level */
+osm_qos_level_t __default_simple_qos_level;
+
+/*
+ * List of match rules that will be generated by the
+ * qos-ulp section. These rules are concatenated to
+ * the end of the usual matching rules list at the
+ * end of parsing.
+ */
+static cl_list_t __ulp_match_rules;
+
+/***************************************************/
+
+%}
+
+%token TK_NUMBER
+%token TK_DASH
+%token TK_DOTDOT
+%token TK_COMMA
+%token TK_ASTERISK
+%token TK_TEXT
+
+%token TK_QOS_ULPS_START
+%token TK_QOS_ULPS_END
+
+%token TK_PORT_GROUPS_START
+%token TK_PORT_GROUPS_END
+%token TK_PORT_GROUP_START
+%token TK_PORT_GROUP_END
+
+%token TK_QOS_SETUP_START
+%token TK_QOS_SETUP_END
+%token TK_VLARB_TABLES_START
+%token TK_VLARB_TABLES_END
+%token TK_VLARB_SCOPE_START
+%token TK_VLARB_SCOPE_END
+
+%token TK_SL2VL_TABLES_START
+%token TK_SL2VL_TABLES_END
+%token TK_SL2VL_SCOPE_START
+%token TK_SL2VL_SCOPE_END
+
+%token TK_QOS_LEVELS_START
+%token TK_QOS_LEVELS_END
+%token TK_QOS_LEVEL_START
+%token TK_QOS_LEVEL_END
+
+%token TK_QOS_MATCH_RULES_START
+%token TK_QOS_MATCH_RULES_END
+%token TK_QOS_MATCH_RULE_START
+%token TK_QOS_MATCH_RULE_END
+
+%token TK_NAME
+%token TK_USE
+%token TK_PORT_GUID
+%token TK_PORT_NAME
+%token TK_PARTITION
+%token TK_NODE_TYPE
+%token TK_GROUP
+%token TK_ACROSS
+%token TK_VLARB_HIGH
+%token TK_VLARB_LOW
+%token TK_VLARB_HIGH_LIMIT
+%token TK_TO
+%token TK_FROM
+%token TK_ACROSS_TO
+%token TK_ACROSS_FROM
+%token TK_SL2VL_TABLE
+%token TK_SL
+%token TK_MTU_LIMIT
+%token TK_RATE_LIMIT
+%token TK_PACKET_LIFE
+%token TK_PATH_BITS
+%token TK_QOS_CLASS
+%token TK_SOURCE
+%token TK_DESTINATION
+%token TK_SERVICE_ID
+%token TK_QOS_LEVEL_NAME
+%token TK_PKEY
+
+%token TK_NODE_TYPE_ROUTER
+%token TK_NODE_TYPE_CA
+%token TK_NODE_TYPE_SWITCH
+%token TK_NODE_TYPE_SELF
+%token TK_NODE_TYPE_ALL
+
+%token TK_ULP_DEFAULT
+%token TK_ULP_ANY_SERVICE_ID
+%token TK_ULP_ANY_PKEY
+%token TK_ULP_ANY_TARGET_PORT_GUID
+%token TK_ULP_ANY_SOURCE_PORT_GUID
+%token TK_ULP_ANY_SOURCE_TARGET_PORT_GUID
+%token TK_ULP_SDP_DEFAULT
+%token TK_ULP_SDP_PORT
+%token TK_ULP_RDS_DEFAULT
+%token TK_ULP_RDS_PORT
+%token TK_ULP_ISER_DEFAULT
+%token TK_ULP_ISER_PORT
+%token TK_ULP_SRP_GUID
+%token TK_ULP_IPOIB_DEFAULT
+%token TK_ULP_IPOIB_PKEY
+
+%start head
+
+%%
+
+head: qos_policy_entries
+ ;
+
+qos_policy_entries: /* empty */
+ | qos_policy_entries qos_policy_entry
+ ;
+
+qos_policy_entry: qos_ulps_section
+ | port_groups_section
+ | qos_setup_section
+ | qos_levels_section
+ | qos_match_rules_section
+ ;
+
+ /*
+ * Parsing qos-ulps:
+ * -------------------
+ * qos-ulps
+ * default : 0 #default SL
+ * sdp, port-num 30000 : 1 #SL for SDP when destination port is 30000
+ * sdp, port-num 10000-20000 : 2
+ * sdp : 0 #default SL for SDP
+ * srp, target-port-guid 0x1234 : 2
+ * rds, port-num 25000 : 2 #SL for RDS when destination port is 25000
+ * rds, : 0 #default SL for RDS
+ * iser, port-num 900 : 5 #SL for iSER where target port is 900
+ * iser : 4 #default SL for iSER
+ * ipoib, pkey 0x0001 : 5 #SL for IPoIB on partition with pkey 0x0001
+ * ipoib : 6 #default IPoIB partition - pkey=0x7FFF
+ * any, service-id 0x6234 : 2
+ * any, pkey 0x0ABC : 3
+ * any, target-port-guid 0x0ABC-0xFFFFF : 6
+ * any, source-port-guid 0x1234 : 7
+ * any, source-target-port-guid 0x5678 : 8
+ * end-qos-ulps
+ */
+
+qos_ulps_section: TK_QOS_ULPS_START qos_ulps TK_QOS_ULPS_END
+ ;
+
+qos_ulps: qos_ulp
+ | qos_ulps qos_ulp
+ ;
+
+ /*
+ * Parsing port groups:
+ * -------------------
+ * port-groups
+ * port-group
+ * name: Storage
+ * use: our SRP storage targets
+ * port-guid: 0x1000000000000001,0x1000000000000002
+ * ...
+ * port-name: vs1 HCA-1/P1
+ * port-name: node_description/P2
+ * ...
+ * pkey: 0x00FF-0x0FFF
+ * ...
+ * partition: Part1
+ * ...
+ * node-type: ROUTER,CA,SWITCH,SELF,ALL
+ * ...
+ * end-port-group
+ * port-group
+ * ...
+ * end-port-group
+ * end-port-groups
+ */
+
+
+port_groups_section: TK_PORT_GROUPS_START port_groups TK_PORT_GROUPS_END
+ ;
+
+port_groups: port_group
+ | port_groups port_group
+ ;
+
+port_group: port_group_start port_group_entries port_group_end
+ ;
+
+port_group_start: TK_PORT_GROUP_START {
+ __parser_port_group_start();
+ }
+ ;
+
+port_group_end: TK_PORT_GROUP_END {
+ if ( __parser_port_group_end() )
+ return 1;
+ }
+ ;
+
+port_group_entries: /* empty */
+ | port_group_entries port_group_entry
+ ;
+
+port_group_entry: port_group_name
+ | port_group_use
+ | port_group_port_guid
+ | port_group_port_name
+ | port_group_pkey
+ | port_group_partition
+ | port_group_node_type
+ ;
+
+
+ /*
+ * Parsing qos setup:
+ * -----------------
+ * qos-setup
+ * vlarb-tables
+ * vlarb-scope
+ * ...
+ * end-vlarb-scope
+ * vlarb-scope
+ * ...
+ * end-vlarb-scope
+ * end-vlarb-tables
+ * sl2vl-tables
+ * sl2vl-scope
+ * ...
+ * end-sl2vl-scope
+ * sl2vl-scope
+ * ...
+ * end-sl2vl-scope
+ * end-sl2vl-tables
+ * end-qos-setup
+ */
+
+qos_setup_section: TK_QOS_SETUP_START qos_setup_items TK_QOS_SETUP_END
+ ;
+
+qos_setup_items: /* empty */
+ | qos_setup_items vlarb_tables
+ | qos_setup_items sl2vl_tables
+ ;
+
+ /* Parsing vlarb-tables */
+
+vlarb_tables: TK_VLARB_TABLES_START vlarb_scope_items TK_VLARB_TABLES_END
+ ;
+
+vlarb_scope_items: /* empty */
+ | vlarb_scope_items vlarb_scope
+ ;
+
+vlarb_scope: vlarb_scope_start vlarb_scope_entries vlarb_scope_end
+ ;
+
+vlarb_scope_start: TK_VLARB_SCOPE_START {
+ __parser_vlarb_scope_start();
+ }
+ ;
+
+vlarb_scope_end: TK_VLARB_SCOPE_END {
+ if ( __parser_vlarb_scope_end() )
+ return 1;
+ }
+ ;
+
+vlarb_scope_entries:/* empty */
+ | vlarb_scope_entries vlarb_scope_entry
+ ;
+
+ /*
+ * vlarb-scope
+ * group: Storage
+ * ...
+ * across: Storage
+ * ...
+ * vlarb-high: 0:255,1:127,2:63,3:31,4:15,5:7,6:3,7:1
+ * vlarb-low: 8:255,9:127,10:63,11:31,12:15,13:7,14:3
+ * vl-high-limit: 10
+ * end-vlarb-scope
+ */
+
+vlarb_scope_entry: vlarb_scope_group
+ | vlarb_scope_across
+ | vlarb_scope_vlarb_high
+ | vlarb_scope_vlarb_low
+ | vlarb_scope_vlarb_high_limit
+ ;
+
+ /* Parsing sl2vl-tables */
+
+sl2vl_tables: TK_SL2VL_TABLES_START sl2vl_scope_items TK_SL2VL_TABLES_END
+ ;
+
+sl2vl_scope_items: /* empty */
+ | sl2vl_scope_items sl2vl_scope
+ ;
+
+sl2vl_scope: sl2vl_scope_start sl2vl_scope_entries sl2vl_scope_end
+ ;
+
+sl2vl_scope_start: TK_SL2VL_SCOPE_START {
+ __parser_sl2vl_scope_start();
+ }
+ ;
+
+sl2vl_scope_end: TK_SL2VL_SCOPE_END {
+ if ( __parser_sl2vl_scope_end() )
+ return 1;
+ }
+ ;
+
+sl2vl_scope_entries:/* empty */
+ | sl2vl_scope_entries sl2vl_scope_entry
+ ;
+
+ /*
+ * sl2vl-scope
+ * group: Part1
+ * ...
+ * from: *
+ * ...
+ * to: *
+ * ...
+ * across-to: Storage2
+ * ...
+ * across-from: Storage1
+ * ...
+ * sl2vl-table: 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,7
+ * end-sl2vl-scope
+ */
+
+sl2vl_scope_entry: sl2vl_scope_group
+ | sl2vl_scope_across
+ | sl2vl_scope_across_from
+ | sl2vl_scope_across_to
+ | sl2vl_scope_from
+ | sl2vl_scope_to
+ | sl2vl_scope_sl2vl_table
+ ;
+
+ /*
+ * Parsing qos-levels:
+ * ------------------
+ * qos-levels
+ * qos-level
+ * name: qos_level_1
+ * use: for the lowest priority communication
+ * sl: 15
+ * mtu-limit: 1
+ * rate-limit: 1
+ * packet-life: 12
+ * path-bits: 2,4,8-32
+ * pkey: 0x00FF-0x0FFF
+ * end-qos-level
+ * ...
+ * qos-level
+ * end-qos-level
+ * end-qos-levels
+ */
+
+
+qos_levels_section: TK_QOS_LEVELS_START qos_levels TK_QOS_LEVELS_END
+ ;
+
+qos_levels: /* empty */
+ | qos_levels qos_level
+ ;
+
+qos_level: qos_level_start qos_level_entries qos_level_end
+ ;
+
+qos_level_start: TK_QOS_LEVEL_START {
+ __parser_qos_level_start();
+ }
+ ;
+
+qos_level_end: TK_QOS_LEVEL_END {
+ if ( __parser_qos_level_end() )
+ return 1;
+ }
+ ;
+
+qos_level_entries: /* empty */
+ | qos_level_entries qos_level_entry
+ ;
+
+qos_level_entry: qos_level_name
+ | qos_level_use
+ | qos_level_sl
+ | qos_level_mtu_limit
+ | qos_level_rate_limit
+ | qos_level_packet_life
+ | qos_level_path_bits
+ | qos_level_pkey
+ ;
+
+ /*
+ * Parsing qos-match-rules:
+ * -----------------------
+ * qos-match-rules
+ * qos-match-rule
+ * use: low latency by class 7-9 or 11 and bla bla
+ * qos-class: 7-9,11
+ * qos-level-name: default
+ * source: Storage
+ * destination: Storage
+ * service-id: 22,4719-5000
+ * pkey: 0x00FF-0x0FFF
+ * end-qos-match-rule
+ * qos-match-rule
+ * ...
+ * end-qos-match-rule
+ * end-qos-match-rules
+ */
+
+qos_match_rules_section: TK_QOS_MATCH_RULES_START qos_match_rules TK_QOS_MATCH_RULES_END
+ ;
+
+qos_match_rules: /* empty */
+ | qos_match_rules qos_match_rule
+ ;
+
+qos_match_rule: qos_match_rule_start qos_match_rule_entries qos_match_rule_end
+ ;
+
+qos_match_rule_start: TK_QOS_MATCH_RULE_START {
+ __parser_match_rule_start();
+ }
+ ;
+
+qos_match_rule_end: TK_QOS_MATCH_RULE_END {
+ if ( __parser_match_rule_end() )
+ return 1;
+ }
+ ;
+
+qos_match_rule_entries: /* empty */
+ | qos_match_rule_entries qos_match_rule_entry
+ ;
+
+qos_match_rule_entry: qos_match_rule_use
+ | qos_match_rule_qos_class
+ | qos_match_rule_qos_level_name
+ | qos_match_rule_source
+ | qos_match_rule_destination
+ | qos_match_rule_service_id
+ | qos_match_rule_pkey
+ ;
+
+
+ /*
+ * Parsing qos-ulps:
+ * -----------------
+ * default
+ * sdp
+ * sdp with port-num
+ * rds
+ * rds with port-num
+ * srp with target-port-guid
+ * iser
+ * iser with port-num
+ * ipoib
+ * ipoib with pkey
+ * any with service-id
+ * any with pkey
+ * any with target-port-guid
+ * any with source-port-guid
+ * any with source-target-port-guid
+ */
+
+qos_ulp: TK_ULP_DEFAULT single_number {
+ /* parsing default ulp rule: "default: num" */
+ cl_list_iterator_t list_iterator;
+ uint64_t * p_tmp_num;
+
+ list_iterator = cl_list_head(&tmp_parser_struct.num_list);
+ p_tmp_num = (uint64_t*)cl_list_obj(list_iterator);
+ if (*p_tmp_num > 15)
+ {
+ yyerror("illegal SL value");
+ return 1;
+ }
+ __default_simple_qos_level.sl = (uint8_t)(*p_tmp_num);
+ __default_simple_qos_level.sl_set = TRUE;
+ free(p_tmp_num);
+ cl_list_remove_all(&tmp_parser_struct.num_list);
+ }
+
+ | qos_ulp_type_any_service list_of_ranges TK_DOTDOT {
+ /* "any, service-id ... : sl" - one instance of list of ranges */
+ uint64_t ** range_arr;
+ unsigned range_len;
+
+ if (!cl_list_count(&tmp_parser_struct.num_pair_list))
+ {
+ yyerror("ULP rule doesn't have service ids");
+ return 1;
+ }
+
+ /* get all the service id ranges */
+ __rangelist2rangearr( &tmp_parser_struct.num_pair_list,
+ &range_arr,
+ &range_len );
+
+ p_current_qos_match_rule->service_id_range_arr = range_arr;
+ p_current_qos_match_rule->service_id_range_len = range_len;
+
+ } qos_ulp_sl
+
+ | qos_ulp_type_any_pkey list_of_ranges TK_DOTDOT {
+ /* "any, pkey ... : sl" - one instance of list of ranges */
+ uint64_t ** range_arr;
+ unsigned range_len;
+
+ if (!cl_list_count(&tmp_parser_struct.num_pair_list))
+ {
+ yyerror("ULP rule doesn't have pkeys");
+ return 1;
+ }
+
+ /* get all the pkey ranges */
+ __pkey_rangelist2rangearr( &tmp_parser_struct.num_pair_list,
+ &range_arr,
+ &range_len );
+
+ p_current_qos_match_rule->pkey_range_arr = range_arr;
+ p_current_qos_match_rule->pkey_range_len = range_len;
+
+ } qos_ulp_sl
+
+ | qos_ulp_type_any_target_port_guid list_of_ranges TK_DOTDOT {
+ /* any, target-port-guid ... : sl */
+ uint64_t ** range_arr;
+ unsigned range_len;
+
+ if (!cl_list_count(&tmp_parser_struct.num_pair_list))
+ {
+ yyerror("ULP rule doesn't have port guids");
+ return 1;
+ }
+
+ /* create a new port group with these ports */
+ __parser_port_group_start();
+
+ p_current_port_group->name = strdup("_ULP_Targets_");
+ p_current_port_group->use = strdup("Generated from ULP rules");
+
+ __rangelist2rangearr( &tmp_parser_struct.num_pair_list,
+ &range_arr,
+ &range_len );
+
+ __parser_add_guid_range_to_port_map(
+ &p_current_port_group->port_map,
+ range_arr,
+ range_len);
+
+ /* add this port group to the destination
+ groups of the current match rule */
+ cl_list_insert_tail(&p_current_qos_match_rule->destination_group_list,
+ p_current_port_group);
+
+ __parser_port_group_end();
+
+ } qos_ulp_sl
+
+ | qos_ulp_type_any_source_port_guid list_of_ranges TK_DOTDOT {
+ /* any, source-port-guid ... : sl */
+ uint64_t ** range_arr;
+ unsigned range_len;
+
+ if (!cl_list_count(&tmp_parser_struct.num_pair_list))
+ {
+ yyerror("ULP rule doesn't have port guids");
+ return 1;
+ }
+
+ /* create a new port group with these ports */
+ __parser_port_group_start();
+
+ p_current_port_group->name = strdup("_ULP_Sources_");
+ p_current_port_group->use = strdup("Generated from ULP rules");
+
+ __rangelist2rangearr( &tmp_parser_struct.num_pair_list,
+ &range_arr,
+ &range_len );
+
+ __parser_add_guid_range_to_port_map(
+ &p_current_port_group->port_map,
+ range_arr,
+ range_len);
+
+ /* add this port group to the source
+ groups of the current match rule */
+ cl_list_insert_tail(&p_current_qos_match_rule->source_group_list,
+ p_current_port_group);
+
+ __parser_port_group_end();
+
+ } qos_ulp_sl
+
+ | qos_ulp_type_any_source_target_port_guid list_of_ranges TK_DOTDOT {
+ /* any, source-target-port-guid ... : sl */
+ uint64_t ** range_arr;
+ unsigned range_len;
+
+ if (!cl_list_count(&tmp_parser_struct.num_pair_list))
+ {
+ yyerror("ULP rule doesn't have port guids");
+ return 1;
+ }
+
+ /* create a new port group with these ports */
+ __parser_port_group_start();
+
+ p_current_port_group->name = strdup("_ULP_Sources_Targets_");
+ p_current_port_group->use = strdup("Generated from ULP rules");
+
+ __rangelist2rangearr( &tmp_parser_struct.num_pair_list,
+ &range_arr,
+ &range_len );
+
+ __parser_add_guid_range_to_port_map(
+ &p_current_port_group->port_map,
+ range_arr,
+ range_len);
+
+ /* add this port group to the source and destination
+ groups of the current match rule */
+ cl_list_insert_tail(&p_current_qos_match_rule->source_group_list,
+ p_current_port_group);
+
+ cl_list_insert_tail(&p_current_qos_match_rule->destination_group_list,
+ p_current_port_group);
+
+ __parser_port_group_end();
+
+ } qos_ulp_sl
+
+ | qos_ulp_type_sdp_default {
+ /* "sdp : sl" - default SL for SDP */
+ uint64_t ** range_arr =
+ (uint64_t **)malloc(sizeof(uint64_t *));
+ range_arr[0] = (uint64_t *)malloc(2*sizeof(uint64_t));
+ range_arr[0][0] = OSM_QOS_POLICY_ULP_SDP_SERVICE_ID;
+ range_arr[0][1] = OSM_QOS_POLICY_ULP_SDP_SERVICE_ID + 0xFFFF;
+
+ p_current_qos_match_rule->service_id_range_arr = range_arr;
+ p_current_qos_match_rule->service_id_range_len = 1;
+
+ } qos_ulp_sl
+
+ | qos_ulp_type_sdp_port list_of_ranges TK_DOTDOT {
+ /* sdp with port numbers */
+ uint64_t ** range_arr;
+ unsigned range_len;
+ unsigned i;
+
+ if (!cl_list_count(&tmp_parser_struct.num_pair_list))
+ {
+ yyerror("SDP ULP rule doesn't have port numbers");
+ return 1;
+ }
+
+ /* get all the port ranges */
+ __rangelist2rangearr( &tmp_parser_struct.num_pair_list,
+ &range_arr,
+ &range_len );
+ /* now translate these port numbers into service ids */
+ for (i = 0; i < range_len; i++)
+ {
+ if (range_arr[i][0] > 0xFFFF || range_arr[i][1] > 0xFFFF)
+ {
+ yyerror("SDP port number out of range");
+ free(range_arr);
+ return 1;
+ }
+ range_arr[i][0] += OSM_QOS_POLICY_ULP_SDP_SERVICE_ID;
+ range_arr[i][1] += OSM_QOS_POLICY_ULP_SDP_SERVICE_ID;
+ }
+
+ p_current_qos_match_rule->service_id_range_arr = range_arr;
+ p_current_qos_match_rule->service_id_range_len = range_len;
+
+ } qos_ulp_sl
+
+ | qos_ulp_type_rds_default {
+ /* "rds : sl" - default SL for RDS */
+ uint64_t ** range_arr =
+ (uint64_t **)malloc(sizeof(uint64_t *));
+ range_arr[0] = (uint64_t *)malloc(2*sizeof(uint64_t));
+ range_arr[0][0] = range_arr[0][1] =
+ OSM_QOS_POLICY_ULP_RDS_SERVICE_ID + OSM_QOS_POLICY_ULP_RDS_PORT;
+
+ p_current_qos_match_rule->service_id_range_arr = range_arr;
+ p_current_qos_match_rule->service_id_range_len = 1;
+
+ } qos_ulp_sl
+
+ | qos_ulp_type_rds_port list_of_ranges TK_DOTDOT {
+ /* rds with port numbers */
+ uint64_t ** range_arr;
+ unsigned range_len;
+ unsigned i;
+
+ if (!cl_list_count(&tmp_parser_struct.num_pair_list))
+ {
+ yyerror("RDS ULP rule doesn't have port numbers");
+ return 1;
+ }
+
+ /* get all the port ranges */
+ __rangelist2rangearr( &tmp_parser_struct.num_pair_list,
+ &range_arr,
+ &range_len );
+ /* now translate these port numbers into service ids */
+ for (i = 0; i < range_len; i++)
+ {
+ if (range_arr[i][0] > 0xFFFF || range_arr[i][1] > 0xFFFF)
+ {
+ yyerror("SDP port number out of range");
+ free(range_arr);
+ return 1;
+ }
+ range_arr[i][0] += OSM_QOS_POLICY_ULP_RDS_SERVICE_ID;
+ range_arr[i][1] += OSM_QOS_POLICY_ULP_RDS_SERVICE_ID;
+ }
+
+ p_current_qos_match_rule->service_id_range_arr = range_arr;
+ p_current_qos_match_rule->service_id_range_len = range_len;
+
+ } qos_ulp_sl
+
+ | qos_ulp_type_iser_default {
+ /* "iSER : sl" - default SL for iSER */
+ uint64_t ** range_arr =
+ (uint64_t **)malloc(sizeof(uint64_t *));
+ range_arr[0] = (uint64_t *)malloc(2*sizeof(uint64_t));
+ range_arr[0][0] = range_arr[0][1] =
+ OSM_QOS_POLICY_ULP_ISER_SERVICE_ID + OSM_QOS_POLICY_ULP_ISER_PORT;
+
+ p_current_qos_match_rule->service_id_range_arr = range_arr;
+ p_current_qos_match_rule->service_id_range_len = 1;
+
+ } qos_ulp_sl
+
+ | qos_ulp_type_iser_port list_of_ranges TK_DOTDOT {
+ /* iser with port numbers */
+ uint64_t ** range_arr;
+ unsigned range_len;
+ unsigned i;
+
+ if (!cl_list_count(&tmp_parser_struct.num_pair_list))
+ {
+ yyerror("iSER ULP rule doesn't have port numbers");
+ return 1;
+ }
+
+ /* get all the port ranges */
+ __rangelist2rangearr( &tmp_parser_struct.num_pair_list,
+ &range_arr,
+ &range_len );
+ /* now translate these port numbers into service ids */
+ for (i = 0; i < range_len; i++)
+ {
+ if (range_arr[i][0] > 0xFFFF || range_arr[i][1] > 0xFFFF)
+ {
+ yyerror("SDP port number out of range");
+ free(range_arr);
+ return 1;
+ }
+ range_arr[i][0] += OSM_QOS_POLICY_ULP_ISER_SERVICE_ID;
+ range_arr[i][1] += OSM_QOS_POLICY_ULP_ISER_SERVICE_ID;
+ }
+
+ p_current_qos_match_rule->service_id_range_arr = range_arr;
+ p_current_qos_match_rule->service_id_range_len = range_len;
+
+ } qos_ulp_sl
+
+ | qos_ulp_type_srp_guid list_of_ranges TK_DOTDOT {
+ /* srp with target guids - this rule is similar
+ to writing 'any' ulp with target port guids */
+ uint64_t ** range_arr;
+ unsigned range_len;
+
+ if (!cl_list_count(&tmp_parser_struct.num_pair_list))
+ {
+ yyerror("SRP ULP rule doesn't have port guids");
+ return 1;
+ }
+
+ /* create a new port group with these ports */
+ __parser_port_group_start();
+
+ p_current_port_group->name = strdup("_SRP_Targets_");
+ p_current_port_group->use = strdup("Generated from ULP rules");
+
+ __rangelist2rangearr( &tmp_parser_struct.num_pair_list,
+ &range_arr,
+ &range_len );
+
+ __parser_add_guid_range_to_port_map(
+ &p_current_port_group->port_map,
+ range_arr,
+ range_len);
+
+ /* add this port group to the destination
+ groups of the current match rule */
+ cl_list_insert_tail(&p_current_qos_match_rule->destination_group_list,
+ p_current_port_group);
+
+ __parser_port_group_end();
+
+ } qos_ulp_sl
+
+ | qos_ulp_type_ipoib_default {
+ /* ipoib w/o any pkeys (default pkey) */
+ uint64_t ** range_arr =
+ (uint64_t **)malloc(sizeof(uint64_t *));
+ range_arr[0] = (uint64_t *)malloc(2*sizeof(uint64_t));
+ range_arr[0][0] = range_arr[0][1] = 0x7fff;
+
+ /*
+ * Although we know that the default partition exists,
+ * we still need to validate it by checking that it has
+ * at least two full members. Otherwise IPoIB won't work.
+ */
+ if (__validate_pkeys(range_arr, 1, TRUE))
+ return 1;
+
+ p_current_qos_match_rule->pkey_range_arr = range_arr;
+ p_current_qos_match_rule->pkey_range_len = 1;
+
+ } qos_ulp_sl
+
+ | qos_ulp_type_ipoib_pkey list_of_ranges TK_DOTDOT {
+ /* ipoib with pkeys */
+ uint64_t ** range_arr;
+ unsigned range_len;
+
+ if (!cl_list_count(&tmp_parser_struct.num_pair_list))
+ {
+ yyerror("IPoIB ULP rule doesn't have pkeys");
+ return 1;
+ }
+
+ /* get all the pkey ranges */
+ __pkey_rangelist2rangearr( &tmp_parser_struct.num_pair_list,
+ &range_arr,
+ &range_len );
+
+ /*
+ * Validate pkeys.
+ * For IPoIB pkeys the validation is strict.
+ * If some problem would be found, parsing will
+ * be aborted with a proper error messages.
+ */
+ if (__validate_pkeys(range_arr, range_len, TRUE)) {
+ free(range_arr);
+ return 1;
+ }
+
+ p_current_qos_match_rule->pkey_range_arr = range_arr;
+ p_current_qos_match_rule->pkey_range_len = range_len;
+
+ } qos_ulp_sl
+ ;
+
+qos_ulp_type_any_service: TK_ULP_ANY_SERVICE_ID
+ { __parser_ulp_match_rule_start(); };
+
+qos_ulp_type_any_pkey: TK_ULP_ANY_PKEY
+ { __parser_ulp_match_rule_start(); };
+
+qos_ulp_type_any_target_port_guid: TK_ULP_ANY_TARGET_PORT_GUID
+ { __parser_ulp_match_rule_start(); };
+
+qos_ulp_type_any_source_port_guid: TK_ULP_ANY_SOURCE_PORT_GUID
+ { __parser_ulp_match_rule_start(); };
+
+qos_ulp_type_any_source_target_port_guid: TK_ULP_ANY_SOURCE_TARGET_PORT_GUID
+ { __parser_ulp_match_rule_start(); };
+
+qos_ulp_type_sdp_default: TK_ULP_SDP_DEFAULT
+ { __parser_ulp_match_rule_start(); };
+
+qos_ulp_type_sdp_port: TK_ULP_SDP_PORT
+ { __parser_ulp_match_rule_start(); };
+
+qos_ulp_type_rds_default: TK_ULP_RDS_DEFAULT
+ { __parser_ulp_match_rule_start(); };
+
+qos_ulp_type_rds_port: TK_ULP_RDS_PORT
+ { __parser_ulp_match_rule_start(); };
+
+qos_ulp_type_iser_default: TK_ULP_ISER_DEFAULT
+ { __parser_ulp_match_rule_start(); };
+
+qos_ulp_type_iser_port: TK_ULP_ISER_PORT
+ { __parser_ulp_match_rule_start(); };
+
+qos_ulp_type_srp_guid: TK_ULP_SRP_GUID
+ { __parser_ulp_match_rule_start(); };
+
+qos_ulp_type_ipoib_default: TK_ULP_IPOIB_DEFAULT
+ { __parser_ulp_match_rule_start(); };
+
+qos_ulp_type_ipoib_pkey: TK_ULP_IPOIB_PKEY
+ { __parser_ulp_match_rule_start(); };
+
+
+qos_ulp_sl: single_number {
+ /* get the SL for ULP rules */
+ cl_list_iterator_t list_iterator;
+ uint64_t * p_tmp_num;
+ uint8_t sl;
+
+ list_iterator = cl_list_head(&tmp_parser_struct.num_list);
+ p_tmp_num = (uint64_t*)cl_list_obj(list_iterator);
+ if (*p_tmp_num > 15)
+ {
+ yyerror("illegal SL value");
+ return 1;
+ }
+
+ sl = (uint8_t)(*p_tmp_num);
+ free(p_tmp_num);
+ cl_list_remove_all(&tmp_parser_struct.num_list);
+
+ p_current_qos_match_rule->p_qos_level =
+ &osm_qos_policy_simple_qos_levels[sl];
+ p_current_qos_match_rule->qos_level_name =
+ strdup(osm_qos_policy_simple_qos_levels[sl].name);
+
+ if (__parser_ulp_match_rule_end())
+ return 1;
+ }
+ ;
+
+ /*
+ * port_group_entry values:
+ * port_group_name
+ * port_group_use
+ * port_group_port_guid
+ * port_group_port_name
+ * port_group_pkey
+ * port_group_partition
+ * port_group_node_type
+ */
+
+port_group_name: port_group_name_start single_string {
+ /* 'name' of 'port-group' - one instance */
+ cl_list_iterator_t list_iterator;
+ char * tmp_str;
+
+ if (p_current_port_group->name)
+ {
+ yyerror("port-group has multiple 'name' tags");
+ cl_list_remove_all(&tmp_parser_struct.str_list);
+ return 1;
+ }
+
+ list_iterator = cl_list_head(&tmp_parser_struct.str_list);
+ if ( list_iterator != cl_list_end(&tmp_parser_struct.str_list) )
+ {
+ tmp_str = (char*)cl_list_obj(list_iterator);
+ if (tmp_str)
+ p_current_port_group->name = tmp_str;
+ }
+ cl_list_remove_all(&tmp_parser_struct.str_list);
+ }
+ ;
+
+port_group_name_start: TK_NAME {
+ RESET_BUFFER;
+ }
+ ;
+
+port_group_use: port_group_use_start single_string {
+ /* 'use' of 'port-group' - one instance */
+ cl_list_iterator_t list_iterator;
+ char * tmp_str;
+
+ if (p_current_port_group->use)
+ {
+ yyerror("port-group has multiple 'use' tags");
+ cl_list_remove_all(&tmp_parser_struct.str_list);
+ return 1;
+ }
+
+ list_iterator = cl_list_head(&tmp_parser_struct.str_list);
+ if ( list_iterator != cl_list_end(&tmp_parser_struct.str_list) )
+ {
+ tmp_str = (char*)cl_list_obj(list_iterator);
+ if (tmp_str)
+ p_current_port_group->use = tmp_str;
+ }
+ cl_list_remove_all(&tmp_parser_struct.str_list);
+ }
+ ;
+
+port_group_use_start: TK_USE {
+ RESET_BUFFER;
+ }
+ ;
+
+port_group_port_name: port_group_port_name_start string_list {
+ /* 'port-name' in 'port-group' - any num of instances */
+ cl_list_iterator_t list_iterator;
+ osm_node_t * p_node;
+ osm_physp_t * p_physp;
+ unsigned port_num;
+ char * tmp_str;
+ char * port_str;
+
+ /* parsing port name strings */
+ for (list_iterator = cl_list_head(&tmp_parser_struct.str_list);
+ list_iterator != cl_list_end(&tmp_parser_struct.str_list);
+ list_iterator = cl_list_next(list_iterator))
+ {
+ tmp_str = (char*)cl_list_obj(list_iterator);
+ if (tmp_str)
+ {
+ /* last slash in port name string is a separator
+ between node name and port number */
+ port_str = strrchr(tmp_str, '/');
+ if (!port_str || (strlen(port_str) < 3) ||
+ (port_str[1] != 'p' && port_str[1] != 'P')) {
+ yyerror("'%s' - illegal port name",
+ tmp_str);
+ free(tmp_str);
+ cl_list_remove_all(&tmp_parser_struct.str_list);
+ return 1;
+ }
+
+ if (!(port_num = strtoul(&port_str[2],NULL,0))) {
+ yyerror(
+ "'%s' - illegal port number in port name",
+ tmp_str);
+ free(tmp_str);
+ cl_list_remove_all(&tmp_parser_struct.str_list);
+ return 1;
+ }
+
+ /* separate node name from port number */
+ port_str[0] = '\0';
+
+ if (st_lookup(p_qos_policy->p_node_hash,
+ (st_data_t)tmp_str,
+ (void *)&p_node))
+ {
+ /* we found the node, now get the right port */
+ p_physp = osm_node_get_physp_ptr(p_node, port_num);
+ if (!p_physp) {
+ yyerror(
+ "'%s' - port number out of range in port name",
+ tmp_str);
+ free(tmp_str);
+ cl_list_remove_all(&tmp_parser_struct.str_list);
+ return 1;
+ }
+ /* we found the port, now add it to guid table */
+ __parser_add_port_to_port_map(&p_current_port_group->port_map,
+ p_physp);
+ }
+ free(tmp_str);
+ }
+ }
+ cl_list_remove_all(&tmp_parser_struct.str_list);
+ }
+ ;
+
+port_group_port_name_start: TK_PORT_NAME {
+ RESET_BUFFER;
+ }
+ ;
+
+port_group_port_guid: port_group_port_guid_start list_of_ranges {
+ /* 'port-guid' in 'port-group' - any num of instances */
+ /* list of guid ranges */
+ if (cl_list_count(&tmp_parser_struct.num_pair_list))
+ {
+ uint64_t ** range_arr;
+ unsigned range_len;
+
+ __rangelist2rangearr( &tmp_parser_struct.num_pair_list,
+ &range_arr,
+ &range_len );
+
+ __parser_add_guid_range_to_port_map(
+ &p_current_port_group->port_map,
+ range_arr,
+ range_len);
+ }
+ }
+ ;
+
+port_group_port_guid_start: TK_PORT_GUID {
+ RESET_BUFFER;
+ }
+ ;
+
+port_group_pkey: port_group_pkey_start list_of_ranges {
+ /* 'pkey' in 'port-group' - any num of instances */
+ /* list of pkey ranges */
+ if (cl_list_count(&tmp_parser_struct.num_pair_list))
+ {
+ uint64_t ** range_arr;
+ unsigned range_len;
+
+ __pkey_rangelist2rangearr( &tmp_parser_struct.num_pair_list,
+ &range_arr,
+ &range_len );
+
+ __parser_add_pkey_range_to_port_map(
+ &p_current_port_group->port_map,
+ range_arr,
+ range_len);
+ }
+ }
+ ;
+
+port_group_pkey_start: TK_PKEY {
+ RESET_BUFFER;
+ }
+ ;
+
+port_group_partition: port_group_partition_start string_list {
+ /* 'partition' in 'port-group' - any num of instances */
+ __parser_add_partition_list_to_port_map(
+ &p_current_port_group->port_map,
+ &tmp_parser_struct.str_list);
+ }
+ ;
+
+port_group_partition_start: TK_PARTITION {
+ RESET_BUFFER;
+ }
+ ;
+
+port_group_node_type: port_group_node_type_start port_group_node_type_list {
+ /* 'node-type' in 'port-group' - any num of instances */
+ }
+ ;
+
+port_group_node_type_start: TK_NODE_TYPE {
+ RESET_BUFFER;
+ }
+ ;
+
+port_group_node_type_list: node_type_item
+ | port_group_node_type_list TK_COMMA node_type_item
+ ;
+
+node_type_item: node_type_ca
+ | node_type_switch
+ | node_type_router
+ | node_type_all
+ | node_type_self
+ ;
+
+node_type_ca: TK_NODE_TYPE_CA {
+ p_current_port_group->node_types |=
+ OSM_QOS_POLICY_NODE_TYPE_CA;
+ }
+ ;
+
+node_type_switch: TK_NODE_TYPE_SWITCH {
+ p_current_port_group->node_types |=
+ OSM_QOS_POLICY_NODE_TYPE_SWITCH;
+ }
+ ;
+
+node_type_router: TK_NODE_TYPE_ROUTER {
+ p_current_port_group->node_types |=
+ OSM_QOS_POLICY_NODE_TYPE_ROUTER;
+ }
+ ;
+
+node_type_all: TK_NODE_TYPE_ALL {
+ p_current_port_group->node_types |=
+ (OSM_QOS_POLICY_NODE_TYPE_CA |
+ OSM_QOS_POLICY_NODE_TYPE_SWITCH |
+ OSM_QOS_POLICY_NODE_TYPE_ROUTER);
+ }
+ ;
+
+node_type_self: TK_NODE_TYPE_SELF {
+ osm_port_t * p_osm_port =
+ osm_get_port_by_guid(p_qos_policy->p_subn,
+ p_qos_policy->p_subn->sm_port_guid);
+ if (p_osm_port)
+ __parser_add_port_to_port_map(
+ &p_current_port_group->port_map,
+ p_osm_port->p_physp);
+ }
+ ;
+
+ /*
+ * vlarb_scope_entry values:
+ * vlarb_scope_group
+ * vlarb_scope_across
+ * vlarb_scope_vlarb_high
+ * vlarb_scope_vlarb_low
+ * vlarb_scope_vlarb_high_limit
+ */
+
+
+
+vlarb_scope_group: vlarb_scope_group_start string_list {
+ /* 'group' in 'vlarb-scope' - any num of instances */
+ cl_list_iterator_t list_iterator;
+ char * tmp_str;
+
+ list_iterator = cl_list_head(&tmp_parser_struct.str_list);
+ while( list_iterator != cl_list_end(&tmp_parser_struct.str_list) )
+ {
+ tmp_str = (char*)cl_list_obj(list_iterator);
+ if (tmp_str)
+ cl_list_insert_tail(&p_current_vlarb_scope->group_list,tmp_str);
+ list_iterator = cl_list_next(list_iterator);
+ }
+ cl_list_remove_all(&tmp_parser_struct.str_list);
+ }
+ ;
+
+vlarb_scope_group_start: TK_GROUP {
+ RESET_BUFFER;
+ }
+ ;
+
+vlarb_scope_across: vlarb_scope_across_start string_list {
+ /* 'across' in 'vlarb-scope' - any num of instances */
+ cl_list_iterator_t list_iterator;
+ char * tmp_str;
+
+ list_iterator = cl_list_head(&tmp_parser_struct.str_list);
+ while( list_iterator != cl_list_end(&tmp_parser_struct.str_list) )
+ {
+ tmp_str = (char*)cl_list_obj(list_iterator);
+ if (tmp_str)
+ cl_list_insert_tail(&p_current_vlarb_scope->across_list,tmp_str);
+ list_iterator = cl_list_next(list_iterator);
+ }
+ cl_list_remove_all(&tmp_parser_struct.str_list);
+ }
+ ;
+
+vlarb_scope_across_start: TK_ACROSS {
+ RESET_BUFFER;
+ }
+ ;
+
+vlarb_scope_vlarb_high_limit: vlarb_scope_vlarb_high_limit_start single_number {
+ /* 'vl-high-limit' in 'vlarb-scope' - one instance of one number */
+ cl_list_iterator_t list_iterator;
+ uint64_t * p_tmp_num;
+
+ list_iterator = cl_list_head(&tmp_parser_struct.num_list);
+ p_tmp_num = (uint64_t*)cl_list_obj(list_iterator);
+ if (p_tmp_num)
+ {
+ p_current_vlarb_scope->vl_high_limit = (uint32_t)(*p_tmp_num);
+ p_current_vlarb_scope->vl_high_limit_set = TRUE;
+ free(p_tmp_num);
+ }
+
+ cl_list_remove_all(&tmp_parser_struct.num_list);
+ }
+ ;
+
+vlarb_scope_vlarb_high_limit_start: TK_VLARB_HIGH_LIMIT {
+ RESET_BUFFER;
+ }
+ ;
+
+vlarb_scope_vlarb_high: vlarb_scope_vlarb_high_start num_list_with_dotdot {
+ /* 'vlarb-high' in 'vlarb-scope' - list of pairs of numbers with ':' and ',' */
+ cl_list_iterator_t list_iterator;
+ uint64_t * num_pair;
+
+ list_iterator = cl_list_head(&tmp_parser_struct.num_pair_list);
+ while( list_iterator != cl_list_end(&tmp_parser_struct.num_pair_list) )
+ {
+ num_pair = (uint64_t*)cl_list_obj(list_iterator);
+ if (num_pair)
+ cl_list_insert_tail(&p_current_vlarb_scope->vlarb_high_list,num_pair);
+ list_iterator = cl_list_next(list_iterator);
+ }
+ cl_list_remove_all(&tmp_parser_struct.num_pair_list);
+ }
+ ;
+
+vlarb_scope_vlarb_high_start: TK_VLARB_HIGH {
+ RESET_BUFFER;
+ }
+ ;
+
+vlarb_scope_vlarb_low: vlarb_scope_vlarb_low_start num_list_with_dotdot {
+ /* 'vlarb-low' in 'vlarb-scope' - list of pairs of numbers with ':' and ',' */
+ cl_list_iterator_t list_iterator;
+ uint64_t * num_pair;
+
+ list_iterator = cl_list_head(&tmp_parser_struct.num_pair_list);
+ while( list_iterator != cl_list_end(&tmp_parser_struct.num_pair_list) )
+ {
+ num_pair = (uint64_t*)cl_list_obj(list_iterator);
+ if (num_pair)
+ cl_list_insert_tail(&p_current_vlarb_scope->vlarb_low_list,num_pair);
+ list_iterator = cl_list_next(list_iterator);
+ }
+ cl_list_remove_all(&tmp_parser_struct.num_pair_list);
+ }
+ ;
+
+vlarb_scope_vlarb_low_start: TK_VLARB_LOW {
+ RESET_BUFFER;
+ }
+ ;
+
+ /*
+ * sl2vl_scope_entry values:
+ * sl2vl_scope_group
+ * sl2vl_scope_across
+ * sl2vl_scope_across_from
+ * sl2vl_scope_across_to
+ * sl2vl_scope_from
+ * sl2vl_scope_to
+ * sl2vl_scope_sl2vl_table
+ */
+
+sl2vl_scope_group: sl2vl_scope_group_start string_list {
+ /* 'group' in 'sl2vl-scope' - any num of instances */
+ cl_list_iterator_t list_iterator;
+ char * tmp_str;
+
+ list_iterator = cl_list_head(&tmp_parser_struct.str_list);
+ while( list_iterator != cl_list_end(&tmp_parser_struct.str_list) )
+ {
+ tmp_str = (char*)cl_list_obj(list_iterator);
+ if (tmp_str)
+ cl_list_insert_tail(&p_current_sl2vl_scope->group_list,tmp_str);
+ list_iterator = cl_list_next(list_iterator);
+ }
+ cl_list_remove_all(&tmp_parser_struct.str_list);
+ }
+ ;
+
+sl2vl_scope_group_start: TK_GROUP {
+ RESET_BUFFER;
+ }
+ ;
+
+sl2vl_scope_across: sl2vl_scope_across_start string_list {
+ /* 'across' in 'sl2vl-scope' - any num of instances */
+ cl_list_iterator_t list_iterator;
+ char * tmp_str;
+
+ list_iterator = cl_list_head(&tmp_parser_struct.str_list);
+ while( list_iterator != cl_list_end(&tmp_parser_struct.str_list) )
+ {
+ tmp_str = (char*)cl_list_obj(list_iterator);
+ if (tmp_str) {
+ cl_list_insert_tail(&p_current_sl2vl_scope->across_from_list,tmp_str);
+ cl_list_insert_tail(&p_current_sl2vl_scope->across_to_list,strdup(tmp_str));
+ }
+ list_iterator = cl_list_next(list_iterator);
+ }
+ cl_list_remove_all(&tmp_parser_struct.str_list);
+ }
+ ;
+
+sl2vl_scope_across_start: TK_ACROSS {
+ RESET_BUFFER;
+ }
+ ;
+
+sl2vl_scope_across_from: sl2vl_scope_across_from_start string_list {
+ /* 'across-from' in 'sl2vl-scope' - any num of instances */
+ cl_list_iterator_t list_iterator;
+ char * tmp_str;
+
+ list_iterator = cl_list_head(&tmp_parser_struct.str_list);
+ while( list_iterator != cl_list_end(&tmp_parser_struct.str_list) )
+ {
+ tmp_str = (char*)cl_list_obj(list_iterator);
+ if (tmp_str)
+ cl_list_insert_tail(&p_current_sl2vl_scope->across_from_list,tmp_str);
+ list_iterator = cl_list_next(list_iterator);
+ }
+ cl_list_remove_all(&tmp_parser_struct.str_list);
+ }
+ ;
+
+sl2vl_scope_across_from_start: TK_ACROSS_FROM {
+ RESET_BUFFER;
+ }
+ ;
+
+sl2vl_scope_across_to: sl2vl_scope_across_to_start string_list {
+ /* 'across-to' in 'sl2vl-scope' - any num of instances */
+ cl_list_iterator_t list_iterator;
+ char * tmp_str;
+
+ list_iterator = cl_list_head(&tmp_parser_struct.str_list);
+ while( list_iterator != cl_list_end(&tmp_parser_struct.str_list) )
+ {
+ tmp_str = (char*)cl_list_obj(list_iterator);
+ if (tmp_str) {
+ cl_list_insert_tail(&p_current_sl2vl_scope->across_to_list,tmp_str);
+ }
+ list_iterator = cl_list_next(list_iterator);
+ }
+ cl_list_remove_all(&tmp_parser_struct.str_list);
+ }
+ ;
+
+sl2vl_scope_across_to_start: TK_ACROSS_TO {
+ RESET_BUFFER;
+ }
+ ;
+
+sl2vl_scope_from: sl2vl_scope_from_start sl2vl_scope_from_list_or_asterisk {
+ /* 'from' in 'sl2vl-scope' - any num of instances */
+ }
+ ;
+
+sl2vl_scope_from_start: TK_FROM {
+ RESET_BUFFER;
+ }
+ ;
+
+sl2vl_scope_to: sl2vl_scope_to_start sl2vl_scope_to_list_or_asterisk {
+ /* 'to' in 'sl2vl-scope' - any num of instances */
+ }
+ ;
+
+sl2vl_scope_to_start: TK_TO {
+ RESET_BUFFER;
+ }
+ ;
+
+sl2vl_scope_from_list_or_asterisk: sl2vl_scope_from_asterisk
+ | sl2vl_scope_from_list_of_ranges
+ ;
+
+sl2vl_scope_from_asterisk: TK_ASTERISK {
+ int i;
+ for (i = 0; i < OSM_QOS_POLICY_MAX_PORTS_ON_SWITCH; i++)
+ p_current_sl2vl_scope->from[i] = TRUE;
+ }
+ ;
+
+sl2vl_scope_to_list_or_asterisk: sl2vl_scope_to_asterisk
+ | sl2vl_scope_to_list_of_ranges
+ ;
+
+sl2vl_scope_to_asterisk: TK_ASTERISK {
+ int i;
+ for (i = 0; i < OSM_QOS_POLICY_MAX_PORTS_ON_SWITCH; i++)
+ p_current_sl2vl_scope->to[i] = TRUE;
+ }
+ ;
+
+sl2vl_scope_from_list_of_ranges: list_of_ranges {
+ int i;
+ cl_list_iterator_t list_iterator;
+ uint64_t * num_pair;
+ uint8_t num1, num2;
+
+ list_iterator = cl_list_head(&tmp_parser_struct.num_pair_list);
+ while( list_iterator != cl_list_end(&tmp_parser_struct.num_pair_list) )
+ {
+ num_pair = (uint64_t*)cl_list_obj(list_iterator);
+ if (num_pair)
+ {
+ if ( num_pair[1] >= OSM_QOS_POLICY_MAX_PORTS_ON_SWITCH )
+ {
+ yyerror("port number out of range 'from' list");
+ free(num_pair);
+ cl_list_remove_all(&tmp_parser_struct.num_pair_list);
+ return 1;
+ }
+ num1 = (uint8_t)num_pair[0];
+ num2 = (uint8_t)num_pair[1];
+ free(num_pair);
+ for (i = num1; i <= num2; i++)
+ p_current_sl2vl_scope->from[i] = TRUE;
+ }
+ list_iterator = cl_list_next(list_iterator);
+ }
+ cl_list_remove_all(&tmp_parser_struct.num_pair_list);
+ }
+ ;
+
+sl2vl_scope_to_list_of_ranges: list_of_ranges {
+ int i;
+ cl_list_iterator_t list_iterator;
+ uint64_t * num_pair;
+ uint8_t num1, num2;
+
+ list_iterator = cl_list_head(&tmp_parser_struct.num_pair_list);
+ while( list_iterator != cl_list_end(&tmp_parser_struct.num_pair_list) )
+ {
+ num_pair = (uint64_t*)cl_list_obj(list_iterator);
+ if (num_pair)
+ {
+ if ( num_pair[1] >= OSM_QOS_POLICY_MAX_PORTS_ON_SWITCH )
+ {
+ yyerror("port number out of range 'to' list");
+ free(num_pair);
+ cl_list_remove_all(&tmp_parser_struct.num_pair_list);
+ return 1;
+ }
+ num1 = (uint8_t)num_pair[0];
+ num2 = (uint8_t)num_pair[1];
+ free(num_pair);
+ for (i = num1; i <= num2; i++)
+ p_current_sl2vl_scope->to[i] = TRUE;
+ }
+ list_iterator = cl_list_next(list_iterator);
+ }
+ cl_list_remove_all(&tmp_parser_struct.num_pair_list);
+ }
+ ;
+
+
+sl2vl_scope_sl2vl_table: sl2vl_scope_sl2vl_table_start num_list {
+ /* 'sl2vl-table' - one instance of exactly
+ OSM_QOS_POLICY_SL2VL_TABLE_LEN numbers */
+ cl_list_iterator_t list_iterator;
+ uint64_t num;
+ uint64_t * p_num;
+ int i = 0;
+
+ if (p_current_sl2vl_scope->sl2vl_table_set)
+ {
+ yyerror("sl2vl-scope has more than one sl2vl-table");
+ cl_list_remove_all(&tmp_parser_struct.num_list);
+ return 1;
+ }
+
+ if (cl_list_count(&tmp_parser_struct.num_list) != OSM_QOS_POLICY_SL2VL_TABLE_LEN)
+ {
+ yyerror("wrong number of values in 'sl2vl-table' (should be 16)");
+ cl_list_remove_all(&tmp_parser_struct.num_list);
+ return 1;
+ }
+
+ list_iterator = cl_list_head(&tmp_parser_struct.num_list);
+ while( list_iterator != cl_list_end(&tmp_parser_struct.num_list) )
+ {
+ p_num = (uint64_t*)cl_list_obj(list_iterator);
+ num = *p_num;
+ free(p_num);
+ if (num >= OSM_QOS_POLICY_MAX_VL_NUM)
+ {
+ yyerror("wrong VL value in 'sl2vl-table' (should be 0 to 15)");
+ cl_list_remove_all(&tmp_parser_struct.num_list);
+ return 1;
+ }
+
+ p_current_sl2vl_scope->sl2vl_table[i++] = (uint8_t)num;
+ list_iterator = cl_list_next(list_iterator);
+ }
+ p_current_sl2vl_scope->sl2vl_table_set = TRUE;
+ cl_list_remove_all(&tmp_parser_struct.num_list);
+ }
+ ;
+
+sl2vl_scope_sl2vl_table_start: TK_SL2VL_TABLE {
+ RESET_BUFFER;
+ }
+ ;
+
+ /*
+ * qos_level_entry values:
+ * qos_level_name
+ * qos_level_use
+ * qos_level_sl
+ * qos_level_mtu_limit
+ * qos_level_rate_limit
+ * qos_level_packet_life
+ * qos_level_path_bits
+ * qos_level_pkey
+ */
+
+qos_level_name: qos_level_name_start single_string {
+ /* 'name' of 'qos-level' - one instance */
+ cl_list_iterator_t list_iterator;
+ char * tmp_str;
+
+ if (p_current_qos_level->name)
+ {
+ yyerror("qos-level has multiple 'name' tags");
+ cl_list_remove_all(&tmp_parser_struct.str_list);
+ return 1;
+ }
+
+ list_iterator = cl_list_head(&tmp_parser_struct.str_list);
+ if ( list_iterator != cl_list_end(&tmp_parser_struct.str_list) )
+ {
+ tmp_str = (char*)cl_list_obj(list_iterator);
+ if (tmp_str)
+ p_current_qos_level->name = tmp_str;
+ }
+ cl_list_remove_all(&tmp_parser_struct.str_list);
+ }
+ ;
+
+qos_level_name_start: TK_NAME {
+ RESET_BUFFER;
+ }
+ ;
+
+qos_level_use: qos_level_use_start single_string {
+ /* 'use' of 'qos-level' - one instance */
+ cl_list_iterator_t list_iterator;
+ char * tmp_str;
+
+ if (p_current_qos_level->use)
+ {
+ yyerror("qos-level has multiple 'use' tags");
+ cl_list_remove_all(&tmp_parser_struct.str_list);
+ return 1;
+ }
+
+ list_iterator = cl_list_head(&tmp_parser_struct.str_list);
+ if ( list_iterator != cl_list_end(&tmp_parser_struct.str_list) )
+ {
+ tmp_str = (char*)cl_list_obj(list_iterator);
+ if (tmp_str)
+ p_current_qos_level->use = tmp_str;
+ }
+ cl_list_remove_all(&tmp_parser_struct.str_list);
+ }
+ ;
+
+qos_level_use_start: TK_USE {
+ RESET_BUFFER;
+ }
+ ;
+
+qos_level_sl: qos_level_sl_start single_number {
+ /* 'sl' in 'qos-level' - one instance */
+ cl_list_iterator_t list_iterator;
+ uint64_t * p_num;
+
+ if (p_current_qos_level->sl_set)
+ {
+ yyerror("'qos-level' has multiple 'sl' tags");
+ cl_list_remove_all(&tmp_parser_struct.num_list);
+ return 1;
+ }
+ list_iterator = cl_list_head(&tmp_parser_struct.num_list);
+ p_num = (uint64_t*)cl_list_obj(list_iterator);
+ p_current_qos_level->sl = (uint8_t)(*p_num);
+ free(p_num);
+ p_current_qos_level->sl_set = TRUE;
+ cl_list_remove_all(&tmp_parser_struct.num_list);
+ }
+ ;
+
+qos_level_sl_start: TK_SL {
+ RESET_BUFFER;
+ }
+ ;
+
+qos_level_mtu_limit: qos_level_mtu_limit_start single_number {
+ /* 'mtu-limit' in 'qos-level' - one instance */
+ cl_list_iterator_t list_iterator;
+ uint64_t * p_num;
+
+ if (p_current_qos_level->mtu_limit_set)
+ {
+ yyerror("'qos-level' has multiple 'mtu-limit' tags");
+ cl_list_remove_all(&tmp_parser_struct.num_list);
+ return 1;
+ }
+ list_iterator = cl_list_head(&tmp_parser_struct.num_list);
+ p_num = (uint64_t*)cl_list_obj(list_iterator);
+ if (*p_num > OSM_QOS_POLICY_MAX_MTU || *p_num < OSM_QOS_POLICY_MIN_MTU)
+ {
+ yyerror("mtu limit is out of range, value: %d", *p_num);
+ free(p_num);
+ cl_list_remove_all(&tmp_parser_struct.num_list);
+ return 1;
+ }
+ p_current_qos_level->mtu_limit = (uint8_t)(*p_num);
+ free(p_num);
+ p_current_qos_level->mtu_limit_set = TRUE;
+ cl_list_remove_all(&tmp_parser_struct.num_list);
+ }
+ ;
+
+qos_level_mtu_limit_start: TK_MTU_LIMIT {
+ /* 'mtu-limit' in 'qos-level' - one instance */
+ RESET_BUFFER;
+ }
+ ;
+
+qos_level_rate_limit: qos_level_rate_limit_start single_number {
+ /* 'rate-limit' in 'qos-level' - one instance */
+ cl_list_iterator_t list_iterator;
+ uint64_t * p_num;
+
+ if (p_current_qos_level->rate_limit_set)
+ {
+ yyerror("'qos-level' has multiple 'rate-limit' tags");
+ cl_list_remove_all(&tmp_parser_struct.num_list);
+ return 1;
+ }
+ list_iterator = cl_list_head(&tmp_parser_struct.num_list);
+ p_num = (uint64_t*)cl_list_obj(list_iterator);
+ if (*p_num > OSM_QOS_POLICY_MAX_RATE || *p_num < OSM_QOS_POLICY_MIN_RATE)
+ {
+ yyerror("rate limit is out of range, value: %d", *p_num);
+ free(p_num);
+ cl_list_remove_all(&tmp_parser_struct.num_list);
+ return 1;
+ }
+ p_current_qos_level->rate_limit = (uint8_t)(*p_num);
+ free(p_num);
+ p_current_qos_level->rate_limit_set = TRUE;
+ cl_list_remove_all(&tmp_parser_struct.num_list);
+ }
+ ;
+
+qos_level_rate_limit_start: TK_RATE_LIMIT {
+ /* 'rate-limit' in 'qos-level' - one instance */
+ RESET_BUFFER;
+ }
+ ;
+
+qos_level_packet_life: qos_level_packet_life_start single_number {
+ /* 'packet-life' in 'qos-level' - one instance */
+ cl_list_iterator_t list_iterator;
+ uint64_t * p_num;
+
+ if (p_current_qos_level->pkt_life_set)
+ {
+ yyerror("'qos-level' has multiple 'packet-life' tags");
+ cl_list_remove_all(&tmp_parser_struct.num_list);
+ return 1;
+ }
+ list_iterator = cl_list_head(&tmp_parser_struct.num_list);
+ p_num = (uint64_t*)cl_list_obj(list_iterator);
+ p_current_qos_level->pkt_life = (uint8_t)(*p_num);
+ free(p_num);
+ p_current_qos_level->pkt_life_set= TRUE;
+ cl_list_remove_all(&tmp_parser_struct.num_list);
+ }
+ ;
+
+qos_level_packet_life_start: TK_PACKET_LIFE {
+ /* 'packet-life' in 'qos-level' - one instance */
+ RESET_BUFFER;
+ }
+ ;
+
+qos_level_path_bits: qos_level_path_bits_start list_of_ranges {
+ /* 'path-bits' in 'qos-level' - any num of instances */
+ /* list of path bit ranges */
+
+ if (cl_list_count(&tmp_parser_struct.num_pair_list))
+ {
+ uint64_t ** range_arr;
+ unsigned range_len;
+
+ __rangelist2rangearr( &tmp_parser_struct.num_pair_list,
+ &range_arr,
+ &range_len );
+
+ if ( !p_current_qos_level->path_bits_range_len )
+ {
+ p_current_qos_level->path_bits_range_arr = range_arr;
+ p_current_qos_level->path_bits_range_len = range_len;
+ }
+ else
+ {
+ uint64_t ** new_range_arr;
+ unsigned new_range_len;
+ __merge_rangearr( p_current_qos_level->path_bits_range_arr,
+ p_current_qos_level->path_bits_range_len,
+ range_arr,
+ range_len,
+ &new_range_arr,
+ &new_range_len );
+ p_current_qos_level->path_bits_range_arr = new_range_arr;
+ p_current_qos_level->path_bits_range_len = new_range_len;
+ }
+ }
+ }
+ ;
+
+qos_level_path_bits_start: TK_PATH_BITS {
+ RESET_BUFFER;
+ }
+ ;
+
+qos_level_pkey: qos_level_pkey_start list_of_ranges {
+ /* 'pkey' in 'qos-level' - num of instances of list of ranges */
+ if (cl_list_count(&tmp_parser_struct.num_pair_list))
+ {
+ uint64_t ** range_arr;
+ unsigned range_len;
+
+ __pkey_rangelist2rangearr( &tmp_parser_struct.num_pair_list,
+ &range_arr,
+ &range_len );
+
+ if ( !p_current_qos_level->pkey_range_len )
+ {
+ p_current_qos_level->pkey_range_arr = range_arr;
+ p_current_qos_level->pkey_range_len = range_len;
+ }
+ else
+ {
+ uint64_t ** new_range_arr;
+ unsigned new_range_len;
+ __merge_rangearr( p_current_qos_level->pkey_range_arr,
+ p_current_qos_level->pkey_range_len,
+ range_arr,
+ range_len,
+ &new_range_arr,
+ &new_range_len );
+ p_current_qos_level->pkey_range_arr = new_range_arr;
+ p_current_qos_level->pkey_range_len = new_range_len;
+ }
+ }
+ }
+ ;
+
+qos_level_pkey_start: TK_PKEY {
+ RESET_BUFFER;
+ }
+ ;
+
+ /*
+ * qos_match_rule_entry values:
+ * qos_match_rule_use
+ * qos_match_rule_qos_class
+ * qos_match_rule_qos_level_name
+ * qos_match_rule_source
+ * qos_match_rule_destination
+ * qos_match_rule_service_id
+ * qos_match_rule_pkey
+ */
+
+
+qos_match_rule_use: qos_match_rule_use_start single_string {
+ /* 'use' of 'qos-match-rule' - one instance */
+ cl_list_iterator_t list_iterator;
+ char * tmp_str;
+
+ if (p_current_qos_match_rule->use)
+ {
+ yyerror("'qos-match-rule' has multiple 'use' tags");
+ cl_list_remove_all(&tmp_parser_struct.str_list);
+ return 1;
+ }
+
+ list_iterator = cl_list_head(&tmp_parser_struct.str_list);
+ if ( list_iterator != cl_list_end(&tmp_parser_struct.str_list) )
+ {
+ tmp_str = (char*)cl_list_obj(list_iterator);
+ if (tmp_str)
+ p_current_qos_match_rule->use = tmp_str;
+ }
+ cl_list_remove_all(&tmp_parser_struct.str_list);
+ }
+ ;
+
+qos_match_rule_use_start: TK_USE {
+ RESET_BUFFER;
+ }
+ ;
+
+qos_match_rule_qos_class: qos_match_rule_qos_class_start list_of_ranges {
+ /* 'qos-class' in 'qos-match-rule' - num of instances of list of ranges */
+ /* list of class ranges (QoS Class is 12-bit value) */
+ if (cl_list_count(&tmp_parser_struct.num_pair_list))
+ {
+ uint64_t ** range_arr;
+ unsigned range_len;
+
+ __rangelist2rangearr( &tmp_parser_struct.num_pair_list,
+ &range_arr,
+ &range_len );
+
+ if ( !p_current_qos_match_rule->qos_class_range_len )
+ {
+ p_current_qos_match_rule->qos_class_range_arr = range_arr;
+ p_current_qos_match_rule->qos_class_range_len = range_len;
+ }
+ else
+ {
+ uint64_t ** new_range_arr;
+ unsigned new_range_len;
+ __merge_rangearr( p_current_qos_match_rule->qos_class_range_arr,
+ p_current_qos_match_rule->qos_class_range_len,
+ range_arr,
+ range_len,
+ &new_range_arr,
+ &new_range_len );
+ p_current_qos_match_rule->qos_class_range_arr = new_range_arr;
+ p_current_qos_match_rule->qos_class_range_len = new_range_len;
+ }
+ }
+ }
+ ;
+
+qos_match_rule_qos_class_start: TK_QOS_CLASS {
+ RESET_BUFFER;
+ }
+ ;
+
+qos_match_rule_source: qos_match_rule_source_start string_list {
+ /* 'source' in 'qos-match-rule' - text */
+ cl_list_iterator_t list_iterator;
+ char * tmp_str;
+
+ list_iterator = cl_list_head(&tmp_parser_struct.str_list);
+ while( list_iterator != cl_list_end(&tmp_parser_struct.str_list) )
+ {
+ tmp_str = (char*)cl_list_obj(list_iterator);
+ if (tmp_str)
+ cl_list_insert_tail(&p_current_qos_match_rule->source_list,tmp_str);
+ list_iterator = cl_list_next(list_iterator);
+ }
+ cl_list_remove_all(&tmp_parser_struct.str_list);
+ }
+ ;
+
+qos_match_rule_source_start: TK_SOURCE {
+ RESET_BUFFER;
+ }
+ ;
+
+qos_match_rule_destination: qos_match_rule_destination_start string_list {
+ /* 'destination' in 'qos-match-rule' - text */
+ cl_list_iterator_t list_iterator;
+ char * tmp_str;
+
+ list_iterator = cl_list_head(&tmp_parser_struct.str_list);
+ while( list_iterator != cl_list_end(&tmp_parser_struct.str_list) )
+ {
+ tmp_str = (char*)cl_list_obj(list_iterator);
+ if (tmp_str)
+ cl_list_insert_tail(&p_current_qos_match_rule->destination_list,tmp_str);
+ list_iterator = cl_list_next(list_iterator);
+ }
+ cl_list_remove_all(&tmp_parser_struct.str_list);
+ }
+ ;
+
+qos_match_rule_destination_start: TK_DESTINATION {
+ RESET_BUFFER;
+ }
+ ;
+
+qos_match_rule_qos_level_name: qos_match_rule_qos_level_name_start single_string {
+ /* 'qos-level-name' in 'qos-match-rule' - single string */
+ cl_list_iterator_t list_iterator;
+ char * tmp_str;
+
+ if (p_current_qos_match_rule->qos_level_name)
+ {
+ yyerror("qos-match-rule has multiple 'qos-level-name' tags");
+ cl_list_remove_all(&tmp_parser_struct.num_list);
+ return 1;
+ }
+
+ list_iterator = cl_list_head(&tmp_parser_struct.str_list);
+ if ( list_iterator != cl_list_end(&tmp_parser_struct.str_list) )
+ {
+ tmp_str = (char*)cl_list_obj(list_iterator);
+ if (tmp_str)
+ p_current_qos_match_rule->qos_level_name = tmp_str;
+ }
+ cl_list_remove_all(&tmp_parser_struct.str_list);
+ }
+ ;
+
+qos_match_rule_qos_level_name_start: TK_QOS_LEVEL_NAME {
+ RESET_BUFFER;
+ }
+ ;
+
+qos_match_rule_service_id: qos_match_rule_service_id_start list_of_ranges {
+ /* 'service-id' in 'qos-match-rule' - num of instances of list of ranges */
+ if (cl_list_count(&tmp_parser_struct.num_pair_list))
+ {
+ uint64_t ** range_arr;
+ unsigned range_len;
+
+ __rangelist2rangearr( &tmp_parser_struct.num_pair_list,
+ &range_arr,
+ &range_len );
+
+ if ( !p_current_qos_match_rule->service_id_range_len )
+ {
+ p_current_qos_match_rule->service_id_range_arr = range_arr;
+ p_current_qos_match_rule->service_id_range_len = range_len;
+ }
+ else
+ {
+ uint64_t ** new_range_arr;
+ unsigned new_range_len;
+ __merge_rangearr( p_current_qos_match_rule->service_id_range_arr,
+ p_current_qos_match_rule->service_id_range_len,
+ range_arr,
+ range_len,
+ &new_range_arr,
+ &new_range_len );
+ p_current_qos_match_rule->service_id_range_arr = new_range_arr;
+ p_current_qos_match_rule->service_id_range_len = new_range_len;
+ }
+ }
+ }
+ ;
+
+qos_match_rule_service_id_start: TK_SERVICE_ID {
+ RESET_BUFFER;
+ }
+ ;
+
+qos_match_rule_pkey: qos_match_rule_pkey_start list_of_ranges {
+ /* 'pkey' in 'qos-match-rule' - num of instances of list of ranges */
+ if (cl_list_count(&tmp_parser_struct.num_pair_list))
+ {
+ uint64_t ** range_arr;
+ unsigned range_len;
+
+ __pkey_rangelist2rangearr( &tmp_parser_struct.num_pair_list,
+ &range_arr,
+ &range_len );
+
+ if ( !p_current_qos_match_rule->pkey_range_len )
+ {
+ p_current_qos_match_rule->pkey_range_arr = range_arr;
+ p_current_qos_match_rule->pkey_range_len = range_len;
+ }
+ else
+ {
+ uint64_t ** new_range_arr;
+ unsigned new_range_len;
+ __merge_rangearr( p_current_qos_match_rule->pkey_range_arr,
+ p_current_qos_match_rule->pkey_range_len,
+ range_arr,
+ range_len,
+ &new_range_arr,
+ &new_range_len );
+ p_current_qos_match_rule->pkey_range_arr = new_range_arr;
+ p_current_qos_match_rule->pkey_range_len = new_range_len;
+ }
+ }
+ }
+ ;
+
+qos_match_rule_pkey_start: TK_PKEY {
+ RESET_BUFFER;
+ }
+ ;
+
+
+ /*
+ * Common part
+ */
+
+
+single_string: single_string_elems {
+ cl_list_insert_tail(&tmp_parser_struct.str_list,
+ strdup(__parser_strip_white(tmp_parser_struct.str)));
+ tmp_parser_struct.str[0] = '\0';
+ }
+ ;
+
+single_string_elems: single_string_element
+ | single_string_elems single_string_element
+ ;
+
+single_string_element: TK_TEXT {
+ strcat(tmp_parser_struct.str,$1);
+ free($1);
+ }
+ ;
+
+
+string_list: single_string
+ | string_list TK_COMMA single_string
+ ;
+
+
+
+single_number: number
+ ;
+
+num_list: number
+ | num_list TK_COMMA number
+ ;
+
+number: TK_NUMBER {
+ uint64_t * p_num = (uint64_t*)malloc(sizeof(uint64_t));
+ __parser_str2uint64(p_num,$1);
+ free($1);
+ cl_list_insert_tail(&tmp_parser_struct.num_list, p_num);
+ }
+ ;
+
+num_list_with_dotdot: number_from_pair_1 TK_DOTDOT number_from_pair_2 {
+ uint64_t * num_pair = (uint64_t*)malloc(sizeof(uint64_t)*2);
+ num_pair[0] = tmp_parser_struct.num_pair[0];
+ num_pair[1] = tmp_parser_struct.num_pair[1];
+ cl_list_insert_tail(&tmp_parser_struct.num_pair_list, num_pair);
+ }
+ | num_list_with_dotdot TK_COMMA number_from_pair_1 TK_DOTDOT number_from_pair_2 {
+ uint64_t * num_pair = (uint64_t*)malloc(sizeof(uint64_t)*2);
+ num_pair[0] = tmp_parser_struct.num_pair[0];
+ num_pair[1] = tmp_parser_struct.num_pair[1];
+ cl_list_insert_tail(&tmp_parser_struct.num_pair_list, num_pair);
+ }
+ ;
+
+number_from_pair_1: TK_NUMBER {
+ __parser_str2uint64(&tmp_parser_struct.num_pair[0],$1);
+ free($1);
+ }
+ ;
+
+number_from_pair_2: TK_NUMBER {
+ __parser_str2uint64(&tmp_parser_struct.num_pair[1],$1);
+ free($1);
+ }
+ ;
+
+list_of_ranges: num_list_with_dash
+ ;
+
+num_list_with_dash: single_number_from_range {
+ uint64_t * num_pair = (uint64_t*)malloc(sizeof(uint64_t)*2);
+ num_pair[0] = tmp_parser_struct.num_pair[0];
+ num_pair[1] = tmp_parser_struct.num_pair[1];
+ cl_list_insert_tail(&tmp_parser_struct.num_pair_list, num_pair);
+ }
+ | number_from_range_1 TK_DASH number_from_range_2 {
+ uint64_t * num_pair = (uint64_t*)malloc(sizeof(uint64_t)*2);
+ if (tmp_parser_struct.num_pair[0] <= tmp_parser_struct.num_pair[1]) {
+ num_pair[0] = tmp_parser_struct.num_pair[0];
+ num_pair[1] = tmp_parser_struct.num_pair[1];
+ }
+ else {
+ num_pair[1] = tmp_parser_struct.num_pair[0];
+ num_pair[0] = tmp_parser_struct.num_pair[1];
+ }
+ cl_list_insert_tail(&tmp_parser_struct.num_pair_list, num_pair);
+ }
+ | num_list_with_dash TK_COMMA number_from_range_1 TK_DASH number_from_range_2 {
+ uint64_t * num_pair = (uint64_t*)malloc(sizeof(uint64_t)*2);
+ if (tmp_parser_struct.num_pair[0] <= tmp_parser_struct.num_pair[1]) {
+ num_pair[0] = tmp_parser_struct.num_pair[0];
+ num_pair[1] = tmp_parser_struct.num_pair[1];
+ }
+ else {
+ num_pair[1] = tmp_parser_struct.num_pair[0];
+ num_pair[0] = tmp_parser_struct.num_pair[1];
+ }
+ cl_list_insert_tail(&tmp_parser_struct.num_pair_list, num_pair);
+ }
+ | num_list_with_dash TK_COMMA single_number_from_range {
+ uint64_t * num_pair = (uint64_t*)malloc(sizeof(uint64_t)*2);
+ num_pair[0] = tmp_parser_struct.num_pair[0];
+ num_pair[1] = tmp_parser_struct.num_pair[1];
+ cl_list_insert_tail(&tmp_parser_struct.num_pair_list, num_pair);
+ }
+ ;
+
+single_number_from_range: TK_NUMBER {
+ __parser_str2uint64(&tmp_parser_struct.num_pair[0],$1);
+ __parser_str2uint64(&tmp_parser_struct.num_pair[1],$1);
+ free($1);
+ }
+ ;
+
+number_from_range_1: TK_NUMBER {
+ __parser_str2uint64(&tmp_parser_struct.num_pair[0],$1);
+ free($1);
+ }
+ ;
+
+number_from_range_2: TK_NUMBER {
+ __parser_str2uint64(&tmp_parser_struct.num_pair[1],$1);
+ free($1);
+ }
+ ;
+
+%%
+
+/***************************************************
+ ***************************************************/
+
+int osm_qos_parse_policy_file(IN osm_subn_t * p_subn)
+{
+ int res = 0;
+ static boolean_t first_time = TRUE;
+ p_qos_parser_osm_log = &p_subn->p_osm->log;
+
+ OSM_LOG_ENTER(p_qos_parser_osm_log);
+
+ osm_qos_policy_destroy(p_subn->p_qos_policy);
+ p_subn->p_qos_policy = NULL;
+
+ yyin = fopen (p_subn->opt.qos_policy_file, "r");
+ if (!yyin)
+ {
+ if (strcmp(p_subn->opt.qos_policy_file,OSM_DEFAULT_QOS_POLICY_FILE)) {
+ OSM_LOG(p_qos_parser_osm_log, OSM_LOG_ERROR, "ERR AC01: "
+ "Failed opening QoS policy file %s - %s\n",
+ p_subn->opt.qos_policy_file, strerror(errno));
+ res = 1;
+ }
+ else
+ OSM_LOG(p_qos_parser_osm_log, OSM_LOG_VERBOSE,
+ "QoS policy file not found (%s)\n",
+ p_subn->opt.qos_policy_file);
+
+ goto Exit;
+ }
+
+ if (first_time)
+ {
+ first_time = FALSE;
+ __setup_simple_qos_levels();
+ __setup_ulp_match_rules();
+ OSM_LOG(p_qos_parser_osm_log, OSM_LOG_INFO,
+ "Loading QoS policy file (%s)\n",
+ p_subn->opt.qos_policy_file);
+ }
+ else
+ /*
+ * ULP match rules list was emptied at the end of
+ * previous parsing iteration.
+ * What's left is to clear simple QoS levels.
+ */
+ __clear_simple_qos_levels();
+
+ column_num = 1;
+ line_num = 1;
+
+ p_subn->p_qos_policy = osm_qos_policy_create(p_subn);
+
+ __parser_tmp_struct_init();
+ p_qos_policy = p_subn->p_qos_policy;
+
+ res = yyparse();
+
+ __parser_tmp_struct_destroy();
+
+ if (res != 0)
+ {
+ OSM_LOG(p_qos_parser_osm_log, OSM_LOG_ERROR, "ERR AC03: "
+ "Failed parsing QoS policy file (%s)\n",
+ p_subn->opt.qos_policy_file);
+ osm_qos_policy_destroy(p_subn->p_qos_policy);
+ p_subn->p_qos_policy = NULL;
+ res = 1;
+ goto Exit;
+ }
+
+ /* add generated ULP match rules to the usual match rules */
+ __process_ulp_match_rules();
+
+ if (osm_qos_policy_validate(p_subn->p_qos_policy,p_qos_parser_osm_log))
+ {
+ OSM_LOG(p_qos_parser_osm_log, OSM_LOG_ERROR, "ERR AC04: "
+ "Error(s) in QoS policy file (%s)\n",
+ p_subn->opt.qos_policy_file);
+ fprintf(stderr, "Error(s) in QoS policy file (%s)\n",
+ p_subn->opt.qos_policy_file);
+ osm_qos_policy_destroy(p_subn->p_qos_policy);
+ p_subn->p_qos_policy = NULL;
+ res = 1;
+ goto Exit;
+ }
+
+ Exit:
+ if (yyin)
+ {
+ yyrestart(yyin);
+ fclose(yyin);
+ }
+ OSM_LOG_EXIT(p_qos_parser_osm_log);
+ return res;
+}
+
+/***************************************************
+ ***************************************************/
+
+int yywrap()
+{
+ return(1);
+}
+
+/***************************************************
+ ***************************************************/
+
+static void yyerror(const char *format, ...)
+{
+ char s[256];
+ va_list pvar;
+
+ OSM_LOG_ENTER(p_qos_parser_osm_log);
+
+ va_start(pvar, format);
+ vsnprintf(s, sizeof(s), format, pvar);
+ va_end(pvar);
+
+ OSM_LOG(p_qos_parser_osm_log, OSM_LOG_ERROR, "ERR AC05: "
+ "Syntax error (line %d:%d): %s\n",
+ line_num, column_num, s);
+ fprintf(stderr, "Error in QoS Policy File (line %d:%d): %s.\n",
+ line_num, column_num, s);
+ OSM_LOG_EXIT(p_qos_parser_osm_log);
+}
+
+/***************************************************
+ ***************************************************/
+
+static char * __parser_strip_white(char * str)
+{
+ char *p;
+
+ while (isspace(*str))
+ str++;
+ if (!*str)
+ return str;
+ p = str + strlen(str) - 1;
+ while (isspace(*p))
+ *p-- = '\0';
+
+ return str;
+}
+
+/***************************************************
+ ***************************************************/
+
+static void __parser_str2uint64(uint64_t * p_val, char * str)
+{
+ *p_val = strtoull(str, NULL, 0);
+}
+
+/***************************************************
+ ***************************************************/
+
+static void __parser_port_group_start()
+{
+ p_current_port_group = osm_qos_policy_port_group_create();
+}
+
+/***************************************************
+ ***************************************************/
+
+static int __parser_port_group_end()
+{
+ if(!p_current_port_group->name)
+ {
+ yyerror("port-group validation failed - no port group name specified");
+ return -1;
+ }
+
+ cl_list_insert_tail(&p_qos_policy->port_groups,
+ p_current_port_group);
+ p_current_port_group = NULL;
+ return 0;
+}
+
+/***************************************************
+ ***************************************************/
+
+static void __parser_vlarb_scope_start()
+{
+ p_current_vlarb_scope = osm_qos_policy_vlarb_scope_create();
+}
+
+/***************************************************
+ ***************************************************/
+
+static int __parser_vlarb_scope_end()
+{
+ if ( !cl_list_count(&p_current_vlarb_scope->group_list) &&
+ !cl_list_count(&p_current_vlarb_scope->across_list) )
+ {
+ yyerror("vlarb-scope validation failed - no port groups specified by 'group' or by 'across'");
+ return -1;
+ }
+
+ cl_list_insert_tail(&p_qos_policy->vlarb_tables,
+ p_current_vlarb_scope);
+ p_current_vlarb_scope = NULL;
+ return 0;
+}
+
+/***************************************************
+ ***************************************************/
+
+static void __parser_sl2vl_scope_start()
+{
+ p_current_sl2vl_scope = osm_qos_policy_sl2vl_scope_create();
+}
+
+/***************************************************
+ ***************************************************/
+
+static int __parser_sl2vl_scope_end()
+{
+ if (!p_current_sl2vl_scope->sl2vl_table_set)
+ {
+ yyerror("sl2vl-scope validation failed - no sl2vl table specified");
+ return -1;
+ }
+ if ( !cl_list_count(&p_current_sl2vl_scope->group_list) &&
+ !cl_list_count(&p_current_sl2vl_scope->across_to_list) &&
+ !cl_list_count(&p_current_sl2vl_scope->across_from_list) )
+ {
+ yyerror("sl2vl-scope validation failed - no port groups specified by 'group', 'across-to' or 'across-from'");
+ return -1;
+ }
+
+ cl_list_insert_tail(&p_qos_policy->sl2vl_tables,
+ p_current_sl2vl_scope);
+ p_current_sl2vl_scope = NULL;
+ return 0;
+}
+
+/***************************************************
+ ***************************************************/
+
+static void __parser_qos_level_start()
+{
+ p_current_qos_level = osm_qos_policy_qos_level_create();
+}
+
+/***************************************************
+ ***************************************************/
+
+static int __parser_qos_level_end()
+{
+ if (!p_current_qos_level->sl_set)
+ {
+ yyerror("qos-level validation failed - no 'sl' specified");
+ return -1;
+ }
+ if (!p_current_qos_level->name)
+ {
+ yyerror("qos-level validation failed - no 'name' specified");
+ return -1;
+ }
+
+ cl_list_insert_tail(&p_qos_policy->qos_levels,
+ p_current_qos_level);
+ p_current_qos_level = NULL;
+ return 0;
+}
+
+/***************************************************
+ ***************************************************/
+
+static void __parser_match_rule_start()
+{
+ p_current_qos_match_rule = osm_qos_policy_match_rule_create();
+}
+
+/***************************************************
+ ***************************************************/
+
+static int __parser_match_rule_end()
+{
+ if (!p_current_qos_match_rule->qos_level_name)
+ {
+ yyerror("match-rule validation failed - no 'qos-level-name' specified");
+ return -1;
+ }
+
+ cl_list_insert_tail(&p_qos_policy->qos_match_rules,
+ p_current_qos_match_rule);
+ p_current_qos_match_rule = NULL;
+ return 0;
+}
+
+/***************************************************
+ ***************************************************/
+
+static void __parser_ulp_match_rule_start()
+{
+ p_current_qos_match_rule = osm_qos_policy_match_rule_create();
+}
+
+/***************************************************
+ ***************************************************/
+
+static int __parser_ulp_match_rule_end()
+{
+ CL_ASSERT(p_current_qos_match_rule->p_qos_level);
+ cl_list_insert_tail(&__ulp_match_rules,
+ p_current_qos_match_rule);
+ p_current_qos_match_rule = NULL;
+ return 0;
+}
+
+/***************************************************
+ ***************************************************/
+
+static void __parser_tmp_struct_init()
+{
+ tmp_parser_struct.str[0] = '\0';
+ cl_list_construct(&tmp_parser_struct.str_list);
+ cl_list_init(&tmp_parser_struct.str_list, 10);
+ cl_list_construct(&tmp_parser_struct.num_list);
+ cl_list_init(&tmp_parser_struct.num_list, 10);
+ cl_list_construct(&tmp_parser_struct.num_pair_list);
+ cl_list_init(&tmp_parser_struct.num_pair_list, 10);
+}
+
+/***************************************************
+ ***************************************************/
+
+/*
+ * Do NOT free objects from the temp struct.
+ * Either they are inserted into the parse tree data
+ * structure, or they are already freed when copying
+ * their values to the parse tree data structure.
+ */
+static void __parser_tmp_struct_reset()
+{
+ tmp_parser_struct.str[0] = '\0';
+ cl_list_remove_all(&tmp_parser_struct.str_list);
+ cl_list_remove_all(&tmp_parser_struct.num_list);
+ cl_list_remove_all(&tmp_parser_struct.num_pair_list);
+}
+
+/***************************************************
+ ***************************************************/
+
+static void __parser_tmp_struct_destroy()
+{
+ __parser_tmp_struct_reset();
+ cl_list_destroy(&tmp_parser_struct.str_list);
+ cl_list_destroy(&tmp_parser_struct.num_list);
+ cl_list_destroy(&tmp_parser_struct.num_pair_list);
+}
+
+/***************************************************
+ ***************************************************/
+
+#define __SIMPLE_QOS_LEVEL_NAME "SimpleQoSLevel_SL"
+#define __SIMPLE_QOS_LEVEL_DEFAULT_NAME "SimpleQoSLevel_DEFAULT"
+
+static void __setup_simple_qos_levels()
+{
+ uint8_t i;
+ char tmp_buf[30];
+ memset(osm_qos_policy_simple_qos_levels, 0,
+ sizeof(osm_qos_policy_simple_qos_levels));
+ for (i = 0; i < 16; i++)
+ {
+ osm_qos_policy_simple_qos_levels[i].sl = i;
+ osm_qos_policy_simple_qos_levels[i].sl_set = TRUE;
+ sprintf(tmp_buf, "%s%u", __SIMPLE_QOS_LEVEL_NAME, i);
+ osm_qos_policy_simple_qos_levels[i].name = strdup(tmp_buf);
+ }
+
+ memset(&__default_simple_qos_level, 0,
+ sizeof(__default_simple_qos_level));
+ __default_simple_qos_level.name =
+ strdup(__SIMPLE_QOS_LEVEL_DEFAULT_NAME);
+}
+
+/***************************************************
+ ***************************************************/
+
+static void __clear_simple_qos_levels()
+{
+ /*
+ * Simple QoS levels are static.
+ * What's left is to invalidate default simple QoS level.
+ */
+ __default_simple_qos_level.sl_set = FALSE;
+}
+
+/***************************************************
+ ***************************************************/
+
+static void __setup_ulp_match_rules()
+{
+ cl_list_construct(&__ulp_match_rules);
+ cl_list_init(&__ulp_match_rules, 10);
+}
+
+/***************************************************
+ ***************************************************/
+
+static void __process_ulp_match_rules()
+{
+ cl_list_iterator_t list_iterator;
+ osm_qos_match_rule_t *p_qos_match_rule = NULL;
+
+ list_iterator = cl_list_head(&__ulp_match_rules);
+ while (list_iterator != cl_list_end(&__ulp_match_rules))
+ {
+ p_qos_match_rule = (osm_qos_match_rule_t *) cl_list_obj(list_iterator);
+ if (p_qos_match_rule)
+ cl_list_insert_tail(&p_qos_policy->qos_match_rules,
+ p_qos_match_rule);
+ list_iterator = cl_list_next(list_iterator);
+ }
+ cl_list_remove_all(&__ulp_match_rules);
+}
+
+/***************************************************
+ ***************************************************/
+
+static int __cmp_num_range(const void * p1, const void * p2)
+{
+ uint64_t * pair1 = *((uint64_t **)p1);
+ uint64_t * pair2 = *((uint64_t **)p2);
+
+ if (pair1[0] < pair2[0])
+ return -1;
+ if (pair1[0] > pair2[0])
+ return 1;
+
+ if (pair1[1] < pair2[1])
+ return -1;
+ if (pair1[1] > pair2[1])
+ return 1;
+
+ return 0;
+}
+
+/***************************************************
+ ***************************************************/
+
+static void __sort_reduce_rangearr(
+ uint64_t ** arr,
+ unsigned arr_len,
+ uint64_t ** * p_res_arr,
+ unsigned * p_res_arr_len )
+{
+ unsigned i = 0;
+ unsigned j = 0;
+ unsigned last_valid_ind = 0;
+ unsigned valid_cnt = 0;
+ uint64_t ** res_arr;
+ boolean_t * is_valid_arr;
+
+ *p_res_arr = NULL;
+ *p_res_arr_len = 0;
+
+ qsort(arr, arr_len, sizeof(uint64_t*), __cmp_num_range);
+
+ is_valid_arr = (boolean_t *)malloc(arr_len * sizeof(boolean_t));
+ is_valid_arr[last_valid_ind] = TRUE;
+ valid_cnt++;
+ for (i = 1; i < arr_len; i++)
+ {
+ if (arr[i][0] <= arr[last_valid_ind][1])
+ {
+ if (arr[i][1] > arr[last_valid_ind][1])
+ arr[last_valid_ind][1] = arr[i][1];
+ free(arr[i]);
+ arr[i] = NULL;
+ is_valid_arr[i] = FALSE;
+ }
+ else if ((arr[i][0] - 1) == arr[last_valid_ind][1])
+ {
+ arr[last_valid_ind][1] = arr[i][1];
+ free(arr[i]);
+ arr[i] = NULL;
+ is_valid_arr[i] = FALSE;
+ }
+ else
+ {
+ is_valid_arr[i] = TRUE;
+ last_valid_ind = i;
+ valid_cnt++;
+ }
+ }
+
+ res_arr = (uint64_t **)malloc(valid_cnt * sizeof(uint64_t *));
+ for (i = 0; i < arr_len; i++)
+ {
+ if (is_valid_arr[i])
+ res_arr[j++] = arr[i];
+ }
+ free(is_valid_arr);
+ free(arr);
+
+ *p_res_arr = res_arr;
+ *p_res_arr_len = valid_cnt;
+}
+
+/***************************************************
+ ***************************************************/
+
+static void __pkey_rangelist2rangearr(
+ cl_list_t * p_list,
+ uint64_t ** * p_arr,
+ unsigned * p_arr_len)
+{
+ uint64_t tmp_pkey;
+ uint64_t * p_pkeys;
+ cl_list_iterator_t list_iterator;
+
+ list_iterator= cl_list_head(p_list);
+ while( list_iterator != cl_list_end(p_list) )
+ {
+ p_pkeys = (uint64_t *)cl_list_obj(list_iterator);
+ p_pkeys[0] &= 0x7fff;
+ p_pkeys[1] &= 0x7fff;
+ if (p_pkeys[0] > p_pkeys[1])
+ {
+ tmp_pkey = p_pkeys[1];
+ p_pkeys[1] = p_pkeys[0];
+ p_pkeys[0] = tmp_pkey;
+ }
+ list_iterator = cl_list_next(list_iterator);
+ }
+
+ __rangelist2rangearr(p_list, p_arr, p_arr_len);
+}
+
+/***************************************************
+ ***************************************************/
+
+static void __rangelist2rangearr(
+ cl_list_t * p_list,
+ uint64_t ** * p_arr,
+ unsigned * p_arr_len)
+{
+ cl_list_iterator_t list_iterator;
+ unsigned len = cl_list_count(p_list);
+ unsigned i = 0;
+ uint64_t ** tmp_arr;
+ uint64_t ** res_arr = NULL;
+ unsigned res_arr_len = 0;
+
+ tmp_arr = (uint64_t **)malloc(len * sizeof(uint64_t *));
+
+ list_iterator = cl_list_head(p_list);
+ while( list_iterator != cl_list_end(p_list) )
+ {
+ tmp_arr[i++] = (uint64_t *)cl_list_obj(list_iterator);
+ list_iterator = cl_list_next(list_iterator);
+ }
+ cl_list_remove_all(p_list);
+
+ __sort_reduce_rangearr( tmp_arr,
+ len,
+ &res_arr,
+ &res_arr_len );
+ *p_arr = res_arr;
+ *p_arr_len = res_arr_len;
+}
+
+/***************************************************
+ ***************************************************/
+
+static void __merge_rangearr(
+ uint64_t ** range_arr_1,
+ unsigned range_len_1,
+ uint64_t ** range_arr_2,
+ unsigned range_len_2,
+ uint64_t ** * p_arr,
+ unsigned * p_arr_len )
+{
+ unsigned i = 0;
+ unsigned j = 0;
+ unsigned len = range_len_1 + range_len_2;
+ uint64_t ** tmp_arr;
+ uint64_t ** res_arr = NULL;
+ unsigned res_arr_len = 0;
+
+ *p_arr = NULL;
+ *p_arr_len = 0;
+
+ tmp_arr = (uint64_t **)malloc(len * sizeof(uint64_t *));
+
+ for (i = 0; i < range_len_1; i++)
+ tmp_arr[j++] = range_arr_1[i];
+ for (i = 0; i < range_len_2; i++)
+ tmp_arr[j++] = range_arr_2[i];
+ free(range_arr_1);
+ free(range_arr_2);
+
+ __sort_reduce_rangearr( tmp_arr,
+ len,
+ &res_arr,
+ &res_arr_len );
+ *p_arr = res_arr;
+ *p_arr_len = res_arr_len;
+}
+
+/***************************************************
+ ***************************************************/
+
+static void __parser_add_port_to_port_map(
+ cl_qmap_t * p_map,
+ osm_physp_t * p_physp)
+{
+ if (cl_qmap_get(p_map, cl_ntoh64(osm_physp_get_port_guid(p_physp))) ==
+ cl_qmap_end(p_map))
+ {
+ osm_qos_port_t * p_port = osm_qos_policy_port_create(p_physp);
+ if (p_port)
+ cl_qmap_insert(p_map,
+ cl_ntoh64(osm_physp_get_port_guid(p_physp)),
+ &p_port->map_item);
+ }
+}
+
+/***************************************************
+ ***************************************************/
+
+static void __parser_add_guid_range_to_port_map(
+ cl_qmap_t * p_map,
+ uint64_t ** range_arr,
+ unsigned range_len)
+{
+ unsigned i;
+ uint64_t guid_ho;
+ osm_port_t * p_osm_port;
+
+ if (!range_arr || !range_len)
+ return;
+
+ for (i = 0; i < range_len; i++) {
+ for (guid_ho = range_arr[i][0]; guid_ho <= range_arr[i][1]; guid_ho++) {
+ p_osm_port =
+ osm_get_port_by_guid(p_qos_policy->p_subn, cl_hton64(guid_ho));
+ if (p_osm_port)
+ __parser_add_port_to_port_map(p_map, p_osm_port->p_physp);
+ }
+ free(range_arr[i]);
+ }
+ free(range_arr);
+}
+
+/***************************************************
+ ***************************************************/
+
+static void __parser_add_pkey_range_to_port_map(
+ cl_qmap_t * p_map,
+ uint64_t ** range_arr,
+ unsigned range_len)
+{
+ unsigned i;
+ uint64_t pkey_64;
+ ib_net16_t pkey;
+ osm_prtn_t * p_prtn;
+
+ if (!range_arr || !range_len)
+ return;
+
+ for (i = 0; i < range_len; i++) {
+ for (pkey_64 = range_arr[i][0]; pkey_64 <= range_arr[i][1]; pkey_64++) {
+ pkey = cl_hton16((uint16_t)(pkey_64 & 0x7fff));
+ p_prtn = (osm_prtn_t *)
+ cl_qmap_get(&p_qos_policy->p_subn->prtn_pkey_tbl, pkey);
+ if (p_prtn != (osm_prtn_t *)cl_qmap_end(
+ &p_qos_policy->p_subn->prtn_pkey_tbl)) {
+ __parser_add_map_to_port_map(p_map, &p_prtn->part_guid_tbl);
+ __parser_add_map_to_port_map(p_map, &p_prtn->full_guid_tbl);
+ }
+ }
+ free(range_arr[i]);
+ }
+ free(range_arr);
+}
+
+/***************************************************
+ ***************************************************/
+
+static void __parser_add_partition_list_to_port_map(
+ cl_qmap_t * p_map,
+ cl_list_t * p_list)
+{
+ cl_list_iterator_t list_iterator;
+ char * tmp_str;
+ osm_prtn_t * p_prtn;
+
+ /* extract all the ports from the partition
+ to the port map of this port group */
+ list_iterator = cl_list_head(p_list);
+ while(list_iterator != cl_list_end(p_list)) {
+ tmp_str = (char*)cl_list_obj(list_iterator);
+ if (tmp_str) {
+ p_prtn = osm_prtn_find_by_name(p_qos_policy->p_subn, tmp_str);
+ if (p_prtn) {
+ __parser_add_map_to_port_map(p_map, &p_prtn->part_guid_tbl);
+ __parser_add_map_to_port_map(p_map, &p_prtn->full_guid_tbl);
+ }
+ free(tmp_str);
+ }
+ list_iterator = cl_list_next(list_iterator);
+ }
+ cl_list_remove_all(p_list);
+}
+
+/***************************************************
+ ***************************************************/
+
+static void __parser_add_map_to_port_map(
+ cl_qmap_t * p_dmap,
+ cl_map_t * p_smap)
+{
+ cl_map_iterator_t map_iterator;
+ osm_physp_t * p_physp;
+
+ if (!p_dmap || !p_smap)
+ return;
+
+ map_iterator = cl_map_head(p_smap);
+ while (map_iterator != cl_map_end(p_smap)) {
+ p_physp = (osm_physp_t*)cl_map_obj(map_iterator);
+ __parser_add_port_to_port_map(p_dmap, p_physp);
+ map_iterator = cl_map_next(map_iterator);
+ }
+}
+
+/***************************************************
+ ***************************************************/
+
+static int __validate_pkeys( uint64_t ** range_arr,
+ unsigned range_len,
+ boolean_t is_ipoib)
+{
+ unsigned i;
+ uint64_t pkey_64;
+ ib_net16_t pkey;
+ osm_prtn_t * p_prtn;
+
+ if (!range_arr || !range_len)
+ return 0;
+
+ for (i = 0; i < range_len; i++) {
+ for (pkey_64 = range_arr[i][0]; pkey_64 <= range_arr[i][1]; pkey_64++) {
+ pkey = cl_hton16((uint16_t)(pkey_64 & 0x7fff));
+ p_prtn = (osm_prtn_t *)
+ cl_qmap_get(&p_qos_policy->p_subn->prtn_pkey_tbl, pkey);
+
+ if (p_prtn == (osm_prtn_t *)cl_qmap_end(
+ &p_qos_policy->p_subn->prtn_pkey_tbl))
+ p_prtn = NULL;
+
+ if (is_ipoib) {
+ /*
+ * Be very strict for IPoIB partition:
+ * - the partition for the pkey have to exist
+ * - it has to have at least 2 full members
+ */
+ if (!p_prtn) {
+ yyerror("IPoIB partition, pkey 0x%04X - "
+ "partition doesn't exist",
+ cl_ntoh16(pkey));
+ return 1;
+ }
+ else if (cl_map_count(&p_prtn->full_guid_tbl) < 2) {
+ yyerror("IPoIB partition, pkey 0x%04X - "
+ "partition has less than two full members",
+ cl_ntoh16(pkey));
+ return 1;
+ }
+ }
+ else if (!p_prtn) {
+ /*
+ * For non-IPoIB pkey we just want to check that
+ * the relevant partition exists.
+ * And even if it doesn't, don't exit - just print
+ * error message and continue.
+ */
+ OSM_LOG(p_qos_parser_osm_log, OSM_LOG_ERROR, "ERR AC02: "
+ "pkey 0x%04X - partition doesn't exist",
+ cl_ntoh16(pkey));
+ }
+ }
+ }
+ return 0;
+}
+
+/***************************************************
+ ***************************************************/
diff --git a/contrib/ofed/opensm/opensm/osm_qos_policy.c b/contrib/ofed/opensm/opensm/osm_qos_policy.c
new file mode 100644
index 0000000..54d351a
--- /dev/null
+++ b/contrib/ofed/opensm/opensm/osm_qos_policy.c
@@ -0,0 +1,1065 @@
+/*
+ * Copyright (c) 2004-2009 Voltaire, Inc. All rights reserved.
+ * Copyright (c) 2002-2012 Mellanox Technologies LTD. All rights reserved.
+ * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
+ * Copyright (c) 2008 Xsigo Systems Inc. All rights reserved.
+ * Copyright (c) 2009 HNR Consulting. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+/*
+ * Abstract:
+ * OSM QoS Policy functions.
+ *
+ * Author:
+ * Yevgeny Kliteynik, Mellanox
+ */
+
+#include <stdio.h>
+#include <assert.h>
+#include <stdlib.h>
+#include <string.h>
+#include <ctype.h>
+#include <arpa/inet.h>
+#include <opensm/osm_file_ids.h>
+#define FILE_ID OSM_FILE_QOS_POLICY_C
+#include <opensm/osm_log.h>
+#include <opensm/osm_node.h>
+#include <opensm/osm_port.h>
+#include <opensm/osm_partition.h>
+#include <opensm/osm_opensm.h>
+#include <opensm/osm_qos_policy.h>
+
+extern osm_qos_level_t __default_simple_qos_level;
+
+/***************************************************
+ ***************************************************/
+
+static void
+__build_nodebyname_hash(osm_qos_policy_t * p_qos_policy)
+{
+ osm_node_t * p_node;
+ cl_qmap_t * p_node_guid_tbl = &p_qos_policy->p_subn->node_guid_tbl;
+
+ p_qos_policy->p_node_hash = st_init_strtable();
+ CL_ASSERT(p_qos_policy->p_node_hash);
+
+ if (!p_node_guid_tbl || !cl_qmap_count(p_node_guid_tbl))
+ return;
+
+ for (p_node = (osm_node_t *) cl_qmap_head(p_node_guid_tbl);
+ p_node != (osm_node_t *) cl_qmap_end(p_node_guid_tbl);
+ p_node = (osm_node_t *) cl_qmap_next(&p_node->map_item)) {
+ if (!st_lookup(p_qos_policy->p_node_hash,
+ (st_data_t)p_node->print_desc, NULL))
+ st_insert(p_qos_policy->p_node_hash,
+ (st_data_t)p_node->print_desc,
+ (st_data_t)p_node);
+ }
+}
+
+/***************************************************
+ ***************************************************/
+
+static boolean_t
+__is_num_in_range_arr(uint64_t ** range_arr,
+ unsigned range_arr_len, uint64_t num)
+{
+ unsigned ind_1 = 0;
+ unsigned ind_2 = range_arr_len - 1;
+ unsigned ind_mid;
+
+ if (!range_arr || !range_arr_len)
+ return FALSE;
+
+ while (ind_1 <= ind_2) {
+ if (num < range_arr[ind_1][0] || num > range_arr[ind_2][1])
+ return FALSE;
+ else if (num <= range_arr[ind_1][1] || num >= range_arr[ind_2][0])
+ return TRUE;
+
+ ind_mid = ind_1 + (ind_2 - ind_1 + 1)/2;
+
+ if (num < range_arr[ind_mid][0])
+ ind_2 = ind_mid;
+ else if (num > range_arr[ind_mid][1])
+ ind_1 = ind_mid;
+ else
+ return TRUE;
+
+ ind_1++;
+ ind_2--;
+ }
+
+ return FALSE;
+}
+
+/***************************************************
+ ***************************************************/
+
+static void __free_single_element(void *p_element, void *context)
+{
+ if (p_element)
+ free(p_element);
+}
+
+/***************************************************
+ ***************************************************/
+
+osm_qos_port_t *osm_qos_policy_port_create(osm_physp_t *p_physp)
+{
+ osm_qos_port_t *p =
+ (osm_qos_port_t *) calloc(1, sizeof(osm_qos_port_t));
+ if (p)
+ p->p_physp = p_physp;
+ return p;
+}
+
+/***************************************************
+ ***************************************************/
+
+osm_qos_port_group_t *osm_qos_policy_port_group_create()
+{
+ osm_qos_port_group_t *p =
+ (osm_qos_port_group_t *) calloc(1, sizeof(osm_qos_port_group_t));
+ if (p)
+ cl_qmap_init(&p->port_map);
+ return p;
+}
+
+/***************************************************
+ ***************************************************/
+
+void osm_qos_policy_port_group_destroy(osm_qos_port_group_t * p)
+{
+ osm_qos_port_t * p_port;
+ osm_qos_port_t * p_old_port;
+
+ if (!p)
+ return;
+
+ if (p->name)
+ free(p->name);
+ if (p->use)
+ free(p->use);
+
+ p_port = (osm_qos_port_t *) cl_qmap_head(&p->port_map);
+ while (p_port != (osm_qos_port_t *) cl_qmap_end(&p->port_map))
+ {
+ p_old_port = p_port;
+ p_port = (osm_qos_port_t *) cl_qmap_next(&p_port->map_item);
+ free(p_old_port);
+ }
+ cl_qmap_remove_all(&p->port_map);
+
+ free(p);
+}
+
+/***************************************************
+ ***************************************************/
+
+osm_qos_vlarb_scope_t *osm_qos_policy_vlarb_scope_create()
+{
+ osm_qos_vlarb_scope_t *p =
+ (osm_qos_vlarb_scope_t *) calloc(1, sizeof(osm_qos_vlarb_scope_t));
+ if (p) {
+ cl_list_init(&p->group_list, 10);
+ cl_list_init(&p->across_list, 10);
+ cl_list_init(&p->vlarb_high_list, 10);
+ cl_list_init(&p->vlarb_low_list, 10);
+ }
+ return p;
+}
+
+/***************************************************
+ ***************************************************/
+
+void osm_qos_policy_vlarb_scope_destroy(osm_qos_vlarb_scope_t * p)
+{
+ if (!p)
+ return;
+
+ cl_list_apply_func(&p->group_list, __free_single_element, NULL);
+ cl_list_apply_func(&p->across_list, __free_single_element, NULL);
+ cl_list_apply_func(&p->vlarb_high_list, __free_single_element, NULL);
+ cl_list_apply_func(&p->vlarb_low_list, __free_single_element, NULL);
+
+ cl_list_remove_all(&p->group_list);
+ cl_list_remove_all(&p->across_list);
+ cl_list_remove_all(&p->vlarb_high_list);
+ cl_list_remove_all(&p->vlarb_low_list);
+
+ cl_list_destroy(&p->group_list);
+ cl_list_destroy(&p->across_list);
+ cl_list_destroy(&p->vlarb_high_list);
+ cl_list_destroy(&p->vlarb_low_list);
+
+ free(p);
+}
+
+/***************************************************
+ ***************************************************/
+
+osm_qos_sl2vl_scope_t *osm_qos_policy_sl2vl_scope_create()
+{
+ osm_qos_sl2vl_scope_t *p =
+ (osm_qos_sl2vl_scope_t *) calloc(1, sizeof(osm_qos_sl2vl_scope_t));
+ if (p) {
+ cl_list_init(&p->group_list, 10);
+ cl_list_init(&p->across_from_list, 10);
+ cl_list_init(&p->across_to_list, 10);
+ }
+ return p;
+}
+
+/***************************************************
+ ***************************************************/
+
+void osm_qos_policy_sl2vl_scope_destroy(osm_qos_sl2vl_scope_t * p)
+{
+ if (!p)
+ return;
+
+ cl_list_apply_func(&p->group_list, __free_single_element, NULL);
+ cl_list_apply_func(&p->across_from_list, __free_single_element, NULL);
+ cl_list_apply_func(&p->across_to_list, __free_single_element, NULL);
+
+ cl_list_remove_all(&p->group_list);
+ cl_list_remove_all(&p->across_from_list);
+ cl_list_remove_all(&p->across_to_list);
+
+ cl_list_destroy(&p->group_list);
+ cl_list_destroy(&p->across_from_list);
+ cl_list_destroy(&p->across_to_list);
+
+ free(p);
+}
+
+/***************************************************
+ ***************************************************/
+
+osm_qos_level_t *osm_qos_policy_qos_level_create()
+{
+ osm_qos_level_t *p =
+ (osm_qos_level_t *) calloc(1, sizeof(osm_qos_level_t));
+ return p;
+}
+
+/***************************************************
+ ***************************************************/
+
+void osm_qos_policy_qos_level_destroy(osm_qos_level_t * p)
+{
+ unsigned i;
+
+ if (!p)
+ return;
+
+ free(p->name);
+ free(p->use);
+
+ for (i = 0; i < p->path_bits_range_len; i++)
+ free(p->path_bits_range_arr[i]);
+ free(p->path_bits_range_arr);
+
+ for(i = 0; i < p->pkey_range_len; i++)
+ free((p->pkey_range_arr[i]));
+ free(p->pkey_range_arr);
+
+ free(p);
+}
+
+/***************************************************
+ ***************************************************/
+
+boolean_t osm_qos_level_has_pkey(IN const osm_qos_level_t * p_qos_level,
+ IN ib_net16_t pkey)
+{
+ if (!p_qos_level || !p_qos_level->pkey_range_len)
+ return FALSE;
+ return __is_num_in_range_arr(p_qos_level->pkey_range_arr,
+ p_qos_level->pkey_range_len,
+ cl_ntoh16(ib_pkey_get_base(pkey)));
+}
+
+/***************************************************
+ ***************************************************/
+
+ib_net16_t osm_qos_level_get_shared_pkey(IN const osm_qos_level_t * p_qos_level,
+ IN const osm_physp_t * p_src_physp,
+ IN const osm_physp_t * p_dest_physp,
+ IN const boolean_t allow_both_pkeys)
+{
+ unsigned i;
+ uint16_t pkey_ho = 0;
+
+ if (!p_qos_level || !p_qos_level->pkey_range_len)
+ return 0;
+
+ /*
+ * ToDo: This approach is not optimal.
+ * Think how to find shared pkey that also exists
+ * in QoS level in less runtime.
+ */
+
+ for (i = 0; i < p_qos_level->pkey_range_len; i++) {
+ for (pkey_ho = p_qos_level->pkey_range_arr[i][0];
+ pkey_ho <= p_qos_level->pkey_range_arr[i][1]; pkey_ho++) {
+ if (osm_physp_share_this_pkey
+ (p_src_physp, p_dest_physp, cl_hton16(pkey_ho),
+ allow_both_pkeys))
+ return cl_hton16(pkey_ho);
+ }
+ }
+
+ return 0;
+}
+
+/***************************************************
+ ***************************************************/
+
+osm_qos_match_rule_t *osm_qos_policy_match_rule_create()
+{
+ osm_qos_match_rule_t *p =
+ (osm_qos_match_rule_t *) calloc(1, sizeof(osm_qos_match_rule_t));
+ if (p) {
+ cl_list_init(&p->source_list, 10);
+ cl_list_init(&p->source_group_list, 10);
+ cl_list_init(&p->destination_list, 10);
+ cl_list_init(&p->destination_group_list, 10);
+ }
+ return p;
+}
+
+/***************************************************
+ ***************************************************/
+
+void osm_qos_policy_match_rule_destroy(osm_qos_match_rule_t * p)
+{
+ unsigned i;
+
+ if (!p)
+ return;
+
+ if (p->qos_level_name)
+ free(p->qos_level_name);
+ if (p->use)
+ free(p->use);
+
+ if (p->service_id_range_arr) {
+ for (i = 0; i < p->service_id_range_len; i++)
+ free(p->service_id_range_arr[i]);
+ free(p->service_id_range_arr);
+ }
+
+ if (p->qos_class_range_arr) {
+ for (i = 0; i < p->qos_class_range_len; i++)
+ free(p->qos_class_range_arr[i]);
+ free(p->qos_class_range_arr);
+ }
+
+ if (p->pkey_range_arr) {
+ for (i = 0; i < p->pkey_range_len; i++)
+ free(p->pkey_range_arr[i]);
+ free(p->pkey_range_arr);
+ }
+
+ cl_list_apply_func(&p->source_list, __free_single_element, NULL);
+ cl_list_remove_all(&p->source_list);
+ cl_list_destroy(&p->source_list);
+
+ cl_list_remove_all(&p->source_group_list);
+ cl_list_destroy(&p->source_group_list);
+
+ cl_list_apply_func(&p->destination_list, __free_single_element, NULL);
+ cl_list_remove_all(&p->destination_list);
+ cl_list_destroy(&p->destination_list);
+
+ cl_list_remove_all(&p->destination_group_list);
+ cl_list_destroy(&p->destination_group_list);
+
+ free(p);
+}
+
+/***************************************************
+ ***************************************************/
+
+osm_qos_policy_t * osm_qos_policy_create(osm_subn_t * p_subn)
+{
+ osm_qos_policy_t * p_qos_policy = (osm_qos_policy_t *)calloc(1, sizeof(osm_qos_policy_t));
+ if (!p_qos_policy)
+ return NULL;
+
+ cl_list_construct(&p_qos_policy->port_groups);
+ cl_list_init(&p_qos_policy->port_groups, 10);
+
+ cl_list_construct(&p_qos_policy->vlarb_tables);
+ cl_list_init(&p_qos_policy->vlarb_tables, 10);
+
+ cl_list_construct(&p_qos_policy->sl2vl_tables);
+ cl_list_init(&p_qos_policy->sl2vl_tables, 10);
+
+ cl_list_construct(&p_qos_policy->qos_levels);
+ cl_list_init(&p_qos_policy->qos_levels, 10);
+
+ cl_list_construct(&p_qos_policy->qos_match_rules);
+ cl_list_init(&p_qos_policy->qos_match_rules, 10);
+
+ p_qos_policy->p_subn = p_subn;
+ __build_nodebyname_hash(p_qos_policy);
+
+ return p_qos_policy;
+}
+
+/***************************************************
+ ***************************************************/
+
+void osm_qos_policy_destroy(osm_qos_policy_t * p_qos_policy)
+{
+ cl_list_iterator_t list_iterator;
+ osm_qos_port_group_t *p_port_group = NULL;
+ osm_qos_vlarb_scope_t *p_vlarb_scope = NULL;
+ osm_qos_sl2vl_scope_t *p_sl2vl_scope = NULL;
+ osm_qos_level_t *p_qos_level = NULL;
+ osm_qos_match_rule_t *p_qos_match_rule = NULL;
+
+ if (!p_qos_policy)
+ return;
+
+ list_iterator = cl_list_head(&p_qos_policy->port_groups);
+ while (list_iterator != cl_list_end(&p_qos_policy->port_groups)) {
+ p_port_group =
+ (osm_qos_port_group_t *) cl_list_obj(list_iterator);
+ if (p_port_group)
+ osm_qos_policy_port_group_destroy(p_port_group);
+ list_iterator = cl_list_next(list_iterator);
+ }
+ cl_list_remove_all(&p_qos_policy->port_groups);
+ cl_list_destroy(&p_qos_policy->port_groups);
+
+ list_iterator = cl_list_head(&p_qos_policy->vlarb_tables);
+ while (list_iterator != cl_list_end(&p_qos_policy->vlarb_tables)) {
+ p_vlarb_scope =
+ (osm_qos_vlarb_scope_t *) cl_list_obj(list_iterator);
+ if (p_vlarb_scope)
+ osm_qos_policy_vlarb_scope_destroy(p_vlarb_scope);
+ list_iterator = cl_list_next(list_iterator);
+ }
+ cl_list_remove_all(&p_qos_policy->vlarb_tables);
+ cl_list_destroy(&p_qos_policy->vlarb_tables);
+
+ list_iterator = cl_list_head(&p_qos_policy->sl2vl_tables);
+ while (list_iterator != cl_list_end(&p_qos_policy->sl2vl_tables)) {
+ p_sl2vl_scope =
+ (osm_qos_sl2vl_scope_t *) cl_list_obj(list_iterator);
+ if (p_sl2vl_scope)
+ osm_qos_policy_sl2vl_scope_destroy(p_sl2vl_scope);
+ list_iterator = cl_list_next(list_iterator);
+ }
+ cl_list_remove_all(&p_qos_policy->sl2vl_tables);
+ cl_list_destroy(&p_qos_policy->sl2vl_tables);
+
+ list_iterator = cl_list_head(&p_qos_policy->qos_levels);
+ while (list_iterator != cl_list_end(&p_qos_policy->qos_levels)) {
+ p_qos_level = (osm_qos_level_t *) cl_list_obj(list_iterator);
+ if (p_qos_level)
+ osm_qos_policy_qos_level_destroy(p_qos_level);
+ list_iterator = cl_list_next(list_iterator);
+ }
+ cl_list_remove_all(&p_qos_policy->qos_levels);
+ cl_list_destroy(&p_qos_policy->qos_levels);
+
+ list_iterator = cl_list_head(&p_qos_policy->qos_match_rules);
+ while (list_iterator != cl_list_end(&p_qos_policy->qos_match_rules)) {
+ p_qos_match_rule =
+ (osm_qos_match_rule_t *) cl_list_obj(list_iterator);
+ if (p_qos_match_rule)
+ osm_qos_policy_match_rule_destroy(p_qos_match_rule);
+ list_iterator = cl_list_next(list_iterator);
+ }
+ cl_list_remove_all(&p_qos_policy->qos_match_rules);
+ cl_list_destroy(&p_qos_policy->qos_match_rules);
+
+ if (p_qos_policy->p_node_hash)
+ st_free_table(p_qos_policy->p_node_hash);
+
+ free(p_qos_policy);
+
+ p_qos_policy = NULL;
+}
+
+/***************************************************
+ ***************************************************/
+
+static boolean_t
+__qos_policy_is_port_in_group(osm_subn_t * p_subn,
+ const osm_physp_t * p_physp,
+ osm_qos_port_group_t * p_port_group)
+{
+ osm_node_t *p_node = osm_physp_get_node_ptr(p_physp);
+ ib_net64_t port_guid = osm_physp_get_port_guid(p_physp);
+ uint64_t port_guid_ho = cl_ntoh64(port_guid);
+
+ /* check whether this port's type matches any of group's types */
+
+ if ( p_port_group->node_types &
+ (((uint8_t)1)<<osm_node_get_type(p_node)) )
+ return TRUE;
+
+ /* check whether this port's guid is in group's port map */
+
+ if (cl_qmap_get(&p_port_group->port_map, port_guid_ho) !=
+ cl_qmap_end(&p_port_group->port_map))
+ return TRUE;
+
+ return FALSE;
+} /* __qos_policy_is_port_in_group() */
+
+/***************************************************
+ ***************************************************/
+
+static boolean_t
+__qos_policy_is_port_in_group_list(const osm_qos_policy_t * p_qos_policy,
+ const osm_physp_t * p_physp,
+ cl_list_t * p_port_group_list)
+{
+ osm_qos_port_group_t *p_port_group;
+ cl_list_iterator_t list_iterator;
+
+ list_iterator = cl_list_head(p_port_group_list);
+ while (list_iterator != cl_list_end(p_port_group_list)) {
+ p_port_group =
+ (osm_qos_port_group_t *) cl_list_obj(list_iterator);
+ if (p_port_group) {
+ if (__qos_policy_is_port_in_group
+ (p_qos_policy->p_subn, p_physp, p_port_group))
+ return TRUE;
+ }
+ list_iterator = cl_list_next(list_iterator);
+ }
+ return FALSE;
+}
+
+/***************************************************
+ ***************************************************/
+
+static osm_qos_match_rule_t *__qos_policy_get_match_rule_by_params(
+ const osm_qos_policy_t * p_qos_policy,
+ uint64_t service_id,
+ uint16_t qos_class,
+ uint16_t pkey,
+ const osm_physp_t * p_src_physp,
+ const osm_physp_t * p_dest_physp,
+ ib_net64_t comp_mask)
+{
+ osm_qos_match_rule_t *p_qos_match_rule = NULL;
+ cl_list_iterator_t list_iterator;
+ osm_log_t * p_log = &p_qos_policy->p_subn->p_osm->log;
+
+ boolean_t matched_by_sguid = FALSE,
+ matched_by_dguid = FALSE,
+ matched_by_sordguid = FALSE,
+ matched_by_class = FALSE,
+ matched_by_sid = FALSE,
+ matched_by_pkey = FALSE;
+
+ if (!cl_list_count(&p_qos_policy->qos_match_rules))
+ return NULL;
+
+ OSM_LOG_ENTER(p_log);
+
+ /* Go over all QoS match rules and find the one that matches the request */
+
+ list_iterator = cl_list_head(&p_qos_policy->qos_match_rules);
+ while (list_iterator != cl_list_end(&p_qos_policy->qos_match_rules)) {
+ p_qos_match_rule =
+ (osm_qos_match_rule_t *) cl_list_obj(list_iterator);
+ if (!p_qos_match_rule) {
+ list_iterator = cl_list_next(list_iterator);
+ continue;
+ }
+
+ /* If a match rule has Source groups and no Destination groups,
+ * PR request source has to be in this list */
+
+ if (cl_list_count(&p_qos_match_rule->source_group_list)
+ && !cl_list_count(&p_qos_match_rule->destination_group_list)) {
+ if (!__qos_policy_is_port_in_group_list(p_qos_policy,
+ p_src_physp,
+ &p_qos_match_rule->
+ source_group_list))
+ {
+ list_iterator = cl_list_next(list_iterator);
+ continue;
+ }
+ matched_by_sguid = TRUE;
+ }
+
+ /* If a match rule has Destination groups and no Source groups,
+ * PR request dest. has to be in this list */
+
+ if (cl_list_count(&p_qos_match_rule->destination_group_list)
+ && !cl_list_count(&p_qos_match_rule->source_group_list)) {
+ if (!__qos_policy_is_port_in_group_list(p_qos_policy,
+ p_dest_physp,
+ &p_qos_match_rule->
+ destination_group_list))
+ {
+ list_iterator = cl_list_next(list_iterator);
+ continue;
+ }
+ matched_by_dguid = TRUE;
+ }
+
+ /* If a match rule has both Source and Destination groups,
+ * PR request source or dest. must be in respective list
+ */
+ if (cl_list_count(&p_qos_match_rule->source_group_list)
+ && cl_list_count(&p_qos_match_rule->destination_group_list)) {
+ if (__qos_policy_is_port_in_group_list(p_qos_policy,
+ p_src_physp,
+ &p_qos_match_rule->
+ source_group_list)
+ && __qos_policy_is_port_in_group_list(p_qos_policy,
+ p_dest_physp,
+ &p_qos_match_rule->
+ destination_group_list))
+ matched_by_sordguid = TRUE;
+ else {
+ list_iterator = cl_list_next(list_iterator);
+ continue;
+ }
+ }
+
+ /* If a match rule has QoS classes, PR request HAS
+ to have a matching QoS class to match the rule */
+
+ if (p_qos_match_rule->qos_class_range_len) {
+ if (!(comp_mask & IB_PR_COMPMASK_QOS_CLASS)) {
+ list_iterator = cl_list_next(list_iterator);
+ continue;
+ }
+
+ if (!__is_num_in_range_arr
+ (p_qos_match_rule->qos_class_range_arr,
+ p_qos_match_rule->qos_class_range_len,
+ qos_class)) {
+ list_iterator = cl_list_next(list_iterator);
+ continue;
+ }
+ matched_by_class = TRUE;
+ }
+
+ /* If a match rule has Service IDs, PR request HAS
+ to have a matching Service ID to match the rule */
+
+ if (p_qos_match_rule->service_id_range_len) {
+ if (!(comp_mask & IB_PR_COMPMASK_SERVICEID_MSB) ||
+ !(comp_mask & IB_PR_COMPMASK_SERVICEID_LSB)) {
+ list_iterator = cl_list_next(list_iterator);
+ continue;
+ }
+
+ if (!__is_num_in_range_arr
+ (p_qos_match_rule->service_id_range_arr,
+ p_qos_match_rule->service_id_range_len,
+ service_id)) {
+ list_iterator = cl_list_next(list_iterator);
+ continue;
+ }
+ matched_by_sid = TRUE;
+ }
+
+ /* If a match rule has PKeys, PR request HAS
+ to have a matching PKey to match the rule */
+
+ if (p_qos_match_rule->pkey_range_len) {
+ if (!(comp_mask & IB_PR_COMPMASK_PKEY)) {
+ list_iterator = cl_list_next(list_iterator);
+ continue;
+ }
+
+ if (!__is_num_in_range_arr
+ (p_qos_match_rule->pkey_range_arr,
+ p_qos_match_rule->pkey_range_len,
+ pkey & 0x7FFF)) {
+ list_iterator = cl_list_next(list_iterator);
+ continue;
+ }
+ matched_by_pkey = TRUE;
+ }
+
+ /* if we got here, then this match-rule matched this PR request */
+ break;
+ }
+
+ if (list_iterator == cl_list_end(&p_qos_policy->qos_match_rules))
+ p_qos_match_rule = NULL;
+
+ if (p_qos_match_rule)
+ OSM_LOG(p_log, OSM_LOG_DEBUG,
+ "request matched rule (%s) by:%s%s%s%s%s%s\n",
+ (p_qos_match_rule->use) ?
+ p_qos_match_rule->use : "no description",
+ (matched_by_sguid) ? " SGUID" : "",
+ (matched_by_dguid) ? " DGUID" : "",
+ (matched_by_sordguid) ? "SorDGUID" : "",
+ (matched_by_class) ? " QoS_Class" : "",
+ (matched_by_sid) ? " ServiceID" : "",
+ (matched_by_pkey) ? " PKey" : "");
+ else
+ OSM_LOG(p_log, OSM_LOG_DEBUG,
+ "request not matched any rule\n");
+
+ OSM_LOG_EXIT(p_log);
+ return p_qos_match_rule;
+} /* __qos_policy_get_match_rule_by_params() */
+
+/***************************************************
+ ***************************************************/
+
+static osm_qos_level_t *__qos_policy_get_qos_level_by_name(
+ const osm_qos_policy_t * p_qos_policy,
+ const char *name)
+{
+ osm_qos_level_t *p_qos_level = NULL;
+ cl_list_iterator_t list_iterator;
+
+ list_iterator = cl_list_head(&p_qos_policy->qos_levels);
+ while (list_iterator != cl_list_end(&p_qos_policy->qos_levels)) {
+ p_qos_level = (osm_qos_level_t *) cl_list_obj(list_iterator);
+ if (!p_qos_level)
+ continue;
+
+ /* names are case INsensitive */
+ if (strcasecmp(name, p_qos_level->name) == 0)
+ return p_qos_level;
+
+ list_iterator = cl_list_next(list_iterator);
+ }
+
+ return NULL;
+}
+
+/***************************************************
+ ***************************************************/
+
+static osm_qos_port_group_t *__qos_policy_get_port_group_by_name(
+ const osm_qos_policy_t * p_qos_policy,
+ const char *const name)
+{
+ osm_qos_port_group_t *p_port_group = NULL;
+ cl_list_iterator_t list_iterator;
+
+ list_iterator = cl_list_head(&p_qos_policy->port_groups);
+ while (list_iterator != cl_list_end(&p_qos_policy->port_groups)) {
+ p_port_group =
+ (osm_qos_port_group_t *) cl_list_obj(list_iterator);
+ if (!p_port_group)
+ continue;
+
+ /* names are case INsensitive */
+ if (strcasecmp(name, p_port_group->name) == 0)
+ return p_port_group;
+
+ list_iterator = cl_list_next(list_iterator);
+ }
+
+ return NULL;
+}
+
+/***************************************************
+ ***************************************************/
+
+static void __qos_policy_validate_pkey(
+ osm_qos_policy_t * p_qos_policy,
+ osm_qos_match_rule_t * p_qos_match_rule,
+ osm_prtn_t * p_prtn)
+{
+ if (!p_qos_policy || !p_qos_match_rule || !p_prtn)
+ return;
+
+ if (!p_qos_match_rule->p_qos_level->sl_set ||
+ p_prtn->sl == p_qos_match_rule->p_qos_level->sl)
+ return;
+
+ OSM_LOG(&p_qos_policy->p_subn->p_osm->log, OSM_LOG_VERBOSE,
+ "QoS Level SL (%u) for Pkey 0x%04X in match rule "
+ "differs from partition SL (%u)\n",
+ p_qos_match_rule->p_qos_level->sl,
+ cl_ntoh16(p_prtn->pkey), p_prtn->sl);
+}
+
+/***************************************************
+ ***************************************************/
+
+int osm_qos_policy_validate(osm_qos_policy_t * p_qos_policy,
+ osm_log_t *p_log)
+{
+ cl_list_iterator_t match_rules_list_iterator;
+ cl_list_iterator_t list_iterator;
+ osm_qos_port_group_t *p_port_group = NULL;
+ osm_qos_match_rule_t *p_qos_match_rule = NULL;
+ char *str;
+ unsigned i, j;
+ int res = 0;
+ uint64_t pkey_64;
+ ib_net16_t pkey;
+ osm_prtn_t * p_prtn;
+
+ OSM_LOG_ENTER(p_log);
+
+ /* set default qos level */
+
+ p_qos_policy->p_default_qos_level =
+ __qos_policy_get_qos_level_by_name(p_qos_policy, OSM_QOS_POLICY_DEFAULT_LEVEL_NAME);
+ if (!p_qos_policy->p_default_qos_level) {
+ /* There's no default QoS level in the usual qos-level section.
+ Check whether the 'simple' default QoS level that can be
+ defined in the qos-ulp section exists */
+ if (__default_simple_qos_level.sl_set) {
+ p_qos_policy->p_default_qos_level = &__default_simple_qos_level;
+ }
+ else {
+ OSM_LOG(p_log, OSM_LOG_ERROR, "ERR AC10: "
+ "Default qos-level (%s) not defined.\n",
+ OSM_QOS_POLICY_DEFAULT_LEVEL_NAME);
+ res = 1;
+ goto Exit;
+ }
+ }
+
+ /* scan all the match rules, and fill the lists of pointers to
+ relevant qos levels and port groups to speed up PR matching */
+
+ i = 1;
+ match_rules_list_iterator =
+ cl_list_head(&p_qos_policy->qos_match_rules);
+ while (match_rules_list_iterator !=
+ cl_list_end(&p_qos_policy->qos_match_rules)) {
+ p_qos_match_rule =
+ (osm_qos_match_rule_t *)
+ cl_list_obj(match_rules_list_iterator);
+ CL_ASSERT(p_qos_match_rule);
+
+ /* find the matching qos-level for each match-rule */
+
+ if (!p_qos_match_rule->p_qos_level)
+ p_qos_match_rule->p_qos_level =
+ __qos_policy_get_qos_level_by_name(p_qos_policy,
+ p_qos_match_rule->qos_level_name);
+
+ if (!p_qos_match_rule->p_qos_level) {
+ OSM_LOG(p_log, OSM_LOG_ERROR, "ERR AC11: "
+ "qos-match-rule num %u: qos-level '%s' not found\n",
+ i, p_qos_match_rule->qos_level_name);
+ res = 1;
+ goto Exit;
+ }
+
+ /* find the matching port-group for element of source_list */
+
+ if (cl_list_count(&p_qos_match_rule->source_list)) {
+ list_iterator =
+ cl_list_head(&p_qos_match_rule->source_list);
+ while (list_iterator !=
+ cl_list_end(&p_qos_match_rule->source_list)) {
+ str = (char *)cl_list_obj(list_iterator);
+ CL_ASSERT(str);
+
+ p_port_group =
+ __qos_policy_get_port_group_by_name(p_qos_policy, str);
+ if (!p_port_group) {
+ OSM_LOG(p_log, OSM_LOG_ERROR, "ERR AC12: "
+ "qos-match-rule num %u: source port-group '%s' not found\n",
+ i, str);
+ res = 1;
+ goto Exit;
+ }
+
+ cl_list_insert_tail(&p_qos_match_rule->
+ source_group_list,
+ p_port_group);
+
+ list_iterator = cl_list_next(list_iterator);
+ }
+ }
+
+ /* find the matching port-group for element of destination_list */
+
+ if (cl_list_count(&p_qos_match_rule->destination_list)) {
+ list_iterator =
+ cl_list_head(&p_qos_match_rule->destination_list);
+ while (list_iterator !=
+ cl_list_end(&p_qos_match_rule->
+ destination_list)) {
+ str = (char *)cl_list_obj(list_iterator);
+ CL_ASSERT(str);
+
+ p_port_group =
+ __qos_policy_get_port_group_by_name(p_qos_policy,str);
+ if (!p_port_group) {
+ OSM_LOG(p_log, OSM_LOG_ERROR, "ERR AC13: "
+ "qos-match-rule num %u: destination port-group '%s' not found\n",
+ i, str);
+ res = 1;
+ goto Exit;
+ }
+
+ cl_list_insert_tail(&p_qos_match_rule->
+ destination_group_list,
+ p_port_group);
+
+ list_iterator = cl_list_next(list_iterator);
+ }
+ }
+
+ /*
+ * Scan all the pkeys in matching rule, and if the
+ * partition for these pkeys exists, set the SL
+ * according to the QoS Level.
+ * Warn if there's mismatch between QoS level SL
+ * and Partition SL.
+ */
+
+ for (j = 0; j < p_qos_match_rule->pkey_range_len; j++) {
+ for ( pkey_64 = p_qos_match_rule->pkey_range_arr[j][0];
+ pkey_64 <= p_qos_match_rule->pkey_range_arr[j][1];
+ pkey_64++) {
+ pkey = cl_hton16((uint16_t)(pkey_64 & 0x7fff));
+ p_prtn = (osm_prtn_t *)cl_qmap_get(
+ &p_qos_policy->p_subn->prtn_pkey_tbl, pkey);
+
+ if (p_prtn == (osm_prtn_t *)cl_qmap_end(
+ &p_qos_policy->p_subn->prtn_pkey_tbl))
+ /* partition for this pkey not found */
+ OSM_LOG(p_log, OSM_LOG_ERROR, "ERR AC14: "
+ "pkey 0x%04X in match rule - "
+ "partition doesn't exist\n",
+ cl_ntoh16(pkey));
+ else
+ __qos_policy_validate_pkey(p_qos_policy,
+ p_qos_match_rule,
+ p_prtn);
+ }
+ }
+
+ /* done with the current match-rule */
+
+ match_rules_list_iterator =
+ cl_list_next(match_rules_list_iterator);
+ i++;
+ }
+
+Exit:
+ OSM_LOG_EXIT(p_log);
+ return res;
+} /* osm_qos_policy_validate() */
+
+/***************************************************
+ ***************************************************/
+
+static osm_qos_level_t * __qos_policy_get_qos_level_by_params(
+ IN const osm_qos_policy_t * p_qos_policy,
+ IN const osm_physp_t * p_src_physp,
+ IN const osm_physp_t * p_dest_physp,
+ IN uint64_t service_id,
+ IN uint16_t qos_class,
+ IN uint16_t pkey,
+ IN ib_net64_t comp_mask)
+{
+ osm_qos_match_rule_t *p_qos_match_rule = NULL;
+
+ if (!p_qos_policy)
+ return NULL;
+
+ p_qos_match_rule = __qos_policy_get_match_rule_by_params(
+ p_qos_policy, service_id, qos_class, pkey,
+ p_src_physp, p_dest_physp, comp_mask);
+
+ return p_qos_match_rule ? p_qos_match_rule->p_qos_level :
+ p_qos_policy->p_default_qos_level;
+} /* __qos_policy_get_qos_level_by_params() */
+
+/***************************************************
+ ***************************************************/
+
+osm_qos_level_t * osm_qos_policy_get_qos_level_by_pr(
+ IN const osm_qos_policy_t * p_qos_policy,
+ IN const ib_path_rec_t * p_pr,
+ IN const osm_physp_t * p_src_physp,
+ IN const osm_physp_t * p_dest_physp,
+ IN ib_net64_t comp_mask)
+{
+ return __qos_policy_get_qos_level_by_params(
+ p_qos_policy, p_src_physp, p_dest_physp,
+ cl_ntoh64(p_pr->service_id), ib_path_rec_qos_class(p_pr),
+ cl_ntoh16(p_pr->pkey), comp_mask);
+}
+
+/***************************************************
+ ***************************************************/
+
+osm_qos_level_t * osm_qos_policy_get_qos_level_by_mpr(
+ IN const osm_qos_policy_t * p_qos_policy,
+ IN const ib_multipath_rec_t * p_mpr,
+ IN const osm_physp_t * p_src_physp,
+ IN const osm_physp_t * p_dest_physp,
+ IN ib_net64_t comp_mask)
+{
+ ib_net64_t pr_comp_mask = 0;
+
+ if (!p_qos_policy)
+ return NULL;
+
+ /*
+ * Converting MultiPathRecord compmask to the PathRecord
+ * compmask. Note that only relevant bits are set.
+ */
+ pr_comp_mask =
+ ((comp_mask & IB_MPR_COMPMASK_QOS_CLASS) ?
+ IB_PR_COMPMASK_QOS_CLASS : 0) |
+ ((comp_mask & IB_MPR_COMPMASK_PKEY) ?
+ IB_PR_COMPMASK_PKEY : 0) |
+ ((comp_mask & IB_MPR_COMPMASK_SERVICEID_MSB) ?
+ IB_PR_COMPMASK_SERVICEID_MSB : 0) |
+ ((comp_mask & IB_MPR_COMPMASK_SERVICEID_LSB) ?
+ IB_PR_COMPMASK_SERVICEID_LSB : 0);
+
+ return __qos_policy_get_qos_level_by_params(
+ p_qos_policy, p_src_physp, p_dest_physp,
+ cl_ntoh64(ib_multipath_rec_service_id(p_mpr)),
+ ib_multipath_rec_qos_class(p_mpr),
+ cl_ntoh16(p_mpr->pkey), pr_comp_mask);
+}
+
+/***************************************************
+ ***************************************************/
diff --git a/contrib/ofed/opensm/opensm/osm_remote_sm.c b/contrib/ofed/opensm/opensm/osm_remote_sm.c
new file mode 100644
index 0000000..4ebbd3f
--- /dev/null
+++ b/contrib/ofed/opensm/opensm/osm_remote_sm.c
@@ -0,0 +1,71 @@
+/*
+ * Copyright (c) 2004-2009 Voltaire, Inc. All rights reserved.
+ * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved.
+ * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+/*
+ * Abstract:
+ * Implementation of osm_sm_t.
+ * This object represents the remote SM object.
+ * This object is part of the opensm family of objects.
+ */
+
+#if HAVE_CONFIG_H
+# include <config.h>
+#endif /* HAVE_CONFIG_H */
+
+#include <string.h>
+#include <opensm/osm_file_ids.h>
+#define FILE_ID OSM_FILE_REMOTE_SM_C
+#include <opensm/osm_remote_sm.h>
+
+void osm_remote_sm_construct(IN osm_remote_sm_t * p_sm)
+{
+ memset(p_sm, 0, sizeof(*p_sm));
+}
+
+void osm_remote_sm_destroy(IN osm_remote_sm_t * p_sm)
+{
+ memset(p_sm, 0, sizeof(*p_sm));
+}
+
+void osm_remote_sm_init(IN osm_remote_sm_t * p_sm,
+ IN const ib_sm_info_t * p_smi)
+{
+ CL_ASSERT(p_sm);
+
+ osm_remote_sm_construct(p_sm);
+
+ p_sm->smi = *p_smi;
+ return;
+}
diff --git a/contrib/ofed/opensm/opensm/osm_req.c b/contrib/ofed/opensm/opensm/osm_req.c
new file mode 100644
index 0000000..7c04465
--- /dev/null
+++ b/contrib/ofed/opensm/opensm/osm_req.c
@@ -0,0 +1,429 @@
+/*
+ * Copyright (c) 2004-2009 Voltaire, Inc. All rights reserved.
+ * Copyright (c) 2002-2015 Mellanox Technologies LTD. All rights reserved.
+ * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
+ * Copyright (c) 2009 HNR Consulting. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+/*
+ * Abstract:
+ * Implementation of osm_req_t.
+ * This object represents the generic attribute requester.
+ * This object is part of the opensm family of objects.
+ */
+
+#if HAVE_CONFIG_H
+# include <config.h>
+#endif /* HAVE_CONFIG_H */
+
+#include <string.h>
+#include <iba/ib_types.h>
+#include <complib/cl_debug.h>
+#include <opensm/osm_file_ids.h>
+#define FILE_ID OSM_FILE_REQ_C
+#include <opensm/osm_madw.h>
+#include <opensm/osm_attrib_req.h>
+#include <opensm/osm_log.h>
+#include <opensm/osm_helper.h>
+#include <opensm/osm_mad_pool.h>
+#include <opensm/osm_vl15intf.h>
+#include <opensm/osm_msgdef.h>
+#include <opensm/osm_opensm.h>
+#include <opensm/osm_db_pack.h>
+
+/**********************************************************************
+ The plock must be held before calling this function.
+**********************************************************************/
+static ib_net64_t req_determine_mkey(IN osm_sm_t * sm,
+ IN const osm_dr_path_t * p_path)
+{
+ osm_node_t *p_node;
+ osm_port_t *p_sm_port;
+ osm_physp_t *p_physp;
+ ib_net64_t dest_port_guid = 0, m_key;
+ uint8_t hop;
+
+ OSM_LOG_ENTER(sm->p_log);
+
+ p_physp = NULL;
+
+ p_sm_port = osm_get_port_by_guid(sm->p_subn, sm->p_subn->sm_port_guid);
+
+ /* hop_count == 0: destination port guid is SM */
+ if (p_path->hop_count == 0) {
+ dest_port_guid = sm->p_subn->sm_port_guid;
+ goto Remote_Guid;
+ }
+
+ if (p_sm_port) {
+ p_node = p_sm_port->p_node;
+ if (osm_node_get_type(p_node) == IB_NODE_TYPE_SWITCH)
+ p_physp = osm_node_get_physp_ptr(p_node, p_path->path[1]);
+ else
+ p_physp = p_sm_port->p_physp;
+ }
+
+ /* hop_count == 1: outgoing physp is SM physp */
+ for (hop = 2; p_physp && hop <= p_path->hop_count; hop++) {
+ p_physp = p_physp->p_remote_physp;
+ if (!p_physp)
+ break;
+ p_node = p_physp->p_node;
+ p_physp = osm_node_get_physp_ptr(p_node, p_path->path[hop]);
+ }
+
+ /* At this point, p_physp points at the outgoing physp on the
+ last hop, or NULL if we don't know it.
+ */
+ if (!p_physp) {
+ OSM_LOG(sm->p_log, OSM_LOG_ERROR,
+ "ERR 1107: Outgoing physp is null on non-hop_0!\n");
+ osm_dump_dr_path_v2(sm->p_log, p_path, FILE_ID, OSM_LOG_ERROR);
+ dest_port_guid = 0;
+ goto Remote_Guid;
+ }
+
+ if (p_physp->p_remote_physp) {
+ dest_port_guid = p_physp->p_remote_physp->port_guid;
+ goto Remote_Guid;
+ }
+
+ OSM_LOG(sm->p_log, OSM_LOG_DEBUG, "Target port guid unknown, "
+ "using persistent DB\n");
+ if (!osm_db_neighbor_get(sm->p_subn->p_neighbor,
+ cl_ntoh64(p_physp->port_guid),
+ p_physp->port_num,
+ &dest_port_guid, NULL)) {
+ dest_port_guid = cl_hton64(dest_port_guid);
+ }
+
+Remote_Guid:
+ if (dest_port_guid) {
+ if (!osm_db_guid2mkey_get(sm->p_subn->p_g2m,
+ cl_ntoh64(dest_port_guid), &m_key)) {
+ m_key = cl_hton64(m_key);
+ OSM_LOG(sm->p_log, OSM_LOG_DEBUG,
+ "Found mkey for guid 0x%"
+ PRIx64 "\n", cl_ntoh64(dest_port_guid));
+ } else {
+ OSM_LOG(sm->p_log, OSM_LOG_DEBUG,
+ "Target port mkey unknown, using default\n");
+ m_key = sm->p_subn->opt.m_key;
+ }
+ } else {
+ OSM_LOG(sm->p_log, OSM_LOG_DEBUG,
+ "Target port guid unknown, using default\n");
+ m_key = sm->p_subn->opt.m_key;
+ }
+
+ OSM_LOG_EXIT(sm->p_log);
+
+ return m_key;
+}
+
+/**********************************************************************
+ The plock must be held before calling this function.
+**********************************************************************/
+ib_api_status_t osm_req_get(IN osm_sm_t * sm, IN const osm_dr_path_t * p_path,
+ IN ib_net16_t attr_id, IN ib_net32_t attr_mod,
+ IN boolean_t find_mkey, ib_net64_t m_key,
+ IN cl_disp_msgid_t err_msg,
+ IN const osm_madw_context_t * p_context)
+{
+ osm_madw_t *p_madw;
+ ib_api_status_t status = IB_SUCCESS;
+ ib_net64_t m_key_calc;
+ ib_net64_t tid;
+
+ CL_ASSERT(sm);
+
+ OSM_LOG_ENTER(sm->p_log);
+
+ CL_ASSERT(p_path);
+ CL_ASSERT(attr_id);
+
+ /* do nothing if we are exiting ... */
+ if (osm_exit_flag)
+ goto Exit;
+
+ /* p_context may be NULL. */
+
+ p_madw = osm_mad_pool_get(sm->p_mad_pool, sm->mad_ctrl.h_bind,
+ MAD_BLOCK_SIZE, NULL);
+ if (p_madw == NULL) {
+ OSM_LOG(sm->p_log, OSM_LOG_ERROR,
+ "ERR 1101: Unable to acquire MAD\n");
+ status = IB_INSUFFICIENT_RESOURCES;
+ goto Exit;
+ }
+
+ tid = cl_hton64((uint64_t) cl_atomic_inc(&sm->sm_trans_id)
+ & (uint64_t)(0xFFFFFFFF));
+ if (tid == 0)
+ tid = cl_hton64((uint64_t) cl_atomic_inc(&sm->sm_trans_id)
+ & (uint64_t)(0xFFFFFFFF));
+
+ if (sm->p_subn->opt.m_key_lookup == TRUE) {
+ if (find_mkey == TRUE)
+ m_key_calc = req_determine_mkey(sm, p_path);
+ else
+ m_key_calc = m_key;
+ } else
+ m_key_calc = sm->p_subn->opt.m_key;
+
+ OSM_LOG(sm->p_log, OSM_LOG_DEBUG,
+ "Getting %s (0x%X), modifier 0x%X, TID 0x%" PRIx64
+ ", MKey 0x%016" PRIx64 "\n",
+ ib_get_sm_attr_str(attr_id), cl_ntoh16(attr_id),
+ cl_ntoh32(attr_mod), cl_ntoh64(tid), cl_ntoh64(m_key_calc));
+
+ ib_smp_init_new(osm_madw_get_smp_ptr(p_madw), IB_MAD_METHOD_GET,
+ tid, attr_id, attr_mod, p_path->hop_count,
+ m_key_calc, p_path->path,
+ IB_LID_PERMISSIVE, IB_LID_PERMISSIVE);
+
+ p_madw->mad_addr.dest_lid = IB_LID_PERMISSIVE;
+ p_madw->mad_addr.addr_type.smi.source_lid = IB_LID_PERMISSIVE;
+ p_madw->resp_expected = TRUE;
+ p_madw->fail_msg = err_msg;
+
+ /*
+ Fill in the mad wrapper context for the recipient.
+ In this case, the only thing the recipient needs is the
+ guid value.
+ */
+
+ if (p_context)
+ p_madw->context = *p_context;
+
+ osm_vl15_post(sm->p_vl15, p_madw);
+
+Exit:
+ OSM_LOG_EXIT(sm->p_log);
+ return status;
+}
+
+/**********************************************************************
+ The plock must be held before calling this function.
+**********************************************************************/
+osm_madw_t *osm_prepare_req_set(IN osm_sm_t * sm, IN const osm_dr_path_t * p_path,
+ IN const uint8_t * p_payload,
+ IN size_t payload_size,
+ IN ib_net16_t attr_id, IN ib_net32_t attr_mod,
+ IN boolean_t find_mkey, IN ib_net64_t m_key,
+ IN cl_disp_msgid_t err_msg,
+ IN const osm_madw_context_t * p_context)
+{
+ osm_madw_t *p_madw = NULL;
+ ib_net64_t m_key_calc;
+ ib_net64_t tid;
+
+ CL_ASSERT(sm);
+
+ OSM_LOG_ENTER(sm->p_log);
+
+ CL_ASSERT(p_path);
+ CL_ASSERT(attr_id);
+ CL_ASSERT(p_payload);
+
+ /* do nothing if we are exiting ... */
+ if (osm_exit_flag)
+ goto Exit;
+
+ /* p_context may be NULL. */
+
+ p_madw = osm_mad_pool_get(sm->p_mad_pool, sm->mad_ctrl.h_bind,
+ MAD_BLOCK_SIZE, NULL);
+ if (p_madw == NULL) {
+ OSM_LOG(sm->p_log, OSM_LOG_ERROR,
+ "ERR 1102: Unable to acquire MAD\n");
+ goto Exit;
+ }
+
+ tid = cl_hton64((uint64_t) cl_atomic_inc(&sm->sm_trans_id)
+ & (uint64_t)(0xFFFFFFFF));
+ if (tid == 0)
+ tid = cl_hton64((uint64_t) cl_atomic_inc(&sm->sm_trans_id)
+ & (uint64_t)(0xFFFFFFFF));
+
+ if (sm->p_subn->opt.m_key_lookup == TRUE) {
+ if (find_mkey == TRUE)
+ m_key_calc = req_determine_mkey(sm, p_path);
+ else
+ m_key_calc = m_key;
+ } else
+ m_key_calc = sm->p_subn->opt.m_key;
+
+ OSM_LOG(sm->p_log, OSM_LOG_DEBUG,
+ "Setting %s (0x%X), modifier 0x%X, TID 0x%" PRIx64
+ ", MKey 0x%016" PRIx64 "\n",
+ ib_get_sm_attr_str(attr_id), cl_ntoh16(attr_id),
+ cl_ntoh32(attr_mod), cl_ntoh64(tid), cl_ntoh64(m_key_calc));
+
+ ib_smp_init_new(osm_madw_get_smp_ptr(p_madw), IB_MAD_METHOD_SET,
+ tid, attr_id, attr_mod, p_path->hop_count,
+ m_key_calc, p_path->path,
+ IB_LID_PERMISSIVE, IB_LID_PERMISSIVE);
+
+ p_madw->mad_addr.dest_lid = IB_LID_PERMISSIVE;
+ p_madw->mad_addr.addr_type.smi.source_lid = IB_LID_PERMISSIVE;
+ p_madw->resp_expected = TRUE;
+ p_madw->fail_msg = err_msg;
+
+ /*
+ Fill in the mad wrapper context for the recipient.
+ In this case, the only thing the recipient needs is the
+ guid value.
+ */
+
+ if (p_context)
+ p_madw->context = *p_context;
+
+ memcpy(osm_madw_get_smp_ptr(p_madw)->data, p_payload, payload_size);
+
+Exit:
+ OSM_LOG_EXIT(sm->p_log);
+ return p_madw;
+}
+
+void osm_send_req_mad(IN osm_sm_t * sm, IN osm_madw_t *p_madw)
+{
+ CL_ASSERT(p_madw);
+ CL_ASSERT(sm);
+
+ osm_vl15_post(sm->p_vl15, p_madw);
+}
+
+/**********************************************************************
+ The plock MAY or MAY NOT be held before calling this function.
+**********************************************************************/
+ib_api_status_t osm_req_set(IN osm_sm_t * sm, IN const osm_dr_path_t * p_path,
+ IN const uint8_t * p_payload,
+ IN size_t payload_size,
+ IN ib_net16_t attr_id, IN ib_net32_t attr_mod,
+ IN boolean_t find_mkey, IN ib_net64_t m_key,
+ IN cl_disp_msgid_t err_msg,
+ IN const osm_madw_context_t * p_context)
+{
+ osm_madw_t *p_madw;
+ ib_api_status_t status = IB_SUCCESS;
+
+ p_madw = osm_prepare_req_set(sm, p_path, p_payload, payload_size, attr_id,
+ attr_mod, find_mkey, m_key, err_msg, p_context);
+ if (p_madw == NULL)
+ status = IB_INSUFFICIENT_RESOURCES;
+ else
+ osm_send_req_mad(sm, p_madw);
+
+ return status;
+}
+
+int osm_send_trap144(osm_sm_t * sm, ib_net16_t local)
+{
+ osm_madw_t *madw;
+ ib_smp_t *smp;
+ ib_mad_notice_attr_t *ntc;
+ osm_port_t *port, *smport;
+ ib_port_info_t *pi;
+
+ port = osm_get_port_by_guid(sm->p_subn, sm->p_subn->sm_port_guid);
+ if (!port) {
+ OSM_LOG(sm->p_log, OSM_LOG_ERROR,
+ "ERR 1104: cannot find SM port by guid 0x%" PRIx64 "\n",
+ cl_ntoh64(sm->p_subn->sm_port_guid));
+ return -1;
+ }
+
+ pi = &port->p_physp->port_info;
+
+ /* don't bother with sending trap when SMA supports this */
+ if (!local &&
+ pi->capability_mask&(IB_PORT_CAP_HAS_TRAP|IB_PORT_CAP_HAS_CAP_NTC))
+ return 0;
+
+ smport = osm_get_port_by_guid(sm->p_subn, sm->master_sm_guid);
+ if (!smport) {
+ OSM_LOG(sm->p_log, OSM_LOG_ERROR,
+ "ERR 1106: cannot find master SM port by guid 0x%" PRIx64 "\n",
+ cl_ntoh64(sm->master_sm_guid));
+ return -1;
+ }
+
+ madw = osm_mad_pool_get(sm->p_mad_pool,
+ osm_sm_mad_ctrl_get_bind_handle(&sm->mad_ctrl),
+ MAD_BLOCK_SIZE, NULL);
+ if (madw == NULL) {
+ OSM_LOG(sm->p_log, OSM_LOG_ERROR,
+ "ERR 1105: Unable to acquire MAD\n");
+ return -1;
+ }
+
+ madw->mad_addr.dest_lid = smport->p_physp->port_info.base_lid;
+ madw->mad_addr.addr_type.smi.source_lid = pi->base_lid;
+ madw->resp_expected = TRUE;
+ madw->fail_msg = CL_DISP_MSGID_NONE;
+
+ smp = osm_madw_get_smp_ptr(madw);
+ memset(smp, 0, sizeof(*smp));
+
+ smp->base_ver = 1;
+ smp->mgmt_class = IB_MCLASS_SUBN_LID;
+ smp->class_ver = 1;
+ smp->method = IB_MAD_METHOD_TRAP;
+ smp->trans_id = cl_hton64((uint64_t) cl_atomic_inc(&sm->sm_trans_id)
+ & (uint64_t)(0xFFFFFFFF));
+ if (smp->trans_id == 0)
+ smp->trans_id = cl_hton64((uint64_t) cl_atomic_inc(&sm->sm_trans_id)
+ & (uint64_t)(0xFFFFFFFF));
+
+ smp->attr_id = IB_MAD_ATTR_NOTICE;
+
+ ntc = (ib_mad_notice_attr_t *) smp->data;
+
+ ntc->generic_type = 0x80 | IB_NOTICE_TYPE_INFO;
+ ib_notice_set_prod_type_ho(ntc, osm_node_get_type(port->p_node));
+ ntc->g_or_v.generic.trap_num = cl_hton16(SM_LOCAL_CHANGES_TRAP); /* 144 */
+ ntc->issuer_lid = pi->base_lid;
+ ntc->data_details.ntc_144.lid = pi->base_lid;
+ ntc->data_details.ntc_144.local_changes = local ?
+ TRAP_144_MASK_OTHER_LOCAL_CHANGES : 0;
+ ntc->data_details.ntc_144.new_cap_mask = pi->capability_mask;
+ ntc->data_details.ntc_144.change_flgs = local;
+
+ OSM_LOG(sm->p_log, OSM_LOG_DEBUG,
+ "Sending Trap 144, TID 0x%" PRIx64 " to SM lid %u\n",
+ cl_ntoh64(smp->trans_id), cl_ntoh16(madw->mad_addr.dest_lid));
+
+ osm_vl15_post(sm->p_vl15, madw);
+
+ return 0;
+}
diff --git a/contrib/ofed/opensm/opensm/osm_resp.c b/contrib/ofed/opensm/opensm/osm_resp.c
new file mode 100644
index 0000000..59a73e0
--- /dev/null
+++ b/contrib/ofed/opensm/opensm/osm_resp.c
@@ -0,0 +1,152 @@
+/*
+ * Copyright (c) 2004-2009 Voltaire, Inc. All rights reserved.
+ * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved.
+ * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+/*
+ * Abstract:
+ * Implementation of osm_resp_t.
+ * This object represents the generic attribute responder.
+ * This object is part of the opensm family of objects.
+ */
+
+#if HAVE_CONFIG_H
+# include <config.h>
+#endif /* HAVE_CONFIG_H */
+
+#include <string.h>
+#include <iba/ib_types.h>
+#include <complib/cl_debug.h>
+#include <opensm/osm_file_ids.h>
+#define FILE_ID OSM_FILE_RESP_C
+#include <opensm/osm_madw.h>
+#include <opensm/osm_attrib_req.h>
+#include <opensm/osm_log.h>
+#include <opensm/osm_helper.h>
+#include <opensm/osm_mad_pool.h>
+#include <opensm/osm_vl15intf.h>
+#include <opensm/osm_msgdef.h>
+#include <opensm/osm_opensm.h>
+
+static void resp_make_resp_smp(IN osm_sm_t * sm, IN const ib_smp_t * p_src_smp,
+ IN ib_net16_t status,
+ IN const uint8_t * p_payload,
+ OUT ib_smp_t * p_dest_smp)
+{
+ OSM_LOG_ENTER(sm->p_log);
+
+ CL_ASSERT(p_dest_smp);
+ CL_ASSERT(p_src_smp);
+ CL_ASSERT(!ib_smp_is_response(p_src_smp));
+
+ *p_dest_smp = *p_src_smp;
+ if (p_src_smp->method == IB_MAD_METHOD_GET ||
+ p_src_smp->method == IB_MAD_METHOD_SET) {
+ p_dest_smp->method = IB_MAD_METHOD_GET_RESP;
+ p_dest_smp->status = status;
+ } else if (p_src_smp->method == IB_MAD_METHOD_TRAP) {
+ p_dest_smp->method = IB_MAD_METHOD_TRAP_REPRESS;
+ p_dest_smp->status = 0;
+ } else {
+ OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR 1302: "
+ "src smp method unsupported 0x%X\n", p_src_smp->method);
+ goto Exit;
+ }
+
+ if (p_src_smp->mgmt_class == IB_MCLASS_SUBN_DIR)
+ p_dest_smp->status |= IB_SMP_DIRECTION;
+
+ p_dest_smp->dr_dlid = p_dest_smp->dr_slid;
+ p_dest_smp->dr_slid = p_dest_smp->dr_dlid;
+ memcpy(&p_dest_smp->data, p_payload, IB_SMP_DATA_SIZE);
+
+Exit:
+ OSM_LOG_EXIT(sm->p_log);
+}
+
+ib_api_status_t osm_resp_send(IN osm_sm_t * sm,
+ IN const osm_madw_t * p_req_madw,
+ IN ib_net16_t mad_status,
+ IN const uint8_t * p_payload)
+{
+ const ib_smp_t *p_req_smp;
+ ib_smp_t *p_smp;
+ osm_madw_t *p_madw;
+ ib_api_status_t status = IB_SUCCESS;
+
+ OSM_LOG_ENTER(sm->p_log);
+
+ CL_ASSERT(p_req_madw);
+ CL_ASSERT(p_payload);
+
+ /* do nothing if we are exiting ... */
+ if (osm_exit_flag)
+ goto Exit;
+
+ p_madw = osm_mad_pool_get(sm->p_mad_pool,
+ osm_madw_get_bind_handle(p_req_madw),
+ MAD_BLOCK_SIZE, NULL);
+
+ if (p_madw == NULL) {
+ OSM_LOG(sm->p_log, OSM_LOG_ERROR,
+ "ERR 1301: Unable to acquire MAD\n");
+ status = IB_INSUFFICIENT_RESOURCES;
+ goto Exit;
+ }
+
+ /*
+ Copy the request smp to the response smp, then just
+ update the necessary fields.
+ */
+ p_smp = osm_madw_get_smp_ptr(p_madw);
+ p_req_smp = osm_madw_get_smp_ptr(p_req_madw);
+ resp_make_resp_smp(sm, p_req_smp, mad_status, p_payload, p_smp);
+ p_madw->mad_addr.dest_lid =
+ p_req_madw->mad_addr.addr_type.smi.source_lid;
+ p_madw->mad_addr.addr_type.smi.source_lid =
+ p_req_madw->mad_addr.dest_lid;
+
+ p_madw->resp_expected = FALSE;
+ p_madw->fail_msg = CL_DISP_MSGID_NONE;
+
+ OSM_LOG(sm->p_log, OSM_LOG_DEBUG, "Responding to %s (0x%X)"
+ "\n\t\t\t\tattribute modifier 0x%X, TID 0x%" PRIx64 "\n",
+ ib_get_sm_attr_str(p_smp->attr_id), cl_ntoh16(p_smp->attr_id),
+ cl_ntoh32(p_smp->attr_mod), cl_ntoh64(p_smp->trans_id));
+
+ osm_vl15_post(sm->p_vl15, p_madw);
+
+Exit:
+ OSM_LOG_EXIT(sm->p_log);
+ return status;
+}
diff --git a/contrib/ofed/opensm/opensm/osm_router.c b/contrib/ofed/opensm/opensm/osm_router.c
new file mode 100644
index 0000000..af5fff5
--- /dev/null
+++ b/contrib/ofed/opensm/opensm/osm_router.c
@@ -0,0 +1,73 @@
+/*
+ * Copyright (c) 2004-2009 Voltaire, Inc. All rights reserved.
+ * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved.
+ * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+/*
+ * Abstract:
+ * Implementation of osm_router_t.
+ * This object represents an Infiniband router.
+ * This object is part of the opensm family of objects.
+ */
+
+#if HAVE_CONFIG_H
+# include <config.h>
+#endif /* HAVE_CONFIG_H */
+
+#include <stdlib.h>
+#include <string.h>
+#include <iba/ib_types.h>
+#include <opensm/osm_file_ids.h>
+#define FILE_ID OSM_FILE_ROUTER_C
+#include <opensm/osm_router.h>
+
+void osm_router_delete(IN OUT osm_router_t ** pp_rtr)
+{
+ free(*pp_rtr);
+ *pp_rtr = NULL;
+}
+
+osm_router_t *osm_router_new(IN osm_port_t * p_port)
+{
+ osm_router_t *p_rtr;
+
+ CL_ASSERT(p_port);
+
+ p_rtr = malloc(sizeof(*p_rtr));
+ if (p_rtr) {
+ memset(p_rtr, 0, sizeof(*p_rtr));
+ p_rtr->p_port = p_port;
+ }
+
+ return p_rtr;
+}
diff --git a/contrib/ofed/opensm/opensm/osm_sa.c b/contrib/ofed/opensm/opensm/osm_sa.c
new file mode 100644
index 0000000..7ef2f68
--- /dev/null
+++ b/contrib/ofed/opensm/opensm/osm_sa.c
@@ -0,0 +1,1379 @@
+/*
+ * Copyright (c) 2004-2009 Voltaire, Inc. All rights reserved.
+ * Copyright (c) 2002-2014 Mellanox Technologies LTD. All rights reserved.
+ * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
+ * Copyright (c) 2008 Xsigo Systems Inc. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+/*
+ * Abstract:
+ * Implementation of osm_sa_t.
+ * This object represents the Subnet Administration object.
+ * This object is part of the opensm family of objects.
+ */
+
+#if HAVE_CONFIG_H
+# include <config.h>
+#endif /* HAVE_CONFIG_H */
+
+#include <string.h>
+#include <ctype.h>
+#include <errno.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <complib/cl_qmap.h>
+#include <complib/cl_passivelock.h>
+#include <complib/cl_debug.h>
+#include <iba/ib_types.h>
+#include <opensm/osm_file_ids.h>
+#define FILE_ID OSM_FILE_SA_C
+#include <opensm/osm_sa.h>
+#include <opensm/osm_madw.h>
+#include <opensm/osm_log.h>
+#include <opensm/osm_subnet.h>
+#include <opensm/osm_mad_pool.h>
+#include <opensm/osm_msgdef.h>
+#include <opensm/osm_opensm.h>
+#include <opensm/osm_multicast.h>
+#include <opensm/osm_inform.h>
+#include <opensm/osm_service.h>
+#include <opensm/osm_guid.h>
+#include <opensm/osm_helper.h>
+#include <vendor/osm_vendor_api.h>
+
+#define OSM_SA_INITIAL_TID_VALUE 0xabc
+
+extern void osm_cpi_rcv_process(IN void *context, IN void *data);
+extern void osm_gir_rcv_process(IN void *context, IN void *data);
+extern void osm_infr_rcv_process(IN void *context, IN void *data);
+extern void osm_infir_rcv_process(IN void *context, IN void *data);
+extern void osm_lftr_rcv_process(IN void *context, IN void *data);
+extern void osm_lr_rcv_process(IN void *context, IN void *data);
+extern void osm_mcmr_rcv_process(IN void *context, IN void *data);
+extern void osm_mftr_rcv_process(IN void *context, IN void *data);
+extern void osm_mpr_rcv_process(IN void *context, IN void *data);
+extern void osm_nr_rcv_process(IN void *context, IN void *data);
+extern void osm_pr_rcv_process(IN void *context, IN void *data);
+extern void osm_pkey_rec_rcv_process(IN void *context, IN void *data);
+extern void osm_pir_rcv_process(IN void *context, IN void *data);
+extern void osm_sr_rcv_process(IN void *context, IN void *data);
+extern void osm_slvl_rec_rcv_process(IN void *context, IN void *data);
+extern void osm_smir_rcv_process(IN void *context, IN void *data);
+extern void osm_sir_rcv_process(IN void *context, IN void *data);
+extern void osm_vlarb_rec_rcv_process(IN void *context, IN void *data);
+extern void osm_sr_rcv_lease_cb(IN void *context);
+
+void osm_sa_construct(IN osm_sa_t * p_sa)
+{
+ memset(p_sa, 0, sizeof(*p_sa));
+ p_sa->state = OSM_SA_STATE_INIT;
+ p_sa->sa_trans_id = OSM_SA_INITIAL_TID_VALUE;
+
+ cl_timer_construct(&p_sa->sr_timer);
+}
+
+void osm_sa_shutdown(IN osm_sa_t * p_sa)
+{
+ OSM_LOG_ENTER(p_sa->p_log);
+
+ cl_timer_stop(&p_sa->sr_timer);
+
+ /* unbind from the mad service */
+ osm_sa_mad_ctrl_unbind(&p_sa->mad_ctrl);
+
+ /* remove any registered dispatcher message */
+ cl_disp_unregister(p_sa->nr_disp_h);
+ cl_disp_unregister(p_sa->pir_disp_h);
+ cl_disp_unregister(p_sa->gir_disp_h);
+ cl_disp_unregister(p_sa->lr_disp_h);
+ cl_disp_unregister(p_sa->pr_disp_h);
+#if defined (VENDOR_RMPP_SUPPORT) && defined (DUAL_SIDED_RMPP)
+ cl_disp_unregister(p_sa->mpr_disp_h);
+#endif
+ cl_disp_unregister(p_sa->smir_disp_h);
+ cl_disp_unregister(p_sa->mcmr_disp_h);
+ cl_disp_unregister(p_sa->sr_disp_h);
+ cl_disp_unregister(p_sa->infr_disp_h);
+ cl_disp_unregister(p_sa->infir_disp_h);
+ cl_disp_unregister(p_sa->vlarb_disp_h);
+ cl_disp_unregister(p_sa->slvl_disp_h);
+ cl_disp_unregister(p_sa->pkey_disp_h);
+ cl_disp_unregister(p_sa->lft_disp_h);
+ cl_disp_unregister(p_sa->sir_disp_h);
+ cl_disp_unregister(p_sa->mft_disp_h);
+
+ if (p_sa->p_set_disp) {
+ cl_disp_unregister(p_sa->mcmr_set_disp_h);
+ cl_disp_unregister(p_sa->infr_set_disp_h);
+ cl_disp_unregister(p_sa->sr_set_disp_h);
+ cl_disp_unregister(p_sa->gir_set_disp_h);
+ }
+
+ osm_sa_mad_ctrl_destroy(&p_sa->mad_ctrl);
+
+ OSM_LOG_EXIT(p_sa->p_log);
+}
+
+void osm_sa_destroy(IN osm_sa_t * p_sa)
+{
+ OSM_LOG_ENTER(p_sa->p_log);
+
+ p_sa->state = OSM_SA_STATE_INIT;
+
+ cl_timer_destroy(&p_sa->sr_timer);
+
+ OSM_LOG_EXIT(p_sa->p_log);
+}
+
+ib_api_status_t osm_sa_init(IN osm_sm_t * p_sm, IN osm_sa_t * p_sa,
+ IN osm_subn_t * p_subn, IN osm_vendor_t * p_vendor,
+ IN osm_mad_pool_t * p_mad_pool,
+ IN osm_log_t * p_log, IN osm_stats_t * p_stats,
+ IN cl_dispatcher_t * p_disp,
+ IN cl_dispatcher_t * p_set_disp,
+ IN cl_plock_t * p_lock)
+{
+ ib_api_status_t status;
+
+ OSM_LOG_ENTER(p_log);
+
+ p_sa->sm = p_sm;
+ p_sa->p_subn = p_subn;
+ p_sa->p_vendor = p_vendor;
+ p_sa->p_mad_pool = p_mad_pool;
+ p_sa->p_log = p_log;
+ p_sa->p_disp = p_disp;
+ p_sa->p_set_disp = p_set_disp;
+ p_sa->p_lock = p_lock;
+
+ p_sa->state = OSM_SA_STATE_READY;
+
+ status = osm_sa_mad_ctrl_init(&p_sa->mad_ctrl, p_sa, p_sa->p_mad_pool,
+ p_sa->p_vendor, p_subn, p_log, p_stats,
+ p_disp, p_set_disp);
+ if (status != IB_SUCCESS)
+ goto Exit;
+
+ status = cl_timer_init(&p_sa->sr_timer, osm_sr_rcv_lease_cb, p_sa);
+ if (status != IB_SUCCESS)
+ goto Exit;
+
+ status = IB_INSUFFICIENT_RESOURCES;
+ p_sa->cpi_disp_h = cl_disp_register(p_disp, OSM_MSG_MAD_CLASS_PORT_INFO,
+ osm_cpi_rcv_process, p_sa);
+ if (p_sa->cpi_disp_h == CL_DISP_INVALID_HANDLE)
+ goto Exit;
+
+ p_sa->nr_disp_h = cl_disp_register(p_disp, OSM_MSG_MAD_NODE_RECORD,
+ osm_nr_rcv_process, p_sa);
+ if (p_sa->nr_disp_h == CL_DISP_INVALID_HANDLE)
+ goto Exit;
+
+ p_sa->pir_disp_h = cl_disp_register(p_disp, OSM_MSG_MAD_PORTINFO_RECORD,
+ osm_pir_rcv_process, p_sa);
+ if (p_sa->pir_disp_h == CL_DISP_INVALID_HANDLE)
+ goto Exit;
+
+ p_sa->gir_disp_h = cl_disp_register(p_disp, OSM_MSG_MAD_GUIDINFO_RECORD,
+ osm_gir_rcv_process, p_sa);
+ if (p_sa->gir_disp_h == CL_DISP_INVALID_HANDLE)
+ goto Exit;
+
+ p_sa->lr_disp_h = cl_disp_register(p_disp, OSM_MSG_MAD_LINK_RECORD,
+ osm_lr_rcv_process, p_sa);
+ if (p_sa->lr_disp_h == CL_DISP_INVALID_HANDLE)
+ goto Exit;
+
+ p_sa->pr_disp_h = cl_disp_register(p_disp, OSM_MSG_MAD_PATH_RECORD,
+ osm_pr_rcv_process, p_sa);
+ if (p_sa->pr_disp_h == CL_DISP_INVALID_HANDLE)
+ goto Exit;
+
+#if defined (VENDOR_RMPP_SUPPORT) && defined (DUAL_SIDED_RMPP)
+ p_sa->mpr_disp_h =
+ cl_disp_register(p_disp, OSM_MSG_MAD_MULTIPATH_RECORD,
+ osm_mpr_rcv_process, p_sa);
+ if (p_sa->mpr_disp_h == CL_DISP_INVALID_HANDLE)
+ goto Exit;
+#endif
+
+ p_sa->smir_disp_h = cl_disp_register(p_disp, OSM_MSG_MAD_SMINFO_RECORD,
+ osm_smir_rcv_process, p_sa);
+ if (p_sa->smir_disp_h == CL_DISP_INVALID_HANDLE)
+ goto Exit;
+
+ p_sa->mcmr_disp_h =
+ cl_disp_register(p_disp, OSM_MSG_MAD_MCMEMBER_RECORD,
+ osm_mcmr_rcv_process, p_sa);
+ if (p_sa->mcmr_disp_h == CL_DISP_INVALID_HANDLE)
+ goto Exit;
+
+ p_sa->sr_disp_h = cl_disp_register(p_disp, OSM_MSG_MAD_SERVICE_RECORD,
+ osm_sr_rcv_process, p_sa);
+ if (p_sa->sr_disp_h == CL_DISP_INVALID_HANDLE)
+ goto Exit;
+
+ p_sa->infr_disp_h = cl_disp_register(p_disp, OSM_MSG_MAD_INFORM_INFO,
+ osm_infr_rcv_process, p_sa);
+ if (p_sa->infr_disp_h == CL_DISP_INVALID_HANDLE)
+ goto Exit;
+
+ p_sa->infir_disp_h =
+ cl_disp_register(p_disp, OSM_MSG_MAD_INFORM_INFO_RECORD,
+ osm_infir_rcv_process, p_sa);
+ if (p_sa->infir_disp_h == CL_DISP_INVALID_HANDLE)
+ goto Exit;
+
+ p_sa->vlarb_disp_h = cl_disp_register(p_disp, OSM_MSG_MAD_VL_ARB_RECORD,
+ osm_vlarb_rec_rcv_process, p_sa);
+ if (p_sa->vlarb_disp_h == CL_DISP_INVALID_HANDLE)
+ goto Exit;
+
+ p_sa->slvl_disp_h =
+ cl_disp_register(p_disp, OSM_MSG_MAD_SLVL_TBL_RECORD,
+ osm_slvl_rec_rcv_process, p_sa);
+ if (p_sa->slvl_disp_h == CL_DISP_INVALID_HANDLE)
+ goto Exit;
+
+ p_sa->pkey_disp_h =
+ cl_disp_register(p_disp, OSM_MSG_MAD_PKEY_TBL_RECORD,
+ osm_pkey_rec_rcv_process, p_sa);
+ if (p_sa->pkey_disp_h == CL_DISP_INVALID_HANDLE)
+ goto Exit;
+
+ p_sa->lft_disp_h = cl_disp_register(p_disp, OSM_MSG_MAD_LFT_RECORD,
+ osm_lftr_rcv_process, p_sa);
+ if (p_sa->lft_disp_h == CL_DISP_INVALID_HANDLE)
+ goto Exit;
+
+ p_sa->sir_disp_h =
+ cl_disp_register(p_disp, OSM_MSG_MAD_SWITCH_INFO_RECORD,
+ osm_sir_rcv_process, p_sa);
+ if (p_sa->sir_disp_h == CL_DISP_INVALID_HANDLE)
+ goto Exit;
+
+ p_sa->mft_disp_h = cl_disp_register(p_disp, OSM_MSG_MAD_MFT_RECORD,
+ osm_mftr_rcv_process, p_sa);
+ if (p_sa->mft_disp_h == CL_DISP_INVALID_HANDLE)
+ goto Exit;
+
+ /*
+ * When p_set_disp is defined, it means that we use different dispatcher
+ * for SA Set requests, and we need to register handlers for it.
+ */
+ if (p_set_disp) {
+ p_sa->gir_set_disp_h =
+ cl_disp_register(p_set_disp, OSM_MSG_MAD_GUIDINFO_RECORD,
+ osm_gir_rcv_process, p_sa);
+ if (p_sa->gir_set_disp_h == CL_DISP_INVALID_HANDLE)
+ goto Exit;
+
+ p_sa->mcmr_set_disp_h =
+ cl_disp_register(p_set_disp, OSM_MSG_MAD_MCMEMBER_RECORD,
+ osm_mcmr_rcv_process, p_sa);
+ if (p_sa->mcmr_set_disp_h == CL_DISP_INVALID_HANDLE)
+ goto Exit;
+
+ p_sa->sr_set_disp_h =
+ cl_disp_register(p_set_disp, OSM_MSG_MAD_SERVICE_RECORD,
+ osm_sr_rcv_process, p_sa);
+ if (p_sa->sr_set_disp_h == CL_DISP_INVALID_HANDLE)
+ goto Exit;
+
+ p_sa->infr_set_disp_h =
+ cl_disp_register(p_set_disp, OSM_MSG_MAD_INFORM_INFO,
+ osm_infr_rcv_process, p_sa);
+ if (p_sa->infr_set_disp_h == CL_DISP_INVALID_HANDLE)
+ goto Exit;
+ }
+
+ status = IB_SUCCESS;
+Exit:
+ OSM_LOG_EXIT(p_log);
+ return status;
+}
+
+ib_api_status_t osm_sa_bind(IN osm_sa_t * p_sa, IN ib_net64_t port_guid)
+{
+ ib_api_status_t status;
+
+ OSM_LOG_ENTER(p_sa->p_log);
+
+ status = osm_sa_mad_ctrl_bind(&p_sa->mad_ctrl, port_guid);
+
+ if (status != IB_SUCCESS) {
+ OSM_LOG(p_sa->p_log, OSM_LOG_ERROR, "ERR 4C03: "
+ "SA MAD Controller bind failed (%s)\n",
+ ib_get_err_str(status));
+ goto Exit;
+ }
+
+Exit:
+ OSM_LOG_EXIT(p_sa->p_log);
+ return status;
+}
+
+ib_api_status_t osm_sa_send(osm_sa_t *sa, IN osm_madw_t * p_madw,
+ IN boolean_t resp_expected)
+{
+ ib_api_status_t status;
+
+ cl_atomic_inc(&sa->p_subn->p_osm->stats.sa_mads_sent);
+ status = osm_vendor_send(p_madw->h_bind, p_madw, resp_expected);
+ if (status != IB_SUCCESS) {
+ cl_atomic_dec(&sa->p_subn->p_osm->stats.sa_mads_sent);
+ OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 4C04: "
+ "osm_vendor_send failed, status = %s\n",
+ ib_get_err_str(status));
+ }
+ return status;
+}
+
+void osm_sa_send_error(IN osm_sa_t * sa, IN const osm_madw_t * p_madw,
+ IN ib_net16_t sa_status)
+{
+ osm_madw_t *p_resp_madw;
+ ib_sa_mad_t *p_resp_sa_mad;
+ ib_sa_mad_t *p_sa_mad;
+
+ OSM_LOG_ENTER(sa->p_log);
+
+ /* avoid races - if we are exiting - exit */
+ if (osm_exit_flag) {
+ OSM_LOG(sa->p_log, OSM_LOG_DEBUG,
+ "Ignoring requested send after exit\n");
+ goto Exit;
+ }
+
+ p_resp_madw = osm_mad_pool_get(sa->p_mad_pool,
+ p_madw->h_bind, MAD_BLOCK_SIZE,
+ &p_madw->mad_addr);
+
+ if (p_resp_madw == NULL) {
+ OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 4C07: "
+ "Unable to acquire response MAD\n");
+ goto Exit;
+ }
+
+ p_resp_sa_mad = osm_madw_get_sa_mad_ptr(p_resp_madw);
+ p_sa_mad = osm_madw_get_sa_mad_ptr(p_madw);
+
+ /* Copy the MAD header back into the response mad */
+ *p_resp_sa_mad = *p_sa_mad;
+ p_resp_sa_mad->status = sa_status;
+
+ if (p_resp_sa_mad->method == IB_MAD_METHOD_SET)
+ p_resp_sa_mad->method = IB_MAD_METHOD_GET;
+ else if (p_resp_sa_mad->method == IB_MAD_METHOD_GETTABLE)
+ p_resp_sa_mad->attr_offset = 0;
+
+ p_resp_sa_mad->method |= IB_MAD_METHOD_RESP_MASK;
+
+ /*
+ * C15-0.1.5 - always return SM_Key = 0 (table 185 p 884)
+ */
+ p_resp_sa_mad->sm_key = 0;
+
+ /*
+ * o15-0.2.7 - The PathRecord Attribute ID shall be used in
+ * the response (to a SubnAdmGetMulti(MultiPathRecord)
+ */
+ if (p_resp_sa_mad->attr_id == IB_MAD_ATTR_MULTIPATH_RECORD)
+ p_resp_sa_mad->attr_id = IB_MAD_ATTR_PATH_RECORD;
+
+ if (OSM_LOG_IS_ACTIVE_V2(sa->p_log, OSM_LOG_FRAMES))
+ osm_dump_sa_mad_v2(sa->p_log, p_resp_sa_mad, FILE_ID, OSM_LOG_FRAMES);
+
+ osm_sa_send(sa, p_resp_madw, FALSE);
+
+Exit:
+ OSM_LOG_EXIT(sa->p_log);
+}
+
+void osm_sa_respond(osm_sa_t *sa, osm_madw_t *madw, size_t attr_size,
+ cl_qlist_t *list)
+{
+ cl_list_item_t *item;
+ osm_madw_t *resp_madw;
+ ib_sa_mad_t *sa_mad, *resp_sa_mad;
+ unsigned num_rec, i;
+#ifndef VENDOR_RMPP_SUPPORT
+ unsigned trim_num_rec;
+#endif
+ unsigned char *p;
+
+ sa_mad = osm_madw_get_sa_mad_ptr(madw);
+ num_rec = cl_qlist_count(list);
+
+ /*
+ * C15-0.1.30:
+ * If we do a SubnAdmGet and got more than one record it is an error!
+ */
+ if (sa_mad->method == IB_MAD_METHOD_GET && num_rec > 1) {
+ OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 4C05: "
+ "Got %u records for SubnAdmGet(%s) comp_mask 0x%016" PRIx64
+ "from requester LID %u\n",
+ num_rec, ib_get_sa_attr_str(sa_mad->attr_id),
+ cl_ntoh64(sa_mad->comp_mask),
+ cl_ntoh16(madw->mad_addr.dest_lid));
+ osm_sa_send_error(sa, madw, IB_SA_MAD_STATUS_TOO_MANY_RECORDS);
+ goto Exit;
+ }
+
+#ifndef VENDOR_RMPP_SUPPORT
+ trim_num_rec = (MAD_BLOCK_SIZE - IB_SA_MAD_HDR_SIZE) / attr_size;
+ if (trim_num_rec < num_rec) {
+ OSM_LOG(sa->p_log, OSM_LOG_VERBOSE,
+ "Number of records:%u trimmed to:%u to fit in one MAD\n",
+ num_rec, trim_num_rec);
+ num_rec = trim_num_rec;
+ }
+#endif
+
+ OSM_LOG(sa->p_log, OSM_LOG_DEBUG, "Returning %u records\n", num_rec);
+
+ if (sa_mad->method == IB_MAD_METHOD_GET && num_rec == 0) {
+ osm_sa_send_error(sa, madw, IB_SA_MAD_STATUS_NO_RECORDS);
+ goto Exit;
+ }
+
+ /*
+ * Get a MAD to reply. Address of Mad is in the received mad_wrapper
+ */
+ resp_madw = osm_mad_pool_get(sa->p_mad_pool, madw->h_bind,
+ num_rec * attr_size + IB_SA_MAD_HDR_SIZE,
+ &madw->mad_addr);
+ if (!resp_madw) {
+ OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 4C06: "
+ "osm_mad_pool_get failed\n");
+ osm_sa_send_error(sa, madw, IB_SA_MAD_STATUS_NO_RESOURCES);
+ goto Exit;
+ }
+
+ resp_sa_mad = osm_madw_get_sa_mad_ptr(resp_madw);
+
+ /*
+ Copy the MAD header back into the response mad.
+ Set the 'R' bit and the payload length,
+ Then copy all records from the list into the response payload.
+ */
+
+ memcpy(resp_sa_mad, sa_mad, IB_SA_MAD_HDR_SIZE);
+ if (resp_sa_mad->method == IB_MAD_METHOD_SET)
+ resp_sa_mad->method = IB_MAD_METHOD_GET;
+ resp_sa_mad->method |= IB_MAD_METHOD_RESP_MASK;
+ /* C15-0.1.5 - always return SM_Key = 0 (table 185 p 884) */
+ resp_sa_mad->sm_key = 0;
+
+ /* Fill in the offset (paylen will be done by the rmpp SAR) */
+ resp_sa_mad->attr_offset = num_rec ? ib_get_attr_offset(attr_size) : 0;
+
+ p = ib_sa_mad_get_payload_ptr(resp_sa_mad);
+
+#ifndef VENDOR_RMPP_SUPPORT
+ /* we support only one packet RMPP - so we will set the first and
+ last flags for gettable */
+ if (resp_sa_mad->method == IB_MAD_METHOD_GETTABLE_RESP) {
+ resp_sa_mad->rmpp_type = IB_RMPP_TYPE_DATA;
+ resp_sa_mad->rmpp_flags =
+ IB_RMPP_FLAG_FIRST | IB_RMPP_FLAG_LAST |
+ IB_RMPP_FLAG_ACTIVE;
+ }
+#else
+ /* forcefully define the packet as RMPP one */
+ if (resp_sa_mad->method == IB_MAD_METHOD_GETTABLE_RESP)
+ resp_sa_mad->rmpp_flags = IB_RMPP_FLAG_ACTIVE;
+#endif
+
+ for (i = 0; i < num_rec; i++) {
+ item = cl_qlist_remove_head(list);
+ memcpy(p, ((osm_sa_item_t *)item)->resp.data, attr_size);
+ p += attr_size;
+ free(item);
+ }
+
+ osm_dump_sa_mad_v2(sa->p_log, resp_sa_mad, FILE_ID, OSM_LOG_FRAMES);
+ osm_sa_send(sa, resp_madw, FALSE);
+
+Exit:
+ /* need to set the mem free ... */
+ item = cl_qlist_remove_head(list);
+ while (item != cl_qlist_end(list)) {
+ free(item);
+ item = cl_qlist_remove_head(list);
+ }
+}
+
+/*
+ * SA DB Dumper
+ *
+ */
+
+struct opensm_dump_context {
+ osm_opensm_t *p_osm;
+ FILE *file;
+};
+
+static int
+opensm_dump_to_file(osm_opensm_t * p_osm, const char *file_name,
+ void (*dump_func) (osm_opensm_t * p_osm, FILE * file))
+{
+ char path[1024];
+ char path_tmp[1032];
+ FILE *file;
+ int fd, status = 0;
+
+ snprintf(path, sizeof(path), "%s/%s",
+ p_osm->subn.opt.dump_files_dir, file_name);
+
+ snprintf(path_tmp, sizeof(path_tmp), "%s.tmp", path);
+
+ file = fopen(path_tmp, "w");
+ if (!file) {
+ OSM_LOG(&p_osm->log, OSM_LOG_ERROR, "ERR 4C01: "
+ "cannot open file \'%s\': %s\n",
+ path_tmp, strerror(errno));
+ return -1;
+ }
+
+ if (chmod(path_tmp, S_IRUSR | S_IWUSR)) {
+ OSM_LOG(&p_osm->log, OSM_LOG_ERROR, "ERR 4C0C: "
+ "cannot change access permissions of file "
+ "\'%s\' : %s\n",
+ path_tmp, strerror(errno));
+ fclose(file);
+ return -1;
+ }
+
+ dump_func(p_osm, file);
+
+ if (p_osm->subn.opt.fsync_high_avail_files) {
+ if (fflush(file) == 0) {
+ fd = fileno(file);
+ if (fd != -1) {
+ if (fsync(fd) == -1)
+ OSM_LOG(&p_osm->log, OSM_LOG_ERROR,
+ "ERR 4C08: fsync() failed (%s) for %s\n",
+ strerror(errno), path_tmp);
+ } else
+ OSM_LOG(&p_osm->log, OSM_LOG_ERROR, "ERR 4C09: "
+ "fileno() failed for %s\n", path_tmp);
+ } else
+ OSM_LOG(&p_osm->log, OSM_LOG_ERROR, "ERR 4C0A: "
+ "fflush() failed (%s) for %s\n",
+ strerror(errno), path_tmp);
+ }
+
+ fclose(file);
+
+ status = rename(path_tmp, path);
+ if (status) {
+ OSM_LOG(&p_osm->log, OSM_LOG_ERROR, "ERR 4C0B: "
+ "Failed to rename file:%s (err:%s)\n",
+ path_tmp, strerror(errno));
+ }
+
+ return status;
+}
+
+static void mcast_mgr_dump_one_port(cl_map_item_t * p_map_item, void *cxt)
+{
+ FILE *file = ((struct opensm_dump_context *)cxt)->file;
+ osm_mcm_alias_guid_t *p_mcm_alias_guid = (osm_mcm_alias_guid_t *) p_map_item;
+
+ fprintf(file, "mcm_port: "
+ "port_gid=0x%016" PRIx64 ":0x%016" PRIx64 " "
+ "scope_state=0x%02x proxy_join=0x%x" "\n\n",
+ cl_ntoh64(p_mcm_alias_guid->port_gid.unicast.prefix),
+ cl_ntoh64(p_mcm_alias_guid->port_gid.unicast.interface_id),
+ p_mcm_alias_guid->scope_state, p_mcm_alias_guid->proxy_join);
+}
+
+static void sa_dump_one_mgrp(osm_mgrp_t *p_mgrp, void *cxt)
+{
+ struct opensm_dump_context dump_context;
+ osm_opensm_t *p_osm = ((struct opensm_dump_context *)cxt)->p_osm;
+ FILE *file = ((struct opensm_dump_context *)cxt)->file;
+
+ fprintf(file, "MC Group 0x%04x %s:"
+ " mgid=0x%016" PRIx64 ":0x%016" PRIx64
+ " port_gid=0x%016" PRIx64 ":0x%016" PRIx64
+ " qkey=0x%08x mlid=0x%04x mtu=0x%02x tclass=0x%02x"
+ " pkey=0x%04x rate=0x%02x pkt_life=0x%02x sl_flow_hop=0x%08x"
+ " scope_state=0x%02x proxy_join=0x%x" "\n\n",
+ cl_ntoh16(p_mgrp->mlid),
+ p_mgrp->well_known ? " (well known)" : "",
+ cl_ntoh64(p_mgrp->mcmember_rec.mgid.unicast.prefix),
+ cl_ntoh64(p_mgrp->mcmember_rec.mgid.unicast.interface_id),
+ cl_ntoh64(p_mgrp->mcmember_rec.port_gid.unicast.prefix),
+ cl_ntoh64(p_mgrp->mcmember_rec.port_gid.unicast.interface_id),
+ cl_ntoh32(p_mgrp->mcmember_rec.qkey),
+ cl_ntoh16(p_mgrp->mcmember_rec.mlid),
+ p_mgrp->mcmember_rec.mtu,
+ p_mgrp->mcmember_rec.tclass,
+ cl_ntoh16(p_mgrp->mcmember_rec.pkey),
+ p_mgrp->mcmember_rec.rate,
+ p_mgrp->mcmember_rec.pkt_life,
+ cl_ntoh32(p_mgrp->mcmember_rec.sl_flow_hop),
+ p_mgrp->mcmember_rec.scope_state,
+ p_mgrp->mcmember_rec.proxy_join);
+
+ dump_context.p_osm = p_osm;
+ dump_context.file = file;
+
+ cl_qmap_apply_func(&p_mgrp->mcm_alias_port_tbl,
+ mcast_mgr_dump_one_port, &dump_context);
+}
+
+static void sa_dump_one_inform(cl_list_item_t * p_list_item, void *cxt)
+{
+ FILE *file = ((struct opensm_dump_context *)cxt)->file;
+ osm_infr_t *p_infr = (osm_infr_t *) p_list_item;
+ ib_inform_info_record_t *p_iir = &p_infr->inform_record;
+
+ fprintf(file, "InformInfo Record:"
+ " subscriber_gid=0x%016" PRIx64 ":0x%016" PRIx64
+ " subscriber_enum=0x%x"
+ " InformInfo:"
+ " gid=0x%016" PRIx64 ":0x%016" PRIx64
+ " lid_range_begin=0x%x"
+ " lid_range_end=0x%x"
+ " is_generic=0x%x"
+ " subscribe=0x%x"
+ " trap_type=0x%x"
+ " trap_num=0x%x"
+ " qpn_resp_time_val=0x%x"
+ " node_type=0x%06x"
+ " rep_addr: lid=0x%04x path_bits=0x%02x static_rate=0x%02x"
+ " remote_qp=0x%08x remote_qkey=0x%08x pkey_ix=0x%04x sl=0x%02x"
+ "\n\n",
+ cl_ntoh64(p_iir->subscriber_gid.unicast.prefix),
+ cl_ntoh64(p_iir->subscriber_gid.unicast.interface_id),
+ cl_ntoh16(p_iir->subscriber_enum),
+ cl_ntoh64(p_iir->inform_info.gid.unicast.prefix),
+ cl_ntoh64(p_iir->inform_info.gid.unicast.interface_id),
+ cl_ntoh16(p_iir->inform_info.lid_range_begin),
+ cl_ntoh16(p_iir->inform_info.lid_range_end),
+ p_iir->inform_info.is_generic,
+ p_iir->inform_info.subscribe,
+ cl_ntoh16(p_iir->inform_info.trap_type),
+ cl_ntoh16(p_iir->inform_info.g_or_v.generic.trap_num),
+ cl_ntoh32(p_iir->inform_info.g_or_v.generic.qpn_resp_time_val),
+ cl_ntoh32(ib_inform_info_get_prod_type(&p_iir->inform_info)),
+ cl_ntoh16(p_infr->report_addr.dest_lid),
+ p_infr->report_addr.path_bits,
+ p_infr->report_addr.static_rate,
+ cl_ntoh32(p_infr->report_addr.addr_type.gsi.remote_qp),
+ cl_ntoh32(p_infr->report_addr.addr_type.gsi.remote_qkey),
+ p_infr->report_addr.addr_type.gsi.pkey_ix,
+ p_infr->report_addr.addr_type.gsi.service_level);
+}
+
+static void sa_dump_one_service(cl_list_item_t * p_list_item, void *cxt)
+{
+ FILE *file = ((struct opensm_dump_context *)cxt)->file;
+ osm_svcr_t *p_svcr = (osm_svcr_t *) p_list_item;
+ ib_service_record_t *p_sr = &p_svcr->service_record;
+
+ fprintf(file, "Service Record: id=0x%016" PRIx64
+ " gid=0x%016" PRIx64 ":0x%016" PRIx64
+ " pkey=0x%x"
+ " lease=0x%x"
+ " key=0x%02x%02x%02x%02x%02x%02x%02x%02x"
+ ":0x%02x%02x%02x%02x%02x%02x%02x%02x"
+ " name=\'%s\'"
+ " data8=0x%02x%02x%02x%02x%02x%02x%02x%02x"
+ ":0x%02x%02x%02x%02x%02x%02x%02x%02x"
+ " data16=0x%04x%04x%04x%04x:0x%04x%04x%04x%04x"
+ " data32=0x%08x%08x:0x%08x%08x"
+ " data64=0x%016" PRIx64 ":0x%016" PRIx64
+ " modified_time=0x%x lease_period=0x%x\n\n",
+ cl_ntoh64(p_sr->service_id),
+ cl_ntoh64(p_sr->service_gid.unicast.prefix),
+ cl_ntoh64(p_sr->service_gid.unicast.interface_id),
+ cl_ntoh16(p_sr->service_pkey),
+ cl_ntoh32(p_sr->service_lease),
+ p_sr->service_key[0], p_sr->service_key[1],
+ p_sr->service_key[2], p_sr->service_key[3],
+ p_sr->service_key[4], p_sr->service_key[5],
+ p_sr->service_key[6], p_sr->service_key[7],
+ p_sr->service_key[8], p_sr->service_key[9],
+ p_sr->service_key[10], p_sr->service_key[11],
+ p_sr->service_key[12], p_sr->service_key[13],
+ p_sr->service_key[14], p_sr->service_key[15],
+ p_sr->service_name,
+ p_sr->service_data8[0], p_sr->service_data8[1],
+ p_sr->service_data8[2], p_sr->service_data8[3],
+ p_sr->service_data8[4], p_sr->service_data8[5],
+ p_sr->service_data8[6], p_sr->service_data8[7],
+ p_sr->service_data8[8], p_sr->service_data8[9],
+ p_sr->service_data8[10], p_sr->service_data8[11],
+ p_sr->service_data8[12], p_sr->service_data8[13],
+ p_sr->service_data8[14], p_sr->service_data8[15],
+ cl_ntoh16(p_sr->service_data16[0]),
+ cl_ntoh16(p_sr->service_data16[1]),
+ cl_ntoh16(p_sr->service_data16[2]),
+ cl_ntoh16(p_sr->service_data16[3]),
+ cl_ntoh16(p_sr->service_data16[4]),
+ cl_ntoh16(p_sr->service_data16[5]),
+ cl_ntoh16(p_sr->service_data16[6]),
+ cl_ntoh16(p_sr->service_data16[7]),
+ cl_ntoh32(p_sr->service_data32[0]),
+ cl_ntoh32(p_sr->service_data32[1]),
+ cl_ntoh32(p_sr->service_data32[2]),
+ cl_ntoh32(p_sr->service_data32[3]),
+ cl_ntoh64(p_sr->service_data64[0]),
+ cl_ntoh64(p_sr->service_data64[1]),
+ p_svcr->modified_time, p_svcr->lease_period);
+}
+
+static void sa_dump_one_port_guidinfo(cl_map_item_t * p_map_item, void *cxt)
+{
+ FILE *file = ((struct opensm_dump_context *)cxt)->file;
+ osm_port_t *p_port = (osm_port_t *) p_map_item;
+ uint32_t max_block;
+ int block_num;
+
+ if (!p_port->p_physp->p_guids)
+ return;
+
+ max_block = (p_port->p_physp->port_info.guid_cap + GUID_TABLE_MAX_ENTRIES - 1) /
+ GUID_TABLE_MAX_ENTRIES;
+
+ for (block_num = 0; block_num < max_block; block_num++) {
+ fprintf(file, "GUIDInfo Record:"
+ " base_guid=0x%016" PRIx64 " lid=0x%04x block_num=0x%x"
+ " guid0=0x%016" PRIx64 " guid1=0x%016" PRIx64
+ " guid2=0x%016" PRIx64 " guid3=0x%016" PRIx64
+ " guid4=0x%016" PRIx64 " guid5=0x%016" PRIx64
+ " guid6=0x%016" PRIx64 " guid7=0x%016" PRIx64
+ "\n\n",
+ cl_ntoh64((*p_port->p_physp->p_guids)[0]),
+ cl_ntoh16(osm_port_get_base_lid(p_port)), block_num,
+ cl_ntoh64((*p_port->p_physp->p_guids)[block_num * GUID_TABLE_MAX_ENTRIES]),
+ cl_ntoh64((*p_port->p_physp->p_guids)[block_num * GUID_TABLE_MAX_ENTRIES + 1]),
+ cl_ntoh64((*p_port->p_physp->p_guids)[block_num * GUID_TABLE_MAX_ENTRIES + 2]),
+ cl_ntoh64((*p_port->p_physp->p_guids)[block_num * GUID_TABLE_MAX_ENTRIES + 3]),
+ cl_ntoh64((*p_port->p_physp->p_guids)[block_num * GUID_TABLE_MAX_ENTRIES + 4]),
+ cl_ntoh64((*p_port->p_physp->p_guids)[block_num * GUID_TABLE_MAX_ENTRIES + 5]),
+ cl_ntoh64((*p_port->p_physp->p_guids)[block_num * GUID_TABLE_MAX_ENTRIES + 6]),
+ cl_ntoh64((*p_port->p_physp->p_guids)[block_num * GUID_TABLE_MAX_ENTRIES + 7]));
+ }
+}
+
+static void sa_dump_all_sa(osm_opensm_t * p_osm, FILE * file)
+{
+ struct opensm_dump_context dump_context;
+ osm_mgrp_t *p_mgrp;
+
+ dump_context.p_osm = p_osm;
+ dump_context.file = file;
+ OSM_LOG(&p_osm->log, OSM_LOG_DEBUG, "Dump guidinfo\n");
+ cl_qmap_apply_func(&p_osm->subn.port_guid_tbl,
+ sa_dump_one_port_guidinfo, &dump_context);
+ OSM_LOG(&p_osm->log, OSM_LOG_DEBUG, "Dump multicast\n");
+ for (p_mgrp = (osm_mgrp_t *) cl_fmap_head(&p_osm->subn.mgrp_mgid_tbl);
+ p_mgrp != (osm_mgrp_t *) cl_fmap_end(&p_osm->subn.mgrp_mgid_tbl);
+ p_mgrp = (osm_mgrp_t *) cl_fmap_next(&p_mgrp->map_item))
+ sa_dump_one_mgrp(p_mgrp, &dump_context);
+ OSM_LOG(&p_osm->log, OSM_LOG_DEBUG, "Dump inform\n");
+ cl_qlist_apply_func(&p_osm->subn.sa_infr_list,
+ sa_dump_one_inform, &dump_context);
+ OSM_LOG(&p_osm->log, OSM_LOG_DEBUG, "Dump services\n");
+ cl_qlist_apply_func(&p_osm->subn.sa_sr_list,
+ sa_dump_one_service, &dump_context);
+}
+
+int osm_sa_db_file_dump(osm_opensm_t * p_osm)
+{
+ int res = 1;
+
+ cl_plock_acquire(&p_osm->lock);
+ if (p_osm->sa.dirty) {
+ res = opensm_dump_to_file(
+ p_osm, "opensm-sa.dump", sa_dump_all_sa);
+ if (!res)
+ p_osm->sa.dirty = FALSE;
+ }
+ cl_plock_release(&p_osm->lock);
+
+ return res;
+}
+
+/*
+ * SA DB Loader
+ */
+static osm_mgrp_t *load_mcgroup(osm_opensm_t * p_osm, ib_net16_t mlid,
+ ib_member_rec_t * p_mcm_rec)
+{
+ ib_net64_t comp_mask;
+ osm_mgrp_t *p_mgrp;
+
+ cl_plock_excl_acquire(&p_osm->lock);
+
+ p_mgrp = osm_get_mgrp_by_mgid(&p_osm->subn, &p_mcm_rec->mgid);
+ if (p_mgrp) {
+ if (p_mgrp->mlid == mlid) {
+ OSM_LOG(&p_osm->log, OSM_LOG_DEBUG,
+ "mgrp %04x is already here.", cl_ntoh16(mlid));
+ goto _out;
+ }
+ OSM_LOG(&p_osm->log, OSM_LOG_VERBOSE,
+ "mlid %04x is already used by another MC group. Will "
+ "request clients reregistration.\n", cl_ntoh16(mlid));
+ p_mgrp = NULL;
+ goto _out;
+ }
+
+ comp_mask = IB_MCR_COMPMASK_MTU | IB_MCR_COMPMASK_MTU_SEL
+ | IB_MCR_COMPMASK_RATE | IB_MCR_COMPMASK_RATE_SEL;
+ if (!(p_mgrp = osm_mcmr_rcv_find_or_create_new_mgrp(&p_osm->sa,
+ comp_mask,
+ p_mcm_rec)) ||
+ p_mgrp->mlid != mlid) {
+ OSM_LOG(&p_osm->log, OSM_LOG_ERROR,
+ "cannot create MC group with mlid 0x%04x and mgid "
+ "0x%016" PRIx64 ":0x%016" PRIx64 "\n", cl_ntoh16(mlid),
+ cl_ntoh64(p_mcm_rec->mgid.unicast.prefix),
+ cl_ntoh64(p_mcm_rec->mgid.unicast.interface_id));
+ p_mgrp = NULL;
+ }
+
+_out:
+ cl_plock_release(&p_osm->lock);
+
+ return p_mgrp;
+}
+
+static int load_svcr(osm_opensm_t * p_osm, ib_service_record_t * sr,
+ uint32_t modified_time, uint32_t lease_period)
+{
+ osm_svcr_t *p_svcr;
+ int ret = 0;
+
+ cl_plock_excl_acquire(&p_osm->lock);
+
+ if (osm_svcr_get_by_rid(&p_osm->subn, &p_osm->log, sr)) {
+ OSM_LOG(&p_osm->log, OSM_LOG_VERBOSE,
+ "ServiceRecord already exists\n");
+ goto _out;
+ }
+
+ if (!(p_svcr = osm_svcr_new(sr))) {
+ OSM_LOG(&p_osm->log, OSM_LOG_ERROR,
+ "cannot allocate new service struct\n");
+ ret = -1;
+ goto _out;
+ }
+
+ p_svcr->modified_time = modified_time;
+ p_svcr->lease_period = lease_period;
+
+ OSM_LOG(&p_osm->log, OSM_LOG_DEBUG, "adding ServiceRecord...\n");
+
+ osm_svcr_insert_to_db(&p_osm->subn, &p_osm->log, p_svcr);
+
+ if (lease_period != 0xffffffff)
+ cl_timer_trim(&p_osm->sa.sr_timer, 1000);
+
+_out:
+ cl_plock_release(&p_osm->lock);
+
+ return ret;
+}
+
+static int load_infr(osm_opensm_t * p_osm, ib_inform_info_record_t * iir,
+ osm_mad_addr_t * addr)
+{
+ osm_infr_t infr, *p_infr;
+ int ret = 0;
+
+ infr.h_bind = p_osm->sa.mad_ctrl.h_bind;
+ infr.sa = &p_osm->sa;
+ /* other possible way to restore mad_addr partially is
+ to extract qpn from InformInfo and to find lid by gid */
+ infr.report_addr = *addr;
+ infr.inform_record = *iir;
+
+ cl_plock_excl_acquire(&p_osm->lock);
+ if (osm_infr_get_by_rec(&p_osm->subn, &p_osm->log, &infr)) {
+ OSM_LOG(&p_osm->log, OSM_LOG_VERBOSE,
+ "InformInfo Record already exists\n");
+ goto _out;
+ }
+
+ if (!(p_infr = osm_infr_new(&infr))) {
+ OSM_LOG(&p_osm->log, OSM_LOG_ERROR,
+ "cannot allocate new infr struct\n");
+ ret = -1;
+ goto _out;
+ }
+
+ OSM_LOG(&p_osm->log, OSM_LOG_DEBUG, "adding InformInfo Record...\n");
+
+ osm_infr_insert_to_db(&p_osm->subn, &p_osm->log, p_infr);
+
+_out:
+ cl_plock_release(&p_osm->lock);
+
+ return ret;
+}
+
+static int load_guidinfo(osm_opensm_t * p_osm, ib_net64_t base_guid,
+ ib_guidinfo_record_t *gir)
+{
+ osm_port_t *p_port;
+ uint32_t max_block;
+ int i, ret = 0;
+ osm_alias_guid_t *p_alias_guid, *p_alias_guid_check;
+
+ cl_plock_excl_acquire(&p_osm->lock);
+
+ p_port = osm_get_port_by_guid(&p_osm->subn, base_guid);
+ if (!p_port)
+ goto _out;
+
+ if (!p_port->p_physp->p_guids) {
+ max_block = (p_port->p_physp->port_info.guid_cap + GUID_TABLE_MAX_ENTRIES - 1) /
+ GUID_TABLE_MAX_ENTRIES;
+ p_port->p_physp->p_guids = calloc(max_block * GUID_TABLE_MAX_ENTRIES,
+ sizeof(ib_net64_t));
+ if (!p_port->p_physp->p_guids) {
+ OSM_LOG(&p_osm->log, OSM_LOG_ERROR,
+ "cannot allocate GUID table for port "
+ "GUID 0x%" PRIx64 "\n",
+ cl_ntoh64(p_port->p_physp->port_guid));
+ goto _out;
+ }
+ }
+
+ for (i = 0; i < GUID_TABLE_MAX_ENTRIES; i++) {
+ if (!gir->guid_info.guid[i])
+ continue;
+ /* skip block 0 index 0 */
+ if (gir->block_num == 0 && i == 0)
+ continue;
+ if (gir->block_num * GUID_TABLE_MAX_ENTRIES + i >
+ p_port->p_physp->port_info.guid_cap)
+ break;
+
+ p_alias_guid = osm_alias_guid_new(gir->guid_info.guid[i],
+ p_port);
+ if (!p_alias_guid) {
+ OSM_LOG(&p_osm->log, OSM_LOG_ERROR,
+ "Alias guid %d memory allocation failed"
+ " for port GUID 0x%" PRIx64 "\n",
+ gir->block_num * GUID_TABLE_MAX_ENTRIES + i,
+ cl_ntoh64(p_port->p_physp->port_guid));
+ goto _out;
+ }
+
+ p_alias_guid_check =
+ (osm_alias_guid_t *) cl_qmap_insert(&p_osm->subn.alias_port_guid_tbl,
+ p_alias_guid->alias_guid,
+ &p_alias_guid->map_item);
+ if (p_alias_guid_check != p_alias_guid) {
+ /* alias GUID is a duplicate */
+ OSM_LOG(&p_osm->log, OSM_LOG_ERROR,
+ "Duplicate alias port GUID 0x%" PRIx64
+ " index %d base port GUID 0x%" PRIx64 "\n",
+ cl_ntoh64(p_alias_guid->alias_guid),
+ gir->block_num * GUID_TABLE_MAX_ENTRIES + i,
+ cl_ntoh64(p_alias_guid->p_base_port->guid));
+ osm_alias_guid_delete(&p_alias_guid);
+ goto _out;
+ }
+ }
+
+ memcpy(&(*p_port->p_physp->p_guids)[gir->block_num * GUID_TABLE_MAX_ENTRIES],
+ &gir->guid_info, sizeof(ib_guid_info_t));
+
+ osm_queue_guidinfo(&p_osm->sa, p_port, gir->block_num);
+
+_out:
+ cl_plock_release(&p_osm->lock);
+
+ return ret;
+}
+
+#define UNPACK_FUNC(name,x) \
+static int unpack_##name##x(char *p, uint##x##_t *val_ptr) \
+{ \
+ char *q; \
+ unsigned long long num; \
+ num = strtoull(p, &q, 16); \
+ if (num > ~((uint##x##_t)0x0) \
+ || q == p || (!isspace(*q) && *q != ':')) { \
+ *val_ptr = 0; \
+ return -1; \
+ } \
+ *val_ptr = cl_hton##x((uint##x##_t)num); \
+ return (int)(q - p); \
+}
+
+#define cl_hton8(x) (x)
+
+UNPACK_FUNC(net, 8);
+UNPACK_FUNC(net, 16);
+UNPACK_FUNC(net, 32);
+UNPACK_FUNC(net, 64);
+
+static int unpack_string(char *p, uint8_t * buf, unsigned len)
+{
+ char *q = p;
+ char delim = ' ';
+
+ if (*q == '\'' || *q == '\"')
+ delim = *q++;
+ while (--len && *q && *q != delim)
+ *buf++ = *q++;
+ *buf = '\0';
+ if (*q == delim && delim != ' ')
+ q++;
+ return (int)(q - p);
+}
+
+static int unpack_string64(char *p, uint8_t * buf)
+{
+ return unpack_string(p, buf, 64);
+}
+
+#define PARSE_AHEAD(p, x, name, val_ptr) { int _ret; \
+ p = strstr(p, name); \
+ if (!p) { \
+ OSM_LOG(&p_osm->log, OSM_LOG_ERROR, \
+ "PARSE ERROR: %s:%u: cannot find \"%s\" string\n", \
+ file_name, lineno, (name)); \
+ ret = -2; \
+ goto _error; \
+ } \
+ p += strlen(name); \
+ _ret = unpack_##x(p, (val_ptr)); \
+ if (_ret < 0) { \
+ OSM_LOG(&p_osm->log, OSM_LOG_ERROR, \
+ "PARSE ERROR: %s:%u: cannot parse "#x" value " \
+ "after \"%s\"\n", file_name, lineno, (name)); \
+ ret = _ret; \
+ goto _error; \
+ } \
+ p += _ret; \
+}
+
+static void sa_db_file_load_handle_mgrp(osm_opensm_t * p_osm,
+ osm_mgrp_t * p_mgrp)
+{
+ /* decide whether to delete the mgrp object or not */
+ if (p_mgrp->full_members == 0 && !p_mgrp->well_known) {
+ OSM_LOG(&p_osm->log, OSM_LOG_VERBOSE,
+ "Closing MC group 0x%016" PRIx64 ":0x%016" PRIx64
+ " - no full members were added to not well known "
+ "group\n",
+ cl_ntoh64(p_mgrp->mcmember_rec.mgid.unicast.prefix),
+ cl_ntoh64(p_mgrp->mcmember_rec.mgid.unicast.interface_id));
+ osm_mgrp_cleanup(&p_osm->subn, p_mgrp);
+ }
+}
+
+int osm_sa_db_file_load(osm_opensm_t * p_osm)
+{
+ char line[1024];
+ char *file_name;
+ FILE *file;
+ int ret = 0;
+ osm_mgrp_t *p_next_mgrp = NULL;
+ osm_mgrp_t *p_prev_mgrp = NULL;
+ unsigned rereg_clients = 0;
+ unsigned lineno;
+
+ if (!p_osm->subn.first_time_master_sweep) {
+ OSM_LOG(&p_osm->log, OSM_LOG_VERBOSE,
+ "Not first sweep - skip SA DB restore\n");
+ return 0;
+ }
+
+ file_name = p_osm->subn.opt.sa_db_file;
+ if (!file_name) {
+ OSM_LOG(&p_osm->log, OSM_LOG_VERBOSE,
+ "sa db file name is not specified. Skip restore\n");
+ return 0;
+ }
+
+ file = fopen(file_name, "r");
+ if (!file) {
+ OSM_LOG(&p_osm->log, OSM_LOG_ERROR | OSM_LOG_SYS, "ERR 4C02: "
+ "Can't open sa db file \'%s\'. Skip restoring\n",
+ file_name);
+ return -1;
+ }
+
+ OSM_LOG(&p_osm->log, OSM_LOG_VERBOSE,
+ "Restoring SA DB from file \'%s\'\n",
+ file_name);
+
+ lineno = 0;
+
+ while (fgets(line, sizeof(line) - 1, file) != NULL) {
+ char *p;
+ uint8_t val;
+
+ lineno++;
+
+ p = line;
+ while (isspace(*p))
+ p++;
+
+ if (*p == '#')
+ continue;
+
+ if (!strncmp(p, "MC Group", 8)) {
+ ib_member_rec_t mcm_rec;
+ ib_net16_t mlid;
+
+ p_next_mgrp = NULL;
+ memset(&mcm_rec, 0, sizeof(mcm_rec));
+
+ PARSE_AHEAD(p, net16, " 0x", &mlid);
+ PARSE_AHEAD(p, net64, " mgid=0x",
+ &mcm_rec.mgid.unicast.prefix);
+ PARSE_AHEAD(p, net64, ":0x",
+ &mcm_rec.mgid.unicast.interface_id);
+ PARSE_AHEAD(p, net64, " port_gid=0x",
+ &mcm_rec.port_gid.unicast.prefix);
+ PARSE_AHEAD(p, net64, ":0x",
+ &mcm_rec.port_gid.unicast.interface_id);
+ PARSE_AHEAD(p, net32, " qkey=0x", &mcm_rec.qkey);
+ PARSE_AHEAD(p, net16, " mlid=0x", &mcm_rec.mlid);
+ PARSE_AHEAD(p, net8, " mtu=0x", &mcm_rec.mtu);
+ PARSE_AHEAD(p, net8, " tclass=0x", &mcm_rec.tclass);
+ PARSE_AHEAD(p, net16, " pkey=0x", &mcm_rec.pkey);
+ PARSE_AHEAD(p, net8, " rate=0x", &mcm_rec.rate);
+ PARSE_AHEAD(p, net8, " pkt_life=0x", &mcm_rec.pkt_life);
+ PARSE_AHEAD(p, net32, " sl_flow_hop=0x",
+ &mcm_rec.sl_flow_hop);
+ PARSE_AHEAD(p, net8, " scope_state=0x",
+ &mcm_rec.scope_state);
+ PARSE_AHEAD(p, net8, " proxy_join=0x", &val);
+ mcm_rec.proxy_join = val;
+
+ p_next_mgrp = load_mcgroup(p_osm, mlid, &mcm_rec);
+ if (!p_next_mgrp)
+ rereg_clients = 1;
+ if (cl_ntoh16(mlid) > p_osm->sm.mlids_init_max)
+ p_osm->sm.mlids_init_max = cl_ntoh16(mlid);
+ } else if (p_next_mgrp && !strncmp(p, "mcm_port", 8)) {
+ ib_member_rec_t mcmr;
+ ib_net64_t guid;
+ osm_port_t *port;
+ boolean_t proxy;
+
+ PARSE_AHEAD(p, net64, " port_gid=0x",
+ &mcmr.port_gid.unicast.prefix);
+ PARSE_AHEAD(p, net64, ":0x",
+ &mcmr.port_gid.unicast.interface_id);
+ PARSE_AHEAD(p, net8, " scope_state=0x", &mcmr.scope_state);
+ PARSE_AHEAD(p, net8, " proxy_join=0x", &val);
+ proxy = val;
+
+ guid = mcmr.port_gid.unicast.interface_id;
+ port = osm_get_port_by_alias_guid(&p_osm->subn, guid);
+ if (port &&
+ cl_qmap_get(&p_next_mgrp->mcm_port_tbl, guid) ==
+ cl_qmap_end(&p_next_mgrp->mcm_port_tbl) &&
+ !osm_mgrp_add_port(&p_osm->subn, &p_osm->log,
+ p_next_mgrp, port, &mcmr, proxy))
+ rereg_clients = 1;
+ } else if (!strncmp(p, "Service Record:", 15)) {
+ ib_service_record_t s_rec;
+ uint32_t modified_time, lease_period;
+
+ p_next_mgrp = NULL;
+ memset(&s_rec, 0, sizeof(s_rec));
+
+ PARSE_AHEAD(p, net64, " id=0x", &s_rec.service_id);
+ PARSE_AHEAD(p, net64, " gid=0x",
+ &s_rec.service_gid.unicast.prefix);
+ PARSE_AHEAD(p, net64, ":0x",
+ &s_rec.service_gid.unicast.interface_id);
+ PARSE_AHEAD(p, net16, " pkey=0x", &s_rec.service_pkey);
+ PARSE_AHEAD(p, net32, " lease=0x",
+ &s_rec.service_lease);
+ PARSE_AHEAD(p, net64, " key=0x",
+ (ib_net64_t *) (&s_rec.service_key[0]));
+ PARSE_AHEAD(p, net64, ":0x",
+ (ib_net64_t *) (&s_rec.service_key[8]));
+ PARSE_AHEAD(p, string64, " name=", s_rec.service_name);
+ PARSE_AHEAD(p, net64, " data8=0x",
+ (ib_net64_t *) (&s_rec.service_data8[0]));
+ PARSE_AHEAD(p, net64, ":0x",
+ (ib_net64_t *) (&s_rec.service_data8[8]));
+ PARSE_AHEAD(p, net64, " data16=0x",
+ (ib_net64_t *) (&s_rec.service_data16[0]));
+ PARSE_AHEAD(p, net64, ":0x",
+ (ib_net64_t *) (&s_rec.service_data16[4]));
+ PARSE_AHEAD(p, net64, " data32=0x",
+ (ib_net64_t *) (&s_rec.service_data32[0]));
+ PARSE_AHEAD(p, net64, ":0x",
+ (ib_net64_t *) (&s_rec.service_data32[2]));
+ PARSE_AHEAD(p, net64, " data64=0x",
+ &s_rec.service_data64[0]);
+ PARSE_AHEAD(p, net64, ":0x", &s_rec.service_data64[1]);
+ PARSE_AHEAD(p, net32, " modified_time=0x",
+ &modified_time);
+ PARSE_AHEAD(p, net32, " lease_period=0x",
+ &lease_period);
+
+ if (load_svcr(p_osm, &s_rec, cl_ntoh32(modified_time),
+ cl_ntoh32(lease_period)))
+ rereg_clients = 1;
+ } else if (!strncmp(p, "InformInfo Record:", 18)) {
+ ib_inform_info_record_t i_rec;
+ osm_mad_addr_t rep_addr;
+ ib_net16_t val16;
+
+ p_next_mgrp = NULL;
+ memset(&i_rec, 0, sizeof(i_rec));
+ memset(&rep_addr, 0, sizeof(rep_addr));
+
+ PARSE_AHEAD(p, net64, " subscriber_gid=0x",
+ &i_rec.subscriber_gid.unicast.prefix);
+ PARSE_AHEAD(p, net64, ":0x",
+ &i_rec.subscriber_gid.unicast.interface_id);
+ PARSE_AHEAD(p, net16, " subscriber_enum=0x",
+ &i_rec.subscriber_enum);
+ PARSE_AHEAD(p, net64, " gid=0x",
+ &i_rec.inform_info.gid.unicast.prefix);
+ PARSE_AHEAD(p, net64, ":0x",
+ &i_rec.inform_info.gid.unicast.
+ interface_id);
+ PARSE_AHEAD(p, net16, " lid_range_begin=0x",
+ &i_rec.inform_info.lid_range_begin);
+ PARSE_AHEAD(p, net16, " lid_range_end=0x",
+ &i_rec.inform_info.lid_range_end);
+ PARSE_AHEAD(p, net8, " is_generic=0x",
+ &i_rec.inform_info.is_generic);
+ PARSE_AHEAD(p, net8, " subscribe=0x",
+ &i_rec.inform_info.subscribe);
+ PARSE_AHEAD(p, net16, " trap_type=0x",
+ &i_rec.inform_info.trap_type);
+ PARSE_AHEAD(p, net16, " trap_num=0x",
+ &i_rec.inform_info.g_or_v.generic.trap_num);
+ PARSE_AHEAD(p, net32, " qpn_resp_time_val=0x",
+ &i_rec.inform_info.g_or_v.generic.
+ qpn_resp_time_val);
+ PARSE_AHEAD(p, net32, " node_type=0x",
+ (uint32_t *) & i_rec.inform_info.g_or_v.
+ generic.reserved2);
+
+ PARSE_AHEAD(p, net16, " rep_addr: lid=0x",
+ &rep_addr.dest_lid);
+ PARSE_AHEAD(p, net8, " path_bits=0x",
+ &rep_addr.path_bits);
+ PARSE_AHEAD(p, net8, " static_rate=0x",
+ &rep_addr.static_rate);
+ PARSE_AHEAD(p, net32, " remote_qp=0x",
+ &rep_addr.addr_type.gsi.remote_qp);
+ PARSE_AHEAD(p, net32, " remote_qkey=0x",
+ &rep_addr.addr_type.gsi.remote_qkey);
+ PARSE_AHEAD(p, net16, " pkey_ix=0x", &val16);
+ rep_addr.addr_type.gsi.pkey_ix = cl_ntoh16(val16);
+ PARSE_AHEAD(p, net8, " sl=0x",
+ &rep_addr.addr_type.gsi.service_level);
+
+ if (load_infr(p_osm, &i_rec, &rep_addr))
+ rereg_clients = 1;
+ } else if (!strncmp(p, "GUIDInfo Record:", 16)) {
+ ib_guidinfo_record_t gi_rec;
+ ib_net64_t base_guid;
+
+ p_next_mgrp = NULL;
+ memset(&gi_rec, 0, sizeof(gi_rec));
+
+ PARSE_AHEAD(p, net64, " base_guid=0x", &base_guid);
+ PARSE_AHEAD(p, net16, " lid=0x", &gi_rec.lid);
+ PARSE_AHEAD(p, net8, " block_num=0x",
+ &gi_rec.block_num);
+ PARSE_AHEAD(p, net64, " guid0=0x",
+ &gi_rec.guid_info.guid[0]);
+ PARSE_AHEAD(p, net64, " guid1=0x",
+ &gi_rec.guid_info.guid[1]);
+ PARSE_AHEAD(p, net64, " guid2=0x",
+ &gi_rec.guid_info.guid[2]);
+ PARSE_AHEAD(p, net64, " guid3=0x",
+ &gi_rec.guid_info.guid[3]);
+ PARSE_AHEAD(p, net64, " guid4=0x",
+ &gi_rec.guid_info.guid[4]);
+ PARSE_AHEAD(p, net64, " guid5=0x",
+ &gi_rec.guid_info.guid[5]);
+ PARSE_AHEAD(p, net64, " guid6=0x",
+ &gi_rec.guid_info.guid[6]);
+ PARSE_AHEAD(p, net64, " guid7=0x",
+ &gi_rec.guid_info.guid[7]);
+
+ if (load_guidinfo(p_osm, base_guid, &gi_rec))
+ rereg_clients = 1;
+ }
+
+ /*
+ * p_next_mgrp points to the multicast group now being parsed.
+ * p_prev_mgrp points to the last multicast group we parsed.
+ * We decide whether to keep or delete each multicast group
+ * only when we finish parsing it's member records. if the
+ * group has full members, or it is a "well known group" we
+ * keep it.
+ */
+ if (p_prev_mgrp != p_next_mgrp) {
+ if (p_prev_mgrp)
+ sa_db_file_load_handle_mgrp(p_osm, p_prev_mgrp);
+ p_prev_mgrp = p_next_mgrp;
+ }
+ }
+
+ if (p_next_mgrp)
+ sa_db_file_load_handle_mgrp(p_osm, p_prev_mgrp);
+
+ /*
+ * If loading succeeded, do whatever 'no_clients_rereg' says.
+ * If loading failed at some point, turn off the 'no_clients_rereg'
+ * option (turn on re-registration requests).
+ */
+ if (rereg_clients)
+ p_osm->subn.opt.no_clients_rereg = FALSE;
+
+ /* We've just finished loading SA DB file - clear the "dirty" flag */
+ p_osm->sa.dirty = FALSE;
+
+_error:
+ fclose(file);
+ return ret;
+}
diff --git a/contrib/ofed/opensm/opensm/osm_sa_class_port_info.c b/contrib/ofed/opensm/opensm/osm_sa_class_port_info.c
new file mode 100644
index 0000000..5c0db8e
--- /dev/null
+++ b/contrib/ofed/opensm/opensm/osm_sa_class_port_info.c
@@ -0,0 +1,220 @@
+/*
+ * Copyright (c) 2004-2008 Voltaire, Inc. All rights reserved.
+ * Copyright (c) 2002-2011 Mellanox Technologies LTD. All rights reserved.
+ * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
+ * Copyright (c) 2013 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+/*
+ * Abstract:
+ * Implementation of osm_cpi_rcv_t.
+ * This object represents the ClassPortInfo Receiver object.
+ * This object is part of the opensm family of objects.
+ */
+
+#if HAVE_CONFIG_H
+# include <config.h>
+#endif /* HAVE_CONFIG_H */
+
+#include <string.h>
+#include <iba/ib_types.h>
+#include <complib/cl_qmap.h>
+#include <complib/cl_passivelock.h>
+#include <complib/cl_debug.h>
+#include <complib/cl_qlist.h>
+#include <opensm/osm_file_ids.h>
+#define FILE_ID OSM_FILE_SA_CLASS_PORT_INFO_C
+#include <vendor/osm_vendor_api.h>
+#include <opensm/osm_helper.h>
+#include <opensm/osm_sa.h>
+
+#define MAX_MSECS_TO_RTV 24
+/* Precalculated table in msec (index is related to encoded value) */
+/* 4.096 usec * 2 ** n (where n = 8 - 31) */
+const static uint32_t msecs_to_rtv_table[MAX_MSECS_TO_RTV] = {
+ 1, 2, 4, 8,
+ 16, 33, 67, 134,
+ 268, 536, 1073, 2147,
+ 4294, 8589, 17179, 34359,
+ 68719, 137438, 274877, 549755,
+ 1099511, 2199023, 4398046, 8796093
+};
+
+static void cpi_rcv_respond(IN osm_sa_t * sa, IN const osm_madw_t * p_madw)
+{
+ osm_madw_t *p_resp_madw;
+ const ib_sa_mad_t *p_sa_mad;
+ ib_sa_mad_t *p_resp_sa_mad;
+ ib_class_port_info_t *p_resp_cpi;
+ ib_gid_t zero_gid;
+ uint32_t cap_mask2;
+ uint8_t rtv;
+
+ OSM_LOG_ENTER(sa->p_log);
+
+ memset(&zero_gid, 0, sizeof(ib_gid_t));
+
+ /*
+ Get a MAD to reply. Address of Mad is in the received mad_wrapper
+ */
+ p_resp_madw = osm_mad_pool_get(sa->p_mad_pool, p_madw->h_bind,
+ MAD_BLOCK_SIZE, &p_madw->mad_addr);
+ if (!p_resp_madw) {
+ OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 1408: "
+ "Unable to allocate MAD\n");
+ goto Exit;
+ }
+
+ p_sa_mad = osm_madw_get_sa_mad_ptr(p_madw);
+ p_resp_sa_mad = osm_madw_get_sa_mad_ptr(p_resp_madw);
+
+ memcpy(p_resp_sa_mad, p_sa_mad, IB_SA_MAD_HDR_SIZE);
+ p_resp_sa_mad->method |= IB_MAD_METHOD_RESP_MASK;
+ /* C15-0.1.5 - always return SM_Key = 0 (table 185 p 884) */
+ p_resp_sa_mad->sm_key = 0;
+
+ p_resp_cpi =
+ (ib_class_port_info_t *) ib_sa_mad_get_payload_ptr(p_resp_sa_mad);
+
+ /* finally do it (the job) man ! */
+ p_resp_cpi->base_ver = 1;
+ p_resp_cpi->class_ver = 2;
+ /* Calculate encoded response time value */
+ /* transaction timeout is in msec */
+ if (sa->p_subn->opt.transaction_timeout >
+ msecs_to_rtv_table[MAX_MSECS_TO_RTV - 1])
+ rtv = MAX_MSECS_TO_RTV - 1;
+ else {
+ for (rtv = 0; rtv < MAX_MSECS_TO_RTV; rtv++) {
+ if (sa->p_subn->opt.transaction_timeout <=
+ msecs_to_rtv_table[rtv])
+ break;
+ }
+ }
+ rtv += 8;
+ ib_class_set_resp_time_val(p_resp_cpi, rtv);
+ p_resp_cpi->redir_gid = zero_gid;
+ p_resp_cpi->redir_tc_sl_fl = 0;
+ p_resp_cpi->redir_lid = 0;
+ p_resp_cpi->redir_pkey = 0;
+ p_resp_cpi->redir_qp = CL_NTOH32(1);
+ p_resp_cpi->redir_qkey = IB_QP1_WELL_KNOWN_Q_KEY;
+ p_resp_cpi->trap_gid = zero_gid;
+ p_resp_cpi->trap_tc_sl_fl = 0;
+ p_resp_cpi->trap_lid = 0;
+ p_resp_cpi->trap_pkey = 0;
+ p_resp_cpi->trap_hop_qp = 0;
+ p_resp_cpi->trap_qkey = IB_QP1_WELL_KNOWN_Q_KEY;
+
+ /* set specific capability mask bits */
+ /* we do not support the following options/optional records:
+ OSM_CAP_IS_SUBN_OPT_RECS_SUP :
+ RandomForwardingTableRecord,
+ ServiceAssociationRecord
+ other optional records supported "under the table"
+
+ OSM_CAP_IS_MULTIPATH_SUP:
+ TraceRecord
+
+ OSM_CAP_IS_REINIT_SUP:
+ For reinitialization functionality.
+
+ So not sending traps, but supporting Get(Notice) and Set(Notice).
+ */
+
+ /* Note host notation replaced later */
+#if defined (VENDOR_RMPP_SUPPORT) && defined (DUAL_SIDED_RMPP)
+ p_resp_cpi->cap_mask = OSM_CAP_IS_SUBN_GET_SET_NOTICE_SUP |
+ OSM_CAP_IS_PORT_INFO_CAPMASK_MATCH_SUPPORTED |
+ OSM_CAP_IS_MULTIPATH_SUP;
+#else
+ p_resp_cpi->cap_mask = OSM_CAP_IS_SUBN_GET_SET_NOTICE_SUP |
+ OSM_CAP_IS_PORT_INFO_CAPMASK_MATCH_SUPPORTED;
+#endif
+ cap_mask2 = OSM_CAP2_IS_FULL_PORTINFO_REC_SUPPORTED |
+ OSM_CAP2_IS_EXTENDED_SPEEDS_SUPPORTED |
+ OSM_CAP2_IS_ALIAS_GUIDS_SUPPORTED |
+ OSM_CAP2_IS_MULTICAST_SERVICE_RECS_SUPPORTED |
+ OSM_CAP2_IS_PORT_INFO_CAPMASK2_MATCH_SUPPORTED |
+ OSM_CAP2_IS_LINK_WIDTH_2X_SUPPORTED;
+ if (sa->p_subn->opt.use_mfttop)
+ cap_mask2 |= OSM_CAP2_IS_MCAST_TOP_SUPPORTED;
+ if (sa->p_subn->opt.qos)
+ cap_mask2 |= OSM_CAP2_IS_QOS_SUPPORTED;
+ ib_class_set_cap_mask2(p_resp_cpi, cap_mask2);
+
+ if (!sa->p_subn->opt.disable_multicast)
+ p_resp_cpi->cap_mask |= OSM_CAP_IS_UD_MCAST_SUP;
+ p_resp_cpi->cap_mask = cl_hton16(p_resp_cpi->cap_mask);
+
+ if (OSM_LOG_IS_ACTIVE_V2(sa->p_log, OSM_LOG_FRAMES))
+ osm_dump_sa_mad_v2(sa->p_log, p_resp_sa_mad, FILE_ID, OSM_LOG_FRAMES);
+
+ osm_sa_send(sa, p_resp_madw, FALSE);
+
+Exit:
+ OSM_LOG_EXIT(sa->p_log);
+}
+
+/**********************************************************************
+ * This code actually handles the call
+ **********************************************************************/
+void osm_cpi_rcv_process(IN void *context, IN void *data)
+{
+ osm_sa_t *sa = context;
+ osm_madw_t *p_madw = data;
+ const ib_sa_mad_t *p_sa_mad;
+
+ OSM_LOG_ENTER(sa->p_log);
+
+ CL_ASSERT(p_madw);
+
+ p_sa_mad = osm_madw_get_sa_mad_ptr(p_madw);
+
+ /* we only support GET */
+ if (p_sa_mad->method != IB_MAD_METHOD_GET) {
+ OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 1403: "
+ "Unsupported Method (%s) for ClassPortInfo request\n",
+ ib_get_sa_method_str(p_sa_mad->method));
+ osm_sa_send_error(sa, p_madw, IB_SA_MAD_STATUS_REQ_INVALID);
+ goto Exit;
+ }
+
+ CL_ASSERT(p_sa_mad->attr_id == IB_MAD_ATTR_CLASS_PORT_INFO);
+
+ /* CLASS PORT INFO does not really look at the SMDB - no lock required. */
+
+ cpi_rcv_respond(sa, p_madw);
+
+Exit:
+ OSM_LOG_EXIT(sa->p_log);
+}
diff --git a/contrib/ofed/opensm/opensm/osm_sa_guidinfo_record.c b/contrib/ofed/opensm/opensm/osm_sa_guidinfo_record.c
new file mode 100644
index 0000000..e548924
--- /dev/null
+++ b/contrib/ofed/opensm/opensm/osm_sa_guidinfo_record.c
@@ -0,0 +1,844 @@
+/*
+ * Copyright (c) 2006-2009 Voltaire, Inc. All rights reserved.
+ * Copyright (c) 2002-2012 Mellanox Technologies LTD. All rights reserved.
+ * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
+ * Copyright (c) 2013 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+/*
+ * Abstract:
+ * Implementation of osm_gir_rcv_t.
+ * This object represents the GUIDInfoRecord Receiver object.
+ * This object is part of the opensm family of objects.
+ */
+
+#if HAVE_CONFIG_H
+# include <config.h>
+#endif /* HAVE_CONFIG_H */
+
+#include <string.h>
+#include <iba/ib_types.h>
+#include <complib/cl_qmap.h>
+#include <complib/cl_passivelock.h>
+#include <complib/cl_debug.h>
+#include <complib/cl_qlist.h>
+#include <opensm/osm_file_ids.h>
+#define FILE_ID OSM_FILE_SA_GUIDINFO_RECORD_C
+#include <vendor/osm_vendor_api.h>
+#include <opensm/osm_port.h>
+#include <opensm/osm_node.h>
+#include <opensm/osm_guid.h>
+#include <opensm/osm_helper.h>
+#include <opensm/osm_pkey.h>
+#include <opensm/osm_sa.h>
+
+#define SA_GIR_RESP_SIZE SA_ITEM_RESP_SIZE(guid_rec)
+
+#define MOD_GIR_COMP_MASK (IB_GIR_COMPMASK_LID | IB_GIR_COMPMASK_BLOCKNUM)
+
+typedef struct osm_gir_item {
+ cl_list_item_t list_item;
+ ib_guidinfo_record_t rec;
+} osm_gir_item_t;
+
+typedef struct osm_gir_search_ctxt {
+ const ib_guidinfo_record_t *p_rcvd_rec;
+ ib_net64_t comp_mask;
+ cl_qlist_t *p_list;
+ osm_sa_t *sa;
+ const osm_physp_t *p_req_physp;
+} osm_gir_search_ctxt_t;
+
+static ib_api_status_t gir_rcv_new_gir(IN osm_sa_t * sa,
+ IN const osm_node_t * p_node,
+ IN cl_qlist_t * p_list,
+ IN ib_net64_t const match_port_guid,
+ IN ib_net16_t const match_lid,
+ IN const osm_physp_t * p_physp,
+ IN uint8_t const block_num)
+{
+ osm_sa_item_t *p_rec_item;
+ ib_api_status_t status = IB_SUCCESS;
+
+ OSM_LOG_ENTER(sa->p_log);
+
+ p_rec_item = malloc(SA_GIR_RESP_SIZE);
+ if (p_rec_item == NULL) {
+ OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 5102: "
+ "rec_item alloc failed\n");
+ status = IB_INSUFFICIENT_RESOURCES;
+ goto Exit;
+ }
+
+ OSM_LOG(sa->p_log, OSM_LOG_DEBUG,
+ "New GUIDInfoRecord: lid %u, block num %d\n",
+ cl_ntoh16(match_lid), block_num);
+
+ memset(p_rec_item, 0, SA_GIR_RESP_SIZE);
+
+ p_rec_item->resp.guid_rec.lid = match_lid;
+ p_rec_item->resp.guid_rec.block_num = block_num;
+ if (p_physp->p_guids)
+ memcpy(&p_rec_item->resp.guid_rec.guid_info,
+ *p_physp->p_guids + block_num * GUID_TABLE_MAX_ENTRIES,
+ sizeof(ib_guid_info_t));
+ else if (!block_num)
+ p_rec_item->resp.guid_rec.guid_info.guid[0] = osm_physp_get_port_guid(p_physp);
+
+ cl_qlist_insert_tail(p_list, &p_rec_item->list_item);
+
+Exit:
+ OSM_LOG_EXIT(sa->p_log);
+ return status;
+}
+
+static void sa_gir_create_gir(IN osm_sa_t * sa, IN osm_node_t * p_node,
+ IN cl_qlist_t * p_list,
+ IN ib_net64_t const match_port_guid,
+ IN ib_net16_t const match_lid,
+ IN const osm_physp_t * p_req_physp,
+ IN uint8_t const match_block_num)
+{
+ const osm_physp_t *p_physp;
+ uint8_t port_num;
+ uint8_t num_ports;
+ uint16_t match_lid_ho;
+ ib_net16_t base_lid_ho;
+ ib_net16_t max_lid_ho;
+ uint8_t lmc;
+ ib_net64_t port_guid;
+ uint8_t block_num, start_block_num, end_block_num, num_blocks;
+
+ OSM_LOG_ENTER(sa->p_log);
+
+ OSM_LOG(sa->p_log, OSM_LOG_DEBUG,
+ "Looking for GUIDRecord with LID: %u GUID:0x%016"
+ PRIx64 "\n", cl_ntoh16(match_lid), cl_ntoh64(match_port_guid));
+
+ /*
+ For switches, do not return the GUIDInfo record(s)
+ for each port on the switch, just for port 0.
+ */
+ if (osm_node_get_type(p_node) == IB_NODE_TYPE_SWITCH)
+ num_ports = 1;
+ else
+ num_ports = osm_node_get_num_physp(p_node);
+
+ for (port_num = 0; port_num < num_ports; port_num++) {
+ p_physp = osm_node_get_physp_ptr(p_node, port_num);
+ if (!p_physp)
+ continue;
+
+ /* Check to see if the found p_physp and the requester physp
+ share a pkey. If not, continue */
+ if (!osm_physp_share_pkey(sa->p_log, p_physp, p_req_physp,
+ sa->p_subn->opt.allow_both_pkeys))
+ continue;
+
+ port_guid = osm_physp_get_port_guid(p_physp);
+
+ if (match_port_guid && (port_guid != match_port_guid))
+ continue;
+
+ /*
+ Note: the following check is a temporary workaround
+ Since 1. GUIDCap should never be 0 on ports where this applies
+ and 2. GUIDCap should not be used on ports where it doesn't apply
+ So this should really be a check for whether the port is a
+ switch external port or not!
+ */
+ if (p_physp->port_info.guid_cap == 0)
+ continue;
+
+ num_blocks = p_physp->port_info.guid_cap / 8;
+ if (p_physp->port_info.guid_cap % 8)
+ num_blocks++;
+ if (match_block_num == 255) {
+ start_block_num = 0;
+ end_block_num = num_blocks - 1;
+ } else {
+ if (match_block_num >= num_blocks)
+ continue;
+ end_block_num = start_block_num = match_block_num;
+ }
+
+ base_lid_ho = cl_ntoh16(osm_physp_get_base_lid(p_physp));
+ match_lid_ho = cl_ntoh16(match_lid);
+ if (match_lid_ho) {
+ lmc = osm_physp_get_lmc(p_physp);
+ max_lid_ho = (uint16_t) (base_lid_ho + (1 << lmc) - 1);
+
+ /*
+ We validate that the lid belongs to this node.
+ */
+ OSM_LOG(sa->p_log, OSM_LOG_DEBUG,
+ "Comparing LID: %u <= %u <= %u\n",
+ base_lid_ho, match_lid_ho, max_lid_ho);
+
+ if (match_lid_ho < base_lid_ho
+ || match_lid_ho > max_lid_ho)
+ continue;
+ }
+
+ for (block_num = start_block_num; block_num <= end_block_num;
+ block_num++)
+ gir_rcv_new_gir(sa, p_node, p_list, port_guid,
+ cl_ntoh16(base_lid_ho), p_physp,
+ block_num);
+ }
+
+ OSM_LOG_EXIT(sa->p_log);
+}
+
+static void sa_gir_by_comp_mask_cb(IN cl_map_item_t * p_map_item, IN void *cxt)
+{
+ const osm_gir_search_ctxt_t *p_ctxt = cxt;
+ osm_node_t *const p_node = (osm_node_t *) p_map_item;
+ const ib_guidinfo_record_t *const p_rcvd_rec = p_ctxt->p_rcvd_rec;
+ const osm_physp_t *const p_req_physp = p_ctxt->p_req_physp;
+ osm_sa_t *sa = p_ctxt->sa;
+ const ib_guid_info_t *p_comp_gi;
+ ib_net64_t const comp_mask = p_ctxt->comp_mask;
+ ib_net64_t match_port_guid = 0;
+ ib_net16_t match_lid = 0;
+ uint8_t match_block_num = 255;
+
+ OSM_LOG_ENTER(p_ctxt->sa->p_log);
+
+ if (comp_mask & IB_GIR_COMPMASK_LID)
+ match_lid = p_rcvd_rec->lid;
+
+ if (comp_mask & IB_GIR_COMPMASK_BLOCKNUM)
+ match_block_num = p_rcvd_rec->block_num;
+
+ p_comp_gi = &p_rcvd_rec->guid_info;
+ /* Different rule for block 0 v. other blocks */
+ if (comp_mask & IB_GIR_COMPMASK_GID0) {
+ if (!p_rcvd_rec->block_num)
+ match_port_guid = osm_physp_get_port_guid(p_req_physp);
+ if (p_comp_gi->guid[0] != match_port_guid)
+ goto Exit;
+ }
+
+ if (comp_mask & IB_GIR_COMPMASK_GID1) {
+ if (p_comp_gi->guid[1] != 0)
+ goto Exit;
+ }
+
+ if (comp_mask & IB_GIR_COMPMASK_GID2) {
+ if (p_comp_gi->guid[2] != 0)
+ goto Exit;
+ }
+
+ if (comp_mask & IB_GIR_COMPMASK_GID3) {
+ if (p_comp_gi->guid[3] != 0)
+ goto Exit;
+ }
+
+ if (comp_mask & IB_GIR_COMPMASK_GID4) {
+ if (p_comp_gi->guid[4] != 0)
+ goto Exit;
+ }
+
+ if (comp_mask & IB_GIR_COMPMASK_GID5) {
+ if (p_comp_gi->guid[5] != 0)
+ goto Exit;
+ }
+
+ if (comp_mask & IB_GIR_COMPMASK_GID6) {
+ if (p_comp_gi->guid[6] != 0)
+ goto Exit;
+ }
+
+ if (comp_mask & IB_GIR_COMPMASK_GID7) {
+ if (p_comp_gi->guid[7] != 0)
+ goto Exit;
+ }
+
+ sa_gir_create_gir(sa, p_node, p_ctxt->p_list, match_port_guid,
+ match_lid, p_req_physp, match_block_num);
+
+Exit:
+ OSM_LOG_EXIT(p_ctxt->sa->p_log);
+}
+
+static inline boolean_t check_mod_comp_mask(ib_net64_t comp_mask)
+{
+ return ((comp_mask & MOD_GIR_COMP_MASK) == MOD_GIR_COMP_MASK);
+}
+
+static uint8_t coalesce_comp_mask(IN osm_madw_t *p_madw)
+{
+ uint8_t comp_mask = 0;
+ ib_sa_mad_t *p_sa_mad;
+
+ p_sa_mad = osm_madw_get_sa_mad_ptr(p_madw);
+ if (p_sa_mad->comp_mask & IB_GIR_COMPMASK_GID0)
+ comp_mask |= 1<<0;
+ if (p_sa_mad->comp_mask & IB_GIR_COMPMASK_GID1)
+ comp_mask |= 1<<1;
+ if (p_sa_mad->comp_mask & IB_GIR_COMPMASK_GID2)
+ comp_mask |= 1<<2;
+ if (p_sa_mad->comp_mask & IB_GIR_COMPMASK_GID3)
+ comp_mask |= 1<<3;
+ if (p_sa_mad->comp_mask & IB_GIR_COMPMASK_GID4)
+ comp_mask |= 1<<4;
+ if (p_sa_mad->comp_mask & IB_GIR_COMPMASK_GID5)
+ comp_mask |= 1<<5;
+ if (p_sa_mad->comp_mask & IB_GIR_COMPMASK_GID6)
+ comp_mask |= 1<<6;
+ if (p_sa_mad->comp_mask & IB_GIR_COMPMASK_GID7)
+ comp_mask |= 1<<7;
+ return comp_mask;
+}
+
+static void guidinfo_respond(IN osm_sa_t *sa, IN osm_madw_t *p_madw,
+ IN ib_guidinfo_record_t * p_guidinfo_rec)
+{
+ cl_qlist_t rec_list;
+ osm_sa_item_t *item;
+
+ OSM_LOG_ENTER(sa->p_log);
+
+ item = malloc(SA_GIR_RESP_SIZE);
+ if (!item) {
+ OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 5101: "
+ "rec_item alloc failed\n");
+ goto Exit;
+ }
+
+ item->resp.guid_rec = *p_guidinfo_rec;
+
+ cl_qlist_init(&rec_list);
+ cl_qlist_insert_tail(&rec_list, &item->list_item);
+
+ osm_sa_respond(sa, p_madw, sizeof(ib_guidinfo_record_t), &rec_list);
+
+Exit:
+ OSM_LOG_EXIT(sa->p_log);
+}
+
+static void gir_respond(IN osm_sa_t *sa, IN osm_madw_t *p_madw)
+{
+ ib_sa_mad_t *p_sa_mad;
+ ib_guidinfo_record_t *p_rcvd_rec;
+ ib_guidinfo_record_t guidinfo_rec;
+
+ p_sa_mad = osm_madw_get_sa_mad_ptr(p_madw);
+ p_rcvd_rec = (ib_guidinfo_record_t *) ib_sa_mad_get_payload_ptr(p_sa_mad);
+ if (OSM_LOG_IS_ACTIVE_V2(sa->p_log, OSM_LOG_DEBUG))
+ osm_dump_guidinfo_record_v2(sa->p_log, p_rcvd_rec, FILE_ID, OSM_LOG_DEBUG);
+
+ guidinfo_rec = *p_rcvd_rec;
+ guidinfo_respond(sa, p_madw, &guidinfo_rec);
+}
+
+static ib_net64_t sm_assigned_guid(uint8_t assigned_byte)
+{
+ static uint32_t uniq_count;
+
+ if (++uniq_count == 0) {
+ uniq_count--;
+ return 0;
+ }
+ return cl_hton64(((uint64_t) uniq_count) |
+ (((uint64_t) assigned_byte) << 32) |
+ (((uint64_t) OSM_VENDOR_ID_OPENIB) << 40));
+}
+
+static void del_guidinfo(IN osm_sa_t *sa, IN osm_madw_t *p_madw,
+ IN osm_port_t *p_port, IN uint8_t block_num)
+{
+ int i;
+ uint32_t max_block;
+ ib_sa_mad_t *p_sa_mad;
+ ib_guidinfo_record_t *p_rcvd_rec;
+ ib_net64_t del_alias_guid;
+ osm_alias_guid_t *p_alias_guid;
+ cl_list_item_t *p_list_item;
+ osm_mcm_port_t *p_mcm_port;
+ osm_mcm_alias_guid_t *p_mcm_alias_guid;
+ uint8_t del_mask;
+ int dirty = 0;
+
+ if (!p_port->p_physp->p_guids)
+ goto Exit;
+
+ max_block = (p_port->p_physp->port_info.guid_cap + GUID_TABLE_MAX_ENTRIES - 1) /
+ GUID_TABLE_MAX_ENTRIES;
+
+ if (block_num >= max_block) {
+ OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 5116: "
+ "block_num %d is higher than Max GUID Cap block %d "
+ "for port GUID 0x%" PRIx64 "\n",
+ block_num, max_block, cl_ntoh64(p_port->p_physp->port_guid));
+ CL_PLOCK_RELEASE(sa->p_lock);
+ osm_sa_send_error(sa, p_madw,
+ IB_SA_MAD_STATUS_NO_RECORDS);
+ return;
+ }
+
+ p_sa_mad = osm_madw_get_sa_mad_ptr(p_madw);
+ p_rcvd_rec =
+ (ib_guidinfo_record_t *) ib_sa_mad_get_payload_ptr(p_sa_mad);
+
+ del_mask = coalesce_comp_mask(p_madw);
+
+ for (i = block_num * GUID_TABLE_MAX_ENTRIES;
+ (block_num + 1) * GUID_TABLE_MAX_ENTRIES < p_port->p_physp->port_info.guid_cap ? i < (block_num + 1) * GUID_TABLE_MAX_ENTRIES : i < p_port->p_physp->port_info.guid_cap;
+ i++) {
+ /* can't delete block 0 index 0 (base guid is RO) for alias guid table */
+ if (i == 0 && p_sa_mad->comp_mask & IB_GIR_COMPMASK_GID0) {
+ CL_PLOCK_RELEASE(sa->p_lock);
+ OSM_LOG(sa->p_log, OSM_LOG_DEBUG,
+ "Not allowed to delete RO GID 0\n");
+ osm_sa_send_error(sa, p_madw,
+ IB_SA_MAD_STATUS_REQ_INVALID);
+ return;
+ }
+ if (!(del_mask & 1<<(i % 8)))
+ continue;
+
+ del_alias_guid = (*p_port->p_physp->p_guids)[i];
+ if (del_alias_guid) {
+ /* Search all of port's multicast groups for alias */
+ p_list_item = cl_qlist_head(&p_port->mcm_list);
+ while (p_list_item != cl_qlist_end(&p_port->mcm_list)) {
+ p_mcm_port = cl_item_obj(p_list_item,
+ p_mcm_port, list_item);
+ p_list_item = cl_qlist_next(p_list_item);
+ p_mcm_alias_guid = osm_mgrp_get_mcm_alias_guid(p_mcm_port->mgrp, del_alias_guid);
+ if (p_mcm_alias_guid) {
+ CL_PLOCK_RELEASE(sa->p_lock);
+ osm_sa_send_error(sa, p_madw,
+ IB_SA_MAD_STATUS_DENIED);
+ return;
+ }
+ }
+ }
+ }
+
+ for (i = block_num * GUID_TABLE_MAX_ENTRIES;
+ (block_num + 1) * GUID_TABLE_MAX_ENTRIES < p_port->p_physp->port_info.guid_cap ? i < (block_num + 1) * GUID_TABLE_MAX_ENTRIES : i < p_port->p_physp->port_info.guid_cap;
+ i++) {
+ if (!(del_mask & 1<<(i % 8)))
+ continue;
+
+ del_alias_guid = (*p_port->p_physp->p_guids)[i];
+ if (del_alias_guid) {
+ /* remove original from alias guid table */
+ p_alias_guid = (osm_alias_guid_t *)
+ cl_qmap_remove(&sa->p_subn->alias_port_guid_tbl,
+ del_alias_guid);
+ if (p_alias_guid != (osm_alias_guid_t *)
+ cl_qmap_end(&sa->p_subn->alias_port_guid_tbl))
+ osm_alias_guid_delete(&p_alias_guid);
+ else
+ OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 510B: "
+ "Original alias GUID 0x%" PRIx64
+ " at index %u not found\n",
+ cl_ntoh64(del_alias_guid), i);
+ /* clear guid at index */
+ (*p_port->p_physp->p_guids)[i] = 0;
+ dirty = 1;
+ }
+ }
+
+ if (dirty) {
+ if (osm_queue_guidinfo(sa, p_port, block_num))
+ osm_sm_signal(sa->sm, OSM_SIGNAL_GUID_PROCESS_REQUEST);
+ sa->dirty = TRUE;
+ }
+
+ memcpy(&p_rcvd_rec->guid_info,
+ &((*p_port->p_physp->p_guids)[block_num * GUID_TABLE_MAX_ENTRIES]),
+ sizeof(ib_guid_info_t));
+
+Exit:
+ CL_PLOCK_RELEASE(sa->p_lock);
+ gir_respond(sa, p_madw);
+}
+
+static void set_guidinfo(IN osm_sa_t *sa, IN osm_madw_t *p_madw,
+ IN osm_port_t *p_port, IN uint8_t block_num)
+{
+ uint32_t max_block;
+ int i, j, dirty = 0;
+ ib_sa_mad_t *p_sa_mad;
+ ib_guidinfo_record_t *p_rcvd_rec;
+ osm_assigned_guids_t *p_assigned_guids = 0;
+ osm_alias_guid_t *p_alias_guid, *p_alias_guid_check;
+ cl_map_item_t *p_item;
+ ib_net64_t set_alias_guid, del_alias_guid, assigned_guid;
+ uint8_t set_mask;
+
+ max_block = (p_port->p_physp->port_info.guid_cap + GUID_TABLE_MAX_ENTRIES - 1) /
+ GUID_TABLE_MAX_ENTRIES;
+ if (block_num >= max_block) {
+ OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 5118: "
+ "block_num %d is higher than Max GUID Cap block %d "
+ "for port GUID 0x%" PRIx64 "\n",
+ block_num, max_block, cl_ntoh64(p_port->p_physp->port_guid));
+ CL_PLOCK_RELEASE(sa->p_lock);
+ osm_sa_send_error(sa, p_madw,
+ IB_SA_MAD_STATUS_NO_RECORDS);
+ return;
+ }
+ if (!p_port->p_physp->p_guids) {
+ p_port->p_physp->p_guids = calloc(max_block * GUID_TABLE_MAX_ENTRIES,
+ sizeof(ib_net64_t));
+ if (!p_port->p_physp->p_guids) {
+ OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 5103: "
+ "GUID table memory allocation failed for port "
+ "GUID 0x%" PRIx64 "\n",
+ cl_ntoh64(p_port->p_physp->port_guid));
+ CL_PLOCK_RELEASE(sa->p_lock);
+ osm_sa_send_error(sa, p_madw,
+ IB_SA_MAD_STATUS_NO_RESOURCES);
+ return;
+ }
+ /* setup base port guid in index 0 */
+ (*p_port->p_physp->p_guids)[0] = p_port->p_physp->port_guid;
+ }
+
+ p_sa_mad = osm_madw_get_sa_mad_ptr(p_madw);
+ p_rcvd_rec = (ib_guidinfo_record_t *) ib_sa_mad_get_payload_ptr(p_sa_mad);
+
+ if (OSM_LOG_IS_ACTIVE_V2(sa->p_log, OSM_LOG_DEBUG)) {
+ OSM_LOG(sa->p_log, OSM_LOG_DEBUG, "Dump of incoming record\n");
+ osm_dump_guidinfo_record_v2(sa->p_log, p_rcvd_rec, FILE_ID, OSM_LOG_DEBUG);
+ }
+
+ set_mask = coalesce_comp_mask(p_madw);
+
+ for (i = block_num * GUID_TABLE_MAX_ENTRIES;
+ (block_num + 1) * GUID_TABLE_MAX_ENTRIES < p_port->p_physp->port_info.guid_cap ? i < (block_num + 1) * GUID_TABLE_MAX_ENTRIES : i < p_port->p_physp->port_info.guid_cap;
+ i++) {
+ /* can't set block 0 index 0 (base guid is RO) for alias guid table */
+ if (i == 0 && p_sa_mad->comp_mask & IB_GIR_COMPMASK_GID0) {
+ CL_PLOCK_RELEASE(sa->p_lock);
+ OSM_LOG(sa->p_log, OSM_LOG_DEBUG,
+ "Not allowed to set RO GID 0\n");
+ osm_sa_send_error(sa, p_madw,
+ IB_SA_MAD_STATUS_REQ_INVALID);
+ return;
+ }
+
+ if (!(set_mask & 1<<(i % 8)))
+ continue;
+
+ set_alias_guid = p_rcvd_rec->guid_info.guid[i % 8];
+ if (!set_alias_guid) {
+ /* was a GUID previously assigned for this index ? */
+ set_alias_guid = (*p_port->p_physp->p_guids)[i];
+ if (set_alias_guid) {
+ p_rcvd_rec->guid_info.guid[i % 8] = set_alias_guid;
+ continue;
+ }
+ /* Is there a persistent SA assigned guid for this index ? */
+ if (!p_assigned_guids)
+ p_assigned_guids =
+ osm_get_assigned_guids_by_guid(sa->p_subn,
+ p_port->p_physp->port_guid);
+ if (p_assigned_guids) {
+ set_alias_guid = p_assigned_guids->assigned_guid[i];
+ if (set_alias_guid) {
+ p_rcvd_rec->guid_info.guid[i % 8] = set_alias_guid;
+ p_item = cl_qmap_get(&sa->sm->p_subn->alias_port_guid_tbl,
+ set_alias_guid);
+ if (p_item == cl_qmap_end(&sa->sm->p_subn->alias_port_guid_tbl))
+ goto add_alias_guid;
+ else {
+ p_alias_guid = (osm_alias_guid_t *) p_item;
+ if (p_alias_guid->p_base_port != p_port) {
+ OSM_LOG(sa->p_log,
+ OSM_LOG_ERROR,
+ "ERR 5110: "
+ " Assigned alias port GUID 0x%" PRIx64
+ " index %d base port GUID 0x%" PRIx64
+ " now attempted on port GUID 0x%" PRIx64
+ "\n",
+ cl_ntoh64(p_alias_guid->alias_guid), i,
+ cl_ntoh64(p_alias_guid->p_base_port->guid),
+ cl_ntoh64(p_port->guid));
+ /* clear response guid at index to indicate duplicate */
+ p_rcvd_rec->guid_info.guid[i % 8] = 0;
+ }
+ continue;
+ }
+ }
+ }
+ }
+ if (!set_alias_guid) {
+ for (j = 0; j < 1000; j++) {
+ assigned_guid = sm_assigned_guid(sa->p_subn->opt.sm_assigned_guid);
+ if (!assigned_guid) {
+ CL_PLOCK_RELEASE(sa->p_lock);
+ OSM_LOG(sa->p_log, OSM_LOG_ERROR,
+ "ERR 510E: No more assigned guids available\n");
+ osm_sa_send_error(sa, p_madw,
+ IB_SA_MAD_STATUS_NO_RESOURCES);
+ return;
+ }
+ p_item = cl_qmap_get(&sa->sm->p_subn->alias_port_guid_tbl,
+ assigned_guid);
+ if (p_item == cl_qmap_end(&sa->sm->p_subn->alias_port_guid_tbl)) {
+ set_alias_guid = assigned_guid;
+ p_rcvd_rec->guid_info.guid[i % 8] = assigned_guid;
+ if (!p_assigned_guids) {
+ p_assigned_guids = osm_assigned_guids_new(p_port->p_physp->port_guid,
+ max_block * GUID_TABLE_MAX_ENTRIES);
+ if (p_assigned_guids) {
+ cl_qmap_insert(&(sa->p_subn->assigned_guids_tbl),
+ p_assigned_guids->port_guid,
+ &p_assigned_guids->map_item);
+ } else {
+ OSM_LOG(sa->p_log,
+ OSM_LOG_ERROR,
+ "ERR 510D: osm_assigned_guids_new failed port GUID 0x%" PRIx64 " index %d\n",
+ cl_ntoh64(p_port->p_physp->port_guid), i);
+ CL_PLOCK_RELEASE(sa->p_lock);
+ osm_sa_send_error(sa, p_madw,
+ IB_SA_MAD_STATUS_NO_RESOURCES);
+ return;
+ }
+ }
+ if (p_assigned_guids)
+ p_assigned_guids->assigned_guid[i] = assigned_guid;
+ break;
+ }
+ }
+ if (!set_alias_guid) {
+ OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 510A: "
+ "SA assigned GUID %d failed for "
+ "port GUID 0x%" PRIx64 "\n", i,
+ cl_ntoh64(p_port->p_physp->port_guid));
+ continue;
+ }
+ }
+
+add_alias_guid:
+ /* allocate alias guid and add to alias guid table */
+ p_alias_guid = osm_alias_guid_new(set_alias_guid, p_port);
+ if (!p_alias_guid) {
+ OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 5107: "
+ "Alias guid %d memory allocation failed"
+ " for port GUID 0x%" PRIx64 "\n",
+ i, cl_ntoh64(p_port->p_physp->port_guid));
+ CL_PLOCK_RELEASE(sa->p_lock);
+ return;
+ }
+
+ p_alias_guid_check =
+ (osm_alias_guid_t *) cl_qmap_insert(&sa->sm->p_subn->alias_port_guid_tbl,
+ p_alias_guid->alias_guid,
+ &p_alias_guid->map_item);
+ if (p_alias_guid_check != p_alias_guid) {
+ /* alias GUID is a duplicate if it exists on another port or on the same port but at another index */
+ if (p_alias_guid_check->p_base_port != p_port ||
+ (*p_port->p_physp->p_guids)[i] != set_alias_guid) {
+ OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 5108: "
+ "Duplicate alias port GUID 0x%" PRIx64
+ " index %d base port GUID 0x%" PRIx64
+ ", alias GUID already assigned to "
+ "base port GUID 0x%" PRIx64 "\n",
+ cl_ntoh64(p_alias_guid->alias_guid), i,
+ cl_ntoh64(p_alias_guid->p_base_port->guid),
+ cl_ntoh64(p_alias_guid_check->p_base_port->guid));
+ /* clear response guid at index to indicate duplicate */
+ p_rcvd_rec->guid_info.guid[i % 8] = 0;
+ }
+ osm_alias_guid_delete(&p_alias_guid);
+ } else {
+ del_alias_guid = (*p_port->p_physp->p_guids)[i];
+ if (del_alias_guid) {
+ /* remove original from alias guid table */
+ p_alias_guid_check = (osm_alias_guid_t *)
+ cl_qmap_remove(&sa->p_subn->alias_port_guid_tbl,
+ del_alias_guid);
+ if (p_alias_guid_check)
+ osm_alias_guid_delete(&p_alias_guid_check);
+ else
+ OSM_LOG(sa->p_log, OSM_LOG_ERROR,
+ "ERR 510C: Original alias GUID "
+ "0x%" PRIx64 "at index %u "
+ "not found\n",
+ cl_ntoh64(del_alias_guid),
+ i);
+ }
+
+ /* insert or replace guid at index */
+ (*p_port->p_physp->p_guids)[i] = set_alias_guid;
+ dirty = 1;
+ }
+ }
+
+ if (dirty) {
+ if (osm_queue_guidinfo(sa, p_port, block_num))
+ osm_sm_signal(sa->sm, OSM_SIGNAL_GUID_PROCESS_REQUEST);
+ sa->dirty = TRUE;
+ }
+
+ memcpy(&p_rcvd_rec->guid_info,
+ &((*p_port->p_physp->p_guids)[block_num * GUID_TABLE_MAX_ENTRIES]),
+ sizeof(ib_guid_info_t));
+
+ CL_PLOCK_RELEASE(sa->p_lock);
+ gir_respond(sa, p_madw);
+}
+
+static void get_guidinfo(IN osm_sa_t *sa, IN osm_madw_t *p_madw,
+ IN osm_physp_t *p_req_physp)
+{
+ const ib_sa_mad_t *p_rcvd_mad;
+ const ib_guidinfo_record_t *p_rcvd_rec;
+ cl_qlist_t rec_list;
+ osm_gir_search_ctxt_t context;
+
+ p_rcvd_mad = osm_madw_get_sa_mad_ptr(p_madw);
+ p_rcvd_rec =
+ (ib_guidinfo_record_t *) ib_sa_mad_get_payload_ptr(p_rcvd_mad);
+
+ cl_qlist_init(&rec_list);
+
+ context.p_rcvd_rec = p_rcvd_rec;
+ context.p_list = &rec_list;
+ context.comp_mask = p_rcvd_mad->comp_mask;
+ context.sa = sa;
+ context.p_req_physp = p_req_physp;
+
+
+ cl_qmap_apply_func(&sa->p_subn->node_guid_tbl, sa_gir_by_comp_mask_cb,
+ &context);
+
+ CL_PLOCK_RELEASE(sa->p_lock);
+
+ osm_sa_respond(sa, p_madw, sizeof(ib_guidinfo_record_t), &rec_list);
+}
+
+void osm_gir_rcv_process(IN void *ctx, IN void *data)
+{
+ osm_sa_t *sa = ctx;
+ osm_madw_t *p_madw = data;
+ const ib_sa_mad_t *p_rcvd_mad;
+ osm_physp_t *p_req_physp;
+ osm_port_t *p_port;
+ const ib_guidinfo_record_t *p_rcvd_rec;
+
+ CL_ASSERT(sa);
+
+ OSM_LOG_ENTER(sa->p_log);
+
+ CL_ASSERT(p_madw);
+
+ p_rcvd_mad = osm_madw_get_sa_mad_ptr(p_madw);
+
+ CL_ASSERT(p_rcvd_mad->attr_id == IB_MAD_ATTR_GUIDINFO_RECORD);
+
+ switch(p_rcvd_mad->method) {
+ case IB_MAD_METHOD_GET:
+ case IB_MAD_METHOD_GETTABLE:
+ /* update the requester physical port */
+ CL_PLOCK_ACQUIRE(sa->p_lock);
+ p_req_physp = osm_get_physp_by_mad_addr(sa->p_log, sa->p_subn,
+ osm_madw_get_mad_addr_ptr(p_madw));
+ if (p_req_physp == NULL) {
+ CL_PLOCK_RELEASE(sa->p_lock);
+ OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 5104: "
+ "Cannot find requester physical port\n");
+ goto Exit;
+ }
+ OSM_LOG(sa->p_log, OSM_LOG_DEBUG,
+ "Requester port GUID 0x%" PRIx64 "\n",
+ cl_ntoh64(osm_physp_get_port_guid(p_req_physp)));
+
+ get_guidinfo(sa, p_madw, p_req_physp);
+ goto Exit;
+ case IB_MAD_METHOD_SET:
+ case IB_MAD_METHOD_DELETE:
+ if (!check_mod_comp_mask(p_rcvd_mad->comp_mask)) {
+ OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 5106: "
+ "component mask = 0x%016" PRIx64 ", "
+ "expected comp mask = 0x%016" PRIx64 "\n",
+ cl_ntoh64(p_rcvd_mad->comp_mask),
+ CL_NTOH64(MOD_GIR_COMP_MASK));
+ osm_sa_send_error(sa, p_madw,
+ IB_SA_MAD_STATUS_INSUF_COMPS);
+ goto Exit;
+ }
+ p_rcvd_rec = (ib_guidinfo_record_t *) ib_sa_mad_get_payload_ptr(p_rcvd_mad);
+
+ /* update the requester physical port */
+ CL_PLOCK_EXCL_ACQUIRE(sa->p_lock);
+ p_req_physp = osm_get_physp_by_mad_addr(sa->p_log, sa->p_subn,
+ osm_madw_get_mad_addr_ptr(p_madw));
+ if (p_req_physp == NULL) {
+ CL_PLOCK_RELEASE(sa->p_lock);
+ OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 5104: "
+ "Cannot find requester physical port\n");
+ goto Exit;
+ }
+ OSM_LOG(sa->p_log, OSM_LOG_DEBUG,
+ "Requester port GUID 0x%" PRIx64 "\n",
+ cl_ntoh64(osm_physp_get_port_guid(p_req_physp)));
+
+ p_port = osm_get_port_by_lid(sa->p_subn, p_rcvd_rec->lid);
+ if (!p_port) {
+ CL_PLOCK_RELEASE(sa->p_lock);
+ OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 5117: "
+ "Port with LID %u not found\n",
+ cl_ntoh16(p_rcvd_rec->lid));
+ osm_sa_send_error(sa, p_madw, IB_SA_MAD_STATUS_NO_RECORDS);
+ goto Exit;
+ }
+ if (!osm_physp_share_pkey(sa->p_log, p_req_physp, p_port->p_physp,
+ sa->p_subn->opt.allow_both_pkeys)) {
+ CL_PLOCK_RELEASE(sa->p_lock);
+ goto Exit;
+ }
+
+ if (p_rcvd_mad->method == IB_MAD_METHOD_SET)
+ set_guidinfo(sa, p_madw, p_port, p_rcvd_rec->block_num);
+ else
+ del_guidinfo(sa, p_madw, p_port, p_rcvd_rec->block_num);
+ break;
+ default:
+ OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 5105: "
+ "Unsupported Method (%s) for GUIDInfoRecord request\n",
+ ib_get_sa_method_str(p_rcvd_mad->method));
+ osm_sa_send_error(sa, p_madw, IB_MAD_STATUS_UNSUP_METHOD_ATTR);
+ break;
+ }
+
+Exit:
+ OSM_LOG_EXIT(sa->p_log);
+}
diff --git a/contrib/ofed/opensm/opensm/osm_sa_informinfo.c b/contrib/ofed/opensm/opensm/osm_sa_informinfo.c
new file mode 100644
index 0000000..da97486
--- /dev/null
+++ b/contrib/ofed/opensm/opensm/osm_sa_informinfo.c
@@ -0,0 +1,643 @@
+/*
+ * Copyright (c) 2004-2009 Voltaire, Inc. All rights reserved.
+ * Copyright (c) 2002-2006 Mellanox Technologies LTD. All rights reserved.
+ * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
+ * Copyright (c) 2009 HNR Consulting. All rights reserved.
+ * Copyright (c) 2013 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+/*
+ * Abstract:
+ * Implementation of osm_infr_rcv_t.
+ * This object represents the InformInfo Receiver object.
+ * This object is part of the opensm family of objects.
+ */
+
+#if HAVE_CONFIG_H
+# include <config.h>
+#endif /* HAVE_CONFIG_H */
+
+#include <string.h>
+#include <iba/ib_types.h>
+#include <arpa/inet.h>
+#include <sys/socket.h>
+#include <complib/cl_qmap.h>
+#include <complib/cl_passivelock.h>
+#include <complib/cl_debug.h>
+#include <complib/cl_qlist.h>
+#include <opensm/osm_file_ids.h>
+#define FILE_ID OSM_FILE_SA_INFORMINFO_C
+#include <vendor/osm_vendor_api.h>
+#include <opensm/osm_port.h>
+#include <opensm/osm_node.h>
+#include <opensm/osm_switch.h>
+#include <opensm/osm_helper.h>
+#include <opensm/osm_sa.h>
+#include <opensm/osm_inform.h>
+#include <opensm/osm_pkey.h>
+
+#define SA_IIR_RESP_SIZE SA_ITEM_RESP_SIZE(inform_rec)
+#define SA_II_RESP_SIZE SA_ITEM_RESP_SIZE(inform)
+
+typedef struct osm_iir_search_ctxt {
+ const ib_inform_info_record_t *p_rcvd_rec;
+ ib_net64_t comp_mask;
+ cl_qlist_t *p_list;
+ ib_gid_t subscriber_gid;
+ ib_net16_t subscriber_enum;
+ osm_sa_t *sa;
+ osm_physp_t *p_req_physp;
+ ib_net64_t sm_key;
+} osm_iir_search_ctxt_t;
+
+/**********************************************************************
+o13-14.1.1: Except for Set(InformInfo) requests with Inform-
+Info:LIDRangeBegin=0xFFFF, managers that support event forwarding
+shall, upon receiving a Set(InformInfo), verify that the requester
+originating the Set(InformInfo) and a Trap() source identified by Inform-
+can access each other - can use path record to verify that.
+**********************************************************************/
+static boolean_t validate_ports_access_rights(IN osm_sa_t * sa,
+ IN osm_infr_t * p_infr_rec)
+{
+ boolean_t valid = TRUE;
+ osm_physp_t *p_requester_physp;
+ osm_port_t *p_port;
+ ib_net64_t portguid;
+ uint16_t lid_range_begin, lid_range_end, lid;
+
+ OSM_LOG_ENTER(sa->p_log);
+
+ /* get the requester physp from the request address */
+ p_requester_physp = osm_get_physp_by_mad_addr(sa->p_log, sa->p_subn,
+ &p_infr_rec->report_addr);
+
+ if (ib_gid_is_notzero(&p_infr_rec->inform_record.inform_info.gid)) {
+ /* a gid is defined */
+ portguid =
+ p_infr_rec->inform_record.inform_info.gid.unicast.
+ interface_id;
+
+ p_port = osm_get_port_by_guid(sa->p_subn, portguid);
+ if (p_port == NULL) {
+ OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 4301: "
+ "Invalid port guid: 0x%016" PRIx64 "\n",
+ cl_ntoh64(portguid));
+ valid = FALSE;
+ goto Exit;
+ }
+
+ /* make sure that the requester and destination port can access
+ each other according to the current partitioning. */
+ if (!osm_physp_share_pkey
+ (sa->p_log, p_port->p_physp, p_requester_physp,
+ sa->p_subn->opt.allow_both_pkeys)) {
+ OSM_LOG(sa->p_log, OSM_LOG_DEBUG,
+ "port and requester don't share pkey\n");
+ valid = FALSE;
+ goto Exit;
+ }
+ } else {
+ size_t lids_size;
+
+ /* gid is zero - check if LID range is defined */
+ lid_range_begin =
+ cl_ntoh16(p_infr_rec->inform_record.inform_info.
+ lid_range_begin);
+ /* if lid is 0xFFFF - meaning all endports managed by the manager */
+ if (lid_range_begin == 0xFFFF)
+ goto Exit;
+
+ lid_range_end =
+ cl_ntoh16(p_infr_rec->inform_record.inform_info.
+ lid_range_end);
+
+ lids_size = cl_ptr_vector_get_size(&sa->p_subn->port_lid_tbl);
+
+ /* lid_range_end is set to zero if no range desired. In this
+ case - just make it equal to the lid_range_begin. */
+ if (lid_range_end == 0)
+ lid_range_end = lid_range_begin;
+ else if (lid_range_end >= lids_size)
+ lid_range_end = lids_size - 1;
+
+ if (lid_range_begin >= lids_size) {
+ /* requested lids are out of range */
+ OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 4302: "
+ "Given LIDs (%u-%u) are out of range (%zu)\n",
+ lid_range_begin, lid_range_end, lids_size);
+ valid = FALSE;
+ goto Exit;
+ }
+
+ /* go over all defined lids within the range and make sure that the
+ requester port can access them according to current partitioning. */
+ for (lid = lid_range_begin; lid <= lid_range_end; lid++) {
+ p_port = osm_get_port_by_lid_ho(sa->p_subn, lid);
+ if (p_port == NULL)
+ continue;
+
+ /* make sure that the requester and destination port can access
+ each other according to the current partitioning. */
+ if (!osm_physp_share_pkey
+ (sa->p_log, p_port->p_physp, p_requester_physp,
+ sa->p_subn->opt.allow_both_pkeys)) {
+ OSM_LOG(sa->p_log, OSM_LOG_DEBUG,
+ "port and requester don't share pkey\n");
+ valid = FALSE;
+ goto Exit;
+ }
+ }
+ }
+
+Exit:
+ OSM_LOG_EXIT(sa->p_log);
+ return valid;
+}
+
+static boolean_t validate_infr(IN osm_sa_t * sa, IN osm_infr_t * p_infr_rec)
+{
+ boolean_t valid = TRUE;
+
+ OSM_LOG_ENTER(sa->p_log);
+
+ valid = validate_ports_access_rights(sa, p_infr_rec);
+ if (!valid) {
+ OSM_LOG(sa->p_log, OSM_LOG_DEBUG,
+ "Invalid Access for InformInfo\n");
+ valid = FALSE;
+ }
+
+ OSM_LOG_EXIT(sa->p_log);
+ return valid;
+}
+
+/**********************************************************************
+o13-12.1.1: Confirm a valid request for event subscription by responding
+with an InformInfo attribute that is a copy of the data in the
+Set(InformInfo) request.
+**********************************************************************/
+static void infr_rcv_respond(IN osm_sa_t * sa, IN osm_madw_t * p_madw)
+{
+ cl_qlist_t rec_list;
+ osm_sa_item_t *item;
+
+ OSM_LOG_ENTER(sa->p_log);
+
+ OSM_LOG(sa->p_log, OSM_LOG_DEBUG,
+ "Generating successful InformInfo response\n");
+
+ item = malloc(SA_II_RESP_SIZE);
+ if (!item) {
+ OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 4303: "
+ "rec_item alloc failed\n");
+ goto Exit;
+ }
+
+ memcpy(&item->resp.inform,
+ ib_sa_mad_get_payload_ptr(osm_madw_get_sa_mad_ptr(p_madw)),
+ sizeof(ib_inform_info_t));
+
+ cl_qlist_init(&rec_list);
+ cl_qlist_insert_tail(&rec_list, &item->list_item);
+
+ osm_sa_respond(sa, p_madw, sizeof(ib_inform_info_t), &rec_list);
+
+Exit:
+ OSM_LOG_EXIT(sa->p_log);
+}
+
+static void sa_inform_info_rec_by_comp_mask(IN osm_sa_t * sa,
+ IN const osm_infr_t * p_infr,
+ osm_iir_search_ctxt_t * p_ctxt)
+{
+ ib_net64_t comp_mask;
+ ib_net64_t portguid;
+ osm_port_t *p_subscriber_port;
+ osm_physp_t *p_subscriber_physp;
+ const osm_physp_t *p_req_physp;
+ osm_sa_item_t *p_rec_item;
+
+ OSM_LOG_ENTER(sa->p_log);
+
+ comp_mask = p_ctxt->comp_mask;
+ p_req_physp = p_ctxt->p_req_physp;
+
+ if (comp_mask & IB_IIR_COMPMASK_SUBSCRIBERGID &&
+ memcmp(&p_infr->inform_record.subscriber_gid,
+ &p_ctxt->subscriber_gid,
+ sizeof(p_infr->inform_record.subscriber_gid)))
+ goto Exit;
+
+ if (comp_mask & IB_IIR_COMPMASK_ENUM &&
+ p_infr->inform_record.subscriber_enum != p_ctxt->subscriber_enum)
+ goto Exit;
+
+ /* Implement any other needed search cases */
+
+ /* Ensure pkey is shared before returning any records */
+ portguid = p_infr->inform_record.subscriber_gid.unicast.interface_id;
+ p_subscriber_port = osm_get_port_by_guid(sa->p_subn, portguid);
+ if (p_subscriber_port == NULL) {
+ OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 430D: "
+ "Invalid subscriber port guid: 0x%016" PRIx64 "\n",
+ cl_ntoh64(portguid));
+ goto Exit;
+ }
+
+ /* get the subscriber InformInfo physical port */
+ p_subscriber_physp = p_subscriber_port->p_physp;
+ /* make sure that the requester and subscriber port can access each
+ other according to the current partitioning. */
+ if (!osm_physp_share_pkey(sa->p_log, p_req_physp, p_subscriber_physp,
+ sa->p_subn->opt.allow_both_pkeys)) {
+ OSM_LOG(sa->p_log, OSM_LOG_DEBUG,
+ "requester and subscriber ports don't share pkey\n");
+ goto Exit;
+ }
+
+ p_rec_item = malloc(SA_IIR_RESP_SIZE);
+ if (p_rec_item == NULL) {
+ OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 430E: "
+ "rec_item alloc failed\n");
+ goto Exit;
+ }
+
+ memcpy(&p_rec_item->resp.inform_rec, &p_infr->inform_record,
+ sizeof(ib_inform_info_record_t));
+
+ /*
+ * Per C15-0.2-1.16, InformInfoRecords shall always be
+ * provided with the QPN set to 0, except for the case
+ * of a trusted request, in which case the actual
+ * subscriber QPN shall be returned.
+ */
+ if (p_ctxt->sm_key == 0)
+ ib_inform_info_set_qpn(&p_rec_item->resp.inform_rec.inform_info, 0);
+
+ cl_qlist_insert_tail(p_ctxt->p_list, &p_rec_item->list_item);
+
+Exit:
+ OSM_LOG_EXIT(sa->p_log);
+}
+
+static void sa_inform_info_rec_by_comp_mask_cb(IN cl_list_item_t * p_list_item,
+ IN void *context)
+{
+ const osm_infr_t *p_infr = (osm_infr_t *) p_list_item;
+ osm_iir_search_ctxt_t *p_ctxt = context;
+
+ sa_inform_info_rec_by_comp_mask(p_ctxt->sa, p_infr, p_ctxt);
+}
+
+/**********************************************************************
+Received a Get(InformInfoRecord) or GetTable(InformInfoRecord) MAD
+**********************************************************************/
+static void infr_rcv_process_get_method(osm_sa_t * sa, IN osm_madw_t * p_madw)
+{
+ char gid_str[INET6_ADDRSTRLEN];
+ ib_sa_mad_t *p_rcvd_mad;
+ const ib_inform_info_record_t *p_rcvd_rec;
+ cl_qlist_t rec_list;
+ osm_iir_search_ctxt_t context;
+ osm_physp_t *p_req_physp;
+ osm_sa_item_t *item;
+
+ OSM_LOG_ENTER(sa->p_log);
+
+ CL_ASSERT(p_madw);
+ p_rcvd_mad = osm_madw_get_sa_mad_ptr(p_madw);
+ p_rcvd_rec =
+ (ib_inform_info_record_t *) ib_sa_mad_get_payload_ptr(p_rcvd_mad);
+
+ cl_plock_acquire(sa->p_lock);
+
+ /* update the requester physical port */
+ p_req_physp = osm_get_physp_by_mad_addr(sa->p_log, sa->p_subn,
+ osm_madw_get_mad_addr_ptr
+ (p_madw));
+ if (p_req_physp == NULL) {
+ cl_plock_release(sa->p_lock);
+ OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 4309: "
+ "Cannot find requester physical port\n");
+ goto Exit;
+ }
+
+ if (OSM_LOG_IS_ACTIVE_V2(sa->p_log, OSM_LOG_DEBUG)) {
+ OSM_LOG(sa->p_log, OSM_LOG_DEBUG,
+ "Requester port GUID 0x%" PRIx64 "\n",
+ cl_ntoh64(osm_physp_get_port_guid(p_req_physp)));
+ osm_dump_inform_info_record_v2(sa->p_log, p_rcvd_rec,
+ FILE_ID, OSM_LOG_DEBUG);
+ }
+
+ cl_qlist_init(&rec_list);
+
+ context.p_rcvd_rec = p_rcvd_rec;
+ context.p_list = &rec_list;
+ context.comp_mask = p_rcvd_mad->comp_mask;
+ context.subscriber_gid = p_rcvd_rec->subscriber_gid;
+ context.subscriber_enum = p_rcvd_rec->subscriber_enum;
+ context.sa = sa;
+ context.p_req_physp = p_req_physp;
+ context.sm_key = p_rcvd_mad->sm_key;
+
+ OSM_LOG(sa->p_log, OSM_LOG_DEBUG,
+ "Query Subscriber GID:%s(%02X) Enum:0x%X(%02X)\n",
+ inet_ntop(AF_INET6, p_rcvd_rec->subscriber_gid.raw,
+ gid_str, sizeof gid_str),
+ (p_rcvd_mad->comp_mask & IB_IIR_COMPMASK_SUBSCRIBERGID) != 0,
+ cl_ntoh16(p_rcvd_rec->subscriber_enum),
+ (p_rcvd_mad->comp_mask & IB_IIR_COMPMASK_ENUM) != 0);
+
+ cl_qlist_apply_func(&sa->p_subn->sa_infr_list,
+ sa_inform_info_rec_by_comp_mask_cb, &context);
+
+ /* clear reserved and pad fields in InformInfoRecord */
+ for (item = (osm_sa_item_t *) cl_qlist_head(&rec_list);
+ item != (osm_sa_item_t *) cl_qlist_end(&rec_list);
+ item = (osm_sa_item_t *) cl_qlist_next(&item->list_item)) {
+ memset(item->resp.inform_rec.reserved, 0, sizeof(item->resp.inform_rec.reserved));
+ memset(item->resp.inform_rec.pad, 0, sizeof(item->resp.inform_rec.pad));
+ }
+
+ cl_plock_release(sa->p_lock);
+
+ osm_sa_respond(sa, p_madw, sizeof(ib_inform_info_record_t), &rec_list);
+
+Exit:
+ OSM_LOG_EXIT(sa->p_log);
+}
+
+/*********************************************************************
+Received a Set(InformInfo) MAD
+**********************************************************************/
+static void infr_rcv_process_set_method(osm_sa_t * sa, IN osm_madw_t * p_madw)
+{
+ ib_sa_mad_t *p_sa_mad;
+ ib_inform_info_t *p_recvd_inform_info;
+ osm_infr_t inform_info_rec; /* actual inform record to be stored for reports */
+ osm_infr_t *p_infr;
+ ib_net32_t qpn;
+ uint8_t resp_time_val;
+ ib_api_status_t res;
+
+ OSM_LOG_ENTER(sa->p_log);
+
+ CL_ASSERT(p_madw);
+
+ p_sa_mad = osm_madw_get_sa_mad_ptr(p_madw);
+ p_recvd_inform_info =
+ (ib_inform_info_t *) ib_sa_mad_get_payload_ptr(p_sa_mad);
+
+#if 0
+ if (OSM_LOG_IS_ACTIVE_V2(sa->p_log, OSM_LOG_DEBUG))
+ osm_dump_inform_info_v2(sa->p_log, p_recvd_inform_info,
+ FILE_ID, OSM_LOG_DEBUG);
+#endif
+
+ /* Grab the lock */
+ cl_plock_excl_acquire(sa->p_lock);
+
+ /* define the inform record */
+ inform_info_rec.inform_record.inform_info = *p_recvd_inform_info;
+
+ /* following C13-32.1.2 Tbl 120: we only copy the source address vector */
+ inform_info_rec.report_addr = p_madw->mad_addr;
+
+ /* we will need to know the mad srvc to send back through */
+ inform_info_rec.h_bind = p_madw->h_bind;
+ inform_info_rec.sa = sa;
+
+ /* update the subscriber GID according to mad address */
+ res = osm_get_gid_by_mad_addr(sa->p_log, sa->p_subn, &p_madw->mad_addr,
+ &inform_info_rec.inform_record.
+ subscriber_gid);
+ if (res != IB_SUCCESS) {
+ cl_plock_release(sa->p_lock);
+
+ OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 4308: "
+ "Subscribe Request from unknown LID: %u\n",
+ cl_ntoh16(p_madw->mad_addr.dest_lid));
+ osm_sa_send_error(sa, p_madw, IB_SA_MAD_STATUS_REQ_INVALID);
+ goto Exit;
+ }
+
+ /* HACK: enum is always 0 (currently) */
+ inform_info_rec.inform_record.subscriber_enum = 0;
+
+ /* Subscribe values above 1 are undefined */
+ if (p_recvd_inform_info->subscribe > 1) {
+ cl_plock_release(sa->p_lock);
+
+ OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 430A: "
+ "Invalid subscribe: %d\n",
+ p_recvd_inform_info->subscribe);
+ osm_sa_send_error(sa, p_madw, IB_SA_MAD_STATUS_REQ_INVALID);
+ goto Exit;
+ }
+
+ /*
+ * Per C15-0.2-1.16, SubnAdmSet(InformInfo) subscriptions for
+ * SM security traps shall be provided only if they come from a
+ * trusted source.
+ */
+ if ((p_sa_mad->sm_key == 0) && p_recvd_inform_info->is_generic &&
+ ((cl_ntoh16(p_recvd_inform_info->g_or_v.generic.trap_num) >= SM_BAD_MKEY_TRAP) &&
+ (cl_ntoh16(p_recvd_inform_info->g_or_v.generic.trap_num) <= SM_BAD_SWITCH_PKEY_TRAP))) {
+ cl_plock_release(sa->p_lock);
+
+ OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 430B "
+ "Request for security trap from non-trusted requester: "
+ "Given SM_Key:0x%016" PRIx64 "\n",
+ cl_ntoh64(p_sa_mad->sm_key));
+ osm_sa_send_error(sa, p_madw, IB_SA_MAD_STATUS_REQ_INVALID);
+ goto Exit;
+ }
+
+ /*
+ * MODIFICATIONS DONE ON INCOMING REQUEST:
+ *
+ * QPN:
+ * Internally we keep the QPN field of the InformInfo updated
+ * so we can simply compare it in the record - when finding such.
+ */
+ if (p_recvd_inform_info->subscribe) {
+ ib_inform_info_set_qpn(&inform_info_rec.inform_record.
+ inform_info,
+ inform_info_rec.report_addr.addr_type.
+ gsi.remote_qp);
+
+ OSM_LOG(sa->p_log, OSM_LOG_DEBUG,
+ "Subscribe Request with QPN: 0x%06X\n",
+ cl_ntoh32(inform_info_rec.report_addr.addr_type.gsi.
+ remote_qp));
+ } else {
+ ib_inform_info_get_qpn_resp_time(p_recvd_inform_info->g_or_v.
+ generic.qpn_resp_time_val,
+ &qpn, &resp_time_val);
+
+ OSM_LOG(sa->p_log, OSM_LOG_DEBUG,
+ "UnSubscribe Request with QPN: 0x%06X\n",
+ cl_ntoh32(qpn));
+ }
+
+ /* If record exists with matching InformInfo */
+ p_infr = osm_infr_get_by_rec(sa->p_subn, sa->p_log, &inform_info_rec);
+
+ /* check to see if the request was for subscribe */
+ if (p_recvd_inform_info->subscribe) {
+ /* validate the request for a new or update InformInfo */
+ if (validate_infr(sa, &inform_info_rec) != TRUE) {
+ cl_plock_release(sa->p_lock);
+
+ OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 4305: "
+ "Failed to validate a new inform object\n");
+
+ /* o13-13.1.1: we need to set the subscribe bit to 0 */
+ p_recvd_inform_info->subscribe = 0;
+ osm_sa_send_error(sa, p_madw,
+ IB_SA_MAD_STATUS_REQ_INVALID);
+ goto Exit;
+ }
+
+ /* ok - we can try and create a new entry */
+ if (p_infr == NULL) {
+ /* Create the instance of the osm_infr_t object */
+ p_infr = osm_infr_new(&inform_info_rec);
+ if (p_infr == NULL) {
+ cl_plock_release(sa->p_lock);
+
+ OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 4306: "
+ "Failed to create a new inform object\n");
+
+ /* o13-13.1.1: we need to set the subscribe bit to 0 */
+ p_recvd_inform_info->subscribe = 0;
+ osm_sa_send_error(sa, p_madw,
+ IB_SA_MAD_STATUS_NO_RESOURCES);
+ goto Exit;
+ }
+
+ OSM_LOG(sa->p_log, OSM_LOG_VERBOSE,
+ "Adding event subscription for port 0x%" PRIx64 "\n",
+ cl_ntoh64(inform_info_rec.inform_record.subscriber_gid.unicast.interface_id));
+
+ /* Add this new osm_infr_t object to subnet object */
+ osm_infr_insert_to_db(sa->p_subn, sa->p_log, p_infr);
+ } else
+ /* Update the old instance of the osm_infr_t object */
+ p_infr->inform_record = inform_info_rec.inform_record;
+ /* We got an UnSubscribe request */
+ } else if (p_infr == NULL) {
+ cl_plock_release(sa->p_lock);
+
+ /* No Such Item - So Error */
+ OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 4307: "
+ "Failed to UnSubscribe to non existing inform object\n");
+
+ /* o13-13.1.1: we need to set the subscribe bit to 0 */
+ p_recvd_inform_info->subscribe = 0;
+ osm_sa_send_error(sa, p_madw, IB_SA_MAD_STATUS_REQ_INVALID);
+ goto Exit;
+ } else {
+ /* Delete this object from the subnet list of informs */
+ OSM_LOG(sa->p_log, OSM_LOG_VERBOSE,
+ "Removing event subscription for port 0x%" PRIx64 "\n",
+ cl_ntoh64(inform_info_rec.inform_record.subscriber_gid.unicast.interface_id));
+ osm_infr_remove_from_db(sa->p_subn, sa->p_log, p_infr);
+ }
+
+ cl_plock_release(sa->p_lock);
+
+ /* send the success response */
+ infr_rcv_respond(sa, p_madw);
+
+Exit:
+ OSM_LOG_EXIT(sa->p_log);
+}
+
+void osm_infr_rcv_process(IN void *context, IN void *data)
+{
+ osm_sa_t *sa = context;
+ osm_madw_t *p_madw = data;
+ ib_sa_mad_t *p_sa_mad;
+
+ OSM_LOG_ENTER(sa->p_log);
+
+ CL_ASSERT(p_madw);
+
+ p_sa_mad = osm_madw_get_sa_mad_ptr(p_madw);
+
+ CL_ASSERT(p_sa_mad->attr_id == IB_MAD_ATTR_INFORM_INFO);
+
+ if (p_sa_mad->method != IB_MAD_METHOD_SET) {
+ OSM_LOG(sa->p_log, OSM_LOG_DEBUG,
+ "Unsupported Method (%s) for InformInfo\n",
+ ib_get_sa_method_str(p_sa_mad->method));
+ osm_sa_send_error(sa, p_madw, IB_MAD_STATUS_UNSUP_METHOD_ATTR);
+ goto Exit;
+ }
+
+ infr_rcv_process_set_method(sa, p_madw);
+
+Exit:
+ OSM_LOG_EXIT(sa->p_log);
+}
+
+void osm_infir_rcv_process(IN void *context, IN void *data)
+{
+ osm_sa_t *sa = context;
+ osm_madw_t *p_madw = data;
+ ib_sa_mad_t *p_sa_mad;
+
+ OSM_LOG_ENTER(sa->p_log);
+
+ CL_ASSERT(p_madw);
+
+ p_sa_mad = osm_madw_get_sa_mad_ptr(p_madw);
+
+ CL_ASSERT(p_sa_mad->attr_id == IB_MAD_ATTR_INFORM_INFO_RECORD);
+
+ if (p_sa_mad->method != IB_MAD_METHOD_GET &&
+ p_sa_mad->method != IB_MAD_METHOD_GETTABLE) {
+ OSM_LOG(sa->p_log, OSM_LOG_DEBUG,
+ "Unsupported Method (%s) for InformInfoRecord\n",
+ ib_get_sa_method_str(p_sa_mad->method));
+ osm_sa_send_error(sa, p_madw, IB_MAD_STATUS_UNSUP_METHOD_ATTR);
+ goto Exit;
+ }
+
+ infr_rcv_process_get_method(sa, p_madw);
+
+Exit:
+ OSM_LOG_EXIT(sa->p_log);
+}
diff --git a/contrib/ofed/opensm/opensm/osm_sa_lft_record.c b/contrib/ofed/opensm/opensm/osm_sa_lft_record.c
new file mode 100644
index 0000000..8f4749e
--- /dev/null
+++ b/contrib/ofed/opensm/opensm/osm_sa_lft_record.c
@@ -0,0 +1,242 @@
+/*
+ * Copyright (c) 2004-2009 Voltaire, Inc. All rights reserved.
+ * Copyright (c) 2002-2005,2008 Mellanox Technologies LTD. All rights reserved.
+ * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
+ * Copyright (c) 2013 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+/*
+ * Abstract:
+ * Implementation of osm_lftr_rcv_t.
+ * This object represents the LinearForwardingTable Receiver object.
+ * This object is part of the opensm family of objects.
+ */
+
+#if HAVE_CONFIG_H
+# include <config.h>
+#endif /* HAVE_CONFIG_H */
+
+#include <string.h>
+#include <iba/ib_types.h>
+#include <complib/cl_debug.h>
+#include <complib/cl_qlist.h>
+#include <opensm/osm_file_ids.h>
+#define FILE_ID OSM_FILE_SA_LFT_RECORD_C
+#include <vendor/osm_vendor_api.h>
+#include <opensm/osm_switch.h>
+#include <opensm/osm_helper.h>
+#include <opensm/osm_pkey.h>
+#include <opensm/osm_sa.h>
+
+#define SA_LFTR_RESP_SIZE SA_ITEM_RESP_SIZE(lft_rec)
+
+typedef struct osm_lftr_search_ctxt {
+ const ib_lft_record_t *p_rcvd_rec;
+ ib_net64_t comp_mask;
+ cl_qlist_t *p_list;
+ osm_sa_t *sa;
+ const osm_physp_t *p_req_physp;
+} osm_lftr_search_ctxt_t;
+
+static ib_api_status_t lftr_rcv_new_lftr(IN osm_sa_t * sa,
+ IN const osm_switch_t * p_sw,
+ IN cl_qlist_t * p_list,
+ IN ib_net16_t lid, IN uint16_t block)
+{
+ osm_sa_item_t *p_rec_item;
+ ib_api_status_t status = IB_SUCCESS;
+
+ OSM_LOG_ENTER(sa->p_log);
+
+ p_rec_item = malloc(SA_LFTR_RESP_SIZE);
+ if (p_rec_item == NULL) {
+ OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 4402: "
+ "rec_item alloc failed\n");
+ status = IB_INSUFFICIENT_RESOURCES;
+ goto Exit;
+ }
+
+ OSM_LOG(sa->p_log, OSM_LOG_DEBUG,
+ "New LinearForwardingTable: sw 0x%016" PRIx64
+ "\n\t\t\t\tblock 0x%02X lid %u\n",
+ cl_ntoh64(osm_node_get_node_guid(p_sw->p_node)),
+ block, cl_ntoh16(lid));
+
+ memset(p_rec_item, 0, SA_LFTR_RESP_SIZE);
+
+ p_rec_item->resp.lft_rec.lid = lid;
+ p_rec_item->resp.lft_rec.block_num = cl_hton16(block);
+
+ /* copy the lft block */
+ osm_switch_get_lft_block(p_sw, block, p_rec_item->resp.lft_rec.lft);
+
+ cl_qlist_insert_tail(p_list, &p_rec_item->list_item);
+
+Exit:
+ OSM_LOG_EXIT(sa->p_log);
+ return status;
+}
+
+static void lftr_rcv_by_comp_mask(IN cl_map_item_t * p_map_item, IN void *cxt)
+{
+ const osm_lftr_search_ctxt_t *p_ctxt = cxt;
+ const osm_switch_t *p_sw = (osm_switch_t *) p_map_item;
+ const ib_lft_record_t *const p_rcvd_rec = p_ctxt->p_rcvd_rec;
+ osm_sa_t *sa = p_ctxt->sa;
+ ib_net64_t const comp_mask = p_ctxt->comp_mask;
+ const osm_physp_t *const p_req_physp = p_ctxt->p_req_physp;
+ osm_port_t *p_port;
+ uint16_t min_lid_ho, max_lid_ho;
+ uint16_t min_block, max_block, block;
+ const osm_physp_t *p_physp;
+
+ /* In switches, the port guid is the node guid. */
+ p_port = osm_get_port_by_guid(sa->p_subn,
+ p_sw->p_node->node_info.port_guid);
+ if (!p_port) {
+ OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 4405: "
+ "Failed to find Port by Node Guid:0x%016" PRIx64
+ "\n", cl_ntoh64(p_sw->p_node->node_info.node_guid));
+ return;
+ }
+
+ /* check that the requester physp and the current physp are under
+ the same partition. */
+ p_physp = p_port->p_physp;
+ if (!p_physp) {
+ OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 4406: "
+ "Failed to find default physical Port by Node Guid:0x%016"
+ PRIx64 "\n",
+ cl_ntoh64(p_sw->p_node->node_info.node_guid));
+ return;
+ }
+ if (!osm_physp_share_pkey(sa->p_log, p_req_physp,
+ p_physp, sa->p_subn->opt.allow_both_pkeys))
+ return;
+
+ /* get the port 0 of the switch */
+ osm_port_get_lid_range_ho(p_port, &min_lid_ho, &max_lid_ho);
+
+ /* compare the lids - if required */
+ if (comp_mask & IB_LFTR_COMPMASK_LID) {
+ OSM_LOG(sa->p_log, OSM_LOG_DEBUG,
+ "Comparing lid:%u to port lid range: %u .. %u\n",
+ cl_ntoh16(p_rcvd_rec->lid), min_lid_ho, max_lid_ho);
+ /* ok we are ready for range check */
+ if (min_lid_ho > cl_ntoh16(p_rcvd_rec->lid) ||
+ max_lid_ho < cl_ntoh16(p_rcvd_rec->lid))
+ return;
+ }
+
+ /* now we need to decide which blocks to output */
+ max_block = osm_switch_get_max_block_id_in_use(p_sw);
+ if (comp_mask & IB_LFTR_COMPMASK_BLOCK) {
+ min_block = cl_ntoh16(p_rcvd_rec->block_num);
+ if (min_block > max_block)
+ return;
+ max_block = min_block;
+ } else /* use as many blocks as "in use" */
+ min_block = 0;
+
+ /* so we can add these blocks one by one ... */
+ for (block = min_block; block <= max_block; block++)
+ lftr_rcv_new_lftr(sa, p_sw, p_ctxt->p_list,
+ osm_port_get_base_lid(p_port), block);
+}
+
+void osm_lftr_rcv_process(IN void *ctx, IN void *data)
+{
+ osm_sa_t *sa = ctx;
+ osm_madw_t *p_madw = data;
+ const ib_sa_mad_t *p_rcvd_mad;
+ const ib_lft_record_t *p_rcvd_rec;
+ cl_qlist_t rec_list;
+ osm_lftr_search_ctxt_t context;
+ osm_physp_t *p_req_physp;
+
+ CL_ASSERT(sa);
+
+ OSM_LOG_ENTER(sa->p_log);
+
+ CL_ASSERT(p_madw);
+
+ p_rcvd_mad = osm_madw_get_sa_mad_ptr(p_madw);
+ p_rcvd_rec = (ib_lft_record_t *) ib_sa_mad_get_payload_ptr(p_rcvd_mad);
+
+ CL_ASSERT(p_rcvd_mad->attr_id == IB_MAD_ATTR_LFT_RECORD);
+
+ /* we only support SubnAdmGet and SubnAdmGetTable methods */
+ if (p_rcvd_mad->method != IB_MAD_METHOD_GET &&
+ p_rcvd_mad->method != IB_MAD_METHOD_GETTABLE) {
+ OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 4408: "
+ "Unsupported Method (%s) for LFTRecord request\n",
+ ib_get_sa_method_str(p_rcvd_mad->method));
+ osm_sa_send_error(sa, p_madw, IB_MAD_STATUS_UNSUP_METHOD_ATTR);
+ goto Exit;
+ }
+
+ cl_plock_acquire(sa->p_lock);
+
+ /* update the requester physical port */
+ p_req_physp = osm_get_physp_by_mad_addr(sa->p_log, sa->p_subn,
+ osm_madw_get_mad_addr_ptr
+ (p_madw));
+ if (p_req_physp == NULL) {
+ cl_plock_release(sa->p_lock);
+ OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 4407: "
+ "Cannot find requester physical port\n");
+ goto Exit;
+ }
+
+ OSM_LOG(sa->p_log, OSM_LOG_DEBUG,
+ "Requester port GUID 0x%" PRIx64 "\n",
+ cl_ntoh64(osm_physp_get_port_guid(p_req_physp)));
+
+ cl_qlist_init(&rec_list);
+
+ context.p_rcvd_rec = p_rcvd_rec;
+ context.p_list = &rec_list;
+ context.comp_mask = p_rcvd_mad->comp_mask;
+ context.sa = sa;
+ context.p_req_physp = p_req_physp;
+
+ /* Go over all switches */
+ cl_qmap_apply_func(&sa->p_subn->sw_guid_tbl, lftr_rcv_by_comp_mask,
+ &context);
+
+ cl_plock_release(sa->p_lock);
+
+ osm_sa_respond(sa, p_madw, sizeof(ib_lft_record_t), &rec_list);
+
+Exit:
+ OSM_LOG_EXIT(sa->p_log);
+}
diff --git a/contrib/ofed/opensm/opensm/osm_sa_link_record.c b/contrib/ofed/opensm/opensm/osm_sa_link_record.c
new file mode 100644
index 0000000..5ab3d74
--- /dev/null
+++ b/contrib/ofed/opensm/opensm/osm_sa_link_record.c
@@ -0,0 +1,485 @@
+/*
+ * Copyright (c) 2004-2009 Voltaire, Inc. All rights reserved.
+ * Copyright (c) 2002-2007 Mellanox Technologies LTD. All rights reserved.
+ * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
+ * Copyright (c) 2013 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+/*
+ * Abstract:
+ * Implementation of osm_lr_rcv_t.
+ * This object represents the LinkRecord Receiver object.
+ * This object is part of the opensm family of objects.
+ */
+
+#if HAVE_CONFIG_H
+# include <config.h>
+#endif /* HAVE_CONFIG_H */
+
+#include <string.h>
+#include <iba/ib_types.h>
+#include <complib/cl_qmap.h>
+#include <complib/cl_debug.h>
+#include <opensm/osm_file_ids.h>
+#define FILE_ID OSM_FILE_SA_LINK_RECORD_C
+#include <vendor/osm_vendor_api.h>
+#include <opensm/osm_node.h>
+#include <opensm/osm_switch.h>
+#include <opensm/osm_helper.h>
+#include <opensm/osm_pkey.h>
+#include <opensm/osm_sa.h>
+
+#define SA_LR_RESP_SIZE SA_ITEM_RESP_SIZE(link_rec)
+
+static void lr_rcv_build_physp_link(IN osm_sa_t * sa, IN ib_net16_t from_lid,
+ IN ib_net16_t to_lid, IN uint8_t from_port,
+ IN uint8_t to_port, IN cl_qlist_t * p_list)
+{
+ osm_sa_item_t *p_lr_item;
+
+ p_lr_item = malloc(SA_LR_RESP_SIZE);
+ if (p_lr_item == NULL) {
+ OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 1801: "
+ "Unable to acquire link record\n"
+ "\t\t\t\tFrom port %u\n" "\t\t\t\tTo port %u\n"
+ "\t\t\t\tFrom lid %u\n" "\t\t\t\tTo lid %u\n",
+ from_port, to_port,
+ cl_ntoh16(from_lid), cl_ntoh16(to_lid));
+ return;
+ }
+ memset(p_lr_item, 0, SA_LR_RESP_SIZE);
+
+ p_lr_item->resp.link_rec.from_port_num = from_port;
+ p_lr_item->resp.link_rec.to_port_num = to_port;
+ p_lr_item->resp.link_rec.to_lid = to_lid;
+ p_lr_item->resp.link_rec.from_lid = from_lid;
+
+ cl_qlist_insert_tail(p_list, &p_lr_item->list_item);
+}
+
+static ib_net16_t get_base_lid(IN const osm_physp_t * p_physp)
+{
+ if (p_physp->p_node->node_info.node_type == IB_NODE_TYPE_SWITCH)
+ p_physp = osm_node_get_physp_ptr(p_physp->p_node, 0);
+ return osm_physp_get_base_lid(p_physp);
+}
+
+static void lr_rcv_get_physp_link(IN osm_sa_t * sa,
+ IN const ib_link_record_t * p_lr,
+ IN const osm_physp_t * p_src_physp,
+ IN const osm_physp_t * p_dest_physp,
+ IN const ib_net64_t comp_mask,
+ IN cl_qlist_t * p_list,
+ IN const osm_physp_t * p_req_physp)
+{
+ uint8_t src_port_num;
+ uint8_t dest_port_num;
+ ib_net16_t from_base_lid;
+ ib_net16_t to_base_lid;
+ ib_net16_t lmc_mask;
+
+ OSM_LOG_ENTER(sa->p_log);
+
+ /*
+ If only one end of the link is specified, determine
+ the other side.
+ */
+ if (p_src_physp) {
+ if (p_dest_physp) {
+ /*
+ Ensure the two physp's are actually connected.
+ If not, bail out.
+ */
+ if (osm_physp_get_remote(p_src_physp) != p_dest_physp)
+ goto Exit;
+ } else {
+ p_dest_physp = osm_physp_get_remote(p_src_physp);
+ if (p_dest_physp == NULL)
+ goto Exit;
+ }
+ } else {
+ if (p_dest_physp) {
+ p_src_physp = osm_physp_get_remote(p_dest_physp);
+ if (p_src_physp == NULL)
+ goto Exit;
+ } else
+ goto Exit; /* no physp's, so nothing to do */
+ }
+
+ /* Check that the p_src_physp, p_dest_physp and p_req_physp
+ all share a pkey (doesn't have to be the same p_key). */
+ if (!osm_physp_share_pkey(sa->p_log, p_src_physp, p_dest_physp,
+ sa->p_subn->opt.allow_both_pkeys)) {
+ OSM_LOG(sa->p_log, OSM_LOG_DEBUG,
+ "Source and Dest PhysPorts do not share PKey\n");
+ goto Exit;
+ }
+ if (!osm_physp_share_pkey(sa->p_log, p_src_physp, p_req_physp,
+ sa->p_subn->opt.allow_both_pkeys)) {
+ OSM_LOG(sa->p_log, OSM_LOG_DEBUG,
+ "Source and Requester PhysPorts do not share PKey\n");
+ goto Exit;
+ }
+ if (!osm_physp_share_pkey(sa->p_log, p_req_physp, p_dest_physp,
+ sa->p_subn->opt.allow_both_pkeys)) {
+ OSM_LOG(sa->p_log, OSM_LOG_DEBUG,
+ "Requester and Dest PhysPorts do not share PKey\n");
+ goto Exit;
+ }
+
+ src_port_num = osm_physp_get_port_num(p_src_physp);
+ dest_port_num = osm_physp_get_port_num(p_dest_physp);
+
+ if (comp_mask & IB_LR_COMPMASK_FROM_PORT)
+ if (src_port_num != p_lr->from_port_num)
+ goto Exit;
+
+ if (comp_mask & IB_LR_COMPMASK_TO_PORT)
+ if (dest_port_num != p_lr->to_port_num)
+ goto Exit;
+
+ from_base_lid = get_base_lid(p_src_physp);
+ to_base_lid = get_base_lid(p_dest_physp);
+
+ lmc_mask = ~((1 << sa->p_subn->opt.lmc) - 1);
+ lmc_mask = cl_hton16(lmc_mask);
+
+ if (comp_mask & IB_LR_COMPMASK_FROM_LID)
+ if (from_base_lid != (p_lr->from_lid & lmc_mask))
+ goto Exit;
+
+ if (comp_mask & IB_LR_COMPMASK_TO_LID)
+ if (to_base_lid != (p_lr->to_lid & lmc_mask))
+ goto Exit;
+
+ OSM_LOG(sa->p_log, OSM_LOG_DEBUG, "Acquiring link record\n"
+ "\t\t\t\tsrc port 0x%" PRIx64 " (port %u)"
+ ", dest port 0x%" PRIx64 " (port %u)\n",
+ cl_ntoh64(osm_physp_get_port_guid(p_src_physp)), src_port_num,
+ cl_ntoh64(osm_physp_get_port_guid(p_dest_physp)),
+ dest_port_num);
+
+ lr_rcv_build_physp_link(sa, from_base_lid, to_base_lid, src_port_num,
+ dest_port_num, p_list);
+
+Exit:
+ OSM_LOG_EXIT(sa->p_log);
+}
+
+static void lr_rcv_get_port_links(IN osm_sa_t * sa,
+ IN const ib_link_record_t * p_lr,
+ IN const osm_port_t * p_src_port,
+ IN const osm_port_t * p_dest_port,
+ IN const ib_net64_t comp_mask,
+ IN cl_qlist_t * p_list,
+ IN const osm_physp_t * p_req_physp)
+{
+ const osm_physp_t *p_src_physp;
+ const osm_physp_t *p_dest_physp;
+ const cl_qmap_t *p_node_tbl;
+ osm_node_t *p_node;
+ uint8_t port_num;
+ uint8_t num_ports;
+ uint8_t dest_num_ports;
+ uint8_t dest_port_num;
+
+ OSM_LOG_ENTER(sa->p_log);
+
+ if (p_src_port) {
+ if (p_dest_port) {
+ /*
+ Build an LR for every link connected between both ports.
+ The inner function will discard physp combinations
+ that do not actually connect. Don't bother screening
+ for that here.
+ */
+ num_ports = osm_node_get_num_physp(p_src_port->p_node);
+ dest_num_ports =
+ osm_node_get_num_physp(p_dest_port->p_node);
+ for (port_num = 1; port_num < num_ports; port_num++) {
+ p_src_physp =
+ osm_node_get_physp_ptr(p_src_port->p_node,
+ port_num);
+ for (dest_port_num = 1;
+ dest_port_num < dest_num_ports;
+ dest_port_num++) {
+ p_dest_physp =
+ osm_node_get_physp_ptr(p_dest_port->
+ p_node,
+ dest_port_num);
+ /* both physical ports should be with data */
+ if (p_src_physp && p_dest_physp)
+ lr_rcv_get_physp_link
+ (sa, p_lr, p_src_physp,
+ p_dest_physp, comp_mask,
+ p_list, p_req_physp);
+ }
+ }
+ } else {
+ /*
+ Build an LR for every link connected from the source port.
+ */
+ if (comp_mask & IB_LR_COMPMASK_FROM_PORT) {
+ port_num = p_lr->from_port_num;
+ /* If the port number is out of the range of the p_src_port, then
+ this couldn't be a relevant record. */
+ if (port_num <
+ p_src_port->p_node->physp_tbl_size) {
+ p_src_physp =
+ osm_node_get_physp_ptr(p_src_port->
+ p_node,
+ port_num);
+ if (p_src_physp)
+ lr_rcv_get_physp_link
+ (sa, p_lr, p_src_physp,
+ NULL, comp_mask, p_list,
+ p_req_physp);
+ }
+ } else {
+ num_ports =
+ osm_node_get_num_physp(p_src_port->p_node);
+ for (port_num = 1; port_num < num_ports;
+ port_num++) {
+ p_src_physp =
+ osm_node_get_physp_ptr(p_src_port->
+ p_node,
+ port_num);
+ if (p_src_physp)
+ lr_rcv_get_physp_link
+ (sa, p_lr, p_src_physp,
+ NULL, comp_mask, p_list,
+ p_req_physp);
+ }
+ }
+ }
+ } else {
+ if (p_dest_port) {
+ /*
+ Build an LR for every link connected to the dest port.
+ */
+ if (comp_mask & IB_LR_COMPMASK_TO_PORT) {
+ port_num = p_lr->to_port_num;
+ /* If the port number is out of the range of the p_dest_port, then
+ this couldn't be a relevant record. */
+ if (port_num <
+ p_dest_port->p_node->physp_tbl_size) {
+ p_dest_physp =
+ osm_node_get_physp_ptr(p_dest_port->
+ p_node,
+ port_num);
+ if (p_dest_physp)
+ lr_rcv_get_physp_link
+ (sa, p_lr, NULL,
+ p_dest_physp, comp_mask,
+ p_list, p_req_physp);
+ }
+ } else {
+ num_ports =
+ osm_node_get_num_physp(p_dest_port->p_node);
+ for (port_num = 1; port_num < num_ports;
+ port_num++) {
+ p_dest_physp =
+ osm_node_get_physp_ptr(p_dest_port->
+ p_node,
+ port_num);
+ if (p_dest_physp)
+ lr_rcv_get_physp_link
+ (sa, p_lr, NULL,
+ p_dest_physp, comp_mask,
+ p_list, p_req_physp);
+ }
+ }
+ } else {
+ /*
+ Process the world (recurse once back into this function).
+ */
+ p_node_tbl = &sa->p_subn->node_guid_tbl;
+ p_node = (osm_node_t *) cl_qmap_head(p_node_tbl);
+
+ while (p_node != (osm_node_t *) cl_qmap_end(p_node_tbl)) {
+ num_ports = osm_node_get_num_physp(p_node);
+ for (port_num = 1; port_num < num_ports;
+ port_num++) {
+ p_src_physp =
+ osm_node_get_physp_ptr(p_node,
+ port_num);
+ if (p_src_physp)
+ lr_rcv_get_physp_link
+ (sa, p_lr, p_src_physp,
+ NULL, comp_mask, p_list,
+ p_req_physp);
+ }
+ p_node = (osm_node_t *) cl_qmap_next(&p_node->
+ map_item);
+ }
+ }
+ }
+
+ OSM_LOG_EXIT(sa->p_log);
+}
+
+/**********************************************************************
+ Returns the SA status to return to the client.
+ **********************************************************************/
+static ib_net16_t lr_rcv_get_end_points(IN osm_sa_t * sa,
+ IN const osm_madw_t * p_madw,
+ OUT const osm_port_t ** pp_src_port,
+ OUT const osm_port_t ** pp_dest_port)
+{
+ const ib_link_record_t *p_lr;
+ const ib_sa_mad_t *p_sa_mad;
+ ib_net64_t comp_mask;
+ ib_net16_t sa_status = IB_SA_MAD_STATUS_SUCCESS;
+
+ OSM_LOG_ENTER(sa->p_log);
+
+ /*
+ Determine what fields are valid and then get a pointer
+ to the source and destination port objects, if possible.
+ */
+ p_sa_mad = osm_madw_get_sa_mad_ptr(p_madw);
+ p_lr = (ib_link_record_t *) ib_sa_mad_get_payload_ptr(p_sa_mad);
+
+ comp_mask = p_sa_mad->comp_mask;
+ *pp_src_port = NULL;
+ *pp_dest_port = NULL;
+
+ if (comp_mask & IB_LR_COMPMASK_FROM_LID) {
+ *pp_src_port = osm_get_port_by_lid(sa->p_subn, p_lr->from_lid);
+ if (!*pp_src_port) {
+ /*
+ This 'error' is the client's fault (bad lid) so
+ don't enter it as an error in our own log.
+ Return an error response to the client.
+ */
+ OSM_LOG(sa->p_log, OSM_LOG_VERBOSE,
+ "No source port with LID %u\n",
+ cl_ntoh16(p_lr->from_lid));
+
+ sa_status = IB_SA_MAD_STATUS_NO_RECORDS;
+ goto Exit;
+ }
+ }
+
+ if (comp_mask & IB_LR_COMPMASK_TO_LID) {
+ *pp_dest_port = osm_get_port_by_lid(sa->p_subn, p_lr->to_lid);
+ if (!*pp_dest_port) {
+ /*
+ This 'error' is the client's fault (bad lid) so
+ don't enter it as an error in our own log.
+ Return an error response to the client.
+ */
+ OSM_LOG(sa->p_log, OSM_LOG_VERBOSE,
+ "No dest port with LID %u\n",
+ cl_ntoh16(p_lr->to_lid));
+
+ sa_status = IB_SA_MAD_STATUS_NO_RECORDS;
+ goto Exit;
+ }
+ }
+
+Exit:
+ OSM_LOG_EXIT(sa->p_log);
+ return sa_status;
+}
+
+void osm_lr_rcv_process(IN void *context, IN void *data)
+{
+ osm_sa_t *sa = context;
+ osm_madw_t *p_madw = data;
+ const ib_link_record_t *p_lr;
+ const ib_sa_mad_t *p_sa_mad;
+ const osm_port_t *p_src_port;
+ const osm_port_t *p_dest_port;
+ cl_qlist_t lr_list;
+ ib_net16_t status;
+ osm_physp_t *p_req_physp;
+
+ OSM_LOG_ENTER(sa->p_log);
+
+ CL_ASSERT(p_madw);
+
+ p_sa_mad = osm_madw_get_sa_mad_ptr(p_madw);
+ p_lr = ib_sa_mad_get_payload_ptr(p_sa_mad);
+
+ CL_ASSERT(p_sa_mad->attr_id == IB_MAD_ATTR_LINK_RECORD);
+
+ /* we only support SubnAdmGet and SubnAdmGetTable methods */
+ if (p_sa_mad->method != IB_MAD_METHOD_GET &&
+ p_sa_mad->method != IB_MAD_METHOD_GETTABLE) {
+ OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 1804: "
+ "Unsupported Method (%s) for LinkRecord request\n",
+ ib_get_sa_method_str(p_sa_mad->method));
+ osm_sa_send_error(sa, p_madw, IB_MAD_STATUS_UNSUP_METHOD_ATTR);
+ goto Exit;
+ }
+
+ cl_plock_acquire(sa->p_lock);
+
+ /* update the requester physical port */
+ p_req_physp = osm_get_physp_by_mad_addr(sa->p_log, sa->p_subn,
+ osm_madw_get_mad_addr_ptr
+ (p_madw));
+ if (p_req_physp == NULL) {
+ cl_plock_release(sa->p_lock);
+ OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 1805: "
+ "Cannot find requester physical port\n");
+ goto Exit;
+ }
+
+ if (OSM_LOG_IS_ACTIVE_V2(sa->p_log, OSM_LOG_DEBUG)) {
+ OSM_LOG(sa->p_log, OSM_LOG_DEBUG,
+ "Requester port GUID 0x%" PRIx64 "\n",
+ cl_ntoh64(osm_physp_get_port_guid(p_req_physp)));
+ osm_dump_link_record_v2(sa->p_log, p_lr, FILE_ID, OSM_LOG_DEBUG);
+ }
+
+ cl_qlist_init(&lr_list);
+
+ /*
+ Most SA functions (including this one) are read-only on the
+ subnet object, so we grab the lock non-exclusively.
+ */
+ status = lr_rcv_get_end_points(sa, p_madw, &p_src_port, &p_dest_port);
+
+ if (status == IB_SA_MAD_STATUS_SUCCESS)
+ lr_rcv_get_port_links(sa, p_lr, p_src_port, p_dest_port,
+ p_sa_mad->comp_mask, &lr_list,
+ p_req_physp);
+
+ cl_plock_release(sa->p_lock);
+
+ osm_sa_respond(sa, p_madw, sizeof(ib_link_record_t), &lr_list);
+
+Exit:
+ OSM_LOG_EXIT(sa->p_log);
+}
diff --git a/contrib/ofed/opensm/opensm/osm_sa_mad_ctrl.c b/contrib/ofed/opensm/opensm/osm_sa_mad_ctrl.c
new file mode 100644
index 0000000..dbab4a9
--- /dev/null
+++ b/contrib/ofed/opensm/opensm/osm_sa_mad_ctrl.c
@@ -0,0 +1,622 @@
+/*
+ * Copyright (c) 2004-2009 Voltaire, Inc. All rights reserved.
+ * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved.
+ * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
+ * Copyright (c) 2009 HNR Consulting. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+/*
+ * Abstract:
+ * Implementation of osm_sa_mad_ctrl_t.
+ * This object is part of the SA object.
+ */
+
+#if HAVE_CONFIG_H
+# include <config.h>
+#endif /* HAVE_CONFIG_H */
+
+#include <string.h>
+#include <complib/cl_debug.h>
+#include <iba/ib_types.h>
+#include <opensm/osm_file_ids.h>
+#define FILE_ID OSM_FILE_SA_MAD_CTRL_C
+#include <vendor/osm_vendor_api.h>
+#include <opensm/osm_sa_mad_ctrl.h>
+#include <opensm/osm_msgdef.h>
+#include <opensm/osm_helper.h>
+#include <opensm/osm_sa.h>
+#include <opensm/osm_opensm.h>
+
+/****f* opensm: SA/sa_mad_ctrl_disp_done_callback
+ * NAME
+ * sa_mad_ctrl_disp_done_callback
+ *
+ * DESCRIPTION
+ * This function is the Dispatcher callback that indicates
+ * a received MAD has been processed by the recipient.
+ *
+ * SYNOPSIS
+ */
+static void sa_mad_ctrl_disp_done_callback(IN void *context, IN void *p_data)
+{
+ osm_sa_mad_ctrl_t *p_ctrl = context;
+ osm_madw_t *p_madw = p_data;
+
+ OSM_LOG_ENTER(p_ctrl->p_log);
+
+ CL_ASSERT(p_madw);
+ /*
+ Return the MAD & wrapper to the pool.
+ */
+ osm_mad_pool_put(p_ctrl->p_mad_pool, p_madw);
+ OSM_LOG_EXIT(p_ctrl->p_log);
+}
+
+/************/
+
+/****f* opensm: SA/sa_mad_ctrl_process
+ * NAME
+ * sa_mad_ctrl_process
+ *
+ * DESCRIPTION
+ * This function handles known methods for received MADs.
+ *
+ * SYNOPSIS
+ */
+static void sa_mad_ctrl_process(IN osm_sa_mad_ctrl_t * p_ctrl,
+ IN osm_madw_t * p_madw,
+ IN boolean_t is_get_request)
+{
+ ib_sa_mad_t *p_sa_mad;
+ cl_disp_reg_handle_t h_disp;
+ cl_status_t status;
+ cl_disp_msgid_t msg_id = CL_DISP_MSGID_NONE;
+ uint64_t last_dispatched_msg_queue_time_msec;
+ uint32_t num_messages;
+
+ OSM_LOG_ENTER(p_ctrl->p_log);
+
+ p_sa_mad = osm_madw_get_sa_mad_ptr(p_madw);
+
+ /*
+ If the dispatcher is showing us that it is overloaded
+ there is no point in placing the request in. We should instead
+ provide immediate response - IB_RESOURCE_BUSY
+ But how do we know?
+ The dispatcher reports back the number of outstanding messages and
+ the time the last message stayed in the queue.
+ HACK: Actually, we cannot send a mad from within the receive callback;
+ thus - we will just drop it.
+ */
+
+ if (!is_get_request && p_ctrl->p_set_disp) {
+ h_disp = p_ctrl->h_set_disp;
+ goto SKIP_QUEUE_CHECK;
+ }
+
+ h_disp = p_ctrl->h_disp;
+ cl_disp_get_queue_status(h_disp, &num_messages,
+ &last_dispatched_msg_queue_time_msec);
+
+ if (num_messages > 1 && p_ctrl->p_subn->opt.max_msg_fifo_timeout &&
+ last_dispatched_msg_queue_time_msec >
+ p_ctrl->p_subn->opt.max_msg_fifo_timeout) {
+ OSM_LOG(p_ctrl->p_log, OSM_LOG_INFO,
+ /* "Responding BUSY status since the dispatcher is already" */
+ "Dropping MAD since the dispatcher is already"
+ " overloaded with %u messages and queue time of:"
+ "%" PRIu64 "[msec]\n",
+ num_messages, last_dispatched_msg_queue_time_msec);
+
+ /* send a busy response */
+ /* osm_sa_send_error(p_ctrl->p_resp, p_madw, IB_RESOURCE_BUSY); */
+
+ /* return the request to the pool */
+ osm_mad_pool_put(p_ctrl->p_mad_pool, p_madw);
+
+ goto Exit;
+ }
+
+SKIP_QUEUE_CHECK:
+ /*
+ Note that attr_id (like the rest of the MAD) is in
+ network byte order.
+ */
+ switch (p_sa_mad->attr_id) {
+ case IB_MAD_ATTR_CLASS_PORT_INFO:
+ msg_id = OSM_MSG_MAD_CLASS_PORT_INFO;
+ break;
+
+ case IB_MAD_ATTR_NODE_RECORD:
+ msg_id = OSM_MSG_MAD_NODE_RECORD;
+ break;
+
+ case IB_MAD_ATTR_PORTINFO_RECORD:
+ msg_id = OSM_MSG_MAD_PORTINFO_RECORD;
+ break;
+
+ case IB_MAD_ATTR_LINK_RECORD:
+ msg_id = OSM_MSG_MAD_LINK_RECORD;
+ break;
+
+ case IB_MAD_ATTR_SMINFO_RECORD:
+ msg_id = OSM_MSG_MAD_SMINFO_RECORD;
+ break;
+
+ case IB_MAD_ATTR_SERVICE_RECORD:
+ msg_id = OSM_MSG_MAD_SERVICE_RECORD;
+ break;
+
+ case IB_MAD_ATTR_PATH_RECORD:
+ msg_id = OSM_MSG_MAD_PATH_RECORD;
+ break;
+
+ case IB_MAD_ATTR_MCMEMBER_RECORD:
+ msg_id = OSM_MSG_MAD_MCMEMBER_RECORD;
+ break;
+
+ case IB_MAD_ATTR_INFORM_INFO:
+ msg_id = OSM_MSG_MAD_INFORM_INFO;
+ break;
+
+ case IB_MAD_ATTR_VLARB_RECORD:
+ msg_id = OSM_MSG_MAD_VL_ARB_RECORD;
+ break;
+
+ case IB_MAD_ATTR_SLVL_RECORD:
+ msg_id = OSM_MSG_MAD_SLVL_TBL_RECORD;
+ break;
+
+ case IB_MAD_ATTR_PKEY_TBL_RECORD:
+ msg_id = OSM_MSG_MAD_PKEY_TBL_RECORD;
+ break;
+
+ case IB_MAD_ATTR_LFT_RECORD:
+ msg_id = OSM_MSG_MAD_LFT_RECORD;
+ break;
+
+ case IB_MAD_ATTR_GUIDINFO_RECORD:
+ msg_id = OSM_MSG_MAD_GUIDINFO_RECORD;
+ break;
+
+ case IB_MAD_ATTR_INFORM_INFO_RECORD:
+ msg_id = OSM_MSG_MAD_INFORM_INFO_RECORD;
+ break;
+
+ case IB_MAD_ATTR_SWITCH_INFO_RECORD:
+ msg_id = OSM_MSG_MAD_SWITCH_INFO_RECORD;
+ break;
+
+ case IB_MAD_ATTR_MFT_RECORD:
+ msg_id = OSM_MSG_MAD_MFT_RECORD;
+ break;
+
+#if defined (VENDOR_RMPP_SUPPORT) && defined (DUAL_SIDED_RMPP)
+ case IB_MAD_ATTR_MULTIPATH_RECORD:
+ msg_id = OSM_MSG_MAD_MULTIPATH_RECORD;
+ break;
+#endif
+
+ default:
+ OSM_LOG(p_ctrl->p_log, OSM_LOG_ERROR, "ERR 1A01: "
+ "Unsupported attribute 0x%X (%s)\n",
+ cl_ntoh16(p_sa_mad->attr_id),
+ ib_get_sa_attr_str(p_sa_mad->attr_id));
+ osm_dump_sa_mad_v2(p_ctrl->p_log, p_sa_mad, FILE_ID, OSM_LOG_ERROR);
+ }
+
+ if (msg_id != CL_DISP_MSGID_NONE) {
+ /*
+ Post this MAD to the dispatcher for asynchronous
+ processing by the appropriate controller.
+ */
+
+ OSM_LOG(p_ctrl->p_log, OSM_LOG_DEBUG,
+ "Posting Dispatcher message %s\n",
+ osm_get_disp_msg_str(msg_id));
+
+ status = cl_disp_post(h_disp, msg_id, p_madw,
+ sa_mad_ctrl_disp_done_callback, p_ctrl);
+
+ if (status != CL_SUCCESS) {
+ OSM_LOG(p_ctrl->p_log, OSM_LOG_ERROR, "ERR 1A02: "
+ "Dispatcher post message failed (%s) for attribute 0x%X (%s)\n",
+ CL_STATUS_MSG(status),
+ cl_ntoh16(p_sa_mad->attr_id),
+ ib_get_sa_attr_str(p_sa_mad->attr_id));
+
+ osm_mad_pool_put(p_ctrl->p_mad_pool, p_madw);
+ goto Exit;
+ }
+ } else {
+ /*
+ There is an unknown MAD attribute type for which there is
+ no recipient. Simply retire the MAD here.
+ */
+ cl_atomic_inc(&p_ctrl->p_stats->sa_mads_rcvd_unknown);
+ osm_mad_pool_put(p_ctrl->p_mad_pool, p_madw);
+ }
+
+Exit:
+ OSM_LOG_EXIT(p_ctrl->p_log);
+}
+
+/*
+ * PARAMETERS
+ *
+ * RETURN VALUES
+ *
+ * NOTES
+ *
+ * SEE ALSO
+ *********/
+
+/****f* opensm: SA/sa_mad_ctrl_rcv_callback
+ * NAME
+ * sa_mad_ctrl_rcv_callback
+ *
+ * DESCRIPTION
+ * This is the callback from the transport layer for received MADs.
+ *
+ * SYNOPSIS
+ */
+static void sa_mad_ctrl_rcv_callback(IN osm_madw_t * p_madw, IN void *context,
+ IN osm_madw_t * p_req_madw)
+{
+ osm_sa_mad_ctrl_t *p_ctrl = context;
+ ib_sa_mad_t *p_sa_mad;
+ boolean_t is_get_request = FALSE;
+
+ OSM_LOG_ENTER(p_ctrl->p_log);
+
+ CL_ASSERT(p_madw);
+
+ /*
+ A MAD was received from the wire, possibly in response to a request.
+ */
+ cl_atomic_inc(&p_ctrl->p_stats->sa_mads_rcvd);
+
+ OSM_LOG(p_ctrl->p_log, OSM_LOG_DEBUG,
+ "%u SA MADs received\n", p_ctrl->p_stats->sa_mads_rcvd);
+
+ /*
+ * C15-0.1.3 requires not responding to any MAD if the SM is
+ * not in active state!
+ * We will not respond if the sm_state is not MASTER, or if the
+ * first_time_master_sweep flag (of the subnet) is TRUE - this
+ * flag indicates that the master still didn't finish its first
+ * sweep, so the subnet is not up and stable yet.
+ */
+ if (p_ctrl->p_subn->sm_state != IB_SMINFO_STATE_MASTER) {
+ cl_atomic_inc(&p_ctrl->p_stats->sa_mads_ignored);
+ OSM_LOG(p_ctrl->p_log, OSM_LOG_VERBOSE,
+ "Received SA MAD while SM not MASTER. MAD ignored\n");
+ osm_mad_pool_put(p_ctrl->p_mad_pool, p_madw);
+ goto Exit;
+ }
+ if (p_ctrl->p_subn->first_time_master_sweep == TRUE) {
+ cl_atomic_inc(&p_ctrl->p_stats->sa_mads_ignored);
+ OSM_LOG(p_ctrl->p_log, OSM_LOG_VERBOSE,
+ "Received SA MAD while SM in first sweep. MAD ignored\n");
+ osm_mad_pool_put(p_ctrl->p_mad_pool, p_madw);
+ goto Exit;
+ }
+
+ p_sa_mad = osm_madw_get_sa_mad_ptr(p_madw);
+
+ if (OSM_LOG_IS_ACTIVE_V2(p_ctrl->p_log, OSM_LOG_FRAMES))
+ osm_dump_sa_mad_v2(p_ctrl->p_log, p_sa_mad, FILE_ID, OSM_LOG_FRAMES);
+
+ /*
+ * C15-0.1.5 - Table 185: SA Header - p884
+ * SM_key should be either 0 or match the current SM_Key
+ * otherwise discard the MAD.
+ */
+ if (p_sa_mad->sm_key != 0 &&
+ p_sa_mad->sm_key != p_ctrl->p_subn->opt.sa_key) {
+ OSM_LOG(p_ctrl->p_log, OSM_LOG_ERROR, "ERR 1A04: "
+ "Non-Zero MAD SM_Key: 0x%" PRIx64 " != SM_Key: 0x%"
+ PRIx64 "; SA MAD ignored for method 0x%X attribute 0x%X (%s)\n",
+ cl_ntoh64(p_sa_mad->sm_key),
+ cl_ntoh64(p_ctrl->p_subn->opt.sa_key),
+ p_sa_mad->method, cl_ntoh16(p_sa_mad->attr_id),
+ ib_get_sa_attr_str(p_sa_mad->attr_id));
+ osm_mad_pool_put(p_ctrl->p_mad_pool, p_madw);
+ goto Exit;
+ }
+
+ switch (p_sa_mad->method) {
+ case IB_MAD_METHOD_REPORT_RESP:
+ /* we do not really do anything with report responses -
+ just retire the transaction */
+ OSM_LOG(p_ctrl->p_log, OSM_LOG_DEBUG,
+ "Received Report Response. Retiring the transaction\n");
+
+ if (p_req_madw)
+ osm_mad_pool_put(p_ctrl->p_mad_pool, p_req_madw);
+ osm_mad_pool_put(p_ctrl->p_mad_pool, p_madw);
+
+ break;
+
+ case IB_MAD_METHOD_GET:
+ case IB_MAD_METHOD_GETTABLE:
+#if defined (VENDOR_RMPP_SUPPORT) && defined (DUAL_SIDED_RMPP)
+ case IB_MAD_METHOD_GETMULTI:
+#endif
+ is_get_request = TRUE;
+ case IB_MAD_METHOD_SET:
+ case IB_MAD_METHOD_DELETE:
+ /* if we are closing down simply do nothing */
+ if (osm_exit_flag)
+ osm_mad_pool_put(p_ctrl->p_mad_pool, p_madw);
+ else
+ sa_mad_ctrl_process(p_ctrl, p_madw, is_get_request);
+ break;
+
+ default:
+ cl_atomic_inc(&p_ctrl->p_stats->sa_mads_rcvd_unknown);
+ OSM_LOG(p_ctrl->p_log, OSM_LOG_ERROR, "ERR 1A05: "
+ "Unsupported method = 0x%X\n", p_sa_mad->method);
+ osm_mad_pool_put(p_ctrl->p_mad_pool, p_madw);
+ goto Exit;
+ }
+
+Exit:
+ OSM_LOG_EXIT(p_ctrl->p_log);
+}
+
+/*
+ * PARAMETERS
+ *
+ * RETURN VALUES
+ *
+ * NOTES
+ *
+ * SEE ALSO
+ *********/
+
+/****f* opensm: SA/sa_mad_ctrl_send_err_callback
+ * NAME
+ * sa_mad_ctrl_send_err_callback
+ *
+ * DESCRIPTION
+ * This is the callback from the transport layer for send errors
+ * on MADs that were expecting a response.
+ *
+ * SYNOPSIS
+ */
+static void sa_mad_ctrl_send_err_callback(IN void *context,
+ IN osm_madw_t * p_madw)
+{
+ osm_sa_mad_ctrl_t *p_ctrl = context;
+ cl_status_t status;
+
+ OSM_LOG_ENTER(p_ctrl->p_log);
+
+ /*
+ We should never be here since the SA never originates a request.
+ Unless we generated a Report(Notice)
+ */
+
+ CL_ASSERT(p_madw);
+
+ OSM_LOG(p_ctrl->p_log, OSM_LOG_ERROR, "ERR 1A06: "
+ "MAD completed in error (%s): "
+ "%s(%s), attr_mod 0x%x, LID %u, TID 0x%" PRIx64 "\n",
+ ib_get_err_str(p_madw->status),
+ ib_get_sa_method_str(p_madw->p_mad->method),
+ ib_get_sa_attr_str(p_madw->p_mad->attr_id),
+ cl_ntoh32(p_madw->p_mad->attr_mod),
+ cl_ntoh16(p_madw->mad_addr.dest_lid),
+ cl_ntoh64(p_madw->p_mad->trans_id));
+
+ osm_dump_sa_mad_v2(p_ctrl->p_log, osm_madw_get_sa_mad_ptr(p_madw),
+ FILE_ID, OSM_LOG_ERROR);
+
+ /*
+ An error occurred. No response was received to a request MAD.
+ Retire the original request MAD.
+ */
+
+ if (osm_madw_get_err_msg(p_madw) != CL_DISP_MSGID_NONE) {
+ OSM_LOG(p_ctrl->p_log, OSM_LOG_DEBUG,
+ "Posting Dispatcher message %s\n",
+ osm_get_disp_msg_str(osm_madw_get_err_msg(p_madw)));
+
+ if (p_ctrl->p_set_disp &&
+ (p_madw->p_mad->method == IB_MAD_METHOD_SET ||
+ p_madw->p_mad->method == IB_MAD_METHOD_DELETE))
+ status = cl_disp_post(p_ctrl->h_set_disp,
+ osm_madw_get_err_msg(p_madw),
+ p_madw,
+ sa_mad_ctrl_disp_done_callback,
+ p_ctrl);
+ else
+ status = cl_disp_post(p_ctrl->h_disp,
+ osm_madw_get_err_msg(p_madw),
+ p_madw,
+ sa_mad_ctrl_disp_done_callback,
+ p_ctrl);
+ if (status != CL_SUCCESS) {
+ OSM_LOG(p_ctrl->p_log, OSM_LOG_ERROR, "ERR 1A07: "
+ "Dispatcher post message failed (%s)\n",
+ CL_STATUS_MSG(status));
+ }
+ } else /* No error message was provided, just retire the MAD. */
+ osm_mad_pool_put(p_ctrl->p_mad_pool, p_madw);
+
+ OSM_LOG_EXIT(p_ctrl->p_log);
+}
+
+/*
+ * PARAMETERS
+ *
+ * RETURN VALUES
+ *
+ * NOTES
+ *
+ * SEE ALSO
+ *********/
+
+void osm_sa_mad_ctrl_construct(IN osm_sa_mad_ctrl_t * p_ctrl)
+{
+ CL_ASSERT(p_ctrl);
+ memset(p_ctrl, 0, sizeof(*p_ctrl));
+ p_ctrl->h_disp = CL_DISP_INVALID_HANDLE;
+ p_ctrl->h_set_disp = CL_DISP_INVALID_HANDLE;
+}
+
+void osm_sa_mad_ctrl_destroy(IN osm_sa_mad_ctrl_t * p_ctrl)
+{
+ CL_ASSERT(p_ctrl);
+ cl_disp_unregister(p_ctrl->h_disp);
+ cl_disp_unregister(p_ctrl->h_set_disp);
+}
+
+ib_api_status_t osm_sa_mad_ctrl_init(IN osm_sa_mad_ctrl_t * p_ctrl,
+ IN osm_sa_t * sa,
+ IN osm_mad_pool_t * p_mad_pool,
+ IN osm_vendor_t * p_vendor,
+ IN osm_subn_t * p_subn,
+ IN osm_log_t * p_log,
+ IN osm_stats_t * p_stats,
+ IN cl_dispatcher_t * p_disp,
+ IN cl_dispatcher_t * p_set_disp)
+{
+ ib_api_status_t status = IB_SUCCESS;
+
+ OSM_LOG_ENTER(p_log);
+
+ osm_sa_mad_ctrl_construct(p_ctrl);
+
+ p_ctrl->sa = sa;
+ p_ctrl->p_log = p_log;
+ p_ctrl->p_disp = p_disp;
+ p_ctrl->p_set_disp = p_set_disp;
+ p_ctrl->p_mad_pool = p_mad_pool;
+ p_ctrl->p_vendor = p_vendor;
+ p_ctrl->p_stats = p_stats;
+ p_ctrl->p_subn = p_subn;
+
+ p_ctrl->h_disp = cl_disp_register(p_disp, CL_DISP_MSGID_NONE, NULL,
+ p_ctrl);
+
+ if (p_ctrl->h_disp == CL_DISP_INVALID_HANDLE) {
+ OSM_LOG(p_log, OSM_LOG_ERROR, "ERR 1A08: "
+ "Dispatcher registration failed\n");
+ status = IB_INSUFFICIENT_RESOURCES;
+ goto Exit;
+ }
+
+ if (p_set_disp) {
+ p_ctrl->h_set_disp =
+ cl_disp_register(p_set_disp, CL_DISP_MSGID_NONE, NULL,
+ p_ctrl);
+
+ if (p_ctrl->h_set_disp == CL_DISP_INVALID_HANDLE) {
+ OSM_LOG(p_log, OSM_LOG_ERROR, "ERR 1A0A: "
+ "SA set dispatcher registration failed\n");
+ status = IB_INSUFFICIENT_RESOURCES;
+ goto Exit;
+ }
+ }
+
+Exit:
+ OSM_LOG_EXIT(p_log);
+ return status;
+}
+
+ib_api_status_t osm_sa_mad_ctrl_bind(IN osm_sa_mad_ctrl_t * p_ctrl,
+ IN ib_net64_t port_guid)
+{
+ osm_bind_info_t bind_info;
+ ib_api_status_t status = IB_SUCCESS;
+
+ OSM_LOG_ENTER(p_ctrl->p_log);
+
+ if (p_ctrl->h_bind != OSM_BIND_INVALID_HANDLE) {
+ OSM_LOG(p_ctrl->p_log, OSM_LOG_ERROR, "ERR 1A09: "
+ "Multiple binds not allowed\n");
+ status = IB_ERROR;
+ goto Exit;
+ }
+
+ bind_info.class_version = 2;
+ bind_info.is_responder = TRUE;
+ bind_info.is_report_processor = FALSE;
+ bind_info.is_trap_processor = FALSE;
+ bind_info.mad_class = IB_MCLASS_SUBN_ADM;
+ bind_info.port_guid = port_guid;
+ bind_info.recv_q_size = OSM_SM_DEFAULT_QP1_RCV_SIZE;
+ bind_info.send_q_size = OSM_SM_DEFAULT_QP1_SEND_SIZE;
+ bind_info.timeout = p_ctrl->sa->p_subn->opt.transaction_timeout;
+ bind_info.retries = p_ctrl->sa->p_subn->opt.transaction_retries;
+
+ OSM_LOG(p_ctrl->p_log, OSM_LOG_VERBOSE,
+ "Binding to port GUID 0x%" PRIx64 "\n", cl_ntoh64(port_guid));
+
+ p_ctrl->h_bind = osm_vendor_bind(p_ctrl->p_vendor, &bind_info,
+ p_ctrl->p_mad_pool,
+ sa_mad_ctrl_rcv_callback,
+ sa_mad_ctrl_send_err_callback, p_ctrl);
+
+ if (p_ctrl->h_bind == OSM_BIND_INVALID_HANDLE) {
+ status = IB_ERROR;
+ OSM_LOG(p_ctrl->p_log, OSM_LOG_ERROR, "ERR 1A10: "
+ "Vendor specific bind failed (%s)\n",
+ ib_get_err_str(status));
+ goto Exit;
+ }
+
+Exit:
+ OSM_LOG_EXIT(p_ctrl->p_log);
+ return status;
+}
+
+ib_api_status_t osm_sa_mad_ctrl_unbind(IN osm_sa_mad_ctrl_t * p_ctrl)
+{
+ ib_api_status_t status = IB_SUCCESS;
+
+ OSM_LOG_ENTER(p_ctrl->p_log);
+
+ if (p_ctrl->h_bind == OSM_BIND_INVALID_HANDLE) {
+ OSM_LOG(p_ctrl->p_log, OSM_LOG_ERROR, "ERR 1A11: "
+ "No previous bind\n");
+ status = IB_ERROR;
+ goto Exit;
+ }
+
+ osm_vendor_unbind(p_ctrl->h_bind);
+Exit:
+ OSM_LOG_EXIT(p_ctrl->p_log);
+ return status;
+}
diff --git a/contrib/ofed/opensm/opensm/osm_sa_mcmember_record.c b/contrib/ofed/opensm/opensm/osm_sa_mcmember_record.c
new file mode 100644
index 0000000..f1c8f18
--- /dev/null
+++ b/contrib/ofed/opensm/opensm/osm_sa_mcmember_record.c
@@ -0,0 +1,1791 @@
+/*
+ * Copyright (c) 2004-2009 Voltaire, Inc. All rights reserved.
+ * Copyright (c) 2002-2015 Mellanox Technologies LTD. All rights reserved.
+ * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
+ * Copyright (c) 2008 Xsigo Systems Inc. All rights reserved.
+ * Copyright (c) 2013 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+/*
+ * Abstract:
+ * Implementation of osm_mcmr_recv_t.
+ * This object represents the MCMemberRecord Receiver object.
+ * This object is part of the opensm family of objects.
+ */
+
+#if HAVE_CONFIG_H
+# include <config.h>
+#endif /* HAVE_CONFIG_H */
+
+#include <stdlib.h>
+#include <string.h>
+#include <arpa/inet.h>
+#include <sys/socket.h>
+#include <iba/ib_types.h>
+#include <complib/cl_qmap.h>
+#include <complib/cl_passivelock.h>
+#include <complib/cl_debug.h>
+#include <complib/cl_qlist.h>
+#include <opensm/osm_file_ids.h>
+#define FILE_ID OSM_FILE_SA_MCMEMBER_RECORD_C
+#include <vendor/osm_vendor_api.h>
+#include <opensm/osm_madw.h>
+#include <opensm/osm_log.h>
+#include <opensm/osm_subnet.h>
+#include <opensm/osm_mad_pool.h>
+#include <opensm/osm_helper.h>
+#include <opensm/osm_msgdef.h>
+#include <opensm/osm_pkey.h>
+#include <opensm/osm_inform.h>
+#include <opensm/osm_sa.h>
+
+#define SA_MCM_RESP_SIZE SA_ITEM_RESP_SIZE(mc_rec)
+
+#define JOIN_MC_COMP_MASK (IB_MCR_COMPMASK_MGID | \
+ IB_MCR_COMPMASK_PORT_GID | \
+ IB_MCR_COMPMASK_JOIN_STATE)
+
+#define REQUIRED_MC_CREATE_COMP_MASK (IB_MCR_COMPMASK_MGID | \
+ IB_MCR_COMPMASK_PORT_GID | \
+ IB_MCR_COMPMASK_JOIN_STATE | \
+ IB_MCR_COMPMASK_QKEY | \
+ IB_MCR_COMPMASK_TCLASS | \
+ IB_MCR_COMPMASK_PKEY | \
+ IB_MCR_COMPMASK_FLOW | \
+ IB_MCR_COMPMASK_SL)
+
+#define IPV4_BCAST_MGID_PREFIX CL_HTON64(0xff10401b00000000ULL)
+#define IPV4_BCAST_MGID_INT_ID CL_HTON64(0x00000000ffffffffULL)
+
+static int validate_other_comp_fields(osm_log_t * p_log, ib_net64_t comp_mask,
+ const ib_member_rec_t * p_mcmr,
+ osm_mgrp_t * p_mgrp,
+ osm_log_level_t log_level);
+
+/*********************************************************************
+ Copy certain fields between two mcmember records
+ used during the process of join request to copy data from the mgrp
+ to the port record.
+**********************************************************************/
+static void copy_from_create_mc_rec(IN ib_member_rec_t * dest,
+ IN const ib_member_rec_t * src)
+{
+ dest->qkey = src->qkey;
+ dest->mlid = src->mlid;
+ dest->tclass = src->tclass;
+ dest->pkey = src->pkey;
+ dest->sl_flow_hop = src->sl_flow_hop;
+ dest->scope_state = ib_member_set_scope_state(src->scope_state >> 4,
+ dest->scope_state & 0x0F);
+ dest->mtu = src->mtu;
+ dest->rate = src->rate;
+ dest->pkt_life = src->pkt_life;
+}
+
+/*********************************************************************
+ Return mlid to the pool of free mlids.
+ But this implementation is not a pool - it simply scans through
+ the MGRP database for unused mlids...
+*********************************************************************/
+static void free_mlid(IN osm_sa_t * sa, IN uint16_t mlid)
+{
+ UNUSED_PARAM(sa);
+ UNUSED_PARAM(mlid);
+}
+
+/*********************************************************************
+ Get a new unused mlid by scanning all the used ones in the subnet.
+**********************************************************************/
+/* Special Case IPv6 Solicited Node Multicast (SNM) addresses */
+/* 0xff1Z601bXXXX0000 : 0x00000001ffYYYYYY */
+/* Where Z is the scope, XXXX is the P_Key, and
+ * YYYYYY is the last 24 bits of the port guid */
+#define PREFIX_MASK CL_HTON64(0xff10ffff0000ffffULL)
+#define PREFIX_SIGNATURE CL_HTON64(0xff10601b00000000ULL)
+#define INT_ID_MASK CL_HTON64(0xfffffff1ff000000ULL)
+#define INT_ID_SIGNATURE CL_HTON64(0x00000001ff000000ULL)
+
+static int compare_ipv6_snm_mgids(const void *m1, const void *m2)
+{
+ return memcmp(m1, m2, sizeof(ib_gid_t) - 3);
+}
+
+static ib_net16_t find_ipv6_snm_mlid(osm_subn_t *subn, ib_gid_t *mgid)
+{
+ osm_mgrp_t *m = (osm_mgrp_t *)cl_fmap_match(&subn->mgrp_mgid_tbl, mgid,
+ compare_ipv6_snm_mgids);
+ if (m != (osm_mgrp_t *)cl_fmap_end(&subn->mgrp_mgid_tbl))
+ return m->mlid;
+ return 0;
+}
+
+static unsigned match_ipv6_snm_mgid(ib_gid_t * mgid)
+{
+ return ((mgid->unicast.prefix & PREFIX_MASK) == PREFIX_SIGNATURE &&
+ (mgid->unicast.interface_id & INT_ID_MASK) == INT_ID_SIGNATURE);
+}
+
+static ib_net16_t get_new_mlid(osm_sa_t * sa, ib_member_rec_t * mcmr)
+{
+ osm_subn_t *p_subn = sa->p_subn;
+ ib_net16_t requested_mlid = mcmr->mlid;
+ unsigned i, max;
+
+ if (requested_mlid && cl_ntoh16(requested_mlid) >= IB_LID_MCAST_START_HO
+ && cl_ntoh16(requested_mlid) <= p_subn->max_mcast_lid_ho
+ && !osm_get_mbox_by_mlid(p_subn, requested_mlid))
+ return requested_mlid;
+
+ if (sa->p_subn->opt.consolidate_ipv6_snm_req
+ && match_ipv6_snm_mgid(&mcmr->mgid)
+ && (requested_mlid = find_ipv6_snm_mlid(sa->p_subn, &mcmr->mgid))) {
+ char str[INET6_ADDRSTRLEN];
+ OSM_LOG(sa->p_log, OSM_LOG_DEBUG,
+ "Special Case Solicited Node Mcast Join for MGID %s\n",
+ inet_ntop(AF_INET6, mcmr->mgid.raw, str, sizeof(str)));
+ return requested_mlid;
+ }
+
+ max = p_subn->max_mcast_lid_ho - IB_LID_MCAST_START_HO + 1;
+ for (i = 0; i < max; i++)
+ if (!sa->p_subn->mboxes[i])
+ return cl_hton16(i + IB_LID_MCAST_START_HO);
+
+ return 0;
+}
+
+static inline boolean_t check_join_comp_mask(ib_net64_t comp_mask)
+{
+ return ((comp_mask & JOIN_MC_COMP_MASK) == JOIN_MC_COMP_MASK);
+}
+
+static boolean_t check_create_comp_mask(ib_net64_t comp_mask,
+ ib_member_rec_t * p_recvd_mcmember_rec)
+{
+ return ((comp_mask & REQUIRED_MC_CREATE_COMP_MASK) ==
+ REQUIRED_MC_CREATE_COMP_MASK);
+}
+
+/**********************************************************************
+ Generate the response MAD
+**********************************************************************/
+static void mcmr_rcv_respond(IN osm_sa_t * sa, IN osm_madw_t * p_madw,
+ IN ib_member_rec_t * p_mcmember_rec)
+{
+ cl_qlist_t rec_list;
+ osm_sa_item_t *item;
+
+ OSM_LOG_ENTER(sa->p_log);
+
+ item = malloc(SA_MCM_RESP_SIZE);
+ if (!item) {
+ OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 1B16: "
+ "rec_item alloc failed\n");
+ goto Exit;
+ }
+
+ item->resp.mc_rec = *p_mcmember_rec;
+
+ /* Fill in the mtu, rate, and packet lifetime selectors */
+ item->resp.mc_rec.mtu &= 0x3f;
+ item->resp.mc_rec.mtu |= IB_PATH_SELECTOR_EXACTLY << 6;
+ item->resp.mc_rec.rate &= 0x3f;
+ item->resp.mc_rec.rate |= IB_PATH_SELECTOR_EXACTLY << 6;
+ item->resp.mc_rec.pkt_life &= 0x3f;
+ item->resp.mc_rec.pkt_life |= IB_PATH_SELECTOR_EXACTLY << 6;
+
+ cl_qlist_init(&rec_list);
+ cl_qlist_insert_tail(&rec_list, &item->list_item);
+
+ osm_sa_respond(sa, p_madw, sizeof(ib_member_rec_t), &rec_list);
+
+Exit:
+ OSM_LOG_EXIT(sa->p_log);
+}
+
+/*********************************************************************
+ In joining an existing group, or when querying the mc groups,
+ we make sure the following components provided match: MTU and RATE
+ HACK: Currently we ignore the PKT_LIFETIME field.
+**********************************************************************/
+static boolean_t validate_more_comp_fields(osm_log_t * p_log,
+ const osm_mgrp_t * p_mgrp,
+ const ib_member_rec_t *
+ p_recvd_mcmember_rec,
+ ib_net64_t comp_mask)
+{
+ uint8_t mtu_sel;
+ uint8_t mtu_required;
+ uint8_t mtu_mgrp;
+ uint8_t rate_sel;
+ uint8_t rate_required;
+ uint8_t rate_mgrp;
+
+ if (comp_mask & IB_MCR_COMPMASK_MTU_SEL) {
+ mtu_sel = (uint8_t) (p_recvd_mcmember_rec->mtu >> 6);
+ /* Clearing last 2 bits */
+ mtu_required = (uint8_t) (p_recvd_mcmember_rec->mtu & 0x3F);
+ mtu_mgrp = (uint8_t) (p_mgrp->mcmember_rec.mtu & 0x3F);
+ switch (mtu_sel) {
+ case 0: /* Greater than MTU specified */
+ if (mtu_mgrp <= mtu_required) {
+ OSM_LOG(p_log, OSM_LOG_VERBOSE,
+ "Requested mcast group has MTU %x, "
+ "which is not greater than %x\n",
+ mtu_mgrp, mtu_required);
+ return FALSE;
+ }
+ break;
+ case 1: /* Less than MTU specified */
+ if (mtu_mgrp >= mtu_required) {
+ OSM_LOG(p_log, OSM_LOG_VERBOSE,
+ "Requested mcast group has MTU %x, "
+ "which is not less than %x\n",
+ mtu_mgrp, mtu_required);
+ return FALSE;
+ }
+ break;
+ case 2: /* Exactly MTU specified */
+ if (mtu_mgrp != mtu_required) {
+ OSM_LOG(p_log, OSM_LOG_VERBOSE,
+ "Requested mcast group has MTU %x, "
+ "which is not equal to %x\n",
+ mtu_mgrp, mtu_required);
+ return FALSE;
+ }
+ break;
+ default:
+ break;
+ }
+ }
+
+ /* what about rate ? */
+ if (comp_mask & IB_MCR_COMPMASK_RATE_SEL) {
+ rate_sel = (uint8_t) (p_recvd_mcmember_rec->rate >> 6);
+ /* Clearing last 2 bits */
+ rate_required = (uint8_t) (p_recvd_mcmember_rec->rate & 0x3F);
+ rate_mgrp = (uint8_t) (p_mgrp->mcmember_rec.rate & 0x3F);
+ switch (rate_sel) {
+ case 0: /* Greater than RATE specified */
+ if (ib_path_compare_rates(rate_mgrp, rate_required) <= 0) {
+ OSM_LOG(p_log, OSM_LOG_VERBOSE,
+ "Requested mcast group has RATE %x, "
+ "which is not greater than %x\n",
+ rate_mgrp, rate_required);
+ return FALSE;
+ }
+ break;
+ case 1: /* Less than RATE specified */
+ if (ib_path_compare_rates(rate_mgrp, rate_required) >= 0) {
+ OSM_LOG(p_log, OSM_LOG_VERBOSE,
+ "Requested mcast group has RATE %x, "
+ "which is not less than %x\n",
+ rate_mgrp, rate_required);
+ return FALSE;
+ }
+ break;
+ case 2: /* Exactly RATE specified */
+ if (ib_path_compare_rates(rate_mgrp, rate_required)) {
+ OSM_LOG(p_log, OSM_LOG_VERBOSE,
+ "Requested mcast group has RATE %x, "
+ "which is not equal to %x\n",
+ rate_mgrp, rate_required);
+ return FALSE;
+ }
+ break;
+ default:
+ break;
+ }
+ }
+
+ return TRUE;
+}
+
+/*********************************************************************
+ In joining an existing group, we make sure the following components
+ are physically realizable: MTU and RATE
+**********************************************************************/
+static boolean_t validate_port_caps(osm_log_t * p_log,
+ const osm_mgrp_t * p_mgrp,
+ const osm_physp_t * p_physp)
+{
+ const ib_port_info_t *p_pi;
+ uint8_t mtu_required;
+ uint8_t mtu_mgrp;
+ uint8_t rate_required;
+ uint8_t rate_mgrp;
+ int extended;
+
+ mtu_required = ib_port_info_get_neighbor_mtu(&p_physp->port_info);
+ mtu_mgrp = (uint8_t) (p_mgrp->mcmember_rec.mtu & 0x3F);
+ if (mtu_required < mtu_mgrp) {
+ OSM_LOG(p_log, OSM_LOG_VERBOSE,
+ "Port's MTU %x is less than %x\n",
+ mtu_required, mtu_mgrp);
+ return FALSE;
+ }
+
+ p_pi = &p_physp->port_info;
+ extended = p_pi->capability_mask & IB_PORT_CAP_HAS_EXT_SPEEDS;
+ rate_required = ib_port_info_compute_rate(p_pi, extended);
+ rate_mgrp = (uint8_t) (p_mgrp->mcmember_rec.rate & 0x3F);
+ if (ib_path_compare_rates(rate_required, rate_mgrp) < 0) {
+ OSM_LOG(p_log, OSM_LOG_VERBOSE,
+ "Port's RATE %x is less than %x\n",
+ rate_required, rate_mgrp);
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+/**********************************************************************
+ * o15-0.2.1: If SA supports UD multicast, then if SA receives a SubnAdmSet()
+ * or SubnAdmDelete() method that would modify an existing
+ * MCMemberRecord, SA shall not modify that MCMemberRecord and shall
+ * return an error status of ERR_REQ_INVALID in response in the
+ * following cases:
+ * 1. Saved MCMemberRecord.ProxyJoin is not set and the request is
+ * issued by a requester with a GID other than the Port-GID.
+ * 2. Saved MCMemberRecord.ProxyJoin is set and the requester is not
+ * part of the partition for that MCMemberRecord.
+ **********************************************************************/
+static boolean_t validate_modify(IN osm_sa_t * sa, IN osm_mgrp_t * p_mgrp,
+ IN osm_mad_addr_t * p_mad_addr,
+ IN ib_member_rec_t * p_recvd_mcmember_rec,
+ OUT osm_mcm_alias_guid_t ** pp_mcm_alias_guid)
+{
+ ib_net64_t portguid;
+ ib_gid_t request_gid;
+ osm_physp_t *p_request_physp;
+ ib_api_status_t res;
+
+ portguid = p_recvd_mcmember_rec->port_gid.unicast.interface_id;
+
+ *pp_mcm_alias_guid = osm_mgrp_get_mcm_alias_guid(p_mgrp, portguid);
+
+ /* o15-0.2.1: If this is a new port being added - nothing to check */
+ if (!*pp_mcm_alias_guid) {
+ OSM_LOG(sa->p_log, OSM_LOG_DEBUG,
+ "This is a new port in the MC group\n");
+ return TRUE;
+ }
+
+ /* We validate the request according the the proxy_join.
+ Check if the proxy_join is set or not */
+ if ((*pp_mcm_alias_guid)->proxy_join == FALSE) {
+ /* The proxy_join is not set. Modifying can by done only
+ if the requester GID == PortGID */
+ res = osm_get_gid_by_mad_addr(sa->p_log, sa->p_subn, p_mad_addr,
+ &request_gid);
+ if (res != IB_SUCCESS) {
+ OSM_LOG(sa->p_log, OSM_LOG_DEBUG,
+ "Could not find port for requested address\n");
+ return FALSE;
+ }
+
+ if ((*pp_mcm_alias_guid)->p_base_mcm_port->port->guid !=
+ request_gid.unicast.interface_id ||
+ (*pp_mcm_alias_guid)->port_gid.unicast.prefix !=
+ request_gid.unicast.prefix) {
+ ib_gid_t base_port_gid;
+ char gid_str[INET6_ADDRSTRLEN];
+ char gid_str2[INET6_ADDRSTRLEN];
+
+ base_port_gid.unicast.prefix = (*pp_mcm_alias_guid)->port_gid.unicast.prefix;
+ base_port_gid.unicast.interface_id = (*pp_mcm_alias_guid)->p_base_mcm_port->port->guid;
+ OSM_LOG(sa->p_log, OSM_LOG_DEBUG,
+ "No ProxyJoin but different ports: stored:"
+ "%s request:%s\n",
+ inet_ntop(AF_INET6, base_port_gid.raw, gid_str,
+ sizeof gid_str),
+ inet_ntop(AF_INET6, request_gid.raw, gid_str2,
+ sizeof gid_str2));
+ return FALSE;
+ }
+ } else {
+ /* The proxy_join is set. Modification allowed only if the
+ requester is part of the partition for this MCMemberRecord */
+ p_request_physp = osm_get_physp_by_mad_addr(sa->p_log,
+ sa->p_subn,
+ p_mad_addr);
+ if (p_request_physp == NULL)
+ return FALSE;
+
+ if (!osm_physp_has_pkey(sa->p_log, p_mgrp->mcmember_rec.pkey,
+ p_request_physp)) {
+ /* the request port is not part of the partition for this mgrp */
+ OSM_LOG(sa->p_log, OSM_LOG_DEBUG,
+ "Requesting port 0x%016" PRIx64 " has no PKey 0x%04x\n",
+ cl_ntoh64(p_request_physp->port_guid),
+ cl_ntoh16(p_mgrp->mcmember_rec.pkey));
+ return FALSE;
+ }
+ }
+ return TRUE;
+}
+
+/*
+ * Check legality of the requested MGID DELETE
+ * o15-0.1.14 = VALID DELETE:
+ * To be a valid delete MAD needs to:
+ * 1 the MADs PortGID and MGID components match the PortGID and
+ * MGID of a stored MCMemberRecord;
+ * 2 the MADs JoinState component contains at least one bit set to 1
+ * in the same position as that stored MCMemberRecords JoinState
+ * has a bit set to 1,
+ * i.e., the logical AND of the two JoinState components
+ * is not all zeros;
+ * 3 the MADs JoinState component does not have some bits set
+ * which are not set in the stored MCMemberRecords JoinState component;
+ * 4 either the stored MCMemberRecord:ProxyJoin is reset (0), and the
+ * MADs source is the stored PortGID;
+ * OR
+ * the stored MCMemberRecord:ProxyJoin is set (1), (see o15-
+ * 0.1.2:); and the MADs source is a member of the partition indicated
+ * by the stored MCMemberRecord:P_Key.
+ */
+static boolean_t validate_delete(IN osm_sa_t * sa, IN osm_mgrp_t * p_mgrp,
+ IN osm_mad_addr_t * p_mad_addr,
+ IN ib_member_rec_t * p_recvd_mcmember_rec,
+ OUT osm_mcm_alias_guid_t ** pp_mcm_alias_guid)
+{
+ ib_net64_t portguid;
+
+ portguid = p_recvd_mcmember_rec->port_gid.unicast.interface_id;
+
+ *pp_mcm_alias_guid = osm_mgrp_get_mcm_alias_guid(p_mgrp, portguid);
+
+ /* 1 */
+ if (!*pp_mcm_alias_guid) {
+ OSM_LOG(sa->p_log, OSM_LOG_DEBUG,
+ "Failed to find the port in the MC group\n");
+ return FALSE;
+ }
+
+ /* 2 */
+ if (!(p_recvd_mcmember_rec->scope_state & 0x0F &
+ (*pp_mcm_alias_guid)->scope_state)) {
+ OSM_LOG(sa->p_log, OSM_LOG_DEBUG,
+ "Could not find any matching bits in the stored "
+ "and requested JoinStates\n");
+ return FALSE;
+ }
+
+ /* 3 */
+ if (((p_recvd_mcmember_rec->scope_state & 0x0F) |
+ (0x0F & (*pp_mcm_alias_guid)->scope_state)) !=
+ (0x0F & (*pp_mcm_alias_guid)->scope_state)) {
+ OSM_LOG(sa->p_log, OSM_LOG_DEBUG,
+ "Some bits in the request JoinState (0x%X) are not "
+ "set in the stored port (0x%X)\n",
+ (p_recvd_mcmember_rec->scope_state & 0x0F),
+ (0x0F & (*pp_mcm_alias_guid)->scope_state));
+ return FALSE;
+ }
+
+ /* 4 */
+ /* Validate according the the proxy_join (o15-0.1.2) */
+ if (validate_modify(sa, p_mgrp, p_mad_addr, p_recvd_mcmember_rec,
+ pp_mcm_alias_guid) == FALSE) {
+ OSM_LOG(sa->p_log, OSM_LOG_DEBUG,
+ "proxy_join validation failure\n");
+ return FALSE;
+ }
+ return TRUE;
+}
+
+/*
+ * Check legality of the requested MGID (note this does not hold for SA
+ * created MGIDs)
+ *
+ * Implementing o15-0.1.5:
+ * A multicast GID is considered to be invalid if:
+ * 1. It does not comply with the rules as specified in 4.1.1 "GID Usage and
+ * Properties" on page 145:
+ *
+ * 14) The multicast GID format is (bytes are comma sep):
+ * 0xff,<Fl><Sc>,<Si>,<Si>,<P>,<P>,<P>,<P>,<P>,<P>,<P>,<P>,<Id>,<Id>,<Id>,<Id>
+ * Fl 4bit = Flags (b)
+ * Sc 4bit = Scope (c)
+ * Si 16bit = Signature (2)
+ * P 64bit = GID Prefix (should be a subnet unique ID - normally Subnet Prefix)
+ * Id 32bit = Unique ID in the Subnet (might be MLID or P_Key ?)
+ *
+ * a) 8-bits of 11111111 at the start of the GID identifies this as being a
+ * multicast GID.
+ * b) Flags is a set of four 1-bit flags: 000T with three flags reserved
+ * and defined as zero (0). The T flag is defined as follows:
+ * i) T = 0 indicates this is a permanently assigned (i.e. wellknown)
+ * multicast GID. See RFC 2373 and RFC 2375 as reference
+ * for these permanently assigned GIDs.
+ * ii) T = 1 indicates this is a non-permanently assigned (i.e. transient)
+ * multicast GID.
+ * c) Scope is a 4-bit multicast scope value used to limit the scope of
+ * the multicast group. The following table defines scope value and
+ * interpretation.
+ *
+ * Multicast Address Scope Values:
+ * 0x2 Link-local
+ * 0x5 Site-local
+ * 0x8 Organization-local
+ * 0xE Global
+ *
+ * 2. It contains the SA-specific signature of 0xA01B and has the link-local
+ * scope bits set. (EZ: the idea here is that SA created MGIDs are the
+ * only source for this signature with link-local scope)
+ */
+static boolean_t validate_requested_mgid(IN osm_sa_t * sa,
+ IN const ib_member_rec_t * p_mcm_rec)
+{
+ uint16_t signature;
+ boolean_t valid = TRUE;
+
+ OSM_LOG_ENTER(sa->p_log);
+
+ /* 14-a: mcast GID must start with 0xFF */
+ if (p_mcm_rec->mgid.multicast.header[0] != 0xFF) {
+ OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 1B01: "
+ "Invalid prefix 0x%02X in requested MGID, "
+ "must be 0xFF\n",
+ cl_ntoh16(p_mcm_rec->mgid.multicast.header[0]));
+ valid = FALSE;
+ goto Exit;
+ }
+
+ /* the MGID signature can mark IPoIB or SA assigned MGIDs */
+ memcpy(&signature, &(p_mcm_rec->mgid.multicast.raw_group_id),
+ sizeof(signature));
+ signature = cl_ntoh16(signature);
+ OSM_LOG(sa->p_log, OSM_LOG_DEBUG, "MGID Signed as 0x%04X\n", signature);
+
+ /*
+ * We skip any checks for MGIDs that follow IPoIB
+ * GID structure as defined by the IETF ipoib-link-multicast.
+ *
+ * For IPv4 over IB, the signature will be "0x401B".
+ *
+ * | 8 | 4 | 4 | 16 bits | 16 bits | 48 bits | 32 bits |
+ * +--------+----+----+-----------------+---------+----------+---------+
+ * |11111111|0001|scop|<IPoIB signature>|< P_Key >|00.......0|<all 1's>|
+ * +--------+----+----+-----------------+---------+----------+---------+
+ *
+ * For IPv6 over IB, the signature will be "0x601B".
+ *
+ * | 8 | 4 | 4 | 16 bits | 16 bits | 80 bits |
+ * +--------+----+----+-----------------+---------+--------------------+
+ * |11111111|0001|scop|<IPoIB signature>|< P_Key >|000.............0001|
+ * +--------+----+----+-----------------+---------+--------------------+
+ *
+ */
+ if (signature == 0x401B || signature == 0x601B) {
+ OSM_LOG(sa->p_log, OSM_LOG_DEBUG,
+ "Skipping MGID Validation for IPoIB Signed (0x%04X) MGIDs\n",
+ signature);
+ goto Exit;
+ }
+
+ /* 14-b: the 3 upper bits in the "flags" should be zero: */
+ if (p_mcm_rec->mgid.multicast.header[1] & 0xE0) {
+ OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 1B28: "
+ "Requested MGID invalid, uses Reserved Flags: flags=0x%X\n",
+ (p_mcm_rec->mgid.multicast.header[1] & 0xE0) >> 4);
+ valid = FALSE;
+ goto Exit;
+ }
+
+ /* 2 - now what if the link local format 0xA01B is used -
+ the scope should not be link local */
+ if (signature == 0xA01B &&
+ (p_mcm_rec->mgid.multicast.header[1] & 0x0F) ==
+ IB_MC_SCOPE_LINK_LOCAL) {
+ OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 1B24: "
+ "Requested MGID invalid, "
+ "uses 0xA01B signature but with link-local scope\n");
+ valid = FALSE;
+ goto Exit;
+ }
+
+ /*
+ * For SA assigned MGIDs (signature 0xA01B):
+ * There is no real way to make sure the GID Prefix is really unique.
+ * If we could enforce using the Subnet Prefix for that purpose it would
+ * have been nice. But the spec does not require it.
+ */
+
+Exit:
+ OSM_LOG_EXIT(sa->p_log);
+ return valid;
+}
+
+/**********************************************************************
+ Check if the requested new MC group parameters are realizable.
+ Also set the default MTU and Rate if not provided by the user.
+**********************************************************************/
+static boolean_t mgrp_request_is_realizable(IN osm_sa_t * sa,
+ IN ib_net64_t comp_mask,
+ IN ib_member_rec_t * p_mcm_rec,
+ IN const osm_physp_t * p_physp)
+{
+ uint8_t mtu_sel = 2; /* exactly */
+ uint8_t mtu_required, mtu, port_mtu;
+ uint8_t rate_sel = 2; /* exactly */
+ uint8_t rate_required, rate, port_rate;
+ const ib_port_info_t *p_pi;
+ osm_log_t *p_log = sa->p_log;
+ int extended;
+
+ OSM_LOG_ENTER(sa->p_log);
+
+ /*
+ * End of o15-0.2.3 specifies:
+ * ....
+ * The entity may also supply the other components such as HopLimit,
+ * MTU, etc. during group creation time. If these components are not
+ * provided during group creation time, SA will provide them for the
+ * group. The values chosen are vendor-dependent and beyond the scope
+ * of the specification.
+ *
+ * so we might also need to assign RATE/MTU if they are not comp
+ * masked in.
+ */
+
+ p_pi = &p_physp->port_info;
+ port_mtu = p_physp ? ib_port_info_get_mtu_cap(p_pi) : 0;
+ if (!(comp_mask & IB_MCR_COMPMASK_MTU) ||
+ !(comp_mask & IB_MCR_COMPMASK_MTU_SEL) ||
+ (mtu_sel = (p_mcm_rec->mtu >> 6)) == 3)
+ mtu = port_mtu ? port_mtu : sa->p_subn->min_ca_mtu;
+ else {
+ mtu_required = (uint8_t) (p_mcm_rec->mtu & 0x3F);
+ mtu = mtu_required;
+ switch (mtu_sel) {
+ case 0: /* Greater than MTU specified */
+ if (port_mtu && mtu_required >= port_mtu) {
+ OSM_LOG(p_log, OSM_LOG_VERBOSE,
+ "Requested MTU %x >= the port\'s mtu:%x\n",
+ mtu_required, port_mtu);
+ return FALSE;
+ }
+ /* we provide the largest MTU possible if we can */
+ if (port_mtu)
+ mtu = port_mtu;
+ else if (mtu_required < sa->p_subn->min_ca_mtu)
+ mtu = sa->p_subn->min_ca_mtu;
+ else
+ mtu++;
+ break;
+ case 1: /* Less than MTU specified */
+ /* use the smaller of the two:
+ a. one lower then the required
+ b. the mtu of the requesting port (if exists) */
+ if (port_mtu && mtu_required > port_mtu)
+ mtu = port_mtu;
+ else
+ mtu--;
+ break;
+ case 2: /* Exactly MTU specified */
+ default:
+ break;
+ }
+ /* make sure it still is in the range */
+ if (mtu < IB_MIN_MTU || mtu > IB_MAX_MTU) {
+ OSM_LOG(p_log, OSM_LOG_VERBOSE,
+ "Calculated MTU %x is out of range\n", mtu);
+ return FALSE;
+ }
+ }
+ p_mcm_rec->mtu = (mtu_sel << 6) | mtu;
+
+ if (p_physp) {
+ extended = p_pi->capability_mask & IB_PORT_CAP_HAS_EXT_SPEEDS;
+ port_rate = ib_port_info_compute_rate(p_pi, extended);
+ } else
+ port_rate = 0;
+
+ if (!(comp_mask & IB_MCR_COMPMASK_RATE)
+ || !(comp_mask & IB_MCR_COMPMASK_RATE_SEL)
+ || (rate_sel = (p_mcm_rec->rate >> 6)) == 3)
+ rate = port_rate ? port_rate : sa->p_subn->min_ca_rate;
+ else {
+ rate_required = (uint8_t) (p_mcm_rec->rate & 0x3F);
+ rate = rate_required;
+ switch (rate_sel) {
+ case 0: /* Greater than RATE specified */
+ if (ib_path_compare_rates(rate_required, port_rate) >= 0) {
+ OSM_LOG(p_log, OSM_LOG_VERBOSE,
+ "Requested RATE %x >= the port\'s rate:%x\n",
+ rate_required, port_rate);
+ return FALSE;
+ }
+ /* we provide the largest RATE possible if we can */
+ if (port_rate)
+ rate = port_rate;
+ else if (ib_path_compare_rates(rate_required,
+ sa->p_subn->min_ca_rate) < 0)
+ rate = sa->p_subn->min_ca_rate;
+ else
+ rate = ib_path_rate_get_next(rate);
+ break;
+ case 1: /* Less than RATE specified */
+ /* use the smaller of the two:
+ a. one lower then the required
+ b. the rate of the requesting port (if exists) */
+ if (ib_path_compare_rates(rate_required, port_rate) > 0)
+ rate = port_rate;
+ else
+ rate = ib_path_rate_get_prev(rate);
+ break;
+ case 2: /* Exactly RATE specified */
+ default:
+ break;
+ }
+ /* make sure it still is in the range */
+ if (rate < IB_MIN_RATE || rate > IB_MAX_RATE) {
+ OSM_LOG(p_log, OSM_LOG_VERBOSE,
+ "Calculated RATE %x is out of range\n", rate);
+ return FALSE;
+ }
+ }
+ p_mcm_rec->rate = (rate_sel << 6) | rate;
+
+ OSM_LOG_EXIT(sa->p_log);
+ return TRUE;
+}
+
+static unsigned build_new_mgid(osm_sa_t * sa, ib_net64_t comp_mask,
+ ib_member_rec_t * mcmr)
+{
+ static uint32_t uniq_count;
+ ib_gid_t *mgid = &mcmr->mgid;
+ uint8_t scope;
+ unsigned i;
+
+ /* use the given scope state only if requested! */
+ if (comp_mask & IB_MCR_COMPMASK_SCOPE)
+ ib_member_get_scope_state(mcmr->scope_state, &scope, NULL);
+ else
+ /* to guarantee no collision with other subnets use local scope! */
+ scope = IB_MC_SCOPE_LINK_LOCAL;
+
+ mgid->raw[0] = 0xff;
+ mgid->raw[1] = 0x10 | scope;
+ mgid->raw[2] = 0xa0;
+ mgid->raw[3] = 0x1b;
+
+ memcpy(&mgid->raw[4], &sa->p_subn->opt.subnet_prefix, sizeof(uint64_t));
+
+ for (i = 0; i < 1000; i++) {
+ memcpy(&mgid->raw[10], &uniq_count, 4);
+ uniq_count++;
+ if (!osm_get_mgrp_by_mgid(sa->p_subn, mgid))
+ return 1;
+ }
+
+ return 0;
+}
+
+/**********************************************************************
+ Call this function to create a new mgrp.
+**********************************************************************/
+static ib_api_status_t mcmr_rcv_create_new_mgrp(IN osm_sa_t * sa,
+ IN ib_net64_t comp_mask,
+ IN const ib_member_rec_t * p_recvd_mcmember_rec,
+ IN const osm_physp_t * p_physp,
+ OUT osm_mgrp_t ** pp_mgrp)
+{
+ ib_net16_t mlid;
+ uint16_t signature;
+ ib_api_status_t status = IB_SUCCESS;
+ osm_mgrp_t *bcast_mgrp;
+ ib_gid_t bcast_mgid;
+ ib_member_rec_t mcm_rec = *p_recvd_mcmember_rec; /* copy for modifications */
+ char gid_str[INET6_ADDRSTRLEN];
+
+ OSM_LOG_ENTER(sa->p_log);
+
+ /* we need to create the new MGID if it was not defined */
+ if (!ib_gid_is_notzero(&p_recvd_mcmember_rec->mgid)) {
+ /* create a new MGID */
+ if (!build_new_mgid(sa, comp_mask, &mcm_rec)) {
+ OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 1B23: "
+ "cannot allocate unique MGID value\n");
+ status = IB_SA_MAD_STATUS_NO_RESOURCES;
+ goto Exit;
+ }
+ OSM_LOG(sa->p_log, OSM_LOG_DEBUG, "Allocated new MGID:%s\n",
+ inet_ntop(AF_INET6, mcm_rec.mgid.raw, gid_str,
+ sizeof gid_str));
+ } else if (sa->p_subn->opt.ipoib_mcgroup_creation_validation) {
+ /* a specific MGID was requested so validate the resulting MGID */
+ if (validate_requested_mgid(sa, &mcm_rec)) {
+ memcpy(&signature, &(mcm_rec.mgid.multicast.raw_group_id),
+ sizeof(signature));
+ signature = cl_ntoh16(signature);
+ /* Check for IPoIB signature in MGID */
+ if (signature == 0x401B || signature == 0x601B) {
+ /* Derive IPoIB broadcast MGID */
+ bcast_mgid.unicast.prefix = IPV4_BCAST_MGID_PREFIX;
+ bcast_mgid.unicast.interface_id = IPV4_BCAST_MGID_INT_ID;
+ /* Set scope in IPoIB broadcast MGID */
+ bcast_mgid.multicast.header[1] =
+ (bcast_mgid.multicast.header[1] & 0xF0) |
+ (mcm_rec.mgid.multicast.header[1] & 0x0F);
+ /* Set P_Key in IPoIB broadcast MGID */
+ bcast_mgid.multicast.raw_group_id[2] =
+ mcm_rec.mgid.multicast.raw_group_id[2];
+ bcast_mgid.multicast.raw_group_id[3] =
+ mcm_rec.mgid.multicast.raw_group_id[3];
+ /* Check MC group for the IPoIB broadcast group */
+ if (signature != 0x401B ||
+ memcmp(&bcast_mgid, &(mcm_rec.mgid), sizeof(ib_gid_t))) {
+ bcast_mgrp = osm_get_mgrp_by_mgid(sa->p_subn,
+ &bcast_mgid);
+ if (!bcast_mgrp) {
+ OSM_LOG(sa->p_log, OSM_LOG_ERROR,
+ "ERR 1B1B: Broadcast group %s not found, sending IB_SA_MAD_STATUS_REQ_INVALID\n",
+ inet_ntop(AF_INET6, bcast_mgid.raw, gid_str, sizeof gid_str));
+ status = IB_SA_MAD_STATUS_REQ_INVALID;
+ goto Exit;
+ }
+ if (!validate_other_comp_fields(sa->p_log, comp_mask, p_recvd_mcmember_rec, bcast_mgrp, OSM_LOG_ERROR)) {
+ OSM_LOG(sa->p_log, OSM_LOG_ERROR,
+ "ERR 1B1C: validate_other_comp_fields failed for MGID: %s, sending IB_SA_MAD_STATUS_REQ_INVALID\n",
+ inet_ntop(AF_INET6, &p_recvd_mcmember_rec->mgid, gid_str, sizeof gid_str));
+ status = IB_SA_MAD_STATUS_REQ_INVALID;
+ goto Exit;
+ }
+ }
+ }
+ } else {
+ status = IB_SA_MAD_STATUS_REQ_INVALID;
+ goto Exit;
+ }
+ }
+
+ /* check the requested parameters are realizable */
+ if (mgrp_request_is_realizable(sa, comp_mask, &mcm_rec, p_physp) ==
+ FALSE) {
+ OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 1B26: "
+ "Requested MGRP parameters are not realizable\n");
+ status = IB_SA_MAD_STATUS_REQ_INVALID;
+ goto Exit;
+ }
+
+ mlid = get_new_mlid(sa, &mcm_rec);
+ if (mlid == 0) {
+ OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 1B19: "
+ "get_new_mlid failed request mlid 0x%04x\n",
+ cl_ntoh16(mcm_rec.mlid));
+ status = IB_SA_MAD_STATUS_NO_RESOURCES;
+ goto Exit;
+ }
+
+ OSM_LOG(sa->p_log, OSM_LOG_DEBUG, "Obtained new mlid 0x%X\n",
+ cl_ntoh16(mlid));
+
+ mcm_rec.mlid = mlid;
+ /* create a new MC Group */
+ *pp_mgrp = osm_mgrp_new(sa->p_subn, mlid, &mcm_rec);
+ if (*pp_mgrp == NULL) {
+ OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 1B08: "
+ "osm_mgrp_new failed\n");
+ free_mlid(sa, mlid);
+ status = IB_SA_MAD_STATUS_NO_RESOURCES;
+ goto Exit;
+ }
+
+ /* the mcmember_record should have mtu_sel, rate_sel, and pkt_lifetime_sel = 2 */
+ (*pp_mgrp)->mcmember_rec.mtu &= 0x3f;
+ (*pp_mgrp)->mcmember_rec.mtu |= IB_PATH_SELECTOR_EXACTLY << 6;
+ (*pp_mgrp)->mcmember_rec.rate &= 0x3f;
+ (*pp_mgrp)->mcmember_rec.rate |= IB_PATH_SELECTOR_EXACTLY << 6;
+ (*pp_mgrp)->mcmember_rec.pkt_life &= 0x3f;
+ (*pp_mgrp)->mcmember_rec.pkt_life |= IB_PATH_SELECTOR_EXACTLY << 6;
+
+Exit:
+ OSM_LOG_EXIT(sa->p_log);
+ return status;
+}
+
+/**********************************************************************
+ Call this function to find or create a new mgrp.
+**********************************************************************/
+osm_mgrp_t *osm_mcmr_rcv_find_or_create_new_mgrp(IN osm_sa_t * sa,
+ IN ib_net64_t comp_mask,
+ IN ib_member_rec_t *
+ p_recvd_mcmember_rec)
+{
+ osm_mgrp_t *mgrp;
+
+ if ((mgrp = osm_get_mgrp_by_mgid(sa->p_subn,
+ &p_recvd_mcmember_rec->mgid)))
+ return mgrp;
+ if (mcmr_rcv_create_new_mgrp(sa, comp_mask, p_recvd_mcmember_rec, NULL,
+ &mgrp) == IB_SUCCESS)
+ return mgrp;
+ return NULL;
+}
+
+/*********************************************************************
+Process a request for leaving the group
+**********************************************************************/
+static void mcmr_rcv_leave_mgrp(IN osm_sa_t * sa, IN osm_madw_t * p_madw)
+{
+ osm_mgrp_t *p_mgrp;
+ ib_sa_mad_t *p_sa_mad;
+ ib_member_rec_t *p_recvd_mcmember_rec;
+ ib_member_rec_t mcmember_rec;
+ osm_mcm_alias_guid_t *p_mcm_alias_guid;
+
+ OSM_LOG_ENTER(sa->p_log);
+
+ p_sa_mad = osm_madw_get_sa_mad_ptr(p_madw);
+ p_recvd_mcmember_rec =
+ (ib_member_rec_t *) ib_sa_mad_get_payload_ptr(p_sa_mad);
+
+ mcmember_rec = *p_recvd_mcmember_rec;
+
+ /* Validate the subnet prefix in the PortGID */
+ if (p_recvd_mcmember_rec->port_gid.unicast.prefix !=
+ sa->p_subn->opt.subnet_prefix) {
+ OSM_LOG(sa->p_log, OSM_LOG_DEBUG,
+ "PortGID subnet prefix 0x%" PRIx64
+ " does not match configured prefix 0x%" PRIx64 "\n",
+ cl_ntoh64(p_recvd_mcmember_rec->port_gid.unicast.prefix),
+ cl_ntoh64(sa->p_subn->opt.subnet_prefix));
+ osm_sa_send_error(sa, p_madw, IB_SA_MAD_STATUS_INVALID_GID);
+ goto Exit;
+ }
+
+ CL_PLOCK_EXCL_ACQUIRE(sa->p_lock);
+
+ if (OSM_LOG_IS_ACTIVE_V2(sa->p_log, OSM_LOG_DEBUG)) {
+ osm_physp_t *p_req_physp;
+
+ p_req_physp = osm_get_physp_by_mad_addr(sa->p_log, sa->p_subn,
+ osm_madw_get_mad_addr_ptr(p_madw));
+ if (p_req_physp == NULL) {
+ OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 1B02: "
+ "Cannot find requester physical port\n");
+ } else {
+ OSM_LOG(sa->p_log, OSM_LOG_DEBUG,
+ "Requester port GUID 0x%" PRIx64 "\n",
+ cl_ntoh64(osm_physp_get_port_guid(p_req_physp)));
+ }
+ OSM_LOG(sa->p_log, OSM_LOG_DEBUG, "Dump of record\n");
+ osm_dump_mc_record_v2(sa->p_log, &mcmember_rec, FILE_ID, OSM_LOG_DEBUG);
+ }
+
+ p_mgrp = osm_get_mgrp_by_mgid(sa->p_subn, &p_recvd_mcmember_rec->mgid);
+ if (!p_mgrp) {
+ char gid_str[INET6_ADDRSTRLEN];
+ CL_PLOCK_RELEASE(sa->p_lock);
+ OSM_LOG(sa->p_log, OSM_LOG_DEBUG,
+ "Failed since multicast group %s not present\n",
+ inet_ntop(AF_INET6, p_recvd_mcmember_rec->mgid.raw,
+ gid_str, sizeof gid_str));
+ osm_sa_send_error(sa, p_madw, IB_SA_MAD_STATUS_REQ_INVALID);
+ goto Exit;
+ }
+
+ /* check validity of the delete request o15-0.1.14 */
+ if (!validate_delete(sa, p_mgrp, osm_madw_get_mad_addr_ptr(p_madw),
+ p_recvd_mcmember_rec, &p_mcm_alias_guid)) {
+ char gid_str[INET6_ADDRSTRLEN];
+ char gid_str2[INET6_ADDRSTRLEN];
+ CL_PLOCK_RELEASE(sa->p_lock);
+ OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 1B25: "
+ "Received an invalid delete request for "
+ "MGID: %s for PortGID: %s\n",
+ inet_ntop(AF_INET6, p_recvd_mcmember_rec->mgid.raw,
+ gid_str, sizeof gid_str),
+ inet_ntop(AF_INET6, p_recvd_mcmember_rec->port_gid.raw,
+ gid_str2, sizeof gid_str2));
+ osm_sa_send_error(sa, p_madw, IB_SA_MAD_STATUS_REQ_INVALID);
+ goto Exit;
+ }
+
+ /* remove port and/or update join state */
+ osm_mgrp_remove_port(sa->p_subn, sa->p_log, p_mgrp, p_mcm_alias_guid,
+ &mcmember_rec);
+ CL_PLOCK_RELEASE(sa->p_lock);
+
+ mcmr_rcv_respond(sa, p_madw, &mcmember_rec);
+
+Exit:
+ OSM_LOG_EXIT(sa->p_log);
+}
+
+static int validate_other_comp_fields(osm_log_t * p_log, ib_net64_t comp_mask,
+ const ib_member_rec_t * p_mcmr,
+ osm_mgrp_t * p_mgrp,
+ osm_log_level_t log_level)
+{
+ int ret = 0;
+
+ if ((IB_MCR_COMPMASK_QKEY & comp_mask) &&
+ p_mcmr->qkey != p_mgrp->mcmember_rec.qkey) {
+ OSM_LOG(p_log, log_level, "ERR 1B30: "
+ "Q_Key mismatch: query 0x%x group 0x%x\n",
+ cl_ntoh32(p_mcmr->qkey),
+ cl_ntoh32(p_mgrp->mcmember_rec.qkey));
+ goto Exit;
+ }
+
+ if (IB_MCR_COMPMASK_PKEY & comp_mask) {
+ if (!(ib_pkey_is_full_member(p_mcmr->pkey) ||
+ ib_pkey_is_full_member(p_mgrp->mcmember_rec.pkey))) {
+ OSM_LOG(p_log, log_level, "ERR 1B31: "
+ "Both limited P_Keys: query 0x%x group 0x%x\n",
+ cl_ntoh16(p_mcmr->pkey),
+ cl_ntoh16(p_mgrp->mcmember_rec.pkey));
+ goto Exit;
+ }
+ if (ib_pkey_get_base(p_mcmr->pkey) !=
+ ib_pkey_get_base(p_mgrp->mcmember_rec.pkey)) {
+ OSM_LOG(p_log, log_level, "ERR 1B32: "
+ "P_Key base mismatch: query 0x%x group 0x%x\n",
+ cl_ntoh16(p_mcmr->pkey),
+ cl_ntoh16(p_mgrp->mcmember_rec.pkey));
+ goto Exit;
+ }
+ }
+
+ if ((IB_MCR_COMPMASK_TCLASS & comp_mask) &&
+ p_mcmr->tclass != p_mgrp->mcmember_rec.tclass) {
+ OSM_LOG(p_log, log_level, "ERR 1B33: "
+ "TClass mismatch: query %d group %d\n",
+ p_mcmr->tclass, p_mgrp->mcmember_rec.tclass);
+ goto Exit;
+ }
+
+ /* check SL, Flow, and Hop limit */
+ {
+ uint32_t mgrp_flow, query_flow;
+ uint8_t mgrp_sl, query_sl;
+ uint8_t mgrp_hop, query_hop;
+
+ ib_member_get_sl_flow_hop(p_mcmr->sl_flow_hop,
+ &query_sl, &query_flow, &query_hop);
+
+ ib_member_get_sl_flow_hop(p_mgrp->mcmember_rec.sl_flow_hop,
+ &mgrp_sl, &mgrp_flow, &mgrp_hop);
+
+ if ((IB_MCR_COMPMASK_SL & comp_mask) && query_sl != mgrp_sl) {
+ OSM_LOG(p_log, log_level, "ERR 1B34: "
+ "SL mismatch: query %d group %d\n",
+ query_sl, mgrp_sl);
+ goto Exit;
+ }
+
+ if ((IB_MCR_COMPMASK_FLOW & comp_mask) &&
+ query_flow != mgrp_flow) {
+ OSM_LOG(p_log, log_level, "ERR 1B35: "
+ "FlowLabel mismatch: query 0x%x group 0x%x\n",
+ query_flow, mgrp_flow);
+ goto Exit;
+ }
+
+ if ((IB_MCR_COMPMASK_HOP & comp_mask) && query_hop != mgrp_hop) {
+ OSM_LOG(p_log, log_level, "ERR 1B36: "
+ "Hop mismatch: query %d group %d\n",
+ query_hop, mgrp_hop);
+ goto Exit;
+ }
+ }
+
+ ret = 1;
+Exit:
+ return ret;
+}
+
+/**********************************************************************
+ Handle a join (or create) request
+**********************************************************************/
+static void mcmr_rcv_join_mgrp(IN osm_sa_t * sa, IN osm_madw_t * p_madw)
+{
+ osm_mgrp_t *p_mgrp = NULL;
+ ib_api_status_t status;
+ ib_sa_mad_t *p_sa_mad;
+ ib_member_rec_t *p_recvd_mcmember_rec;
+ ib_member_rec_t mcmember_rec;
+ osm_mcm_port_t *p_mcmr_port;
+ osm_mcm_alias_guid_t *p_mcm_alias_guid;
+ ib_net64_t portguid;
+ osm_port_t *p_port;
+ osm_physp_t *p_physp;
+ osm_physp_t *p_request_physp;
+ uint8_t is_new_group; /* TRUE = there is a need to create a group */
+ uint8_t join_state;
+ boolean_t proxy;
+
+ OSM_LOG_ENTER(sa->p_log);
+
+ p_sa_mad = osm_madw_get_sa_mad_ptr(p_madw);
+ p_recvd_mcmember_rec = ib_sa_mad_get_payload_ptr(p_sa_mad);
+
+ portguid = p_recvd_mcmember_rec->port_gid.unicast.interface_id;
+
+ mcmember_rec = *p_recvd_mcmember_rec;
+
+ /* Validate the subnet prefix in the PortGID */
+ if (p_recvd_mcmember_rec->port_gid.unicast.prefix !=
+ sa->p_subn->opt.subnet_prefix) {
+ OSM_LOG(sa->p_log, OSM_LOG_DEBUG,
+ "PortGID subnet prefix 0x%" PRIx64
+ " does not match configured prefix 0x%" PRIx64 "\n",
+ cl_ntoh64(p_recvd_mcmember_rec->port_gid.unicast.prefix),
+ cl_ntoh64(sa->p_subn->opt.subnet_prefix));
+ osm_sa_send_error(sa, p_madw, IB_SA_MAD_STATUS_INVALID_GID);
+ goto Exit;
+ }
+
+ CL_PLOCK_EXCL_ACQUIRE(sa->p_lock);
+
+ if (OSM_LOG_IS_ACTIVE_V2(sa->p_log, OSM_LOG_DEBUG)) {
+ osm_physp_t *p_req_physp;
+
+ p_req_physp = osm_get_physp_by_mad_addr(sa->p_log, sa->p_subn,
+ osm_madw_get_mad_addr_ptr(p_madw));
+ if (p_req_physp == NULL) {
+ OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 1B03: "
+ "Cannot find requester physical port\n");
+ } else {
+ OSM_LOG(sa->p_log, OSM_LOG_DEBUG,
+ "Requester port GUID 0x%" PRIx64 "\n",
+ cl_ntoh64(osm_physp_get_port_guid(p_req_physp)));
+ }
+ OSM_LOG(sa->p_log, OSM_LOG_DEBUG, "Dump of incoming record\n");
+ osm_dump_mc_record_v2(sa->p_log, &mcmember_rec, FILE_ID, OSM_LOG_DEBUG);
+ }
+
+ /* make sure the requested port guid is known to the SM */
+ p_port = osm_get_port_by_alias_guid(sa->p_subn, portguid);
+ if (!p_port) {
+ CL_PLOCK_RELEASE(sa->p_lock);
+ OSM_LOG(sa->p_log, OSM_LOG_DEBUG,
+ "Unknown port GUID 0x%016" PRIx64 "\n",
+ cl_ntoh64(portguid));
+ osm_sa_send_error(sa, p_madw, IB_SA_MAD_STATUS_REQ_INVALID);
+ goto Exit;
+ }
+
+ p_physp = p_port->p_physp;
+ /* Check that the p_physp and the requester physp are in the same
+ partition. */
+ p_request_physp =
+ osm_get_physp_by_mad_addr(sa->p_log, sa->p_subn,
+ osm_madw_get_mad_addr_ptr(p_madw));
+ if (p_request_physp == NULL) {
+ CL_PLOCK_RELEASE(sa->p_lock);
+ goto Exit;
+ }
+
+ proxy = (p_physp != p_request_physp);
+
+ if (proxy && !osm_physp_share_pkey(sa->p_log, p_physp, p_request_physp,
+ sa->p_subn->opt.allow_both_pkeys)) {
+ CL_PLOCK_RELEASE(sa->p_lock);
+ OSM_LOG(sa->p_log, OSM_LOG_VERBOSE,
+ "Port and requester don't share PKey\n");
+ osm_sa_send_error(sa, p_madw, IB_SA_MAD_STATUS_REQ_INVALID);
+ goto Exit;
+ }
+
+ if ((p_sa_mad->comp_mask & IB_MCR_COMPMASK_PKEY) &&
+ ib_pkey_is_invalid(p_recvd_mcmember_rec->pkey)) {
+ CL_PLOCK_RELEASE(sa->p_lock);
+ OSM_LOG(sa->p_log, OSM_LOG_VERBOSE,
+ "Invalid PKey supplied in request\n");
+ osm_sa_send_error(sa, p_madw, IB_SA_MAD_STATUS_REQ_INVALID);
+ goto Exit;
+ }
+
+ ib_member_get_scope_state(p_recvd_mcmember_rec->scope_state, NULL,
+ &join_state);
+
+ /* do we need to create a new group? */
+ p_mgrp = osm_get_mgrp_by_mgid(sa->p_subn, &p_recvd_mcmember_rec->mgid);
+ if (!p_mgrp) {
+ /* check for JoinState.FullMember = 1 o15.0.1.9 */
+ if ((join_state & 0x01) != 0x01) {
+ char gid_str[INET6_ADDRSTRLEN];
+ CL_PLOCK_RELEASE(sa->p_lock);
+ OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 1B10: "
+ "Failed to create multicast group "
+ "because Join State != FullMember, "
+ "MGID: %s from port 0x%016" PRIx64 " (%s)\n",
+ inet_ntop(AF_INET6,
+ p_recvd_mcmember_rec->mgid.raw,
+ gid_str, sizeof gid_str),
+ cl_ntoh64(portguid),
+ p_port->p_node->print_desc);
+ osm_sa_send_error(sa, p_madw,
+ IB_SA_MAD_STATUS_REQ_INVALID);
+ goto Exit;
+ }
+
+ /* check the comp_mask */
+ if (!check_create_comp_mask(p_sa_mad->comp_mask,
+ p_recvd_mcmember_rec)) {
+ char gid_str[INET6_ADDRSTRLEN];
+ CL_PLOCK_RELEASE(sa->p_lock);
+ OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 1B11: "
+ "Port 0x%016" PRIx64 " (%s) failed to join "
+ "non-existing multicast group with MGID %s, "
+ "insufficient components specified for "
+ "implicit create (comp_mask 0x%" PRIx64 ")\n",
+ cl_ntoh64(portguid), p_port->p_node->print_desc,
+ inet_ntop(AF_INET6,
+ p_recvd_mcmember_rec->mgid.raw,
+ gid_str, sizeof gid_str),
+ cl_ntoh64(p_sa_mad->comp_mask));
+ osm_sa_send_error(sa, p_madw,
+ IB_SA_MAD_STATUS_INSUF_COMPS);
+ goto Exit;
+ }
+
+ status = mcmr_rcv_create_new_mgrp(sa, p_sa_mad->comp_mask,
+ p_recvd_mcmember_rec,
+ p_physp, &p_mgrp);
+ if (status != IB_SUCCESS) {
+ CL_PLOCK_RELEASE(sa->p_lock);
+ osm_sa_send_error(sa, p_madw, status);
+ goto Exit;
+ }
+ /* copy the MGID to the result */
+ mcmember_rec.mgid = p_mgrp->mcmember_rec.mgid;
+ is_new_group = 1;
+ } else {
+ /* no need for a new group */
+ is_new_group = 0;
+ if (sa->p_subn->opt.mcgroup_join_validation &&
+ !validate_other_comp_fields(sa->p_log, p_sa_mad->comp_mask,
+ p_recvd_mcmember_rec, p_mgrp,
+ OSM_LOG_ERROR)) {
+ char gid_str[INET6_ADDRSTRLEN];
+ CL_PLOCK_RELEASE(sa->p_lock);
+ OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 1B1A: "
+ "validate_other_comp_fields failed for "
+ "MGID: %s port 0x%016" PRIx64
+ " (%s), sending IB_SA_MAD_STATUS_REQ_INVALID\n",
+ inet_ntop(AF_INET6,
+ p_mgrp->mcmember_rec.mgid.raw,
+ gid_str, sizeof gid_str),
+ cl_ntoh64(portguid),
+ p_port->p_node->print_desc);
+ osm_sa_send_error(sa, p_madw,
+ IB_SA_MAD_STATUS_REQ_INVALID);
+ goto Exit;
+ }
+ }
+
+ CL_ASSERT(p_mgrp);
+
+ /*
+ * o15-0.2.4: If SA supports UD multicast, then SA shall cause an
+ * endport to join an existing multicast group if:
+ * 1. It receives a SubnAdmSet() method for a MCMemberRecord, and
+ * - WE KNOW THAT ALREADY
+ * 2. The MGID is specified and matches an existing multicast
+ * group, and
+ * - WE KNOW THAT ALREADY
+ * 3. The MCMemberRecord:JoinState is not all 0s, and
+ * 4. PortGID is specified and
+ * - WE KNOW THAT ALREADY (as it matched a real one)
+ * 5. All other components match that existing group, either by
+ * being wildcarded or by having values identical to those specified
+ * by the component mask and in use by the group with the exception
+ * of components such as ProxyJoin and Reserved, which are ignored
+ * by SA.
+ *
+ * We need to check #3 and #5 here:
+ */
+ if (!validate_more_comp_fields(sa->p_log, p_mgrp, p_recvd_mcmember_rec,
+ p_sa_mad->comp_mask)
+ || !validate_port_caps(sa->p_log, p_mgrp, p_physp)
+ || !(join_state != 0)) {
+ char gid_str[INET6_ADDRSTRLEN];
+ /* since we might have created the new group we need to cleanup */
+ if (is_new_group)
+ osm_mgrp_cleanup(sa->p_subn, p_mgrp);
+ CL_PLOCK_RELEASE(sa->p_lock);
+ OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 1B12: "
+ "validate_more_comp_fields, validate_port_caps, "
+ "or JoinState = 0 failed for MGID: %s port 0x%016" PRIx64
+ " (%s), sending IB_SA_MAD_STATUS_REQ_INVALID\n",
+ inet_ntop(AF_INET6, p_mgrp->mcmember_rec.mgid.raw,
+ gid_str, sizeof gid_str),
+ cl_ntoh64(portguid), p_port->p_node->print_desc);
+ osm_sa_send_error(sa, p_madw, IB_SA_MAD_STATUS_REQ_INVALID);
+ goto Exit;
+ }
+
+ /* verify that the joining port is in the partition of the group */
+ if (!osm_physp_has_pkey(sa->p_log, p_mgrp->mcmember_rec.pkey, p_physp)) {
+ char gid_str[INET6_ADDRSTRLEN];
+ if (is_new_group)
+ osm_mgrp_cleanup(sa->p_subn, p_mgrp);
+ CL_PLOCK_RELEASE(sa->p_lock);
+ memset(gid_str, 0, sizeof(gid_str));
+ OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 1B14: "
+ "Cannot join port 0x%016" PRIx64 " to MGID %s - "
+ "Port is not in partition of this MC group\n",
+ cl_ntoh64(portguid),
+ inet_ntop(AF_INET6,
+ p_mgrp->mcmember_rec.mgid.raw,
+ gid_str, sizeof(gid_str)));
+ osm_sa_send_error(sa, p_madw, IB_SA_MAD_STATUS_REQ_INVALID);
+ goto Exit;
+ }
+
+ /*
+ * o15-0.2.1 requires validation of the requesting port
+ * in the case of modification:
+ */
+ if (!is_new_group &&
+ !validate_modify(sa, p_mgrp, osm_madw_get_mad_addr_ptr(p_madw),
+ p_recvd_mcmember_rec, &p_mcm_alias_guid)) {
+ char gid_str[INET6_ADDRSTRLEN];
+ CL_PLOCK_RELEASE(sa->p_lock);
+ OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 1B13: "
+ "validate_modify failed from port 0x%016" PRIx64
+ " (%s) for MGID: %s, sending IB_SA_MAD_STATUS_REQ_INVALID\n",
+ cl_ntoh64(portguid), p_port->p_node->print_desc,
+ inet_ntop(AF_INET6,
+ p_mgrp->mcmember_rec.mgid.raw,
+ gid_str, sizeof(gid_str)));
+ osm_sa_send_error(sa, p_madw, IB_SA_MAD_STATUS_REQ_INVALID);
+ goto Exit;
+ }
+
+ /* copy qkey mlid tclass pkey sl_flow_hop mtu rate pkt_life */
+ copy_from_create_mc_rec(&mcmember_rec, &p_mgrp->mcmember_rec);
+
+ /* create or update existing port (join-state will be updated) */
+ p_mcmr_port = osm_mgrp_add_port(sa->p_subn, sa->p_log, p_mgrp, p_port,
+ &mcmember_rec, proxy);
+ if (!p_mcmr_port) {
+ /* we fail to add the port so we might need to delete the group */
+ if (is_new_group)
+ osm_mgrp_cleanup(sa->p_subn, p_mgrp);
+ CL_PLOCK_RELEASE(sa->p_lock);
+ OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 1B06: "
+ "osm_mgrp_add_port failed\n");
+ osm_sa_send_error(sa, p_madw, IB_SA_MAD_STATUS_NO_RESOURCES);
+ goto Exit;
+ }
+
+ /* Release the lock as we don't need it. */
+ CL_PLOCK_RELEASE(sa->p_lock);
+
+ if (OSM_LOG_IS_ACTIVE_V2(sa->p_log, OSM_LOG_DEBUG))
+ osm_dump_mc_record_v2(sa->p_log, &mcmember_rec, FILE_ID, OSM_LOG_DEBUG);
+
+ mcmr_rcv_respond(sa, p_madw, &mcmember_rec);
+
+Exit:
+ OSM_LOG_EXIT(sa->p_log);
+}
+
+/**********************************************************************
+ Add a patched multicast group to the results list
+**********************************************************************/
+static ib_api_status_t mcmr_rcv_new_mcmr(IN osm_sa_t * sa,
+ IN const ib_member_rec_t * p_rcvd_rec,
+ IN cl_qlist_t * p_list)
+{
+ osm_sa_item_t *p_rec_item;
+ ib_api_status_t status = IB_SUCCESS;
+
+ OSM_LOG_ENTER(sa->p_log);
+
+ p_rec_item = malloc(SA_MCM_RESP_SIZE);
+ if (p_rec_item == NULL) {
+ OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 1B15: "
+ "rec_item alloc failed\n");
+ status = IB_INSUFFICIENT_RESOURCES;
+ goto Exit;
+ }
+
+ memset(p_rec_item, 0, sizeof(cl_list_item_t));
+
+ /* HACK: Untrusted requesters should result with 0 Join
+ State, Port Guid, and Proxy */
+ p_rec_item->resp.mc_rec = *p_rcvd_rec;
+ cl_qlist_insert_tail(p_list, &p_rec_item->list_item);
+
+Exit:
+ OSM_LOG_EXIT(sa->p_log);
+ return status;
+}
+
+/**********************************************************************
+ Match the given mgrp to the requested mcmr
+**********************************************************************/
+static void mcmr_by_comp_mask(osm_sa_t * sa, const ib_member_rec_t * p_rcvd_rec,
+ ib_net64_t comp_mask, osm_mgrp_t * p_mgrp,
+ const osm_physp_t * p_req_physp,
+ boolean_t trusted_req, cl_qlist_t * list)
+{
+ /* since we might change scope_state */
+ ib_member_rec_t match_rec;
+ osm_mcm_alias_guid_t *p_mcm_alias_guid;
+ ib_net64_t portguid = p_rcvd_rec->port_gid.unicast.interface_id;
+ /* will be used for group or port info */
+ uint8_t scope_state;
+ uint8_t scope_state_mask = 0;
+ cl_map_item_t *p_item;
+ ib_gid_t port_gid;
+ boolean_t proxy_join = FALSE;
+
+ OSM_LOG_ENTER(sa->p_log);
+
+ OSM_LOG(sa->p_log, OSM_LOG_DEBUG,
+ "Checking mlid:0x%X\n", cl_ntoh16(p_mgrp->mlid));
+
+ /* first try to eliminate the group by MGID, MLID, or P_Key */
+ if ((IB_MCR_COMPMASK_MGID & comp_mask) &&
+ memcmp(&p_rcvd_rec->mgid, &p_mgrp->mcmember_rec.mgid,
+ sizeof(ib_gid_t)))
+ goto Exit;
+
+ if ((IB_MCR_COMPMASK_MLID & comp_mask) &&
+ memcmp(&p_rcvd_rec->mlid, &p_mgrp->mcmember_rec.mlid,
+ sizeof(uint16_t)))
+ goto Exit;
+
+ /* if the requester physical port doesn't have the pkey that is defined
+ for the group - exit. */
+ if (!osm_physp_has_pkey(sa->p_log, p_mgrp->mcmember_rec.pkey,
+ p_req_physp))
+ goto Exit;
+
+ /* now do the rest of the match */
+ if (!validate_other_comp_fields(sa->p_log, comp_mask, p_rcvd_rec, p_mgrp,
+ OSM_LOG_NONE))
+ goto Exit;
+
+ if ((IB_MCR_COMPMASK_PROXY & comp_mask) &&
+ p_rcvd_rec->proxy_join != p_mgrp->mcmember_rec.proxy_join)
+ goto Exit;
+
+ /* need to validate mtu, rate, and pkt_lifetime fields */
+ if (validate_more_comp_fields(sa->p_log, p_mgrp, p_rcvd_rec,
+ comp_mask) == FALSE)
+ goto Exit;
+
+ /* Port specific fields */
+ /* so did we get the PortGUID mask */
+ if (IB_MCR_COMPMASK_PORT_GID & comp_mask) {
+ /* try to find this port */
+ p_mcm_alias_guid = osm_mgrp_get_mcm_alias_guid(p_mgrp, portguid);
+ if (!p_mcm_alias_guid) /* port not in group */
+ goto Exit;
+ scope_state = p_mcm_alias_guid->scope_state;
+ memcpy(&port_gid, &(p_mcm_alias_guid->port_gid),
+ sizeof(ib_gid_t));
+ proxy_join = p_mcm_alias_guid->proxy_join;
+ } else /* point to the group information */
+ scope_state = p_mgrp->mcmember_rec.scope_state;
+
+ if (IB_MCR_COMPMASK_SCOPE & comp_mask)
+ scope_state_mask = 0xF0;
+
+ if (IB_MCR_COMPMASK_JOIN_STATE & comp_mask)
+ scope_state_mask = scope_state_mask | 0x0F;
+
+ /* Many MC records returned */
+ if (trusted_req == TRUE && !(IB_MCR_COMPMASK_PORT_GID & comp_mask)) {
+ char gid_str[INET6_ADDRSTRLEN];
+ OSM_LOG(sa->p_log, OSM_LOG_DEBUG,
+ "Trusted req is TRUE and no specific port defined\n");
+
+ /* return all the ports that match in this MC group */
+ p_item = cl_qmap_head(&(p_mgrp->mcm_alias_port_tbl));
+ while (p_item != cl_qmap_end(&(p_mgrp->mcm_alias_port_tbl))) {
+ p_mcm_alias_guid = (osm_mcm_alias_guid_t *) p_item;
+
+ if ((scope_state_mask & p_rcvd_rec->scope_state) ==
+ (scope_state_mask & p_mcm_alias_guid->scope_state)) {
+ /* add to the list */
+ match_rec = p_mgrp->mcmember_rec;
+ match_rec.scope_state = p_mcm_alias_guid->scope_state;
+ memcpy(&match_rec.port_gid,
+ &p_mcm_alias_guid->port_gid,
+ sizeof(ib_gid_t));
+ OSM_LOG(sa->p_log, OSM_LOG_DEBUG,
+ "Record of port_gid: %s"
+ " in multicast_lid: 0x%X is returned\n",
+ inet_ntop(AF_INET6,
+ match_rec.port_gid.raw,
+ gid_str, sizeof gid_str),
+ cl_ntoh16(p_mgrp->mlid));
+
+ match_rec.proxy_join =
+ (uint8_t) (p_mcm_alias_guid->proxy_join);
+
+ mcmr_rcv_new_mcmr(sa, &match_rec, list);
+ }
+ p_item = cl_qmap_next(p_item);
+ }
+ } else { /* One MC record returned */
+ if ((scope_state_mask & p_rcvd_rec->scope_state) !=
+ (scope_state_mask & scope_state))
+ goto Exit;
+
+ /* add to the list */
+ match_rec = p_mgrp->mcmember_rec;
+ match_rec.scope_state = scope_state;
+ memcpy(&(match_rec.port_gid), &port_gid, sizeof(ib_gid_t));
+ match_rec.proxy_join = (uint8_t) proxy_join;
+
+ mcmr_rcv_new_mcmr(sa, &match_rec, list);
+ }
+
+Exit:
+ OSM_LOG_EXIT(sa->p_log);
+}
+
+/**********************************************************************
+ Handle a query request
+**********************************************************************/
+static void mcmr_query_mgrp(IN osm_sa_t * sa, IN osm_madw_t * p_madw)
+{
+ const ib_sa_mad_t *p_rcvd_mad;
+ const ib_member_rec_t *p_rcvd_rec;
+ cl_qlist_t rec_list;
+ ib_net64_t comp_mask;
+ osm_physp_t *p_req_physp;
+ boolean_t trusted_req;
+ osm_mgrp_t *p_mgrp;
+
+ OSM_LOG_ENTER(sa->p_log);
+
+ p_rcvd_mad = osm_madw_get_sa_mad_ptr(p_madw);
+ p_rcvd_rec = (ib_member_rec_t *) ib_sa_mad_get_payload_ptr(p_rcvd_mad);
+ comp_mask = p_rcvd_mad->comp_mask;
+
+ /*
+ if sm_key is not zero and does not match we never get here
+ see main SA receiver
+ */
+ trusted_req = (p_rcvd_mad->sm_key != 0);
+
+ CL_PLOCK_ACQUIRE(sa->p_lock);
+
+ /* update the requester physical port */
+ p_req_physp = osm_get_physp_by_mad_addr(sa->p_log, sa->p_subn,
+ osm_madw_get_mad_addr_ptr
+ (p_madw));
+ if (p_req_physp == NULL) {
+ CL_PLOCK_RELEASE(sa->p_lock);
+ OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 1B04: "
+ "Cannot find requester physical port\n");
+ goto Exit;
+ }
+
+ if (OSM_LOG_IS_ACTIVE_V2(sa->p_log, OSM_LOG_DEBUG)) {
+ OSM_LOG(sa->p_log, OSM_LOG_DEBUG,
+ "Requester port GUID 0x%" PRIx64 "\n",
+ cl_ntoh64(osm_physp_get_port_guid(p_req_physp)));
+ OSM_LOG(sa->p_log, OSM_LOG_DEBUG, "Dump of record\n");
+ osm_dump_mc_record(sa->p_log, p_rcvd_rec, OSM_LOG_DEBUG);
+ }
+
+ cl_qlist_init(&rec_list);
+
+ /* simply go over all MCGs and match */
+ for (p_mgrp = (osm_mgrp_t *) cl_fmap_head(&sa->p_subn->mgrp_mgid_tbl);
+ p_mgrp != (osm_mgrp_t *) cl_fmap_end(&sa->p_subn->mgrp_mgid_tbl);
+ p_mgrp = (osm_mgrp_t *) cl_fmap_next(&p_mgrp->map_item))
+ mcmr_by_comp_mask(sa, p_rcvd_rec, comp_mask, p_mgrp,
+ p_req_physp, trusted_req, &rec_list);
+
+ CL_PLOCK_RELEASE(sa->p_lock);
+
+ /*
+ p923 - The PortGID, JoinState and ProxyJoin shall be zero,
+ except in the case of a trusted request.
+ Note: In the mad controller we check that the SM_Key received on
+ the mad is valid. Meaning - is either zero or equal to the local
+ sm_key.
+ */
+
+ if (!p_rcvd_mad->sm_key) {
+ osm_sa_item_t *item;
+ for (item = (osm_sa_item_t *) cl_qlist_head(&rec_list);
+ item != (osm_sa_item_t *) cl_qlist_end(&rec_list);
+ item =
+ (osm_sa_item_t *) cl_qlist_next(&item->list_item)) {
+ memset(&item->resp.mc_rec.port_gid, 0, sizeof(ib_gid_t));
+ ib_member_set_join_state(&item->resp.mc_rec, 0);
+ item->resp.mc_rec.proxy_join = 0;
+ }
+ }
+
+ osm_sa_respond(sa, p_madw, sizeof(ib_member_rec_t), &rec_list);
+
+Exit:
+ OSM_LOG_EXIT(sa->p_log);
+}
+
+static uint8_t rate_is_valid(IN const ib_sa_mad_t *p_sa_mad,
+ IN const ib_member_rec_t *p_recvd_mcmember_rec)
+{
+ uint8_t rate;
+
+ /* Validate rate if supplied */
+ if ((p_sa_mad->comp_mask & IB_MCR_COMPMASK_RATE_SEL) &&
+ (p_sa_mad->comp_mask & IB_MCR_COMPMASK_RATE)) {
+ rate = (uint8_t) (p_recvd_mcmember_rec->rate & 0x3F);
+ return ib_rate_is_valid(rate);
+ }
+ return 1;
+}
+
+static int mtu_is_valid(IN const ib_sa_mad_t *p_sa_mad,
+ IN const ib_member_rec_t *p_recvd_mcmember_rec)
+{
+ uint8_t mtu;
+
+ /* Validate MTU if supplied */
+ if ((p_sa_mad->comp_mask & IB_MCR_COMPMASK_MTU_SEL) &&
+ (p_sa_mad->comp_mask & IB_MCR_COMPMASK_MTU)) {
+ mtu = (uint8_t) (p_recvd_mcmember_rec->mtu & 0x3F);
+ return ib_mtu_is_valid(mtu);
+ }
+ return 1;
+}
+
+void osm_mcmr_rcv_process(IN void *context, IN void *data)
+{
+ osm_sa_t *sa = context;
+ osm_madw_t *p_madw = data;
+ ib_sa_mad_t *p_sa_mad;
+ ib_member_rec_t *p_recvd_mcmember_rec;
+
+ CL_ASSERT(sa);
+
+ OSM_LOG_ENTER(sa->p_log);
+
+ CL_ASSERT(p_madw);
+
+ p_sa_mad = osm_madw_get_sa_mad_ptr(p_madw);
+ p_recvd_mcmember_rec =
+ (ib_member_rec_t *) ib_sa_mad_get_payload_ptr(p_sa_mad);
+
+ CL_ASSERT(p_sa_mad->attr_id == IB_MAD_ATTR_MCMEMBER_RECORD);
+
+ switch (p_sa_mad->method) {
+ case IB_MAD_METHOD_SET:
+ if (!check_join_comp_mask(p_sa_mad->comp_mask)) {
+ char gid_str[INET6_ADDRSTRLEN];
+ char gid_str2[INET6_ADDRSTRLEN];
+ OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 1B18: "
+ "component mask = 0x%016" PRIx64 ", "
+ "expected comp mask = 0x%016" PRIx64 ", "
+ "MGID: %s for PortGID: %s\n",
+ cl_ntoh64(p_sa_mad->comp_mask),
+ CL_NTOH64(JOIN_MC_COMP_MASK),
+ inet_ntop(AF_INET6,
+ p_recvd_mcmember_rec->mgid.raw,
+ gid_str, sizeof gid_str),
+ inet_ntop(AF_INET6,
+ p_recvd_mcmember_rec->port_gid.raw,
+ gid_str2, sizeof gid_str2));
+ osm_sa_send_error(sa, p_madw,
+ IB_SA_MAD_STATUS_INSUF_COMPS);
+ goto Exit;
+ }
+ if (!rate_is_valid(p_sa_mad, p_recvd_mcmember_rec) ||
+ !mtu_is_valid(p_sa_mad, p_recvd_mcmember_rec)) {
+ osm_sa_send_error(sa, p_madw,
+ IB_SA_MAD_STATUS_REQ_INVALID);
+ goto Exit;
+ }
+
+ /*
+ * Join or Create Multicast Group
+ */
+ mcmr_rcv_join_mgrp(sa, p_madw);
+ break;
+ case IB_MAD_METHOD_DELETE:
+ if (!check_join_comp_mask(p_sa_mad->comp_mask)) {
+ OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 1B20: "
+ "component mask = 0x%016" PRIx64 ", "
+ "expected comp mask = 0x%016" PRIx64 "\n",
+ cl_ntoh64(p_sa_mad->comp_mask),
+ CL_NTOH64(JOIN_MC_COMP_MASK));
+ osm_sa_send_error(sa, p_madw,
+ IB_SA_MAD_STATUS_INSUF_COMPS);
+ goto Exit;
+ }
+ if (!rate_is_valid(p_sa_mad, p_recvd_mcmember_rec) ||
+ !mtu_is_valid(p_sa_mad, p_recvd_mcmember_rec)) {
+ osm_sa_send_error(sa, p_madw,
+ IB_SA_MAD_STATUS_REQ_INVALID);
+ goto Exit;
+ }
+
+ /*
+ * Leave Multicast Group
+ */
+ mcmr_rcv_leave_mgrp(sa, p_madw);
+ break;
+ case IB_MAD_METHOD_GET:
+ case IB_MAD_METHOD_GETTABLE:
+ if (!rate_is_valid(p_sa_mad, p_recvd_mcmember_rec) ||
+ !mtu_is_valid(p_sa_mad, p_recvd_mcmember_rec)) {
+ osm_sa_send_error(sa, p_madw,
+ IB_SA_MAD_STATUS_REQ_INVALID);
+ goto Exit;
+ }
+
+ /*
+ * Querying a Multicast Group
+ */
+ mcmr_query_mgrp(sa, p_madw);
+ break;
+ default:
+ OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 1B21: "
+ "Unsupported Method (%s) for MCMemberRecord request\n",
+ ib_get_sa_method_str(p_sa_mad->method));
+ osm_sa_send_error(sa, p_madw, IB_MAD_STATUS_UNSUP_METHOD_ATTR);
+ break;
+ }
+
+Exit:
+ OSM_LOG_EXIT(sa->p_log);
+ return;
+}
diff --git a/contrib/ofed/opensm/opensm/osm_sa_mft_record.c b/contrib/ofed/opensm/opensm/osm_sa_mft_record.c
new file mode 100644
index 0000000..3f9b14a
--- /dev/null
+++ b/contrib/ofed/opensm/opensm/osm_sa_mft_record.c
@@ -0,0 +1,274 @@
+/*
+ * Copyright (c) 2004-2009 Voltaire, Inc. All rights reserved.
+ * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved.
+ * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
+ * Copyright (c) 2013 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+/*
+ * Abstract:
+ * Implementation of osm_mftr_rcv_t.
+ * This object represents the MulticastForwardingTable Receiver object.
+ * This object is part of the opensm family of objects.
+ */
+
+#if HAVE_CONFIG_H
+# include <config.h>
+#endif /* HAVE_CONFIG_H */
+
+#include <string.h>
+#include <iba/ib_types.h>
+#include <complib/cl_debug.h>
+#include <complib/cl_qlist.h>
+#include <opensm/osm_file_ids.h>
+#define FILE_ID OSM_FILE_SA_MFT_RECORD_C
+#include <vendor/osm_vendor_api.h>
+#include <opensm/osm_switch.h>
+#include <opensm/osm_helper.h>
+#include <opensm/osm_pkey.h>
+#include <opensm/osm_sa.h>
+
+#define SA_MFTR_RESP_SIZE SA_ITEM_RESP_SIZE(mft_rec)
+
+typedef struct osm_mftr_search_ctxt {
+ const ib_mft_record_t *p_rcvd_rec;
+ ib_net64_t comp_mask;
+ cl_qlist_t *p_list;
+ osm_sa_t *sa;
+ const osm_physp_t *p_req_physp;
+} osm_mftr_search_ctxt_t;
+
+static ib_api_status_t mftr_rcv_new_mftr(IN osm_sa_t * sa,
+ IN osm_switch_t * p_sw,
+ IN cl_qlist_t * p_list,
+ IN ib_net16_t lid, IN uint16_t block,
+ IN uint8_t position)
+{
+ osm_sa_item_t *p_rec_item;
+ ib_api_status_t status = IB_SUCCESS;
+ uint16_t position_block_num;
+
+ OSM_LOG_ENTER(sa->p_log);
+
+ p_rec_item = malloc(SA_MFTR_RESP_SIZE);
+ if (p_rec_item == NULL) {
+ OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 4A02: "
+ "rec_item alloc failed\n");
+ status = IB_INSUFFICIENT_RESOURCES;
+ goto Exit;
+ }
+
+ OSM_LOG(sa->p_log, OSM_LOG_DEBUG,
+ "New MulticastForwardingTable: sw 0x%016" PRIx64
+ "\n\t\t\t\tblock %u position %u lid %u\n",
+ cl_ntoh64(osm_node_get_node_guid(p_sw->p_node)),
+ block, position, cl_ntoh16(lid));
+
+ position_block_num = ((uint16_t) position << 12) |
+ (block & IB_MCAST_BLOCK_ID_MASK_HO);
+
+ memset(p_rec_item, 0, SA_MFTR_RESP_SIZE);
+
+ p_rec_item->resp.mft_rec.lid = lid;
+ p_rec_item->resp.mft_rec.position_block_num = cl_hton16(position_block_num);
+
+ /* copy the mft block */
+ osm_switch_get_mft_block(p_sw, block, position, p_rec_item->resp.mft_rec.mft);
+
+ cl_qlist_insert_tail(p_list, &p_rec_item->list_item);
+
+Exit:
+ OSM_LOG_EXIT(sa->p_log);
+ return status;
+}
+
+static void mftr_rcv_by_comp_mask(IN cl_map_item_t * p_map_item, IN void *cxt)
+{
+ const osm_mftr_search_ctxt_t *p_ctxt = cxt;
+ osm_switch_t *p_sw = (osm_switch_t *) p_map_item;
+ const ib_mft_record_t *const p_rcvd_rec = p_ctxt->p_rcvd_rec;
+ osm_sa_t *sa = p_ctxt->sa;
+ ib_net64_t const comp_mask = p_ctxt->comp_mask;
+ const osm_physp_t *const p_req_physp = p_ctxt->p_req_physp;
+ osm_port_t *p_port;
+ uint16_t min_lid_ho, max_lid_ho;
+ uint16_t position_block_num_ho;
+ uint16_t min_block, max_block, block;
+ const osm_physp_t *p_physp;
+ uint8_t min_position, max_position, position;
+
+ /* In switches, the port guid is the node guid. */
+ p_port =
+ osm_get_port_by_guid(sa->p_subn, p_sw->p_node->node_info.port_guid);
+ if (!p_port) {
+ OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 4A05: "
+ "Failed to find Port by Node Guid:0x%016" PRIx64
+ "\n", cl_ntoh64(p_sw->p_node->node_info.node_guid));
+ return;
+ }
+
+ /* check that the requester physp and the current physp are under
+ the same partition. */
+ p_physp = p_port->p_physp;
+ if (!p_physp) {
+ OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 4A06: "
+ "Failed to find default physical Port by Node Guid:0x%016"
+ PRIx64 "\n",
+ cl_ntoh64(p_sw->p_node->node_info.node_guid));
+ return;
+ }
+ if (!osm_physp_share_pkey(sa->p_log, p_req_physp, p_physp,
+ sa->p_subn->opt.allow_both_pkeys))
+ return;
+
+ /* get the port 0 of the switch */
+ osm_port_get_lid_range_ho(p_port, &min_lid_ho, &max_lid_ho);
+
+ /* compare the lids - if required */
+ if (comp_mask & IB_MFTR_COMPMASK_LID) {
+ OSM_LOG(sa->p_log, OSM_LOG_DEBUG,
+ "Comparing lid:%u to port lid range: %u .. %u\n",
+ cl_ntoh16(p_rcvd_rec->lid), min_lid_ho, max_lid_ho);
+ /* ok we are ready for range check */
+ if (min_lid_ho > cl_ntoh16(p_rcvd_rec->lid) ||
+ max_lid_ho < cl_ntoh16(p_rcvd_rec->lid))
+ return;
+ }
+
+ if (!osm_switch_supports_mcast(p_sw))
+ return;
+
+ /* Are there any blocks in use ? */
+ if (osm_switch_get_mft_max_block_in_use(p_sw) == -1)
+ return;
+
+ position_block_num_ho = cl_ntoh16(p_rcvd_rec->position_block_num);
+
+ /* now we need to decide which blocks to output */
+ if (comp_mask & IB_MFTR_COMPMASK_BLOCK) {
+ max_block = min_block =
+ position_block_num_ho & IB_MCAST_BLOCK_ID_MASK_HO;
+ if (max_block > osm_switch_get_mft_max_block_in_use(p_sw))
+ return;
+ } else {
+ /* use as many blocks as needed */
+ min_block = 0;
+ max_block = osm_switch_get_mft_max_block_in_use(p_sw);
+ }
+
+ /* need to decide which positions to output */
+ if (comp_mask & IB_MFTR_COMPMASK_POSITION) {
+ min_position = max_position =
+ (position_block_num_ho & 0xF000) >> 12;
+ if (max_position > osm_switch_get_mft_max_position(p_sw))
+ return;
+ } else {
+ /* use as many positions as needed */
+ min_position = 0;
+ max_position = osm_switch_get_mft_max_position(p_sw);
+ }
+
+ /* so we can add these one by one ... */
+ for (block = min_block; block <= max_block; block++)
+ for (position = min_position; position <= max_position;
+ position++)
+ mftr_rcv_new_mftr(sa, p_sw, p_ctxt->p_list,
+ osm_port_get_base_lid(p_port), block,
+ position);
+}
+
+void osm_mftr_rcv_process(IN void *ctx, IN void *data)
+{
+ osm_sa_t *sa = ctx;
+ osm_madw_t *p_madw = data;
+ const ib_sa_mad_t *p_rcvd_mad;
+ const ib_mft_record_t *p_rcvd_rec;
+ cl_qlist_t rec_list;
+ osm_mftr_search_ctxt_t context;
+ osm_physp_t *p_req_physp;
+
+ CL_ASSERT(sa);
+
+ OSM_LOG_ENTER(sa->p_log);
+
+ CL_ASSERT(p_madw);
+
+ p_rcvd_mad = osm_madw_get_sa_mad_ptr(p_madw);
+ p_rcvd_rec = (ib_mft_record_t *) ib_sa_mad_get_payload_ptr(p_rcvd_mad);
+
+ CL_ASSERT(p_rcvd_mad->attr_id == IB_MAD_ATTR_MFT_RECORD);
+
+ /* we only support SubnAdmGet and SubnAdmGetTable methods */
+ if (p_rcvd_mad->method != IB_MAD_METHOD_GET &&
+ p_rcvd_mad->method != IB_MAD_METHOD_GETTABLE) {
+ OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 4A08: "
+ "Unsupported Method (%s) for MFTRecord request\n",
+ ib_get_sa_method_str(p_rcvd_mad->method));
+ osm_sa_send_error(sa, p_madw, IB_MAD_STATUS_UNSUP_METHOD_ATTR);
+ goto Exit;
+ }
+
+ cl_plock_acquire(sa->p_lock);
+
+ /* update the requester physical port */
+ p_req_physp = osm_get_physp_by_mad_addr(sa->p_log, sa->p_subn,
+ osm_madw_get_mad_addr_ptr
+ (p_madw));
+ if (p_req_physp == NULL) {
+ cl_plock_release(sa->p_lock);
+ OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 4A07: "
+ "Cannot find requester physical port\n");
+ goto Exit;
+ }
+ OSM_LOG(sa->p_log, OSM_LOG_DEBUG,
+ "Requester port GUID 0x%" PRIx64 "\n",
+ cl_ntoh64(osm_physp_get_port_guid(p_req_physp)));
+
+ cl_qlist_init(&rec_list);
+
+ context.p_rcvd_rec = p_rcvd_rec;
+ context.p_list = &rec_list;
+ context.comp_mask = p_rcvd_mad->comp_mask;
+ context.sa = sa;
+ context.p_req_physp = p_req_physp;
+
+ /* Go over all switches */
+ cl_qmap_apply_func(&sa->p_subn->sw_guid_tbl, mftr_rcv_by_comp_mask,
+ &context);
+
+ cl_plock_release(sa->p_lock);
+
+ osm_sa_respond(sa, p_madw, sizeof(ib_mft_record_t), &rec_list);
+
+Exit:
+ OSM_LOG_EXIT(sa->p_log);
+}
diff --git a/contrib/ofed/opensm/opensm/osm_sa_multipath_record.c b/contrib/ofed/opensm/opensm/osm_sa_multipath_record.c
new file mode 100644
index 0000000..6151876
--- /dev/null
+++ b/contrib/ofed/opensm/opensm/osm_sa_multipath_record.c
@@ -0,0 +1,1673 @@
+/*
+ * Copyright (c) 2006-2009 Voltaire, Inc. All rights reserved.
+ * Copyright (c) 2002-2011 Mellanox Technologies LTD. All rights reserved.
+ * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
+ * Copyright (c) 2013 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+/*
+ * Abstract:
+ * Implementation of osm_mpr_rcv_t.
+ * This object represents the MultiPath Record Receiver object.
+ * This object is part of the opensm family of objects.
+ */
+
+#if HAVE_CONFIG_H
+# include <config.h>
+#endif /* HAVE_CONFIG_H */
+
+#if defined (VENDOR_RMPP_SUPPORT) && defined (DUAL_SIDED_RMPP)
+
+#include <string.h>
+#include <iba/ib_types.h>
+#include <complib/cl_qmap.h>
+#include <complib/cl_passivelock.h>
+#include <complib/cl_debug.h>
+#include <complib/cl_qlist.h>
+#include <opensm/osm_file_ids.h>
+#define FILE_ID OSM_FILE_SA_MULTIPATH_RECORD_C
+#include <vendor/osm_vendor_api.h>
+#include <opensm/osm_port.h>
+#include <opensm/osm_node.h>
+#include <opensm/osm_switch.h>
+#include <opensm/osm_partition.h>
+#include <opensm/osm_helper.h>
+#include <opensm/osm_qos_policy.h>
+#include <opensm/osm_sa.h>
+
+#define OSM_SA_MPR_MAX_NUM_PATH 127
+#define MAX_HOPS 64
+
+#define SA_MPR_RESP_SIZE SA_ITEM_RESP_SIZE(mpr_rec)
+
+static boolean_t sa_multipath_rec_is_tavor_port(IN const osm_port_t * p_port)
+{
+ osm_node_t const *p_node;
+ ib_net32_t vend_id;
+
+ p_node = p_port->p_node;
+ vend_id = ib_node_info_get_vendor_id(&p_node->node_info);
+
+ return ((p_node->node_info.device_id == CL_HTON16(23108)) &&
+ ((vend_id == CL_HTON32(OSM_VENDOR_ID_MELLANOX)) ||
+ (vend_id == CL_HTON32(OSM_VENDOR_ID_TOPSPIN)) ||
+ (vend_id == CL_HTON32(OSM_VENDOR_ID_SILVERSTORM)) ||
+ (vend_id == CL_HTON32(OSM_VENDOR_ID_VOLTAIRE))));
+}
+
+static boolean_t
+sa_multipath_rec_apply_tavor_mtu_limit(IN const ib_multipath_rec_t * p_mpr,
+ IN const osm_port_t * p_src_port,
+ IN const osm_port_t * p_dest_port,
+ IN const ib_net64_t comp_mask)
+{
+ uint8_t required_mtu;
+
+ /* only if at least one of the ports is a Tavor device */
+ if (!sa_multipath_rec_is_tavor_port(p_src_port) &&
+ !sa_multipath_rec_is_tavor_port(p_dest_port))
+ return FALSE;
+
+ /*
+ we can apply the patch if either:
+ 1. No MTU required
+ 2. Required MTU <
+ 3. Required MTU = 1K or 512 or 256
+ 4. Required MTU > 256 or 512
+ */
+ required_mtu = ib_multipath_rec_mtu(p_mpr);
+ if ((comp_mask & IB_MPR_COMPMASK_MTUSELEC) &&
+ (comp_mask & IB_MPR_COMPMASK_MTU)) {
+ switch (ib_multipath_rec_mtu_sel(p_mpr)) {
+ case 0: /* must be greater than */
+ case 2: /* exact match */
+ if (IB_MTU_LEN_1024 < required_mtu)
+ return FALSE;
+ break;
+
+ case 1: /* must be less than */
+ /* can't be disqualified by this one */
+ break;
+
+ case 3: /* largest available */
+ /* the ULP intentionally requested */
+ /* the largest MTU possible */
+ return FALSE;
+ break;
+
+ default:
+ /* if we're here, there's a bug in ib_multipath_rec_mtu_sel() */
+ CL_ASSERT(FALSE);
+ break;
+ }
+ }
+
+ return TRUE;
+}
+
+static ib_api_status_t mpr_rcv_get_path_parms(IN osm_sa_t * sa,
+ IN const ib_multipath_rec_t *
+ p_mpr,
+ IN const osm_alias_guid_t * p_src_alias_guid,
+ IN const osm_alias_guid_t * p_dest_alias_guid,
+ IN const uint16_t src_lid_ho,
+ IN const uint16_t dest_lid_ho,
+ IN const ib_net64_t comp_mask,
+ OUT osm_path_parms_t * p_parms)
+{
+ const osm_node_t *p_node;
+ const osm_physp_t *p_physp, *p_physp0;
+ const osm_physp_t *p_src_physp;
+ const osm_physp_t *p_dest_physp;
+ const osm_prtn_t *p_prtn = NULL;
+ const ib_port_info_t *p_pi, *p_pi0;
+ ib_slvl_table_t *p_slvl_tbl;
+ ib_api_status_t status = IB_SUCCESS;
+ uint8_t mtu;
+ uint8_t rate, p0_extended_rate, dest_rate;
+ uint8_t pkt_life;
+ uint8_t required_mtu;
+ uint8_t required_rate;
+ ib_net16_t required_pkey;
+ uint8_t required_sl;
+ uint8_t required_pkt_life;
+ ib_net16_t dest_lid;
+ int hops = 0;
+ int in_port_num = 0;
+ uint8_t i;
+ osm_qos_level_t *p_qos_level = NULL;
+ uint16_t valid_sl_mask = 0xffff;
+ int extended, p0_extended;
+
+ OSM_LOG_ENTER(sa->p_log);
+
+ dest_lid = cl_hton16(dest_lid_ho);
+
+ p_dest_physp = p_dest_alias_guid->p_base_port->p_physp;
+ p_physp = p_src_alias_guid->p_base_port->p_physp;
+ p_src_physp = p_physp;
+ p_pi = &p_physp->port_info;
+
+ mtu = ib_port_info_get_mtu_cap(p_pi);
+ extended = p_pi->capability_mask & IB_PORT_CAP_HAS_EXT_SPEEDS;
+ rate = ib_port_info_compute_rate(p_pi, extended);
+
+ /*
+ Mellanox Tavor device performance is better using 1K MTU.
+ If required MTU and MTU selector are such that 1K is OK
+ and at least one end of the path is Tavor we override the
+ port MTU with 1K.
+ */
+ if (sa->p_subn->opt.enable_quirks &&
+ sa_multipath_rec_apply_tavor_mtu_limit(p_mpr,
+ p_src_alias_guid->p_base_port,
+ p_dest_alias_guid->p_base_port,
+ comp_mask))
+ if (mtu > IB_MTU_LEN_1024) {
+ mtu = IB_MTU_LEN_1024;
+ OSM_LOG(sa->p_log, OSM_LOG_DEBUG,
+ "Optimized Path MTU to 1K for Mellanox Tavor device\n");
+ }
+
+ /*
+ Walk the subnet object from source to destination,
+ tracking the most restrictive rate and mtu values along the way...
+
+ If source port node is a switch, then p_physp should
+ point to the port that routes the destination lid
+ */
+
+ p_node = osm_physp_get_node_ptr(p_physp);
+
+ if (p_node->sw) {
+ /*
+ * Source node is a switch.
+ * Make sure that p_physp points to the out port of the
+ * switch that routes to the destination lid (dest_lid_ho)
+ */
+ p_physp = osm_switch_get_route_by_lid(p_node->sw, dest_lid);
+ if (p_physp == 0) {
+ OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 4514: "
+ "Can't find routing from LID %u to LID %u on "
+ "switch %s (GUID 0x%016" PRIx64 ")\n",
+ src_lid_ho, dest_lid_ho, p_node->print_desc,
+ cl_ntoh64(osm_node_get_node_guid(p_node)));
+ status = IB_NOT_FOUND;
+ goto Exit;
+ }
+ }
+
+ if (sa->p_subn->opt.qos) {
+
+ /*
+ * Whether this node is switch or CA, the IN port for
+ * the sl2vl table is 0, because this is a source node.
+ */
+ p_slvl_tbl = osm_physp_get_slvl_tbl(p_physp, 0);
+
+ /* update valid SLs that still exist on this route */
+ for (i = 0; i < IB_MAX_NUM_VLS; i++) {
+ if (valid_sl_mask & (1 << i) &&
+ ib_slvl_table_get(p_slvl_tbl, i) == IB_DROP_VL)
+ valid_sl_mask &= ~(1 << i);
+ }
+ if (!valid_sl_mask) {
+ OSM_LOG(sa->p_log, OSM_LOG_DEBUG,
+ "All the SLs lead to VL15 on this path\n");
+ status = IB_NOT_FOUND;
+ goto Exit;
+ }
+ }
+
+ /*
+ * Same as above
+ */
+ p_node = osm_physp_get_node_ptr(p_dest_physp);
+
+ if (p_node->sw) {
+ /*
+ * if destination is switch, we want p_dest_physp to point to port 0
+ */
+ p_dest_physp =
+ osm_switch_get_route_by_lid(p_node->sw, dest_lid);
+
+ if (p_dest_physp == 0) {
+ OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 4515: "
+ "Can't find routing from LID %u to LID %u on "
+ "switch %s (GUID 0x%016" PRIx64 ")\n",
+ src_lid_ho, dest_lid_ho, p_node->print_desc,
+ cl_ntoh64(osm_node_get_node_guid(p_node)));
+ status = IB_NOT_FOUND;
+ goto Exit;
+ }
+
+ }
+
+ /*
+ * Now go through the path step by step
+ */
+
+ while (p_physp != p_dest_physp) {
+
+ int tmp_pnum = p_physp->port_num;
+ p_node = osm_physp_get_node_ptr(p_physp);
+ p_physp = osm_physp_get_remote(p_physp);
+
+ if (p_physp == 0) {
+ OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 4505: "
+ "Can't find remote phys port of %s (GUID "
+ "0x%016" PRIx64 ") port %d "
+ "while routing from LID %u to LID %u",
+ p_node->print_desc,
+ cl_ntoh64(osm_node_get_node_guid(p_node)),
+ tmp_pnum, src_lid_ho, dest_lid_ho);
+ status = IB_ERROR;
+ goto Exit;
+ }
+
+ /* update number of hops traversed */
+ hops++;
+ if (hops > MAX_HOPS) {
+ OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 4520: "
+ "Path from GUID 0x%016" PRIx64 " (%s) to"
+ " lid %u GUID 0x%016" PRIx64 " (%s) needs"
+ " more than %d hops, max %d hops allowed\n",
+ cl_ntoh64(osm_physp_get_port_guid(p_src_physp)),
+ p_src_physp->p_node->print_desc, dest_lid_ho,
+ cl_ntoh64(osm_physp_get_port_guid
+ (p_dest_physp)),
+ p_dest_physp->p_node->print_desc, hops,
+ MAX_HOPS);
+ status = IB_NOT_FOUND;
+ goto Exit;
+ }
+
+ in_port_num = osm_physp_get_port_num(p_physp);
+
+ /*
+ This is point to point case (no switch in between)
+ */
+ if (p_physp == p_dest_physp)
+ break;
+
+ p_node = osm_physp_get_node_ptr(p_physp);
+
+ if (!p_node->sw) {
+ /*
+ There is some sort of problem in the subnet object!
+ If this isn't a switch, we should have reached
+ the destination by now!
+ */
+ OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 4503: "
+ "Internal error, bad path while routing "
+ "from %s (GUID: 0x%016"PRIx64") port %d "
+ "to %s (GUID: 0x%016"PRIx64") port %d; "
+ "ended at %s port %d\n",
+ p_src_alias_guid->p_base_port->p_node->print_desc,
+ cl_ntoh64(p_src_alias_guid->p_base_port->p_node->node_info.node_guid),
+ p_src_alias_guid->p_base_port->p_physp->port_num,
+ p_dest_alias_guid->p_base_port->p_node->print_desc,
+ cl_ntoh64(p_dest_alias_guid->p_base_port->p_node->node_info.node_guid),
+ p_dest_alias_guid->p_base_port->p_physp->port_num,
+ p_node->print_desc,
+ p_physp->port_num);
+ status = IB_ERROR;
+ goto Exit;
+ }
+
+ /*
+ Check parameters for the ingress port in this switch.
+ */
+ p_pi = &p_physp->port_info;
+
+ if (mtu > ib_port_info_get_mtu_cap(p_pi))
+ mtu = ib_port_info_get_mtu_cap(p_pi);
+
+ p_physp0 = osm_node_get_physp_ptr((osm_node_t *)p_node, 0);
+ p_pi0 = &p_physp0->port_info;
+ p0_extended = p_pi0->capability_mask & IB_PORT_CAP_HAS_EXT_SPEEDS;
+ p0_extended_rate = ib_port_info_compute_rate(p_pi, p0_extended);
+ if (ib_path_compare_rates(rate, p0_extended_rate) > 0)
+ rate = p0_extended_rate;
+
+ /*
+ Continue with the egress port on this switch.
+ */
+ p_physp = osm_switch_get_route_by_lid(p_node->sw, dest_lid);
+ if (p_physp == 0) {
+ OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 4516: "
+ "Dead end path on switch "
+ "%s (GUID: 0x%016"PRIx64") to LID %u\n",
+ p_node->print_desc,
+ cl_ntoh64(osm_node_get_node_guid(p_node)),
+ dest_lid_ho);
+ status = IB_ERROR;
+ goto Exit;
+ }
+
+ p_pi = &p_physp->port_info;
+
+ if (mtu > ib_port_info_get_mtu_cap(p_pi))
+ mtu = ib_port_info_get_mtu_cap(p_pi);
+
+ p_physp0 = osm_node_get_physp_ptr((osm_node_t *)p_node, 0);
+ p_pi0 = &p_physp0->port_info;
+ p0_extended = p_pi0->capability_mask & IB_PORT_CAP_HAS_EXT_SPEEDS;
+ p0_extended_rate = ib_port_info_compute_rate(p_pi, p0_extended);
+ if (ib_path_compare_rates(rate, p0_extended_rate) > 0)
+ rate = p0_extended_rate;
+
+ if (sa->p_subn->opt.qos) {
+ /*
+ * Check SL2VL table of the switch and update valid SLs
+ */
+ p_slvl_tbl =
+ osm_physp_get_slvl_tbl(p_physp, in_port_num);
+ for (i = 0; i < IB_MAX_NUM_VLS; i++) {
+ if (valid_sl_mask & (1 << i) &&
+ ib_slvl_table_get(p_slvl_tbl,
+ i) == IB_DROP_VL)
+ valid_sl_mask &= ~(1 << i);
+ }
+ if (!valid_sl_mask) {
+ OSM_LOG(sa->p_log, OSM_LOG_DEBUG,
+ "All the SLs lead to VL15 "
+ "on this path\n");
+ status = IB_NOT_FOUND;
+ goto Exit;
+ }
+ }
+ }
+
+ /*
+ p_physp now points to the destination
+ */
+ p_pi = &p_physp->port_info;
+
+ if (mtu > ib_port_info_get_mtu_cap(p_pi))
+ mtu = ib_port_info_get_mtu_cap(p_pi);
+
+ extended = p_pi->capability_mask & IB_PORT_CAP_HAS_EXT_SPEEDS;
+ dest_rate = ib_port_info_compute_rate(p_pi, extended);
+ if (ib_path_compare_rates(rate, dest_rate) > 0)
+ rate = dest_rate;
+
+ OSM_LOG(sa->p_log, OSM_LOG_DEBUG,
+ "Path min MTU = %u, min rate = %u\n", mtu, rate);
+
+ /*
+ * Get QoS Level object according to the MultiPath request
+ * and adjust MultiPath parameters according to QoS settings
+ */
+ if (sa->p_subn->opt.qos && sa->p_subn->p_qos_policy &&
+ (p_qos_level =
+ osm_qos_policy_get_qos_level_by_mpr(sa->p_subn->p_qos_policy,
+ p_mpr, p_src_physp,
+ p_dest_physp, comp_mask))) {
+
+ OSM_LOG(sa->p_log, OSM_LOG_DEBUG,
+ "MultiPathRecord request matches QoS Level '%s' (%s)\n",
+ p_qos_level->name,
+ p_qos_level->use ? p_qos_level->use : "no description");
+
+ if (p_qos_level->mtu_limit_set
+ && (mtu > p_qos_level->mtu_limit))
+ mtu = p_qos_level->mtu_limit;
+
+ if (p_qos_level->rate_limit_set
+ && (ib_path_compare_rates(rate, p_qos_level->rate_limit) > 0))
+ rate = p_qos_level->rate_limit;
+
+ if (p_qos_level->sl_set) {
+ required_sl = p_qos_level->sl;
+ if (!(valid_sl_mask & (1 << required_sl))) {
+ status = IB_NOT_FOUND;
+ goto Exit;
+ }
+ }
+ }
+
+ /*
+ Determine if these values meet the user criteria
+ */
+
+ /* we silently ignore cases where only the MTU selector is defined */
+ if ((comp_mask & IB_MPR_COMPMASK_MTUSELEC) &&
+ (comp_mask & IB_MPR_COMPMASK_MTU)) {
+ required_mtu = ib_multipath_rec_mtu(p_mpr);
+ switch (ib_multipath_rec_mtu_sel(p_mpr)) {
+ case 0: /* must be greater than */
+ if (mtu <= required_mtu)
+ status = IB_NOT_FOUND;
+ break;
+
+ case 1: /* must be less than */
+ if (mtu >= required_mtu) {
+ /* adjust to use the highest mtu
+ lower then the required one */
+ if (required_mtu > 1)
+ mtu = required_mtu - 1;
+ else
+ status = IB_NOT_FOUND;
+ }
+ break;
+
+ case 2: /* exact match */
+ if (mtu < required_mtu)
+ status = IB_NOT_FOUND;
+ else
+ mtu = required_mtu;
+ break;
+
+ case 3: /* largest available */
+ /* can't be disqualified by this one */
+ break;
+
+ default:
+ /* if we're here, there's a bug in ib_multipath_rec_mtu_sel() */
+ CL_ASSERT(FALSE);
+ status = IB_ERROR;
+ break;
+ }
+ }
+ if (status != IB_SUCCESS)
+ goto Exit;
+
+ /* we silently ignore cases where only the Rate selector is defined */
+ if ((comp_mask & IB_MPR_COMPMASK_RATESELEC) &&
+ (comp_mask & IB_MPR_COMPMASK_RATE)) {
+ required_rate = ib_multipath_rec_rate(p_mpr);
+ switch (ib_multipath_rec_rate_sel(p_mpr)) {
+ case 0: /* must be greater than */
+ if (ib_path_compare_rates(rate, required_rate) <= 0)
+ status = IB_NOT_FOUND;
+ break;
+
+ case 1: /* must be less than */
+ if (ib_path_compare_rates(rate, required_rate) >= 0) {
+ /* adjust the rate to use the highest rate
+ lower then the required one */
+ rate = ib_path_rate_get_prev(required_rate);
+ if (!rate)
+ status = IB_NOT_FOUND;
+ }
+ break;
+
+ case 2: /* exact match */
+ if (ib_path_compare_rates(rate, required_rate))
+ status = IB_NOT_FOUND;
+ else
+ rate = required_rate;
+ break;
+
+ case 3: /* largest available */
+ /* can't be disqualified by this one */
+ break;
+
+ default:
+ /* if we're here, there's a bug in ib_multipath_rec_mtu_sel() */
+ CL_ASSERT(FALSE);
+ status = IB_ERROR;
+ break;
+ }
+ }
+ if (status != IB_SUCCESS)
+ goto Exit;
+
+ /* Verify the pkt_life_time */
+ /* According to spec definition IBA 1.2 Table 205 PacketLifeTime description,
+ for loopback paths, packetLifeTime shall be zero. */
+ if (p_src_alias_guid->p_base_port == p_dest_alias_guid->p_base_port)
+ pkt_life = 0; /* loopback */
+ else if (p_qos_level && p_qos_level->pkt_life_set)
+ pkt_life = p_qos_level->pkt_life;
+ else
+ pkt_life = sa->p_subn->opt.subnet_timeout;
+
+ /* we silently ignore cases where only the PktLife selector is defined */
+ if ((comp_mask & IB_MPR_COMPMASK_PKTLIFETIMESELEC) &&
+ (comp_mask & IB_MPR_COMPMASK_PKTLIFETIME)) {
+ required_pkt_life = ib_multipath_rec_pkt_life(p_mpr);
+ switch (ib_multipath_rec_pkt_life_sel(p_mpr)) {
+ case 0: /* must be greater than */
+ if (pkt_life <= required_pkt_life)
+ status = IB_NOT_FOUND;
+ break;
+
+ case 1: /* must be less than */
+ if (pkt_life >= required_pkt_life) {
+ /* adjust the lifetime to use the highest possible
+ lower then the required one */
+ if (required_pkt_life > 1)
+ pkt_life = required_pkt_life - 1;
+ else
+ status = IB_NOT_FOUND;
+ }
+ break;
+
+ case 2: /* exact match */
+ if (pkt_life < required_pkt_life)
+ status = IB_NOT_FOUND;
+ else
+ pkt_life = required_pkt_life;
+ break;
+
+ case 3: /* smallest available */
+ /* can't be disqualified by this one */
+ break;
+
+ default:
+ /* if we're here, there's a bug in ib_path_rec_pkt_life_sel() */
+ CL_ASSERT(FALSE);
+ status = IB_ERROR;
+ break;
+ }
+ }
+
+ if (status != IB_SUCCESS)
+ goto Exit;
+
+ /*
+ * set Pkey for this MultiPath record request
+ */
+
+ if (comp_mask & IB_MPR_COMPMASK_RAWTRAFFIC &&
+ cl_ntoh32(p_mpr->hop_flow_raw) & (1 << 31))
+ required_pkey =
+ osm_physp_find_common_pkey(p_src_physp, p_dest_physp,
+ sa->p_subn->opt.allow_both_pkeys);
+
+ else if (comp_mask & IB_MPR_COMPMASK_PKEY) {
+ /*
+ * MPR request has a specific pkey:
+ * Check that source and destination share this pkey.
+ * If QoS level has pkeys, check that this pkey exists
+ * in the QoS level pkeys.
+ * MPR returned pkey is the requested pkey.
+ */
+ required_pkey = p_mpr->pkey;
+ if (!osm_physp_share_this_pkey
+ (p_src_physp, p_dest_physp, required_pkey,
+ sa->p_subn->opt.allow_both_pkeys)) {
+ OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 4518: "
+ "Ports src 0x%016"PRIx64" (%s port %d) "
+ "and dst 0x%016"PRIx64" (%s port %d) "
+ "do not share the specified PKey 0x%04x\n",
+ cl_ntoh64(osm_physp_get_port_guid(p_src_physp)),
+ p_src_physp->p_node->print_desc,
+ p_src_physp->port_num,
+ cl_ntoh64(osm_physp_get_port_guid
+ (p_dest_physp)),
+ p_dest_physp->p_node->print_desc,
+ p_dest_physp->port_num,
+ cl_ntoh16(required_pkey));
+ status = IB_NOT_FOUND;
+ goto Exit;
+ }
+ if (p_qos_level && p_qos_level->pkey_range_len &&
+ !osm_qos_level_has_pkey(p_qos_level, required_pkey)) {
+ OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 451C: "
+ "Ports src 0x%016"PRIx64" (%s port %d) "
+ "and dst 0x%016"PRIx64" (%s port %d) "
+ "do not share specified PKey (0x%04x) as "
+ "defined by QoS level \"%s\"\n",
+ cl_ntoh64(osm_physp_get_port_guid(p_src_physp)),
+ p_src_physp->p_node->print_desc,
+ p_src_physp->port_num,
+ cl_ntoh64(osm_physp_get_port_guid
+ (p_dest_physp)),
+ p_dest_physp->p_node->print_desc,
+ p_dest_physp->port_num,
+ cl_ntoh16(required_pkey),
+ p_qos_level->name);
+ status = IB_NOT_FOUND;
+ goto Exit;
+ }
+
+ } else if (p_qos_level && p_qos_level->pkey_range_len) {
+ /*
+ * MPR request doesn't have a specific pkey, but QoS level
+ * has pkeys - get shared pkey from QoS level pkeys
+ */
+ required_pkey = osm_qos_level_get_shared_pkey(p_qos_level,
+ p_src_physp,
+ p_dest_physp,
+ sa->p_subn->opt.allow_both_pkeys);
+ if (!required_pkey) {
+ OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 451D: "
+ "Ports src 0x%016"PRIx64" (%s port %d) "
+ "and dst 0x%016"PRIx64" (%s port %d) "
+ "do not share a PKey as defined by QoS "
+ "level \"%s\"\n",
+ cl_ntoh64(osm_physp_get_port_guid(p_src_physp)),
+ p_src_physp->p_node->print_desc,
+ p_src_physp->port_num,
+ cl_ntoh64(osm_physp_get_port_guid
+ (p_dest_physp)),
+ p_dest_physp->p_node->print_desc,
+ p_dest_physp->port_num,
+ p_qos_level->name);
+ status = IB_NOT_FOUND;
+ goto Exit;
+ }
+
+ } else {
+ /*
+ * Neither MPR request nor QoS level have pkey.
+ * Just get any shared pkey.
+ */
+ required_pkey =
+ osm_physp_find_common_pkey(p_src_physp, p_dest_physp,
+ sa->p_subn->opt.allow_both_pkeys);
+ if (!required_pkey) {
+ OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 4519: "
+ "Ports src 0x%016"PRIx64" (%s port %d) "
+ "and dst 0x%016"PRIx64" (%s port %d) "
+ "do not have any shared PKeys\n",
+ cl_ntoh64(osm_physp_get_port_guid(p_src_physp)),
+ p_src_physp->p_node->print_desc,
+ p_src_physp->port_num,
+ cl_ntoh64(osm_physp_get_port_guid
+ (p_dest_physp)),
+ p_dest_physp->p_node->print_desc,
+ p_dest_physp->port_num);
+ status = IB_NOT_FOUND;
+ goto Exit;
+ }
+ }
+
+ if (required_pkey) {
+ p_prtn =
+ (osm_prtn_t *) cl_qmap_get(&sa->p_subn->prtn_pkey_tbl,
+ required_pkey &
+ cl_ntoh16((uint16_t) ~ 0x8000));
+ if (p_prtn ==
+ (osm_prtn_t *) cl_qmap_end(&sa->p_subn->prtn_pkey_tbl))
+ p_prtn = NULL;
+ }
+
+ /*
+ * Set MultiPathRecord SL.
+ */
+
+ if (comp_mask & IB_MPR_COMPMASK_SL) {
+ /*
+ * Specific SL was requested
+ */
+ required_sl = ib_multipath_rec_sl(p_mpr);
+
+ if (p_qos_level && p_qos_level->sl_set &&
+ p_qos_level->sl != required_sl) {
+ OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 451E: "
+ "QoS constraints: required MultiPathRecord SL "
+ "(%u) doesn't match QoS policy \"%s\" SL (%u) "
+ "[%s port %d <-> %s port %d]\n", required_sl,
+ p_qos_level->name,
+ p_qos_level->sl,
+ p_src_alias_guid->p_base_port->p_node->print_desc,
+ p_src_alias_guid->p_base_port->p_physp->port_num,
+ p_dest_alias_guid->p_base_port->p_node->print_desc,
+ p_dest_alias_guid->p_base_port->p_physp->port_num);
+ status = IB_NOT_FOUND;
+ goto Exit;
+ }
+
+ } else if (p_qos_level && p_qos_level->sl_set) {
+ /*
+ * No specific SL was requested,
+ * but there is an SL in QoS level.
+ */
+ required_sl = p_qos_level->sl;
+
+ if (required_pkey && p_prtn && p_prtn->sl != p_qos_level->sl)
+ OSM_LOG(sa->p_log, OSM_LOG_DEBUG,
+ "QoS level SL (%u) overrides partition SL (%u)\n",
+ p_qos_level->sl, p_prtn->sl);
+
+ } else if (required_pkey) {
+ /*
+ * No specific SL in request or in QoS level - use partition SL
+ */
+ p_prtn =
+ (osm_prtn_t *) cl_qmap_get(&sa->p_subn->prtn_pkey_tbl,
+ required_pkey &
+ cl_ntoh16((uint16_t) ~ 0x8000));
+ if (!p_prtn) {
+ required_sl = OSM_DEFAULT_SL;
+ /* this may be possible when pkey tables are created somehow in
+ previous runs or things are going wrong here */
+ OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 451A: "
+ "No partition found for PKey 0x%04x - "
+ "using default SL %d "
+ "[%s port %d <-> %s port %d]\n",
+ cl_ntoh16(required_pkey), required_sl,
+ p_src_alias_guid->p_base_port->p_node->print_desc,
+ p_src_alias_guid->p_base_port->p_physp->port_num,
+ p_dest_alias_guid->p_base_port->p_node->print_desc,
+ p_dest_alias_guid->p_base_port->p_physp->port_num);
+ } else
+ required_sl = p_prtn->sl;
+
+ } else if (sa->p_subn->opt.qos) {
+ if (valid_sl_mask & (1 << OSM_DEFAULT_SL))
+ required_sl = OSM_DEFAULT_SL;
+ else {
+ for (i = 0; i < IB_MAX_NUM_VLS; i++)
+ if (valid_sl_mask & (1 << i))
+ break;
+ required_sl = i;
+ }
+ } else
+ required_sl = OSM_DEFAULT_SL;
+
+ if (sa->p_subn->opt.qos && !(valid_sl_mask & (1 << required_sl))) {
+ OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 451F: "
+ "Selected SL (%u) leads to VL15 "
+ "[%s port %d <-> %s port %d]\n",
+ required_sl,
+ p_src_alias_guid->p_base_port->p_node->print_desc,
+ p_src_alias_guid->p_base_port->p_physp->port_num,
+ p_dest_alias_guid->p_base_port->p_node->print_desc,
+ p_dest_alias_guid->p_base_port->p_physp->port_num);
+ status = IB_NOT_FOUND;
+ goto Exit;
+ }
+
+ /* reset pkey when raw traffic */
+ if (comp_mask & IB_MPR_COMPMASK_RAWTRAFFIC &&
+ cl_ntoh32(p_mpr->hop_flow_raw) & (1 << 31))
+ required_pkey = 0;
+
+ p_parms->mtu = mtu;
+ p_parms->rate = rate;
+ p_parms->pkey = required_pkey;
+ p_parms->pkt_life = pkt_life;
+ p_parms->sl = required_sl;
+ p_parms->hops = hops;
+
+ OSM_LOG(sa->p_log, OSM_LOG_DEBUG, "MultiPath params:"
+ " mtu = %u, rate = %u, packet lifetime = %u,"
+ " pkey = 0x%04X, sl = %u, hops = %u\n", mtu, rate,
+ pkt_life, cl_ntoh16(required_pkey), required_sl, hops);
+
+Exit:
+ OSM_LOG_EXIT(sa->p_log);
+ return status;
+}
+
+static void mpr_rcv_build_pr(IN osm_sa_t * sa,
+ IN const osm_alias_guid_t * p_src_alias_guid,
+ IN const osm_alias_guid_t * p_dest_alias_guid,
+ IN uint16_t src_lid_ho, IN uint16_t dest_lid_ho,
+ IN uint8_t preference,
+ IN const osm_path_parms_t * p_parms,
+ OUT ib_path_rec_t * p_pr)
+{
+ const osm_physp_t *p_src_physp, *p_dest_physp;
+
+ OSM_LOG_ENTER(sa->p_log);
+
+ p_src_physp = p_src_alias_guid->p_base_port->p_physp;
+ p_dest_physp = p_dest_alias_guid->p_base_port->p_physp;
+
+ p_pr->dgid.unicast.prefix = osm_physp_get_subnet_prefix(p_dest_physp);
+ p_pr->dgid.unicast.interface_id = p_dest_alias_guid->alias_guid;
+
+ p_pr->sgid.unicast.prefix = osm_physp_get_subnet_prefix(p_src_physp);
+ p_pr->sgid.unicast.interface_id = p_src_alias_guid->alias_guid;
+
+ p_pr->dlid = cl_hton16(dest_lid_ho);
+ p_pr->slid = cl_hton16(src_lid_ho);
+
+ p_pr->hop_flow_raw &= cl_hton32(1 << 31);
+
+ p_pr->pkey = p_parms->pkey;
+ ib_path_rec_set_qos_class(p_pr, 0);
+ ib_path_rec_set_sl(p_pr, p_parms->sl);
+ p_pr->mtu = (uint8_t) (p_parms->mtu | 0x80);
+ p_pr->rate = (uint8_t) (p_parms->rate | 0x80);
+
+ /* According to 1.2 spec definition Table 205 PacketLifeTime description,
+ for loopback paths, packetLifeTime shall be zero. */
+ if (p_src_alias_guid->p_base_port == p_dest_alias_guid->p_base_port)
+ p_pr->pkt_life = 0x80; /* loopback */
+ else
+ p_pr->pkt_life = (uint8_t) (p_parms->pkt_life | 0x80);
+
+ p_pr->preference = preference;
+
+ /* always return num_path = 0 so this is only the reversible component */
+ if (p_parms->reversible)
+ p_pr->num_path = 0x80;
+
+ OSM_LOG_EXIT(sa->p_log);
+}
+
+static osm_sa_item_t *mpr_rcv_get_lid_pair_path(IN osm_sa_t * sa,
+ IN const ib_multipath_rec_t *
+ p_mpr,
+ IN const osm_alias_guid_t *
+ p_src_alias_guid,
+ IN const osm_alias_guid_t *
+ p_dest_alias_guid,
+ IN const uint16_t src_lid_ho,
+ IN const uint16_t dest_lid_ho,
+ IN const ib_net64_t comp_mask,
+ IN const uint8_t preference)
+{
+ osm_path_parms_t path_parms;
+ osm_path_parms_t rev_path_parms;
+ osm_sa_item_t *p_pr_item;
+ ib_api_status_t status, rev_path_status;
+
+ OSM_LOG_ENTER(sa->p_log);
+
+ OSM_LOG(sa->p_log, OSM_LOG_DEBUG, "Src LID %u, Dest LID %u\n",
+ src_lid_ho, dest_lid_ho);
+
+ p_pr_item = malloc(SA_MPR_RESP_SIZE);
+ if (p_pr_item == NULL) {
+ OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 4501: "
+ "Unable to allocate path record\n");
+ goto Exit;
+ }
+ memset(p_pr_item, 0, SA_MPR_RESP_SIZE);
+
+ status = mpr_rcv_get_path_parms(sa, p_mpr, p_src_alias_guid,
+ p_dest_alias_guid,
+ src_lid_ho, dest_lid_ho,
+ comp_mask, &path_parms);
+
+ if (status != IB_SUCCESS) {
+ free(p_pr_item);
+ p_pr_item = NULL;
+ goto Exit;
+ }
+
+ /* now try the reversible path */
+ rev_path_status = mpr_rcv_get_path_parms(sa, p_mpr, p_dest_alias_guid,
+ p_src_alias_guid,
+ dest_lid_ho, src_lid_ho,
+ comp_mask, &rev_path_parms);
+ path_parms.reversible = (rev_path_status == IB_SUCCESS);
+
+ /* did we get a Reversible Path compmask ? */
+ /*
+ NOTE that if the reversible component = 0, it is a don't care
+ rather then requiring non-reversible paths ...
+ see Vol1 Ver1.2 p900 l16
+ */
+ if (comp_mask & IB_MPR_COMPMASK_REVERSIBLE) {
+ if ((!path_parms.reversible && (p_mpr->num_path & 0x80))) {
+ OSM_LOG(sa->p_log, OSM_LOG_DEBUG,
+ "Requested reversible path but failed to get one\n");
+
+ free(p_pr_item);
+ p_pr_item = NULL;
+ goto Exit;
+ }
+ }
+
+ p_pr_item->resp.mpr_rec.p_src_port = p_src_alias_guid->p_base_port;
+ p_pr_item->resp.mpr_rec.p_dest_port = p_dest_alias_guid->p_base_port;
+ p_pr_item->resp.mpr_rec.hops = path_parms.hops;
+
+ mpr_rcv_build_pr(sa, p_src_alias_guid, p_dest_alias_guid, src_lid_ho,
+ dest_lid_ho, preference, &path_parms,
+ &p_pr_item->resp.mpr_rec.path_rec);
+
+Exit:
+ OSM_LOG_EXIT(sa->p_log);
+ return p_pr_item;
+}
+
+static uint32_t mpr_rcv_get_port_pair_paths(IN osm_sa_t * sa,
+ IN const ib_multipath_rec_t * p_mpr,
+ IN const osm_port_t * p_req_port,
+ IN const osm_alias_guid_t * p_src_alias_guid,
+ IN const osm_alias_guid_t * p_dest_alias_guid,
+ IN const uint32_t rem_paths,
+ IN const ib_net64_t comp_mask,
+ IN cl_qlist_t * p_list)
+{
+ osm_sa_item_t *p_pr_item;
+ uint16_t src_lid_min_ho;
+ uint16_t src_lid_max_ho;
+ uint16_t dest_lid_min_ho;
+ uint16_t dest_lid_max_ho;
+ uint16_t src_lid_ho;
+ uint16_t dest_lid_ho;
+ uint32_t path_num = 0;
+ uint8_t preference;
+ unsigned src_offset, dest_offset;
+
+ OSM_LOG_ENTER(sa->p_log);
+
+ OSM_LOG(sa->p_log, OSM_LOG_DEBUG,
+ "Src port 0x%016" PRIx64 ", Dst port 0x%016" PRIx64 "\n",
+ cl_ntoh64(p_src_alias_guid->alias_guid),
+ cl_ntoh64(p_dest_alias_guid->alias_guid));
+
+ /* Check that the req_port, src_port and dest_port all share a
+ pkey. The check is done on the default physical port of the ports. */
+ if (osm_port_share_pkey(sa->p_log, p_req_port,
+ p_src_alias_guid->p_base_port,
+ sa->p_subn->opt.allow_both_pkeys) == FALSE
+ || osm_port_share_pkey(sa->p_log, p_req_port,
+ p_dest_alias_guid->p_base_port,
+ sa->p_subn->opt.allow_both_pkeys) == FALSE
+ || osm_port_share_pkey(sa->p_log, p_src_alias_guid->p_base_port,
+ p_dest_alias_guid->p_base_port,
+ sa->p_subn->opt.allow_both_pkeys) == FALSE)
+ /* One of the pairs doesn't share a pkey so the path is disqualified. */
+ goto Exit;
+
+ /*
+ We shouldn't be here if the paths are disqualified in some way...
+ Thus, we assume every possible connection is valid.
+
+ We desire to return high-quality paths first.
+ In OpenSM, higher quality mean least overlap with other paths.
+ This is acheived in practice by returning paths with
+ different LID value on each end, which means these
+ paths are more redundant that paths with the same LID repeated
+ on one side. For example, in OpenSM the paths between two
+ endpoints with LMC = 1 might be as follows:
+
+ Port A, LID 1 <-> Port B, LID 3
+ Port A, LID 1 <-> Port B, LID 4
+ Port A, LID 2 <-> Port B, LID 3
+ Port A, LID 2 <-> Port B, LID 4
+
+ The OpenSM unicast routing algorithms attempt to disperse each path
+ to as varied a physical path as is reasonable. 1<->3 and 1<->4 have
+ more physical overlap (hence less redundancy) than 1<->3 and 2<->4.
+
+ OpenSM ranks paths in three preference groups:
+
+ Preference Value Description
+ ---------------- -------------------------------------------
+ 0 Redundant in both directions with other
+ pref value = 0 paths
+
+ 1 Redundant in one direction with other
+ pref value = 0 and pref value = 1 paths
+
+ 2 Not redundant in either direction with
+ other paths
+
+ 3-FF Unused
+
+ SA clients don't need to know these details, only that the lower
+ preference paths are preferred, as stated in the spec. The paths
+ may not actually be physically redundant depending on the topology
+ of the subnet, but the point of LMC > 0 is to offer redundancy,
+ so I assume the subnet is physically appropriate for the specified
+ LMC value. A more advanced implementation could inspect for physical
+ redundancy, but I'm not going to bother with that now.
+ */
+
+ osm_port_get_lid_range_ho(p_src_alias_guid->p_base_port,
+ &src_lid_min_ho, &src_lid_max_ho);
+ osm_port_get_lid_range_ho(p_dest_alias_guid->p_base_port,
+ &dest_lid_min_ho, &dest_lid_max_ho);
+
+ OSM_LOG(sa->p_log, OSM_LOG_DEBUG, "Src LID [%u-%u], Dest LID [%u-%u]\n",
+ src_lid_min_ho, src_lid_max_ho,
+ dest_lid_min_ho, dest_lid_max_ho);
+
+ src_lid_ho = src_lid_min_ho;
+ dest_lid_ho = dest_lid_min_ho;
+
+ /*
+ Preferred paths come first in OpenSM
+ */
+ preference = 0;
+
+ while (path_num < rem_paths) {
+ /*
+ These paths are "fully redundant"
+ */
+ p_pr_item = mpr_rcv_get_lid_pair_path(sa, p_mpr,
+ p_src_alias_guid,
+ p_dest_alias_guid,
+ src_lid_ho, dest_lid_ho,
+ comp_mask, preference);
+
+ if (p_pr_item) {
+ cl_qlist_insert_tail(p_list, &p_pr_item->list_item);
+ ++path_num;
+ }
+
+ if (++src_lid_ho > src_lid_max_ho)
+ break;
+
+ if (++dest_lid_ho > dest_lid_max_ho)
+ break;
+ }
+
+ /*
+ Check if we've accumulated all the paths that the user cares to see
+ */
+ if (path_num == rem_paths)
+ goto Exit;
+
+ /*
+ Don't bother reporting preference 1 paths for now.
+ It's more trouble than it's worth and can only occur
+ if ports have different LMC values, which isn't supported
+ by OpenSM right now anyway.
+ */
+ preference = 2;
+ src_lid_ho = src_lid_min_ho;
+ dest_lid_ho = dest_lid_min_ho;
+ src_offset = 0;
+ dest_offset = 0;
+
+ /*
+ Iterate over the remaining paths
+ */
+ while (path_num < rem_paths) {
+ dest_offset++;
+ dest_lid_ho++;
+
+ if (dest_lid_ho > dest_lid_max_ho) {
+ src_offset++;
+ src_lid_ho++;
+
+ if (src_lid_ho > src_lid_max_ho)
+ break; /* done */
+
+ dest_offset = 0;
+ dest_lid_ho = dest_lid_min_ho;
+ }
+
+ /*
+ These paths are "fully non-redundant" with paths already
+ identified above and consequently not of much value.
+
+ Don't return paths we already identified above, as indicated
+ by the offset values being equal.
+ */
+ if (src_offset == dest_offset)
+ continue; /* already reported */
+
+ p_pr_item = mpr_rcv_get_lid_pair_path(sa, p_mpr,
+ p_src_alias_guid,
+ p_dest_alias_guid,
+ src_lid_ho, dest_lid_ho,
+ comp_mask, preference);
+
+ if (p_pr_item) {
+ cl_qlist_insert_tail(p_list, &p_pr_item->list_item);
+ ++path_num;
+ }
+ }
+
+Exit:
+ OSM_LOG_EXIT(sa->p_log);
+ return path_num;
+}
+
+#undef min
+#define min(x,y) (((x) < (y)) ? (x) : (y))
+
+static osm_sa_item_t *mpr_rcv_get_apm_port_pair_paths(IN osm_sa_t * sa,
+ IN const
+ ib_multipath_rec_t *
+ p_mpr,
+ IN const osm_alias_guid_t *
+ p_src_alias_guid,
+ IN const osm_alias_guid_t *
+ p_dest_alias_guid,
+ IN int base_offs,
+ IN const ib_net64_t
+ comp_mask,
+ IN cl_qlist_t * p_list)
+{
+ osm_sa_item_t *p_pr_item = 0;
+ uint16_t src_lid_min_ho;
+ uint16_t src_lid_max_ho;
+ uint16_t dest_lid_min_ho;
+ uint16_t dest_lid_max_ho;
+ uint16_t src_lid_ho;
+ uint16_t dest_lid_ho;
+ unsigned iterations;
+ int src_lids, dest_lids;
+
+ OSM_LOG_ENTER(sa->p_log);
+
+ OSM_LOG(sa->p_log, OSM_LOG_DEBUG, "Src port 0x%016" PRIx64 ", "
+ "Dst port 0x%016" PRIx64 ", base offs %d\n",
+ cl_ntoh64(p_src_alias_guid->alias_guid),
+ cl_ntoh64(p_dest_alias_guid->alias_guid),
+ base_offs);
+
+ osm_port_get_lid_range_ho(p_src_alias_guid->p_base_port,
+ &src_lid_min_ho, &src_lid_max_ho);
+ osm_port_get_lid_range_ho(p_dest_alias_guid->p_base_port,
+ &dest_lid_min_ho, &dest_lid_max_ho);
+
+ src_lid_ho = src_lid_min_ho;
+ dest_lid_ho = dest_lid_min_ho;
+
+ src_lids = src_lid_max_ho - src_lid_min_ho + 1;
+ dest_lids = dest_lid_max_ho - dest_lid_min_ho + 1;
+
+ src_lid_ho += base_offs % src_lids;
+ dest_lid_ho += base_offs % dest_lids;
+
+ OSM_LOG(sa->p_log, OSM_LOG_DEBUG,
+ "Src LIDs [%u-%u] hashed %u, "
+ "Dest LIDs [%u-%u] hashed %u\n",
+ src_lid_min_ho, src_lid_max_ho, src_lid_ho,
+ dest_lid_min_ho, dest_lid_max_ho, dest_lid_ho);
+
+ iterations = min(src_lids, dest_lids);
+
+ while (iterations--) {
+ /*
+ These paths are "fully redundant"
+ */
+ p_pr_item = mpr_rcv_get_lid_pair_path(sa, p_mpr,
+ p_src_alias_guid,
+ p_dest_alias_guid,
+ src_lid_ho, dest_lid_ho,
+ comp_mask, 0);
+
+ if (p_pr_item) {
+ OSM_LOG(sa->p_log, OSM_LOG_DEBUG,
+ "Found matching path from Src LID %u to Dest LID %u with %d hops\n",
+ src_lid_ho, dest_lid_ho, p_pr_item->resp.mpr_rec.hops);
+ break;
+ }
+
+ if (++src_lid_ho > src_lid_max_ho)
+ src_lid_ho = src_lid_min_ho;
+
+ if (++dest_lid_ho > dest_lid_max_ho)
+ dest_lid_ho = dest_lid_min_ho;
+ }
+
+ OSM_LOG_EXIT(sa->p_log);
+ return p_pr_item;
+}
+
+static ib_net16_t mpr_rcv_get_gids(IN osm_sa_t * sa, IN const ib_gid_t * gids,
+ IN int ngids, IN int is_sgid,
+ OUT osm_alias_guid_t ** pp_alias_guid)
+{
+ osm_alias_guid_t *p_alias_guid;
+ ib_net16_t ib_status = IB_SUCCESS;
+ int i;
+
+ OSM_LOG_ENTER(sa->p_log);
+
+ for (i = 0; i < ngids; i++, gids++) {
+ if (!ib_gid_is_link_local(gids)) {
+ if ((is_sgid && ib_gid_is_multicast(gids)) ||
+ (ib_gid_get_subnet_prefix(gids) !=
+ sa->p_subn->opt.subnet_prefix)) {
+ /*
+ This 'error' is the client's fault (bad gid)
+ so don't enter it as an error in our own log.
+ Return an error response to the client.
+ */
+ OSM_LOG(sa->p_log, OSM_LOG_VERBOSE, "ERR 451B: "
+ "%sGID 0x%016" PRIx64
+ " is multicast or non local subnet prefix\n",
+ is_sgid ? "S" : "D",
+ cl_ntoh64(gids->unicast.prefix));
+
+ ib_status = IB_SA_MAD_STATUS_INVALID_GID;
+ goto Exit;
+ }
+ }
+
+ p_alias_guid =
+ osm_get_alias_guid_by_guid(sa->p_subn,
+ gids->unicast.interface_id);
+ if (!p_alias_guid) {
+ /*
+ This 'error' is the client's fault (bad gid) so
+ don't enter it as an error in our own log.
+ Return an error response to the client.
+ */
+ OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 4506: "
+ "No port with GUID 0x%016" PRIx64 "\n",
+ cl_ntoh64(gids->unicast.interface_id));
+
+ ib_status = IB_SA_MAD_STATUS_INVALID_GID;
+ goto Exit;
+ }
+
+ pp_alias_guid[i] = p_alias_guid;
+ }
+
+Exit:
+ OSM_LOG_EXIT(sa->p_log);
+
+ return ib_status;
+}
+
+static ib_net16_t mpr_rcv_get_end_points(IN osm_sa_t * sa,
+ IN const osm_madw_t * p_madw,
+ OUT osm_alias_guid_t ** pp_alias_guids,
+ OUT int *nsrc, OUT int *ndest)
+{
+ const ib_multipath_rec_t *p_mpr;
+ const ib_sa_mad_t *p_sa_mad;
+ ib_net64_t comp_mask;
+ ib_net16_t sa_status = IB_SA_MAD_STATUS_SUCCESS;
+ ib_gid_t *gids;
+
+ OSM_LOG_ENTER(sa->p_log);
+
+ /*
+ Determine what fields are valid and then get a pointer
+ to the source and destination port objects, if possible.
+ */
+ p_sa_mad = osm_madw_get_sa_mad_ptr(p_madw);
+ p_mpr = (ib_multipath_rec_t *) ib_sa_mad_get_payload_ptr(p_sa_mad);
+ gids = (ib_gid_t *) p_mpr->gids;
+
+ comp_mask = p_sa_mad->comp_mask;
+
+ /*
+ Check a few easy disqualifying cases up front before getting
+ into the endpoints.
+ */
+ *nsrc = *ndest = 0;
+
+ if (comp_mask & IB_MPR_COMPMASK_SGIDCOUNT) {
+ *nsrc = p_mpr->sgid_count;
+ if (*nsrc > IB_MULTIPATH_MAX_GIDS)
+ *nsrc = IB_MULTIPATH_MAX_GIDS;
+ sa_status = mpr_rcv_get_gids(sa, gids, *nsrc, 1, pp_alias_guids);
+ if (sa_status != IB_SUCCESS)
+ goto Exit;
+ }
+
+ if (comp_mask & IB_MPR_COMPMASK_DGIDCOUNT) {
+ *ndest = p_mpr->dgid_count;
+ if (*ndest + *nsrc > IB_MULTIPATH_MAX_GIDS)
+ *ndest = IB_MULTIPATH_MAX_GIDS - *nsrc;
+ sa_status =
+ mpr_rcv_get_gids(sa, gids + *nsrc, *ndest, 0,
+ pp_alias_guids + *nsrc);
+ }
+
+Exit:
+ OSM_LOG_EXIT(sa->p_log);
+ return sa_status;
+}
+
+#define hash_lids(a, b, lmc) \
+ (((((a) >> (lmc)) << 4) | ((b) >> (lmc))) % 103)
+
+static void mpr_rcv_get_apm_paths(IN osm_sa_t * sa,
+ IN const ib_multipath_rec_t * p_mpr,
+ IN const osm_port_t * p_req_port,
+ IN osm_alias_guid_t ** _pp_alias_guids,
+ IN const ib_net64_t comp_mask,
+ IN cl_qlist_t * p_list)
+{
+ osm_alias_guid_t *pp_alias_guids[4];
+ osm_sa_item_t *matrix[2][2];
+ int base_offs, src_lid_ho, dest_lid_ho;
+ int sumA, sumB, minA, minB;
+
+ OSM_LOG_ENTER(sa->p_log);
+
+ /*
+ * We want to:
+ * 1. use different lid offsets (from base) for the resultant paths
+ * to increase the probability of redundant paths or in case
+ * of Clos - to ensure it (different offset => different spine!)
+ * 2. keep consistent paths no matter of direction and order of ports
+ * 3. distibute the lid offsets to balance the load
+ * So, we sort the ports (within the srcs, and within the dests),
+ * hash the lids of S0, D0 (after the sort), and call mpr_rcv_get_apm_port_pair_paths
+ * with base_lid for S0, D0 and base_lid + 1 for S1, D1. This way we will get
+ * always the same offsets - order independent, and make sure different spines are used.
+ * Note that the diagonals on a Clos have the same number of hops, so it doesn't
+ * really matter which diagonal we use.
+ */
+ if (_pp_alias_guids[0]->p_base_port->guid <
+ _pp_alias_guids[1]->p_base_port->guid) {
+ pp_alias_guids[0] = _pp_alias_guids[0];
+ pp_alias_guids[1] = _pp_alias_guids[1];
+ } else {
+ pp_alias_guids[0] = _pp_alias_guids[1];
+ pp_alias_guids[1] = _pp_alias_guids[0];
+ }
+ if (_pp_alias_guids[2]->p_base_port->guid <
+ _pp_alias_guids[3]->p_base_port->guid) {
+ pp_alias_guids[2] = _pp_alias_guids[2];
+ pp_alias_guids[3] = _pp_alias_guids[3];
+ } else {
+ pp_alias_guids[2] = _pp_alias_guids[3];
+ pp_alias_guids[3] = _pp_alias_guids[2];
+ }
+
+ src_lid_ho = osm_port_get_base_lid(pp_alias_guids[0]->p_base_port);
+ dest_lid_ho = osm_port_get_base_lid(pp_alias_guids[2]->p_base_port);
+
+ base_offs = src_lid_ho < dest_lid_ho ?
+ hash_lids(src_lid_ho, dest_lid_ho, sa->p_subn->opt.lmc) :
+ hash_lids(dest_lid_ho, src_lid_ho, sa->p_subn->opt.lmc);
+
+ matrix[0][0] =
+ mpr_rcv_get_apm_port_pair_paths(sa, p_mpr, pp_alias_guids[0],
+ pp_alias_guids[2], base_offs,
+ comp_mask, p_list);
+ matrix[0][1] =
+ mpr_rcv_get_apm_port_pair_paths(sa, p_mpr, pp_alias_guids[0],
+ pp_alias_guids[3], base_offs,
+ comp_mask, p_list);
+ matrix[1][0] =
+ mpr_rcv_get_apm_port_pair_paths(sa, p_mpr, pp_alias_guids[1],
+ pp_alias_guids[2], base_offs + 1,
+ comp_mask, p_list);
+ matrix[1][1] =
+ mpr_rcv_get_apm_port_pair_paths(sa, p_mpr, pp_alias_guids[1],
+ pp_alias_guids[3], base_offs + 1,
+ comp_mask, p_list);
+
+ OSM_LOG(sa->p_log, OSM_LOG_DEBUG, "APM matrix:\n"
+ "\t{0,0} 0x%X->0x%X (%d)\t| {0,1} 0x%X->0x%X (%d)\n"
+ "\t{1,0} 0x%X->0x%X (%d)\t| {1,1} 0x%X->0x%X (%d)\n",
+ matrix[0][0] ? matrix[0][0]->resp.mpr_rec.path_rec.slid : 0,
+ matrix[0][0] ? matrix[0][0]->resp.mpr_rec.path_rec.dlid : 0,
+ matrix[0][0] ? matrix[0][0]->resp.mpr_rec.hops : 0,
+ matrix[0][1] ? matrix[0][1]->resp.mpr_rec.path_rec.slid : 0,
+ matrix[0][1] ? matrix[0][1]->resp.mpr_rec.path_rec.dlid : 0,
+ matrix[0][1] ? matrix[0][1]->resp.mpr_rec.hops : 0,
+ matrix[1][0] ? matrix[1][0]->resp.mpr_rec.path_rec.slid : 0,
+ matrix[1][0] ? matrix[1][0]->resp.mpr_rec.path_rec.dlid : 0,
+ matrix[1][0] ? matrix[1][0]->resp.mpr_rec.hops : 0,
+ matrix[1][1] ? matrix[1][1]->resp.mpr_rec.path_rec.slid : 0,
+ matrix[1][1] ? matrix[1][1]->resp.mpr_rec.path_rec.dlid : 0,
+ matrix[1][1] ? matrix[1][1]->resp.mpr_rec.hops : 0);
+
+ sumA = minA = sumB = minB = 0;
+
+ /* check diagonal A {(0,0), (1,1)} */
+ if (matrix[0][0]) {
+ sumA += matrix[0][0]->resp.mpr_rec.hops;
+ minA = matrix[0][0]->resp.mpr_rec.hops;
+ }
+ if (matrix[1][1]) {
+ sumA += matrix[1][1]->resp.mpr_rec.hops;
+ if (minA)
+ minA = min(minA, matrix[1][1]->resp.mpr_rec.hops);
+ else
+ minA = matrix[1][1]->resp.mpr_rec.hops;
+ }
+
+ /* check diagonal B {(0,1), (1,0)} */
+ if (matrix[0][1]) {
+ sumB += matrix[0][1]->resp.mpr_rec.hops;
+ minB = matrix[0][1]->resp.mpr_rec.hops;
+ }
+ if (matrix[1][0]) {
+ sumB += matrix[1][0]->resp.mpr_rec.hops;
+ if (minB)
+ minB = min(minB, matrix[1][0]->resp.mpr_rec.hops);
+ else
+ minB = matrix[1][0]->resp.mpr_rec.hops;
+ }
+
+ /* and the winner is... */
+ if (minA <= minB || (minA == minB && sumA < sumB)) {
+ /* Diag A */
+ OSM_LOG(sa->p_log, OSM_LOG_DEBUG,
+ "Diag {0,0} & {1,1} is the best:\n"
+ "\t{0,0} 0x%X->0x%X (%d)\t & {1,1} 0x%X->0x%X (%d)\n",
+ matrix[0][0] ? matrix[0][0]->resp.mpr_rec.path_rec.slid : 0,
+ matrix[0][0] ? matrix[0][0]->resp.mpr_rec.path_rec.dlid : 0,
+ matrix[0][0] ? matrix[0][0]->resp.mpr_rec.hops : 0,
+ matrix[1][1] ? matrix[1][1]->resp.mpr_rec.path_rec.slid : 0,
+ matrix[1][1] ? matrix[1][1]->resp.mpr_rec.path_rec.dlid : 0,
+ matrix[1][1] ? matrix[1][1]->resp.mpr_rec.hops : 0);
+ if (matrix[0][0])
+ cl_qlist_insert_tail(p_list, &matrix[0][0]->list_item);
+ if (matrix[1][1])
+ cl_qlist_insert_tail(p_list, &matrix[1][1]->list_item);
+ free(matrix[0][1]);
+ free(matrix[1][0]);
+ } else {
+ /* Diag B */
+ OSM_LOG(sa->p_log, OSM_LOG_DEBUG,
+ "Diag {0,1} & {1,0} is the best:\n"
+ "\t{0,1} 0x%X->0x%X (%d)\t & {1,0} 0x%X->0x%X (%d)\n",
+ matrix[0][1] ? matrix[0][1]->resp.mpr_rec.path_rec.slid : 0,
+ matrix[0][1] ? matrix[0][1]->resp.mpr_rec.path_rec.dlid : 0,
+ matrix[0][1] ? matrix[0][1]->resp.mpr_rec.hops : 0,
+ matrix[1][0] ? matrix[1][0]->resp.mpr_rec.path_rec.slid : 0,
+ matrix[1][0] ? matrix[1][0]->resp.mpr_rec.path_rec.dlid: 0,
+ matrix[1][0] ? matrix[1][0]->resp.mpr_rec.hops : 0);
+ if (matrix[0][1])
+ cl_qlist_insert_tail(p_list, &matrix[0][1]->list_item);
+ if (matrix[1][0])
+ cl_qlist_insert_tail(p_list, &matrix[1][0]->list_item);
+ free(matrix[0][0]);
+ free(matrix[1][1]);
+ }
+
+ OSM_LOG_EXIT(sa->p_log);
+}
+
+static void mpr_rcv_process_pairs(IN osm_sa_t * sa,
+ IN const ib_multipath_rec_t * p_mpr,
+ IN osm_port_t * p_req_port,
+ IN osm_alias_guid_t ** pp_alias_guids,
+ IN const int nsrc, IN int ndest,
+ IN ib_net64_t comp_mask,
+ IN cl_qlist_t * p_list)
+{
+ osm_alias_guid_t **pp_src_alias_guid, **pp_es;
+ osm_alias_guid_t **pp_dest_alias_guid, **pp_ed;
+ uint32_t max_paths, num_paths, total_paths = 0;
+
+ OSM_LOG_ENTER(sa->p_log);
+
+ if (comp_mask & IB_MPR_COMPMASK_NUMBPATH)
+ max_paths = p_mpr->num_path & 0x7F;
+ else
+ max_paths = OSM_SA_MPR_MAX_NUM_PATH;
+
+ for (pp_src_alias_guid = pp_alias_guids, pp_es = pp_alias_guids + nsrc;
+ pp_src_alias_guid < pp_es; pp_src_alias_guid++) {
+ for (pp_dest_alias_guid = pp_es, pp_ed = pp_es + ndest;
+ pp_dest_alias_guid < pp_ed; pp_dest_alias_guid++) {
+ num_paths =
+ mpr_rcv_get_port_pair_paths(sa, p_mpr, p_req_port,
+ *pp_src_alias_guid,
+ *pp_dest_alias_guid,
+ max_paths - total_paths,
+ comp_mask, p_list);
+ total_paths += num_paths;
+ OSM_LOG(sa->p_log, OSM_LOG_DEBUG,
+ "%d paths %d total paths %d max paths\n",
+ num_paths, total_paths, max_paths);
+ /* Just take first NumbPaths found */
+ if (total_paths >= max_paths)
+ goto Exit;
+ }
+ }
+
+Exit:
+ OSM_LOG_EXIT(sa->p_log);
+}
+
+void osm_mpr_rcv_process(IN void *context, IN void *data)
+{
+ osm_sa_t *sa = context;
+ osm_madw_t *p_madw = data;
+ const ib_multipath_rec_t *p_mpr;
+ ib_sa_mad_t *p_sa_mad;
+ osm_port_t *requester_port;
+ osm_alias_guid_t *pp_alias_guids[IB_MULTIPATH_MAX_GIDS];
+ cl_qlist_t pr_list;
+ ib_net16_t sa_status;
+ int nsrc, ndest;
+ uint8_t rate, mtu;
+
+ OSM_LOG_ENTER(sa->p_log);
+
+ CL_ASSERT(p_madw);
+
+ p_sa_mad = osm_madw_get_sa_mad_ptr(p_madw);
+ p_mpr = (ib_multipath_rec_t *) ib_sa_mad_get_payload_ptr(p_sa_mad);
+
+ CL_ASSERT(p_sa_mad->attr_id == IB_MAD_ATTR_MULTIPATH_RECORD);
+
+ if ((p_sa_mad->rmpp_flags & IB_RMPP_FLAG_ACTIVE) != IB_RMPP_FLAG_ACTIVE) {
+ OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 4510: "
+ "Invalid request since RMPP_FLAG_ACTIVE is not set\n");
+ osm_sa_send_error(sa, p_madw, IB_SA_MAD_STATUS_REQ_INVALID);
+ goto Exit;
+ }
+
+ /* we only support SubnAdmGetMulti method */
+ if (p_sa_mad->method != IB_MAD_METHOD_GETMULTI) {
+ OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 4513: "
+ "Unsupported Method (%s) for MultiPathRecord request\n",
+ ib_get_sa_method_str(p_sa_mad->method));
+ osm_sa_send_error(sa, p_madw, IB_MAD_STATUS_UNSUP_METHOD_ATTR);
+ goto Exit;
+ }
+
+ if (OSM_LOG_IS_ACTIVE_V2(sa->p_log, OSM_LOG_DEBUG))
+ osm_dump_multipath_record_v2(sa->p_log, p_mpr, FILE_ID, OSM_LOG_DEBUG);
+
+ /* Make sure required components (S/DGIDCount) are supplied */
+ if (!(p_sa_mad->comp_mask & IB_MPR_COMPMASK_SGIDCOUNT) ||
+ !(p_sa_mad->comp_mask & IB_MPR_COMPMASK_DGIDCOUNT)) {
+ osm_sa_send_error(sa, p_madw, IB_SA_MAD_STATUS_INSUF_COMPS);
+ goto Exit;
+ }
+
+ /* Validate rate if supplied */
+ if ((p_sa_mad->comp_mask & IB_MPR_COMPMASK_RATESELEC) &&
+ (p_sa_mad->comp_mask & IB_MPR_COMPMASK_RATE)) {
+ rate = ib_multipath_rec_rate(p_mpr);
+ if (!ib_rate_is_valid(rate)) {
+ osm_sa_send_error(sa, p_madw,
+ IB_SA_MAD_STATUS_REQ_INVALID);
+ goto Exit;
+ }
+ }
+ /* Validate MTU if supplied */
+ if ((p_sa_mad->comp_mask & IB_MPR_COMPMASK_MTUSELEC) &&
+ (p_sa_mad->comp_mask & IB_MPR_COMPMASK_MTU)) {
+ mtu = ib_multipath_rec_mtu(p_mpr);
+ if (!ib_mtu_is_valid(mtu)) {
+ osm_sa_send_error(sa, p_madw,
+ IB_SA_MAD_STATUS_REQ_INVALID);
+ goto Exit;
+ }
+ }
+
+ /* Make sure either none or both ServiceID parameters are supplied */
+ if ((p_sa_mad->comp_mask & IB_MPR_COMPMASK_SERVICEID) != 0 &&
+ (p_sa_mad->comp_mask & IB_MPR_COMPMASK_SERVICEID) !=
+ IB_MPR_COMPMASK_SERVICEID) {
+ osm_sa_send_error(sa, p_madw, IB_SA_MAD_STATUS_INSUF_COMPS);
+ goto Exit;
+ }
+
+ cl_qlist_init(&pr_list);
+
+ /*
+ Most SA functions (including this one) are read-only on the
+ subnet object, so we grab the lock non-exclusively.
+ */
+ cl_plock_acquire(sa->p_lock);
+
+ /* update the requester physical port */
+ requester_port = osm_get_port_by_mad_addr(sa->p_log, sa->p_subn,
+ osm_madw_get_mad_addr_ptr
+ (p_madw));
+ if (requester_port == NULL) {
+ cl_plock_release(sa->p_lock);
+ OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 4517: "
+ "Cannot find requester physical port\n");
+ goto Exit;
+ }
+
+ OSM_LOG(sa->p_log, OSM_LOG_DEBUG,
+ "Requester port GUID 0x%" PRIx64 "\n",
+ cl_ntoh64(osm_port_get_guid(requester_port)));
+
+ sa_status = mpr_rcv_get_end_points(sa, p_madw, pp_alias_guids,
+ &nsrc, &ndest);
+
+ if (sa_status != IB_SA_MAD_STATUS_SUCCESS || !nsrc || !ndest) {
+ cl_plock_release(sa->p_lock);
+ if (sa_status == IB_SA_MAD_STATUS_SUCCESS && (!nsrc || !ndest))
+ OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 4512: "
+ "mpr_rcv_get_end_points failed, # GIDs found; "
+ "src %d; dest %d)\n", nsrc, ndest);
+ if (sa_status == IB_SA_MAD_STATUS_SUCCESS)
+ osm_sa_send_error(sa, p_madw,
+ IB_SA_MAD_STATUS_REQ_INVALID);
+ else
+ osm_sa_send_error(sa, p_madw, sa_status);
+ goto Exit;
+ }
+
+ /* APM request */
+ if (nsrc == 2 && ndest == 2 && (p_mpr->num_path & 0x7F) == 2)
+ mpr_rcv_get_apm_paths(sa, p_mpr, requester_port, pp_alias_guids,
+ p_sa_mad->comp_mask, &pr_list);
+ else
+ mpr_rcv_process_pairs(sa, p_mpr, requester_port, pp_alias_guids,
+ nsrc, ndest, p_sa_mad->comp_mask,
+ &pr_list);
+
+ cl_plock_release(sa->p_lock);
+
+ /* o15-0.2.7: If MultiPath is supported, then SA shall respond to a
+ SubnAdmGetMulti() containing a valid MultiPathRecord attribute with
+ a set of zero or more PathRecords satisfying the constraints
+ indicated in the MultiPathRecord received. The PathRecord Attribute
+ ID shall be used in the response.
+ */
+ p_sa_mad->attr_id = IB_MAD_ATTR_PATH_RECORD;
+ osm_sa_respond(sa, p_madw, sizeof(ib_path_rec_t), &pr_list);
+
+Exit:
+ OSM_LOG_EXIT(sa->p_log);
+}
+#endif
diff --git a/contrib/ofed/opensm/opensm/osm_sa_node_record.c b/contrib/ofed/opensm/opensm/osm_sa_node_record.c
new file mode 100644
index 0000000..0cb0ffb
--- /dev/null
+++ b/contrib/ofed/opensm/opensm/osm_sa_node_record.c
@@ -0,0 +1,352 @@
+/*
+ * Copyright (c) 2004-2009 Voltaire, Inc. All rights reserved.
+ * Copyright (c) 2002-2010 Mellanox Technologies LTD. All rights reserved.
+ * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
+ * Copyright (c) 2013 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+/*
+ * Abstract:
+ * Implementation of osm_nr_rcv_t.
+ * This object represents the NodeInfo Receiver object.
+ * This object is part of the opensm family of objects.
+ */
+
+#if HAVE_CONFIG_H
+# include <config.h>
+#endif /* HAVE_CONFIG_H */
+
+#include <string.h>
+#include <iba/ib_types.h>
+#include <complib/cl_debug.h>
+#include <complib/cl_qlist.h>
+#include <opensm/osm_file_ids.h>
+#define FILE_ID OSM_FILE_SA_NODE_RECORD_C
+#include <vendor/osm_vendor_api.h>
+#include <opensm/osm_node.h>
+#include <opensm/osm_helper.h>
+#include <opensm/osm_pkey.h>
+#include <opensm/osm_sa.h>
+
+#define SA_NR_RESP_SIZE SA_ITEM_RESP_SIZE(node_rec)
+
+typedef struct osm_nr_search_ctxt {
+ const ib_node_record_t *p_rcvd_rec;
+ ib_net64_t comp_mask;
+ cl_qlist_t *p_list;
+ osm_sa_t *sa;
+ const osm_physp_t *p_req_physp;
+} osm_nr_search_ctxt_t;
+
+static ib_api_status_t nr_rcv_new_nr(osm_sa_t * sa,
+ IN const osm_node_t * p_node,
+ IN cl_qlist_t * p_list,
+ IN ib_net64_t port_guid, IN ib_net16_t lid,
+ IN unsigned int port_num)
+{
+ osm_sa_item_t *p_rec_item;
+ ib_api_status_t status = IB_SUCCESS;
+
+ OSM_LOG_ENTER(sa->p_log);
+
+ p_rec_item = malloc(SA_NR_RESP_SIZE);
+ if (p_rec_item == NULL) {
+ OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 1D02: "
+ "rec_item alloc failed\n");
+ status = IB_INSUFFICIENT_RESOURCES;
+ goto Exit;
+ }
+
+ OSM_LOG(sa->p_log, OSM_LOG_DEBUG,
+ "New NodeRecord: node 0x%016" PRIx64
+ ", port 0x%016" PRIx64 ", lid %u\n",
+ cl_ntoh64(osm_node_get_node_guid(p_node)),
+ cl_ntoh64(port_guid), cl_ntoh16(lid));
+
+ memset(p_rec_item, 0, SA_NR_RESP_SIZE);
+
+ p_rec_item->resp.node_rec.lid = lid;
+
+ p_rec_item->resp.node_rec.node_info = p_node->node_info;
+ p_rec_item->resp.node_rec.node_info.port_guid = port_guid;
+ p_rec_item->resp.node_rec.node_info.port_num_vendor_id =
+ (p_rec_item->resp.node_rec.node_info.port_num_vendor_id & IB_NODE_INFO_VEND_ID_MASK) |
+ ((port_num << IB_NODE_INFO_PORT_NUM_SHIFT) & IB_NODE_INFO_PORT_NUM_MASK);
+ memcpy(&(p_rec_item->resp.node_rec.node_desc), &(p_node->node_desc),
+ IB_NODE_DESCRIPTION_SIZE);
+ cl_qlist_insert_tail(p_list, &p_rec_item->list_item);
+
+Exit:
+ OSM_LOG_EXIT(sa->p_log);
+ return status;
+}
+
+static void nr_rcv_create_nr(IN osm_sa_t * sa, IN osm_node_t * p_node,
+ IN cl_qlist_t * p_list,
+ IN ib_net64_t const match_port_guid,
+ IN ib_net16_t const match_lid,
+ IN unsigned int const match_port_num,
+ IN const osm_physp_t * p_req_physp,
+ IN const ib_net64_t comp_mask)
+{
+ const osm_physp_t *p_physp;
+ uint8_t port_num;
+ uint8_t num_ports;
+ uint16_t match_lid_ho;
+ ib_net16_t base_lid;
+ ib_net16_t base_lid_ho;
+ ib_net16_t max_lid_ho;
+ uint8_t lmc;
+ ib_net64_t port_guid;
+
+ OSM_LOG_ENTER(sa->p_log);
+
+ OSM_LOG(sa->p_log, OSM_LOG_DEBUG,
+ "Looking for NodeRecord with LID: %u GUID: 0x%016"
+ PRIx64 "\n", cl_ntoh16(match_lid), cl_ntoh64(match_port_guid));
+
+ /*
+ For switches, do not return the NodeInfo record
+ for each port on the switch, just for port 0.
+ */
+ if (osm_node_get_type(p_node) == IB_NODE_TYPE_SWITCH)
+ num_ports = 1;
+ else
+ num_ports = osm_node_get_num_physp(p_node);
+
+ for (port_num = 0; port_num < num_ports; port_num++) {
+ p_physp = osm_node_get_physp_ptr(p_node, port_num);
+ if (!p_physp)
+ continue;
+
+ /* Check to see if the found p_physp and the requester physp
+ share a pkey. If not - continue */
+ if (!osm_physp_share_pkey(sa->p_log, p_physp, p_req_physp,
+ sa->p_subn->opt.allow_both_pkeys))
+ continue;
+
+ port_guid = osm_physp_get_port_guid(p_physp);
+
+ if ((comp_mask & IB_NR_COMPMASK_PORTGUID)
+ && (port_guid != match_port_guid))
+ continue;
+
+ base_lid = osm_physp_get_base_lid(p_physp);
+
+ if (comp_mask & IB_NR_COMPMASK_LID) {
+ base_lid_ho = cl_ntoh16(base_lid);
+ lmc = osm_physp_get_lmc(p_physp);
+ max_lid_ho = (uint16_t) (base_lid_ho + (1 << lmc) - 1);
+ match_lid_ho = cl_ntoh16(match_lid);
+
+ /*
+ We validate that the lid belongs to this node.
+ */
+ OSM_LOG(sa->p_log, OSM_LOG_DEBUG,
+ "Comparing LID: %u <= %u <= %u\n",
+ base_lid_ho, match_lid_ho, max_lid_ho);
+
+ if (match_lid_ho < base_lid_ho
+ || match_lid_ho > max_lid_ho)
+ continue;
+ }
+
+ if ((comp_mask & IB_NR_COMPMASK_PORTNUM) &&
+ (port_num != match_port_num))
+ continue;
+
+ nr_rcv_new_nr(sa, p_node, p_list, port_guid, base_lid, port_num);
+ }
+
+ OSM_LOG_EXIT(sa->p_log);
+}
+
+static void nr_rcv_by_comp_mask(IN cl_map_item_t * p_map_item, IN void *context)
+{
+ const osm_nr_search_ctxt_t *p_ctxt = context;
+ osm_node_t *p_node = (osm_node_t *) p_map_item;
+ const ib_node_record_t *const p_rcvd_rec = p_ctxt->p_rcvd_rec;
+ const osm_physp_t *const p_req_physp = p_ctxt->p_req_physp;
+ osm_sa_t *sa = p_ctxt->sa;
+ ib_net64_t comp_mask = p_ctxt->comp_mask;
+ ib_net64_t match_port_guid = 0;
+ ib_net16_t match_lid = 0;
+ unsigned int match_port_num = 0;
+
+ OSM_LOG_ENTER(p_ctxt->sa->p_log);
+
+ osm_dump_node_info_v2(p_ctxt->sa->p_log, &p_node->node_info,
+ FILE_ID, OSM_LOG_DEBUG);
+
+ if (comp_mask & IB_NR_COMPMASK_LID)
+ match_lid = p_rcvd_rec->lid;
+
+ if (comp_mask & IB_NR_COMPMASK_NODEGUID) {
+ OSM_LOG(sa->p_log, OSM_LOG_DEBUG,
+ "Looking for node 0x%016" PRIx64
+ ", found 0x%016" PRIx64 "\n",
+ cl_ntoh64(p_rcvd_rec->node_info.node_guid),
+ cl_ntoh64(osm_node_get_node_guid(p_node)));
+
+ if (p_node->node_info.node_guid !=
+ p_rcvd_rec->node_info.node_guid)
+ goto Exit;
+ }
+
+ if (comp_mask & IB_NR_COMPMASK_PORTGUID)
+ match_port_guid = p_rcvd_rec->node_info.port_guid;
+
+ if ((comp_mask & IB_NR_COMPMASK_SYSIMAGEGUID) &&
+ p_node->node_info.sys_guid != p_rcvd_rec->node_info.sys_guid)
+ goto Exit;
+
+ if ((comp_mask & IB_NR_COMPMASK_BASEVERSION) &&
+ p_node->node_info.base_version !=
+ p_rcvd_rec->node_info.base_version)
+ goto Exit;
+
+ if ((comp_mask & IB_NR_COMPMASK_CLASSVERSION) &&
+ p_node->node_info.class_version !=
+ p_rcvd_rec->node_info.class_version)
+ goto Exit;
+
+ if ((comp_mask & IB_NR_COMPMASK_NODETYPE) &&
+ p_node->node_info.node_type != p_rcvd_rec->node_info.node_type)
+ goto Exit;
+
+ if ((comp_mask & IB_NR_COMPMASK_NUMPORTS) &&
+ p_node->node_info.num_ports != p_rcvd_rec->node_info.num_ports)
+ goto Exit;
+
+ if ((comp_mask & IB_NR_COMPMASK_PARTCAP) &&
+ p_node->node_info.partition_cap !=
+ p_rcvd_rec->node_info.partition_cap)
+ goto Exit;
+
+ if ((comp_mask & IB_NR_COMPMASK_DEVID) &&
+ p_node->node_info.device_id != p_rcvd_rec->node_info.device_id)
+ goto Exit;
+
+ if ((comp_mask & IB_NR_COMPMASK_REV) &&
+ p_node->node_info.revision !=
+ p_rcvd_rec->node_info.revision)
+ goto Exit;
+
+ if (comp_mask & IB_NR_COMPMASK_PORTNUM)
+ match_port_num = ib_node_info_get_local_port_num(&p_rcvd_rec->node_info);
+
+ if ((comp_mask & IB_NR_COMPMASK_VENDID) &&
+ ib_node_info_get_vendor_id(&p_node->node_info) !=
+ ib_node_info_get_vendor_id(&p_rcvd_rec->node_info))
+ goto Exit;
+
+ if ((comp_mask & IB_NR_COMPMASK_NODEDESC) &&
+ strncmp((char *)&p_node->node_desc, (char *)&p_rcvd_rec->node_desc,
+ sizeof(ib_node_desc_t)))
+ goto Exit;
+
+ nr_rcv_create_nr(sa, p_node, p_ctxt->p_list, match_port_guid,
+ match_lid, match_port_num, p_req_physp, comp_mask);
+
+Exit:
+ OSM_LOG_EXIT(p_ctxt->sa->p_log);
+}
+
+void osm_nr_rcv_process(IN void *ctx, IN void *data)
+{
+ osm_sa_t *sa = ctx;
+ osm_madw_t *p_madw = data;
+ const ib_sa_mad_t *p_rcvd_mad;
+ const ib_node_record_t *p_rcvd_rec;
+ cl_qlist_t rec_list;
+ osm_nr_search_ctxt_t context;
+ osm_physp_t *p_req_physp;
+
+ CL_ASSERT(sa);
+
+ OSM_LOG_ENTER(sa->p_log);
+
+ CL_ASSERT(p_madw);
+
+ p_rcvd_mad = osm_madw_get_sa_mad_ptr(p_madw);
+ p_rcvd_rec = (ib_node_record_t *) ib_sa_mad_get_payload_ptr(p_rcvd_mad);
+
+ CL_ASSERT(p_rcvd_mad->attr_id == IB_MAD_ATTR_NODE_RECORD);
+
+ /* we only support SubnAdmGet and SubnAdmGetTable methods */
+ if (p_rcvd_mad->method != IB_MAD_METHOD_GET &&
+ p_rcvd_mad->method != IB_MAD_METHOD_GETTABLE) {
+ OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 1D05: "
+ "Unsupported Method (%s) for NodeRecord request\n",
+ ib_get_sa_method_str(p_rcvd_mad->method));
+ osm_sa_send_error(sa, p_madw, IB_MAD_STATUS_UNSUP_METHOD_ATTR);
+ goto Exit;
+ }
+
+ cl_plock_acquire(sa->p_lock);
+
+ /* update the requester physical port */
+ p_req_physp = osm_get_physp_by_mad_addr(sa->p_log, sa->p_subn,
+ osm_madw_get_mad_addr_ptr
+ (p_madw));
+ if (p_req_physp == NULL) {
+ cl_plock_release(sa->p_lock);
+ OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 1D04: "
+ "Cannot find requester physical port\n");
+ goto Exit;
+ }
+
+ if (OSM_LOG_IS_ACTIVE_V2(sa->p_log, OSM_LOG_DEBUG)) {
+ OSM_LOG(sa->p_log, OSM_LOG_DEBUG,
+ "Requester port GUID 0x%" PRIx64 "\n",
+ cl_ntoh64(osm_physp_get_port_guid(p_req_physp)));
+ osm_dump_node_record_v2(sa->p_log, p_rcvd_rec, FILE_ID, OSM_LOG_DEBUG);
+ }
+
+ cl_qlist_init(&rec_list);
+
+ context.p_rcvd_rec = p_rcvd_rec;
+ context.p_list = &rec_list;
+ context.comp_mask = p_rcvd_mad->comp_mask;
+ context.sa = sa;
+ context.p_req_physp = p_req_physp;
+
+ cl_qmap_apply_func(&sa->p_subn->node_guid_tbl, nr_rcv_by_comp_mask,
+ &context);
+
+ cl_plock_release(sa->p_lock);
+
+ osm_sa_respond(sa, p_madw, sizeof(ib_node_record_t), &rec_list);
+
+Exit:
+ OSM_LOG_EXIT(sa->p_log);
+}
diff --git a/contrib/ofed/opensm/opensm/osm_sa_path_record.c b/contrib/ofed/opensm/opensm/osm_sa_path_record.c
new file mode 100644
index 0000000..93e51fc
--- /dev/null
+++ b/contrib/ofed/opensm/opensm/osm_sa_path_record.c
@@ -0,0 +1,1971 @@
+/*
+ * Copyright (c) 2004-2009 Voltaire, Inc. All rights reserved.
+ * Copyright (c) 2002-2011 Mellanox Technologies LTD. All rights reserved.
+ * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
+ * Copyright (c) 2008 Xsigo Systems Inc. All rights reserved.
+ * Copyright (c) 2009 HNR Consulting. All rights reserved.
+ * Copyright (c) 2010 Sun Microsystems, Inc. All rights reserved.
+ * Copyright (c) 2009-2011 ZIH, TU Dresden, Federal Republic of Germany. All rights reserved.
+ * Copyright (c) 2013 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+/*
+ * Abstract:
+ * Implementation of osm_pr_rcv_t.
+ * This object represents the PathRecord Receiver object.
+ * This object is part of the opensm family of objects.
+ */
+
+#if HAVE_CONFIG_H
+# include <config.h>
+#endif /* HAVE_CONFIG_H */
+
+#include <string.h>
+#include <arpa/inet.h>
+#include <sys/socket.h>
+#include <iba/ib_types.h>
+#include <complib/cl_qmap.h>
+#include <complib/cl_passivelock.h>
+#include <complib/cl_debug.h>
+#include <complib/cl_qlist.h>
+#include <opensm/osm_file_ids.h>
+#define FILE_ID OSM_FILE_SA_PATH_RECORD_C
+#include <vendor/osm_vendor_api.h>
+#include <opensm/osm_base.h>
+#include <opensm/osm_port.h>
+#include <opensm/osm_node.h>
+#include <opensm/osm_switch.h>
+#include <opensm/osm_helper.h>
+#include <opensm/osm_pkey.h>
+#include <opensm/osm_multicast.h>
+#include <opensm/osm_partition.h>
+#include <opensm/osm_opensm.h>
+#include <opensm/osm_qos_policy.h>
+#include <opensm/osm_sa.h>
+#include <opensm/osm_router.h>
+#include <opensm/osm_prefix_route.h>
+#include <opensm/osm_ucast_lash.h>
+
+#define SA_PR_RESP_SIZE SA_ITEM_RESP_SIZE(path_rec)
+
+#define MAX_HOPS 64
+
+static inline boolean_t sa_path_rec_is_tavor_port(IN const osm_port_t * p_port)
+{
+ osm_node_t const *p_node;
+ ib_net32_t vend_id;
+
+ p_node = p_port->p_node;
+ vend_id = ib_node_info_get_vendor_id(&p_node->node_info);
+
+ return ((p_node->node_info.device_id == CL_HTON16(23108)) &&
+ ((vend_id == CL_HTON32(OSM_VENDOR_ID_MELLANOX)) ||
+ (vend_id == CL_HTON32(OSM_VENDOR_ID_TOPSPIN)) ||
+ (vend_id == CL_HTON32(OSM_VENDOR_ID_SILVERSTORM)) ||
+ (vend_id == CL_HTON32(OSM_VENDOR_ID_VOLTAIRE))));
+}
+
+static boolean_t
+sa_path_rec_apply_tavor_mtu_limit(IN const ib_path_rec_t * p_pr,
+ IN const osm_port_t * p_src_port,
+ IN const osm_port_t * p_dest_port,
+ IN const ib_net64_t comp_mask)
+{
+ uint8_t required_mtu;
+
+ /* only if at least one of the ports is a Tavor device */
+ if (!sa_path_rec_is_tavor_port(p_src_port) &&
+ !sa_path_rec_is_tavor_port(p_dest_port))
+ return FALSE;
+
+ /*
+ we can apply the patch if either:
+ 1. No MTU required
+ 2. Required MTU <
+ 3. Required MTU = 1K or 512 or 256
+ 4. Required MTU > 256 or 512
+ */
+ required_mtu = ib_path_rec_mtu(p_pr);
+ if ((comp_mask & IB_PR_COMPMASK_MTUSELEC) &&
+ (comp_mask & IB_PR_COMPMASK_MTU)) {
+ switch (ib_path_rec_mtu_sel(p_pr)) {
+ case 0: /* must be greater than */
+ case 2: /* exact match */
+ if (IB_MTU_LEN_1024 < required_mtu)
+ return FALSE;
+ break;
+
+ case 1: /* must be less than */
+ /* can't be disqualified by this one */
+ break;
+
+ case 3: /* largest available */
+ /* the ULP intentionally requested */
+ /* the largest MTU possible */
+ return FALSE;
+
+ default:
+ /* if we're here, there's a bug in ib_path_rec_mtu_sel() */
+ CL_ASSERT(FALSE);
+ break;
+ }
+ }
+
+ return TRUE;
+}
+
+static ib_api_status_t pr_rcv_get_path_parms(IN osm_sa_t * sa,
+ IN const ib_path_rec_t * p_pr,
+ IN const osm_alias_guid_t * p_src_alias_guid,
+ IN const uint16_t src_lid_ho,
+ IN const osm_alias_guid_t * p_dest_alias_guid,
+ IN const uint16_t dest_lid_ho,
+ IN const ib_net64_t comp_mask,
+ OUT osm_path_parms_t * p_parms)
+{
+ const osm_node_t *p_node;
+ const osm_physp_t *p_physp, *p_physp0;
+ const osm_physp_t *p_src_physp;
+ const osm_physp_t *p_dest_physp;
+ const osm_prtn_t *p_prtn = NULL;
+ osm_opensm_t *p_osm;
+ struct osm_routing_engine *p_re;
+ const ib_port_info_t *p_pi, *p_pi0;
+ ib_api_status_t status = IB_SUCCESS;
+ ib_net16_t pkey;
+ uint8_t mtu;
+ uint8_t rate, p0_extended_rate, dest_rate;
+ uint8_t pkt_life;
+ uint8_t required_mtu;
+ uint8_t required_rate;
+ uint8_t required_pkt_life;
+ uint8_t sl;
+ uint8_t in_port_num;
+ ib_net16_t dest_lid;
+ uint8_t i;
+ ib_slvl_table_t *p_slvl_tbl = NULL;
+ osm_qos_level_t *p_qos_level = NULL;
+ uint16_t valid_sl_mask = 0xffff;
+ int hops = 0;
+ int extended, p0_extended;
+
+ OSM_LOG_ENTER(sa->p_log);
+
+ dest_lid = cl_hton16(dest_lid_ho);
+
+ p_dest_physp = p_dest_alias_guid->p_base_port->p_physp;
+ p_physp = p_src_alias_guid->p_base_port->p_physp;
+ p_src_physp = p_physp;
+ p_pi = &p_physp->port_info;
+ p_osm = sa->p_subn->p_osm;
+ p_re = p_osm->routing_engine_used;
+
+ mtu = ib_port_info_get_mtu_cap(p_pi);
+ extended = p_pi->capability_mask & IB_PORT_CAP_HAS_EXT_SPEEDS;
+ rate = ib_port_info_compute_rate(p_pi, extended);
+
+ /*
+ Mellanox Tavor device performance is better using 1K MTU.
+ If required MTU and MTU selector are such that 1K is OK
+ and at least one end of the path is Tavor we override the
+ port MTU with 1K.
+ */
+ if (sa->p_subn->opt.enable_quirks &&
+ sa_path_rec_apply_tavor_mtu_limit(p_pr,
+ p_src_alias_guid->p_base_port,
+ p_dest_alias_guid->p_base_port,
+ comp_mask))
+ if (mtu > IB_MTU_LEN_1024) {
+ mtu = IB_MTU_LEN_1024;
+ OSM_LOG(sa->p_log, OSM_LOG_DEBUG,
+ "Optimized Path MTU to 1K for Mellanox Tavor device\n");
+ }
+
+ /*
+ Walk the subnet object from source to destination,
+ tracking the most restrictive rate and mtu values along the way...
+
+ If source port node is a switch, then p_physp should
+ point to the port that routes the destination lid
+ */
+
+ p_node = osm_physp_get_node_ptr(p_physp);
+
+ if (p_node->sw) {
+ /*
+ * Source node is a switch.
+ * Make sure that p_physp points to the out port of the
+ * switch that routes to the destination lid (dest_lid_ho)
+ */
+ p_physp = osm_switch_get_route_by_lid(p_node->sw, dest_lid);
+ if (p_physp == 0) {
+ OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 1F02: "
+ "Cannot find routing from LID %u to LID %u on "
+ "switch %s (GUID: 0x%016" PRIx64 ")\n",
+ src_lid_ho, dest_lid_ho, p_node->print_desc,
+ cl_ntoh64(osm_node_get_node_guid(p_node)));
+ status = IB_NOT_FOUND;
+ goto Exit;
+ }
+ }
+
+ if (sa->p_subn->opt.qos) {
+ /*
+ * Whether this node is switch or CA, the IN port for
+ * the sl2vl table is 0, because this is a source node.
+ */
+ p_slvl_tbl = osm_physp_get_slvl_tbl(p_physp, 0);
+
+ /* update valid SLs that still exist on this route */
+ for (i = 0; i < IB_MAX_NUM_VLS; i++) {
+ if (valid_sl_mask & (1 << i) &&
+ ib_slvl_table_get(p_slvl_tbl, i) == IB_DROP_VL)
+ valid_sl_mask &= ~(1 << i);
+ }
+ if (!valid_sl_mask) {
+ OSM_LOG(sa->p_log, OSM_LOG_DEBUG,
+ "All the SLs lead to VL15 on this path\n");
+ status = IB_NOT_FOUND;
+ goto Exit;
+ }
+ }
+
+ /*
+ * Same as above
+ */
+ p_node = osm_physp_get_node_ptr(p_dest_physp);
+
+ if (p_node->sw) {
+ /*
+ * if destination is switch, we want p_dest_physp to point to port 0
+ */
+ p_dest_physp =
+ osm_switch_get_route_by_lid(p_node->sw, dest_lid);
+
+ if (p_dest_physp == 0) {
+ OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 1F03: "
+ "Can't find routing from LID %u to LID %u on "
+ "switch %s (GUID: 0x%016" PRIx64 ")\n",
+ src_lid_ho, dest_lid_ho, p_node->print_desc,
+ cl_ntoh64(osm_node_get_node_guid(p_node)));
+ status = IB_NOT_FOUND;
+ goto Exit;
+ }
+
+ }
+
+ /*
+ * Now go through the path step by step
+ */
+
+ while (p_physp != p_dest_physp) {
+
+ int tmp_pnum = p_physp->port_num;
+ p_node = osm_physp_get_node_ptr(p_physp);
+ p_physp = osm_physp_get_remote(p_physp);
+
+ if (p_physp == 0) {
+ OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 1F05: "
+ "Can't find remote phys port of %s (GUID: "
+ "0x%016"PRIx64") port %d "
+ "while routing from LID %u to LID %u\n",
+ p_node->print_desc,
+ cl_ntoh64(osm_node_get_node_guid(p_node)),
+ tmp_pnum, src_lid_ho, dest_lid_ho);
+ status = IB_ERROR;
+ goto Exit;
+ }
+
+ in_port_num = osm_physp_get_port_num(p_physp);
+
+ /*
+ This is point to point case (no switch in between)
+ */
+ if (p_physp == p_dest_physp)
+ break;
+
+ p_node = osm_physp_get_node_ptr(p_physp);
+
+ if (!p_node->sw) {
+ /*
+ There is some sort of problem in the subnet object!
+ If this isn't a switch, we should have reached
+ the destination by now!
+ */
+ OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 1F06: "
+ "Internal error, bad path while routing "
+ "%s (GUID: 0x%016"PRIx64") port %d to "
+ "%s (GUID: 0x%016"PRIx64") port %d; "
+ "ended at %s port %d\n",
+ p_src_alias_guid->p_base_port->p_node->print_desc,
+ cl_ntoh64(p_src_alias_guid->p_base_port->p_node->node_info.node_guid),
+ p_src_alias_guid->p_base_port->p_physp->port_num,
+ p_dest_alias_guid->p_base_port->p_node->print_desc,
+ cl_ntoh64(p_dest_alias_guid->p_base_port->p_node->node_info.node_guid),
+ p_dest_alias_guid->p_base_port->p_physp->port_num,
+ p_node->print_desc,
+ p_physp->port_num);
+ status = IB_ERROR;
+ goto Exit;
+ }
+
+ /*
+ Check parameters for the ingress port in this switch.
+ */
+ p_pi = &p_physp->port_info;
+
+ if (mtu > ib_port_info_get_mtu_cap(p_pi))
+ mtu = ib_port_info_get_mtu_cap(p_pi);
+
+ p_physp0 = osm_node_get_physp_ptr((osm_node_t *)p_node, 0);
+ p_pi0 = &p_physp0->port_info;
+ p0_extended = p_pi0->capability_mask & IB_PORT_CAP_HAS_EXT_SPEEDS;
+ p0_extended_rate = ib_port_info_compute_rate(p_pi, p0_extended);
+ if (ib_path_compare_rates(rate, p0_extended_rate) > 0)
+ rate = p0_extended_rate;
+
+ /*
+ Continue with the egress port on this switch.
+ */
+ p_physp = osm_switch_get_route_by_lid(p_node->sw, dest_lid);
+ if (p_physp == 0) {
+ OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 1F07: "
+ "Dead end path on switch "
+ "%s (GUID: 0x%016"PRIx64") to LID %u\n",
+ p_node->print_desc,
+ cl_ntoh64(osm_node_get_node_guid(p_node)),
+ dest_lid_ho);
+ status = IB_ERROR;
+ goto Exit;
+ }
+
+ p_pi = &p_physp->port_info;
+
+ if (mtu > ib_port_info_get_mtu_cap(p_pi))
+ mtu = ib_port_info_get_mtu_cap(p_pi);
+
+ p_physp0 = osm_node_get_physp_ptr((osm_node_t *)p_node, 0);
+ p_pi0 = &p_physp0->port_info;
+ p0_extended = p_pi0->capability_mask & IB_PORT_CAP_HAS_EXT_SPEEDS;
+ p0_extended_rate = ib_port_info_compute_rate(p_pi, p0_extended);
+ if (ib_path_compare_rates(rate, p0_extended_rate) > 0)
+ rate = p0_extended_rate;
+
+ if (sa->p_subn->opt.qos) {
+ /*
+ * Check SL2VL table of the switch and update valid SLs
+ */
+ p_slvl_tbl =
+ osm_physp_get_slvl_tbl(p_physp, in_port_num);
+ for (i = 0; i < IB_MAX_NUM_VLS; i++) {
+ if (valid_sl_mask & (1 << i) &&
+ ib_slvl_table_get(p_slvl_tbl,
+ i) == IB_DROP_VL)
+ valid_sl_mask &= ~(1 << i);
+ }
+ if (!valid_sl_mask) {
+ OSM_LOG(sa->p_log, OSM_LOG_DEBUG, "All the SLs "
+ "lead to VL15 on this path\n");
+ status = IB_NOT_FOUND;
+ goto Exit;
+ }
+ }
+
+ /* update number of hops traversed */
+ hops++;
+ if (hops > MAX_HOPS) {
+ OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 1F25: "
+ "Path from GUID 0x%016" PRIx64 " (%s port %d) "
+ "to lid %u GUID 0x%016" PRIx64 " (%s port %d) "
+ "needs more than %d hops, max %d hops allowed\n",
+ cl_ntoh64(osm_physp_get_port_guid(p_src_physp)),
+ p_src_physp->p_node->print_desc,
+ p_src_physp->port_num,
+ dest_lid_ho,
+ cl_ntoh64(osm_physp_get_port_guid
+ (p_dest_physp)),
+ p_dest_physp->p_node->print_desc,
+ p_dest_physp->port_num,
+ hops,
+ MAX_HOPS);
+ status = IB_NOT_FOUND;
+ goto Exit;
+ }
+ }
+
+ /*
+ p_physp now points to the destination
+ */
+ p_pi = &p_physp->port_info;
+
+ if (mtu > ib_port_info_get_mtu_cap(p_pi))
+ mtu = ib_port_info_get_mtu_cap(p_pi);
+
+ extended = p_pi->capability_mask & IB_PORT_CAP_HAS_EXT_SPEEDS;
+ dest_rate = ib_port_info_compute_rate(p_pi, extended);
+ if (ib_path_compare_rates(rate, dest_rate) > 0)
+ rate = dest_rate;
+
+ OSM_LOG(sa->p_log, OSM_LOG_DEBUG,
+ "Path min MTU = %u, min rate = %u\n", mtu, rate);
+
+ /*
+ * Get QoS Level object according to the path request
+ * and adjust path parameters according to QoS settings
+ */
+ if (sa->p_subn->opt.qos &&
+ sa->p_subn->p_qos_policy &&
+ (p_qos_level =
+ osm_qos_policy_get_qos_level_by_pr(sa->p_subn->p_qos_policy,
+ p_pr, p_src_physp, p_dest_physp,
+ comp_mask))) {
+ OSM_LOG(sa->p_log, OSM_LOG_DEBUG,
+ "PathRecord request matches QoS Level '%s' (%s)\n",
+ p_qos_level->name, p_qos_level->use ?
+ p_qos_level->use : "no description");
+
+ if (p_qos_level->mtu_limit_set
+ && (mtu > p_qos_level->mtu_limit))
+ mtu = p_qos_level->mtu_limit;
+
+ if (p_qos_level->rate_limit_set
+ && (ib_path_compare_rates(rate, p_qos_level->rate_limit) > 0))
+ rate = p_qos_level->rate_limit;
+
+ if (p_qos_level->sl_set) {
+ sl = p_qos_level->sl;
+ if (!(valid_sl_mask & (1 << sl))) {
+ status = IB_NOT_FOUND;
+ goto Exit;
+ }
+ }
+ }
+
+ /*
+ * Set packet lifetime.
+ * According to spec definition IBA 1.2 Table 205
+ * PacketLifeTime description, for loopback paths,
+ * packetLifeTime shall be zero.
+ */
+ if (p_src_alias_guid->p_base_port == p_dest_alias_guid->p_base_port)
+ pkt_life = 0;
+ else if (p_qos_level && p_qos_level->pkt_life_set)
+ pkt_life = p_qos_level->pkt_life;
+ else
+ pkt_life = sa->p_subn->opt.subnet_timeout;
+
+ /*
+ Determine if these values meet the user criteria
+ and adjust appropriately
+ */
+
+ /* we silently ignore cases where only the MTU selector is defined */
+ if ((comp_mask & IB_PR_COMPMASK_MTUSELEC) &&
+ (comp_mask & IB_PR_COMPMASK_MTU)) {
+ required_mtu = ib_path_rec_mtu(p_pr);
+ switch (ib_path_rec_mtu_sel(p_pr)) {
+ case 0: /* must be greater than */
+ if (mtu <= required_mtu)
+ status = IB_NOT_FOUND;
+ break;
+
+ case 1: /* must be less than */
+ if (mtu >= required_mtu) {
+ /* adjust to use the highest mtu
+ lower than the required one */
+ if (required_mtu > 1)
+ mtu = required_mtu - 1;
+ else
+ status = IB_NOT_FOUND;
+ }
+ break;
+
+ case 2: /* exact match */
+ if (mtu < required_mtu)
+ status = IB_NOT_FOUND;
+ else
+ mtu = required_mtu;
+ break;
+
+ case 3: /* largest available */
+ /* can't be disqualified by this one */
+ break;
+
+ default:
+ /* if we're here, there's a bug in ib_path_rec_mtu_sel() */
+ CL_ASSERT(FALSE);
+ status = IB_ERROR;
+ break;
+ }
+ }
+ if (status != IB_SUCCESS)
+ goto Exit;
+
+ /* we silently ignore cases where only the Rate selector is defined */
+ if ((comp_mask & IB_PR_COMPMASK_RATESELEC) &&
+ (comp_mask & IB_PR_COMPMASK_RATE)) {
+ required_rate = ib_path_rec_rate(p_pr);
+ switch (ib_path_rec_rate_sel(p_pr)) {
+ case 0: /* must be greater than */
+ if (ib_path_compare_rates(rate, required_rate) <= 0)
+ status = IB_NOT_FOUND;
+ break;
+
+ case 1: /* must be less than */
+ if (ib_path_compare_rates(rate, required_rate) >= 0) {
+ /* adjust the rate to use the highest rate
+ lower than the required one */
+ rate = ib_path_rate_get_prev(required_rate);
+ if (!rate)
+ status = IB_NOT_FOUND;
+ }
+ break;
+
+ case 2: /* exact match */
+ if (ib_path_compare_rates(rate, required_rate))
+ status = IB_NOT_FOUND;
+ else
+ rate = required_rate;
+ break;
+
+ case 3: /* largest available */
+ /* can't be disqualified by this one */
+ break;
+
+ default:
+ /* if we're here, there's a bug in ib_path_rec_mtu_sel() */
+ CL_ASSERT(FALSE);
+ status = IB_ERROR;
+ break;
+ }
+ }
+ if (status != IB_SUCCESS)
+ goto Exit;
+
+ /* we silently ignore cases where only the PktLife selector is defined */
+ if ((comp_mask & IB_PR_COMPMASK_PKTLIFETIMESELEC) &&
+ (comp_mask & IB_PR_COMPMASK_PKTLIFETIME)) {
+ required_pkt_life = ib_path_rec_pkt_life(p_pr);
+ switch (ib_path_rec_pkt_life_sel(p_pr)) {
+ case 0: /* must be greater than */
+ if (pkt_life <= required_pkt_life)
+ status = IB_NOT_FOUND;
+ break;
+
+ case 1: /* must be less than */
+ if (pkt_life >= required_pkt_life) {
+ /* adjust the lifetime to use the highest possible
+ lower than the required one */
+ if (required_pkt_life > 1)
+ pkt_life = required_pkt_life - 1;
+ else
+ status = IB_NOT_FOUND;
+ }
+ break;
+
+ case 2: /* exact match */
+ if (pkt_life < required_pkt_life)
+ status = IB_NOT_FOUND;
+ else
+ pkt_life = required_pkt_life;
+ break;
+
+ case 3: /* smallest available */
+ /* can't be disqualified by this one */
+ break;
+
+ default:
+ /* if we're here, there's a bug in ib_path_rec_pkt_life_sel() */
+ CL_ASSERT(FALSE);
+ status = IB_ERROR;
+ break;
+ }
+ }
+
+ if (status != IB_SUCCESS)
+ goto Exit;
+
+ /*
+ * set Pkey for this path record request
+ */
+
+ if ((comp_mask & IB_PR_COMPMASK_RAWTRAFFIC) &&
+ (cl_ntoh32(p_pr->hop_flow_raw) & (1 << 31)))
+ pkey = osm_physp_find_common_pkey(p_src_physp, p_dest_physp,
+ sa->p_subn->opt.allow_both_pkeys);
+
+ else if (comp_mask & IB_PR_COMPMASK_PKEY) {
+ /*
+ * PR request has a specific pkey:
+ * Check that source and destination share this pkey.
+ * If QoS level has pkeys, check that this pkey exists
+ * in the QoS level pkeys.
+ * PR returned pkey is the requested pkey.
+ */
+ pkey = p_pr->pkey;
+ if (!osm_physp_share_this_pkey(p_src_physp, p_dest_physp, pkey,
+ sa->p_subn->opt.allow_both_pkeys)) {
+ OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 1F1A: "
+ "Ports 0x%016" PRIx64 " (%s port %d) and "
+ "0x%016" PRIx64 " (%s port %d) "
+ "do not share specified PKey 0x%04x\n",
+ cl_ntoh64(osm_physp_get_port_guid(p_src_physp)),
+ p_src_physp->p_node->print_desc,
+ p_src_physp->port_num,
+ cl_ntoh64(osm_physp_get_port_guid
+ (p_dest_physp)),
+ p_dest_physp->p_node->print_desc,
+ p_dest_physp->port_num,
+ cl_ntoh16(pkey));
+ status = IB_NOT_FOUND;
+ goto Exit;
+ }
+ if (p_qos_level && p_qos_level->pkey_range_len &&
+ !osm_qos_level_has_pkey(p_qos_level, pkey)) {
+ OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 1F1D: "
+ "QoS level \"%s\" doesn't define specified PKey 0x%04x "
+ "for ports 0x%016" PRIx64 " (%s port %d) and "
+ "0x%016"PRIx64" (%s port %d)\n",
+ p_qos_level->name,
+ cl_ntoh16(pkey),
+ cl_ntoh64(osm_physp_get_port_guid(p_src_physp)),
+ p_src_physp->p_node->print_desc,
+ p_src_alias_guid->p_base_port->p_physp->port_num,
+ cl_ntoh64(osm_physp_get_port_guid
+ (p_dest_physp)),
+ p_dest_physp->p_node->print_desc,
+ p_dest_alias_guid->p_base_port->p_physp->port_num);
+ status = IB_NOT_FOUND;
+ goto Exit;
+ }
+
+ } else if (p_qos_level && p_qos_level->pkey_range_len) {
+ /*
+ * PR request doesn't have a specific pkey, but QoS level
+ * has pkeys - get shared pkey from QoS level pkeys
+ */
+ pkey = osm_qos_level_get_shared_pkey(p_qos_level,
+ p_src_physp, p_dest_physp,
+ sa->p_subn->opt.allow_both_pkeys);
+ if (!pkey) {
+ OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 1F1E: "
+ "Ports 0x%016" PRIx64 " (%s) and "
+ "0x%016" PRIx64 " (%s) do not share "
+ "PKeys defined by QoS level \"%s\"\n",
+ cl_ntoh64(osm_physp_get_port_guid(p_src_physp)),
+ p_src_physp->p_node->print_desc,
+ cl_ntoh64(osm_physp_get_port_guid
+ (p_dest_physp)),
+ p_dest_physp->p_node->print_desc,
+ p_qos_level->name);
+ status = IB_NOT_FOUND;
+ goto Exit;
+ }
+ } else {
+ /*
+ * Neither PR request nor QoS level have pkey.
+ * Just get any shared pkey.
+ */
+ pkey = osm_physp_find_common_pkey(p_src_physp, p_dest_physp,
+ sa->p_subn->opt.allow_both_pkeys);
+ if (!pkey) {
+ OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 1F1B: "
+ "Ports src 0x%016"PRIx64" (%s port %d) and "
+ "dst 0x%016"PRIx64" (%s port %d) do not have "
+ "any shared PKeys\n",
+ cl_ntoh64(osm_physp_get_port_guid(p_src_physp)),
+ p_src_physp->p_node->print_desc,
+ p_src_physp->port_num,
+ cl_ntoh64(osm_physp_get_port_guid
+ (p_dest_physp)),
+ p_dest_physp->p_node->print_desc,
+ p_dest_physp->port_num);
+ status = IB_NOT_FOUND;
+ goto Exit;
+ }
+ }
+
+ if (pkey) {
+ p_prtn =
+ (osm_prtn_t *) cl_qmap_get(&sa->p_subn->prtn_pkey_tbl,
+ pkey & cl_hton16((uint16_t) ~
+ 0x8000));
+ if (p_prtn ==
+ (osm_prtn_t *) cl_qmap_end(&sa->p_subn->prtn_pkey_tbl))
+ p_prtn = NULL;
+ }
+
+ /*
+ * Set PathRecord SL
+ */
+
+ if (comp_mask & IB_PR_COMPMASK_SL) {
+ /*
+ * Specific SL was requested
+ */
+ sl = ib_path_rec_sl(p_pr);
+
+ if (p_qos_level && p_qos_level->sl_set
+ && (p_qos_level->sl != sl)) {
+ OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 1F1F: "
+ "QoS constraints: required PathRecord SL (%u) "
+ "doesn't match QoS policy \"%s\" SL (%u) "
+ "[%s port %d <-> %s port %d]\n", sl,
+ p_qos_level->name,
+ p_qos_level->sl,
+ p_src_alias_guid->p_base_port->p_node->print_desc,
+ p_src_alias_guid->p_base_port->p_physp->port_num,
+ p_dest_alias_guid->p_base_port->p_node->print_desc,
+ p_dest_alias_guid->p_base_port->p_physp->port_num);
+ status = IB_NOT_FOUND;
+ goto Exit;
+ }
+
+ } else if (p_qos_level && p_qos_level->sl_set) {
+ /*
+ * No specific SL was requested, but there is an SL in
+ * QoS level.
+ */
+ sl = p_qos_level->sl;
+
+ if (pkey && p_prtn && p_prtn->sl != p_qos_level->sl)
+ OSM_LOG(sa->p_log, OSM_LOG_DEBUG,
+ "QoS level SL (%u) overrides partition SL (%u)\n",
+ p_qos_level->sl, p_prtn->sl);
+
+ } else if (pkey) {
+ /*
+ * No specific SL in request or in QoS level - use partition SL
+ */
+ if (!p_prtn) {
+ sl = OSM_DEFAULT_SL;
+ /* this may be possible when pkey tables are created somehow in
+ previous runs or things are going wrong here */
+ OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 1F1C: "
+ "No partition found for PKey 0x%04x - "
+ "using default SL %d "
+ "[%s port %d <-> %s port %d]\n",
+ cl_ntoh16(pkey), sl,
+ p_src_alias_guid->p_base_port->p_node->print_desc,
+ p_src_alias_guid->p_base_port->p_physp->port_num,
+ p_dest_alias_guid->p_base_port->p_node->print_desc,
+ p_dest_alias_guid->p_base_port->p_physp->port_num);
+ } else
+ sl = p_prtn->sl;
+ } else if (sa->p_subn->opt.qos) {
+ if (valid_sl_mask & (1 << OSM_DEFAULT_SL))
+ sl = OSM_DEFAULT_SL;
+ else {
+ for (i = 0; i < IB_MAX_NUM_VLS; i++)
+ if (valid_sl_mask & (1 << i))
+ break;
+ sl = i;
+ }
+ } else
+ sl = OSM_DEFAULT_SL;
+
+ if (sa->p_subn->opt.qos && !(valid_sl_mask & (1 << sl))) {
+ OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 1F24: "
+ "Selected SL (%u) leads to VL15 "
+ "[%s port %d <-> %s port %d]\n",
+ sl,
+ p_src_alias_guid->p_base_port->p_node->print_desc,
+ p_src_alias_guid->p_base_port->p_physp->port_num,
+ p_dest_alias_guid->p_base_port->p_node->print_desc,
+ p_dest_alias_guid->p_base_port->p_physp->port_num);
+ status = IB_NOT_FOUND;
+ goto Exit;
+ }
+
+ /*
+ * If the routing engine wants to have a say in path SL selection,
+ * send the currently computed SL value as a hint and let the routing
+ * engine override it.
+ */
+ if (p_re && p_re->path_sl) {
+ uint8_t pr_sl;
+ pr_sl = sl;
+
+ sl = p_re->path_sl(p_re->context, sl,
+ cl_hton16(src_lid_ho), cl_hton16(dest_lid_ho));
+
+ if ((comp_mask & IB_PR_COMPMASK_SL) && (sl != pr_sl)) {
+ OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 1F2A: "
+ "Requested SL (%u) doesn't match SL calculated"
+ "by routing engine (%u) "
+ "[%s port %d <-> %s port %d]\n",
+ pr_sl,
+ sl,
+ p_src_alias_guid->p_base_port->p_node->print_desc,
+ p_src_alias_guid->p_base_port->p_physp->port_num,
+ p_dest_alias_guid->p_base_port->p_node->print_desc,
+ p_dest_alias_guid->p_base_port->p_physp->port_num);
+ status = IB_NOT_FOUND;
+ goto Exit;
+ }
+ }
+ /* reset pkey when raw traffic */
+ if (comp_mask & IB_PR_COMPMASK_RAWTRAFFIC &&
+ cl_ntoh32(p_pr->hop_flow_raw) & (1 << 31))
+ pkey = 0;
+
+ p_parms->mtu = mtu;
+ p_parms->rate = rate;
+ p_parms->pkt_life = pkt_life;
+ p_parms->pkey = pkey;
+ p_parms->sl = sl;
+
+ OSM_LOG(sa->p_log, OSM_LOG_DEBUG, "Path params: mtu = %u, rate = %u,"
+ " packet lifetime = %u, pkey = 0x%04X, sl = %u\n",
+ mtu, rate, pkt_life, cl_ntoh16(pkey), sl);
+Exit:
+ OSM_LOG_EXIT(sa->p_log);
+ return status;
+}
+
+ib_api_status_t osm_get_path_params(IN osm_sa_t * sa,
+ IN const osm_port_t * p_src_port,
+ IN const uint16_t slid_ho,
+ IN const osm_port_t * p_dest_port,
+ IN const uint16_t dlid_ho,
+ OUT osm_path_parms_t * p_parms)
+{
+ osm_alias_guid_t *p_src_alias_guid, *p_dest_alias_guid;
+ ib_path_rec_t pr;
+
+ if (!p_src_port || !slid_ho || !p_dest_port || !dlid_ho)
+ return IB_INVALID_PARAMETER;
+
+ memset(&pr, 0, sizeof(ib_path_rec_t));
+
+ p_src_alias_guid = osm_get_alias_guid_by_guid(sa->p_subn,
+ osm_port_get_guid(p_src_port));
+ p_dest_alias_guid = osm_get_alias_guid_by_guid(sa->p_subn,
+ osm_port_get_guid(p_dest_port));
+ return pr_rcv_get_path_parms(sa, &pr,
+ p_src_alias_guid, slid_ho,
+ p_dest_alias_guid, dlid_ho, 0, p_parms);
+}
+
+static void pr_rcv_build_pr(IN osm_sa_t * sa,
+ IN const osm_alias_guid_t * p_src_alias_guid,
+ IN const osm_alias_guid_t * p_dest_alias_guid,
+ IN const ib_gid_t * p_sgid,
+ IN const ib_gid_t * p_dgid,
+ IN const uint16_t src_lid_ho,
+ IN const uint16_t dest_lid_ho,
+ IN const uint8_t preference,
+ IN const osm_path_parms_t * p_parms,
+ OUT ib_path_rec_t * p_pr)
+{
+ const osm_physp_t *p_src_physp, *p_dest_physp;
+
+ OSM_LOG_ENTER(sa->p_log);
+
+ if (p_dgid)
+ p_pr->dgid = *p_dgid;
+ else {
+ p_dest_physp = p_dest_alias_guid->p_base_port->p_physp;
+
+ p_pr->dgid.unicast.prefix =
+ osm_physp_get_subnet_prefix(p_dest_physp);
+ p_pr->dgid.unicast.interface_id = p_dest_alias_guid->alias_guid;
+ }
+ if (p_sgid)
+ p_pr->sgid = *p_sgid;
+ else {
+ p_src_physp = p_src_alias_guid->p_base_port->p_physp;
+
+ p_pr->sgid.unicast.prefix = osm_physp_get_subnet_prefix(p_src_physp);
+ p_pr->sgid.unicast.interface_id = p_src_alias_guid->alias_guid;
+ }
+
+ p_pr->dlid = cl_hton16(dest_lid_ho);
+ p_pr->slid = cl_hton16(src_lid_ho);
+
+ p_pr->hop_flow_raw &= cl_hton32(1 << 31);
+
+ /* Only set HopLimit if going through a router */
+ if (p_dgid)
+ p_pr->hop_flow_raw |= cl_hton32(IB_HOPLIMIT_MAX);
+
+ p_pr->pkey = p_parms->pkey;
+ ib_path_rec_set_sl(p_pr, p_parms->sl);
+ ib_path_rec_set_qos_class(p_pr, 0);
+ p_pr->mtu = (uint8_t) (p_parms->mtu | 0x80);
+ p_pr->rate = (uint8_t) (p_parms->rate | 0x80);
+
+ /* According to 1.2 spec definition Table 205 PacketLifeTime description,
+ for loopback paths, packetLifeTime shall be zero. */
+ if (p_src_alias_guid->p_base_port == p_dest_alias_guid->p_base_port)
+ p_pr->pkt_life = 0x80; /* loopback */
+ else
+ p_pr->pkt_life = (uint8_t) (p_parms->pkt_life | 0x80);
+
+ p_pr->preference = preference;
+
+ /* always return num_path = 0 so this is only the reversible component */
+ if (p_parms->reversible)
+ p_pr->num_path = 0x80;
+
+ OSM_LOG_EXIT(sa->p_log);
+}
+
+static osm_sa_item_t *pr_rcv_get_lid_pair_path(IN osm_sa_t * sa,
+ IN const ib_path_rec_t * p_pr,
+ IN const osm_alias_guid_t * p_src_alias_guid,
+ IN const osm_alias_guid_t * p_dest_alias_guid,
+ IN const ib_gid_t * p_sgid,
+ IN const ib_gid_t * p_dgid,
+ IN const uint16_t src_lid_ho,
+ IN const uint16_t dest_lid_ho,
+ IN const ib_net64_t comp_mask,
+ IN const uint8_t preference)
+{
+ osm_path_parms_t path_parms;
+ osm_path_parms_t rev_path_parms;
+ osm_sa_item_t *p_pr_item;
+ ib_api_status_t status, rev_path_status;
+
+ OSM_LOG_ENTER(sa->p_log);
+
+ OSM_LOG(sa->p_log, OSM_LOG_DEBUG, "Src LID %u, Dest LID %u\n",
+ src_lid_ho, dest_lid_ho);
+
+ p_pr_item = malloc(SA_PR_RESP_SIZE);
+ if (p_pr_item == NULL) {
+ OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 1F01: "
+ "Unable to allocate path record\n");
+ goto Exit;
+ }
+ memset(p_pr_item, 0, SA_PR_RESP_SIZE);
+
+ status = pr_rcv_get_path_parms(sa, p_pr, p_src_alias_guid, src_lid_ho,
+ p_dest_alias_guid, dest_lid_ho,
+ comp_mask, &path_parms);
+
+ if (status != IB_SUCCESS) {
+ free(p_pr_item);
+ p_pr_item = NULL;
+ goto Exit;
+ }
+
+ /* now try the reversible path */
+ rev_path_status = pr_rcv_get_path_parms(sa, p_pr, p_dest_alias_guid,
+ dest_lid_ho, p_src_alias_guid,
+ src_lid_ho, comp_mask,
+ &rev_path_parms);
+
+ path_parms.reversible = (rev_path_status == IB_SUCCESS);
+
+ /* did we get a Reversible Path compmask ? */
+ /*
+ NOTE that if the reversible component = 0, it is a don't care
+ rather than requiring non-reversible paths ...
+ see Vol1 Ver1.2 p900 l16
+ */
+ if ((comp_mask & IB_PR_COMPMASK_REVERSIBLE) &&
+ !path_parms.reversible && (p_pr->num_path & 0x80)) {
+ OSM_LOG(sa->p_log, OSM_LOG_DEBUG,
+ "Requested reversible path but failed to get one\n");
+ free(p_pr_item);
+ p_pr_item = NULL;
+ goto Exit;
+ }
+
+ pr_rcv_build_pr(sa, p_src_alias_guid, p_dest_alias_guid, p_sgid, p_dgid,
+ src_lid_ho, dest_lid_ho, preference, &path_parms,
+ &p_pr_item->resp.path_rec);
+
+Exit:
+ OSM_LOG_EXIT(sa->p_log);
+ return p_pr_item;
+}
+
+static void pr_rcv_get_port_pair_paths(IN osm_sa_t * sa,
+ IN const ib_sa_mad_t *sa_mad,
+ IN const osm_port_t * p_req_port,
+ IN const osm_alias_guid_t * p_src_alias_guid,
+ IN const osm_alias_guid_t * p_dest_alias_guid,
+ IN const ib_gid_t * p_sgid,
+ IN const ib_gid_t * p_dgid,
+ IN cl_qlist_t * p_list)
+{
+ const ib_path_rec_t *p_pr = ib_sa_mad_get_payload_ptr(sa_mad);
+ ib_net64_t comp_mask = sa_mad->comp_mask;
+ osm_sa_item_t *p_pr_item;
+ uint16_t src_lid_min_ho;
+ uint16_t src_lid_max_ho;
+ uint16_t dest_lid_min_ho;
+ uint16_t dest_lid_max_ho;
+ uint16_t src_lid_ho;
+ uint16_t dest_lid_ho;
+ uint32_t path_num;
+ uint8_t preference;
+ unsigned iterations, src_offset, dest_offset;
+
+ OSM_LOG_ENTER(sa->p_log);
+
+ OSM_LOG(sa->p_log, OSM_LOG_DEBUG,
+ "Src port 0x%016" PRIx64 ", Dst port 0x%016" PRIx64 "\n",
+ cl_ntoh64(p_src_alias_guid->alias_guid),
+ cl_ntoh64(p_dest_alias_guid->alias_guid));
+
+ /* Check that the req_port, src_port and dest_port all share a
+ pkey. The check is done on the default physical port of the ports. */
+ if (osm_port_share_pkey(sa->p_log, p_req_port,
+ p_src_alias_guid->p_base_port,
+ sa->p_subn->opt.allow_both_pkeys) == FALSE
+ || osm_port_share_pkey(sa->p_log, p_req_port,
+ p_dest_alias_guid->p_base_port,
+ sa->p_subn->opt.allow_both_pkeys) == FALSE
+ || osm_port_share_pkey(sa->p_log, p_src_alias_guid->p_base_port,
+ p_dest_alias_guid->p_base_port,
+ sa->p_subn->opt.allow_both_pkeys) == FALSE)
+ /* One of the pairs doesn't share a pkey so the path is disqualified. */
+ goto Exit;
+
+ /*
+ We shouldn't be here if the paths are disqualified in some way...
+ Thus, we assume every possible connection is valid.
+
+ We desire to return high-quality paths first.
+ In OpenSM, higher quality means least overlap with other paths.
+ This is acheived in practice by returning paths with
+ different LID value on each end, which means these
+ paths are more redundant that paths with the same LID repeated
+ on one side. For example, in OpenSM the paths between two
+ endpoints with LMC = 1 might be as follows:
+
+ Port A, LID 1 <-> Port B, LID 3
+ Port A, LID 1 <-> Port B, LID 4
+ Port A, LID 2 <-> Port B, LID 3
+ Port A, LID 2 <-> Port B, LID 4
+
+ The OpenSM unicast routing algorithms attempt to disperse each path
+ to as varied a physical path as is reasonable. 1<->3 and 1<->4 have
+ more physical overlap (hence less redundancy) than 1<->3 and 2<->4.
+
+ OpenSM ranks paths in three preference groups:
+
+ Preference Value Description
+ ---------------- -------------------------------------------
+ 0 Redundant in both directions with other
+ pref value = 0 paths
+
+ 1 Redundant in one direction with other
+ pref value = 0 and pref value = 1 paths
+
+ 2 Not redundant in either direction with
+ other paths
+
+ 3-FF Unused
+
+ SA clients don't need to know these details, only that the lower
+ preference paths are preferred, as stated in the spec. The paths
+ may not actually be physically redundant depending on the topology
+ of the subnet, but the point of LMC > 0 is to offer redundancy,
+ so it is assumed that the subnet is physically appropriate for the
+ specified LMC value. A more advanced implementation would inspect for
+ physical redundancy, but I'm not going to bother with that now.
+ */
+
+ /*
+ Refine our search if the client specified end-point LIDs
+ */
+ if (comp_mask & IB_PR_COMPMASK_DLID)
+ dest_lid_max_ho = dest_lid_min_ho = cl_ntoh16(p_pr->dlid);
+ else
+ osm_port_get_lid_range_ho(p_dest_alias_guid->p_base_port,
+ &dest_lid_min_ho, &dest_lid_max_ho);
+
+ if (comp_mask & IB_PR_COMPMASK_SLID)
+ src_lid_max_ho = src_lid_min_ho = cl_ntoh16(p_pr->slid);
+ else
+ osm_port_get_lid_range_ho(p_src_alias_guid->p_base_port,
+ &src_lid_min_ho, &src_lid_max_ho);
+
+ if (src_lid_min_ho == 0) {
+ OSM_LOG(sa->p_log, OSM_LOG_DEBUG,
+ "Obtained source LID of 0. No such LID possible "
+ "(%s port %d)\n",
+ p_src_alias_guid->p_base_port->p_node->print_desc,
+ p_src_alias_guid->p_base_port->p_physp->port_num);
+ goto Exit;
+ }
+
+ if (dest_lid_min_ho == 0) {
+ OSM_LOG(sa->p_log, OSM_LOG_DEBUG,
+ "Obtained destination LID of 0. No such LID possible "
+ "(%s port %d)\n",
+ p_dest_alias_guid->p_base_port->p_node->print_desc,
+ p_dest_alias_guid->p_base_port->p_physp->port_num);
+ goto Exit;
+ }
+
+ OSM_LOG(sa->p_log, OSM_LOG_DEBUG,
+ "Src LIDs [%u-%u], Dest LIDs [%u-%u]\n",
+ src_lid_min_ho, src_lid_max_ho,
+ dest_lid_min_ho, dest_lid_max_ho);
+
+ src_lid_ho = src_lid_min_ho;
+ dest_lid_ho = dest_lid_min_ho;
+
+ /*
+ Preferred paths come first in OpenSM
+ */
+ preference = 0;
+ path_num = 0;
+
+ /* If SubnAdmGet, assume NumbPaths 1 (1.2 erratum) */
+ if (sa_mad->method == IB_MAD_METHOD_GET)
+ iterations = 1;
+ else if (comp_mask & IB_PR_COMPMASK_NUMBPATH)
+ iterations = ib_path_rec_num_path(p_pr);
+ else
+ iterations = (unsigned) (-1);
+
+ while (path_num < iterations) {
+ /*
+ These paths are "fully redundant"
+ */
+
+ p_pr_item = pr_rcv_get_lid_pair_path(sa, p_pr, p_src_alias_guid,
+ p_dest_alias_guid,
+ p_sgid, p_dgid,
+ src_lid_ho, dest_lid_ho,
+ comp_mask, preference);
+
+ if (p_pr_item) {
+ cl_qlist_insert_tail(p_list, &p_pr_item->list_item);
+ ++path_num;
+ }
+
+ if (++src_lid_ho > src_lid_max_ho)
+ break;
+
+ if (++dest_lid_ho > dest_lid_max_ho)
+ break;
+ }
+
+ /*
+ Check if we've accumulated all the paths that the user cares to see
+ */
+ if (path_num == iterations)
+ goto Exit;
+
+ /*
+ Don't bother reporting preference 1 paths for now.
+ It's more trouble than it's worth and can only occur
+ if ports have different LMC values, which isn't supported
+ by OpenSM right now anyway.
+ */
+ preference = 2;
+ src_lid_ho = src_lid_min_ho;
+ dest_lid_ho = dest_lid_min_ho;
+ src_offset = 0;
+ dest_offset = 0;
+
+ /*
+ Iterate over the remaining paths
+ */
+ while (path_num < iterations) {
+ dest_offset++;
+ dest_lid_ho++;
+
+ if (dest_lid_ho > dest_lid_max_ho) {
+ src_offset++;
+ src_lid_ho++;
+
+ if (src_lid_ho > src_lid_max_ho)
+ break; /* done */
+
+ dest_offset = 0;
+ dest_lid_ho = dest_lid_min_ho;
+ }
+
+ /*
+ These paths are "fully non-redundant" with paths already
+ identified above and consequently not of much value.
+
+ Don't return paths we already identified above, as indicated
+ by the offset values being equal.
+ */
+ if (src_offset == dest_offset)
+ continue; /* already reported */
+
+ p_pr_item = pr_rcv_get_lid_pair_path(sa, p_pr, p_src_alias_guid,
+ p_dest_alias_guid, p_sgid,
+ p_dgid, src_lid_ho,
+ dest_lid_ho, comp_mask,
+ preference);
+
+ if (p_pr_item) {
+ cl_qlist_insert_tail(p_list, &p_pr_item->list_item);
+ ++path_num;
+ }
+ }
+
+Exit:
+ OSM_LOG_EXIT(sa->p_log);
+}
+
+/* Find the router port that is configured to handle this prefix, if any */
+static ib_net64_t find_router(const osm_sa_t *sa, ib_net64_t prefix)
+{
+ osm_prefix_route_t *route = NULL;
+ osm_router_t *rtr;
+ cl_qlist_t *l = &sa->p_subn->prefix_routes_list;
+ cl_list_item_t *i;
+
+ OSM_LOG(sa->p_log, OSM_LOG_VERBOSE, "Non local DGID subnet prefix "
+ "0x%016" PRIx64 "\n", cl_ntoh64(prefix));
+
+ for (i = cl_qlist_head(l); i != cl_qlist_end(l); i = cl_qlist_next(i)) {
+ osm_prefix_route_t *r = (osm_prefix_route_t *)i;
+ if (!r->prefix || r->prefix == prefix) {
+ route = r;
+ break;
+ }
+ }
+ if (!route)
+ return 0;
+
+ if (route->guid == 0) /* first router */
+ rtr = (osm_router_t *) cl_qmap_head(&sa->p_subn->rtr_guid_tbl);
+ else
+ rtr = (osm_router_t *) cl_qmap_get(&sa->p_subn->rtr_guid_tbl,
+ route->guid);
+
+ if (rtr == (osm_router_t *) cl_qmap_end(&sa->p_subn->rtr_guid_tbl))
+ return 0;
+
+ return osm_port_get_guid(osm_router_get_port_ptr(rtr));
+}
+
+ib_net16_t osm_pr_get_end_points(IN osm_sa_t * sa,
+ IN const ib_sa_mad_t *sa_mad,
+ OUT const osm_alias_guid_t ** pp_src_alias_guid,
+ OUT const osm_alias_guid_t ** pp_dest_alias_guid,
+ OUT const osm_port_t ** pp_src_port,
+ OUT const osm_port_t ** pp_dest_port,
+ OUT const ib_gid_t ** pp_sgid,
+ OUT const ib_gid_t ** pp_dgid)
+{
+ const ib_path_rec_t *p_pr = ib_sa_mad_get_payload_ptr(sa_mad);
+ ib_net64_t comp_mask = sa_mad->comp_mask;
+ ib_net64_t dest_guid;
+ ib_net16_t sa_status = IB_SA_MAD_STATUS_SUCCESS;
+
+ OSM_LOG_ENTER(sa->p_log);
+
+ /*
+ Determine what fields are valid and then get a pointer
+ to the source and destination port objects, if possible.
+ */
+
+ /*
+ Check a few easy disqualifying cases up front before getting
+ into the endpoints.
+ */
+
+ *pp_src_alias_guid = NULL;
+ *pp_src_port = NULL;
+ if (comp_mask & IB_PR_COMPMASK_SGID) {
+ if (!ib_gid_is_link_local(&p_pr->sgid)) {
+ if (ib_gid_get_subnet_prefix(&p_pr->sgid) !=
+ sa->p_subn->opt.subnet_prefix) {
+ /*
+ This 'error' is the client's fault (bad gid)
+ so don't enter it as an error in our own log.
+ Return an error response to the client.
+ */
+ OSM_LOG(sa->p_log, OSM_LOG_VERBOSE,
+ "Non local SGID subnet prefix 0x%016"
+ PRIx64 "\n",
+ cl_ntoh64(p_pr->sgid.unicast.prefix));
+ sa_status = IB_SA_MAD_STATUS_INVALID_GID;
+ goto Exit;
+ }
+ }
+
+ *pp_src_alias_guid = osm_get_alias_guid_by_guid(sa->p_subn,
+ p_pr->sgid.unicast.interface_id);
+ if (!*pp_src_alias_guid) {
+ /*
+ This 'error' is the client's fault (bad gid) so
+ don't enter it as an error in our own log.
+ Return an error response to the client.
+ */
+ OSM_LOG(sa->p_log, OSM_LOG_VERBOSE,
+ "No source port with GUID 0x%016" PRIx64 "\n",
+ cl_ntoh64(p_pr->sgid.unicast.interface_id));
+ sa_status = IB_SA_MAD_STATUS_INVALID_GID;
+ goto Exit;
+ }
+ if (pp_sgid)
+ *pp_sgid = &p_pr->sgid;
+ }
+
+ if (comp_mask & IB_PR_COMPMASK_SLID) {
+ *pp_src_port = osm_get_port_by_lid(sa->p_subn, p_pr->slid);
+ if (!*pp_src_port) {
+ /*
+ This 'error' is the client's fault (bad lid) so
+ don't enter it as an error in our own log.
+ Return an error response to the client.
+ */
+ OSM_LOG(sa->p_log, OSM_LOG_VERBOSE, "No source port "
+ "with LID %u\n", cl_ntoh16(p_pr->slid));
+ sa_status = IB_SA_MAD_STATUS_NO_RECORDS;
+ goto Exit;
+ }
+ }
+
+ *pp_dest_alias_guid = NULL;
+ *pp_dest_port = NULL;
+ if (comp_mask & IB_PR_COMPMASK_DGID) {
+ if (!ib_gid_is_link_local(&p_pr->dgid) &&
+ !ib_gid_is_multicast(&p_pr->dgid) &&
+ ib_gid_get_subnet_prefix(&p_pr->dgid) !=
+ sa->p_subn->opt.subnet_prefix) {
+ dest_guid = find_router(sa, p_pr->dgid.unicast.prefix);
+ if (!dest_guid) {
+ char gid_str[INET6_ADDRSTRLEN];
+ OSM_LOG(sa->p_log, OSM_LOG_VERBOSE,
+ "Off subnet DGID %s, but router not "
+ "found\n",
+ inet_ntop(AF_INET6, p_pr->dgid.raw,
+ gid_str, sizeof(gid_str)));
+ sa_status = IB_SA_MAD_STATUS_INVALID_GID;
+ goto Exit;
+ }
+ if (pp_dgid)
+ *pp_dgid = &p_pr->dgid;
+ } else
+ dest_guid = p_pr->dgid.unicast.interface_id;
+
+ *pp_dest_alias_guid = osm_get_alias_guid_by_guid(sa->p_subn,
+ dest_guid);
+ if (!*pp_dest_alias_guid) {
+ /*
+ This 'error' is the client's fault (bad gid) so
+ don't enter it as an error in our own log.
+ Return an error response to the client.
+ */
+ OSM_LOG(sa->p_log, OSM_LOG_VERBOSE,
+ "No dest port with GUID 0x%016" PRIx64 "\n",
+ cl_ntoh64(dest_guid));
+ sa_status = IB_SA_MAD_STATUS_INVALID_GID;
+ goto Exit;
+ }
+ }
+
+ if (comp_mask & IB_PR_COMPMASK_DLID) {
+ *pp_dest_port = osm_get_port_by_lid(sa->p_subn, p_pr->dlid);
+ if (!*pp_dest_port) {
+ /*
+ This 'error' is the client's fault (bad lid)
+ so don't enter it as an error in our own log.
+ Return an error response to the client.
+ */
+ OSM_LOG(sa->p_log, OSM_LOG_VERBOSE, "No dest port "
+ "with LID %u\n", cl_ntoh16(p_pr->dlid));
+ sa_status = IB_SA_MAD_STATUS_NO_RECORDS;
+ goto Exit;
+ }
+ }
+
+Exit:
+ OSM_LOG_EXIT(sa->p_log);
+ return sa_status;
+}
+
+static void pr_rcv_process_world(IN osm_sa_t * sa, IN const ib_sa_mad_t * sa_mad,
+ IN const osm_port_t * requester_port,
+ IN const ib_gid_t * p_sgid,
+ IN const ib_gid_t * p_dgid,
+ IN cl_qlist_t * p_list)
+{
+ const cl_qmap_t *p_tbl;
+ const osm_alias_guid_t *p_dest_alias_guid, *p_src_alias_guid;
+
+ OSM_LOG_ENTER(sa->p_log);
+
+ /*
+ Iterate the entire port space over itself.
+ A path record from a port to itself is legit, so no
+ need for a special case there.
+
+ We compute both A -> B and B -> A, since we don't have
+ any check to determine the reversability of the paths.
+ */
+ p_tbl = &sa->p_subn->alias_port_guid_tbl;
+
+ p_dest_alias_guid = (osm_alias_guid_t *) cl_qmap_head(p_tbl);
+ while (p_dest_alias_guid != (osm_alias_guid_t *) cl_qmap_end(p_tbl)) {
+ p_src_alias_guid = (osm_alias_guid_t *) cl_qmap_head(p_tbl);
+ while (p_src_alias_guid != (osm_alias_guid_t *) cl_qmap_end(p_tbl)) {
+ pr_rcv_get_port_pair_paths(sa, sa_mad, requester_port,
+ p_src_alias_guid,
+ p_dest_alias_guid,
+ p_sgid, p_dgid, p_list);
+ if (sa_mad->method == IB_MAD_METHOD_GET &&
+ cl_qlist_count(p_list) > 0)
+ goto Exit;
+
+ p_src_alias_guid =
+ (osm_alias_guid_t *) cl_qmap_next(&p_src_alias_guid->map_item);
+ }
+
+ p_dest_alias_guid =
+ (osm_alias_guid_t *) cl_qmap_next(&p_dest_alias_guid->map_item);
+ }
+
+Exit:
+ OSM_LOG_EXIT(sa->p_log);
+}
+
+void osm_pr_process_half(IN osm_sa_t * sa, IN const ib_sa_mad_t * sa_mad,
+ IN const osm_port_t * requester_port,
+ IN const osm_alias_guid_t * p_src_alias_guid,
+ IN const osm_alias_guid_t * p_dest_alias_guid,
+ IN const ib_gid_t * p_sgid,
+ IN const ib_gid_t * p_dgid,
+ IN cl_qlist_t * p_list)
+{
+ const cl_qmap_t *p_tbl;
+ const osm_alias_guid_t *p_alias_guid;
+
+ OSM_LOG_ENTER(sa->p_log);
+
+ /*
+ Iterate over every port, looking for matches...
+ A path record from a port to itself is legit, so no
+ need to special case that one.
+ */
+ p_tbl = &sa->p_subn->alias_port_guid_tbl;
+
+ if (p_src_alias_guid) {
+ /*
+ The src port if fixed, so iterate over destination ports.
+ */
+ p_alias_guid = (osm_alias_guid_t *) cl_qmap_head(p_tbl);
+ while (p_alias_guid != (osm_alias_guid_t *) cl_qmap_end(p_tbl)) {
+ pr_rcv_get_port_pair_paths(sa, sa_mad, requester_port,
+ p_src_alias_guid,
+ p_alias_guid,
+ p_sgid, p_dgid, p_list);
+ if (sa_mad->method == IB_MAD_METHOD_GET &&
+ cl_qlist_count(p_list) > 0)
+ break;
+ p_alias_guid = (osm_alias_guid_t *) cl_qmap_next(&p_alias_guid->map_item);
+ }
+ } else {
+ /*
+ The dest port if fixed, so iterate over source ports.
+ */
+ p_alias_guid = (osm_alias_guid_t *) cl_qmap_head(p_tbl);
+ while (p_alias_guid != (osm_alias_guid_t *) cl_qmap_end(p_tbl)) {
+ pr_rcv_get_port_pair_paths(sa, sa_mad, requester_port,
+ p_alias_guid,
+ p_dest_alias_guid, p_sgid,
+ p_dgid, p_list);
+ if (sa_mad->method == IB_MAD_METHOD_GET &&
+ cl_qlist_count(p_list) > 0)
+ break;
+ p_alias_guid = (osm_alias_guid_t *) cl_qmap_next(&p_alias_guid->map_item);
+ }
+ }
+
+ OSM_LOG_EXIT(sa->p_log);
+}
+
+void osm_pr_process_pair(IN osm_sa_t * sa, IN const ib_sa_mad_t * sa_mad,
+ IN const osm_port_t * requester_port,
+ IN const osm_alias_guid_t * p_src_alias_guid,
+ IN const osm_alias_guid_t * p_dest_alias_guid,
+ IN const ib_gid_t * p_sgid,
+ IN const ib_gid_t * p_dgid,
+ IN cl_qlist_t * p_list)
+{
+ OSM_LOG_ENTER(sa->p_log);
+
+ pr_rcv_get_port_pair_paths(sa, sa_mad, requester_port, p_src_alias_guid,
+ p_dest_alias_guid, p_sgid, p_dgid, p_list);
+
+ OSM_LOG_EXIT(sa->p_log);
+}
+
+static ib_api_status_t pr_match_mgrp_attributes(IN osm_sa_t * sa,
+ IN const ib_sa_mad_t * sa_mad,
+ IN const osm_mgrp_t * p_mgrp)
+{
+ const ib_path_rec_t *p_pr = ib_sa_mad_get_payload_ptr(sa_mad);
+ ib_net64_t comp_mask = sa_mad->comp_mask;
+ const osm_port_t *port;
+ ib_api_status_t status = IB_ERROR;
+ uint32_t flow_label;
+ uint8_t sl, hop_limit;
+
+ OSM_LOG_ENTER(sa->p_log);
+
+ /* check that MLID of the MC group matches the PathRecord DLID */
+ if ((comp_mask & IB_PR_COMPMASK_DLID) && p_mgrp->mlid != p_pr->dlid) {
+ OSM_LOG(sa->p_log, OSM_LOG_DEBUG,
+ "DLID 0x%x is not MLID 0x%x for MC group\n",
+ cl_ntoh16(p_pr->dlid), cl_ntoh16(p_mgrp->mlid));
+ goto Exit;
+ }
+
+ /* If SGID and/or SLID specified, should validate as member of MC group */
+ if (comp_mask & IB_PR_COMPMASK_SGID) {
+ if (!osm_mgrp_get_mcm_alias_guid(p_mgrp,
+ p_pr->sgid.unicast.interface_id)) {
+ char gid_str[INET6_ADDRSTRLEN];
+ OSM_LOG(sa->p_log, OSM_LOG_DEBUG,
+ "SGID %s is not a member of MC group\n",
+ inet_ntop(AF_INET6, p_pr->sgid.raw,
+ gid_str, sizeof gid_str));
+ goto Exit;
+ }
+ }
+
+ if (comp_mask & IB_PR_COMPMASK_SLID) {
+ port = osm_get_port_by_lid(sa->p_subn, p_pr->slid);
+ if (!port || !osm_mgrp_get_mcm_port(p_mgrp, port->guid)) {
+ OSM_LOG(sa->p_log, OSM_LOG_DEBUG,
+ "Either no port with SLID %u found or "
+ "SLID not a member of MC group\n",
+ cl_ntoh16(p_pr->slid));
+ goto Exit;
+ }
+ }
+
+ /* Also, MTU, rate, packet lifetime, and raw traffic requested are not currently checked */
+ if ((comp_mask & IB_PR_COMPMASK_PKEY) &&
+ p_pr->pkey != p_mgrp->mcmember_rec.pkey) {
+ OSM_LOG(sa->p_log, OSM_LOG_DEBUG,
+ "Pkey 0x%x doesn't match MC group Pkey 0x%x\n",
+ cl_ntoh16(p_pr->pkey),
+ cl_ntoh16(p_mgrp->mcmember_rec.pkey));
+ goto Exit;
+ }
+
+ ib_member_get_sl_flow_hop(p_mgrp->mcmember_rec.sl_flow_hop,
+ &sl, &flow_label, &hop_limit);
+
+ if ((comp_mask & IB_PR_COMPMASK_SL) && ib_path_rec_sl(p_pr) != sl) {
+ OSM_LOG(sa->p_log, OSM_LOG_DEBUG,
+ "SL %d doesn't match MC group SL %d\n",
+ ib_path_rec_sl(p_pr), sl);
+ goto Exit;
+ }
+
+ /* If SubnAdmGet, assume NumbPaths of 1 (1.2 erratum) */
+ if ((comp_mask & IB_PR_COMPMASK_NUMBPATH) &&
+ sa_mad->method != IB_MAD_METHOD_GET &&
+ ib_path_rec_num_path(p_pr) == 0) {
+ OSM_LOG(sa->p_log, OSM_LOG_DEBUG,
+ "Number of paths requested is 0\n");
+ goto Exit;
+ }
+
+ if ((comp_mask & IB_PR_COMPMASK_FLOWLABEL) &&
+ ib_path_rec_flow_lbl(p_pr) != flow_label) {
+ OSM_LOG(sa->p_log, OSM_LOG_DEBUG,
+ "Flow label 0x%x doesn't match MC group "
+ " flow label 0x%x\n",
+ ib_path_rec_flow_lbl(p_pr), flow_label);
+ goto Exit;
+ }
+
+ if ((comp_mask & IB_PR_COMPMASK_HOPLIMIT) &&
+ ib_path_rec_hop_limit(p_pr) != hop_limit) {
+ OSM_LOG(sa->p_log, OSM_LOG_DEBUG,
+ "Hop limit %u doesn't match MC group hop limit %u\n",
+ ib_path_rec_hop_limit(p_pr), hop_limit);
+ goto Exit;
+ }
+
+
+ if ((comp_mask & IB_PR_COMPMASK_TCLASS) &&
+ p_pr->tclass != p_mgrp->mcmember_rec.tclass) {
+ OSM_LOG(sa->p_log, OSM_LOG_DEBUG,
+ "TClass 0x%02x doesn't match MC group TClass 0x%02x\n",
+ p_pr->tclass, p_mgrp->mcmember_rec.tclass);
+ goto Exit;
+ }
+
+ status = IB_SUCCESS;
+
+Exit:
+ OSM_LOG_EXIT(sa->p_log);
+ return status;
+}
+
+static void pr_process_multicast(osm_sa_t * sa, const ib_sa_mad_t *sa_mad,
+ cl_qlist_t *list)
+{
+ ib_path_rec_t *pr = ib_sa_mad_get_payload_ptr(sa_mad);
+ osm_mgrp_t *mgrp;
+ ib_api_status_t status;
+ osm_sa_item_t *pr_item;
+ uint32_t flow_label;
+ uint8_t sl, hop_limit;
+
+ OSM_LOG(sa->p_log, OSM_LOG_DEBUG, "Multicast destination requested\n");
+
+ mgrp = osm_get_mgrp_by_mgid(sa->p_subn, &pr->dgid);
+ if (!mgrp) {
+ char gid_str[INET6_ADDRSTRLEN];
+ OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 1F09: "
+ "No MC group found for PathRecord destination GID %s\n",
+ inet_ntop(AF_INET6, pr->dgid.raw, gid_str,
+ sizeof gid_str));
+ return;
+ }
+
+ /* Make sure the rest of the PathRecord matches the MC group attributes */
+ status = pr_match_mgrp_attributes(sa, sa_mad, mgrp);
+ if (status != IB_SUCCESS) {
+ OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 1F19: "
+ "MC group attributes don't match PathRecord request\n");
+ return;
+ }
+
+ pr_item = malloc(SA_PR_RESP_SIZE);
+ if (pr_item == NULL) {
+ OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 1F18: "
+ "Unable to allocate path record for MC group\n");
+ return;
+ }
+ memset(pr_item, 0, sizeof(cl_list_item_t));
+
+ /* Copy PathRecord request into response */
+ pr_item->resp.path_rec = *pr;
+
+ /* Now, use the MC info to cruft up the PathRecord response */
+ pr_item->resp.path_rec.dgid = mgrp->mcmember_rec.mgid;
+ pr_item->resp.path_rec.dlid = mgrp->mcmember_rec.mlid;
+ pr_item->resp.path_rec.tclass = mgrp->mcmember_rec.tclass;
+ pr_item->resp.path_rec.num_path = 1;
+ pr_item->resp.path_rec.pkey = mgrp->mcmember_rec.pkey;
+
+ /* MTU, rate, and packet lifetime should be exactly */
+ pr_item->resp.path_rec.mtu = (IB_PATH_SELECTOR_EXACTLY << 6) | mgrp->mcmember_rec.mtu;
+ pr_item->resp.path_rec.rate = (IB_PATH_SELECTOR_EXACTLY << 6) | mgrp->mcmember_rec.rate;
+ pr_item->resp.path_rec.pkt_life = (IB_PATH_SELECTOR_EXACTLY << 6) | mgrp->mcmember_rec.pkt_life;
+
+ /* SL, Hop Limit, and Flow Label */
+ ib_member_get_sl_flow_hop(mgrp->mcmember_rec.sl_flow_hop,
+ &sl, &flow_label, &hop_limit);
+ ib_path_rec_set_sl(&pr_item->resp.path_rec, sl);
+ ib_path_rec_set_qos_class(&pr_item->resp.path_rec, 0);
+
+ /* HopLimit is not yet set in non link local MC groups */
+ /* If it were, this would not be needed */
+ if (ib_mgid_get_scope(&mgrp->mcmember_rec.mgid) !=
+ IB_MC_SCOPE_LINK_LOCAL)
+ hop_limit = IB_HOPLIMIT_MAX;
+
+ pr_item->resp.path_rec.hop_flow_raw =
+ cl_hton32(hop_limit) | (flow_label << 8);
+
+ cl_qlist_insert_tail(list, &pr_item->list_item);
+}
+
+void osm_pr_rcv_process(IN void *context, IN void *data)
+{
+ osm_sa_t *sa = context;
+ osm_madw_t *p_madw = data;
+ const ib_sa_mad_t *p_sa_mad = osm_madw_get_sa_mad_ptr(p_madw);
+ ib_path_rec_t *p_pr = ib_sa_mad_get_payload_ptr(p_sa_mad);
+ cl_qlist_t pr_list;
+ const ib_gid_t *p_sgid = NULL, *p_dgid = NULL;
+ const osm_alias_guid_t *p_src_alias_guid, *p_dest_alias_guid;
+ const osm_port_t *p_src_port, *p_dest_port;
+ osm_port_t *requester_port;
+ uint8_t rate, mtu;
+
+ OSM_LOG_ENTER(sa->p_log);
+
+ CL_ASSERT(p_madw);
+
+ CL_ASSERT(p_sa_mad->attr_id == IB_MAD_ATTR_PATH_RECORD);
+
+ /* we only support SubnAdmGet and SubnAdmGetTable methods */
+ if (p_sa_mad->method != IB_MAD_METHOD_GET &&
+ p_sa_mad->method != IB_MAD_METHOD_GETTABLE) {
+ OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 1F17: "
+ "Unsupported Method (%s) for PathRecord request\n",
+ ib_get_sa_method_str(p_sa_mad->method));
+ osm_sa_send_error(sa, p_madw, IB_MAD_STATUS_UNSUP_METHOD_ATTR);
+ goto Exit;
+ }
+
+ /* Validate rate if supplied */
+ if ((p_sa_mad->comp_mask & IB_PR_COMPMASK_RATESELEC) &&
+ (p_sa_mad->comp_mask & IB_PR_COMPMASK_RATE)) {
+ rate = ib_path_rec_rate(p_pr);
+ if (!ib_rate_is_valid(rate)) {
+ osm_sa_send_error(sa, p_madw,
+ IB_SA_MAD_STATUS_REQ_INVALID);
+ goto Exit;
+ }
+ }
+ /* Validate MTU if supplied */
+ if ((p_sa_mad->comp_mask & IB_PR_COMPMASK_MTUSELEC) &&
+ (p_sa_mad->comp_mask & IB_PR_COMPMASK_MTU)) {
+ mtu = ib_path_rec_mtu(p_pr);
+ if (!ib_mtu_is_valid(mtu)) {
+ osm_sa_send_error(sa, p_madw,
+ IB_SA_MAD_STATUS_REQ_INVALID);
+ goto Exit;
+ }
+ }
+
+ /* Make sure either none or both ServiceID parameters are supplied */
+ if ((p_sa_mad->comp_mask & IB_PR_COMPMASK_SERVICEID) != 0 &&
+ (p_sa_mad->comp_mask & IB_PR_COMPMASK_SERVICEID) !=
+ IB_PR_COMPMASK_SERVICEID) {
+ osm_sa_send_error(sa, p_madw, IB_SA_MAD_STATUS_INSUF_COMPS);
+ goto Exit;
+ }
+
+ cl_qlist_init(&pr_list);
+
+ /*
+ Most SA functions (including this one) are read-only on the
+ subnet object, so we grab the lock non-exclusively.
+ */
+ cl_plock_acquire(sa->p_lock);
+
+ /* update the requester physical port */
+ requester_port = osm_get_port_by_mad_addr(sa->p_log, sa->p_subn,
+ osm_madw_get_mad_addr_ptr
+ (p_madw));
+ if (requester_port == NULL) {
+ cl_plock_release(sa->p_lock);
+ OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 1F16: "
+ "Cannot find requester physical port\n");
+ goto Exit;
+ }
+
+ if (OSM_LOG_IS_ACTIVE_V2(sa->p_log, OSM_LOG_DEBUG)) {
+ OSM_LOG(sa->p_log, OSM_LOG_DEBUG,
+ "Requester port GUID 0x%" PRIx64 "\n",
+ cl_ntoh64(osm_port_get_guid(requester_port)));
+ osm_dump_path_record_v2(sa->p_log, p_pr, FILE_ID, OSM_LOG_DEBUG);
+ }
+
+ /* Handle multicast destinations separately */
+ if ((p_sa_mad->comp_mask & IB_PR_COMPMASK_DGID) &&
+ ib_gid_is_multicast(&p_pr->dgid)) {
+ pr_process_multicast(sa, p_sa_mad, &pr_list);
+ goto Unlock;
+ }
+
+ OSM_LOG(sa->p_log, OSM_LOG_DEBUG, "Unicast destination requested\n");
+
+ if (osm_pr_get_end_points(sa, p_sa_mad,
+ &p_src_alias_guid, &p_dest_alias_guid,
+ &p_src_port, &p_dest_port,
+ &p_sgid, &p_dgid) != IB_SA_MAD_STATUS_SUCCESS)
+ goto Unlock;
+
+ if (p_src_alias_guid && p_src_port &&
+ p_src_alias_guid->p_base_port != p_src_port) {
+ cl_plock_release(sa->p_lock);
+ OSM_LOG(sa->p_log, OSM_LOG_VERBOSE,
+ "Requester port GUID 0x%" PRIx64 ": Port for SGUID "
+ "0x%" PRIx64 " not same as port for SLID %u\n",
+ cl_ntoh64(osm_port_get_guid(requester_port)),
+ cl_ntoh64(p_pr->sgid.unicast.interface_id),
+ cl_ntoh16(p_pr->slid));
+ osm_sa_send_error(sa, p_madw, IB_SA_MAD_STATUS_REQ_INVALID);
+ goto Exit;
+ }
+
+ if (p_dest_alias_guid && p_dest_port &&
+ p_dest_alias_guid->p_base_port != p_dest_port) {
+ cl_plock_release(sa->p_lock);
+ OSM_LOG(sa->p_log, OSM_LOG_VERBOSE,
+ "Requester port GUID 0x%" PRIx64 ": Port for DGUID "
+ "0x%" PRIx64 " not same as port for DLID %u\n",
+ cl_ntoh64(osm_port_get_guid(requester_port)),
+ cl_ntoh64(p_pr->dgid.unicast.interface_id),
+ cl_ntoh16(p_pr->dlid));
+ osm_sa_send_error(sa, p_madw, IB_SA_MAD_STATUS_REQ_INVALID);
+ goto Exit;
+ }
+
+ /*
+ What happens next depends on the type of endpoint information
+ that was specified....
+ */
+ if (p_src_alias_guid) {
+ if (p_dest_alias_guid)
+ osm_pr_process_pair(sa, p_sa_mad, requester_port,
+ p_src_alias_guid, p_dest_alias_guid,
+ p_sgid, p_dgid, &pr_list);
+ else if (!p_dest_port)
+ osm_pr_process_half(sa, p_sa_mad, requester_port,
+ p_src_alias_guid, NULL, p_sgid,
+ p_dgid, &pr_list);
+ else {
+ /* Get all alias GUIDs for the dest port */
+ p_dest_alias_guid = (osm_alias_guid_t *) cl_qmap_head(&sa->p_subn->alias_port_guid_tbl);
+ while (p_dest_alias_guid !=
+ (osm_alias_guid_t *) cl_qmap_end(&sa->p_subn->alias_port_guid_tbl)) {
+ if (osm_get_port_by_alias_guid(sa->p_subn, p_dest_alias_guid->alias_guid) ==
+ p_dest_port)
+ osm_pr_process_pair(sa, p_sa_mad,
+ requester_port,
+ p_src_alias_guid,
+ p_dest_alias_guid,
+ p_sgid, p_dgid,
+ &pr_list);
+ if (p_sa_mad->method == IB_MAD_METHOD_GET &&
+ cl_qlist_count(&pr_list) > 0)
+ break;
+
+ p_dest_alias_guid = (osm_alias_guid_t *) cl_qmap_next(&p_dest_alias_guid->map_item);
+ }
+ }
+ } else {
+ if (p_dest_alias_guid && !p_src_port)
+ osm_pr_process_half(sa, p_sa_mad, requester_port,
+ NULL, p_dest_alias_guid, p_sgid,
+ p_dgid, &pr_list);
+ else if (!p_src_port && !p_dest_port)
+ /*
+ Katie, bar the door!
+ */
+ pr_rcv_process_world(sa, p_sa_mad, requester_port,
+ p_sgid, p_dgid, &pr_list);
+ else if (p_dest_alias_guid && p_src_port) {
+ /* Get all alias GUIDs for the src port */
+ p_src_alias_guid = (osm_alias_guid_t *) cl_qmap_head(&sa->p_subn->alias_port_guid_tbl);
+ while (p_src_alias_guid !=
+ (osm_alias_guid_t *) cl_qmap_end(&sa->p_subn->alias_port_guid_tbl)) {
+ if (osm_get_port_by_alias_guid(sa->p_subn,
+ p_src_alias_guid->alias_guid) ==
+ p_src_port)
+ osm_pr_process_pair(sa, p_sa_mad,
+ requester_port,
+ p_src_alias_guid,
+ p_dest_alias_guid,
+ p_sgid, p_dgid,
+ &pr_list);
+ if (p_sa_mad->method == IB_MAD_METHOD_GET &&
+ cl_qlist_count(&pr_list) > 0)
+ break;
+ p_src_alias_guid = (osm_alias_guid_t *) cl_qmap_next(&p_src_alias_guid->map_item);
+ }
+ } else if (p_src_port && !p_dest_port) {
+ /* Get all alias GUIDs for the src port */
+ p_src_alias_guid = (osm_alias_guid_t *) cl_qmap_head(&sa->p_subn->alias_port_guid_tbl);
+ while (p_src_alias_guid !=
+ (osm_alias_guid_t *) cl_qmap_end(&sa->p_subn->alias_port_guid_tbl)) {
+ if (osm_get_port_by_alias_guid(sa->p_subn,
+ p_src_alias_guid->alias_guid) ==
+ p_src_port)
+ osm_pr_process_half(sa, p_sa_mad,
+ requester_port,
+ p_src_alias_guid,
+ NULL, p_sgid,
+ p_dgid, &pr_list);
+ p_src_alias_guid = (osm_alias_guid_t *) cl_qmap_next(&p_src_alias_guid->map_item);
+ }
+ } else if (p_dest_port && !p_src_port) {
+ /* Get all alias GUIDs for the dest port */
+ p_dest_alias_guid = (osm_alias_guid_t *) cl_qmap_head(&sa->p_subn->alias_port_guid_tbl);
+ while (p_dest_alias_guid !=
+ (osm_alias_guid_t *) cl_qmap_end(&sa->p_subn->alias_port_guid_tbl)) {
+ if (osm_get_port_by_alias_guid(sa->p_subn,
+ p_dest_alias_guid->alias_guid) ==
+ p_dest_port)
+ osm_pr_process_half(sa, p_sa_mad,
+ requester_port,
+ NULL,
+ p_dest_alias_guid,
+ p_sgid, p_dgid,
+ &pr_list);
+ p_dest_alias_guid = (osm_alias_guid_t *) cl_qmap_next(&p_dest_alias_guid->map_item);
+ }
+ } else {
+ /* Get all alias GUIDs for the src port */
+ p_src_alias_guid = (osm_alias_guid_t *) cl_qmap_head(&sa->p_subn->alias_port_guid_tbl);
+ while (p_src_alias_guid !=
+ (osm_alias_guid_t *) cl_qmap_end(&sa->p_subn->alias_port_guid_tbl)) {
+ if (osm_get_port_by_alias_guid(sa->p_subn,
+ p_src_alias_guid->alias_guid) ==
+ p_src_port) {
+ /* Get all alias GUIDs for the dest port */
+ p_dest_alias_guid = (osm_alias_guid_t *) cl_qmap_head(&sa->p_subn->alias_port_guid_tbl);
+ while (p_dest_alias_guid !=
+ (osm_alias_guid_t *) cl_qmap_end(&sa->p_subn->alias_port_guid_tbl)) {
+ if (osm_get_port_by_alias_guid(sa->p_subn,
+ p_dest_alias_guid->alias_guid) ==
+ p_dest_port)
+ osm_pr_process_pair(sa,
+ p_sa_mad,
+ requester_port,
+ p_src_alias_guid,
+ p_dest_alias_guid,
+ p_sgid,
+ p_dgid,
+ &pr_list);
+ if (p_sa_mad->method == IB_MAD_METHOD_GET &&
+ cl_qlist_count(&pr_list) > 0)
+ break;
+ p_dest_alias_guid = (osm_alias_guid_t *) cl_qmap_next(&p_dest_alias_guid->map_item);
+ }
+ }
+ if (p_sa_mad->method == IB_MAD_METHOD_GET &&
+ cl_qlist_count(&pr_list) > 0)
+ break;
+ p_src_alias_guid = (osm_alias_guid_t *) cl_qmap_next(&p_src_alias_guid->map_item);
+ }
+ }
+ }
+
+Unlock:
+ cl_plock_release(sa->p_lock);
+
+ /* Now, (finally) respond to the PathRecord request */
+ osm_sa_respond(sa, p_madw, sizeof(ib_path_rec_t), &pr_list);
+
+Exit:
+ OSM_LOG_EXIT(sa->p_log);
+}
diff --git a/contrib/ofed/opensm/opensm/osm_sa_pkey_record.c b/contrib/ofed/opensm/opensm/osm_sa_pkey_record.c
new file mode 100644
index 0000000..296d0a5
--- /dev/null
+++ b/contrib/ofed/opensm/opensm/osm_sa_pkey_record.c
@@ -0,0 +1,316 @@
+/*
+ * Copyright (c) 2004-2009 Voltaire, Inc. All rights reserved.
+ * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved.
+ * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
+ * Copyright (c) 2013 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+#if HAVE_CONFIG_H
+# include <config.h>
+#endif /* HAVE_CONFIG_H */
+
+#include <string.h>
+#include <iba/ib_types.h>
+#include <complib/cl_qmap.h>
+#include <complib/cl_passivelock.h>
+#include <complib/cl_debug.h>
+#include <complib/cl_qlist.h>
+#include <opensm/osm_file_ids.h>
+#define FILE_ID OSM_FILE_SA_PKEY_RECORD_C
+#include <vendor/osm_vendor_api.h>
+#include <opensm/osm_port.h>
+#include <opensm/osm_node.h>
+#include <opensm/osm_helper.h>
+#include <opensm/osm_pkey.h>
+#include <opensm/osm_sa.h>
+
+#define SA_PKEY_RESP_SIZE SA_ITEM_RESP_SIZE(pkey_rec)
+
+typedef struct osm_pkey_search_ctxt {
+ const ib_pkey_table_record_t *p_rcvd_rec;
+ ib_net64_t comp_mask;
+ uint16_t block_num;
+ cl_qlist_t *p_list;
+ osm_sa_t *sa;
+ const osm_physp_t *p_req_physp;
+} osm_pkey_search_ctxt_t;
+
+static void sa_pkey_create(IN osm_sa_t * sa, IN osm_physp_t * p_physp,
+ IN osm_pkey_search_ctxt_t * p_ctxt,
+ IN uint16_t block)
+{
+ osm_sa_item_t *p_rec_item;
+ uint16_t lid;
+ ib_pkey_table_t *tbl;
+
+ OSM_LOG_ENTER(sa->p_log);
+
+ p_rec_item = malloc(SA_PKEY_RESP_SIZE);
+ if (p_rec_item == NULL) {
+ OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 4602: "
+ "rec_item alloc failed\n");
+ goto Exit;
+ }
+
+ if (p_physp->p_node->node_info.node_type != IB_NODE_TYPE_SWITCH)
+ lid = p_physp->port_info.base_lid;
+ else
+ lid = osm_node_get_base_lid(p_physp->p_node, 0);
+
+ OSM_LOG(sa->p_log, OSM_LOG_DEBUG,
+ "New P_Key table for: port 0x%016" PRIx64
+ ", lid %u, port %u Block:%u\n",
+ cl_ntoh64(osm_physp_get_port_guid(p_physp)),
+ cl_ntoh16(lid), osm_physp_get_port_num(p_physp), block);
+
+ memset(p_rec_item, 0, SA_PKEY_RESP_SIZE);
+
+ p_rec_item->resp.pkey_rec.lid = lid;
+ p_rec_item->resp.pkey_rec.block_num = block;
+ p_rec_item->resp.pkey_rec.port_num = osm_physp_get_port_num(p_physp);
+ /* FIXME: There are ninf.PartitionCap or swinf.PartitionEnforcementCap
+ pkey entries so everything in that range is a valid block number
+ even if opensm is not using it. Return 0. However things outside
+ that range should return no entries. Not sure how to figure that
+ here? The range of pkey_tbl can be less than the cap, so
+ this falsely triggers. */
+ tbl = osm_pkey_tbl_block_get(osm_physp_get_pkey_tbl(p_physp), block);
+ if (tbl)
+ p_rec_item->resp.pkey_rec.pkey_tbl = *tbl;
+
+ cl_qlist_insert_tail(p_ctxt->p_list, &p_rec_item->list_item);
+
+Exit:
+ OSM_LOG_EXIT(sa->p_log);
+}
+
+static void sa_pkey_check_physp(IN osm_sa_t * sa, IN osm_physp_t * p_physp,
+ osm_pkey_search_ctxt_t * p_ctxt)
+{
+ ib_net64_t comp_mask = p_ctxt->comp_mask;
+ uint16_t block, num_blocks;
+
+ OSM_LOG_ENTER(sa->p_log);
+
+ /* we got here with the phys port - all is left is to get the right block */
+ if (comp_mask & IB_PKEY_COMPMASK_BLOCK) {
+ sa_pkey_create(sa, p_physp, p_ctxt, p_ctxt->block_num);
+ } else {
+ num_blocks =
+ osm_pkey_tbl_get_num_blocks(osm_physp_get_pkey_tbl
+ (p_physp));
+ for (block = 0; block < num_blocks; block++)
+ sa_pkey_create(sa, p_physp, p_ctxt, block);
+ }
+
+ OSM_LOG_EXIT(sa->p_log);
+}
+
+static void sa_pkey_by_comp_mask(IN osm_sa_t * sa, IN const osm_port_t * p_port,
+ osm_pkey_search_ctxt_t * p_ctxt)
+{
+ const ib_pkey_table_record_t *p_rcvd_rec;
+ ib_net64_t comp_mask;
+ osm_physp_t *p_physp;
+ uint8_t port_num;
+ uint8_t num_ports;
+ const osm_physp_t *p_req_physp;
+
+ OSM_LOG_ENTER(sa->p_log);
+
+ p_rcvd_rec = p_ctxt->p_rcvd_rec;
+ comp_mask = p_ctxt->comp_mask;
+ port_num = p_rcvd_rec->port_num;
+ p_req_physp = p_ctxt->p_req_physp;
+
+ /* if this is a switch port we can search all ports
+ otherwise we must be looking on port 0 */
+ if (p_port->p_node->node_info.node_type != IB_NODE_TYPE_SWITCH) {
+ /* we put it in the comp mask and port num */
+ port_num = p_port->p_physp->port_num;
+ OSM_LOG(sa->p_log, OSM_LOG_DEBUG,
+ "Using Physical Default Port Number: 0x%X (for End Node)\n",
+ port_num);
+ comp_mask |= IB_PKEY_COMPMASK_PORT;
+ }
+
+ if (comp_mask & IB_PKEY_COMPMASK_PORT) {
+ if (port_num < osm_node_get_num_physp(p_port->p_node)) {
+ p_physp =
+ osm_node_get_physp_ptr(p_port->p_node, port_num);
+ /* Check that the p_physp is valid, and that is shares a pkey
+ with the p_req_physp. */
+ if (p_physp &&
+ osm_physp_share_pkey(sa->p_log, p_req_physp,
+ p_physp, sa->p_subn->opt.allow_both_pkeys))
+ sa_pkey_check_physp(sa, p_physp, p_ctxt);
+ } else {
+ OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 4603: "
+ "Given Physical Port Number: 0x%X is out of range should be < 0x%X\n",
+ port_num,
+ osm_node_get_num_physp(p_port->p_node));
+ goto Exit;
+ }
+ } else {
+ num_ports = osm_node_get_num_physp(p_port->p_node);
+ for (port_num = 0; port_num < num_ports; port_num++) {
+ p_physp =
+ osm_node_get_physp_ptr(p_port->p_node, port_num);
+ if (!p_physp)
+ continue;
+
+ /* if the requester and the p_physp don't share a pkey -
+ continue */
+ if (!osm_physp_share_pkey
+ (sa->p_log, p_req_physp, p_physp, sa->p_subn->opt.allow_both_pkeys))
+ continue;
+
+ sa_pkey_check_physp(sa, p_physp, p_ctxt);
+ }
+ }
+Exit:
+ OSM_LOG_EXIT(sa->p_log);
+}
+
+static void sa_pkey_by_comp_mask_cb(IN cl_map_item_t * p_map_item, IN void *cxt)
+{
+ const osm_port_t *p_port = (osm_port_t *) p_map_item;
+ osm_pkey_search_ctxt_t *p_ctxt = cxt;
+
+ sa_pkey_by_comp_mask(p_ctxt->sa, p_port, p_ctxt);
+}
+
+void osm_pkey_rec_rcv_process(IN void *ctx, IN void *data)
+{
+ osm_sa_t *sa = ctx;
+ osm_madw_t *p_madw = data;
+ const ib_sa_mad_t *p_rcvd_mad;
+ const ib_pkey_table_record_t *p_rcvd_rec;
+ const osm_port_t *p_port = NULL;
+ cl_qlist_t rec_list;
+ osm_pkey_search_ctxt_t context;
+ ib_net64_t comp_mask;
+ osm_physp_t *p_req_physp;
+
+ CL_ASSERT(sa);
+
+ OSM_LOG_ENTER(sa->p_log);
+
+ CL_ASSERT(p_madw);
+
+ p_rcvd_mad = osm_madw_get_sa_mad_ptr(p_madw);
+ p_rcvd_rec =
+ (ib_pkey_table_record_t *) ib_sa_mad_get_payload_ptr(p_rcvd_mad);
+ comp_mask = p_rcvd_mad->comp_mask;
+
+ CL_ASSERT(p_rcvd_mad->attr_id == IB_MAD_ATTR_PKEY_TBL_RECORD);
+
+ /* we only support SubnAdmGet and SubnAdmGetTable methods */
+ if (p_rcvd_mad->method != IB_MAD_METHOD_GET &&
+ p_rcvd_mad->method != IB_MAD_METHOD_GETTABLE) {
+ OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 4605: "
+ "Unsupported Method (%s) for PKeyRecord request\n",
+ ib_get_sa_method_str(p_rcvd_mad->method));
+ osm_sa_send_error(sa, p_madw, IB_MAD_STATUS_UNSUP_METHOD_ATTR);
+ goto Exit;
+ }
+
+ /*
+ p922 - P_KeyTableRecords shall only be provided in response
+ to trusted requests.
+ Check that the requester is a trusted one.
+ */
+ if (p_rcvd_mad->sm_key != sa->p_subn->opt.sa_key) {
+ /* This is not a trusted requester! */
+ OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 4608: "
+ "Ignoring PKeyRecord request from non-trusted requester"
+ " with SM_Key 0x%016" PRIx64 "\n",
+ cl_ntoh64(p_rcvd_mad->sm_key));
+ osm_sa_send_error(sa, p_madw, IB_SA_MAD_STATUS_REQ_INVALID);
+ goto Exit;
+ }
+
+ cl_plock_acquire(sa->p_lock);
+
+ /* update the requester physical port */
+ p_req_physp = osm_get_physp_by_mad_addr(sa->p_log, sa->p_subn,
+ osm_madw_get_mad_addr_ptr
+ (p_madw));
+ if (p_req_physp == NULL) {
+ cl_plock_release(sa->p_lock);
+ OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 4604: "
+ "Cannot find requester physical port\n");
+ goto Exit;
+ }
+ OSM_LOG(sa->p_log, OSM_LOG_DEBUG,
+ "Requester port GUID 0x%" PRIx64 "\n",
+ cl_ntoh64(osm_physp_get_port_guid(p_req_physp)));
+
+ cl_qlist_init(&rec_list);
+
+ context.p_rcvd_rec = p_rcvd_rec;
+ context.p_list = &rec_list;
+ context.comp_mask = p_rcvd_mad->comp_mask;
+ context.sa = sa;
+ context.block_num = cl_ntoh16(p_rcvd_rec->block_num);
+ context.p_req_physp = p_req_physp;
+
+ OSM_LOG(sa->p_log, OSM_LOG_DEBUG,
+ "Got Query Lid:%u(%02X), Block:0x%02X(%02X), Port:0x%02X(%02X)\n",
+ cl_ntoh16(p_rcvd_rec->lid),
+ (comp_mask & IB_PKEY_COMPMASK_LID) != 0, p_rcvd_rec->port_num,
+ (comp_mask & IB_PKEY_COMPMASK_PORT) != 0, context.block_num,
+ (comp_mask & IB_PKEY_COMPMASK_BLOCK) != 0);
+
+ /*
+ If the user specified a LID, it obviously narrows our
+ work load, since we don't have to search every port
+ */
+ if (comp_mask & IB_PKEY_COMPMASK_LID) {
+ p_port = osm_get_port_by_lid(sa->p_subn, p_rcvd_rec->lid);
+ if (!p_port)
+ OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 460B: "
+ "No port found with LID %u\n",
+ cl_ntoh16(p_rcvd_rec->lid));
+ else
+ sa_pkey_by_comp_mask(sa, p_port, &context);
+ } else
+ cl_qmap_apply_func(&sa->p_subn->port_guid_tbl,
+ sa_pkey_by_comp_mask_cb, &context);
+
+ cl_plock_release(sa->p_lock);
+
+ osm_sa_respond(sa, p_madw, sizeof(ib_pkey_table_record_t), &rec_list);
+
+Exit:
+ OSM_LOG_EXIT(sa->p_log);
+}
diff --git a/contrib/ofed/opensm/opensm/osm_sa_portinfo_record.c b/contrib/ofed/opensm/opensm/osm_sa_portinfo_record.c
new file mode 100644
index 0000000..c362c62
--- /dev/null
+++ b/contrib/ofed/opensm/opensm/osm_sa_portinfo_record.c
@@ -0,0 +1,608 @@
+/*
+ * Copyright (c) 2004-2009 Voltaire, Inc. All rights reserved.
+ * Copyright (c) 2002-2011 Mellanox Technologies LTD. All rights reserved.
+ * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
+ * Copyright (c) 2013 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+/*
+ * Abstract:
+ * Implementation of osm_pir_rcv_t.
+ * This object represents the PortInfoRecord Receiver object.
+ * This object is part of the opensm family of objects.
+ */
+
+#if HAVE_CONFIG_H
+# include <config.h>
+#endif /* HAVE_CONFIG_H */
+
+#include <string.h>
+#include <iba/ib_types.h>
+#include <complib/cl_qmap.h>
+#include <complib/cl_passivelock.h>
+#include <complib/cl_debug.h>
+#include <complib/cl_qlist.h>
+#include <opensm/osm_file_ids.h>
+#define FILE_ID OSM_FILE_SA_PORTINFO_RECORD_C
+#include <vendor/osm_vendor_api.h>
+#include <opensm/osm_port.h>
+#include <opensm/osm_node.h>
+#include <opensm/osm_switch.h>
+#include <opensm/osm_helper.h>
+#include <opensm/osm_pkey.h>
+#include <opensm/osm_sa.h>
+
+#define SA_PIR_RESP_SIZE SA_ITEM_RESP_SIZE(port_rec)
+
+typedef struct osm_pir_search_ctxt {
+ const ib_portinfo_record_t *p_rcvd_rec;
+ ib_net64_t comp_mask;
+ cl_qlist_t *p_list;
+ osm_sa_t *sa;
+ const osm_physp_t *p_req_physp;
+ boolean_t is_enhanced_comp_mask;
+} osm_pir_search_ctxt_t;
+
+static ib_api_status_t pir_rcv_new_pir(IN osm_sa_t * sa,
+ IN const osm_physp_t * p_physp,
+ IN osm_pir_search_ctxt_t * p_ctxt,
+ IN ib_net16_t const lid)
+{
+ osm_sa_item_t *p_rec_item;
+ ib_port_info_t *p_pi;
+ osm_physp_t *p_physp0;
+ ib_api_status_t status = IB_SUCCESS;
+
+ OSM_LOG_ENTER(sa->p_log);
+
+ p_rec_item = malloc(SA_PIR_RESP_SIZE);
+ if (p_rec_item == NULL) {
+ OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 2102: "
+ "rec_item alloc failed\n");
+ status = IB_INSUFFICIENT_RESOURCES;
+ goto Exit;
+ }
+
+ OSM_LOG(sa->p_log, OSM_LOG_DEBUG,
+ "New PortInfoRecord: port 0x%016" PRIx64
+ ", lid %u, port %u\n",
+ cl_ntoh64(osm_physp_get_port_guid(p_physp)),
+ cl_ntoh16(lid), osm_physp_get_port_num(p_physp));
+
+ memset(p_rec_item, 0, SA_PIR_RESP_SIZE);
+
+ p_rec_item->resp.port_rec.lid = lid;
+ p_rec_item->resp.port_rec.port_info = p_physp->port_info;
+ if (p_ctxt->comp_mask & IB_PIR_COMPMASK_OPTIONS)
+ p_rec_item->resp.port_rec.options = p_ctxt->p_rcvd_rec->options;
+ if ((p_ctxt->comp_mask & IB_PIR_COMPMASK_OPTIONS) == 0 ||
+ (p_ctxt->p_rcvd_rec->options & 0x80) == 0) {
+ /* Does requested port have an extended link speed active ? */
+ if (osm_node_get_type(p_physp->p_node) ==
+ IB_NODE_TYPE_SWITCH) {
+ p_physp0 = osm_node_get_physp_ptr(p_physp->p_node, 0);
+ p_pi = &p_physp0->port_info;
+ } else
+ p_pi = (ib_port_info_t *) &p_physp->port_info;
+ if ((p_pi->capability_mask & IB_PORT_CAP_HAS_EXT_SPEEDS) > 0) {
+ if (ib_port_info_get_link_speed_ext_active(&p_physp->port_info)) {
+ /* Add QDR bits to original link speed components */
+ p_pi = &p_rec_item->resp.port_rec.port_info;
+ ib_port_info_set_link_speed_enabled(p_pi,
+ ib_port_info_get_link_speed_enabled(p_pi) | IB_LINK_SPEED_ACTIVE_10);
+ p_pi->state_info1 =
+ (uint8_t) ((p_pi->state_info1 & IB_PORT_STATE_MASK) |
+ (ib_port_info_get_link_speed_sup(p_pi) | IB_LINK_SPEED_ACTIVE_10) << IB_PORT_LINK_SPEED_SHIFT);
+ p_pi->link_speed =
+ (uint8_t) ((p_pi->link_speed & IB_PORT_LINK_SPEED_ENABLED_MASK) |
+ (ib_port_info_get_link_speed_active(p_pi) | IB_LINK_SPEED_ACTIVE_10) << IB_PORT_LINK_SPEED_SHIFT);
+ }
+ }
+ }
+ p_rec_item->resp.port_rec.port_num = osm_physp_get_port_num(p_physp);
+
+ cl_qlist_insert_tail(p_ctxt->p_list, &p_rec_item->list_item);
+
+Exit:
+ OSM_LOG_EXIT(sa->p_log);
+ return status;
+}
+
+static void sa_pir_create(IN osm_sa_t * sa, IN const osm_physp_t * p_physp,
+ IN osm_pir_search_ctxt_t * p_ctxt)
+{
+ uint8_t lmc;
+ uint16_t max_lid_ho;
+ uint16_t base_lid_ho;
+ uint16_t match_lid_ho;
+ osm_physp_t *p_node_physp;
+
+ OSM_LOG_ENTER(sa->p_log);
+
+ if (p_physp->p_node->sw) {
+ p_node_physp = osm_node_get_physp_ptr(p_physp->p_node, 0);
+ base_lid_ho = cl_ntoh16(osm_physp_get_base_lid(p_node_physp));
+ lmc =
+ osm_switch_sp0_is_lmc_capable(p_physp->p_node->sw,
+ sa->p_subn) ?
+ osm_physp_get_lmc(p_node_physp) : 0;
+ } else {
+ lmc = osm_physp_get_lmc(p_physp);
+ base_lid_ho = cl_ntoh16(osm_physp_get_base_lid(p_physp));
+ }
+ max_lid_ho = (uint16_t) (base_lid_ho + (1 << lmc) - 1);
+
+ if (p_ctxt->comp_mask & IB_PIR_COMPMASK_LID) {
+ match_lid_ho = cl_ntoh16(p_ctxt->p_rcvd_rec->lid);
+
+ /*
+ We validate that the lid belongs to this node.
+ */
+ OSM_LOG(sa->p_log, OSM_LOG_DEBUG,
+ "Comparing LID: %u <= %u <= %u\n",
+ base_lid_ho, match_lid_ho, max_lid_ho);
+
+ if (match_lid_ho < base_lid_ho || match_lid_ho > max_lid_ho)
+ goto Exit;
+ }
+
+ pir_rcv_new_pir(sa, p_physp, p_ctxt, cl_hton16(base_lid_ho));
+
+Exit:
+ OSM_LOG_EXIT(sa->p_log);
+}
+
+static void sa_pir_check_physp(IN osm_sa_t * sa, IN const osm_physp_t * p_physp,
+ osm_pir_search_ctxt_t * p_ctxt)
+{
+ const ib_portinfo_record_t *p_rcvd_rec;
+ ib_net64_t comp_mask;
+ const ib_port_info_t *p_comp_pi;
+ const ib_port_info_t *p_pi;
+ const osm_physp_t * p_physp0;
+ ib_net32_t cap_mask;
+
+ OSM_LOG_ENTER(sa->p_log);
+
+ p_rcvd_rec = p_ctxt->p_rcvd_rec;
+ comp_mask = p_ctxt->comp_mask;
+ p_comp_pi = &p_rcvd_rec->port_info;
+ p_pi = &p_physp->port_info;
+
+ osm_dump_port_info_v2(sa->p_log, osm_node_get_node_guid(p_physp->p_node),
+ p_physp->port_guid, p_physp->port_num,
+ &p_physp->port_info, FILE_ID, OSM_LOG_DEBUG);
+
+ /* We have to re-check the base_lid, since if the given
+ base_lid in p_pi is zero - we are comparing on all ports. */
+ if (comp_mask & IB_PIR_COMPMASK_BASELID) {
+ if (p_comp_pi->base_lid != p_pi->base_lid)
+ goto Exit;
+ }
+ if (comp_mask & IB_PIR_COMPMASK_MKEY) {
+ if (p_comp_pi->m_key != p_pi->m_key)
+ goto Exit;
+ }
+ if (comp_mask & IB_PIR_COMPMASK_GIDPRE) {
+ if (p_comp_pi->subnet_prefix != p_pi->subnet_prefix)
+ goto Exit;
+ }
+ if (comp_mask & IB_PIR_COMPMASK_SMLID) {
+ if (p_comp_pi->master_sm_base_lid != p_pi->master_sm_base_lid)
+ goto Exit;
+ }
+
+ /* IBTA 1.2 errata provides support for bitwise compare if the bit 31
+ of the attribute modifier of the Get/GetTable is set */
+ if (comp_mask & IB_PIR_COMPMASK_CAPMASK) {
+ if (p_ctxt->is_enhanced_comp_mask) {
+ if ((p_comp_pi->capability_mask & p_pi->
+ capability_mask) != p_comp_pi->capability_mask)
+ goto Exit;
+ } else {
+ if (p_comp_pi->capability_mask != p_pi->capability_mask)
+ goto Exit;
+ }
+ }
+
+ if (comp_mask & IB_PIR_COMPMASK_DIAGCODE) {
+ if (p_comp_pi->diag_code != p_pi->diag_code)
+ goto Exit;
+ }
+ if (comp_mask & IB_PIR_COMPMASK_MKEYLEASEPRD) {
+ if (p_comp_pi->m_key_lease_period != p_pi->m_key_lease_period)
+ goto Exit;
+ }
+ if (comp_mask & IB_PIR_COMPMASK_LOCALPORTNUM) {
+ if (p_comp_pi->local_port_num != p_pi->local_port_num)
+ goto Exit;
+ }
+ if (comp_mask & IB_PIR_COMPMASK_LNKWIDTHSUPPORT) {
+ if (p_comp_pi->link_width_supported !=
+ p_pi->link_width_supported)
+ goto Exit;
+ }
+ if (comp_mask & IB_PIR_COMPMASK_LNKWIDTHACTIVE) {
+ if (p_comp_pi->link_width_active != p_pi->link_width_active)
+ goto Exit;
+ }
+ if (comp_mask & IB_PIR_COMPMASK_LINKWIDTHENABLED) {
+ if (p_comp_pi->link_width_enabled != p_pi->link_width_enabled)
+ goto Exit;
+ }
+ if (comp_mask & IB_PIR_COMPMASK_LNKSPEEDSUPPORT) {
+ if (ib_port_info_get_link_speed_sup(p_comp_pi) !=
+ ib_port_info_get_link_speed_sup(p_pi))
+ goto Exit;
+ }
+ if (comp_mask & IB_PIR_COMPMASK_PORTSTATE) {
+ if (ib_port_info_get_port_state(p_comp_pi) !=
+ ib_port_info_get_port_state(p_pi))
+ goto Exit;
+ }
+ if (comp_mask & IB_PIR_COMPMASK_PORTPHYSTATE) {
+ if (ib_port_info_get_port_phys_state(p_comp_pi) !=
+ ib_port_info_get_port_phys_state(p_pi))
+ goto Exit;
+ }
+ if (comp_mask & IB_PIR_COMPMASK_LINKDWNDFLTSTATE) {
+ if (ib_port_info_get_link_down_def_state(p_comp_pi) !=
+ ib_port_info_get_link_down_def_state(p_pi))
+ goto Exit;
+ }
+ if (comp_mask & IB_PIR_COMPMASK_MKEYPROTBITS) {
+ if (ib_port_info_get_mpb(p_comp_pi) !=
+ ib_port_info_get_mpb(p_pi))
+ goto Exit;
+ }
+ if (comp_mask & IB_PIR_COMPMASK_LMC) {
+ if (ib_port_info_get_lmc(p_comp_pi) !=
+ ib_port_info_get_lmc(p_pi))
+ goto Exit;
+ }
+ if (comp_mask & IB_PIR_COMPMASK_LINKSPEEDACTIVE) {
+ if (ib_port_info_get_link_speed_active(p_comp_pi) !=
+ ib_port_info_get_link_speed_active(p_pi))
+ goto Exit;
+ }
+ if (comp_mask & IB_PIR_COMPMASK_LINKSPEEDENABLE) {
+ if (ib_port_info_get_link_speed_enabled(p_comp_pi) !=
+ ib_port_info_get_link_speed_enabled(p_pi))
+ goto Exit;
+ }
+ if (comp_mask & IB_PIR_COMPMASK_NEIGHBORMTU) {
+ if (ib_port_info_get_neighbor_mtu(p_comp_pi) !=
+ ib_port_info_get_neighbor_mtu(p_pi))
+ goto Exit;
+ }
+ if (comp_mask & IB_PIR_COMPMASK_MASTERSMSL) {
+ if (ib_port_info_get_master_smsl(p_comp_pi) !=
+ ib_port_info_get_master_smsl(p_pi))
+ goto Exit;
+ }
+ if (comp_mask & IB_PIR_COMPMASK_VLCAP) {
+ if (ib_port_info_get_vl_cap(p_comp_pi) !=
+ ib_port_info_get_vl_cap(p_pi))
+ goto Exit;
+ }
+ if (comp_mask & IB_PIR_COMPMASK_INITTYPE) {
+ if (ib_port_info_get_init_type(p_comp_pi) !=
+ ib_port_info_get_init_type(p_pi))
+ goto Exit;
+ }
+ if (comp_mask & IB_PIR_COMPMASK_VLHIGHLIMIT) {
+ if (p_comp_pi->vl_high_limit != p_pi->vl_high_limit)
+ goto Exit;
+ }
+ if (comp_mask & IB_PIR_COMPMASK_VLARBHIGHCAP) {
+ if (p_comp_pi->vl_arb_high_cap != p_pi->vl_arb_high_cap)
+ goto Exit;
+ }
+ if (comp_mask & IB_PIR_COMPMASK_VLARBLOWCAP) {
+ if (p_comp_pi->vl_arb_low_cap != p_pi->vl_arb_low_cap)
+ goto Exit;
+ }
+ if (comp_mask & IB_PIR_COMPMASK_MTUCAP) {
+ if (ib_port_info_get_mtu_cap(p_comp_pi) !=
+ ib_port_info_get_mtu_cap(p_pi))
+ goto Exit;
+ }
+ if (comp_mask & IB_PIR_COMPMASK_VLSTALLCNT) {
+ if (ib_port_info_get_vl_stall_count(p_comp_pi) !=
+ ib_port_info_get_vl_stall_count(p_pi))
+ goto Exit;
+ }
+ if (comp_mask & IB_PIR_COMPMASK_HOQLIFE) {
+ if ((p_comp_pi->vl_stall_life & 0x1F) !=
+ (p_pi->vl_stall_life & 0x1F))
+ goto Exit;
+ }
+ if (comp_mask & IB_PIR_COMPMASK_OPVLS) {
+ if ((p_comp_pi->vl_enforce & 0xF0) != (p_pi->vl_enforce & 0xF0))
+ goto Exit;
+ }
+ if (comp_mask & IB_PIR_COMPMASK_PARENFIN) {
+ if ((p_comp_pi->vl_enforce & 0x08) != (p_pi->vl_enforce & 0x08))
+ goto Exit;
+ }
+ if (comp_mask & IB_PIR_COMPMASK_PARENFOUT) {
+ if ((p_comp_pi->vl_enforce & 0x04) != (p_pi->vl_enforce & 0x04))
+ goto Exit;
+ }
+ if (comp_mask & IB_PIR_COMPMASK_FILTERRAWIN) {
+ if ((p_comp_pi->vl_enforce & 0x02) != (p_pi->vl_enforce & 0x02))
+ goto Exit;
+ }
+ if (comp_mask & IB_PIR_COMPMASK_FILTERRAWOUT) {
+ if ((p_comp_pi->vl_enforce & 0x01) != (p_pi->vl_enforce & 0x01))
+ goto Exit;
+ }
+ if (comp_mask & IB_PIR_COMPMASK_MKEYVIO) {
+ if (p_comp_pi->m_key_violations != p_pi->m_key_violations)
+ goto Exit;
+ }
+ if (comp_mask & IB_PIR_COMPMASK_PKEYVIO) {
+ if (p_comp_pi->p_key_violations != p_pi->p_key_violations)
+ goto Exit;
+ }
+ if (comp_mask & IB_PIR_COMPMASK_QKEYVIO) {
+ if (p_comp_pi->q_key_violations != p_pi->q_key_violations)
+ goto Exit;
+ }
+ if (comp_mask & IB_PIR_COMPMASK_GUIDCAP) {
+ if (p_comp_pi->guid_cap != p_pi->guid_cap)
+ goto Exit;
+ }
+ if (comp_mask & IB_PIR_COMPMASK_SUBNTO) {
+ if (ib_port_info_get_timeout(p_comp_pi) !=
+ ib_port_info_get_timeout(p_pi))
+ goto Exit;
+ }
+ if (comp_mask & IB_PIR_COMPMASK_RESPTIME) {
+ if ((p_comp_pi->resp_time_value & 0x1F) !=
+ (p_pi->resp_time_value & 0x1F))
+ goto Exit;
+ }
+ if (comp_mask & IB_PIR_COMPMASK_LOCALPHYERR) {
+ if (ib_port_info_get_local_phy_err_thd(p_comp_pi) !=
+ ib_port_info_get_local_phy_err_thd(p_pi))
+ goto Exit;
+ }
+ if (comp_mask & IB_PIR_COMPMASK_OVERRUNERR) {
+ if (ib_port_info_get_overrun_err_thd(p_comp_pi) !=
+ ib_port_info_get_overrun_err_thd(p_pi))
+ goto Exit;
+ }
+
+ /* IBTA 1.2 errata provides support for bitwise compare if the bit 31
+ of the attribute modifier of the Get/GetTable is set */
+ if (comp_mask & IB_PIR_COMPMASK_CAPMASK2) {
+ if (p_ctxt->is_enhanced_comp_mask) {
+ if ((cl_ntoh16(p_comp_pi->capability_mask2) &
+ cl_ntoh16(p_pi->capability_mask2)) !=
+ cl_ntoh16(p_comp_pi->capability_mask2))
+ goto Exit;
+ } else {
+ if (cl_ntoh16(p_comp_pi->capability_mask2) !=
+ cl_ntoh16(p_pi->capability_mask2))
+ goto Exit;
+ }
+ }
+ if (osm_node_get_type(p_physp->p_node) == IB_NODE_TYPE_SWITCH) {
+ p_physp0 = osm_node_get_physp_ptr(p_physp->p_node, 0);
+ cap_mask = p_physp0->port_info.capability_mask;
+ } else
+ cap_mask = p_pi->capability_mask;
+ if (comp_mask & IB_PIR_COMPMASK_LINKSPDEXTACT) {
+ if (((cap_mask & IB_PORT_CAP_HAS_EXT_SPEEDS) > 0) &&
+ (ib_port_info_get_link_speed_ext_active(p_comp_pi) !=
+ ib_port_info_get_link_speed_ext_active(p_pi)))
+ goto Exit;
+ }
+ if (comp_mask & IB_PIR_COMPMASK_LINKSPDEXTSUPP) {
+ if (((cap_mask & IB_PORT_CAP_HAS_EXT_SPEEDS) > 0) &&
+ (ib_port_info_get_link_speed_ext_sup(p_comp_pi) !=
+ ib_port_info_get_link_speed_ext_sup(p_pi)))
+ goto Exit;
+ }
+ if (comp_mask & IB_PIR_COMPMASK_LINKSPDEXTENAB) {
+ if (((cap_mask & IB_PORT_CAP_HAS_EXT_SPEEDS) > 0) &&
+ (ib_port_info_get_link_speed_ext_enabled(p_comp_pi) !=
+ ib_port_info_get_link_speed_ext_enabled(p_pi)))
+ goto Exit;
+ }
+ sa_pir_create(sa, p_physp, p_ctxt);
+
+Exit:
+ OSM_LOG_EXIT(sa->p_log);
+}
+
+static void sa_pir_by_comp_mask(IN osm_sa_t * sa, IN osm_node_t * p_node,
+ osm_pir_search_ctxt_t * p_ctxt)
+{
+ const ib_portinfo_record_t *p_rcvd_rec;
+ ib_net64_t comp_mask;
+ const osm_physp_t *p_physp;
+ uint8_t port_num;
+ uint8_t num_ports;
+ const osm_physp_t *p_req_physp;
+
+ OSM_LOG_ENTER(sa->p_log);
+
+ p_rcvd_rec = p_ctxt->p_rcvd_rec;
+ comp_mask = p_ctxt->comp_mask;
+ p_req_physp = p_ctxt->p_req_physp;
+
+ num_ports = osm_node_get_num_physp(p_node);
+
+ if (comp_mask & IB_PIR_COMPMASK_PORTNUM) {
+ if (p_rcvd_rec->port_num < num_ports) {
+ p_physp =
+ osm_node_get_physp_ptr(p_node,
+ p_rcvd_rec->port_num);
+ /* Check that the p_physp is valid, and that the
+ p_physp and the p_req_physp share a pkey. */
+ if (p_physp &&
+ osm_physp_share_pkey(sa->p_log, p_req_physp, p_physp,
+ sa->p_subn->opt.allow_both_pkeys))
+ sa_pir_check_physp(sa, p_physp, p_ctxt);
+ }
+ } else {
+ for (port_num = 0; port_num < num_ports; port_num++) {
+ p_physp = osm_node_get_physp_ptr(p_node, port_num);
+ if (!p_physp)
+ continue;
+
+ /* if the requester and the p_physp don't share a pkey -
+ continue */
+ if (!osm_physp_share_pkey(sa->p_log, p_req_physp, p_physp,
+ sa->p_subn->opt.allow_both_pkeys))
+ continue;
+
+ sa_pir_check_physp(sa, p_physp, p_ctxt);
+ }
+ }
+
+ OSM_LOG_EXIT(sa->p_log);
+}
+
+static void sa_pir_by_comp_mask_cb(IN cl_map_item_t * p_map_item, IN void *cxt)
+{
+ osm_node_t *p_node = (osm_node_t *) p_map_item;
+ osm_pir_search_ctxt_t *p_ctxt = cxt;
+
+ sa_pir_by_comp_mask(p_ctxt->sa, p_node, p_ctxt);
+}
+
+void osm_pir_rcv_process(IN void *ctx, IN void *data)
+{
+ osm_sa_t *sa = ctx;
+ osm_madw_t *p_madw = data;
+ const ib_sa_mad_t *p_rcvd_mad;
+ const ib_portinfo_record_t *p_rcvd_rec;
+ const osm_port_t *p_port = NULL;
+ cl_qlist_t rec_list;
+ osm_pir_search_ctxt_t context;
+ ib_net64_t comp_mask;
+ osm_physp_t *p_req_physp;
+
+ CL_ASSERT(sa);
+
+ OSM_LOG_ENTER(sa->p_log);
+
+ CL_ASSERT(p_madw);
+
+ p_rcvd_mad = osm_madw_get_sa_mad_ptr(p_madw);
+ p_rcvd_rec =
+ (ib_portinfo_record_t *) ib_sa_mad_get_payload_ptr(p_rcvd_mad);
+ comp_mask = p_rcvd_mad->comp_mask;
+
+ CL_ASSERT(p_rcvd_mad->attr_id == IB_MAD_ATTR_PORTINFO_RECORD);
+
+ /* we only support SubnAdmGet and SubnAdmGetTable methods */
+ if (p_rcvd_mad->method != IB_MAD_METHOD_GET &&
+ p_rcvd_mad->method != IB_MAD_METHOD_GETTABLE) {
+ OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 2105: "
+ "Unsupported Method (%s) for PortInfoRecord request\n",
+ ib_get_sa_method_str(p_rcvd_mad->method));
+ osm_sa_send_error(sa, p_madw, IB_MAD_STATUS_UNSUP_METHOD_ATTR);
+ goto Exit;
+ }
+
+ cl_plock_acquire(sa->p_lock);
+
+ /* update the requester physical port */
+ p_req_physp = osm_get_physp_by_mad_addr(sa->p_log, sa->p_subn,
+ osm_madw_get_mad_addr_ptr
+ (p_madw));
+ if (p_req_physp == NULL) {
+ cl_plock_release(sa->p_lock);
+ OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 2104: "
+ "Cannot find requester physical port\n");
+ goto Exit;
+ }
+
+ if (OSM_LOG_IS_ACTIVE_V2(sa->p_log, OSM_LOG_DEBUG)) {
+ OSM_LOG(sa->p_log, OSM_LOG_DEBUG,
+ "Requester port GUID 0x%" PRIx64 "\n",
+ cl_ntoh64(osm_physp_get_port_guid(p_req_physp)));
+ osm_dump_portinfo_record_v2(sa->p_log, p_rcvd_rec, FILE_ID, OSM_LOG_DEBUG);
+ }
+
+ cl_qlist_init(&rec_list);
+
+ context.p_rcvd_rec = p_rcvd_rec;
+ context.p_list = &rec_list;
+ context.comp_mask = p_rcvd_mad->comp_mask;
+ context.sa = sa;
+ context.p_req_physp = p_req_physp;
+ context.is_enhanced_comp_mask =
+ cl_ntoh32(p_rcvd_mad->attr_mod) & (1 << 31);
+
+ /*
+ If the user specified a LID, it obviously narrows our
+ work load, since we don't have to search every port
+ */
+ if (comp_mask & (IB_PIR_COMPMASK_LID | IB_PIR_COMPMASK_BASELID)) {
+ p_port = osm_get_port_by_lid(sa->p_subn, p_rcvd_rec->lid);
+ if (p_port)
+ sa_pir_by_comp_mask(sa, p_port->p_node, &context);
+ else
+ OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 2109: "
+ "No port found with requested LID %u\n",
+ cl_ntoh16(p_rcvd_rec->lid));
+ } else
+ cl_qmap_apply_func(&sa->p_subn->node_guid_tbl,
+ sa_pir_by_comp_mask_cb, &context);
+
+ cl_plock_release(sa->p_lock);
+
+ /*
+ p922 - The M_Key returned shall be zero, except in the case of a
+ trusted request.
+ Note: In the mad controller we check that the SM_Key received on
+ the mad is valid. Meaning - is either zero or equal to the local
+ sm_key.
+ */
+ if (!p_rcvd_mad->sm_key) {
+ osm_sa_item_t *item;
+ for (item = (osm_sa_item_t *) cl_qlist_head(&rec_list);
+ item != (osm_sa_item_t *) cl_qlist_end(&rec_list);
+ item = (osm_sa_item_t *) cl_qlist_next(&item->list_item))
+ item->resp.port_rec.port_info.m_key = 0;
+ }
+
+ osm_sa_respond(sa, p_madw, sizeof(ib_portinfo_record_t), &rec_list);
+
+Exit:
+ OSM_LOG_EXIT(sa->p_log);
+}
diff --git a/contrib/ofed/opensm/opensm/osm_sa_service_record.c b/contrib/ofed/opensm/opensm/osm_sa_service_record.c
new file mode 100644
index 0000000..e55e203
--- /dev/null
+++ b/contrib/ofed/opensm/opensm/osm_sa_service_record.c
@@ -0,0 +1,802 @@
+/*
+ * Copyright (c) 2004-2009 Voltaire, Inc. All rights reserved.
+ * Copyright (c) 2002-2011 Mellanox Technologies LTD. All rights reserved.
+ * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
+ * Copyright (c) 2013 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+/*
+ * Abstract:
+ * Implementation of osm_sr_rcv_t.
+ * This object represents the ServiceRecord Receiver object.
+ * This object is part of the opensm family of objects.
+ */
+
+#if HAVE_CONFIG_H
+# include <config.h>
+#endif /* HAVE_CONFIG_H */
+
+#include <string.h>
+#include <iba/ib_types.h>
+#include <complib/cl_qmap.h>
+#include <complib/cl_passivelock.h>
+#include <complib/cl_debug.h>
+#include <complib/cl_qlist.h>
+#include <opensm/osm_file_ids.h>
+#define FILE_ID OSM_FILE_SA_SERVICE_RECORD_C
+#include <vendor/osm_vendor_api.h>
+#include <opensm/osm_port.h>
+#include <opensm/osm_node.h>
+#include <opensm/osm_switch.h>
+#include <opensm/osm_helper.h>
+#include <opensm/osm_sa.h>
+#include <opensm/osm_service.h>
+#include <opensm/osm_pkey.h>
+
+#define SA_SR_RESP_SIZE SA_ITEM_RESP_SIZE(service_rec)
+
+typedef struct osm_sr_match_item {
+ cl_qlist_t sr_list;
+ ib_service_record_t *p_service_rec;
+ ib_net64_t comp_mask;
+ osm_sa_t *sa;
+} osm_sr_match_item_t;
+
+typedef struct osm_sr_search_ctxt {
+ osm_sr_match_item_t *p_sr_item;
+ const osm_physp_t *p_req_physp;
+} osm_sr_search_ctxt_t;
+
+static boolean_t
+match_service_pkey_with_ports_pkey(IN osm_sa_t * sa,
+ IN const osm_madw_t * p_madw,
+ ib_service_record_t * p_service_rec,
+ ib_net64_t const comp_mask)
+{
+ boolean_t valid = TRUE;
+ osm_physp_t *p_req_physp;
+ ib_net64_t service_guid;
+ osm_port_t *service_port;
+
+ /* update the requester physical port */
+ p_req_physp = osm_get_physp_by_mad_addr(sa->p_log, sa->p_subn,
+ osm_madw_get_mad_addr_ptr
+ (p_madw));
+ if (p_req_physp == NULL) {
+ OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 2404: "
+ "Cannot find requester physical port\n");
+ valid = FALSE;
+ goto Exit;
+ }
+ OSM_LOG(sa->p_log, OSM_LOG_DEBUG,
+ "Requester port GUID 0x%" PRIx64 "\n",
+ cl_ntoh64(osm_physp_get_port_guid(p_req_physp)));
+
+ if ((comp_mask & IB_SR_COMPMASK_SPKEY) == IB_SR_COMPMASK_SPKEY) {
+ /* We have a ServiceP_Key - check matching on requester port,
+ and ServiceGid port (if such exists) */
+ /* Make sure it matches the p_req_physp */
+ if (!osm_physp_has_pkey
+ (sa->p_log, p_service_rec->service_pkey, p_req_physp)) {
+ valid = FALSE;
+ goto Exit;
+ }
+
+ /* If unicast, make sure it matches the port of the ServiceGid */
+ if (comp_mask & IB_SR_COMPMASK_SGID &&
+ !ib_gid_is_multicast(&p_service_rec->service_gid)) {
+ service_guid =
+ p_service_rec->service_gid.unicast.interface_id;
+ service_port =
+ osm_get_port_by_alias_guid(sa->p_subn, service_guid);
+ if (!service_port) {
+ OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 2405: "
+ "No port object for port 0x%016" PRIx64
+ "\n", cl_ntoh64(service_guid));
+ valid = FALSE;
+ goto Exit;
+ }
+ /* check on the table of the default physical port of the service port */
+ if (!osm_physp_has_pkey(sa->p_log,
+ p_service_rec->service_pkey,
+ service_port->p_physp)) {
+ valid = FALSE;
+ goto Exit;
+ }
+ }
+ }
+
+Exit:
+ return valid;
+}
+
+static boolean_t
+match_name_to_key_association(IN osm_sa_t * sa,
+ ib_service_record_t * p_service_rec,
+ ib_net64_t comp_mask)
+{
+ UNUSED_PARAM(p_service_rec);
+ UNUSED_PARAM(sa);
+
+ if ((comp_mask & (IB_SR_COMPMASK_SKEY | IB_SR_COMPMASK_SNAME)) ==
+ (IB_SR_COMPMASK_SKEY | IB_SR_COMPMASK_SNAME)) {
+ /* For now, we are not maintaining the ServiceAssociation record
+ * so just return TRUE
+ */
+ return TRUE;
+ }
+
+ return TRUE;
+}
+
+static boolean_t validate_sr(IN osm_sa_t * sa, IN const osm_madw_t * p_madw)
+{
+ boolean_t valid = TRUE;
+ ib_sa_mad_t *p_sa_mad;
+ ib_service_record_t *p_recvd_service_rec;
+
+ OSM_LOG_ENTER(sa->p_log);
+
+ p_sa_mad = osm_madw_get_sa_mad_ptr(p_madw);
+ p_recvd_service_rec =
+ (ib_service_record_t *) ib_sa_mad_get_payload_ptr(p_sa_mad);
+
+ valid = match_service_pkey_with_ports_pkey(sa, p_madw,
+ p_recvd_service_rec,
+ p_sa_mad->comp_mask);
+ if (!valid) {
+ OSM_LOG(sa->p_log, OSM_LOG_DEBUG,
+ "No Match for Service Pkey\n");
+ valid = FALSE;
+ goto Exit;
+ }
+
+ valid = match_name_to_key_association(sa, p_recvd_service_rec,
+ p_sa_mad->comp_mask);
+ if (!valid) {
+ OSM_LOG(sa->p_log, OSM_LOG_DEBUG,
+ "Service Record Name to key matching failed\n");
+ valid = FALSE;
+ goto Exit;
+ }
+
+Exit:
+ OSM_LOG_EXIT(sa->p_log);
+ return valid;
+}
+
+static void sr_rcv_respond(IN osm_sa_t * sa, IN osm_madw_t * p_madw,
+ IN cl_qlist_t * p_list)
+{
+ /* p923 - The ServiceKey shall be set to 0, except in the case of
+ a trusted request.
+ Note: In the mad controller we check that the SM_Key received on
+ the mad is valid. Meaning - is either zero or equal to the local
+ sm_key.
+ */
+ if (!osm_madw_get_sa_mad_ptr(p_madw)->sm_key) {
+ osm_sa_item_t *item;
+ for (item = (osm_sa_item_t *) cl_qlist_head(p_list);
+ item != (osm_sa_item_t *) cl_qlist_end(p_list);
+ item = (osm_sa_item_t *) cl_qlist_next(&item->list_item))
+ memset(item->resp.service_rec.service_key, 0,
+ sizeof(item->resp.service_rec.service_key));
+ }
+
+ osm_sa_respond(sa, p_madw, sizeof(ib_service_record_t), p_list);
+}
+
+static void get_matching_sr(IN cl_list_item_t * p_list_item, IN void *context)
+{
+ osm_sr_search_ctxt_t *p_ctxt = context;
+ osm_svcr_t *p_svcr = (osm_svcr_t *) p_list_item;
+ osm_sa_item_t *p_sr_pool_item;
+ osm_sr_match_item_t *p_sr_item = p_ctxt->p_sr_item;
+ ib_net64_t comp_mask = p_sr_item->comp_mask;
+ const osm_physp_t *p_req_physp = p_ctxt->p_req_physp;
+
+ if (comp_mask & IB_SR_COMPMASK_SID) {
+ if (p_sr_item->p_service_rec->service_id !=
+ p_svcr->service_record.service_id)
+ return;
+ }
+ if (comp_mask & IB_SR_COMPMASK_SGID) {
+ if (memcmp(&p_sr_item->p_service_rec->service_gid,
+ &p_svcr->service_record.service_gid,
+ sizeof(p_svcr->service_record.service_gid)) != 0)
+ return;
+ }
+ if (comp_mask & IB_SR_COMPMASK_SPKEY) {
+ if (p_sr_item->p_service_rec->service_pkey !=
+ p_svcr->service_record.service_pkey)
+ return;
+ }
+
+ if (comp_mask & IB_SR_COMPMASK_SKEY) {
+ if (memcmp(p_sr_item->p_service_rec->service_key,
+ p_svcr->service_record.service_key,
+ 16 * sizeof(uint8_t)))
+ return;
+ }
+ if (comp_mask & IB_SR_COMPMASK_SNAME) {
+ if (memcmp(p_sr_item->p_service_rec->service_name,
+ p_svcr->service_record.service_name,
+ sizeof(p_svcr->service_record.service_name)) != 0)
+ return;
+ }
+ if (comp_mask & IB_SR_COMPMASK_SDATA8_0) {
+ if (p_sr_item->p_service_rec->service_data8[0] !=
+ p_svcr->service_record.service_data8[0])
+ return;
+ }
+
+ if (comp_mask & IB_SR_COMPMASK_SDATA8_1) {
+ if (p_sr_item->p_service_rec->service_data8[1] !=
+ p_svcr->service_record.service_data8[1])
+ return;
+ }
+ if (comp_mask & IB_SR_COMPMASK_SDATA8_2) {
+ if (p_sr_item->p_service_rec->service_data8[2] !=
+ p_svcr->service_record.service_data8[2])
+ return;
+ }
+ if (comp_mask & IB_SR_COMPMASK_SDATA8_3) {
+ if (p_sr_item->p_service_rec->service_data8[3] !=
+ p_svcr->service_record.service_data8[3])
+ return;
+ }
+ if (comp_mask & IB_SR_COMPMASK_SDATA8_4) {
+ if (p_sr_item->p_service_rec->service_data8[4] !=
+ p_svcr->service_record.service_data8[4])
+ return;
+ }
+ if (comp_mask & IB_SR_COMPMASK_SDATA8_5) {
+ if (p_sr_item->p_service_rec->service_data8[5] !=
+ p_svcr->service_record.service_data8[5])
+ return;
+ }
+ if (comp_mask & IB_SR_COMPMASK_SDATA8_6) {
+ if (p_sr_item->p_service_rec->service_data8[6] !=
+ p_svcr->service_record.service_data8[6])
+ return;
+ }
+
+ if (comp_mask & IB_SR_COMPMASK_SDATA8_7) {
+ if (p_sr_item->p_service_rec->service_data8[7] !=
+ p_svcr->service_record.service_data8[7])
+ return;
+ }
+
+ if (comp_mask & IB_SR_COMPMASK_SDATA8_8) {
+ if (p_sr_item->p_service_rec->service_data8[8] !=
+ p_svcr->service_record.service_data8[8])
+ return;
+ }
+
+ if (comp_mask & IB_SR_COMPMASK_SDATA8_9) {
+ if (p_sr_item->p_service_rec->service_data8[9] !=
+ p_svcr->service_record.service_data8[9])
+ return;
+ }
+
+ if (comp_mask & IB_SR_COMPMASK_SDATA8_10) {
+ if (p_sr_item->p_service_rec->service_data8[10] !=
+ p_svcr->service_record.service_data8[10])
+ return;
+ }
+
+ if (comp_mask & IB_SR_COMPMASK_SDATA8_11) {
+ if (p_sr_item->p_service_rec->service_data8[11] !=
+ p_svcr->service_record.service_data8[11])
+ return;
+ }
+
+ if (comp_mask & IB_SR_COMPMASK_SDATA8_12) {
+ if (p_sr_item->p_service_rec->service_data8[12] !=
+ p_svcr->service_record.service_data8[12])
+ return;
+ }
+ if (comp_mask & IB_SR_COMPMASK_SDATA8_13) {
+ if (p_sr_item->p_service_rec->service_data8[13] !=
+ p_svcr->service_record.service_data8[13])
+ return;
+ }
+ if (comp_mask & IB_SR_COMPMASK_SDATA8_14) {
+ if (p_sr_item->p_service_rec->service_data8[14] !=
+ p_svcr->service_record.service_data8[14])
+ return;
+ }
+ if (comp_mask & IB_SR_COMPMASK_SDATA8_15) {
+ if (p_sr_item->p_service_rec->service_data8[15] !=
+ p_svcr->service_record.service_data8[15])
+ return;
+ }
+ if (comp_mask & IB_SR_COMPMASK_SDATA16_0) {
+ if (p_sr_item->p_service_rec->service_data16[0] !=
+ p_svcr->service_record.service_data16[0])
+ return;
+ }
+ if (comp_mask & IB_SR_COMPMASK_SDATA16_1) {
+ if (p_sr_item->p_service_rec->service_data16[1] !=
+ p_svcr->service_record.service_data16[1])
+ return;
+ }
+ if (comp_mask & IB_SR_COMPMASK_SDATA16_2) {
+ if (p_sr_item->p_service_rec->service_data16[2] !=
+ p_svcr->service_record.service_data16[2])
+ return;
+ }
+ if (comp_mask & IB_SR_COMPMASK_SDATA16_3) {
+ if (p_sr_item->p_service_rec->service_data16[3] !=
+ p_svcr->service_record.service_data16[3])
+ return;
+ }
+ if (comp_mask & IB_SR_COMPMASK_SDATA16_4) {
+ if (p_sr_item->p_service_rec->service_data16[4] !=
+ p_svcr->service_record.service_data16[4])
+ return;
+ }
+ if (comp_mask & IB_SR_COMPMASK_SDATA16_5) {
+ if (p_sr_item->p_service_rec->service_data16[5] !=
+ p_svcr->service_record.service_data16[5])
+ return;
+ }
+ if (comp_mask & IB_SR_COMPMASK_SDATA16_6) {
+ if (p_sr_item->p_service_rec->service_data16[6] !=
+ p_svcr->service_record.service_data16[6])
+ return;
+ }
+ if (comp_mask & IB_SR_COMPMASK_SDATA16_7) {
+ if (p_sr_item->p_service_rec->service_data16[7] !=
+ p_svcr->service_record.service_data16[7])
+ return;
+ }
+ if (comp_mask & IB_SR_COMPMASK_SDATA32_0) {
+ if (p_sr_item->p_service_rec->service_data32[0] !=
+ p_svcr->service_record.service_data32[0])
+ return;
+ }
+ if (comp_mask & IB_SR_COMPMASK_SDATA32_1) {
+ if (p_sr_item->p_service_rec->service_data32[1] !=
+ p_svcr->service_record.service_data32[1])
+ return;
+ }
+ if (comp_mask & IB_SR_COMPMASK_SDATA32_2) {
+ if (p_sr_item->p_service_rec->service_data32[2] !=
+ p_svcr->service_record.service_data32[2])
+ return;
+ }
+ if (comp_mask & IB_SR_COMPMASK_SDATA32_3) {
+ if (p_sr_item->p_service_rec->service_data32[3] !=
+ p_svcr->service_record.service_data32[3])
+ return;
+ }
+
+ if (comp_mask & IB_SR_COMPMASK_SDATA64_0) {
+ if (p_sr_item->p_service_rec->service_data64[0] !=
+ p_svcr->service_record.service_data64[0])
+ return;
+ }
+ if (comp_mask & IB_SR_COMPMASK_SDATA64_1) {
+ if (p_sr_item->p_service_rec->service_data64[1] !=
+ p_svcr->service_record.service_data64[1])
+ return;
+ }
+
+ /* Check that the requester port has the pkey which is the service_pkey.
+ If not - then it cannot receive this ServiceRecord. */
+ /* The check is relevant only if the service_pkey is valid */
+ if (!ib_pkey_is_invalid(p_svcr->service_record.service_pkey)) {
+ if (!osm_physp_has_pkey(p_sr_item->sa->p_log,
+ p_svcr->service_record.service_pkey,
+ p_req_physp)) {
+ OSM_LOG(p_sr_item->sa->p_log, OSM_LOG_VERBOSE,
+ "requester port doesn't have the service_pkey: 0x%X\n",
+ cl_ntoh16(p_svcr->service_record.service_pkey));
+ return;
+ }
+ }
+
+ p_sr_pool_item = malloc(SA_SR_RESP_SIZE);
+ if (p_sr_pool_item == NULL) {
+ OSM_LOG(p_sr_item->sa->p_log, OSM_LOG_ERROR, "ERR 2408: "
+ "Unable to acquire Service Record from pool\n");
+ goto Exit;
+ }
+
+ p_sr_pool_item->resp.service_rec = p_svcr->service_record;
+
+ cl_qlist_insert_tail(&p_sr_item->sr_list, &p_sr_pool_item->list_item);
+
+Exit:
+ return;
+}
+
+static void sr_rcv_process_get_method(osm_sa_t * sa, IN osm_madw_t * p_madw)
+{
+ ib_sa_mad_t *p_sa_mad;
+ ib_service_record_t *p_recvd_service_rec;
+ osm_sr_match_item_t sr_match_item;
+ osm_sr_search_ctxt_t context;
+ osm_physp_t *p_req_physp;
+
+ OSM_LOG_ENTER(sa->p_log);
+
+ CL_ASSERT(p_madw);
+
+ /* Grab the lock */
+ cl_plock_acquire(sa->p_lock);
+
+ /* update the requester physical port */
+ p_req_physp = osm_get_physp_by_mad_addr(sa->p_log, sa->p_subn,
+ osm_madw_get_mad_addr_ptr
+ (p_madw));
+ if (p_req_physp == NULL) {
+ cl_plock_release(sa->p_lock);
+ OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 2409: "
+ "Cannot find requester physical port\n");
+ goto Exit;
+ }
+
+ p_sa_mad = osm_madw_get_sa_mad_ptr(p_madw);
+ p_recvd_service_rec =
+ (ib_service_record_t *) ib_sa_mad_get_payload_ptr(p_sa_mad);
+
+ if (OSM_LOG_IS_ACTIVE_V2(sa->p_log, OSM_LOG_DEBUG)) {
+ OSM_LOG(sa->p_log, OSM_LOG_DEBUG,
+ "Requester port GUID 0x%" PRIx64 "\n",
+ cl_ntoh64(osm_physp_get_port_guid(p_req_physp)));
+ osm_dump_service_record_v2(sa->p_log, p_recvd_service_rec,
+ FILE_ID, OSM_LOG_DEBUG);
+ }
+
+ cl_qlist_init(&sr_match_item.sr_list);
+ sr_match_item.p_service_rec = p_recvd_service_rec;
+ sr_match_item.comp_mask = p_sa_mad->comp_mask;
+ sr_match_item.sa = sa;
+
+ context.p_sr_item = &sr_match_item;
+ context.p_req_physp = p_req_physp;
+
+ cl_qlist_apply_func(&sa->p_subn->sa_sr_list, get_matching_sr, &context);
+
+ cl_plock_release(sa->p_lock);
+
+ if (p_sa_mad->method == IB_MAD_METHOD_GET &&
+ cl_qlist_count(&sr_match_item.sr_list) == 0) {
+ OSM_LOG(sa->p_log, OSM_LOG_DEBUG,
+ "No records matched the Service Record query\n");
+ osm_sa_send_error(sa, p_madw, IB_SA_MAD_STATUS_NO_RECORDS);
+ goto Exit;
+ }
+
+ sr_rcv_respond(sa, p_madw, &sr_match_item.sr_list);
+
+Exit:
+ OSM_LOG_EXIT(sa->p_log);
+ return;
+}
+
+static void sr_rcv_process_set_method(osm_sa_t * sa, IN osm_madw_t * p_madw)
+{
+ ib_sa_mad_t *p_sa_mad;
+ ib_service_record_t *p_recvd_service_rec;
+ ib_net64_t comp_mask;
+ osm_svcr_t *p_svcr;
+ osm_sa_item_t *p_sr_item;
+ cl_qlist_t sr_list;
+
+ OSM_LOG_ENTER(sa->p_log);
+
+ CL_ASSERT(p_madw);
+
+ p_sa_mad = osm_madw_get_sa_mad_ptr(p_madw);
+ p_recvd_service_rec =
+ (ib_service_record_t *) ib_sa_mad_get_payload_ptr(p_sa_mad);
+
+ comp_mask = p_sa_mad->comp_mask;
+
+ if (OSM_LOG_IS_ACTIVE_V2(sa->p_log, OSM_LOG_DEBUG))
+ osm_dump_service_record_v2(sa->p_log, p_recvd_service_rec,
+ FILE_ID, OSM_LOG_DEBUG);
+
+ if ((comp_mask & (IB_SR_COMPMASK_SID | IB_SR_COMPMASK_SGID)) !=
+ (IB_SR_COMPMASK_SID | IB_SR_COMPMASK_SGID)) {
+ cl_plock_release(sa->p_lock);
+ OSM_LOG(sa->p_log, OSM_LOG_VERBOSE,
+ "Component Mask RID check failed for METHOD_SET\n");
+ osm_sa_send_error(sa, p_madw, IB_SA_MAD_STATUS_REQ_INVALID);
+ goto Exit;
+ }
+
+ /* if we were not provided with a service lease make it infinite */
+ if (!(comp_mask & IB_SR_COMPMASK_SLEASE)) {
+ OSM_LOG(sa->p_log, OSM_LOG_DEBUG,
+ "ServiceLease Component Mask not set - using infinite lease\n");
+ p_recvd_service_rec->service_lease = 0xFFFFFFFF;
+ }
+
+ /* If Record exists with matching RID */
+ p_svcr = osm_svcr_get_by_rid(sa->p_subn, sa->p_log,
+ p_recvd_service_rec);
+
+ if (p_svcr == NULL) {
+ /* Create the instance of the osm_svcr_t object */
+ p_svcr = osm_svcr_new(p_recvd_service_rec);
+ if (p_svcr == NULL) {
+ cl_plock_release(sa->p_lock);
+ OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 2411: "
+ "Failed to create new service record\n");
+
+ osm_sa_send_error(sa, p_madw,
+ IB_SA_MAD_STATUS_NO_RESOURCES);
+ goto Exit;
+ }
+
+ /* Add this new osm_svcr_t object to subnet object */
+ osm_svcr_insert_to_db(sa->p_subn, sa->p_log, p_svcr);
+
+ } else /* Update the old instance of the osm_svcr_t object */
+ osm_svcr_init(p_svcr, p_recvd_service_rec);
+
+ cl_plock_release(sa->p_lock);
+
+ if (p_recvd_service_rec->service_lease != 0xFFFFFFFF) {
+#if 0
+ cl_timer_trim(&sa->sr_timer,
+ p_recvd_service_rec->service_lease * 1000);
+#endif
+ /* This was a bug since no check was made to see if too long */
+ /* just make sure the timer works - get a call back within a second */
+ cl_timer_trim(&sa->sr_timer, 1000);
+ p_svcr->modified_time = cl_get_time_stamp_sec();
+ }
+
+ p_sr_item = malloc(SA_SR_RESP_SIZE);
+ if (p_sr_item == NULL) {
+ OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 2412: "
+ "Unable to acquire Service record\n");
+ osm_sa_send_error(sa, p_madw, IB_SA_MAD_STATUS_NO_RESOURCES);
+ goto Exit;
+ }
+
+ if ((comp_mask & IB_SR_COMPMASK_SPKEY) != IB_SR_COMPMASK_SPKEY)
+ /* Set the Default Service P_Key in the response */
+ p_recvd_service_rec->service_pkey = IB_DEFAULT_PKEY;
+
+ p_sr_item->resp.service_rec = *p_recvd_service_rec;
+ cl_qlist_init(&sr_list);
+
+ cl_qlist_insert_tail(&sr_list, &p_sr_item->list_item);
+
+ sr_rcv_respond(sa, p_madw, &sr_list);
+
+Exit:
+ OSM_LOG_EXIT(sa->p_log);
+}
+
+static void sr_rcv_process_delete_method(osm_sa_t * sa, IN osm_madw_t * p_madw)
+{
+ ib_sa_mad_t *p_sa_mad;
+ ib_service_record_t *p_recvd_service_rec;
+ osm_svcr_t *p_svcr;
+ osm_sa_item_t *p_sr_item;
+ cl_qlist_t sr_list;
+
+ OSM_LOG_ENTER(sa->p_log);
+
+ CL_ASSERT(p_madw);
+
+ p_sa_mad = osm_madw_get_sa_mad_ptr(p_madw);
+ p_recvd_service_rec =
+ (ib_service_record_t *) ib_sa_mad_get_payload_ptr(p_sa_mad);
+
+ if (OSM_LOG_IS_ACTIVE_V2(sa->p_log, OSM_LOG_DEBUG))
+ osm_dump_service_record_v2(sa->p_log, p_recvd_service_rec,
+ FILE_ID, OSM_LOG_DEBUG);
+
+ /* If Record exists with matching RID */
+ p_svcr = osm_svcr_get_by_rid(sa->p_subn, sa->p_log,
+ p_recvd_service_rec);
+
+ if (p_svcr == NULL) {
+ cl_plock_release(sa->p_lock);
+ OSM_LOG(sa->p_log, OSM_LOG_DEBUG,
+ "No records matched the RID\n");
+ osm_sa_send_error(sa, p_madw, IB_SA_MAD_STATUS_NO_RECORDS);
+ goto Exit;
+ }
+
+ osm_svcr_remove_from_db(sa->p_subn, sa->p_log, p_svcr);
+ cl_plock_release(sa->p_lock);
+
+ p_sr_item = malloc(SA_SR_RESP_SIZE);
+ if (p_sr_item == NULL) {
+ OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 2413: "
+ "Unable to acquire Service record\n");
+ osm_sa_send_error(sa, p_madw, IB_SA_MAD_STATUS_NO_RESOURCES);
+ osm_svcr_delete(p_svcr);
+ goto Exit;
+ }
+
+ /* provide back the copy of the record */
+ p_sr_item->resp.service_rec = p_svcr->service_record;
+ cl_qlist_init(&sr_list);
+
+ cl_qlist_insert_tail(&sr_list, &p_sr_item->list_item);
+
+ osm_svcr_delete(p_svcr);
+
+ sr_rcv_respond(sa, p_madw, &sr_list);
+
+Exit:
+ OSM_LOG_EXIT(sa->p_log);
+ return;
+}
+
+void osm_sr_rcv_process(IN void *context, IN void *data)
+{
+ osm_sa_t *sa = context;
+ osm_madw_t *p_madw = data;
+ ib_sa_mad_t *p_sa_mad;
+ boolean_t valid;
+
+ OSM_LOG_ENTER(sa->p_log);
+
+ CL_ASSERT(p_madw);
+
+ p_sa_mad = osm_madw_get_sa_mad_ptr(p_madw);
+
+ CL_ASSERT(p_sa_mad->attr_id == IB_MAD_ATTR_SERVICE_RECORD);
+
+ switch (p_sa_mad->method) {
+ case IB_MAD_METHOD_SET:
+ cl_plock_excl_acquire(sa->p_lock);
+ valid = validate_sr(sa, p_madw);
+ if (!valid) {
+ cl_plock_release(sa->p_lock);
+ OSM_LOG(sa->p_log, OSM_LOG_VERBOSE,
+ "Component Mask check failed for set request\n");
+ osm_sa_send_error(sa, p_madw,
+ IB_SA_MAD_STATUS_REQ_INVALID);
+ goto Exit;
+ }
+ sr_rcv_process_set_method(sa, p_madw);
+ break;
+ case IB_MAD_METHOD_DELETE:
+ cl_plock_excl_acquire(sa->p_lock);
+ valid = validate_sr(sa, p_madw);
+ if (!valid) {
+ cl_plock_release(sa->p_lock);
+ OSM_LOG(sa->p_log, OSM_LOG_DEBUG,
+ "Component Mask check failed for delete request\n");
+ osm_sa_send_error(sa, p_madw,
+ IB_SA_MAD_STATUS_REQ_INVALID);
+ goto Exit;
+ }
+ sr_rcv_process_delete_method(sa, p_madw);
+ break;
+ case IB_MAD_METHOD_GET:
+ case IB_MAD_METHOD_GETTABLE:
+ sr_rcv_process_get_method(sa, p_madw);
+ break;
+ default:
+ OSM_LOG(sa->p_log, OSM_LOG_DEBUG,
+ "Unsupported Method (%s) for ServiceRecord request\n",
+ ib_get_sa_method_str(p_sa_mad->method));
+ osm_sa_send_error(sa, p_madw, IB_MAD_STATUS_UNSUP_METHOD_ATTR);
+ break;
+ }
+
+Exit:
+ OSM_LOG_EXIT(sa->p_log);
+}
+
+void osm_sr_rcv_lease_cb(IN void *context)
+{
+ osm_sa_t *sa = context;
+ cl_list_item_t *p_list_item;
+ cl_list_item_t *p_next_list_item;
+ osm_svcr_t *p_svcr;
+ uint32_t curr_time;
+ uint32_t elapsed_time;
+ uint32_t trim_time = 20; /* maxiaml timer refresh is 20 seconds */
+
+ OSM_LOG_ENTER(sa->p_log);
+
+ cl_plock_excl_acquire(sa->p_lock);
+
+ p_list_item = cl_qlist_head(&sa->p_subn->sa_sr_list);
+
+ while (p_list_item != cl_qlist_end(&sa->p_subn->sa_sr_list)) {
+ p_svcr = (osm_svcr_t *) p_list_item;
+
+ if (p_svcr->service_record.service_lease == 0xFFFFFFFF) {
+ p_list_item = cl_qlist_next(p_list_item);
+ continue;
+ }
+
+ /* current time in seconds */
+ curr_time = cl_get_time_stamp_sec();
+ /* elapsed time from last modify */
+ elapsed_time = curr_time - p_svcr->modified_time;
+ /* but it can not be less then 1 */
+ if (elapsed_time < 1)
+ elapsed_time = 1;
+
+ if (elapsed_time < p_svcr->lease_period) {
+ /*
+ Just update the service lease period
+ note: for simplicity we work with a uint32_t field
+ external to the network order lease_period of the MAD
+ */
+ p_svcr->lease_period -= elapsed_time;
+
+ OSM_LOG(sa->p_log, OSM_LOG_DEBUG,
+ "Remaining time for Service Name:%s is:0x%X\n",
+ p_svcr->service_record.service_name,
+ p_svcr->lease_period);
+
+ p_svcr->modified_time = curr_time;
+
+ /* Update the trim timer */
+ if (trim_time > p_svcr->lease_period) {
+ trim_time = p_svcr->lease_period;
+ if (trim_time < 1)
+ trim_time = 1;
+ }
+
+ p_list_item = cl_qlist_next(p_list_item);
+ continue;
+
+ } else {
+ p_next_list_item = cl_qlist_next(p_list_item);
+
+ /* Remove the service Record */
+ osm_svcr_remove_from_db(sa->p_subn, sa->p_log, p_svcr);
+
+ osm_svcr_delete(p_svcr);
+
+ p_list_item = p_next_list_item;
+ continue;
+ }
+ }
+
+ /* Release the Lock */
+ cl_plock_release(sa->p_lock);
+
+ if (trim_time != 0xFFFFFFFF) {
+ cl_timer_trim(&sa->sr_timer, trim_time * 1000); /* Convert to milli seconds */
+ }
+
+ OSM_LOG_EXIT(sa->p_log);
+}
diff --git a/contrib/ofed/opensm/opensm/osm_sa_slvl_record.c b/contrib/ofed/opensm/opensm/osm_sa_slvl_record.c
new file mode 100644
index 0000000..83f0cb1
--- /dev/null
+++ b/contrib/ofed/opensm/opensm/osm_sa_slvl_record.c
@@ -0,0 +1,299 @@
+/*
+ * Copyright (c) 2004-2009 Voltaire, Inc. All rights reserved.
+ * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved.
+ * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
+ * Copyright (c) 2013 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+/*
+ * Abstract:
+ * Implementation of osm_slvl_rec_rcv_t.
+ * This object represents the SLtoVL Mapping Query Receiver object.
+ * This object is part of the opensm family of objects.
+ */
+
+#if HAVE_CONFIG_H
+# include <config.h>
+#endif /* HAVE_CONFIG_H */
+
+#include <string.h>
+#include <iba/ib_types.h>
+#include <complib/cl_qmap.h>
+#include <complib/cl_passivelock.h>
+#include <complib/cl_debug.h>
+#include <complib/cl_qlist.h>
+#include <opensm/osm_file_ids.h>
+#define FILE_ID OSM_FILE_SA_SLVL_RECORD_C
+#include <vendor/osm_vendor_api.h>
+#include <opensm/osm_port.h>
+#include <opensm/osm_node.h>
+#include <opensm/osm_helper.h>
+#include <opensm/osm_pkey.h>
+#include <opensm/osm_sa.h>
+
+#define SA_SLVL_RESP_SIZE SA_ITEM_RESP_SIZE(slvl_rec)
+
+typedef struct osm_slvl_search_ctxt {
+ const ib_slvl_table_record_t *p_rcvd_rec;
+ ib_net64_t comp_mask;
+ uint8_t in_port_num;
+ cl_qlist_t *p_list;
+ osm_sa_t *sa;
+ const osm_physp_t *p_req_physp;
+} osm_slvl_search_ctxt_t;
+
+static void sa_slvl_create(IN osm_sa_t * sa, IN const osm_physp_t * p_physp,
+ IN osm_slvl_search_ctxt_t * p_ctxt,
+ IN uint8_t in_port_idx)
+{
+ osm_sa_item_t *p_rec_item;
+ uint16_t lid;
+
+ OSM_LOG_ENTER(sa->p_log);
+
+ p_rec_item = malloc(SA_SLVL_RESP_SIZE);
+ if (p_rec_item == NULL) {
+ OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 2602: "
+ "rec_item alloc failed\n");
+ goto Exit;
+ }
+
+ if (p_physp->p_node->node_info.node_type != IB_NODE_TYPE_SWITCH)
+ lid = p_physp->port_info.base_lid;
+ else
+ lid = osm_node_get_base_lid(p_physp->p_node, 0);
+
+ OSM_LOG(sa->p_log, OSM_LOG_DEBUG,
+ "New SLtoVL Map for: OUT port 0x%016" PRIx64
+ ", lid 0x%X, port %u to In Port:%u\n",
+ cl_ntoh64(osm_physp_get_port_guid(p_physp)),
+ cl_ntoh16(lid), osm_physp_get_port_num(p_physp), in_port_idx);
+
+ memset(p_rec_item, 0, SA_SLVL_RESP_SIZE);
+
+ p_rec_item->resp.slvl_rec.lid = lid;
+ if (p_physp->p_node->node_info.node_type == IB_NODE_TYPE_SWITCH) {
+ p_rec_item->resp.slvl_rec.out_port_num = osm_physp_get_port_num(p_physp);
+ p_rec_item->resp.slvl_rec.in_port_num = in_port_idx;
+ }
+ p_rec_item->resp.slvl_rec.slvl_tbl =
+ *(osm_physp_get_slvl_tbl(p_physp, in_port_idx));
+
+ cl_qlist_insert_tail(p_ctxt->p_list, &p_rec_item->list_item);
+
+Exit:
+ OSM_LOG_EXIT(sa->p_log);
+}
+
+static void sa_slvl_by_comp_mask(IN osm_sa_t * sa, IN const osm_port_t * p_port,
+ osm_slvl_search_ctxt_t * p_ctxt)
+{
+ const ib_slvl_table_record_t *p_rcvd_rec;
+ ib_net64_t comp_mask;
+ const osm_physp_t *p_out_physp, *p_in_physp;
+ uint8_t in_port_num, out_port_num;
+ uint8_t num_ports;
+ uint8_t in_port_start, in_port_end;
+ uint8_t out_port_start, out_port_end;
+ const osm_physp_t *p_req_physp;
+
+ OSM_LOG_ENTER(sa->p_log);
+
+ p_rcvd_rec = p_ctxt->p_rcvd_rec;
+ comp_mask = p_ctxt->comp_mask;
+ num_ports = osm_node_get_num_physp(p_port->p_node);
+ in_port_start = 0;
+ in_port_end = num_ports - 1;
+ out_port_start = 0;
+ out_port_end = num_ports - 1;
+ p_req_physp = p_ctxt->p_req_physp;
+
+ if (p_port->p_node->node_info.node_type != IB_NODE_TYPE_SWITCH) {
+ OSM_LOG(sa->p_log, OSM_LOG_DEBUG,
+ "Using Physical Default Port Number: 0x%X (for End Node)\n",
+ p_port->p_physp->port_num);
+ p_out_physp = p_port->p_physp;
+ /* check that the p_out_physp and the p_req_physp share a pkey */
+ if (osm_physp_share_pkey(sa->p_log, p_req_physp, p_out_physp,
+ sa->p_subn->opt.allow_both_pkeys))
+ sa_slvl_create(sa, p_out_physp, p_ctxt, 0);
+ } else {
+ if (comp_mask & IB_SLVL_COMPMASK_OUT_PORT)
+ out_port_start = out_port_end =
+ p_rcvd_rec->out_port_num;
+ if (comp_mask & IB_SLVL_COMPMASK_IN_PORT)
+ in_port_start = in_port_end = p_rcvd_rec->in_port_num;
+
+ for (out_port_num = out_port_start;
+ out_port_num <= out_port_end; out_port_num++) {
+ p_out_physp =
+ osm_node_get_physp_ptr(p_port->p_node,
+ out_port_num);
+ if (!p_out_physp)
+ continue;
+
+ for (in_port_num = in_port_start;
+ in_port_num <= in_port_end; in_port_num++) {
+#if 0
+ if (out_port_num && out_port_num == in_port_num)
+ continue;
+#endif
+
+ p_in_physp =
+ osm_node_get_physp_ptr(p_port->p_node,
+ in_port_num);
+ if (!p_in_physp)
+ continue;
+
+ /* if the requester and the p_out_physp don't share a pkey -
+ continue */
+ if (!osm_physp_share_pkey(sa->p_log, p_req_physp, p_out_physp,
+ sa->p_subn->opt.allow_both_pkeys))
+ continue;
+
+ sa_slvl_create(sa, p_out_physp, p_ctxt,
+ in_port_num);
+ }
+ }
+ }
+ OSM_LOG_EXIT(sa->p_log);
+}
+
+static void sa_slvl_by_comp_mask_cb(IN cl_map_item_t * p_map_item, IN void *cxt)
+{
+ const osm_port_t *p_port = (osm_port_t *) p_map_item;
+ osm_slvl_search_ctxt_t *p_ctxt = cxt;
+
+ sa_slvl_by_comp_mask(p_ctxt->sa, p_port, p_ctxt);
+}
+
+void osm_slvl_rec_rcv_process(IN void *ctx, IN void *data)
+{
+ osm_sa_t *sa = ctx;
+ osm_madw_t *p_madw = data;
+ const ib_sa_mad_t *p_rcvd_mad;
+ const ib_slvl_table_record_t *p_rcvd_rec;
+ const osm_port_t *p_port = NULL;
+ cl_qlist_t rec_list;
+ osm_slvl_search_ctxt_t context;
+ ib_api_status_t status = IB_SUCCESS;
+ ib_net64_t comp_mask;
+ osm_physp_t *p_req_physp;
+
+ CL_ASSERT(sa);
+
+ OSM_LOG_ENTER(sa->p_log);
+
+ CL_ASSERT(p_madw);
+
+ p_rcvd_mad = osm_madw_get_sa_mad_ptr(p_madw);
+ p_rcvd_rec =
+ (ib_slvl_table_record_t *) ib_sa_mad_get_payload_ptr(p_rcvd_mad);
+ comp_mask = p_rcvd_mad->comp_mask;
+
+ CL_ASSERT(p_rcvd_mad->attr_id == IB_MAD_ATTR_SLVL_RECORD);
+
+ /* we only support SubnAdmGet and SubnAdmGetTable methods */
+ if (p_rcvd_mad->method != IB_MAD_METHOD_GET &&
+ p_rcvd_mad->method != IB_MAD_METHOD_GETTABLE) {
+ OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 2604: "
+ "Unsupported Method (%s) for SL2VLRecord request\n",
+ ib_get_sa_method_str(p_rcvd_mad->method));
+ osm_sa_send_error(sa, p_madw, IB_MAD_STATUS_UNSUP_METHOD_ATTR);
+ goto Exit;
+ }
+
+ cl_plock_acquire(sa->p_lock);
+
+ /* update the requester physical port */
+ p_req_physp = osm_get_physp_by_mad_addr(sa->p_log, sa->p_subn,
+ osm_madw_get_mad_addr_ptr
+ (p_madw));
+ if (p_req_physp == NULL) {
+ cl_plock_release(sa->p_lock);
+ OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 2603: "
+ "Cannot find requester physical port\n");
+ goto Exit;
+ }
+ OSM_LOG(sa->p_log, OSM_LOG_DEBUG,
+ "Requester port GUID 0x%" PRIx64 "\n",
+ cl_ntoh64(osm_physp_get_port_guid(p_req_physp)));
+
+ cl_qlist_init(&rec_list);
+
+ context.p_rcvd_rec = p_rcvd_rec;
+ context.p_list = &rec_list;
+ context.comp_mask = p_rcvd_mad->comp_mask;
+ context.sa = sa;
+ context.in_port_num = p_rcvd_rec->in_port_num;
+ context.p_req_physp = p_req_physp;
+
+ OSM_LOG(sa->p_log, OSM_LOG_DEBUG,
+ "Got Query Lid:%u(%02X), In-Port:0x%02X(%02X), Out-Port:0x%02X(%02X)\n",
+ cl_ntoh16(p_rcvd_rec->lid),
+ (comp_mask & IB_SLVL_COMPMASK_LID) != 0,
+ p_rcvd_rec->in_port_num,
+ (comp_mask & IB_SLVL_COMPMASK_IN_PORT) != 0,
+ p_rcvd_rec->out_port_num,
+ (comp_mask & IB_SLVL_COMPMASK_OUT_PORT) != 0);
+
+ /*
+ If the user specified a LID, it obviously narrows our
+ work load, since we don't have to search every port
+ */
+ if (comp_mask & IB_SLVL_COMPMASK_LID) {
+ p_port = osm_get_port_by_lid(sa->p_subn, p_rcvd_rec->lid);
+ if (!p_port) {
+ status = IB_NOT_FOUND;
+ OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 2608: "
+ "No port found with LID %u\n",
+ cl_ntoh16(p_rcvd_rec->lid));
+ }
+ }
+
+ if (status == IB_SUCCESS) {
+ /* if we have a unique port - no need for a port search */
+ if (p_port)
+ /* this does the loop on all the port phys ports */
+ sa_slvl_by_comp_mask(sa, p_port, &context);
+ else
+ cl_qmap_apply_func(&sa->p_subn->port_guid_tbl,
+ sa_slvl_by_comp_mask_cb, &context);
+ }
+
+ cl_plock_release(sa->p_lock);
+
+ osm_sa_respond(sa, p_madw, sizeof(ib_slvl_table_record_t), &rec_list);
+
+Exit:
+ OSM_LOG_EXIT(sa->p_log);
+}
diff --git a/contrib/ofed/opensm/opensm/osm_sa_sminfo_record.c b/contrib/ofed/opensm/opensm/osm_sa_sminfo_record.c
new file mode 100644
index 0000000..243b6a4
--- /dev/null
+++ b/contrib/ofed/opensm/opensm/osm_sa_sminfo_record.c
@@ -0,0 +1,328 @@
+/*
+ * Copyright (c) 2004-2009 Voltaire, Inc. All rights reserved.
+ * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved.
+ * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
+ * Copyright (c) 2013 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+/*
+ * Abstract:
+ * Implementation of osm_smir_rcv_t.
+ * This object represents the SMInfo Receiver object.
+ * This object is part of the opensm family of objects.
+ */
+
+#if HAVE_CONFIG_H
+# include <config.h>
+#endif /* HAVE_CONFIG_H */
+
+#include <string.h>
+#include <iba/ib_types.h>
+#include <complib/cl_qmap.h>
+#include <complib/cl_passivelock.h>
+#include <complib/cl_debug.h>
+#include <complib/cl_qlist.h>
+#include <opensm/osm_file_ids.h>
+#define FILE_ID OSM_FILE_SA_SMINFO_RECORD_C
+#include <vendor/osm_vendor_api.h>
+#include <opensm/osm_madw.h>
+#include <opensm/osm_log.h>
+#include <opensm/osm_subnet.h>
+#include <opensm/osm_mad_pool.h>
+#include <opensm/osm_helper.h>
+#include <opensm/osm_msgdef.h>
+#include <opensm/osm_port.h>
+#include <opensm/osm_pkey.h>
+#include <opensm/osm_remote_sm.h>
+#include <opensm/osm_sa.h>
+#include <opensm/osm_opensm.h>
+
+#define SA_SMIR_RESP_SIZE SA_ITEM_RESP_SIZE(sminfo_rec)
+
+typedef struct osm_smir_search_ctxt {
+ const ib_sminfo_record_t *p_rcvd_rec;
+ ib_net64_t comp_mask;
+ cl_qlist_t *p_list;
+ osm_sa_t *sa;
+ const osm_physp_t *p_req_physp;
+} osm_smir_search_ctxt_t;
+
+static ib_api_status_t smir_rcv_new_smir(IN osm_sa_t * sa,
+ IN const osm_port_t * p_port,
+ IN cl_qlist_t * p_list,
+ IN ib_net64_t const guid,
+ IN ib_net32_t const act_count,
+ IN uint8_t const pri_state,
+ IN const osm_physp_t * p_req_physp)
+{
+ osm_sa_item_t *p_rec_item;
+ ib_api_status_t status = IB_SUCCESS;
+
+ OSM_LOG_ENTER(sa->p_log);
+
+ p_rec_item = malloc(SA_SMIR_RESP_SIZE);
+ if (p_rec_item == NULL) {
+ OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 2801: "
+ "rec_item alloc failed\n");
+ status = IB_INSUFFICIENT_RESOURCES;
+ goto Exit;
+ }
+
+ OSM_LOG(sa->p_log, OSM_LOG_DEBUG,
+ "New SMInfo: GUID 0x%016" PRIx64 "\n", cl_ntoh64(guid));
+
+ memset(p_rec_item, 0, SA_SMIR_RESP_SIZE);
+
+ p_rec_item->resp.sminfo_rec.lid = osm_port_get_base_lid(p_port);
+ p_rec_item->resp.sminfo_rec.sm_info.guid = guid;
+ p_rec_item->resp.sminfo_rec.sm_info.act_count = act_count;
+ p_rec_item->resp.sminfo_rec.sm_info.pri_state = pri_state;
+
+ cl_qlist_insert_tail(p_list, &p_rec_item->list_item);
+
+Exit:
+ OSM_LOG_EXIT(sa->p_log);
+ return status;
+}
+
+static void sa_smir_by_comp_mask(IN osm_sa_t * sa,
+ IN const osm_remote_sm_t * p_rem_sm,
+ osm_smir_search_ctxt_t * p_ctxt)
+{
+ const ib_sminfo_record_t *const p_rcvd_rec = p_ctxt->p_rcvd_rec;
+ const osm_physp_t *const p_req_physp = p_ctxt->p_req_physp;
+ ib_net64_t const comp_mask = p_ctxt->comp_mask;
+ osm_port_t *p_port;
+
+ OSM_LOG_ENTER(sa->p_log);
+
+ if (comp_mask & IB_SMIR_COMPMASK_GUID) {
+ if (p_rem_sm->smi.guid != p_rcvd_rec->sm_info.guid)
+ goto Exit;
+ }
+
+ if (comp_mask & IB_SMIR_COMPMASK_PRIORITY) {
+ if (ib_sminfo_get_priority(&p_rem_sm->smi) !=
+ ib_sminfo_get_priority(&p_rcvd_rec->sm_info))
+ goto Exit;
+ }
+
+ if (comp_mask & IB_SMIR_COMPMASK_SMSTATE) {
+ if (ib_sminfo_get_state(&p_rem_sm->smi) !=
+ ib_sminfo_get_state(&p_rcvd_rec->sm_info))
+ goto Exit;
+ }
+
+ /* Implement any other needed search cases */
+ p_port = osm_get_port_by_guid(sa->p_subn, p_rem_sm->smi.guid);
+
+ if (p_port == NULL) {
+ OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 2810: "
+ "No port for remote sm\n");
+ goto Exit;
+ }
+
+ smir_rcv_new_smir(sa, p_port, p_ctxt->p_list,
+ p_rem_sm->smi.guid, p_rem_sm->smi.act_count,
+ p_rem_sm->smi.pri_state, p_req_physp);
+
+Exit:
+ OSM_LOG_EXIT(sa->p_log);
+}
+
+static void sa_smir_by_comp_mask_cb(IN cl_map_item_t * p_map_item, IN void *cxt)
+{
+ const osm_remote_sm_t *p_rem_sm = (osm_remote_sm_t *) p_map_item;
+ osm_smir_search_ctxt_t *p_ctxt = cxt;
+
+ sa_smir_by_comp_mask(p_ctxt->sa, p_rem_sm, p_ctxt);
+}
+
+void osm_smir_rcv_process(IN void *ctx, IN void *data)
+{
+ osm_sa_t *sa = ctx;
+ osm_madw_t *p_madw = data;
+ const ib_sa_mad_t *sad_mad;
+ const ib_sminfo_record_t *p_rcvd_rec;
+ const osm_port_t *p_port = NULL;
+ const ib_sm_info_t *p_smi;
+ cl_qlist_t rec_list;
+ osm_smir_search_ctxt_t context;
+ ib_api_status_t status = IB_SUCCESS;
+ ib_net64_t comp_mask;
+ ib_net64_t port_guid;
+ osm_physp_t *p_req_physp;
+ osm_port_t *local_port;
+ osm_remote_sm_t *p_rem_sm;
+ cl_qmap_t *p_sm_guid_tbl;
+ uint8_t pri_state;
+
+ CL_ASSERT(sa);
+
+ OSM_LOG_ENTER(sa->p_log);
+
+ CL_ASSERT(p_madw);
+
+ sad_mad = osm_madw_get_sa_mad_ptr(p_madw);
+ p_rcvd_rec = (ib_sminfo_record_t *) ib_sa_mad_get_payload_ptr(sad_mad);
+ comp_mask = sad_mad->comp_mask;
+
+ CL_ASSERT(sad_mad->attr_id == IB_MAD_ATTR_SMINFO_RECORD);
+
+ /* we only support SubnAdmGet and SubnAdmGetTable methods */
+ if (sad_mad->method != IB_MAD_METHOD_GET &&
+ sad_mad->method != IB_MAD_METHOD_GETTABLE) {
+ OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 2804: "
+ "Unsupported Method (%s) for SMInfoRecord request\n",
+ ib_get_sa_method_str(sad_mad->method));
+ osm_sa_send_error(sa, p_madw, IB_MAD_STATUS_UNSUP_METHOD_ATTR);
+ goto Exit;
+ }
+
+ cl_plock_acquire(sa->p_lock);
+
+ /* update the requester physical port */
+ p_req_physp = osm_get_physp_by_mad_addr(sa->p_log, sa->p_subn,
+ osm_madw_get_mad_addr_ptr
+ (p_madw));
+ if (p_req_physp == NULL) {
+ cl_plock_release(sa->p_lock);
+ OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 2803: "
+ "Cannot find requester physical port\n");
+ goto Exit;
+ }
+
+ if (OSM_LOG_IS_ACTIVE_V2(sa->p_log, OSM_LOG_DEBUG)) {
+ OSM_LOG(sa->p_log, OSM_LOG_DEBUG,
+ "Requester port GUID 0x%" PRIx64 "\n",
+ cl_ntoh64(osm_physp_get_port_guid(p_req_physp)));
+ osm_dump_sm_info_record_v2(sa->p_log, p_rcvd_rec, FILE_ID, OSM_LOG_DEBUG);
+ }
+
+ p_smi = &p_rcvd_rec->sm_info;
+
+ cl_qlist_init(&rec_list);
+
+ context.p_rcvd_rec = p_rcvd_rec;
+ context.p_list = &rec_list;
+ context.comp_mask = sad_mad->comp_mask;
+ context.sa = sa;
+ context.p_req_physp = p_req_physp;
+
+ /*
+ If the user specified a LID, it obviously narrows our
+ work load, since we don't have to search every port
+ */
+ if (comp_mask & IB_SMIR_COMPMASK_LID) {
+ p_port = osm_get_port_by_lid(sa->p_subn, p_rcvd_rec->lid);
+ if (!p_port) {
+ status = IB_NOT_FOUND;
+ OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 2806: "
+ "No port found with LID %u\n",
+ cl_ntoh16(p_rcvd_rec->lid));
+ }
+ }
+
+ if (status == IB_SUCCESS) {
+ /* Handle our own SM first */
+ local_port = osm_get_port_by_guid(sa->p_subn,
+ sa->p_subn->sm_port_guid);
+ if (!local_port) {
+ cl_plock_release(sa->p_lock);
+ OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 2809: "
+ "No port found with GUID 0x%016" PRIx64 "\n",
+ cl_ntoh64(sa->p_subn->sm_port_guid));
+ goto Exit;
+ }
+
+ if (!p_port || local_port == p_port) {
+ if (FALSE ==
+ osm_physp_share_pkey(sa->p_log, p_req_physp,
+ local_port->p_physp,
+ sa->p_subn->opt.allow_both_pkeys)) {
+ cl_plock_release(sa->p_lock);
+ OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 2805: "
+ "Cannot get SMInfo record due to pkey violation\n");
+ goto Exit;
+ }
+
+ /* Check that other search components specified match */
+ if ((comp_mask & IB_SMIR_COMPMASK_GUID) &&
+ sa->p_subn->sm_port_guid != p_smi->guid)
+ goto Remotes;
+ if ((comp_mask & IB_SMIR_COMPMASK_PRIORITY) &&
+ sa->p_subn->opt.sm_priority !=
+ ib_sminfo_get_priority(p_smi))
+ goto Remotes;
+ if ((comp_mask & IB_SMIR_COMPMASK_SMSTATE) &&
+ sa->p_subn->sm_state != ib_sminfo_get_state(p_smi))
+ goto Remotes;
+
+ /* Now, add local SMInfo to list */
+ pri_state = sa->p_subn->sm_state & 0x0F;
+ pri_state |= (sa->p_subn->opt.sm_priority & 0x0F) << 4;
+ smir_rcv_new_smir(sa, local_port, context.p_list,
+ sa->p_subn->sm_port_guid,
+ cl_ntoh32(sa->p_subn->p_osm->stats.
+ qp0_mads_sent), pri_state,
+ p_req_physp);
+ }
+
+ Remotes:
+ if (p_port && p_port != local_port) {
+ /* Find remote SM corresponding to p_port */
+ port_guid = osm_port_get_guid(p_port);
+ p_sm_guid_tbl = &sa->p_subn->sm_guid_tbl;
+ p_rem_sm =
+ (osm_remote_sm_t *) cl_qmap_get(p_sm_guid_tbl,
+ port_guid);
+ if (p_rem_sm !=
+ (osm_remote_sm_t *) cl_qmap_end(p_sm_guid_tbl))
+ sa_smir_by_comp_mask(sa, p_rem_sm, &context);
+ else
+ OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 280A: "
+ "No remote SM for GUID 0x%016" PRIx64
+ "\n", cl_ntoh64(port_guid));
+ } else if (!p_port) {
+ /* Go over all other known (remote) SMs */
+ cl_qmap_apply_func(&sa->p_subn->sm_guid_tbl,
+ sa_smir_by_comp_mask_cb, &context);
+ }
+ }
+
+ cl_plock_release(sa->p_lock);
+
+ osm_sa_respond(sa, p_madw, sizeof(ib_sminfo_record_t), &rec_list);
+
+Exit:
+ OSM_LOG_EXIT(sa->p_log);
+}
diff --git a/contrib/ofed/opensm/opensm/osm_sa_sw_info_record.c b/contrib/ofed/opensm/opensm/osm_sa_sw_info_record.c
new file mode 100644
index 0000000..acbe3a6
--- /dev/null
+++ b/contrib/ofed/opensm/opensm/osm_sa_sw_info_record.c
@@ -0,0 +1,264 @@
+/*
+ * Copyright (c) 2004-2009 Voltaire, Inc. All rights reserved.
+ * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved.
+ * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
+ * Copyright (c) 2013 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+/*
+ * Abstract:
+ * Implementation of osm_sir_rcv_t.
+ * This object represents the SwitchInfo Receiver object.
+ * This object is part of the opensm family of objects.
+ */
+
+#if HAVE_CONFIG_H
+# include <config.h>
+#endif /* HAVE_CONFIG_H */
+
+#include <string.h>
+#include <iba/ib_types.h>
+#include <complib/cl_debug.h>
+#include <complib/cl_qlist.h>
+#include <opensm/osm_file_ids.h>
+#define FILE_ID OSM_FILE_SA_SW_INFO_RECORD_C
+#include <vendor/osm_vendor_api.h>
+#include <opensm/osm_node.h>
+#include <opensm/osm_helper.h>
+#include <opensm/osm_pkey.h>
+#include <opensm/osm_sa.h>
+
+#define SA_SIR_RESP_SIZE SA_ITEM_RESP_SIZE(swinfo_rec)
+
+typedef struct osm_sir_search_ctxt {
+ const ib_switch_info_record_t *p_rcvd_rec;
+ ib_net64_t comp_mask;
+ cl_qlist_t *p_list;
+ osm_sa_t *sa;
+ const osm_physp_t *p_req_physp;
+} osm_sir_search_ctxt_t;
+
+static ib_api_status_t sir_rcv_new_sir(IN osm_sa_t * sa,
+ IN const osm_switch_t * p_sw,
+ IN cl_qlist_t * p_list,
+ IN ib_net16_t lid)
+{
+ osm_sa_item_t *p_rec_item;
+ ib_api_status_t status = IB_SUCCESS;
+
+ OSM_LOG_ENTER(sa->p_log);
+
+ p_rec_item = malloc(SA_SIR_RESP_SIZE);
+ if (p_rec_item == NULL) {
+ OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 5308: "
+ "rec_item alloc failed\n");
+ status = IB_INSUFFICIENT_RESOURCES;
+ goto Exit;
+ }
+
+ OSM_LOG(sa->p_log, OSM_LOG_DEBUG,
+ "New SwitchInfoRecord: lid %u\n", cl_ntoh16(lid));
+
+ memset(p_rec_item, 0, SA_SIR_RESP_SIZE);
+
+ p_rec_item->resp.swinfo_rec.lid = lid;
+ p_rec_item->resp.swinfo_rec.switch_info = p_sw->switch_info;
+
+ cl_qlist_insert_tail(p_list, &p_rec_item->list_item);
+
+Exit:
+ OSM_LOG_EXIT(sa->p_log);
+ return status;
+}
+
+static void sir_rcv_create_sir(IN osm_sa_t * sa, IN const osm_switch_t * p_sw,
+ IN cl_qlist_t * p_list, IN ib_net16_t match_lid,
+ IN const osm_physp_t * p_req_physp)
+{
+ osm_port_t *p_port;
+ const osm_physp_t *p_physp;
+ uint16_t match_lid_ho;
+ ib_net16_t min_lid_ho;
+ ib_net16_t max_lid_ho;
+
+ OSM_LOG_ENTER(sa->p_log);
+
+ OSM_LOG(sa->p_log, OSM_LOG_DEBUG,
+ "Looking for SwitchInfoRecord with LID: %u\n",
+ cl_ntoh16(match_lid));
+
+ /* In switches, the port guid is the node guid. */
+ p_port =
+ osm_get_port_by_guid(sa->p_subn, p_sw->p_node->node_info.port_guid);
+ if (!p_port) {
+ OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 530A: "
+ "Failed to find Port by Node Guid:0x%016" PRIx64
+ "\n", cl_ntoh64(p_sw->p_node->node_info.node_guid));
+ goto Exit;
+ }
+
+ /* check that the requester physp and the current physp are under
+ the same partition. */
+ p_physp = p_port->p_physp;
+ if (!p_physp) {
+ OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 530B: "
+ "Failed to find default physical Port by Node Guid:0x%016"
+ PRIx64 "\n",
+ cl_ntoh64(p_sw->p_node->node_info.node_guid));
+ goto Exit;
+ }
+ if (!osm_physp_share_pkey(sa->p_log, p_req_physp, p_physp,
+ sa->p_subn->opt.allow_both_pkeys))
+ goto Exit;
+
+ /* get the port 0 of the switch */
+ osm_port_get_lid_range_ho(p_port, &min_lid_ho, &max_lid_ho);
+
+ match_lid_ho = cl_ntoh16(match_lid);
+ if (match_lid_ho) {
+ /*
+ We validate that the lid belongs to this switch.
+ */
+ OSM_LOG(sa->p_log, OSM_LOG_DEBUG,
+ "Comparing LID: %u <= %u <= %u\n",
+ min_lid_ho, match_lid_ho, max_lid_ho);
+
+ if (match_lid_ho < min_lid_ho || match_lid_ho > max_lid_ho)
+ goto Exit;
+
+ }
+
+ sir_rcv_new_sir(sa, p_sw, p_list, osm_port_get_base_lid(p_port));
+
+Exit:
+ OSM_LOG_EXIT(sa->p_log);
+}
+
+static void sir_rcv_by_comp_mask(IN cl_map_item_t * p_map_item, IN void *cxt)
+{
+ const osm_sir_search_ctxt_t *p_ctxt = cxt;
+ const osm_switch_t *p_sw = (osm_switch_t *) p_map_item;
+ const ib_switch_info_record_t *const p_rcvd_rec = p_ctxt->p_rcvd_rec;
+ const osm_physp_t *const p_req_physp = p_ctxt->p_req_physp;
+ osm_sa_t *sa = p_ctxt->sa;
+ ib_net64_t const comp_mask = p_ctxt->comp_mask;
+ ib_net16_t match_lid = 0;
+
+ OSM_LOG_ENTER(p_ctxt->sa->p_log);
+
+ osm_dump_switch_info_v2(p_ctxt->sa->p_log, &p_sw->switch_info,
+ FILE_ID, OSM_LOG_VERBOSE);
+
+ if (comp_mask & IB_SWIR_COMPMASK_LID) {
+ match_lid = p_rcvd_rec->lid;
+ if (!match_lid)
+ goto Exit;
+ }
+
+ sir_rcv_create_sir(sa, p_sw, p_ctxt->p_list, match_lid, p_req_physp);
+
+Exit:
+ OSM_LOG_EXIT(p_ctxt->sa->p_log);
+}
+
+void osm_sir_rcv_process(IN void *ctx, IN void *data)
+{
+ osm_sa_t *sa = ctx;
+ osm_madw_t *p_madw = data;
+ const ib_sa_mad_t *sad_mad;
+ const ib_switch_info_record_t *p_rcvd_rec;
+ cl_qlist_t rec_list;
+ osm_sir_search_ctxt_t context;
+ osm_physp_t *p_req_physp;
+
+ CL_ASSERT(sa);
+
+ OSM_LOG_ENTER(sa->p_log);
+
+ CL_ASSERT(p_madw);
+
+ sad_mad = osm_madw_get_sa_mad_ptr(p_madw);
+ p_rcvd_rec =
+ (ib_switch_info_record_t *) ib_sa_mad_get_payload_ptr(sad_mad);
+
+ CL_ASSERT(sad_mad->attr_id == IB_MAD_ATTR_SWITCH_INFO_RECORD);
+
+ /* we only support SubnAdmGet and SubnAdmGetTable methods */
+ if (sad_mad->method != IB_MAD_METHOD_GET &&
+ sad_mad->method != IB_MAD_METHOD_GETTABLE) {
+ OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 5305: "
+ "Unsupported Method (%s) for SwitchInfoRecord request\n",
+ ib_get_sa_method_str(sad_mad->method));
+ osm_sa_send_error(sa, p_madw, IB_MAD_STATUS_UNSUP_METHOD_ATTR);
+ goto Exit;
+ }
+
+ cl_plock_acquire(sa->p_lock);
+
+ /* update the requester physical port */
+ p_req_physp = osm_get_physp_by_mad_addr(sa->p_log, sa->p_subn,
+ osm_madw_get_mad_addr_ptr
+ (p_madw));
+ if (p_req_physp == NULL) {
+ cl_plock_release(sa->p_lock);
+ OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 5304: "
+ "Cannot find requester physical port\n");
+ goto Exit;
+ }
+
+ if (OSM_LOG_IS_ACTIVE_V2(sa->p_log, OSM_LOG_DEBUG)) {
+ OSM_LOG(sa->p_log, OSM_LOG_DEBUG,
+ "Requester port GUID 0x%" PRIx64 "\n",
+ cl_ntoh64(osm_physp_get_port_guid(p_req_physp)));
+ osm_dump_switch_info_record_v2(sa->p_log, p_rcvd_rec,
+ FILE_ID, OSM_LOG_DEBUG);
+ }
+
+ cl_qlist_init(&rec_list);
+
+ context.p_rcvd_rec = p_rcvd_rec;
+ context.p_list = &rec_list;
+ context.comp_mask = sad_mad->comp_mask;
+ context.sa = sa;
+ context.p_req_physp = p_req_physp;
+
+ /* Go over all switches */
+ cl_qmap_apply_func(&sa->p_subn->sw_guid_tbl, sir_rcv_by_comp_mask,
+ &context);
+
+ cl_plock_release(sa->p_lock);
+
+ osm_sa_respond(sa, p_madw, sizeof(ib_switch_info_record_t), &rec_list);
+
+Exit:
+ OSM_LOG_EXIT(sa->p_log);
+}
diff --git a/contrib/ofed/opensm/opensm/osm_sa_vlarb_record.c b/contrib/ofed/opensm/opensm/osm_sa_vlarb_record.c
new file mode 100644
index 0000000..8cb25fc
--- /dev/null
+++ b/contrib/ofed/opensm/opensm/osm_sa_vlarb_record.c
@@ -0,0 +1,305 @@
+/*
+ * Copyright (c) 2004-2009 Voltaire, Inc. All rights reserved.
+ * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved.
+ * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
+ * Copyright (c) 2013 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+/*
+ * Abstract:
+ * Implementation of osm_vlarb_rec_rcv_t.
+ * This object represents the VLArbitrationRecord Receiver object.
+ * This object is part of the opensm family of objects.
+ */
+
+#if HAVE_CONFIG_H
+# include <config.h>
+#endif /* HAVE_CONFIG_H */
+
+#include <string.h>
+#include <iba/ib_types.h>
+#include <complib/cl_qmap.h>
+#include <complib/cl_passivelock.h>
+#include <complib/cl_debug.h>
+#include <complib/cl_qlist.h>
+#include <opensm/osm_file_ids.h>
+#define FILE_ID OSM_FILE_SA_VLARB_RECORD_C
+#include <vendor/osm_vendor_api.h>
+#include <opensm/osm_port.h>
+#include <opensm/osm_node.h>
+#include <opensm/osm_helper.h>
+#include <opensm/osm_pkey.h>
+#include <opensm/osm_sa.h>
+
+#define SA_VLA_RESP_SIZE SA_ITEM_RESP_SIZE(vlarb_rec)
+
+typedef struct osm_vl_arb_search_ctxt {
+ const ib_vl_arb_table_record_t *p_rcvd_rec;
+ ib_net64_t comp_mask;
+ uint8_t block_num;
+ cl_qlist_t *p_list;
+ osm_sa_t *sa;
+ const osm_physp_t *p_req_physp;
+} osm_vl_arb_search_ctxt_t;
+
+static void sa_vl_arb_create(IN osm_sa_t * sa, IN osm_physp_t * p_physp,
+ IN osm_vl_arb_search_ctxt_t * p_ctxt,
+ IN uint8_t block)
+{
+ osm_sa_item_t *p_rec_item;
+ uint16_t lid;
+
+ OSM_LOG_ENTER(sa->p_log);
+
+ p_rec_item = malloc(SA_VLA_RESP_SIZE);
+ if (p_rec_item == NULL) {
+ OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 2A02: "
+ "rec_item alloc failed\n");
+ goto Exit;
+ }
+
+ if (p_physp->p_node->node_info.node_type != IB_NODE_TYPE_SWITCH)
+ lid = p_physp->port_info.base_lid;
+ else
+ lid = osm_node_get_base_lid(p_physp->p_node, 0);
+
+ OSM_LOG(sa->p_log, OSM_LOG_DEBUG,
+ "New VLArbitration for: port 0x%016" PRIx64
+ ", lid %u, port %u Block:%u\n",
+ cl_ntoh64(osm_physp_get_port_guid(p_physp)),
+ cl_ntoh16(lid), osm_physp_get_port_num(p_physp), block);
+
+ memset(p_rec_item, 0, SA_VLA_RESP_SIZE);
+
+ p_rec_item->resp.vlarb_rec.lid = lid;
+ p_rec_item->resp.vlarb_rec.port_num = osm_physp_get_port_num(p_physp);
+ p_rec_item->resp.vlarb_rec.block_num = block;
+ p_rec_item->resp.vlarb_rec.vl_arb_tbl = *(osm_physp_get_vla_tbl(p_physp, block));
+
+ cl_qlist_insert_tail(p_ctxt->p_list, &p_rec_item->list_item);
+
+Exit:
+ OSM_LOG_EXIT(sa->p_log);
+}
+
+static void sa_vl_arb_check_physp(IN osm_sa_t * sa, IN osm_physp_t * p_physp,
+ osm_vl_arb_search_ctxt_t * p_ctxt)
+{
+ ib_net64_t comp_mask = p_ctxt->comp_mask;
+ uint8_t block;
+
+ OSM_LOG_ENTER(sa->p_log);
+
+ /* we got here with the phys port - all that's left is to get the right block */
+ for (block = 1; block <= 4; block++) {
+ if (!(comp_mask & IB_VLA_COMPMASK_BLOCK)
+ || block == p_ctxt->block_num)
+ sa_vl_arb_create(sa, p_physp, p_ctxt, block);
+ }
+
+ OSM_LOG_EXIT(sa->p_log);
+}
+
+static void sa_vl_arb_by_comp_mask(osm_sa_t * sa, IN const osm_port_t * p_port,
+ osm_vl_arb_search_ctxt_t * p_ctxt)
+{
+ const ib_vl_arb_table_record_t *p_rcvd_rec;
+ ib_net64_t comp_mask;
+ osm_physp_t *p_physp;
+ uint8_t port_num;
+ uint8_t num_ports;
+ const osm_physp_t *p_req_physp;
+
+ OSM_LOG_ENTER(sa->p_log);
+
+ p_rcvd_rec = p_ctxt->p_rcvd_rec;
+ comp_mask = p_ctxt->comp_mask;
+ port_num = p_rcvd_rec->port_num;
+ p_req_physp = p_ctxt->p_req_physp;
+
+ /* if this is a switch port we can search all ports
+ otherwise we must be looking on port 0 */
+ if (p_port->p_node->node_info.node_type != IB_NODE_TYPE_SWITCH) {
+ /* we put it in the comp mask and port num */
+ port_num = p_port->p_physp->port_num;
+ OSM_LOG(sa->p_log, OSM_LOG_DEBUG,
+ "Using Physical Default Port Number: 0x%X (for End Node)\n",
+ port_num);
+ comp_mask |= IB_VLA_COMPMASK_OUT_PORT;
+ }
+
+ if (comp_mask & IB_VLA_COMPMASK_OUT_PORT) {
+ if (port_num < osm_node_get_num_physp(p_port->p_node)) {
+ p_physp =
+ osm_node_get_physp_ptr(p_port->p_node, port_num);
+ /* check that the p_physp is valid, and that the requester
+ and the p_physp share a pkey. */
+ if (p_physp &&
+ osm_physp_share_pkey(sa->p_log, p_req_physp, p_physp,
+ sa->p_subn->opt.allow_both_pkeys))
+ sa_vl_arb_check_physp(sa, p_physp, p_ctxt);
+ } else {
+ OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 2A03: "
+ "Given Physical Port Number: 0x%X is out of range should be < 0x%X\n",
+ port_num,
+ osm_node_get_num_physp(p_port->p_node));
+ goto Exit;
+ }
+ } else {
+ num_ports = osm_node_get_num_physp(p_port->p_node);
+ for (port_num = 0; port_num < num_ports; port_num++) {
+ p_physp =
+ osm_node_get_physp_ptr(p_port->p_node, port_num);
+ if (!p_physp)
+ continue;
+
+ /* if the requester and the p_physp don't share a pkey -
+ continue */
+ if (!osm_physp_share_pkey(sa->p_log, p_req_physp, p_physp,
+ sa->p_subn->opt.allow_both_pkeys))
+ continue;
+
+ sa_vl_arb_check_physp(sa, p_physp, p_ctxt);
+ }
+ }
+Exit:
+ OSM_LOG_EXIT(sa->p_log);
+}
+
+static void sa_vl_arb_by_comp_mask_cb(IN cl_map_item_t * p_map_item, void *cxt)
+{
+ const osm_port_t *p_port = (osm_port_t *) p_map_item;
+ osm_vl_arb_search_ctxt_t *p_ctxt = cxt;
+
+ sa_vl_arb_by_comp_mask(p_ctxt->sa, p_port, p_ctxt);
+}
+
+void osm_vlarb_rec_rcv_process(IN void *ctx, IN void *data)
+{
+ osm_sa_t *sa = ctx;
+ osm_madw_t *p_madw = data;
+ const ib_sa_mad_t *sad_mad;
+ const ib_vl_arb_table_record_t *p_rcvd_rec;
+ const osm_port_t *p_port = NULL;
+ cl_qlist_t rec_list;
+ osm_vl_arb_search_ctxt_t context;
+ ib_api_status_t status = IB_SUCCESS;
+ ib_net64_t comp_mask;
+ osm_physp_t *p_req_physp;
+
+ CL_ASSERT(sa);
+
+ OSM_LOG_ENTER(sa->p_log);
+
+ CL_ASSERT(p_madw);
+
+ sad_mad = osm_madw_get_sa_mad_ptr(p_madw);
+ p_rcvd_rec =
+ (ib_vl_arb_table_record_t *) ib_sa_mad_get_payload_ptr(sad_mad);
+ comp_mask = sad_mad->comp_mask;
+
+ CL_ASSERT(sad_mad->attr_id == IB_MAD_ATTR_VLARB_RECORD);
+
+ /* we only support SubnAdmGet and SubnAdmGetTable methods */
+ if (sad_mad->method != IB_MAD_METHOD_GET &&
+ sad_mad->method != IB_MAD_METHOD_GETTABLE) {
+ OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 2A05: "
+ "Unsupported Method (%s) for a VLArbRecord request\n",
+ ib_get_sa_method_str(sad_mad->method));
+ osm_sa_send_error(sa, p_madw, IB_MAD_STATUS_UNSUP_METHOD_ATTR);
+ goto Exit;
+ }
+
+ cl_plock_acquire(sa->p_lock);
+
+ /* update the requester physical port */
+ p_req_physp = osm_get_physp_by_mad_addr(sa->p_log, sa->p_subn,
+ osm_madw_get_mad_addr_ptr
+ (p_madw));
+ if (p_req_physp == NULL) {
+ cl_plock_release(sa->p_lock);
+ OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 2A04: "
+ "Cannot find requester physical port\n");
+ goto Exit;
+ }
+ OSM_LOG(sa->p_log, OSM_LOG_DEBUG,
+ "Requester port GUID 0x%" PRIx64 "\n",
+ cl_ntoh64(osm_physp_get_port_guid(p_req_physp)));
+
+ cl_qlist_init(&rec_list);
+
+ context.p_rcvd_rec = p_rcvd_rec;
+ context.p_list = &rec_list;
+ context.comp_mask = sad_mad->comp_mask;
+ context.sa = sa;
+ context.block_num = p_rcvd_rec->block_num;
+ context.p_req_physp = p_req_physp;
+
+ OSM_LOG(sa->p_log, OSM_LOG_DEBUG,
+ "Got Query Lid:%u(%02X), Port:0x%02X(%02X), Block:0x%02X(%02X)\n",
+ cl_ntoh16(p_rcvd_rec->lid),
+ (comp_mask & IB_VLA_COMPMASK_LID) != 0, p_rcvd_rec->port_num,
+ (comp_mask & IB_VLA_COMPMASK_OUT_PORT) != 0,
+ p_rcvd_rec->block_num,
+ (comp_mask & IB_VLA_COMPMASK_BLOCK) != 0);
+
+ /*
+ If the user specified a LID, it obviously narrows our
+ work load, since we don't have to search every port
+ */
+ if (comp_mask & IB_VLA_COMPMASK_LID) {
+ p_port = osm_get_port_by_lid(sa->p_subn, p_rcvd_rec->lid);
+ if (!p_port) {
+ status = IB_NOT_FOUND;
+ OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 2A09: "
+ "No port found with LID %u\n",
+ cl_ntoh16(p_rcvd_rec->lid));
+ }
+ }
+
+ if (status == IB_SUCCESS) {
+ /* if we got a unique port - no need for a port search */
+ if (p_port)
+ /* this does the loop on all the port phys ports */
+ sa_vl_arb_by_comp_mask(sa, p_port, &context);
+ else
+ cl_qmap_apply_func(&sa->p_subn->port_guid_tbl,
+ sa_vl_arb_by_comp_mask_cb, &context);
+ }
+
+ cl_plock_release(sa->p_lock);
+
+ osm_sa_respond(sa, p_madw, sizeof(ib_vl_arb_table_record_t), &rec_list);
+
+Exit:
+ OSM_LOG_EXIT(sa->p_log);
+}
diff --git a/contrib/ofed/opensm/opensm/osm_service.c b/contrib/ofed/opensm/opensm/osm_service.c
new file mode 100644
index 0000000..ba5a982
--- /dev/null
+++ b/contrib/ofed/opensm/opensm/osm_service.c
@@ -0,0 +1,147 @@
+/*
+ * Copyright (c) 2004-2009 Voltaire, Inc. All rights reserved.
+ * Copyright (c) 2002-2006 Mellanox Technologies LTD. All rights reserved.
+ * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+/*
+ * Abstract:
+ * Implementation of service record functions.
+ */
+
+#if HAVE_CONFIG_H
+# include <config.h>
+#endif /* HAVE_CONFIG_H */
+
+#include <stdlib.h>
+#include <complib/cl_debug.h>
+#include <complib/cl_timer.h>
+#include <opensm/osm_file_ids.h>
+#define FILE_ID OSM_FILE_SERVICE_C
+#include <opensm/osm_service.h>
+#include <opensm/osm_opensm.h>
+
+void osm_svcr_delete(IN osm_svcr_t * p_svcr)
+{
+ free(p_svcr);
+}
+
+void osm_svcr_init(IN osm_svcr_t * p_svcr,
+ IN const ib_service_record_t * p_svc_rec)
+{
+ CL_ASSERT(p_svcr);
+
+ p_svcr->modified_time = cl_get_time_stamp_sec();
+
+ /* We track the time left for this service in
+ an external field to avoid extra cl_ntoh/hton
+ required for working with the MAD field */
+ p_svcr->lease_period = cl_ntoh32(p_svc_rec->service_lease);
+ p_svcr->service_record = *p_svc_rec;
+}
+
+osm_svcr_t *osm_svcr_new(IN const ib_service_record_t * p_svc_rec)
+{
+ osm_svcr_t *p_svcr;
+
+ CL_ASSERT(p_svc_rec);
+
+ p_svcr = (osm_svcr_t *) malloc(sizeof(*p_svcr));
+ if (p_svcr) {
+ memset(p_svcr, 0, sizeof(*p_svcr));
+ osm_svcr_init(p_svcr, p_svc_rec);
+ }
+
+ return p_svcr;
+}
+
+static cl_status_t match_rid_of_svc_rec(IN const cl_list_item_t * p_list_item,
+ IN void *context)
+{
+ ib_service_record_t *p_svc_rec = (ib_service_record_t *) context;
+ osm_svcr_t *p_svcr = (osm_svcr_t *) p_list_item;
+
+ if (memcmp(&p_svcr->service_record, p_svc_rec,
+ sizeof(p_svc_rec->service_id) +
+ sizeof(p_svc_rec->service_gid) +
+ sizeof(p_svc_rec->service_pkey)))
+ return CL_NOT_FOUND;
+ else
+ return CL_SUCCESS;
+}
+
+osm_svcr_t *osm_svcr_get_by_rid(IN osm_subn_t const *p_subn,
+ IN osm_log_t * p_log,
+ IN ib_service_record_t * p_svc_rec)
+{
+ cl_list_item_t *p_list_item;
+
+ OSM_LOG_ENTER(p_log);
+
+ p_list_item = cl_qlist_find_from_head(&p_subn->sa_sr_list,
+ match_rid_of_svc_rec, p_svc_rec);
+ if (p_list_item == cl_qlist_end(&p_subn->sa_sr_list))
+ p_list_item = NULL;
+
+ OSM_LOG_EXIT(p_log);
+ return (osm_svcr_t *) p_list_item;
+}
+
+void osm_svcr_insert_to_db(IN osm_subn_t * p_subn, IN osm_log_t * p_log,
+ IN osm_svcr_t * p_svcr)
+{
+ OSM_LOG_ENTER(p_log);
+
+ OSM_LOG(p_log, OSM_LOG_DEBUG,
+ "Inserting new Service Record into Database\n");
+
+ cl_qlist_insert_head(&p_subn->sa_sr_list, &p_svcr->list_item);
+ p_subn->p_osm->sa.dirty = TRUE;
+
+ OSM_LOG_EXIT(p_log);
+}
+
+void osm_svcr_remove_from_db(IN osm_subn_t * p_subn, IN osm_log_t * p_log,
+ IN osm_svcr_t * p_svcr)
+{
+ OSM_LOG_ENTER(p_log);
+
+ OSM_LOG(p_log, OSM_LOG_DEBUG,
+ "Removing Service Record Name:%s ID:0x%016" PRIx64
+ " from Database\n", p_svcr->service_record.service_name,
+ cl_ntoh64(p_svcr->service_record.service_id));
+
+ cl_qlist_remove_item(&p_subn->sa_sr_list, &p_svcr->list_item);
+ p_subn->p_osm->sa.dirty = TRUE;
+
+ OSM_LOG_EXIT(p_log);
+}
diff --git a/contrib/ofed/opensm/opensm/osm_slvl_map_rcv.c b/contrib/ofed/opensm/opensm/osm_slvl_map_rcv.c
new file mode 100644
index 0000000..67f0e19
--- /dev/null
+++ b/contrib/ofed/opensm/opensm/osm_slvl_map_rcv.c
@@ -0,0 +1,172 @@
+/*
+ * Copyright (c) 2004-2009 Voltaire, Inc. All rights reserved.
+ * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved.
+ * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
+ * Copyright (c) 2009 HNR Consulting. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+/*
+ * Abstract:
+ * Implementation of osm_slvl_rcv_t.
+ * This object represents the SLtoVL Receiver object.
+ * This object is part of the opensm family of objects.
+ */
+
+#if HAVE_CONFIG_H
+# include <config.h>
+#endif /* HAVE_CONFIG_H */
+
+#include <string.h>
+#include <iba/ib_types.h>
+#include <complib/cl_passivelock.h>
+#include <complib/cl_debug.h>
+#include <opensm/osm_file_ids.h>
+#define FILE_ID OSM_FILE_SLVL_MAP_RCV_C
+#include <opensm/osm_madw.h>
+#include <opensm/osm_log.h>
+#include <opensm/osm_node.h>
+#include <opensm/osm_subnet.h>
+#include <opensm/osm_helper.h>
+#include <opensm/osm_sm.h>
+
+/*
+ * WE ONLY RECEIVE GET or SET responses
+ */
+void osm_slvl_rcv_process(IN void *context, IN void *p_data)
+{
+ osm_sm_t *sm = context;
+ osm_madw_t *p_madw = p_data;
+ ib_slvl_table_t *p_slvl_tbl;
+ ib_smp_t *p_smp;
+ osm_port_t *p_port;
+ osm_physp_t *p_physp;
+ osm_node_t *p_node;
+ osm_slvl_context_t *p_context;
+ ib_net64_t port_guid;
+ ib_net64_t node_guid;
+ uint32_t attr_mod;
+ uint8_t startinport, endinport, startoutport, endoutport;
+ uint8_t in_port, out_port;
+
+ CL_ASSERT(sm);
+
+ OSM_LOG_ENTER(sm->p_log);
+
+ CL_ASSERT(p_madw);
+
+ p_smp = osm_madw_get_smp_ptr(p_madw);
+ p_context = osm_madw_get_slvl_context_ptr(p_madw);
+ p_slvl_tbl = ib_smp_get_payload_ptr(p_smp);
+
+ port_guid = p_context->port_guid;
+ node_guid = p_context->node_guid;
+
+ CL_ASSERT(p_smp->attr_id == IB_MAD_ATTR_SLVL_TABLE);
+
+ if (!sm->p_subn->opt.suppress_sl2vl_mad_status_errors &&
+ ib_smp_get_status(p_smp)) {
+ OSM_LOG(sm->p_log, OSM_LOG_DEBUG,
+ "MAD status 0x%x received\n",
+ cl_ntoh16(ib_smp_get_status(p_smp)));
+ goto Exit2;
+ }
+
+ cl_plock_excl_acquire(sm->p_lock);
+ p_port = osm_get_port_by_guid(sm->p_subn, port_guid);
+
+ if (!p_port) {
+ OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR 2C06: "
+ "No port object for port with GUID 0x%" PRIx64
+ "\n\t\t\t\tfor parent node GUID 0x%" PRIx64
+ ", TID 0x%" PRIx64 "\n", cl_ntoh64(port_guid),
+ cl_ntoh64(node_guid), cl_ntoh64(p_smp->trans_id));
+ goto Exit;
+ }
+
+ p_node = p_port->p_node;
+ CL_ASSERT(p_node);
+
+ /* in case of a non switch node the attr modifier should be ignored */
+ if (osm_node_get_type(p_node) == IB_NODE_TYPE_SWITCH) {
+ unsigned num_ports = osm_node_get_num_physp(p_node) - 1;
+ attr_mod = cl_ntoh32(p_smp->attr_mod);
+
+ if (attr_mod & 0x10000) {
+ startoutport = ib_switch_info_is_enhanced_port0(&p_node->sw->switch_info) ? 0 : 1;
+ endoutport = osm_node_get_num_physp(p_node) - 1;
+ } else
+ startoutport = endoutport = attr_mod & 0xff;
+
+ if (attr_mod & 0x20000) {
+ startinport = ib_switch_info_is_enhanced_port0(&p_node->sw->switch_info) ? 0 : 1;
+ endinport = osm_node_get_num_physp(p_node) - 1;
+ } else
+ startinport = endinport = (attr_mod >> 8) & 0xff;
+
+ if (startinport > num_ports || startoutport > num_ports) {
+ OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR 2C07"
+ "Invalid attribute modifier 0x%x received in"
+ " response from switch 0x%" PRIx64 "\n",
+ cl_ntoh32(attr_mod), cl_ntoh64(node_guid));
+ goto Exit;
+ }
+
+ } else {
+ startoutport = endoutport = p_port->p_physp->port_num;
+ startinport = endinport = 0;
+ }
+
+ OSM_LOG(sm->p_log, OSM_LOG_DEBUG, "Received SLtoVL GetResp"
+ " in_port_num %u out_port_num %u with GUID 0x%" PRIx64
+ " for parent node GUID 0x%" PRIx64 ", TID 0x%" PRIx64 "\n",
+ startinport == endinport ? startinport : 0xff,
+ startoutport == endoutport ? startoutport : 0xff,
+ cl_ntoh64(port_guid), cl_ntoh64(node_guid),
+ cl_ntoh64(p_smp->trans_id));
+
+ osm_dump_slvl_map_table_v2(sm->p_log, port_guid,
+ startinport == endinport ? startinport : 0xff,
+ startoutport == endoutport ? startoutport : 0xff,
+ p_slvl_tbl, FILE_ID, OSM_LOG_DEBUG);
+
+ for (out_port = startoutport; out_port <= endoutport; out_port++) {
+ p_physp = osm_node_get_physp_ptr(p_node, out_port);
+ for (in_port = startinport; in_port <= endinport; in_port++)
+ osm_physp_set_slvl_tbl(p_physp, p_slvl_tbl, in_port);
+ }
+
+Exit:
+ cl_plock_release(sm->p_lock);
+
+Exit2:
+ OSM_LOG_EXIT(sm->p_log);
+}
diff --git a/contrib/ofed/opensm/opensm/osm_sm.c b/contrib/ofed/opensm/opensm/osm_sm.c
new file mode 100644
index 0000000..e5e14ea
--- /dev/null
+++ b/contrib/ofed/opensm/opensm/osm_sm.c
@@ -0,0 +1,464 @@
+/*
+ * Copyright (c) 2004-2009 Voltaire, Inc. All rights reserved.
+ * Copyright (c) 2002-2011 Mellanox Technologies LTD. All rights reserved.
+ * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
+ * Copyright (c) 2008 Xsigo Systems Inc. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+/*
+ * Abstract:
+ * Implementation of osm_sm_t.
+ * This object represents the SM Receiver object.
+ * This object is part of the opensm family of objects.
+ */
+
+#if HAVE_CONFIG_H
+# include <config.h>
+#endif /* HAVE_CONFIG_H */
+
+#include <stdlib.h>
+#include <string.h>
+#include <iba/ib_types.h>
+#include <complib/cl_qmap.h>
+#include <complib/cl_passivelock.h>
+#include <complib/cl_debug.h>
+#include <complib/cl_thread.h>
+#include <opensm/osm_file_ids.h>
+#define FILE_ID OSM_FILE_SM_C
+#include <opensm/osm_sm.h>
+#include <opensm/osm_madw.h>
+#include <opensm/osm_log.h>
+#include <opensm/osm_node.h>
+#include <opensm/osm_msgdef.h>
+#include <opensm/osm_perfmgr.h>
+#include <opensm/osm_opensm.h>
+
+#define OSM_SM_INITIAL_TID_VALUE 0x1233
+
+extern void osm_lft_rcv_process(IN void *context, IN void *data);
+extern void osm_mft_rcv_process(IN void *context, IN void *data);
+extern void osm_nd_rcv_process(IN void *context, IN void *data);
+extern void osm_ni_rcv_process(IN void *context, IN void *data);
+extern void osm_pkey_rcv_process(IN void *context, IN void *data);
+extern void osm_pi_rcv_process(IN void *context, IN void *data);
+extern void osm_gi_rcv_process(IN void *context, IN void *data);
+extern void osm_slvl_rcv_process(IN void *context, IN void *p_data);
+extern void osm_sminfo_rcv_process(IN void *context, IN void *data);
+extern void osm_si_rcv_process(IN void *context, IN void *data);
+extern void osm_trap_rcv_process(IN void *context, IN void *data);
+extern void osm_vla_rcv_process(IN void *context, IN void *data);
+extern void osm_mlnx_epi_rcv_process(IN void *context, IN void *data);
+
+extern void osm_state_mgr_process(IN osm_sm_t * sm, IN osm_signal_t signal);
+extern void osm_sm_state_mgr_polling_callback(IN void *context);
+
+static void sm_process(osm_sm_t * sm, osm_signal_t signal)
+{
+#ifdef ENABLE_OSM_PERF_MGR
+ if (signal == OSM_SIGNAL_PERFMGR_SWEEP)
+ osm_perfmgr_process(&sm->p_subn->p_osm->perfmgr);
+ else
+#endif
+ osm_state_mgr_process(sm, signal);
+}
+
+static void sm_sweeper(IN void *p_ptr)
+{
+ ib_api_status_t status;
+ osm_sm_t * p_sm = p_ptr;
+ unsigned signals, i;
+
+ OSM_LOG_ENTER(p_sm->p_log);
+
+ while (p_sm->thread_state == OSM_THREAD_STATE_RUN) {
+ /*
+ * Wait on the event with a timeout.
+ * Sweeps may be initiated "off schedule" by simply
+ * signaling the event.
+ */
+ status = cl_event_wait_on(&p_sm->signal_event,
+ EVENT_NO_TIMEOUT, TRUE);
+
+ if (status == CL_SUCCESS)
+ OSM_LOG(p_sm->p_log, OSM_LOG_DEBUG,
+ "Off schedule sweep signalled\n");
+ else {
+ OSM_LOG(p_sm->p_log, OSM_LOG_ERROR, "ERR 2E01: "
+ "Event wait failed (%s)\n",
+ CL_STATUS_MSG(status));
+ continue;
+ }
+
+ if (osm_exit_flag)
+ break;
+
+ cl_spinlock_acquire(&p_sm->signal_lock);
+ signals = p_sm->signal_mask;
+ p_sm->signal_mask = 0;
+ cl_spinlock_release(&p_sm->signal_lock);
+
+ for (i = 0; signals; signals >>= 1, i++)
+ if (signals & 1)
+ sm_process(p_sm, i);
+ }
+
+ OSM_LOG_EXIT(p_sm->p_log);
+}
+
+static void sm_sweep(void *arg)
+{
+ osm_sm_t *sm = arg;
+
+ /* do the sweep only if we are in MASTER state */
+ if (sm->p_subn->sm_state == IB_SMINFO_STATE_MASTER ||
+ sm->p_subn->sm_state == IB_SMINFO_STATE_DISCOVERING)
+ osm_sm_signal(sm, OSM_SIGNAL_SWEEP);
+ cl_timer_start(&sm->sweep_timer, sm->p_subn->opt.sweep_interval * 1000);
+}
+
+static void sweep_fail_process(IN void *context, IN void *p_data)
+{
+ osm_sm_t *sm = context;
+
+ OSM_LOG(sm->p_log, OSM_LOG_DEBUG, "light sweep failed\n");
+ sm->p_subn->force_heavy_sweep = TRUE;
+}
+
+void osm_sm_construct(IN osm_sm_t * p_sm)
+{
+ memset(p_sm, 0, sizeof(*p_sm));
+ p_sm->thread_state = OSM_THREAD_STATE_NONE;
+ p_sm->sm_trans_id = OSM_SM_INITIAL_TID_VALUE;
+ cl_spinlock_construct(&p_sm->signal_lock);
+ cl_spinlock_construct(&p_sm->state_lock);
+ cl_timer_construct(&p_sm->polling_timer);
+ cl_event_construct(&p_sm->signal_event);
+ cl_event_construct(&p_sm->subnet_up_event);
+ cl_event_wheel_construct(&p_sm->trap_aging_tracker);
+ cl_thread_construct(&p_sm->sweeper);
+ osm_sm_mad_ctrl_construct(&p_sm->mad_ctrl);
+ osm_lid_mgr_construct(&p_sm->lid_mgr);
+ osm_ucast_mgr_construct(&p_sm->ucast_mgr);
+}
+
+void osm_sm_shutdown(IN osm_sm_t * p_sm)
+{
+ boolean_t signal_event = FALSE;
+
+ OSM_LOG_ENTER(p_sm->p_log);
+
+ /*
+ * Signal our threads that we're leaving.
+ */
+ if (p_sm->thread_state != OSM_THREAD_STATE_NONE)
+ signal_event = TRUE;
+
+ p_sm->thread_state = OSM_THREAD_STATE_EXIT;
+
+ /*
+ * Don't trigger unless event has been initialized.
+ * Destroy the thread before we tear down the other objects.
+ */
+ if (signal_event)
+ cl_event_signal(&p_sm->signal_event);
+
+ cl_timer_stop(&p_sm->polling_timer);
+ cl_timer_stop(&p_sm->sweep_timer);
+ cl_thread_destroy(&p_sm->sweeper);
+
+ /*
+ * Always destroy controllers before the corresponding
+ * receiver to guarantee that all callbacks from the
+ * dispatcher are complete.
+ */
+ osm_sm_mad_ctrl_destroy(&p_sm->mad_ctrl);
+ cl_disp_unregister(p_sm->ni_disp_h);
+ cl_disp_unregister(p_sm->pi_disp_h);
+ cl_disp_unregister(p_sm->gi_disp_h);
+ cl_disp_unregister(p_sm->si_disp_h);
+ cl_disp_unregister(p_sm->nd_disp_h);
+ cl_disp_unregister(p_sm->lft_disp_h);
+ cl_disp_unregister(p_sm->mft_disp_h);
+ cl_disp_unregister(p_sm->sm_info_disp_h);
+ cl_disp_unregister(p_sm->trap_disp_h);
+ cl_disp_unregister(p_sm->slvl_disp_h);
+ cl_disp_unregister(p_sm->vla_disp_h);
+ cl_disp_unregister(p_sm->pkey_disp_h);
+ cl_disp_unregister(p_sm->mlnx_epi_disp_h);
+ cl_disp_unregister(p_sm->sweep_fail_disp_h);
+
+ OSM_LOG_EXIT(p_sm->p_log);
+}
+
+void osm_sm_destroy(IN osm_sm_t * p_sm)
+{
+ OSM_LOG_ENTER(p_sm->p_log);
+ osm_lid_mgr_destroy(&p_sm->lid_mgr);
+ osm_ucast_mgr_destroy(&p_sm->ucast_mgr);
+ cl_event_wheel_destroy(&p_sm->trap_aging_tracker);
+ cl_timer_destroy(&p_sm->sweep_timer);
+ cl_timer_destroy(&p_sm->polling_timer);
+ cl_event_destroy(&p_sm->signal_event);
+ cl_event_destroy(&p_sm->subnet_up_event);
+ cl_spinlock_destroy(&p_sm->signal_lock);
+ cl_spinlock_destroy(&p_sm->state_lock);
+ free(p_sm->mlids_req);
+
+ osm_log_v2(p_sm->p_log, OSM_LOG_SYS, FILE_ID, "Exiting SM\n"); /* Format Waived */
+ OSM_LOG_EXIT(p_sm->p_log);
+}
+
+ib_api_status_t osm_sm_init(IN osm_sm_t * p_sm, IN osm_subn_t * p_subn,
+ IN osm_db_t * p_db, IN osm_vendor_t * p_vendor,
+ IN osm_mad_pool_t * p_mad_pool,
+ IN osm_vl15_t * p_vl15, IN osm_log_t * p_log,
+ IN osm_stats_t * p_stats,
+ IN cl_dispatcher_t * p_disp, IN cl_plock_t * p_lock)
+{
+ ib_api_status_t status;
+
+ OSM_LOG_ENTER(p_log);
+
+ p_sm->p_subn = p_subn;
+ p_sm->p_db = p_db;
+ p_sm->p_vendor = p_vendor;
+ p_sm->p_mad_pool = p_mad_pool;
+ p_sm->p_vl15 = p_vl15;
+ p_sm->p_log = p_log;
+ p_sm->p_disp = p_disp;
+ p_sm->p_lock = p_lock;
+
+ status = cl_spinlock_init(&p_sm->signal_lock);
+ if (status != CL_SUCCESS)
+ goto Exit;
+
+ status = cl_spinlock_init(&p_sm->state_lock);
+ if (status != CL_SUCCESS)
+ goto Exit;
+
+ status = cl_event_init(&p_sm->signal_event, FALSE);
+ if (status != CL_SUCCESS)
+ goto Exit;
+
+ status = cl_event_init(&p_sm->subnet_up_event, FALSE);
+ if (status != CL_SUCCESS)
+ goto Exit;
+
+ status = cl_timer_init(&p_sm->sweep_timer, sm_sweep, p_sm);
+ if (status != CL_SUCCESS)
+ goto Exit;
+
+ status = cl_timer_init(&p_sm->polling_timer,
+ osm_sm_state_mgr_polling_callback, p_sm);
+ if (status != CL_SUCCESS)
+ goto Exit;
+
+ p_sm->mlids_req_max = 0;
+ p_sm->mlids_req = malloc((IB_LID_MCAST_END_HO - IB_LID_MCAST_START_HO +
+ 1) * sizeof(p_sm->mlids_req[0]));
+ if (!p_sm->mlids_req)
+ goto Exit;
+ memset(p_sm->mlids_req, 0,
+ (IB_LID_MCAST_END_HO - IB_LID_MCAST_START_HO +
+ 1) * sizeof(p_sm->mlids_req[0]));
+
+ status = osm_sm_mad_ctrl_init(&p_sm->mad_ctrl, p_sm->p_subn,
+ p_sm->p_mad_pool, p_sm->p_vl15,
+ p_sm->p_vendor,
+ p_log, p_stats, p_lock, p_disp);
+ if (status != IB_SUCCESS)
+ goto Exit;
+
+ status = cl_event_wheel_init(&p_sm->trap_aging_tracker);
+ if (status != IB_SUCCESS)
+ goto Exit;
+
+ status = osm_lid_mgr_init(&p_sm->lid_mgr, p_sm);
+ if (status != IB_SUCCESS)
+ goto Exit;
+
+ status = osm_ucast_mgr_init(&p_sm->ucast_mgr, p_sm);
+ if (status != IB_SUCCESS)
+ goto Exit;
+
+ status = IB_INSUFFICIENT_RESOURCES;
+ p_sm->sweep_fail_disp_h = cl_disp_register(p_disp,
+ OSM_MSG_LIGHT_SWEEP_FAIL,
+ sweep_fail_process, p_sm);
+ if (p_sm->sweep_fail_disp_h == CL_DISP_INVALID_HANDLE)
+ goto Exit;
+
+ p_sm->ni_disp_h = cl_disp_register(p_disp, OSM_MSG_MAD_NODE_INFO,
+ osm_ni_rcv_process, p_sm);
+ if (p_sm->ni_disp_h == CL_DISP_INVALID_HANDLE)
+ goto Exit;
+
+ p_sm->pi_disp_h = cl_disp_register(p_disp, OSM_MSG_MAD_PORT_INFO,
+ osm_pi_rcv_process, p_sm);
+ if (p_sm->pi_disp_h == CL_DISP_INVALID_HANDLE)
+ goto Exit;
+
+ p_sm->gi_disp_h = cl_disp_register(p_disp, OSM_MSG_MAD_GUID_INFO,
+ osm_gi_rcv_process, p_sm);
+ if (p_sm->gi_disp_h == CL_DISP_INVALID_HANDLE)
+ goto Exit;
+
+ p_sm->si_disp_h = cl_disp_register(p_disp, OSM_MSG_MAD_SWITCH_INFO,
+ osm_si_rcv_process, p_sm);
+ if (p_sm->si_disp_h == CL_DISP_INVALID_HANDLE)
+ goto Exit;
+
+ p_sm->nd_disp_h = cl_disp_register(p_disp, OSM_MSG_MAD_NODE_DESC,
+ osm_nd_rcv_process, p_sm);
+ if (p_sm->nd_disp_h == CL_DISP_INVALID_HANDLE)
+ goto Exit;
+
+ p_sm->lft_disp_h = cl_disp_register(p_disp, OSM_MSG_MAD_LFT,
+ osm_lft_rcv_process, p_sm);
+ if (p_sm->lft_disp_h == CL_DISP_INVALID_HANDLE)
+ goto Exit;
+
+ p_sm->mft_disp_h = cl_disp_register(p_disp, OSM_MSG_MAD_MFT,
+ osm_mft_rcv_process, p_sm);
+ if (p_sm->mft_disp_h == CL_DISP_INVALID_HANDLE)
+ goto Exit;
+
+ p_sm->sm_info_disp_h = cl_disp_register(p_disp, OSM_MSG_MAD_SM_INFO,
+ osm_sminfo_rcv_process, p_sm);
+ if (p_sm->sm_info_disp_h == CL_DISP_INVALID_HANDLE)
+ goto Exit;
+
+ p_sm->trap_disp_h = cl_disp_register(p_disp, OSM_MSG_MAD_NOTICE,
+ osm_trap_rcv_process, p_sm);
+ if (p_sm->trap_disp_h == CL_DISP_INVALID_HANDLE)
+ goto Exit;
+
+ p_sm->slvl_disp_h = cl_disp_register(p_disp, OSM_MSG_MAD_SLVL,
+ osm_slvl_rcv_process, p_sm);
+ if (p_sm->slvl_disp_h == CL_DISP_INVALID_HANDLE)
+ goto Exit;
+
+ p_sm->vla_disp_h = cl_disp_register(p_disp, OSM_MSG_MAD_VL_ARB,
+ osm_vla_rcv_process, p_sm);
+ if (p_sm->vla_disp_h == CL_DISP_INVALID_HANDLE)
+ goto Exit;
+
+ p_sm->pkey_disp_h = cl_disp_register(p_disp, OSM_MSG_MAD_PKEY,
+ osm_pkey_rcv_process, p_sm);
+ if (p_sm->pkey_disp_h == CL_DISP_INVALID_HANDLE)
+ goto Exit;
+
+ p_sm->mlnx_epi_disp_h = cl_disp_register(p_disp,
+ OSM_MSG_MAD_MLNX_EXT_PORT_INFO,
+ osm_mlnx_epi_rcv_process, p_sm);
+ if (p_sm->mlnx_epi_disp_h == CL_DISP_INVALID_HANDLE)
+ goto Exit;
+
+ p_subn->sm_state = p_subn->opt.sm_inactive ?
+ IB_SMINFO_STATE_NOTACTIVE : IB_SMINFO_STATE_DISCOVERING;
+ osm_report_sm_state(p_sm);
+
+ /*
+ * Now that the component objects are initialized, start
+ * the sweeper thread if the user wants sweeping.
+ */
+ p_sm->thread_state = OSM_THREAD_STATE_RUN;
+ status = cl_thread_init(&p_sm->sweeper, sm_sweeper, p_sm,
+ "opensm sweeper");
+ if (status != IB_SUCCESS)
+ goto Exit;
+
+ if (p_sm->p_subn->opt.sweep_interval)
+ cl_timer_start(&p_sm->sweep_timer,
+ p_sm->p_subn->opt.sweep_interval * 1000);
+
+Exit:
+ OSM_LOG_EXIT(p_log);
+ return status;
+}
+
+void osm_sm_signal(osm_sm_t * p_sm, osm_signal_t signal)
+{
+ cl_spinlock_acquire(&p_sm->signal_lock);
+ p_sm->signal_mask |= 1 << signal;
+ cl_event_signal(&p_sm->signal_event);
+ cl_spinlock_release(&p_sm->signal_lock);
+}
+
+void osm_sm_sweep(IN osm_sm_t * p_sm)
+{
+ OSM_LOG_ENTER(p_sm->p_log);
+ osm_sm_signal(p_sm, OSM_SIGNAL_SWEEP);
+ OSM_LOG_EXIT(p_sm->p_log);
+}
+
+ib_api_status_t osm_sm_bind(IN osm_sm_t * p_sm, IN ib_net64_t port_guid)
+{
+ ib_api_status_t status;
+
+ OSM_LOG_ENTER(p_sm->p_log);
+
+ status = osm_sm_mad_ctrl_bind(&p_sm->mad_ctrl, port_guid);
+
+ if (status != IB_SUCCESS) {
+ OSM_LOG(p_sm->p_log, OSM_LOG_ERROR, "ERR 2E10: "
+ "SM MAD Controller bind failed (%s)\n",
+ ib_get_err_str(status));
+ goto Exit;
+ }
+
+Exit:
+ OSM_LOG_EXIT(p_sm->p_log);
+ return status;
+}
+
+void osm_sm_reroute_mlid(osm_sm_t * sm, ib_net16_t mlid)
+{
+ mlid = cl_ntoh16(mlid) - IB_LID_MCAST_START_HO;
+ sm->mlids_req[mlid] = 1;
+ if (sm->mlids_req_max < mlid)
+ sm->mlids_req_max = mlid;
+ osm_sm_signal(sm, OSM_SIGNAL_IDLE_TIME_PROCESS_REQUEST);
+ OSM_LOG(sm->p_log, OSM_LOG_DEBUG, "rerouting requested for MLID 0x%x\n",
+ mlid + IB_LID_MCAST_START_HO);
+}
+
+void osm_set_sm_priority(osm_sm_t * sm, uint8_t priority)
+{
+ uint8_t old_pri = sm->p_subn->opt.sm_priority;
+
+ sm->p_subn->opt.sm_priority = priority;
+
+ if (old_pri < priority &&
+ sm->p_subn->sm_state == IB_SMINFO_STATE_STANDBY)
+ osm_send_trap144(sm, TRAP_144_MASK_SM_PRIORITY_CHANGE);
+}
diff --git a/contrib/ofed/opensm/opensm/osm_sm_mad_ctrl.c b/contrib/ofed/opensm/opensm/osm_sm_mad_ctrl.c
new file mode 100644
index 0000000..ebac558
--- /dev/null
+++ b/contrib/ofed/opensm/opensm/osm_sm_mad_ctrl.c
@@ -0,0 +1,925 @@
+/*
+ * Copyright (c) 2004-2009 Voltaire, Inc. All rights reserved.
+ * Copyright (c) 2002-2011 Mellanox Technologies LTD. All rights reserved.
+ * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
+ * Copyright (c) 2009 HNR Consulting. All rights reserved.
+ * Copyright (c) 2009 Sun Microsystems, Inc. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+/*
+ * Abstract:
+ * Implementation of osm_sm_mad_ctrl_t.
+ * This object represents the SM MAD request controller object.
+ * This object is part of the opensm family of objects.
+ */
+
+#if HAVE_CONFIG_H
+# include <config.h>
+#endif /* HAVE_CONFIG_H */
+
+#include <string.h>
+#include <complib/cl_debug.h>
+#include <iba/ib_types.h>
+#include <opensm/osm_file_ids.h>
+#define FILE_ID OSM_FILE_SM_MAD_CTRL_C
+#include <opensm/osm_sm_mad_ctrl.h>
+#include <vendor/osm_vendor_api.h>
+#include <opensm/osm_madw.h>
+#include <opensm/osm_msgdef.h>
+#include <opensm/osm_helper.h>
+#include <opensm/osm_opensm.h>
+
+/****f* opensm: SM/sm_mad_ctrl_retire_trans_mad
+ * NAME
+ * sm_mad_ctrl_retire_trans_mad
+ *
+ * DESCRIPTION
+ * This function handles clean-up of MADs associated with the SM's
+ * outstanding transactions on the wire.
+ *
+ * SYNOPSIS
+ */
+
+static void sm_mad_ctrl_retire_trans_mad(IN osm_sm_mad_ctrl_t * p_ctrl,
+ IN osm_madw_t * p_madw)
+{
+ uint32_t outstanding;
+
+ OSM_LOG_ENTER(p_ctrl->p_log);
+
+ CL_ASSERT(p_madw);
+ /*
+ Return the MAD & wrapper to the pool.
+ */
+ OSM_LOG(p_ctrl->p_log, OSM_LOG_DEBUG,
+ "Retiring MAD with TID 0x%" PRIx64 "\n",
+ cl_ntoh64(osm_madw_get_smp_ptr(p_madw)->trans_id));
+
+ osm_mad_pool_put(p_ctrl->p_mad_pool, p_madw);
+
+ outstanding = osm_stats_dec_qp0_outstanding(p_ctrl->p_stats);
+
+ OSM_LOG(p_ctrl->p_log, OSM_LOG_DEBUG, "%u QP0 MADs outstanding%s\n",
+ p_ctrl->p_stats->qp0_mads_outstanding,
+ outstanding ? "" : ": wire is clean.");
+
+ OSM_LOG_EXIT(p_ctrl->p_log);
+}
+
+/************/
+
+/****f* opensm: SM/sm_mad_ctrl_disp_done_callback
+ * NAME
+ * sm_mad_ctrl_disp_done_callback
+ *
+ * DESCRIPTION
+ * This function is the Dispatcher callback that indicates
+ * a received MAD has been processed by the recipient.
+ *
+ * SYNOPSIS
+ */
+static void sm_mad_ctrl_disp_done_callback(IN void *context, IN void *p_data)
+{
+ osm_sm_mad_ctrl_t *p_ctrl = context;
+ osm_madw_t *p_madw = p_data;
+ ib_smp_t *p_smp;
+
+ OSM_LOG_ENTER(p_ctrl->p_log);
+
+ /*
+ If the MAD that just finished processing was a response,
+ then retire the transaction, since we must have generated
+ the request.
+
+ Otherwise, retire the transaction if a response was expected,
+ as in the case of a send failure. If a response was not expected,
+ just put the MAD back in the pool, because the MAD was a query
+ from some outside agent, e.g. Get(SMInfo) from another SM.
+ */
+ p_smp = osm_madw_get_smp_ptr(p_madw);
+ if (ib_smp_is_response(p_smp)) {
+ CL_ASSERT(p_madw->resp_expected == FALSE);
+ sm_mad_ctrl_retire_trans_mad(p_ctrl, p_madw);
+ } else if (p_madw->resp_expected == TRUE)
+ sm_mad_ctrl_retire_trans_mad(p_ctrl, p_madw);
+ else
+ osm_mad_pool_put(p_ctrl->p_mad_pool, p_madw);
+
+ OSM_LOG_EXIT(p_ctrl->p_log);
+}
+
+/************/
+
+/****f* opensm: SM/sm_mad_ctrl_update_wire_stats
+ * NAME
+ * sm_mad_ctrl_update_wire_stats
+ *
+ * DESCRIPTION
+ * Updates wire stats for outstanding MADs and calls the VL15 poller.
+ *
+ * SYNOPSIS
+ */
+static void sm_mad_ctrl_update_wire_stats(IN osm_sm_mad_ctrl_t * p_ctrl)
+{
+ uint32_t mads_on_wire;
+
+ OSM_LOG_ENTER(p_ctrl->p_log);
+
+ mads_on_wire =
+ cl_atomic_dec(&p_ctrl->p_stats->qp0_mads_outstanding_on_wire);
+
+ OSM_LOG(p_ctrl->p_log, OSM_LOG_DEBUG,
+ "%u SMPs on the wire, %u outstanding\n", mads_on_wire,
+ p_ctrl->p_stats->qp0_mads_outstanding);
+
+ /*
+ We can signal the VL15 controller to send another MAD
+ if any are waiting for transmission.
+ */
+ osm_vl15_poll(p_ctrl->p_vl15);
+ OSM_LOG_EXIT(p_ctrl->p_log);
+}
+
+/****f* opensm: SM/sm_mad_ctrl_process_get_resp
+ * NAME
+ * sm_mad_ctrl_process_get_resp
+ *
+ * DESCRIPTION
+ * This function handles method GetResp() for received MADs.
+ * This is the most common path for QP0 MADs.
+ *
+ * SYNOPSIS
+ */
+static void sm_mad_ctrl_process_get_resp(IN osm_sm_mad_ctrl_t * p_ctrl,
+ IN osm_madw_t * p_madw,
+ IN void *transaction_context)
+{
+ ib_smp_t *p_smp;
+ cl_status_t status;
+ osm_madw_t *p_old_madw;
+ cl_disp_msgid_t msg_id = CL_DISP_MSGID_NONE;
+
+ OSM_LOG_ENTER(p_ctrl->p_log);
+
+ CL_ASSERT(p_madw);
+ CL_ASSERT(transaction_context);
+
+ p_smp = osm_madw_get_smp_ptr(p_madw);
+
+ if (p_smp->mgmt_class == IB_MCLASS_SUBN_DIR && !ib_smp_is_d(p_smp)) {
+ OSM_LOG(p_ctrl->p_log, OSM_LOG_ERROR, "ERR 3102: "
+ "'D' bit not set in returned SMP\n");
+ osm_dump_dr_smp_v2(p_ctrl->p_log, p_smp, FILE_ID, OSM_LOG_ERROR);
+ }
+
+ p_old_madw = transaction_context;
+
+ sm_mad_ctrl_update_wire_stats(p_ctrl);
+
+ /*
+ Copy the MAD Wrapper context from the requesting MAD
+ to the new MAD. This mechanism allows the recipient
+ controller to recover its own context regarding this
+ MAD transaction. Once we've copied the context, we
+ can return the original MAD to the pool.
+ */
+ osm_madw_copy_context(p_madw, p_old_madw);
+ osm_mad_pool_put(p_ctrl->p_mad_pool, p_old_madw);
+
+ /*
+ Note that attr_id (like the rest of the MAD) is in
+ network byte order.
+ */
+ switch (p_smp->attr_id) {
+ case IB_MAD_ATTR_NODE_DESC:
+ msg_id = OSM_MSG_MAD_NODE_DESC;
+ break;
+ case IB_MAD_ATTR_NODE_INFO:
+ msg_id = OSM_MSG_MAD_NODE_INFO;
+ break;
+ case IB_MAD_ATTR_GUID_INFO:
+ msg_id = OSM_MSG_MAD_GUID_INFO;
+ break;
+ case IB_MAD_ATTR_SWITCH_INFO:
+ msg_id = OSM_MSG_MAD_SWITCH_INFO;
+ break;
+ case IB_MAD_ATTR_PORT_INFO:
+ msg_id = OSM_MSG_MAD_PORT_INFO;
+ break;
+ case IB_MAD_ATTR_LIN_FWD_TBL:
+ msg_id = OSM_MSG_MAD_LFT;
+ break;
+ case IB_MAD_ATTR_MCAST_FWD_TBL:
+ msg_id = OSM_MSG_MAD_MFT;
+ break;
+ case IB_MAD_ATTR_SM_INFO:
+ msg_id = OSM_MSG_MAD_SM_INFO;
+ break;
+ case IB_MAD_ATTR_SLVL_TABLE:
+ msg_id = OSM_MSG_MAD_SLVL;
+ break;
+ case IB_MAD_ATTR_VL_ARBITRATION:
+ msg_id = OSM_MSG_MAD_VL_ARB;
+ break;
+ case IB_MAD_ATTR_P_KEY_TABLE:
+ msg_id = OSM_MSG_MAD_PKEY;
+ break;
+ case IB_MAD_ATTR_MLNX_EXTENDED_PORT_INFO:
+ msg_id = OSM_MSG_MAD_MLNX_EXT_PORT_INFO;
+ break;
+ case IB_MAD_ATTR_CLASS_PORT_INFO:
+ case IB_MAD_ATTR_NOTICE:
+ case IB_MAD_ATTR_INFORM_INFO:
+ default:
+ cl_atomic_inc(&p_ctrl->p_stats->qp0_mads_rcvd_unknown);
+ OSM_LOG(p_ctrl->p_log, OSM_LOG_ERROR, "ERR 3103: "
+ "Unsupported attribute 0x%X (%s)\n",
+ cl_ntoh16(p_smp->attr_id),
+ ib_get_sm_attr_str(p_smp->attr_id));
+ osm_dump_dr_smp_v2(p_ctrl->p_log, p_smp, FILE_ID, OSM_LOG_ERROR);
+ osm_mad_pool_put(p_ctrl->p_mad_pool, p_madw);
+ goto Exit;
+ }
+
+ /*
+ Post this MAD to the dispatcher for asynchronous
+ processing by the appropriate controller.
+ */
+
+ OSM_LOG(p_ctrl->p_log, OSM_LOG_DEBUG, "Posting Dispatcher message %s\n",
+ osm_get_disp_msg_str(msg_id));
+
+ status = cl_disp_post(p_ctrl->h_disp, msg_id, p_madw,
+ sm_mad_ctrl_disp_done_callback, p_ctrl);
+
+ if (status != CL_SUCCESS) {
+ OSM_LOG(p_ctrl->p_log, OSM_LOG_ERROR, "ERR 3104: "
+ "Dispatcher post message failed (%s) for attribute 0x%X (%s)\n",
+ CL_STATUS_MSG(status), cl_ntoh16(p_smp->attr_id),
+ ib_get_sm_attr_str(p_smp->attr_id));
+ goto Exit;
+ }
+
+Exit:
+ OSM_LOG_EXIT(p_ctrl->p_log);
+}
+
+/****f* opensm: SM/sm_mad_ctrl_process_get
+ * NAME
+ * sm_mad_ctrl_process_get
+ *
+ * DESCRIPTION
+ * This function handles method Get() for received MADs.
+ *
+ * SYNOPSIS
+ */
+static void sm_mad_ctrl_process_get(IN osm_sm_mad_ctrl_t * p_ctrl,
+ IN osm_madw_t * p_madw)
+{
+ ib_smp_t *p_smp;
+ cl_status_t status;
+ cl_disp_msgid_t msg_id = CL_DISP_MSGID_NONE;
+
+ OSM_LOG_ENTER(p_ctrl->p_log);
+
+ p_smp = osm_madw_get_smp_ptr(p_madw);
+
+ /*
+ Note that attr_id (like the rest of the MAD) is in
+ network byte order.
+ */
+ switch (p_smp->attr_id) {
+ case IB_MAD_ATTR_SM_INFO:
+ msg_id = OSM_MSG_MAD_SM_INFO;
+ break;
+ default:
+ cl_atomic_inc(&p_ctrl->p_stats->qp0_mads_rcvd_unknown);
+ OSM_LOG(p_ctrl->p_log, OSM_LOG_VERBOSE,
+ "Ignoring SubnGet MAD - unsupported attribute 0x%X\n",
+ cl_ntoh16(p_smp->attr_id));
+ osm_mad_pool_put(p_ctrl->p_mad_pool, p_madw);
+ goto Exit;
+ }
+
+ /*
+ Post this MAD to the dispatcher for asynchronous
+ processing by the appropriate controller.
+ */
+
+ OSM_LOG(p_ctrl->p_log, OSM_LOG_DEBUG, "Posting Dispatcher message %s\n",
+ osm_get_disp_msg_str(msg_id));
+
+ status = cl_disp_post(p_ctrl->h_disp, msg_id, p_madw,
+ sm_mad_ctrl_disp_done_callback, p_ctrl);
+
+ if (status != CL_SUCCESS) {
+ OSM_LOG(p_ctrl->p_log, OSM_LOG_ERROR, "ERR 3106: "
+ "Dispatcher post message failed (%s)\n",
+ CL_STATUS_MSG(status));
+ goto Exit;
+ }
+
+Exit:
+ OSM_LOG_EXIT(p_ctrl->p_log);
+}
+
+/*
+ * PARAMETERS
+ *
+ * RETURN VALUES
+ *
+ * NOTES
+ *
+ * SEE ALSO
+ *********/
+
+/****f* opensm: SM/sm_mad_ctrl_process_set
+ * NAME
+ * sm_mad_ctrl_process_set
+ *
+ * DESCRIPTION
+ * This function handles method Set() for received MADs.
+ *
+ * SYNOPSIS
+ */
+static void sm_mad_ctrl_process_set(IN osm_sm_mad_ctrl_t * p_ctrl,
+ IN osm_madw_t * p_madw)
+{
+ ib_smp_t *p_smp;
+ cl_status_t status;
+ cl_disp_msgid_t msg_id = CL_DISP_MSGID_NONE;
+
+ OSM_LOG_ENTER(p_ctrl->p_log);
+
+ p_smp = osm_madw_get_smp_ptr(p_madw);
+
+ /*
+ Note that attr_id (like the rest of the MAD) is in
+ network byte order.
+ */
+ switch (p_smp->attr_id) {
+ case IB_MAD_ATTR_SM_INFO:
+ msg_id = OSM_MSG_MAD_SM_INFO;
+ break;
+ default:
+ cl_atomic_inc(&p_ctrl->p_stats->qp0_mads_rcvd_unknown);
+ OSM_LOG(p_ctrl->p_log, OSM_LOG_ERROR, "ERR 3107: "
+ "Unsupported attribute 0x%X (%s)\n",
+ cl_ntoh16(p_smp->attr_id),
+ ib_get_sm_attr_str(p_smp->attr_id));
+ osm_dump_dr_smp_v2(p_ctrl->p_log, p_smp, FILE_ID, OSM_LOG_ERROR);
+ osm_mad_pool_put(p_ctrl->p_mad_pool, p_madw);
+ goto Exit;
+ }
+
+ /*
+ Post this MAD to the dispatcher for asynchronous
+ processing by the appropriate controller.
+ */
+
+ OSM_LOG(p_ctrl->p_log, OSM_LOG_DEBUG, "Posting Dispatcher message %s\n",
+ osm_get_disp_msg_str(msg_id));
+
+ status = cl_disp_post(p_ctrl->h_disp, msg_id, p_madw,
+ sm_mad_ctrl_disp_done_callback, p_ctrl);
+
+ if (status != CL_SUCCESS) {
+ OSM_LOG(p_ctrl->p_log, OSM_LOG_ERROR, "ERR 3108: "
+ "Dispatcher post message failed (%s)\n",
+ CL_STATUS_MSG(status));
+ goto Exit;
+ }
+
+Exit:
+ OSM_LOG_EXIT(p_ctrl->p_log);
+}
+
+/*
+ * PARAMETERS
+ *
+ * RETURN VALUES
+ *
+ * NOTES
+ *
+ * SEE ALSO
+ *********/
+
+/****f* opensm: SM/sm_mad_ctrl_process_trap
+ * NAME
+ * sm_mad_ctrl_process_trap
+ *
+ * DESCRIPTION
+ * This function handles method Trap() for received MADs.
+ *
+ * SYNOPSIS
+ */
+static void sm_mad_ctrl_process_trap(IN osm_sm_mad_ctrl_t * p_ctrl,
+ IN osm_madw_t * p_madw)
+{
+ ib_smp_t *p_smp;
+ cl_status_t status;
+ cl_disp_msgid_t msg_id = CL_DISP_MSGID_NONE;
+
+ OSM_LOG_ENTER(p_ctrl->p_log);
+
+ p_smp = osm_madw_get_smp_ptr(p_madw);
+
+ /* Make sure OpenSM is master. If not - then we should not process the trap */
+ if (p_ctrl->p_subn->sm_state != IB_SMINFO_STATE_MASTER) {
+ OSM_LOG(p_ctrl->p_log, OSM_LOG_DEBUG,
+ "Received trap but OpenSM is not in MASTER state. "
+ "Dropping mad\n");
+ osm_mad_pool_put(p_ctrl->p_mad_pool, p_madw);
+ goto Exit;
+ }
+
+ /*
+ Note that attr_id (like the rest of the MAD) is in
+ network byte order.
+ */
+ switch (p_smp->attr_id) {
+ case IB_MAD_ATTR_NOTICE:
+ msg_id = OSM_MSG_MAD_NOTICE;
+ break;
+ default:
+ cl_atomic_inc(&p_ctrl->p_stats->qp0_mads_rcvd_unknown);
+ OSM_LOG(p_ctrl->p_log, OSM_LOG_ERROR, "ERR 3109: "
+ "Unsupported attribute 0x%X (%s)\n",
+ cl_ntoh16(p_smp->attr_id),
+ ib_get_sm_attr_str(p_smp->attr_id));
+ osm_dump_dr_smp_v2(p_ctrl->p_log, p_smp, FILE_ID, OSM_LOG_ERROR);
+ osm_mad_pool_put(p_ctrl->p_mad_pool, p_madw);
+ goto Exit;
+ }
+
+ /*
+ Post this MAD to the dispatcher for asynchronous
+ processing by the appropriate controller.
+ */
+
+ OSM_LOG(p_ctrl->p_log, OSM_LOG_DEBUG, "Posting Dispatcher message %s\n",
+ osm_get_disp_msg_str(msg_id));
+
+ status = cl_disp_post(p_ctrl->h_disp, msg_id, p_madw,
+ sm_mad_ctrl_disp_done_callback, p_ctrl);
+
+ if (status != CL_SUCCESS) {
+ OSM_LOG(p_ctrl->p_log, OSM_LOG_ERROR, "ERR 3110: "
+ "Dispatcher post message failed (%s)\n",
+ CL_STATUS_MSG(status));
+ goto Exit;
+ }
+
+Exit:
+ OSM_LOG_EXIT(p_ctrl->p_log);
+}
+
+/*
+ * PARAMETERS
+ *
+ * RETURN VALUES
+ *
+ * NOTES
+ *
+ * SEE ALSO
+ *********/
+
+/****f* opensm: SM/sm_mad_ctrl_process_trap_repress
+ * NAME
+ * sm_mad_ctrl_process_trap_repress
+ *
+ * DESCRIPTION
+ * This function handles method TrapRepress() for received MADs.
+ *
+ * SYNOPSIS
+ */
+static void sm_mad_ctrl_process_trap_repress(IN osm_sm_mad_ctrl_t * p_ctrl,
+ IN osm_madw_t * p_madw)
+{
+ ib_smp_t *p_smp;
+
+ OSM_LOG_ENTER(p_ctrl->p_log);
+
+ p_smp = osm_madw_get_smp_ptr(p_madw);
+
+ /*
+ Note that attr_id (like the rest of the MAD) is in
+ network byte order.
+ */
+ switch (p_smp->attr_id) {
+ case IB_MAD_ATTR_NOTICE:
+ sm_mad_ctrl_update_wire_stats(p_ctrl);
+ sm_mad_ctrl_retire_trans_mad(p_ctrl, p_madw);
+ break;
+ default:
+ cl_atomic_inc(&p_ctrl->p_stats->qp0_mads_rcvd_unknown);
+ OSM_LOG(p_ctrl->p_log, OSM_LOG_ERROR, "ERR 3105: "
+ "Unsupported attribute 0x%X (%s)\n",
+ cl_ntoh16(p_smp->attr_id),
+ ib_get_sm_attr_str(p_smp->attr_id));
+ osm_dump_dr_smp_v2(p_ctrl->p_log, p_smp, FILE_ID, OSM_LOG_ERROR);
+ osm_mad_pool_put(p_ctrl->p_mad_pool, p_madw);
+ break;
+ }
+
+ OSM_LOG_EXIT(p_ctrl->p_log);
+}
+
+static void log_rcv_cb_error(osm_log_t *p_log, ib_smp_t *p_smp, ib_net16_t status)
+{
+ char buf[BUF_SIZE];
+ uint32_t i;
+
+ if (p_smp->mgmt_class == IB_MCLASS_SUBN_DIR) {
+ char ipath[BUF_SIZE], rpath[BUF_SIZE];
+ int ni = sprintf(ipath, "%d", p_smp->initial_path[0]);
+ int nr = sprintf(rpath, "%d", p_smp->return_path[0]);
+ for (i = 1; i <= p_smp->hop_count; i++) {
+ ni += sprintf(ipath + ni, ",%d", p_smp->initial_path[i]);
+ nr += sprintf(rpath + nr, ",%d", p_smp->return_path[i]);
+ }
+ snprintf(buf, sizeof(buf),
+ "\n\t\t\tInitial path: %s Return path: %s",
+ ipath, rpath);
+ }
+
+ OSM_LOG(p_log, OSM_LOG_ERROR, "ERR 3111: "
+ "Received MAD with error status = 0x%X\n"
+ "\t\t\t%s(%s), attr_mod 0x%x, TID 0x%" PRIx64 "%s\n",
+ cl_ntoh16(status), ib_get_sm_method_str(p_smp->method),
+ ib_get_sm_attr_str(p_smp->attr_id), cl_ntoh32(p_smp->attr_mod),
+ cl_ntoh64(p_smp->trans_id),
+ p_smp->mgmt_class == IB_MCLASS_SUBN_DIR ? buf : "");
+
+ osm_dump_dr_smp_v2(p_log, p_smp, FILE_ID, OSM_LOG_VERBOSE);
+}
+
+/*
+ * PARAMETERS
+ *
+ * RETURN VALUES
+ *
+ * NOTES
+ *
+ * SEE ALSO
+ *********/
+
+/****f* opensm: SM/sm_mad_ctrl_rcv_callback
+ * NAME
+ * sm_mad_ctrl_rcv_callback
+ *
+ * DESCRIPTION
+ * This is the callback from the transport layer for received MADs.
+ *
+ * SYNOPSIS
+ */
+static void sm_mad_ctrl_rcv_callback(IN osm_madw_t * p_madw,
+ IN void *bind_context,
+ IN osm_madw_t * p_req_madw)
+{
+ osm_sm_mad_ctrl_t *p_ctrl = bind_context;
+ ib_smp_t *p_smp;
+ ib_net16_t status;
+
+ OSM_LOG_ENTER(p_ctrl->p_log);
+
+ CL_ASSERT(p_madw);
+
+ /*
+ A MAD was received from the wire, possibly in response to a request.
+ */
+ cl_atomic_inc(&p_ctrl->p_stats->qp0_mads_rcvd);
+
+ OSM_LOG(p_ctrl->p_log, OSM_LOG_DEBUG, "%u QP0 MADs received\n",
+ p_ctrl->p_stats->qp0_mads_rcvd);
+
+ p_smp = osm_madw_get_smp_ptr(p_madw);
+
+ /* if we are closing down simply do nothing */
+ if (osm_exit_flag) {
+ OSM_LOG(p_ctrl->p_log, OSM_LOG_ERROR,
+ "Ignoring received mad - since we are exiting\n");
+
+ osm_dump_dr_smp_v2(p_ctrl->p_log, p_smp, FILE_ID, OSM_LOG_DEBUG);
+
+ /* retire the mad or put it back */
+ if (ib_smp_is_response(p_smp)) {
+ CL_ASSERT(p_madw->resp_expected == FALSE);
+ sm_mad_ctrl_retire_trans_mad(p_ctrl, p_madw);
+ } else if (p_madw->resp_expected == TRUE)
+ sm_mad_ctrl_retire_trans_mad(p_ctrl, p_madw);
+ else
+ osm_mad_pool_put(p_ctrl->p_mad_pool, p_madw);
+
+ goto Exit;
+ }
+
+ if (OSM_LOG_IS_ACTIVE_V2(p_ctrl->p_log, OSM_LOG_FRAMES))
+ osm_dump_dr_smp_v2(p_ctrl->p_log, p_smp, FILE_ID, OSM_LOG_FRAMES);
+
+ if (p_smp->mgmt_class == IB_MCLASS_SUBN_DIR)
+ status = ib_smp_get_status(p_smp);
+ else
+ status = p_smp->status;
+
+ if (status != 0)
+ log_rcv_cb_error(p_ctrl->p_log, p_smp, status);
+
+ switch (p_smp->method) {
+ case IB_MAD_METHOD_GET_RESP:
+ CL_ASSERT(p_req_madw != NULL);
+ sm_mad_ctrl_process_get_resp(p_ctrl, p_madw, p_req_madw);
+ break;
+ case IB_MAD_METHOD_GET:
+ CL_ASSERT(p_req_madw == NULL);
+ sm_mad_ctrl_process_get(p_ctrl, p_madw);
+ break;
+ case IB_MAD_METHOD_TRAP:
+ CL_ASSERT(p_req_madw == NULL);
+ sm_mad_ctrl_process_trap(p_ctrl, p_madw);
+ break;
+ case IB_MAD_METHOD_SET:
+ CL_ASSERT(p_req_madw == NULL);
+ sm_mad_ctrl_process_set(p_ctrl, p_madw);
+ break;
+ case IB_MAD_METHOD_TRAP_REPRESS:
+ CL_ASSERT(p_req_madw != NULL);
+ sm_mad_ctrl_process_trap_repress(p_ctrl, p_madw);
+ break;
+ case IB_MAD_METHOD_SEND:
+ case IB_MAD_METHOD_REPORT:
+ case IB_MAD_METHOD_REPORT_RESP:
+ default:
+ cl_atomic_inc(&p_ctrl->p_stats->qp0_mads_rcvd_unknown);
+ OSM_LOG(p_ctrl->p_log, OSM_LOG_ERROR, "ERR 3112: "
+ "Unsupported method = 0x%X\n", p_smp->method);
+ osm_dump_dr_smp_v2(p_ctrl->p_log, p_smp, FILE_ID, OSM_LOG_ERROR);
+ osm_mad_pool_put(p_ctrl->p_mad_pool, p_madw);
+ goto Exit;
+ }
+
+Exit:
+ OSM_LOG_EXIT(p_ctrl->p_log);
+}
+
+/*
+ * PARAMETERS
+ *
+ * RETURN VALUES
+ *
+ * NOTES
+ *
+ * SEE ALSO
+ *********/
+
+/****f* opensm: SM/sm_mad_ctrl_send_err_cb
+ * NAME
+ * sm_mad_ctrl_send_err_cb
+ *
+ * DESCRIPTION
+ * This is the callback from the transport layer for send errors
+ * on MADs that were expecting a response.
+ *
+ * SYNOPSIS
+ */
+static void sm_mad_ctrl_send_err_cb(IN void *context, IN osm_madw_t * p_madw)
+{
+ osm_sm_mad_ctrl_t *p_ctrl = context;
+ ib_api_status_t status;
+ ib_smp_t *p_smp;
+
+ OSM_LOG_ENTER(p_ctrl->p_log);
+
+ CL_ASSERT(p_madw);
+
+ p_smp = osm_madw_get_smp_ptr(p_madw);
+ OSM_LOG(p_ctrl->p_log, OSM_LOG_ERROR, "ERR 3113: "
+ "MAD completed in error (%s): "
+ "%s(%s), attr_mod 0x%x, TID 0x%" PRIx64 "\n",
+ ib_get_err_str(p_madw->status),
+ ib_get_sm_method_str(p_smp->method),
+ ib_get_sm_attr_str(p_smp->attr_id), cl_ntoh32(p_smp->attr_mod),
+ cl_ntoh64(p_smp->trans_id));
+
+ /*
+ If this was a SubnSet MAD, then this error might indicate a problem
+ in configuring the subnet. In this case - need to mark that there was
+ such a problem. The subnet will not be up, and the next sweep should
+ be a heavy sweep as well.
+ */
+ if (p_smp->method == IB_MAD_METHOD_SET &&
+ (p_smp->attr_id == IB_MAD_ATTR_PORT_INFO ||
+ p_smp->attr_id == IB_MAD_ATTR_MLNX_EXTENDED_PORT_INFO ||
+ p_smp->attr_id == IB_MAD_ATTR_MCAST_FWD_TBL ||
+ p_smp->attr_id == IB_MAD_ATTR_SWITCH_INFO ||
+ p_smp->attr_id == IB_MAD_ATTR_LIN_FWD_TBL ||
+ p_smp->attr_id == IB_MAD_ATTR_P_KEY_TABLE)) {
+ OSM_LOG(p_ctrl->p_log, OSM_LOG_ERROR, "ERR 3119: "
+ "Set method failed for attribute 0x%X (%s)\n",
+ cl_ntoh16(p_smp->attr_id),
+ ib_get_sm_attr_str(p_smp->attr_id));
+ p_ctrl->p_subn->subnet_initialization_error = TRUE;
+ } else if (p_madw->status == IB_TIMEOUT &&
+ p_smp->method == IB_MAD_METHOD_GET) {
+ OSM_LOG(p_ctrl->p_log, OSM_LOG_ERROR, "ERR 3120: "
+ "Timeout while getting attribute 0x%X (%s); "
+ "Possible mis-set mkey?\n",
+ cl_ntoh16(p_smp->attr_id),
+ ib_get_sm_attr_str(p_smp->attr_id));
+ }
+
+ osm_dump_dr_smp_v2(p_ctrl->p_log, p_smp, FILE_ID, OSM_LOG_VERBOSE);
+
+ /*
+ Since we did not get any response we suspect the DR path
+ used for the target port.
+ Find it and replace it with an alternate path.
+ This is true only if the destination lid is not 0xFFFF, since
+ then we are aiming for a specific path and not specific destination
+ lid.
+ */
+ /* For now - do not add the alternate dr path to the release */
+#if 0
+ if (p_madw->mad_addr.dest_lid != 0xFFFF) {
+ osm_physp_t *p_physp = osm_get_physp_by_mad_addr(p_ctrl->p_log,
+ p_ctrl->p_subn,
+ &(p_madw->
+ mad_addr));
+ if (!p_physp) {
+ OSM_LOG(p_ctrl->p_log, OSM_LOG_ERROR, "ERR 3114: "
+ "Failed to find the corresponding phys port\n");
+ } else {
+ osm_physp_replace_dr_path_with_alternate_dr_path
+ (p_ctrl->p_log, p_ctrl->p_subn, p_physp,
+ p_madw->h_bind);
+ }
+ }
+#endif
+
+ /*
+ An error occurred. No response was received to a request MAD.
+ Retire the original request MAD.
+ */
+ sm_mad_ctrl_update_wire_stats(p_ctrl);
+
+ if (osm_madw_get_err_msg(p_madw) != CL_DISP_MSGID_NONE) {
+ OSM_LOG(p_ctrl->p_log, OSM_LOG_DEBUG,
+ "Posting Dispatcher message %s\n",
+ osm_get_disp_msg_str(osm_madw_get_err_msg(p_madw)));
+
+ status = cl_disp_post(p_ctrl->h_disp,
+ osm_madw_get_err_msg(p_madw), p_madw,
+ sm_mad_ctrl_disp_done_callback, p_ctrl);
+ if (status != CL_SUCCESS)
+ OSM_LOG(p_ctrl->p_log, OSM_LOG_ERROR, "ERR 3115: "
+ "Dispatcher post message failed (%s)\n",
+ CL_STATUS_MSG(status));
+ } else
+ /*
+ No error message was provided, just retire the MAD.
+ */
+ sm_mad_ctrl_retire_trans_mad(p_ctrl, p_madw);
+
+ OSM_LOG_EXIT(p_ctrl->p_log);
+}
+
+/*
+ * PARAMETERS
+ *
+ * RETURN VALUES
+ *
+ * NOTES
+ *
+ * SEE ALSO
+ *********/
+
+void osm_sm_mad_ctrl_construct(IN osm_sm_mad_ctrl_t * p_ctrl)
+{
+ CL_ASSERT(p_ctrl);
+ memset(p_ctrl, 0, sizeof(*p_ctrl));
+ p_ctrl->h_disp = CL_DISP_INVALID_HANDLE;
+}
+
+void osm_sm_mad_ctrl_destroy(IN osm_sm_mad_ctrl_t * p_ctrl)
+{
+ CL_ASSERT(p_ctrl);
+
+ if (p_ctrl->h_bind != CL_DISP_INVALID_HANDLE)
+ osm_vendor_unbind(p_ctrl->h_bind);
+ cl_disp_unregister(p_ctrl->h_disp);
+}
+
+ib_api_status_t osm_sm_mad_ctrl_init(IN osm_sm_mad_ctrl_t * p_ctrl,
+ IN osm_subn_t * p_subn,
+ IN osm_mad_pool_t * p_mad_pool,
+ IN osm_vl15_t * p_vl15,
+ IN osm_vendor_t * p_vendor,
+ IN osm_log_t * p_log,
+ IN osm_stats_t * p_stats,
+ IN cl_plock_t * p_lock,
+ IN cl_dispatcher_t * p_disp)
+{
+ ib_api_status_t status = IB_SUCCESS;
+
+ OSM_LOG_ENTER(p_log);
+
+ osm_sm_mad_ctrl_construct(p_ctrl);
+
+ p_ctrl->p_subn = p_subn;
+ p_ctrl->p_log = p_log;
+ p_ctrl->p_disp = p_disp;
+ p_ctrl->p_mad_pool = p_mad_pool;
+ p_ctrl->p_vendor = p_vendor;
+ p_ctrl->p_stats = p_stats;
+ p_ctrl->p_lock = p_lock;
+ p_ctrl->p_vl15 = p_vl15;
+
+ p_ctrl->h_disp = cl_disp_register(p_disp, CL_DISP_MSGID_NONE, NULL,
+ NULL);
+
+ if (p_ctrl->h_disp == CL_DISP_INVALID_HANDLE) {
+ OSM_LOG(p_log, OSM_LOG_ERROR, "ERR 3116: "
+ "Dispatcher registration failed\n");
+ status = IB_INSUFFICIENT_RESOURCES;
+ goto Exit;
+ }
+
+Exit:
+ OSM_LOG_EXIT(p_log);
+ return status;
+}
+
+ib_api_status_t osm_sm_mad_ctrl_bind(IN osm_sm_mad_ctrl_t * p_ctrl,
+ IN ib_net64_t port_guid)
+{
+ osm_bind_info_t bind_info;
+ ib_api_status_t status = IB_SUCCESS;
+
+ OSM_LOG_ENTER(p_ctrl->p_log);
+
+ if (p_ctrl->h_bind != OSM_BIND_INVALID_HANDLE) {
+ OSM_LOG(p_ctrl->p_log, OSM_LOG_ERROR, "ERR 3117: "
+ "Multiple binds not allowed\n");
+ status = IB_ERROR;
+ goto Exit;
+ }
+
+ bind_info.class_version = 1;
+ bind_info.is_report_processor = FALSE;
+ bind_info.is_responder = TRUE;
+ bind_info.is_trap_processor = TRUE;
+ bind_info.mad_class = IB_MCLASS_SUBN_DIR;
+ bind_info.port_guid = port_guid;
+ bind_info.recv_q_size = OSM_SM_DEFAULT_QP0_RCV_SIZE;
+ bind_info.send_q_size = OSM_SM_DEFAULT_QP0_SEND_SIZE;
+ bind_info.timeout = p_ctrl->p_subn->opt.transaction_timeout;
+ bind_info.retries = p_ctrl->p_subn->opt.transaction_retries;
+
+ OSM_LOG(p_ctrl->p_log, OSM_LOG_VERBOSE,
+ "Binding to port 0x%" PRIx64 "\n", cl_ntoh64(port_guid));
+
+ p_ctrl->h_bind = osm_vendor_bind(p_ctrl->p_vendor, &bind_info,
+ p_ctrl->p_mad_pool,
+ sm_mad_ctrl_rcv_callback,
+ sm_mad_ctrl_send_err_cb, p_ctrl);
+
+ if (p_ctrl->h_bind == OSM_BIND_INVALID_HANDLE) {
+ status = IB_ERROR;
+ OSM_LOG(p_ctrl->p_log, OSM_LOG_ERROR, "ERR 3118: "
+ "Vendor specific bind failed\n");
+ goto Exit;
+ }
+
+Exit:
+ OSM_LOG_EXIT(p_ctrl->p_log);
+ return status;
+}
diff --git a/contrib/ofed/opensm/opensm/osm_sm_state_mgr.c b/contrib/ofed/opensm/opensm/osm_sm_state_mgr.c
new file mode 100644
index 0000000..b543e7f
--- /dev/null
+++ b/contrib/ofed/opensm/opensm/osm_sm_state_mgr.c
@@ -0,0 +1,588 @@
+/*
+ * Copyright (c) 2002-2013 Mellanox Technologies LTD. All rights reserved.
+ * Copyright (c) 2004-2009 Voltaire, Inc. All rights reserved.
+ * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
+ * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+/*
+ * Abstract:
+ * Implementation of osm_sm_state_mgr_t.
+ * This file implements the SM State Manager object.
+ */
+
+#if HAVE_CONFIG_H
+# include <config.h>
+#endif /* HAVE_CONFIG_H */
+
+#include <string.h>
+#include <time.h>
+#include <iba/ib_types.h>
+#include <complib/cl_passivelock.h>
+#include <complib/cl_debug.h>
+#include <opensm/osm_file_ids.h>
+#define FILE_ID OSM_FILE_SM_STATE_MGR_C
+#include <opensm/osm_sm.h>
+#include <opensm/osm_madw.h>
+#include <opensm/osm_switch.h>
+#include <opensm/osm_log.h>
+#include <opensm/osm_subnet.h>
+#include <opensm/osm_helper.h>
+#include <opensm/osm_msgdef.h>
+#include <opensm/osm_node.h>
+#include <opensm/osm_port.h>
+#include <vendor/osm_vendor_api.h>
+#include <opensm/osm_helper.h>
+#include <opensm/osm_opensm.h>
+
+void osm_report_sm_state(osm_sm_t * sm)
+{
+ char buf[64];
+ const char *state_str = osm_get_sm_mgr_state_str(sm->p_subn->sm_state);
+
+ osm_log_v2(sm->p_log, OSM_LOG_SYS, FILE_ID, "Entering %s state\n", state_str);
+ snprintf(buf, sizeof(buf), "ENTERING SM %s STATE", state_str);
+ OSM_LOG_MSG_BOX(sm->p_log, OSM_LOG_VERBOSE, buf);
+}
+
+static boolean_t sm_state_mgr_send_master_sm_info_req(osm_sm_t * sm, uint8_t sm_state)
+{
+ osm_madw_context_t context;
+ const osm_port_t *p_port;
+ ib_api_status_t status;
+ osm_dr_path_t dr_path;
+ ib_net64_t guid;
+ boolean_t sent_req = FALSE;
+
+ OSM_LOG_ENTER(sm->p_log);
+
+ memset(&context, 0, sizeof(context));
+ if (sm_state == IB_SMINFO_STATE_STANDBY) {
+ /*
+ * We are in STANDBY state - this means we need to poll the
+ * master SM (according to master_guid).
+ * Send a query of SubnGet(SMInfo) to the subn
+ * master_sm_base_lid object.
+ */
+ guid = sm->master_sm_guid;
+ } else {
+ /*
+ * We are not in STANDBY - this means we are in MASTER state -
+ * so we need to poll the SM that is saved in polling_sm_guid
+ * under sm.
+ * Send a query of SubnGet(SMInfo) to that SM.
+ */
+ guid = sm->polling_sm_guid;
+ }
+
+ /* Verify that SM is not polling itself */
+ if (guid == sm->p_subn->sm_port_guid) {
+ OSM_LOG(sm->p_log, OSM_LOG_VERBOSE,
+ "OpenSM doesn't poll itself\n");
+ goto Exit;
+ }
+
+ p_port = osm_get_port_by_guid(sm->p_subn, guid);
+
+ if (p_port == NULL) {
+ OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR 3203: "
+ "No port object for GUID 0x%016" PRIx64 "\n",
+ cl_ntoh64(guid));
+ goto Exit;
+ }
+
+ context.smi_context.port_guid = guid;
+ context.smi_context.set_method = FALSE;
+ memcpy(&dr_path, osm_physp_get_dr_path_ptr(p_port->p_physp), sizeof(osm_dr_path_t));
+
+ status = osm_req_get(sm, &dr_path,
+ IB_MAD_ATTR_SM_INFO, 0, FALSE,
+ ib_port_info_get_m_key(&p_port->p_physp->port_info),
+ CL_DISP_MSGID_NONE, &context);
+
+ if (status != IB_SUCCESS)
+ OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR 3204: "
+ "Failure requesting SMInfo (%s)\n",
+ ib_get_err_str(status));
+ else
+ sent_req = TRUE;
+
+Exit:
+ OSM_LOG_EXIT(sm->p_log);
+
+ return (sent_req);
+}
+
+static void sm_state_mgr_start_polling(osm_sm_t * sm)
+{
+ uint32_t timeout;
+ cl_status_t cl_status;
+
+ OSM_LOG_ENTER(sm->p_log);
+
+ /*
+ * Init the retry_number back to zero - need to restart counting
+ */
+ sm->retry_number = 0;
+
+ /*
+ * Send a SubnGet(SMInfo) query to the current (or new) master found.
+ */
+ CL_PLOCK_ACQUIRE(sm->p_lock);
+ timeout = sm->p_subn->opt.sminfo_polling_timeout;
+ sm_state_mgr_send_master_sm_info_req(sm, sm->p_subn->sm_state);
+ CL_PLOCK_RELEASE(sm->p_lock);
+
+ /*
+ * Start a timer that will wake up every sminfo_polling_timeout milliseconds.
+ * The callback of the timer will send a SubnGet(SMInfo) to the Master SM
+ * and restart the timer
+ */
+ cl_status = cl_timer_start(&sm->polling_timer, timeout);
+ if (cl_status != CL_SUCCESS)
+ OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR 3210: "
+ "Failed to start polling timer\n");
+
+ OSM_LOG_EXIT(sm->p_log);
+}
+
+void osm_sm_state_mgr_polling_callback(IN void *context)
+{
+ osm_sm_t *sm = context;
+ uint32_t timeout;
+ cl_status_t cl_status;
+ uint8_t sm_state;
+
+ OSM_LOG_ENTER(sm->p_log);
+
+ cl_spinlock_acquire(&sm->state_lock);
+ sm_state = sm->p_subn->sm_state;
+ cl_spinlock_release(&sm->state_lock);
+
+ CL_PLOCK_ACQUIRE(sm->p_lock);
+ timeout = sm->p_subn->opt.sminfo_polling_timeout;
+
+ /*
+ * We can be here in one of two cases:
+ * 1. We are a STANDBY sm polling on the master SM.
+ * 2. We are a MASTER sm, waiting for a handover from a remote master sm.
+ * If we are not in one of these cases - don't need to restart the poller.
+ */
+ if (!((sm_state == IB_SMINFO_STATE_MASTER &&
+ sm->polling_sm_guid != 0) ||
+ sm_state == IB_SMINFO_STATE_STANDBY)) {
+ CL_PLOCK_RELEASE(sm->p_lock);
+ goto Exit;
+ }
+
+ /*
+ * If we are a STANDBY sm and the osm_exit_flag is set, then let's
+ * signal the subnet_up. This is relevant for the case of running only
+ * once. In that case - the program is stuck until this signal is
+ * received. In other cases - it is not relevant whether or not the
+ * signal is on - since we are currently in exit flow
+ */
+ if (sm_state == IB_SMINFO_STATE_STANDBY && osm_exit_flag) {
+ CL_PLOCK_RELEASE(sm->p_lock);
+ OSM_LOG(sm->p_log, OSM_LOG_VERBOSE,
+ "Signalling subnet_up_event\n");
+ cl_event_signal(&sm->subnet_up_event);
+ goto Exit;
+ }
+
+ /*
+ * If retry number reached the max_retry_number in the subnet opt - call
+ * osm_sm_state_mgr_process with signal OSM_SM_SIGNAL_POLLING_TIMEOUT
+ */
+ OSM_LOG(sm->p_log, OSM_LOG_VERBOSE, "SM State %d (%s), Retry number:%d\n",
+ sm->p_subn->sm_state, osm_get_sm_mgr_state_str(sm->p_subn->sm_state),
+ sm->retry_number);
+
+ if (sm->retry_number > sm->p_subn->opt.polling_retry_number) {
+ CL_PLOCK_RELEASE(sm->p_lock);
+ OSM_LOG(sm->p_log, OSM_LOG_DEBUG,
+ "Reached polling_retry_number value in retry_number. "
+ "Go to DISCOVERY state\n");
+ osm_sm_state_mgr_process(sm, OSM_SM_SIGNAL_POLLING_TIMEOUT);
+ goto Exit;
+ }
+
+ /* Send a SubnGet(SMInfo) request to the remote sm (depends on our state) */
+ if (sm_state_mgr_send_master_sm_info_req(sm, sm_state)) {
+ /* Request sent, increment the retry number */
+ sm->retry_number++;
+ }
+
+ CL_PLOCK_RELEASE(sm->p_lock);
+
+ /* restart the timer */
+ cl_status = cl_timer_start(&sm->polling_timer, timeout);
+ if (cl_status != CL_SUCCESS)
+ OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR 3211: "
+ "Failed to restart polling timer\n");
+
+Exit:
+ OSM_LOG_EXIT(sm->p_log);
+}
+
+static void sm_state_mgr_signal_error(osm_sm_t * sm, IN osm_sm_signal_t signal)
+{
+ OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR 3207: "
+ "Invalid signal %s in state %s\n",
+ osm_get_sm_mgr_signal_str(signal),
+ osm_get_sm_mgr_state_str(sm->p_subn->sm_state));
+}
+
+void osm_sm_state_mgr_signal_master_is_alive(osm_sm_t * sm)
+{
+ OSM_LOG_ENTER(sm->p_log);
+ sm->retry_number = 0;
+ OSM_LOG_EXIT(sm->p_log);
+}
+
+ib_api_status_t osm_sm_state_mgr_process(osm_sm_t * sm,
+ IN osm_sm_signal_t signal)
+{
+ ib_api_status_t status = IB_SUCCESS;
+
+ CL_ASSERT(sm);
+
+ OSM_LOG_ENTER(sm->p_log);
+
+ /*
+ * The state lock prevents many race conditions from screwing
+ * up the state transition process.
+ */
+ cl_spinlock_acquire(&sm->state_lock);
+
+ OSM_LOG(sm->p_log, OSM_LOG_DEBUG,
+ "Received signal %s in state %s\n",
+ osm_get_sm_mgr_signal_str(signal),
+ osm_get_sm_mgr_state_str(sm->p_subn->sm_state));
+
+ switch (sm->p_subn->sm_state) {
+ case IB_SMINFO_STATE_DISCOVERING:
+ switch (signal) {
+ case OSM_SM_SIGNAL_DISCOVERY_COMPLETED:
+ /*
+ * Update the state of the SM to MASTER
+ */
+ /* Turn on the first_time_master_sweep flag */
+ sm->p_subn->sm_state = IB_SMINFO_STATE_MASTER;
+ osm_report_sm_state(sm);
+ /*
+ * Make sure to set the subnet master_sm_base_lid
+ * to the sm_base_lid value
+ */
+ CL_PLOCK_EXCL_ACQUIRE(sm->p_lock);
+ sm->p_subn->first_time_master_sweep = TRUE;
+ sm->p_subn->master_sm_base_lid =
+ sm->p_subn->sm_base_lid;
+ CL_PLOCK_RELEASE(sm->p_lock);
+ break;
+ case OSM_SM_SIGNAL_MASTER_OR_HIGHER_SM_DETECTED:
+ /*
+ * Finished all discovery actions - move to STANDBY
+ * start the polling
+ */
+ sm->p_subn->sm_state = IB_SMINFO_STATE_STANDBY;
+ osm_report_sm_state(sm);
+ /*
+ * Since another SM is doing the LFT config - we should not
+ * ignore the results of it
+ */
+ CL_PLOCK_EXCL_ACQUIRE(sm->p_lock);
+ sm->p_subn->ignore_existing_lfts = FALSE;
+ CL_PLOCK_RELEASE(sm->p_lock);
+ sm_state_mgr_start_polling(sm);
+ break;
+ case OSM_SM_SIGNAL_HANDOVER:
+ /*
+ * Signal for a new sweep. We need to discover the other SM.
+ * If we already discovered this SM, and got the
+ * HANDOVER - this means the remote SM is of lower priority.
+ * In this case we will stop polling it (since it is a lower
+ * priority SM in STANDBY state).
+ */
+ osm_sm_signal(sm, OSM_SIGNAL_SWEEP);
+ break;
+ default:
+ sm_state_mgr_signal_error(sm, signal);
+ status = IB_INVALID_PARAMETER;
+ break;
+ }
+ break;
+
+ case IB_SMINFO_STATE_STANDBY:
+ switch (signal) {
+ case OSM_SM_SIGNAL_POLLING_TIMEOUT:
+ case OSM_SM_SIGNAL_DISCOVER:
+ /*
+ * case 1: Polling timeout occured - this means that the Master SM
+ * is no longer alive.
+ * case 2: Got a signal to move to DISCOVERING
+ * Move to DISCOVERING state and start sweeping
+ */
+ sm->p_subn->sm_state = IB_SMINFO_STATE_DISCOVERING;
+ osm_report_sm_state(sm);
+ CL_PLOCK_EXCL_ACQUIRE(sm->p_lock);
+ sm->p_subn->coming_out_of_standby = TRUE;
+ CL_PLOCK_RELEASE(sm->p_lock);
+ osm_sm_signal(sm, OSM_SIGNAL_SWEEP);
+ break;
+ case OSM_SM_SIGNAL_DISABLE:
+ /*
+ * Update the state to NOT_ACTIVE
+ */
+ sm->p_subn->sm_state = IB_SMINFO_STATE_NOTACTIVE;
+ osm_report_sm_state(sm);
+ break;
+ case OSM_SM_SIGNAL_HANDOVER:
+ /*
+ * Update the state to MASTER, and start sweeping
+ * OPTIONAL: send ACKNOWLEDGE
+ */
+ /* Turn on the force_first_time_master_sweep flag */
+ /* We want full reconfiguration to occur on the first */
+ /* master sweep of this SM */
+ CL_PLOCK_EXCL_ACQUIRE(sm->p_lock);
+ /*
+ * Make sure to set the subnet master_sm_base_lid
+ * to the sm_base_lid value
+ */
+ sm->p_subn->master_sm_base_lid =
+ sm->p_subn->sm_base_lid;
+
+ sm->p_subn->force_first_time_master_sweep = TRUE;
+ CL_PLOCK_RELEASE(sm->p_lock);
+
+ sm->p_subn->sm_state = IB_SMINFO_STATE_MASTER;
+ osm_report_sm_state(sm);
+ osm_sm_signal(sm, OSM_SIGNAL_SWEEP);
+ break;
+ case OSM_SM_SIGNAL_ACKNOWLEDGE:
+ /*
+ * Do nothing - already moved to STANDBY
+ */
+ break;
+ default:
+ sm_state_mgr_signal_error(sm, signal);
+ status = IB_INVALID_PARAMETER;
+ break;
+ }
+ break;
+
+ case IB_SMINFO_STATE_NOTACTIVE:
+ switch (signal) {
+ case OSM_SM_SIGNAL_STANDBY:
+ /*
+ * Update the state to STANDBY
+ * start the polling
+ */
+ sm->p_subn->sm_state = IB_SMINFO_STATE_STANDBY;
+ osm_report_sm_state(sm);
+ sm_state_mgr_start_polling(sm);
+ break;
+ default:
+ sm_state_mgr_signal_error(sm, signal);
+ status = IB_INVALID_PARAMETER;
+ break;
+ }
+ break;
+
+ case IB_SMINFO_STATE_MASTER:
+ switch (signal) {
+ case OSM_SM_SIGNAL_POLLING_TIMEOUT:
+ /*
+ * We received a polling timeout - this means that we
+ * waited for a remote master sm to send us a handover,
+ * but didn't get it, and didn't get a response from
+ * that remote sm.
+ * We want to force a heavy sweep - hopefully this
+ * occurred because the remote sm died, and we'll find
+ * this out and configure the subnet after a heavy sweep.
+ * We also want to clear the polling_sm_guid - since
+ * we are done polling on that remote sm - we are
+ * sweeping again.
+ */
+ case OSM_SM_SIGNAL_HANDOVER:
+ /*
+ * If we received a handover in a master state - then we
+ * want to force a heavy sweep. This means that either
+ * we are in a sweep currently - in this case - no
+ * change, or we are in idle state - since we
+ * recognized a master SM before - so we want to make a
+ * heavy sweep and reconfigure the new subnet.
+ * We also want to clear the polling_sm_guid - since
+ * we are done polling on that remote sm - we got a
+ * handover from it.
+ */
+ OSM_LOG(sm->p_log, OSM_LOG_VERBOSE,
+ "Forcing heavy sweep. Received signal %s\n",
+ osm_get_sm_mgr_signal_str(signal));
+ CL_PLOCK_EXCL_ACQUIRE(sm->p_lock);
+ sm->polling_sm_guid = 0;
+ sm->p_subn->force_first_time_master_sweep = TRUE;
+ CL_PLOCK_RELEASE(sm->p_lock);
+ osm_sm_signal(sm, OSM_SIGNAL_SWEEP);
+ break;
+ case OSM_SM_SIGNAL_HANDOVER_SENT:
+ /*
+ * Just sent a HANDOVER signal - move to STANDBY
+ * start the polling
+ */
+ sm->p_subn->sm_state = IB_SMINFO_STATE_STANDBY;
+ osm_report_sm_state(sm);
+ sm_state_mgr_start_polling(sm);
+ break;
+ case OSM_SM_SIGNAL_WAIT_FOR_HANDOVER:
+ /*
+ * We found a remote master SM, and we are waiting for
+ * it to handover the mastership to us. Need to start
+ * polling that SM, to make sure it is alive, if it
+ * isn't - then we should move back to discovering,
+ * since something must have happened to it.
+ */
+ sm_state_mgr_start_polling(sm);
+ break;
+ case OSM_SM_SIGNAL_DISCOVER:
+ sm->p_subn->sm_state = IB_SMINFO_STATE_DISCOVERING;
+ osm_report_sm_state(sm);
+ break;
+ default:
+ sm_state_mgr_signal_error(sm, signal);
+ status = IB_INVALID_PARAMETER;
+ break;
+ }
+ break;
+
+ default:
+ OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR 3208: "
+ "Invalid state %s\n",
+ osm_get_sm_mgr_state_str(sm->p_subn->sm_state));
+
+ }
+
+ cl_spinlock_release(&sm->state_lock);
+
+ OSM_LOG_EXIT(sm->p_log);
+ return status;
+}
+
+ib_api_status_t osm_sm_state_mgr_check_legality(osm_sm_t * sm,
+ IN osm_sm_signal_t signal)
+{
+ ib_api_status_t status = IB_SUCCESS;
+
+ CL_ASSERT(sm);
+
+ OSM_LOG_ENTER(sm->p_log);
+
+ /*
+ * The state lock prevents many race conditions from screwing
+ * up the state transition process.
+ */
+ cl_spinlock_acquire(&sm->state_lock);
+
+ OSM_LOG(sm->p_log, OSM_LOG_DEBUG, "Received signal %s in state %s\n",
+ osm_get_sm_mgr_signal_str(signal),
+ osm_get_sm_mgr_state_str(sm->p_subn->sm_state));
+
+ switch (sm->p_subn->sm_state) {
+ case IB_SMINFO_STATE_DISCOVERING:
+ switch (signal) {
+ case OSM_SM_SIGNAL_DISCOVERY_COMPLETED:
+ case OSM_SM_SIGNAL_MASTER_OR_HIGHER_SM_DETECTED:
+ case OSM_SM_SIGNAL_HANDOVER:
+ status = IB_SUCCESS;
+ break;
+ default:
+ sm_state_mgr_signal_error(sm, signal);
+ status = IB_INVALID_PARAMETER;
+ break;
+ }
+ break;
+
+ case IB_SMINFO_STATE_STANDBY:
+ switch (signal) {
+ case OSM_SM_SIGNAL_POLLING_TIMEOUT:
+ case OSM_SM_SIGNAL_DISCOVER:
+ case OSM_SM_SIGNAL_DISABLE:
+ case OSM_SM_SIGNAL_HANDOVER:
+ case OSM_SM_SIGNAL_ACKNOWLEDGE:
+ status = IB_SUCCESS;
+ break;
+ default:
+ sm_state_mgr_signal_error(sm, signal);
+ status = IB_INVALID_PARAMETER;
+ break;
+ }
+ break;
+
+ case IB_SMINFO_STATE_NOTACTIVE:
+ switch (signal) {
+ case OSM_SM_SIGNAL_STANDBY:
+ status = IB_SUCCESS;
+ break;
+ default:
+ sm_state_mgr_signal_error(sm, signal);
+ status = IB_INVALID_PARAMETER;
+ break;
+ }
+ break;
+
+ case IB_SMINFO_STATE_MASTER:
+ switch (signal) {
+ case OSM_SM_SIGNAL_HANDOVER:
+ case OSM_SM_SIGNAL_HANDOVER_SENT:
+ status = IB_SUCCESS;
+ break;
+ default:
+ sm_state_mgr_signal_error(sm, signal);
+ status = IB_INVALID_PARAMETER;
+ break;
+ }
+ break;
+
+ default:
+ OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR 3209: "
+ "Invalid state %s\n",
+ osm_get_sm_mgr_state_str(sm->p_subn->sm_state));
+ status = IB_INVALID_PARAMETER;
+
+ }
+
+ cl_spinlock_release(&sm->state_lock);
+
+ OSM_LOG_EXIT(sm->p_log);
+ return status;
+}
diff --git a/contrib/ofed/opensm/opensm/osm_sminfo_rcv.c b/contrib/ofed/opensm/opensm/osm_sminfo_rcv.c
new file mode 100644
index 0000000..2a1f10e
--- /dev/null
+++ b/contrib/ofed/opensm/opensm/osm_sminfo_rcv.c
@@ -0,0 +1,657 @@
+/*
+ * Copyright (c) 2004-2009 Voltaire, Inc. All rights reserved.
+ * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved.
+ * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
+ * Copyright (c) 2013 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+/*
+ * Abstract:
+ * Implementation of osm_sminfo_rcv_t.
+ * This object represents the SMInfo Receiver object.
+ * This object is part of the opensm family of objects.
+ */
+
+#if HAVE_CONFIG_H
+# include <config.h>
+#endif /* HAVE_CONFIG_H */
+
+#include <stdlib.h>
+#include <string.h>
+#include <iba/ib_types.h>
+#include <complib/cl_qmap.h>
+#include <complib/cl_passivelock.h>
+#include <complib/cl_debug.h>
+#include <opensm/osm_file_ids.h>
+#define FILE_ID OSM_FILE_SMINFO_RCV_C
+#include <opensm/osm_madw.h>
+#include <opensm/osm_log.h>
+#include <opensm/osm_node.h>
+#include <opensm/osm_helper.h>
+#include <opensm/osm_subnet.h>
+#include <opensm/osm_sm.h>
+#include <opensm/osm_opensm.h>
+
+/**********************************************************************
+ Return TRUE if the remote sm given (by ib_sm_info_t) is higher,
+ return FALSE otherwise.
+ By higher - we mean: SM with higher priority or with same priority
+ and lower GUID.
+**********************************************************************/
+static boolean_t smi_rcv_remote_sm_is_higher(IN osm_sm_t * sm,
+ IN const ib_sm_info_t * p_rem_smi)
+{
+ return osm_sm_is_greater_than(ib_sminfo_get_priority(p_rem_smi),
+ p_rem_smi->guid,
+ sm->p_subn->opt.sm_priority,
+ sm->p_subn->sm_port_guid);
+
+}
+
+static void smi_rcv_process_get_request(IN osm_sm_t * sm,
+ IN const osm_madw_t * p_madw,
+ IN boolean_t fill_sm_key)
+{
+ uint8_t payload[IB_SMP_DATA_SIZE];
+ ib_sm_info_t *p_smi = (ib_sm_info_t *) payload;
+ ib_api_status_t status;
+
+ OSM_LOG_ENTER(sm->p_log);
+
+ CL_ASSERT(p_madw);
+
+ /* No real need to grab the lock for this function. */
+ memset(payload, 0, sizeof(payload));
+
+ CL_ASSERT(osm_madw_get_smp_ptr(p_madw)->method == IB_MAD_METHOD_GET);
+
+ p_smi->guid = sm->p_subn->sm_port_guid;
+ p_smi->act_count = cl_hton32(sm->p_subn->p_osm->stats.qp0_mads_sent);
+ p_smi->pri_state = (uint8_t) (sm->p_subn->sm_state |
+ sm->p_subn->opt.sm_priority << 4);
+ p_smi->sm_key = fill_sm_key ? sm->p_subn->opt.sm_key : 0;
+
+ status = osm_resp_send(sm, p_madw, 0, payload);
+ if (status != IB_SUCCESS) {
+ OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR 2F02: "
+ "Error sending SMInfo response (%s)\n",
+ ib_get_err_str(status));
+ goto Exit;
+ }
+
+Exit:
+ OSM_LOG_EXIT(sm->p_log);
+}
+
+/**********************************************************************
+ * Check if the p_smp received is legal.
+ * Current checks:
+ * MADHeader:AttributeModifier of ACKNOWLEDGE that was not sent by a
+ * Standby SM.
+ * MADHeader:AttributeModifiers of HANDOVER/DISABLE/STANDBY/DISCOVER
+ * that was not sent by a Master SM.
+ * FUTURE - TO DO:
+ * Check that the SM_Key matches.
+ **********************************************************************/
+static ib_api_status_t smi_rcv_check_set_req_legality(IN const ib_smp_t * p_smp)
+{
+ ib_sm_info_t *p_smi;
+
+ p_smi = ib_smp_get_payload_ptr(p_smp);
+
+ if (p_smp->attr_mod == IB_SMINFO_ATTR_MOD_ACKNOWLEDGE) {
+ if (ib_sminfo_get_state(p_smi) == IB_SMINFO_STATE_STANDBY)
+ return IB_SUCCESS;
+ } else if (p_smp->attr_mod == IB_SMINFO_ATTR_MOD_HANDOVER ||
+ p_smp->attr_mod == IB_SMINFO_ATTR_MOD_DISABLE ||
+ p_smp->attr_mod == IB_SMINFO_ATTR_MOD_STANDBY ||
+ p_smp->attr_mod == IB_SMINFO_ATTR_MOD_DISCOVER) {
+ if (ib_sminfo_get_state(p_smi) == IB_SMINFO_STATE_MASTER)
+ return IB_SUCCESS;
+ }
+
+ return IB_INVALID_PARAMETER;
+}
+
+static void smi_rcv_process_set_request(IN osm_sm_t * sm,
+ IN const osm_madw_t * p_madw)
+{
+ uint8_t payload[IB_SMP_DATA_SIZE];
+ ib_smp_t *p_smp;
+ ib_sm_info_t *p_smi = (ib_sm_info_t *) payload;
+ ib_sm_info_t *sm_smi;
+ ib_api_status_t status;
+ osm_sm_signal_t sm_signal;
+
+ OSM_LOG_ENTER(sm->p_log);
+
+ CL_ASSERT(p_madw);
+
+ memset(payload, 0, sizeof(payload));
+
+ p_smp = osm_madw_get_smp_ptr(p_madw);
+ sm_smi = ib_smp_get_payload_ptr(p_smp);
+
+ if (p_smp->method != IB_MAD_METHOD_SET) {
+ OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR 2F03: "
+ "Unsupported set method 0x%X\n", p_smp->method);
+ goto Exit;
+ }
+
+ CL_PLOCK_ACQUIRE(sm->p_lock);
+
+ p_smi->guid = sm->p_subn->sm_port_guid;
+ p_smi->act_count = cl_hton32(sm->p_subn->p_osm->stats.qp0_mads_sent);
+ p_smi->pri_state = (uint8_t) (sm->p_subn->sm_state |
+ sm->p_subn->opt.sm_priority << 4);
+ p_smi->sm_key = sm->p_subn->opt.sm_key;
+
+ /* Check the legality of the packet */
+ status = smi_rcv_check_set_req_legality(p_smp);
+ if (status != IB_SUCCESS) {
+ OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR 2F04: "
+ "Check legality failed. AttributeModifier:0x%X RemoteState:%s\n",
+ p_smp->attr_mod,
+ osm_get_sm_mgr_state_str(ib_sminfo_get_state(sm_smi)));
+ status = osm_resp_send(sm, p_madw, 7, payload);
+ if (status != IB_SUCCESS)
+ OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR 2F05: "
+ "Error sending SMInfo response (%s)\n",
+ ib_get_err_str(status));
+ CL_PLOCK_RELEASE(sm->p_lock);
+ goto Exit;
+ }
+
+ /* translate from IB_SMINFO_ATTR to OSM_SM_SIGNAL */
+ switch (p_smp->attr_mod) {
+ case IB_SMINFO_ATTR_MOD_HANDOVER:
+ sm_signal = OSM_SM_SIGNAL_HANDOVER;
+ break;
+ case IB_SMINFO_ATTR_MOD_ACKNOWLEDGE:
+ sm_signal = OSM_SM_SIGNAL_ACKNOWLEDGE;
+ break;
+ case IB_SMINFO_ATTR_MOD_DISABLE:
+ sm_signal = OSM_SM_SIGNAL_DISABLE;
+ break;
+ case IB_SMINFO_ATTR_MOD_STANDBY:
+ sm_signal = OSM_SM_SIGNAL_STANDBY;
+ break;
+ case IB_SMINFO_ATTR_MOD_DISCOVER:
+ sm_signal = OSM_SM_SIGNAL_DISCOVER;
+ break;
+ default:
+ /*
+ This code shouldn't be reached - checked in the
+ check legality
+ */
+ OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR 2F06: "
+ "THIS CODE SHOULD NOT BE REACHED!!\n");
+ CL_PLOCK_RELEASE(sm->p_lock);
+ goto Exit;
+ }
+
+ CL_PLOCK_RELEASE(sm->p_lock);
+
+ /* check legality of the needed transition in the SM state machine */
+ status = osm_sm_state_mgr_check_legality(sm, sm_signal);
+ if (status != IB_SUCCESS) {
+ OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR 2F07: "
+ "Failed check of legality of needed SM transition. "
+ "AttributeModifier:0x%X RemoteState:%s\n",
+ p_smp->attr_mod,
+ osm_get_sm_mgr_state_str(ib_sminfo_get_state(sm_smi)));
+ status = osm_resp_send(sm, p_madw, 7, payload);
+ if (status != IB_SUCCESS)
+ OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR 2F08: "
+ "Error sending SMInfo response (%s)\n",
+ ib_get_err_str(status));
+ goto Exit;
+ }
+
+ /* the SubnSet(SMInfo) command is ok. Send a response. */
+ status = osm_resp_send(sm, p_madw, 0, payload);
+ if (status != IB_SUCCESS)
+ OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR 2F09: "
+ "Error sending SMInfo response (%s)\n",
+ ib_get_err_str(status));
+
+ /* it is a legal packet - act according to it */
+
+ /* if the AttributeModifier is STANDBY - need to save on the sm in */
+ /* the master_sm_guid variable - the guid of the current master. */
+ if (p_smp->attr_mod == IB_SMINFO_ATTR_MOD_STANDBY) {
+ OSM_LOG(sm->p_log, OSM_LOG_VERBOSE,
+ "Received a STANDBY signal. Updating "
+ "sm_state_mgr master_guid: 0x%016" PRIx64 "\n",
+ cl_ntoh64(sm_smi->guid));
+ CL_PLOCK_EXCL_ACQUIRE(sm->p_lock);
+ sm->master_sm_guid = sm_smi->guid;
+ CL_PLOCK_RELEASE(sm->p_lock);
+ }
+
+ status = osm_sm_state_mgr_process(sm, sm_signal);
+
+ if (status != IB_SUCCESS)
+ OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR 2F10: "
+ "Error in SM state transition (%s)\n",
+ ib_get_err_str(status));
+
+Exit:
+ OSM_LOG_EXIT(sm->p_log);
+}
+
+static void smi_rcv_process_get_sm(IN osm_sm_t * sm,
+ IN const osm_remote_sm_t * p_sm,
+ boolean_t light_sweep)
+{
+ const ib_sm_info_t *p_smi;
+
+ OSM_LOG_ENTER(sm->p_log);
+
+ p_smi = &p_sm->smi;
+
+ OSM_LOG(sm->p_log, OSM_LOG_VERBOSE,
+ "Detected SM 0x%016" PRIx64 " in state %u (%s)\n",
+ cl_ntoh64(p_smi->guid), ib_sminfo_get_state(p_smi),
+ osm_get_sm_mgr_state_str(ib_sminfo_get_state(p_smi)));
+
+ /* Check the state of this SM vs. our own. */
+ switch (sm->p_subn->sm_state) {
+ case IB_SMINFO_STATE_NOTACTIVE:
+ break;
+
+ case IB_SMINFO_STATE_DISCOVERING:
+ switch (ib_sminfo_get_state(p_smi)) {
+ case IB_SMINFO_STATE_NOTACTIVE:
+ break;
+ case IB_SMINFO_STATE_MASTER:
+ sm->master_sm_found = 1;
+ /* save on the sm the guid of the current master. */
+ OSM_LOG(sm->p_log, OSM_LOG_VERBOSE,
+ "Found master SM. Updating sm_state_mgr master_guid: 0x%016"
+ PRIx64 "\n", cl_ntoh64(p_smi->guid));
+ sm->master_sm_guid = p_smi->guid;
+ break;
+ case IB_SMINFO_STATE_DISCOVERING:
+ case IB_SMINFO_STATE_STANDBY:
+ if (smi_rcv_remote_sm_is_higher(sm, p_smi)) {
+ /* the remote is a higher sm - need to stop sweeping */
+ sm->master_sm_found = 1;
+ /* save on the sm the guid of the higher SM we found - */
+ /* we will poll it - as long as it lives - we should be in Standby. */
+ OSM_LOG(sm->p_log, OSM_LOG_VERBOSE,
+ "Found higher SM. Updating sm_state_mgr master_guid:"
+ " 0x%016" PRIx64 "\n",
+ cl_ntoh64(p_smi->guid));
+ sm->master_sm_guid = p_smi->guid;
+ }
+ break;
+ default:
+ break;
+ }
+ break;
+
+ case IB_SMINFO_STATE_STANDBY:
+ /* if the guid of the SM that sent us this response is equal to the */
+ /* p_sm_mgr->master_guid - then this is a signal that the polling */
+ switch (ib_sminfo_get_state(p_smi)) {
+ case IB_SMINFO_STATE_MASTER:
+ /* This means the master is alive */
+ /* Signal that to the SM state mgr */
+ osm_sm_state_mgr_signal_master_is_alive(sm);
+
+ if (!smi_rcv_remote_sm_is_higher(sm, p_smi))
+ osm_send_trap144(sm,
+ TRAP_144_MASK_SM_PRIORITY_CHANGE);
+ break;
+ case IB_SMINFO_STATE_STANDBY:
+ /* This should be the response from the sm we are polling. */
+ /* If it is - then signal master is alive */
+ if (sm->master_sm_guid == p_sm->smi.guid) {
+ /* Make sure that it is an SM with higher priority than us.
+ If we started polling it when it was master, and it moved
+ to standby - then it might be with a lower priority than
+ us - and then we don't want to continue polling it. */
+ if (smi_rcv_remote_sm_is_higher(sm, p_smi))
+ osm_sm_state_mgr_signal_master_is_alive
+ (sm);
+ }
+ break;
+ default:
+ /* any other state - do nothing */
+ break;
+ }
+ break;
+
+ case IB_SMINFO_STATE_MASTER:
+ switch (ib_sminfo_get_state(p_smi)) {
+ case IB_SMINFO_STATE_MASTER:
+ /* If this is a response due to our polling, this means that we are
+ * waiting for a handover from this SM, and it is still alive -
+ * signal that. If we detected the remote SM with higher priority
+ * we should init a heavy sweep in order to go STANDBY. If we
+ * detected a remote SM with lower priority, we should resend trap144
+ * as it might not get it and we don't want to wait for a HANDOVER
+ * forever.
+ */
+ if (sm->polling_sm_guid) {
+ if (smi_rcv_remote_sm_is_higher(sm, p_smi))
+ sm->p_subn->force_heavy_sweep = TRUE;
+ else {
+ /* Update master_sm_guid to the GUID of the newly
+ * found MASTER SM and send trap 144 to it.
+ */
+ sm->master_sm_guid = sm->polling_sm_guid;
+ osm_send_trap144(sm, TRAP_144_MASK_SM_PRIORITY_CHANGE);
+ }
+ osm_sm_state_mgr_signal_master_is_alive(sm);
+ } else {
+ /* This is a response we got while sweeping the subnet.
+ *
+ * If this is during a heavy sweep, we will handle a case of
+ * handover needed later on, when the sweep is done and all
+ * SMs are recognized.
+ *
+ * If this is during a light sweep, initiate a heavy sweep
+ * to initiate handover scenarios.
+ *
+ * Note that it does not matter if the remote SM is lower
+ * or higher priority. If it is lower priority, we must
+ * wait for it HANDOVER. If it is higher priority, we need
+ * to HANDOVER to it. Both cases are handled after doing
+ * a heavy sweep.
+ */
+ if (light_sweep)
+ sm->p_subn->force_heavy_sweep = TRUE;
+ }
+ break;
+ case IB_SMINFO_STATE_STANDBY:
+ if (light_sweep &&
+ smi_rcv_remote_sm_is_higher(sm, p_smi))
+ sm->p_subn->force_heavy_sweep = TRUE;
+ break;
+ default:
+ /* any other state - do nothing */
+ break;
+ }
+ break;
+
+ default:
+ break;
+ }
+
+ OSM_LOG_EXIT(sm->p_log);
+}
+
+static void smi_rcv_process_get_response(IN osm_sm_t * sm,
+ IN const osm_madw_t * p_madw)
+{
+ const ib_smp_t *p_smp;
+ const ib_sm_info_t *p_smi;
+ cl_qmap_t *p_sm_tbl;
+ osm_port_t *p_port;
+ ib_net64_t port_guid;
+ osm_remote_sm_t *p_sm;
+ char buf[256];
+
+ OSM_LOG_ENTER(sm->p_log);
+
+ CL_ASSERT(p_madw);
+
+ p_smp = osm_madw_get_smp_ptr(p_madw);
+
+ if (p_smp->method != IB_MAD_METHOD_GET_RESP) {
+ OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR 2F11: "
+ "Unsupported response method 0x%X\n", p_smp->method);
+ goto Exit;
+ }
+
+ p_smi = ib_smp_get_payload_ptr(p_smp);
+ p_sm_tbl = &sm->p_subn->sm_guid_tbl;
+ port_guid = p_smi->guid;
+
+ osm_dump_sm_info_v2(sm->p_log, p_smi, FILE_ID, OSM_LOG_DEBUG);
+
+ /* Check that the sm_key of the found SM is the same as ours,
+ or is zero. If not - OpenSM should ignore this SM */
+ if (sm->p_subn->opt.sm_key != 0 && p_smi->sm_key != sm->p_subn->opt.sm_key) {
+ if (p_smp->mgmt_class == IB_MCLASS_SUBN_DIR)
+ sprint_uint8_arr(buf, sizeof(buf),
+ p_smp->initial_path, p_smp->hop_count + 1);
+ else
+ sprintf(buf, "LID %u",
+ cl_ntoh16(p_madw->mad_addr.addr_type.smi.source_lid));
+ OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR 2F18: "
+ "Got SM (%s) with sm_key 0x%016" PRIx64 " that doesn't match our "
+ "local sm_key. Ignoring SMInfo\n", buf, cl_ntoh64(p_smi->sm_key));
+ osm_log_v2(sm->p_log, OSM_LOG_SYS, FILE_ID,
+ "Found remote SM (%s) with non-matching sm_key\n", buf);
+ goto Exit;
+ }
+
+ /* Determine if we already have another SM object for this SM. */
+ CL_PLOCK_EXCL_ACQUIRE(sm->p_lock);
+
+ p_port = osm_get_port_by_guid(sm->p_subn, port_guid);
+ if (!p_port) {
+ OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR 2F12: "
+ "No port object for this SM\n");
+ goto _unlock_and_exit;
+ }
+
+ if (osm_port_get_guid(p_port) != p_smi->guid) {
+ OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR 2F13: "
+ "Bogus SM port GUID, Expected 0x%016" PRIx64
+ ", Received 0x%016" PRIx64 "\n",
+ cl_ntoh64(osm_port_get_guid(p_port)),
+ cl_ntoh64(p_smi->guid));
+ goto _unlock_and_exit;
+ }
+
+ if (port_guid == sm->p_subn->sm_port_guid) {
+ OSM_LOG(sm->p_log, OSM_LOG_VERBOSE,
+ "Self query response received - SM port 0x%016" PRIx64
+ "\n", cl_ntoh64(port_guid));
+ goto _unlock_and_exit;
+ }
+
+ p_sm = (osm_remote_sm_t *) cl_qmap_get(p_sm_tbl, port_guid);
+ if (p_sm == (osm_remote_sm_t *) cl_qmap_end(p_sm_tbl)) {
+ p_sm = malloc(sizeof(*p_sm));
+ if (p_sm == NULL) {
+ OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR 2F14: "
+ "Unable to allocate SM object\n");
+ goto _unlock_and_exit;
+ }
+
+ osm_remote_sm_init(p_sm, p_smi);
+
+ cl_qmap_insert(p_sm_tbl, port_guid, &p_sm->map_item);
+ } else
+ /* We already know this SM. Update the SMInfo attribute. */
+ p_sm->smi = *p_smi;
+
+ smi_rcv_process_get_sm(sm, p_sm,
+ osm_madw_get_smi_context_ptr(p_madw)->
+ light_sweep);
+
+_unlock_and_exit:
+ CL_PLOCK_RELEASE(sm->p_lock);
+
+Exit:
+ OSM_LOG_EXIT(sm->p_log);
+}
+
+static void smi_rcv_process_set_response(IN osm_sm_t * sm,
+ IN const osm_madw_t * p_madw)
+{
+ const ib_smp_t *p_smp;
+ const ib_sm_info_t *p_smi;
+
+ OSM_LOG_ENTER(sm->p_log);
+
+ CL_ASSERT(p_madw);
+
+ p_smp = osm_madw_get_smp_ptr(p_madw);
+ if (ib_smp_get_status(p_smp)) {
+ OSM_LOG(sm->p_log, OSM_LOG_DEBUG,
+ "MAD status 0x%x received\n",
+ cl_ntoh16(ib_smp_get_status(p_smp)));
+ goto Exit;
+ }
+
+ if (p_smp->method != IB_MAD_METHOD_GET_RESP) {
+ OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR 2F16: "
+ "Unsupported response method 0x%X\n", p_smp->method);
+ goto Exit;
+ }
+
+ p_smi = ib_smp_get_payload_ptr(p_smp);
+ osm_dump_sm_info_v2(sm->p_log, p_smi, FILE_ID, OSM_LOG_DEBUG);
+
+ /* Check the AttributeModifier */
+ if (p_smp->attr_mod != IB_SMINFO_ATTR_MOD_HANDOVER) {
+ OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR 2F17: "
+ "Unsupported attribute modifier 0x%X, "
+ "expected ATTR_MOD_HANDOVER\n",
+ p_smp->attr_mod);
+ goto Exit;
+ }
+
+ /* This is a response on a HANDOVER request - Nothing to do. */
+
+Exit:
+ OSM_LOG_EXIT(sm->p_log);
+}
+
+void osm_sminfo_rcv_process(IN void *context, IN void *data)
+{
+ osm_sm_t *sm = context;
+ osm_madw_t *p_madw = data;
+ ib_smp_t *p_smp;
+ osm_smi_context_t *p_smi_context;
+
+ OSM_LOG_ENTER(sm->p_log);
+
+ CL_ASSERT(p_madw);
+
+ p_smp = osm_madw_get_smp_ptr(p_madw);
+ if (ib_smp_get_status(p_smp)) {
+ OSM_LOG(sm->p_log, OSM_LOG_DEBUG,
+ "MAD status 0x%x received\n",
+ cl_ntoh16(ib_smp_get_status(p_smp)));
+ goto Exit;
+ }
+
+ /* Determine if this is a request for our own SMInfo or if
+ this is a response to our request for another SM's SMInfo. */
+ if (ib_smp_is_response(p_smp)) {
+ const ib_sm_info_t *p_smi = ib_smp_get_payload_ptr(p_smp);
+
+ /* Get the context - to see if this is a response to a Get or Set method */
+ p_smi_context = osm_madw_get_smi_context_ptr(p_madw);
+
+ /* Verify that response is from expected port and there is
+ no port moving issue. */
+ if (p_smi_context->port_guid != p_smi->guid) {
+ OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR 2F19: "
+ "Unexpected SM port GUID in response"
+ ", Expected 0x%016" PRIx64
+ ", Received 0x%016" PRIx64 "\n",
+ cl_ntoh64(p_smi_context->port_guid),
+ cl_ntoh64(p_smi->guid));
+ goto Exit;
+ }
+
+ if (p_smi_context->set_method == FALSE)
+ /* this is a response to a Get method */
+ smi_rcv_process_get_response(sm, p_madw);
+ else
+ /* this is a response to a Set method */
+ smi_rcv_process_set_response(sm, p_madw);
+ } else {
+ osm_port_t * p_port;
+ ib_net64_t my_mkey;
+ uint8_t mpb;
+ char buf[256];
+
+ if(!(p_port = osm_get_port_by_guid(sm->p_subn,
+ sm->p_subn->sm_port_guid)))
+ goto Exit;
+
+ if (!p_port->p_physp)
+ goto Exit;
+
+ my_mkey = ib_port_info_get_m_key(&p_port->p_physp->port_info);
+ mpb = my_mkey ? ib_port_info_get_mpb(&p_port->p_physp->port_info) : 0;
+
+ if (p_smp->method == IB_MAD_METHOD_GET) {
+ /* M-Key Authentication */
+ if (my_mkey && mpb > 1 && my_mkey != p_smp->m_key) {
+ if (p_smp->mgmt_class == IB_MCLASS_SUBN_DIR)
+ sprint_uint8_arr(buf, sizeof(buf),
+ p_smp->return_path, p_smp->hop_count + 1);
+ else
+ sprintf(buf, "LID %u",
+ cl_ntoh16(p_madw->mad_addr.addr_type.smi.source_lid));
+ OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR 2F1A: "
+ "SMInfo(GET) sender (%s) authentication failure."
+ "Ignoring SMInfo\n", buf);
+ goto Exit;
+ }
+ /* If protection bits == 1 but MKEY mismatch, return SM-KEY = 0 */
+ if (my_mkey && mpb == 1 && my_mkey != p_smp->m_key)
+ smi_rcv_process_get_request(sm, p_madw, FALSE);
+ else
+ smi_rcv_process_get_request(sm, p_madw, TRUE);
+ } else {
+ /* M-Key Authentication */
+ if (my_mkey && my_mkey != p_smp->m_key) {
+ if (p_smp->mgmt_class == IB_MCLASS_SUBN_DIR)
+ sprint_uint8_arr(buf, sizeof(buf),
+ p_smp->return_path, p_smp->hop_count + 1);
+ else
+ sprintf(buf, "LID %u",
+ cl_ntoh16(p_madw->mad_addr.addr_type.smi.source_lid));
+ OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR 2F1B: "
+ "SMInfo(SET) sender (%s) authentication failure."
+ "Ignoring SMInfo\n", buf);
+ goto Exit;
+ }
+ /* This should be a SubnSet request */
+ smi_rcv_process_set_request(sm, p_madw);
+ }
+ }
+
+Exit:
+ OSM_LOG_EXIT(sm->p_log);
+}
diff --git a/contrib/ofed/opensm/opensm/osm_state_mgr.c b/contrib/ofed/opensm/opensm/osm_state_mgr.c
new file mode 100644
index 0000000..21f11a3
--- /dev/null
+++ b/contrib/ofed/opensm/opensm/osm_state_mgr.c
@@ -0,0 +1,1757 @@
+/*
+ * Copyright (c) 2009 Sun Microsystems, Inc. All rights reserved.
+ * Copyright (c) 2004-2009 Voltaire, Inc. All rights reserved.
+ * Copyright (c) 2002-2015 Mellanox Technologies LTD. All rights reserved.
+ * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
+ * Copyright (c) 2009 HNR Consulting. All rights reserved.
+ * Copyright (c) 2013 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+/*
+ * Abstract:
+ * Implementation of osm_state_mgr_t.
+ * This file implements the State Manager object.
+ */
+
+#if HAVE_CONFIG_H
+# include <config.h>
+#endif /* HAVE_CONFIG_H */
+
+#include <unistd.h>
+#include <stdlib.h>
+#include <string.h>
+#include <iba/ib_types.h>
+#include <complib/cl_passivelock.h>
+#include <complib/cl_debug.h>
+#include <complib/cl_qmap.h>
+#include <opensm/osm_file_ids.h>
+#define FILE_ID OSM_FILE_STATE_MGR_C
+#include <opensm/osm_sm.h>
+#include <opensm/osm_madw.h>
+#include <opensm/osm_switch.h>
+#include <opensm/osm_log.h>
+#include <opensm/osm_subnet.h>
+#include <opensm/osm_helper.h>
+#include <opensm/osm_msgdef.h>
+#include <opensm/osm_node.h>
+#include <opensm/osm_port.h>
+#include <vendor/osm_vendor_api.h>
+#include <opensm/osm_inform.h>
+#include <opensm/osm_opensm.h>
+#include <opensm/osm_congestion_control.h>
+#include <opensm/osm_db.h>
+#include <opensm/osm_service.h>
+#include <opensm/osm_guid.h>
+
+extern void osm_drop_mgr_process(IN osm_sm_t * sm);
+extern int osm_qos_setup(IN osm_opensm_t * p_osm);
+extern int osm_pkey_mgr_process(IN osm_opensm_t * p_osm);
+extern int osm_mcast_mgr_process(IN osm_sm_t * sm, boolean_t config_all);
+extern int osm_link_mgr_process(IN osm_sm_t * sm, IN uint8_t state);
+extern void osm_guid_mgr_process(IN osm_sm_t * sm);
+
+static void state_mgr_up_msg(IN const osm_sm_t * sm)
+{
+ /*
+ * This message should be written only once - when the
+ * SM moves to Master state and the subnet is up for
+ * the first time.
+ */
+ osm_log_v2(sm->p_log, sm->p_subn->first_time_master_sweep ?
+ OSM_LOG_SYS : OSM_LOG_INFO, FILE_ID, "SUBNET UP\n");
+
+ OSM_LOG_MSG_BOX(sm->p_log, OSM_LOG_VERBOSE,
+ sm->p_subn->opt.sweep_interval ?
+ "SUBNET UP" : "SUBNET UP (sweep disabled)");
+}
+
+static void state_mgr_reset_node_count(IN cl_map_item_t * p_map_item,
+ IN void *context)
+{
+ osm_node_t *p_node = (osm_node_t *) p_map_item;
+
+ p_node->discovery_count = 0;
+
+ memset(p_node->physp_discovered, 0, sizeof(uint8_t) * p_node->physp_tbl_size);
+}
+
+static void state_mgr_reset_port_count(IN cl_map_item_t * p_map_item,
+ IN void *context)
+{
+ osm_port_t *p_port = (osm_port_t *) p_map_item;
+
+ p_port->discovery_count = 0;
+}
+
+static void state_mgr_reset_switch_count(IN cl_map_item_t * p_map_item,
+ IN void *context)
+{
+ osm_switch_t *p_sw = (osm_switch_t *) p_map_item;
+
+ if (p_sw->max_lid_ho != 0)
+ p_sw->need_update = 1;
+}
+
+static void state_mgr_get_sw_info(IN cl_map_item_t * p_object, IN void *context)
+{
+ osm_node_t *p_node;
+ osm_physp_t *p_physp;
+ osm_dr_path_t *p_dr_path;
+ osm_madw_context_t mad_context;
+ osm_switch_t *const p_sw = (osm_switch_t *) p_object;
+ osm_sm_t *sm = context;
+ ib_api_status_t status;
+
+ OSM_LOG_ENTER(sm->p_log);
+
+ p_node = p_sw->p_node;
+ p_physp = osm_node_get_physp_ptr(p_node, 0);
+ p_dr_path = osm_physp_get_dr_path_ptr(p_physp);
+
+ memset(&mad_context, 0, sizeof(mad_context));
+
+ mad_context.si_context.node_guid = osm_node_get_node_guid(p_node);
+ mad_context.si_context.set_method = FALSE;
+ mad_context.si_context.light_sweep = TRUE;
+ mad_context.si_context.lft_top_change = FALSE;
+
+ status = osm_req_get(sm, p_dr_path, IB_MAD_ATTR_SWITCH_INFO, 0,
+ FALSE, ib_port_info_get_m_key(&p_physp->port_info),
+ OSM_MSG_LIGHT_SWEEP_FAIL, &mad_context);
+ if (status != IB_SUCCESS)
+ OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR 3304: "
+ "Request for SwitchInfo from 0x%" PRIx64 " failed (%s)\n",
+ cl_ntoh64(osm_node_get_node_guid(p_node)),
+ ib_get_err_str(status));
+
+ OSM_LOG_EXIT(sm->p_log);
+}
+
+/**********************************************************************
+ Initiate a remote port info request for the given physical port
+ **********************************************************************/
+static void state_mgr_get_remote_port_info(IN osm_sm_t * sm,
+ IN osm_physp_t * p_physp)
+{
+ osm_dr_path_t *p_dr_path;
+ osm_dr_path_t rem_node_dr_path;
+ osm_madw_context_t mad_context;
+ ib_api_status_t status;
+
+ OSM_LOG_ENTER(sm->p_log);
+
+ /* generate a dr path leaving on the physp to the remote node */
+ p_dr_path = osm_physp_get_dr_path_ptr(p_physp);
+ memcpy(&rem_node_dr_path, p_dr_path, sizeof(osm_dr_path_t));
+ if (osm_dr_path_extend(&rem_node_dr_path, osm_physp_get_port_num(p_physp))) {
+ OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR 332D: "
+ "DR path with hop count %d couldn't be extended "
+ "so skipping PortInfo query\n",
+ p_dr_path->hop_count);
+ goto Exit;
+ }
+
+ memset(&mad_context, 0, sizeof(mad_context));
+
+ mad_context.pi_context.node_guid =
+ osm_node_get_node_guid(osm_physp_get_node_ptr(p_physp));
+ mad_context.pi_context.port_guid = p_physp->port_guid;
+ mad_context.pi_context.set_method = FALSE;
+ mad_context.pi_context.light_sweep = TRUE;
+ mad_context.pi_context.active_transition = FALSE;
+ mad_context.pi_context.client_rereg = FALSE;
+
+ /* note that with some negative logic - if the query failed it means
+ * that there is no point in going to heavy sweep */
+ status = osm_req_get(sm, &rem_node_dr_path, IB_MAD_ATTR_PORT_INFO, 0,
+ TRUE, 0, CL_DISP_MSGID_NONE, &mad_context);
+ if (status != IB_SUCCESS)
+ OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR 332E: "
+ "Request for remote PortInfo from 0x%" PRIx64 " failed (%s)\n",
+ cl_ntoh64(p_physp->port_guid), ib_get_err_str(status));
+
+Exit:
+ OSM_LOG_EXIT(sm->p_log);
+}
+
+/**********************************************************************
+ Initiates a thorough sweep of the subnet.
+ Used when there is suspicion that something on the subnet has changed.
+**********************************************************************/
+static ib_api_status_t state_mgr_sweep_hop_0(IN osm_sm_t * sm)
+{
+ ib_api_status_t status;
+ osm_dr_path_t dr_path;
+ osm_bind_handle_t h_bind;
+ uint8_t path_array[IB_SUBNET_PATH_HOPS_MAX];
+
+ OSM_LOG_ENTER(sm->p_log);
+
+ memset(path_array, 0, sizeof(path_array));
+
+ /*
+ * First, get the bind handle.
+ */
+ h_bind = osm_sm_mad_ctrl_get_bind_handle(&sm->mad_ctrl);
+ if (h_bind != OSM_BIND_INVALID_HANDLE) {
+ OSM_LOG_MSG_BOX(sm->p_log, OSM_LOG_VERBOSE,
+ "INITIATING HEAVY SWEEP");
+ /*
+ * Start the sweep by clearing the port counts, then
+ * get our own NodeInfo at 0 hops.
+ */
+ CL_PLOCK_ACQUIRE(sm->p_lock);
+
+ cl_qmap_apply_func(&sm->p_subn->node_guid_tbl,
+ state_mgr_reset_node_count, sm);
+
+ cl_qmap_apply_func(&sm->p_subn->port_guid_tbl,
+ state_mgr_reset_port_count, sm);
+
+ cl_qmap_apply_func(&sm->p_subn->sw_guid_tbl,
+ state_mgr_reset_switch_count, sm);
+
+ /* Set the in_sweep_hop_0 flag in subn to be TRUE.
+ * This will indicate the sweeping not to continue beyond the
+ * the current node.
+ * This is relevant for the case of SM on switch, since in the
+ * switch info we need to signal somehow not to continue
+ * the sweeping. */
+ sm->p_subn->in_sweep_hop_0 = TRUE;
+
+ CL_PLOCK_RELEASE(sm->p_lock);
+
+ osm_dr_path_init(&dr_path, 0, path_array);
+ CL_PLOCK_ACQUIRE(sm->p_lock);
+ status = osm_req_get(sm, &dr_path, IB_MAD_ATTR_NODE_INFO, 0,
+ TRUE, 0, CL_DISP_MSGID_NONE, NULL);
+ CL_PLOCK_RELEASE(sm->p_lock);
+ if (status != IB_SUCCESS)
+ OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR 3305: "
+ "Request for NodeInfo failed (%s)\n",
+ ib_get_err_str(status));
+ } else {
+ OSM_LOG(sm->p_log, OSM_LOG_DEBUG,
+ "No bound ports. Deferring sweep...\n");
+ status = IB_INVALID_STATE;
+ }
+
+ OSM_LOG_EXIT(sm->p_log);
+ return status;
+}
+
+/**********************************************************************
+ Clear out all existing port lid assignments
+**********************************************************************/
+static ib_api_status_t state_mgr_clean_known_lids(IN osm_sm_t * sm)
+{
+ ib_api_status_t status = IB_SUCCESS;
+ cl_ptr_vector_t *p_vec = &(sm->p_subn->port_lid_tbl);
+ uint32_t i;
+
+ OSM_LOG_ENTER(sm->p_log);
+
+ /* we need a lock here! */
+ CL_PLOCK_ACQUIRE(sm->p_lock);
+
+ for (i = 0; i < cl_ptr_vector_get_size(p_vec); i++)
+ cl_ptr_vector_set(p_vec, i, NULL);
+
+ CL_PLOCK_RELEASE(sm->p_lock);
+
+ OSM_LOG_EXIT(sm->p_log);
+ return status;
+}
+
+/**********************************************************************
+ Clear SA cache
+**********************************************************************/
+static ib_api_status_t state_mgr_sa_clean(IN osm_sm_t * sm)
+{
+ ib_api_status_t status = IB_SUCCESS;
+ cl_qmap_t *p_port_guid_tbl;
+ osm_assigned_guids_t *p_assigned_guids, *p_next_assigned_guids;
+ osm_alias_guid_t *p_alias_guid, *p_next_alias_guid;
+ osm_mcm_port_t *mcm_port;
+ osm_subn_t * p_subn;
+ osm_port_t *p_port;
+ osm_infr_t *p_infr;
+ osm_svcr_t *p_svcr;
+
+ OSM_LOG_ENTER(sm->p_log);
+
+ p_subn = sm->p_subn;
+
+ /* we need a lock here! */
+ CL_PLOCK_EXCL_ACQUIRE(sm->p_lock);
+
+ if (p_subn->opt.drop_event_subscriptions) {
+ /* Clean InformInfo records */
+ p_infr = (osm_infr_t *) cl_qlist_remove_head(&p_subn->sa_infr_list);
+ while (p_infr !=
+ (osm_infr_t *) cl_qlist_end(&p_subn->sa_infr_list)) {
+ osm_infr_delete(p_infr);
+ p_infr = (osm_infr_t *) cl_qlist_remove_head(&p_subn->sa_infr_list);
+ }
+
+ /* For now, treat Service Records in same category as InformInfos */
+ /* Clean Service records */
+ p_svcr = (osm_svcr_t *) cl_qlist_remove_head(&p_subn->sa_sr_list);
+ while (p_svcr !=
+ (osm_svcr_t *) cl_qlist_end(&p_subn->sa_sr_list)) {
+ osm_svcr_delete(p_svcr);
+ p_svcr = (osm_svcr_t *) cl_qlist_remove_head(&p_subn->sa_sr_list);
+ }
+ }
+
+ /* Clean Multicast member list on each port */
+ p_port_guid_tbl = &p_subn->port_guid_tbl;
+ for (p_port = (osm_port_t *) cl_qmap_head(p_port_guid_tbl);
+ p_port != (osm_port_t *) cl_qmap_end(p_port_guid_tbl);
+ p_port = (osm_port_t *) cl_qmap_next(&p_port->map_item)) {
+ while (!cl_is_qlist_empty(&p_port->mcm_list)) {
+ mcm_port = cl_item_obj(cl_qlist_head(&p_port->mcm_list),
+ mcm_port, list_item);
+ osm_mgrp_delete_port(p_subn, sm->p_log, mcm_port->mgrp,
+ p_port);
+ }
+ /* Hack - clean alias guid table from physp */
+ free(p_port->p_physp->p_guids);
+ p_port->p_physp->p_guids = NULL;
+ }
+
+ /* Clean Alias Guid work objects */
+ while (cl_qlist_count(&p_subn->alias_guid_list))
+ osm_guid_work_obj_delete((osm_guidinfo_work_obj_t *)
+ cl_qlist_remove_head(&p_subn->alias_guid_list));
+
+ /* Clean Assigned GUIDs table */
+ p_next_assigned_guids = (osm_assigned_guids_t *)
+ cl_qmap_head(&p_subn->assigned_guids_tbl);
+ while (p_next_assigned_guids !=
+ (osm_assigned_guids_t *) cl_qmap_end(&p_subn->assigned_guids_tbl)) {
+ p_assigned_guids = p_next_assigned_guids;
+ p_next_assigned_guids = (osm_assigned_guids_t *)
+ cl_qmap_next(&p_assigned_guids->map_item);
+ cl_qmap_remove_item(&p_subn->assigned_guids_tbl,
+ &p_assigned_guids->map_item);
+ osm_assigned_guids_delete(&p_assigned_guids);
+ }
+
+ /* Clean Alias GUIDs table */
+ p_next_alias_guid = (osm_alias_guid_t *)
+ cl_qmap_head(&p_subn->alias_port_guid_tbl);
+ while (p_next_alias_guid !=
+ (osm_alias_guid_t *) cl_qmap_end(&p_subn->alias_port_guid_tbl)) {
+ p_alias_guid = p_next_alias_guid;
+ p_next_alias_guid = (osm_alias_guid_t *)
+ cl_qmap_next(&p_alias_guid->map_item);
+ if (osm_alias_guid_get_alias_guid(p_alias_guid) !=
+ osm_alias_guid_get_base_guid(p_alias_guid)) {
+ /* Clean if it's not base port GUID */
+ cl_qmap_remove_item(&p_subn->alias_port_guid_tbl,
+ &p_alias_guid->map_item);
+ osm_alias_guid_delete(&p_alias_guid);
+ }
+ }
+
+ p_subn->p_osm->sa.dirty = TRUE;
+
+ CL_PLOCK_RELEASE(sm->p_lock);
+ OSM_LOG_EXIT(sm->p_log);
+ return status;
+}
+
+/**********************************************************************
+ Notifies the transport layer that the local LID has changed,
+ which give it a chance to update address vectors, etc..
+**********************************************************************/
+static ib_api_status_t state_mgr_notify_lid_change(IN osm_sm_t * sm)
+{
+ ib_api_status_t status;
+ osm_bind_handle_t h_bind;
+
+ OSM_LOG_ENTER(sm->p_log);
+
+ /*
+ * First, get the bind handle.
+ */
+ h_bind = osm_sm_mad_ctrl_get_bind_handle(&sm->mad_ctrl);
+ if (h_bind == OSM_BIND_INVALID_HANDLE) {
+ OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR 3306: "
+ "No bound ports\n");
+ status = IB_ERROR;
+ goto Exit;
+ }
+
+ /*
+ * Notify the transport layer that we changed the local LID.
+ */
+ status = osm_vendor_local_lid_change(h_bind);
+ if (status != IB_SUCCESS)
+ OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR 3307: "
+ "Vendor LID update failed (%s)\n",
+ ib_get_err_str(status));
+
+Exit:
+ OSM_LOG_EXIT(sm->p_log);
+ return status;
+}
+
+/**********************************************************************
+ Returns true if the SM port is down.
+ The SM's port object must exist in the port_guid table.
+**********************************************************************/
+static boolean_t state_mgr_is_sm_port_down(IN osm_sm_t * sm)
+{
+ ib_net64_t port_guid;
+ osm_port_t *p_port;
+ osm_physp_t *p_physp;
+ uint8_t state;
+
+ OSM_LOG_ENTER(sm->p_log);
+
+ port_guid = sm->p_subn->sm_port_guid;
+
+ /*
+ * If we don't know our own port guid yet, assume the port is down.
+ */
+ if (port_guid == 0) {
+ OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR 3308: "
+ "SM port GUID unknown\n");
+ state = IB_LINK_DOWN;
+ goto Exit;
+ }
+
+ CL_ASSERT(port_guid);
+
+ CL_PLOCK_ACQUIRE(sm->p_lock);
+ p_port = osm_get_port_by_guid(sm->p_subn, port_guid);
+ if (!p_port) {
+ OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR 3309: "
+ "SM port with GUID:%016" PRIx64 " is unknown\n",
+ cl_ntoh64(port_guid));
+ state = IB_LINK_DOWN;
+ CL_PLOCK_RELEASE(sm->p_lock);
+ goto Exit;
+ }
+
+ p_physp = p_port->p_physp;
+
+ CL_ASSERT(p_physp);
+
+ if (p_port->p_node->sw &&
+ !ib_switch_info_is_enhanced_port0(&p_port->p_node->sw->switch_info))
+ state = IB_LINK_ACTIVE; /* base SP0 */
+ else
+ state = osm_physp_get_port_state(p_physp);
+
+ if (!p_port->discovery_count) {
+ OSM_LOG(sm->p_log, OSM_LOG_ERROR,
+ "ERR 330A: Failed to discover SM port\n");
+ state = IB_LINK_DOWN;
+ }
+
+ CL_PLOCK_RELEASE(sm->p_lock);
+
+Exit:
+ OSM_LOG_EXIT(sm->p_log);
+ return (state == IB_LINK_DOWN);
+}
+
+/**********************************************************************
+ Sweeps the node 1 hop away.
+ This sets off a "chain reaction" that causes discovery of the subnet.
+ Used when there is suspicion that something on the subnet has changed.
+**********************************************************************/
+static ib_api_status_t state_mgr_sweep_hop_1(IN osm_sm_t * sm)
+{
+ ib_api_status_t status = IB_SUCCESS;
+ osm_madw_context_t context;
+ osm_node_t *p_node;
+ osm_port_t *p_port;
+ osm_dr_path_t hop_1_path;
+ ib_net64_t port_guid;
+ uint8_t port_num;
+ uint8_t path_array[IB_SUBNET_PATH_HOPS_MAX];
+ uint8_t num_ports;
+ osm_physp_t *p_ext_physp;
+
+ OSM_LOG_ENTER(sm->p_log);
+
+ /*
+ * First, get our own port and node objects.
+ */
+ port_guid = sm->p_subn->sm_port_guid;
+
+ CL_ASSERT(port_guid);
+
+ /* Set the in_sweep_hop_0 flag in subn to be FALSE.
+ * This will indicate the sweeping to continue beyond the
+ * the current node.
+ * This is relevant for the case of SM on switch, since in the
+ * switch info we need to signal that the sweeping should
+ * continue through the switch. */
+ sm->p_subn->in_sweep_hop_0 = FALSE;
+
+ p_port = osm_get_port_by_guid(sm->p_subn, port_guid);
+ if (!p_port) {
+ OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR 3310: "
+ "No SM port object\n");
+ status = IB_ERROR;
+ goto Exit;
+ }
+
+ p_node = p_port->p_node;
+ CL_ASSERT(p_node);
+
+ port_num = ib_node_info_get_local_port_num(&p_node->node_info);
+
+ OSM_LOG(sm->p_log, OSM_LOG_DEBUG,
+ "Probing hop 1 on local port %u\n", port_num);
+
+ memset(path_array, 0, sizeof(path_array));
+ /* the hop_1 operations depend on the type of our node.
+ * Currently - legal nodes that can host SM are SW and CA */
+ switch (osm_node_get_type(p_node)) {
+ case IB_NODE_TYPE_CA:
+ case IB_NODE_TYPE_ROUTER:
+ memset(&context, 0, sizeof(context));
+ context.ni_context.node_guid = osm_node_get_node_guid(p_node);
+ context.ni_context.port_num = port_num;
+
+ path_array[1] = port_num;
+
+ osm_dr_path_init(&hop_1_path, 1, path_array);
+ CL_PLOCK_ACQUIRE(sm->p_lock);
+ status = osm_req_get(sm, &hop_1_path, IB_MAD_ATTR_NODE_INFO, 0,
+ TRUE, 0, CL_DISP_MSGID_NONE, &context);
+ CL_PLOCK_RELEASE(sm->p_lock);
+ if (status != IB_SUCCESS)
+ OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR 3311: "
+ "Request for NodeInfo failed (%s)\n",
+ ib_get_err_str(status));
+ break;
+
+ case IB_NODE_TYPE_SWITCH:
+ /* Need to go over all the ports of the switch, and send a
+ * node_info from them. This doesn't include the port 0 of the
+ * switch, which hosts the SM.
+ * Note: We'll send another switchInfo on port 0, since if no
+ * ports are connected, we still want to get some response, and
+ * have the subnet come up.
+ */
+ num_ports = osm_node_get_num_physp(p_node);
+ for (port_num = 1; port_num < num_ports; port_num++) {
+ /* go through the port only if the port is not DOWN */
+ p_ext_physp = osm_node_get_physp_ptr(p_node, port_num);
+ if (p_ext_physp && ib_port_info_get_port_state
+ (&(p_ext_physp->port_info)) > IB_LINK_DOWN) {
+ memset(&context, 0, sizeof(context));
+ context.ni_context.node_guid =
+ osm_node_get_node_guid(p_node);
+ context.ni_context.port_num = port_num;
+
+ path_array[1] = port_num;
+ osm_dr_path_init(&hop_1_path, 1, path_array);
+ CL_PLOCK_ACQUIRE(sm->p_lock);
+ status = osm_req_get(sm, &hop_1_path,
+ IB_MAD_ATTR_NODE_INFO, 0,
+ TRUE, 0,
+ CL_DISP_MSGID_NONE,
+ &context);
+ CL_PLOCK_RELEASE(sm->p_lock);
+ if (status != IB_SUCCESS)
+ OSM_LOG(sm->p_log, OSM_LOG_ERROR,
+ "ERR 3312: "
+ "Request for NodeInfo failed (%s)\n",
+ ib_get_err_str(status));
+ }
+ }
+ break;
+
+ default:
+ OSM_LOG(sm->p_log, OSM_LOG_ERROR,
+ "ERR 3313: Unknown node type %d (%s)\n",
+ osm_node_get_type(p_node), p_node->print_desc);
+ }
+
+Exit:
+ OSM_LOG_EXIT(sm->p_log);
+ return status;
+}
+
+static void query_sm_info(cl_map_item_t * item, void *cxt)
+{
+ osm_madw_context_t context;
+ osm_remote_sm_t *r_sm = cl_item_obj(item, r_sm, map_item);
+ osm_sm_t *sm = cxt;
+ ib_api_status_t ret;
+ osm_port_t *p_port;
+
+ p_port= osm_get_port_by_guid(sm->p_subn, r_sm->smi.guid);
+ if (p_port == NULL) {
+ OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR 3340: "
+ "No port object on given sm object\n");
+ return;
+ }
+
+ context.smi_context.port_guid = r_sm->smi.guid;
+ context.smi_context.set_method = FALSE;
+ context.smi_context.light_sweep = TRUE;
+
+ ret = osm_req_get(sm, osm_physp_get_dr_path_ptr(p_port->p_physp),
+ IB_MAD_ATTR_SM_INFO, 0, FALSE,
+ ib_port_info_get_m_key(&p_port->p_physp->port_info),
+ CL_DISP_MSGID_NONE, &context);
+ if (ret != IB_SUCCESS)
+ OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR 3314: "
+ "Failure requesting SMInfo (%s)\n",
+ ib_get_err_str(ret));
+}
+
+static void state_mgr_reset_state_change_bit(IN cl_map_item_t * obj,
+ IN void *context)
+{
+ osm_madw_context_t mad_context;
+ osm_switch_t *p_sw = (osm_switch_t *) obj;
+ osm_sm_t *sm = context;
+ osm_node_t *p_node;
+ osm_physp_t *p_physp;
+ osm_dr_path_t *p_path;
+ ib_api_status_t status;
+ ib_switch_info_t si;
+
+ OSM_LOG_ENTER(sm->p_log);
+
+ CL_ASSERT(p_sw);
+
+ p_node = p_sw->p_node;
+
+ CL_ASSERT(p_node);
+
+ p_physp = osm_node_get_physp_ptr(p_node, 0);
+ p_path = osm_physp_get_dr_path_ptr(p_physp);
+
+ if (!ib_switch_info_get_state_change(&p_sw->switch_info))
+ goto exit;
+
+ si = p_sw->switch_info;
+
+ ib_switch_info_state_change_set(&si);
+
+ OSM_LOG(sm->p_log, OSM_LOG_DEBUG,
+ "Resetting PortStateChange on switch GUID 0x%016" PRIx64 "\n",
+ cl_ntoh64(osm_node_get_node_guid(p_node)));
+
+ mad_context.si_context.light_sweep = FALSE;
+ mad_context.si_context.node_guid = osm_node_get_node_guid(p_node);
+ mad_context.si_context.set_method = TRUE;
+ mad_context.si_context.lft_top_change = FALSE;
+
+ status = osm_req_set(sm, p_path, (uint8_t *) &si,
+ sizeof(si), IB_MAD_ATTR_SWITCH_INFO,
+ 0, FALSE,
+ ib_port_info_get_m_key(&p_physp->port_info),
+ CL_DISP_MSGID_NONE, &mad_context);
+
+ if (status != IB_SUCCESS)
+ OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR 332A: "
+ "Sending SwitchInfo attribute failed (%s)\n",
+ ib_get_err_str(status));
+
+exit:
+ OSM_LOG_EXIT(sm->p_log);
+}
+
+static void state_mgr_update_node_desc(IN cl_map_item_t * obj, IN void *context)
+{
+ osm_madw_context_t mad_context;
+ osm_node_t *p_node = (osm_node_t *) obj;
+ osm_sm_t *sm = context;
+ osm_physp_t *p_physp = NULL;
+ unsigned i, num_ports;
+ ib_api_status_t status;
+
+ OSM_LOG_ENTER(sm->p_log);
+
+ CL_ASSERT(p_node);
+
+ OSM_LOG(sm->p_log, OSM_LOG_DEBUG,
+ "Updating NodeDesc for 0x%016" PRIx64 "\n",
+ cl_ntoh64(osm_node_get_node_guid(p_node)));
+
+ /* get a physp to request from. */
+ num_ports = osm_node_get_num_physp(p_node);
+ for (i = 0; i < num_ports; i++)
+ if ((p_physp = osm_node_get_physp_ptr(p_node, i)))
+ break;
+
+ if (!p_physp) {
+ OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR 331C: "
+ "Failed to find any valid physical port object.\n");
+ goto exit;
+ }
+
+ mad_context.nd_context.node_guid = osm_node_get_node_guid(p_node);
+
+ status = osm_req_get(sm, osm_physp_get_dr_path_ptr(p_physp),
+ IB_MAD_ATTR_NODE_DESC, 0, FALSE,
+ ib_port_info_get_m_key(&p_physp->port_info),
+ CL_DISP_MSGID_NONE, &mad_context);
+ if (status != IB_SUCCESS)
+ OSM_LOG(sm->p_log, OSM_LOG_ERROR,
+ "ERR 331B: Failure initiating NodeDescription request "
+ "(%s) to 0x%016" PRIx64 "\n", ib_get_err_str(status),
+ cl_ntoh64(osm_node_get_node_guid(p_node)));
+
+exit:
+ OSM_LOG_EXIT(sm->p_log);
+}
+
+void osm_reset_switch_state_change_bit(IN osm_opensm_t *osm)
+{
+ CL_PLOCK_ACQUIRE(&osm->lock);
+ cl_qmap_apply_func(&osm->subn.sw_guid_tbl, state_mgr_reset_state_change_bit,
+ &osm->sm);
+ CL_PLOCK_RELEASE(&osm->lock);
+}
+
+void osm_update_node_desc(IN osm_opensm_t *osm)
+{
+ CL_PLOCK_ACQUIRE(&osm->lock);
+ cl_qmap_apply_func(&osm->subn.node_guid_tbl, state_mgr_update_node_desc,
+ &osm->sm);
+ CL_PLOCK_RELEASE(&osm->lock);
+}
+
+/**********************************************************************
+ During a light sweep, check each node to see if the node description
+ is valid and if not issue a ND query.
+**********************************************************************/
+static void state_mgr_get_node_desc(IN cl_map_item_t * obj, IN void *context)
+{
+ osm_node_t *p_node = (osm_node_t *) obj;
+ osm_sm_t *sm = context;
+
+ OSM_LOG_ENTER(sm->p_log);
+
+ CL_ASSERT(p_node);
+
+ if (p_node->print_desc
+ && strcmp(p_node->print_desc, OSM_NODE_DESC_UNKNOWN))
+ /* if ND is valid, do nothing */
+ goto exit;
+
+ OSM_LOG(sm->p_log, OSM_LOG_ERROR,
+ "ERR 3319: Unknown node description for node GUID "
+ "0x%016" PRIx64 ". Reissuing ND query\n",
+ cl_ntoh64(osm_node_get_node_guid(p_node)));
+
+ state_mgr_update_node_desc(obj, context);
+
+exit:
+ OSM_LOG_EXIT(sm->p_log);
+}
+
+/**********************************************************************
+ Initiates a lightweight sweep of the subnet.
+ Used during normal sweeps after the subnet is up.
+**********************************************************************/
+static ib_api_status_t state_mgr_light_sweep_start(IN osm_sm_t * sm)
+{
+ ib_api_status_t status = IB_SUCCESS;
+ osm_bind_handle_t h_bind;
+ cl_qmap_t *p_sw_tbl;
+ cl_map_item_t *p_next;
+ osm_node_t *p_node;
+ osm_physp_t *p_physp;
+ uint8_t port_num;
+
+ OSM_LOG_ENTER(sm->p_log);
+
+ p_sw_tbl = &sm->p_subn->sw_guid_tbl;
+
+ /*
+ * First, get the bind handle.
+ */
+ h_bind = osm_sm_mad_ctrl_get_bind_handle(&sm->mad_ctrl);
+ if (h_bind == OSM_BIND_INVALID_HANDLE) {
+ OSM_LOG(sm->p_log, OSM_LOG_DEBUG,
+ "No bound ports. Deferring sweep...\n");
+ status = IB_INVALID_STATE;
+ goto _exit;
+ }
+
+ OSM_LOG_MSG_BOX(sm->p_log, OSM_LOG_VERBOSE, "INITIATING LIGHT SWEEP");
+ CL_PLOCK_ACQUIRE(sm->p_lock);
+ cl_qmap_apply_func(p_sw_tbl, state_mgr_get_sw_info, sm);
+ CL_PLOCK_RELEASE(sm->p_lock);
+
+ CL_PLOCK_ACQUIRE(sm->p_lock);
+ cl_qmap_apply_func(&sm->p_subn->node_guid_tbl, state_mgr_get_node_desc,
+ sm);
+ CL_PLOCK_RELEASE(sm->p_lock);
+
+ /* now scan the list of physical ports that were not down but have no remote port */
+ CL_PLOCK_ACQUIRE(sm->p_lock);
+ p_next = cl_qmap_head(&sm->p_subn->node_guid_tbl);
+ while (p_next != cl_qmap_end(&sm->p_subn->node_guid_tbl)) {
+ p_node = (osm_node_t *) p_next;
+ p_next = cl_qmap_next(p_next);
+
+ for (port_num = 1; port_num < osm_node_get_num_physp(p_node);
+ port_num++) {
+ p_physp = osm_node_get_physp_ptr(p_node, port_num);
+ if (p_physp && (osm_physp_get_port_state(p_physp) !=
+ IB_LINK_DOWN)
+ && !osm_physp_get_remote(p_physp)) {
+ OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR 3315: "
+ "Unknown remote side for node 0x%016"
+ PRIx64
+ " (%s) port %u. Adding to light sweep sampling list\n",
+ cl_ntoh64(osm_node_get_node_guid
+ (p_node)),
+ p_node->print_desc, port_num);
+
+ osm_dump_dr_path_v2(sm->p_log,
+ osm_physp_get_dr_path_ptr
+ (p_physp), FILE_ID, OSM_LOG_ERROR);
+
+ state_mgr_get_remote_port_info(sm, p_physp);
+ }
+ }
+ }
+
+ cl_qmap_apply_func(&sm->p_subn->sm_guid_tbl, query_sm_info, sm);
+
+ CL_PLOCK_RELEASE(sm->p_lock);
+
+_exit:
+ OSM_LOG_EXIT(sm->p_log);
+ return status;
+}
+
+/**********************************************************************
+ * Go over all the remote SMs (as updated in the sm_guid_tbl).
+ * Find if there is a remote sm that is a master SM.
+ * If there is a remote master SM - return a pointer to it,
+ * else - return NULL.
+ **********************************************************************/
+static osm_remote_sm_t *state_mgr_exists_other_master_sm(IN osm_sm_t * sm)
+{
+ cl_qmap_t *p_sm_tbl;
+ osm_remote_sm_t *p_sm;
+ osm_remote_sm_t *p_sm_res = NULL;
+ osm_node_t *p_node;
+
+ OSM_LOG_ENTER(sm->p_log);
+
+ p_sm_tbl = &sm->p_subn->sm_guid_tbl;
+
+ /* go over all the remote SMs */
+ for (p_sm = (osm_remote_sm_t *) cl_qmap_head(p_sm_tbl);
+ p_sm != (osm_remote_sm_t *) cl_qmap_end(p_sm_tbl);
+ p_sm = (osm_remote_sm_t *) cl_qmap_next(&p_sm->map_item)) {
+ /* If the sm is in MASTER state - return a pointer to it */
+ p_node = osm_get_node_by_guid(sm->p_subn, p_sm->smi.guid);
+ if (ib_sminfo_get_state(&p_sm->smi) == IB_SMINFO_STATE_MASTER) {
+ OSM_LOG(sm->p_log, OSM_LOG_VERBOSE,
+ "Found remote master SM with guid:0x%016" PRIx64
+ " (node %s)\n", cl_ntoh64(p_sm->smi.guid),
+ p_node ? p_node->print_desc : "UNKNOWN");
+ p_sm_res = p_sm;
+ goto Exit;
+ }
+ }
+
+Exit:
+ OSM_LOG_EXIT(sm->p_log);
+ return p_sm_res;
+}
+
+/**********************************************************************
+ * Go over all remote SMs (as updated in the sm_guid_tbl).
+ * Find the one with the highest priority and lowest guid.
+ * Compare this SM to the local SM. If the local SM is higher -
+ * return NULL, if the remote SM is higher - return a pointer to it.
+ **********************************************************************/
+static osm_remote_sm_t *state_mgr_get_highest_sm(IN osm_sm_t * sm)
+{
+ cl_qmap_t *p_sm_tbl;
+ osm_remote_sm_t *p_sm = NULL;
+ osm_remote_sm_t *p_highest_sm;
+ uint8_t highest_sm_priority;
+ ib_net64_t highest_sm_guid;
+ osm_node_t *p_node;
+
+ OSM_LOG_ENTER(sm->p_log);
+
+ p_sm_tbl = &sm->p_subn->sm_guid_tbl;
+
+ /* Start with the local sm as the standard */
+ p_highest_sm = NULL;
+ highest_sm_priority = sm->p_subn->opt.sm_priority;
+ highest_sm_guid = sm->p_subn->sm_port_guid;
+
+ /* go over all the remote SMs */
+ for (p_sm = (osm_remote_sm_t *) cl_qmap_head(p_sm_tbl);
+ p_sm != (osm_remote_sm_t *) cl_qmap_end(p_sm_tbl);
+ p_sm = (osm_remote_sm_t *) cl_qmap_next(&p_sm->map_item)) {
+
+ /* If the sm is in NOTACTIVE state - continue */
+ if (ib_sminfo_get_state(&p_sm->smi) ==
+ IB_SMINFO_STATE_NOTACTIVE)
+ continue;
+
+ if (osm_sm_is_greater_than(ib_sminfo_get_priority(&p_sm->smi),
+ p_sm->smi.guid, highest_sm_priority,
+ highest_sm_guid)) {
+ /* the new p_sm is with higher priority - update the highest_sm */
+ /* to this sm */
+ p_highest_sm = p_sm;
+ highest_sm_priority =
+ ib_sminfo_get_priority(&p_sm->smi);
+ highest_sm_guid = p_sm->smi.guid;
+ }
+ }
+
+ if (p_highest_sm != NULL) {
+ p_node = osm_get_node_by_guid(sm->p_subn, p_highest_sm->smi.guid);
+ OSM_LOG(sm->p_log, OSM_LOG_DEBUG,
+ "Found higher priority SM with guid: %016" PRIx64 " (node %s)\n",
+ cl_ntoh64(p_highest_sm->smi.guid),
+ p_node ? p_node->print_desc : "UNKNOWN");
+ }
+ OSM_LOG_EXIT(sm->p_log);
+ return p_highest_sm;
+}
+
+/**********************************************************************
+ * Send SubnSet(SMInfo) SMP with HANDOVER attribute to the
+ * remote_sm indicated.
+ **********************************************************************/
+static void state_mgr_send_handover(IN osm_sm_t * sm, IN osm_remote_sm_t * p_sm)
+{
+ uint8_t payload[IB_SMP_DATA_SIZE];
+ ib_sm_info_t *p_smi = (ib_sm_info_t *) payload;
+ osm_madw_context_t context;
+ const osm_port_t *p_port;
+ ib_api_status_t status;
+
+ OSM_LOG_ENTER(sm->p_log);
+
+ /*
+ * Send a query of SubnSet(SMInfo) HANDOVER to the remote sm given.
+ */
+
+ memset(&context, 0, sizeof(context));
+ p_port = osm_get_port_by_guid(sm->p_subn, p_sm->smi.guid);
+ if (p_port == NULL) {
+ OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR 3316: "
+ "No port object on given remote_sm object\n");
+ goto Exit;
+ }
+
+ /* update the master_guid in the sm_state_mgr object according to */
+ /* the guid of the port where the new Master SM should reside. */
+ OSM_LOG(sm->p_log, OSM_LOG_VERBOSE,
+ "Handing over mastership. Updating sm_state_mgr master_guid: %016"
+ PRIx64 " (node %s)\n", cl_ntoh64(p_port->guid),
+ p_port->p_node ? p_port->p_node->print_desc : "UNKNOWN");
+ sm->master_sm_guid = p_port->guid;
+
+ context.smi_context.port_guid = p_port->guid;
+ context.smi_context.set_method = TRUE;
+
+ memset(payload, 0, sizeof(payload));
+ p_smi->guid = sm->p_subn->sm_port_guid;
+ p_smi->act_count = cl_hton32(sm->p_subn->p_osm->stats.qp0_mads_sent);
+ p_smi->pri_state = (uint8_t) (sm->p_subn->sm_state |
+ sm->p_subn->opt.sm_priority << 4);
+ p_smi->sm_key = sm->p_subn->opt.sm_key;
+
+ CL_PLOCK_ACQUIRE(sm->p_lock);
+ status = osm_req_set(sm, osm_physp_get_dr_path_ptr(p_port->p_physp),
+ payload, sizeof(payload), IB_MAD_ATTR_SM_INFO,
+ IB_SMINFO_ATTR_MOD_HANDOVER, FALSE,
+ ib_port_info_get_m_key(&p_port->p_physp->port_info),
+ CL_DISP_MSGID_NONE, &context);
+ CL_PLOCK_RELEASE(sm->p_lock);
+
+ if (status != IB_SUCCESS)
+ OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR 3317: "
+ "Failure requesting SMInfo (%s), remote SM at 0x%"
+ PRIx64 " (node %s)\n",
+ ib_get_err_str(status), cl_ntoh64(p_port->guid),
+ p_port->p_node ? p_port->p_node->print_desc : "UNKNOWN");
+
+Exit:
+ OSM_LOG_EXIT(sm->p_log);
+}
+
+/**********************************************************************
+ * Send Trap 64 on all new ports.
+ **********************************************************************/
+static void state_mgr_report_new_ports(IN osm_sm_t * sm)
+{
+ ib_gid_t port_gid;
+ ib_mad_notice_attr_t notice;
+ ib_api_status_t status;
+ ib_net64_t port_guid;
+ cl_map_item_t *p_next;
+ osm_port_t *p_port;
+ uint16_t min_lid_ho;
+ uint16_t max_lid_ho;
+
+ OSM_LOG_ENTER(sm->p_log);
+
+ CL_PLOCK_ACQUIRE(sm->p_lock);
+ p_next = cl_qmap_head(&sm->p_subn->port_guid_tbl);
+ while (p_next != cl_qmap_end(&sm->p_subn->port_guid_tbl)) {
+ p_port = (osm_port_t *) p_next;
+ p_next = cl_qmap_next(p_next);
+
+ if (!p_port->is_new)
+ continue;
+
+ port_guid = osm_port_get_guid(p_port);
+ /* issue a notice - trap 64 (SM_GID_IN_SERVICE_TRAP) */
+
+ /* details of the notice */
+ notice.generic_type = 0x80 | IB_NOTICE_TYPE_SUBN_MGMT; /* is generic subn mgt type */
+ ib_notice_set_prod_type_ho(&notice, 4); /* A Class Manager generator */
+ /* endport becomes reachable */
+ notice.g_or_v.generic.trap_num = CL_HTON16(SM_GID_IN_SERVICE_TRAP); /* 64 */
+ /* The sm_base_lid is saved in network order already. */
+ notice.issuer_lid = sm->p_subn->sm_base_lid;
+ /* following C14-72.1.1 and table 119 p739 */
+ /* we need to provide the GID */
+ port_gid.unicast.prefix = sm->p_subn->opt.subnet_prefix;
+ port_gid.unicast.interface_id = port_guid;
+ memcpy(&(notice.data_details.ntc_64_67.gid), &(port_gid),
+ sizeof(ib_gid_t));
+
+ /* According to page 653 - the issuer gid in this case of trap
+ * is the SM gid, since the SM is the initiator of this trap. */
+ notice.issuer_gid.unicast.prefix =
+ sm->p_subn->opt.subnet_prefix;
+ notice.issuer_gid.unicast.interface_id =
+ sm->p_subn->sm_port_guid;
+
+ status = osm_report_notice(sm->p_log, sm->p_subn, &notice);
+ if (status != IB_SUCCESS)
+ OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR 3318: "
+ "Error sending trap reports on GUID:0x%016"
+ PRIx64 " (%s)\n", port_gid.unicast.interface_id,
+ ib_get_err_str(status));
+ osm_port_get_lid_range_ho(p_port, &min_lid_ho, &max_lid_ho);
+ OSM_LOG(sm->p_log, OSM_LOG_INFO,
+ "Discovered new port with GUID:0x%016" PRIx64
+ " LID range [%u,%u] of node: %s\n",
+ cl_ntoh64(port_gid.unicast.interface_id),
+ min_lid_ho, max_lid_ho,
+ p_port->p_node ? p_port->p_node->
+ print_desc : "UNKNOWN");
+
+ p_port->is_new = 0;
+ }
+ CL_PLOCK_RELEASE(sm->p_lock);
+
+ OSM_LOG_EXIT(sm->p_log);
+}
+
+/**********************************************************************
+ * Make sure that the lid_port_tbl of the subnet has only the ports
+ * that are recognized, and in the correct lid place. There could be
+ * errors if we wanted to assign a certain port with lid X, but that
+ * request didn't reach the port. In this case port_lid_tbl will have
+ * the port under lid X, though the port isn't updated with this lid.
+ * We will run a new heavy sweep (since there were errors in the
+ * initialization), but here we'll clean the database from incorrect
+ * information.
+ **********************************************************************/
+static void state_mgr_check_tbl_consistency(IN osm_sm_t * sm)
+{
+ cl_qmap_t *p_port_guid_tbl;
+ osm_port_t *p_port;
+ osm_port_t *p_next_port;
+ cl_ptr_vector_t *p_port_lid_tbl;
+ size_t max_lid, ref_size, curr_size, lid;
+ osm_port_t *p_port_ref, *p_port_stored;
+ cl_ptr_vector_t ref_port_lid_tbl;
+ uint16_t min_lid_ho;
+ uint16_t max_lid_ho;
+ uint16_t lid_ho;
+
+ OSM_LOG_ENTER(sm->p_log);
+
+ if (sm->lid_mgr.dirty == FALSE)
+ goto Exit;
+
+ sm->lid_mgr.dirty = FALSE;
+
+ cl_ptr_vector_construct(&ref_port_lid_tbl);
+ cl_ptr_vector_init(&ref_port_lid_tbl,
+ cl_ptr_vector_get_size(&sm->p_subn->port_lid_tbl),
+ OSM_SUBNET_VECTOR_GROW_SIZE);
+
+ p_port_guid_tbl = &sm->p_subn->port_guid_tbl;
+
+ /* Let's go over all the ports according to port_guid_tbl,
+ * and add the port to a reference port_lid_tbl. */
+ p_next_port = (osm_port_t *) cl_qmap_head(p_port_guid_tbl);
+ while (p_next_port != (osm_port_t *) cl_qmap_end(p_port_guid_tbl)) {
+ p_port = p_next_port;
+ p_next_port =
+ (osm_port_t *) cl_qmap_next(&p_next_port->map_item);
+
+ osm_port_get_lid_range_ho(p_port, &min_lid_ho, &max_lid_ho);
+ for (lid_ho = min_lid_ho; lid_ho <= max_lid_ho; lid_ho++)
+ cl_ptr_vector_set(&ref_port_lid_tbl, lid_ho, p_port);
+ }
+
+ p_port_lid_tbl = &sm->p_subn->port_lid_tbl;
+
+ ref_size = cl_ptr_vector_get_size(&ref_port_lid_tbl);
+ curr_size = cl_ptr_vector_get_size(p_port_lid_tbl);
+ /* They should be the same, but compare it anyway */
+ max_lid = (ref_size > curr_size) ? ref_size : curr_size;
+
+ for (lid = 1; lid < max_lid; lid++) {
+ p_port_ref = NULL;
+ p_port_stored = NULL;
+ cl_ptr_vector_at(p_port_lid_tbl, lid, (void *)&p_port_stored);
+ cl_ptr_vector_at(&ref_port_lid_tbl, lid, (void *)&p_port_ref);
+
+ if (p_port_stored == p_port_ref)
+ /* This is the "good" case - both entries are the
+ * same for this lid. Nothing to do. */
+ continue;
+
+ if (p_port_ref == NULL) {
+ /* There is an object in the subnet database for this
+ * lid, but no such object exists in the reference
+ * port_list_tbl. This can occur if we wanted to assign
+ * a certain port with some lid (different than the one
+ * pre-assigned to it), and the port didn't get the
+ * PortInfo Set request. Due to this, the port is
+ * updated with its original lid in our database
+ * rather than the new lid we wanted to give it. */
+ OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR 3322: "
+ "lid %zu is wrongly assigned to port 0x%016"
+ PRIx64 " (\'%s\' port %u) in port_lid_tbl\n",
+ lid,
+ cl_ntoh64(osm_port_get_guid(p_port_stored)),
+ p_port_stored->p_node->print_desc,
+ p_port_stored->p_physp->port_num);
+ } else if (p_port_stored == NULL)
+ /* There is an object in the new database, but no
+ * object in our subnet database. This is the matching
+ * case of the prior check - the port still has its
+ * original lid. */
+ OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR 3323: "
+ "port 0x%016" PRIx64 " (\'%s\' port %u)"
+ " exists in new port_lid_tbl under lid %zu,"
+ " but missing in subnet port_lid_tbl db\n",
+ cl_ntoh64(osm_port_get_guid(p_port_ref)),
+ p_port_ref->p_node->print_desc,
+ p_port_ref->p_physp->port_num, lid);
+ else {
+ /* if we reached here then p_port_stored != p_port_ref.
+ * We were trying to set a lid to p_port_stored, but
+ * it didn't reach it, and p_port_ref also didn't get
+ * the lid update. */
+ OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR 3324: "
+ "lid %zu has port 0x%016" PRIx64
+ " (\'%s\' port %u) in new port_lid_tbl db, "
+ "and port 0x%016" PRIx64 " (\'%s\' port %u)"
+ " in subnet port_lid_tbl db\n", lid,
+ cl_ntoh64(osm_port_get_guid(p_port_ref)),
+ p_port_ref->p_node->print_desc,
+ p_port_ref->p_physp->port_num,
+ cl_ntoh64(osm_port_get_guid(p_port_stored)),
+ p_port_stored->p_node->print_desc,
+ p_port_stored->p_physp->port_num);
+ }
+
+ /*
+ * Clear the lid of the port in order to ignore it
+ * in routing phase
+ */
+ if (p_port_stored) {
+ OSM_LOG(sm->p_log, OSM_LOG_INFO, "Clearing Lid for "
+ "port 0x%016" PRIx64 "\n",
+ cl_ntoh64(osm_port_get_guid(p_port_stored)));
+ osm_port_clear_base_lid(p_port_stored);
+ cl_ptr_vector_set(p_port_lid_tbl, lid, NULL);
+ }
+
+ /* Make sure we'll do another heavy sweep. */
+ sm->p_subn->subnet_initialization_error = TRUE;
+ }
+
+ cl_ptr_vector_destroy(&ref_port_lid_tbl);
+
+Exit:
+ OSM_LOG_EXIT(sm->p_log);
+}
+
+static void check_switch_lft(cl_map_item_t * item, void *log)
+{
+ osm_switch_t *sw = (osm_switch_t *) item;
+
+ if (!sw->new_lft)
+ return;
+
+ if (memcmp(sw->lft, sw->new_lft, sw->max_lid_ho + 1))
+ osm_log_v2(log, OSM_LOG_ERROR, FILE_ID, "ERR 331D: "
+ "LFT of switch 0x%016" PRIx64 " (%s) is not up to date\n",
+ cl_ntoh64(sw->p_node->node_info.node_guid),
+ sw->p_node->print_desc);
+}
+
+int wait_for_pending_transactions(osm_stats_t * stats)
+{
+#ifdef HAVE_LIBPTHREAD
+ pthread_mutex_lock(&stats->mutex);
+ while (stats->qp0_mads_outstanding && !osm_exit_flag)
+ pthread_cond_wait(&stats->cond, &stats->mutex);
+ pthread_mutex_unlock(&stats->mutex);
+#else
+ while (1) {
+ unsigned count = stats->qp0_mads_outstanding;
+ if (!count || osm_exit_flag)
+ break;
+ cl_event_wait_on(&stats->event, EVENT_NO_TIMEOUT, TRUE);
+ }
+#endif
+ return osm_exit_flag;
+}
+
+static void do_sweep(osm_sm_t * sm)
+{
+ ib_api_status_t status;
+ osm_remote_sm_t *p_remote_sm;
+ unsigned config_parsed = 0;
+
+ if (sm->p_subn->force_first_time_master_sweep) {
+ sm->p_subn->force_heavy_sweep = TRUE;
+ sm->p_subn->coming_out_of_standby = TRUE;
+ sm->p_subn->first_time_master_sweep = TRUE;
+ sm->p_subn->force_first_time_master_sweep = FALSE;
+ }
+
+ /* after subnet initialization error, run heavy sweep */
+ if (sm->p_subn->subnet_initialization_error)
+ sm->p_subn->force_heavy_sweep = TRUE;
+
+ if (sm->p_subn->force_heavy_sweep) {
+ if (osm_subn_rescan_conf_files(sm->p_subn) < 0)
+ OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR 331A: "
+ "osm_subn_rescan_conf_file failed\n");
+ else
+ config_parsed = 1;
+ }
+
+ if (sm->p_subn->sm_state != IB_SMINFO_STATE_MASTER &&
+ sm->p_subn->sm_state != IB_SMINFO_STATE_DISCOVERING)
+ return;
+
+ if (sm->p_subn->coming_out_of_standby) {
+ /*
+ * Need to force re-write of sm_base_lid to all ports
+ * to do that we want all the ports to be considered
+ * foreign
+ */
+ state_mgr_clean_known_lids(sm);
+
+ /*
+ * Need to clean SA cache when state changes to STANDBY
+ * after handover.
+ */
+ state_mgr_sa_clean(sm);
+
+ /*
+ * Need to reconfigure LFTs, PKEYs, and QoS on all switches
+ * when coming out of STANDBY
+ */
+ sm->p_subn->need_update = 1;
+ }
+
+ sm->master_sm_found = 0;
+
+ /*
+ * If we already have switches, then try a light sweep.
+ * Otherwise, this is probably our first discovery pass
+ * or we are connected in loopback. In both cases do a
+ * heavy sweep.
+ * Note: If we are connected in loopback we want a heavy
+ * sweep, since we will not be getting any traps if there is
+ * a lost connection.
+ */
+ /* if we are in DISCOVERING state - this means it is either in
+ * initializing or wake up from STANDBY - run the heavy sweep */
+ if (cl_qmap_count(&sm->p_subn->sw_guid_tbl)
+ && sm->p_subn->sm_state != IB_SMINFO_STATE_DISCOVERING
+ && sm->p_subn->opt.force_heavy_sweep == FALSE
+ && sm->p_subn->force_heavy_sweep == FALSE
+ && sm->p_subn->force_reroute == FALSE
+ && sm->p_subn->subnet_initialization_error == FALSE
+ && (state_mgr_light_sweep_start(sm) == IB_SUCCESS)) {
+ if (wait_for_pending_transactions(&sm->p_subn->p_osm->stats))
+ return;
+ if (!sm->p_subn->force_heavy_sweep) {
+ if (sm->p_subn->opt.sa_db_dump &&
+ !osm_sa_db_file_dump(sm->p_subn->p_osm))
+ osm_opensm_report_event(sm->p_subn->p_osm,
+ OSM_EVENT_ID_SA_DB_DUMPED,
+ NULL);
+ OSM_LOG_MSG_BOX(sm->p_log, OSM_LOG_VERBOSE,
+ "LIGHT SWEEP COMPLETE");
+ return;
+ }
+ }
+
+ /*
+ * Unicast cache should be invalidated when subnet re-route is
+ * requested, and when OpenSM comes out of standby state.
+ */
+ if (sm->p_subn->opt.use_ucast_cache &&
+ (sm->p_subn->force_reroute || sm->p_subn->coming_out_of_standby))
+ osm_ucast_cache_invalidate(&sm->ucast_mgr);
+
+ /*
+ * If we don't need to do a heavy sweep and we want to do a reroute,
+ * just reroute only.
+ */
+ if (cl_qmap_count(&sm->p_subn->sw_guid_tbl)
+ && sm->p_subn->sm_state != IB_SMINFO_STATE_DISCOVERING
+ && sm->p_subn->opt.force_heavy_sweep == FALSE
+ && sm->p_subn->force_heavy_sweep == FALSE
+ && sm->p_subn->force_reroute == TRUE
+ && sm->p_subn->subnet_initialization_error == FALSE) {
+ /* Reset flag */
+ sm->p_subn->force_reroute = FALSE;
+
+ /* Re-program the switches fully */
+ sm->p_subn->ignore_existing_lfts = TRUE;
+
+ if (osm_ucast_mgr_process(&sm->ucast_mgr)) {
+ OSM_LOG_MSG_BOX(sm->p_log, OSM_LOG_VERBOSE,
+ "REROUTE FAILED");
+ return;
+ }
+ osm_qos_setup(sm->p_subn->p_osm);
+
+ /* Reset flag */
+ sm->p_subn->ignore_existing_lfts = FALSE;
+
+ if (wait_for_pending_transactions(&sm->p_subn->p_osm->stats))
+ return;
+
+ osm_congestion_control_setup(sm->p_subn->p_osm);
+
+ if (osm_congestion_control_wait_pending_transactions(sm->p_subn->p_osm))
+ return;
+
+ if (!sm->p_subn->subnet_initialization_error) {
+ OSM_LOG_MSG_BOX(sm->p_log, OSM_LOG_VERBOSE,
+ "REROUTE COMPLETE");
+ osm_opensm_report_event(sm->p_subn->p_osm,
+ OSM_EVENT_ID_UCAST_ROUTING_DONE,
+ (void *) UCAST_ROUTING_REROUTE);
+ return;
+ }
+ }
+
+ osm_opensm_report_event(sm->p_subn->p_osm,
+ OSM_EVENT_ID_HEAVY_SWEEP_START, NULL);
+
+ /* go to heavy sweep */
+repeat_discovery:
+
+ /* First of all - unset all flags */
+ sm->p_subn->force_heavy_sweep = FALSE;
+ sm->p_subn->force_reroute = FALSE;
+ sm->p_subn->subnet_initialization_error = FALSE;
+
+ /* Reset tracking values in case limiting component got removed
+ * from fabric. */
+ sm->p_subn->min_ca_mtu = IB_MAX_MTU;
+ sm->p_subn->min_ca_rate = IB_PATH_RECORD_RATE_300_GBS;
+ sm->p_subn->min_data_vls = IB_MAX_NUM_VLS - 1;
+ sm->p_subn->min_sw_data_vls = IB_MAX_NUM_VLS - 1;
+
+ /* rescan configuration updates */
+ if (!config_parsed && osm_subn_rescan_conf_files(sm->p_subn) < 0)
+ OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR 331A: "
+ "osm_subn_rescan_conf_file failed\n");
+
+ if (sm->p_subn->sm_state != IB_SMINFO_STATE_MASTER)
+ sm->p_subn->need_update = 1;
+
+ status = state_mgr_sweep_hop_0(sm);
+ if (status != IB_SUCCESS ||
+ wait_for_pending_transactions(&sm->p_subn->p_osm->stats))
+ return;
+
+ if (state_mgr_is_sm_port_down(sm) == TRUE) {
+ if (sm->p_subn->last_sm_port_state) {
+ sm->p_subn->last_sm_port_state = 0;
+ state_mgr_sa_clean(sm);
+ osm_log_v2(sm->p_log, OSM_LOG_SYS, FILE_ID,
+ "SM port is down\n");
+ OSM_LOG_MSG_BOX(sm->p_log, OSM_LOG_VERBOSE,
+ "SM PORT DOWN");
+ }
+
+ /* Run the drop manager - we want to clear all records */
+ osm_drop_mgr_process(sm);
+
+ /* Move to DISCOVERING state */
+ if (sm->p_subn->sm_state != IB_SMINFO_STATE_DISCOVERING)
+ osm_sm_state_mgr_process(sm, OSM_SM_SIGNAL_DISCOVER);
+ osm_opensm_report_event(sm->p_subn->p_osm,
+ OSM_EVENT_ID_STATE_CHANGE, NULL);
+ return;
+ } else {
+ if (!sm->p_subn->last_sm_port_state) {
+ sm->p_subn->last_sm_port_state = 1;
+ osm_log_v2(sm->p_log, OSM_LOG_SYS, FILE_ID,
+ "SM port is up\n");
+ OSM_LOG_MSG_BOX(sm->p_log, OSM_LOG_VERBOSE,
+ "SM PORT UP");
+ }
+ }
+
+ status = state_mgr_sweep_hop_1(sm);
+ if (status != IB_SUCCESS ||
+ wait_for_pending_transactions(&sm->p_subn->p_osm->stats))
+ return;
+
+ /* discovery completed - check other sm presence */
+ if (sm->master_sm_found) {
+ /*
+ * Call the sm_state_mgr with signal
+ * MASTER_OR_HIGHER_SM_DETECTED_DONE
+ */
+ osm_sm_state_mgr_process(sm,
+ OSM_SM_SIGNAL_MASTER_OR_HIGHER_SM_DETECTED);
+ OSM_LOG_MSG_BOX(sm->p_log, OSM_LOG_VERBOSE,
+ "ENTERING STANDBY STATE");
+ /* notify master SM about us */
+ osm_send_trap144(sm, 0);
+ osm_opensm_report_event(sm->p_subn->p_osm,
+ OSM_EVENT_ID_STATE_CHANGE, NULL);
+ return;
+ }
+
+ /* if new sweep requested - don't bother with the rest */
+ if (sm->p_subn->force_heavy_sweep) {
+ config_parsed = 0;
+ goto repeat_discovery;
+ }
+
+ osm_opensm_report_event(sm->p_subn->p_osm,
+ OSM_EVENT_ID_HEAVY_SWEEP_DONE, NULL);
+
+ OSM_LOG_MSG_BOX(sm->p_log, OSM_LOG_VERBOSE, "HEAVY SWEEP COMPLETE");
+
+ osm_drop_mgr_process(sm);
+
+ /* If we are MASTER - get the highest remote_sm, and
+ * see if it is higher than our local sm.
+ */
+ if (sm->p_subn->sm_state == IB_SMINFO_STATE_MASTER) {
+ p_remote_sm = state_mgr_get_highest_sm(sm);
+ if (p_remote_sm != NULL) {
+ /* report new ports (trap 64) before leaving MASTER */
+ state_mgr_report_new_ports(sm);
+
+ /* need to handover the mastership
+ * to the remote sm, and move to standby */
+ state_mgr_send_handover(sm, p_remote_sm);
+ osm_sm_state_mgr_process(sm,
+ OSM_SM_SIGNAL_HANDOVER_SENT);
+ return;
+ } else {
+ /* We are the highest sm - check to see if there is
+ * a remote SM that is in master state. */
+ p_remote_sm = state_mgr_exists_other_master_sm(sm);
+ if (p_remote_sm != NULL) {
+ /* There is a remote SM that is master.
+ * need to wait for that SM to relinquish control
+ * of its portion of the subnet. C14-60.2.1.
+ * Also - need to start polling on that SM. */
+ CL_PLOCK_EXCL_ACQUIRE(sm->p_lock);
+ sm->polling_sm_guid = p_remote_sm->smi.guid;
+ CL_PLOCK_RELEASE(sm->p_lock);
+ osm_sm_state_mgr_process(sm,
+ OSM_SM_SIGNAL_WAIT_FOR_HANDOVER);
+ return;
+ } else if (sm->polling_sm_guid) {
+ /* Stop polling SM if it's not found */
+ osm_sm_state_mgr_process(sm,
+ OSM_SM_SIGNAL_POLLING_TIMEOUT);
+ return;
+ }
+ }
+ }
+
+ /*
+ * If we are not MASTER already - this means that we are
+ * in discovery state. call osm_sm_state_mgr with signal
+ * DISCOVERY_COMPLETED
+ */
+ if (sm->p_subn->sm_state == IB_SMINFO_STATE_DISCOVERING)
+ osm_sm_state_mgr_process(sm, OSM_SM_SIGNAL_DISCOVERY_COMPLETED);
+
+ osm_reset_switch_state_change_bit(sm->p_subn->p_osm);
+ if (wait_for_pending_transactions(&sm->p_subn->p_osm->stats))
+ return;
+
+ osm_pkey_mgr_process(sm->p_subn->p_osm);
+
+ /* try to restore SA DB (this should be before lid_mgr
+ because we may want to disable clients reregistration
+ when SA DB is restored) */
+ osm_sa_db_file_load(sm->p_subn->p_osm);
+
+ if (wait_for_pending_transactions(&sm->p_subn->p_osm->stats))
+ return;
+
+ OSM_LOG_MSG_BOX(sm->p_log, OSM_LOG_VERBOSE,
+ "PKEY setup completed - STARTING SM LID CONFIG");
+
+ osm_lid_mgr_process_sm(&sm->lid_mgr);
+ if (wait_for_pending_transactions(&sm->p_subn->p_osm->stats))
+ return;
+
+ OSM_LOG_MSG_BOX(sm->p_log, OSM_LOG_VERBOSE,
+ "SM LID ASSIGNMENT COMPLETE - STARTING SUBNET LID CONFIG");
+ state_mgr_notify_lid_change(sm);
+
+ osm_lid_mgr_process_subnet(&sm->lid_mgr);
+ if (wait_for_pending_transactions(&sm->p_subn->p_osm->stats))
+ return;
+
+ /* At this point we need to check the consistency of
+ * the port_lid_tbl under the subnet. There might be
+ * errors in it if PortInfo Set requests didn't reach
+ * their destination. */
+ state_mgr_check_tbl_consistency(sm);
+
+ OSM_LOG_MSG_BOX(sm->p_log, OSM_LOG_VERBOSE,
+ "LID ASSIGNMENT COMPLETE - STARTING SWITCH TABLE CONFIG");
+
+ /*
+ * Proceed with unicast forwarding table configuration; if it fails
+ * return early to wait for a trap or the next sweep interval.
+ */
+
+ if (!sm->ucast_mgr.cache_valid ||
+ osm_ucast_cache_process(&sm->ucast_mgr)) {
+ if (osm_ucast_mgr_process(&sm->ucast_mgr)) {
+ osm_ucast_cache_invalidate(&sm->ucast_mgr);
+ return;
+ }
+ }
+
+ osm_qos_setup(sm->p_subn->p_osm);
+
+ if (wait_for_pending_transactions(&sm->p_subn->p_osm->stats))
+ return;
+
+ /* We are done setting all LFTs so clear the ignore existing.
+ * From now on, as long as we are still master, we want to
+ * take into account these lfts. */
+ sm->p_subn->ignore_existing_lfts = FALSE;
+
+ OSM_LOG_MSG_BOX(sm->p_log, OSM_LOG_VERBOSE,
+ "SWITCHES CONFIGURED FOR UNICAST");
+ osm_opensm_report_event(sm->p_subn->p_osm,
+ OSM_EVENT_ID_UCAST_ROUTING_DONE,
+ (void *) UCAST_ROUTING_HEAVY_SWEEP);
+
+ if (!sm->p_subn->opt.disable_multicast) {
+ osm_mcast_mgr_process(sm, TRUE);
+ if (wait_for_pending_transactions(&sm->p_subn->p_osm->stats))
+ return;
+ OSM_LOG_MSG_BOX(sm->p_log, OSM_LOG_VERBOSE,
+ "SWITCHES CONFIGURED FOR MULTICAST");
+ }
+
+ osm_guid_mgr_process(sm);
+ if (wait_for_pending_transactions(&sm->p_subn->p_osm->stats))
+ return;
+ OSM_LOG_MSG_BOX(sm->p_log, OSM_LOG_VERBOSE, "ALIAS GUIDS CONFIGURED");
+
+ /*
+ * The LINK_PORTS state is required since we cannot count on
+ * the port state change MADs to succeed. This is an artifact
+ * of the spec defining state change from state X to state X
+ * as an error. The hardware then is not required to process
+ * other parameters provided by the Set(PortInfo) Packet.
+ */
+
+ osm_link_mgr_process(sm, IB_LINK_NO_CHANGE);
+ if (wait_for_pending_transactions(&sm->p_subn->p_osm->stats))
+ return;
+
+ OSM_LOG_MSG_BOX(sm->p_log, OSM_LOG_VERBOSE,
+ "LINKS PORTS CONFIGURED - SET LINKS TO ARMED STATE");
+
+ osm_link_mgr_process(sm, IB_LINK_ARMED);
+ if (wait_for_pending_transactions(&sm->p_subn->p_osm->stats))
+ return;
+
+ OSM_LOG_MSG_BOX(sm->p_log, OSM_LOG_VERBOSE,
+ "LINKS ARMED - SET LINKS TO ACTIVE STATE");
+
+ osm_link_mgr_process(sm, IB_LINK_ACTIVE);
+ if (wait_for_pending_transactions(&sm->p_subn->p_osm->stats))
+ return;
+
+ /*
+ * The sweep completed!
+ */
+
+ /* Now do GSI configuration */
+
+ osm_congestion_control_setup(sm->p_subn->p_osm);
+
+ if (osm_congestion_control_wait_pending_transactions(sm->p_subn->p_osm))
+ return;
+
+ /*
+ * Send trap 64 on newly discovered endports
+ */
+ state_mgr_report_new_ports(sm);
+
+ /* check switch lft buffers assignments */
+ cl_qmap_apply_func(&sm->p_subn->sw_guid_tbl, check_switch_lft,
+ sm->p_log);
+
+ /* in any case we zero this flag */
+ sm->p_subn->coming_out_of_standby = FALSE;
+ sm->p_subn->first_time_master_sweep = FALSE;
+
+ /* If there were errors - then the subnet is not really up */
+ if (sm->p_subn->subnet_initialization_error == TRUE) {
+ osm_log_v2(sm->p_log, OSM_LOG_SYS, FILE_ID,
+ "Errors during initialization\n");
+ OSM_LOG_MSG_BOX(sm->p_log, OSM_LOG_ERROR,
+ "ERRORS DURING INITIALIZATION");
+ } else {
+ sm->p_subn->need_update = 0;
+ osm_dump_all(sm->p_subn->p_osm);
+ state_mgr_up_msg(sm);
+
+ if ((OSM_LOG_IS_ACTIVE_V2(sm->p_log, OSM_LOG_VERBOSE) ||
+ sm->p_subn->opt.sa_db_dump) &&
+ !osm_sa_db_file_dump(sm->p_subn->p_osm))
+ osm_opensm_report_event(sm->p_subn->p_osm,
+ OSM_EVENT_ID_SA_DB_DUMPED,
+ NULL);
+ }
+
+ /*
+ * Finally signal the subnet up event
+ */
+ cl_event_signal(&sm->subnet_up_event);
+
+ /* if we got a signal to force heavy sweep or errors
+ * in the middle of the sweep - try another sweep. */
+ if (sm->p_subn->force_heavy_sweep)
+ osm_sm_signal(sm, OSM_SIGNAL_SWEEP);
+
+ /* Write a new copy of our persistent guid2mkey database */
+ osm_db_store(sm->p_subn->p_g2m, sm->p_subn->opt.fsync_high_avail_files);
+ osm_db_store(sm->p_subn->p_neighbor,
+ sm->p_subn->opt.fsync_high_avail_files);
+
+ osm_opensm_report_event(sm->p_subn->p_osm, OSM_EVENT_ID_SUBNET_UP,
+ NULL);
+}
+
+static void do_process_mgrp_queue(osm_sm_t * sm)
+{
+ if (sm->p_subn->sm_state != IB_SMINFO_STATE_MASTER)
+ return;
+ if (!sm->p_subn->opt.disable_multicast) {
+ osm_mcast_mgr_process(sm, FALSE);
+ wait_for_pending_transactions(&sm->p_subn->p_osm->stats);
+ }
+}
+
+static void do_process_guid_queue(osm_sm_t *sm)
+{
+ osm_guid_mgr_process(sm);
+ wait_for_pending_transactions(&sm->p_subn->p_osm->stats);
+}
+
+void osm_state_mgr_process(IN osm_sm_t * sm, IN osm_signal_t signal)
+{
+ CL_ASSERT(sm);
+
+ OSM_LOG_ENTER(sm->p_log);
+
+ OSM_LOG(sm->p_log, OSM_LOG_DEBUG, "Received signal %s in state %s\n",
+ osm_get_sm_signal_str(signal),
+ osm_get_sm_mgr_state_str(sm->p_subn->sm_state));
+
+ switch (signal) {
+ case OSM_SIGNAL_SWEEP:
+ if (!sm->p_subn->sweeping_enabled) {
+ OSM_LOG(sm->p_log, OSM_LOG_DEBUG, "sweeping disabled - "
+ "ignoring signal %s in state %s\n",
+ osm_get_sm_signal_str(signal),
+ osm_get_sm_mgr_state_str(sm->p_subn->sm_state));
+ } else
+ do_sweep(sm);
+ break;
+ case OSM_SIGNAL_IDLE_TIME_PROCESS_REQUEST:
+ do_process_mgrp_queue(sm);
+ break;
+ case OSM_SIGNAL_GUID_PROCESS_REQUEST:
+ do_process_guid_queue(sm);
+ break;
+ default:
+ CL_ASSERT(FALSE);
+ OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR 3320: "
+ "Invalid SM signal %u\n", signal);
+ break;
+ }
+
+ OSM_LOG_EXIT(sm->p_log);
+}
diff --git a/contrib/ofed/opensm/opensm/osm_subnet.c b/contrib/ofed/opensm/opensm/osm_subnet.c
new file mode 100644
index 0000000..a7de1b9
--- /dev/null
+++ b/contrib/ofed/opensm/opensm/osm_subnet.c
@@ -0,0 +1,3027 @@
+/*
+ * Copyright (c) 2004-2009 Voltaire, Inc. All rights reserved.
+ * Copyright (c) 2002-2011 Mellanox Technologies LTD. All rights reserved.
+ * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
+ * Copyright (c) 2008 Xsigo Systems Inc. All rights reserved.
+ * Copyright (c) 2009 System Fabric Works, Inc. All rights reserved.
+ * Copyright (c) 2009 HNR Consulting. All rights reserved.
+ * Copyright (c) 2009-2015 ZIH, TU Dresden, Federal Republic of Germany. All rights reserved.
+ * Copyright (c) 2013 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+/*
+ * Abstract:
+ * Implementation of osm_subn_t.
+ * This object represents an IBA subnet.
+ * This object is part of the opensm family of objects.
+ */
+
+#if HAVE_CONFIG_H
+# include <config.h>
+#endif /* HAVE_CONFIG_H */
+
+#include <string.h>
+#include <stdio.h>
+#include <stdarg.h>
+#include <limits.h>
+#include <errno.h>
+#include <ctype.h>
+#include <complib/cl_debug.h>
+#include <complib/cl_log.h>
+#include <opensm/osm_file_ids.h>
+#define FILE_ID OSM_FILE_SUBNET_C
+#include <opensm/osm_subnet.h>
+#include <opensm/osm_opensm.h>
+#include <opensm/osm_log.h>
+#include <opensm/osm_madw.h>
+#include <opensm/osm_port.h>
+#include <opensm/osm_switch.h>
+#include <opensm/osm_remote_sm.h>
+#include <opensm/osm_partition.h>
+#include <opensm/osm_node.h>
+#include <opensm/osm_guid.h>
+#include <opensm/osm_multicast.h>
+#include <opensm/osm_inform.h>
+#include <opensm/osm_console.h>
+#include <opensm/osm_perfmgr.h>
+#include <opensm/osm_congestion_control.h>
+#include <opensm/osm_event_plugin.h>
+#include <opensm/osm_qos_policy.h>
+#include <opensm/osm_service.h>
+#include <opensm/osm_db.h>
+#include <opensm/osm_db_pack.h>
+
+static const char null_str[] = "(null)";
+
+#define OPT_OFFSET(opt) offsetof(osm_subn_opt_t, opt)
+#define ARR_SIZE(a) (sizeof(a)/sizeof((a)[0]))
+
+typedef struct opt_rec {
+ const char *name;
+ unsigned long opt_offset;
+ void (*parse_fn)(osm_subn_t *p_subn, char *p_key, char *p_val_str,
+ void *p_val1, void *p_val2,
+ void (*)(osm_subn_t *, void *));
+ void (*setup_fn)(osm_subn_t *p_subn, void *p_val);
+ int can_update;
+} opt_rec_t;
+
+static const char *module_name_str[] = {
+ "main.c",
+ "osm_console.c",
+ "osm_console_io.c",
+ "osm_db_files.c",
+ "osm_db_pack.c",
+ "osm_drop_mgr.c",
+ "osm_dump.c",
+ "osm_event_plugin.c",
+ "osm_guid_info_rcv.c",
+ "osm_guid_mgr.c",
+ "osm_helper.c",
+ "osm_inform.c",
+ "osm_lid_mgr.c",
+ "osm_lin_fwd_rcv.c",
+ "osm_link_mgr.c",
+ "osm_log.c",
+ "osm_mad_pool.c",
+ "osm_mcast_fwd_rcv.c",
+ "osm_mcast_mgr.c",
+ "osm_mcast_tbl.c",
+ "osm_mcm_port.c",
+ "osm_mesh.c",
+ "osm_mlnx_ext_port_info_rcv.c",
+ "osm_mtree.c",
+ "osm_multicast.c",
+ "osm_node.c",
+ "osm_node_desc_rcv.c",
+ "osm_node_info_rcv.c",
+ "osm_opensm.c",
+ "osm_perfmgr.c",
+ "osm_perfmgr_db.c",
+ "osm_pkey.c",
+ "osm_pkey_mgr.c",
+ "osm_pkey_rcv.c",
+ "osm_port.c",
+ "osm_port_info_rcv.c",
+ "osm_prtn.c",
+ "osm_prtn_config.c",
+ "osm_qos.c",
+ "osm_qos_parser_l.c",
+ "osm_qos_parser_y.c",
+ "osm_qos_policy.c",
+ "osm_remote_sm.c",
+ "osm_req.c",
+ "osm_resp.c",
+ "osm_router.c",
+ "osm_sa.c",
+ "osm_sa_class_port_info.c",
+ "osm_sa_guidinfo_record.c",
+ "osm_sa_informinfo.c",
+ "osm_sa_lft_record.c",
+ "osm_sa_link_record.c",
+ "osm_sa_mad_ctrl.c",
+ "osm_sa_mcmember_record.c",
+ "osm_sa_mft_record.c",
+ "osm_sa_multipath_record.c",
+ "osm_sa_node_record.c",
+ "osm_sa_path_record.c",
+ "osm_sa_pkey_record.c",
+ "osm_sa_portinfo_record.c",
+ "osm_sa_service_record.c",
+ "osm_sa_slvl_record.c",
+ "osm_sa_sminfo_record.c",
+ "osm_sa_sw_info_record.c",
+ "osm_sa_vlarb_record.c",
+ "osm_service.c",
+ "osm_slvl_map_rcv.c",
+ "osm_sm.c",
+ "osm_sminfo_rcv.c",
+ "osm_sm_mad_ctrl.c",
+ "osm_sm_state_mgr.c",
+ "osm_state_mgr.c",
+ "osm_subnet.c",
+ "osm_sw_info_rcv.c",
+ "osm_switch.c",
+ "osm_torus.c",
+ "osm_trap_rcv.c",
+ "osm_ucast_cache.c",
+ "osm_ucast_dnup.c",
+ "osm_ucast_file.c",
+ "osm_ucast_ftree.c",
+ "osm_ucast_lash.c",
+ "osm_ucast_mgr.c",
+ "osm_ucast_updn.c",
+ "osm_vendor_ibumad.c",
+ "osm_vl15intf.c",
+ "osm_vl_arb_rcv.c",
+ "st.c",
+ "osm_ucast_dfsssp.c",
+ "osm_congestion_control.c",
+ /* Add new module names here ... */
+ /* FILE_ID define in those modules must be identical to index here */
+ /* last FILE_ID is currently 89 */
+};
+
+#define MOD_NAME_STR_UNKNOWN_VAL (ARR_SIZE(module_name_str))
+
+static int find_module_name(const char *name, uint8_t *file_id)
+{
+ uint8_t i;
+
+ for (i = 0; i < MOD_NAME_STR_UNKNOWN_VAL; i++) {
+ if (strcmp(name, module_name_str[i]) == 0) {
+ if (file_id)
+ *file_id = i;
+ return 0;
+ }
+ }
+ return 1;
+}
+
+static void log_report(const char *fmt, ...)
+{
+ char buf[128];
+ va_list args;
+ va_start(args, fmt);
+ vsnprintf(buf, sizeof(buf), fmt, args);
+ va_end(args);
+ printf("%s", buf);
+ cl_log_event("OpenSM", CL_LOG_INFO, buf, NULL, 0);
+}
+
+static void log_config_value(char *name, const char *fmt, ...)
+{
+ char buf[128];
+ va_list args;
+ unsigned n;
+ va_start(args, fmt);
+ n = snprintf(buf, sizeof(buf), " Loading Cached Option:%s = ", name);
+ if (n > sizeof(buf))
+ n = sizeof(buf);
+ n += vsnprintf(buf + n, sizeof(buf) - n, fmt, args);
+ if (n > sizeof(buf) - 2)
+ n = sizeof(buf) - 2;
+ snprintf(buf + n, sizeof(buf) - n, "\n");
+ va_end(args);
+ printf("%s", buf);
+ cl_log_event("OpenSM", CL_LOG_INFO, buf, NULL, 0);
+}
+
+static void opts_setup_log_flags(osm_subn_t *p_subn, void *p_val)
+{
+ p_subn->p_osm->log.level = *((uint8_t *) p_val);
+}
+
+static void opts_setup_force_log_flush(osm_subn_t *p_subn, void *p_val)
+{
+ p_subn->p_osm->log.flush = *((boolean_t *) p_val);
+}
+
+static void opts_setup_accum_log_file(osm_subn_t *p_subn, void *p_val)
+{
+ p_subn->p_osm->log.accum_log_file = *((boolean_t *) p_val);
+}
+
+static void opts_setup_log_max_size(osm_subn_t *p_subn, void *p_val)
+{
+ uint32_t log_max_size = *((uint32_t *) p_val);
+
+ p_subn->p_osm->log.max_size = (unsigned long)log_max_size << 20; /* convert from MB to bytes */
+}
+
+static void opts_setup_sminfo_polling_timeout(osm_subn_t *p_subn, void *p_val)
+{
+ osm_sm_t *p_sm = &p_subn->p_osm->sm;
+ uint32_t sminfo_polling_timeout = *((uint32_t *) p_val);
+
+ cl_timer_stop(&p_sm->polling_timer);
+ cl_timer_start(&p_sm->polling_timer, sminfo_polling_timeout);
+}
+
+static void opts_setup_sm_priority(osm_subn_t *p_subn, void *p_val)
+{
+ osm_sm_t *p_sm = &p_subn->p_osm->sm;
+ uint8_t sm_priority = *((uint8_t *) p_val);
+
+ osm_set_sm_priority(p_sm, sm_priority);
+}
+
+static int opts_strtoul(uint32_t *val, IN char *p_val_str,
+ IN char *p_key, uint32_t max_value)
+{
+ char *endptr;
+ unsigned long int tmp_val;
+
+ errno = 0;
+ tmp_val = strtoul(p_val_str, &endptr, 0);
+ *val = tmp_val;
+ if (*p_val_str == '\0' || *endptr != '\0') {
+ log_report("-E- Parsing error in field %s, expected "
+ "numeric input received: %s\n", p_key, p_val_str);
+ return -1;
+ }
+ if (tmp_val > max_value ||
+ ((tmp_val == ULONG_MAX) && errno == ERANGE)) {
+ log_report("-E- Parsing error in field %s, value out of range\n", p_key);
+ return -1;
+ }
+ return 0;
+}
+
+static int opts_strtoull(uint64_t *val, IN char *p_val_str,
+ IN char *p_key, uint64_t max_value)
+{
+ char *endptr;
+ unsigned long long int tmp_val;
+
+ errno = 0;
+ tmp_val = strtoull(p_val_str, &endptr, 0);
+ *val = tmp_val;
+ if (*p_val_str == '\0' || *endptr != '\0') {
+ log_report("-E- Parsing error in field %s, expected "
+ "numeric input received: %s\n", p_key, p_val_str);
+ return -1;
+ }
+ if (tmp_val > max_value || (tmp_val == ULLONG_MAX && errno == ERANGE)) {
+ log_report("-E- Parsing error in field %s, value out of range\n", p_key);
+ return -1;
+ }
+ return 0;
+}
+
+static void opts_parse_net64(IN osm_subn_t *p_subn, IN char *p_key,
+ IN char *p_val_str, void *p_v1, void *p_v2,
+ void (*pfn)(osm_subn_t *, void *))
+{
+ uint64_t *p_val1 = p_v1, *p_val2 = p_v2;
+ uint64_t val;
+
+ if (opts_strtoull(&val, p_val_str, p_key, UINT64_MAX))
+ return;
+
+ if (cl_hton64(val) != *p_val1) {
+ log_config_value(p_key, "0x%016" PRIx64, val);
+ if (pfn)
+ pfn(p_subn, &val);
+ *p_val1 = *p_val2 = cl_ntoh64(val);
+ }
+}
+
+static void opts_parse_uint32(IN osm_subn_t *p_subn, IN char *p_key,
+ IN char *p_val_str, void *p_v1, void *p_v2,
+ void (*pfn)(osm_subn_t *, void *))
+{
+ uint32_t *p_val1 = p_v1, *p_val2 = p_v2;
+ uint32_t val;
+
+ if (opts_strtoul(&val, p_val_str, p_key, UINT32_MAX))
+ return;
+
+ if (val != *p_val1) {
+ log_config_value(p_key, "%u", val);
+ if (pfn)
+ pfn(p_subn, &val);
+ *p_val1 = *p_val2 = val;
+ }
+}
+
+static void opts_parse_net32(IN osm_subn_t *p_subn, IN char *p_key,
+ IN char *p_val_str, void *p_v1, void *p_v2,
+ void (*pfn)(osm_subn_t *, void *))
+{
+ uint32_t *p_val1 = p_v1, *p_val2 = p_v2;
+ uint32_t val;
+
+ if (opts_strtoul(&val, p_val_str, p_key, UINT32_MAX))
+ return;
+
+ if (cl_hton32(val) != *p_val1) {
+ log_config_value(p_key, "%u", val);
+ if (pfn)
+ pfn(p_subn, &val);
+ *p_val1 = *p_val2 = cl_hton32(val);
+ }
+}
+
+static void opts_parse_int32(IN osm_subn_t *p_subn, IN char *p_key,
+ IN char *p_val_str, void *p_v1, void *p_v2,
+ void (*pfn)(osm_subn_t *, void *))
+{
+ int32_t *p_val1 = p_v1, *p_val2 = p_v2;
+ int32_t val = strtol(p_val_str, NULL, 0);
+
+ if (val != *p_val1) {
+ log_config_value(p_key, "%d", val);
+ if (pfn)
+ pfn(p_subn, &val);
+ *p_val1 = *p_val2 = val;
+ }
+}
+
+static void opts_parse_uint16(IN osm_subn_t *p_subn, IN char *p_key,
+ IN char *p_val_str, void *p_v1, void *p_v2,
+ void (*pfn)(osm_subn_t *, void *))
+{
+ uint16_t *p_val1 = p_v1, *p_val2 = p_v2;
+ uint32_t tmp_val;
+
+ if (opts_strtoul(&tmp_val, p_val_str, p_key, UINT16_MAX))
+ return;
+
+ uint16_t val = (uint16_t) tmp_val;
+ if (val != *p_val1) {
+ log_config_value(p_key, "%u", val);
+ if (pfn)
+ pfn(p_subn, &val);
+ *p_val1 = *p_val2 = val;
+ }
+}
+
+static void opts_parse_net16(IN osm_subn_t *p_subn, IN char *p_key,
+ IN char *p_val_str, void *p_v1, void *p_v2,
+ void (*pfn)(osm_subn_t *, void *))
+{
+ uint16_t *p_val1 = p_v1, *p_val2 = p_v2;
+ uint32_t tmp_val;
+
+ if (opts_strtoul(&tmp_val, p_val_str, p_key, UINT16_MAX))
+ return;
+
+ uint16_t val = (uint16_t) tmp_val;
+ if (cl_hton16(val) != *p_val1) {
+ log_config_value(p_key, "0x%04x", val);
+ if (pfn)
+ pfn(p_subn, &val);
+ *p_val1 = *p_val2 = cl_hton16(val);
+ }
+}
+
+static void opts_parse_uint8(IN osm_subn_t *p_subn, IN char *p_key,
+ IN char *p_val_str, void *p_v1, void *p_v2,
+ void (*pfn)(osm_subn_t *, void *))
+{
+ uint8_t *p_val1 = p_v1, *p_val2 = p_v2;
+ uint32_t tmp_val;
+
+ if (opts_strtoul(&tmp_val, p_val_str, p_key, UINT8_MAX))
+ return;
+
+ uint8_t val = (uint8_t) tmp_val;
+ if (val != *p_val1) {
+ log_config_value(p_key, "%u", val);
+ if (pfn)
+ pfn(p_subn, &val);
+ *p_val1 = *p_val2 = val;
+ }
+}
+
+static void opts_parse_boolean(IN osm_subn_t *p_subn, IN char *p_key,
+ IN char *p_val_str, void *p_v1, void *p_v2,
+ void (*pfn)(osm_subn_t *, void *))
+{
+ boolean_t *p_val1 = p_v1, *p_val2 = p_v2;
+ boolean_t val;
+
+ if (!p_val_str)
+ return;
+
+ if (strcmp("TRUE", p_val_str))
+ val = FALSE;
+ else
+ val = TRUE;
+
+ if (val != *p_val1) {
+ log_config_value(p_key, "%s", p_val_str);
+ if (pfn)
+ pfn(p_subn, &val);
+ *p_val1 = *p_val2 = val;
+ }
+}
+
+static void opts_parse_charp(IN osm_subn_t *p_subn, IN char *p_key,
+ IN char *p_val_str, void *p_v1, void *p_v2,
+ void (*pfn)(osm_subn_t *, void *))
+{
+ char **p_val1 = p_v1, **p_val2 = p_v2;
+ const char *current_str = *p_val1 ? *p_val1 : null_str;
+
+ if (p_val_str && strcmp(p_val_str, current_str)) {
+ char *new;
+ log_config_value(p_key, "%s", p_val_str);
+ /* special case the "(null)" string */
+ new = strcmp(null_str, p_val_str) ? strdup(p_val_str) : NULL;
+ if (pfn)
+ pfn(p_subn, new);
+ if (*p_val1 && *p_val1 != *p_val2)
+ free(*p_val1);
+ if (*p_val2)
+ free(*p_val2);
+ *p_val1 = *p_val2 = new;
+ }
+}
+
+static void opts_parse_256bit(IN osm_subn_t *p_subn, IN char *p_key,
+ IN char *p_val_str, void *p_v1, void *p_v2,
+ void (*pfn)(osm_subn_t *, void *))
+{
+ uint8_t *p_val1 = p_v1, *p_val2 = p_v2;
+ uint8_t val[IB_CC_PORT_MASK_DATA_SIZE] = { 0 };
+ char tmpbuf[3] = { 0 };
+ uint8_t tmpint;
+ int numdigits = 0;
+ int startindex;
+ char *strptr = p_val_str;
+ char *ptr;
+ int i;
+
+ /* parse like it's hypothetically a 256 bit integer code
+ *
+ * store "big endian"
+ */
+
+ if (!strncmp(strptr, "0x", 2) || !strncmp(strptr, "0X", 2))
+ strptr+=2;
+
+ for (ptr = strptr; *ptr; ptr++) {
+ if (!isxdigit(*ptr)) {
+ log_report("invalid hex digit in bitmask\n");
+ return;
+ }
+ numdigits++;
+ }
+
+ if (!numdigits) {
+ log_report("invalid length bitmask\n");
+ return;
+ }
+
+ /* max of 2 hex chars per byte */
+ if (numdigits > IB_CC_PORT_MASK_DATA_SIZE * 2)
+ numdigits = IB_CC_PORT_MASK_DATA_SIZE * 2;
+
+ startindex = IB_CC_PORT_MASK_DATA_SIZE - ((numdigits - 1) / 2) - 1;
+
+ if (numdigits % 2) {
+ memcpy(tmpbuf, strptr, 1);
+ strptr += 1;
+ }
+ else {
+ memcpy(tmpbuf, strptr, 2);
+ strptr += 2;
+ }
+
+ tmpint = strtoul(tmpbuf, NULL, 16);
+ val[startindex] = tmpint;
+
+ for (i = (startindex + 1); i < IB_CC_PORT_MASK_DATA_SIZE; i++) {
+ memcpy(tmpbuf, strptr, 2);
+ strptr += 2;
+ tmpint = strtoul(tmpbuf, NULL, 16);
+ val[i] = tmpint;
+ }
+
+ if (memcmp(val, p_val1, IB_CC_PORT_MASK_DATA_SIZE)) {
+ log_config_value(p_key, "%s", p_val_str);
+ if (pfn)
+ pfn(p_subn, val);
+ memcpy(p_val1, val, IB_CC_PORT_MASK_DATA_SIZE);
+ memcpy(p_val2, val, IB_CC_PORT_MASK_DATA_SIZE);
+ }
+
+}
+
+static void opts_parse_cct_entry(IN osm_subn_t *p_subn, IN char *p_key,
+ IN char *p_val_str, void *p_v1, void *p_v2,
+ void (*pfn)(osm_subn_t *, void *))
+{
+ osm_cct_entry_t *p_cct1 = p_v1, *p_cct2 = p_v2;
+ osm_cct_entry_t cct;
+ char buf[512] = { 0 };
+ char *ptr;
+
+ strncpy(buf, p_val_str, 511);
+
+ if (!(ptr = strchr(buf, ':'))) {
+ log_report("invalid CCT entry\n");
+ return;
+ }
+
+ *ptr = '\0';
+ ptr++;
+
+ cct.shift = strtoul(buf, NULL, 0);
+ cct.multiplier = strtoul(ptr, NULL, 0);
+
+ if (cct.shift != p_cct1->shift
+ || cct.multiplier != p_cct1->multiplier) {
+ log_config_value(p_key, "%s", p_val_str);
+ if (pfn)
+ pfn(p_subn, &cct);
+ p_cct1->shift = p_cct2->shift = cct.shift;
+ p_cct1->multiplier = p_cct2->multiplier = cct.multiplier;
+ }
+}
+
+static void opts_parse_cc_cct(IN osm_subn_t *p_subn, IN char *p_key,
+ IN char *p_val_str, void *p_v1, void *p_v2,
+ void (*pfn)(osm_subn_t *, void *))
+{
+ osm_cct_t *p_val1 = p_v1, *p_val2 = p_v2;
+ const char *current_str = p_val1->input_str ? p_val1->input_str : null_str;
+
+ if (p_val_str && strcmp(p_val_str, current_str)) {
+ osm_cct_t newcct;
+ char *new;
+ unsigned int len = 0;
+ char *lasts;
+ char *tok;
+ char *ptr;
+
+ /* special case the "(null)" string */
+ new = strcmp(null_str, p_val_str) ? strdup(p_val_str) : NULL;
+
+ if (!new) {
+ log_config_value(p_key, "%s", p_val_str);
+ if (pfn)
+ pfn(p_subn, NULL);
+ memset(p_val1->entries, '\0', sizeof(p_val1->entries));
+ memset(p_val2->entries, '\0', sizeof(p_val2->entries));
+ p_val1->entries_len = p_val2->entries_len = 0;
+ p_val1->input_str = p_val2->input_str = NULL;
+ return;
+ }
+
+ memset(&newcct, '\0', sizeof(newcct));
+
+ tok = strtok_r(new, ",", &lasts);
+ while (tok && len < OSM_CCT_ENTRY_MAX) {
+
+ if (!(ptr = strchr(tok, ':'))) {
+ log_report("invalid CCT entry\n");
+ free(new);
+ return;
+ }
+ *ptr = '\0';
+ ptr++;
+
+ newcct.entries[len].shift = strtoul(tok, NULL, 0);
+ newcct.entries[len].multiplier = strtoul(ptr, NULL, 0);
+ len++;
+ tok = strtok_r(NULL, ",", &lasts);
+ }
+
+ free(new);
+
+ newcct.entries_len = len;
+ newcct.input_str = strdup(p_val_str);
+
+ log_config_value(p_key, "%s", p_val_str);
+ if (pfn)
+ pfn(p_subn, &newcct);
+ if (p_val1->input_str && p_val1->input_str != p_val2->input_str)
+ free(p_val1->input_str);
+ if (p_val2->input_str)
+ free(p_val2->input_str);
+ memcpy(p_val1->entries, newcct.entries, sizeof(newcct.entries));
+ memcpy(p_val2->entries, newcct.entries, sizeof(newcct.entries));
+ p_val1->entries_len = p_val2->entries_len = newcct.entries_len;
+ p_val1->input_str = p_val2->input_str = newcct.input_str;
+ }
+}
+
+static int parse_ca_cong_common(char *p_val_str, uint8_t *sl, unsigned int *val_offset) {
+ char *new, *lasts, *sl_str, *val_str;
+ uint8_t sltmp;
+
+ new = strcmp(null_str, p_val_str) ? strdup(p_val_str) : NULL;
+ if (!new)
+ return -1;
+
+ sl_str = strtok_r(new, " \t", &lasts);
+ val_str = strtok_r(NULL, " \t", &lasts);
+
+ if (!val_str) {
+ log_report("value must be specified in addition to SL\n");
+ free(new);
+ return -1;
+ }
+
+ sltmp = strtoul(sl_str, NULL, 0);
+ if (sltmp >= IB_CA_CONG_ENTRY_DATA_SIZE) {
+ log_report("invalid SL specified\n");
+ free(new);
+ return -1;
+ }
+
+ *sl = sltmp;
+ *val_offset = (unsigned int)(val_str - new);
+
+ free(new);
+ return 0;
+}
+
+static void opts_parse_ccti_timer(IN osm_subn_t *p_subn, IN char *p_key,
+ IN char *p_val_str, void *p_v1, void *p_v2,
+ void (*pfn)(osm_subn_t *, void *))
+{
+ osm_cacongestion_entry_t *p_val1 = p_v1, *p_val2 = p_v2;
+ unsigned int val_offset = 0;
+ uint8_t sl = 0;
+
+ if (parse_ca_cong_common(p_val_str, &sl, &val_offset) < 0)
+ return;
+
+ opts_parse_net16(p_subn, p_key, p_val_str + val_offset,
+ &p_val1[sl].ccti_timer,
+ &p_val2[sl].ccti_timer,
+ pfn);
+}
+
+static void opts_parse_ccti_increase(IN osm_subn_t *p_subn, IN char *p_key,
+ IN char *p_val_str, void *p_v1, void *p_v2,
+ void (*pfn)(osm_subn_t *, void *))
+{
+ osm_cacongestion_entry_t *p_val1 = p_v1, *p_val2 = p_v2;
+ unsigned int val_offset = 0;
+ uint8_t sl = 0;
+
+ if (parse_ca_cong_common(p_val_str, &sl, &val_offset) < 0)
+ return;
+
+ opts_parse_uint8(p_subn, p_key, p_val_str + val_offset,
+ &p_val1[sl].ccti_increase,
+ &p_val2[sl].ccti_increase,
+ pfn);
+}
+
+static void opts_parse_trigger_threshold(IN osm_subn_t *p_subn, IN char *p_key,
+ IN char *p_val_str, void *p_v1, void *p_v2,
+ void (*pfn)(osm_subn_t *, void *))
+{
+ osm_cacongestion_entry_t *p_val1 = p_v1, *p_val2 = p_v2;
+ unsigned int val_offset = 0;
+ uint8_t sl = 0;
+
+ if (parse_ca_cong_common(p_val_str, &sl, &val_offset) < 0)
+ return;
+
+ opts_parse_uint8(p_subn, p_key, p_val_str + val_offset,
+ &p_val1[sl].trigger_threshold,
+ &p_val2[sl].trigger_threshold,
+ pfn);
+}
+
+static void opts_parse_ccti_min(IN osm_subn_t *p_subn, IN char *p_key,
+ IN char *p_val_str, void *p_v1, void *p_v2,
+ void (*pfn)(osm_subn_t *, void *))
+{
+ osm_cacongestion_entry_t *p_val1 = p_v1, *p_val2 = p_v2;
+ unsigned int val_offset = 0;
+ uint8_t sl = 0;
+
+ if (parse_ca_cong_common(p_val_str, &sl, &val_offset) < 0)
+ return;
+
+ opts_parse_uint8(p_subn, p_key, p_val_str + val_offset,
+ &p_val1[sl].ccti_min,
+ &p_val2[sl].ccti_min,
+ pfn);
+}
+
+static const opt_rec_t opt_tbl[] = {
+ { "guid", OPT_OFFSET(guid), opts_parse_net64, NULL, 0 },
+ { "m_key", OPT_OFFSET(m_key), opts_parse_net64, NULL, 1 },
+ { "sm_key", OPT_OFFSET(sm_key), opts_parse_net64, NULL, 1 },
+ { "sa_key", OPT_OFFSET(sa_key), opts_parse_net64, NULL, 1 },
+ { "subnet_prefix", OPT_OFFSET(subnet_prefix), opts_parse_net64, NULL, 0 },
+ { "m_key_lease_period", OPT_OFFSET(m_key_lease_period), opts_parse_net16, NULL, 1 },
+ { "m_key_protection_level", OPT_OFFSET(m_key_protect_bits), opts_parse_uint8, NULL, 1 },
+ { "m_key_lookup", OPT_OFFSET(m_key_lookup), opts_parse_boolean, NULL, 1 },
+ { "sweep_interval", OPT_OFFSET(sweep_interval), opts_parse_uint32, NULL, 1 },
+ { "max_wire_smps", OPT_OFFSET(max_wire_smps), opts_parse_uint32, NULL, 1 },
+ { "max_wire_smps2", OPT_OFFSET(max_wire_smps2), opts_parse_uint32, NULL, 1 },
+ { "max_smps_timeout", OPT_OFFSET(max_smps_timeout), opts_parse_uint32, NULL, 1 },
+ { "console", OPT_OFFSET(console), opts_parse_charp, NULL, 0 },
+ { "console_port", OPT_OFFSET(console_port), opts_parse_uint16, NULL, 0 },
+ { "transaction_timeout", OPT_OFFSET(transaction_timeout), opts_parse_uint32, NULL, 0 },
+ { "transaction_retries", OPT_OFFSET(transaction_retries), opts_parse_uint32, NULL, 0 },
+ { "max_msg_fifo_timeout", OPT_OFFSET(max_msg_fifo_timeout), opts_parse_uint32, NULL, 1 },
+ { "sm_priority", OPT_OFFSET(sm_priority), opts_parse_uint8, opts_setup_sm_priority, 1 },
+ { "lmc", OPT_OFFSET(lmc), opts_parse_uint8, NULL, 0 },
+ { "lmc_esp0", OPT_OFFSET(lmc_esp0), opts_parse_boolean, NULL, 0 },
+ { "max_op_vls", OPT_OFFSET(max_op_vls), opts_parse_uint8, NULL, 1 },
+ { "force_link_speed", OPT_OFFSET(force_link_speed), opts_parse_uint8, NULL, 1 },
+ { "force_link_speed_ext", OPT_OFFSET(force_link_speed_ext), opts_parse_uint8, NULL, 1 },
+ { "fdr10", OPT_OFFSET(fdr10), opts_parse_uint8, NULL, 1 },
+ { "reassign_lids", OPT_OFFSET(reassign_lids), opts_parse_boolean, NULL, 1 },
+ { "ignore_other_sm", OPT_OFFSET(ignore_other_sm), opts_parse_boolean, NULL, 1 },
+ { "single_thread", OPT_OFFSET(single_thread), opts_parse_boolean, NULL, 0 },
+ { "disable_multicast", OPT_OFFSET(disable_multicast), opts_parse_boolean, NULL, 1 },
+ { "subnet_timeout", OPT_OFFSET(subnet_timeout), opts_parse_uint8, NULL, 1 },
+ { "packet_life_time", OPT_OFFSET(packet_life_time), opts_parse_uint8, NULL, 1 },
+ { "vl_stall_count", OPT_OFFSET(vl_stall_count), opts_parse_uint8, NULL, 1 },
+ { "leaf_vl_stall_count", OPT_OFFSET(leaf_vl_stall_count), opts_parse_uint8, NULL, 1 },
+ { "head_of_queue_lifetime", OPT_OFFSET(head_of_queue_lifetime), opts_parse_uint8, NULL, 1 },
+ { "leaf_head_of_queue_lifetime", OPT_OFFSET(leaf_head_of_queue_lifetime), opts_parse_uint8, NULL, 1 },
+ { "local_phy_errors_threshold", OPT_OFFSET(local_phy_errors_threshold), opts_parse_uint8, NULL, 1 },
+ { "overrun_errors_threshold", OPT_OFFSET(overrun_errors_threshold), opts_parse_uint8, NULL, 1 },
+ { "use_mfttop", OPT_OFFSET(use_mfttop), opts_parse_boolean, NULL, 1},
+ { "sminfo_polling_timeout", OPT_OFFSET(sminfo_polling_timeout), opts_parse_uint32, opts_setup_sminfo_polling_timeout, 1 },
+ { "polling_retry_number", OPT_OFFSET(polling_retry_number), opts_parse_uint32, NULL, 1 },
+ { "force_heavy_sweep", OPT_OFFSET(force_heavy_sweep), opts_parse_boolean, NULL, 1 },
+ { "port_prof_ignore_file", OPT_OFFSET(port_prof_ignore_file), opts_parse_charp, NULL, 0 },
+ { "hop_weights_file", OPT_OFFSET(hop_weights_file), opts_parse_charp, NULL, 0 },
+ { "dimn_ports_file", OPT_OFFSET(port_search_ordering_file), opts_parse_charp, NULL, 0 },
+ { "port_search_ordering_file", OPT_OFFSET(port_search_ordering_file), opts_parse_charp, NULL, 0 },
+ { "port_profile_switch_nodes", OPT_OFFSET(port_profile_switch_nodes), opts_parse_boolean, NULL, 1 },
+ { "sweep_on_trap", OPT_OFFSET(sweep_on_trap), opts_parse_boolean, NULL, 1 },
+ { "routing_engine", OPT_OFFSET(routing_engine_names), opts_parse_charp, NULL, 0 },
+ { "connect_roots", OPT_OFFSET(connect_roots), opts_parse_boolean, NULL, 1 },
+ { "use_ucast_cache", OPT_OFFSET(use_ucast_cache), opts_parse_boolean, NULL, 0 },
+ { "log_file", OPT_OFFSET(log_file), opts_parse_charp, NULL, 0 },
+ { "log_max_size", OPT_OFFSET(log_max_size), opts_parse_uint32, opts_setup_log_max_size, 1 },
+ { "log_flags", OPT_OFFSET(log_flags), opts_parse_uint8, opts_setup_log_flags, 1 },
+ { "force_log_flush", OPT_OFFSET(force_log_flush), opts_parse_boolean, opts_setup_force_log_flush, 1 },
+ { "accum_log_file", OPT_OFFSET(accum_log_file), opts_parse_boolean, opts_setup_accum_log_file, 1 },
+ { "partition_config_file", OPT_OFFSET(partition_config_file), opts_parse_charp, NULL, 0 },
+ { "no_partition_enforcement", OPT_OFFSET(no_partition_enforcement), opts_parse_boolean, NULL, 1 },
+ { "part_enforce", OPT_OFFSET(part_enforce), opts_parse_charp, NULL, 1 },
+ { "allow_both_pkeys", OPT_OFFSET(allow_both_pkeys), opts_parse_boolean, NULL, 0 },
+ { "sm_assigned_guid", OPT_OFFSET(sm_assigned_guid), opts_parse_uint8, NULL, 1 },
+ { "qos", OPT_OFFSET(qos), opts_parse_boolean, NULL, 1 },
+ { "qos_policy_file", OPT_OFFSET(qos_policy_file), opts_parse_charp, NULL, 0 },
+ { "suppress_sl2vl_mad_status_errors", OPT_OFFSET(suppress_sl2vl_mad_status_errors), opts_parse_boolean, NULL, 1 },
+ { "dump_files_dir", OPT_OFFSET(dump_files_dir), opts_parse_charp, NULL, 0 },
+ { "lid_matrix_dump_file", OPT_OFFSET(lid_matrix_dump_file), opts_parse_charp, NULL, 0 },
+ { "lfts_file", OPT_OFFSET(lfts_file), opts_parse_charp, NULL, 0 },
+ { "root_guid_file", OPT_OFFSET(root_guid_file), opts_parse_charp, NULL, 0 },
+ { "cn_guid_file", OPT_OFFSET(cn_guid_file), opts_parse_charp, NULL, 0 },
+ { "io_guid_file", OPT_OFFSET(io_guid_file), opts_parse_charp, NULL, 0 },
+ { "port_shifting", OPT_OFFSET(port_shifting), opts_parse_boolean, NULL, 1 },
+ { "scatter_ports", OPT_OFFSET(scatter_ports), opts_parse_uint32, NULL, 1 },
+ { "max_reverse_hops", OPT_OFFSET(max_reverse_hops), opts_parse_uint16, NULL, 0 },
+ { "ids_guid_file", OPT_OFFSET(ids_guid_file), opts_parse_charp, NULL, 0 },
+ { "guid_routing_order_file", OPT_OFFSET(guid_routing_order_file), opts_parse_charp, NULL, 0 },
+ { "guid_routing_order_no_scatter", OPT_OFFSET(guid_routing_order_no_scatter), opts_parse_boolean, NULL, 0 },
+ { "sa_db_file", OPT_OFFSET(sa_db_file), opts_parse_charp, NULL, 0 },
+ { "sa_db_dump", OPT_OFFSET(sa_db_dump), opts_parse_boolean, NULL, 1 },
+ { "torus_config", OPT_OFFSET(torus_conf_file), opts_parse_charp, NULL, 1 },
+ { "do_mesh_analysis", OPT_OFFSET(do_mesh_analysis), opts_parse_boolean, NULL, 1 },
+ { "exit_on_fatal", OPT_OFFSET(exit_on_fatal), opts_parse_boolean, NULL, 1 },
+ { "honor_guid2lid_file", OPT_OFFSET(honor_guid2lid_file), opts_parse_boolean, NULL, 1 },
+ { "daemon", OPT_OFFSET(daemon), opts_parse_boolean, NULL, 0 },
+ { "sm_inactive", OPT_OFFSET(sm_inactive), opts_parse_boolean, NULL, 1 },
+ { "babbling_port_policy", OPT_OFFSET(babbling_port_policy), opts_parse_boolean, NULL, 1 },
+ { "drop_event_subscriptions", OPT_OFFSET(drop_event_subscriptions), opts_parse_boolean, NULL, 1 },
+ { "ipoib_mcgroup_creation_validation", OPT_OFFSET(ipoib_mcgroup_creation_validation), opts_parse_boolean, NULL, 1 },
+ { "mcgroup_join_validation", OPT_OFFSET(mcgroup_join_validation), opts_parse_boolean, NULL, 1 },
+ { "use_optimized_slvl", OPT_OFFSET(use_optimized_slvl), opts_parse_boolean, NULL, 1 },
+ { "fsync_high_avail_files", OPT_OFFSET(fsync_high_avail_files), opts_parse_boolean, NULL, 1 },
+#ifdef ENABLE_OSM_PERF_MGR
+ { "perfmgr", OPT_OFFSET(perfmgr), opts_parse_boolean, NULL, 0 },
+ { "perfmgr_redir", OPT_OFFSET(perfmgr_redir), opts_parse_boolean, NULL, 0 },
+ { "perfmgr_sweep_time_s", OPT_OFFSET(perfmgr_sweep_time_s), opts_parse_uint16, NULL, 0 },
+ { "perfmgr_max_outstanding_queries", OPT_OFFSET(perfmgr_max_outstanding_queries), opts_parse_uint32, NULL, 0 },
+ { "perfmgr_ignore_cas", OPT_OFFSET(perfmgr_ignore_cas), opts_parse_boolean, NULL, 0 },
+ { "event_db_dump_file", OPT_OFFSET(event_db_dump_file), opts_parse_charp, NULL, 0 },
+ { "perfmgr_rm_nodes", OPT_OFFSET(perfmgr_rm_nodes), opts_parse_boolean, NULL, 0 },
+ { "perfmgr_log_errors", OPT_OFFSET(perfmgr_log_errors), opts_parse_boolean, NULL, 0 },
+ { "perfmgr_query_cpi", OPT_OFFSET(perfmgr_query_cpi), opts_parse_boolean, NULL, 0 },
+ { "perfmgr_xmit_wait_log", OPT_OFFSET(perfmgr_xmit_wait_log), opts_parse_boolean, NULL, 0 },
+ { "perfmgr_xmit_wait_threshold", OPT_OFFSET(perfmgr_xmit_wait_threshold), opts_parse_uint32, NULL, 0 },
+#endif /* ENABLE_OSM_PERF_MGR */
+ { "event_plugin_name", OPT_OFFSET(event_plugin_name), opts_parse_charp, NULL, 0 },
+ { "event_plugin_options", OPT_OFFSET(event_plugin_options), opts_parse_charp, NULL, 0 },
+ { "node_name_map_name", OPT_OFFSET(node_name_map_name), opts_parse_charp, NULL, 0 },
+ { "qos_max_vls", OPT_OFFSET(qos_options.max_vls), opts_parse_uint32, NULL, 1 },
+ { "qos_high_limit", OPT_OFFSET(qos_options.high_limit), opts_parse_int32, NULL, 1 },
+ { "qos_vlarb_high", OPT_OFFSET(qos_options.vlarb_high), opts_parse_charp, NULL, 1 },
+ { "qos_vlarb_low", OPT_OFFSET(qos_options.vlarb_low), opts_parse_charp, NULL, 1 },
+ { "qos_sl2vl", OPT_OFFSET(qos_options.sl2vl), opts_parse_charp, NULL, 1 },
+ { "qos_ca_max_vls", OPT_OFFSET(qos_ca_options.max_vls), opts_parse_uint32, NULL, 1 },
+ { "qos_ca_high_limit", OPT_OFFSET(qos_ca_options.high_limit), opts_parse_int32, NULL, 1 },
+ { "qos_ca_vlarb_high", OPT_OFFSET(qos_ca_options.vlarb_high), opts_parse_charp, NULL, 1 },
+ { "qos_ca_vlarb_low", OPT_OFFSET(qos_ca_options.vlarb_low), opts_parse_charp, NULL, 1 },
+ { "qos_ca_sl2vl", OPT_OFFSET(qos_ca_options.sl2vl), opts_parse_charp, NULL, 1 },
+ { "qos_sw0_max_vls", OPT_OFFSET(qos_sw0_options.max_vls), opts_parse_uint32, NULL, 1 },
+ { "qos_sw0_high_limit", OPT_OFFSET(qos_sw0_options.high_limit), opts_parse_int32, NULL, 1 },
+ { "qos_sw0_vlarb_high", OPT_OFFSET(qos_sw0_options.vlarb_high), opts_parse_charp, NULL, 1 },
+ { "qos_sw0_vlarb_low", OPT_OFFSET(qos_sw0_options.vlarb_low), opts_parse_charp, NULL, 1 },
+ { "qos_sw0_sl2vl", OPT_OFFSET(qos_sw0_options.sl2vl), opts_parse_charp, NULL, 1 },
+ { "qos_swe_max_vls", OPT_OFFSET(qos_swe_options.max_vls), opts_parse_uint32, NULL, 1 },
+ { "qos_swe_high_limit", OPT_OFFSET(qos_swe_options.high_limit), opts_parse_int32, NULL, 1 },
+ { "qos_swe_vlarb_high", OPT_OFFSET(qos_swe_options.vlarb_high), opts_parse_charp, NULL, 1 },
+ { "qos_swe_vlarb_low", OPT_OFFSET(qos_swe_options.vlarb_low), opts_parse_charp, NULL, 1 },
+ { "qos_swe_sl2vl", OPT_OFFSET(qos_swe_options.sl2vl), opts_parse_charp, NULL, 1 },
+ { "qos_rtr_max_vls", OPT_OFFSET(qos_rtr_options.max_vls), opts_parse_uint32, NULL, 1 },
+ { "qos_rtr_high_limit", OPT_OFFSET(qos_rtr_options.high_limit), opts_parse_int32, NULL, 1 },
+ { "qos_rtr_vlarb_high", OPT_OFFSET(qos_rtr_options.vlarb_high), opts_parse_charp, NULL, 1 },
+ { "qos_rtr_vlarb_low", OPT_OFFSET(qos_rtr_options.vlarb_low), opts_parse_charp, NULL, 1 },
+ { "qos_rtr_sl2vl", OPT_OFFSET(qos_rtr_options.sl2vl), opts_parse_charp, NULL, 1 },
+ { "congestion_control", OPT_OFFSET(congestion_control), opts_parse_boolean, NULL, 1 },
+ { "cc_key", OPT_OFFSET(cc_key), opts_parse_net64, NULL, 0},
+ { "cc_max_outstanding_mads", OPT_OFFSET(cc_max_outstanding_mads), opts_parse_uint32, NULL, 0 },
+ { "cc_sw_cong_setting_control_map", OPT_OFFSET(cc_sw_cong_setting_control_map), opts_parse_net32, NULL, 1},
+ { "cc_sw_cong_setting_victim_mask", OPT_OFFSET(cc_sw_cong_setting_victim_mask), opts_parse_256bit, NULL, 1},
+ { "cc_sw_cong_setting_credit_mask", OPT_OFFSET(cc_sw_cong_setting_credit_mask), opts_parse_256bit, NULL, 1},
+ { "cc_sw_cong_setting_threshold", OPT_OFFSET(cc_sw_cong_setting_threshold), opts_parse_uint8, NULL, 1},
+ { "cc_sw_cong_setting_packet_size", OPT_OFFSET(cc_sw_cong_setting_packet_size), opts_parse_uint8, NULL, 1},
+ { "cc_sw_cong_setting_credit_starvation_threshold", OPT_OFFSET(cc_sw_cong_setting_credit_starvation_threshold), opts_parse_uint8, NULL, 1},
+ { "cc_sw_cong_setting_credit_starvation_return_delay", OPT_OFFSET(cc_sw_cong_setting_credit_starvation_return_delay), opts_parse_cct_entry, NULL, 1},
+ { "cc_sw_cong_setting_marking_rate", OPT_OFFSET(cc_sw_cong_setting_marking_rate), opts_parse_net16, NULL, 1},
+ { "cc_ca_cong_setting_port_control", OPT_OFFSET(cc_ca_cong_setting_port_control), opts_parse_net16, NULL, 1},
+ { "cc_ca_cong_setting_control_map", OPT_OFFSET(cc_ca_cong_setting_control_map), opts_parse_net16, NULL, 1},
+ { "cc_ca_cong_setting_ccti_timer", OPT_OFFSET(cc_ca_cong_entries), opts_parse_ccti_timer, NULL, 1},
+ { "cc_ca_cong_setting_ccti_increase", OPT_OFFSET(cc_ca_cong_entries), opts_parse_ccti_increase, NULL, 1},
+ { "cc_ca_cong_setting_trigger_threshold", OPT_OFFSET(cc_ca_cong_entries), opts_parse_trigger_threshold, NULL, 1},
+ { "cc_ca_cong_setting_ccti_min", OPT_OFFSET(cc_ca_cong_entries), opts_parse_ccti_min, NULL, 1},
+ { "cc_cct", OPT_OFFSET(cc_cct), opts_parse_cc_cct, NULL, 1},
+ { "enable_quirks", OPT_OFFSET(enable_quirks), opts_parse_boolean, NULL, 1 },
+ { "no_clients_rereg", OPT_OFFSET(no_clients_rereg), opts_parse_boolean, NULL, 1 },
+ { "prefix_routes_file", OPT_OFFSET(prefix_routes_file), opts_parse_charp, NULL, 0 },
+ { "consolidate_ipv6_snm_req", OPT_OFFSET(consolidate_ipv6_snm_req), opts_parse_boolean, NULL, 1 },
+ { "lash_start_vl", OPT_OFFSET(lash_start_vl), opts_parse_uint8, NULL, 1 },
+ { "sm_sl", OPT_OFFSET(sm_sl), opts_parse_uint8, NULL, 1 },
+ { "log_prefix", OPT_OFFSET(log_prefix), opts_parse_charp, NULL, 1 },
+ { "per_module_logging_file", OPT_OFFSET(per_module_logging_file), opts_parse_charp, NULL, 0 },
+ { "quasi_ftree_indexing", OPT_OFFSET(quasi_ftree_indexing), opts_parse_boolean, NULL, 1 },
+ {0}
+};
+
+static int compar_mgids(const void *m1, const void *m2)
+{
+ return memcmp(m1, m2, sizeof(ib_gid_t));
+}
+
+static void subn_validate_g2m(osm_subn_t *p_subn)
+{
+ cl_qlist_t guids;
+ osm_db_guid_elem_t *p_item;
+ uint64_t mkey;
+ boolean_t valid_entry;
+
+ OSM_LOG_ENTER(&(p_subn->p_osm->log));
+ cl_qlist_init(&guids);
+
+ if (osm_db_guid2mkey_guids(p_subn->p_g2m, &guids)) {
+ OSM_LOG(&(p_subn->p_osm->log), OSM_LOG_ERROR, "ERR 7506: "
+ "could not get mkey guid list\n");
+ goto Exit;
+ }
+
+ while ((p_item = (osm_db_guid_elem_t *) cl_qlist_remove_head(&guids))
+ != (osm_db_guid_elem_t *) cl_qlist_end(&guids)) {
+ valid_entry = TRUE;
+
+ if (p_item->guid == 0) {
+ OSM_LOG(&(p_subn->p_osm->log), OSM_LOG_ERROR,
+ "ERR 7507: found invalid zero guid");
+ valid_entry = FALSE;
+ } else if (osm_db_guid2mkey_get(p_subn->p_g2m, p_item->guid,
+ &mkey)) {
+ OSM_LOG(&(p_subn->p_osm->log), OSM_LOG_ERROR,
+ "ERR 7508: could not get mkey for guid:0x%016"
+ PRIx64 "\n", p_item->guid);
+ valid_entry = FALSE;
+ }
+
+ if (valid_entry == FALSE) {
+ if (osm_db_guid2mkey_delete(p_subn->p_g2m,
+ p_item->guid))
+ OSM_LOG(&(p_subn->p_osm->log), OSM_LOG_ERROR,
+ "ERR 7509: failed to delete entry for "
+ "guid:0x%016" PRIx64 "\n",
+ p_item->guid);
+ }
+ free(p_item);
+ }
+
+Exit:
+ OSM_LOG_EXIT(&(p_subn->p_osm->log));
+}
+
+static void subn_validate_neighbor(osm_subn_t *p_subn)
+{
+ cl_qlist_t entries;
+ osm_db_neighbor_elem_t *p_item;
+ boolean_t valid_entry;
+ uint64_t guid;
+ uint8_t port;
+
+ OSM_LOG_ENTER(&(p_subn->p_osm->log));
+ cl_qlist_init(&entries);
+
+ if (osm_db_neighbor_guids(p_subn->p_neighbor, &entries)) {
+ OSM_LOG(&(p_subn->p_osm->log), OSM_LOG_ERROR, "ERR 7512: "
+ "could not get neighbor entry list\n");
+ goto Exit;
+ }
+
+ while ((p_item =
+ (osm_db_neighbor_elem_t *) cl_qlist_remove_head(&entries))
+ != (osm_db_neighbor_elem_t *) cl_qlist_end(&entries)) {
+ valid_entry = TRUE;
+
+ OSM_LOG(&(p_subn->p_osm->log), OSM_LOG_DEBUG,
+ "Validating neighbor for guid:0x%016" PRIx64
+ ", port %d\n",
+ p_item->guid, p_item->portnum);
+ if (p_item->guid == 0) {
+ OSM_LOG(&(p_subn->p_osm->log), OSM_LOG_ERROR,
+ "ERR 7513: found invalid zero guid\n");
+ valid_entry = FALSE;
+ } else if (p_item->portnum == 0) {
+ OSM_LOG(&(p_subn->p_osm->log), OSM_LOG_ERROR,
+ "ERR 7514: found invalid zero port for "
+ "guid: 0x%016" PRIx64 "\n",
+ p_item->guid);
+ valid_entry = FALSE;
+ } else if (osm_db_neighbor_get(p_subn->p_neighbor,
+ p_item->guid, p_item->portnum,
+ &guid, &port)) {
+ OSM_LOG(&(p_subn->p_osm->log), OSM_LOG_ERROR,
+ "ERR 7515: could not find neighbor for "
+ "guid: 0x%016" PRIx64 ", port %d\n",
+ p_item->guid, p_item->portnum);
+ valid_entry = FALSE;
+ } else if (guid == 0) {
+ OSM_LOG(&(p_subn->p_osm->log), OSM_LOG_ERROR,
+ "ERR 7516: found invalid neighbor "
+ "zero guid for guid: 0x%016" PRIx64
+ ", port %d\n",
+ p_item->guid, p_item->portnum);
+ valid_entry = FALSE;
+ } else if (port == 0) {
+ OSM_LOG(&(p_subn->p_osm->log), OSM_LOG_ERROR,
+ "ERR 7517: found invalid neighbor "
+ "zero port for guid: 0x%016" PRIx64
+ ", port %d\n",
+ p_item->guid, p_item->portnum);
+ valid_entry = FALSE;
+ } else if (osm_db_neighbor_get(p_subn->p_neighbor,
+ guid, port, &guid, &port) ||
+ guid != p_item->guid || port != p_item->portnum) {
+ OSM_LOG(&(p_subn->p_osm->log), OSM_LOG_ERROR,
+ "ERR 7518: neighbor does not point "
+ "back at us (guid: 0x%016" PRIx64
+ ", port %d)\n",
+ p_item->guid, p_item->portnum);
+ valid_entry = FALSE;
+ }
+
+ if (valid_entry == FALSE) {
+ if (osm_db_neighbor_delete(p_subn->p_neighbor,
+ p_item->guid,
+ p_item->portnum))
+ OSM_LOG(&(p_subn->p_osm->log), OSM_LOG_ERROR,
+ "ERR 7519: failed to delete entry for "
+ "guid:0x%016" PRIx64 " port:%u\n",
+ p_item->guid, p_item->portnum);
+ }
+ free(p_item);
+ }
+
+Exit:
+ OSM_LOG_EXIT(&(p_subn->p_osm->log));
+}
+
+void osm_subn_construct(IN osm_subn_t * p_subn)
+{
+ memset(p_subn, 0, sizeof(*p_subn));
+ cl_ptr_vector_construct(&p_subn->port_lid_tbl);
+ cl_qmap_init(&p_subn->sw_guid_tbl);
+ cl_qmap_init(&p_subn->node_guid_tbl);
+ cl_qmap_init(&p_subn->port_guid_tbl);
+ cl_qmap_init(&p_subn->alias_port_guid_tbl);
+ cl_qmap_init(&p_subn->assigned_guids_tbl);
+ cl_qmap_init(&p_subn->sm_guid_tbl);
+ cl_qlist_init(&p_subn->sa_sr_list);
+ cl_qlist_init(&p_subn->sa_infr_list);
+ cl_qlist_init(&p_subn->alias_guid_list);
+ cl_qlist_init(&p_subn->prefix_routes_list);
+ cl_qmap_init(&p_subn->rtr_guid_tbl);
+ cl_qmap_init(&p_subn->prtn_pkey_tbl);
+ cl_fmap_init(&p_subn->mgrp_mgid_tbl, compar_mgids);
+}
+
+static void subn_destroy_qos_options(osm_qos_options_t *opt)
+{
+ free(opt->vlarb_high);
+ free(opt->vlarb_low);
+ free(opt->sl2vl);
+}
+
+static void subn_opt_destroy(IN osm_subn_opt_t * p_opt)
+{
+ free(p_opt->console);
+ free(p_opt->port_prof_ignore_file);
+ free(p_opt->hop_weights_file);
+ free(p_opt->port_search_ordering_file);
+ free(p_opt->routing_engine_names);
+ free(p_opt->log_file);
+ free(p_opt->partition_config_file);
+ free(p_opt->qos_policy_file);
+ free(p_opt->dump_files_dir);
+ free(p_opt->part_enforce);
+ free(p_opt->lid_matrix_dump_file);
+ free(p_opt->lfts_file);
+ free(p_opt->root_guid_file);
+ free(p_opt->cn_guid_file);
+ free(p_opt->io_guid_file);
+ free(p_opt->ids_guid_file);
+ free(p_opt->guid_routing_order_file);
+ free(p_opt->sa_db_file);
+ free(p_opt->torus_conf_file);
+#ifdef ENABLE_OSM_PERF_MGR
+ free(p_opt->event_db_dump_file);
+#endif /* ENABLE_OSM_PERF_MGR */
+ free(p_opt->event_plugin_name);
+ free(p_opt->event_plugin_options);
+ free(p_opt->node_name_map_name);
+ free(p_opt->prefix_routes_file);
+ free(p_opt->log_prefix);
+ subn_destroy_qos_options(&p_opt->qos_options);
+ subn_destroy_qos_options(&p_opt->qos_ca_options);
+ subn_destroy_qos_options(&p_opt->qos_sw0_options);
+ subn_destroy_qos_options(&p_opt->qos_swe_options);
+ subn_destroy_qos_options(&p_opt->qos_rtr_options);
+ free(p_opt->cc_cct.input_str);
+}
+
+void osm_subn_destroy(IN osm_subn_t * p_subn)
+{
+ int i;
+ osm_node_t *p_node, *p_next_node;
+ osm_assigned_guids_t *p_assigned_guids, *p_next_assigned_guids;
+ osm_alias_guid_t *p_alias_guid, *p_next_alias_guid;
+ osm_port_t *p_port, *p_next_port;
+ osm_switch_t *p_sw, *p_next_sw;
+ osm_remote_sm_t *p_rsm, *p_next_rsm;
+ osm_prtn_t *p_prtn, *p_next_prtn;
+ osm_infr_t *p_infr, *p_next_infr;
+ osm_svcr_t *p_svcr, *p_next_svcr;
+
+ /* it might be a good idea to de-allocate all known objects */
+ p_next_node = (osm_node_t *) cl_qmap_head(&p_subn->node_guid_tbl);
+ while (p_next_node !=
+ (osm_node_t *) cl_qmap_end(&p_subn->node_guid_tbl)) {
+ p_node = p_next_node;
+ p_next_node = (osm_node_t *) cl_qmap_next(&p_node->map_item);
+ osm_node_delete(&p_node);
+ }
+
+ p_next_assigned_guids = (osm_assigned_guids_t *) cl_qmap_head(&p_subn->assigned_guids_tbl);
+ while (p_next_assigned_guids !=
+ (osm_assigned_guids_t *) cl_qmap_end(&p_subn->assigned_guids_tbl)) {
+ p_assigned_guids = p_next_assigned_guids;
+ p_next_assigned_guids = (osm_assigned_guids_t *) cl_qmap_next(&p_assigned_guids->map_item);
+ osm_assigned_guids_delete(&p_assigned_guids);
+ }
+
+ p_next_alias_guid = (osm_alias_guid_t *) cl_qmap_head(&p_subn->alias_port_guid_tbl);
+ while (p_next_alias_guid !=
+ (osm_alias_guid_t *) cl_qmap_end(&p_subn->alias_port_guid_tbl)) {
+ p_alias_guid = p_next_alias_guid;
+ p_next_alias_guid = (osm_alias_guid_t *) cl_qmap_next(&p_alias_guid->map_item);
+ osm_alias_guid_delete(&p_alias_guid);
+ }
+
+ while (cl_qlist_count(&p_subn->alias_guid_list))
+ osm_guid_work_obj_delete((osm_guidinfo_work_obj_t *) cl_qlist_remove_head(&p_subn->alias_guid_list));
+
+ p_next_port = (osm_port_t *) cl_qmap_head(&p_subn->port_guid_tbl);
+ while (p_next_port !=
+ (osm_port_t *) cl_qmap_end(&p_subn->port_guid_tbl)) {
+ p_port = p_next_port;
+ p_next_port = (osm_port_t *) cl_qmap_next(&p_port->map_item);
+ osm_port_delete(&p_port);
+ }
+
+ p_next_sw = (osm_switch_t *) cl_qmap_head(&p_subn->sw_guid_tbl);
+ while (p_next_sw != (osm_switch_t *) cl_qmap_end(&p_subn->sw_guid_tbl)) {
+ p_sw = p_next_sw;
+ p_next_sw = (osm_switch_t *) cl_qmap_next(&p_sw->map_item);
+ osm_switch_delete(&p_sw);
+ }
+
+ p_next_rsm = (osm_remote_sm_t *) cl_qmap_head(&p_subn->sm_guid_tbl);
+ while (p_next_rsm !=
+ (osm_remote_sm_t *) cl_qmap_end(&p_subn->sm_guid_tbl)) {
+ p_rsm = p_next_rsm;
+ p_next_rsm = (osm_remote_sm_t *) cl_qmap_next(&p_rsm->map_item);
+ free(p_rsm);
+ }
+
+ p_next_prtn = (osm_prtn_t *) cl_qmap_head(&p_subn->prtn_pkey_tbl);
+ while (p_next_prtn !=
+ (osm_prtn_t *) cl_qmap_end(&p_subn->prtn_pkey_tbl)) {
+ p_prtn = p_next_prtn;
+ p_next_prtn = (osm_prtn_t *) cl_qmap_next(&p_prtn->map_item);
+ osm_prtn_delete(p_subn, &p_prtn);
+ }
+
+ cl_fmap_remove_all(&p_subn->mgrp_mgid_tbl);
+
+ for (i = 0; i <= p_subn->max_mcast_lid_ho - IB_LID_MCAST_START_HO;
+ i++)
+ if (p_subn->mboxes[i])
+ osm_mgrp_box_delete(p_subn->mboxes[i]);
+
+ p_next_infr = (osm_infr_t *) cl_qlist_head(&p_subn->sa_infr_list);
+ while (p_next_infr !=
+ (osm_infr_t *) cl_qlist_end(&p_subn->sa_infr_list)) {
+ p_infr = p_next_infr;
+ p_next_infr = (osm_infr_t *) cl_qlist_next(&p_infr->list_item);
+ osm_infr_delete(p_infr);
+ }
+
+ p_next_svcr = (osm_svcr_t *) cl_qlist_head(&p_subn->sa_sr_list);
+ while (p_next_svcr !=
+ (osm_svcr_t *) cl_qlist_end(&p_subn->sa_sr_list)) {
+ p_svcr = p_next_svcr;
+ p_next_svcr = (osm_svcr_t *) cl_qlist_next(&p_svcr->list_item);
+ osm_svcr_delete(p_svcr);
+ }
+
+ cl_ptr_vector_destroy(&p_subn->port_lid_tbl);
+
+ osm_qos_policy_destroy(p_subn->p_qos_policy);
+
+ while (!cl_is_qlist_empty(&p_subn->prefix_routes_list)) {
+ cl_list_item_t *item = cl_qlist_remove_head(&p_subn->prefix_routes_list);
+ free(item);
+ }
+
+ subn_opt_destroy(&p_subn->opt);
+ free(p_subn->opt.file_opts);
+}
+
+ib_api_status_t osm_subn_init(IN osm_subn_t * p_subn, IN osm_opensm_t * p_osm,
+ IN const osm_subn_opt_t * p_opt)
+{
+ cl_status_t status;
+
+ p_subn->p_osm = p_osm;
+
+ status = cl_ptr_vector_init(&p_subn->port_lid_tbl,
+ OSM_SUBNET_VECTOR_MIN_SIZE,
+ OSM_SUBNET_VECTOR_GROW_SIZE);
+ if (status != CL_SUCCESS)
+ return status;
+
+ status = cl_ptr_vector_set_capacity(&p_subn->port_lid_tbl,
+ OSM_SUBNET_VECTOR_CAPACITY);
+ if (status != CL_SUCCESS)
+ return status;
+
+ /*
+ LID zero is not valid. NULL out this entry for the
+ convenience of other code.
+ */
+ cl_ptr_vector_set(&p_subn->port_lid_tbl, 0, NULL);
+
+ p_subn->opt = *p_opt;
+ p_subn->max_ucast_lid_ho = IB_LID_UCAST_END_HO;
+ p_subn->max_mcast_lid_ho = IB_LID_MCAST_END_HO;
+ p_subn->min_ca_mtu = IB_MAX_MTU;
+ p_subn->min_ca_rate = IB_PATH_RECORD_RATE_300_GBS;
+ p_subn->min_data_vls = IB_MAX_NUM_VLS - 1;
+ p_subn->min_sw_data_vls = IB_MAX_NUM_VLS - 1;
+ p_subn->ignore_existing_lfts = TRUE;
+
+ /* we assume master by default - so we only need to set it true if STANDBY */
+ p_subn->coming_out_of_standby = FALSE;
+ p_subn->sweeping_enabled = TRUE;
+ p_subn->last_sm_port_state = 1;
+
+ /* Initialize the guid2mkey database */
+ p_subn->p_g2m = osm_db_domain_init(&(p_osm->db), "guid2mkey");
+ if (!p_subn->p_g2m) {
+ OSM_LOG(&(p_osm->log), OSM_LOG_ERROR, "ERR 7510: "
+ "Error initializing Guid-to-MKey persistent database\n");
+ return IB_ERROR;
+ }
+
+ if (osm_db_restore(p_subn->p_g2m)) {
+#ifndef __WIN__
+ /*
+ * When Windows is BSODing, it might corrupt files that
+ * were previously opened for writing, even if the files
+ * are closed, so we might see corrupted guid2mkey file.
+ */
+ if (p_subn->opt.exit_on_fatal) {
+ osm_log(&(p_osm->log), OSM_LOG_SYS,
+ "FATAL: Error restoring Guid-to-Mkey "
+ "persistent database\n");
+ return IB_ERROR;
+ } else
+#endif
+ OSM_LOG(&(p_osm->log), OSM_LOG_ERROR,
+ "ERR 7511: Error restoring Guid-to-Mkey "
+ "persistent database\n");
+ }
+
+ subn_validate_g2m(p_subn);
+
+ /* Initialize the neighbor database */
+ p_subn->p_neighbor = osm_db_domain_init(&(p_osm->db), "neighbors");
+ if (!p_subn->p_neighbor) {
+ OSM_LOG(&(p_osm->log), OSM_LOG_ERROR, "ERR 7520: Error "
+ "initializing neighbor link persistent database\n");
+ return IB_ERROR;
+ }
+
+ if (osm_db_restore(p_subn->p_neighbor)) {
+#ifndef __WIN__
+ /*
+ * When Windows is BSODing, it might corrupt files that
+ * were previously opened for writing, even if the files
+ * are closed, so we might see corrupted neighbors file.
+ */
+ if (p_subn->opt.exit_on_fatal) {
+ osm_log(&(p_osm->log), OSM_LOG_SYS,
+ "FATAL: Error restoring neighbor link "
+ "persistent database\n");
+ return IB_ERROR;
+ } else
+#endif
+ OSM_LOG(&(p_osm->log), OSM_LOG_ERROR,
+ "ERR 7521: Error restoring neighbor link "
+ "persistent database\n");
+ }
+
+ subn_validate_neighbor(p_subn);
+
+ return IB_SUCCESS;
+}
+
+osm_port_t *osm_get_port_by_mad_addr(IN osm_log_t * p_log,
+ IN const osm_subn_t * p_subn,
+ IN osm_mad_addr_t * p_mad_addr)
+{
+ osm_port_t *port = osm_get_port_by_lid(p_subn, p_mad_addr->dest_lid);
+ if (!port)
+ OSM_LOG(p_log, OSM_LOG_ERROR, "ERR 7504: "
+ "Lid is out of range: %u\n",
+ cl_ntoh16(p_mad_addr->dest_lid));
+
+ return port;
+}
+
+ib_api_status_t osm_get_gid_by_mad_addr(IN osm_log_t * p_log,
+ IN const osm_subn_t * p_subn,
+ IN osm_mad_addr_t * p_mad_addr,
+ OUT ib_gid_t * p_gid)
+{
+ const osm_port_t *p_port;
+
+ if (p_gid == NULL) {
+ OSM_LOG(p_log, OSM_LOG_ERROR, "ERR 7505: "
+ "Provided output GID is NULL\n");
+ return IB_INVALID_PARAMETER;
+ }
+
+ p_port = osm_get_port_by_mad_addr(p_log, p_subn, p_mad_addr);
+ if (!p_port)
+ return IB_INVALID_PARAMETER;
+
+ p_gid->unicast.interface_id = p_port->p_physp->port_guid;
+ p_gid->unicast.prefix = p_subn->opt.subnet_prefix;
+
+ return IB_SUCCESS;
+}
+
+osm_physp_t *osm_get_physp_by_mad_addr(IN osm_log_t * p_log,
+ IN const osm_subn_t * p_subn,
+ IN osm_mad_addr_t * p_mad_addr)
+{
+ osm_port_t *p_port;
+
+ p_port = osm_get_port_by_mad_addr(p_log, p_subn, p_mad_addr);
+ if (!p_port)
+ return NULL;
+
+ return p_port->p_physp;
+}
+
+osm_switch_t *osm_get_switch_by_guid(IN const osm_subn_t * p_subn,
+ IN ib_net64_t guid)
+{
+ osm_switch_t *p_switch;
+
+ p_switch = (osm_switch_t *) cl_qmap_get(&(p_subn->sw_guid_tbl), guid);
+ if (p_switch == (osm_switch_t *) cl_qmap_end(&(p_subn->sw_guid_tbl)))
+ p_switch = NULL;
+ return p_switch;
+}
+
+osm_node_t *osm_get_node_by_guid(IN osm_subn_t const *p_subn, IN ib_net64_t guid)
+{
+ osm_node_t *p_node;
+
+ p_node = (osm_node_t *) cl_qmap_get(&(p_subn->node_guid_tbl), guid);
+ if (p_node == (osm_node_t *) cl_qmap_end(&(p_subn->node_guid_tbl)))
+ p_node = NULL;
+ return p_node;
+}
+
+osm_port_t *osm_get_port_by_guid(IN osm_subn_t const *p_subn, IN ib_net64_t guid)
+{
+ osm_port_t *p_port;
+
+ p_port = (osm_port_t *) cl_qmap_get(&(p_subn->port_guid_tbl), guid);
+ if (p_port == (osm_port_t *) cl_qmap_end(&(p_subn->port_guid_tbl)))
+ p_port = NULL;
+ return p_port;
+}
+
+osm_alias_guid_t *osm_get_alias_guid_by_guid(IN osm_subn_t const *p_subn,
+ IN ib_net64_t guid)
+{
+ osm_alias_guid_t *p_alias_guid;
+
+ p_alias_guid = (osm_alias_guid_t *) cl_qmap_get(&(p_subn->alias_port_guid_tbl), guid);
+ if (p_alias_guid == (osm_alias_guid_t *) cl_qmap_end(&(p_subn->alias_port_guid_tbl)))
+ return NULL;
+ return p_alias_guid;
+}
+
+osm_port_t *osm_get_port_by_alias_guid(IN osm_subn_t const *p_subn,
+ IN ib_net64_t guid)
+{
+ osm_alias_guid_t *p_alias_guid;
+
+ p_alias_guid = osm_get_alias_guid_by_guid(p_subn, guid);
+ if (!p_alias_guid)
+ return NULL;
+ return p_alias_guid->p_base_port;
+}
+
+osm_assigned_guids_t *osm_assigned_guids_new(IN const ib_net64_t port_guid,
+ IN const uint32_t num_guids)
+{
+ osm_assigned_guids_t *p_assigned_guids;
+
+ p_assigned_guids = calloc(1, sizeof(*p_assigned_guids) +
+ sizeof(ib_net64_t) * (num_guids - 1));
+ if (p_assigned_guids)
+ p_assigned_guids->port_guid = port_guid;
+ return p_assigned_guids;
+}
+
+void osm_assigned_guids_delete(IN OUT osm_assigned_guids_t ** pp_assigned_guids)
+{
+ free(*pp_assigned_guids);
+ *pp_assigned_guids = NULL;
+}
+
+osm_assigned_guids_t *osm_get_assigned_guids_by_guid(IN osm_subn_t const *p_subn,
+ IN ib_net64_t port_guid)
+{
+ osm_assigned_guids_t *p_assigned_guids;
+
+ p_assigned_guids = (osm_assigned_guids_t *) cl_qmap_get(&(p_subn->assigned_guids_tbl), port_guid);
+ if (p_assigned_guids == (osm_assigned_guids_t *) cl_qmap_end(&(p_subn->assigned_guids_tbl)))
+ return NULL;
+ return p_assigned_guids;
+}
+
+osm_port_t *osm_get_port_by_lid_ho(IN osm_subn_t const * subn, IN uint16_t lid)
+{
+ if (lid < cl_ptr_vector_get_size(&subn->port_lid_tbl))
+ return cl_ptr_vector_get(&subn->port_lid_tbl, lid);
+ return NULL;
+}
+
+osm_mgrp_t *osm_get_mgrp_by_mgid(IN osm_subn_t * subn, IN ib_gid_t * mgid)
+{
+ osm_mgrp_t *mgrp;
+
+ mgrp = (osm_mgrp_t *)cl_fmap_get(&subn->mgrp_mgid_tbl, mgid);
+ if (mgrp != (osm_mgrp_t *)cl_fmap_end(&subn->mgrp_mgid_tbl))
+ return mgrp;
+ return NULL;
+}
+
+int is_mlnx_ext_port_info_supported(ib_net32_t vendid, ib_net16_t devid)
+{
+ uint32_t vendid_ho;
+ uint16_t devid_ho;
+
+ devid_ho = cl_ntoh16(devid);
+ if ((devid_ho >= 0xc738 && devid_ho <= 0xc73b) || devid_ho == 0xcb20 ||
+ devid_ho == 0xcf08 || devid == 0x1b02)
+ return 1;
+ if (devid_ho >= 0x1003 && devid_ho <= 0x1017)
+ return 1;
+
+ vendid_ho = cl_ntoh32(vendid);
+ if (vendid_ho == 0x119f) {
+ /* Bull Switch-X */
+ if (devid_ho == 0x1b02 || devid_ho == 0x1b50)
+ return 1;
+ /* Bull Switch-IB/IB2 */
+ if (devid_ho == 0x1ba0 ||
+ (devid_ho >= 0x1bd0 && devid_ho <= 0x1bd5))
+ return 1;
+ /* Bull Connect-X3 */
+ if (devid_ho == 0x1b33 || devid_ho == 0x1b73 ||
+ devid_ho == 0x1b40 || devid_ho == 0x1b41 ||
+ devid_ho == 0x1b60 || devid_ho == 0x1b61)
+ return 1;
+ /* Bull Connect-IB */
+ if (devid_ho == 0x1b83 ||
+ devid_ho == 0x1b93 || devid_ho == 0x1b94)
+ return 1;
+ /* Bull Connect-X4 */
+ if (devid_ho == 0x1bb4 || devid_ho == 0x1bb5 ||
+ devid_ho == 0x1bc4)
+ return 1;
+ }
+ return 0;
+}
+
+static void subn_init_qos_options(osm_qos_options_t *opt, osm_qos_options_t *f)
+{
+ opt->max_vls = 0;
+ opt->high_limit = -1;
+ if (opt->vlarb_high)
+ free(opt->vlarb_high);
+ opt->vlarb_high = NULL;
+ if (opt->vlarb_low)
+ free(opt->vlarb_low);
+ opt->vlarb_low = NULL;
+ if (opt->sl2vl)
+ free(opt->sl2vl);
+ opt->sl2vl = NULL;
+ if (f)
+ memcpy(f, opt, sizeof(*f));
+}
+
+void osm_subn_set_default_opt(IN osm_subn_opt_t * p_opt)
+{
+ memset(p_opt, 0, sizeof(osm_subn_opt_t));
+ p_opt->guid = 0;
+ p_opt->m_key = OSM_DEFAULT_M_KEY;
+ p_opt->sm_key = OSM_DEFAULT_SM_KEY;
+ p_opt->sa_key = OSM_DEFAULT_SA_KEY;
+ p_opt->subnet_prefix = IB_DEFAULT_SUBNET_PREFIX;
+ p_opt->m_key_lease_period = 0;
+ p_opt->m_key_protect_bits = 0;
+ p_opt->m_key_lookup = TRUE;
+ p_opt->sweep_interval = OSM_DEFAULT_SWEEP_INTERVAL_SECS;
+ p_opt->max_wire_smps = OSM_DEFAULT_SMP_MAX_ON_WIRE;
+ p_opt->max_wire_smps2 = p_opt->max_wire_smps;
+ p_opt->console = strdup(OSM_DEFAULT_CONSOLE);
+ p_opt->console_port = OSM_DEFAULT_CONSOLE_PORT;
+ p_opt->transaction_timeout = OSM_DEFAULT_TRANS_TIMEOUT_MILLISEC;
+ p_opt->transaction_retries = OSM_DEFAULT_RETRY_COUNT;
+ p_opt->max_smps_timeout = 1000 * p_opt->transaction_timeout *
+ p_opt->transaction_retries;
+ /* by default we will consider waiting for 50x transaction timeout normal */
+ p_opt->max_msg_fifo_timeout = 50 * OSM_DEFAULT_TRANS_TIMEOUT_MILLISEC;
+ p_opt->sm_priority = OSM_DEFAULT_SM_PRIORITY;
+ p_opt->lmc = OSM_DEFAULT_LMC;
+ p_opt->lmc_esp0 = FALSE;
+ p_opt->max_op_vls = OSM_DEFAULT_MAX_OP_VLS;
+ p_opt->force_link_speed = 15;
+ p_opt->force_link_speed_ext = 31;
+ p_opt->fdr10 = 1;
+ p_opt->reassign_lids = FALSE;
+ p_opt->ignore_other_sm = FALSE;
+ p_opt->single_thread = FALSE;
+ p_opt->disable_multicast = FALSE;
+ p_opt->force_log_flush = FALSE;
+ p_opt->subnet_timeout = OSM_DEFAULT_SUBNET_TIMEOUT;
+ p_opt->packet_life_time = OSM_DEFAULT_SWITCH_PACKET_LIFE;
+ p_opt->vl_stall_count = OSM_DEFAULT_VL_STALL_COUNT;
+ p_opt->leaf_vl_stall_count = OSM_DEFAULT_LEAF_VL_STALL_COUNT;
+ p_opt->head_of_queue_lifetime = OSM_DEFAULT_HEAD_OF_QUEUE_LIFE;
+ p_opt->leaf_head_of_queue_lifetime =
+ OSM_DEFAULT_LEAF_HEAD_OF_QUEUE_LIFE;
+ p_opt->local_phy_errors_threshold = OSM_DEFAULT_ERROR_THRESHOLD;
+ p_opt->overrun_errors_threshold = OSM_DEFAULT_ERROR_THRESHOLD;
+ p_opt->use_mfttop = TRUE;
+ p_opt->sminfo_polling_timeout =
+ OSM_SM_DEFAULT_POLLING_TIMEOUT_MILLISECS;
+ p_opt->polling_retry_number = OSM_SM_DEFAULT_POLLING_RETRY_NUMBER;
+ p_opt->force_heavy_sweep = FALSE;
+ p_opt->log_flags = OSM_LOG_DEFAULT_LEVEL;
+ p_opt->honor_guid2lid_file = FALSE;
+ p_opt->daemon = FALSE;
+ p_opt->sm_inactive = FALSE;
+ p_opt->babbling_port_policy = FALSE;
+ p_opt->drop_event_subscriptions = FALSE;
+ p_opt->ipoib_mcgroup_creation_validation = TRUE;
+ p_opt->mcgroup_join_validation = TRUE;
+ p_opt->use_optimized_slvl = FALSE;
+ p_opt->fsync_high_avail_files = TRUE;
+#ifdef ENABLE_OSM_PERF_MGR
+ p_opt->perfmgr = FALSE;
+ p_opt->perfmgr_redir = TRUE;
+ p_opt->perfmgr_sweep_time_s = OSM_PERFMGR_DEFAULT_SWEEP_TIME_S;
+ p_opt->perfmgr_max_outstanding_queries =
+ OSM_PERFMGR_DEFAULT_MAX_OUTSTANDING_QUERIES;
+ p_opt->perfmgr_ignore_cas = FALSE;
+ p_opt->event_db_dump_file = NULL; /* use default */
+ p_opt->perfmgr_rm_nodes = TRUE;
+ p_opt->perfmgr_log_errors = TRUE;
+ p_opt->perfmgr_query_cpi = TRUE;
+ p_opt->perfmgr_xmit_wait_log = FALSE;
+ p_opt->perfmgr_xmit_wait_threshold = OSM_PERFMGR_DEFAULT_XMIT_WAIT_THRESHOLD;
+#endif /* ENABLE_OSM_PERF_MGR */
+
+ p_opt->event_plugin_name = NULL;
+ p_opt->event_plugin_options = NULL;
+ p_opt->node_name_map_name = NULL;
+
+ p_opt->dump_files_dir = getenv("OSM_TMP_DIR");
+ if (!p_opt->dump_files_dir || !(*p_opt->dump_files_dir))
+ p_opt->dump_files_dir = strdup(OSM_DEFAULT_TMP_DIR);
+ else
+ p_opt->dump_files_dir = strdup(p_opt->dump_files_dir);
+ p_opt->log_file = strdup(OSM_DEFAULT_LOG_FILE);
+ p_opt->log_max_size = 0;
+ p_opt->partition_config_file = strdup(OSM_DEFAULT_PARTITION_CONFIG_FILE);
+ p_opt->no_partition_enforcement = FALSE;
+ p_opt->part_enforce = strdup(OSM_PARTITION_ENFORCE_BOTH);
+ p_opt->allow_both_pkeys = FALSE;
+ p_opt->sm_assigned_guid = 0;
+ p_opt->qos = FALSE;
+ p_opt->qos_policy_file = strdup(OSM_DEFAULT_QOS_POLICY_FILE);
+ p_opt->suppress_sl2vl_mad_status_errors = FALSE;
+ p_opt->accum_log_file = TRUE;
+ p_opt->port_prof_ignore_file = NULL;
+ p_opt->hop_weights_file = NULL;
+ p_opt->port_search_ordering_file = NULL;
+ p_opt->port_profile_switch_nodes = FALSE;
+ p_opt->sweep_on_trap = TRUE;
+ p_opt->use_ucast_cache = FALSE;
+ p_opt->routing_engine_names = NULL;
+ p_opt->connect_roots = FALSE;
+ p_opt->lid_matrix_dump_file = NULL;
+ p_opt->lfts_file = NULL;
+ p_opt->root_guid_file = NULL;
+ p_opt->cn_guid_file = NULL;
+ p_opt->io_guid_file = NULL;
+ p_opt->port_shifting = FALSE;
+ p_opt->scatter_ports = OSM_DEFAULT_SCATTER_PORTS;
+ p_opt->max_reverse_hops = 0;
+ p_opt->ids_guid_file = NULL;
+ p_opt->guid_routing_order_file = NULL;
+ p_opt->guid_routing_order_no_scatter = FALSE;
+ p_opt->sa_db_file = NULL;
+ p_opt->sa_db_dump = FALSE;
+ p_opt->torus_conf_file = strdup(OSM_DEFAULT_TORUS_CONF_FILE);
+ p_opt->do_mesh_analysis = FALSE;
+ p_opt->exit_on_fatal = TRUE;
+ p_opt->congestion_control = FALSE;
+ p_opt->cc_key = OSM_DEFAULT_CC_KEY;
+ p_opt->cc_max_outstanding_mads = OSM_CC_DEFAULT_MAX_OUTSTANDING_QUERIES;
+ p_opt->enable_quirks = FALSE;
+ p_opt->no_clients_rereg = FALSE;
+ p_opt->prefix_routes_file = strdup(OSM_DEFAULT_PREFIX_ROUTES_FILE);
+ p_opt->consolidate_ipv6_snm_req = FALSE;
+ p_opt->lash_start_vl = 0;
+ p_opt->sm_sl = OSM_DEFAULT_SL;
+ p_opt->log_prefix = NULL;
+ p_opt->per_module_logging_file = strdup(OSM_DEFAULT_PER_MOD_LOGGING_CONF_FILE);
+ subn_init_qos_options(&p_opt->qos_options, NULL);
+ subn_init_qos_options(&p_opt->qos_ca_options, NULL);
+ subn_init_qos_options(&p_opt->qos_sw0_options, NULL);
+ subn_init_qos_options(&p_opt->qos_swe_options, NULL);
+ subn_init_qos_options(&p_opt->qos_rtr_options, NULL);
+ p_opt->cc_cct.entries_len = 0;
+ p_opt->cc_cct.input_str = NULL;
+ p_opt->quasi_ftree_indexing = FALSE;
+}
+
+static char *clean_val(char *val)
+{
+ char *p = val;
+ /* clean leading spaces */
+ while (isspace(*p))
+ p++;
+ val = p;
+ if (!*val)
+ return val;
+ /* clean trailing spaces */
+ p = val + strlen(val) - 1;
+ while (p > val && isspace(*p))
+ p--;
+ p[1] = '\0';
+ /* clean quotas */
+ if ((*val == '\"' && *p == '\"') || (*val == '\'' && *p == '\'')) {
+ val++;
+ *p-- = '\0';
+ }
+ return val;
+}
+
+static int subn_dump_qos_options(FILE * file, const char *set_name,
+ const char *prefix, osm_qos_options_t * opt)
+{
+ return fprintf(file, "# %s\n"
+ "%s_max_vls %u\n"
+ "%s_high_limit %d\n"
+ "%s_vlarb_high %s\n"
+ "%s_vlarb_low %s\n"
+ "%s_sl2vl %s\n",
+ set_name,
+ prefix, opt->max_vls,
+ prefix, opt->high_limit,
+ prefix, opt->vlarb_high,
+ prefix, opt->vlarb_low, prefix, opt->sl2vl);
+}
+
+static ib_api_status_t append_prefix_route(IN osm_subn_t * p_subn,
+ uint64_t prefix, uint64_t guid)
+{
+ osm_prefix_route_t *route;
+
+ route = malloc(sizeof *route);
+ if (! route) {
+ OSM_LOG(&p_subn->p_osm->log, OSM_LOG_ERROR, "out of memory");
+ return IB_ERROR;
+ }
+
+ route->prefix = cl_hton64(prefix);
+ route->guid = cl_hton64(guid);
+ cl_qlist_insert_tail(&p_subn->prefix_routes_list, &route->list_item);
+ return IB_SUCCESS;
+}
+
+static ib_api_status_t parse_prefix_routes_file(IN osm_subn_t * p_subn)
+{
+ osm_log_t *log = &p_subn->p_osm->log;
+ FILE *fp;
+ char buf[1024];
+ int line = 0;
+ int errors = 0;
+
+ while (!cl_is_qlist_empty(&p_subn->prefix_routes_list)) {
+ cl_list_item_t *item = cl_qlist_remove_head(&p_subn->prefix_routes_list);
+ free(item);
+ }
+
+ fp = fopen(p_subn->opt.prefix_routes_file, "r");
+ if (! fp) {
+ if (errno == ENOENT)
+ return IB_SUCCESS;
+
+ OSM_LOG(log, OSM_LOG_ERROR, "fopen(%s) failed: %s",
+ p_subn->opt.prefix_routes_file, strerror(errno));
+ return IB_ERROR;
+ }
+
+ while (fgets(buf, sizeof buf, fp) != NULL) {
+ char *p_prefix, *p_guid, *p_extra, *p_last, *p_end;
+ uint64_t prefix, guid;
+
+ line++;
+ if (errors > 10)
+ break;
+
+ p_prefix = strtok_r(buf, " \t\n", &p_last);
+ if (! p_prefix)
+ continue; /* ignore blank lines */
+
+ if (*p_prefix == '#')
+ continue; /* ignore comment lines */
+
+ p_guid = strtok_r(NULL, " \t\n", &p_last);
+ if (! p_guid) {
+ OSM_LOG(log, OSM_LOG_ERROR, "%s:%d: missing GUID\n",
+ p_subn->opt.prefix_routes_file, line);
+ errors++;
+ continue;
+ }
+
+ p_extra = strtok_r(NULL, " \t\n", &p_last);
+ if (p_extra && *p_extra != '#') {
+ OSM_LOG(log, OSM_LOG_INFO, "%s:%d: extra tokens ignored\n",
+ p_subn->opt.prefix_routes_file, line);
+ }
+
+ if (strcmp(p_prefix, "*") == 0)
+ prefix = 0;
+ else {
+ prefix = strtoull(p_prefix, &p_end, 16);
+ if (*p_end != '\0') {
+ OSM_LOG(log, OSM_LOG_ERROR, "%s:%d: illegal prefix: %s\n",
+ p_subn->opt.prefix_routes_file, line, p_prefix);
+ errors++;
+ continue;
+ }
+ }
+
+ if (strcmp(p_guid, "*") == 0)
+ guid = 0;
+ else {
+ guid = strtoull(p_guid, &p_end, 16);
+ if (*p_end != '\0' && *p_end != '#') {
+ OSM_LOG(log, OSM_LOG_ERROR, "%s:%d: illegal GUID: %s\n",
+ p_subn->opt.prefix_routes_file, line, p_guid);
+ errors++;
+ continue;
+ }
+ }
+
+ if (append_prefix_route(p_subn, prefix, guid) != IB_SUCCESS) {
+ errors++;
+ break;
+ }
+ }
+
+ fclose(fp);
+ return (errors == 0) ? IB_SUCCESS : IB_ERROR;
+}
+
+static ib_api_status_t insert_per_module_debug(IN osm_subn_t * p_subn,
+ char *mod_name,
+ osm_log_level_t level)
+{
+ uint8_t index;
+
+ if (find_module_name(mod_name, &index)) {
+ OSM_LOG(&p_subn->p_osm->log, OSM_LOG_ERROR,
+ "Module name %s not found\n", mod_name);
+ return IB_ERROR;
+ }
+ osm_set_log_per_module(&p_subn->p_osm->log, index, level);
+ return IB_SUCCESS;
+}
+
+static ib_api_status_t parse_per_mod_logging_file(IN osm_subn_t * p_subn)
+{
+ osm_log_t *log = &p_subn->p_osm->log;
+ FILE *fp;
+ char buf[1024];
+ int line = 0;
+ int errors = 0;
+
+ osm_reset_log_per_module(log);
+
+ if (p_subn->opt.per_module_logging_file == NULL)
+ return IB_SUCCESS;
+
+ fp = fopen(p_subn->opt.per_module_logging_file, "r");
+ if (!fp) {
+ if (errno == ENOENT)
+ return IB_SUCCESS;
+
+ OSM_LOG(log, OSM_LOG_ERROR, "fopen(%s) failed: %s",
+ p_subn->opt.per_module_logging_file, strerror(errno));
+ return IB_ERROR;
+ }
+
+ while (fgets(buf, sizeof buf, fp) != NULL) {
+ char *p_mod_name, *p_level, *p_extra, *p_last;
+ osm_log_level_t level;
+
+ line++;
+ if (errors > 10)
+ break;
+
+ p_mod_name = strtok_r(buf, " =,\t\n", &p_last);
+ if (!p_mod_name)
+ continue; /* ignore blank lines */
+
+ if (*p_mod_name == '#')
+ continue; /* ignore comment lines */
+
+ p_level = strtok_r(NULL, " \t\n", &p_last);
+ if (!p_level) {
+ OSM_LOG(log, OSM_LOG_ERROR, "%s:%d: missing log level\n",
+ p_subn->opt.per_module_logging_file, line);
+ errors++;
+ continue;
+ }
+ p_extra = strtok_r(NULL, " \t\n", &p_last);
+ if (p_extra && *p_extra != '#') {
+ OSM_LOG(log, OSM_LOG_INFO, "%s:%d: extra tokens ignored\n",
+ p_subn->opt.per_module_logging_file, line);
+ }
+
+ level = strtoul(p_level, NULL, 0);
+ if (insert_per_module_debug(p_subn, p_mod_name, level) != IB_SUCCESS) {
+ errors++;
+ break;
+ }
+ }
+
+ fclose(fp);
+ return (errors == 0) ? IB_SUCCESS : IB_ERROR;
+}
+
+static void subn_verify_max_vls(unsigned *max_vls, const char *prefix)
+{
+ if (!*max_vls || *max_vls > 15) {
+ if (*max_vls)
+ log_report(" Invalid Cached Option: %s_max_vls=%u: "
+ "Using Default = %u\n",
+ prefix, *max_vls, OSM_DEFAULT_QOS_MAX_VLS);
+ *max_vls = 0;
+ }
+}
+
+static void subn_verify_high_limit(int *high_limit, const char *prefix)
+{
+ if (*high_limit < 0 || *high_limit > 255) {
+ if (*high_limit > 255)
+ log_report(" Invalid Cached Option: %s_high_limit=%d: "
+ "Using Default: %d\n",
+ prefix, *high_limit,
+ OSM_DEFAULT_QOS_HIGH_LIMIT);
+ *high_limit = -1;
+ }
+}
+
+static void subn_verify_vlarb(char **vlarb, const char *prefix,
+ const char *suffix)
+{
+ char *str, *tok, *end, *ptr;
+ int count = 0;
+
+ if (*vlarb == NULL)
+ return;
+
+ str = strdup(*vlarb);
+
+ tok = strtok_r(str, ",\n", &ptr);
+ while (tok) {
+ char *vl_str, *weight_str;
+
+ vl_str = tok;
+ weight_str = strchr(tok, ':');
+
+ if (weight_str) {
+ long vl, weight;
+
+ *weight_str = '\0';
+ weight_str++;
+
+ vl = strtol(vl_str, &end, 0);
+
+ if (*end)
+ log_report(" Warning: Cached Option "
+ "%s_vlarb_%s:vl=%s"
+ " improperly formatted\n",
+ prefix, suffix, vl_str);
+ else if (vl < 0 || vl > 14)
+ log_report(" Warning: Cached Option "
+ "%s_vlarb_%s:vl=%ld out of range\n",
+ prefix, suffix, vl);
+
+ weight = strtol(weight_str, &end, 0);
+
+ if (*end)
+ log_report(" Warning: Cached Option "
+ "%s_vlarb_%s:weight=%s "
+ "improperly formatted\n",
+ prefix, suffix, weight_str);
+ else if (weight < 0 || weight > 255)
+ log_report(" Warning: Cached Option "
+ "%s_vlarb_%s:weight=%ld "
+ "out of range\n",
+ prefix, suffix, weight);
+ } else
+ log_report(" Warning: Cached Option "
+ "%s_vlarb_%s:vl:weight=%s "
+ "improperly formatted\n",
+ prefix, suffix, tok);
+
+ count++;
+ tok = strtok_r(NULL, ",\n", &ptr);
+ }
+
+ if (count > 64)
+ log_report(" Warning: Cached Option %s_vlarb_%s: > 64 listed:"
+ " excess vl:weight pairs will be dropped\n",
+ prefix, suffix);
+
+ free(str);
+}
+
+static void subn_verify_sl2vl(char **sl2vl, const char *prefix)
+{
+ char *str, *tok, *end, *ptr;
+ int count = 0;
+
+ if (*sl2vl == NULL)
+ return;
+
+ str = strdup(*sl2vl);
+
+ tok = strtok_r(str, ",\n", &ptr);
+ while (tok) {
+ long vl = strtol(tok, &end, 0);
+
+ if (*end)
+ log_report(" Warning: Cached Option %s_sl2vl:vl=%s "
+ "improperly formatted\n", prefix, tok);
+ else if (vl < 0 || vl > 15)
+ log_report(" Warning: Cached Option %s_sl2vl:vl=%ld "
+ "out of range\n", prefix, vl);
+
+ count++;
+ tok = strtok_r(NULL, ",\n", &ptr);
+ }
+
+ if (count < 16)
+ log_report(" Warning: Cached Option %s_sl2vl: < 16 VLs "
+ "listed\n", prefix);
+ else if (count > 16)
+ log_report(" Warning: Cached Option %s_sl2vl: > 16 listed: "
+ "excess VLs will be dropped\n", prefix);
+
+ free(str);
+}
+
+static void subn_verify_qos_set(osm_qos_options_t *set, const char *prefix)
+{
+ subn_verify_max_vls(&set->max_vls, prefix);
+ subn_verify_high_limit(&set->high_limit, prefix);
+ subn_verify_vlarb(&set->vlarb_low, prefix, "low");
+ subn_verify_vlarb(&set->vlarb_high, prefix, "high");
+ subn_verify_sl2vl(&set->sl2vl, prefix);
+}
+
+int osm_subn_verify_config(IN osm_subn_opt_t * p_opts)
+{
+ if (p_opts->lmc > 7) {
+ log_report(" Invalid Cached Option Value:lmc = %u:"
+ "Using Default:%u\n", p_opts->lmc, OSM_DEFAULT_LMC);
+ p_opts->lmc = OSM_DEFAULT_LMC;
+ }
+
+ if (15 < p_opts->sm_priority) {
+ log_report(" Invalid Cached Option Value:sm_priority = %u:"
+ "Using Default:%u\n",
+ p_opts->sm_priority, OSM_DEFAULT_SM_PRIORITY);
+ p_opts->sm_priority = OSM_DEFAULT_SM_PRIORITY;
+ }
+
+ if ((15 < p_opts->force_link_speed) ||
+ (p_opts->force_link_speed > 7 && p_opts->force_link_speed < 15)) {
+ log_report(" Invalid Cached Option Value:force_link_speed = %u:"
+ "Using Default:%u\n", p_opts->force_link_speed,
+ IB_PORT_LINK_SPEED_ENABLED_MASK);
+ p_opts->force_link_speed = IB_PORT_LINK_SPEED_ENABLED_MASK;
+ }
+
+ if ((31 < p_opts->force_link_speed_ext) ||
+ (p_opts->force_link_speed_ext > 3 && p_opts->force_link_speed_ext < 30)) {
+ log_report(" Invalid Cached Option Value:force_link_speed_ext = %u:"
+ "Using Default:%u\n", p_opts->force_link_speed_ext,
+ 31);
+ p_opts->force_link_speed_ext = 31;
+ }
+
+ if (2 < p_opts->fdr10) {
+ log_report(" Invalid Cached Option Value:fdr10 = %u:"
+ "Using Default:%u\n", p_opts->fdr10, 1);
+ p_opts->fdr10 = 1;
+ }
+
+ if (p_opts->max_wire_smps == 0)
+ p_opts->max_wire_smps = 0x7FFFFFFF;
+ else if (p_opts->max_wire_smps > 0x7FFFFFFF) {
+ log_report(" Invalid Cached Option Value: max_wire_smps = %u,"
+ " Using Default: %u\n",
+ p_opts->max_wire_smps, OSM_DEFAULT_SMP_MAX_ON_WIRE);
+ p_opts->max_wire_smps = OSM_DEFAULT_SMP_MAX_ON_WIRE;
+ }
+
+ if (p_opts->max_wire_smps2 > 0x7FFFFFFF) {
+ log_report(" Invalid Cached Option Value: max_wire_smps2 = %u,"
+ " Using Default: %u",
+ p_opts->max_wire_smps2, p_opts->max_wire_smps);
+ p_opts->max_wire_smps2 = p_opts->max_wire_smps;
+ }
+
+ if (strcmp(p_opts->console, OSM_DISABLE_CONSOLE)
+ && strcmp(p_opts->console, OSM_LOCAL_CONSOLE)
+#ifdef ENABLE_OSM_CONSOLE_LOOPBACK
+ && strcmp(p_opts->console, OSM_LOOPBACK_CONSOLE)
+#endif
+#ifdef ENABLE_OSM_CONSOLE_SOCKET
+ && strcmp(p_opts->console, OSM_REMOTE_CONSOLE)
+#endif
+ ) {
+ log_report(" Invalid Cached Option Value:console = %s"
+ ", Using Default:%s\n",
+ p_opts->console, OSM_DEFAULT_CONSOLE);
+ free(p_opts->console);
+ p_opts->console = strdup(OSM_DEFAULT_CONSOLE);
+ }
+
+ if (p_opts->no_partition_enforcement == TRUE) {
+ strcpy(p_opts->part_enforce, OSM_PARTITION_ENFORCE_OFF);
+ p_opts->part_enforce_enum = OSM_PARTITION_ENFORCE_TYPE_OFF;
+ } else {
+ if (strcmp(p_opts->part_enforce, OSM_PARTITION_ENFORCE_BOTH) == 0)
+ p_opts->part_enforce_enum = OSM_PARTITION_ENFORCE_TYPE_BOTH;
+ else if (strcmp(p_opts->part_enforce, OSM_PARTITION_ENFORCE_IN) == 0)
+ p_opts->part_enforce_enum = OSM_PARTITION_ENFORCE_TYPE_IN;
+ else if (strcmp(p_opts->part_enforce, OSM_PARTITION_ENFORCE_OUT) == 0)
+ p_opts->part_enforce_enum = OSM_PARTITION_ENFORCE_TYPE_OUT;
+ else if (strcmp(p_opts->part_enforce, OSM_PARTITION_ENFORCE_OFF) == 0)
+ p_opts->part_enforce_enum = OSM_PARTITION_ENFORCE_TYPE_OFF;
+ else {
+ log_report(" Invalid Cached Option Value:part_enforce = %s"
+ ", Using Default:%s\n",
+ p_opts->part_enforce, OSM_PARTITION_ENFORCE_BOTH);
+ strcpy(p_opts->part_enforce, OSM_PARTITION_ENFORCE_BOTH);
+ p_opts->part_enforce_enum = OSM_PARTITION_ENFORCE_TYPE_BOTH;
+ }
+ }
+
+ if (p_opts->qos) {
+ subn_verify_qos_set(&p_opts->qos_options, "qos");
+ subn_verify_qos_set(&p_opts->qos_ca_options, "qos_ca");
+ subn_verify_qos_set(&p_opts->qos_sw0_options, "qos_sw0");
+ subn_verify_qos_set(&p_opts->qos_swe_options, "qos_swe");
+ subn_verify_qos_set(&p_opts->qos_rtr_options, "qos_rtr");
+ }
+
+#ifdef ENABLE_OSM_PERF_MGR
+ if (p_opts->perfmgr_sweep_time_s < 1) {
+ log_report(" Invalid Cached Option Value:perfmgr_sweep_time_s "
+ "= %u Using Default:%u\n",
+ p_opts->perfmgr_sweep_time_s,
+ OSM_PERFMGR_DEFAULT_SWEEP_TIME_S);
+ p_opts->perfmgr_sweep_time_s = OSM_PERFMGR_DEFAULT_SWEEP_TIME_S;
+ }
+ if (p_opts->perfmgr_max_outstanding_queries < 1) {
+ log_report(" Invalid Cached Option Value:"
+ "perfmgr_max_outstanding_queries = %u"
+ " Using Default:%u\n",
+ p_opts->perfmgr_max_outstanding_queries,
+ OSM_PERFMGR_DEFAULT_MAX_OUTSTANDING_QUERIES);
+ p_opts->perfmgr_max_outstanding_queries =
+ OSM_PERFMGR_DEFAULT_MAX_OUTSTANDING_QUERIES;
+ }
+#endif
+
+ if (p_opts->m_key_protect_bits > 3) {
+ log_report(" Invalid Cached Option Value:"
+ "m_key_protection_level = %u Setting to %u "
+ "instead\n", p_opts->m_key_protect_bits, 2);
+ p_opts->m_key_protect_bits = 2;
+ }
+ if (p_opts->m_key_protect_bits && p_opts->m_key_lease_period) {
+ if (!p_opts->sweep_interval) {
+ log_report(" Sweep disabled with protected mkey "
+ "leases in effect; re-enabling sweeping "
+ "with interval %u\n",
+ cl_ntoh16(p_opts->m_key_lease_period) - 1);
+ p_opts->sweep_interval =
+ cl_ntoh16(p_opts->m_key_lease_period) - 1;
+ }
+ if (p_opts->sweep_interval >=
+ cl_ntoh16(p_opts->m_key_lease_period)) {
+ log_report(" Sweep interval %u >= mkey lease period "
+ "%u. Setting lease period to %u\n",
+ p_opts->sweep_interval,
+ cl_ntoh16(p_opts->m_key_lease_period),
+ p_opts->sweep_interval + 1);
+ p_opts->m_key_lease_period =
+ cl_hton16(p_opts->sweep_interval + 1);
+ }
+ }
+
+ return 0;
+}
+
+int osm_subn_parse_conf_file(const char *file_name, osm_subn_opt_t * p_opts)
+{
+ char line[1024];
+ FILE *opts_file;
+ char *p_key, *p_val, *pound_sign;
+ const opt_rec_t *r;
+ void *p_field1, *p_field2;
+ int token_matched;
+
+ opts_file = fopen(file_name, "r");
+ if (!opts_file) {
+ if (errno == ENOENT)
+ return 1;
+ printf("cannot open file \'%s\': %s\n",
+ file_name, strerror(errno));
+ return -1;
+ }
+
+ printf(" Reading Cached Option File: %s\n", file_name);
+
+ p_opts->config_file = file_name;
+ if (!p_opts->file_opts && !(p_opts->file_opts = malloc(sizeof(*p_opts)))) {
+ fclose(opts_file);
+ return -1;
+ }
+ memcpy(p_opts->file_opts, p_opts, sizeof(*p_opts));
+ p_opts->file_opts->file_opts = NULL;
+
+ while (fgets(line, 1023, opts_file) != NULL) {
+ pound_sign = strchr(line,'#');
+ token_matched = 0;
+ /* Truncate any comments. */
+ if (pound_sign)
+ *pound_sign = '\0';
+
+ /* get the first token */
+ p_key = strtok_r(line, " \t\n", &p_val);
+ if (!p_key)
+ continue;
+
+ p_val = clean_val(p_val);
+
+ for (r = opt_tbl; r->name; r++) {
+ if (strcmp(r->name, p_key))
+ continue;
+
+ token_matched = 1;
+ p_field1 = (void *)p_opts->file_opts + r->opt_offset;
+ p_field2 = (void *)p_opts + r->opt_offset;
+ /* don't call setup function first time */
+ r->parse_fn(NULL, p_key, p_val, p_field1, p_field2,
+ NULL);
+ break;
+ }
+
+ if (!token_matched)
+ log_report(" Unrecognized token: \"%s\"\n", p_key);
+ }
+ fclose(opts_file);
+
+ osm_subn_verify_config(p_opts);
+
+ return 0;
+}
+
+int osm_subn_rescan_conf_files(IN osm_subn_t * p_subn)
+{
+ char line[1024];
+ osm_subn_opt_t *p_opts = &p_subn->opt;
+ const opt_rec_t *r;
+ FILE *opts_file;
+ char *p_key, *p_val, *pound_sign;
+ void *p_field1, *p_field2;
+ int token_matched;
+
+ if (!p_opts->config_file)
+ return 0;
+
+ opts_file = fopen(p_opts->config_file, "r");
+ if (!opts_file) {
+ if (errno == ENOENT)
+ return 1;
+ OSM_LOG(&p_subn->p_osm->log, OSM_LOG_ERROR,
+ "cannot open file \'%s\': %s\n",
+ p_opts->config_file, strerror(errno));
+ return -1;
+ }
+
+ subn_init_qos_options(&p_opts->qos_options,
+ &p_opts->file_opts->qos_options);
+ subn_init_qos_options(&p_opts->qos_ca_options,
+ &p_opts->file_opts->qos_ca_options);
+ subn_init_qos_options(&p_opts->qos_sw0_options,
+ &p_opts->file_opts->qos_sw0_options);
+ subn_init_qos_options(&p_opts->qos_swe_options,
+ &p_opts->file_opts->qos_swe_options);
+ subn_init_qos_options(&p_opts->qos_rtr_options,
+ &p_opts->file_opts->qos_rtr_options);
+
+ while (fgets(line, 1023, opts_file) != NULL) {
+ pound_sign = strchr(line,'#');
+ token_matched = 0;
+
+ /* Truncate any comments. */
+ if (pound_sign)
+ *pound_sign = '\0';
+
+ /* get the first token */
+ p_key = strtok_r(line, " \t\n", &p_val);
+ if (!p_key)
+ continue;
+
+ p_val = clean_val(p_val);
+
+ for (r = opt_tbl; r->name; r++) {
+ if (strcmp(r->name, p_key))
+ continue;
+
+ token_matched = 1;
+
+ if (!r->can_update)
+ continue;
+
+ p_field1 = (void *)p_opts->file_opts + r->opt_offset;
+ p_field2 = (void *)p_opts + r->opt_offset;
+ r->parse_fn(p_subn, p_key, p_val, p_field1, p_field2,
+ r->setup_fn);
+ break;
+ }
+ if (!token_matched)
+ log_report(" Unrecognized token: \"%s\"\n", p_key);
+ }
+ fclose(opts_file);
+
+ osm_subn_verify_config(p_opts);
+
+ parse_prefix_routes_file(p_subn);
+
+ parse_per_mod_logging_file(p_subn);
+
+ return 0;
+}
+
+void osm_subn_output_conf(FILE *out, IN osm_subn_opt_t * p_opts)
+{
+ int cacongoutputcount = 0;
+ int i;
+
+ fprintf(out,
+ "#\n# DEVICE ATTRIBUTES OPTIONS\n#\n"
+ "# The port GUID on which the OpenSM is running\n"
+ "guid 0x%016" PRIx64 "\n\n"
+ "# M_Key value sent to all ports qualifying all Set(PortInfo)\n"
+ "m_key 0x%016" PRIx64 "\n\n"
+ "# The lease period used for the M_Key on this subnet in [sec]\n"
+ "m_key_lease_period %u\n\n"
+ "# The protection level used for the M_Key on this subnet\n"
+ "m_key_protection_level %u\n\n"
+ "# If TRUE, SM tries to determine the m_key of unknown ports from guid2mkey file\n"
+ "# If FALSE, SM won't try to determine the m_key of unknown ports.\n"
+ "# Preconfigured m_key will be used instead\n"
+ "m_key_lookup %s\n\n"
+ "# SM_Key value of the SM used for SM authentication\n"
+ "sm_key 0x%016" PRIx64 "\n\n"
+ "# SM_Key value to qualify rcv SA queries as 'trusted'\n"
+ "sa_key 0x%016" PRIx64 "\n\n"
+ "# Note that for both values above (sm_key and sa_key)\n"
+ "# OpenSM version 3.2.1 and below used the default value '1'\n"
+ "# in a host byte order, it is fixed now but you may need to\n"
+ "# change the values to interoperate with old OpenSM running\n"
+ "# on a little endian machine.\n\n"
+ "# Subnet prefix used on this subnet\n"
+ "subnet_prefix 0x%016" PRIx64 "\n\n"
+ "# The LMC value used on this subnet\n"
+ "lmc %u\n\n"
+ "# lmc_esp0 determines whether LMC value used on subnet is used for\n"
+ "# enhanced switch port 0. If TRUE, LMC value for subnet is used for\n"
+ "# ESP0. Otherwise, LMC value for ESP0s is 0.\n"
+ "lmc_esp0 %s\n\n"
+ "# sm_sl determines SMSL used for SM/SA communication\n"
+ "sm_sl %u\n\n"
+ "# The code of maximal time a packet can live in a switch\n"
+ "# The actual time is 4.096usec * 2^<packet_life_time>\n"
+ "# The value 0x14 disables this mechanism\n"
+ "packet_life_time 0x%02x\n\n"
+ "# The number of sequential packets dropped that cause the port\n"
+ "# to enter the VLStalled state. The result of setting this value to\n"
+ "# zero is undefined.\n"
+ "vl_stall_count 0x%02x\n\n"
+ "# The number of sequential packets dropped that cause the port\n"
+ "# to enter the VLStalled state. This value is for switch ports\n"
+ "# driving a CA or router port. The result of setting this value\n"
+ "# to zero is undefined.\n"
+ "leaf_vl_stall_count 0x%02x\n\n"
+ "# The code of maximal time a packet can wait at the head of\n"
+ "# transmission queue.\n"
+ "# The actual time is 4.096usec * 2^<head_of_queue_lifetime>\n"
+ "# The value 0x14 disables this mechanism\n"
+ "head_of_queue_lifetime 0x%02x\n\n"
+ "# The maximal time a packet can wait at the head of queue on\n"
+ "# switch port connected to a CA or router port\n"
+ "leaf_head_of_queue_lifetime 0x%02x\n\n"
+ "# Limit the maximal operational VLs\n"
+ "max_op_vls %u\n\n"
+ "# Force PortInfo:LinkSpeedEnabled on switch ports\n"
+ "# If 0, don't modify PortInfo:LinkSpeedEnabled on switch port\n"
+ "# Otherwise, use value for PortInfo:LinkSpeedEnabled on switch port\n"
+ "# Values are (IB Spec 1.2.1, 14.2.5.6 Table 146 \"PortInfo\")\n"
+ "# 1: 2.5 Gbps\n"
+ "# 3: 2.5 or 5.0 Gbps\n"
+ "# 5: 2.5 or 10.0 Gbps\n"
+ "# 7: 2.5 or 5.0 or 10.0 Gbps\n"
+ "# 2,4,6,8-14 Reserved\n"
+ "# Default 15: set to PortInfo:LinkSpeedSupported\n"
+ "force_link_speed %u\n\n"
+ "# Force PortInfo:LinkSpeedExtEnabled on ports\n"
+ "# If 0, don't modify PortInfo:LinkSpeedExtEnabled on port\n"
+ "# Otherwise, use value for PortInfo:LinkSpeedExtEnabled on port\n"
+ "# Values are (MgtWG RefID #4722)\n"
+ "# 1: 14.0625 Gbps\n"
+ "# 2: 25.78125 Gbps\n"
+ "# 3: 14.0625 Gbps or 25.78125 Gbps\n"
+ "# 30: Disable extended link speeds\n"
+ "# Default 31: set to PortInfo:LinkSpeedExtSupported\n"
+ "force_link_speed_ext %u\n\n"
+ "# FDR10 on ports on devices that support FDR10\n"
+ "# Values are:\n"
+ "# 0: don't use fdr10 (no MLNX ExtendedPortInfo MADs)\n"
+ "# Default 1: enable fdr10 when supported\n"
+ "# 2: disable fdr10 when supported\n"
+ "fdr10 %u\n\n"
+ "# The subnet_timeout code that will be set for all the ports\n"
+ "# The actual timeout is 4.096usec * 2^<subnet_timeout>\n"
+ "subnet_timeout %u\n\n"
+ "# Threshold of local phy errors for sending Trap 129\n"
+ "local_phy_errors_threshold 0x%02x\n\n"
+ "# Threshold of credit overrun errors for sending Trap 130\n"
+ "overrun_errors_threshold 0x%02x\n\n"
+ "# Use SwitchInfo:MulticastFDBTop if advertised in PortInfo:CapabilityMask\n"
+ "use_mfttop %s\n\n",
+ cl_ntoh64(p_opts->guid),
+ cl_ntoh64(p_opts->m_key),
+ cl_ntoh16(p_opts->m_key_lease_period),
+ p_opts->m_key_protect_bits,
+ p_opts->m_key_lookup ? "TRUE" : "FALSE",
+ cl_ntoh64(p_opts->sm_key),
+ cl_ntoh64(p_opts->sa_key),
+ cl_ntoh64(p_opts->subnet_prefix),
+ p_opts->lmc,
+ p_opts->lmc_esp0 ? "TRUE" : "FALSE",
+ p_opts->sm_sl,
+ p_opts->packet_life_time,
+ p_opts->vl_stall_count,
+ p_opts->leaf_vl_stall_count,
+ p_opts->head_of_queue_lifetime,
+ p_opts->leaf_head_of_queue_lifetime,
+ p_opts->max_op_vls,
+ p_opts->force_link_speed,
+ p_opts->force_link_speed_ext,
+ p_opts->fdr10,
+ p_opts->subnet_timeout,
+ p_opts->local_phy_errors_threshold,
+ p_opts->overrun_errors_threshold,
+ p_opts->use_mfttop ? "TRUE" : "FALSE");
+
+ fprintf(out,
+ "#\n# PARTITIONING OPTIONS\n#\n"
+ "# Partition configuration file to be used\n"
+ "partition_config_file %s\n\n"
+ "# Disable partition enforcement by switches (DEPRECATED)\n"
+ "# This option is DEPRECATED. Please use part_enforce instead\n"
+ "no_partition_enforcement %s\n\n"
+ "# Partition enforcement type (for switches)\n"
+ "# Values are both, out, in and off\n"
+ "# Default is both (outbound and inbound enforcement)\n"
+ "part_enforce %s\n\n"
+ "# Allow both full and limited membership on the same partition\n"
+ "allow_both_pkeys %s\n\n"
+ "# SM assigned GUID byte where GUID is formed from OpenFabrics OUI\n"
+ "# followed by 40 bits xy 00 ab cd ef where xy is the SM assigned GUID byte\n"
+ "# and ab cd ef is an SM autogenerated 24 bits\n"
+ "# SM assigned GUID byte should be configured as subnet unique\n"
+ "sm_assigned_guid 0x%02x\n\n",
+ p_opts->partition_config_file,
+ p_opts->no_partition_enforcement ? "TRUE" : "FALSE",
+ p_opts->part_enforce,
+ p_opts->allow_both_pkeys ? "TRUE" : "FALSE",
+ p_opts->sm_assigned_guid);
+
+ fprintf(out,
+ "#\n# SWEEP OPTIONS\n#\n"
+ "# The number of seconds between subnet sweeps (0 disables it)\n"
+ "sweep_interval %u\n\n"
+ "# If TRUE cause all lids to be reassigned\n"
+ "reassign_lids %s\n\n"
+ "# If TRUE forces every sweep to be a heavy sweep\n"
+ "force_heavy_sweep %s\n\n"
+ "# If TRUE every trap 128 and 144 will cause a heavy sweep.\n"
+ "# NOTE: successive identical traps (>10) are suppressed\n"
+ "sweep_on_trap %s\n\n",
+ p_opts->sweep_interval,
+ p_opts->reassign_lids ? "TRUE" : "FALSE",
+ p_opts->force_heavy_sweep ? "TRUE" : "FALSE",
+ p_opts->sweep_on_trap ? "TRUE" : "FALSE");
+
+ fprintf(out,
+ "#\n# ROUTING OPTIONS\n#\n"
+ "# If TRUE count switches as link subscriptions\n"
+ "port_profile_switch_nodes %s\n\n",
+ p_opts->port_profile_switch_nodes ? "TRUE" : "FALSE");
+
+ fprintf(out,
+ "# Name of file with port guids to be ignored by port profiling\n"
+ "port_prof_ignore_file %s\n\n", p_opts->port_prof_ignore_file ?
+ p_opts->port_prof_ignore_file : null_str);
+
+ fprintf(out,
+ "# The file holding routing weighting factors per output port\n"
+ "hop_weights_file %s\n\n",
+ p_opts->hop_weights_file ? p_opts->hop_weights_file : null_str);
+
+ fprintf(out,
+ "# The file holding non-default port order per switch for routing\n"
+ "port_search_ordering_file %s\n\n",
+ p_opts->port_search_ordering_file ?
+ p_opts->port_search_ordering_file : null_str);
+
+ fprintf(out,
+ "# Routing engine\n"
+ "# Multiple routing engines can be specified separated by\n"
+ "# commas so that specific ordering of routing algorithms will\n"
+ "# be tried if earlier routing engines fail.\n"
+ "# Supported engines: minhop, updn, dnup, file, ftree, lash,\n"
+ "# dor, torus-2QoS, dfsssp, sssp\n"
+ "routing_engine %s\n\n", p_opts->routing_engine_names ?
+ p_opts->routing_engine_names : null_str);
+
+ fprintf(out,
+ "# Connect roots (use FALSE if unsure)\n"
+ "connect_roots %s\n\n",
+ p_opts->connect_roots ? "TRUE" : "FALSE");
+
+ fprintf(out,
+ "# Use unicast routing cache (use FALSE if unsure)\n"
+ "use_ucast_cache %s\n\n",
+ p_opts->use_ucast_cache ? "TRUE" : "FALSE");
+
+ fprintf(out,
+ "# Lid matrix dump file name\n"
+ "lid_matrix_dump_file %s\n\n", p_opts->lid_matrix_dump_file ?
+ p_opts->lid_matrix_dump_file : null_str);
+
+ fprintf(out,
+ "# LFTs file name\nlfts_file %s\n\n",
+ p_opts->lfts_file ? p_opts->lfts_file : null_str);
+
+ fprintf(out,
+ "# The file holding the root node guids (for fat-tree or Up/Down)\n"
+ "# One guid in each line\nroot_guid_file %s\n\n",
+ p_opts->root_guid_file ? p_opts->root_guid_file : null_str);
+
+ fprintf(out,
+ "# The file holding the fat-tree compute node guids\n"
+ "# One guid in each line\ncn_guid_file %s\n\n",
+ p_opts->cn_guid_file ? p_opts->cn_guid_file : null_str);
+
+ fprintf(out,
+ "# The file holding the fat-tree I/O node guids\n"
+ "# One guid in each line.\n"
+ "# If only io_guid file is provided, the rest of nodes\n"
+ "# are considered as compute nodes.\n"
+ "io_guid_file %s\n\n",
+ p_opts->io_guid_file ? p_opts->io_guid_file : null_str);
+
+ fprintf(out,
+ "# If TRUE enables alternative indexing policy for ftree routing\n"
+ "# in quasi-ftree topologies that can improve shift-pattern support.\n"
+ "# The switch indexing starts from root switch and leaf switches\n"
+ "# are termination points of BFS algorithm\n"
+ "# If FALSE, the indexing starts from leaf switch (default)\n"
+ "quasi_ftree_indexing %s\n\n",
+ p_opts->quasi_ftree_indexing ? "TRUE" : "FALSE");
+
+ fprintf(out,
+ "# Number of reverse hops allowed for I/O nodes\n"
+ "# Used for connectivity between I/O nodes connected to Top Switches\nmax_reverse_hops %d\n\n",
+ p_opts->max_reverse_hops);
+
+ fprintf(out,
+ "# The file holding the node ids which will be used by"
+ " Up/Down algorithm instead\n# of GUIDs (one guid and"
+ " id in each line)\nids_guid_file %s\n\n",
+ p_opts->ids_guid_file ? p_opts->ids_guid_file : null_str);
+
+ fprintf(out,
+ "# The file holding guid routing order guids (for MinHop and Up/Down)\n"
+ "guid_routing_order_file %s\n\n",
+ p_opts->guid_routing_order_file ? p_opts->guid_routing_order_file : null_str);
+
+ fprintf(out,
+ "# Do mesh topology analysis (for LASH algorithm)\n"
+ "do_mesh_analysis %s\n\n",
+ p_opts->do_mesh_analysis ? "TRUE" : "FALSE");
+
+ fprintf(out,
+ "# Starting VL for LASH algorithm\n"
+ "lash_start_vl %u\n\n",
+ p_opts->lash_start_vl);
+
+ fprintf(out,
+ "# Port Shifting (use FALSE if unsure)\n"
+ "port_shifting %s\n\n",
+ p_opts->port_shifting ? "TRUE" : "FALSE");
+
+ fprintf(out,
+ "# Assign ports in a random order instead of round-robin\n"
+ "# If zero disable (default), otherwise use the value as a random seed\n"
+ "scatter_ports %d\n\n",
+ p_opts->scatter_ports);
+
+ fprintf(out,
+ "# Don't use scatter for ports defined in\n"
+ "# guid_routing_order file\n"
+ "guid_routing_order_no_scatter %s\n\n",
+ p_opts->guid_routing_order_no_scatter ? "TRUE" : "FALSE");
+
+ fprintf(out,
+ "# SA database file name\nsa_db_file %s\n\n",
+ p_opts->sa_db_file ? p_opts->sa_db_file : null_str);
+
+ fprintf(out,
+ "# If TRUE causes OpenSM to dump SA database at the end of\n"
+ "# every light sweep, regardless of the verbosity level\n"
+ "sa_db_dump %s\n\n",
+ p_opts->sa_db_dump ? "TRUE" : "FALSE");
+
+ fprintf(out,
+ "# Torus-2QoS configuration file name\ntorus_config %s\n\n",
+ p_opts->torus_conf_file ? p_opts->torus_conf_file : null_str);
+
+ fprintf(out,
+ "#\n# HANDOVER - MULTIPLE SMs OPTIONS\n#\n"
+ "# SM priority used for deciding who is the master\n"
+ "# Range goes from 0 (lowest priority) to 15 (highest).\n"
+ "sm_priority %u\n\n"
+ "# If TRUE other SMs on the subnet should be ignored\n"
+ "ignore_other_sm %s\n\n"
+ "# Timeout in [msec] between two polls of active master SM\n"
+ "sminfo_polling_timeout %u\n\n"
+ "# Number of failing polls of remote SM that declares it dead\n"
+ "polling_retry_number %u\n\n"
+ "# If TRUE honor the guid2lid file when coming out of standby\n"
+ "# state, if such file exists and is valid\n"
+ "honor_guid2lid_file %s\n\n",
+ p_opts->sm_priority,
+ p_opts->ignore_other_sm ? "TRUE" : "FALSE",
+ p_opts->sminfo_polling_timeout,
+ p_opts->polling_retry_number,
+ p_opts->honor_guid2lid_file ? "TRUE" : "FALSE");
+
+ fprintf(out,
+ "#\n# TIMING AND THREADING OPTIONS\n#\n"
+ "# Maximum number of SMPs sent in parallel\n"
+ "max_wire_smps %u\n\n"
+ "# Maximum number of timeout based SMPs allowed to be outstanding\n"
+ "# A value less than or equal to max_wire_smps disables this mechanism\n"
+ "max_wire_smps2 %u\n\n"
+ "# The timeout in [usec] used for sending SMPs above max_wire_smps limit\n"
+ "# and below max_wire_smps2 limit\n"
+ "max_smps_timeout %u\n\n"
+ "# The maximum time in [msec] allowed for a transaction to complete\n"
+ "transaction_timeout %u\n\n"
+ "# The maximum number of retries allowed for a transaction to complete\n"
+ "transaction_retries %u\n\n"
+ "# Maximal time in [msec] a message can stay in the incoming message queue.\n"
+ "# If there is more than one message in the queue and the last message\n"
+ "# stayed in the queue more than this value, any SA request will be\n"
+ "# immediately be dropped but BUSY status is not currently returned.\n"
+ "max_msg_fifo_timeout %u\n\n"
+ "# Use a single thread for handling SA queries\n"
+ "single_thread %s\n\n",
+ p_opts->max_wire_smps,
+ p_opts->max_wire_smps2,
+ p_opts->max_smps_timeout,
+ p_opts->transaction_timeout,
+ p_opts->transaction_retries,
+ p_opts->max_msg_fifo_timeout,
+ p_opts->single_thread ? "TRUE" : "FALSE");
+
+ fprintf(out,
+ "#\n# MISC OPTIONS\n#\n"
+ "# Daemon mode\n"
+ "daemon %s\n\n"
+ "# SM Inactive\n"
+ "sm_inactive %s\n\n"
+ "# Babbling Port Policy\n"
+ "babbling_port_policy %s\n\n"
+ "# Drop event subscriptions (InformInfo and ServiceRecord) on port removal and SM coming out of STANDBY\n"
+ "drop_event_subscriptions %s\n\n"
+ "# Validate IPoIB non-broadcast group creation parameters against\n"
+ "# broadcast group parameters per IETF RFC 4391 (default TRUE)\n"
+ "ipoib_mcgroup_creation_validation %s\n\n"
+ "# Validate multicast join parameters against multicast group\n"
+ "# parameters when MC group already exists\n"
+ "mcgroup_join_validation %s\n\n"
+ "# Use Optimized SLtoVLMapping programming if supported by device\n"
+ "use_optimized_slvl %s\n\n"
+ "# Sync in memory files used for high availability with storage\n"
+ "fsync_high_avail_files %s\n\n",
+ p_opts->daemon ? "TRUE" : "FALSE",
+ p_opts->sm_inactive ? "TRUE" : "FALSE",
+ p_opts->babbling_port_policy ? "TRUE" : "FALSE",
+ p_opts->drop_event_subscriptions ? "TRUE" : "FALSE",
+ p_opts->ipoib_mcgroup_creation_validation ? "TRUE" : "FALSE",
+ p_opts->mcgroup_join_validation ? "TRUE" : "FALSE",
+ p_opts->use_optimized_slvl ? "TRUE" : "FALSE",
+ p_opts->fsync_high_avail_files ? "TRUE" : "FALSE");
+
+#ifdef ENABLE_OSM_PERF_MGR
+ fprintf(out,
+ "#\n# Performance Manager Options\n#\n"
+ "# perfmgr enable\n"
+ "# PerfMgr is enabled if TRUE and disabled if FALSE (default FALSE)\n"
+ "perfmgr %s\n\n"
+ "# redirection enable\n"
+ "# Redirection supported if TRUE and not supported if FALSE (default TRUE)\n"
+ "perfmgr_redir %s\n\n"
+ "# sweep time in seconds (default %u seconds)\n"
+ "perfmgr_sweep_time_s %u\n\n"
+ "# Max outstanding queries (default %u)\n"
+ "perfmgr_max_outstanding_queries %u\n\n"
+ "# Ignore CAs on sweep (default FALSE)\n"
+ "perfmgr_ignore_cas %s\n\n"
+ "# Remove missing nodes from DB (default TRUE)\n"
+ "perfmgr_rm_nodes %s\n\n"
+ "# Log error counters to opensm.log (default TRUE)\n"
+ "perfmgr_log_errors %s\n\n"
+ "# Query PerfMgt Get(ClassPortInfo) for extended capabilities\n"
+ "# Extended capabilities include 64 bit extended counters\n"
+ "# and transmit wait support (default TRUE)\n"
+ "perfmgr_query_cpi %s\n\n"
+ "# Log xmit_wait errors (default FALSE)\n"
+ "perfmgr_xmit_wait_log %s\n\n"
+ "# If logging xmit_wait's; set threshold (default %u)\n"
+ "perfmgr_xmit_wait_threshold %u\n\n"
+ ,
+ p_opts->perfmgr ? "TRUE" : "FALSE",
+ p_opts->perfmgr_redir ? "TRUE" : "FALSE",
+ OSM_PERFMGR_DEFAULT_SWEEP_TIME_S,
+ p_opts->perfmgr_sweep_time_s,
+ OSM_PERFMGR_DEFAULT_MAX_OUTSTANDING_QUERIES,
+ p_opts->perfmgr_max_outstanding_queries,
+ p_opts->perfmgr_ignore_cas ? "TRUE" : "FALSE",
+ p_opts->perfmgr_rm_nodes ? "TRUE" : "FALSE",
+ p_opts->perfmgr_log_errors ? "TRUE" : "FALSE",
+ p_opts->perfmgr_query_cpi ? "TRUE" : "FALSE",
+ p_opts->perfmgr_xmit_wait_log ? "TRUE" : "FALSE",
+ OSM_PERFMGR_DEFAULT_XMIT_WAIT_THRESHOLD,
+ p_opts->perfmgr_xmit_wait_threshold);
+
+ fprintf(out,
+ "#\n# Event DB Options\n#\n"
+ "# Dump file to dump the events to\n"
+ "event_db_dump_file %s\n\n", p_opts->event_db_dump_file ?
+ p_opts->event_db_dump_file : null_str);
+#endif /* ENABLE_OSM_PERF_MGR */
+
+ fprintf(out,
+ "#\n# Event Plugin Options\n#\n"
+ "# Event plugin name(s)\n"
+ "event_plugin_name %s\n\n"
+ "# Options string that would be passed to the plugin(s)\n"
+ "event_plugin_options %s\n\n",
+ p_opts->event_plugin_name ?
+ p_opts->event_plugin_name : null_str,
+ p_opts->event_plugin_options ?
+ p_opts->event_plugin_options : null_str);
+
+ fprintf(out,
+ "#\n# Node name map for mapping node's to more descriptive node descriptions\n"
+ "# (man ibnetdiscover for more information)\n#\n"
+ "node_name_map_name %s\n\n", p_opts->node_name_map_name ?
+ p_opts->node_name_map_name : null_str);
+
+ fprintf(out,
+ "#\n# DEBUG FEATURES\n#\n"
+ "# The log flags used\n"
+ "log_flags 0x%02x\n\n"
+ "# Force flush of the log file after each log message\n"
+ "force_log_flush %s\n\n"
+ "# Log file to be used\n"
+ "log_file %s\n\n"
+ "# Limit the size of the log file in MB. If overrun, log is restarted\n"
+ "log_max_size %u\n\n"
+ "# If TRUE will accumulate the log over multiple OpenSM sessions\n"
+ "accum_log_file %s\n\n"
+ "# Per module logging configuration file\n"
+ "# Each line in config file contains <module_name><separator><log_flags>\n"
+ "# where module_name is file name including .c\n"
+ "# separator is either = , space, or tab\n"
+ "# log_flags is the same flags as used in the coarse/overall logging\n"
+ "per_module_logging_file %s\n\n"
+ "# The directory to hold the file OpenSM dumps\n"
+ "dump_files_dir %s\n\n"
+ "# If TRUE enables new high risk options and hardware specific quirks\n"
+ "enable_quirks %s\n\n"
+ "# If TRUE disables client reregistration\n"
+ "no_clients_rereg %s\n\n"
+ "# If TRUE OpenSM should disable multicast support and\n"
+ "# no multicast routing is performed if TRUE\n"
+ "disable_multicast %s\n\n"
+ "# If TRUE opensm will exit on fatal initialization issues\n"
+ "exit_on_fatal %s\n\n" "# console [off|local"
+#ifdef ENABLE_OSM_CONSOLE_LOOPBACK
+ "|loopback"
+#endif
+#ifdef ENABLE_OSM_CONSOLE_SOCKET
+ "|socket]\n"
+#else
+ "]\n"
+#endif
+ "console %s\n\n"
+ "# Telnet port for console (default %d)\n"
+ "console_port %d\n\n",
+ p_opts->log_flags,
+ p_opts->force_log_flush ? "TRUE" : "FALSE",
+ p_opts->log_file,
+ p_opts->log_max_size,
+ p_opts->accum_log_file ? "TRUE" : "FALSE",
+ p_opts->per_module_logging_file ?
+ p_opts->per_module_logging_file : null_str,
+ p_opts->dump_files_dir,
+ p_opts->enable_quirks ? "TRUE" : "FALSE",
+ p_opts->no_clients_rereg ? "TRUE" : "FALSE",
+ p_opts->disable_multicast ? "TRUE" : "FALSE",
+ p_opts->exit_on_fatal ? "TRUE" : "FALSE",
+ p_opts->console,
+ OSM_DEFAULT_CONSOLE_PORT, p_opts->console_port);
+
+ fprintf(out,
+ "#\n# QoS OPTIONS\n#\n"
+ "# Enable QoS setup\n"
+ "qos %s\n\n"
+ "# QoS policy file to be used\n"
+ "qos_policy_file %s\n"
+ "# Supress QoS MAD status errors\n"
+ "suppress_sl2vl_mad_status_errors %s\n\n",
+ p_opts->qos ? "TRUE" : "FALSE", p_opts->qos_policy_file,
+ p_opts->suppress_sl2vl_mad_status_errors ? "TRUE" : "FALSE");
+
+ subn_dump_qos_options(out,
+ "QoS default options", "qos",
+ &p_opts->qos_options);
+ fprintf(out, "\n");
+ subn_dump_qos_options(out,
+ "QoS CA options", "qos_ca",
+ &p_opts->qos_ca_options);
+ fprintf(out, "\n");
+ subn_dump_qos_options(out,
+ "QoS Switch Port 0 options", "qos_sw0",
+ &p_opts->qos_sw0_options);
+ fprintf(out, "\n");
+ subn_dump_qos_options(out,
+ "QoS Switch external ports options", "qos_swe",
+ &p_opts->qos_swe_options);
+ fprintf(out, "\n");
+ subn_dump_qos_options(out,
+ "QoS Router ports options", "qos_rtr",
+ &p_opts->qos_rtr_options);
+ fprintf(out, "\n");
+
+ fprintf(out,
+ "#\n# Congestion Control OPTIONS (EXPERIMENTAL)\n#\n\n"
+ "# Enable Congestion Control Configuration\n"
+ "congestion_control %s\n\n"
+ "# CCKey to use when configuring congestion control\n"
+ "# note that this does not configure a new CCkey, only the CCkey to use\n"
+ "cc_key 0x%016" PRIx64 "\n\n"
+ "# Congestion Control Max outstanding MAD\n"
+ "cc_max_outstanding_mads %u\n\n",
+ p_opts->congestion_control ? "TRUE" : "FALSE",
+ cl_ntoh64(p_opts->cc_key),
+ p_opts->cc_max_outstanding_mads);
+
+ fprintf(out,
+ "#\n# Congestion Control SwitchCongestionSetting options\n#\n"
+ "# Control Map - bitmask indicating which of the following are to be used\n"
+ "# bit 0 - victim mask\n"
+ "# bit 1 - credit mask\n"
+ "# bit 2 - threshold + packet size\n"
+ "# bit 3 - credit starvation threshold + return delay valid\n"
+ "# bit 4 - marking rate valid\n"
+ "cc_sw_cong_setting_control_map 0x%X\n\n",
+ cl_ntoh32(p_opts->cc_sw_cong_setting_control_map));
+
+ fprintf(out,
+ "# Victim Mask - 256 bit mask representing switch ports, mark packets with FECN\n"
+ "# whether they are the source or victim of congestion\n"
+ "# bit 0 - port 0 (enhanced port)\n"
+ "# bit 1 - port 1\n"
+ "# ...\n"
+ "# bit 254 - port 254\n"
+ "# bit 255 - reserved\n"
+ "cc_sw_cong_setting_victim_mask 0x");
+
+ for (i = 0; i < IB_CC_PORT_MASK_DATA_SIZE; i++)
+ fprintf(out, "%02X", p_opts->cc_sw_cong_setting_victim_mask[i]);
+ fprintf(out, "\n\n");
+
+ fprintf(out,
+ "# Credit Mask - 256 bit mask representing switch ports to apply credit starvation\n"
+ "# bit 0 - port 0 (enhanced port)\n"
+ "# bit 1 - port 1\n"
+ "# ...\n"
+ "# bit 254 - port 254\n"
+ "# bit 255 - reserved\n"
+ "cc_sw_cong_setting_credit_mask 0x");
+
+ for (i = 0; i < IB_CC_PORT_MASK_DATA_SIZE; i++)
+ fprintf(out, "%02X", p_opts->cc_sw_cong_setting_credit_mask[i]);
+ fprintf(out, "\n\n");
+
+ fprintf(out,
+ "# Threshold - value indicating aggressiveness of congestion marking\n"
+ "# 0x0 - none, 0x1 - loose, ..., 0xF - aggressive\n"
+ "cc_sw_cong_setting_threshold 0x%02X\n\n"
+ "# Packet Size - any packet less than this size will not be marked with a FECN\n"
+ "# units are in credits\n"
+ "cc_sw_cong_setting_packet_size %u\n\n"
+ "# Credit Starvation Threshold - value indicating aggressiveness of credit starvation\n"
+ "# 0x0 - none, 0x1 - loose, ..., 0xF - aggressive\n"
+ "cc_sw_cong_setting_credit_starvation_threshold 0x%02X\n\n"
+ "# Credit Starvation Return Delay - in CCT entry shift:multiplier format, see IB spec\n"
+ "cc_sw_cong_setting_credit_starvation_return_delay %u:%u\n\n"
+ "# Marking Rate - mean number of packets between markings\n"
+ "cc_sw_cong_setting_marking_rate %u\n\n",
+ p_opts->cc_sw_cong_setting_threshold,
+ p_opts->cc_sw_cong_setting_packet_size,
+ p_opts->cc_sw_cong_setting_credit_starvation_threshold,
+ p_opts->cc_sw_cong_setting_credit_starvation_return_delay.shift,
+ p_opts->cc_sw_cong_setting_credit_starvation_return_delay.multiplier,
+ cl_ntoh16(p_opts->cc_sw_cong_setting_marking_rate));
+
+ fprintf(out,
+ "#\n# Congestion Control CA Congestion Setting options\n#\n"
+ "# Port Control\n"
+ "# bit 0 = 0, QP based congestion control\n"
+ "# bit 0 = 1, SL/port based congestion control\n"
+ "cc_ca_cong_setting_port_control 0x%04X\n\n"
+ "# Control Map - 16 bit bitmask indicating which SLs should be configured\n"
+ "cc_ca_cong_setting_control_map 0x%04X\n\n",
+ cl_ntoh16(p_opts->cc_ca_cong_setting_port_control),
+ cl_ntoh16(p_opts->cc_ca_cong_setting_control_map));
+
+ fprintf(out,
+ "#\n# CA Congestion Setting Entries\n#\n"
+ "# Each of congestion control settings below configures the CA Congestion\n"
+ "# Settings for an individual SL. The SL must be specified before the value.\n"
+ "# These options may be specified multiple times to configure different values\n"
+ "# for different SLs.\n"
+ "#\n"
+ "# ccti timer - when expires decrements 1 from the CCTI\n"
+ "# ccti increase - number to be added to the table index on receipt of a BECN\n"
+ "# trigger threshold - when the ccti is equal to this, an event is logged\n"
+ "# ccti min - the minimum value for the ccti. This imposes a minimum rate\n"
+ "# on the injection rate\n\n");
+
+ for (i = 0; i < IB_CA_CONG_ENTRY_DATA_SIZE; i++) {
+ /* Don't output unless one of the settings has been set, there's no need
+ * to output 16 chunks of this with all defaults of 0 */
+ if (p_opts->cc_ca_cong_entries[i].ccti_timer
+ || p_opts->cc_ca_cong_entries[i].ccti_increase
+ || p_opts->cc_ca_cong_entries[i].trigger_threshold
+ || p_opts->cc_ca_cong_entries[i].ccti_min) {
+ fprintf(out,
+ "# SL = %u\n"
+ "cc_ca_cong_setting_ccti_timer %u %u\n"
+ "cc_ca_cong_setting_ccti_increase %u %u\n"
+ "cc_ca_cong_setting_trigger_threshold %u %u\n"
+ "cc_ca_cong_setting_ccti_min %u %u\n\n",
+ i,
+ i,
+ cl_ntoh16(p_opts->cc_ca_cong_entries[i].ccti_timer),
+ i,
+ p_opts->cc_ca_cong_entries[i].ccti_increase,
+ i,
+ p_opts->cc_ca_cong_entries[i].trigger_threshold,
+ i,
+ p_opts->cc_ca_cong_entries[i].ccti_min);
+ cacongoutputcount++;
+ }
+ }
+
+ /* If by chance all the CA Cong Settings are default, output at least 1 chunk
+ * for illustration */
+ if (!cacongoutputcount)
+ fprintf(out,
+ "# SL = 0\n"
+ "cc_ca_cong_setting_ccti_timer 0 %u\n"
+ "cc_ca_cong_setting_ccti_increase 0 %u\n"
+ "cc_ca_cong_setting_trigger_threshold 0 %u\n"
+ "cc_ca_cong_setting_ccti_min 0 %u\n\n",
+ cl_ntoh16(p_opts->cc_ca_cong_entries[0].ccti_timer),
+ p_opts->cc_ca_cong_entries[0].ccti_increase,
+ p_opts->cc_ca_cong_entries[0].trigger_threshold,
+ p_opts->cc_ca_cong_entries[0].ccti_min);
+
+ fprintf(out,
+ "#\n# Congestion Control Table\n#\n"
+ "# Comma separated list of CCT entries representing CCT.\n"
+ "# Format is shift:multipler,shift_multiplier,shift:multiplier,...\n"
+ "cc_cct ");
+
+ if (!p_opts->cc_cct.entries_len) {
+ fprintf(out, "%s\n", null_str);
+ }
+ else {
+ fprintf(out, "%u:%u",
+ p_opts->cc_cct.entries[0].shift,
+ p_opts->cc_cct.entries[0].multiplier);
+ for (i = 1; i < p_opts->cc_cct.entries_len; i++) {
+ fprintf(out, ",%u:%u",
+ p_opts->cc_cct.entries[i].shift,
+ p_opts->cc_cct.entries[i].multiplier);
+ }
+ fprintf(out, "\n");
+ }
+ fprintf(out, "\n");
+
+ fprintf(out,
+ "# Prefix routes file name\n"
+ "prefix_routes_file %s\n\n",
+ p_opts->prefix_routes_file);
+
+ fprintf(out,
+ "#\n# IPv6 Solicited Node Multicast (SNM) Options\n#\n"
+ "consolidate_ipv6_snm_req %s\n\n",
+ p_opts->consolidate_ipv6_snm_req ? "TRUE" : "FALSE");
+
+ fprintf(out, "# Log prefix\nlog_prefix %s\n\n", p_opts->log_prefix);
+
+ /* optional string attributes ... */
+
+}
+
+int osm_subn_write_conf_file(char *file_name, IN osm_subn_opt_t * p_opts)
+{
+ FILE *opts_file;
+
+ opts_file = fopen(file_name, "w");
+ if (!opts_file) {
+ printf("cannot open file \'%s\' for writing: %s\n",
+ file_name, strerror(errno));
+ return -1;
+ }
+
+ osm_subn_output_conf(opts_file, p_opts);
+
+ fclose(opts_file);
+
+ return 0;
+}
diff --git a/contrib/ofed/opensm/opensm/osm_sw_info_rcv.c b/contrib/ofed/opensm/opensm/osm_sw_info_rcv.c
new file mode 100644
index 0000000..e8c056b
--- /dev/null
+++ b/contrib/ofed/opensm/opensm/osm_sw_info_rcv.c
@@ -0,0 +1,454 @@
+/*
+ * Copyright (c) 2004-2009 Voltaire, Inc. All rights reserved.
+ * Copyright (c) 2002-2005,2008 Mellanox Technologies LTD. All rights reserved.
+ * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
+ * Copyright (c) 2009 HNR Consulting. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+/*
+ * Abstract:
+ * Implementation of osm_si_rcv_t.
+ * This object represents the SwitchInfo Receiver object.
+ * This object is part of the opensm family of objects.
+ */
+
+#if HAVE_CONFIG_H
+# include <config.h>
+#endif /* HAVE_CONFIG_H */
+
+#include <string.h>
+#include <iba/ib_types.h>
+#include <complib/cl_qmap.h>
+#include <complib/cl_passivelock.h>
+#include <complib/cl_debug.h>
+#include <opensm/osm_file_ids.h>
+#define FILE_ID OSM_FILE_SW_INFO_RCV_C
+#include <opensm/osm_log.h>
+#include <opensm/osm_switch.h>
+#include <opensm/osm_subnet.h>
+#include <opensm/osm_helper.h>
+#include <opensm/osm_opensm.h>
+
+#if 0
+/**********************************************************************
+ The plock must be held before calling this function.
+**********************************************************************/
+static void si_rcv_get_fwd_tbl(IN osm_sm_t * sm, IN osm_switch_t * p_sw)
+{
+ osm_madw_context_t context;
+ osm_dr_path_t *p_dr_path;
+ osm_physp_t *p_physp;
+ osm_node_t *p_node;
+ uint32_t block_id_ho;
+ uint32_t max_block_id_ho;
+ ib_api_status_t status = IB_SUCCESS;
+
+ OSM_LOG_ENTER(sm->p_log);
+
+ CL_ASSERT(p_sw);
+
+ p_node = p_sw->p_node;
+
+ CL_ASSERT(osm_node_get_type(p_node) == IB_NODE_TYPE_SWITCH);
+
+ context.lft_context.node_guid = osm_node_get_node_guid(p_node);
+ context.lft_context.set_method = FALSE;
+
+ max_block_id_ho = osm_switch_get_max_block_id_in_use(p_sw);
+
+ p_physp = osm_node_get_physp_ptr(p_node, 0);
+ p_dr_path = osm_physp_get_dr_path_ptr(p_physp);
+
+ for (block_id_ho = 0; block_id_ho <= max_block_id_ho; block_id_ho++) {
+ OSM_LOG(sm->p_log, OSM_LOG_DEBUG,
+ "Retrieving FT block %u\n", block_id_ho);
+
+ status = osm_req_get(sm, p_dr_path, IB_MAD_ATTR_LIN_FWD_TBL,
+ cl_hton32(block_id_ho), TRUE, 0,
+ CL_DISP_MSGID_NONE, &context);
+ if (status != IB_SUCCESS)
+ /* continue the loop despite the error */
+ OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR 3603: "
+ "Failure initiating PortInfo request (%s)\n",
+ ib_get_err_str(status));
+ }
+
+ OSM_LOG_EXIT(sm->p_log);
+}
+
+/**********************************************************************
+ The plock must be held before calling this function.
+**********************************************************************/
+static void si_rcv_get_mcast_fwd_tbl(IN osm_sm_t * sm, IN osm_switch_t * p_sw)
+{
+ osm_madw_context_t context;
+ osm_dr_path_t *p_dr_path;
+ osm_physp_t *p_physp;
+ osm_node_t *p_node;
+ osm_mcast_tbl_t *p_tbl;
+ uint32_t block_id_ho;
+ uint32_t max_block_id_ho;
+ uint32_t position;
+ uint32_t max_position;
+ uint32_t attr_mod_ho;
+ ib_api_status_t status = IB_SUCCESS;
+
+ OSM_LOG_ENTER(sm->p_log);
+
+ CL_ASSERT(p_sw);
+
+ p_node = p_sw->p_node;
+
+ CL_ASSERT(osm_node_get_type(p_node) == IB_NODE_TYPE_SWITCH);
+
+ if (osm_switch_get_mcast_fwd_tbl_size(p_sw) == 0) {
+ OSM_LOG(sm->p_log, OSM_LOG_DEBUG,
+ "Multicast not supported by switch 0x%016" PRIx64 "\n",
+ cl_ntoh64(osm_node_get_node_guid(p_node)));
+ goto Exit;
+ }
+
+ context.mft_context.node_guid = osm_node_get_node_guid(p_node);
+ context.mft_context.set_method = FALSE;
+
+ p_tbl = osm_switch_get_mcast_tbl_ptr(p_sw);
+ max_block_id_ho = osm_mcast_tbl_get_max_block(p_tbl);
+
+ if (max_block_id_ho > IB_MCAST_MAX_BLOCK_ID) {
+ OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR 3609: "
+ "Out-of-range mcast block size = %u on switch 0x%016"
+ PRIx64 "\n", max_block_id_ho,
+ cl_ntoh64(osm_node_get_node_guid(p_node)));
+ goto Exit;
+ }
+
+ max_position = osm_mcast_tbl_get_max_position(p_tbl);
+
+ CL_ASSERT(max_position <= IB_MCAST_POSITION_MAX);
+
+ OSM_LOG(sm->p_log, OSM_LOG_DEBUG,
+ "Max MFT block = %u, Max position = %u\n", max_block_id_ho,
+ max_position);
+
+ p_physp = osm_node_get_physp_ptr(p_node, 0);
+ p_dr_path = osm_physp_get_dr_path_ptr(p_physp);
+
+ for (block_id_ho = 0; block_id_ho <= max_block_id_ho; block_id_ho++) {
+ OSM_LOG(sm->p_log, OSM_LOG_DEBUG,
+ "Retrieving MFT block %u\n", block_id_ho);
+
+ for (position = 0; position <= max_position; position++) {
+ OSM_LOG(sm->p_log, OSM_LOG_DEBUG,
+ "Retrieving MFT position %u\n", position);
+
+ attr_mod_ho =
+ block_id_ho | position << IB_MCAST_POSITION_SHIFT;
+ status =
+ osm_req_get(sm, p_dr_path,
+ IB_MAD_ATTR_MCAST_FWD_TBL,
+ cl_hton32(attr_mod_ho), TRUE, 0,
+ CL_DISP_MSGID_NONE, &context);
+ if (status != IB_SUCCESS)
+ /* continue the loop despite the error */
+ OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR 3607: "
+ "Failure initiating PortInfo request (%s)\n",
+ ib_get_err_str(status));
+ }
+ }
+
+Exit:
+ OSM_LOG_EXIT(sm->p_log);
+}
+#endif
+
+/**********************************************************************
+ Lock must be held on entry to this function.
+**********************************************************************/
+static void si_rcv_process_new(IN osm_sm_t * sm, IN osm_node_t * p_node,
+ IN const osm_madw_t * p_madw)
+{
+ osm_switch_t *p_sw;
+ osm_switch_t *p_check;
+ ib_switch_info_t *p_si;
+ ib_smp_t *p_smp;
+ cl_qmap_t *p_sw_guid_tbl;
+
+ CL_ASSERT(sm);
+
+ OSM_LOG_ENTER(sm->p_log);
+
+ CL_ASSERT(p_madw);
+
+ p_sw_guid_tbl = &sm->p_subn->sw_guid_tbl;
+ p_smp = osm_madw_get_smp_ptr(p_madw);
+ p_si = ib_smp_get_payload_ptr(p_smp);
+
+ osm_dump_switch_info_v2(sm->p_log, p_si, FILE_ID, OSM_LOG_DEBUG);
+
+ p_sw = osm_switch_new(p_node, p_madw);
+ if (p_sw == NULL) {
+ OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR 3608: "
+ "Unable to allocate new switch object\n");
+ goto Exit;
+ }
+
+ /* set subnet max mlid to the minimum MulticastFDBCap of all switches */
+ if (p_si->mcast_cap &&
+ cl_ntoh16(p_si->mcast_cap) + IB_LID_MCAST_START_HO - 1 <
+ sm->p_subn->max_mcast_lid_ho) {
+ sm->p_subn->max_mcast_lid_ho = cl_ntoh16(p_si->mcast_cap) +
+ IB_LID_MCAST_START_HO - 1;
+ OSM_LOG(sm->p_log, OSM_LOG_VERBOSE,
+ "Subnet max multicast lid is 0x%X\n",
+ sm->p_subn->max_mcast_lid_ho);
+ }
+
+ /* set subnet max unicast lid to the minimum LinearFDBCap of all switches */
+ if (cl_ntoh16(p_si->lin_cap) < sm->p_subn->max_ucast_lid_ho) {
+ sm->p_subn->max_ucast_lid_ho = cl_ntoh16(p_si->lin_cap);
+ OSM_LOG(sm->p_log, OSM_LOG_VERBOSE,
+ "Subnet max unicast lid is 0x%X\n",
+ sm->p_subn->max_ucast_lid_ho);
+ }
+
+ p_check = (osm_switch_t *) cl_qmap_insert(p_sw_guid_tbl,
+ osm_node_get_node_guid
+ (p_node), &p_sw->map_item);
+ if (p_check != p_sw) {
+ /* This shouldn't happen since we hold the lock! */
+ OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR 3605: "
+ "Unable to add new switch object to database\n");
+ osm_switch_delete(&p_sw);
+ goto Exit;
+ }
+
+ p_node->sw = p_sw;
+
+ /* Update the switch info according to the info we just received. */
+ osm_switch_set_switch_info(p_sw, p_si);
+
+#if 0
+ /* Don't bother retrieving the current unicast and multicast tables
+ from the switches. The current version of SM does
+ not support silent take-over of an existing multicast
+ configuration.
+
+ Gathering the multicast tables can also generate large amounts
+ of extra subnet-init traffic.
+
+ The code to retrieve the tables was fully debugged. */
+
+ si_rcv_get_fwd_tbl(sm, p_sw);
+ if (!sm->p_subn->opt.disable_multicast)
+ si_rcv_get_mcast_fwd_tbl(sm, p_sw);
+#endif
+
+Exit:
+ OSM_LOG_EXIT(sm->p_log);
+}
+
+/**********************************************************************
+ Lock must be held on entry to this function.
+ Return 1 if the caller is expected to send a change_detected event.
+ this can not be done internally as the event needs the lock...
+**********************************************************************/
+static boolean_t si_rcv_process_existing(IN osm_sm_t * sm,
+ IN osm_node_t * p_node,
+ IN const osm_madw_t * p_madw)
+{
+ osm_switch_t *p_sw = p_node->sw;
+ ib_switch_info_t *p_si;
+ osm_si_context_t *p_si_context;
+ ib_smp_t *p_smp;
+ osm_epi_lft_change_event_t lft_change;
+ boolean_t is_change_detected = FALSE;
+
+ OSM_LOG_ENTER(sm->p_log);
+
+ CL_ASSERT(p_madw);
+
+ p_smp = osm_madw_get_smp_ptr(p_madw);
+ p_si = ib_smp_get_payload_ptr(p_smp);
+ p_si_context = osm_madw_get_si_context_ptr(p_madw);
+
+ OSM_LOG(sm->p_log, OSM_LOG_DEBUG, "Received logical %cetResp()\n",
+ p_si_context->set_method ? 'S' : 'G');
+
+ osm_switch_set_switch_info(p_sw, p_si);
+
+ if (p_si_context->light_sweep == TRUE && !p_si_context->set_method) {
+ /* If state changed bit is on the mad was returned with an
+ error - signal a change to the state manager. */
+ if (ib_smp_get_status(p_smp) != 0) {
+ OSM_LOG(sm->p_log, OSM_LOG_VERBOSE,
+ "GetResp() received with error in light sweep. "
+ "Commencing heavy sweep\n");
+ is_change_detected = TRUE;
+ } else if (ib_switch_info_get_state_change(p_si)) {
+ osm_dump_switch_info_v2(sm->p_log, p_si, FILE_ID, OSM_LOG_DEBUG);
+ is_change_detected = TRUE;
+ }
+ }
+
+ if (sm->p_subn->first_time_master_sweep == FALSE &&
+ p_si_context->set_method && p_si_context->lft_top_change) {
+ lft_change.p_sw = p_sw;
+ lft_change.flags = LFT_CHANGED_LFT_TOP;
+ lft_change.lft_top = cl_ntoh16(p_si->lin_top);
+ lft_change.block_num = 0;
+ osm_opensm_report_event(sm->p_subn->p_osm,
+ OSM_EVENT_ID_LFT_CHANGE,
+ &lft_change);
+ }
+
+ OSM_LOG_EXIT(sm->p_log);
+ return is_change_detected;
+}
+
+static void si_rcv_get_sp0_info(IN osm_sm_t * sm, IN osm_node_t * node)
+{
+ osm_madw_context_t context;
+ osm_physp_t *physp;
+ ib_api_status_t status;
+ int mlnx_epi_supported = 0;
+
+ physp = osm_node_get_physp_ptr(node, 0);
+
+ context.pi_context.node_guid = osm_node_get_node_guid(node);
+ context.pi_context.port_guid = osm_physp_get_port_guid(physp);
+ context.pi_context.set_method = FALSE;
+ context.pi_context.light_sweep = FALSE;
+ context.pi_context.active_transition = FALSE;
+ context.pi_context.client_rereg = FALSE;
+
+ status = osm_req_get(sm, osm_physp_get_dr_path_ptr(physp),
+ IB_MAD_ATTR_PORT_INFO, 0, TRUE, 0,
+ CL_DISP_MSGID_NONE, &context);
+ if (status != IB_SUCCESS)
+ OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR 3611: "
+ "Failure initiating PortInfo request (%s)\n",
+ ib_get_err_str(status));
+
+ if (ib_switch_info_is_enhanced_port0(&node->sw->switch_info) &&
+ sm->p_subn->opt.fdr10) {
+ mlnx_epi_supported = is_mlnx_ext_port_info_supported(
+ ib_node_info_get_vendor_id(&node->node_info),
+ node->node_info.device_id);
+ if (mlnx_epi_supported) {
+ status = osm_req_get(sm,
+ osm_physp_get_dr_path_ptr(physp),
+ IB_MAD_ATTR_MLNX_EXTENDED_PORT_INFO,
+ 0, TRUE, 0,
+ CL_DISP_MSGID_NONE, &context);
+ if (status != IB_SUCCESS)
+ OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR 3616: "
+ "Failure initiating MLNX ExtPortInfo request (%s)\n",
+ ib_get_err_str(status));
+ }
+ }
+
+}
+
+void osm_si_rcv_process(IN void *context, IN void *data)
+{
+ osm_sm_t *sm = context;
+ osm_madw_t *p_madw = data;
+ ib_switch_info_t *p_si;
+ ib_smp_t *p_smp;
+ osm_node_t *p_node;
+ ib_net64_t node_guid;
+ osm_si_context_t *p_context;
+
+ CL_ASSERT(sm);
+
+ OSM_LOG_ENTER(sm->p_log);
+
+ CL_ASSERT(p_madw);
+
+ p_smp = osm_madw_get_smp_ptr(p_madw);
+ p_si = ib_smp_get_payload_ptr(p_smp);
+ p_context = osm_madw_get_si_context_ptr(p_madw);
+ node_guid = p_context->node_guid;
+
+ OSM_LOG(sm->p_log, OSM_LOG_DEBUG,
+ "Switch GUID 0x%016" PRIx64 ", TID 0x%" PRIx64 "\n",
+ cl_ntoh64(node_guid), cl_ntoh64(p_smp->trans_id));
+
+ if (ib_smp_get_status(p_smp)) {
+ OSM_LOG(sm->p_log, OSM_LOG_DEBUG,
+ "MAD status 0x%x received\n",
+ cl_ntoh16(ib_smp_get_status(p_smp)));
+ goto Exit2;
+ }
+
+ CL_PLOCK_EXCL_ACQUIRE(sm->p_lock);
+
+ p_node = osm_get_node_by_guid(sm->p_subn, node_guid);
+ if (!p_node) {
+ CL_PLOCK_RELEASE(sm->p_lock);
+ OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR 3606: "
+ "SwitchInfo received for nonexistent node "
+ "with GUID 0x%" PRIx64 "\n", cl_ntoh64(node_guid));
+ goto Exit;
+ }
+
+ /* Hack for bad value in Mellanox switch */
+ if (cl_ntoh16(p_si->lin_top) > IB_LID_UCAST_END_HO) {
+ OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR 3610: "
+ "\n\t\t\t\tBad LinearFDBTop value = 0x%X "
+ "on switch 0x%" PRIx64
+ "\n\t\t\t\tForcing internal correction to 0x%X\n",
+ cl_ntoh16(p_si->lin_top),
+ cl_ntoh64(osm_node_get_node_guid(p_node)), 0);
+ p_si->lin_top = 0;
+ }
+
+ /* Acquire the switch object for this switch. */
+ if (!p_node->sw) {
+ si_rcv_process_new(sm, p_node, p_madw);
+ /* A new switch was found during the sweep so we need
+ to ignore the current LFT settings. */
+ sm->p_subn->ignore_existing_lfts = TRUE;
+ } else if (si_rcv_process_existing(sm, p_node, p_madw))
+ /* we might get back a request for signaling change was detected */
+ sm->p_subn->force_heavy_sweep = TRUE;
+
+ if (p_context->light_sweep || p_context->set_method)
+ goto Exit;
+
+ si_rcv_get_sp0_info(sm, p_node);
+
+Exit:
+ CL_PLOCK_RELEASE(sm->p_lock);
+Exit2:
+ OSM_LOG_EXIT(sm->p_log);
+}
diff --git a/contrib/ofed/opensm/opensm/osm_switch.c b/contrib/ofed/opensm/opensm/osm_switch.c
new file mode 100644
index 0000000..cfcf410
--- /dev/null
+++ b/contrib/ofed/opensm/opensm/osm_switch.c
@@ -0,0 +1,767 @@
+/*
+ * Copyright (c) 2004-2009 Voltaire, Inc. All rights reserved.
+ * Copyright (c) 2002-2015 Mellanox Technologies LTD. All rights reserved.
+ * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
+ * Copyright (c) 2009 HNR Consulting. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+/*
+ * Abstract:
+ * Implementation of osm_switch_t.
+ * This object represents an Infiniband switch.
+ * This object is part of the opensm family of objects.
+ */
+
+#if HAVE_CONFIG_H
+# include <config.h>
+#endif /* HAVE_CONFIG_H */
+
+#include <stdlib.h>
+#include <string.h>
+#include <complib/cl_math.h>
+#include <iba/ib_types.h>
+#include <opensm/osm_file_ids.h>
+#define FILE_ID OSM_FILE_SWITCH_C
+#include <opensm/osm_switch.h>
+
+struct switch_port_path {
+ uint8_t port_num;
+ uint32_t path_count;
+ int found_sys_guid;
+ int found_node_guid;
+ uint32_t forwarded_to;
+};
+
+cl_status_t osm_switch_set_hops(IN osm_switch_t * p_sw, IN uint16_t lid_ho,
+ IN uint8_t port_num, IN uint8_t num_hops)
+{
+ if (!lid_ho || lid_ho > p_sw->max_lid_ho)
+ return -1;
+ if (port_num >= p_sw->num_ports)
+ return -1;
+ if (!p_sw->hops[lid_ho]) {
+ p_sw->hops[lid_ho] = malloc(p_sw->num_ports);
+ if (!p_sw->hops[lid_ho])
+ return -1;
+ memset(p_sw->hops[lid_ho], OSM_NO_PATH, p_sw->num_ports);
+ }
+
+ p_sw->hops[lid_ho][port_num] = num_hops;
+ if (p_sw->hops[lid_ho][0] > num_hops)
+ p_sw->hops[lid_ho][0] = num_hops;
+
+ return 0;
+}
+
+void osm_switch_delete(IN OUT osm_switch_t ** pp_sw)
+{
+ osm_switch_t *p_sw = *pp_sw;
+ unsigned i;
+
+ osm_mcast_tbl_destroy(&p_sw->mcast_tbl);
+ if (p_sw->p_prof)
+ free(p_sw->p_prof);
+ if (p_sw->search_ordering_ports)
+ free(p_sw->search_ordering_ports);
+ if (p_sw->lft)
+ free(p_sw->lft);
+ if (p_sw->new_lft)
+ free(p_sw->new_lft);
+ if (p_sw->hops) {
+ for (i = 0; i < p_sw->num_hops; i++)
+ if (p_sw->hops[i])
+ free(p_sw->hops[i]);
+ free(p_sw->hops);
+ }
+ free(*pp_sw);
+ *pp_sw = NULL;
+}
+
+osm_switch_t *osm_switch_new(IN osm_node_t * p_node,
+ IN const osm_madw_t * p_madw)
+{
+ osm_switch_t *p_sw;
+ ib_switch_info_t *p_si;
+ ib_smp_t *p_smp;
+ uint8_t num_ports;
+ uint32_t port_num;
+
+ CL_ASSERT(p_madw);
+ CL_ASSERT(p_node);
+
+ p_smp = osm_madw_get_smp_ptr(p_madw);
+ p_si = ib_smp_get_payload_ptr(p_smp);
+ num_ports = osm_node_get_num_physp(p_node);
+
+ CL_ASSERT(p_smp->attr_id == IB_MAD_ATTR_SWITCH_INFO);
+
+ if (!p_si->lin_cap) /* The switch doesn't support LFT */
+ return NULL;
+
+ p_sw = malloc(sizeof(*p_sw));
+ if (!p_sw)
+ return NULL;
+
+ memset(p_sw, 0, sizeof(*p_sw));
+
+ p_sw->p_node = p_node;
+ p_sw->switch_info = *p_si;
+ p_sw->num_ports = num_ports;
+ p_sw->need_update = 2;
+
+ p_sw->p_prof = malloc(sizeof(*p_sw->p_prof) * num_ports);
+ if (!p_sw->p_prof)
+ goto err;
+
+ memset(p_sw->p_prof, 0, sizeof(*p_sw->p_prof) * num_ports);
+
+ osm_mcast_tbl_init(&p_sw->mcast_tbl, osm_node_get_num_physp(p_node),
+ cl_ntoh16(p_si->mcast_cap));
+
+ for (port_num = 0; port_num < num_ports; port_num++)
+ osm_port_prof_construct(&p_sw->p_prof[port_num]);
+
+ return p_sw;
+
+err:
+ osm_switch_delete(&p_sw);
+ return NULL;
+}
+
+boolean_t osm_switch_get_lft_block(IN const osm_switch_t * p_sw,
+ IN uint16_t block_id, OUT uint8_t * p_block)
+{
+ uint16_t base_lid_ho = block_id * IB_SMP_DATA_SIZE;
+
+ CL_ASSERT(p_sw);
+ CL_ASSERT(p_block);
+
+ if (base_lid_ho > p_sw->max_lid_ho)
+ return FALSE;
+
+ CL_ASSERT(base_lid_ho + IB_SMP_DATA_SIZE - 1 <= IB_LID_UCAST_END_HO);
+ memcpy(p_block, &(p_sw->new_lft[base_lid_ho]), IB_SMP_DATA_SIZE);
+ return TRUE;
+}
+
+static struct osm_remote_node *
+switch_find_guid_common(IN const osm_switch_t * p_sw,
+ IN struct osm_remote_guids_count *r,
+ IN uint8_t port_num, IN int find_sys_guid,
+ IN int find_node_guid)
+{
+ struct osm_remote_node *p_remote_guid = NULL;
+ osm_physp_t *p_physp;
+ osm_physp_t *p_rem_physp;
+ osm_node_t *p_rem_node;
+ uint64_t sys_guid;
+ uint64_t node_guid;
+ unsigned int i;
+
+ CL_ASSERT(p_sw);
+
+ if (!r)
+ goto out;
+
+ p_physp = osm_node_get_physp_ptr(p_sw->p_node, port_num);
+ if (!p_physp)
+ goto out;
+
+ p_rem_physp = osm_physp_get_remote(p_physp);
+ p_rem_node = osm_physp_get_node_ptr(p_rem_physp);
+ sys_guid = p_rem_node->node_info.sys_guid;
+ node_guid = p_rem_node->node_info.node_guid;
+
+ for (i = 0; i < r->count; i++) {
+ if ((!find_sys_guid
+ || r->guids[i].node->node_info.sys_guid == sys_guid)
+ && (!find_node_guid
+ || r->guids[i].node->node_info.node_guid == node_guid)) {
+ p_remote_guid = &r->guids[i];
+ break;
+ }
+ }
+
+out:
+ return p_remote_guid;
+}
+
+static struct osm_remote_node *
+switch_find_sys_guid_count(IN const osm_switch_t * p_sw,
+ IN struct osm_remote_guids_count *r,
+ IN uint8_t port_num)
+{
+ return switch_find_guid_common(p_sw, r, port_num, 1, 0);
+}
+
+static struct osm_remote_node *
+switch_find_node_guid_count(IN const osm_switch_t * p_sw,
+ IN struct osm_remote_guids_count *r,
+ IN uint8_t port_num)
+{
+ return switch_find_guid_common(p_sw, r, port_num, 0, 1);
+}
+
+uint8_t osm_switch_recommend_path(IN const osm_switch_t * p_sw,
+ IN osm_port_t * p_port, IN uint16_t lid_ho,
+ IN unsigned start_from,
+ IN boolean_t ignore_existing,
+ IN boolean_t routing_for_lmc,
+ IN boolean_t dor,
+ IN boolean_t port_shifting,
+ IN uint32_t scatter_ports,
+ IN osm_lft_type_enum lft_enum)
+{
+ /*
+ We support an enhanced LMC aware routing mode:
+ In the case of LMC > 0, we can track the remote side
+ system and node for all of the lids of the target
+ and try and avoid routing again through the same
+ system / node.
+
+ Assume if routing_for_lmc is true that this procedure was
+ provided the tracking array and counter via p_port->priv,
+ and we can conduct this algorithm.
+ */
+ uint16_t base_lid;
+ uint8_t hops;
+ uint8_t least_hops;
+ uint8_t port_num;
+ uint8_t num_ports;
+ uint32_t least_paths = 0xFFFFFFFF;
+ unsigned i;
+ /*
+ The following will track the least paths if the
+ route should go through a new system/node
+ */
+ uint32_t least_paths_other_sys = 0xFFFFFFFF;
+ uint32_t least_paths_other_nodes = 0xFFFFFFFF;
+ uint32_t least_forwarded_to = 0xFFFFFFFF;
+ uint32_t check_count;
+ uint8_t best_port = 0;
+ /*
+ These vars track the best port if it connects to
+ not used system/node.
+ */
+ uint8_t best_port_other_sys = 0;
+ uint8_t best_port_other_node = 0;
+ boolean_t port_found = FALSE;
+ osm_physp_t *p_physp;
+ osm_physp_t *p_rem_physp;
+ osm_node_t *p_rem_node;
+ osm_node_t *p_rem_node_first = NULL;
+ struct osm_remote_node *p_remote_guid = NULL;
+ struct osm_remote_node null_remote_node = {NULL, 0, 0};
+ struct switch_port_path port_paths[IB_NODE_NUM_PORTS_MAX];
+ unsigned int port_paths_total_paths = 0;
+ unsigned int port_paths_count = 0;
+ uint8_t scatter_possible_ports[IB_NODE_NUM_PORTS_MAX];
+ unsigned int scatter_possible_ports_count = 0;
+ int found_sys_guid = 0;
+ int found_node_guid = 0;
+
+ CL_ASSERT(lid_ho > 0);
+
+ if (p_port->p_node->sw) {
+ if (p_port->p_node->sw == p_sw)
+ return 0;
+ base_lid = osm_port_get_base_lid(p_port);
+ } else {
+ p_physp = p_port->p_physp;
+ if (!p_physp || !p_physp->p_remote_physp ||
+ !p_physp->p_remote_physp->p_node->sw)
+ return OSM_NO_PATH;
+
+ if (p_physp->p_remote_physp->p_node->sw == p_sw)
+ return p_physp->p_remote_physp->port_num;
+ base_lid =
+ osm_node_get_base_lid(p_physp->p_remote_physp->p_node, 0);
+ }
+ base_lid = cl_ntoh16(base_lid);
+
+ num_ports = p_sw->num_ports;
+
+ least_hops = osm_switch_get_least_hops(p_sw, base_lid);
+ if (least_hops == OSM_NO_PATH)
+ return OSM_NO_PATH;
+
+ /*
+ First, inquire with the forwarding table for an existing
+ route. If one is found, honor it unless:
+ 1. the ignore existing flag is set.
+ 2. the physical port is not a valid one or not healthy
+ 3. the physical port has a remote port (the link is up)
+ 4. the port has min-hops to the target (avoid loops)
+ */
+ if (!ignore_existing) {
+ port_num = osm_switch_get_port_by_lid(p_sw, lid_ho, lft_enum);
+
+ if (port_num != OSM_NO_PATH) {
+ CL_ASSERT(port_num < num_ports);
+
+ p_physp =
+ osm_node_get_physp_ptr(p_sw->p_node, port_num);
+ /*
+ Don't be too trusting of the current forwarding table!
+ Verify that the port number is legal and that the
+ LID is reachable through this port.
+ */
+ if (p_physp && osm_physp_is_healthy(p_physp) &&
+ osm_physp_get_remote(p_physp)) {
+ hops =
+ osm_switch_get_hop_count(p_sw, base_lid,
+ port_num);
+ /*
+ If we aren't using pre-defined user routes
+ function, then we need to make sure that the
+ current path is the minimum one. In case of
+ having such a user function - this check will
+ not be done, and the old routing will be used.
+ Note: This means that it is the user's job to
+ clean all data in the forwarding tables that
+ he wants to be overridden by the minimum
+ hop function.
+ */
+ if (hops == least_hops)
+ return port_num;
+ }
+ }
+ }
+
+ /*
+ This algorithm selects a port based on a static load balanced
+ selection across equal hop-count ports.
+ There is lots of room for improved sophistication here,
+ possibly guided by user configuration info.
+ */
+
+ /*
+ OpenSM routing is "local" - not considering a full lid to lid
+ path. As such we can not guarantee a path will not loop if we
+ do not always follow least hops.
+ So we must abort if not least hops.
+ */
+
+ /* port number starts with one and num_ports is 1 + num phys ports */
+ for (i = start_from; i < start_from + num_ports; i++) {
+ port_num = osm_switch_get_dimn_port(p_sw, i % num_ports);
+ if (!port_num ||
+ osm_switch_get_hop_count(p_sw, base_lid, port_num) !=
+ least_hops)
+ continue;
+
+ /* let us make sure it is not down or unhealthy */
+ p_physp = osm_node_get_physp_ptr(p_sw->p_node, port_num);
+ if (!p_physp || !osm_physp_is_healthy(p_physp) ||
+ /*
+ we require all - non sma ports to be linked
+ to be routed through
+ */
+ !osm_physp_get_remote(p_physp))
+ continue;
+
+ /*
+ We located a least-hop port, possibly one of many.
+ For this port, check the running total count of
+ the number of paths through this port. Select
+ the port routing the least number of paths.
+ */
+ check_count =
+ osm_port_prof_path_count_get(&p_sw->p_prof[port_num]);
+
+
+ if (dor) {
+ /* Get the Remote Node */
+ p_rem_physp = osm_physp_get_remote(p_physp);
+ p_rem_node = osm_physp_get_node_ptr(p_rem_physp);
+ /* use the first dimension, but spread traffic
+ * out among the group of ports representing
+ * that dimension */
+ if (!p_rem_node_first)
+ p_rem_node_first = p_rem_node;
+ else if (p_rem_node != p_rem_node_first)
+ continue;
+ if (routing_for_lmc) {
+ struct osm_remote_guids_count *r = p_port->priv;
+ uint8_t rem_port = osm_physp_get_port_num(p_rem_physp);
+ unsigned int j;
+
+ for (j = 0; j < r->count; j++) {
+ p_remote_guid = &r->guids[j];
+ if ((p_remote_guid->node == p_rem_node)
+ && (p_remote_guid->port == rem_port))
+ break;
+ }
+ if (j == r->count)
+ p_remote_guid = &null_remote_node;
+ }
+ /*
+ Advanced LMC routing requires tracking of the
+ best port by the node connected to the other side of
+ it.
+ */
+ } else if (routing_for_lmc) {
+ /* Is the sys guid already used ? */
+ p_remote_guid = switch_find_sys_guid_count(p_sw,
+ p_port->priv,
+ port_num);
+
+ /* If not update the least hops for this case */
+ if (!p_remote_guid) {
+ if (check_count < least_paths_other_sys) {
+ least_paths_other_sys = check_count;
+ best_port_other_sys = port_num;
+ least_forwarded_to = 0;
+ }
+ found_sys_guid = 0;
+ } else { /* same sys found - try node */
+
+
+ /* Else is the node guid already used ? */
+ p_remote_guid = switch_find_node_guid_count(p_sw,
+ p_port->priv,
+ port_num);
+
+ /* If not update the least hops for this case */
+ if (!p_remote_guid
+ && check_count < least_paths_other_nodes) {
+ least_paths_other_nodes = check_count;
+ best_port_other_node = port_num;
+ least_forwarded_to = 0;
+ }
+ /* else prior sys and node guid already used */
+
+ if (!p_remote_guid)
+ found_node_guid = 0;
+ else
+ found_node_guid = 1;
+ found_sys_guid = 1;
+ } /* same sys found */
+ }
+
+ port_paths[port_paths_count].port_num = port_num;
+ port_paths[port_paths_count].path_count = check_count;
+ if (routing_for_lmc) {
+ port_paths[port_paths_count].found_sys_guid = found_sys_guid;
+ port_paths[port_paths_count].found_node_guid = found_node_guid;
+ }
+ if (routing_for_lmc && p_remote_guid)
+ port_paths[port_paths_count].forwarded_to = p_remote_guid->forwarded_to;
+ else
+ port_paths[port_paths_count].forwarded_to = 0;
+ port_paths_total_paths += check_count;
+ port_paths_count++;
+
+ /* routing for LMC mode */
+ /*
+ the count is min but also lower then the max subscribed
+ */
+ if (check_count < least_paths) {
+ port_found = TRUE;
+ best_port = port_num;
+ least_paths = check_count;
+ scatter_possible_ports_count = 0;
+ scatter_possible_ports[scatter_possible_ports_count++] = port_num;
+ if (routing_for_lmc
+ && p_remote_guid
+ && p_remote_guid->forwarded_to < least_forwarded_to)
+ least_forwarded_to = p_remote_guid->forwarded_to;
+ } else if (scatter_ports
+ && check_count == least_paths) {
+ scatter_possible_ports[scatter_possible_ports_count++] = port_num;
+ } else if (routing_for_lmc
+ && p_remote_guid
+ && check_count == least_paths
+ && p_remote_guid->forwarded_to < least_forwarded_to) {
+ least_forwarded_to = p_remote_guid->forwarded_to;
+ best_port = port_num;
+ }
+ }
+
+ if (port_found == FALSE)
+ return OSM_NO_PATH;
+
+ if (port_shifting && port_paths_count) {
+ /* In the port_paths[] array, we now have all the ports that we
+ * can route out of. Using some shifting math below, possibly
+ * select a different one so that lids won't align in LFTs
+ *
+ * If lmc > 0, we need to loop through these ports to find the
+ * least_forwarded_to port, best_port_other_sys, and
+ * best_port_other_node just like before but through the different
+ * ordering.
+ */
+
+ least_paths = 0xFFFFFFFF;
+ least_paths_other_sys = 0xFFFFFFFF;
+ least_paths_other_nodes = 0xFFFFFFFF;
+ least_forwarded_to = 0xFFFFFFFF;
+ best_port = 0;
+ best_port_other_sys = 0;
+ best_port_other_node = 0;
+
+ for (i = 0; i < port_paths_count; i++) {
+ unsigned int idx;
+
+ idx = (port_paths_total_paths/port_paths_count + i) % port_paths_count;
+
+ if (routing_for_lmc) {
+ if (!port_paths[idx].found_sys_guid
+ && port_paths[idx].path_count < least_paths_other_sys) {
+ least_paths_other_sys = port_paths[idx].path_count;
+ best_port_other_sys = port_paths[idx].port_num;
+ least_forwarded_to = 0;
+ }
+ else if (!port_paths[idx].found_node_guid
+ && port_paths[idx].path_count < least_paths_other_nodes) {
+ least_paths_other_nodes = port_paths[idx].path_count;
+ best_port_other_node = port_paths[idx].port_num;
+ least_forwarded_to = 0;
+ }
+ }
+
+ if (port_paths[idx].path_count < least_paths) {
+ best_port = port_paths[idx].port_num;
+ least_paths = port_paths[idx].path_count;
+ if (routing_for_lmc
+ && (port_paths[idx].found_sys_guid
+ || port_paths[idx].found_node_guid)
+ && port_paths[idx].forwarded_to < least_forwarded_to)
+ least_forwarded_to = port_paths[idx].forwarded_to;
+ }
+ else if (routing_for_lmc
+ && (port_paths[idx].found_sys_guid
+ || port_paths[idx].found_node_guid)
+ && port_paths[idx].path_count == least_paths
+ && port_paths[idx].forwarded_to < least_forwarded_to) {
+ least_forwarded_to = port_paths[idx].forwarded_to;
+ best_port = port_paths[idx].port_num;
+ }
+
+ }
+ }
+
+ /*
+ if we are in enhanced routing mode and the best port is not
+ the local port 0
+ */
+ if (routing_for_lmc && best_port && !scatter_ports) {
+ /* Select the least hop port of the non used sys first */
+ if (best_port_other_sys)
+ best_port = best_port_other_sys;
+ else if (best_port_other_node)
+ best_port = best_port_other_node;
+ } else if (scatter_ports) {
+ /*
+ * There is some danger that this random could "rebalance" the routes
+ * every time, to combat this there is a global srandom that
+ * occurs at the start of every sweep.
+ */
+ unsigned int idx = random() % scatter_possible_ports_count;
+ best_port = scatter_possible_ports[idx];
+ }
+ return best_port;
+}
+
+void osm_switch_clear_hops(IN osm_switch_t * p_sw)
+{
+ unsigned i;
+
+ for (i = 0; i < p_sw->num_hops; i++)
+ if (p_sw->hops[i])
+ memset(p_sw->hops[i], OSM_NO_PATH, p_sw->num_ports);
+}
+
+static int alloc_lft(IN osm_switch_t * p_sw, uint16_t lids)
+{
+ uint16_t lft_size;
+
+ /* Ensure LFT is in units of LFT block size */
+ lft_size = (lids / IB_SMP_DATA_SIZE + 1) * IB_SMP_DATA_SIZE;
+ if (lft_size > p_sw->lft_size) {
+ uint8_t *new_lft = realloc(p_sw->lft, lft_size);
+ if (!new_lft)
+ return -1;
+ memset(new_lft + p_sw->lft_size, OSM_NO_PATH,
+ lft_size - p_sw->lft_size);
+ p_sw->lft = new_lft;
+ p_sw->lft_size = lft_size;
+ }
+
+ return 0;
+}
+
+int osm_switch_prepare_path_rebuild(IN osm_switch_t * p_sw, IN uint16_t max_lids)
+{
+ uint8_t **hops;
+ uint8_t *new_lft;
+ unsigned i;
+
+ if (alloc_lft(p_sw, max_lids))
+ return -1;
+
+ for (i = 0; i < p_sw->num_ports; i++)
+ osm_port_prof_construct(&p_sw->p_prof[i]);
+
+ osm_switch_clear_hops(p_sw);
+
+ if (!(new_lft = realloc(p_sw->new_lft, p_sw->lft_size)))
+ return -1;
+
+ p_sw->new_lft = new_lft;
+
+ memset(p_sw->new_lft, OSM_NO_PATH, p_sw->lft_size);
+
+ if (!p_sw->hops) {
+ hops = malloc((max_lids + 1) * sizeof(hops[0]));
+ if (!hops)
+ return -1;
+ memset(hops, 0, (max_lids + 1) * sizeof(hops[0]));
+ p_sw->hops = hops;
+ p_sw->num_hops = max_lids + 1;
+ } else if (max_lids + 1 > p_sw->num_hops) {
+ hops = realloc(p_sw->hops, (max_lids + 1) * sizeof(hops[0]));
+ if (!hops)
+ return -1;
+ memset(hops + p_sw->num_hops, 0,
+ (max_lids + 1 - p_sw->num_hops) * sizeof(hops[0]));
+ p_sw->hops = hops;
+ p_sw->num_hops = max_lids + 1;
+ }
+ p_sw->max_lid_ho = max_lids;
+
+ return 0;
+}
+
+uint8_t osm_switch_get_port_least_hops(IN const osm_switch_t * p_sw,
+ IN const osm_port_t * p_port)
+{
+ uint16_t lid;
+
+ if (p_port->p_node->sw) {
+ if (p_port->p_node->sw == p_sw)
+ return 0;
+ lid = osm_node_get_base_lid(p_port->p_node, 0);
+ return osm_switch_get_least_hops(p_sw, cl_ntoh16(lid));
+ } else {
+ osm_physp_t *p = p_port->p_physp;
+ uint8_t hops;
+
+ if (!p || !p->p_remote_physp || !p->p_remote_physp->p_node->sw)
+ return OSM_NO_PATH;
+ if (p->p_remote_physp->p_node->sw == p_sw)
+ return 1;
+ lid = osm_node_get_base_lid(p->p_remote_physp->p_node, 0);
+ hops = osm_switch_get_least_hops(p_sw, cl_ntoh16(lid));
+ return hops != OSM_NO_PATH ? hops + 1 : OSM_NO_PATH;
+ }
+}
+
+uint8_t osm_switch_recommend_mcast_path(IN osm_switch_t * p_sw,
+ IN osm_port_t * p_port,
+ IN uint16_t mlid_ho,
+ IN boolean_t ignore_existing)
+{
+ uint16_t base_lid;
+ uint8_t hops;
+ uint8_t port_num;
+ uint8_t num_ports;
+ uint8_t least_hops;
+
+ CL_ASSERT(mlid_ho >= IB_LID_MCAST_START_HO);
+
+ if (p_port->p_node->sw) {
+ if (p_port->p_node->sw == p_sw)
+ return 0;
+ base_lid = osm_port_get_base_lid(p_port);
+ } else {
+ osm_physp_t *p_physp = p_port->p_physp;
+ if (!p_physp || !p_physp->p_remote_physp ||
+ !p_physp->p_remote_physp->p_node->sw)
+ return OSM_NO_PATH;
+ if (p_physp->p_remote_physp->p_node->sw == p_sw)
+ return p_physp->p_remote_physp->port_num;
+ base_lid =
+ osm_node_get_base_lid(p_physp->p_remote_physp->p_node, 0);
+ }
+ base_lid = cl_ntoh16(base_lid);
+ num_ports = p_sw->num_ports;
+
+ /*
+ If the user wants us to ignore existing multicast routes,
+ then simply return the shortest hop count path to the
+ target port.
+
+ Otherwise, return the first port that has a path to the target,
+ picking from the ports that are already in the multicast group.
+ */
+ if (!ignore_existing) {
+ for (port_num = 1; port_num < num_ports; port_num++) {
+ if (!osm_mcast_tbl_is_port
+ (&p_sw->mcast_tbl, mlid_ho, port_num))
+ continue;
+ /*
+ Don't be too trusting of the current forwarding table!
+ Verify that the LID is reachable through this port.
+ */
+ hops =
+ osm_switch_get_hop_count(p_sw, base_lid, port_num);
+ if (hops != OSM_NO_PATH)
+ return port_num;
+ }
+ }
+
+ /*
+ Either no existing mcast paths reach this port or we are
+ ignoring existing paths.
+
+ Determine the best multicast path to the target. Note that this
+ algorithm is slightly different from the one used for unicast route
+ recommendation. In this case (multicast), we must NOT
+ perform any sort of load balancing. We MUST take the FIRST
+ port found that has <= the lowest hop count path. This prevents
+ more than one multicast path to the same remote switch which
+ prevents a multicast loop. Multicast loops are bad since the same
+ multicast packet will go around and around, inevitably creating
+ a black hole that will destroy the Earth in a firey conflagration.
+ */
+ least_hops = osm_switch_get_least_hops(p_sw, base_lid);
+ if (least_hops == OSM_NO_PATH)
+ return OSM_NO_PATH;
+ for (port_num = 1; port_num < num_ports; port_num++)
+ if (osm_switch_get_hop_count(p_sw, base_lid, port_num) ==
+ least_hops)
+ break;
+
+ CL_ASSERT(port_num < num_ports);
+ return port_num;
+}
diff --git a/contrib/ofed/opensm/opensm/osm_torus.c b/contrib/ofed/opensm/opensm/osm_torus.c
new file mode 100644
index 0000000..ff8e37b
--- /dev/null
+++ b/contrib/ofed/opensm/opensm/osm_torus.c
@@ -0,0 +1,9565 @@
+/*
+ * Copyright 2009 Sandia Corporation. Under the terms of Contract
+ * DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
+ * certain rights in this software.
+ * Copyright (c) 2009-2011 ZIH, TU Dresden, Federal Republic of Germany. All rights reserved.
+ * Copyright (c) 2010-2012 Mellanox Technologies LTD. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+#define _WITH_GETLINE /* for getline() */
+#include <stdint.h>
+#include <stdbool.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <unistd.h>
+#include <errno.h>
+#include <string.h>
+
+#if HAVE_CONFIG_H
+# include <config.h>
+#endif /* HAVE_CONFIG_H */
+
+#include <opensm/osm_file_ids.h>
+#define FILE_ID OSM_FILE_TORUS_C
+#include <opensm/osm_log.h>
+#include <opensm/osm_port.h>
+#include <opensm/osm_switch.h>
+#include <opensm/osm_node.h>
+#include <opensm/osm_opensm.h>
+
+#define TORUS_MAX_DIM 3
+#define PORTGRP_MAX_PORTS 16
+#define SWITCH_MAX_PORTGRPS (1 + 2 * TORUS_MAX_DIM)
+#define DEFAULT_MAX_CHANGES 32
+
+#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
+
+typedef ib_net64_t guid_t;
+
+/*
+ * An endpoint terminates a link, and is one of three types:
+ * UNKNOWN - Uninitialized endpoint.
+ * SRCSINK - generates or consumes traffic, and thus has an associated LID;
+ * i.e. a CA or router port.
+ * PASSTHRU - Has no associated LID; i.e. a switch port.
+ *
+ * If it is possible to communicate in-band with a switch, it will require
+ * a port with a GUID in the switch to source/sink that traffic, but there
+ * will be no attached link. This code assumes there is only one such port.
+ *
+ * Here is an endpoint taxonomy:
+ *
+ * type == SRCSINK
+ * link == pointer to a valid struct link
+ * ==> This endpoint is a CA or router port connected via a link to
+ * either a switch or another CA/router. Thus:
+ * n_id ==> identifies the CA/router node GUID
+ * sw ==> NULL
+ * port ==> identifies the port on the CA/router this endpoint uses
+ * pgrp ==> NULL
+ *
+ * type == SRCSINK
+ * link == NULL pointer
+ * ==> This endpoint is the switch port used for in-band communication
+ * with the switch itself. Thus:
+ * n_id ==> identifies the node GUID used to talk to the switch
+ * containing this endpoint
+ * sw ==> pointer to valid struct switch containing this endpoint
+ * port ==> identifies the port on the switch this endpoint uses
+ * pgrp ==> NULL, or pointer to the valid struct port_grp holding
+ * the port in a t_switch.
+ *
+ * type == PASSTHRU
+ * link == pointer to valid struct link
+ * ==> This endpoint is a switch port connected via a link to either
+ * another switch or a CA/router. Thus:
+ * n_id ==> identifies the node GUID used to talk to the switch
+ * containing this endpoint - since each switch is assumed
+ * to have only one in-band communication port, this is a
+ * convenient unique name for the switch itself.
+ * sw ==> pointer to valid struct switch containing this endpoint,
+ * or NULL, in the case of a fabric link that has been
+ * disconnected after being transferred to a torus link.
+ * port ==> identifies the port on the switch this endpoint uses.
+ * Note that in the special case of the coordinate direction
+ * links, the port value is -1, as those links aren't
+ * really connected to anything.
+ * pgrp ==> NULL, or pointer to the valid struct port_grp holding
+ * the port in a t_switch.
+ */
+enum endpt_type { UNKNOWN = 0, SRCSINK, PASSTHRU };
+struct torus;
+struct t_switch;
+struct port_grp;
+
+struct endpoint {
+ enum endpt_type type;
+ int port;
+ guid_t n_id; /* IBA node GUID */
+ void *sw; /* void* can point to either switch type */
+ struct link *link;
+ struct port_grp *pgrp;
+ void *tmp;
+ /*
+ * Note: osm_port is only guaranteed to contain a valid pointer
+ * when the call stack contains torus_build_lfts() or
+ * osm_port_relink_endpoint().
+ *
+ * Otherwise, the opensm core could have deleted an osm_port object
+ * without notifying us, invalidating the pointer we hold.
+ *
+ * When presented with a pointer to an osm_port_t, it is generally
+ * safe and required to cast osm_port_t:priv to struct endpoint, and
+ * check that the endpoint's osm_port is the same as the original
+ * osm_port_t pointer. Failure to do so means that invalidated
+ * pointers will go undetected.
+ */
+ struct osm_port *osm_port;
+};
+
+struct link {
+ struct endpoint end[2];
+};
+
+/*
+ * A port group is a collection of endpoints on a switch that share certain
+ * characteristics. All the endpoints in a port group must have the same
+ * type. Furthermore, if that type is PASSTHRU, then the connected links:
+ * 1) are parallel to a given coordinate direction
+ * 2) share the same two switches as endpoints.
+ *
+ * Torus-2QoS uses one master spanning tree for multicast, of which every
+ * multicast group spanning tree is a subtree. to_stree_root is a pointer
+ * to the next port_grp on the path to the master spanning tree root.
+ * to_stree_tip is a pointer to the next port_grp on the path to a master
+ * spanning tree branch tip.
+ *
+ * Each t_switch can have at most one port_grp with a non-NULL to_stree_root.
+ * Exactly one t_switch in the fabric will have all port_grp objects with
+ * to_stree_root NULL; it is the master spanning tree root.
+ *
+ * A t_switch with all port_grp objects where to_stree_tip is NULL is at a
+ * master spanning tree branch tip.
+ */
+struct port_grp {
+ enum endpt_type type;
+ size_t port_cnt; /* number of attached ports in group */
+ size_t port_grp; /* what switch port_grp we're in */
+ unsigned sw_dlid_cnt; /* switch dlids routed through this group */
+ unsigned ca_dlid_cnt; /* CA dlids routed through this group */
+ struct t_switch *sw; /* what switch we're attached to */
+ struct port_grp *to_stree_root;
+ struct port_grp *to_stree_tip;
+ struct endpoint **port;
+};
+
+/*
+ * A struct t_switch is used to represent a switch as placed in a torus.
+ *
+ * A t_switch used to build an N-dimensional torus will have 2N+1 port groups,
+ * used as follows, assuming 0 <= d < N:
+ * port_grp[2d] => links leaving in negative direction for coordinate d
+ * port_grp[2d+1] => links leaving in positive direction for coordinate d
+ * port_grp[2N] => endpoints local to switch; i.e., hosts on switch
+ *
+ * struct link objects referenced by a t_switch are assumed to be oriented:
+ * traversing a link from link.end[0] to link.end[1] is always in the positive
+ * coordinate direction.
+ */
+struct t_switch {
+ guid_t n_id; /* IBA node GUID */
+ int i, j, k;
+ unsigned port_cnt; /* including management port */
+ struct torus *torus;
+ void *tmp;
+ /*
+ * Note: osm_switch is only guaranteed to contain a valid pointer
+ * when the call stack contains torus_build_lfts().
+ *
+ * Otherwise, the opensm core could have deleted an osm_switch object
+ * without notifying us, invalidating the pointer we hold.
+ *
+ * When presented with a pointer to an osm_switch_t, it is generally
+ * safe and required to cast osm_switch_t:priv to struct t_switch, and
+ * check that the switch's osm_switch is the same as the original
+ * osm_switch_t pointer. Failure to do so means that invalidated
+ * pointers will go undetected.
+ */
+ struct osm_switch *osm_switch;
+
+ struct port_grp ptgrp[SWITCH_MAX_PORTGRPS];
+ struct endpoint **port;
+};
+
+/*
+ * We'd like to be able to discover the torus topology in a pile of switch
+ * links if we can. We'll use a struct f_switch to store raw topology for a
+ * fabric description, then contruct the torus topology from struct t_switch
+ * objects as we process the fabric and recover it.
+ */
+struct f_switch {
+ guid_t n_id; /* IBA node GUID */
+ unsigned port_cnt; /* including management port */
+ void *tmp;
+ /*
+ * Same rules apply here as for a struct t_switch member osm_switch.
+ */
+ struct osm_switch *osm_switch;
+ struct endpoint **port;
+};
+
+struct fabric {
+ osm_opensm_t *osm;
+ unsigned ca_cnt;
+ unsigned link_cnt;
+ unsigned switch_cnt;
+
+ unsigned link_cnt_max;
+ unsigned switch_cnt_max;
+
+ struct link **link;
+ struct f_switch **sw;
+};
+
+struct coord_dirs {
+ /*
+ * These links define the coordinate directions for the torus.
+ * They are duplicates of links connected to switches. Each of
+ * these links must connect to a common switch.
+ *
+ * In the event that a failed switch was specified as one of these
+ * link endpoints, our algorithm would not be able to find the
+ * torus in the fabric. So, we'll allow multiple instances of
+ * this in the config file to allow improved resiliency.
+ */
+ struct link xm_link, ym_link, zm_link;
+ struct link xp_link, yp_link, zp_link;
+ /*
+ * A torus dimension has coordinate values 0, 1, ..., radix - 1.
+ * The dateline, where we need to change VLs to avoid credit loops,
+ * for a torus dimension is always between coordinate values
+ * radix - 1 and 0. The following specify the dateline location
+ * relative to the coordinate links shared switch location.
+ *
+ * E.g. if the shared switch is at 0,0,0, the following are all
+ * zero; if the shared switch is at 1,1,1, the following are all
+ * -1, etc.
+ *
+ * Since our SL/VL assignment for a path depends on the position
+ * of the path endpoints relative to the torus datelines, we need
+ * this information to keep SL/VL assignment constant in the event
+ * one of the switches used to specify coordinate directions fails.
+ */
+ int x_dateline, y_dateline, z_dateline;
+};
+
+struct torus {
+ osm_opensm_t *osm;
+ unsigned ca_cnt;
+ unsigned link_cnt;
+ unsigned switch_cnt;
+ unsigned seed_cnt, seed_idx;
+ unsigned x_sz, y_sz, z_sz;
+
+ unsigned port_order[IB_NODE_NUM_PORTS_MAX+1];
+
+ unsigned sw_pool_sz;
+ unsigned link_pool_sz;
+ unsigned seed_sz;
+ unsigned portgrp_sz; /* max ports for port groups in this torus */
+
+ struct fabric *fabric;
+ struct t_switch **sw_pool;
+ struct link *link_pool;
+
+ struct coord_dirs *seed;
+ struct t_switch ****sw;
+ struct t_switch *master_stree_root;
+
+ unsigned flags;
+ unsigned max_changes;
+ int debug;
+};
+
+/*
+ * Bits to use in torus.flags
+ */
+#define X_MESH (1U << 0)
+#define Y_MESH (1U << 1)
+#define Z_MESH (1U << 2)
+#define MSG_DEADLOCK (1U << 29)
+#define NOTIFY_CHANGES (1U << 30)
+
+#define ALL_MESH(flags) \
+ ((flags & (X_MESH | Y_MESH | Z_MESH)) == (X_MESH | Y_MESH | Z_MESH))
+
+
+struct torus_context {
+ osm_opensm_t *osm;
+ struct torus *torus;
+ struct fabric fabric;
+};
+
+static
+void teardown_fabric(struct fabric *f)
+{
+ unsigned l, p, s;
+ struct endpoint *port;
+ struct f_switch *sw;
+
+ if (!f)
+ return;
+
+ if (f->sw) {
+ /*
+ * Need to free switches, and also find/free the endpoints
+ * we allocated for switch management ports.
+ */
+ for (s = 0; s < f->switch_cnt; s++) {
+ sw = f->sw[s];
+ if (!sw)
+ continue;
+
+ for (p = 0; p < sw->port_cnt; p++) {
+ port = sw->port[p];
+ if (port && !port->link)
+ free(port); /* management port */
+ }
+ free(sw);
+ }
+ free(f->sw);
+ }
+ if (f->link) {
+ for (l = 0; l < f->link_cnt; l++)
+ if (f->link[l])
+ free(f->link[l]);
+
+ free(f->link);
+ }
+ memset(f, 0, sizeof(*f));
+}
+
+void teardown_torus(struct torus *t)
+{
+ unsigned p, s;
+ struct endpoint *port;
+ struct t_switch *sw;
+
+ if (!t)
+ return;
+
+ if (t->sw_pool) {
+ /*
+ * Need to free switches, and also find/free the endpoints
+ * we allocated for switch management ports.
+ */
+ for (s = 0; s < t->switch_cnt; s++) {
+ sw = t->sw_pool[s];
+ if (!sw)
+ continue;
+
+ for (p = 0; p < sw->port_cnt; p++) {
+ port = sw->port[p];
+ if (port && !port->link)
+ free(port); /* management port */
+ }
+ free(sw);
+ }
+ free(t->sw_pool);
+ }
+ if (t->link_pool)
+ free(t->link_pool);
+
+ if (t->sw)
+ free(t->sw);
+
+ if (t->seed)
+ free(t->seed);
+
+ free(t);
+}
+
+static
+struct torus_context *torus_context_create(osm_opensm_t *osm)
+{
+ struct torus_context *ctx;
+
+ ctx = calloc(1, sizeof(*ctx));
+ if (ctx)
+ ctx->osm = osm;
+ else
+ OSM_LOG(&osm->log, OSM_LOG_ERROR,
+ "ERR 4E01: calloc: %s\n", strerror(errno));
+
+ return ctx;
+}
+
+static
+void torus_context_delete(void *context)
+{
+ struct torus_context *ctx = context;
+
+ teardown_fabric(&ctx->fabric);
+ if (ctx->torus)
+ teardown_torus(ctx->torus);
+ free(ctx);
+}
+
+static
+bool grow_seed_array(struct torus *t, int new_seeds)
+{
+ unsigned cnt;
+ void *ptr;
+
+ cnt = t->seed_cnt + new_seeds;
+ if (cnt > t->seed_sz) {
+ cnt += 2 + cnt / 2;
+ ptr = realloc(t->seed, cnt * sizeof(*t->seed));
+ if (!ptr)
+ return false;
+ t->seed = ptr;
+ t->seed_sz = cnt;
+ memset(&t->seed[t->seed_cnt], 0,
+ (cnt - t->seed_cnt) * sizeof(*t->seed));
+ }
+ return true;
+}
+
+static
+struct f_switch *find_f_sw(struct fabric *f, guid_t sw_guid)
+{
+ unsigned s;
+ struct f_switch *sw;
+
+ if (f->sw) {
+ for (s = 0; s < f->switch_cnt; s++) {
+ sw = f->sw[s];
+ if (sw->n_id == sw_guid)
+ return sw;
+ }
+ }
+ return NULL;
+}
+
+static
+struct link *find_f_link(struct fabric *f,
+ guid_t guid0, int port0, guid_t guid1, int port1)
+{
+ unsigned l;
+ struct link *link;
+
+ if (f->link) {
+ for (l = 0; l < f->link_cnt; l++) {
+ link = f->link[l];
+ if ((link->end[0].n_id == guid0 &&
+ link->end[0].port == port0 &&
+ link->end[1].n_id == guid1 &&
+ link->end[1].port == port1) ||
+ (link->end[0].n_id == guid1 &&
+ link->end[0].port == port1 &&
+ link->end[1].n_id == guid0 &&
+ link->end[1].port == port0))
+ return link;
+ }
+ }
+ return NULL;
+}
+
+static
+struct f_switch *alloc_fswitch(struct fabric *f,
+ guid_t sw_id, unsigned port_cnt)
+{
+ size_t new_sw_sz;
+ unsigned cnt_max;
+ struct f_switch *sw = NULL;
+ void *ptr;
+
+ if (f->switch_cnt >= f->switch_cnt_max) {
+
+ cnt_max = 16 + 5 * f->switch_cnt_max / 4;
+ ptr = realloc(f->sw, cnt_max * sizeof(*f->sw));
+ if (!ptr) {
+ OSM_LOG(&f->osm->log, OSM_LOG_ERROR,
+ "ERR 4E02: realloc: %s\n", strerror(errno));
+ goto out;
+ }
+ f->sw = ptr;
+ f->switch_cnt_max = cnt_max;
+ memset(&f->sw[f->switch_cnt], 0,
+ (f->switch_cnt_max - f->switch_cnt)*sizeof(*f->sw));
+ }
+ new_sw_sz = sizeof(*sw) + port_cnt * sizeof(*sw->port);
+ sw = calloc(1, new_sw_sz);
+ if (!sw) {
+ OSM_LOG(&f->osm->log, OSM_LOG_ERROR,
+ "ERR 4E03: calloc: %s\n", strerror(errno));
+ goto out;
+ }
+ sw->port = (void *)(sw + 1);
+ sw->n_id = sw_id;
+ sw->port_cnt = port_cnt;
+ f->sw[f->switch_cnt++] = sw;
+out:
+ return sw;
+}
+
+static
+struct link *alloc_flink(struct fabric *f)
+{
+ unsigned cnt_max;
+ struct link *l = NULL;
+ void *ptr;
+
+ if (f->link_cnt >= f->link_cnt_max) {
+
+ cnt_max = 16 + 5 * f->link_cnt_max / 4;
+ ptr = realloc(f->link, cnt_max * sizeof(*f->link));
+ if (!ptr) {
+ OSM_LOG(&f->osm->log, OSM_LOG_ERROR,
+ "ERR 4E04: realloc: %s\n", strerror(errno));
+ goto out;
+ }
+ f->link = ptr;
+ f->link_cnt_max = cnt_max;
+ memset(&f->link[f->link_cnt], 0,
+ (f->link_cnt_max - f->link_cnt) * sizeof(*f->link));
+ }
+ l = calloc(1, sizeof(*l));
+ if (!l) {
+ OSM_LOG(&f->osm->log, OSM_LOG_ERROR,
+ "ERR 4E05: calloc: %s\n", strerror(errno));
+ goto out;
+ }
+ f->link[f->link_cnt++] = l;
+out:
+ return l;
+}
+
+/*
+ * Caller must ensure osm_port points to a valid port which contains
+ * a valid osm_physp_t pointer for port 0, the switch management port.
+ */
+static
+bool build_sw_endpoint(struct fabric *f, osm_port_t *osm_port)
+{
+ int sw_port;
+ guid_t sw_guid;
+ struct osm_switch *osm_sw;
+ struct f_switch *sw;
+ struct endpoint *ep;
+ bool success = false;
+
+ sw_port = osm_physp_get_port_num(osm_port->p_physp);
+ sw_guid = osm_node_get_node_guid(osm_port->p_node);
+ osm_sw = osm_port->p_node->sw;
+
+ /*
+ * The switch must already exist.
+ */
+ sw = find_f_sw(f, sw_guid);
+ if (!sw) {
+ OSM_LOG(&f->osm->log, OSM_LOG_ERROR,
+ "ERR 4E06: missing switch w/GUID 0x%04"PRIx64"\n",
+ cl_ntoh64(sw_guid));
+ goto out;
+ }
+ /*
+ * The endpoint may already exist.
+ */
+ if (sw->port[sw_port]) {
+ if (sw->port[sw_port]->n_id == sw_guid) {
+ ep = sw->port[sw_port];
+ goto success;
+ } else
+ OSM_LOG(&f->osm->log, OSM_LOG_ERROR,
+ "ERR 4E07: switch port %d has id "
+ "0x%04"PRIx64", expected 0x%04"PRIx64"\n",
+ sw_port, cl_ntoh64(sw->port[sw_port]->n_id),
+ cl_ntoh64(sw_guid));
+ goto out;
+ }
+ ep = calloc(1, sizeof(*ep));
+ if (!ep) {
+ OSM_LOG(&f->osm->log, OSM_LOG_ERROR,
+ "ERR 4E08: allocating endpoint: %s\n", strerror(errno));
+ goto out;
+ }
+ ep->type = SRCSINK;
+ ep->port = sw_port;
+ ep->n_id = sw_guid;
+ ep->link = NULL;
+ ep->sw = sw;
+
+ sw->port[sw_port] = ep;
+
+success:
+ /*
+ * Fabric objects are temporary, so don't set osm_sw/osm_port priv
+ * pointers using them. Wait until torus objects get constructed.
+ */
+ sw->osm_switch = osm_sw;
+ ep->osm_port = osm_port;
+
+ success = true;
+out:
+ return success;
+}
+
+static
+bool build_ca_link(struct fabric *f,
+ osm_port_t *osm_port_ca, guid_t sw_guid, int sw_port)
+{
+ int ca_port;
+ guid_t ca_guid;
+ struct link *l;
+ struct f_switch *sw;
+ bool success = false;
+
+ ca_port = osm_physp_get_port_num(osm_port_ca->p_physp);
+ ca_guid = osm_node_get_node_guid(osm_port_ca->p_node);
+
+ /*
+ * The link may already exist.
+ */
+ l = find_f_link(f, sw_guid, sw_port, ca_guid, ca_port);
+ if (l) {
+ success = true;
+ goto out;
+ }
+ /*
+ * The switch must already exist.
+ */
+ sw = find_f_sw(f, sw_guid);
+ if (!sw) {
+ OSM_LOG(&f->osm->log, OSM_LOG_ERROR,
+ "ERR 4E09: missing switch w/GUID 0x%04"PRIx64"\n",
+ cl_ntoh64(sw_guid));
+ goto out;
+ }
+ l = alloc_flink(f);
+ if (!l)
+ goto out;
+
+ l->end[0].type = PASSTHRU;
+ l->end[0].port = sw_port;
+ l->end[0].n_id = sw_guid;
+ l->end[0].sw = sw;
+ l->end[0].link = l;
+
+ sw->port[sw_port] = &l->end[0];
+
+ l->end[1].type = SRCSINK;
+ l->end[1].port = ca_port;
+ l->end[1].n_id = ca_guid;
+ l->end[1].sw = NULL; /* Correct for a CA */
+ l->end[1].link = l;
+
+ /*
+ * Fabric objects are temporary, so don't set osm_sw/osm_port priv
+ * pointers using them. Wait until torus objects get constructed.
+ */
+ l->end[1].osm_port = osm_port_ca;
+
+ ++f->ca_cnt;
+ success = true;
+out:
+ return success;
+}
+
+static
+bool build_link(struct fabric *f,
+ guid_t sw_guid0, int sw_port0, guid_t sw_guid1, int sw_port1)
+{
+ struct link *l;
+ struct f_switch *sw0, *sw1;
+ bool success = false;
+
+ /*
+ * The link may already exist.
+ */
+ l = find_f_link(f, sw_guid0, sw_port0, sw_guid1, sw_port1);
+ if (l) {
+ success = true;
+ goto out;
+ }
+ /*
+ * The switches must already exist.
+ */
+ sw0 = find_f_sw(f, sw_guid0);
+ if (!sw0) {
+ OSM_LOG(&f->osm->log, OSM_LOG_ERROR,
+ "ERR 4E0A: missing switch w/GUID 0x%04"PRIx64"\n",
+ cl_ntoh64(sw_guid0));
+ goto out;
+ }
+ sw1 = find_f_sw(f, sw_guid1);
+ if (!sw1) {
+ OSM_LOG(&f->osm->log, OSM_LOG_ERROR,
+ "ERR 4E0B: missing switch w/GUID 0x%04"PRIx64"\n",
+ cl_ntoh64(sw_guid1));
+ goto out;
+ }
+ l = alloc_flink(f);
+ if (!l)
+ goto out;
+
+ l->end[0].type = PASSTHRU;
+ l->end[0].port = sw_port0;
+ l->end[0].n_id = sw_guid0;
+ l->end[0].sw = sw0;
+ l->end[0].link = l;
+
+ sw0->port[sw_port0] = &l->end[0];
+
+ l->end[1].type = PASSTHRU;
+ l->end[1].port = sw_port1;
+ l->end[1].n_id = sw_guid1;
+ l->end[1].sw = sw1;
+ l->end[1].link = l;
+
+ sw1->port[sw_port1] = &l->end[1];
+
+ success = true;
+out:
+ return success;
+}
+
+static
+bool parse_size(unsigned *tsz, unsigned *tflags, unsigned mask,
+ const char *parse_sep)
+{
+ char *val, *nextchar;
+
+ val = strtok(NULL, parse_sep);
+ if (!val)
+ return false;
+ *tsz = strtoul(val, &nextchar, 0);
+ if (*tsz) {
+ if (*nextchar == 't' || *nextchar == 'T')
+ *tflags &= ~mask;
+ else if (*nextchar == 'm' || *nextchar == 'M')
+ *tflags |= mask;
+ /*
+ * A torus of radix two is also a mesh of radix two
+ * with multiple links between switches in that direction.
+ *
+ * Make it so always, otherwise the failure case routing
+ * logic gets confused.
+ */
+ if (*tsz == 2)
+ *tflags |= mask;
+ }
+ return true;
+}
+
+static
+bool parse_torus(struct torus *t, const char *parse_sep)
+{
+ unsigned i, j, k, cnt;
+ char *ptr;
+ bool success = false;
+
+ /*
+ * There can be only one. Ignore the imposters.
+ */
+ if (t->sw_pool)
+ goto out;
+
+ if (!parse_size(&t->x_sz, &t->flags, X_MESH, parse_sep))
+ goto out;
+
+ if (!parse_size(&t->y_sz, &t->flags, Y_MESH, parse_sep))
+ goto out;
+
+ if (!parse_size(&t->z_sz, &t->flags, Z_MESH, parse_sep))
+ goto out;
+
+ /*
+ * Set up a linear array of switch pointers big enough to hold
+ * all expected switches.
+ */
+ t->sw_pool_sz = t->x_sz * t->y_sz * t->z_sz;
+ t->sw_pool = calloc(t->sw_pool_sz, sizeof(*t->sw_pool));
+ if (!t->sw_pool) {
+ OSM_LOG(&t->osm->log, OSM_LOG_ERROR,
+ "ERR 4E0C: Torus switch array calloc: %s\n",
+ strerror(errno));
+ goto out;
+ }
+ /*
+ * Set things up so that t->sw[i][j][k] can point to the i,j,k switch.
+ */
+ cnt = t->x_sz * (1 + t->y_sz * (1 + t->z_sz));
+ t->sw = malloc(cnt * sizeof(void *));
+ if (!t->sw) {
+ OSM_LOG(&t->osm->log, OSM_LOG_ERROR,
+ "ERR 4E0D: Torus switch array malloc: %s\n",
+ strerror(errno));
+ goto out;
+ }
+ ptr = (void *)(t->sw);
+
+ ptr += t->x_sz * sizeof(void *);
+ for (i = 0; i < t->x_sz; i++) {
+ t->sw[i] = (void *)ptr;
+ ptr += t->y_sz * sizeof(void *);
+ }
+ for (i = 0; i < t->x_sz; i++)
+ for (j = 0; j < t->y_sz; j++) {
+ t->sw[i][j] = (void *)ptr;
+ ptr += t->z_sz * sizeof(void *);
+ }
+
+ for (i = 0; i < t->x_sz; i++)
+ for (j = 0; j < t->y_sz; j++)
+ for (k = 0; k < t->z_sz; k++)
+ t->sw[i][j][k] = NULL;
+
+ success = true;
+out:
+ return success;
+}
+
+static
+bool parse_unsigned(unsigned *result, const char *parse_sep)
+{
+ char *val, *nextchar;
+
+ val = strtok(NULL, parse_sep);
+ if (!val)
+ return false;
+ *result = strtoul(val, &nextchar, 0);
+ return true;
+}
+
+static
+bool parse_port_order(struct torus *t, const char *parse_sep)
+{
+ unsigned i, j, k, n;
+
+ for (i = 0; i < ARRAY_SIZE(t->port_order); i++) {
+ if (!parse_unsigned(&(t->port_order[i]), parse_sep))
+ break;
+
+ for (j = 0; j < i; j++) {
+ if (t->port_order[j] == t->port_order[i]) {
+ OSM_LOG(&t->osm->log, OSM_LOG_INFO,
+ "Ignored duplicate port %u in"
+ " port_order parsing\n",
+ t->port_order[j]);
+ i--; /* Ignore duplicate port number */
+ break;
+ }
+ }
+ }
+
+ n = i;
+ for (j = 0; j < ARRAY_SIZE(t->port_order); j++) {
+ for (k = 0; k < i; k++)
+ if (t->port_order[k] == j)
+ break;
+ if (k >= i)
+ t->port_order[n++] = j;
+ }
+
+ return true;
+}
+
+static
+bool parse_guid(struct torus *t, guid_t *guid, const char *parse_sep)
+{
+ char *val;
+ bool success = false;
+
+ val = strtok(NULL, parse_sep);
+ if (!val)
+ goto out;
+ *guid = strtoull(val, NULL, 0);
+ *guid = cl_hton64(*guid);
+
+ success = true;
+out:
+ return success;
+}
+
+static
+bool parse_dir_link(int c_dir, struct torus *t, const char *parse_sep)
+{
+ guid_t sw_guid0, sw_guid1;
+ struct link *l;
+ bool success = false;
+
+ if (!parse_guid(t, &sw_guid0, parse_sep))
+ goto out;
+
+ if (!parse_guid(t, &sw_guid1, parse_sep))
+ goto out;
+
+ if (!t) {
+ success = true;
+ goto out;
+ }
+
+ switch (c_dir) {
+ case -1:
+ l = &t->seed[t->seed_cnt - 1].xm_link;
+ break;
+ case 1:
+ l = &t->seed[t->seed_cnt - 1].xp_link;
+ break;
+ case -2:
+ l = &t->seed[t->seed_cnt - 1].ym_link;
+ break;
+ case 2:
+ l = &t->seed[t->seed_cnt - 1].yp_link;
+ break;
+ case -3:
+ l = &t->seed[t->seed_cnt - 1].zm_link;
+ break;
+ case 3:
+ l = &t->seed[t->seed_cnt - 1].zp_link;
+ break;
+ default:
+ OSM_LOG(&t->osm->log, OSM_LOG_ERROR,
+ "ERR 4E0E: unknown link direction %d\n", c_dir);
+ goto out;
+ }
+ l->end[0].type = PASSTHRU;
+ l->end[0].port = -1; /* We don't really connect. */
+ l->end[0].n_id = sw_guid0;
+ l->end[0].sw = NULL; /* Fix this up later. */
+ l->end[0].link = NULL; /* Fix this up later. */
+
+ l->end[1].type = PASSTHRU;
+ l->end[1].port = -1; /* We don't really connect. */
+ l->end[1].n_id = sw_guid1;
+ l->end[1].sw = NULL; /* Fix this up later. */
+ l->end[1].link = NULL; /* Fix this up later. */
+
+ success = true;
+out:
+ return success;
+}
+
+static
+bool parse_dir_dateline(int c_dir, struct torus *t, const char *parse_sep)
+{
+ char *val;
+ int *dl, max_dl;
+ bool success = false;
+
+ val = strtok(NULL, parse_sep);
+ if (!val)
+ goto out;
+
+ if (!t) {
+ success = true;
+ goto out;
+ }
+
+ switch (c_dir) {
+ case 1:
+ dl = &t->seed[t->seed_cnt - 1].x_dateline;
+ max_dl = t->x_sz;
+ break;
+ case 2:
+ dl = &t->seed[t->seed_cnt - 1].y_dateline;
+ max_dl = t->y_sz;
+ break;
+ case 3:
+ dl = &t->seed[t->seed_cnt - 1].z_dateline;
+ max_dl = t->z_sz;
+ break;
+ default:
+ OSM_LOG(&t->osm->log, OSM_LOG_ERROR,
+ "ERR 4E0F: unknown dateline direction %d\n", c_dir);
+ goto out;
+ }
+ *dl = strtol(val, NULL, 0);
+
+ if ((*dl < 0 && *dl <= -max_dl) || *dl >= max_dl)
+ OSM_LOG(&t->osm->log, OSM_LOG_ERROR,
+ "ERR 4E10: dateline value for coordinate direction %d "
+ "must be %d < dl < %d\n",
+ c_dir, -max_dl, max_dl);
+ else
+ success = true;
+out:
+ return success;
+}
+
+static
+bool parse_config(const char *fn, struct fabric *f, struct torus *t)
+{
+ FILE *fp;
+ unsigned i;
+ char *keyword;
+ char *line_buf = NULL;
+ const char *parse_sep = " \n\t\015";
+ size_t line_buf_sz = 0;
+ size_t line_cntr = 0;
+ ssize_t llen;
+ bool kw_success, success = true;
+
+ if (!grow_seed_array(t, 2))
+ return false;
+
+ for (i = 0; i < ARRAY_SIZE(t->port_order); i++)
+ t->port_order[i] = i;
+
+ fp = fopen(fn, "r");
+ if (!fp) {
+ OSM_LOG(&t->osm->log, OSM_LOG_ERROR,
+ "ERR 4E11: Opening %s: %s\n", fn, strerror(errno));
+ return false;
+ }
+ t->flags |= NOTIFY_CHANGES;
+ t->portgrp_sz = PORTGRP_MAX_PORTS;
+ t->max_changes = DEFAULT_MAX_CHANGES;
+
+next_line:
+ llen = getline(&line_buf, &line_buf_sz, fp);
+ if (llen < 0)
+ goto out;
+
+ ++line_cntr;
+
+ keyword = strtok(line_buf, parse_sep);
+ if (!keyword)
+ goto next_line;
+
+ if (strcmp("torus", keyword) == 0) {
+ kw_success = parse_torus(t, parse_sep);
+ } else if (strcmp("mesh", keyword) == 0) {
+ t->flags |= X_MESH | Y_MESH | Z_MESH;
+ kw_success = parse_torus(t, parse_sep);
+ } else if (strcmp("port_order", keyword) == 0) {
+ kw_success = parse_port_order(t, parse_sep);
+ } else if (strcmp("next_seed", keyword) == 0) {
+ kw_success = grow_seed_array(t, 1);
+ t->seed_cnt++;
+ } else if (strcmp("portgroup_max_ports", keyword) == 0) {
+ kw_success = parse_unsigned(&t->portgrp_sz, parse_sep);
+ } else if (strcmp("xp_link", keyword) == 0) {
+ if (!t->seed_cnt)
+ t->seed_cnt++;
+ kw_success = parse_dir_link(1, t, parse_sep);
+ } else if (strcmp("xm_link", keyword) == 0) {
+ if (!t->seed_cnt)
+ t->seed_cnt++;
+ kw_success = parse_dir_link(-1, t, parse_sep);
+ } else if (strcmp("x_dateline", keyword) == 0) {
+ if (!t->seed_cnt)
+ t->seed_cnt++;
+ kw_success = parse_dir_dateline(1, t, parse_sep);
+ } else if (strcmp("yp_link", keyword) == 0) {
+ if (!t->seed_cnt)
+ t->seed_cnt++;
+ kw_success = parse_dir_link(2, t, parse_sep);
+ } else if (strcmp("ym_link", keyword) == 0) {
+ if (!t->seed_cnt)
+ t->seed_cnt++;
+ kw_success = parse_dir_link(-2, t, parse_sep);
+ } else if (strcmp("y_dateline", keyword) == 0) {
+ if (!t->seed_cnt)
+ t->seed_cnt++;
+ kw_success = parse_dir_dateline(2, t, parse_sep);
+ } else if (strcmp("zp_link", keyword) == 0) {
+ if (!t->seed_cnt)
+ t->seed_cnt++;
+ kw_success = parse_dir_link(3, t, parse_sep);
+ } else if (strcmp("zm_link", keyword) == 0) {
+ if (!t->seed_cnt)
+ t->seed_cnt++;
+ kw_success = parse_dir_link(-3, t, parse_sep);
+ } else if (strcmp("z_dateline", keyword) == 0) {
+ if (!t->seed_cnt)
+ t->seed_cnt++;
+ kw_success = parse_dir_dateline(3, t, parse_sep);
+ } else if (strcmp("max_changes", keyword) == 0) {
+ kw_success = parse_unsigned(&t->max_changes, parse_sep);
+ } else if (keyword[0] == '#')
+ goto next_line;
+ else {
+ OSM_LOG(&t->osm->log, OSM_LOG_ERROR,
+ "ERR 4E12: no keyword found: line %u\n",
+ (unsigned)line_cntr);
+ kw_success = false;
+ }
+ if (!kw_success) {
+ OSM_LOG(&t->osm->log, OSM_LOG_ERROR,
+ "ERR 4E13: parsing '%s': line %u\n",
+ keyword, (unsigned)line_cntr);
+ }
+ success = success && kw_success;
+ goto next_line;
+
+out:
+ if (line_buf)
+ free(line_buf);
+ fclose(fp);
+ return success;
+}
+
+static
+bool capture_fabric(struct fabric *fabric)
+{
+ osm_subn_t *subnet = &fabric->osm->subn;
+ osm_switch_t *osm_sw;
+ osm_physp_t *lphysp, *rphysp;
+ osm_port_t *lport;
+ osm_node_t *osm_node;
+ cl_map_item_t *item;
+ uint8_t ltype, rtype;
+ int p, port_cnt;
+ guid_t sw_guid;
+ bool success = true;
+
+ OSM_LOG_ENTER(&fabric->osm->log);
+
+ /*
+ * On OpenSM data structures:
+ *
+ * Apparently, every port in a fabric has an associated osm_physp_t,
+ * but not every port has an associated osm_port_t. Apparently every
+ * osm_port_t has an associated osm_physp_t.
+ *
+ * So, in order to find the inter-switch links we need to walk the
+ * switch list and examine each port, via its osm_physp_t object.
+ *
+ * But, we need to associate our CA and switch management port
+ * endpoints with the corresponding osm_port_t objects, in order
+ * to simplify computation of LFT entries and perform SL lookup for
+ * path records. Since it is apparently difficult to locate the
+ * osm_port_t that corresponds to a given osm_physp_t, we also
+ * need to walk the list of ports indexed by GUID to get access
+ * to the appropriate osm_port_t objects.
+ *
+ * Need to allocate our switches before we do anything else.
+ */
+ item = cl_qmap_head(&subnet->sw_guid_tbl);
+ while (item != cl_qmap_end(&subnet->sw_guid_tbl)) {
+
+ osm_sw = (osm_switch_t *)item;
+ item = cl_qmap_next(item);
+ osm_sw->priv = NULL; /* avoid stale pointer dereferencing */
+ osm_node = osm_sw->p_node;
+
+ if (osm_node_get_type(osm_node) != IB_NODE_TYPE_SWITCH)
+ continue;
+
+ port_cnt = osm_node_get_num_physp(osm_node);
+ sw_guid = osm_node_get_node_guid(osm_node);
+
+ success = alloc_fswitch(fabric, sw_guid, port_cnt);
+ if (!success)
+ goto out;
+ }
+ /*
+ * Now build all our endpoints.
+ */
+ item = cl_qmap_head(&subnet->port_guid_tbl);
+ while (item != cl_qmap_end(&subnet->port_guid_tbl)) {
+
+ lport = (osm_port_t *)item;
+ item = cl_qmap_next(item);
+ lport->priv = NULL; /* avoid stale pointer dereferencing */
+
+ lphysp = lport->p_physp;
+ if (!(lphysp && osm_physp_is_valid(lphysp)))
+ continue;
+
+ ltype = osm_node_get_type(lphysp->p_node);
+ /*
+ * Switch management port is always port 0.
+ */
+ if (lphysp->port_num == 0 && ltype == IB_NODE_TYPE_SWITCH) {
+ success = build_sw_endpoint(fabric, lport);
+ if (!success)
+ goto out;
+ continue;
+ }
+ rphysp = lphysp->p_remote_physp;
+ if (!(rphysp && osm_physp_is_valid(rphysp)))
+ continue;
+
+ rtype = osm_node_get_type(rphysp->p_node);
+
+ if ((ltype != IB_NODE_TYPE_CA &&
+ ltype != IB_NODE_TYPE_ROUTER) ||
+ rtype != IB_NODE_TYPE_SWITCH)
+ continue;
+
+ success =
+ build_ca_link(fabric, lport,
+ osm_node_get_node_guid(rphysp->p_node),
+ osm_physp_get_port_num(rphysp));
+ if (!success)
+ goto out;
+ }
+ /*
+ * Lastly, build all our interswitch links.
+ */
+ item = cl_qmap_head(&subnet->sw_guid_tbl);
+ while (item != cl_qmap_end(&subnet->sw_guid_tbl)) {
+
+ osm_sw = (osm_switch_t *)item;
+ item = cl_qmap_next(item);
+
+ port_cnt = osm_node_get_num_physp(osm_sw->p_node);
+ for (p = 0; p < port_cnt; p++) {
+
+ lphysp = osm_node_get_physp_ptr(osm_sw->p_node, p);
+ if (!(lphysp && osm_physp_is_valid(lphysp)))
+ continue;
+
+ rphysp = lphysp->p_remote_physp;
+ if (!(rphysp && osm_physp_is_valid(rphysp)))
+ continue;
+
+ if (lphysp == rphysp)
+ continue; /* ignore loopbacks */
+
+ ltype = osm_node_get_type(lphysp->p_node);
+ rtype = osm_node_get_type(rphysp->p_node);
+
+ if (ltype != IB_NODE_TYPE_SWITCH ||
+ rtype != IB_NODE_TYPE_SWITCH)
+ continue;
+
+ success =
+ build_link(fabric,
+ osm_node_get_node_guid(lphysp->p_node),
+ osm_physp_get_port_num(lphysp),
+ osm_node_get_node_guid(rphysp->p_node),
+ osm_physp_get_port_num(rphysp));
+ if (!success)
+ goto out;
+ }
+ }
+out:
+ OSM_LOG_EXIT(&fabric->osm->log);
+ return success;
+}
+
+/*
+ * diagnose_fabric() is just intended to report on fabric elements that
+ * could not be placed into the torus. We want to warn that there were
+ * non-torus fabric elements, but they will be ignored for routing purposes.
+ * Having them is not an error, and diagnose_fabric() thus has no return
+ * value.
+ */
+static
+void diagnose_fabric(struct fabric *f)
+{
+ struct link *l;
+ struct endpoint *ep;
+ unsigned k, p;
+
+ /*
+ * Report on any links that didn't get transferred to the torus.
+ */
+ for (k = 0; k < f->link_cnt; k++) {
+ l = f->link[k];
+
+ if (!(l->end[0].sw && l->end[1].sw))
+ continue;
+
+ OSM_LOG(&f->osm->log, OSM_LOG_INFO,
+ "Found non-torus fabric link:"
+ " sw GUID 0x%04"PRIx64" port %d <->"
+ " sw GUID 0x%04"PRIx64" port %d\n",
+ cl_ntoh64(l->end[0].n_id), l->end[0].port,
+ cl_ntoh64(l->end[1].n_id), l->end[1].port);
+ }
+ /*
+ * Report on any switches with ports using endpoints that didn't
+ * get transferred to the torus.
+ */
+ for (k = 0; k < f->switch_cnt; k++)
+ for (p = 0; p < f->sw[k]->port_cnt; p++) {
+
+ if (!f->sw[k]->port[p])
+ continue;
+
+ ep = f->sw[k]->port[p];
+
+ /*
+ * We already reported on inter-switch links above.
+ */
+ if (ep->type == PASSTHRU)
+ continue;
+
+ OSM_LOG(&f->osm->log, OSM_LOG_INFO,
+ "Found non-torus fabric port:"
+ " sw GUID 0x%04"PRIx64" port %d\n",
+ cl_ntoh64(f->sw[k]->n_id), p);
+ }
+}
+
+static
+struct t_switch *alloc_tswitch(struct torus *t, struct f_switch *fsw)
+{
+ unsigned g;
+ size_t new_sw_sz;
+ struct t_switch *sw = NULL;
+ void *ptr;
+
+ if (!fsw)
+ goto out;
+
+ if (t->switch_cnt >= t->sw_pool_sz) {
+ /*
+ * This should never happen, but occasionally a particularly
+ * pathological fabric can induce it. So log an error.
+ */
+ OSM_LOG(&t->osm->log, OSM_LOG_ERROR,
+ "ERR 4E14: unexpectedly requested too many switch "
+ "structures!\n");
+ goto out;
+ }
+ new_sw_sz = sizeof(*sw)
+ + fsw->port_cnt * sizeof(*sw->port)
+ + SWITCH_MAX_PORTGRPS * t->portgrp_sz * sizeof(*sw->ptgrp[0].port);
+ sw = calloc(1, new_sw_sz);
+ if (!sw) {
+ OSM_LOG(&t->osm->log, OSM_LOG_ERROR,
+ "ERR 4E15: calloc: %s\n", strerror(errno));
+ goto out;
+ }
+ sw->port = (void *)(sw + 1);
+ sw->n_id = fsw->n_id;
+ sw->port_cnt = fsw->port_cnt;
+ sw->torus = t;
+ sw->tmp = fsw;
+
+ ptr = &sw->port[sw->port_cnt];
+
+ for (g = 0; g < SWITCH_MAX_PORTGRPS; g++) {
+ sw->ptgrp[g].port_grp = g;
+ sw->ptgrp[g].sw = sw;
+ sw->ptgrp[g].port = ptr;
+ ptr = &sw->ptgrp[g].port[t->portgrp_sz];
+ }
+ t->sw_pool[t->switch_cnt++] = sw;
+out:
+ return sw;
+}
+
+/*
+ * install_tswitch() expects the switch coordinates i,j,k to be canonicalized
+ * by caller.
+ */
+static
+bool install_tswitch(struct torus *t,
+ int i, int j, int k, struct f_switch *fsw)
+{
+ struct t_switch **sw = &t->sw[i][j][k];
+
+ if (!*sw)
+ *sw = alloc_tswitch(t, fsw);
+
+ if (*sw) {
+ (*sw)->i = i;
+ (*sw)->j = j;
+ (*sw)->k = k;
+ }
+ return !!*sw;
+}
+
+static
+struct link *alloc_tlink(struct torus *t)
+{
+ if (t->link_cnt >= t->link_pool_sz) {
+ OSM_LOG(&t->osm->log, OSM_LOG_ERROR,
+ "ERR 4E16: unexpectedly out of pre-allocated link "
+ "structures!\n");
+ return NULL;
+ }
+ return &t->link_pool[t->link_cnt++];
+}
+
+static
+int canonicalize(int v, int vmax)
+{
+ if (v >= 0 && v < vmax)
+ return v;
+
+ if (v < 0)
+ v += vmax * (1 - v/vmax);
+
+ return v % vmax;
+}
+
+static
+unsigned set_fp_bit(bool present, int i, int j, int k)
+{
+ return (unsigned)(!present) << (i + 2 * j + 4 * k);
+}
+
+/*
+ * Returns an 11-bit fingerprint of what switches are absent in a cube of
+ * neighboring switches. Each bit 0-7 corresponds to a corner of the cube;
+ * if a bit is set the corresponding switch is absent.
+ *
+ * Bits 8-10 distinguish between 2D and 3D cases. If bit 8+d is set,
+ * for 0 <= d < 3; the d dimension of the desired torus has radix greater
+ * than 1. Thus, if all bits 8-10 are set, the desired torus is 3D.
+ */
+static
+unsigned fingerprint(struct torus *t, int i, int j, int k)
+{
+ unsigned fp;
+ int ip1, jp1, kp1;
+ int x_sz_gt1, y_sz_gt1, z_sz_gt1;
+
+ x_sz_gt1 = t->x_sz > 1;
+ y_sz_gt1 = t->y_sz > 1;
+ z_sz_gt1 = t->z_sz > 1;
+
+ ip1 = canonicalize(i + 1, t->x_sz);
+ jp1 = canonicalize(j + 1, t->y_sz);
+ kp1 = canonicalize(k + 1, t->z_sz);
+
+ fp = set_fp_bit(t->sw[i][j][k], 0, 0, 0);
+ fp |= set_fp_bit(t->sw[ip1][j][k], x_sz_gt1, 0, 0);
+ fp |= set_fp_bit(t->sw[i][jp1][k], 0, y_sz_gt1, 0);
+ fp |= set_fp_bit(t->sw[ip1][jp1][k], x_sz_gt1, y_sz_gt1, 0);
+ fp |= set_fp_bit(t->sw[i][j][kp1], 0, 0, z_sz_gt1);
+ fp |= set_fp_bit(t->sw[ip1][j][kp1], x_sz_gt1, 0, z_sz_gt1);
+ fp |= set_fp_bit(t->sw[i][jp1][kp1], 0, y_sz_gt1, z_sz_gt1);
+ fp |= set_fp_bit(t->sw[ip1][jp1][kp1], x_sz_gt1, y_sz_gt1, z_sz_gt1);
+
+ fp |= x_sz_gt1 << 8;
+ fp |= y_sz_gt1 << 9;
+ fp |= z_sz_gt1 << 10;
+
+ return fp;
+}
+
+static
+bool connect_tlink(struct port_grp *pg0, struct endpoint *f_ep0,
+ struct port_grp *pg1, struct endpoint *f_ep1,
+ struct torus *t)
+{
+ struct link *l;
+ bool success = false;
+
+ if (pg0->port_cnt == t->portgrp_sz) {
+ OSM_LOG(&t->osm->log, OSM_LOG_ERROR,
+ "ERR 4E17: exceeded port group max "
+ "port count (%d): switch GUID 0x%04"PRIx64"\n",
+ t->portgrp_sz, cl_ntoh64(pg0->sw->n_id));
+ goto out;
+ }
+ if (pg1->port_cnt == t->portgrp_sz) {
+ OSM_LOG(&t->osm->log, OSM_LOG_ERROR,
+ "ERR 4E18: exceeded port group max "
+ "port count (%d): switch GUID 0x%04"PRIx64"\n",
+ t->portgrp_sz, cl_ntoh64(pg1->sw->n_id));
+ goto out;
+ }
+ l = alloc_tlink(t);
+ if (!l)
+ goto out;
+
+ l->end[0].type = f_ep0->type;
+ l->end[0].port = f_ep0->port;
+ l->end[0].n_id = f_ep0->n_id;
+ l->end[0].sw = pg0->sw;
+ l->end[0].link = l;
+ l->end[0].pgrp = pg0;
+ pg0->port[pg0->port_cnt++] = &l->end[0];
+ pg0->sw->port[f_ep0->port] = &l->end[0];
+
+ if (f_ep0->osm_port) {
+ l->end[0].osm_port = f_ep0->osm_port;
+ l->end[0].osm_port->priv = &l->end[0];
+ f_ep0->osm_port = NULL;
+ }
+
+ l->end[1].type = f_ep1->type;
+ l->end[1].port = f_ep1->port;
+ l->end[1].n_id = f_ep1->n_id;
+ l->end[1].sw = pg1->sw;
+ l->end[1].link = l;
+ l->end[1].pgrp = pg1;
+ pg1->port[pg1->port_cnt++] = &l->end[1];
+ pg1->sw->port[f_ep1->port] = &l->end[1];
+
+ if (f_ep1->osm_port) {
+ l->end[1].osm_port = f_ep1->osm_port;
+ l->end[1].osm_port->priv = &l->end[1];
+ f_ep1->osm_port = NULL;
+ }
+ /*
+ * Disconnect fabric link, so that later we can see if any were
+ * left unconnected in the torus.
+ */
+ ((struct f_switch *)f_ep0->sw)->port[f_ep0->port] = NULL;
+ f_ep0->sw = NULL;
+ f_ep0->port = -1;
+
+ ((struct f_switch *)f_ep1->sw)->port[f_ep1->port] = NULL;
+ f_ep1->sw = NULL;
+ f_ep1->port = -1;
+
+ success = true;
+out:
+ return success;
+}
+
+static
+bool link_tswitches(struct torus *t, int cdir,
+ struct t_switch *t_sw0, struct t_switch *t_sw1)
+{
+ int p;
+ struct port_grp *pg0, *pg1;
+ struct f_switch *f_sw0, *f_sw1;
+ const char *cdir_name = "unknown";
+ unsigned port_cnt;
+ int success = false;
+
+ /*
+ * If this is a 2D torus, it is possible for this function to be
+ * called with its two switch arguments being the same switch, in
+ * which case there are no links to install.
+ */
+ if (t_sw0 == t_sw1 &&
+ ((cdir == 0 && t->x_sz == 1) ||
+ (cdir == 1 && t->y_sz == 1) ||
+ (cdir == 2 && t->z_sz == 1))) {
+ success = true;
+ goto out;
+ }
+ /*
+ * Ensure that t_sw1 is in the positive cdir direction wrt. t_sw0.
+ * ring_next_sw() relies on it.
+ */
+ switch (cdir) {
+ case 0:
+ if (t->x_sz > 1 &&
+ canonicalize(t_sw0->i + 1, t->x_sz) != t_sw1->i) {
+ cdir_name = "x";
+ goto cdir_error;
+ }
+ break;
+ case 1:
+ if (t->y_sz > 1 &&
+ canonicalize(t_sw0->j + 1, t->y_sz) != t_sw1->j) {
+ cdir_name = "y";
+ goto cdir_error;
+ }
+ break;
+ case 2:
+ if (t->z_sz > 1 &&
+ canonicalize(t_sw0->k + 1, t->z_sz) != t_sw1->k) {
+ cdir_name = "z";
+ goto cdir_error;
+ }
+ break;
+ default:
+ cdir_error:
+ OSM_LOG(&t->osm->log, OSM_LOG_ERROR, "ERR 4E19: "
+ "sw 0x%04"PRIx64" (%d,%d,%d) <--> "
+ "sw 0x%04"PRIx64" (%d,%d,%d) "
+ "invalid torus %s link orientation\n",
+ cl_ntoh64(t_sw0->n_id), t_sw0->i, t_sw0->j, t_sw0->k,
+ cl_ntoh64(t_sw1->n_id), t_sw1->i, t_sw1->j, t_sw1->k,
+ cdir_name);
+ goto out;
+ }
+
+ f_sw0 = t_sw0->tmp;
+ f_sw1 = t_sw1->tmp;
+
+ if (!f_sw0 || !f_sw1) {
+ OSM_LOG(&t->osm->log, OSM_LOG_ERROR,
+ "ERR 4E1A: missing fabric switches!\n"
+ " switch GUIDs: 0x%04"PRIx64" 0x%04"PRIx64"\n",
+ cl_ntoh64(t_sw0->n_id), cl_ntoh64(t_sw1->n_id));
+ goto out;
+ }
+ pg0 = &t_sw0->ptgrp[2*cdir + 1];
+ pg0->type = PASSTHRU;
+
+ pg1 = &t_sw1->ptgrp[2*cdir];
+ pg1->type = PASSTHRU;
+
+ port_cnt = f_sw0->port_cnt;
+ /*
+ * Find all the links between these two switches.
+ */
+ for (p = 0; p < port_cnt; p++) {
+ struct endpoint *f_ep0 = NULL, *f_ep1 = NULL;
+
+ if (!f_sw0->port[p] || !f_sw0->port[p]->link)
+ continue;
+
+ if (f_sw0->port[p]->link->end[0].n_id == t_sw0->n_id &&
+ f_sw0->port[p]->link->end[1].n_id == t_sw1->n_id) {
+
+ f_ep0 = &f_sw0->port[p]->link->end[0];
+ f_ep1 = &f_sw0->port[p]->link->end[1];
+ } else if (f_sw0->port[p]->link->end[1].n_id == t_sw0->n_id &&
+ f_sw0->port[p]->link->end[0].n_id == t_sw1->n_id) {
+
+ f_ep0 = &f_sw0->port[p]->link->end[1];
+ f_ep1 = &f_sw0->port[p]->link->end[0];
+ } else
+ continue;
+
+ if (!(f_ep0->type == PASSTHRU && f_ep1->type == PASSTHRU)) {
+ OSM_LOG(&t->osm->log, OSM_LOG_ERROR,
+ "ERR 4E1B: not interswitch "
+ "link:\n 0x%04"PRIx64"/%d <-> 0x%04"PRIx64"/%d\n",
+ cl_ntoh64(f_ep0->n_id), f_ep0->port,
+ cl_ntoh64(f_ep1->n_id), f_ep1->port);
+ goto out;
+ }
+ /*
+ * Skip over links that already have been established in the
+ * torus.
+ */
+ if (!(f_ep0->sw && f_ep1->sw))
+ continue;
+
+ if (!connect_tlink(pg0, f_ep0, pg1, f_ep1, t))
+ goto out;
+ }
+ success = true;
+out:
+ return success;
+}
+
+static
+bool link_srcsink(struct torus *t, int i, int j, int k)
+{
+ struct endpoint *f_ep0;
+ struct endpoint *f_ep1;
+ struct t_switch *tsw;
+ struct f_switch *fsw;
+ struct port_grp *pg;
+ struct link *fl, *tl;
+ unsigned p, port_cnt;
+ bool success = false;
+
+ i = canonicalize(i, t->x_sz);
+ j = canonicalize(j, t->y_sz);
+ k = canonicalize(k, t->z_sz);
+
+ tsw = t->sw[i][j][k];
+ if (!tsw)
+ return true;
+
+ fsw = tsw->tmp;
+ /*
+ * link_srcsink is supposed to get called once for every switch in
+ * the fabric. At this point every fsw we encounter must have a
+ * non-null osm_switch. Otherwise something has gone horribly
+ * wrong with topology discovery; the most likely reason is that
+ * the fabric contains a radix-4 torus dimension, but the user gave
+ * a config that didn't say so, breaking all the checking in
+ * safe_x_perpendicular and friends.
+ */
+ if (!(fsw && fsw->osm_switch)) {
+ OSM_LOG(&t->osm->log, OSM_LOG_ERROR,
+ "ERR 4E1C: Invalid topology discovery. "
+ "Verify torus-2QoS.conf contents.\n");
+ return false;
+ }
+
+ pg = &tsw->ptgrp[2 * TORUS_MAX_DIM];
+ pg->type = SRCSINK;
+ tsw->osm_switch = fsw->osm_switch;
+ tsw->osm_switch->priv = tsw;
+ fsw->osm_switch = NULL;
+
+ port_cnt = fsw->port_cnt;
+ for (p = 0; p < port_cnt; p++) {
+
+ if (!fsw->port[p])
+ continue;
+
+ if (fsw->port[p]->type == SRCSINK) {
+ /*
+ * If the endpoint is the switch port used for in-band
+ * communication with the switch itself, move it to
+ * the torus.
+ */
+ if (pg->port_cnt == t->portgrp_sz) {
+ OSM_LOG(&t->osm->log, OSM_LOG_ERROR,
+ "ERR 4E1D: exceeded port group max port "
+ "count (%d): switch GUID 0x%04"PRIx64"\n",
+ t->portgrp_sz, cl_ntoh64(tsw->n_id));
+ goto out;
+ }
+ fsw->port[p]->sw = tsw;
+ fsw->port[p]->pgrp = pg;
+ tsw->port[p] = fsw->port[p];
+ tsw->port[p]->osm_port->priv = tsw->port[p];
+ pg->port[pg->port_cnt++] = fsw->port[p];
+ fsw->port[p] = NULL;
+
+ } else if (fsw->port[p]->link &&
+ fsw->port[p]->type == PASSTHRU) {
+ /*
+ * If the endpoint is a link to a CA, create a new link
+ * in the torus. Disconnect the fabric link.
+ */
+
+ fl = fsw->port[p]->link;
+
+ if (fl->end[0].sw == fsw) {
+ f_ep0 = &fl->end[0];
+ f_ep1 = &fl->end[1];
+ } else if (fl->end[1].sw == fsw) {
+ f_ep1 = &fl->end[0];
+ f_ep0 = &fl->end[1];
+ } else
+ continue;
+
+ if (f_ep1->type != SRCSINK)
+ continue;
+
+ if (pg->port_cnt == t->portgrp_sz) {
+ OSM_LOG(&t->osm->log, OSM_LOG_ERROR,
+ "ERR 4E1E: exceeded port group max port "
+ "count (%d): switch GUID 0x%04"PRIx64"\n",
+ t->portgrp_sz, cl_ntoh64(tsw->n_id));
+ goto out;
+ }
+ /*
+ * Switch ports connected to links don't get
+ * associated with osm_port_t objects; see
+ * capture_fabric(). So just check CA end.
+ */
+ if (!f_ep1->osm_port) {
+ OSM_LOG(&t->osm->log, OSM_LOG_ERROR,
+ "ERR 4E1F: NULL osm_port->priv port "
+ "GUID 0x%04"PRIx64"\n",
+ cl_ntoh64(f_ep1->n_id));
+ goto out;
+ }
+ tl = alloc_tlink(t);
+ if (!tl)
+ continue;
+
+ tl->end[0].type = f_ep0->type;
+ tl->end[0].port = f_ep0->port;
+ tl->end[0].n_id = f_ep0->n_id;
+ tl->end[0].sw = tsw;
+ tl->end[0].link = tl;
+ tl->end[0].pgrp = pg;
+ pg->port[pg->port_cnt++] = &tl->end[0];
+ pg->sw->port[f_ep0->port] = &tl->end[0];
+
+ tl->end[1].type = f_ep1->type;
+ tl->end[1].port = f_ep1->port;
+ tl->end[1].n_id = f_ep1->n_id;
+ tl->end[1].sw = NULL; /* Correct for a CA */
+ tl->end[1].link = tl;
+ tl->end[1].pgrp = NULL; /* Correct for a CA */
+
+ tl->end[1].osm_port = f_ep1->osm_port;
+ tl->end[1].osm_port->priv = &tl->end[1];
+ f_ep1->osm_port = NULL;
+
+ t->ca_cnt++;
+ f_ep0->sw = NULL;
+ f_ep0->port = -1;
+ fsw->port[p] = NULL;
+ }
+ }
+ success = true;
+out:
+ return success;
+}
+
+static
+struct f_switch *ffind_face_corner(struct f_switch *fsw0,
+ struct f_switch *fsw1,
+ struct f_switch *fsw2)
+{
+ int p0, p3;
+ struct link *l;
+ struct endpoint *far_end;
+ struct f_switch *fsw, *fsw3 = NULL;
+
+ if (!(fsw0 && fsw1 && fsw2))
+ goto out;
+
+ for (p0 = 0; p0 < fsw0->port_cnt; p0++) {
+ /*
+ * Ignore everything except switch links that haven't
+ * been installed into the torus.
+ */
+ if (!(fsw0->port[p0] && fsw0->port[p0]->sw &&
+ fsw0->port[p0]->type == PASSTHRU))
+ continue;
+
+ l = fsw0->port[p0]->link;
+
+ if (l->end[0].n_id == fsw0->n_id)
+ far_end = &l->end[1];
+ else
+ far_end = &l->end[0];
+
+ /*
+ * Ignore CAs
+ */
+ if (!(far_end->type == PASSTHRU && far_end->sw))
+ continue;
+
+ fsw3 = far_end->sw;
+ if (fsw3->n_id == fsw1->n_id) /* existing corner */
+ continue;
+
+ for (p3 = 0; p3 < fsw3->port_cnt; p3++) {
+ /*
+ * Ignore everything except switch links that haven't
+ * been installed into the torus.
+ */
+ if (!(fsw3->port[p3] && fsw3->port[p3]->sw &&
+ fsw3->port[p3]->type == PASSTHRU))
+ continue;
+
+ l = fsw3->port[p3]->link;
+
+ if (l->end[0].n_id == fsw3->n_id)
+ far_end = &l->end[1];
+ else
+ far_end = &l->end[0];
+
+ /*
+ * Ignore CAs
+ */
+ if (!(far_end->type == PASSTHRU && far_end->sw))
+ continue;
+
+ fsw = far_end->sw;
+ if (fsw->n_id == fsw2->n_id)
+ goto out;
+ }
+ }
+ fsw3 = NULL;
+out:
+ return fsw3;
+}
+
+static
+struct f_switch *tfind_face_corner(struct t_switch *tsw0,
+ struct t_switch *tsw1,
+ struct t_switch *tsw2)
+{
+ if (!(tsw0 && tsw1 && tsw2))
+ return NULL;
+
+ return ffind_face_corner(tsw0->tmp, tsw1->tmp, tsw2->tmp);
+}
+
+/*
+ * This code can break on any torus with a dimension that has radix four.
+ *
+ * What is supposed to happen is that this code will find the
+ * two faces whose shared edge is the desired perpendicular.
+ *
+ * What actually happens is while searching we send two connected
+ * edges that are colinear in a torus dimension with radix four to
+ * ffind_face_corner(), which tries to complete a face by finding a
+ * 4-loop of edges.
+ *
+ * In the radix four torus case, it can find a 4-loop which is a ring in a
+ * dimension with radix four, rather than the desired face. It thus returns
+ * true when it shouldn't, so the wrong edge is returned as the perpendicular.
+ *
+ * The appropriate instance of safe_N_perpendicular() (where N == x, y, z)
+ * should be used to determine if it is safe to call ffind_perpendicular();
+ * these functions will return false it there is a possibility of finding
+ * a wrong perpendicular.
+ */
+struct f_switch *ffind_3d_perpendicular(struct f_switch *fsw0,
+ struct f_switch *fsw1,
+ struct f_switch *fsw2,
+ struct f_switch *fsw3)
+{
+ int p1;
+ struct link *l;
+ struct endpoint *far_end;
+ struct f_switch *fsw4 = NULL;
+
+ if (!(fsw0 && fsw1 && fsw2 && fsw3))
+ goto out;
+
+ /*
+ * Look at all the ports on the switch, fsw1, that is the base of
+ * the perpendicular.
+ */
+ for (p1 = 0; p1 < fsw1->port_cnt; p1++) {
+ /*
+ * Ignore everything except switch links that haven't
+ * been installed into the torus.
+ */
+ if (!(fsw1->port[p1] && fsw1->port[p1]->sw &&
+ fsw1->port[p1]->type == PASSTHRU))
+ continue;
+
+ l = fsw1->port[p1]->link;
+
+ if (l->end[0].n_id == fsw1->n_id)
+ far_end = &l->end[1];
+ else
+ far_end = &l->end[0];
+ /*
+ * Ignore CAs
+ */
+ if (!(far_end->type == PASSTHRU && far_end->sw))
+ continue;
+
+ fsw4 = far_end->sw;
+ if (fsw4->n_id == fsw3->n_id) /* wrong perpendicular */
+ continue;
+
+ if (ffind_face_corner(fsw0, fsw1, fsw4) &&
+ ffind_face_corner(fsw2, fsw1, fsw4))
+ goto out;
+ }
+ fsw4 = NULL;
+out:
+ return fsw4;
+}
+struct f_switch *ffind_2d_perpendicular(struct f_switch *fsw0,
+ struct f_switch *fsw1,
+ struct f_switch *fsw2)
+{
+ int p1;
+ struct link *l;
+ struct endpoint *far_end;
+ struct f_switch *fsw3 = NULL;
+
+ if (!(fsw0 && fsw1 && fsw2))
+ goto out;
+
+ /*
+ * Look at all the ports on the switch, fsw1, that is the base of
+ * the perpendicular.
+ */
+ for (p1 = 0; p1 < fsw1->port_cnt; p1++) {
+ /*
+ * Ignore everything except switch links that haven't
+ * been installed into the torus.
+ */
+ if (!(fsw1->port[p1] && fsw1->port[p1]->sw &&
+ fsw1->port[p1]->type == PASSTHRU))
+ continue;
+
+ l = fsw1->port[p1]->link;
+
+ if (l->end[0].n_id == fsw1->n_id)
+ far_end = &l->end[1];
+ else
+ far_end = &l->end[0];
+ /*
+ * Ignore CAs
+ */
+ if (!(far_end->type == PASSTHRU && far_end->sw))
+ continue;
+
+ fsw3 = far_end->sw;
+ if (fsw3->n_id == fsw2->n_id) /* wrong perpendicular */
+ continue;
+
+ if (ffind_face_corner(fsw0, fsw1, fsw3))
+ goto out;
+ }
+ fsw3 = NULL;
+out:
+ return fsw3;
+}
+
+static
+struct f_switch *tfind_3d_perpendicular(struct t_switch *tsw0,
+ struct t_switch *tsw1,
+ struct t_switch *tsw2,
+ struct t_switch *tsw3)
+{
+ if (!(tsw0 && tsw1 && tsw2 && tsw3))
+ return NULL;
+
+ return ffind_3d_perpendicular(tsw0->tmp, tsw1->tmp,
+ tsw2->tmp, tsw3->tmp);
+}
+
+static
+struct f_switch *tfind_2d_perpendicular(struct t_switch *tsw0,
+ struct t_switch *tsw1,
+ struct t_switch *tsw2)
+{
+ if (!(tsw0 && tsw1 && tsw2))
+ return NULL;
+
+ return ffind_2d_perpendicular(tsw0->tmp, tsw1->tmp, tsw2->tmp);
+}
+
+static
+bool safe_x_ring(struct torus *t, int i, int j, int k)
+{
+ int im1, ip1, ip2;
+ bool success = true;
+
+ /*
+ * If this x-direction radix-4 ring has at least two links
+ * already installed into the torus, then this ring does not
+ * prevent us from looking for y or z direction perpendiculars.
+ *
+ * It is easier to check for the appropriate switches being installed
+ * into the torus than it is to check for the links, so force the
+ * link installation if the appropriate switches are installed.
+ *
+ * Recall that canonicalize(n - 2, 4) == canonicalize(n + 2, 4).
+ */
+ if (t->x_sz != 4 || t->flags & X_MESH)
+ goto out;
+
+ im1 = canonicalize(i - 1, t->x_sz);
+ ip1 = canonicalize(i + 1, t->x_sz);
+ ip2 = canonicalize(i + 2, t->x_sz);
+
+ if (!!t->sw[im1][j][k] +
+ !!t->sw[ip1][j][k] + !!t->sw[ip2][j][k] < 2) {
+ success = false;
+ goto out;
+ }
+ if (t->sw[ip2][j][k] && t->sw[im1][j][k])
+ success = link_tswitches(t, 0,
+ t->sw[ip2][j][k],
+ t->sw[im1][j][k])
+ && success;
+
+ if (t->sw[im1][j][k] && t->sw[i][j][k])
+ success = link_tswitches(t, 0,
+ t->sw[im1][j][k],
+ t->sw[i][j][k])
+ && success;
+
+ if (t->sw[i][j][k] && t->sw[ip1][j][k])
+ success = link_tswitches(t, 0,
+ t->sw[i][j][k],
+ t->sw[ip1][j][k])
+ && success;
+
+ if (t->sw[ip1][j][k] && t->sw[ip2][j][k])
+ success = link_tswitches(t, 0,
+ t->sw[ip1][j][k],
+ t->sw[ip2][j][k])
+ && success;
+out:
+ return success;
+}
+
+static
+bool safe_y_ring(struct torus *t, int i, int j, int k)
+{
+ int jm1, jp1, jp2;
+ bool success = true;
+
+ /*
+ * If this y-direction radix-4 ring has at least two links
+ * already installed into the torus, then this ring does not
+ * prevent us from looking for x or z direction perpendiculars.
+ *
+ * It is easier to check for the appropriate switches being installed
+ * into the torus than it is to check for the links, so force the
+ * link installation if the appropriate switches are installed.
+ *
+ * Recall that canonicalize(n - 2, 4) == canonicalize(n + 2, 4).
+ */
+ if (t->y_sz != 4 || (t->flags & Y_MESH))
+ goto out;
+
+ jm1 = canonicalize(j - 1, t->y_sz);
+ jp1 = canonicalize(j + 1, t->y_sz);
+ jp2 = canonicalize(j + 2, t->y_sz);
+
+ if (!!t->sw[i][jm1][k] +
+ !!t->sw[i][jp1][k] + !!t->sw[i][jp2][k] < 2) {
+ success = false;
+ goto out;
+ }
+ if (t->sw[i][jp2][k] && t->sw[i][jm1][k])
+ success = link_tswitches(t, 1,
+ t->sw[i][jp2][k],
+ t->sw[i][jm1][k])
+ && success;
+
+ if (t->sw[i][jm1][k] && t->sw[i][j][k])
+ success = link_tswitches(t, 1,
+ t->sw[i][jm1][k],
+ t->sw[i][j][k])
+ && success;
+
+ if (t->sw[i][j][k] && t->sw[i][jp1][k])
+ success = link_tswitches(t, 1,
+ t->sw[i][j][k],
+ t->sw[i][jp1][k])
+ && success;
+
+ if (t->sw[i][jp1][k] && t->sw[i][jp2][k])
+ success = link_tswitches(t, 1,
+ t->sw[i][jp1][k],
+ t->sw[i][jp2][k])
+ && success;
+out:
+ return success;
+}
+
+static
+bool safe_z_ring(struct torus *t, int i, int j, int k)
+{
+ int km1, kp1, kp2;
+ bool success = true;
+
+ /*
+ * If this z-direction radix-4 ring has at least two links
+ * already installed into the torus, then this ring does not
+ * prevent us from looking for x or y direction perpendiculars.
+ *
+ * It is easier to check for the appropriate switches being installed
+ * into the torus than it is to check for the links, so force the
+ * link installation if the appropriate switches are installed.
+ *
+ * Recall that canonicalize(n - 2, 4) == canonicalize(n + 2, 4).
+ */
+ if (t->z_sz != 4 || t->flags & Z_MESH)
+ goto out;
+
+ km1 = canonicalize(k - 1, t->z_sz);
+ kp1 = canonicalize(k + 1, t->z_sz);
+ kp2 = canonicalize(k + 2, t->z_sz);
+
+ if (!!t->sw[i][j][km1] +
+ !!t->sw[i][j][kp1] + !!t->sw[i][j][kp2] < 2) {
+ success = false;
+ goto out;
+ }
+ if (t->sw[i][j][kp2] && t->sw[i][j][km1])
+ success = link_tswitches(t, 2,
+ t->sw[i][j][kp2],
+ t->sw[i][j][km1])
+ && success;
+
+ if (t->sw[i][j][km1] && t->sw[i][j][k])
+ success = link_tswitches(t, 2,
+ t->sw[i][j][km1],
+ t->sw[i][j][k])
+ && success;
+
+ if (t->sw[i][j][k] && t->sw[i][j][kp1])
+ success = link_tswitches(t, 2,
+ t->sw[i][j][k],
+ t->sw[i][j][kp1])
+ && success;
+
+ if (t->sw[i][j][kp1] && t->sw[i][j][kp2])
+ success = link_tswitches(t, 2,
+ t->sw[i][j][kp1],
+ t->sw[i][j][kp2])
+ && success;
+out:
+ return success;
+}
+
+/*
+ * These functions return true when it safe to call
+ * tfind_3d_perpendicular()/ffind_3d_perpendicular().
+ */
+static
+bool safe_x_perpendicular(struct torus *t, int i, int j, int k)
+{
+ /*
+ * If the dimensions perpendicular to the search direction are
+ * not radix 4 torus dimensions, it is always safe to search for
+ * a perpendicular.
+ *
+ * Here we are checking for enough appropriate links having been
+ * installed into the torus to prevent an incorrect link from being
+ * considered as a perpendicular candidate.
+ */
+ return safe_y_ring(t, i, j, k) && safe_z_ring(t, i, j, k);
+}
+
+static
+bool safe_y_perpendicular(struct torus *t, int i, int j, int k)
+{
+ /*
+ * If the dimensions perpendicular to the search direction are
+ * not radix 4 torus dimensions, it is always safe to search for
+ * a perpendicular.
+ *
+ * Here we are checking for enough appropriate links having been
+ * installed into the torus to prevent an incorrect link from being
+ * considered as a perpendicular candidate.
+ */
+ return safe_x_ring(t, i, j, k) && safe_z_ring(t, i, j, k);
+}
+
+static
+bool safe_z_perpendicular(struct torus *t, int i, int j, int k)
+{
+ /*
+ * If the dimensions perpendicular to the search direction are
+ * not radix 4 torus dimensions, it is always safe to search for
+ * a perpendicular.
+ *
+ * Implement this by checking for enough appropriate links having
+ * been installed into the torus to prevent an incorrect link from
+ * being considered as a perpendicular candidate.
+ */
+ return safe_x_ring(t, i, j, k) && safe_y_ring(t, i, j, k);
+}
+
+/*
+ * Templates for determining 2D/3D case fingerprints. Recall that if
+ * a fingerprint bit is set the corresponding switch is absent from
+ * the all-switches-present template.
+ *
+ * I.e., for the 2D case where the x,y dimensions have a radix greater
+ * than one, and the z dimension has radix 1, fingerprint bits 4-7 are
+ * always zero.
+ *
+ * For the 2D case where the x,z dimensions have a radix greater than
+ * one, and the y dimension has radix 1, fingerprint bits 2,3,6,7 are
+ * always zero.
+ *
+ * For the 2D case where the y,z dimensions have a radix greater than
+ * one, and the x dimension has radix 1, fingerprint bits 1,3,5,7 are
+ * always zero.
+ *
+ * Recall also that bits 8-10 distinguish between 2D and 3D cases.
+ * If bit 8+d is set, for 0 <= d < 3; the d dimension of the desired
+ * torus has radix greater than 1.
+ */
+
+/*
+ * 2D case 0x300
+ * b0: t->sw[i ][j ][0 ]
+ * b1: t->sw[i+1][j ][0 ]
+ * b2: t->sw[i ][j+1][0 ]
+ * b3: t->sw[i+1][j+1][0 ]
+ * O . . . . . O
+ * 2D case 0x500 . .
+ * b0: t->sw[i ][0 ][k ] . .
+ * b1: t->sw[i+1][0 ][k ] . .
+ * b4: t->sw[i ][0 ][k+1] . .
+ * b5: t->sw[i+1][0 ][k+1] . .
+ * @ . . . . . O
+ * 2D case 0x600
+ * b0: t->sw[0 ][j ][k ]
+ * b2: t->sw[0 ][j+1][k ]
+ * b4: t->sw[0 ][j ][k+1]
+ * b6: t->sw[0 ][j+1][k+1]
+ */
+
+/*
+ * 3D case 0x700: O
+ * . . .
+ * b0: t->sw[i ][j ][k ] . . .
+ * b1: t->sw[i+1][j ][k ] . . .
+ * b2: t->sw[i ][j+1][k ] . . .
+ * b3: t->sw[i+1][j+1][k ] O . O
+ * b4: t->sw[i ][j ][k+1] . . O . .
+ * b5: t->sw[i+1][j ][k+1] . . . . . .
+ * b6: t->sw[i ][j+1][k+1] . . . .
+ * b7: t->sw[i+1][j+1][k+1] . . . . . .
+ * . . O . .
+ * O . O
+ * . . .
+ * . . .
+ * . . .
+ * . . .
+ * @
+ */
+
+static
+void log_no_crnr(struct torus *t, unsigned n,
+ int case_i, int case_j, int case_k,
+ int crnr_i, int crnr_j, int crnr_k)
+{
+ if (t->debug)
+ OSM_LOG(&t->osm->log, OSM_LOG_INFO, "Case 0x%03x "
+ "@ %d %d %d: no corner @ %d %d %d\n",
+ n, case_i, case_j, case_k, crnr_i, crnr_j, crnr_k);
+}
+
+static
+void log_no_perp(struct torus *t, unsigned n,
+ int case_i, int case_j, int case_k,
+ int perp_i, int perp_j, int perp_k)
+{
+ if (t->debug)
+ OSM_LOG(&t->osm->log, OSM_LOG_INFO, "Case 0x%03x "
+ "@ %d %d %d: no perpendicular @ %d %d %d\n",
+ n, case_i, case_j, case_k, perp_i, perp_j, perp_k);
+}
+
+/*
+ * Handle the 2D cases with a single existing edge.
+ *
+ */
+
+/*
+ * 2D case 0x30c
+ * b0: t->sw[i ][j ][0 ]
+ * b1: t->sw[i+1][j ][0 ]
+ * b2:
+ * b3:
+ * O O
+ * 2D case 0x530
+ * b0: t->sw[i ][0 ][k ]
+ * b1: t->sw[i+1][0 ][k ]
+ * b4:
+ * b5:
+ * @ . . . . . O
+ * 2D case 0x650
+ * b0: t->sw[0 ][j ][k ]
+ * b2: t->sw[0 ][j+1][k ]
+ * b4:
+ * b6:
+ */
+static
+bool handle_case_0x30c(struct torus *t, int i, int j, int k)
+{
+ int ip1 = canonicalize(i + 1, t->x_sz);
+ int jm1 = canonicalize(j - 1, t->y_sz);
+ int jp1 = canonicalize(j + 1, t->y_sz);
+
+ if (safe_y_perpendicular(t, i, j, k) &&
+ install_tswitch(t, i, jp1, k,
+ tfind_2d_perpendicular(t->sw[ip1][j][k],
+ t->sw[i][j][k],
+ t->sw[i][jm1][k]))) {
+ return true;
+ }
+ log_no_perp(t, 0x30c, i, j, k, i, j, k);
+
+ if (safe_y_perpendicular(t, ip1, j, k) &&
+ install_tswitch(t, ip1, jp1, k,
+ tfind_2d_perpendicular(t->sw[i][j][k],
+ t->sw[ip1][j][k],
+ t->sw[ip1][jm1][k]))) {
+ return true;
+ }
+ log_no_perp(t, 0x30c, i, j, k, ip1, j, k);
+ return false;
+}
+
+static
+bool handle_case_0x530(struct torus *t, int i, int j, int k)
+{
+ int ip1 = canonicalize(i + 1, t->x_sz);
+ int km1 = canonicalize(k - 1, t->z_sz);
+ int kp1 = canonicalize(k + 1, t->z_sz);
+
+ if (safe_z_perpendicular(t, i, j, k) &&
+ install_tswitch(t, i, j, kp1,
+ tfind_2d_perpendicular(t->sw[ip1][j][k],
+ t->sw[i][j][k],
+ t->sw[i][j][km1]))) {
+ return true;
+ }
+ log_no_perp(t, 0x530, i, j, k, i, j, k);
+
+ if (safe_z_perpendicular(t, ip1, j, k) &&
+ install_tswitch(t, ip1, j, kp1,
+ tfind_2d_perpendicular(t->sw[i][j][k],
+ t->sw[ip1][j][k],
+ t->sw[ip1][j][km1]))) {
+ return true;
+ }
+ log_no_perp(t, 0x530, i, j, k, ip1, j, k);
+ return false;
+}
+
+static
+bool handle_case_0x650(struct torus *t, int i, int j, int k)
+{
+ int jp1 = canonicalize(j + 1, t->y_sz);
+ int km1 = canonicalize(k - 1, t->z_sz);
+ int kp1 = canonicalize(k + 1, t->z_sz);
+
+ if (safe_z_perpendicular(t, i, j, k) &&
+ install_tswitch(t, i, j, kp1,
+ tfind_2d_perpendicular(t->sw[i][jp1][k],
+ t->sw[i][j][k],
+ t->sw[i][j][km1]))) {
+ return true;
+ }
+ log_no_perp(t, 0x650, i, j, k, i, j, k);
+
+ if (safe_z_perpendicular(t, i, jp1, k) &&
+ install_tswitch(t, i, jp1, kp1,
+ tfind_2d_perpendicular(t->sw[i][j][k],
+ t->sw[i][jp1][k],
+ t->sw[i][jp1][km1]))) {
+ return true;
+ }
+ log_no_perp(t, 0x650, i, j, k, i, jp1, k);
+ return false;
+}
+
+/*
+ * 2D case 0x305
+ * b0:
+ * b1: t->sw[i+1][j ][0 ]
+ * b2:
+ * b3: t->sw[i+1][j+1][0 ]
+ * O O
+ * 2D case 0x511 .
+ * b0: .
+ * b1: t->sw[i+1][0 ][k ] .
+ * b4: .
+ * b5: t->sw[i+1][0 ][k+1] .
+ * @ O
+ * 2D case 0x611
+ * b0:
+ * b2: t->sw[0 ][j+1][k ]
+ * b4:
+ * b6: t->sw[0 ][j+1][k+1]
+ */
+static
+bool handle_case_0x305(struct torus *t, int i, int j, int k)
+{
+ int ip1 = canonicalize(i + 1, t->x_sz);
+ int ip2 = canonicalize(i + 2, t->x_sz);
+ int jp1 = canonicalize(j + 1, t->y_sz);
+
+ if (safe_x_perpendicular(t, ip1, j, k) &&
+ install_tswitch(t, i, j, k,
+ tfind_2d_perpendicular(t->sw[ip1][jp1][k],
+ t->sw[ip1][j][k],
+ t->sw[ip2][j][k]))) {
+ return true;
+ }
+ log_no_perp(t, 0x305, i, j, k, ip1, j, k);
+
+ if (safe_x_perpendicular(t, ip1, jp1, k) &&
+ install_tswitch(t, i, jp1, k,
+ tfind_2d_perpendicular(t->sw[ip1][j][k],
+ t->sw[ip1][jp1][k],
+ t->sw[ip2][jp1][k]))) {
+ return true;
+ }
+ log_no_perp(t, 0x305, i, j, k, ip1, jp1, k);
+ return false;
+}
+
+static
+bool handle_case_0x511(struct torus *t, int i, int j, int k)
+{
+ int ip1 = canonicalize(i + 1, t->x_sz);
+ int ip2 = canonicalize(i + 2, t->x_sz);
+ int kp1 = canonicalize(k + 1, t->z_sz);
+
+ if (safe_x_perpendicular(t, ip1, j, k) &&
+ install_tswitch(t, i, j, k,
+ tfind_2d_perpendicular(t->sw[ip1][j][kp1],
+ t->sw[ip1][j][k],
+ t->sw[ip2][j][k]))) {
+ return true;
+ }
+ log_no_perp(t, 0x511, i, j, k, ip1, j, k);
+
+ if (safe_x_perpendicular(t, ip1, j, kp1) &&
+ install_tswitch(t, i, j, kp1,
+ tfind_2d_perpendicular(t->sw[ip1][j][k],
+ t->sw[ip1][j][kp1],
+ t->sw[ip2][j][kp1]))) {
+ return true;
+ }
+ log_no_perp(t, 0x511, i, j, k, ip1, j, kp1);
+ return false;
+}
+
+static
+bool handle_case_0x611(struct torus *t, int i, int j, int k)
+{
+ int jp1 = canonicalize(j + 1, t->y_sz);
+ int jp2 = canonicalize(j + 2, t->y_sz);
+ int kp1 = canonicalize(k + 1, t->z_sz);
+
+ if (safe_y_perpendicular(t, i, jp1, k) &&
+ install_tswitch(t, i, j, k,
+ tfind_2d_perpendicular(t->sw[i][jp1][kp1],
+ t->sw[i][jp1][k],
+ t->sw[i][jp2][k]))) {
+ return true;
+ }
+ log_no_perp(t, 0x611, i, j, k, i, jp1, k);
+
+ if (safe_y_perpendicular(t, i, jp1, kp1) &&
+ install_tswitch(t, i, j, kp1,
+ tfind_2d_perpendicular(t->sw[i][jp1][k],
+ t->sw[i][jp1][kp1],
+ t->sw[i][jp2][kp1]))) {
+ return true;
+ }
+ log_no_perp(t, 0x611, i, j, k, i, jp1, kp1);
+ return false;
+}
+
+/*
+ * 2D case 0x303
+ * b0:
+ * b1:
+ * b2: t->sw[i ][j+1][0 ]
+ * b3: t->sw[i+1][j+1][0 ]
+ * O . . . . . O
+ * 2D case 0x503
+ * b0:
+ * b1:
+ * b4: t->sw[i ][0 ][k+1]
+ * b5: t->sw[i+1][0 ][k+1]
+ * @ O
+ * 2D case 0x605
+ * b0:
+ * b2:
+ * b4: t->sw[0 ][j ][k+1]
+ * b6: t->sw[0 ][j+1][k+1]
+ */
+static
+bool handle_case_0x303(struct torus *t, int i, int j, int k)
+{
+ int ip1 = canonicalize(i + 1, t->x_sz);
+ int jp1 = canonicalize(j + 1, t->y_sz);
+ int jp2 = canonicalize(j + 2, t->y_sz);
+
+ if (safe_y_perpendicular(t, i, jp1, k) &&
+ install_tswitch(t, i, j, k,
+ tfind_2d_perpendicular(t->sw[ip1][jp1][k],
+ t->sw[i][jp1][k],
+ t->sw[i][jp2][k]))) {
+ return true;
+ }
+ log_no_perp(t, 0x303, i, j, k, i, jp1, k);
+
+ if (safe_y_perpendicular(t, ip1, jp1, k) &&
+ install_tswitch(t, ip1, j, k,
+ tfind_2d_perpendicular(t->sw[i][jp1][k],
+ t->sw[ip1][jp1][k],
+ t->sw[ip1][jp2][k]))) {
+ return true;
+ }
+ log_no_perp(t, 0x303, i, j, k, ip1, jp1, k);
+ return false;
+}
+
+static
+bool handle_case_0x503(struct torus *t, int i, int j, int k)
+{
+ int ip1 = canonicalize(i + 1, t->x_sz);
+ int kp1 = canonicalize(k + 1, t->z_sz);
+ int kp2 = canonicalize(k + 2, t->z_sz);
+
+ if (safe_z_perpendicular(t, i, j, kp1) &&
+ install_tswitch(t, i, j, k,
+ tfind_2d_perpendicular(t->sw[ip1][j][kp1],
+ t->sw[i][j][kp1],
+ t->sw[i][j][kp2]))) {
+ return true;
+ }
+ log_no_perp(t, 0x503, i, j, k, i, j, kp1);
+
+ if (safe_z_perpendicular(t, ip1, j, kp1) &&
+ install_tswitch(t, ip1, j, k,
+ tfind_2d_perpendicular(t->sw[i][j][kp1],
+ t->sw[ip1][j][kp1],
+ t->sw[ip1][j][kp2]))) {
+ return true;
+ }
+ log_no_perp(t, 0x503, i, j, k, ip1, j, kp1);
+ return false;
+}
+
+static
+bool handle_case_0x605(struct torus *t, int i, int j, int k)
+{
+ int jp1 = canonicalize(j + 1, t->y_sz);
+ int kp1 = canonicalize(k + 1, t->z_sz);
+ int kp2 = canonicalize(k + 2, t->z_sz);
+
+ if (safe_z_perpendicular(t, i, j, kp1) &&
+ install_tswitch(t, i, j, k,
+ tfind_2d_perpendicular(t->sw[i][jp1][kp1],
+ t->sw[i][j][kp1],
+ t->sw[i][j][kp2]))) {
+ return true;
+ }
+ log_no_perp(t, 0x605, i, j, k, i, j, kp1);
+
+ if (safe_z_perpendicular(t, i, jp1, kp1) &&
+ install_tswitch(t, i, jp1, k,
+ tfind_2d_perpendicular(t->sw[i][j][kp1],
+ t->sw[i][jp1][kp1],
+ t->sw[i][jp1][kp2]))) {
+ return true;
+ }
+ log_no_perp(t, 0x605, i, j, k, i, jp1, kp1);
+ return false;
+}
+
+/*
+ * 2D case 0x30a
+ * b0: t->sw[i ][j ][0 ]
+ * b1:
+ * b2: t->sw[i ][j+1][0 ]
+ * b3:
+ * O O
+ * 2D case 0x522 .
+ * b0: t->sw[i ][0 ][k ] .
+ * b1: .
+ * b4: t->sw[i ][0 ][k+1] .
+ * b5: .
+ * @ O
+ * 2D case 0x644
+ * b0: t->sw[0 ][j ][k ]
+ * b2:
+ * b4: t->sw[0 ][j ][k+1]
+ * b6:
+ */
+static
+bool handle_case_0x30a(struct torus *t, int i, int j, int k)
+{
+ int im1 = canonicalize(i - 1, t->x_sz);
+ int ip1 = canonicalize(i + 1, t->x_sz);
+ int jp1 = canonicalize(j + 1, t->y_sz);
+
+ if (safe_x_perpendicular(t, i, j, k) &&
+ install_tswitch(t, ip1, j, k,
+ tfind_2d_perpendicular(t->sw[i][jp1][k],
+ t->sw[i][j][k],
+ t->sw[im1][j][k]))) {
+ return true;
+ }
+ log_no_perp(t, 0x30a, i, j, k, i, j, k);
+
+ if (safe_x_perpendicular(t, i, jp1, k) &&
+ install_tswitch(t, ip1, jp1, k,
+ tfind_2d_perpendicular(t->sw[i][j][k],
+ t->sw[i][jp1][k],
+ t->sw[im1][jp1][k]))) {
+ return true;
+ }
+ log_no_perp(t, 0x30a, i, j, k, i, jp1, k);
+ return false;
+}
+
+static
+bool handle_case_0x522(struct torus *t, int i, int j, int k)
+{
+ int im1 = canonicalize(i - 1, t->x_sz);
+ int ip1 = canonicalize(i + 1, t->x_sz);
+ int kp1 = canonicalize(k + 1, t->z_sz);
+
+ if (safe_x_perpendicular(t, i, j, k) &&
+ install_tswitch(t, ip1, j, k,
+ tfind_2d_perpendicular(t->sw[i][j][kp1],
+ t->sw[i][j][k],
+ t->sw[im1][j][k]))) {
+ return true;
+ }
+ log_no_perp(t, 0x522, i, j, k, i, j, k);
+
+ if (safe_x_perpendicular(t, i, j, kp1) &&
+ install_tswitch(t, ip1, j, kp1,
+ tfind_2d_perpendicular(t->sw[i][j][k],
+ t->sw[i][j][kp1],
+ t->sw[im1][j][kp1]))) {
+ return true;
+ }
+ log_no_perp(t, 0x522, i, j, k, i, j, kp1);
+ return false;
+}
+
+static
+bool handle_case_0x644(struct torus *t, int i, int j, int k)
+{
+ int jm1 = canonicalize(j - 1, t->y_sz);
+ int jp1 = canonicalize(j + 1, t->y_sz);
+ int kp1 = canonicalize(k + 1, t->z_sz);
+
+ if (safe_y_perpendicular(t, i, j, k) &&
+ install_tswitch(t, i, jp1, k,
+ tfind_2d_perpendicular(t->sw[i][j][kp1],
+ t->sw[i][j][k],
+ t->sw[i][jm1][k]))) {
+ return true;
+ }
+ log_no_perp(t, 0x644, i, j, k, i, j, k);
+
+ if (safe_y_perpendicular(t, i, j, kp1) &&
+ install_tswitch(t, i, jp1, kp1,
+ tfind_2d_perpendicular(t->sw[i][j][k],
+ t->sw[i][j][kp1],
+ t->sw[i][jm1][kp1]))) {
+ return true;
+ }
+ log_no_perp(t, 0x644, i, j, k, i, j, kp1);
+ return false;
+}
+
+/*
+ * Handle the 2D cases where two existing edges meet at a corner.
+ *
+ */
+
+/*
+ * 2D case 0x301
+ * b0:
+ * b1: t->sw[i+1][j ][0 ]
+ * b2: t->sw[i ][j+1][0 ]
+ * b3: t->sw[i+1][j+1][0 ]
+ * O . . . . . O
+ * 2D case 0x501 .
+ * b0: .
+ * b1: t->sw[i+1][0 ][k ] .
+ * b4: t->sw[i ][0 ][k+1] .
+ * b5: t->sw[i+1][0 ][k+1] .
+ * @ O
+ * 2D case 0x601
+ * b0:
+ * b2: t->sw[0 ][j+1][k ]
+ * b4: t->sw[0 ][j ][k+1]
+ * b6: t->sw[0 ][j+1][k+1]
+ */
+static
+bool handle_case_0x301(struct torus *t, int i, int j, int k)
+{
+ int ip1 = canonicalize(i + 1, t->x_sz);
+ int jp1 = canonicalize(j + 1, t->y_sz);
+
+ if (install_tswitch(t, i, j, k,
+ tfind_face_corner(t->sw[ip1][j][k],
+ t->sw[ip1][jp1][k],
+ t->sw[i][jp1][k]))) {
+ return true;
+ }
+ log_no_crnr(t, 0x301, i, j, k, i, j, k);
+ return false;
+}
+
+static
+bool handle_case_0x501(struct torus *t, int i, int j, int k)
+{
+ int ip1 = canonicalize(i + 1, t->x_sz);
+ int kp1 = canonicalize(k + 1, t->z_sz);
+
+ if (install_tswitch(t, i, j, k,
+ tfind_face_corner(t->sw[ip1][j][k],
+ t->sw[ip1][j][kp1],
+ t->sw[i][j][kp1]))) {
+ return true;
+ }
+ log_no_crnr(t, 0x501, i, j, k, i, j, k);
+ return false;
+}
+
+static
+bool handle_case_0x601(struct torus *t, int i, int j, int k)
+{
+ int jp1 = canonicalize(j + 1, t->y_sz);
+ int kp1 = canonicalize(k + 1, t->z_sz);
+
+ if (install_tswitch(t, i, j, k,
+ tfind_face_corner(t->sw[i][jp1][k],
+ t->sw[i][jp1][kp1],
+ t->sw[i][j][kp1]))) {
+ return true;
+ }
+ log_no_crnr(t, 0x601, i, j, k, i, j, k);
+ return false;
+}
+
+/*
+ * 2D case 0x302
+ * b0: t->sw[i ][j ][0 ]
+ * b1:
+ * b2: t->sw[i ][j+1][0 ]
+ * b3: t->sw[i+1][j+1][0 ]
+ * O . . . . . O
+ * 2D case 0x502 .
+ * b0: t->sw[i ][0 ][k ] .
+ * b1: .
+ * b4: t->sw[i ][0 ][k+1] .
+ * b5: t->sw[i+1][0 ][k+1] .
+ * @ O
+ * 2D case 0x604
+ * b0: t->sw[0 ][j ][k ]
+ * b2:
+ * b4: t->sw[0 ][j ][k+1]
+ * b6: t->sw[0 ][j+1][k+1]
+ */
+static
+bool handle_case_0x302(struct torus *t, int i, int j, int k)
+{
+ int ip1 = canonicalize(i + 1, t->x_sz);
+ int jp1 = canonicalize(j + 1, t->y_sz);
+
+ if (install_tswitch(t, ip1, j, k,
+ tfind_face_corner(t->sw[i][j][k],
+ t->sw[i][jp1][k],
+ t->sw[ip1][jp1][k]))) {
+ return true;
+ }
+ log_no_crnr(t, 0x302, i, j, k, ip1, j, k);
+ return false;
+}
+
+static
+bool handle_case_0x502(struct torus *t, int i, int j, int k)
+{
+ int ip1 = canonicalize(i + 1, t->x_sz);
+ int kp1 = canonicalize(k + 1, t->z_sz);
+
+ if (install_tswitch(t, ip1, j, k,
+ tfind_face_corner(t->sw[i][j][k],
+ t->sw[i][j][kp1],
+ t->sw[ip1][j][kp1]))) {
+ return true;
+ }
+ log_no_crnr(t, 0x502, i, j, k, ip1, j, k);
+ return false;
+}
+
+static
+bool handle_case_0x604(struct torus *t, int i, int j, int k)
+{
+ int jp1 = canonicalize(j + 1, t->y_sz);
+ int kp1 = canonicalize(k + 1, t->z_sz);
+
+ if (install_tswitch(t, i, jp1, k,
+ tfind_face_corner(t->sw[i][j][k],
+ t->sw[i][j][kp1],
+ t->sw[i][jp1][kp1]))) {
+ return true;
+ }
+ log_no_crnr(t, 0x604, i, j, k, i, jp1, k);
+ return false;
+}
+
+
+/*
+ * 2D case 0x308
+ * b0: t->sw[i ][j ][0 ]
+ * b1: t->sw[i+1][j ][0 ]
+ * b2: t->sw[i ][j+1][0 ]
+ * b3:
+ * O O
+ * 2D case 0x520 .
+ * b0: t->sw[i ][0 ][k ] .
+ * b1: t->sw[i+1][0 ][k ] .
+ * b4: t->sw[i ][0 ][k+1] .
+ * b5: .
+ * @ . . . . . O
+ * 2D case 0x640
+ * b0: t->sw[0 ][j ][k ]
+ * b2: t->sw[0 ][j+1][k ]
+ * b4: t->sw[0 ][j ][k+1]
+ * b6:
+ */
+static
+bool handle_case_0x308(struct torus *t, int i, int j, int k)
+{
+ int ip1 = canonicalize(i + 1, t->x_sz);
+ int jp1 = canonicalize(j + 1, t->y_sz);
+
+ if (install_tswitch(t, ip1, jp1, k,
+ tfind_face_corner(t->sw[ip1][j][k],
+ t->sw[i][j][k],
+ t->sw[i][jp1][k]))) {
+ return true;
+ }
+ log_no_crnr(t, 0x308, i, j, k, ip1, jp1, k);
+ return false;
+}
+
+static
+bool handle_case_0x520(struct torus *t, int i, int j, int k)
+{
+ int ip1 = canonicalize(i + 1, t->x_sz);
+ int kp1 = canonicalize(k + 1, t->z_sz);
+
+ if (install_tswitch(t, ip1, j, kp1,
+ tfind_face_corner(t->sw[ip1][j][k],
+ t->sw[i][j][k],
+ t->sw[i][j][kp1]))) {
+ return true;
+ }
+ log_no_crnr(t, 0x520, i, j, k, ip1, j, kp1);
+ return false;
+}
+
+static
+bool handle_case_0x640(struct torus *t, int i, int j, int k)
+{
+ int jp1 = canonicalize(j + 1, t->y_sz);
+ int kp1 = canonicalize(k + 1, t->z_sz);
+
+ if (install_tswitch(t, i, jp1, kp1,
+ tfind_face_corner(t->sw[i][jp1][k],
+ t->sw[i][j][k],
+ t->sw[i][j][kp1]))) {
+ return true;
+ }
+ log_no_crnr(t, 0x640, i, j, k, i, jp1, kp1);
+ return false;
+}
+
+/*
+ * 2D case 0x304
+ * b0: t->sw[i ][j ][0 ]
+ * b1: t->sw[i+1][j ][0 ]
+ * b2:
+ * b3: t->sw[i+1][j+1][0 ]
+ * O O
+ * 2D case 0x510 .
+ * b0: t->sw[i ][0 ][k ] .
+ * b1: t->sw[i+1][0 ][k ] .
+ * b4: .
+ * b5: t->sw[i+1][0 ][k+1] .
+ * @ . . . . . O
+ * 2D case 0x610
+ * b0: t->sw[0 ][j ][k ]
+ * b2: t->sw[0 ][j+1][k ]
+ * b4:
+ * b6: t->sw[0 ][j+1][k+1]
+ */
+static
+bool handle_case_0x304(struct torus *t, int i, int j, int k)
+{
+ int ip1 = canonicalize(i + 1, t->x_sz);
+ int jp1 = canonicalize(j + 1, t->y_sz);
+
+ if (install_tswitch(t, i, jp1, k,
+ tfind_face_corner(t->sw[i][j][k],
+ t->sw[ip1][j][k],
+ t->sw[ip1][jp1][k]))) {
+ return true;
+ }
+ log_no_crnr(t, 0x304, i, j, k, i, jp1, k);
+ return false;
+}
+
+static
+bool handle_case_0x510(struct torus *t, int i, int j, int k)
+{
+ int ip1 = canonicalize(i + 1, t->x_sz);
+ int kp1 = canonicalize(k + 1, t->z_sz);
+
+ if (install_tswitch(t, i, j, kp1,
+ tfind_face_corner(t->sw[i][j][k],
+ t->sw[ip1][j][k],
+ t->sw[ip1][j][kp1]))) {
+ return true;
+ }
+ log_no_crnr(t, 0x510, i, j, k, i, j, kp1);
+ return false;
+}
+
+static
+bool handle_case_0x610(struct torus *t, int i, int j, int k)
+{
+ int jp1 = canonicalize(j + 1, t->y_sz);
+ int kp1 = canonicalize(k + 1, t->z_sz);
+
+ if (install_tswitch(t, i, j, kp1,
+ tfind_face_corner(t->sw[i][j][k],
+ t->sw[i][jp1][k],
+ t->sw[i][jp1][kp1]))) {
+ return true;
+ }
+ log_no_crnr(t, 0x610, i, j, k, i, j, kp1);
+ return false;
+}
+
+/*
+ * Handle the 3D cases where two existing edges meet at a corner.
+ *
+ */
+
+/*
+ * 3D case 0x71f: O
+ * . .
+ * b0: . .
+ * b1: . .
+ * b2: . .
+ * b3: O O
+ * b4: O
+ * b5: t->sw[i+1][j ][k+1]
+ * b6: t->sw[i ][j+1][k+1]
+ * b7: t->sw[i+1][j+1][k+1]
+ * O
+ * O O
+ *
+ *
+ *
+ *
+ * @
+ */
+static
+bool handle_case_0x71f(struct torus *t, int i, int j, int k)
+{
+ int ip1 = canonicalize(i + 1, t->x_sz);
+ int jp1 = canonicalize(j + 1, t->y_sz);
+ int kp1 = canonicalize(k + 1, t->z_sz);
+ int kp2 = canonicalize(k + 2, t->z_sz);
+
+ if (safe_z_perpendicular(t, ip1, jp1, kp1) &&
+ install_tswitch(t, ip1, jp1, k,
+ tfind_3d_perpendicular(t->sw[ip1][j][kp1],
+ t->sw[ip1][jp1][kp1],
+ t->sw[i][jp1][kp1],
+ t->sw[ip1][jp1][kp2]))) {
+ return true;
+ }
+ log_no_perp(t, 0x71f, i, j, k, ip1, jp1, kp1);
+ return false;
+}
+
+/*
+ * 3D case 0x72f: O
+ * .
+ * b0: .
+ * b1: .
+ * b2: .
+ * b3: O O
+ * b4: t->sw[i ][j ][k+1] . O
+ * b5: .
+ * b6: t->sw[i ][j+1][k+1] .
+ * b7: t->sw[i+1][j+1][k+1] .
+ * O
+ * O O
+ *
+ *
+ *
+ *
+ * @
+ */
+static
+bool handle_case_0x72f(struct torus *t, int i, int j, int k)
+{
+ int ip1 = canonicalize(i + 1, t->x_sz);
+ int jp1 = canonicalize(j + 1, t->y_sz);
+ int kp1 = canonicalize(k + 1, t->z_sz);
+ int kp2 = canonicalize(k + 2, t->z_sz);
+
+ if (safe_z_perpendicular(t, i, jp1, kp1) &&
+ install_tswitch(t, i, jp1, k,
+ tfind_3d_perpendicular(t->sw[i][j][kp1],
+ t->sw[i][jp1][kp1],
+ t->sw[ip1][jp1][kp1],
+ t->sw[i][jp1][kp2]))) {
+ return true;
+ }
+ log_no_perp(t, 0x72f, i, j, k, i, jp1, kp1);
+ return false;
+}
+
+/*
+ * 3D case 0x737: O
+ * . .
+ * b0: . .
+ * b1: . .
+ * b2: . .
+ * b3: t->sw[i+1][j+1][k ] O . O
+ * b4: O
+ * b5:
+ * b6: t->sw[i ][j+1][k+1]
+ * b7: t->sw[i+1][j+1][k+1]
+ * O
+ * O O
+ *
+ *
+ *
+ *
+ * @
+ */
+static
+bool handle_case_0x737(struct torus *t, int i, int j, int k)
+{
+ int ip1 = canonicalize(i + 1, t->x_sz);
+ int jp1 = canonicalize(j + 1, t->y_sz);
+ int jp2 = canonicalize(j + 2, t->y_sz);
+ int kp1 = canonicalize(k + 1, t->z_sz);
+
+ if (safe_y_perpendicular(t, ip1, jp1, kp1) &&
+ install_tswitch(t, ip1, j, kp1,
+ tfind_3d_perpendicular(t->sw[i][jp1][kp1],
+ t->sw[ip1][jp1][kp1],
+ t->sw[ip1][jp1][k],
+ t->sw[ip1][jp2][kp1]))) {
+ return true;
+ }
+ log_no_perp(t, 0x737, i, j, k, ip1, jp1, kp1);
+ return false;
+}
+
+/*
+ * 3D case 0x73b: O
+ * .
+ * b0: .
+ * b1: .
+ * b2: t->sw[i ][j+1][k ] .
+ * b3: O O
+ * b4: . O
+ * b5: .
+ * b6: t->sw[i ][j+1][k+1] .
+ * b7: t->sw[i+1][j+1][k+1] .
+ * . O
+ * O O
+ *
+ *
+ *
+ *
+ * @
+ */
+static
+bool handle_case_0x73b(struct torus *t, int i, int j, int k)
+{
+ int ip1 = canonicalize(i + 1, t->x_sz);
+ int jp1 = canonicalize(j + 1, t->y_sz);
+ int jp2 = canonicalize(j + 2, t->y_sz);
+ int kp1 = canonicalize(k + 1, t->z_sz);
+
+ if (safe_y_perpendicular(t, i, jp1, kp1) &&
+ install_tswitch(t, i, j, kp1,
+ tfind_3d_perpendicular(t->sw[i][jp1][k],
+ t->sw[i][jp1][kp1],
+ t->sw[ip1][jp1][kp1],
+ t->sw[i][jp2][kp1]))) {
+ return true;
+ }
+ log_no_perp(t, 0x73b, i, j, k, i, jp1, kp1);
+ return false;
+}
+
+/*
+ * 3D case 0x74f: O
+ * .
+ * b0: .
+ * b1: .
+ * b2: .
+ * b3: O O
+ * b4: t->sw[i ][j ][k+1] O .
+ * b5: t->sw[i+1][j ][k+1] .
+ * b6: .
+ * b7: t->sw[i+1][j+1][k+1] .
+ * O
+ * O O
+ *
+ *
+ *
+ *
+ * @
+ */
+static
+bool handle_case_0x74f(struct torus *t, int i, int j, int k)
+{
+ int ip1 = canonicalize(i + 1, t->x_sz);
+ int jp1 = canonicalize(j + 1, t->y_sz);
+ int kp1 = canonicalize(k + 1, t->z_sz);
+ int kp2 = canonicalize(k + 2, t->z_sz);
+
+ if (safe_z_perpendicular(t, ip1, j, kp1) &&
+ install_tswitch(t, ip1, j, k,
+ tfind_3d_perpendicular(t->sw[i][j][kp1],
+ t->sw[ip1][j][kp1],
+ t->sw[ip1][jp1][kp1],
+ t->sw[ip1][j][kp2]))) {
+ return true;
+ }
+ log_no_perp(t, 0x74f, i, j, k, ip1, j, kp1);
+ return false;
+}
+
+/*
+ * 3D case 0x757: O
+ * . .
+ * b0: . .
+ * b1: . .
+ * b2: . .
+ * b3: t->sw[i+1][j+1][k ] O . O
+ * b4: O
+ * b5: t->sw[i+1][j ][k+1]
+ * b6:
+ * b7: t->sw[i+1][j+1][k+1]
+ * O
+ * O O
+ *
+ *
+ *
+ *
+ * @
+ */
+static
+bool handle_case_0x757(struct torus *t, int i, int j, int k)
+{
+ int ip1 = canonicalize(i + 1, t->x_sz);
+ int ip2 = canonicalize(i + 2, t->x_sz);
+ int jp1 = canonicalize(j + 1, t->y_sz);
+ int kp1 = canonicalize(k + 1, t->z_sz);
+
+ if (safe_x_perpendicular(t, ip1, jp1, kp1) &&
+ install_tswitch(t, i, jp1, kp1,
+ tfind_3d_perpendicular(t->sw[ip1][j][kp1],
+ t->sw[ip1][jp1][kp1],
+ t->sw[ip1][jp1][k],
+ t->sw[ip2][jp1][kp1]))) {
+ return true;
+ }
+ log_no_perp(t, 0x757, i, j, k, ip1, jp1, kp1);
+ return false;
+}
+
+/*
+ * 3D case 0x75d: O
+ * .
+ * b0: .
+ * b1: t->sw[i+1][j ][k ] .
+ * b2: .
+ * b3: O O
+ * b4: O .
+ * b5: t->sw[i+1][j ][k+1] .
+ * b6: .
+ * b7: t->sw[i+1][j+1][k+1] .
+ * O .
+ * O O
+ *
+ *
+ *
+ *
+ * @
+ */
+static
+bool handle_case_0x75d(struct torus *t, int i, int j, int k)
+{
+ int ip1 = canonicalize(i + 1, t->x_sz);
+ int ip2 = canonicalize(i + 2, t->x_sz);
+ int jp1 = canonicalize(j + 1, t->y_sz);
+ int kp1 = canonicalize(k + 1, t->z_sz);
+
+ if (safe_x_perpendicular(t, ip1, j, kp1) &&
+ install_tswitch(t, i, j, kp1,
+ tfind_3d_perpendicular(t->sw[ip1][j][k],
+ t->sw[ip1][j][kp1],
+ t->sw[ip1][jp1][kp1],
+ t->sw[ip2][j][kp1]))) {
+ return true;
+ }
+ log_no_perp(t, 0x75d, i, j, k, ip1, j, kp1);
+ return false;
+}
+
+/*
+ * 3D case 0x773: O
+ * .
+ * b0: .
+ * b1: .
+ * b2: t->sw[i ][j+1][k ] .
+ * b3: t->sw[i+1][j+1][k ] O . O
+ * b4: O
+ * b5: .
+ * b6: .
+ * b7: t->sw[i+1][j+1][k+1] .
+ * . O
+ * O O
+ *
+ *
+ *
+ *
+ * @
+ */
+static
+bool handle_case_0x773(struct torus *t, int i, int j, int k)
+{
+ int ip1 = canonicalize(i + 1, t->x_sz);
+ int jp1 = canonicalize(j + 1, t->y_sz);
+ int jp2 = canonicalize(j + 2, t->y_sz);
+ int kp1 = canonicalize(k + 1, t->z_sz);
+
+ if (safe_y_perpendicular(t, ip1, jp1, k) &&
+ install_tswitch(t, ip1, j, k,
+ tfind_3d_perpendicular(t->sw[i][jp1][k],
+ t->sw[ip1][jp1][k],
+ t->sw[ip1][jp1][kp1],
+ t->sw[ip1][jp2][k]))) {
+ return true;
+ }
+ log_no_perp(t, 0x773, i, j, k, ip1, jp1, k);
+ return false;
+}
+
+/*
+ * 3D case 0x775: O
+ * .
+ * b0: .
+ * b1: t->sw[i+1][j ][k ] .
+ * b2: .
+ * b3: t->sw[i+1][j+1][k ] O . O
+ * b4: O
+ * b5: .
+ * b6: .
+ * b7: t->sw[i+1][j+1][k+1] .
+ * O .
+ * O O
+ *
+ *
+ *
+ *
+ * @
+ */
+static
+bool handle_case_0x775(struct torus *t, int i, int j, int k)
+{
+ int ip1 = canonicalize(i + 1, t->x_sz);
+ int ip2 = canonicalize(i + 2, t->x_sz);
+ int jp1 = canonicalize(j + 1, t->y_sz);
+ int kp1 = canonicalize(k + 1, t->z_sz);
+
+ if (safe_x_perpendicular(t, ip1, jp1, k) &&
+ install_tswitch(t, i, jp1, k,
+ tfind_3d_perpendicular(t->sw[ip1][j][k],
+ t->sw[ip1][jp1][k],
+ t->sw[ip1][jp1][kp1],
+ t->sw[ip2][jp1][k]))) {
+ return true;
+ }
+ log_no_perp(t, 0x775, i, j, k, ip1, jp1, k);
+ return false;
+}
+
+/*
+ * 3D case 0x78f: O
+ *
+ * b0:
+ * b1:
+ * b2:
+ * b3: O O
+ * b4: t->sw[i ][j ][k+1] . O .
+ * b5: t->sw[i+1][j ][k+1] . .
+ * b6: t->sw[i ][j+1][k+1] . .
+ * b7: . .
+ * O
+ * O O
+ *
+ *
+ *
+ *
+ * @
+ */
+static
+bool handle_case_0x78f(struct torus *t, int i, int j, int k)
+{
+ int ip1 = canonicalize(i + 1, t->x_sz);
+ int jp1 = canonicalize(j + 1, t->y_sz);
+ int kp1 = canonicalize(k + 1, t->z_sz);
+ int kp2 = canonicalize(k + 2, t->z_sz);
+
+ if (safe_z_perpendicular(t, i, j, kp1) &&
+ install_tswitch(t, i, j, k,
+ tfind_3d_perpendicular(t->sw[ip1][j][kp1],
+ t->sw[i][j][kp1],
+ t->sw[i][jp1][kp1],
+ t->sw[i][j][kp2]))) {
+ return true;
+ }
+ log_no_perp(t, 0x78f, i, j, k, i, j, kp1);
+ return false;
+}
+
+/*
+ * 3D case 0x7ab: O
+ *
+ * b0:
+ * b1:
+ * b2: t->sw[i ][j+1][k ]
+ * b3: O O
+ * b4: t->sw[i ][j ][k+1] . . O
+ * b5: . .
+ * b6: t->sw[i ][j+1][k+1] . .
+ * b7: . .
+ * . O
+ * O O
+ *
+ *
+ *
+ *
+ * @
+ */
+static
+bool handle_case_0x7ab(struct torus *t, int i, int j, int k)
+{
+ int im1 = canonicalize(i - 1, t->x_sz);
+ int ip1 = canonicalize(i + 1, t->x_sz);
+ int jp1 = canonicalize(j + 1, t->y_sz);
+ int kp1 = canonicalize(k + 1, t->z_sz);
+
+ if (safe_x_perpendicular(t, i, jp1, kp1) &&
+ install_tswitch(t, ip1, jp1, kp1,
+ tfind_3d_perpendicular(t->sw[i][j][kp1],
+ t->sw[i][jp1][kp1],
+ t->sw[i][jp1][k],
+ t->sw[im1][jp1][kp1]))) {
+ return true;
+ }
+ log_no_perp(t, 0x7ab, i, j, k, i, jp1, kp1);
+ return false;
+}
+
+/*
+ * 3D case 0x7ae: O
+ *
+ * b0: t->sw[i ][j ][k ]
+ * b1:
+ * b2:
+ * b3: O O
+ * b4: t->sw[i ][j ][k+1] . O
+ * b5: .
+ * b6: t->sw[i ][j+1][k+1] .
+ * b7: .
+ * O
+ * O . O
+ * .
+ * .
+ * .
+ * .
+ * @
+ */
+static
+bool handle_case_0x7ae(struct torus *t, int i, int j, int k)
+{
+ int im1 = canonicalize(i - 1, t->x_sz);
+ int ip1 = canonicalize(i + 1, t->x_sz);
+ int jp1 = canonicalize(j + 1, t->y_sz);
+ int kp1 = canonicalize(k + 1, t->z_sz);
+
+ if (safe_x_perpendicular(t, i, j, kp1) &&
+ install_tswitch(t, ip1, j, kp1,
+ tfind_3d_perpendicular(t->sw[i][j][k],
+ t->sw[i][j][kp1],
+ t->sw[i][jp1][kp1],
+ t->sw[im1][j][kp1]))) {
+ return true;
+ }
+ log_no_perp(t, 0x7ae, i, j, k, i, j, kp1);
+ return false;
+}
+
+/*
+ * 3D case 0x7b3: O
+ *
+ * b0:
+ * b1:
+ * b2: t->sw[i ][j+1][k ]
+ * b3: t->sw[i+1][j+1][k ] O O
+ * b4: . O
+ * b5: . .
+ * b6: t->sw[i ][j+1][k+1] . .
+ * b7: . .
+ * . . O
+ * O O
+ *
+ *
+ *
+ *
+ * @
+ */
+static
+bool handle_case_0x7b3(struct torus *t, int i, int j, int k)
+{
+ int ip1 = canonicalize(i + 1, t->x_sz);
+ int jp1 = canonicalize(j + 1, t->y_sz);
+ int jp2 = canonicalize(j + 2, t->y_sz);
+ int kp1 = canonicalize(k + 1, t->z_sz);
+
+ if (safe_y_perpendicular(t, i, jp1, k) &&
+ install_tswitch(t, i, j, k,
+ tfind_3d_perpendicular(t->sw[i][jp1][kp1],
+ t->sw[i][jp1][k],
+ t->sw[ip1][jp1][k],
+ t->sw[i][jp2][k]))) {
+ return true;
+ }
+ log_no_perp(t, 0x7b3, i, j, k, i, jp1, k);
+ return false;
+}
+
+/*
+ * 3D case 0x7ba: O
+ *
+ * b0: t->sw[i ][j ][k ]
+ * b1:
+ * b2: t->sw[i ][j+1][k ]
+ * b3: O O
+ * b4: . O
+ * b5: .
+ * b6: t->sw[i ][j+1][k+1] .
+ * b7: .
+ * . O
+ * O O
+ * .
+ * .
+ * .
+ * .
+ * @
+ */
+static
+bool handle_case_0x7ba(struct torus *t, int i, int j, int k)
+{
+ int im1 = canonicalize(i - 1, t->x_sz);
+ int ip1 = canonicalize(i + 1, t->x_sz);
+ int jp1 = canonicalize(j + 1, t->y_sz);
+ int kp1 = canonicalize(k + 1, t->z_sz);
+
+ if (safe_x_perpendicular(t, i, jp1, k) &&
+ install_tswitch(t, ip1, jp1, k,
+ tfind_3d_perpendicular(t->sw[i][j][k],
+ t->sw[i][jp1][k],
+ t->sw[i][jp1][kp1],
+ t->sw[im1][jp1][k]))) {
+ return true;
+ }
+ log_no_perp(t, 0x7ba, i, j, k, i, jp1, k);
+ return false;
+}
+
+/*
+ * 3D case 0x7cd: O
+ *
+ * b0:
+ * b1: t->sw[i+1][j ][k ]
+ * b2:
+ * b3: O O
+ * b4: t->sw[i ][j ][k+1] O . .
+ * b5: t->sw[i+1][j ][k+1] . .
+ * b6: . .
+ * b7: . .
+ * O .
+ * O O
+ *
+ *
+ *
+ *
+ * @
+ */
+static
+bool handle_case_0x7cd(struct torus *t, int i, int j, int k)
+{
+ int ip1 = canonicalize(i + 1, t->x_sz);
+ int jp1 = canonicalize(j + 1, t->y_sz);
+ int jm1 = canonicalize(j - 1, t->y_sz);
+ int kp1 = canonicalize(k + 1, t->z_sz);
+
+ if (safe_y_perpendicular(t, ip1, j, kp1) &&
+ install_tswitch(t, ip1, jp1, kp1,
+ tfind_3d_perpendicular(t->sw[i][j][kp1],
+ t->sw[ip1][j][kp1],
+ t->sw[ip1][j][k],
+ t->sw[ip1][jm1][kp1]))) {
+ return true;
+ }
+ log_no_perp(t, 0x7cd, i, j, k, ip1, j, kp1);
+ return false;
+}
+
+/*
+ * 3D case 0x7ce: O
+ *
+ * b0: t->sw[i ][j ][k ]
+ * b1:
+ * b2:
+ * b3: O O
+ * b4: t->sw[i ][j ][k+1] O .
+ * b5: t->sw[i+1][j ][k+1] .
+ * b6: .
+ * b7: .
+ * O
+ * O . O
+ * .
+ * .
+ * .
+ * .
+ * @
+ */
+static
+bool handle_case_0x7ce(struct torus *t, int i, int j, int k)
+{
+ int ip1 = canonicalize(i + 1, t->x_sz);
+ int jp1 = canonicalize(j + 1, t->y_sz);
+ int jm1 = canonicalize(j - 1, t->y_sz);
+ int kp1 = canonicalize(k + 1, t->z_sz);
+
+ if (safe_y_perpendicular(t, i, j, kp1) &&
+ install_tswitch(t, i, jp1, kp1,
+ tfind_3d_perpendicular(t->sw[i][j][k],
+ t->sw[i][j][kp1],
+ t->sw[ip1][j][kp1],
+ t->sw[i][jm1][kp1]))) {
+ return true;
+ }
+ log_no_perp(t, 0x7ce, i, j, k, i, j, kp1);
+ return false;
+}
+
+/*
+ * 3D case 0x7d5: O
+ *
+ * b0:
+ * b1: t->sw[i+1][j ][k ]
+ * b2:
+ * b3: t->sw[i+1][j+1][k ] O O
+ * b4: O .
+ * b5: t->sw[i+1][j ][k+1] . .
+ * b6: . .
+ * b7: . .
+ * O . .
+ * O O
+ *
+ *
+ *
+ *
+ * @
+ */
+static
+bool handle_case_0x7d5(struct torus *t, int i, int j, int k)
+{
+ int ip1 = canonicalize(i + 1, t->x_sz);
+ int ip2 = canonicalize(i + 2, t->x_sz);
+ int jp1 = canonicalize(j + 1, t->y_sz);
+ int kp1 = canonicalize(k + 1, t->z_sz);
+
+ if (safe_x_perpendicular(t, ip1, j, k) &&
+ install_tswitch(t, i, j, k,
+ tfind_3d_perpendicular(t->sw[ip1][j][kp1],
+ t->sw[ip1][j][k],
+ t->sw[ip1][jp1][k],
+ t->sw[ip2][j][k]))) {
+ return true;
+ }
+ log_no_perp(t, 0x7d5, i, j, k, ip1, j, k);
+ return false;
+}
+
+/*
+ * 3D case 0x7dc: O
+ *
+ * b0: t->sw[i ][j ][k ]
+ * b1: t->sw[i+1][j ][k ]
+ * b2:
+ * b3: O O
+ * b4: O .
+ * b5: t->sw[i+1][j ][k+1] .
+ * b6: .
+ * b7: .
+ * O .
+ * O O
+ * .
+ * .
+ * .
+ * .
+ * @
+ */
+static
+bool handle_case_0x7dc(struct torus *t, int i, int j, int k)
+{
+ int ip1 = canonicalize(i + 1, t->x_sz);
+ int jp1 = canonicalize(j + 1, t->y_sz);
+ int jm1 = canonicalize(j - 1, t->y_sz);
+ int kp1 = canonicalize(k + 1, t->z_sz);
+
+ if (safe_y_perpendicular(t, ip1, j, k) &&
+ install_tswitch(t, ip1, jp1, k,
+ tfind_3d_perpendicular(t->sw[i][j][k],
+ t->sw[ip1][j][k],
+ t->sw[ip1][j][kp1],
+ t->sw[ip1][jm1][k]))) {
+ return true;
+ }
+ log_no_perp(t, 0x7dc, i, j, k, ip1, j, k);
+ return false;
+}
+
+/*
+ * 3D case 0x7ea: O
+ *
+ * b0: t->sw[i ][j ][k ]
+ * b1:
+ * b2: t->sw[i ][j+1][k ]
+ * b3: O O
+ * b4: t->sw[i ][j ][k+1] O
+ * b5:
+ * b6:
+ * b7:
+ * O
+ * O . O
+ * . .
+ * . .
+ * . .
+ * . .
+ * @
+ */
+static
+bool handle_case_0x7ea(struct torus *t, int i, int j, int k)
+{
+ int im1 = canonicalize(i - 1, t->x_sz);
+ int ip1 = canonicalize(i + 1, t->x_sz);
+ int jp1 = canonicalize(j + 1, t->y_sz);
+ int kp1 = canonicalize(k + 1, t->z_sz);
+
+ if (safe_x_perpendicular(t, i, j, k) &&
+ install_tswitch(t, ip1, j, k,
+ tfind_3d_perpendicular(t->sw[i][j][kp1],
+ t->sw[i][j][k],
+ t->sw[i][jp1][k],
+ t->sw[im1][j][k]))) {
+ return true;
+ }
+ log_no_perp(t, 0x7ea, i, j, k, i, j, k);
+ return false;
+}
+
+/*
+ * 3D case 0x7ec: O
+ *
+ * b0: t->sw[i ][j ][k ]
+ * b1: t->sw[i+1][j ][k ]
+ * b2:
+ * b3: O O
+ * b4: t->sw[i ][j ][k+1] O
+ * b5:
+ * b6:
+ * b7:
+ * O
+ * O . O
+ * . .
+ * . .
+ * . .
+ * . .
+ * @
+ */
+static
+bool handle_case_0x7ec(struct torus *t, int i, int j, int k)
+{
+ int ip1 = canonicalize(i + 1, t->x_sz);
+ int jp1 = canonicalize(j + 1, t->y_sz);
+ int jm1 = canonicalize(j - 1, t->y_sz);
+ int kp1 = canonicalize(k + 1, t->z_sz);
+
+ if (safe_y_perpendicular(t, i, j, k) &&
+ install_tswitch(t, i, jp1, k,
+ tfind_3d_perpendicular(t->sw[i][j][kp1],
+ t->sw[i][j][k],
+ t->sw[ip1][j][k],
+ t->sw[i][jm1][k]))) {
+ return true;
+ }
+ log_no_perp(t, 0x7ec, i, j, k, i, j, k);
+ return false;
+}
+
+/*
+ * 3D case 0x7f1: O
+ *
+ * b0:
+ * b1: t->sw[i+1][j ][k ]
+ * b2: t->sw[i ][j+1][k ]
+ * b3: t->sw[i+1][j+1][k ] O O
+ * b4: O
+ * b5: . .
+ * b6: . .
+ * b7: . .
+ * . O .
+ * O O
+ *
+ *
+ *
+ *
+ * @
+ */
+static
+bool handle_case_0x7f1(struct torus *t, int i, int j, int k)
+{
+ int ip1 = canonicalize(i + 1, t->x_sz);
+ int jp1 = canonicalize(j + 1, t->y_sz);
+ int km1 = canonicalize(k - 1, t->z_sz);
+ int kp1 = canonicalize(k + 1, t->z_sz);
+
+ if (safe_z_perpendicular(t, ip1, jp1, k) &&
+ install_tswitch(t, ip1, jp1, kp1,
+ tfind_3d_perpendicular(t->sw[ip1][j][k],
+ t->sw[ip1][jp1][k],
+ t->sw[i][jp1][k],
+ t->sw[ip1][jp1][km1]))) {
+ return true;
+ }
+ log_no_perp(t, 0x7f1, i, j, k, ip1, jp1, k);
+ return false;
+}
+
+/*
+ * 3D case 0x7f2: O
+ *
+ * b0: t->sw[i ][j ][k ]
+ * b1:
+ * b2: t->sw[i ][j+1][k ]
+ * b3: t->sw[i+1][j+1][k ] O O
+ * b4: O
+ * b5: .
+ * b6: .
+ * b7: .
+ * . O
+ * O O
+ * .
+ * .
+ * .
+ * .
+ * @
+ */
+static
+bool handle_case_0x7f2(struct torus *t, int i, int j, int k)
+{
+ int ip1 = canonicalize(i + 1, t->x_sz);
+ int jp1 = canonicalize(j + 1, t->y_sz);
+ int km1 = canonicalize(k - 1, t->z_sz);
+ int kp1 = canonicalize(k + 1, t->z_sz);
+
+ if (safe_z_perpendicular(t, i, jp1, k) &&
+ install_tswitch(t, i, jp1, kp1,
+ tfind_3d_perpendicular(t->sw[i][j][k],
+ t->sw[i][jp1][k],
+ t->sw[ip1][jp1][k],
+ t->sw[i][jp1][km1]))) {
+ return true;
+ }
+ log_no_perp(t, 0x7f2, i, j, k, i, jp1, k);
+ return false;
+}
+
+/*
+ * 3D case 0x7f4: O
+ *
+ * b0: t->sw[i ][j ][k ]
+ * b1: t->sw[i+1][j ][k ]
+ * b2:
+ * b3: t->sw[i+1][j+1][k ] O O
+ * b4: O
+ * b5: .
+ * b6: .
+ * b7: .
+ * O .
+ * O O
+ * .
+ * .
+ * .
+ * .
+ * @
+ */
+static
+bool handle_case_0x7f4(struct torus *t, int i, int j, int k)
+{
+ int ip1 = canonicalize(i + 1, t->x_sz);
+ int jp1 = canonicalize(j + 1, t->y_sz);
+ int km1 = canonicalize(k - 1, t->z_sz);
+ int kp1 = canonicalize(k + 1, t->z_sz);
+
+ if (safe_z_perpendicular(t, ip1, j, k) &&
+ install_tswitch(t, ip1, j, kp1,
+ tfind_3d_perpendicular(t->sw[i][j][k],
+ t->sw[ip1][j][k],
+ t->sw[ip1][jp1][k],
+ t->sw[ip1][j][km1]))) {
+ return true;
+ }
+ log_no_perp(t, 0x7f4, i, j, k, ip1, j, k);
+ return false;
+}
+
+/*
+ * 3D case 0x7f8: O
+ *
+ * b0: t->sw[i ][j ][k ]
+ * b1: t->sw[i+1][j ][k ]
+ * b2: t->sw[i ][j+1][k ]
+ * b3: O O
+ * b4: O
+ * b5:
+ * b6:
+ * b7:
+ * O
+ * O O
+ * . .
+ * . .
+ * . .
+ * . .
+ * @
+ */
+static
+bool handle_case_0x7f8(struct torus *t, int i, int j, int k)
+{
+ int ip1 = canonicalize(i + 1, t->x_sz);
+ int jp1 = canonicalize(j + 1, t->y_sz);
+ int km1 = canonicalize(k - 1, t->z_sz);
+ int kp1 = canonicalize(k + 1, t->z_sz);
+
+ if (safe_z_perpendicular(t, i, j, k) &&
+ install_tswitch(t, i, j, kp1,
+ tfind_3d_perpendicular(t->sw[ip1][j][k],
+ t->sw[i][j][k],
+ t->sw[i][jp1][k],
+ t->sw[i][j][km1]))) {
+ return true;
+ }
+ log_no_perp(t, 0x7f8, i, j, k, i, j, k);
+ return false;
+}
+
+/*
+ * Handle the cases where three existing edges meet at a corner.
+ */
+
+/*
+ * 3D case 0x717: O
+ * . . .
+ * b0: . . .
+ * b1: . . .
+ * b2: . . .
+ * b3: t->sw[i+1][j+1][k ] O . O
+ * b4: O
+ * b5: t->sw[i+1][j ][k+1]
+ * b6: t->sw[i ][j+1][k+1]
+ * b7: t->sw[i+1][j+1][k+1]
+ * O
+ * O O
+ *
+ *
+ *
+ *
+ * @
+ */
+static
+bool handle_case_0x717(struct torus *t, int i, int j, int k)
+{
+ int ip1 = canonicalize(i + 1, t->x_sz);
+ int jp1 = canonicalize(j + 1, t->y_sz);
+ int kp1 = canonicalize(k + 1, t->z_sz);
+
+ if (install_tswitch(t, i, j, kp1,
+ tfind_face_corner(t->sw[i][jp1][kp1],
+ t->sw[ip1][jp1][kp1],
+ t->sw[ip1][j][kp1]))) {
+ return true;
+ }
+ log_no_crnr(t, 0x717, i, j, k, i, j, kp1);
+
+ if (install_tswitch(t, ip1, j, k,
+ tfind_face_corner(t->sw[ip1][jp1][k],
+ t->sw[ip1][jp1][kp1],
+ t->sw[ip1][j][kp1]))) {
+ return true;
+ }
+ log_no_crnr(t, 0x717, i, j, k, ip1, j, k);
+
+ if (install_tswitch(t, i, jp1, k,
+ tfind_face_corner(t->sw[ip1][jp1][k],
+ t->sw[ip1][jp1][kp1],
+ t->sw[i][jp1][kp1]))) {
+ return true;
+ }
+ log_no_crnr(t, 0x717, i, j, k, i, jp1, k);
+ return false;
+}
+
+/*
+ * 3D case 0x72b: O
+ * .
+ * b0: .
+ * b1: .
+ * b2: t->sw[i ][j+1][k ] .
+ * b3: O O
+ * b4: t->sw[i ][j ][k+1] . . O
+ * b5: . .
+ * b6: t->sw[i ][j+1][k+1] . .
+ * b7: t->sw[i+1][j+1][k+1] . .
+ * . O
+ * O O
+ *
+ *
+ *
+ *
+ * @
+ */
+static
+bool handle_case_0x72b(struct torus *t, int i, int j, int k)
+{
+ int ip1 = canonicalize(i + 1, t->x_sz);
+ int jp1 = canonicalize(j + 1, t->y_sz);
+ int kp1 = canonicalize(k + 1, t->z_sz);
+
+ if (install_tswitch(t, ip1, j, kp1,
+ tfind_face_corner(t->sw[i][j][kp1],
+ t->sw[i][jp1][kp1],
+ t->sw[ip1][jp1][kp1]))) {
+ return true;
+ }
+ log_no_crnr(t, 0x72b, i, j, k, ip1, j, kp1);
+
+ if (install_tswitch(t, i, j, k,
+ tfind_face_corner(t->sw[i][jp1][k],
+ t->sw[i][jp1][kp1],
+ t->sw[i][j][kp1]))) {
+ return true;
+ }
+ log_no_crnr(t, 0x72b, i, j, k, i, j, k);
+
+ if (install_tswitch(t, ip1, jp1, k,
+ tfind_face_corner(t->sw[i][jp1][k],
+ t->sw[i][jp1][kp1],
+ t->sw[ip1][jp1][kp1]))) {
+ return true;
+ }
+ log_no_crnr(t, 0x72b, i, j, k, ip1, jp1, k);
+ return false;
+}
+
+/*
+ * 3D case 0x74d: O
+ * .
+ * b0: .
+ * b1: t->sw[i+1][j ][k ] .
+ * b2: .
+ * b3: O O
+ * b4: t->sw[i ][j ][k+1] O . .
+ * b5: t->sw[i+1][j ][k+1] . .
+ * b6: . .
+ * b7: t->sw[i+1][j+1][k+1] . .
+ * O .
+ * O O
+ *
+ *
+ *
+ *
+ * @
+ */
+static
+bool handle_case_0x74d(struct torus *t, int i, int j, int k)
+{
+ int ip1 = canonicalize(i + 1, t->x_sz);
+ int jp1 = canonicalize(j + 1, t->y_sz);
+ int kp1 = canonicalize(k + 1, t->z_sz);
+
+ if (install_tswitch(t, i, jp1, kp1,
+ tfind_face_corner(t->sw[i][j][kp1],
+ t->sw[ip1][j][kp1],
+ t->sw[ip1][jp1][kp1]))) {
+ return true;
+ }
+ log_no_crnr(t, 0x74d, i, j, k, i, jp1, kp1);
+
+ if (install_tswitch(t, i, j, k,
+ tfind_face_corner(t->sw[ip1][j][k],
+ t->sw[ip1][j][kp1],
+ t->sw[i][j][kp1]))) {
+ return true;
+ }
+ log_no_crnr(t, 0x74d, i, j, k, i, j, k);
+
+ if (install_tswitch(t, ip1, jp1, k,
+ tfind_face_corner(t->sw[ip1][j][k],
+ t->sw[ip1][j][kp1],
+ t->sw[ip1][jp1][kp1]))) {
+ return true;
+ }
+ log_no_crnr(t, 0x74d, i, j, k, ip1, jp1, k);
+ return false;
+}
+
+/*
+ * 3D case 0x771: O
+ * .
+ * b0: .
+ * b1: t->sw[i+1][j ][k ] .
+ * b2: t->sw[i ][j+1][k ] .
+ * b3: t->sw[i+1][j+1][k ] O . O
+ * b4: O
+ * b5: . .
+ * b6: . .
+ * b7: t->sw[i+1][j+1][k+1] . .
+ * . O .
+ * O O
+ *
+ *
+ *
+ *
+ * @
+ */
+static
+bool handle_case_0x771(struct torus *t, int i, int j, int k)
+{
+ int ip1 = canonicalize(i + 1, t->x_sz);
+ int jp1 = canonicalize(j + 1, t->y_sz);
+ int kp1 = canonicalize(k + 1, t->z_sz);
+
+ if (install_tswitch(t, i, j, k,
+ tfind_face_corner(t->sw[i][jp1][k],
+ t->sw[ip1][jp1][k],
+ t->sw[ip1][j][k]))) {
+ return true;
+ }
+ log_no_crnr(t, 0x771, i, j, k, i, j, k);
+
+ if (install_tswitch(t, ip1, j, kp1,
+ tfind_face_corner(t->sw[ip1][jp1][kp1],
+ t->sw[ip1][jp1][k],
+ t->sw[ip1][j][k]))) {
+ return true;
+ }
+ log_no_crnr(t, 0x771, i, j, k, ip1, j, kp1);
+
+ if (install_tswitch(t, i, jp1, kp1,
+ tfind_face_corner(t->sw[ip1][jp1][kp1],
+ t->sw[ip1][jp1][k],
+ t->sw[i][jp1][k]))) {
+ return true;
+ }
+ log_no_crnr(t, 0x771, i, j, k, i, jp1, kp1);
+ return false;
+}
+
+/*
+ * 3D case 0x78e: O
+ *
+ * b0: t->sw[i ][j ][k ]
+ * b1:
+ * b2:
+ * b3: O O
+ * b4: t->sw[i ][j ][k+1] . O .
+ * b5: t->sw[i+1][j ][k+1] . .
+ * b6: t->sw[i ][j+1][k+1] . .
+ * b7: . .
+ * O
+ * O . O
+ * .
+ * .
+ * .
+ * .
+ * @
+ */
+static
+bool handle_case_0x78e(struct torus *t, int i, int j, int k)
+{
+ int ip1 = canonicalize(i + 1, t->x_sz);
+ int jp1 = canonicalize(j + 1, t->y_sz);
+ int kp1 = canonicalize(k + 1, t->z_sz);
+
+ if (install_tswitch(t, ip1, jp1, kp1,
+ tfind_face_corner(t->sw[ip1][j][kp1],
+ t->sw[i][j][kp1],
+ t->sw[i][jp1][kp1]))) {
+ return true;
+ }
+ log_no_crnr(t, 0x78e, i, j, k, ip1, jp1, kp1);
+
+ if (install_tswitch(t, ip1, j, k,
+ tfind_face_corner(t->sw[i][j][k],
+ t->sw[i][j][kp1],
+ t->sw[ip1][j][kp1]))) {
+ return true;
+ }
+ log_no_crnr(t, 0x78e, i, j, k, ip1, j, k);
+
+ if (install_tswitch(t, i, jp1, k,
+ tfind_face_corner(t->sw[i][j][k],
+ t->sw[i][j][kp1],
+ t->sw[i][jp1][kp1]))) {
+ return true;
+ }
+ log_no_crnr(t, 0x78e, i, j, k, i, jp1, k);
+ return false;
+}
+
+/*
+ * 3D case 0x7b2: O
+ *
+ * b0: t->sw[i ][j ][k ]
+ * b1:
+ * b2: t->sw[i ][j+1][k ]
+ * b3: t->sw[i+1][j+1][k ] O O
+ * b4: . O
+ * b5: . .
+ * b6: t->sw[i ][j+1][k+1] . .
+ * b7: . .
+ * . . O
+ * O O
+ * .
+ * .
+ * .
+ * .
+ * @
+ */
+static
+bool handle_case_0x7b2(struct torus *t, int i, int j, int k)
+{
+ int ip1 = canonicalize(i + 1, t->x_sz);
+ int jp1 = canonicalize(j + 1, t->y_sz);
+ int kp1 = canonicalize(k + 1, t->z_sz);
+
+ if (install_tswitch(t, ip1, j, k,
+ tfind_face_corner(t->sw[i][j][k],
+ t->sw[i][jp1][k],
+ t->sw[ip1][jp1][k]))) {
+ return true;
+ }
+ log_no_crnr(t, 0x7b2, i, j, k, ip1, j, k);
+
+ if (install_tswitch(t, ip1, jp1, kp1,
+ tfind_face_corner(t->sw[i][jp1][kp1],
+ t->sw[i][jp1][k],
+ t->sw[ip1][jp1][k]))) {
+ return true;
+ }
+ log_no_crnr(t, 0x7b2, i, j, k, ip1, jp1, kp1);
+
+ if (install_tswitch(t, i, j, kp1,
+ tfind_face_corner(t->sw[i][jp1][kp1],
+ t->sw[i][jp1][k],
+ t->sw[i][j][k]))) {
+ return true;
+ }
+ log_no_crnr(t, 0x7b2, i, j, k, i, j, kp1);
+ return false;
+}
+
+/*
+ * 3D case 0x7d4: O
+ *
+ * b0: t->sw[i ][j ][k ]
+ * b1: t->sw[i+1][j ][k ]
+ * b2:
+ * b3: t->sw[i+1][j+1][k ] O O
+ * b4: O .
+ * b5: t->sw[i+1][j ][k+1] . .
+ * b6: . .
+ * b7: . .
+ * O . .
+ * O O
+ * .
+ * .
+ * .
+ * .
+ * @
+ */
+static
+bool handle_case_0x7d4(struct torus *t, int i, int j, int k)
+{
+ int ip1 = canonicalize(i + 1, t->x_sz);
+ int jp1 = canonicalize(j + 1, t->y_sz);
+ int kp1 = canonicalize(k + 1, t->z_sz);
+
+ if (install_tswitch(t, i, jp1, k,
+ tfind_face_corner(t->sw[i][j][k],
+ t->sw[ip1][j][k],
+ t->sw[ip1][jp1][k]))) {
+ return true;
+ }
+ log_no_crnr(t, 0x7d4, i, j, k, i, jp1, k);
+
+ if (install_tswitch(t, i, j, kp1,
+ tfind_face_corner(t->sw[ip1][j][kp1],
+ t->sw[ip1][j][k],
+ t->sw[i][j][k]))) {
+ return true;
+ }
+ log_no_crnr(t, 0x7d4, i, j, k, i, j, kp1);
+
+ if (install_tswitch(t, ip1, jp1, kp1,
+ tfind_face_corner(t->sw[ip1][j][kp1],
+ t->sw[ip1][j][k],
+ t->sw[ip1][jp1][k]))) {
+ return true;
+ }
+ log_no_crnr(t, 0x7d4, i, j, k, ip1, jp1, kp1);
+ return false;
+}
+
+/*
+ * 3D case 0x7e8: O
+ *
+ * b0: t->sw[i ][j ][k ]
+ * b1: t->sw[i+1][j ][k ]
+ * b2: t->sw[i ][j+1][k ]
+ * b3: O O
+ * b4: t->sw[i ][j ][k+1] O
+ * b5:
+ * b6:
+ * b7:
+ * O
+ * O . O
+ * . . .
+ * . . .
+ * . . .
+ * . . .
+ * @
+ */
+static
+bool handle_case_0x7e8(struct torus *t, int i, int j, int k)
+{
+ int ip1 = canonicalize(i + 1, t->x_sz);
+ int jp1 = canonicalize(j + 1, t->y_sz);
+ int kp1 = canonicalize(k + 1, t->z_sz);
+
+ if (install_tswitch(t, ip1, jp1, k,
+ tfind_face_corner(t->sw[ip1][j][k],
+ t->sw[i][j][k],
+ t->sw[i][jp1][k]))) {
+ return true;
+ }
+ log_no_crnr(t, 0x7e8, i, j, k, ip1, jp1, k);
+
+ if (install_tswitch(t, ip1, j, kp1,
+ tfind_face_corner(t->sw[ip1][j][k],
+ t->sw[i][j][k],
+ t->sw[i][j][kp1]))) {
+ return true;
+ }
+ log_no_crnr(t, 0x7e8, i, j, k, ip1, j, kp1);
+
+ if (install_tswitch(t, i, jp1, kp1,
+ tfind_face_corner(t->sw[i][jp1][k],
+ t->sw[i][j][k],
+ t->sw[i][j][kp1]))) {
+ return true;
+ }
+ log_no_crnr(t, 0x7e8, i, j, k, i, jp1, kp1);
+ return false;
+}
+
+/*
+ * Handle the cases where four corners on a single face are missing.
+ */
+
+/*
+ * 3D case 0x70f: O
+ * . .
+ * b0: . .
+ * b1: . .
+ * b2: . .
+ * b3: O O
+ * b4: t->sw[i ][j ][k+1] . O .
+ * b5: t->sw[i+1][j ][k+1] . .
+ * b6: t->sw[i ][j+1][k+1] . .
+ * b7: t->sw[i+1][j+1][k+1] . .
+ * O
+ * O O
+ *
+ *
+ *
+ *
+ * @
+ */
+static
+bool handle_case_0x70f(struct torus *t, int i, int j, int k)
+{
+ if (handle_case_0x71f(t, i, j, k))
+ return true;
+
+ if (handle_case_0x72f(t, i, j, k))
+ return true;
+
+ if (handle_case_0x74f(t, i, j, k))
+ return true;
+
+ return handle_case_0x78f(t, i, j, k);
+}
+
+/*
+ * 3D case 0x733: O
+ * . .
+ * b0: . .
+ * b1: . .
+ * b2: t->sw[i ][j+1][k ] . .
+ * b3: t->sw[i+1][j+1][k ] O . O
+ * b4: . O
+ * b5: . .
+ * b6: t->sw[i ][j+1][k+1] . .
+ * b7: t->sw[i+1][j+1][k+1] . .
+ * . . O
+ * O O
+ *
+ *
+ *
+ *
+ * @
+ */
+static
+bool handle_case_0x733(struct torus *t, int i, int j, int k)
+{
+ if (handle_case_0x737(t, i, j, k))
+ return true;
+
+ if (handle_case_0x73b(t, i, j, k))
+ return true;
+
+ if (handle_case_0x773(t, i, j, k))
+ return true;
+
+ return handle_case_0x7b3(t, i, j, k);
+}
+
+/*
+ * 3D case 0x755: O
+ * . .
+ * b0: . .
+ * b1: t->sw[i+1][j ][k ] . .
+ * b2: . .
+ * b3: t->sw[i+1][j+1][k ] O . O
+ * b4: O .
+ * b5: t->sw[i+1][j ][k+1] . .
+ * b6: . .
+ * b7: t->sw[i+1][j+1][k+1] . .
+ * O . .
+ * O O
+ *
+ *
+ *
+ *
+ * @
+ */
+static
+bool handle_case_0x755(struct torus *t, int i, int j, int k)
+{
+ if (handle_case_0x757(t, i, j, k))
+ return true;
+
+ if (handle_case_0x75d(t, i, j, k))
+ return true;
+
+ if (handle_case_0x775(t, i, j, k))
+ return true;
+
+ return handle_case_0x7d5(t, i, j, k);
+}
+
+/*
+ * 3D case 0x7aa: O
+ *
+ * b0: t->sw[i ][j ][k ]
+ * b1:
+ * b2: t->sw[i ][j+1][k ]
+ * b3: O O
+ * b4: t->sw[i ][j ][k+1] . . O
+ * b5: . .
+ * b6: t->sw[i ][j+1][k+1] . .
+ * b7: . .
+ * . O
+ * O . O
+ * . .
+ * . .
+ * . .
+ * . .
+ * @
+ */
+static
+bool handle_case_0x7aa(struct torus *t, int i, int j, int k)
+{
+ if (handle_case_0x7ab(t, i, j, k))
+ return true;
+
+ if (handle_case_0x7ae(t, i, j, k))
+ return true;
+
+ if (handle_case_0x7ba(t, i, j, k))
+ return true;
+
+ return handle_case_0x7ea(t, i, j, k);
+}
+
+/*
+ * 3D case 0x7cc: O
+ *
+ * b0: t->sw[i ][j ][k ]
+ * b1: t->sw[i+1][j ][k ]
+ * b2:
+ * b3: O O
+ * b4: t->sw[i ][j ][k+1] O . .
+ * b5: t->sw[i+1][j ][k+1] . .
+ * b6: . .
+ * b7: . .
+ * O .
+ * O . O
+ * . .
+ * . .
+ * . .
+ * . .
+ * @
+ */
+static
+bool handle_case_0x7cc(struct torus *t, int i, int j, int k)
+{
+ if (handle_case_0x7cd(t, i, j, k))
+ return true;
+
+ if (handle_case_0x7ce(t, i, j, k))
+ return true;
+
+ if (handle_case_0x7dc(t, i, j, k))
+ return true;
+
+ return handle_case_0x7ec(t, i, j, k);
+}
+
+/*
+ * 3D case 0x7f0: O
+ *
+ * b0: t->sw[i ][j ][k ]
+ * b1: t->sw[i+1][j ][k ]
+ * b2: t->sw[i ][j+1][k ]
+ * b3: t->sw[i+1][j+1][k ] O O
+ * b4: O
+ * b5: . .
+ * b6: . .
+ * b7: . .
+ * . O .
+ * O O
+ * . .
+ * . .
+ * . .
+ * . .
+ * @
+ */
+static
+bool handle_case_0x7f0(struct torus *t, int i, int j, int k)
+{
+ if (handle_case_0x7f1(t, i, j, k))
+ return true;
+
+ if (handle_case_0x7f2(t, i, j, k))
+ return true;
+
+ if (handle_case_0x7f4(t, i, j, k))
+ return true;
+
+ return handle_case_0x7f8(t, i, j, k);
+}
+
+/*
+ * Handle the cases where three corners on a single face are missing.
+ */
+
+
+/*
+ * 3D case 0x707: O
+ * . . .
+ * b0: . . .
+ * b1: . . .
+ * b2: . . .
+ * b3: t->sw[i+1][j+1][k ] O . O
+ * b4: t->sw[i ][j ][k+1] . O .
+ * b5: t->sw[i+1][j ][k+1] . .
+ * b6: t->sw[i ][j+1][k+1] . .
+ * b7: t->sw[i+1][j+1][k+1] . .
+ * O
+ * O O
+ *
+ *
+ *
+ *
+ * @
+ */
+static
+bool handle_case_0x707(struct torus *t, int i, int j, int k)
+{
+ int ip1 = canonicalize(i + 1, t->x_sz);
+ int jp1 = canonicalize(j + 1, t->y_sz);
+ int kp1 = canonicalize(k + 1, t->z_sz);
+
+ if (install_tswitch(t, ip1, j, k,
+ tfind_face_corner(t->sw[ip1][jp1][k],
+ t->sw[ip1][jp1][kp1],
+ t->sw[ip1][j][kp1]))) {
+ return true;
+ }
+ log_no_crnr(t, 0x707, i, j, k, ip1, j, k);
+
+ if (install_tswitch(t, i, jp1, k,
+ tfind_face_corner(t->sw[ip1][jp1][k],
+ t->sw[ip1][jp1][kp1],
+ t->sw[i][jp1][kp1]))) {
+ return true;
+ }
+ log_no_crnr(t, 0x707, i, j, k, i, jp1, k);
+ return false;
+}
+
+/*
+ * 3D case 0x70b: O
+ * . .
+ * b0: . .
+ * b1: . .
+ * b2: t->sw[i ][j+1][k ] . .
+ * b3: O O
+ * b4: t->sw[i ][j ][k+1] . . O .
+ * b5: t->sw[i+1][j ][k+1] . . .
+ * b6: t->sw[i ][j+1][k+1] . . .
+ * b7: t->sw[i+1][j+1][k+1] . . .
+ * . O
+ * O O
+ *
+ *
+ *
+ *
+ * @
+ */
+static
+bool handle_case_0x70b(struct torus *t, int i, int j, int k)
+{
+ int ip1 = canonicalize(i + 1, t->x_sz);
+ int jp1 = canonicalize(j + 1, t->y_sz);
+ int kp1 = canonicalize(k + 1, t->z_sz);
+
+ if (install_tswitch(t, i, j, k,
+ tfind_face_corner(t->sw[i][jp1][k],
+ t->sw[i][jp1][kp1],
+ t->sw[i][j][kp1]))) {
+ return true;
+ }
+ log_no_crnr(t, 0x70b, i, j, k, i, j, k);
+
+ if (install_tswitch(t, ip1, jp1, k,
+ tfind_face_corner(t->sw[i][jp1][k],
+ t->sw[i][jp1][kp1],
+ t->sw[ip1][jp1][kp1]))) {
+ return true;
+ }
+ log_no_crnr(t, 0x70b, i, j, k, ip1, jp1, k);
+ return false;
+}
+
+/*
+ * 3D case 0x70d: O
+ * . .
+ * b0: . .
+ * b1: t->sw[i+1][j ][k ] . .
+ * b2: . .
+ * b3: O O
+ * b4: t->sw[i ][j ][k+1] . O . .
+ * b5: t->sw[i+1][j ][k+1] . . .
+ * b6: t->sw[i ][j+1][k+1] . . .
+ * b7: t->sw[i+1][j+1][k+1] . . .
+ * O .
+ * O O
+ *
+ *
+ *
+ *
+ * @
+ */
+static
+bool handle_case_0x70d(struct torus *t, int i, int j, int k)
+{
+ int ip1 = canonicalize(i + 1, t->x_sz);
+ int jp1 = canonicalize(j + 1, t->y_sz);
+ int kp1 = canonicalize(k + 1, t->z_sz);
+
+ if (install_tswitch(t, i, j, k,
+ tfind_face_corner(t->sw[ip1][j][k],
+ t->sw[ip1][j][kp1],
+ t->sw[i][j][kp1]))) {
+ return true;
+ }
+ log_no_crnr(t, 0x70d, i, j, k, i, j, k);
+
+ if (install_tswitch(t, ip1, jp1, k,
+ tfind_face_corner(t->sw[ip1][j][k],
+ t->sw[ip1][j][kp1],
+ t->sw[ip1][jp1][kp1]))) {
+ return true;
+ }
+ log_no_crnr(t, 0x70d, i, j, k, ip1, jp1, k);
+ return false;
+}
+
+/*
+ * 3D case 0x70e: O
+ * . .
+ * b0: t->sw[i ][j ][k ] . .
+ * b1: . .
+ * b2: . .
+ * b3: O O
+ * b4: t->sw[i ][j ][k+1] . O .
+ * b5: t->sw[i+1][j ][k+1] . .
+ * b6: t->sw[i ][j+1][k+1] . .
+ * b7: t->sw[i+1][j+1][k+1] . .
+ * O
+ * O . O
+ * .
+ * .
+ * .
+ * .
+ * @
+ */
+static
+bool handle_case_0x70e(struct torus *t, int i, int j, int k)
+{
+ int ip1 = canonicalize(i + 1, t->x_sz);
+ int jp1 = canonicalize(j + 1, t->y_sz);
+ int kp1 = canonicalize(k + 1, t->z_sz);
+
+ if (install_tswitch(t, ip1, j, k,
+ tfind_face_corner(t->sw[i][j][k],
+ t->sw[i][j][kp1],
+ t->sw[ip1][j][kp1]))) {
+ return true;
+ }
+ log_no_crnr(t, 0x70e, i, j, k, ip1, j, k);
+
+ if (install_tswitch(t, i, jp1, k,
+ tfind_face_corner(t->sw[i][j][k],
+ t->sw[i][j][kp1],
+ t->sw[i][jp1][kp1]))) {
+ return true;
+ }
+ log_no_crnr(t, 0x70e, i, j, k, i, jp1, k);
+ return false;
+}
+
+/*
+ * 3D case 0x713: O
+ * . . .
+ * b0: . . .
+ * b1: . . .
+ * b2: t->sw[i ][j+1][k ] . . .
+ * b3: t->sw[i+1][j+1][k ] O . O
+ * b4: . O
+ * b5: t->sw[i+1][j ][k+1] . .
+ * b6: t->sw[i ][j+1][k+1] . .
+ * b7: t->sw[i+1][j+1][k+1] . .
+ * . . O
+ * O O
+ *
+ *
+ *
+ *
+ * @
+ */
+static
+bool handle_case_0x713(struct torus *t, int i, int j, int k)
+{
+ int ip1 = canonicalize(i + 1, t->x_sz);
+ int jp1 = canonicalize(j + 1, t->y_sz);
+ int kp1 = canonicalize(k + 1, t->z_sz);
+
+ if (install_tswitch(t, ip1, j, k,
+ tfind_face_corner(t->sw[ip1][jp1][k],
+ t->sw[ip1][jp1][kp1],
+ t->sw[ip1][j][kp1]))) {
+ return true;
+ }
+ log_no_crnr(t, 0x713, i, j, k, ip1, j, k);
+
+ if (install_tswitch(t, i, j, kp1,
+ tfind_face_corner(t->sw[ip1][j][kp1],
+ t->sw[ip1][jp1][kp1],
+ t->sw[i][jp1][kp1]))) {
+ return true;
+ }
+ log_no_crnr(t, 0x713, i, j, k, i, j, kp1);
+ return false;
+}
+
+/*
+ * 3D case 0x715: O
+ * . . .
+ * b0: . . .
+ * b1: t->sw[i+1][j ][k ] . . .
+ * b2: . . .
+ * b3: t->sw[i+1][j+1][k ] O . O
+ * b4: O .
+ * b5: t->sw[i+1][j ][k+1] . .
+ * b6: t->sw[i ][j+1][k+1] . .
+ * b7: t->sw[i+1][j+1][k+1] . .
+ * O . .
+ * O O
+ *
+ *
+ *
+ *
+ * @
+ */
+static
+bool handle_case_0x715(struct torus *t, int i, int j, int k)
+{
+ int ip1 = canonicalize(i + 1, t->x_sz);
+ int jp1 = canonicalize(j + 1, t->y_sz);
+ int kp1 = canonicalize(k + 1, t->z_sz);
+
+ if (install_tswitch(t, i, jp1, k,
+ tfind_face_corner(t->sw[ip1][jp1][k],
+ t->sw[ip1][jp1][kp1],
+ t->sw[i][jp1][kp1]))) {
+ return true;
+ }
+ log_no_crnr(t, 0x715, i, j, k, i, jp1, k);
+
+ if (install_tswitch(t, i, j, kp1,
+ tfind_face_corner(t->sw[ip1][j][kp1],
+ t->sw[ip1][jp1][kp1],
+ t->sw[i][jp1][kp1]))) {
+ return true;
+ }
+ log_no_crnr(t, 0x715, i, j, k, i, j, kp1);
+ return false;
+}
+
+/*
+ * 3D case 0x723: O
+ * . .
+ * b0: . .
+ * b1: . .
+ * b2: t->sw[i ][j+1][k ] . .
+ * b3: t->sw[i+1][j+1][k ] O . O
+ * b4: t->sw[i ][j ][k+1] . . O
+ * b5: . . .
+ * b6: t->sw[i ][j+1][k+1] . .
+ * b7: t->sw[i+1][j+1][k+1] . . .
+ * . . O
+ * O O
+ *
+ *
+ *
+ *
+ * @
+ */
+static
+bool handle_case_0x723(struct torus *t, int i, int j, int k)
+{
+ int ip1 = canonicalize(i + 1, t->x_sz);
+ int jp1 = canonicalize(j + 1, t->y_sz);
+ int kp1 = canonicalize(k + 1, t->z_sz);
+
+ if (install_tswitch(t, i, j, k,
+ tfind_face_corner(t->sw[i][jp1][k],
+ t->sw[i][jp1][kp1],
+ t->sw[i][j][kp1]))) {
+ return true;
+ }
+ log_no_crnr(t, 0x723, i, j, k, i, j, k);
+
+ if (install_tswitch(t, ip1, j, kp1,
+ tfind_face_corner(t->sw[i][j][kp1],
+ t->sw[i][jp1][kp1],
+ t->sw[ip1][jp1][kp1]))) {
+ return true;
+ }
+ log_no_crnr(t, 0x723, i, j, k, ip1, j, kp1);
+ return false;
+}
+
+/*
+ * 3D case 0x72a: O
+ * .
+ * b0: t->sw[i ][j ][k ] .
+ * b1: .
+ * b2: t->sw[i ][j+1][k ] .
+ * b3: O O
+ * b4: t->sw[i ][j ][k+1] . . O
+ * b5: . .
+ * b6: t->sw[i ][j+1][k+1] . .
+ * b7: t->sw[i+1][j+1][k+1] . .
+ * . O
+ * O . O
+ * . .
+ * . .
+ * . .
+ * . .
+ * @
+ */
+static
+bool handle_case_0x72a(struct torus *t, int i, int j, int k)
+{
+ int ip1 = canonicalize(i + 1, t->x_sz);
+ int jp1 = canonicalize(j + 1, t->y_sz);
+ int kp1 = canonicalize(k + 1, t->z_sz);
+
+ if (install_tswitch(t, ip1, jp1, k,
+ tfind_face_corner(t->sw[i][jp1][k],
+ t->sw[i][jp1][kp1],
+ t->sw[ip1][jp1][kp1]))) {
+ return true;
+ }
+ log_no_crnr(t, 0x72a, i, j, k, ip1, jp1, k);
+
+ if (install_tswitch(t, ip1, j, kp1,
+ tfind_face_corner(t->sw[i][j][kp1],
+ t->sw[i][jp1][kp1],
+ t->sw[ip1][jp1][kp1]))) {
+ return true;
+ }
+ log_no_crnr(t, 0x72a, i, j, k, ip1, j, kp1);
+ return false;
+}
+
+/*
+ * 3D case 0x731: O
+ * . .
+ * b0: . .
+ * b1: t->sw[i+1][j ][k ] . .
+ * b2: t->sw[i ][j+1][k ] . .
+ * b3: t->sw[i+1][j+1][k ] O . O
+ * b4: . O
+ * b5: . . .
+ * b6: t->sw[i ][j+1][k+1] . . .
+ * b7: t->sw[i+1][j+1][k+1] . . .
+ * . . O .
+ * O O
+ *
+ *
+ *
+ *
+ * @
+ */
+static
+bool handle_case_0x731(struct torus *t, int i, int j, int k)
+{
+ int ip1 = canonicalize(i + 1, t->x_sz);
+ int jp1 = canonicalize(j + 1, t->y_sz);
+ int kp1 = canonicalize(k + 1, t->z_sz);
+
+ if (install_tswitch(t, i, j, k,
+ tfind_face_corner(t->sw[ip1][j][k],
+ t->sw[ip1][jp1][k],
+ t->sw[i][jp1][k]))) {
+ return true;
+ }
+ log_no_crnr(t, 0x731, i, j, k, i, j, k);
+
+ if (install_tswitch(t, ip1, j, kp1,
+ tfind_face_corner(t->sw[ip1][j][k],
+ t->sw[ip1][jp1][k],
+ t->sw[ip1][jp1][kp1]))) {
+ return true;
+ }
+ log_no_crnr(t, 0x731, i, j, k, ip1, j, kp1);
+ return false;
+}
+
+/*
+ * 3D case 0x732: O
+ * . .
+ * b0: t->sw[i ][j ][k ] . .
+ * b1: . .
+ * b2: t->sw[i ][j+1][k ] . .
+ * b3: t->sw[i+1][j+1][k ] O . O
+ * b4: . O
+ * b5: . .
+ * b6: t->sw[i ][j+1][k+1] . .
+ * b7: t->sw[i+1][j+1][k+1] . .
+ * . . O
+ * O O
+ * .
+ * .
+ * .
+ * .
+ * @
+ */
+static
+bool handle_case_0x732(struct torus *t, int i, int j, int k)
+{
+ int ip1 = canonicalize(i + 1, t->x_sz);
+ int jp1 = canonicalize(j + 1, t->y_sz);
+ int kp1 = canonicalize(k + 1, t->z_sz);
+
+ if (install_tswitch(t, ip1, j, k,
+ tfind_face_corner(t->sw[i][j][k],
+ t->sw[i][jp1][k],
+ t->sw[ip1][jp1][k]))) {
+ return true;
+ }
+ log_no_crnr(t, 0x732, i, j, k, ip1, j, k);
+
+ if (install_tswitch(t, i, j, kp1,
+ tfind_face_corner(t->sw[i][j][k],
+ t->sw[i][jp1][k],
+ t->sw[i][jp1][kp1]))) {
+ return true;
+ }
+ log_no_crnr(t, 0x732, i, j, k, i, j, kp1);
+ return false;
+}
+
+/*
+ * 3D case 0x745: O
+ * . .
+ * b0: . .
+ * b1: t->sw[i+1][j ][k ] . .
+ * b2: . .
+ * b3: t->sw[i+1][j+1][k ] O . O
+ * b4: t->sw[i ][j ][k+1] O . .
+ * b5: t->sw[i+1][j ][k+1] . . .
+ * b6: . .
+ * b7: t->sw[i+1][j+1][k+1] . . .
+ * O . .
+ * O O
+ *
+ *
+ *
+ *
+ * @
+ */
+static
+bool handle_case_0x745(struct torus *t, int i, int j, int k)
+{
+ int ip1 = canonicalize(i + 1, t->x_sz);
+ int jp1 = canonicalize(j + 1, t->y_sz);
+ int kp1 = canonicalize(k + 1, t->z_sz);
+
+ if (install_tswitch(t, i, j, k,
+ tfind_face_corner(t->sw[ip1][j][k],
+ t->sw[ip1][j][kp1],
+ t->sw[i][j][kp1]))) {
+ return true;
+ }
+ log_no_crnr(t, 0x745, i, j, k, i, j, k);
+
+ if (install_tswitch(t, i, jp1, kp1,
+ tfind_face_corner(t->sw[i][j][kp1],
+ t->sw[ip1][j][kp1],
+ t->sw[ip1][jp1][kp1]))) {
+ return true;
+ }
+ log_no_crnr(t, 0x745, i, j, k, i, jp1, kp1);
+ return false;
+}
+
+/*
+ * 3D case 0x74c: O
+ * .
+ * b0: t->sw[i ][j ][k ] .
+ * b1: t->sw[i+1][j ][k ] .
+ * b2: .
+ * b3: O O
+ * b4: t->sw[i ][j ][k+1] O . .
+ * b5: t->sw[i+1][j ][k+1] . .
+ * b6: . .
+ * b7: t->sw[i+1][j+1][k+1] . .
+ * O .
+ * O . O
+ * . .
+ * . .
+ * . .
+ * . .
+ * @
+ */
+static
+bool handle_case_0x74c(struct torus *t, int i, int j, int k)
+{
+ int ip1 = canonicalize(i + 1, t->x_sz);
+ int jp1 = canonicalize(j + 1, t->y_sz);
+ int kp1 = canonicalize(k + 1, t->z_sz);
+
+ if (install_tswitch(t, ip1, jp1, k,
+ tfind_face_corner(t->sw[ip1][j][k],
+ t->sw[ip1][j][kp1],
+ t->sw[ip1][jp1][kp1]))) {
+ return true;
+ }
+ log_no_crnr(t, 0x74c, i, j, k, ip1, jp1, k);
+
+ if (install_tswitch(t, i, jp1, kp1,
+ tfind_face_corner(t->sw[i][j][kp1],
+ t->sw[ip1][j][kp1],
+ t->sw[ip1][jp1][kp1]))) {
+ return true;
+ }
+ log_no_crnr(t, 0x74c, i, j, k, i, jp1, kp1);
+ return false;
+}
+
+/*
+ * 3D case 0x751: O
+ * . .
+ * b0: . .
+ * b1: t->sw[i+1][j ][k ] . .
+ * b2: t->sw[i ][j+1][k ] . .
+ * b3: t->sw[i+1][j+1][k ] O . O
+ * b4: O .
+ * b5: t->sw[i+1][j ][k+1] . . .
+ * b6: . . .
+ * b7: t->sw[i+1][j+1][k+1] . . .
+ * . O . .
+ * O O
+ *
+ *
+ *
+ *
+ * @
+ */
+static
+bool handle_case_0x751(struct torus *t, int i, int j, int k)
+{
+ int ip1 = canonicalize(i + 1, t->x_sz);
+ int jp1 = canonicalize(j + 1, t->y_sz);
+ int kp1 = canonicalize(k + 1, t->z_sz);
+
+ if (install_tswitch(t, i, j, k,
+ tfind_face_corner(t->sw[ip1][j][k],
+ t->sw[ip1][jp1][k],
+ t->sw[i][jp1][k]))) {
+ return true;
+ }
+ log_no_crnr(t, 0x751, i, j, k, i, j, k);
+
+ if (install_tswitch(t, i, jp1, kp1,
+ tfind_face_corner(t->sw[i][jp1][k],
+ t->sw[ip1][jp1][k],
+ t->sw[ip1][jp1][kp1]))) {
+ return true;
+ }
+ log_no_crnr(t, 0x751, i, j, k, i, jp1, kp1);
+ return false;
+}
+
+/*
+ * 3D case 0x754: O
+ * . .
+ * b0: t->sw[i ][j ][k ] . .
+ * b1: t->sw[i+1][j ][k ] . .
+ * b2: . .
+ * b3: t->sw[i+1][j+1][k ] O . O
+ * b4: O .
+ * b5: t->sw[i+1][j ][k+1] . .
+ * b6: . .
+ * b7: t->sw[i+1][j+1][k+1] . .
+ * O . .
+ * O O
+ * .
+ * .
+ * .
+ * .
+ * @
+ */
+static
+bool handle_case_0x754(struct torus *t, int i, int j, int k)
+{
+ int ip1 = canonicalize(i + 1, t->x_sz);
+ int jp1 = canonicalize(j + 1, t->y_sz);
+ int kp1 = canonicalize(k + 1, t->z_sz);
+
+ if (install_tswitch(t, i, jp1, k,
+ tfind_face_corner(t->sw[i][j][k],
+ t->sw[ip1][j][k],
+ t->sw[ip1][jp1][k]))) {
+ return true;
+ }
+ log_no_crnr(t, 0x754, i, j, k, i, jp1, k);
+
+ if (install_tswitch(t, i, j, kp1,
+ tfind_face_corner(t->sw[i][j][k],
+ t->sw[ip1][j][k],
+ t->sw[ip1][j][kp1]))) {
+ return true;
+ }
+ log_no_crnr(t, 0x754, i, j, k, i, j, kp1);
+ return false;
+}
+
+/*
+ * 3D case 0x770: O
+ * .
+ * b0: t->sw[i ][j ][k ] .
+ * b1: t->sw[i+1][j ][k ] .
+ * b2: t->sw[i ][j+1][k ] .
+ * b3: t->sw[i+1][j+1][k ] O . O
+ * b4: O
+ * b5: . .
+ * b6: . .
+ * b7: t->sw[i+1][j+1][k+1] . .
+ * . O .
+ * O O
+ * . .
+ * . .
+ * . .
+ * . .
+ * @
+ */
+static
+bool handle_case_0x770(struct torus *t, int i, int j, int k)
+{
+ int ip1 = canonicalize(i + 1, t->x_sz);
+ int jp1 = canonicalize(j + 1, t->y_sz);
+ int kp1 = canonicalize(k + 1, t->z_sz);
+
+ if (install_tswitch(t, ip1, j, kp1,
+ tfind_face_corner(t->sw[ip1][j][k],
+ t->sw[ip1][jp1][k],
+ t->sw[ip1][jp1][kp1]))) {
+ return true;
+ }
+ log_no_crnr(t, 0x770, i, j, k, ip1, j, kp1);
+
+ if (install_tswitch(t, i, jp1, kp1,
+ tfind_face_corner(t->sw[i][jp1][k],
+ t->sw[ip1][jp1][k],
+ t->sw[ip1][jp1][kp1]))) {
+ return true;
+ }
+ log_no_crnr(t, 0x770, i, j, k, i, jp1, kp1);
+ return false;
+}
+
+/*
+ * 3D case 0x78a: O
+ *
+ * b0: t->sw[i ][j ][k ]
+ * b1:
+ * b2: t->sw[i ][j+1][k ]
+ * b3: O O
+ * b4: t->sw[i ][j ][k+1] . . O .
+ * b5: t->sw[i+1][j ][k+1] . . .
+ * b6: t->sw[i ][j+1][k+1] . . .
+ * b7: . . .
+ * . O
+ * O . O
+ * . .
+ * . .
+ * . .
+ * . .
+ * @
+ */
+static
+bool handle_case_0x78a(struct torus *t, int i, int j, int k)
+{
+ int ip1 = canonicalize(i + 1, t->x_sz);
+ int jp1 = canonicalize(j + 1, t->y_sz);
+ int kp1 = canonicalize(k + 1, t->z_sz);
+
+ if (install_tswitch(t, ip1, j, k,
+ tfind_face_corner(t->sw[i][j][k],
+ t->sw[i][j][kp1],
+ t->sw[ip1][j][kp1]))) {
+ return true;
+ }
+ log_no_crnr(t, 0x78a, i, j, k, ip1, j, k);
+
+ if (install_tswitch(t, ip1, jp1, kp1,
+ tfind_face_corner(t->sw[ip1][j][kp1],
+ t->sw[i][j][kp1],
+ t->sw[i][jp1][kp1]))) {
+ return true;
+ }
+ log_no_crnr(t, 0x78a, i, j, k, ip1, jp1, kp1);
+ return false;
+}
+
+/*
+ * 3D case 0x78c: O
+ *
+ * b0: t->sw[i ][j ][k ]
+ * b1: t->sw[i+1][j ][k ]
+ * b2:
+ * b3: O O
+ * b4: t->sw[i ][j ][k+1] . O . .
+ * b5: t->sw[i+1][j ][k+1] . . .
+ * b6: t->sw[i ][j+1][k+1] . . .
+ * b7: . . .
+ * O .
+ * O . O
+ * . .
+ * . .
+ * . .
+ * . .
+ * @
+ */
+static
+bool handle_case_0x78c(struct torus *t, int i, int j, int k)
+{
+ int ip1 = canonicalize(i + 1, t->x_sz);
+ int jp1 = canonicalize(j + 1, t->y_sz);
+ int kp1 = canonicalize(k + 1, t->z_sz);
+
+ if (install_tswitch(t, i, jp1, k,
+ tfind_face_corner(t->sw[i][j][k],
+ t->sw[i][j][kp1],
+ t->sw[i][jp1][kp1]))) {
+ return true;
+ }
+ log_no_crnr(t, 0x78c, i, j, k, i, jp1, k);
+
+ if (install_tswitch(t, ip1, jp1, kp1,
+ tfind_face_corner(t->sw[ip1][j][kp1],
+ t->sw[i][j][kp1],
+ t->sw[i][jp1][kp1]))) {
+ return true;
+ }
+ log_no_crnr(t, 0x78c, i, j, k, ip1, jp1, kp1);
+ return false;
+}
+
+/*
+ * 3D case 0x7a2: O
+ *
+ * b0: t->sw[i ][j ][k ]
+ * b1:
+ * b2: t->sw[i ][j+1][k ]
+ * b3: t->sw[i+1][j+1][k ] O O
+ * b4: t->sw[i ][j ][k+1] . . O
+ * b5: . . .
+ * b6: t->sw[i ][j+1][k+1] . .
+ * b7: . . .
+ * . . O
+ * O . O
+ * . .
+ * . .
+ * . .
+ * . .
+ * @
+ */
+static
+bool handle_case_0x7a2(struct torus *t, int i, int j, int k)
+{
+ int ip1 = canonicalize(i + 1, t->x_sz);
+ int jp1 = canonicalize(j + 1, t->y_sz);
+ int kp1 = canonicalize(k + 1, t->z_sz);
+
+ if (install_tswitch(t, ip1, j, k,
+ tfind_face_corner(t->sw[i][j][k],
+ t->sw[i][jp1][k],
+ t->sw[ip1][jp1][k]))) {
+ return true;
+ }
+ log_no_crnr(t, 0x7a2, i, j, k, ip1, j, k);
+
+ if (install_tswitch(t, ip1, jp1, kp1,
+ tfind_face_corner(t->sw[i][jp1][kp1],
+ t->sw[i][jp1][k],
+ t->sw[ip1][jp1][k]))) {
+ return true;
+ }
+ log_no_crnr(t, 0x7a2, i, j, k, ip1, jp1, kp1);
+ return false;
+}
+
+/*
+ * 3D case 0x7a8: O
+ *
+ * b0: t->sw[i ][j ][k ]
+ * b1: t->sw[ip1][j ][k ]
+ * b2: t->sw[i ][j+1][k ]
+ * b3: O O
+ * b4: t->sw[i ][j ][k+1] . . O
+ * b5: . .
+ * b6: t->sw[i ][j+1][k+1] . .
+ * b7: . .
+ * . O
+ * O . O
+ * . . .
+ * . . .
+ * . . .
+ * . . .
+ * @
+ */
+static
+bool handle_case_0x7a8(struct torus *t, int i, int j, int k)
+{
+ int ip1 = canonicalize(i + 1, t->x_sz);
+ int jp1 = canonicalize(j + 1, t->y_sz);
+ int kp1 = canonicalize(k + 1, t->z_sz);
+
+ if (install_tswitch(t, ip1, jp1, k,
+ tfind_face_corner(t->sw[ip1][j][k],
+ t->sw[i][j][k],
+ t->sw[i][jp1][k]))) {
+ return true;
+ }
+ log_no_crnr(t, 0x7a8, i, j, k, ip1, jp1, k);
+
+ if (install_tswitch(t, ip1, j, kp1,
+ tfind_face_corner(t->sw[i][j][kp1],
+ t->sw[i][j][k],
+ t->sw[ip1][j][k]))) {
+ return true;
+ }
+ log_no_crnr(t, 0x7a8, i, j, k, ip1, j, kp1);
+ return false;
+}
+
+/*
+ * 3D case 0x7b0: O
+ *
+ * b0: t->sw[i ][j ][k ]
+ * b1: t->sw[i+1][j ][k ]
+ * b2: t->sw[i ][j+1][k ]
+ * b3: t->sw[i+1][j+1][k ] O O
+ * b4: . O
+ * b5: . . .
+ * b6: t->sw[i ][j+1][k+1] . . .
+ * b7: . . .
+ * . . O .
+ * O O
+ * . .
+ * . .
+ * . .
+ * . .
+ * @
+ */
+static
+bool handle_case_0x7b0(struct torus *t, int i, int j, int k)
+{
+ int ip1 = canonicalize(i + 1, t->x_sz);
+ int jp1 = canonicalize(j + 1, t->y_sz);
+ int kp1 = canonicalize(k + 1, t->z_sz);
+
+ if (install_tswitch(t, i, j, kp1,
+ tfind_face_corner(t->sw[i][j][k],
+ t->sw[i][jp1][k],
+ t->sw[i][jp1][kp1]))) {
+ return true;
+ }
+ log_no_crnr(t, 0x7b0, i, j, k, i, j, kp1);
+
+ if (install_tswitch(t, ip1, jp1, kp1,
+ tfind_face_corner(t->sw[i][jp1][kp1],
+ t->sw[i][jp1][k],
+ t->sw[ip1][jp1][k]))) {
+ return true;
+ }
+ log_no_crnr(t, 0x7b0, i, j, k, ip1, jp1, kp1);
+ return false;
+}
+
+/*
+ * 3D case 0x7c4: O
+ *
+ * b0: t->sw[i ][j ][k ]
+ * b1: t->sw[i+1][j ][k ]
+ * b2:
+ * b3: t->sw[i+1][j+1][k ] O O
+ * b4: t->sw[i ][j ][k+1] O . .
+ * b5: t->sw[i+1][j ][k+1] . . .
+ * b6: . .
+ * b7: . . .
+ * O . .
+ * O . O
+ * . .
+ * . .
+ * . .
+ * . .
+ * @
+ */
+static
+bool handle_case_0x7c4(struct torus *t, int i, int j, int k)
+{
+ int ip1 = canonicalize(i + 1, t->x_sz);
+ int jp1 = canonicalize(j + 1, t->y_sz);
+ int kp1 = canonicalize(k + 1, t->z_sz);
+
+ if (install_tswitch(t, i, jp1, k,
+ tfind_face_corner(t->sw[i][j][k],
+ t->sw[ip1][j][k],
+ t->sw[ip1][jp1][k]))) {
+ return true;
+ }
+ log_no_crnr(t, 0x7c4, i, j, k, i, jp1, k);
+
+ if (install_tswitch(t, ip1, jp1, kp1,
+ tfind_face_corner(t->sw[ip1][j][kp1],
+ t->sw[ip1][j][k],
+ t->sw[ip1][jp1][k]))) {
+ return true;
+ }
+ log_no_crnr(t, 0x7c4, i, j, k, ip1, jp1, kp1);
+ return false;
+}
+
+/*
+ * 3D case 0x7c8: O
+ *
+ * b0: t->sw[i ][j ][k ]
+ * b1: t->sw[i+1][j ][k ]
+ * b2: t->sw[i ][j+1][k ]
+ * b3: O O
+ * b4: t->sw[i ][j ][k+1] O . .
+ * b5: t->sw[i+1][j ][k+1] . .
+ * b6: . .
+ * b7: . .
+ * O .
+ * O . O
+ * . . .
+ * . . .
+ * . . .
+ * . . .
+ * @
+ */
+static
+bool handle_case_0x7c8(struct torus *t, int i, int j, int k)
+{
+ int ip1 = canonicalize(i + 1, t->x_sz);
+ int jp1 = canonicalize(j + 1, t->y_sz);
+ int kp1 = canonicalize(k + 1, t->z_sz);
+
+ if (install_tswitch(t, ip1, jp1, k,
+ tfind_face_corner(t->sw[ip1][j][k],
+ t->sw[i][j][k],
+ t->sw[i][jp1][k]))) {
+ return true;
+ }
+ log_no_crnr(t, 0x7c8, i, j, k, ip1, jp1, k);
+
+ if (install_tswitch(t, i, jp1, kp1,
+ tfind_face_corner(t->sw[i][j][kp1],
+ t->sw[i][j][k],
+ t->sw[i][jp1][k]))) {
+ return true;
+ }
+ log_no_crnr(t, 0x7c8, i, j, k, i, jp1, kp1);
+ return false;
+}
+
+/*
+ * 3D case 0x7d0: O
+ *
+ * b0: t->sw[i ][j ][k ]
+ * b1: t->sw[i+1][j ][k ]
+ * b2: t->sw[i ][j+1][k ]
+ * b3: t->sw[i+1][j+1][k ] O O
+ * b4: O .
+ * b5: t->sw[i+1][j ][k+1] . . .
+ * b6: . . .
+ * b7: . . .
+ * . O . .
+ * O O
+ * . .
+ * . .
+ * . .
+ * . .
+ * @
+ */
+static
+bool handle_case_0x7d0(struct torus *t, int i, int j, int k)
+{
+ int ip1 = canonicalize(i + 1, t->x_sz);
+ int jp1 = canonicalize(j + 1, t->y_sz);
+ int kp1 = canonicalize(k + 1, t->z_sz);
+
+ if (install_tswitch(t, i, j, kp1,
+ tfind_face_corner(t->sw[i][j][k],
+ t->sw[ip1][j][k],
+ t->sw[ip1][j][kp1]))) {
+ return true;
+ }
+ log_no_crnr(t, 0x7d0, i, j, k, i, j, kp1);
+
+ if (install_tswitch(t, ip1, jp1, kp1,
+ tfind_face_corner(t->sw[ip1][j][kp1],
+ t->sw[ip1][j][k],
+ t->sw[ip1][jp1][k]))) {
+ return true;
+ }
+ log_no_crnr(t, 0x7d0, i, j, k, ip1, jp1, kp1);
+ return false;
+}
+
+/*
+ * 3D case 0x7e0: O
+ *
+ * b0: t->sw[i ][j ][k ]
+ * b1: t->sw[i+1][j ][k ]
+ * b2: t->sw[i ][j+1][k ]
+ * b3: t->sw[i+1][j+1][k ] O O
+ * b4: t->sw[i ][j ][k+1] O
+ * b5: . .
+ * b6: . .
+ * b7: . .
+ * . O .
+ * O . O
+ * . . .
+ * . . .
+ * . . .
+ * . . .
+ * @
+ */
+static
+bool handle_case_0x7e0(struct torus *t, int i, int j, int k)
+{
+ int ip1 = canonicalize(i + 1, t->x_sz);
+ int jp1 = canonicalize(j + 1, t->y_sz);
+ int kp1 = canonicalize(k + 1, t->z_sz);
+
+ if (install_tswitch(t, ip1, j, kp1,
+ tfind_face_corner(t->sw[i][j][kp1],
+ t->sw[i][j][k],
+ t->sw[ip1][j][k]))) {
+ return true;
+ }
+ log_no_crnr(t, 0x7e0, i, j, k, ip1, j, kp1);
+
+ if (install_tswitch(t, i, jp1, kp1,
+ tfind_face_corner(t->sw[i][j][kp1],
+ t->sw[i][j][k],
+ t->sw[i][jp1][k]))) {
+ return true;
+ }
+ log_no_crnr(t, 0x7e0, i, j, k, i, jp1, kp1);
+ return false;
+}
+
+/*
+ * Handle the cases where two corners on a single edge are missing.
+ */
+
+/*
+ * 3D case 0x703: O
+ * . . .
+ * b0: . . .
+ * b1: . . .
+ * b2: t->sw[i ][j+1][k ] . . .
+ * b3: t->sw[i+1][j+1][k ] O . O
+ * b4: t->sw[i ][j ][k+1] . . O .
+ * b5: t->sw[i+1][j ][k+1] . . . .
+ * b6: t->sw[i ][j+1][k+1] . . .
+ * b7: t->sw[i+1][j+1][k+1] . . . .
+ * . . O
+ * O O
+ *
+ *
+ *
+ *
+ * @
+ */
+static
+bool handle_case_0x703(struct torus *t, int i, int j, int k)
+{
+ int ip1 = canonicalize(i + 1, t->x_sz);
+ int jp1 = canonicalize(j + 1, t->y_sz);
+ int kp1 = canonicalize(k + 1, t->z_sz);
+
+ if (install_tswitch(t, i, j, k,
+ tfind_face_corner(t->sw[i][jp1][k],
+ t->sw[i][jp1][kp1],
+ t->sw[i][j][kp1]))) {
+ return true;
+ }
+ log_no_crnr(t, 0x703, i, j, k, i, j, k);
+
+ if (install_tswitch(t, ip1, j, k,
+ tfind_face_corner(t->sw[ip1][jp1][k],
+ t->sw[ip1][jp1][kp1],
+ t->sw[ip1][j][kp1]))) {
+ return true;
+ }
+ log_no_crnr(t, 0x703, i, j, k, ip1, j, k);
+ return false;
+}
+
+/*
+ * 3D case 0x705: O
+ * . . .
+ * b0: . . .
+ * b1: t->sw[i+1][j ][k ] . . .
+ * b2: . . .
+ * b3: t->sw[i+1][j+1][k ] O . O
+ * b4: t->sw[i ][j ][k+1] . O . .
+ * b5: t->sw[i+1][j ][k+1] . . . .
+ * b6: t->sw[i ][j+1][k+1] . . .
+ * b7: t->sw[i+1][j+1][k+1] . . . .
+ * O . .
+ * O O
+ *
+ *
+ *
+ *
+ * @
+ */
+static
+bool handle_case_0x705(struct torus *t, int i, int j, int k)
+{
+ int ip1 = canonicalize(i + 1, t->x_sz);
+ int jp1 = canonicalize(j + 1, t->y_sz);
+ int kp1 = canonicalize(k + 1, t->z_sz);
+
+ if (install_tswitch(t, i, j, k,
+ tfind_face_corner(t->sw[ip1][j][k],
+ t->sw[ip1][j][kp1],
+ t->sw[i][j][kp1]))) {
+ return true;
+ }
+ log_no_crnr(t, 0x705, i, j, k, i, j, k);
+
+ if (install_tswitch(t, i, jp1, k,
+ tfind_face_corner(t->sw[ip1][jp1][k],
+ t->sw[ip1][jp1][kp1],
+ t->sw[i][jp1][kp1]))) {
+ return true;
+ }
+ log_no_crnr(t, 0x705, i, j, k, i, jp1, k);
+ return false;
+}
+
+/*
+ * 3D case 0x70a: O
+ * . . .
+ * b0: t->sw[i ][j ][k ] . .
+ * b1: . .
+ * b2: t->sw[i ][j+1][k ] . .
+ * b3: O O
+ * b4: t->sw[i ][j ][k+1] . . O .
+ * b5: t->sw[i+1][j ][k+1] . . .
+ * b6: t->sw[i ][j+1][k+1] . . .
+ * b7: t->sw[i+1][j+1][k+1] . . .
+ * . O
+ * O . O
+ * . .
+ * . .
+ * . .
+ * . .
+ * @
+ */
+static
+bool handle_case_0x70a(struct torus *t, int i, int j, int k)
+{
+ int ip1 = canonicalize(i + 1, t->x_sz);
+ int jp1 = canonicalize(j + 1, t->y_sz);
+ int kp1 = canonicalize(k + 1, t->z_sz);
+
+ if (install_tswitch(t, ip1, j, k,
+ tfind_face_corner(t->sw[i][j][k],
+ t->sw[i][j][kp1],
+ t->sw[ip1][j][kp1]))) {
+ return true;
+ }
+ log_no_crnr(t, 0x70a, i, j, k, ip1, j, k);
+
+ if (install_tswitch(t, ip1, jp1, k,
+ tfind_face_corner(t->sw[i][jp1][k],
+ t->sw[i][jp1][kp1],
+ t->sw[ip1][jp1][kp1]))) {
+ return true;
+ }
+ log_no_crnr(t, 0x70a, i, j, k, ip1, jp1, k);
+ return false;
+}
+
+/*
+ * 3D case 0x70c: O
+ * . .
+ * b0: t->sw[i ][j ][k ] . .
+ * b1: t->sw[i+1][j ][k ] . .
+ * b2: . .
+ * b3: O O
+ * b4: t->sw[i ][j ][k+1] . O . .
+ * b5: t->sw[i+1][j ][k+1] . . .
+ * b6: t->sw[i ][j+1][k+1] . . .
+ * b7: t->sw[i+1][j+1][k+1] . . .
+ * O .
+ * O . O
+ * . .
+ * . .
+ * . .
+ * . .
+ * @
+ */
+static
+bool handle_case_0x70c(struct torus *t, int i, int j, int k)
+{
+ int ip1 = canonicalize(i + 1, t->x_sz);
+ int jp1 = canonicalize(j + 1, t->y_sz);
+ int kp1 = canonicalize(k + 1, t->z_sz);
+
+ if (install_tswitch(t, i, jp1, k,
+ tfind_face_corner(t->sw[i][j][k],
+ t->sw[i][j][kp1],
+ t->sw[i][jp1][kp1]))) {
+ return true;
+ }
+ log_no_crnr(t, 0x70c, i, j, k, i, jp1, k);
+
+ if (install_tswitch(t, ip1, jp1, k,
+ tfind_face_corner(t->sw[ip1][j][k],
+ t->sw[ip1][j][kp1],
+ t->sw[ip1][jp1][kp1]))) {
+ return true;
+ }
+ log_no_crnr(t, 0x70c, i, j, k, ip1, jp1, k);
+ return false;
+}
+
+/*
+ * 3D case 0x711: O
+ * . . .
+ * b0: . . .
+ * b1: t->sw[i+1][j ][k ] . . .
+ * b2: t->sw[i ][j+1][k ] . . .
+ * b3: t->sw[i+1][j+1][k ] O . O
+ * b4: . O .
+ * b5: t->sw[i+1][j ][k+1] . . . .
+ * b6: t->sw[i ][j+1][k+1] . . . .
+ * b7: t->sw[i+1][j+1][k+1] . . . .
+ * . . O . .
+ * O O
+ *
+ *
+ *
+ *
+ * @
+ */
+static
+bool handle_case_0x711(struct torus *t, int i, int j, int k)
+{
+ int ip1 = canonicalize(i + 1, t->x_sz);
+ int jp1 = canonicalize(j + 1, t->y_sz);
+ int kp1 = canonicalize(k + 1, t->z_sz);
+
+ if (install_tswitch(t, i, j, k,
+ tfind_face_corner(t->sw[ip1][j][k],
+ t->sw[ip1][jp1][k],
+ t->sw[i][jp1][k]))) {
+ return true;
+ }
+ log_no_crnr(t, 0x711, i, j, k, i, j, k);
+
+ if (install_tswitch(t, i, j, kp1,
+ tfind_face_corner(t->sw[ip1][j][kp1],
+ t->sw[ip1][jp1][kp1],
+ t->sw[i][jp1][kp1]))) {
+ return true;
+ }
+ log_no_crnr(t, 0x711, i, j, k, i, j, kp1);
+ return false;
+}
+
+/*
+ * 3D case 0x722: O
+ * . .
+ * b0: t->sw[i ][j ][k ] . .
+ * b1: . .
+ * b2: t->sw[i ][j+1][k ] . .
+ * b3: t->sw[i+1][j+1][k ] O . O
+ * b4: t->sw[i ][j ][k+1] . . O
+ * b5: . . .
+ * b6: t->sw[i ][j+1][k+1] . .
+ * b7: t->sw[i+1][j+1][k+1] . . .
+ * . . O
+ * O . O
+ * . .
+ * . .
+ * . .
+ * . .
+ * @
+ */
+static
+bool handle_case_0x722(struct torus *t, int i, int j, int k)
+{
+ int ip1 = canonicalize(i + 1, t->x_sz);
+ int jp1 = canonicalize(j + 1, t->y_sz);
+ int kp1 = canonicalize(k + 1, t->z_sz);
+
+ if (install_tswitch(t, ip1, j, k,
+ tfind_face_corner(t->sw[i][j][k],
+ t->sw[i][jp1][k],
+ t->sw[ip1][jp1][k]))) {
+ return true;
+ }
+ log_no_crnr(t, 0x722, i, j, k, ip1, j, k);
+
+ if (install_tswitch(t, ip1, j, kp1,
+ tfind_face_corner(t->sw[i][j][kp1],
+ t->sw[i][jp1][kp1],
+ t->sw[ip1][jp1][kp1]))) {
+ return true;
+ }
+ log_no_crnr(t, 0x722, i, j, k, ip1, j, kp1);
+ return false;
+}
+
+/*
+ * 3D case 0x730: O
+ * . .
+ * b0: t->sw[i ][j ][k ] . .
+ * b1: t->sw[i+1][j ][k ] . .
+ * b2: t->sw[i ][j+1][k ] . .
+ * b3: t->sw[i+1][j+1][k ] O . O
+ * b4: . O
+ * b5: . . .
+ * b6: t->sw[i ][j+1][k+1] . . .
+ * b7: t->sw[i+1][j+1][k+1] . . .
+ * . . O .
+ * O O
+ * . .
+ * . .
+ * . .
+ * . .
+ * @
+ */
+static
+bool handle_case_0x730(struct torus *t, int i, int j, int k)
+{
+ int ip1 = canonicalize(i + 1, t->x_sz);
+ int jp1 = canonicalize(j + 1, t->y_sz);
+ int kp1 = canonicalize(k + 1, t->z_sz);
+
+ if (install_tswitch(t, i, j, kp1,
+ tfind_face_corner(t->sw[i][j][k],
+ t->sw[i][jp1][k],
+ t->sw[i][jp1][kp1]))) {
+ return true;
+ }
+ log_no_crnr(t, 0x730, i, j, k, i, j, kp1);
+
+ if (install_tswitch(t, ip1, j, kp1,
+ tfind_face_corner(t->sw[ip1][j][k],
+ t->sw[ip1][jp1][k],
+ t->sw[ip1][jp1][kp1]))) {
+ return true;
+ }
+ log_no_crnr(t, 0x730, i, j, k, ip1, j, kp1);
+ return false;
+}
+
+/*
+ * 3D case 0x744: O
+ * . .
+ * b0: t->sw[i ][j ][k ] . .
+ * b1: t->sw[i+1][j ][k ] . .
+ * b2: . .
+ * b3: t->sw[i+1][j+1][k ] O . O
+ * b4: t->sw[i ][j ][k+1] O . .
+ * b5: t->sw[i+1][j ][k+1] . . .
+ * b6: . .
+ * b7: t->sw[i+1][j+1][k+1] . . .
+ * O . .
+ * O . O
+ * . .
+ * . .
+ * . .
+ * . .
+ * @
+ */
+static
+bool handle_case_0x744(struct torus *t, int i, int j, int k)
+{
+ int ip1 = canonicalize(i + 1, t->x_sz);
+ int jp1 = canonicalize(j + 1, t->y_sz);
+ int kp1 = canonicalize(k + 1, t->z_sz);
+
+ if (install_tswitch(t, i, jp1, k,
+ tfind_face_corner(t->sw[i][j][k],
+ t->sw[ip1][j][k],
+ t->sw[ip1][jp1][k]))) {
+ return true;
+ }
+ log_no_crnr(t, 0x744, i, j, k, i, jp1, k);
+
+ if (install_tswitch(t, i, jp1, kp1,
+ tfind_face_corner(t->sw[i][j][kp1],
+ t->sw[ip1][j][kp1],
+ t->sw[ip1][jp1][kp1]))) {
+ return true;
+ }
+ log_no_crnr(t, 0x744, i, j, k, i, jp1, kp1);
+ return false;
+}
+
+/*
+ * 3D case 0x750: O
+ * . .
+ * b0: t->sw[i ][j ][k ] . .
+ * b1: t->sw[i+1][j ][k ] . .
+ * b2: t->sw[i ][j+1][k ] . .
+ * b3: t->sw[i+1][j+1][k ] O . O
+ * b4: O .
+ * b5: t->sw[i+1][j ][k+1] . . .
+ * b6: . . .
+ * b7: t->sw[i+1][j+1][k+1] . . .
+ * . O . .
+ * O O
+ * . .
+ * . .
+ * . .
+ * . .
+ * @
+ */
+static
+bool handle_case_0x750(struct torus *t, int i, int j, int k)
+{
+ int ip1 = canonicalize(i + 1, t->x_sz);
+ int jp1 = canonicalize(j + 1, t->y_sz);
+ int kp1 = canonicalize(k + 1, t->z_sz);
+
+ if (install_tswitch(t, i, j, kp1,
+ tfind_face_corner(t->sw[i][j][k],
+ t->sw[ip1][j][k],
+ t->sw[ip1][j][kp1]))) {
+ return true;
+ }
+ log_no_crnr(t, 0x750, i, j, k, i, j, kp1);
+
+ if (install_tswitch(t, i, jp1, kp1,
+ tfind_face_corner(t->sw[i][jp1][k],
+ t->sw[ip1][jp1][k],
+ t->sw[ip1][jp1][kp1]))) {
+ return true;
+ }
+ log_no_crnr(t, 0x750, i, j, k, i, jp1, kp1);
+ return false;
+}
+
+/*
+ * 3D case 0x788: O
+ *
+ * b0: t->sw[i ][j ][k ]
+ * b1: t->sw[ip1][j ][k ]
+ * b2: t->sw[i ][j+1][k ]
+ * b3: O O
+ * b4: t->sw[i ][j ][k+1] . . O . .
+ * b5: t->sw[i+1][j ][k+1] . . . .
+ * b6: t->sw[i ][j+1][k+1] . . . .
+ * b7: . . . .
+ * . O .
+ * O . O
+ * . . .
+ * . . .
+ * . . .
+ * . . .
+ * @
+ */
+static
+bool handle_case_0x788(struct torus *t, int i, int j, int k)
+{
+ int ip1 = canonicalize(i + 1, t->x_sz);
+ int jp1 = canonicalize(j + 1, t->y_sz);
+ int kp1 = canonicalize(k + 1, t->z_sz);
+
+ if (install_tswitch(t, ip1, jp1, k,
+ tfind_face_corner(t->sw[ip1][j][k],
+ t->sw[i][j][k],
+ t->sw[i][jp1][k]))) {
+ return true;
+ }
+ log_no_crnr(t, 0x788, i, j, k, ip1, jp1, k);
+
+ if (install_tswitch(t, ip1, jp1, kp1,
+ tfind_face_corner(t->sw[ip1][j][kp1],
+ t->sw[i][j][kp1],
+ t->sw[i][jp1][kp1]))) {
+ return true;
+ }
+ log_no_crnr(t, 0x788, i, j, k, ip1, jp1, kp1);
+ return false;
+}
+
+/*
+ * 3D case 0x7a0: O
+ *
+ * b0: t->sw[i ][j ][k ]
+ * b1: t->sw[i+1][j ][k ]
+ * b2: t->sw[i ][j+1][k ]
+ * b3: t->sw[i+1][j+1][k ] O O
+ * b4: t->sw[i ][j ][k+1] . . O
+ * b5: . . . .
+ * b6: t->sw[i ][j+1][k+1] . . .
+ * b7: . . . .
+ * . . O .
+ * O . O
+ * . . .
+ * . . .
+ * . . .
+ * . . .
+ * @
+ */
+static
+bool handle_case_0x7a0(struct torus *t, int i, int j, int k)
+{
+ int ip1 = canonicalize(i + 1, t->x_sz);
+ int jp1 = canonicalize(j + 1, t->y_sz);
+ int kp1 = canonicalize(k + 1, t->z_sz);
+
+ if (install_tswitch(t, ip1, j, kp1,
+ tfind_face_corner(t->sw[i][j][kp1],
+ t->sw[i][j][k],
+ t->sw[ip1][j][k]))) {
+ return true;
+ }
+ log_no_crnr(t, 0x7a0, i, j, k, ip1, j, kp1);
+
+ if (install_tswitch(t, ip1, jp1, kp1,
+ tfind_face_corner(t->sw[i][jp1][kp1],
+ t->sw[i][jp1][k],
+ t->sw[ip1][jp1][k]))) {
+ return true;
+ }
+ log_no_crnr(t, 0x7a0, i, j, k, ip1, jp1, kp1);
+ return false;
+}
+
+/*
+ * 3D case 0x7c0: O
+ *
+ * b0: t->sw[i ][j ][k ]
+ * b1: t->sw[i+1][j ][k ]
+ * b2: t->sw[i ][j+1][k ]
+ * b3: t->sw[i+1][j+1][k ] O O
+ * b4: t->sw[i ][j ][k+1] O . .
+ * b5: t->sw[i+1][j ][k+1] . . . .
+ * b6: . . .
+ * b7: . . . .
+ * . O . .
+ * O . O
+ * . . .
+ * . . .
+ * . . .
+ * . . .
+ * @
+ */
+static
+bool handle_case_0x7c0(struct torus *t, int i, int j, int k)
+{
+ int ip1 = canonicalize(i + 1, t->x_sz);
+ int jp1 = canonicalize(j + 1, t->y_sz);
+ int kp1 = canonicalize(k + 1, t->z_sz);
+
+ if (install_tswitch(t, i, jp1, kp1,
+ tfind_face_corner(t->sw[i][j][kp1],
+ t->sw[i][j][k],
+ t->sw[i][jp1][k]))) {
+ return true;
+ }
+ log_no_crnr(t, 0x7c0, i, j, k, i, jp1, kp1);
+
+ if (install_tswitch(t, ip1, jp1, kp1,
+ tfind_face_corner(t->sw[ip1][j][kp1],
+ t->sw[ip1][j][k],
+ t->sw[ip1][jp1][k]))) {
+ return true;
+ }
+ log_no_crnr(t, 0x7c0, i, j, k, ip1, jp1, kp1);
+ return false;
+}
+
+/*
+ * Handle the cases where a single corner is missing.
+ */
+
+/*
+ * 3D case 0x701: O
+ * . . .
+ * b0: . . .
+ * b1: t->sw[i+1][j ][k ] . . .
+ * b2: t->sw[i ][j+1][k ] . . .
+ * b3: t->sw[i+1][j+1][k ] O . O
+ * b4: t->sw[i ][j ][k+1] . . O . .
+ * b5: t->sw[i+1][j ][k+1] . . . . . .
+ * b6: t->sw[i ][j+1][k+1] . . . .
+ * b7: t->sw[i+1][j+1][k+1] . . . . . .
+ * . . O . .
+ * O O
+ *
+ *
+ *
+ *
+ * @
+ */
+static
+bool handle_case_0x701(struct torus *t, int i, int j, int k)
+{
+ int ip1 = canonicalize(i + 1, t->x_sz);
+ int jp1 = canonicalize(j + 1, t->y_sz);
+
+ if (install_tswitch(t, i, j, k,
+ tfind_face_corner(t->sw[i][jp1][k],
+ t->sw[ip1][jp1][k],
+ t->sw[ip1][j][k]))) {
+ return true;
+ }
+ log_no_crnr(t, 0x701, i, j, k, i, j, k);
+ return false;
+}
+
+/*
+ * 3D case 0x702: O
+ * . . .
+ * b0: t->sw[i ][j ][k ] . . .
+ * b1: . . .
+ * b2: t->sw[i ][j+1][k ] . . .
+ * b3: t->sw[i+1][j+1][k ] O . O
+ * b4: t->sw[i ][j ][k+1] . . O .
+ * b5: t->sw[i+1][j ][k+1] . . . .
+ * b6: t->sw[i ][j+1][k+1] . . .
+ * b7: t->sw[i+1][j+1][k+1] . . . .
+ * . . O
+ * O . O
+ * . .
+ * . .
+ * . .
+ * . .
+ * @
+ */
+static
+bool handle_case_0x702(struct torus *t, int i, int j, int k)
+{
+ int ip1 = canonicalize(i + 1, t->x_sz);
+ int kp1 = canonicalize(k + 1, t->z_sz);
+
+ if (install_tswitch(t, ip1, j, k,
+ tfind_face_corner(t->sw[i][j][k],
+ t->sw[i][j][kp1],
+ t->sw[ip1][j][kp1]))) {
+ return true;
+ }
+ log_no_crnr(t, 0x702, i, j, k, ip1, j, k);
+ return false;
+}
+
+/*
+ * 3D case 0x704: O
+ * . . .
+ * b0: t->sw[i ][j ][k ] . . .
+ * b1: t->sw[i+1][j ][k ] . . .
+ * b2: . . .
+ * b3: t->sw[i+1][j+1][k ] O . O
+ * b4: t->sw[i ][j ][k+1] . O . .
+ * b5: t->sw[i+1][j ][k+1] . . . .
+ * b6: t->sw[i ][j+1][k+1] . . .
+ * b7: t->sw[i+1][j+1][k+1] . . . .
+ * O . .
+ * O . O
+ * . .
+ * . .
+ * . .
+ * . .
+ * @
+ */
+static
+bool handle_case_0x704(struct torus *t, int i, int j, int k)
+{
+ int jp1 = canonicalize(j + 1, t->y_sz);
+ int kp1 = canonicalize(k + 1, t->z_sz);
+
+ if (install_tswitch(t, i, jp1, k,
+ tfind_face_corner(t->sw[i][j][k],
+ t->sw[i][j][kp1],
+ t->sw[i][jp1][kp1]))) {
+ return true;
+ }
+ log_no_crnr(t, 0x704, i, j, k, i, jp1, k);
+ return false;
+}
+
+/*
+ * 3D case 0x708: O
+ * . .
+ * b0: t->sw[i ][j ][k ] . .
+ * b1: t->sw[i+1][j ][k ] . .
+ * b2: t->sw[i ][j+1][k ] . .
+ * b3: O O
+ * b4: t->sw[i ][j ][k+1] . . O . .
+ * b5: t->sw[i+1][j ][k+1] . . . .
+ * b6: t->sw[i ][j+1][k+1] . . . .
+ * b7: t->sw[i+1][j+1][k+1] . . . .
+ * . O .
+ * O . O
+ * . . .
+ * . . .
+ * . . .
+ * . . .
+ * @
+ */
+static
+bool handle_case_0x708(struct torus *t, int i, int j, int k)
+{
+ int ip1 = canonicalize(i + 1, t->x_sz);
+ int jp1 = canonicalize(j + 1, t->y_sz);
+
+ if (install_tswitch(t, ip1, jp1, k,
+ tfind_face_corner(t->sw[i][jp1][k],
+ t->sw[i][j][k],
+ t->sw[ip1][j][k]))) {
+ return true;
+ }
+ log_no_crnr(t, 0x708, i, j, k, ip1, jp1, k);
+ return false;
+}
+
+/*
+ * 3D case 0x710: O
+ * . . .
+ * b0: t->sw[i ][j ][k ] . . .
+ * b1: t->sw[i+1][j ][k ] . . .
+ * b2: t->sw[i ][j+1][k ] . . .
+ * b3: t->sw[i+1][j+1][k ] O . O
+ * b4: . O .
+ * b5: t->sw[i+1][j ][k+1] . . . .
+ * b6: t->sw[i ][j+1][k+1] . . . .
+ * b7: t->sw[i+1][j+1][k+1] . . . .
+ * . . O . .
+ * O O
+ * . .
+ * . .
+ * . .
+ * . .
+ * @
+ */
+static
+bool handle_case_0x710(struct torus *t, int i, int j, int k)
+{
+ int ip1 = canonicalize(i + 1, t->x_sz);
+ int kp1 = canonicalize(k + 1, t->z_sz);
+
+ if (install_tswitch(t, i, j, kp1,
+ tfind_face_corner(t->sw[i][j][k],
+ t->sw[ip1][j][k],
+ t->sw[ip1][j][kp1]))) {
+ return true;
+ }
+ log_no_crnr(t, 0x710, i, j, k, i, j, kp1);
+ return false;
+}
+
+/*
+ * 3D case 0x720: O
+ * . .
+ * b0: t->sw[i ][j ][k ] . .
+ * b1: t->sw[i+1][j ][k ] . .
+ * b2: t->sw[i ][j+1][k ] . .
+ * b3: t->sw[i+1][j+1][k ] O . O
+ * b4: t->sw[i ][j ][k+1] . . O
+ * b5: . . . .
+ * b6: t->sw[i ][j+1][k+1] . . .
+ * b7: t->sw[i+1][j+1][k+1] . . . .
+ * . . O .
+ * O . O
+ * . . .
+ * . . .
+ * . . .
+ * . . .
+ * @
+ */
+static
+bool handle_case_0x720(struct torus *t, int i, int j, int k)
+{
+ int ip1 = canonicalize(i + 1, t->x_sz);
+ int kp1 = canonicalize(k + 1, t->z_sz);
+
+ if (install_tswitch(t, ip1, j, kp1,
+ tfind_face_corner(t->sw[ip1][j][k],
+ t->sw[i][j][k],
+ t->sw[i][j][kp1]))) {
+ return true;
+ }
+ log_no_crnr(t, 0x720, i, j, k, ip1, j, kp1);
+ return false;
+}
+
+/*
+ * 3D case 0x740: O
+ * . .
+ * b0: t->sw[i ][j ][k ] . .
+ * b1: t->sw[i+1][j ][k ] . .
+ * b2: t->sw[i ][j+1][k ] . .
+ * b3: t->sw[i+1][j+1][k ] O . O
+ * b4: t->sw[i ][j ][k+1] O . .
+ * b5: t->sw[i+1][j ][k+1] . . . .
+ * b6: . . .
+ * b7: t->sw[i+1][j+1][k+1] . . . .
+ * . O . .
+ * O . O
+ * . . .
+ * . . .
+ * . . .
+ * . . .
+ * @
+ */
+static
+bool handle_case_0x740(struct torus *t, int i, int j, int k)
+{
+ int jp1 = canonicalize(j + 1, t->y_sz);
+ int kp1 = canonicalize(k + 1, t->z_sz);
+
+ if (install_tswitch(t, i, jp1, kp1,
+ tfind_face_corner(t->sw[i][jp1][k],
+ t->sw[i][j][k],
+ t->sw[i][j][kp1]))) {
+ return true;
+ }
+ log_no_crnr(t, 0x740, i, j, k, i, jp1, kp1);
+ return false;
+}
+
+/*
+ * 3D case 0x780: O
+ *
+ * b0: t->sw[i ][j ][k ]
+ * b1: t->sw[i+1][j ][k ]
+ * b2: t->sw[i ][j+1][k ]
+ * b3: t->sw[i+1][j+1][k ] O O
+ * b4: t->sw[i ][j ][k+1] . . O . .
+ * b5: t->sw[i+1][j ][k+1] . . . . . .
+ * b6: t->sw[i ][j+1][k+1] . . . .
+ * b7: . . . . . .
+ * . . O . .
+ * O . O
+ * . . .
+ * . . .
+ * . . .
+ * . . .
+ * @
+ */
+static
+bool handle_case_0x780(struct torus *t, int i, int j, int k)
+{
+ int ip1 = canonicalize(i + 1, t->x_sz);
+ int jp1 = canonicalize(j + 1, t->y_sz);
+ int kp1 = canonicalize(k + 1, t->z_sz);
+
+ if (install_tswitch(t, ip1, jp1, kp1,
+ tfind_face_corner(t->sw[i][jp1][kp1],
+ t->sw[i][j][kp1],
+ t->sw[ip1][j][kp1]))) {
+ return true;
+ }
+ log_no_crnr(t, 0x780, i, j, k, ip1, jp1, kp1);
+ return false;
+}
+
+/*
+ * Make sure links between all known torus/mesh switches are installed.
+ *
+ * We don't have to worry about links that wrap on a mesh coordinate, as
+ * there shouldn't be any; if there are it indicates an input error.
+ */
+static
+void check_tlinks(struct torus *t, int i, int j, int k)
+{
+ struct t_switch ****sw = t->sw;
+ int ip1 = canonicalize(i + 1, t->x_sz);
+ int jp1 = canonicalize(j + 1, t->y_sz);
+ int kp1 = canonicalize(k + 1, t->z_sz);
+
+ /*
+ * Don't waste time/code checking return status of link_tswitches()
+ * here. It is unlikely to fail, and the result of any failure here
+ * will be caught elsewhere anyway.
+ */
+ if (sw[i][j][k] && sw[ip1][j][k])
+ link_tswitches(t, 0, sw[i][j][k], sw[ip1][j][k]);
+
+ if (sw[i][jp1][k] && sw[ip1][jp1][k])
+ link_tswitches(t, 0, sw[i][jp1][k], sw[ip1][jp1][k]);
+
+ if (sw[i][j][kp1] && sw[ip1][j][kp1])
+ link_tswitches(t, 0, sw[i][j][kp1], sw[ip1][j][kp1]);
+
+ if (sw[i][jp1][kp1] && sw[ip1][jp1][kp1])
+ link_tswitches(t, 0, sw[i][jp1][kp1], sw[ip1][jp1][kp1]);
+
+
+ if (sw[i][j][k] && sw[i][jp1][k])
+ link_tswitches(t, 1, sw[i][j][k], sw[i][jp1][k]);
+
+ if (sw[ip1][j][k] && sw[ip1][jp1][k])
+ link_tswitches(t, 1, sw[ip1][j][k], sw[ip1][jp1][k]);
+
+ if (sw[i][j][kp1] && sw[i][jp1][kp1])
+ link_tswitches(t, 1, sw[i][j][kp1], sw[i][jp1][kp1]);
+
+ if (sw[ip1][j][kp1] && sw[ip1][jp1][kp1])
+ link_tswitches(t, 1, sw[ip1][j][kp1], sw[ip1][jp1][kp1]);
+
+
+ if (sw[i][j][k] && sw[i][j][kp1])
+ link_tswitches(t, 2, sw[i][j][k], sw[i][j][kp1]);
+
+ if (sw[ip1][j][k] && sw[ip1][j][kp1])
+ link_tswitches(t, 2, sw[ip1][j][k], sw[ip1][j][kp1]);
+
+ if (sw[i][jp1][k] && sw[i][jp1][kp1])
+ link_tswitches(t, 2, sw[i][jp1][k], sw[i][jp1][kp1]);
+
+ if (sw[ip1][jp1][k] && sw[ip1][jp1][kp1])
+ link_tswitches(t, 2, sw[ip1][jp1][k], sw[ip1][jp1][kp1]);
+}
+
+static
+void locate_sw(struct torus *t, int i, int j, int k)
+{
+ unsigned fp;
+ bool success;
+
+ i = canonicalize(i, t->x_sz);
+ j = canonicalize(j, t->y_sz);
+ k = canonicalize(k, t->z_sz);
+
+ /*
+ * By definition, if a coordinate direction is meshed, we don't
+ * allow it to wrap to zero.
+ */
+ if (t->flags & X_MESH) {
+ int ip1 = canonicalize(i + 1, t->x_sz);
+ if (ip1 < i)
+ goto out;
+ }
+ if (t->flags & Y_MESH) {
+ int jp1 = canonicalize(j + 1, t->y_sz);
+ if (jp1 < j)
+ goto out;
+ }
+ if (t->flags & Z_MESH) {
+ int kp1 = canonicalize(k + 1, t->z_sz);
+ if (kp1 < k)
+ goto out;
+ }
+ /*
+ * There are various reasons that the links are not installed between
+ * known torus switches. These include cases where the search for
+ * new switches only partially succeeds due to missing switches, and
+ * cases where we haven't processed this position yet, but processing
+ * of multiple independent neighbor positions has installed switches
+ * into corners of our case.
+ *
+ * In any event, the topology assumptions made in handling the
+ * fingerprint for this position require that all links be installed
+ * between installed switches for this position.
+ */
+again:
+ check_tlinks(t, i, j, k);
+ fp = fingerprint(t, i, j, k);
+
+ switch (fp) {
+ /*
+ * When all switches are present, we are done. Otherwise, one of
+ * the cases below will be unsuccessful, and we'll be done also.
+ *
+ * Note that check_tlinks() above will ensure all links that are
+ * present are connected, in the event that all our switches are
+ * present due to successful case handling in the surrounding
+ * torus/mesh.
+ */
+ case 0x300:
+ case 0x500:
+ case 0x600:
+ case 0x700:
+ goto out;
+ /*
+ * Ignore the 2D cases where there isn't enough information to uniquely
+ * locate/place a switch into the cube.
+ */
+ case 0x30f: /* 0 corners available */
+ case 0x533: /* 0 corners available */
+ case 0x655: /* 0 corners available */
+ case 0x30e: /* 1 corner available */
+ case 0x532: /* 1 corner available */
+ case 0x654: /* 1 corner available */
+ case 0x30d: /* 1 corner available */
+ case 0x531: /* 1 corner available */
+ case 0x651: /* 1 corner available */
+ case 0x30b: /* 1 corner available */
+ case 0x523: /* 1 corner available */
+ case 0x645: /* 1 corner available */
+ case 0x307: /* 1 corner available */
+ case 0x513: /* 1 corner available */
+ case 0x615: /* 1 corner available */
+ goto out;
+ /*
+ * Handle the 2D cases with a single existing edge.
+ *
+ */
+ case 0x30c:
+ success = handle_case_0x30c(t, i, j, k);
+ break;
+ case 0x303:
+ success = handle_case_0x303(t, i, j, k);
+ break;
+ case 0x305:
+ success = handle_case_0x305(t, i, j, k);
+ break;
+ case 0x30a:
+ success = handle_case_0x30a(t, i, j, k);
+ break;
+ case 0x503:
+ success = handle_case_0x503(t, i, j, k);
+ break;
+ case 0x511:
+ success = handle_case_0x511(t, i, j, k);
+ break;
+ case 0x522:
+ success = handle_case_0x522(t, i, j, k);
+ break;
+ case 0x530:
+ success = handle_case_0x530(t, i, j, k);
+ break;
+ case 0x605:
+ success = handle_case_0x605(t, i, j, k);
+ break;
+ case 0x611:
+ success = handle_case_0x611(t, i, j, k);
+ break;
+ case 0x644:
+ success = handle_case_0x644(t, i, j, k);
+ break;
+ case 0x650:
+ success = handle_case_0x650(t, i, j, k);
+ break;
+ /*
+ * Handle the 2D cases where two existing edges meet at a corner.
+ */
+ case 0x301:
+ success = handle_case_0x301(t, i, j, k);
+ break;
+ case 0x302:
+ success = handle_case_0x302(t, i, j, k);
+ break;
+ case 0x304:
+ success = handle_case_0x304(t, i, j, k);
+ break;
+ case 0x308:
+ success = handle_case_0x308(t, i, j, k);
+ break;
+ case 0x501:
+ success = handle_case_0x501(t, i, j, k);
+ break;
+ case 0x502:
+ success = handle_case_0x502(t, i, j, k);
+ break;
+ case 0x520:
+ success = handle_case_0x520(t, i, j, k);
+ break;
+ case 0x510:
+ success = handle_case_0x510(t, i, j, k);
+ break;
+ case 0x601:
+ success = handle_case_0x601(t, i, j, k);
+ break;
+ case 0x604:
+ success = handle_case_0x604(t, i, j, k);
+ break;
+ case 0x610:
+ success = handle_case_0x610(t, i, j, k);
+ break;
+ case 0x640:
+ success = handle_case_0x640(t, i, j, k);
+ break;
+ /*
+ * Ignore the 3D cases where there isn't enough information to uniquely
+ * locate/place a switch into the cube.
+ */
+ case 0x7ff: /* 0 corners available */
+ case 0x7fe: /* 1 corner available */
+ case 0x7fd: /* 1 corner available */
+ case 0x7fb: /* 1 corner available */
+ case 0x7f7: /* 1 corner available */
+ case 0x7ef: /* 1 corner available */
+ case 0x7df: /* 1 corner available */
+ case 0x7bf: /* 1 corner available */
+ case 0x77f: /* 1 corner available */
+ case 0x7fc: /* 2 adj corners available */
+ case 0x7fa: /* 2 adj corners available */
+ case 0x7f5: /* 2 adj corners available */
+ case 0x7f3: /* 2 adj corners available */
+ case 0x7cf: /* 2 adj corners available */
+ case 0x7af: /* 2 adj corners available */
+ case 0x75f: /* 2 adj corners available */
+ case 0x73f: /* 2 adj corners available */
+ case 0x7ee: /* 2 adj corners available */
+ case 0x7dd: /* 2 adj corners available */
+ case 0x7bb: /* 2 adj corners available */
+ case 0x777: /* 2 adj corners available */
+ goto out;
+ /*
+ * Handle the 3D cases where two existing edges meet at a corner.
+ *
+ */
+ case 0x71f:
+ success = handle_case_0x71f(t, i, j, k);
+ break;
+ case 0x72f:
+ success = handle_case_0x72f(t, i, j, k);
+ break;
+ case 0x737:
+ success = handle_case_0x737(t, i, j, k);
+ break;
+ case 0x73b:
+ success = handle_case_0x73b(t, i, j, k);
+ break;
+ case 0x74f:
+ success = handle_case_0x74f(t, i, j, k);
+ break;
+ case 0x757:
+ success = handle_case_0x757(t, i, j, k);
+ break;
+ case 0x75d:
+ success = handle_case_0x75d(t, i, j, k);
+ break;
+ case 0x773:
+ success = handle_case_0x773(t, i, j, k);
+ break;
+ case 0x775:
+ success = handle_case_0x775(t, i, j, k);
+ break;
+ case 0x78f:
+ success = handle_case_0x78f(t, i, j, k);
+ break;
+ case 0x7ab:
+ success = handle_case_0x7ab(t, i, j, k);
+ break;
+ case 0x7ae:
+ success = handle_case_0x7ae(t, i, j, k);
+ break;
+ case 0x7b3:
+ success = handle_case_0x7b3(t, i, j, k);
+ break;
+ case 0x7ba:
+ success = handle_case_0x7ba(t, i, j, k);
+ break;
+ case 0x7cd:
+ success = handle_case_0x7cd(t, i, j, k);
+ break;
+ case 0x7ce:
+ success = handle_case_0x7ce(t, i, j, k);
+ break;
+ case 0x7d5:
+ success = handle_case_0x7d5(t, i, j, k);
+ break;
+ case 0x7dc:
+ success = handle_case_0x7dc(t, i, j, k);
+ break;
+ case 0x7ea:
+ success = handle_case_0x7ea(t, i, j, k);
+ break;
+ case 0x7ec:
+ success = handle_case_0x7ec(t, i, j, k);
+ break;
+ case 0x7f1:
+ success = handle_case_0x7f1(t, i, j, k);
+ break;
+ case 0x7f2:
+ success = handle_case_0x7f2(t, i, j, k);
+ break;
+ case 0x7f4:
+ success = handle_case_0x7f4(t, i, j, k);
+ break;
+ case 0x7f8:
+ success = handle_case_0x7f8(t, i, j, k);
+ break;
+ /*
+ * Handle the cases where three existing edges meet at a corner.
+ *
+ */
+ case 0x717:
+ success = handle_case_0x717(t, i, j, k);
+ break;
+ case 0x72b:
+ success = handle_case_0x72b(t, i, j, k);
+ break;
+ case 0x74d:
+ success = handle_case_0x74d(t, i, j, k);
+ break;
+ case 0x771:
+ success = handle_case_0x771(t, i, j, k);
+ break;
+ case 0x78e:
+ success = handle_case_0x78e(t, i, j, k);
+ break;
+ case 0x7b2:
+ success = handle_case_0x7b2(t, i, j, k);
+ break;
+ case 0x7d4:
+ success = handle_case_0x7d4(t, i, j, k);
+ break;
+ case 0x7e8:
+ success = handle_case_0x7e8(t, i, j, k);
+ break;
+ /*
+ * Handle the cases where four corners on a single face are missing.
+ */
+ case 0x70f:
+ success = handle_case_0x70f(t, i, j, k);
+ break;
+ case 0x733:
+ success = handle_case_0x733(t, i, j, k);
+ break;
+ case 0x755:
+ success = handle_case_0x755(t, i, j, k);
+ break;
+ case 0x7aa:
+ success = handle_case_0x7aa(t, i, j, k);
+ break;
+ case 0x7cc:
+ success = handle_case_0x7cc(t, i, j, k);
+ break;
+ case 0x7f0:
+ success = handle_case_0x7f0(t, i, j, k);
+ break;
+ /*
+ * Handle the cases where three corners on a single face are missing.
+ */
+ case 0x707:
+ success = handle_case_0x707(t, i, j, k);
+ break;
+ case 0x70b:
+ success = handle_case_0x70b(t, i, j, k);
+ break;
+ case 0x70d:
+ success = handle_case_0x70d(t, i, j, k);
+ break;
+ case 0x70e:
+ success = handle_case_0x70e(t, i, j, k);
+ break;
+ case 0x713:
+ success = handle_case_0x713(t, i, j, k);
+ break;
+ case 0x715:
+ success = handle_case_0x715(t, i, j, k);
+ break;
+ case 0x723:
+ success = handle_case_0x723(t, i, j, k);
+ break;
+ case 0x72a:
+ success = handle_case_0x72a(t, i, j, k);
+ break;
+ case 0x731:
+ success = handle_case_0x731(t, i, j, k);
+ break;
+ case 0x732:
+ success = handle_case_0x732(t, i, j, k);
+ break;
+ case 0x745:
+ success = handle_case_0x745(t, i, j, k);
+ break;
+ case 0x74c:
+ success = handle_case_0x74c(t, i, j, k);
+ break;
+ case 0x751:
+ success = handle_case_0x751(t, i, j, k);
+ break;
+ case 0x754:
+ success = handle_case_0x754(t, i, j, k);
+ break;
+ case 0x770:
+ success = handle_case_0x770(t, i, j, k);
+ break;
+ case 0x78a:
+ success = handle_case_0x78a(t, i, j, k);
+ break;
+ case 0x78c:
+ success = handle_case_0x78c(t, i, j, k);
+ break;
+ case 0x7a2:
+ success = handle_case_0x7a2(t, i, j, k);
+ break;
+ case 0x7a8:
+ success = handle_case_0x7a8(t, i, j, k);
+ break;
+ case 0x7b0:
+ success = handle_case_0x7b0(t, i, j, k);
+ break;
+ case 0x7c4:
+ success = handle_case_0x7c4(t, i, j, k);
+ break;
+ case 0x7c8:
+ success = handle_case_0x7c8(t, i, j, k);
+ break;
+ case 0x7d0:
+ success = handle_case_0x7d0(t, i, j, k);
+ break;
+ case 0x7e0:
+ success = handle_case_0x7e0(t, i, j, k);
+ break;
+ /*
+ * Handle the cases where two corners on a single edge are missing.
+ */
+ case 0x703:
+ success = handle_case_0x703(t, i, j, k);
+ break;
+ case 0x705:
+ success = handle_case_0x705(t, i, j, k);
+ break;
+ case 0x70a:
+ success = handle_case_0x70a(t, i, j, k);
+ break;
+ case 0x70c:
+ success = handle_case_0x70c(t, i, j, k);
+ break;
+ case 0x711:
+ success = handle_case_0x711(t, i, j, k);
+ break;
+ case 0x722:
+ success = handle_case_0x722(t, i, j, k);
+ break;
+ case 0x730:
+ success = handle_case_0x730(t, i, j, k);
+ break;
+ case 0x744:
+ success = handle_case_0x744(t, i, j, k);
+ break;
+ case 0x750:
+ success = handle_case_0x750(t, i, j, k);
+ break;
+ case 0x788:
+ success = handle_case_0x788(t, i, j, k);
+ break;
+ case 0x7a0:
+ success = handle_case_0x7a0(t, i, j, k);
+ break;
+ case 0x7c0:
+ success = handle_case_0x7c0(t, i, j, k);
+ break;
+ /*
+ * Handle the cases where a single corner is missing.
+ */
+ case 0x701:
+ success = handle_case_0x701(t, i, j, k);
+ break;
+ case 0x702:
+ success = handle_case_0x702(t, i, j, k);
+ break;
+ case 0x704:
+ success = handle_case_0x704(t, i, j, k);
+ break;
+ case 0x708:
+ success = handle_case_0x708(t, i, j, k);
+ break;
+ case 0x710:
+ success = handle_case_0x710(t, i, j, k);
+ break;
+ case 0x720:
+ success = handle_case_0x720(t, i, j, k);
+ break;
+ case 0x740:
+ success = handle_case_0x740(t, i, j, k);
+ break;
+ case 0x780:
+ success = handle_case_0x780(t, i, j, k);
+ break;
+
+ default:
+ /*
+ * There's lots of unhandled cases still, but it's not clear
+ * we care. Let debugging show us what they are so we can
+ * learn if we care.
+ */
+ if (t->debug)
+ OSM_LOG(&t->osm->log, OSM_LOG_ERROR,
+ "Unhandled fingerprint 0x%03x @ %d %d %d\n",
+ fp, i, j, k);
+ goto out;
+ }
+ /*
+ * If we successfully handled a case, we may be able to make more
+ * progress at this position, so try again. Otherwise, even though
+ * we didn't successfully handle a case, we may have installed a
+ * switch into the torus/mesh, so try to install links as well.
+ * Then we'll have another go at the next position.
+ */
+ if (success) {
+ if (t->debug)
+ OSM_LOG(&t->osm->log, OSM_LOG_ERROR,
+ "Success on fingerprint 0x%03x @ %d %d %d\n",
+ fp, i, j, k);
+ goto again;
+ } else {
+ check_tlinks(t, i, j, k);
+ if (t->debug)
+ OSM_LOG(&t->osm->log, OSM_LOG_ERROR,
+ "Failed on fingerprint 0x%03x @ %d %d %d\n",
+ fp, i, j, k);
+ }
+out:
+ return;
+}
+
+#define LINK_ERR_STR " direction link required for topology seed configuration since radix == 4! See torus-2QoS.conf(5).\n"
+#define LINK_ERR2_STR " direction link required for topology seed configuration! See torus-2QoS.conf(5).\n"
+#define SEED_ERR_STR " direction links for topology seed do not share a common switch! See torus-2QoS.conf(5).\n"
+
+static
+bool verify_setup(struct torus *t, struct fabric *f)
+{
+ struct coord_dirs *o;
+ struct f_switch *sw;
+ unsigned p, s, n = 0;
+ bool success = false;
+ bool all_sw_present, need_seed = true;
+
+ if (!(t->x_sz && t->y_sz && t->z_sz)) {
+ OSM_LOG(&t->osm->log, OSM_LOG_ERROR,
+ "ERR 4E20: missing required torus size specification!\n");
+ goto out;
+ }
+ if (t->osm->subn.min_sw_data_vls < 2) {
+ OSM_LOG(&t->osm->log, OSM_LOG_ERROR,
+ "ERR 4E48: Too few data VLs to support torus routing "
+ "without credit loops (have switchport %d need 2)\n",
+ (int)t->osm->subn.min_sw_data_vls);
+ goto out;
+ }
+ if (t->osm->subn.min_sw_data_vls < 4)
+ OSM_LOG(&t->osm->log, OSM_LOG_INFO,
+ "Warning: Too few data VLs to support torus routing "
+ "with a failed switch without credit loops "
+ "(have switchport %d need 4)\n",
+ (int)t->osm->subn.min_sw_data_vls);
+ if (t->osm->subn.min_sw_data_vls < 8)
+ OSM_LOG(&t->osm->log, OSM_LOG_INFO,
+ "Warning: Too few data VLs to support torus routing "
+ "with two QoS levels (have switchport %d need 8)\n",
+ (int)t->osm->subn.min_sw_data_vls);
+ if (t->osm->subn.min_data_vls < 2)
+ OSM_LOG(&t->osm->log, OSM_LOG_INFO,
+ "Warning: Too few data VLs to support torus routing "
+ "with two QoS levels (have endport %d need 2)\n",
+ (int)t->osm->subn.min_data_vls);
+ /*
+ * Be sure all the switches in the torus support the port
+ * ordering that might have been configured.
+ */
+ for (s = 0; s < f->switch_cnt; s++) {
+ sw = f->sw[s];
+ for (p = 0; p < sw->port_cnt; p++) {
+ if (t->port_order[p] >= sw->port_cnt) {
+ OSM_LOG(&t->osm->log, OSM_LOG_ERROR,
+ "ERR 4E21: port_order configured using "
+ "port %u, but only %u ports in "
+ "switch w/ GUID 0x%04"PRIx64"\n",
+ t->port_order[p], sw->port_cnt - 1,
+ cl_ntoh64(sw->n_id));
+ goto out;
+ }
+ }
+ }
+ /*
+ * Unfortunately, there is a problem with non-unique topology for any
+ * torus dimension which has radix four. This problem requires extra
+ * input, in the form of specifying both the positive and negative
+ * coordinate directions from a common switch, for any torus dimension
+ * with radix four (see also build_torus()).
+ *
+ * Do the checking required to ensure that the required information
+ * is present, but more than the needed information is not required.
+ *
+ * So, verify that we learned the coordinate directions correctly for
+ * the fabric. The coordinate direction links get an invalid port
+ * set on their ends when parsed.
+ */
+again:
+ all_sw_present = true;
+ o = &t->seed[n];
+
+ if (t->x_sz == 4 && !(t->flags & X_MESH)) {
+ if (o->xp_link.end[0].port >= 0) {
+ OSM_LOG(&t->osm->log, OSM_LOG_ERROR,
+ "ERR 4E22: Positive x" LINK_ERR_STR);
+ goto out;
+ }
+ if (o->xm_link.end[0].port >= 0) {
+ OSM_LOG(&t->osm->log, OSM_LOG_ERROR,
+ "ERR 4E23: Negative x" LINK_ERR_STR);
+ goto out;
+ }
+ if (o->xp_link.end[0].n_id != o->xm_link.end[0].n_id) {
+ OSM_LOG(&t->osm->log, OSM_LOG_ERROR,
+ "ERR 4E24: Positive/negative x" SEED_ERR_STR);
+ goto out;
+ }
+ }
+ if (t->y_sz == 4 && !(t->flags & Y_MESH)) {
+ if (o->yp_link.end[0].port >= 0) {
+ OSM_LOG(&t->osm->log, OSM_LOG_ERROR,
+ "ERR 4E25: Positive y" LINK_ERR_STR);
+ goto out;
+ }
+ if (o->ym_link.end[0].port >= 0) {
+ OSM_LOG(&t->osm->log, OSM_LOG_ERROR,
+ "ERR 4E26: Negative y" LINK_ERR_STR);
+ goto out;
+ }
+ if (o->yp_link.end[0].n_id != o->ym_link.end[0].n_id) {
+ OSM_LOG(&t->osm->log, OSM_LOG_ERROR,
+ "ERR 4E27: Positive/negative y" SEED_ERR_STR);
+ goto out;
+ }
+ }
+ if (t->z_sz == 4 && !(t->flags & Z_MESH)) {
+ if (o->zp_link.end[0].port >= 0) {
+ OSM_LOG(&t->osm->log, OSM_LOG_ERROR,
+ "ERR 4E28: Positive z" LINK_ERR_STR);
+ goto out;
+ }
+ if (o->zm_link.end[0].port >= 0) {
+ OSM_LOG(&t->osm->log, OSM_LOG_ERROR,
+ "ERR 4E29: Negative z" LINK_ERR_STR);
+ goto out;
+ }
+ if (o->zp_link.end[0].n_id != o->zm_link.end[0].n_id) {
+ OSM_LOG(&t->osm->log, OSM_LOG_ERROR,
+ "ERR 4E2A: Positive/negative z" SEED_ERR_STR);
+ goto out;
+ }
+ }
+ if (t->x_sz > 1) {
+ if (o->xp_link.end[0].port >= 0 &&
+ o->xm_link.end[0].port >= 0) {
+ OSM_LOG(&t->osm->log, OSM_LOG_ERROR,
+ "ERR 4E2B: Positive or negative x" LINK_ERR2_STR);
+ goto out;
+ }
+ if (o->xp_link.end[0].port < 0 &&
+ !find_f_sw(f, o->xp_link.end[0].n_id))
+ all_sw_present = false;
+
+ if (o->xp_link.end[1].port < 0 &&
+ !find_f_sw(f, o->xp_link.end[1].n_id))
+ all_sw_present = false;
+
+ if (o->xm_link.end[0].port < 0 &&
+ !find_f_sw(f, o->xm_link.end[0].n_id))
+ all_sw_present = false;
+
+ if (o->xm_link.end[1].port < 0 &&
+ !find_f_sw(f, o->xm_link.end[1].n_id))
+ all_sw_present = false;
+ }
+ if (t->z_sz > 1) {
+ if (o->zp_link.end[0].port >= 0 &&
+ o->zm_link.end[0].port >= 0) {
+ OSM_LOG(&t->osm->log, OSM_LOG_ERROR,
+ "ERR 4E2C: Positive or negative z" LINK_ERR2_STR);
+ goto out;
+ }
+ if ((o->xp_link.end[0].port < 0 &&
+ o->zp_link.end[0].port < 0 &&
+ o->zp_link.end[0].n_id != o->xp_link.end[0].n_id) ||
+
+ (o->xp_link.end[0].port < 0 &&
+ o->zm_link.end[0].port < 0 &&
+ o->zm_link.end[0].n_id != o->xp_link.end[0].n_id) ||
+
+ (o->xm_link.end[0].port < 0 &&
+ o->zp_link.end[0].port < 0 &&
+ o->zp_link.end[0].n_id != o->xm_link.end[0].n_id) ||
+
+ (o->xm_link.end[0].port < 0 &&
+ o->zm_link.end[0].port < 0 &&
+ o->zm_link.end[0].n_id != o->xm_link.end[0].n_id)) {
+
+ OSM_LOG(&t->osm->log, OSM_LOG_ERROR,
+ "ERR 4E2D: x and z" SEED_ERR_STR);
+ goto out;
+ }
+ if (o->zp_link.end[0].port < 0 &&
+ !find_f_sw(f, o->zp_link.end[0].n_id))
+ all_sw_present = false;
+
+ if (o->zp_link.end[1].port < 0 &&
+ !find_f_sw(f, o->zp_link.end[1].n_id))
+ all_sw_present = false;
+
+ if (o->zm_link.end[0].port < 0 &&
+ !find_f_sw(f, o->zm_link.end[0].n_id))
+ all_sw_present = false;
+
+ if (o->zm_link.end[1].port < 0 &&
+ !find_f_sw(f, o->zm_link.end[1].n_id))
+ all_sw_present = false;
+ }
+ if (t->y_sz > 1) {
+ if (o->yp_link.end[0].port >= 0 &&
+ o->ym_link.end[0].port >= 0) {
+ OSM_LOG(&t->osm->log, OSM_LOG_ERROR,
+ "ERR 4E2E: Positive or negative y" LINK_ERR2_STR);
+ goto out;
+ }
+ if ((o->xp_link.end[0].port < 0 &&
+ o->yp_link.end[0].port < 0 &&
+ o->yp_link.end[0].n_id != o->xp_link.end[0].n_id) ||
+
+ (o->xp_link.end[0].port < 0 &&
+ o->ym_link.end[0].port < 0 &&
+ o->ym_link.end[0].n_id != o->xp_link.end[0].n_id) ||
+
+ (o->xm_link.end[0].port < 0 &&
+ o->yp_link.end[0].port < 0 &&
+ o->yp_link.end[0].n_id != o->xm_link.end[0].n_id) ||
+
+ (o->xm_link.end[0].port < 0 &&
+ o->ym_link.end[0].port < 0 &&
+ o->ym_link.end[0].n_id != o->xm_link.end[0].n_id)) {
+
+ OSM_LOG(&t->osm->log, OSM_LOG_ERROR,
+ "ERR 4E2F: x and y" SEED_ERR_STR);
+ goto out;
+ }
+ if (o->yp_link.end[0].port < 0 &&
+ !find_f_sw(f, o->yp_link.end[0].n_id))
+ all_sw_present = false;
+
+ if (o->yp_link.end[1].port < 0 &&
+ !find_f_sw(f, o->yp_link.end[1].n_id))
+ all_sw_present = false;
+
+ if (o->ym_link.end[0].port < 0 &&
+ !find_f_sw(f, o->ym_link.end[0].n_id))
+ all_sw_present = false;
+
+ if (o->ym_link.end[1].port < 0 &&
+ !find_f_sw(f, o->ym_link.end[1].n_id))
+ all_sw_present = false;
+ }
+ if (all_sw_present && need_seed) {
+ t->seed_idx = n;
+ need_seed = false;
+ }
+ if (++n < t->seed_cnt)
+ goto again;
+
+ if (need_seed)
+ OSM_LOG(&t->osm->log, OSM_LOG_ERROR,
+ "ERR 4E30: Every configured torus seed has at "
+ "least one switch missing in fabric! See "
+ "torus-2QoS.conf(5) and TORUS TOPOLOGY DISCOVERY "
+ "in torus-2QoS(8)\n");
+ else
+ success = true;
+out:
+ return success;
+}
+
+static
+bool build_torus(struct fabric *f, struct torus *t)
+{
+ int i, j, k;
+ int im1, jm1, km1;
+ int ip1, jp1, kp1;
+ unsigned nlink;
+ struct coord_dirs *o;
+ struct f_switch *fsw0, *fsw1;
+ struct t_switch ****sw = t->sw;
+ bool success = true;
+
+ t->link_pool_sz = f->link_cnt;
+ t->link_pool = calloc(1, t->link_pool_sz * sizeof(*t->link_pool));
+ if (!t->link_pool) {
+ OSM_LOG(&t->osm->log, OSM_LOG_ERROR,
+ "ERR 4E31: Allocating torus link pool: %s\n",
+ strerror(errno));
+ goto out;
+ }
+ t->fabric = f;
+
+ /*
+ * Get things started by locating the up to seven switches that
+ * define the torus "seed", coordinate directions, and datelines.
+ */
+ o = &t->seed[t->seed_idx];
+
+ i = canonicalize(-o->x_dateline, t->x_sz);
+ j = canonicalize(-o->y_dateline, t->y_sz);
+ k = canonicalize(-o->z_dateline, t->z_sz);
+
+ if (o->xp_link.end[0].port < 0) {
+ ip1 = canonicalize(1 - o->x_dateline, t->x_sz);
+ fsw0 = find_f_sw(f, o->xp_link.end[0].n_id);
+ fsw1 = find_f_sw(f, o->xp_link.end[1].n_id);
+ success =
+ install_tswitch(t, i, j, k, fsw0) &&
+ install_tswitch(t, ip1, j, k, fsw1) && success;
+ }
+ if (o->xm_link.end[0].port < 0) {
+ im1 = canonicalize(-1 - o->x_dateline, t->x_sz);
+ fsw0 = find_f_sw(f, o->xm_link.end[0].n_id);
+ fsw1 = find_f_sw(f, o->xm_link.end[1].n_id);
+ success =
+ install_tswitch(t, i, j, k, fsw0) &&
+ install_tswitch(t, im1, j, k, fsw1) && success;
+ }
+ if (o->yp_link.end[0].port < 0) {
+ jp1 = canonicalize(1 - o->y_dateline, t->y_sz);
+ fsw0 = find_f_sw(f, o->yp_link.end[0].n_id);
+ fsw1 = find_f_sw(f, o->yp_link.end[1].n_id);
+ success =
+ install_tswitch(t, i, j, k, fsw0) &&
+ install_tswitch(t, i, jp1, k, fsw1) && success;
+ }
+ if (o->ym_link.end[0].port < 0) {
+ jm1 = canonicalize(-1 - o->y_dateline, t->y_sz);
+ fsw0 = find_f_sw(f, o->ym_link.end[0].n_id);
+ fsw1 = find_f_sw(f, o->ym_link.end[1].n_id);
+ success =
+ install_tswitch(t, i, j, k, fsw0) &&
+ install_tswitch(t, i, jm1, k, fsw1) && success;
+ }
+ if (o->zp_link.end[0].port < 0) {
+ kp1 = canonicalize(1 - o->z_dateline, t->z_sz);
+ fsw0 = find_f_sw(f, o->zp_link.end[0].n_id);
+ fsw1 = find_f_sw(f, o->zp_link.end[1].n_id);
+ success =
+ install_tswitch(t, i, j, k, fsw0) &&
+ install_tswitch(t, i, j, kp1, fsw1) && success;
+ }
+ if (o->zm_link.end[0].port < 0) {
+ km1 = canonicalize(-1 - o->z_dateline, t->z_sz);
+ fsw0 = find_f_sw(f, o->zm_link.end[0].n_id);
+ fsw1 = find_f_sw(f, o->zm_link.end[1].n_id);
+ success =
+ install_tswitch(t, i, j, k, fsw0) &&
+ install_tswitch(t, i, j, km1, fsw1) && success;
+ }
+ if (!success)
+ goto out;
+
+ if (!t->seed_idx)
+ OSM_LOG(&t->osm->log, OSM_LOG_INFO,
+ "Using torus seed configured as default "
+ "(seed sw %d,%d,%d GUID 0x%04"PRIx64").\n",
+ i, j, k, cl_ntoh64(sw[i][j][k]->n_id));
+ else
+ OSM_LOG(&t->osm->log, OSM_LOG_INFO,
+ "Using torus seed configured as backup #%u "
+ "(seed sw %d,%d,%d GUID 0x%04"PRIx64").\n",
+ t->seed_idx, i, j, k, cl_ntoh64(sw[i][j][k]->n_id));
+
+ /*
+ * Search the fabric and construct the expected torus topology.
+ *
+ * The algorithm is to consider the "cube" formed by eight switch
+ * locations bounded by the corners i, j, k and i+1, j+1, k+1.
+ * For each such cube look at the topology of the switches already
+ * placed in the torus, and deduce which new switches can be placed
+ * into their proper locations in the torus. Examine each cube
+ * multiple times, until the number of links moved into the torus
+ * topology does not change.
+ */
+again:
+ nlink = t->link_cnt;
+
+ for (k = 0; k < (int)t->z_sz; k++)
+ for (j = 0; j < (int)t->y_sz; j++)
+ for (i = 0; i < (int)t->x_sz; i++)
+ locate_sw(t, i, j, k);
+
+ if (t->link_cnt != nlink)
+ goto again;
+
+ /*
+ * Move all other endpoints into torus/mesh.
+ */
+ for (k = 0; k < (int)t->z_sz; k++)
+ for (j = 0; j < (int)t->y_sz; j++)
+ for (i = 0; i < (int)t->x_sz; i++)
+ if (!link_srcsink(t, i, j, k)) {
+ success = false;
+ goto out;
+ }
+out:
+ return success;
+}
+
+/*
+ * Returns a count of differences between old and new switches.
+ */
+static
+unsigned tsw_changes(struct t_switch *nsw, struct t_switch *osw)
+{
+ unsigned p, cnt = 0, port_cnt;
+ struct endpoint *npt, *opt;
+ struct endpoint *rnpt, *ropt;
+
+ if (nsw && !osw) {
+ cnt++;
+ OSM_LOG(&nsw->torus->osm->log, OSM_LOG_INFO,
+ "New torus switch %d,%d,%d GUID 0x%04"PRIx64"\n",
+ nsw->i, nsw->j, nsw->k, cl_ntoh64(nsw->n_id));
+ goto out;
+ }
+ if (osw && !nsw) {
+ cnt++;
+ OSM_LOG(&osw->torus->osm->log, OSM_LOG_INFO,
+ "Lost torus switch %d,%d,%d GUID 0x%04"PRIx64"\n",
+ osw->i, osw->j, osw->k, cl_ntoh64(osw->n_id));
+ goto out;
+ }
+ if (!(nsw && osw))
+ goto out;
+
+ if (nsw->n_id != osw->n_id) {
+ cnt++;
+ OSM_LOG(&nsw->torus->osm->log, OSM_LOG_INFO,
+ "Torus switch %d,%d,%d GUID "
+ "was 0x%04"PRIx64", now 0x%04"PRIx64"\n",
+ nsw->i, nsw->j, nsw->k,
+ cl_ntoh64(osw->n_id), cl_ntoh64(nsw->n_id));
+ }
+
+ if (nsw->port_cnt != osw->port_cnt) {
+ cnt++;
+ OSM_LOG(&nsw->torus->osm->log, OSM_LOG_INFO,
+ "Torus switch %d,%d,%d GUID 0x%04"PRIx64" "
+ "had %d ports, now has %d\n",
+ nsw->i, nsw->j, nsw->k, cl_ntoh64(nsw->n_id),
+ osw->port_cnt, nsw->port_cnt);
+ }
+ port_cnt = nsw->port_cnt;
+ if (port_cnt > osw->port_cnt)
+ port_cnt = osw->port_cnt;
+
+ for (p = 0; p < port_cnt; p++) {
+ npt = nsw->port[p];
+ opt = osw->port[p];
+
+ if (npt && npt->link) {
+ if (&npt->link->end[0] == npt)
+ rnpt = &npt->link->end[1];
+ else
+ rnpt = &npt->link->end[0];
+ } else
+ rnpt = NULL;
+
+ if (opt && opt->link) {
+ if (&opt->link->end[0] == opt)
+ ropt = &opt->link->end[1];
+ else
+ ropt = &opt->link->end[0];
+ } else
+ ropt = NULL;
+
+ if (rnpt && !ropt) {
+ ++cnt;
+ OSM_LOG(&nsw->torus->osm->log, OSM_LOG_INFO,
+ "Torus switch %d,%d,%d GUID 0x%04"PRIx64"[%d] "
+ "remote now %s GUID 0x%04"PRIx64"[%d], "
+ "was missing\n",
+ nsw->i, nsw->j, nsw->k, cl_ntoh64(nsw->n_id),
+ p, rnpt->type == PASSTHRU ? "sw" : "node",
+ cl_ntoh64(rnpt->n_id), rnpt->port);
+ continue;
+ }
+ if (ropt && !rnpt) {
+ ++cnt;
+ OSM_LOG(&nsw->torus->osm->log, OSM_LOG_INFO,
+ "Torus switch %d,%d,%d GUID 0x%04"PRIx64"[%d] "
+ "remote now missing, "
+ "was %s GUID 0x%04"PRIx64"[%d]\n",
+ osw->i, osw->j, osw->k, cl_ntoh64(nsw->n_id),
+ p, ropt->type == PASSTHRU ? "sw" : "node",
+ cl_ntoh64(ropt->n_id), ropt->port);
+ continue;
+ }
+ if (!(rnpt && ropt))
+ continue;
+
+ if (rnpt->n_id != ropt->n_id) {
+ ++cnt;
+ OSM_LOG(&nsw->torus->osm->log, OSM_LOG_INFO,
+ "Torus switch %d,%d,%d GUID 0x%04"PRIx64"[%d] "
+ "remote now %s GUID 0x%04"PRIx64"[%d], "
+ "was %s GUID 0x%04"PRIx64"[%d]\n",
+ nsw->i, nsw->j, nsw->k, cl_ntoh64(nsw->n_id),
+ p, rnpt->type == PASSTHRU ? "sw" : "node",
+ cl_ntoh64(rnpt->n_id), rnpt->port,
+ ropt->type == PASSTHRU ? "sw" : "node",
+ cl_ntoh64(ropt->n_id), ropt->port);
+ continue;
+ }
+ }
+out:
+ return cnt;
+}
+
+static
+void dump_torus(struct torus *t)
+{
+ unsigned i, j, k;
+ unsigned x_sz = t->x_sz;
+ unsigned y_sz = t->y_sz;
+ unsigned z_sz = t->z_sz;
+ char path[1024];
+ FILE *file;
+
+ snprintf(path, sizeof(path), "%s/%s", t->osm->subn.opt.dump_files_dir,
+ "opensm-torus.dump");
+ file = fopen(path, "w");
+ if (!file) {
+ OSM_LOG(&t->osm->log, OSM_LOG_ERROR,
+ "ERR 4E47: cannot create file \'%s\'\n", path);
+ return;
+ }
+
+ for (k = 0; k < z_sz; k++)
+ for (j = 0; j < y_sz; j++)
+ for (i = 0; i < x_sz; i++)
+ if (t->sw[i][j][k])
+ fprintf(file, "switch %u,%u,%u GUID 0x%04"
+ PRIx64 " (%s)\n",
+ i, j, k,
+ cl_ntoh64(t->sw[i][j][k]->n_id),
+ t->sw[i][j][k]->osm_switch->p_node->print_desc);
+ fclose(file);
+}
+
+static
+void report_torus_changes(struct torus *nt, struct torus *ot)
+{
+ unsigned cnt = 0;
+ unsigned i, j, k;
+ unsigned x_sz = nt->x_sz;
+ unsigned y_sz = nt->y_sz;
+ unsigned z_sz = nt->z_sz;
+ unsigned max_changes = nt->max_changes;
+
+ if (OSM_LOG_IS_ACTIVE_V2(&nt->osm->log, OSM_LOG_ROUTING))
+ dump_torus(nt);
+
+ if (!ot)
+ return;
+
+ if (x_sz != ot->x_sz) {
+ cnt++;
+ OSM_LOG(&nt->osm->log, OSM_LOG_INFO,
+ "Torus x radix was %d now %d\n",
+ ot->x_sz, nt->x_sz);
+ if (x_sz > ot->x_sz)
+ x_sz = ot->x_sz;
+ }
+ if (y_sz != ot->y_sz) {
+ cnt++;
+ OSM_LOG(&nt->osm->log, OSM_LOG_INFO,
+ "Torus y radix was %d now %d\n",
+ ot->y_sz, nt->y_sz);
+ if (y_sz > ot->y_sz)
+ y_sz = ot->y_sz;
+ }
+ if (z_sz != ot->z_sz) {
+ cnt++;
+ OSM_LOG(&nt->osm->log, OSM_LOG_INFO,
+ "Torus z radix was %d now %d\n",
+ ot->z_sz, nt->z_sz);
+ if (z_sz > ot->z_sz)
+ z_sz = ot->z_sz;
+ }
+
+ for (k = 0; k < z_sz; k++)
+ for (j = 0; j < y_sz; j++)
+ for (i = 0; i < x_sz; i++) {
+ cnt += tsw_changes(nt->sw[i][j][k],
+ ot->sw[i][j][k]);
+ /*
+ * Booting a big fabric will cause lots of
+ * changes as hosts come up, so don't spew.
+ * We want to log changes to learn more about
+ * bouncing links, etc, so they can be fixed.
+ */
+ if (cnt > max_changes) {
+ OSM_LOG(&nt->osm->log, OSM_LOG_INFO,
+ "Too many torus changes; "
+ "stopping reporting early\n");
+ return;
+ }
+ }
+}
+
+static
+void rpt_torus_missing(struct torus *t, int i, int j, int k,
+ struct t_switch *sw, int *missing_z)
+{
+ uint64_t guid_ho;
+
+ if (!sw) {
+ /*
+ * We can have multiple missing switches without deadlock
+ * if and only if they are adajacent in the Z direction.
+ */
+ if ((t->switch_cnt + 1) < t->sw_pool_sz) {
+ if (t->sw[i][j][canonicalize(k - 1, t->z_sz)] &&
+ t->sw[i][j][canonicalize(k + 1, t->z_sz)])
+ t->flags |= MSG_DEADLOCK;
+ }
+ /*
+ * There can be only one such Z-column of missing switches.
+ */
+ if (*missing_z < 0)
+ *missing_z = i + j * t->x_sz;
+ else if (*missing_z != i + j * t->x_sz)
+ t->flags |= MSG_DEADLOCK;
+
+ OSM_LOG(&t->osm->log, OSM_LOG_INFO,
+ "Missing torus switch at %d,%d,%d\n", i, j, k);
+ return;
+ }
+ guid_ho = cl_ntoh64(sw->n_id);
+
+ if (!(sw->ptgrp[0].port_cnt || (t->x_sz == 1) ||
+ ((t->flags & X_MESH) && i == 0)))
+ OSM_LOG(&t->osm->log, OSM_LOG_INFO,
+ "Missing torus -x link on "
+ "switch %d,%d,%d GUID 0x%04"PRIx64"\n",
+ i, j, k, guid_ho);
+ if (!(sw->ptgrp[1].port_cnt || (t->x_sz == 1) ||
+ ((t->flags & X_MESH) && (i + 1) == t->x_sz)))
+ OSM_LOG(&t->osm->log, OSM_LOG_INFO,
+ "Missing torus +x link on "
+ "switch %d,%d,%d GUID 0x%04"PRIx64"\n",
+ i, j, k, guid_ho);
+ if (!(sw->ptgrp[2].port_cnt || (t->y_sz == 1) ||
+ ((t->flags & Y_MESH) && j == 0)))
+ OSM_LOG(&t->osm->log, OSM_LOG_INFO,
+ "Missing torus -y link on "
+ "switch %d,%d,%d GUID 0x%04"PRIx64"\n",
+ i, j, k, guid_ho);
+ if (!(sw->ptgrp[3].port_cnt || (t->y_sz == 1) ||
+ ((t->flags & Y_MESH) && (j + 1) == t->y_sz)))
+ OSM_LOG(&t->osm->log, OSM_LOG_INFO,
+ "Missing torus +y link on "
+ "switch %d,%d,%d GUID 0x%04"PRIx64"\n",
+ i, j, k, guid_ho);
+ if (!(sw->ptgrp[4].port_cnt || (t->z_sz == 1) ||
+ ((t->flags & Z_MESH) && k == 0)))
+ OSM_LOG(&t->osm->log, OSM_LOG_INFO,
+ "Missing torus -z link on "
+ "switch %d,%d,%d GUID 0x%04"PRIx64"\n",
+ i, j, k, guid_ho);
+ if (!(sw->ptgrp[5].port_cnt || (t->z_sz == 1) ||
+ ((t->flags & Z_MESH) && (k + 1) == t->z_sz)))
+ OSM_LOG(&t->osm->log, OSM_LOG_INFO,
+ "Missing torus +z link on "
+ "switch %d,%d,%d GUID 0x%04"PRIx64"\n",
+ i, j, k, guid_ho);
+}
+
+/*
+ * Returns true if the torus can be successfully routed, false otherwise.
+ */
+static
+bool routable_torus(struct torus *t, struct fabric *f)
+{
+ int i, j, k, tmp = -1;
+ unsigned b2g_cnt, g2b_cnt;
+ bool success = true;
+
+ t->flags &= ~MSG_DEADLOCK;
+
+ if (t->link_cnt != f->link_cnt || t->switch_cnt != f->switch_cnt)
+ OSM_LOG(&t->osm->log, OSM_LOG_INFO,
+ "Warning: Could not construct torus using all "
+ "known fabric switches and/or links.\n");
+
+ for (k = 0; k < (int)t->z_sz; k++)
+ for (j = 0; j < (int)t->y_sz; j++)
+ for (i = 0; i < (int)t->x_sz; i++)
+ rpt_torus_missing(t, i, j, k,
+ t->sw[i][j][k], &tmp);
+ /*
+ * Check for multiple failures that create disjoint regions on a ring.
+ */
+ for (k = 0; k < (int)t->z_sz; k++)
+ for (j = 0; j < (int)t->y_sz; j++) {
+ b2g_cnt = 0;
+ g2b_cnt = 0;
+ for (i = 0; i < (int)t->x_sz; i++) {
+
+ if (!t->sw[i][j][k])
+ continue;
+
+ if (!t->sw[i][j][k]->ptgrp[0].port_cnt)
+ b2g_cnt++;
+ if (!t->sw[i][j][k]->ptgrp[1].port_cnt)
+ g2b_cnt++;
+ }
+ if (b2g_cnt != g2b_cnt) {
+ OSM_LOG(&t->osm->log, OSM_LOG_ERROR,
+ "ERR 4E32: strange failures in "
+ "x ring at y=%d z=%d"
+ " b2g_cnt %u g2b_cnt %u\n",
+ j, k, b2g_cnt, g2b_cnt);
+ success = false;
+ }
+ if (b2g_cnt > 1) {
+ OSM_LOG(&t->osm->log, OSM_LOG_ERROR,
+ "ERR 4E33: disjoint failures in "
+ "x ring at y=%d z=%d\n", j, k);
+ success = false;
+ }
+ }
+
+ for (i = 0; i < (int)t->x_sz; i++)
+ for (k = 0; k < (int)t->z_sz; k++) {
+ b2g_cnt = 0;
+ g2b_cnt = 0;
+ for (j = 0; j < (int)t->y_sz; j++) {
+
+ if (!t->sw[i][j][k])
+ continue;
+
+ if (!t->sw[i][j][k]->ptgrp[2].port_cnt)
+ b2g_cnt++;
+ if (!t->sw[i][j][k]->ptgrp[3].port_cnt)
+ g2b_cnt++;
+ }
+ if (b2g_cnt != g2b_cnt) {
+ OSM_LOG(&t->osm->log, OSM_LOG_ERROR,
+ "ERR 4E34: strange failures in "
+ "y ring at x=%d z=%d"
+ " b2g_cnt %u g2b_cnt %u\n",
+ i, k, b2g_cnt, g2b_cnt);
+ success = false;
+ }
+ if (b2g_cnt > 1) {
+ OSM_LOG(&t->osm->log, OSM_LOG_ERROR,
+ "ERR 4E35: disjoint failures in "
+ "y ring at x=%d z=%d\n", i, k);
+ success = false;
+ }
+ }
+
+ for (j = 0; j < (int)t->y_sz; j++)
+ for (i = 0; i < (int)t->x_sz; i++) {
+ b2g_cnt = 0;
+ g2b_cnt = 0;
+ for (k = 0; k < (int)t->z_sz; k++) {
+
+ if (!t->sw[i][j][k])
+ continue;
+
+ if (!t->sw[i][j][k]->ptgrp[4].port_cnt)
+ b2g_cnt++;
+ if (!t->sw[i][j][k]->ptgrp[5].port_cnt)
+ g2b_cnt++;
+ }
+ if (b2g_cnt != g2b_cnt) {
+ OSM_LOG(&t->osm->log, OSM_LOG_ERROR,
+ "ERR 4E36: strange failures in "
+ "z ring at x=%d y=%d"
+ " b2g_cnt %u g2b_cnt %u\n",
+ i, j, b2g_cnt, g2b_cnt);
+ success = false;
+ }
+ if (b2g_cnt > 1) {
+ OSM_LOG(&t->osm->log, OSM_LOG_ERROR,
+ "ERR 4E37: disjoint failures in "
+ "z ring at x=%d y=%d\n", i, j);
+ success = false;
+ }
+ }
+
+ if (t->flags & MSG_DEADLOCK) {
+ OSM_LOG(&t->osm->log, OSM_LOG_ERROR,
+ "ERR 4E38: missing switch topology "
+ "==> message deadlock!\n");
+ success = false;
+ }
+ return success;
+}
+
+/*
+ * Use this function to re-establish the pointers between a torus endpoint
+ * and an opensm osm_port_t.
+ *
+ * Typically this is only needed when "opensm --ucast-cache" is used, and
+ * a CA link bounces. When the CA port goes away, the osm_port_t object
+ * is destroyed, invalidating the endpoint osm_port_t pointer. When the
+ * link comes back, a new osm_port_t object is created with a NULL priv
+ * member. Thus, when osm_get_torus_sl() is called it is missing the data
+ * needed to do its work. Use this function to fix things up.
+ */
+static
+struct endpoint *osm_port_relink_endpoint(const osm_port_t *osm_port)
+{
+ guid_t node_guid;
+ uint8_t port_num, r_port_num;
+ struct t_switch *sw;
+ struct endpoint *ep = NULL;
+ osm_switch_t *osm_sw;
+ osm_physp_t *osm_physp;
+ osm_node_t *osm_node, *r_osm_node;
+
+ /*
+ * We need to find the torus endpoint that has the same GUID as
+ * the osm_port. Rather than search the entire set of endpoints,
+ * we'll try to follow pointers.
+ */
+ osm_physp = osm_port->p_physp;
+ osm_node = osm_port->p_node;
+ port_num = osm_physp_get_port_num(osm_physp);
+ node_guid = osm_node_get_node_guid(osm_node);
+ /*
+ * Switch management port?
+ */
+ if (port_num == 0 &&
+ osm_node_get_type(osm_node) == IB_NODE_TYPE_SWITCH) {
+
+ osm_sw = osm_node->sw;
+ if (osm_sw && osm_sw->priv) {
+ sw = osm_sw->priv;
+ if (sw->osm_switch == osm_sw &&
+ sw->port[0]->n_id == node_guid) {
+
+ ep = sw->port[0];
+ goto relink_priv;
+ }
+ }
+ }
+ /*
+ * CA port? Try other end of link. This should also catch a
+ * router port if it is connected to a switch.
+ */
+ r_osm_node = osm_node_get_remote_node(osm_node, port_num, &r_port_num);
+ if (!r_osm_node)
+ goto out;
+
+ osm_sw = r_osm_node->sw;
+ if (!osm_sw)
+ goto out;
+
+ sw = osm_sw->priv;
+ if (!(sw && sw->osm_switch == osm_sw))
+ goto out;
+
+ ep = sw->port[r_port_num];
+ if (!(ep && ep->link))
+ goto out;
+
+ if (ep->link->end[0].n_id == node_guid) {
+ ep = &ep->link->end[0];
+ goto relink_priv;
+ }
+ if (ep->link->end[1].n_id == node_guid) {
+ ep = &ep->link->end[1];
+ goto relink_priv;
+ }
+ ep = NULL;
+ goto out;
+
+relink_priv:
+ /* FIXME:
+ * Unfortunately, we need to cast away const to rebuild the links
+ * between the torus endpoint and the osm_port_t.
+ *
+ * What is really needed is to check whether pr_rcv_get_path_parms()
+ * needs its port objects to be const. If so, why, and whether
+ * anything can be done about it.
+ */
+ ((osm_port_t *)osm_port)->priv = ep;
+ ep->osm_port = (osm_port_t *)osm_port;
+out:
+ return ep;
+}
+
+/*
+ * Computing LFT entries and path SL values:
+ *
+ * For a pristine torus, we compute LFT entries using XYZ DOR, and select
+ * which direction to route on a ring (i.e., the 1-D torus for the coordinate
+ * in question) based on shortest path. We compute the SL to use for the
+ * path based on whether we crossed a dateline (where a ring coordinate
+ * wraps to zero) for each coordinate.
+ *
+ * When there is a link/switch failure, we want to compute LFT entries
+ * to route around the failure, without changing the path SL. I.e., we
+ * want the SL to reach a given destination from a given source to be
+ * independent of the presence or number of failed components in the fabric.
+ *
+ * In order to make this feasible, we will assume that no ring is broken
+ * into disjoint pieces by multiple failures
+ *
+ * We handle failure by attempting to take the long way around any ring
+ * with connectivity interrupted by failed components, unless the path
+ * requires a turn on a failed switch.
+ *
+ * For paths that require a turn on a failed switch, we head towards the
+ * failed switch, then turn when progress is blocked by a failure, using a
+ * turn allowed under XYZ DOR. However, such a path will also require a turn
+ * that is not a legal XYZ DOR turn, so we construct the SL2VL mapping tables
+ * such that XYZ DOR turns use one set of VLs and ZYX DOR turns use a
+ * separate set of VLs.
+ *
+ * Under these rules the algorithm guarantees credit-loop-free routing for a
+ * single failed switch, without any change in path SL values. We can also
+ * guarantee credit-loop-free routing for failures of multiple switches, if
+ * they are adjacent in the last DOR direction. Since we use XYZ-DOR,
+ * that means failed switches at i,j,k and i,j,k+1 will not cause credit
+ * loops.
+ *
+ * These failure routing rules are intended to prevent paths that cross any
+ * coordinate dateline twice (over and back), so we don't need to worry about
+ * any ambiguity over which SL to use for such a case. Also, we cannot have
+ * a ring deadlock when a ring is broken by failure and we route the long
+ * way around, so we don't need to worry about the impact of such routing
+ * on SL choice.
+ */
+
+/*
+ * Functions to set our SL bit encoding for routing/QoS info. Combine the
+ * resuts of these functions with bitwise or to get final SL.
+ *
+ * SL bits 0-2 encode whether we "looped" in a given direction
+ * on the torus on the path from source to destination.
+ *
+ * SL bit 3 encodes the QoS level. We only support two QoS levels.
+ *
+ * Below we assume TORUS_MAX_DIM == 3 and 0 <= coord_dir < TORUS_MAX_DIM.
+ */
+static inline
+unsigned sl_set_use_loop_vl(bool use_loop_vl, unsigned coord_dir)
+{
+ return (coord_dir < TORUS_MAX_DIM)
+ ? ((unsigned)use_loop_vl << coord_dir) : 0;
+}
+
+static inline
+unsigned sl_set_qos(unsigned qos)
+{
+ return (unsigned)(!!qos) << TORUS_MAX_DIM;
+}
+
+/*
+ * Functions to crack our SL bit encoding for routing/QoS info.
+ */
+static inline
+bool sl_get_use_loop_vl(unsigned sl, unsigned coord_dir)
+{
+ return (coord_dir < TORUS_MAX_DIM)
+ ? (sl >> coord_dir) & 0x1 : false;
+}
+
+static inline
+unsigned sl_get_qos(unsigned sl)
+{
+ return (sl >> TORUS_MAX_DIM) & 0x1;
+}
+
+/*
+ * Functions to encode routing/QoS info into VL bits. Combine the resuts of
+ * these functions with bitwise or to get final VL.
+ *
+ * For interswitch links:
+ * VL bit 0 encodes whether we need to leave on the "loop" VL.
+ *
+ * VL bit 1 encodes whether turn is XYZ DOR or ZYX DOR. A 3d mesh/torus
+ * has 6 turn types: x-y, y-z, x-z, y-x, z-y, z-x. The first three are
+ * legal XYZ DOR turns, and the second three are legal ZYX DOR turns.
+ * Straight-through (x-x, y-y, z-z) paths are legal in both DOR variants,
+ * so we'll assign them to XYZ DOR VLs.
+ *
+ * Note that delivery to switch-local ports (i.e. those that source/sink
+ * traffic, rather than forwarding it) cannot cause a deadlock, so that
+ * can also use either XYZ or ZYX DOR.
+ *
+ * VL bit 2 encodes QoS level.
+ *
+ * For end port links:
+ * VL bit 0 encodes QoS level.
+ *
+ * Note that if VL bit encodings are changed here, the available fabric VL
+ * verification in verify_setup() needs to be updated as well.
+ */
+static inline
+unsigned vl_set_loop_vl(bool use_loop_vl)
+{
+ return use_loop_vl;
+}
+
+static inline
+unsigned vl_set_qos_vl(unsigned qos)
+{
+ return (qos & 0x1) << 2;
+}
+
+static inline
+unsigned vl_set_ca_qos_vl(unsigned qos)
+{
+ return qos & 0x1;
+}
+
+static inline
+unsigned vl_set_turn_vl(unsigned in_coord_dir, unsigned out_coord_dir)
+{
+ unsigned vl = 0;
+
+ if (in_coord_dir != TORUS_MAX_DIM &&
+ out_coord_dir != TORUS_MAX_DIM)
+ vl = (in_coord_dir > out_coord_dir)
+ ? 0x1 << 1 : 0;
+
+ return vl;
+}
+
+static
+unsigned sl2vl_entry(struct torus *t, struct t_switch *sw,
+ int input_pt, int output_pt, unsigned sl)
+{
+ unsigned id, od, vl, data_vls;
+
+ if (sw && sw->port[input_pt])
+ id = sw->port[input_pt]->pgrp->port_grp / 2;
+ else
+ id = TORUS_MAX_DIM;
+
+ if (sw && sw->port[output_pt])
+ od = sw->port[output_pt]->pgrp->port_grp / 2;
+ else
+ od = TORUS_MAX_DIM;
+
+ if (sw)
+ data_vls = t->osm->subn.min_sw_data_vls;
+ else
+ data_vls = t->osm->subn.min_data_vls;
+
+ vl = 0;
+ if (sw && od != TORUS_MAX_DIM) {
+ if (data_vls >= 2)
+ vl |= vl_set_loop_vl(sl_get_use_loop_vl(sl, od));
+ if (data_vls >= 4)
+ vl |= vl_set_turn_vl(id, od);
+ if (data_vls >= 8)
+ vl |= vl_set_qos_vl(sl_get_qos(sl));
+ } else {
+ if (data_vls >= 2)
+ vl |= vl_set_ca_qos_vl(sl_get_qos(sl));
+ }
+ return vl;
+}
+
+static
+void torus_update_osm_sl2vl(void *context, osm_physp_t *osm_phys_port,
+ uint8_t iport_num, uint8_t oport_num,
+ ib_slvl_table_t *osm_oport_sl2vl)
+{
+ osm_node_t *node = osm_physp_get_node_ptr(osm_phys_port);
+ struct torus_context *ctx = context;
+ struct t_switch *sw = NULL;
+ int sl, vl;
+
+ if (node->sw) {
+ sw = node->sw->priv;
+ if (sw && sw->osm_switch != node->sw) {
+ osm_log_t *log = &ctx->osm->log;
+ guid_t guid;
+
+ guid = osm_node_get_node_guid(node);
+ OSM_LOG(log, OSM_LOG_INFO,
+ "Note: osm_switch (GUID 0x%04"PRIx64") "
+ "not in torus fabric description\n",
+ cl_ntoh64(guid));
+ return;
+ }
+ }
+ for (sl = 0; sl < 16; sl++) {
+ vl = sl2vl_entry(ctx->torus, sw, iport_num, oport_num, sl);
+ ib_slvl_table_set(osm_oport_sl2vl, sl, vl);
+ }
+}
+
+static
+void torus_update_osm_vlarb(void *context, osm_physp_t *osm_phys_port,
+ uint8_t port_num, ib_vl_arb_table_t *block,
+ unsigned block_length, unsigned block_num)
+{
+ osm_node_t *node = osm_physp_get_node_ptr(osm_phys_port);
+ struct torus_context *ctx = context;
+ struct t_switch *sw = NULL;
+ unsigned i, next;
+
+ if (node->sw) {
+ sw = node->sw->priv;
+ if (sw && sw->osm_switch != node->sw) {
+ osm_log_t *log = &ctx->osm->log;
+ guid_t guid;
+
+ guid = osm_node_get_node_guid(node);
+ OSM_LOG(log, OSM_LOG_INFO,
+ "Note: osm_switch (GUID 0x%04"PRIx64") "
+ "not in torus fabric description\n",
+ cl_ntoh64(guid));
+ return;
+ }
+ }
+
+ /*
+ * If osm_phys_port is a switch port that connects to a CA, then
+ * we're using at most VL 0 (for QoS level 0) and VL 1 (for QoS
+ * level 1). We've been passed the VLarb values for a switch
+ * external port, so we need to fix them up to avoid unexpected
+ * results depending on how the switch handles VLarb values for
+ * unprogrammed VLs.
+ *
+ * For inter-switch links torus-2QoS uses VLs 0-3 to implement
+ * QoS level 0, and VLs 4-7 to implement QoS level 1.
+ *
+ * So, leave VL 0 alone, remap VL 4 to VL 1, zero out the rest,
+ * and compress out the zero entries to the end.
+ */
+ if (!sw || !port_num || !sw->port[port_num] ||
+ sw->port[port_num]->pgrp->port_grp != 2 * TORUS_MAX_DIM)
+ return;
+
+ next = 0;
+ for (i = 0; i < block_length; i++) {
+ switch (block->vl_entry[i].vl) {
+ case 4:
+ block->vl_entry[i].vl = 1;
+ /* fall through */
+ case 0:
+ block->vl_entry[next].vl = block->vl_entry[i].vl;
+ block->vl_entry[next].weight = block->vl_entry[i].weight;
+ next++;
+ /*
+ * If we didn't update vl_entry[i] in place,
+ * fall through to zero it out.
+ */
+ if (next > i)
+ break;
+ default:
+ block->vl_entry[i].vl = 0;
+ block->vl_entry[i].weight = 0;
+ break;
+ }
+ }
+}
+
+/*
+ * Computes the path lengths *vl0_len and *vl1_len to get from src
+ * to dst on a ring with count switches.
+ *
+ * *vl0_len is the path length for a direct path; it corresponds to a path
+ * that should be assigned to use VL0 in a switch. *vl1_len is the path
+ * length for a path that wraps aroung the ring, i.e. where the ring index
+ * goes from count to zero or from zero to count. It corresponds to the path
+ * that should be assigned to use VL1 in a switch.
+ */
+static
+void get_pathlen(unsigned src, unsigned dst, unsigned count,
+ unsigned *vl0_len, unsigned *vl1_len)
+{
+ unsigned s, l; /* assume s < l */
+
+ if (dst > src) {
+ s = src;
+ l = dst;
+ } else {
+ s = dst;
+ l = src;
+ }
+ *vl0_len = l - s;
+ *vl1_len = s + count - l;
+}
+
+/*
+ * Returns a positive number if we should take the "positive" ring direction
+ * to reach dst from src, a negative number if we should take the "negative"
+ * ring direction, and 0 if src and dst are the same. The choice is strictly
+ * based on which path is shorter.
+ */
+static
+int ring_dir_idx(unsigned src, unsigned dst, unsigned count)
+{
+ int r;
+ unsigned vl0_len, vl1_len;
+
+ if (dst == src)
+ return 0;
+
+ get_pathlen(src, dst, count, &vl0_len, &vl1_len);
+
+ if (dst > src)
+ r = vl0_len <= vl1_len ? 1 : -1;
+ else
+ r = vl0_len <= vl1_len ? -1 : 1;
+
+ return r;
+}
+
+/*
+ * Returns true if the VL1 path should be used to reach src from dst on a
+ * ring, based on which path is shorter.
+ */
+static
+bool use_vl1(unsigned src, unsigned dst, unsigned count)
+{
+ unsigned vl0_len, vl1_len;
+
+ get_pathlen(src, dst, count, &vl0_len, &vl1_len);
+
+ return vl0_len <= vl1_len ? false : true;
+}
+
+/*
+ * Returns the next switch in the ring of switches along coordinate direction
+ * cdir, in the positive ring direction if rdir is positive, and in the
+ * negative ring direction if rdir is negative.
+ *
+ * Returns NULL if rdir is zero, or there is no next switch.
+ */
+static
+struct t_switch *ring_next_sw(struct t_switch *sw, unsigned cdir, int rdir)
+{
+ unsigned pt_grp, far_end = 0;
+
+ if (!rdir)
+ return NULL;
+ /*
+ * Recall that links are installed into the torus so that their 1 end
+ * is in the "positive" coordinate direction relative to their 0 end
+ * (see link_tswitches() and connect_tlink()). Recall also that for
+ * interswitch links, all links in a given switch port group have the
+ * same endpoints, so we just need to look at the first link.
+ */
+ pt_grp = 2 * cdir;
+ if (rdir > 0) {
+ pt_grp++;
+ far_end = 1;
+ }
+
+ if (!sw->ptgrp[pt_grp].port_cnt)
+ return NULL;
+
+ return sw->ptgrp[pt_grp].port[0]->link->end[far_end].sw;
+}
+
+/*
+ * Returns a positive number if we should take the "positive" ring direction
+ * to reach dsw from ssw, a negative number if we should take the "negative"
+ * ring direction, and 0 if src and dst are the same, or if dsw is not
+ * reachable from ssw because the path is interrupted by failure.
+ */
+static
+int ring_dir_path(struct torus *t, unsigned cdir,
+ struct t_switch *ssw, struct t_switch *dsw)
+{
+ int d = 0;
+ struct t_switch *sw;
+
+ switch (cdir) {
+ case 0:
+ d = ring_dir_idx(ssw->i, dsw->i, t->x_sz);
+ break;
+ case 1:
+ d = ring_dir_idx(ssw->j, dsw->j, t->y_sz);
+ break;
+ case 2:
+ d = ring_dir_idx(ssw->k, dsw->k, t->z_sz);
+ break;
+ default:
+ break;
+ }
+ if (!d)
+ goto out;
+
+ sw = ssw;
+ while (sw) {
+ sw = ring_next_sw(sw, cdir, d);
+ if (sw == dsw)
+ goto out;
+ }
+ d *= -1;
+ sw = ssw;
+ while (sw) {
+ sw = ring_next_sw(sw, cdir, d);
+ if (sw == dsw)
+ goto out;
+ }
+ d = 0;
+out:
+ return d;
+}
+
+/*
+ * Returns true, and sets *pt_grp to the port group index to use for the
+ * next hop, if it is possible to make progress from ssw to dsw along the
+ * coordinate direction cdir, taking into account whether there are
+ * interruptions in the path.
+ *
+ * This next hop result can be used without worrying about ring deadlocks -
+ * if we don't choose the shortest path it is because there is a failure in
+ * the ring, which removes the possibilility of a ring deadlock on that ring.
+ */
+static
+bool next_hop_path(struct torus *t, unsigned cdir,
+ struct t_switch *ssw, struct t_switch *dsw,
+ unsigned *pt_grp)
+{
+ struct t_switch *tsw = NULL;
+ bool success = false;
+ int d;
+
+ /*
+ * If the path from ssw to dsw turns, this is the switch where the
+ * turn happens.
+ */
+ switch (cdir) {
+ case 0:
+ tsw = t->sw[dsw->i][ssw->j][ssw->k];
+ break;
+ case 1:
+ tsw = t->sw[ssw->i][dsw->j][ssw->k];
+ break;
+ case 2:
+ tsw = t->sw[ssw->i][ssw->j][dsw->k];
+ break;
+ default:
+ goto out;
+ }
+ if (tsw) {
+ d = ring_dir_path(t, cdir, ssw, tsw);
+ cdir *= 2;
+ if (d > 0)
+ *pt_grp = cdir + 1;
+ else if (d < 0)
+ *pt_grp = cdir;
+ else
+ goto out;
+ success = true;
+ }
+out:
+ return success;
+}
+
+/*
+ * Returns true, and sets *pt_grp to the port group index to use for the
+ * next hop, if it is possible to make progress from ssw to dsw along the
+ * coordinate direction cdir. This decision is made strictly on a
+ * shortest-path basis without regard for path availability.
+ */
+static
+bool next_hop_idx(struct torus *t, unsigned cdir,
+ struct t_switch *ssw, struct t_switch *dsw,
+ unsigned *pt_grp)
+{
+ int d;
+ unsigned g;
+ bool success = false;
+
+ switch (cdir) {
+ case 0:
+ d = ring_dir_idx(ssw->i, dsw->i, t->x_sz);
+ break;
+ case 1:
+ d = ring_dir_idx(ssw->j, dsw->j, t->y_sz);
+ break;
+ case 2:
+ d = ring_dir_idx(ssw->k, dsw->k, t->z_sz);
+ break;
+ default:
+ goto out;
+ }
+
+ cdir *= 2;
+ if (d > 0)
+ g = cdir + 1;
+ else if (d < 0)
+ g = cdir;
+ else
+ goto out;
+
+ if (!ssw->ptgrp[g].port_cnt)
+ goto out;
+
+ *pt_grp = g;
+ success = true;
+out:
+ return success;
+}
+
+static
+void warn_on_routing(const char *msg,
+ struct t_switch *sw, struct t_switch *dsw)
+{
+ OSM_LOG(&sw->torus->osm->log, OSM_LOG_ERROR,
+ "%s from sw 0x%04"PRIx64" (%d,%d,%d) "
+ "to sw 0x%04"PRIx64" (%d,%d,%d)\n",
+ msg, cl_ntoh64(sw->n_id), sw->i, sw->j, sw->k,
+ cl_ntoh64(dsw->n_id), dsw->i, dsw->j, dsw->k);
+}
+
+static
+bool next_hop_x(struct torus *t,
+ struct t_switch *ssw, struct t_switch *dsw, unsigned *pt_grp)
+{
+ if (t->sw[dsw->i][ssw->j][ssw->k])
+ /*
+ * The next turning switch on this path is available,
+ * so head towards it by the shortest available path.
+ */
+ return next_hop_path(t, 0, ssw, dsw, pt_grp);
+ else
+ /*
+ * The next turning switch on this path is not
+ * available, so head towards it in the shortest
+ * path direction.
+ */
+ return next_hop_idx(t, 0, ssw, dsw, pt_grp);
+}
+
+static
+bool next_hop_y(struct torus *t,
+ struct t_switch *ssw, struct t_switch *dsw, unsigned *pt_grp)
+{
+ if (t->sw[ssw->i][dsw->j][ssw->k])
+ /*
+ * The next turning switch on this path is available,
+ * so head towards it by the shortest available path.
+ */
+ return next_hop_path(t, 1, ssw, dsw, pt_grp);
+ else
+ /*
+ * The next turning switch on this path is not
+ * available, so head towards it in the shortest
+ * path direction.
+ */
+ return next_hop_idx(t, 1, ssw, dsw, pt_grp);
+}
+
+static
+bool next_hop_z(struct torus *t,
+ struct t_switch *ssw, struct t_switch *dsw, unsigned *pt_grp)
+{
+ return next_hop_path(t, 2, ssw, dsw, pt_grp);
+}
+
+/*
+ * Returns the port number on *sw to use to reach *dsw, or -1 if unable to
+ * route.
+ */
+static
+int lft_port(struct torus *t,
+ struct t_switch *sw, struct t_switch *dsw,
+ bool update_port_cnt, bool ca)
+{
+ unsigned g, p;
+ struct port_grp *pg;
+
+ /*
+ * The IBA does not provide a way to preserve path history for
+ * routing decisions and VL assignment, and the only mechanism to
+ * provide global fabric knowledge to the routing engine is via
+ * the four SL bits. This severely constrains the ability to deal
+ * with missing/dead switches.
+ *
+ * Also, if routing a torus with XYZ-DOR, the only way to route
+ * around a missing/dead switch is to introduce a turn that is
+ * illegal under XYZ-DOR.
+ *
+ * But here's what we can do:
+ *
+ * We have a VL bit we use to flag illegal turns, thus putting the
+ * hop directly after an illegal turn on a separate set of VLs.
+ * Unfortunately, since there is no path history, the _second_
+ * and subsequent hops after an illegal turn use the standard
+ * XYZ-DOR VL set. This is enough to introduce credit loops in
+ * many cases.
+ *
+ * To minimize the number of cases such illegal turns can introduce
+ * credit loops, we try to introduce the illegal turn as late in a
+ * path as possible.
+ *
+ * Define a turning switch as a switch where a path turns from one
+ * coordinate direction onto another. If a turning switch in a path
+ * is missing, construct the LFT entries so that the path progresses
+ * as far as possible on the shortest path to the turning switch.
+ * When progress is not possible, turn onto the next coordinate
+ * direction.
+ *
+ * The next turn after that will be an illegal turn, after which
+ * point the path will continue to use a standard XYZ-DOR path.
+ */
+ if (dsw->i != sw->i) {
+
+ if (next_hop_x(t, sw, dsw, &g))
+ goto done;
+ /*
+ * This path has made as much progress in this direction as
+ * is possible, so turn it now.
+ */
+ if (dsw->j != sw->j && next_hop_y(t, sw, dsw, &g))
+ goto done;
+
+ if (dsw->k != sw->k && next_hop_z(t, sw, dsw, &g))
+ goto done;
+
+ warn_on_routing("Error: unable to route", sw, dsw);
+ goto no_route;
+ } else if (dsw->j != sw->j) {
+
+ if (next_hop_y(t, sw, dsw, &g))
+ goto done;
+
+ if (dsw->k != sw->k && next_hop_z(t, sw, dsw, &g))
+ goto done;
+
+ warn_on_routing("Error: unable to route", sw, dsw);
+ goto no_route;
+ } else {
+ if (dsw->k == sw->k)
+ warn_on_routing("Warning: bad routing", sw, dsw);
+
+ if (next_hop_z(t, sw, dsw, &g))
+ goto done;
+
+ warn_on_routing("Error: unable to route", sw, dsw);
+ goto no_route;
+ }
+done:
+ pg = &sw->ptgrp[g];
+ if (!pg->port_cnt)
+ goto no_route;
+
+ if (update_port_cnt) {
+ if (ca)
+ p = pg->ca_dlid_cnt++ % pg->port_cnt;
+ else
+ p = pg->sw_dlid_cnt++ % pg->port_cnt;
+ } else {
+ /*
+ * If we're not updating port counts, then we're just running
+ * routes for SL path checking, and it doesn't matter which
+ * of several parallel links we use. Use the first one.
+ */
+ p = 0;
+ }
+ p = pg->port[p]->port;
+
+ return p;
+
+no_route:
+ /*
+ * We can't get there from here.
+ */
+ OSM_LOG(&t->osm->log, OSM_LOG_ERROR,
+ "ERR 4E39: routing on sw 0x%04"PRIx64": sending "
+ "traffic for dest sw 0x%04"PRIx64" to port %u\n",
+ cl_ntoh64(sw->n_id), cl_ntoh64(dsw->n_id), OSM_NO_PATH);
+ return -1;
+}
+
+static
+bool get_lid(struct port_grp *pg, unsigned p,
+ uint16_t *dlid_base, uint8_t *dlid_lmc, bool *ca)
+{
+ struct endpoint *ep;
+ osm_port_t *osm_port;
+
+ if (p >= pg->port_cnt) {
+ OSM_LOG(&pg->sw->torus->osm->log, OSM_LOG_ERROR,
+ "ERR 4E3A: Port group index %u too large: sw "
+ "0x%04"PRIx64" pt_grp %u pt_grp_cnt %u\n",
+ p, cl_ntoh64(pg->sw->n_id),
+ (unsigned)pg->port_grp, (unsigned)pg->port_cnt);
+ return false;
+ }
+ if (pg->port[p]->type == SRCSINK) {
+ ep = pg->port[p];
+ if (ca)
+ *ca = false;
+ } else if (pg->port[p]->type == PASSTHRU &&
+ pg->port[p]->link->end[1].type == SRCSINK) {
+ /*
+ * If this port is connected via a link to a CA, then we
+ * know link->end[0] is the switch end and link->end[1] is
+ * the CA end; see build_ca_link() and link_srcsink().
+ */
+ ep = &pg->port[p]->link->end[1];
+ if (ca)
+ *ca = true;
+ } else {
+ OSM_LOG(&pg->sw->torus->osm->log, OSM_LOG_ERROR,
+ "ERR 4E3B: Switch 0x%04"PRIx64" port %d improperly connected\n",
+ cl_ntoh64(pg->sw->n_id), pg->port[p]->port);
+ return false;
+ }
+ osm_port = ep->osm_port;
+ if (!(osm_port && osm_port->priv == ep)) {
+ OSM_LOG(&pg->sw->torus->osm->log, OSM_LOG_ERROR,
+ "ERR 4E3C: ep->osm_port->priv != ep "
+ "for sw 0x%04"PRIx64" port %d\n",
+ cl_ntoh64(((struct t_switch *)(ep->sw))->n_id), ep->port);
+ return false;
+ }
+ *dlid_base = cl_ntoh16(osm_physp_get_base_lid(osm_port->p_physp));
+ *dlid_lmc = osm_physp_get_lmc(osm_port->p_physp);
+
+ return true;
+}
+
+static
+bool torus_lft(struct torus *t, struct t_switch *sw)
+{
+ bool success = true;
+ int dp;
+ unsigned p, s;
+ uint16_t l, dlid_base;
+ uint8_t dlid_lmc;
+ bool ca;
+ struct port_grp *pgrp;
+ struct t_switch *dsw;
+ osm_switch_t *osm_sw;
+ uint8_t order[IB_NODE_NUM_PORTS_MAX+1];
+
+ if (!(sw->osm_switch && sw->osm_switch->priv == sw)) {
+ OSM_LOG(&t->osm->log, OSM_LOG_ERROR,
+ "ERR 4E3D: sw->osm_switch->priv != sw "
+ "for sw 0x%04"PRIx64"\n", cl_ntoh64(sw->n_id));
+ return false;
+ }
+ osm_sw = sw->osm_switch;
+ memset(osm_sw->new_lft, OSM_NO_PATH, osm_sw->lft_size);
+
+ for (s = 0; s < t->switch_cnt; s++) {
+
+ dsw = t->sw_pool[s];
+ pgrp = &dsw->ptgrp[2 * TORUS_MAX_DIM];
+
+ memset(order, IB_INVALID_PORT_NUM, sizeof(order));
+ for (p = 0; p < pgrp->port_cnt; p++)
+ order[pgrp->port[p]->port] = p;
+
+ for (p = 0; p < ARRAY_SIZE(order); p++) {
+
+ uint8_t px = order[t->port_order[p]];
+
+ if (px == IB_INVALID_PORT_NUM)
+ continue;
+
+ if (!get_lid(pgrp, px, &dlid_base, &dlid_lmc, &ca))
+ return false;
+
+ if (sw->n_id == dsw->n_id)
+ dp = pgrp->port[px]->port;
+ else
+ dp = lft_port(t, sw, dsw, true, ca);
+ /*
+ * LMC > 0 doesn't really make sense for torus-2QoS.
+ * So, just make sure traffic gets delivered if
+ * non-zero LMC is used.
+ */
+ if (dp >= 0)
+ for (l = 0; l < (1U << dlid_lmc); l++)
+ osm_sw->new_lft[dlid_base + l] = dp;
+ else
+ success = false;
+ }
+ }
+ return success;
+}
+
+static
+osm_mtree_node_t *mcast_stree_branch(struct t_switch *sw, osm_switch_t *osm_sw,
+ osm_mgrp_box_t *mgb, unsigned depth,
+ unsigned *port_cnt, unsigned *max_depth)
+{
+ osm_mtree_node_t *mtn = NULL;
+ osm_mcast_tbl_t *mcast_tbl, *ds_mcast_tbl;
+ osm_node_t *ds_node;
+ struct t_switch *ds_sw;
+ struct port_grp *ptgrp;
+ struct link *link;
+ struct endpoint *port;
+ unsigned g, p;
+ unsigned mcast_fwd_ports = 0, mcast_end_ports = 0;
+
+ depth++;
+
+ if (osm_sw->priv != sw) {
+ OSM_LOG(&sw->torus->osm->log, OSM_LOG_ERROR,
+ "ERR 4E3E: osm_sw (GUID 0x%04"PRIx64") "
+ "not in torus fabric description\n",
+ cl_ntoh64(osm_node_get_node_guid(osm_sw->p_node)));
+ goto out;
+ }
+ if (!osm_switch_supports_mcast(osm_sw)) {
+ OSM_LOG(&sw->torus->osm->log, OSM_LOG_ERROR,
+ "ERR 4E3F: osm_sw (GUID 0x%04"PRIx64") "
+ "does not support multicast\n",
+ cl_ntoh64(osm_node_get_node_guid(osm_sw->p_node)));
+ goto out;
+ }
+ mtn = osm_mtree_node_new(osm_sw);
+ if (!mtn) {
+ OSM_LOG(&sw->torus->osm->log, OSM_LOG_ERROR,
+ "ERR 4E46: Insufficient memory to build multicast tree\n");
+ goto out;
+ }
+ mcast_tbl = osm_switch_get_mcast_tbl_ptr(osm_sw);
+ /*
+ * Recurse to downstream switches, i.e. those closer to master
+ * spanning tree branch tips.
+ *
+ * Note that if there are multiple ports in this port group, i.e.,
+ * multiple parallel links, we can pick any one of them to use for
+ * any individual MLID without causing loops. Pick one based on MLID
+ * for now, until someone turns up evidence we need to be smarter.
+ *
+ * Also, it might be we got called in a window between a switch getting
+ * removed from the fabric, and torus-2QoS getting to rebuild its
+ * fabric representation. If that were to happen, our next hop
+ * osm_switch pointer might be stale. Look it up via opensm's fabric
+ * description to be sure it's not.
+ */
+ for (g = 0; g < 2 * TORUS_MAX_DIM; g++) {
+ ptgrp = &sw->ptgrp[g];
+ if (!ptgrp->to_stree_tip)
+ continue;
+
+ p = mgb->mlid % ptgrp->port_cnt;/* port # in port group */
+ p = ptgrp->port[p]->port; /* now port # in switch */
+
+ ds_node = osm_node_get_remote_node(osm_sw->p_node, p, NULL);
+ ds_sw = ptgrp->to_stree_tip->sw;
+
+ if (!(ds_node && ds_node->sw &&
+ ds_sw->osm_switch == ds_node->sw)) {
+ OSM_LOG(&sw->torus->osm->log, OSM_LOG_ERROR,
+ "ERR 4E40: stale pointer to osm_sw "
+ "(GUID 0x%04"PRIx64")\n", cl_ntoh64(ds_sw->n_id));
+ continue;
+ }
+ mtn->child_array[p] =
+ mcast_stree_branch(ds_sw, ds_node->sw, mgb,
+ depth, port_cnt, max_depth);
+ if (!mtn->child_array[p])
+ continue;
+
+ osm_mcast_tbl_set(mcast_tbl, mgb->mlid, p);
+ mcast_fwd_ports++;
+ /*
+ * Since we forward traffic for this multicast group on this
+ * port, cause the switch on the other end of the link
+ * to forward traffic back to us. Do it now since have at
+ * hand the link used; otherwise it'll be hard to figure out
+ * later, and if we get it wrong we get a MC routing loop.
+ */
+ link = sw->port[p]->link;
+ ds_mcast_tbl = osm_switch_get_mcast_tbl_ptr(ds_node->sw);
+
+ if (&link->end[0] == sw->port[p])
+ osm_mcast_tbl_set(ds_mcast_tbl, mgb->mlid,
+ link->end[1].port);
+ else
+ osm_mcast_tbl_set(ds_mcast_tbl, mgb->mlid,
+ link->end[0].port);
+ }
+ /*
+ * Add any host ports marked as in mcast group into spanning tree.
+ */
+ ptgrp = &sw->ptgrp[2 * TORUS_MAX_DIM];
+ for (p = 0; p < ptgrp->port_cnt; p++) {
+ port = ptgrp->port[p];
+ if (port->tmp) {
+ port->tmp = NULL;
+ mtn->child_array[port->port] = OSM_MTREE_LEAF;
+ osm_mcast_tbl_set(mcast_tbl, mgb->mlid, port->port);
+ mcast_end_ports++;
+ }
+ }
+ if (!(mcast_end_ports || mcast_fwd_ports)) {
+ osm_mtree_destroy(mtn);
+ mtn = NULL;
+ } else if (depth > *max_depth)
+ *max_depth = depth;
+
+ *port_cnt += mcast_end_ports;
+out:
+ return mtn;
+}
+
+static
+osm_port_t *next_mgrp_box_port(osm_mgrp_box_t *mgb,
+ cl_list_item_t **list_iterator,
+ cl_map_item_t **map_iterator)
+{
+ osm_mgrp_t *mgrp;
+ osm_mcm_port_t *mcm_port;
+ osm_port_t *osm_port = NULL;
+ cl_map_item_t *m_item = *map_iterator;
+ cl_list_item_t *l_item = *list_iterator;
+
+next_mgrp:
+ if (!l_item)
+ l_item = cl_qlist_head(&mgb->mgrp_list);
+ if (l_item == cl_qlist_end(&mgb->mgrp_list)) {
+ l_item = NULL;
+ goto out;
+ }
+ mgrp = cl_item_obj(l_item, mgrp, list_item);
+
+ if (!m_item)
+ m_item = cl_qmap_head(&mgrp->mcm_port_tbl);
+ if (m_item == cl_qmap_end(&mgrp->mcm_port_tbl)) {
+ m_item = NULL;
+ l_item = cl_qlist_next(l_item);
+ goto next_mgrp;
+ }
+ mcm_port = cl_item_obj(m_item, mcm_port, map_item);
+ m_item = cl_qmap_next(m_item);
+ osm_port = mcm_port->port;
+out:
+ *list_iterator = l_item;
+ *map_iterator = m_item;
+ return osm_port;
+}
+
+static
+ib_api_status_t torus_mcast_stree(void *context, osm_mgrp_box_t *mgb)
+{
+ struct torus_context *ctx = context;
+ struct torus *t = ctx->torus;
+ cl_map_item_t *m_item = NULL;
+ cl_list_item_t *l_item = NULL;
+ osm_port_t *osm_port;
+ osm_switch_t *osm_sw;
+ struct endpoint *port;
+ unsigned port_cnt = 0, max_depth = 0;
+
+ osm_purge_mtree(&ctx->osm->sm, mgb);
+
+ /*
+ * Build a spanning tree for a multicast group by first marking
+ * the torus endpoints that are participating in the group.
+ * Then do a depth-first search of the torus master spanning
+ * tree to build up the spanning tree specific to this group.
+ *
+ * Since the torus master spanning tree is constructed specifically
+ * to guarantee that multicast will not deadlock against unicast
+ * when they share VLs, we can be sure that any multicast group
+ * spanning tree constructed this way has the same property.
+ */
+ while ((osm_port = next_mgrp_box_port(mgb, &l_item, &m_item))) {
+ port = osm_port->priv;
+ if (!(port && port->osm_port == osm_port)) {
+ port = osm_port_relink_endpoint(osm_port);
+ if (!port) {
+ guid_t id;
+ id = osm_node_get_node_guid(osm_port->p_node);
+ OSM_LOG(&ctx->osm->log, OSM_LOG_ERROR,
+ "ERR 4E41: osm_port (GUID 0x%04"PRIx64") "
+ "not in torus fabric description\n",
+ cl_ntoh64(id));
+ continue;
+ }
+ }
+ /*
+ * If this is a CA port, mark the switch port at the
+ * other end of this port's link.
+ *
+ * By definition, a CA port is connected to end[1] of a link,
+ * and the switch port is end[0]. See build_ca_link() and
+ * link_srcsink().
+ */
+ if (port->link)
+ port = &port->link->end[0];
+ port->tmp = osm_port;
+ }
+ /*
+ * It might be we got called in a window between a switch getting
+ * removed from the fabric, and torus-2QoS getting to rebuild its
+ * fabric representation. If that were to happen, our
+ * master_stree_root->osm_switch pointer might be stale. Look up
+ * the osm_switch by GUID to be sure it's not.
+ *
+ * Also, call into mcast_stree_branch with depth = -1, because
+ * depth at root switch needs to be 0.
+ */
+ osm_sw = (osm_switch_t *)cl_qmap_get(&ctx->osm->subn.sw_guid_tbl,
+ t->master_stree_root->n_id);
+ if (!(osm_sw && t->master_stree_root->osm_switch == osm_sw)) {
+ OSM_LOG(&ctx->osm->log, OSM_LOG_ERROR,
+ "ERR 4E42: stale pointer to osm_sw (GUID 0x%04"PRIx64")\n",
+ cl_ntoh64(t->master_stree_root->n_id));
+ return IB_ERROR;
+ }
+ mgb->root = mcast_stree_branch(t->master_stree_root, osm_sw,
+ mgb, -1, &port_cnt, &max_depth);
+
+ OSM_LOG(&ctx->osm->log, OSM_LOG_VERBOSE,
+ "Configured MLID 0x%X for %u ports, max tree depth = %u\n",
+ mgb->mlid, port_cnt, max_depth);
+
+ return IB_SUCCESS;
+}
+
+static
+bool good_xy_ring(struct torus *t, const int x, const int y, const int z)
+{
+ struct t_switch ****sw = t->sw;
+ bool good_ring = true;
+ int x_tst, y_tst;
+
+ for (x_tst = 0; x_tst < t->x_sz && good_ring; x_tst++)
+ good_ring = sw[x_tst][y][z];
+
+ for (y_tst = 0; y_tst < t->y_sz && good_ring; y_tst++)
+ good_ring = sw[x][y_tst][z];
+
+ return good_ring;
+}
+
+static
+struct t_switch *find_plane_mid(struct torus *t, const int z)
+{
+ int x, dx, xm = t->x_sz / 2;
+ int y, dy, ym = t->y_sz / 2;
+ struct t_switch ****sw = t->sw;
+
+ if (good_xy_ring(t, xm, ym, z))
+ return sw[xm][ym][z];
+
+ for (dx = 1, dy = 1; dx <= xm && dy <= ym; dx++, dy++) {
+
+ x = canonicalize(xm - dx, t->x_sz);
+ y = canonicalize(ym - dy, t->y_sz);
+ if (good_xy_ring(t, x, y, z))
+ return sw[x][y][z];
+
+ x = canonicalize(xm + dx, t->x_sz);
+ y = canonicalize(ym + dy, t->y_sz);
+ if (good_xy_ring(t, x, y, z))
+ return sw[x][y][z];
+ }
+ return NULL;
+}
+
+static
+struct t_switch *find_stree_root(struct torus *t)
+{
+ int x, y, z, dz, zm = t->z_sz / 2;
+ struct t_switch ****sw = t->sw;
+ struct t_switch *root;
+ bool good_plane;
+
+ /*
+ * Look for a switch near the "center" (wrt. the datelines) of the
+ * torus, as that will be the most optimum spanning tree root. Use
+ * a search that is not exhaustive, on the theory that this routing
+ * engine isn't useful anyway if too many switches are missing.
+ *
+ * Also, want to pick an x-y plane with no missing switches, so that
+ * the master spanning tree construction algorithm doesn't have to
+ * deal with needing a turn on a missing switch.
+ */
+ for (dz = 0; dz <= zm; dz++) {
+
+ z = canonicalize(zm - dz, t->z_sz);
+ good_plane = true;
+ for (y = 0; y < t->y_sz && good_plane; y++)
+ for (x = 0; x < t->x_sz && good_plane; x++)
+ good_plane = sw[x][y][z];
+
+ if (good_plane) {
+ root = find_plane_mid(t, z);
+ if (root)
+ goto out;
+ }
+ if (!dz)
+ continue;
+
+ z = canonicalize(zm + dz, t->z_sz);
+ good_plane = true;
+ for (y = 0; y < t->y_sz && good_plane; y++)
+ for (x = 0; x < t->x_sz && good_plane; x++)
+ good_plane = sw[x][y][z];
+
+ if (good_plane) {
+ root = find_plane_mid(t, z);
+ if (root)
+ goto out;
+ }
+ }
+ /*
+ * Note that torus-2QoS can route a torus that is missing an entire
+ * column (switches with x,y constant, for all z values) without
+ * deadlocks.
+ *
+ * if we've reached this point, we must have a column of missing
+ * switches, as routable_torus() would have returned false for
+ * any other configuration of missing switches that made it through
+ * the above.
+ *
+ * So any switch in the mid-z plane will do as the root.
+ */
+ root = find_plane_mid(t, zm);
+out:
+ return root;
+}
+
+static
+bool sw_in_master_stree(struct t_switch *sw)
+{
+ int g;
+ bool connected;
+
+ connected = sw == sw->torus->master_stree_root;
+ for (g = 0; g < 2 * TORUS_MAX_DIM; g++)
+ connected = connected || sw->ptgrp[g].to_stree_root;
+
+ return connected;
+}
+
+static
+void grow_master_stree_branch(struct t_switch *root, struct t_switch *tip,
+ unsigned to_root_pg, unsigned to_tip_pg)
+{
+ root->ptgrp[to_tip_pg].to_stree_tip = &tip->ptgrp[to_root_pg];
+ tip->ptgrp[to_root_pg].to_stree_root = &root->ptgrp[to_tip_pg];
+}
+
+static
+void build_master_stree_branch(struct t_switch *branch_root, int cdir)
+{
+ struct t_switch *sw, *n_sw, *p_sw;
+ unsigned l, idx, cnt, pg, ng;
+
+ switch (cdir) {
+ case 0:
+ idx = branch_root->i;
+ cnt = branch_root->torus->x_sz;
+ break;
+ case 1:
+ idx = branch_root->j;
+ cnt = branch_root->torus->y_sz;
+ break;
+ case 2:
+ idx = branch_root->k;
+ cnt = branch_root->torus->z_sz;
+ break;
+ default:
+ goto out;
+ }
+ /*
+ * This algorithm intends that a spanning tree branch never crosses
+ * a dateline unless the 1-D ring for which we're building the branch
+ * is interrupted by failure. We need that guarantee to prevent
+ * multicast/unicast credit loops.
+ */
+ n_sw = branch_root; /* tip of negative cdir branch */
+ ng = 2 * cdir; /* negative cdir port group index */
+ p_sw = branch_root; /* tip of positive cdir branch */
+ pg = 2 * cdir + 1; /* positive cdir port group index */
+
+ for (l = idx; n_sw && l >= 1; l--) {
+ sw = ring_next_sw(n_sw, cdir, -1);
+ if (sw && !sw_in_master_stree(sw)) {
+ grow_master_stree_branch(n_sw, sw, pg, ng);
+ n_sw = sw;
+ } else
+ n_sw = NULL;
+ }
+ for (l = idx; p_sw && l < (cnt - 1); l++) {
+ sw = ring_next_sw(p_sw, cdir, 1);
+ if (sw && !sw_in_master_stree(sw)) {
+ grow_master_stree_branch(p_sw, sw, ng, pg);
+ p_sw = sw;
+ } else
+ p_sw = NULL;
+ }
+ if (n_sw && p_sw)
+ goto out;
+ /*
+ * At least one branch couldn't grow to the dateline for this ring.
+ * That means it is acceptable to grow the branch by crossing the
+ * dateline.
+ */
+ for (l = 0; l < cnt; l++) {
+ if (n_sw) {
+ sw = ring_next_sw(n_sw, cdir, -1);
+ if (sw && !sw_in_master_stree(sw)) {
+ grow_master_stree_branch(n_sw, sw, pg, ng);
+ n_sw = sw;
+ } else
+ n_sw = NULL;
+ }
+ if (p_sw) {
+ sw = ring_next_sw(p_sw, cdir, 1);
+ if (sw && !sw_in_master_stree(sw)) {
+ grow_master_stree_branch(p_sw, sw, ng, pg);
+ p_sw = sw;
+ } else
+ p_sw = NULL;
+ }
+ if (!(n_sw || p_sw))
+ break;
+ }
+out:
+ return;
+}
+
+static
+bool torus_master_stree(struct torus *t)
+{
+ int i, j, k;
+ bool success = false;
+ struct t_switch *stree_root = find_stree_root(t);
+
+ if (stree_root)
+ build_master_stree_branch(stree_root, 0);
+ else
+ goto out;
+
+ k = stree_root->k;
+ for (i = 0; i < t->x_sz; i++) {
+ j = stree_root->j;
+ if (t->sw[i][j][k])
+ build_master_stree_branch(t->sw[i][j][k], 1);
+
+ for (j = 0; j < t->y_sz; j++)
+ if (t->sw[i][j][k])
+ build_master_stree_branch(t->sw[i][j][k], 2);
+ }
+ t->master_stree_root = stree_root;
+ /*
+ * At this point we should have a master spanning tree that contains
+ * every present switch, for all fabrics that torus-2QoS can route
+ * without deadlocks. Make sure this is the case; otherwise warn
+ * and return failure so we get bug reports.
+ */
+ success = true;
+ for (i = 0; i < t->x_sz; i++)
+ for (j = 0; j < t->y_sz; j++)
+ for (k = 0; k < t->z_sz; k++) {
+ struct t_switch *sw = t->sw[i][j][k];
+ if (!sw || sw_in_master_stree(sw))
+ continue;
+
+ success = false;
+ OSM_LOG(&t->osm->log, OSM_LOG_ERROR,
+ "ERR 4E43: sw 0x%04"PRIx64" (%d,%d,%d) not in "
+ "torus multicast master spanning tree\n",
+ cl_ntoh64(sw->n_id), i, j, k);
+ }
+out:
+ return success;
+}
+
+int route_torus(struct torus *t)
+{
+ int s;
+ bool success = true;
+
+ for (s = 0; s < (int)t->switch_cnt; s++)
+ success = torus_lft(t, t->sw_pool[s]) && success;
+
+ success = success && torus_master_stree(t);
+
+ return success ? 0 : -1;
+}
+
+uint8_t torus_path_sl(void *context, uint8_t path_sl_hint,
+ const ib_net16_t slid, const ib_net16_t dlid)
+{
+ struct torus_context *ctx = context;
+ osm_opensm_t *p_osm = ctx->osm;
+ osm_log_t *log = &p_osm->log;
+ osm_port_t *osm_sport, *osm_dport;
+ struct endpoint *sport, *dport;
+ struct t_switch *ssw, *dsw;
+ struct torus *t;
+ guid_t guid;
+ unsigned sl = 0;
+
+ osm_sport = osm_get_port_by_lid(&p_osm->subn, slid);
+ if (!osm_sport)
+ goto out;
+
+ osm_dport = osm_get_port_by_lid(&p_osm->subn, dlid);
+ if (!osm_dport)
+ goto out;
+
+ sport = osm_sport->priv;
+ if (!(sport && sport->osm_port == osm_sport)) {
+ sport = osm_port_relink_endpoint(osm_sport);
+ if (!sport) {
+ guid = osm_node_get_node_guid(osm_sport->p_node);
+ OSM_LOG(log, OSM_LOG_INFO,
+ "Note: osm_sport (GUID 0x%04"PRIx64") "
+ "not in torus fabric description\n",
+ cl_ntoh64(guid));
+ goto out;
+ }
+ }
+ dport = osm_dport->priv;
+ if (!(dport && dport->osm_port == osm_dport)) {
+ dport = osm_port_relink_endpoint(osm_dport);
+ if (!dport) {
+ guid = osm_node_get_node_guid(osm_dport->p_node);
+ OSM_LOG(log, OSM_LOG_INFO,
+ "Note: osm_dport (GUID 0x%04"PRIx64") "
+ "not in torus fabric description\n",
+ cl_ntoh64(guid));
+ goto out;
+ }
+ }
+ /*
+ * We're only supposed to be called for CA ports, and maybe
+ * switch management ports.
+ */
+ if (sport->type != SRCSINK) {
+ guid = osm_node_get_node_guid(osm_sport->p_node);
+ OSM_LOG(log, OSM_LOG_INFO,
+ "Error: osm_sport (GUID 0x%04"PRIx64") "
+ "not a data src/sink port\n", cl_ntoh64(guid));
+ goto out;
+ }
+ if (dport->type != SRCSINK) {
+ guid = osm_node_get_node_guid(osm_dport->p_node);
+ OSM_LOG(log, OSM_LOG_INFO,
+ "Error: osm_dport (GUID 0x%04"PRIx64") "
+ "not a data src/sink port\n", cl_ntoh64(guid));
+ goto out;
+ }
+ /*
+ * By definition, a CA port is connected to end[1] of a link, and
+ * the switch port is end[0]. See build_ca_link() and link_srcsink().
+ */
+ if (sport->link) {
+ ssw = sport->link->end[0].sw;
+ } else {
+ ssw = sport->sw;
+ }
+ if (dport->link)
+ dsw = dport->link->end[0].sw;
+ else
+ dsw = dport->sw;
+
+ t = ssw->torus;
+
+ sl = sl_set_use_loop_vl(use_vl1(ssw->i, dsw->i, t->x_sz), 0);
+ sl |= sl_set_use_loop_vl(use_vl1(ssw->j, dsw->j, t->y_sz), 1);
+ sl |= sl_set_use_loop_vl(use_vl1(ssw->k, dsw->k, t->z_sz), 2);
+ sl |= sl_set_qos(sl_get_qos(path_sl_hint));
+out:
+ return sl;
+}
+
+static
+void sum_vlarb_weights(const char *vlarb_str,
+ unsigned total_weight[IB_MAX_NUM_VLS])
+{
+ unsigned i = 0, v, vl = 0;
+ char *end;
+
+ while (*vlarb_str && i++ < 2 * IB_NUM_VL_ARB_ELEMENTS_IN_BLOCK) {
+ v = strtoul(vlarb_str, &end, 0);
+ if (*end)
+ end++;
+ vlarb_str = end;
+ if (i & 0x1)
+ vl = v & 0xf;
+ else
+ total_weight[vl] += v & 0xff;
+ }
+}
+
+static
+int uniform_vlarb_weight_value(unsigned *weight, unsigned count)
+{
+ int i, v = weight[0];
+
+ for (i = 1; i < count; i++) {
+ if (v != weight[i])
+ return -1;
+ }
+ return v;
+}
+
+static
+void check_vlarb_config(const char *vlarb_str, bool is_default,
+ const char *str, const char *pri, osm_log_t *log)
+{
+ unsigned total_weight[IB_MAX_NUM_VLS] = {0,};
+
+ sum_vlarb_weights(vlarb_str, total_weight);
+ if (!(uniform_vlarb_weight_value(&total_weight[0], 4) >= 0 &&
+ uniform_vlarb_weight_value(&total_weight[4], 4) >= 0))
+ OSM_LOG(log, OSM_LOG_INFO,
+ "Warning: torus-2QoS requires same VLarb weights for "
+ "VLs 0-3; also for VLs 4-7: not true for %s "
+ "%s_vlarb_%s\n",
+ (is_default ? "default" : "configured"), str, pri);
+}
+
+/*
+ * Use this to check the qos_config for switch external ports.
+ */
+static
+void check_qos_swe_config(osm_qos_options_t *opt,
+ osm_qos_options_t *def, osm_log_t *log)
+{
+ const char *vlarb_str, *tstr;
+ bool is_default;
+ unsigned max_vls;
+
+ max_vls = def->max_vls;
+ if (opt->max_vls > 0)
+ max_vls = opt->max_vls;
+
+ if (max_vls > 0 && max_vls < 8)
+ OSM_LOG(log, OSM_LOG_INFO,
+ "Warning: full torus-2QoS functionality not available "
+ "for configured %s_max_vls = %d\n",
+ (opt->max_vls > 0 ? "qos_swe" : "qos"), opt->max_vls);
+
+ vlarb_str = opt->vlarb_high;
+ is_default = false;
+ tstr = "qos_swe";
+ if (!vlarb_str) {
+ vlarb_str = def->vlarb_high;
+ tstr = "qos";
+ }
+ if (!vlarb_str) {
+ vlarb_str = OSM_DEFAULT_QOS_VLARB_HIGH;
+ is_default = true;
+ }
+ check_vlarb_config(vlarb_str, is_default, tstr, "high", log);
+
+ vlarb_str = opt->vlarb_low;
+ is_default = false;
+ tstr = "qos_swe";
+ if (!vlarb_str) {
+ vlarb_str = def->vlarb_low;
+ tstr = "qos";
+ }
+ if (!vlarb_str) {
+ vlarb_str = OSM_DEFAULT_QOS_VLARB_LOW;
+ is_default = true;
+ }
+ check_vlarb_config(vlarb_str, is_default, tstr, "low", log);
+
+ if (opt->sl2vl)
+ OSM_LOG(log, OSM_LOG_INFO,
+ "Warning: torus-2QoS must override configured "
+ "qos_swe_sl2vl to generate deadlock-free routes\n");
+}
+
+static
+void check_ep_vlarb_config(const char *vlarb_str,
+ bool is_default, bool is_specific,
+ const char *str, const char *pri, osm_log_t *log)
+{
+ unsigned i, total_weight[IB_MAX_NUM_VLS] = {0,};
+ int val = 0;
+
+ sum_vlarb_weights(vlarb_str, total_weight);
+ for (i = 2; i < 8; i++) {
+ val += total_weight[i];
+ }
+ if (!val)
+ return;
+
+ if (is_specific)
+ OSM_LOG(log, OSM_LOG_INFO,
+ "Warning: torus-2QoS recommends 0 VLarb weights"
+ " for VLs 2-7 on endpoint links; not true for "
+ " configured %s_vlarb_%s\n", str, pri);
+ else
+ OSM_LOG(log, OSM_LOG_INFO,
+ "Warning: torus-2QoS recommends 0 VLarb weights "
+ "for VLs 2-7 on endpoint links; not true for %s "
+ "qos_vlarb_%s values used for %s_vlarb_%s\n",
+ (is_default ? "default" : "configured"), pri, str, pri);
+}
+
+/*
+ * Use this to check the qos_config for endports
+ */
+static
+void check_qos_ep_config(osm_qos_options_t *opt, osm_qos_options_t *def,
+ const char *str, osm_log_t *log)
+{
+ const char *vlarb_str;
+ bool is_default, is_specific;
+ unsigned max_vls;
+
+ max_vls = def->max_vls;
+ if (opt->max_vls > 0)
+ max_vls = opt->max_vls;
+
+ if (max_vls > 0 && max_vls < 2)
+ OSM_LOG(log, OSM_LOG_INFO,
+ "Warning: full torus-2QoS functionality not available "
+ "for configured %s_max_vls = %d\n",
+ (opt->max_vls > 0 ? str : "qos"), opt->max_vls);
+
+ vlarb_str = opt->vlarb_high;
+ is_default = false;
+ is_specific = true;
+ if (!vlarb_str) {
+ vlarb_str = def->vlarb_high;
+ is_specific = false;
+ }
+ if (!vlarb_str) {
+ vlarb_str = OSM_DEFAULT_QOS_VLARB_HIGH;
+ is_default = true;
+ }
+ check_ep_vlarb_config(vlarb_str, is_default, is_specific,
+ str, "high", log);
+
+ vlarb_str = opt->vlarb_low;
+ is_default = false;
+ is_specific = true;
+ if (!vlarb_str) {
+ vlarb_str = def->vlarb_low;
+ is_specific = false;
+ }
+ if (!vlarb_str) {
+ vlarb_str = OSM_DEFAULT_QOS_VLARB_LOW;
+ is_default = true;
+ }
+ check_ep_vlarb_config(vlarb_str, is_default, is_specific,
+ str, "low", log);
+
+ if (opt->sl2vl)
+ OSM_LOG(log, OSM_LOG_INFO,
+ "Warning: torus-2QoS must override configured "
+ "%s_sl2vl to generate deadlock-free routes\n", str);
+}
+
+static
+int torus_build_lfts(void *context)
+{
+ int status = -1;
+ struct torus_context *ctx = context;
+ struct fabric *fabric;
+ struct torus *torus;
+
+ if (!ctx->osm->subn.opt.qos) {
+ OSM_LOG(&ctx->osm->log, OSM_LOG_ERROR,
+ "ERR 4E44: Routing engine list contains torus-2QoS. "
+ "Enable QoS for correct operation "
+ "(-Q or 'qos TRUE' in opensm.conf).\n");
+ return status;
+ }
+
+ fabric = &ctx->fabric;
+ teardown_fabric(fabric);
+
+ torus = calloc(1, sizeof(*torus));
+ if (!torus) {
+ OSM_LOG(&ctx->osm->log, OSM_LOG_ERROR,
+ "ERR 4E45: allocating torus: %s\n", strerror(errno));
+ goto out;
+ }
+ torus->osm = ctx->osm;
+ fabric->osm = ctx->osm;
+
+ if (!parse_config(ctx->osm->subn.opt.torus_conf_file,
+ fabric, torus))
+ goto out;
+
+ if (!capture_fabric(fabric))
+ goto out;
+
+ OSM_LOG(&torus->osm->log, OSM_LOG_INFO,
+ "Found fabric w/ %d links, %d switches, %d CA ports, "
+ "minimum data VLs: endport %d, switchport %d\n",
+ (int)fabric->link_cnt, (int)fabric->switch_cnt,
+ (int)fabric->ca_cnt, (int)ctx->osm->subn.min_data_vls,
+ (int)ctx->osm->subn.min_sw_data_vls);
+
+ if (!verify_setup(torus, fabric))
+ goto out;
+
+ OSM_LOG(&torus->osm->log, OSM_LOG_INFO,
+ "Looking for %d x %d x %d %s\n",
+ (int)torus->x_sz, (int)torus->y_sz, (int)torus->z_sz,
+ (ALL_MESH(torus->flags) ? "mesh" : "torus"));
+
+ if (!build_torus(fabric, torus)) {
+ OSM_LOG(&torus->osm->log, OSM_LOG_ERROR, "ERR 4E57: "
+ "build_torus finished with errors\n");
+ goto out;
+ }
+
+ OSM_LOG(&torus->osm->log, OSM_LOG_INFO,
+ "Built %d x %d x %d %s w/ %d links, %d switches, %d CA ports\n",
+ (int)torus->x_sz, (int)torus->y_sz, (int)torus->z_sz,
+ (ALL_MESH(torus->flags) ? "mesh" : "torus"),
+ (int)torus->link_cnt, (int)torus->switch_cnt,
+ (int)torus->ca_cnt);
+
+ diagnose_fabric(fabric);
+ /*
+ * Since we found some sort of torus fabric, report on any topology
+ * changes vs. the last torus we found.
+ */
+ if (torus->flags & NOTIFY_CHANGES)
+ report_torus_changes(torus, ctx->torus);
+
+ if (routable_torus(torus, fabric))
+ status = route_torus(torus);
+
+out:
+ if (status) { /* bad torus!! */
+ if (torus)
+ teardown_torus(torus);
+ } else {
+ osm_subn_opt_t *opt = &torus->osm->subn.opt;
+ osm_log_t *log = &torus->osm->log;
+
+ if (ctx->torus)
+ teardown_torus(ctx->torus);
+ ctx->torus = torus;
+
+ check_qos_swe_config(&opt->qos_swe_options, &opt->qos_options,
+ log);
+
+ check_qos_ep_config(&opt->qos_ca_options,
+ &opt->qos_options, "qos_ca", log);
+ check_qos_ep_config(&opt->qos_sw0_options,
+ &opt->qos_options, "qos_sw0", log);
+ check_qos_ep_config(&opt->qos_rtr_options,
+ &opt->qos_options, "qos_rtr", log);
+ }
+ teardown_fabric(fabric);
+ return status;
+}
+
+int osm_ucast_torus2QoS_setup(struct osm_routing_engine *r,
+ osm_opensm_t *osm)
+{
+ struct torus_context *ctx;
+
+ ctx = torus_context_create(osm);
+ if (!ctx)
+ return -1;
+
+ r->context = ctx;
+ r->ucast_build_fwd_tables = torus_build_lfts;
+ r->build_lid_matrices = ucast_dummy_build_lid_matrices;
+ r->update_sl2vl = torus_update_osm_sl2vl;
+ r->update_vlarb = torus_update_osm_vlarb;
+ r->path_sl = torus_path_sl;
+ r->mcast_build_stree = torus_mcast_stree;
+ r->destroy = torus_context_delete;
+ return 0;
+}
diff --git a/contrib/ofed/opensm/opensm/osm_trap_rcv.c b/contrib/ofed/opensm/opensm/osm_trap_rcv.c
new file mode 100644
index 0000000..2aef40e
--- /dev/null
+++ b/contrib/ofed/opensm/opensm/osm_trap_rcv.c
@@ -0,0 +1,689 @@
+/*
+ * Copyright (c) 2004-2009 Voltaire, Inc. All rights reserved.
+ * Copyright (c) 2002-2007 Mellanox Technologies LTD. All rights reserved.
+ * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
+ * Copyright (c) 2009,2010 HNR Consulting. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+/*
+ * Abstract:
+ * Implementation of osm_trap_rcv_t.
+ * This object represents the Trap Receiver object.
+ * This object is part of the opensm family of objects.
+ */
+
+#if HAVE_CONFIG_H
+# include <config.h>
+#endif /* HAVE_CONFIG_H */
+
+#include <string.h>
+#include <iba/ib_types.h>
+#include <complib/cl_qmap.h>
+#include <complib/cl_debug.h>
+#include <opensm/osm_file_ids.h>
+#define FILE_ID OSM_FILE_TRAP_RCV_C
+#include <opensm/osm_madw.h>
+#include <opensm/osm_log.h>
+#include <opensm/osm_node.h>
+#include <opensm/osm_helper.h>
+#include <opensm/osm_subnet.h>
+#include <opensm/osm_inform.h>
+#include <opensm/osm_opensm.h>
+
+extern void osm_req_get_node_desc(IN osm_sm_t * sm, osm_physp_t *p_physp);
+
+/**********************************************************************
+ *
+ * TRAP HANDLING:
+ *
+ * Assuming traps can be caused by bad hardware we should provide
+ * a mechanism for filtering their propagation into the actual logic
+ * of OpenSM such that it is not overloaded by them.
+ *
+ * We will provide a trap filtering mechanism with "Aging" capability.
+ * This mechanism will track incoming traps, clasify them by their
+ * source and content and provide back their age.
+ *
+ * A timer running in the background will toggle a timer counter
+ * that should be referenced by the aging algorithm.
+ * To provide an efficient handling of aging, we also track all traps
+ * in a sorted list by their aging.
+ *
+ * The generic Aging Tracker mechanism is implemented in the
+ * cl_aging_tracker object.
+ *
+ **********************************************************************/
+
+static osm_physp_t *get_physp_by_lid_and_num(IN osm_sm_t * sm,
+ IN ib_net16_t lid, IN uint8_t num)
+{
+ osm_port_t *p_port = osm_get_port_by_lid(sm->p_subn, lid);
+ if (!p_port)
+ return NULL;
+
+ if (osm_node_get_num_physp(p_port->p_node) <= num)
+ return NULL;
+
+ return osm_node_get_physp_ptr(p_port->p_node, num);
+}
+
+static uint64_t aging_tracker_callback(IN uint64_t key, IN uint32_t num_regs,
+ IN void *context)
+{
+ osm_sm_t *sm = context;
+ ib_net16_t lid;
+ uint8_t port_num;
+ osm_physp_t *p_physp;
+
+ OSM_LOG_ENTER(sm->p_log);
+
+ if (osm_exit_flag)
+ /* We got an exit flag - do nothing */
+ return 0;
+
+ lid = (ib_net16_t) ((key & 0x0000FFFF00000000ULL) >> 32);
+ port_num = (uint8_t) ((key & 0x00FF000000000000ULL) >> 48);
+
+ CL_PLOCK_ACQUIRE(sm->p_lock);
+
+ p_physp = get_physp_by_lid_and_num(sm, lid, port_num);
+ if (!p_physp)
+ OSM_LOG(sm->p_log, OSM_LOG_VERBOSE,
+ "Cannot find port num:%u with lid:%u\n",
+ port_num, cl_ntoh16(lid));
+ /* make sure the physp is still valid */
+ /* If the health port was false - set it to true */
+ else if (!osm_physp_is_healthy(p_physp)) {
+ OSM_LOG(sm->p_log, OSM_LOG_VERBOSE,
+ "Clearing health bit of port num:%u with lid:%u\n",
+ port_num, cl_ntoh16(lid));
+
+ /* Clear its health bit */
+ osm_physp_set_health(p_physp, TRUE);
+ }
+
+ CL_PLOCK_RELEASE(sm->p_lock);
+ OSM_LOG_EXIT(sm->p_log);
+
+ /* We want to remove the event from the tracker - so
+ need to return zero. */
+ return 0;
+}
+
+/**********************************************************************
+ * CRC calculation for notice identification
+ **********************************************************************/
+
+#define CRC32_POLYNOMIAL 0xEDB88320L
+
+/* calculate the crc for a given buffer */
+static uint32_t trap_calc_crc32(void *buffer, uint32_t count)
+{
+ uint32_t temp1, temp2;
+ uint32_t crc = -1L;
+ unsigned char *p = (unsigned char *)buffer;
+ /* precalculated table for faster crc calculation */
+ static uint32_t crc_table[256];
+ static boolean_t first = TRUE;
+ int i, j;
+
+ /* if we need to initialize the lookup table */
+ if (first) {
+ /* calc the CRC table */
+ for (i = 0; i <= 255; i++) {
+ crc = i;
+ for (j = 8; j > 0; j--)
+ if (crc & 1)
+ crc = (crc >> 1) ^ CRC32_POLYNOMIAL;
+ else
+ crc >>= 1;
+ crc_table[i] = crc;
+ }
+ first = FALSE;
+ }
+
+ crc = -1L;
+ /* do the calculation */
+ while (count-- != 0) {
+ temp1 = (crc >> 8) & 0x00FFFFFFL;
+ temp2 = crc_table[((int)crc ^ *p++) & 0xFF];
+ crc = temp1 ^ temp2;
+ }
+ return crc;
+}
+
+/* The key is created in the following manner:
+ port_num lid crc
+ \______/ \___/ \___/
+ 16b 16b 32b
+*/
+static uint64_t trap_get_key(IN uint16_t lid, IN uint8_t port_num,
+ IN ib_mad_notice_attr_t * p_ntci)
+{
+ uint32_t crc = trap_calc_crc32(p_ntci, sizeof(ib_mad_notice_attr_t));
+ return ((uint64_t) port_num << 48) | ((uint64_t) lid << 32) | crc;
+}
+
+static int print_num_received(IN uint32_t num_received)
+{
+ uint32_t i;
+
+ /* Series is 10, 20, 50, 100, 200, 500, ... */
+ i = num_received;
+ while (i >= 10) {
+ if (i % 10)
+ break;
+ i = i / 10;
+ }
+
+ if (i == 1 || i == 2 || i == 5)
+ return 1;
+ else
+ return 0;
+}
+
+static int disable_port(osm_sm_t *sm, osm_physp_t *p)
+{
+ uint8_t payload[IB_SMP_DATA_SIZE];
+ osm_madw_context_t context;
+ ib_port_info_t *pi = (ib_port_info_t *)payload;
+ osm_physp_t *physp0;
+ osm_port_t *p_port;
+ ib_net64_t m_key;
+ ib_api_status_t status;
+
+ /* select the nearest port to master opensm */
+ if (p->p_remote_physp &&
+ p->dr_path.hop_count > p->p_remote_physp->dr_path.hop_count)
+ p = p->p_remote_physp;
+
+ /* If trap 131, might want to disable peer port if available */
+ /* but peer port has been observed not to respond to SM requests */
+
+ memcpy(payload, &p->port_info, sizeof(ib_port_info_t));
+
+ /* Set port to disabled/down */
+ ib_port_info_set_port_state(pi, IB_LINK_DOWN);
+ ib_port_info_set_port_phys_state(IB_PORT_PHYS_STATE_DISABLED, pi);
+
+ /* Issue set of PortInfo */
+ context.pi_context.node_guid = osm_node_get_node_guid(p->p_node);
+ context.pi_context.port_guid = osm_physp_get_port_guid(p);
+ context.pi_context.set_method = TRUE;
+ context.pi_context.light_sweep = FALSE;
+ context.pi_context.active_transition = FALSE;
+ context.pi_context.client_rereg = FALSE;
+ if (osm_node_get_type(p->p_node) == IB_NODE_TYPE_SWITCH &&
+ osm_physp_get_port_num(p) != 0) {
+ physp0 = osm_node_get_physp_ptr(p->p_node, 0);
+ m_key = ib_port_info_get_m_key(&physp0->port_info);
+ } else
+ m_key = ib_port_info_get_m_key(&p->port_info);
+
+ if (osm_node_get_type(p->p_node) != IB_NODE_TYPE_SWITCH) {
+ if (!pi->base_lid) {
+ p_port = osm_get_port_by_guid(sm->p_subn,
+ osm_physp_get_port_guid(p));
+ pi->base_lid = p_port->lid;
+ }
+ pi->master_sm_base_lid = sm->p_subn->sm_base_lid;
+ }
+
+ status = osm_req_set(sm, osm_physp_get_dr_path_ptr(p),
+ payload, sizeof(payload), IB_MAD_ATTR_PORT_INFO,
+ cl_hton32(osm_physp_get_port_num(p)),
+ FALSE, m_key,
+ CL_DISP_MSGID_NONE, &context);
+ return status;
+}
+
+static void log_trap_info(osm_log_t *p_log, ib_mad_notice_attr_t *p_ntci,
+ ib_net16_t source_lid, ib_net64_t trans_id)
+{
+ if (!OSM_LOG_IS_ACTIVE_V2(p_log, OSM_LOG_ERROR))
+ return;
+
+ if (ib_notice_is_generic(p_ntci)) {
+ char str[32];
+
+ if ((p_ntci->g_or_v.generic.trap_num == CL_HTON16(SM_LINK_INTEGRITY_THRESHOLD_TRAP)) ||
+ (p_ntci->g_or_v.generic.trap_num == CL_HTON16(SM_BUFFER_OVERRUN_THRESHOLD_TRAP)) ||
+ (p_ntci->g_or_v.generic.trap_num == CL_HTON16(SM_WATCHDOG_TIMER_EXPIRED_TRAP)))
+ snprintf(str, sizeof(str), " Port %u",
+ p_ntci->data_details.ntc_129_131.port_num);
+ else
+ str[0] = '\0';
+
+ OSM_LOG(p_log, OSM_LOG_ERROR,
+ "Received Generic Notice type:%u "
+ "num:%u (%s) Producer:%u (%s) "
+ "from LID:%u%s TID:0x%016" PRIx64 "\n",
+ ib_notice_get_type(p_ntci),
+ cl_ntoh16(p_ntci->g_or_v.generic.trap_num),
+ ib_get_trap_str(p_ntci->g_or_v.generic.trap_num),
+ cl_ntoh32(ib_notice_get_prod_type(p_ntci)),
+ ib_get_producer_type_str(ib_notice_get_prod_type(p_ntci)),
+ cl_hton16(source_lid), str, cl_ntoh64(trans_id));
+ if ((p_ntci->g_or_v.generic.trap_num == CL_HTON16(SM_BAD_PKEY_TRAP)) ||
+ (p_ntci->g_or_v.generic.trap_num == CL_HTON16(SM_BAD_QKEY_TRAP))) {
+ OSM_LOG(p_log, OSM_LOG_ERROR,
+ "Bad %s_Key:0x%x on SL:%d from "
+ "LID1:%u QP1:0x%x to "
+ "LID2:%u QP2:0x%x\n",
+ (p_ntci->g_or_v.generic.trap_num == CL_HTON16(257)) ? "P" : "Q",
+ cl_ntoh32(p_ntci->data_details.ntc_257_258.key),
+ cl_ntoh32(p_ntci->data_details.ntc_257_258.qp1) >> 28,
+ cl_ntoh16(p_ntci->data_details.ntc_257_258.lid1),
+ cl_ntoh32(p_ntci->data_details.ntc_257_258.qp1) & 0xfff,
+ cl_ntoh16(p_ntci->data_details.ntc_257_258.lid2),
+ cl_ntoh32(p_ntci->data_details.ntc_257_258.qp2));
+ }
+ } else
+ OSM_LOG(p_log, OSM_LOG_ERROR,
+ "Received Vendor Notice type:%u vend:0x%06X "
+ "dev:%u from LID:%u TID:0x%016" PRIx64 "\n",
+ ib_notice_get_type(p_ntci),
+ cl_ntoh32(ib_notice_get_vend_id(p_ntci)),
+ cl_ntoh16(p_ntci->g_or_v.vend.dev_id),
+ cl_ntoh16(source_lid), cl_ntoh64(trans_id));
+}
+
+static int shutup_noisy_port(osm_sm_t *sm, ib_net16_t lid, uint8_t port,
+ unsigned num)
+{
+ osm_physp_t *p = get_physp_by_lid_and_num(sm, lid, port);
+ if (!p) {
+ OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR 3805: "
+ "Failed to find physical port by lid:%u num:%u\n",
+ cl_ntoh16(lid), port);
+ return -1;
+ }
+
+ /* When babbling port policy option is enabled and
+ Threshold for disabling a "babbling" port is exceeded */
+ if (sm->p_subn->opt.babbling_port_policy && num >= 250) {
+ OSM_LOG(sm->p_log, OSM_LOG_VERBOSE,
+ "Disabling noisy physical port 0x%016" PRIx64
+ ": lid %u, num %u\n",
+ cl_ntoh64(osm_physp_get_port_guid(p)),
+ cl_ntoh16(lid), port);
+ if (disable_port(sm, p))
+ OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR 3811: "
+ "Failed to disable noisy physical port 0x%016"
+ PRIx64 ": lid %u, num %u\n",
+ cl_ntoh64(osm_physp_get_port_guid(p)),
+ cl_ntoh16(lid), port);
+ else
+ return 1;
+ }
+
+ /* check if the current state of the p_physp is healthy. If
+ it is - then this is a first change of state. Run a heavy sweep. */
+ if (osm_physp_is_healthy(p)) {
+ OSM_LOG(sm->p_log, OSM_LOG_VERBOSE,
+ "Marking unhealthy physical port by lid:%u num:%u\n",
+ cl_ntoh16(lid), port);
+ osm_physp_set_health(p, FALSE);
+ return 2;
+ }
+ return 0;
+}
+
+static void trap_rcv_process_request(IN osm_sm_t * sm,
+ IN const osm_madw_t * p_madw)
+{
+ uint8_t payload[sizeof(ib_mad_notice_attr_t)];
+ ib_smp_t *p_smp;
+ ib_mad_notice_attr_t *p_ntci = (ib_mad_notice_attr_t *) payload;
+ ib_api_status_t status;
+ osm_madw_t tmp_madw; /* we need a copy to last after repress */
+ uint64_t trap_key;
+ uint32_t num_received;
+ osm_physp_t *p_physp;
+ osm_port_t *p_port;
+ ib_net16_t source_lid = 0;
+ boolean_t is_gsi = TRUE;
+ uint8_t port_num = 0;
+ boolean_t physp_change_trap = FALSE;
+ uint64_t event_wheel_timeout = OSM_DEFAULT_TRAP_SUPRESSION_TIMEOUT;
+ boolean_t run_heavy_sweep = FALSE;
+ char buf[1024];
+ osm_dr_path_t *p_path;
+ unsigned n;
+
+ OSM_LOG_ENTER(sm->p_log);
+
+ CL_ASSERT(p_madw);
+
+ if (osm_exit_flag)
+ /*
+ We got an exit flag - do nothing
+ Otherwise we start a sweep on the trap 144 caused by
+ cleaning up SM Cap bit...
+ */
+ goto Exit2;
+
+ /* update the is_gsi flag according to the mgmt_class field */
+ if (p_madw->p_mad->mgmt_class == IB_MCLASS_SUBN_LID ||
+ p_madw->p_mad->mgmt_class == IB_MCLASS_SUBN_DIR)
+ is_gsi = FALSE;
+
+ /* No real need to grab the lock for this function. */
+ memset(payload, 0, sizeof(payload));
+ memset(&tmp_madw, 0, sizeof(tmp_madw));
+
+ p_smp = osm_madw_get_smp_ptr(p_madw);
+
+ if (p_smp->method != IB_MAD_METHOD_TRAP) {
+ OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR 3801: "
+ "Unsupported method 0x%X\n", p_smp->method);
+ goto Exit2;
+ }
+
+ /*
+ * The NOTICE Attribute is part of the SMP CLASS attributes
+ * As such the actual attribute data resides inside the SMP
+ * payload.
+ */
+
+ memcpy(payload, &p_smp->data, IB_SMP_DATA_SIZE);
+ memcpy(&tmp_madw, p_madw, sizeof(tmp_madw));
+
+ if (is_gsi == FALSE) {
+ /* We are in smi flow */
+ /*
+ * When we receive a TRAP with dlid = 0 - it means it
+ * came from our own node. So we need to fix it.
+ */
+
+ if (p_madw->mad_addr.addr_type.smi.source_lid == 0) {
+ /* Check if the sm_base_lid is 0. If yes - this means
+ that the local lid wasn't configured yet. Don't send
+ a response to the trap. */
+ if (sm->p_subn->sm_base_lid == 0) {
+ OSM_LOG(sm->p_log, OSM_LOG_DEBUG,
+ "Received SLID=0 Trap with local LID=0. Ignoring MAD\n");
+ goto Exit2;
+ }
+ OSM_LOG(sm->p_log, OSM_LOG_DEBUG,
+ "Received SLID=0 Trap. Using local LID:%u instead\n",
+ cl_ntoh16(sm->p_subn->sm_base_lid));
+ tmp_madw.mad_addr.addr_type.smi.source_lid =
+ sm->p_subn->sm_base_lid;
+ }
+
+ source_lid = tmp_madw.mad_addr.addr_type.smi.source_lid;
+
+ /* Print some info about the incoming Trap */
+ log_trap_info(sm->p_log, p_ntci, source_lid, p_smp->trans_id);
+ }
+
+ osm_dump_notice_v2(sm->p_log, p_ntci, FILE_ID, OSM_LOG_VERBOSE);
+ CL_PLOCK_ACQUIRE(sm->p_lock);
+ p_physp = osm_get_physp_by_mad_addr(sm->p_log, sm->p_subn,
+ &tmp_madw.mad_addr);
+ if (p_physp)
+ p_smp->m_key = ib_port_info_get_m_key(&p_physp->port_info);
+ else
+ OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR 3809: "
+ "Failed to find source physical port for trap\n");
+
+ status = osm_resp_send(sm, &tmp_madw, 0, payload);
+ if (status != IB_SUCCESS) {
+ OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR 3802: "
+ "Error sending response (%s)\n",
+ ib_get_err_str(status));
+ goto Exit;
+ }
+
+ /*
+ * We would like to filter out recurring Traps so we track them by
+ * their source lid and content. If the same trap was already
+ * received within the aging time window more than 10 times,
+ * we simply ignore it. This is done only if we are in smi mode
+ */
+
+ if (is_gsi == FALSE) {
+ if (ib_notice_is_generic(p_ntci) &&
+ (p_ntci->g_or_v.generic.trap_num == CL_HTON16(SM_LINK_INTEGRITY_THRESHOLD_TRAP) ||
+ p_ntci->g_or_v.generic.trap_num == CL_HTON16(SM_BUFFER_OVERRUN_THRESHOLD_TRAP) ||
+ p_ntci->g_or_v.generic.trap_num == CL_HTON16(SM_WATCHDOG_TIMER_EXPIRED_TRAP))) {
+ /* If this is a trap 129, 130, or 131 - then this is a
+ * trap signaling a change on a physical port.
+ * Mark the physp_change_trap flag as TRUE.
+ */
+ physp_change_trap = TRUE;
+ /* The source_lid should be based on the source_lid from the trap */
+ source_lid = p_ntci->data_details.ntc_129_131.lid;
+ port_num = p_ntci->data_details.ntc_129_131.port_num;
+ }
+
+ /* try to find it in the aging tracker */
+ trap_key = trap_get_key(source_lid, port_num, p_ntci);
+ num_received = cl_event_wheel_num_regs(&sm->trap_aging_tracker,
+ trap_key);
+
+ /* Now we know how many times it provided this trap */
+ if (num_received > 10) {
+ if (print_num_received(num_received))
+ OSM_LOG(sm->p_log, OSM_LOG_VERBOSE,
+ "Received trap %u times consecutively\n",
+ num_received);
+ /*
+ * If the trap provides info about a bad port
+ * we mark it as unhealthy.
+ */
+ if (physp_change_trap == TRUE) {
+ int ret = shutup_noisy_port(sm, source_lid,
+ port_num,
+ num_received);
+ if (ret == 1) /* port disabled */
+ goto Exit;
+ else if (ret == 2) /* unhealthy - run sweep */
+ run_heavy_sweep = TRUE;
+ /* in any case increase timeout interval */
+ event_wheel_timeout =
+ OSM_DEFAULT_UNHEALTHY_TIMEOUT;
+ }
+ }
+
+ /* restart the aging anyway */
+ /* If physp_change_trap is TRUE - then use a callback to unset
+ the healthy bit. If not - no need to use a callback. */
+ if (physp_change_trap == TRUE)
+ cl_event_wheel_reg(&sm->trap_aging_tracker, trap_key,
+ cl_get_time_stamp() + event_wheel_timeout,
+ aging_tracker_callback, sm);
+ else
+ cl_event_wheel_reg(&sm->trap_aging_tracker, trap_key,
+ cl_get_time_stamp() + event_wheel_timeout,
+ NULL, NULL);
+
+ /* If was already registered do nothing more */
+ if (num_received > 10 && run_heavy_sweep == FALSE) {
+ if (print_num_received(num_received))
+ OSM_LOG(sm->p_log, OSM_LOG_VERBOSE,
+ "Ignoring noisy traps.\n");
+ goto Exit;
+ }
+ }
+
+ /* Check for node description update. IB Spec v1.2.1 pg 823 */
+ if (!ib_notice_is_generic(p_ntci))
+ goto check_sweep;
+ if (cl_ntoh16(p_ntci->g_or_v.generic.trap_num) == SM_LOCAL_CHANGES_TRAP &&
+ p_ntci->data_details.ntc_144.local_changes & TRAP_144_MASK_OTHER_LOCAL_CHANGES &&
+ p_ntci->data_details.ntc_144.change_flgs & TRAP_144_MASK_NODE_DESCRIPTION_CHANGE) {
+ OSM_LOG(sm->p_log, OSM_LOG_INFO, "Trap 144 Node description update\n");
+
+ if (p_physp) {
+ osm_req_get_node_desc(sm, p_physp);
+ if (!(p_ntci->data_details.ntc_144.change_flgs & ~TRAP_144_MASK_NODE_DESCRIPTION_CHANGE) &&
+ p_ntci->data_details.ntc_144.new_cap_mask == p_physp->port_info.capability_mask)
+ goto check_report;
+ } else
+ OSM_LOG(sm->p_log, OSM_LOG_ERROR,
+ "ERR 3812: No physical port found for "
+ "trap 144: \"node description update\"\n");
+ goto check_sweep;
+ } else if (cl_ntoh16(p_ntci->g_or_v.generic.trap_num) == SM_SYS_IMG_GUID_CHANGED_TRAP) {
+ if (p_physp) {
+ CL_PLOCK_RELEASE(sm->p_lock);
+ CL_PLOCK_EXCL_ACQUIRE(sm->p_lock);
+ p_physp = osm_get_physp_by_mad_addr(sm->p_log,
+ sm->p_subn,
+ &tmp_madw.mad_addr);
+ if (p_physp) {
+ /* this assumes that trap 145 content is not broken? */
+ p_physp->p_node->node_info.sys_guid =
+ p_ntci->data_details.ntc_145.new_sys_guid;
+ }
+ CL_PLOCK_RELEASE(sm->p_lock);
+ CL_PLOCK_ACQUIRE(sm->p_lock);
+ } else
+ OSM_LOG(sm->p_log, OSM_LOG_ERROR,
+ "ERR 3813: No physical port found for "
+ "trap 145: \"SystemImageGUID update\"\n");
+ goto check_report;
+ }
+
+check_sweep:
+ if (osm_log_is_active_v2(sm->p_log, OSM_LOG_INFO, FILE_ID)) {
+ if (ib_notice_is_generic(p_ntci) &&
+ cl_ntoh16(p_ntci->g_or_v.generic.trap_num) == SM_LINK_STATE_CHANGED_TRAP) {
+ p_path = (p_physp) ?
+ osm_physp_get_dr_path_ptr(p_physp) : NULL;
+ if (p_path) {
+ n = sprintf(buf, "SM class trap %u: ",
+ cl_ntoh16(p_ntci->g_or_v.generic.trap_num));
+ n += snprintf(buf + n, sizeof(buf) - n,
+ "Directed Path Dump of %u hop path: "
+ "Path = ", p_path->hop_count);
+
+ osm_dump_dr_path_as_buf(sizeof(buf) - n, p_path,
+ buf + n);
+
+ osm_log_v2(sm->p_log, OSM_LOG_INFO, FILE_ID,
+ "%s\n", buf);
+ }
+ }
+ }
+
+ /* do a sweep if we received a trap */
+ if (sm->p_subn->opt.sweep_on_trap) {
+ /* if this is trap number 128 or run_heavy_sweep is TRUE -
+ update the force_heavy_sweep flag of the subnet.
+ Sweep also on traps 144 - these traps signal a change of
+ certain port capabilities.
+ TODO: In the future this can be changed to just getting
+ PortInfo on this port instead of sweeping the entire subnet. */
+ if (ib_notice_is_generic(p_ntci) &&
+ (cl_ntoh16(p_ntci->g_or_v.generic.trap_num) == SM_LINK_STATE_CHANGED_TRAP ||
+ cl_ntoh16(p_ntci->g_or_v.generic.trap_num) == SM_LOCAL_CHANGES_TRAP ||
+ run_heavy_sweep)) {
+ OSM_LOG(sm->p_log, OSM_LOG_VERBOSE,
+ "Forcing heavy sweep. Received trap:%u\n",
+ cl_ntoh16(p_ntci->g_or_v.generic.trap_num));
+
+ sm->p_subn->force_heavy_sweep = TRUE;
+ }
+ osm_sm_signal(sm, OSM_SIGNAL_SWEEP);
+ }
+
+ /* If we reached here due to trap 129/130/131 - do not need to do
+ the notice report. Just goto exit. We know this is the case
+ if physp_change_trap is TRUE. */
+ if (physp_change_trap == TRUE)
+ goto Exit;
+
+check_report:
+ /* We are going to report the notice - so need to fix the IssuerGID
+ accordingly. See IBA 1.2 p.739 or IBA 1.1 p.653 for details. */
+ if (is_gsi) {
+ if (!tmp_madw.mad_addr.addr_type.gsi.global_route) {
+ OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR 3806: "
+ "Received gsi trap with global_route FALSE. "
+ "Cannot update issuer_gid!\n");
+ goto Exit;
+ }
+ memcpy(&p_ntci->issuer_gid,
+ &tmp_madw.mad_addr.addr_type.gsi.grh_info.src_gid,
+ sizeof(ib_gid_t));
+ } else {
+ /* Need to use the IssuerLID */
+ p_port = osm_get_port_by_lid(sm->p_subn, source_lid);
+ if (!p_port) {
+ OSM_LOG(sm->p_log, OSM_LOG_VERBOSE,
+ "Cannot find port corresponding to lid:%u\n",
+ cl_ntoh16(source_lid));
+
+ goto Exit;
+ }
+
+ p_ntci->issuer_gid.unicast.prefix =
+ sm->p_subn->opt.subnet_prefix;
+ p_ntci->issuer_gid.unicast.interface_id = p_port->guid;
+ }
+
+ /* we need a lock here as the InformInfo DB must be stable */
+ status = osm_report_notice(sm->p_log, sm->p_subn, p_ntci);
+ if (status != IB_SUCCESS) {
+ OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR 3803: "
+ "Error sending trap reports (%s)\n",
+ ib_get_err_str(status));
+ goto Exit;
+ }
+
+Exit:
+ CL_PLOCK_RELEASE(sm->p_lock);
+Exit2:
+ OSM_LOG_EXIT(sm->p_log);
+}
+
+void osm_trap_rcv_process(IN void *context, IN void *data)
+{
+ osm_sm_t *sm = context;
+ osm_madw_t *p_madw = data;
+ ib_smp_t __attribute__((unused)) *p_smp;
+
+ OSM_LOG_ENTER(sm->p_log);
+
+ CL_ASSERT(p_madw);
+
+ p_smp = osm_madw_get_smp_ptr(p_madw);
+
+ /* Only Trap requests get here */
+ CL_ASSERT(!ib_smp_is_response(p_smp));
+ trap_rcv_process_request(sm, p_madw);
+
+ OSM_LOG_EXIT(sm->p_log);
+}
diff --git a/contrib/ofed/opensm/opensm/osm_ucast_cache.c b/contrib/ofed/opensm/opensm/osm_ucast_cache.c
new file mode 100644
index 0000000..3caf318
--- /dev/null
+++ b/contrib/ofed/opensm/opensm/osm_ucast_cache.c
@@ -0,0 +1,1059 @@
+/*
+ * Copyright (c) 2008-2009 Voltaire, Inc. All rights reserved.
+ * Copyright (c) 2008-2009 Mellanox Technologies LTD. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+/*
+ * Abstract:
+ * Implementation of OpenSM Cached Unicast Routing
+ *
+ * Environment:
+ * Linux User Mode
+ *
+ */
+
+#if HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include <stdlib.h>
+#include <string.h>
+#include <ctype.h>
+#include <errno.h>
+#include <iba/ib_types.h>
+#include <complib/cl_qmap.h>
+#include <complib/cl_pool.h>
+#include <complib/cl_debug.h>
+#include <opensm/osm_file_ids.h>
+#define FILE_ID OSM_FILE_UCAST_CACHE_C
+#include <opensm/osm_opensm.h>
+#include <opensm/osm_ucast_mgr.h>
+#include <opensm/osm_ucast_cache.h>
+#include <opensm/osm_switch.h>
+#include <opensm/osm_node.h>
+#include <opensm/osm_port.h>
+
+typedef struct cache_port {
+ boolean_t is_leaf;
+ uint16_t remote_lid_ho;
+} cache_port_t;
+
+typedef struct cache_switch {
+ cl_map_item_t map_item;
+ boolean_t dropped;
+ uint16_t max_lid_ho;
+ uint16_t num_hops;
+ uint8_t **hops;
+ uint8_t *lft;
+ uint8_t num_ports;
+ cache_port_t ports[0];
+} cache_switch_t;
+
+static uint16_t cache_sw_get_base_lid_ho(cache_switch_t * p_sw)
+{
+ return p_sw->ports[0].remote_lid_ho;
+}
+
+static boolean_t cache_sw_is_leaf(cache_switch_t * p_sw)
+{
+ return p_sw->ports[0].is_leaf;
+}
+
+static void cache_sw_set_leaf(cache_switch_t * p_sw)
+{
+ p_sw->ports[0].is_leaf = TRUE;
+}
+
+static cache_switch_t *cache_sw_new(uint16_t lid_ho, unsigned num_ports)
+{
+ cache_switch_t *p_cache_sw = malloc(sizeof(cache_switch_t) +
+ num_ports * sizeof(cache_port_t));
+ if (!p_cache_sw)
+ return NULL;
+
+ memset(p_cache_sw, 0,
+ sizeof(*p_cache_sw) + num_ports * sizeof(cache_port_t));
+
+ p_cache_sw->num_ports = num_ports;
+
+ /* port[0] fields represent this switch details - lid and type */
+ p_cache_sw->ports[0].remote_lid_ho = lid_ho;
+ p_cache_sw->ports[0].is_leaf = FALSE;
+
+ return p_cache_sw;
+}
+
+static void cache_sw_destroy(cache_switch_t * p_sw)
+{
+ unsigned i;
+
+ if (!p_sw)
+ return;
+
+ if (p_sw->lft)
+ free(p_sw->lft);
+ if (p_sw->hops) {
+ for (i = 0; i < p_sw->num_hops; i++)
+ if (p_sw->hops[i])
+ free(p_sw->hops[i]);
+ free(p_sw->hops);
+ }
+ free(p_sw);
+}
+
+static cache_switch_t *cache_get_sw(osm_ucast_mgr_t * p_mgr, uint16_t lid_ho)
+{
+ cache_switch_t *p_cache_sw = (cache_switch_t *)
+ cl_qmap_get(&p_mgr->cache_sw_tbl, lid_ho);
+ if (p_cache_sw == (cache_switch_t *)
+ cl_qmap_end(&p_mgr->cache_sw_tbl))
+ p_cache_sw = NULL;
+
+ return p_cache_sw;
+}
+
+static void cache_add_sw_link(osm_ucast_mgr_t * p_mgr, osm_physp_t *p,
+ uint16_t remote_lid_ho, boolean_t is_ca)
+{
+ cache_switch_t *p_cache_sw;
+ uint16_t lid_ho = cl_ntoh16(osm_node_get_base_lid(p->p_node, 0));
+
+ OSM_LOG_ENTER(p_mgr->p_log);
+
+ if (!lid_ho || !remote_lid_ho || !p->port_num)
+ goto Exit;
+
+ OSM_LOG(p_mgr->p_log, OSM_LOG_DEBUG,
+ "Caching switch port: lid %u [port %u] -> lid %u (%s)\n",
+ lid_ho, p->port_num, remote_lid_ho, (is_ca) ? "CA/RTR" : "SW");
+
+ p_cache_sw = cache_get_sw(p_mgr, lid_ho);
+ if (!p_cache_sw) {
+ p_cache_sw = cache_sw_new(lid_ho, p->p_node->sw->num_ports);
+ if (!p_cache_sw) {
+ OSM_LOG(p_mgr->p_log, OSM_LOG_ERROR,
+ "ERR AD01: Out of memory - cache is invalid\n");
+ osm_ucast_cache_invalidate(p_mgr);
+ goto Exit;
+ }
+ cl_qmap_insert(&p_mgr->cache_sw_tbl, lid_ho,
+ &p_cache_sw->map_item);
+ }
+
+ if (p->port_num >= p_cache_sw->num_ports) {
+ OSM_LOG(p_mgr->p_log, OSM_LOG_ERROR,
+ "ERR AD02: Wrong switch? - cache is invalid\n");
+ osm_ucast_cache_invalidate(p_mgr);
+ goto Exit;
+ }
+
+ if (is_ca)
+ cache_sw_set_leaf(p_cache_sw);
+
+ if (p_cache_sw->ports[p->port_num].remote_lid_ho == 0) {
+ /* cache this link only if it hasn't been already cached */
+ p_cache_sw->ports[p->port_num].remote_lid_ho = remote_lid_ho;
+ p_cache_sw->ports[p->port_num].is_leaf = is_ca;
+ }
+Exit:
+ OSM_LOG_EXIT(p_mgr->p_log);
+}
+
+static void cache_cleanup_switches(osm_ucast_mgr_t * p_mgr)
+{
+ cache_switch_t *p_sw;
+ cache_switch_t *p_next_sw;
+ unsigned port_num;
+ boolean_t found_port;
+
+ if (!p_mgr->cache_valid)
+ return;
+
+ p_next_sw = (cache_switch_t *) cl_qmap_head(&p_mgr->cache_sw_tbl);
+ while (p_next_sw !=
+ (cache_switch_t *) cl_qmap_end(&p_mgr->cache_sw_tbl)) {
+ p_sw = p_next_sw;
+ p_next_sw = (cache_switch_t *) cl_qmap_next(&p_sw->map_item);
+
+ found_port = FALSE;
+ for (port_num = 1; port_num < p_sw->num_ports; port_num++)
+ if (p_sw->ports[port_num].remote_lid_ho)
+ found_port = TRUE;
+
+ if (!found_port) {
+ cl_qmap_remove_item(&p_mgr->cache_sw_tbl,
+ &p_sw->map_item);
+ cache_sw_destroy(p_sw);
+ }
+ }
+}
+
+static void
+cache_check_link_change(osm_ucast_mgr_t * p_mgr,
+ osm_physp_t * p_physp_1, osm_physp_t * p_physp_2)
+{
+ OSM_LOG_ENTER(p_mgr->p_log);
+ CL_ASSERT(p_physp_1 && p_physp_2);
+
+ if (!p_mgr->cache_valid)
+ goto Exit;
+
+ if (!p_physp_1->p_remote_physp && !p_physp_2->p_remote_physp)
+ /* both ports were down - new link */
+ goto Exit;
+
+ /* unicast cache cannot tolerate any link location change */
+
+ if ((p_physp_1->p_remote_physp &&
+ p_physp_1->p_remote_physp->p_remote_physp) ||
+ (p_physp_2->p_remote_physp &&
+ p_physp_2->p_remote_physp->p_remote_physp)) {
+ OSM_LOG(p_mgr->p_log, OSM_LOG_DEBUG,
+ "Link location change discovered\n");
+ osm_ucast_cache_invalidate(p_mgr);
+ goto Exit;
+ }
+Exit:
+ OSM_LOG_EXIT(p_mgr->p_log);
+}
+
+static void cache_remove_port(osm_ucast_mgr_t * p_mgr, uint16_t lid_ho,
+ uint8_t port_num, uint16_t remote_lid_ho,
+ boolean_t is_ca)
+{
+ cache_switch_t *p_cache_sw;
+
+ OSM_LOG_ENTER(p_mgr->p_log);
+
+ if (!p_mgr->cache_valid)
+ goto Exit;
+
+ p_cache_sw = cache_get_sw(p_mgr, lid_ho);
+ if (!p_cache_sw) {
+ OSM_LOG(p_mgr->p_log, OSM_LOG_DEBUG,
+ "Found uncached switch/link (lid %u, port %u)\n",
+ lid_ho, port_num);
+ osm_ucast_cache_invalidate(p_mgr);
+ goto Exit;
+ }
+
+ if (port_num >= p_cache_sw->num_ports ||
+ !p_cache_sw->ports[port_num].remote_lid_ho) {
+ OSM_LOG(p_mgr->p_log, OSM_LOG_DEBUG,
+ "Found uncached switch link (lid %u, port %u)\n",
+ lid_ho, port_num);
+ osm_ucast_cache_invalidate(p_mgr);
+ goto Exit;
+ }
+
+ if (p_cache_sw->ports[port_num].remote_lid_ho != remote_lid_ho) {
+ OSM_LOG(p_mgr->p_log, OSM_LOG_DEBUG,
+ "Remote lid change on switch lid %u, port %u "
+ "(was %u, now %u)\n", lid_ho, port_num,
+ p_cache_sw->ports[port_num].remote_lid_ho,
+ remote_lid_ho);
+ osm_ucast_cache_invalidate(p_mgr);
+ goto Exit;
+ }
+
+ if ((p_cache_sw->ports[port_num].is_leaf && !is_ca) ||
+ (!p_cache_sw->ports[port_num].is_leaf && is_ca)) {
+ OSM_LOG(p_mgr->p_log, OSM_LOG_DEBUG,
+ "Remote node type change on switch lid %u, port %u\n",
+ lid_ho, port_num);
+ osm_ucast_cache_invalidate(p_mgr);
+ goto Exit;
+ }
+
+ OSM_LOG(p_mgr->p_log, OSM_LOG_DEBUG,
+ "New link from lid %u, port %u to lid %u - "
+ "found in cache\n", lid_ho, port_num, remote_lid_ho);
+
+ /* the new link was cached - clean it from the cache */
+
+ p_cache_sw->ports[port_num].remote_lid_ho = 0;
+ p_cache_sw->ports[port_num].is_leaf = FALSE;
+Exit:
+ OSM_LOG_EXIT(p_mgr->p_log);
+} /* cache_remove_port() */
+
+static void
+cache_restore_ucast_info(osm_ucast_mgr_t * p_mgr,
+ cache_switch_t * p_cache_sw, osm_switch_t * p_sw)
+{
+ if (!p_mgr->cache_valid)
+ return;
+
+ /* when seting unicast info, the cached port
+ should have all the required info */
+ CL_ASSERT(p_cache_sw->max_lid_ho && p_cache_sw->lft &&
+ p_cache_sw->num_hops && p_cache_sw->hops);
+
+ p_sw->max_lid_ho = p_cache_sw->max_lid_ho;
+
+ if (p_sw->new_lft)
+ free(p_sw->new_lft);
+ p_sw->new_lft = p_cache_sw->lft;
+ p_cache_sw->lft = NULL;
+
+ p_sw->num_hops = p_cache_sw->num_hops;
+ p_cache_sw->num_hops = 0;
+ if (p_sw->hops)
+ free(p_sw->hops);
+ p_sw->hops = p_cache_sw->hops;
+ p_cache_sw->hops = NULL;
+
+ p_sw->need_update = 2;
+}
+
+static void ucast_cache_dump(osm_ucast_mgr_t * p_mgr)
+{
+ cache_switch_t *p_sw;
+ unsigned i;
+
+ OSM_LOG_ENTER(p_mgr->p_log);
+
+ if (!OSM_LOG_IS_ACTIVE_V2(p_mgr->p_log, OSM_LOG_DEBUG))
+ goto Exit;
+
+ OSM_LOG(p_mgr->p_log, OSM_LOG_DEBUG,
+ "Dumping missing nodes/links as logged by unicast cache:\n");
+ for (p_sw = (cache_switch_t *) cl_qmap_head(&p_mgr->cache_sw_tbl);
+ p_sw != (cache_switch_t *) cl_qmap_end(&p_mgr->cache_sw_tbl);
+ p_sw = (cache_switch_t *) cl_qmap_next(&p_sw->map_item)) {
+
+ OSM_LOG(p_mgr->p_log, OSM_LOG_DEBUG,
+ "\t Switch lid %u %s%s\n",
+ cache_sw_get_base_lid_ho(p_sw),
+ (cache_sw_is_leaf(p_sw)) ? "[leaf switch] " : "",
+ (p_sw->dropped) ? "[whole switch missing]" : "");
+
+ for (i = 1; i < p_sw->num_ports; i++)
+ if (p_sw->ports[i].remote_lid_ho > 0)
+ OSM_LOG(p_mgr->p_log,
+ OSM_LOG_DEBUG,
+ "\t - port %u -> lid %u %s\n",
+ i, p_sw->ports[i].remote_lid_ho,
+ (p_sw->ports[i].is_leaf) ?
+ "[remote node is leaf]" : "");
+ }
+Exit:
+ OSM_LOG_EXIT(p_mgr->p_log);
+}
+
+void osm_ucast_cache_invalidate(osm_ucast_mgr_t * p_mgr)
+{
+ cache_switch_t *p_sw;
+ cache_switch_t *p_next_sw;
+
+ OSM_LOG_ENTER(p_mgr->p_log);
+
+ if (!p_mgr->cache_valid)
+ goto Exit;
+
+ p_mgr->cache_valid = FALSE;
+
+ p_next_sw = (cache_switch_t *) cl_qmap_head(&p_mgr->cache_sw_tbl);
+ while (p_next_sw !=
+ (cache_switch_t *) cl_qmap_end(&p_mgr->cache_sw_tbl)) {
+ p_sw = p_next_sw;
+ p_next_sw = (cache_switch_t *) cl_qmap_next(&p_sw->map_item);
+ cache_sw_destroy(p_sw);
+ }
+ cl_qmap_remove_all(&p_mgr->cache_sw_tbl);
+
+ OSM_LOG(p_mgr->p_log, OSM_LOG_VERBOSE, "Unicast Cache invalidated\n");
+Exit:
+ OSM_LOG_EXIT(p_mgr->p_log);
+}
+
+static void ucast_cache_validate(osm_ucast_mgr_t * p_mgr)
+{
+ cache_switch_t *p_cache_sw;
+ cache_switch_t *p_remote_cache_sw;
+ unsigned port_num;
+ unsigned max_ports;
+ uint8_t remote_node_type;
+ uint16_t lid_ho;
+ uint16_t remote_lid_ho;
+ osm_switch_t *p_sw;
+ osm_switch_t *p_remote_sw;
+ osm_node_t *p_node;
+ osm_physp_t *p_physp;
+ osm_physp_t *p_remote_physp;
+ osm_port_t *p_remote_port;
+ cl_qmap_t *p_sw_tbl;
+
+ OSM_LOG_ENTER(p_mgr->p_log);
+ if (!p_mgr->cache_valid)
+ goto Exit;
+
+ /* If there are no switches in the subnet, we are done */
+ p_sw_tbl = &p_mgr->p_subn->sw_guid_tbl;
+ if (cl_qmap_count(p_sw_tbl) == 0) {
+ osm_ucast_cache_invalidate(p_mgr);
+ goto Exit;
+ }
+
+ /*
+ * Scan all the physical switch ports in the subnet.
+ * If the port need_update flag is on, check whether
+ * it's just some node/port reset or a cached topology
+ * change. Otherwise the cache is invalid.
+ */
+ for (p_sw = (osm_switch_t *) cl_qmap_head(p_sw_tbl);
+ p_sw != (osm_switch_t *) cl_qmap_end(p_sw_tbl);
+ p_sw = (osm_switch_t *) cl_qmap_next(&p_sw->map_item)) {
+
+ p_node = p_sw->p_node;
+
+ lid_ho = cl_ntoh16(osm_node_get_base_lid(p_node, 0));
+ p_cache_sw = cache_get_sw(p_mgr, lid_ho);
+
+ max_ports = osm_node_get_num_physp(p_node);
+
+ /* skip port 0 */
+ for (port_num = 1; port_num < max_ports; port_num++) {
+
+ p_physp = osm_node_get_physp_ptr(p_node, port_num);
+
+ if (!p_physp || !p_physp->p_remote_physp ||
+ !osm_physp_link_exists(p_physp,
+ p_physp->p_remote_physp))
+ /* no valid link */
+ continue;
+
+ /*
+ * While scanning all the physical ports in the subnet,
+ * mark corresponding leaf switches in the cache.
+ */
+ if (p_cache_sw &&
+ !p_cache_sw->dropped &&
+ !cache_sw_is_leaf(p_cache_sw) &&
+ p_physp->p_remote_physp->p_node &&
+ osm_node_get_type(p_physp->p_remote_physp->
+ p_node) != IB_NODE_TYPE_SWITCH)
+ cache_sw_set_leaf(p_cache_sw);
+
+ if (!p_physp->need_update)
+ continue;
+
+ OSM_LOG(p_mgr->p_log, OSM_LOG_DEBUG,
+ "Checking switch lid %u, port %u\n",
+ lid_ho, port_num);
+
+ p_remote_physp = osm_physp_get_remote(p_physp);
+ remote_node_type =
+ osm_node_get_type(p_remote_physp->p_node);
+
+ if (remote_node_type == IB_NODE_TYPE_SWITCH)
+ remote_lid_ho =
+ cl_ntoh16(osm_node_get_base_lid
+ (p_remote_physp->p_node, 0));
+ else
+ remote_lid_ho =
+ cl_ntoh16(osm_node_get_base_lid
+ (p_remote_physp->p_node,
+ osm_physp_get_port_num
+ (p_remote_physp)));
+
+ if (!p_cache_sw ||
+ port_num >= p_cache_sw->num_ports ||
+ !p_cache_sw->ports[port_num].remote_lid_ho) {
+ /*
+ * There is some uncached change on the port.
+ * In general, the reasons might be as follows:
+ * - switch reset
+ * - port reset (or port down/up)
+ * - quick connection location change
+ * - new link (or new switch)
+ *
+ * First two reasons allow cache usage, while
+ * the last two reasons should invalidate cache.
+ *
+ * In case of quick connection location change,
+ * cache would have been invalidated by
+ * osm_ucast_cache_check_new_link() function.
+ *
+ * In case of new link between two known nodes,
+ * cache also would have been invalidated by
+ * osm_ucast_cache_check_new_link() function.
+ *
+ * Another reason is cached link between two
+ * known switches went back. In this case the
+ * osm_ucast_cache_check_new_link() function would
+ * clear both sides of the link from the cache
+ * during the discovery process, so effectively
+ * this would be equivalent to port reset.
+ *
+ * So three possible reasons remain:
+ * - switch reset
+ * - port reset (or port down/up)
+ * - link of a new switch
+ *
+ * To validate cache, we need to check only the
+ * third reason - link of a new node/switch:
+ * - If this is the local switch that is new,
+ * then it should have (p_sw->need_update == 2).
+ * - If the remote node is switch and it's new,
+ * then it also should have
+ * (p_sw->need_update == 2).
+ * - If the remote node is CA/RTR and it's new,
+ * then its port should have is_new flag on.
+ */
+ if (p_sw->need_update == 2) {
+ OSM_LOG(p_mgr->p_log, OSM_LOG_DEBUG,
+ "New switch found (lid %u)\n",
+ lid_ho);
+ osm_ucast_cache_invalidate(p_mgr);
+ goto Exit;
+ }
+
+ if (remote_node_type == IB_NODE_TYPE_SWITCH) {
+
+ p_remote_sw =
+ p_remote_physp->p_node->sw;
+ if (p_remote_sw->need_update == 2) {
+ /* this could also be case of
+ switch coming back with an
+ additional link that it
+ didn't have before */
+ OSM_LOG(p_mgr->p_log,
+ OSM_LOG_DEBUG,
+ "New switch/link found (lid %u)\n",
+ remote_lid_ho);
+ osm_ucast_cache_invalidate
+ (p_mgr);
+ goto Exit;
+ }
+ } else {
+ /*
+ * Remote node is CA/RTR.
+ * Get p_port of the remote node and
+ * check its p_port->is_new flag.
+ */
+ p_remote_port =
+ osm_get_port_by_guid(p_mgr->p_subn,
+ osm_physp_get_port_guid
+ (p_remote_physp));
+ if (!p_remote_port) {
+ OSM_LOG(p_mgr->p_log,
+ OSM_LOG_ERROR,
+ "ERR AD04: No port was found for "
+ "port GUID 0x%" PRIx64 "\n",
+ cl_ntoh64(osm_physp_get_port_guid
+ (p_remote_physp)));
+ osm_ucast_cache_invalidate
+ (p_mgr);
+ goto Exit;
+ }
+ if (p_remote_port->is_new) {
+ OSM_LOG(p_mgr->p_log,
+ OSM_LOG_DEBUG,
+ "New CA/RTR found (lid %u)\n",
+ remote_lid_ho);
+ osm_ucast_cache_invalidate
+ (p_mgr);
+ goto Exit;
+ }
+ }
+ } else {
+ /*
+ * The change on the port is cached.
+ * In general, the reasons might be as follows:
+ * - link between two known nodes went back
+ * - one or more nodes went back, causing all
+ * the links to reappear
+ *
+ * If it was link that went back, then this case
+ * would have been taken care of during the
+ * discovery by osm_ucast_cache_check_new_link(),
+ * so it's some node that went back.
+ */
+ if ((p_cache_sw->ports[port_num].is_leaf &&
+ remote_node_type == IB_NODE_TYPE_SWITCH) ||
+ (!p_cache_sw->ports[port_num].is_leaf &&
+ remote_node_type != IB_NODE_TYPE_SWITCH)) {
+ OSM_LOG(p_mgr->p_log, OSM_LOG_DEBUG,
+ "Remote node type change on switch lid %u, port %u\n",
+ lid_ho, port_num);
+ osm_ucast_cache_invalidate(p_mgr);
+ goto Exit;
+ }
+
+ if (p_cache_sw->ports[port_num].remote_lid_ho !=
+ remote_lid_ho) {
+ OSM_LOG(p_mgr->p_log, OSM_LOG_DEBUG,
+ "Remote lid change on switch lid %u, port %u"
+ "(was %u, now %u)\n",
+ lid_ho, port_num,
+ p_cache_sw->ports[port_num].
+ remote_lid_ho, remote_lid_ho);
+ osm_ucast_cache_invalidate(p_mgr);
+ goto Exit;
+ }
+
+ /*
+ * We don't care who is the node that has
+ * reappeared in the subnet (local or remote).
+ * What's important that the cached link matches
+ * the real fabrics link.
+ * Just clean it from cache.
+ */
+
+ p_cache_sw->ports[port_num].remote_lid_ho = 0;
+ p_cache_sw->ports[port_num].is_leaf = FALSE;
+ if (p_cache_sw->dropped) {
+ cache_restore_ucast_info(p_mgr,
+ p_cache_sw,
+ p_sw);
+ p_cache_sw->dropped = FALSE;
+ }
+
+ OSM_LOG(p_mgr->p_log, OSM_LOG_DEBUG,
+ "Restored link from cache: lid %u, port %u to lid %u\n",
+ lid_ho, port_num, remote_lid_ho);
+ }
+ }
+ }
+
+ /* Remove all the cached switches that
+ have all their ports restored */
+ cache_cleanup_switches(p_mgr);
+
+ /*
+ * Done scanning all the physical switch ports in the subnet.
+ * Now we need to check the other side:
+ * Scan all the cached switches and their ports:
+ * - If the cached switch is missing in the subnet
+ * (dropped flag is on), check that it's a leaf switch.
+ * If it's not a leaf, the cache is invalid, because
+ * cache can tolerate only leaf switch removal.
+ * - If the cached switch exists in fabric, check all
+ * its cached ports. These cached ports represent
+ * missing link in the fabric.
+ * The missing links that can be tolerated are:
+ * + link to missing CA/RTR
+ * + link to missing leaf switch
+ */
+ for (p_cache_sw = (cache_switch_t *) cl_qmap_head(&p_mgr->cache_sw_tbl);
+ p_cache_sw != (cache_switch_t *) cl_qmap_end(&p_mgr->cache_sw_tbl);
+ p_cache_sw =
+ (cache_switch_t *) cl_qmap_next(&p_cache_sw->map_item)) {
+
+ if (p_cache_sw->dropped) {
+ if (!cache_sw_is_leaf(p_cache_sw)) {
+ OSM_LOG(p_mgr->p_log, OSM_LOG_DEBUG,
+ "Missing non-leaf switch (lid %u)\n",
+ cache_sw_get_base_lid_ho(p_cache_sw));
+ osm_ucast_cache_invalidate(p_mgr);
+ goto Exit;
+ }
+
+ OSM_LOG(p_mgr->p_log, OSM_LOG_DEBUG,
+ "Missing leaf switch (lid %u) - "
+ "continuing validation\n",
+ cache_sw_get_base_lid_ho(p_cache_sw));
+ continue;
+ }
+
+ for (port_num = 1; port_num < p_cache_sw->num_ports; port_num++) {
+ if (!p_cache_sw->ports[port_num].remote_lid_ho)
+ continue;
+
+ if (p_cache_sw->ports[port_num].is_leaf) {
+ CL_ASSERT(cache_sw_is_leaf(p_cache_sw));
+ OSM_LOG(p_mgr->p_log, OSM_LOG_DEBUG,
+ "Switch lid %u, port %u: missing link to CA/RTR - "
+ "continuing validation\n",
+ cache_sw_get_base_lid_ho(p_cache_sw),
+ port_num);
+ continue;
+ }
+
+ p_remote_cache_sw = cache_get_sw(p_mgr,
+ p_cache_sw->
+ ports[port_num].
+ remote_lid_ho);
+
+ if (!p_remote_cache_sw || !p_remote_cache_sw->dropped) {
+ OSM_LOG(p_mgr->p_log, OSM_LOG_DEBUG,
+ "Switch lid %u, port %u: missing link to existing switch\n",
+ cache_sw_get_base_lid_ho(p_cache_sw),
+ port_num);
+ osm_ucast_cache_invalidate(p_mgr);
+ goto Exit;
+ }
+
+ if (!cache_sw_is_leaf(p_remote_cache_sw)) {
+ OSM_LOG(p_mgr->p_log, OSM_LOG_DEBUG,
+ "Switch lid %u, port %u: missing link to non-leaf switch\n",
+ cache_sw_get_base_lid_ho(p_cache_sw),
+ port_num);
+ osm_ucast_cache_invalidate(p_mgr);
+ goto Exit;
+ }
+
+ /*
+ * At this point we know that the missing link is to
+ * a leaf switch. However, one case deserves a special
+ * treatment. If there was a link between two leaf
+ * switches, then missing leaf switch might break
+ * routing. It is possible that there are routes
+ * that use leaf switches to get from switch to switch
+ * and not just to get to the CAs behind the leaf switch.
+ */
+ if (cache_sw_is_leaf(p_cache_sw) &&
+ cache_sw_is_leaf(p_remote_cache_sw)) {
+ OSM_LOG(p_mgr->p_log, OSM_LOG_DEBUG,
+ "Switch lid %u, port %u: missing leaf-2-leaf link\n",
+ cache_sw_get_base_lid_ho(p_cache_sw),
+ port_num);
+ osm_ucast_cache_invalidate(p_mgr);
+ goto Exit;
+ }
+
+ OSM_LOG(p_mgr->p_log, OSM_LOG_DEBUG,
+ "Switch lid %u, port %u: missing remote leaf switch - "
+ "continuing validation\n",
+ cache_sw_get_base_lid_ho(p_cache_sw),
+ port_num);
+ }
+ }
+
+ OSM_LOG(p_mgr->p_log, OSM_LOG_DEBUG, "Unicast cache is valid\n");
+ ucast_cache_dump(p_mgr);
+Exit:
+ OSM_LOG_EXIT(p_mgr->p_log);
+} /* osm_ucast_cache_validate() */
+
+void osm_ucast_cache_check_new_link(osm_ucast_mgr_t * p_mgr,
+ osm_node_t * p_node_1, uint8_t port_num_1,
+ osm_node_t * p_node_2, uint8_t port_num_2)
+{
+ uint16_t lid_ho_1;
+ uint16_t lid_ho_2;
+
+ OSM_LOG_ENTER(p_mgr->p_log);
+
+ if (!p_mgr->cache_valid)
+ goto Exit;
+
+ cache_check_link_change(p_mgr,
+ osm_node_get_physp_ptr(p_node_1, port_num_1),
+ osm_node_get_physp_ptr(p_node_2, port_num_2));
+
+ if (!p_mgr->cache_valid)
+ goto Exit;
+
+ if (osm_node_get_type(p_node_1) != IB_NODE_TYPE_SWITCH &&
+ osm_node_get_type(p_node_2) != IB_NODE_TYPE_SWITCH) {
+ OSM_LOG(p_mgr->p_log, OSM_LOG_DEBUG, "Found CA-2-CA link\n");
+ osm_ucast_cache_invalidate(p_mgr);
+ goto Exit;
+ }
+
+ /* for code simplicity, we want the first node to be switch */
+ if (osm_node_get_type(p_node_1) != IB_NODE_TYPE_SWITCH) {
+ osm_node_t *tmp_node = p_node_1;
+ uint8_t tmp_port_num = port_num_1;
+ p_node_1 = p_node_2;
+ port_num_1 = port_num_2;
+ p_node_2 = tmp_node;
+ port_num_2 = tmp_port_num;
+ }
+
+ lid_ho_1 = cl_ntoh16(osm_node_get_base_lid(p_node_1, 0));
+
+ if (osm_node_get_type(p_node_2) == IB_NODE_TYPE_SWITCH)
+ lid_ho_2 = cl_ntoh16(osm_node_get_base_lid(p_node_2, 0));
+ else
+ lid_ho_2 =
+ cl_ntoh16(osm_node_get_base_lid(p_node_2, port_num_2));
+
+ if (!lid_ho_1 || !lid_ho_2) {
+ /*
+ * No lid assigned, which means that one of the nodes is new.
+ * Need to wait for lid manager to process this node.
+ * The switches and their links will be checked later when
+ * the whole cache validity will be verified.
+ */
+ OSM_LOG(p_mgr->p_log, OSM_LOG_DEBUG,
+ "Link port %u <-> %u reveals new node - cache will "
+ "be validated later\n", port_num_1, port_num_2);
+ goto Exit;
+ }
+
+ cache_remove_port(p_mgr, lid_ho_1, port_num_1, lid_ho_2,
+ (osm_node_get_type(p_node_2) !=
+ IB_NODE_TYPE_SWITCH));
+
+ /* if node_2 is a switch, the link should be cleaned from its cache */
+
+ if (osm_node_get_type(p_node_2) == IB_NODE_TYPE_SWITCH)
+ cache_remove_port(p_mgr, lid_ho_2,
+ port_num_2, lid_ho_1, FALSE);
+
+Exit:
+ OSM_LOG_EXIT(p_mgr->p_log);
+} /* osm_ucast_cache_check_new_link() */
+
+void osm_ucast_cache_add_link(osm_ucast_mgr_t * p_mgr,
+ osm_physp_t * p_physp1, osm_physp_t * p_physp2)
+{
+ osm_node_t *p_node_1 = p_physp1->p_node, *p_node_2 = p_physp2->p_node;
+ uint16_t lid_ho_1, lid_ho_2;
+
+ OSM_LOG_ENTER(p_mgr->p_log);
+
+ if (!p_mgr->cache_valid)
+ goto Exit;
+
+ if (osm_node_get_type(p_node_1) != IB_NODE_TYPE_SWITCH &&
+ osm_node_get_type(p_node_2) != IB_NODE_TYPE_SWITCH) {
+ OSM_LOG(p_mgr->p_log, OSM_LOG_DEBUG, "Dropping CA-2-CA link\n");
+ osm_ucast_cache_invalidate(p_mgr);
+ goto Exit;
+ }
+
+ if ((osm_node_get_type(p_node_1) == IB_NODE_TYPE_SWITCH &&
+ !osm_node_get_physp_ptr(p_node_1, 0)) ||
+ (osm_node_get_type(p_node_2) == IB_NODE_TYPE_SWITCH &&
+ !osm_node_get_physp_ptr(p_node_2, 0))) {
+ /* we're caching a link when one of the nodes
+ has already been dropped and cached */
+ OSM_LOG(p_mgr->p_log, OSM_LOG_DEBUG,
+ "Port %u <-> port %u: port0 on one of the nodes "
+ "has already been dropped and cached\n",
+ p_physp1->port_num, p_physp2->port_num);
+ goto Exit;
+ }
+
+ /* One of the nodes is switch. Just for code
+ simplicity, make sure that it's the first node. */
+
+ if (osm_node_get_type(p_node_1) != IB_NODE_TYPE_SWITCH) {
+ osm_physp_t *tmp = p_physp1;
+ p_physp1 = p_physp2;
+ p_physp2 = tmp;
+ p_node_1 = p_physp1->p_node;
+ p_node_2 = p_physp2->p_node;
+ }
+
+ if (!p_node_1->sw) {
+ /* something is wrong - we'd better not use cache */
+ osm_ucast_cache_invalidate(p_mgr);
+ goto Exit;
+ }
+
+ lid_ho_1 = cl_ntoh16(osm_node_get_base_lid(p_node_1, 0));
+
+ if (osm_node_get_type(p_node_2) == IB_NODE_TYPE_SWITCH) {
+
+ if (!p_node_2->sw) {
+ /* something is wrong - we'd better not use cache */
+ osm_ucast_cache_invalidate(p_mgr);
+ goto Exit;
+ }
+
+ lid_ho_2 = cl_ntoh16(osm_node_get_base_lid(p_node_2, 0));
+
+ /* lost switch-2-switch link - cache both sides */
+ cache_add_sw_link(p_mgr, p_physp1, lid_ho_2, FALSE);
+ cache_add_sw_link(p_mgr, p_physp2, lid_ho_1, FALSE);
+ } else {
+ lid_ho_2 = cl_ntoh16(osm_physp_get_base_lid(p_physp2));
+
+ /* lost link to CA/RTR - cache only switch side */
+ cache_add_sw_link(p_mgr, p_physp1, lid_ho_2, TRUE);
+ }
+
+Exit:
+ OSM_LOG_EXIT(p_mgr->p_log);
+} /* osm_ucast_cache_add_link() */
+
+void osm_ucast_cache_add_node(osm_ucast_mgr_t * p_mgr, osm_node_t * p_node)
+{
+ uint16_t lid_ho;
+ uint8_t max_ports;
+ uint8_t port_num;
+ osm_physp_t *p_physp;
+ cache_switch_t *p_cache_sw;
+
+ OSM_LOG_ENTER(p_mgr->p_log);
+
+ if (!p_mgr->cache_valid)
+ goto Exit;
+
+ if (osm_node_get_type(p_node) == IB_NODE_TYPE_SWITCH) {
+
+ lid_ho = cl_ntoh16(osm_node_get_base_lid(p_node, 0));
+
+ if (!lid_ho) {
+ OSM_LOG(p_mgr->p_log, OSM_LOG_VERBOSE,
+ "Skip caching. Switch dropped before "
+ "it gets a valid lid.\n");
+ osm_ucast_cache_invalidate(p_mgr);
+ goto Exit;
+ }
+
+ OSM_LOG(p_mgr->p_log, OSM_LOG_DEBUG,
+ "Caching dropped switch lid %u\n", lid_ho);
+
+ if (!p_node->sw) {
+ /* something is wrong - forget about cache */
+ OSM_LOG(p_mgr->p_log, OSM_LOG_ERROR,
+ "ERR AD03: no switch info for node lid %u - "
+ "clearing cache\n", lid_ho);
+ osm_ucast_cache_invalidate(p_mgr);
+ goto Exit;
+ }
+
+ /* unlink (add to cache) all the ports of this switch */
+ max_ports = osm_node_get_num_physp(p_node);
+ for (port_num = 1; port_num < max_ports; port_num++) {
+
+ p_physp = osm_node_get_physp_ptr(p_node, port_num);
+ if (!p_physp || !p_physp->p_remote_physp)
+ continue;
+
+ osm_ucast_cache_add_link(p_mgr, p_physp,
+ p_physp->p_remote_physp);
+ }
+
+ /*
+ * All the ports have been dropped (cached).
+ * If one of the ports was connected to CA/RTR,
+ * then the cached switch would be marked as leaf.
+ * If it isn't, then the dropped switch isn't a leaf,
+ * and cache can't handle it.
+ */
+
+ p_cache_sw = cache_get_sw(p_mgr, lid_ho);
+
+ /* p_cache_sw could be NULL if it has no remote phys ports */
+ if (!p_cache_sw || !cache_sw_is_leaf(p_cache_sw)) {
+ OSM_LOG(p_mgr->p_log, OSM_LOG_DEBUG,
+ "Dropped non-leaf switch (lid %u)\n", lid_ho);
+ osm_ucast_cache_invalidate(p_mgr);
+ goto Exit;
+ }
+
+ p_cache_sw->dropped = TRUE;
+
+ if (!p_node->sw->num_hops || !p_node->sw->hops) {
+ OSM_LOG(p_mgr->p_log, OSM_LOG_DEBUG,
+ "No LID matrices for switch lid %u\n", lid_ho);
+ osm_ucast_cache_invalidate(p_mgr);
+ goto Exit;
+ }
+
+ /* lid matrices */
+
+ p_cache_sw->num_hops = p_node->sw->num_hops;
+ p_node->sw->num_hops = 0;
+ p_cache_sw->hops = p_node->sw->hops;
+ p_node->sw->hops = NULL;
+
+ /* linear forwarding table */
+
+ if (p_node->sw->new_lft) {
+ /* LFT buffer exists - we use it, because
+ it is more updated than the switch's LFT */
+ p_cache_sw->lft = p_node->sw->new_lft;
+ p_node->sw->new_lft = NULL;
+ } else {
+ /* no LFT buffer, so we use the switch's LFT */
+ p_cache_sw->lft = p_node->sw->lft;
+ p_node->sw->lft = NULL;
+ p_node->sw->lft_size = 0;
+ }
+ p_cache_sw->max_lid_ho = p_node->sw->max_lid_ho;
+ } else {
+ /* dropping CA/RTR: add to cache all the ports of this node */
+ max_ports = osm_node_get_num_physp(p_node);
+ for (port_num = 1; port_num < max_ports; port_num++) {
+
+ p_physp = osm_node_get_physp_ptr(p_node, port_num);
+ if (!p_physp || !p_physp->p_remote_physp)
+ continue;
+
+ CL_ASSERT(osm_node_get_type
+ (p_physp->p_remote_physp->p_node) ==
+ IB_NODE_TYPE_SWITCH);
+
+ osm_ucast_cache_add_link(p_mgr,
+ p_physp->p_remote_physp,
+ p_physp);
+ }
+ }
+Exit:
+ OSM_LOG_EXIT(p_mgr->p_log);
+} /* osm_ucast_cache_add_node() */
+
+int osm_ucast_cache_process(osm_ucast_mgr_t * p_mgr)
+{
+ cl_qmap_t *tbl = &p_mgr->p_subn->sw_guid_tbl;
+ cl_map_item_t *item;
+ osm_switch_t *p_sw;
+ uint16_t lft_size;
+
+ if (!p_mgr->p_subn->opt.use_ucast_cache)
+ return 1;
+
+ ucast_cache_validate(p_mgr);
+ if (!p_mgr->cache_valid)
+ return 1;
+
+ OSM_LOG(p_mgr->p_log, OSM_LOG_INFO,
+ "Configuring switch tables using cached routing\n");
+
+ for (item = cl_qmap_head(tbl); item != cl_qmap_end(tbl);
+ item = cl_qmap_next(item)) {
+ p_sw = (osm_switch_t *) item;
+ CL_ASSERT(p_sw->new_lft);
+ if (!p_sw->lft) {
+ lft_size = (p_sw->max_lid_ho / IB_SMP_DATA_SIZE + 1)
+ * IB_SMP_DATA_SIZE;
+ p_sw->lft = malloc(lft_size);
+ if (!p_sw->lft)
+ return IB_INSUFFICIENT_MEMORY;
+ p_sw->lft_size = lft_size;
+ memset(p_sw->lft, OSM_NO_PATH, p_sw->lft_size);
+ }
+
+ }
+
+ osm_ucast_mgr_set_fwd_tables(p_mgr);
+
+ return 0;
+}
diff --git a/contrib/ofed/opensm/opensm/osm_ucast_dfsssp.c b/contrib/ofed/opensm/opensm/osm_ucast_dfsssp.c
new file mode 100644
index 0000000..67744fa
--- /dev/null
+++ b/contrib/ofed/opensm/opensm/osm_ucast_dfsssp.c
@@ -0,0 +1,2873 @@
+/*
+ * Copyright (c) 2004-2008 Voltaire, Inc. All rights reserved.
+ * Copyright (c) 2002-2015 Mellanox Technologies LTD. All rights reserved.
+ * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
+ * Copyright (c) 2009-2015 ZIH, TU Dresden, Federal Republic of Germany. All rights reserved.
+ * Copyright (C) 2012-2017 Tokyo Institute of Technology. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+/*
+ * Abstract:
+ * Implementation of OpenSM (deadlock-free) single-source-shortest-path routing
+ * (with dijkstra algorithm)
+ */
+
+#if HAVE_CONFIG_H
+# include <config.h>
+#endif /* HAVE_CONFIG_H */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <opensm/osm_file_ids.h>
+#define FILE_ID OSM_FILE_UCAST_DFSSSP_C
+#include <opensm/osm_ucast_mgr.h>
+#include <opensm/osm_opensm.h>
+#include <opensm/osm_node.h>
+#include <opensm/osm_multicast.h>
+#include <opensm/osm_mcast_mgr.h>
+
+/* "infinity" for dijkstra */
+#define INF 0x7FFFFFFF
+
+enum {
+ UNDISCOVERED = 0,
+ DISCOVERED
+};
+
+enum {
+ UNKNOWN = 0,
+ GRAY,
+ BLACK,
+};
+
+typedef struct link {
+ uint64_t guid; /* guid of the neighbor behind the link */
+ uint32_t from; /* base_index in the adjazenz list (start of the link) */
+ uint8_t from_port; /* port on the base_side (needed for weight update to identify the correct link for multigraphs) */
+ uint32_t to; /* index of the neighbor in the adjazenz list (end of the link) */
+ uint8_t to_port; /* port on the side of the neighbor (needed for the LFT) */
+ uint64_t weight; /* link weight */
+ struct link *next;
+} link_t;
+
+typedef struct vertex {
+ /* informations of the fabric */
+ uint64_t guid;
+ uint16_t lid; /* for lft filling */
+ uint32_t num_hca; /* numbers of Hca/LIDs on the switch, for weight calculation */
+ link_t *links;
+ uint8_t hops;
+ /* for dijkstra routing */
+ link_t *used_link; /* link between the vertex discovered before and this vertex */
+ uint64_t distance; /* distance from source to this vertex */
+ uint8_t state;
+ /* for the binary heap */
+ uint32_t heap_id;
+ /* for LFT writing and debug */
+ osm_switch_t *sw; /* selfpointer */
+ boolean_t dropped; /* indicate dropped switches (w/ ucast cache) */
+} vertex_t;
+
+typedef struct binary_heap {
+ uint32_t size; /* size of the heap */
+ vertex_t **nodes; /* array with pointers to elements of the adj_list */
+} binary_heap_t;
+
+typedef struct vltable {
+ uint64_t num_lids; /* size of the lids array */
+ uint16_t *lids; /* sorted array of all lids in the subnet */
+ uint8_t *vls; /* matrix form assignment lid X lid -> virtual lane */
+} vltable_t;
+
+typedef struct cdg_link {
+ struct cdg_node *node;
+ uint32_t num_pairs; /* number of src->dest pairs incremented in path adding step */
+ uint32_t max_len; /* length of the srcdest array */
+ uint32_t removed; /* number of pairs removed in path deletion step */
+ uint32_t *srcdest_pairs;
+ struct cdg_link *next;
+} cdg_link_t;
+
+/* struct for a node of a binary tree with additional parent pointer */
+typedef struct cdg_node {
+ uint64_t channelID; /* unique key consist of src lid + port + dest lid + port */
+ cdg_link_t *linklist; /* edges to adjazent nodes */
+ uint8_t status; /* node status in cycle search to avoid recursive function */
+ uint8_t visited; /* needed to traverse the binary tree */
+ struct cdg_node *pre; /* to save the path in cycle detection algorithm */
+ struct cdg_node *left, *right, *parent;
+} cdg_node_t;
+
+typedef struct dfsssp_context {
+ osm_routing_engine_type_t routing_type;
+ osm_ucast_mgr_t *p_mgr;
+ vertex_t *adj_list;
+ uint32_t adj_list_size;
+ vltable_t *srcdest2vl_table;
+ uint8_t *vl_split_count;
+} dfsssp_context_t;
+
+/**************** set initial values for structs **********************
+ **********************************************************************/
+static inline void set_default_link(link_t * link)
+{
+ link->guid = 0;
+ link->from = 0;
+ link->from_port = 0;
+ link->to = 0;
+ link->to_port = 0;
+ link->weight = 0;
+ link->next = NULL;
+}
+
+static inline void set_default_vertex(vertex_t * vertex)
+{
+ vertex->guid = 0;
+ vertex->lid = 0;
+ vertex->num_hca = 0;
+ vertex->links = NULL;
+ vertex->hops = 0;
+ vertex->used_link = NULL;
+ vertex->distance = 0;
+ vertex->state = UNDISCOVERED;
+ vertex->heap_id = 0;
+ vertex->sw = NULL;
+ vertex->dropped = FALSE;
+}
+
+static inline void set_default_cdg_node(cdg_node_t * node)
+{
+ node->channelID = 0;
+ node->linklist = NULL;
+ node->status = UNKNOWN;
+ node->visited = 0;
+ node->pre = NULL;
+ node->left = NULL;
+ node->right = NULL;
+ node->parent = NULL;
+}
+
+/**********************************************************************
+ **********************************************************************/
+
+/************ helper functions for heap in dijkstra *******************
+ **********************************************************************/
+/* returns true if element 1 is smaller than element 2 */
+static inline uint32_t heap_smaller(binary_heap_t * heap, uint32_t i,
+ uint32_t j)
+{
+ return (heap->nodes[i]->distance < heap->nodes[j]->distance) ? 1 : 0;
+}
+
+/* swap two elements */
+static void heap_exchange(binary_heap_t * heap, uint32_t i, uint32_t j)
+{
+ uint32_t tmp_heap_id = 0;
+ vertex_t *tmp_node = NULL;
+
+ /* 1. swap the heap_id */
+ tmp_heap_id = heap->nodes[i]->heap_id;
+ heap->nodes[i]->heap_id = heap->nodes[j]->heap_id;
+ heap->nodes[j]->heap_id = tmp_heap_id;
+ /* 2. swap pointers */
+ tmp_node = heap->nodes[i];
+ heap->nodes[i] = heap->nodes[j];
+ heap->nodes[j] = tmp_node;
+}
+
+/* changes position of element with parent until children are bigger */
+static uint32_t heap_up(binary_heap_t * heap, uint32_t i)
+{
+ uint32_t curr = i, father = 0;
+
+ if (curr > 0) {
+ father = (curr - 1) >> 1;
+ while (heap_smaller(heap, curr, father)) {
+ heap_exchange(heap, curr, father);
+ /* try to go up when we arent already root */
+ curr = father;
+ if (curr > 0)
+ father = (curr - 1) >> 1;
+ }
+ }
+
+ return curr;
+}
+
+/* changes position of element with children until parent is smaller */
+static uint32_t heap_down(binary_heap_t * heap, uint32_t i)
+{
+ uint32_t curr = i;
+ uint32_t son1 = 0, son2 = 0, smaller_son = 0;
+ uint32_t exchanged = 0;
+
+ do {
+ son1 = ((curr + 1) << 1) - 1;
+ son2 = (curr + 1) << 1;
+ exchanged = 0;
+
+ /* exchange with smaller son */
+ if (son1 < heap->size && son2 < heap->size) {
+ if (heap_smaller(heap, son1, son2))
+ smaller_son = son1;
+ else
+ smaller_son = son2;
+ } else if (son1 < heap->size) {
+ /* only one son */
+ smaller_son = son1;
+ } else {
+ /* finished */
+ break;
+ }
+
+ /* only exchange when smaller */
+ if (heap_smaller(heap, smaller_son, curr)) {
+ heap_exchange(heap, curr, smaller_son);
+ exchanged = 1;
+ curr = smaller_son;
+ }
+ } while (exchanged);
+
+ return curr;
+}
+
+/* reheapify element */
+static inline void heap_heapify(binary_heap_t * heap, uint32_t i)
+{
+ heap_down(heap, heap_up(heap, i));
+}
+
+/* creates heap for graph */
+static int heap_create(vertex_t * adj_list, uint32_t adj_list_size,
+ binary_heap_t ** binheap)
+{
+ binary_heap_t *heap = NULL;
+ uint32_t i = 0;
+
+ /* allocate the memory for the heap object */
+ heap = (binary_heap_t *) malloc(sizeof(binary_heap_t));
+ if (!heap)
+ return 1;
+
+ /* the heap size is equivalent to the size of the adj_list */
+ heap->size = adj_list_size;
+
+ /* allocate the pointer array, fill with the pointers to the elements of the adj_list and set the initial heap_id */
+ heap->nodes = (vertex_t **) malloc(heap->size * sizeof(vertex_t *));
+ if (!heap->nodes) {
+ free(heap);
+ return 1;
+ }
+ for (i = 0; i < heap->size; i++) {
+ heap->nodes[i] = &adj_list[i];
+ heap->nodes[i]->heap_id = i;
+ }
+
+ /* sort elements */
+ for (i = heap->size; i > 0; i--)
+ heap_down(heap, i - 1);
+
+ *binheap = heap;
+ return 0;
+}
+
+/* returns current minimum and removes it from heap */
+static vertex_t *heap_getmin(binary_heap_t * heap)
+{
+ vertex_t *min = NULL;
+
+ if (heap->size > 0)
+ min = heap->nodes[0];
+
+ if (min == NULL)
+ return min;
+
+ if (heap->size > 0) {
+ if (heap->size > 1) {
+ heap_exchange(heap, 0, heap->size - 1);
+ heap->size--;
+ heap_down(heap, 0);
+ } else {
+ heap->size--;
+ }
+ }
+
+ return min;
+}
+
+/* cleanup heap */
+static void heap_free(binary_heap_t * heap)
+{
+ if (heap) {
+ if (heap->nodes) {
+ free(heap->nodes);
+ heap->nodes = NULL;
+ }
+ free(heap);
+ }
+}
+
+/**********************************************************************
+ **********************************************************************/
+
+/************ helper functions to save src/dest X vl combination ******
+ **********************************************************************/
+/* compare function of two lids for stdlib qsort */
+static int cmp_lids(const void *l1, const void *l2)
+{
+ ib_net16_t lid1 = *((ib_net16_t *) l1), lid2 = *((ib_net16_t *) l2);
+
+ if (lid1 < lid2)
+ return -1;
+ else if (lid1 > lid2)
+ return 1;
+ else
+ return 0;
+}
+
+/* use stdlib to sort the lid array */
+static inline void vltable_sort_lids(vltable_t * vltable)
+{
+ qsort(vltable->lids, vltable->num_lids, sizeof(ib_net16_t), cmp_lids);
+}
+
+/* use stdlib to get index of key in lid array;
+ return -1 if lid isn't found in lids array
+*/
+static inline int64_t vltable_get_lidindex(ib_net16_t * key, vltable_t * vltable)
+{
+ ib_net16_t *found_lid = NULL;
+
+ found_lid =
+ (ib_net16_t *) bsearch(key, vltable->lids, vltable->num_lids,
+ sizeof(ib_net16_t), cmp_lids);
+ if (found_lid)
+ return found_lid - vltable->lids;
+ else
+ return -1;
+}
+
+/* get virtual lane from src lid X dest lid combination;
+ return -1 for invalid lids
+*/
+static int32_t vltable_get_vl(vltable_t * vltable, ib_net16_t slid, ib_net16_t dlid)
+{
+ int64_t ind1 = vltable_get_lidindex(&slid, vltable);
+ int64_t ind2 = vltable_get_lidindex(&dlid, vltable);
+
+ if (ind1 > -1 && ind2 > -1)
+ return (int32_t) (vltable->
+ vls[ind1 + ind2 * vltable->num_lids]);
+ else
+ return -1;
+}
+
+/* set a virtual lane in the matrix */
+static inline void vltable_insert(vltable_t * vltable, ib_net16_t slid,
+ ib_net16_t dlid, uint8_t vl)
+{
+ int64_t ind1 = vltable_get_lidindex(&slid, vltable);
+ int64_t ind2 = vltable_get_lidindex(&dlid, vltable);
+
+ if (ind1 > -1 && ind2 > -1)
+ vltable->vls[ind1 + ind2 * vltable->num_lids] = vl;
+}
+
+/* change a number of lanes from lane xy to lane yz */
+static void vltable_change_vl(vltable_t * vltable, uint8_t from, uint8_t to,
+ uint64_t count)
+{
+ uint64_t set = 0, stop = 0;
+ uint64_t ind1 = 0, ind2 = 0;
+
+ for (ind1 = 0; ind1 < vltable->num_lids; ind1++) {
+ for (ind2 = 0; ind2 < vltable->num_lids; ind2++) {
+ if (set == count) {
+ stop = 1;
+ break;
+ }
+ if (ind1 != ind2) {
+ if (vltable->
+ vls[ind1 + ind2 * vltable->num_lids] ==
+ from) {
+ vltable->vls[ind1 +
+ ind2 * vltable->num_lids] =
+ to;
+ set++;
+ }
+ }
+ }
+ if (stop)
+ break;
+ }
+}
+
+static void vltable_print(osm_ucast_mgr_t * p_mgr, vltable_t * vltable)
+{
+ uint64_t ind1 = 0, ind2 = 0;
+
+ for (ind1 = 0; ind1 < vltable->num_lids; ind1++) {
+ for (ind2 = 0; ind2 < vltable->num_lids; ind2++) {
+ if (ind1 != ind2) {
+ OSM_LOG(p_mgr->p_log, OSM_LOG_DEBUG,
+ " route from src_lid=%" PRIu16
+ " to dest_lid=%" PRIu16 " on vl=%" PRIu8
+ "\n", cl_ntoh16(vltable->lids[ind1]),
+ cl_ntoh16(vltable->lids[ind2]),
+ vltable->vls[ind1 +
+ ind2 * vltable->num_lids]);
+ }
+ }
+ }
+}
+
+static void vltable_dealloc(vltable_t ** vltable)
+{
+ if (*vltable) {
+ if ((*vltable)->lids)
+ free((*vltable)->lids);
+ if ((*vltable)->vls)
+ free((*vltable)->vls);
+ free(*vltable);
+ *vltable = NULL;
+ }
+}
+
+static int vltable_alloc(vltable_t ** vltable, uint64_t size)
+{
+ /* allocate VL table and indexing array */
+ *vltable = (vltable_t *) malloc(sizeof(vltable_t));
+ if (!(*vltable))
+ goto ERROR;
+ (*vltable)->num_lids = size;
+ (*vltable)->lids = (ib_net16_t *) malloc(size * sizeof(ib_net16_t));
+ if (!((*vltable)->lids))
+ goto ERROR;
+ (*vltable)->vls = (uint8_t *) malloc(size * size * sizeof(uint8_t));
+ if (!((*vltable)->vls))
+ goto ERROR;
+ memset((*vltable)->vls, OSM_DEFAULT_SL, size * size);
+
+ return 0;
+
+ERROR:
+ vltable_dealloc(vltable);
+
+ return 1;
+}
+
+/**********************************************************************
+ **********************************************************************/
+
+/************ helper functions to save/manage the channel dep. graph **
+ **********************************************************************/
+/* update the srcdest array;
+ realloc array (double the size) if size is not large enough
+*/
+static void set_next_srcdest_pair(cdg_link_t * link, uint32_t srcdest)
+{
+ uint32_t new_size = 0, start_size = 2;
+ uint32_t *tmp = NULL, *tmp2 = NULL;
+
+ if (link->num_pairs == 0) {
+ link->srcdest_pairs =
+ (uint32_t *) malloc(start_size * sizeof(uint32_t));
+ link->srcdest_pairs[link->num_pairs] = srcdest;
+ link->max_len = start_size;
+ link->removed = 0;
+ } else if (link->num_pairs == link->max_len) {
+ new_size = link->max_len << 1;
+ tmp = (uint32_t *) malloc(new_size * sizeof(uint32_t));
+ tmp =
+ memcpy(tmp, link->srcdest_pairs,
+ link->max_len * sizeof(uint32_t));
+ tmp2 = link->srcdest_pairs;
+ link->srcdest_pairs = tmp;
+ link->srcdest_pairs[link->num_pairs] = srcdest;
+ free(tmp2);
+ link->max_len = new_size;
+ } else {
+ link->srcdest_pairs[link->num_pairs] = srcdest;
+ }
+ link->num_pairs++;
+}
+
+static inline uint32_t get_next_srcdest_pair(cdg_link_t * link, uint32_t index)
+{
+ return link->srcdest_pairs[index];
+}
+
+/* traverse binary tree to find a node */
+static cdg_node_t *cdg_search(cdg_node_t * root, uint64_t channelID)
+{
+ while (root) {
+ if (channelID < root->channelID)
+ root = root->left;
+ else if (channelID > root->channelID)
+ root = root->right;
+ else if (channelID == root->channelID)
+ return root;
+ }
+ return NULL;
+}
+
+/* insert new node into the binary tree */
+static void cdg_insert(cdg_node_t ** root, cdg_node_t * new_node)
+{
+ cdg_node_t *current = *root;
+
+ if (!current) {
+ current = new_node;
+ *root = current;
+ return;
+ }
+
+ while (current) {
+ if (new_node->channelID < current->channelID) {
+ if (current->left) {
+ current = current->left;
+ } else {
+ current->left = new_node;
+ new_node->parent = current;
+ break;
+ }
+ } else if (new_node->channelID > current->channelID) {
+ if (current->right) {
+ current = current->right;
+ } else {
+ current->right = new_node;
+ new_node->parent = current;
+ break;
+ }
+ } else if (new_node->channelID == current->channelID) {
+ /* not really possible, maybe programming error */
+ break;
+ }
+ }
+}
+
+static void cdg_node_dealloc(cdg_node_t * node)
+{
+ cdg_link_t *link = node->linklist, *tmp = NULL;
+
+ /* dealloc linklist */
+ while (link) {
+ tmp = link;
+ link = link->next;
+
+ if (tmp->num_pairs)
+ free(tmp->srcdest_pairs);
+ free(tmp);
+ }
+ /* dealloc node */
+ free(node);
+}
+
+static void cdg_dealloc(cdg_node_t ** root)
+{
+ cdg_node_t *current = *root;
+
+ while (current) {
+ if (current->left) {
+ current = current->left;
+ } else if (current->right) {
+ current = current->right;
+ } else {
+ if (current->parent == NULL) {
+ cdg_node_dealloc(current);
+ *root = NULL;
+ break;
+ }
+ if (current->parent->left == current) {
+ current = current->parent;
+ cdg_node_dealloc(current->left);
+ current->left = NULL;
+ } else if (current->parent->right == current) {
+ current = current->parent;
+ cdg_node_dealloc(current->right);
+ current->right = NULL;
+ }
+ }
+ }
+}
+
+/* search for a edge in the cdg which should be removed to break a cycle */
+static cdg_link_t *get_weakest_link_in_cycle(cdg_node_t * cycle)
+{
+ cdg_node_t *current = cycle, *node_with_weakest_link = NULL;
+ cdg_link_t *link = NULL, *weakest_link = NULL;
+
+ link = current->linklist;
+ while (link) {
+ if (link->node->status == GRAY) {
+ weakest_link = link;
+ node_with_weakest_link = current;
+ current = link->node;
+ break;
+ }
+ link = link->next;
+ }
+
+ while (1) {
+ current->status = UNKNOWN;
+ link = current->linklist;
+ while (link) {
+ if (link->node->status == GRAY) {
+ if ((link->num_pairs - link->removed) <
+ (weakest_link->num_pairs -
+ weakest_link->removed)) {
+ weakest_link = link;
+ node_with_weakest_link = current;
+ }
+ current = link->node;
+ break;
+ }
+ link = link->next;
+ }
+ /* if complete cycle is traversed */
+ if (current == cycle) {
+ current->status = UNKNOWN;
+ break;
+ }
+ }
+
+ if (node_with_weakest_link->linklist == weakest_link) {
+ node_with_weakest_link->linklist = weakest_link->next;
+ } else {
+ link = node_with_weakest_link->linklist;
+ while (link) {
+ if (link->next == weakest_link) {
+ link->next = weakest_link->next;
+ break;
+ }
+ link = link->next;
+ }
+ }
+
+ return weakest_link;
+}
+
+/* search for nodes in the cdg not yet reached in the cycle search process;
+ (some nodes are unreachable, e.g. a node is a source or the cdg has not connected parts)
+*/
+static cdg_node_t *get_next_cdg_node(cdg_node_t * root)
+{
+ cdg_node_t *current = root, *res = NULL;
+
+ while (current) {
+ current->visited = 1;
+ if (current->status == UNKNOWN) {
+ res = current;
+ break;
+ }
+ if (current->left && !current->left->visited) {
+ current = current->left;
+ } else if (current->right && !current->right->visited) {
+ current = current->right;
+ } else {
+ if (current->left)
+ current->left->visited = 0;
+ if (current->right)
+ current->right->visited = 0;
+ if (current->parent == NULL)
+ break;
+ else
+ current = current->parent;
+ }
+ }
+
+ /* Clean up */
+ while (current) {
+ current->visited = 0;
+ if (current->left)
+ current->left->visited = 0;
+ if (current->right)
+ current->right->visited = 0;
+ current = current->parent;
+ }
+
+ return res;
+}
+
+/* make a DFS on the cdg to check for a cycle */
+static cdg_node_t *search_cycle_in_channel_dep_graph(cdg_node_t * cdg,
+ cdg_node_t * start_node)
+{
+ cdg_node_t *cycle = NULL;
+ cdg_node_t *current = start_node, *next_node = NULL, *tmp = NULL;
+ cdg_link_t *link = NULL;
+
+ while (current) {
+ current->status = GRAY;
+ link = current->linklist;
+ next_node = NULL;
+ while (link) {
+ if (link->node->status == UNKNOWN) {
+ next_node = link->node;
+ break;
+ }
+ if (link->node->status == GRAY) {
+ cycle = link->node;
+ goto Exit;
+ }
+ link = link->next;
+ }
+ if (next_node) {
+ next_node->pre = current;
+ current = next_node;
+ } else {
+ /* found a sink in the graph, go to last node */
+ current->status = BLACK;
+
+ /* srcdest_pairs of this node aren't relevant, free the allocated memory */
+ link = current->linklist;
+ while (link) {
+ if (link->num_pairs)
+ free(link->srcdest_pairs);
+ link->srcdest_pairs = NULL;
+ link->num_pairs = 0;
+ link->removed = 0;
+ link = link->next;
+ }
+
+ if (current->pre) {
+ tmp = current;
+ current = current->pre;
+ tmp->pre = NULL;
+ } else {
+ /* search for other subgraphs in cdg */
+ current = get_next_cdg_node(cdg);
+ if (!current)
+ break; /* all relevant nodes traversed, no more cycles found */
+ }
+ }
+ }
+
+Exit:
+ return cycle;
+}
+
+/* calculate the path from source to destination port;
+ new channels are added directly to the cdg
+*/
+static int update_channel_dep_graph(cdg_node_t ** cdg_root,
+ osm_port_t * src_port, uint16_t slid,
+ osm_port_t * dest_port, uint16_t dlid)
+{
+ osm_node_t *local_node = NULL, *remote_node = NULL;
+ uint16_t local_lid = 0, remote_lid = 0;
+ uint32_t srcdest = 0;
+ uint8_t local_port = 0, remote_port = 0;
+ uint64_t channelID = 0;
+
+ cdg_node_t *channel_head = NULL, *channel = NULL, *last_channel = NULL;
+ cdg_link_t *linklist = NULL;
+
+ /* set the identifier for the src/dest pair to save this on each edge of the cdg */
+ srcdest = (((uint32_t) slid) << 16) + ((uint32_t) dlid);
+
+ channel_head = (cdg_node_t *) malloc(sizeof(cdg_node_t));
+ if (!channel_head)
+ goto ERROR;
+ set_default_cdg_node(channel_head);
+ last_channel = channel_head;
+
+ /* if src is a Hca, then the channel from Hca to switch would be a source in the graph
+ sources can't be part of a cycle -> skip this channel
+ */
+ remote_node =
+ osm_node_get_remote_node(src_port->p_node,
+ src_port->p_physp->port_num, &remote_port);
+
+ while (remote_node && remote_node->sw) {
+ local_node = remote_node;
+ local_port = local_node->sw->new_lft[dlid];
+ /* sanity check: local_port must be set or routing is broken */
+ if (local_port == OSM_NO_PATH)
+ goto ERROR;
+ local_lid = cl_ntoh16(osm_node_get_base_lid(local_node, 0));
+ /* each port belonging to a switch has lmc==0 -> get_base_lid is fine
+ (local/remote port in this function are always part of a switch)
+ */
+
+ remote_node =
+ osm_node_get_remote_node(local_node, local_port,
+ &remote_port);
+ /* if remote_node is a Hca, then the last channel from switch to Hca would be a sink in the cdg -> skip */
+ if (!remote_node || !remote_node->sw)
+ break;
+ remote_lid = cl_ntoh16(osm_node_get_base_lid(remote_node, 0));
+
+ channelID =
+ (((uint64_t) local_lid) << 48) +
+ (((uint64_t) local_port) << 32) +
+ (((uint64_t) remote_lid) << 16) + ((uint64_t) remote_port);
+ channel = cdg_search(*cdg_root, channelID);
+ if (channel) {
+ /* check whether last channel has connection to this channel, i.e. subpath already exists in cdg */
+ linklist = last_channel->linklist;
+ while (linklist && linklist->node != channel
+ && linklist->next)
+ linklist = linklist->next;
+ /* if there is no connection, add one */
+ if (linklist) {
+ if (linklist->node == channel) {
+ set_next_srcdest_pair(linklist,
+ srcdest);
+ } else {
+ linklist->next =
+ (cdg_link_t *)
+ malloc(sizeof(cdg_link_t));
+ if (!linklist->next)
+ goto ERROR;
+ linklist = linklist->next;
+ linklist->node = channel;
+ linklist->num_pairs = 0;
+ linklist->srcdest_pairs = NULL;
+ set_next_srcdest_pair(linklist,
+ srcdest);
+ linklist->next = NULL;
+ }
+ } else {
+ /* either this is the first channel of the path, or the last channel was a new channel, or last channel was a sink */
+ last_channel->linklist =
+ (cdg_link_t *) malloc(sizeof(cdg_link_t));
+ if (!last_channel->linklist)
+ goto ERROR;
+ last_channel->linklist->node = channel;
+ last_channel->linklist->num_pairs = 0;
+ last_channel->linklist->srcdest_pairs = NULL;
+ set_next_srcdest_pair(last_channel->linklist,
+ srcdest);
+ last_channel->linklist->next = NULL;
+ }
+ } else {
+ /* create new channel */
+ channel = (cdg_node_t *) malloc(sizeof(cdg_node_t));
+ if (!channel)
+ goto ERROR;
+ set_default_cdg_node(channel);
+ channel->channelID = channelID;
+ cdg_insert(cdg_root, channel);
+
+ /* go to end of link list of last channel */
+ linklist = last_channel->linklist;
+ while (linklist && linklist->next)
+ linklist = linklist->next;
+ if (linklist) {
+ /* update last link of an existing channel */
+ linklist->next =
+ (cdg_link_t *) malloc(sizeof(cdg_link_t));
+ if (!linklist->next)
+ goto ERROR;
+ linklist = linklist->next;
+ linklist->node = channel;
+ linklist->num_pairs = 0;
+ linklist->srcdest_pairs = NULL;
+ set_next_srcdest_pair(linklist, srcdest);
+ linklist->next = NULL;
+ } else {
+ /* either this is the first channel of the path, or the last channel was a new channel, or last channel was a sink */
+ last_channel->linklist =
+ (cdg_link_t *) malloc(sizeof(cdg_link_t));
+ if (!last_channel->linklist)
+ goto ERROR;
+ last_channel->linklist->node = channel;
+ last_channel->linklist->num_pairs = 0;
+ last_channel->linklist->srcdest_pairs = NULL;
+ set_next_srcdest_pair(last_channel->linklist,
+ srcdest);
+ last_channel->linklist->next = NULL;
+ }
+ }
+ last_channel = channel;
+ }
+
+ if (channel_head->linklist) {
+ if (channel_head->linklist->srcdest_pairs)
+ free(channel_head->linklist->srcdest_pairs);
+ free(channel_head->linklist);
+ }
+ free(channel_head);
+
+ return 0;
+
+ERROR:
+ /* cleanup data and exit */
+ if (channel_head) {
+ if (channel_head->linklist)
+ free(channel_head->linklist);
+ free(channel_head);
+ }
+
+ return 1;
+}
+
+/* calculate the path from source to destination port;
+ the links in the cdg representing this path are decremented to simulate the removal
+*/
+static int remove_path_from_cdg(cdg_node_t ** cdg_root, osm_port_t * src_port,
+ uint16_t slid, osm_port_t * dest_port,
+ uint16_t dlid)
+{
+ osm_node_t *local_node = NULL, *remote_node = NULL;
+ uint16_t local_lid = 0, remote_lid = 0;
+ uint8_t local_port = 0, remote_port = 0;
+ uint64_t channelID = 0;
+
+ cdg_node_t *channel_head = NULL, *channel = NULL, *last_channel = NULL;
+ cdg_link_t *linklist = NULL;
+
+ channel_head = (cdg_node_t *) malloc(sizeof(cdg_node_t));
+ if (!channel_head)
+ goto ERROR;
+ set_default_cdg_node(channel_head);
+ last_channel = channel_head;
+
+ /* if src is a Hca, then the channel from Hca to switch would be a source in the graph
+ sources can't be part of a cycle -> skip this channel
+ */
+ remote_node =
+ osm_node_get_remote_node(src_port->p_node,
+ src_port->p_physp->port_num, &remote_port);
+
+ while (remote_node && remote_node->sw) {
+ local_node = remote_node;
+ local_port = local_node->sw->new_lft[dlid];
+ /* sanity check: local_port must be set or routing is broken */
+ if (local_port == OSM_NO_PATH)
+ goto ERROR;
+ local_lid = cl_ntoh16(osm_node_get_base_lid(local_node, 0));
+
+ remote_node =
+ osm_node_get_remote_node(local_node, local_port,
+ &remote_port);
+ /* if remote_node is a Hca, then the last channel from switch to Hca would be a sink in the cdg -> skip */
+ if (!remote_node || !remote_node->sw)
+ break;
+ remote_lid = cl_ntoh16(osm_node_get_base_lid(remote_node, 0));
+
+ channelID =
+ (((uint64_t) local_lid) << 48) +
+ (((uint64_t) local_port) << 32) +
+ (((uint64_t) remote_lid) << 16) + ((uint64_t) remote_port);
+ channel = cdg_search(*cdg_root, channelID);
+ if (channel) {
+ /* check whether last channel has connection to this channel, i.e. subpath already exists in cdg */
+ linklist = last_channel->linklist;
+ while (linklist && linklist->node != channel
+ && linklist->next)
+ linklist = linklist->next;
+ /* remove the srcdest from the link */
+ if (linklist) {
+ if (linklist->node == channel) {
+ linklist->removed++;
+ } else {
+ /* may happen if the link is missing (thru cycle detect algorithm) */
+ }
+ } else {
+ /* may happen if the link is missing (thru cycle detect algorithm or last_channel==channel_head (dummy channel)) */
+ }
+ } else {
+ /* must be an error, channels for the path are added before, so a missing channel would be a corrupt data structure */
+ goto ERROR;
+ }
+ last_channel = channel;
+ }
+
+ if (channel_head->linklist)
+ free(channel_head->linklist);
+ free(channel_head);
+
+ return 0;
+
+ERROR:
+ /* cleanup data and exit */
+ if (channel_head) {
+ if (channel_head->linklist)
+ free(channel_head->linklist);
+ free(channel_head);
+ }
+
+ return 1;
+}
+
+/**********************************************************************
+ **********************************************************************/
+
+/************ helper functions to generate an ordered list of ports ***
+ ************ (functions copied from osm_ucast_mgr.c and modified) ****
+ **********************************************************************/
+static void add_sw_endports_to_order_list(osm_switch_t * sw,
+ osm_ucast_mgr_t * m,
+ cl_qmap_t * guid_tbl,
+ boolean_t add_guids)
+{
+ osm_port_t *port;
+ ib_net64_t port_guid;
+ uint64_t sw_guid;
+ osm_physp_t *p;
+ int i;
+ boolean_t found;
+
+ for (i = 1; i < sw->num_ports; i++) {
+ p = osm_node_get_physp_ptr(sw->p_node, i);
+ if (p && p->p_remote_physp && !p->p_remote_physp->p_node->sw) {
+ port_guid = p->p_remote_physp->port_guid;
+ /* check if link is healthy, otherwise ignore CA */
+ if (!osm_link_is_healthy(p)) {
+ sw_guid =
+ cl_ntoh64(osm_node_get_node_guid
+ (sw->p_node));
+ OSM_LOG(m->p_log, OSM_LOG_INFO,
+ "WRN AD40: ignoring CA due to unhealthy"
+ " link from switch 0x%016" PRIx64
+ " port %" PRIu8 " to CA 0x%016" PRIx64
+ "\n", sw_guid, i, cl_ntoh64(port_guid));
+ }
+ port = osm_get_port_by_guid(m->p_subn, port_guid);
+ if (!port)
+ continue;
+ if (!cl_is_qmap_empty(guid_tbl)) {
+ found = (cl_qmap_get(guid_tbl, port_guid)
+ != cl_qmap_end(guid_tbl));
+ if ((add_guids && !found)
+ || (!add_guids && found))
+ continue;
+ }
+ if (!cl_is_item_in_qlist(&m->port_order_list,
+ &port->list_item))
+ cl_qlist_insert_tail(&m->port_order_list,
+ &port->list_item);
+ else
+ OSM_LOG(m->p_log, OSM_LOG_INFO,
+ "WRN AD37: guid 0x%016" PRIx64
+ " already in list\n", port_guid);
+ }
+ }
+}
+
+static void add_guid_to_order_list(uint64_t guid, osm_ucast_mgr_t * m)
+{
+ osm_port_t *port = osm_get_port_by_guid(m->p_subn, cl_hton64(guid));
+
+ if (!port) {
+ OSM_LOG(m->p_log, OSM_LOG_DEBUG,
+ "port guid not found: 0x%016" PRIx64 "\n", guid);
+ }
+
+ if (!cl_is_item_in_qlist(&m->port_order_list, &port->list_item))
+ cl_qlist_insert_tail(&m->port_order_list, &port->list_item);
+ else
+ OSM_LOG(m->p_log, OSM_LOG_INFO,
+ "WRN AD38: guid 0x%016" PRIx64 " already in list\n",
+ guid);
+}
+
+/* compare function of #Hca attached to a switch for stdlib qsort */
+static int cmp_num_hca(const void * l1, const void * l2)
+{
+ vertex_t *sw1 = *((vertex_t **) l1);
+ vertex_t *sw2 = *((vertex_t **) l2);
+ uint32_t num_hca1 = 0, num_hca2 = 0;
+
+ if (sw1)
+ num_hca1 = sw1->num_hca;
+ if (sw2)
+ num_hca2 = sw2->num_hca;
+
+ if (num_hca1 > num_hca2)
+ return -1;
+ else if (num_hca1 < num_hca2)
+ return 1;
+ else
+ return 0;
+}
+
+/* use stdlib to sort the switch array depending on num_hca */
+static inline void sw_list_sort_by_num_hca(vertex_t ** sw_list,
+ uint32_t sw_list_size)
+{
+ qsort(sw_list, sw_list_size, sizeof(vertex_t *), cmp_num_hca);
+}
+
+/**********************************************************************
+ **********************************************************************/
+
+/************ helper functions to manage a map of CN and I/O guids ****
+ **********************************************************************/
+static int add_guid_to_map(void * cxt, uint64_t guid, char * p)
+{
+ cl_qmap_t *map = cxt;
+ name_map_item_t *item;
+ name_map_item_t *inserted_item;
+
+ item = malloc(sizeof(*item));
+ if (!item)
+ return -1;
+
+ item->guid = cl_hton64(guid); /* internal: network byte order */
+ item->name = NULL; /* name isn't needed */
+ inserted_item = (name_map_item_t *) cl_qmap_insert(map, item->guid, &item->item);
+ if (inserted_item != item)
+ free(item);
+
+ return 0;
+}
+
+static void destroy_guid_map(cl_qmap_t * guid_tbl)
+{
+ name_map_item_t *p_guid = NULL, *p_next_guid = NULL;
+
+ p_next_guid = (name_map_item_t *) cl_qmap_head(guid_tbl);
+ while (p_next_guid != (name_map_item_t *) cl_qmap_end(guid_tbl)) {
+ p_guid = p_next_guid;
+ p_next_guid = (name_map_item_t *) cl_qmap_next(&p_guid->item);
+ free(p_guid);
+ }
+ cl_qmap_remove_all(guid_tbl);
+}
+
+/**********************************************************************
+ **********************************************************************/
+
+static void dfsssp_print_graph(osm_ucast_mgr_t * p_mgr, vertex_t * adj_list,
+ uint32_t size)
+{
+ uint32_t i = 0, c = 0;
+ link_t *link = NULL;
+
+ /* index 0 is for the source in dijkstra -> ignore */
+ for (i = 1; i < size; i++) {
+ OSM_LOG(p_mgr->p_log, OSM_LOG_DEBUG, "adj_list[%" PRIu32 "]:\n",
+ i);
+ OSM_LOG(p_mgr->p_log, OSM_LOG_DEBUG,
+ " guid = 0x%" PRIx64 " lid = %" PRIu16 " (%s)\n",
+ adj_list[i].guid, adj_list[i].lid,
+ adj_list[i].sw->p_node->print_desc);
+ OSM_LOG(p_mgr->p_log, OSM_LOG_DEBUG,
+ " num_hca = %" PRIu32 "\n", adj_list[i].num_hca);
+
+ c = 1;
+ for (link = adj_list[i].links; link != NULL;
+ link = link->next, c++) {
+ OSM_LOG(p_mgr->p_log, OSM_LOG_DEBUG,
+ " link[%" PRIu32 "]:\n", c);
+ OSM_LOG(p_mgr->p_log, OSM_LOG_DEBUG,
+ " to guid = 0x%" PRIx64 " (%s) port %"
+ PRIu8 "\n", link->guid,
+ adj_list[link->to].sw->p_node->print_desc,
+ link->to_port);
+ OSM_LOG(p_mgr->p_log, OSM_LOG_DEBUG,
+ " weight on this link = %" PRIu64 "\n",
+ link->weight);
+ }
+ }
+}
+
+/* predefine, to use this in next function */
+static void dfsssp_context_destroy(void *context);
+static int dijkstra(osm_ucast_mgr_t * p_mgr, vertex_t * adj_list,
+ uint32_t adj_list_size, osm_port_t * port, uint16_t lid);
+
+/* traverse subnet to gather information about the connected switches */
+static int dfsssp_build_graph(void *context)
+{
+ dfsssp_context_t *dfsssp_ctx = (dfsssp_context_t *) context;
+ osm_ucast_mgr_t *p_mgr = (osm_ucast_mgr_t *) (dfsssp_ctx->p_mgr);
+
+ cl_qmap_t *port_tbl = &p_mgr->p_subn->port_guid_tbl; /* 1 management port per switch + 1 or 2 ports for each Hca */
+ osm_port_t *p_port = NULL;
+ cl_qmap_t *sw_tbl = &p_mgr->p_subn->sw_guid_tbl;
+ cl_map_item_t *item = NULL;
+ osm_switch_t *sw = NULL;
+ osm_node_t *remote_node = NULL;
+ uint8_t port = 0, remote_port = 0;
+ uint32_t i = 0, j = 0, err = 0, undiscov = 0, max_num_undiscov = 0;
+ uint64_t total_num_hca = 0;
+ vertex_t *adj_list = NULL;
+ osm_physp_t *p_physp = NULL;
+ link_t *link = NULL, *head = NULL;
+ uint32_t num_sw = 0, adj_list_size = 0;
+ uint8_t lmc = 0;
+ uint16_t sm_lid = 0;
+
+ OSM_LOG_ENTER(p_mgr->p_log);
+ OSM_LOG(p_mgr->p_log, OSM_LOG_VERBOSE,
+ "Building graph for df-/sssp routing\n");
+
+ /* if this pointer isn't NULL, this is a reroute step;
+ old context will be destroyed (adj_list and srcdest2vl_table)
+ */
+ if (dfsssp_ctx->adj_list)
+ dfsssp_context_destroy(context);
+
+ num_sw = cl_qmap_count(sw_tbl);
+ adj_list_size = num_sw + 1;
+ /* allocate an adjazenz list (array), 0. element is reserved for the source (Hca) in the routing algo, others are switches */
+ adj_list = (vertex_t *) malloc(adj_list_size * sizeof(vertex_t));
+ if (!adj_list) {
+ OSM_LOG(p_mgr->p_log, OSM_LOG_ERROR,
+ "ERR AD02: cannot allocate memory for adj_list\n");
+ goto ERROR;
+ }
+ for (i = 0; i < adj_list_size; i++)
+ set_default_vertex(&adj_list[i]);
+
+ dfsssp_ctx->adj_list = adj_list;
+ dfsssp_ctx->adj_list_size = adj_list_size;
+
+ /* count the total number of Hca / LIDs (for lmc>0) in the fabric;
+ even include base/enhanced switch port 0; base SP0 will have lmc=0
+ */
+ for (item = cl_qmap_head(port_tbl); item != cl_qmap_end(port_tbl);
+ item = cl_qmap_next(item)) {
+ p_port = (osm_port_t *) item;
+ if (osm_node_get_type(p_port->p_node) == IB_NODE_TYPE_CA ||
+ osm_node_get_type(p_port->p_node) == IB_NODE_TYPE_SWITCH) {
+ lmc = osm_port_get_lmc(p_port);
+ total_num_hca += (1 << lmc);
+ }
+ }
+
+ i = 1; /* fill adj_list -> start with index 1 */
+ for (item = cl_qmap_head(sw_tbl); item != cl_qmap_end(sw_tbl);
+ item = cl_qmap_next(item), i++) {
+ sw = (osm_switch_t *) item;
+ OSM_LOG(p_mgr->p_log, OSM_LOG_DEBUG,
+ "Processing switch with GUID 0x%" PRIx64 "\n",
+ cl_ntoh64(osm_node_get_node_guid(sw->p_node)));
+
+ adj_list[i].guid =
+ cl_ntoh64(osm_node_get_node_guid(sw->p_node));
+ adj_list[i].lid =
+ cl_ntoh16(osm_node_get_base_lid(sw->p_node, 0));
+ adj_list[i].sw = sw;
+
+ link = (link_t *) malloc(sizeof(link_t));
+ if (!link) {
+ OSM_LOG(p_mgr->p_log, OSM_LOG_ERROR,
+ "ERR AD03: cannot allocate memory for a link\n");
+ goto ERROR;
+ }
+ head = link;
+ head->next = NULL;
+
+ /* add SP0 to number of CA connected to a switch */
+ lmc = osm_node_get_lmc(sw->p_node, 0);
+ adj_list[i].num_hca += (1 << lmc);
+
+ /* iterate over all ports in the switch, start with port 1 (port 0 is a management port) */
+ for (port = 1; port < sw->num_ports; port++) {
+ /* get the node behind the port */
+ remote_node =
+ osm_node_get_remote_node(sw->p_node, port,
+ &remote_port);
+ /* if there is no remote node on this port or it's the same switch -> try next port */
+ if (!remote_node || remote_node->sw == sw)
+ continue;
+ /* make sure the link is healthy */
+ p_physp = osm_node_get_physp_ptr(sw->p_node, port);
+ if (!p_physp || !osm_link_is_healthy(p_physp))
+ continue;
+ /* if there is a Hca connected -> count and cycle */
+ if (!remote_node->sw) {
+ lmc = osm_node_get_lmc(remote_node, (uint32_t)remote_port);
+ adj_list[i].num_hca += (1 << lmc);
+ continue;
+ }
+ OSM_LOG(p_mgr->p_log, OSM_LOG_DEBUG,
+ "Node 0x%" PRIx64 ", remote node 0x%" PRIx64
+ ", port %" PRIu8 ", remote port %" PRIu8 "\n",
+ cl_ntoh64(osm_node_get_node_guid(sw->p_node)),
+ cl_ntoh64(osm_node_get_node_guid(remote_node)),
+ port, remote_port);
+
+ link->next = (link_t *) malloc(sizeof(link_t));
+ if (!link->next) {
+ OSM_LOG(p_mgr->p_log, OSM_LOG_ERROR,
+ "ERR AD08: cannot allocate memory for a link\n");
+ while (head) {
+ link = head;
+ head = head->next;
+ free(link);
+ }
+ goto ERROR;
+ }
+ link = link->next;
+ set_default_link(link);
+ link->guid =
+ cl_ntoh64(osm_node_get_node_guid(remote_node));
+ link->from = i;
+ link->from_port = port;
+ link->to_port = remote_port;
+ link->weight = total_num_hca * total_num_hca; /* initialize with P^2 to force shortest paths */
+ }
+
+ adj_list[i].links = head->next;
+ free(head);
+ }
+ /* connect the links with it's second adjacent node in the list */
+ for (i = 1; i < adj_list_size; i++) {
+ link = adj_list[i].links;
+ while (link) {
+ for (j = 1; j < adj_list_size; j++) {
+ if (link->guid == adj_list[j].guid) {
+ link->to = j;
+ break;
+ }
+ }
+ link = link->next;
+ }
+ }
+ /* do one dry run to determine connectivity issues */
+ sm_lid = p_mgr->p_subn->master_sm_base_lid;
+ p_port = osm_get_port_by_lid(p_mgr->p_subn, sm_lid);
+ err = dijkstra(p_mgr, adj_list, adj_list_size, p_port, sm_lid);
+ if (err) {
+ goto ERROR;
+ } else {
+ /* if sm is running on a switch, then dijkstra doesn't
+ initialize the used_link for this switch
+ */
+ if (osm_node_get_type(p_port->p_node) != IB_NODE_TYPE_CA)
+ max_num_undiscov = 1;
+ for (i = 1; i < adj_list_size; i++)
+ undiscov += (adj_list[i].used_link) ? 0 : 1;
+ if (max_num_undiscov < undiscov) {
+ OSM_LOG(p_mgr->p_log, OSM_LOG_ERROR,
+ "ERR AD0C: unsupported network state (detached"
+ " and inaccessible switches found; gracefully"
+ " shutdown this routing engine)\n");
+ goto ERROR;
+ }
+ }
+ /* print the discovered graph */
+ if (OSM_LOG_IS_ACTIVE_V2(p_mgr->p_log, OSM_LOG_DEBUG))
+ dfsssp_print_graph(p_mgr, adj_list, adj_list_size);
+
+ OSM_LOG_EXIT(p_mgr->p_log);
+ return 0;
+
+ERROR:
+ dfsssp_context_destroy(context);
+ return -1;
+}
+
+static void print_routes(osm_ucast_mgr_t * p_mgr, vertex_t * adj_list,
+ uint32_t adj_list_size, osm_port_t * port)
+{
+ uint32_t i = 0, j = 0;
+
+ for (i = 1; i < adj_list_size; i++) {
+ if (adj_list[i].state == DISCOVERED) {
+ OSM_LOG(p_mgr->p_log, OSM_LOG_DEBUG,
+ "Route from 0x%" PRIx64 " (%s) to 0x%" PRIx64
+ " (%s):\n", adj_list[i].guid,
+ adj_list[i].sw->p_node->print_desc,
+ cl_ntoh64(osm_node_get_node_guid(port->p_node)),
+ port->p_node->print_desc);
+ j = i;
+ while (adj_list[j].used_link) {
+ if (j > 0) {
+ OSM_LOG(p_mgr->p_log, OSM_LOG_DEBUG,
+ " 0x%" PRIx64
+ " (%s) routes thru port %" PRIu8
+ "\n", adj_list[j].guid,
+ adj_list[j].sw->p_node->
+ print_desc,
+ adj_list[j].used_link->to_port);
+ } else {
+ OSM_LOG(p_mgr->p_log, OSM_LOG_DEBUG,
+ " 0x%" PRIx64
+ " (%s) routes thru port %" PRIu8
+ "\n", adj_list[j].guid,
+ port->p_node->print_desc,
+ adj_list[j].used_link->to_port);
+ }
+ j = adj_list[j].used_link->from;
+ }
+ }
+ }
+}
+
+/* dijkstra step from one source to all switches in the df-/sssp graph */
+static int dijkstra(osm_ucast_mgr_t * p_mgr, vertex_t * adj_list,
+ uint32_t adj_list_size, osm_port_t * port, uint16_t lid)
+{
+ uint32_t i = 0, j = 0, index = 0;
+ osm_node_t *remote_node = NULL;
+ uint8_t remote_port = 0;
+ vertex_t *current = NULL;
+ link_t *link = NULL;
+ uint64_t guid = 0;
+ binary_heap_t *heap = NULL;
+ int err = 0;
+
+ OSM_LOG_ENTER(p_mgr->p_log);
+
+ /* reset all switches for new round with a new source for dijkstra */
+ for (i = 1; i < adj_list_size; i++) {
+ adj_list[i].hops = 0;
+ adj_list[i].used_link = NULL;
+ adj_list[i].distance = INF;
+ adj_list[i].state = UNDISCOVERED;
+ }
+
+ /* if behind port is a Hca -> set adj_list[0] */
+ if (osm_node_get_type(port->p_node) == IB_NODE_TYPE_CA) {
+ /* save old link to prevent many mallocs after set_default_... */
+ link = adj_list[0].links;
+ /* initialize adj_list[0] (the source for the routing, a Hca) */
+ set_default_vertex(&adj_list[0]);
+ adj_list[0].guid =
+ cl_ntoh64(osm_node_get_node_guid(port->p_node));
+ adj_list[0].lid = lid;
+ index = 0;
+ /* write saved link back to new adj_list[0] */
+ adj_list[0].links = link;
+
+ /* initialize link to neighbor for adj_list[0];
+ make sure the link is healthy
+ */
+ if (port->p_physp && osm_link_is_healthy(port->p_physp)) {
+ remote_node =
+ osm_node_get_remote_node(port->p_node,
+ port->p_physp->port_num,
+ &remote_port);
+ /* if there is no remote node on this port or it's the same Hca -> ignore */
+ if (remote_node
+ && (osm_node_get_type(remote_node) ==
+ IB_NODE_TYPE_SWITCH)) {
+ if (!(adj_list[0].links)) {
+ adj_list[0].links =
+ (link_t *) malloc(sizeof(link_t));
+ if (!(adj_list[0].links)) {
+ OSM_LOG(p_mgr->p_log,
+ OSM_LOG_ERROR,
+ "ERR AD07: cannot allocate memory for a link\n");
+ return 1;
+ }
+ }
+ set_default_link(adj_list[0].links);
+ adj_list[0].links->guid =
+ cl_ntoh64(osm_node_get_node_guid
+ (remote_node));
+ adj_list[0].links->from_port =
+ port->p_physp->port_num;
+ adj_list[0].links->to_port = remote_port;
+ adj_list[0].links->weight = 1;
+ for (j = 1; j < adj_list_size; j++) {
+ if (adj_list[0].links->guid ==
+ adj_list[j].guid) {
+ adj_list[0].links->to = j;
+ break;
+ }
+ }
+ }
+ } else {
+ /* if link is unhealthy then there's a severe issue */
+ OSM_LOG(p_mgr->p_log, OSM_LOG_ERROR,
+ "ERR AD0B: unsupported network state (CA with"
+ " unhealthy link state discovered; should have"
+ " been filtered out before already; gracefully"
+ " shutdown this routing engine)\n");
+ return 1;
+ }
+ /* if behind port is a switch -> search switch in adj_list */
+ } else {
+ /* reset adj_list[0], if links=NULL reset was done before, then skip */
+ if (adj_list[0].links) {
+ free(adj_list[0].links);
+ set_default_vertex(&adj_list[0]);
+ }
+ /* search for the switch which is the source in this round */
+ guid = cl_ntoh64(osm_node_get_node_guid(port->p_node));
+ for (i = 1; i < adj_list_size; i++) {
+ if (guid == adj_list[i].guid) {
+ index = i;
+ break;
+ }
+ }
+ }
+
+ /* source in dijkstra */
+ adj_list[index].distance = 0;
+ adj_list[index].state = DISCOVERED;
+ adj_list[index].hops = 0; /* the source has hop count = 0 */
+
+ /* create a heap to find (efficient) the node with the smallest distance */
+ if (osm_node_get_type(port->p_node) == IB_NODE_TYPE_CA)
+ err = heap_create(adj_list, adj_list_size, &heap);
+ else
+ err = heap_create(&adj_list[1], adj_list_size - 1, &heap);
+ if (err) {
+ OSM_LOG(p_mgr->p_log, OSM_LOG_ERROR,
+ "ERR AD09: cannot allocate memory for heap or heap->node in heap_create(...)\n");
+ return err;
+ }
+
+ current = heap_getmin(heap);
+ while (current) {
+ current->state = DISCOVERED;
+ if (current->used_link) /* increment the number of hops to the source for each new node */
+ current->hops =
+ adj_list[current->used_link->from].hops + 1;
+
+ /* add/update nodes which aren't discovered but accessible */
+ for (link = current->links; link != NULL; link = link->next) {
+ if ((adj_list[link->to].state != DISCOVERED)
+ && (current->distance + link->weight <
+ adj_list[link->to].distance)) {
+ adj_list[link->to].used_link = link;
+ adj_list[link->to].distance =
+ current->distance + link->weight;
+ heap_heapify(heap, adj_list[link->to].heap_id);
+ }
+ }
+
+ current = heap_getmin(heap);
+ }
+
+ /* destroy the heap */
+ heap_free(heap);
+ heap = NULL;
+
+ OSM_LOG_EXIT(p_mgr->p_log);
+ return 0;
+}
+
+/* update the linear forwarding tables of all switches with the informations
+ from the last dijsktra step
+*/
+static int update_lft(osm_ucast_mgr_t * p_mgr, vertex_t * adj_list,
+ uint32_t adj_list_size, osm_port_t * p_port, uint16_t lid)
+{
+ uint32_t i = 0;
+ uint8_t port = 0;
+ uint8_t hops = 0;
+ osm_switch_t *p_sw = NULL;
+ boolean_t is_ignored_by_port_prof = FALSE;
+ osm_physp_t *p = NULL;
+ cl_status_t ret;
+
+ OSM_LOG_ENTER(p_mgr->p_log);
+
+ for (i = 1; i < adj_list_size; i++) {
+ /* if no route goes thru this switch -> cycle */
+ if (!(adj_list[i].used_link))
+ continue;
+
+ p_sw = adj_list[i].sw;
+ hops = adj_list[i].hops;
+ port = adj_list[i].used_link->to_port;
+ /* the used_link is the link that was used in dijkstra to reach this node,
+ so the to_port is the local port on this node
+ */
+
+ if (port == OSM_NO_PATH) { /* if clause shouldn't be possible in this routing, but who cares */
+ OSM_LOG(p_mgr->p_log, OSM_LOG_ERROR,
+ "ERR AD06: No path to get to LID %" PRIu16
+ " from switch 0x%" PRIx64 "\n", lid,
+ cl_ntoh64(osm_node_get_node_guid
+ (p_sw->p_node)));
+
+ /* do not try to overwrite the ppro of non existing port ... */
+ is_ignored_by_port_prof = TRUE;
+ return 1;
+ } else {
+ OSM_LOG(p_mgr->p_log, OSM_LOG_DEBUG,
+ "Routing LID %" PRIu16 " to port %" PRIu8
+ " for switch 0x%" PRIx64 "\n", lid, port,
+ cl_ntoh64(osm_node_get_node_guid
+ (p_sw->p_node)));
+
+ p = osm_node_get_physp_ptr(p_sw->p_node, port);
+ if (!p) {
+ OSM_LOG(p_mgr->p_log, OSM_LOG_ERROR,
+ "ERR AD0A: Physical port %d of Node GUID 0x%"
+ PRIx64 "not found\n", port,
+ cl_ntoh64(osm_node_get_node_guid(p_sw->p_node)));
+ return 1;
+ }
+
+ /* we would like to optionally ignore this port in equalization
+ as in the case of the Mellanox Anafa Internal PCI TCA port
+ */
+ is_ignored_by_port_prof = p->is_prof_ignored;
+
+ /* We also would ignore this route if the target lid is of
+ a switch and the port_profile_switch_node is not TRUE
+ */
+ if (!p_mgr->p_subn->opt.port_profile_switch_nodes)
+ is_ignored_by_port_prof |=
+ (osm_node_get_type(p_port->p_node) ==
+ IB_NODE_TYPE_SWITCH);
+ }
+
+ /* to support lmc > 0 the functions alloc_ports_priv, free_ports_priv, find_and_add_remote_sys
+ from minhop aren't needed cause osm_switch_recommend_path is implicitly calculated
+ for each LID pair thru dijkstra;
+ for each port the dijkstra algorithm calculates (max_lid_ho - min_lid_ho)-times maybe
+ disjoint routes to spread the bandwidth -> diffent routes for one port and lmc>0
+ */
+
+ /* set port in LFT */
+ p_sw->new_lft[lid] = port;
+ if (!is_ignored_by_port_prof) {
+ /* update the number of path routing thru this port */
+ osm_switch_count_path(p_sw, port);
+ }
+ /* set the hop count from this switch to the lid */
+ ret = osm_switch_set_hops(p_sw, lid, port, hops);
+ if (ret != CL_SUCCESS)
+ OSM_LOG(p_mgr->p_log, OSM_LOG_ERROR,
+ "ERR AD05: cannot set hops for LID %" PRIu16
+ " at switch 0x%" PRIx64 "\n", lid,
+ cl_ntoh64(osm_node_get_node_guid
+ (p_sw->p_node)));
+ }
+
+ OSM_LOG_EXIT(p_mgr->p_log);
+ return 0;
+}
+
+/* the function updates the multicast group membership information
+ similar to create_mgrp_switch_map (osm_mcast_mgr.c)
+ => with it we can identify if a switch needs to be processed
+ or not in update_mcft
+*/
+static void update_mgrp_membership(cl_qlist_t * port_list)
+{
+ osm_mcast_work_obj_t *wobj = NULL;
+ osm_port_t *port = NULL;
+ osm_switch_t *sw = NULL;
+ cl_list_item_t *i = NULL;
+
+ for (i = cl_qlist_head(port_list); i != cl_qlist_end(port_list);
+ i = cl_qlist_next(i)) {
+ wobj = cl_item_obj(i, wobj, list_item);
+ port = wobj->p_port;
+ if (port->p_node->sw) {
+ sw = port->p_node->sw;
+ sw->is_mc_member = 1;
+ } else {
+ sw = port->p_physp->p_remote_physp->p_node->sw;
+ sw->num_of_mcm++;
+ }
+ }
+}
+
+/* reset is_mc_member and num_of_mcm for future computations */
+static void reset_mgrp_membership(vertex_t * adj_list, uint32_t adj_list_size)
+{
+ uint32_t i = 0;
+
+ for (i = 1; i < adj_list_size; i++) {
+ if (adj_list[i].dropped)
+ continue;
+
+ adj_list[i].sw->is_mc_member = 0;
+ adj_list[i].sw->num_of_mcm = 0;
+ }
+}
+
+/* update the multicast forwarding tables of all switches with the informations
+ from the previous dijsktra step for the current mlid
+*/
+static int update_mcft(osm_sm_t * p_sm, vertex_t * adj_list,
+ uint32_t adj_list_size, uint16_t mlid_ho,
+ cl_qmap_t * port_map, osm_switch_t * root_sw)
+{
+ uint32_t i = 0;
+ uint8_t port = 0, remote_port = 0;
+ uint8_t upstream_port = 0, downstream_port = 0;
+ ib_net64_t guid = 0;
+ osm_switch_t *p_sw = NULL;
+ osm_node_t *remote_node = NULL;
+ osm_physp_t *p_physp = NULL;
+ osm_mcast_tbl_t *p_tbl = NULL;
+ vertex_t *curr_adj = NULL;
+
+ OSM_LOG_ENTER(p_sm->p_log);
+
+ for (i = 1; i < adj_list_size; i++) {
+ if (adj_list[i].dropped)
+ continue;
+
+ p_sw = adj_list[i].sw;
+ OSM_LOG(p_sm->p_log, OSM_LOG_VERBOSE,
+ "Processing switch 0x%016" PRIx64
+ " (%s) for MLID 0x%X\n", cl_ntoh64(adj_list[i].guid),
+ p_sw->p_node->print_desc, mlid_ho);
+
+ /* if a) the switch does not support mcast or
+ b) no ports of this switch are part or the mcast group
+ then cycle
+ */
+ if (osm_switch_supports_mcast(p_sw) == FALSE ||
+ (p_sw->num_of_mcm == 0 && !(p_sw->is_mc_member)))
+ continue;
+
+ p_tbl = osm_switch_get_mcast_tbl_ptr(p_sw);
+
+ /* add all ports of this sw to the mcast table,
+ if they are part of the mcast grp
+ */
+ if (p_sw->is_mc_member)
+ osm_mcast_tbl_set(p_tbl, mlid_ho, 0);
+ for (port = 1; port < p_sw->num_ports; port++) {
+ /* get the node behind the port */
+ remote_node =
+ osm_node_get_remote_node(p_sw->p_node, port,
+ &remote_port);
+ /* check if connected and its not the same switch */
+ if (!remote_node || remote_node->sw == p_sw)
+ continue;
+ /* make sure the link is healthy */
+ p_physp = osm_node_get_physp_ptr(p_sw->p_node, port);
+ if (!p_physp || !osm_link_is_healthy(p_physp))
+ continue;
+ /* we don't add upstream ports in this step */
+ if (osm_node_get_type(remote_node) != IB_NODE_TYPE_CA)
+ continue;
+
+ guid = osm_physp_get_port_guid(osm_node_get_physp_ptr(
+ remote_node,
+ remote_port));
+ if (cl_qmap_get(port_map, guid)
+ != cl_qmap_end(port_map))
+ osm_mcast_tbl_set(p_tbl, mlid_ho, port);
+ }
+
+ /* now we have to add the upstream port of 'this' switch and
+ the downstream port of the next switch to the mcast table
+ until we reach the root_sw
+ */
+ curr_adj = &adj_list[i];
+ while (curr_adj->sw != root_sw) {
+ /* the used_link is the link that was used in dijkstra to reach this node,
+ so the to_port is the local (upstream) port on curr_adj->sw
+ */
+ upstream_port = curr_adj->used_link->to_port;
+ osm_mcast_tbl_set(p_tbl, mlid_ho, upstream_port);
+
+ /* now we go one step in direction root_sw and add the
+ downstream port for the spanning tree
+ */
+ downstream_port = curr_adj->used_link->from_port;
+ p_tbl = osm_switch_get_mcast_tbl_ptr(
+ adj_list[curr_adj->used_link->from].sw);
+ osm_mcast_tbl_set(p_tbl, mlid_ho, downstream_port);
+
+ curr_adj = &adj_list[curr_adj->used_link->from];
+ }
+ }
+
+ OSM_LOG_EXIT(p_sm->p_log);
+ return 0;
+}
+
+/* increment the edge weights of the df-/sssp graph which represent the number
+ of paths on this link
+*/
+static void update_weights(osm_ucast_mgr_t * p_mgr, vertex_t * adj_list,
+ uint32_t adj_list_size)
+{
+ uint32_t i = 0, j = 0;
+ uint32_t additional_weight = 0;
+
+ OSM_LOG_ENTER(p_mgr->p_log);
+
+ for (i = 1; i < adj_list_size; i++) {
+ /* if no route goes thru this switch -> cycle */
+ if (!(adj_list[i].used_link))
+ continue;
+ additional_weight = adj_list[i].num_hca;
+
+ j = i;
+ while (adj_list[j].used_link) {
+ /* update the link from pre to this node */
+ adj_list[j].used_link->weight += additional_weight;
+
+ j = adj_list[j].used_link->from;
+ }
+ }
+
+ OSM_LOG_EXIT(p_mgr->p_log);
+}
+
+/* get the largest number of virtual lanes which is supported by all switches
+ in the subnet
+*/
+static uint8_t get_avail_vl_in_subn(osm_ucast_mgr_t * p_mgr)
+{
+ uint32_t i = 0;
+ uint8_t vls_avail = 0xFF, port_vls_avail = 0;
+ cl_qmap_t *sw_tbl = &p_mgr->p_subn->sw_guid_tbl;
+ cl_map_item_t *item = NULL;
+ osm_switch_t *sw = NULL;
+
+ /* traverse all switches to get the number of available virtual lanes in the subnet */
+ for (item = cl_qmap_head(sw_tbl); item != cl_qmap_end(sw_tbl);
+ item = cl_qmap_next(item)) {
+ sw = (osm_switch_t *) item;
+
+ /* ignore management port 0 */
+ for (i = 1; i < osm_node_get_num_physp(sw->p_node); i++) {
+ osm_physp_t *p_physp =
+ osm_node_get_physp_ptr(sw->p_node, i);
+
+ if (p_physp && p_physp->p_remote_physp) {
+ port_vls_avail =
+ ib_port_info_get_op_vls(&p_physp->
+ port_info);
+ if (port_vls_avail
+ && port_vls_avail < vls_avail)
+ vls_avail = port_vls_avail;
+ }
+ }
+ }
+
+ /* ib_port_info_get_op_vls gives values 1 ... 5 (s. IBAS 14.2.5.6) */
+ vls_avail = 1 << (vls_avail - 1);
+
+ /* set boundaries (s. IBAS 3.5.7) */
+ if (vls_avail > 15)
+ vls_avail = 15;
+ if (vls_avail < 1)
+ vls_avail = 1;
+
+ return vls_avail;
+}
+
+/* search for cycles in the channel dependency graph to identify possible
+ deadlocks in the network;
+ assign new virtual lanes to some paths to break the deadlocks
+*/
+static int dfsssp_remove_deadlocks(dfsssp_context_t * dfsssp_ctx)
+{
+ osm_ucast_mgr_t *p_mgr = (osm_ucast_mgr_t *) dfsssp_ctx->p_mgr;
+
+ cl_qlist_t *port_tbl = &p_mgr->port_order_list; /* 1 management port per switch + 1 or 2 ports for each Hca */
+ cl_list_item_t *item1 = NULL, *item2 = NULL;
+ osm_port_t *src_port = NULL, *dest_port = NULL;
+
+ uint32_t i = 0, j = 0, err = 0;
+ uint8_t vl = 0, test_vl = 0, vl_avail = 0, vl_needed = 1;
+ double most_avg_paths = 0.0;
+ cdg_node_t **cdg = NULL, *start_here = NULL, *cycle = NULL;
+ cdg_link_t *weakest_link = NULL;
+ uint32_t srcdest = 0;
+
+ vltable_t *srcdest2vl_table = NULL;
+ uint8_t lmc = 0;
+ uint16_t slid = 0, dlid = 0, min_lid_ho = 0, max_lid_ho =
+ 0, min_lid_ho2 = 0, max_lid_ho2 = 0;;
+ uint64_t *paths_per_vl = NULL;
+ uint64_t from = 0, to = 0, count = 0;
+ uint8_t *split_count = NULL;
+ uint8_t ntype = 0;
+
+ OSM_LOG_ENTER(p_mgr->p_log);
+ OSM_LOG(p_mgr->p_log, OSM_LOG_VERBOSE,
+ "Assign each src/dest pair a Virtual Lanes, to remove deadlocks in the routing\n");
+
+ vl_avail = get_avail_vl_in_subn(p_mgr);
+ OSM_LOG(p_mgr->p_log, OSM_LOG_INFO,
+ "Virtual Lanes available: %" PRIu8 "\n", vl_avail);
+
+ paths_per_vl = (uint64_t *) malloc(vl_avail * sizeof(uint64_t));
+ if (!paths_per_vl) {
+ OSM_LOG(p_mgr->p_log, OSM_LOG_ERROR,
+ "ERR AD22: cannot allocate memory for paths_per_vl\n");
+ return 1;
+ }
+ memset(paths_per_vl, 0, vl_avail * sizeof(uint64_t));
+
+ cdg = (cdg_node_t **) malloc(vl_avail * sizeof(cdg_node_t *));
+ if (!cdg) {
+ OSM_LOG(p_mgr->p_log, OSM_LOG_ERROR,
+ "ERR AD23: cannot allocate memory for cdg\n");
+ free(paths_per_vl);
+ return 1;
+ }
+ for (i = 0; i < vl_avail; i++)
+ cdg[i] = NULL;
+
+ count = 0;
+ /* count all ports (also multiple LIDs) of type CA or SP0 for size of VL table */
+ for (item1 = cl_qlist_head(port_tbl); item1 != cl_qlist_end(port_tbl);
+ item1 = cl_qlist_next(item1)) {
+ dest_port = (osm_port_t *)cl_item_obj(item1, dest_port,
+ list_item);
+ ntype = osm_node_get_type(dest_port->p_node);
+ if (ntype == IB_NODE_TYPE_CA || ntype == IB_NODE_TYPE_SWITCH) {
+ /* only SP0 with SLtoVLMapping support will be processed */
+ if (ntype == IB_NODE_TYPE_SWITCH
+ && !(dest_port->p_physp->port_info.capability_mask
+ & IB_PORT_CAP_HAS_SL_MAP))
+ continue;
+
+ lmc = osm_port_get_lmc(dest_port);
+ count += (1 << lmc);
+ }
+ }
+ /* allocate VL table and indexing array */
+ err = vltable_alloc(&srcdest2vl_table, count);
+ if (err) {
+ OSM_LOG(p_mgr->p_log, OSM_LOG_ERROR,
+ "ERR AD26: cannot allocate memory for srcdest2vl_table\n");
+ goto ERROR;
+ }
+
+ i = 0;
+ /* fill lids into indexing array */
+ for (item1 = cl_qlist_head(port_tbl); item1 != cl_qlist_end(port_tbl);
+ item1 = cl_qlist_next(item1)) {
+ dest_port = (osm_port_t *)cl_item_obj(item1, dest_port,
+ list_item);
+ ntype = osm_node_get_type(dest_port->p_node);
+ if (ntype == IB_NODE_TYPE_CA || ntype == IB_NODE_TYPE_SWITCH) {
+ /* only SP0 with SLtoVLMapping support will be processed */
+ if (ntype == IB_NODE_TYPE_SWITCH
+ && !(dest_port->p_physp->port_info.capability_mask
+ & IB_PORT_CAP_HAS_SL_MAP))
+ continue;
+
+ osm_port_get_lid_range_ho(dest_port, &min_lid_ho,
+ &max_lid_ho);
+ for (dlid = min_lid_ho; dlid <= max_lid_ho; dlid++, i++)
+ srcdest2vl_table->lids[i] = cl_hton16(dlid);
+ }
+ }
+ /* sort lids */
+ vltable_sort_lids(srcdest2vl_table);
+
+ test_vl = 0;
+ /* fill cdg[0] with routes from each src/dest port combination for all Hca/SP0 in the subnet */
+ for (item1 = cl_qlist_head(port_tbl); item1 != cl_qlist_end(port_tbl);
+ item1 = cl_qlist_next(item1)) {
+ dest_port = (osm_port_t *)cl_item_obj(item1, dest_port,
+ list_item);
+ ntype = osm_node_get_type(dest_port->p_node);
+ if ((ntype != IB_NODE_TYPE_CA && ntype != IB_NODE_TYPE_SWITCH)
+ || !(dest_port->p_physp->port_info.capability_mask
+ & IB_PORT_CAP_HAS_SL_MAP))
+ continue;
+
+ for (item2 = cl_qlist_head(port_tbl);
+ item2 != cl_qlist_end(port_tbl);
+ item2 = cl_qlist_next(item2)) {
+ src_port = (osm_port_t *)cl_item_obj(item2, src_port,
+ list_item);
+ ntype = osm_node_get_type(src_port->p_node);
+ if ((ntype != IB_NODE_TYPE_CA
+ && ntype != IB_NODE_TYPE_SWITCH)
+ || !(src_port->p_physp->port_info.capability_mask
+ & IB_PORT_CAP_HAS_SL_MAP))
+ continue;
+
+ if (src_port != dest_port) {
+ /* iterate over LIDs of src and dest port */
+ osm_port_get_lid_range_ho(src_port, &min_lid_ho,
+ &max_lid_ho);
+ for (slid = min_lid_ho; slid <= max_lid_ho;
+ slid++) {
+ osm_port_get_lid_range_ho
+ (dest_port, &min_lid_ho2,
+ &max_lid_ho2);
+ for (dlid = min_lid_ho2;
+ dlid <= max_lid_ho2;
+ dlid++) {
+
+ /* try to add the path to cdg[0] */
+ err =
+ update_channel_dep_graph
+ (&(cdg[test_vl]),
+ src_port, slid,
+ dest_port, dlid);
+ if (err) {
+ OSM_LOG(p_mgr->
+ p_log,
+ OSM_LOG_ERROR,
+ "ERR AD14: cannot allocate memory for cdg node or link in update_channel_dep_graph(...)\n");
+ goto ERROR;
+ }
+ /* add the <s,d> combination / corresponding virtual lane to the VL table */
+ vltable_insert
+ (srcdest2vl_table,
+ cl_hton16(slid),
+ cl_hton16(dlid),
+ test_vl);
+ paths_per_vl[test_vl]++;
+
+ }
+
+ }
+ }
+
+ }
+ }
+ dfsssp_ctx->srcdest2vl_table = srcdest2vl_table;
+
+ /* test all cdg for cycles and break the cycles by moving paths on the weakest link to the next cdg */
+ for (test_vl = 0; test_vl < vl_avail - 1; test_vl++) {
+ start_here = cdg[test_vl];
+ while (start_here) {
+ cycle =
+ search_cycle_in_channel_dep_graph(cdg[test_vl],
+ start_here);
+
+ if (cycle) {
+ vl_needed = test_vl + 2;
+
+ /* calc weakest link n cycle */
+ weakest_link = get_weakest_link_in_cycle(cycle);
+ if (!weakest_link) {
+ OSM_LOG(p_mgr->p_log, OSM_LOG_ERROR,
+ "ERR AD27: something went wrong in get_weakest_link_in_cycle(...)\n");
+ err = 1;
+ goto ERROR;
+ }
+
+ paths_per_vl[test_vl] -=
+ weakest_link->num_pairs;
+ paths_per_vl[test_vl + 1] +=
+ weakest_link->num_pairs;
+
+ /* move all <s,d> paths on this link to the next cdg */
+ for (i = 0; i < weakest_link->num_pairs; i++) {
+ srcdest =
+ get_next_srcdest_pair(weakest_link,
+ i);
+ slid = (uint16_t) (srcdest >> 16);
+ dlid =
+ (uint16_t) ((srcdest << 16) >> 16);
+
+ /* only move if not moved in a previous step */
+ if (test_vl !=
+ (uint8_t)
+ vltable_get_vl(srcdest2vl_table,
+ cl_hton16(slid),
+ cl_hton16(dlid))) {
+ /* this path has been moved
+ before -> don't count
+ */
+ paths_per_vl[test_vl]++;
+ paths_per_vl[test_vl + 1]--;
+ continue;
+ }
+
+ src_port =
+ osm_get_port_by_lid(p_mgr->p_subn,
+ cl_hton16
+ (slid));
+ dest_port =
+ osm_get_port_by_lid(p_mgr->p_subn,
+ cl_hton16
+ (dlid));
+
+ /* remove path from current cdg / vl */
+ err =
+ remove_path_from_cdg(&
+ (cdg[test_vl]),
+ src_port, slid,
+ dest_port,
+ dlid);
+ if (err) {
+ OSM_LOG(p_mgr->p_log,
+ OSM_LOG_ERROR,
+ "ERR AD44: something went wrong in remove_path_from_cdg(...)\n");
+ goto ERROR;
+ }
+
+ /* add path to next cdg / vl */
+ err =
+ update_channel_dep_graph(&
+ (cdg
+ [test_vl +
+ 1]),
+ src_port,
+ slid,
+ dest_port,
+ dlid);
+ if (err) {
+ OSM_LOG(p_mgr->p_log,
+ OSM_LOG_ERROR,
+ "ERR AD14: cannot allocate memory for cdg node or link in update_channel_dep_graph(...)\n");
+ goto ERROR;
+ }
+ vltable_insert(srcdest2vl_table,
+ cl_hton16(slid),
+ cl_hton16(dlid),
+ test_vl + 1);
+ }
+
+ if (weakest_link->num_pairs)
+ free(weakest_link->srcdest_pairs);
+ if (weakest_link)
+ free(weakest_link);
+ }
+
+ start_here = cycle;
+ }
+ }
+
+ /* test the last avail cdg for a cycle;
+ if there is one, than vl_needed > vl_avail
+ */
+ start_here = cdg[vl_avail - 1];
+ if (start_here) {
+ cycle =
+ search_cycle_in_channel_dep_graph(cdg[vl_avail - 1],
+ start_here);
+ if (cycle) {
+ vl_needed = vl_avail + 1;
+ }
+ }
+
+ OSM_LOG(p_mgr->p_log, OSM_LOG_INFO,
+ "Virtual Lanes needed: %" PRIu8 "\n", vl_needed);
+ if (OSM_LOG_IS_ACTIVE_V2(p_mgr->p_log, OSM_LOG_INFO)) {
+ OSM_LOG(p_mgr->p_log, OSM_LOG_INFO,
+ "Paths per VL (before balancing):\n");
+ for (i = 0; i < vl_avail; i++)
+ OSM_LOG(p_mgr->p_log, OSM_LOG_INFO,
+ " %" PRIu32 ". lane: %" PRIu64 "\n", i,
+ paths_per_vl[i]);
+ }
+
+ OSM_LOG(p_mgr->p_log, OSM_LOG_VERBOSE,
+ "Balancing the paths on the available Virtual Lanes\n");
+
+ /* optimal balancing virtual lanes, under condition: no additional cycle checks;
+ sl/vl != 0 might be assigned to loopback packets (i.e. slid/dlid on the
+ same port for lmc>0), but thats no problem, see IBAS 10.2.2.3
+ */
+ split_count = (uint8_t *) calloc(vl_avail, sizeof(uint8_t));
+ if (!split_count) {
+ OSM_LOG(p_mgr->p_log, OSM_LOG_ERROR,
+ "ERR AD24: cannot allocate memory for split_count, skip balancing\n");
+ err = 1;
+ goto ERROR;
+ }
+ /* initial state: paths for VLs won't be separated */
+ for (i = 0; i < ((vl_needed < vl_avail) ? vl_needed : vl_avail); i++)
+ split_count[i] = 1;
+ dfsssp_ctx->vl_split_count = split_count;
+ /* balancing is necessary if we have empty VLs */
+ if (vl_needed < vl_avail) {
+ /* split paths of VLs until we find an equal distribution */
+ for (i = vl_needed; i < vl_avail; i++) {
+ /* find VL with most paths in it */
+ vl = 0;
+ most_avg_paths = 0.0;
+ for (test_vl = 0; test_vl < vl_needed; test_vl++) {
+ if (most_avg_paths <
+ ((double)paths_per_vl[test_vl] /
+ split_count[test_vl])) {
+ vl = test_vl;
+ most_avg_paths =
+ (double)paths_per_vl[test_vl] /
+ split_count[test_vl];
+ }
+ }
+ split_count[vl]++;
+ }
+ /* change the VL assignment depending on split_count for
+ all VLs except VL 0
+ */
+ for (from = vl_needed - 1; from > 0; from--) {
+ /* how much space needed for others? */
+ to = 0;
+ for (i = 0; i < from; i++)
+ to += split_count[i];
+ count = paths_per_vl[from];
+ vltable_change_vl(srcdest2vl_table, from, to, count);
+ /* change also the information within the split_count
+ array; this is important for fast calculation later
+ */
+ split_count[to] = split_count[from];
+ split_count[from] = 0;
+ paths_per_vl[to] = paths_per_vl[from];
+ paths_per_vl[from] = 0;
+ }
+ } else if (vl_needed > vl_avail) {
+ /* routing not possible, a further development would be the LASH-TOR approach (update: LASH-TOR isn't possible, there is a mistake in the theory) */
+ OSM_LOG(p_mgr->p_log, OSM_LOG_ERROR,
+ "ERR AD25: Not enough VLs available (avail=%d, needed=%d); Stopping dfsssp routing!\n",
+ vl_avail, vl_needed);
+ err = 1;
+ goto ERROR;
+ }
+ /* else { no balancing } */
+
+ if (OSM_LOG_IS_ACTIVE_V2(p_mgr->p_log, OSM_LOG_DEBUG)) {
+ OSM_LOG(p_mgr->p_log, OSM_LOG_DEBUG,
+ "Virtual Lanes per src/dest combination after balancing:\n");
+ vltable_print(p_mgr, srcdest2vl_table);
+ }
+ if (OSM_LOG_IS_ACTIVE_V2(p_mgr->p_log, OSM_LOG_INFO)) {
+ OSM_LOG(p_mgr->p_log, OSM_LOG_INFO,
+ "Approx. #paths per VL (after balancing):\n");
+ j = 0;
+ count = 1; /* to prevent div. by 0 */
+ for (i = 0; i < vl_avail; i++) {
+ if (split_count[i] > 0) {
+ j = i;
+ count = split_count[i];
+ }
+ OSM_LOG(p_mgr->p_log, OSM_LOG_INFO,
+ " %" PRIu32 ". lane: %" PRIu64 "\n", i,
+ paths_per_vl[j] / count);
+ }
+ }
+
+ free(paths_per_vl);
+
+ /* deallocate channel dependency graphs */
+ for (i = 0; i < vl_avail; i++)
+ cdg_dealloc(&cdg[i]);
+ free(cdg);
+
+ OSM_LOG_EXIT(p_mgr->p_log);
+ return 0;
+
+ERROR:
+ free(paths_per_vl);
+
+ for (i = 0; i < vl_avail; i++)
+ cdg_dealloc(&cdg[i]);
+ free(cdg);
+
+ vltable_dealloc(&srcdest2vl_table);
+ dfsssp_ctx->srcdest2vl_table = NULL;
+
+ return err;
+}
+
+/* meta function which calls subfunctions for dijkstra, update lft and weights,
+ (and remove deadlocks) to calculate the routing for the subnet
+*/
+static int dfsssp_do_dijkstra_routing(void *context)
+{
+ dfsssp_context_t *dfsssp_ctx = (dfsssp_context_t *) context;
+ osm_ucast_mgr_t *p_mgr = (osm_ucast_mgr_t *) dfsssp_ctx->p_mgr;
+ vertex_t *adj_list = (vertex_t *) dfsssp_ctx->adj_list;
+ uint32_t adj_list_size = dfsssp_ctx->adj_list_size;
+
+ vertex_t **sw_list = NULL;
+ uint32_t sw_list_size = 0;
+ uint64_t guid = 0;
+ cl_qlist_t *qlist = NULL;
+ cl_list_item_t *qlist_item = NULL;
+
+ cl_qmap_t *sw_tbl = &p_mgr->p_subn->sw_guid_tbl;
+ cl_qmap_t cn_tbl, io_tbl, *p_mixed_tbl = NULL;
+ cl_map_item_t *item = NULL;
+ osm_switch_t *sw = NULL;
+ osm_port_t *port = NULL;
+ uint32_t i = 0, err = 0;
+ uint16_t lid = 0, min_lid_ho = 0, max_lid_ho = 0;
+ uint8_t lmc = 0;
+ boolean_t cn_nodes_provided = FALSE, io_nodes_provided = FALSE;
+
+ OSM_LOG_ENTER(p_mgr->p_log);
+ OSM_LOG(p_mgr->p_log, OSM_LOG_VERBOSE,
+ "Calculating shortest path from all Hca/switches to all\n");
+
+ cl_qmap_init(&cn_tbl);
+ cl_qmap_init(&io_tbl);
+ p_mixed_tbl = &cn_tbl;
+
+ cl_qlist_init(&p_mgr->port_order_list);
+
+ /* reset the new_lft for each switch */
+ for (item = cl_qmap_head(sw_tbl); item != cl_qmap_end(sw_tbl);
+ item = cl_qmap_next(item)) {
+ sw = (osm_switch_t *) item;
+ /* initialize LIDs in buffer to invalid port number */
+ memset(sw->new_lft, OSM_NO_PATH, sw->max_lid_ho + 1);
+ /* initialize LFT and hop count for bsp0/esp0 of the switch */
+ min_lid_ho = cl_ntoh16(osm_node_get_base_lid(sw->p_node, 0));
+ lmc = osm_node_get_lmc(sw->p_node, 0);
+ for (i = min_lid_ho; i < min_lid_ho + (1 << lmc); i++) {
+ /* for each switch the port to the 'self'lid is the management port 0 */
+ sw->new_lft[i] = 0;
+ /* the hop count to the 'self'lid is 0 for each switch */
+ osm_switch_set_hops(sw, i, 0, 0);
+ }
+ }
+
+ /* we need an intermediate array of pointers to switches in adj_list;
+ this array will be sorted in respect to num_hca (descending)
+ */
+ sw_list_size = adj_list_size - 1;
+ sw_list = (vertex_t **)malloc(sw_list_size * sizeof(vertex_t *));
+ if (!sw_list) {
+ OSM_LOG(p_mgr->p_log, OSM_LOG_ERROR,
+ "ERR AD29: cannot allocate memory for sw_list in dfsssp_do_dijkstra_routing\n");
+ goto ERROR;
+ }
+ memset(sw_list, 0, sw_list_size * sizeof(vertex_t *));
+
+ /* fill the array with references to the 'real' sw in adj_list */
+ for (i = 0; i < sw_list_size; i++)
+ sw_list[i] = &(adj_list[i + 1]);
+
+ /* sort the sw_list in descending order */
+ sw_list_sort_by_num_hca(sw_list, sw_list_size);
+
+ /* parse compute node guid file, if provided by the user */
+ if (p_mgr->p_subn->opt.cn_guid_file) {
+ OSM_LOG(p_mgr->p_log, OSM_LOG_DEBUG,
+ "Parsing compute nodes from file %s\n",
+ p_mgr->p_subn->opt.cn_guid_file);
+
+ if (parse_node_map(p_mgr->p_subn->opt.cn_guid_file,
+ add_guid_to_map, &cn_tbl)) {
+ OSM_LOG(p_mgr->p_log, OSM_LOG_ERROR,
+ "ERR AD33: Problem parsing compute node guid file\n");
+ goto ERROR;
+ }
+
+ if (cl_is_qmap_empty(&cn_tbl))
+ OSM_LOG(p_mgr->p_log, OSM_LOG_INFO,
+ "WRN AD34: compute node guids file contains no valid guids\n");
+ else
+ cn_nodes_provided = TRUE;
+ }
+
+ /* parse I/O guid file, if provided by the user */
+ if (p_mgr->p_subn->opt.io_guid_file) {
+ OSM_LOG(p_mgr->p_log, OSM_LOG_DEBUG,
+ "Parsing I/O nodes from file %s\n",
+ p_mgr->p_subn->opt.io_guid_file);
+
+ if (parse_node_map(p_mgr->p_subn->opt.io_guid_file,
+ add_guid_to_map, &io_tbl)) {
+ OSM_LOG(p_mgr->p_log, OSM_LOG_ERROR,
+ "ERR AD35: Problem parsing I/O guid file\n");
+ goto ERROR;
+ }
+
+ if (cl_is_qmap_empty(&io_tbl))
+ OSM_LOG(p_mgr->p_log, OSM_LOG_INFO,
+ "WRN AD36: I/O node guids file contains no valid guids\n");
+ else
+ io_nodes_provided = TRUE;
+ }
+
+ /* if we mix Hca/Tca/SP0 during the dijkstra routing, we might end up
+ in rare cases with a bad balancing for Hca<->Hca connections, i.e.
+ some inter-switch links get oversubscribed with paths;
+ therefore: add Hca ports first to ensure good Hca<->Hca balancing
+ */
+ if (cn_nodes_provided) {
+ for (i = 0; i < adj_list_size - 1; i++) {
+ if (sw_list[i] && sw_list[i]->sw) {
+ sw = (osm_switch_t *)(sw_list[i]->sw);
+ add_sw_endports_to_order_list(sw, p_mgr,
+ &cn_tbl, TRUE);
+ } else {
+ OSM_LOG(p_mgr->p_log, OSM_LOG_ERROR,
+ "ERR AD30: corrupted sw_list array in dfsssp_do_dijkstra_routing\n");
+ goto ERROR;
+ }
+ }
+ }
+ /* then: add Tca ports to ensure good Hca->Tca balancing and separate
+ paths towards I/O nodes on the same switch (if possible)
+ */
+ if (io_nodes_provided) {
+ for (i = 0; i < adj_list_size - 1; i++) {
+ if (sw_list[i] && sw_list[i]->sw) {
+ sw = (osm_switch_t *)(sw_list[i]->sw);
+ add_sw_endports_to_order_list(sw, p_mgr,
+ &io_tbl, TRUE);
+ } else {
+ OSM_LOG(p_mgr->p_log, OSM_LOG_ERROR,
+ "ERR AD32: corrupted sw_list array in dfsssp_do_dijkstra_routing\n");
+ goto ERROR;
+ }
+ }
+ }
+ /* then: add anything else, such as administration nodes, ... */
+ if (cn_nodes_provided && io_nodes_provided) {
+ cl_qmap_merge(&cn_tbl, &io_tbl);
+ } else if (io_nodes_provided) {
+ p_mixed_tbl = &io_tbl;
+ }
+ for (i = 0; i < adj_list_size - 1; i++) {
+ if (sw_list[i] && sw_list[i]->sw) {
+ sw = (osm_switch_t *)(sw_list[i]->sw);
+ add_sw_endports_to_order_list(sw, p_mgr, p_mixed_tbl,
+ FALSE);
+ } else {
+ OSM_LOG(p_mgr->p_log, OSM_LOG_ERROR,
+ "ERR AD39: corrupted sw_list array in dfsssp_do_dijkstra_routing\n");
+ goto ERROR;
+ }
+ }
+ /* last: add SP0 afterwards which have lower priority for balancing */
+ for (i = 0; i < sw_list_size; i++) {
+ if (sw_list[i] && sw_list[i]->sw) {
+ sw = (osm_switch_t *)(sw_list[i]->sw);
+ guid = cl_ntoh64(osm_node_get_node_guid(sw->p_node));
+ add_guid_to_order_list(guid, p_mgr);
+ } else {
+ OSM_LOG(p_mgr->p_log, OSM_LOG_ERROR,
+ "ERR AD31: corrupted sw_list array in dfsssp_do_dijkstra_routing\n");
+ goto ERROR;
+ }
+ }
+
+ /* the intermediate array lived long enough */
+ free(sw_list);
+ sw_list = NULL;
+ /* same is true for the compute node and I/O guid map */
+ destroy_guid_map(&cn_tbl);
+ cn_nodes_provided = FALSE;
+ destroy_guid_map(&io_tbl);
+ io_nodes_provided = FALSE;
+
+ /* do the routing for the each Hca in the subnet and each switch
+ in the subnet (to add the routes to base/enhanced SP0)
+ */
+ qlist = &p_mgr->port_order_list;
+ for (qlist_item = cl_qlist_head(qlist);
+ qlist_item != cl_qlist_end(qlist);
+ qlist_item = cl_qlist_next(qlist_item)) {
+ port = (osm_port_t *)cl_item_obj(qlist_item, port, list_item);
+
+ /* calculate shortest path with dijkstra from node to all switches/Hca */
+ if (osm_node_get_type(port->p_node) == IB_NODE_TYPE_CA) {
+ OSM_LOG(p_mgr->p_log, OSM_LOG_DEBUG,
+ "Processing Hca with GUID 0x%" PRIx64 "\n",
+ cl_ntoh64(osm_node_get_node_guid
+ (port->p_node)));
+ } else if (osm_node_get_type(port->p_node) == IB_NODE_TYPE_SWITCH) {
+ OSM_LOG(p_mgr->p_log, OSM_LOG_DEBUG,
+ "Processing switch with GUID 0x%" PRIx64 "\n",
+ cl_ntoh64(osm_node_get_node_guid
+ (port->p_node)));
+ } else {
+ /* we don't handle routers, in case they show up */
+ continue;
+ }
+
+ /* distribute the LID range across the ports that can reach those LIDs
+ to have disjoint paths for one destination port with lmc>0;
+ for switches with bsp0: min=max; with esp0: max>min if lmc>0
+ */
+ osm_port_get_lid_range_ho(port, &min_lid_ho,
+ &max_lid_ho);
+ for (lid = min_lid_ho; lid <= max_lid_ho; lid++) {
+ /* do dijkstra from this Hca/LID/SP0 to each switch */
+ err =
+ dijkstra(p_mgr, adj_list, adj_list_size, port, lid);
+ if (err)
+ goto ERROR;
+ if (OSM_LOG_IS_ACTIVE_V2(p_mgr->p_log, OSM_LOG_DEBUG))
+ print_routes(p_mgr, adj_list, adj_list_size,
+ port);
+
+ /* make an update for the linear forwarding tables of the switches */
+ err =
+ update_lft(p_mgr, adj_list, adj_list_size, port, lid);
+ if (err)
+ goto ERROR;
+
+ /* add weights for calculated routes to adjust the weights for the next cycle */
+ update_weights(p_mgr, adj_list, adj_list_size);
+
+ if (OSM_LOG_IS_ACTIVE_V2(p_mgr->p_log, OSM_LOG_DEBUG))
+ dfsssp_print_graph(p_mgr, adj_list,
+ adj_list_size);
+ }
+ }
+
+ /* try deadlock removal only for the dfsssp routing (not for the sssp case, which is a subset of the dfsssp algorithm) */
+ if (dfsssp_ctx->routing_type == OSM_ROUTING_ENGINE_TYPE_DFSSSP) {
+ /* remove potential deadlocks by assigning different virtual lanes to src/dest paths and balance the lanes */
+ err = dfsssp_remove_deadlocks(dfsssp_ctx);
+ if (err)
+ goto ERROR;
+ } else if (dfsssp_ctx->routing_type == OSM_ROUTING_ENGINE_TYPE_SSSP) {
+ OSM_LOG(p_mgr->p_log, OSM_LOG_INFO,
+ "SSSP routing specified -> skipping deadlock removal thru dfsssp_remove_deadlocks(...)\n");
+ } else {
+ OSM_LOG(p_mgr->p_log, OSM_LOG_ERROR,
+ "ERR AD28: wrong routing engine specified in dfsssp_ctx\n");
+ goto ERROR;
+ }
+
+ /* list not needed after the dijkstra steps and deadlock removal */
+ cl_qlist_remove_all(&p_mgr->port_order_list);
+
+ /* print the new_lft for each switch after routing is done */
+ if (OSM_LOG_IS_ACTIVE_V2(p_mgr->p_log, OSM_LOG_DEBUG)) {
+ for (item = cl_qmap_head(sw_tbl); item != cl_qmap_end(sw_tbl);
+ item = cl_qmap_next(item)) {
+ sw = (osm_switch_t *) item;
+ OSM_LOG(p_mgr->p_log, OSM_LOG_DEBUG,
+ "Summary of the (new) LFT for switch 0x%" PRIx64
+ " (%s):\n",
+ cl_ntoh64(osm_node_get_node_guid(sw->p_node)),
+ sw->p_node->print_desc);
+ for (i = 0; i < sw->max_lid_ho + 1; i++)
+ if (sw->new_lft[i] != OSM_NO_PATH) {
+ OSM_LOG(p_mgr->p_log, OSM_LOG_DEBUG,
+ " for LID=%" PRIu32
+ " use port=%" PRIu8 "\n", i,
+ sw->new_lft[i]);
+ }
+ }
+ }
+
+ OSM_LOG_EXIT(p_mgr->p_log);
+ return 0;
+
+ERROR:
+ if (!cl_is_qlist_empty(&p_mgr->port_order_list))
+ cl_qlist_remove_all(&p_mgr->port_order_list);
+ if (cn_nodes_provided)
+ destroy_guid_map(&cn_tbl);
+ if (io_nodes_provided)
+ destroy_guid_map(&io_tbl);
+ if (sw_list)
+ free(sw_list);
+ return -1;
+}
+
+/* meta function which calls subfunctions for finding the optimal switch
+ for the spanning tree, performing a dijkstra step with this sw as root,
+ and calculating the mcast table for MLID
+*/
+static ib_api_status_t dfsssp_do_mcast_routing(void * context,
+ osm_mgrp_box_t * mbox)
+{
+ dfsssp_context_t *dfsssp_ctx = (dfsssp_context_t *) context;
+ osm_ucast_mgr_t *p_mgr = (osm_ucast_mgr_t *) dfsssp_ctx->p_mgr;
+ osm_sm_t *sm = (osm_sm_t *) p_mgr->sm;
+ vertex_t *adj_list = (vertex_t *) dfsssp_ctx->adj_list;
+ uint32_t adj_list_size = dfsssp_ctx->adj_list_size;
+ cl_qlist_t mcastgrp_port_list;
+ cl_qmap_t mcastgrp_port_map;
+ osm_switch_t *root_sw = NULL, *p_sw = NULL;
+ osm_port_t *port = NULL;
+ ib_net16_t lid = 0;
+ uint32_t err = 0, num_ports = 0, i = 0;
+ ib_net64_t guid = 0;
+ ib_api_status_t status = IB_SUCCESS;
+
+ OSM_LOG_ENTER(sm->p_log);
+
+ /* using the ucast cache feature with dfsssp might mean that a leaf sw
+ got removed (and got back) without calling dfsssp_build_graph
+ and therefore the adj_list (and pointers to osm's internal switches)
+ could be outdated (here we have no knowledge if it has happened, so
+ unfortunately a check is necessary... still better than rebuilding
+ adj_list every time we arrive here)
+ */
+ if (p_mgr->p_subn->opt.use_ucast_cache && p_mgr->cache_valid) {
+ for (i = 1; i < adj_list_size; i++) {
+ guid = cl_hton64(adj_list[i].guid);
+ p_sw = osm_get_switch_by_guid(p_mgr->p_subn, guid);
+ if (p_sw) {
+ /* check if switch came back from the dead */
+ if (adj_list[i].dropped)
+ adj_list[i].dropped = FALSE;
+
+ /* verify that sw object has not been moved
+ (this can happen for a leaf switch, if it
+ was dropped and came back later without a
+ rerouting), otherwise we have to update
+ dfsssp's internal switch list with the new
+ sw pointer
+ */
+ if (p_sw == adj_list[i].sw)
+ continue;
+ else
+ adj_list[i].sw = p_sw;
+ } else {
+ /* if a switch from adj_list is not in the
+ sw_guid_tbl anymore, then the only reason is
+ that it was a leaf switch and opensm dropped
+ it without calling a rerouting
+ -> calling dijkstra is no problem, since it
+ is a leaf and different from root_sw
+ -> only update_mcft and reset_mgrp_membership
+ need to be aware of these dropped switches
+ */
+ if (!adj_list[i].dropped)
+ adj_list[i].dropped = TRUE;
+ }
+ }
+ }
+
+ /* create a map and a list of all ports which are member in the mcast
+ group; map for searching elements and list for iteration
+ */
+ if (osm_mcast_make_port_list_and_map(&mcastgrp_port_list,
+ &mcastgrp_port_map, mbox)) {
+ OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR AD50: "
+ "Insufficient memory to make port list\n");
+ status = IB_ERROR;
+ goto Exit;
+ }
+
+ num_ports = cl_qlist_count(&mcastgrp_port_list);
+ if (num_ports < 2) {
+ OSM_LOG(sm->p_log, OSM_LOG_VERBOSE,
+ "MLID 0x%X has %u members - nothing to do\n",
+ mbox->mlid, num_ports);
+ goto Exit;
+ }
+
+ /* find the root switch for the spanning tree, which has the smallest
+ hops count to all LIDs in the mcast group
+ */
+ root_sw = osm_mcast_mgr_find_root_switch(sm, &mcastgrp_port_list);
+ if (!root_sw) {
+ OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR AD51: "
+ "Unable to locate a suitable switch for group 0x%X\n",
+ mbox->mlid);
+ status = IB_ERROR;
+ goto Exit;
+ }
+
+ /* a) start one dijkstra step from the root switch to generate a
+ spanning tree
+ b) this might be a bit of an overkill to span the whole
+ network, if there are only a few ports in the mcast group, but
+ its only one dijkstra step for each mcast group and we did many
+ steps before in the ucast routing for each LID in the subnet;
+ c) we can use the subnet structure from the ucast routing, and
+ don't even have to reset the link weights (=> therefore the mcast
+ spanning tree will use less 'growded' links in the network)
+ d) the mcast dfsssp algorithm will not change the link weights
+ */
+ lid = osm_node_get_base_lid(root_sw->p_node, 0);
+ port = osm_get_port_by_lid(sm->p_subn, lid);
+ err = dijkstra(p_mgr, adj_list, adj_list_size, port, lid);
+ if (err) {
+ OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR AD52: "
+ "Dijkstra step for mcast failed for group 0x%X\n",
+ mbox->mlid);
+ status = IB_ERROR;
+ goto Exit;
+ }
+
+ /* set mcast group membership again for update_mcft
+ (unfortunately: osm_mcast_mgr_find_root_switch resets it)
+ */
+ update_mgrp_membership(&mcastgrp_port_list);
+
+ /* update the mcast forwarding tables of the switches */
+ err = update_mcft(sm, adj_list, adj_list_size, mbox->mlid,
+ &mcastgrp_port_map, root_sw);
+ if (err) {
+ OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR AD53: "
+ "Update of mcast forwarding tables failed for group 0x%X\n",
+ mbox->mlid);
+ status = IB_ERROR;
+ goto Exit;
+ }
+
+Exit:
+ reset_mgrp_membership(adj_list, adj_list_size);
+ osm_mcast_drop_port_list(&mcastgrp_port_list);
+ OSM_LOG_EXIT(sm->p_log);
+ return status;
+}
+
+/* called from extern in QP creation process to gain the the service level and
+ the virtual lane respectively for a <s,d> pair
+*/
+static uint8_t get_dfsssp_sl(void *context, uint8_t hint_for_default_sl,
+ const ib_net16_t slid, const ib_net16_t dlid)
+{
+ dfsssp_context_t *dfsssp_ctx = (dfsssp_context_t *) context;
+ osm_port_t *src_port, *dest_port;
+ vltable_t *srcdest2vl_table = NULL;
+ uint8_t *vl_split_count = NULL;
+ osm_ucast_mgr_t *p_mgr = NULL;
+ int32_t res = 0;
+
+ if (dfsssp_ctx
+ && dfsssp_ctx->routing_type == OSM_ROUTING_ENGINE_TYPE_DFSSSP) {
+ p_mgr = (osm_ucast_mgr_t *) dfsssp_ctx->p_mgr;
+ srcdest2vl_table = (vltable_t *) (dfsssp_ctx->srcdest2vl_table);
+ vl_split_count = (uint8_t *) (dfsssp_ctx->vl_split_count);
+ }
+ else
+ return hint_for_default_sl;
+
+ src_port = osm_get_port_by_lid(p_mgr->p_subn, slid);
+ if (!src_port)
+ return hint_for_default_sl;
+
+ dest_port = osm_get_port_by_lid(p_mgr->p_subn, dlid);
+ if (!dest_port)
+ return hint_for_default_sl;
+
+ if (!srcdest2vl_table)
+ return hint_for_default_sl;
+
+ res = vltable_get_vl(srcdest2vl_table, slid, dlid);
+
+ /* we will randomly distribute the traffic over multiple VLs if
+ necessary for good balancing; therefore vl_split_count provides
+ the number of VLs to use for certain traffic
+ */
+ if (res > -1) {
+ if (vl_split_count[res] > 1)
+ return (uint8_t) (res + rand()%(vl_split_count[res]));
+ else
+ return (uint8_t) res;
+ } else
+ return hint_for_default_sl;
+}
+
+static dfsssp_context_t *dfsssp_context_create(osm_opensm_t * p_osm,
+ osm_routing_engine_type_t
+ routing_type)
+{
+ dfsssp_context_t *dfsssp_ctx = NULL;
+
+ /* allocate memory */
+ dfsssp_ctx = (dfsssp_context_t *) malloc(sizeof(dfsssp_context_t));
+ if (dfsssp_ctx) {
+ /* set initial values */
+ dfsssp_ctx->routing_type = routing_type;
+ dfsssp_ctx->p_mgr = (osm_ucast_mgr_t *) & (p_osm->sm.ucast_mgr);
+ dfsssp_ctx->adj_list = NULL;
+ dfsssp_ctx->adj_list_size = 0;
+ dfsssp_ctx->srcdest2vl_table = NULL;
+ dfsssp_ctx->vl_split_count = NULL;
+ } else {
+ OSM_LOG(p_osm->sm.ucast_mgr.p_log, OSM_LOG_ERROR,
+ "ERR AD04: cannot allocate memory for dfsssp_ctx in dfsssp_context_create\n");
+ return NULL;
+ }
+
+ return dfsssp_ctx;
+}
+
+static void dfsssp_context_destroy(void *context)
+{
+ dfsssp_context_t *dfsssp_ctx = (dfsssp_context_t *) context;
+ vertex_t *adj_list = (vertex_t *) (dfsssp_ctx->adj_list);
+ uint32_t i = 0;
+ link_t *link = NULL, *tmp = NULL;
+
+ /* free adj_list */
+ for (i = 0; i < dfsssp_ctx->adj_list_size; i++) {
+ link = adj_list[i].links;
+ while (link) {
+ tmp = link;
+ link = link->next;
+ free(tmp);
+ }
+ }
+ free(adj_list);
+ dfsssp_ctx->adj_list = NULL;
+ dfsssp_ctx->adj_list_size = 0;
+
+ /* free srcdest2vl table and the split count information table
+ (can be done, because dfsssp_context_destroy is called after
+ osm_get_dfsssp_sl)
+ */
+ vltable_dealloc(&(dfsssp_ctx->srcdest2vl_table));
+ dfsssp_ctx->srcdest2vl_table = NULL;
+
+ if (dfsssp_ctx->vl_split_count) {
+ free(dfsssp_ctx->vl_split_count);
+ dfsssp_ctx->vl_split_count = NULL;
+ }
+}
+
+static void delete(void *context)
+{
+ if (!context)
+ return;
+ dfsssp_context_destroy(context);
+
+ free(context);
+}
+
+int osm_ucast_dfsssp_setup(struct osm_routing_engine *r, osm_opensm_t * p_osm)
+{
+ /* create context container and add ucast management object */
+ dfsssp_context_t *dfsssp_context =
+ dfsssp_context_create(p_osm, OSM_ROUTING_ENGINE_TYPE_DFSSSP);
+ if (!dfsssp_context) {
+ return 1; /* alloc failed -> skip this routing */
+ }
+
+ /* reset function pointers to dfsssp routines */
+ r->context = (void *)dfsssp_context;
+ r->build_lid_matrices = dfsssp_build_graph;
+ r->ucast_build_fwd_tables = dfsssp_do_dijkstra_routing;
+ r->mcast_build_stree = dfsssp_do_mcast_routing;
+ r->path_sl = get_dfsssp_sl;
+ r->destroy = delete;
+
+ /* we initialize with the current time to achieve a 'good' randomized
+ assignment in get_dfsssp_sl(...)
+ */
+ srand(time(NULL));
+
+ return 0;
+}
+
+int osm_ucast_sssp_setup(struct osm_routing_engine *r, osm_opensm_t * p_osm)
+{
+ /* create context container and add ucast management object */
+ dfsssp_context_t *dfsssp_context =
+ dfsssp_context_create(p_osm, OSM_ROUTING_ENGINE_TYPE_SSSP);
+ if (!dfsssp_context) {
+ return 1; /* alloc failed -> skip this routing */
+ }
+
+ /* reset function pointers to sssp routines */
+ r->context = (void *)dfsssp_context;
+ r->build_lid_matrices = dfsssp_build_graph;
+ r->ucast_build_fwd_tables = dfsssp_do_dijkstra_routing;
+ r->mcast_build_stree = dfsssp_do_mcast_routing;
+ r->destroy = delete;
+
+ return 0;
+}
diff --git a/contrib/ofed/opensm/opensm/osm_ucast_dnup.c b/contrib/ofed/opensm/opensm/osm_ucast_dnup.c
new file mode 100644
index 0000000..d3e5383
--- /dev/null
+++ b/contrib/ofed/opensm/opensm/osm_ucast_dnup.c
@@ -0,0 +1,499 @@
+/*
+ * Copyright (c) 2004-2008 Voltaire, Inc. All rights reserved.
+ * Copyright (c) 2002-2007,2009 Mellanox Technologies LTD. All rights reserved.
+ * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
+ * Copyright (c) 2009 HNR Consulting. All rights reserved.
+ * Copyright (c) 2009 Battelle Memorial Institue. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+/*
+ * Abstract:
+ * Implementation of Up Down Algorithm using ranking & Min Hop
+ * Calculation functions
+ */
+
+#if HAVE_CONFIG_H
+# include <config.h>
+#endif /* HAVE_CONFIG_H */
+
+#include <stdlib.h>
+#include <ctype.h>
+#include <complib/cl_debug.h>
+#include <complib/cl_qmap.h>
+#include <opensm/osm_file_ids.h>
+#define FILE_ID OSM_FILE_UCAST_DNUP_C
+#include <opensm/osm_switch.h>
+#include <opensm/osm_opensm.h>
+#include <opensm/osm_ucast_mgr.h>
+
+/* //////////////////////////// */
+/* Local types */
+/* //////////////////////////// */
+
+/* direction */
+typedef enum dnup_switch_dir {
+ UP = 0,
+ DOWN,
+ EQUAL
+} dnup_switch_dir_t;
+
+/* dnup structure */
+typedef struct dnup {
+ osm_opensm_t *p_osm;
+} dnup_t;
+
+struct dnup_node {
+ cl_list_item_t list;
+ osm_switch_t *sw;
+ dnup_switch_dir_t dir;
+ unsigned rank;
+ unsigned visited;
+};
+
+/* This function returns direction based on rank and guid info of current &
+ remote ports */
+static dnup_switch_dir_t dnup_get_dir(unsigned cur_rank, unsigned rem_rank)
+{
+ /* HACK: comes to solve root nodes connection, in a classic subnet root nodes do not connect
+ directly, but in case they are we assign to root node an UP direction to allow DNUP to discover
+ the subnet correctly (and not from the point of view of the last root node).
+ */
+ if (!cur_rank && !rem_rank)
+ return EQUAL;
+
+ if (cur_rank < rem_rank)
+ return DOWN;
+ else if (cur_rank > rem_rank)
+ return UP;
+ else
+ return EQUAL;
+}
+
+/**********************************************************************
+ * This function does the bfs of min hop table calculation by guid index
+ * as a starting point.
+ **********************************************************************/
+static int dnup_bfs_by_node(IN osm_log_t * p_log, IN osm_subn_t * p_subn,
+ IN osm_switch_t * p_sw, IN uint8_t prune_weight,
+ OUT uint8_t * max_hops)
+{
+ uint8_t pn, pn_rem;
+ cl_qlist_t list;
+ uint16_t lid;
+ struct dnup_node *u;
+ dnup_switch_dir_t next_dir, current_dir;
+
+ OSM_LOG_ENTER(p_log);
+
+ lid = osm_node_get_base_lid(p_sw->p_node, 0);
+ lid = cl_ntoh16(lid);
+ osm_switch_set_hops(p_sw, lid, 0, 0);
+
+ OSM_LOG(p_log, OSM_LOG_DEBUG,
+ "Starting from switch - port GUID 0x%" PRIx64 " lid %u\n",
+ cl_ntoh64(p_sw->p_node->node_info.port_guid), lid);
+
+ u = p_sw->priv;
+ u->dir = DOWN;
+
+ /* Update list with the new element */
+ cl_qlist_init(&list);
+ cl_qlist_insert_tail(&list, &u->list);
+
+ /* BFS the list till no next element */
+ while (!cl_is_qlist_empty(&list)) {
+ u = (struct dnup_node *)cl_qlist_remove_head(&list);
+ u->visited = 0; /* cleanup */
+ current_dir = u->dir;
+ /* Go over all ports of the switch and find unvisited remote nodes */
+ for (pn = 1; pn < u->sw->num_ports; pn++) {
+ osm_node_t *p_remote_node;
+ struct dnup_node *rem_u;
+ uint8_t current_min_hop, remote_min_hop,
+ set_hop_return_value;
+ osm_switch_t *p_remote_sw;
+
+ p_remote_node =
+ osm_node_get_remote_node(u->sw->p_node, pn,
+ &pn_rem);
+ /* If no remote node OR remote node is not a SWITCH
+ continue to next pn */
+ if (!p_remote_node || !p_remote_node->sw)
+ continue;
+ /* Fetch remote guid only after validation of remote node */
+ p_remote_sw = p_remote_node->sw;
+ rem_u = p_remote_sw->priv;
+ /* Decide which direction to mark it (UP/DOWN) */
+ next_dir = dnup_get_dir(u->rank, rem_u->rank);
+
+ /* Set MinHop value for the current lid */
+ current_min_hop = osm_switch_get_least_hops(u->sw, lid);
+ /* Check hop count if better insert into list && update
+ the remote node Min Hop Table */
+ remote_min_hop =
+ osm_switch_get_hop_count(p_remote_sw, lid, pn_rem);
+
+ /* Check if this is a legal step : the only illegal step is going
+ from UP to DOWN */
+ if ((current_dir == UP) && (next_dir == DOWN)) {
+ OSM_LOG(p_log, OSM_LOG_DEBUG,
+ "Avoiding move from 0x%016" PRIx64
+ " to 0x%016" PRIx64 "\n",
+ cl_ntoh64(osm_node_get_node_guid(u->sw->p_node)),
+ cl_ntoh64(osm_node_get_node_guid(p_remote_node)));
+ /* Illegal step. If prune_weight is set, allow it with an
+ * additional weight
+ */
+ if(prune_weight) {
+ current_min_hop+=prune_weight;
+ if(current_min_hop >= 64) {
+ OSM_LOG(p_log, OSM_LOG_ERROR,
+ "ERR AE02: Too many hops on subnet,"
+ " can't relax illegal Dn/Up transition.");
+ osm_switch_set_hops(p_remote_sw, lid,
+ pn_rem, OSM_NO_PATH);
+ }
+ } else {
+ continue;
+ }
+ }
+ if (current_min_hop + 1 < remote_min_hop) {
+ set_hop_return_value =
+ osm_switch_set_hops(p_remote_sw, lid,
+ pn_rem,
+ current_min_hop + 1);
+ if(max_hops && current_min_hop + 1 > *max_hops) {
+ *max_hops = current_min_hop + 1;
+ }
+ if (set_hop_return_value) {
+ OSM_LOG(p_log, OSM_LOG_ERROR, "ERR AE01: "
+ "Invalid value returned from set min hop is: %d\n",
+ set_hop_return_value);
+ }
+ /* Check if remote port has already been visited */
+ if (!rem_u->visited) {
+ /* Insert dnup_switch item into the list */
+ rem_u->dir = next_dir;
+ rem_u->visited = 1;
+ cl_qlist_insert_tail(&list,
+ &rem_u->list);
+ }
+ }
+ }
+ }
+
+ OSM_LOG_EXIT(p_log);
+ return 0;
+}
+
+/* NOTE : PLS check if we need to decide that the first */
+/* rank is a SWITCH for BFS purpose */
+static int dnup_subn_rank(IN dnup_t * p_dnup)
+{
+ osm_switch_t *p_sw;
+ osm_physp_t *p_physp, *p_remote_physp;
+ cl_qlist_t list;
+ cl_map_item_t *item;
+ struct dnup_node *u, *remote_u;
+ uint8_t num_ports, port_num;
+ osm_log_t *p_log = &p_dnup->p_osm->log;
+ unsigned max_rank = 0;
+
+ OSM_LOG_ENTER(p_log);
+ cl_qlist_init(&list);
+
+ /* add all node level switches to the list */
+ for (item = cl_qmap_head(&p_dnup->p_osm->subn.sw_guid_tbl);
+ item != cl_qmap_end(&p_dnup->p_osm->subn.sw_guid_tbl);
+ item = cl_qmap_next(item)) {
+ p_sw = (osm_switch_t *)item;
+ u = p_sw->priv;
+ if (u->rank == 0)
+ cl_qlist_insert_tail(&list, &u->list);
+ }
+
+ /* BFS the list till it's empty */
+ while (!cl_is_qlist_empty(&list)) {
+ u = (struct dnup_node *)cl_qlist_remove_head(&list);
+ /* Go over all remote nodes and rank them (if not already visited) */
+ p_sw = u->sw;
+ num_ports = p_sw->num_ports;
+ OSM_LOG(p_log, OSM_LOG_DEBUG,
+ "Handling switch GUID 0x%" PRIx64 "\n",
+ cl_ntoh64(osm_node_get_node_guid(p_sw->p_node)));
+ for (port_num = 1; port_num < num_ports; port_num++) {
+ ib_net64_t port_guid;
+
+ /* Current port fetched in order to get remote side */
+ p_physp =
+ osm_node_get_physp_ptr(p_sw->p_node, port_num);
+
+ if (!p_physp)
+ continue;
+
+ p_remote_physp = p_physp->p_remote_physp;
+
+ /*
+ make sure that all the following occur on p_remote_physp:
+ 1. The port isn't NULL
+ 2. It is a switch
+ */
+ if (p_remote_physp && p_remote_physp->p_node->sw) {
+ remote_u = p_remote_physp->p_node->sw->priv;
+ port_guid = p_remote_physp->port_guid;
+
+ if (remote_u->rank > u->rank + 1) {
+ remote_u->rank = u->rank + 1;
+ max_rank = remote_u->rank;
+ cl_qlist_insert_tail(&list,
+ &remote_u->list);
+ OSM_LOG(p_log, OSM_LOG_DEBUG,
+ "Rank of port GUID 0x%" PRIx64
+ " = %u\n", cl_ntoh64(port_guid),
+ remote_u->rank);
+ }
+ }
+ }
+ }
+
+ /* Print Summary of ranking */
+ OSM_LOG(p_log, OSM_LOG_VERBOSE,
+ "Subnet ranking completed. Max Node Rank = %d\n", max_rank);
+ OSM_LOG_EXIT(p_log);
+ return 0;
+}
+
+static int dnup_set_min_hop_table(IN dnup_t * p_dnup)
+{
+ osm_subn_t *p_subn = &p_dnup->p_osm->subn;
+ osm_log_t *p_log = &p_dnup->p_osm->log;
+ osm_switch_t *p_sw;
+ struct dnup_node *u;
+ cl_map_item_t *item;
+ uint8_t max_hops = 0;
+
+ OSM_LOG_ENTER(p_log);
+
+ /* Go over all the switches in the subnet - for each init their Min Hop
+ Table */
+ OSM_LOG(p_log, OSM_LOG_VERBOSE,
+ "Init Min Hop Table of all switches [\n");
+
+ for (item = cl_qmap_head(&p_dnup->p_osm->subn.sw_guid_tbl);
+ item != cl_qmap_end(&p_dnup->p_osm->subn.sw_guid_tbl);
+ item = cl_qmap_next(item)) {
+ p_sw = (osm_switch_t *)item;
+ /* Clear Min Hop Table */
+ osm_switch_clear_hops(p_sw);
+ }
+
+ OSM_LOG(p_log, OSM_LOG_VERBOSE,
+ "Init Min Hop Table of all switches ]\n");
+
+ /* Now do the BFS for each port in the subnet */
+ OSM_LOG(p_log, OSM_LOG_VERBOSE,
+ "BFS through all port guids in the subnet [\n");
+
+ for (item = cl_qmap_head(&p_dnup->p_osm->subn.sw_guid_tbl);
+ item != cl_qmap_end(&p_dnup->p_osm->subn.sw_guid_tbl);
+ item = cl_qmap_next(item)) {
+ p_sw = (osm_switch_t *)item;
+ dnup_bfs_by_node(p_log, p_subn, p_sw, 0, &max_hops);
+ }
+ if(p_subn->opt.connect_roots) {
+ /*This is probably not necessary, by I am more comfortable
+ * clearing any possible side effects from the previous
+ * dnup routing pass
+ */
+ for (item = cl_qmap_head(&p_dnup->p_osm->subn.sw_guid_tbl);
+ item != cl_qmap_end(&p_dnup->p_osm->subn.sw_guid_tbl);
+ item = cl_qmap_next(item)) {
+ p_sw = (osm_switch_t *)item;
+ osm_switch_clear_hops(p_sw);
+ u = (struct dnup_node *) p_sw->priv;
+ u->visited = 0;
+ }
+ for (item = cl_qmap_head(&p_dnup->p_osm->subn.sw_guid_tbl);
+ item != cl_qmap_end(&p_dnup->p_osm->subn.sw_guid_tbl);
+ item = cl_qmap_next(item)) {
+ p_sw = (osm_switch_t *)item;
+ dnup_bfs_by_node(p_log, p_subn, p_sw, max_hops + 1, NULL);
+ }
+ }
+
+ OSM_LOG(p_log, OSM_LOG_VERBOSE,
+ "BFS through all port guids in the subnet ]\n");
+ /* Cleanup */
+ OSM_LOG_EXIT(p_log);
+ return 0;
+}
+
+static int dnup_build_lid_matrices(IN dnup_t * p_dnup)
+{
+ int status;
+
+ OSM_LOG_ENTER(&p_dnup->p_osm->log);
+
+ OSM_LOG(&p_dnup->p_osm->log, OSM_LOG_VERBOSE,
+ "Ranking all port guids in the list\n");
+ /* Check if it's not a switched subnet */
+ if (cl_is_qmap_empty(&p_dnup->p_osm->subn.sw_guid_tbl)) {
+ OSM_LOG(&p_dnup->p_osm->log, OSM_LOG_ERROR, "ERR AEOB: "
+ "This is not a switched subnet, cannot perform DNUP algorithm\n");
+ status = -1;
+ goto _exit;
+ }
+
+ /* Rank the subnet switches */
+ dnup_subn_rank(p_dnup);
+
+ /* After multiple ranking need to set Min Hop Table by DnUp algorithm */
+ OSM_LOG(&p_dnup->p_osm->log, OSM_LOG_VERBOSE,
+ "Setting all switches' Min Hop Table\n");
+ status = dnup_set_min_hop_table(p_dnup);
+
+_exit:
+ OSM_LOG_EXIT(&p_dnup->p_osm->log);
+ return status;
+}
+
+static struct dnup_node *create_dnup_node(osm_switch_t * sw)
+{
+ struct dnup_node *u;
+
+ u = malloc(sizeof(*u));
+ if (!u)
+ return NULL;
+ memset(u, 0, sizeof(*u));
+ u->sw = sw;
+ u->rank = 0xffffffff;
+ return u;
+}
+
+static void delete_dnup_node(struct dnup_node *u)
+{
+ u->sw->priv = NULL;
+ free(u);
+}
+
+/* DNUP callback function */
+static int dnup_lid_matrices(void *ctx)
+{
+ dnup_t *p_dnup = ctx;
+ cl_map_item_t *item;
+ osm_switch_t *p_sw;
+ int ret = 0;
+ int num_leafs = 0;
+ uint8_t pn, pn_rem;
+
+ OSM_LOG_ENTER(&p_dnup->p_osm->log);
+
+ for (item = cl_qmap_head(&p_dnup->p_osm->subn.sw_guid_tbl);
+ item != cl_qmap_end(&p_dnup->p_osm->subn.sw_guid_tbl);
+ item = cl_qmap_next(item)) {
+ p_sw = (osm_switch_t *)item;
+ p_sw->priv = create_dnup_node(p_sw);
+ if (!p_sw->priv) {
+ OSM_LOG(&(p_dnup->p_osm->log), OSM_LOG_ERROR, "ERR AE0C: "
+ "cannot create dnup node\n");
+ OSM_LOG_EXIT(&p_dnup->p_osm->log);
+ return -1;
+ }
+ }
+
+
+ /* First setup node level nodes */
+ for (item = cl_qmap_head(&p_dnup->p_osm->subn.sw_guid_tbl);
+ item != cl_qmap_end(&p_dnup->p_osm->subn.sw_guid_tbl);
+ item = cl_qmap_next(item)) {
+ p_sw = (osm_switch_t *)item;
+
+ for (pn = 0; pn < p_sw->num_ports; pn++) {
+ osm_node_t *p_remote_node;
+ p_remote_node = osm_node_get_remote_node(p_sw->p_node, pn, &pn_rem);
+ if(p_remote_node && !p_remote_node->sw) {
+ struct dnup_node *u = p_sw->priv;
+ u->rank = 0;
+ OSM_LOG(&(p_dnup->p_osm->log),
+ OSM_LOG_VERBOSE, "(%s) rank 0 leaf switch\n",
+ p_sw->p_node->print_desc);
+ num_leafs++;
+ break;
+ }
+ }
+ }
+
+ if(num_leafs == 0) {
+ OSM_LOG(&(p_dnup->p_osm->log),
+ OSM_LOG_ERROR, "ERR AE0D: No leaf switches found, DnUp routing failed\n");
+ OSM_LOG_EXIT(&p_dnup->p_osm->log);
+ return -1;
+ }
+
+ ret = dnup_build_lid_matrices(p_dnup);
+
+ for (item = cl_qmap_head(&p_dnup->p_osm->subn.sw_guid_tbl);
+ item != cl_qmap_end(&p_dnup->p_osm->subn.sw_guid_tbl);
+ item = cl_qmap_next(item)) {
+ p_sw = (osm_switch_t *) item;
+ delete_dnup_node(p_sw->priv);
+ }
+
+ OSM_LOG_EXIT(&p_dnup->p_osm->log);
+ return ret;
+}
+
+static void dnup_delete(void *context)
+{
+ free(context);
+}
+
+int osm_ucast_dnup_setup(struct osm_routing_engine *r, osm_opensm_t *osm)
+{
+ dnup_t *dnup;
+
+ OSM_LOG_ENTER(&osm->log);
+
+ dnup = malloc(sizeof(dnup_t));
+ if (!dnup)
+ return -1;
+ memset(dnup, 0, sizeof(dnup_t));
+
+ dnup->p_osm = osm;
+
+ r->context = dnup;
+ r->destroy = dnup_delete;
+ r->build_lid_matrices = dnup_lid_matrices;
+
+ OSM_LOG_EXIT(&osm->log);
+ return 0;
+}
diff --git a/contrib/ofed/opensm/opensm/osm_ucast_file.c b/contrib/ofed/opensm/opensm/osm_ucast_file.c
new file mode 100644
index 0000000..f891281
--- /dev/null
+++ b/contrib/ofed/opensm/opensm/osm_ucast_file.c
@@ -0,0 +1,406 @@
+/*
+ * Copyright (c) 2006-2008 Voltaire, Inc. All rights reserved.
+ * Copyright (c) 2006,2008-2009 Mellanox Technologies LTD. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+/*
+ * Abstract:
+ * Implementation of OpenSM unicast routing module which loads
+ * routes from the dump file
+ */
+
+#if HAVE_CONFIG_H
+# include <config.h>
+#endif /* HAVE_CONFIG_H */
+
+#include <stdlib.h>
+#include <string.h>
+#include <ctype.h>
+
+#include <iba/ib_types.h>
+#include <complib/cl_qmap.h>
+#include <complib/cl_debug.h>
+#include <opensm/osm_file_ids.h>
+#define FILE_ID OSM_FILE_UCAST_FILE_C
+#include <opensm/osm_opensm.h>
+#include <opensm/osm_switch.h>
+#include <opensm/osm_log.h>
+
+static uint16_t remap_lid(osm_opensm_t * p_osm, uint16_t lid, ib_net64_t guid)
+{
+ osm_port_t *p_port;
+ uint16_t min_lid, max_lid;
+ uint8_t lmc;
+
+ p_port = osm_get_port_by_guid(&p_osm->subn, guid);
+ if (!p_port) {
+ OSM_LOG(&p_osm->log, OSM_LOG_VERBOSE,
+ "cannot find port guid 0x%016" PRIx64
+ " , will use the same lid\n", cl_ntoh64(guid));
+ return lid;
+ }
+
+ osm_port_get_lid_range_ho(p_port, &min_lid, &max_lid);
+ if (min_lid <= lid && lid <= max_lid)
+ return lid;
+
+ lmc = osm_port_get_lmc(p_port);
+ return min_lid + (lid & ((1 << lmc) - 1));
+}
+
+static void add_path(osm_opensm_t * p_osm,
+ osm_switch_t * p_sw, uint16_t lid, uint8_t port_num,
+ ib_net64_t port_guid)
+{
+ uint16_t new_lid;
+ uint8_t old_port;
+
+ new_lid = port_guid ? remap_lid(p_osm, lid, port_guid) : lid;
+ old_port = osm_switch_get_port_by_lid(p_sw, new_lid, OSM_LFT);
+ if (old_port != OSM_NO_PATH && old_port != port_num) {
+ OSM_LOG(&p_osm->log, OSM_LOG_VERBOSE,
+ "LID collision is detected on switch "
+ "0x016%" PRIx64 ", will overwrite LID %u entry\n",
+ cl_ntoh64(osm_node_get_node_guid(p_sw->p_node)),
+ new_lid);
+ }
+
+ p_sw->new_lft[new_lid] = port_num;
+ if (!(p_osm->subn.opt.port_profile_switch_nodes && port_guid &&
+ osm_get_switch_by_guid(&p_osm->subn, port_guid)))
+ osm_switch_count_path(p_sw, port_num);
+
+ OSM_LOG(&p_osm->log, OSM_LOG_DEBUG,
+ "route 0x%04x(was 0x%04x) %u 0x%016" PRIx64
+ " is added to switch 0x%016" PRIx64 "\n",
+ new_lid, lid, port_num, cl_ntoh64(port_guid),
+ cl_ntoh64(osm_node_get_node_guid(p_sw->p_node)));
+}
+
+static void add_lid_hops(osm_opensm_t * p_osm, osm_switch_t * p_sw,
+ uint16_t lid, ib_net64_t guid,
+ uint8_t hops[], unsigned len)
+{
+ uint8_t i;
+
+ if (len > p_sw->num_ports)
+ len = p_sw->num_ports;
+
+ for (i = 0; i < len; i++)
+ osm_switch_set_hops(p_sw, lid, i, hops[i]);
+}
+
+static int do_ucast_file_load(void *context)
+{
+ char line[1024];
+ char *file_name;
+ FILE *file;
+ ib_net64_t sw_guid, port_guid;
+ osm_opensm_t *p_osm = context;
+ osm_switch_t *p_sw;
+ uint16_t lid;
+ uint8_t port_num;
+ unsigned lineno;
+ int status = -1;
+
+ file_name = p_osm->subn.opt.lfts_file;
+ if (!file_name) {
+ OSM_LOG(&p_osm->log, OSM_LOG_VERBOSE,
+ "LFTs file name is not given; "
+ "using default routing algorithm\n");
+ return 1;
+ }
+
+ file = fopen(file_name, "r");
+ if (!file) {
+ OSM_LOG(&p_osm->log, OSM_LOG_ERROR | OSM_LOG_SYS, "ERR 6302: "
+ "Can't open ucast dump file \'%s\': %m\n", file_name);
+ goto Exit;
+ }
+
+ lineno = 0;
+ p_sw = NULL;
+
+ while (fgets(line, sizeof(line) - 1, file) != NULL) {
+ char *p, *q;
+ lineno++;
+
+ p = line;
+ while (isspace(*p))
+ p++;
+
+ if (*p == '#')
+ continue;
+
+ if (!strncmp(p, "Multicast mlids", 15)) {
+ OSM_LOG(&p_osm->log, OSM_LOG_ERROR | OSM_LOG_SYS,
+ "ERR 6303: "
+ "Multicast dump file detected; "
+ "skipping parsing. Using default "
+ "routing algorithm\n");
+ } else if (!strncmp(p, "Unicast lids", 12)) {
+ q = strstr(p, " guid 0x");
+ if (!q) {
+ OSM_LOG(&p_osm->log, OSM_LOG_ERROR,
+ "PARSE ERROR: %s:%u: "
+ "cannot parse switch definition\n",
+ file_name, lineno);
+ goto Exit;
+ }
+ p = q + 8;
+ sw_guid = strtoull(p, &q, 16);
+ if (q == p || !isspace(*q)) {
+ OSM_LOG(&p_osm->log, OSM_LOG_ERROR,
+ "PARSE ERROR: %s:%u: "
+ "cannot parse switch guid: \'%s\'\n",
+ file_name, lineno, p);
+ goto Exit;
+ }
+ sw_guid = cl_hton64(sw_guid);
+
+ p_sw = osm_get_switch_by_guid(&p_osm->subn, sw_guid);
+ if (!p_sw) {
+ OSM_LOG(&p_osm->log, OSM_LOG_VERBOSE,
+ "cannot find switch %016" PRIx64 "\n",
+ cl_ntoh64(sw_guid));
+ continue;
+ }
+ memset(p_sw->new_lft, OSM_NO_PATH, p_sw->lft_size);
+ } else if (p_sw && !strncmp(p, "0x", 2)) {
+ p += 2;
+ lid = (uint16_t) strtoul(p, &q, 16);
+ if (q == p || !isspace(*q)) {
+ OSM_LOG(&p_osm->log, OSM_LOG_ERROR,
+ "PARSE ERROR: %s:%u: "
+ "cannot parse lid: \'%s\'\n",
+ file_name, lineno, p);
+ goto Exit;
+ }
+ p = q;
+ while (isspace(*p))
+ p++;
+ port_num = (uint8_t) strtoul(p, &q, 10);
+ if (q == p || !isspace(*q)) {
+ OSM_LOG(&p_osm->log, OSM_LOG_ERROR,
+ "PARSE ERROR: %s:%u: "
+ "cannot parse port: \'%s\'\n",
+ file_name, lineno, p);
+ goto Exit;
+ }
+ if (port_num >=
+ osm_node_get_num_physp(p_sw->p_node)) {
+ OSM_LOG(&p_osm->log, OSM_LOG_ERROR,
+ "Invalid port %d found "
+ "for switch %016" PRIx64 "\n",
+ port_num,
+ cl_ntoh64(osm_node_get_node_guid
+ (p_sw->p_node)));
+ goto Exit;
+ }
+
+ p = q;
+ /* additionally try to extract guid */
+ q = strstr(p, " portguid 0x");
+ if (!q) {
+ OSM_LOG(&p_osm->log, OSM_LOG_VERBOSE,
+ "PARSE WARNING: %s:%u: "
+ "cannot find port guid "
+ "(maybe broken dump): \'%s\'\n",
+ file_name, lineno, p);
+ port_guid = 0;
+ } else {
+ p = q + 12;
+ port_guid = strtoull(p, &q, 16);
+ if (q == p || (!isspace(*q) && *q != ':')) {
+ OSM_LOG(&p_osm->log, OSM_LOG_VERBOSE,
+ "PARSE WARNING: %s:%u: "
+ "cannot parse port guid "
+ "(maybe broken dump): \'%s\'\n",
+ file_name, lineno, p);
+ port_guid = 0;
+ }
+ }
+ port_guid = cl_hton64(port_guid);
+ add_path(p_osm, p_sw, lid, port_num, port_guid);
+ }
+ }
+ status = 0;
+Exit:
+ if (file)
+ fclose(file);
+ return status;
+}
+
+static int do_lid_matrix_file_load(void *context)
+{
+ char line[1024];
+ uint8_t hops[256];
+ char *file_name;
+ FILE *file;
+ ib_net64_t guid;
+ osm_opensm_t *p_osm = context;
+ osm_switch_t *p_sw;
+ unsigned lineno;
+ uint16_t lid;
+ int status = -1;
+
+ file_name = p_osm->subn.opt.lid_matrix_dump_file;
+ if (!file_name) {
+ OSM_LOG(&p_osm->log, OSM_LOG_VERBOSE,
+ "lid matrix file name is not given; "
+ "using default lid matrix generation algorithm\n");
+ return 1;
+ }
+
+ file = fopen(file_name, "r");
+ if (!file) {
+ OSM_LOG(&p_osm->log, OSM_LOG_ERROR | OSM_LOG_SYS, "ERR 6305: "
+ "Can't open lid matrix file \'%s\': %m\n", file_name);
+ goto Exit;
+ }
+
+ lineno = 0;
+ p_sw = NULL;
+
+ while (fgets(line, sizeof(line) - 1, file) != NULL) {
+ char *p, *q;
+ lineno++;
+
+ p = line;
+ while (isspace(*p))
+ p++;
+
+ if (*p == '#')
+ continue;
+
+ if (!strncmp(p, "Switch", 6)) {
+ q = strstr(p, " guid 0x");
+ if (!q) {
+ OSM_LOG(&p_osm->log, OSM_LOG_ERROR,
+ "PARSE ERROR: %s:%u: "
+ "cannot parse switch definition\n",
+ file_name, lineno);
+ goto Exit;
+ }
+ p = q + 8;
+ guid = strtoull(p, &q, 16);
+ if (q == p || !isspace(*q)) {
+ OSM_LOG(&p_osm->log, OSM_LOG_ERROR,
+ "PARSE ERROR: %s:%u: "
+ "cannot parse switch guid: \'%s\'\n",
+ file_name, lineno, p);
+ goto Exit;
+ }
+ guid = cl_hton64(guid);
+
+ p_sw = osm_get_switch_by_guid(&p_osm->subn, guid);
+ if (!p_sw) {
+ OSM_LOG(&p_osm->log, OSM_LOG_VERBOSE,
+ "cannot find switch %016" PRIx64 "\n",
+ cl_ntoh64(guid));
+ continue;
+ }
+ } else if (p_sw && !strncmp(p, "0x", 2)) {
+ unsigned long num;
+ unsigned len = 0;
+
+ memset(hops, 0xff, sizeof(hops));
+
+ p += 2;
+ num = strtoul(p, &q, 16);
+ if (num > 0xffff || q == p ||
+ (*q != ':' && !isspace(*q))) {
+ OSM_LOG(&p_osm->log, OSM_LOG_ERROR,
+ "PARSE ERROR: %s:%u: "
+ "cannot parse lid: \'%s\'\n",
+ file_name, lineno, p);
+ goto Exit;
+ }
+ /* Just checked the range, so casting is safe */
+ lid = (uint16_t) num;
+ p = q;
+ while (isspace(*p) || *p == ':')
+ p++;
+ while (len < 256 && *p && *p != '#') {
+ num = strtoul(p, &q, 16);
+ if (num > 0xff || q == p) {
+ OSM_LOG(&p_osm->log, OSM_LOG_ERROR,
+ "PARSE ERROR: %s:%u: "
+ "cannot parse hops number: \'%s\'\n",
+ file_name, lineno, p);
+ goto Exit;
+ }
+ /* Just checked the range, so casting is safe */
+ hops[len++] = (uint8_t) num;
+ p = q;
+ while (isspace(*p))
+ p++;
+ }
+ /* additionally try to extract guid */
+ q = strstr(p, " portguid 0x");
+ if (!q) {
+ OSM_LOG(&p_osm->log, OSM_LOG_VERBOSE,
+ "PARSE WARNING: %s:%u: "
+ "cannot find port guid "
+ "(maybe broken dump): \'%s\'\n",
+ file_name, lineno, p);
+ guid = 0;
+ } else {
+ p = q + 12;
+ guid = strtoull(p, &q, 16);
+ if (q == p || !isspace(*q)) {
+ OSM_LOG(&p_osm->log, OSM_LOG_VERBOSE,
+ "PARSE WARNING: %s:%u: "
+ "cannot parse port guid "
+ "(maybe broken dump): \'%s\'\n",
+ file_name, lineno, p);
+ guid = 0;
+ }
+ }
+ guid = cl_hton64(guid);
+ add_lid_hops(p_osm, p_sw, lid, guid, hops, len);
+ }
+ }
+ status = 0;
+Exit:
+ if (file)
+ fclose(file);
+ return status;
+}
+
+int osm_ucast_file_setup(struct osm_routing_engine *r, osm_opensm_t *osm)
+{
+ r->context = osm;
+ r->build_lid_matrices = do_lid_matrix_file_load;
+ r->ucast_build_fwd_tables = do_ucast_file_load;
+ return 0;
+}
diff --git a/contrib/ofed/opensm/opensm/osm_ucast_ftree.c b/contrib/ofed/opensm/opensm/osm_ucast_ftree.c
new file mode 100644
index 0000000..58980b4
--- /dev/null
+++ b/contrib/ofed/opensm/opensm/osm_ucast_ftree.c
@@ -0,0 +1,4340 @@
+/*
+ * Copyright (c) 2009 Simula Research Laboratory. All rights reserved.
+ * Copyright (c) 2009 Sun Microsystems, Inc. All rights reserved.
+ * Copyright (c) 2004-2009 Voltaire, Inc. All rights reserved.
+ * Copyright (c) 2002-2011 Mellanox Technologies LTD. All rights reserved.
+ * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+/*
+ * Abstract:
+ * Implementation of OpenSM FatTree routing
+ */
+
+#if HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include <stdlib.h>
+#include <string.h>
+#include <ctype.h>
+#include <errno.h>
+#include <iba/ib_types.h>
+#include <complib/cl_qmap.h>
+#include <complib/cl_debug.h>
+#include <opensm/osm_file_ids.h>
+#define FILE_ID OSM_FILE_UCAST_FTREE_C
+#include <opensm/osm_opensm.h>
+#include <opensm/osm_switch.h>
+
+/*
+ * FatTree rank is bounded between 2 and 8:
+ * - Tree of rank 1 has only trivial routing paths,
+ * so no need to use FatTree routing.
+ * - Why maximum rank is 8:
+ * Each node (switch) is assigned a unique tuple.
+ * Switches are stored in two cl_qmaps - one is
+ * ordered by guid, and the other by a key that is
+ * generated from tuple. Since cl_qmap supports only
+ * a 64-bit key, the maximal tuple length is 8 bytes.
+ * which means that maximal tree rank is 8.
+ * Note that the above also implies that each switch
+ * can have at max 255 up/down ports.
+ */
+
+#define FAT_TREE_MIN_RANK 2
+#define FAT_TREE_MAX_RANK 8
+
+typedef enum {
+ FTREE_DIRECTION_DOWN = -1,
+ FTREE_DIRECTION_SAME,
+ FTREE_DIRECTION_UP
+} ftree_direction_t;
+
+/***************************************************
+ **
+ ** Forward references
+ **
+ ***************************************************/
+struct ftree_sw_t_;
+struct ftree_hca_t_;
+struct ftree_port_t_;
+struct ftree_port_group_t_;
+struct ftree_fabric_t_;
+
+/***************************************************
+ **
+ ** ftree_tuple_t definition
+ **
+ ***************************************************/
+
+#define FTREE_TUPLE_BUFF_LEN 1024
+#define FTREE_TUPLE_LEN 8
+
+typedef uint8_t ftree_tuple_t[FTREE_TUPLE_LEN];
+typedef uint64_t ftree_tuple_key_t;
+
+/***************************************************
+ **
+ ** ftree_sw_table_element_t definition
+ **
+ ***************************************************/
+
+typedef struct {
+ cl_map_item_t map_item;
+ struct ftree_sw_t_ *p_sw;
+} ftree_sw_tbl_element_t;
+
+/***************************************************
+ **
+ ** ftree_port_t definition
+ **
+ ***************************************************/
+
+typedef struct ftree_port_t_ {
+ cl_map_item_t map_item;
+ uint8_t port_num; /* port number on the current node */
+ uint8_t remote_port_num; /* port number on the remote node */
+ uint32_t counter_up; /* number of allocated routes upwards */
+ uint32_t counter_down; /* number of allocated routes downwards */
+} ftree_port_t;
+
+/***************************************************
+ **
+ ** ftree_port_group_t definition
+ **
+ ***************************************************/
+
+typedef union ftree_hca_or_sw_ {
+ struct ftree_hca_t_ *p_hca;
+ struct ftree_sw_t_ *p_sw;
+} ftree_hca_or_sw;
+
+typedef struct ftree_port_group_t_ {
+ cl_map_item_t map_item;
+ uint16_t lid; /* lid of the current node */
+ uint16_t remote_lid; /* lid of the remote node */
+ ib_net64_t port_guid; /* port guid of this port */
+ ib_net64_t node_guid; /* this node's guid */
+ uint8_t node_type; /* this node's type */
+ ib_net64_t remote_port_guid; /* port guid of the remote port */
+ ib_net64_t remote_node_guid; /* node guid of the remote node */
+ uint8_t remote_node_type; /* IB_NODE_TYPE_{CA,SWITCH,ROUTER,...} */
+ ftree_hca_or_sw hca_or_sw; /* pointer to this hca/switch */
+ ftree_hca_or_sw remote_hca_or_sw; /* pointer to remote hca/switch */
+ cl_ptr_vector_t ports; /* vector of ports to the same lid */
+ boolean_t is_cn; /* whether this port is a compute node */
+ boolean_t is_io; /* whether this port is an I/O node */
+ uint32_t counter_down; /* number of allocated routes downwards */
+ uint32_t counter_up; /* number of allocated routes upwards */
+} ftree_port_group_t;
+
+/***************************************************
+ **
+ ** ftree_sw_t definition
+ **
+ ***************************************************/
+
+typedef struct ftree_sw_t_ {
+ cl_map_item_t map_item;
+ osm_switch_t *p_osm_sw;
+ uint32_t rank;
+ ftree_tuple_t tuple;
+ uint16_t lid;
+ ftree_port_group_t **down_port_groups;
+ uint8_t down_port_groups_num;
+ ftree_port_group_t **sibling_port_groups;
+ uint8_t sibling_port_groups_num;
+ ftree_port_group_t **up_port_groups;
+ uint8_t up_port_groups_num;
+ boolean_t is_leaf;
+ unsigned down_port_groups_idx;
+ uint8_t *hops;
+ uint32_t min_counter_down;
+ boolean_t counter_up_changed;
+} ftree_sw_t;
+
+/***************************************************
+ **
+ ** ftree_hca_t definition
+ **
+ ***************************************************/
+
+typedef struct ftree_hca_t_ {
+ cl_map_item_t map_item;
+ osm_node_t *p_osm_node;
+ ftree_port_group_t **up_port_groups;
+ uint8_t *disconnected_ports;
+ uint16_t up_port_groups_num;
+ unsigned cn_num;
+} ftree_hca_t;
+
+/***************************************************
+ **
+ ** ftree_fabric_t definition
+ **
+ ***************************************************/
+
+typedef struct ftree_fabric_t_ {
+ osm_opensm_t *p_osm;
+ osm_subn_t *p_subn;
+ cl_qmap_t hca_tbl;
+ cl_qmap_t sw_tbl;
+ cl_qmap_t sw_by_tuple_tbl;
+ cl_qmap_t cn_guid_tbl;
+ cl_qmap_t io_guid_tbl;
+ unsigned cn_num;
+ unsigned ca_ports;
+ uint8_t leaf_switch_rank;
+ uint8_t max_switch_rank;
+ ftree_sw_t **leaf_switches;
+ uint32_t leaf_switches_num;
+ uint16_t max_cn_per_leaf;
+ uint16_t lft_max_lid;
+ boolean_t fabric_built;
+} ftree_fabric_t;
+
+static inline osm_subn_t *ftree_get_subnet(IN ftree_fabric_t * p_ftree)
+{
+ return p_ftree->p_subn;
+}
+
+/***************************************************
+ **
+ ** comparators
+ **
+ ***************************************************/
+
+static int compare_switches_by_index(IN const void *p1, IN const void *p2)
+{
+ ftree_sw_t **pp_sw1 = (ftree_sw_t **) p1;
+ ftree_sw_t **pp_sw2 = (ftree_sw_t **) p2;
+
+ uint16_t i;
+ for (i = 0; i < FTREE_TUPLE_LEN; i++) {
+ if ((*pp_sw1)->tuple[i] > (*pp_sw2)->tuple[i])
+ return 1;
+ if ((*pp_sw1)->tuple[i] < (*pp_sw2)->tuple[i])
+ return -1;
+ }
+ return 0;
+}
+
+/***************************************************/
+
+static int
+compare_port_groups_by_remote_switch_index(IN const void *p1, IN const void *p2)
+{
+ ftree_port_group_t **pp_g1 = (ftree_port_group_t **) p1;
+ ftree_port_group_t **pp_g2 = (ftree_port_group_t **) p2;
+
+ return
+ compare_switches_by_index(&((*pp_g1)->remote_hca_or_sw.p_sw),
+ &((*pp_g2)->remote_hca_or_sw.p_sw));
+}
+
+/***************************************************
+ **
+ ** ftree_tuple_t functions
+ **
+ ***************************************************/
+
+static void tuple_init(IN ftree_tuple_t tuple)
+{
+ memset(tuple, 0xFF, FTREE_TUPLE_LEN);
+}
+
+/***************************************************/
+
+static inline boolean_t tuple_assigned(IN ftree_tuple_t tuple)
+{
+ return (tuple[0] != 0xFF);
+}
+
+/***************************************************/
+
+#define FTREE_TUPLE_BUFFERS_NUM 6
+
+static const char *tuple_to_str(IN ftree_tuple_t tuple)
+{
+ static char buffer[FTREE_TUPLE_BUFFERS_NUM][FTREE_TUPLE_BUFF_LEN];
+ static uint8_t ind = 0;
+ char *ret_buffer;
+ uint32_t i;
+
+ if (!tuple_assigned(tuple))
+ return "INDEX.NOT.ASSIGNED";
+
+ buffer[ind][0] = '\0';
+
+ for (i = 0; (i < FTREE_TUPLE_LEN) && (tuple[i] != 0xFF); i++) {
+ if ((strlen(buffer[ind]) + 10) > FTREE_TUPLE_BUFF_LEN)
+ return "INDEX.TOO.LONG";
+ if (i != 0)
+ strcat(buffer[ind], ".");
+ sprintf(&buffer[ind][strlen(buffer[ind])], "%u", tuple[i]);
+ }
+
+ ret_buffer = buffer[ind];
+ ind = (ind + 1) % FTREE_TUPLE_BUFFERS_NUM;
+ return ret_buffer;
+} /* tuple_to_str() */
+
+/***************************************************/
+
+static inline ftree_tuple_key_t tuple_to_key(IN ftree_tuple_t tuple)
+{
+ ftree_tuple_key_t key;
+ memcpy(&key, tuple, FTREE_TUPLE_LEN);
+ return key;
+}
+
+/***************************************************/
+
+static inline void tuple_from_key(IN ftree_tuple_t tuple,
+ IN ftree_tuple_key_t key)
+{
+ memcpy(tuple, &key, FTREE_TUPLE_LEN);
+}
+
+/***************************************************
+ **
+ ** ftree_sw_tbl_element_t functions
+ **
+ ***************************************************/
+
+static ftree_sw_tbl_element_t *sw_tbl_element_create(IN ftree_sw_t * p_sw)
+{
+ ftree_sw_tbl_element_t *p_element =
+ (ftree_sw_tbl_element_t *) malloc(sizeof(ftree_sw_tbl_element_t));
+ if (!p_element)
+ return NULL;
+ memset(p_element, 0, sizeof(ftree_sw_tbl_element_t));
+
+ p_element->p_sw = p_sw;
+ return p_element;
+}
+
+/***************************************************/
+
+static void sw_tbl_element_destroy(IN ftree_sw_tbl_element_t * p_element)
+{
+ free(p_element);
+}
+
+/***************************************************
+ **
+ ** ftree_port_t functions
+ **
+ ***************************************************/
+
+static ftree_port_t *port_create(IN uint8_t port_num,
+ IN uint8_t remote_port_num)
+{
+ ftree_port_t *p_port = (ftree_port_t *) malloc(sizeof(ftree_port_t));
+ if (!p_port)
+ return NULL;
+ memset(p_port, 0, sizeof(ftree_port_t));
+
+ p_port->port_num = port_num;
+ p_port->remote_port_num = remote_port_num;
+
+ return p_port;
+}
+
+/***************************************************/
+
+static void port_destroy(IN ftree_port_t * p_port)
+{
+ free(p_port);
+}
+
+/***************************************************
+ **
+ ** ftree_port_group_t functions
+ **
+ ***************************************************/
+
+static ftree_port_group_t *port_group_create(IN uint16_t lid,
+ IN uint16_t remote_lid,
+ IN ib_net64_t port_guid,
+ IN ib_net64_t node_guid,
+ IN uint8_t node_type,
+ IN void *p_hca_or_sw,
+ IN ib_net64_t remote_port_guid,
+ IN ib_net64_t remote_node_guid,
+ IN uint8_t remote_node_type,
+ IN void *p_remote_hca_or_sw,
+ IN boolean_t is_cn,
+ IN boolean_t is_io)
+{
+ ftree_port_group_t *p_group =
+ (ftree_port_group_t *) malloc(sizeof(ftree_port_group_t));
+ if (p_group == NULL)
+ return NULL;
+ memset(p_group, 0, sizeof(ftree_port_group_t));
+
+ p_group->lid = lid;
+ p_group->remote_lid = remote_lid;
+ memcpy(&p_group->port_guid, &port_guid, sizeof(ib_net64_t));
+ memcpy(&p_group->node_guid, &node_guid, sizeof(ib_net64_t));
+ memcpy(&p_group->remote_port_guid, &remote_port_guid,
+ sizeof(ib_net64_t));
+ memcpy(&p_group->remote_node_guid, &remote_node_guid,
+ sizeof(ib_net64_t));
+
+ p_group->node_type = node_type;
+ switch (node_type) {
+ case IB_NODE_TYPE_CA:
+ p_group->hca_or_sw.p_hca = (ftree_hca_t *) p_hca_or_sw;
+ break;
+ case IB_NODE_TYPE_SWITCH:
+ p_group->hca_or_sw.p_sw = (ftree_sw_t *) p_hca_or_sw;
+ break;
+ default:
+ /* we shouldn't get here - port is created only in hca or switch */
+ CL_ASSERT(0);
+ }
+
+ p_group->remote_node_type = remote_node_type;
+ switch (remote_node_type) {
+ case IB_NODE_TYPE_CA:
+ p_group->remote_hca_or_sw.p_hca =
+ (ftree_hca_t *) p_remote_hca_or_sw;
+ break;
+ case IB_NODE_TYPE_SWITCH:
+ p_group->remote_hca_or_sw.p_sw =
+ (ftree_sw_t *) p_remote_hca_or_sw;
+ break;
+ default:
+ /* we shouldn't get here - port is created only in hca or switch */
+ CL_ASSERT(0);
+ }
+
+ cl_ptr_vector_init(&p_group->ports, 0, /* min size */
+ 8); /* grow size */
+ p_group->is_cn = is_cn;
+ p_group->is_io = is_io;
+ return p_group;
+} /* port_group_create() */
+
+/***************************************************/
+
+static void port_group_destroy(IN ftree_port_group_t * p_group)
+{
+ uint32_t i;
+ uint32_t size;
+ ftree_port_t *p_port;
+
+ if (!p_group)
+ return;
+
+ /* remove all the elements of p_group->ports vector */
+ size = cl_ptr_vector_get_size(&p_group->ports);
+ for (i = 0; i < size; i++)
+ if (cl_ptr_vector_at(&p_group->ports, i, (void *)&p_port) == CL_SUCCESS)
+ port_destroy(p_port);
+
+ cl_ptr_vector_destroy(&p_group->ports);
+ free(p_group);
+} /* port_group_destroy() */
+
+/***************************************************/
+
+static void port_group_dump(IN ftree_fabric_t * p_ftree,
+ IN ftree_port_group_t * p_group,
+ IN ftree_direction_t direction)
+{
+ ftree_port_t *p_port;
+ uint32_t size;
+ uint32_t i;
+ char *buff;
+
+ if (!p_group)
+ return;
+
+ if (!OSM_LOG_IS_ACTIVE_V2(&p_ftree->p_osm->log, OSM_LOG_DEBUG))
+ return;
+
+ size = cl_ptr_vector_get_size(&p_group->ports);
+
+ buff = calloc(10, 1024);
+ if (!buff) {
+ OSM_LOG(&p_ftree->p_osm->log, OSM_LOG_ERROR, "ERR AB33: "
+ "Failed to allocate buffer\n");
+ return;
+ }
+
+ for (i = 0; i < size; i++) {
+ cl_ptr_vector_at(&p_group->ports, i, (void *)&p_port);
+ CL_ASSERT(p_port);
+
+ if (i != 0)
+ strcat(buff, ", ");
+ sprintf(buff + strlen(buff), "%u", p_port->port_num);
+ }
+
+ OSM_LOG(&p_ftree->p_osm->log, OSM_LOG_DEBUG,
+ " Port Group of size %u, port(s): %s, direction: %s\n"
+ " Local <--> Remote GUID (LID):"
+ "0x%016" PRIx64 " (0x%04x) <--> 0x%016" PRIx64 " (0x%04x)\n",
+ size, buff,
+ (direction == FTREE_DIRECTION_DOWN) ? "DOWN" : (direction ==
+ FTREE_DIRECTION_SAME)
+ ? "SIBLING" : "UP", cl_ntoh64(p_group->port_guid),
+ p_group->lid, cl_ntoh64(p_group->remote_port_guid),
+ p_group->remote_lid);
+
+ free(buff);
+
+} /* port_group_dump() */
+
+/***************************************************/
+
+static void port_group_add_port(IN ftree_port_group_t * p_group,
+ IN uint8_t port_num, IN uint8_t remote_port_num)
+{
+ uint16_t i;
+ ftree_port_t *p_port;
+
+ for (i = 0; i < cl_ptr_vector_get_size(&p_group->ports); i++) {
+ cl_ptr_vector_at(&p_group->ports, i, (void *)&p_port);
+ if (p_port->port_num == port_num)
+ return;
+ }
+
+ p_port = port_create(port_num, remote_port_num);
+ CL_ASSERT(p_port);
+ cl_ptr_vector_insert(&p_group->ports, p_port, NULL);
+}
+
+/***************************************************
+ **
+ ** ftree_sw_t functions
+ **
+ ***************************************************/
+
+static ftree_sw_t *sw_create(IN osm_switch_t * p_osm_sw)
+{
+ ftree_sw_t *p_sw;
+ uint8_t ports_num;
+
+ /* make sure that the switch has ports */
+ if (p_osm_sw->num_ports == 1)
+ return NULL;
+
+ p_sw = (ftree_sw_t *) malloc(sizeof(ftree_sw_t));
+ if (p_sw == NULL)
+ return NULL;
+ memset(p_sw, 0, sizeof(ftree_sw_t));
+
+ p_sw->p_osm_sw = p_osm_sw;
+ p_sw->rank = 0xFFFFFFFF;
+ tuple_init(p_sw->tuple);
+
+ p_sw->lid =
+ cl_ntoh16(osm_node_get_base_lid(p_sw->p_osm_sw->p_node, 0));
+
+ ports_num = osm_node_get_num_physp(p_sw->p_osm_sw->p_node);
+ p_sw->down_port_groups =
+ (ftree_port_group_t **) malloc(ports_num *
+ sizeof(ftree_port_group_t *));
+ if (p_sw->down_port_groups == NULL)
+ goto FREE_P_SW;
+ memset(p_sw->down_port_groups, 0, ports_num * sizeof(ftree_port_group_t *));
+
+ p_sw->up_port_groups =
+ (ftree_port_group_t **) malloc(ports_num *
+ sizeof(ftree_port_group_t *));
+ if (p_sw->up_port_groups == NULL)
+ goto FREE_DOWN;
+ memset(p_sw->up_port_groups, 0, ports_num * sizeof(ftree_port_group_t *));
+
+ p_sw->sibling_port_groups =
+ (ftree_port_group_t **) malloc(ports_num *
+ sizeof(ftree_port_group_t *));
+ if (p_sw->sibling_port_groups == NULL)
+ goto FREE_UP;
+ memset(p_sw->sibling_port_groups, 0, ports_num * sizeof(ftree_port_group_t *));
+
+ /* initialize lft buffer */
+ memset(p_osm_sw->new_lft, OSM_NO_PATH, p_osm_sw->lft_size);
+ p_sw->hops = malloc((p_osm_sw->max_lid_ho + 1) * sizeof(*(p_sw->hops)));
+ if (p_sw->hops == NULL)
+ goto FREE_SIBLING;
+
+ memset(p_sw->hops, OSM_NO_PATH, p_osm_sw->max_lid_ho + 1);
+
+ return p_sw;
+
+FREE_SIBLING:
+ free(p_sw->sibling_port_groups);
+FREE_UP:
+ free(p_sw->up_port_groups);
+FREE_DOWN:
+ free(p_sw->down_port_groups);
+FREE_P_SW:
+ free(p_sw);
+ return NULL;
+} /* sw_create() */
+
+/***************************************************/
+
+static void sw_destroy(IN ftree_sw_t * p_sw)
+{
+ uint8_t i;
+
+ if (!p_sw)
+ return;
+ free(p_sw->hops);
+
+ for (i = 0; i < p_sw->down_port_groups_num; i++)
+ port_group_destroy(p_sw->down_port_groups[i]);
+ for (i = 0; i < p_sw->sibling_port_groups_num; i++)
+ port_group_destroy(p_sw->sibling_port_groups[i]);
+ for (i = 0; i < p_sw->up_port_groups_num; i++)
+ port_group_destroy(p_sw->up_port_groups[i]);
+ free(p_sw->down_port_groups);
+ free(p_sw->sibling_port_groups);
+ free(p_sw->up_port_groups);
+
+ free(p_sw);
+} /* sw_destroy() */
+
+/***************************************************/
+
+static uint64_t sw_get_guid_no(IN ftree_sw_t * p_sw)
+{
+ if (!p_sw)
+ return 0;
+ return osm_node_get_node_guid(p_sw->p_osm_sw->p_node);
+}
+
+/***************************************************/
+
+static uint64_t sw_get_guid_ho(IN ftree_sw_t * p_sw)
+{
+ return cl_ntoh64(sw_get_guid_no(p_sw));
+}
+
+/***************************************************/
+
+static void sw_dump(IN ftree_fabric_t * p_ftree, IN ftree_sw_t * p_sw)
+{
+ uint32_t i;
+
+ if (!p_sw)
+ return;
+
+ if (!OSM_LOG_IS_ACTIVE_V2(&p_ftree->p_osm->log, OSM_LOG_DEBUG))
+ return;
+
+ OSM_LOG(&p_ftree->p_osm->log, OSM_LOG_DEBUG,
+ "Switch index: %s, GUID: 0x%016" PRIx64
+ ", Ports: %u DOWN, %u SIBLINGS, %u UP\n",
+ tuple_to_str(p_sw->tuple), sw_get_guid_ho(p_sw),
+ p_sw->down_port_groups_num, p_sw->sibling_port_groups_num,
+ p_sw->up_port_groups_num);
+
+ for (i = 0; i < p_sw->down_port_groups_num; i++)
+ port_group_dump(p_ftree, p_sw->down_port_groups[i],
+ FTREE_DIRECTION_DOWN);
+ for (i = 0; i < p_sw->sibling_port_groups_num; i++)
+ port_group_dump(p_ftree, p_sw->sibling_port_groups[i],
+ FTREE_DIRECTION_SAME);
+ for (i = 0; i < p_sw->up_port_groups_num; i++)
+ port_group_dump(p_ftree, p_sw->up_port_groups[i],
+ FTREE_DIRECTION_UP);
+
+} /* sw_dump() */
+
+/***************************************************/
+
+static boolean_t sw_ranked(IN ftree_sw_t * p_sw)
+{
+ return (p_sw->rank != 0xFFFFFFFF);
+}
+
+/***************************************************/
+
+static ftree_port_group_t *sw_get_port_group_by_remote_lid(IN ftree_sw_t * p_sw,
+ IN uint16_t
+ remote_lid,
+ IN ftree_direction_t
+ direction)
+{
+ uint32_t i;
+ uint32_t size;
+ ftree_port_group_t **port_groups;
+
+ if (direction == FTREE_DIRECTION_UP) {
+ port_groups = p_sw->up_port_groups;
+ size = p_sw->up_port_groups_num;
+ } else if (direction == FTREE_DIRECTION_SAME) {
+ port_groups = p_sw->sibling_port_groups;
+ size = p_sw->sibling_port_groups_num;
+ } else {
+ port_groups = p_sw->down_port_groups;
+ size = p_sw->down_port_groups_num;
+ }
+
+ for (i = 0; i < size; i++)
+ if (remote_lid == port_groups[i]->remote_lid)
+ return port_groups[i];
+
+ return NULL;
+} /* sw_get_port_group_by_remote_lid() */
+
+/***************************************************/
+
+static void sw_add_port(IN ftree_sw_t * p_sw, IN uint8_t port_num,
+ IN uint8_t remote_port_num, IN uint16_t lid,
+ IN uint16_t remote_lid, IN ib_net64_t port_guid,
+ IN ib_net64_t remote_port_guid,
+ IN ib_net64_t remote_node_guid,
+ IN uint8_t remote_node_type,
+ IN void *p_remote_hca_or_sw,
+ IN ftree_direction_t direction)
+{
+ ftree_port_group_t *p_group =
+ sw_get_port_group_by_remote_lid(p_sw, remote_lid, direction);
+
+ if (!p_group) {
+ p_group = port_group_create(lid, remote_lid,
+ port_guid, sw_get_guid_no(p_sw),
+ IB_NODE_TYPE_SWITCH, p_sw,
+ remote_port_guid, remote_node_guid,
+ remote_node_type,
+ p_remote_hca_or_sw, FALSE, FALSE);
+ CL_ASSERT(p_group);
+
+ if (direction == FTREE_DIRECTION_UP) {
+ p_sw->up_port_groups[p_sw->up_port_groups_num++] =
+ p_group;
+ } else if (direction == FTREE_DIRECTION_SAME) {
+ p_sw->
+ sibling_port_groups[p_sw->sibling_port_groups_num++]
+ = p_group;
+ } else
+ p_sw->down_port_groups[p_sw->down_port_groups_num++] =
+ p_group;
+ }
+ port_group_add_port(p_group, port_num, remote_port_num);
+
+} /* sw_add_port() */
+
+/***************************************************/
+
+static inline cl_status_t sw_set_hops(IN ftree_sw_t * p_sw, IN uint16_t lid,
+ IN uint8_t port_num, IN uint8_t hops,
+ IN boolean_t is_target_sw)
+{
+ /* set local min hop table(LID) */
+ p_sw->hops[lid] = hops;
+ if (is_target_sw)
+ return osm_switch_set_hops(p_sw->p_osm_sw, lid, port_num, hops);
+ return 0;
+}
+
+/***************************************************/
+
+static int set_hops_on_remote_sw(IN ftree_port_group_t * p_group,
+ IN uint16_t target_lid, IN uint8_t hops,
+ IN boolean_t is_target_sw)
+{
+ ftree_port_t *p_port;
+ uint8_t i, ports_num;
+ ftree_sw_t *p_remote_sw = p_group->remote_hca_or_sw.p_sw;
+
+ /* if lid is a switch, we set the min hop table in the osm_switch struct */
+ CL_ASSERT(p_group->remote_node_type == IB_NODE_TYPE_SWITCH);
+ p_remote_sw->hops[target_lid] = hops;
+
+ /* If target lid is a switch we set the min hop table values
+ * for each port on the associated osm_sw struct */
+ if (!is_target_sw)
+ return 0;
+
+ ports_num = (uint8_t) cl_ptr_vector_get_size(&p_group->ports);
+ for (i = 0; i < ports_num; i++) {
+ cl_ptr_vector_at(&p_group->ports, i, (void *)&p_port);
+ if (sw_set_hops(p_remote_sw, target_lid,
+ p_port->remote_port_num, hops, is_target_sw))
+ return -1;
+ }
+ return 0;
+}
+
+/***************************************************/
+
+static inline uint8_t
+sw_get_least_hops(IN ftree_sw_t * p_sw, IN uint16_t target_lid)
+{
+ CL_ASSERT(p_sw->hops != NULL);
+ return p_sw->hops[target_lid];
+}
+
+/***************************************************
+ **
+ ** ftree_hca_t functions
+ **
+ ***************************************************/
+
+static ftree_hca_t *hca_create(IN osm_node_t * p_osm_node)
+{
+ ftree_hca_t *p_hca = (ftree_hca_t *) malloc(sizeof(ftree_hca_t));
+ if (p_hca == NULL)
+ return NULL;
+ memset(p_hca, 0, sizeof(ftree_hca_t));
+
+ p_hca->p_osm_node = p_osm_node;
+ p_hca->up_port_groups = (ftree_port_group_t **)
+ malloc(osm_node_get_num_physp(p_hca->p_osm_node) *
+ sizeof(ftree_port_group_t *));
+ if (!p_hca->up_port_groups) {
+ free(p_hca);
+ return NULL;
+ }
+ memset(p_hca->up_port_groups, 0, osm_node_get_num_physp(p_hca->p_osm_node) *
+ sizeof(ftree_port_group_t *));
+
+ p_hca->disconnected_ports = (uint8_t *)
+ calloc(osm_node_get_num_physp(p_hca->p_osm_node) + 1, sizeof(uint8_t));
+ if (!p_hca->disconnected_ports) {
+ free(p_hca->up_port_groups);
+ free(p_hca);
+ return NULL;
+ }
+ p_hca->up_port_groups_num = 0;
+ return p_hca;
+}
+
+/***************************************************/
+
+static void hca_destroy(IN ftree_hca_t * p_hca)
+{
+ uint32_t i;
+
+ if (!p_hca)
+ return;
+
+ for (i = 0; i < p_hca->up_port_groups_num; i++)
+ port_group_destroy(p_hca->up_port_groups[i]);
+
+ free(p_hca->up_port_groups);
+ free(p_hca->disconnected_ports);
+
+ free(p_hca);
+}
+
+/***************************************************/
+
+static uint64_t hca_get_guid_no(IN ftree_hca_t * p_hca)
+{
+ if (!p_hca)
+ return 0;
+ return osm_node_get_node_guid(p_hca->p_osm_node);
+}
+
+/***************************************************/
+
+static uint64_t hca_get_guid_ho(IN ftree_hca_t * p_hca)
+{
+ return cl_ntoh64(hca_get_guid_no(p_hca));
+}
+
+/***************************************************/
+
+static void hca_dump(IN ftree_fabric_t * p_ftree, IN ftree_hca_t * p_hca)
+{
+ uint32_t i;
+
+ if (!p_hca)
+ return;
+
+ if (!OSM_LOG_IS_ACTIVE_V2(&p_ftree->p_osm->log, OSM_LOG_DEBUG))
+ return;
+
+ OSM_LOG(&p_ftree->p_osm->log, OSM_LOG_DEBUG,
+ "CA GUID: 0x%016" PRIx64 ", Ports: %u UP\n",
+ hca_get_guid_ho(p_hca), p_hca->up_port_groups_num);
+
+ for (i = 0; i < p_hca->up_port_groups_num; i++)
+ port_group_dump(p_ftree, p_hca->up_port_groups[i],
+ FTREE_DIRECTION_UP);
+}
+
+static ftree_port_group_t *hca_get_port_group_by_lid(IN ftree_hca_t *
+ p_hca,
+ IN uint16_t
+ lid)
+{
+ uint32_t i;
+ for (i = 0; i < p_hca->up_port_groups_num; i++)
+ if (lid ==
+ p_hca->up_port_groups[i]->lid)
+ return p_hca->up_port_groups[i];
+
+ return NULL;
+}
+/***************************************************/
+
+static void hca_add_port(IN ftree_fabric_t * p_ftree,
+ IN ftree_hca_t * p_hca, IN uint8_t port_num,
+ IN uint8_t remote_port_num, IN uint16_t lid,
+ IN uint16_t remote_lid, IN ib_net64_t port_guid,
+ IN ib_net64_t remote_port_guid,
+ IN ib_net64_t remote_node_guid,
+ IN uint8_t remote_node_type,
+ IN void *p_remote_hca_or_sw, IN boolean_t is_cn,
+ IN boolean_t is_io)
+{
+ ftree_port_group_t *p_group;
+
+ /* this function is supposed to be called only for adding ports
+ in hca's that lead to switches */
+ CL_ASSERT(remote_node_type == IB_NODE_TYPE_SWITCH);
+
+ p_group = hca_get_port_group_by_lid(p_hca, lid);
+
+ if (!p_group) {
+ p_group = port_group_create(lid, remote_lid,
+ port_guid, hca_get_guid_no(p_hca),
+ IB_NODE_TYPE_CA, p_hca,
+ remote_port_guid, remote_node_guid,
+ remote_node_type,
+ p_remote_hca_or_sw, is_cn, is_io);
+ CL_ASSERT(p_group);
+ p_hca->up_port_groups[p_hca->up_port_groups_num++] = p_group;
+ port_group_add_port(p_group, port_num, remote_port_num);
+ } else
+ OSM_LOG(&p_ftree->p_osm->log, OSM_LOG_ERROR,
+ "ERR AB32: Duplicated LID for CA GUID: 0x%016" PRIx64 "\n",
+ cl_ntoh64(port_guid));
+} /* hca_add_port() */
+
+/***************************************************
+ **
+ ** ftree_fabric_t functions
+ **
+ ***************************************************/
+
+static ftree_fabric_t *fabric_create()
+{
+ ftree_fabric_t *p_ftree =
+ (ftree_fabric_t *) malloc(sizeof(ftree_fabric_t));
+ if (p_ftree == NULL)
+ return NULL;
+
+ memset(p_ftree, 0, sizeof(ftree_fabric_t));
+
+ cl_qmap_init(&p_ftree->hca_tbl);
+ cl_qmap_init(&p_ftree->sw_tbl);
+ cl_qmap_init(&p_ftree->sw_by_tuple_tbl);
+ cl_qmap_init(&p_ftree->cn_guid_tbl);
+ cl_qmap_init(&p_ftree->io_guid_tbl);
+
+ return p_ftree;
+}
+
+/***************************************************/
+
+static void fabric_clear(ftree_fabric_t * p_ftree)
+{
+ ftree_hca_t *p_hca;
+ ftree_hca_t *p_next_hca;
+ ftree_sw_t *p_sw;
+ ftree_sw_t *p_next_sw;
+ ftree_sw_tbl_element_t *p_element;
+ ftree_sw_tbl_element_t *p_next_element;
+ name_map_item_t *p_guid_element, *p_next_guid_element;
+
+ if (!p_ftree)
+ return;
+
+ /* remove all the elements of hca_tbl */
+
+ p_next_hca = (ftree_hca_t *) cl_qmap_head(&p_ftree->hca_tbl);
+ while (p_next_hca != (ftree_hca_t *) cl_qmap_end(&p_ftree->hca_tbl)) {
+ p_hca = p_next_hca;
+ p_next_hca = (ftree_hca_t *) cl_qmap_next(&p_hca->map_item);
+ hca_destroy(p_hca);
+ }
+ cl_qmap_remove_all(&p_ftree->hca_tbl);
+
+ /* remove all the elements of sw_tbl */
+
+ p_next_sw = (ftree_sw_t *) cl_qmap_head(&p_ftree->sw_tbl);
+ while (p_next_sw != (ftree_sw_t *) cl_qmap_end(&p_ftree->sw_tbl)) {
+ p_sw = p_next_sw;
+ p_next_sw = (ftree_sw_t *) cl_qmap_next(&p_sw->map_item);
+ sw_destroy(p_sw);
+ }
+ cl_qmap_remove_all(&p_ftree->sw_tbl);
+
+ /* remove all the elements of sw_by_tuple_tbl */
+
+ p_next_element =
+ (ftree_sw_tbl_element_t *) cl_qmap_head(&p_ftree->sw_by_tuple_tbl);
+ while (p_next_element != (ftree_sw_tbl_element_t *)
+ cl_qmap_end(&p_ftree->sw_by_tuple_tbl)) {
+ p_element = p_next_element;
+ p_next_element = (ftree_sw_tbl_element_t *)
+ cl_qmap_next(&p_element->map_item);
+ sw_tbl_element_destroy(p_element);
+ }
+ cl_qmap_remove_all(&p_ftree->sw_by_tuple_tbl);
+
+ /* remove all the elements of cn_guid_tbl */
+ p_next_guid_element =
+ (name_map_item_t *) cl_qmap_head(&p_ftree->cn_guid_tbl);
+ while (p_next_guid_element !=
+ (name_map_item_t *) cl_qmap_end(&p_ftree->cn_guid_tbl)) {
+ p_guid_element = p_next_guid_element;
+ p_next_guid_element =
+ (name_map_item_t *) cl_qmap_next(&p_guid_element->item);
+ free(p_guid_element);
+ }
+ cl_qmap_remove_all(&p_ftree->cn_guid_tbl);
+
+ /* remove all the elements of io_guid_tbl */
+ p_next_guid_element =
+ (name_map_item_t *) cl_qmap_head(&p_ftree->io_guid_tbl);
+ while (p_next_guid_element !=
+ (name_map_item_t *) cl_qmap_end(&p_ftree->io_guid_tbl)) {
+ p_guid_element = p_next_guid_element;
+ p_next_guid_element =
+ (name_map_item_t *) cl_qmap_next(&p_guid_element->item);
+ free(p_guid_element);
+ }
+ cl_qmap_remove_all(&p_ftree->io_guid_tbl);
+
+ /* free the leaf switches array */
+ if ((p_ftree->leaf_switches_num > 0) && (p_ftree->leaf_switches))
+ free(p_ftree->leaf_switches);
+
+ p_ftree->leaf_switches_num = 0;
+ p_ftree->cn_num = 0;
+ p_ftree->ca_ports = 0;
+ p_ftree->leaf_switch_rank = 0;
+ p_ftree->max_switch_rank = 0;
+ p_ftree->max_cn_per_leaf = 0;
+ p_ftree->lft_max_lid = 0;
+ p_ftree->leaf_switches = NULL;
+ p_ftree->fabric_built = FALSE;
+
+} /* fabric_destroy() */
+
+/***************************************************/
+
+static void fabric_destroy(ftree_fabric_t * p_ftree)
+{
+ if (!p_ftree)
+ return;
+ fabric_clear(p_ftree);
+ free(p_ftree);
+}
+
+/***************************************************/
+
+static uint8_t fabric_get_rank(ftree_fabric_t * p_ftree)
+{
+ return p_ftree->leaf_switch_rank + 1;
+}
+
+/***************************************************/
+
+static void fabric_add_hca(ftree_fabric_t * p_ftree, osm_node_t * p_osm_node)
+{
+ ftree_hca_t *p_hca;
+
+ CL_ASSERT(osm_node_get_type(p_osm_node) == IB_NODE_TYPE_CA);
+
+ p_hca = hca_create(p_osm_node);
+ if (!p_hca)
+ return;
+
+ cl_qmap_insert(&p_ftree->hca_tbl, p_osm_node->node_info.node_guid,
+ &p_hca->map_item);
+}
+
+/***************************************************/
+
+static void fabric_add_sw(ftree_fabric_t * p_ftree, osm_switch_t * p_osm_sw)
+{
+ ftree_sw_t *p_sw;
+
+ CL_ASSERT(osm_node_get_type(p_osm_sw->p_node) == IB_NODE_TYPE_SWITCH);
+
+ p_sw = sw_create(p_osm_sw);
+ if (!p_sw)
+ return;
+
+ cl_qmap_insert(&p_ftree->sw_tbl, p_osm_sw->p_node->node_info.node_guid,
+ &p_sw->map_item);
+
+ /* track the max lid (in host order) that exists in the fabric */
+ if (p_sw->lid > p_ftree->lft_max_lid)
+ p_ftree->lft_max_lid = p_sw->lid;
+}
+
+/***************************************************/
+
+static void fabric_add_sw_by_tuple(IN ftree_fabric_t * p_ftree,
+ IN ftree_sw_t * p_sw)
+{
+ CL_ASSERT(tuple_assigned(p_sw->tuple));
+
+ cl_qmap_insert(&p_ftree->sw_by_tuple_tbl, tuple_to_key(p_sw->tuple),
+ &sw_tbl_element_create(p_sw)->map_item);
+}
+
+/***************************************************/
+
+static ftree_sw_t *fabric_get_sw_by_tuple(IN ftree_fabric_t * p_ftree,
+ IN ftree_tuple_t tuple)
+{
+ ftree_sw_tbl_element_t *p_element;
+
+ CL_ASSERT(tuple_assigned(tuple));
+
+ tuple_to_key(tuple);
+
+ p_element =
+ (ftree_sw_tbl_element_t *) cl_qmap_get(&p_ftree->sw_by_tuple_tbl,
+ tuple_to_key(tuple));
+ if (p_element ==
+ (ftree_sw_tbl_element_t *) cl_qmap_end(&p_ftree->sw_by_tuple_tbl))
+ return NULL;
+
+ return p_element->p_sw;
+}
+
+/***************************************************/
+
+static ftree_sw_t *fabric_get_sw_by_guid(IN ftree_fabric_t * p_ftree,
+ IN uint64_t guid)
+{
+ ftree_sw_t *p_sw;
+ p_sw = (ftree_sw_t *) cl_qmap_get(&p_ftree->sw_tbl, guid);
+ if (p_sw == (ftree_sw_t *) cl_qmap_end(&p_ftree->sw_tbl))
+ return NULL;
+ return p_sw;
+}
+
+/***************************************************/
+
+static ftree_hca_t *fabric_get_hca_by_guid(IN ftree_fabric_t * p_ftree,
+ IN uint64_t guid)
+{
+ ftree_hca_t *p_hca;
+ p_hca = (ftree_hca_t *) cl_qmap_get(&p_ftree->hca_tbl, guid);
+ if (p_hca == (ftree_hca_t *) cl_qmap_end(&p_ftree->hca_tbl))
+ return NULL;
+ return p_hca;
+}
+
+/***************************************************/
+
+static void fabric_dump(ftree_fabric_t * p_ftree)
+{
+ uint32_t i;
+ ftree_hca_t *p_hca;
+ ftree_sw_t *p_sw;
+
+ if (!OSM_LOG_IS_ACTIVE_V2(&p_ftree->p_osm->log, OSM_LOG_DEBUG))
+ return;
+
+ OSM_LOG(&p_ftree->p_osm->log, OSM_LOG_DEBUG, "\n"
+ " |-------------------------------|\n"
+ " |- Full fabric topology dump -|\n"
+ " |-------------------------------|\n\n");
+
+ OSM_LOG(&p_ftree->p_osm->log, OSM_LOG_DEBUG, "-- CAs:\n");
+
+ for (p_hca = (ftree_hca_t *) cl_qmap_head(&p_ftree->hca_tbl);
+ p_hca != (ftree_hca_t *) cl_qmap_end(&p_ftree->hca_tbl);
+ p_hca = (ftree_hca_t *) cl_qmap_next(&p_hca->map_item)) {
+ hca_dump(p_ftree, p_hca);
+ }
+
+ for (i = 0; i <= p_ftree->max_switch_rank; i++) {
+ OSM_LOG(&p_ftree->p_osm->log, OSM_LOG_DEBUG,
+ "-- Rank %u switches\n", i);
+ for (p_sw = (ftree_sw_t *) cl_qmap_head(&p_ftree->sw_tbl);
+ p_sw != (ftree_sw_t *) cl_qmap_end(&p_ftree->sw_tbl);
+ p_sw = (ftree_sw_t *) cl_qmap_next(&p_sw->map_item)) {
+ if (p_sw->rank == i)
+ sw_dump(p_ftree, p_sw);
+ }
+ }
+
+ OSM_LOG(&p_ftree->p_osm->log, OSM_LOG_DEBUG, "\n"
+ " |---------------------------------------|\n"
+ " |- Full fabric topology dump completed -|\n"
+ " |---------------------------------------|\n\n");
+} /* fabric_dump() */
+
+/***************************************************/
+
+static void fabric_dump_general_info(IN ftree_fabric_t * p_ftree)
+{
+ uint32_t i, j;
+ ftree_sw_t *p_sw;
+
+ OSM_LOG(&p_ftree->p_osm->log, OSM_LOG_INFO,
+ "General fabric topology info\n");
+ OSM_LOG(&p_ftree->p_osm->log, OSM_LOG_INFO,
+ "============================\n");
+
+ OSM_LOG(&p_ftree->p_osm->log, OSM_LOG_INFO,
+ " - FatTree rank (roots to leaf switches): %u\n",
+ p_ftree->leaf_switch_rank + 1);
+ OSM_LOG(&p_ftree->p_osm->log, OSM_LOG_INFO,
+ " - FatTree max switch rank: %u\n", p_ftree->max_switch_rank);
+ OSM_LOG(&p_ftree->p_osm->log, OSM_LOG_INFO,
+ " - Fabric has %u CAs, %u CA ports (%u of them CNs), %u switches\n",
+ cl_qmap_count(&p_ftree->hca_tbl), p_ftree->ca_ports,
+ p_ftree->cn_num, cl_qmap_count(&p_ftree->sw_tbl));
+
+ CL_ASSERT(p_ftree->ca_ports >= p_ftree->cn_num);
+
+ for (i = 0; i <= p_ftree->max_switch_rank; i++) {
+ j = 0;
+ for (p_sw = (ftree_sw_t *) cl_qmap_head(&p_ftree->sw_tbl);
+ p_sw != (ftree_sw_t *) cl_qmap_end(&p_ftree->sw_tbl);
+ p_sw = (ftree_sw_t *) cl_qmap_next(&p_sw->map_item)) {
+ if (p_sw->rank == i)
+ j++;
+ }
+ if (i == 0)
+ OSM_LOG(&p_ftree->p_osm->log, OSM_LOG_INFO,
+ " - Fabric has %u switches at rank %u (roots)\n",
+ j, i);
+ else if (i == p_ftree->leaf_switch_rank)
+ OSM_LOG(&p_ftree->p_osm->log, OSM_LOG_INFO,
+ " - Fabric has %u switches at rank %u (%u of them leafs)\n",
+ j, i, p_ftree->leaf_switches_num);
+ else
+ OSM_LOG(&p_ftree->p_osm->log, OSM_LOG_INFO,
+ " - Fabric has %u switches at rank %u\n", j,
+ i);
+ }
+
+ if (OSM_LOG_IS_ACTIVE_V2(&p_ftree->p_osm->log, OSM_LOG_VERBOSE)) {
+ OSM_LOG(&p_ftree->p_osm->log, OSM_LOG_VERBOSE,
+ " - Root switches:\n");
+ for (p_sw = (ftree_sw_t *) cl_qmap_head(&p_ftree->sw_tbl);
+ p_sw != (ftree_sw_t *) cl_qmap_end(&p_ftree->sw_tbl);
+ p_sw = (ftree_sw_t *) cl_qmap_next(&p_sw->map_item)) {
+ if (p_sw->rank == 0)
+ OSM_LOG(&p_ftree->p_osm->log, OSM_LOG_VERBOSE,
+ " GUID: 0x%016" PRIx64
+ ", LID: %u, Index %s\n",
+ sw_get_guid_ho(p_sw),
+ p_sw->lid,
+ tuple_to_str(p_sw->tuple));
+ }
+
+ OSM_LOG(&p_ftree->p_osm->log, OSM_LOG_VERBOSE,
+ " - Leaf switches (sorted by index):\n");
+ for (i = 0; i < p_ftree->leaf_switches_num; i++) {
+ OSM_LOG(&p_ftree->p_osm->log, OSM_LOG_VERBOSE,
+ " GUID: 0x%016" PRIx64
+ ", LID: %u, Index %s\n",
+ sw_get_guid_ho(p_ftree->leaf_switches[i]),
+ p_ftree->leaf_switches[i]->lid,
+ tuple_to_str(p_ftree->leaf_switches[i]->tuple));
+ }
+ }
+} /* fabric_dump_general_info() */
+
+/***************************************************/
+
+static void fabric_dump_hca_ordering(IN ftree_fabric_t * p_ftree)
+{
+ ftree_hca_t *p_hca;
+ ftree_sw_t *p_sw;
+ ftree_port_group_t *p_group_on_sw;
+ ftree_port_group_t *p_group_on_hca;
+ int rename_status = 0;
+ uint32_t i;
+ uint32_t j;
+ unsigned printed_hcas_on_leaf;
+
+ char path[1024], path_tmp[1032];
+ FILE *p_hca_ordering_file;
+ const char *filename = "opensm-ftree-ca-order.dump";
+
+ snprintf(path, sizeof(path), "%s/%s",
+ p_ftree->p_osm->subn.opt.dump_files_dir, filename);
+
+ snprintf(path_tmp, sizeof(path_tmp), "%s.tmp", path);
+
+ p_hca_ordering_file = fopen(path_tmp, "w");
+ if (!p_hca_ordering_file) {
+ OSM_LOG(&p_ftree->p_osm->log, OSM_LOG_ERROR, "ERR AB01: "
+ "cannot open file \'%s\': %s\n", path_tmp,
+ strerror(errno));
+ return;
+ }
+
+ /* for each leaf switch (in indexing order) */
+ for (i = 0; i < p_ftree->leaf_switches_num; i++) {
+ p_sw = p_ftree->leaf_switches[i];
+ printed_hcas_on_leaf = 0;
+
+ /* for each real CA (CNs and not) connected to this switch */
+ for (j = 0; j < p_sw->down_port_groups_num; j++) {
+ p_group_on_sw = p_sw->down_port_groups[j];
+
+ if (p_group_on_sw->remote_node_type != IB_NODE_TYPE_CA)
+ continue;
+
+ p_hca = p_group_on_sw->remote_hca_or_sw.p_hca;
+ p_group_on_hca =
+ hca_get_port_group_by_lid(p_hca,
+ p_group_on_sw->
+ remote_lid);
+
+ /* treat non-compute nodes as dummies */
+ if (!p_group_on_hca->is_cn)
+ continue;
+
+ fprintf(p_hca_ordering_file, "0x%04x\t%s\n",
+ p_group_on_hca->lid,
+ p_hca->p_osm_node->print_desc);
+
+ printed_hcas_on_leaf++;
+ }
+
+ /* now print missing HCAs */
+ for (j = 0;
+ j < (p_ftree->max_cn_per_leaf - printed_hcas_on_leaf); j++)
+ fprintf(p_hca_ordering_file, "0xFFFF\tDUMMY\n");
+
+ }
+ /* done going through all the leaf switches */
+
+ fclose(p_hca_ordering_file);
+
+ rename_status = rename(path_tmp, path);
+ if (rename_status) {
+ OSM_LOG(&p_ftree->p_osm->log, OSM_LOG_ERROR, "ERR AB03: "
+ "cannot rename file \'%s\': %s\n", path_tmp,
+ strerror(errno));
+ }
+} /* fabric_dump_hca_ordering() */
+
+/***************************************************/
+
+static void fabric_assign_tuple(IN ftree_fabric_t * p_ftree,
+ IN ftree_sw_t * p_sw,
+ IN ftree_tuple_t new_tuple)
+{
+ memcpy(p_sw->tuple, new_tuple, FTREE_TUPLE_LEN);
+ fabric_add_sw_by_tuple(p_ftree, p_sw);
+}
+
+/***************************************************/
+
+static void fabric_assign_first_tuple(IN ftree_fabric_t * p_ftree,
+ IN ftree_sw_t * p_sw,
+ IN unsigned int subtree)
+{
+ uint8_t i;
+ ftree_tuple_t new_tuple;
+
+ if (p_ftree->leaf_switch_rank >= FTREE_TUPLE_LEN)
+ return;
+
+ tuple_init(new_tuple);
+ new_tuple[0] = (uint8_t) p_sw->rank;
+
+ for (i = 1; i <= p_ftree->leaf_switch_rank; i++)
+ new_tuple[i] = 0;
+
+ if (p_sw->rank == 0) {
+ if (p_ftree->leaf_switch_rank > 1)
+ new_tuple[p_ftree->leaf_switch_rank] = subtree;
+
+ for (i = 0; i < 0xFF; i++) {
+ new_tuple[1] = i;
+ if (fabric_get_sw_by_tuple(p_ftree, new_tuple) == NULL)
+ break;
+ }
+ if (i == 0xFF) {
+ /* new tuple not found - there are more than 255 ports in one direction */
+ return;
+ }
+ }
+ fabric_assign_tuple(p_ftree, p_sw, new_tuple);
+}
+
+/***************************************************/
+
+static void fabric_get_new_tuple(IN ftree_fabric_t * p_ftree,
+ OUT ftree_tuple_t new_tuple,
+ IN ftree_tuple_t from_tuple,
+ IN ftree_direction_t direction)
+{
+ ftree_sw_t *p_sw;
+ ftree_tuple_t temp_tuple;
+ uint8_t var_index;
+ uint8_t i;
+
+ tuple_init(new_tuple);
+ memcpy(temp_tuple, from_tuple, FTREE_TUPLE_LEN);
+
+ if (direction == FTREE_DIRECTION_DOWN) {
+ temp_tuple[0]++;
+ var_index = from_tuple[0] + 1;
+ } else {
+ temp_tuple[0]--;
+ var_index = from_tuple[0];
+ }
+
+ for (i = 0; i < 0xFF; i++) {
+ temp_tuple[var_index] = i;
+ p_sw = fabric_get_sw_by_tuple(p_ftree, temp_tuple);
+ if (p_sw == NULL) /* found free tuple */
+ break;
+ }
+
+ if (i == 0xFF) {
+ /* new tuple not found - there are more than 255 ports in one direction */
+ return;
+ }
+ memcpy(new_tuple, temp_tuple, FTREE_TUPLE_LEN);
+
+} /* fabric_get_new_tuple() */
+
+/***************************************************/
+
+static inline boolean_t fabric_roots_provided(IN ftree_fabric_t * p_ftree)
+{
+ return (p_ftree->p_osm->subn.opt.root_guid_file != NULL);
+}
+
+/***************************************************/
+
+static inline boolean_t fabric_cns_provided(IN ftree_fabric_t * p_ftree)
+{
+ return (p_ftree->p_osm->subn.opt.cn_guid_file != NULL);
+}
+
+/***************************************************/
+
+static inline boolean_t fabric_ios_provided(IN ftree_fabric_t * p_ftree)
+{
+ return (p_ftree->p_osm->subn.opt.io_guid_file != NULL);
+}
+
+/***************************************************/
+
+static int fabric_mark_leaf_switches(IN ftree_fabric_t * p_ftree)
+{
+ ftree_sw_t *p_sw;
+ ftree_hca_t *p_hca;
+ ftree_hca_t *p_next_hca;
+ unsigned i;
+ int res = 0;
+
+ OSM_LOG_ENTER(&p_ftree->p_osm->log);
+
+ OSM_LOG(&p_ftree->p_osm->log, OSM_LOG_VERBOSE,
+ "Marking leaf switches in fabric\n");
+
+ /* Scan all the CAs, if they have CNs - find CN port and mark switch
+ that is connected to this port as leaf switch.
+ Also, ensure that this marked leaf has rank of p_ftree->leaf_switch_rank. */
+ p_next_hca = (ftree_hca_t *) cl_qmap_head(&p_ftree->hca_tbl);
+ while (p_next_hca != (ftree_hca_t *) cl_qmap_end(&p_ftree->hca_tbl)) {
+ p_hca = p_next_hca;
+ p_next_hca = (ftree_hca_t *) cl_qmap_next(&p_hca->map_item);
+ if (!p_hca->cn_num)
+ continue;
+
+ for (i = 0; i < p_hca->up_port_groups_num; i++) {
+ if (!p_hca->up_port_groups[i]->is_cn)
+ continue;
+
+ /* In CAs, port group alway has one port, and since this
+ port group is CN, we know that this port is compute node */
+ CL_ASSERT(p_hca->up_port_groups[i]->remote_node_type ==
+ IB_NODE_TYPE_SWITCH);
+ p_sw = p_hca->up_port_groups[i]->remote_hca_or_sw.p_sw;
+
+ /* check if this switch was already processed */
+ if (p_sw->is_leaf)
+ continue;
+ p_sw->is_leaf = TRUE;
+
+ /* ensure that this leaf switch is at the correct tree level */
+ if (p_sw->rank != p_ftree->leaf_switch_rank) {
+ OSM_LOG(&p_ftree->p_osm->log, OSM_LOG_ERROR,
+ "ERR AB26: CN port 0x%" PRIx64
+ " is connected to switch 0x%" PRIx64
+ " with rank %u, "
+ "while FatTree leaf rank is %u\n",
+ cl_ntoh64(p_hca->
+ up_port_groups[i]->port_guid),
+ sw_get_guid_ho(p_sw), p_sw->rank,
+ p_ftree->leaf_switch_rank);
+ res = -1;
+ goto Exit;
+
+ }
+ }
+ }
+
+Exit:
+ OSM_LOG_EXIT(&p_ftree->p_osm->log);
+ return res;
+} /* fabric_mark_leaf_switches() */
+
+/***************************************************/
+static void bfs_fabric_indexing(IN ftree_fabric_t * p_ftree,
+ IN ftree_sw_t *p_first_sw)
+{
+ ftree_sw_t *p_remote_sw;
+ ftree_sw_t *p_sw = NULL;
+ ftree_tuple_t new_tuple;
+ uint32_t i;
+ cl_list_t bfs_list;
+
+ OSM_LOG_ENTER(&p_ftree->p_osm->log);
+ cl_list_init(&bfs_list, cl_qmap_count(&p_ftree->sw_tbl));
+ /*
+ * Now run BFS and assign indexes to all switches
+ * Pseudo code of the algorithm is as follows:
+ *
+ * * Add first switch to BFS queue
+ * * While (BFS queue not empty)
+ * - Pop the switch from the head of the queue
+ * - Scan all the downward and upward ports
+ * - For each port
+ * + Get the remote switch
+ * + Assign index to the remote switch
+ * + Add remote switch to the BFS queue
+ */
+
+ cl_list_insert_tail(&bfs_list, p_first_sw);
+
+ while (!cl_is_list_empty(&bfs_list)) {
+ p_sw = (ftree_sw_t *) cl_list_remove_head(&bfs_list);
+
+ /* Discover all the nodes from ports that are pointing down */
+
+ if (p_sw->rank >= p_ftree->leaf_switch_rank) {
+ /* whether downward ports are pointing to CAs or switches,
+ we don't assign indexes to switches that are located
+ lower than leaf switches */
+ } else {
+ /* This is not the leaf switch */
+ for (i = 0; i < p_sw->down_port_groups_num; i++) {
+ /* Work with port groups that are pointing to switches only.
+ No need to assign indexing to HCAs */
+ if (p_sw->
+ down_port_groups[i]->remote_node_type !=
+ IB_NODE_TYPE_SWITCH)
+ continue;
+
+ p_remote_sw =
+ p_sw->down_port_groups[i]->
+ remote_hca_or_sw.p_sw;
+ if (tuple_assigned(p_remote_sw->tuple)) {
+ /* this switch has been already indexed */
+ continue;
+ }
+ /* allocate new tuple */
+ fabric_get_new_tuple(p_ftree, new_tuple,
+ p_sw->tuple,
+ FTREE_DIRECTION_DOWN);
+ /* Assign the new tuple to the remote switch.
+ This fuction also adds the switch into the switch_by_tuple table. */
+ fabric_assign_tuple(p_ftree, p_remote_sw,
+ new_tuple);
+
+ /* add the newly discovered switch to the BFS queue */
+ cl_list_insert_tail(&bfs_list, p_remote_sw);
+ }
+ /* Done assigning indexes to all the remote switches
+ that are pointed by the downgoing ports.
+ Now sort port groups according to remote index. */
+ qsort(p_sw->down_port_groups, /* array */
+ p_sw->down_port_groups_num, /* number of elements */
+ sizeof(ftree_port_group_t *), /* size of each element */
+ compare_port_groups_by_remote_switch_index); /* comparator */
+ }
+
+ /* Done indexing switches from ports that go down.
+ Now do the same with ports that are pointing up.
+ if we started from root (rank == 0), the leaf is bsf termination point */
+
+ if (p_sw->rank != 0 && (p_first_sw->rank != 0 || !p_sw->is_leaf)) {
+ /* This is not the root switch, which means that all the ports
+ that are pointing up are taking us to another switches. */
+ for (i = 0; i < p_sw->up_port_groups_num; i++) {
+ p_remote_sw =
+ p_sw->up_port_groups[i]->
+ remote_hca_or_sw.p_sw;
+ if (tuple_assigned(p_remote_sw->tuple))
+ continue;
+ /* allocate new tuple */
+ fabric_get_new_tuple(p_ftree, new_tuple,
+ p_sw->tuple,
+ FTREE_DIRECTION_UP);
+ /* Assign the new tuple to the remote switch.
+ This fuction also adds the switch to the
+ switch_by_tuple table. */
+ fabric_assign_tuple(p_ftree,
+ p_remote_sw, new_tuple);
+ /* add the newly discovered switch to the BFS queue */
+ cl_list_insert_tail(&bfs_list, p_remote_sw);
+ }
+ /* Done assigning indexes to all the remote switches
+ that are pointed by the upgoing ports.
+ Now sort port groups according to remote index. */
+ qsort(p_sw->up_port_groups, /* array */
+ p_sw->up_port_groups_num, /* number of elements */
+ sizeof(ftree_port_group_t *), /* size of each element */
+ compare_port_groups_by_remote_switch_index); /* comparator */
+ }
+ /* Done assigning indexes to all the switches that are directly connected
+ to the current switch - go to the next switch in the BFS queue */
+ }
+ cl_list_destroy(&bfs_list);
+
+ OSM_LOG_EXIT(&p_ftree->p_osm->log);
+}
+
+static void fabric_make_indexing(IN ftree_fabric_t * p_ftree)
+{
+ ftree_sw_t *p_sw = NULL;
+ unsigned int subtree = 0;
+ OSM_LOG_ENTER(&p_ftree->p_osm->log);
+
+ OSM_LOG(&p_ftree->p_osm->log, OSM_LOG_VERBOSE,
+ "Starting FatTree indexing\n");
+
+ /* using the first switch as a starting point for indexing algorithm. */
+ for (p_sw = (ftree_sw_t *) cl_qmap_head(&p_ftree->sw_tbl);
+ p_sw != (ftree_sw_t *) cl_qmap_end(&p_ftree->sw_tbl);
+ p_sw = (ftree_sw_t *) cl_qmap_next(&p_sw->map_item)) {
+ if (ftree_get_subnet(p_ftree)->opt.quasi_ftree_indexing) {
+ /* find first root switch */
+ if (p_sw->rank != 0)
+ continue;
+ } else {
+ /* find first leaf switch */
+ if (!p_sw->is_leaf)
+ continue;
+ }
+ /* Assign the first tuple to the switch that is used as BFS starting point
+ in the subtree.
+ The tuple will be as follows: [rank].0...0.subtree
+ This fuction also adds the switch it into the switch_by_tuple table. */
+ if (!tuple_assigned(p_sw->tuple)) {
+ fabric_assign_first_tuple(p_ftree, p_sw, subtree++);
+ OSM_LOG(&p_ftree->p_osm->log, OSM_LOG_VERBOSE,
+ "Indexing starting point:\n"
+ " - Switch rank : %u\n"
+ " - Switch index : %s\n"
+ " - Node LID : %u\n"
+ " - Node GUID : 0x%016"
+ PRIx64 "\n", p_sw->rank, tuple_to_str(p_sw->tuple),
+ p_sw->lid, sw_get_guid_ho(p_sw));
+ }
+
+ bfs_fabric_indexing(p_ftree, p_sw);
+
+ if (ftree_get_subnet(p_ftree)->opt.quasi_ftree_indexing == FALSE)
+ goto Exit;
+ }
+ p_sw = (ftree_sw_t *) cl_qmap_head(&p_ftree->sw_tbl);
+ while (p_sw != (ftree_sw_t *) cl_qmap_end(&p_ftree->sw_tbl)) {
+ if (p_sw->is_leaf) {
+ qsort(p_sw->up_port_groups, /* array */
+ p_sw->up_port_groups_num, /* number of elements */
+ sizeof(ftree_port_group_t *), /* size of each element */
+ compare_port_groups_by_remote_switch_index); /* comparator */
+ }
+ p_sw = (ftree_sw_t *) cl_qmap_next(&p_sw->map_item);
+
+ }
+Exit:
+ OSM_LOG_EXIT(&p_ftree->p_osm->log);
+} /* fabric_make_indexing() */
+/***************************************************/
+
+static int fabric_create_leaf_switch_array(IN ftree_fabric_t * p_ftree)
+{
+ ftree_sw_t *p_sw;
+ ftree_sw_t *p_next_sw;
+ ftree_sw_t **all_switches_at_leaf_level;
+ unsigned i;
+ unsigned all_leaf_idx = 0;
+ unsigned first_leaf_idx;
+ unsigned last_leaf_idx;
+ int res = 0;
+
+ OSM_LOG_ENTER(&p_ftree->p_osm->log);
+
+ /* create array of ALL the switches that have leaf rank */
+ all_switches_at_leaf_level = (ftree_sw_t **)
+ malloc(cl_qmap_count(&p_ftree->sw_tbl) * sizeof(ftree_sw_t *));
+ if (!all_switches_at_leaf_level) {
+ osm_log_v2(&p_ftree->p_osm->log, OSM_LOG_SYS, FILE_ID,
+ "Fat-tree routing: Memory allocation failed\n");
+ res = -1;
+ goto Exit;
+ }
+ memset(all_switches_at_leaf_level, 0,
+ cl_qmap_count(&p_ftree->sw_tbl) * sizeof(ftree_sw_t *));
+
+ p_next_sw = (ftree_sw_t *) cl_qmap_head(&p_ftree->sw_tbl);
+ while (p_next_sw != (ftree_sw_t *) cl_qmap_end(&p_ftree->sw_tbl)) {
+ p_sw = p_next_sw;
+ p_next_sw = (ftree_sw_t *) cl_qmap_next(&p_sw->map_item);
+ if (p_sw->rank == p_ftree->leaf_switch_rank) {
+ OSM_LOG(&p_ftree->p_osm->log, OSM_LOG_DEBUG,
+ "Adding switch 0x%" PRIx64
+ " to full leaf switch array\n",
+ sw_get_guid_ho(p_sw));
+ all_switches_at_leaf_level[all_leaf_idx++] = p_sw;
+ }
+ }
+
+ /* quick-sort array of leaf switches by index */
+ qsort(all_switches_at_leaf_level, /* array */
+ all_leaf_idx, /* number of elements */
+ sizeof(ftree_sw_t *), /* size of each element */
+ compare_switches_by_index); /* comparator */
+
+ /* check the first and the last REAL leaf (the one
+ that has CNs) in the array of all the leafs */
+
+ first_leaf_idx = all_leaf_idx;
+ last_leaf_idx = 0;
+ for (i = 0; i < all_leaf_idx; i++) {
+ if (all_switches_at_leaf_level[i]->is_leaf) {
+ if (i < first_leaf_idx)
+ first_leaf_idx = i;
+ last_leaf_idx = i;
+ }
+ }
+
+ OSM_LOG(&p_ftree->p_osm->log, OSM_LOG_DEBUG,
+ "Full leaf array info: first_leaf_idx = %u, last_leaf_idx = %u\n",
+ first_leaf_idx, last_leaf_idx);
+
+ if (first_leaf_idx >= last_leaf_idx) {
+ osm_log_v2(&p_ftree->p_osm->log, OSM_LOG_INFO, FILE_ID,
+ "Failed to find leaf switches - topology is not "
+ "fat-tree\n");
+ res = -1;
+ goto Exit;
+ }
+
+ /* Create array of REAL leaf switches, sorted by index.
+ This array may contain switches at the same rank w/o CNs,
+ in case this is the order of indexing. */
+ p_ftree->leaf_switches_num = last_leaf_idx - first_leaf_idx + 1;
+ p_ftree->leaf_switches = (ftree_sw_t **)
+ malloc(p_ftree->leaf_switches_num * sizeof(ftree_sw_t *));
+ if (!p_ftree->leaf_switches) {
+ osm_log_v2(&p_ftree->p_osm->log, OSM_LOG_SYS, FILE_ID,
+ "Fat-tree routing: Memory allocation failed\n");
+ res = -1;
+ goto Exit;
+ }
+
+ memcpy(p_ftree->leaf_switches,
+ &(all_switches_at_leaf_level[first_leaf_idx]),
+ p_ftree->leaf_switches_num * sizeof(ftree_sw_t *));
+
+ OSM_LOG(&p_ftree->p_osm->log, OSM_LOG_DEBUG,
+ "Created array of %u leaf switches\n",
+ p_ftree->leaf_switches_num);
+
+Exit:
+ free(all_switches_at_leaf_level);
+ OSM_LOG_EXIT(&p_ftree->p_osm->log);
+ return res;
+} /* fabric_create_leaf_switch_array() */
+
+/***************************************************/
+
+static void fabric_set_max_cn_per_leaf(IN ftree_fabric_t * p_ftree)
+{
+ unsigned i;
+ unsigned j;
+ unsigned cns_on_this_leaf;
+ ftree_sw_t *p_sw;
+ ftree_port_group_t *p_group, *p_up_group;
+ ftree_hca_t *p_hca;
+
+ for (i = 0; i < p_ftree->leaf_switches_num; i++) {
+ p_sw = p_ftree->leaf_switches[i];
+ cns_on_this_leaf = 0;
+ for (j = 0; j < p_sw->down_port_groups_num; j++) {
+ p_group = p_sw->down_port_groups[j];
+ if (p_group->remote_node_type != IB_NODE_TYPE_CA)
+ continue;
+ p_hca = p_group->remote_hca_or_sw.p_hca;
+ /*
+ * Get the hca port group corresponding
+ * to the LID of remote HCA port
+ */
+ p_up_group = hca_get_port_group_by_lid(p_hca,
+ p_group->remote_lid);
+
+ CL_ASSERT(p_up_group);
+
+ if (p_up_group->is_cn)
+ cns_on_this_leaf++;
+ }
+ if (cns_on_this_leaf > p_ftree->max_cn_per_leaf)
+ p_ftree->max_cn_per_leaf = cns_on_this_leaf;
+ }
+} /* fabric_set_max_cn_per_leaf() */
+
+/***************************************************/
+
+static boolean_t fabric_validate_topology(IN ftree_fabric_t * p_ftree)
+{
+ ftree_port_group_t *p_group;
+ ftree_port_group_t *p_ref_group;
+ ftree_sw_t *p_sw;
+ ftree_sw_t *p_next_sw;
+ ftree_sw_t **reference_sw_arr;
+ uint16_t tree_rank = fabric_get_rank(p_ftree);
+ boolean_t res = TRUE;
+ uint8_t i;
+
+ OSM_LOG_ENTER(&p_ftree->p_osm->log);
+
+ OSM_LOG(&p_ftree->p_osm->log, OSM_LOG_VERBOSE,
+ "Validating fabric topology\n");
+
+ reference_sw_arr =
+ (ftree_sw_t **) malloc(tree_rank * sizeof(ftree_sw_t *));
+ if (reference_sw_arr == NULL) {
+ osm_log_v2(&p_ftree->p_osm->log, OSM_LOG_SYS, FILE_ID,
+ "Fat-tree routing: Memory allocation failed\n");
+ return FALSE;
+ }
+ memset(reference_sw_arr, 0, tree_rank * sizeof(ftree_sw_t *));
+
+ p_next_sw = (ftree_sw_t *) cl_qmap_head(&p_ftree->sw_tbl);
+ while (res && p_next_sw != (ftree_sw_t *) cl_qmap_end(&p_ftree->sw_tbl)) {
+ p_sw = p_next_sw;
+ p_next_sw = (ftree_sw_t *) cl_qmap_next(&p_sw->map_item);
+
+ if (!reference_sw_arr[p_sw->rank])
+ /* This is the first switch in the current level that
+ we're checking - use it as a reference */
+ reference_sw_arr[p_sw->rank] = p_sw;
+ else {
+ /* compare this switch properties to the reference switch */
+
+ if (reference_sw_arr[p_sw->rank]->up_port_groups_num !=
+ p_sw->up_port_groups_num) {
+ OSM_LOG(&p_ftree->p_osm->log, OSM_LOG_ERROR,
+ "ERR AB09: Different number of upward port groups on switches:\n"
+ " GUID 0x%016" PRIx64
+ ", LID %u, Index %s - %u groups\n"
+ " GUID 0x%016" PRIx64
+ ", LID %u, Index %s - %u groups\n",
+ sw_get_guid_ho
+ (reference_sw_arr[p_sw->rank]),
+ reference_sw_arr[p_sw->rank]->lid,
+ tuple_to_str
+ (reference_sw_arr[p_sw->rank]->tuple),
+ reference_sw_arr[p_sw->
+ rank]->
+ up_port_groups_num,
+ sw_get_guid_ho(p_sw), p_sw->lid,
+ tuple_to_str(p_sw->tuple),
+ p_sw->up_port_groups_num);
+ res = FALSE;
+ break;
+ }
+
+ if (p_sw->rank != (tree_rank - 1) &&
+ reference_sw_arr[p_sw->
+ rank]->down_port_groups_num !=
+ p_sw->down_port_groups_num) {
+ /* we're allowing some hca's to be missing */
+ OSM_LOG(&p_ftree->p_osm->log, OSM_LOG_ERROR,
+ "ERR AB0A: Different number of downward port groups on switches:\n"
+ " GUID 0x%016" PRIx64
+ ", LID %u, Index %s - %u port groups\n"
+ " GUID 0x%016" PRIx64
+ ", LID %u, Index %s - %u port groups\n",
+ sw_get_guid_ho
+ (reference_sw_arr[p_sw->rank]),
+ reference_sw_arr[p_sw->rank]->lid,
+ tuple_to_str
+ (reference_sw_arr[p_sw->rank]->tuple),
+ reference_sw_arr[p_sw->
+ rank]->
+ down_port_groups_num,
+ sw_get_guid_ho(p_sw), p_sw->lid,
+ tuple_to_str(p_sw->tuple),
+ p_sw->down_port_groups_num);
+ res = FALSE;
+ break;
+ }
+
+ if (reference_sw_arr[p_sw->rank]->up_port_groups_num !=
+ 0) {
+ p_ref_group =
+ reference_sw_arr[p_sw->
+ rank]->up_port_groups[0];
+ for (i = 0; i < p_sw->up_port_groups_num; i++) {
+ p_group = p_sw->up_port_groups[i];
+ if (cl_ptr_vector_get_size
+ (&p_ref_group->ports) !=
+ cl_ptr_vector_get_size
+ (&p_group->ports)) {
+ OSM_LOG(&p_ftree->p_osm->log,
+ OSM_LOG_ERROR,
+ "ERR AB0B: Different number of ports in an upward port group on switches:\n"
+ " GUID 0x%016"
+ PRIx64
+ ", LID %u, Index %s - %u ports\n"
+ " GUID 0x%016"
+ PRIx64
+ ", LID %u, Index %s - %u ports\n",
+ sw_get_guid_ho
+ (reference_sw_arr
+ [p_sw->rank]),
+ reference_sw_arr[p_sw->
+ rank]->
+ lid,
+ tuple_to_str
+ (reference_sw_arr
+ [p_sw->rank]->tuple),
+ cl_ptr_vector_get_size
+ (&p_ref_group->ports),
+ sw_get_guid_ho(p_sw),
+ p_sw->lid,
+ tuple_to_str(p_sw->
+ tuple),
+ cl_ptr_vector_get_size
+ (&p_group->ports));
+ res = FALSE;
+ break;
+ }
+ }
+ }
+ if (reference_sw_arr[p_sw->rank]->down_port_groups_num
+ != 0 && p_sw->rank != (tree_rank - 1)) {
+ /* we're allowing some hca's to be missing */
+ p_ref_group =
+ reference_sw_arr[p_sw->
+ rank]->down_port_groups[0];
+ for (i = 0; i < p_sw->down_port_groups_num; i++) {
+ p_group = p_sw->down_port_groups[0];
+ if (cl_ptr_vector_get_size
+ (&p_ref_group->ports) !=
+ cl_ptr_vector_get_size
+ (&p_group->ports)) {
+ OSM_LOG(&p_ftree->p_osm->log,
+ OSM_LOG_ERROR,
+ "ERR AB0C: Different number of ports in an downward port group on switches:\n"
+ " GUID 0x%016"
+ PRIx64
+ ", LID %u, Index %s - %u ports\n"
+ " GUID 0x%016"
+ PRIx64
+ ", LID %u, Index %s - %u ports\n",
+ sw_get_guid_ho
+ (reference_sw_arr
+ [p_sw->rank]),
+ reference_sw_arr[p_sw->
+ rank]->
+ lid,
+ tuple_to_str
+ (reference_sw_arr
+ [p_sw->rank]->tuple),
+ cl_ptr_vector_get_size
+ (&p_ref_group->ports),
+ sw_get_guid_ho(p_sw),
+ p_sw->lid,
+ tuple_to_str(p_sw->
+ tuple),
+ cl_ptr_vector_get_size
+ (&p_group->ports));
+ res = FALSE;
+ break;
+ }
+ }
+ }
+ } /* end of else */
+ } /* end of while */
+
+ if (res == TRUE)
+ OSM_LOG(&p_ftree->p_osm->log, OSM_LOG_VERBOSE,
+ "Fabric topology has been identified as FatTree\n");
+ else
+ OSM_LOG(&p_ftree->p_osm->log, OSM_LOG_ERROR,
+ "ERR AB0D: Fabric topology hasn't been identified as FatTree\n");
+
+ free(reference_sw_arr);
+ OSM_LOG_EXIT(&p_ftree->p_osm->log);
+ return res;
+} /* fabric_validate_topology() */
+
+/***************************************************
+ ***************************************************/
+
+static void set_sw_fwd_table(IN cl_map_item_t * const p_map_item,
+ IN void *context)
+{
+ ftree_sw_t *p_sw = (ftree_sw_t * const)p_map_item;
+ ftree_fabric_t *p_ftree = (ftree_fabric_t *) context;
+
+ p_sw->p_osm_sw->max_lid_ho = p_ftree->lft_max_lid;
+}
+
+/***************************************************
+ ***************************************************/
+
+/*
+ * Function: Finds the least loaded port group and stores its counter
+ * Given : A switch
+ */
+static inline void recalculate_min_counter_down(ftree_sw_t * p_sw)
+{
+ uint32_t min = (1 << 30);
+ uint32_t i;
+ for (i = 0; i < p_sw->down_port_groups_num; i++) {
+ if (p_sw->down_port_groups[i]->counter_down < min) {
+ min = p_sw->down_port_groups[i]->counter_down;
+ }
+ }
+ p_sw->min_counter_down = min;
+ return;
+}
+
+/*
+ * Function: Return the counter value of the least loaded down port group
+ * Given : A switch
+ */
+static inline uint32_t find_lowest_loaded_group_on_sw(ftree_sw_t * p_sw)
+{
+ return p_sw->min_counter_down;
+}
+
+/*
+ * Function: Compare the load of two port groups and return which is the least loaded
+ * Given : Two port groups with remote switch
+ * When both port groups are equally loaded, it picks the one whom
+ * remote switch down ports are least loaded.
+ * This way, it prefers the switch from where it will be easier to go down (creating upward routes).
+ * If both are equal, it picks the lowest INDEX to be deterministic.
+ */
+static inline int port_group_compare_load_down(const ftree_port_group_t * p1,
+ const ftree_port_group_t * p2)
+{
+ int temp = p1->counter_down - p2->counter_down;
+ if (temp > 0)
+ return 1;
+ if (temp < 0)
+ return -1;
+
+ /* Find the less loaded remote sw and choose this one */
+ do {
+ uint32_t load1 =
+ find_lowest_loaded_group_on_sw(p1->remote_hca_or_sw.p_sw);
+ uint32_t load2 =
+ find_lowest_loaded_group_on_sw(p2->remote_hca_or_sw.p_sw);
+ temp = load1 - load2;
+ if (temp > 0)
+ return 1;
+ } while (0);
+ /* If they are both equal, choose the lowest index */
+ return compare_port_groups_by_remote_switch_index(&p1, &p2);
+}
+
+static inline int port_group_compare_load_up(const ftree_port_group_t * p1,
+ const ftree_port_group_t * p2)
+{
+ int temp = p1->counter_up - p2->counter_up;
+ if (temp > 0)
+ return 1;
+ if (temp < 0)
+ return -1;
+
+ /* If they are both equal, choose the lowest index */
+ return compare_port_groups_by_remote_switch_index (&p1,&p2);
+}
+
+/*
+ * Function: Sorts an array of port group by up load order
+ * Given : A port group array and its length
+ * As the list is mostly sorted, we used a bubble sort instead of qsort
+ * as it is much faster.
+ *
+ * Important note:
+ * This function and bubble_sort_down must NOT be factorized.
+ * Although most of the code is the same and a function pointer could be used
+ * for the compareason function, it would prevent the compareason function to be inlined
+ * and cost a great deal to performances.
+ */
+static inline void
+bubble_sort_up(ftree_port_group_t ** p_group_array, uint32_t nmemb)
+{
+ uint32_t i = 0;
+ uint32_t j = 0;
+ ftree_port_group_t *tmp = p_group_array[0];
+
+ /* As this function is a great number of times, we only go into the loop
+ * if one of the port counters has changed, thus saving some tests */
+ if (tmp->hca_or_sw.p_sw->counter_up_changed == FALSE) {
+ return;
+ }
+ /* While we did modifications on the array order */
+ /* i may grew above array length but next loop will fail and tmp will be null for the next time
+ * this way we save a test i < nmemb for each pass through the loop */
+ for (i = 0; tmp; i++) {
+ /* Assume the array is orderd */
+ tmp = NULL;
+ /* Comparing elements j and j-1 */
+ for (j = 1; j < (nmemb - i); j++) {
+ /* If they are the wrong way around */
+ if (port_group_compare_load_up(p_group_array[j],
+ p_group_array[j - 1]) < 0) {
+ /* We invert them */
+ tmp = p_group_array[j - 1];
+ p_group_array[j - 1] = p_group_array[j];
+ p_group_array[j] = tmp;
+ /* This sets tmp != NULL so the main loop will make another pass */
+ }
+ }
+ }
+
+ /* We have reordered the array so as long noone changes the counter
+ * it's not necessary to do it again */
+ p_group_array[0]->hca_or_sw.p_sw->counter_up_changed = FALSE;
+}
+
+static inline void
+bubble_sort_siblings(ftree_port_group_t ** p_group_array, uint32_t nmemb)
+{
+ uint32_t i = 0;
+ uint32_t j = 0;
+ ftree_port_group_t *tmp = p_group_array[0];
+
+ /* While we did modifications on the array order */
+ /* i may grew above array length but next loop will fail and tmp will be null for the next time
+ * this way we save a test i < nmemb for each pass through the loop */
+ for (i = 0; tmp != NULL; i++) {
+ /* Assume the array is orderd */
+ tmp = NULL;
+ /* Comparing elements j and j-1 */
+ for (j = 1; j < (nmemb - i); j++) {
+ /* If they are the wrong way around */
+ if (port_group_compare_load_up(p_group_array[j],
+ p_group_array[j - 1]) < 0) {
+ /* We invert them */
+ tmp = p_group_array[j - 1];
+ p_group_array[j - 1] = p_group_array[j];
+ p_group_array[j] = tmp;
+ }
+ }
+ }
+}
+
+/*
+ * Function: Sorts an array of port group. Order is decide through
+ * port_group_compare_load_down ( up counters, least load remote switch, biggest GUID)
+ * Given : A port group array and its length. Each port group points to a remote switch (not a HCA)
+ * As the list is mostly sorted, we used a bubble sort instead of qsort
+ * as it is much faster.
+ *
+ * Important note:
+ * This function and bubble_sort_up must NOT be factorized.
+ * Although most of the code is the same and a function pointer could be used
+ * for the compareason function, it would prevent the compareason function to be inlined
+ * and cost a great deal to performances.
+ */
+static inline void
+bubble_sort_down(ftree_port_group_t ** p_group_array, uint32_t nmemb)
+{
+ uint32_t i = 0;
+ uint32_t j = 0;
+ ftree_port_group_t *tmp = p_group_array[0];
+
+ /* While we did modifications on the array order */
+ /* i may grew above array length but next loop will fail and tmp will be null for the next time
+ * this way we save a test i < nmemb for each pass through the loop */
+ for (i = 0; tmp; i++) {
+ /* Assume the array is orderd */
+ tmp = NULL;
+ /* Comparing elements j and j-1 */
+ for (j = 1; j < (nmemb - i); j++) {
+ /* If they are the wrong way around */
+ if (port_group_compare_load_down
+ (p_group_array[j], p_group_array[j - 1]) < 0) {
+ /* We invert them */
+ tmp = p_group_array[j - 1];
+ p_group_array[j - 1] = p_group_array[j];
+ p_group_array[j] = tmp;
+
+ }
+ }
+ }
+}
+
+/***************************************************
+ ***************************************************/
+
+/*
+ * Function: assign-up-going-port-by-descending-down
+ * Given : a switch and a LID
+ * Pseudo code:
+ * foreach down-going-port-group (in indexing order)
+ * skip this group if the LFT(LID) port is part of this group
+ * find the least loaded port of the group (scan in indexing order)
+ * r-port is the remote port connected to it
+ * assign the remote switch node LFT(LID) to r-port
+ * increase r-port usage counter
+ * assign-up-going-port-by-descending-down to r-port node (recursion)
+ */
+
+static boolean_t
+fabric_route_upgoing_by_going_down(IN ftree_fabric_t * p_ftree,
+ IN ftree_sw_t * p_sw,
+ IN ftree_sw_t * p_prev_sw,
+ IN uint16_t target_lid,
+ IN boolean_t is_main_path,
+ IN boolean_t is_target_a_sw,
+ IN uint8_t current_hops)
+{
+ ftree_sw_t *p_remote_sw;
+ uint16_t ports_num;
+ ftree_port_group_t *p_group;
+ ftree_port_t *p_port;
+ ftree_port_t *p_min_port;
+ uint16_t j;
+ uint16_t k;
+ boolean_t created_route = FALSE;
+ boolean_t routed = 0;
+ uint8_t least_hops;
+
+ /* if there is no down-going ports */
+ if (p_sw->down_port_groups_num == 0)
+ return FALSE;
+
+ /* foreach down-going port group (in load order) */
+ bubble_sort_up(p_sw->down_port_groups, p_sw->down_port_groups_num);
+
+ if (p_sw->sibling_port_groups_num > 0)
+ bubble_sort_siblings(p_sw->sibling_port_groups,
+ p_sw->sibling_port_groups_num);
+
+ for (k = 0;
+ k <
+ (p_sw->down_port_groups_num +
+ ((target_lid != 0) ? p_sw->sibling_port_groups_num : 0)); k++) {
+
+ if (k < p_sw->down_port_groups_num) {
+ p_group = p_sw->down_port_groups[k];
+ } else {
+ p_group =
+ p_sw->sibling_port_groups[k -
+ p_sw->
+ down_port_groups_num];
+ }
+
+ /* If this port group doesn't point to a switch, mark
+ that the route was created and skip to the next group */
+ if (p_group->remote_node_type != IB_NODE_TYPE_SWITCH) {
+ created_route = TRUE;
+ continue;
+ }
+
+ if (p_prev_sw
+ && p_group->remote_lid == p_prev_sw->lid) {
+ /* This port group has a port that was used when we entered this switch,
+ which means that the current group points to the switch where we were
+ at the previous step of the algorithm (before going up).
+ Skipping this group. */
+ continue;
+ }
+
+ /* find the least loaded port of the group (in indexing order) */
+ p_min_port = NULL;
+ ports_num = (uint16_t) cl_ptr_vector_get_size(&p_group->ports);
+ if(ports_num == 0)
+ continue;
+
+ for (j = 0; j < ports_num; j++) {
+ cl_ptr_vector_at(&p_group->ports, j, (void *)&p_port);
+ /* first port that we're checking - set as port with the lowest load */
+ /* or this port is less loaded - use it as min */
+ if (!p_min_port ||
+ p_port->counter_up < p_min_port->counter_up)
+ p_min_port = p_port;
+ }
+ /* At this point we have selected a port in this group with the
+ lowest load of upgoing routes.
+ Set on the remote switch how to get to the target_lid -
+ set LFT(target_lid) on the remote switch to the remote port */
+ p_remote_sw = p_group->remote_hca_or_sw.p_sw;
+ least_hops = sw_get_least_hops(p_remote_sw, target_lid);
+
+ if (least_hops != OSM_NO_PATH) {
+ /* Loop in the fabric - we already routed the remote switch
+ on our way UP, and now we see it again on our way DOWN */
+ OSM_LOG(&p_ftree->p_osm->log, OSM_LOG_DEBUG,
+ "Loop of length %d in the fabric:\n "
+ "Switch %s (LID %u) closes loop through switch %s (LID %u)\n",
+ current_hops,
+ tuple_to_str(p_remote_sw->tuple),
+ p_group->lid,
+ tuple_to_str(p_sw->tuple),
+ p_group->remote_lid);
+ /* We skip only if we have come through a longer path */
+ if (current_hops + 1 >= least_hops)
+ continue;
+ }
+
+ /* Four possible cases:
+ *
+ * 1. is_main_path == TRUE:
+ * - going DOWN(TRUE,TRUE) through ALL the groups
+ * + promoting port counter
+ * + setting path in remote switch fwd tbl
+ * + setting hops in remote switch on all the ports of each group
+ *
+ * 2. is_main_path == FALSE:
+ * - going DOWN(TRUE,FALSE) through ALL the groups but only if
+ * the remote (lower) switch hasn't been already configured
+ * for this target LID (or with a longer path)
+ * + promoting port counter
+ * + setting path in remote switch fwd tbl if it hasn't been set yet
+ * + setting hops in remote switch on all the ports of each group
+ * if it hasn't been set yet
+ */
+
+ /* setting fwd tbl port only */
+ p_remote_sw->p_osm_sw->new_lft[target_lid] =
+ p_min_port->remote_port_num;
+ OSM_LOG(&p_ftree->p_osm->log, OSM_LOG_DEBUG,
+ "Switch %s: set path to CA LID %u through port %u\n",
+ tuple_to_str(p_remote_sw->tuple),
+ target_lid, p_min_port->remote_port_num);
+
+ /* On the remote switch that is pointed by the p_group,
+ set hops for ALL the ports in the remote group. */
+
+ set_hops_on_remote_sw(p_group, target_lid,
+ current_hops + 1, is_target_a_sw);
+
+ /* Recursion step:
+ Assign upgoing ports by stepping down, starting on REMOTE switch */
+ routed = fabric_route_upgoing_by_going_down(p_ftree, p_remote_sw, /* remote switch - used as a route-upgoing alg. start point */
+ NULL, /* prev. position - NULL to mark that we went down and not up */
+ target_lid, /* LID that we're routing to */
+ is_main_path, /* whether this is path to HCA that should by tracked by counters */
+ is_target_a_sw, /* Whether target lid is a switch or not */
+ current_hops + 1); /* Number of hops done to this point */
+ created_route |= routed;
+ /* Counters are promoted only if a route toward a node is created */
+ if (routed) {
+ p_min_port->counter_up++;
+ p_group->counter_up++;
+ p_group->hca_or_sw.p_sw->counter_up_changed = TRUE;
+ }
+ }
+ /* done scanning all the down-going port groups */
+
+ /* if the route was created, promote the index that
+ indicates which group should we start with when
+ going through all the downgoing groups */
+ if (created_route)
+ p_sw->down_port_groups_idx = (p_sw->down_port_groups_idx + 1)
+ % p_sw->down_port_groups_num;
+
+ return created_route;
+} /* fabric_route_upgoing_by_going_down() */
+
+/***************************************************/
+
+/*
+ * Function: assign-down-going-port-by-ascending-up
+ * Given : a switch and a LID
+ * Pseudo code:
+ * find the least loaded port of all the upgoing groups (scan in indexing order)
+ * assign the LFT(LID) of remote switch to that port
+ * track that port usage
+ * assign-up-going-port-by-descending-down on CURRENT switch
+ * assign-down-going-port-by-ascending-up on REMOTE switch (recursion)
+ */
+
+static boolean_t
+fabric_route_downgoing_by_going_up(IN ftree_fabric_t * p_ftree,
+ IN ftree_sw_t * p_sw,
+ IN ftree_sw_t * p_prev_sw,
+ IN uint16_t target_lid,
+ IN boolean_t is_main_path,
+ IN boolean_t is_target_a_sw,
+ IN uint16_t reverse_hop_credit,
+ IN uint16_t reverse_hops,
+ IN uint8_t current_hops)
+{
+ ftree_sw_t *p_remote_sw;
+ uint16_t ports_num;
+ ftree_port_group_t *p_group;
+ ftree_port_t *p_port;
+ ftree_port_group_t *p_min_group;
+ ftree_port_t *p_min_port;
+ uint16_t i;
+ uint16_t j;
+ boolean_t created_route = FALSE;
+ boolean_t routed = FALSE;
+
+
+ /* Assign upgoing ports by stepping down, starting on THIS switch */
+ created_route = fabric_route_upgoing_by_going_down(p_ftree, p_sw, /* local switch - used as a route-upgoing alg. start point */
+ p_prev_sw, /* switch that we went up from (NULL means that we went down) */
+ target_lid, /* LID that we're routing to */
+ is_main_path, /* whether this path to HCA should by tracked by counters */
+ is_target_a_sw, /* Whether target lid is a switch or not */
+ current_hops); /* Number of hops done up to this point */
+
+ /* recursion stop condition - if it's a root switch, */
+ if (p_sw->rank == 0) {
+ if (reverse_hop_credit > 0) {
+ /* We go up by going down as we have some reverse_hop_credit left */
+ /* We use the index to scatter a bit the reverse up routes */
+ p_sw->down_port_groups_idx =
+ (p_sw->down_port_groups_idx +
+ 1) % p_sw->down_port_groups_num;
+ i = p_sw->down_port_groups_idx;
+ for (j = 0; j < p_sw->down_port_groups_num; j++) {
+
+ p_group = p_sw->down_port_groups[i];
+ i = (i + 1) % p_sw->down_port_groups_num;
+
+ /* Skip this port group unless it points to a switch */
+ if (p_group->remote_node_type !=
+ IB_NODE_TYPE_SWITCH)
+ continue;
+ p_remote_sw = p_group->remote_hca_or_sw.p_sw;
+
+ created_route |= fabric_route_downgoing_by_going_up(p_ftree, p_remote_sw, /* remote switch - used as a route-downgoing alg. next step point */
+ p_sw, /* this switch - prev. position switch for the function */
+ target_lid, /* LID that we're routing to */
+ is_main_path, /* whether this is path to HCA that should by tracked by counters */
+ is_target_a_sw, /* Whether target lid is a switch or not */
+ reverse_hop_credit - 1, /* Remaining reverse_hops allowed */
+ reverse_hops + 1, /* Number of reverse_hops done up to this point */
+ current_hops
+ +
+ 1);
+ }
+
+ }
+ return created_route;
+ }
+
+ /* We should generate a list of port sorted by load so we can find easily the least
+ * going port and explore the other pots on secondary routes more easily (and quickly) */
+ bubble_sort_down(p_sw->up_port_groups, p_sw->up_port_groups_num);
+
+ p_min_group = p_sw->up_port_groups[0];
+ /* Find the least loaded upgoing port in the selected group */
+ p_min_port = NULL;
+ ports_num = (uint16_t) cl_ptr_vector_get_size(&p_min_group->ports);
+ for (j = 0; j < ports_num; j++) {
+ cl_ptr_vector_at(&p_min_group->ports, j, (void *)&p_port);
+ if (!p_min_port) {
+ /* first port that we're checking - use
+ it as a port with the lowest load */
+ p_min_port = p_port;
+ } else if (p_port->counter_down < p_min_port->counter_down) {
+ /* this port is less loaded - use it as min */
+ p_min_port = p_port;
+ }
+ }
+
+ /* At this point we have selected a group and port with the
+ lowest load of downgoing routes.
+ Set on the remote switch how to get to the target_lid -
+ set LFT(target_lid) on the remote switch to the remote port */
+ p_remote_sw = p_min_group->remote_hca_or_sw.p_sw;
+
+ /* Four possible cases:
+ *
+ * 1. is_main_path == TRUE:
+ * - going UP(TRUE,TRUE) on selected min_group and min_port
+ * + promoting port counter
+ * + setting path in remote switch fwd tbl
+ * + setting hops in remote switch on all the ports of selected group
+ * - going UP(TRUE,FALSE) on rest of the groups, each time on port 0
+ * + NOT promoting port counter
+ * + setting path in remote switch fwd tbl if it hasn't been set yet
+ * + setting hops in remote switch on all the ports of each group
+ * if it hasn't been set yet
+ *
+ * 2. is_main_path == FALSE:
+ * - going UP(TRUE,FALSE) on ALL the groups, each time on port 0,
+ * but only if the remote (upper) switch hasn't been already
+ * configured for this target LID
+ * + NOT promoting port counter
+ * + setting path in remote switch fwd tbl if it hasn't been set yet
+ * + setting hops in remote switch on all the ports of each group
+ * if it hasn't been set yet
+ */
+
+ /* covering first half of case 1, and case 3 */
+ if (is_main_path) {
+ if (p_sw->is_leaf) {
+ OSM_LOG(&p_ftree->p_osm->log, OSM_LOG_DEBUG,
+ " - Routing MAIN path for %s CA LID %u: %s --> %s\n",
+ (target_lid != 0) ? "real" : "DUMMY",
+ target_lid,
+ tuple_to_str(p_sw->tuple),
+ tuple_to_str(p_remote_sw->tuple));
+ }
+ /* The number of downgoing routes is tracked in the
+ p_group->counter_down p_port->counter_down counters of the
+ group and port that belong to the lower side of the link
+ (on switch with higher rank) */
+ p_min_group->counter_down++;
+ p_min_port->counter_down++;
+ if (p_min_group->counter_down ==
+ (p_min_group->remote_hca_or_sw.p_sw->min_counter_down +
+ 1)) {
+ recalculate_min_counter_down
+ (p_min_group->remote_hca_or_sw.p_sw);
+ }
+
+ /* This LID may already be in the LFT in the reverse_hop feature is used */
+ /* We update the LFT only if this LID isn't already present. */
+
+ /* skip if target lid has been already set on remote switch fwd tbl (with a bigger hop count) */
+ if ((p_remote_sw->p_osm_sw->new_lft[target_lid] == OSM_NO_PATH)
+ ||
+ (current_hops + 1 <
+ sw_get_least_hops(p_remote_sw, target_lid))) {
+
+ p_remote_sw->p_osm_sw->new_lft[target_lid] =
+ p_min_port->remote_port_num;
+ OSM_LOG(&p_ftree->p_osm->log, OSM_LOG_DEBUG,
+ "Switch %s: set path to CA LID %u through port %u\n",
+ tuple_to_str(p_remote_sw->tuple),
+ target_lid,
+ p_min_port->remote_port_num);
+
+ /* On the remote switch that is pointed by the min_group,
+ set hops for ALL the ports in the remote group. */
+
+ set_hops_on_remote_sw(p_min_group, target_lid,
+ current_hops + 1,
+ is_target_a_sw);
+ }
+ /* Recursion step: Assign downgoing ports by stepping up, starting on REMOTE switch. */
+ created_route |= fabric_route_downgoing_by_going_up(p_ftree,
+ p_remote_sw, /* remote switch - used as a route-downgoing alg. next step point */
+ p_sw, /* this switch - prev. position switch for the function */
+ target_lid, /* LID that we're routing to */
+ is_main_path, /* whether this is path to HCA that should by tracked by counters */
+ is_target_a_sw, /* Whether target lid is a switch or not */
+ reverse_hop_credit, /* Remaining reverse_hops allowed */
+ reverse_hops, /* Number of reverse_hops done up to this point */
+ current_hops + 1);
+ }
+
+ /* What's left to do at this point:
+ *
+ * 1. is_main_path == TRUE:
+ * - going UP(TRUE,FALSE) on rest of the groups, each time on port 0,
+ * but only if the remote (upper) switch hasn't been already
+ * configured for this target LID
+ * + NOT promoting port counter
+ * + setting path in remote switch fwd tbl if it hasn't been set yet
+ * + setting hops in remote switch on all the ports of each group
+ * if it hasn't been set yet
+ *
+ * 2. is_main_path == FALSE:
+ * - going UP(TRUE,FALSE) on ALL the groups, each time on port 0,
+ * but only if the remote (upper) switch hasn't been already
+ * configured for this target LID
+ * + NOT promoting port counter
+ * + setting path in remote switch fwd tbl if it hasn't been set yet
+ * + setting hops in remote switch on all the ports of each group
+ * if it hasn't been set yet
+ *
+ * These two rules can be rephrased this way:
+ * - foreach UP port group
+ * + if remote switch has been set with the target LID
+ * - skip this port group
+ * + else
+ * - select port 0
+ * - do NOT promote port counter
+ * - set path in remote switch fwd tbl
+ * - set hops in remote switch on all the ports of this group
+ * - go UP(TRUE,FALSE) to the remote switch
+ */
+
+ for (i = is_main_path ? 1 : 0; i < p_sw->up_port_groups_num; i++) {
+ p_group = p_sw->up_port_groups[i];
+ p_remote_sw = p_group->remote_hca_or_sw.p_sw;
+
+ /* skip if target lid has been already set on remote switch fwd tbl (with a bigger hop count) */
+ if (p_remote_sw->p_osm_sw->new_lft[target_lid] != OSM_NO_PATH)
+ if (current_hops + 1 >=
+ sw_get_least_hops(p_remote_sw, target_lid))
+ continue;
+
+ if (p_sw->is_leaf) {
+ OSM_LOG(&p_ftree->p_osm->log, OSM_LOG_DEBUG,
+ " - Routing SECONDARY path for LID %u: %s --> %s\n",
+ target_lid,
+ tuple_to_str(p_sw->tuple),
+ tuple_to_str(p_remote_sw->tuple));
+ }
+
+ /* Routing REAL lids on SECONDARY path means routing
+ switch-to-switch or switch-to-CA paths.
+ We can safely assume that switch will initiate very
+ few traffic, so there's no point wasting runtime on
+ trying to balance these routes - always pick port 0. */
+ p_min_port = NULL;
+ ports_num = (uint16_t) cl_ptr_vector_get_size(&p_group->ports);
+ if(ports_num == 0)
+ continue;
+ for (j = 0; j < ports_num; j++) {
+ cl_ptr_vector_at(&p_group->ports, j, (void *)&p_port);
+ if (!p_min_port) {
+ /* first port that we're checking - use
+ it as a port with the lowest load */
+ p_min_port = p_port;
+ } else if (p_port->counter_down <
+ p_min_port->counter_down) {
+ /* this port is less loaded - use it as min */
+ p_min_port = p_port;
+ }
+ }
+
+ p_port = p_min_port;
+ p_remote_sw->p_osm_sw->new_lft[target_lid] =
+ p_port->remote_port_num;
+
+ /* On the remote switch that is pointed by the p_group,
+ set hops for ALL the ports in the remote group. */
+
+ set_hops_on_remote_sw(p_group, target_lid,
+ current_hops + 1, is_target_a_sw);
+
+ /* Recursion step:
+ Assign downgoing ports by stepping up, starting on REMOTE switch. */
+ routed = fabric_route_downgoing_by_going_up(p_ftree, p_remote_sw, /* remote switch - used as a route-downgoing alg. next step point */
+ p_sw, /* this switch - prev. position switch for the function */
+ target_lid, /* LID that we're routing to */
+ FALSE, /* whether this is path to HCA that should by tracked by counters */
+ is_target_a_sw, /* Whether target lid is a switch or not */
+ reverse_hop_credit, /* Remaining reverse_hops allowed */
+ reverse_hops, /* Number of reverse_hops done up to this point */
+ current_hops + 1);
+ created_route |= routed;
+ }
+
+ /* Now doing the same thing with horizontal links */
+ if (p_sw->sibling_port_groups_num > 0)
+ bubble_sort_down(p_sw->sibling_port_groups,
+ p_sw->sibling_port_groups_num);
+
+ for (i = 0; i < p_sw->sibling_port_groups_num; i++) {
+ p_group = p_sw->sibling_port_groups[i];
+ p_remote_sw = p_group->remote_hca_or_sw.p_sw;
+
+ /* skip if target lid has been already set on remote switch fwd tbl (with a bigger hop count) */
+ if (p_remote_sw->p_osm_sw->new_lft[target_lid] != OSM_NO_PATH)
+ if (current_hops + 1 >=
+ sw_get_least_hops(p_remote_sw, target_lid))
+ continue;
+
+ if (p_sw->is_leaf) {
+ OSM_LOG(&p_ftree->p_osm->log, OSM_LOG_DEBUG,
+ " - Routing SECONDARY path for LID %u: %s --> %s\n",
+ target_lid,
+ tuple_to_str(p_sw->tuple),
+ tuple_to_str(p_remote_sw->tuple));
+ }
+
+ /* Routing REAL lids on SECONDARY path means routing
+ switch-to-switch or switch-to-CA paths.
+ We can safely assume that switch will initiate very
+ few traffic, so there's no point wasting runtime on
+ trying to balance these routes - always pick port 0. */
+
+ p_min_port = NULL;
+ ports_num = (uint16_t) cl_ptr_vector_get_size(&p_group->ports);
+ for (j = 0; j < ports_num; j++) {
+ cl_ptr_vector_at(&p_group->ports, j, (void *)&p_port);
+ if (!p_min_port) {
+ /* first port that we're checking - use
+ it as a port with the lowest load */
+ p_min_port = p_port;
+ } else if (p_port->counter_down <
+ p_min_port->counter_down) {
+ /* this port is less loaded - use it as min */
+ p_min_port = p_port;
+ }
+ }
+
+ p_port = p_min_port;
+ p_remote_sw->p_osm_sw->new_lft[target_lid] =
+ p_port->remote_port_num;
+
+ /* On the remote switch that is pointed by the p_group,
+ set hops for ALL the ports in the remote group. */
+
+ set_hops_on_remote_sw(p_group, target_lid,
+ current_hops + 1, is_target_a_sw);
+
+ /* Recursion step:
+ Assign downgoing ports by stepping up, starting on REMOTE switch. */
+ routed = fabric_route_downgoing_by_going_up(p_ftree, p_remote_sw, /* remote switch - used as a route-downgoing alg. next step point */
+ p_sw, /* this switch - prev. position switch for the function */
+ target_lid, /* LID that we're routing to */
+ FALSE, /* whether this is path to HCA that should by tracked by counters */
+ is_target_a_sw, /* Whether target lid is a switch or not */
+ reverse_hop_credit, /* Remaining reverse_hops allowed */
+ reverse_hops, /* Number of reverse_hops done up to this point */
+ current_hops + 1);
+ created_route |= routed;
+ if (routed) {
+ p_min_group->counter_down++;
+ p_min_port->counter_down++;
+ }
+ }
+
+ /* If we don't have any reverse hop credits, we are done */
+ if (reverse_hop_credit == 0)
+ return created_route;
+
+ if (p_sw->is_leaf)
+ return created_route;
+
+ /* We explore all the down group ports */
+ /* We try to reverse jump for each of them */
+ /* They already have a route to us from the upgoing_by_going_down started earlier */
+ /* This is only so it'll continue exploring up, after this step backwards */
+ for (i = 0; i < p_sw->down_port_groups_num; i++) {
+ p_group = p_sw->down_port_groups[i];
+ p_remote_sw = p_group->remote_hca_or_sw.p_sw;
+
+ /* Skip this port group unless it points to a switch */
+ if (p_group->remote_node_type != IB_NODE_TYPE_SWITCH)
+ continue;
+
+ /* Recursion step:
+ Assign downgoing ports by stepping up, fter doing one step down starting on REMOTE switch. */
+ created_route |= fabric_route_downgoing_by_going_up(p_ftree, p_remote_sw, /* remote switch - used as a route-downgoing alg. next step point */
+ p_sw, /* this switch - prev. position switch for the function */
+ target_lid, /* LID that we're routing to */
+ TRUE, /* whether this is path to HCA that should by tracked by counters */
+ is_target_a_sw, /* Whether target lid is a switch or not */
+ reverse_hop_credit - 1, /* Remaining reverse_hops allowed */
+ reverse_hops + 1, /* Number of reverse_hops done up to this point */
+ current_hops
+ + 1);
+ }
+ return created_route;
+
+} /* ftree_fabric_route_downgoing_by_going_up() */
+
+/***************************************************/
+
+/*
+ * Pseudo code:
+ * foreach leaf switch (in indexing order)
+ * for each compute node (in indexing order)
+ * obtain the LID of the compute node
+ * set local LFT(LID) of the port connecting to compute node
+ * call assign-down-going-port-by-ascending-up(TRUE,TRUE) on CURRENT switch
+ * for each MISSING compute node
+ * call assign-down-going-port-by-ascending-up(FALSE,TRUE) on CURRENT switch
+ */
+
+static void fabric_route_to_cns(IN ftree_fabric_t * p_ftree)
+{
+ ftree_sw_t *p_sw;
+ ftree_hca_t *p_hca;
+ ftree_port_group_t *p_leaf_port_group;
+ ftree_port_group_t *p_hca_port_group;
+ ftree_port_t *p_port;
+ unsigned int i, j;
+ uint16_t hca_lid;
+ unsigned routed_targets_on_leaf;
+
+ OSM_LOG_ENTER(&p_ftree->p_osm->log);
+
+ /* for each leaf switch (in indexing order) */
+ for (i = 0; i < p_ftree->leaf_switches_num; i++) {
+ p_sw = p_ftree->leaf_switches[i];
+ routed_targets_on_leaf = 0;
+
+ /* for each HCA connected to this switch */
+ for (j = 0; j < p_sw->down_port_groups_num; j++) {
+ p_leaf_port_group = p_sw->down_port_groups[j];
+
+ /* work with this port group only if the remote node is CA */
+ if (p_leaf_port_group->remote_node_type !=
+ IB_NODE_TYPE_CA)
+ continue;
+
+ p_hca = p_leaf_port_group->remote_hca_or_sw.p_hca;
+
+ /* work with this port group only if remote HCA has CNs */
+ if (!p_hca->cn_num)
+ continue;
+
+ p_hca_port_group =
+ hca_get_port_group_by_lid(p_hca,
+ p_leaf_port_group->
+ remote_lid);
+ CL_ASSERT(p_hca_port_group);
+
+ /* work with this port group only if remote port is CN */
+ if (!p_hca_port_group->is_cn)
+ continue;
+
+ /* obtain the LID of HCA port */
+ hca_lid = p_leaf_port_group->remote_lid;
+
+ /* set local LFT(LID) to the port that is connected to HCA */
+ cl_ptr_vector_at(&p_leaf_port_group->ports, 0,
+ (void *)&p_port);
+ p_sw->p_osm_sw->new_lft[hca_lid] = p_port->port_num;
+
+ OSM_LOG(&p_ftree->p_osm->log, OSM_LOG_DEBUG,
+ "Switch %s: set path to CN LID %u through port %u\n",
+ tuple_to_str(p_sw->tuple),
+ hca_lid, p_port->port_num);
+
+ /* set local min hop table(LID) to route to the CA */
+ sw_set_hops(p_sw, hca_lid, p_port->port_num, 1, FALSE);
+
+ /* Assign downgoing ports by stepping up.
+ Since we're routing here only CNs, we're routing it as REAL
+ LID and updating fat-tree balancing counters. */
+ fabric_route_downgoing_by_going_up(p_ftree, p_sw, /* local switch - used as a route-downgoing alg. start point */
+ NULL, /* prev. position switch */
+ hca_lid, /* LID that we're routing to */
+ TRUE, /* whether this path to HCA should by tracked by counters */
+ FALSE, /* whether target lid is a switch or not */
+ 0, /* Number of reverse hops allowed */
+ 0, /* Number of reverse hops done yet */
+ 1); /* Number of hops done yet */
+
+ /* count how many real targets have been routed from this leaf switch */
+ routed_targets_on_leaf++;
+ }
+
+ /* We're done with the real targets (all CNs) of this leaf switch.
+ Now route the dummy HCAs that are missing or that are non-CNs.
+ When routing to dummy HCAs we don't fill lid matrices. */
+ if (p_ftree->max_cn_per_leaf > routed_targets_on_leaf) {
+ OSM_LOG(&p_ftree->p_osm->log, OSM_LOG_DEBUG,
+ "Routing %u dummy CAs\n",
+ p_ftree->max_cn_per_leaf -
+ p_sw->down_port_groups_num);
+ for (j = 0; j <
+ p_ftree->max_cn_per_leaf - routed_targets_on_leaf;
+ j++) {
+ ftree_sw_t *p_next_sw, *p_ftree_sw;
+ sw_set_hops(p_sw, 0, 0xFF, 1, FALSE);
+ /* assign downgoing ports by stepping up */
+ fabric_route_downgoing_by_going_up(p_ftree, p_sw, /* local switch - used as a route-downgoing alg. start point */
+ NULL, /* prev. position switch */
+ 0, /* LID that we're routing to - ignored for dummy HCA */
+ TRUE, /* whether this path to HCA should by tracked by counters */
+ FALSE, /* Whether the target LID is a switch or not */
+ 0, /* Number of reverse hops allowed */
+ 0, /* Number of reverse hops done yet */
+ 1); /* Number of hops done yet */
+
+ p_next_sw = (ftree_sw_t *) cl_qmap_head(&p_ftree->sw_tbl);
+ /* need to clean the LID 0 hops for dummy node */
+ while (p_next_sw != (ftree_sw_t *) cl_qmap_end(&p_ftree->sw_tbl)) {
+ p_ftree_sw = p_next_sw;
+ p_next_sw = (ftree_sw_t *) cl_qmap_next(&p_ftree_sw->map_item);
+ p_ftree_sw->hops[0] = OSM_NO_PATH;
+ p_ftree_sw->p_osm_sw->new_lft[0] = OSM_NO_PATH;
+ }
+
+ }
+ }
+ }
+ /* done going through all the leaf switches */
+ OSM_LOG_EXIT(&p_ftree->p_osm->log);
+} /* fabric_route_to_cns() */
+
+/***************************************************/
+
+/*
+ * Pseudo code:
+ * foreach HCA non-CN port in fabric
+ * obtain the LID of the HCA port
+ * get switch that is connected to this HCA port
+ * set switch LFT(LID) to the port connected to the HCA port
+ * call assign-down-going-port-by-ascending-up(TRUE,TRUE) on the switch
+ *
+ * Routing to these HCAs is routing a REAL hca lid on MAIN path.
+ * We want to allow load-leveling of the traffic to the non-CNs,
+ * because such nodes may include IO nodes with heavy usage
+ * - we should set fwd tables
+ * - we should update port counters
+ * Routing to non-CNs is done after routing to CNs, so updated port
+ * counters will not affect CN-to-CN routing.
+ */
+
+static void fabric_route_to_non_cns(IN ftree_fabric_t * p_ftree)
+{
+ ftree_sw_t *p_sw;
+ ftree_hca_t *p_hca;
+ ftree_hca_t *p_next_hca;
+ ftree_port_t *p_hca_port;
+ ftree_port_group_t *p_hca_port_group;
+ uint16_t hca_lid;
+ unsigned port_num_on_switch;
+ unsigned i;
+
+ OSM_LOG_ENTER(&p_ftree->p_osm->log);
+
+ p_next_hca = (ftree_hca_t *) cl_qmap_head(&p_ftree->hca_tbl);
+ while (p_next_hca != (ftree_hca_t *) cl_qmap_end(&p_ftree->hca_tbl)) {
+ p_hca = p_next_hca;
+ p_next_hca = (ftree_hca_t *) cl_qmap_next(&p_hca->map_item);
+
+ for (i = 0; i < p_hca->up_port_groups_num; i++) {
+ p_hca_port_group = p_hca->up_port_groups[i];
+
+ /* skip this port if it's CN, in which case it has been already routed */
+ if (p_hca_port_group->is_cn)
+ continue;
+
+ /* skip this port if it is not connected to switch */
+ if (p_hca_port_group->remote_node_type !=
+ IB_NODE_TYPE_SWITCH)
+ continue;
+
+ p_sw = p_hca_port_group->remote_hca_or_sw.p_sw;
+ hca_lid = p_hca_port_group->lid;
+
+ /* set switches LFT(LID) to the port that is connected to HCA */
+ cl_ptr_vector_at(&p_hca_port_group->ports, 0,
+ (void *)&p_hca_port);
+ port_num_on_switch = p_hca_port->remote_port_num;
+ p_sw->p_osm_sw->new_lft[hca_lid] = port_num_on_switch;
+
+ OSM_LOG(&p_ftree->p_osm->log, OSM_LOG_DEBUG,
+ "Switch %s: set path to non-CN HCA LID %u through port %u\n",
+ tuple_to_str(p_sw->tuple),
+ hca_lid, port_num_on_switch);
+
+ /* set local min hop table(LID) to route to the CA */
+ sw_set_hops(p_sw, hca_lid, port_num_on_switch, /* port num */
+ 1, FALSE); /* hops */
+
+ /* Assign downgoing ports by stepping up.
+ We're routing REAL targets. They are not CNs and not included
+ in the leafs array, but we treat them as MAIN path to allow load
+ leveling, which means that the counters will be updated. */
+ fabric_route_downgoing_by_going_up(p_ftree, p_sw, /* local switch - used as a route-downgoing alg. start point */
+ NULL, /* prev. position switch */
+ hca_lid, /* LID that we're routing to */
+ TRUE, /* whether this path to HCA should by tracked by counters */
+ FALSE, /* Whether the target LID is a switch or not */
+ p_hca_port_group->is_io ? p_ftree->p_osm->subn.opt.max_reverse_hops : 0, /* Number or reverse hops allowed */
+ 0, /* Number or reverse hops done yet */
+ 1); /* Number of hops done yet */
+ }
+ /* done with all the port groups of this HCA - go to next HCA */
+ }
+
+ OSM_LOG_EXIT(&p_ftree->p_osm->log);
+} /* fabric_route_to_non_cns() */
+
+/***************************************************/
+
+/*
+ * Pseudo code:
+ * foreach switch in fabric
+ * obtain its LID
+ * set local LFT(LID) to port 0
+ * call assign-down-going-port-by-ascending-up(TRUE,FALSE) on CURRENT switch
+ *
+ * Routing to switch is similar to routing a REAL hca lid on SECONDARY path:
+ * - we should set fwd tables
+ * - we should NOT update port counters
+ */
+
+static void fabric_route_to_switches(IN ftree_fabric_t * p_ftree)
+{
+ ftree_sw_t *p_sw;
+ ftree_sw_t *p_next_sw;
+
+ OSM_LOG_ENTER(&p_ftree->p_osm->log);
+
+ p_next_sw = (ftree_sw_t *) cl_qmap_head(&p_ftree->sw_tbl);
+ while (p_next_sw != (ftree_sw_t *) cl_qmap_end(&p_ftree->sw_tbl)) {
+ p_sw = p_next_sw;
+ p_next_sw = (ftree_sw_t *) cl_qmap_next(&p_sw->map_item);
+
+ /* set local LFT(LID) to 0 (route to itself) */
+ p_sw->p_osm_sw->new_lft[p_sw->lid] = 0;
+
+ OSM_LOG(&p_ftree->p_osm->log, OSM_LOG_DEBUG,
+ "Switch %s (LID %u): routing switch-to-switch paths\n",
+ tuple_to_str(p_sw->tuple), p_sw->lid);
+
+ /* set min hop table of the switch to itself */
+ sw_set_hops(p_sw, p_sw->lid, 0, /* port_num */
+ 0, TRUE); /* hops */
+
+ fabric_route_downgoing_by_going_up(p_ftree, p_sw, /* local switch - used as a route-downgoing alg. start point */
+ NULL, /* prev. position switch */
+ p_sw->lid, /* LID that we're routing to */
+ FALSE, /* whether this path to HCA should by tracked by counters */
+ TRUE, /* Whether the target LID is a switch or not */
+ 0, /* Number of reverse hops allowed */
+ 0, /* Number of reverse hops done yet */
+ 0); /* Number of hops done yet */
+ }
+
+ OSM_LOG_EXIT(&p_ftree->p_osm->log);
+} /* fabric_route_to_switches() */
+
+/***************************************************
+ ***************************************************/
+
+static void fabric_route_roots(IN ftree_fabric_t * p_ftree)
+{
+ uint16_t lid;
+ uint8_t port_num;
+ osm_port_t *p_port;
+ ftree_sw_t *p_sw;
+ ftree_sw_t *p_leaf_sw;
+
+ OSM_LOG_ENTER(&p_ftree->p_osm->log);
+
+ /*
+ * We need a switch that will accomodate all the down/up turns in
+ * the fabric. Having these turn in a single place in the fabric
+ * will not create credit loops.
+ * So we need to select this switch.
+ * The idea here is to chose leaf with the highest index. I don't
+ * have any theory to back me up on this. It's just a general thought
+ * that this way the switch that might be a bottleneck for many mcast
+ * groups will be far away from the OpenSM, so it will draw the
+ * multicast traffic away from the SM.
+ */
+
+ p_leaf_sw = p_ftree->leaf_switches[p_ftree->leaf_switches_num-1];
+
+ /*
+ * Now go over all the switches in the fabric that
+ * have lower rank, and route the missing LIDs to
+ * the selected leaf switch.
+ * In short, this leaf switch now poses a target
+ * for all those missing LIDs.
+ */
+
+ for (p_sw = (ftree_sw_t *) cl_qmap_head(&p_ftree->sw_tbl);
+ p_sw != (ftree_sw_t *) cl_qmap_end(&p_ftree->sw_tbl);
+ p_sw = (ftree_sw_t *) cl_qmap_next(&p_sw->map_item)) {
+
+ if (p_sw->rank >= p_ftree->leaf_switch_rank)
+ continue;
+
+ for (lid = 1; lid <= p_leaf_sw->p_osm_sw->max_lid_ho; lid ++) {
+
+ if (p_sw->p_osm_sw->new_lft[lid] != OSM_NO_PATH ||
+ p_leaf_sw->hops[lid] == OSM_NO_PATH)
+ continue;
+
+ p_port = osm_get_port_by_lid_ho(&p_ftree->p_osm->subn,
+ lid);
+
+ /* we're interested only in switches */
+ if (!p_port || !p_port->p_node->sw)
+ continue;
+
+ /*
+ * the missing LID will be routed through the same
+ * port that routes to the selected leaf switch
+ */
+ port_num = p_sw->p_osm_sw->new_lft[p_leaf_sw->lid];
+
+ OSM_LOG(&p_ftree->p_osm->log, OSM_LOG_DEBUG,
+ "Switch %s: setting path to LID %u "
+ "through port %u\n",
+ tuple_to_str(p_sw->tuple), lid, port_num);
+
+ /* set local lft */
+ p_sw->p_osm_sw->new_lft[lid] = port_num;
+
+ /*
+ * Set local min hop table.
+ * The distance to the target LID is a distance
+ * to the selected leaf switch plus the distance
+ * from the leaf to the target LID.
+ */
+ sw_set_hops(p_sw, lid, port_num,
+ p_sw->hops[p_leaf_sw->lid] +
+ p_leaf_sw->hops[lid], TRUE);
+ }
+ }
+
+ OSM_LOG_EXIT(&p_ftree->p_osm->log);
+} /* fabric_route_roots() */
+
+/***************************************************/
+
+static int fabric_populate_nodes(IN ftree_fabric_t * p_ftree)
+{
+ osm_node_t *p_osm_node;
+ osm_node_t *p_next_osm_node;
+
+ OSM_LOG_ENTER(&p_ftree->p_osm->log);
+
+ p_next_osm_node =
+ (osm_node_t *) cl_qmap_head(&p_ftree->p_osm->subn.node_guid_tbl);
+ while (p_next_osm_node !=
+ (osm_node_t *) cl_qmap_end(&p_ftree->p_osm->
+ subn.node_guid_tbl)) {
+ p_osm_node = p_next_osm_node;
+ p_next_osm_node =
+ (osm_node_t *) cl_qmap_next(&p_osm_node->map_item);
+ switch (osm_node_get_type(p_osm_node)) {
+ case IB_NODE_TYPE_CA:
+ fabric_add_hca(p_ftree, p_osm_node);
+ break;
+ case IB_NODE_TYPE_ROUTER:
+ break;
+ case IB_NODE_TYPE_SWITCH:
+ fabric_add_sw(p_ftree, p_osm_node->sw);
+ break;
+ default:
+ OSM_LOG(&p_ftree->p_osm->log, OSM_LOG_ERROR,
+ "ERR AB0E: " "Node GUID 0x%016" PRIx64
+ " - Unknown node type: %s\n",
+ cl_ntoh64(osm_node_get_node_guid(p_osm_node)),
+ ib_get_node_type_str(osm_node_get_type
+ (p_osm_node)));
+ OSM_LOG_EXIT(&p_ftree->p_osm->log);
+ return -1;
+ }
+ }
+
+ OSM_LOG_EXIT(&p_ftree->p_osm->log);
+ return 0;
+} /* fabric_populate_nodes() */
+
+/***************************************************
+ ***************************************************/
+
+static boolean_t sw_update_rank(IN ftree_sw_t * p_sw, IN uint32_t new_rank)
+{
+ if (sw_ranked(p_sw) && p_sw->rank <= new_rank)
+ return FALSE;
+ p_sw->rank = new_rank;
+ return TRUE;
+
+}
+
+/***************************************************/
+
+static void rank_switches_from_leafs(IN ftree_fabric_t * p_ftree,
+ IN cl_list_t * p_ranking_bfs_list)
+{
+ ftree_sw_t *p_sw;
+ ftree_sw_t *p_remote_sw;
+ osm_node_t *p_node;
+ osm_node_t *p_remote_node;
+ osm_physp_t *p_osm_port;
+ uint8_t i;
+ unsigned max_rank = 0;
+
+ while (!cl_is_list_empty(p_ranking_bfs_list)) {
+ p_sw = (ftree_sw_t *) cl_list_remove_head(p_ranking_bfs_list);
+ p_node = p_sw->p_osm_sw->p_node;
+
+ /* note: skipping port 0 on switches */
+ for (i = 1; i < osm_node_get_num_physp(p_node); i++) {
+ p_osm_port = osm_node_get_physp_ptr(p_node, i);
+ if (!p_osm_port || !osm_link_is_healthy(p_osm_port))
+ continue;
+
+ p_remote_node =
+ osm_node_get_remote_node(p_node, i, NULL);
+ if (!p_remote_node)
+ continue;
+ if (osm_node_get_type(p_remote_node) !=
+ IB_NODE_TYPE_SWITCH)
+ continue;
+
+ p_remote_sw = fabric_get_sw_by_guid(p_ftree,
+ osm_node_get_node_guid
+ (p_remote_node));
+ if (!p_remote_sw) {
+ /* remote node is not a switch */
+ continue;
+ }
+
+ /* if needed, rank the remote switch and add it to the BFS list */
+ if (sw_update_rank(p_remote_sw, p_sw->rank + 1)) {
+ max_rank = p_remote_sw->rank;
+ cl_list_insert_tail(p_ranking_bfs_list,
+ p_remote_sw);
+ }
+ }
+ }
+
+ /* set FatTree maximal switch rank */
+ p_ftree->max_switch_rank = max_rank;
+
+} /* rank_switches_from_leafs() */
+
+/***************************************************/
+
+static int rank_leaf_switches(IN ftree_fabric_t * p_ftree,
+ IN ftree_hca_t * p_hca,
+ IN cl_list_t * p_ranking_bfs_list)
+{
+ ftree_sw_t *p_sw;
+ osm_node_t *p_osm_node = p_hca->p_osm_node;
+ osm_node_t *p_remote_osm_node;
+ osm_physp_t *p_osm_port;
+ static uint8_t i = 0;
+ int res = 0;
+
+ OSM_LOG_ENTER(&p_ftree->p_osm->log);
+
+ for (i = 0; i < osm_node_get_num_physp(p_osm_node); i++) {
+ p_osm_port = osm_node_get_physp_ptr(p_osm_node, i);
+ if (!p_osm_port || !osm_link_is_healthy(p_osm_port))
+ continue;
+
+ p_remote_osm_node =
+ osm_node_get_remote_node(p_osm_node, i, NULL);
+ if (!p_remote_osm_node)
+ continue;
+
+ switch (osm_node_get_type(p_remote_osm_node)) {
+ case IB_NODE_TYPE_CA:
+ /* HCA connected directly to another HCA - not FatTree */
+ OSM_LOG(&p_ftree->p_osm->log, OSM_LOG_ERROR,
+ "ERR AB0F: "
+ "CA conected directly to another CA: " "0x%016"
+ PRIx64 " <---> 0x%016" PRIx64 "\n",
+ hca_get_guid_ho(p_hca),
+ cl_ntoh64(osm_node_get_node_guid
+ (p_remote_osm_node)));
+ res = -1;
+ goto Exit;
+
+ case IB_NODE_TYPE_ROUTER:
+ /* leaving this port - proceeding to the next one */
+ continue;
+
+ case IB_NODE_TYPE_SWITCH:
+ /* continue with this port */
+ break;
+
+ default:
+ OSM_LOG(&p_ftree->p_osm->log, OSM_LOG_ERROR,
+ "ERR AB10: Node GUID 0x%016" PRIx64
+ " - Unknown node type: %s\n",
+ cl_ntoh64(osm_node_get_node_guid
+ (p_remote_osm_node)),
+ ib_get_node_type_str(osm_node_get_type
+ (p_remote_osm_node)));
+ res = -1;
+ goto Exit;
+ }
+
+ /* remote node is switch */
+
+ p_sw = fabric_get_sw_by_guid(p_ftree,
+ osm_node_get_node_guid
+ (p_osm_port->p_remote_physp->
+ p_node));
+ CL_ASSERT(p_sw);
+
+ /* if needed, rank the remote switch and add it to the BFS list */
+
+ if (!sw_update_rank(p_sw, 0))
+ continue;
+ OSM_LOG(&p_ftree->p_osm->log, OSM_LOG_DEBUG,
+ "Marking rank of switch that is directly connected to CA:\n"
+ " - CA guid : 0x%016"
+ PRIx64 "\n"
+ " - Switch guid: 0x%016"
+ PRIx64 "\n"
+ " - Switch LID : %u\n",
+ hca_get_guid_ho(p_hca),
+ sw_get_guid_ho(p_sw), p_sw->lid);
+ cl_list_insert_tail(p_ranking_bfs_list, p_sw);
+ }
+
+Exit:
+ OSM_LOG_EXIT(&p_ftree->p_osm->log);
+ return res;
+} /* rank_leaf_switches() */
+
+/***************************************************/
+
+static void sw_reverse_rank(IN cl_map_item_t * const p_map_item,
+ IN void *context)
+{
+ ftree_fabric_t *p_ftree = (ftree_fabric_t *) context;
+ ftree_sw_t *p_sw = (ftree_sw_t * const)p_map_item;
+ if (p_sw->rank != 0xFFFFFFFF)
+ p_sw->rank = p_ftree->max_switch_rank - p_sw->rank;
+}
+
+/***************************************************
+ ***************************************************/
+
+static int
+fabric_construct_hca_ports(IN ftree_fabric_t * p_ftree, IN ftree_hca_t * p_hca)
+{
+ ftree_sw_t *p_remote_sw;
+ osm_node_t *p_node = p_hca->p_osm_node;
+ osm_node_t *p_remote_node;
+ uint8_t remote_node_type;
+ ib_net64_t remote_node_guid;
+ osm_physp_t *p_remote_osm_port;
+ uint8_t i;
+ uint8_t remote_port_num;
+ boolean_t is_cn;
+ boolean_t is_in_cn_file;
+ boolean_t is_io;
+ boolean_t is_cns_file_provided = fabric_cns_provided(p_ftree);
+ boolean_t is_ios_file_provided = fabric_ios_provided(p_ftree);
+ int res = 0;
+
+ for (i = 0; i < osm_node_get_num_physp(p_node); i++) {
+ osm_physp_t *p_osm_port = osm_node_get_physp_ptr(p_node, i);
+ is_io = FALSE;
+ is_cn = TRUE;
+ is_in_cn_file = FALSE;
+
+ if (!p_osm_port || !osm_link_is_healthy(p_osm_port))
+ continue;
+
+ if (p_hca->disconnected_ports[i])
+ continue;
+
+ p_remote_osm_port = osm_physp_get_remote(p_osm_port);
+ p_remote_node =
+ osm_node_get_remote_node(p_node, i, &remote_port_num);
+
+ if (!p_remote_osm_port || !p_remote_node)
+ continue;
+
+ remote_node_type = osm_node_get_type(p_remote_node);
+ remote_node_guid = osm_node_get_node_guid(p_remote_node);
+
+ switch (remote_node_type) {
+ case IB_NODE_TYPE_ROUTER:
+ /* leaving this port - proceeding to the next one */
+ continue;
+
+ case IB_NODE_TYPE_CA:
+ /* HCA connected directly to another HCA - not FatTree */
+ OSM_LOG(&p_ftree->p_osm->log, OSM_LOG_ERROR,
+ "ERR AB11: "
+ "CA conected directly to another CA: " "0x%016"
+ PRIx64 " <---> 0x%016" PRIx64 "\n",
+ cl_ntoh64(osm_node_get_node_guid(p_node)),
+ cl_ntoh64(remote_node_guid));
+ res = -1;
+ goto Exit;
+
+ case IB_NODE_TYPE_SWITCH:
+ /* continue with this port */
+ break;
+
+ default:
+ OSM_LOG(&p_ftree->p_osm->log, OSM_LOG_ERROR,
+ "ERR AB12: Node GUID 0x%016" PRIx64
+ " - Unknown node type: %s\n",
+ cl_ntoh64(remote_node_guid),
+ ib_get_node_type_str(remote_node_type));
+ res = -1;
+ goto Exit;
+ }
+
+ /* remote node is switch */
+
+ p_remote_sw = fabric_get_sw_by_guid(p_ftree, remote_node_guid);
+ CL_ASSERT(p_remote_sw);
+
+ /* If CN file is not supplied, then all the CAs considered as Compute Nodes.
+ Otherwise all the CAs are not CNs, and only guids that are present in the
+ CN file will be marked as compute nodes. */
+ if (is_cns_file_provided == TRUE) {
+ name_map_item_t *p_elem = (name_map_item_t *)
+ cl_qmap_get(&p_ftree->cn_guid_tbl,
+ cl_ntoh64(osm_physp_get_port_guid
+ (p_osm_port)));
+ if (p_elem == (name_map_item_t *)
+ cl_qmap_end(&p_ftree->cn_guid_tbl))
+ is_cn = FALSE;
+ else
+ is_in_cn_file = TRUE;
+ }
+ if (is_in_cn_file == FALSE && is_ios_file_provided == TRUE) {
+ name_map_item_t *p_elem = (name_map_item_t *)
+ cl_qmap_get(&p_ftree->io_guid_tbl,
+ cl_ntoh64(osm_physp_get_port_guid
+ (p_osm_port)));
+ if (p_elem != (name_map_item_t *)
+ cl_qmap_end(&p_ftree->io_guid_tbl)) {
+ is_io = TRUE;
+ is_cn = FALSE;
+ }
+ }
+
+ if (is_cn) {
+ p_ftree->cn_num++;
+ p_hca->cn_num++;
+ OSM_LOG(&p_ftree->p_osm->log, OSM_LOG_DEBUG,
+ "Marking CN port GUID 0x%016" PRIx64 "\n",
+ cl_ntoh64(osm_physp_get_port_guid(p_osm_port)));
+ } else if (is_io) {
+ OSM_LOG(&p_ftree->p_osm->log, OSM_LOG_DEBUG,
+ "Marking I/O port GUID 0x%016" PRIx64 "\n",
+ cl_ntoh64(osm_physp_get_port_guid(p_osm_port)));
+ } else {
+ OSM_LOG(&p_ftree->p_osm->log, OSM_LOG_DEBUG,
+ "Marking non-CN port GUID 0x%016" PRIx64 "\n",
+ cl_ntoh64(osm_physp_get_port_guid(p_osm_port)));
+ }
+ p_ftree->ca_ports++;
+
+ hca_add_port(p_ftree,
+ p_hca, /* local ftree_hca object */
+ i, /* local port number */
+ remote_port_num, /* remote port number */
+ cl_ntoh16(osm_node_get_base_lid(p_node, i)), /* local lid */
+ cl_ntoh16(osm_node_get_base_lid(p_remote_node, 0)), /* remote lid */
+ osm_physp_get_port_guid(p_osm_port), /* local port guid */
+ osm_physp_get_port_guid(p_remote_osm_port), /* remote port guid */
+ remote_node_guid, /* remote node guid */
+ remote_node_type, /* remote node type */
+ (void *)p_remote_sw, /* remote ftree_hca/sw object */
+ is_cn, is_io); /* whether this port is compute node */
+ }
+
+Exit:
+ return res;
+} /* fabric_construct_hca_ports() */
+
+/***************************************************
+ ***************************************************/
+
+static int fabric_construct_sw_ports(IN ftree_fabric_t * p_ftree,
+ IN ftree_sw_t * p_sw)
+{
+ ftree_hca_t *p_remote_hca;
+ ftree_sw_t *p_remote_sw;
+ osm_node_t *p_node = p_sw->p_osm_sw->p_node;
+ osm_node_t *p_remote_node;
+ uint16_t remote_lid;
+ uint8_t remote_node_type;
+ ib_net64_t remote_node_guid;
+ osm_physp_t *p_remote_osm_port;
+ ftree_direction_t direction;
+ void *p_remote_hca_or_sw;
+ uint8_t i;
+ uint8_t remote_port_num;
+ int res = 0;
+
+ CL_ASSERT(osm_node_get_type(p_node) == IB_NODE_TYPE_SWITCH);
+
+ for (i = 1; i < osm_node_get_num_physp(p_node); i++) {
+ osm_physp_t *p_osm_port = osm_node_get_physp_ptr(p_node, i);
+ if (!p_osm_port || !osm_link_is_healthy(p_osm_port))
+ continue;
+
+ p_remote_osm_port = osm_physp_get_remote(p_osm_port);
+ if (!p_remote_osm_port)
+ continue;
+
+ p_remote_node =
+ osm_node_get_remote_node(p_node, i, &remote_port_num);
+ if (!p_remote_node)
+ continue;
+
+ /* ignore any loopback connection on switch */
+ if (p_node == p_remote_node) {
+ OSM_LOG(&p_ftree->p_osm->log, OSM_LOG_DEBUG,
+ "Ignoring loopback on switch GUID 0x%016" PRIx64
+ ", LID %u, rank %u\n",
+ sw_get_guid_ho(p_sw),
+ p_sw->lid, p_sw->rank);
+ continue;
+ }
+
+ remote_node_type = osm_node_get_type(p_remote_node);
+ remote_node_guid = osm_node_get_node_guid(p_remote_node);
+
+ switch (remote_node_type) {
+ case IB_NODE_TYPE_ROUTER:
+ /* leaving this port - proceeding to the next one */
+ continue;
+
+ case IB_NODE_TYPE_CA:
+ /* switch connected to hca */
+
+ p_remote_hca =
+ fabric_get_hca_by_guid(p_ftree, remote_node_guid);
+ CL_ASSERT(p_remote_hca);
+
+ p_remote_hca_or_sw = (void *)p_remote_hca;
+ direction = FTREE_DIRECTION_DOWN;
+
+ remote_lid =
+ cl_ntoh16(osm_physp_get_base_lid(p_remote_osm_port));
+ break;
+
+ case IB_NODE_TYPE_SWITCH:
+ /* switch connected to another switch */
+
+ p_remote_sw =
+ fabric_get_sw_by_guid(p_ftree, remote_node_guid);
+ CL_ASSERT(p_remote_sw);
+
+ p_remote_hca_or_sw = (void *)p_remote_sw;
+
+ if (p_sw->rank > p_remote_sw->rank) {
+ direction = FTREE_DIRECTION_UP;
+ } else if (p_sw->rank == p_remote_sw->rank) {
+ direction = FTREE_DIRECTION_SAME;
+ } else
+ direction = FTREE_DIRECTION_DOWN;
+
+ /* switch LID is only in port 0 port_info structure */
+ remote_lid =
+ cl_ntoh16(osm_node_get_base_lid(p_remote_node, 0));
+
+ break;
+
+ default:
+ OSM_LOG(&p_ftree->p_osm->log, OSM_LOG_ERROR,
+ "ERR AB13: Node GUID 0x%016" PRIx64
+ " - Unknown node type: %s\n",
+ cl_ntoh64(remote_node_guid),
+ ib_get_node_type_str(remote_node_type));
+ res = -1;
+ goto Exit;
+ }
+ sw_add_port(p_sw, /* local ftree_sw object */
+ i, /* local port number */
+ remote_port_num, /* remote port number */
+ p_sw->lid, /* local lid */
+ remote_lid, /* remote lid */
+ osm_physp_get_port_guid(p_osm_port), /* local port guid */
+ osm_physp_get_port_guid(p_remote_osm_port), /* remote port guid */
+ remote_node_guid, /* remote node guid */
+ remote_node_type, /* remote node type */
+ p_remote_hca_or_sw, /* remote ftree_hca/sw object */
+ direction); /* port direction (up or down) */
+
+ /* Track the max lid (in host order) that exists in the fabric */
+ if (remote_lid > p_ftree->lft_max_lid)
+ p_ftree->lft_max_lid = remote_lid;
+ }
+
+Exit:
+ return res;
+} /* fabric_construct_sw_ports() */
+
+/***************************************************
+ ***************************************************/
+struct rank_root_cxt {
+ ftree_fabric_t *fabric;
+ cl_list_t *list;
+};
+/***************************************************
+ ***************************************************/
+static int rank_root_sw_by_guid(void *cxt, uint64_t guid, char *p)
+{
+ struct rank_root_cxt *c = cxt;
+ ftree_sw_t *sw;
+
+ sw = fabric_get_sw_by_guid(c->fabric, cl_hton64(guid));
+ if (!sw) {
+ /* the specified root guid wasn't found in the fabric */
+ OSM_LOG(&c->fabric->p_osm->log, OSM_LOG_ERROR, "ERR AB24: "
+ "Root switch GUID 0x%" PRIx64 " not found\n", guid);
+ return 0;
+ }
+
+ OSM_LOG(&c->fabric->p_osm->log, OSM_LOG_DEBUG,
+ "Ranking root switch with GUID 0x%" PRIx64 "\n", guid);
+ sw->rank = 0;
+ cl_list_insert_tail(c->list, sw);
+
+ return 0;
+}
+/***************************************************
+ ***************************************************/
+static boolean_t fabric_load_roots(IN ftree_fabric_t * p_ftree,
+ IN cl_list_t* p_ranking_bfs_list)
+{
+ struct rank_root_cxt context;
+ unsigned num_roots;
+
+ if (p_ranking_bfs_list) {
+
+ /* Rank all the roots and add them to list */
+ OSM_LOG(&p_ftree->p_osm->log, OSM_LOG_DEBUG,
+ "Fetching root nodes from file %s\n",
+ p_ftree->p_osm->subn.opt.root_guid_file);
+
+ context.fabric = p_ftree;
+ context.list = p_ranking_bfs_list;
+ if (parse_node_map(p_ftree->p_osm->subn.opt.root_guid_file,
+ rank_root_sw_by_guid, &context)) {
+ OSM_LOG(&p_ftree->p_osm->log, OSM_LOG_ERROR, "ERR AB2A: "
+ "cannot parse root guids file \'%s\'\n",
+ p_ftree->p_osm->subn.opt.root_guid_file);
+ return FALSE;
+ }
+
+ num_roots = cl_list_count(p_ranking_bfs_list);
+ if (!num_roots) {
+ OSM_LOG(&p_ftree->p_osm->log, OSM_LOG_ERROR, "ERR AB25: "
+ "No valid roots supplied\n");
+ return FALSE;
+ }
+
+ OSM_LOG(&p_ftree->p_osm->log, OSM_LOG_VERBOSE,
+ "Ranked %u valid root switches\n", num_roots);
+ }
+ return TRUE;
+}
+/***************************************************
+ ***************************************************/
+static int fabric_rank_from_roots(IN ftree_fabric_t * p_ftree,
+ IN cl_list_t* p_ranking_bfs_list)
+{
+ osm_node_t *p_osm_node;
+ osm_node_t *p_remote_osm_node;
+ osm_physp_t *p_osm_physp;
+ ftree_sw_t *p_sw;
+ ftree_sw_t *p_remote_sw;
+ int res = 0;
+ unsigned max_rank = 0;
+ unsigned i;
+
+ OSM_LOG_ENTER(&p_ftree->p_osm->log);
+
+ if (!p_ranking_bfs_list) {
+ res = -1;
+ goto Exit;
+ }
+ while (!cl_is_list_empty(p_ranking_bfs_list)) {
+ p_sw = (ftree_sw_t *) cl_list_remove_head(p_ranking_bfs_list);
+ p_osm_node = p_sw->p_osm_sw->p_node;
+
+ /* note: skipping port 0 on switches */
+ for (i = 1; i < osm_node_get_num_physp(p_osm_node); i++) {
+ p_osm_physp = osm_node_get_physp_ptr(p_osm_node, i);
+ if (!p_osm_physp || !osm_link_is_healthy(p_osm_physp))
+ continue;
+
+ p_remote_osm_node =
+ osm_node_get_remote_node(p_osm_node, i, NULL);
+ if (!p_remote_osm_node)
+ continue;
+
+ if (osm_node_get_type(p_remote_osm_node) !=
+ IB_NODE_TYPE_SWITCH)
+ continue;
+
+ p_remote_sw = fabric_get_sw_by_guid(p_ftree,
+ osm_node_get_node_guid
+ (p_remote_osm_node));
+ CL_ASSERT(p_remote_sw);
+
+ /* if needed, rank the remote switch and add it to the BFS list */
+ if (sw_update_rank(p_remote_sw, p_sw->rank + 1)) {
+ OSM_LOG(&p_ftree->p_osm->log, OSM_LOG_DEBUG,
+ "Ranking switch 0x%" PRIx64
+ " with rank %u\n",
+ sw_get_guid_ho(p_remote_sw),
+ p_remote_sw->rank);
+ max_rank = p_remote_sw->rank;
+ cl_list_insert_tail(p_ranking_bfs_list,
+ p_remote_sw);
+ }
+ }
+ /* done with ports of this switch - go to the next switch in the list */
+ }
+
+ OSM_LOG(&p_ftree->p_osm->log, OSM_LOG_VERBOSE,
+ "Subnet ranking completed. Max Node Rank = %u\n", max_rank);
+
+ /* set FatTree maximal switch rank */
+ p_ftree->max_switch_rank = max_rank;
+
+Exit:
+ OSM_LOG_EXIT(&p_ftree->p_osm->log);
+ return res;
+} /* fabric_rank_from_roots() */
+
+/***************************************************
+ ***************************************************/
+
+static int fabric_rank_from_hcas(IN ftree_fabric_t * p_ftree)
+{
+ ftree_hca_t *p_hca;
+ ftree_hca_t *p_next_hca;
+ cl_list_t ranking_bfs_list;
+ int res = 0;
+
+ OSM_LOG_ENTER(&p_ftree->p_osm->log);
+
+ cl_list_init(&ranking_bfs_list, 10);
+
+ /* Mark REVERSED rank of all the switches in the subnet.
+ Start from switches that are connected to hca's, and
+ scan all the switches in the subnet. */
+ p_next_hca = (ftree_hca_t *) cl_qmap_head(&p_ftree->hca_tbl);
+ while (p_next_hca != (ftree_hca_t *) cl_qmap_end(&p_ftree->hca_tbl)) {
+ p_hca = p_next_hca;
+ p_next_hca = (ftree_hca_t *) cl_qmap_next(&p_hca->map_item);
+ if (rank_leaf_switches(p_ftree, p_hca, &ranking_bfs_list) != 0) {
+ res = -1;
+ OSM_LOG(&p_ftree->p_osm->log, OSM_LOG_ERROR,
+ "ERR AB14: "
+ "Subnet ranking failed - subnet is not FatTree");
+ goto Exit;
+ }
+ }
+
+ /* Now rank rest of the switches in the fabric, while the
+ list already contains all the ranked leaf switches */
+ rank_switches_from_leafs(p_ftree, &ranking_bfs_list);
+
+ /* fix ranking of the switches by reversing the ranking direction */
+ cl_qmap_apply_func(&p_ftree->sw_tbl, sw_reverse_rank, (void *)p_ftree);
+
+Exit:
+ cl_list_destroy(&ranking_bfs_list);
+ OSM_LOG_EXIT(&p_ftree->p_osm->log);
+ return res;
+} /* fabric_rank_from_hcas() */
+
+/***************************************************
+ * After ranking from HCA's we want to re-rank using
+ * the roots
+ ***************************************************/
+static int fabric_rerank_using_root(IN ftree_fabric_t * p_ftree,
+ IN cl_list_t* p_ranking_bfs_list)
+{
+ ftree_sw_t *p_sw = NULL;
+ ftree_sw_t *p_next_sw;
+ int res;
+
+ OSM_LOG_ENTER(&p_ftree->p_osm->log);
+
+ p_next_sw = (ftree_sw_t *) cl_qmap_head(&p_ftree->sw_tbl);
+ while (p_next_sw != (ftree_sw_t *) cl_qmap_end(&p_ftree->sw_tbl)) {
+ p_sw = p_next_sw;
+ p_next_sw = (ftree_sw_t *) cl_qmap_next(&p_sw->map_item);
+ if (p_sw->rank == 0)
+ cl_list_insert_tail(p_ranking_bfs_list, p_sw);
+ else
+ p_sw->rank = 0xFFFFFFFF;
+ }
+ res = fabric_rank_from_roots(p_ftree, p_ranking_bfs_list);
+ OSM_LOG_EXIT(&p_ftree->p_osm->log);
+ return res;
+}
+/***************************************************
+ ***************************************************/
+static int fabric_rank(IN ftree_fabric_t * p_ftree)
+{
+ int res = -1;
+ cl_list_t ranking_bfs_list;
+
+ OSM_LOG_ENTER(&p_ftree->p_osm->log);
+ cl_list_init(&ranking_bfs_list, 10);
+
+ if (fabric_roots_provided(p_ftree) &&
+ fabric_load_roots(p_ftree, &ranking_bfs_list))
+ res = fabric_rank_from_roots(p_ftree, &ranking_bfs_list);
+ else {
+ res = fabric_rank_from_hcas(p_ftree);
+ if (!res)
+ res = fabric_rerank_using_root(p_ftree, &ranking_bfs_list);
+ }
+
+ if (res)
+ goto Exit;
+
+ OSM_LOG(&p_ftree->p_osm->log, OSM_LOG_VERBOSE,
+ "FatTree max switch rank is %u\n", p_ftree->max_switch_rank);
+
+Exit:
+ cl_list_destroy(&ranking_bfs_list);
+ OSM_LOG_EXIT(&p_ftree->p_osm->log);
+ return res;
+} /* fabric_rank() */
+
+/***************************************************
+ ***************************************************/
+
+static void fabric_set_leaf_rank(IN ftree_fabric_t * p_ftree)
+{
+ unsigned i;
+ ftree_sw_t *p_sw;
+ ftree_hca_t *p_hca = NULL;
+ ftree_hca_t *p_next_hca;
+
+ OSM_LOG_ENTER(&p_ftree->p_osm->log);
+
+ if (!fabric_roots_provided(p_ftree)) {
+ /* If root file is not provided, the fabric has to be pure fat-tree
+ in terms of ranking. Thus, leaf switches rank is the max rank. */
+ p_ftree->leaf_switch_rank = p_ftree->max_switch_rank;
+ } else {
+ /* Find the first CN and set the leaf_switch_rank to the rank
+ of the switch that is connected to this CN. Later we will
+ ensure that all the leaf switches have the same rank. */
+ p_next_hca = (ftree_hca_t *) cl_qmap_head(&p_ftree->hca_tbl);
+ while (p_next_hca !=
+ (ftree_hca_t *) cl_qmap_end(&p_ftree->hca_tbl)) {
+ p_hca = p_next_hca;
+ if (p_hca->cn_num)
+ break;
+ p_next_hca =
+ (ftree_hca_t *) cl_qmap_next(&p_hca->map_item);
+ }
+ /* we know that there are CNs in the fabric, so just to be sure... */
+ CL_ASSERT(p_next_hca !=
+ (ftree_hca_t *) cl_qmap_end(&p_ftree->hca_tbl));
+
+ OSM_LOG(&p_ftree->p_osm->log, OSM_LOG_DEBUG,
+ "Selected CN port GUID 0x%" PRIx64 "\n",
+ hca_get_guid_ho(p_hca));
+
+ for (i = 0; (i < p_hca->up_port_groups_num)
+ && (!p_hca->up_port_groups[i]->is_cn); i++)
+ ;
+ CL_ASSERT(i < p_hca->up_port_groups_num);
+ CL_ASSERT(p_hca->up_port_groups[i]->remote_node_type ==
+ IB_NODE_TYPE_SWITCH);
+
+ p_sw = p_hca->up_port_groups[i]->remote_hca_or_sw.p_sw;
+ OSM_LOG(&p_ftree->p_osm->log, OSM_LOG_DEBUG,
+ "Selected leaf switch GUID 0x%" PRIx64 ", rank %u\n",
+ sw_get_guid_ho(p_sw), p_sw->rank);
+ p_ftree->leaf_switch_rank = p_sw->rank;
+ }
+
+ OSM_LOG(&p_ftree->p_osm->log, OSM_LOG_VERBOSE,
+ "FatTree leaf switch rank is %u\n", p_ftree->leaf_switch_rank);
+ OSM_LOG_EXIT(&p_ftree->p_osm->log);
+} /* fabric_set_leaf_rank() */
+
+/***************************************************
+ ***************************************************/
+
+static int fabric_populate_ports(IN ftree_fabric_t * p_ftree)
+{
+ ftree_hca_t *p_hca;
+ ftree_hca_t *p_next_hca;
+ ftree_sw_t *p_sw;
+ ftree_sw_t *p_next_sw;
+ int res = 0;
+
+ OSM_LOG_ENTER(&p_ftree->p_osm->log);
+
+ p_next_hca = (ftree_hca_t *) cl_qmap_head(&p_ftree->hca_tbl);
+ while (p_next_hca != (ftree_hca_t *) cl_qmap_end(&p_ftree->hca_tbl)) {
+ p_hca = p_next_hca;
+ p_next_hca = (ftree_hca_t *) cl_qmap_next(&p_hca->map_item);
+ if (fabric_construct_hca_ports(p_ftree, p_hca) != 0) {
+ res = -1;
+ goto Exit;
+ }
+ }
+
+ p_next_sw = (ftree_sw_t *) cl_qmap_head(&p_ftree->sw_tbl);
+ while (p_next_sw != (ftree_sw_t *) cl_qmap_end(&p_ftree->sw_tbl)) {
+ p_sw = p_next_sw;
+ p_next_sw = (ftree_sw_t *) cl_qmap_next(&p_sw->map_item);
+ if (fabric_construct_sw_ports(p_ftree, p_sw) != 0) {
+ res = -1;
+ goto Exit;
+ }
+ }
+Exit:
+ OSM_LOG_EXIT(&p_ftree->p_osm->log);
+ return res;
+} /* fabric_populate_ports() */
+
+/***************************************************
+ ***************************************************/
+static int add_guid_item_to_map(void *cxt, uint64_t guid, char *p)
+{
+ cl_qmap_t *map = cxt;
+ name_map_item_t *item;
+ name_map_item_t *inserted_item;
+
+ item = malloc(sizeof(*item));
+ if (!item)
+ return -1;
+
+ item->guid = guid;
+ inserted_item = (name_map_item_t *) cl_qmap_insert(map, guid, &item->item);
+ if (inserted_item != item)
+ free(item);
+
+ return 0;
+}
+
+static int fabric_read_guid_files(IN ftree_fabric_t * p_ftree)
+{
+ int status = 0;
+
+ OSM_LOG_ENTER(&p_ftree->p_osm->log);
+
+ if (fabric_cns_provided(p_ftree)) {
+ OSM_LOG(&p_ftree->p_osm->log, OSM_LOG_DEBUG,
+ "Fetching compute nodes from file %s\n",
+ p_ftree->p_osm->subn.opt.cn_guid_file);
+
+ if (parse_node_map(p_ftree->p_osm->subn.opt.cn_guid_file,
+ add_guid_item_to_map,
+ &p_ftree->cn_guid_tbl)) {
+ OSM_LOG(&p_ftree->p_osm->log, OSM_LOG_ERROR,
+ "ERR AB23: " "Problem parsing CN guid file\n");
+ status = -1;
+ goto Exit;
+ }
+
+ if (!cl_qmap_count(&p_ftree->cn_guid_tbl)) {
+ OSM_LOG(&p_ftree->p_osm->log, OSM_LOG_ERROR,
+ "ERR AB27: "
+ "Compute node guids file has no valid guids\n");
+ status = -1;
+ goto Exit;
+ }
+ }
+
+ if (fabric_ios_provided(p_ftree)) {
+ OSM_LOG(&p_ftree->p_osm->log, OSM_LOG_DEBUG,
+ "Fetching I/O nodes from file %s\n",
+ p_ftree->p_osm->subn.opt.io_guid_file);
+
+ if (parse_node_map(p_ftree->p_osm->subn.opt.io_guid_file,
+ add_guid_item_to_map,
+ &p_ftree->io_guid_tbl)) {
+ OSM_LOG(&p_ftree->p_osm->log, OSM_LOG_ERROR,
+ "ERR AB28: Problem parsing I/O guid file\n");
+ status = -1;
+ goto Exit;
+ }
+
+ if (!cl_qmap_count(&p_ftree->io_guid_tbl)) {
+ OSM_LOG(&p_ftree->p_osm->log, OSM_LOG_ERROR,
+ "ERR AB29: "
+ "I/O node guids file has no valid guids\n");
+ status = -1;
+ goto Exit;
+ }
+ }
+Exit:
+ OSM_LOG_EXIT(&p_ftree->p_osm->log);
+ return status;
+} /*fabric_read_guid_files() */
+
+/***************************************************
+ ***************************************************/
+/* Get a Sw and remove all depended HCA's, meaning all
+ * HCA's which this is the only switch they are connected
+ * to */
+static int remove_depended_hca(IN ftree_fabric_t *p_ftree, IN ftree_sw_t *p_sw)
+{
+ ftree_hca_t *p_hca;
+ int counter = 0;
+ int port_num;
+ uint8_t remote_port_num;
+ osm_physp_t* physp;
+ osm_node_t* sw_node;
+ uint64_t remote_hca_guid;
+
+ sw_node = p_sw->p_osm_sw->p_node;
+ for (port_num = 0; port_num < sw_node->physp_tbl_size; port_num++) {
+ physp = osm_node_get_physp_ptr(sw_node, port_num);
+ if (physp && physp->p_remote_physp) {
+ if (osm_node_get_type(physp->p_remote_physp->p_node) == IB_NODE_TYPE_CA) {
+ remote_hca_guid =
+ osm_node_get_node_guid(physp->p_remote_physp->p_node);
+ p_hca = fabric_get_hca_by_guid(p_ftree, remote_hca_guid);
+ if (!p_hca)
+ continue;
+
+ remote_port_num =
+ osm_physp_get_port_num(physp->p_remote_physp);
+ p_hca->disconnected_ports[remote_port_num] = 1;
+ }
+ }
+ }
+ return counter;
+}
+/***************************************************
+ ***************************************************/
+static void fabric_remove_unranked_sw(IN ftree_fabric_t *p_ftree)
+{
+ ftree_sw_t *p_sw = NULL;
+ ftree_sw_t *p_next_sw;
+ int removed_hca;
+ int count = 0;
+
+ p_next_sw = (ftree_sw_t *) cl_qmap_head(&p_ftree->sw_tbl);
+ while (p_next_sw != (ftree_sw_t *) cl_qmap_end(&p_ftree->sw_tbl)) {
+ p_sw = p_next_sw;
+ p_next_sw = (ftree_sw_t *) cl_qmap_next(&p_sw->map_item);
+ if (!sw_ranked(p_sw)) {
+ cl_qmap_remove_item(&p_ftree->sw_tbl,&p_sw->map_item);
+ removed_hca = remove_depended_hca(p_ftree, p_sw);
+ OSM_LOG(&p_ftree->p_osm->log, OSM_LOG_VERBOSE,
+ "Removing Unranked sw 0x%" PRIx64 " (with %d dependent hca's)\n",
+ sw_get_guid_ho(p_sw),removed_hca);
+ sw_destroy(p_sw);
+ count++;
+ }
+ }
+ OSM_LOG(&p_ftree->p_osm->log, OSM_LOG_DEBUG,
+ "Removed %d invalid switches\n", count);
+}
+/***************************************************
+ ***************************************************/
+static int construct_fabric(IN void *context)
+{
+ ftree_fabric_t *p_ftree = context;
+ int status = 0;
+
+ OSM_LOG_ENTER(&p_ftree->p_osm->log);
+
+ fabric_clear(p_ftree);
+
+ if (p_ftree->p_osm->subn.opt.lmc > 0) {
+ osm_log_v2(&p_ftree->p_osm->log, OSM_LOG_INFO, FILE_ID,
+ "LMC > 0 is not supported by fat-tree routing.\n"
+ "Falling back to default routing\n");
+ status = -1;
+ goto Exit;
+ }
+
+ if (cl_qmap_count(&p_ftree->p_osm->subn.sw_guid_tbl) < 2) {
+ osm_log_v2(&p_ftree->p_osm->log, OSM_LOG_INFO, FILE_ID,
+ "Fabric has %u switches - topology is not fat-tree.\n"
+ "Falling back to default routing\n",
+ cl_qmap_count(&p_ftree->p_osm->subn.sw_guid_tbl));
+ status = -1;
+ goto Exit;
+ }
+
+ if ((cl_qmap_count(&p_ftree->p_osm->subn.node_guid_tbl) -
+ cl_qmap_count(&p_ftree->p_osm->subn.sw_guid_tbl)) < 2) {
+ osm_log_v2(&p_ftree->p_osm->log, OSM_LOG_INFO, FILE_ID,
+ "Fabric has %u nodes (%u switches) - topology is not fat-tree.\n"
+ "Falling back to default routing\n",
+ cl_qmap_count(&p_ftree->p_osm->subn.node_guid_tbl),
+ cl_qmap_count(&p_ftree->p_osm->subn.sw_guid_tbl));
+ status = -1;
+ goto Exit;
+ }
+
+ OSM_LOG(&p_ftree->p_osm->log, OSM_LOG_VERBOSE, "\n"
+ " |----------------------------------------|\n"
+ " |- Starting FatTree fabric construction -|\n"
+ " |----------------------------------------|\n\n");
+
+ OSM_LOG(&p_ftree->p_osm->log, OSM_LOG_VERBOSE,
+ "Populating FatTree Switch and CA tables\n");
+ if (fabric_populate_nodes(p_ftree) != 0) {
+ osm_log_v2(&p_ftree->p_osm->log, OSM_LOG_INFO, FILE_ID,
+ "Fabric topology is not fat-tree - "
+ "falling back to default routing\n");
+ status = -1;
+ goto Exit;
+ }
+
+ OSM_LOG(&p_ftree->p_osm->log, OSM_LOG_VERBOSE,
+ "Reading guid files provided by user\n");
+ if (fabric_read_guid_files(p_ftree) != 0) {
+ osm_log_v2(&p_ftree->p_osm->log, OSM_LOG_INFO, FILE_ID,
+ "Failed reading guid files - "
+ "falling back to default routing\n");
+ status = -1;
+ goto Exit;
+ }
+
+ if (cl_qmap_count(&p_ftree->hca_tbl) < 2) {
+ osm_log_v2(&p_ftree->p_osm->log, OSM_LOG_INFO, FILE_ID,
+ "Fabric has %u CAs - topology is not fat-tree.\n"
+ "Falling back to default routing\n",
+ cl_qmap_count(&p_ftree->hca_tbl));
+ status = -1;
+ goto Exit;
+ }
+
+ /* Rank all the switches in the fabric.
+ After that we will know only fabric max switch rank.
+ We will be able to check leaf switches rank and the
+ whole tree rank after filling ports and marking CNs. */
+ OSM_LOG(&p_ftree->p_osm->log, OSM_LOG_VERBOSE, "Ranking FatTree\n");
+ if (fabric_rank(p_ftree) != 0) {
+ osm_log_v2(&p_ftree->p_osm->log, OSM_LOG_INFO, FILE_ID,
+ "Failed ranking the tree\n");
+ status = -1;
+ goto Exit;
+ }
+ fabric_remove_unranked_sw(p_ftree);
+
+ if (p_ftree->max_switch_rank == 0 &&
+ cl_qmap_count(&p_ftree->sw_tbl) > 1) {
+ OSM_LOG(&p_ftree->p_osm->log, OSM_LOG_ERROR,
+ "ERR AB2B: Found more than one root on fabric with "
+ "maximum rank 0\n");
+ status = -1;
+ goto Exit;
+ }
+
+ /* For each hca and switch, construct array of ports.
+ This is done after the whole FatTree data structure is ready,
+ because we want the ports to have pointers to ftree_{sw,hca}_t
+ objects, and we need the switches to be already ranked because
+ that's how the port direction is determined. */
+ OSM_LOG(&p_ftree->p_osm->log, OSM_LOG_VERBOSE,
+ "Populating CA & switch ports\n");
+ if (fabric_populate_ports(p_ftree) != 0) {
+ osm_log_v2(&p_ftree->p_osm->log, OSM_LOG_INFO, FILE_ID,
+ "Fabric topology is not a fat-tree\n");
+ status = -1;
+ goto Exit;
+ } else if (p_ftree->cn_num == 0) {
+ osm_log_v2(&p_ftree->p_osm->log, OSM_LOG_INFO, FILE_ID,
+ "Fabric has no valid compute nodes\n");
+ status = -1;
+ goto Exit;
+ }
+
+ /* Now that the CA ports have been created and CNs were marked,
+ we can complete the fabric ranking - set leaf switches rank. */
+ fabric_set_leaf_rank(p_ftree);
+
+ if (fabric_get_rank(p_ftree) > FAT_TREE_MAX_RANK ||
+ fabric_get_rank(p_ftree) < FAT_TREE_MIN_RANK) {
+ osm_log_v2(&p_ftree->p_osm->log, OSM_LOG_INFO, FILE_ID,
+ "Fabric rank is %u (should be between %u and %u)\n",
+ fabric_get_rank(p_ftree), FAT_TREE_MIN_RANK,
+ FAT_TREE_MAX_RANK);
+ status = -1;
+ goto Exit;
+ }
+
+ /* Mark all the switches in the fabric with rank equal to
+ p_ftree->leaf_switch_rank and that are also connected to CNs.
+ As a by-product, this function also runs basic topology
+ validation - it checks that all the CNs are at the same rank. */
+ if (fabric_mark_leaf_switches(p_ftree)) {
+ osm_log_v2(&p_ftree->p_osm->log, OSM_LOG_INFO, FILE_ID,
+ "Fabric topology is not a fat-tree\n");
+ status = -1;
+ goto Exit;
+ }
+
+ /* Assign index to all the switches in the fabric.
+ This function also sorts leaf switch array by the switch index,
+ sorts all the port arrays of the indexed switches by remote
+ switch index, and creates switch-by-tuple table (sw_by_tuple_tbl) */
+ fabric_make_indexing(p_ftree);
+
+ /* Create leaf switch array sorted by index.
+ This array contains switches with rank equal to p_ftree->leaf_switch_rank
+ and that are also connected to CNs (REAL leafs), and it may contain
+ switches at the same leaf rank w/o CNs, if this is the order of indexing.
+ In any case, the first and the last switches in the array are REAL leafs. */
+ if (fabric_create_leaf_switch_array(p_ftree)) {
+ osm_log_v2(&p_ftree->p_osm->log, OSM_LOG_INFO, FILE_ID,
+ "Fabric topology is not a fat-tree\n");
+ status = -1;
+ goto Exit;
+ }
+
+ /* calculate and set ftree.max_cn_per_leaf field */
+ fabric_set_max_cn_per_leaf(p_ftree);
+
+ /* print general info about fabric topology */
+ fabric_dump_general_info(p_ftree);
+
+ /* dump full tree topology */
+ if (OSM_LOG_IS_ACTIVE_V2(&p_ftree->p_osm->log, OSM_LOG_DEBUG))
+ fabric_dump(p_ftree);
+
+ /* the fabric is required to be PURE fat-tree only if the root
+ guid file hasn't been provided by user */
+ if (!fabric_roots_provided(p_ftree) &&
+ !fabric_validate_topology(p_ftree)) {
+ osm_log_v2(&p_ftree->p_osm->log, OSM_LOG_INFO, FILE_ID,
+ "Fabric topology is not a fat-tree\n");
+ status = -1;
+ goto Exit;
+ }
+
+ OSM_LOG(&p_ftree->p_osm->log, OSM_LOG_VERBOSE,
+ "Max LID in switch LFTs: %u\n", p_ftree->lft_max_lid);
+
+ /* Build the full lid matrices needed for multicast routing */
+ osm_ucast_mgr_build_lid_matrices(&p_ftree->p_osm->sm.ucast_mgr);
+
+Exit:
+ if (status != 0) {
+ OSM_LOG(&p_ftree->p_osm->log, OSM_LOG_VERBOSE,
+ "Clearing FatTree Fabric data structures\n");
+ fabric_clear(p_ftree);
+ } else
+ p_ftree->fabric_built = TRUE;
+
+ OSM_LOG(&p_ftree->p_osm->log, OSM_LOG_VERBOSE, "\n"
+ " |--------------------------------------------------|\n"
+ " |- Done constructing FatTree fabric (status = %d) -|\n"
+ " |--------------------------------------------------|\n\n",
+ status);
+
+ OSM_LOG_EXIT(&p_ftree->p_osm->log);
+ return status;
+} /* construct_fabric() */
+
+/***************************************************
+ ***************************************************/
+
+static int do_routing(IN void *context)
+{
+ ftree_fabric_t *p_ftree = context;
+ int status = 0;
+
+ OSM_LOG_ENTER(&p_ftree->p_osm->log);
+
+ if (!p_ftree->fabric_built) {
+ status = -1;
+ goto Exit;
+ }
+
+ OSM_LOG(&p_ftree->p_osm->log, OSM_LOG_VERBOSE,
+ "Starting FatTree routing\n");
+
+ OSM_LOG(&p_ftree->p_osm->log, OSM_LOG_VERBOSE,
+ "Filling switch forwarding tables for Compute Nodes\n");
+ fabric_route_to_cns(p_ftree);
+
+ OSM_LOG(&p_ftree->p_osm->log, OSM_LOG_VERBOSE,
+ "Filling switch forwarding tables for non-CN targets\n");
+ fabric_route_to_non_cns(p_ftree);
+
+ OSM_LOG(&p_ftree->p_osm->log, OSM_LOG_VERBOSE,
+ "Filling switch forwarding tables for switch-to-switch paths\n");
+ fabric_route_to_switches(p_ftree);
+
+ if (p_ftree->p_osm->subn.opt.connect_roots) {
+ OSM_LOG(&p_ftree->p_osm->log, OSM_LOG_VERBOSE,
+ "Connecting switches that are unreachable within "
+ "Up/Down rules\n");
+ fabric_route_roots(p_ftree);
+ }
+
+ /* for each switch, set its fwd table */
+ cl_qmap_apply_func(&p_ftree->sw_tbl, set_sw_fwd_table, (void *)p_ftree);
+
+ /* write out hca ordering file */
+ fabric_dump_hca_ordering(p_ftree);
+
+ OSM_LOG(&p_ftree->p_osm->log, OSM_LOG_VERBOSE,
+ "FatTree routing is done\n");
+
+Exit:
+ OSM_LOG_EXIT(&p_ftree->p_osm->log);
+ return status;
+}
+
+/***************************************************
+ ***************************************************/
+
+static void delete(IN void *context)
+{
+ if (!context)
+ return;
+ fabric_destroy((ftree_fabric_t *) context);
+}
+
+/***************************************************
+ ***************************************************/
+
+int osm_ucast_ftree_setup(struct osm_routing_engine *r, osm_opensm_t * p_osm)
+{
+ ftree_fabric_t *p_ftree = fabric_create();
+ if (!p_ftree)
+ return -1;
+
+ p_ftree->p_osm = p_osm;
+ p_ftree->p_subn = p_osm->sm.ucast_mgr.p_subn;
+
+ r->context = (void *)p_ftree;
+ r->build_lid_matrices = construct_fabric;
+ r->ucast_build_fwd_tables = do_routing;
+ r->destroy = delete;
+
+ return 0;
+}
diff --git a/contrib/ofed/opensm/opensm/osm_ucast_lash.c b/contrib/ofed/opensm/opensm/osm_ucast_lash.c
new file mode 100644
index 0000000..b0d9fbc
--- /dev/null
+++ b/contrib/ofed/opensm/opensm/osm_ucast_lash.c
@@ -0,0 +1,1331 @@
+/*
+ * Copyright (c) 2004-2009 Voltaire, Inc. All rights reserved.
+ * Copyright (c) 2002-2015 Mellanox Technologies LTD. All rights reserved.
+ * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
+ * Copyright (c) 2007 Simula Research Laboratory. All rights reserved.
+ * Copyright (c) 2007 Silicon Graphics Inc. All rights reserved.
+ * Copyright (c) 2008,2009 System Fabric Works, Inc. All rights reserved.
+ * Copyright (c) 2009 HNR Consulting. All rights reserved.
+ * Copyright (c) 2009-2011 ZIH, TU Dresden, Federal Republic of Germany. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+/*
+ * Abstract:
+ * Implementation of LASH algorithm Calculation functions
+ */
+
+#if HAVE_CONFIG_H
+# include <config.h>
+#endif /* HAVE_CONFIG_H */
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <errno.h>
+#include <complib/cl_debug.h>
+#include <complib/cl_qmap.h>
+#include <opensm/osm_file_ids.h>
+#define FILE_ID OSM_FILE_UCAST_LASH_C
+#include <opensm/osm_switch.h>
+#include <opensm/osm_opensm.h>
+#include <opensm/osm_log.h>
+#include <opensm/osm_mesh.h>
+#include <opensm/osm_ucast_lash.h>
+
+typedef struct _reachable_dest {
+ int switch_id;
+ struct _reachable_dest *next;
+} reachable_dest_t;
+
+static void connect_switches(lash_t * p_lash, int sw1, int sw2, int phy_port_1)
+{
+ osm_log_t *p_log = &p_lash->p_osm->log;
+ unsigned num = p_lash->switches[sw1]->node->num_links;
+ switch_t *s1 = p_lash->switches[sw1];
+ mesh_node_t *node = s1->node;
+ switch_t *s2;
+ link_t *l;
+ unsigned int i;
+
+ /*
+ * if doing mesh analysis:
+ * - do not consider connections to self
+ * - collapse multiple connections between
+ * pair of switches to a single locical link
+ */
+ if (p_lash->p_osm->subn.opt.do_mesh_analysis) {
+ if (sw1 == sw2)
+ return;
+
+ /* see if we are already linked to sw2 */
+ for (i = 0; i < num; i++) {
+ l = node->links[i];
+
+ if (node->links[i]->switch_id == sw2) {
+ l->ports[l->num_ports++] = phy_port_1;
+ return;
+ }
+ }
+ }
+
+ l = node->links[num];
+ l->switch_id = sw2;
+ l->link_id = -1;
+ l->ports[l->num_ports++] = phy_port_1;
+
+ s2 = p_lash->switches[sw2];
+ for (i = 0; i < s2->node->num_links; i++) {
+ if (s2->node->links[i]->switch_id == sw1) {
+ s2->node->links[i]->link_id = num;
+ l->link_id = i;
+ break;
+ }
+ }
+
+ node->num_links++;
+
+ OSM_LOG(p_log, OSM_LOG_VERBOSE,
+ "LASH connect: %d, %d, %d\n", sw1, sw2, phy_port_1);
+}
+
+static osm_switch_t *get_osm_switch_from_port(const osm_port_t * port)
+{
+ osm_physp_t *p = port->p_physp;
+ if (p->p_node->sw)
+ return p->p_node->sw;
+ else if (p->p_remote_physp && p->p_remote_physp->p_node->sw)
+ return p->p_remote_physp->p_node->sw;
+ return NULL;
+}
+
+static int cycle_exists(cdg_vertex_t * start, cdg_vertex_t * current,
+ cdg_vertex_t * prev, int visit_num)
+{
+ int i, new_visit_num;
+ int cycle_found = 0;
+
+ if (current != NULL && current->visiting_number > 0) {
+ if (visit_num > current->visiting_number && current->seen == 0) {
+ cycle_found = 1;
+ }
+ } else {
+ if (current == NULL) {
+ current = start;
+ CL_ASSERT(prev == NULL);
+ }
+
+ current->visiting_number = visit_num;
+
+ if (prev != NULL) {
+ prev->next = current;
+ CL_ASSERT(prev->to == current->from);
+ CL_ASSERT(prev->visiting_number > 0);
+ }
+
+ new_visit_num = visit_num + 1;
+
+ for (i = 0; i < current->num_deps; i++) {
+ cycle_found =
+ cycle_exists(start, current->deps[i].v, current,
+ new_visit_num);
+ if (cycle_found == 1)
+ i = current->num_deps;
+ }
+
+ current->seen = 1;
+ if (prev != NULL)
+ prev->next = NULL;
+ }
+
+ return cycle_found;
+}
+
+static inline int get_next_switch(lash_t *p_lash, int sw, int link)
+{
+ return p_lash->switches[sw]->node->links[link]->switch_id;
+}
+
+static void remove_semipermanent_depend_for_sp(lash_t * p_lash, int sw,
+ int dest_switch, int lane)
+{
+ switch_t **switches = p_lash->switches;
+ cdg_vertex_t ****cdg_vertex_matrix = p_lash->cdg_vertex_matrix;
+ int i_next_switch, output_link, i, next_link, i_next_next_switch,
+ depend = 0;
+ cdg_vertex_t *v;
+ int __attribute__((unused)) found;
+
+ output_link = switches[sw]->routing_table[dest_switch].out_link;
+ i_next_switch = get_next_switch(p_lash, sw, output_link);
+
+ while (sw != dest_switch) {
+ v = cdg_vertex_matrix[lane][sw][i_next_switch];
+ CL_ASSERT(v != NULL);
+
+ if (v->num_using_vertex == 1) {
+
+ cdg_vertex_matrix[lane][sw][i_next_switch] = NULL;
+
+ free(v);
+ } else {
+ v->num_using_vertex--;
+ if (i_next_switch != dest_switch) {
+ next_link =
+ switches[i_next_switch]->routing_table[dest_switch].out_link;
+ i_next_next_switch = get_next_switch(p_lash, i_next_switch, next_link);
+ found = 0;
+
+ for (i = 0; i < v->num_deps; i++)
+ if (v->deps[i].v ==
+ cdg_vertex_matrix[lane][i_next_switch]
+ [i_next_next_switch]) {
+ found = 1;
+ depend = i;
+ }
+
+ CL_ASSERT(found);
+
+ if (v->deps[depend].num_used == 1) {
+ for (i = depend;
+ i < v->num_deps - 1; i++) {
+ v->deps[i].v = v->deps[i + 1].v;
+ v->deps[i].num_used =
+ v->deps[i + 1].num_used;
+ }
+
+ v->num_deps--;
+ } else
+ v->deps[depend].num_used--;
+ }
+ }
+
+ sw = i_next_switch;
+ output_link = switches[sw]->routing_table[dest_switch].out_link;
+
+ if (sw != dest_switch)
+ i_next_switch = get_next_switch(p_lash, sw, output_link);
+ }
+}
+
+inline static void enqueue(cl_list_t * bfsq, switch_t * sw)
+{
+ CL_ASSERT(sw->q_state == UNQUEUED);
+ sw->q_state = Q_MEMBER;
+ cl_list_insert_tail(bfsq, sw);
+}
+
+inline static void dequeue(cl_list_t * bfsq, switch_t ** sw)
+{
+ *sw = (switch_t *) cl_list_remove_head(bfsq);
+ CL_ASSERT((*sw)->q_state == Q_MEMBER);
+ (*sw)->q_state = MST_MEMBER;
+}
+
+static int get_phys_connection(switch_t *sw, int switch_to)
+{
+ unsigned int i;
+
+ for (i = 0; i < sw->node->num_links; i++)
+ if (sw->node->links[i]->switch_id == switch_to)
+ return i;
+ return i;
+}
+
+static void shortest_path(lash_t * p_lash, int ir)
+{
+ switch_t **switches = p_lash->switches, *sw, *swi;
+ unsigned int i;
+ cl_list_t bfsq;
+
+ cl_list_construct(&bfsq);
+ cl_list_init(&bfsq, 20);
+
+ enqueue(&bfsq, switches[ir]);
+
+ while (!cl_is_list_empty(&bfsq)) {
+ dequeue(&bfsq, &sw);
+ for (i = 0; i < sw->node->num_links; i++) {
+ swi = switches[sw->node->links[i]->switch_id];
+ if (swi->q_state == UNQUEUED) {
+ enqueue(&bfsq, swi);
+ sw->dij_channels[sw->used_channels++] = swi->id;
+ }
+ }
+ }
+
+ cl_list_destroy(&bfsq);
+}
+
+static int generate_routing_func_for_mst(lash_t * p_lash, int sw_id,
+ reachable_dest_t ** destinations)
+{
+ int i, next_switch;
+ switch_t *sw = p_lash->switches[sw_id];
+ int num_channels = sw->used_channels;
+ reachable_dest_t *dest, *i_dest, *concat_dest = NULL, *prev;
+
+ for (i = 0; i < num_channels; i++) {
+ next_switch = sw->dij_channels[i];
+ if (generate_routing_func_for_mst(p_lash, next_switch, &dest))
+ return -1;
+
+ i_dest = dest;
+ prev = i_dest;
+
+ while (i_dest != NULL) {
+ if (sw->routing_table[i_dest->switch_id].out_link ==
+ NONE)
+ sw->routing_table[i_dest->switch_id].out_link =
+ get_phys_connection(sw, next_switch);
+
+ prev = i_dest;
+ i_dest = i_dest->next;
+ }
+
+ CL_ASSERT(prev->next == NULL);
+ prev->next = concat_dest;
+ concat_dest = dest;
+ }
+
+ i_dest = (reachable_dest_t *) malloc(sizeof(reachable_dest_t));
+ if (!i_dest)
+ return -1;
+ i_dest->switch_id = sw->id;
+ i_dest->next = concat_dest;
+ *destinations = i_dest;
+ return 0;
+}
+
+static int generate_cdg_for_sp(lash_t * p_lash, int sw, int dest_switch,
+ int lane)
+{
+ unsigned num_switches = p_lash->num_switches;
+ switch_t **switches = p_lash->switches;
+ cdg_vertex_t ****cdg_vertex_matrix = p_lash->cdg_vertex_matrix;
+ int next_switch, output_link, j, exists;
+ cdg_vertex_t *v, *prev = NULL;
+
+ output_link = switches[sw]->routing_table[dest_switch].out_link;
+ next_switch = get_next_switch(p_lash, sw, output_link);
+
+ while (sw != dest_switch) {
+
+ if (cdg_vertex_matrix[lane][sw][next_switch] == NULL) {
+ v = calloc(1, sizeof(*v) + (num_switches - 1) * sizeof(v->deps[0]));
+ if (!v)
+ return -1;
+ v->from = sw;
+ v->to = next_switch;
+ v->temp = 1;
+ cdg_vertex_matrix[lane][sw][next_switch] = v;
+ } else
+ v = cdg_vertex_matrix[lane][sw][next_switch];
+
+ v->num_using_vertex++;
+
+ if (prev != NULL) {
+ exists = 0;
+
+ for (j = 0; j < prev->num_deps; j++)
+ if (prev->deps[j].v == v) {
+ exists = 1;
+ prev->deps[j].num_used++;
+ }
+
+ if (exists == 0) {
+ prev->deps[prev->num_deps].v = v;
+ prev->deps[prev->num_deps].num_used++;
+ prev->num_deps++;
+
+ CL_ASSERT(prev->num_deps < (int)num_switches);
+
+ if (prev->temp == 0)
+ prev->num_temp_depend++;
+
+ }
+ }
+
+ sw = next_switch;
+ output_link = switches[sw]->routing_table[dest_switch].out_link;
+
+ if (sw != dest_switch) {
+ CL_ASSERT(output_link != NONE);
+ next_switch = get_next_switch(p_lash, sw, output_link);
+ }
+
+ prev = v;
+ }
+ return 0;
+}
+
+static void set_temp_depend_to_permanent_for_sp(lash_t * p_lash, int sw,
+ int dest_switch, int lane)
+{
+ switch_t **switches = p_lash->switches;
+ cdg_vertex_t ****cdg_vertex_matrix = p_lash->cdg_vertex_matrix;
+ int next_switch, output_link;
+ cdg_vertex_t *v;
+
+ output_link = switches[sw]->routing_table[dest_switch].out_link;
+ next_switch = get_next_switch(p_lash, sw, output_link);
+
+ while (sw != dest_switch) {
+ v = cdg_vertex_matrix[lane][sw][next_switch];
+ CL_ASSERT(v != NULL);
+
+ if (v->temp == 1)
+ v->temp = 0;
+ else
+ v->num_temp_depend = 0;
+
+ sw = next_switch;
+ output_link = switches[sw]->routing_table[dest_switch].out_link;
+
+ if (sw != dest_switch)
+ next_switch = get_next_switch(p_lash, sw, output_link);
+ }
+
+}
+
+static void remove_temp_depend_for_sp(lash_t * p_lash, int sw, int dest_switch,
+ int lane)
+{
+ switch_t **switches = p_lash->switches;
+ cdg_vertex_t ****cdg_vertex_matrix = p_lash->cdg_vertex_matrix;
+ int next_switch, output_link, i;
+ cdg_vertex_t *v;
+
+ output_link = switches[sw]->routing_table[dest_switch].out_link;
+ next_switch = get_next_switch(p_lash, sw, output_link);
+
+ while (sw != dest_switch) {
+ v = cdg_vertex_matrix[lane][sw][next_switch];
+ CL_ASSERT(v != NULL);
+
+ if (v->temp == 1) {
+ cdg_vertex_matrix[lane][sw][next_switch] = NULL;
+ free(v);
+ } else {
+ CL_ASSERT(v->num_temp_depend <= v->num_deps);
+ v->num_deps = v->num_deps - v->num_temp_depend;
+ v->num_temp_depend = 0;
+ v->num_using_vertex--;
+
+ for (i = v->num_deps; i < p_lash->num_switches - 1; i++)
+ v->deps[i].num_used = 0;
+ }
+
+ sw = next_switch;
+ output_link = switches[sw]->routing_table[dest_switch].out_link;
+
+ if (sw != dest_switch)
+ next_switch = get_next_switch(p_lash, sw, output_link);
+
+ }
+}
+
+static int balance_virtual_lanes(lash_t * p_lash, unsigned lanes_needed)
+{
+ unsigned num_switches = p_lash->num_switches;
+ cdg_vertex_t ****cdg_vertex_matrix = p_lash->cdg_vertex_matrix;
+ int *num_mst_in_lane = p_lash->num_mst_in_lane;
+ int ***virtual_location = p_lash->virtual_location;
+ int min_filled_lane, max_filled_lane, trials;
+ int old_min_filled_lane, old_max_filled_lane, new_num_min_lane,
+ new_num_max_lane;
+ unsigned int i, j;
+ int src, dest, start, next_switch, output_link;
+ int next_switch2, output_link2;
+ int stop = 0, cycle_found;
+ int cycle_found2;
+ unsigned start_vl = p_lash->p_osm->subn.opt.lash_start_vl;
+
+ max_filled_lane = 0;
+ min_filled_lane = lanes_needed - 1;
+
+ trials = num_mst_in_lane[max_filled_lane];
+ if (lanes_needed == 1)
+ stop = 1;
+
+ while (stop == 0) {
+ src = abs(rand()) % (num_switches);
+ dest = abs(rand()) % (num_switches);
+
+ while (virtual_location[src][dest][max_filled_lane] != 1) {
+ start = dest;
+ if (dest == num_switches - 1)
+ dest = 0;
+ else
+ dest++;
+
+ while (dest != start
+ && virtual_location[src][dest][max_filled_lane]
+ != 1) {
+ if (dest == num_switches - 1)
+ dest = 0;
+ else
+ dest++;
+ }
+
+ if (virtual_location[src][dest][max_filled_lane] != 1) {
+ if (src == num_switches - 1)
+ src = 0;
+ else
+ src++;
+ }
+ }
+
+ if (generate_cdg_for_sp(p_lash, src, dest, min_filled_lane) ||
+ generate_cdg_for_sp(p_lash, dest, src, min_filled_lane))
+ return -1;
+
+ output_link = p_lash->switches[src]->routing_table[dest].out_link;
+ next_switch = get_next_switch(p_lash, src, output_link);
+
+ output_link2 = p_lash->switches[dest]->routing_table[src].out_link;
+ next_switch2 = get_next_switch(p_lash, dest, output_link2);
+
+ CL_ASSERT(cdg_vertex_matrix[min_filled_lane][src][next_switch] != NULL);
+ CL_ASSERT(cdg_vertex_matrix[min_filled_lane][dest][next_switch2] != NULL);
+
+ cycle_found =
+ cycle_exists(cdg_vertex_matrix[min_filled_lane][src][next_switch], NULL, NULL,
+ 1);
+ cycle_found2 =
+ cycle_exists(cdg_vertex_matrix[min_filled_lane][dest][next_switch2], NULL, NULL,
+ 1);
+
+ for (i = 0; i < num_switches; i++)
+ for (j = 0; j < num_switches; j++)
+ if (cdg_vertex_matrix[min_filled_lane][i][j] != NULL) {
+ cdg_vertex_matrix[min_filled_lane][i][j]->visiting_number =
+ 0;
+ cdg_vertex_matrix[min_filled_lane][i][j]->seen = 0;
+ }
+
+ if (cycle_found == 1 || cycle_found2 == 1) {
+ remove_temp_depend_for_sp(p_lash, src, dest, min_filled_lane);
+ remove_temp_depend_for_sp(p_lash, dest, src, min_filled_lane);
+
+ virtual_location[src][dest][max_filled_lane] = 2;
+ virtual_location[dest][src][max_filled_lane] = 2;
+ trials--;
+ trials--;
+ } else {
+ set_temp_depend_to_permanent_for_sp(p_lash, src, dest, min_filled_lane);
+ set_temp_depend_to_permanent_for_sp(p_lash, dest, src, min_filled_lane);
+
+ num_mst_in_lane[max_filled_lane]--;
+ num_mst_in_lane[max_filled_lane]--;
+ num_mst_in_lane[min_filled_lane]++;
+ num_mst_in_lane[min_filled_lane]++;
+
+ remove_semipermanent_depend_for_sp(p_lash, src, dest, max_filled_lane);
+ remove_semipermanent_depend_for_sp(p_lash, dest, src, max_filled_lane);
+ virtual_location[src][dest][max_filled_lane] = 0;
+ virtual_location[dest][src][max_filled_lane] = 0;
+ virtual_location[src][dest][min_filled_lane] = 1;
+ virtual_location[dest][src][min_filled_lane] = 1;
+ p_lash->switches[src]->routing_table[dest].lane = min_filled_lane + start_vl;
+ p_lash->switches[dest]->routing_table[src].lane = min_filled_lane + start_vl;
+ }
+
+ if (trials == 0)
+ stop = 1;
+ else {
+ if (num_mst_in_lane[max_filled_lane] - num_mst_in_lane[min_filled_lane] <
+ p_lash->balance_limit)
+ stop = 1;
+ }
+
+ old_min_filled_lane = min_filled_lane;
+ old_max_filled_lane = max_filled_lane;
+
+ new_num_min_lane = MAX_INT;
+ new_num_max_lane = 0;
+
+ for (i = 0; i < lanes_needed; i++) {
+
+ if (num_mst_in_lane[i] < new_num_min_lane) {
+ new_num_min_lane = num_mst_in_lane[i];
+ min_filled_lane = i;
+ }
+
+ if (num_mst_in_lane[i] > new_num_max_lane) {
+ new_num_max_lane = num_mst_in_lane[i];
+ max_filled_lane = i;
+ }
+ }
+
+ if (old_min_filled_lane != min_filled_lane) {
+ trials = num_mst_in_lane[max_filled_lane];
+ for (i = 0; i < num_switches; i++)
+ for (j = 0; j < num_switches; j++)
+ if (virtual_location[i][j][max_filled_lane] == 2)
+ virtual_location[i][j][max_filled_lane] = 1;
+ }
+
+ if (old_max_filled_lane != max_filled_lane) {
+ trials = num_mst_in_lane[max_filled_lane];
+ for (i = 0; i < num_switches; i++)
+ for (j = 0; j < num_switches; j++)
+ if (virtual_location[i][j][old_max_filled_lane] == 2)
+ virtual_location[i][j][old_max_filled_lane] = 1;
+ }
+ }
+ return 0;
+}
+
+static switch_t *switch_create(lash_t * p_lash, unsigned id, osm_switch_t * p_sw)
+{
+ unsigned num_switches = p_lash->num_switches;
+ unsigned num_ports = p_sw->num_ports;
+ switch_t *sw;
+ unsigned int i;
+
+ sw = malloc(sizeof(*sw) + num_switches * sizeof(sw->routing_table[0]));
+ if (!sw)
+ return NULL;
+
+ memset(sw, 0, sizeof(*sw));
+ for (i = 0; i < num_switches; i++) {
+ sw->routing_table[i].out_link = NONE;
+ sw->routing_table[i].lane = NONE;
+ }
+
+ sw->id = id;
+ sw->dij_channels = malloc(num_ports * sizeof(int));
+ if (!sw->dij_channels) {
+ free(sw);
+ return NULL;
+ }
+
+ sw->p_sw = p_sw;
+ p_sw->priv = sw;
+
+ if (osm_mesh_node_create(p_lash, sw)) {
+ free(sw->dij_channels);
+ free(sw);
+ return NULL;
+ }
+
+ return sw;
+}
+
+static void switch_delete(lash_t *p_lash, switch_t * sw)
+{
+ if (sw->dij_channels)
+ free(sw->dij_channels);
+ free(sw);
+}
+
+static void delete_mesh_switches(lash_t *p_lash)
+{
+ if (p_lash->switches) {
+ unsigned id;
+ for (id = 0; ((int)id) < p_lash->num_switches; id++)
+ if (p_lash->switches[id])
+ osm_mesh_node_delete(p_lash,
+ p_lash->switches[id]);
+ }
+}
+
+static void free_lash_structures(lash_t * p_lash)
+{
+ unsigned int i, j, k;
+ unsigned num_switches = p_lash->num_switches;
+ osm_log_t *p_log = &p_lash->p_osm->log;
+
+ OSM_LOG_ENTER(p_log);
+
+ delete_mesh_switches(p_lash);
+
+ /* free cdg_vertex_matrix */
+ for (i = 0; i < p_lash->vl_min; i++) {
+ for (j = 0; j < num_switches; j++) {
+ for (k = 0; k < num_switches; k++)
+ if (p_lash->cdg_vertex_matrix[i][j][k])
+ free(p_lash->cdg_vertex_matrix[i][j][k]);
+ if (p_lash->cdg_vertex_matrix[i][j])
+ free(p_lash->cdg_vertex_matrix[i][j]);
+ }
+ if (p_lash->cdg_vertex_matrix[i])
+ free(p_lash->cdg_vertex_matrix[i]);
+ }
+
+ if (p_lash->cdg_vertex_matrix)
+ free(p_lash->cdg_vertex_matrix);
+
+ /* free virtual_location */
+ for (i = 0; i < num_switches; i++) {
+ for (j = 0; j < num_switches; j++) {
+ if (p_lash->virtual_location[i][j])
+ free(p_lash->virtual_location[i][j]);
+ }
+ if (p_lash->virtual_location[i])
+ free(p_lash->virtual_location[i]);
+ }
+ if (p_lash->virtual_location)
+ free(p_lash->virtual_location);
+
+ OSM_LOG_EXIT(p_log);
+}
+
+static int init_lash_structures(lash_t * p_lash)
+{
+ unsigned vl_min = p_lash->vl_min;
+ unsigned num_switches = p_lash->num_switches;
+ osm_log_t *p_log = &p_lash->p_osm->log;
+ int status = 0;
+ unsigned int i, j, k;
+
+ OSM_LOG_ENTER(p_log);
+
+ /* initialise cdg_vertex_matrix[num_switches][num_switches][num_switches] */
+ p_lash->cdg_vertex_matrix =
+ (cdg_vertex_t ****) malloc(vl_min * sizeof(cdg_vertex_t ***));
+ if (p_lash->cdg_vertex_matrix == NULL)
+ goto Exit_Mem_Error;
+ for (i = 0; i < vl_min; i++) {
+ p_lash->cdg_vertex_matrix[i] =
+ (cdg_vertex_t ***) malloc(num_switches *
+ sizeof(cdg_vertex_t **));
+
+ if (p_lash->cdg_vertex_matrix[i] == NULL)
+ goto Exit_Mem_Error;
+ }
+
+ for (i = 0; i < vl_min; i++) {
+ for (j = 0; j < num_switches; j++) {
+ p_lash->cdg_vertex_matrix[i][j] =
+ (cdg_vertex_t **) malloc(num_switches *
+ sizeof(cdg_vertex_t *));
+ if (p_lash->cdg_vertex_matrix[i][j] == NULL)
+ goto Exit_Mem_Error;
+
+ for (k = 0; k < num_switches; k++)
+ p_lash->cdg_vertex_matrix[i][j][k] = NULL;
+ }
+ }
+
+ /*
+ * initialise virtual_location[num_switches][num_switches][num_layers],
+ * default value = 0
+ */
+ p_lash->virtual_location =
+ (int ***)malloc(num_switches * sizeof(int ***));
+ if (p_lash->virtual_location == NULL)
+ goto Exit_Mem_Error;
+
+ for (i = 0; i < num_switches; i++) {
+ p_lash->virtual_location[i] =
+ (int **)malloc(num_switches * sizeof(int **));
+ if (p_lash->virtual_location[i] == NULL)
+ goto Exit_Mem_Error;
+ }
+
+ for (i = 0; i < num_switches; i++) {
+ for (j = 0; j < num_switches; j++) {
+ p_lash->virtual_location[i][j] =
+ (int *)malloc(vl_min * sizeof(int *));
+ if (p_lash->virtual_location[i][j] == NULL)
+ goto Exit_Mem_Error;
+ for (k = 0; k < vl_min; k++)
+ p_lash->virtual_location[i][j][k] = 0;
+ }
+ }
+
+ /* initialise num_mst_in_lane[num_switches], default 0 */
+ memset(p_lash->num_mst_in_lane, 0,
+ IB_MAX_NUM_VLS * sizeof(p_lash->num_mst_in_lane[0]));
+
+ goto Exit;
+
+Exit_Mem_Error:
+ status = -1;
+ OSM_LOG(p_log, OSM_LOG_ERROR, "ERR 4D01: "
+ "Could not allocate required memory for LASH errno %d, errno %d for lack of memory\n",
+ errno, ENOMEM);
+
+Exit:
+ OSM_LOG_EXIT(p_log);
+ return status;
+}
+
+static int lash_core(lash_t * p_lash)
+{
+ osm_log_t *p_log = &p_lash->p_osm->log;
+ unsigned num_switches = p_lash->num_switches;
+ switch_t **switches = p_lash->switches;
+ unsigned lanes_needed = 1;
+ unsigned int i, j, k, dest_switch = 0;
+ reachable_dest_t *dests, *idest;
+ int cycle_found = 0;
+ unsigned v_lane;
+ int stop = 0, output_link, i_next_switch;
+ int output_link2, i_next_switch2;
+ int cycle_found2 = 0;
+ int status = -1;
+ int *switch_bitmap = NULL; /* Bitmap to check if we have processed this pair */
+ unsigned start_vl = p_lash->p_osm->subn.opt.lash_start_vl;
+
+ OSM_LOG_ENTER(p_log);
+
+ if (p_lash->p_osm->subn.opt.do_mesh_analysis && osm_do_mesh_analysis(p_lash)) {
+ OSM_LOG(p_log, OSM_LOG_ERROR, "ERR 4D05: Mesh analysis failed\n");
+ goto Exit;
+ }
+
+ for (i = 0; i < num_switches; i++) {
+
+ shortest_path(p_lash, i);
+ if (generate_routing_func_for_mst(p_lash, i, &dests)) {
+ OSM_LOG(p_log, OSM_LOG_ERROR, "ERR 4D06: "
+ "generate_routing_func_for_mst failed\n");
+ goto Exit;
+ }
+
+ idest = dests;
+ while (idest != NULL) {
+ dests = dests->next;
+ free(idest);
+ idest = dests;
+ }
+
+ for (j = 0; j < num_switches; j++) {
+ switches[j]->used_channels = 0;
+ switches[j]->q_state = UNQUEUED;
+ }
+ }
+
+ switch_bitmap = calloc(num_switches * num_switches, sizeof(int));
+ if (!switch_bitmap) {
+ OSM_LOG(p_log, OSM_LOG_ERROR, "ERR 4D04: "
+ "Failed allocating switch_bitmap - out of memory\n");
+ goto Exit;
+ }
+
+ for (i = 0; i < num_switches; i++) {
+ for (dest_switch = 0; dest_switch < num_switches; dest_switch++)
+ if (dest_switch != i && switch_bitmap[i * num_switches + dest_switch] == 0) {
+ v_lane = 0;
+ stop = 0;
+ while (v_lane < lanes_needed && stop == 0) {
+ if (generate_cdg_for_sp(p_lash, i, dest_switch, v_lane) ||
+ generate_cdg_for_sp(p_lash, dest_switch, i, v_lane)) {
+ OSM_LOG(p_log, OSM_LOG_ERROR,
+ "ERR 4D07: generate_cdg_for_sp failed\n");
+ goto Exit;
+ }
+
+ output_link =
+ switches[i]->routing_table[dest_switch].out_link;
+ output_link2 =
+ switches[dest_switch]->routing_table[i].out_link;
+
+ i_next_switch = get_next_switch(p_lash, i, output_link);
+ i_next_switch2 = get_next_switch(p_lash, dest_switch, output_link2);
+
+ CL_ASSERT(p_lash->
+ cdg_vertex_matrix[v_lane][i][i_next_switch] !=
+ NULL);
+ CL_ASSERT(p_lash->
+ cdg_vertex_matrix[v_lane][dest_switch]
+ [i_next_switch2] != NULL);
+
+ cycle_found =
+ cycle_exists(p_lash->
+ cdg_vertex_matrix[v_lane][i]
+ [i_next_switch], NULL, NULL, 1);
+ cycle_found2 =
+ cycle_exists(p_lash->
+ cdg_vertex_matrix[v_lane][dest_switch]
+ [i_next_switch2], NULL, NULL, 1);
+
+ for (j = 0; j < num_switches; j++)
+ for (k = 0; k < num_switches; k++)
+ if (p_lash->
+ cdg_vertex_matrix[v_lane][j][k] !=
+ NULL) {
+ p_lash->
+ cdg_vertex_matrix[v_lane][j]
+ [k]->visiting_number = 0;
+ p_lash->
+ cdg_vertex_matrix[v_lane][j]
+ [k]->seen = 0;
+ }
+
+ if (cycle_found == 1 || cycle_found2 == 1) {
+ remove_temp_depend_for_sp(p_lash, i, dest_switch,
+ v_lane);
+ remove_temp_depend_for_sp(p_lash, dest_switch, i,
+ v_lane);
+ v_lane++;
+ } else {
+ set_temp_depend_to_permanent_for_sp(p_lash, i,
+ dest_switch,
+ v_lane);
+ set_temp_depend_to_permanent_for_sp(p_lash,
+ dest_switch, i,
+ v_lane);
+ stop = 1;
+ p_lash->num_mst_in_lane[v_lane]++;
+ p_lash->num_mst_in_lane[v_lane]++;
+ }
+ }
+
+ switches[i]->routing_table[dest_switch].lane = v_lane + start_vl;
+ switches[dest_switch]->routing_table[i].lane = v_lane + start_vl;
+
+ if (cycle_found == 1 || cycle_found2 == 1) {
+ if (++lanes_needed > p_lash->vl_min)
+ goto Error_Not_Enough_Lanes;
+
+ if (generate_cdg_for_sp(p_lash, i, dest_switch, v_lane) ||
+ generate_cdg_for_sp(p_lash, dest_switch, i, v_lane)) {
+ OSM_LOG(p_log, OSM_LOG_ERROR,
+ "ERR 4D08: generate_cdg_for_sp failed\n");
+ goto Exit;
+ }
+
+ set_temp_depend_to_permanent_for_sp(p_lash, i, dest_switch,
+ v_lane);
+ set_temp_depend_to_permanent_for_sp(p_lash, dest_switch, i,
+ v_lane);
+
+ p_lash->num_mst_in_lane[v_lane]++;
+ p_lash->num_mst_in_lane[v_lane]++;
+ }
+ p_lash->virtual_location[i][dest_switch][v_lane] = 1;
+ p_lash->virtual_location[dest_switch][i][v_lane] = 1;
+
+ switch_bitmap[i * num_switches + dest_switch] = 1;
+ switch_bitmap[dest_switch * num_switches + i] = 1;
+ }
+ }
+
+ for (i = 0; i < lanes_needed; i++)
+ OSM_LOG(p_log, OSM_LOG_INFO, "Lanes in layer %d: %d\n",
+ i, p_lash->num_mst_in_lane[i]);
+
+ OSM_LOG(p_log, OSM_LOG_INFO,
+ "Lanes needed: %d, Balancing\n", lanes_needed);
+
+ if (balance_virtual_lanes(p_lash, lanes_needed)) {
+ OSM_LOG(p_log, OSM_LOG_ERROR, "ERR 4D09: Balancing failed\n");
+ goto Exit;
+ }
+
+ for (i = 0; i < lanes_needed; i++)
+ OSM_LOG(p_log, OSM_LOG_INFO, "Lanes in layer %d: %d\n",
+ i, p_lash->num_mst_in_lane[i]);
+
+ status = 0;
+ goto Exit;
+
+Error_Not_Enough_Lanes:
+ OSM_LOG(p_log, OSM_LOG_ERROR, "ERR 4D02: "
+ "Lane requirements (%d) exceed available lanes (%d)"
+ " with starting lane (%d)\n",
+ lanes_needed, p_lash->vl_min, start_vl);
+Exit:
+ if (switch_bitmap)
+ free(switch_bitmap);
+ OSM_LOG_EXIT(p_log);
+ return status;
+}
+
+static unsigned get_lash_id(osm_switch_t * p_sw)
+{
+ return ((switch_t *) p_sw->priv)->id;
+}
+
+static int get_next_port(switch_t *sw, int link)
+{
+ link_t *l = sw->node->links[link];
+ int port = l->next_port++;
+
+ /*
+ * note if not doing mesh analysis
+ * then num_ports is always 1
+ */
+ if (l->next_port >= l->num_ports)
+ l->next_port = 0;
+
+ return l->ports[port];
+}
+
+static void populate_fwd_tbls(lash_t * p_lash)
+{
+ osm_log_t *p_log = &p_lash->p_osm->log;
+ osm_subn_t *p_subn = &p_lash->p_osm->subn;
+ osm_switch_t *p_sw, *p_next_sw, *p_dst_sw;
+ osm_port_t *port;
+ uint16_t max_lid_ho, lid;
+
+ OSM_LOG_ENTER(p_log);
+
+ p_next_sw = (osm_switch_t *) cl_qmap_head(&p_subn->sw_guid_tbl);
+
+ /* Go through each switch individually */
+ while (p_next_sw != (osm_switch_t *) cl_qmap_end(&p_subn->sw_guid_tbl)) {
+ uint64_t current_guid;
+ switch_t *sw;
+ p_sw = p_next_sw;
+ p_next_sw = (osm_switch_t *) cl_qmap_next(&p_sw->map_item);
+
+ max_lid_ho = p_sw->max_lid_ho;
+ current_guid = p_sw->p_node->node_info.port_guid;
+ sw = p_sw->priv;
+
+ memset(p_sw->new_lft, OSM_NO_PATH, p_sw->lft_size);
+
+ for (lid = 1; lid <= max_lid_ho; lid++) {
+ port = osm_get_port_by_lid_ho(p_subn, lid);
+ if (!port)
+ continue;
+
+ p_dst_sw = get_osm_switch_from_port(port);
+ if (p_dst_sw == p_sw) {
+ uint8_t egress_port = port->p_node->sw ? 0 :
+ port->p_physp->p_remote_physp->port_num;
+ p_sw->new_lft[lid] = egress_port;
+ OSM_LOG(p_log, OSM_LOG_VERBOSE,
+ "LASH fwd MY SRC SRC GUID 0x%016" PRIx64
+ " src lash id (%d), src lid no (%u) src lash port (%d) "
+ "DST GUID 0x%016" PRIx64
+ " src lash id (%d), src lash port (%d)\n",
+ cl_ntoh64(current_guid), -1, lid,
+ egress_port, cl_ntoh64(current_guid),
+ -1, egress_port);
+ } else if (p_dst_sw) {
+ unsigned dst_lash_switch_id =
+ get_lash_id(p_dst_sw);
+ uint8_t lash_egress_port =
+ (uint8_t) sw->
+ routing_table[dst_lash_switch_id].out_link;
+ uint8_t physical_egress_port =
+ get_next_port(sw, lash_egress_port);
+
+ p_sw->new_lft[lid] = physical_egress_port;
+ OSM_LOG(p_log, OSM_LOG_VERBOSE,
+ "LASH fwd SRC GUID 0x%016" PRIx64
+ " src lash id (%d), "
+ "src lid no (%u) src lash port (%d) "
+ "DST GUID 0x%016" PRIx64
+ " src lash id (%d), src lash port (%d)\n",
+ cl_ntoh64(current_guid), sw->id, lid,
+ lash_egress_port,
+ cl_ntoh64(p_dst_sw->p_node->node_info.
+ port_guid),
+ dst_lash_switch_id,
+ physical_egress_port);
+ }
+ } /* for */
+ }
+ OSM_LOG_EXIT(p_log);
+}
+
+static void osm_lash_process_switch(lash_t * p_lash, osm_switch_t * p_sw)
+{
+ osm_log_t *p_log = &p_lash->p_osm->log;
+ int i, port_count;
+ osm_physp_t *p_current_physp, *p_remote_physp;
+ unsigned switch_a_lash_id, switch_b_lash_id;
+
+ OSM_LOG_ENTER(p_log);
+
+ switch_a_lash_id = get_lash_id(p_sw);
+ port_count = osm_node_get_num_physp(p_sw->p_node);
+
+ /* starting at port 1, ignoring management port on switch */
+ for (i = 1; i < port_count; i++) {
+
+ p_current_physp = osm_node_get_physp_ptr(p_sw->p_node, i);
+ if (p_current_physp) {
+ p_remote_physp = p_current_physp->p_remote_physp;
+ if (p_remote_physp && p_remote_physp->p_node->sw) {
+ int physical_port_a_num =
+ osm_physp_get_port_num(p_current_physp);
+ int physical_port_b_num =
+ osm_physp_get_port_num(p_remote_physp);
+ switch_b_lash_id =
+ get_lash_id(p_remote_physp->p_node->sw);
+
+ connect_switches(p_lash, switch_a_lash_id,
+ switch_b_lash_id,
+ physical_port_a_num);
+ OSM_LOG(p_log, OSM_LOG_VERBOSE,
+ "LASH SUCCESS connected G 0x%016" PRIx64
+ " , lash_id(%u), P(%u) " " to G 0x%016"
+ PRIx64 " , lash_id(%u) , P(%u)\n",
+ cl_ntoh64(osm_physp_get_port_guid
+ (p_current_physp)),
+ switch_a_lash_id, physical_port_a_num,
+ cl_ntoh64(osm_physp_get_port_guid
+ (p_remote_physp)),
+ switch_b_lash_id, physical_port_b_num);
+ }
+ }
+ }
+
+ OSM_LOG_EXIT(p_log);
+}
+
+static void lash_cleanup(lash_t * p_lash)
+{
+ osm_subn_t *p_subn = &p_lash->p_osm->subn;
+ osm_switch_t *p_next_sw, *p_sw;
+
+ /* drop any existing references to old lash switches */
+ p_next_sw = (osm_switch_t *) cl_qmap_head(&p_subn->sw_guid_tbl);
+ while (p_next_sw != (osm_switch_t *) cl_qmap_end(&p_subn->sw_guid_tbl)) {
+ p_sw = p_next_sw;
+ p_next_sw = (osm_switch_t *) cl_qmap_next(&p_sw->map_item);
+ p_sw->priv = NULL;
+ }
+
+ if (p_lash->switches) {
+ unsigned id;
+ for (id = 0; ((int)id) < p_lash->num_switches; id++)
+ if (p_lash->switches[id])
+ switch_delete(p_lash, p_lash->switches[id]);
+ free(p_lash->switches);
+ }
+ p_lash->switches = NULL;
+}
+
+/*
+ static int discover_network_properties()
+ Traverse the topology of the network in order to determine
+ - the maximum number of switches,
+ - the minimum number of virtual layers
+*/
+
+static int discover_network_properties(lash_t * p_lash)
+{
+ int i, id = 0;
+ uint8_t vl_min;
+ osm_subn_t *p_subn = &p_lash->p_osm->subn;
+ osm_switch_t *p_next_sw, *p_sw;
+ osm_log_t *p_log = &p_lash->p_osm->log;
+
+ p_lash->num_switches = cl_qmap_count(&p_subn->sw_guid_tbl);
+
+ p_lash->switches = calloc(p_lash->num_switches, sizeof(switch_t *));
+ if (!p_lash->switches)
+ return -1;
+
+ vl_min = 5; /* set to a high value */
+
+ p_next_sw = (osm_switch_t *) cl_qmap_head(&p_subn->sw_guid_tbl);
+ while (p_next_sw != (osm_switch_t *) cl_qmap_end(&p_subn->sw_guid_tbl)) {
+ uint16_t port_count;
+ p_sw = p_next_sw;
+ p_next_sw = (osm_switch_t *) cl_qmap_next(&p_sw->map_item);
+
+ p_lash->switches[id] = switch_create(p_lash, id, p_sw);
+ if (!p_lash->switches[id])
+ return -1;
+ id++;
+
+ port_count = osm_node_get_num_physp(p_sw->p_node);
+
+ /* Note, ignoring port 0. management port */
+ for (i = 1; i < port_count; i++) {
+ osm_physp_t *p_current_physp =
+ osm_node_get_physp_ptr(p_sw->p_node, i);
+
+ if (p_current_physp
+ && p_current_physp->p_remote_physp) {
+
+ ib_port_info_t *p_port_info =
+ &p_current_physp->port_info;
+ uint8_t port_vl_min =
+ ib_port_info_get_op_vls(p_port_info);
+ if (port_vl_min && port_vl_min < vl_min)
+ vl_min = port_vl_min;
+ }
+ } /* for */
+ } /* while */
+
+ vl_min = 1 << (vl_min - 1);
+ if (vl_min > 15)
+ vl_min = 15;
+
+ if (p_lash->p_osm->subn.opt.lash_start_vl >= vl_min) {
+ OSM_LOG(p_log, OSM_LOG_ERROR, "ERR 4D03: "
+ "Start VL(%d) too high for min operational vl(%d)\n",
+ p_lash->p_osm->subn.opt.lash_start_vl, vl_min);
+ return -1;
+ }
+
+ p_lash->vl_min = vl_min - p_lash->p_osm->subn.opt.lash_start_vl;
+
+ OSM_LOG(p_log, OSM_LOG_INFO,
+ "min operational vl(%d) start vl(%d) max_switches(%d)\n",
+ p_lash->vl_min, p_lash->p_osm->subn.opt.lash_start_vl,
+ p_lash->num_switches);
+ return 0;
+}
+
+static void process_switches(lash_t * p_lash)
+{
+ osm_switch_t *p_sw, *p_next_sw;
+ osm_subn_t *p_subn = &p_lash->p_osm->subn;
+
+ /* Go through each switch and process it. i.e build the connection
+ structure required by LASH */
+ p_next_sw = (osm_switch_t *) cl_qmap_head(&p_subn->sw_guid_tbl);
+ while (p_next_sw != (osm_switch_t *) cl_qmap_end(&p_subn->sw_guid_tbl)) {
+ p_sw = p_next_sw;
+ p_next_sw = (osm_switch_t *) cl_qmap_next(&p_sw->map_item);
+
+ osm_lash_process_switch(p_lash, p_sw);
+ }
+}
+
+static int lash_process(void *context)
+{
+ lash_t *p_lash = context;
+ osm_log_t *p_log = &p_lash->p_osm->log;
+ int status = 0;
+
+ OSM_LOG_ENTER(p_log);
+
+ p_lash->balance_limit = 6;
+
+ /* everything starts here */
+ lash_cleanup(p_lash);
+
+ status = discover_network_properties(p_lash);
+ if (status)
+ goto Exit;
+
+ status = init_lash_structures(p_lash);
+ if (status)
+ goto Exit;
+
+ process_switches(p_lash);
+
+ status = lash_core(p_lash);
+ if (status)
+ goto Exit;
+
+ populate_fwd_tbls(p_lash);
+
+Exit:
+ if (p_lash->vl_min)
+ free_lash_structures(p_lash);
+ OSM_LOG_EXIT(p_log);
+
+ return status;
+}
+
+static lash_t *lash_create(osm_opensm_t * p_osm)
+{
+ lash_t *p_lash;
+
+ p_lash = calloc(1, sizeof(lash_t));
+ if (!p_lash)
+ return NULL;
+
+ p_lash->p_osm = p_osm;
+
+ return p_lash;
+}
+
+static void lash_delete(void *context)
+{
+ lash_t *p_lash = context;
+
+ if (p_lash->switches) {
+ unsigned id;
+ for (id = 0; ((int)id) < p_lash->num_switches; id++)
+ if (p_lash->switches[id])
+ switch_delete(p_lash, p_lash->switches[id]);
+ free(p_lash->switches);
+ }
+
+ free(p_lash);
+}
+
+static uint8_t get_lash_sl(void *context, uint8_t path_sl_hint,
+ const ib_net16_t slid, const ib_net16_t dlid)
+{
+ unsigned dst_id;
+ unsigned src_id;
+ osm_port_t *p_src_port, *p_dst_port;
+ osm_switch_t *p_sw;
+ lash_t *p_lash = context;
+ osm_opensm_t *p_osm = p_lash->p_osm;
+
+ if (!(p_osm->routing_engine_used &&
+ p_osm->routing_engine_used->type == OSM_ROUTING_ENGINE_TYPE_LASH))
+ return OSM_DEFAULT_SL;
+
+ p_src_port = osm_get_port_by_lid(&p_osm->subn, slid);
+ if (!p_src_port)
+ return OSM_DEFAULT_SL;
+
+ p_dst_port = osm_get_port_by_lid(&p_osm->subn, dlid);
+ if (!p_dst_port)
+ return OSM_DEFAULT_SL;
+
+ p_sw = get_osm_switch_from_port(p_dst_port);
+ if (!p_sw || !p_sw->priv)
+ return OSM_DEFAULT_SL;
+ dst_id = get_lash_id(p_sw);
+
+ p_sw = get_osm_switch_from_port(p_src_port);
+ if (!p_sw || !p_sw->priv)
+ return OSM_DEFAULT_SL;
+
+ src_id = get_lash_id(p_sw);
+ if (src_id == dst_id)
+ return p_osm->subn.opt.lash_start_vl;
+
+ return (uint8_t) ((switch_t *) p_sw->priv)->routing_table[dst_id].lane;
+}
+
+int osm_ucast_lash_setup(struct osm_routing_engine *r, osm_opensm_t *p_osm)
+{
+ lash_t *p_lash = lash_create(p_osm);
+ if (!p_lash)
+ return -1;
+
+ r->context = p_lash;
+ r->ucast_build_fwd_tables = lash_process;
+ r->path_sl = get_lash_sl;
+ r->destroy = lash_delete;
+
+ return 0;
+}
diff --git a/contrib/ofed/opensm/opensm/osm_ucast_mgr.c b/contrib/ofed/opensm/opensm/osm_ucast_mgr.c
new file mode 100644
index 0000000..672f694
--- /dev/null
+++ b/contrib/ofed/opensm/opensm/osm_ucast_mgr.c
@@ -0,0 +1,1196 @@
+/*
+ * Copyright (c) 2004-2009 Voltaire, Inc. All rights reserved.
+ * Copyright (c) 2002-2015 Mellanox Technologies LTD. All rights reserved.
+ * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+/*
+ * Abstract:
+ * Implementation of osm_ucast_mgr_t.
+ * This file implements the Unicast Manager object.
+ */
+
+#if HAVE_CONFIG_H
+# include <config.h>
+#endif /* HAVE_CONFIG_H */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <ctype.h>
+#include <iba/ib_types.h>
+#include <complib/cl_qmap.h>
+#include <complib/cl_debug.h>
+#include <complib/cl_qlist.h>
+#include <opensm/osm_file_ids.h>
+#define FILE_ID OSM_FILE_UCAST_MGR_C
+#include <opensm/osm_ucast_mgr.h>
+#include <opensm/osm_sm.h>
+#include <opensm/osm_log.h>
+#include <opensm/osm_node.h>
+#include <opensm/osm_switch.h>
+#include <opensm/osm_helper.h>
+#include <opensm/osm_msgdef.h>
+#include <opensm/osm_opensm.h>
+
+void osm_ucast_mgr_construct(IN osm_ucast_mgr_t * p_mgr)
+{
+ memset(p_mgr, 0, sizeof(*p_mgr));
+}
+
+void osm_ucast_mgr_destroy(IN osm_ucast_mgr_t * p_mgr)
+{
+ CL_ASSERT(p_mgr);
+
+ OSM_LOG_ENTER(p_mgr->p_log);
+
+ if (p_mgr->cache_valid)
+ osm_ucast_cache_invalidate(p_mgr);
+
+ OSM_LOG_EXIT(p_mgr->p_log);
+}
+
+ib_api_status_t osm_ucast_mgr_init(IN osm_ucast_mgr_t * p_mgr, IN osm_sm_t * sm)
+{
+ ib_api_status_t status = IB_SUCCESS;
+
+ OSM_LOG_ENTER(sm->p_log);
+
+ osm_ucast_mgr_construct(p_mgr);
+
+ p_mgr->sm = sm;
+ p_mgr->p_log = sm->p_log;
+ p_mgr->p_subn = sm->p_subn;
+ p_mgr->p_lock = sm->p_lock;
+
+ if (sm->p_subn->opt.use_ucast_cache)
+ cl_qmap_init(&p_mgr->cache_sw_tbl);
+
+ OSM_LOG_EXIT(p_mgr->p_log);
+ return status;
+}
+
+/**********************************************************************
+ Add each switch's own and neighbor LIDs to its LID matrix
+**********************************************************************/
+static void ucast_mgr_process_hop_0_1(IN cl_map_item_t * p_map_item,
+ IN void *context)
+{
+ osm_switch_t * p_sw = (osm_switch_t *) p_map_item;
+ osm_node_t *p_remote_node;
+ uint16_t lid, remote_lid;
+ uint8_t i;
+
+ lid = cl_ntoh16(osm_node_get_base_lid(p_sw->p_node, 0));
+ osm_switch_set_hops(p_sw, lid, 0, 0);
+
+ for (i = 1; i < p_sw->num_ports; i++) {
+ osm_physp_t *p = osm_node_get_physp_ptr(p_sw->p_node, i);
+ p_remote_node = (p && p->p_remote_physp) ?
+ p->p_remote_physp->p_node : NULL;
+
+ if (p_remote_node && p_remote_node->sw &&
+ p_remote_node != p_sw->p_node) {
+ remote_lid = osm_node_get_base_lid(p_remote_node, 0);
+ remote_lid = cl_ntoh16(remote_lid);
+ osm_switch_set_hops(p_sw, remote_lid, i, p->hop_wf);
+ }
+ }
+}
+
+static void ucast_mgr_process_neighbor(IN osm_ucast_mgr_t * p_mgr,
+ IN osm_switch_t * p_this_sw,
+ IN osm_switch_t * p_remote_sw,
+ IN uint8_t port_num,
+ IN uint8_t remote_port_num)
+{
+ osm_switch_t *p_sw;
+ cl_map_item_t *item;
+ uint16_t lid_ho;
+ uint16_t hops;
+ osm_physp_t *p;
+
+ OSM_LOG_ENTER(p_mgr->p_log);
+
+ OSM_LOG(p_mgr->p_log, OSM_LOG_DEBUG,
+ "Node 0x%" PRIx64 ", remote node 0x%" PRIx64
+ ", port %u, remote port %u\n",
+ cl_ntoh64(osm_node_get_node_guid(p_this_sw->p_node)),
+ cl_ntoh64(osm_node_get_node_guid(p_remote_sw->p_node)),
+ port_num, remote_port_num);
+
+ p = osm_node_get_physp_ptr(p_this_sw->p_node, port_num);
+
+ for (item = cl_qmap_head(&p_mgr->p_subn->sw_guid_tbl);
+ item != cl_qmap_end(&p_mgr->p_subn->sw_guid_tbl);
+ item = cl_qmap_next(item)) {
+ p_sw = (osm_switch_t *) item;
+ lid_ho = cl_ntoh16(osm_node_get_base_lid(p_sw->p_node, 0));
+ hops = osm_switch_get_least_hops(p_remote_sw, lid_ho);
+ if (hops == OSM_NO_PATH)
+ continue;
+ hops += p->hop_wf;
+ if (hops <
+ osm_switch_get_hop_count(p_this_sw, lid_ho, port_num)) {
+ if (osm_switch_set_hops
+ (p_this_sw, lid_ho, port_num, (uint8_t) hops) != 0)
+ OSM_LOG(p_mgr->p_log, OSM_LOG_ERROR, "ERR 3A03: "
+ "cannot set hops for lid %u at switch 0x%"
+ PRIx64 "\n", lid_ho,
+ cl_ntoh64(osm_node_get_node_guid
+ (p_this_sw->p_node)));
+ p_mgr->some_hop_count_set = TRUE;
+ }
+ }
+
+ OSM_LOG_EXIT(p_mgr->p_log);
+}
+
+static struct osm_remote_node *find_and_add_remote_sys(osm_switch_t * sw,
+ uint8_t port,
+ boolean_t dor, struct
+ osm_remote_guids_count
+ *r)
+{
+ unsigned i;
+ osm_physp_t *p = osm_node_get_physp_ptr(sw->p_node, port);
+ osm_node_t *node = p->p_remote_physp->p_node;
+ uint8_t rem_port = osm_physp_get_port_num(p->p_remote_physp);
+
+ for (i = 0; i < r->count; i++)
+ if (r->guids[i].node == node)
+ if (!dor || (r->guids[i].port == rem_port))
+ return &r->guids[i];
+
+ r->guids[i].node = node;
+ r->guids[i].forwarded_to = 0;
+ r->guids[i].port = rem_port;
+ r->count++;
+ return &r->guids[i];
+}
+
+static void ucast_mgr_process_port(IN osm_ucast_mgr_t * p_mgr,
+ IN osm_switch_t * p_sw,
+ IN osm_port_t * p_port,
+ IN unsigned lid_offset)
+{
+ uint16_t min_lid_ho;
+ uint16_t max_lid_ho;
+ uint16_t lid_ho;
+ uint8_t port;
+ boolean_t is_ignored_by_port_prof;
+ ib_net64_t node_guid;
+ unsigned start_from = 1;
+
+ OSM_LOG_ENTER(p_mgr->p_log);
+
+ osm_port_get_lid_range_ho(p_port, &min_lid_ho, &max_lid_ho);
+
+ /* If the lids are zero - then there was some problem with
+ * the initialization. Don't handle this port. */
+ if (min_lid_ho == 0 || max_lid_ho == 0) {
+ OSM_LOG(p_mgr->p_log, OSM_LOG_ERROR, "ERR 3A04: "
+ "Port 0x%" PRIx64 " (%s port %d) has LID 0. An "
+ "initialization error occurred. Ignoring port\n",
+ cl_ntoh64(osm_port_get_guid(p_port)),
+ p_port->p_node->print_desc,
+ p_port->p_physp->port_num);
+ goto Exit;
+ }
+
+ lid_ho = min_lid_ho + lid_offset;
+
+ if (lid_ho > max_lid_ho)
+ goto Exit;
+
+ if (lid_offset && !p_mgr->is_dor)
+ /* ignore potential overflow - it is handled in osm_switch.c */
+ start_from =
+ osm_switch_get_port_by_lid(p_sw, lid_ho - 1, OSM_NEW_LFT) + 1;
+
+ OSM_LOG(p_mgr->p_log, OSM_LOG_DEBUG,
+ "Processing port 0x%" PRIx64
+ " (\'%s\' port %u), LID %u [%u,%u]\n",
+ cl_ntoh64(osm_port_get_guid(p_port)),
+ p_port->p_node->print_desc, p_port->p_physp->port_num, lid_ho,
+ min_lid_ho, max_lid_ho);
+
+ /* TODO - This should be runtime error, not a CL_ASSERT() */
+ CL_ASSERT(max_lid_ho <= IB_LID_UCAST_END_HO);
+
+ node_guid = osm_node_get_node_guid(p_sw->p_node);
+
+ /*
+ The lid matrix contains the number of hops to each
+ lid from each port. From this information we determine
+ how best to distribute the LID range across the ports
+ that can reach those LIDs.
+ */
+ port = osm_switch_recommend_path(p_sw, p_port, lid_ho, start_from,
+ p_mgr->p_subn->ignore_existing_lfts,
+ p_mgr->p_subn->opt.lmc,
+ p_mgr->is_dor,
+ p_mgr->p_subn->opt.port_shifting,
+ !lid_offset && p_port->use_scatter,
+ OSM_LFT);
+
+ if (port == OSM_NO_PATH) {
+ /* do not try to overwrite the ppro of non existing port ... */
+ is_ignored_by_port_prof = TRUE;
+
+ OSM_LOG(p_mgr->p_log, OSM_LOG_DEBUG,
+ "No path to get to LID %u from switch 0x%" PRIx64 "\n",
+ lid_ho, cl_ntoh64(node_guid));
+ } else {
+ osm_physp_t *p = osm_node_get_physp_ptr(p_sw->p_node, port);
+ if (!p)
+ goto Exit;
+
+ OSM_LOG(p_mgr->p_log, OSM_LOG_DEBUG,
+ "Routing LID %u to port %u for switch 0x%" PRIx64 "\n",
+ lid_ho, port, cl_ntoh64(node_guid));
+
+ /*
+ we would like to optionally ignore this port in equalization
+ as in the case of the Mellanox Anafa Internal PCI TCA port
+ */
+ is_ignored_by_port_prof = p->is_prof_ignored;
+
+ /*
+ We also would ignore this route if the target lid is of
+ a switch and the port_profile_switch_node is not TRUE
+ */
+ if (!p_mgr->p_subn->opt.port_profile_switch_nodes)
+ is_ignored_by_port_prof |=
+ (osm_node_get_type(p_port->p_node) ==
+ IB_NODE_TYPE_SWITCH);
+ }
+
+ /*
+ We have selected the port for this LID.
+ Write it to the forwarding tables.
+ */
+ p_sw->new_lft[lid_ho] = port;
+ if (!is_ignored_by_port_prof) {
+ struct osm_remote_node *rem_node_used;
+ osm_switch_count_path(p_sw, port);
+ if (port > 0 && p_port->priv &&
+ (rem_node_used = find_and_add_remote_sys(p_sw, port,
+ p_mgr->is_dor,
+ p_port->priv)))
+ rem_node_used->forwarded_to++;
+ }
+
+Exit:
+ OSM_LOG_EXIT(p_mgr->p_log);
+}
+
+static void alloc_ports_priv(osm_ucast_mgr_t * mgr)
+{
+ cl_qmap_t *port_tbl = &mgr->p_subn->port_guid_tbl;
+ struct osm_remote_guids_count *r;
+ osm_port_t *port;
+ cl_map_item_t *item;
+ unsigned lmc;
+
+ for (item = cl_qmap_head(port_tbl); item != cl_qmap_end(port_tbl);
+ item = cl_qmap_next(item)) {
+ port = (osm_port_t *) item;
+ lmc = ib_port_info_get_lmc(&port->p_physp->port_info);
+ r = malloc(sizeof(*r) + sizeof(r->guids[0]) * (1 << lmc));
+ if (!r) {
+ OSM_LOG(mgr->p_log, OSM_LOG_ERROR, "ERR 3A09: "
+ "cannot allocate memory to track remote"
+ " systems for lmc > 0\n");
+ port->priv = NULL;
+ continue;
+ }
+ memset(r, 0, sizeof(*r) + sizeof(r->guids[0]) * (1 << lmc));
+ port->priv = r;
+ }
+}
+
+static void free_ports_priv(osm_ucast_mgr_t * mgr)
+{
+ cl_qmap_t *port_tbl = &mgr->p_subn->port_guid_tbl;
+ osm_port_t *port;
+ cl_map_item_t *item;
+ for (item = cl_qmap_head(port_tbl); item != cl_qmap_end(port_tbl);
+ item = cl_qmap_next(item)) {
+ port = (osm_port_t *) item;
+ if (port->priv) {
+ free(port->priv);
+ port->priv = NULL;
+ }
+ }
+}
+
+static void ucast_mgr_process_tbl(IN cl_map_item_t * p_map_item,
+ IN void *context)
+{
+ osm_ucast_mgr_t *p_mgr = context;
+ osm_switch_t * p_sw = (osm_switch_t *) p_map_item;
+ unsigned i, lids_per_port;
+
+ OSM_LOG_ENTER(p_mgr->p_log);
+
+ CL_ASSERT(p_sw && p_sw->p_node);
+
+ OSM_LOG(p_mgr->p_log, OSM_LOG_DEBUG,
+ "Processing switch 0x%" PRIx64 "\n",
+ cl_ntoh64(osm_node_get_node_guid(p_sw->p_node)));
+
+ /* Initialize LIDs in buffer to invalid port number. */
+ memset(p_sw->new_lft, OSM_NO_PATH, p_sw->max_lid_ho + 1);
+
+ alloc_ports_priv(p_mgr);
+
+ /*
+ Iterate through every port setting LID routes for each
+ port based on base LID and LMC value.
+ */
+ lids_per_port = 1 << p_mgr->p_subn->opt.lmc;
+ for (i = 0; i < lids_per_port; i++) {
+ cl_qlist_t *list = &p_mgr->port_order_list;
+ cl_list_item_t *item;
+ for (item = cl_qlist_head(list); item != cl_qlist_end(list);
+ item = cl_qlist_next(item)) {
+ osm_port_t *port = cl_item_obj(item, port, list_item);
+ ucast_mgr_process_port(p_mgr, p_sw, port, i);
+ }
+ }
+
+ free_ports_priv(p_mgr);
+
+ OSM_LOG_EXIT(p_mgr->p_log);
+}
+
+static void ucast_mgr_process_neighbors(IN cl_map_item_t * p_map_item,
+ IN void *context)
+{
+ osm_switch_t * p_sw = (osm_switch_t *) p_map_item;
+ osm_ucast_mgr_t * p_mgr = context;
+ osm_node_t *p_node;
+ osm_node_t *p_remote_node;
+ uint32_t port_num;
+ uint8_t remote_port_num;
+ uint32_t num_ports;
+ osm_physp_t *p_physp;
+
+ OSM_LOG_ENTER(p_mgr->p_log);
+
+ p_node = p_sw->p_node;
+
+ CL_ASSERT(p_node);
+ CL_ASSERT(osm_node_get_type(p_node) == IB_NODE_TYPE_SWITCH);
+
+ OSM_LOG(p_mgr->p_log, OSM_LOG_DEBUG,
+ "Processing switch with GUID 0x%" PRIx64 "\n",
+ cl_ntoh64(osm_node_get_node_guid(p_node)));
+
+ num_ports = osm_node_get_num_physp(p_node);
+
+ /*
+ Start with port 1 to skip the switch's management port.
+ */
+ for (port_num = 1; port_num < num_ports; port_num++) {
+ p_remote_node = osm_node_get_remote_node(p_node,
+ (uint8_t) port_num,
+ &remote_port_num);
+ if (p_remote_node && p_remote_node->sw
+ && (p_remote_node != p_node)) {
+ /* make sure the link is healthy. If it is not - don't
+ propagate through it. */
+ p_physp = osm_node_get_physp_ptr(p_node, port_num);
+ if (!p_physp || !osm_link_is_healthy(p_physp))
+ continue;
+
+ ucast_mgr_process_neighbor(p_mgr, p_sw,
+ p_remote_node->sw,
+ (uint8_t) port_num,
+ remote_port_num);
+ }
+ }
+
+ OSM_LOG_EXIT(p_mgr->p_log);
+}
+
+static int set_hop_wf(void *ctx, uint64_t guid, char *p)
+{
+ osm_ucast_mgr_t *m = ctx;
+ osm_node_t *node = osm_get_node_by_guid(m->p_subn, cl_hton64(guid));
+ osm_physp_t *physp;
+ unsigned port, hop_wf;
+ char *e;
+
+ if (!node || !node->sw) {
+ OSM_LOG(m->p_log, OSM_LOG_DEBUG,
+ "switch with guid 0x%016" PRIx64 " is not found\n",
+ guid);
+ return 0;
+ }
+
+ if (!p || !*p || !(port = strtoul(p, &e, 0)) || (p == e) ||
+ port >= node->sw->num_ports) {
+ OSM_LOG(m->p_log, OSM_LOG_DEBUG,
+ "bad port specified for guid 0x%016" PRIx64 "\n", guid);
+ return 0;
+ }
+
+ p = e + 1;
+
+ if (!*p || !(hop_wf = strtoul(p, &e, 0)) || p == e || hop_wf >= 0x100) {
+ OSM_LOG(m->p_log, OSM_LOG_DEBUG,
+ "bad hop weight factor specified for guid 0x%016" PRIx64
+ "port %u\n", guid, port);
+ return 0;
+ }
+
+ physp = osm_node_get_physp_ptr(node, port);
+ if (!physp)
+ return 0;
+
+ physp->hop_wf = hop_wf;
+
+ return 0;
+}
+
+static void set_default_hop_wf(cl_map_item_t * p_map_item, void *ctx)
+{
+ osm_switch_t *sw = (osm_switch_t *) p_map_item;
+ int i;
+
+ for (i = 1; i < sw->num_ports; i++) {
+ osm_physp_t *p = osm_node_get_physp_ptr(sw->p_node, i);
+ if (p)
+ p->hop_wf = 1;
+ }
+}
+
+static int set_search_ordering_ports(void *ctx, uint64_t guid, char *p)
+{
+ osm_subn_t *p_subn = ctx;
+ osm_node_t *node = osm_get_node_by_guid(p_subn, cl_hton64(guid));
+ osm_switch_t *sw;
+ uint8_t *search_ordering_ports = NULL;
+ uint8_t port;
+ unsigned int *ports = NULL;
+ const int bpw = sizeof(*ports)*8;
+ int words;
+ int i = 1; /* port 0 maps to port 0 */
+
+ if (!node || !(sw = node->sw)) {
+ OSM_LOG(&p_subn->p_osm->log, OSM_LOG_VERBOSE,
+ "switch with guid 0x%016" PRIx64 " is not found\n",
+ guid);
+ return 0;
+ }
+
+ if (sw->search_ordering_ports) {
+ OSM_LOG(&p_subn->p_osm->log, OSM_LOG_VERBOSE,
+ "switch with guid 0x%016" PRIx64 " already listed\n",
+ guid);
+ return 0;
+ }
+
+ search_ordering_ports = malloc(sizeof(*search_ordering_ports)*sw->num_ports);
+ if (!search_ordering_ports) {
+ OSM_LOG(&p_subn->p_osm->log, OSM_LOG_ERROR,
+ "ERR 3A07: cannot allocate memory for search_ordering_ports\n");
+ return -1;
+ }
+ memset(search_ordering_ports, 0, sizeof(*search_ordering_ports)*sw->num_ports);
+
+ /* the ports array is for record keeping of which ports have
+ * been seen */
+ words = (sw->num_ports + bpw - 1)/bpw;
+ ports = malloc(words*sizeof(*ports));
+ if (!ports) {
+ OSM_LOG(&p_subn->p_osm->log, OSM_LOG_ERROR,
+ "ERR 3A08: cannot allocate memory for ports\n");
+ free(search_ordering_ports);
+ return -1;
+ }
+ memset(ports, 0, words*sizeof(*ports));
+
+ while ((*p != '\0') && (*p != '#')) {
+ char *e;
+
+ port = strtoul(p, &e, 0);
+ if ((p == e) || (port == 0) || (port >= sw->num_ports) ||
+ !osm_node_get_physp_ptr(node, port)) {
+ OSM_LOG(&p_subn->p_osm->log, OSM_LOG_VERBOSE,
+ "bad port %d specified for guid 0x%016" PRIx64 "\n",
+ port, guid);
+ free(search_ordering_ports);
+ free(ports);
+ return 0;
+ }
+
+ if (ports[port/bpw] & (1u << (port%bpw))) {
+ OSM_LOG(&p_subn->p_osm->log, OSM_LOG_VERBOSE,
+ "port %d already specified for guid 0x%016" PRIx64 "\n",
+ port, guid);
+ free(search_ordering_ports);
+ free(ports);
+ return 0;
+ }
+
+ ports[port/bpw] |= (1u << (port%bpw));
+ search_ordering_ports[i++] = port;
+
+ p = e;
+ while (isspace(*p)) {
+ p++;
+ }
+ }
+
+ if (i > 1) {
+ for (port = 1; port < sw->num_ports; port++) {
+ /* fill out the rest of the search_ordering_ports array
+ * in sequence using the remaining unspecified
+ * ports.
+ */
+ if (!(ports[port/bpw] & (1u << (port%bpw)))) {
+ search_ordering_ports[i++] = port;
+ }
+ }
+ sw->search_ordering_ports = search_ordering_ports;
+ } else {
+ free(search_ordering_ports);
+ }
+
+ free(ports);
+ return 0;
+}
+
+int osm_ucast_mgr_build_lid_matrices(IN osm_ucast_mgr_t * p_mgr)
+{
+ uint32_t i;
+ uint32_t iteration_max;
+ cl_qmap_t *p_sw_guid_tbl;
+
+ p_sw_guid_tbl = &p_mgr->p_subn->sw_guid_tbl;
+
+ OSM_LOG(p_mgr->p_log, OSM_LOG_VERBOSE,
+ "Starting switches' Min Hop Table Assignment\n");
+
+ /*
+ Set up the weighting factors for the routing.
+ */
+ cl_qmap_apply_func(p_sw_guid_tbl, set_default_hop_wf, NULL);
+ if (p_mgr->p_subn->opt.hop_weights_file) {
+ OSM_LOG(p_mgr->p_log, OSM_LOG_DEBUG,
+ "Fetching hop weight factor file \'%s\'\n",
+ p_mgr->p_subn->opt.hop_weights_file);
+ if (parse_node_map(p_mgr->p_subn->opt.hop_weights_file,
+ set_hop_wf, p_mgr)) {
+ OSM_LOG(p_mgr->p_log, OSM_LOG_ERROR, "ERR 3A05: "
+ "cannot parse hop_weights_file \'%s\'\n",
+ p_mgr->p_subn->opt.hop_weights_file);
+ }
+ }
+
+ /*
+ Set the switch matrices for each switch's own port 0 LID(s)
+ then set the lid matrices for the each switch's leaf nodes.
+ */
+ cl_qmap_apply_func(p_sw_guid_tbl, ucast_mgr_process_hop_0_1, p_mgr);
+
+ /*
+ Get the switch matrices for each switch's neighbors.
+ This process requires a number of iterations equal to
+ the number of switches in the subnet minus 1.
+
+ In each iteration, a switch learns the lid/port/hop
+ information (as contained by a switch's lid matrix) from
+ its immediate neighbors. After each iteration, a switch
+ (and it's neighbors) know more routing information than
+ it did on the previous iteration.
+ Thus, by repeatedly absorbing the routing information of
+ neighbor switches, every switch eventually learns how to
+ route all LIDs on the subnet.
+
+ Note that there may not be any switches in the subnet if
+ we are in simple p2p configuration.
+ */
+ iteration_max = cl_qmap_count(p_sw_guid_tbl);
+
+ /*
+ If there are switches in the subnet, iterate until the lid
+ matrix has been constructed. Otherwise, just immediately
+ indicate we're done if no switches exist.
+ */
+ if (iteration_max) {
+ iteration_max--;
+
+ /*
+ we need to find out when the propagation of
+ hop counts has relaxed. So this global variable
+ is preset to 0 on each iteration and if
+ if non of the switches was set will exit the
+ while loop
+ */
+ p_mgr->some_hop_count_set = TRUE;
+ for (i = 0; (i < iteration_max) && p_mgr->some_hop_count_set;
+ i++) {
+ p_mgr->some_hop_count_set = FALSE;
+ cl_qmap_apply_func(p_sw_guid_tbl,
+ ucast_mgr_process_neighbors, p_mgr);
+ }
+ OSM_LOG(p_mgr->p_log, OSM_LOG_DEBUG,
+ "Min-hop propagated in %d steps\n", i);
+ }
+
+ return 0;
+}
+
+static int ucast_mgr_setup_all_switches(osm_subn_t * p_subn)
+{
+ osm_switch_t *p_sw;
+ uint16_t lids;
+
+ lids = (uint16_t) cl_ptr_vector_get_size(&p_subn->port_lid_tbl);
+ lids = lids ? lids - 1 : 0;
+
+ for (p_sw = (osm_switch_t *) cl_qmap_head(&p_subn->sw_guid_tbl);
+ p_sw != (osm_switch_t *) cl_qmap_end(&p_subn->sw_guid_tbl);
+ p_sw = (osm_switch_t *) cl_qmap_next(&p_sw->map_item)) {
+ if (osm_switch_prepare_path_rebuild(p_sw, lids)) {
+ OSM_LOG(&p_subn->p_osm->log, OSM_LOG_ERROR, "ERR 3A0B: "
+ "cannot setup switch 0x%016" PRIx64 "\n",
+ cl_ntoh64(osm_node_get_node_guid
+ (p_sw->p_node)));
+ return -1;
+ }
+ if (p_sw->search_ordering_ports) {
+ free(p_sw->search_ordering_ports);
+ p_sw->search_ordering_ports = NULL;
+ }
+ }
+
+ if (p_subn->opt.port_search_ordering_file) {
+ OSM_LOG(&p_subn->p_osm->log, OSM_LOG_DEBUG,
+ "Fetching dimension ports file \'%s\'\n",
+ p_subn->opt.port_search_ordering_file);
+ if (parse_node_map(p_subn->opt.port_search_ordering_file,
+ set_search_ordering_ports, p_subn)) {
+ OSM_LOG(&p_subn->p_osm->log, OSM_LOG_ERROR, "ERR 3A0F: "
+ "cannot parse port_search_ordering_file \'%s\'\n",
+ p_subn->opt.port_search_ordering_file);
+ }
+ }
+
+ return 0;
+}
+
+static int add_guid_to_order_list(void *ctx, uint64_t guid, char *p)
+{
+ osm_ucast_mgr_t *m = ctx;
+ osm_port_t *port = osm_get_port_by_guid(m->p_subn, cl_hton64(guid));
+
+ if (!port) {
+ OSM_LOG(m->p_log, OSM_LOG_DEBUG,
+ "port guid not found: 0x%016" PRIx64 "\n", guid);
+ return 0;
+ }
+
+ if (port->flag) {
+ OSM_LOG(m->p_log, OSM_LOG_DEBUG,
+ "port guid specified multiple times 0x%016" PRIx64 "\n",
+ guid);
+ return 0;
+ }
+
+ cl_qlist_insert_tail(&m->port_order_list, &port->list_item);
+ port->flag = 1;
+ port->use_scatter = (m->p_subn->opt.guid_routing_order_no_scatter == TRUE) ? 0 : m->p_subn->opt.scatter_ports;
+
+ return 0;
+}
+
+static void add_port_to_order_list(cl_map_item_t * p_map_item, void *ctx)
+{
+ osm_port_t *port = (osm_port_t *) p_map_item;
+ osm_ucast_mgr_t *m = ctx;
+
+ if (!port->flag) {
+ port->use_scatter = m->p_subn->opt.scatter_ports;
+ cl_qlist_insert_tail(&m->port_order_list, &port->list_item);
+ } else
+ port->flag = 0;
+}
+
+static int mark_ignored_port(void *ctx, uint64_t guid, char *p)
+{
+ osm_ucast_mgr_t *m = ctx;
+ osm_node_t *node = osm_get_node_by_guid(m->p_subn, cl_hton64(guid));
+ osm_physp_t *physp;
+ unsigned port;
+
+ if (!node || !node->sw) {
+ OSM_LOG(m->p_log, OSM_LOG_DEBUG,
+ "switch with guid 0x%016" PRIx64 " is not found\n",
+ guid);
+ return 0;
+ }
+
+ if (!p || !*p || !(port = strtoul(p, NULL, 0)) ||
+ port >= node->sw->num_ports) {
+ OSM_LOG(m->p_log, OSM_LOG_DEBUG,
+ "bad port specified for guid 0x%016" PRIx64 "\n", guid);
+ return 0;
+ }
+
+ physp = osm_node_get_physp_ptr(node, port);
+ if (!physp)
+ return 0;
+
+ physp->is_prof_ignored = 1;
+
+ return 0;
+}
+
+static void clear_prof_ignore_flag(cl_map_item_t * p_map_item, void *ctx)
+{
+ osm_switch_t *sw = (osm_switch_t *) p_map_item;
+ int i;
+
+ for (i = 1; i < sw->num_ports; i++) {
+ osm_physp_t *p = osm_node_get_physp_ptr(sw->p_node, i);
+ if (p)
+ p->is_prof_ignored = 0;
+ }
+}
+
+static void add_sw_endports_to_order_list(osm_switch_t * sw,
+ osm_ucast_mgr_t * m)
+{
+ osm_port_t *port;
+ osm_physp_t *p;
+ int i;
+
+ for (i = 1; i < sw->num_ports; i++) {
+ p = osm_node_get_physp_ptr(sw->p_node, i);
+ if (p && p->p_remote_physp && !p->p_remote_physp->p_node->sw) {
+ port = osm_get_port_by_guid(m->p_subn,
+ p->p_remote_physp->
+ port_guid);
+ if (!port || port->flag)
+ continue;
+ cl_qlist_insert_tail(&m->port_order_list,
+ &port->list_item);
+ port->flag = 1;
+ port->use_scatter = m->p_subn->opt.scatter_ports;
+ }
+ }
+}
+
+static void sw_count_endport_links(osm_switch_t * sw)
+{
+ osm_physp_t *p;
+ int i;
+
+ sw->endport_links = 0;
+ for (i = 1; i < sw->num_ports; i++) {
+ p = osm_node_get_physp_ptr(sw->p_node, i);
+ if (p && p->p_remote_physp && !p->p_remote_physp->p_node->sw)
+ sw->endport_links++;
+ }
+}
+
+static int compar_sw_load(const void *s1, const void *s2)
+{
+#define get_sw_endport_links(s) (*(osm_switch_t **)s)->endport_links
+ return get_sw_endport_links(s2) - get_sw_endport_links(s1);
+}
+
+static void sort_ports_by_switch_load(osm_ucast_mgr_t * m)
+{
+ int i, num = cl_qmap_count(&m->p_subn->sw_guid_tbl);
+ void **s = malloc(num * sizeof(*s));
+ if (!s) {
+ OSM_LOG(m->p_log, OSM_LOG_ERROR, "ERR 3A0C: "
+ "No memory, skip by switch load sorting.\n");
+ return;
+ }
+ s[0] = cl_qmap_head(&m->p_subn->sw_guid_tbl);
+ for (i = 1; i < num; i++)
+ s[i] = cl_qmap_next(s[i - 1]);
+
+ for (i = 0; i < num; i++)
+ sw_count_endport_links(s[i]);
+
+ qsort(s, num, sizeof(*s), compar_sw_load);
+
+ for (i = 0; i < num; i++)
+ add_sw_endports_to_order_list(s[i], m);
+ free(s);
+}
+
+static int ucast_mgr_build_lfts(osm_ucast_mgr_t * p_mgr)
+{
+ cl_qlist_init(&p_mgr->port_order_list);
+
+ if (p_mgr->p_subn->opt.guid_routing_order_file) {
+ OSM_LOG(p_mgr->p_log, OSM_LOG_DEBUG,
+ "Fetching guid routing order file \'%s\'\n",
+ p_mgr->p_subn->opt.guid_routing_order_file);
+
+ if (parse_node_map(p_mgr->p_subn->opt.guid_routing_order_file,
+ add_guid_to_order_list, p_mgr))
+ OSM_LOG(p_mgr->p_log, OSM_LOG_ERROR, "ERR 3A0D: "
+ "cannot parse guid routing order file \'%s\'\n",
+ p_mgr->p_subn->opt.guid_routing_order_file);
+ }
+ sort_ports_by_switch_load(p_mgr);
+
+ if (p_mgr->p_subn->opt.port_prof_ignore_file) {
+ cl_qmap_apply_func(&p_mgr->p_subn->sw_guid_tbl,
+ clear_prof_ignore_flag, NULL);
+ if (parse_node_map(p_mgr->p_subn->opt.port_prof_ignore_file,
+ mark_ignored_port, p_mgr)) {
+ OSM_LOG(p_mgr->p_log, OSM_LOG_ERROR, "ERR 3A0E: "
+ "cannot parse port prof ignore file \'%s\'\n",
+ p_mgr->p_subn->opt.port_prof_ignore_file);
+ }
+ }
+
+ cl_qmap_apply_func(&p_mgr->p_subn->port_guid_tbl,
+ add_port_to_order_list, p_mgr);
+
+ cl_qmap_apply_func(&p_mgr->p_subn->sw_guid_tbl, ucast_mgr_process_tbl,
+ p_mgr);
+
+ cl_qlist_remove_all(&p_mgr->port_order_list);
+
+ return 0;
+}
+
+static void ucast_mgr_set_fwd_top(IN cl_map_item_t * p_map_item,
+ IN void *cxt)
+{
+ osm_ucast_mgr_t *p_mgr = cxt;
+ osm_switch_t * p_sw = (osm_switch_t *) p_map_item;
+ osm_node_t *p_node;
+ osm_physp_t *p_physp;
+ osm_dr_path_t *p_path;
+ osm_madw_context_t context;
+ ib_api_status_t status;
+ ib_switch_info_t si;
+ boolean_t set_swinfo_require = FALSE;
+ uint16_t lin_top;
+ uint8_t life_state;
+
+ CL_ASSERT(p_mgr);
+
+ OSM_LOG_ENTER(p_mgr->p_log);
+
+ CL_ASSERT(p_sw && p_sw->max_lid_ho);
+
+ p_node = p_sw->p_node;
+
+ CL_ASSERT(p_node);
+
+ if (p_mgr->max_lid < p_sw->max_lid_ho)
+ p_mgr->max_lid = p_sw->max_lid_ho;
+
+ p_physp = osm_node_get_physp_ptr(p_node, 0);
+
+ CL_ASSERT(p_physp);
+
+ p_path = osm_physp_get_dr_path_ptr(p_physp);
+
+ /*
+ Set the top of the unicast forwarding table.
+ */
+ si = p_sw->switch_info;
+ lin_top = cl_hton16(p_sw->max_lid_ho);
+ if (lin_top != si.lin_top) {
+ set_swinfo_require = TRUE;
+ si.lin_top = lin_top;
+ context.si_context.lft_top_change = TRUE;
+ } else
+ context.si_context.lft_top_change = FALSE;
+
+ life_state = si.life_state;
+ ib_switch_info_set_life_time(&si, p_mgr->p_subn->opt.packet_life_time);
+
+ if (life_state != si.life_state)
+ set_swinfo_require = TRUE;
+
+ if (set_swinfo_require) {
+ OSM_LOG(p_mgr->p_log, OSM_LOG_DEBUG,
+ "Setting switch FT top to LID %u\n", p_sw->max_lid_ho);
+
+ context.si_context.light_sweep = FALSE;
+ context.si_context.node_guid = osm_node_get_node_guid(p_node);
+ context.si_context.set_method = TRUE;
+
+ status = osm_req_set(p_mgr->sm, p_path, (uint8_t *) & si,
+ sizeof(si), IB_MAD_ATTR_SWITCH_INFO,
+ 0, FALSE,
+ ib_port_info_get_m_key(&p_physp->port_info),
+ CL_DISP_MSGID_NONE, &context);
+
+ if (status != IB_SUCCESS)
+ OSM_LOG(p_mgr->p_log, OSM_LOG_ERROR, "ERR 3A06: "
+ "Sending SwitchInfo attribute failed (%s)\n",
+ ib_get_err_str(status));
+ }
+
+ OSM_LOG_EXIT(p_mgr->p_log);
+}
+
+static int set_lft_block(IN osm_switch_t *p_sw, IN osm_ucast_mgr_t *p_mgr,
+ IN uint16_t block_id_ho)
+{
+ osm_madw_context_t context;
+ osm_dr_path_t *p_path;
+ osm_physp_t *p_physp;
+ ib_api_status_t status;
+
+ /*
+ Send linear forwarding table blocks to the switch
+ as long as the switch indicates it has blocks needing
+ configuration.
+ */
+ if (!p_sw->new_lft) {
+ /* any routing should provide the new_lft */
+ CL_ASSERT(p_mgr->p_subn->opt.use_ucast_cache &&
+ p_mgr->cache_valid && !p_sw->need_update);
+ return -1;
+ }
+
+ p_physp = osm_node_get_physp_ptr(p_sw->p_node, 0);
+ if (!p_physp)
+ return -1;
+
+ p_path = osm_physp_get_dr_path_ptr(p_physp);
+
+ context.lft_context.node_guid = osm_node_get_node_guid(p_sw->p_node);
+ context.lft_context.set_method = TRUE;
+
+ if (!p_sw->need_update && !p_mgr->p_subn->need_update &&
+ !memcmp(p_sw->new_lft + block_id_ho * IB_SMP_DATA_SIZE,
+ p_sw->lft + block_id_ho * IB_SMP_DATA_SIZE,
+ IB_SMP_DATA_SIZE))
+ return 0;
+
+ /*
+ * Zero the stored LFT block, so in case the MAD will end up
+ * with error, we will resend it in the next sweep.
+ */
+ memset(p_sw->lft + block_id_ho * IB_SMP_DATA_SIZE, 0,
+ IB_SMP_DATA_SIZE);
+
+ OSM_LOG(p_mgr->p_log, OSM_LOG_DEBUG,
+ "Writing FT block %u to switch 0x%" PRIx64 "\n", block_id_ho,
+ cl_ntoh64(context.lft_context.node_guid));
+
+ status = osm_req_set(p_mgr->sm, p_path,
+ p_sw->new_lft + block_id_ho * IB_SMP_DATA_SIZE,
+ IB_SMP_DATA_SIZE, IB_MAD_ATTR_LIN_FWD_TBL,
+ cl_hton32(block_id_ho), FALSE,
+ ib_port_info_get_m_key(&p_physp->port_info),
+ CL_DISP_MSGID_NONE, &context);
+
+ if (status != IB_SUCCESS) {
+ OSM_LOG(p_mgr->p_log, OSM_LOG_ERROR, "ERR 3A10: "
+ "Sending linear fwd. tbl. block failed (%s)\n",
+ ib_get_err_str(status));
+ return -1;
+ }
+
+ return 0;
+}
+
+static void ucast_mgr_pipeline_fwd_tbl(osm_ucast_mgr_t * p_mgr)
+{
+ cl_qmap_t *tbl;
+ cl_map_item_t *item;
+ unsigned i, max_block = p_mgr->max_lid / IB_SMP_DATA_SIZE + 1;
+
+ tbl = &p_mgr->p_subn->sw_guid_tbl;
+ for (i = 0; i < max_block; i++)
+ for (item = cl_qmap_head(tbl); item != cl_qmap_end(tbl);
+ item = cl_qmap_next(item))
+ set_lft_block((osm_switch_t *)item, p_mgr, i);
+}
+
+void osm_ucast_mgr_set_fwd_tables(osm_ucast_mgr_t * p_mgr)
+{
+ p_mgr->max_lid = 0;
+
+ cl_qmap_apply_func(&p_mgr->p_subn->sw_guid_tbl, ucast_mgr_set_fwd_top,
+ p_mgr);
+
+ ucast_mgr_pipeline_fwd_tbl(p_mgr);
+}
+
+static int ucast_mgr_route(struct osm_routing_engine *r, osm_opensm_t * osm)
+{
+ int ret;
+
+ OSM_LOG(&osm->log, OSM_LOG_VERBOSE,
+ "building routing with \'%s\' routing algorithm...\n", r->name);
+
+ /* Set the before each lft build to keep the routes in place between sweeps */
+ if (osm->subn.opt.scatter_ports)
+ srandom(osm->subn.opt.scatter_ports);
+
+ if (!r->build_lid_matrices ||
+ (ret = r->build_lid_matrices(r->context)) > 0)
+ ret = osm_ucast_mgr_build_lid_matrices(&osm->sm.ucast_mgr);
+
+ if (ret < 0) {
+ OSM_LOG(&osm->log, OSM_LOG_ERROR,
+ "%s: cannot build lid matrices\n", r->name);
+ return ret;
+ }
+
+ if (!r->ucast_build_fwd_tables ||
+ (ret = r->ucast_build_fwd_tables(r->context)) > 0)
+ ret = ucast_mgr_build_lfts(&osm->sm.ucast_mgr);
+
+ if (ret < 0) {
+ OSM_LOG(&osm->log, OSM_LOG_ERROR,
+ "%s: cannot build fwd tables\n", r->name);
+ return ret;
+ }
+
+ osm->routing_engine_used = r;
+
+ osm_ucast_mgr_set_fwd_tables(&osm->sm.ucast_mgr);
+
+ return 0;
+}
+
+int osm_ucast_mgr_process(IN osm_ucast_mgr_t * p_mgr)
+{
+ osm_opensm_t *p_osm;
+ struct osm_routing_engine *p_routing_eng;
+ cl_qmap_t *p_sw_guid_tbl;
+ int failed = 0;
+
+ OSM_LOG_ENTER(p_mgr->p_log);
+
+ p_sw_guid_tbl = &p_mgr->p_subn->sw_guid_tbl;
+ p_osm = p_mgr->p_subn->p_osm;
+ p_routing_eng = p_osm->routing_engine_list;
+
+ CL_PLOCK_EXCL_ACQUIRE(p_mgr->p_lock);
+
+ /*
+ If there are no switches in the subnet, we are done.
+ */
+ if (cl_qmap_count(p_sw_guid_tbl) == 0 ||
+ ucast_mgr_setup_all_switches(p_mgr->p_subn) < 0)
+ goto Exit;
+
+ failed = -1;
+ p_osm->routing_engine_used = NULL;
+ while (p_routing_eng) {
+ failed = ucast_mgr_route(p_routing_eng, p_osm);
+ if (!failed)
+ break;
+ p_routing_eng = p_routing_eng->next;
+ }
+
+ if (!p_osm->routing_engine_used &&
+ p_osm->no_fallback_routing_engine != TRUE) {
+ /* If configured routing algorithm failed, use default MinHop */
+ failed = ucast_mgr_route(p_osm->default_routing_engine, p_osm);
+ }
+
+ if (p_osm->routing_engine_used) {
+ OSM_LOG(p_mgr->p_log, OSM_LOG_INFO,
+ "%s tables configured on all switches\n",
+ osm_routing_engine_type_str(p_osm->
+ routing_engine_used->type));
+
+ if (p_mgr->p_subn->opt.use_ucast_cache)
+ p_mgr->cache_valid = TRUE;
+ } else {
+ p_mgr->p_subn->subnet_initialization_error = TRUE;
+ OSM_LOG(p_mgr->p_log, OSM_LOG_ERROR,
+ "No routing engine able to successfully configure "
+ " switch tables on current fabric\n");
+ }
+Exit:
+ CL_PLOCK_RELEASE(p_mgr->p_lock);
+ OSM_LOG_EXIT(p_mgr->p_log);
+ return failed;
+}
+
+static int ucast_build_lid_matrices(void *context)
+{
+ return osm_ucast_mgr_build_lid_matrices(context);
+}
+
+static int ucast_build_lfts(void *context)
+{
+ return ucast_mgr_build_lfts(context);
+}
+
+int osm_ucast_minhop_setup(struct osm_routing_engine *r, osm_opensm_t * osm)
+{
+ r->context = &osm->sm.ucast_mgr;
+ r->build_lid_matrices = ucast_build_lid_matrices;
+ r->ucast_build_fwd_tables = ucast_build_lfts;
+ return 0;
+}
+
+static int ucast_dor_build_lfts(void *context)
+{
+ osm_ucast_mgr_t *mgr = context;
+ int ret;
+
+ mgr->is_dor = 1;
+ ret = ucast_mgr_build_lfts(mgr);
+ mgr->is_dor = 0;
+
+ return ret;
+}
+
+int osm_ucast_dor_setup(struct osm_routing_engine *r, osm_opensm_t * osm)
+{
+ r->context = &osm->sm.ucast_mgr;
+ r->build_lid_matrices = ucast_build_lid_matrices;
+ r->ucast_build_fwd_tables = ucast_dor_build_lfts;
+ return 0;
+}
+
+int ucast_dummy_build_lid_matrices(void *context)
+{
+ return 0;
+}
diff --git a/contrib/ofed/opensm/opensm/osm_ucast_updn.c b/contrib/ofed/opensm/opensm/osm_ucast_updn.c
new file mode 100644
index 0000000..d29f12a
--- /dev/null
+++ b/contrib/ofed/opensm/opensm/osm_ucast_updn.c
@@ -0,0 +1,677 @@
+/*
+ * Copyright (c) 2004-2008 Voltaire, Inc. All rights reserved.
+ * Copyright (c) 2002-2007,2009 Mellanox Technologies LTD. All rights reserved.
+ * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
+ * Copyright (c) 2009 HNR Consulting. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+/*
+ * Abstract:
+ * Implementation of Up Down Algorithm using ranking & Min Hop
+ * Calculation functions
+ */
+
+#if HAVE_CONFIG_H
+# include <config.h>
+#endif /* HAVE_CONFIG_H */
+
+#include <stdlib.h>
+#include <ctype.h>
+#include <complib/cl_debug.h>
+#include <complib/cl_qmap.h>
+#include <opensm/osm_file_ids.h>
+#define FILE_ID OSM_FILE_UCAST_UPDN_C
+#include <opensm/osm_switch.h>
+#include <opensm/osm_opensm.h>
+#include <opensm/osm_ucast_mgr.h>
+
+/* //////////////////////////// */
+/* Local types */
+/* //////////////////////////// */
+
+/* direction */
+typedef enum updn_switch_dir {
+ UP = 0,
+ DOWN
+} updn_switch_dir_t;
+
+/* updn structure */
+typedef struct updn {
+ unsigned num_roots;
+ osm_opensm_t *p_osm;
+} updn_t;
+
+struct updn_node {
+ cl_list_item_t list;
+ osm_switch_t *sw;
+ uint64_t id;
+ updn_switch_dir_t dir;
+ unsigned rank;
+ unsigned visited;
+};
+
+/* This function returns direction based on rank and guid info of current &
+ remote ports */
+static updn_switch_dir_t updn_get_dir(unsigned cur_rank, unsigned rem_rank,
+ uint64_t cur_id, uint64_t rem_id)
+{
+ /* HACK: comes to solve root nodes connection, in a classic subnet root nodes do not connect
+ directly, but in case they are we assign to root node an UP direction to allow UPDN to discover
+ the subnet correctly (and not from the point of view of the last root node).
+ */
+ if (!cur_rank && !rem_rank)
+ return UP;
+
+ if (cur_rank < rem_rank)
+ return DOWN;
+ else if (cur_rank > rem_rank)
+ return UP;
+ else {
+ /* Equal rank, decide by id number, bigger == UP direction */
+ if (cur_id > rem_id)
+ return UP;
+ else
+ return DOWN;
+ }
+}
+
+/**********************************************************************
+ * This function does the bfs of min hop table calculation by guid index
+ * as a starting point.
+ **********************************************************************/
+static int updn_bfs_by_node(IN osm_log_t * p_log, IN osm_subn_t * p_subn,
+ IN osm_switch_t * p_sw)
+{
+ uint8_t pn, pn_rem;
+ cl_qlist_t list;
+ uint16_t lid;
+ struct updn_node *u;
+ updn_switch_dir_t next_dir, current_dir;
+
+ OSM_LOG_ENTER(p_log);
+
+ lid = osm_node_get_base_lid(p_sw->p_node, 0);
+ lid = cl_ntoh16(lid);
+ osm_switch_set_hops(p_sw, lid, 0, 0);
+
+ OSM_LOG(p_log, OSM_LOG_DEBUG,
+ "Starting from switch - port GUID 0x%" PRIx64 " lid %u\n",
+ cl_ntoh64(p_sw->p_node->node_info.port_guid), lid);
+
+ u = p_sw->priv;
+ u->dir = UP;
+
+ /* Update list with the new element */
+ cl_qlist_init(&list);
+ cl_qlist_insert_tail(&list, &u->list);
+
+ /* BFS the list till no next element */
+ while (!cl_is_qlist_empty(&list)) {
+ u = (struct updn_node *)cl_qlist_remove_head(&list);
+ u->visited = 0; /* cleanup */
+ current_dir = u->dir;
+ /* Go over all ports of the switch and find unvisited remote nodes */
+ for (pn = 1; pn < u->sw->num_ports; pn++) {
+ osm_node_t *p_remote_node;
+ struct updn_node *rem_u;
+ uint8_t current_min_hop, remote_min_hop,
+ set_hop_return_value;
+ osm_switch_t *p_remote_sw;
+
+ p_remote_node =
+ osm_node_get_remote_node(u->sw->p_node, pn,
+ &pn_rem);
+ /* If no remote node OR remote node is not a SWITCH
+ continue to next pn */
+ if (!p_remote_node || !p_remote_node->sw)
+ continue;
+ /* Fetch remote guid only after validation of remote node */
+ p_remote_sw = p_remote_node->sw;
+ rem_u = p_remote_sw->priv;
+ /* Decide which direction to mark it (UP/DOWN) */
+ next_dir = updn_get_dir(u->rank, rem_u->rank,
+ u->id, rem_u->id);
+
+ /* Check if this is a legal step : the only illegal step is going
+ from DOWN to UP */
+ if ((current_dir == DOWN) && (next_dir == UP)) {
+ OSM_LOG(p_log, OSM_LOG_DEBUG,
+ "Avoiding move from 0x%016" PRIx64
+ " to 0x%016" PRIx64 "\n",
+ cl_ntoh64(osm_node_get_node_guid(u->sw->p_node)),
+ cl_ntoh64(osm_node_get_node_guid(p_remote_node)));
+ /* Illegal step */
+ continue;
+ }
+ /* Set MinHop value for the current lid */
+ current_min_hop = osm_switch_get_least_hops(u->sw, lid);
+ /* Check hop count if better insert into list && update
+ the remote node Min Hop Table */
+ remote_min_hop =
+ osm_switch_get_hop_count(p_remote_sw, lid, pn_rem);
+ if (current_min_hop + 1 < remote_min_hop) {
+ set_hop_return_value =
+ osm_switch_set_hops(p_remote_sw, lid,
+ pn_rem,
+ current_min_hop + 1);
+ if (set_hop_return_value) {
+ OSM_LOG(p_log, OSM_LOG_ERROR, "ERR AA01: "
+ "Invalid value returned from set min hop is: %d\n",
+ set_hop_return_value);
+ }
+ /* Check if remote port has already been visited */
+ if (!rem_u->visited) {
+ /* Insert updn_switch item into the list */
+ rem_u->dir = next_dir;
+ rem_u->visited = 1;
+ cl_qlist_insert_tail(&list,
+ &rem_u->list);
+ }
+ }
+ }
+ }
+
+ OSM_LOG_EXIT(p_log);
+ return 0;
+}
+
+/* NOTE : PLS check if we need to decide that the first */
+/* rank is a SWITCH for BFS purpose */
+static int updn_subn_rank(IN updn_t * p_updn)
+{
+ osm_switch_t *p_sw;
+ osm_physp_t *p_physp, *p_remote_physp;
+ cl_qlist_t list;
+ cl_map_item_t *item;
+ struct updn_node *u, *remote_u;
+ uint8_t num_ports, port_num;
+ osm_log_t *p_log = &p_updn->p_osm->log;
+ unsigned max_rank = 0;
+
+ OSM_LOG_ENTER(p_log);
+ cl_qlist_init(&list);
+
+ /* add all roots to the list */
+ for (item = cl_qmap_head(&p_updn->p_osm->subn.sw_guid_tbl);
+ item != cl_qmap_end(&p_updn->p_osm->subn.sw_guid_tbl);
+ item = cl_qmap_next(item)) {
+ p_sw = (osm_switch_t *)item;
+ u = p_sw->priv;
+ if (!u->rank)
+ cl_qlist_insert_tail(&list, &u->list);
+ }
+
+ /* BFS the list till it's empty */
+ while (!cl_is_qlist_empty(&list)) {
+ u = (struct updn_node *)cl_qlist_remove_head(&list);
+ /* Go over all remote nodes and rank them (if not already visited) */
+ p_sw = u->sw;
+ num_ports = p_sw->num_ports;
+ OSM_LOG(p_log, OSM_LOG_DEBUG,
+ "Handling switch GUID 0x%" PRIx64 "\n",
+ cl_ntoh64(osm_node_get_node_guid(p_sw->p_node)));
+ for (port_num = 1; port_num < num_ports; port_num++) {
+ ib_net64_t port_guid;
+
+ /* Current port fetched in order to get remote side */
+ p_physp =
+ osm_node_get_physp_ptr(p_sw->p_node, port_num);
+
+ if (!p_physp)
+ continue;
+
+ p_remote_physp = p_physp->p_remote_physp;
+
+ /*
+ make sure that all the following occur on p_remote_physp:
+ 1. The port isn't NULL
+ 2. It is a switch
+ */
+ if (p_remote_physp && p_remote_physp->p_node->sw) {
+ remote_u = p_remote_physp->p_node->sw->priv;
+ port_guid = p_remote_physp->port_guid;
+
+ if (remote_u->rank > u->rank + 1) {
+ remote_u->rank = u->rank + 1;
+ max_rank = remote_u->rank;
+ cl_qlist_insert_tail(&list,
+ &remote_u->list);
+ OSM_LOG(p_log, OSM_LOG_DEBUG,
+ "Rank of port GUID 0x%" PRIx64
+ " = %u\n", cl_ntoh64(port_guid),
+ remote_u->rank);
+ }
+ }
+ }
+ }
+
+ /* Print Summary of ranking */
+ OSM_LOG(p_log, OSM_LOG_VERBOSE,
+ "Subnet ranking completed. Max Node Rank = %d\n", max_rank);
+ OSM_LOG_EXIT(p_log);
+ return 0;
+}
+
+/* hack: preserve min hops entries to any other root switches */
+static void updn_clear_non_root_hops(updn_t * updn, osm_switch_t * sw)
+{
+ osm_port_t *port;
+ unsigned i;
+
+ for (i = 0; i < sw->num_hops; i++)
+ if (sw->hops[i]) {
+ port = osm_get_port_by_lid_ho(&updn->p_osm->subn, i);
+ if (!port || !port->p_node->sw
+ || ((struct updn_node *)port->p_node->sw->priv)->
+ rank != 0)
+ memset(sw->hops[i], 0xff, sw->num_ports);
+ }
+}
+
+static int updn_set_min_hop_table(IN updn_t * p_updn)
+{
+ osm_subn_t *p_subn = &p_updn->p_osm->subn;
+ osm_log_t *p_log = &p_updn->p_osm->log;
+ osm_switch_t *p_sw;
+ cl_map_item_t *item;
+
+ OSM_LOG_ENTER(p_log);
+
+ /* Go over all the switches in the subnet - for each init their Min Hop
+ Table */
+ OSM_LOG(p_log, OSM_LOG_VERBOSE,
+ "Init Min Hop Table of all switches [\n");
+
+ for (item = cl_qmap_head(&p_updn->p_osm->subn.sw_guid_tbl);
+ item != cl_qmap_end(&p_updn->p_osm->subn.sw_guid_tbl);
+ item = cl_qmap_next(item)) {
+ p_sw = (osm_switch_t *)item;
+ /* Clear Min Hop Table */
+ if (p_subn->opt.connect_roots)
+ updn_clear_non_root_hops(p_updn, p_sw);
+ else
+ osm_switch_clear_hops(p_sw);
+ }
+
+ OSM_LOG(p_log, OSM_LOG_VERBOSE,
+ "Init Min Hop Table of all switches ]\n");
+
+ /* Now do the BFS for each port in the subnet */
+ OSM_LOG(p_log, OSM_LOG_VERBOSE,
+ "BFS through all port guids in the subnet [\n");
+
+ for (item = cl_qmap_head(&p_updn->p_osm->subn.sw_guid_tbl);
+ item != cl_qmap_end(&p_updn->p_osm->subn.sw_guid_tbl);
+ item = cl_qmap_next(item)) {
+ p_sw = (osm_switch_t *)item;
+ updn_bfs_by_node(p_log, p_subn, p_sw);
+ }
+
+ OSM_LOG(p_log, OSM_LOG_VERBOSE,
+ "BFS through all port guids in the subnet ]\n");
+ /* Cleanup */
+ OSM_LOG_EXIT(p_log);
+ return 0;
+}
+
+static int updn_build_lid_matrices(IN updn_t * p_updn)
+{
+ int status;
+
+ OSM_LOG_ENTER(&p_updn->p_osm->log);
+
+ OSM_LOG(&p_updn->p_osm->log, OSM_LOG_VERBOSE,
+ "Ranking all port guids in the list\n");
+ if (!p_updn->num_roots) {
+ OSM_LOG(&p_updn->p_osm->log, OSM_LOG_ERROR, "ERR AA0A: "
+ "No guids were provided or number of guids is 0\n");
+ status = -1;
+ goto _exit;
+ }
+
+ /* Check if it's not a switched subnet */
+ if (cl_is_qmap_empty(&p_updn->p_osm->subn.sw_guid_tbl)) {
+ OSM_LOG(&p_updn->p_osm->log, OSM_LOG_ERROR, "ERR AA0B: "
+ "This is not a switched subnet, cannot perform UPDN algorithm\n");
+ status = -1;
+ goto _exit;
+ }
+
+ /* Rank the subnet switches */
+ if (updn_subn_rank(p_updn)) {
+ OSM_LOG(&p_updn->p_osm->log, OSM_LOG_ERROR, "ERR AA0E: "
+ "Failed to assign ranks\n");
+ status = -1;
+ goto _exit;
+ }
+
+ /* After multiple ranking need to set Min Hop Table by UpDn algorithm */
+ OSM_LOG(&p_updn->p_osm->log, OSM_LOG_VERBOSE,
+ "Setting all switches' Min Hop Table\n");
+ status = updn_set_min_hop_table(p_updn);
+
+_exit:
+ OSM_LOG_EXIT(&p_updn->p_osm->log);
+ return status;
+}
+
+static struct updn_node *create_updn_node(osm_switch_t * sw)
+{
+ struct updn_node *u;
+
+ u = malloc(sizeof(*u));
+ if (!u)
+ return NULL;
+ memset(u, 0, sizeof(*u));
+ u->sw = sw;
+ u->id = cl_ntoh64(osm_node_get_node_guid(sw->p_node));
+ u->rank = 0xffffffff;
+ return u;
+}
+
+static void delete_updn_node(struct updn_node *u)
+{
+ u->sw->priv = NULL;
+ free(u);
+}
+
+/* Find Root nodes automatically by Min Hop Table info */
+static void updn_find_root_nodes_by_min_hop(OUT updn_t * p_updn)
+{
+ osm_opensm_t *p_osm = p_updn->p_osm;
+ osm_switch_t *p_sw;
+ osm_port_t *p_port;
+ osm_physp_t *p_physp;
+ cl_map_item_t *item;
+ double thd1, thd2;
+ unsigned i, cas_num = 0;
+ unsigned *cas_per_sw;
+ uint16_t lid_ho;
+
+ OSM_LOG_ENTER(&p_osm->log);
+
+ OSM_LOG(&p_osm->log, OSM_LOG_DEBUG,
+ "Current number of ports in the subnet is %d\n",
+ cl_qmap_count(&p_osm->subn.port_guid_tbl));
+
+ lid_ho = (uint16_t) cl_ptr_vector_get_size(&p_updn->p_osm->subn.port_lid_tbl) + 1;
+ cas_per_sw = malloc(lid_ho * sizeof(*cas_per_sw));
+ if (!cas_per_sw) {
+ OSM_LOG(&p_osm->log, OSM_LOG_ERROR, "ERR AA14: "
+ "cannot alloc mem for CAs per switch counter array\n");
+ goto _exit;
+ }
+ memset(cas_per_sw, 0, lid_ho * sizeof(*cas_per_sw));
+
+ /* Find the Maximum number of CAs (and routers) for histogram normalization */
+ OSM_LOG(&p_osm->log, OSM_LOG_VERBOSE,
+ "Finding the number of CAs and storing them in cl_map\n");
+ for (item = cl_qmap_head(&p_updn->p_osm->subn.port_guid_tbl);
+ item != cl_qmap_end(&p_updn->p_osm->subn.port_guid_tbl);
+ item = cl_qmap_next(item)) {
+ p_port = (osm_port_t *)item;
+ if (!p_port->p_node->sw) {
+ p_physp = p_port->p_physp->p_remote_physp;
+ if (!p_physp || !p_physp->p_node->sw)
+ continue;
+ lid_ho = osm_node_get_base_lid(p_physp->p_node, 0);
+ lid_ho = cl_ntoh16(lid_ho);
+ cas_per_sw[lid_ho]++;
+ cas_num++;
+ }
+ }
+
+ thd1 = cas_num * 0.9;
+ thd2 = cas_num * 0.05;
+ OSM_LOG(&p_osm->log, OSM_LOG_DEBUG,
+ "Found %u CAs and RTRs, %u SWs in the subnet. "
+ "Thresholds are thd1 = %f && thd2 = %f\n",
+ cas_num, cl_qmap_count(&p_osm->subn.sw_guid_tbl), thd1, thd2);
+
+ OSM_LOG(&p_osm->log, OSM_LOG_VERBOSE,
+ "Passing through all switches to collect Min Hop info\n");
+ for (item = cl_qmap_head(&p_updn->p_osm->subn.sw_guid_tbl);
+ item != cl_qmap_end(&p_updn->p_osm->subn.sw_guid_tbl);
+ item = cl_qmap_next(item)) {
+ unsigned hop_hist[IB_SUBNET_PATH_HOPS_MAX];
+ uint16_t max_lid_ho;
+ uint8_t hop_val;
+ uint16_t numHopBarsOverThd1 = 0;
+ uint16_t numHopBarsOverThd2 = 0;
+
+ p_sw = (osm_switch_t *) item;
+
+ memset(hop_hist, 0, sizeof(hop_hist));
+
+ max_lid_ho = p_sw->max_lid_ho;
+ for (lid_ho = 1; lid_ho <= max_lid_ho; lid_ho++)
+ if (cas_per_sw[lid_ho]) {
+ hop_val =
+ osm_switch_get_least_hops(p_sw, lid_ho);
+ if (hop_val >= IB_SUBNET_PATH_HOPS_MAX)
+ continue;
+
+ hop_hist[hop_val] += cas_per_sw[lid_ho];
+ }
+
+ /* Now recognize the spines by requiring one bar to be
+ above 90% of the number of CAs and RTRs */
+ for (i = 0; i < IB_SUBNET_PATH_HOPS_MAX; i++) {
+ if (hop_hist[i] > thd1)
+ numHopBarsOverThd1++;
+ if (hop_hist[i] > thd2)
+ numHopBarsOverThd2++;
+ }
+
+ /* If thd conditions are valid - rank the root node */
+ if (numHopBarsOverThd1 == 1 && numHopBarsOverThd2 == 1) {
+ OSM_LOG(&p_osm->log, OSM_LOG_DEBUG,
+ "Ranking GUID 0x%" PRIx64 " as root node\n",
+ cl_ntoh64(osm_node_get_node_guid(p_sw->p_node)));
+ ((struct updn_node *)p_sw->priv)->rank = 0;
+ p_updn->num_roots++;
+ }
+ }
+
+ free(cas_per_sw);
+_exit:
+ OSM_LOG_EXIT(&p_osm->log);
+ return;
+}
+
+static void dump_roots(cl_map_item_t *item, FILE *file, void *cxt)
+{
+ osm_switch_t *sw = (osm_switch_t *)item;
+ if (!((struct updn_node *)sw->priv)->rank)
+ fprintf(file, "0x%" PRIx64 "\n",
+ cl_ntoh64(osm_node_get_node_guid(sw->p_node)));
+}
+
+static int update_id(void *cxt, uint64_t guid, char *p)
+{
+ osm_opensm_t *osm = cxt;
+ osm_switch_t *sw;
+ uint64_t id;
+ char *e;
+
+ sw = osm_get_switch_by_guid(&osm->subn, cl_hton64(guid));
+ if (!sw) {
+ OSM_LOG(&osm->log, OSM_LOG_VERBOSE,
+ "switch with guid 0x%" PRIx64 " is not found\n", guid);
+ return 0;
+ }
+
+ id = strtoull(p, &e, 0);
+ if (*e && !isspace(*e)) {
+ OSM_LOG(&osm->log, OSM_LOG_ERROR,
+ "ERR AA05: cannot parse node id \'%s\'", p);
+ return -1;
+ }
+
+ OSM_LOG(&osm->log, OSM_LOG_DEBUG,
+ "update node 0x%" PRIx64 " id to 0x%" PRIx64 "\n", guid, id);
+
+ ((struct updn_node *)sw->priv)->id = id;
+
+ return 0;
+}
+
+static int rank_root_node(void *cxt, uint64_t guid, char *p)
+{
+ updn_t *updn = cxt;
+ osm_switch_t *sw;
+
+ sw = osm_get_switch_by_guid(&updn->p_osm->subn, cl_hton64(guid));
+ if (!sw) {
+ OSM_LOG(&updn->p_osm->log, OSM_LOG_VERBOSE,
+ "switch with guid 0x%" PRIx64 " is not found\n", guid);
+ return 0;
+ }
+
+ OSM_LOG(&updn->p_osm->log, OSM_LOG_DEBUG,
+ "Ranking root port GUID 0x%" PRIx64 "\n", guid);
+
+ ((struct updn_node *)sw->priv)->rank = 0;
+ updn->num_roots++;
+
+ return 0;
+}
+
+/* UPDN callback function */
+static int updn_lid_matrices(void *ctx)
+{
+ updn_t *p_updn = ctx;
+ cl_map_item_t *item;
+ osm_switch_t *p_sw;
+ int ret = 0;
+
+ OSM_LOG_ENTER(&p_updn->p_osm->log);
+
+ for (item = cl_qmap_head(&p_updn->p_osm->subn.sw_guid_tbl);
+ item != cl_qmap_end(&p_updn->p_osm->subn.sw_guid_tbl);
+ item = cl_qmap_next(item)) {
+ p_sw = (osm_switch_t *)item;
+ p_sw->priv = create_updn_node(p_sw);
+ if (!p_sw->priv) {
+ OSM_LOG(&(p_updn->p_osm->log), OSM_LOG_ERROR, "ERR AA0C: "
+ "cannot create updn node\n");
+ OSM_LOG_EXIT(&p_updn->p_osm->log);
+ return -1;
+ }
+ }
+
+ /* First setup root nodes */
+ p_updn->num_roots = 0;
+
+ if (p_updn->p_osm->subn.opt.root_guid_file) {
+ OSM_LOG(&p_updn->p_osm->log, OSM_LOG_DEBUG,
+ "UPDN - Fetching root nodes from file \'%s\'\n",
+ p_updn->p_osm->subn.opt.root_guid_file);
+
+ ret = parse_node_map(p_updn->p_osm->subn.opt.root_guid_file,
+ rank_root_node, p_updn);
+ if (ret) {
+ OSM_LOG(&p_updn->p_osm->log, OSM_LOG_ERROR, "ERR AA02: "
+ "cannot parse root guids file \'%s\'\n",
+ p_updn->p_osm->subn.opt.root_guid_file);
+ osm_ucast_mgr_build_lid_matrices(&p_updn->p_osm->sm.ucast_mgr);
+ updn_find_root_nodes_by_min_hop(p_updn);
+ } else if (p_updn->p_osm->subn.opt.connect_roots &&
+ p_updn->num_roots > 1)
+ osm_ucast_mgr_build_lid_matrices(&p_updn->p_osm->sm.ucast_mgr);
+ } else {
+ osm_ucast_mgr_build_lid_matrices(&p_updn->p_osm->sm.ucast_mgr);
+ updn_find_root_nodes_by_min_hop(p_updn);
+ }
+
+ if (p_updn->p_osm->subn.opt.ids_guid_file) {
+ OSM_LOG(&p_updn->p_osm->log, OSM_LOG_DEBUG,
+ "UPDN - update node ids from file \'%s\'\n",
+ p_updn->p_osm->subn.opt.ids_guid_file);
+
+ ret = parse_node_map(p_updn->p_osm->subn.opt.ids_guid_file,
+ update_id, p_updn->p_osm);
+ if (ret)
+ OSM_LOG(&p_updn->p_osm->log, OSM_LOG_ERROR, "ERR AA03: "
+ "cannot parse node ids file \'%s\'\n",
+ p_updn->p_osm->subn.opt.ids_guid_file);
+ }
+
+ /* Only if there are assigned root nodes do the algorithm, otherwise perform do nothing */
+ if (p_updn->num_roots) {
+ OSM_LOG(&p_updn->p_osm->log, OSM_LOG_DEBUG,
+ "activating UPDN algorithm\n");
+ ret = updn_build_lid_matrices(p_updn);
+ } else {
+ OSM_LOG(&p_updn->p_osm->log, OSM_LOG_INFO,
+ "disabling UPDN algorithm, no root nodes were found\n");
+ ret = -1;
+ }
+
+ if (OSM_LOG_IS_ACTIVE_V2(&p_updn->p_osm->log, OSM_LOG_ROUTING))
+ osm_dump_qmap_to_file(p_updn->p_osm, "opensm-updn-roots.dump",
+ &p_updn->p_osm->subn.sw_guid_tbl,
+ dump_roots, NULL);
+
+ for (item = cl_qmap_head(&p_updn->p_osm->subn.sw_guid_tbl);
+ item != cl_qmap_end(&p_updn->p_osm->subn.sw_guid_tbl);
+ item = cl_qmap_next(item)) {
+ p_sw = (osm_switch_t *) item;
+ delete_updn_node(p_sw->priv);
+ }
+
+ OSM_LOG_EXIT(&p_updn->p_osm->log);
+ return ret;
+}
+
+static void updn_delete(void *context)
+{
+ free(context);
+}
+
+int osm_ucast_updn_setup(struct osm_routing_engine *r, osm_opensm_t *osm)
+{
+ updn_t *updn;
+
+ updn = malloc(sizeof(updn_t));
+ if (!updn)
+ return -1;
+ memset(updn, 0, sizeof(updn_t));
+
+ updn->p_osm = osm;
+
+ r->context = updn;
+ r->destroy = updn_delete;
+ r->build_lid_matrices = updn_lid_matrices;
+
+ return 0;
+}
diff --git a/contrib/ofed/opensm/opensm/osm_vl15intf.c b/contrib/ofed/opensm/opensm/osm_vl15intf.c
new file mode 100644
index 0000000..06a5001
--- /dev/null
+++ b/contrib/ofed/opensm/opensm/osm_vl15intf.c
@@ -0,0 +1,401 @@
+/*
+ * Copyright (c) 2009 Sun Microsystems, Inc. All rights reserved.
+ * Copyright (c) 2004-2009 Voltaire, Inc. All rights reserved.
+ * Copyright (c) 2002-2010 Mellanox Technologies LTD. All rights reserved.
+ * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+/*
+ * Abstract:
+ * Implementation of osm_vl15_t.
+ * This object represents the VL15 Interface object.
+ * This object is part of the opensm family of objects.
+ */
+
+#if HAVE_CONFIG_H
+# include <config.h>
+#endif /* HAVE_CONFIG_H */
+
+#include <string.h>
+#include <iba/ib_types.h>
+#include <complib/cl_thread.h>
+#include <opensm/osm_file_ids.h>
+#define FILE_ID OSM_FILE_VL15INTF_C
+#include <vendor/osm_vendor_api.h>
+#include <opensm/osm_vl15intf.h>
+#include <opensm/osm_madw.h>
+#include <opensm/osm_log.h>
+#include <opensm/osm_helper.h>
+
+static void vl15_send_mad(osm_vl15_t * p_vl, osm_madw_t * p_madw)
+{
+ ib_api_status_t status;
+ boolean_t resp_expected = p_madw->resp_expected;
+ ib_smp_t * p_smp;
+ ib_net16_t attr_id;
+ uint8_t method;
+
+ p_smp = osm_madw_get_smp_ptr(p_madw);
+ method = p_smp->method;
+ attr_id = p_smp->attr_id;
+
+ /*
+ Non-response-expected mads are not throttled on the wire
+ since we can have no confirmation that they arrived
+ at their destination.
+ */
+ if (resp_expected)
+ /*
+ Note that other threads may not see the response MAD
+ arrive before send() even returns.
+ In that case, the wire count would temporarily go negative.
+ To avoid this confusion, preincrement the counts on the
+ assumption that send() will succeed.
+ */
+ cl_atomic_inc(&p_vl->p_stats->qp0_mads_outstanding_on_wire);
+ else
+ cl_atomic_inc(&p_vl->p_stats->qp0_unicasts_sent);
+
+ cl_atomic_inc(&p_vl->p_stats->qp0_mads_sent);
+
+ status = osm_vendor_send(osm_madw_get_bind_handle(p_madw),
+ p_madw, p_madw->resp_expected);
+
+ if (status == IB_SUCCESS) {
+ OSM_LOG(p_vl->p_log, OSM_LOG_DEBUG,
+ "%u QP0 MADs on wire, %u outstanding, "
+ "%u unicasts sent, %u total sent\n",
+ p_vl->p_stats->qp0_mads_outstanding_on_wire,
+ p_vl->p_stats->qp0_mads_outstanding,
+ p_vl->p_stats->qp0_unicasts_sent,
+ p_vl->p_stats->qp0_mads_sent);
+ return;
+ }
+
+ OSM_LOG(p_vl->p_log, OSM_LOG_ERROR, "ERR 3E03: "
+ "MAD send failed (%s)\n", ib_get_err_str(status));
+
+ /*
+ The MAD was never successfully sent, so
+ fix up the pre-incremented count values.
+ */
+
+ /* Decrement qp0_mads_sent that were incremented in the code above.
+ qp0_mads_outstanding will be decremented by send error callback
+ (called by osm_vendor_send() */
+ cl_atomic_dec(&p_vl->p_stats->qp0_mads_sent);
+ if (!resp_expected) {
+ cl_atomic_dec(&p_vl->p_stats->qp0_unicasts_sent);
+ return;
+ }
+
+ /* need to cause heavy-sweep if resp_expected MAD sending failed */
+ OSM_LOG(p_vl->p_log, OSM_LOG_ERROR, "ERR 3E04: "
+ "%s method failed for attribute 0x%X (%s)\n",
+ method == IB_MAD_METHOD_SET ? "SET" : "GET",
+ cl_ntoh16(attr_id), ib_get_sm_attr_str(attr_id));
+
+ p_vl->p_subn->subnet_initialization_error = TRUE;
+
+}
+
+static void vl15_poller(IN void *p_ptr)
+{
+ ib_api_status_t status;
+ osm_madw_t *p_madw;
+ osm_vl15_t *p_vl = p_ptr;
+ cl_qlist_t *p_fifo;
+ int32_t max_smps = p_vl->max_wire_smps;
+ int32_t max_smps2 = p_vl->max_wire_smps2;
+
+ OSM_LOG_ENTER(p_vl->p_log);
+
+ if (p_vl->thread_state == OSM_THREAD_STATE_NONE)
+ p_vl->thread_state = OSM_THREAD_STATE_RUN;
+
+ while (p_vl->thread_state == OSM_THREAD_STATE_RUN) {
+ /*
+ Start servicing the FIFOs by pulling off MAD wrappers
+ and passing them to the transport interface.
+ There are lots of corner cases here so tread carefully.
+
+ The unicast FIFO has priority, since somebody is waiting
+ for a timely response.
+ */
+ cl_spinlock_acquire(&p_vl->lock);
+
+ if (cl_qlist_count(&p_vl->ufifo) != 0)
+ p_fifo = &p_vl->ufifo;
+ else
+ p_fifo = &p_vl->rfifo;
+
+ p_madw = (osm_madw_t *) cl_qlist_remove_head(p_fifo);
+
+ cl_spinlock_release(&p_vl->lock);
+
+ if (p_madw != (osm_madw_t *) cl_qlist_end(p_fifo)) {
+ OSM_LOG(p_vl->p_log, OSM_LOG_DEBUG,
+ "Servicing p_madw = %p\n", p_madw);
+ if (OSM_LOG_IS_ACTIVE_V2(p_vl->p_log, OSM_LOG_FRAMES))
+ osm_dump_dr_smp_v2(p_vl->p_log,
+ osm_madw_get_smp_ptr(p_madw),
+ FILE_ID, OSM_LOG_FRAMES);
+
+ vl15_send_mad(p_vl, p_madw);
+ } else
+ /*
+ The VL15 FIFO is empty, so we have nothing left to do.
+ */
+ status = cl_event_wait_on(&p_vl->signal,
+ EVENT_NO_TIMEOUT, TRUE);
+
+ while (p_vl->p_stats->qp0_mads_outstanding_on_wire >= max_smps &&
+ p_vl->thread_state == OSM_THREAD_STATE_RUN) {
+ status = cl_event_wait_on(&p_vl->signal,
+ p_vl->max_smps_timeout,
+ TRUE);
+ if (status == CL_TIMEOUT) {
+ if (max_smps < max_smps2)
+ max_smps++;
+ break;
+ } else if (status != CL_SUCCESS) {
+ OSM_LOG(p_vl->p_log, OSM_LOG_ERROR, "ERR 3E02: "
+ "Event wait failed (%s)\n",
+ CL_STATUS_MSG(status));
+ break;
+ }
+ max_smps = p_vl->max_wire_smps;
+ }
+ }
+
+ /*
+ since we abort immediately when the state != OSM_THREAD_STATE_RUN
+ we might have some mads on the queues. After the thread exits
+ the vl15 destroy routine should put these mads back...
+ */
+
+ OSM_LOG_EXIT(p_vl->p_log);
+}
+
+void osm_vl15_construct(IN osm_vl15_t * p_vl)
+{
+ memset(p_vl, 0, sizeof(*p_vl));
+ p_vl->state = OSM_VL15_STATE_INIT;
+ p_vl->thread_state = OSM_THREAD_STATE_NONE;
+ cl_event_construct(&p_vl->signal);
+ cl_spinlock_construct(&p_vl->lock);
+ cl_qlist_init(&p_vl->rfifo);
+ cl_qlist_init(&p_vl->ufifo);
+ cl_thread_construct(&p_vl->poller);
+}
+
+void osm_vl15_destroy(IN osm_vl15_t * p_vl, IN struct osm_mad_pool *p_pool)
+{
+ osm_madw_t *p_madw;
+
+ OSM_LOG_ENTER(p_vl->p_log);
+
+ /*
+ Signal our threads that we're leaving.
+ */
+ p_vl->thread_state = OSM_THREAD_STATE_EXIT;
+
+ /*
+ Don't trigger unless event has been initialized.
+ Destroy the thread before we tear down the other objects.
+ */
+ if (p_vl->state != OSM_VL15_STATE_INIT)
+ cl_event_signal(&p_vl->signal);
+
+ cl_thread_destroy(&p_vl->poller);
+
+ /*
+ Return the outstanding messages to the pool
+ */
+
+ cl_spinlock_acquire(&p_vl->lock);
+
+ while (!cl_is_qlist_empty(&p_vl->rfifo)) {
+ p_madw = (osm_madw_t *) cl_qlist_remove_head(&p_vl->rfifo);
+ osm_mad_pool_put(p_pool, p_madw);
+ }
+ while (!cl_is_qlist_empty(&p_vl->ufifo)) {
+ p_madw = (osm_madw_t *) cl_qlist_remove_head(&p_vl->ufifo);
+ osm_mad_pool_put(p_pool, p_madw);
+ }
+
+ cl_spinlock_release(&p_vl->lock);
+
+ cl_event_destroy(&p_vl->signal);
+ p_vl->state = OSM_VL15_STATE_INIT;
+ cl_spinlock_destroy(&p_vl->lock);
+
+ OSM_LOG_EXIT(p_vl->p_log);
+}
+
+ib_api_status_t osm_vl15_init(IN osm_vl15_t * p_vl, IN osm_vendor_t * p_vend,
+ IN osm_log_t * p_log, IN osm_stats_t * p_stats,
+ IN osm_subn_t * p_subn,
+ IN int32_t max_wire_smps,
+ IN int32_t max_wire_smps2,
+ IN uint32_t max_smps_timeout)
+{
+ ib_api_status_t status = IB_SUCCESS;
+
+ OSM_LOG_ENTER(p_log);
+
+ p_vl->p_vend = p_vend;
+ p_vl->p_log = p_log;
+ p_vl->p_stats = p_stats;
+ p_vl->p_subn = p_subn;
+ p_vl->max_wire_smps = max_wire_smps;
+ p_vl->max_wire_smps2 = max_wire_smps2;
+ p_vl->max_smps_timeout = max_wire_smps < max_wire_smps2 ?
+ max_smps_timeout : EVENT_NO_TIMEOUT;
+
+ status = cl_event_init(&p_vl->signal, FALSE);
+ if (status != IB_SUCCESS)
+ goto Exit;
+
+ p_vl->state = OSM_VL15_STATE_READY;
+
+ status = cl_spinlock_init(&p_vl->lock);
+ if (status != IB_SUCCESS)
+ goto Exit;
+
+ /*
+ Initialize the thread after all other dependent objects
+ have been initialized.
+ */
+ status = cl_thread_init(&p_vl->poller, vl15_poller, p_vl,
+ "opensm poller");
+Exit:
+ OSM_LOG_EXIT(p_log);
+ return status;
+}
+
+void osm_vl15_poll(IN osm_vl15_t * p_vl)
+{
+ OSM_LOG_ENTER(p_vl->p_log);
+
+ CL_ASSERT(p_vl->state == OSM_VL15_STATE_READY);
+
+ /*
+ If we have room for more VL15 MADs on the wire,
+ then signal the poller thread.
+
+ This is not an airtight check, since the poller thread
+ could be just about to send another MAD as we signal
+ the event here. To cover this rare case, the poller
+ thread checks for a spurious wake-up.
+ */
+ if (p_vl->p_stats->qp0_mads_outstanding_on_wire <
+ (int32_t) p_vl->max_wire_smps) {
+ OSM_LOG(p_vl->p_log, OSM_LOG_DEBUG,
+ "Signalling poller thread\n");
+ cl_event_signal(&p_vl->signal);
+ }
+
+ OSM_LOG_EXIT(p_vl->p_log);
+}
+
+void osm_vl15_post(IN osm_vl15_t * p_vl, IN osm_madw_t * p_madw)
+{
+ OSM_LOG_ENTER(p_vl->p_log);
+
+ CL_ASSERT(p_vl->state == OSM_VL15_STATE_READY);
+
+ OSM_LOG(p_vl->p_log, OSM_LOG_DEBUG, "Posting p_madw = %p\n", p_madw);
+
+ /*
+ Determine in which fifo to place the pending madw.
+ */
+ cl_spinlock_acquire(&p_vl->lock);
+ if (p_madw->resp_expected == TRUE) {
+ cl_qlist_insert_tail(&p_vl->rfifo, &p_madw->list_item);
+ osm_stats_inc_qp0_outstanding(p_vl->p_stats);
+ } else
+ cl_qlist_insert_tail(&p_vl->ufifo, &p_madw->list_item);
+ cl_spinlock_release(&p_vl->lock);
+
+ OSM_LOG(p_vl->p_log, OSM_LOG_DEBUG,
+ "%u QP0 MADs on wire, %u QP0 MADs outstanding\n",
+ p_vl->p_stats->qp0_mads_outstanding_on_wire,
+ p_vl->p_stats->qp0_mads_outstanding);
+
+ osm_vl15_poll(p_vl);
+
+ OSM_LOG_EXIT(p_vl->p_log);
+}
+
+void osm_vl15_shutdown(IN osm_vl15_t * p_vl, IN osm_mad_pool_t * p_mad_pool)
+{
+ osm_madw_t *p_madw;
+
+ OSM_LOG_ENTER(p_vl->p_log);
+
+ /* we only should get here after the VL15 interface was initialized */
+ CL_ASSERT(p_vl->state == OSM_VL15_STATE_READY);
+
+ /* grab a lock on the object */
+ cl_spinlock_acquire(&p_vl->lock);
+
+ /* go over all outstanding MADs and retire their transactions */
+
+ /* first we handle the list of response MADs */
+ p_madw = (osm_madw_t *) cl_qlist_remove_head(&p_vl->ufifo);
+ while (p_madw != (osm_madw_t *) cl_qlist_end(&p_vl->ufifo)) {
+ OSM_LOG(p_vl->p_log, OSM_LOG_DEBUG,
+ "Releasing Response p_madw = %p\n", p_madw);
+
+ osm_mad_pool_put(p_mad_pool, p_madw);
+
+ p_madw = (osm_madw_t *) cl_qlist_remove_head(&p_vl->ufifo);
+ }
+
+ /* Request MADs we send out */
+ p_madw = (osm_madw_t *) cl_qlist_remove_head(&p_vl->rfifo);
+ while (p_madw != (osm_madw_t *) cl_qlist_end(&p_vl->rfifo)) {
+ OSM_LOG(p_vl->p_log, OSM_LOG_DEBUG,
+ "Releasing Request p_madw = %p\n", p_madw);
+
+ osm_mad_pool_put(p_mad_pool, p_madw);
+ osm_stats_dec_qp0_outstanding(p_vl->p_stats);
+
+ p_madw = (osm_madw_t *) cl_qlist_remove_head(&p_vl->rfifo);
+ }
+
+ /* free the lock */
+ cl_spinlock_release(&p_vl->lock);
+
+ OSM_LOG_EXIT(p_vl->p_log);
+}
diff --git a/contrib/ofed/opensm/opensm/osm_vl_arb_rcv.c b/contrib/ofed/opensm/opensm/osm_vl_arb_rcv.c
new file mode 100644
index 0000000..fe6b8c7
--- /dev/null
+++ b/contrib/ofed/opensm/opensm/osm_vl_arb_rcv.c
@@ -0,0 +1,161 @@
+/*
+ * Copyright (c) 2004-2009 Voltaire, Inc. All rights reserved.
+ * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved.
+ * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
+ * Copyright (c) 2010 HNR Consulting. All rights reserved.
+ * Copyright (c) 2010 Sun Microsystems, Inc. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+/*
+ * Abstract:
+ * Implementation of osm_vla_rcv_t.
+ * This object represents the Vl Arbitration Receiver object.
+ * This object is part of the opensm family of objects.
+ */
+
+#if HAVE_CONFIG_H
+# include <config.h>
+#endif /* HAVE_CONFIG_H */
+
+#include <string.h>
+#include <iba/ib_types.h>
+#include <complib/cl_passivelock.h>
+#include <complib/cl_debug.h>
+#include <opensm/osm_file_ids.h>
+#define FILE_ID OSM_FILE_VL_ARB_RCV_C
+#include <opensm/osm_madw.h>
+#include <opensm/osm_log.h>
+#include <opensm/osm_node.h>
+#include <opensm/osm_subnet.h>
+#include <opensm/osm_helper.h>
+#include <opensm/osm_sm.h>
+
+/*
+ * WE ONLY RECEIVE GET or SET responses
+ */
+void osm_vla_rcv_process(IN void *context, IN void *data)
+{
+ osm_sm_t *sm = context;
+ osm_madw_t *p_madw = data;
+ ib_vl_arb_table_t *p_vla_tbl;
+ ib_smp_t *p_smp;
+ osm_port_t *p_port;
+ osm_physp_t *p_physp;
+ osm_node_t *p_node;
+ osm_vla_context_t *p_context;
+ ib_net64_t port_guid;
+ ib_net64_t node_guid;
+ uint8_t port_num, block_num;
+
+ CL_ASSERT(sm);
+
+ OSM_LOG_ENTER(sm->p_log);
+
+ CL_ASSERT(p_madw);
+
+ p_smp = osm_madw_get_smp_ptr(p_madw);
+
+ p_context = osm_madw_get_vla_context_ptr(p_madw);
+ p_vla_tbl = ib_smp_get_payload_ptr(p_smp);
+
+ port_guid = p_context->port_guid;
+ node_guid = p_context->node_guid;
+
+ CL_ASSERT(p_smp->attr_id == IB_MAD_ATTR_VL_ARBITRATION);
+
+ if (ib_smp_get_status(p_smp)) {
+ OSM_LOG(sm->p_log, OSM_LOG_DEBUG,
+ "MAD status 0x%x received\n",
+ cl_ntoh16(ib_smp_get_status(p_smp)));
+ goto Exit2;
+ }
+
+ cl_plock_excl_acquire(sm->p_lock);
+ p_port = osm_get_port_by_guid(sm->p_subn, port_guid);
+ if (!p_port) {
+ OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR 3F06: "
+ "No port object for port with GUID 0x%" PRIx64
+ "\n\t\t\t\tfor parent node GUID 0x%" PRIx64
+ ", TID 0x%" PRIx64 "\n", cl_ntoh64(port_guid),
+ cl_ntoh64(node_guid), cl_ntoh64(p_smp->trans_id));
+ goto Exit;
+ }
+
+ p_node = p_port->p_node;
+ CL_ASSERT(p_node);
+
+ block_num = (uint8_t) (cl_ntoh32(p_smp->attr_mod) >> 16);
+ /* in case of a non switch node the attr modifier should be ignored */
+ if (osm_node_get_type(p_node) == IB_NODE_TYPE_SWITCH) {
+ port_num = (uint8_t) (cl_ntoh32(p_smp->attr_mod) & 0x000000FF);
+ p_physp = osm_node_get_physp_ptr(p_node, port_num);
+ } else {
+ p_physp = p_port->p_physp;
+ port_num = p_physp->port_num;
+ }
+
+ /*
+ We do not care if this is a result of a set or get -
+ all we want is to update the subnet.
+ */
+ OSM_LOG(sm->p_log, OSM_LOG_VERBOSE,
+ "Got GetResp(VLArb) block:%u port_num %u with GUID 0x%"
+ PRIx64 " for parent node GUID 0x%" PRIx64 ", TID 0x%"
+ PRIx64 "\n", block_num, port_num, cl_ntoh64(port_guid),
+ cl_ntoh64(node_guid), cl_ntoh64(p_smp->trans_id));
+
+ /*
+ Determine if we encountered a new Physical Port.
+ If so, Ignore it.
+ */
+ if (!p_physp) {
+ OSM_LOG(sm->p_log, OSM_LOG_ERROR,
+ "Got invalid port number %u\n", port_num);
+ goto Exit;
+ }
+
+ if ((block_num < 1) || (block_num > 4)) {
+ OSM_LOG(sm->p_log, OSM_LOG_ERROR,
+ "Got invalid block number 0x%X\n", block_num);
+ goto Exit;
+ }
+
+ osm_dump_vl_arb_table_v2(sm->p_log, port_guid, block_num, port_num,
+ p_vla_tbl, FILE_ID, OSM_LOG_DEBUG);
+ osm_physp_set_vla_tbl(p_physp, p_vla_tbl, block_num);
+
+Exit:
+ cl_plock_release(sm->p_lock);
+
+Exit2:
+ OSM_LOG_EXIT(sm->p_log);
+}
diff --git a/contrib/ofed/opensm/opensm/st.c b/contrib/ofed/opensm/opensm/st.c
new file mode 100644
index 0000000..c2ee014
--- /dev/null
+++ b/contrib/ofed/opensm/opensm/st.c
@@ -0,0 +1,591 @@
+/*
+ * Copyright (c) 2004-2006 Voltaire, Inc. All rights reserved.
+ * Copyright (c) 2002-2006 Mellanox Technologies LTD. All rights reserved.
+ * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+/* static char sccsid[] = "@(#) st.c 5.1 89/12/14 Crucible"; */
+
+#if HAVE_CONFIG_H
+# include <config.h>
+#endif /* HAVE_CONFIG_H */
+
+#include <stdio.h>
+#include <string.h>
+#include <opensm/osm_file_ids.h>
+#define FILE_ID OSM_FILE_ST_C
+#include <opensm/st.h>
+
+typedef struct st_table_entry st_table_entry;
+
+struct st_table_entry {
+ unsigned int hash;
+ st_data_t key;
+ st_data_t record;
+ st_table_entry *next;
+};
+
+#define ST_DEFAULT_MAX_DENSITY 5
+#define ST_DEFAULT_INIT_TABLE_SIZE 11
+
+/*
+ * DEFAULT_MAX_DENSITY is the default for the largest we allow the
+ * average number of items per bin before increasing the number of
+ * bins
+ *
+ * DEFAULT_INIT_TABLE_SIZE is the default for the number of bins
+ * allocated initially
+ *
+ */
+static int numcmp(void *, void *);
+static st_ptr_t numhash(void *);
+static struct st_hash_type type_numhash = {
+ numcmp,
+ numhash,
+};
+
+/* extern int strcmp(const char *, const char *); */
+static int strhash(const char *);
+
+static inline st_ptr_t st_strhash(void *key)
+{
+ return strhash((const char *)key);
+}
+
+static inline int st_strcmp(void *key1, void *key2)
+{
+ return strcmp((const char *)key1, (const char *)key2);
+}
+
+static struct st_hash_type type_strhash = {
+ st_strcmp,
+ st_strhash
+};
+
+#define xmalloc malloc
+#define xcalloc calloc
+#define xrealloc realloc
+#define xfree free
+
+static void rehash(st_table *);
+
+#define alloc(type) (type*)xmalloc(sizeof(type))
+#define Calloc(n,s) (char*)xcalloc((n), (s))
+
+#define EQUAL(table,x,y) ((x)==(y) || (*table->type->compare)(((void*)x),((void *)y)) == 0)
+
+#define do_hash(key,table) (unsigned int)(*(table)->type->hash)(((void*)key))
+#define do_hash_bin(key,table) (do_hash(key, table)%(table)->num_bins)
+
+/*
+ * MINSIZE is the minimum size of a dictionary.
+ */
+
+#define MINSIZE 8
+
+/*
+ Table of prime numbers 2^n+a, 2<=n<=30.
+*/
+static long primes[] = {
+ 8 + 3,
+ 16 + 3,
+ 32 + 5,
+ 64 + 3,
+ 128 + 3,
+ 256 + 27,
+ 512 + 9,
+ 1024 + 9,
+ 2048 + 5,
+ 4096 + 3,
+ 8192 + 27,
+ 16384 + 43,
+ 32768 + 3,
+ 65536 + 45,
+ 131072 + 29,
+ 262144 + 3,
+ 524288 + 21,
+ 1048576 + 7,
+ 2097152 + 17,
+ 4194304 + 15,
+ 8388608 + 9,
+ 16777216 + 43,
+ 33554432 + 35,
+ 67108864 + 15,
+ 134217728 + 29,
+ 268435456 + 3,
+ 536870912 + 11,
+ 1073741824 + 85,
+ 0
+};
+
+static int new_size(int size)
+{
+ int i;
+
+#if 0
+ for (i = 3; i < 31; i++) {
+ if ((1 << i) > size)
+ return 1 << i;
+ }
+ return -1;
+#else
+ int newsize;
+
+ for (i = 0, newsize = MINSIZE;
+ i < sizeof(primes) / sizeof(primes[0]); i++, newsize <<= 1) {
+ if (newsize > size)
+ return primes[i];
+ }
+ /* Ran out of polynomials */
+ return 0; /* should raise exception */
+#endif
+}
+
+#ifdef HASH_LOG
+static int collision = 0;
+static int init_st = 0;
+
+static void stat_col()
+{
+ FILE *f = fopen("/var/log/osm_st_col", "w");
+ fprintf(f, "collision: %d\n", collision);
+ fclose(f);
+}
+#endif
+
+st_table *st_init_table_with_size(type, size)
+struct st_hash_type *type;
+size_t size;
+{
+ st_table *tbl;
+
+#ifdef HASH_LOG
+ if (init_st == 0) {
+ init_st = 1;
+ atexit(stat_col);
+ }
+#endif
+
+ size = new_size(size); /* round up to prime number */
+ if (!size)
+ return NULL;
+
+ tbl = alloc(st_table);
+ tbl->type = type;
+ tbl->num_entries = 0;
+ tbl->num_bins = size;
+ tbl->bins = (st_table_entry **) Calloc(size, sizeof(st_table_entry *));
+
+ return tbl;
+}
+
+st_table *st_init_table(type)
+struct st_hash_type *type;
+{
+ return st_init_table_with_size(type, 0);
+}
+
+st_table *st_init_numtable(void)
+{
+ return st_init_table(&type_numhash);
+}
+
+st_table *st_init_numtable_with_size(size)
+size_t size;
+{
+ return st_init_table_with_size(&type_numhash, size);
+}
+
+st_table *st_init_strtable(void)
+{
+ return st_init_table(&type_strhash);
+}
+
+st_table *st_init_strtable_with_size(size)
+size_t size;
+{
+ return st_init_table_with_size(&type_strhash, size);
+}
+
+void st_free_table(table)
+st_table *table;
+{
+ register st_table_entry *ptr, *next;
+ int i;
+
+ for (i = 0; i < table->num_bins; i++) {
+ ptr = table->bins[i];
+ while (ptr != 0) {
+ next = ptr->next;
+ free(ptr);
+ ptr = next;
+ }
+ }
+ free(table->bins);
+ free(table);
+}
+
+#define PTR_NOT_EQUAL(table, ptr, hash_val, key) \
+((ptr) != 0 && (ptr->hash != (hash_val) || !EQUAL((table), (key), (ptr)->key)))
+
+#ifdef HASH_LOG
+#define COLLISION collision++
+#else
+#define COLLISION
+#endif
+
+#define FIND_ENTRY(table, ptr, hash_val, bin_pos) do {\
+ bin_pos = hash_val%(table)->num_bins;\
+ ptr = (table)->bins[bin_pos];\
+ if (PTR_NOT_EQUAL(table, ptr, hash_val, key)) \
+ {\
+ COLLISION;\
+ while (PTR_NOT_EQUAL(table, ptr->next, hash_val, key)) {\
+ ptr = ptr->next;\
+ }\
+ ptr = ptr->next;\
+ }\
+} while (0)
+
+int st_lookup(table, key, value)
+st_table *table;
+register st_data_t key;
+st_data_t *value;
+{
+ unsigned int hash_val, bin_pos;
+ register st_table_entry *ptr;
+
+ hash_val = do_hash(key, table);
+ FIND_ENTRY(table, ptr, hash_val, bin_pos);
+
+ if (ptr == 0) {
+ return 0;
+ } else {
+ if (value != 0)
+ *value = ptr->record;
+ return 1;
+ }
+}
+
+#define ADD_DIRECT(table, key, value, hash_val, bin_pos)\
+do {\
+ st_table_entry *entry;\
+ if (table->num_entries/(table->num_bins) > ST_DEFAULT_MAX_DENSITY) \
+ {\
+ rehash(table);\
+ bin_pos = hash_val % table->num_bins;\
+ }\
+ \
+ entry = alloc(st_table_entry);\
+ \
+ entry->hash = hash_val;\
+ entry->key = key;\
+ entry->record = value;\
+ entry->next = table->bins[bin_pos];\
+ table->bins[bin_pos] = entry;\
+ table->num_entries++;\
+} while (0);
+
+int st_insert(table, key, value)
+register st_table *table;
+register st_data_t key;
+st_data_t value;
+{
+ unsigned int hash_val, bin_pos;
+ register st_table_entry *ptr;
+
+ hash_val = do_hash(key, table);
+ FIND_ENTRY(table, ptr, hash_val, bin_pos);
+
+ if (ptr == 0) {
+ ADD_DIRECT(table, key, value, hash_val, bin_pos);
+ return 0;
+ } else {
+ ptr->record = value;
+ return 1;
+ }
+}
+
+void st_add_direct(table, key, value)
+st_table *table;
+st_data_t key;
+st_data_t value;
+{
+ unsigned int hash_val, bin_pos;
+
+ hash_val = do_hash(key, table);
+ bin_pos = hash_val % table->num_bins;
+ ADD_DIRECT(table, key, value, hash_val, bin_pos);
+}
+
+static void rehash(table)
+register st_table *table;
+{
+ register st_table_entry *ptr, *next, **new_bins;
+ int i, old_num_bins = table->num_bins, new_num_bins;
+ unsigned int hash_val;
+
+ new_num_bins = new_size(old_num_bins + 1);
+ if (!new_num_bins)
+ return;
+
+ new_bins =
+ (st_table_entry **) Calloc(new_num_bins, sizeof(st_table_entry *));
+
+ for (i = 0; i < old_num_bins; i++) {
+ ptr = table->bins[i];
+ while (ptr != 0) {
+ next = ptr->next;
+ hash_val = ptr->hash % new_num_bins;
+ ptr->next = new_bins[hash_val];
+ new_bins[hash_val] = ptr;
+ ptr = next;
+ }
+ }
+ free(table->bins);
+ table->num_bins = new_num_bins;
+ table->bins = new_bins;
+}
+
+st_table *st_copy(old_table)
+st_table *old_table;
+{
+ st_table *new_table;
+ st_table_entry *ptr, *entry;
+ size_t i, num_bins = old_table->num_bins;
+
+ new_table = alloc(st_table);
+ if (new_table == 0) {
+ return 0;
+ }
+
+ *new_table = *old_table;
+ new_table->bins = (st_table_entry **)
+ Calloc(num_bins, sizeof(st_table_entry *));
+
+ if (new_table->bins == 0) {
+ free(new_table);
+ return 0;
+ }
+
+ for (i = 0; i < num_bins; i++) {
+ new_table->bins[i] = 0;
+ ptr = old_table->bins[i];
+ while (ptr != 0) {
+ entry = alloc(st_table_entry);
+ if (entry == 0) {
+ free(new_table->bins);
+ free(new_table);
+ return 0;
+ }
+ *entry = *ptr;
+ entry->next = new_table->bins[i];
+ new_table->bins[i] = entry;
+ ptr = ptr->next;
+ }
+ }
+ return new_table;
+}
+
+int st_delete(table, key, value)
+register st_table *table;
+register st_data_t *key;
+st_data_t *value;
+{
+ unsigned int hash_val;
+ st_table_entry *tmp;
+ register st_table_entry *ptr;
+
+ hash_val = do_hash_bin(*key, table);
+ ptr = table->bins[hash_val];
+
+ if (ptr == 0) {
+ if (value != 0)
+ *value = 0;
+ return 0;
+ }
+
+ if (EQUAL(table, *key, ptr->key)) {
+ table->bins[hash_val] = ptr->next;
+ table->num_entries--;
+ if (value != 0)
+ *value = ptr->record;
+ *key = ptr->key;
+ free(ptr);
+ return 1;
+ }
+
+ for (; ptr->next != 0; ptr = ptr->next) {
+ if (EQUAL(table, ptr->next->key, *key)) {
+ tmp = ptr->next;
+ ptr->next = ptr->next->next;
+ table->num_entries--;
+ if (value != 0)
+ *value = tmp->record;
+ *key = tmp->key;
+ free(tmp);
+ return 1;
+ }
+ }
+
+ return 0;
+}
+
+int st_delete_safe(table, key, value, never)
+register st_table *table;
+register st_data_t *key;
+st_data_t *value;
+st_data_t never;
+{
+ unsigned int hash_val;
+ register st_table_entry *ptr;
+
+ hash_val = do_hash_bin(*key, table);
+ ptr = table->bins[hash_val];
+
+ if (ptr == 0) {
+ if (value != 0)
+ *value = 0;
+ return 0;
+ }
+
+ for (; ptr != 0; ptr = ptr->next) {
+ if ((ptr->key != never) && EQUAL(table, ptr->key, *key)) {
+ table->num_entries--;
+ *key = ptr->key;
+ if (value != 0)
+ *value = ptr->record;
+ ptr->key = ptr->record = never;
+ return 1;
+ }
+ }
+
+ return 0;
+}
+
+static int delete_never(st_data_t key, st_data_t value, st_data_t never)
+{
+ if (value == never)
+ return ST_DELETE;
+ return ST_CONTINUE;
+}
+
+void st_cleanup_safe(table, never)
+st_table *table;
+st_data_t never;
+{
+ int num_entries = table->num_entries;
+
+ st_foreach(table, delete_never, never);
+ table->num_entries = num_entries;
+}
+
+void st_foreach(table, func, arg)
+st_table *table;
+int (*func) (st_data_t key, st_data_t val, st_data_t arg);
+st_data_t arg;
+{
+ st_table_entry *ptr, *last, *tmp;
+ enum st_retval retval;
+ int i;
+
+ for (i = 0; i < table->num_bins; i++) {
+ last = 0;
+ for (ptr = table->bins[i]; ptr != 0;) {
+ retval = (*func) (ptr->key, ptr->record, arg);
+ switch (retval) {
+ case ST_CONTINUE:
+ last = ptr;
+ ptr = ptr->next;
+ break;
+ case ST_STOP:
+ return;
+ case ST_DELETE:
+ tmp = ptr;
+ if (last == 0) {
+ table->bins[i] = ptr->next;
+ } else {
+ last->next = ptr->next;
+ }
+ ptr = ptr->next;
+ free(tmp);
+ table->num_entries--;
+ }
+ }
+ }
+}
+
+static int strhash(string)
+register const char *string;
+{
+ register int c;
+
+#ifdef HASH_ELFHASH
+ register unsigned int h = 0, g;
+
+ while ((c = *string++) != '\0') {
+ h = (h << 4) + c;
+ if (g = h & 0xF0000000)
+ h ^= g >> 24;
+ h &= ~g;
+ }
+ return h;
+#elif HASH_PERL
+ register int val = 0;
+
+ while ((c = *string++) != '\0') {
+ val = val * 33 + c;
+ }
+
+ return val + (val >> 5);
+#else
+ register int val = 0;
+
+ while ((c = *string++) != '\0') {
+ val = val * 997 + c;
+ }
+
+ return val + (val >> 5);
+#endif
+}
+
+static int numcmp(x, y)
+void *x, *y;
+{
+ return (st_ptr_t) x != (st_ptr_t) y;
+}
+
+static st_ptr_t numhash(n)
+void *n;
+{
+ return (st_ptr_t) n;
+}
diff --git a/contrib/ofed/usr.bin/Makefile b/contrib/ofed/usr.bin/Makefile
index 2e133739..105ad821 100644
--- a/contrib/ofed/usr.bin/Makefile
+++ b/contrib/ofed/usr.bin/Makefile
@@ -1,12 +1,10 @@
-.include <src.opts.mk>
+# $FreeBSD$
-SUBDIR= ibaddr ibnetdiscover ibping ibportstate ibroute ibsendtrap ibstat \
- ibsysstat ibtracert opensm perfquery saquery \
- sminfo smpdump smpquery vendstat
-
-.if ${MK_TESTS} != "no"
-SUBDIR+= osmtest
-.endif
+SUBDIR= \
+../libibverbs/examples/build \
+../librdmacm/examples/build \
+../opensm/opensm \
+../infiniband-diags/build
SUBDIR_PARALLEL=
diff --git a/contrib/ofed/usr.bin/Makefile.inc b/contrib/ofed/usr.bin/Makefile.inc
deleted file mode 100644
index d05778c..0000000
--- a/contrib/ofed/usr.bin/Makefile.inc
+++ /dev/null
@@ -1,9 +0,0 @@
-DIAGPATH= ${.CURDIR}/../../management/infiniband-diags
-BINDIR?= /usr/bin
-CFLAGS+= -I${.CURDIR}/../../include/infiniband
-CFLAGS+= -I${.CURDIR}/../../include
-CFLAGS+= -I${.CURDIR}/../../management/opensm/include/
-CFLAGS+= -I${.CURDIR}/../../management/opensm
-CFLAGS+= -I${.CURDIR}/../../management/libibcommon/include
-CFLAGS+= -I${.CURDIR}/../../management/libibumad/include
-CFLAGS+= -I${.CURDIR}/../../management/libibmad/include
diff --git a/contrib/ofed/usr.bin/ibaddr/Makefile b/contrib/ofed/usr.bin/ibaddr/Makefile
deleted file mode 100644
index a50eefa..0000000
--- a/contrib/ofed/usr.bin/ibaddr/Makefile
+++ /dev/null
@@ -1,14 +0,0 @@
-# $FreeBSD$
-
-.include "../Makefile.inc"
-.PATH: ${DIAGPATH}/src ${DIAGPATH}/man
-
-PROG= ibaddr
-SRCS= ibaddr.c ibdiag_common.c
-LIBADD= ibmad
-CFLAGS+= -I${DIAGPATH}/include
-MAN= ibaddr.8
-
-WARNS?= 1
-
-.include <bsd.prog.mk>
diff --git a/contrib/ofed/usr.bin/ibaddr/Makefile.depend b/contrib/ofed/usr.bin/ibaddr/Makefile.depend
deleted file mode 100644
index 97ff2c9..0000000
--- a/contrib/ofed/usr.bin/ibaddr/Makefile.depend
+++ /dev/null
@@ -1,22 +0,0 @@
-# $FreeBSD$
-# Autogenerated - do NOT edit!
-
-DIRDEPS = \
- contrib/ofed/usr.lib/libibcommon \
- contrib/ofed/usr.lib/libibmad \
- contrib/ofed/usr.lib/libibumad \
- gnu/lib/csu \
- gnu/lib/libgcc \
- include \
- include/arpa \
- include/xlocale \
- lib/${CSU_DIR} \
- lib/libc \
- lib/libcompiler_rt \
-
-
-.include <dirdeps.mk>
-
-.if ${DEP_RELDIR} == ${_DEP_RELDIR}
-# local dependencies - needed for -jN in clean tree
-.endif
diff --git a/contrib/ofed/usr.bin/ibnetdiscover/Makefile b/contrib/ofed/usr.bin/ibnetdiscover/Makefile
deleted file mode 100644
index e724341..0000000
--- a/contrib/ofed/usr.bin/ibnetdiscover/Makefile
+++ /dev/null
@@ -1,14 +0,0 @@
-# $FreeBSD$
-
-.include "../Makefile.inc"
-.PATH: ${DIAGPATH}/src ${DIAGPATH}/man
-
-PROG= ibnetdiscover
-SRCS= ibnetdiscover.c grouping.c ibdiag_common.c
-LIBADD= ibumad ibcommon ibmad osmcomp
-CFLAGS+= -I${DIAGPATH}/include
-MAN= ibnetdiscover.8
-
-WARNS?= 1
-
-.include <bsd.prog.mk>
diff --git a/contrib/ofed/usr.bin/ibnetdiscover/Makefile.depend b/contrib/ofed/usr.bin/ibnetdiscover/Makefile.depend
deleted file mode 100644
index a4dafaf..0000000
--- a/contrib/ofed/usr.bin/ibnetdiscover/Makefile.depend
+++ /dev/null
@@ -1,23 +0,0 @@
-# $FreeBSD$
-# Autogenerated - do NOT edit!
-
-DIRDEPS = \
- contrib/ofed/usr.lib/libibcommon \
- contrib/ofed/usr.lib/libibmad \
- contrib/ofed/usr.lib/libibumad \
- contrib/ofed/usr.lib/libosmcomp \
- gnu/lib/csu \
- gnu/lib/libgcc \
- include \
- include/xlocale \
- lib/${CSU_DIR} \
- lib/libc \
- lib/libcompiler_rt \
- lib/libthr \
-
-
-.include <dirdeps.mk>
-
-.if ${DEP_RELDIR} == ${_DEP_RELDIR}
-# local dependencies - needed for -jN in clean tree
-.endif
diff --git a/contrib/ofed/usr.bin/ibping/Makefile b/contrib/ofed/usr.bin/ibping/Makefile
deleted file mode 100644
index 55ceca8..0000000
--- a/contrib/ofed/usr.bin/ibping/Makefile
+++ /dev/null
@@ -1,14 +0,0 @@
-# $FreeBSD$
-
-.include "../Makefile.inc"
-.PATH: ${DIAGPATH}/src ${DIAGPATH}/man
-
-PROG= ibping
-SRCS= ibping.c ibdiag_common.c
-LIBADD= ibumad ibcommon ibmad
-CFLAGS+= -I${DIAGPATH}/include
-MAN= ibping.8
-
-WARNS?= 1
-
-.include <bsd.prog.mk>
diff --git a/contrib/ofed/usr.bin/ibping/Makefile.depend b/contrib/ofed/usr.bin/ibping/Makefile.depend
deleted file mode 100644
index b1cc1b0..0000000
--- a/contrib/ofed/usr.bin/ibping/Makefile.depend
+++ /dev/null
@@ -1,21 +0,0 @@
-# $FreeBSD$
-# Autogenerated - do NOT edit!
-
-DIRDEPS = \
- contrib/ofed/usr.lib/libibcommon \
- contrib/ofed/usr.lib/libibmad \
- contrib/ofed/usr.lib/libibumad \
- gnu/lib/csu \
- gnu/lib/libgcc \
- include \
- include/xlocale \
- lib/${CSU_DIR} \
- lib/libc \
- lib/libcompiler_rt \
-
-
-.include <dirdeps.mk>
-
-.if ${DEP_RELDIR} == ${_DEP_RELDIR}
-# local dependencies - needed for -jN in clean tree
-.endif
diff --git a/contrib/ofed/usr.bin/ibportstate/Makefile b/contrib/ofed/usr.bin/ibportstate/Makefile
deleted file mode 100644
index feaced2..0000000
--- a/contrib/ofed/usr.bin/ibportstate/Makefile
+++ /dev/null
@@ -1,14 +0,0 @@
-# $FreeBSD$
-
-.include "../Makefile.inc"
-.PATH: ${DIAGPATH}/src ${DIAGPATH}/man
-
-PROG= ibportstate
-SRCS= ibportstate.c ibdiag_common.c
-LIBADD= ibumad ibcommon ibmad
-CFLAGS+= -I${DIAGPATH}/include
-MAN= ibportstate.8
-
-WARNS?= 1
-
-.include <bsd.prog.mk>
diff --git a/contrib/ofed/usr.bin/ibportstate/Makefile.depend b/contrib/ofed/usr.bin/ibportstate/Makefile.depend
deleted file mode 100644
index b1cc1b0..0000000
--- a/contrib/ofed/usr.bin/ibportstate/Makefile.depend
+++ /dev/null
@@ -1,21 +0,0 @@
-# $FreeBSD$
-# Autogenerated - do NOT edit!
-
-DIRDEPS = \
- contrib/ofed/usr.lib/libibcommon \
- contrib/ofed/usr.lib/libibmad \
- contrib/ofed/usr.lib/libibumad \
- gnu/lib/csu \
- gnu/lib/libgcc \
- include \
- include/xlocale \
- lib/${CSU_DIR} \
- lib/libc \
- lib/libcompiler_rt \
-
-
-.include <dirdeps.mk>
-
-.if ${DEP_RELDIR} == ${_DEP_RELDIR}
-# local dependencies - needed for -jN in clean tree
-.endif
diff --git a/contrib/ofed/usr.bin/ibroute/Makefile b/contrib/ofed/usr.bin/ibroute/Makefile
deleted file mode 100644
index bac5194..0000000
--- a/contrib/ofed/usr.bin/ibroute/Makefile
+++ /dev/null
@@ -1,14 +0,0 @@
-# $FreeBSD$
-
-.include "../Makefile.inc"
-.PATH: ${DIAGPATH}/src ${DIAGPATH}/man
-
-PROG= ibroute
-SRCS= ibroute.c ibdiag_common.c
-LIBADD= ibcommon ibmad osmcomp
-CFLAGS+= -I${DIAGPATH}/include
-MAN= ibroute.8
-
-WARNS?= 1
-
-.include <bsd.prog.mk>
diff --git a/contrib/ofed/usr.bin/ibroute/Makefile.depend b/contrib/ofed/usr.bin/ibroute/Makefile.depend
deleted file mode 100644
index a4dafaf..0000000
--- a/contrib/ofed/usr.bin/ibroute/Makefile.depend
+++ /dev/null
@@ -1,23 +0,0 @@
-# $FreeBSD$
-# Autogenerated - do NOT edit!
-
-DIRDEPS = \
- contrib/ofed/usr.lib/libibcommon \
- contrib/ofed/usr.lib/libibmad \
- contrib/ofed/usr.lib/libibumad \
- contrib/ofed/usr.lib/libosmcomp \
- gnu/lib/csu \
- gnu/lib/libgcc \
- include \
- include/xlocale \
- lib/${CSU_DIR} \
- lib/libc \
- lib/libcompiler_rt \
- lib/libthr \
-
-
-.include <dirdeps.mk>
-
-.if ${DEP_RELDIR} == ${_DEP_RELDIR}
-# local dependencies - needed for -jN in clean tree
-.endif
diff --git a/contrib/ofed/usr.bin/ibsendtrap/Makefile b/contrib/ofed/usr.bin/ibsendtrap/Makefile
deleted file mode 100644
index 8f94722..0000000
--- a/contrib/ofed/usr.bin/ibsendtrap/Makefile
+++ /dev/null
@@ -1,14 +0,0 @@
-# $FreeBSD$
-
-.include "../Makefile.inc"
-.PATH: ${DIAGPATH}/src ${DIAGPATH}/man
-
-PROG= ibsendtrap
-SRCS= ibsendtrap.c ibdiag_common.c
-LIBADD= ibmad
-CFLAGS+= -I${DIAGPATH}/include
-MAN=
-
-WARNS?= 1
-
-.include <bsd.prog.mk>
diff --git a/contrib/ofed/usr.bin/ibsendtrap/Makefile.depend b/contrib/ofed/usr.bin/ibsendtrap/Makefile.depend
deleted file mode 100644
index b1cc1b0..0000000
--- a/contrib/ofed/usr.bin/ibsendtrap/Makefile.depend
+++ /dev/null
@@ -1,21 +0,0 @@
-# $FreeBSD$
-# Autogenerated - do NOT edit!
-
-DIRDEPS = \
- contrib/ofed/usr.lib/libibcommon \
- contrib/ofed/usr.lib/libibmad \
- contrib/ofed/usr.lib/libibumad \
- gnu/lib/csu \
- gnu/lib/libgcc \
- include \
- include/xlocale \
- lib/${CSU_DIR} \
- lib/libc \
- lib/libcompiler_rt \
-
-
-.include <dirdeps.mk>
-
-.if ${DEP_RELDIR} == ${_DEP_RELDIR}
-# local dependencies - needed for -jN in clean tree
-.endif
diff --git a/contrib/ofed/usr.bin/ibstat/Makefile b/contrib/ofed/usr.bin/ibstat/Makefile
deleted file mode 100644
index 652cc68..0000000
--- a/contrib/ofed/usr.bin/ibstat/Makefile
+++ /dev/null
@@ -1,14 +0,0 @@
-# $FreeBSD$
-
-.include "../Makefile.inc"
-.PATH: ${DIAGPATH}/src ${DIAGPATH}/man
-
-PROG= ibstat
-SRCS= ibstat.c
-LIBADD= ibumad ibcommon
-CFLAGS+= -I${DIAGPATH}/include
-MAN= ibstat.8
-
-WARNS?= 1
-
-.include <bsd.prog.mk>
diff --git a/contrib/ofed/usr.bin/ibstat/Makefile.depend b/contrib/ofed/usr.bin/ibstat/Makefile.depend
deleted file mode 100644
index dfd9052..0000000
--- a/contrib/ofed/usr.bin/ibstat/Makefile.depend
+++ /dev/null
@@ -1,20 +0,0 @@
-# $FreeBSD$
-# Autogenerated - do NOT edit!
-
-DIRDEPS = \
- contrib/ofed/usr.lib/libibcommon \
- contrib/ofed/usr.lib/libibumad \
- gnu/lib/csu \
- gnu/lib/libgcc \
- include \
- include/xlocale \
- lib/${CSU_DIR} \
- lib/libc \
- lib/libcompiler_rt \
-
-
-.include <dirdeps.mk>
-
-.if ${DEP_RELDIR} == ${_DEP_RELDIR}
-# local dependencies - needed for -jN in clean tree
-.endif
diff --git a/contrib/ofed/usr.bin/ibsysstat/Makefile b/contrib/ofed/usr.bin/ibsysstat/Makefile
deleted file mode 100644
index 52fec8d..0000000
--- a/contrib/ofed/usr.bin/ibsysstat/Makefile
+++ /dev/null
@@ -1,14 +0,0 @@
-# $FreeBSD$
-
-.include "../Makefile.inc"
-.PATH: ${DIAGPATH}/src ${DIAGPATH}/man
-
-PROG= ibsysstat
-SRCS= ibsysstat.c ibdiag_common.c
-LIBADD= ibumad ibcommon ibmad
-CFLAGS+= -I${DIAGPATH}/include
-MAN= ibsysstat.8
-
-WARNS?= 1
-
-.include <bsd.prog.mk>
diff --git a/contrib/ofed/usr.bin/ibsysstat/Makefile.depend b/contrib/ofed/usr.bin/ibsysstat/Makefile.depend
deleted file mode 100644
index b1cc1b0..0000000
--- a/contrib/ofed/usr.bin/ibsysstat/Makefile.depend
+++ /dev/null
@@ -1,21 +0,0 @@
-# $FreeBSD$
-# Autogenerated - do NOT edit!
-
-DIRDEPS = \
- contrib/ofed/usr.lib/libibcommon \
- contrib/ofed/usr.lib/libibmad \
- contrib/ofed/usr.lib/libibumad \
- gnu/lib/csu \
- gnu/lib/libgcc \
- include \
- include/xlocale \
- lib/${CSU_DIR} \
- lib/libc \
- lib/libcompiler_rt \
-
-
-.include <dirdeps.mk>
-
-.if ${DEP_RELDIR} == ${_DEP_RELDIR}
-# local dependencies - needed for -jN in clean tree
-.endif
diff --git a/contrib/ofed/usr.bin/ibtracert/Makefile b/contrib/ofed/usr.bin/ibtracert/Makefile
deleted file mode 100644
index 821966f..0000000
--- a/contrib/ofed/usr.bin/ibtracert/Makefile
+++ /dev/null
@@ -1,14 +0,0 @@
-# $FreeBSD$
-
-.include "../Makefile.inc"
-.PATH: ${DIAGPATH}/src ${DIAGPATH}/man
-
-PROG= ibtracert
-SRCS= ibtracert.c ibdiag_common.c
-LIBADD= ibumad ibcommon ibmad osmcomp
-CFLAGS+= -I${DIAGPATH}/include
-MAN= ibtracert.8
-
-WARNS?= 1
-
-.include <bsd.prog.mk>
diff --git a/contrib/ofed/usr.bin/ibtracert/Makefile.depend b/contrib/ofed/usr.bin/ibtracert/Makefile.depend
deleted file mode 100644
index a4dafaf..0000000
--- a/contrib/ofed/usr.bin/ibtracert/Makefile.depend
+++ /dev/null
@@ -1,23 +0,0 @@
-# $FreeBSD$
-# Autogenerated - do NOT edit!
-
-DIRDEPS = \
- contrib/ofed/usr.lib/libibcommon \
- contrib/ofed/usr.lib/libibmad \
- contrib/ofed/usr.lib/libibumad \
- contrib/ofed/usr.lib/libosmcomp \
- gnu/lib/csu \
- gnu/lib/libgcc \
- include \
- include/xlocale \
- lib/${CSU_DIR} \
- lib/libc \
- lib/libcompiler_rt \
- lib/libthr \
-
-
-.include <dirdeps.mk>
-
-.if ${DEP_RELDIR} == ${_DEP_RELDIR}
-# local dependencies - needed for -jN in clean tree
-.endif
diff --git a/contrib/ofed/usr.bin/opensm/Makefile b/contrib/ofed/usr.bin/opensm/Makefile
deleted file mode 100644
index 5b0bcb0..0000000
--- a/contrib/ofed/usr.bin/opensm/Makefile
+++ /dev/null
@@ -1,39 +0,0 @@
-# $FreeBSD$
-
-.include "../Makefile.inc"
-
-OPENSM = ${.CURDIR}/../../management/opensm
-.PATH: ${OPENSM}/opensm ${OPENSM}/man
-
-PROG= opensm
-
-SRCS= main.c osm_console_io.c osm_console.c osm_db_files.c
-SRCS+= osm_db_pack.c osm_drop_mgr.c osm_inform.c osm_lid_mgr.c
-SRCS+= osm_lin_fwd_rcv.c osm_link_mgr.c osm_mcast_fwd_rcv.c osm_mcast_mgr.c
-SRCS+= osm_mcast_tbl.c osm_mcm_info.c osm_mcm_port.c osm_mtree.c
-SRCS+= osm_multicast.c osm_node.c osm_node_desc_rcv.c osm_node_info_rcv.c
-SRCS+= osm_opensm.c osm_pkey.c osm_pkey_mgr.c osm_pkey_rcv.c osm_port.c
-SRCS+= osm_port_info_rcv.c osm_remote_sm.c osm_req.c osm_resp.c osm_sa.c
-SRCS+= osm_sa_class_port_info.c osm_sa_informinfo.c osm_sa_lft_record.c
-SRCS+= osm_sa_mft_record.c osm_sa_link_record.c osm_sa_mad_ctrl.c
-SRCS+= osm_sa_mcmember_record.c osm_sa_node_record.c osm_sa_path_record.c
-SRCS+= osm_sa_pkey_record.c osm_sa_portinfo_record.c osm_sa_guidinfo_record.c
-SRCS+= osm_sa_multipath_record.c osm_sa_service_record.c osm_sa_slvl_record.c
-SRCS+= osm_sa_sminfo_record.c osm_sa_vlarb_record.c osm_sa_sw_info_record.c
-SRCS+= osm_service.c osm_slvl_map_rcv.c osm_sm.c osm_sminfo_rcv.c
-SRCS+= osm_sm_mad_ctrl.c osm_sm_state_mgr.c osm_state_mgr.c osm_subnet.c
-SRCS+= osm_sw_info_rcv.c osm_switch.c osm_prtn.c osm_prtn_config.c osm_qos.c
-SRCS+= osm_router.c osm_trap_rcv.c osm_ucast_mgr.c osm_ucast_updn.c
-SRCS+= osm_ucast_lash.c osm_ucast_file.c osm_ucast_ftree.c osm_vl15intf.c
-SRCS+= osm_vl_arb_rcv.c st.c osm_perfmgr.c osm_perfmgr_db.c osm_event_plugin.c
-SRCS+= osm_dump.c osm_ucast_cache.c osm_qos_parser_y.y osm_qos_parser_l.l
-SRCS+= osm_qos_policy.c
-
-LIBADD= opensm osmvendor osmcomp pthread
-CFLAGS+= -DVENDOR_RMPP_SUPPORT -DDUAL_SIDED_RMPP
-
-MAN= opensm.8
-
-WARNS?= 1
-
-.include <bsd.prog.mk>
diff --git a/contrib/ofed/usr.bin/opensm/Makefile.depend b/contrib/ofed/usr.bin/opensm/Makefile.depend
deleted file mode 100644
index 797b43b..0000000
--- a/contrib/ofed/usr.bin/opensm/Makefile.depend
+++ /dev/null
@@ -1,26 +0,0 @@
-# $FreeBSD$
-# Autogenerated - do NOT edit!
-
-DIRDEPS = \
- contrib/ofed/usr.lib/libibcommon \
- contrib/ofed/usr.lib/libibumad \
- contrib/ofed/usr.lib/libopensm \
- contrib/ofed/usr.lib/libosmcomp \
- contrib/ofed/usr.lib/libosmvendor \
- gnu/lib/csu \
- gnu/lib/libgcc \
- include \
- include/arpa \
- include/xlocale \
- lib/${CSU_DIR} \
- lib/libc \
- lib/libcompiler_rt \
- lib/libthr \
- usr.bin/yacc.host \
-
-
-.include <dirdeps.mk>
-
-.if ${DEP_RELDIR} == ${_DEP_RELDIR}
-# local dependencies - needed for -jN in clean tree
-.endif
diff --git a/contrib/ofed/usr.bin/osmtest/Makefile b/contrib/ofed/usr.bin/osmtest/Makefile
deleted file mode 100644
index 0330b2e..0000000
--- a/contrib/ofed/usr.bin/osmtest/Makefile
+++ /dev/null
@@ -1,28 +0,0 @@
-# $FreeBSD$
-
-.include "../Makefile.inc"
-
-OPENSM= ${.CURDIR}/../../management/opensm
-.PATH: ${OPENSM}/osmtest ${OPENSM}/man
-
-BINDIR= ${TESTSBASE}/usr.bin/opensm
-PROG= osmtest
-
-SRCS= main.c \
- osmt_inform.c \
- osmt_mtl_regular_qp.c \
- osmt_multicast.c \
- osmt_service.c \
- osmt_slvl_vl_arb.c \
- osmtest.c
-
-LIBADD= ibcommon ibmad ibumad osmvendor osmcomp opensm pthread
-
-CFLAGS= -DVENDOR_RMPP_SUPPORT -DDUAL_SIDED_RMPP \
- -I${OPENSM}/osmtest/include
-
-MAN= osmtest.8
-
-WARNS?= 1
-
-.include <bsd.prog.mk>
diff --git a/contrib/ofed/usr.bin/osmtest/Makefile.depend b/contrib/ofed/usr.bin/osmtest/Makefile.depend
deleted file mode 100644
index 1f2ff13..0000000
--- a/contrib/ofed/usr.bin/osmtest/Makefile.depend
+++ /dev/null
@@ -1,26 +0,0 @@
-# $FreeBSD$
-# Autogenerated - do NOT edit!
-
-DIRDEPS = \
- contrib/ofed/usr.lib/libibcommon \
- contrib/ofed/usr.lib/libibmad \
- contrib/ofed/usr.lib/libibumad \
- contrib/ofed/usr.lib/libopensm \
- contrib/ofed/usr.lib/libosmcomp \
- contrib/ofed/usr.lib/libosmvendor \
- gnu/lib/csu \
- gnu/lib/libgcc \
- include \
- include/arpa \
- include/xlocale \
- lib/${CSU_DIR} \
- lib/libc \
- lib/libcompiler_rt \
- lib/libthr \
-
-
-.include <dirdeps.mk>
-
-.if ${DEP_RELDIR} == ${_DEP_RELDIR}
-# local dependencies - needed for -jN in clean tree
-.endif
diff --git a/contrib/ofed/usr.bin/perfquery/Makefile b/contrib/ofed/usr.bin/perfquery/Makefile
deleted file mode 100644
index ba337e1..0000000
--- a/contrib/ofed/usr.bin/perfquery/Makefile
+++ /dev/null
@@ -1,14 +0,0 @@
-# $FreeBSD$
-
-.include "../Makefile.inc"
-.PATH: ${DIAGPATH}/src ${DIAGPATH}/man
-
-PROG= perfquery
-SRCS= perfquery.c ibdiag_common.c
-LIBADD= ibumad ibcommon ibmad
-CFLAGS+= -I${DIAGPATH}/include
-MAN= perfquery.8
-
-WARNS?= 1
-
-.include <bsd.prog.mk>
diff --git a/contrib/ofed/usr.bin/perfquery/Makefile.depend b/contrib/ofed/usr.bin/perfquery/Makefile.depend
deleted file mode 100644
index b1cc1b0..0000000
--- a/contrib/ofed/usr.bin/perfquery/Makefile.depend
+++ /dev/null
@@ -1,21 +0,0 @@
-# $FreeBSD$
-# Autogenerated - do NOT edit!
-
-DIRDEPS = \
- contrib/ofed/usr.lib/libibcommon \
- contrib/ofed/usr.lib/libibmad \
- contrib/ofed/usr.lib/libibumad \
- gnu/lib/csu \
- gnu/lib/libgcc \
- include \
- include/xlocale \
- lib/${CSU_DIR} \
- lib/libc \
- lib/libcompiler_rt \
-
-
-.include <dirdeps.mk>
-
-.if ${DEP_RELDIR} == ${_DEP_RELDIR}
-# local dependencies - needed for -jN in clean tree
-.endif
diff --git a/contrib/ofed/usr.bin/saquery/Makefile b/contrib/ofed/usr.bin/saquery/Makefile
deleted file mode 100644
index 2155748..0000000
--- a/contrib/ofed/usr.bin/saquery/Makefile
+++ /dev/null
@@ -1,15 +0,0 @@
-# $FreeBSD$
-
-.include "../Makefile.inc"
-.PATH: ${DIAGPATH}/src ${DIAGPATH}/man
-
-PROG= saquery
-SRCS= saquery.c ibdiag_common.c
-LIBADD= ibmad osmcomp osmvendor opensm
-CFLAGS+= -I${DIAGPATH}/include
-CFLAGS+= -DOSM_VENDOR_INTF_OPENIB -DVENDOR_RMPP_SUPPORT -DDUAL_SIDED_RMPP
-MAN= saquery.8
-
-WARNS?= 1
-
-.include <bsd.prog.mk>
diff --git a/contrib/ofed/usr.bin/saquery/Makefile.depend b/contrib/ofed/usr.bin/saquery/Makefile.depend
deleted file mode 100644
index 1f2ff13..0000000
--- a/contrib/ofed/usr.bin/saquery/Makefile.depend
+++ /dev/null
@@ -1,26 +0,0 @@
-# $FreeBSD$
-# Autogenerated - do NOT edit!
-
-DIRDEPS = \
- contrib/ofed/usr.lib/libibcommon \
- contrib/ofed/usr.lib/libibmad \
- contrib/ofed/usr.lib/libibumad \
- contrib/ofed/usr.lib/libopensm \
- contrib/ofed/usr.lib/libosmcomp \
- contrib/ofed/usr.lib/libosmvendor \
- gnu/lib/csu \
- gnu/lib/libgcc \
- include \
- include/arpa \
- include/xlocale \
- lib/${CSU_DIR} \
- lib/libc \
- lib/libcompiler_rt \
- lib/libthr \
-
-
-.include <dirdeps.mk>
-
-.if ${DEP_RELDIR} == ${_DEP_RELDIR}
-# local dependencies - needed for -jN in clean tree
-.endif
diff --git a/contrib/ofed/usr.bin/sminfo/Makefile b/contrib/ofed/usr.bin/sminfo/Makefile
deleted file mode 100644
index 72e930d..0000000
--- a/contrib/ofed/usr.bin/sminfo/Makefile
+++ /dev/null
@@ -1,14 +0,0 @@
-# $FreeBSD$
-
-.include "../Makefile.inc"
-.PATH: ${DIAGPATH}/src ${DIAGPATH}/man
-
-PROG= sminfo
-SRCS= sminfo.c ibdiag_common.c
-LIBADD= ibumad ibmad
-CFLAGS+= -I${DIAGPATH}/include
-MAN= sminfo.8
-
-WARNS?= 1
-
-.include <bsd.prog.mk>
diff --git a/contrib/ofed/usr.bin/sminfo/Makefile.depend b/contrib/ofed/usr.bin/sminfo/Makefile.depend
deleted file mode 100644
index b1cc1b0..0000000
--- a/contrib/ofed/usr.bin/sminfo/Makefile.depend
+++ /dev/null
@@ -1,21 +0,0 @@
-# $FreeBSD$
-# Autogenerated - do NOT edit!
-
-DIRDEPS = \
- contrib/ofed/usr.lib/libibcommon \
- contrib/ofed/usr.lib/libibmad \
- contrib/ofed/usr.lib/libibumad \
- gnu/lib/csu \
- gnu/lib/libgcc \
- include \
- include/xlocale \
- lib/${CSU_DIR} \
- lib/libc \
- lib/libcompiler_rt \
-
-
-.include <dirdeps.mk>
-
-.if ${DEP_RELDIR} == ${_DEP_RELDIR}
-# local dependencies - needed for -jN in clean tree
-.endif
diff --git a/contrib/ofed/usr.bin/smpdump/Makefile b/contrib/ofed/usr.bin/smpdump/Makefile
deleted file mode 100644
index e9258a5..0000000
--- a/contrib/ofed/usr.bin/smpdump/Makefile
+++ /dev/null
@@ -1,14 +0,0 @@
-# $FreeBSD$
-
-.include "../Makefile.inc"
-.PATH: ${DIAGPATH}/src ${DIAGPATH}/man
-
-PROG= smpdump
-SRCS= smpdump.c
-LIBADD= ibumad ibcommon ibmad
-CFLAGS+= -I${DIAGPATH}/include
-MAN= smpdump.8
-
-WARNS?= 1
-
-.include <bsd.prog.mk>
diff --git a/contrib/ofed/usr.bin/smpdump/Makefile.depend b/contrib/ofed/usr.bin/smpdump/Makefile.depend
deleted file mode 100644
index b1cc1b0..0000000
--- a/contrib/ofed/usr.bin/smpdump/Makefile.depend
+++ /dev/null
@@ -1,21 +0,0 @@
-# $FreeBSD$
-# Autogenerated - do NOT edit!
-
-DIRDEPS = \
- contrib/ofed/usr.lib/libibcommon \
- contrib/ofed/usr.lib/libibmad \
- contrib/ofed/usr.lib/libibumad \
- gnu/lib/csu \
- gnu/lib/libgcc \
- include \
- include/xlocale \
- lib/${CSU_DIR} \
- lib/libc \
- lib/libcompiler_rt \
-
-
-.include <dirdeps.mk>
-
-.if ${DEP_RELDIR} == ${_DEP_RELDIR}
-# local dependencies - needed for -jN in clean tree
-.endif
diff --git a/contrib/ofed/usr.bin/smpquery/Makefile b/contrib/ofed/usr.bin/smpquery/Makefile
deleted file mode 100644
index 01acbe2..0000000
--- a/contrib/ofed/usr.bin/smpquery/Makefile
+++ /dev/null
@@ -1,14 +0,0 @@
-# $FreeBSD$
-
-.include "../Makefile.inc"
-.PATH: ${DIAGPATH}/src ${DIAGPATH}/man
-
-PROG= smpquery
-SRCS= smpquery.c ibdiag_common.c
-LIBADD= ibumad ibmad osmcomp
-CFLAGS+= -I${DIAGPATH}/include
-MAN= smpquery.8
-
-WARNS?= 1
-
-.include <bsd.prog.mk>
diff --git a/contrib/ofed/usr.bin/smpquery/Makefile.depend b/contrib/ofed/usr.bin/smpquery/Makefile.depend
deleted file mode 100644
index a4dafaf..0000000
--- a/contrib/ofed/usr.bin/smpquery/Makefile.depend
+++ /dev/null
@@ -1,23 +0,0 @@
-# $FreeBSD$
-# Autogenerated - do NOT edit!
-
-DIRDEPS = \
- contrib/ofed/usr.lib/libibcommon \
- contrib/ofed/usr.lib/libibmad \
- contrib/ofed/usr.lib/libibumad \
- contrib/ofed/usr.lib/libosmcomp \
- gnu/lib/csu \
- gnu/lib/libgcc \
- include \
- include/xlocale \
- lib/${CSU_DIR} \
- lib/libc \
- lib/libcompiler_rt \
- lib/libthr \
-
-
-.include <dirdeps.mk>
-
-.if ${DEP_RELDIR} == ${_DEP_RELDIR}
-# local dependencies - needed for -jN in clean tree
-.endif
diff --git a/contrib/ofed/usr.bin/vendstat/Makefile b/contrib/ofed/usr.bin/vendstat/Makefile
deleted file mode 100644
index 48cda6b..0000000
--- a/contrib/ofed/usr.bin/vendstat/Makefile
+++ /dev/null
@@ -1,14 +0,0 @@
-# $FreeBSD$
-
-.include "../Makefile.inc"
-.PATH: ${DIAGPATH}/src ${DIAGPATH}/man
-
-PROG= vendstat
-SRCS= vendstat.c ibdiag_common.c
-LIBADD= ibumad ibmad
-CFLAGS+= -I${DIAGPATH}/include
-MAN= vendstat.8
-
-WARNS?= 1
-
-.include <bsd.prog.mk>
diff --git a/contrib/ofed/usr.bin/vendstat/Makefile.depend b/contrib/ofed/usr.bin/vendstat/Makefile.depend
deleted file mode 100644
index b1cc1b0..0000000
--- a/contrib/ofed/usr.bin/vendstat/Makefile.depend
+++ /dev/null
@@ -1,21 +0,0 @@
-# $FreeBSD$
-# Autogenerated - do NOT edit!
-
-DIRDEPS = \
- contrib/ofed/usr.lib/libibcommon \
- contrib/ofed/usr.lib/libibmad \
- contrib/ofed/usr.lib/libibumad \
- gnu/lib/csu \
- gnu/lib/libgcc \
- include \
- include/xlocale \
- lib/${CSU_DIR} \
- lib/libc \
- lib/libcompiler_rt \
-
-
-.include <dirdeps.mk>
-
-.if ${DEP_RELDIR} == ${_DEP_RELDIR}
-# local dependencies - needed for -jN in clean tree
-.endif
diff --git a/contrib/ofed/usr.lib/0/Makefile b/contrib/ofed/usr.lib/0/Makefile
new file mode 100644
index 0000000..2f7360a
--- /dev/null
+++ b/contrib/ofed/usr.lib/0/Makefile
@@ -0,0 +1,8 @@
+# $FreeBSD$
+
+SUBDIR= \
+../../libibverbs
+
+SUBDIR_PARALLEL=
+
+.include <bsd.subdir.mk>
diff --git a/contrib/ofed/usr.lib/1/Makefile b/contrib/ofed/usr.lib/1/Makefile
new file mode 100644
index 0000000..3203cc9
--- /dev/null
+++ b/contrib/ofed/usr.lib/1/Makefile
@@ -0,0 +1,9 @@
+# $FreeBSD$
+
+SUBDIR= \
+../../libibcm \
+../../libibumad
+
+SUBDIR_PARALLEL=
+
+.include <bsd.subdir.mk>
diff --git a/contrib/ofed/usr.lib/2/Makefile b/contrib/ofed/usr.lib/2/Makefile
new file mode 100644
index 0000000..bc865b1
--- /dev/null
+++ b/contrib/ofed/usr.lib/2/Makefile
@@ -0,0 +1,14 @@
+# $FreeBSD$
+
+SUBDIR= \
+../../librdmacm \
+../../libibmad \
+../../opensm/complib \
+../../opensm/libvendor \
+../../libcxgb4 \
+../../libmlx4 \
+../../libmlx5
+
+SUBDIR_PARALLEL=
+
+.include <bsd.subdir.mk>
diff --git a/contrib/ofed/usr.lib/3/Makefile b/contrib/ofed/usr.lib/3/Makefile
new file mode 100644
index 0000000..c512a03
--- /dev/null
+++ b/contrib/ofed/usr.lib/3/Makefile
@@ -0,0 +1,9 @@
+# $FreeBSD$
+
+SUBDIR= \
+../../libibnetdisc \
+../../opensm/libopensm
+
+SUBDIR_PARALLEL=
+
+.include <bsd.subdir.mk>
diff --git a/contrib/ofed/usr.lib/Makefile b/contrib/ofed/usr.lib/Makefile
index 47b9759..6481b405 100644
--- a/contrib/ofed/usr.lib/Makefile
+++ b/contrib/ofed/usr.lib/Makefile
@@ -1,14 +1,8 @@
-SUBDIR= libibcommon libibmad libibumad libibverbs libmlx4 libmthca \
- libopensm libosmcomp libosmvendor libibcm librdmacm libsdp libcxgb4
+# $FreeBSD$
-SUBDIR_DEPEND_libcxgb4= libibverbs
-SUBDIR_DEPEND_libibcm= libibverbs
-SUBDIR_DEPEND_libibmad= libibcommon libibumad
-SUBDIR_DEPEND_libibumad= libibcommon
-SUBDIR_DEPEND_libmlx4= libibverbs
-SUBDIR_DEPEND_libmthca= libibverbs
-SUBDIR_DEPEND_libosmvendor= libibumad libopensm libosmcomp
-SUBDIR_DEPEND_librdmacm= libibverbs
-SUBDIR_PARALLEL=
+# NOTE: If building outside the buildworld target, install each subdirectory
+# before building the next one.
+
+SUBDIR=0 1 2 3
.include <bsd.subdir.mk>
diff --git a/contrib/ofed/usr.lib/Makefile.inc b/contrib/ofed/usr.lib/Makefile.inc
deleted file mode 100644
index e48285dc..0000000
--- a/contrib/ofed/usr.lib/Makefile.inc
+++ /dev/null
@@ -1,24 +0,0 @@
-IBMGMT= ${.CURDIR}/../../management
-IBCOMMONDIR= ${IBMGMT}/libibcommon
-IBMADDIR= ${IBMGMT}/libibmad
-UMADDIR= ${IBMGMT}/libibumad
-OPENSMDIR= ${IBMGMT}/opensm
-COMPLIBDIR= ${OPENSMDIR}/complib
-VENDORLIBDIR= ${OPENSMDIR}/libvendor
-IBVERBSDIR= ${.CURDIR}/../../libibverbs
-IBINC= ${.CURDIR}/../../include
-RDMACMDIR= ${.CURDIR}/../../librdmacm
-
-CFLAGS+= -I${.CURDIR} \
- -I${IBINC}/infiniband \
- -I${IBINC} \
- -I${IBCOMMONDIR}/include/infiniband \
- -I${IBCOMMONDIR}/include \
- -I${IBMADDIR}/include/infiniband \
- -I${IBMADDIR}/include \
- -I${UMADDIR}/include/infiniband \
- -I${UMADDIR}/include \
- -I${OPENSMDIR}/include \
- -I${RDMACMDIR}/include \
- -I${IBVERBSDIR}/include
-
diff --git a/contrib/ofed/usr.lib/libcxgb4/Makefile b/contrib/ofed/usr.lib/libcxgb4/Makefile
deleted file mode 100644
index 3c75043..0000000
--- a/contrib/ofed/usr.lib/libcxgb4/Makefile
+++ /dev/null
@@ -1,25 +0,0 @@
-# $FreeBSD$
-
-SHLIBDIR?= /usr/lib
-
-.include <bsd.own.mk>
-
-CXGB4DIR= ${.CURDIR}/../../libcxgb4
-IBVERBSDIR= ${.CURDIR}/../../libibverbs
-CXGBSRCDIR= ${CXGB4DIR}/src
-
-.PATH: ${CXGBSRCDIR}
-
-LIB= cxgb4
-SHLIB_MAJOR= 1
-MK_PROFILE= no
-
-SRCS= dev.c cq.c qp.c verbs.c
-
-LIBADD= ibverbs pthread
-CFLAGS+= -g -DHAVE_CONFIG_H -DDEBUG
-CFLAGS+= -I${.CURDIR} -I${CXGBSRCDIR} -I${IBVERBSDIR}/include
-
-VERSION_MAP= ${CXGBSRCDIR}/cxgb4.map
-
-.include <bsd.lib.mk>
diff --git a/contrib/ofed/usr.lib/libcxgb4/Makefile.depend b/contrib/ofed/usr.lib/libcxgb4/Makefile.depend
deleted file mode 100644
index 7bb3c2d..0000000
--- a/contrib/ofed/usr.lib/libcxgb4/Makefile.depend
+++ /dev/null
@@ -1,21 +0,0 @@
-# $FreeBSD$
-# Autogenerated - do NOT edit!
-
-DIRDEPS = \
- contrib/ofed/usr.lib/libibverbs \
- gnu/lib/csu \
- gnu/lib/libgcc \
- include \
- include/arpa \
- include/xlocale \
- lib/${CSU_DIR} \
- lib/libc \
- lib/libcompiler_rt \
- lib/libthr \
-
-
-.include <dirdeps.mk>
-
-.if ${DEP_RELDIR} == ${_DEP_RELDIR}
-# local dependencies - needed for -jN in clean tree
-.endif
diff --git a/contrib/ofed/usr.lib/libcxgb4/config.h b/contrib/ofed/usr.lib/libcxgb4/config.h
deleted file mode 100644
index a235013..0000000
--- a/contrib/ofed/usr.lib/libcxgb4/config.h
+++ /dev/null
@@ -1,4 +0,0 @@
-#define HAVE_IBV_DONTFORK_RANGE
-#define HAVE_IBV_DOFORK_RANGE
-#define HAVE_IBV_REGISTER_DRIVER
-#define HAVE_IBV_READ_SYSFS_FILE
diff --git a/contrib/ofed/usr.lib/libibcm/Makefile b/contrib/ofed/usr.lib/libibcm/Makefile
deleted file mode 100644
index 5f895d0..0000000
--- a/contrib/ofed/usr.lib/libibcm/Makefile
+++ /dev/null
@@ -1,24 +0,0 @@
-# $FreeBSD$
-
-SHLIBDIR?= /usr/lib
-
-.include <bsd.own.mk>
-.include "../Makefile.inc"
-
-IBCMDIR= ${.CURDIR}/../../libibcm
-IBSRCDIR= ${IBCMDIR}/src
-
-.PATH: ${IBSRCDIR}
-
-LIB= ibcm
-SHLIB_MAJOR= 1
-MK_PROFILE= no
-
-SRCS= cm.c
-LIBADD= ibverbs
-CFLAGS+= -I${IBCMDIR}/include
-
-MAN=
-VERSION_MAP= ${IBSRCDIR}/libibcm.map
-
-.include <bsd.lib.mk>
diff --git a/contrib/ofed/usr.lib/libibcm/Makefile.depend b/contrib/ofed/usr.lib/libibcm/Makefile.depend
deleted file mode 100644
index e8013ca..0000000
--- a/contrib/ofed/usr.lib/libibcm/Makefile.depend
+++ /dev/null
@@ -1,19 +0,0 @@
-# $FreeBSD$
-# Autogenerated - do NOT edit!
-
-DIRDEPS = \
- contrib/ofed/usr.lib/libibverbs \
- gnu/lib/csu \
- gnu/lib/libgcc \
- include \
- include/xlocale \
- lib/${CSU_DIR} \
- lib/libc \
- lib/libcompiler_rt \
-
-
-.include <dirdeps.mk>
-
-.if ${DEP_RELDIR} == ${_DEP_RELDIR}
-# local dependencies - needed for -jN in clean tree
-.endif
diff --git a/contrib/ofed/usr.lib/libibcommon/Makefile b/contrib/ofed/usr.lib/libibcommon/Makefile
deleted file mode 100644
index daa1f42..0000000
--- a/contrib/ofed/usr.lib/libibcommon/Makefile
+++ /dev/null
@@ -1,20 +0,0 @@
-# $FreeBSD$
-
-SHLIBDIR?= /usr/lib
-
-.include <bsd.own.mk>
-.include "../Makefile.inc"
-
-IBSRCDIR= ${IBCOMMONDIR}/src
-
-.PATH: ${IBSRCDIR}
-
-LIB= ibcommon
-SHLIB_MAJOR= 1
-MK_PROFILE= no
-
-SRCS= sysfs.c util.c hash.c stack.c time.c
-
-VERSION_MAP= ${IBSRCDIR}/libibcommon.map
-
-.include <bsd.lib.mk>
diff --git a/contrib/ofed/usr.lib/libibcommon/Makefile.depend b/contrib/ofed/usr.lib/libibcommon/Makefile.depend
deleted file mode 100644
index 3646e2e..0000000
--- a/contrib/ofed/usr.lib/libibcommon/Makefile.depend
+++ /dev/null
@@ -1,18 +0,0 @@
-# $FreeBSD$
-# Autogenerated - do NOT edit!
-
-DIRDEPS = \
- gnu/lib/csu \
- gnu/lib/libgcc \
- include \
- include/xlocale \
- lib/${CSU_DIR} \
- lib/libc \
- lib/libcompiler_rt \
-
-
-.include <dirdeps.mk>
-
-.if ${DEP_RELDIR} == ${_DEP_RELDIR}
-# local dependencies - needed for -jN in clean tree
-.endif
diff --git a/contrib/ofed/usr.lib/libibmad/Makefile b/contrib/ofed/usr.lib/libibmad/Makefile
deleted file mode 100644
index 4ccdb4f..0000000
--- a/contrib/ofed/usr.lib/libibmad/Makefile
+++ /dev/null
@@ -1,24 +0,0 @@
-# $FreeBSD$
-
-SHLIBDIR?= /usr/lib
-
-.include <bsd.own.mk>
-.include "../Makefile.inc"
-
-IBSRCDIR= ${IBMADDIR}/src
-
-.PATH: ${IBSRCDIR}
-
-LIB= ibmad
-SHLIB_MAJOR= 1
-MK_PROFILE= no
-
-SRCS= dump.c fields.c gs.c mad.c portid.c register.c resolve.c rpc.c sa.c \
- serv.c smp.c vendor.c
-
-LIBADD= ibcommon ibumad
-CFLAGS+= -DHAVE_CONFIG_H
-
-VERSION_MAP= ${IBSRCDIR}/libibmad.map
-
-.include <bsd.lib.mk>
diff --git a/contrib/ofed/usr.lib/libibmad/Makefile.depend b/contrib/ofed/usr.lib/libibmad/Makefile.depend
deleted file mode 100644
index a32fbc9..0000000
--- a/contrib/ofed/usr.lib/libibmad/Makefile.depend
+++ /dev/null
@@ -1,21 +0,0 @@
-# $FreeBSD$
-# Autogenerated - do NOT edit!
-
-DIRDEPS = \
- contrib/ofed/usr.lib/libibcommon \
- contrib/ofed/usr.lib/libibumad \
- gnu/lib/csu \
- gnu/lib/libgcc \
- include \
- include/arpa \
- include/xlocale \
- lib/${CSU_DIR} \
- lib/libc \
- lib/libcompiler_rt \
-
-
-.include <dirdeps.mk>
-
-.if ${DEP_RELDIR} == ${_DEP_RELDIR}
-# local dependencies - needed for -jN in clean tree
-.endif
diff --git a/contrib/ofed/usr.lib/libibmad/config.h b/contrib/ofed/usr.lib/libibmad/config.h
deleted file mode 100644
index dc979c0..0000000
--- a/contrib/ofed/usr.lib/libibmad/config.h
+++ /dev/null
@@ -1 +0,0 @@
-#include <sys/socket.h>
diff --git a/contrib/ofed/usr.lib/libibumad/Makefile b/contrib/ofed/usr.lib/libibumad/Makefile
deleted file mode 100644
index daa12c0..0000000
--- a/contrib/ofed/usr.lib/libibumad/Makefile
+++ /dev/null
@@ -1,23 +0,0 @@
-# $FreeBSD$
-
-SHLIBDIR?= /usr/lib
-
-.include <bsd.own.mk>
-.include "../Makefile.inc"
-
-IBSRCDIR= ${UMADDIR}/src
-
-.PATH: ${IBSRCDIR}
-
-LIB= ibumad
-SHLIB_MAJOR= 1
-MK_PROFILE= no
-
-SRCS= umad.c
-
-LIBADD= ibcommon
-CFLAGS+= -DHAVE_CONFIG_H
-
-VERSION_MAP= ${IBSRCDIR}/libibumad.map
-
-.include <bsd.lib.mk>
diff --git a/contrib/ofed/usr.lib/libibumad/Makefile.depend b/contrib/ofed/usr.lib/libibumad/Makefile.depend
deleted file mode 100644
index d8b158b..0000000
--- a/contrib/ofed/usr.lib/libibumad/Makefile.depend
+++ /dev/null
@@ -1,19 +0,0 @@
-# $FreeBSD$
-# Autogenerated - do NOT edit!
-
-DIRDEPS = \
- contrib/ofed/usr.lib/libibcommon \
- gnu/lib/csu \
- gnu/lib/libgcc \
- include \
- include/xlocale \
- lib/${CSU_DIR} \
- lib/libc \
- lib/libcompiler_rt \
-
-
-.include <dirdeps.mk>
-
-.if ${DEP_RELDIR} == ${_DEP_RELDIR}
-# local dependencies - needed for -jN in clean tree
-.endif
diff --git a/contrib/ofed/usr.lib/libibumad/config.h b/contrib/ofed/usr.lib/libibumad/config.h
deleted file mode 100644
index dc979c0..0000000
--- a/contrib/ofed/usr.lib/libibumad/config.h
+++ /dev/null
@@ -1 +0,0 @@
-#include <sys/socket.h>
diff --git a/contrib/ofed/usr.lib/libibverbs/Makefile b/contrib/ofed/usr.lib/libibverbs/Makefile
deleted file mode 100644
index b8f73ba..0000000
--- a/contrib/ofed/usr.lib/libibverbs/Makefile
+++ /dev/null
@@ -1,39 +0,0 @@
-# $FreeBSD$
-
-SHLIBDIR?= /usr/lib
-
-.include <bsd.own.mk>
-.include "../Makefile.inc"
-
-IBSRCDIR= ${IBVERBSDIR}/src
-IBMANDIR= ${IBVERBSDIR}/man
-
-.PATH: ${IBSRCDIR} ${IBMANDIR}
-
-LIB= ibverbs
-SHLIB_MAJOR= 1
-MK_PROFILE= no
-
-SRCS= device.c init.c marshall.c verbs.c cmd.c enum_strs.c kern_abi.h \
- memory.c compat-1_0.c sysfs.c
-
-MAN= ibv_alloc_pd.3 ibv_asyncwatch.1 ibv_attach_mcast.3 ibv_create_ah.3 \
- ibv_create_ah_from_wc.3 ibv_create_comp_channel.3 ibv_create_cq.3 \
- ibv_create_qp.3 ibv_create_srq.3 ibv_devices.1 ibv_devinfo.1 \
- ibv_event_type_str.3 ibv_fork_init.3 ibv_get_async_event.3 \
- ibv_get_cq_event.3 ibv_get_device_guid.3 ibv_get_device_list.3 \
- ibv_get_device_name.3 ibv_modify_qp.3 ibv_modify_srq.3 \
- ibv_open_device.3 ibv_poll_cq.3 ibv_post_recv.3 ibv_post_send.3 \
- ibv_post_srq_recv.3 ibv_query_device.3 ibv_query_gid.3 \
- ibv_query_pkey.3 ibv_query_port.3 ibv_query_qp.3 ibv_query_srq.3 \
- ibv_rate_to_mult.3 ibv_rc_pingpong.1 ibv_reg_mr.3 ibv_req_notify_cq.3 \
- ibv_resize_cq.3 ibv_srq_pingpong.1 ibv_uc_pingpong.1 ibv_ud_pingpong.1 \
- ibv_query_xrc_rcv_qp.3 ibv_reg_xrc_rcv_qp.3 ibv_modify_xrc_rcv_qp.3 \
- verbs.7 ibv_create_xrc_rcv_qp.3 ibv_open_xrc_domain.3
-
-
-CFLAGS+= -DHAVE_CONFIG_H -DIBV_CONFIG_DIR=\"/etc/ibverbs/\"
-
-VERSION_MAP= ${IBSRCDIR}/libibverbs.map
-
-.include <bsd.lib.mk>
diff --git a/contrib/ofed/usr.lib/libibverbs/Makefile.depend b/contrib/ofed/usr.lib/libibverbs/Makefile.depend
deleted file mode 100644
index 3646e2e..0000000
--- a/contrib/ofed/usr.lib/libibverbs/Makefile.depend
+++ /dev/null
@@ -1,18 +0,0 @@
-# $FreeBSD$
-# Autogenerated - do NOT edit!
-
-DIRDEPS = \
- gnu/lib/csu \
- gnu/lib/libgcc \
- include \
- include/xlocale \
- lib/${CSU_DIR} \
- lib/libc \
- lib/libcompiler_rt \
-
-
-.include <dirdeps.mk>
-
-.if ${DEP_RELDIR} == ${_DEP_RELDIR}
-# local dependencies - needed for -jN in clean tree
-.endif
diff --git a/contrib/ofed/usr.lib/libibverbs/config.h b/contrib/ofed/usr.lib/libibverbs/config.h
deleted file mode 100644
index 688ab16..0000000
--- a/contrib/ofed/usr.lib/libibverbs/config.h
+++ /dev/null
@@ -1,2 +0,0 @@
-#define _WITH_GETLINE
-#include <alloca.h>
diff --git a/contrib/ofed/usr.lib/libmlx4/Makefile b/contrib/ofed/usr.lib/libmlx4/Makefile
deleted file mode 100644
index b4adc4c..0000000
--- a/contrib/ofed/usr.lib/libmlx4/Makefile
+++ /dev/null
@@ -1,25 +0,0 @@
-# $FreeBSD$
-
-SHLIBDIR?= /usr/lib
-
-.include <bsd.own.mk>
-
-MLX4DIR= ${.CURDIR}/../../libmlx4
-IBVERBSDIR= ${.CURDIR}/../../libibverbs
-MLXSRCDIR= ${MLX4DIR}/src
-
-.PATH: ${MLXSRCDIR}
-
-LIB= mlx4
-SHLIB_MAJOR= 1
-MK_PROFILE= no
-
-SRCS= buf.c cq.c dbrec.c mlx4.c qp.c srq.c verbs.c
-
-LIBADD= ibverbs pthread
-CFLAGS+= -DHAVE_CONFIG_H
-CFLAGS+= -I${.CURDIR} -I${MLXSRCDIR} -I${IBVERBSDIR}/include
-
-VERSION_MAP= ${MLXSRCDIR}/mlx4.map
-
-.include <bsd.lib.mk>
diff --git a/contrib/ofed/usr.lib/libmlx4/Makefile.depend b/contrib/ofed/usr.lib/libmlx4/Makefile.depend
deleted file mode 100644
index 9a8a2fe..0000000
--- a/contrib/ofed/usr.lib/libmlx4/Makefile.depend
+++ /dev/null
@@ -1,20 +0,0 @@
-# $FreeBSD$
-# Autogenerated - do NOT edit!
-
-DIRDEPS = \
- contrib/ofed/usr.lib/libibverbs \
- gnu/lib/csu \
- gnu/lib/libgcc \
- include \
- include/xlocale \
- lib/${CSU_DIR} \
- lib/libc \
- lib/libcompiler_rt \
- lib/libthr \
-
-
-.include <dirdeps.mk>
-
-.if ${DEP_RELDIR} == ${_DEP_RELDIR}
-# local dependencies - needed for -jN in clean tree
-.endif
diff --git a/contrib/ofed/usr.lib/libmlx4/config.h b/contrib/ofed/usr.lib/libmlx4/config.h
deleted file mode 100644
index a235013..0000000
--- a/contrib/ofed/usr.lib/libmlx4/config.h
+++ /dev/null
@@ -1,4 +0,0 @@
-#define HAVE_IBV_DONTFORK_RANGE
-#define HAVE_IBV_DOFORK_RANGE
-#define HAVE_IBV_REGISTER_DRIVER
-#define HAVE_IBV_READ_SYSFS_FILE
diff --git a/contrib/ofed/usr.lib/libmthca/Makefile b/contrib/ofed/usr.lib/libmthca/Makefile
deleted file mode 100644
index d81d7cd..0000000
--- a/contrib/ofed/usr.lib/libmthca/Makefile
+++ /dev/null
@@ -1,25 +0,0 @@
-# $FreeBSD$
-
-SHLIBDIR?= /usr/lib
-
-.include <bsd.own.mk>
-
-MTHCADIR= ${.CURDIR}/../../libmthca
-IBVERBSDIR= ${.CURDIR}/../../libibverbs
-MTHCASRCDIR= ${MTHCADIR}/src
-
-.PATH: ${MTHCASRCDIR}
-
-LIB= mthca
-SHLIB_MAJOR= 1
-MK_PROFILE= no
-
-SRCS= ah.c buf.c cq.c memfree.c mthca.c qp.c srq.c verbs.c
-
-LIBADD= ibverbs pthread
-CFLAGS+= -DHAVE_CONFIG_H
-CFLAGS+= -I${.CURDIR} -I${MTHCASRCDIR} -I${IBVERBSDIR}/include
-
-VERSION_MAP= ${MTHCASRCDIR}/mthca.map
-
-.include <bsd.lib.mk>
diff --git a/contrib/ofed/usr.lib/libmthca/Makefile.depend b/contrib/ofed/usr.lib/libmthca/Makefile.depend
deleted file mode 100644
index 9a8a2fe..0000000
--- a/contrib/ofed/usr.lib/libmthca/Makefile.depend
+++ /dev/null
@@ -1,20 +0,0 @@
-# $FreeBSD$
-# Autogenerated - do NOT edit!
-
-DIRDEPS = \
- contrib/ofed/usr.lib/libibverbs \
- gnu/lib/csu \
- gnu/lib/libgcc \
- include \
- include/xlocale \
- lib/${CSU_DIR} \
- lib/libc \
- lib/libcompiler_rt \
- lib/libthr \
-
-
-.include <dirdeps.mk>
-
-.if ${DEP_RELDIR} == ${_DEP_RELDIR}
-# local dependencies - needed for -jN in clean tree
-.endif
diff --git a/contrib/ofed/usr.lib/libmthca/config.h b/contrib/ofed/usr.lib/libmthca/config.h
deleted file mode 100644
index 564ebef..0000000
--- a/contrib/ofed/usr.lib/libmthca/config.h
+++ /dev/null
@@ -1,9 +0,0 @@
-#define HAVE_IBV_DONTFORK_RANGE
-#define HAVE_IBV_DOFORK_RANGE
-#define HAVE_IBV_REGISTER_DRIVER
-#define HAVE_IBV_READ_SYSFS_FILE
-#ifdef __LP64__
-#define SIZEOF_LONG 8
-#else
-#define SIZEOF_LONG 4
-#endif
diff --git a/contrib/ofed/usr.lib/libopensm/Makefile b/contrib/ofed/usr.lib/libopensm/Makefile
deleted file mode 100644
index a1c6002..0000000
--- a/contrib/ofed/usr.lib/libopensm/Makefile
+++ /dev/null
@@ -1,20 +0,0 @@
-# $FreeBSD$
-
-SHLIBDIR?= /usr/lib
-
-.include <bsd.own.mk>
-.include "../Makefile.inc"
-
-.PATH: ${OPENSMDIR}/opensm
-
-LIB= opensm
-SHLIB_MAJOR= 1
-MK_PROFILE= no
-
-SRCS= osm_log.c osm_mad_pool.c osm_helper.c
-
-LIBADD= pthread
-
-VERSION_MAP= ${OPENSMDIR}/opensm/libopensm.map
-
-.include <bsd.lib.mk>
diff --git a/contrib/ofed/usr.lib/libopensm/Makefile.depend b/contrib/ofed/usr.lib/libopensm/Makefile.depend
deleted file mode 100644
index 2337568..0000000
--- a/contrib/ofed/usr.lib/libopensm/Makefile.depend
+++ /dev/null
@@ -1,20 +0,0 @@
-# $FreeBSD$
-# Autogenerated - do NOT edit!
-
-DIRDEPS = \
- gnu/lib/csu \
- gnu/lib/libgcc \
- include \
- include/arpa \
- include/xlocale \
- lib/${CSU_DIR} \
- lib/libc \
- lib/libcompiler_rt \
- lib/libthr \
-
-
-.include <dirdeps.mk>
-
-.if ${DEP_RELDIR} == ${_DEP_RELDIR}
-# local dependencies - needed for -jN in clean tree
-.endif
diff --git a/contrib/ofed/usr.lib/libosmcomp/Makefile b/contrib/ofed/usr.lib/libosmcomp/Makefile
deleted file mode 100644
index 1d06830..0000000
--- a/contrib/ofed/usr.lib/libosmcomp/Makefile
+++ /dev/null
@@ -1,23 +0,0 @@
-# $FreeBSD$
-
-SHLIBDIR?= /usr/lib
-
-.include <bsd.own.mk>
-.include "../Makefile.inc"
-
-.PATH: ${COMPLIBDIR}
-
-LIB= osmcomp
-SHLIB_MAJOR= 1
-MK_PROFILE= no
-
-SRCS= cl_complib.c cl_dispatcher.c cl_event.c cl_event_wheel.c cl_list.c
-SRCS+= cl_log.c cl_map.c cl_pool.c cl_ptr_vector.c cl_spinlock.c
-SRCS+= cl_statustext.c cl_thread.c cl_threadpool.c cl_timer.c cl_vector.c
-SRCS+= ib_statustext.c cl_nodenamemap.c
-
-LIBADD= pthread
-
-VERSION_MAP= ${COMPLIBDIR}/libosmcomp.map
-
-.include <bsd.lib.mk>
diff --git a/contrib/ofed/usr.lib/libosmcomp/Makefile.depend b/contrib/ofed/usr.lib/libosmcomp/Makefile.depend
deleted file mode 100644
index 8caf187..0000000
--- a/contrib/ofed/usr.lib/libosmcomp/Makefile.depend
+++ /dev/null
@@ -1,20 +0,0 @@
-# $FreeBSD$
-# Autogenerated - do NOT edit!
-
-DIRDEPS = \
- gnu/lib/csu \
- gnu/lib/libgcc \
- include \
- include/xlocale \
- lib/${CSU_DIR} \
- lib/libc \
- lib/libcompiler_rt \
- lib/libthr \
- lib/msun \
-
-
-.include <dirdeps.mk>
-
-.if ${DEP_RELDIR} == ${_DEP_RELDIR}
-# local dependencies - needed for -jN in clean tree
-.endif
diff --git a/contrib/ofed/usr.lib/libosmvendor/Makefile b/contrib/ofed/usr.lib/libosmvendor/Makefile
deleted file mode 100644
index e277def..0000000
--- a/contrib/ofed/usr.lib/libosmvendor/Makefile
+++ /dev/null
@@ -1,21 +0,0 @@
-# $FreeBSD$
-
-SHLIBDIR?= /usr/lib
-
-.include <bsd.own.mk>
-.include "../Makefile.inc"
-
-.PATH: ${VENDORLIBDIR}
-
-LIB= osmvendor
-SHLIB_MAJOR= 1
-MK_PROFILE= no
-
-SRCS= osm_vendor_ibumad.c osm_vendor_ibumad_sa.c
-
-LIBADD= ibumad opensm osmcomp pthread
-CFLAGS+= -DOSM_VENDOR_INTF_OPENIB
-
-VERSION_MAP= ${VENDORLIBDIR}/libosmvendor.map
-
-.include <bsd.lib.mk>
diff --git a/contrib/ofed/usr.lib/libosmvendor/Makefile.depend b/contrib/ofed/usr.lib/libosmvendor/Makefile.depend
deleted file mode 100644
index 20e0a6b..0000000
--- a/contrib/ofed/usr.lib/libosmvendor/Makefile.depend
+++ /dev/null
@@ -1,22 +0,0 @@
-# $FreeBSD$
-# Autogenerated - do NOT edit!
-
-DIRDEPS = \
- contrib/ofed/usr.lib/libibumad \
- contrib/ofed/usr.lib/libopensm \
- contrib/ofed/usr.lib/libosmcomp \
- gnu/lib/csu \
- gnu/lib/libgcc \
- include \
- include/xlocale \
- lib/${CSU_DIR} \
- lib/libc \
- lib/libcompiler_rt \
- lib/libthr \
-
-
-.include <dirdeps.mk>
-
-.if ${DEP_RELDIR} == ${_DEP_RELDIR}
-# local dependencies - needed for -jN in clean tree
-.endif
diff --git a/contrib/ofed/usr.lib/librdmacm/Makefile b/contrib/ofed/usr.lib/librdmacm/Makefile
deleted file mode 100644
index 3845622..0000000
--- a/contrib/ofed/usr.lib/librdmacm/Makefile
+++ /dev/null
@@ -1,34 +0,0 @@
-# $FreeBSD$
-
-SHLIBDIR?= /usr/lib
-
-.include <bsd.own.mk>
-
-RDMACMDIR= ${.CURDIR}/../../librdmacm
-RDMASRCDIR= ${RDMACMDIR}/src
-RDMAMANDIR= ${RDMACMDIR}/man
-
-.PATH: ${RDMASRCDIR} ${RDMAMANDIR}
-
-LIB= rdmacm
-SHLIB_MAJOR= 1
-MK_PROFILE= no
-
-SRCS= cma.c
-
-MAN= rdma_get_devices.3 mckey.1 rdma_get_dst_port.3 rdma_accept.3
-MAN+= rdma_get_local_addr.3 rdma_ack_cm_event.3 rdma_get_peer_addr.3
-MAN+= rdma_bind_addr.3 rdma_get_src_port.3 rdma_cm.7 rdma_join_multicast.3
-MAN+= rdma_connect.3 rdma_leave_multicast.3 rdma_create_event_channel.3
-MAN+= rdma_listen.3 rdma_create_id.3 rdma_migrate_id.3 rdma_create_qp.3
-MAN+= rdma_notify.3 rdma_destroy_event_channel.3 rdma_reject.3
-MAN+= rdma_destroy_id.3 rdma_resolve_addr.3 rdma_destroy_qp.3
-MAN+= rdma_resolve_route.3 rdma_disconnect.3 rdma_set_option.3
-MAN+= rdma_event_str.3 rping.1 rdma_free_devices.3 ucmatose.1
-MAN+= rdma_get_cm_event.3 udaddy.1
-
-LIBADD= ibverbs
-
-VERSION_MAP= ${RDMASRCDIR}/librdmacm.map
-
-.include <bsd.lib.mk>
diff --git a/contrib/ofed/usr.lib/librdmacm/Makefile.depend b/contrib/ofed/usr.lib/librdmacm/Makefile.depend
deleted file mode 100644
index e8013ca..0000000
--- a/contrib/ofed/usr.lib/librdmacm/Makefile.depend
+++ /dev/null
@@ -1,19 +0,0 @@
-# $FreeBSD$
-# Autogenerated - do NOT edit!
-
-DIRDEPS = \
- contrib/ofed/usr.lib/libibverbs \
- gnu/lib/csu \
- gnu/lib/libgcc \
- include \
- include/xlocale \
- lib/${CSU_DIR} \
- lib/libc \
- lib/libcompiler_rt \
-
-
-.include <dirdeps.mk>
-
-.if ${DEP_RELDIR} == ${_DEP_RELDIR}
-# local dependencies - needed for -jN in clean tree
-.endif
diff --git a/contrib/ofed/usr.lib/libsdp/Makefile b/contrib/ofed/usr.lib/libsdp/Makefile
deleted file mode 100644
index 54d09ca..0000000
--- a/contrib/ofed/usr.lib/libsdp/Makefile
+++ /dev/null
@@ -1,25 +0,0 @@
-# $FreeBSD$
-
-SHLIBDIR?= /usr/lib
-
-.include <bsd.own.mk>
-
-SDPDIR= ${.CURDIR}/../../libsdp/src
-
-.PATH: ${SDPDIR}
-
-LIB= ibsdp
-SHLIB_MAJOR= 1
-MK_PROFILE= no
-MAN=
-
-SRCS= log.c match.c port.c config_parser.c config_scanner.c
-
-CFLAGS+= -DSYSCONFDIR=\"/etc\"
-CFLAGS+= -I${OFEDSYS}/include
-
-.include <bsd.lib.mk>
-
-# Remove .[ly] since the checked-in version is preferred.
-.SUFFIXES:
-.SUFFIXES: .o .po .pico .c .ln
diff --git a/contrib/ofed/usr.lib/libsdp/Makefile.depend b/contrib/ofed/usr.lib/libsdp/Makefile.depend
deleted file mode 100644
index 54c1f6f..0000000
--- a/contrib/ofed/usr.lib/libsdp/Makefile.depend
+++ /dev/null
@@ -1,19 +0,0 @@
-# $FreeBSD$
-# Autogenerated - do NOT edit!
-
-DIRDEPS = \
- gnu/lib/csu \
- gnu/lib/libgcc \
- include \
- include/arpa \
- include/xlocale \
- lib/${CSU_DIR} \
- lib/libc \
- lib/libcompiler_rt \
-
-
-.include <dirdeps.mk>
-
-.if ${DEP_RELDIR} == ${_DEP_RELDIR}
-# local dependencies - needed for -jN in clean tree
-.endif
diff --git a/share/mk/bsd.libnames.mk b/share/mk/bsd.libnames.mk
index 07e7a4c..e09b2a6 100644
--- a/share/mk/bsd.libnames.mk
+++ b/share/mk/bsd.libnames.mk
@@ -95,6 +95,11 @@ LIBKICONV?= ${DESTDIR}${LIBDIR_BASE}/libkiconv.a
LIBKRB5?= ${DESTDIR}${LIBDIR_BASE}/libkrb5.a
LIBKVM?= ${DESTDIR}${LIBDIR_BASE}/libkvm.a
LIBL?= ${DESTDIR}${LIBDIR_BASE}/libl.a
+LIBIBCM?= ${DESTDIR}${LIBDIR_BASE}/libibcm.a
+LIBIBMAD?= ${DESTDIR}${LIBDIR_BASE}/libibmad.a
+LIBIBNETDISC?= ${LIBDESTDIR}${LIBDIR_BASE}/libibnetdisc.
+LIBIBUMAD?= ${DESTDIR}${LIBDIR_BASE}/libibumad.a
+LIBIBVERBS?= ${DESTDIR}${LIBDIR_BASE}/libibverbs.a
LIBLN?= "don't use LIBLN, use LIBL"
LIBLZMA?= ${DESTDIR}${LIBDIR_BASE}/liblzma.a
LIBM?= ${DESTDIR}${LIBDIR_BASE}/libm.a
@@ -104,9 +109,9 @@ LIBMEMSTAT?= ${DESTDIR}${LIBDIR_BASE}/libmemstat.a
LIBMENU?= ${DESTDIR}${LIBDIR_BASE}/libmenu.a
LIBMILTER?= ${DESTDIR}${LIBDIR_BASE}/libmilter.a
LIBMLX4?= ${DESTDIR}${LIBDIR_BASE}/libmlx4.a
+LIBMLX5?= ${DESTDIR}${LIBDIR_BASE}/libmlx5.a
LIBMP?= ${DESTDIR}${LIBDIR_BASE}/libmp.a
LIBMT?= ${DESTDIR}${LIBDIR_BASE}/libmt.a
-LIBMTHCA?= ${DESTDIR}${LIBDIR_BASE}/libmthca.a
LIBNANDFS?= ${DESTDIR}${LIBDIR_BASE}/libnandfs.a
LIBNCURSES?= ${DESTDIR}${LIBDIR_BASE}/libncurses.a
LIBNCURSESW?= ${DESTDIR}${LIBDIR_BASE}/libncursesw.a
diff --git a/share/mk/src.libnames.mk b/share/mk/src.libnames.mk
index ac3f9c2..3064027 100644
--- a/share/mk/src.libnames.mk
+++ b/share/mk/src.libnames.mk
@@ -190,18 +190,16 @@ _LIBRARIES+= \
_LIBRARIES+= \
cxgb4 \
ibcm \
- ibcommon \
ibmad \
- ibsdp \
+ ibnetdisc \
ibumad \
ibverbs \
mlx4 \
- mthca \
- opensm \
- osmcomp \
- osmvendor \
+ mlx5 \
rdmacm \
-
+ osmcomp \
+ opensm \
+ osmvendor
.endif
# Each library's LIBADD needs to be duplicated here for static linkage of
@@ -325,17 +323,21 @@ _DP_zfs= md pthread umem util uutil m nvpair avl bsdxml geom nvpair z \
zfs_core
_DP_zfs_core= nvpair
_DP_zpool= md pthread z nvpair avl umem
+
+# OFED support
.if ${MK_OFED} != "no"
_DP_cxgb4= ibverbs pthread
_DP_ibcm= ibverbs
-_DP_ibmad= ibcommon ibumad
-_DP_ibumad= ibcommon
+_DP_ibmad= ibumad
+_DP_ibnetdisc= osmcomp ibmad ibumad
+_DP_ibumad=
+_DP_ibverbs=
_DP_mlx4= ibverbs pthread
-_DP_mthca= ibverbs pthread
-_DP_opensm= pthread
-_DP_osmcomp= pthread
-_DP_osmvendor= ibumad opensm osmcomp pthread
+_DP_mlx5= ibverbs pthread
_DP_rdmacm= ibverbs
+_DP_osmcomp= pthread
+_DP_opensm= pthread
+_DP_osmvendor= ibumad pthread
.endif
# Define special cases
@@ -473,19 +475,21 @@ LIBUUTILDIR= ${OBJTOP}/cddl/lib/libuutil
LIBZFSDIR= ${OBJTOP}/cddl/lib/libzfs
LIBZFS_COREDIR= ${OBJTOP}/cddl/lib/libzfs_core
LIBZPOOLDIR= ${OBJTOP}/cddl/lib/libzpool
-LIBCXGB4DIR= ${OBJTOP}/contrib/ofed/usr.lib/libcxgb4
-LIBIBCMDIR= ${OBJTOP}/contrib/ofed/usr.lib/libibcm
-LIBIBCOMMONDIR= ${OBJTOP}/contrib/ofed/usr.lib/libibcommon
-LIBIBMADDIR= ${OBJTOP}/contrib/ofed/usr.lib/libibmad
-LIBIBUMADDIR= ${OBJTOP}/contrib/ofed/usr.lib/libibumad
-LIBIBVERBSDIR= ${OBJTOP}/contrib/ofed/usr.lib/libibverbs
-LIBMLX4DIR= ${OBJTOP}/contrib/ofed/usr.lib/libmlx4
-LIBMTHCADIR= ${OBJTOP}/contrib/ofed/usr.lib/libmthca
-LIBOPENSMDIR= ${OBJTOP}/contrib/ofed/usr.lib/libopensm
-LIBOSMCOMPDIR= ${OBJTOP}/contrib/ofed/usr.lib/libosmcomp
-LIBOSMVENDORDIR= ${OBJTOP}/contrib/ofed/usr.lib/libosmvendor
-LIBRDMACMDIR= ${OBJTOP}/contrib/ofed/usr.lib/librdmacm
-LIBIBSDPDIR= ${OBJTOP}/contrib/ofed/usr.lib/libsdp
+
+# OFED support
+LIBCXGB4DIR= ${OBJTOP}/contrib/ofed/libcxgb4
+LIBIBCMDIR= ${OBJTOP}/contrib/ofed/libibcm
+LIBIBMADDIR= ${OBJTOP}/contrib/ofed/libibmad
+LIBIBNETDISCDIR=${OBJTOP}/contrib/ofed/libibnetdisc
+LIBIBUMADDIR= ${OBJTOP}/contrib/ofed/libibumad
+LIBIBVERBSDIR= ${OBJTOP}/contrib/ofed/libibverbs
+LIBMLX4DIR= ${OBJTOP}/contrib/ofed/libmlx4
+LIBMLX5DIR= ${OBJTOP}/contrib/ofed/libmlx5
+LIBRDMACMDIR= ${OBJTOP}/contrib/ofed/librdmacm
+LIBOSMCOMPDIR= ${OBJTOP}/contrib/ofed/opensm/complib
+LIBOPENSMDIR= ${OBJTOP}/contrib/ofed/opensm/libopensm
+LIBOSMVENDORDIR=${OBJTOP}/contrib/ofed/opensm/libvendor
+
LIBDIALOGDIR= ${OBJTOP}/gnu/lib/libdialog
LIBGCOVDIR= ${OBJTOP}/gnu/lib/libgcov
LIBGOMPDIR= ${OBJTOP}/gnu/lib/libgomp
diff --git a/sys/amd64/conf/NOTES b/sys/amd64/conf/NOTES
index 723f1d8..56b868f 100644
--- a/sys/amd64/conf/NOTES
+++ b/sys/amd64/conf/NOTES
@@ -323,9 +323,9 @@ options DRM_DEBUG # Include debug printfs (slow)
# Requires the iwn firmware module
# ixl: Intel XL710 40Gbe PCIE Ethernet
# ixlv: Intel XL710 40Gbe VF PCIE Ethernet
+# mthca: Mellanox HCA InfiniBand
# mlx4ib: Mellanox ConnectX HCA InfiniBand
# mlx4en: Mellanox ConnectX HCA Ethernet
-# mthca: Mellanox HCA InfiniBand
# nfe: nVidia nForce MCP on-board Ethernet Networking (BSD open source)
# sfxge: Solarflare SFC9000 family 10Gb Ethernet adapters
# vmx: VMware VMXNET3 Ethernet (BSD open source)
@@ -343,10 +343,10 @@ device iwn # Intel 4965/1000/5000/6000 wireless NICs.
device ixl # Intel XL710 40Gbe PCIE Ethernet
options IXL_IW # Enable iWARP Client Interface in ixl(4)
device ixlv # Intel XL710 40Gbe VF PCIE Ethernet
+device mthca # Mellanox HCA InfiniBand
device mlx4 # Shared code module between IB and Ethernet
device mlx4ib # Mellanox ConnectX HCA InfiniBand
device mlx4en # Mellanox ConnectX HCA Ethernet
-device mthca # Mellanox HCA InfiniBand
device nfe # nVidia nForce MCP on-board Ethernet
device sfxge # Solarflare SFC9000 10Gb Ethernet
device vmx # VMware VMXNET3 Ethernet
diff --git a/sys/conf/files b/sys/conf/files
index 1bed7fe..017469b 100644
--- a/sys/conf/files
+++ b/sys/conf/files
@@ -4276,58 +4276,62 @@ compat/linuxkpi/common/src/linux_work.c optional compat_linuxkpi \
compile-with "${LINUXKPI_C}"
# OpenFabrics Enterprise Distribution (Infiniband)
-ofed/drivers/infiniband/core/addr.c optional ofed \
- compile-with "${OFED_C} -I$S/ofed/drivers/infiniband/core/"
-ofed/drivers/infiniband/core/agent.c optional ofed \
- compile-with "${OFED_C} -I$S/ofed/drivers/infiniband/core/"
-ofed/drivers/infiniband/core/cache.c optional ofed \
- compile-with "${OFED_C} -I$S/ofed/drivers/infiniband/core/"
-# XXX Mad.c must be ordered before cm.c for sysinit sets to occur in
-# the correct order.
-ofed/drivers/infiniband/core/mad.c optional ofed \
- compile-with "${OFED_C} -I$S/ofed/drivers/infiniband/core/"
-ofed/drivers/infiniband/core/cm.c optional ofed \
- compile-with "${OFED_C} -I$S/ofed/drivers/infiniband/core/ -Wno-unused-function"
-ofed/drivers/infiniband/core/cma.c optional ofed \
- compile-with "${OFED_C} -I$S/ofed/drivers/infiniband/core/"
-ofed/drivers/infiniband/core/device.c optional ofed \
- compile-with "${OFED_C} -I$S/ofed/drivers/infiniband/core/"
-ofed/drivers/infiniband/core/fmr_pool.c optional ofed \
- compile-with "${OFED_C} -I$S/ofed/drivers/infiniband/core/"
-ofed/drivers/infiniband/core/iwcm.c optional ofed \
- compile-with "${OFED_C} -I$S/ofed/drivers/infiniband/core/"
-ofed/drivers/infiniband/core/mad_rmpp.c optional ofed \
- compile-with "${OFED_C} -I$S/ofed/drivers/infiniband/core/"
-ofed/drivers/infiniband/core/multicast.c optional ofed \
- compile-with "${OFED_C} -I$S/ofed/drivers/infiniband/core/"
-ofed/drivers/infiniband/core/packer.c optional ofed \
- compile-with "${OFED_C} -I$S/ofed/drivers/infiniband/core/"
-ofed/drivers/infiniband/core/peer_mem.c optional ofed \
- compile-with "${OFED_C} -I$S/ofed/drivers/infiniband/core/"
-ofed/drivers/infiniband/core/sa_query.c optional ofed \
- compile-with "${OFED_C} -I$S/ofed/drivers/infiniband/core/"
-ofed/drivers/infiniband/core/smi.c optional ofed \
- compile-with "${OFED_C} -I$S/ofed/drivers/infiniband/core/"
-ofed/drivers/infiniband/core/sysfs.c optional ofed \
- compile-with "${OFED_C} -I$S/ofed/drivers/infiniband/core/"
-ofed/drivers/infiniband/core/ucm.c optional ofed \
- compile-with "${OFED_C} -I$S/ofed/drivers/infiniband/core/"
-ofed/drivers/infiniband/core/ucma.c optional ofed \
- compile-with "${OFED_C} -I$S/ofed/drivers/infiniband/core/"
-ofed/drivers/infiniband/core/ud_header.c optional ofed \
- compile-with "${OFED_C} -I$S/ofed/drivers/infiniband/core/"
-ofed/drivers/infiniband/core/umem.c optional ofed \
- compile-with "${OFED_C} -I$S/ofed/drivers/infiniband/core/"
-ofed/drivers/infiniband/core/user_mad.c optional ofed \
- compile-with "${OFED_C} -I$S/ofed/drivers/infiniband/core/"
-ofed/drivers/infiniband/core/uverbs_cmd.c optional ofed \
- compile-with "${OFED_C} -I$S/ofed/drivers/infiniband/core/"
-ofed/drivers/infiniband/core/uverbs_main.c optional ofed \
- compile-with "${OFED_C} -I$S/ofed/drivers/infiniband/core/"
-ofed/drivers/infiniband/core/uverbs_marshall.c optional ofed \
- compile-with "${OFED_C} -I$S/ofed/drivers/infiniband/core/"
-ofed/drivers/infiniband/core/verbs.c optional ofed \
- compile-with "${OFED_C} -I$S/ofed/drivers/infiniband/core/"
+ofed/drivers/infiniband/core/ib_addr.c optional ofed \
+ compile-with "${OFED_C}"
+ofed/drivers/infiniband/core/ib_agent.c optional ofed \
+ compile-with "${OFED_C}"
+ofed/drivers/infiniband/core/ib_cache.c optional ofed \
+ compile-with "${OFED_C}"
+ofed/drivers/infiniband/core/ib_cm.c optional ofed \
+ compile-with "${OFED_C}"
+ofed/drivers/infiniband/core/ib_cma.c optional ofed \
+ compile-with "${OFED_C}"
+ofed/drivers/infiniband/core/ib_cq.c optional ofed \
+ compile-with "${OFED_C}"
+ofed/drivers/infiniband/core/ib_device.c optional ofed \
+ compile-with "${OFED_C}"
+ofed/drivers/infiniband/core/ib_fmr_pool.c optional ofed \
+ compile-with "${OFED_C}"
+ofed/drivers/infiniband/core/ib_iwcm.c optional ofed \
+ compile-with "${OFED_C}"
+ofed/drivers/infiniband/core/ib_iwpm_msg.c optional ofed \
+ compile-with "${OFED_C}"
+ofed/drivers/infiniband/core/ib_iwpm_util.c optional ofed \
+ compile-with "${OFED_C}"
+ofed/drivers/infiniband/core/ib_mad.c optional ofed \
+ compile-with "${OFED_C}"
+ofed/drivers/infiniband/core/ib_mad_rmpp.c optional ofed \
+ compile-with "${OFED_C}"
+ofed/drivers/infiniband/core/ib_multicast.c optional ofed \
+ compile-with "${OFED_C}"
+ofed/drivers/infiniband/core/ib_packer.c optional ofed \
+ compile-with "${OFED_C}"
+ofed/drivers/infiniband/core/ib_roce_gid_mgmt.c optional ofed \
+ compile-with "${OFED_C}"
+ofed/drivers/infiniband/core/ib_sa_query.c optional ofed \
+ compile-with "${OFED_C}"
+ofed/drivers/infiniband/core/ib_smi.c optional ofed \
+ compile-with "${OFED_C}"
+ofed/drivers/infiniband/core/ib_sysfs.c optional ofed \
+ compile-with "${OFED_C}"
+ofed/drivers/infiniband/core/ib_ucm.c optional ofed \
+ compile-with "${OFED_C}"
+ofed/drivers/infiniband/core/ib_ucma.c optional ofed \
+ compile-with "${OFED_C}"
+ofed/drivers/infiniband/core/ib_ud_header.c optional ofed \
+ compile-with "${OFED_C}"
+ofed/drivers/infiniband/core/ib_umem.c optional ofed \
+ compile-with "${OFED_C}"
+ofed/drivers/infiniband/core/ib_user_mad.c optional ofed \
+ compile-with "${OFED_C}"
+ofed/drivers/infiniband/core/ib_uverbs_cmd.c optional ofed \
+ compile-with "${OFED_C}"
+ofed/drivers/infiniband/core/ib_uverbs_main.c optional ofed \
+ compile-with "${OFED_C}"
+ofed/drivers/infiniband/core/ib_uverbs_marshall.c optional ofed \
+ compile-with "${OFED_C}"
+ofed/drivers/infiniband/core/ib_verbs.c optional ofed \
+ compile-with "${OFED_C}"
ofed/drivers/infiniband/ulp/ipoib/ipoib_cm.c optional ipoib \
compile-with "${OFED_C} -I$S/ofed/drivers/infiniband/ulp/ipoib/"
@@ -4355,6 +4359,43 @@ ofed/drivers/infiniband/ulp/sdp/sdp_cma.c optional sdp inet \
ofed/drivers/infiniband/ulp/sdp/sdp_tx.c optional sdp inet \
compile-with "${OFED_C} -I$S/ofed/drivers/infiniband/ulp/sdp/"
+dev/mthca/mthca_allocator.c optional mthca pci ofed \
+ compile-with "${OFED_C}"
+dev/mthca/mthca_av.c optional mthca pci ofed \
+ compile-with "${OFED_C}"
+dev/mthca/mthca_catas.c optional mthca pci ofed \
+ compile-with "${OFED_C}"
+dev/mthca/mthca_cmd.c optional mthca pci ofed \
+ compile-with "${OFED_C}"
+dev/mthca/mthca_cq.c optional mthca pci ofed \
+ compile-with "${OFED_C}"
+dev/mthca/mthca_eq.c optional mthca pci ofed \
+ compile-with "${OFED_C}"
+dev/mthca/mthca_mad.c optional mthca pci ofed \
+ compile-with "${OFED_C}"
+dev/mthca/mthca_main.c optional mthca pci ofed \
+ compile-with "${OFED_C}"
+dev/mthca/mthca_mcg.c optional mthca pci ofed \
+ compile-with "${OFED_C}"
+dev/mthca/mthca_memfree.c optional mthca pci ofed \
+ compile-with "${OFED_C}"
+dev/mthca/mthca_mr.c optional mthca pci ofed \
+ compile-with "${OFED_C}"
+dev/mthca/mthca_pd.c optional mthca pci ofed \
+ compile-with "${OFED_C}"
+dev/mthca/mthca_profile.c optional mthca pci ofed \
+ compile-with "${OFED_C}"
+dev/mthca/mthca_provider.c optional mthca pci ofed \
+ compile-with "${OFED_C}"
+dev/mthca/mthca_qp.c optional mthca pci ofed \
+ compile-with "${OFED_C}"
+dev/mthca/mthca_reset.c optional mthca pci ofed \
+ compile-with "${OFED_C}"
+dev/mthca/mthca_srq.c optional mthca pci ofed \
+ compile-with "${OFED_C}"
+dev/mthca/mthca_uar.c optional mthca pci ofed \
+ compile-with "${OFED_C}"
+
dev/mlx4/mlx4_ib/mlx4_ib_alias_GUID.c optional mlx4ib pci ofed \
compile-with "${OFED_C}"
dev/mlx4/mlx4_ib/mlx4_ib_mcg.c optional mlx4ib pci ofed \
@@ -4373,8 +4414,6 @@ dev/mlx4/mlx4_ib/mlx4_ib_mad.c optional mlx4ib pci ofed \
compile-with "${OFED_C}"
dev/mlx4/mlx4_ib/mlx4_ib_main.c optional mlx4ib pci ofed \
compile-with "${OFED_C}"
-dev/mlx4/mlx4_ib/mlx4_ib_exp.c optional mlx4ib pci ofed \
- compile-with "${OFED_C}"
dev/mlx4/mlx4_ib/mlx4_ib_mr.c optional mlx4ib pci ofed \
compile-with "${OFED_C}"
dev/mlx4/mlx4_ib/mlx4_ib_qp.c optional mlx4ib pci ofed \
@@ -4446,6 +4485,8 @@ dev/mlx5/mlx5_ib/mlx5_ib_cq.c optional mlx5ib pci ofed \
compile-with "${OFED_C}"
dev/mlx5/mlx5_ib/mlx5_ib_doorbell.c optional mlx5ib pci ofed \
compile-with "${OFED_C}"
+dev/mlx5/mlx5_ib/mlx5_ib_gsi.c optional mlx5ib pci ofed \
+ compile-with "${OFED_C}"
dev/mlx5/mlx5_ib/mlx5_ib_mad.c optional mlx5ib pci ofed \
compile-with "${OFED_C}"
dev/mlx5/mlx5_ib/mlx5_ib_main.c optional mlx5ib pci ofed \
@@ -4456,10 +4497,10 @@ dev/mlx5/mlx5_ib/mlx5_ib_mr.c optional mlx5ib pci ofed \
compile-with "${OFED_C}"
dev/mlx5/mlx5_ib/mlx5_ib_qp.c optional mlx5ib pci ofed \
compile-with "${OFED_C}"
-dev/mlx5/mlx5_ib/mlx5_ib_roce.c optional mlx5ib pci ofed \
- compile-with "${OFED_C}"
dev/mlx5/mlx5_ib/mlx5_ib_srq.c optional mlx5ib pci ofed \
compile-with "${OFED_C}"
+dev/mlx5/mlx5_ib/mlx5_ib_virt.c optional mlx5ib pci ofed \
+ compile-with "${OFED_C}"
dev/mlx5/mlx5_core/mlx5_alloc.c optional mlx5 pci \
compile-with "${OFED_C}"
@@ -4525,43 +4566,6 @@ dev/mlx5/mlx5_en/mlx5_en_rx.c optional mlx5en pci inet inet6 \
dev/mlx5/mlx5_en/mlx5_en_txrx.c optional mlx5en pci inet inet6 \
compile-with "${OFED_C}"
-ofed/drivers/infiniband/hw/mthca/mthca_allocator.c optional mthca \
- compile-with "${OFED_C}"
-ofed/drivers/infiniband/hw/mthca/mthca_av.c optional mthca \
- compile-with "${OFED_C}"
-ofed/drivers/infiniband/hw/mthca/mthca_catas.c optional mthca \
- compile-with "${OFED_C}"
-ofed/drivers/infiniband/hw/mthca/mthca_cmd.c optional mthca \
- compile-with "${OFED_C}"
-ofed/drivers/infiniband/hw/mthca/mthca_cq.c optional mthca \
- compile-with "${OFED_C}"
-ofed/drivers/infiniband/hw/mthca/mthca_eq.c optional mthca \
- compile-with "${OFED_C}"
-ofed/drivers/infiniband/hw/mthca/mthca_mad.c optional mthca \
- compile-with "${OFED_C}"
-ofed/drivers/infiniband/hw/mthca/mthca_main.c optional mthca \
- compile-with "${OFED_C}"
-ofed/drivers/infiniband/hw/mthca/mthca_mcg.c optional mthca \
- compile-with "${OFED_C}"
-ofed/drivers/infiniband/hw/mthca/mthca_memfree.c optional mthca \
- compile-with "${OFED_C}"
-ofed/drivers/infiniband/hw/mthca/mthca_mr.c optional mthca \
- compile-with "${OFED_C}"
-ofed/drivers/infiniband/hw/mthca/mthca_pd.c optional mthca \
- compile-with "${OFED_C}"
-ofed/drivers/infiniband/hw/mthca/mthca_profile.c optional mthca \
- compile-with "${OFED_C}"
-ofed/drivers/infiniband/hw/mthca/mthca_provider.c optional mthca \
- compile-with "${OFED_C}"
-ofed/drivers/infiniband/hw/mthca/mthca_qp.c optional mthca \
- compile-with "${OFED_C}"
-ofed/drivers/infiniband/hw/mthca/mthca_reset.c optional mthca \
- compile-with "${OFED_C}"
-ofed/drivers/infiniband/hw/mthca/mthca_srq.c optional mthca \
- compile-with "${OFED_C}"
-ofed/drivers/infiniband/hw/mthca/mthca_uar.c optional mthca \
- compile-with "${OFED_C}"
-
# crypto support
opencrypto/cast.c optional crypto | ipsec | ipsec_support
opencrypto/criov.c optional crypto | ipsec | ipsec_support
diff --git a/sys/conf/kern.pre.mk b/sys/conf/kern.pre.mk
index bf9d389..1f784b5 100644
--- a/sys/conf/kern.pre.mk
+++ b/sys/conf/kern.pre.mk
@@ -176,9 +176,10 @@ LINUXKPI_C= ${NORMAL_C} ${LINUXKPI_INCLUDES}
# Infiniband C flags. Correct include paths and omit errors that linux
# does not honor.
-OFEDINCLUDES= -I$S/ofed/include ${LINUXKPI_INCLUDES}
+OFEDINCLUDES= -I$S/ofed/include -I$S/ofed/include/uapi ${LINUXKPI_INCLUDES}
OFEDNOERR= -Wno-cast-qual -Wno-pointer-arith
-OFEDCFLAGS= ${CFLAGS:N-I*} ${OFEDINCLUDES} ${CFLAGS:M-I*} ${OFEDNOERR}
+OFEDCFLAGS= ${CFLAGS:N-I*} -DCONFIG_INFINIBAND_USER_MEM \
+ ${OFEDINCLUDES} ${CFLAGS:M-I*} ${OFEDNOERR}
OFED_C_NOIMP= ${CC} -c -o ${.TARGET} ${OFEDCFLAGS} ${WERROR} ${PROF}
OFED_C= ${OFED_C_NOIMP} ${.IMPSRC}
diff --git a/sys/contrib/rdma/krping/krping.c b/sys/contrib/rdma/krping/krping.c
index 08b57f0..6e0608e 100644
--- a/sys/contrib/rdma/krping/krping.c
+++ b/sys/contrib/rdma/krping/krping.c
@@ -54,13 +54,14 @@ __FBSDID("$FreeBSD$");
#include "krping.h"
#include "getopt.h"
+#define PFX "krping: "
+
extern int krping_debug;
-#define DEBUG_LOG(cb, x...) if (krping_debug) log(LOG_INFO, x)
-#define PRINTF(cb, x...) log(LOG_INFO, x)
+#define DEBUG_LOG(...) do { if (krping_debug) log(LOG_INFO, __VA_ARGS__); } while (0)
#define BIND_INFO 1
MODULE_AUTHOR("Steve Wise");
-MODULE_DESCRIPTION("RDMA ping client/server");
+MODULE_DESCRIPTION("RDMA ping server");
MODULE_LICENSE("Dual BSD/GPL");
MODULE_VERSION(krping, 1);
MODULE_DEPEND(krping, linuxkpi, 1, 1, 1);
@@ -77,9 +78,7 @@ typedef uint64_t cycles_t;
enum mem_type {
DMA = 1,
- FASTREG = 2,
- MW = 3,
- MR = 4
+ REG = 2,
};
static const struct krping_option krping_opts[] = {
@@ -92,7 +91,6 @@ static const struct krping_option krping_opts[] = {
{"validate", OPT_NOPARAM, 'V'},
{"server", OPT_NOPARAM, 's'},
{"client", OPT_NOPARAM, 'c'},
- {"mem_mode", OPT_STRING, 'm'},
{"server_inv", OPT_NOPARAM, 'I'},
{"wlat", OPT_NOPARAM, 'l'},
{"rlat", OPT_NOPARAM, 'L'},
@@ -102,14 +100,14 @@ static const struct krping_option krping_opts[] = {
{"poll", OPT_NOPARAM, 'P'},
{"local_dma_lkey", OPT_NOPARAM, 'Z'},
{"read_inv", OPT_NOPARAM, 'R'},
- {"fr", OPT_INT, 'f'},
+ {"fr", OPT_NOPARAM, 'f'},
{NULL, 0, 0}
};
#define htonll(x) cpu_to_be64((x))
#define ntohll(x) cpu_to_be64((x))
-static struct mutex krping_mutex;
+static DEFINE_MUTEX(krping_mutex);
/*
* List of running krping threads.
@@ -117,6 +115,13 @@ static struct mutex krping_mutex;
static LIST_HEAD(krping_cbs);
/*
+ * Invoke like this, one on each side, using the server's address on
+ * the RDMA device (iw%d):
+ *
+ * /bin/echo server,port=9999,addr=192.168.69.142,validate > /proc/krping
+ * /bin/echo client,port=9999,addr=192.168.69.142,validate > /proc/krping
+ * /bin/echo client,port=9999,addr6=2001:db8:0:f101::1,validate > /proc/krping
+ *
* krping "ping/pong" loop:
* client sends source rkey/addr/len
* server receives source rkey/add/len
@@ -165,42 +170,35 @@ struct krping_rdma_info {
* Control block struct.
*/
struct krping_cb {
- void *cookie;
int server; /* 0 iff client */
struct ib_cq *cq;
struct ib_pd *pd;
struct ib_qp *qp;
- enum mem_type mem;
struct ib_mr *dma_mr;
struct ib_fast_reg_page_list *page_list;
int page_list_len;
- struct ib_send_wr fastreg_wr;
+ struct ib_reg_wr reg_mr_wr;
struct ib_send_wr invalidate_wr;
- struct ib_mr *fastreg_mr;
+ struct ib_mr *reg_mr;
int server_invalidate;
int read_inv;
u8 key;
- struct ib_mw *mw;
- struct ib_mw_bind bind_attr;
-
struct ib_recv_wr rq_wr; /* recv work request record */
struct ib_sge recv_sgl; /* recv single SGE */
- struct krping_rdma_info recv_buf;/* malloc'd buffer */
+ struct krping_rdma_info recv_buf __aligned(16); /* malloc'd buffer */
u64 recv_dma_addr;
DECLARE_PCI_UNMAP_ADDR(recv_mapping)
- struct ib_mr *recv_mr;
struct ib_send_wr sq_wr; /* send work requrest record */
struct ib_sge send_sgl;
- struct krping_rdma_info send_buf;/* single send buf */
+ struct krping_rdma_info send_buf __aligned(16); /* single send buf */
u64 send_dma_addr;
DECLARE_PCI_UNMAP_ADDR(send_mapping)
- struct ib_mr *send_mr;
- struct ib_send_wr rdma_sq_wr; /* rdma work request record */
+ struct ib_rdma_wr rdma_sq_wr; /* rdma work request record */
struct ib_sge rdma_sgl; /* rdma single SGE */
char *rdma_buf; /* used as rdma sink */
u64 rdma_dma_addr;
@@ -221,12 +219,9 @@ struct krping_cb {
struct krping_stats stats;
uint16_t port; /* dst port in NBO */
- union {
- struct in_addr v4;
- struct in6_addr v6;
- } addr; /* dst addr in NBO */
- int addr_type; /* AF_INET or AF_INET6 */
+ u8 addr[16] __aligned(8); /* dst addr in NBO */
char *addr_str; /* dst addr string */
+ uint8_t addr_type; /* ADDR_FAMILY - IPv4/V6 */
int verbose; /* verbose logging */
int count; /* ping count */
int size; /* ping data size */
@@ -238,8 +233,7 @@ struct krping_cb {
int poll; /* poll or block for rlat test */
int txdepth; /* SQ depth */
int local_dma_lkey; /* use 0 for lkey */
- int frtest; /* fastreg test */
- int testnum;
+ int frtest; /* reg test */
/* CM stuff */
struct rdma_cm_id *cm_id; /* connection on client side,*/
@@ -254,39 +248,34 @@ static int krping_cma_event_handler(struct rdma_cm_id *cma_id,
int ret;
struct krping_cb *cb = cma_id->context;
- DEBUG_LOG(cb, "cma_event type %d cma_id %p (%s)\n", event->event,
- cma_id, (cma_id == cb->cm_id) ? "parent" : "child");
+ DEBUG_LOG("cma_event type %d cma_id %p (%s)\n", event->event, cma_id,
+ (cma_id == cb->cm_id) ? "parent" : "child");
switch (event->event) {
case RDMA_CM_EVENT_ADDR_RESOLVED:
cb->state = ADDR_RESOLVED;
ret = rdma_resolve_route(cma_id, 2000);
if (ret) {
- PRINTF(cb, "rdma_resolve_route error %d\n", ret);
+ printk(KERN_ERR PFX "rdma_resolve_route error %d\n",
+ ret);
wake_up_interruptible(&cb->sem);
}
break;
case RDMA_CM_EVENT_ROUTE_RESOLVED:
cb->state = ROUTE_RESOLVED;
- cb->child_cm_id = cma_id;
wake_up_interruptible(&cb->sem);
break;
case RDMA_CM_EVENT_CONNECT_REQUEST:
- if (cb->state == IDLE) {
- cb->state = CONNECT_REQUEST;
- cb->child_cm_id = cma_id;
- } else {
- PRINTF(cb, "Received connection request in wrong state"
- " (%d)\n", cb->state);
- }
- DEBUG_LOG(cb, "child cma %p\n", cb->child_cm_id);
+ cb->state = CONNECT_REQUEST;
+ cb->child_cm_id = cma_id;
+ DEBUG_LOG("child cma %p\n", cb->child_cm_id);
wake_up_interruptible(&cb->sem);
break;
case RDMA_CM_EVENT_ESTABLISHED:
- DEBUG_LOG(cb, "ESTABLISHED\n");
+ DEBUG_LOG("ESTABLISHED\n");
if (!cb->server) {
cb->state = CONNECTED;
}
@@ -298,24 +287,24 @@ static int krping_cma_event_handler(struct rdma_cm_id *cma_id,
case RDMA_CM_EVENT_CONNECT_ERROR:
case RDMA_CM_EVENT_UNREACHABLE:
case RDMA_CM_EVENT_REJECTED:
- PRINTF(cb, "cma event %d, error %d\n", event->event,
+ printk(KERN_ERR PFX "cma event %d, error %d\n", event->event,
event->status);
cb->state = ERROR;
wake_up_interruptible(&cb->sem);
break;
case RDMA_CM_EVENT_DISCONNECTED:
- PRINTF(cb, "DISCONNECT EVENT...\n");
+ printk(KERN_ERR PFX "DISCONNECT EVENT...\n");
cb->state = ERROR;
wake_up_interruptible(&cb->sem);
break;
case RDMA_CM_EVENT_DEVICE_REMOVAL:
- PRINTF(cb, "cma detected device removal!!!!\n");
+ printk(KERN_ERR PFX "cma detected device removal!!!!\n");
break;
default:
- PRINTF(cb, "oof bad type!\n");
+ printk(KERN_ERR PFX "oof bad type!\n");
wake_up_interruptible(&cb->sem);
break;
}
@@ -325,7 +314,7 @@ static int krping_cma_event_handler(struct rdma_cm_id *cma_id,
static int server_recv(struct krping_cb *cb, struct ib_wc *wc)
{
if (wc->byte_len != sizeof(cb->recv_buf)) {
- PRINTF(cb, "Received bogus data, size %d\n",
+ printk(KERN_ERR PFX "Received bogus data, size %d\n",
wc->byte_len);
return -1;
}
@@ -333,7 +322,7 @@ static int server_recv(struct krping_cb *cb, struct ib_wc *wc)
cb->remote_rkey = ntohl(cb->recv_buf.rkey);
cb->remote_addr = ntohll(cb->recv_buf.buf);
cb->remote_len = ntohl(cb->recv_buf.size);
- DEBUG_LOG(cb, "Received rkey %x addr %llx len %d from peer\n",
+ DEBUG_LOG("Received rkey %x addr %llx len %d from peer\n",
cb->remote_rkey, (unsigned long long)cb->remote_addr,
cb->remote_len);
@@ -348,7 +337,7 @@ static int server_recv(struct krping_cb *cb, struct ib_wc *wc)
static int client_recv(struct krping_cb *cb, struct ib_wc *wc)
{
if (wc->byte_len != sizeof(cb->recv_buf)) {
- PRINTF(cb, "Received bogus data, size %d\n",
+ printk(KERN_ERR PFX "Received bogus data, size %d\n",
wc->byte_len);
return -1;
}
@@ -370,18 +359,22 @@ static void krping_cq_event_handler(struct ib_cq *cq, void *ctx)
BUG_ON(cb->cq != cq);
if (cb->state == ERROR) {
- PRINTF(cb, "cq completion in ERROR state\n");
+ printk(KERN_ERR PFX "cq completion in ERROR state\n");
+ return;
+ }
+ if (cb->frtest) {
+ printk(KERN_ERR PFX "cq completion event in frtest!\n");
return;
}
- if (!cb->wlat && !cb->rlat && !cb->bw && !cb->frtest)
+ if (!cb->wlat && !cb->rlat && !cb->bw)
ib_req_notify_cq(cb->cq, IB_CQ_NEXT_COMP);
while ((ret = ib_poll_cq(cb->cq, 1, &wc)) == 1) {
if (wc.status) {
if (wc.status == IB_WC_WR_FLUSH_ERR) {
- DEBUG_LOG(cb, "cq flushed\n");
+ DEBUG_LOG("cq flushed\n");
continue;
} else {
- PRINTF(cb, "cq completion failed with "
+ printk(KERN_ERR PFX "cq completion failed with "
"wr_id %jx status %d opcode %d vender_err %x\n",
(uintmax_t)wc.wr_id, wc.status, wc.opcode, wc.vendor_err);
goto error;
@@ -390,44 +383,44 @@ static void krping_cq_event_handler(struct ib_cq *cq, void *ctx)
switch (wc.opcode) {
case IB_WC_SEND:
- DEBUG_LOG(cb, "send completion\n");
+ DEBUG_LOG("send completion\n");
cb->stats.send_bytes += cb->send_sgl.length;
cb->stats.send_msgs++;
break;
case IB_WC_RDMA_WRITE:
- DEBUG_LOG(cb, "rdma write completion\n");
- cb->stats.write_bytes += cb->rdma_sq_wr.sg_list->length;
+ DEBUG_LOG("rdma write completion\n");
+ cb->stats.write_bytes += cb->rdma_sq_wr.wr.sg_list->length;
cb->stats.write_msgs++;
cb->state = RDMA_WRITE_COMPLETE;
wake_up_interruptible(&cb->sem);
break;
case IB_WC_RDMA_READ:
- DEBUG_LOG(cb, "rdma read completion\n");
- cb->stats.read_bytes += cb->rdma_sq_wr.sg_list->length;
+ DEBUG_LOG("rdma read completion\n");
+ cb->stats.read_bytes += cb->rdma_sq_wr.wr.sg_list->length;
cb->stats.read_msgs++;
cb->state = RDMA_READ_COMPLETE;
wake_up_interruptible(&cb->sem);
break;
case IB_WC_RECV:
- DEBUG_LOG(cb, "recv completion\n");
+ DEBUG_LOG("recv completion\n");
cb->stats.recv_bytes += sizeof(cb->recv_buf);
cb->stats.recv_msgs++;
- if (cb->wlat || cb->rlat || cb->bw || cb->frtest)
+ if (cb->wlat || cb->rlat || cb->bw)
ret = server_recv(cb, &wc);
else
ret = cb->server ? server_recv(cb, &wc) :
client_recv(cb, &wc);
if (ret) {
- PRINTF(cb, "recv wc error: %d\n", ret);
+ printk(KERN_ERR PFX "recv wc error: %d\n", ret);
goto error;
}
ret = ib_post_recv(cb->qp, &cb->rq_wr, &bad_wr);
if (ret) {
- PRINTF(cb, "post recv error: %d\n",
+ printk(KERN_ERR PFX "post recv error: %d\n",
ret);
goto error;
}
@@ -435,14 +428,14 @@ static void krping_cq_event_handler(struct ib_cq *cq, void *ctx)
break;
default:
- PRINTF(cb,
+ printk(KERN_ERR PFX
"%s:%d Unexpected opcode %d, Shutting down\n",
__func__, __LINE__, wc.opcode);
goto error;
}
}
if (ret) {
- PRINTF(cb, "poll error %d\n", ret);
+ printk(KERN_ERR PFX "poll error %d\n", ret);
goto error;
}
return;
@@ -456,7 +449,7 @@ static int krping_accept(struct krping_cb *cb)
struct rdma_conn_param conn_param;
int ret;
- DEBUG_LOG(cb, "accepting client connection request\n");
+ DEBUG_LOG("accepting client connection request\n");
memset(&conn_param, 0, sizeof conn_param);
conn_param.responder_resources = 1;
@@ -464,14 +457,14 @@ static int krping_accept(struct krping_cb *cb)
ret = rdma_accept(cb->child_cm_id, &conn_param);
if (ret) {
- PRINTF(cb, "rdma_accept error: %d\n", ret);
+ printk(KERN_ERR PFX "rdma_accept error: %d\n", ret);
return ret;
}
- if (!cb->wlat && !cb->rlat && !cb->bw && !cb->frtest) {
+ if (!cb->wlat && !cb->rlat && !cb->bw) {
wait_event_interruptible(cb->sem, cb->state >= CONNECTED);
if (cb->state == ERROR) {
- PRINTF(cb, "wait for CONNECTED state %d\n",
+ printk(KERN_ERR PFX "wait for CONNECTED state %d\n",
cb->state);
return -1;
}
@@ -483,278 +476,120 @@ static void krping_setup_wr(struct krping_cb *cb)
{
cb->recv_sgl.addr = cb->recv_dma_addr;
cb->recv_sgl.length = sizeof cb->recv_buf;
- if (cb->local_dma_lkey)
- cb->recv_sgl.lkey = cb->qp->device->local_dma_lkey;
- else if (cb->mem == DMA)
- cb->recv_sgl.lkey = cb->dma_mr->lkey;
- else
- cb->recv_sgl.lkey = cb->recv_mr->lkey;
+ cb->recv_sgl.lkey = cb->pd->local_dma_lkey;
cb->rq_wr.sg_list = &cb->recv_sgl;
cb->rq_wr.num_sge = 1;
cb->send_sgl.addr = cb->send_dma_addr;
cb->send_sgl.length = sizeof cb->send_buf;
- if (cb->local_dma_lkey)
- cb->send_sgl.lkey = cb->qp->device->local_dma_lkey;
- else if (cb->mem == DMA)
- cb->send_sgl.lkey = cb->dma_mr->lkey;
- else
- cb->send_sgl.lkey = cb->send_mr->lkey;
+ cb->send_sgl.lkey = cb->pd->local_dma_lkey;
cb->sq_wr.opcode = IB_WR_SEND;
cb->sq_wr.send_flags = IB_SEND_SIGNALED;
cb->sq_wr.sg_list = &cb->send_sgl;
cb->sq_wr.num_sge = 1;
- if (cb->server || cb->wlat || cb->rlat || cb->bw || cb->frtest) {
+ if (cb->server || cb->wlat || cb->rlat || cb->bw) {
cb->rdma_sgl.addr = cb->rdma_dma_addr;
- if (cb->mem == MR)
- cb->rdma_sgl.lkey = cb->rdma_mr->lkey;
- cb->rdma_sq_wr.send_flags = IB_SEND_SIGNALED;
- cb->rdma_sq_wr.sg_list = &cb->rdma_sgl;
- cb->rdma_sq_wr.num_sge = 1;
- }
-
- switch(cb->mem) {
- case FASTREG:
-
- /*
- * A chain of 2 WRs, INVALDATE_MR + FAST_REG_MR.
- * both unsignaled. The client uses them to reregister
- * the rdma buffers with a new key each iteration.
- */
- cb->fastreg_wr.opcode = IB_WR_FAST_REG_MR;
- cb->fastreg_wr.wr.fast_reg.page_shift = PAGE_SHIFT;
- cb->fastreg_wr.wr.fast_reg.length = cb->size;
- cb->fastreg_wr.wr.fast_reg.page_list = cb->page_list;
- cb->fastreg_wr.wr.fast_reg.page_list_len = cb->page_list_len;
-
- cb->invalidate_wr.next = &cb->fastreg_wr;
- cb->invalidate_wr.opcode = IB_WR_LOCAL_INV;
- break;
- case MW:
- cb->bind_attr.wr_id = 0xabbaabba;
- cb->bind_attr.send_flags = 0; /* unsignaled */
-#ifdef BIND_INFO
- cb->bind_attr.bind_info.length = cb->size;
-#else
- cb->bind_attr.length = cb->size;
-#endif
- break;
- default:
- break;
+ cb->rdma_sq_wr.wr.send_flags = IB_SEND_SIGNALED;
+ cb->rdma_sq_wr.wr.sg_list = &cb->rdma_sgl;
+ cb->rdma_sq_wr.wr.num_sge = 1;
}
+
+ /*
+ * A chain of 2 WRs, INVALDATE_MR + REG_MR.
+ * both unsignaled. The client uses them to reregister
+ * the rdma buffers with a new key each iteration.
+ */
+ cb->reg_mr_wr.wr.opcode = IB_WR_REG_MR;
+ cb->reg_mr_wr.mr = cb->reg_mr;
+
+ cb->invalidate_wr.next = &cb->reg_mr_wr.wr;
+ cb->invalidate_wr.opcode = IB_WR_LOCAL_INV;
}
static int krping_setup_buffers(struct krping_cb *cb)
{
int ret;
- struct ib_phys_buf buf;
- u64 iovbase;
- DEBUG_LOG(cb, "krping_setup_buffers called on cb %p\n", cb);
+ DEBUG_LOG(PFX "krping_setup_buffers called on cb %p\n", cb);
- cb->recv_dma_addr = dma_map_single(cb->pd->device->dma_device,
+ cb->recv_dma_addr = ib_dma_map_single(cb->pd->device,
&cb->recv_buf,
sizeof(cb->recv_buf), DMA_BIDIRECTIONAL);
pci_unmap_addr_set(cb, recv_mapping, cb->recv_dma_addr);
- cb->send_dma_addr = dma_map_single(cb->pd->device->dma_device,
+ cb->send_dma_addr = ib_dma_map_single(cb->pd->device,
&cb->send_buf, sizeof(cb->send_buf),
DMA_BIDIRECTIONAL);
pci_unmap_addr_set(cb, send_mapping, cb->send_dma_addr);
- if (cb->mem == DMA) {
- cb->dma_mr = ib_get_dma_mr(cb->pd, IB_ACCESS_LOCAL_WRITE|
- IB_ACCESS_REMOTE_READ|
- IB_ACCESS_REMOTE_WRITE);
- if (IS_ERR(cb->dma_mr)) {
- DEBUG_LOG(cb, "reg_dmamr failed\n");
- ret = PTR_ERR(cb->dma_mr);
- goto bail;
- }
- } else {
- if (!cb->local_dma_lkey) {
- buf.addr = cb->recv_dma_addr;
- buf.size = sizeof cb->recv_buf;
- DEBUG_LOG(cb, "recv buf dma_addr %jx size %d\n",
- (uintmax_t)buf.addr, (int)buf.size);
- iovbase = cb->recv_dma_addr;
- cb->recv_mr = ib_reg_phys_mr(cb->pd, &buf, 1,
- IB_ACCESS_LOCAL_WRITE,
- &iovbase);
-
- if (IS_ERR(cb->recv_mr)) {
- DEBUG_LOG(cb, "recv_buf reg_mr failed\n");
- ret = PTR_ERR(cb->recv_mr);
- goto bail;
- }
-
- buf.addr = cb->send_dma_addr;
- buf.size = sizeof cb->send_buf;
- DEBUG_LOG(cb, "send buf dma_addr %jx size %d\n",
- (uintmax_t)buf.addr, (int)buf.size);
- iovbase = cb->send_dma_addr;
- cb->send_mr = ib_reg_phys_mr(cb->pd, &buf, 1,
- 0, &iovbase);
-
- if (IS_ERR(cb->send_mr)) {
- DEBUG_LOG(cb, "send_buf reg_mr failed\n");
- ret = PTR_ERR(cb->send_mr);
- goto bail;
- }
- }
- }
-
- cb->rdma_buf = kmalloc(cb->size, GFP_KERNEL);
+ cb->rdma_buf = ib_dma_alloc_coherent(cb->pd->device, cb->size,
+ &cb->rdma_dma_addr,
+ GFP_KERNEL);
if (!cb->rdma_buf) {
- DEBUG_LOG(cb, "rdma_buf malloc failed\n");
+ DEBUG_LOG(PFX "rdma_buf allocation failed\n");
ret = -ENOMEM;
goto bail;
}
-
- cb->rdma_dma_addr = dma_map_single(cb->pd->device->dma_device,
- cb->rdma_buf, cb->size,
- DMA_BIDIRECTIONAL);
pci_unmap_addr_set(cb, rdma_mapping, cb->rdma_dma_addr);
- if (cb->mem != DMA) {
- switch (cb->mem) {
- case FASTREG:
- cb->page_list_len = (((cb->size - 1) & PAGE_MASK) +
- PAGE_SIZE) >> PAGE_SHIFT;
- cb->page_list = ib_alloc_fast_reg_page_list(
- cb->pd->device,
- cb->page_list_len);
- if (IS_ERR(cb->page_list)) {
- DEBUG_LOG(cb, "recv_buf reg_mr failed\n");
- ret = PTR_ERR(cb->page_list);
- goto bail;
- }
- cb->fastreg_mr = ib_alloc_fast_reg_mr(cb->pd,
- cb->page_list->max_page_list_len);
- if (IS_ERR(cb->fastreg_mr)) {
- DEBUG_LOG(cb, "recv_buf reg_mr failed\n");
- ret = PTR_ERR(cb->fastreg_mr);
- goto bail;
- }
- DEBUG_LOG(cb, "fastreg rkey 0x%x page_list %p"
- " page_list_len %u\n", cb->fastreg_mr->rkey,
- cb->page_list, cb->page_list_len);
- break;
- case MW:
- cb->mw = ib_alloc_mw(cb->pd,IB_MW_TYPE_1);
- if (IS_ERR(cb->mw)) {
- DEBUG_LOG(cb, "recv_buf alloc_mw failed\n");
- ret = PTR_ERR(cb->mw);
- goto bail;
- }
- DEBUG_LOG(cb, "mw rkey 0x%x\n", cb->mw->rkey);
- /*FALLTHROUGH*/
- case MR:
- buf.addr = cb->rdma_dma_addr;
- buf.size = cb->size;
- iovbase = cb->rdma_dma_addr;
- cb->rdma_mr = ib_reg_phys_mr(cb->pd, &buf, 1,
- IB_ACCESS_LOCAL_WRITE|
- IB_ACCESS_REMOTE_READ|
- IB_ACCESS_REMOTE_WRITE,
- &iovbase);
- if (IS_ERR(cb->rdma_mr)) {
- DEBUG_LOG(cb, "rdma_buf reg_mr failed\n");
- ret = PTR_ERR(cb->rdma_mr);
- goto bail;
- }
- DEBUG_LOG(cb, "rdma buf dma_addr %jx size %d mr rkey 0x%x\n",
- (uintmax_t)buf.addr, (int)buf.size, cb->rdma_mr->rkey);
- break;
- default:
- ret = -EINVAL;
- goto bail;
- break;
- }
+ cb->page_list_len = (((cb->size - 1) & PAGE_MASK) + PAGE_SIZE)
+ >> PAGE_SHIFT;
+ cb->reg_mr = ib_alloc_mr(cb->pd, IB_MR_TYPE_MEM_REG,
+ cb->page_list_len);
+ if (IS_ERR(cb->reg_mr)) {
+ ret = PTR_ERR(cb->reg_mr);
+ DEBUG_LOG(PFX "recv_buf reg_mr failed %d\n", ret);
+ goto bail;
}
+ DEBUG_LOG(PFX "reg rkey 0x%x page_list_len %u\n",
+ cb->reg_mr->rkey, cb->page_list_len);
- if (!cb->server || cb->wlat || cb->rlat || cb->bw || cb->frtest) {
+ if (!cb->server || cb->wlat || cb->rlat || cb->bw) {
- cb->start_buf = kmalloc(cb->size, GFP_KERNEL);
+ cb->start_buf = ib_dma_alloc_coherent(cb->pd->device, cb->size,
+ &cb->start_dma_addr,
+ GFP_KERNEL);
if (!cb->start_buf) {
- DEBUG_LOG(cb, "start_buf malloc failed\n");
+ DEBUG_LOG(PFX "start_buf malloc failed\n");
ret = -ENOMEM;
goto bail;
}
-
- cb->start_dma_addr = dma_map_single(cb->pd->device->dma_device,
- cb->start_buf, cb->size,
- DMA_BIDIRECTIONAL);
pci_unmap_addr_set(cb, start_mapping, cb->start_dma_addr);
-
- if (cb->mem == MR || cb->mem == MW) {
- unsigned flags = IB_ACCESS_REMOTE_READ;
-
- if (cb->wlat || cb->rlat || cb->bw || cb->frtest) {
- flags |= IB_ACCESS_LOCAL_WRITE |
- IB_ACCESS_REMOTE_WRITE;
- }
-
- buf.addr = cb->start_dma_addr;
- buf.size = cb->size;
- DEBUG_LOG(cb, "start buf dma_addr %jx size %d\n",
- (uintmax_t)buf.addr, (int)buf.size);
- iovbase = cb->start_dma_addr;
- cb->start_mr = ib_reg_phys_mr(cb->pd, &buf, 1,
- flags,
- &iovbase);
-
- if (IS_ERR(cb->start_mr)) {
- DEBUG_LOG(cb, "start_buf reg_mr failed\n");
- ret = PTR_ERR(cb->start_mr);
- goto bail;
- }
- }
}
krping_setup_wr(cb);
- DEBUG_LOG(cb, "allocated & registered buffers...\n");
+ DEBUG_LOG(PFX "allocated & registered buffers...\n");
return 0;
bail:
- if (cb->fastreg_mr && !IS_ERR(cb->fastreg_mr))
- ib_dereg_mr(cb->fastreg_mr);
- if (cb->mw && !IS_ERR(cb->mw))
- ib_dealloc_mw(cb->mw);
+ if (cb->reg_mr && !IS_ERR(cb->reg_mr))
+ ib_dereg_mr(cb->reg_mr);
if (cb->rdma_mr && !IS_ERR(cb->rdma_mr))
ib_dereg_mr(cb->rdma_mr);
- if (cb->page_list && !IS_ERR(cb->page_list))
- ib_free_fast_reg_page_list(cb->page_list);
if (cb->dma_mr && !IS_ERR(cb->dma_mr))
ib_dereg_mr(cb->dma_mr);
- if (cb->recv_mr && !IS_ERR(cb->recv_mr))
- ib_dereg_mr(cb->recv_mr);
- if (cb->send_mr && !IS_ERR(cb->send_mr))
- ib_dereg_mr(cb->send_mr);
- if (cb->rdma_buf)
- kfree(cb->rdma_buf);
- if (cb->start_buf)
- kfree(cb->start_buf);
+ if (cb->rdma_buf) {
+ ib_dma_free_coherent(cb->pd->device, cb->size, cb->rdma_buf,
+ cb->rdma_dma_addr);
+ }
+ if (cb->start_buf) {
+ ib_dma_free_coherent(cb->pd->device, cb->size, cb->start_buf,
+ cb->start_dma_addr);
+ }
return ret;
}
static void krping_free_buffers(struct krping_cb *cb)
{
- DEBUG_LOG(cb, "krping_free_buffers called on cb %p\n", cb);
+ DEBUG_LOG("krping_free_buffers called on cb %p\n", cb);
if (cb->dma_mr)
ib_dereg_mr(cb->dma_mr);
- if (cb->send_mr)
- ib_dereg_mr(cb->send_mr);
- if (cb->recv_mr)
- ib_dereg_mr(cb->recv_mr);
if (cb->rdma_mr)
ib_dereg_mr(cb->rdma_mr);
if (cb->start_mr)
ib_dereg_mr(cb->start_mr);
- if (cb->fastreg_mr)
- ib_dereg_mr(cb->fastreg_mr);
- if (cb->mw)
- ib_dealloc_mw(cb->mw);
+ if (cb->reg_mr)
+ ib_dereg_mr(cb->reg_mr);
dma_unmap_single(cb->pd->device->dma_device,
pci_unmap_addr(cb, recv_mapping),
@@ -762,15 +597,13 @@ static void krping_free_buffers(struct krping_cb *cb)
dma_unmap_single(cb->pd->device->dma_device,
pci_unmap_addr(cb, send_mapping),
sizeof(cb->send_buf), DMA_BIDIRECTIONAL);
- dma_unmap_single(cb->pd->device->dma_device,
- pci_unmap_addr(cb, rdma_mapping),
- cb->size, DMA_BIDIRECTIONAL);
- kfree(cb->rdma_buf);
+
+ ib_dma_free_coherent(cb->pd->device, cb->size, cb->rdma_buf,
+ cb->rdma_dma_addr);
+
if (cb->start_buf) {
- dma_unmap_single(cb->pd->device->dma_device,
- pci_unmap_addr(cb, start_mapping),
- cb->size, DMA_BIDIRECTIONAL);
- kfree(cb->start_buf);
+ ib_dma_free_coherent(cb->pd->device, cb->size, cb->start_buf,
+ cb->start_dma_addr);
}
}
@@ -782,6 +615,11 @@ static int krping_create_qp(struct krping_cb *cb)
memset(&init_attr, 0, sizeof(init_attr));
init_attr.cap.max_send_wr = cb->txdepth;
init_attr.cap.max_recv_wr = 2;
+
+ /* For flush_qp() */
+ init_attr.cap.max_send_wr++;
+ init_attr.cap.max_recv_wr++;
+
init_attr.cap.max_recv_sge = 1;
init_attr.cap.max_send_sge = 1;
init_attr.qp_type = IB_QPT_RC;
@@ -812,38 +650,42 @@ static void krping_free_qp(struct krping_cb *cb)
static int krping_setup_qp(struct krping_cb *cb, struct rdma_cm_id *cm_id)
{
int ret;
- cb->pd = ib_alloc_pd(cm_id->device);
+ struct ib_cq_init_attr attr = {0};
+
+ cb->pd = ib_alloc_pd(cm_id->device, 0);
if (IS_ERR(cb->pd)) {
- PRINTF(cb, "ib_alloc_pd failed\n");
+ printk(KERN_ERR PFX "ib_alloc_pd failed\n");
return PTR_ERR(cb->pd);
}
- DEBUG_LOG(cb, "created pd %p\n", cb->pd);
+ DEBUG_LOG("created pd %p\n", cb->pd);
strlcpy(cb->stats.name, cb->pd->device->name, sizeof(cb->stats.name));
+ attr.cqe = cb->txdepth * 2;
+ attr.comp_vector = 0;
cb->cq = ib_create_cq(cm_id->device, krping_cq_event_handler, NULL,
- cb, cb->txdepth * 2, 0);
+ cb, &attr);
if (IS_ERR(cb->cq)) {
- PRINTF(cb, "ib_create_cq failed\n");
+ printk(KERN_ERR PFX "ib_create_cq failed\n");
ret = PTR_ERR(cb->cq);
goto err1;
}
- DEBUG_LOG(cb, "created cq %p\n", cb->cq);
+ DEBUG_LOG("created cq %p\n", cb->cq);
if (!cb->wlat && !cb->rlat && !cb->bw && !cb->frtest) {
ret = ib_req_notify_cq(cb->cq, IB_CQ_NEXT_COMP);
if (ret) {
- PRINTF(cb, "ib_create_cq failed\n");
+ printk(KERN_ERR PFX "ib_create_cq failed\n");
goto err2;
}
}
ret = krping_create_qp(cb);
if (ret) {
- PRINTF(cb, "krping_create_qp failed: %d\n", ret);
+ printk(KERN_ERR PFX "krping_create_qp failed: %d\n", ret);
goto err2;
}
- DEBUG_LOG(cb, "created qp %p\n", cb->qp);
+ DEBUG_LOG("created qp %p\n", cb->qp);
return 0;
err2:
ib_destroy_cq(cb->cq);
@@ -854,115 +696,54 @@ err1:
/*
* return the (possibly rebound) rkey for the rdma buffer.
- * FASTREG mode: invalidate and rebind via fastreg wr.
- * MW mode: rebind the MW.
+ * REG mode: invalidate and rebind via reg wr.
* other modes: just return the mr rkey.
*/
static u32 krping_rdma_rkey(struct krping_cb *cb, u64 buf, int post_inv)
{
- u32 rkey = 0xffffffff;
- u64 p;
+ u32 rkey;
struct ib_send_wr *bad_wr;
- int i;
int ret;
+ struct scatterlist sg = {0};
- switch (cb->mem) {
- case FASTREG:
- cb->invalidate_wr.ex.invalidate_rkey = cb->fastreg_mr->rkey;
-
- /*
- * Update the fastreg key.
- */
- ib_update_fast_reg_key(cb->fastreg_mr, ++cb->key);
- cb->fastreg_wr.wr.fast_reg.rkey = cb->fastreg_mr->rkey;
-
- /*
- * Update the fastreg WR with new buf info.
- */
- if (buf == (u64)cb->start_dma_addr)
- cb->fastreg_wr.wr.fast_reg.access_flags = IB_ACCESS_REMOTE_READ;
- else
- cb->fastreg_wr.wr.fast_reg.access_flags = IB_ACCESS_REMOTE_WRITE | IB_ACCESS_LOCAL_WRITE;
- cb->fastreg_wr.wr.fast_reg.iova_start = buf;
- p = (u64)(buf & PAGE_MASK);
- for (i=0; i < cb->fastreg_wr.wr.fast_reg.page_list_len;
- i++, p += PAGE_SIZE) {
- cb->page_list->page_list[i] = p;
- DEBUG_LOG(cb, "page_list[%d] 0x%jx\n", i, (uintmax_t)p);
- }
+ cb->invalidate_wr.ex.invalidate_rkey = cb->reg_mr->rkey;
- DEBUG_LOG(cb, "post_inv = %d, fastreg new rkey 0x%x shift %u len %u"
- " iova_start %jx page_list_len %u\n",
- post_inv,
- cb->fastreg_wr.wr.fast_reg.rkey,
- cb->fastreg_wr.wr.fast_reg.page_shift,
- (unsigned)cb->fastreg_wr.wr.fast_reg.length,
- (uintmax_t)cb->fastreg_wr.wr.fast_reg.iova_start,
- cb->fastreg_wr.wr.fast_reg.page_list_len);
-
- if (post_inv)
- ret = ib_post_send(cb->qp, &cb->invalidate_wr, &bad_wr);
- else
- ret = ib_post_send(cb->qp, &cb->fastreg_wr, &bad_wr);
- if (ret) {
- PRINTF(cb, "post send error %d\n", ret);
- cb->state = ERROR;
- }
- rkey = cb->fastreg_mr->rkey;
- break;
- case MW:
- /*
- * Update the MW with new buf info.
- */
- if (buf == (u64)cb->start_dma_addr) {
-#ifdef BIND_INFO
- cb->bind_attr.bind_info.mw_access_flags = IB_ACCESS_REMOTE_READ;
- cb->bind_attr.bind_info.mr = cb->start_mr;
-#else
- cb->bind_attr.mw_access_flags = IB_ACCESS_REMOTE_READ;
- cb->bind_attr.mr = cb->start_mr;
-#endif
- } else {
-#ifdef BIND_INFO
- cb->bind_attr.bind_info.mw_access_flags = IB_ACCESS_REMOTE_WRITE;
- cb->bind_attr.bind_info.mr = cb->rdma_mr;
-#else
- cb->bind_attr.mw_access_flags = IB_ACCESS_REMOTE_WRITE;
- cb->bind_attr.mr = cb->rdma_mr;
-#endif
- }
-#ifdef BIND_INFO
- cb->bind_attr.bind_info.addr = buf;
-#else
- cb->bind_attr.addr = buf;
-#endif
- DEBUG_LOG(cb, "binding mw rkey 0x%x to buf %jx mr rkey 0x%x\n",
-#ifdef BIND_INFO
- cb->mw->rkey, (uintmax_t)buf, cb->bind_attr.bind_info.mr->rkey);
-#else
- cb->mw->rkey, buf, cb->bind_attr.mr->rkey);
-#endif
- ret = ib_bind_mw(cb->qp, cb->mw, &cb->bind_attr);
- if (ret) {
- PRINTF(cb, "bind mw error %d\n", ret);
- cb->state = ERROR;
- } else
- rkey = cb->mw->rkey;
- break;
- case MR:
- if (buf == (u64)cb->start_dma_addr)
- rkey = cb->start_mr->rkey;
- else
- rkey = cb->rdma_mr->rkey;
- break;
- case DMA:
- rkey = cb->dma_mr->rkey;
- break;
- default:
- PRINTF(cb, "%s:%d case ERROR\n", __func__, __LINE__);
+ /*
+ * Update the reg key.
+ */
+ ib_update_fast_reg_key(cb->reg_mr, ++cb->key);
+ cb->reg_mr_wr.key = cb->reg_mr->rkey;
+
+ /*
+ * Update the reg WR with new buf info.
+ */
+ if (buf == (u64)cb->start_dma_addr)
+ cb->reg_mr_wr.access = IB_ACCESS_REMOTE_READ;
+ else
+ cb->reg_mr_wr.access = IB_ACCESS_REMOTE_WRITE | IB_ACCESS_LOCAL_WRITE;
+ sg_dma_address(&sg) = buf;
+ sg_dma_len(&sg) = cb->size;
+
+ ret = ib_map_mr_sg(cb->reg_mr, &sg, 1, NULL, PAGE_SIZE);
+ BUG_ON(ret <= 0 || ret > cb->page_list_len);
+
+ DEBUG_LOG(PFX "post_inv = %d, reg_mr new rkey 0x%x pgsz %u len %u"
+ " iova_start %llx\n",
+ post_inv,
+ cb->reg_mr_wr.key,
+ cb->reg_mr->page_size,
+ cb->reg_mr->length,
+ (unsigned long long)cb->reg_mr->iova);
+
+ if (post_inv)
+ ret = ib_post_send(cb->qp, &cb->invalidate_wr, &bad_wr);
+ else
+ ret = ib_post_send(cb->qp, &cb->reg_mr_wr.wr, &bad_wr);
+ if (ret) {
+ printk(KERN_ERR PFX "post send error %d\n", ret);
cb->state = ERROR;
- break;
}
+ rkey = cb->reg_mr->rkey;
return rkey;
}
@@ -972,16 +753,16 @@ static void krping_format_send(struct krping_cb *cb, u64 buf)
u32 rkey;
/*
- * Client side will do fastreg or mw bind before
+ * Client side will do reg or mw bind before
* advertising the rdma buffer. Server side
* sends have no data.
*/
- if (!cb->server || cb->wlat || cb->rlat || cb->bw || cb->frtest) {
+ if (!cb->server || cb->wlat || cb->rlat || cb->bw) {
rkey = krping_rdma_rkey(cb, buf, !cb->server_invalidate);
info->buf = htonll(buf);
info->rkey = htonl(rkey);
info->size = htonl(cb->size);
- DEBUG_LOG(cb, "RDMA addr %llx rkey %x len %d\n",
+ DEBUG_LOG("RDMA addr %llx rkey %x len %d\n",
(unsigned long long)buf, rkey, cb->size);
}
}
@@ -995,111 +776,102 @@ static void krping_test_server(struct krping_cb *cb)
/* Wait for client's Start STAG/TO/Len */
wait_event_interruptible(cb->sem, cb->state >= RDMA_READ_ADV);
if (cb->state != RDMA_READ_ADV) {
- PRINTF(cb, "wait for RDMA_READ_ADV state %d\n",
+ printk(KERN_ERR PFX "wait for RDMA_READ_ADV state %d\n",
cb->state);
break;
}
- DEBUG_LOG(cb, "server received sink adv\n");
+ DEBUG_LOG("server received sink adv\n");
- cb->rdma_sq_wr.wr.rdma.rkey = cb->remote_rkey;
- cb->rdma_sq_wr.wr.rdma.remote_addr = cb->remote_addr;
- cb->rdma_sq_wr.sg_list->length = cb->remote_len;
- cb->rdma_sgl.lkey = krping_rdma_rkey(cb, cb->rdma_dma_addr, 1);
+ cb->rdma_sq_wr.rkey = cb->remote_rkey;
+ cb->rdma_sq_wr.remote_addr = cb->remote_addr;
+ cb->rdma_sq_wr.wr.sg_list->length = cb->remote_len;
+ cb->rdma_sgl.lkey = krping_rdma_rkey(cb, cb->rdma_dma_addr, !cb->read_inv);
+ cb->rdma_sq_wr.wr.next = NULL;
/* Issue RDMA Read. */
if (cb->read_inv)
- cb->rdma_sq_wr.opcode = IB_WR_RDMA_READ_WITH_INV;
+ cb->rdma_sq_wr.wr.opcode = IB_WR_RDMA_READ_WITH_INV;
else {
- cb->rdma_sq_wr.opcode = IB_WR_RDMA_READ;
- if (cb->mem == FASTREG) {
- /*
- * Immediately follow the read with a
- * fenced LOCAL_INV.
- */
- cb->rdma_sq_wr.next = &inv;
- memset(&inv, 0, sizeof inv);
- inv.opcode = IB_WR_LOCAL_INV;
- inv.ex.invalidate_rkey = cb->fastreg_mr->rkey;
- inv.send_flags = IB_SEND_FENCE;
- }
+ cb->rdma_sq_wr.wr.opcode = IB_WR_RDMA_READ;
+ /*
+ * Immediately follow the read with a
+ * fenced LOCAL_INV.
+ */
+ cb->rdma_sq_wr.wr.next = &inv;
+ memset(&inv, 0, sizeof inv);
+ inv.opcode = IB_WR_LOCAL_INV;
+ inv.ex.invalidate_rkey = cb->reg_mr->rkey;
+ inv.send_flags = IB_SEND_FENCE;
}
- ret = ib_post_send(cb->qp, &cb->rdma_sq_wr, &bad_wr);
+ ret = ib_post_send(cb->qp, &cb->rdma_sq_wr.wr, &bad_wr);
if (ret) {
- PRINTF(cb, "post send error %d\n", ret);
+ printk(KERN_ERR PFX "post send error %d\n", ret);
break;
}
- cb->rdma_sq_wr.next = NULL;
+ cb->rdma_sq_wr.wr.next = NULL;
- DEBUG_LOG(cb, "server posted rdma read req \n");
+ DEBUG_LOG("server posted rdma read req \n");
/* Wait for read completion */
wait_event_interruptible(cb->sem,
cb->state >= RDMA_READ_COMPLETE);
if (cb->state != RDMA_READ_COMPLETE) {
- PRINTF(cb,
+ printk(KERN_ERR PFX
"wait for RDMA_READ_COMPLETE state %d\n",
cb->state);
break;
}
- DEBUG_LOG(cb, "server received read complete\n");
+ DEBUG_LOG("server received read complete\n");
/* Display data in recv buf */
- if (cb->verbose) {
- if (strlen(cb->rdma_buf) > 128) {
- char msgbuf[128];
-
- strlcpy(msgbuf, cb->rdma_buf, sizeof(msgbuf));
- PRINTF(cb, "server ping data stripped: %s\n",
- msgbuf);
- } else
- PRINTF(cb, "server ping data: %s\n",
- cb->rdma_buf);
- }
+ if (cb->verbose)
+ printk(KERN_INFO PFX "server ping data: %s\n",
+ cb->rdma_buf);
/* Tell client to continue */
if (cb->server && cb->server_invalidate) {
cb->sq_wr.ex.invalidate_rkey = cb->remote_rkey;
cb->sq_wr.opcode = IB_WR_SEND_WITH_INV;
- DEBUG_LOG(cb, "send-w-inv rkey 0x%x\n", cb->remote_rkey);
+ DEBUG_LOG("send-w-inv rkey 0x%x\n", cb->remote_rkey);
}
ret = ib_post_send(cb->qp, &cb->sq_wr, &bad_wr);
if (ret) {
- PRINTF(cb, "post send error %d\n", ret);
+ printk(KERN_ERR PFX "post send error %d\n", ret);
break;
}
- DEBUG_LOG(cb, "server posted go ahead\n");
+ DEBUG_LOG("server posted go ahead\n");
/* Wait for client's RDMA STAG/TO/Len */
wait_event_interruptible(cb->sem, cb->state >= RDMA_WRITE_ADV);
if (cb->state != RDMA_WRITE_ADV) {
- PRINTF(cb,
+ printk(KERN_ERR PFX
"wait for RDMA_WRITE_ADV state %d\n",
cb->state);
break;
}
- DEBUG_LOG(cb, "server received sink adv\n");
+ DEBUG_LOG("server received sink adv\n");
/* RDMA Write echo data */
- cb->rdma_sq_wr.opcode = IB_WR_RDMA_WRITE;
- cb->rdma_sq_wr.wr.rdma.rkey = cb->remote_rkey;
- cb->rdma_sq_wr.wr.rdma.remote_addr = cb->remote_addr;
- cb->rdma_sq_wr.sg_list->length = strlen(cb->rdma_buf) + 1;
+ cb->rdma_sq_wr.wr.opcode = IB_WR_RDMA_WRITE;
+ cb->rdma_sq_wr.rkey = cb->remote_rkey;
+ cb->rdma_sq_wr.remote_addr = cb->remote_addr;
+ cb->rdma_sq_wr.wr.sg_list->length = strlen(cb->rdma_buf) + 1;
if (cb->local_dma_lkey)
- cb->rdma_sgl.lkey = cb->qp->device->local_dma_lkey;
+ cb->rdma_sgl.lkey = cb->pd->local_dma_lkey;
else
cb->rdma_sgl.lkey = krping_rdma_rkey(cb, cb->rdma_dma_addr, 0);
- DEBUG_LOG(cb, "rdma write from lkey %x laddr %llx len %d\n",
- cb->rdma_sq_wr.sg_list->lkey,
- (unsigned long long)cb->rdma_sq_wr.sg_list->addr,
- cb->rdma_sq_wr.sg_list->length);
+ DEBUG_LOG("rdma write from lkey %x laddr %llx len %d\n",
+ cb->rdma_sq_wr.wr.sg_list->lkey,
+ (unsigned long long)cb->rdma_sq_wr.wr.sg_list->addr,
+ cb->rdma_sq_wr.wr.sg_list->length);
- ret = ib_post_send(cb->qp, &cb->rdma_sq_wr, &bad_wr);
+ ret = ib_post_send(cb->qp, &cb->rdma_sq_wr.wr, &bad_wr);
if (ret) {
- PRINTF(cb, "post send error %d\n", ret);
+ printk(KERN_ERR PFX "post send error %d\n", ret);
break;
}
@@ -1107,12 +879,12 @@ static void krping_test_server(struct krping_cb *cb)
ret = wait_event_interruptible(cb->sem, cb->state >=
RDMA_WRITE_COMPLETE);
if (cb->state != RDMA_WRITE_COMPLETE) {
- PRINTF(cb,
+ printk(KERN_ERR PFX
"wait for RDMA_WRITE_COMPLETE state %d\n",
cb->state);
break;
}
- DEBUG_LOG(cb, "server rdma write complete \n");
+ DEBUG_LOG("server rdma write complete \n");
cb->state = CONNECTED;
@@ -1120,14 +892,14 @@ static void krping_test_server(struct krping_cb *cb)
if (cb->server && cb->server_invalidate) {
cb->sq_wr.ex.invalidate_rkey = cb->remote_rkey;
cb->sq_wr.opcode = IB_WR_SEND_WITH_INV;
- DEBUG_LOG(cb, "send-w-inv rkey 0x%x\n", cb->remote_rkey);
+ DEBUG_LOG("send-w-inv rkey 0x%x\n", cb->remote_rkey);
}
ret = ib_post_send(cb->qp, &cb->sq_wr, &bad_wr);
if (ret) {
- PRINTF(cb, "post send error %d\n", ret);
+ printk(KERN_ERR PFX "post send error %d\n", ret);
break;
}
- DEBUG_LOG(cb, "server posted go ahead\n");
+ DEBUG_LOG("server posted go ahead\n");
}
}
@@ -1142,10 +914,10 @@ static void rlat_test(struct krping_cb *cb)
int ne;
scnt = 0;
- cb->rdma_sq_wr.opcode = IB_WR_RDMA_READ;
- cb->rdma_sq_wr.wr.rdma.rkey = cb->remote_rkey;
- cb->rdma_sq_wr.wr.rdma.remote_addr = cb->remote_addr;
- cb->rdma_sq_wr.sg_list->length = cb->size;
+ cb->rdma_sq_wr.wr.opcode = IB_WR_RDMA_READ;
+ cb->rdma_sq_wr.rkey = cb->remote_rkey;
+ cb->rdma_sq_wr.remote_addr = cb->remote_addr;
+ cb->rdma_sq_wr.wr.sg_list->length = cb->size;
microtime(&start_tv);
if (!cb->poll) {
@@ -1155,9 +927,9 @@ static void rlat_test(struct krping_cb *cb)
while (scnt < iters) {
cb->state = RDMA_READ_ADV;
- ret = ib_post_send(cb->qp, &cb->rdma_sq_wr, &bad_wr);
+ ret = ib_post_send(cb->qp, &cb->rdma_sq_wr.wr, &bad_wr);
if (ret) {
- PRINTF(cb,
+ printk(KERN_ERR PFX
"Couldn't post send: ret=%d scnt %d\n",
ret, scnt);
return;
@@ -1177,7 +949,7 @@ static void rlat_test(struct krping_cb *cb)
} else
ne = ib_poll_cq(cb->cq, 1, &wc);
if (cb->state == ERROR) {
- PRINTF(cb,
+ printk(KERN_ERR PFX
"state == ERROR...bailing scnt %d\n",
scnt);
return;
@@ -1185,13 +957,13 @@ static void rlat_test(struct krping_cb *cb)
} while (ne == 0);
if (ne < 0) {
- PRINTF(cb, "poll CQ failed %d\n", ne);
+ printk(KERN_ERR PFX "poll CQ failed %d\n", ne);
return;
}
if (cb->poll && wc.status != IB_WC_SUCCESS) {
- PRINTF(cb, "Completion wth error at %s:\n",
+ printk(KERN_ERR PFX "Completion wth error at %s:\n",
cb->server ? "server" : "client");
- PRINTF(cb, "Failed status %d: wr_id %d\n",
+ printk(KERN_ERR PFX "Failed status %d: wr_id %d\n",
wc.status, (int) wc.wr_id);
return;
}
@@ -1204,7 +976,7 @@ static void rlat_test(struct krping_cb *cb)
stop_tv.tv_sec -= 1;
}
- PRINTF(cb, "delta sec %lu delta usec %lu iter %d size %d\n",
+ printk(KERN_ERR PFX "delta sec %lu delta usec %lu iter %d size %d\n",
(unsigned long)(stop_tv.tv_sec - start_tv.tv_sec),
(unsigned long)(stop_tv.tv_usec - start_tv.tv_usec),
scnt, cb->size);
@@ -1230,34 +1002,34 @@ static void wlat_test(struct krping_cb *cb)
post_cycles_start = kmalloc(cycle_iters * sizeof(cycles_t), GFP_KERNEL);
if (!post_cycles_start) {
- PRINTF(cb, "%s kmalloc failed\n", __FUNCTION__);
+ printk(KERN_ERR PFX "%s kmalloc failed\n", __FUNCTION__);
return;
}
post_cycles_stop = kmalloc(cycle_iters * sizeof(cycles_t), GFP_KERNEL);
if (!post_cycles_stop) {
- PRINTF(cb, "%s kmalloc failed\n", __FUNCTION__);
+ printk(KERN_ERR PFX "%s kmalloc failed\n", __FUNCTION__);
return;
}
poll_cycles_start = kmalloc(cycle_iters * sizeof(cycles_t), GFP_KERNEL);
if (!poll_cycles_start) {
- PRINTF(cb, "%s kmalloc failed\n", __FUNCTION__);
+ printk(KERN_ERR PFX "%s kmalloc failed\n", __FUNCTION__);
return;
}
poll_cycles_stop = kmalloc(cycle_iters * sizeof(cycles_t), GFP_KERNEL);
if (!poll_cycles_stop) {
- PRINTF(cb, "%s kmalloc failed\n", __FUNCTION__);
+ printk(KERN_ERR PFX "%s kmalloc failed\n", __FUNCTION__);
return;
}
last_poll_cycles_start = kmalloc(cycle_iters * sizeof(cycles_t),
GFP_KERNEL);
if (!last_poll_cycles_start) {
- PRINTF(cb, "%s kmalloc failed\n", __FUNCTION__);
+ printk(KERN_ERR PFX "%s kmalloc failed\n", __FUNCTION__);
return;
}
- cb->rdma_sq_wr.opcode = IB_WR_RDMA_WRITE;
- cb->rdma_sq_wr.wr.rdma.rkey = cb->remote_rkey;
- cb->rdma_sq_wr.wr.rdma.remote_addr = cb->remote_addr;
- cb->rdma_sq_wr.sg_list->length = cb->size;
+ cb->rdma_sq_wr.wr.opcode = IB_WR_RDMA_WRITE;
+ cb->rdma_sq_wr.rkey = cb->remote_rkey;
+ cb->rdma_sq_wr.remote_addr = cb->remote_addr;
+ cb->rdma_sq_wr.wr.sg_list->length = cb->size;
if (cycle_iters > iters)
cycle_iters = iters;
@@ -1269,7 +1041,7 @@ static void wlat_test(struct krping_cb *cb)
++rcnt;
while (*poll_buf != (char)rcnt) {
if (cb->state == ERROR) {
- PRINTF(cb,
+ printk(KERN_ERR PFX
"state = ERROR, bailing\n");
return;
}
@@ -1282,8 +1054,8 @@ static void wlat_test(struct krping_cb *cb)
*buf = (char)scnt+1;
if (scnt < cycle_iters)
post_cycles_start[scnt] = get_cycles();
- if (ib_post_send(cb->qp, &cb->rdma_sq_wr, &bad_wr)) {
- PRINTF(cb,
+ if (ib_post_send(cb->qp, &cb->rdma_sq_wr.wr, &bad_wr)) {
+ printk(KERN_ERR PFX
"Couldn't post send: scnt=%d\n",
scnt);
return;
@@ -1310,17 +1082,17 @@ static void wlat_test(struct krping_cb *cb)
++ccnt;
if (ne < 0) {
- PRINTF(cb, "poll CQ failed %d\n", ne);
+ printk(KERN_ERR PFX "poll CQ failed %d\n", ne);
return;
}
if (wc.status != IB_WC_SUCCESS) {
- PRINTF(cb,
+ printk(KERN_ERR PFX
"Completion wth error at %s:\n",
cb->server ? "server" : "client");
- PRINTF(cb,
+ printk(KERN_ERR PFX
"Failed status %d: wr_id %d\n",
wc.status, (int) wc.wr_id);
- PRINTF(cb,
+ printk(KERN_ERR PFX
"scnt=%d, rcnt=%d, ccnt=%d\n",
scnt, rcnt, ccnt);
return;
@@ -1339,7 +1111,7 @@ static void wlat_test(struct krping_cb *cb)
sum_poll += poll_cycles_stop[i] - poll_cycles_start[i];
sum_last_poll += poll_cycles_stop[i]-last_poll_cycles_start[i];
}
- PRINTF(cb,
+ printk(KERN_ERR PFX
"delta sec %lu delta usec %lu iter %d size %d cycle_iters %d"
" sum_post %llu sum_poll %llu sum_last_poll %llu\n",
(unsigned long)(stop_tv.tv_sec - start_tv.tv_sec),
@@ -1372,34 +1144,34 @@ static void bw_test(struct krping_cb *cb)
post_cycles_start = kmalloc(cycle_iters * sizeof(cycles_t), GFP_KERNEL);
if (!post_cycles_start) {
- PRINTF(cb, "%s kmalloc failed\n", __FUNCTION__);
+ printk(KERN_ERR PFX "%s kmalloc failed\n", __FUNCTION__);
return;
}
post_cycles_stop = kmalloc(cycle_iters * sizeof(cycles_t), GFP_KERNEL);
if (!post_cycles_stop) {
- PRINTF(cb, "%s kmalloc failed\n", __FUNCTION__);
+ printk(KERN_ERR PFX "%s kmalloc failed\n", __FUNCTION__);
return;
}
poll_cycles_start = kmalloc(cycle_iters * sizeof(cycles_t), GFP_KERNEL);
if (!poll_cycles_start) {
- PRINTF(cb, "%s kmalloc failed\n", __FUNCTION__);
+ printk(KERN_ERR PFX "%s kmalloc failed\n", __FUNCTION__);
return;
}
poll_cycles_stop = kmalloc(cycle_iters * sizeof(cycles_t), GFP_KERNEL);
if (!poll_cycles_stop) {
- PRINTF(cb, "%s kmalloc failed\n", __FUNCTION__);
+ printk(KERN_ERR PFX "%s kmalloc failed\n", __FUNCTION__);
return;
}
last_poll_cycles_start = kmalloc(cycle_iters * sizeof(cycles_t),
GFP_KERNEL);
if (!last_poll_cycles_start) {
- PRINTF(cb, "%s kmalloc failed\n", __FUNCTION__);
+ printk(KERN_ERR PFX "%s kmalloc failed\n", __FUNCTION__);
return;
}
- cb->rdma_sq_wr.opcode = IB_WR_RDMA_WRITE;
- cb->rdma_sq_wr.wr.rdma.rkey = cb->remote_rkey;
- cb->rdma_sq_wr.wr.rdma.remote_addr = cb->remote_addr;
- cb->rdma_sq_wr.sg_list->length = cb->size;
+ cb->rdma_sq_wr.wr.opcode = IB_WR_RDMA_WRITE;
+ cb->rdma_sq_wr.rkey = cb->remote_rkey;
+ cb->rdma_sq_wr.remote_addr = cb->remote_addr;
+ cb->rdma_sq_wr.wr.sg_list->length = cb->size;
if (cycle_iters > iters)
cycle_iters = iters;
@@ -1411,8 +1183,8 @@ static void bw_test(struct krping_cb *cb)
if (scnt < cycle_iters)
post_cycles_start[scnt] = get_cycles();
- if (ib_post_send(cb->qp, &cb->rdma_sq_wr, &bad_wr)) {
- PRINTF(cb,
+ if (ib_post_send(cb->qp, &cb->rdma_sq_wr.wr, &bad_wr)) {
+ printk(KERN_ERR PFX
"Couldn't post send: scnt=%d\n",
scnt);
return;
@@ -1439,14 +1211,14 @@ static void bw_test(struct krping_cb *cb)
ccnt += 1;
if (ne < 0) {
- PRINTF(cb, "poll CQ failed %d\n", ne);
+ printk(KERN_ERR PFX "poll CQ failed %d\n", ne);
return;
}
if (wc.status != IB_WC_SUCCESS) {
- PRINTF(cb,
+ printk(KERN_ERR PFX
"Completion wth error at %s:\n",
cb->server ? "server" : "client");
- PRINTF(cb,
+ printk(KERN_ERR PFX
"Failed status %d: wr_id %d\n",
wc.status, (int) wc.wr_id);
return;
@@ -1465,7 +1237,7 @@ static void bw_test(struct krping_cb *cb)
sum_poll += poll_cycles_stop[i] - poll_cycles_start[i];
sum_last_poll += poll_cycles_stop[i]-last_poll_cycles_start[i];
}
- PRINTF(cb,
+ printk(KERN_ERR PFX
"delta sec %lu delta usec %lu iter %d size %d cycle_iters %d"
" sum_post %llu sum_poll %llu sum_last_poll %llu\n",
(unsigned long)(stop_tv.tv_sec - start_tv.tv_sec),
@@ -1495,20 +1267,21 @@ static void krping_rlat_test_server(struct krping_cb *cb)
krping_format_send(cb, cb->start_dma_addr);
ret = ib_post_send(cb->qp, &cb->sq_wr, &bad_wr);
if (ret) {
- PRINTF(cb, "post send error %d\n", ret);
+ printk(KERN_ERR PFX "post send error %d\n", ret);
return;
}
/* Spin waiting for send completion */
while ((ret = ib_poll_cq(cb->cq, 1, &wc) == 0));
if (ret < 0) {
- PRINTF(cb, "poll error %d\n", ret);
+ printk(KERN_ERR PFX "poll error %d\n", ret);
return;
}
if (wc.status) {
- PRINTF(cb, "send completiong error %d\n", wc.status);
+ printk(KERN_ERR PFX "send completiong error %d\n", wc.status);
return;
}
+
wait_event_interruptible(cb->sem, cb->state == ERROR);
}
@@ -1527,18 +1300,18 @@ static void krping_wlat_test_server(struct krping_cb *cb)
krping_format_send(cb, cb->start_dma_addr);
ret = ib_post_send(cb->qp, &cb->sq_wr, &bad_wr);
if (ret) {
- PRINTF(cb, "post send error %d\n", ret);
+ printk(KERN_ERR PFX "post send error %d\n", ret);
return;
}
/* Spin waiting for send completion */
while ((ret = ib_poll_cq(cb->cq, 1, &wc) == 0));
if (ret < 0) {
- PRINTF(cb, "poll error %d\n", ret);
+ printk(KERN_ERR PFX "poll error %d\n", ret);
return;
}
if (wc.status) {
- PRINTF(cb, "send completiong error %d\n", wc.status);
+ printk(KERN_ERR PFX "send completiong error %d\n", wc.status);
return;
}
@@ -1561,18 +1334,18 @@ static void krping_bw_test_server(struct krping_cb *cb)
krping_format_send(cb, cb->start_dma_addr);
ret = ib_post_send(cb->qp, &cb->sq_wr, &bad_wr);
if (ret) {
- PRINTF(cb, "post send error %d\n", ret);
+ printk(KERN_ERR PFX "post send error %d\n", ret);
return;
}
/* Spin waiting for send completion */
while ((ret = ib_poll_cq(cb->cq, 1, &wc) == 0));
if (ret < 0) {
- PRINTF(cb, "poll error %d\n", ret);
+ printk(KERN_ERR PFX "poll error %d\n", ret);
return;
}
if (wc.status) {
- PRINTF(cb, "send completiong error %d\n", wc.status);
+ printk(KERN_ERR PFX "send completiong error %d\n", wc.status);
return;
}
@@ -1581,717 +1354,75 @@ static void krping_bw_test_server(struct krping_cb *cb)
wait_event_interruptible(cb->sem, cb->state == ERROR);
}
-static int fastreg_supported(struct krping_cb *cb, int server)
+static int reg_supported(struct ib_device *dev)
{
- struct ib_device *dev = server?cb->child_cm_id->device:
- cb->cm_id->device;
- struct ib_device_attr attr;
- int ret;
+ u64 needed_flags = IB_DEVICE_MEM_MGT_EXTENSIONS;
- ret = ib_query_device(dev, &attr);
- if (ret) {
- PRINTF(cb, "ib_query_device failed ret %d\n", ret);
+ if ((dev->attrs.device_cap_flags & needed_flags) != needed_flags) {
+ printk(KERN_ERR PFX
+ "Fastreg not supported - device_cap_flags 0x%llx\n",
+ (unsigned long long)dev->attrs.device_cap_flags);
return 0;
}
- if (!(attr.device_cap_flags & IB_DEVICE_MEM_MGT_EXTENSIONS)) {
- PRINTF(cb, "Fastreg not supported - device_cap_flags 0x%llx\n",
- (unsigned long long)attr.device_cap_flags);
- return 0;
- }
- DEBUG_LOG(cb, "Fastreg supported - device_cap_flags 0x%jx\n",
- (uintmax_t)attr.device_cap_flags);
+ DEBUG_LOG("Fastreg supported - device_cap_flags 0x%llx\n",
+ (unsigned long long)dev->attrs.device_cap_flags);
return 1;
}
+static void fill_sockaddr(struct sockaddr_storage *sin, struct krping_cb *cb)
+{
+ memset(sin, 0, sizeof(*sin));
+
+ if (cb->addr_type == AF_INET) {
+ struct sockaddr_in *sin4 = (struct sockaddr_in *)sin;
+ sin4->sin_len = sizeof(*sin4);
+ sin4->sin_family = AF_INET;
+ memcpy((void *)&sin4->sin_addr.s_addr, cb->addr, 4);
+ sin4->sin_port = cb->port;
+ } else if (cb->addr_type == AF_INET6) {
+ struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *)sin;
+ sin6->sin6_len = sizeof(*sin6);
+ sin6->sin6_family = AF_INET6;
+ memcpy((void *)&sin6->sin6_addr, cb->addr, 16);
+ sin6->sin6_port = cb->port;
+ }
+}
+
static int krping_bind_server(struct krping_cb *cb)
{
- union {
- struct sockaddr_in v4;
- struct sockaddr_in6 v6;
- } sin;
+ struct sockaddr_storage sin;
int ret;
- memset(&sin, 0, sizeof(sin));
- switch (cb->addr_type) {
- case AF_INET:
- sin.v4.sin_len = sizeof sin.v4;
- sin.v4.sin_family = AF_INET;
- sin.v4.sin_addr = cb->addr.v4;
- sin.v4.sin_port = cb->port;
- break;
- case AF_INET6:
- sin.v6.sin6_len = sizeof sin.v6;
- sin.v6.sin6_family = AF_INET6;
- sin.v6.sin6_addr = cb->addr.v6;
- sin.v6.sin6_port = cb->port;
- break;
- default:
- return (-EINVAL);
- }
+ fill_sockaddr(&sin, cb);
- ret = rdma_bind_addr(cb->cm_id, (struct sockaddr *) &sin);
+ ret = rdma_bind_addr(cb->cm_id, (struct sockaddr *)&sin);
if (ret) {
- PRINTF(cb, "rdma_bind_addr error %d\n", ret);
+ printk(KERN_ERR PFX "rdma_bind_addr error %d\n", ret);
return ret;
}
- DEBUG_LOG(cb, "rdma_bind_addr successful\n");
+ DEBUG_LOG("rdma_bind_addr successful\n");
- DEBUG_LOG(cb, "rdma_listen\n");
+ DEBUG_LOG("rdma_listen\n");
ret = rdma_listen(cb->cm_id, 3);
if (ret) {
- PRINTF(cb, "rdma_listen failed: %d\n", ret);
+ printk(KERN_ERR PFX "rdma_listen failed: %d\n", ret);
return ret;
}
wait_event_interruptible(cb->sem, cb->state >= CONNECT_REQUEST);
if (cb->state != CONNECT_REQUEST) {
- PRINTF(cb, "wait for CONNECT_REQUEST state %d\n",
+ printk(KERN_ERR PFX "wait for CONNECT_REQUEST state %d\n",
cb->state);
return -1;
}
- if (cb->mem == FASTREG && !fastreg_supported(cb, 1))
+ if (!reg_supported(cb->child_cm_id->device))
return -EINVAL;
return 0;
}
-/*
- * sq-depth worth of fastreg + 0B read-inv pairs, reposting them as the reads
- * complete.
- * NOTE: every 9 seconds we sleep for 1 second to keep the kernel happy.
- */
-static void krping_fr_test5(struct krping_cb *cb)
-{
- struct ib_fast_reg_page_list **pl;
- struct ib_send_wr *fr, *read, *bad;
- struct ib_wc wc;
- struct ib_sge *sgl;
- u8 key = 0;
- struct ib_mr **mr;
- u8 **buf;
- dma_addr_t *dma_addr;
- int i;
- int ret;
- int plen = (((cb->size - 1) & PAGE_MASK) + PAGE_SIZE) >> PAGE_SHIFT;
- time_t start;
- int count = 0;
- int scnt;
- int depth = cb->txdepth >> 1;
-
- if (!depth) {
- PRINTF(cb, "txdepth must be > 1 for this test!\n");
- return;
- }
-
- pl = kzalloc(sizeof *pl * depth, GFP_KERNEL);
- DEBUG_LOG(cb, "%s pl %p size %zu\n", __func__, pl, sizeof *pl * depth);
- mr = kzalloc(sizeof *mr * depth, GFP_KERNEL);
- DEBUG_LOG(cb, "%s mr %p size %zu\n", __func__, mr, sizeof *mr * depth);
- fr = kzalloc(sizeof *fr * depth, GFP_KERNEL);
- DEBUG_LOG(cb, "%s fr %p size %zu\n", __func__, fr, sizeof *fr * depth);
- sgl = kzalloc(sizeof *sgl * depth, GFP_KERNEL);
- DEBUG_LOG(cb, "%s sgl %p size %zu\n", __func__, sgl, sizeof *sgl * depth);
- read = kzalloc(sizeof *read * depth, GFP_KERNEL);
- DEBUG_LOG(cb, "%s read %p size %zu\n", __func__, read, sizeof *read * depth);
- buf = kzalloc(sizeof *buf * depth, GFP_KERNEL);
- DEBUG_LOG(cb, "%s buf %p size %zu\n", __func__, buf, sizeof *buf * depth);
- dma_addr = kzalloc(sizeof *dma_addr * depth, GFP_KERNEL);
- DEBUG_LOG(cb, "%s dma_addr %p size %zu\n", __func__, dma_addr, sizeof *dma_addr * depth);
- if (!pl || !mr || !fr || !read || !sgl || !buf || !dma_addr) {
- PRINTF(cb, "kzalloc failed\n");
- goto err1;
- }
-
- for (scnt = 0; scnt < depth; scnt++) {
- pl[scnt] = ib_alloc_fast_reg_page_list(cb->qp->device, plen);
- if (IS_ERR(pl[scnt])) {
- PRINTF(cb, "alloc_fr_page_list failed %ld\n",
- PTR_ERR(pl[scnt]));
- goto err2;
- }
- DEBUG_LOG(cb, "%s pl[%u] %p\n", __func__, scnt, pl[scnt]);
-
- mr[scnt] = ib_alloc_fast_reg_mr(cb->pd, plen);
- if (IS_ERR(mr[scnt])) {
- PRINTF(cb, "alloc_fr failed %ld\n",
- PTR_ERR(mr[scnt]));
- goto err2;
- }
- DEBUG_LOG(cb, "%s mr[%u] %p\n", __func__, scnt, mr[scnt]);
- ib_update_fast_reg_key(mr[scnt], ++key);
-
- buf[scnt] = kmalloc(cb->size, GFP_KERNEL);
- if (!buf[scnt]) {
- PRINTF(cb, "kmalloc failed\n");
- ret = -ENOMEM;
- goto err2;
- }
- DEBUG_LOG(cb, "%s buf[%u] %p\n", __func__, scnt, buf[scnt]);
- dma_addr[scnt] = dma_map_single(cb->pd->device->dma_device,
- buf[scnt], cb->size,
- DMA_BIDIRECTIONAL);
- if (dma_mapping_error(cb->pd->device->dma_device,
- dma_addr[scnt])) {
- PRINTF(cb, "dma_map failed\n");
- ret = -ENOMEM;
- goto err2;
- }
- DEBUG_LOG(cb, "%s dma_addr[%u] %p\n", __func__, scnt, (void *)dma_addr[scnt]);
- for (i=0; i<plen; i++) {
- pl[scnt]->page_list[i] = ((unsigned long)dma_addr[scnt] & PAGE_MASK) + (i * PAGE_SIZE);
- DEBUG_LOG(cb, "%s pl[%u]->page_list[%u] 0x%jx\n",
- __func__, scnt, i, (uintmax_t)pl[scnt]->page_list[i]);
- }
-
- sgl[scnt].lkey = mr[scnt]->rkey;
- sgl[scnt].length = cb->size;
- sgl[scnt].addr = (u64)buf[scnt];
- DEBUG_LOG(cb, "%s sgl[%u].lkey 0x%x length %u addr 0x%jx\n",
- __func__, scnt, sgl[scnt].lkey, sgl[scnt].length,
- (uintmax_t)sgl[scnt].addr);
-
- fr[scnt].opcode = IB_WR_FAST_REG_MR;
- fr[scnt].wr_id = scnt;
- fr[scnt].send_flags = 0;
- fr[scnt].wr.fast_reg.page_shift = PAGE_SHIFT;
- fr[scnt].wr.fast_reg.length = cb->size;
- fr[scnt].wr.fast_reg.page_list = pl[scnt];
- fr[scnt].wr.fast_reg.page_list_len = plen;
- fr[scnt].wr.fast_reg.iova_start = (u64)buf[scnt];
- fr[scnt].wr.fast_reg.access_flags = IB_ACCESS_REMOTE_WRITE | IB_ACCESS_LOCAL_WRITE;
- fr[scnt].wr.fast_reg.rkey = mr[scnt]->rkey;
- fr[scnt].next = &read[scnt];
- read[scnt].opcode = IB_WR_RDMA_READ_WITH_INV;
- read[scnt].wr_id = scnt;
- read[scnt].send_flags = IB_SEND_SIGNALED;
- read[scnt].wr.rdma.rkey = cb->remote_rkey;
- read[scnt].wr.rdma.remote_addr = cb->remote_addr;
- read[scnt].num_sge = 1;
- read[scnt].sg_list = &sgl[scnt];
- ret = ib_post_send(cb->qp, &fr[scnt], &bad);
- if (ret) {
- PRINTF(cb, "ib_post_send failed %d\n", ret);
- goto err2;
- }
- }
-
- start = time_uptime;
- DEBUG_LOG(cb, "%s starting IO.\n", __func__);
- while (!cb->count || cb->server || count < cb->count) {
- if ((time_uptime - start) >= 9) {
- DEBUG_LOG(cb, "%s pausing 1 tick! count %u\n", __func__,
- count);
- wait_event_interruptible_timeout(cb->sem,
- cb->state == ERROR,
- 1);
- if (cb->state == ERROR)
- break;
- start = time_uptime;
- }
- do {
- ret = ib_poll_cq(cb->cq, 1, &wc);
- if (ret < 0) {
- PRINTF(cb, "ib_poll_cq failed %d\n",
- ret);
- goto err2;
- }
- if (ret == 1) {
- if (wc.status) {
- PRINTF(cb,
- "completion error %u wr_id %ju "
- "opcode %d\n", wc.status,
- (uintmax_t)wc.wr_id, wc.opcode);
- goto err2;
- }
- count++;
- if (count == cb->count)
- break;
- ib_update_fast_reg_key(mr[wc.wr_id], ++key);
- fr[wc.wr_id].wr.fast_reg.rkey =
- mr[wc.wr_id]->rkey;
- sgl[wc.wr_id].lkey = mr[wc.wr_id]->rkey;
- ret = ib_post_send(cb->qp, &fr[wc.wr_id], &bad);
- if (ret) {
- PRINTF(cb,
- "ib_post_send failed %d\n", ret);
- goto err2;
- }
- } else if (krping_sigpending()) {
- PRINTF(cb, "signal!\n");
- goto err2;
- }
- } while (ret == 1);
- }
- DEBUG_LOG(cb, "%s done!\n", __func__);
-err2:
- DEBUG_LOG(cb, "sleeping 1 second\n");
- wait_event_interruptible_timeout(cb->sem, cb->state == ERROR, HZ);
- DEBUG_LOG(cb, "draining the cq...\n");
- do {
- ret = ib_poll_cq(cb->cq, 1, &wc);
- if (ret < 0) {
- PRINTF(cb, "ib_poll_cq failed %d\n", ret);
- break;
- }
- if (ret == 1) {
- if (wc.status) {
- PRINTF(cb, "completion error %u "
- "opcode %u\n", wc.status, wc.opcode);
- }
- }
- } while (ret == 1);
-
- DEBUG_LOG(cb, "destroying fr mrs!\n");
- for (scnt = 0; scnt < depth; scnt++) {
- if (mr[scnt]) {
- ib_dereg_mr(mr[scnt]);
- DEBUG_LOG(cb, "%s dereg mr %p\n", __func__, mr[scnt]);
- }
- }
- DEBUG_LOG(cb, "unmapping/freeing bufs!\n");
- for (scnt = 0; scnt < depth; scnt++) {
- if (buf[scnt]) {
- dma_unmap_single(cb->pd->device->dma_device,
- dma_addr[scnt], cb->size,
- DMA_BIDIRECTIONAL);
- kfree(buf[scnt]);
- DEBUG_LOG(cb, "%s unmap/free buf %p dma_addr %p\n", __func__, buf[scnt], (void *)dma_addr[scnt]);
- }
- }
- DEBUG_LOG(cb, "destroying fr page lists!\n");
- for (scnt = 0; scnt < depth; scnt++) {
- if (pl[scnt]) {
- DEBUG_LOG(cb, "%s free pl %p\n", __func__, pl[scnt]);
- ib_free_fast_reg_page_list(pl[scnt]);
- }
- }
-err1:
- if (pl)
- kfree(pl);
- if (mr)
- kfree(mr);
- if (fr)
- kfree(fr);
- if (read)
- kfree(read);
- if (sgl)
- kfree(sgl);
- if (buf)
- kfree(buf);
- if (dma_addr)
- kfree(dma_addr);
-}
-static void krping_fr_test_server(struct krping_cb *cb)
-{
- DEBUG_LOG(cb, "%s waiting for disconnect...\n", __func__);
- wait_event_interruptible(cb->sem, cb->state == ERROR);
-}
-
-static void krping_fr_test5_server(struct krping_cb *cb)
-{
- struct ib_send_wr *bad_wr;
- struct ib_wc wc;
- int ret;
-
- /* Spin waiting for client's Start STAG/TO/Len */
- while (cb->state < RDMA_READ_ADV) {
- krping_cq_event_handler(cb->cq, cb);
- }
- DEBUG_LOG(cb, "%s client STAG %x TO 0x%jx\n", __func__,
- cb->remote_rkey, (uintmax_t)cb->remote_addr);
-
- /* Send STAG/TO/Len to client */
- krping_format_send(cb, cb->start_dma_addr);
- ret = ib_post_send(cb->qp, &cb->sq_wr, &bad_wr);
- if (ret) {
- PRINTF(cb, "post send error %d\n", ret);
- return;
- }
-
- /* Spin waiting for send completion */
- while ((ret = ib_poll_cq(cb->cq, 1, &wc) == 0));
- if (ret < 0) {
- PRINTF(cb, "poll error %d\n", ret);
- return;
- }
- if (wc.status) {
- PRINTF(cb, "send completiong error %d\n", wc.status);
- return;
- }
-
- if (cb->duplex)
- krping_fr_test5(cb);
- DEBUG_LOG(cb, "%s waiting for disconnect...\n", __func__);
- wait_event_interruptible(cb->sem, cb->state == ERROR);
-}
-
-static void krping_fr_test5_client(struct krping_cb *cb)
-{
- struct ib_send_wr *bad;
- struct ib_wc wc;
- int ret;
-
- cb->state = RDMA_READ_ADV;
-
- /* Send STAG/TO/Len to server */
- krping_format_send(cb, cb->start_dma_addr);
- if (cb->state == ERROR) {
- PRINTF(cb, "krping_format_send failed\n");
- return;
- }
- ret = ib_post_send(cb->qp, &cb->sq_wr, &bad);
- if (ret) {
- PRINTF(cb, "post send error %d\n", ret);
- return;
- }
-
- /* Spin waiting for send completion */
- while ((ret = ib_poll_cq(cb->cq, 1, &wc) == 0));
- if (ret < 0) {
- PRINTF(cb, "poll error %d\n", ret);
- return;
- }
- if (wc.status) {
- PRINTF(cb, "send completion error %d\n", wc.status);
- return;
- }
-
- /* Spin waiting for server's Start STAG/TO/Len */
- while (cb->state < RDMA_WRITE_ADV) {
- krping_cq_event_handler(cb->cq, cb);
- }
- DEBUG_LOG(cb, "%s server STAG %x TO 0x%jx\n", __func__, cb->remote_rkey,
- (uintmax_t)cb->remote_addr);
-
- return krping_fr_test5(cb);
-}
-
-/*
- * sq-depth worth of write + fastreg + inv, reposting them as the invs
- * complete.
- * NOTE: every 9 seconds we sleep for 1 second to keep the kernel happy.
- * If a count is given, then the last IO will have a bogus lkey in the
- * write work request. This reproduces a fw bug where the connection
- * will get stuck if a fastreg is processed while the ulptx is failing
- * the bad write.
- */
-static void krping_fr_test6(struct krping_cb *cb)
-{
- struct ib_fast_reg_page_list **pl;
- struct ib_send_wr *fr, *write, *inv, *bad;
- struct ib_wc wc;
- struct ib_sge *sgl;
- u8 key = 0;
- struct ib_mr **mr;
- u8 **buf;
- dma_addr_t *dma_addr;
- int i;
- int ret;
- int plen = (((cb->size - 1) & PAGE_MASK) + PAGE_SIZE) >> PAGE_SHIFT;
- unsigned long start;
- int count = 0;
- int scnt;
- int depth = cb->txdepth / 3;
-
- if (!depth) {
- PRINTF(cb, "txdepth must be > 3 for this test!\n");
- return;
- }
-
- pl = kzalloc(sizeof *pl * depth, GFP_KERNEL);
- DEBUG_LOG(cb, "%s pl %p size %zu\n", __func__, pl, sizeof *pl * depth);
-
- mr = kzalloc(sizeof *mr * depth, GFP_KERNEL);
- DEBUG_LOG(cb, "%s mr %p size %zu\n", __func__, mr, sizeof *mr * depth);
-
- fr = kzalloc(sizeof *fr * depth, GFP_KERNEL);
- DEBUG_LOG(cb, "%s fr %p size %zu\n", __func__, fr, sizeof *fr * depth);
-
- sgl = kzalloc(sizeof *sgl * depth, GFP_KERNEL);
- DEBUG_LOG(cb, "%s sgl %p size %zu\n", __func__, sgl, sizeof *sgl * depth);
-
- write = kzalloc(sizeof *write * depth, GFP_KERNEL);
- DEBUG_LOG(cb, "%s read %p size %zu\n", __func__, write, sizeof *write * depth);
-
- inv = kzalloc(sizeof *inv * depth, GFP_KERNEL);
- DEBUG_LOG(cb, "%s inv %p size %zu\n", __func__, inv, sizeof *inv * depth);
-
- buf = kzalloc(sizeof *buf * depth, GFP_KERNEL);
- DEBUG_LOG(cb, "%s buf %p size %zu\n", __func__, buf, sizeof *buf * depth);
-
- dma_addr = kzalloc(sizeof *dma_addr * depth, GFP_KERNEL);
- DEBUG_LOG(cb, "%s dma_addr %p size %zu\n", __func__, dma_addr, sizeof *dma_addr * depth);
-
- if (!pl || !mr || !fr || !write || !sgl || !buf || !dma_addr) {
- PRINTF(cb, "kzalloc failed\n");
- goto err1;
- }
-
- for (scnt = 0; scnt < depth; scnt++) {
- pl[scnt] = ib_alloc_fast_reg_page_list(cb->qp->device, plen);
- if (IS_ERR(pl[scnt])) {
- PRINTF(cb, "alloc_fr_page_list failed %ld\n",
- PTR_ERR(pl[scnt]));
- goto err2;
- }
- DEBUG_LOG(cb, "%s pl[%u] %p\n", __func__, scnt, pl[scnt]);
-
- mr[scnt] = ib_alloc_fast_reg_mr(cb->pd, plen);
- if (IS_ERR(mr[scnt])) {
- PRINTF(cb, "alloc_fr failed %ld\n",
- PTR_ERR(mr[scnt]));
- goto err2;
- }
- DEBUG_LOG(cb, "%s mr[%u] %p\n", __func__, scnt, mr[scnt]);
- ib_update_fast_reg_key(mr[scnt], ++key);
-
- buf[scnt] = kmalloc(cb->size, GFP_KERNEL);
- if (!buf[scnt]) {
- PRINTF(cb, "kmalloc failed\n");
- ret = -ENOMEM;
- goto err2;
- }
- DEBUG_LOG(cb, "%s buf[%u] %p\n", __func__, scnt, buf[scnt]);
- dma_addr[scnt] = dma_map_single(cb->pd->device->dma_device,
- buf[scnt], cb->size,
- DMA_BIDIRECTIONAL);
- if (dma_mapping_error(cb->pd->device->dma_device,
- dma_addr[scnt])) {
- PRINTF(cb, "dma_map failed\n");
- ret = -ENOMEM;
- goto err2;
- }
- DEBUG_LOG(cb, "%s dma_addr[%u] %p\n", __func__, scnt, (void *)dma_addr[scnt]);
- for (i=0; i<plen; i++) {
- pl[scnt]->page_list[i] = ((unsigned long)dma_addr[scnt] & PAGE_MASK) + (i * PAGE_SIZE);
- DEBUG_LOG(cb, "%s pl[%u]->page_list[%u] 0x%jx\n",
- __func__, scnt, i, (uintmax_t)pl[scnt]->page_list[i]);
- }
-
- write[scnt].opcode = IB_WR_RDMA_WRITE;
- write[scnt].wr_id = scnt;
- write[scnt].wr.rdma.rkey = cb->remote_rkey;
- write[scnt].wr.rdma.remote_addr = cb->remote_addr;
- write[scnt].num_sge = 1;
- write[scnt].sg_list = &cb->rdma_sgl;
- write[scnt].sg_list->length = cb->size;
- write[scnt].next = &fr[scnt];
-
- fr[scnt].opcode = IB_WR_FAST_REG_MR;
- fr[scnt].wr_id = scnt;
- fr[scnt].wr.fast_reg.page_shift = PAGE_SHIFT;
- fr[scnt].wr.fast_reg.length = cb->size;
- fr[scnt].wr.fast_reg.page_list = pl[scnt];
- fr[scnt].wr.fast_reg.page_list_len = plen;
- fr[scnt].wr.fast_reg.iova_start = (u64)buf[scnt];
- fr[scnt].wr.fast_reg.access_flags = IB_ACCESS_REMOTE_WRITE | IB_ACCESS_LOCAL_WRITE;
- fr[scnt].wr.fast_reg.rkey = mr[scnt]->rkey;
- fr[scnt].next = &inv[scnt];
-
- inv[scnt].opcode = IB_WR_LOCAL_INV;
- inv[scnt].send_flags = IB_SEND_SIGNALED;
- inv[scnt].ex.invalidate_rkey = mr[scnt]->rkey;
-
- ret = ib_post_send(cb->qp, &write[scnt], &bad);
- if (ret) {
- PRINTF(cb, "ib_post_send failed %d\n", ret);
- goto err2;
- }
- }
-
- start = time_uptime;
- DEBUG_LOG(cb, "%s starting IO.\n", __func__);
- while (!cb->count || cb->server || count < cb->count) {
- if ((time_uptime - start) >= 9) {
- DEBUG_LOG(cb, "%s pausing 1 tick! count %u\n", __func__,
- count);
- wait_event_interruptible_timeout(cb->sem,
- cb->state == ERROR,
- 1);
- if (cb->state == ERROR)
- break;
- start = time_uptime;
- }
- do {
- ret = ib_poll_cq(cb->cq, 1, &wc);
- if (ret < 0) {
- PRINTF(cb, "ib_poll_cq failed %d\n",
- ret);
- goto err2;
- }
- if (ret == 1) {
- if (wc.status) {
- PRINTF(cb,
- "completion error %u wr_id %ju "
- "opcode %d\n", wc.status,
- (uintmax_t)wc.wr_id, wc.opcode);
- goto err2;
- }
- count++;
- if (count == (cb->count -1))
- cb->rdma_sgl.lkey = 0x00dead;
- if (count == cb->count)
- break;
- ib_update_fast_reg_key(mr[wc.wr_id], ++key);
- fr[wc.wr_id].wr.fast_reg.rkey =
- mr[wc.wr_id]->rkey;
- inv[wc.wr_id].ex.invalidate_rkey =
- mr[wc.wr_id]->rkey;
- ret = ib_post_send(cb->qp, &write[wc.wr_id], &bad);
- if (ret) {
- PRINTF(cb,
- "ib_post_send failed %d\n", ret);
- goto err2;
- }
- } else if (krping_sigpending()){
- PRINTF(cb, "signal!\n");
- goto err2;
- }
- } while (ret == 1);
- }
- DEBUG_LOG(cb, "%s done!\n", __func__);
-err2:
- DEBUG_LOG(cb, "sleeping 1 second\n");
- wait_event_interruptible_timeout(cb->sem, cb->state == ERROR, HZ);
- DEBUG_LOG(cb, "draining the cq...\n");
- do {
- ret = ib_poll_cq(cb->cq, 1, &wc);
- if (ret < 0) {
- PRINTF(cb, "ib_poll_cq failed %d\n", ret);
- break;
- }
- if (ret == 1) {
- if (wc.status) {
- PRINTF(cb, "completion error %u "
- "opcode %u\n", wc.status, wc.opcode);
- }
- }
- } while (ret == 1);
-
- DEBUG_LOG(cb, "destroying fr mrs!\n");
- for (scnt = 0; scnt < depth; scnt++) {
- if (mr[scnt]) {
- ib_dereg_mr(mr[scnt]);
- DEBUG_LOG(cb, "%s dereg mr %p\n", __func__, mr[scnt]);
- }
- }
- DEBUG_LOG(cb, "unmapping/freeing bufs!\n");
- for (scnt = 0; scnt < depth; scnt++) {
- if (buf[scnt]) {
- dma_unmap_single(cb->pd->device->dma_device,
- dma_addr[scnt], cb->size,
- DMA_BIDIRECTIONAL);
- kfree(buf[scnt]);
- DEBUG_LOG(cb, "%s unmap/free buf %p dma_addr %p\n", __func__, buf[scnt], (void *)dma_addr[scnt]);
- }
- }
- DEBUG_LOG(cb, "destroying fr page lists!\n");
- for (scnt = 0; scnt < depth; scnt++) {
- if (pl[scnt]) {
- DEBUG_LOG(cb, "%s free pl %p\n", __func__, pl[scnt]);
- ib_free_fast_reg_page_list(pl[scnt]);
- }
- }
-err1:
- if (pl)
- kfree(pl);
- if (mr)
- kfree(mr);
- if (fr)
- kfree(fr);
- if (write)
- kfree(write);
- if (inv)
- kfree(inv);
- if (sgl)
- kfree(sgl);
- if (buf)
- kfree(buf);
- if (dma_addr)
- kfree(dma_addr);
-}
-
-static void krping_fr_test6_server(struct krping_cb *cb)
-{
- struct ib_send_wr *bad_wr;
- struct ib_wc wc;
- int ret;
-
- /* Spin waiting for client's Start STAG/TO/Len */
- while (cb->state < RDMA_READ_ADV) {
- krping_cq_event_handler(cb->cq, cb);
- }
- DEBUG_LOG(cb, "%s client STAG %x TO 0x%jx\n", __func__,
- cb->remote_rkey, (uintmax_t)cb->remote_addr);
-
- /* Send STAG/TO/Len to client */
- krping_format_send(cb, cb->start_dma_addr);
- ret = ib_post_send(cb->qp, &cb->sq_wr, &bad_wr);
- if (ret) {
- PRINTF(cb, "post send error %d\n", ret);
- return;
- }
-
- /* Spin waiting for send completion */
- while ((ret = ib_poll_cq(cb->cq, 1, &wc) == 0));
- if (ret < 0) {
- PRINTF(cb, "poll error %d\n", ret);
- return;
- }
- if (wc.status) {
- PRINTF(cb, "send completiong error %d\n", wc.status);
- return;
- }
-
- if (cb->duplex)
- krping_fr_test6(cb);
- DEBUG_LOG(cb, "%s waiting for disconnect...\n", __func__);
- wait_event_interruptible(cb->sem, cb->state == ERROR);
-}
-
-static void krping_fr_test6_client(struct krping_cb *cb)
-{
- struct ib_send_wr *bad;
- struct ib_wc wc;
- int ret;
-
- cb->state = RDMA_READ_ADV;
-
- /* Send STAG/TO/Len to server */
- krping_format_send(cb, cb->start_dma_addr);
- if (cb->state == ERROR) {
- PRINTF(cb, "krping_format_send failed\n");
- return;
- }
- ret = ib_post_send(cb->qp, &cb->sq_wr, &bad);
- if (ret) {
- PRINTF(cb, "post send error %d\n", ret);
- return;
- }
-
- /* Spin waiting for send completion */
- while ((ret = ib_poll_cq(cb->cq, 1, &wc) == 0));
- if (ret < 0) {
- PRINTF(cb, "poll error %d\n", ret);
- return;
- }
- if (wc.status) {
- PRINTF(cb, "send completion error %d\n", wc.status);
- return;
- }
-
- /* Spin waiting for server's Start STAG/TO/Len */
- while (cb->state < RDMA_WRITE_ADV) {
- krping_cq_event_handler(cb->cq, cb);
- }
- DEBUG_LOG(cb, "%s server STAG %x TO 0x%jx\n", __func__, cb->remote_rkey,
- (uintmax_t)cb->remote_addr);
-
- return krping_fr_test6(cb);
-}
-
static void krping_run_server(struct krping_cb *cb)
{
struct ib_recv_wr *bad_wr;
@@ -2303,25 +1434,25 @@ static void krping_run_server(struct krping_cb *cb)
ret = krping_setup_qp(cb, cb->child_cm_id);
if (ret) {
- PRINTF(cb, "setup_qp failed: %d\n", ret);
+ printk(KERN_ERR PFX "setup_qp failed: %d\n", ret);
goto err0;
}
ret = krping_setup_buffers(cb);
if (ret) {
- PRINTF(cb, "krping_setup_buffers failed: %d\n", ret);
+ printk(KERN_ERR PFX "krping_setup_buffers failed: %d\n", ret);
goto err1;
}
ret = ib_post_recv(cb->qp, &cb->rq_wr, &bad_wr);
if (ret) {
- PRINTF(cb, "ib_post_recv failed: %d\n", ret);
+ printk(KERN_ERR PFX "ib_post_recv failed: %d\n", ret);
goto err2;
}
ret = krping_accept(cb);
if (ret) {
- PRINTF(cb, "connect error %d\n", ret);
+ printk(KERN_ERR PFX "connect error %d\n", ret);
goto err2;
}
@@ -2331,26 +1462,7 @@ static void krping_run_server(struct krping_cb *cb)
krping_rlat_test_server(cb);
else if (cb->bw)
krping_bw_test_server(cb);
- else if (cb->frtest) {
- switch (cb->testnum) {
- case 1:
- case 2:
- case 3:
- case 4:
- krping_fr_test_server(cb);
- break;
- case 5:
- krping_fr_test5_server(cb);
- break;
- case 6:
- krping_fr_test6_server(cb);
- break;
- default:
- PRINTF(cb, "unknown fr test %d\n", cb->testnum);
- goto err2;
- break;
- }
- } else
+ else
krping_test_server(cb);
rdma_disconnect(cb->child_cm_id);
err2:
@@ -2386,19 +1498,19 @@ static void krping_test_client(struct krping_cb *cb)
krping_format_send(cb, cb->start_dma_addr);
if (cb->state == ERROR) {
- PRINTF(cb, "krping_format_send failed\n");
+ printk(KERN_ERR PFX "krping_format_send failed\n");
break;
}
ret = ib_post_send(cb->qp, &cb->sq_wr, &bad_wr);
if (ret) {
- PRINTF(cb, "post send error %d\n", ret);
+ printk(KERN_ERR PFX "post send error %d\n", ret);
break;
}
/* Wait for server to ACK */
wait_event_interruptible(cb->sem, cb->state >= RDMA_WRITE_ADV);
if (cb->state != RDMA_WRITE_ADV) {
- PRINTF(cb,
+ printk(KERN_ERR PFX
"wait for RDMA_WRITE_ADV state %d\n",
cb->state);
break;
@@ -2407,7 +1519,7 @@ static void krping_test_client(struct krping_cb *cb)
krping_format_send(cb, cb->rdma_dma_addr);
ret = ib_post_send(cb->qp, &cb->sq_wr, &bad_wr);
if (ret) {
- PRINTF(cb, "post send error %d\n", ret);
+ printk(KERN_ERR PFX "post send error %d\n", ret);
break;
}
@@ -2415,7 +1527,7 @@ static void krping_test_client(struct krping_cb *cb)
wait_event_interruptible(cb->sem,
cb->state >= RDMA_WRITE_COMPLETE);
if (cb->state != RDMA_WRITE_COMPLETE) {
- PRINTF(cb,
+ printk(KERN_ERR PFX
"wait for RDMA_WRITE_COMPLETE state %d\n",
cb->state);
break;
@@ -2423,20 +1535,12 @@ static void krping_test_client(struct krping_cb *cb)
if (cb->validate)
if (memcmp(cb->start_buf, cb->rdma_buf, cb->size)) {
- PRINTF(cb, "data mismatch!\n");
+ printk(KERN_ERR PFX "data mismatch!\n");
break;
}
- if (cb->verbose) {
- if (strlen(cb->rdma_buf) > 128) {
- char msgbuf[128];
-
- strlcpy(msgbuf, cb->rdma_buf, sizeof(msgbuf));
- PRINTF(cb, "ping data stripped: %s\n",
- msgbuf);
- } else
- PRINTF(cb, "ping data: %s\n", cb->rdma_buf);
- }
+ if (cb->verbose)
+ printk(KERN_INFO PFX "ping data: %s\n", cb->rdma_buf);
#ifdef SLOW_KRPING
wait_event_interruptible_timeout(cb->sem, cb->state == ERROR, HZ);
#endif
@@ -2454,23 +1558,23 @@ static void krping_rlat_test_client(struct krping_cb *cb)
/* Send STAG/TO/Len to client */
krping_format_send(cb, cb->start_dma_addr);
if (cb->state == ERROR) {
- PRINTF(cb, "krping_format_send failed\n");
+ printk(KERN_ERR PFX "krping_format_send failed\n");
return;
}
ret = ib_post_send(cb->qp, &cb->sq_wr, &bad_wr);
if (ret) {
- PRINTF(cb, "post send error %d\n", ret);
+ printk(KERN_ERR PFX "post send error %d\n", ret);
return;
}
/* Spin waiting for send completion */
while ((ret = ib_poll_cq(cb->cq, 1, &wc) == 0));
if (ret < 0) {
- PRINTF(cb, "poll error %d\n", ret);
+ printk(KERN_ERR PFX "poll error %d\n", ret);
return;
}
if (wc.status) {
- PRINTF(cb, "send completion error %d\n", wc.status);
+ printk(KERN_ERR PFX "send completion error %d\n", wc.status);
return;
}
@@ -2490,29 +1594,29 @@ static void krping_rlat_test_client(struct krping_cb *cb)
struct ib_send_wr *bad_wr;
int ne;
- cb->rdma_sq_wr.opcode = IB_WR_RDMA_WRITE;
- cb->rdma_sq_wr.wr.rdma.rkey = cb->remote_rkey;
- cb->rdma_sq_wr.wr.rdma.remote_addr = cb->remote_addr;
- cb->rdma_sq_wr.sg_list->length = 0;
- cb->rdma_sq_wr.num_sge = 0;
+ cb->rdma_sq_wr.wr.opcode = IB_WR_RDMA_WRITE;
+ cb->rdma_sq_wr.rkey = cb->remote_rkey;
+ cb->rdma_sq_wr.remote_addr = cb->remote_addr;
+ cb->rdma_sq_wr.wr.sg_list->length = 0;
+ cb->rdma_sq_wr.wr.num_sge = 0;
microtime(&start);
for (i=0; i < 100000; i++) {
- if (ib_post_send(cb->qp, &cb->rdma_sq_wr, &bad_wr)) {
- PRINTF(cb, "Couldn't post send\n");
+ if (ib_post_send(cb->qp, &cb->rdma_sq_wr.wr, &bad_wr)) {
+ printk(KERN_ERR PFX "Couldn't post send\n");
return;
}
do {
ne = ib_poll_cq(cb->cq, 1, &wc);
} while (ne == 0);
if (ne < 0) {
- PRINTF(cb, "poll CQ failed %d\n", ne);
+ printk(KERN_ERR PFX "poll CQ failed %d\n", ne);
return;
}
if (wc.status != IB_WC_SUCCESS) {
- PRINTF(cb, "Completion wth error at %s:\n",
+ printk(KERN_ERR PFX "Completion wth error at %s:\n",
cb->server ? "server" : "client");
- PRINTF(cb, "Failed status %d: wr_id %d\n",
+ printk(KERN_ERR PFX "Failed status %d: wr_id %d\n",
wc.status, (int) wc.wr_id);
return;
}
@@ -2526,7 +1630,7 @@ static void krping_rlat_test_client(struct krping_cb *cb)
sec = stop.tv_sec - start.tv_sec;
usec = stop.tv_usec - start.tv_usec;
elapsed = sec * 1000000 + usec;
- PRINTF(cb, "0B-write-lat iters 100000 usec %llu\n", elapsed);
+ printk(KERN_ERR PFX "0B-write-lat iters 100000 usec %llu\n", elapsed);
}
#endif
@@ -2544,23 +1648,23 @@ static void krping_wlat_test_client(struct krping_cb *cb)
/* Send STAG/TO/Len to client */
krping_format_send(cb, cb->start_dma_addr);
if (cb->state == ERROR) {
- PRINTF(cb, "krping_format_send failed\n");
+ printk(KERN_ERR PFX "krping_format_send failed\n");
return;
}
ret = ib_post_send(cb->qp, &cb->sq_wr, &bad_wr);
if (ret) {
- PRINTF(cb, "post send error %d\n", ret);
+ printk(KERN_ERR PFX "post send error %d\n", ret);
return;
}
/* Spin waiting for send completion */
while ((ret = ib_poll_cq(cb->cq, 1, &wc) == 0));
if (ret < 0) {
- PRINTF(cb, "poll error %d\n", ret);
+ printk(KERN_ERR PFX "poll error %d\n", ret);
return;
}
if (wc.status) {
- PRINTF(cb, "send completion error %d\n", wc.status);
+ printk(KERN_ERR PFX "send completion error %d\n", wc.status);
return;
}
@@ -2583,23 +1687,23 @@ static void krping_bw_test_client(struct krping_cb *cb)
/* Send STAG/TO/Len to client */
krping_format_send(cb, cb->start_dma_addr);
if (cb->state == ERROR) {
- PRINTF(cb, "krping_format_send failed\n");
+ printk(KERN_ERR PFX "krping_format_send failed\n");
return;
}
ret = ib_post_send(cb->qp, &cb->sq_wr, &bad_wr);
if (ret) {
- PRINTF(cb, "post send error %d\n", ret);
+ printk(KERN_ERR PFX "post send error %d\n", ret);
return;
}
/* Spin waiting for send completion */
while ((ret = ib_poll_cq(cb->cq, 1, &wc) == 0));
if (ret < 0) {
- PRINTF(cb, "poll error %d\n", ret);
+ printk(KERN_ERR PFX "poll error %d\n", ret);
return;
}
if (wc.status) {
- PRINTF(cb, "send completion error %d\n", wc.status);
+ printk(KERN_ERR PFX "send completion error %d\n", wc.status);
return;
}
@@ -2611,261 +1715,101 @@ static void krping_bw_test_client(struct krping_cb *cb)
bw_test(cb);
}
-
/*
- * fastreg 2 valid different mrs and verify the completions.
+ * Manual qp flush test
*/
-static void krping_fr_test1(struct krping_cb *cb)
+static void flush_qp(struct krping_cb *cb)
{
- struct ib_fast_reg_page_list *pl;
- struct ib_send_wr fr, *bad;
+ struct ib_send_wr wr = { 0 }, *bad;
+ struct ib_recv_wr recv_wr = { 0 }, *recv_bad;
struct ib_wc wc;
- struct ib_mr *mr1, *mr2;
- int i;
int ret;
- int size = cb->size;
- int plen = (((size - 1) & PAGE_MASK) + PAGE_SIZE) >> PAGE_SHIFT;
- int count = 0;
-
- pl = ib_alloc_fast_reg_page_list(cb->qp->device, plen);
- if (IS_ERR(pl)) {
- PRINTF(cb, "ib_alloc_fast_reg_page_list failed %ld\n", PTR_ERR(pl));
- return;
- }
-
- mr1 = ib_alloc_fast_reg_mr(cb->pd, plen);
- if (IS_ERR(mr1)) {
- PRINTF(cb, "ib_alloc_fast_reg_mr failed %ld\n", PTR_ERR(pl));
- goto err1;
- }
- mr2 = ib_alloc_fast_reg_mr(cb->pd, plen);
- if (IS_ERR(mr2)) {
- PRINTF(cb, "ib_alloc_fast_reg_mr failed %ld\n", PTR_ERR(pl));
- goto err2;
- }
-
+ int flushed = 0;
+ int ccnt = 0;
- for (i=0; i<plen; i++)
- pl->page_list[i] = i * PAGE_SIZE;
+ rdma_disconnect(cb->cm_id);
+ DEBUG_LOG("disconnected!\n");
- memset(&fr, 0, sizeof fr);
- fr.opcode = IB_WR_FAST_REG_MR;
- fr.wr_id = 1;
- fr.wr.fast_reg.page_shift = PAGE_SHIFT;
- fr.wr.fast_reg.length = size;
- fr.wr.fast_reg.page_list = pl;
- fr.wr.fast_reg.page_list_len = plen;
- fr.wr.fast_reg.iova_start = 0;
- fr.wr.fast_reg.access_flags = IB_ACCESS_REMOTE_WRITE | IB_ACCESS_LOCAL_WRITE;
- fr.send_flags = IB_SEND_SIGNALED;
- fr.wr.fast_reg.rkey = mr1->rkey;
- DEBUG_LOG(cb, "%s fr1: stag 0x%x plen %u size %u depth %u\n", __func__, fr.wr.fast_reg.rkey, plen, cb->size, cb->txdepth);
- ret = ib_post_send(cb->qp, &fr, &bad);
+ wr.opcode = IB_WR_SEND;
+ wr.wr_id = 0xdeadbeefcafebabe;
+ ret = ib_post_send(cb->qp, &wr, &bad);
if (ret) {
- PRINTF(cb, "ib_post_send failed %d\n", ret);
- goto err3;
- }
- fr.wr.fast_reg.rkey = mr2->rkey;
- DEBUG_LOG(cb, "%s fr2: stag 0x%x plen %u size %u depth %u\n", __func__, fr.wr.fast_reg.rkey, plen, cb->size, cb->txdepth);
- ret = ib_post_send(cb->qp, &fr, &bad);
- if (ret) {
- PRINTF(cb, "ib_post_send failed %d\n", ret);
- goto err3;
- }
-
- DEBUG_LOG(cb, "sleeping 1 second\n");
- wait_event_interruptible_timeout(cb->sem, cb->state == ERROR, HZ);
- do {
- ret = ib_poll_cq(cb->cq, 1, &wc);
- if (ret < 0) {
- PRINTF(cb, "ib_poll_cq failed %d\n", ret);
- goto err3;
- }
- if (ret == 1) {
- DEBUG_LOG(cb, "completion status %u wr %s\n",
- wc.status, wc.wr_id == 1 ? "fr" : "inv");
- count++;
- } else if (krping_sigpending()) {
- PRINTF(cb, "signal!\n");
- goto err3;
- }
-
- wait_event_interruptible_timeout(cb->sem, cb->state == ERROR, HZ);
- } while (count != 2);
-err3:
- DEBUG_LOG(cb, "sleeping 1 second\n");
- wait_event_interruptible_timeout(cb->sem, cb->state == ERROR, HZ);
- DEBUG_LOG(cb, "draining the cq...\n");
- do {
- ret = ib_poll_cq(cb->cq, 1, &wc);
- if (ret < 0) {
- PRINTF(cb, "ib_poll_cq failed %d\n", ret);
- break;
- }
- if (ret == 1) {
- PRINTF(cb, "completion %u opcode %u\n", wc.status, wc.opcode);
- }
- } while (ret == 1);
- DEBUG_LOG(cb, "destroying fr mr2!\n");
-
- ib_dereg_mr(mr2);
-err2:
- DEBUG_LOG(cb, "destroying fr mr1!\n");
- ib_dereg_mr(mr1);
-err1:
- DEBUG_LOG(cb, "destroying fr page list!\n");
- ib_free_fast_reg_page_list(pl);
- DEBUG_LOG(cb, "%s done!\n", __func__);
-}
-
-/*
- * fastreg the same mr twice, 2nd one should produce error cqe.
- */
-static void krping_fr_test2(struct krping_cb *cb)
-{
- struct ib_fast_reg_page_list *pl;
- struct ib_send_wr fr, *bad;
- struct ib_wc wc;
- struct ib_mr *mr1;
- int i;
- int ret;
- int size = cb->size;
- int plen = (((size - 1) & PAGE_MASK) + PAGE_SIZE) >> PAGE_SHIFT;
- int count = 0;
-
- pl = ib_alloc_fast_reg_page_list(cb->qp->device, plen);
- if (IS_ERR(pl)) {
- PRINTF(cb, "ib_alloc_fast_reg_page_list failed %ld\n", PTR_ERR(pl));
+ printk(KERN_ERR PFX "%s post_send failed ret %d\n", __func__, ret);
return;
}
- mr1 = ib_alloc_fast_reg_mr(cb->pd, plen);
- if (IS_ERR(mr1)) {
- PRINTF(cb, "ib_alloc_fast_reg_mr failed %ld\n", PTR_ERR(pl));
- goto err1;
- }
-
- for (i=0; i<plen; i++)
- pl->page_list[i] = i * PAGE_SIZE;
-
- memset(&fr, 0, sizeof fr);
- fr.opcode = IB_WR_FAST_REG_MR;
- fr.wr_id = 1;
- fr.wr.fast_reg.page_shift = PAGE_SHIFT;
- fr.wr.fast_reg.length = size;
- fr.wr.fast_reg.page_list = pl;
- fr.wr.fast_reg.page_list_len = plen;
- fr.wr.fast_reg.iova_start = 0;
- fr.wr.fast_reg.access_flags = IB_ACCESS_REMOTE_WRITE | IB_ACCESS_LOCAL_WRITE;
- fr.send_flags = IB_SEND_SIGNALED;
- fr.wr.fast_reg.rkey = mr1->rkey;
- DEBUG_LOG(cb, "%s fr1: stag 0x%x plen %u size %u depth %u\n", __func__, fr.wr.fast_reg.rkey, plen, cb->size, cb->txdepth);
- ret = ib_post_send(cb->qp, &fr, &bad);
- if (ret) {
- PRINTF(cb, "ib_post_send failed %d\n", ret);
- goto err3;
- }
- DEBUG_LOG(cb, "%s fr2: stag 0x%x plen %u size %u depth %u\n", __func__, fr.wr.fast_reg.rkey, plen, cb->size, cb->txdepth);
- ret = ib_post_send(cb->qp, &fr, &bad);
+ recv_wr.wr_id = 0xcafebabedeadbeef;
+ ret = ib_post_recv(cb->qp, &recv_wr, &recv_bad);
if (ret) {
- PRINTF(cb, "ib_post_send failed %d\n", ret);
- goto err3;
+ printk(KERN_ERR PFX "%s post_recv failed ret %d\n", __func__, ret);
+ return;
}
- DEBUG_LOG(cb, "sleeping 1 second\n");
- wait_event_interruptible_timeout(cb->sem, cb->state == ERROR, HZ);
+ /* poll until the flush WRs complete */
do {
ret = ib_poll_cq(cb->cq, 1, &wc);
if (ret < 0) {
- PRINTF(cb, "ib_poll_cq failed %d\n", ret);
- goto err3;
- }
- if (ret == 1) {
- DEBUG_LOG(cb, "completion status %u wr %s\n",
- wc.status, wc.wr_id == 1 ? "fr" : "inv");
- count++;
- } else if (krping_sigpending()) {
- PRINTF(cb, "signal!\n");
- goto err3;
- }
- wait_event_interruptible_timeout(cb->sem, cb->state == ERROR, HZ);
- } while (count != 2);
-err3:
- DEBUG_LOG(cb, "sleeping 1 second\n");
- wait_event_interruptible_timeout(cb->sem, cb->state == ERROR, HZ);
- DEBUG_LOG(cb, "draining the cq...\n");
- do {
- ret = ib_poll_cq(cb->cq, 1, &wc);
- if (ret < 0) {
- PRINTF(cb, "ib_poll_cq failed %d\n", ret);
- break;
- }
- if (ret == 1) {
- PRINTF(cb, "completion %u opcode %u\n", wc.status, wc.opcode);
+ printk(KERN_ERR PFX "ib_poll_cq failed %d\n", ret);
+ return;
}
- } while (ret == 1);
- DEBUG_LOG(cb, "destroying fr mr1!\n");
- ib_dereg_mr(mr1);
-err1:
- DEBUG_LOG(cb, "destroying fr page list!\n");
- ib_free_fast_reg_page_list(pl);
- DEBUG_LOG(cb, "%s done!\n", __func__);
+ if (ret == 0)
+ continue;
+ ccnt++;
+ if (wc.wr_id == 0xdeadbeefcafebabe ||
+ wc.wr_id == 0xcafebabedeadbeef)
+ flushed++;
+ } while (flushed != 2);
+ DEBUG_LOG("qp_flushed! ccnt %u\n", ccnt);
}
-/*
- * fastreg pipelined in a loop as fast as we can until the user interrupts.
- * NOTE: every 9 seconds we sleep for 1 second to keep the kernel happy.
- */
-static void krping_fr_test3(struct krping_cb *cb)
+static void krping_fr_test(struct krping_cb *cb)
{
- struct ib_fast_reg_page_list *pl;
- struct ib_send_wr fr, inv, *bad;
+ struct ib_send_wr inv, *bad;
+ struct ib_reg_wr fr;
struct ib_wc wc;
u8 key = 0;
struct ib_mr *mr;
- int i;
int ret;
int size = cb->size;
int plen = (((size - 1) & PAGE_MASK) + PAGE_SIZE) >> PAGE_SHIFT;
unsigned long start;
int count = 0;
int scnt = 0;
+ struct scatterlist sg = {0};
-
- pl = ib_alloc_fast_reg_page_list(cb->qp->device, plen);
- if (IS_ERR(pl)) {
- PRINTF(cb, "ib_alloc_fast_reg_page_list failed %ld\n", PTR_ERR(pl));
+ mr = ib_alloc_mr(cb->pd, IB_MR_TYPE_MEM_REG, plen);
+ if (IS_ERR(mr)) {
+ printk(KERN_ERR PFX "ib_alloc_mr failed %ld\n", PTR_ERR(mr));
return;
}
-
- mr = ib_alloc_fast_reg_mr(cb->pd, plen);
- if (IS_ERR(mr)) {
- PRINTF(cb, "ib_alloc_fast_reg_mr failed %ld\n", PTR_ERR(pl));
- goto err1;
+
+ sg_dma_address(&sg) = (dma_addr_t)0xcafebabe0000ULL;
+ sg_dma_len(&sg) = size;
+ ret = ib_map_mr_sg(mr, &sg, 1, NULL, PAGE_SIZE);
+ if (ret <= 0) {
+ printk(KERN_ERR PFX "ib_map_mr_sge err %d\n", ret);
+ goto err2;
}
- for (i=0; i<plen; i++)
- pl->page_list[i] = i * PAGE_SIZE;
-
memset(&fr, 0, sizeof fr);
- fr.opcode = IB_WR_FAST_REG_MR;
- fr.wr.fast_reg.page_shift = PAGE_SHIFT;
- fr.wr.fast_reg.length = size;
- fr.wr.fast_reg.page_list = pl;
- fr.wr.fast_reg.page_list_len = plen;
- fr.wr.fast_reg.iova_start = 0;
- fr.send_flags = IB_SEND_SIGNALED;
- fr.wr.fast_reg.access_flags = IB_ACCESS_REMOTE_WRITE | IB_ACCESS_LOCAL_WRITE;
- fr.next = &inv;
+ fr.wr.opcode = IB_WR_REG_MR;
+ fr.access = IB_ACCESS_REMOTE_WRITE | IB_ACCESS_LOCAL_WRITE;
+ fr.mr = mr;
+ fr.wr.next = &inv;
+
memset(&inv, 0, sizeof inv);
inv.opcode = IB_WR_LOCAL_INV;
inv.send_flags = IB_SEND_SIGNALED;
- DEBUG_LOG(cb, "fr_test: stag index 0x%x plen %u size %u depth %u\n", mr->rkey >> 8, plen, cb->size, cb->txdepth);
+ DEBUG_LOG("fr_test: stag index 0x%x plen %u size %u depth %u\n", mr->rkey >> 8, plen, cb->size, cb->txdepth);
start = time_uptime;
- while (1) {
+ while (!cb->count || count <= cb->count) {
+ if (SIGPENDING(curthread)) {
+ printk(KERN_ERR PFX "signal!\n");
+ break;
+ }
if ((time_uptime - start) >= 9) {
- DEBUG_LOG(cb, "fr_test: pausing 1 second! count %u latest size %u plen %u\n", count, size, plen);
+ DEBUG_LOG("fr_test: pausing 1 second! count %u latest size %u plen %u\n", count, size, plen);
wait_event_interruptible_timeout(cb->sem, cb->state == ERROR, HZ);
if (cb->state == ERROR)
break;
@@ -2873,183 +1817,44 @@ static void krping_fr_test3(struct krping_cb *cb)
}
while (scnt < (cb->txdepth>>1)) {
ib_update_fast_reg_key(mr, ++key);
- fr.wr.fast_reg.rkey = mr->rkey;
+ fr.key = mr->rkey;
inv.ex.invalidate_rkey = mr->rkey;
+
size = arc4random() % cb->size;
if (size == 0)
size = cb->size;
- plen = (((size - 1) & PAGE_MASK) + PAGE_SIZE) >> PAGE_SHIFT;
- fr.wr.fast_reg.length = size;
- fr.wr.fast_reg.page_list_len = plen;
- ret = ib_post_send(cb->qp, &fr, &bad);
+ sg_dma_len(&sg) = size;
+ ret = ib_map_mr_sg(mr, &sg, 1, NULL, PAGE_SIZE);
+ if (ret <= 0) {
+ printk(KERN_ERR PFX "ib_map_mr_sge err %d\n", ret);
+ goto err2;
+ }
+ ret = ib_post_send(cb->qp, &fr.wr, &bad);
if (ret) {
- PRINTF(cb, "ib_post_send failed %d\n", ret);
+ printk(KERN_ERR PFX "ib_post_send failed %d\n", ret);
goto err2;
}
- scnt+=2;
+ scnt++;
}
- do {
- ret = ib_poll_cq(cb->cq, 1, &wc);
- if (ret < 0) {
- PRINTF(cb, "ib_poll_cq failed %d\n", ret);
- goto err2;
- }
- if (ret == 1) {
- if (wc.status) {
- PRINTF(cb, "completion error %u\n", wc.status);
- goto err2;
- }
- count++;
- scnt--;
- }
- else if (krping_sigpending()) {
- PRINTF(cb, "signal!\n");
- goto err2;
- }
- } while (ret == 1);
- }
-err2:
- DEBUG_LOG(cb, "sleeping 1 second\n");
- wait_event_interruptible_timeout(cb->sem, cb->state == ERROR, HZ);
- DEBUG_LOG(cb, "draining the cq...\n");
- do {
ret = ib_poll_cq(cb->cq, 1, &wc);
if (ret < 0) {
- PRINTF(cb, "ib_poll_cq failed %d\n", ret);
- break;
+ printk(KERN_ERR PFX "ib_poll_cq failed %d\n", ret);
+ goto err2;
}
if (ret == 1) {
if (wc.status) {
- PRINTF(cb, "completion error %u opcode %u\n", wc.status, wc.opcode);
+ printk(KERN_ERR PFX "completion error %u\n", wc.status);
+ goto err2;
}
- }
- } while (ret == 1);
- DEBUG_LOG(cb, "fr_test: done!\n");
- ib_dereg_mr(mr);
-err1:
- DEBUG_LOG(cb, "destroying fr page list!\n");
- ib_free_fast_reg_page_list(pl);
- DEBUG_LOG(cb, "%s done!\n", __func__);
-}
-
-/*
- * fastreg 1 and invalidate 1 mr and verify completion.
- */
-static void krping_fr_test4(struct krping_cb *cb)
-{
- struct ib_fast_reg_page_list *pl;
- struct ib_send_wr fr, inv, *bad;
- struct ib_wc wc;
- struct ib_mr *mr1;
- int i;
- int ret;
- int size = cb->size;
- int plen = (((size - 1) & PAGE_MASK) + PAGE_SIZE) >> PAGE_SHIFT;
- int count = 0;
-
- pl = ib_alloc_fast_reg_page_list(cb->qp->device, plen);
- if (IS_ERR(pl)) {
- PRINTF(cb, "ib_alloc_fast_reg_page_list failed %ld\n", PTR_ERR(pl));
- return;
- }
-
- mr1 = ib_alloc_fast_reg_mr(cb->pd, plen);
- if (IS_ERR(mr1)) {
- PRINTF(cb, "ib_alloc_fast_reg_mr failed %ld\n", PTR_ERR(pl));
- goto err1;
- }
-
- for (i=0; i<plen; i++)
- pl->page_list[i] = i * PAGE_SIZE;
-
- memset(&fr, 0, sizeof fr);
- fr.opcode = IB_WR_FAST_REG_MR;
- fr.wr_id = 1;
- fr.wr.fast_reg.page_shift = PAGE_SHIFT;
- fr.wr.fast_reg.length = size;
- fr.wr.fast_reg.page_list = pl;
- fr.wr.fast_reg.page_list_len = plen;
- fr.wr.fast_reg.iova_start = 0;
- fr.wr.fast_reg.access_flags = IB_ACCESS_REMOTE_WRITE | IB_ACCESS_LOCAL_WRITE;
- fr.send_flags = IB_SEND_SIGNALED;
- fr.wr.fast_reg.rkey = mr1->rkey;
- fr.next = &inv;
- memset(&inv, 0, sizeof inv);
- inv.opcode = IB_WR_LOCAL_INV;
- inv.ex.invalidate_rkey = mr1->rkey;
-
- DEBUG_LOG(cb, "%s fr1: stag 0x%x plen %u size %u depth %u\n", __func__, fr.wr.fast_reg.rkey, plen, cb->size, cb->txdepth);
- ret = ib_post_send(cb->qp, &fr, &bad);
- if (ret) {
- PRINTF(cb, "ib_post_send failed %d\n", ret);
- goto err3;
- }
- DEBUG_LOG(cb, "sleeping 1 second\n");
- wait_event_interruptible_timeout(cb->sem, cb->state == ERROR, HZ);
- do {
- ret = ib_poll_cq(cb->cq, 1, &wc);
- if (ret < 0) {
- PRINTF(cb, "ib_poll_cq failed %d\n", ret);
- goto err3;
- }
- if (ret == 1) {
- DEBUG_LOG(cb, "completion status %u wr %s\n",
- wc.status, wc.wr_id == 1 ? "fr" : "inv");
count++;
- } else if (krping_sigpending()) {
- PRINTF(cb, "signal!\n");
- goto err3;
- }
- wait_event_interruptible_timeout(cb->sem, cb->state == ERROR, HZ);
- } while (count != 1);
-err3:
- DEBUG_LOG(cb, "sleeping 1 second\n");
- wait_event_interruptible_timeout(cb->sem, cb->state == ERROR, HZ);
- DEBUG_LOG(cb, "draining the cq...\n");
- do {
- ret = ib_poll_cq(cb->cq, 1, &wc);
- if (ret < 0) {
- PRINTF(cb, "ib_poll_cq failed %d\n", ret);
- break;
- }
- if (ret == 1) {
- PRINTF(cb, "completion %u opcode %u\n", wc.status, wc.opcode);
+ scnt--;
}
- } while (ret == 1);
- DEBUG_LOG(cb, "destroying fr mr1!\n");
- ib_dereg_mr(mr1);
-err1:
- DEBUG_LOG(cb, "destroying fr page list!\n");
- ib_free_fast_reg_page_list(pl);
- DEBUG_LOG(cb, "%s done!\n", __func__);
-}
-
-static void krping_fr_test(struct krping_cb *cb)
-{
- switch (cb->testnum) {
- case 1:
- krping_fr_test1(cb);
- break;
- case 2:
- krping_fr_test2(cb);
- break;
- case 3:
- krping_fr_test3(cb);
- break;
- case 4:
- krping_fr_test4(cb);
- break;
- case 5:
- krping_fr_test5_client(cb);
- break;
- case 6:
- krping_fr_test6_client(cb);
- break;
- default:
- PRINTF(cb, "Unkown frtest num %u\n", cb->testnum);
- break;
}
+err2:
+ flush_qp(cb);
+ DEBUG_LOG("fr_test: done!\n");
+ ib_dereg_mr(mr);
}
static int krping_connect_client(struct krping_cb *cb)
@@ -3064,66 +1869,45 @@ static int krping_connect_client(struct krping_cb *cb)
ret = rdma_connect(cb->cm_id, &conn_param);
if (ret) {
- PRINTF(cb, "rdma_connect error %d\n", ret);
+ printk(KERN_ERR PFX "rdma_connect error %d\n", ret);
return ret;
}
wait_event_interruptible(cb->sem, cb->state >= CONNECTED);
if (cb->state == ERROR) {
- PRINTF(cb, "wait for CONNECTED state %d\n", cb->state);
+ printk(KERN_ERR PFX "wait for CONNECTED state %d\n", cb->state);
return -1;
}
- DEBUG_LOG(cb, "rdma_connect successful\n");
+ DEBUG_LOG("rdma_connect successful\n");
return 0;
}
static int krping_bind_client(struct krping_cb *cb)
{
- union {
- struct sockaddr_in v4;
- struct sockaddr_in6 v6;
- } sin;
+ struct sockaddr_storage sin;
int ret;
- memset(&sin, 0, sizeof(sin));
+ fill_sockaddr(&sin, cb);
- switch (cb->addr_type) {
- case AF_INET:
- sin.v4.sin_len = sizeof sin.v4;
- sin.v4.sin_family = AF_INET;
- sin.v4.sin_addr = cb->addr.v4;
- sin.v4.sin_port = cb->port;
- break;
- case AF_INET6:
- sin.v6.sin6_len = sizeof sin.v6;
- sin.v6.sin6_family = AF_INET6;
- sin.v6.sin6_addr = cb->addr.v6;
- sin.v6.sin6_port = cb->port;
- break;
- default:
- return (-EINVAL);
- }
-
- ret = rdma_resolve_addr(cb->cm_id, NULL, (struct sockaddr *) &sin,
- 2000);
+ ret = rdma_resolve_addr(cb->cm_id, NULL, (struct sockaddr *)&sin, 2000);
if (ret) {
- PRINTF(cb, "rdma_resolve_addr error %d\n", ret);
+ printk(KERN_ERR PFX "rdma_resolve_addr error %d\n", ret);
return ret;
}
wait_event_interruptible(cb->sem, cb->state >= ROUTE_RESOLVED);
if (cb->state != ROUTE_RESOLVED) {
- PRINTF(cb,
+ printk(KERN_ERR PFX
"addr/route resolution did not resolve: state %d\n",
cb->state);
return -EINTR;
}
- if (cb->mem == FASTREG && !fastreg_supported(cb, 0))
+ if (!reg_supported(cb->cm_id->device))
return -EINVAL;
- DEBUG_LOG(cb, "rdma_resolve_addr - rdma_resolve_route successful\n");
+ DEBUG_LOG("rdma_resolve_addr - rdma_resolve_route successful\n");
return 0;
}
@@ -3138,25 +1922,25 @@ static void krping_run_client(struct krping_cb *cb)
ret = krping_setup_qp(cb, cb->cm_id);
if (ret) {
- PRINTF(cb, "setup_qp failed: %d\n", ret);
+ printk(KERN_ERR PFX "setup_qp failed: %d\n", ret);
return;
}
ret = krping_setup_buffers(cb);
if (ret) {
- PRINTF(cb, "krping_setup_buffers failed: %d\n", ret);
+ printk(KERN_ERR PFX "krping_setup_buffers failed: %d\n", ret);
goto err1;
}
ret = ib_post_recv(cb->qp, &cb->rq_wr, &bad_wr);
if (ret) {
- PRINTF(cb, "ib_post_recv failed: %d\n", ret);
+ printk(KERN_ERR PFX "ib_post_recv failed: %d\n", ret);
goto err2;
}
ret = krping_connect_client(cb);
if (ret) {
- PRINTF(cb, "connect error %d\n", ret);
+ printk(KERN_ERR PFX "connect error %d\n", ret);
goto err2;
}
@@ -3195,7 +1979,7 @@ krping_get_ipv6_scope_id(char *name)
return (retval);
}
-int krping_doit(char *cmd, void *cookie)
+int krping_doit(char *cmd)
{
struct krping_cb *cb;
int op;
@@ -3212,13 +1996,10 @@ int krping_doit(char *cmd, void *cookie)
list_add_tail(&cb->list, &krping_cbs);
mutex_unlock(&krping_mutex);
- cb->cookie = cookie;
cb->server = -1;
cb->state = IDLE;
cb->size = 64;
cb->txdepth = RPING_SQ_DEPTH;
- cb->mem = DMA;
- cb->addr_type = AF_INET;
init_waitqueue_head(&cb->sem);
while ((op = krping_getopt("krping", &cmd, krping_opts, NULL, &optarg,
@@ -3227,9 +2008,9 @@ int krping_doit(char *cmd, void *cookie)
case 'a':
cb->addr_str = optarg;
cb->addr_type = AF_INET;
- DEBUG_LOG(cb, "ipv4addr (%s)\n", optarg);
- if (inet_pton(AF_INET, optarg, &cb->addr) != 1) {
- PRINTF(cb, "bad addr string %s\n",
+ DEBUG_LOG("ipaddr (%s)\n", optarg);
+ if (inet_pton(AF_INET, optarg, cb->addr) != 1) {
+ printk(KERN_ERR PFX "bad addr string %s\n",
optarg);
ret = EINVAL;
}
@@ -3237,67 +2018,67 @@ int krping_doit(char *cmd, void *cookie)
case 'A':
cb->addr_str = optarg;
cb->addr_type = AF_INET6;
- DEBUG_LOG(cb, "ipv6addr (%s)\n", optarg);
+ DEBUG_LOG("ipv6addr (%s)\n", optarg);
scope = strstr(optarg, "%");
/* extract scope ID, if any */
if (scope != NULL)
*scope++ = 0;
/* extract IPv6 network address */
- if (inet_pton(AF_INET6, optarg, &cb->addr) != 1) {
- PRINTF(cb, "bad addr string %s\n",
+ if (inet_pton(AF_INET6, optarg, cb->addr) != 1) {
+ printk(KERN_ERR PFX "bad addr string %s\n",
optarg);
ret = EINVAL;
- } else if (IN6_IS_SCOPE_LINKLOCAL(&cb->addr.v6) ||
- IN6_IS_ADDR_MC_INTFACELOCAL(&cb->addr.v6)) {
+ } else if (IN6_IS_SCOPE_LINKLOCAL((struct in6_addr *)cb->addr) ||
+ IN6_IS_ADDR_MC_INTFACELOCAL((struct in6_addr *)cb->addr)) {
uint16_t scope_id = krping_get_ipv6_scope_id(scope);
- DEBUG_LOG(cb, "ipv6 scope ID = %d\n", scope_id);
- cb->addr.v6.s6_addr[2] = scope_id >> 8;
- cb->addr.v6.s6_addr[3] = scope_id & 0xFF;
+ DEBUG_LOG("ipv6 scope ID = %d\n", scope_id);
+ cb->addr[2] = scope_id >> 8;
+ cb->addr[3] = scope_id & 0xFF;
}
break;
case 'p':
cb->port = htons(optint);
- DEBUG_LOG(cb, "port %d\n", (int)optint);
+ DEBUG_LOG("port %d\n", (int)optint);
break;
case 'P':
cb->poll = 1;
- DEBUG_LOG(cb, "server\n");
+ DEBUG_LOG("server\n");
break;
case 's':
cb->server = 1;
- DEBUG_LOG(cb, "server\n");
+ DEBUG_LOG("server\n");
break;
case 'c':
cb->server = 0;
- DEBUG_LOG(cb, "client\n");
+ DEBUG_LOG("client\n");
break;
case 'S':
cb->size = optint;
if ((cb->size < 1) ||
(cb->size > RPING_BUFSIZE)) {
- PRINTF(cb, "Invalid size %d "
+ printk(KERN_ERR PFX "Invalid size %d "
"(valid range is 1 to %d)\n",
cb->size, RPING_BUFSIZE);
ret = EINVAL;
} else
- DEBUG_LOG(cb, "size %d\n", (int)optint);
+ DEBUG_LOG("size %d\n", (int)optint);
break;
case 'C':
cb->count = optint;
if (cb->count < 0) {
- PRINTF(cb, "Invalid count %d\n",
+ printk(KERN_ERR PFX "Invalid count %d\n",
cb->count);
ret = EINVAL;
} else
- DEBUG_LOG(cb, "count %d\n", (int) cb->count);
+ DEBUG_LOG("count %d\n", (int) cb->count);
break;
case 'v':
cb->verbose++;
- DEBUG_LOG(cb, "verbose\n");
+ DEBUG_LOG("verbose\n");
break;
case 'V':
cb->validate++;
- DEBUG_LOG(cb, "validate data\n");
+ DEBUG_LOG("validate data\n");
break;
case 'l':
cb->wlat++;
@@ -3311,45 +2092,27 @@ int krping_doit(char *cmd, void *cookie)
case 'd':
cb->duplex++;
break;
- case 'm':
- if (!strncmp(optarg, "dma", 3))
- cb->mem = DMA;
- else if (!strncmp(optarg, "fastreg", 7))
- cb->mem = FASTREG;
- else if (!strncmp(optarg, "mw", 2))
- cb->mem = MW;
- else if (!strncmp(optarg, "mr", 2))
- cb->mem = MR;
- else {
- PRINTF(cb, "unknown mem mode %s. "
- "Must be dma, fastreg, mw, or mr\n",
- optarg);
- ret = -EINVAL;
- break;
- }
- break;
case 'I':
cb->server_invalidate = 1;
break;
case 'T':
cb->txdepth = optint;
- DEBUG_LOG(cb, "txdepth %d\n", (int) cb->txdepth);
+ DEBUG_LOG("txdepth %d\n", (int) cb->txdepth);
break;
case 'Z':
cb->local_dma_lkey = 1;
- DEBUG_LOG(cb, "using local dma lkey\n");
+ DEBUG_LOG("using local dma lkey\n");
break;
case 'R':
cb->read_inv = 1;
- DEBUG_LOG(cb, "using read-with-inv\n");
+ DEBUG_LOG("using read-with-inv\n");
break;
case 'f':
cb->frtest = 1;
- cb->testnum = optint;
- DEBUG_LOG(cb, "fast-reg test!\n");
+ DEBUG_LOG("fast-reg test!\n");
break;
default:
- PRINTF(cb, "unknown opt %s\n", optarg);
+ printk(KERN_ERR PFX "unknown opt %s\n", optarg);
ret = -EINVAL;
break;
}
@@ -3358,48 +2121,43 @@ int krping_doit(char *cmd, void *cookie)
goto out;
if (cb->server == -1) {
- PRINTF(cb, "must be either client or server\n");
+ printk(KERN_ERR PFX "must be either client or server\n");
ret = -EINVAL;
goto out;
}
- if ((cb->frtest + cb->bw + cb->rlat + cb->wlat) > 1) {
- PRINTF(cb, "Pick only one test: fr, bw, rlat, wlat\n");
- ret = -EINVAL;
- goto out;
- }
- if (cb->server_invalidate && cb->mem != FASTREG) {
- PRINTF(cb, "server_invalidate only valid with fastreg mem_mode\n");
+ if (cb->server && cb->frtest) {
+ printk(KERN_ERR PFX "must be client to run frtest\n");
ret = -EINVAL;
goto out;
}
- if (cb->read_inv && cb->mem != FASTREG) {
- PRINTF(cb, "read_inv only valid with fastreg mem_mode\n");
+ if ((cb->frtest + cb->bw + cb->rlat + cb->wlat) > 1) {
+ printk(KERN_ERR PFX "Pick only one test: fr, bw, rlat, wlat\n");
ret = -EINVAL;
goto out;
}
- if (cb->mem != MR && (cb->wlat || cb->rlat || cb->bw || cb->frtest)) {
- PRINTF(cb, "wlat, rlat, and bw tests only support mem_mode MR\n");
+ if (cb->wlat || cb->rlat || cb->bw) {
+ printk(KERN_ERR PFX "wlat, rlat, and bw tests only support mem_mode MR - which is no longer supported\n");
ret = -EINVAL;
goto out;
}
- cb->cm_id = rdma_create_id(krping_cma_event_handler, cb, RDMA_PS_TCP, IB_QPT_RC);
+ cb->cm_id = rdma_create_id(&init_net, krping_cma_event_handler, cb, RDMA_PS_TCP, IB_QPT_RC);
if (IS_ERR(cb->cm_id)) {
ret = PTR_ERR(cb->cm_id);
- PRINTF(cb, "rdma_create_id error %d\n", ret);
+ printk(KERN_ERR PFX "rdma_create_id error %d\n", ret);
goto out;
}
- DEBUG_LOG(cb, "created cm_id %p\n", cb->cm_id);
+ DEBUG_LOG("created cm_id %p\n", cb->cm_id);
if (cb->server)
krping_run_server(cb);
else
krping_run_client(cb);
- DEBUG_LOG(cb, "destroy cm_id %p\n", cb->cm_id);
+ DEBUG_LOG("destroy cm_id %p\n", cb->cm_id);
rdma_destroy_id(cb->cm_id);
out:
mutex_lock(&krping_mutex);
@@ -3419,9 +2177,3 @@ krping_walk_cb_list(void (*f)(struct krping_stats *, void *), void *arg)
(*f)(cb->pd ? &cb->stats : NULL, arg);
mutex_unlock(&krping_mutex);
}
-
-void krping_init(void)
-{
-
- mutex_init(&krping_mutex);
-}
diff --git a/sys/contrib/rdma/krping/krping.h b/sys/contrib/rdma/krping/krping.h
index f201d10..5987b1c 100644
--- a/sys/contrib/rdma/krping/krping.h
+++ b/sys/contrib/rdma/krping/krping.h
@@ -14,7 +14,6 @@ struct krping_stats {
char name[16];
};
-int krping_doit(char *, void *);
+int krping_doit(char *);
void krping_walk_cb_list(void (*)(struct krping_stats *, void *), void *);
-void krping_init(void);
int krping_sigpending(void);
diff --git a/sys/contrib/rdma/krping/krping_dev.c b/sys/contrib/rdma/krping/krping_dev.c
index 7902ebf..b1e009b 100644
--- a/sys/contrib/rdma/krping/krping_dev.c
+++ b/sys/contrib/rdma/krping/krping_dev.c
@@ -72,7 +72,6 @@ krping_loader(struct module *m, int what, void *arg)
switch (what) {
case MOD_LOAD: /* kldload */
- krping_init();
krping_dev = make_dev(&krping_cdevsw, 0, UID_ROOT, GID_WHEEL,
0600, "krping");
printf("Krping device loaded.\n");
@@ -204,7 +203,7 @@ krping_write(struct cdev *dev, struct uio *uio, int ioflag)
*cp = 0;
krpingmsg->len = (unsigned long)(cp - krpingmsg->msg);
uprintf("krping: write string = |%s|\n", krpingmsg->msg);
- err = krping_doit(krpingmsg->msg, curproc);
+ err = krping_doit(krpingmsg->msg);
free(krpingmsg, M_DEVBUF);
return(err);
}
diff --git a/sys/contrib/rdma/krping_compat/getopt.c b/sys/contrib/rdma/krping_compat/getopt.c
new file mode 100644
index 0000000..24e62e1
--- /dev/null
+++ b/sys/contrib/rdma/krping_compat/getopt.c
@@ -0,0 +1,78 @@
+/*
+ * lifted from fs/ncpfs/getopt.c
+ *
+ */
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include <sys/types.h>
+#include <linux/kernel.h>
+#include <linux/string.h>
+
+#include "getopt.h"
+
+/**
+ * krping_getopt - option parser
+ * @caller: name of the caller, for error messages
+ * @options: the options string
+ * @opts: an array of &struct option entries controlling parser operations
+ * @optopt: output; will contain the current option
+ * @optarg: output; will contain the value (if one exists)
+ * @flag: output; may be NULL; should point to a long for or'ing flags
+ * @value: output; may be NULL; will be overwritten with the integer value
+ * of the current argument.
+ *
+ * Helper to parse options on the format used by mount ("a=b,c=d,e,f").
+ * Returns opts->val if a matching entry in the 'opts' array is found,
+ * 0 when no more tokens are found, -1 if an error is encountered.
+ */
+int krping_getopt(const char *caller, char **options,
+ const struct krping_option *opts, char **optopt,
+ char **optarg, unsigned long *value)
+{
+ char *token;
+ char *val;
+
+ do {
+ if ((token = strsep(options, ",")) == NULL)
+ return 0;
+ } while (*token == '\0');
+ if (optopt)
+ *optopt = token;
+
+ if ((val = strchr (token, '=')) != NULL) {
+ *val++ = 0;
+ }
+ *optarg = val;
+ for (; opts->name; opts++) {
+ if (!strcmp(opts->name, token)) {
+ if (!val) {
+ if (opts->has_arg & OPT_NOPARAM) {
+ return opts->val;
+ }
+ printk(KERN_INFO "%s: the %s option requires "
+ "an argument\n", caller, token);
+ return -EINVAL;
+ }
+ if (opts->has_arg & OPT_INT) {
+ char* v;
+
+ *value = simple_strtoul(val, &v, 0);
+ if (!*v) {
+ return opts->val;
+ }
+ printk(KERN_INFO "%s: invalid numeric value "
+ "in %s=%s\n", caller, token, val);
+ return -EDOM;
+ }
+ if (opts->has_arg & OPT_STRING) {
+ return opts->val;
+ }
+ printk(KERN_INFO "%s: unexpected argument %s to the "
+ "%s option\n", caller, val, token);
+ return -EINVAL;
+ }
+ }
+ printk(KERN_INFO "%s: Unrecognized option %s\n", caller, token);
+ return -EOPNOTSUPP;
+}
diff --git a/sys/contrib/rdma/krping_compat/getopt.h b/sys/contrib/rdma/krping_compat/getopt.h
new file mode 100644
index 0000000..610ec76
--- /dev/null
+++ b/sys/contrib/rdma/krping_compat/getopt.h
@@ -0,0 +1,21 @@
+/*
+ * lifted from fs/ncpfs/getopt.c
+ *
+ * $FreeBSD$
+ */
+#ifndef _KRPING_GETOPT_H
+#define _KRPING_GETOPT_H
+
+#define OPT_NOPARAM 1
+#define OPT_INT 2
+#define OPT_STRING 4
+struct krping_option {
+ const char *name;
+ unsigned int has_arg;
+ int val;
+};
+
+extern int krping_getopt(const char *caller, char **options, const struct krping_option *opts,
+ char **optopt, char **optarg, unsigned long *value);
+
+#endif /* _KRPING_GETOPT_H */
diff --git a/sys/contrib/rdma/krping_compat/krping.c b/sys/contrib/rdma/krping_compat/krping.c
new file mode 100644
index 0000000..93c1c80
--- /dev/null
+++ b/sys/contrib/rdma/krping_compat/krping.c
@@ -0,0 +1,3427 @@
+/*
+ * Copyright (c) 2005 Ammasso, Inc. All rights reserved.
+ * Copyright (c) 2006-2009 Open Grid Computing, Inc. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include <linux/module.h>
+#include <linux/moduleparam.h>
+#include <linux/slab.h>
+#include <linux/err.h>
+#include <linux/string.h>
+#include <linux/list.h>
+#include <linux/in.h>
+#include <linux/device.h>
+#include <linux/pci.h>
+#include <linux/sched.h>
+#include <linux/wait.h>
+
+#include <asm/atomic.h>
+
+#include <rdma/ib_verbs_compat.h>
+#include <rdma/rdma_cm.h>
+
+#include "krping.h"
+#include "getopt.h"
+
+extern int krping_debug;
+#define DEBUG_LOG(cb, x...) if (krping_debug) log(LOG_INFO, x)
+#define PRINTF(cb, x...) log(LOG_INFO, x)
+#define BIND_INFO 1
+
+MODULE_AUTHOR("Steve Wise");
+MODULE_DESCRIPTION("RDMA ping client/server");
+MODULE_LICENSE("Dual BSD/GPL");
+MODULE_VERSION(krping, 1);
+MODULE_DEPEND(krping, linuxkpi, 1, 1, 1);
+
+static __inline uint64_t
+get_cycles(void)
+{
+ uint32_t low, high;
+ __asm __volatile("rdtsc" : "=a" (low), "=d" (high));
+ return (low | ((u_int64_t)high << 32));
+}
+
+typedef uint64_t cycles_t;
+
+enum mem_type {
+ DMA = 1,
+ FASTREG = 2,
+ MW = 3,
+ MR = 4
+};
+
+static const struct krping_option krping_opts[] = {
+ {"count", OPT_INT, 'C'},
+ {"size", OPT_INT, 'S'},
+ {"addr", OPT_STRING, 'a'},
+ {"addr6", OPT_STRING, 'A'},
+ {"port", OPT_INT, 'p'},
+ {"verbose", OPT_NOPARAM, 'v'},
+ {"validate", OPT_NOPARAM, 'V'},
+ {"server", OPT_NOPARAM, 's'},
+ {"client", OPT_NOPARAM, 'c'},
+ {"mem_mode", OPT_STRING, 'm'},
+ {"server_inv", OPT_NOPARAM, 'I'},
+ {"wlat", OPT_NOPARAM, 'l'},
+ {"rlat", OPT_NOPARAM, 'L'},
+ {"bw", OPT_NOPARAM, 'B'},
+ {"duplex", OPT_NOPARAM, 'd'},
+ {"txdepth", OPT_INT, 'T'},
+ {"poll", OPT_NOPARAM, 'P'},
+ {"local_dma_lkey", OPT_NOPARAM, 'Z'},
+ {"read_inv", OPT_NOPARAM, 'R'},
+ {"fr", OPT_INT, 'f'},
+ {NULL, 0, 0}
+};
+
+#define htonll(x) cpu_to_be64((x))
+#define ntohll(x) cpu_to_be64((x))
+
+static struct mutex krping_mutex;
+
+/*
+ * List of running krping threads.
+ */
+static LIST_HEAD(krping_cbs);
+
+/*
+ * krping "ping/pong" loop:
+ * client sends source rkey/addr/len
+ * server receives source rkey/add/len
+ * server rdma reads "ping" data from source
+ * server sends "go ahead" on rdma read completion
+ * client sends sink rkey/addr/len
+ * server receives sink rkey/addr/len
+ * server rdma writes "pong" data to sink
+ * server sends "go ahead" on rdma write completion
+ * <repeat loop>
+ */
+
+/*
+ * These states are used to signal events between the completion handler
+ * and the main client or server thread.
+ *
+ * Once CONNECTED, they cycle through RDMA_READ_ADV, RDMA_WRITE_ADV,
+ * and RDMA_WRITE_COMPLETE for each ping.
+ */
+enum test_state {
+ IDLE = 1,
+ CONNECT_REQUEST,
+ ADDR_RESOLVED,
+ ROUTE_RESOLVED,
+ CONNECTED,
+ RDMA_READ_ADV,
+ RDMA_READ_COMPLETE,
+ RDMA_WRITE_ADV,
+ RDMA_WRITE_COMPLETE,
+ ERROR
+};
+
+struct krping_rdma_info {
+ uint64_t buf;
+ uint32_t rkey;
+ uint32_t size;
+};
+
+/*
+ * Default max buffer size for IO...
+ */
+#define RPING_BUFSIZE 128*1024
+#define RPING_SQ_DEPTH 64
+
+/*
+ * Control block struct.
+ */
+struct krping_cb {
+ void *cookie;
+ int server; /* 0 iff client */
+ struct ib_cq *cq;
+ struct ib_pd *pd;
+ struct ib_qp *qp;
+
+ enum mem_type mem;
+ struct ib_mr *dma_mr;
+
+ struct ib_fast_reg_page_list *page_list;
+ int page_list_len;
+ struct ib_send_wr fastreg_wr;
+ struct ib_send_wr invalidate_wr;
+ struct ib_mr *fastreg_mr;
+ int server_invalidate;
+ int read_inv;
+ u8 key;
+
+ struct ib_mw *mw;
+ struct ib_mw_bind bind_attr;
+
+ struct ib_recv_wr rq_wr; /* recv work request record */
+ struct ib_sge recv_sgl; /* recv single SGE */
+ struct krping_rdma_info recv_buf;/* malloc'd buffer */
+ u64 recv_dma_addr;
+ DECLARE_PCI_UNMAP_ADDR(recv_mapping)
+ struct ib_mr *recv_mr;
+
+ struct ib_send_wr sq_wr; /* send work requrest record */
+ struct ib_sge send_sgl;
+ struct krping_rdma_info send_buf;/* single send buf */
+ u64 send_dma_addr;
+ DECLARE_PCI_UNMAP_ADDR(send_mapping)
+ struct ib_mr *send_mr;
+
+ struct ib_send_wr rdma_sq_wr; /* rdma work request record */
+ struct ib_sge rdma_sgl; /* rdma single SGE */
+ char *rdma_buf; /* used as rdma sink */
+ u64 rdma_dma_addr;
+ DECLARE_PCI_UNMAP_ADDR(rdma_mapping)
+ struct ib_mr *rdma_mr;
+
+ uint32_t remote_rkey; /* remote guys RKEY */
+ uint64_t remote_addr; /* remote guys TO */
+ uint32_t remote_len; /* remote guys LEN */
+
+ char *start_buf; /* rdma read src */
+ u64 start_dma_addr;
+ DECLARE_PCI_UNMAP_ADDR(start_mapping)
+ struct ib_mr *start_mr;
+
+ enum test_state state; /* used for cond/signalling */
+ wait_queue_head_t sem;
+ struct krping_stats stats;
+
+ uint16_t port; /* dst port in NBO */
+ union {
+ struct in_addr v4;
+ struct in6_addr v6;
+ } addr; /* dst addr in NBO */
+ int addr_type; /* AF_INET or AF_INET6 */
+ char *addr_str; /* dst addr string */
+ int verbose; /* verbose logging */
+ int count; /* ping count */
+ int size; /* ping data size */
+ int validate; /* validate ping data */
+ int wlat; /* run wlat test */
+ int rlat; /* run rlat test */
+ int bw; /* run bw test */
+ int duplex; /* run bw full duplex test */
+ int poll; /* poll or block for rlat test */
+ int txdepth; /* SQ depth */
+ int local_dma_lkey; /* use 0 for lkey */
+ int frtest; /* fastreg test */
+ int testnum;
+
+ /* CM stuff */
+ struct rdma_cm_id *cm_id; /* connection on client side,*/
+ /* listener on server side. */
+ struct rdma_cm_id *child_cm_id; /* connection on server side */
+ struct list_head list;
+};
+
+static int krping_cma_event_handler(struct rdma_cm_id *cma_id,
+ struct rdma_cm_event *event)
+{
+ int ret;
+ struct krping_cb *cb = cma_id->context;
+
+ DEBUG_LOG(cb, "cma_event type %d cma_id %p (%s)\n", event->event,
+ cma_id, (cma_id == cb->cm_id) ? "parent" : "child");
+
+ switch (event->event) {
+ case RDMA_CM_EVENT_ADDR_RESOLVED:
+ cb->state = ADDR_RESOLVED;
+ ret = rdma_resolve_route(cma_id, 2000);
+ if (ret) {
+ PRINTF(cb, "rdma_resolve_route error %d\n", ret);
+ wake_up_interruptible(&cb->sem);
+ }
+ break;
+
+ case RDMA_CM_EVENT_ROUTE_RESOLVED:
+ cb->state = ROUTE_RESOLVED;
+ cb->child_cm_id = cma_id;
+ wake_up_interruptible(&cb->sem);
+ break;
+
+ case RDMA_CM_EVENT_CONNECT_REQUEST:
+ if (cb->state == IDLE) {
+ cb->state = CONNECT_REQUEST;
+ cb->child_cm_id = cma_id;
+ } else {
+ PRINTF(cb, "Received connection request in wrong state"
+ " (%d)\n", cb->state);
+ }
+ DEBUG_LOG(cb, "child cma %p\n", cb->child_cm_id);
+ wake_up_interruptible(&cb->sem);
+ break;
+
+ case RDMA_CM_EVENT_ESTABLISHED:
+ DEBUG_LOG(cb, "ESTABLISHED\n");
+ if (!cb->server) {
+ cb->state = CONNECTED;
+ }
+ wake_up_interruptible(&cb->sem);
+ break;
+
+ case RDMA_CM_EVENT_ADDR_ERROR:
+ case RDMA_CM_EVENT_ROUTE_ERROR:
+ case RDMA_CM_EVENT_CONNECT_ERROR:
+ case RDMA_CM_EVENT_UNREACHABLE:
+ case RDMA_CM_EVENT_REJECTED:
+ PRINTF(cb, "cma event %d, error %d\n", event->event,
+ event->status);
+ cb->state = ERROR;
+ wake_up_interruptible(&cb->sem);
+ break;
+
+ case RDMA_CM_EVENT_DISCONNECTED:
+ PRINTF(cb, "DISCONNECT EVENT...\n");
+ cb->state = ERROR;
+ wake_up_interruptible(&cb->sem);
+ break;
+
+ case RDMA_CM_EVENT_DEVICE_REMOVAL:
+ PRINTF(cb, "cma detected device removal!!!!\n");
+ break;
+
+ default:
+ PRINTF(cb, "oof bad type!\n");
+ wake_up_interruptible(&cb->sem);
+ break;
+ }
+ return 0;
+}
+
+static int server_recv(struct krping_cb *cb, struct ib_wc *wc)
+{
+ if (wc->byte_len != sizeof(cb->recv_buf)) {
+ PRINTF(cb, "Received bogus data, size %d\n",
+ wc->byte_len);
+ return -1;
+ }
+
+ cb->remote_rkey = ntohl(cb->recv_buf.rkey);
+ cb->remote_addr = ntohll(cb->recv_buf.buf);
+ cb->remote_len = ntohl(cb->recv_buf.size);
+ DEBUG_LOG(cb, "Received rkey %x addr %llx len %d from peer\n",
+ cb->remote_rkey, (unsigned long long)cb->remote_addr,
+ cb->remote_len);
+
+ if (cb->state <= CONNECTED || cb->state == RDMA_WRITE_COMPLETE)
+ cb->state = RDMA_READ_ADV;
+ else
+ cb->state = RDMA_WRITE_ADV;
+
+ return 0;
+}
+
+static int client_recv(struct krping_cb *cb, struct ib_wc *wc)
+{
+ if (wc->byte_len != sizeof(cb->recv_buf)) {
+ PRINTF(cb, "Received bogus data, size %d\n",
+ wc->byte_len);
+ return -1;
+ }
+
+ if (cb->state == RDMA_READ_ADV)
+ cb->state = RDMA_WRITE_ADV;
+ else
+ cb->state = RDMA_WRITE_COMPLETE;
+
+ return 0;
+}
+
+static void krping_cq_event_handler(struct ib_cq *cq, void *ctx)
+{
+ struct krping_cb *cb = ctx;
+ struct ib_wc wc;
+ struct ib_recv_wr *bad_wr;
+ int ret;
+
+ BUG_ON(cb->cq != cq);
+ if (cb->state == ERROR) {
+ PRINTF(cb, "cq completion in ERROR state\n");
+ return;
+ }
+ if (!cb->wlat && !cb->rlat && !cb->bw && !cb->frtest)
+ ib_req_notify_cq(cb->cq, IB_CQ_NEXT_COMP);
+ while ((ret = ib_poll_cq(cb->cq, 1, &wc)) == 1) {
+ if (wc.status) {
+ if (wc.status == IB_WC_WR_FLUSH_ERR) {
+ DEBUG_LOG(cb, "cq flushed\n");
+ continue;
+ } else {
+ PRINTF(cb, "cq completion failed with "
+ "wr_id %jx status %d opcode %d vender_err %x\n",
+ (uintmax_t)wc.wr_id, wc.status, wc.opcode, wc.vendor_err);
+ goto error;
+ }
+ }
+
+ switch (wc.opcode) {
+ case IB_WC_SEND:
+ DEBUG_LOG(cb, "send completion\n");
+ cb->stats.send_bytes += cb->send_sgl.length;
+ cb->stats.send_msgs++;
+ break;
+
+ case IB_WC_RDMA_WRITE:
+ DEBUG_LOG(cb, "rdma write completion\n");
+ cb->stats.write_bytes += cb->rdma_sq_wr.sg_list->length;
+ cb->stats.write_msgs++;
+ cb->state = RDMA_WRITE_COMPLETE;
+ wake_up_interruptible(&cb->sem);
+ break;
+
+ case IB_WC_RDMA_READ:
+ DEBUG_LOG(cb, "rdma read completion\n");
+ cb->stats.read_bytes += cb->rdma_sq_wr.sg_list->length;
+ cb->stats.read_msgs++;
+ cb->state = RDMA_READ_COMPLETE;
+ wake_up_interruptible(&cb->sem);
+ break;
+
+ case IB_WC_RECV:
+ DEBUG_LOG(cb, "recv completion\n");
+ cb->stats.recv_bytes += sizeof(cb->recv_buf);
+ cb->stats.recv_msgs++;
+ if (cb->wlat || cb->rlat || cb->bw || cb->frtest)
+ ret = server_recv(cb, &wc);
+ else
+ ret = cb->server ? server_recv(cb, &wc) :
+ client_recv(cb, &wc);
+ if (ret) {
+ PRINTF(cb, "recv wc error: %d\n", ret);
+ goto error;
+ }
+
+ ret = ib_post_recv(cb->qp, &cb->rq_wr, &bad_wr);
+ if (ret) {
+ PRINTF(cb, "post recv error: %d\n",
+ ret);
+ goto error;
+ }
+ wake_up_interruptible(&cb->sem);
+ break;
+
+ default:
+ PRINTF(cb,
+ "%s:%d Unexpected opcode %d, Shutting down\n",
+ __func__, __LINE__, wc.opcode);
+ goto error;
+ }
+ }
+ if (ret) {
+ PRINTF(cb, "poll error %d\n", ret);
+ goto error;
+ }
+ return;
+error:
+ cb->state = ERROR;
+ wake_up_interruptible(&cb->sem);
+}
+
+static int krping_accept(struct krping_cb *cb)
+{
+ struct rdma_conn_param conn_param;
+ int ret;
+
+ DEBUG_LOG(cb, "accepting client connection request\n");
+
+ memset(&conn_param, 0, sizeof conn_param);
+ conn_param.responder_resources = 1;
+ conn_param.initiator_depth = 1;
+
+ ret = rdma_accept(cb->child_cm_id, &conn_param);
+ if (ret) {
+ PRINTF(cb, "rdma_accept error: %d\n", ret);
+ return ret;
+ }
+
+ if (!cb->wlat && !cb->rlat && !cb->bw && !cb->frtest) {
+ wait_event_interruptible(cb->sem, cb->state >= CONNECTED);
+ if (cb->state == ERROR) {
+ PRINTF(cb, "wait for CONNECTED state %d\n",
+ cb->state);
+ return -1;
+ }
+ }
+ return 0;
+}
+
+static void krping_setup_wr(struct krping_cb *cb)
+{
+ cb->recv_sgl.addr = cb->recv_dma_addr;
+ cb->recv_sgl.length = sizeof cb->recv_buf;
+ if (cb->local_dma_lkey)
+ cb->recv_sgl.lkey = cb->qp->device->local_dma_lkey;
+ else if (cb->mem == DMA)
+ cb->recv_sgl.lkey = cb->dma_mr->lkey;
+ else
+ cb->recv_sgl.lkey = cb->recv_mr->lkey;
+ cb->rq_wr.sg_list = &cb->recv_sgl;
+ cb->rq_wr.num_sge = 1;
+
+ cb->send_sgl.addr = cb->send_dma_addr;
+ cb->send_sgl.length = sizeof cb->send_buf;
+ if (cb->local_dma_lkey)
+ cb->send_sgl.lkey = cb->qp->device->local_dma_lkey;
+ else if (cb->mem == DMA)
+ cb->send_sgl.lkey = cb->dma_mr->lkey;
+ else
+ cb->send_sgl.lkey = cb->send_mr->lkey;
+
+ cb->sq_wr.opcode = IB_WR_SEND;
+ cb->sq_wr.send_flags = IB_SEND_SIGNALED;
+ cb->sq_wr.sg_list = &cb->send_sgl;
+ cb->sq_wr.num_sge = 1;
+
+ if (cb->server || cb->wlat || cb->rlat || cb->bw || cb->frtest) {
+ cb->rdma_sgl.addr = cb->rdma_dma_addr;
+ if (cb->mem == MR)
+ cb->rdma_sgl.lkey = cb->rdma_mr->lkey;
+ cb->rdma_sq_wr.send_flags = IB_SEND_SIGNALED;
+ cb->rdma_sq_wr.sg_list = &cb->rdma_sgl;
+ cb->rdma_sq_wr.num_sge = 1;
+ }
+
+ switch(cb->mem) {
+ case FASTREG:
+
+ /*
+ * A chain of 2 WRs, INVALDATE_MR + FAST_REG_MR.
+ * both unsignaled. The client uses them to reregister
+ * the rdma buffers with a new key each iteration.
+ */
+ cb->fastreg_wr.opcode = IB_WR_FAST_REG_MR;
+ cb->fastreg_wr.wr.fast_reg.page_shift = PAGE_SHIFT;
+ cb->fastreg_wr.wr.fast_reg.length = cb->size;
+ cb->fastreg_wr.wr.fast_reg.page_list = cb->page_list;
+ cb->fastreg_wr.wr.fast_reg.page_list_len = cb->page_list_len;
+
+ cb->invalidate_wr.next = &cb->fastreg_wr;
+ cb->invalidate_wr.opcode = IB_WR_LOCAL_INV;
+ break;
+ case MW:
+ cb->bind_attr.wr_id = 0xabbaabba;
+ cb->bind_attr.send_flags = 0; /* unsignaled */
+#ifdef BIND_INFO
+ cb->bind_attr.bind_info.length = cb->size;
+#else
+ cb->bind_attr.length = cb->size;
+#endif
+ break;
+ default:
+ break;
+ }
+}
+
+static int krping_setup_buffers(struct krping_cb *cb)
+{
+ int ret;
+ struct ib_phys_buf buf;
+ u64 iovbase;
+
+ DEBUG_LOG(cb, "krping_setup_buffers called on cb %p\n", cb);
+
+ cb->recv_dma_addr = dma_map_single(cb->pd->device->dma_device,
+ &cb->recv_buf,
+ sizeof(cb->recv_buf), DMA_BIDIRECTIONAL);
+ pci_unmap_addr_set(cb, recv_mapping, cb->recv_dma_addr);
+ cb->send_dma_addr = dma_map_single(cb->pd->device->dma_device,
+ &cb->send_buf, sizeof(cb->send_buf),
+ DMA_BIDIRECTIONAL);
+ pci_unmap_addr_set(cb, send_mapping, cb->send_dma_addr);
+
+ if (cb->mem == DMA) {
+ cb->dma_mr = ib_get_dma_mr(cb->pd, IB_ACCESS_LOCAL_WRITE|
+ IB_ACCESS_REMOTE_READ|
+ IB_ACCESS_REMOTE_WRITE);
+ if (IS_ERR(cb->dma_mr)) {
+ DEBUG_LOG(cb, "reg_dmamr failed\n");
+ ret = PTR_ERR(cb->dma_mr);
+ goto bail;
+ }
+ } else {
+ if (!cb->local_dma_lkey) {
+ buf.addr = cb->recv_dma_addr;
+ buf.size = sizeof cb->recv_buf;
+ DEBUG_LOG(cb, "recv buf dma_addr %jx size %d\n",
+ (uintmax_t)buf.addr, (int)buf.size);
+ iovbase = cb->recv_dma_addr;
+ cb->recv_mr = ib_reg_phys_mr(cb->pd, &buf, 1,
+ IB_ACCESS_LOCAL_WRITE,
+ &iovbase);
+
+ if (IS_ERR(cb->recv_mr)) {
+ DEBUG_LOG(cb, "recv_buf reg_mr failed\n");
+ ret = PTR_ERR(cb->recv_mr);
+ goto bail;
+ }
+
+ buf.addr = cb->send_dma_addr;
+ buf.size = sizeof cb->send_buf;
+ DEBUG_LOG(cb, "send buf dma_addr %jx size %d\n",
+ (uintmax_t)buf.addr, (int)buf.size);
+ iovbase = cb->send_dma_addr;
+ cb->send_mr = ib_reg_phys_mr(cb->pd, &buf, 1,
+ 0, &iovbase);
+
+ if (IS_ERR(cb->send_mr)) {
+ DEBUG_LOG(cb, "send_buf reg_mr failed\n");
+ ret = PTR_ERR(cb->send_mr);
+ goto bail;
+ }
+ }
+ }
+
+ cb->rdma_buf = kmalloc(cb->size, GFP_KERNEL);
+ if (!cb->rdma_buf) {
+ DEBUG_LOG(cb, "rdma_buf malloc failed\n");
+ ret = -ENOMEM;
+ goto bail;
+ }
+
+ cb->rdma_dma_addr = dma_map_single(cb->pd->device->dma_device,
+ cb->rdma_buf, cb->size,
+ DMA_BIDIRECTIONAL);
+ pci_unmap_addr_set(cb, rdma_mapping, cb->rdma_dma_addr);
+ if (cb->mem != DMA) {
+ switch (cb->mem) {
+ case FASTREG:
+ cb->page_list_len = (((cb->size - 1) & PAGE_MASK) +
+ PAGE_SIZE) >> PAGE_SHIFT;
+ cb->page_list = ib_alloc_fast_reg_page_list(
+ cb->pd->device,
+ cb->page_list_len);
+ if (IS_ERR(cb->page_list)) {
+ DEBUG_LOG(cb, "recv_buf reg_mr failed\n");
+ ret = PTR_ERR(cb->page_list);
+ goto bail;
+ }
+ cb->fastreg_mr = ib_alloc_fast_reg_mr(cb->pd,
+ cb->page_list->max_page_list_len);
+ if (IS_ERR(cb->fastreg_mr)) {
+ DEBUG_LOG(cb, "recv_buf reg_mr failed\n");
+ ret = PTR_ERR(cb->fastreg_mr);
+ goto bail;
+ }
+ DEBUG_LOG(cb, "fastreg rkey 0x%x page_list %p"
+ " page_list_len %u\n", cb->fastreg_mr->rkey,
+ cb->page_list, cb->page_list_len);
+ break;
+ case MW:
+ cb->mw = ib_alloc_mw(cb->pd,IB_MW_TYPE_1);
+ if (IS_ERR(cb->mw)) {
+ DEBUG_LOG(cb, "recv_buf alloc_mw failed\n");
+ ret = PTR_ERR(cb->mw);
+ goto bail;
+ }
+ DEBUG_LOG(cb, "mw rkey 0x%x\n", cb->mw->rkey);
+ /*FALLTHROUGH*/
+ case MR:
+ buf.addr = cb->rdma_dma_addr;
+ buf.size = cb->size;
+ iovbase = cb->rdma_dma_addr;
+ cb->rdma_mr = ib_reg_phys_mr(cb->pd, &buf, 1,
+ IB_ACCESS_LOCAL_WRITE|
+ IB_ACCESS_REMOTE_READ|
+ IB_ACCESS_REMOTE_WRITE,
+ &iovbase);
+ if (IS_ERR(cb->rdma_mr)) {
+ DEBUG_LOG(cb, "rdma_buf reg_mr failed\n");
+ ret = PTR_ERR(cb->rdma_mr);
+ goto bail;
+ }
+ DEBUG_LOG(cb, "rdma buf dma_addr %jx size %d mr rkey 0x%x\n",
+ (uintmax_t)buf.addr, (int)buf.size, cb->rdma_mr->rkey);
+ break;
+ default:
+ ret = -EINVAL;
+ goto bail;
+ break;
+ }
+ }
+
+ if (!cb->server || cb->wlat || cb->rlat || cb->bw || cb->frtest) {
+
+ cb->start_buf = kmalloc(cb->size, GFP_KERNEL);
+ if (!cb->start_buf) {
+ DEBUG_LOG(cb, "start_buf malloc failed\n");
+ ret = -ENOMEM;
+ goto bail;
+ }
+
+ cb->start_dma_addr = dma_map_single(cb->pd->device->dma_device,
+ cb->start_buf, cb->size,
+ DMA_BIDIRECTIONAL);
+ pci_unmap_addr_set(cb, start_mapping, cb->start_dma_addr);
+
+ if (cb->mem == MR || cb->mem == MW) {
+ unsigned flags = IB_ACCESS_REMOTE_READ;
+
+ if (cb->wlat || cb->rlat || cb->bw || cb->frtest) {
+ flags |= IB_ACCESS_LOCAL_WRITE |
+ IB_ACCESS_REMOTE_WRITE;
+ }
+
+ buf.addr = cb->start_dma_addr;
+ buf.size = cb->size;
+ DEBUG_LOG(cb, "start buf dma_addr %jx size %d\n",
+ (uintmax_t)buf.addr, (int)buf.size);
+ iovbase = cb->start_dma_addr;
+ cb->start_mr = ib_reg_phys_mr(cb->pd, &buf, 1,
+ flags,
+ &iovbase);
+
+ if (IS_ERR(cb->start_mr)) {
+ DEBUG_LOG(cb, "start_buf reg_mr failed\n");
+ ret = PTR_ERR(cb->start_mr);
+ goto bail;
+ }
+ }
+ }
+
+ krping_setup_wr(cb);
+ DEBUG_LOG(cb, "allocated & registered buffers...\n");
+ return 0;
+bail:
+ if (cb->fastreg_mr && !IS_ERR(cb->fastreg_mr))
+ ib_dereg_mr(cb->fastreg_mr);
+ if (cb->mw && !IS_ERR(cb->mw))
+ ib_dealloc_mw(cb->mw);
+ if (cb->rdma_mr && !IS_ERR(cb->rdma_mr))
+ ib_dereg_mr(cb->rdma_mr);
+ if (cb->page_list && !IS_ERR(cb->page_list))
+ ib_free_fast_reg_page_list(cb->page_list);
+ if (cb->dma_mr && !IS_ERR(cb->dma_mr))
+ ib_dereg_mr(cb->dma_mr);
+ if (cb->recv_mr && !IS_ERR(cb->recv_mr))
+ ib_dereg_mr(cb->recv_mr);
+ if (cb->send_mr && !IS_ERR(cb->send_mr))
+ ib_dereg_mr(cb->send_mr);
+ if (cb->rdma_buf)
+ kfree(cb->rdma_buf);
+ if (cb->start_buf)
+ kfree(cb->start_buf);
+ return ret;
+}
+
+static void krping_free_buffers(struct krping_cb *cb)
+{
+ DEBUG_LOG(cb, "krping_free_buffers called on cb %p\n", cb);
+
+ if (cb->dma_mr)
+ ib_dereg_mr(cb->dma_mr);
+ if (cb->send_mr)
+ ib_dereg_mr(cb->send_mr);
+ if (cb->recv_mr)
+ ib_dereg_mr(cb->recv_mr);
+ if (cb->rdma_mr)
+ ib_dereg_mr(cb->rdma_mr);
+ if (cb->start_mr)
+ ib_dereg_mr(cb->start_mr);
+ if (cb->fastreg_mr)
+ ib_dereg_mr(cb->fastreg_mr);
+ if (cb->mw)
+ ib_dealloc_mw(cb->mw);
+
+ dma_unmap_single(cb->pd->device->dma_device,
+ pci_unmap_addr(cb, recv_mapping),
+ sizeof(cb->recv_buf), DMA_BIDIRECTIONAL);
+ dma_unmap_single(cb->pd->device->dma_device,
+ pci_unmap_addr(cb, send_mapping),
+ sizeof(cb->send_buf), DMA_BIDIRECTIONAL);
+ dma_unmap_single(cb->pd->device->dma_device,
+ pci_unmap_addr(cb, rdma_mapping),
+ cb->size, DMA_BIDIRECTIONAL);
+ kfree(cb->rdma_buf);
+ if (cb->start_buf) {
+ dma_unmap_single(cb->pd->device->dma_device,
+ pci_unmap_addr(cb, start_mapping),
+ cb->size, DMA_BIDIRECTIONAL);
+ kfree(cb->start_buf);
+ }
+}
+
+static int krping_create_qp(struct krping_cb *cb)
+{
+ struct ib_qp_init_attr init_attr;
+ int ret;
+
+ memset(&init_attr, 0, sizeof(init_attr));
+ init_attr.cap.max_send_wr = cb->txdepth;
+ init_attr.cap.max_recv_wr = 2;
+ init_attr.cap.max_recv_sge = 1;
+ init_attr.cap.max_send_sge = 1;
+ init_attr.qp_type = IB_QPT_RC;
+ init_attr.send_cq = cb->cq;
+ init_attr.recv_cq = cb->cq;
+ init_attr.sq_sig_type = IB_SIGNAL_REQ_WR;
+
+ if (cb->server) {
+ ret = rdma_create_qp(cb->child_cm_id, cb->pd, &init_attr);
+ if (!ret)
+ cb->qp = cb->child_cm_id->qp;
+ } else {
+ ret = rdma_create_qp(cb->cm_id, cb->pd, &init_attr);
+ if (!ret)
+ cb->qp = cb->cm_id->qp;
+ }
+
+ return ret;
+}
+
+static void krping_free_qp(struct krping_cb *cb)
+{
+ ib_destroy_qp(cb->qp);
+ ib_destroy_cq(cb->cq);
+ ib_dealloc_pd(cb->pd);
+}
+
+static int krping_setup_qp(struct krping_cb *cb, struct rdma_cm_id *cm_id)
+{
+ int ret;
+ cb->pd = ib_alloc_pd(cm_id->device);
+ if (IS_ERR(cb->pd)) {
+ PRINTF(cb, "ib_alloc_pd failed\n");
+ return PTR_ERR(cb->pd);
+ }
+ DEBUG_LOG(cb, "created pd %p\n", cb->pd);
+
+ strlcpy(cb->stats.name, cb->pd->device->name, sizeof(cb->stats.name));
+
+ cb->cq = ib_create_cq(cm_id->device, krping_cq_event_handler, NULL,
+ cb, cb->txdepth * 2, 0);
+ if (IS_ERR(cb->cq)) {
+ PRINTF(cb, "ib_create_cq failed\n");
+ ret = PTR_ERR(cb->cq);
+ goto err1;
+ }
+ DEBUG_LOG(cb, "created cq %p\n", cb->cq);
+
+ if (!cb->wlat && !cb->rlat && !cb->bw && !cb->frtest) {
+ ret = ib_req_notify_cq(cb->cq, IB_CQ_NEXT_COMP);
+ if (ret) {
+ PRINTF(cb, "ib_create_cq failed\n");
+ goto err2;
+ }
+ }
+
+ ret = krping_create_qp(cb);
+ if (ret) {
+ PRINTF(cb, "krping_create_qp failed: %d\n", ret);
+ goto err2;
+ }
+ DEBUG_LOG(cb, "created qp %p\n", cb->qp);
+ return 0;
+err2:
+ ib_destroy_cq(cb->cq);
+err1:
+ ib_dealloc_pd(cb->pd);
+ return ret;
+}
+
+/*
+ * return the (possibly rebound) rkey for the rdma buffer.
+ * FASTREG mode: invalidate and rebind via fastreg wr.
+ * MW mode: rebind the MW.
+ * other modes: just return the mr rkey.
+ */
+static u32 krping_rdma_rkey(struct krping_cb *cb, u64 buf, int post_inv)
+{
+ u32 rkey = 0xffffffff;
+ u64 p;
+ struct ib_send_wr *bad_wr;
+ int i;
+ int ret;
+
+ switch (cb->mem) {
+ case FASTREG:
+ cb->invalidate_wr.ex.invalidate_rkey = cb->fastreg_mr->rkey;
+
+ /*
+ * Update the fastreg key.
+ */
+ ib_update_fast_reg_key(cb->fastreg_mr, ++cb->key);
+ cb->fastreg_wr.wr.fast_reg.rkey = cb->fastreg_mr->rkey;
+
+ /*
+ * Update the fastreg WR with new buf info.
+ */
+ if (buf == (u64)cb->start_dma_addr)
+ cb->fastreg_wr.wr.fast_reg.access_flags = IB_ACCESS_REMOTE_READ;
+ else
+ cb->fastreg_wr.wr.fast_reg.access_flags = IB_ACCESS_REMOTE_WRITE | IB_ACCESS_LOCAL_WRITE;
+ cb->fastreg_wr.wr.fast_reg.iova_start = buf;
+ p = (u64)(buf & PAGE_MASK);
+ for (i=0; i < cb->fastreg_wr.wr.fast_reg.page_list_len;
+ i++, p += PAGE_SIZE) {
+ cb->page_list->page_list[i] = p;
+ DEBUG_LOG(cb, "page_list[%d] 0x%jx\n", i, (uintmax_t)p);
+ }
+
+ DEBUG_LOG(cb, "post_inv = %d, fastreg new rkey 0x%x shift %u len %u"
+ " iova_start %jx page_list_len %u\n",
+ post_inv,
+ cb->fastreg_wr.wr.fast_reg.rkey,
+ cb->fastreg_wr.wr.fast_reg.page_shift,
+ (unsigned)cb->fastreg_wr.wr.fast_reg.length,
+ (uintmax_t)cb->fastreg_wr.wr.fast_reg.iova_start,
+ cb->fastreg_wr.wr.fast_reg.page_list_len);
+
+ if (post_inv)
+ ret = ib_post_send(cb->qp, &cb->invalidate_wr, &bad_wr);
+ else
+ ret = ib_post_send(cb->qp, &cb->fastreg_wr, &bad_wr);
+ if (ret) {
+ PRINTF(cb, "post send error %d\n", ret);
+ cb->state = ERROR;
+ }
+ rkey = cb->fastreg_mr->rkey;
+ break;
+ case MW:
+ /*
+ * Update the MW with new buf info.
+ */
+ if (buf == (u64)cb->start_dma_addr) {
+#ifdef BIND_INFO
+ cb->bind_attr.bind_info.mw_access_flags = IB_ACCESS_REMOTE_READ;
+ cb->bind_attr.bind_info.mr = cb->start_mr;
+#else
+ cb->bind_attr.mw_access_flags = IB_ACCESS_REMOTE_READ;
+ cb->bind_attr.mr = cb->start_mr;
+#endif
+ } else {
+#ifdef BIND_INFO
+ cb->bind_attr.bind_info.mw_access_flags = IB_ACCESS_REMOTE_WRITE;
+ cb->bind_attr.bind_info.mr = cb->rdma_mr;
+#else
+ cb->bind_attr.mw_access_flags = IB_ACCESS_REMOTE_WRITE;
+ cb->bind_attr.mr = cb->rdma_mr;
+#endif
+ }
+#ifdef BIND_INFO
+ cb->bind_attr.bind_info.addr = buf;
+#else
+ cb->bind_attr.addr = buf;
+#endif
+ DEBUG_LOG(cb, "binding mw rkey 0x%x to buf %jx mr rkey 0x%x\n",
+#ifdef BIND_INFO
+ cb->mw->rkey, (uintmax_t)buf, cb->bind_attr.bind_info.mr->rkey);
+#else
+ cb->mw->rkey, buf, cb->bind_attr.mr->rkey);
+#endif
+ ret = ib_bind_mw(cb->qp, cb->mw, &cb->bind_attr);
+ if (ret) {
+ PRINTF(cb, "bind mw error %d\n", ret);
+ cb->state = ERROR;
+ } else
+ rkey = cb->mw->rkey;
+ break;
+ case MR:
+ if (buf == (u64)cb->start_dma_addr)
+ rkey = cb->start_mr->rkey;
+ else
+ rkey = cb->rdma_mr->rkey;
+ break;
+ case DMA:
+ rkey = cb->dma_mr->rkey;
+ break;
+ default:
+ PRINTF(cb, "%s:%d case ERROR\n", __func__, __LINE__);
+ cb->state = ERROR;
+ break;
+ }
+ return rkey;
+}
+
+static void krping_format_send(struct krping_cb *cb, u64 buf)
+{
+ struct krping_rdma_info *info = &cb->send_buf;
+ u32 rkey;
+
+ /*
+ * Client side will do fastreg or mw bind before
+ * advertising the rdma buffer. Server side
+ * sends have no data.
+ */
+ if (!cb->server || cb->wlat || cb->rlat || cb->bw || cb->frtest) {
+ rkey = krping_rdma_rkey(cb, buf, !cb->server_invalidate);
+ info->buf = htonll(buf);
+ info->rkey = htonl(rkey);
+ info->size = htonl(cb->size);
+ DEBUG_LOG(cb, "RDMA addr %llx rkey %x len %d\n",
+ (unsigned long long)buf, rkey, cb->size);
+ }
+}
+
+static void krping_test_server(struct krping_cb *cb)
+{
+ struct ib_send_wr *bad_wr, inv;
+ int ret;
+
+ while (1) {
+ /* Wait for client's Start STAG/TO/Len */
+ wait_event_interruptible(cb->sem, cb->state >= RDMA_READ_ADV);
+ if (cb->state != RDMA_READ_ADV) {
+ PRINTF(cb, "wait for RDMA_READ_ADV state %d\n",
+ cb->state);
+ break;
+ }
+
+ DEBUG_LOG(cb, "server received sink adv\n");
+
+ cb->rdma_sq_wr.wr.rdma.rkey = cb->remote_rkey;
+ cb->rdma_sq_wr.wr.rdma.remote_addr = cb->remote_addr;
+ cb->rdma_sq_wr.sg_list->length = cb->remote_len;
+ cb->rdma_sgl.lkey = krping_rdma_rkey(cb, cb->rdma_dma_addr, 1);
+
+ /* Issue RDMA Read. */
+ if (cb->read_inv)
+ cb->rdma_sq_wr.opcode = IB_WR_RDMA_READ_WITH_INV;
+ else {
+
+ cb->rdma_sq_wr.opcode = IB_WR_RDMA_READ;
+ if (cb->mem == FASTREG) {
+ /*
+ * Immediately follow the read with a
+ * fenced LOCAL_INV.
+ */
+ cb->rdma_sq_wr.next = &inv;
+ memset(&inv, 0, sizeof inv);
+ inv.opcode = IB_WR_LOCAL_INV;
+ inv.ex.invalidate_rkey = cb->fastreg_mr->rkey;
+ inv.send_flags = IB_SEND_FENCE;
+ }
+ }
+
+ ret = ib_post_send(cb->qp, &cb->rdma_sq_wr, &bad_wr);
+ if (ret) {
+ PRINTF(cb, "post send error %d\n", ret);
+ break;
+ }
+ cb->rdma_sq_wr.next = NULL;
+
+ DEBUG_LOG(cb, "server posted rdma read req \n");
+
+ /* Wait for read completion */
+ wait_event_interruptible(cb->sem,
+ cb->state >= RDMA_READ_COMPLETE);
+ if (cb->state != RDMA_READ_COMPLETE) {
+ PRINTF(cb,
+ "wait for RDMA_READ_COMPLETE state %d\n",
+ cb->state);
+ break;
+ }
+ DEBUG_LOG(cb, "server received read complete\n");
+
+ /* Display data in recv buf */
+ if (cb->verbose) {
+ if (strlen(cb->rdma_buf) > 128) {
+ char msgbuf[128];
+
+ strlcpy(msgbuf, cb->rdma_buf, sizeof(msgbuf));
+ PRINTF(cb, "server ping data stripped: %s\n",
+ msgbuf);
+ } else
+ PRINTF(cb, "server ping data: %s\n",
+ cb->rdma_buf);
+ }
+
+ /* Tell client to continue */
+ if (cb->server && cb->server_invalidate) {
+ cb->sq_wr.ex.invalidate_rkey = cb->remote_rkey;
+ cb->sq_wr.opcode = IB_WR_SEND_WITH_INV;
+ DEBUG_LOG(cb, "send-w-inv rkey 0x%x\n", cb->remote_rkey);
+ }
+ ret = ib_post_send(cb->qp, &cb->sq_wr, &bad_wr);
+ if (ret) {
+ PRINTF(cb, "post send error %d\n", ret);
+ break;
+ }
+ DEBUG_LOG(cb, "server posted go ahead\n");
+
+ /* Wait for client's RDMA STAG/TO/Len */
+ wait_event_interruptible(cb->sem, cb->state >= RDMA_WRITE_ADV);
+ if (cb->state != RDMA_WRITE_ADV) {
+ PRINTF(cb,
+ "wait for RDMA_WRITE_ADV state %d\n",
+ cb->state);
+ break;
+ }
+ DEBUG_LOG(cb, "server received sink adv\n");
+
+ /* RDMA Write echo data */
+ cb->rdma_sq_wr.opcode = IB_WR_RDMA_WRITE;
+ cb->rdma_sq_wr.wr.rdma.rkey = cb->remote_rkey;
+ cb->rdma_sq_wr.wr.rdma.remote_addr = cb->remote_addr;
+ cb->rdma_sq_wr.sg_list->length = strlen(cb->rdma_buf) + 1;
+ if (cb->local_dma_lkey)
+ cb->rdma_sgl.lkey = cb->qp->device->local_dma_lkey;
+ else
+ cb->rdma_sgl.lkey = krping_rdma_rkey(cb, cb->rdma_dma_addr, 0);
+
+ DEBUG_LOG(cb, "rdma write from lkey %x laddr %llx len %d\n",
+ cb->rdma_sq_wr.sg_list->lkey,
+ (unsigned long long)cb->rdma_sq_wr.sg_list->addr,
+ cb->rdma_sq_wr.sg_list->length);
+
+ ret = ib_post_send(cb->qp, &cb->rdma_sq_wr, &bad_wr);
+ if (ret) {
+ PRINTF(cb, "post send error %d\n", ret);
+ break;
+ }
+
+ /* Wait for completion */
+ ret = wait_event_interruptible(cb->sem, cb->state >=
+ RDMA_WRITE_COMPLETE);
+ if (cb->state != RDMA_WRITE_COMPLETE) {
+ PRINTF(cb,
+ "wait for RDMA_WRITE_COMPLETE state %d\n",
+ cb->state);
+ break;
+ }
+ DEBUG_LOG(cb, "server rdma write complete \n");
+
+ cb->state = CONNECTED;
+
+ /* Tell client to begin again */
+ if (cb->server && cb->server_invalidate) {
+ cb->sq_wr.ex.invalidate_rkey = cb->remote_rkey;
+ cb->sq_wr.opcode = IB_WR_SEND_WITH_INV;
+ DEBUG_LOG(cb, "send-w-inv rkey 0x%x\n", cb->remote_rkey);
+ }
+ ret = ib_post_send(cb->qp, &cb->sq_wr, &bad_wr);
+ if (ret) {
+ PRINTF(cb, "post send error %d\n", ret);
+ break;
+ }
+ DEBUG_LOG(cb, "server posted go ahead\n");
+ }
+}
+
+static void rlat_test(struct krping_cb *cb)
+{
+ int scnt;
+ int iters = cb->count;
+ struct timeval start_tv, stop_tv;
+ int ret;
+ struct ib_wc wc;
+ struct ib_send_wr *bad_wr;
+ int ne;
+
+ scnt = 0;
+ cb->rdma_sq_wr.opcode = IB_WR_RDMA_READ;
+ cb->rdma_sq_wr.wr.rdma.rkey = cb->remote_rkey;
+ cb->rdma_sq_wr.wr.rdma.remote_addr = cb->remote_addr;
+ cb->rdma_sq_wr.sg_list->length = cb->size;
+
+ microtime(&start_tv);
+ if (!cb->poll) {
+ cb->state = RDMA_READ_ADV;
+ ib_req_notify_cq(cb->cq, IB_CQ_NEXT_COMP);
+ }
+ while (scnt < iters) {
+
+ cb->state = RDMA_READ_ADV;
+ ret = ib_post_send(cb->qp, &cb->rdma_sq_wr, &bad_wr);
+ if (ret) {
+ PRINTF(cb,
+ "Couldn't post send: ret=%d scnt %d\n",
+ ret, scnt);
+ return;
+ }
+
+ do {
+ if (!cb->poll) {
+ wait_event_interruptible(cb->sem,
+ cb->state != RDMA_READ_ADV);
+ if (cb->state == RDMA_READ_COMPLETE) {
+ ne = 1;
+ ib_req_notify_cq(cb->cq,
+ IB_CQ_NEXT_COMP);
+ } else {
+ ne = -1;
+ }
+ } else
+ ne = ib_poll_cq(cb->cq, 1, &wc);
+ if (cb->state == ERROR) {
+ PRINTF(cb,
+ "state == ERROR...bailing scnt %d\n",
+ scnt);
+ return;
+ }
+ } while (ne == 0);
+
+ if (ne < 0) {
+ PRINTF(cb, "poll CQ failed %d\n", ne);
+ return;
+ }
+ if (cb->poll && wc.status != IB_WC_SUCCESS) {
+ PRINTF(cb, "Completion wth error at %s:\n",
+ cb->server ? "server" : "client");
+ PRINTF(cb, "Failed status %d: wr_id %d\n",
+ wc.status, (int) wc.wr_id);
+ return;
+ }
+ ++scnt;
+ }
+ microtime(&stop_tv);
+
+ if (stop_tv.tv_usec < start_tv.tv_usec) {
+ stop_tv.tv_usec += 1000000;
+ stop_tv.tv_sec -= 1;
+ }
+
+ PRINTF(cb, "delta sec %lu delta usec %lu iter %d size %d\n",
+ (unsigned long)(stop_tv.tv_sec - start_tv.tv_sec),
+ (unsigned long)(stop_tv.tv_usec - start_tv.tv_usec),
+ scnt, cb->size);
+}
+
+static void wlat_test(struct krping_cb *cb)
+{
+ int ccnt, scnt, rcnt;
+ int iters=cb->count;
+ volatile char *poll_buf = (char *) cb->start_buf;
+ char *buf = (char *)cb->rdma_buf;
+ struct timeval start_tv, stop_tv;
+ cycles_t *post_cycles_start, *post_cycles_stop;
+ cycles_t *poll_cycles_start, *poll_cycles_stop;
+ cycles_t *last_poll_cycles_start;
+ cycles_t sum_poll = 0, sum_post = 0, sum_last_poll = 0;
+ int i;
+ int cycle_iters = 1000;
+
+ ccnt = 0;
+ scnt = 0;
+ rcnt = 0;
+
+ post_cycles_start = kmalloc(cycle_iters * sizeof(cycles_t), GFP_KERNEL);
+ if (!post_cycles_start) {
+ PRINTF(cb, "%s kmalloc failed\n", __FUNCTION__);
+ return;
+ }
+ post_cycles_stop = kmalloc(cycle_iters * sizeof(cycles_t), GFP_KERNEL);
+ if (!post_cycles_stop) {
+ PRINTF(cb, "%s kmalloc failed\n", __FUNCTION__);
+ return;
+ }
+ poll_cycles_start = kmalloc(cycle_iters * sizeof(cycles_t), GFP_KERNEL);
+ if (!poll_cycles_start) {
+ PRINTF(cb, "%s kmalloc failed\n", __FUNCTION__);
+ return;
+ }
+ poll_cycles_stop = kmalloc(cycle_iters * sizeof(cycles_t), GFP_KERNEL);
+ if (!poll_cycles_stop) {
+ PRINTF(cb, "%s kmalloc failed\n", __FUNCTION__);
+ return;
+ }
+ last_poll_cycles_start = kmalloc(cycle_iters * sizeof(cycles_t),
+ GFP_KERNEL);
+ if (!last_poll_cycles_start) {
+ PRINTF(cb, "%s kmalloc failed\n", __FUNCTION__);
+ return;
+ }
+ cb->rdma_sq_wr.opcode = IB_WR_RDMA_WRITE;
+ cb->rdma_sq_wr.wr.rdma.rkey = cb->remote_rkey;
+ cb->rdma_sq_wr.wr.rdma.remote_addr = cb->remote_addr;
+ cb->rdma_sq_wr.sg_list->length = cb->size;
+
+ if (cycle_iters > iters)
+ cycle_iters = iters;
+ microtime(&start_tv);
+ while (scnt < iters || ccnt < iters || rcnt < iters) {
+
+ /* Wait till buffer changes. */
+ if (rcnt < iters && !(scnt < 1 && !cb->server)) {
+ ++rcnt;
+ while (*poll_buf != (char)rcnt) {
+ if (cb->state == ERROR) {
+ PRINTF(cb,
+ "state = ERROR, bailing\n");
+ return;
+ }
+ }
+ }
+
+ if (scnt < iters) {
+ struct ib_send_wr *bad_wr;
+
+ *buf = (char)scnt+1;
+ if (scnt < cycle_iters)
+ post_cycles_start[scnt] = get_cycles();
+ if (ib_post_send(cb->qp, &cb->rdma_sq_wr, &bad_wr)) {
+ PRINTF(cb,
+ "Couldn't post send: scnt=%d\n",
+ scnt);
+ return;
+ }
+ if (scnt < cycle_iters)
+ post_cycles_stop[scnt] = get_cycles();
+ scnt++;
+ }
+
+ if (ccnt < iters) {
+ struct ib_wc wc;
+ int ne;
+
+ if (ccnt < cycle_iters)
+ poll_cycles_start[ccnt] = get_cycles();
+ do {
+ if (ccnt < cycle_iters)
+ last_poll_cycles_start[ccnt] =
+ get_cycles();
+ ne = ib_poll_cq(cb->cq, 1, &wc);
+ } while (ne == 0);
+ if (ccnt < cycle_iters)
+ poll_cycles_stop[ccnt] = get_cycles();
+ ++ccnt;
+
+ if (ne < 0) {
+ PRINTF(cb, "poll CQ failed %d\n", ne);
+ return;
+ }
+ if (wc.status != IB_WC_SUCCESS) {
+ PRINTF(cb,
+ "Completion wth error at %s:\n",
+ cb->server ? "server" : "client");
+ PRINTF(cb,
+ "Failed status %d: wr_id %d\n",
+ wc.status, (int) wc.wr_id);
+ PRINTF(cb,
+ "scnt=%d, rcnt=%d, ccnt=%d\n",
+ scnt, rcnt, ccnt);
+ return;
+ }
+ }
+ }
+ microtime(&stop_tv);
+
+ if (stop_tv.tv_usec < start_tv.tv_usec) {
+ stop_tv.tv_usec += 1000000;
+ stop_tv.tv_sec -= 1;
+ }
+
+ for (i=0; i < cycle_iters; i++) {
+ sum_post += post_cycles_stop[i] - post_cycles_start[i];
+ sum_poll += poll_cycles_stop[i] - poll_cycles_start[i];
+ sum_last_poll += poll_cycles_stop[i]-last_poll_cycles_start[i];
+ }
+ PRINTF(cb,
+ "delta sec %lu delta usec %lu iter %d size %d cycle_iters %d"
+ " sum_post %llu sum_poll %llu sum_last_poll %llu\n",
+ (unsigned long)(stop_tv.tv_sec - start_tv.tv_sec),
+ (unsigned long)(stop_tv.tv_usec - start_tv.tv_usec),
+ scnt, cb->size, cycle_iters,
+ (unsigned long long)sum_post, (unsigned long long)sum_poll,
+ (unsigned long long)sum_last_poll);
+ kfree(post_cycles_start);
+ kfree(post_cycles_stop);
+ kfree(poll_cycles_start);
+ kfree(poll_cycles_stop);
+ kfree(last_poll_cycles_start);
+}
+
+static void bw_test(struct krping_cb *cb)
+{
+ int ccnt, scnt, rcnt;
+ int iters=cb->count;
+ struct timeval start_tv, stop_tv;
+ cycles_t *post_cycles_start, *post_cycles_stop;
+ cycles_t *poll_cycles_start, *poll_cycles_stop;
+ cycles_t *last_poll_cycles_start;
+ cycles_t sum_poll = 0, sum_post = 0, sum_last_poll = 0;
+ int i;
+ int cycle_iters = 1000;
+
+ ccnt = 0;
+ scnt = 0;
+ rcnt = 0;
+
+ post_cycles_start = kmalloc(cycle_iters * sizeof(cycles_t), GFP_KERNEL);
+ if (!post_cycles_start) {
+ PRINTF(cb, "%s kmalloc failed\n", __FUNCTION__);
+ return;
+ }
+ post_cycles_stop = kmalloc(cycle_iters * sizeof(cycles_t), GFP_KERNEL);
+ if (!post_cycles_stop) {
+ PRINTF(cb, "%s kmalloc failed\n", __FUNCTION__);
+ return;
+ }
+ poll_cycles_start = kmalloc(cycle_iters * sizeof(cycles_t), GFP_KERNEL);
+ if (!poll_cycles_start) {
+ PRINTF(cb, "%s kmalloc failed\n", __FUNCTION__);
+ return;
+ }
+ poll_cycles_stop = kmalloc(cycle_iters * sizeof(cycles_t), GFP_KERNEL);
+ if (!poll_cycles_stop) {
+ PRINTF(cb, "%s kmalloc failed\n", __FUNCTION__);
+ return;
+ }
+ last_poll_cycles_start = kmalloc(cycle_iters * sizeof(cycles_t),
+ GFP_KERNEL);
+ if (!last_poll_cycles_start) {
+ PRINTF(cb, "%s kmalloc failed\n", __FUNCTION__);
+ return;
+ }
+ cb->rdma_sq_wr.opcode = IB_WR_RDMA_WRITE;
+ cb->rdma_sq_wr.wr.rdma.rkey = cb->remote_rkey;
+ cb->rdma_sq_wr.wr.rdma.remote_addr = cb->remote_addr;
+ cb->rdma_sq_wr.sg_list->length = cb->size;
+
+ if (cycle_iters > iters)
+ cycle_iters = iters;
+ microtime(&start_tv);
+ while (scnt < iters || ccnt < iters) {
+
+ while (scnt < iters && scnt - ccnt < cb->txdepth) {
+ struct ib_send_wr *bad_wr;
+
+ if (scnt < cycle_iters)
+ post_cycles_start[scnt] = get_cycles();
+ if (ib_post_send(cb->qp, &cb->rdma_sq_wr, &bad_wr)) {
+ PRINTF(cb,
+ "Couldn't post send: scnt=%d\n",
+ scnt);
+ return;
+ }
+ if (scnt < cycle_iters)
+ post_cycles_stop[scnt] = get_cycles();
+ ++scnt;
+ }
+
+ if (ccnt < iters) {
+ int ne;
+ struct ib_wc wc;
+
+ if (ccnt < cycle_iters)
+ poll_cycles_start[ccnt] = get_cycles();
+ do {
+ if (ccnt < cycle_iters)
+ last_poll_cycles_start[ccnt] =
+ get_cycles();
+ ne = ib_poll_cq(cb->cq, 1, &wc);
+ } while (ne == 0);
+ if (ccnt < cycle_iters)
+ poll_cycles_stop[ccnt] = get_cycles();
+ ccnt += 1;
+
+ if (ne < 0) {
+ PRINTF(cb, "poll CQ failed %d\n", ne);
+ return;
+ }
+ if (wc.status != IB_WC_SUCCESS) {
+ PRINTF(cb,
+ "Completion wth error at %s:\n",
+ cb->server ? "server" : "client");
+ PRINTF(cb,
+ "Failed status %d: wr_id %d\n",
+ wc.status, (int) wc.wr_id);
+ return;
+ }
+ }
+ }
+ microtime(&stop_tv);
+
+ if (stop_tv.tv_usec < start_tv.tv_usec) {
+ stop_tv.tv_usec += 1000000;
+ stop_tv.tv_sec -= 1;
+ }
+
+ for (i=0; i < cycle_iters; i++) {
+ sum_post += post_cycles_stop[i] - post_cycles_start[i];
+ sum_poll += poll_cycles_stop[i] - poll_cycles_start[i];
+ sum_last_poll += poll_cycles_stop[i]-last_poll_cycles_start[i];
+ }
+ PRINTF(cb,
+ "delta sec %lu delta usec %lu iter %d size %d cycle_iters %d"
+ " sum_post %llu sum_poll %llu sum_last_poll %llu\n",
+ (unsigned long)(stop_tv.tv_sec - start_tv.tv_sec),
+ (unsigned long)(stop_tv.tv_usec - start_tv.tv_usec),
+ scnt, cb->size, cycle_iters,
+ (unsigned long long)sum_post, (unsigned long long)sum_poll,
+ (unsigned long long)sum_last_poll);
+ kfree(post_cycles_start);
+ kfree(post_cycles_stop);
+ kfree(poll_cycles_start);
+ kfree(poll_cycles_stop);
+ kfree(last_poll_cycles_start);
+}
+
+static void krping_rlat_test_server(struct krping_cb *cb)
+{
+ struct ib_send_wr *bad_wr;
+ struct ib_wc wc;
+ int ret;
+
+ /* Spin waiting for client's Start STAG/TO/Len */
+ while (cb->state < RDMA_READ_ADV) {
+ krping_cq_event_handler(cb->cq, cb);
+ }
+
+ /* Send STAG/TO/Len to client */
+ krping_format_send(cb, cb->start_dma_addr);
+ ret = ib_post_send(cb->qp, &cb->sq_wr, &bad_wr);
+ if (ret) {
+ PRINTF(cb, "post send error %d\n", ret);
+ return;
+ }
+
+ /* Spin waiting for send completion */
+ while ((ret = ib_poll_cq(cb->cq, 1, &wc) == 0));
+ if (ret < 0) {
+ PRINTF(cb, "poll error %d\n", ret);
+ return;
+ }
+ if (wc.status) {
+ PRINTF(cb, "send completiong error %d\n", wc.status);
+ return;
+ }
+ wait_event_interruptible(cb->sem, cb->state == ERROR);
+}
+
+static void krping_wlat_test_server(struct krping_cb *cb)
+{
+ struct ib_send_wr *bad_wr;
+ struct ib_wc wc;
+ int ret;
+
+ /* Spin waiting for client's Start STAG/TO/Len */
+ while (cb->state < RDMA_READ_ADV) {
+ krping_cq_event_handler(cb->cq, cb);
+ }
+
+ /* Send STAG/TO/Len to client */
+ krping_format_send(cb, cb->start_dma_addr);
+ ret = ib_post_send(cb->qp, &cb->sq_wr, &bad_wr);
+ if (ret) {
+ PRINTF(cb, "post send error %d\n", ret);
+ return;
+ }
+
+ /* Spin waiting for send completion */
+ while ((ret = ib_poll_cq(cb->cq, 1, &wc) == 0));
+ if (ret < 0) {
+ PRINTF(cb, "poll error %d\n", ret);
+ return;
+ }
+ if (wc.status) {
+ PRINTF(cb, "send completiong error %d\n", wc.status);
+ return;
+ }
+
+ wlat_test(cb);
+ wait_event_interruptible(cb->sem, cb->state == ERROR);
+}
+
+static void krping_bw_test_server(struct krping_cb *cb)
+{
+ struct ib_send_wr *bad_wr;
+ struct ib_wc wc;
+ int ret;
+
+ /* Spin waiting for client's Start STAG/TO/Len */
+ while (cb->state < RDMA_READ_ADV) {
+ krping_cq_event_handler(cb->cq, cb);
+ }
+
+ /* Send STAG/TO/Len to client */
+ krping_format_send(cb, cb->start_dma_addr);
+ ret = ib_post_send(cb->qp, &cb->sq_wr, &bad_wr);
+ if (ret) {
+ PRINTF(cb, "post send error %d\n", ret);
+ return;
+ }
+
+ /* Spin waiting for send completion */
+ while ((ret = ib_poll_cq(cb->cq, 1, &wc) == 0));
+ if (ret < 0) {
+ PRINTF(cb, "poll error %d\n", ret);
+ return;
+ }
+ if (wc.status) {
+ PRINTF(cb, "send completiong error %d\n", wc.status);
+ return;
+ }
+
+ if (cb->duplex)
+ bw_test(cb);
+ wait_event_interruptible(cb->sem, cb->state == ERROR);
+}
+
+static int fastreg_supported(struct krping_cb *cb, int server)
+{
+ struct ib_device *dev = server?cb->child_cm_id->device:
+ cb->cm_id->device;
+ struct ib_device_attr attr;
+ int ret;
+
+ ret = ib_query_device(dev, &attr);
+ if (ret) {
+ PRINTF(cb, "ib_query_device failed ret %d\n", ret);
+ return 0;
+ }
+ if (!(attr.device_cap_flags & IB_DEVICE_MEM_MGT_EXTENSIONS)) {
+ PRINTF(cb, "Fastreg not supported - device_cap_flags 0x%llx\n",
+ (unsigned long long)attr.device_cap_flags);
+ return 0;
+ }
+ DEBUG_LOG(cb, "Fastreg supported - device_cap_flags 0x%jx\n",
+ (uintmax_t)attr.device_cap_flags);
+ return 1;
+}
+
+static int krping_bind_server(struct krping_cb *cb)
+{
+ union {
+ struct sockaddr_in v4;
+ struct sockaddr_in6 v6;
+ } sin;
+ int ret;
+
+ memset(&sin, 0, sizeof(sin));
+
+ switch (cb->addr_type) {
+ case AF_INET:
+ sin.v4.sin_len = sizeof sin.v4;
+ sin.v4.sin_family = AF_INET;
+ sin.v4.sin_addr = cb->addr.v4;
+ sin.v4.sin_port = cb->port;
+ break;
+ case AF_INET6:
+ sin.v6.sin6_len = sizeof sin.v6;
+ sin.v6.sin6_family = AF_INET6;
+ sin.v6.sin6_addr = cb->addr.v6;
+ sin.v6.sin6_port = cb->port;
+ break;
+ default:
+ return (-EINVAL);
+ }
+
+ ret = rdma_bind_addr(cb->cm_id, (struct sockaddr *) &sin);
+ if (ret) {
+ PRINTF(cb, "rdma_bind_addr error %d\n", ret);
+ return ret;
+ }
+ DEBUG_LOG(cb, "rdma_bind_addr successful\n");
+
+ DEBUG_LOG(cb, "rdma_listen\n");
+ ret = rdma_listen(cb->cm_id, 3);
+ if (ret) {
+ PRINTF(cb, "rdma_listen failed: %d\n", ret);
+ return ret;
+ }
+
+ wait_event_interruptible(cb->sem, cb->state >= CONNECT_REQUEST);
+ if (cb->state != CONNECT_REQUEST) {
+ PRINTF(cb, "wait for CONNECT_REQUEST state %d\n",
+ cb->state);
+ return -1;
+ }
+
+ if (cb->mem == FASTREG && !fastreg_supported(cb, 1))
+ return -EINVAL;
+
+ return 0;
+}
+
+/*
+ * sq-depth worth of fastreg + 0B read-inv pairs, reposting them as the reads
+ * complete.
+ * NOTE: every 9 seconds we sleep for 1 second to keep the kernel happy.
+ */
+static void krping_fr_test5(struct krping_cb *cb)
+{
+ struct ib_fast_reg_page_list **pl;
+ struct ib_send_wr *fr, *read, *bad;
+ struct ib_wc wc;
+ struct ib_sge *sgl;
+ u8 key = 0;
+ struct ib_mr **mr;
+ u8 **buf;
+ dma_addr_t *dma_addr;
+ int i;
+ int ret;
+ int plen = (((cb->size - 1) & PAGE_MASK) + PAGE_SIZE) >> PAGE_SHIFT;
+ time_t start;
+ int count = 0;
+ int scnt;
+ int depth = cb->txdepth >> 1;
+
+ if (!depth) {
+ PRINTF(cb, "txdepth must be > 1 for this test!\n");
+ return;
+ }
+
+ pl = kzalloc(sizeof *pl * depth, GFP_KERNEL);
+ DEBUG_LOG(cb, "%s pl %p size %zu\n", __func__, pl, sizeof *pl * depth);
+ mr = kzalloc(sizeof *mr * depth, GFP_KERNEL);
+ DEBUG_LOG(cb, "%s mr %p size %zu\n", __func__, mr, sizeof *mr * depth);
+ fr = kzalloc(sizeof *fr * depth, GFP_KERNEL);
+ DEBUG_LOG(cb, "%s fr %p size %zu\n", __func__, fr, sizeof *fr * depth);
+ sgl = kzalloc(sizeof *sgl * depth, GFP_KERNEL);
+ DEBUG_LOG(cb, "%s sgl %p size %zu\n", __func__, sgl, sizeof *sgl * depth);
+ read = kzalloc(sizeof *read * depth, GFP_KERNEL);
+ DEBUG_LOG(cb, "%s read %p size %zu\n", __func__, read, sizeof *read * depth);
+ buf = kzalloc(sizeof *buf * depth, GFP_KERNEL);
+ DEBUG_LOG(cb, "%s buf %p size %zu\n", __func__, buf, sizeof *buf * depth);
+ dma_addr = kzalloc(sizeof *dma_addr * depth, GFP_KERNEL);
+ DEBUG_LOG(cb, "%s dma_addr %p size %zu\n", __func__, dma_addr, sizeof *dma_addr * depth);
+ if (!pl || !mr || !fr || !read || !sgl || !buf || !dma_addr) {
+ PRINTF(cb, "kzalloc failed\n");
+ goto err1;
+ }
+
+ for (scnt = 0; scnt < depth; scnt++) {
+ pl[scnt] = ib_alloc_fast_reg_page_list(cb->qp->device, plen);
+ if (IS_ERR(pl[scnt])) {
+ PRINTF(cb, "alloc_fr_page_list failed %ld\n",
+ PTR_ERR(pl[scnt]));
+ goto err2;
+ }
+ DEBUG_LOG(cb, "%s pl[%u] %p\n", __func__, scnt, pl[scnt]);
+
+ mr[scnt] = ib_alloc_fast_reg_mr(cb->pd, plen);
+ if (IS_ERR(mr[scnt])) {
+ PRINTF(cb, "alloc_fr failed %ld\n",
+ PTR_ERR(mr[scnt]));
+ goto err2;
+ }
+ DEBUG_LOG(cb, "%s mr[%u] %p\n", __func__, scnt, mr[scnt]);
+ ib_update_fast_reg_key(mr[scnt], ++key);
+
+ buf[scnt] = kmalloc(cb->size, GFP_KERNEL);
+ if (!buf[scnt]) {
+ PRINTF(cb, "kmalloc failed\n");
+ ret = -ENOMEM;
+ goto err2;
+ }
+ DEBUG_LOG(cb, "%s buf[%u] %p\n", __func__, scnt, buf[scnt]);
+ dma_addr[scnt] = dma_map_single(cb->pd->device->dma_device,
+ buf[scnt], cb->size,
+ DMA_BIDIRECTIONAL);
+ if (dma_mapping_error(cb->pd->device->dma_device,
+ dma_addr[scnt])) {
+ PRINTF(cb, "dma_map failed\n");
+ ret = -ENOMEM;
+ goto err2;
+ }
+ DEBUG_LOG(cb, "%s dma_addr[%u] %p\n", __func__, scnt, (void *)dma_addr[scnt]);
+ for (i=0; i<plen; i++) {
+ pl[scnt]->page_list[i] = ((unsigned long)dma_addr[scnt] & PAGE_MASK) + (i * PAGE_SIZE);
+ DEBUG_LOG(cb, "%s pl[%u]->page_list[%u] 0x%jx\n",
+ __func__, scnt, i, (uintmax_t)pl[scnt]->page_list[i]);
+ }
+
+ sgl[scnt].lkey = mr[scnt]->rkey;
+ sgl[scnt].length = cb->size;
+ sgl[scnt].addr = (u64)buf[scnt];
+ DEBUG_LOG(cb, "%s sgl[%u].lkey 0x%x length %u addr 0x%jx\n",
+ __func__, scnt, sgl[scnt].lkey, sgl[scnt].length,
+ (uintmax_t)sgl[scnt].addr);
+
+ fr[scnt].opcode = IB_WR_FAST_REG_MR;
+ fr[scnt].wr_id = scnt;
+ fr[scnt].send_flags = 0;
+ fr[scnt].wr.fast_reg.page_shift = PAGE_SHIFT;
+ fr[scnt].wr.fast_reg.length = cb->size;
+ fr[scnt].wr.fast_reg.page_list = pl[scnt];
+ fr[scnt].wr.fast_reg.page_list_len = plen;
+ fr[scnt].wr.fast_reg.iova_start = (u64)buf[scnt];
+ fr[scnt].wr.fast_reg.access_flags = IB_ACCESS_REMOTE_WRITE | IB_ACCESS_LOCAL_WRITE;
+ fr[scnt].wr.fast_reg.rkey = mr[scnt]->rkey;
+ fr[scnt].next = &read[scnt];
+ read[scnt].opcode = IB_WR_RDMA_READ_WITH_INV;
+ read[scnt].wr_id = scnt;
+ read[scnt].send_flags = IB_SEND_SIGNALED;
+ read[scnt].wr.rdma.rkey = cb->remote_rkey;
+ read[scnt].wr.rdma.remote_addr = cb->remote_addr;
+ read[scnt].num_sge = 1;
+ read[scnt].sg_list = &sgl[scnt];
+ ret = ib_post_send(cb->qp, &fr[scnt], &bad);
+ if (ret) {
+ PRINTF(cb, "ib_post_send failed %d\n", ret);
+ goto err2;
+ }
+ }
+
+ start = time_uptime;
+ DEBUG_LOG(cb, "%s starting IO.\n", __func__);
+ while (!cb->count || cb->server || count < cb->count) {
+ if ((time_uptime - start) >= 9) {
+ DEBUG_LOG(cb, "%s pausing 1 tick! count %u\n", __func__,
+ count);
+ wait_event_interruptible_timeout(cb->sem,
+ cb->state == ERROR,
+ 1);
+ if (cb->state == ERROR)
+ break;
+ start = time_uptime;
+ }
+ do {
+ ret = ib_poll_cq(cb->cq, 1, &wc);
+ if (ret < 0) {
+ PRINTF(cb, "ib_poll_cq failed %d\n",
+ ret);
+ goto err2;
+ }
+ if (ret == 1) {
+ if (wc.status) {
+ PRINTF(cb,
+ "completion error %u wr_id %ju "
+ "opcode %d\n", wc.status,
+ (uintmax_t)wc.wr_id, wc.opcode);
+ goto err2;
+ }
+ count++;
+ if (count == cb->count)
+ break;
+ ib_update_fast_reg_key(mr[wc.wr_id], ++key);
+ fr[wc.wr_id].wr.fast_reg.rkey =
+ mr[wc.wr_id]->rkey;
+ sgl[wc.wr_id].lkey = mr[wc.wr_id]->rkey;
+ ret = ib_post_send(cb->qp, &fr[wc.wr_id], &bad);
+ if (ret) {
+ PRINTF(cb,
+ "ib_post_send failed %d\n", ret);
+ goto err2;
+ }
+ } else if (krping_sigpending()) {
+ PRINTF(cb, "signal!\n");
+ goto err2;
+ }
+ } while (ret == 1);
+ }
+ DEBUG_LOG(cb, "%s done!\n", __func__);
+err2:
+ DEBUG_LOG(cb, "sleeping 1 second\n");
+ wait_event_interruptible_timeout(cb->sem, cb->state == ERROR, HZ);
+ DEBUG_LOG(cb, "draining the cq...\n");
+ do {
+ ret = ib_poll_cq(cb->cq, 1, &wc);
+ if (ret < 0) {
+ PRINTF(cb, "ib_poll_cq failed %d\n", ret);
+ break;
+ }
+ if (ret == 1) {
+ if (wc.status) {
+ PRINTF(cb, "completion error %u "
+ "opcode %u\n", wc.status, wc.opcode);
+ }
+ }
+ } while (ret == 1);
+
+ DEBUG_LOG(cb, "destroying fr mrs!\n");
+ for (scnt = 0; scnt < depth; scnt++) {
+ if (mr[scnt]) {
+ ib_dereg_mr(mr[scnt]);
+ DEBUG_LOG(cb, "%s dereg mr %p\n", __func__, mr[scnt]);
+ }
+ }
+ DEBUG_LOG(cb, "unmapping/freeing bufs!\n");
+ for (scnt = 0; scnt < depth; scnt++) {
+ if (buf[scnt]) {
+ dma_unmap_single(cb->pd->device->dma_device,
+ dma_addr[scnt], cb->size,
+ DMA_BIDIRECTIONAL);
+ kfree(buf[scnt]);
+ DEBUG_LOG(cb, "%s unmap/free buf %p dma_addr %p\n", __func__, buf[scnt], (void *)dma_addr[scnt]);
+ }
+ }
+ DEBUG_LOG(cb, "destroying fr page lists!\n");
+ for (scnt = 0; scnt < depth; scnt++) {
+ if (pl[scnt]) {
+ DEBUG_LOG(cb, "%s free pl %p\n", __func__, pl[scnt]);
+ ib_free_fast_reg_page_list(pl[scnt]);
+ }
+ }
+err1:
+ if (pl)
+ kfree(pl);
+ if (mr)
+ kfree(mr);
+ if (fr)
+ kfree(fr);
+ if (read)
+ kfree(read);
+ if (sgl)
+ kfree(sgl);
+ if (buf)
+ kfree(buf);
+ if (dma_addr)
+ kfree(dma_addr);
+}
+static void krping_fr_test_server(struct krping_cb *cb)
+{
+ DEBUG_LOG(cb, "%s waiting for disconnect...\n", __func__);
+ wait_event_interruptible(cb->sem, cb->state == ERROR);
+}
+
+static void krping_fr_test5_server(struct krping_cb *cb)
+{
+ struct ib_send_wr *bad_wr;
+ struct ib_wc wc;
+ int ret;
+
+ /* Spin waiting for client's Start STAG/TO/Len */
+ while (cb->state < RDMA_READ_ADV) {
+ krping_cq_event_handler(cb->cq, cb);
+ }
+ DEBUG_LOG(cb, "%s client STAG %x TO 0x%jx\n", __func__,
+ cb->remote_rkey, (uintmax_t)cb->remote_addr);
+
+ /* Send STAG/TO/Len to client */
+ krping_format_send(cb, cb->start_dma_addr);
+ ret = ib_post_send(cb->qp, &cb->sq_wr, &bad_wr);
+ if (ret) {
+ PRINTF(cb, "post send error %d\n", ret);
+ return;
+ }
+
+ /* Spin waiting for send completion */
+ while ((ret = ib_poll_cq(cb->cq, 1, &wc) == 0));
+ if (ret < 0) {
+ PRINTF(cb, "poll error %d\n", ret);
+ return;
+ }
+ if (wc.status) {
+ PRINTF(cb, "send completiong error %d\n", wc.status);
+ return;
+ }
+
+ if (cb->duplex)
+ krping_fr_test5(cb);
+ DEBUG_LOG(cb, "%s waiting for disconnect...\n", __func__);
+ wait_event_interruptible(cb->sem, cb->state == ERROR);
+}
+
+static void krping_fr_test5_client(struct krping_cb *cb)
+{
+ struct ib_send_wr *bad;
+ struct ib_wc wc;
+ int ret;
+
+ cb->state = RDMA_READ_ADV;
+
+ /* Send STAG/TO/Len to server */
+ krping_format_send(cb, cb->start_dma_addr);
+ if (cb->state == ERROR) {
+ PRINTF(cb, "krping_format_send failed\n");
+ return;
+ }
+ ret = ib_post_send(cb->qp, &cb->sq_wr, &bad);
+ if (ret) {
+ PRINTF(cb, "post send error %d\n", ret);
+ return;
+ }
+
+ /* Spin waiting for send completion */
+ while ((ret = ib_poll_cq(cb->cq, 1, &wc) == 0));
+ if (ret < 0) {
+ PRINTF(cb, "poll error %d\n", ret);
+ return;
+ }
+ if (wc.status) {
+ PRINTF(cb, "send completion error %d\n", wc.status);
+ return;
+ }
+
+ /* Spin waiting for server's Start STAG/TO/Len */
+ while (cb->state < RDMA_WRITE_ADV) {
+ krping_cq_event_handler(cb->cq, cb);
+ }
+ DEBUG_LOG(cb, "%s server STAG %x TO 0x%jx\n", __func__, cb->remote_rkey,
+ (uintmax_t)cb->remote_addr);
+
+ return krping_fr_test5(cb);
+}
+
+/*
+ * sq-depth worth of write + fastreg + inv, reposting them as the invs
+ * complete.
+ * NOTE: every 9 seconds we sleep for 1 second to keep the kernel happy.
+ * If a count is given, then the last IO will have a bogus lkey in the
+ * write work request. This reproduces a fw bug where the connection
+ * will get stuck if a fastreg is processed while the ulptx is failing
+ * the bad write.
+ */
+static void krping_fr_test6(struct krping_cb *cb)
+{
+ struct ib_fast_reg_page_list **pl;
+ struct ib_send_wr *fr, *write, *inv, *bad;
+ struct ib_wc wc;
+ struct ib_sge *sgl;
+ u8 key = 0;
+ struct ib_mr **mr;
+ u8 **buf;
+ dma_addr_t *dma_addr;
+ int i;
+ int ret;
+ int plen = (((cb->size - 1) & PAGE_MASK) + PAGE_SIZE) >> PAGE_SHIFT;
+ unsigned long start;
+ int count = 0;
+ int scnt;
+ int depth = cb->txdepth / 3;
+
+ if (!depth) {
+ PRINTF(cb, "txdepth must be > 3 for this test!\n");
+ return;
+ }
+
+ pl = kzalloc(sizeof *pl * depth, GFP_KERNEL);
+ DEBUG_LOG(cb, "%s pl %p size %zu\n", __func__, pl, sizeof *pl * depth);
+
+ mr = kzalloc(sizeof *mr * depth, GFP_KERNEL);
+ DEBUG_LOG(cb, "%s mr %p size %zu\n", __func__, mr, sizeof *mr * depth);
+
+ fr = kzalloc(sizeof *fr * depth, GFP_KERNEL);
+ DEBUG_LOG(cb, "%s fr %p size %zu\n", __func__, fr, sizeof *fr * depth);
+
+ sgl = kzalloc(sizeof *sgl * depth, GFP_KERNEL);
+ DEBUG_LOG(cb, "%s sgl %p size %zu\n", __func__, sgl, sizeof *sgl * depth);
+
+ write = kzalloc(sizeof *write * depth, GFP_KERNEL);
+ DEBUG_LOG(cb, "%s read %p size %zu\n", __func__, write, sizeof *write * depth);
+
+ inv = kzalloc(sizeof *inv * depth, GFP_KERNEL);
+ DEBUG_LOG(cb, "%s inv %p size %zu\n", __func__, inv, sizeof *inv * depth);
+
+ buf = kzalloc(sizeof *buf * depth, GFP_KERNEL);
+ DEBUG_LOG(cb, "%s buf %p size %zu\n", __func__, buf, sizeof *buf * depth);
+
+ dma_addr = kzalloc(sizeof *dma_addr * depth, GFP_KERNEL);
+ DEBUG_LOG(cb, "%s dma_addr %p size %zu\n", __func__, dma_addr, sizeof *dma_addr * depth);
+
+ if (!pl || !mr || !fr || !write || !sgl || !buf || !dma_addr) {
+ PRINTF(cb, "kzalloc failed\n");
+ goto err1;
+ }
+
+ for (scnt = 0; scnt < depth; scnt++) {
+ pl[scnt] = ib_alloc_fast_reg_page_list(cb->qp->device, plen);
+ if (IS_ERR(pl[scnt])) {
+ PRINTF(cb, "alloc_fr_page_list failed %ld\n",
+ PTR_ERR(pl[scnt]));
+ goto err2;
+ }
+ DEBUG_LOG(cb, "%s pl[%u] %p\n", __func__, scnt, pl[scnt]);
+
+ mr[scnt] = ib_alloc_fast_reg_mr(cb->pd, plen);
+ if (IS_ERR(mr[scnt])) {
+ PRINTF(cb, "alloc_fr failed %ld\n",
+ PTR_ERR(mr[scnt]));
+ goto err2;
+ }
+ DEBUG_LOG(cb, "%s mr[%u] %p\n", __func__, scnt, mr[scnt]);
+ ib_update_fast_reg_key(mr[scnt], ++key);
+
+ buf[scnt] = kmalloc(cb->size, GFP_KERNEL);
+ if (!buf[scnt]) {
+ PRINTF(cb, "kmalloc failed\n");
+ ret = -ENOMEM;
+ goto err2;
+ }
+ DEBUG_LOG(cb, "%s buf[%u] %p\n", __func__, scnt, buf[scnt]);
+ dma_addr[scnt] = dma_map_single(cb->pd->device->dma_device,
+ buf[scnt], cb->size,
+ DMA_BIDIRECTIONAL);
+ if (dma_mapping_error(cb->pd->device->dma_device,
+ dma_addr[scnt])) {
+ PRINTF(cb, "dma_map failed\n");
+ ret = -ENOMEM;
+ goto err2;
+ }
+ DEBUG_LOG(cb, "%s dma_addr[%u] %p\n", __func__, scnt, (void *)dma_addr[scnt]);
+ for (i=0; i<plen; i++) {
+ pl[scnt]->page_list[i] = ((unsigned long)dma_addr[scnt] & PAGE_MASK) + (i * PAGE_SIZE);
+ DEBUG_LOG(cb, "%s pl[%u]->page_list[%u] 0x%jx\n",
+ __func__, scnt, i, (uintmax_t)pl[scnt]->page_list[i]);
+ }
+
+ write[scnt].opcode = IB_WR_RDMA_WRITE;
+ write[scnt].wr_id = scnt;
+ write[scnt].wr.rdma.rkey = cb->remote_rkey;
+ write[scnt].wr.rdma.remote_addr = cb->remote_addr;
+ write[scnt].num_sge = 1;
+ write[scnt].sg_list = &cb->rdma_sgl;
+ write[scnt].sg_list->length = cb->size;
+ write[scnt].next = &fr[scnt];
+
+ fr[scnt].opcode = IB_WR_FAST_REG_MR;
+ fr[scnt].wr_id = scnt;
+ fr[scnt].wr.fast_reg.page_shift = PAGE_SHIFT;
+ fr[scnt].wr.fast_reg.length = cb->size;
+ fr[scnt].wr.fast_reg.page_list = pl[scnt];
+ fr[scnt].wr.fast_reg.page_list_len = plen;
+ fr[scnt].wr.fast_reg.iova_start = (u64)buf[scnt];
+ fr[scnt].wr.fast_reg.access_flags = IB_ACCESS_REMOTE_WRITE | IB_ACCESS_LOCAL_WRITE;
+ fr[scnt].wr.fast_reg.rkey = mr[scnt]->rkey;
+ fr[scnt].next = &inv[scnt];
+
+ inv[scnt].opcode = IB_WR_LOCAL_INV;
+ inv[scnt].send_flags = IB_SEND_SIGNALED;
+ inv[scnt].ex.invalidate_rkey = mr[scnt]->rkey;
+
+ ret = ib_post_send(cb->qp, &write[scnt], &bad);
+ if (ret) {
+ PRINTF(cb, "ib_post_send failed %d\n", ret);
+ goto err2;
+ }
+ }
+
+ start = time_uptime;
+ DEBUG_LOG(cb, "%s starting IO.\n", __func__);
+ while (!cb->count || cb->server || count < cb->count) {
+ if ((time_uptime - start) >= 9) {
+ DEBUG_LOG(cb, "%s pausing 1 tick! count %u\n", __func__,
+ count);
+ wait_event_interruptible_timeout(cb->sem,
+ cb->state == ERROR,
+ 1);
+ if (cb->state == ERROR)
+ break;
+ start = time_uptime;
+ }
+ do {
+ ret = ib_poll_cq(cb->cq, 1, &wc);
+ if (ret < 0) {
+ PRINTF(cb, "ib_poll_cq failed %d\n",
+ ret);
+ goto err2;
+ }
+ if (ret == 1) {
+ if (wc.status) {
+ PRINTF(cb,
+ "completion error %u wr_id %ju "
+ "opcode %d\n", wc.status,
+ (uintmax_t)wc.wr_id, wc.opcode);
+ goto err2;
+ }
+ count++;
+ if (count == (cb->count -1))
+ cb->rdma_sgl.lkey = 0x00dead;
+ if (count == cb->count)
+ break;
+ ib_update_fast_reg_key(mr[wc.wr_id], ++key);
+ fr[wc.wr_id].wr.fast_reg.rkey =
+ mr[wc.wr_id]->rkey;
+ inv[wc.wr_id].ex.invalidate_rkey =
+ mr[wc.wr_id]->rkey;
+ ret = ib_post_send(cb->qp, &write[wc.wr_id], &bad);
+ if (ret) {
+ PRINTF(cb,
+ "ib_post_send failed %d\n", ret);
+ goto err2;
+ }
+ } else if (krping_sigpending()){
+ PRINTF(cb, "signal!\n");
+ goto err2;
+ }
+ } while (ret == 1);
+ }
+ DEBUG_LOG(cb, "%s done!\n", __func__);
+err2:
+ DEBUG_LOG(cb, "sleeping 1 second\n");
+ wait_event_interruptible_timeout(cb->sem, cb->state == ERROR, HZ);
+ DEBUG_LOG(cb, "draining the cq...\n");
+ do {
+ ret = ib_poll_cq(cb->cq, 1, &wc);
+ if (ret < 0) {
+ PRINTF(cb, "ib_poll_cq failed %d\n", ret);
+ break;
+ }
+ if (ret == 1) {
+ if (wc.status) {
+ PRINTF(cb, "completion error %u "
+ "opcode %u\n", wc.status, wc.opcode);
+ }
+ }
+ } while (ret == 1);
+
+ DEBUG_LOG(cb, "destroying fr mrs!\n");
+ for (scnt = 0; scnt < depth; scnt++) {
+ if (mr[scnt]) {
+ ib_dereg_mr(mr[scnt]);
+ DEBUG_LOG(cb, "%s dereg mr %p\n", __func__, mr[scnt]);
+ }
+ }
+ DEBUG_LOG(cb, "unmapping/freeing bufs!\n");
+ for (scnt = 0; scnt < depth; scnt++) {
+ if (buf[scnt]) {
+ dma_unmap_single(cb->pd->device->dma_device,
+ dma_addr[scnt], cb->size,
+ DMA_BIDIRECTIONAL);
+ kfree(buf[scnt]);
+ DEBUG_LOG(cb, "%s unmap/free buf %p dma_addr %p\n", __func__, buf[scnt], (void *)dma_addr[scnt]);
+ }
+ }
+ DEBUG_LOG(cb, "destroying fr page lists!\n");
+ for (scnt = 0; scnt < depth; scnt++) {
+ if (pl[scnt]) {
+ DEBUG_LOG(cb, "%s free pl %p\n", __func__, pl[scnt]);
+ ib_free_fast_reg_page_list(pl[scnt]);
+ }
+ }
+err1:
+ if (pl)
+ kfree(pl);
+ if (mr)
+ kfree(mr);
+ if (fr)
+ kfree(fr);
+ if (write)
+ kfree(write);
+ if (inv)
+ kfree(inv);
+ if (sgl)
+ kfree(sgl);
+ if (buf)
+ kfree(buf);
+ if (dma_addr)
+ kfree(dma_addr);
+}
+
+static void krping_fr_test6_server(struct krping_cb *cb)
+{
+ struct ib_send_wr *bad_wr;
+ struct ib_wc wc;
+ int ret;
+
+ /* Spin waiting for client's Start STAG/TO/Len */
+ while (cb->state < RDMA_READ_ADV) {
+ krping_cq_event_handler(cb->cq, cb);
+ }
+ DEBUG_LOG(cb, "%s client STAG %x TO 0x%jx\n", __func__,
+ cb->remote_rkey, (uintmax_t)cb->remote_addr);
+
+ /* Send STAG/TO/Len to client */
+ krping_format_send(cb, cb->start_dma_addr);
+ ret = ib_post_send(cb->qp, &cb->sq_wr, &bad_wr);
+ if (ret) {
+ PRINTF(cb, "post send error %d\n", ret);
+ return;
+ }
+
+ /* Spin waiting for send completion */
+ while ((ret = ib_poll_cq(cb->cq, 1, &wc) == 0));
+ if (ret < 0) {
+ PRINTF(cb, "poll error %d\n", ret);
+ return;
+ }
+ if (wc.status) {
+ PRINTF(cb, "send completiong error %d\n", wc.status);
+ return;
+ }
+
+ if (cb->duplex)
+ krping_fr_test6(cb);
+ DEBUG_LOG(cb, "%s waiting for disconnect...\n", __func__);
+ wait_event_interruptible(cb->sem, cb->state == ERROR);
+}
+
+static void krping_fr_test6_client(struct krping_cb *cb)
+{
+ struct ib_send_wr *bad;
+ struct ib_wc wc;
+ int ret;
+
+ cb->state = RDMA_READ_ADV;
+
+ /* Send STAG/TO/Len to server */
+ krping_format_send(cb, cb->start_dma_addr);
+ if (cb->state == ERROR) {
+ PRINTF(cb, "krping_format_send failed\n");
+ return;
+ }
+ ret = ib_post_send(cb->qp, &cb->sq_wr, &bad);
+ if (ret) {
+ PRINTF(cb, "post send error %d\n", ret);
+ return;
+ }
+
+ /* Spin waiting for send completion */
+ while ((ret = ib_poll_cq(cb->cq, 1, &wc) == 0));
+ if (ret < 0) {
+ PRINTF(cb, "poll error %d\n", ret);
+ return;
+ }
+ if (wc.status) {
+ PRINTF(cb, "send completion error %d\n", wc.status);
+ return;
+ }
+
+ /* Spin waiting for server's Start STAG/TO/Len */
+ while (cb->state < RDMA_WRITE_ADV) {
+ krping_cq_event_handler(cb->cq, cb);
+ }
+ DEBUG_LOG(cb, "%s server STAG %x TO 0x%jx\n", __func__, cb->remote_rkey,
+ (uintmax_t)cb->remote_addr);
+
+ return krping_fr_test6(cb);
+}
+
+static void krping_run_server(struct krping_cb *cb)
+{
+ struct ib_recv_wr *bad_wr;
+ int ret;
+
+ ret = krping_bind_server(cb);
+ if (ret)
+ return;
+
+ ret = krping_setup_qp(cb, cb->child_cm_id);
+ if (ret) {
+ PRINTF(cb, "setup_qp failed: %d\n", ret);
+ goto err0;
+ }
+
+ ret = krping_setup_buffers(cb);
+ if (ret) {
+ PRINTF(cb, "krping_setup_buffers failed: %d\n", ret);
+ goto err1;
+ }
+
+ ret = ib_post_recv(cb->qp, &cb->rq_wr, &bad_wr);
+ if (ret) {
+ PRINTF(cb, "ib_post_recv failed: %d\n", ret);
+ goto err2;
+ }
+
+ ret = krping_accept(cb);
+ if (ret) {
+ PRINTF(cb, "connect error %d\n", ret);
+ goto err2;
+ }
+
+ if (cb->wlat)
+ krping_wlat_test_server(cb);
+ else if (cb->rlat)
+ krping_rlat_test_server(cb);
+ else if (cb->bw)
+ krping_bw_test_server(cb);
+ else if (cb->frtest) {
+ switch (cb->testnum) {
+ case 1:
+ case 2:
+ case 3:
+ case 4:
+ krping_fr_test_server(cb);
+ break;
+ case 5:
+ krping_fr_test5_server(cb);
+ break;
+ case 6:
+ krping_fr_test6_server(cb);
+ break;
+ default:
+ PRINTF(cb, "unknown fr test %d\n", cb->testnum);
+ goto err2;
+ break;
+ }
+ } else
+ krping_test_server(cb);
+ rdma_disconnect(cb->child_cm_id);
+err2:
+ krping_free_buffers(cb);
+err1:
+ krping_free_qp(cb);
+err0:
+ rdma_destroy_id(cb->child_cm_id);
+}
+
+static void krping_test_client(struct krping_cb *cb)
+{
+ int ping, start, cc, i, ret;
+ struct ib_send_wr *bad_wr;
+ unsigned char c;
+
+ start = 65;
+ for (ping = 0; !cb->count || ping < cb->count; ping++) {
+ cb->state = RDMA_READ_ADV;
+
+ /* Put some ascii text in the buffer. */
+ cc = sprintf(cb->start_buf, "rdma-ping-%d: ", ping);
+ for (i = cc, c = start; i < cb->size; i++) {
+ cb->start_buf[i] = c;
+ c++;
+ if (c > 122)
+ c = 65;
+ }
+ start++;
+ if (start > 122)
+ start = 65;
+ cb->start_buf[cb->size - 1] = 0;
+
+ krping_format_send(cb, cb->start_dma_addr);
+ if (cb->state == ERROR) {
+ PRINTF(cb, "krping_format_send failed\n");
+ break;
+ }
+ ret = ib_post_send(cb->qp, &cb->sq_wr, &bad_wr);
+ if (ret) {
+ PRINTF(cb, "post send error %d\n", ret);
+ break;
+ }
+
+ /* Wait for server to ACK */
+ wait_event_interruptible(cb->sem, cb->state >= RDMA_WRITE_ADV);
+ if (cb->state != RDMA_WRITE_ADV) {
+ PRINTF(cb,
+ "wait for RDMA_WRITE_ADV state %d\n",
+ cb->state);
+ break;
+ }
+
+ krping_format_send(cb, cb->rdma_dma_addr);
+ ret = ib_post_send(cb->qp, &cb->sq_wr, &bad_wr);
+ if (ret) {
+ PRINTF(cb, "post send error %d\n", ret);
+ break;
+ }
+
+ /* Wait for the server to say the RDMA Write is complete. */
+ wait_event_interruptible(cb->sem,
+ cb->state >= RDMA_WRITE_COMPLETE);
+ if (cb->state != RDMA_WRITE_COMPLETE) {
+ PRINTF(cb,
+ "wait for RDMA_WRITE_COMPLETE state %d\n",
+ cb->state);
+ break;
+ }
+
+ if (cb->validate)
+ if (memcmp(cb->start_buf, cb->rdma_buf, cb->size)) {
+ PRINTF(cb, "data mismatch!\n");
+ break;
+ }
+
+ if (cb->verbose) {
+ if (strlen(cb->rdma_buf) > 128) {
+ char msgbuf[128];
+
+ strlcpy(msgbuf, cb->rdma_buf, sizeof(msgbuf));
+ PRINTF(cb, "ping data stripped: %s\n",
+ msgbuf);
+ } else
+ PRINTF(cb, "ping data: %s\n", cb->rdma_buf);
+ }
+#ifdef SLOW_KRPING
+ wait_event_interruptible_timeout(cb->sem, cb->state == ERROR, HZ);
+#endif
+ }
+}
+
+static void krping_rlat_test_client(struct krping_cb *cb)
+{
+ struct ib_send_wr *bad_wr;
+ struct ib_wc wc;
+ int ret;
+
+ cb->state = RDMA_READ_ADV;
+
+ /* Send STAG/TO/Len to client */
+ krping_format_send(cb, cb->start_dma_addr);
+ if (cb->state == ERROR) {
+ PRINTF(cb, "krping_format_send failed\n");
+ return;
+ }
+ ret = ib_post_send(cb->qp, &cb->sq_wr, &bad_wr);
+ if (ret) {
+ PRINTF(cb, "post send error %d\n", ret);
+ return;
+ }
+
+ /* Spin waiting for send completion */
+ while ((ret = ib_poll_cq(cb->cq, 1, &wc) == 0));
+ if (ret < 0) {
+ PRINTF(cb, "poll error %d\n", ret);
+ return;
+ }
+ if (wc.status) {
+ PRINTF(cb, "send completion error %d\n", wc.status);
+ return;
+ }
+
+ /* Spin waiting for server's Start STAG/TO/Len */
+ while (cb->state < RDMA_WRITE_ADV) {
+ krping_cq_event_handler(cb->cq, cb);
+ }
+
+#if 0
+{
+ int i;
+ struct timeval start, stop;
+ time_t sec;
+ suseconds_t usec;
+ unsigned long long elapsed;
+ struct ib_wc wc;
+ struct ib_send_wr *bad_wr;
+ int ne;
+
+ cb->rdma_sq_wr.opcode = IB_WR_RDMA_WRITE;
+ cb->rdma_sq_wr.wr.rdma.rkey = cb->remote_rkey;
+ cb->rdma_sq_wr.wr.rdma.remote_addr = cb->remote_addr;
+ cb->rdma_sq_wr.sg_list->length = 0;
+ cb->rdma_sq_wr.num_sge = 0;
+
+ microtime(&start);
+ for (i=0; i < 100000; i++) {
+ if (ib_post_send(cb->qp, &cb->rdma_sq_wr, &bad_wr)) {
+ PRINTF(cb, "Couldn't post send\n");
+ return;
+ }
+ do {
+ ne = ib_poll_cq(cb->cq, 1, &wc);
+ } while (ne == 0);
+ if (ne < 0) {
+ PRINTF(cb, "poll CQ failed %d\n", ne);
+ return;
+ }
+ if (wc.status != IB_WC_SUCCESS) {
+ PRINTF(cb, "Completion wth error at %s:\n",
+ cb->server ? "server" : "client");
+ PRINTF(cb, "Failed status %d: wr_id %d\n",
+ wc.status, (int) wc.wr_id);
+ return;
+ }
+ }
+ microtime(&stop);
+
+ if (stop.tv_usec < start.tv_usec) {
+ stop.tv_usec += 1000000;
+ stop.tv_sec -= 1;
+ }
+ sec = stop.tv_sec - start.tv_sec;
+ usec = stop.tv_usec - start.tv_usec;
+ elapsed = sec * 1000000 + usec;
+ PRINTF(cb, "0B-write-lat iters 100000 usec %llu\n", elapsed);
+}
+#endif
+
+ rlat_test(cb);
+}
+
+static void krping_wlat_test_client(struct krping_cb *cb)
+{
+ struct ib_send_wr *bad_wr;
+ struct ib_wc wc;
+ int ret;
+
+ cb->state = RDMA_READ_ADV;
+
+ /* Send STAG/TO/Len to client */
+ krping_format_send(cb, cb->start_dma_addr);
+ if (cb->state == ERROR) {
+ PRINTF(cb, "krping_format_send failed\n");
+ return;
+ }
+ ret = ib_post_send(cb->qp, &cb->sq_wr, &bad_wr);
+ if (ret) {
+ PRINTF(cb, "post send error %d\n", ret);
+ return;
+ }
+
+ /* Spin waiting for send completion */
+ while ((ret = ib_poll_cq(cb->cq, 1, &wc) == 0));
+ if (ret < 0) {
+ PRINTF(cb, "poll error %d\n", ret);
+ return;
+ }
+ if (wc.status) {
+ PRINTF(cb, "send completion error %d\n", wc.status);
+ return;
+ }
+
+ /* Spin waiting for server's Start STAG/TO/Len */
+ while (cb->state < RDMA_WRITE_ADV) {
+ krping_cq_event_handler(cb->cq, cb);
+ }
+
+ wlat_test(cb);
+}
+
+static void krping_bw_test_client(struct krping_cb *cb)
+{
+ struct ib_send_wr *bad_wr;
+ struct ib_wc wc;
+ int ret;
+
+ cb->state = RDMA_READ_ADV;
+
+ /* Send STAG/TO/Len to client */
+ krping_format_send(cb, cb->start_dma_addr);
+ if (cb->state == ERROR) {
+ PRINTF(cb, "krping_format_send failed\n");
+ return;
+ }
+ ret = ib_post_send(cb->qp, &cb->sq_wr, &bad_wr);
+ if (ret) {
+ PRINTF(cb, "post send error %d\n", ret);
+ return;
+ }
+
+ /* Spin waiting for send completion */
+ while ((ret = ib_poll_cq(cb->cq, 1, &wc) == 0));
+ if (ret < 0) {
+ PRINTF(cb, "poll error %d\n", ret);
+ return;
+ }
+ if (wc.status) {
+ PRINTF(cb, "send completion error %d\n", wc.status);
+ return;
+ }
+
+ /* Spin waiting for server's Start STAG/TO/Len */
+ while (cb->state < RDMA_WRITE_ADV) {
+ krping_cq_event_handler(cb->cq, cb);
+ }
+
+ bw_test(cb);
+}
+
+
+/*
+ * fastreg 2 valid different mrs and verify the completions.
+ */
+static void krping_fr_test1(struct krping_cb *cb)
+{
+ struct ib_fast_reg_page_list *pl;
+ struct ib_send_wr fr, *bad;
+ struct ib_wc wc;
+ struct ib_mr *mr1, *mr2;
+ int i;
+ int ret;
+ int size = cb->size;
+ int plen = (((size - 1) & PAGE_MASK) + PAGE_SIZE) >> PAGE_SHIFT;
+ int count = 0;
+
+ pl = ib_alloc_fast_reg_page_list(cb->qp->device, plen);
+ if (IS_ERR(pl)) {
+ PRINTF(cb, "ib_alloc_fast_reg_page_list failed %ld\n", PTR_ERR(pl));
+ return;
+ }
+
+ mr1 = ib_alloc_fast_reg_mr(cb->pd, plen);
+ if (IS_ERR(mr1)) {
+ PRINTF(cb, "ib_alloc_fast_reg_mr failed %ld\n", PTR_ERR(pl));
+ goto err1;
+ }
+ mr2 = ib_alloc_fast_reg_mr(cb->pd, plen);
+ if (IS_ERR(mr2)) {
+ PRINTF(cb, "ib_alloc_fast_reg_mr failed %ld\n", PTR_ERR(pl));
+ goto err2;
+ }
+
+
+ for (i=0; i<plen; i++)
+ pl->page_list[i] = i * PAGE_SIZE;
+
+ memset(&fr, 0, sizeof fr);
+ fr.opcode = IB_WR_FAST_REG_MR;
+ fr.wr_id = 1;
+ fr.wr.fast_reg.page_shift = PAGE_SHIFT;
+ fr.wr.fast_reg.length = size;
+ fr.wr.fast_reg.page_list = pl;
+ fr.wr.fast_reg.page_list_len = plen;
+ fr.wr.fast_reg.iova_start = 0;
+ fr.wr.fast_reg.access_flags = IB_ACCESS_REMOTE_WRITE | IB_ACCESS_LOCAL_WRITE;
+ fr.send_flags = IB_SEND_SIGNALED;
+ fr.wr.fast_reg.rkey = mr1->rkey;
+ DEBUG_LOG(cb, "%s fr1: stag 0x%x plen %u size %u depth %u\n", __func__, fr.wr.fast_reg.rkey, plen, cb->size, cb->txdepth);
+ ret = ib_post_send(cb->qp, &fr, &bad);
+ if (ret) {
+ PRINTF(cb, "ib_post_send failed %d\n", ret);
+ goto err3;
+ }
+ fr.wr.fast_reg.rkey = mr2->rkey;
+ DEBUG_LOG(cb, "%s fr2: stag 0x%x plen %u size %u depth %u\n", __func__, fr.wr.fast_reg.rkey, plen, cb->size, cb->txdepth);
+ ret = ib_post_send(cb->qp, &fr, &bad);
+ if (ret) {
+ PRINTF(cb, "ib_post_send failed %d\n", ret);
+ goto err3;
+ }
+
+ DEBUG_LOG(cb, "sleeping 1 second\n");
+ wait_event_interruptible_timeout(cb->sem, cb->state == ERROR, HZ);
+ do {
+ ret = ib_poll_cq(cb->cq, 1, &wc);
+ if (ret < 0) {
+ PRINTF(cb, "ib_poll_cq failed %d\n", ret);
+ goto err3;
+ }
+ if (ret == 1) {
+ DEBUG_LOG(cb, "completion status %u wr %s\n",
+ wc.status, wc.wr_id == 1 ? "fr" : "inv");
+ count++;
+ } else if (krping_sigpending()) {
+ PRINTF(cb, "signal!\n");
+ goto err3;
+ }
+
+ wait_event_interruptible_timeout(cb->sem, cb->state == ERROR, HZ);
+ } while (count != 2);
+err3:
+ DEBUG_LOG(cb, "sleeping 1 second\n");
+ wait_event_interruptible_timeout(cb->sem, cb->state == ERROR, HZ);
+ DEBUG_LOG(cb, "draining the cq...\n");
+ do {
+ ret = ib_poll_cq(cb->cq, 1, &wc);
+ if (ret < 0) {
+ PRINTF(cb, "ib_poll_cq failed %d\n", ret);
+ break;
+ }
+ if (ret == 1) {
+ PRINTF(cb, "completion %u opcode %u\n", wc.status, wc.opcode);
+ }
+ } while (ret == 1);
+ DEBUG_LOG(cb, "destroying fr mr2!\n");
+
+ ib_dereg_mr(mr2);
+err2:
+ DEBUG_LOG(cb, "destroying fr mr1!\n");
+ ib_dereg_mr(mr1);
+err1:
+ DEBUG_LOG(cb, "destroying fr page list!\n");
+ ib_free_fast_reg_page_list(pl);
+ DEBUG_LOG(cb, "%s done!\n", __func__);
+}
+
+/*
+ * fastreg the same mr twice, 2nd one should produce error cqe.
+ */
+static void krping_fr_test2(struct krping_cb *cb)
+{
+ struct ib_fast_reg_page_list *pl;
+ struct ib_send_wr fr, *bad;
+ struct ib_wc wc;
+ struct ib_mr *mr1;
+ int i;
+ int ret;
+ int size = cb->size;
+ int plen = (((size - 1) & PAGE_MASK) + PAGE_SIZE) >> PAGE_SHIFT;
+ int count = 0;
+
+ pl = ib_alloc_fast_reg_page_list(cb->qp->device, plen);
+ if (IS_ERR(pl)) {
+ PRINTF(cb, "ib_alloc_fast_reg_page_list failed %ld\n", PTR_ERR(pl));
+ return;
+ }
+
+ mr1 = ib_alloc_fast_reg_mr(cb->pd, plen);
+ if (IS_ERR(mr1)) {
+ PRINTF(cb, "ib_alloc_fast_reg_mr failed %ld\n", PTR_ERR(pl));
+ goto err1;
+ }
+
+ for (i=0; i<plen; i++)
+ pl->page_list[i] = i * PAGE_SIZE;
+
+ memset(&fr, 0, sizeof fr);
+ fr.opcode = IB_WR_FAST_REG_MR;
+ fr.wr_id = 1;
+ fr.wr.fast_reg.page_shift = PAGE_SHIFT;
+ fr.wr.fast_reg.length = size;
+ fr.wr.fast_reg.page_list = pl;
+ fr.wr.fast_reg.page_list_len = plen;
+ fr.wr.fast_reg.iova_start = 0;
+ fr.wr.fast_reg.access_flags = IB_ACCESS_REMOTE_WRITE | IB_ACCESS_LOCAL_WRITE;
+ fr.send_flags = IB_SEND_SIGNALED;
+ fr.wr.fast_reg.rkey = mr1->rkey;
+ DEBUG_LOG(cb, "%s fr1: stag 0x%x plen %u size %u depth %u\n", __func__, fr.wr.fast_reg.rkey, plen, cb->size, cb->txdepth);
+ ret = ib_post_send(cb->qp, &fr, &bad);
+ if (ret) {
+ PRINTF(cb, "ib_post_send failed %d\n", ret);
+ goto err3;
+ }
+ DEBUG_LOG(cb, "%s fr2: stag 0x%x plen %u size %u depth %u\n", __func__, fr.wr.fast_reg.rkey, plen, cb->size, cb->txdepth);
+ ret = ib_post_send(cb->qp, &fr, &bad);
+ if (ret) {
+ PRINTF(cb, "ib_post_send failed %d\n", ret);
+ goto err3;
+ }
+
+ DEBUG_LOG(cb, "sleeping 1 second\n");
+ wait_event_interruptible_timeout(cb->sem, cb->state == ERROR, HZ);
+ do {
+ ret = ib_poll_cq(cb->cq, 1, &wc);
+ if (ret < 0) {
+ PRINTF(cb, "ib_poll_cq failed %d\n", ret);
+ goto err3;
+ }
+ if (ret == 1) {
+ DEBUG_LOG(cb, "completion status %u wr %s\n",
+ wc.status, wc.wr_id == 1 ? "fr" : "inv");
+ count++;
+ } else if (krping_sigpending()) {
+ PRINTF(cb, "signal!\n");
+ goto err3;
+ }
+ wait_event_interruptible_timeout(cb->sem, cb->state == ERROR, HZ);
+ } while (count != 2);
+err3:
+ DEBUG_LOG(cb, "sleeping 1 second\n");
+ wait_event_interruptible_timeout(cb->sem, cb->state == ERROR, HZ);
+ DEBUG_LOG(cb, "draining the cq...\n");
+ do {
+ ret = ib_poll_cq(cb->cq, 1, &wc);
+ if (ret < 0) {
+ PRINTF(cb, "ib_poll_cq failed %d\n", ret);
+ break;
+ }
+ if (ret == 1) {
+ PRINTF(cb, "completion %u opcode %u\n", wc.status, wc.opcode);
+ }
+ } while (ret == 1);
+ DEBUG_LOG(cb, "destroying fr mr1!\n");
+ ib_dereg_mr(mr1);
+err1:
+ DEBUG_LOG(cb, "destroying fr page list!\n");
+ ib_free_fast_reg_page_list(pl);
+ DEBUG_LOG(cb, "%s done!\n", __func__);
+}
+
+/*
+ * fastreg pipelined in a loop as fast as we can until the user interrupts.
+ * NOTE: every 9 seconds we sleep for 1 second to keep the kernel happy.
+ */
+static void krping_fr_test3(struct krping_cb *cb)
+{
+ struct ib_fast_reg_page_list *pl;
+ struct ib_send_wr fr, inv, *bad;
+ struct ib_wc wc;
+ u8 key = 0;
+ struct ib_mr *mr;
+ int i;
+ int ret;
+ int size = cb->size;
+ int plen = (((size - 1) & PAGE_MASK) + PAGE_SIZE) >> PAGE_SHIFT;
+ unsigned long start;
+ int count = 0;
+ int scnt = 0;
+
+
+ pl = ib_alloc_fast_reg_page_list(cb->qp->device, plen);
+ if (IS_ERR(pl)) {
+ PRINTF(cb, "ib_alloc_fast_reg_page_list failed %ld\n", PTR_ERR(pl));
+ return;
+ }
+
+ mr = ib_alloc_fast_reg_mr(cb->pd, plen);
+ if (IS_ERR(mr)) {
+ PRINTF(cb, "ib_alloc_fast_reg_mr failed %ld\n", PTR_ERR(pl));
+ goto err1;
+ }
+
+ for (i=0; i<plen; i++)
+ pl->page_list[i] = i * PAGE_SIZE;
+
+ memset(&fr, 0, sizeof fr);
+ fr.opcode = IB_WR_FAST_REG_MR;
+ fr.wr.fast_reg.page_shift = PAGE_SHIFT;
+ fr.wr.fast_reg.length = size;
+ fr.wr.fast_reg.page_list = pl;
+ fr.wr.fast_reg.page_list_len = plen;
+ fr.wr.fast_reg.iova_start = 0;
+ fr.send_flags = IB_SEND_SIGNALED;
+ fr.wr.fast_reg.access_flags = IB_ACCESS_REMOTE_WRITE | IB_ACCESS_LOCAL_WRITE;
+ fr.next = &inv;
+ memset(&inv, 0, sizeof inv);
+ inv.opcode = IB_WR_LOCAL_INV;
+ inv.send_flags = IB_SEND_SIGNALED;
+
+ DEBUG_LOG(cb, "fr_test: stag index 0x%x plen %u size %u depth %u\n", mr->rkey >> 8, plen, cb->size, cb->txdepth);
+ start = time_uptime;
+ while (1) {
+ if ((time_uptime - start) >= 9) {
+ DEBUG_LOG(cb, "fr_test: pausing 1 second! count %u latest size %u plen %u\n", count, size, plen);
+ wait_event_interruptible_timeout(cb->sem, cb->state == ERROR, HZ);
+ if (cb->state == ERROR)
+ break;
+ start = time_uptime;
+ }
+ while (scnt < (cb->txdepth>>1)) {
+ ib_update_fast_reg_key(mr, ++key);
+ fr.wr.fast_reg.rkey = mr->rkey;
+ inv.ex.invalidate_rkey = mr->rkey;
+ size = arc4random() % cb->size;
+ if (size == 0)
+ size = cb->size;
+ plen = (((size - 1) & PAGE_MASK) + PAGE_SIZE) >> PAGE_SHIFT;
+ fr.wr.fast_reg.length = size;
+ fr.wr.fast_reg.page_list_len = plen;
+ ret = ib_post_send(cb->qp, &fr, &bad);
+ if (ret) {
+ PRINTF(cb, "ib_post_send failed %d\n", ret);
+ goto err2;
+ }
+ scnt+=2;
+ }
+
+ do {
+ ret = ib_poll_cq(cb->cq, 1, &wc);
+ if (ret < 0) {
+ PRINTF(cb, "ib_poll_cq failed %d\n", ret);
+ goto err2;
+ }
+ if (ret == 1) {
+ if (wc.status) {
+ PRINTF(cb, "completion error %u\n", wc.status);
+ goto err2;
+ }
+ count++;
+ scnt--;
+ }
+ else if (krping_sigpending()) {
+ PRINTF(cb, "signal!\n");
+ goto err2;
+ }
+ } while (ret == 1);
+ }
+err2:
+ DEBUG_LOG(cb, "sleeping 1 second\n");
+ wait_event_interruptible_timeout(cb->sem, cb->state == ERROR, HZ);
+ DEBUG_LOG(cb, "draining the cq...\n");
+ do {
+ ret = ib_poll_cq(cb->cq, 1, &wc);
+ if (ret < 0) {
+ PRINTF(cb, "ib_poll_cq failed %d\n", ret);
+ break;
+ }
+ if (ret == 1) {
+ if (wc.status) {
+ PRINTF(cb, "completion error %u opcode %u\n", wc.status, wc.opcode);
+ }
+ }
+ } while (ret == 1);
+ DEBUG_LOG(cb, "fr_test: done!\n");
+ ib_dereg_mr(mr);
+err1:
+ DEBUG_LOG(cb, "destroying fr page list!\n");
+ ib_free_fast_reg_page_list(pl);
+ DEBUG_LOG(cb, "%s done!\n", __func__);
+}
+
+/*
+ * fastreg 1 and invalidate 1 mr and verify completion.
+ */
+static void krping_fr_test4(struct krping_cb *cb)
+{
+ struct ib_fast_reg_page_list *pl;
+ struct ib_send_wr fr, inv, *bad;
+ struct ib_wc wc;
+ struct ib_mr *mr1;
+ int i;
+ int ret;
+ int size = cb->size;
+ int plen = (((size - 1) & PAGE_MASK) + PAGE_SIZE) >> PAGE_SHIFT;
+ int count = 0;
+
+ pl = ib_alloc_fast_reg_page_list(cb->qp->device, plen);
+ if (IS_ERR(pl)) {
+ PRINTF(cb, "ib_alloc_fast_reg_page_list failed %ld\n", PTR_ERR(pl));
+ return;
+ }
+
+ mr1 = ib_alloc_fast_reg_mr(cb->pd, plen);
+ if (IS_ERR(mr1)) {
+ PRINTF(cb, "ib_alloc_fast_reg_mr failed %ld\n", PTR_ERR(pl));
+ goto err1;
+ }
+
+ for (i=0; i<plen; i++)
+ pl->page_list[i] = i * PAGE_SIZE;
+
+ memset(&fr, 0, sizeof fr);
+ fr.opcode = IB_WR_FAST_REG_MR;
+ fr.wr_id = 1;
+ fr.wr.fast_reg.page_shift = PAGE_SHIFT;
+ fr.wr.fast_reg.length = size;
+ fr.wr.fast_reg.page_list = pl;
+ fr.wr.fast_reg.page_list_len = plen;
+ fr.wr.fast_reg.iova_start = 0;
+ fr.wr.fast_reg.access_flags = IB_ACCESS_REMOTE_WRITE | IB_ACCESS_LOCAL_WRITE;
+ fr.send_flags = IB_SEND_SIGNALED;
+ fr.wr.fast_reg.rkey = mr1->rkey;
+ fr.next = &inv;
+ memset(&inv, 0, sizeof inv);
+ inv.opcode = IB_WR_LOCAL_INV;
+ inv.ex.invalidate_rkey = mr1->rkey;
+
+ DEBUG_LOG(cb, "%s fr1: stag 0x%x plen %u size %u depth %u\n", __func__, fr.wr.fast_reg.rkey, plen, cb->size, cb->txdepth);
+ ret = ib_post_send(cb->qp, &fr, &bad);
+ if (ret) {
+ PRINTF(cb, "ib_post_send failed %d\n", ret);
+ goto err3;
+ }
+ DEBUG_LOG(cb, "sleeping 1 second\n");
+ wait_event_interruptible_timeout(cb->sem, cb->state == ERROR, HZ);
+ do {
+ ret = ib_poll_cq(cb->cq, 1, &wc);
+ if (ret < 0) {
+ PRINTF(cb, "ib_poll_cq failed %d\n", ret);
+ goto err3;
+ }
+ if (ret == 1) {
+ DEBUG_LOG(cb, "completion status %u wr %s\n",
+ wc.status, wc.wr_id == 1 ? "fr" : "inv");
+ count++;
+ } else if (krping_sigpending()) {
+ PRINTF(cb, "signal!\n");
+ goto err3;
+ }
+ wait_event_interruptible_timeout(cb->sem, cb->state == ERROR, HZ);
+ } while (count != 1);
+err3:
+ DEBUG_LOG(cb, "sleeping 1 second\n");
+ wait_event_interruptible_timeout(cb->sem, cb->state == ERROR, HZ);
+ DEBUG_LOG(cb, "draining the cq...\n");
+ do {
+ ret = ib_poll_cq(cb->cq, 1, &wc);
+ if (ret < 0) {
+ PRINTF(cb, "ib_poll_cq failed %d\n", ret);
+ break;
+ }
+ if (ret == 1) {
+ PRINTF(cb, "completion %u opcode %u\n", wc.status, wc.opcode);
+ }
+ } while (ret == 1);
+ DEBUG_LOG(cb, "destroying fr mr1!\n");
+ ib_dereg_mr(mr1);
+err1:
+ DEBUG_LOG(cb, "destroying fr page list!\n");
+ ib_free_fast_reg_page_list(pl);
+ DEBUG_LOG(cb, "%s done!\n", __func__);
+}
+
+static void krping_fr_test(struct krping_cb *cb)
+{
+ switch (cb->testnum) {
+ case 1:
+ krping_fr_test1(cb);
+ break;
+ case 2:
+ krping_fr_test2(cb);
+ break;
+ case 3:
+ krping_fr_test3(cb);
+ break;
+ case 4:
+ krping_fr_test4(cb);
+ break;
+ case 5:
+ krping_fr_test5_client(cb);
+ break;
+ case 6:
+ krping_fr_test6_client(cb);
+ break;
+ default:
+ PRINTF(cb, "Unkown frtest num %u\n", cb->testnum);
+ break;
+ }
+}
+
+static int krping_connect_client(struct krping_cb *cb)
+{
+ struct rdma_conn_param conn_param;
+ int ret;
+
+ memset(&conn_param, 0, sizeof conn_param);
+ conn_param.responder_resources = 1;
+ conn_param.initiator_depth = 1;
+ conn_param.retry_count = 10;
+
+ ret = rdma_connect(cb->cm_id, &conn_param);
+ if (ret) {
+ PRINTF(cb, "rdma_connect error %d\n", ret);
+ return ret;
+ }
+
+ wait_event_interruptible(cb->sem, cb->state >= CONNECTED);
+ if (cb->state == ERROR) {
+ PRINTF(cb, "wait for CONNECTED state %d\n", cb->state);
+ return -1;
+ }
+
+ DEBUG_LOG(cb, "rdma_connect successful\n");
+ return 0;
+}
+
+static int krping_bind_client(struct krping_cb *cb)
+{
+ union {
+ struct sockaddr_in v4;
+ struct sockaddr_in6 v6;
+ } sin;
+ int ret;
+
+ memset(&sin, 0, sizeof(sin));
+
+ switch (cb->addr_type) {
+ case AF_INET:
+ sin.v4.sin_len = sizeof sin.v4;
+ sin.v4.sin_family = AF_INET;
+ sin.v4.sin_addr = cb->addr.v4;
+ sin.v4.sin_port = cb->port;
+ break;
+ case AF_INET6:
+ sin.v6.sin6_len = sizeof sin.v6;
+ sin.v6.sin6_family = AF_INET6;
+ sin.v6.sin6_addr = cb->addr.v6;
+ sin.v6.sin6_port = cb->port;
+ break;
+ default:
+ return (-EINVAL);
+ }
+
+ ret = rdma_resolve_addr(cb->cm_id, NULL, (struct sockaddr *) &sin,
+ 2000);
+ if (ret) {
+ PRINTF(cb, "rdma_resolve_addr error %d\n", ret);
+ return ret;
+ }
+
+ wait_event_interruptible(cb->sem, cb->state >= ROUTE_RESOLVED);
+ if (cb->state != ROUTE_RESOLVED) {
+ PRINTF(cb,
+ "addr/route resolution did not resolve: state %d\n",
+ cb->state);
+ return -EINTR;
+ }
+
+ if (cb->mem == FASTREG && !fastreg_supported(cb, 0))
+ return -EINVAL;
+
+ DEBUG_LOG(cb, "rdma_resolve_addr - rdma_resolve_route successful\n");
+ return 0;
+}
+
+static void krping_run_client(struct krping_cb *cb)
+{
+ struct ib_recv_wr *bad_wr;
+ int ret;
+
+ ret = krping_bind_client(cb);
+ if (ret)
+ return;
+
+ ret = krping_setup_qp(cb, cb->cm_id);
+ if (ret) {
+ PRINTF(cb, "setup_qp failed: %d\n", ret);
+ return;
+ }
+
+ ret = krping_setup_buffers(cb);
+ if (ret) {
+ PRINTF(cb, "krping_setup_buffers failed: %d\n", ret);
+ goto err1;
+ }
+
+ ret = ib_post_recv(cb->qp, &cb->rq_wr, &bad_wr);
+ if (ret) {
+ PRINTF(cb, "ib_post_recv failed: %d\n", ret);
+ goto err2;
+ }
+
+ ret = krping_connect_client(cb);
+ if (ret) {
+ PRINTF(cb, "connect error %d\n", ret);
+ goto err2;
+ }
+
+ if (cb->wlat)
+ krping_wlat_test_client(cb);
+ else if (cb->rlat)
+ krping_rlat_test_client(cb);
+ else if (cb->bw)
+ krping_bw_test_client(cb);
+ else if (cb->frtest)
+ krping_fr_test(cb);
+ else
+ krping_test_client(cb);
+ rdma_disconnect(cb->cm_id);
+err2:
+ krping_free_buffers(cb);
+err1:
+ krping_free_qp(cb);
+}
+
+static uint16_t
+krping_get_ipv6_scope_id(char *name)
+{
+ struct ifnet *ifp;
+ uint16_t retval;
+
+ if (name == NULL)
+ return (0);
+ CURVNET_SET_QUIET(TD_TO_VNET(curthread));
+ ifp = ifunit_ref(name);
+ CURVNET_RESTORE();
+ if (ifp == NULL)
+ return (0);
+ retval = ifp->if_index;
+ if_rele(ifp);
+ return (retval);
+}
+
+int krping_doit(char *cmd, void *cookie)
+{
+ struct krping_cb *cb;
+ int op;
+ int ret = 0;
+ char *optarg;
+ char *scope;
+ unsigned long optint;
+
+ cb = kzalloc(sizeof(*cb), GFP_KERNEL);
+ if (!cb)
+ return -ENOMEM;
+
+ mutex_lock(&krping_mutex);
+ list_add_tail(&cb->list, &krping_cbs);
+ mutex_unlock(&krping_mutex);
+
+ cb->cookie = cookie;
+ cb->server = -1;
+ cb->state = IDLE;
+ cb->size = 64;
+ cb->txdepth = RPING_SQ_DEPTH;
+ cb->mem = DMA;
+ cb->addr_type = AF_INET;
+ init_waitqueue_head(&cb->sem);
+
+ while ((op = krping_getopt("krping", &cmd, krping_opts, NULL, &optarg,
+ &optint)) != 0) {
+ switch (op) {
+ case 'a':
+ cb->addr_str = optarg;
+ cb->addr_type = AF_INET;
+ DEBUG_LOG(cb, "ipv4addr (%s)\n", optarg);
+ if (inet_pton(AF_INET, optarg, &cb->addr) != 1) {
+ PRINTF(cb, "bad addr string %s\n",
+ optarg);
+ ret = EINVAL;
+ }
+ break;
+ case 'A':
+ cb->addr_str = optarg;
+ cb->addr_type = AF_INET6;
+ DEBUG_LOG(cb, "ipv6addr (%s)\n", optarg);
+ scope = strstr(optarg, "%");
+ /* extract scope ID, if any */
+ if (scope != NULL)
+ *scope++ = 0;
+ /* extract IPv6 network address */
+ if (inet_pton(AF_INET6, optarg, &cb->addr) != 1) {
+ PRINTF(cb, "bad addr string %s\n",
+ optarg);
+ ret = EINVAL;
+ } else if (IN6_IS_SCOPE_LINKLOCAL(&cb->addr.v6) ||
+ IN6_IS_ADDR_MC_INTFACELOCAL(&cb->addr.v6)) {
+ uint16_t scope_id = krping_get_ipv6_scope_id(scope);
+ DEBUG_LOG(cb, "ipv6 scope ID = %d\n", scope_id);
+ cb->addr.v6.s6_addr[2] = scope_id >> 8;
+ cb->addr.v6.s6_addr[3] = scope_id & 0xFF;
+ }
+ break;
+ case 'p':
+ cb->port = htons(optint);
+ DEBUG_LOG(cb, "port %d\n", (int)optint);
+ break;
+ case 'P':
+ cb->poll = 1;
+ DEBUG_LOG(cb, "server\n");
+ break;
+ case 's':
+ cb->server = 1;
+ DEBUG_LOG(cb, "server\n");
+ break;
+ case 'c':
+ cb->server = 0;
+ DEBUG_LOG(cb, "client\n");
+ break;
+ case 'S':
+ cb->size = optint;
+ if ((cb->size < 1) ||
+ (cb->size > RPING_BUFSIZE)) {
+ PRINTF(cb, "Invalid size %d "
+ "(valid range is 1 to %d)\n",
+ cb->size, RPING_BUFSIZE);
+ ret = EINVAL;
+ } else
+ DEBUG_LOG(cb, "size %d\n", (int)optint);
+ break;
+ case 'C':
+ cb->count = optint;
+ if (cb->count < 0) {
+ PRINTF(cb, "Invalid count %d\n",
+ cb->count);
+ ret = EINVAL;
+ } else
+ DEBUG_LOG(cb, "count %d\n", (int) cb->count);
+ break;
+ case 'v':
+ cb->verbose++;
+ DEBUG_LOG(cb, "verbose\n");
+ break;
+ case 'V':
+ cb->validate++;
+ DEBUG_LOG(cb, "validate data\n");
+ break;
+ case 'l':
+ cb->wlat++;
+ break;
+ case 'L':
+ cb->rlat++;
+ break;
+ case 'B':
+ cb->bw++;
+ break;
+ case 'd':
+ cb->duplex++;
+ break;
+ case 'm':
+ if (!strncmp(optarg, "dma", 3))
+ cb->mem = DMA;
+ else if (!strncmp(optarg, "fastreg", 7))
+ cb->mem = FASTREG;
+ else if (!strncmp(optarg, "mw", 2))
+ cb->mem = MW;
+ else if (!strncmp(optarg, "mr", 2))
+ cb->mem = MR;
+ else {
+ PRINTF(cb, "unknown mem mode %s. "
+ "Must be dma, fastreg, mw, or mr\n",
+ optarg);
+ ret = -EINVAL;
+ break;
+ }
+ break;
+ case 'I':
+ cb->server_invalidate = 1;
+ break;
+ case 'T':
+ cb->txdepth = optint;
+ DEBUG_LOG(cb, "txdepth %d\n", (int) cb->txdepth);
+ break;
+ case 'Z':
+ cb->local_dma_lkey = 1;
+ DEBUG_LOG(cb, "using local dma lkey\n");
+ break;
+ case 'R':
+ cb->read_inv = 1;
+ DEBUG_LOG(cb, "using read-with-inv\n");
+ break;
+ case 'f':
+ cb->frtest = 1;
+ cb->testnum = optint;
+ DEBUG_LOG(cb, "fast-reg test!\n");
+ break;
+ default:
+ PRINTF(cb, "unknown opt %s\n", optarg);
+ ret = -EINVAL;
+ break;
+ }
+ }
+ if (ret)
+ goto out;
+
+ if (cb->server == -1) {
+ PRINTF(cb, "must be either client or server\n");
+ ret = -EINVAL;
+ goto out;
+ }
+
+ if ((cb->frtest + cb->bw + cb->rlat + cb->wlat) > 1) {
+ PRINTF(cb, "Pick only one test: fr, bw, rlat, wlat\n");
+ ret = -EINVAL;
+ goto out;
+ }
+ if (cb->server_invalidate && cb->mem != FASTREG) {
+ PRINTF(cb, "server_invalidate only valid with fastreg mem_mode\n");
+ ret = -EINVAL;
+ goto out;
+ }
+
+ if (cb->read_inv && cb->mem != FASTREG) {
+ PRINTF(cb, "read_inv only valid with fastreg mem_mode\n");
+ ret = -EINVAL;
+ goto out;
+ }
+
+ if (cb->mem != MR && (cb->wlat || cb->rlat || cb->bw || cb->frtest)) {
+ PRINTF(cb, "wlat, rlat, and bw tests only support mem_mode MR\n");
+ ret = -EINVAL;
+ goto out;
+ }
+
+ cb->cm_id = rdma_create_id(krping_cma_event_handler, cb, RDMA_PS_TCP, IB_QPT_RC);
+ if (IS_ERR(cb->cm_id)) {
+ ret = PTR_ERR(cb->cm_id);
+ PRINTF(cb, "rdma_create_id error %d\n", ret);
+ goto out;
+ }
+ DEBUG_LOG(cb, "created cm_id %p\n", cb->cm_id);
+
+ if (cb->server)
+ krping_run_server(cb);
+ else
+ krping_run_client(cb);
+
+ DEBUG_LOG(cb, "destroy cm_id %p\n", cb->cm_id);
+ rdma_destroy_id(cb->cm_id);
+out:
+ mutex_lock(&krping_mutex);
+ list_del(&cb->list);
+ mutex_unlock(&krping_mutex);
+ kfree(cb);
+ return ret;
+}
+
+void
+krping_walk_cb_list(void (*f)(struct krping_stats *, void *), void *arg)
+{
+ struct krping_cb *cb;
+
+ mutex_lock(&krping_mutex);
+ list_for_each_entry(cb, &krping_cbs, list)
+ (*f)(cb->pd ? &cb->stats : NULL, arg);
+ mutex_unlock(&krping_mutex);
+}
+
+void krping_init(void)
+{
+
+ mutex_init(&krping_mutex);
+}
diff --git a/sys/contrib/rdma/krping_compat/krping.h b/sys/contrib/rdma/krping_compat/krping.h
new file mode 100644
index 0000000..f201d10
--- /dev/null
+++ b/sys/contrib/rdma/krping_compat/krping.h
@@ -0,0 +1,20 @@
+/*
+ * $FreeBSD$
+ */
+
+struct krping_stats {
+ unsigned long long send_bytes;
+ unsigned long long send_msgs;
+ unsigned long long recv_bytes;
+ unsigned long long recv_msgs;
+ unsigned long long write_bytes;
+ unsigned long long write_msgs;
+ unsigned long long read_bytes;
+ unsigned long long read_msgs;
+ char name[16];
+};
+
+int krping_doit(char *, void *);
+void krping_walk_cb_list(void (*)(struct krping_stats *, void *), void *);
+void krping_init(void);
+int krping_sigpending(void);
diff --git a/sys/contrib/rdma/krping_compat/krping_dev.c b/sys/contrib/rdma/krping_compat/krping_dev.c
new file mode 100644
index 0000000..7902ebf
--- /dev/null
+++ b/sys/contrib/rdma/krping_compat/krping_dev.c
@@ -0,0 +1,220 @@
+/*
+ * This code lifted from:
+ * Simple `echo' pseudo-device KLD
+ * Murray Stokely
+ * Converted to 5.X by Søren (Xride) Straarup
+ */
+
+/*
+ * /bin/echo "server,port=9999,addr=192.168.69.142,validate" > /dev/krping
+ * /bin/echo "client,port=9999,addr=192.168.69.142,validate" > /dev/krping
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include <sys/types.h>
+#include <sys/module.h>
+#include <sys/systm.h> /* uprintf */
+#include <sys/errno.h>
+#include <sys/param.h> /* defines used in kernel.h */
+#include <sys/kernel.h> /* types used in module initialization */
+#include <sys/conf.h> /* cdevsw struct */
+#include <sys/uio.h> /* uio struct */
+#include <sys/malloc.h>
+#include <sys/proc.h>
+#include <sys/sysctl.h>
+#include <machine/stdarg.h>
+
+#include "krping.h"
+
+#define BUFFERSIZE 512
+
+SYSCTL_NODE(_dev, OID_AUTO, krping, CTLFLAG_RW, 0, "kernel rping module");
+
+int krping_debug = 0;
+SYSCTL_INT(_dev_krping, OID_AUTO, debug, CTLFLAG_RW, &krping_debug, 0 , "");
+
+/* Function prototypes */
+static d_open_t krping_open;
+static d_close_t krping_close;
+static d_read_t krping_read;
+static d_write_t krping_write;
+
+/* Character device entry points */
+static struct cdevsw krping_cdevsw = {
+ .d_version = D_VERSION,
+ .d_open = krping_open,
+ .d_close = krping_close,
+ .d_read = krping_read,
+ .d_write = krping_write,
+ .d_name = "krping",
+};
+
+typedef struct s_krping {
+ char msg[BUFFERSIZE];
+ int len;
+} krping_t;
+
+struct stats_list_entry {
+ STAILQ_ENTRY(stats_list_entry) link;
+ struct krping_stats *stats;
+};
+STAILQ_HEAD(stats_list, stats_list_entry);
+
+/* vars */
+static struct cdev *krping_dev;
+
+static int
+krping_loader(struct module *m, int what, void *arg)
+{
+ int err = 0;
+
+ switch (what) {
+ case MOD_LOAD: /* kldload */
+ krping_init();
+ krping_dev = make_dev(&krping_cdevsw, 0, UID_ROOT, GID_WHEEL,
+ 0600, "krping");
+ printf("Krping device loaded.\n");
+ break;
+ case MOD_UNLOAD:
+ destroy_dev(krping_dev);
+ printf("Krping device unloaded.\n");
+ break;
+ default:
+ err = EOPNOTSUPP;
+ break;
+ }
+
+ return (err);
+}
+
+static int
+krping_open(struct cdev *dev, int oflags, int devtype, struct thread *p)
+{
+
+ return (0);
+}
+
+static int
+krping_close(struct cdev *dev, int fflag, int devtype, struct thread *p)
+{
+
+ return 0;
+}
+
+static void
+krping_copy_stats(struct krping_stats *stats, void *arg)
+{
+ struct stats_list_entry *s;
+ struct stats_list *list = arg;
+
+ s = malloc(sizeof(*s), M_DEVBUF, M_NOWAIT | M_ZERO);
+ if (s == NULL)
+ return;
+ if (stats != NULL) {
+ s->stats = malloc(sizeof(*stats), M_DEVBUF, M_NOWAIT | M_ZERO);
+ if (s->stats == NULL) {
+ free(s, M_DEVBUF);
+ return;
+ }
+ *s->stats = *stats;
+ }
+ STAILQ_INSERT_TAIL(list, s, link);
+}
+
+static int
+krping_read(struct cdev *dev, struct uio *uio, int ioflag)
+{
+ int num = 1;
+ struct stats_list list;
+ struct stats_list_entry *e;
+
+ STAILQ_INIT(&list);
+ krping_walk_cb_list(krping_copy_stats, &list);
+
+ if (STAILQ_EMPTY(&list))
+ return (0);
+
+ uprintf("krping: %4s %10s %10s %10s %10s %10s %10s %10s %10s %10s\n",
+ "num", "device", "snd bytes", "snd msgs", "rcv bytes", "rcv msgs",
+ "wr bytes", "wr msgs", "rd bytes", "rd msgs");
+
+ while (!STAILQ_EMPTY(&list)) {
+ e = STAILQ_FIRST(&list);
+ STAILQ_REMOVE_HEAD(&list, link);
+ if (e->stats == NULL)
+ uprintf("krping: %d listen\n", num);
+ else {
+ struct krping_stats *stats = e->stats;
+
+ uprintf("krping: %4d %10s %10llu %10llu %10llu %10llu "
+ "%10llu %10llu %10llu %10llu\n", num, stats->name,
+ stats->send_bytes, stats->send_msgs,
+ stats->recv_bytes, stats->recv_msgs,
+ stats->write_bytes, stats->write_msgs,
+ stats->read_bytes, stats->read_msgs);
+ free(stats, M_DEVBUF);
+ }
+ num++;
+ free(e, M_DEVBUF);
+ }
+
+ return (0);
+}
+
+static int
+krping_write(struct cdev *dev, struct uio *uio, int ioflag)
+{
+ int err = 0;
+ int amt;
+ int remain = BUFFERSIZE;
+ char *cp;
+ krping_t *krpingmsg;
+
+ krpingmsg = malloc(sizeof *krpingmsg, M_DEVBUF, M_WAITOK|M_ZERO);
+ if (!krpingmsg) {
+ uprintf("Could not malloc mem!\n");
+ return ENOMEM;
+ }
+
+ cp = krpingmsg->msg;
+ while (uio->uio_resid) {
+ amt = MIN(uio->uio_resid, remain);
+ if (amt == 0)
+ break;
+
+ /* Copy the string in from user memory to kernel memory */
+ err = uiomove(cp, amt, uio);
+ if (err) {
+ uprintf("Write failed: bad address!\n");
+ return err;
+ }
+ cp += amt;
+ remain -= amt;
+ }
+
+ if (uio->uio_resid != 0) {
+ uprintf("Message too big. max size is %d!\n", BUFFERSIZE);
+ return EMSGSIZE;
+ }
+
+ /* null terminate and remove the \n */
+ cp--;
+ *cp = 0;
+ krpingmsg->len = (unsigned long)(cp - krpingmsg->msg);
+ uprintf("krping: write string = |%s|\n", krpingmsg->msg);
+ err = krping_doit(krpingmsg->msg, curproc);
+ free(krpingmsg, M_DEVBUF);
+ return(err);
+}
+
+int
+krping_sigpending(void)
+{
+
+ return (SIGPENDING(curthread));
+}
+
+DEV_MODULE(krping, krping_loader, NULL);
+MODULE_DEPEND(krping, ibcore, 1, 1, 1);
diff --git a/sys/dev/cxgbe/adapter.h b/sys/dev/cxgbe/adapter.h
index 27b3ad9..8ff5d22 100644
--- a/sys/dev/cxgbe/adapter.h
+++ b/sys/dev/cxgbe/adapter.h
@@ -797,6 +797,7 @@ struct adapter {
void *tom_softc; /* (struct tom_data *) */
struct tom_tunables tt;
+ struct iw_tunables iwt;
void *iwarp_softc; /* (struct c4iw_dev *) */
void *iscsi_ulp_softc; /* (struct cxgbei_data *) */
struct l2t_data *l2t; /* L2 table */
diff --git a/sys/dev/cxgbe/common/common.h b/sys/dev/cxgbe/common/common.h
index 902f81c..ed1cff2 100644
--- a/sys/dev/cxgbe/common/common.h
+++ b/sys/dev/cxgbe/common/common.h
@@ -69,6 +69,8 @@ enum {
FEC_RESERVED = 1 << 2,
};
+enum t4_bar2_qtype { T4_BAR2_QTYPE_EGRESS, T4_BAR2_QTYPE_INGRESS };
+
struct port_stats {
u64 tx_octets; /* total # of octets in good frames */
u64 tx_frames; /* all good frames */
@@ -374,6 +376,9 @@ struct adapter_params {
unsigned int max_ird_adapter;
uint32_t mps_bg_map; /* rx buffer group map for all ports (upto 4) */
+
+ bool ulptx_memwrite_dsgl; /* use of T5 DSGL allowed */
+ bool fr_nsmr_tpte_wr_support; /* FW support for FR_NSMR_TPTE_WR */
};
#define CHELSIO_T4 0x4
@@ -846,5 +851,8 @@ int t4vf_get_sge_params(struct adapter *adapter);
int t4vf_get_rss_glb_config(struct adapter *adapter);
int t4vf_get_vfres(struct adapter *adapter);
int t4vf_prep_adapter(struct adapter *adapter);
+int t4_bar2_sge_qregs(struct adapter *adapter, unsigned int qid,
+ enum t4_bar2_qtype qtype, int user, u64 *pbar2_qoffset,
+ unsigned int *pbar2_qid);
#endif /* __CHELSIO_COMMON_H */
diff --git a/sys/dev/cxgbe/common/t4_hw.c b/sys/dev/cxgbe/common/t4_hw.c
index ea19676..938519a 100644
--- a/sys/dev/cxgbe/common/t4_hw.c
+++ b/sys/dev/cxgbe/common/t4_hw.c
@@ -8112,6 +8112,98 @@ int t4_shutdown_adapter(struct adapter *adapter)
}
/**
+ * t4_bar2_sge_qregs - return BAR2 SGE Queue register information
+ * @adapter: the adapter
+ * @qid: the Queue ID
+ * @qtype: the Ingress or Egress type for @qid
+ * @user: true if this request is for a user mode queue
+ * @pbar2_qoffset: BAR2 Queue Offset
+ * @pbar2_qid: BAR2 Queue ID or 0 for Queue ID inferred SGE Queues
+ *
+ * Returns the BAR2 SGE Queue Registers information associated with the
+ * indicated Absolute Queue ID. These are passed back in return value
+ * pointers. @qtype should be T4_BAR2_QTYPE_EGRESS for Egress Queue
+ * and T4_BAR2_QTYPE_INGRESS for Ingress Queues.
+ *
+ * This may return an error which indicates that BAR2 SGE Queue
+ * registers aren't available. If an error is not returned, then the
+ * following values are returned:
+ *
+ * *@pbar2_qoffset: the BAR2 Offset of the @qid Registers
+ * *@pbar2_qid: the BAR2 SGE Queue ID or 0 of @qid
+ *
+ * If the returned BAR2 Queue ID is 0, then BAR2 SGE registers which
+ * require the "Inferred Queue ID" ability may be used. E.g. the
+ * Write Combining Doorbell Buffer. If the BAR2 Queue ID is not 0,
+ * then these "Inferred Queue ID" register may not be used.
+ */
+int t4_bar2_sge_qregs(struct adapter *adapter,
+ unsigned int qid,
+ enum t4_bar2_qtype qtype,
+ int user,
+ u64 *pbar2_qoffset,
+ unsigned int *pbar2_qid)
+{
+ unsigned int page_shift, page_size, qpp_shift, qpp_mask;
+ u64 bar2_page_offset, bar2_qoffset;
+ unsigned int bar2_qid, bar2_qid_offset, bar2_qinferred;
+
+ /* T4 doesn't support BAR2 SGE Queue registers for kernel
+ * mode queues.
+ */
+ if (!user && is_t4(adapter))
+ return -EINVAL;
+
+ /* Get our SGE Page Size parameters.
+ */
+ page_shift = adapter->params.sge.page_shift;
+ page_size = 1 << page_shift;
+
+ /* Get the right Queues per Page parameters for our Queue.
+ */
+ qpp_shift = (qtype == T4_BAR2_QTYPE_EGRESS
+ ? adapter->params.sge.eq_s_qpp
+ : adapter->params.sge.iq_s_qpp);
+ qpp_mask = (1 << qpp_shift) - 1;
+
+ /* Calculate the basics of the BAR2 SGE Queue register area:
+ * o The BAR2 page the Queue registers will be in.
+ * o The BAR2 Queue ID.
+ * o The BAR2 Queue ID Offset into the BAR2 page.
+ */
+ bar2_page_offset = ((u64)(qid >> qpp_shift) << page_shift);
+ bar2_qid = qid & qpp_mask;
+ bar2_qid_offset = bar2_qid * SGE_UDB_SIZE;
+
+ /* If the BAR2 Queue ID Offset is less than the Page Size, then the
+ * hardware will infer the Absolute Queue ID simply from the writes to
+ * the BAR2 Queue ID Offset within the BAR2 Page (and we need to use a
+ * BAR2 Queue ID of 0 for those writes). Otherwise, we'll simply
+ * write to the first BAR2 SGE Queue Area within the BAR2 Page with
+ * the BAR2 Queue ID and the hardware will infer the Absolute Queue ID
+ * from the BAR2 Page and BAR2 Queue ID.
+ *
+ * One important censequence of this is that some BAR2 SGE registers
+ * have a "Queue ID" field and we can write the BAR2 SGE Queue ID
+ * there. But other registers synthesize the SGE Queue ID purely
+ * from the writes to the registers -- the Write Combined Doorbell
+ * Buffer is a good example. These BAR2 SGE Registers are only
+ * available for those BAR2 SGE Register areas where the SGE Absolute
+ * Queue ID can be inferred from simple writes.
+ */
+ bar2_qoffset = bar2_page_offset;
+ bar2_qinferred = (bar2_qid_offset < page_size);
+ if (bar2_qinferred) {
+ bar2_qoffset += bar2_qid_offset;
+ bar2_qid = 0;
+ }
+
+ *pbar2_qoffset = bar2_qoffset;
+ *pbar2_qid = bar2_qid;
+ return 0;
+}
+
+/**
* t4_init_devlog_params - initialize adapter->params.devlog
* @adap: the adapter
* @fw_attach: whether we can talk to the firmware
diff --git a/sys/dev/cxgbe/iw_cxgbe/cm.c b/sys/dev/cxgbe/iw_cxgbe/cm.c
index 2d94dc3..f943f9c 100644
--- a/sys/dev/cxgbe/iw_cxgbe/cm.c
+++ b/sys/dev/cxgbe/iw_cxgbe/cm.c
@@ -46,8 +46,11 @@ __FBSDID("$FreeBSD$");
#include <netinet/in_systm.h>
#include <netinet/in_pcb.h>
+#include <netinet6/in6_pcb.h>
#include <netinet/ip.h>
#include <netinet/in_fib.h>
+#include <netinet6/in6_fib.h>
+#include <netinet6/scope6_var.h>
#include <netinet/ip_var.h>
#include <netinet/tcp_var.h>
#include <netinet/tcp.h>
@@ -78,6 +81,8 @@ static struct work_struct c4iw_task;
static struct workqueue_struct *c4iw_taskq;
static LIST_HEAD(err_cqe_list);
static spinlock_t err_cqe_lock;
+static LIST_HEAD(listen_port_list);
+static DEFINE_MUTEX(listen_port_mutex);
static void process_req(struct work_struct *ctx);
static void start_ep_timer(struct c4iw_ep *ep);
@@ -85,12 +90,7 @@ static int stop_ep_timer(struct c4iw_ep *ep);
static int set_tcpinfo(struct c4iw_ep *ep);
static void process_timeout(struct c4iw_ep *ep);
static void process_err_cqes(void);
-static enum c4iw_ep_state state_read(struct c4iw_ep_common *epc);
-static void __state_set(struct c4iw_ep_common *epc, enum c4iw_ep_state tostate);
-static void state_set(struct c4iw_ep_common *epc, enum c4iw_ep_state tostate);
static void *alloc_ep(int size, gfp_t flags);
-static int find_route(__be32 local_ip, __be32 peer_ip, __be16 local_port,
- __be16 peer_port, u8 tos, struct nhop4_extended *pnh4);
static void close_socket(struct socket *so);
static int send_mpa_req(struct c4iw_ep *ep);
static int send_mpa_reject(struct c4iw_ep *ep, const void *pdata, u8 plen);
@@ -108,6 +108,7 @@ static void process_peer_close(struct c4iw_ep *ep);
static void process_conn_error(struct c4iw_ep *ep);
static void process_close_complete(struct c4iw_ep *ep);
static void ep_timeout(unsigned long arg);
+static void setiwsockopt(struct socket *so);
static void init_iwarp_socket(struct socket *so, void *arg);
static void uninit_iwarp_socket(struct socket *so);
static void process_data(struct c4iw_ep *ep);
@@ -119,6 +120,15 @@ static int process_terminate(struct c4iw_ep *ep);
static int terminate(struct sge_iq *iq, const struct rss_header *rss,
struct mbuf *m);
static int add_ep_to_req_list(struct c4iw_ep *ep, int ep_events);
+static struct listen_port_info *
+add_ep_to_listenlist(struct c4iw_listen_ep *lep);
+static int rem_ep_from_listenlist(struct c4iw_listen_ep *lep);
+static struct c4iw_listen_ep *
+find_real_listen_ep(struct c4iw_listen_ep *master_lep, struct socket *so);
+static int get_ifnet_from_raddr(struct sockaddr_storage *raddr,
+ struct ifnet **ifp);
+static void process_newconn(struct c4iw_listen_ep *master_lep,
+ struct socket *new_so);
#define START_EP_TIMER(ep) \
do { \
CTR3(KTR_IW_CXGBE, "start_ep_timer (%s:%d) ep %p", \
@@ -133,6 +143,34 @@ static int add_ep_to_req_list(struct c4iw_ep *ep, int ep_events);
stop_ep_timer(ep); \
})
+#define GET_LOCAL_ADDR(pladdr, so) \
+ do { \
+ struct sockaddr_storage *__a = NULL; \
+ struct inpcb *__inp = sotoinpcb(so); \
+ KASSERT(__inp != NULL, \
+ ("GET_LOCAL_ADDR(%s):so:%p, inp = NULL", __func__, so)); \
+ if (__inp->inp_vflag & INP_IPV4) \
+ in_getsockaddr(so, (struct sockaddr **)&__a); \
+ else \
+ in6_getsockaddr(so, (struct sockaddr **)&__a); \
+ *(pladdr) = *__a; \
+ free(__a, M_SONAME); \
+ } while (0)
+
+#define GET_REMOTE_ADDR(praddr, so) \
+ do { \
+ struct sockaddr_storage *__a = NULL; \
+ struct inpcb *__inp = sotoinpcb(so); \
+ KASSERT(__inp != NULL, \
+ ("GET_REMOTE_ADDR(%s):so:%p, inp = NULL", __func__, so)); \
+ if (__inp->inp_vflag & INP_IPV4) \
+ in_getpeeraddr(so, (struct sockaddr **)&__a); \
+ else \
+ in6_getpeeraddr(so, (struct sockaddr **)&__a); \
+ *(praddr) = *__a; \
+ free(__a, M_SONAME); \
+ } while (0)
+
#ifdef KTR
static char *states[] = {
"idle",
@@ -151,7 +189,6 @@ static char *states[] = {
};
#endif
-
static void deref_cm_id(struct c4iw_ep_common *epc)
{
epc->cm_id->rem_ref(epc->cm_id);
@@ -178,13 +215,184 @@ static void ref_qp(struct c4iw_ep *ep)
set_bit(QP_REFED, &ep->com.history);
c4iw_qp_add_ref(&ep->com.qp->ibqp);
}
+/* allocated per TCP port while listening */
+struct listen_port_info {
+ uint16_t port_num; /* TCP port address */
+ struct list_head list; /* belongs to listen_port_list */
+ struct list_head lep_list; /* per port lep list */
+ uint32_t refcnt; /* number of lep's listening */
+};
+
+/*
+ * Following two lists are used to manage INADDR_ANY listeners:
+ * 1)listen_port_list
+ * 2)lep_list
+ *
+ * Below is the INADDR_ANY listener lists overview on a system with a two port
+ * adapter:
+ * |------------------|
+ * |listen_port_list |
+ * |------------------|
+ * |
+ * | |-----------| |-----------|
+ * | | port_num:X| | port_num:X|
+ * |--------------|-list------|-------|-list------|-------....
+ * | lep_list----| | lep_list----|
+ * | refcnt | | | refcnt | |
+ * | | | | | |
+ * | | | | | |
+ * |-----------| | |-----------| |
+ * | |
+ * | |
+ * | |
+ * | | lep1 lep2
+ * | | |----------------| |----------------|
+ * | |----| listen_ep_list |----| listen_ep_list |
+ * | |----------------| |----------------|
+ * |
+ * |
+ * | lep1 lep2
+ * | |----------------| |----------------|
+ * |---| listen_ep_list |----| listen_ep_list |
+ * |----------------| |----------------|
+ *
+ * Because of two port adapter, the number of lep's are two(lep1 & lep2) for
+ * each TCP port number.
+ *
+ * Here 'lep1' is always marked as Master lep, because solisten() is always
+ * called through first lep.
+ *
+ */
+static struct listen_port_info *
+add_ep_to_listenlist(struct c4iw_listen_ep *lep)
+{
+ uint16_t port;
+ struct listen_port_info *port_info = NULL;
+ struct sockaddr_storage *laddr = &lep->com.local_addr;
+
+ port = (laddr->ss_family == AF_INET) ?
+ ((struct sockaddr_in *)laddr)->sin_port :
+ ((struct sockaddr_in6 *)laddr)->sin6_port;
+
+ mutex_lock(&listen_port_mutex);
+
+ list_for_each_entry(port_info, &listen_port_list, list)
+ if (port_info->port_num == port)
+ goto found_port;
+
+ port_info = malloc(sizeof(*port_info), M_CXGBE, M_WAITOK);
+ port_info->port_num = port;
+ port_info->refcnt = 0;
+
+ list_add_tail(&port_info->list, &listen_port_list);
+ INIT_LIST_HEAD(&port_info->lep_list);
+
+found_port:
+ port_info->refcnt++;
+ list_add_tail(&lep->listen_ep_list, &port_info->lep_list);
+ mutex_unlock(&listen_port_mutex);
+ return port_info;
+}
+
+static int
+rem_ep_from_listenlist(struct c4iw_listen_ep *lep)
+{
+ uint16_t port;
+ struct listen_port_info *port_info = NULL;
+ struct sockaddr_storage *laddr = &lep->com.local_addr;
+ int refcnt = 0;
+
+ port = (laddr->ss_family == AF_INET) ?
+ ((struct sockaddr_in *)laddr)->sin_port :
+ ((struct sockaddr_in6 *)laddr)->sin6_port;
+
+ mutex_lock(&listen_port_mutex);
+
+ /* get the port_info structure based on the lep's port address */
+ list_for_each_entry(port_info, &listen_port_list, list) {
+ if (port_info->port_num == port) {
+ port_info->refcnt--;
+ refcnt = port_info->refcnt;
+ /* remove the current lep from the listen list */
+ list_del(&lep->listen_ep_list);
+ if (port_info->refcnt == 0) {
+ /* Remove this entry from the list as there
+ * are no more listeners for this port_num.
+ */
+ list_del(&port_info->list);
+ kfree(port_info);
+ }
+ break;
+ }
+ }
+ mutex_unlock(&listen_port_mutex);
+ return refcnt;
+}
+
+/*
+ * Find the lep that belongs to the ifnet on which the SYN frame was received.
+ */
+struct c4iw_listen_ep *
+find_real_listen_ep(struct c4iw_listen_ep *master_lep, struct socket *so)
+{
+ struct adapter *adap = NULL;
+ struct c4iw_listen_ep *lep = NULL;
+ struct sockaddr_storage remote = { 0 };
+ struct ifnet *new_conn_ifp = NULL;
+ struct listen_port_info *port_info = NULL;
+ int err = 0, i = 0,
+ found_portinfo = 0, found_lep = 0;
+ uint16_t port;
+
+ /* STEP 1: get 'ifnet' based on socket's remote address */
+ GET_REMOTE_ADDR(&remote, so);
+
+ err = get_ifnet_from_raddr(&remote, &new_conn_ifp);
+ if (err) {
+ CTR4(KTR_IW_CXGBE, "%s: Failed to get ifnet, sock %p, "
+ "master_lep %p err %d",
+ __func__, so, master_lep, err);
+ return (NULL);
+ }
+
+ /* STEP 2: Find 'port_info' with listener local port address. */
+ port = (master_lep->com.local_addr.ss_family == AF_INET) ?
+ ((struct sockaddr_in *)&master_lep->com.local_addr)->sin_port :
+ ((struct sockaddr_in6 *)&master_lep->com.local_addr)->sin6_port;
+
+
+ mutex_lock(&listen_port_mutex);
+ list_for_each_entry(port_info, &listen_port_list, list)
+ if (port_info->port_num == port) {
+ found_portinfo =1;
+ break;
+ }
+ if (!found_portinfo)
+ goto out;
+
+ /* STEP 3: Traverse through list of lep's that are bound to the current
+ * TCP port address and find the lep that belongs to the ifnet on which
+ * the SYN frame was received.
+ */
+ list_for_each_entry(lep, &port_info->lep_list, listen_ep_list) {
+ adap = lep->com.dev->rdev.adap;
+ for_each_port(adap, i) {
+ if (new_conn_ifp == adap->port[i]->vi[0].ifp) {
+ found_lep =1;
+ goto out;
+ }
+ }
+ }
+out:
+ mutex_unlock(&listen_port_mutex);
+ return found_lep ? lep : (NULL);
+}
static void process_timeout(struct c4iw_ep *ep)
{
- struct c4iw_qp_attributes attrs;
+ struct c4iw_qp_attributes attrs = {0};
int abort = 1;
- mutex_lock(&ep->com.mutex);
CTR4(KTR_IW_CXGBE, "%s ep :%p, tid:%u, state %d", __func__,
ep, ep->hwtid, ep->com.state);
set_bit(TIMEDOUT, &ep->com.history);
@@ -220,7 +428,6 @@ static void process_timeout(struct c4iw_ep *ep)
, __func__, ep, ep->hwtid, ep->com.state);
abort = 0;
}
- mutex_unlock(&ep->com.mutex);
if (abort)
c4iw_ep_disconnect(ep, 1, GFP_KERNEL);
c4iw_put_ep(&ep->com);
@@ -272,14 +479,16 @@ process_req(struct work_struct *ctx)
ep_events = epc->ep_events;
epc->ep_events = 0;
spin_unlock_irqrestore(&req_lock, flag);
- CTR4(KTR_IW_CXGBE, "%s: so %p, ep %p, events 0x%x", __func__,
- epc->so, epc, ep_events);
+ mutex_lock(&epc->mutex);
+ CTR5(KTR_IW_CXGBE, "%s: so %p, ep %p, ep_state %s events 0x%x",
+ __func__, epc->so, epc, states[epc->state], ep_events);
if (ep_events & C4IW_EVENT_TERM)
process_terminate((struct c4iw_ep *)epc);
if (ep_events & C4IW_EVENT_TIMEOUT)
process_timeout((struct c4iw_ep *)epc);
if (ep_events & C4IW_EVENT_SOCKET)
process_socket_event((struct c4iw_ep *)epc);
+ mutex_unlock(&epc->mutex);
c4iw_put_ep(epc);
process_err_cqes();
spin_lock_irqsave(&req_lock, flag);
@@ -320,55 +529,67 @@ done:
return (rc);
}
-
static int
-find_route(__be32 local_ip, __be32 peer_ip, __be16 local_port,
- __be16 peer_port, u8 tos, struct nhop4_extended *pnh4)
+get_ifnet_from_raddr(struct sockaddr_storage *raddr, struct ifnet **ifp)
{
- struct in_addr addr;
- int err;
-
- CTR5(KTR_IW_CXGBE, "%s:frtB %x, %x, %d, %d", __func__, local_ip,
- peer_ip, ntohs(local_port), ntohs(peer_port));
+ int err = 0;
- addr.s_addr = peer_ip;
- err = fib4_lookup_nh_ext(RT_DEFAULT_FIB, addr, NHR_REF, 0, pnh4);
+ if (raddr->ss_family == AF_INET) {
+ struct sockaddr_in *raddr4 = (struct sockaddr_in *)raddr;
+ struct nhop4_extended nh4 = {0};
- CTR2(KTR_IW_CXGBE, "%s:frtE %d", __func__, err);
+ err = fib4_lookup_nh_ext(RT_DEFAULT_FIB, raddr4->sin_addr,
+ NHR_REF, 0, &nh4);
+ *ifp = nh4.nh_ifp;
+ if (err)
+ fib4_free_nh_ext(RT_DEFAULT_FIB, &nh4);
+ } else {
+ struct sockaddr_in6 *raddr6 = (struct sockaddr_in6 *)raddr;
+ struct nhop6_extended nh6 = {0};
+ struct in6_addr addr6;
+ uint32_t scopeid;
+
+ memset(&addr6, 0, sizeof(addr6));
+ in6_splitscope((struct in6_addr *)&raddr6->sin6_addr,
+ &addr6, &scopeid);
+ err = fib6_lookup_nh_ext(RT_DEFAULT_FIB, &addr6, scopeid,
+ NHR_REF, 0, &nh6);
+ *ifp = nh6.nh_ifp;
+ if (err)
+ fib6_free_nh_ext(RT_DEFAULT_FIB, &nh6);
+ }
+
+ CTR2(KTR_IW_CXGBE, "%s: return: %d", __func__, err);
return err;
}
static void
close_socket(struct socket *so)
{
-
uninit_iwarp_socket(so);
- sodisconnect(so);
+ soclose(so);
}
static void
process_peer_close(struct c4iw_ep *ep)
{
- struct c4iw_qp_attributes attrs;
+ struct c4iw_qp_attributes attrs = {0};
int disconnect = 1;
int release = 0;
CTR4(KTR_IW_CXGBE, "%s:ppcB ep %p so %p state %s", __func__, ep,
ep->com.so, states[ep->com.state]);
- mutex_lock(&ep->com.mutex);
switch (ep->com.state) {
case MPA_REQ_WAIT:
- CTR2(KTR_IW_CXGBE, "%s:ppc1 %p MPA_REQ_WAIT CLOSING",
+ CTR2(KTR_IW_CXGBE, "%s:ppc1 %p MPA_REQ_WAIT DEAD",
__func__, ep);
- __state_set(&ep->com, CLOSING);
- break;
-
+ /* Fallthrough */
case MPA_REQ_SENT:
- CTR2(KTR_IW_CXGBE, "%s:ppc2 %p MPA_REQ_SENT CLOSING",
+ CTR2(KTR_IW_CXGBE, "%s:ppc2 %p MPA_REQ_SENT DEAD",
__func__, ep);
- __state_set(&ep->com, DEAD);
+ ep->com.state = DEAD;
connect_reply_upcall(ep, -ECONNABORTED);
disconnect = 0;
@@ -387,21 +608,20 @@ process_peer_close(struct c4iw_ep *ep)
*/
CTR2(KTR_IW_CXGBE, "%s:ppc3 %p MPA_REQ_RCVD CLOSING",
__func__, ep);
- __state_set(&ep->com, CLOSING);
- c4iw_get_ep(&ep->com);
+ ep->com.state = CLOSING;
break;
case MPA_REP_SENT:
CTR2(KTR_IW_CXGBE, "%s:ppc4 %p MPA_REP_SENT CLOSING",
__func__, ep);
- __state_set(&ep->com, CLOSING);
+ ep->com.state = CLOSING;
break;
case FPDU_MODE:
CTR2(KTR_IW_CXGBE, "%s:ppc5 %p FPDU_MODE CLOSING",
__func__, ep);
START_EP_TIMER(ep);
- __state_set(&ep->com, CLOSING);
+ ep->com.state = CLOSING;
attrs.next_state = C4IW_QP_STATE_CLOSING;
c4iw_modify_qp(ep->com.dev, ep->com.qp,
C4IW_QP_ATTR_NEXT_STATE, &attrs, 1);
@@ -417,7 +637,7 @@ process_peer_close(struct c4iw_ep *ep)
case CLOSING:
CTR2(KTR_IW_CXGBE, "%s:ppc7 %p CLOSING MORIBUND",
__func__, ep);
- __state_set(&ep->com, MORIBUND);
+ ep->com.state = MORIBUND;
disconnect = 0;
break;
@@ -432,7 +652,7 @@ process_peer_close(struct c4iw_ep *ep)
}
close_socket(ep->com.so);
close_complete_upcall(ep, 0);
- __state_set(&ep->com, DEAD);
+ ep->com.state = DEAD;
release = 1;
disconnect = 0;
break;
@@ -449,7 +669,6 @@ process_peer_close(struct c4iw_ep *ep)
break;
}
- mutex_unlock(&ep->com.mutex);
if (disconnect) {
@@ -468,11 +687,10 @@ process_peer_close(struct c4iw_ep *ep)
static void
process_conn_error(struct c4iw_ep *ep)
{
- struct c4iw_qp_attributes attrs;
+ struct c4iw_qp_attributes attrs = {0};
int ret;
int state;
- mutex_lock(&ep->com.mutex);
state = ep->com.state;
CTR5(KTR_IW_CXGBE, "%s:pceB ep %p so %p so->so_error %u state %s",
__func__, ep, ep->com.so, ep->com.so->so_error,
@@ -482,6 +700,7 @@ process_conn_error(struct c4iw_ep *ep)
case MPA_REQ_WAIT:
STOP_EP_TIMER(ep);
+ c4iw_put_ep(&ep->parent_ep->com);
break;
case MPA_REQ_SENT:
@@ -495,13 +714,6 @@ process_conn_error(struct c4iw_ep *ep)
break;
case MPA_REQ_RCVD:
-
- /*
- * We're gonna mark this puppy DEAD, but keep
- * the reference on it until the ULP accepts or
- * rejects the CR.
- */
- c4iw_get_ep(&ep->com);
break;
case MORIBUND:
@@ -530,7 +742,6 @@ process_conn_error(struct c4iw_ep *ep)
case DEAD:
CTR2(KTR_IW_CXGBE, "%s so_error %d IN DEAD STATE!!!!",
__func__, ep->com.so->so_error);
- mutex_unlock(&ep->com.mutex);
return;
default:
@@ -540,10 +751,9 @@ process_conn_error(struct c4iw_ep *ep)
if (state != ABORTING) {
close_socket(ep->com.so);
- __state_set(&ep->com, DEAD);
+ ep->com.state = DEAD;
c4iw_put_ep(&ep->com);
}
- mutex_unlock(&ep->com.mutex);
CTR2(KTR_IW_CXGBE, "%s:pceE %p", __func__, ep);
return;
}
@@ -551,14 +761,13 @@ process_conn_error(struct c4iw_ep *ep)
static void
process_close_complete(struct c4iw_ep *ep)
{
- struct c4iw_qp_attributes attrs;
+ struct c4iw_qp_attributes attrs = {0};
int release = 0;
CTR4(KTR_IW_CXGBE, "%s:pccB ep %p so %p state %s", __func__, ep,
ep->com.so, states[ep->com.state]);
/* The cm_id may be null if we failed to connect */
- mutex_lock(&ep->com.mutex);
set_bit(CLOSE_CON_RPL, &ep->com.history);
switch (ep->com.state) {
@@ -566,7 +775,7 @@ process_close_complete(struct c4iw_ep *ep)
case CLOSING:
CTR2(KTR_IW_CXGBE, "%s:pcc1 %p CLOSING MORIBUND",
__func__, ep);
- __state_set(&ep->com, MORIBUND);
+ ep->com.state = MORIBUND;
break;
case MORIBUND:
@@ -587,7 +796,7 @@ process_close_complete(struct c4iw_ep *ep)
close_socket(ep->com.so);
close_complete_upcall(ep, 0);
- __state_set(&ep->com, DEAD);
+ ep->com.state = DEAD;
release = 1;
break;
@@ -604,29 +813,23 @@ process_close_complete(struct c4iw_ep *ep)
panic("%s:pcc6 %p unknown ep state", __func__, ep);
break;
}
- mutex_unlock(&ep->com.mutex);
if (release) {
CTR2(KTR_IW_CXGBE, "%s:pcc8 %p", __func__, ep);
- c4iw_put_ep(&ep->com);
+ release_ep_resources(ep);
}
CTR2(KTR_IW_CXGBE, "%s:pccE %p", __func__, ep);
return;
}
static void
-init_iwarp_socket(struct socket *so, void *arg)
+setiwsockopt(struct socket *so)
{
int rc;
struct sockopt sopt;
int on = 1;
- /* Note that SOCK_LOCK(so) is same as SOCKBUF_LOCK(&so->so_rcv) */
- SOCK_LOCK(so);
- soupcall_set(so, SO_RCV, c4iw_so_upcall, arg);
- so->so_state |= SS_NBIO;
- SOCK_UNLOCK(so);
sopt.sopt_dir = SOPT_SET;
sopt.sopt_level = IPPROTO_TCP;
sopt.sopt_name = TCP_NODELAY;
@@ -641,6 +844,16 @@ init_iwarp_socket(struct socket *so, void *arg)
}
static void
+init_iwarp_socket(struct socket *so, void *arg)
+{
+
+ SOCKBUF_LOCK(&so->so_rcv);
+ soupcall_set(so, SO_RCV, c4iw_so_upcall, arg);
+ so->so_state |= SS_NBIO;
+ SOCKBUF_UNLOCK(&so->so_rcv);
+}
+
+static void
uninit_iwarp_socket(struct socket *so)
{
@@ -652,30 +865,26 @@ uninit_iwarp_socket(struct socket *so)
static void
process_data(struct c4iw_ep *ep)
{
- struct sockaddr_in *local, *remote;
int disconnect = 0;
CTR5(KTR_IW_CXGBE, "%s: so %p, ep %p, state %s, sbused %d", __func__,
ep->com.so, ep, states[ep->com.state], sbused(&ep->com.so->so_rcv));
- switch (state_read(&ep->com)) {
+ switch (ep->com.state) {
case MPA_REQ_SENT:
disconnect = process_mpa_reply(ep);
break;
case MPA_REQ_WAIT:
- in_getsockaddr(ep->com.so, (struct sockaddr **)&local);
- in_getpeeraddr(ep->com.so, (struct sockaddr **)&remote);
- ep->com.local_addr = *local;
- ep->com.remote_addr = *remote;
- free(local, M_SONAME);
- free(remote, M_SONAME);
disconnect = process_mpa_request(ep);
+ if (disconnect)
+ /* Refered in process_newconn() */
+ c4iw_put_ep(&ep->parent_ep->com);
break;
default:
if (sbused(&ep->com.so->so_rcv))
log(LOG_ERR, "%s: Unexpected streaming data. ep %p, "
"state %d, so %p, so_state 0x%x, sbused %u\n",
- __func__, ep, state_read(&ep->com), ep->com.so,
+ __func__, ep, ep->com.state, ep->com.so,
ep->com.so->so_state, sbused(&ep->com.so->so_rcv));
break;
}
@@ -699,57 +908,122 @@ process_connected(struct c4iw_ep *ep)
return;
err:
close_socket(so);
- state_set(&ep->com, DEAD);
+ ep->com.state = DEAD;
c4iw_put_ep(&ep->com);
return;
}
-void
-process_newconn(struct iw_cm_id *parent_cm_id, struct socket *child_so)
+static inline int c4iw_zero_addr(struct sockaddr *addr)
{
- struct c4iw_ep *child_ep;
- struct sockaddr_in *local;
- struct sockaddr_in *remote;
- struct c4iw_ep *parent_ep = parent_cm_id->provider_data;
- int ret = 0;
+ struct in6_addr *ip6;
- MPASS(child_so != NULL);
+ if (addr->sa_family == AF_INET)
+ return IN_ZERONET(
+ ntohl(((struct sockaddr_in *)addr)->sin_addr.s_addr));
+ else {
+ ip6 = &((struct sockaddr_in6 *) addr)->sin6_addr;
+ return (ip6->s6_addr32[0] | ip6->s6_addr32[1] |
+ ip6->s6_addr32[2] | ip6->s6_addr32[3]) == 0;
+ }
+}
- child_ep = alloc_ep(sizeof(*child_ep), GFP_KERNEL);
+static inline int c4iw_loopback_addr(struct sockaddr *addr)
+{
+ if (addr->sa_family == AF_INET)
+ return IN_LOOPBACK(
+ ntohl(((struct sockaddr_in *) addr)->sin_addr.s_addr));
+ else
+ return IN6_IS_ADDR_LOOPBACK(
+ &((struct sockaddr_in6 *) addr)->sin6_addr);
+}
- CTR5(KTR_IW_CXGBE,
- "%s: parent so %p, parent ep %p, child so %p, child ep %p",
- __func__, parent_ep->com.so, parent_ep, child_so, child_ep);
+static inline int c4iw_any_addr(struct sockaddr *addr)
+{
+ return c4iw_zero_addr(addr) || c4iw_loopback_addr(addr);
+}
- in_getsockaddr(child_so, (struct sockaddr **)&local);
- in_getpeeraddr(child_so, (struct sockaddr **)&remote);
+static void
+process_newconn(struct c4iw_listen_ep *master_lep, struct socket *new_so)
+{
+ struct c4iw_listen_ep *real_lep = NULL;
+ struct c4iw_ep *new_ep = NULL;
+ struct sockaddr_in *remote = NULL;
+ int ret = 0;
- child_ep->com.local_addr = *local;
- child_ep->com.remote_addr = *remote;
- child_ep->com.dev = parent_ep->com.dev;
- child_ep->com.so = child_so;
- child_ep->com.cm_id = NULL;
- child_ep->com.thread = parent_ep->com.thread;
- child_ep->parent_ep = parent_ep;
+ MPASS(new_so != NULL);
- free(local, M_SONAME);
+ if (c4iw_any_addr((struct sockaddr *)&master_lep->com.local_addr)) {
+ /* Here we need to find the 'real_lep' that belongs to the
+ * incomming socket's network interface, such that the newly
+ * created 'ep' can be attached to the real 'lep'.
+ */
+ real_lep = find_real_listen_ep(master_lep, new_so);
+ if (real_lep == NULL) {
+ CTR2(KTR_IW_CXGBE, "%s: Could not find the real listen "
+ "ep for sock: %p", __func__, new_so);
+ log(LOG_ERR,"%s: Could not find the real listen ep for "
+ "sock: %p\n", __func__, new_so);
+ /* FIXME: properly free the 'new_so' in failure case.
+ * Use of soabort() and soclose() are not legal
+ * here(before soaccept()).
+ */
+ return;
+ }
+ } else /* for Non-Wildcard address, master_lep is always the real_lep */
+ real_lep = master_lep;
+
+ new_ep = alloc_ep(sizeof(*new_ep), GFP_KERNEL);
+
+ CTR6(KTR_IW_CXGBE, "%s: master_lep %p, real_lep: %p, new ep %p, "
+ "listening so %p, new so %p", __func__, master_lep, real_lep,
+ new_ep, master_lep->com.so, new_so);
+
+ new_ep->com.dev = real_lep->com.dev;
+ new_ep->com.so = new_so;
+ new_ep->com.cm_id = NULL;
+ new_ep->com.thread = real_lep->com.thread;
+ new_ep->parent_ep = real_lep;
+
+ GET_LOCAL_ADDR(&new_ep->com.local_addr, new_so);
+ GET_REMOTE_ADDR(&new_ep->com.remote_addr, new_so);
+ c4iw_get_ep(&real_lep->com);
+ init_timer(&new_ep->timer);
+ new_ep->com.state = MPA_REQ_WAIT;
+ START_EP_TIMER(new_ep);
+
+ setiwsockopt(new_so);
+ ret = soaccept(new_so, (struct sockaddr **)&remote);
+ if (ret != 0) {
+ CTR4(KTR_IW_CXGBE,
+ "%s:listen sock:%p, new sock:%p, ret:%d\n",
+ __func__, master_lep->com.so, new_so, ret);
+ if (remote != NULL)
+ free(remote, M_SONAME);
+ uninit_iwarp_socket(new_so);
+ soclose(new_so);
+ c4iw_put_ep(&new_ep->com);
+ c4iw_put_ep(&real_lep->com);
+ return;
+ }
free(remote, M_SONAME);
- init_iwarp_socket(child_so, &child_ep->com);
- c4iw_get_ep(&parent_ep->com);
- init_timer(&child_ep->timer);
- state_set(&child_ep->com, MPA_REQ_WAIT);
- START_EP_TIMER(child_ep);
+ /* MPA request might have been queued up on the socket already, so we
+ * initialize the socket/upcall_handler under lock to prevent processing
+ * MPA request on another thread(via process_req()) simultaniously.
+ */
+ c4iw_get_ep(&new_ep->com); /* Dereferenced at the end below, this is to
+ avoid freeing of ep before ep unlock. */
+ mutex_lock(&new_ep->com.mutex);
+ init_iwarp_socket(new_so, &new_ep->com);
- /* maybe the request has already been queued up on the socket... */
- ret = process_mpa_request(child_ep);
- if (ret == 2)
+ ret = process_mpa_request(new_ep);
+ if (ret) {
/* ABORT */
- c4iw_ep_disconnect(child_ep, 1, GFP_KERNEL);
- else if (ret == 1)
- /* CLOSE */
- c4iw_ep_disconnect(child_ep, 0, GFP_KERNEL);
-
+ c4iw_ep_disconnect(new_ep, 1, GFP_KERNEL);
+ c4iw_put_ep(&real_lep->com);
+ }
+ mutex_unlock(&new_ep->com.mutex);
+ c4iw_put_ep(&new_ep->com);
return;
}
@@ -783,6 +1057,12 @@ c4iw_so_upcall(struct socket *so, void *arg, int waitflag)
ep->com.entry.tqe_prev);
MPASS(ep->com.so == so);
+ /*
+ * Wake up any threads waiting in rdma_init()/rdma_fini(),
+ * with locks held.
+ */
+ if (so->so_error)
+ c4iw_wake_up(&ep->com.wr_wait, -ECONNRESET);
add_ep_to_req_list(ep, C4IW_EVENT_SOCKET);
return (SU_OK);
@@ -810,12 +1090,52 @@ terminate(struct sge_iq *iq, const struct rss_header *rss, struct mbuf *m)
return 0;
}
+static struct socket *
+dequeue_socket(struct socket *head)
+{
+ struct socket *so;
+ struct sockaddr_in *remote;
+
+ ACCEPT_LOCK();
+ so = TAILQ_FIRST(&head->so_comp);
+ if (!so) {
+ ACCEPT_UNLOCK();
+ return NULL;
+ }
+
+ SOCK_LOCK(so);
+ /*
+ * Before changing the flags on the socket, we have to bump the
+ * reference count. Otherwise, if the protocol calls sofree(),
+ * the socket will be released due to a zero refcount.
+ */
+ soref(so);
+ TAILQ_REMOVE(&head->so_comp, so, so_list);
+ head->so_qlen--;
+ so->so_qstate &= ~SQ_COMP;
+ so->so_head = NULL;
+ so->so_state |= SS_NBIO;
+ SOCK_UNLOCK(so);
+ ACCEPT_UNLOCK();
+ remote = NULL;
+ soaccept(so, (struct sockaddr **)&remote);
+
+ free(remote, M_SONAME);
+ return so;
+}
+
static void
process_socket_event(struct c4iw_ep *ep)
{
- int state = state_read(&ep->com);
+ int state = ep->com.state;
struct socket *so = ep->com.so;
+ if (ep->com.state == DEAD) {
+ CTR3(KTR_IW_CXGBE, "%s: Pending socket event discarded "
+ "ep %p ep_state %s", __func__, ep, states[state]);
+ return;
+ }
+
CTR6(KTR_IW_CXGBE, "process_socket_event: so %p, so_state 0x%x, "
"so_err %d, sb_state 0x%x, ep %p, ep_state %s", so, so->so_state,
so->so_error, so->so_rcv.sb_state, ep, states[state]);
@@ -826,10 +1146,12 @@ process_socket_event(struct c4iw_ep *ep)
}
if (state == LISTEN) {
- /* socket listening events are handled at IWCM */
- CTR3(KTR_IW_CXGBE, "%s Invalid ep state:%u, ep:%p", __func__,
- ep->com.state, ep);
- BUG();
+ struct c4iw_listen_ep *lep = (struct c4iw_listen_ep *)ep;
+ struct socket *new_so;
+
+ while ((new_so = dequeue_socket(so)) != NULL) {
+ process_newconn(lep, new_so);
+ }
return;
}
@@ -948,34 +1270,6 @@ stop_ep_timer(struct c4iw_ep *ep)
return 1;
}
-static enum
-c4iw_ep_state state_read(struct c4iw_ep_common *epc)
-{
- enum c4iw_ep_state state;
-
- mutex_lock(&epc->mutex);
- state = epc->state;
- mutex_unlock(&epc->mutex);
-
- return (state);
-}
-
-static void
-__state_set(struct c4iw_ep_common *epc, enum c4iw_ep_state new)
-{
-
- epc->state = new;
-}
-
-static void
-state_set(struct c4iw_ep_common *epc, enum c4iw_ep_state new)
-{
-
- mutex_lock(&epc->mutex);
- __state_set(epc, new);
- mutex_unlock(&epc->mutex);
-}
-
static void *
alloc_ep(int size, gfp_t gfp)
{
@@ -1054,8 +1348,8 @@ send_mpa_req(struct c4iw_ep *ep)
}
if (mpa_rev_to_use == 2) {
- mpa->private_data_size +=
- htons(sizeof(struct mpa_v2_conn_params));
+ mpa->private_data_size = htons(ntohs(mpa->private_data_size) +
+ sizeof(struct mpa_v2_conn_params));
mpa_v2_params.ird = htons((u16)ep->ird);
mpa_v2_params.ord = htons((u16)ep->ord);
@@ -1107,7 +1401,7 @@ send_mpa_req(struct c4iw_ep *ep)
}
START_EP_TIMER(ep);
- state_set(&ep->com, MPA_REQ_SENT);
+ ep->com.state = MPA_REQ_SENT;
ep->mpa_attr.initiator = 1;
CTR3(KTR_IW_CXGBE, "%s:smrE %p, error: %d", __func__, ep, err);
return 0;
@@ -1150,8 +1444,8 @@ static int send_mpa_reject(struct c4iw_ep *ep, const void *pdata, u8 plen)
if (ep->mpa_attr.version == 2 && ep->mpa_attr.enhanced_rdma_conn) {
mpa->flags |= MPA_ENHANCED_RDMA_CONN;
- mpa->private_data_size +=
- htons(sizeof(struct mpa_v2_conn_params));
+ mpa->private_data_size = htons(ntohs(mpa->private_data_size) +
+ sizeof(struct mpa_v2_conn_params));
mpa_v2_params.ird = htons(((u16)ep->ird) |
(peer2peer ? MPA_V2_PEER2PEER_MODEL :
0));
@@ -1166,7 +1460,7 @@ static int send_mpa_reject(struct c4iw_ep *ep, const void *pdata, u8 plen)
if (ep->plen)
memcpy(mpa->private_data +
- sizeof(struct mpa_v2_conn_params), pdata, plen);
+ sizeof(struct mpa_v2_conn_params), pdata, plen);
CTR5(KTR_IW_CXGBE, "%s:smrej3 %p %d %d %d", __func__, ep,
mpa_v2_params.ird, mpa_v2_params.ord, ep->plen);
} else
@@ -1270,7 +1564,7 @@ static int send_mpa_reply(struct c4iw_ep *ep, const void *pdata, u8 plen)
free(mpa, M_CXGBE);
- state_set(&ep->com, MPA_REP_SENT);
+ ep->com.state = MPA_REP_SENT;
ep->snd_seq += mpalen;
err = -sosend(ep->com.so, NULL, NULL, m, NULL, MSG_DONTWAIT,
ep->com.thread);
@@ -1327,17 +1621,17 @@ send_abort(struct c4iw_ep *ep)
}
uninit_iwarp_socket(so);
- sodisconnect(so);
+ soclose(so);
set_bit(ABORT_CONN, &ep->com.history);
/*
* TBD: iw_cxgbe driver should receive ABORT reply for every ABORT
* request it has sent. But the current TOE driver is not propagating
* this ABORT reply event (via do_abort_rpl) to iw_cxgbe. So as a work-
- * around de-refer 'ep' (which was refered before sending ABORT request)
- * here instead of doing it in abort_rpl() handler of iw_cxgbe driver.
+ * around de-refererece 'ep' here instead of doing it in abort_rpl()
+ * handler(not yet implemented) of iw_cxgbe driver.
*/
- c4iw_put_ep(&ep->com);
+ release_ep_resources(ep);
return (0);
}
@@ -1396,6 +1690,8 @@ static void connect_reply_upcall(struct c4iw_ep *ep, int status)
CTR2(KTR_IW_CXGBE, "%s:cru1 %p", __func__, ep);
/* this means MPA_v2 is used */
+ event.ord = ep->ird;
+ event.ird = ep->ord;
event.private_data_len = ep->plen -
sizeof(struct mpa_v2_conn_params);
event.private_data = ep->mpa_pkt +
@@ -1405,6 +1701,8 @@ static void connect_reply_upcall(struct c4iw_ep *ep, int status)
CTR2(KTR_IW_CXGBE, "%s:cru2 %p", __func__, ep);
/* this means MPA_v1 is used */
+ event.ord = c4iw_max_read_depth;
+ event.ird = c4iw_max_read_depth;
event.private_data_len = ep->plen;
event.private_data = ep->mpa_pkt +
sizeof(struct mpa_message);
@@ -1446,7 +1744,6 @@ static int connect_request_upcall(struct c4iw_ep *ep)
event.local_addr = ep->com.local_addr;
event.remote_addr = ep->com.remote_addr;
event.provider_data = ep;
- event.so = ep->com.so;
if (!ep->tried_with_mpa_v1) {
/* this means MPA_v2 is used */
@@ -1468,11 +1765,18 @@ static int connect_request_upcall(struct c4iw_ep *ep)
c4iw_get_ep(&ep->com);
ret = ep->parent_ep->com.cm_id->event_handler(ep->parent_ep->com.cm_id,
&event);
- if(ret)
+ if(ret) {
+ CTR3(KTR_IW_CXGBE, "%s: ep %p, Failure while notifying event to"
+ " IWCM, err:%d", __func__, ep, ret);
c4iw_put_ep(&ep->com);
+ } else
+ /* Dereference parent_ep only in success case.
+ * In case of failure, parent_ep is dereferenced by the caller
+ * of process_mpa_request().
+ */
+ c4iw_put_ep(&ep->parent_ep->com);
set_bit(CONNREQ_UPCALL, &ep->com.history);
- c4iw_put_ep(&ep->parent_ep->com);
return ret;
}
@@ -1483,8 +1787,8 @@ static void established_upcall(struct c4iw_ep *ep)
CTR2(KTR_IW_CXGBE, "%s:euB %p", __func__, ep);
memset(&event, 0, sizeof(event));
event.event = IW_CM_EVENT_ESTABLISHED;
- event.ird = ep->ird;
- event.ord = ep->ord;
+ event.ird = ep->ord;
+ event.ord = ep->ird;
if (ep->com.cm_id) {
@@ -1496,6 +1800,8 @@ static void established_upcall(struct c4iw_ep *ep)
}
+#define RELAXED_IRD_NEGOTIATION 1
+
/*
* process_mpa_reply - process streaming mode MPA reply
*
@@ -1515,7 +1821,7 @@ static int process_mpa_reply(struct c4iw_ep *ep)
u16 plen;
u16 resp_ird, resp_ord;
u8 rtr_mismatch = 0, insuff_ird = 0;
- struct c4iw_qp_attributes attrs;
+ struct c4iw_qp_attributes attrs = {0};
enum c4iw_qp_attr_mask mask;
int err;
struct mbuf *top, *m;
@@ -1659,7 +1965,7 @@ static int process_mpa_reply(struct c4iw_ep *ep)
* start reply message including private data. And
* the MPA header is valid.
*/
- state_set(&ep->com, FPDU_MODE);
+ ep->com.state = FPDU_MODE;
ep->mpa_attr.crc_enabled = (mpa->flags & MPA_CRC) | crc_enabled ? 1 : 0;
ep->mpa_attr.recv_marker_enabled = markers_enabled;
ep->mpa_attr.xmit_marker_enabled = mpa->flags & MPA_MARKERS ? 1 : 0;
@@ -1687,13 +1993,25 @@ static int process_mpa_reply(struct c4iw_ep *ep)
* not required since ird/ord stuff has been taken
* care of in c4iw_accept_cr
*/
- if ((ep->ird < resp_ord) || (ep->ord > resp_ird)) {
-
- CTR2(KTR_IW_CXGBE, "%s:pmre %p", __func__, ep);
+ if (ep->ird < resp_ord) {
+ if (RELAXED_IRD_NEGOTIATION && resp_ord <=
+ ep->com.dev->rdev.adap->params.max_ordird_qp)
+ ep->ird = resp_ord;
+ else
+ insuff_ird = 1;
+ } else if (ep->ird > resp_ord) {
+ ep->ird = resp_ord;
+ }
+ if (ep->ord > resp_ird) {
+ if (RELAXED_IRD_NEGOTIATION)
+ ep->ord = resp_ird;
+ else
+ insuff_ird = 1;
+ }
+ if (insuff_ird) {
err = -ENOMEM;
ep->ird = resp_ord;
ep->ord = resp_ird;
- insuff_ird = 1;
}
if (ntohs(mpa_v2_params->ird) &
@@ -1792,8 +2110,9 @@ static int process_mpa_reply(struct c4iw_ep *ep)
attrs.layer_etype = LAYER_MPA | DDP_LLP;
attrs.ecode = MPA_NOMATCH_RTR;
attrs.next_state = C4IW_QP_STATE_TERMINATE;
+ attrs.send_term = 1;
err = c4iw_modify_qp(ep->com.qp->rhp, ep->com.qp,
- C4IW_QP_ATTR_NEXT_STATE, &attrs, 0);
+ C4IW_QP_ATTR_NEXT_STATE, &attrs, 1);
err = -ENOMEM;
disconnect = 1;
goto out;
@@ -1813,8 +2132,9 @@ static int process_mpa_reply(struct c4iw_ep *ep)
attrs.layer_etype = LAYER_MPA | DDP_LLP;
attrs.ecode = MPA_INSUFF_IRD;
attrs.next_state = C4IW_QP_STATE_TERMINATE;
+ attrs.send_term = 1;
err = c4iw_modify_qp(ep->com.qp->rhp, ep->com.qp,
- C4IW_QP_ATTR_NEXT_STATE, &attrs, 0);
+ C4IW_QP_ATTR_NEXT_STATE, &attrs, 1);
err = -ENOMEM;
disconnect = 1;
goto out;
@@ -1846,12 +2166,13 @@ static int
process_mpa_request(struct c4iw_ep *ep)
{
struct mpa_message *mpa;
+ struct mpa_v2_conn_params *mpa_v2_params;
u16 plen;
int flags = MSG_DONTWAIT;
int rc;
struct iovec iov;
struct uio uio;
- enum c4iw_ep_state state = state_read(&ep->com);
+ enum c4iw_ep_state state = ep->com.state;
CTR3(KTR_IW_CXGBE, "%s: ep %p, state %s", __func__, ep, states[state]);
@@ -1940,24 +2261,29 @@ process_mpa_request(struct c4iw_ep *ep)
ep->mpa_attr.enhanced_rdma_conn =
mpa->flags & MPA_ENHANCED_RDMA_CONN ? 1 : 0;
if (ep->mpa_attr.enhanced_rdma_conn) {
- struct mpa_v2_conn_params *mpa_v2_params;
- u16 ird, ord;
-
- mpa_v2_params = (void *)&ep->mpa_pkt[sizeof(*mpa)];
- ird = ntohs(mpa_v2_params->ird);
- ord = ntohs(mpa_v2_params->ord);
-
- ep->ird = ird & MPA_V2_IRD_ORD_MASK;
- ep->ord = ord & MPA_V2_IRD_ORD_MASK;
- if (ird & MPA_V2_PEER2PEER_MODEL && peer2peer) {
- if (ord & MPA_V2_RDMA_WRITE_RTR) {
- ep->mpa_attr.p2p_type =
- FW_RI_INIT_P2PTYPE_RDMA_WRITE;
- } else if (ord & MPA_V2_RDMA_READ_RTR) {
- ep->mpa_attr.p2p_type =
- FW_RI_INIT_P2PTYPE_READ_REQ;
+ mpa_v2_params = (struct mpa_v2_conn_params *)
+ (ep->mpa_pkt + sizeof(*mpa));
+ ep->ird = ntohs(mpa_v2_params->ird) &
+ MPA_V2_IRD_ORD_MASK;
+ ep->ird = min_t(u32, ep->ird,
+ cur_max_read_depth(ep->com.dev));
+ ep->ord = ntohs(mpa_v2_params->ord) &
+ MPA_V2_IRD_ORD_MASK;
+ ep->ord = min_t(u32, ep->ord,
+ cur_max_read_depth(ep->com.dev));
+ CTR3(KTR_IW_CXGBE, "%s initiator ird %u ord %u\n",
+ __func__, ep->ird, ep->ord);
+ if (ntohs(mpa_v2_params->ird) & MPA_V2_PEER2PEER_MODEL)
+ if (peer2peer) {
+ if (ntohs(mpa_v2_params->ord) &
+ MPA_V2_RDMA_WRITE_RTR)
+ ep->mpa_attr.p2p_type =
+ FW_RI_INIT_P2PTYPE_RDMA_WRITE;
+ else if (ntohs(mpa_v2_params->ord) &
+ MPA_V2_RDMA_READ_RTR)
+ ep->mpa_attr.p2p_type =
+ FW_RI_INIT_P2PTYPE_READ_REQ;
}
- }
}
} else if (mpa->revision == 1 && peer2peer)
ep->mpa_attr.p2p_type = p2p_type;
@@ -1970,22 +2296,15 @@ process_mpa_request(struct c4iw_ep *ep)
ep->mpa_attr.crc_enabled, ep->mpa_attr.recv_marker_enabled,
ep->mpa_attr.xmit_marker_enabled, ep->mpa_attr.version);
- state_set(&ep->com, MPA_REQ_RCVD);
+ ep->com.state = MPA_REQ_RCVD;
STOP_EP_TIMER(ep);
/* drive upcall */
- mutex_lock(&ep->parent_ep->com.mutex);
- if (ep->parent_ep->com.state != DEAD) {
+ if (ep->parent_ep->com.state != DEAD)
if (connect_request_upcall(ep))
- goto err_unlock_parent;
- } else
- goto err_unlock_parent;
- mutex_unlock(&ep->parent_ep->com.mutex);
+ goto err_out;
return 0;
-err_unlock_parent:
- mutex_unlock(&ep->parent_ep->com.mutex);
- goto err_out;
err_stop_timer:
STOP_EP_TIMER(ep);
err_out:
@@ -2001,13 +2320,16 @@ int c4iw_reject_cr(struct iw_cm_id *cm_id, const void *pdata, u8 pdata_len)
{
int err;
struct c4iw_ep *ep = to_ep(cm_id);
- CTR2(KTR_IW_CXGBE, "%s:crcB %p", __func__, ep);
int abort = 0;
- if ((state_read(&ep->com) == DEAD) ||
- (state_read(&ep->com) != MPA_REQ_RCVD)) {
+ mutex_lock(&ep->com.mutex);
+ CTR2(KTR_IW_CXGBE, "%s:crcB %p", __func__, ep);
+
+ if ((ep->com.state == DEAD) ||
+ (ep->com.state != MPA_REQ_RCVD)) {
CTR2(KTR_IW_CXGBE, "%s:crc1 %p", __func__, ep);
+ mutex_unlock(&ep->com.mutex);
c4iw_put_ep(&ep->com);
return -ECONNRESET;
}
@@ -2023,8 +2345,9 @@ int c4iw_reject_cr(struct iw_cm_id *cm_id, const void *pdata, u8 pdata_len)
CTR2(KTR_IW_CXGBE, "%s:crc3 %p", __func__, ep);
abort = send_mpa_reject(ep, pdata, pdata_len);
}
- stop_ep_timer(ep);
+ STOP_EP_TIMER(ep);
err = c4iw_ep_disconnect(ep, abort != 0, GFP_KERNEL);
+ mutex_unlock(&ep->com.mutex);
c4iw_put_ep(&ep->com);
CTR3(KTR_IW_CXGBE, "%s:crc4 %p, err: %d", __func__, ep, err);
return 0;
@@ -2033,23 +2356,24 @@ int c4iw_reject_cr(struct iw_cm_id *cm_id, const void *pdata, u8 pdata_len)
int c4iw_accept_cr(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param)
{
int err;
- struct c4iw_qp_attributes attrs;
+ struct c4iw_qp_attributes attrs = {0};
enum c4iw_qp_attr_mask mask;
struct c4iw_ep *ep = to_ep(cm_id);
struct c4iw_dev *h = to_c4iw_dev(cm_id->device);
struct c4iw_qp *qp = get_qhp(h, conn_param->qpn);
int abort = 0;
+ mutex_lock(&ep->com.mutex);
CTR2(KTR_IW_CXGBE, "%s:cacB %p", __func__, ep);
- if (state_read(&ep->com) == DEAD) {
+ if ((ep->com.state == DEAD) ||
+ (ep->com.state != MPA_REQ_RCVD)) {
CTR2(KTR_IW_CXGBE, "%s:cac1 %p", __func__, ep);
err = -ECONNRESET;
goto err_out;
}
- BUG_ON(state_read(&ep->com) != MPA_REQ_RCVD);
BUG_ON(!qp);
set_bit(ULP_ACCEPT, &ep->com.history);
@@ -2067,47 +2391,42 @@ int c4iw_accept_cr(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param)
CTR2(KTR_IW_CXGBE, "%s:cac3 %p", __func__, ep);
if (conn_param->ord > ep->ird) {
-
- CTR2(KTR_IW_CXGBE, "%s:cac4 %p", __func__, ep);
- ep->ird = conn_param->ird;
- ep->ord = conn_param->ord;
- send_mpa_reject(ep, conn_param->private_data,
- conn_param->private_data_len);
- err = -ENOMEM;
- goto err_abort;
- }
-
- if (conn_param->ird > ep->ord) {
-
- CTR2(KTR_IW_CXGBE, "%s:cac5 %p", __func__, ep);
-
- if (!ep->ord) {
-
- CTR2(KTR_IW_CXGBE, "%s:cac6 %p", __func__, ep);
- conn_param->ird = 1;
+ if (RELAXED_IRD_NEGOTIATION) {
+ conn_param->ord = ep->ird;
+ } else {
+ ep->ird = conn_param->ird;
+ ep->ord = conn_param->ord;
+ send_mpa_reject(ep, conn_param->private_data,
+ conn_param->private_data_len);
+ err = -ENOMEM;
+ goto err_abort;
}
- else {
- CTR2(KTR_IW_CXGBE, "%s:cac7 %p", __func__, ep);
+ }
+ if (conn_param->ird < ep->ord) {
+ if (RELAXED_IRD_NEGOTIATION &&
+ ep->ord <= h->rdev.adap->params.max_ordird_qp) {
+ conn_param->ird = ep->ord;
+ } else {
err = -ENOMEM;
goto err_abort;
}
}
-
}
ep->ird = conn_param->ird;
ep->ord = conn_param->ord;
- if (ep->mpa_attr.version != 2) {
-
- CTR2(KTR_IW_CXGBE, "%s:cac8 %p", __func__, ep);
-
- if (peer2peer && ep->ird == 0) {
-
- CTR2(KTR_IW_CXGBE, "%s:cac9 %p", __func__, ep);
+ if (ep->mpa_attr.version == 1) {
+ if (peer2peer && ep->ird == 0)
+ ep->ird = 1;
+ } else {
+ if (peer2peer &&
+ (ep->mpa_attr.p2p_type != FW_RI_INIT_P2PTYPE_DISABLED) &&
+ (p2p_type == FW_RI_INIT_P2PTYPE_READ_REQ) && ep->ird == 0)
ep->ird = 1;
- }
}
+ CTR4(KTR_IW_CXGBE, "%s %d ird %d ord %d\n", __func__, __LINE__,
+ ep->ird, ep->ord);
ep->com.cm_id = cm_id;
ref_cm_id(&ep->com);
@@ -2130,23 +2449,21 @@ int c4iw_accept_cr(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param)
C4IW_QP_ATTR_MAX_ORD;
err = c4iw_modify_qp(ep->com.qp->rhp, ep->com.qp, mask, &attrs, 1);
-
if (err) {
-
- CTR2(KTR_IW_CXGBE, "%s:caca %p", __func__, ep);
+ CTR3(KTR_IW_CXGBE, "%s:caca %p, err: %d", __func__, ep, err);
goto err_defef_cm_id;
}
+
err = send_mpa_reply(ep, conn_param->private_data,
conn_param->private_data_len);
-
if (err) {
-
- CTR2(KTR_IW_CXGBE, "%s:caca %p", __func__, ep);
+ CTR3(KTR_IW_CXGBE, "%s:cacb %p, err: %d", __func__, ep, err);
goto err_defef_cm_id;
}
- state_set(&ep->com, FPDU_MODE);
+ ep->com.state = FPDU_MODE;
established_upcall(ep);
+ mutex_unlock(&ep->com.mutex);
c4iw_put_ep(&ep->com);
CTR2(KTR_IW_CXGBE, "%s:cacE %p", __func__, ep);
return 0;
@@ -2157,22 +2474,59 @@ err_abort:
err_out:
if (abort)
c4iw_ep_disconnect(ep, 1, GFP_KERNEL);
+ mutex_unlock(&ep->com.mutex);
c4iw_put_ep(&ep->com);
CTR2(KTR_IW_CXGBE, "%s:cacE err %p", __func__, ep);
return err;
}
+static int
+c4iw_sock_create(struct sockaddr_storage *laddr, struct socket **so)
+{
+ int ret;
+ int size;
+ struct socket *sock = NULL;
+ ret = sock_create_kern(laddr->ss_family,
+ SOCK_STREAM, IPPROTO_TCP, &sock);
+ if (ret) {
+ CTR2(KTR_IW_CXGBE, "%s:Failed to create TCP socket. err %d",
+ __func__, ret);
+ return ret;
+ }
+
+ ret = sobind(sock, (struct sockaddr *)laddr, curthread);
+ if (ret) {
+ CTR2(KTR_IW_CXGBE, "%s:Failed to bind socket. err %p",
+ __func__, ret);
+ sock_release(sock);
+ return ret;
+ }
+
+ size = laddr->ss_family == AF_INET6 ?
+ sizeof(struct sockaddr_in6) : sizeof(struct sockaddr_in);
+ ret = sock_getname(sock, (struct sockaddr *)laddr, &size, 0);
+ if (ret) {
+ CTR2(KTR_IW_CXGBE, "%s:sock_getname failed. err %p",
+ __func__, ret);
+ sock_release(sock);
+ return ret;
+ }
+
+ *so = sock;
+ return 0;
+}
int c4iw_connect(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param)
{
int err = 0;
struct c4iw_dev *dev = to_c4iw_dev(cm_id->device);
struct c4iw_ep *ep = NULL;
- struct nhop4_extended nh4;
+ struct ifnet *nh_ifp; /* Logical egress interface */
CTR2(KTR_IW_CXGBE, "%s:ccB %p", __func__, cm_id);
+
if ((conn_param->ord > c4iw_max_read_depth) ||
(conn_param->ird > c4iw_max_read_depth)) {
@@ -2181,6 +2535,7 @@ int c4iw_connect(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param)
goto out;
}
ep = alloc_ep(sizeof(*ep), GFP_KERNEL);
+
init_timer(&ep->timer);
ep->plen = conn_param->private_data_len;
@@ -2208,96 +2563,161 @@ int c4iw_connect(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param)
CTR2(KTR_IW_CXGBE, "%s:cc5 %p", __func__, ep);
err = -EINVAL;
- goto fail2;
+ goto fail;
}
ref_qp(ep);
ep->com.thread = curthread;
- ep->com.so = cm_id->so;
-
- /* find a route */
- err = find_route(
- cm_id->local_addr.sin_addr.s_addr,
- cm_id->remote_addr.sin_addr.s_addr,
- cm_id->local_addr.sin_port,
- cm_id->remote_addr.sin_port, 0, &nh4);
+ err = get_ifnet_from_raddr(&cm_id->remote_addr, &nh_ifp);
if (err) {
CTR2(KTR_IW_CXGBE, "%s:cc7 %p", __func__, ep);
printk(KERN_ERR MOD "%s - cannot find route.\n", __func__);
- err = -EHOSTUNREACH;
- goto fail2;
+ err = EHOSTUNREACH;
+ return err;
}
- if (!(nh4.nh_ifp->if_capenable & IFCAP_TOE) ||
- TOEDEV(nh4.nh_ifp) == NULL) {
+ if (!(nh_ifp->if_capenable & IFCAP_TOE) ||
+ TOEDEV(nh_ifp) == NULL) {
err = -ENOPROTOOPT;
- goto fail3;
+ goto fail;
}
- fib4_free_nh_ext(RT_DEFAULT_FIB, &nh4);
-
- state_set(&ep->com, CONNECTING);
+ ep->com.state = CONNECTING;
ep->tos = 0;
ep->com.local_addr = cm_id->local_addr;
ep->com.remote_addr = cm_id->remote_addr;
+
+ err = c4iw_sock_create(&cm_id->local_addr, &ep->com.so);
+ if (err)
+ goto fail;
+
+ setiwsockopt(ep->com.so);
err = -soconnect(ep->com.so, (struct sockaddr *)&ep->com.remote_addr,
ep->com.thread);
-
if (!err) {
- init_iwarp_socket(cm_id->so, &ep->com);
+ init_iwarp_socket(ep->com.so, &ep->com);
goto out;
- } else {
- goto fail2;
- }
+ } else
+ goto fail_free_so;
-fail3:
- fib4_free_nh_ext(RT_DEFAULT_FIB, &nh4);
-fail2:
+fail_free_so:
+ sock_release(ep->com.so);
+fail:
deref_cm_id(&ep->com);
c4iw_put_ep(&ep->com);
- ep = NULL; /* CTR shouldn't display already-freed ep. */
+ ep = NULL;
out:
- CTR2(KTR_IW_CXGBE, "%s:ccE %p", __func__, ep);
+ CTR2(KTR_IW_CXGBE, "%s:ccE ret:%d", __func__, err);
return err;
}
/*
- * iwcm->create_listen_ep. Returns -errno on failure.
+ * iwcm->create_listen. Returns -errno on failure.
*/
int
-c4iw_create_listen_ep(struct iw_cm_id *cm_id, int backlog)
+c4iw_create_listen(struct iw_cm_id *cm_id, int backlog)
{
struct c4iw_dev *dev = to_c4iw_dev(cm_id->device);
- struct c4iw_listen_ep *ep;
- struct socket *so = cm_id->so;
+ struct c4iw_listen_ep *lep = NULL;
+ struct listen_port_info *port_info = NULL;
+ int rc = 0;
- ep = alloc_ep(sizeof(*ep), GFP_KERNEL);
- ep->com.cm_id = cm_id;
- ref_cm_id(&ep->com);
- ep->com.dev = dev;
- ep->backlog = backlog;
- ep->com.local_addr = cm_id->local_addr;
- ep->com.thread = curthread;
- state_set(&ep->com, LISTEN);
- ep->com.so = so;
+ CTR3(KTR_IW_CXGBE, "%s: cm_id %p, backlog %s", __func__, cm_id,
+ backlog);
+ lep = alloc_ep(sizeof(*lep), GFP_KERNEL);
+ lep->com.cm_id = cm_id;
+ ref_cm_id(&lep->com);
+ lep->com.dev = dev;
+ lep->backlog = backlog;
+ lep->com.local_addr = cm_id->local_addr;
+ lep->com.thread = curthread;
+ cm_id->provider_data = lep;
+ lep->com.state = LISTEN;
+
+ /* In case of INDADDR_ANY, ibcore creates cmid for each device and
+ * invokes iw_cxgbe listener callbacks assuming that iw_cxgbe creates
+ * HW listeners for each device seperately. But toecore expects single
+ * solisten() call with INADDR_ANY address to create HW listeners on
+ * all devices for a given port number. So iw_cxgbe driver calls
+ * solisten() only once for INADDR_ANY(usually done at first time
+ * listener callback from ibcore). And all the subsequent INADDR_ANY
+ * listener callbacks from ibcore(for the same port address) do not
+ * invoke solisten() as first listener callback has already created
+ * listeners for all other devices(via solisten).
+ */
+ if (c4iw_any_addr((struct sockaddr *)&lep->com.local_addr)) {
+ port_info = add_ep_to_listenlist(lep);
+ /* skip solisten() if refcnt > 1, as the listeners were
+ * alredy created by 'Master lep'
+ */
+ if (port_info->refcnt > 1) {
+ /* As there will be only one listener socket for a TCP
+ * port, copy Master lep's socket pointer to other lep's
+ * that are belonging to same TCP port.
+ */
+ struct c4iw_listen_ep *head_lep =
+ container_of(port_info->lep_list.next,
+ struct c4iw_listen_ep, listen_ep_list);
+ lep->com.so = head_lep->com.so;
+ goto out;
+ }
+ }
+ rc = c4iw_sock_create(&cm_id->local_addr, &lep->com.so);
+ if (rc) {
+ CTR2(KTR_IW_CXGBE, "%s:Failed to create socket. err %d",
+ __func__, rc);
+ goto fail;
+ }
- cm_id->provider_data = ep;
- return (0);
+ rc = solisten(lep->com.so, backlog, curthread);
+ if (rc) {
+ CTR3(KTR_IW_CXGBE, "%s:Failed to listen on sock:%p. err %d",
+ __func__, lep->com.so, rc);
+ goto fail_free_so;
+ }
+ init_iwarp_socket(lep->com.so, &lep->com);
+out:
+ return 0;
+
+fail_free_so:
+ sock_release(lep->com.so);
+fail:
+ if (port_info)
+ rem_ep_from_listenlist(lep);
+ deref_cm_id(&lep->com);
+ c4iw_put_ep(&lep->com);
+ return rc;
}
-void
-c4iw_destroy_listen_ep(struct iw_cm_id *cm_id)
+int
+c4iw_destroy_listen(struct iw_cm_id *cm_id)
{
- struct c4iw_listen_ep *ep = to_listen_ep(cm_id);
+ struct c4iw_listen_ep *lep = to_listen_ep(cm_id);
- CTR4(KTR_IW_CXGBE, "%s: cm_id %p, so %p, state %s", __func__, cm_id,
- cm_id->so, states[ep->com.state]);
+ mutex_lock(&lep->com.mutex);
+ CTR3(KTR_IW_CXGBE, "%s: cm_id %p, state %s", __func__, cm_id,
+ states[lep->com.state]);
- state_set(&ep->com, DEAD);
- deref_cm_id(&ep->com);
- c4iw_put_ep(&ep->com);
+ lep->com.state = DEAD;
+ if (c4iw_any_addr((struct sockaddr *)&lep->com.local_addr)) {
+ /* if no refcount then close listen socket */
+ if (!rem_ep_from_listenlist(lep))
+ close_socket(lep->com.so);
+ } else
+ close_socket(lep->com.so);
+ deref_cm_id(&lep->com);
+ mutex_unlock(&lep->com.mutex);
+ c4iw_put_ep(&lep->com);
+ return 0;
+}
- return;
+int __c4iw_ep_disconnect(struct c4iw_ep *ep, int abrupt, gfp_t gfp)
+{
+ int ret;
+ mutex_lock(&ep->com.mutex);
+ ret = c4iw_ep_disconnect(ep, abrupt, gfp);
+ mutex_unlock(&ep->com.mutex);
+ return ret;
}
int c4iw_ep_disconnect(struct c4iw_ep *ep, int abrupt, gfp_t gfp)
@@ -2307,7 +2727,6 @@ int c4iw_ep_disconnect(struct c4iw_ep *ep, int abrupt, gfp_t gfp)
int fatal = 0;
struct c4iw_rdev *rdev;
- mutex_lock(&ep->com.mutex);
CTR2(KTR_IW_CXGBE, "%s:cedB %p", __func__, ep);
@@ -2318,11 +2737,17 @@ int c4iw_ep_disconnect(struct c4iw_ep *ep, int abrupt, gfp_t gfp)
CTR2(KTR_IW_CXGBE, "%s:ced1 %p", __func__, ep);
fatal = 1;
close_complete_upcall(ep, -ECONNRESET);
+ send_abort(ep);
ep->com.state = DEAD;
}
CTR3(KTR_IW_CXGBE, "%s:ced2 %p %s", __func__, ep,
states[ep->com.state]);
+ /*
+ * Ref the ep here in case we have fatal errors causing the
+ * ep to be released and freed.
+ */
+ c4iw_get_ep(&ep->com);
switch (ep->com.state) {
case MPA_REQ_WAIT:
@@ -2366,7 +2791,6 @@ int c4iw_ep_disconnect(struct c4iw_ep *ep, int abrupt, gfp_t gfp)
break;
}
- mutex_unlock(&ep->com.mutex);
if (close) {
@@ -2386,7 +2810,7 @@ int c4iw_ep_disconnect(struct c4iw_ep *ep, int abrupt, gfp_t gfp)
set_bit(EP_DISC_CLOSE, &ep->com.history);
if (!ep->parent_ep)
- __state_set(&ep->com, MORIBUND);
+ ep->com.state = MORIBUND;
sodisconnect(ep->com.so);
}
@@ -2399,7 +2823,7 @@ int c4iw_ep_disconnect(struct c4iw_ep *ep, int abrupt, gfp_t gfp)
close_complete_upcall(ep, -EIO);
}
if (ep->com.qp) {
- struct c4iw_qp_attributes attrs;
+ struct c4iw_qp_attributes attrs = {0};
attrs.next_state = C4IW_QP_STATE_ERROR;
ret = c4iw_modify_qp(ep->com.dev, ep->com.qp,
@@ -2414,6 +2838,7 @@ int c4iw_ep_disconnect(struct c4iw_ep *ep, int abrupt, gfp_t gfp)
ep->com.state = DEAD;
CTR2(KTR_IW_CXGBE, "%s:ced6 %p", __func__, ep);
}
+ c4iw_put_ep(&ep->com);
CTR2(KTR_IW_CXGBE, "%s:cedE %p", __func__, ep);
return ret;
}
@@ -2491,7 +2916,7 @@ static int fw6_cqe_handler(struct adapter *sc, const __be64 *rpl)
static int
process_terminate(struct c4iw_ep *ep)
{
- struct c4iw_qp_attributes attrs;
+ struct c4iw_qp_attributes attrs = {0};
CTR2(KTR_IW_CXGBE, "%s:tB %p %d", __func__, ep);
diff --git a/sys/dev/cxgbe/iw_cxgbe/cq.c b/sys/dev/cxgbe/iw_cxgbe/cq.c
index 68f4188..317b64a 100644
--- a/sys/dev/cxgbe/iw_cxgbe/cq.c
+++ b/sys/dev/cxgbe/iw_cxgbe/cq.c
@@ -53,6 +53,7 @@ static int destroy_cq(struct c4iw_rdev *rdev, struct t4_cq *cq,
struct c4iw_dev_ucontext *uctx)
{
struct adapter *sc = rdev->adap;
+ struct c4iw_dev *rhp = rdev_to_c4iw_dev(rdev);
struct fw_ri_res_wr *res_wr;
struct fw_ri_res *res;
int wr_len;
@@ -80,10 +81,12 @@ static int destroy_cq(struct c4iw_rdev *rdev, struct t4_cq *cq,
t4_wrq_tx(sc, wr);
- c4iw_wait_for_reply(rdev, &wr_wait, 0, 0, __func__);
+ c4iw_wait_for_reply(rdev, &wr_wait, 0, 0, NULL, __func__);
kfree(cq->sw_queue);
- contigfree(cq->queue, cq->memsize, M_DEVBUF);
+ dma_free_coherent(rhp->ibdev.dma_device,
+ cq->memsize, cq->queue,
+ dma_unmap_addr(cq, mapping));
c4iw_put_cqid(rdev, cq->cqid, uctx);
return 0;
}
@@ -93,6 +96,7 @@ create_cq(struct c4iw_rdev *rdev, struct t4_cq *cq,
struct c4iw_dev_ucontext *uctx)
{
struct adapter *sc = rdev->adap;
+ struct c4iw_dev *rhp = rdev_to_c4iw_dev(rdev);
struct fw_ri_res_wr *res_wr;
struct fw_ri_res *res;
int wr_len;
@@ -100,6 +104,7 @@ create_cq(struct c4iw_rdev *rdev, struct t4_cq *cq,
struct c4iw_wr_wait wr_wait;
int ret;
struct wrqe *wr;
+ u64 cq_bar2_qoffset = 0;
cq->cqid = c4iw_get_cqid(rdev, uctx);
if (!cq->cqid) {
@@ -114,17 +119,13 @@ create_cq(struct c4iw_rdev *rdev, struct t4_cq *cq,
goto err2;
}
}
-
- cq->queue = contigmalloc(cq->memsize, M_DEVBUF, M_NOWAIT, 0ul, ~0ul,
- PAGE_SIZE, 0);
- if (cq->queue)
- cq->dma_addr = vtophys(cq->queue);
- else {
+ cq->queue = dma_alloc_coherent(rhp->ibdev.dma_device, cq->memsize,
+ &cq->dma_addr, GFP_KERNEL);
+ if (!cq->queue) {
ret = -ENOMEM;
- goto err3;
+ goto err3;
}
-
- pci_unmap_addr_set(cq, mapping, cq->dma_addr);
+ dma_unmap_addr_set(cq, mapping, cq->dma_addr);
memset(cq->queue, 0, cq->memsize);
/* build fw_ri_res_wr */
@@ -166,26 +167,30 @@ create_cq(struct c4iw_rdev *rdev, struct t4_cq *cq,
t4_wrq_tx(sc, wr);
CTR2(KTR_IW_CXGBE, "%s wait_event wr_wait %p", __func__, &wr_wait);
- ret = c4iw_wait_for_reply(rdev, &wr_wait, 0, 0, __func__);
+ ret = c4iw_wait_for_reply(rdev, &wr_wait, 0, 0, NULL, __func__);
if (ret)
goto err4;
cq->gen = 1;
- cq->gts = (void *)((unsigned long)rman_get_virtual(sc->regs_res) +
- sc->sge_gts_reg);
cq->rdev = rdev;
- if (user) {
- cq->ugts = (u64)((char*)rman_get_virtual(sc->udbs_res) +
- (cq->cqid << rdev->cqshift));
- cq->ugts &= PAGE_MASK;
- CTR5(KTR_IW_CXGBE,
- "%s: UGTS %p cqid %x cqshift %d page_mask %x", __func__,
- cq->ugts, cq->cqid, rdev->cqshift, PAGE_MASK);
- }
+ /* Determine the BAR2 queue offset and qid. */
+ t4_bar2_sge_qregs(rdev->adap, cq->cqid, T4_BAR2_QTYPE_INGRESS, user,
+ &cq_bar2_qoffset, &cq->bar2_qid);
+
+ /* If user mapping then compute the page-aligned physical
+ * address for mapping.
+ */
+ if (user)
+ cq->bar2_pa = (rdev->bar2_pa + cq_bar2_qoffset) & PAGE_MASK;
+ else
+ cq->bar2_va = (void __iomem *)((u64)rdev->bar2_kva +
+ cq_bar2_qoffset);
+
return 0;
err4:
- contigfree(cq->queue, cq->memsize, M_DEVBUF);
+ dma_free_coherent(rhp->ibdev.dma_device, cq->memsize, cq->queue,
+ dma_unmap_addr(cq, mapping));
err3:
kfree(cq->sw_queue);
err2:
@@ -275,7 +280,7 @@ int c4iw_flush_sq(struct c4iw_qp *qhp)
}
wq->sq.flush_cidx += flushed;
if (wq->sq.flush_cidx >= wq->sq.size)
- wq->sq.flush_cidx -= wq->sq.size;
+ wq->sq.flush_cidx -= wq->sq.size;
return flushed;
}
@@ -317,14 +322,14 @@ static void flush_completed_wrs(struct t4_wq *wq, struct t4_cq *cq)
}
static void create_read_req_cqe(struct t4_wq *wq, struct t4_cqe *hw_cqe,
- struct t4_cqe *read_cqe)
+ struct t4_cqe *read_cqe)
{
read_cqe->u.scqe.cidx = wq->sq.oldest_read->idx;
read_cqe->len = htonl(wq->sq.oldest_read->read_len);
read_cqe->header = htonl(V_CQE_QPID(CQE_QPID(hw_cqe)) |
- V_CQE_SWCQE(SW_CQE(hw_cqe)) |
- V_CQE_OPCODE(FW_RI_READ_REQ) |
- V_CQE_TYPE(1));
+ V_CQE_SWCQE(SW_CQE(hw_cqe)) |
+ V_CQE_OPCODE(FW_RI_READ_REQ) |
+ V_CQE_TYPE(1));
read_cqe->bits_type_ts = hw_cqe->bits_type_ts;
}
@@ -358,8 +363,8 @@ void c4iw_flush_hw_cq(struct c4iw_cq *chp)
struct t4_swsqe *swsqe;
int ret;
- CTR3(KTR_IW_CXGBE, "%s c4iw_cq %p cqid 0x%x", __func__, chp,
- chp->cq.cqid);
+ CTR3(KTR_IW_CXGBE, "%s cq %p cqid 0x%x", __func__, &chp->cq,
+ chp->cq.cqid);
ret = t4_next_hw_cqe(&chp->cq, &hw_cqe);
/*
@@ -381,17 +386,14 @@ void c4iw_flush_hw_cq(struct c4iw_cq *chp)
if (CQE_OPCODE(hw_cqe) == FW_RI_READ_RESP) {
- /*
- * If we have reached here because of async
+ /* If we have reached here because of async
* event or other error, and have egress error
* then drop
*/
- if (CQE_TYPE(hw_cqe) == 1) {
+ if (CQE_TYPE(hw_cqe) == 1)
goto next_cqe;
- }
- /*
- * drop peer2peer RTR reads.
+ /* drop peer2peer RTR reads.
*/
if (CQE_WRID_STAG(hw_cqe) == 1)
goto next_cqe;
@@ -424,7 +426,7 @@ void c4iw_flush_hw_cq(struct c4iw_cq *chp)
} else {
swcqe = &chp->cq.sw_queue[chp->cq.sw_pidx];
*swcqe = *hw_cqe;
- swcqe->header |= cpu_to_be32(V_CQE_SWCQE(1));
+ swcqe->header |= cpu_to_be32(V_CQE_SWCQE(1));
t4_swcq_produce(&chp->cq);
}
next_cqe:
@@ -603,7 +605,12 @@ static int poll_cq(struct t4_wq *wq, struct t4_cq *cq, struct t4_cqe *cqe,
* then we complete this with T4_ERR_MSN and mark the wq in
* error.
*/
- BUG_ON(t4_rq_empty(wq));
+
+ if (t4_rq_empty(wq)) {
+ t4_set_wq_in_error(wq);
+ ret = -EAGAIN;
+ goto skip_cqe;
+ }
if (unlikely((CQE_WRID_MSN(hw_cqe) != (wq->rq.msn)))) {
t4_set_wq_in_error(wq);
hw_cqe->header |= htonl(V_CQE_STATUS(T4_ERR_MSN));
@@ -659,7 +666,7 @@ proc_cqe:
wq->sq.in_use -= wq->sq.size + idx - wq->sq.cidx;
else
wq->sq.in_use -= idx - wq->sq.cidx;
- BUG_ON(wq->sq.in_use <= 0 || wq->sq.in_use >= wq->sq.size);
+ BUG_ON(wq->sq.in_use <= 0 && wq->sq.in_use >= wq->sq.size);
wq->sq.cidx = (uint16_t)idx;
CTR2(KTR_IW_CXGBE, "%s completing sq idx %u\n",
@@ -751,6 +758,7 @@ static int c4iw_poll_cq_one(struct c4iw_cq *chp, struct ib_wc *wc)
CQE_OPCODE(&cqe) == FW_RI_SEND_WITH_SE_INV) {
wc->ex.invalidate_rkey = CQE_WRID_STAG(&cqe);
wc->wc_flags |= IB_WC_WITH_INVALIDATE;
+ c4iw_invalidate_mr(qhp->rhp, wc->ex.invalidate_rkey);
}
} else {
switch (CQE_OPCODE(&cqe)) {
@@ -770,15 +778,16 @@ static int c4iw_poll_cq_one(struct c4iw_cq *chp, struct ib_wc *wc)
case FW_RI_SEND_WITH_SE:
wc->opcode = IB_WC_SEND;
break;
- case FW_RI_BIND_MW:
- wc->opcode = IB_WC_BIND_MW;
- break;
-
case FW_RI_LOCAL_INV:
wc->opcode = IB_WC_LOCAL_INV;
break;
case FW_RI_FAST_REGISTER:
- wc->opcode = IB_WC_FAST_REG_MR;
+ wc->opcode = IB_WC_REG_MR;
+
+ /* Invalidate the MR if the fastreg failed */
+ if (CQE_STATUS(&cqe) != T4_ERR_SUCCESS)
+ c4iw_invalidate_mr(qhp->rhp,
+ CQE_WRID_FR_STAG(&cqe));
break;
case C4IW_DRAIN_OPCODE:
wc->opcode = IB_WC_SEND;
@@ -893,9 +902,11 @@ int c4iw_destroy_cq(struct ib_cq *ib_cq)
}
struct ib_cq *
-c4iw_create_cq(struct ib_device *ibdev, struct ib_cq_init_attr *attr,
+c4iw_create_cq(struct ib_device *ibdev, const struct ib_cq_init_attr *attr,
struct ib_ucontext *ib_context, struct ib_udata *udata)
{
+ int entries = attr->cqe;
+ int vector = attr->comp_vector;
struct c4iw_dev *rhp;
struct c4iw_cq *chp;
struct c4iw_create_cq_resp uresp;
@@ -903,9 +914,10 @@ c4iw_create_cq(struct ib_device *ibdev, struct ib_cq_init_attr *attr,
int ret;
size_t memsize, hwentries;
struct c4iw_mm_entry *mm, *mm2;
- int entries = attr->cqe;
CTR3(KTR_IW_CXGBE, "%s ib_dev %p entries %d", __func__, ibdev, entries);
+ if (attr->flags)
+ return ERR_PTR(-EINVAL);
rhp = to_c4iw_dev(ibdev);
@@ -913,6 +925,7 @@ c4iw_create_cq(struct ib_device *ibdev, struct ib_cq_init_attr *attr,
if (!chp)
return ERR_PTR(-ENOMEM);
+
if (ib_context)
ucontext = to_c4iw_ucontext(ib_context);
@@ -928,9 +941,9 @@ c4iw_create_cq(struct ib_device *ibdev, struct ib_cq_init_attr *attr,
entries = roundup(entries, 16);
/*
- * Make actual HW queue 2x to avoid cidx_inc overflows.
+ * Make actual HW queue 2x to avoid cdix_inc overflows.
*/
- hwentries = entries * 2;
+ hwentries = min(entries * 2, rhp->rdev.hw_queue.t4_max_iq_size);
/*
* Make HW queue at least 64 entries so GTS updates aren't too
@@ -944,16 +957,11 @@ c4iw_create_cq(struct ib_device *ibdev, struct ib_cq_init_attr *attr,
/*
* memsize must be a multiple of the page size if its a user cq.
*/
- if (ucontext) {
+ if (ucontext)
memsize = roundup(memsize, PAGE_SIZE);
- hwentries = memsize / sizeof *chp->cq.queue;
- while (hwentries > T4_MAX_IQ_SIZE) {
- memsize -= PAGE_SIZE;
- hwentries = memsize / sizeof *chp->cq.queue;
- }
- }
chp->cq.size = hwentries;
chp->cq.memsize = memsize;
+ chp->cq.vector = vector;
ret = create_cq(&rhp->rdev, &chp->cq,
ucontext ? &ucontext->uctx : &rhp->rdev.uctx);
@@ -972,6 +980,7 @@ c4iw_create_cq(struct ib_device *ibdev, struct ib_cq_init_attr *attr,
goto err2;
if (ucontext) {
+ ret = -ENOMEM;
mm = kmalloc(sizeof *mm, GFP_KERNEL);
if (!mm)
goto err3;
@@ -1001,7 +1010,7 @@ c4iw_create_cq(struct ib_device *ibdev, struct ib_cq_init_attr *attr,
insert_mmap(ucontext, mm);
mm2->key = uresp.gts_key;
- mm2->addr = chp->cq.ugts;
+ mm2->addr = chp->cq.bar2_pa;
mm2->len = PAGE_SIZE;
insert_mmap(ucontext, mm2);
}
@@ -1032,16 +1041,16 @@ int c4iw_resize_cq(struct ib_cq *cq, int cqe, struct ib_udata *udata)
int c4iw_arm_cq(struct ib_cq *ibcq, enum ib_cq_notify_flags flags)
{
struct c4iw_cq *chp;
- int ret;
+ int ret = 0;
unsigned long flag;
chp = to_c4iw_cq(ibcq);
spin_lock_irqsave(&chp->lock, flag);
- ret = t4_arm_cq(&chp->cq,
- (flags & IB_CQ_SOLICITED_MASK) == IB_CQ_SOLICITED);
+ t4_arm_cq(&chp->cq,
+ (flags & IB_CQ_SOLICITED_MASK) == IB_CQ_SOLICITED);
+ if (flags & IB_CQ_REPORT_MISSED_EVENTS)
+ ret = t4_cq_notempty(&chp->cq);
spin_unlock_irqrestore(&chp->lock, flag);
- if (ret && !(flags & IB_CQ_REPORT_MISSED_EVENTS))
- ret = 0;
return ret;
}
#endif
diff --git a/sys/dev/cxgbe/iw_cxgbe/device.c b/sys/dev/cxgbe/iw_cxgbe/device.c
index 3c51abc..98833da 100644
--- a/sys/dev/cxgbe/iw_cxgbe/device.c
+++ b/sys/dev/cxgbe/iw_cxgbe/device.c
@@ -66,7 +66,7 @@ c4iw_release_dev_ucontext(struct c4iw_rdev *rdev,
kfree(entry);
}
- list_for_each_safe(pos, nxt, &uctx->qpids) {
+ list_for_each_safe(pos, nxt, &uctx->cqids) {
entry = list_entry(pos, struct c4iw_qid_list, entry);
list_del_init(&entry->entry);
kfree(entry);
@@ -89,22 +89,54 @@ c4iw_rdev_open(struct c4iw_rdev *rdev)
struct adapter *sc = rdev->adap;
struct sge_params *sp = &sc->params.sge;
int rc;
+ unsigned short ucq_density = 1 << sp->iq_s_qpp; /* # of user CQs/page */
+ unsigned short udb_density = 1 << sp->eq_s_qpp; /* # of user DB/page */
+
c4iw_init_dev_ucontext(rdev, &rdev->uctx);
- /* XXX: we can probably make this work */
- if (sp->eq_s_qpp > PAGE_SHIFT || sp->iq_s_qpp > PAGE_SHIFT) {
- device_printf(sc->dev,
- "doorbell density too high (eq %d, iq %d, pg %d).\n",
- sp->eq_s_qpp, sp->eq_s_qpp, PAGE_SHIFT);
+ /*
+ * This implementation assumes udb_density == ucq_density! Eventually
+ * we might need to support this but for now fail the open. Also the
+ * cqid and qpid range must match for now.
+ */
+ if (udb_density != ucq_density) {
+ device_printf(sc->dev, "unsupported udb/ucq densities %u/%u\n",
+ udb_density, ucq_density);
+ rc = -EINVAL;
+ goto err1;
+ }
+ if (sc->vres.qp.start != sc->vres.cq.start ||
+ sc->vres.qp.size != sc->vres.cq.size) {
+ device_printf(sc->dev, "%s: unsupported qp and cq id ranges "
+ "qp start %u size %u cq start %u size %u\n", __func__,
+ sc->vres.qp.start, sc->vres.qp.size, sc->vres.cq.start,
+ sc->vres.cq.size);
rc = -EINVAL;
goto err1;
}
rdev->qpshift = PAGE_SHIFT - sp->eq_s_qpp;
- rdev->qpmask = (1 << sp->eq_s_qpp) - 1;
+ rdev->qpmask = udb_density - 1;
rdev->cqshift = PAGE_SHIFT - sp->iq_s_qpp;
- rdev->cqmask = (1 << sp->iq_s_qpp) - 1;
+ rdev->cqmask = ucq_density - 1;
+ CTR5(KTR_IW_CXGBE, "%s dev %s stag start 0x%0x size 0x%0x num stags %d",
+ __func__, device_get_nameunit(sc->dev), sc->vres.stag.start,
+ sc->vres.stag.size, c4iw_num_stags(rdev));
+ CTR5(KTR_IW_CXGBE, "%s pbl start 0x%0x size 0x%0x"
+ " rq start 0x%0x size 0x%0x", __func__,
+ sc->vres.pbl.start, sc->vres.pbl.size,
+ sc->vres.rq.start, sc->vres.rq.size);
+ CTR5(KTR_IW_CXGBE, "%s:qp qid start %u size %u cq qid start %u size %u",
+ __func__, sc->vres.qp.start, sc->vres.qp.size,
+ sc->vres.cq.start, sc->vres.cq.size);
+ /*TODO
+ CTR5(KTR_IW_CXGBE, "%s udb %pR db_reg %p gts_reg %p"
+ "qpmask 0x%x cqmask 0x%x", __func__,
+ db_reg,gts_reg,rdev->qpmask, rdev->cqmask);
+ */
+
+
if (c4iw_num_stags(rdev) == 0) {
rc = -EINVAL;
@@ -132,8 +164,34 @@ c4iw_rdev_open(struct c4iw_rdev *rdev)
device_printf(sc->dev, "error %d initializing rqt pool\n", rc);
goto err3;
}
-
+ rdev->status_page = (struct t4_dev_status_page *)
+ __get_free_page(GFP_KERNEL);
+ if (!rdev->status_page) {
+ rc = -ENOMEM;
+ goto err4;
+ }
+ rdev->status_page->qp_start = sc->vres.qp.start;
+ rdev->status_page->qp_size = sc->vres.qp.size;
+ rdev->status_page->cq_start = sc->vres.cq.start;
+ rdev->status_page->cq_size = sc->vres.cq.size;
+
+ /* T5 and above devices don't need Doorbell recovery logic,
+ * so db_off is always set to '0'.
+ */
+ rdev->status_page->db_off = 0;
+
+ rdev->status_page->wc_supported = rdev->adap->iwt.wc_en;
+
+ rdev->free_workq = create_singlethread_workqueue("iw_cxgb4_free");
+ if (!rdev->free_workq) {
+ rc = -ENOMEM;
+ goto err5;
+ }
return (0);
+err5:
+ free_page((unsigned long)rdev->status_page);
+err4:
+ c4iw_rqtpool_destroy(rdev);
err3:
c4iw_pblpool_destroy(rdev);
err2:
@@ -144,6 +202,7 @@ err1:
static void c4iw_rdev_close(struct c4iw_rdev *rdev)
{
+ free_page((unsigned long)rdev->status_page);
c4iw_pblpool_destroy(rdev);
c4iw_rqtpool_destroy(rdev);
c4iw_destroy_resource(&rdev->resource);
@@ -173,6 +232,34 @@ c4iw_alloc(struct adapter *sc)
}
iwsc->rdev.adap = sc;
+ /* init various hw-queue params based on lld info */
+ CTR3(KTR_IW_CXGBE, "%s: Ing. padding boundary is %d, "
+ "egrsstatuspagesize = %d", __func__,
+ sc->params.sge.pad_boundary,
+ sc->params.sge.spg_len);
+
+ iwsc->rdev.hw_queue.t4_eq_status_entries =
+ sc->params.sge.spg_len / EQ_ESIZE;
+ iwsc->rdev.hw_queue.t4_max_eq_size = 65520;
+ iwsc->rdev.hw_queue.t4_max_iq_size = 65520;
+ iwsc->rdev.hw_queue.t4_max_rq_size = 8192 -
+ iwsc->rdev.hw_queue.t4_eq_status_entries - 1;
+ iwsc->rdev.hw_queue.t4_max_sq_size =
+ iwsc->rdev.hw_queue.t4_max_eq_size -
+ iwsc->rdev.hw_queue.t4_eq_status_entries - 1;
+ iwsc->rdev.hw_queue.t4_max_qp_depth =
+ iwsc->rdev.hw_queue.t4_max_rq_size;
+ iwsc->rdev.hw_queue.t4_max_cq_depth =
+ iwsc->rdev.hw_queue.t4_max_iq_size - 2;
+ iwsc->rdev.hw_queue.t4_stat_len = iwsc->rdev.adap->params.sge.spg_len;
+
+ /* As T5 and above devices support BAR2 kernel doorbells & WC, we map
+ * all of BAR2, for both User and Kernel Doorbells-GTS.
+ */
+ iwsc->rdev.bar2_kva = (void __iomem *)((u64)iwsc->rdev.adap->udbs_base);
+ iwsc->rdev.bar2_pa = vtophys(iwsc->rdev.adap->udbs_base);
+ iwsc->rdev.bar2_len = rman_get_size(iwsc->rdev.adap->udbs_res);
+
rc = c4iw_rdev_open(&iwsc->rdev);
if (rc != 0) {
device_printf(sc->dev, "Unable to open CXIO rdev (%d)\n", rc);
@@ -185,6 +272,7 @@ c4iw_alloc(struct adapter *sc)
idr_init(&iwsc->mmidr);
spin_lock_init(&iwsc->lock);
mutex_init(&iwsc->rdev.stats.lock);
+ iwsc->avail_ird = iwsc->rdev.adap->params.max_ird_adapter;
return (iwsc);
}
@@ -208,6 +296,12 @@ c4iw_activate(struct adapter *sc)
ASSERT_SYNCHRONIZED_OP(sc);
+ if (is_t4(sc)) {
+ device_printf(sc->dev, "No iWARP support for T4 devices, "
+ "please install T5 or above devices.\n");
+ return (ENOSYS);
+ }
+
if (uld_active(sc, ULD_IWARP)) {
KASSERT(0, ("%s: RDMA already eanbled on sc %p", __func__, sc));
return (0);
@@ -330,7 +424,7 @@ c4iw_modevent(module_t mod, int cmd, void *arg)
case MOD_LOAD:
rc = c4iw_mod_load();
if (rc == 0)
- printf("iw_cxgbe: Chelsio T4/T5/T6 RDMA driver loaded.\n");
+ printf("iw_cxgbe: Chelsio T5/T6 RDMA driver loaded.\n");
break;
case MOD_UNLOAD:
diff --git a/sys/dev/cxgbe/iw_cxgbe/iw_cxgbe.h b/sys/dev/cxgbe/iw_cxgbe/iw_cxgbe.h
index c74133a..2f649f5 100644
--- a/sys/dev/cxgbe/iw_cxgbe/iw_cxgbe.h
+++ b/sys/dev/cxgbe/iw_cxgbe/iw_cxgbe.h
@@ -115,6 +115,7 @@ struct c4iw_dev_ucontext {
enum c4iw_rdev_flags {
T4_FATAL_ERROR = (1<<0),
+ T4_STATUS_PAGE_DISABLED = (1<<1),
};
struct c4iw_stat {
@@ -133,6 +134,17 @@ struct c4iw_stats {
struct c4iw_stat rqt;
};
+struct c4iw_hw_queue {
+ int t4_eq_status_entries;
+ int t4_max_eq_size;
+ int t4_max_iq_size;
+ int t4_max_rq_size;
+ int t4_max_sq_size;
+ int t4_max_qp_depth;
+ int t4_max_cq_depth;
+ int t4_stat_len;
+};
+
struct c4iw_rdev {
struct adapter *adap;
struct c4iw_resource resource;
@@ -145,6 +157,12 @@ struct c4iw_rdev {
vmem_t *pbl_arena;
u32 flags;
struct c4iw_stats stats;
+ struct c4iw_hw_queue hw_queue;
+ struct t4_dev_status_page *status_page;
+ unsigned long bar2_pa;
+ void __iomem *bar2_kva;
+ unsigned int bar2_len;
+ struct workqueue_struct *free_workq;
};
static inline int c4iw_fatal_error(struct c4iw_rdev *rdev)
@@ -178,7 +196,7 @@ static inline void c4iw_wake_up(struct c4iw_wr_wait *wr_waitp, int ret)
static inline int
c4iw_wait_for_reply(struct c4iw_rdev *rdev, struct c4iw_wr_wait *wr_waitp,
- u32 hwtid, u32 qpid, const char *func)
+ u32 hwtid, u32 qpid, struct socket *so, const char *func)
{
struct adapter *sc = rdev->adap;
unsigned to = C4IW_WR_TO;
@@ -193,6 +211,17 @@ c4iw_wait_for_reply(struct c4iw_rdev *rdev, struct c4iw_wr_wait *wr_waitp,
getmicrotime(&t1);
do {
+ /* If waiting for reply in rdma_init()/rdma_fini() threads, then
+ * check if there are any connection errors.
+ */
+ if (so && so->so_error) {
+ wr_waitp->ret = -ECONNRESET;
+ CTR5(KTR_IW_CXGBE, "%s - Connection ERROR %u for sock %p"
+ "tid %u qpid %u", func,
+ so->so_error, so, hwtid, qpid);
+ break;
+ }
+
ret = wait_for_completion_timeout(&wr_waitp->completion, to);
if (!ret) {
getmicrotime(&t2);
@@ -233,6 +262,7 @@ struct c4iw_dev {
struct idr mmidr;
spinlock_t lock;
struct dentry *debugfs_root;
+ u32 avail_ird;
};
static inline struct c4iw_dev *to_c4iw_dev(struct ib_device *ibdev)
@@ -313,6 +343,13 @@ static inline void remove_handle_nolock(struct c4iw_dev *rhp,
_remove_handle(rhp, idr, id, 0);
}
+extern int c4iw_max_read_depth;
+
+static inline int cur_max_read_depth(struct c4iw_dev *dev)
+{
+ return min(dev->rdev.adap->params.max_ordird_qp, c4iw_max_read_depth);
+}
+
struct c4iw_pd {
struct ib_pd ibpd;
u32 pdid;
@@ -348,6 +385,10 @@ struct c4iw_mr {
struct c4iw_dev *rhp;
u64 kva;
struct tpt_attributes attr;
+ u64 *mpl;
+ dma_addr_t mpl_addr;
+ u32 max_mpl_len;
+ u32 mpl_len;
};
static inline struct c4iw_mr *to_c4iw_mr(struct ib_mr *ibmr)
@@ -367,20 +408,6 @@ static inline struct c4iw_mw *to_c4iw_mw(struct ib_mw *ibmw)
return container_of(ibmw, struct c4iw_mw, ibmw);
}
-struct c4iw_fr_page_list {
- struct ib_fast_reg_page_list ibpl;
- DECLARE_PCI_UNMAP_ADDR(mapping);
- dma_addr_t dma_addr;
- struct c4iw_dev *dev;
- int size;
-};
-
-static inline struct c4iw_fr_page_list *to_c4iw_fr_page_list(
- struct ib_fast_reg_page_list *ibpl)
-{
- return container_of(ibpl, struct c4iw_fr_page_list, ibpl);
-}
-
struct c4iw_cq {
struct ib_cq ibcq;
struct c4iw_dev *rhp;
@@ -432,6 +459,7 @@ struct c4iw_qp_attributes {
u8 ecode;
u16 sq_db_inc;
u16 rq_db_inc;
+ u8 send_term;
};
struct c4iw_qp {
@@ -442,10 +470,12 @@ struct c4iw_qp {
struct t4_wq wq;
spinlock_t lock;
struct mutex mutex;
- atomic_t refcnt;
+ struct kref kref;
wait_queue_head_t wait;
struct timer_list timer;
int sq_sig_all;
+ struct work_struct free_work;
+ struct c4iw_ucontext *ucontext;
};
static inline struct c4iw_qp *to_c4iw_qp(struct ib_qp *ibqp)
@@ -459,6 +489,7 @@ struct c4iw_ucontext {
u32 key;
spinlock_t mmap_lock;
struct list_head mmaps;
+ struct kref kref;
};
static inline struct c4iw_ucontext *to_c4iw_ucontext(struct ib_ucontext *c)
@@ -466,6 +497,17 @@ static inline struct c4iw_ucontext *to_c4iw_ucontext(struct ib_ucontext *c)
return container_of(c, struct c4iw_ucontext, ibucontext);
}
+void _c4iw_free_ucontext(struct kref *kref);
+
+static inline void c4iw_put_ucontext(struct c4iw_ucontext *ucontext)
+{
+ kref_put(&ucontext->kref, _c4iw_free_ucontext);
+}
+static inline void c4iw_get_ucontext(struct c4iw_ucontext *ucontext)
+{
+ kref_get(&ucontext->kref);
+}
+
struct c4iw_mm_entry {
struct list_head entry;
u64 addr;
@@ -734,7 +776,8 @@ enum c4iw_ep_flags {
RELEASE_RESOURCES = 2,
CLOSE_SENT = 3,
TIMEOUT = 4,
- QP_REFERENCED = 5
+ QP_REFERENCED = 5,
+ STOP_MPA_TIMER = 7,
};
enum c4iw_ep_history {
@@ -776,8 +819,8 @@ struct c4iw_ep_common {
enum c4iw_ep_state state;
struct kref kref;
struct mutex mutex;
- struct sockaddr_in local_addr;
- struct sockaddr_in remote_addr;
+ struct sockaddr_storage local_addr;
+ struct sockaddr_storage remote_addr;
struct c4iw_wr_wait wr_wait;
unsigned long flags;
unsigned long history;
@@ -792,11 +835,13 @@ struct c4iw_listen_ep {
struct c4iw_ep_common com;
unsigned int stid;
int backlog;
+ struct list_head listen_ep_list; /* list of all listener ep's bound
+ to one port address */
};
struct c4iw_ep {
struct c4iw_ep_common com;
- struct c4iw_ep *parent_ep;
+ struct c4iw_listen_ep *parent_ep;
struct timer_list timer;
unsigned int atid;
u32 hwtid;
@@ -852,6 +897,8 @@ typedef int (*c4iw_handler_func)(struct c4iw_dev *dev, struct mbuf *m);
int c4iw_ep_redirect(void *ctx, struct dst_entry *old, struct dst_entry *new,
struct l2t_entry *l2t);
+void c4iw_put_qpid(struct c4iw_rdev *rdev, u32 qpid,
+ struct c4iw_dev_ucontext *uctx);
u32 c4iw_get_resource(struct c4iw_id_table *id_table);
void c4iw_put_resource(struct c4iw_id_table *id_table, u32 entry);
int c4iw_init_resource(struct c4iw_rdev *rdev, u32 nr_tpt, u32 nr_pdid);
@@ -875,41 +922,30 @@ int c4iw_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr,
struct ib_send_wr **bad_wr);
int c4iw_post_receive(struct ib_qp *ibqp, struct ib_recv_wr *wr,
struct ib_recv_wr **bad_wr);
-int c4iw_bind_mw(struct ib_qp *qp, struct ib_mw *mw,
- struct ib_mw_bind *mw_bind);
int c4iw_connect(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param);
-int c4iw_create_listen_ep(struct iw_cm_id *cm_id, int backlog);
-void c4iw_destroy_listen_ep(struct iw_cm_id *cm_id);
+int c4iw_create_listen(struct iw_cm_id *cm_id, int backlog);
+int c4iw_destroy_listen(struct iw_cm_id *cm_id);
int c4iw_accept_cr(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param);
int c4iw_reject_cr(struct iw_cm_id *cm_id, const void *pdata, u8 pdata_len);
void c4iw_qp_add_ref(struct ib_qp *qp);
void c4iw_qp_rem_ref(struct ib_qp *qp);
-void c4iw_free_fastreg_pbl(struct ib_fast_reg_page_list *page_list);
-struct ib_fast_reg_page_list *c4iw_alloc_fastreg_pbl(
- struct ib_device *device,
- int page_list_len);
-struct ib_mr *c4iw_alloc_fast_reg_mr(struct ib_pd *pd, int pbl_depth);
+struct ib_mr *c4iw_alloc_mr(struct ib_pd *pd, enum ib_mr_type mr_type,
+ u32 max_num_sg);
+int c4iw_map_mr_sg(struct ib_mr *ibmr, struct scatterlist *sg,
+ int sg_nents, unsigned int *sg_offset);
int c4iw_dealloc_mw(struct ib_mw *mw);
-struct ib_mw *c4iw_alloc_mw(struct ib_pd *pd, enum ib_mw_type type);
+struct ib_mw *c4iw_alloc_mw(struct ib_pd *pd, enum ib_mw_type type,
+ struct ib_udata *udata);
struct ib_mr *c4iw_reg_user_mr(struct ib_pd *pd, u64 start, u64 length, u64
- virt, int acc, struct ib_udata *udata, int mr_id);
+ virt, int acc, struct ib_udata *udata);
struct ib_mr *c4iw_get_dma_mr(struct ib_pd *pd, int acc);
-struct ib_mr *c4iw_register_phys_mem(struct ib_pd *pd,
- struct ib_phys_buf *buffer_list,
- int num_phys_buf,
- int acc,
- u64 *iova_start);
-int c4iw_reregister_phys_mem(struct ib_mr *mr,
- int mr_rereg_mask,
- struct ib_pd *pd,
- struct ib_phys_buf *buffer_list,
- int num_phys_buf,
- int acc, u64 *iova_start);
int c4iw_dereg_mr(struct ib_mr *ib_mr);
+void c4iw_invalidate_mr(struct c4iw_dev *rhp, u32 rkey);
int c4iw_destroy_cq(struct ib_cq *ib_cq);
-struct ib_cq *c4iw_create_cq(struct ib_device *ibdev, struct ib_cq_init_attr *attr,
- struct ib_ucontext *ib_context,
- struct ib_udata *udata);
+struct ib_cq *c4iw_create_cq(struct ib_device *ibdev,
+ const struct ib_cq_init_attr *attr,
+ struct ib_ucontext *ib_context,
+ struct ib_udata *udata);
int c4iw_resize_cq(struct ib_cq *cq, int cqe, struct ib_udata *udata);
int c4iw_arm_cq(struct ib_cq *ibcq, enum ib_cq_notify_flags flags);
int c4iw_destroy_qp(struct ib_qp *ib_qp);
@@ -926,9 +962,11 @@ void c4iw_rqtpool_free(struct c4iw_rdev *rdev, u32 addr, int size);
u32 c4iw_pblpool_alloc(struct c4iw_rdev *rdev, int size);
void c4iw_pblpool_free(struct c4iw_rdev *rdev, u32 addr, int size);
int c4iw_ofld_send(struct c4iw_rdev *rdev, struct mbuf *m);
-void c4iw_flush_hw_cq(struct c4iw_cq *chp);
+void c4iw_flush_hw_cq(struct c4iw_cq *cq);
void c4iw_count_rcqes(struct t4_cq *cq, struct t4_wq *wq, int *count);
+void c4iw_count_scqes(struct t4_cq *cq, struct t4_wq *wq, int *count);
int c4iw_ep_disconnect(struct c4iw_ep *ep, int abrupt, gfp_t gfp);
+int __c4iw_ep_disconnect(struct c4iw_ep *ep, int abrupt, gfp_t gfp);
int c4iw_flush_rq(struct t4_wq *wq, struct t4_cq *cq, int count);
int c4iw_flush_sq(struct c4iw_qp *qhp);
int c4iw_ev_handler(struct sge_iq *, const struct rsp_ctrl *);
@@ -941,9 +979,9 @@ u32 c4iw_get_qpid(struct c4iw_rdev *rdev, struct c4iw_dev_ucontext *uctx);
void c4iw_put_qpid(struct c4iw_rdev *rdev, u32 qid,
struct c4iw_dev_ucontext *uctx);
void c4iw_ev_dispatch(struct c4iw_dev *dev, struct t4_cqe *err_cqe);
-void process_newconn(struct iw_cm_id *parent_cm_id,
- struct socket *child_so);
-
+void __iomem *c4iw_bar2_addrs(struct c4iw_rdev *rdev, unsigned int qid,
+ enum t4_bar2_qtype qtype,
+ unsigned int *pbar2_qid, u64 *pbar2_pa);
extern struct cxgb4_client t4c_client;
extern c4iw_handler_func c4iw_handlers[NUM_CPL_CMDS];
extern int c4iw_max_read_depth;
diff --git a/sys/dev/cxgbe/iw_cxgbe/mem.c b/sys/dev/cxgbe/iw_cxgbe/mem.c
index 27bd902..7a62e82 100644
--- a/sys/dev/cxgbe/iw_cxgbe/mem.c
+++ b/sys/dev/cxgbe/iw_cxgbe/mem.c
@@ -43,6 +43,7 @@ __FBSDID("$FreeBSD$");
#include <common/t4_msg.h>
#include "iw_cxgbe.h"
+int use_dsgl = 1;
#define T4_ULPTX_MIN_IO 32
#define C4IW_MAX_INLINE_SIZE 96
@@ -50,9 +51,7 @@ static int
mr_exceeds_hw_limits(struct c4iw_dev *dev, u64 length)
{
- return ((is_t4(dev->rdev.adap) ||
- is_t5(dev->rdev.adap)) &&
- length >= 8*1024*1024*1024ULL);
+ return (is_t5(dev->rdev.adap) && length >= 8*1024*1024*1024ULL);
}
static int
@@ -68,10 +67,8 @@ write_adapter_mem(struct c4iw_rdev *rdev, u32 addr, u32 len, void *data)
u32 cmd;
cmd = cpu_to_be32(V_ULPTX_CMD(ULP_TX_MEM_WRITE));
- if (is_t4(sc))
- cmd |= cpu_to_be32(F_ULP_MEMIO_ORDER);
- else
- cmd |= cpu_to_be32(F_T5_ULP_MEMIO_IMM);
+
+ cmd |= cpu_to_be32(F_T5_ULP_MEMIO_IMM);
addr &= 0x7FFFFFF;
CTR3(KTR_IW_CXGBE, "%s addr 0x%x len %u", __func__, addr, len);
@@ -124,7 +121,7 @@ write_adapter_mem(struct c4iw_rdev *rdev, u32 addr, u32 len, void *data)
len -= C4IW_MAX_INLINE_SIZE;
}
- ret = c4iw_wait_for_reply(rdev, &wr_wait, 0, 0, __func__);
+ ret = c4iw_wait_for_reply(rdev, &wr_wait, 0, 0, NULL, __func__);
return ret;
}
@@ -277,32 +274,6 @@ static int register_mem(struct c4iw_dev *rhp, struct c4iw_pd *php,
return ret;
}
-static int reregister_mem(struct c4iw_dev *rhp, struct c4iw_pd *php,
- struct c4iw_mr *mhp, int shift, int npages)
-{
- u32 stag;
- int ret;
-
- if (npages > mhp->attr.pbl_size)
- return -ENOMEM;
-
- stag = mhp->attr.stag;
- ret = write_tpt_entry(&rhp->rdev, 0, &stag, 1, mhp->attr.pdid,
- FW_RI_STAG_NSMR, mhp->attr.perms,
- mhp->attr.mw_bind_enable, mhp->attr.zbva,
- mhp->attr.va_fbo, mhp->attr.len, shift - 12,
- mhp->attr.pbl_size, mhp->attr.pbl_addr);
- if (ret)
- return ret;
-
- ret = finish_mem_reg(mhp, stag);
- if (ret)
- dereg_mem(&rhp->rdev, mhp->attr.stag, mhp->attr.pbl_size,
- mhp->attr.pbl_addr);
-
- return ret;
-}
-
static int alloc_pbl(struct c4iw_mr *mhp, int npages)
{
mhp->attr.pbl_addr = c4iw_pblpool_alloc(&mhp->rhp->rdev,
@@ -316,223 +287,6 @@ static int alloc_pbl(struct c4iw_mr *mhp, int npages)
return 0;
}
-static int build_phys_page_list(struct ib_phys_buf *buffer_list,
- int num_phys_buf, u64 *iova_start,
- u64 *total_size, int *npages,
- int *shift, __be64 **page_list)
-{
- u64 mask;
- int i, j, n;
-
- mask = 0;
- *total_size = 0;
- for (i = 0; i < num_phys_buf; ++i) {
- if (i != 0 && buffer_list[i].addr & ~PAGE_MASK)
- return -EINVAL;
- if (i != 0 && i != num_phys_buf - 1 &&
- (buffer_list[i].size & ~PAGE_MASK))
- return -EINVAL;
- *total_size += buffer_list[i].size;
- if (i > 0)
- mask |= buffer_list[i].addr;
- else
- mask |= buffer_list[i].addr & PAGE_MASK;
- if (i != num_phys_buf - 1)
- mask |= buffer_list[i].addr + buffer_list[i].size;
- else
- mask |= (buffer_list[i].addr + buffer_list[i].size +
- PAGE_SIZE - 1) & PAGE_MASK;
- }
-
- /* Find largest page shift we can use to cover buffers */
- for (*shift = PAGE_SHIFT; *shift < PAGE_SHIFT + M_FW_RI_TPTE_PS;
- ++(*shift))
- if ((1ULL << *shift) & mask)
- break;
-
- buffer_list[0].size += buffer_list[0].addr & ((1ULL << *shift) - 1);
- buffer_list[0].addr &= ~0ull << *shift;
-
- *npages = 0;
- for (i = 0; i < num_phys_buf; ++i)
- *npages += (buffer_list[i].size +
- (1ULL << *shift) - 1) >> *shift;
-
- if (!*npages)
- return -EINVAL;
-
- *page_list = kmalloc(sizeof(u64) * *npages, GFP_KERNEL);
- if (!*page_list)
- return -ENOMEM;
-
- n = 0;
- for (i = 0; i < num_phys_buf; ++i)
- for (j = 0;
- j < (buffer_list[i].size + (1ULL << *shift) - 1) >> *shift;
- ++j)
- (*page_list)[n++] = cpu_to_be64(buffer_list[i].addr +
- ((u64) j << *shift));
-
- CTR6(KTR_IW_CXGBE,
- "%s va 0x%llx mask 0x%llx shift %d len %lld pbl_size %d", __func__,
- (unsigned long long)*iova_start, (unsigned long long)mask, *shift,
- (unsigned long long)*total_size, *npages);
-
- return 0;
-
-}
-
-int c4iw_reregister_phys_mem(struct ib_mr *mr, int mr_rereg_mask,
- struct ib_pd *pd, struct ib_phys_buf *buffer_list,
- int num_phys_buf, int acc, u64 *iova_start)
-{
-
- struct c4iw_mr mh, *mhp;
- struct c4iw_pd *php;
- struct c4iw_dev *rhp;
- __be64 *page_list = NULL;
- int shift = 0;
- u64 total_size = 0;
- int npages = 0;
- int ret;
-
- CTR3(KTR_IW_CXGBE, "%s ib_mr %p ib_pd %p", __func__, mr, pd);
-
- /* There can be no memory windows */
- if (atomic_read(&mr->usecnt))
- return -EINVAL;
-
- mhp = to_c4iw_mr(mr);
- rhp = mhp->rhp;
- php = to_c4iw_pd(mr->pd);
-
- /* make sure we are on the same adapter */
- if (rhp != php->rhp)
- return -EINVAL;
-
- memcpy(&mh, mhp, sizeof *mhp);
-
- if (mr_rereg_mask & IB_MR_REREG_PD)
- php = to_c4iw_pd(pd);
- if (mr_rereg_mask & IB_MR_REREG_ACCESS) {
- mh.attr.perms = c4iw_ib_to_tpt_access(acc);
- mh.attr.mw_bind_enable = (acc & IB_ACCESS_MW_BIND) ==
- IB_ACCESS_MW_BIND;
- }
- if (mr_rereg_mask & IB_MR_REREG_TRANS) {
- ret = build_phys_page_list(buffer_list, num_phys_buf,
- iova_start,
- &total_size, &npages,
- &shift, &page_list);
- if (ret)
- return ret;
- }
- if (mr_exceeds_hw_limits(rhp, total_size)) {
- kfree(page_list);
- return -EINVAL;
- }
- ret = reregister_mem(rhp, php, &mh, shift, npages);
- kfree(page_list);
- if (ret)
- return ret;
- if (mr_rereg_mask & IB_MR_REREG_PD)
- mhp->attr.pdid = php->pdid;
- if (mr_rereg_mask & IB_MR_REREG_ACCESS)
- mhp->attr.perms = c4iw_ib_to_tpt_access(acc);
- if (mr_rereg_mask & IB_MR_REREG_TRANS) {
- mhp->attr.zbva = 0;
- mhp->attr.va_fbo = *iova_start;
- mhp->attr.page_size = shift - 12;
- mhp->attr.len = total_size;
- mhp->attr.pbl_size = npages;
- }
-
- return 0;
-}
-
-struct ib_mr *c4iw_register_phys_mem(struct ib_pd *pd,
- struct ib_phys_buf *buffer_list,
- int num_phys_buf, int acc, u64 *iova_start)
-{
- __be64 *page_list;
- int shift;
- u64 total_size;
- int npages;
- struct c4iw_dev *rhp;
- struct c4iw_pd *php;
- struct c4iw_mr *mhp;
- int ret;
-
- CTR2(KTR_IW_CXGBE, "%s ib_pd %p", __func__, pd);
- php = to_c4iw_pd(pd);
- rhp = php->rhp;
-
- mhp = kzalloc(sizeof(*mhp), GFP_KERNEL);
- if (!mhp)
- return ERR_PTR(-ENOMEM);
-
- mhp->rhp = rhp;
-
- /* First check that we have enough alignment */
- if ((*iova_start & ~PAGE_MASK) != (buffer_list[0].addr & ~PAGE_MASK)) {
- ret = -EINVAL;
- goto err;
- }
-
- if (num_phys_buf > 1 &&
- ((buffer_list[0].addr + buffer_list[0].size) & ~PAGE_MASK)) {
- ret = -EINVAL;
- goto err;
- }
-
- ret = build_phys_page_list(buffer_list, num_phys_buf, iova_start,
- &total_size, &npages, &shift,
- &page_list);
- if (ret)
- goto err;
-
- if (mr_exceeds_hw_limits(rhp, total_size)) {
- kfree(page_list);
- ret = -EINVAL;
- goto err;
- }
- ret = alloc_pbl(mhp, npages);
- if (ret) {
- kfree(page_list);
- goto err;
- }
-
- ret = write_pbl(&mhp->rhp->rdev, page_list, mhp->attr.pbl_addr,
- npages);
- kfree(page_list);
- if (ret)
- goto err_pbl;
-
- mhp->attr.pdid = php->pdid;
- mhp->attr.zbva = 0;
-
- mhp->attr.perms = c4iw_ib_to_tpt_access(acc);
- mhp->attr.va_fbo = *iova_start;
- mhp->attr.page_size = shift - 12;
-
- mhp->attr.len = total_size;
- mhp->attr.pbl_size = npages;
- ret = register_mem(rhp, php, mhp, shift);
- if (ret)
- goto err_pbl;
-
- return &mhp->ibmr;
-
-err_pbl:
- c4iw_pblpool_free(&mhp->rhp->rdev, mhp->attr.pbl_addr,
- mhp->attr.pbl_size << 3);
-
-err:
- kfree(mhp);
- return ERR_PTR(ret);
-
-}
-
struct ib_mr *c4iw_get_dma_mr(struct ib_pd *pd, int acc)
{
struct c4iw_dev *rhp;
@@ -556,12 +310,12 @@ struct ib_mr *c4iw_get_dma_mr(struct ib_pd *pd, int acc)
mhp->attr.zbva = 0;
mhp->attr.va_fbo = 0;
mhp->attr.page_size = 0;
- mhp->attr.len = ~0UL;
+ mhp->attr.len = ~0ULL;
mhp->attr.pbl_size = 0;
ret = write_tpt_entry(&rhp->rdev, 0, &stag, 1, php->pdid,
FW_RI_STAG_NSMR, mhp->attr.perms,
- mhp->attr.mw_bind_enable, 0, 0, ~0UL, 0, 0, 0);
+ mhp->attr.mw_bind_enable, 0, 0, ~0ULL, 0, 0, 0);
if (ret)
goto err1;
@@ -578,7 +332,7 @@ err1:
}
struct ib_mr *c4iw_reg_user_mr(struct ib_pd *pd, u64 start, u64 length,
- u64 virt, int acc, struct ib_udata *udata, int mr_id)
+ u64 virt, int acc, struct ib_udata *udata)
{
__be64 *pages;
int shift, n, len;
@@ -680,7 +434,8 @@ err:
return ERR_PTR(err);
}
-struct ib_mw *c4iw_alloc_mw(struct ib_pd *pd, enum ib_mw_type type)
+struct ib_mw *c4iw_alloc_mw(struct ib_pd *pd, enum ib_mw_type type,
+ struct ib_udata *udata)
{
struct c4iw_dev *rhp;
struct c4iw_pd *php;
@@ -689,6 +444,9 @@ struct ib_mw *c4iw_alloc_mw(struct ib_pd *pd, enum ib_mw_type type)
u32 stag = 0;
int ret;
+ if (type != IB_MW_TYPE_1)
+ return ERR_PTR(-EINVAL);
+
php = to_c4iw_pd(pd);
rhp = php->rhp;
mhp = kzalloc(sizeof(*mhp), GFP_KERNEL);
@@ -732,7 +490,9 @@ int c4iw_dealloc_mw(struct ib_mw *mw)
return 0;
}
-struct ib_mr *c4iw_alloc_fast_reg_mr(struct ib_pd *pd, int pbl_depth)
+struct ib_mr *c4iw_alloc_mr(struct ib_pd *pd,
+ enum ib_mr_type mr_type,
+ u32 max_num_sg)
{
struct c4iw_dev *rhp;
struct c4iw_pd *php;
@@ -740,28 +500,43 @@ struct ib_mr *c4iw_alloc_fast_reg_mr(struct ib_pd *pd, int pbl_depth)
u32 mmid;
u32 stag = 0;
int ret = 0;
+ int length = roundup(max_num_sg * sizeof(u64), 32);
php = to_c4iw_pd(pd);
rhp = php->rhp;
+
+ if (mr_type != IB_MR_TYPE_MEM_REG ||
+ max_num_sg > t4_max_fr_depth(
+ rhp->rdev.adap->params.ulptx_memwrite_dsgl && use_dsgl))
+ return ERR_PTR(-EINVAL);
+
mhp = kzalloc(sizeof(*mhp), GFP_KERNEL);
if (!mhp) {
ret = -ENOMEM;
goto err;
}
+ mhp->mpl = dma_alloc_coherent(rhp->ibdev.dma_device,
+ length, &mhp->mpl_addr, GFP_KERNEL);
+ if (!mhp->mpl) {
+ ret = -ENOMEM;
+ goto err_mpl;
+ }
+ mhp->max_mpl_len = length;
+
mhp->rhp = rhp;
- ret = alloc_pbl(mhp, pbl_depth);
+ ret = alloc_pbl(mhp, max_num_sg);
if (ret)
goto err1;
- mhp->attr.pbl_size = pbl_depth;
+ mhp->attr.pbl_size = max_num_sg;
ret = allocate_stag(&rhp->rdev, &stag, php->pdid,
- mhp->attr.pbl_size, mhp->attr.pbl_addr);
+ mhp->attr.pbl_size, mhp->attr.pbl_addr);
if (ret)
goto err2;
mhp->attr.pdid = php->pdid;
mhp->attr.type = FW_RI_STAG_NSMR;
mhp->attr.stag = stag;
- mhp->attr.state = 1;
+ mhp->attr.state = 0;
mmid = (stag) >> 8;
mhp->ibmr.rkey = mhp->ibmr.lkey = stag;
if (insert_handle(rhp, &rhp->mmidr, mhp, mmid)) {
@@ -769,8 +544,7 @@ struct ib_mr *c4iw_alloc_fast_reg_mr(struct ib_pd *pd, int pbl_depth)
goto err3;
}
- CTR4(KTR_IW_CXGBE, "%s mmid 0x%x mhp %p stag 0x%x", __func__, mmid, mhp,
- stag);
+ PDBG("%s mmid 0x%x mhp %p stag 0x%x\n", __func__, mmid, mhp, stag);
return &(mhp->ibmr);
err3:
dereg_mem(&rhp->rdev, stag, mhp->attr.pbl_size,
@@ -779,42 +553,36 @@ err2:
c4iw_pblpool_free(&mhp->rhp->rdev, mhp->attr.pbl_addr,
mhp->attr.pbl_size << 3);
err1:
+ dma_free_coherent(rhp->ibdev.dma_device,
+ mhp->max_mpl_len, mhp->mpl, mhp->mpl_addr);
+err_mpl:
kfree(mhp);
err:
return ERR_PTR(ret);
}
-
-struct ib_fast_reg_page_list *c4iw_alloc_fastreg_pbl(struct ib_device *device,
- int page_list_len)
+static int c4iw_set_page(struct ib_mr *ibmr, u64 addr)
{
- struct c4iw_fr_page_list *c4pl;
- struct c4iw_dev *dev = to_c4iw_dev(device);
- bus_addr_t dma_addr;
- int size = sizeof *c4pl + page_list_len * sizeof(u64);
-
- c4pl = contigmalloc(size,
- M_DEVBUF, M_NOWAIT, 0ul, ~0ul, 4096, 0);
- if (c4pl)
- dma_addr = vtophys(c4pl);
- else
- return ERR_PTR(-ENOMEM);
-
- pci_unmap_addr_set(c4pl, mapping, dma_addr);
- c4pl->dma_addr = dma_addr;
- c4pl->dev = dev;
- c4pl->size = size;
- c4pl->ibpl.page_list = (u64 *)(c4pl + 1);
- c4pl->ibpl.max_page_list_len = page_list_len;
-
- return &c4pl->ibpl;
+ struct c4iw_mr *mhp = to_c4iw_mr(ibmr);
+
+ if (unlikely(mhp->mpl_len == mhp->max_mpl_len))
+ return -ENOMEM;
+
+ mhp->mpl[mhp->mpl_len++] = addr;
+
+ return 0;
}
-void c4iw_free_fastreg_pbl(struct ib_fast_reg_page_list *ibpl)
+int c4iw_map_mr_sg(struct ib_mr *ibmr, struct scatterlist *sg,
+ int sg_nents, unsigned int *sg_offset)
{
- struct c4iw_fr_page_list *c4pl = to_c4iw_fr_page_list(ibpl);
- contigfree(c4pl, c4pl->size, M_DEVBUF);
+ struct c4iw_mr *mhp = to_c4iw_mr(ibmr);
+
+ mhp->mpl_len = 0;
+
+ return ib_sg_to_pages(ibmr, sg, sg_nents, sg_offset, c4iw_set_page);
}
+
int c4iw_dereg_mr(struct ib_mr *ib_mr)
{
struct c4iw_dev *rhp;
@@ -822,9 +590,6 @@ int c4iw_dereg_mr(struct ib_mr *ib_mr)
u32 mmid;
CTR2(KTR_IW_CXGBE, "%s ib_mr %p", __func__, ib_mr);
- /* There can be no memory windows */
- if (atomic_read(&ib_mr->usecnt))
- return -EINVAL;
mhp = to_c4iw_mr(ib_mr);
rhp = mhp->rhp;
@@ -843,4 +608,16 @@ int c4iw_dereg_mr(struct ib_mr *ib_mr)
kfree(mhp);
return 0;
}
+
+void c4iw_invalidate_mr(struct c4iw_dev *rhp, u32 rkey)
+{
+ struct c4iw_mr *mhp;
+ unsigned long flags;
+
+ spin_lock_irqsave(&rhp->lock, flags);
+ mhp = get_mhp(rhp, rkey >> 8);
+ if (mhp)
+ mhp->attr.state = 0;
+ spin_unlock_irqrestore(&rhp->lock, flags);
+}
#endif
diff --git a/sys/dev/cxgbe/iw_cxgbe/provider.c b/sys/dev/cxgbe/iw_cxgbe/provider.c
index 0cc698a..b3da809 100644
--- a/sys/dev/cxgbe/iw_cxgbe/provider.c
+++ b/sys/dev/cxgbe/iw_cxgbe/provider.c
@@ -44,7 +44,7 @@ __FBSDID("$FreeBSD$");
#include "iw_cxgbe.h"
#include "user.h"
-
+extern int use_dsgl;
static int fastreg_support = 1;
module_param(fastreg_support, int, 0644);
MODULE_PARM_DESC(fastreg_support, "Advertise fastreg support (default = 1)");
@@ -78,24 +78,40 @@ static int c4iw_multicast_detach(struct ib_qp *ibqp, union ib_gid *gid, u16 lid)
}
static int c4iw_process_mad(struct ib_device *ibdev, int mad_flags,
- u8 port_num, struct ib_wc *in_wc,
- struct ib_grh *in_grh, struct ib_mad *in_mad,
- struct ib_mad *out_mad)
+ u8 port_num, const struct ib_wc *in_wc,
+ const struct ib_grh *in_grh,
+ const struct ib_mad_hdr *in_mad,
+ size_t in_mad_size,
+ struct ib_mad_hdr *out_mad,
+ size_t *out_mad_size,
+ u16 *out_mad_pkey_index)
+
{
return -ENOSYS;
}
-static int c4iw_dealloc_ucontext(struct ib_ucontext *context)
+void _c4iw_free_ucontext(struct kref *kref)
{
- struct c4iw_dev *rhp = to_c4iw_dev(context->device);
- struct c4iw_ucontext *ucontext = to_c4iw_ucontext(context);
+ struct c4iw_ucontext *ucontext;
+ struct c4iw_dev *rhp;
struct c4iw_mm_entry *mm, *tmp;
- CTR2(KTR_IW_CXGBE, "%s context %p", __func__, context);
+ ucontext = container_of(kref, struct c4iw_ucontext, kref);
+ rhp = to_c4iw_dev(ucontext->ibucontext.device);
+
+ CTR2(KTR_IW_CXGBE, "%s ucontext %p", __func__, ucontext);
list_for_each_entry_safe(mm, tmp, &ucontext->mmaps, entry)
kfree(mm);
c4iw_release_dev_ucontext(&rhp->rdev, &ucontext->uctx);
kfree(ucontext);
+}
+
+static int c4iw_dealloc_ucontext(struct ib_ucontext *context)
+{
+ struct c4iw_ucontext *ucontext = to_c4iw_ucontext(context);
+
+ CTR2(KTR_IW_CXGBE, "%s context %p", __func__, context);
+ c4iw_put_ucontext(ucontext);
return 0;
}
@@ -104,23 +120,60 @@ static struct ib_ucontext *c4iw_alloc_ucontext(struct ib_device *ibdev,
{
struct c4iw_ucontext *context;
struct c4iw_dev *rhp = to_c4iw_dev(ibdev);
+ static int warned;
+ struct c4iw_alloc_ucontext_resp uresp;
+ int ret = 0;
+ struct c4iw_mm_entry *mm = NULL;
- CTR2(KTR_IW_CXGBE, "%s ibdev %p", __func__, ibdev);
+ PDBG("%s ibdev %p\n", __func__, ibdev);
context = kzalloc(sizeof(*context), GFP_KERNEL);
- if (!context)
- return ERR_PTR(-ENOMEM);
+ if (!context) {
+ ret = -ENOMEM;
+ goto err;
+ }
+
c4iw_init_dev_ucontext(&rhp->rdev, &context->uctx);
INIT_LIST_HEAD(&context->mmaps);
spin_lock_init(&context->mmap_lock);
- return &context->ibucontext;
-}
+ kref_init(&context->kref);
+
+ if (udata->outlen < sizeof(uresp) - sizeof(uresp.reserved)) {
+ if (!warned++)
+ log(LOG_ERR, "%s Warning - downlevel libcxgb4 "
+ "(non-fatal), device status page disabled.\n",
+ __func__);
+ rhp->rdev.flags |= T4_STATUS_PAGE_DISABLED;
+ } else {
-#ifdef DOT5
-static inline pgprot_t t4_pgprot_wc(pgprot_t prot)
-{
- return pgprot_writecombine(prot);
+ mm = kmalloc(sizeof *mm, GFP_KERNEL);
+ if (!mm)
+ goto err_free;
+
+ uresp.status_page_size = PAGE_SIZE;
+
+ spin_lock(&context->mmap_lock);
+ uresp.status_page_key = context->key;
+ context->key += PAGE_SIZE;
+ spin_unlock(&context->mmap_lock);
+
+ ret = ib_copy_to_udata(udata, &uresp,
+ sizeof(uresp) - sizeof(uresp.reserved));
+ if (ret)
+ goto err_mm;
+
+ mm->key = uresp.status_page_key;
+ mm->addr = vtophys(rhp->rdev.status_page);
+ mm->len = PAGE_SIZE;
+ insert_mmap(context, mm);
+ }
+ return &context->ibucontext;
+err_mm:
+ kfree(mm);
+err_free:
+ kfree(context);
+err:
+ return ERR_PTR(ret);
}
-#endif
static int c4iw_mmap(struct ib_ucontext *context, struct vm_area_struct *vma)
{
@@ -130,12 +183,10 @@ static int c4iw_mmap(struct ib_ucontext *context, struct vm_area_struct *vma)
int ret = 0;
struct c4iw_mm_entry *mm;
struct c4iw_ucontext *ucontext;
- u64 addr, paddr;
-
- u64 va_regs_res = 0, va_udbs_res = 0;
- u64 len_regs_res = 0, len_udbs_res = 0;
+ u64 addr = 0;
- CTR3(KTR_IW_CXGBE, "%s:1 ctx %p vma %p", __func__, context, vma);
+ CTR4(KTR_IW_CXGBE, "%s:1 ctx %p vma %p, vm_start %u", __func__,
+ context, vma, vma->vm_start);
CTR4(KTR_IW_CXGBE, "%s:1a pgoff 0x%lx key 0x%x len %d", __func__,
vma->vm_pgoff, key, len);
@@ -158,59 +209,16 @@ static int c4iw_mmap(struct ib_ucontext *context, struct vm_area_struct *vma)
addr = mm->addr;
kfree(mm);
- va_regs_res = (u64)rman_get_virtual(rdev->adap->regs_res);
- len_regs_res = (u64)rman_get_size(rdev->adap->regs_res);
- va_udbs_res = (u64)rman_get_virtual(rdev->adap->udbs_res);
- len_udbs_res = (u64)rman_get_size(rdev->adap->udbs_res);
-
- CTR6(KTR_IW_CXGBE,
- "%s:4 addr %p, masync region %p:%p, udb region %p:%p", __func__,
- addr, va_regs_res, va_regs_res+len_regs_res, va_udbs_res,
- va_udbs_res+len_udbs_res);
-
- if (addr >= va_regs_res && addr < va_regs_res + len_regs_res) {
- CTR4(KTR_IW_CXGBE, "%s:5 MA_SYNC addr %p region %p, reglen %u",
- __func__, addr, va_regs_res, len_regs_res);
- /*
- * MA_SYNC register...
- */
- paddr = vtophys(addr);
- vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);
- ret = io_remap_pfn_range(vma, vma->vm_start,
- paddr >> PAGE_SHIFT,
- len, vma->vm_page_prot);
- } else {
+ /* user DB-GTS registers if addr in udbs_res range,
+ * else WQ or CQ memory.
+ * */
+ if (rdev->adap->iwt.wc_en && addr >= rdev->bar2_pa &&
+ addr < rdev->bar2_pa + rdev->bar2_len)
+ vma->vm_page_prot = t4_pgprot_wc(vma->vm_page_prot);
- if (addr >= va_udbs_res && addr < va_udbs_res + len_udbs_res) {
- /*
- * Map user DB or OCQP memory...
- */
- paddr = vtophys(addr);
- CTR4(KTR_IW_CXGBE,
- "%s:6 USER DB-GTS addr %p region %p, reglen %u",
- __func__, addr, va_udbs_res, len_udbs_res);
-#ifdef DOT5
- if (!is_t4(rdev->lldi.adapter_type) && map_udb_as_wc)
- vma->vm_page_prot = t4_pgprot_wc(vma->vm_page_prot);
- else
-#endif
- vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);
- ret = io_remap_pfn_range(vma, vma->vm_start,
- paddr >> PAGE_SHIFT,
- len, vma->vm_page_prot);
- } else {
- /*
- * Map WQ or CQ contig dma memory...
- */
- CTR4(KTR_IW_CXGBE,
- "%s:7 WQ/CQ addr %p vm_start %u vma %p", __func__,
- addr, vma->vm_start, vma);
- ret = io_remap_pfn_range(vma, vma->vm_start,
- addr >> PAGE_SHIFT,
- len, vma->vm_page_prot);
- }
- }
- CTR4(KTR_IW_CXGBE, "%s:8 ctx %p vma %p ret %u", __func__, context, vma,
+ ret = io_remap_pfn_range(vma, vma->vm_start, addr >> PAGE_SHIFT,
+ len, vma->vm_page_prot);
+ CTR4(KTR_IW_CXGBE, "%s:4 ctx %p vma %p ret %u", __func__, context, vma,
ret);
return ret;
}
@@ -303,14 +311,17 @@ c4iw_query_gid(struct ib_device *ibdev, u8 port, int index, union ib_gid *gid)
}
static int
-c4iw_query_device(struct ib_device *ibdev, struct ib_device_attr *props)
+c4iw_query_device(struct ib_device *ibdev, struct ib_device_attr *props,
+ struct ib_udata *uhw)
{
struct c4iw_dev *dev = to_c4iw_dev(ibdev);
struct adapter *sc = dev->rdev.adap;
- const int spg_ndesc = sc->params.sge.spg_len / EQ_ESIZE;
CTR3(KTR_IW_CXGBE, "%s ibdev %p, props %p", __func__, ibdev, props);
+ if (uhw->inlen || uhw->outlen)
+ return -EINVAL;
+
memset(props, 0, sizeof *props);
memcpy(&props->sys_image_guid, sc->port[0]->vi[0].hw_addr,
ETHER_ADDR_LEN);
@@ -322,7 +333,7 @@ c4iw_query_device(struct ib_device *ibdev, struct ib_device_attr *props)
props->vendor_part_id = pci_get_device(sc->dev);
props->max_mr_size = T4_MAX_MR_SIZE;
props->max_qp = sc->vres.qp.size / 2;
- props->max_qp_wr = T4_MAX_QP_DEPTH(spg_ndesc);
+ props->max_qp_wr = dev->rdev.hw_queue.t4_max_qp_depth;
props->max_sge = T4_MAX_RECV_SGE;
props->max_sge_rd = 1;
props->max_res_rd_atom = sc->params.max_ird_adapter;
@@ -330,11 +341,12 @@ c4iw_query_device(struct ib_device *ibdev, struct ib_device_attr *props)
c4iw_max_read_depth);
props->max_qp_init_rd_atom = props->max_qp_rd_atom;
props->max_cq = sc->vres.qp.size;
- props->max_cqe = T4_MAX_CQ_DEPTH;
+ props->max_cqe = dev->rdev.hw_queue.t4_max_cq_depth;
props->max_mr = c4iw_num_stags(&dev->rdev);
props->max_pd = T4_MAX_NUM_PD;
props->local_ca_ack_delay = 0;
- props->max_fast_reg_page_list_len = T4_MAX_FR_DEPTH;
+ props->max_fast_reg_page_list_len =
+ t4_max_fr_depth(sc->params.ulptx_memwrite_dsgl && use_dsgl);
return (0);
}
@@ -472,16 +484,12 @@ c4iw_register_device(struct c4iw_dev *dev)
ibdev->resize_cq = c4iw_resize_cq;
ibdev->poll_cq = c4iw_poll_cq;
ibdev->get_dma_mr = c4iw_get_dma_mr;
- ibdev->reg_phys_mr = c4iw_register_phys_mem;
- ibdev->rereg_phys_mr = c4iw_reregister_phys_mem;
ibdev->reg_user_mr = c4iw_reg_user_mr;
ibdev->dereg_mr = c4iw_dereg_mr;
ibdev->alloc_mw = c4iw_alloc_mw;
- ibdev->bind_mw = c4iw_bind_mw;
ibdev->dealloc_mw = c4iw_dealloc_mw;
- ibdev->alloc_fast_reg_mr = c4iw_alloc_fast_reg_mr;
- ibdev->alloc_fast_reg_page_list = c4iw_alloc_fastreg_pbl;
- ibdev->free_fast_reg_page_list = c4iw_free_fastreg_pbl;
+ ibdev->alloc_mr = c4iw_alloc_mr;
+ ibdev->map_mr_sg = c4iw_map_mr_sg;
ibdev->attach_mcast = c4iw_multicast_attach;
ibdev->detach_mcast = c4iw_multicast_detach;
ibdev->process_mad = c4iw_process_mad;
@@ -498,9 +506,8 @@ c4iw_register_device(struct c4iw_dev *dev)
iwcm->connect = c4iw_connect;
iwcm->accept = c4iw_accept_cr;
iwcm->reject = c4iw_reject_cr;
- iwcm->create_listen_ep = c4iw_create_listen_ep;
- iwcm->destroy_listen_ep = c4iw_destroy_listen_ep;
- iwcm->newconn = process_newconn;
+ iwcm->create_listen = c4iw_create_listen;
+ iwcm->destroy_listen = c4iw_destroy_listen;
iwcm->add_ref = c4iw_qp_add_ref;
iwcm->rem_ref = c4iw_qp_rem_ref;
iwcm->get_qp = c4iw_get_qp;
diff --git a/sys/dev/cxgbe/iw_cxgbe/qp.c b/sys/dev/cxgbe/iw_cxgbe/qp.c
index 6c743d8..9eada7e 100644
--- a/sys/dev/cxgbe/iw_cxgbe/qp.c
+++ b/sys/dev/cxgbe/iw_cxgbe/qp.c
@@ -63,55 +63,57 @@ struct cpl_set_tcb_rpl;
#include "iw_cxgbe.h"
#include "user.h"
-
+extern int use_dsgl;
static int creds(struct toepcb *toep, struct inpcb *inp, size_t wrsize);
+static int max_fr_immd = T4_MAX_FR_IMMD;//SYSCTL parameter later...
-
-static void set_state(struct c4iw_qp *qhp, enum c4iw_qp_state state)
+static int alloc_ird(struct c4iw_dev *dev, u32 ird)
{
- unsigned long flag;
- spin_lock_irqsave(&qhp->lock, flag);
- qhp->attr.state = state;
- spin_unlock_irqrestore(&qhp->lock, flag);
-}
+ int ret = 0;
-static void dealloc_host_sq(struct c4iw_rdev *rdev, struct t4_sq *sq)
-{
+ spin_lock_irq(&dev->lock);
+ if (ird <= dev->avail_ird)
+ dev->avail_ird -= ird;
+ else
+ ret = -ENOMEM;
+ spin_unlock_irq(&dev->lock);
+
+ if (ret)
+ log(LOG_WARNING, "%s: device IRD resources exhausted\n",
+ device_get_nameunit(dev->rdev.adap->dev));
- contigfree(sq->queue, sq->memsize, M_DEVBUF);
+ return ret;
}
-static void dealloc_sq(struct c4iw_rdev *rdev, struct t4_sq *sq)
+static void free_ird(struct c4iw_dev *dev, int ird)
{
-
- dealloc_host_sq(rdev, sq);
+ spin_lock_irq(&dev->lock);
+ dev->avail_ird += ird;
+ spin_unlock_irq(&dev->lock);
}
-static int alloc_host_sq(struct c4iw_rdev *rdev, struct t4_sq *sq)
+static void set_state(struct c4iw_qp *qhp, enum c4iw_qp_state state)
{
- sq->queue = contigmalloc(sq->memsize, M_DEVBUF, M_NOWAIT, 0ul, ~0ul,
- 4096, 0);
-
- if (sq->queue)
- sq->dma_addr = vtophys(sq->queue);
- else
- return -ENOMEM;
- sq->phys_addr = vtophys(sq->queue);
- pci_unmap_addr_set(sq, mapping, sq->dma_addr);
- CTR4(KTR_IW_CXGBE, "%s sq %p dma_addr %p phys_addr %p", __func__,
- sq->queue, sq->dma_addr, sq->phys_addr);
- return 0;
+ unsigned long flag;
+ spin_lock_irqsave(&qhp->lock, flag);
+ qhp->attr.state = state;
+ spin_unlock_irqrestore(&qhp->lock, flag);
}
static int destroy_qp(struct c4iw_rdev *rdev, struct t4_wq *wq,
struct c4iw_dev_ucontext *uctx)
{
+ struct c4iw_dev *rhp = rdev_to_c4iw_dev(rdev);
/*
* uP clears EQ contexts when the connection exits rdma mode,
* so no need to post a RESET WR for these EQs.
*/
- contigfree(wq->rq.queue, wq->rq.memsize, M_DEVBUF);
- dealloc_sq(rdev, &wq->sq);
+ dma_free_coherent(rhp->ibdev.dma_device,
+ wq->rq.memsize, wq->rq.queue,
+ dma_unmap_addr(&wq->rq, mapping));
+ dma_free_coherent(rhp->ibdev.dma_device,
+ wq->sq.memsize, wq->sq.queue,
+ dma_unmap_addr(&wq->sq, mapping));
c4iw_rqtpool_free(rdev, wq->rq.rqt_hwaddr, wq->rq.rqt_size);
kfree(wq->rq.sw_rq);
kfree(wq->sq.sw_sq);
@@ -125,73 +127,107 @@ static int create_qp(struct c4iw_rdev *rdev, struct t4_wq *wq,
struct c4iw_dev_ucontext *uctx)
{
struct adapter *sc = rdev->adap;
+ struct c4iw_dev *rhp = rdev_to_c4iw_dev(rdev);
int user = (uctx != &rdev->uctx);
struct fw_ri_res_wr *res_wr;
struct fw_ri_res *res;
int wr_len;
struct c4iw_wr_wait wr_wait;
- int ret;
+ int ret = 0;
int eqsize;
struct wrqe *wr;
- const int spg_ndesc = sc->params.sge.spg_len / EQ_ESIZE;
+ u64 sq_bar2_qoffset = 0, rq_bar2_qoffset = 0;
wq->sq.qid = c4iw_get_qpid(rdev, uctx);
if (!wq->sq.qid)
return -ENOMEM;
wq->rq.qid = c4iw_get_qpid(rdev, uctx);
- if (!wq->rq.qid)
- goto err1;
+ if (!wq->rq.qid) {
+ ret = -ENOMEM;
+ goto free_sq_qid;
+ }
if (!user) {
wq->sq.sw_sq = kzalloc(wq->sq.size * sizeof *wq->sq.sw_sq,
GFP_KERNEL);
- if (!wq->sq.sw_sq)
- goto err2;
+ if (!wq->sq.sw_sq) {
+ ret = -ENOMEM;
+ goto free_rq_qid;
+ }
wq->rq.sw_rq = kzalloc(wq->rq.size * sizeof *wq->rq.sw_rq,
GFP_KERNEL);
- if (!wq->rq.sw_rq)
- goto err3;
+ if (!wq->rq.sw_rq) {
+ ret = -ENOMEM;
+ goto free_sw_sq;
+ }
}
- /* RQT must be a power of 2. */
- wq->rq.rqt_size = roundup_pow_of_two(wq->rq.size);
+ /*
+ * RQT must be a power of 2 and at least 16 deep.
+ */
+ wq->rq.rqt_size = roundup_pow_of_two(max_t(u16, wq->rq.size, 16));
wq->rq.rqt_hwaddr = c4iw_rqtpool_alloc(rdev, wq->rq.rqt_size);
- if (!wq->rq.rqt_hwaddr)
- goto err4;
-
- if (alloc_host_sq(rdev, &wq->sq))
- goto err5;
+ if (!wq->rq.rqt_hwaddr) {
+ ret = -ENOMEM;
+ goto free_sw_rq;
+ }
+ /*QP memory, allocate DMAable memory for Send & Receive Queues */
+ wq->sq.queue = dma_alloc_coherent(rhp->ibdev.dma_device, wq->sq.memsize,
+ &(wq->sq.dma_addr), GFP_KERNEL);
+ if (!wq->sq.queue) {
+ ret = -ENOMEM;
+ goto free_hwaddr;
+ }
+ wq->sq.phys_addr = vtophys(wq->sq.queue);
+ dma_unmap_addr_set(&wq->sq, mapping, wq->sq.dma_addr);
memset(wq->sq.queue, 0, wq->sq.memsize);
- pci_unmap_addr_set(&wq->sq, mapping, wq->sq.dma_addr);
-
- wq->rq.queue = contigmalloc(wq->rq.memsize,
- M_DEVBUF, M_NOWAIT, 0ul, ~0ul, 4096, 0);
- if (wq->rq.queue)
- wq->rq.dma_addr = vtophys(wq->rq.queue);
- else
- goto err6;
- CTR5(KTR_IW_CXGBE,
- "%s sq base va 0x%p pa 0x%llx rq base va 0x%p pa 0x%llx", __func__,
- wq->sq.queue, (unsigned long long)vtophys(wq->sq.queue),
- wq->rq.queue, (unsigned long long)vtophys(wq->rq.queue));
+
+ wq->rq.queue = dma_alloc_coherent(rhp->ibdev.dma_device,
+ wq->rq.memsize, &(wq->rq.dma_addr), GFP_KERNEL);
+ if (!wq->rq.queue) {
+ ret = -ENOMEM;
+ goto free_sq_dma;
+ }
+ wq->rq.phys_addr = vtophys(wq->rq.queue);
+ dma_unmap_addr_set(&wq->rq, mapping, wq->rq.dma_addr);
memset(wq->rq.queue, 0, wq->rq.memsize);
- pci_unmap_addr_set(&wq->rq, mapping, wq->rq.dma_addr);
- wq->db = (void *)((unsigned long)rman_get_virtual(sc->regs_res) +
- sc->sge_kdoorbell_reg);
- wq->gts = (void *)((unsigned long)rman_get_virtual(rdev->adap->regs_res)
- + sc->sge_gts_reg);
+ CTR5(KTR_IW_CXGBE,
+ "%s QP sq base va 0x%p pa 0x%llx rq base va 0x%p pa 0x%llx",
+ __func__,
+ wq->sq.queue, (unsigned long long)wq->sq.phys_addr,
+ wq->rq.queue, (unsigned long long)wq->rq.phys_addr);
+
+ /* Doorbell/WC regions, determine the BAR2 queue offset and qid. */
+ t4_bar2_sge_qregs(rdev->adap, wq->sq.qid, T4_BAR2_QTYPE_EGRESS, user,
+ &sq_bar2_qoffset, &wq->sq.bar2_qid);
+ t4_bar2_sge_qregs(rdev->adap, wq->rq.qid, T4_BAR2_QTYPE_EGRESS, user,
+ &rq_bar2_qoffset, &wq->rq.bar2_qid);
+
if (user) {
- wq->sq.udb = (u64)((char*)rman_get_virtual(rdev->adap->udbs_res) +
- (wq->sq.qid << rdev->qpshift));
- wq->sq.udb &= PAGE_MASK;
- wq->rq.udb = (u64)((char*)rman_get_virtual(rdev->adap->udbs_res) +
- (wq->rq.qid << rdev->qpshift));
- wq->rq.udb &= PAGE_MASK;
+ /* Compute BAR2 DB/WC physical address(page-aligned) for
+ * Userspace mapping.
+ */
+ wq->sq.bar2_pa = (rdev->bar2_pa + sq_bar2_qoffset) & PAGE_MASK;
+ wq->rq.bar2_pa = (rdev->bar2_pa + rq_bar2_qoffset) & PAGE_MASK;
+ CTR3(KTR_IW_CXGBE,
+ "%s BAR2 DB/WC sq base pa 0x%llx rq base pa 0x%llx",
+ __func__, (unsigned long long)wq->sq.bar2_pa,
+ (unsigned long long)wq->rq.bar2_pa);
+ } else {
+ /* Compute BAR2 DB/WC virtual address to access in kernel. */
+ wq->sq.bar2_va = (void __iomem *)((u64)rdev->bar2_kva +
+ sq_bar2_qoffset);
+ wq->rq.bar2_va = (void __iomem *)((u64)rdev->bar2_kva +
+ rq_bar2_qoffset);
+ CTR3(KTR_IW_CXGBE, "%s BAR2 DB/WC sq base va %p rq base va %p",
+ __func__, (unsigned long long)wq->sq.bar2_va,
+ (unsigned long long)wq->rq.bar2_va);
}
+
wq->rdev = rdev;
wq->rq.msn = 1;
@@ -199,8 +235,10 @@ static int create_qp(struct c4iw_rdev *rdev, struct t4_wq *wq,
wr_len = sizeof *res_wr + 2 * sizeof *res;
wr = alloc_wrqe(wr_len, &sc->sge.mgmtq);
- if (wr == NULL)
- return (0);
+ if (wr == NULL) {
+ ret = -ENOMEM;
+ goto free_rq_dma;
+ }
res_wr = wrtod(wr);
memset(res_wr, 0, wr_len);
@@ -215,7 +253,8 @@ static int create_qp(struct c4iw_rdev *rdev, struct t4_wq *wq,
res->u.sqrq.op = FW_RI_RES_OP_WRITE;
/* eqsize is the number of 64B entries plus the status page size. */
- eqsize = wq->sq.size * T4_SQ_NUM_SLOTS + spg_ndesc;
+ eqsize = wq->sq.size * T4_SQ_NUM_SLOTS +
+ rdev->hw_queue.t4_eq_status_entries;
res->u.sqrq.fetchszm_to_iqid = cpu_to_be32(
V_FW_RI_RES_WR_HOSTFCMODE(0) | /* no host cidx updates */
@@ -226,7 +265,7 @@ static int create_qp(struct c4iw_rdev *rdev, struct t4_wq *wq,
V_FW_RI_RES_WR_DCAEN(0) |
V_FW_RI_RES_WR_DCACPU(0) |
V_FW_RI_RES_WR_FBMIN(2) |
- V_FW_RI_RES_WR_FBMAX(2) |
+ V_FW_RI_RES_WR_FBMAX(3) |
V_FW_RI_RES_WR_CIDXFTHRESHO(0) |
V_FW_RI_RES_WR_CIDXFTHRESH(0) |
V_FW_RI_RES_WR_EQSIZE(eqsize));
@@ -237,7 +276,8 @@ static int create_qp(struct c4iw_rdev *rdev, struct t4_wq *wq,
res->u.sqrq.op = FW_RI_RES_OP_WRITE;
/* eqsize is the number of 64B entries plus the status page size. */
- eqsize = wq->rq.size * T4_RQ_NUM_SLOTS + spg_ndesc;
+ eqsize = wq->rq.size * T4_RQ_NUM_SLOTS +
+ rdev->hw_queue.t4_eq_status_entries;
res->u.sqrq.fetchszm_to_iqid = cpu_to_be32(
V_FW_RI_RES_WR_HOSTFCMODE(0) | /* no host cidx updates */
V_FW_RI_RES_WR_CPRIO(0) | /* don't keep in chip cache */
@@ -247,7 +287,7 @@ static int create_qp(struct c4iw_rdev *rdev, struct t4_wq *wq,
V_FW_RI_RES_WR_DCAEN(0) |
V_FW_RI_RES_WR_DCACPU(0) |
V_FW_RI_RES_WR_FBMIN(2) |
- V_FW_RI_RES_WR_FBMAX(2) |
+ V_FW_RI_RES_WR_FBMAX(3) |
V_FW_RI_RES_WR_CIDXFTHRESHO(0) |
V_FW_RI_RES_WR_CIDXFTHRESH(0) |
V_FW_RI_RES_WR_EQSIZE(eqsize));
@@ -257,31 +297,37 @@ static int create_qp(struct c4iw_rdev *rdev, struct t4_wq *wq,
c4iw_init_wr_wait(&wr_wait);
t4_wrq_tx(sc, wr);
- ret = c4iw_wait_for_reply(rdev, &wr_wait, 0, wq->sq.qid, __func__);
+ ret = c4iw_wait_for_reply(rdev, &wr_wait, 0, wq->sq.qid,
+ NULL, __func__);
if (ret)
- goto err7;
+ goto free_rq_dma;
- CTR6(KTR_IW_CXGBE,
+ CTR5(KTR_IW_CXGBE,
"%s sqid 0x%x rqid 0x%x kdb 0x%p squdb 0x%llx rqudb 0x%llx",
- __func__, wq->sq.qid, wq->rq.qid, wq->db,
- (unsigned long long)wq->sq.udb, (unsigned long long)wq->rq.udb);
+ __func__, wq->sq.qid, wq->rq.qid,
+ (unsigned long long)wq->sq.bar2_va,
+ (unsigned long long)wq->rq.bar2_va);
return 0;
-err7:
- contigfree(wq->rq.queue, wq->rq.memsize, M_DEVBUF);
-err6:
- dealloc_sq(rdev, &wq->sq);
-err5:
+free_rq_dma:
+ dma_free_coherent(rhp->ibdev.dma_device,
+ wq->rq.memsize, wq->rq.queue,
+ dma_unmap_addr(&wq->rq, mapping));
+free_sq_dma:
+ dma_free_coherent(rhp->ibdev.dma_device,
+ wq->sq.memsize, wq->sq.queue,
+ dma_unmap_addr(&wq->sq, mapping));
+free_hwaddr:
c4iw_rqtpool_free(rdev, wq->rq.rqt_hwaddr, wq->rq.rqt_size);
-err4:
+free_sw_rq:
kfree(wq->rq.sw_rq);
-err3:
+free_sw_sq:
kfree(wq->sq.sw_sq);
-err2:
+free_rq_qid:
c4iw_put_qpid(rdev, wq->rq.qid, uctx);
-err1:
+free_sq_qid:
c4iw_put_qpid(rdev, wq->sq.qid, uctx);
- return -ENOMEM;
+ return ret;
}
static int build_immd(struct t4_sq *sq, struct fw_ri_immd *immdp,
@@ -386,6 +432,8 @@ static int build_rdma_send(struct t4_sq *sq, union t4_wr *wqe,
default:
return -EINVAL;
}
+ wqe->send.r3 = 0;
+ wqe->send.r4 = 0;
plen = 0;
if (wr->num_sge) {
@@ -429,8 +477,8 @@ static int build_rdma_write(struct t4_sq *sq, union t4_wr *wqe,
if (wr->num_sge > T4_MAX_SEND_SGE)
return -EINVAL;
wqe->write.immd_data = 0;
- wqe->write.stag_sink = cpu_to_be32(wr->wr.rdma.rkey);
- wqe->write.to_sink = cpu_to_be64(wr->wr.rdma.remote_addr);
+ wqe->write.stag_sink = cpu_to_be32(rdma_wr(wr)->rkey);
+ wqe->write.to_sink = cpu_to_be64(rdma_wr(wr)->remote_addr);
if (wr->num_sge) {
if (wr->send_flags & IB_SEND_INLINE) {
ret = build_immd(sq, wqe->write.u.immd_src, wr,
@@ -466,11 +514,12 @@ static int build_rdma_read(union t4_wr *wqe, struct ib_send_wr *wr, u8 *len16)
{
if (wr->num_sge > 1)
return -EINVAL;
- if (wr->num_sge) {
- wqe->read.stag_src = cpu_to_be32(wr->wr.rdma.rkey);
- wqe->read.to_src_hi = cpu_to_be32((u32)(wr->wr.rdma.remote_addr
+ if (wr->num_sge && wr->sg_list[0].length) {
+ wqe->read.stag_src = cpu_to_be32(rdma_wr(wr)->rkey);
+ wqe->read.to_src_hi = cpu_to_be32((u32)(rdma_wr(wr)->remote_addr
>> 32));
- wqe->read.to_src_lo = cpu_to_be32((u32)wr->wr.rdma.remote_addr);
+ wqe->read.to_src_lo =
+ cpu_to_be32((u32)rdma_wr(wr)->remote_addr);
wqe->read.stag_sink = cpu_to_be32(wr->sg_list[0].lkey);
wqe->read.plen = cpu_to_be32(wr->sg_list[0].length);
wqe->read.to_sink_hi = cpu_to_be32((u32)(wr->sg_list[0].addr
@@ -506,54 +555,6 @@ static int build_rdma_recv(struct c4iw_qp *qhp, union t4_recv_wr *wqe,
return 0;
}
-static int build_fastreg(struct t4_sq *sq, union t4_wr *wqe,
- struct ib_send_wr *wr, u8 *len16)
-{
-
- struct fw_ri_immd *imdp;
- __be64 *p;
- int i;
- int pbllen = roundup(wr->wr.fast_reg.page_list_len * sizeof(u64), 32);
- int rem;
-
- if (wr->wr.fast_reg.page_list_len > T4_MAX_FR_DEPTH)
- return -EINVAL;
-
- wqe->fr.qpbinde_to_dcacpu = 0;
- wqe->fr.pgsz_shift = wr->wr.fast_reg.page_shift - 12;
- wqe->fr.addr_type = FW_RI_VA_BASED_TO;
- wqe->fr.mem_perms = c4iw_ib_to_tpt_access(wr->wr.fast_reg.access_flags);
- wqe->fr.len_hi = 0;
- wqe->fr.len_lo = cpu_to_be32(wr->wr.fast_reg.length);
- wqe->fr.stag = cpu_to_be32(wr->wr.fast_reg.rkey);
- wqe->fr.va_hi = cpu_to_be32(wr->wr.fast_reg.iova_start >> 32);
- wqe->fr.va_lo_fbo = cpu_to_be32(wr->wr.fast_reg.iova_start &
- 0xffffffff);
- WARN_ON(pbllen > T4_MAX_FR_IMMD);
- imdp = (struct fw_ri_immd *)(&wqe->fr + 1);
- imdp->op = FW_RI_DATA_IMMD;
- imdp->r1 = 0;
- imdp->r2 = 0;
- imdp->immdlen = cpu_to_be32(pbllen);
- p = (__be64 *)(imdp + 1);
- rem = pbllen;
- for (i = 0; i < wr->wr.fast_reg.page_list_len; i++) {
- *p = cpu_to_be64((u64)wr->wr.fast_reg.page_list->page_list[i]);
- rem -= sizeof *p;
- if (++p == (__be64 *)&sq->queue[sq->size])
- p = (__be64 *)sq->queue;
- }
- BUG_ON(rem < 0);
- while (rem) {
- *p = 0;
- rem -= sizeof *p;
- if (++p == (__be64 *)&sq->queue[sq->size])
- p = (__be64 *)sq->queue;
- }
- *len16 = DIV_ROUND_UP(sizeof wqe->fr + sizeof *imdp + pbllen, 16);
- return 0;
-}
-
static int build_inv_stag(union t4_wr *wqe, struct ib_send_wr *wr,
u8 *len16)
{
@@ -563,17 +564,45 @@ static int build_inv_stag(union t4_wr *wqe, struct ib_send_wr *wr,
return 0;
}
+static void free_qp_work(struct work_struct *work)
+{
+ struct c4iw_ucontext *ucontext;
+ struct c4iw_qp *qhp;
+ struct c4iw_dev *rhp;
+
+ qhp = container_of(work, struct c4iw_qp, free_work);
+ ucontext = qhp->ucontext;
+ rhp = qhp->rhp;
+
+ CTR3(KTR_IW_CXGBE, "%s qhp %p ucontext %p\n", __func__,
+ qhp, ucontext);
+ destroy_qp(&rhp->rdev, &qhp->wq,
+ ucontext ? &ucontext->uctx : &rhp->rdev.uctx);
+
+ if (ucontext)
+ c4iw_put_ucontext(ucontext);
+ kfree(qhp);
+}
+
+static void queue_qp_free(struct kref *kref)
+{
+ struct c4iw_qp *qhp;
+
+ qhp = container_of(kref, struct c4iw_qp, kref);
+ CTR2(KTR_IW_CXGBE, "%s qhp %p", __func__, qhp);
+ queue_work(qhp->rhp->rdev.free_workq, &qhp->free_work);
+}
+
void c4iw_qp_add_ref(struct ib_qp *qp)
{
CTR2(KTR_IW_CXGBE, "%s ib_qp %p", __func__, qp);
- atomic_inc(&(to_c4iw_qp(qp)->refcnt));
+ kref_get(&to_c4iw_qp(qp)->kref);
}
void c4iw_qp_rem_ref(struct ib_qp *qp)
{
CTR2(KTR_IW_CXGBE, "%s ib_qp %p", __func__, qp);
- if (atomic_dec_and_test(&(to_c4iw_qp(qp)->refcnt)))
- wake_up(&(to_c4iw_qp(qp)->wait));
+ kref_put(&to_c4iw_qp(qp)->kref, queue_qp_free);
}
static void complete_sq_drain_wr(struct c4iw_qp *qhp, struct ib_send_wr *wr)
@@ -636,6 +665,104 @@ static void complete_rq_drain_wr(struct c4iw_qp *qhp, struct ib_recv_wr *wr)
spin_unlock_irqrestore(&rchp->comp_handler_lock, flag);
}
+static void build_tpte_memreg(struct fw_ri_fr_nsmr_tpte_wr *fr,
+ struct ib_reg_wr *wr, struct c4iw_mr *mhp, u8 *len16)
+{
+ __be64 *p = (__be64 *)fr->pbl;
+
+ fr->r2 = cpu_to_be32(0);
+ fr->stag = cpu_to_be32(mhp->ibmr.rkey);
+
+ fr->tpte.valid_to_pdid = cpu_to_be32(F_FW_RI_TPTE_VALID |
+ V_FW_RI_TPTE_STAGKEY((mhp->ibmr.rkey & M_FW_RI_TPTE_STAGKEY)) |
+ V_FW_RI_TPTE_STAGSTATE(1) |
+ V_FW_RI_TPTE_STAGTYPE(FW_RI_STAG_NSMR) |
+ V_FW_RI_TPTE_PDID(mhp->attr.pdid));
+ fr->tpte.locread_to_qpid = cpu_to_be32(
+ V_FW_RI_TPTE_PERM(c4iw_ib_to_tpt_access(wr->access)) |
+ V_FW_RI_TPTE_ADDRTYPE(FW_RI_VA_BASED_TO) |
+ V_FW_RI_TPTE_PS(ilog2(wr->mr->page_size) - 12));
+ fr->tpte.nosnoop_pbladdr = cpu_to_be32(V_FW_RI_TPTE_PBLADDR(
+ PBL_OFF(&mhp->rhp->rdev, mhp->attr.pbl_addr)>>3));
+ fr->tpte.dca_mwbcnt_pstag = cpu_to_be32(0);
+ fr->tpte.len_hi = cpu_to_be32(0);
+ fr->tpte.len_lo = cpu_to_be32(mhp->ibmr.length);
+ fr->tpte.va_hi = cpu_to_be32(mhp->ibmr.iova >> 32);
+ fr->tpte.va_lo_fbo = cpu_to_be32(mhp->ibmr.iova & 0xffffffff);
+
+ p[0] = cpu_to_be64((u64)mhp->mpl[0]);
+ p[1] = cpu_to_be64((u64)mhp->mpl[1]);
+
+ *len16 = DIV_ROUND_UP(sizeof(*fr), 16);
+}
+
+static int build_memreg(struct t4_sq *sq, union t4_wr *wqe,
+ struct ib_reg_wr *wr, struct c4iw_mr *mhp, u8 *len16,
+ bool dsgl_supported)
+{
+ struct fw_ri_immd *imdp;
+ __be64 *p;
+ int i;
+ int pbllen = roundup(mhp->mpl_len * sizeof(u64), 32);
+ int rem;
+
+ if (mhp->mpl_len > t4_max_fr_depth(use_dsgl && dsgl_supported))
+ return -EINVAL;
+
+ wqe->fr.qpbinde_to_dcacpu = 0;
+ wqe->fr.pgsz_shift = ilog2(wr->mr->page_size) - 12;
+ wqe->fr.addr_type = FW_RI_VA_BASED_TO;
+ wqe->fr.mem_perms = c4iw_ib_to_tpt_access(wr->access);
+ wqe->fr.len_hi = 0;
+ wqe->fr.len_lo = cpu_to_be32(mhp->ibmr.length);
+ wqe->fr.stag = cpu_to_be32(wr->key);
+ wqe->fr.va_hi = cpu_to_be32(mhp->ibmr.iova >> 32);
+ wqe->fr.va_lo_fbo = cpu_to_be32(mhp->ibmr.iova &
+ 0xffffffff);
+
+ if (dsgl_supported && use_dsgl && (pbllen > max_fr_immd)) {
+ struct fw_ri_dsgl *sglp;
+
+ for (i = 0; i < mhp->mpl_len; i++)
+ mhp->mpl[i] =
+ (__force u64)cpu_to_be64((u64)mhp->mpl[i]);
+
+ sglp = (struct fw_ri_dsgl *)(&wqe->fr + 1);
+ sglp->op = FW_RI_DATA_DSGL;
+ sglp->r1 = 0;
+ sglp->nsge = cpu_to_be16(1);
+ sglp->addr0 = cpu_to_be64(mhp->mpl_addr);
+ sglp->len0 = cpu_to_be32(pbllen);
+
+ *len16 = DIV_ROUND_UP(sizeof(wqe->fr) + sizeof(*sglp), 16);
+ } else {
+ imdp = (struct fw_ri_immd *)(&wqe->fr + 1);
+ imdp->op = FW_RI_DATA_IMMD;
+ imdp->r1 = 0;
+ imdp->r2 = 0;
+ imdp->immdlen = cpu_to_be32(pbllen);
+ p = (__be64 *)(imdp + 1);
+ rem = pbllen;
+ for (i = 0; i < mhp->mpl_len; i++) {
+ *p = cpu_to_be64((u64)mhp->mpl[i]);
+ rem -= sizeof(*p);
+ if (++p == (__be64 *)&sq->queue[sq->size])
+ p = (__be64 *)sq->queue;
+ }
+ BUG_ON(rem < 0);
+ while (rem) {
+ *p = 0;
+ rem -= sizeof(*p);
+ if (++p == (__be64 *)&sq->queue[sq->size])
+ p = (__be64 *)sq->queue;
+ }
+ *len16 = DIV_ROUND_UP(sizeof(wqe->fr) + sizeof(*imdp)
+ + pbllen, 16);
+ }
+
+ return 0;
+}
+
int c4iw_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr,
struct ib_send_wr **bad_wr)
{
@@ -644,13 +771,15 @@ int c4iw_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr,
enum fw_wr_opcodes fw_opcode = 0;
enum fw_ri_wr_flags fw_flags;
struct c4iw_qp *qhp;
- union t4_wr *wqe;
+ union t4_wr *wqe = NULL;
u32 num_wrs;
struct t4_swsqe *swsqe;
unsigned long flag;
u16 idx = 0;
+ struct c4iw_rdev *rdev;
qhp = to_c4iw_qp(ibqp);
+ rdev = &qhp->rhp->rdev;
spin_lock_irqsave(&qhp->lock, flag);
if (t4_wq_in_error(&qhp->wq)) {
spin_unlock_irqrestore(&qhp->lock, flag);
@@ -660,6 +789,7 @@ int c4iw_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr,
num_wrs = t4_sq_avail(&qhp->wq);
if (num_wrs == 0) {
spin_unlock_irqrestore(&qhp->lock, flag);
+ *bad_wr = wr;
return -ENOMEM;
}
while (wr) {
@@ -698,10 +828,13 @@ int c4iw_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr,
case IB_WR_RDMA_READ_WITH_INV:
fw_opcode = FW_RI_RDMA_READ_WR;
swsqe->opcode = FW_RI_READ_REQ;
- if (wr->opcode == IB_WR_RDMA_READ_WITH_INV)
+ if (wr->opcode == IB_WR_RDMA_READ_WITH_INV) {
+ c4iw_invalidate_mr(qhp->rhp,
+ wr->sg_list[0].lkey);
fw_flags = FW_RI_RDMA_READ_INVALIDATE;
- else
+ } else {
fw_flags = 0;
+ }
err = build_rdma_read(wqe, wr, &len16);
if (err)
break;
@@ -709,17 +842,33 @@ int c4iw_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr,
if (!qhp->wq.sq.oldest_read)
qhp->wq.sq.oldest_read = swsqe;
break;
- case IB_WR_FAST_REG_MR:
- fw_opcode = FW_RI_FR_NSMR_WR;
+ case IB_WR_REG_MR: {
+ struct c4iw_mr *mhp = to_c4iw_mr(reg_wr(wr)->mr);
+
swsqe->opcode = FW_RI_FAST_REGISTER;
- err = build_fastreg(&qhp->wq.sq, wqe, wr, &len16);
+ if (rdev->adap->params.fr_nsmr_tpte_wr_support &&
+ !mhp->attr.state && mhp->mpl_len <= 2) {
+ fw_opcode = FW_RI_FR_NSMR_TPTE_WR;
+ build_tpte_memreg(&wqe->fr_tpte, reg_wr(wr),
+ mhp, &len16);
+ } else {
+ fw_opcode = FW_RI_FR_NSMR_WR;
+ err = build_memreg(&qhp->wq.sq, wqe, reg_wr(wr),
+ mhp, &len16,
+ rdev->adap->params.ulptx_memwrite_dsgl);
+ if (err)
+ break;
+ }
+ mhp->attr.state = 1;
break;
+ }
case IB_WR_LOCAL_INV:
if (wr->send_flags & IB_SEND_FENCE)
fw_flags |= FW_RI_LOCAL_FENCE_FLAG;
fw_opcode = FW_RI_INV_LSTAG_WR;
swsqe->opcode = FW_RI_LOCAL_INV;
err = build_inv_stag(wqe, wr, &len16);
+ c4iw_invalidate_mr(qhp->rhp, wr->ex.invalidate_rkey);
break;
default:
CTR2(KTR_IW_CXGBE, "%s post of type =%d TBD!", __func__,
@@ -749,7 +898,7 @@ int c4iw_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr,
idx += DIV_ROUND_UP(len16*16, T4_EQ_ENTRY_SIZE);
}
- t4_ring_sq_db(&qhp->wq, idx);
+ t4_ring_sq_db(&qhp->wq, idx, wqe, rdev->adap->iwt.wc_en);
spin_unlock_irqrestore(&qhp->lock, flag);
return err;
}
@@ -759,7 +908,7 @@ int c4iw_post_receive(struct ib_qp *ibqp, struct ib_recv_wr *wr,
{
int err = 0;
struct c4iw_qp *qhp;
- union t4_recv_wr *wqe;
+ union t4_recv_wr *wqe = NULL;
u32 num_wrs;
u8 len16 = 0;
unsigned long flag;
@@ -775,6 +924,7 @@ int c4iw_post_receive(struct ib_qp *ibqp, struct ib_recv_wr *wr,
num_wrs = t4_rq_avail(&qhp->wq);
if (num_wrs == 0) {
spin_unlock_irqrestore(&qhp->lock, flag);
+ *bad_wr = wr;
return -ENOMEM;
}
while (wr) {
@@ -812,16 +962,11 @@ int c4iw_post_receive(struct ib_qp *ibqp, struct ib_recv_wr *wr,
num_wrs--;
}
- t4_ring_rq_db(&qhp->wq, idx);
+ t4_ring_rq_db(&qhp->wq, idx, wqe, qhp->rhp->rdev.adap->iwt.wc_en);
spin_unlock_irqrestore(&qhp->lock, flag);
return err;
}
-int c4iw_bind_mw(struct ib_qp *qp, struct ib_mw *mw, struct ib_mw_bind *mw_bind)
-{
- return -ENOSYS;
-}
-
static inline void build_term_codes(struct t4_cqe *err_cqe, u8 *layer_type,
u8 *ecode)
{
@@ -1005,13 +1150,13 @@ static void __flush_qp(struct c4iw_qp *qhp, struct c4iw_cq *rchp,
struct c4iw_cq *schp)
{
int count;
- int flushed;
+ int rq_flushed, sq_flushed;
unsigned long flag;
CTR4(KTR_IW_CXGBE, "%s qhp %p rchp %p schp %p", __func__, qhp, rchp,
schp);
- /* locking heirarchy: cq lock first, then qp lock. */
+ /* locking hierarchy: cq lock first, then qp lock. */
spin_lock_irqsave(&rchp->lock, flag);
spin_lock(&qhp->lock);
@@ -1024,27 +1169,40 @@ static void __flush_qp(struct c4iw_qp *qhp, struct c4iw_cq *rchp,
c4iw_flush_hw_cq(rchp);
c4iw_count_rcqes(&rchp->cq, &qhp->wq, &count);
- flushed = c4iw_flush_rq(&qhp->wq, &rchp->cq, count);
+ rq_flushed = c4iw_flush_rq(&qhp->wq, &rchp->cq, count);
spin_unlock(&qhp->lock);
spin_unlock_irqrestore(&rchp->lock, flag);
- if (flushed && rchp->ibcq.comp_handler) {
- spin_lock_irqsave(&rchp->comp_handler_lock, flag);
- (*rchp->ibcq.comp_handler)(&rchp->ibcq, rchp->ibcq.cq_context);
- spin_unlock_irqrestore(&rchp->comp_handler_lock, flag);
- }
- /* locking heirarchy: cq lock first, then qp lock. */
+ /* locking hierarchy: cq lock first, then qp lock. */
spin_lock_irqsave(&schp->lock, flag);
spin_lock(&qhp->lock);
if (schp != rchp)
c4iw_flush_hw_cq(schp);
- flushed = c4iw_flush_sq(qhp);
+ sq_flushed = c4iw_flush_sq(qhp);
spin_unlock(&qhp->lock);
spin_unlock_irqrestore(&schp->lock, flag);
- if (flushed && schp->ibcq.comp_handler) {
- spin_lock_irqsave(&schp->comp_handler_lock, flag);
- (*schp->ibcq.comp_handler)(&schp->ibcq, schp->ibcq.cq_context);
- spin_unlock_irqrestore(&schp->comp_handler_lock, flag);
+
+ if (schp == rchp) {
+ if (t4_clear_cq_armed(&rchp->cq) &&
+ (rq_flushed || sq_flushed)) {
+ spin_lock_irqsave(&rchp->comp_handler_lock, flag);
+ (*rchp->ibcq.comp_handler)(&rchp->ibcq,
+ rchp->ibcq.cq_context);
+ spin_unlock_irqrestore(&rchp->comp_handler_lock, flag);
+ }
+ } else {
+ if (t4_clear_cq_armed(&rchp->cq) && rq_flushed) {
+ spin_lock_irqsave(&rchp->comp_handler_lock, flag);
+ (*rchp->ibcq.comp_handler)(&rchp->ibcq,
+ rchp->ibcq.cq_context);
+ spin_unlock_irqrestore(&rchp->comp_handler_lock, flag);
+ }
+ if (t4_clear_cq_armed(&schp->cq) && sq_flushed) {
+ spin_lock_irqsave(&schp->comp_handler_lock, flag);
+ (*schp->ibcq.comp_handler)(&schp->ibcq,
+ schp->ibcq.cq_context);
+ spin_unlock_irqrestore(&schp->comp_handler_lock, flag);
+ }
}
}
@@ -1053,8 +1211,8 @@ static void flush_qp(struct c4iw_qp *qhp)
struct c4iw_cq *rchp, *schp;
unsigned long flag;
- rchp = get_chp(qhp->rhp, qhp->attr.rcq);
- schp = get_chp(qhp->rhp, qhp->attr.scq);
+ rchp = to_c4iw_cq(qhp->ibqp.recv_cq);
+ schp = to_c4iw_cq(qhp->ibqp.send_cq);
t4_set_wq_in_error(&qhp->wq);
if (qhp->ibqp.uobject) {
@@ -1089,8 +1247,8 @@ rdma_fini(struct c4iw_dev *rhp, struct c4iw_qp *qhp, struct c4iw_ep *ep)
KASSERT(rhp == qhp->rhp && ep == qhp->ep, ("%s: EDOOFUS", __func__));
- CTR4(KTR_IW_CXGBE, "%s qhp %p qid 0x%x tid %u", __func__, qhp,
- qhp->wq.sq.qid, ep->hwtid);
+ CTR5(KTR_IW_CXGBE, "%s qhp %p qid 0x%x ep %p tid %u", __func__, qhp,
+ qhp->wq.sq.qid, ep, ep->hwtid);
wr = alloc_wrqe(sizeof(*wqe), toep->ofld_txq);
if (wr == NULL)
@@ -1115,7 +1273,7 @@ rdma_fini(struct c4iw_dev *rhp, struct c4iw_qp *qhp, struct c4iw_ep *ep)
t4_wrq_tx(sc, wr);
ret = c4iw_wait_for_reply(rdev, &ep->com.wr_wait, ep->hwtid,
- qhp->wq.sq.qid, __func__);
+ qhp->wq.sq.qid, ep->com.so, __func__);
return ret;
}
@@ -1183,13 +1341,19 @@ static int rdma_init(struct c4iw_dev *rhp, struct c4iw_qp *qhp)
struct tcpcb *tp = intotcpcb(inp);
struct toepcb *toep = tp->t_toe;
- CTR4(KTR_IW_CXGBE, "%s qhp %p qid 0x%x tid %u", __func__, qhp,
- qhp->wq.sq.qid, ep->hwtid);
+ CTR5(KTR_IW_CXGBE, "%s qhp %p qid 0x%x ep %p tid %u", __func__, qhp,
+ qhp->wq.sq.qid, ep, ep->hwtid);
wr = alloc_wrqe(sizeof(*wqe), toep->ofld_txq);
if (wr == NULL)
return (0);
wqe = wrtod(wr);
+ ret = alloc_ird(rhp, qhp->attr.max_ird);
+ if (ret) {
+ qhp->attr.max_ird = 0;
+ free_wrqe(wr);
+ return ret;
+ }
memset(wqe, 0, sizeof *wqe);
@@ -1241,14 +1405,16 @@ static int rdma_init(struct c4iw_dev *rhp, struct c4iw_qp *qhp)
ret = creds(toep, inp, sizeof(*wqe));
if (ret) {
free_wrqe(wr);
+ free_ird(rhp, qhp->attr.max_ird);
return ret;
}
t4_wrq_tx(sc, wr);
ret = c4iw_wait_for_reply(rdev, &ep->com.wr_wait, ep->hwtid,
- qhp->wq.sq.qid, __func__);
+ qhp->wq.sq.qid, ep->com.so, __func__);
toep->ulp_mode = ULP_MODE_RDMA;
+ free_ird(rhp, qhp->attr.max_ird);
return ret;
}
@@ -1293,7 +1459,7 @@ int c4iw_modify_qp(struct c4iw_dev *rhp, struct c4iw_qp *qhp,
newattr.max_ord = attrs->max_ord;
}
if (mask & C4IW_QP_ATTR_MAX_IRD) {
- if (attrs->max_ird > c4iw_max_read_depth) {
+ if (attrs->max_ird > cur_max_read_depth(rhp)) {
ret = -EINVAL;
goto out;
}
@@ -1366,10 +1532,16 @@ int c4iw_modify_qp(struct c4iw_dev *rhp, struct c4iw_qp *qhp,
qhp->attr.layer_etype = attrs->layer_etype;
qhp->attr.ecode = attrs->ecode;
ep = qhp->ep;
- if (!internal)
+ if (!internal) {
+ c4iw_get_ep(&qhp->ep->com);
terminate = 1;
- disconnect = 1;
- c4iw_get_ep(&qhp->ep->com);
+ disconnect = 1;
+ } else {
+ terminate = qhp->attr.send_term;
+ ret = rdma_fini(rhp, qhp, ep);
+ if (ret)
+ goto err;
+ }
break;
case C4IW_QP_STATE_ERROR:
t4_set_wq_in_error(&qhp->wq);
@@ -1466,7 +1638,7 @@ out:
* an abnormal close (RTS/CLOSING->ERROR).
*/
if (disconnect) {
- c4iw_ep_disconnect(ep, abort, internal ? GFP_ATOMIC :
+ __c4iw_ep_disconnect(ep, abort, internal ? GFP_ATOMIC :
GFP_KERNEL);
c4iw_put_ep(&ep->com);
}
@@ -1486,7 +1658,6 @@ int c4iw_destroy_qp(struct ib_qp *ib_qp)
struct c4iw_dev *rhp;
struct c4iw_qp *qhp;
struct c4iw_qp_attributes attrs;
- struct c4iw_ucontext *ucontext;
CTR2(KTR_IW_CXGBE, "%s ib_qp %p", __func__, ib_qp);
qhp = to_c4iw_qp(ib_qp);
@@ -1499,20 +1670,13 @@ int c4iw_destroy_qp(struct ib_qp *ib_qp)
c4iw_modify_qp(rhp, qhp, C4IW_QP_ATTR_NEXT_STATE, &attrs, 0);
wait_event(qhp->wait, !qhp->ep);
- spin_lock_irq(&rhp->lock);
- remove_handle_nolock(rhp, &rhp->qpidr, qhp->wq.sq.qid);
- spin_unlock_irq(&rhp->lock);
- atomic_dec(&qhp->refcnt);
- wait_event(qhp->wait, !atomic_read(&qhp->refcnt));
+ remove_handle(rhp, &rhp->qpidr, qhp->wq.sq.qid);
- ucontext = ib_qp->uobject ?
- to_c4iw_ucontext(ib_qp->uobject->context) : NULL;
- destroy_qp(&rhp->rdev, &qhp->wq,
- ucontext ? &ucontext->uctx : &rhp->rdev.uctx);
+ free_ird(rhp, qhp->attr.max_ird);
+ c4iw_qp_rem_ref(ib_qp);
CTR3(KTR_IW_CXGBE, "%s ib_qp %p qpid 0x%0x", __func__, ib_qp,
qhp->wq.sq.qid);
- kfree(qhp);
return 0;
}
@@ -1526,10 +1690,11 @@ c4iw_create_qp(struct ib_pd *pd, struct ib_qp_init_attr *attrs,
struct c4iw_cq *schp;
struct c4iw_cq *rchp;
struct c4iw_create_qp_resp uresp;
- int sqsize, rqsize;
+ unsigned int sqsize, rqsize;
struct c4iw_ucontext *ucontext;
- int ret, spg_ndesc;
- struct c4iw_mm_entry *mm1, *mm2, *mm3, *mm4;
+ int ret;
+ struct c4iw_mm_entry *sq_key_mm = NULL, *rq_key_mm = NULL;
+ struct c4iw_mm_entry *sq_db_key_mm = NULL, *rq_db_key_mm = NULL;
CTR2(KTR_IW_CXGBE, "%s ib_pd %p", __func__, pd);
@@ -1546,27 +1711,32 @@ c4iw_create_qp(struct ib_pd *pd, struct ib_qp_init_attr *attrs,
if (attrs->cap.max_inline_data > T4_MAX_SEND_INLINE)
return ERR_PTR(-EINVAL);
- spg_ndesc = rhp->rdev.adap->params.sge.spg_len / EQ_ESIZE;
- rqsize = roundup(attrs->cap.max_recv_wr + 1, 16);
- if (rqsize > T4_MAX_RQ_SIZE(spg_ndesc))
+ if (attrs->cap.max_recv_wr > rhp->rdev.hw_queue.t4_max_rq_size)
return ERR_PTR(-E2BIG);
+ rqsize = attrs->cap.max_recv_wr + 1;
+ if (rqsize < 8)
+ rqsize = 8;
- sqsize = roundup(attrs->cap.max_send_wr + 1, 16);
- if (sqsize > T4_MAX_SQ_SIZE(spg_ndesc))
+ if (attrs->cap.max_send_wr > rhp->rdev.hw_queue.t4_max_sq_size)
return ERR_PTR(-E2BIG);
+ sqsize = attrs->cap.max_send_wr + 1;
+ if (sqsize < 8)
+ sqsize = 8;
ucontext = pd->uobject ? to_c4iw_ucontext(pd->uobject->context) : NULL;
-
qhp = kzalloc(sizeof(*qhp), GFP_KERNEL);
if (!qhp)
return ERR_PTR(-ENOMEM);
qhp->wq.sq.size = sqsize;
- qhp->wq.sq.memsize = (sqsize + spg_ndesc) * sizeof *qhp->wq.sq.queue +
- 16 * sizeof(__be64);
+ qhp->wq.sq.memsize =
+ (sqsize + rhp->rdev.hw_queue.t4_eq_status_entries) *
+ sizeof(*qhp->wq.sq.queue) + 16 * sizeof(__be64);
qhp->wq.sq.flush_cidx = -1;
qhp->wq.rq.size = rqsize;
- qhp->wq.rq.memsize = (rqsize + spg_ndesc) * sizeof *qhp->wq.rq.queue;
+ qhp->wq.rq.memsize =
+ (rqsize + rhp->rdev.hw_queue.t4_eq_status_entries) *
+ sizeof(*qhp->wq.rq.queue);
if (ucontext) {
qhp->wq.sq.memsize = roundup(qhp->wq.sq.memsize, PAGE_SIZE);
@@ -1599,38 +1769,37 @@ c4iw_create_qp(struct ib_pd *pd, struct ib_qp_init_attr *attrs,
qhp->attr.enable_rdma_read = 1;
qhp->attr.enable_rdma_write = 1;
qhp->attr.enable_bind = 1;
- qhp->attr.max_ord = 1;
- qhp->attr.max_ird = 1;
+ qhp->attr.max_ord = 0;
+ qhp->attr.max_ird = 0;
qhp->sq_sig_all = attrs->sq_sig_type == IB_SIGNAL_ALL_WR;
spin_lock_init(&qhp->lock);
mutex_init(&qhp->mutex);
init_waitqueue_head(&qhp->wait);
- atomic_set(&qhp->refcnt, 1);
+ kref_init(&qhp->kref);
+ INIT_WORK(&qhp->free_work, free_qp_work);
- spin_lock_irq(&rhp->lock);
- ret = insert_handle_nolock(rhp, &rhp->qpidr, qhp, qhp->wq.sq.qid);
- spin_unlock_irq(&rhp->lock);
+ ret = insert_handle(rhp, &rhp->qpidr, qhp, qhp->wq.sq.qid);
if (ret)
goto err2;
if (udata) {
- mm1 = kmalloc(sizeof *mm1, GFP_KERNEL);
- if (!mm1) {
+ sq_key_mm = kmalloc(sizeof(*sq_key_mm), GFP_KERNEL);
+ if (!sq_key_mm) {
ret = -ENOMEM;
goto err3;
}
- mm2 = kmalloc(sizeof *mm2, GFP_KERNEL);
- if (!mm2) {
+ rq_key_mm = kmalloc(sizeof(*rq_key_mm), GFP_KERNEL);
+ if (!rq_key_mm) {
ret = -ENOMEM;
goto err4;
}
- mm3 = kmalloc(sizeof *mm3, GFP_KERNEL);
- if (!mm3) {
+ sq_db_key_mm = kmalloc(sizeof(*sq_db_key_mm), GFP_KERNEL);
+ if (!sq_db_key_mm) {
ret = -ENOMEM;
goto err5;
}
- mm4 = kmalloc(sizeof *mm4, GFP_KERNEL);
- if (!mm4) {
+ rq_db_key_mm = kmalloc(sizeof(*rq_db_key_mm), GFP_KERNEL);
+ if (!rq_db_key_mm) {
ret = -ENOMEM;
goto err6;
}
@@ -1643,6 +1812,7 @@ c4iw_create_qp(struct ib_pd *pd, struct ib_qp_init_attr *attrs,
uresp.rq_size = qhp->wq.rq.size;
uresp.rq_memsize = qhp->wq.rq.memsize;
spin_lock(&ucontext->mmap_lock);
+ uresp.ma_sync_key = 0;
uresp.sq_key = ucontext->key;
ucontext->key += PAGE_SIZE;
uresp.rq_key = ucontext->key;
@@ -1655,46 +1825,56 @@ c4iw_create_qp(struct ib_pd *pd, struct ib_qp_init_attr *attrs,
ret = ib_copy_to_udata(udata, &uresp, sizeof uresp);
if (ret)
goto err7;
- mm1->key = uresp.sq_key;
- mm1->addr = qhp->wq.sq.phys_addr;
- mm1->len = PAGE_ALIGN(qhp->wq.sq.memsize);
- CTR4(KTR_IW_CXGBE, "%s mm1 %x, %x, %d", __func__, mm1->key,
- mm1->addr, mm1->len);
- insert_mmap(ucontext, mm1);
- mm2->key = uresp.rq_key;
- mm2->addr = vtophys(qhp->wq.rq.queue);
- mm2->len = PAGE_ALIGN(qhp->wq.rq.memsize);
- CTR4(KTR_IW_CXGBE, "%s mm2 %x, %x, %d", __func__, mm2->key,
- mm2->addr, mm2->len);
- insert_mmap(ucontext, mm2);
- mm3->key = uresp.sq_db_gts_key;
- mm3->addr = qhp->wq.sq.udb;
- mm3->len = PAGE_SIZE;
- CTR4(KTR_IW_CXGBE, "%s mm3 %x, %x, %d", __func__, mm3->key,
- mm3->addr, mm3->len);
- insert_mmap(ucontext, mm3);
- mm4->key = uresp.rq_db_gts_key;
- mm4->addr = qhp->wq.rq.udb;
- mm4->len = PAGE_SIZE;
- CTR4(KTR_IW_CXGBE, "%s mm4 %x, %x, %d", __func__, mm4->key,
- mm4->addr, mm4->len);
- insert_mmap(ucontext, mm4);
+ sq_key_mm->key = uresp.sq_key;
+ sq_key_mm->addr = qhp->wq.sq.phys_addr;
+ sq_key_mm->len = PAGE_ALIGN(qhp->wq.sq.memsize);
+ CTR4(KTR_IW_CXGBE, "%s sq_key_mm %x, %x, %d", __func__,
+ sq_key_mm->key, sq_key_mm->addr,
+ sq_key_mm->len);
+ insert_mmap(ucontext, sq_key_mm);
+ rq_key_mm->key = uresp.rq_key;
+ rq_key_mm->addr = qhp->wq.rq.phys_addr;
+ rq_key_mm->len = PAGE_ALIGN(qhp->wq.rq.memsize);
+ CTR4(KTR_IW_CXGBE, "%s rq_key_mm %x, %x, %d", __func__,
+ rq_key_mm->key, rq_key_mm->addr,
+ rq_key_mm->len);
+ insert_mmap(ucontext, rq_key_mm);
+ sq_db_key_mm->key = uresp.sq_db_gts_key;
+ sq_db_key_mm->addr = (u64)qhp->wq.sq.bar2_pa;
+ sq_db_key_mm->len = PAGE_SIZE;
+ CTR4(KTR_IW_CXGBE, "%s sq_db_key_mm %x, %x, %d", __func__,
+ sq_db_key_mm->key, sq_db_key_mm->addr,
+ sq_db_key_mm->len);
+ insert_mmap(ucontext, sq_db_key_mm);
+ rq_db_key_mm->key = uresp.rq_db_gts_key;
+ rq_db_key_mm->addr = (u64)qhp->wq.rq.bar2_pa;
+ rq_db_key_mm->len = PAGE_SIZE;
+ CTR4(KTR_IW_CXGBE, "%s rq_db_key_mm %x, %x, %d", __func__,
+ rq_db_key_mm->key, rq_db_key_mm->addr,
+ rq_db_key_mm->len);
+ insert_mmap(ucontext, rq_db_key_mm);
+
+ c4iw_get_ucontext(ucontext);
+ qhp->ucontext = ucontext;
}
qhp->ibqp.qp_num = qhp->wq.sq.qid;
init_timer(&(qhp->timer));
- CTR5(KTR_IW_CXGBE,
- "%s qhp %p sq_num_entries %d, rq_num_entries %d qpid 0x%0x",
- __func__, qhp, qhp->attr.sq_num_entries, qhp->attr.rq_num_entries,
- qhp->wq.sq.qid);
+
+ CTR5(KTR_IW_CXGBE, "%s sq id %u size %u memsize %zu num_entries %u\n",
+ __func__, qhp->wq.sq.qid,
+ qhp->wq.sq.size, qhp->wq.sq.memsize, attrs->cap.max_send_wr);
+ CTR5(KTR_IW_CXGBE, "%s rq id %u size %u memsize %zu num_entries %u\n",
+ __func__, qhp->wq.rq.qid,
+ qhp->wq.rq.size, qhp->wq.rq.memsize, attrs->cap.max_recv_wr);
return &qhp->ibqp;
err7:
- kfree(mm4);
+ kfree(rq_db_key_mm);
err6:
- kfree(mm3);
+ kfree(sq_db_key_mm);
err5:
- kfree(mm2);
+ kfree(rq_key_mm);
err4:
- kfree(mm1);
+ kfree(sq_key_mm);
err3:
remove_handle(rhp, &rhp->qpidr, qhp->wq.sq.qid);
err2:
diff --git a/sys/dev/cxgbe/iw_cxgbe/t4.h b/sys/dev/cxgbe/iw_cxgbe/t4.h
index 3e0d7a6..375688c 100644
--- a/sys/dev/cxgbe/iw_cxgbe/t4.h
+++ b/sys/dev/cxgbe/iw_cxgbe/t4.h
@@ -33,6 +33,8 @@
#ifndef __T4_H__
#define __T4_H__
+#include "common/t4_regs_values.h"
+#include "common/t4_regs.h"
/*
* Fixme: Adding missing defines
*/
@@ -60,14 +62,8 @@
#define CIDXINC(x) ((x) << CIDXINC_SHIFT)
#define T4_MAX_NUM_PD 65536
-#define T4_MAX_EQ_SIZE 65520
-#define T4_MAX_IQ_SIZE 65520
-#define T4_MAX_RQ_SIZE(n) (8192 - (n) - 1)
-#define T4_MAX_SQ_SIZE(n) (T4_MAX_EQ_SIZE - (n) - 1)
-#define T4_MAX_QP_DEPTH(n) (T4_MAX_RQ_SIZE(n))
-#define T4_MAX_CQ_DEPTH (T4_MAX_IQ_SIZE - 2)
-#define T4_MAX_MR_SIZE (~0ULL - 1)
-#define T4_PAGESIZE_MASK 0xffffffff000 /* 4KB-8TB */
+#define T4_MAX_MR_SIZE (~0ULL)
+#define T4_PAGESIZE_MASK 0xffffffff000 /* 4KB-8TB */
#define T4_STAG_UNSET 0xffffffff
#define T4_FW_MAJ 0
#define A_PCIE_MA_SYNC 0x30b4
@@ -102,7 +98,14 @@ struct t4_status_page {
sizeof(struct fw_ri_isgl)) / sizeof(struct fw_ri_sge))
#define T4_MAX_FR_IMMD ((T4_SQ_NUM_BYTES - sizeof(struct fw_ri_fr_nsmr_wr) - \
sizeof(struct fw_ri_immd)) & ~31UL)
-#define T4_MAX_FR_DEPTH (T4_MAX_FR_IMMD / sizeof(u64))
+#define T4_MAX_FR_IMMD_DEPTH (T4_MAX_FR_IMMD / sizeof(u64))
+#define T4_MAX_FR_DSGL 1024
+#define T4_MAX_FR_DSGL_DEPTH (T4_MAX_FR_DSGL / sizeof(u64))
+
+static inline int t4_max_fr_depth(int use_dsgl)
+{
+ return use_dsgl ? T4_MAX_FR_DSGL_DEPTH : T4_MAX_FR_IMMD_DEPTH;
+}
#define T4_RQ_NUM_SLOTS 2
#define T4_RQ_NUM_BYTES (T4_EQ_ENTRY_SIZE * T4_RQ_NUM_SLOTS)
@@ -116,6 +119,7 @@ union t4_wr {
struct fw_ri_rdma_read_wr read;
struct fw_ri_bind_mw_wr bind;
struct fw_ri_fr_nsmr_wr fr;
+ struct fw_ri_fr_nsmr_tpte_wr fr_tpte;
struct fw_ri_inv_lstag_wr inv;
struct t4_status_page status;
__be64 flits[T4_EQ_ENTRY_SIZE / sizeof(__be64) * T4_SQ_NUM_SLOTS];
@@ -191,7 +195,7 @@ struct t4_cqe {
__be32 msn;
} rcqe;
struct {
- u32 nada1;
+ u32 stag;
u16 nada2;
u16 cidx;
} scqe;
@@ -254,6 +258,7 @@ struct t4_cqe {
/* used for SQ completion processing */
#define CQE_WRID_SQ_IDX(x) ((x)->u.scqe.cidx)
+#define CQE_WRID_FR_STAG(x) (be32_to_cpu((x)->u.scqe.stag))
/* generic accessor macros */
#define CQE_WRID_HI(x) ((x)->u.gen.wrid_hi)
@@ -289,24 +294,42 @@ struct t4_swsqe {
int complete;
int signaled;
u16 idx;
- int flushed;
+ int flushed;
+ struct timespec host_ts;
+ u64 sge_ts;
+};
+
+static inline pgprot_t t4_pgprot_wc(pgprot_t prot)
+{
+#if defined(__i386__) || defined(__x86_64__) || defined(CONFIG_PPC64)
+ return pgprot_writecombine(prot);
+#else
+ return pgprot_noncached(prot);
+#endif
+}
+
+enum {
+ T4_SQ_ONCHIP = (1<<0),
};
struct t4_sq {
union t4_wr *queue;
bus_addr_t dma_addr;
- DECLARE_PCI_UNMAP_ADDR(mapping);
+ DEFINE_DMA_UNMAP_ADDR(mapping);
unsigned long phys_addr;
struct t4_swsqe *sw_sq;
struct t4_swsqe *oldest_read;
- u64 udb;
+ void __iomem *bar2_va;
+ u64 bar2_pa;
size_t memsize;
+ u32 bar2_qid;
u32 qid;
u16 in_use;
u16 size;
u16 cidx;
u16 pidx;
u16 wq_pidx;
+ u16 wq_pidx_inc;
u16 flags;
short flush_cidx;
};
@@ -318,10 +341,13 @@ struct t4_swrqe {
struct t4_rq {
union t4_recv_wr *queue;
bus_addr_t dma_addr;
- DECLARE_PCI_UNMAP_ADDR(mapping);
+ DEFINE_DMA_UNMAP_ADDR(mapping);
+ unsigned long phys_addr;
struct t4_swrqe *sw_rq;
- u64 udb;
+ void __iomem *bar2_va;
+ u64 bar2_pa;
size_t memsize;
+ u32 bar2_qid;
u32 qid;
u32 msn;
u32 rqt_hwaddr;
@@ -331,13 +357,12 @@ struct t4_rq {
u16 cidx;
u16 pidx;
u16 wq_pidx;
+ u16 wq_pidx_inc;
};
struct t4_wq {
struct t4_sq sq;
struct t4_rq rq;
- void __iomem *db;
- void __iomem *gts;
struct c4iw_rdev *rdev;
int flushed;
};
@@ -387,7 +412,12 @@ static inline u16 t4_rq_host_wq_pidx(struct t4_wq *wq)
static inline u16 t4_rq_wq_size(struct t4_wq *wq)
{
- return wq->rq.size * T4_RQ_NUM_SLOTS;
+ return wq->rq.size * T4_RQ_NUM_SLOTS;
+}
+
+static inline int t4_sq_onchip(struct t4_sq *sq)
+{
+ return sq->flags & T4_SQ_ONCHIP;
}
static inline int t4_sq_empty(struct t4_wq *wq)
@@ -435,16 +465,69 @@ static inline u16 t4_sq_wq_size(struct t4_wq *wq)
return wq->sq.size * T4_SQ_NUM_SLOTS;
}
-static inline void t4_ring_sq_db(struct t4_wq *wq, u16 inc)
+/* This function copies 64 byte coalesced work request to memory
+ * mapped BAR2 space. For coalesced WRs, the SGE fetches data
+ * from the FIFO instead of from Host.
+ */
+static inline void pio_copy(u64 __iomem *dst, u64 *src)
{
+ int count = 8;
+
+ while (count) {
+ writeq(*src, dst);
+ src++;
+ dst++;
+ count--;
+ }
+}
+
+static inline void
+t4_ring_sq_db(struct t4_wq *wq, u16 inc, union t4_wr *wqe, u8 wc)
+{
+
+ /* Flush host queue memory writes. */
+ wmb();
+ if (wc && inc == 1 && wq->sq.bar2_qid == 0 && wqe) {
+ CTR2(KTR_IW_CXGBE, "%s: WC wq->sq.pidx = %d\n",
+ __func__, wq->sq.pidx);
+ pio_copy((u64 __iomem *)
+ ((u64)wq->sq.bar2_va + SGE_UDB_WCDOORBELL),
+ (u64 *)wqe);
+ } else {
+ CTR2(KTR_IW_CXGBE, "%s: DB wq->sq.pidx = %d\n",
+ __func__, wq->sq.pidx);
+ writel(V_PIDX_T5(inc) | V_QID(wq->sq.bar2_qid),
+ (void __iomem *)((u64)wq->sq.bar2_va +
+ SGE_UDB_KDOORBELL));
+ }
+
+ /* Flush user doorbell area writes. */
wmb();
- writel(QID(wq->sq.qid) | PIDX(inc), wq->db);
+ return;
}
-static inline void t4_ring_rq_db(struct t4_wq *wq, u16 inc)
+static inline void
+t4_ring_rq_db(struct t4_wq *wq, u16 inc, union t4_recv_wr *wqe, u8 wc)
{
+
+ /* Flush host queue memory writes. */
+ wmb();
+ if (wc && inc == 1 && wq->rq.bar2_qid == 0 && wqe) {
+ CTR2(KTR_IW_CXGBE, "%s: WC wq->rq.pidx = %d\n",
+ __func__, wq->rq.pidx);
+ pio_copy((u64 __iomem *)((u64)wq->rq.bar2_va +
+ SGE_UDB_WCDOORBELL), (u64 *)wqe);
+ } else {
+ CTR2(KTR_IW_CXGBE, "%s: DB wq->rq.pidx = %d\n",
+ __func__, wq->rq.pidx);
+ writel(V_PIDX_T5(inc) | V_QID(wq->rq.bar2_qid),
+ (void __iomem *)((u64)wq->rq.bar2_va +
+ SGE_UDB_KDOORBELL));
+ }
+
+ /* Flush user doorbell area writes. */
wmb();
- writel(QID(wq->rq.qid) | PIDX(inc), wq->db);
+ return;
}
static inline int t4_wq_in_error(struct t4_wq *wq)
@@ -457,17 +540,24 @@ static inline void t4_set_wq_in_error(struct t4_wq *wq)
wq->rq.queue[wq->rq.size].status.qp_err = 1;
}
+enum t4_cq_flags {
+ CQ_ARMED = 1,
+};
+
struct t4_cq {
struct t4_cqe *queue;
bus_addr_t dma_addr;
- DECLARE_PCI_UNMAP_ADDR(mapping);
+ DEFINE_DMA_UNMAP_ADDR(mapping);
struct t4_cqe *sw_queue;
- void __iomem *gts;
+ void __iomem *bar2_va;
+ u64 bar2_pa;
+ u32 bar2_qid;
struct c4iw_rdev *rdev;
- u64 ugts;
size_t memsize;
__be64 bits_type_ts;
u32 cqid;
+ u32 qid_mask;
+ int vector;
u16 size; /* including status page */
u16 cidx;
u16 sw_pidx;
@@ -476,21 +566,34 @@ struct t4_cq {
u16 cidx_inc;
u8 gen;
u8 error;
+ unsigned long flags;
};
+static inline void write_gts(struct t4_cq *cq, u32 val)
+{
+ writel(val | V_INGRESSQID(cq->bar2_qid),
+ (void __iomem *)((u64)cq->bar2_va + SGE_UDB_GTS));
+}
+
+static inline int t4_clear_cq_armed(struct t4_cq *cq)
+{
+ return test_and_clear_bit(CQ_ARMED, &cq->flags);
+}
+
static inline int t4_arm_cq(struct t4_cq *cq, int se)
{
u32 val;
+ set_bit(CQ_ARMED, &cq->flags);
while (cq->cidx_inc > CIDXINC_MASK) {
- val = SEINTARM(0) | CIDXINC(CIDXINC_MASK) | TIMERREG(7) |
- INGRESSQID(cq->cqid);
- writel(val, cq->gts);
+ val = SEINTARM(0) | CIDXINC(CIDXINC_MASK) | TIMERREG(7);
+ writel(val | V_INGRESSQID(cq->bar2_qid),
+ (void __iomem *)((u64)cq->bar2_va + SGE_UDB_GTS));
cq->cidx_inc -= CIDXINC_MASK;
}
- val = SEINTARM(se) | CIDXINC(cq->cidx_inc) | TIMERREG(6) |
- INGRESSQID(cq->cqid);
- writel(val, cq->gts);
+ val = SEINTARM(se) | CIDXINC(cq->cidx_inc) | TIMERREG(6);
+ writel(val | V_INGRESSQID(cq->bar2_qid),
+ (void __iomem *)((u64)cq->bar2_va + SGE_UDB_GTS));
cq->cidx_inc = 0;
return 0;
}
@@ -498,7 +601,12 @@ static inline int t4_arm_cq(struct t4_cq *cq, int se)
static inline void t4_swcq_produce(struct t4_cq *cq)
{
cq->sw_in_use++;
- BUG_ON(cq->sw_in_use >= cq->size);
+ if (cq->sw_in_use == cq->size) {
+ CTR2(KTR_IW_CXGBE, "%s cxgb4 sw cq overflow cqid %u\n",
+ __func__, cq->cqid);
+ cq->error = 1;
+ BUG_ON(1);
+ }
if (++cq->sw_pidx == cq->size)
cq->sw_pidx = 0;
}
@@ -517,9 +625,8 @@ static inline void t4_hwcq_consume(struct t4_cq *cq)
if (++cq->cidx_inc == (cq->size >> 4) || cq->cidx_inc == M_CIDXINC) {
u32 val;
- val = SEINTARM(0) | CIDXINC(cq->cidx_inc) | TIMERREG(7) |
- INGRESSQID(cq->cqid);
- writel(val, cq->gts);
+ val = SEINTARM(0) | CIDXINC(cq->cidx_inc) | TIMERREG(7);
+ write_gts(cq, val);
cq->cidx_inc = 0;
}
if (++cq->cidx == cq->size) {
@@ -533,6 +640,11 @@ static inline int t4_valid_cqe(struct t4_cq *cq, struct t4_cqe *cqe)
return (CQE_GENBIT(cqe) == cq->gen);
}
+static inline int t4_cq_notempty(struct t4_cq *cq)
+{
+ return cq->sw_in_use || t4_valid_cqe(cq, &cq->queue[cq->cidx]);
+}
+
static inline int t4_next_hw_cqe(struct t4_cq *cq, struct t4_cqe **cqe)
{
int ret;
@@ -547,7 +659,10 @@ static inline int t4_next_hw_cqe(struct t4_cq *cq, struct t4_cqe **cqe)
ret = -EOVERFLOW;
cq->error = 1;
printk(KERN_ERR MOD "cq overflow cqid %u\n", cq->cqid);
+ BUG_ON(1);
} else if (t4_valid_cqe(cq, &cq->queue[cq->cidx])) {
+
+ /* Ensure CQE is flushed to memory */
rmb();
*cqe = &cq->queue[cq->cidx];
ret = 0;
@@ -558,6 +673,13 @@ static inline int t4_next_hw_cqe(struct t4_cq *cq, struct t4_cqe **cqe)
static inline struct t4_cqe *t4_next_sw_cqe(struct t4_cq *cq)
{
+ if (cq->sw_in_use == cq->size) {
+ CTR2(KTR_IW_CXGBE, "%s cxgb4 sw cq overflow cqid %u\n",
+ __func__, cq->cqid);
+ cq->error = 1;
+ BUG_ON(1);
+ return NULL;
+ }
if (cq->sw_in_use)
return &cq->sw_queue[cq->sw_cidx];
return NULL;
@@ -585,4 +707,14 @@ static inline void t4_set_cq_in_error(struct t4_cq *cq)
{
((struct t4_status_page *)&cq->queue[cq->size])->qp_err = 1;
}
+struct t4_dev_status_page {
+ u8 db_off;
+ u8 wc_supported;
+ u16 pad2;
+ u32 pad3;
+ u64 qp_start;
+ u64 qp_size;
+ u64 cq_start;
+ u64 cq_size;
+};
#endif
diff --git a/sys/dev/cxgbe/iw_cxgbe/user.h b/sys/dev/cxgbe/iw_cxgbe/user.h
index d42f659..a98a300 100644
--- a/sys/dev/cxgbe/iw_cxgbe/user.h
+++ b/sys/dev/cxgbe/iw_cxgbe/user.h
@@ -34,7 +34,7 @@
#ifndef __C4IW_USER_H__
#define __C4IW_USER_H__
-#define C4IW_UVERBS_ABI_VERSION 2
+#define C4IW_UVERBS_ABI_VERSION 3
/*
* Make sure that all structs defined in this file remain laid out so
@@ -68,4 +68,10 @@ struct c4iw_create_qp_resp {
__u32 qid_mask;
__u32 flags;
};
+
+struct c4iw_alloc_ucontext_resp {
+ __u64 status_page_key;
+ __u32 status_page_size;
+ __u32 reserved; /* explicit padding (optional for i386) */
+};
#endif
diff --git a/sys/dev/cxgbe/offload.h b/sys/dev/cxgbe/offload.h
index 3eefc3b..d920268 100644
--- a/sys/dev/cxgbe/offload.h
+++ b/sys/dev/cxgbe/offload.h
@@ -151,7 +151,10 @@ struct tom_tunables {
int tx_align;
int tx_zcopy;
};
-
+/* iWARP driver tunables */
+struct iw_tunables {
+ int wc_en;
+};
#ifdef TCP_OFFLOAD
int t4_register_uld(struct uld_info *);
int t4_unregister_uld(struct uld_info *);
diff --git a/sys/dev/cxgbe/t4_main.c b/sys/dev/cxgbe/t4_main.c
index 62f08d5..87a4bf0 100644
--- a/sys/dev/cxgbe/t4_main.c
+++ b/sys/dev/cxgbe/t4_main.c
@@ -451,7 +451,7 @@ TUNABLE_INT("hw.cxgbe.iscsicaps_allowed", &t4_iscsicaps_allowed);
static int t4_fcoecaps_allowed = 0;
TUNABLE_INT("hw.cxgbe.fcoecaps_allowed", &t4_fcoecaps_allowed);
-static int t5_write_combine = 0;
+static int t5_write_combine = 1;
TUNABLE_INT("hw.cxl.write_combine", &t5_write_combine);
static int t4_num_vis = 1;
@@ -2276,6 +2276,7 @@ t4_map_bar_2(struct adapter *sc)
setbit(&sc->doorbells, DOORBELL_WCWR);
setbit(&sc->doorbells, DOORBELL_UDBWC);
} else {
+ t5_write_combine = 0;
device_printf(sc->dev,
"couldn't enable write combining: %d\n",
rc);
@@ -2285,7 +2286,10 @@ t4_map_bar_2(struct adapter *sc)
t4_write_reg(sc, A_SGE_STAT_CFG,
V_STATSOURCE_T5(7) | mode);
}
+#else
+ t5_write_combine = 0;
#endif
+ sc->iwt.wc_en = t5_write_combine;
}
return (0);
diff --git a/sys/dev/iser/icl_iser.c b/sys/dev/iser/icl_iser.c
index fa95921..257ab29 100644
--- a/sys/dev/iser/icl_iser.c
+++ b/sys/dev/iser/icl_iser.c
@@ -396,7 +396,7 @@ iser_conn_connect(struct icl_conn *ic, int domain, int socktype,
iser_conn->state = ISER_CONN_PENDING;
- ib_conn->cma_id = rdma_create_id(iser_cma_handler, (void *)iser_conn,
+ ib_conn->cma_id = rdma_create_id(&init_net, iser_cma_handler, (void *)iser_conn,
RDMA_PS_TCP, IB_QPT_RC);
if (IS_ERR(ib_conn->cma_id)) {
err = -PTR_ERR(ib_conn->cma_id);
diff --git a/sys/dev/iser/icl_iser.h b/sys/dev/iser/icl_iser.h
index d58a2e2..fa899cb 100644
--- a/sys/dev/iser/icl_iser.h
+++ b/sys/dev/iser/icl_iser.h
@@ -245,7 +245,7 @@ enum iser_desc_type {
struct iser_data_buf {
struct scatterlist sgl[ISCSI_ISER_SG_TABLESIZE];
void *sg;
- unsigned int size;
+ int size;
unsigned long data_len;
unsigned int dma_nents;
char *copy_buf;
@@ -364,12 +364,10 @@ struct iser_device {
* struct iser_reg_resources - Fast registration recources
*
* @mr: memory region
- * @frpl: fast reg page list
* @mr_valid: is mr valid indicator
*/
struct iser_reg_resources {
struct ib_mr *mr;
- struct ib_fast_reg_page_list *frpl;
u8 mr_valid:1;
};
diff --git a/sys/dev/iser/iser_memory.c b/sys/dev/iser/iser_memory.c
index 1acc1ba..ca3b557 100644
--- a/sys/dev/iser/iser_memory.c
+++ b/sys/dev/iser/iser_memory.c
@@ -52,64 +52,6 @@ iser_reg_desc_put(struct ib_conn *ib_conn,
#define IS_4K_ALIGNED(addr) ((((unsigned long)addr) & ~MASK_4K) == 0)
/**
- * iser_sg_to_page_vec - Translates scatterlist entries to physical addresses
- * and returns the length of resulting physical address array (may be less than
- * the original due to possible compaction).
- *
- * we build a "page vec" under the assumption that the SG meets the RDMA
- * alignment requirements. Other then the first and last SG elements, all
- * the "internal" elements can be compacted into a list whose elements are
- * dma addresses of physical pages. The code supports also the weird case
- * where --few fragments of the same page-- are present in the SG as
- * consecutive elements. Also, it handles one entry SG.
- */
-static int
-iser_sg_to_page_vec(struct iser_data_buf *data,
- struct ib_device *ibdev, u64 *pages,
- int *offset, int *data_size)
-{
- struct scatterlist *sg, *sgl = data->sgl;
- u64 start_addr, end_addr, page, chunk_start = 0;
- unsigned long total_sz = 0;
- unsigned int dma_len;
- int i, new_chunk, cur_page, last_ent = data->dma_nents - 1;
-
- /* compute the offset of first element */
- *offset = (u64) sgl[0].offset & ~MASK_4K;
-
- new_chunk = 1;
- cur_page = 0;
- for_each_sg(sgl, sg, data->dma_nents, i) {
- start_addr = ib_sg_dma_address(ibdev, sg);
- if (new_chunk)
- chunk_start = start_addr;
- dma_len = ib_sg_dma_len(ibdev, sg);
- end_addr = start_addr + dma_len;
- total_sz += dma_len;
-
- /* collect page fragments until aligned or end of SG list */
- if (!IS_4K_ALIGNED(end_addr) && i < last_ent) {
- new_chunk = 0;
- continue;
- }
- new_chunk = 1;
-
- /* address of the first page in the contiguous chunk;
- masking relevant for the very first SG entry,
- which might be unaligned */
- page = chunk_start & MASK_4K;
- do {
- pages[cur_page++] = page;
- page += SIZE_4K;
- } while (page < end_addr);
- }
-
- *data_size = total_sz;
-
- return (cur_page);
-}
-
-/**
* iser_data_buf_aligned_len - Tries to determine the maximal correctly aligned
* for RDMA sub-list of a scatter-gather list of memory buffers, and returns
* the number of entries which are aligned correctly. Supports the case where
@@ -214,46 +156,41 @@ iser_fast_reg_mr(struct icl_iser_pdu *iser_pdu,
{
struct ib_conn *ib_conn = &iser_pdu->iser_conn->ib_conn;
struct iser_device *device = ib_conn->device;
- struct ib_send_wr fastreg_wr, inv_wr;
+ struct ib_mr *mr = rsc->mr;
+ struct ib_reg_wr fastreg_wr;
+ struct ib_send_wr inv_wr;
struct ib_send_wr *bad_wr, *wr = NULL;
- int ret, offset, size, plen;
+ int ret, n;
/* if there a single dma entry, dma mr suffices */
if (mem->dma_nents == 1)
return iser_reg_dma(device, mem, reg);
- /* rsc is not null */
- plen = iser_sg_to_page_vec(mem, device->ib_device,
- rsc->frpl->page_list,
- &offset, &size);
- if (plen * SIZE_4K < size) {
- ISER_ERR("fast reg page_list too short to hold this SG");
- return (EINVAL);
- }
-
if (!rsc->mr_valid) {
- iser_inv_rkey(&inv_wr, rsc->mr);
+ iser_inv_rkey(&inv_wr, mr);
wr = &inv_wr;
}
+ n = ib_map_mr_sg(mr, mem->sg, mem->size, NULL, SIZE_4K);
+ if (unlikely(n != mem->size)) {
+ ISER_ERR("failed to map sg (%d/%d)\n", n, mem->size);
+ return n < 0 ? n : -EINVAL;
+ }
/* Prepare FASTREG WR */
memset(&fastreg_wr, 0, sizeof(fastreg_wr));
- fastreg_wr.wr_id = ISER_FASTREG_LI_WRID;
- fastreg_wr.opcode = IB_WR_FAST_REG_MR;
- fastreg_wr.wr.fast_reg.iova_start = rsc->frpl->page_list[0] + offset;
- fastreg_wr.wr.fast_reg.page_list = rsc->frpl;
- fastreg_wr.wr.fast_reg.page_list_len = plen;
- fastreg_wr.wr.fast_reg.page_shift = SHIFT_4K;
- fastreg_wr.wr.fast_reg.length = size;
- fastreg_wr.wr.fast_reg.rkey = rsc->mr->rkey;
- fastreg_wr.wr.fast_reg.access_flags = (IB_ACCESS_LOCAL_WRITE |
- IB_ACCESS_REMOTE_WRITE |
- IB_ACCESS_REMOTE_READ);
+ fastreg_wr.wr.opcode = IB_WR_REG_MR;
+ fastreg_wr.wr.wr_id = ISER_FASTREG_LI_WRID;
+ fastreg_wr.wr.num_sge = 0;
+ fastreg_wr.mr = mr;
+ fastreg_wr.key = mr->rkey;
+ fastreg_wr.access = IB_ACCESS_LOCAL_WRITE |
+ IB_ACCESS_REMOTE_WRITE |
+ IB_ACCESS_REMOTE_READ;
if (!wr)
- wr = &fastreg_wr;
+ wr = &fastreg_wr.wr;
else
- wr->next = &fastreg_wr;
+ wr->next = &fastreg_wr.wr;
ret = ib_post_send(ib_conn->qp, wr, &bad_wr);
if (ret) {
@@ -262,10 +199,10 @@ iser_fast_reg_mr(struct icl_iser_pdu *iser_pdu,
}
rsc->mr_valid = 0;
- reg->sge.lkey = rsc->mr->lkey;
- reg->rkey = rsc->mr->rkey;
- reg->sge.addr = rsc->frpl->page_list[0] + offset;
- reg->sge.length = size;
+ reg->sge.lkey = mr->lkey;
+ reg->rkey = mr->rkey;
+ reg->sge.addr = mr->iova;
+ reg->sge.length = mr->length;
return (ret);
}
diff --git a/sys/dev/iser/iser_verbs.c b/sys/dev/iser/iser_verbs.c
index 9c9ed72..c9d42da 100644
--- a/sys/dev/iser/iser_verbs.c
+++ b/sys/dev/iser/iser_verbs.c
@@ -200,16 +200,10 @@ iser_cq_callback(struct ib_cq *cq, void *cq_context)
static int
iser_create_device_ib_res(struct iser_device *device)
{
- struct ib_device_attr *dev_attr = &device->dev_attr;
- int ret, i, max_cqe;
+ struct ib_device *ib_dev = device->ib_device;
+ int i, max_cqe;
- ret = ib_query_device(device->ib_device, dev_attr);
- if (ret) {
- ISER_ERR("Query device failed for %s", device->ib_device->name);
- return (ret);
- }
-
- if (!(dev_attr->device_cap_flags & IB_DEVICE_MEM_MGT_EXTENSIONS)) {
+ if (!(ib_dev->attrs.device_cap_flags & IB_DEVICE_MEM_MGT_EXTENSIONS)) {
ISER_ERR("device %s doesn't support Fastreg, "
"can't register memory", device->ib_device->name);
return (1);
@@ -222,25 +216,29 @@ iser_create_device_ib_res(struct iser_device *device)
if (!device->comps)
goto comps_err;
- max_cqe = min(ISER_MAX_CQ_LEN, dev_attr->max_cqe);
+ max_cqe = min(ISER_MAX_CQ_LEN, ib_dev->attrs.max_cqe);
ISER_DBG("using %d CQs, device %s supports %d vectors max_cqe %d",
device->comps_used, device->ib_device->name,
device->ib_device->num_comp_vectors, max_cqe);
- device->pd = ib_alloc_pd(device->ib_device);
+ device->pd = ib_alloc_pd(device->ib_device, IB_PD_UNSAFE_GLOBAL_RKEY);
if (IS_ERR(device->pd))
goto pd_err;
for (i = 0; i < device->comps_used; i++) {
struct iser_comp *comp = &device->comps[i];
+ struct ib_cq_init_attr cq_attr = {
+ .cqe = max_cqe,
+ .comp_vector = i,
+ };
comp->device = device;
comp->cq = ib_create_cq(device->ib_device,
iser_cq_callback,
iser_cq_event_callback,
(void *)comp,
- max_cqe, i);
+ &cq_attr);
if (IS_ERR(comp->cq)) {
comp->cq = NULL;
goto cq_err;
@@ -257,21 +255,17 @@ iser_create_device_ib_res(struct iser_device *device)
taskqueue_start_threads(&comp->tq, 1, PI_NET, "iser taskq");
}
- device->mr = ib_get_dma_mr(device->pd, IB_ACCESS_LOCAL_WRITE |
- IB_ACCESS_REMOTE_WRITE |
- IB_ACCESS_REMOTE_READ);
+ device->mr = device->pd->__internal_mr;
if (IS_ERR(device->mr))
goto tq_err;
INIT_IB_EVENT_HANDLER(&device->event_handler, device->ib_device,
iser_event_handler);
if (ib_register_event_handler(&device->event_handler))
- goto handler_err;
+ goto tq_err;
return (0);
-handler_err:
- ib_dereg_mr(device->mr);
tq_err:
for (i = 0; i < device->comps_used; i++) {
struct iser_comp *comp = &device->comps[i];
@@ -310,7 +304,6 @@ iser_free_device_ib_res(struct iser_device *device)
}
(void)ib_unregister_event_handler(&device->event_handler);
- (void)ib_dereg_mr(device->mr);
(void)ib_dealloc_pd(device->pd);
free(device->comps, M_ISER_VERBS);
@@ -327,35 +320,21 @@ iser_alloc_reg_res(struct ib_device *ib_device,
{
int ret;
- res->frpl = ib_alloc_fast_reg_page_list(ib_device,
- ISCSI_ISER_SG_TABLESIZE + 1);
- if (IS_ERR(res->frpl)) {
- ret = -PTR_ERR(res->frpl);
- ISER_ERR("Failed to allocate fast reg page list err=%d", ret);
- return (ret);
- }
-
- res->mr = ib_alloc_fast_reg_mr(pd, ISCSI_ISER_SG_TABLESIZE + 1);
+ res->mr = ib_alloc_mr(pd, IB_MR_TYPE_MEM_REG, ISCSI_ISER_SG_TABLESIZE + 1);
if (IS_ERR(res->mr)) {
ret = -PTR_ERR(res->mr);
ISER_ERR("Failed to allocate fast reg mr err=%d", ret);
- goto fast_reg_mr_failure;
+ return (ret);
}
res->mr_valid = 1;
return (0);
-
-fast_reg_mr_failure:
- ib_free_fast_reg_page_list(res->frpl);
-
- return (ret);
}
static void
iser_free_reg_res(struct iser_reg_resources *rsc)
{
ib_dereg_mr(rsc->mr);
- ib_free_fast_reg_page_list(rsc->frpl);
}
static struct fast_reg_descriptor *
diff --git a/sys/dev/mlx4/device.h b/sys/dev/mlx4/device.h
index e5d9f07..9d4c461 100644
--- a/sys/dev/mlx4/device.h
+++ b/sys/dev/mlx4/device.h
@@ -804,6 +804,14 @@ union mlx4_ext_av {
struct mlx4_eth_av eth;
};
+/* Counters should be saturate once they reach their maximum value */
+#define ASSIGN_32BIT_COUNTER(counter, value) do { \
+ if ((value) > U32_MAX) \
+ counter = cpu_to_be32(U32_MAX); \
+ else \
+ counter = cpu_to_be32(value); \
+} while (0)
+
struct mlx4_counter {
u8 reserved1[3];
u8 counter_mode;
diff --git a/sys/dev/mlx4/mlx4_ib/mlx4_exp.h b/sys/dev/mlx4/mlx4_ib/mlx4_exp.h
deleted file mode 100644
index 58675a4..0000000
--- a/sys/dev/mlx4/mlx4_ib/mlx4_exp.h
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Copyright (c) 2006, 2007 Cisco Systems. All rights reserved.
- * Copyright (c) 2007, 2008 Mellanox Technologies. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-#ifndef MLX4_EXP_H
-#define MLX4_EXP_H
-
-#include <rdma/ib_verbs_exp.h>
-#include "mlx4_ib.h"
-
-struct ib_qp *mlx4_ib_exp_create_qp(struct ib_pd *pd,
- struct ib_exp_qp_init_attr *init_attr,
- struct ib_udata *udata);
-int mlx4_ib_exp_query_device(struct ib_device *ibdev,
- struct ib_exp_device_attr *props);
-
-#endif /* MLX4_EXP_H */
diff --git a/sys/dev/mlx4/mlx4_ib/mlx4_ib.h b/sys/dev/mlx4/mlx4_ib/mlx4_ib.h
index d04bd8c..15c3cd0 100644
--- a/sys/dev/mlx4/mlx4_ib/mlx4_ib.h
+++ b/sys/dev/mlx4/mlx4_ib/mlx4_ib.h
@@ -41,6 +41,8 @@
#include <linux/rbtree.h>
#include <linux/notifier.h>
+#include <asm/atomic64.h>
+
#include <rdma/ib_verbs.h>
#include <rdma/ib_umem.h>
#include <rdma/ib_mad.h>
@@ -59,9 +61,6 @@
#define mlx4_ib_warn(ibdev, format, arg...) \
dev_warn((ibdev)->dma_device, MLX4_IB_DRV_NAME ": " format, ## arg)
-#define mlx4_ib_info(ibdev, format, arg...) \
- dev_info((ibdev)->dma_device, MLX4_IB_DRV_NAME ": " format, ## arg)
-
enum {
MLX4_IB_SQ_MIN_WQE_SHIFT = 6,
MLX4_IB_MAX_HEADROOM = 2048
@@ -75,17 +74,25 @@ extern int mlx4_ib_sm_guid_assign;
extern struct proc_dir_entry *mlx4_mrs_dir_entry;
#define MLX4_IB_UC_STEER_QPN_ALIGN 1
-#define MLX4_IB_UC_MAX_NUM_QPS (256 * 1024)
+#define MLX4_IB_UC_MAX_NUM_QPS 256
+enum hw_bar_type {
+ HW_BAR_BF,
+ HW_BAR_DB,
+ HW_BAR_CLOCK,
+ HW_BAR_COUNT
+};
-#define MLX4_IB_MMAP_CMD_MASK 0xFF
-#define MLX4_IB_MMAP_CMD_BITS 8
+struct mlx4_ib_vma_private_data {
+ struct vm_area_struct *vma;
+};
struct mlx4_ib_ucontext {
struct ib_ucontext ibucontext;
struct mlx4_uar uar;
struct list_head db_page_list;
struct mutex db_page_mutex;
+ struct mlx4_ib_vma_private_data hw_bar_info[HW_BAR_COUNT];
};
struct mlx4_ib_pd {
@@ -111,11 +118,6 @@ struct mlx4_ib_cq_resize {
int cqe;
};
-struct mlx4_shared_mr_info {
- int mr_id;
- struct ib_umem *umem;
-};
-
struct mlx4_ib_cq {
struct ib_cq ibcq;
struct mlx4_cq mcq;
@@ -127,15 +129,22 @@ struct mlx4_ib_cq {
struct ib_umem *umem;
struct ib_umem *resize_umem;
int create_flags;
+ /* List of qps that it serves.*/
+ struct list_head send_qp_list;
+ struct list_head recv_qp_list;
};
+#define MLX4_MR_PAGES_ALIGN 0x40
+
struct mlx4_ib_mr {
struct ib_mr ibmr;
+ __be64 *pages;
+ dma_addr_t page_map;
+ u32 npages;
+ u32 max_pages;
struct mlx4_mr mmr;
struct ib_umem *umem;
- struct mlx4_shared_mr_info *smr_info;
- atomic_t invalidated;
- struct completion invalidation_comp;
+ size_t page_map_size;
};
struct mlx4_ib_mw {
@@ -143,21 +152,22 @@ struct mlx4_ib_mw {
struct mlx4_mw mmw;
};
-struct mlx4_ib_fast_reg_page_list {
- struct ib_fast_reg_page_list ibfrpl;
- __be64 *mapped_page_list;
- dma_addr_t map;
-};
-
struct mlx4_ib_fmr {
struct ib_fmr ibfmr;
struct mlx4_fmr mfmr;
};
+#define MAX_REGS_PER_FLOW 2
+
+struct mlx4_flow_reg_id {
+ u64 id;
+ u64 mirror;
+};
+
struct mlx4_ib_flow {
struct ib_flow ibflow;
/* translating DMFS verbs sniffer rule to FW API requires two reg IDs */
- u64 reg_id[2];
+ struct mlx4_flow_reg_id reg_id[MAX_REGS_PER_FLOW];
};
struct mlx4_ib_wq {
@@ -172,13 +182,18 @@ struct mlx4_ib_wq {
unsigned tail;
};
+enum {
+ MLX4_IB_QP_CREATE_ROCE_V2_GSI = IB_QP_CREATE_RESERVED_START
+};
+
enum mlx4_ib_qp_flags {
MLX4_IB_QP_LSO = IB_QP_CREATE_IPOIB_UD_LSO,
MLX4_IB_QP_BLOCK_MULTICAST_LOOPBACK = IB_QP_CREATE_BLOCK_MULTICAST_LOOPBACK,
- MLX4_IB_QP_CAP_CROSS_CHANNEL = IB_QP_CREATE_CROSS_CHANNEL,
- MLX4_IB_QP_CAP_MANAGED_SEND = IB_QP_CREATE_MANAGED_SEND,
- MLX4_IB_QP_CAP_MANAGED_RECV = IB_QP_CREATE_MANAGED_RECV,
MLX4_IB_QP_NETIF = IB_QP_CREATE_NETIF_QP,
+ MLX4_IB_QP_CREATE_USE_GFP_NOIO = IB_QP_CREATE_USE_GFP_NOIO,
+
+ /* Mellanox specific flags start from IB_QP_CREATE_RESERVED_START */
+ MLX4_IB_ROCE_V2_GSI_QP = MLX4_IB_QP_CREATE_ROCE_V2_GSI,
MLX4_IB_SRIOV_TUNNEL_QP = 1 << 30,
MLX4_IB_SRIOV_SQP = 1 << 31,
};
@@ -190,13 +205,6 @@ struct mlx4_ib_gid_entry {
u8 port;
};
-enum mlx4_ib_mmap_cmd {
- MLX4_IB_MMAP_UAR_PAGE = 0,
- MLX4_IB_MMAP_BLUE_FLAME_PAGE = 1,
- MLX4_IB_MMAP_GET_CONTIGUOUS_PAGES = 2,
- MLX4_IB_MMAP_GET_HW_CLOCK = 3,
-};
-
enum mlx4_ib_qp_type {
/*
* IB_QPT_SMI and IB_QPT_GSI have to be the first two entries
@@ -287,17 +295,6 @@ struct mlx4_roce_smac_vlan_info {
int update_vid;
};
-struct mlx4_ib_qpg_data {
- unsigned long *tss_bitmap;
- unsigned long *rss_bitmap;
- struct mlx4_ib_qp *qpg_parent;
- int tss_qpn_base;
- int rss_qpn_base;
- u32 tss_child_count;
- u32 rss_child_count;
- u32 qpg_tss_mask_sz;
-};
-
struct mlx4_ib_qp {
struct ib_qp ibqp;
struct mlx4_qp mqp;
@@ -327,22 +324,16 @@ struct mlx4_ib_qp {
u8 sq_no_prefetch;
u8 state;
int mlx_type;
- enum ib_qpg_type qpg_type;
- struct mlx4_ib_qpg_data *qpg_data;
struct list_head gid_list;
struct list_head steering_rules;
struct mlx4_ib_buf *sqp_proxy_rcv;
struct mlx4_roce_smac_vlan_info pri;
struct mlx4_roce_smac_vlan_info alt;
- struct list_head rules_list;
u64 reg_id;
- int max_inline_data;
- struct mlx4_bf bf;
-
- /*
- * Experimental data
- */
- int max_inlr_data;
+ struct list_head qps_list;
+ struct list_head cq_recv_list;
+ struct list_head cq_send_list;
+ struct counter_index *counter_index;
};
struct mlx4_ib_srq {
@@ -376,23 +367,12 @@ struct mlx4_ib_ah {
#define MLX4_NOT_SET_GUID (0x00LL)
#define MLX4_GUID_FOR_DELETE_VAL (~(0x00LL))
-/****************************************/
-/* ioctl codes */
-/****************************************/
-#define MLX4_IOC_MAGIC 'm'
-#define MLX4_IOCHWCLOCKOFFSET _IOR(MLX4_IOC_MAGIC, 1, int)
-
enum mlx4_guid_alias_rec_status {
MLX4_GUID_INFO_STATUS_IDLE,
MLX4_GUID_INFO_STATUS_SET,
- MLX4_GUID_INFO_STATUS_PENDING,
};
-enum mlx4_guid_alias_rec_ownership {
- MLX4_GUID_DRIVER_ASSIGN,
- MLX4_GUID_SYSADMIN_ASSIGN,
- MLX4_GUID_NONE_ASSIGN, /*init state of each record*/
-};
+#define GUID_STATE_NEED_PORT_INIT 0x01
enum mlx4_guid_alias_rec_method {
MLX4_GUID_INFO_RECORD_SET = IB_MGMT_METHOD_SET,
@@ -403,8 +383,8 @@ struct mlx4_sriov_alias_guid_info_rec_det {
u8 all_recs[GUID_REC_SIZE * NUM_ALIAS_GUID_IN_REC];
ib_sa_comp_mask guid_indexes; /*indicates what from the 8 records are valid*/
enum mlx4_guid_alias_rec_status status; /*indicates the administraively status of the record.*/
- u8 method; /*set or delete*/
- enum mlx4_guid_alias_rec_ownership ownership; /*indicates who assign that alias_guid record*/
+ unsigned int guids_retry_schedule[NUM_ALIAS_GUID_IN_REC];
+ u64 time_to_run;
};
struct mlx4_sriov_alias_guid_port_rec_det {
@@ -412,6 +392,7 @@ struct mlx4_sriov_alias_guid_port_rec_det {
struct workqueue_struct *wq;
struct delayed_work alias_guid_work;
u8 port;
+ u32 state_flags;
struct mlx4_sriov_alias_guid *parent;
struct list_head cb_list;
};
@@ -461,7 +442,6 @@ struct mlx4_ib_demux_pv_ctx {
struct ib_device *ib_dev;
struct ib_cq *cq;
struct ib_pd *pd;
- struct ib_mr *mr;
struct work_struct work;
struct workqueue_struct *wq;
struct mlx4_ib_demux_pv_qp qp[2];
@@ -473,7 +453,7 @@ struct mlx4_ib_demux_ctx {
struct workqueue_struct *wq;
struct workqueue_struct *ud_wq;
spinlock_t ud_lock;
- __be64 subnet_prefix;
+ atomic64_t subnet_prefix;
__be64 guid_cache[128];
struct mlx4_ib_dev *dev;
/* the following lock protects both mcg_table and mcg_mgid0_list */
@@ -503,13 +483,27 @@ struct mlx4_ib_sriov {
struct idr pv_id_table;
};
+struct gid_cache_context {
+ int real_index;
+ int refcount;
+};
+
+struct gid_entry {
+ union ib_gid gid;
+ enum ib_gid_type gid_type;
+ struct gid_cache_context *ctx;
+};
+
+struct mlx4_port_gid_table {
+ struct gid_entry gids[MLX4_MAX_PORT_GIDS];
+};
+
struct mlx4_ib_iboe {
spinlock_t lock;
struct net_device *netdevs[MLX4_MAX_PORTS];
- struct net_device *masters[MLX4_MAX_PORTS];
- struct notifier_block nb;
- struct notifier_block nb_inet;
- union ib_gid gid_table[MLX4_MAX_PORTS][128];
+ atomic64_t mac[MLX4_MAX_PORTS];
+ struct notifier_block nb;
+ struct mlx4_port_gid_table gids[MLX4_MAX_PORTS];
};
struct pkey_mgt {
@@ -548,15 +542,32 @@ struct mlx4_ib_iov_port {
struct mlx4_ib_iov_sysfs_attr mcg_dentry;
};
-struct mlx4_ib_counter {
- int counter_index;
- int status;
+struct counter_index {
+ struct list_head list;
+ u32 index;
+ u8 allocated;
+};
+
+struct mlx4_ib_counters {
+ struct list_head counters_list;
+ struct mutex mutex; /* mutex for accessing counters list */
+ u32 default_counter;
+};
+
+#define MLX4_DIAG_COUNTERS_TYPES 2
+
+struct mlx4_ib_diag_counters {
+ const char **name;
+ u32 *offset;
+ u32 num_counters;
};
struct mlx4_ib_dev {
struct ib_device ib_dev;
struct mlx4_dev *dev;
int num_ports;
+ void __iomem *uar_map;
+
struct mlx4_uar priv_uar;
u32 priv_pdn;
MLX4_DECLARE_DOORBELL_LOCK(uar_lock);
@@ -564,14 +575,14 @@ struct mlx4_ib_dev {
struct ib_mad_agent *send_agent[MLX4_MAX_PORTS][2];
struct ib_ah *sm_ah[MLX4_MAX_PORTS];
spinlock_t sm_lock;
+ atomic64_t sl2vl[MLX4_MAX_PORTS];
struct mlx4_ib_sriov sriov;
struct mutex cap_mask_mutex;
bool ib_active;
struct mlx4_ib_iboe iboe;
- struct mlx4_ib_counter counters[MLX4_MAX_PORTS];
+ struct mlx4_ib_counters counters_table[MLX4_MAX_PORTS];
int *eq_table;
- int eq_added;
struct kobject *iov_parent;
struct kobject *ports_parent;
struct kobject *dev_ports_parent[MLX4_MFUNC_MAX];
@@ -580,12 +591,22 @@ struct mlx4_ib_dev {
unsigned long *ib_uc_qpns_bitmap;
int steer_qpn_count;
int steer_qpn_base;
+ int steering_support;
+ struct mlx4_ib_qp *qp1_proxy[MLX4_MAX_PORTS];
+ /* lock when destroying qp1_proxy and getting netdev events */
+ struct mutex qp1_proxy_lock[MLX4_MAX_PORTS];
+ u8 bond_next_port;
+ /* protect resources needed as part of reset flow */
+ spinlock_t reset_flow_resource_lock;
+ struct list_head qp_list;
+ struct mlx4_ib_diag_counters diag_counters[MLX4_DIAG_COUNTERS_TYPES];
};
struct ib_event_work {
struct work_struct work;
struct mlx4_ib_dev *ib_dev;
struct mlx4_eqe ib_eqe;
+ int port;
};
struct mlx4_ib_qp_tunnel_init_attr {
@@ -595,6 +616,21 @@ struct mlx4_ib_qp_tunnel_init_attr {
u8 port;
};
+struct mlx4_uverbs_ex_query_device {
+ __u32 comp_mask;
+ __u32 reserved;
+};
+
+enum query_device_resp_mask {
+ QUERY_DEVICE_RESP_MASK_TIMESTAMP = 1UL << 0,
+};
+
+struct mlx4_uverbs_ex_query_device_resp {
+ __u32 comp_mask;
+ __u32 response_length;
+ __u64 hca_core_clock_offset;
+};
+
static inline struct mlx4_ib_dev *to_mdev(struct ib_device *ibdev)
{
return container_of(ibdev, struct mlx4_ib_dev, ib_dev);
@@ -635,11 +671,6 @@ static inline struct mlx4_ib_mw *to_mmw(struct ib_mw *ibmw)
return container_of(ibmw, struct mlx4_ib_mw, ibmw);
}
-static inline struct mlx4_ib_fast_reg_page_list *to_mfrpl(struct ib_fast_reg_page_list *ibfrpl)
-{
- return container_of(ibfrpl, struct mlx4_ib_fast_reg_page_list, ibfrpl);
-}
-
static inline struct mlx4_ib_fmr *to_mfmr(struct ib_fmr *ibfmr)
{
return container_of(ibfmr, struct mlx4_ib_fmr, ibfmr);
@@ -675,6 +706,13 @@ static inline struct mlx4_ib_ah *to_mah(struct ib_ah *ibah)
return container_of(ibah, struct mlx4_ib_ah, ibah);
}
+static inline u8 mlx4_ib_bond_next_port(struct mlx4_ib_dev *dev)
+{
+ dev->bond_next_port = (dev->bond_next_port + 1) % dev->num_ports;
+
+ return dev->bond_next_port + 1;
+}
+
int mlx4_ib_init_sriov(struct mlx4_ib_dev *dev);
void mlx4_ib_close_sriov(struct mlx4_ib_dev *dev);
@@ -685,30 +723,27 @@ void mlx4_ib_db_unmap_user(struct mlx4_ib_ucontext *context, struct mlx4_db *db)
struct ib_mr *mlx4_ib_get_dma_mr(struct ib_pd *pd, int acc);
int mlx4_ib_umem_write_mtt(struct mlx4_ib_dev *dev, struct mlx4_mtt *mtt,
struct ib_umem *umem);
-int mlx4_ib_umem_calc_optimal_mtt_size(struct ib_umem *umem,
- u64 start_va,
- int *num_of_mtts);
struct ib_mr *mlx4_ib_reg_user_mr(struct ib_pd *pd, u64 start, u64 length,
u64 virt_addr, int access_flags,
- struct ib_udata *udata, int mr_id);
+ struct ib_udata *udata);
+struct ib_mr *mlx4_ib_reg_phys_mr(struct ib_pd *pd,
+ struct ib_phys_buf *buffer_list,
+ int num_phys_buf,
+ int access_flags,
+ u64 *virt_addr);
int mlx4_ib_dereg_mr(struct ib_mr *mr);
-struct ib_mw *mlx4_ib_alloc_mw(struct ib_pd *pd, enum ib_mw_type type);
-int mlx4_ib_bind_mw(struct ib_qp *qp, struct ib_mw *mw,
- struct ib_mw_bind *mw_bind);
+struct ib_mw *mlx4_ib_alloc_mw(struct ib_pd *pd, enum ib_mw_type type,
+ struct ib_udata *udata);
int mlx4_ib_dealloc_mw(struct ib_mw *mw);
-struct ib_mr *mlx4_ib_alloc_fast_reg_mr(struct ib_pd *pd,
- int max_page_list_len);
-struct ib_fast_reg_page_list *mlx4_ib_alloc_fast_reg_page_list(struct ib_device *ibdev,
- int page_list_len);
-void mlx4_ib_free_fast_reg_page_list(struct ib_fast_reg_page_list *page_list);
-
-int mlx4_ib_modify_cq(struct ib_cq *cq,
- struct ib_cq_attr *cq_attr,
- int cq_attr_mask);
+struct ib_mr *mlx4_ib_alloc_mr(struct ib_pd *pd,
+ enum ib_mr_type mr_type,
+ u32 max_num_sg);
+int mlx4_ib_map_mr_sg(struct ib_mr *ibmr, struct scatterlist *sg, int sg_nents,
+ unsigned int *sg_offset);
+int mlx4_ib_modify_cq(struct ib_cq *cq, u16 cq_count, u16 cq_period);
int mlx4_ib_resize_cq(struct ib_cq *ibcq, int entries, struct ib_udata *udata);
-int mlx4_ib_ignore_overrun_cq(struct ib_cq *ibcq);
struct ib_cq *mlx4_ib_create_cq(struct ib_device *ibdev,
- struct ib_cq_init_attr *attr,
+ const struct ib_cq_init_attr *attr,
struct ib_ucontext *context,
struct ib_udata *udata);
int mlx4_ib_destroy_cq(struct ib_cq *cq);
@@ -746,11 +781,13 @@ int mlx4_ib_post_recv(struct ib_qp *ibqp, struct ib_recv_wr *wr,
struct ib_recv_wr **bad_wr);
int mlx4_MAD_IFC(struct mlx4_ib_dev *dev, int mad_ifc_flags,
- int port, struct ib_wc *in_wc, struct ib_grh *in_grh,
- void *in_mad, void *response_mad);
+ int port, const struct ib_wc *in_wc, const struct ib_grh *in_grh,
+ const void *in_mad, void *response_mad);
int mlx4_ib_process_mad(struct ib_device *ibdev, int mad_flags, u8 port_num,
- struct ib_wc *in_wc, struct ib_grh *in_grh,
- struct ib_mad *in_mad, struct ib_mad *out_mad);
+ const struct ib_wc *in_wc, const struct ib_grh *in_grh,
+ const struct ib_mad_hdr *in, size_t in_mad_size,
+ struct ib_mad_hdr *out, size_t *out_mad_size,
+ u16 *out_mad_pkey_index);
int mlx4_ib_mad_init(struct mlx4_ib_dev *dev);
void mlx4_ib_mad_cleanup(struct mlx4_ib_dev *dev);
@@ -768,25 +805,15 @@ int __mlx4_ib_query_pkey(struct ib_device *ibdev, u8 port, u16 index,
int __mlx4_ib_query_gid(struct ib_device *ibdev, u8 port, int index,
union ib_gid *gid, int netw_view);
-int mlx4_ib_resolve_grh(struct mlx4_ib_dev *dev, const struct ib_ah_attr *ah_attr,
- u8 *mac, int *is_mcast, u8 port);
-
-static inline int mlx4_ib_ah_grh_present(struct mlx4_ib_ah *ah)
+static inline bool mlx4_ib_ah_grh_present(struct mlx4_ib_ah *ah)
{
u8 port = be32_to_cpu(ah->av.ib.port_pd) >> 24 & 3;
if (rdma_port_get_link_layer(ah->ibah.device, port) == IB_LINK_LAYER_ETHERNET)
- return 1;
+ return true;
return !!(ah->av.ib.g_slid & 0x80);
}
-static inline int mlx4_ib_qp_has_rq(struct ib_qp_init_attr *attr)
-{
- if (attr->qp_type == IB_QPT_XRC_INI || attr->qp_type == IB_QPT_XRC_TGT)
- return 0;
-
- return !attr->srq;
-}
int mlx4_ib_mcg_port_init(struct mlx4_ib_demux_ctx *ctx);
void mlx4_ib_mcg_port_cleanup(struct mlx4_ib_demux_ctx *ctx, int destroy_wq);
@@ -812,13 +839,16 @@ void mlx4_ib_tunnels_update_work(struct work_struct *work);
int mlx4_ib_send_to_slave(struct mlx4_ib_dev *dev, int slave, u8 port,
enum ib_qp_type qpt, struct ib_wc *wc,
struct ib_grh *grh, struct ib_mad *mad);
+
int mlx4_ib_send_to_wire(struct mlx4_ib_dev *dev, int slave, u8 port,
enum ib_qp_type dest_qpt, u16 pkey_index, u32 remote_qpn,
- u32 qkey, struct ib_ah_attr *attr, u8 *s_mac, struct ib_mad *mad);
+ u32 qkey, struct ib_ah_attr *attr, u8 *s_mac,
+ u16 vlan_id, struct ib_mad *mad);
+
__be64 mlx4_ib_get_new_demux_tid(struct mlx4_ib_demux_ctx *ctx);
int mlx4_ib_demux_cm_handler(struct ib_device *ibdev, int port, int *slave,
- struct ib_mad *mad, int is_eth);
+ struct ib_mad *mad);
int mlx4_ib_multiplex_cm_handler(struct ib_device *ibdev, int port, int slave_id,
struct ib_mad *mad);
@@ -845,6 +875,8 @@ int add_sysfs_port_mcg_attr(struct mlx4_ib_dev *device, int port_num,
void del_sysfs_port_mcg_attr(struct mlx4_ib_dev *device, int port_num,
struct attribute *attr);
ib_sa_comp_mask mlx4_ib_get_aguid_comp_mask_from_ix(int index);
+void mlx4_ib_slave_alias_guid_event(struct mlx4_ib_dev *dev, int slave,
+ int port, int slave_init);
int mlx4_ib_device_register_sysfs(struct mlx4_ib_dev *device) ;
@@ -856,7 +888,16 @@ int mlx4_ib_steer_qp_alloc(struct mlx4_ib_dev *dev, int count, int *qpn);
void mlx4_ib_steer_qp_free(struct mlx4_ib_dev *dev, u32 qpn, int count);
int mlx4_ib_steer_qp_reg(struct mlx4_ib_dev *mdev, struct mlx4_ib_qp *mqp,
int is_attach);
-int mlx4_ib_query_device(struct ib_device *ibdev,
- struct ib_device_attr *props);
+int mlx4_ib_rereg_user_mr(struct ib_mr *mr, int flags,
+ u64 start, u64 length, u64 virt_addr,
+ int mr_access_flags, struct ib_pd *pd,
+ struct ib_udata *udata);
+int mlx4_ib_gid_index_to_real_index(struct mlx4_ib_dev *ibdev,
+ u8 port_num, int index);
+
+void mlx4_sched_ib_sl2vl_update_work(struct mlx4_ib_dev *ibdev,
+ int port);
+
+void mlx4_ib_sl2vl_update(struct mlx4_ib_dev *mdev, int port);
#endif /* MLX4_IB_H */
diff --git a/sys/dev/mlx4/mlx4_ib/mlx4_ib_ah.c b/sys/dev/mlx4/mlx4_ib/mlx4_ib_ah.c
index 1c30fa9..d991621 100644
--- a/sys/dev/mlx4/mlx4_ib/mlx4_ib_ah.c
+++ b/sys/dev/mlx4/mlx4_ib/mlx4_ib_ah.c
@@ -38,28 +38,10 @@
#include <linux/slab.h>
#include <linux/string.h>
+#include <linux/etherdevice.h>
#include "mlx4_ib.h"
-int mlx4_ib_resolve_grh(struct mlx4_ib_dev *dev, const struct ib_ah_attr *ah_attr,
- u8 *mac, int *is_mcast, u8 port)
-{
- struct in6_addr in6;
-
- *is_mcast = 0;
-
- memcpy(&in6, ah_attr->grh.dgid.raw, sizeof in6);
- if (rdma_link_local_addr(&in6))
- rdma_get_ll_mac(&in6, mac);
- else if (rdma_is_multicast_addr(&in6)) {
- rdma_get_mcast_mac(&in6, mac);
- *is_mcast = 1;
- } else
- return -EINVAL;
-
- return 0;
-}
-
static struct ib_ah *create_ib_ah(struct ib_pd *pd, struct ib_ah_attr *ah_attr,
struct mlx4_ib_ah *ah)
{
@@ -67,6 +49,7 @@ static struct ib_ah *create_ib_ah(struct ib_pd *pd, struct ib_ah_attr *ah_attr,
ah->av.ib.port_pd = cpu_to_be32(to_mpd(pd)->pdn | (ah_attr->port_num << 24));
ah->av.ib.g_slid = ah_attr->src_path_bits;
+ ah->av.ib.sl_tclass_flowlabel = cpu_to_be32(ah_attr->sl << 28);
if (ah_attr->ah_flags & IB_AH_GRH) {
ah->av.ib.g_slid |= 0x80;
ah->av.ib.gid_index = ah_attr->grh.sgid_index;
@@ -84,7 +67,6 @@ static struct ib_ah *create_ib_ah(struct ib_pd *pd, struct ib_ah_attr *ah_attr,
!(1 << ah->av.ib.stat_rate & dev->caps.stat_rate_support))
--ah->av.ib.stat_rate;
}
- ah->av.ib.sl_tclass_flowlabel = cpu_to_be32(ah_attr->sl << 28);
return &ah->ibah;
}
@@ -96,21 +78,38 @@ static struct ib_ah *create_iboe_ah(struct ib_pd *pd, struct ib_ah_attr *ah_attr
struct mlx4_dev *dev = ibdev->dev;
int is_mcast = 0;
struct in6_addr in6;
- u16 vlan_tag;
+ u16 vlan_tag = 0xffff;
+ union ib_gid sgid;
+ struct ib_gid_attr gid_attr;
+ int ret;
memcpy(&in6, ah_attr->grh.dgid.raw, sizeof(in6));
if (rdma_is_multicast_addr(&in6)) {
is_mcast = 1;
- resolve_mcast_mac(&in6, ah->av.eth.mac);
+ rdma_get_mcast_mac(&in6, ah->av.eth.mac);
} else {
- memcpy(ah->av.eth.mac, ah_attr->dmac, 6);
+ memcpy(ah->av.eth.mac, ah_attr->dmac, ETH_ALEN);
+ }
+ ret = ib_get_cached_gid(pd->device, ah_attr->port_num,
+ ah_attr->grh.sgid_index, &sgid, &gid_attr);
+ if (ret)
+ return ERR_PTR(ret);
+ eth_zero_addr(ah->av.eth.s_mac);
+ if (gid_attr.ndev) {
+ if (is_vlan_dev(gid_attr.ndev))
+ vlan_tag = vlan_dev_vlan_id(gid_attr.ndev);
+ memcpy(ah->av.eth.s_mac, IF_LLADDR(gid_attr.ndev), ETH_ALEN);
+ dev_put(gid_attr.ndev);
}
- vlan_tag = ah_attr->vlan_id;
if (vlan_tag < 0x1000)
vlan_tag |= (ah_attr->sl & 7) << 13;
ah->av.eth.port_pd = cpu_to_be32(to_mpd(pd)->pdn | (ah_attr->port_num << 24));
- ah->av.eth.gid_index = ah_attr->grh.sgid_index;
+ ret = mlx4_ib_gid_index_to_real_index(ibdev, ah_attr->port_num, ah_attr->grh.sgid_index);
+ if (ret < 0)
+ return ERR_PTR(ret);
+ ah->av.eth.gid_index = ret;
ah->av.eth.vlan = cpu_to_be16(vlan_tag);
+ ah->av.eth.hop_limit = ah_attr->grh.hop_limit;
if (ah_attr->static_rate) {
ah->av.eth.stat_rate = ah_attr->static_rate + MLX4_STAT_RATE_OFFSET;
while (ah->av.eth.stat_rate > IB_RATE_2_5_GBPS + MLX4_STAT_RATE_OFFSET &&
@@ -168,9 +167,13 @@ int mlx4_ib_query_ah(struct ib_ah *ibah, struct ib_ah_attr *ah_attr)
enum rdma_link_layer ll;
memset(ah_attr, 0, sizeof *ah_attr);
- ah_attr->sl = be32_to_cpu(ah->av.ib.sl_tclass_flowlabel) >> 28;
ah_attr->port_num = be32_to_cpu(ah->av.ib.port_pd) >> 24;
ll = rdma_port_get_link_layer(ibah->device, ah_attr->port_num);
+ if (ll == IB_LINK_LAYER_ETHERNET)
+ ah_attr->sl = be32_to_cpu(ah->av.eth.sl_tclass_flowlabel) >> 29;
+ else
+ ah_attr->sl = be32_to_cpu(ah->av.ib.sl_tclass_flowlabel) >> 28;
+
ah_attr->dlid = ll == IB_LINK_LAYER_INFINIBAND ? be16_to_cpu(ah->av.ib.dlid) : 0;
if (ah->av.ib.stat_rate)
ah_attr->static_rate = ah->av.ib.stat_rate - MLX4_STAT_RATE_OFFSET;
diff --git a/sys/dev/mlx4/mlx4_ib/mlx4_ib_alias_GUID.c b/sys/dev/mlx4/mlx4_ib/mlx4_ib_alias_GUID.c
index 352219a..91d240b 100644
--- a/sys/dev/mlx4/mlx4_ib/mlx4_ib_alias_GUID.c
+++ b/sys/dev/mlx4/mlx4_ib/mlx4_ib_alias_GUID.c
@@ -42,6 +42,8 @@
#include <linux/errno.h>
#include <rdma/ib_user_verbs.h>
#include <linux/delay.h>
+#include <linux/math64.h>
+#include <linux/ktime.h>
#include "mlx4_ib.h"
/*
@@ -57,15 +59,19 @@ struct mlx4_alias_guid_work_context {
int query_id;
struct list_head list;
int block_num;
+ ib_sa_comp_mask guid_indexes;
u8 method;
};
struct mlx4_next_alias_guid_work {
u8 port;
u8 block_num;
+ u8 method;
struct mlx4_sriov_alias_guid_info_rec_det rec_det;
};
+static int get_low_record_time_index(struct mlx4_ib_dev *dev, u8 port,
+ int *resched_delay_sec);
void mlx4_ib_update_cache_on_guid_change(struct mlx4_ib_dev *dev, int block_num,
u8 port_num, u8 *p_data)
@@ -119,6 +125,57 @@ ib_sa_comp_mask mlx4_ib_get_aguid_comp_mask_from_ix(int index)
return IB_SA_COMP_MASK(4 + index);
}
+void mlx4_ib_slave_alias_guid_event(struct mlx4_ib_dev *dev, int slave,
+ int port, int slave_init)
+{
+ __be64 curr_guid, required_guid;
+ int record_num = slave / 8;
+ int index = slave % 8;
+ int port_index = port - 1;
+ unsigned long flags;
+ int do_work = 0;
+
+ spin_lock_irqsave(&dev->sriov.alias_guid.ag_work_lock, flags);
+ if (dev->sriov.alias_guid.ports_guid[port_index].state_flags &
+ GUID_STATE_NEED_PORT_INIT)
+ goto unlock;
+ if (!slave_init) {
+ curr_guid = *(__be64 *)&dev->sriov.
+ alias_guid.ports_guid[port_index].
+ all_rec_per_port[record_num].
+ all_recs[GUID_REC_SIZE * index];
+ if (curr_guid == cpu_to_be64(MLX4_GUID_FOR_DELETE_VAL) ||
+ !curr_guid)
+ goto unlock;
+ required_guid = cpu_to_be64(MLX4_GUID_FOR_DELETE_VAL);
+ } else {
+ required_guid = mlx4_get_admin_guid(dev->dev, slave, port);
+ if (required_guid == cpu_to_be64(MLX4_GUID_FOR_DELETE_VAL))
+ goto unlock;
+ }
+ *(__be64 *)&dev->sriov.alias_guid.ports_guid[port_index].
+ all_rec_per_port[record_num].
+ all_recs[GUID_REC_SIZE * index] = required_guid;
+ dev->sriov.alias_guid.ports_guid[port_index].
+ all_rec_per_port[record_num].guid_indexes
+ |= mlx4_ib_get_aguid_comp_mask_from_ix(index);
+ dev->sriov.alias_guid.ports_guid[port_index].
+ all_rec_per_port[record_num].status
+ = MLX4_GUID_INFO_STATUS_IDLE;
+ /* set to run immediately */
+ dev->sriov.alias_guid.ports_guid[port_index].
+ all_rec_per_port[record_num].time_to_run = 0;
+ dev->sriov.alias_guid.ports_guid[port_index].
+ all_rec_per_port[record_num].
+ guids_retry_schedule[index] = 0;
+ do_work = 1;
+unlock:
+ spin_unlock_irqrestore(&dev->sriov.alias_guid.ag_work_lock, flags);
+
+ if (do_work)
+ mlx4_ib_init_alias_guid_work(dev, port_index);
+}
+
/*
* Whenever new GUID is set/unset (guid table change) create event and
* notify the relevant slave (master also should be notified).
@@ -134,15 +191,20 @@ void mlx4_ib_notify_slaves_on_guid_change(struct mlx4_ib_dev *dev,
{
int i;
u64 guid_indexes;
- int slave_id;
+ int slave_id, slave_port;
enum slave_port_state new_state;
enum slave_port_state prev_state;
__be64 tmp_cur_ag, form_cache_ag;
enum slave_port_gen_event gen_event;
+ struct mlx4_sriov_alias_guid_info_rec_det *rec;
+ unsigned long flags;
+ __be64 required_value;
if (!mlx4_is_master(dev->dev))
return;
+ rec = &dev->sriov.alias_guid.ports_guid[port_num - 1].
+ all_rec_per_port[block_num];
guid_indexes = be64_to_cpu((__force __be64) dev->sriov.alias_guid.
ports_guid[port_num - 1].
all_rec_per_port[block_num].guid_indexes);
@@ -156,8 +218,13 @@ void mlx4_ib_notify_slaves_on_guid_change(struct mlx4_ib_dev *dev,
continue;
slave_id = (block_num * NUM_ALIAS_GUID_IN_REC) + i ;
- if (slave_id >= dev->dev->num_slaves)
+ if (slave_id >= dev->dev->persist->num_vfs + 1)
return;
+
+ slave_port = mlx4_phys_to_slave_port(dev->dev, slave_id, port_num);
+ if (slave_port < 0) /* this port isn't available for the VF */
+ continue;
+
tmp_cur_ag = *(__be64 *)&p_data[i * GUID_REC_SIZE];
form_cache_ag = get_cached_alias_guid(dev, port_num,
(NUM_ALIAS_GUID_IN_REC * block_num) + i);
@@ -168,8 +235,27 @@ void mlx4_ib_notify_slaves_on_guid_change(struct mlx4_ib_dev *dev,
*/
if (tmp_cur_ag != form_cache_ag)
continue;
- mlx4_gen_guid_change_eqe(dev->dev, slave_id, port_num);
+ spin_lock_irqsave(&dev->sriov.alias_guid.ag_work_lock, flags);
+ required_value = *(__be64 *)&rec->all_recs[i * GUID_REC_SIZE];
+
+ if (required_value == cpu_to_be64(MLX4_GUID_FOR_DELETE_VAL))
+ required_value = 0;
+
+ if (tmp_cur_ag == required_value) {
+ rec->guid_indexes = rec->guid_indexes &
+ ~mlx4_ib_get_aguid_comp_mask_from_ix(i);
+ } else {
+ /* may notify port down if value is 0 */
+ if (tmp_cur_ag != MLX4_NOT_SET_GUID) {
+ spin_unlock_irqrestore(&dev->sriov.
+ alias_guid.ag_work_lock, flags);
+ continue;
+ }
+ }
+ spin_unlock_irqrestore(&dev->sriov.alias_guid.ag_work_lock,
+ flags);
+ mlx4_gen_guid_change_eqe(dev->dev, slave_id, port_num);
/*2 cases: Valid GUID, and Invalid Guid*/
if (tmp_cur_ag != MLX4_NOT_SET_GUID) { /*valid GUID*/
@@ -190,10 +276,14 @@ void mlx4_ib_notify_slaves_on_guid_change(struct mlx4_ib_dev *dev,
set_and_calc_slave_port_state(dev->dev, slave_id, port_num,
MLX4_PORT_STATE_IB_EVENT_GID_INVALID,
&gen_event);
- pr_debug("sending PORT DOWN event to slave: %d, port: %d\n",
- slave_id, port_num);
- mlx4_gen_port_state_change_eqe(dev->dev, slave_id, port_num,
- MLX4_PORT_CHANGE_SUBTYPE_DOWN);
+ if (gen_event == SLAVE_PORT_GEN_EVENT_DOWN) {
+ pr_debug("sending PORT DOWN event to slave: %d, port: %d\n",
+ slave_id, port_num);
+ mlx4_gen_port_state_change_eqe(dev->dev,
+ slave_id,
+ port_num,
+ MLX4_PORT_CHANGE_SUBTYPE_DOWN);
+ }
}
}
}
@@ -208,6 +298,9 @@ static void aliasguid_query_handler(int status,
int i;
struct mlx4_sriov_alias_guid_info_rec_det *rec;
unsigned long flags, flags1;
+ ib_sa_comp_mask declined_guid_indexes = 0;
+ ib_sa_comp_mask applied_guid_indexes = 0;
+ unsigned int resched_delay_sec = 0;
if (!context)
return;
@@ -218,9 +311,9 @@ static void aliasguid_query_handler(int status,
all_rec_per_port[cb_ctx->block_num];
if (status) {
- rec->status = MLX4_GUID_INFO_STATUS_IDLE;
pr_debug("(port: %d) failed: status = %d\n",
cb_ctx->port, status);
+ rec->time_to_run = ktime_get_ns() + 1 * NSEC_PER_SEC;
goto out;
}
@@ -237,69 +330,101 @@ static void aliasguid_query_handler(int status,
rec = &dev->sriov.alias_guid.ports_guid[port_index].
all_rec_per_port[guid_rec->block_num];
- rec->status = MLX4_GUID_INFO_STATUS_SET;
- rec->method = MLX4_GUID_INFO_RECORD_SET;
-
+ spin_lock_irqsave(&dev->sriov.alias_guid.ag_work_lock, flags);
for (i = 0 ; i < NUM_ALIAS_GUID_IN_REC; i++) {
- __be64 tmp_cur_ag;
- tmp_cur_ag = *(__be64 *)&guid_rec->guid_info_list[i * GUID_REC_SIZE];
- if ((cb_ctx->method == MLX4_GUID_INFO_RECORD_DELETE)
- && (MLX4_NOT_SET_GUID == tmp_cur_ag)) {
- pr_debug("%s:Record num %d in block_num:%d "
- "was deleted by SM,ownership by %d "
- "(0 = driver, 1=sysAdmin, 2=None)\n",
- __func__, i, guid_rec->block_num,
- rec->ownership);
- rec->guid_indexes = rec->guid_indexes &
- ~mlx4_ib_get_aguid_comp_mask_from_ix(i);
+ __be64 sm_response, required_val;
+
+ if (!(cb_ctx->guid_indexes &
+ mlx4_ib_get_aguid_comp_mask_from_ix(i)))
continue;
+ sm_response = *(__be64 *)&guid_rec->guid_info_list
+ [i * GUID_REC_SIZE];
+ required_val = *(__be64 *)&rec->all_recs[i * GUID_REC_SIZE];
+ if (cb_ctx->method == MLX4_GUID_INFO_RECORD_DELETE) {
+ if (required_val ==
+ cpu_to_be64(MLX4_GUID_FOR_DELETE_VAL))
+ goto next_entry;
+
+ /* A new value was set till we got the response */
+ pr_debug("need to set new value %llx, record num %d, block_num:%d\n",
+ (long long)be64_to_cpu(required_val),
+ i, guid_rec->block_num);
+ goto entry_declined;
}
/* check if the SM didn't assign one of the records.
- * if it didn't, if it was not sysadmin request:
- * ask the SM to give a new GUID, (instead of the driver request).
+ * if it didn't, re-ask for.
*/
- if (tmp_cur_ag == MLX4_NOT_SET_GUID) {
- mlx4_ib_warn(&dev->ib_dev, "%s:Record num %d in "
- "block_num: %d was declined by SM, "
- "ownership by %d (0 = driver, 1=sysAdmin,"
- " 2=None)\n", __func__, i,
- guid_rec->block_num, rec->ownership);
- if (rec->ownership == MLX4_GUID_DRIVER_ASSIGN) {
- /* if it is driver assign, asks for new GUID from SM*/
- *(__be64 *)&rec->all_recs[i * GUID_REC_SIZE] =
- MLX4_NOT_SET_GUID;
-
- /* Mark the record as not assigned, and let it
- * be sent again in the next work sched.*/
- rec->status = MLX4_GUID_INFO_STATUS_IDLE;
- rec->guid_indexes |= mlx4_ib_get_aguid_comp_mask_from_ix(i);
- }
+ if (sm_response == MLX4_NOT_SET_GUID) {
+ if (rec->guids_retry_schedule[i] == 0)
+ mlx4_ib_warn(&dev->ib_dev,
+ "%s:Record num %d in block_num: %d was declined by SM\n",
+ __func__, i,
+ guid_rec->block_num);
+ goto entry_declined;
} else {
/* properly assigned record. */
/* We save the GUID we just got from the SM in the
* admin_guid in order to be persistent, and in the
* request from the sm the process will ask for the same GUID */
- if (rec->ownership == MLX4_GUID_SYSADMIN_ASSIGN &&
- tmp_cur_ag != *(__be64 *)&rec->all_recs[i * GUID_REC_SIZE]) {
- /* the sysadmin assignment failed.*/
- mlx4_ib_warn(&dev->ib_dev, "%s: Failed to set"
- " admin guid after SysAdmin "
- "configuration. "
- "Record num %d in block_num:%d "
- "was declined by SM, "
- "new val(0x%llx) was kept\n",
- __func__, i,
- guid_rec->block_num,
- (long long)be64_to_cpu(*(__be64 *) &
- rec->all_recs[i * GUID_REC_SIZE]));
+ if (required_val &&
+ sm_response != required_val) {
+ /* Warn only on first retry */
+ if (rec->guids_retry_schedule[i] == 0)
+ mlx4_ib_warn(&dev->ib_dev, "%s: Failed to set"
+ " admin guid after SysAdmin "
+ "configuration. "
+ "Record num %d in block_num:%d "
+ "was declined by SM, "
+ "new val(0x%llx) was kept, SM returned (0x%llx)\n",
+ __func__, i,
+ guid_rec->block_num,
+ (long long)be64_to_cpu(required_val),
+ (long long)be64_to_cpu(sm_response));
+ goto entry_declined;
} else {
- memcpy(&rec->all_recs[i * GUID_REC_SIZE],
- &guid_rec->guid_info_list[i * GUID_REC_SIZE],
- GUID_REC_SIZE);
+ *(__be64 *)&rec->all_recs[i * GUID_REC_SIZE] =
+ sm_response;
+ if (required_val == 0)
+ mlx4_set_admin_guid(dev->dev,
+ sm_response,
+ (guid_rec->block_num
+ * NUM_ALIAS_GUID_IN_REC) + i,
+ cb_ctx->port);
+ goto next_entry;
}
}
+entry_declined:
+ declined_guid_indexes |= mlx4_ib_get_aguid_comp_mask_from_ix(i);
+ rec->guids_retry_schedule[i] =
+ (rec->guids_retry_schedule[i] == 0) ? 1 :
+ min((unsigned int)60,
+ rec->guids_retry_schedule[i] * 2);
+ /* using the minimum value among all entries in that record */
+ resched_delay_sec = (resched_delay_sec == 0) ?
+ rec->guids_retry_schedule[i] :
+ min(resched_delay_sec,
+ rec->guids_retry_schedule[i]);
+ continue;
+
+next_entry:
+ rec->guids_retry_schedule[i] = 0;
+ }
+
+ applied_guid_indexes = cb_ctx->guid_indexes & ~declined_guid_indexes;
+ if (declined_guid_indexes ||
+ rec->guid_indexes & ~(applied_guid_indexes)) {
+ pr_debug("record=%d wasn't fully set, guid_indexes=0x%llx applied_indexes=0x%llx, declined_indexes=0x%llx\n",
+ guid_rec->block_num,
+ (long long)be64_to_cpu((__force __be64)rec->guid_indexes),
+ (long long)be64_to_cpu((__force __be64)applied_guid_indexes),
+ (long long)be64_to_cpu((__force __be64)declined_guid_indexes));
+ rec->time_to_run = ktime_get_ns() +
+ resched_delay_sec * NSEC_PER_SEC;
+ } else {
+ rec->status = MLX4_GUID_INFO_STATUS_SET;
}
+ spin_unlock_irqrestore(&dev->sriov.alias_guid.ag_work_lock, flags);
/*
The func is call here to close the cases when the
sm doesn't send smp, so in the sa response the driver
@@ -311,10 +436,13 @@ static void aliasguid_query_handler(int status,
out:
spin_lock_irqsave(&dev->sriov.going_down_lock, flags);
spin_lock_irqsave(&dev->sriov.alias_guid.ag_work_lock, flags1);
- if (!dev->sriov.is_going_down)
+ if (!dev->sriov.is_going_down) {
+ get_low_record_time_index(dev, port_index, &resched_delay_sec);
queue_delayed_work(dev->sriov.alias_guid.ports_guid[port_index].wq,
&dev->sriov.alias_guid.ports_guid[port_index].
- alias_guid_work, 0);
+ alias_guid_work,
+ msecs_to_jiffies(resched_delay_sec * 1000));
+ }
if (cb_ctx->sa_query) {
list_del(&cb_ctx->list);
kfree(cb_ctx);
@@ -331,9 +459,7 @@ static void invalidate_guid_record(struct mlx4_ib_dev *dev, u8 port, int index)
ib_sa_comp_mask comp_mask = 0;
dev->sriov.alias_guid.ports_guid[port - 1].all_rec_per_port[index].status
- = MLX4_GUID_INFO_STATUS_IDLE;
- dev->sriov.alias_guid.ports_guid[port - 1].all_rec_per_port[index].method
- = MLX4_GUID_INFO_RECORD_SET;
+ = MLX4_GUID_INFO_STATUS_SET;
/* calculate the comp_mask for that record.*/
for (i = 0; i < NUM_ALIAS_GUID_IN_REC; i++) {
@@ -347,19 +473,21 @@ static void invalidate_guid_record(struct mlx4_ib_dev *dev, u8 port, int index)
need to assign GUIDs, then don't put it up for assignment.
*/
if (MLX4_GUID_FOR_DELETE_VAL == cur_admin_val ||
- (!index && !i) ||
- MLX4_GUID_NONE_ASSIGN == dev->sriov.alias_guid.
- ports_guid[port - 1].all_rec_per_port[index].ownership)
+ (!index && !i))
continue;
comp_mask |= mlx4_ib_get_aguid_comp_mask_from_ix(i);
}
dev->sriov.alias_guid.ports_guid[port - 1].
- all_rec_per_port[index].guid_indexes = comp_mask;
+ all_rec_per_port[index].guid_indexes |= comp_mask;
+ if (dev->sriov.alias_guid.ports_guid[port - 1].
+ all_rec_per_port[index].guid_indexes)
+ dev->sriov.alias_guid.ports_guid[port - 1].
+ all_rec_per_port[index].status = MLX4_GUID_INFO_STATUS_IDLE;
+
}
static int set_guid_rec(struct ib_device *ibdev,
- u8 port, int index,
- struct mlx4_sriov_alias_guid_info_rec_det *rec_det)
+ struct mlx4_next_alias_guid_work *rec)
{
int err;
struct mlx4_ib_dev *dev = to_mdev(ibdev);
@@ -368,6 +496,9 @@ static int set_guid_rec(struct ib_device *ibdev,
struct ib_port_attr attr;
struct mlx4_alias_guid_work_context *callback_context;
unsigned long resched_delay, flags, flags1;
+ u8 port = rec->port + 1;
+ int index = rec->block_num;
+ struct mlx4_sriov_alias_guid_info_rec_det *rec_det = &rec->rec_det;
struct list_head *head =
&dev->sriov.alias_guid.ports_guid[port - 1].cb_list;
@@ -394,7 +525,9 @@ static int set_guid_rec(struct ib_device *ibdev,
callback_context->port = port;
callback_context->dev = dev;
callback_context->block_num = index;
- callback_context->method = rec_det->method;
+ callback_context->guid_indexes = rec_det->guid_indexes;
+ callback_context->method = rec->method;
+
memset(&guid_info_rec, 0, sizeof (struct ib_sa_guidinfo_rec));
guid_info_rec.lid = cpu_to_be16(attr.lid);
@@ -413,7 +546,7 @@ static int set_guid_rec(struct ib_device *ibdev,
callback_context->query_id =
ib_sa_guid_info_rec_query(dev->sriov.alias_guid.sa_client,
ibdev, port, &guid_info_rec,
- comp_mask, rec_det->method, 1000,
+ comp_mask, rec->method, 1000,
GFP_KERNEL, aliasguid_query_handler,
callback_context,
&callback_context->sa_query);
@@ -448,6 +581,30 @@ out:
return err;
}
+static void mlx4_ib_guid_port_init(struct mlx4_ib_dev *dev, int port)
+{
+ int j, k, entry;
+ __be64 guid;
+
+ /*Check if the SM doesn't need to assign the GUIDs*/
+ for (j = 0; j < NUM_ALIAS_GUID_REC_IN_PORT; j++) {
+ for (k = 0; k < NUM_ALIAS_GUID_IN_REC; k++) {
+ entry = j * NUM_ALIAS_GUID_IN_REC + k;
+ /* no request for the 0 entry (hw guid) */
+ if (!entry || entry > dev->dev->persist->num_vfs ||
+ !mlx4_is_slave_active(dev->dev, entry))
+ continue;
+ guid = mlx4_get_admin_guid(dev->dev, entry, port);
+ *(__be64 *)&dev->sriov.alias_guid.ports_guid[port - 1].
+ all_rec_per_port[j].all_recs
+ [GUID_REC_SIZE * k] = guid;
+ pr_debug("guid was set, entry=%d, val=0x%llx, port=%d\n",
+ entry,
+ (long long)be64_to_cpu(guid),
+ port);
+ }
+ }
+}
void mlx4_ib_invalidate_all_guid_record(struct mlx4_ib_dev *dev, int port)
{
int i;
@@ -457,6 +614,13 @@ void mlx4_ib_invalidate_all_guid_record(struct mlx4_ib_dev *dev, int port)
spin_lock_irqsave(&dev->sriov.going_down_lock, flags);
spin_lock_irqsave(&dev->sriov.alias_guid.ag_work_lock, flags1);
+
+ if (dev->sriov.alias_guid.ports_guid[port - 1].state_flags &
+ GUID_STATE_NEED_PORT_INIT) {
+ mlx4_ib_guid_port_init(dev, port);
+ dev->sriov.alias_guid.ports_guid[port - 1].state_flags &=
+ (~GUID_STATE_NEED_PORT_INIT);
+ }
for (i = 0; i < NUM_ALIAS_GUID_REC_IN_PORT; i++)
invalidate_guid_record(dev, port, i);
@@ -476,60 +640,107 @@ void mlx4_ib_invalidate_all_guid_record(struct mlx4_ib_dev *dev, int port)
spin_unlock_irqrestore(&dev->sriov.going_down_lock, flags);
}
-/* The function returns the next record that was
- * not configured (or failed to be configured) */
-static int get_next_record_to_update(struct mlx4_ib_dev *dev, u8 port,
- struct mlx4_next_alias_guid_work *rec)
+static void set_required_record(struct mlx4_ib_dev *dev, u8 port,
+ struct mlx4_next_alias_guid_work *next_rec,
+ int record_index)
{
- int j;
- unsigned long flags;
+ int i;
+ int lowset_time_entry = -1;
+ int lowest_time = 0;
+ ib_sa_comp_mask delete_guid_indexes = 0;
+ ib_sa_comp_mask set_guid_indexes = 0;
+ struct mlx4_sriov_alias_guid_info_rec_det *rec =
+ &dev->sriov.alias_guid.ports_guid[port].
+ all_rec_per_port[record_index];
- for (j = 0; j < NUM_ALIAS_GUID_REC_IN_PORT; j++) {
- spin_lock_irqsave(&dev->sriov.alias_guid.ag_work_lock, flags);
- if (dev->sriov.alias_guid.ports_guid[port].all_rec_per_port[j].status ==
- MLX4_GUID_INFO_STATUS_IDLE) {
- memcpy(&rec->rec_det,
- &dev->sriov.alias_guid.ports_guid[port].all_rec_per_port[j],
- sizeof (struct mlx4_sriov_alias_guid_info_rec_det));
- rec->port = port;
- rec->block_num = j;
- dev->sriov.alias_guid.ports_guid[port].all_rec_per_port[j].status =
- MLX4_GUID_INFO_STATUS_PENDING;
- spin_unlock_irqrestore(&dev->sriov.alias_guid.ag_work_lock, flags);
- return 0;
+ for (i = 0; i < NUM_ALIAS_GUID_IN_REC; i++) {
+ if (!(rec->guid_indexes &
+ mlx4_ib_get_aguid_comp_mask_from_ix(i)))
+ continue;
+
+ if (*(__be64 *)&rec->all_recs[i * GUID_REC_SIZE] ==
+ cpu_to_be64(MLX4_GUID_FOR_DELETE_VAL))
+ delete_guid_indexes |=
+ mlx4_ib_get_aguid_comp_mask_from_ix(i);
+ else
+ set_guid_indexes |=
+ mlx4_ib_get_aguid_comp_mask_from_ix(i);
+
+ if (lowset_time_entry == -1 || rec->guids_retry_schedule[i] <=
+ lowest_time) {
+ lowset_time_entry = i;
+ lowest_time = rec->guids_retry_schedule[i];
}
- spin_unlock_irqrestore(&dev->sriov.alias_guid.ag_work_lock, flags);
}
- return -ENOENT;
+
+ memcpy(&next_rec->rec_det, rec, sizeof(*rec));
+ next_rec->port = port;
+ next_rec->block_num = record_index;
+
+ if (*(__be64 *)&rec->all_recs[lowset_time_entry * GUID_REC_SIZE] ==
+ cpu_to_be64(MLX4_GUID_FOR_DELETE_VAL)) {
+ next_rec->rec_det.guid_indexes = delete_guid_indexes;
+ next_rec->method = MLX4_GUID_INFO_RECORD_DELETE;
+ } else {
+ next_rec->rec_det.guid_indexes = set_guid_indexes;
+ next_rec->method = MLX4_GUID_INFO_RECORD_SET;
+ }
}
-static void set_administratively_guid_record(struct mlx4_ib_dev *dev, int port,
- int rec_index,
- struct mlx4_sriov_alias_guid_info_rec_det *rec_det)
+/* return index of record that should be updated based on lowest
+ * rescheduled time
+ */
+static int get_low_record_time_index(struct mlx4_ib_dev *dev, u8 port,
+ int *resched_delay_sec)
{
- dev->sriov.alias_guid.ports_guid[port].all_rec_per_port[rec_index].guid_indexes =
- rec_det->guid_indexes;
- memcpy(dev->sriov.alias_guid.ports_guid[port].all_rec_per_port[rec_index].all_recs,
- rec_det->all_recs, NUM_ALIAS_GUID_IN_REC * GUID_REC_SIZE);
- dev->sriov.alias_guid.ports_guid[port].all_rec_per_port[rec_index].status =
- rec_det->status;
+ int record_index = -1;
+ u64 low_record_time = 0;
+ struct mlx4_sriov_alias_guid_info_rec_det rec;
+ int j;
+
+ for (j = 0; j < NUM_ALIAS_GUID_REC_IN_PORT; j++) {
+ rec = dev->sriov.alias_guid.ports_guid[port].
+ all_rec_per_port[j];
+ if (rec.status == MLX4_GUID_INFO_STATUS_IDLE &&
+ rec.guid_indexes) {
+ if (record_index == -1 ||
+ rec.time_to_run < low_record_time) {
+ record_index = j;
+ low_record_time = rec.time_to_run;
+ }
+ }
+ }
+ if (resched_delay_sec) {
+ u64 curr_time = ktime_get_ns();
+
+ *resched_delay_sec = (low_record_time < curr_time) ? 0 :
+ div_u64((low_record_time - curr_time), NSEC_PER_SEC);
+ }
+
+ return record_index;
}
-static void set_all_slaves_guids(struct mlx4_ib_dev *dev, int port)
+/* The function returns the next record that was
+ * not configured (or failed to be configured) */
+static int get_next_record_to_update(struct mlx4_ib_dev *dev, u8 port,
+ struct mlx4_next_alias_guid_work *rec)
{
- int j;
- struct mlx4_sriov_alias_guid_info_rec_det rec_det ;
-
- for (j = 0 ; j < NUM_ALIAS_GUID_REC_IN_PORT ; j++) {
- memset(rec_det.all_recs, 0, NUM_ALIAS_GUID_IN_REC * GUID_REC_SIZE);
- rec_det.guid_indexes = (!j ? 0 : IB_SA_GUIDINFO_REC_GID0) |
- IB_SA_GUIDINFO_REC_GID1 | IB_SA_GUIDINFO_REC_GID2 |
- IB_SA_GUIDINFO_REC_GID3 | IB_SA_GUIDINFO_REC_GID4 |
- IB_SA_GUIDINFO_REC_GID5 | IB_SA_GUIDINFO_REC_GID6 |
- IB_SA_GUIDINFO_REC_GID7;
- rec_det.status = MLX4_GUID_INFO_STATUS_IDLE;
- set_administratively_guid_record(dev, port, j, &rec_det);
+ unsigned long flags;
+ int record_index;
+ int ret = 0;
+
+ spin_lock_irqsave(&dev->sriov.alias_guid.ag_work_lock, flags);
+ record_index = get_low_record_time_index(dev, port, NULL);
+
+ if (record_index < 0) {
+ ret = -ENOENT;
+ goto out;
}
+
+ set_required_record(dev, port, rec, record_index);
+out:
+ spin_unlock_irqrestore(&dev->sriov.alias_guid.ag_work_lock, flags);
+ return ret;
}
static void alias_guid_work(struct work_struct *work)
@@ -559,9 +770,7 @@ static void alias_guid_work(struct work_struct *work)
goto out;
}
- set_guid_rec(&dev->ib_dev, rec->port + 1, rec->block_num,
- &rec->rec_det);
-
+ set_guid_rec(&dev->ib_dev, rec);
out:
kfree(rec);
}
@@ -576,6 +785,12 @@ void mlx4_ib_init_alias_guid_work(struct mlx4_ib_dev *dev, int port)
spin_lock_irqsave(&dev->sriov.going_down_lock, flags);
spin_lock_irqsave(&dev->sriov.alias_guid.ag_work_lock, flags1);
if (!dev->sriov.is_going_down) {
+ /* If there is pending one should cancell then run, otherwise
+ * won't run till previous one is ended as same work
+ * struct is used.
+ */
+ cancel_delayed_work(&dev->sriov.alias_guid.ports_guid[port].
+ alias_guid_work);
queue_delayed_work(dev->sriov.alias_guid.ports_guid[port].wq,
&dev->sriov.alias_guid.ports_guid[port].alias_guid_work, 0);
}
@@ -623,7 +838,7 @@ int mlx4_ib_init_alias_guid_service(struct mlx4_ib_dev *dev)
{
char alias_wq_name[15];
int ret = 0;
- int i, j, k;
+ int i, j;
union ib_gid gid;
if (!mlx4_is_master(dev->dev))
@@ -647,37 +862,29 @@ int mlx4_ib_init_alias_guid_service(struct mlx4_ib_dev *dev)
for (i = 0 ; i < dev->num_ports; i++) {
memset(&dev->sriov.alias_guid.ports_guid[i], 0,
sizeof (struct mlx4_sriov_alias_guid_port_rec_det));
- /*Check if the SM doesn't need to assign the GUIDs*/
+ dev->sriov.alias_guid.ports_guid[i].state_flags |=
+ GUID_STATE_NEED_PORT_INIT;
for (j = 0; j < NUM_ALIAS_GUID_REC_IN_PORT; j++) {
- if (mlx4_ib_sm_guid_assign) {
- dev->sriov.alias_guid.ports_guid[i].
- all_rec_per_port[j].
- ownership = MLX4_GUID_DRIVER_ASSIGN;
- continue;
- }
- dev->sriov.alias_guid.ports_guid[i].all_rec_per_port[j].
- ownership = MLX4_GUID_NONE_ASSIGN;
- /*mark each val as it was deleted,
- till the sysAdmin will give it valid val*/
- for (k = 0; k < NUM_ALIAS_GUID_IN_REC; k++) {
- *(__be64 *)&dev->sriov.alias_guid.ports_guid[i].
- all_rec_per_port[j].all_recs[GUID_REC_SIZE * k] =
- cpu_to_be64(MLX4_GUID_FOR_DELETE_VAL);
- }
+ /* mark each val as it was deleted */
+ memset(dev->sriov.alias_guid.ports_guid[i].
+ all_rec_per_port[j].all_recs, 0xFF,
+ sizeof(dev->sriov.alias_guid.ports_guid[i].
+ all_rec_per_port[j].all_recs));
}
INIT_LIST_HEAD(&dev->sriov.alias_guid.ports_guid[i].cb_list);
/*prepare the records, set them to be allocated by sm*/
+ if (mlx4_ib_sm_guid_assign)
+ for (j = 1; j < NUM_ALIAS_GUID_PER_PORT; j++)
+ mlx4_set_admin_guid(dev->dev, 0, j, i + 1);
for (j = 0 ; j < NUM_ALIAS_GUID_REC_IN_PORT; j++)
invalidate_guid_record(dev, i + 1, j);
dev->sriov.alias_guid.ports_guid[i].parent = &dev->sriov.alias_guid;
dev->sriov.alias_guid.ports_guid[i].port = i;
- if (mlx4_ib_sm_guid_assign)
- set_all_slaves_guids(dev, i);
snprintf(alias_wq_name, sizeof alias_wq_name, "alias_guid%d", i);
dev->sriov.alias_guid.ports_guid[i].wq =
- create_singlethread_workqueue(alias_wq_name);
+ alloc_ordered_workqueue(alias_wq_name, WQ_MEM_RECLAIM);
if (!dev->sriov.alias_guid.ports_guid[i].wq) {
ret = -ENOMEM;
goto err_thread;
diff --git a/sys/dev/mlx4/mlx4_ib/mlx4_ib_cm.c b/sys/dev/mlx4/mlx4_ib/mlx4_ib_cm.c
index 4a89c54..4097369 100644
--- a/sys/dev/mlx4/mlx4_ib/mlx4_ib_cm.c
+++ b/sys/dev/mlx4/mlx4_ib/mlx4_ib_cm.c
@@ -242,8 +242,7 @@ static void sl_id_map_add(struct ib_device *ibdev, struct id_map_entry *new)
static struct id_map_entry *
id_map_alloc(struct ib_device *ibdev, int slave_id, u32 sl_cm_id)
{
- int ret, id;
- static int next_id;
+ int ret;
struct id_map_entry *ent;
struct mlx4_ib_sriov *sriov = &to_mdev(ibdev)->sriov;
@@ -259,25 +258,22 @@ id_map_alloc(struct ib_device *ibdev, int slave_id, u32 sl_cm_id)
ent->dev = to_mdev(ibdev);
INIT_DELAYED_WORK(&ent->timeout, id_map_ent_timeout);
- do {
- spin_lock(&to_mdev(ibdev)->sriov.id_map_lock);
- ret = idr_get_new_above(&sriov->pv_id_table, ent,
- next_id, &id);
- if (!ret) {
- next_id = ((unsigned) id + 1) & MAX_IDR_MASK;
- ent->pv_cm_id = (u32)id;
- sl_id_map_add(ibdev, ent);
- }
+ idr_preload(GFP_KERNEL);
+ spin_lock(&to_mdev(ibdev)->sriov.id_map_lock);
- spin_unlock(&sriov->id_map_lock);
- } while (ret == -EAGAIN && idr_pre_get(&sriov->pv_id_table, GFP_KERNEL));
- /*the function idr_get_new_above can return -ENOSPC, so don't insert in that case.*/
- if (!ret) {
- spin_lock(&sriov->id_map_lock);
+ ret = idr_alloc_cyclic(&sriov->pv_id_table, ent, 0, 0, GFP_NOWAIT);
+ if (ret >= 0) {
+ ent->pv_cm_id = (u32)ret;
+ sl_id_map_add(ibdev, ent);
list_add_tail(&ent->list, &sriov->cm_list);
- spin_unlock(&sriov->id_map_lock);
- return ent;
}
+
+ spin_unlock(&sriov->id_map_lock);
+ idr_preload_end();
+
+ if (ret >= 0)
+ return ent;
+
/*error flow*/
kfree(ent);
mlx4_ib_warn(ibdev, "No more space in the idr (err:0x%x)\n", ret);
@@ -327,8 +323,7 @@ int mlx4_ib_multiplex_cm_handler(struct ib_device *ibdev, int port, int slave_id
if (mad->mad_hdr.attr_id == CM_REQ_ATTR_ID ||
mad->mad_hdr.attr_id == CM_REP_ATTR_ID ||
- mad->mad_hdr.attr_id == CM_SIDR_REQ_ATTR_ID ||
- mad->mad_hdr.attr_id == CM_SIDR_REP_ATTR_ID) {
+ mad->mad_hdr.attr_id == CM_SIDR_REQ_ATTR_ID) {
sl_cm_id = get_local_comm_id(mad);
id = id_map_alloc(ibdev, slave_id, sl_cm_id);
if (IS_ERR(id)) {
@@ -361,7 +356,7 @@ int mlx4_ib_multiplex_cm_handler(struct ib_device *ibdev, int port, int slave_id
}
int mlx4_ib_demux_cm_handler(struct ib_device *ibdev, int port, int *slave,
- struct ib_mad *mad, int is_eth)
+ struct ib_mad *mad)
{
u32 pv_cm_id;
struct id_map_entry *id;
@@ -370,7 +365,7 @@ int mlx4_ib_demux_cm_handler(struct ib_device *ibdev, int port, int *slave,
mad->mad_hdr.attr_id == CM_SIDR_REQ_ATTR_ID) {
union ib_gid gid;
- if (is_eth)
+ if (!slave)
return 0;
gid = gid_from_req_msg(ibdev, mad);
@@ -391,7 +386,7 @@ int mlx4_ib_demux_cm_handler(struct ib_device *ibdev, int port, int *slave,
return -ENOENT;
}
- if (!is_eth)
+ if (slave)
*slave = id->slave_id;
set_remote_comm_id(mad, id->sl_cm_id);
@@ -411,7 +406,6 @@ void mlx4_ib_cm_paravirt_init(struct mlx4_ib_dev *dev)
INIT_LIST_HEAD(&dev->sriov.cm_list);
dev->sriov.sl_id_map = RB_ROOT;
idr_init(&dev->sriov.pv_id_table);
- idr_pre_get(&dev->sriov.pv_id_table, GFP_KERNEL);
}
/* slave = -1 ==> all slaves */
diff --git a/sys/dev/mlx4/mlx4_ib/mlx4_ib_cq.c b/sys/dev/mlx4/mlx4_ib/mlx4_ib_cq.c
index 11aab31..6ebca11 100644
--- a/sys/dev/mlx4/mlx4_ib/mlx4_ib_cq.c
+++ b/sys/dev/mlx4/mlx4_ib/mlx4_ib_cq.c
@@ -34,14 +34,11 @@
#include <dev/mlx4/cq.h>
#include <dev/mlx4/qp.h>
#include <dev/mlx4/srq.h>
+#include <dev/mlx4/driver.h>
#include <linux/slab.h>
#include "mlx4_ib.h"
-#include "user.h"
-
-/* Which firmware version adds support for Resize CQ */
-#define MLX4_FW_VER_RESIZE_CQ mlx4_fw_ver(2, 5, 0)
-#define MLX4_FW_VER_IGNORE_OVERRUN_CQ mlx4_fw_ver(2, 7, 8200)
+#include <rdma/mlx4-abi.h>
static void mlx4_ib_cq_comp(struct mlx4_cq *cq)
{
@@ -93,29 +90,12 @@ static struct mlx4_cqe *next_cqe_sw(struct mlx4_ib_cq *cq)
return get_sw_cqe(cq, cq->mcq.cons_index);
}
-int mlx4_ib_modify_cq(struct ib_cq *cq,
- struct ib_cq_attr *cq_attr,
- int cq_attr_mask)
+int mlx4_ib_modify_cq(struct ib_cq *cq, u16 cq_count, u16 cq_period)
{
- int err = 0;
struct mlx4_ib_cq *mcq = to_mcq(cq);
struct mlx4_ib_dev *dev = to_mdev(cq->device);
- if (cq_attr_mask & IB_CQ_CAP_FLAGS) {
- if (cq_attr->cq_cap_flags & IB_CQ_TIMESTAMP)
- return -ENOTSUPP;
-
- if (cq_attr->cq_cap_flags & IB_CQ_IGNORE_OVERRUN)
- return -ENOSYS;
- }
-
- if (!err)
- if (cq_attr_mask & IB_CQ_MODERATION)
- err = mlx4_cq_modify(dev->dev, &mcq->mcq,
- cq_attr->moderation.cq_count,
- cq_attr->moderation.cq_period);
-
- return err;
+ return mlx4_cq_modify(dev->dev, &mcq->mcq, cq_count, cq_period);
}
static int mlx4_ib_alloc_cq_buf(struct mlx4_ib_dev *dev, struct mlx4_ib_cq_buf *buf, int nent)
@@ -161,18 +141,14 @@ static int mlx4_ib_get_cq_umem(struct mlx4_ib_dev *dev, struct ib_ucontext *cont
{
int err;
int cqe_size = dev->dev->caps.cqe_size;
- int shift;
- int n;
*umem = ib_umem_get(context, buf_addr, cqe * cqe_size,
IB_ACCESS_LOCAL_WRITE, 1);
if (IS_ERR(*umem))
return PTR_ERR(*umem);
- n = ib_umem_page_count(*umem);
- shift = mlx4_ib_umem_calc_optimal_mtt_size(*umem, 0, &n);
- err = mlx4_mtt_init(dev->dev, n, shift, &buf->mtt);
-
+ err = mlx4_mtt_init(dev->dev, ib_umem_page_count(*umem),
+ ilog2((*umem)->page_size), &buf->mtt);
if (err)
goto err_buf;
@@ -191,20 +167,18 @@ err_buf:
return err;
}
-/* we don't support system timestamping */
-#define CQ_CREATE_FLAGS_SUPPORTED IB_CQ_TIMESTAMP
-
+#define CQ_CREATE_FLAGS_SUPPORTED IB_CQ_FLAGS_TIMESTAMP_COMPLETION
struct ib_cq *mlx4_ib_create_cq(struct ib_device *ibdev,
- struct ib_cq_init_attr *attr,
+ const struct ib_cq_init_attr *attr,
struct ib_ucontext *context,
struct ib_udata *udata)
{
+ int entries = attr->cqe;
+ int vector = attr->comp_vector;
struct mlx4_ib_dev *dev = to_mdev(ibdev);
struct mlx4_ib_cq *cq;
struct mlx4_uar *uar;
int err;
- int entries = attr->cqe;
- int vector = attr->comp_vector;
if (entries < 1 || entries > dev->dev->caps.max_cqes)
return ERR_PTR(-EINVAL);
@@ -212,7 +186,7 @@ struct ib_cq *mlx4_ib_create_cq(struct ib_device *ibdev,
if (attr->flags & ~CQ_CREATE_FLAGS_SUPPORTED)
return ERR_PTR(-EINVAL);
- cq = kzalloc(sizeof(*cq), GFP_KERNEL);
+ cq = kmalloc(sizeof *cq, GFP_KERNEL);
if (!cq)
return ERR_PTR(-ENOMEM);
@@ -223,6 +197,8 @@ struct ib_cq *mlx4_ib_create_cq(struct ib_device *ibdev,
cq->resize_buf = NULL;
cq->resize_umem = NULL;
cq->create_flags = attr->flags;
+ INIT_LIST_HEAD(&cq->send_qp_list);
+ INIT_LIST_HEAD(&cq->recv_qp_list);
if (context) {
struct mlx4_ib_create_cq ucmd;
@@ -265,21 +241,24 @@ struct ib_cq *mlx4_ib_create_cq(struct ib_device *ibdev,
err = mlx4_cq_alloc(dev->dev, entries, &cq->buf.mtt, uar,
cq->db.dma, &cq->mcq, vector, 0,
- !!(cq->create_flags & IB_CQ_TIMESTAMP));
+ !!(cq->create_flags & IB_CQ_FLAGS_TIMESTAMP_COMPLETION));
if (err)
goto err_dbmap;
- cq->mcq.comp = mlx4_ib_cq_comp;
+ cq->mcq.comp = mlx4_ib_cq_comp;
cq->mcq.event = mlx4_ib_cq_event;
if (context)
if (ib_copy_to_udata(udata, &cq->mcq.cqn, sizeof (__u32))) {
err = -EFAULT;
- goto err_dbmap;
+ goto err_cq_free;
}
return &cq->ibcq;
+err_cq_free:
+ mlx4_cq_free(dev->dev, &cq->mcq);
+
err_dbmap:
if (context)
mlx4_ib_db_unmap_user(to_mucontext(context), &cq->db);
@@ -310,7 +289,7 @@ static int mlx4_alloc_resize_buf(struct mlx4_ib_dev *dev, struct mlx4_ib_cq *cq,
if (cq->resize_buf)
return -EBUSY;
- cq->resize_buf = kmalloc(sizeof *cq->resize_buf, GFP_ATOMIC);
+ cq->resize_buf = kmalloc(sizeof *cq->resize_buf, GFP_KERNEL);
if (!cq->resize_buf)
return -ENOMEM;
@@ -338,7 +317,7 @@ static int mlx4_alloc_resize_umem(struct mlx4_ib_dev *dev, struct mlx4_ib_cq *cq
if (ib_copy_from_udata(&ucmd, udata, sizeof ucmd))
return -EFAULT;
- cq->resize_buf = kmalloc(sizeof *cq->resize_buf, GFP_ATOMIC);
+ cq->resize_buf = kmalloc(sizeof *cq->resize_buf, GFP_KERNEL);
if (!cq->resize_buf)
return -ENOMEM;
@@ -366,17 +345,15 @@ static int mlx4_ib_get_outstanding_cqes(struct mlx4_ib_cq *cq)
return i - cq->mcq.cons_index;
}
-static int mlx4_ib_cq_resize_copy_cqes(struct mlx4_ib_cq *cq)
+static void mlx4_ib_cq_resize_copy_cqes(struct mlx4_ib_cq *cq)
{
struct mlx4_cqe *cqe, *new_cqe;
int i;
int cqe_size = cq->buf.entry_size;
int cqe_inc = cqe_size == 64 ? 1 : 0;
- struct mlx4_cqe *start_cqe;
i = cq->mcq.cons_index;
cqe = get_cqe(cq, i & cq->ibcq.cqe);
- start_cqe = cqe;
cqe += cqe_inc;
while ((cqe->owner_sr_opcode & MLX4_CQE_OPCODE_MASK) != MLX4_CQE_OPCODE_RESIZE) {
@@ -388,15 +365,9 @@ static int mlx4_ib_cq_resize_copy_cqes(struct mlx4_ib_cq *cq)
new_cqe->owner_sr_opcode = (cqe->owner_sr_opcode & ~MLX4_CQE_OWNER_MASK) |
(((i + 1) & (cq->resize_buf->cqe + 1)) ? MLX4_CQE_OWNER_MASK : 0);
cqe = get_cqe(cq, ++i & cq->ibcq.cqe);
- if (cqe == start_cqe) {
- pr_warn("resize CQ failed to get resize CQE, CQN 0x%x\n", cq->mcq.cqn);
- return -ENOMEM;
- }
cqe += cqe_inc;
-
}
++cq->mcq.cons_index;
- return 0;
}
int mlx4_ib_resize_cq(struct ib_cq *ibcq, int entries, struct ib_udata *udata)
@@ -407,9 +378,6 @@ int mlx4_ib_resize_cq(struct ib_cq *ibcq, int entries, struct ib_udata *udata)
int outst_cqe;
int err;
- if (dev->dev->caps.fw_ver < MLX4_FW_VER_RESIZE_CQ)
- return -ENOSYS;
-
mutex_lock(&cq->resize_mutex);
if (entries < 1 || entries > dev->dev->caps.max_cqes) {
err = -EINVAL;
@@ -435,7 +403,7 @@ int mlx4_ib_resize_cq(struct ib_cq *ibcq, int entries, struct ib_udata *udata)
/* Can't be smaller than the number of outstanding CQEs */
outst_cqe = mlx4_ib_get_outstanding_cqes(cq);
if (entries < outst_cqe + 1) {
- err = 0;
+ err = -EINVAL;
goto out;
}
@@ -466,7 +434,7 @@ int mlx4_ib_resize_cq(struct ib_cq *ibcq, int entries, struct ib_udata *udata)
spin_lock_irq(&cq->lock);
if (cq->resize_buf) {
- err = mlx4_ib_cq_resize_copy_cqes(cq);
+ mlx4_ib_cq_resize_copy_cqes(cq);
tmp_buf = cq->buf;
tmp_cqe = cq->ibcq.cqe;
cq->buf = cq->resize_buf->buf;
@@ -503,11 +471,6 @@ out:
return err;
}
-int mlx4_ib_ignore_overrun_cq(struct ib_cq *ibcq)
-{
- return -ENOSYS;
-}
-
int mlx4_ib_destroy_cq(struct ib_cq *cq)
{
struct mlx4_ib_dev *dev = to_mdev(cq->device);
@@ -614,8 +577,8 @@ static int mlx4_ib_ipoib_csum_ok(__be16 status, __be16 checksum)
checksum == cpu_to_be16(0xffff);
}
-static int use_tunnel_data(struct mlx4_ib_qp *qp, struct mlx4_ib_cq *cq, struct ib_wc *wc,
- unsigned tail, struct mlx4_cqe *cqe, int is_eth)
+static void use_tunnel_data(struct mlx4_ib_qp *qp, struct mlx4_ib_cq *cq, struct ib_wc *wc,
+ unsigned tail, struct mlx4_cqe *cqe, int is_eth)
{
struct mlx4_ib_proxy_sqp_hdr *hdr;
@@ -633,12 +596,60 @@ static int use_tunnel_data(struct mlx4_ib_qp *qp, struct mlx4_ib_cq *cq, struct
wc->vlan_id = be16_to_cpu(hdr->tun.sl_vid);
memcpy(&(wc->smac[0]), (char *)&hdr->tun.mac_31_0, 4);
memcpy(&(wc->smac[4]), (char *)&hdr->tun.slid_mac_47_32, 2);
+ wc->wc_flags |= (IB_WC_WITH_VLAN | IB_WC_WITH_SMAC);
} else {
wc->slid = be16_to_cpu(hdr->tun.slid_mac_47_32);
wc->sl = (u8) (be16_to_cpu(hdr->tun.sl_vid) >> 12);
}
+}
- return 0;
+static void mlx4_ib_qp_sw_comp(struct mlx4_ib_qp *qp, int num_entries,
+ struct ib_wc *wc, int *npolled, int is_send)
+{
+ struct mlx4_ib_wq *wq;
+ unsigned cur;
+ int i;
+
+ wq = is_send ? &qp->sq : &qp->rq;
+ cur = wq->head - wq->tail;
+
+ if (cur == 0)
+ return;
+
+ for (i = 0; i < cur && *npolled < num_entries; i++) {
+ wc->wr_id = wq->wrid[wq->tail & (wq->wqe_cnt - 1)];
+ wc->status = IB_WC_WR_FLUSH_ERR;
+ wc->vendor_err = MLX4_CQE_SYNDROME_WR_FLUSH_ERR;
+ wq->tail++;
+ (*npolled)++;
+ wc->qp = &qp->ibqp;
+ wc++;
+ }
+}
+
+static void mlx4_ib_poll_sw_comp(struct mlx4_ib_cq *cq, int num_entries,
+ struct ib_wc *wc, int *npolled)
+{
+ struct mlx4_ib_qp *qp;
+
+ *npolled = 0;
+ /* Find uncompleted WQEs belonging to that cq and retrun
+ * simulated FLUSH_ERR completions
+ */
+ list_for_each_entry(qp, &cq->send_qp_list, cq_send_list) {
+ mlx4_ib_qp_sw_comp(qp, num_entries, wc + *npolled, npolled, 1);
+ if (*npolled >= num_entries)
+ goto out;
+ }
+
+ list_for_each_entry(qp, &cq->recv_qp_list, cq_recv_list) {
+ mlx4_ib_qp_sw_comp(qp, num_entries, wc + *npolled, npolled, 0);
+ if (*npolled >= num_entries)
+ goto out;
+ }
+
+out:
+ return;
}
static int mlx4_ib_poll_one(struct mlx4_ib_cq *cq,
@@ -652,11 +663,10 @@ static int mlx4_ib_poll_one(struct mlx4_ib_cq *cq,
struct mlx4_srq *msrq = NULL;
int is_send;
int is_error;
+ int is_eth;
u32 g_mlpath_rqpn;
u16 wqe_ctr;
unsigned tail = 0;
- int timestamp_en = !!(cq->create_flags & IB_CQ_TIMESTAMP);
-
repoll:
cqe = next_cqe_sw(cq);
@@ -678,12 +688,6 @@ repoll:
is_error = (cqe->owner_sr_opcode & MLX4_CQE_OPCODE_MASK) ==
MLX4_CQE_OPCODE_ERROR;
- if (unlikely((cqe->owner_sr_opcode & MLX4_CQE_OPCODE_MASK) == MLX4_OPCODE_NOP &&
- is_send)) {
- pr_warn("Completion for NOP opcode detected!\n");
- return -EINVAL;
- }
-
/* Resize CQ in progress */
if (unlikely((cqe->owner_sr_opcode & MLX4_CQE_OPCODE_MASK) == MLX4_CQE_OPCODE_RESIZE)) {
if (cq->resize_buf) {
@@ -709,12 +713,6 @@ repoll:
*/
mqp = __mlx4_qp_lookup(to_mdev(cq->ibcq.device)->dev,
be32_to_cpu(cqe->vlan_my_qpn));
- if (unlikely(!mqp)) {
- pr_warn("CQ %06x with entry for unknown QPN %06x\n",
- cq->mcq.cqn, be32_to_cpu(cqe->vlan_my_qpn) & MLX4_CQE_QPN_MASK);
- return -EINVAL;
- }
-
*cur_qp = to_mibqp(mqp);
}
@@ -727,11 +725,6 @@ repoll:
/* SRQ is also in the radix tree */
msrq = mlx4_srq_lookup(to_mdev(cq->ibcq.device)->dev,
srq_num);
- if (unlikely(!msrq)) {
- pr_warn("CQ %06x with entry for unknown SRQN %06x\n",
- cq->mcq.cqn, srq_num);
- return -EINVAL;
- }
}
if (is_send) {
@@ -771,7 +764,6 @@ repoll:
switch (cqe->owner_sr_opcode & MLX4_CQE_OPCODE_MASK) {
case MLX4_OPCODE_RDMA_WRITE_IMM:
wc->wc_flags |= IB_WC_WITH_IMM;
- /* fall through */
case MLX4_OPCODE_RDMA_WRITE:
wc->opcode = IB_WC_RDMA_WRITE;
break;
@@ -801,14 +793,11 @@ repoll:
wc->opcode = IB_WC_MASKED_FETCH_ADD;
wc->byte_len = 8;
break;
- case MLX4_OPCODE_BIND_MW:
- wc->opcode = IB_WC_BIND_MW;
- break;
case MLX4_OPCODE_LSO:
wc->opcode = IB_WC_LSO;
break;
case MLX4_OPCODE_FMR:
- wc->opcode = IB_WC_FAST_REG_MR;
+ wc->opcode = IB_WC_REG_MR;
break;
case MLX4_OPCODE_LOCAL_INVAL:
wc->opcode = IB_WC_LOCAL_INV;
@@ -839,37 +828,20 @@ repoll:
break;
}
+ is_eth = (rdma_port_get_link_layer(wc->qp->device,
+ (*cur_qp)->port) ==
+ IB_LINK_LAYER_ETHERNET);
if (mlx4_is_mfunc(to_mdev(cq->ibcq.device)->dev)) {
if ((*cur_qp)->mlx4_ib_qp_type &
(MLX4_IB_QPT_PROXY_SMI_OWNER |
- MLX4_IB_QPT_PROXY_SMI | MLX4_IB_QPT_PROXY_GSI))
- return use_tunnel_data
- (*cur_qp, cq, wc, tail, cqe,
- rdma_port_get_link_layer
- (wc->qp->device,
- (*cur_qp)->port) ==
- IB_LINK_LAYER_ETHERNET);
- }
-
- if (timestamp_en) {
- const struct mlx4_ts_cqe *ts_cqe =
- (const struct mlx4_ts_cqe *)cqe;
- /* currently, only CQ_CREATE_WITH_TIMESTAMPING_RAW is
- * supported. CQ_CREATE_WITH_TIMESTAMPING_SYS isn't
- * supported */
- if (cq->create_flags & IB_CQ_TIMESTAMP_TO_SYS_TIME) {
- wc->ts.timestamp = 0;
- } else {
- wc->ts.timestamp =
- ((u64)(be32_to_cpu(ts_cqe->timestamp_hi)
- + !ts_cqe->timestamp_lo) << 16)
- | be16_to_cpu(ts_cqe->timestamp_lo);
- wc->wc_flags |= IB_WC_WITH_TIMESTAMP;
+ MLX4_IB_QPT_PROXY_SMI | MLX4_IB_QPT_PROXY_GSI)) {
+ use_tunnel_data(*cur_qp, cq, wc, tail, cqe,
+ is_eth);
+ return 0;
}
- } else {
- wc->wc_flags |= IB_WC_WITH_SLID;
- wc->slid = be16_to_cpu(cqe->rlid);
}
+
+ wc->slid = be16_to_cpu(cqe->rlid);
g_mlpath_rqpn = be32_to_cpu(cqe->g_mlpath_rqpn);
wc->src_qp = g_mlpath_rqpn & 0xffffff;
wc->dlid_path_bits = (g_mlpath_rqpn >> 24) & 0x7f;
@@ -877,27 +849,21 @@ repoll:
wc->pkey_index = be32_to_cpu(cqe->immed_rss_invalid) & 0x7f;
wc->wc_flags |= mlx4_ib_ipoib_csum_ok(cqe->status,
cqe->checksum) ? IB_WC_IP_CSUM_OK : 0;
- if (!timestamp_en) {
- if (rdma_port_get_link_layer(wc->qp->device,
- (*cur_qp)->port) ==
- IB_LINK_LAYER_ETHERNET)
- wc->sl = be16_to_cpu(cqe->sl_vid) >> 13;
- else
- wc->sl = be16_to_cpu(cqe->sl_vid) >> 12;
- wc->wc_flags |= IB_WC_WITH_SL;
- }
- if ((be32_to_cpu(cqe->vlan_my_qpn) &
- MLX4_CQE_CVLAN_PRESENT_MASK) && !timestamp_en) {
- wc->vlan_id = be16_to_cpu(cqe->sl_vid) &
- MLX4_CQE_VID_MASK;
- wc->wc_flags |= IB_WC_WITH_VLAN;
+ if (is_eth) {
+ wc->sl = be16_to_cpu(cqe->sl_vid) >> 13;
+ if (be32_to_cpu(cqe->vlan_my_qpn) &
+ MLX4_CQE_CVLAN_PRESENT_MASK) {
+ wc->vlan_id = be16_to_cpu(cqe->sl_vid) &
+ MLX4_CQE_VID_MASK;
+ } else {
+ wc->vlan_id = 0xffff;
+ }
+ memcpy(wc->smac, cqe->smac, ETH_ALEN);
+ wc->wc_flags |= (IB_WC_WITH_VLAN | IB_WC_WITH_SMAC);
} else {
+ wc->sl = be16_to_cpu(cqe->sl_vid) >> 12;
wc->vlan_id = 0xffff;
}
- if (!timestamp_en) {
- memcpy(wc->smac, cqe->smac, 6);
- wc->wc_flags |= IB_WC_WITH_SMAC;
- }
}
return 0;
@@ -909,24 +875,25 @@ int mlx4_ib_poll_cq(struct ib_cq *ibcq, int num_entries, struct ib_wc *wc)
struct mlx4_ib_qp *cur_qp = NULL;
unsigned long flags;
int npolled;
- int err = 0;
+ struct mlx4_ib_dev *mdev = to_mdev(cq->ibcq.device);
spin_lock_irqsave(&cq->lock, flags);
+ if (mdev->dev->persist->state & MLX4_DEVICE_STATE_INTERNAL_ERROR) {
+ mlx4_ib_poll_sw_comp(cq, num_entries, wc, &npolled);
+ goto out;
+ }
for (npolled = 0; npolled < num_entries; ++npolled) {
- err = mlx4_ib_poll_one(cq, &cur_qp, wc + npolled);
- if (err)
+ if (mlx4_ib_poll_one(cq, &cur_qp, wc + npolled))
break;
}
mlx4_cq_set_ci(&cq->mcq);
+out:
spin_unlock_irqrestore(&cq->lock, flags);
- if (err == 0 || err == -EAGAIN)
- return npolled;
- else
- return err;
+ return npolled;
}
int mlx4_ib_arm_cq(struct ib_cq *ibcq, enum ib_cq_notify_flags flags)
@@ -934,7 +901,7 @@ int mlx4_ib_arm_cq(struct ib_cq *ibcq, enum ib_cq_notify_flags flags)
mlx4_cq_arm(&to_mcq(ibcq)->mcq,
(flags & IB_CQ_SOLICITED_MASK) == IB_CQ_SOLICITED ?
MLX4_CQ_DB_REQ_NOT_SOL : MLX4_CQ_DB_REQ_NOT,
- to_mdev(ibcq->device)->priv_uar.map,
+ to_mdev(ibcq->device)->uar_map,
MLX4_GET_DOORBELL_LOCK(&to_mdev(ibcq->device)->uar_lock));
return 0;
diff --git a/sys/dev/mlx4/mlx4_ib/mlx4_ib_exp.c b/sys/dev/mlx4/mlx4_ib/mlx4_ib_exp.c
deleted file mode 100644
index 8a706e3..0000000
--- a/sys/dev/mlx4/mlx4_ib/mlx4_ib_exp.c
+++ /dev/null
@@ -1,116 +0,0 @@
-/*
- * Copyright (c) 2006, 2007 Cisco Systems, Inc. All rights reserved.
- * Copyright (c) 2007, 2008 Mellanox Technologies. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-#include "mlx4_ib.h"
-#include "mlx4_exp.h"
-#include <dev/mlx4/qp.h>
-
-int mlx4_ib_exp_query_device(struct ib_device *ibdev,
- struct ib_exp_device_attr *props)
-{
- struct ib_device_attr *base = &props->base;
- struct mlx4_ib_dev *dev = to_mdev(ibdev);
- int ret = mlx4_ib_query_device(ibdev, &props->base);
-
- props->exp_comp_mask = IB_EXP_DEVICE_ATTR_INLINE_RECV_SZ;
- props->inline_recv_sz = dev->dev->caps.max_rq_sg * sizeof(struct mlx4_wqe_data_seg);
- props->device_cap_flags2 = 0;
-
- /* move RSS device cap from device_cap to device_cap_flags2 */
- if (base->device_cap_flags & IB_DEVICE_QPG) {
- props->device_cap_flags2 |= IB_EXP_DEVICE_QPG;
- if (base->device_cap_flags & IB_DEVICE_UD_RSS)
- props->device_cap_flags2 |= IB_EXP_DEVICE_UD_RSS;
- }
- base->device_cap_flags &= ~(IB_DEVICE_QPG |
- IB_DEVICE_UD_RSS |
- IB_DEVICE_UD_TSS);
-
- if (base->max_rss_tbl_sz > 0) {
- props->max_rss_tbl_sz = base->max_rss_tbl_sz;
- props->exp_comp_mask |= IB_EXP_DEVICE_ATTR_RSS_TBL_SZ;
- } else {
- props->max_rss_tbl_sz = 0;
- props->exp_comp_mask &= ~IB_EXP_DEVICE_ATTR_RSS_TBL_SZ;
- }
-
- if (props->device_cap_flags2)
- props->exp_comp_mask |= IB_EXP_DEVICE_ATTR_CAP_FLAGS2;
-
- return ret;
-}
-
-/*
- * Experimental functions
- */
-struct ib_qp *mlx4_ib_exp_create_qp(struct ib_pd *pd,
- struct ib_exp_qp_init_attr *init_attr,
- struct ib_udata *udata)
-{
- int rwqe_size;
- struct ib_qp *qp;
- struct mlx4_ib_qp *mqp;
- int use_inlr;
- struct mlx4_ib_dev *dev;
-
- if (init_attr->max_inl_recv && !udata)
- return ERR_PTR(-EINVAL);
-
- use_inlr = mlx4_ib_qp_has_rq((struct ib_qp_init_attr *)init_attr) &&
- init_attr->max_inl_recv && pd;
- if (use_inlr) {
- rwqe_size = roundup_pow_of_two(max(1U, init_attr->cap.max_recv_sge)) *
- sizeof(struct mlx4_wqe_data_seg);
- if (rwqe_size < init_attr->max_inl_recv) {
- dev = to_mdev(pd->device);
- init_attr->max_inl_recv = min(init_attr->max_inl_recv,
- (u32)(dev->dev->caps.max_rq_sg *
- sizeof(struct mlx4_wqe_data_seg)));
- init_attr->cap.max_recv_sge = roundup_pow_of_two(init_attr->max_inl_recv) /
- sizeof(struct mlx4_wqe_data_seg);
- }
- } else {
- init_attr->max_inl_recv = 0;
- }
- qp = mlx4_ib_create_qp(pd, (struct ib_qp_init_attr *)init_attr, udata);
- if (IS_ERR(qp))
- return qp;
-
- if (use_inlr) {
- mqp = to_mqp(qp);
- mqp->max_inlr_data = 1 << mqp->rq.wqe_shift;
- init_attr->max_inl_recv = mqp->max_inlr_data;
- }
-
- return qp;
-}
diff --git a/sys/dev/mlx4/mlx4_ib/mlx4_ib_mad.c b/sys/dev/mlx4/mlx4_ib/mlx4_ib_mad.c
index e0ff3d8..183ccec 100644
--- a/sys/dev/mlx4/mlx4_ib/mlx4_ib_mad.c
+++ b/sys/dev/mlx4/mlx4_ib/mlx4_ib_mad.c
@@ -37,6 +37,7 @@
#include <linux/random.h>
#include <dev/mlx4/cmd.h>
+#include <dev/mlx4/driver.h>
#include <linux/gfp.h>
#include <rdma/ib_pma.h>
@@ -103,8 +104,9 @@ __be64 mlx4_ib_get_new_demux_tid(struct mlx4_ib_demux_ctx *ctx)
}
int mlx4_MAD_IFC(struct mlx4_ib_dev *dev, int mad_ifc_flags,
- int port, struct ib_wc *in_wc, struct ib_grh *in_grh,
- void *in_mad, void *response_mad)
+ int port, const struct ib_wc *in_wc,
+ const struct ib_grh *in_grh,
+ const void *in_mad, void *response_mad)
{
struct mlx4_cmd_mailbox *inmailbox, *outmailbox;
void *inbox;
@@ -212,7 +214,7 @@ static void update_sm_ah(struct mlx4_ib_dev *dev, u8 port_num, u16 lid, u8 sl)
* Snoop SM MADs for port info, GUID info, and P_Key table sets, so we can
* synthesize LID change, Client-Rereg, GID change, and P_Key change events.
*/
-static void smp_snoop(struct ib_device *ibdev, u8 port_num, struct ib_mad *mad,
+static void smp_snoop(struct ib_device *ibdev, u8 port_num, const struct ib_mad *mad,
u16 prev_lid)
{
struct ib_port_info *pinfo;
@@ -228,6 +230,8 @@ static void smp_snoop(struct ib_device *ibdev, u8 port_num, struct ib_mad *mad,
mad->mad_hdr.method == IB_MGMT_METHOD_SET)
switch (mad->mad_hdr.attr_id) {
case IB_SMP_ATTR_PORT_INFO:
+ if (dev->dev->caps.flags & MLX4_DEV_CAP_FLAG_PORT_MNG_CHG_EV)
+ return;
pinfo = (struct ib_port_info *) ((struct ib_smp *) mad)->data;
lid = be16_to_cpu(pinfo->lid);
@@ -243,6 +247,8 @@ static void smp_snoop(struct ib_device *ibdev, u8 port_num, struct ib_mad *mad,
break;
case IB_SMP_ATTR_PKEY_TABLE:
+ if (dev->dev->caps.flags & MLX4_DEV_CAP_FLAG_PORT_MNG_CHG_EV)
+ return;
if (!mlx4_is_mfunc(dev->dev)) {
mlx4_ib_dispatch_event(dev, port_num,
IB_EVENT_PKEY_CHANGE);
@@ -279,6 +285,8 @@ static void smp_snoop(struct ib_device *ibdev, u8 port_num, struct ib_mad *mad,
break;
case IB_SMP_ATTR_GUID_INFO:
+ if (dev->dev->caps.flags & MLX4_DEV_CAP_FLAG_PORT_MNG_CHG_EV)
+ return;
/* paravirtualized master's guid is guid 0 -- does not change */
if (!mlx4_is_master(dev->dev))
mlx4_ib_dispatch_event(dev, port_num,
@@ -294,6 +302,25 @@ static void smp_snoop(struct ib_device *ibdev, u8 port_num, struct ib_mad *mad,
}
break;
+ case IB_SMP_ATTR_SL_TO_VL_TABLE:
+ /* cache sl to vl mapping changes for use in
+ * filling QP1 LRH VL field when sending packets
+ */
+ if (dev->dev->caps.flags & MLX4_DEV_CAP_FLAG_PORT_MNG_CHG_EV &&
+ dev->dev->caps.flags2 & MLX4_DEV_CAP_FLAG2_SL_TO_VL_CHANGE_EVENT)
+ return;
+ if (!mlx4_is_slave(dev->dev)) {
+ union sl2vl_tbl_to_u64 sl2vl64;
+ int jj;
+
+ for (jj = 0; jj < 8; jj++) {
+ sl2vl64.sl8[jj] = ((struct ib_smp *)mad)->data[jj];
+ pr_debug("sl2vl[%d] = %02x\n", jj, sl2vl64.sl8[jj]);
+ }
+ atomic64_set(&dev->sl2vl[port_num - 1], sl2vl64.sl64);
+ }
+ break;
+
default:
break;
}
@@ -343,12 +370,13 @@ static void node_desc_override(struct ib_device *dev,
mad->mad_hdr.method == IB_MGMT_METHOD_GET_RESP &&
mad->mad_hdr.attr_id == IB_SMP_ATTR_NODE_DESC) {
spin_lock_irqsave(&to_mdev(dev)->sm_lock, flags);
- memcpy(((struct ib_smp *) mad)->data, dev->node_desc, 64);
+ memcpy(((struct ib_smp *) mad)->data, dev->node_desc,
+ IB_DEVICE_NODE_DESC_MAX);
spin_unlock_irqrestore(&to_mdev(dev)->sm_lock, flags);
}
}
-static void forward_trap(struct mlx4_ib_dev *dev, u8 port_num, struct ib_mad *mad)
+static void forward_trap(struct mlx4_ib_dev *dev, u8 port_num, const struct ib_mad *mad)
{
int qpn = mad->mad_hdr.mgmt_class != IB_MGMT_CLASS_SUBN_LID_ROUTED;
struct ib_mad_send_buf *send_buf;
@@ -358,7 +386,8 @@ static void forward_trap(struct mlx4_ib_dev *dev, u8 port_num, struct ib_mad *ma
if (agent) {
send_buf = ib_create_send_mad(agent, qpn, 0, 0, IB_MGMT_MAD_HDR,
- IB_MGMT_MAD_DATA, GFP_ATOMIC);
+ IB_MGMT_MAD_DATA, GFP_ATOMIC,
+ IB_MGMT_BASE_VERSION);
if (IS_ERR(send_buf))
return;
/*
@@ -455,7 +484,8 @@ int mlx4_ib_send_to_slave(struct mlx4_ib_dev *dev, int slave, u8 port,
struct ib_grh *grh, struct ib_mad *mad)
{
struct ib_sge list;
- struct ib_send_wr wr, *bad_wr;
+ struct ib_ud_wr wr;
+ struct ib_send_wr *bad_wr;
struct mlx4_ib_demux_pv_ctx *tun_ctx;
struct mlx4_ib_demux_pv_qp *tun_qp;
struct mlx4_rcv_tunnel_mad *tun_mad;
@@ -478,10 +508,6 @@ int mlx4_ib_send_to_slave(struct mlx4_ib_dev *dev, int slave, u8 port,
if (!tun_ctx || tun_ctx->state != DEMUX_PV_STATE_ACTIVE)
return -EAGAIN;
- /* QP0 forwarding only for Dom0 */
- if (!dest_qpt && (mlx4_master_func_num(dev->dev) != slave))
- return -EINVAL;
-
if (!dest_qpt)
tun_qp = &tun_ctx->qp[0];
else
@@ -527,7 +553,7 @@ int mlx4_ib_send_to_slave(struct mlx4_ib_dev *dev, int slave, u8 port,
tun_tx_ix = (++tun_qp->tx_ix_head) & (MLX4_NUM_TUNNEL_BUFS - 1);
spin_unlock(&tun_qp->tx_lock);
if (ret)
- goto out;
+ goto end;
tun_mad = (struct mlx4_rcv_tunnel_mad *) (tun_qp->tx_ring[tun_tx_ix].buf.addr);
if (tun_qp->tx_ring[tun_tx_ix].ah)
@@ -551,14 +577,20 @@ int mlx4_ib_send_to_slave(struct mlx4_ib_dev *dev, int slave, u8 port,
if (is_eth) {
u16 vlan = 0;
if (mlx4_get_slave_default_vlan(dev->dev, port, slave, &vlan,
- NULL)) {
- if (vlan != wc->vlan_id)
- /* VST and default vlan is not the packet vlan drop the
- * packet*/
+ NULL)) {
+ /* VST mode */
+ if (vlan != wc->vlan_id) {
+ /* Packet vlan is not the VST-assigned vlan.
+ * Drop the packet.
+ */
+ ret = -EPERM;
goto out;
- else
- /* VST , remove hide the vlan from the VF */
- vlan = 0;
+ } else {
+ /* Remove the vlan tag before forwarding
+ * the packet to the VF.
+ */
+ vlan = 0xffff;
+ }
} else {
vlan = wc->vlan_id;
}
@@ -578,23 +610,29 @@ int mlx4_ib_send_to_slave(struct mlx4_ib_dev *dev, int slave, u8 port,
list.addr = tun_qp->tx_ring[tun_tx_ix].buf.map;
list.length = sizeof (struct mlx4_rcv_tunnel_mad);
- list.lkey = tun_ctx->mr->lkey;
-
- wr.wr.ud.ah = ah;
- wr.wr.ud.port_num = port;
- wr.wr.ud.remote_qkey = IB_QP_SET_QKEY;
- wr.wr.ud.remote_qpn = dqpn;
- wr.next = NULL;
- wr.wr_id = ((u64) tun_tx_ix) | MLX4_TUN_SET_WRID_QPN(dest_qpt);
- wr.sg_list = &list;
- wr.num_sge = 1;
- wr.opcode = IB_WR_SEND;
- wr.send_flags = IB_SEND_SIGNALED;
-
- ret = ib_post_send(src_qp, &wr, &bad_wr);
-out:
- if (ret)
- ib_destroy_ah(ah);
+ list.lkey = tun_ctx->pd->local_dma_lkey;
+
+ wr.ah = ah;
+ wr.port_num = port;
+ wr.remote_qkey = IB_QP_SET_QKEY;
+ wr.remote_qpn = dqpn;
+ wr.wr.next = NULL;
+ wr.wr.wr_id = ((u64) tun_tx_ix) | MLX4_TUN_SET_WRID_QPN(dest_qpt);
+ wr.wr.sg_list = &list;
+ wr.wr.num_sge = 1;
+ wr.wr.opcode = IB_WR_SEND;
+ wr.wr.send_flags = IB_SEND_SIGNALED;
+
+ ret = ib_post_send(src_qp, &wr.wr, &bad_wr);
+ if (!ret)
+ return 0;
+ out:
+ spin_lock(&tun_qp->tx_lock);
+ tun_qp->tx_ix_tail++;
+ spin_unlock(&tun_qp->tx_lock);
+ tun_qp->tx_ring[tun_tx_ix].ah = NULL;
+end:
+ ib_destroy_ah(ah);
return ret;
}
@@ -603,8 +641,8 @@ static int mlx4_ib_demux_mad(struct ib_device *ibdev, u8 port,
struct ib_mad *mad)
{
struct mlx4_ib_dev *dev = to_mdev(ibdev);
- int err;
- int slave;
+ int err, other_port;
+ int slave = -1;
u8 *slave_id;
int is_eth = 0;
@@ -622,7 +660,17 @@ static int mlx4_ib_demux_mad(struct ib_device *ibdev, u8 port,
mlx4_ib_warn(ibdev, "RoCE mgmt class is not CM\n");
return -EINVAL;
}
- if (mlx4_get_slave_from_roce_gid(dev->dev, port, grh->dgid.raw, &slave)) {
+ err = mlx4_get_slave_from_roce_gid(dev->dev, port, grh->dgid.raw, &slave);
+ if (err && mlx4_is_mf_bonded(dev->dev)) {
+ other_port = (port == 1) ? 2 : 1;
+ err = mlx4_get_slave_from_roce_gid(dev->dev, other_port, grh->dgid.raw, &slave);
+ if (!err) {
+ port = other_port;
+ pr_debug("resolved slave %d from gid %pI6 wire port %d other %d\n",
+ slave, grh->dgid.raw, port, other_port);
+ }
+ }
+ if (err) {
mlx4_ib_warn(ibdev, "failed matching grh\n");
return -ENOENT;
}
@@ -632,7 +680,7 @@ static int mlx4_ib_demux_mad(struct ib_device *ibdev, u8 port,
return -ENOENT;
}
- if (mlx4_ib_demux_cm_handler(ibdev, port, &slave, mad, is_eth))
+ if (mlx4_ib_demux_cm_handler(ibdev, port, NULL, mad))
return 0;
err = mlx4_ib_send_to_slave(dev, slave, port, wc->qp->qp_type, wc, grh, mad);
@@ -663,13 +711,28 @@ static int mlx4_ib_demux_mad(struct ib_device *ibdev, u8 port,
}
/* Class-specific handling */
switch (mad->mad_hdr.mgmt_class) {
+ case IB_MGMT_CLASS_SUBN_LID_ROUTED:
+ case IB_MGMT_CLASS_SUBN_DIRECTED_ROUTE:
+ /* 255 indicates the dom0 */
+ if (slave != 255 && slave != mlx4_master_func_num(dev->dev)) {
+ if (!mlx4_vf_smi_enabled(dev->dev, slave, port))
+ return -EPERM;
+ /* for a VF. drop unsolicited MADs */
+ if (!(mad->mad_hdr.method & IB_MGMT_METHOD_RESP)) {
+ mlx4_ib_warn(ibdev, "demux QP0. rejecting unsolicited mad for slave %d class 0x%x, method 0x%x\n",
+ slave, mad->mad_hdr.mgmt_class,
+ mad->mad_hdr.method);
+ return -EINVAL;
+ }
+ }
+ break;
case IB_MGMT_CLASS_SUBN_ADM:
if (mlx4_ib_demux_sa_handler(ibdev, port, slave,
(struct ib_sa_mad *) mad))
return 0;
break;
case IB_MGMT_CLASS_CM:
- if (mlx4_ib_demux_cm_handler(ibdev, port, &slave, mad, is_eth))
+ if (mlx4_ib_demux_cm_handler(ibdev, port, &slave, mad))
return 0;
break;
case IB_MGMT_CLASS_DEVICE_MGMT:
@@ -699,8 +762,8 @@ static int mlx4_ib_demux_mad(struct ib_device *ibdev, u8 port,
}
static int ib_process_mad(struct ib_device *ibdev, int mad_flags, u8 port_num,
- struct ib_wc *in_wc, struct ib_grh *in_grh,
- struct ib_mad *in_mad, struct ib_mad *out_mad)
+ const struct ib_wc *in_wc, const struct ib_grh *in_grh,
+ const struct ib_mad *in_mad, struct ib_mad *out_mad)
{
u16 slid, prev_lid = 0;
int err;
@@ -770,8 +833,7 @@ static int ib_process_mad(struct ib_device *ibdev, int mad_flags, u8 port_num,
return IB_MAD_RESULT_FAILURE;
if (!out_mad->mad_hdr.status) {
- if (!(to_mdev(ibdev)->dev->caps.flags & MLX4_DEV_CAP_FLAG_PORT_MNG_CHG_EV))
- smp_snoop(ibdev, port_num, in_mad, prev_lid);
+ smp_snoop(ibdev, port_num, in_mad, prev_lid);
/* slaves get node desc from FW */
if (!mlx4_is_slave(to_mdev(ibdev)->dev))
node_desc_override(ibdev, out_mad);
@@ -825,38 +887,54 @@ static void edit_counter(struct mlx4_counter *cnt, void *counters,
}
}
+static int iboe_process_mad_port_info(void *out_mad)
+{
+ struct ib_class_port_info cpi = {};
+
+ cpi.capability_mask = IB_PMA_CLASS_CAP_EXT_WIDTH;
+ memcpy(out_mad, &cpi, sizeof(cpi));
+ return IB_MAD_RESULT_SUCCESS | IB_MAD_RESULT_REPLY;
+}
+
static int iboe_process_mad(struct ib_device *ibdev, int mad_flags, u8 port_num,
const struct ib_wc *in_wc, const struct ib_grh *in_grh,
const struct ib_mad *in_mad, struct ib_mad *out_mad)
{
struct mlx4_counter counter_stats;
struct mlx4_ib_dev *dev = to_mdev(ibdev);
- int err;
- u32 counter_index = dev->counters[port_num - 1].counter_index & 0xffff;
+ struct counter_index *tmp_counter;
+ int err = IB_MAD_RESULT_FAILURE, stats_avail = 0;
if (in_mad->mad_hdr.mgmt_class != IB_MGMT_CLASS_PERF_MGMT)
return -EINVAL;
- /* in case of default counter IB shares the counter with ETH */
- /* the state could be -EEXIST or -ENOSPC */
- if (dev->counters[port_num - 1].status) {
- memset(out_mad->data, 0, sizeof out_mad->data);
- err = IB_MAD_RESULT_SUCCESS | IB_MAD_RESULT_REPLY;
- } else {
- memset(&counter_stats, 0, sizeof(counter_stats));
+ if (in_mad->mad_hdr.attr_id == IB_PMA_CLASS_PORT_INFO)
+ return iboe_process_mad_port_info((void *)(out_mad->data + 40));
+
+ memset(&counter_stats, 0, sizeof(counter_stats));
+ mutex_lock(&dev->counters_table[port_num - 1].mutex);
+ list_for_each_entry(tmp_counter,
+ &dev->counters_table[port_num - 1].counters_list,
+ list) {
err = mlx4_get_counter_stats(dev->dev,
- counter_index,
+ tmp_counter->index,
&counter_stats, 0);
- if (err)
- return IB_MAD_RESULT_FAILURE;
-
- memset(out_mad->data, 0, sizeof(out_mad->data));
- err = IB_MAD_RESULT_SUCCESS | IB_MAD_RESULT_REPLY;
+ if (err) {
+ err = IB_MAD_RESULT_FAILURE;
+ stats_avail = 0;
+ break;
+ }
+ stats_avail = 1;
+ }
+ mutex_unlock(&dev->counters_table[port_num - 1].mutex);
+ if (stats_avail) {
+ memset(out_mad->data, 0, sizeof out_mad->data);
switch (counter_stats.counter_mode & 0xf) {
case 0:
edit_counter(&counter_stats,
(void *)(out_mad->data + 40),
in_mad->mad_hdr.attr_id);
+ err = IB_MAD_RESULT_SUCCESS | IB_MAD_RESULT_REPLY;
break;
default:
err = IB_MAD_RESULT_FAILURE;
@@ -867,19 +945,41 @@ static int iboe_process_mad(struct ib_device *ibdev, int mad_flags, u8 port_num,
}
int mlx4_ib_process_mad(struct ib_device *ibdev, int mad_flags, u8 port_num,
- struct ib_wc *in_wc, struct ib_grh *in_grh,
- struct ib_mad *in_mad, struct ib_mad *out_mad)
+ const struct ib_wc *in_wc, const struct ib_grh *in_grh,
+ const struct ib_mad_hdr *in, size_t in_mad_size,
+ struct ib_mad_hdr *out, size_t *out_mad_size,
+ u16 *out_mad_pkey_index)
{
- switch (rdma_port_get_link_layer(ibdev, port_num)) {
- case IB_LINK_LAYER_INFINIBAND:
+ struct mlx4_ib_dev *dev = to_mdev(ibdev);
+ const struct ib_mad *in_mad = (const struct ib_mad *)in;
+ struct ib_mad *out_mad = (struct ib_mad *)out;
+ enum rdma_link_layer link = rdma_port_get_link_layer(ibdev, port_num);
+
+ if (WARN_ON_ONCE(in_mad_size != sizeof(*in_mad) ||
+ *out_mad_size != sizeof(*out_mad)))
+ return IB_MAD_RESULT_FAILURE;
+
+ /* iboe_process_mad() which uses the HCA flow-counters to implement IB PMA
+ * queries, should be called only by VFs and for that specific purpose
+ */
+ if (link == IB_LINK_LAYER_INFINIBAND) {
+ if (mlx4_is_slave(dev->dev) &&
+ (in_mad->mad_hdr.mgmt_class == IB_MGMT_CLASS_PERF_MGMT &&
+ (in_mad->mad_hdr.attr_id == IB_PMA_PORT_COUNTERS ||
+ in_mad->mad_hdr.attr_id == IB_PMA_PORT_COUNTERS_EXT ||
+ in_mad->mad_hdr.attr_id == IB_PMA_CLASS_PORT_INFO)))
+ return iboe_process_mad(ibdev, mad_flags, port_num, in_wc,
+ in_grh, in_mad, out_mad);
+
return ib_process_mad(ibdev, mad_flags, port_num, in_wc,
in_grh, in_mad, out_mad);
- case IB_LINK_LAYER_ETHERNET:
- return iboe_process_mad(ibdev, mad_flags, port_num, in_wc,
- in_grh, in_mad, out_mad);
- default:
- return -EINVAL;
}
+
+ if (link == IB_LINK_LAYER_ETHERNET)
+ return iboe_process_mad(ibdev, mad_flags, port_num, in_wc,
+ in_grh, in_mad, out_mad);
+
+ return -EINVAL;
}
static void send_handler(struct ib_mad_agent *agent,
@@ -904,7 +1004,7 @@ int mlx4_ib_mad_init(struct mlx4_ib_dev *dev)
agent = ib_register_mad_agent(&dev->ib_dev, p + 1,
q ? IB_QPT_GSI : IB_QPT_SMI,
NULL, 0, send_handler,
- NULL, NULL);
+ NULL, NULL, 0);
if (IS_ERR(agent)) {
ret = PTR_ERR(agent);
goto err;
@@ -966,6 +1066,23 @@ static void handle_client_rereg_event(struct mlx4_ib_dev *dev, u8 port_num)
MLX4_EQ_PORT_INFO_CLIENT_REREG_MASK);
}
}
+
+ /* Update the sl to vl table from inside client rereg
+ * only if in secure-host mode (snooping is not possible)
+ * and the sl-to-vl change event is not generated by FW.
+ */
+ if (!mlx4_is_slave(dev->dev) &&
+ dev->dev->flags & MLX4_FLAG_SECURE_HOST &&
+ !(dev->dev->caps.flags2 & MLX4_DEV_CAP_FLAG2_SL_TO_VL_CHANGE_EVENT)) {
+ if (mlx4_is_master(dev->dev))
+ /* already in work queue from mlx4_ib_event queueing
+ * mlx4_handle_port_mgmt_change_event, which calls
+ * this procedure. Therefore, call sl2vl_update directly.
+ */
+ mlx4_ib_sl2vl_update(dev, port_num);
+ else
+ mlx4_sched_ib_sl2vl_update_work(dev, port_num);
+ }
mlx4_ib_dispatch_event(dev, port_num, IB_EVENT_CLIENT_REREGISTER);
}
@@ -1057,6 +1174,27 @@ void handle_port_mgmt_change_event(struct work_struct *work)
/* Generate GUID changed event */
if (changed_attr & MLX4_EQ_PORT_INFO_GID_PFX_CHANGE_MASK) {
+ if (mlx4_is_master(dev->dev)) {
+ union ib_gid gid;
+ int err = 0;
+
+ if (!eqe->event.port_mgmt_change.params.port_info.gid_prefix)
+ err = __mlx4_ib_query_gid(&dev->ib_dev, port, 0, &gid, 1);
+ else
+ gid.global.subnet_prefix =
+ eqe->event.port_mgmt_change.params.port_info.gid_prefix;
+ if (err) {
+ pr_warn("Could not change QP1 subnet prefix for port %d: query_gid error (%d)\n",
+ port, err);
+ } else {
+ pr_debug("Changing QP1 subnet prefix for port %d. old=0x%llx. new=0x%llx\n",
+ port,
+ (long long)atomic64_read(&dev->sriov.demux[port - 1].subnet_prefix),
+ (long long)be64_to_cpu(gid.global.subnet_prefix));
+ atomic64_set(&dev->sriov.demux[port - 1].subnet_prefix,
+ be64_to_cpu(gid.global.subnet_prefix));
+ }
+ }
mlx4_ib_dispatch_event(dev, port, IB_EVENT_GID_CHANGE);
/*if master, notify all slaves*/
if (mlx4_is_master(dev->dev))
@@ -1084,6 +1222,23 @@ void handle_port_mgmt_change_event(struct work_struct *work)
handle_slaves_guid_change(dev, port, tbl_block, change_bitmap);
}
break;
+
+ case MLX4_DEV_PMC_SUBTYPE_SL_TO_VL_MAP:
+ /* cache sl to vl mapping changes for use in
+ * filling QP1 LRH VL field when sending packets
+ */
+ if (!mlx4_is_slave(dev->dev)) {
+ union sl2vl_tbl_to_u64 sl2vl64;
+ int jj;
+
+ for (jj = 0; jj < 8; jj++) {
+ sl2vl64.sl8[jj] =
+ eqe->event.port_mgmt_change.params.sl2vl_tbl_change_info.sl2vl_table[jj];
+ pr_debug("sl2vl[%d] = %02x\n", jj, sl2vl64.sl8[jj]);
+ }
+ atomic64_set(&dev->sl2vl[port - 1], sl2vl64.sl64);
+ }
+ break;
default:
pr_warn("Unsupported subtype 0x%x for "
"Port Management Change event\n", eqe->subtype);
@@ -1128,7 +1283,7 @@ static int mlx4_ib_post_pv_qp_buf(struct mlx4_ib_demux_pv_ctx *ctx,
sg_list.addr = tun_qp->ring[index].map;
sg_list.length = size;
- sg_list.lkey = ctx->mr->lkey;
+ sg_list.lkey = ctx->pd->local_dma_lkey;
recv_wr.next = NULL;
recv_wr.sg_list = &sg_list;
@@ -1167,10 +1322,11 @@ static int is_proxy_qp0(struct mlx4_ib_dev *dev, int qpn, int slave)
int mlx4_ib_send_to_wire(struct mlx4_ib_dev *dev, int slave, u8 port,
enum ib_qp_type dest_qpt, u16 pkey_index,
u32 remote_qpn, u32 qkey, struct ib_ah_attr *attr,
- u8 *s_mac, struct ib_mad *mad)
+ u8 *s_mac, u16 vlan_id, struct ib_mad *mad)
{
struct ib_sge list;
- struct ib_send_wr wr, *bad_wr;
+ struct ib_ud_wr wr;
+ struct ib_send_wr *bad_wr;
struct mlx4_ib_demux_pv_ctx *sqp_ctx;
struct mlx4_ib_demux_pv_qp *sqp;
struct mlx4_mad_snd_buf *sqp_mad;
@@ -1189,10 +1345,6 @@ int mlx4_ib_send_to_wire(struct mlx4_ib_dev *dev, int slave, u8 port,
if (!sqp_ctx || sqp_ctx->state != DEMUX_PV_STATE_ACTIVE)
return -EAGAIN;
- /* QP0 forwarding only for Dom0 */
- if (dest_qpt == IB_QPT_SMI && (mlx4_master_func_num(dev->dev) != slave))
- return -EINVAL;
-
if (dest_qpt == IB_QPT_SMI) {
src_qpnum = 0;
sqp = &sqp_ctx->qp[0];
@@ -1243,58 +1395,53 @@ int mlx4_ib_send_to_wire(struct mlx4_ib_dev *dev, int slave, u8 port,
list.addr = sqp->tx_ring[wire_tx_ix].buf.map;
list.length = sizeof (struct mlx4_mad_snd_buf);
- list.lkey = sqp_ctx->mr->lkey;
-
- wr.wr.ud.ah = ah;
- wr.wr.ud.port_num = port;
- wr.wr.ud.pkey_index = wire_pkey_ix;
- wr.wr.ud.remote_qkey = qkey;
- wr.wr.ud.remote_qpn = remote_qpn;
- wr.next = NULL;
- wr.wr_id = ((u64) wire_tx_ix) | MLX4_TUN_SET_WRID_QPN(src_qpnum);
- wr.sg_list = &list;
- wr.num_sge = 1;
- wr.opcode = IB_WR_SEND;
- wr.send_flags = IB_SEND_SIGNALED;
+ list.lkey = sqp_ctx->pd->local_dma_lkey;
+
+ wr.ah = ah;
+ wr.port_num = port;
+ wr.pkey_index = wire_pkey_ix;
+ wr.remote_qkey = qkey;
+ wr.remote_qpn = remote_qpn;
+ wr.wr.next = NULL;
+ wr.wr.wr_id = ((u64) wire_tx_ix) | MLX4_TUN_SET_WRID_QPN(src_qpnum);
+ wr.wr.sg_list = &list;
+ wr.wr.num_sge = 1;
+ wr.wr.opcode = IB_WR_SEND;
+ wr.wr.send_flags = IB_SEND_SIGNALED;
if (s_mac)
memcpy(to_mah(ah)->av.eth.s_mac, s_mac, 6);
+ if (vlan_id < 0x1000)
+ vlan_id |= (attr->sl & 7) << 13;
+ to_mah(ah)->av.eth.vlan = cpu_to_be16(vlan_id);
- ret = ib_post_send(send_qp, &wr, &bad_wr);
+ ret = ib_post_send(send_qp, &wr.wr, &bad_wr);
+ if (!ret)
+ return 0;
+
+ spin_lock(&sqp->tx_lock);
+ sqp->tx_ix_tail++;
+ spin_unlock(&sqp->tx_lock);
+ sqp->tx_ring[wire_tx_ix].ah = NULL;
out:
- if (ret)
- ib_destroy_ah(ah);
+ ib_destroy_ah(ah);
return ret;
}
static int get_slave_base_gid_ix(struct mlx4_ib_dev *dev, int slave, int port)
{
- int gids;
- int vfs;
-
if (rdma_port_get_link_layer(&dev->ib_dev, port) == IB_LINK_LAYER_INFINIBAND)
return slave;
-
- gids = MLX4_ROCE_MAX_GIDS - MLX4_ROCE_PF_GIDS;
- vfs = dev->dev->persist->num_vfs;
-
- if (slave == 0)
- return 0;
- if (slave <= gids % vfs)
- return MLX4_ROCE_PF_GIDS + ((gids / vfs) + 1) * (slave - 1);
-
- return MLX4_ROCE_PF_GIDS + (gids % vfs) + ((gids / vfs) * (slave - 1));
+ return mlx4_get_base_gid_ix(dev->dev, slave, port);
}
-static int get_real_sgid_index(struct mlx4_ib_dev *dev, int slave, int port,
- struct ib_ah_attr *ah_attr)
+static void fill_in_real_sgid_index(struct mlx4_ib_dev *dev, int slave, int port,
+ struct ib_ah_attr *ah_attr)
{
- if (rdma_port_get_link_layer(&dev->ib_dev, port) == IB_LINK_LAYER_INFINIBAND) {
+ if (rdma_port_get_link_layer(&dev->ib_dev, port) == IB_LINK_LAYER_INFINIBAND)
ah_attr->grh.sgid_index = slave;
- return 0;
- }
- ah_attr->grh.sgid_index += get_slave_base_gid_ix(dev, slave, port);
- return 0;
+ else
+ ah_attr->grh.sgid_index += get_slave_base_gid_ix(dev, slave, port);
}
static void mlx4_ib_multiplex_mad(struct mlx4_ib_demux_pv_ctx *ctx, struct ib_wc *wc)
@@ -1307,6 +1454,8 @@ static void mlx4_ib_multiplex_mad(struct mlx4_ib_demux_pv_ctx *ctx, struct ib_wc
struct ib_ah_attr ah_attr;
u8 *slave_id;
int slave;
+ int port;
+ u16 vlan_id;
/* Get slave that sent this packet */
if (wc->src_qp < dev->dev->phys_caps.base_proxy_sqpn ||
@@ -1322,11 +1471,6 @@ static void mlx4_ib_multiplex_mad(struct mlx4_ib_demux_pv_ctx *ctx, struct ib_wc
"belongs to another slave\n", wc->src_qp);
return;
}
- if (slave != mlx4_master_func_num(dev->dev) && !(wc->src_qp & 0x2)) {
- mlx4_ib_warn(ctx->ib_dev, "can't multiplex bad sqp:%d: "
- "non-master trying to send QP0 packets\n", wc->src_qp);
- return;
- }
/* Map transaction ID */
ib_dma_sync_single_for_cpu(ctx->ib_dev, tun_qp->ring[wr_ix].map,
@@ -1354,6 +1498,12 @@ static void mlx4_ib_multiplex_mad(struct mlx4_ib_demux_pv_ctx *ctx, struct ib_wc
/* Class-specific handling */
switch (tunnel->mad.mad_hdr.mgmt_class) {
+ case IB_MGMT_CLASS_SUBN_LID_ROUTED:
+ case IB_MGMT_CLASS_SUBN_DIRECTED_ROUTE:
+ if (slave != mlx4_master_func_num(dev->dev) &&
+ !mlx4_vf_smi_enabled(dev->dev, slave, ctx->port))
+ return;
+ break;
case IB_MGMT_CLASS_SUBN_ADM:
if (mlx4_ib_multiplex_sa_handler(ctx->ib_dev, ctx->port, slave,
(struct ib_sa_mad *) &tunnel->mad))
@@ -1382,15 +1532,22 @@ static void mlx4_ib_multiplex_mad(struct mlx4_ib_demux_pv_ctx *ctx, struct ib_wc
* stadard address handle by decoding the tunnelled mlx4_ah fields */
memcpy(&ah.av, &tunnel->hdr.av, sizeof (struct mlx4_av));
ah.ibah.device = ctx->ib_dev;
+
+ port = be32_to_cpu(ah.av.ib.port_pd) >> 24;
+ port = mlx4_slave_convert_port(dev->dev, slave, port);
+ if (port < 0)
+ return;
+ ah.av.ib.port_pd = cpu_to_be32(port << 24 | (be32_to_cpu(ah.av.ib.port_pd) & 0xffffff));
+
mlx4_ib_query_ah(&ah.ibah, &ah_attr);
if (ah_attr.ah_flags & IB_AH_GRH)
- if (get_real_sgid_index(dev, slave, ctx->port, &ah_attr))
- return;
+ fill_in_real_sgid_index(dev, slave, ctx->port, &ah_attr);
+
memcpy(ah_attr.dmac, tunnel->hdr.mac, 6);
- ah_attr.vlan_id = tunnel->hdr.vlan;
+ vlan_id = be16_to_cpu(tunnel->hdr.vlan);
/* if slave have default vlan use it */
mlx4_get_slave_default_vlan(dev->dev, ctx->port, slave,
- &ah_attr.vlan_id, &ah_attr.sl);
+ &vlan_id, &ah_attr.sl);
mlx4_ib_send_to_wire(dev, slave, ctx->port,
is_proxy_qp0(dev, wc->src_qp, slave) ?
@@ -1398,7 +1555,7 @@ static void mlx4_ib_multiplex_mad(struct mlx4_ib_demux_pv_ctx *ctx, struct ib_wc
be16_to_cpu(tunnel->hdr.pkey_index),
be32_to_cpu(tunnel->hdr.remote_qpn),
be32_to_cpu(tunnel->hdr.qkey),
- &ah_attr, wc->smac, &tunnel->mad);
+ &ah_attr, wc->smac, vlan_id, &tunnel->mad);
}
static int mlx4_ib_alloc_pv_bufs(struct mlx4_ib_demux_pv_ctx *ctx,
@@ -1443,9 +1600,7 @@ static int mlx4_ib_alloc_pv_bufs(struct mlx4_ib_demux_pv_ctx *ctx,
tun_qp->ring[i].addr,
rx_buf_size,
DMA_FROM_DEVICE);
- if (unlikely(ib_dma_mapping_error(ctx->ib_dev,
- tun_qp->ring[i].map))) {
- mlx4_ib_warn(ctx->ib_dev, "ib_dma_map_single failed\n");
+ if (ib_dma_mapping_error(ctx->ib_dev, tun_qp->ring[i].map)) {
kfree(tun_qp->ring[i].addr);
goto err;
}
@@ -1461,9 +1616,8 @@ static int mlx4_ib_alloc_pv_bufs(struct mlx4_ib_demux_pv_ctx *ctx,
tun_qp->tx_ring[i].buf.addr,
tx_buf_size,
DMA_TO_DEVICE);
- if (unlikely(ib_dma_mapping_error(ctx->ib_dev,
- tun_qp->tx_ring[i].buf.map))) {
- mlx4_ib_warn(ctx->ib_dev, "ib_dma_map_single failed\n");
+ if (ib_dma_mapping_error(ctx->ib_dev,
+ tun_qp->tx_ring[i].buf.map)) {
kfree(tun_qp->tx_ring[i].buf.addr);
goto tx_err;
}
@@ -1623,7 +1777,8 @@ static int create_pv_sqp(struct mlx4_ib_demux_pv_ctx *ctx,
qp_init_attr.init_attr.cap.max_recv_sge = 1;
if (create_tun) {
qp_init_attr.init_attr.qp_type = IB_QPT_UD;
- qp_init_attr.init_attr.create_flags = (enum ib_qp_create_flags)MLX4_IB_SRIOV_TUNNEL_QP;
+ qp_init_attr.init_attr.create_flags =
+ (enum ib_qp_create_flags)MLX4_IB_SRIOV_TUNNEL_QP;
qp_init_attr.port = ctx->port;
qp_init_attr.slave = ctx->slave;
qp_init_attr.proxy_qp_type = qp_type;
@@ -1631,7 +1786,8 @@ static int create_pv_sqp(struct mlx4_ib_demux_pv_ctx *ctx,
IB_QP_QKEY | IB_QP_PORT;
} else {
qp_init_attr.init_attr.qp_type = qp_type;
- qp_init_attr.init_attr.create_flags = (enum ib_qp_create_flags)MLX4_IB_SRIOV_SQP;
+ qp_init_attr.init_attr.create_flags =
+ (enum ib_qp_create_flags)MLX4_IB_SRIOV_SQP;
qp_attr_mask_INIT = IB_QP_STATE | IB_QP_PKEY_INDEX | IB_QP_QKEY;
}
qp_init_attr.init_attr.port_num = ctx->port;
@@ -1651,7 +1807,8 @@ static int create_pv_sqp(struct mlx4_ib_demux_pv_ctx *ctx,
ret = 0;
if (create_tun)
ret = find_slave_port_pkey_ix(to_mdev(ctx->ib_dev), ctx->slave,
- ctx->port, 0xFFFF, &attr.pkey_index);
+ ctx->port, IB_DEFAULT_PKEY_FULL,
+ &attr.pkey_index);
if (ret || !create_tun)
attr.pkey_index =
to_mdev(ctx->ib_dev)->pkeys.virt2phys_pkey[ctx->slave][ctx->port - 1][0];
@@ -1788,14 +1945,15 @@ static int create_pv_resources(struct ib_device *ibdev, int slave, int port,
int create_tun, struct mlx4_ib_demux_pv_ctx *ctx)
{
int ret, cq_size;
+ struct ib_cq_init_attr cq_attr = {};
if (ctx->state != DEMUX_PV_STATE_DOWN)
return -EEXIST;
ctx->state = DEMUX_PV_STATE_STARTING;
- /* have QP0 only on port owner, and only if link layer is IB */
- if (ctx->slave == mlx4_master_func_num(to_mdev(ctx->ib_dev)->dev) &&
- rdma_port_get_link_layer(ibdev, ctx->port) == IB_LINK_LAYER_INFINIBAND)
+ /* have QP0 only if link layer is IB */
+ if (rdma_port_get_link_layer(ibdev, ctx->port) ==
+ IB_LINK_LAYER_INFINIBAND)
ctx->has_smi = 1;
if (ctx->has_smi) {
@@ -1816,34 +1974,28 @@ static int create_pv_resources(struct ib_device *ibdev, int slave, int port,
if (ctx->has_smi)
cq_size *= 2;
+ cq_attr.cqe = cq_size;
ctx->cq = ib_create_cq(ctx->ib_dev, mlx4_ib_tunnel_comp_handler,
- NULL, ctx, cq_size, 0);
+ NULL, ctx, &cq_attr);
if (IS_ERR(ctx->cq)) {
ret = PTR_ERR(ctx->cq);
pr_err("Couldn't create tunnel CQ (%d)\n", ret);
goto err_buf;
}
- ctx->pd = ib_alloc_pd(ctx->ib_dev);
+ ctx->pd = ib_alloc_pd(ctx->ib_dev, 0);
if (IS_ERR(ctx->pd)) {
ret = PTR_ERR(ctx->pd);
pr_err("Couldn't create tunnel PD (%d)\n", ret);
goto err_cq;
}
- ctx->mr = ib_get_dma_mr(ctx->pd, IB_ACCESS_LOCAL_WRITE);
- if (IS_ERR(ctx->mr)) {
- ret = PTR_ERR(ctx->mr);
- pr_err("Couldn't get tunnel DMA MR (%d)\n", ret);
- goto err_pd;
- }
-
if (ctx->has_smi) {
ret = create_pv_sqp(ctx, IB_QPT_SMI, create_tun);
if (ret) {
pr_err("Couldn't create %s QP0 (%d)\n",
create_tun ? "tunnel for" : "", ret);
- goto err_mr;
+ goto err_pd;
}
}
@@ -1880,10 +2032,6 @@ err_qp0:
ib_destroy_qp(ctx->qp[0].qp);
ctx->qp[0].qp = NULL;
-err_mr:
- ib_dereg_mr(ctx->mr);
- ctx->mr = NULL;
-
err_pd:
ib_dealloc_pd(ctx->pd);
ctx->pd = NULL;
@@ -1920,8 +2068,6 @@ static void destroy_pv_resources(struct mlx4_ib_dev *dev, int slave, int port,
ib_destroy_qp(ctx->qp[1].qp);
ctx->qp[1].qp = NULL;
mlx4_ib_free_pv_qp_bufs(ctx, IB_QPT_GSI, 1);
- ib_dereg_mr(ctx->mr);
- ctx->mr = NULL;
ib_dealloc_pd(ctx->pd);
ctx->pd = NULL;
ib_destroy_cq(ctx->cq);
@@ -1986,7 +2132,16 @@ static int mlx4_ib_alloc_demux_ctx(struct mlx4_ib_dev *dev,
ctx->port = port;
ctx->ib_dev = &dev->ib_dev;
- for (i = 0; i < dev->dev->caps.sqp_demux; i++) {
+ for (i = 0;
+ i < min(dev->dev->caps.sqp_demux,
+ (u16)(dev->dev->persist->num_vfs + 1));
+ i++) {
+ struct mlx4_active_ports actv_ports =
+ mlx4_get_active_ports(dev->dev, i);
+
+ if (!test_bit(port - 1, actv_ports.ports))
+ continue;
+
ret = alloc_pv_object(dev, i, port, &ctx->tun[i]);
if (ret) {
ret = -ENOMEM;
@@ -2001,7 +2156,7 @@ static int mlx4_ib_alloc_demux_ctx(struct mlx4_ib_dev *dev,
}
snprintf(name, sizeof name, "mlx4_ibt%d", port);
- ctx->wq = create_singlethread_workqueue(name);
+ ctx->wq = alloc_ordered_workqueue(name, WQ_MEM_RECLAIM);
if (!ctx->wq) {
pr_err("Failed to create tunnelling WQ for port %d\n", port);
ret = -ENOMEM;
@@ -2009,7 +2164,7 @@ static int mlx4_ib_alloc_demux_ctx(struct mlx4_ib_dev *dev,
}
snprintf(name, sizeof name, "mlx4_ibud%d", port);
- ctx->ud_wq = create_singlethread_workqueue(name);
+ ctx->ud_wq = alloc_ordered_workqueue(name, WQ_MEM_RECLAIM);
if (!ctx->ud_wq) {
pr_err("Failed to create up/down WQ for port %d\n", port);
ret = -ENOMEM;
@@ -2045,8 +2200,6 @@ static void mlx4_ib_free_sqp_ctx(struct mlx4_ib_demux_pv_ctx *sqp_ctx)
ib_destroy_qp(sqp_ctx->qp[1].qp);
sqp_ctx->qp[1].qp = NULL;
mlx4_ib_free_pv_qp_bufs(sqp_ctx, IB_QPT_GSI, 0);
- ib_dereg_mr(sqp_ctx->mr);
- sqp_ctx->mr = NULL;
ib_dealloc_pd(sqp_ctx->pd);
sqp_ctx->pd = NULL;
ib_destroy_cq(sqp_ctx->cq);
@@ -2135,22 +2288,25 @@ int mlx4_ib_init_sriov(struct mlx4_ib_dev *dev)
if (err)
goto demux_err;
dev->sriov.demux[i].guid_cache[0] = gid.global.interface_id;
+ atomic64_set(&dev->sriov.demux[i].subnet_prefix,
+ be64_to_cpu(gid.global.subnet_prefix));
err = alloc_pv_object(dev, mlx4_master_func_num(dev->dev), i + 1,
&dev->sriov.sqps[i]);
if (err)
goto demux_err;
err = mlx4_ib_alloc_demux_ctx(dev, &dev->sriov.demux[i], i + 1);
if (err)
- goto demux_err;
+ goto free_pv;
}
mlx4_ib_master_tunnels(dev, 1);
return 0;
+free_pv:
+ free_pv_object(dev, mlx4_master_func_num(dev->dev), i + 1);
demux_err:
- while (i > 0) {
+ while (--i >= 0) {
free_pv_object(dev, mlx4_master_func_num(dev->dev), i + 1);
mlx4_ib_free_demux_ctx(&dev->sriov.demux[i]);
- --i;
}
mlx4_ib_device_unregister_sysfs(dev);
diff --git a/sys/dev/mlx4/mlx4_ib/mlx4_ib_main.c b/sys/dev/mlx4/mlx4_ib/mlx4_ib_main.c
index 0f089ea..18ed593 100644
--- a/sys/dev/mlx4/mlx4_ib/mlx4_ib_main.c
+++ b/sys/dev/mlx4/mlx4_ib/mlx4_ib_main.c
@@ -36,73 +36,54 @@
#include <linux/module.h>
#include <linux/slab.h>
#include <linux/errno.h>
+#include <linux/etherdevice.h>
#include <linux/netdevice.h>
#include <linux/inetdevice.h>
#include <linux/if_vlan.h>
#include <linux/fs.h>
+#include <linux/rcupdate.h>
+#include <linux/notifier.h>
+#include <linux/delay.h>
+
#include <net/ipv6.h>
#include <rdma/ib_smi.h>
#include <rdma/ib_user_verbs.h>
-#include <rdma/ib_user_verbs_exp.h>
#include <rdma/ib_addr.h>
+#include <rdma/ib_cache.h>
#include <dev/mlx4/driver.h>
#include <dev/mlx4/cmd.h>
+#include <dev/mlx4/qp.h>
#include <linux/sched.h>
#include <linux/page.h>
#include <linux/printk.h>
#include "mlx4_ib.h"
-#include "mlx4_exp.h"
-#include "user.h"
+#include <rdma/mlx4-abi.h>
#include "wc.h"
#define DRV_NAME MLX4_IB_DRV_NAME
-#define DRV_VERSION "1.0"
+#define DRV_VERSION "3.4.1-BETA"
+#define DRV_RELDATE "October 2017"
-#define MLX4_IB_DRIVER_PROC_DIR_NAME "driver/mlx4_ib"
-#define MLX4_IB_MRS_PROC_DIR_NAME "mrs"
#define MLX4_IB_FLOW_MAX_PRIO 0xFFF
#define MLX4_IB_FLOW_QPN_MASK 0xFFFFFF
+#define MLX4_IB_CARD_REV_A0 0xA0
MODULE_AUTHOR("Roland Dreier");
MODULE_DESCRIPTION("Mellanox ConnectX HCA InfiniBand driver");
MODULE_LICENSE("Dual BSD/GPL");
-#ifdef __linux__
-MODULE_VERSION(DRV_VERSION);
-#endif
-
-int mlx4_ib_sm_guid_assign = 1;
+int mlx4_ib_sm_guid_assign = 0;
module_param_named(sm_guid_assign, mlx4_ib_sm_guid_assign, int, 0444);
-MODULE_PARM_DESC(sm_guid_assign, "Enable SM alias_GUID assignment if sm_guid_assign > 0 (Default: 1)");
+MODULE_PARM_DESC(sm_guid_assign, "Enable SM alias_GUID assignment if sm_guid_assign > 0 (Default: 0)");
static const char mlx4_ib_version[] =
DRV_NAME ": Mellanox ConnectX InfiniBand driver v"
- DRV_VERSION "\n";
-
-struct update_gid_work {
- struct work_struct work;
- union ib_gid gids[128];
- struct mlx4_ib_dev *dev;
- int port;
-};
-
-struct dev_rec {
- int bus;
- int dev;
- int func;
- int nr;
-};
+ DRV_VERSION " (" DRV_RELDATE ")\n";
static void do_slave_init(struct mlx4_ib_dev *ibdev, int slave, int do_init);
-static void mlx4_ib_scan_netdevs(struct mlx4_ib_dev *ibdev, struct net_device*,
- unsigned long);
-
-static u8 mlx4_ib_get_dev_port(struct net_device *dev,
- struct mlx4_ib_dev *ibdev);
-
static struct workqueue_struct *wq;
static void init_query_mad(struct ib_smp *mad)
@@ -113,12 +94,11 @@ static void init_query_mad(struct ib_smp *mad)
mad->method = IB_MGMT_METHOD_GET;
}
-static union ib_gid zgid;
-
static int check_flow_steering_support(struct mlx4_dev *dev)
{
int eth_num_ports = 0;
int ib_num_ports = 0;
+
int dmfs = dev->caps.steering_mode == MLX4_STEERING_MODE_DEVICE_MANAGED;
if (dmfs) {
@@ -132,21 +112,353 @@ static int check_flow_steering_support(struct mlx4_dev *dev)
(!eth_num_ports ||
(dev->caps.flags2 & MLX4_DEV_CAP_FLAG2_FS_EN));
if (ib_num_ports && mlx4_is_mfunc(dev)) {
+ pr_warn("Device managed flow steering is unavailable for IB port in multifunction env.\n");
dmfs = 0;
}
}
return dmfs;
}
-int mlx4_ib_query_device(struct ib_device *ibdev,
- struct ib_device_attr *props)
+static int num_ib_ports(struct mlx4_dev *dev)
+{
+ int ib_ports = 0;
+ int i;
+
+ mlx4_foreach_port(i, dev, MLX4_PORT_TYPE_IB)
+ ib_ports++;
+
+ return ib_ports;
+}
+
+static struct net_device *mlx4_ib_get_netdev(struct ib_device *device, u8 port_num)
+{
+ struct mlx4_ib_dev *ibdev = to_mdev(device);
+ struct net_device *dev;
+
+ rcu_read_lock();
+ dev = mlx4_get_protocol_dev(ibdev->dev, MLX4_PROT_ETH, port_num);
+
+#if 0
+ if (dev) {
+ if (mlx4_is_bonded(ibdev->dev)) {
+ struct net_device *upper = NULL;
+
+ upper = netdev_master_upper_dev_get_rcu(dev);
+ if (upper) {
+ struct net_device *active;
+
+ active = bond_option_active_slave_get_rcu(netdev_priv(upper));
+ if (active)
+ dev = active;
+ }
+ }
+ }
+#endif
+ if (dev)
+ dev_hold(dev);
+
+ rcu_read_unlock();
+ return dev;
+}
+
+static int mlx4_ib_update_gids_v1(struct gid_entry *gids,
+ struct mlx4_ib_dev *ibdev,
+ u8 port_num)
+{
+ struct mlx4_cmd_mailbox *mailbox;
+ int err;
+ struct mlx4_dev *dev = ibdev->dev;
+ int i;
+ union ib_gid *gid_tbl;
+
+ mailbox = mlx4_alloc_cmd_mailbox(dev);
+ if (IS_ERR(mailbox))
+ return -ENOMEM;
+
+ gid_tbl = mailbox->buf;
+
+ for (i = 0; i < MLX4_MAX_PORT_GIDS; ++i)
+ memcpy(&gid_tbl[i], &gids[i].gid, sizeof(union ib_gid));
+
+ err = mlx4_cmd(dev, mailbox->dma,
+ MLX4_SET_PORT_GID_TABLE << 8 | port_num,
+ 1, MLX4_CMD_SET_PORT, MLX4_CMD_TIME_CLASS_B,
+ MLX4_CMD_WRAPPED);
+ if (mlx4_is_bonded(dev))
+ err += mlx4_cmd(dev, mailbox->dma,
+ MLX4_SET_PORT_GID_TABLE << 8 | 2,
+ 1, MLX4_CMD_SET_PORT, MLX4_CMD_TIME_CLASS_B,
+ MLX4_CMD_WRAPPED);
+
+ mlx4_free_cmd_mailbox(dev, mailbox);
+ return err;
+}
+
+static int mlx4_ib_update_gids_v1_v2(struct gid_entry *gids,
+ struct mlx4_ib_dev *ibdev,
+ u8 port_num)
+{
+ struct mlx4_cmd_mailbox *mailbox;
+ int err;
+ struct mlx4_dev *dev = ibdev->dev;
+ int i;
+ struct {
+ union ib_gid gid;
+ __be32 rsrvd1[2];
+ __be16 rsrvd2;
+ u8 type;
+ u8 version;
+ __be32 rsrvd3;
+ } *gid_tbl;
+
+ mailbox = mlx4_alloc_cmd_mailbox(dev);
+ if (IS_ERR(mailbox))
+ return -ENOMEM;
+
+ gid_tbl = mailbox->buf;
+ for (i = 0; i < MLX4_MAX_PORT_GIDS; ++i) {
+ memcpy(&gid_tbl[i].gid, &gids[i].gid, sizeof(union ib_gid));
+ if (gids[i].gid_type == IB_GID_TYPE_ROCE_UDP_ENCAP) {
+ gid_tbl[i].version = 2;
+ if (!ipv6_addr_v4mapped((struct in6_addr *)&gids[i].gid))
+ gid_tbl[i].type = 1;
+ else
+ memset(&gid_tbl[i].gid, 0, 12);
+ }
+ }
+
+ err = mlx4_cmd(dev, mailbox->dma,
+ MLX4_SET_PORT_ROCE_ADDR << 8 | port_num,
+ 1, MLX4_CMD_SET_PORT, MLX4_CMD_TIME_CLASS_B,
+ MLX4_CMD_WRAPPED);
+ if (mlx4_is_bonded(dev))
+ err += mlx4_cmd(dev, mailbox->dma,
+ MLX4_SET_PORT_ROCE_ADDR << 8 | 2,
+ 1, MLX4_CMD_SET_PORT, MLX4_CMD_TIME_CLASS_B,
+ MLX4_CMD_WRAPPED);
+
+ mlx4_free_cmd_mailbox(dev, mailbox);
+ return err;
+}
+
+static int mlx4_ib_update_gids(struct gid_entry *gids,
+ struct mlx4_ib_dev *ibdev,
+ u8 port_num)
+{
+ if (ibdev->dev->caps.flags2 & MLX4_DEV_CAP_FLAG2_ROCE_V1_V2)
+ return mlx4_ib_update_gids_v1_v2(gids, ibdev, port_num);
+
+ return mlx4_ib_update_gids_v1(gids, ibdev, port_num);
+}
+
+static int mlx4_ib_add_gid(struct ib_device *device,
+ u8 port_num,
+ unsigned int index,
+ const union ib_gid *gid,
+ const struct ib_gid_attr *attr,
+ void **context)
+{
+ struct mlx4_ib_dev *ibdev = to_mdev(device);
+ struct mlx4_ib_iboe *iboe = &ibdev->iboe;
+ struct mlx4_port_gid_table *port_gid_table;
+ int free = -1, found = -1;
+ int ret = 0;
+ int hw_update = 0;
+ int i;
+ struct gid_entry *gids = NULL;
+
+ if (!rdma_cap_roce_gid_table(device, port_num))
+ return -EINVAL;
+
+ if (port_num > MLX4_MAX_PORTS)
+ return -EINVAL;
+
+ if (!context)
+ return -EINVAL;
+
+ port_gid_table = &iboe->gids[port_num - 1];
+ spin_lock_bh(&iboe->lock);
+ for (i = 0; i < MLX4_MAX_PORT_GIDS; ++i) {
+ if (!memcmp(&port_gid_table->gids[i].gid, gid, sizeof(*gid)) &&
+ (port_gid_table->gids[i].gid_type == attr->gid_type)) {
+ found = i;
+ break;
+ }
+ if (free < 0 && !memcmp(&port_gid_table->gids[i].gid, &zgid, sizeof(*gid)))
+ free = i; /* HW has space */
+ }
+
+ if (found < 0) {
+ if (free < 0) {
+ ret = -ENOSPC;
+ } else {
+ port_gid_table->gids[free].ctx = kmalloc(sizeof(*port_gid_table->gids[free].ctx), GFP_ATOMIC);
+ if (!port_gid_table->gids[free].ctx) {
+ ret = -ENOMEM;
+ } else {
+ *context = port_gid_table->gids[free].ctx;
+ memcpy(&port_gid_table->gids[free].gid, gid, sizeof(*gid));
+ port_gid_table->gids[free].gid_type = attr->gid_type;
+ port_gid_table->gids[free].ctx->real_index = free;
+ port_gid_table->gids[free].ctx->refcount = 1;
+ hw_update = 1;
+ }
+ }
+ } else {
+ struct gid_cache_context *ctx = port_gid_table->gids[found].ctx;
+ *context = ctx;
+ ctx->refcount++;
+ }
+ if (!ret && hw_update) {
+ gids = kmalloc(sizeof(*gids) * MLX4_MAX_PORT_GIDS, GFP_ATOMIC);
+ if (!gids) {
+ ret = -ENOMEM;
+ } else {
+ for (i = 0; i < MLX4_MAX_PORT_GIDS; i++) {
+ memcpy(&gids[i].gid, &port_gid_table->gids[i].gid, sizeof(union ib_gid));
+ gids[i].gid_type = port_gid_table->gids[i].gid_type;
+ }
+ }
+ }
+ spin_unlock_bh(&iboe->lock);
+
+ if (!ret && hw_update) {
+ ret = mlx4_ib_update_gids(gids, ibdev, port_num);
+ kfree(gids);
+ }
+
+ return ret;
+}
+
+static int mlx4_ib_del_gid(struct ib_device *device,
+ u8 port_num,
+ unsigned int index,
+ void **context)
+{
+ struct gid_cache_context *ctx = *context;
+ struct mlx4_ib_dev *ibdev = to_mdev(device);
+ struct mlx4_ib_iboe *iboe = &ibdev->iboe;
+ struct mlx4_port_gid_table *port_gid_table;
+ int ret = 0;
+ int hw_update = 0;
+ struct gid_entry *gids = NULL;
+
+ if (!rdma_cap_roce_gid_table(device, port_num))
+ return -EINVAL;
+
+ if (port_num > MLX4_MAX_PORTS)
+ return -EINVAL;
+
+ port_gid_table = &iboe->gids[port_num - 1];
+ spin_lock_bh(&iboe->lock);
+ if (ctx) {
+ ctx->refcount--;
+ if (!ctx->refcount) {
+ unsigned int real_index = ctx->real_index;
+
+ memcpy(&port_gid_table->gids[real_index].gid, &zgid, sizeof(zgid));
+ kfree(port_gid_table->gids[real_index].ctx);
+ port_gid_table->gids[real_index].ctx = NULL;
+ hw_update = 1;
+ }
+ }
+ if (!ret && hw_update) {
+ int i;
+
+ gids = kmalloc(sizeof(*gids) * MLX4_MAX_PORT_GIDS, GFP_ATOMIC);
+ if (!gids) {
+ ret = -ENOMEM;
+ } else {
+ for (i = 0; i < MLX4_MAX_PORT_GIDS; i++)
+ memcpy(&gids[i].gid, &port_gid_table->gids[i].gid, sizeof(union ib_gid));
+ }
+ }
+ spin_unlock_bh(&iboe->lock);
+
+ if (!ret && hw_update) {
+ ret = mlx4_ib_update_gids(gids, ibdev, port_num);
+ kfree(gids);
+ }
+ return ret;
+}
+
+int mlx4_ib_gid_index_to_real_index(struct mlx4_ib_dev *ibdev,
+ u8 port_num, int index)
+{
+ struct mlx4_ib_iboe *iboe = &ibdev->iboe;
+ struct gid_cache_context *ctx = NULL;
+ union ib_gid gid;
+ struct mlx4_port_gid_table *port_gid_table;
+ int real_index = -EINVAL;
+ int i;
+ int ret;
+ unsigned long flags;
+ struct ib_gid_attr attr;
+
+ if (port_num > MLX4_MAX_PORTS)
+ return -EINVAL;
+
+ if (mlx4_is_bonded(ibdev->dev))
+ port_num = 1;
+
+ if (!rdma_cap_roce_gid_table(&ibdev->ib_dev, port_num))
+ return index;
+
+ ret = ib_get_cached_gid(&ibdev->ib_dev, port_num, index, &gid, &attr);
+ if (ret)
+ return ret;
+
+ if (attr.ndev)
+ dev_put(attr.ndev);
+
+ if (!memcmp(&gid, &zgid, sizeof(gid)))
+ return -EINVAL;
+
+ spin_lock_irqsave(&iboe->lock, flags);
+ port_gid_table = &iboe->gids[port_num - 1];
+
+ for (i = 0; i < MLX4_MAX_PORT_GIDS; ++i)
+ if (!memcmp(&port_gid_table->gids[i].gid, &gid, sizeof(gid)) &&
+ attr.gid_type == port_gid_table->gids[i].gid_type) {
+ ctx = port_gid_table->gids[i].ctx;
+ break;
+ }
+ if (ctx)
+ real_index = ctx->real_index;
+ spin_unlock_irqrestore(&iboe->lock, flags);
+ return real_index;
+}
+
+static int mlx4_ib_query_device(struct ib_device *ibdev,
+ struct ib_device_attr *props,
+ struct ib_udata *uhw)
{
struct mlx4_ib_dev *dev = to_mdev(ibdev);
struct ib_smp *in_mad = NULL;
struct ib_smp *out_mad = NULL;
int err = -ENOMEM;
+ int have_ib_ports;
+ struct mlx4_uverbs_ex_query_device cmd;
+ struct mlx4_uverbs_ex_query_device_resp resp = {.comp_mask = 0};
struct mlx4_clock_params clock_params;
+ if (uhw->inlen) {
+ if (uhw->inlen < sizeof(cmd))
+ return -EINVAL;
+
+ err = ib_copy_from_udata(&cmd, uhw, sizeof(cmd));
+ if (err)
+ return err;
+
+ if (cmd.comp_mask)
+ return -EINVAL;
+
+ if (cmd.reserved)
+ return -EINVAL;
+ }
+
+ resp.response_length = offsetof(typeof(resp), response_length) +
+ sizeof(resp.response_length);
in_mad = kzalloc(sizeof *in_mad, GFP_KERNEL);
out_mad = kmalloc(sizeof *out_mad, GFP_KERNEL);
if (!in_mad || !out_mad)
@@ -162,25 +474,27 @@ int mlx4_ib_query_device(struct ib_device *ibdev,
memset(props, 0, sizeof *props);
+ have_ib_ports = num_ib_ports(dev->dev);
+
props->fw_ver = dev->dev->caps.fw_ver;
props->device_cap_flags = IB_DEVICE_CHANGE_PHY_PORT |
IB_DEVICE_PORT_ACTIVE_EVENT |
IB_DEVICE_SYS_IMAGE_GUID |
IB_DEVICE_RC_RNR_NAK_GEN |
- IB_DEVICE_BLOCK_MULTICAST_LOOPBACK |
- IB_DEVICE_SHARED_MR;
-
+ IB_DEVICE_BLOCK_MULTICAST_LOOPBACK;
if (dev->dev->caps.flags & MLX4_DEV_CAP_FLAG_BAD_PKEY_CNTR)
props->device_cap_flags |= IB_DEVICE_BAD_PKEY_CNTR;
if (dev->dev->caps.flags & MLX4_DEV_CAP_FLAG_BAD_QKEY_CNTR)
props->device_cap_flags |= IB_DEVICE_BAD_QKEY_CNTR;
- if (dev->dev->caps.flags & MLX4_DEV_CAP_FLAG_APM)
+ if (dev->dev->caps.flags & MLX4_DEV_CAP_FLAG_APM && have_ib_ports)
props->device_cap_flags |= IB_DEVICE_AUTO_PATH_MIG;
if (dev->dev->caps.flags & MLX4_DEV_CAP_FLAG_UD_AV_PORT)
props->device_cap_flags |= IB_DEVICE_UD_AV_PORT_ENFORCE;
if (dev->dev->caps.flags & MLX4_DEV_CAP_FLAG_IPOIB_CSUM)
props->device_cap_flags |= IB_DEVICE_UD_IP_CSUM;
- if (dev->dev->caps.max_gso_sz && dev->dev->caps.flags & MLX4_DEV_CAP_FLAG_BLH)
+ if (dev->dev->caps.max_gso_sz &&
+ (dev->dev->rev_id != MLX4_IB_CARD_REV_A0) &&
+ (dev->dev->caps.flags & MLX4_DEV_CAP_FLAG_BLH))
props->device_cap_flags |= IB_DEVICE_UD_TSO;
if (dev->dev->caps.bmme_flags & MLX4_BMME_FLAG_RESERVED_LKEY)
props->device_cap_flags |= IB_DEVICE_LOCAL_DMA_LKEY;
@@ -190,16 +504,6 @@ int mlx4_ib_query_device(struct ib_device *ibdev,
props->device_cap_flags |= IB_DEVICE_MEM_MGT_EXTENSIONS;
if (dev->dev->caps.flags & MLX4_DEV_CAP_FLAG_XRC)
props->device_cap_flags |= IB_DEVICE_XRC;
-
- if (check_flow_steering_support(dev->dev))
- props->device_cap_flags |= IB_DEVICE_MANAGED_FLOW_STEERING;
-
-
- props->device_cap_flags |= IB_DEVICE_QPG;
- if (dev->dev->caps.flags2 & MLX4_DEV_CAP_FLAG2_RSS) {
- props->device_cap_flags |= IB_DEVICE_UD_RSS;
- props->max_rss_tbl_sz = dev->dev->caps.max_rss_tbl_sz;
- }
if (dev->dev->caps.flags & MLX4_DEV_CAP_FLAG_MEM_WINDOW)
props->device_cap_flags |= IB_DEVICE_MEM_WINDOW;
if (dev->dev->caps.bmme_flags & MLX4_BMME_FLAG_TYPE_2_WIN) {
@@ -208,6 +512,11 @@ int mlx4_ib_query_device(struct ib_device *ibdev,
else
props->device_cap_flags |= IB_DEVICE_MEM_WINDOW_TYPE_2A;
}
+ if (dev->steering_support == MLX4_STEERING_MODE_DEVICE_MANAGED)
+ props->device_cap_flags |= IB_DEVICE_MANAGED_FLOW_STEERING;
+
+ props->device_cap_flags |= IB_DEVICE_RAW_IP_CSUM;
+
props->vendor_id = be32_to_cpup((__be32 *) (out_mad->data + 36)) &
0xffffff;
props->vendor_part_id = dev->dev->persist->pdev->device;
@@ -220,6 +529,7 @@ int mlx4_ib_query_device(struct ib_device *ibdev,
props->max_qp_wr = dev->dev->caps.max_wqes - MLX4_IB_SQ_MAX_SPARE;
props->max_sge = min(dev->dev->caps.max_sq_sg,
dev->dev->caps.max_rq_sg);
+ props->max_sge_rd = MLX4_MAX_SGE_RD;
props->max_cq = dev->dev->quotas.cq;
props->max_cqe = dev->dev->caps.max_cqes;
props->max_mr = dev->dev->quotas.mpt;
@@ -241,17 +551,25 @@ int mlx4_ib_query_device(struct ib_device *ibdev,
props->max_total_mcast_qp_attach = props->max_mcast_qp_attach *
props->max_mcast_grp;
props->max_map_per_fmr = dev->dev->caps.max_fmr_maps;
- props->hca_core_clock = dev->dev->caps.hca_core_clock;
+ props->hca_core_clock = dev->dev->caps.hca_core_clock * 1000UL;
+ props->timestamp_mask = 0xFFFFFFFFFFFFULL;
if (!mlx4_is_slave(dev->dev))
err = mlx4_get_internal_clock_params(dev->dev, &clock_params);
- if (dev->dev->caps.hca_core_clock > 0)
- props->comp_mask |= IB_DEVICE_ATTR_WITH_HCA_CORE_CLOCK;
- if (!err && !mlx4_is_slave(dev->dev)) {
- props->timestamp_mask = 0xFFFFFFFFFFFF;
- props->comp_mask |= IB_DEVICE_ATTR_WITH_TIMESTAMP_MASK;
+
+ if (uhw->outlen >= resp.response_length + sizeof(resp.hca_core_clock_offset)) {
+ resp.response_length += sizeof(resp.hca_core_clock_offset);
+ if (!err && !mlx4_is_slave(dev->dev)) {
+ resp.comp_mask |= QUERY_DEVICE_RESP_MASK_TIMESTAMP;
+ resp.hca_core_clock_offset = clock_params.offset % PAGE_SIZE;
+ }
}
+ if (uhw->outlen) {
+ err = ib_copy_to_udata(uhw, &resp, resp.response_length);
+ if (err)
+ goto out;
+ }
out:
kfree(in_mad);
kfree(out_mad);
@@ -372,8 +690,8 @@ static int eth_link_query_port(struct ib_device *ibdev, u8 port,
struct net_device *ndev;
enum ib_mtu tmp;
struct mlx4_cmd_mailbox *mailbox;
- unsigned long flags;
int err = 0;
+ int is_bonded = mlx4_is_bonded(mdev->dev);
mailbox = mlx4_alloc_cmd_mailbox(mdev->dev);
if (IS_ERR(mailbox))
@@ -388,12 +706,8 @@ static int eth_link_query_port(struct ib_device *ibdev, u8 port,
props->active_width = (((u8 *)mailbox->buf)[5] == 0x40) ?
IB_WIDTH_4X : IB_WIDTH_1X;
props->active_speed = IB_SPEED_QDR;
- props->port_cap_flags = IB_PORT_CM_SUP;
- if (netw_view)
- props->gid_tbl_len = MLX4_ROCE_MAX_GIDS;
- else
- props->gid_tbl_len = mdev->dev->caps.gid_table_len[port];
-
+ props->port_cap_flags = IB_PORT_CM_SUP | IB_PORT_IP_BASED_GIDS;
+ props->gid_tbl_len = mdev->dev->caps.gid_table_len[port];
props->max_msg_sz = mdev->dev->caps.max_msg_sz;
props->pkey_tbl_len = 1;
props->max_mtu = IB_MTU_4096;
@@ -401,8 +715,15 @@ static int eth_link_query_port(struct ib_device *ibdev, u8 port,
props->state = IB_PORT_DOWN;
props->phys_state = state_to_phys_state(props->state);
props->active_mtu = IB_MTU_256;
- spin_lock_irqsave(&iboe->lock, flags);
+ spin_lock_bh(&iboe->lock);
ndev = iboe->netdevs[port - 1];
+ if (ndev && is_bonded) {
+#if 0
+ rcu_read_lock(); /* required to get upper dev */
+ ndev = netdev_master_upper_dev_get_rcu(ndev);
+ rcu_read_unlock();
+#endif
+ }
if (!ndev)
goto out_unlock;
@@ -413,7 +734,7 @@ static int eth_link_query_port(struct ib_device *ibdev, u8 port,
IB_PORT_ACTIVE : IB_PORT_DOWN;
props->phys_state = state_to_phys_state(props->state);
out_unlock:
- spin_unlock_irqrestore(&iboe->lock, flags);
+ spin_unlock_bh(&iboe->lock);
out:
mlx4_free_cmd_mailbox(mdev->dev, mailbox);
return err;
@@ -496,23 +817,87 @@ out:
return err;
}
-static int iboe_query_gid(struct ib_device *ibdev, u8 port, int index,
- union ib_gid *gid)
+static int mlx4_ib_query_gid(struct ib_device *ibdev, u8 port, int index,
+ union ib_gid *gid)
{
- struct mlx4_ib_dev *dev = to_mdev(ibdev);
+ int ret;
- *gid = dev->iboe.gid_table[port - 1][index];
+ if (rdma_protocol_ib(ibdev, port))
+ return __mlx4_ib_query_gid(ibdev, port, index, gid, 0);
- return 0;
+ if (!rdma_protocol_roce(ibdev, port))
+ return -ENODEV;
+
+ if (!rdma_cap_roce_gid_table(ibdev, port))
+ return -ENODEV;
+
+ ret = ib_get_cached_gid(ibdev, port, index, gid, NULL);
+ if (ret == -EAGAIN) {
+ memcpy(gid, &zgid, sizeof(*gid));
+ return 0;
+ }
+
+ return ret;
}
-static int mlx4_ib_query_gid(struct ib_device *ibdev, u8 port, int index,
- union ib_gid *gid)
+static int mlx4_ib_query_sl2vl(struct ib_device *ibdev, u8 port, u64 *sl2vl_tbl)
{
- if (rdma_port_get_link_layer(ibdev, port) == IB_LINK_LAYER_INFINIBAND)
- return __mlx4_ib_query_gid(ibdev, port, index, gid, 0);
- else
- return iboe_query_gid(ibdev, port, index, gid);
+ union sl2vl_tbl_to_u64 sl2vl64;
+ struct ib_smp *in_mad = NULL;
+ struct ib_smp *out_mad = NULL;
+ int mad_ifc_flags = MLX4_MAD_IFC_IGNORE_KEYS;
+ int err = -ENOMEM;
+ int jj;
+
+ if (mlx4_is_slave(to_mdev(ibdev)->dev)) {
+ *sl2vl_tbl = 0;
+ return 0;
+ }
+
+ in_mad = kzalloc(sizeof(*in_mad), GFP_KERNEL);
+ out_mad = kmalloc(sizeof(*out_mad), GFP_KERNEL);
+ if (!in_mad || !out_mad)
+ goto out;
+
+ init_query_mad(in_mad);
+ in_mad->attr_id = IB_SMP_ATTR_SL_TO_VL_TABLE;
+ in_mad->attr_mod = 0;
+
+ if (mlx4_is_mfunc(to_mdev(ibdev)->dev))
+ mad_ifc_flags |= MLX4_MAD_IFC_NET_VIEW;
+
+ err = mlx4_MAD_IFC(to_mdev(ibdev), mad_ifc_flags, port, NULL, NULL,
+ in_mad, out_mad);
+ if (err)
+ goto out;
+
+ for (jj = 0; jj < 8; jj++)
+ sl2vl64.sl8[jj] = ((struct ib_smp *)out_mad)->data[jj];
+ *sl2vl_tbl = sl2vl64.sl64;
+
+out:
+ kfree(in_mad);
+ kfree(out_mad);
+ return err;
+}
+
+static void mlx4_init_sl2vl_tbl(struct mlx4_ib_dev *mdev)
+{
+ u64 sl2vl;
+ int i;
+ int err;
+
+ for (i = 1; i <= mdev->dev->caps.num_ports; i++) {
+ if (mdev->dev->caps.port_type[i] == MLX4_PORT_TYPE_ETH)
+ continue;
+ err = mlx4_ib_query_sl2vl(&mdev->ib_dev, i, &sl2vl);
+ if (err) {
+ pr_err("Unable to get default sl to vl mapping for port %d. Using all zeroes (%d)\n",
+ i, err);
+ sl2vl = 0;
+ }
+ atomic64_set(&mdev->sl2vl[i - 1], sl2vl);
+ }
}
int __mlx4_ib_query_pkey(struct ib_device *ibdev, u8 port, u16 index,
@@ -569,7 +954,7 @@ static int mlx4_ib_modify_device(struct ib_device *ibdev, int mask,
return -EOPNOTSUPP;
spin_lock_irqsave(&to_mdev(ibdev)->sm_lock, flags);
- memcpy(ibdev->node_desc, props->node_desc, 64);
+ memcpy(ibdev->node_desc, props->node_desc, IB_DEVICE_NODE_DESC_MAX);
spin_unlock_irqrestore(&to_mdev(ibdev)->sm_lock, flags);
/*
@@ -580,8 +965,7 @@ static int mlx4_ib_modify_device(struct ib_device *ibdev, int mask,
if (IS_ERR(mailbox))
return 0;
- memset(mailbox->buf, 0, 256);
- memcpy(mailbox->buf, props->node_desc, 64);
+ memcpy(mailbox->buf, props->node_desc, IB_DEVICE_NODE_DESC_MAX);
mlx4_cmd(to_mdev(ibdev)->dev, mailbox->dma, 1, 0,
MLX4_CMD_SET_NODE, MLX4_CMD_TIME_CLASS_A, MLX4_CMD_NATIVE);
@@ -590,19 +974,16 @@ static int mlx4_ib_modify_device(struct ib_device *ibdev, int mask,
return 0;
}
-static int mlx4_SET_PORT(struct mlx4_ib_dev *dev, u8 port, int reset_qkey_viols,
- u32 cap_mask)
+static int mlx4_ib_SET_PORT(struct mlx4_ib_dev *dev, u8 port, int reset_qkey_viols,
+ u32 cap_mask)
{
struct mlx4_cmd_mailbox *mailbox;
int err;
- u8 is_eth = dev->dev->caps.port_type[port] == MLX4_PORT_TYPE_ETH;
mailbox = mlx4_alloc_cmd_mailbox(dev->dev);
if (IS_ERR(mailbox))
return PTR_ERR(mailbox);
- memset(mailbox->buf, 0, 256);
-
if (dev->dev->flags & MLX4_FLAG_OLD_PORT_CMDS) {
*(u8 *) mailbox->buf = !!reset_qkey_viols << 6;
((__be32 *) mailbox->buf)[2] = cpu_to_be32(cap_mask);
@@ -611,8 +992,9 @@ static int mlx4_SET_PORT(struct mlx4_ib_dev *dev, u8 port, int reset_qkey_viols,
((__be32 *) mailbox->buf)[1] = cpu_to_be32(cap_mask);
}
- err = mlx4_cmd(dev->dev, mailbox->dma, port, is_eth, MLX4_CMD_SET_PORT,
- MLX4_CMD_TIME_CLASS_B, MLX4_CMD_NATIVE);
+ err = mlx4_cmd(dev->dev, mailbox->dma, port, MLX4_SET_PORT_IB_OPCODE,
+ MLX4_CMD_SET_PORT, MLX4_CMD_TIME_CLASS_B,
+ MLX4_CMD_WRAPPED);
mlx4_free_cmd_mailbox(dev->dev, mailbox);
return err;
@@ -621,11 +1003,20 @@ static int mlx4_SET_PORT(struct mlx4_ib_dev *dev, u8 port, int reset_qkey_viols,
static int mlx4_ib_modify_port(struct ib_device *ibdev, u8 port, int mask,
struct ib_port_modify *props)
{
+ struct mlx4_ib_dev *mdev = to_mdev(ibdev);
+ u8 is_eth = mdev->dev->caps.port_type[port] == MLX4_PORT_TYPE_ETH;
struct ib_port_attr attr;
u32 cap_mask;
int err;
- mutex_lock(&to_mdev(ibdev)->cap_mask_mutex);
+ /* return OK if this is RoCE. CM calls ib_modify_port() regardless
+ * of whether port link layer is ETH or IB. For ETH ports, qkey
+ * violations and port capabilities are not meaningful.
+ */
+ if (is_eth)
+ return 0;
+
+ mutex_lock(&mdev->cap_mask_mutex);
err = mlx4_ib_query_port(ibdev, port, &attr);
if (err)
@@ -634,9 +1025,9 @@ static int mlx4_ib_modify_port(struct ib_device *ibdev, u8 port, int mask,
cap_mask = (attr.port_cap_flags | props->set_port_cap_mask) &
~props->clr_port_cap_mask;
- err = mlx4_SET_PORT(to_mdev(ibdev), port,
- !!(mask & IB_PORT_RESET_QKEY_CNTR),
- cap_mask);
+ err = mlx4_ib_SET_PORT(mdev, port,
+ !!(mask & IB_PORT_RESET_QKEY_CNTR),
+ cap_mask);
out:
mutex_unlock(&to_mdev(ibdev)->cap_mask_mutex);
@@ -657,27 +1048,17 @@ static struct ib_ucontext *mlx4_ib_alloc_ucontext(struct ib_device *ibdev,
if (ibdev->uverbs_abi_ver == MLX4_IB_UVERBS_NO_DEV_CAPS_ABI_VERSION) {
resp_v3.qp_tab_size = dev->dev->caps.num_qps;
- if (mlx4_wc_enabled()) {
- resp_v3.bf_reg_size = dev->dev->caps.bf_reg_size;
- resp_v3.bf_regs_per_page = dev->dev->caps.bf_regs_per_page;
- } else {
- resp_v3.bf_reg_size = 0;
- resp_v3.bf_regs_per_page = 0;
- }
+ resp_v3.bf_reg_size = dev->dev->caps.bf_reg_size;
+ resp_v3.bf_regs_per_page = dev->dev->caps.bf_regs_per_page;
} else {
resp.dev_caps = dev->dev->caps.userspace_caps;
resp.qp_tab_size = dev->dev->caps.num_qps;
- if (mlx4_wc_enabled()) {
- resp.bf_reg_size = dev->dev->caps.bf_reg_size;
- resp.bf_regs_per_page = dev->dev->caps.bf_regs_per_page;
- } else {
- resp.bf_reg_size = 0;
- resp.bf_regs_per_page = 0;
- }
+ resp.bf_reg_size = dev->dev->caps.bf_reg_size;
+ resp.bf_regs_per_page = dev->dev->caps.bf_regs_per_page;
resp.cqe_size = dev->dev->caps.cqe_size;
}
- context = kmalloc(sizeof *context, GFP_KERNEL);
+ context = kzalloc(sizeof(*context), GFP_KERNEL);
if (!context)
return ERR_PTR(-ENOMEM);
@@ -714,100 +1095,167 @@ static int mlx4_ib_dealloc_ucontext(struct ib_ucontext *ibcontext)
return 0;
}
-/* XXX FBSD has no support for get_unmapped_area function */
-#if 0
-static unsigned long mlx4_ib_get_unmapped_area(struct file *file,
- unsigned long addr,
- unsigned long len, unsigned long pgoff,
- unsigned long flags)
+static void mlx4_ib_vma_open(struct vm_area_struct *area)
+{
+ /* vma_open is called when a new VMA is created on top of our VMA.
+ * This is done through either mremap flow or split_vma (usually due
+ * to mlock, madvise, munmap, etc.). We do not support a clone of the
+ * vma, as this VMA is strongly hardware related. Therefore we set the
+ * vm_ops of the newly created/cloned VMA to NULL, to prevent it from
+ * calling us again and trying to do incorrect actions. We assume that
+ * the original vma size is exactly a single page that there will be no
+ * "splitting" operations on.
+ */
+ area->vm_ops = NULL;
+}
+
+static void mlx4_ib_vma_close(struct vm_area_struct *area)
+{
+ struct mlx4_ib_vma_private_data *mlx4_ib_vma_priv_data;
+
+ /* It's guaranteed that all VMAs opened on a FD are closed before the
+ * file itself is closed, therefore no sync is needed with the regular
+ * closing flow. (e.g. mlx4_ib_dealloc_ucontext) However need a sync
+ * with accessing the vma as part of mlx4_ib_disassociate_ucontext.
+ * The close operation is usually called under mm->mmap_sem except when
+ * process is exiting. The exiting case is handled explicitly as part
+ * of mlx4_ib_disassociate_ucontext.
+ */
+ mlx4_ib_vma_priv_data = (struct mlx4_ib_vma_private_data *)
+ area->vm_private_data;
+
+ /* set the vma context pointer to null in the mlx4_ib driver's private
+ * data to protect against a race condition in mlx4_ib_dissassociate_ucontext().
+ */
+ mlx4_ib_vma_priv_data->vma = NULL;
+}
+
+static const struct vm_operations_struct mlx4_ib_vm_ops = {
+ .open = mlx4_ib_vma_open,
+ .close = mlx4_ib_vma_close
+};
+
+static void mlx4_ib_disassociate_ucontext(struct ib_ucontext *ibcontext)
{
- struct mm_struct *mm;
+ int i;
+ int ret = 0;
struct vm_area_struct *vma;
- unsigned long start_addr;
- unsigned long page_size_order;
- unsigned long command;
-
- mm = current->mm;
- if (addr)
- return current->mm->get_unmapped_area(file, addr, len,
- pgoff, flags);
-
- /* Last 8 bits hold the command others are data per that command */
- command = pgoff & MLX4_IB_MMAP_CMD_MASK;
- if (command != MLX4_IB_MMAP_GET_CONTIGUOUS_PAGES)
- return current->mm->get_unmapped_area(file, addr, len,
- pgoff, flags);
-
- page_size_order = pgoff >> MLX4_IB_MMAP_CMD_BITS;
- /* code is based on the huge-pages get_unmapped_area code */
- start_addr = mm->free_area_cache;
-
- if (len <= mm->cached_hole_size)
- start_addr = TASK_UNMAPPED_BASE;
-
-
-full_search:
- addr = ALIGN(start_addr, 1 << page_size_order);
-
- for (vma = find_vma(mm, addr); ; vma = vma->vm_next) {
- /* At this point: (!vma || addr < vma->vm_end). */
- if (TASK_SIZE - len < addr) {
- /*
- * Start a new search - just in case we missed
- * some holes.
+ struct mlx4_ib_ucontext *context = to_mucontext(ibcontext);
+ struct task_struct *owning_process = NULL;
+ struct mm_struct *owning_mm = NULL;
+
+ owning_process = get_pid_task(ibcontext->tgid, PIDTYPE_PID);
+ if (!owning_process)
+ return;
+
+ owning_mm = get_task_mm(owning_process);
+ if (!owning_mm) {
+ pr_info("no mm, disassociate ucontext is pending task termination\n");
+ while (1) {
+ /* make sure that task is dead before returning, it may
+ * prevent a rare case of module down in parallel to a
+ * call to mlx4_ib_vma_close.
*/
- if (start_addr != TASK_UNMAPPED_BASE) {
- start_addr = TASK_UNMAPPED_BASE;
- goto full_search;
+ put_task_struct(owning_process);
+ msleep(1);
+ owning_process = get_pid_task(ibcontext->tgid,
+ PIDTYPE_PID);
+ if (!owning_process /* ||
+ owning_process->state == TASK_DEAD */) {
+ pr_info("disassociate ucontext done, task was terminated\n");
+ /* in case task was dead need to release the task struct */
+ if (owning_process)
+ put_task_struct(owning_process);
+ return;
}
- return -ENOMEM;
}
+ }
- if (!vma || addr + len <= vma->vm_start)
- return addr;
- addr = ALIGN(vma->vm_end, 1 << page_size_order);
+ /* need to protect from a race on closing the vma as part of
+ * mlx4_ib_vma_close().
+ */
+ down_read(&owning_mm->mmap_sem);
+ for (i = 0; i < HW_BAR_COUNT; i++) {
+ vma = context->hw_bar_info[i].vma;
+ if (!vma)
+ continue;
+
+ ret = zap_vma_ptes(context->hw_bar_info[i].vma,
+ context->hw_bar_info[i].vma->vm_start,
+ PAGE_SIZE);
+ if (ret) {
+ pr_err("Error: zap_vma_ptes failed for index=%d, ret=%d\n", i, ret);
+ BUG_ON(1);
+ }
+
+ /* context going to be destroyed, should not access ops any more */
+ context->hw_bar_info[i].vma->vm_ops = NULL;
}
+
+ up_read(&owning_mm->mmap_sem);
+ mmput(owning_mm);
+ put_task_struct(owning_process);
+}
+
+static void mlx4_ib_set_vma_data(struct vm_area_struct *vma,
+ struct mlx4_ib_vma_private_data *vma_private_data)
+{
+ vma_private_data->vma = vma;
+ vma->vm_private_data = vma_private_data;
+ vma->vm_ops = &mlx4_ib_vm_ops;
}
-#endif
static int mlx4_ib_mmap(struct ib_ucontext *context, struct vm_area_struct *vma)
{
struct mlx4_ib_dev *dev = to_mdev(context->device);
+ struct mlx4_ib_ucontext *mucontext = to_mucontext(context);
- /* Last 8 bits hold the command others are data per that command */
- unsigned long command = vma->vm_pgoff & MLX4_IB_MMAP_CMD_MASK;
+ if (vma->vm_end - vma->vm_start != PAGE_SIZE)
+ return -EINVAL;
- if (command < MLX4_IB_MMAP_GET_CONTIGUOUS_PAGES) {
- /* compatibility handling for commands 0 & 1*/
- if (vma->vm_end - vma->vm_start != PAGE_SIZE)
+ if (vma->vm_pgoff == 0) {
+ /* We prevent double mmaping on same context */
+ if (mucontext->hw_bar_info[HW_BAR_DB].vma)
return -EINVAL;
- }
- if (command == MLX4_IB_MMAP_UAR_PAGE) {
+
vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);
if (io_remap_pfn_range(vma, vma->vm_start,
to_mucontext(context)->uar.pfn,
PAGE_SIZE, vma->vm_page_prot))
return -EAGAIN;
- } else if (command == MLX4_IB_MMAP_BLUE_FLAME_PAGE &&
- dev->dev->caps.bf_reg_size != 0) {
- vma->vm_page_prot = pgprot_wc(vma->vm_page_prot);
+
+ mlx4_ib_set_vma_data(vma, &mucontext->hw_bar_info[HW_BAR_DB]);
+
+ } else if (vma->vm_pgoff == 1 && dev->dev->caps.bf_reg_size != 0) {
+ /* We prevent double mmaping on same context */
+ if (mucontext->hw_bar_info[HW_BAR_BF].vma)
+ return -EINVAL;
+
+ vma->vm_page_prot = pgprot_writecombine(vma->vm_page_prot);
if (io_remap_pfn_range(vma, vma->vm_start,
to_mucontext(context)->uar.pfn +
dev->dev->caps.num_uars,
PAGE_SIZE, vma->vm_page_prot))
return -EAGAIN;
- } else if (command == MLX4_IB_MMAP_GET_HW_CLOCK) {
+
+ mlx4_ib_set_vma_data(vma, &mucontext->hw_bar_info[HW_BAR_BF]);
+
+ } else if (vma->vm_pgoff == 3) {
struct mlx4_clock_params params;
int ret;
+ /* We prevent double mmaping on same context */
+ if (mucontext->hw_bar_info[HW_BAR_CLOCK].vma)
+ return -EINVAL;
+
ret = mlx4_get_internal_clock_params(dev->dev, &params);
+
if (ret)
return ret;
vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);
-
if (io_remap_pfn_range(vma, vma->vm_start,
(pci_resource_start(dev->dev->persist->pdev,
params.bar) +
@@ -815,62 +1263,13 @@ static int mlx4_ib_mmap(struct ib_ucontext *context, struct vm_area_struct *vma)
>> PAGE_SHIFT,
PAGE_SIZE, vma->vm_page_prot))
return -EAGAIN;
- } else
- return -EINVAL;
-
- return 0;
-}
-
-static int mlx4_ib_ioctl(struct ib_ucontext *context, unsigned int cmd,
- unsigned long arg)
-{
- struct mlx4_ib_dev *dev = to_mdev(context->device);
- int ret;
- int offset;
-
- switch (cmd) {
- case MLX4_IOCHWCLOCKOFFSET: {
- struct mlx4_clock_params params;
- int ret;
- ret = mlx4_get_internal_clock_params(dev->dev, &params);
- if (!ret) {
- offset = params.offset % PAGE_SIZE;
- ret = put_user(offset,
- (int *)arg);
- return sizeof(int);
- } else {
- return ret;
- }
- }
- default: {
- pr_err("mlx4_ib: invalid ioctl %u command with arg %lX\n",
- cmd, arg);
- return -ENOTTY;
- }
- }
-
- return ret;
-}
-
-static int mlx4_ib_query_values(struct ib_device *device, int q_values,
- struct ib_device_values *values)
-{
- struct mlx4_ib_dev *dev = to_mdev(device);
- s64 cycles;
- values->values_mask = 0;
- if (q_values & IBV_VALUES_HW_CLOCK) {
- cycles = mlx4_read_clock(dev->dev);
- if (cycles >= 0) {
- values->hwclock = cycles & CORE_CLOCK_MASK;
- values->values_mask |= IBV_VALUES_HW_CLOCK;
- }
- q_values &= ~IBV_VALUES_HW_CLOCK;
+ mlx4_ib_set_vma_data(vma,
+ &mucontext->hw_bar_info[HW_BAR_CLOCK]);
+ } else {
+ return -EINVAL;
}
- if (q_values)
- return -ENOTTY;
-
return 0;
}
@@ -914,6 +1313,7 @@ static struct ib_xrcd *mlx4_ib_alloc_xrcd(struct ib_device *ibdev,
struct ib_udata *udata)
{
struct mlx4_ib_xrcd *xrcd;
+ struct ib_cq_init_attr cq_attr = {};
int err;
if (!(to_mdev(ibdev)->dev->caps.flags & MLX4_DEV_CAP_FLAG_XRC))
@@ -927,13 +1327,14 @@ static struct ib_xrcd *mlx4_ib_alloc_xrcd(struct ib_device *ibdev,
if (err)
goto err1;
- xrcd->pd = ib_alloc_pd(ibdev);
+ xrcd->pd = ib_alloc_pd(ibdev, 0);
if (IS_ERR(xrcd->pd)) {
err = PTR_ERR(xrcd->pd);
goto err2;
}
- xrcd->cq = ib_create_cq(ibdev, NULL, NULL, xrcd, 1, 0);
+ cq_attr.cqe = 1;
+ xrcd->cq = ib_create_cq(ibdev, NULL, NULL, xrcd, &cq_attr);
if (IS_ERR(xrcd->cq)) {
err = PTR_ERR(xrcd->cq);
goto err3;
@@ -983,28 +1384,39 @@ static int add_gid_entry(struct ib_qp *ibqp, union ib_gid *gid)
return 0;
}
+static void mlx4_ib_delete_counters_table(struct mlx4_ib_dev *ibdev,
+ struct mlx4_ib_counters *ctr_table)
+{
+ struct counter_index *counter, *tmp_count;
+
+ mutex_lock(&ctr_table->mutex);
+ list_for_each_entry_safe(counter, tmp_count, &ctr_table->counters_list,
+ list) {
+ if (counter->allocated)
+ mlx4_counter_free(ibdev->dev, counter->index);
+ list_del(&counter->list);
+ kfree(counter);
+ }
+ mutex_unlock(&ctr_table->mutex);
+}
+
int mlx4_ib_add_mc(struct mlx4_ib_dev *mdev, struct mlx4_ib_qp *mqp,
union ib_gid *gid)
{
- u8 mac[6];
struct net_device *ndev;
int ret = 0;
if (!mqp->port)
return 0;
- spin_lock(&mdev->iboe.lock);
+ spin_lock_bh(&mdev->iboe.lock);
ndev = mdev->iboe.netdevs[mqp->port - 1];
if (ndev)
dev_hold(ndev);
- spin_unlock(&mdev->iboe.lock);
+ spin_unlock_bh(&mdev->iboe.lock);
if (ndev) {
- rdma_get_mcast_mac((struct in6_addr *)gid, mac);
- rtnl_lock();
- dev_mc_add(mdev->iboe.netdevs[mqp->port - 1], mac, 6, 0);
ret = 1;
- rtnl_unlock();
dev_put(ndev);
}
@@ -1013,11 +1425,25 @@ int mlx4_ib_add_mc(struct mlx4_ib_dev *mdev, struct mlx4_ib_qp *mqp,
struct mlx4_ib_steering {
struct list_head list;
- u64 reg_id;
+ struct mlx4_flow_reg_id reg_id;
union ib_gid gid;
};
+#define LAST_ETH_FIELD vlan_tag
+#define LAST_IB_FIELD sl
+#define LAST_IPV4_FIELD dst_ip
+#define LAST_TCP_UDP_FIELD src_port
+
+/* Field is the last supported field */
+#define FIELDS_NOT_SUPPORTED(filter, field)\
+ memchr_inv((void *)&filter.field +\
+ sizeof(filter.field), 0,\
+ sizeof(filter) -\
+ offsetof(typeof(filter), field) -\
+ sizeof(filter.field))
+
static int parse_flow_attr(struct mlx4_dev *dev,
+ u32 qp_num,
union ib_flow_spec *ib_spec,
struct _rule_hw *mlx4_spec)
{
@@ -1025,6 +1451,9 @@ static int parse_flow_attr(struct mlx4_dev *dev,
switch (ib_spec->type) {
case IB_FLOW_SPEC_ETH:
+ if (FIELDS_NOT_SUPPORTED(ib_spec->eth.mask, LAST_ETH_FIELD))
+ return -ENOTSUPP;
+
type = MLX4_NET_TRANS_RULE_ID_ETH;
memcpy(mlx4_spec->eth.dst_mac, ib_spec->eth.val.dst_mac,
ETH_ALEN);
@@ -1033,17 +1462,22 @@ static int parse_flow_attr(struct mlx4_dev *dev,
mlx4_spec->eth.vlan_tag = ib_spec->eth.val.vlan_tag;
mlx4_spec->eth.vlan_tag_msk = ib_spec->eth.mask.vlan_tag;
break;
-
case IB_FLOW_SPEC_IB:
+ if (FIELDS_NOT_SUPPORTED(ib_spec->ib.mask, LAST_IB_FIELD))
+ return -ENOTSUPP;
+
type = MLX4_NET_TRANS_RULE_ID_IB;
- mlx4_spec->ib.l3_qpn = ib_spec->ib.val.l3_type_qpn;
- mlx4_spec->ib.qpn_mask = ib_spec->ib.mask.l3_type_qpn;
- memcpy(&mlx4_spec->ib.dst_gid, ib_spec->ib.val.dst_gid, 16);
- memcpy(&mlx4_spec->ib.dst_gid_msk,
- ib_spec->ib.mask.dst_gid, 16);
+ mlx4_spec->ib.l3_qpn =
+ cpu_to_be32(qp_num);
+ mlx4_spec->ib.qpn_mask =
+ cpu_to_be32(MLX4_IB_FLOW_QPN_MASK);
break;
+
case IB_FLOW_SPEC_IPV4:
+ if (FIELDS_NOT_SUPPORTED(ib_spec->ipv4.mask, LAST_IPV4_FIELD))
+ return -ENOTSUPP;
+
type = MLX4_NET_TRANS_RULE_ID_IPV4;
mlx4_spec->ipv4.src_ip = ib_spec->ipv4.val.src_ip;
mlx4_spec->ipv4.src_ip_msk = ib_spec->ipv4.mask.src_ip;
@@ -1053,15 +1487,16 @@ static int parse_flow_attr(struct mlx4_dev *dev,
case IB_FLOW_SPEC_TCP:
case IB_FLOW_SPEC_UDP:
+ if (FIELDS_NOT_SUPPORTED(ib_spec->tcp_udp.mask, LAST_TCP_UDP_FIELD))
+ return -ENOTSUPP;
+
type = ib_spec->type == IB_FLOW_SPEC_TCP ?
MLX4_NET_TRANS_RULE_ID_TCP :
MLX4_NET_TRANS_RULE_ID_UDP;
mlx4_spec->tcp_udp.dst_port = ib_spec->tcp_udp.val.dst_port;
- mlx4_spec->tcp_udp.dst_port_msk =
- ib_spec->tcp_udp.mask.dst_port;
+ mlx4_spec->tcp_udp.dst_port_msk = ib_spec->tcp_udp.mask.dst_port;
mlx4_spec->tcp_udp.src_port = ib_spec->tcp_udp.val.src_port;
- mlx4_spec->tcp_udp.src_port_msk =
- ib_spec->tcp_udp.mask.src_port;
+ mlx4_spec->tcp_udp.src_port_msk = ib_spec->tcp_udp.mask.src_port;
break;
default:
@@ -1075,6 +1510,113 @@ static int parse_flow_attr(struct mlx4_dev *dev,
return mlx4_hw_rule_sz(dev, type);
}
+struct default_rules {
+ __u32 mandatory_fields[IB_FLOW_SPEC_SUPPORT_LAYERS];
+ __u32 mandatory_not_fields[IB_FLOW_SPEC_SUPPORT_LAYERS];
+ __u32 rules_create_list[IB_FLOW_SPEC_SUPPORT_LAYERS];
+ __u8 link_layer;
+};
+static const struct default_rules default_table[] = {
+ {
+ .mandatory_fields = {IB_FLOW_SPEC_IPV4},
+ .mandatory_not_fields = {IB_FLOW_SPEC_ETH},
+ .rules_create_list = {IB_FLOW_SPEC_IB},
+ .link_layer = IB_LINK_LAYER_INFINIBAND
+ }
+};
+
+static int __mlx4_ib_default_rules_match(struct ib_qp *qp,
+ struct ib_flow_attr *flow_attr)
+{
+ int i, j, k;
+ void *ib_flow;
+ const struct default_rules *pdefault_rules = default_table;
+ u8 link_layer = rdma_port_get_link_layer(qp->device, flow_attr->port);
+
+ for (i = 0; i < ARRAY_SIZE(default_table); i++, pdefault_rules++) {
+ __u32 field_types[IB_FLOW_SPEC_SUPPORT_LAYERS];
+ memset(&field_types, 0, sizeof(field_types));
+
+ if (link_layer != pdefault_rules->link_layer)
+ continue;
+
+ ib_flow = flow_attr + 1;
+ /* we assume the specs are sorted */
+ for (j = 0, k = 0; k < IB_FLOW_SPEC_SUPPORT_LAYERS &&
+ j < flow_attr->num_of_specs; k++) {
+ union ib_flow_spec *current_flow =
+ (union ib_flow_spec *)ib_flow;
+
+ /* same layer but different type */
+ if (((current_flow->type & IB_FLOW_SPEC_LAYER_MASK) ==
+ (pdefault_rules->mandatory_fields[k] &
+ IB_FLOW_SPEC_LAYER_MASK)) &&
+ (current_flow->type !=
+ pdefault_rules->mandatory_fields[k]))
+ goto out;
+
+ /* same layer, try match next one */
+ if (current_flow->type ==
+ pdefault_rules->mandatory_fields[k]) {
+ j++;
+ ib_flow +=
+ ((union ib_flow_spec *)ib_flow)->size;
+ }
+ }
+
+ ib_flow = flow_attr + 1;
+ for (j = 0; j < flow_attr->num_of_specs;
+ j++, ib_flow += ((union ib_flow_spec *)ib_flow)->size)
+ for (k = 0; k < IB_FLOW_SPEC_SUPPORT_LAYERS; k++)
+ /* same layer and same type */
+ if (((union ib_flow_spec *)ib_flow)->type ==
+ pdefault_rules->mandatory_not_fields[k])
+ goto out;
+
+ return i;
+ }
+out:
+ return -1;
+}
+
+static int __mlx4_ib_create_default_rules(
+ struct mlx4_ib_dev *mdev,
+ struct ib_qp *qp,
+ const struct default_rules *pdefault_rules,
+ struct _rule_hw *mlx4_spec) {
+ int size = 0;
+ int i;
+
+ for (i = 0; i < ARRAY_SIZE(pdefault_rules->rules_create_list); i++) {
+ int ret;
+ union ib_flow_spec ib_spec;
+ switch (pdefault_rules->rules_create_list[i]) {
+ case 0:
+ /* no rule */
+ continue;
+ case IB_FLOW_SPEC_IB:
+ ib_spec.type = IB_FLOW_SPEC_IB;
+ ib_spec.size = sizeof(struct ib_flow_spec_ib);
+
+ break;
+ default:
+ /* invalid rule */
+ return -EINVAL;
+ }
+ /* We must put empty rule, qpn is being ignored */
+ ret = parse_flow_attr(mdev->dev, 0, &ib_spec,
+ mlx4_spec);
+ if (ret < 0) {
+ pr_info("invalid parsing\n");
+ return -EINVAL;
+ }
+
+ mlx4_spec = (void *)mlx4_spec + ret;
+ size += ret;
+ }
+ return size;
+}
+
static int __mlx4_ib_create_flow(struct ib_qp *qp, struct ib_flow_attr *flow_attr,
int domain,
enum mlx4_net_trans_promisc_mode flow_type,
@@ -1086,8 +1628,7 @@ static int __mlx4_ib_create_flow(struct ib_qp *qp, struct ib_flow_attr *flow_att
struct mlx4_ib_dev *mdev = to_mdev(qp->device);
struct mlx4_cmd_mailbox *mailbox;
struct mlx4_net_trans_rule_hw_ctrl *ctrl;
- size_t rule_size = sizeof(struct mlx4_net_trans_rule_hw_ctrl) +
- (sizeof(struct _rule_hw) * flow_attr->num_of_specs);
+ int default_flow;
static const u16 __mlx4_domain[] = {
[IB_FLOW_DOMAIN_USER] = MLX4_DOMAIN_UVERBS,
@@ -1097,11 +1638,12 @@ static int __mlx4_ib_create_flow(struct ib_qp *qp, struct ib_flow_attr *flow_att
};
if (flow_attr->priority > MLX4_IB_FLOW_MAX_PRIO) {
- pr_err("Invalid priority value.\n");
+ pr_err("Invalid priority value %d\n", flow_attr->priority);
return -EINVAL;
}
+
if (domain >= IB_FLOW_DOMAIN_NUM) {
- pr_err("Invalid domain value.\n");
+ pr_err("Invalid domain value %d\n", domain);
return -EINVAL;
}
@@ -1111,7 +1653,6 @@ static int __mlx4_ib_create_flow(struct ib_qp *qp, struct ib_flow_attr *flow_att
mailbox = mlx4_alloc_cmd_mailbox(mdev->dev);
if (IS_ERR(mailbox))
return PTR_ERR(mailbox);
- memset(mailbox->buf, 0, rule_size);
ctrl = mailbox->buf;
ctrl->prio = cpu_to_be16(__mlx4_domain[domain] |
@@ -1120,30 +1661,41 @@ static int __mlx4_ib_create_flow(struct ib_qp *qp, struct ib_flow_attr *flow_att
ctrl->port = flow_attr->port;
ctrl->qpn = cpu_to_be32(qp->qp_num);
- if (flow_attr->flags & IB_FLOW_ATTR_FLAGS_ALLOW_LOOP_BACK)
- ctrl->flags = (1 << 3);
-
ib_flow = flow_attr + 1;
size += sizeof(struct mlx4_net_trans_rule_hw_ctrl);
+ /* Add default flows */
+ default_flow = __mlx4_ib_default_rules_match(qp, flow_attr);
+ if (default_flow >= 0) {
+ ret = __mlx4_ib_create_default_rules(
+ mdev, qp, default_table + default_flow,
+ mailbox->buf + size);
+ if (ret < 0) {
+ mlx4_free_cmd_mailbox(mdev->dev, mailbox);
+ return -EINVAL;
+ }
+ size += ret;
+ }
for (i = 0; i < flow_attr->num_of_specs; i++) {
- ret = parse_flow_attr(mdev->dev, ib_flow, mailbox->buf + size);
+ ret = parse_flow_attr(mdev->dev, qp->qp_num, ib_flow,
+ mailbox->buf + size);
if (ret < 0) {
mlx4_free_cmd_mailbox(mdev->dev, mailbox);
return -EINVAL;
}
- ib_flow += ((union ib_flow_spec *)ib_flow)->size;
+ ib_flow += ((union ib_flow_spec *) ib_flow)->size;
size += ret;
}
ret = mlx4_cmd_imm(mdev->dev, mailbox->dma, reg_id, size >> 2, 0,
MLX4_QP_FLOW_STEERING_ATTACH, MLX4_CMD_TIME_CLASS_A,
- MLX4_CMD_NATIVE);
+ MLX4_CMD_WRAPPED);
if (ret == -ENOMEM)
pr_err("mcg table is full. Fail to register network rule.\n");
else if (ret == -ENXIO)
pr_err("Device managed flow steering is disabled. Fail to register network rule.\n");
else if (ret)
- pr_err("Invalid argumant. Fail to register network rule.\n");
+ pr_err("Invalid argument. Fail to register network rule.\n");
+
mlx4_free_cmd_mailbox(mdev->dev, mailbox);
return ret;
}
@@ -1153,10 +1705,85 @@ static int __mlx4_ib_destroy_flow(struct mlx4_dev *dev, u64 reg_id)
int err;
err = mlx4_cmd(dev, reg_id, 0, 0,
MLX4_QP_FLOW_STEERING_DETACH, MLX4_CMD_TIME_CLASS_A,
- MLX4_CMD_NATIVE);
+ MLX4_CMD_WRAPPED);
if (err)
pr_err("Fail to detach network rule. registration id = 0x%llx\n",
- (unsigned long long)reg_id);
+ (long long)reg_id);
+ return err;
+}
+
+static int mlx4_ib_tunnel_steer_add(struct ib_qp *qp, struct ib_flow_attr *flow_attr,
+ u64 *reg_id)
+{
+ void *ib_flow;
+ union ib_flow_spec *ib_spec;
+ struct mlx4_dev *dev = to_mdev(qp->device)->dev;
+ int err = 0;
+
+ if (dev->caps.tunnel_offload_mode != MLX4_TUNNEL_OFFLOAD_MODE_VXLAN ||
+ dev->caps.dmfs_high_steer_mode == MLX4_STEERING_DMFS_A0_STATIC)
+ return 0; /* do nothing */
+
+ ib_flow = flow_attr + 1;
+ ib_spec = (union ib_flow_spec *)ib_flow;
+
+ if (ib_spec->type != IB_FLOW_SPEC_ETH || flow_attr->num_of_specs != 1)
+ return 0; /* do nothing */
+
+ err = mlx4_tunnel_steer_add(to_mdev(qp->device)->dev, ib_spec->eth.val.dst_mac,
+ flow_attr->port, qp->qp_num,
+ MLX4_DOMAIN_UVERBS | (flow_attr->priority & 0xff),
+ reg_id);
+ return err;
+}
+
+static int mlx4_ib_add_dont_trap_rule(struct mlx4_dev *dev,
+ struct ib_flow_attr *flow_attr,
+ enum mlx4_net_trans_promisc_mode *type)
+{
+ int err = 0;
+
+ if (!(dev->caps.flags2 & MLX4_DEV_CAP_FLAG2_DMFS_UC_MC_SNIFFER) ||
+ (dev->caps.dmfs_high_steer_mode == MLX4_STEERING_DMFS_A0_STATIC) ||
+ (flow_attr->num_of_specs > 1) || (flow_attr->priority != 0)) {
+ return -EOPNOTSUPP;
+ }
+
+ if (flow_attr->num_of_specs == 0) {
+ type[0] = MLX4_FS_MC_SNIFFER;
+ type[1] = MLX4_FS_UC_SNIFFER;
+ } else {
+ union ib_flow_spec *ib_spec;
+
+ ib_spec = (union ib_flow_spec *)(flow_attr + 1);
+ if (ib_spec->type != IB_FLOW_SPEC_ETH)
+ return -EINVAL;
+
+ /* if all is zero than MC and UC */
+ if (is_zero_ether_addr(ib_spec->eth.mask.dst_mac)) {
+ type[0] = MLX4_FS_MC_SNIFFER;
+ type[1] = MLX4_FS_UC_SNIFFER;
+ } else {
+ u8 mac[ETH_ALEN] = {ib_spec->eth.mask.dst_mac[0] ^ 0x01,
+ ib_spec->eth.mask.dst_mac[1],
+ ib_spec->eth.mask.dst_mac[2],
+ ib_spec->eth.mask.dst_mac[3],
+ ib_spec->eth.mask.dst_mac[4],
+ ib_spec->eth.mask.dst_mac[5]};
+
+ /* Above xor was only on MC bit, non empty mask is valid
+ * only if this bit is set and rest are zero.
+ */
+ if (!is_zero_ether_addr(&mac[0]))
+ return -EINVAL;
+
+ if (is_multicast_ether_addr(ib_spec->eth.val.dst_mac))
+ type[0] = MLX4_FS_MC_SNIFFER;
+ else
+ type[0] = MLX4_FS_UC_SNIFFER;
+ }
+ }
+
return err;
}
@@ -1164,13 +1791,22 @@ static struct ib_flow *mlx4_ib_create_flow(struct ib_qp *qp,
struct ib_flow_attr *flow_attr,
int domain)
{
- int err = 0, i = 0;
+ int err = 0, i = 0, j = 0;
struct mlx4_ib_flow *mflow;
enum mlx4_net_trans_promisc_mode type[2];
+ struct mlx4_dev *dev = (to_mdev(qp->device))->dev;
+ int is_bonded = mlx4_is_bonded(dev);
+
+ if (flow_attr->port < 1 || flow_attr->port > qp->device->phys_port_cnt)
+ return ERR_PTR(-EINVAL);
+
+ if ((flow_attr->flags & IB_FLOW_ATTR_FLAGS_DONT_TRAP) &&
+ (flow_attr->type != IB_FLOW_ATTR_NORMAL))
+ return ERR_PTR(-EOPNOTSUPP);
memset(type, 0, sizeof(type));
- mflow = kzalloc(sizeof(struct mlx4_ib_flow), GFP_KERNEL);
+ mflow = kzalloc(sizeof(*mflow), GFP_KERNEL);
if (!mflow) {
err = -ENOMEM;
goto err_free;
@@ -1178,7 +1814,19 @@ static struct ib_flow *mlx4_ib_create_flow(struct ib_qp *qp,
switch (flow_attr->type) {
case IB_FLOW_ATTR_NORMAL:
- type[0] = MLX4_FS_REGULAR;
+ /* If dont trap flag (continue match) is set, under specific
+ * condition traffic be replicated to given qp,
+ * without stealing it
+ */
+ if (unlikely(flow_attr->flags & IB_FLOW_ATTR_FLAGS_DONT_TRAP)) {
+ err = mlx4_ib_add_dont_trap_rule(dev,
+ flow_attr,
+ type);
+ if (err)
+ goto err_free;
+ } else {
+ type[0] = MLX4_FS_REGULAR;
+ }
break;
case IB_FLOW_ATTR_ALL_DEFAULT:
@@ -1190,8 +1838,8 @@ static struct ib_flow *mlx4_ib_create_flow(struct ib_qp *qp,
break;
case IB_FLOW_ATTR_SNIFFER:
- type[0] = MLX4_FS_UC_SNIFFER;
- type[1] = MLX4_FS_MC_SNIFFER;
+ type[0] = MLX4_FS_MIRROR_RX_PORT;
+ type[1] = MLX4_FS_MIRROR_SX_PORT;
break;
default:
@@ -1201,14 +1849,59 @@ static struct ib_flow *mlx4_ib_create_flow(struct ib_qp *qp,
while (i < ARRAY_SIZE(type) && type[i]) {
err = __mlx4_ib_create_flow(qp, flow_attr, domain, type[i],
- &mflow->reg_id[i]);
+ &mflow->reg_id[i].id);
if (err)
- goto err_free;
+ goto err_create_flow;
+ if (is_bonded) {
+ /* Application always sees one port so the mirror rule
+ * must be on port #2
+ */
+ flow_attr->port = 2;
+ err = __mlx4_ib_create_flow(qp, flow_attr,
+ domain, type[j],
+ &mflow->reg_id[j].mirror);
+ flow_attr->port = 1;
+ if (err)
+ goto err_create_flow;
+ j++;
+ }
+
+ i++;
+ }
+
+ if (i < ARRAY_SIZE(type) && flow_attr->type == IB_FLOW_ATTR_NORMAL) {
+ err = mlx4_ib_tunnel_steer_add(qp, flow_attr,
+ &mflow->reg_id[i].id);
+ if (err)
+ goto err_create_flow;
+
+ if (is_bonded) {
+ flow_attr->port = 2;
+ err = mlx4_ib_tunnel_steer_add(qp, flow_attr,
+ &mflow->reg_id[j].mirror);
+ flow_attr->port = 1;
+ if (err)
+ goto err_create_flow;
+ j++;
+ }
+ /* function to create mirror rule */
i++;
}
return &mflow->ibflow;
+err_create_flow:
+ while (i) {
+ (void)__mlx4_ib_destroy_flow(to_mdev(qp->device)->dev,
+ mflow->reg_id[i].id);
+ i--;
+ }
+
+ while (j) {
+ (void)__mlx4_ib_destroy_flow(to_mdev(qp->device)->dev,
+ mflow->reg_id[j].mirror);
+ j--;
+ }
err_free:
kfree(mflow);
return ERR_PTR(err);
@@ -1221,10 +1914,16 @@ static int mlx4_ib_destroy_flow(struct ib_flow *flow_id)
struct mlx4_ib_dev *mdev = to_mdev(flow_id->qp->device);
struct mlx4_ib_flow *mflow = to_mflow(flow_id);
- while (i < ARRAY_SIZE(mflow->reg_id) && mflow->reg_id[i]) {
- err = __mlx4_ib_destroy_flow(mdev->dev, mflow->reg_id[i]);
+ while (i < ARRAY_SIZE(mflow->reg_id) && mflow->reg_id[i].id) {
+ err = __mlx4_ib_destroy_flow(mdev->dev, mflow->reg_id[i].id);
if (err)
ret = err;
+ if (mflow->reg_id[i].mirror) {
+ err = __mlx4_ib_destroy_flow(mdev->dev,
+ mflow->reg_id[i].mirror);
+ if (err)
+ ret = err;
+ }
i++;
}
@@ -1232,6 +1931,68 @@ static int mlx4_ib_destroy_flow(struct ib_flow *flow_id)
return ret;
}
+static int mlx4_ib_mcg_attach(struct ib_qp *ibqp, union ib_gid *gid, u16 lid)
+{
+ int err;
+ struct mlx4_ib_dev *mdev = to_mdev(ibqp->device);
+ struct mlx4_dev *dev = mdev->dev;
+ struct mlx4_ib_qp *mqp = to_mqp(ibqp);
+ struct mlx4_ib_steering *ib_steering = NULL;
+ enum mlx4_protocol prot = MLX4_PROT_IB_IPV6;
+ struct mlx4_flow_reg_id reg_id;
+
+ if (mdev->dev->caps.steering_mode ==
+ MLX4_STEERING_MODE_DEVICE_MANAGED) {
+ ib_steering = kmalloc(sizeof(*ib_steering), GFP_KERNEL);
+ if (!ib_steering)
+ return -ENOMEM;
+ }
+
+ err = mlx4_multicast_attach(mdev->dev, &mqp->mqp, gid->raw, mqp->port,
+ !!(mqp->flags &
+ MLX4_IB_QP_BLOCK_MULTICAST_LOOPBACK),
+ prot, &reg_id.id);
+ if (err) {
+ pr_err("multicast attach op failed, err %d\n", err);
+ goto err_malloc;
+ }
+
+ reg_id.mirror = 0;
+ if (mlx4_is_bonded(dev)) {
+ err = mlx4_multicast_attach(mdev->dev, &mqp->mqp, gid->raw,
+ (mqp->port == 1) ? 2 : 1,
+ !!(mqp->flags &
+ MLX4_IB_QP_BLOCK_MULTICAST_LOOPBACK),
+ prot, &reg_id.mirror);
+ if (err)
+ goto err_add;
+ }
+
+ err = add_gid_entry(ibqp, gid);
+ if (err)
+ goto err_add;
+
+ if (ib_steering) {
+ memcpy(ib_steering->gid.raw, gid->raw, 16);
+ ib_steering->reg_id = reg_id;
+ mutex_lock(&mqp->mutex);
+ list_add(&ib_steering->list, &mqp->steering_rules);
+ mutex_unlock(&mqp->mutex);
+ }
+ return 0;
+
+err_add:
+ mlx4_multicast_detach(mdev->dev, &mqp->mqp, gid->raw,
+ prot, reg_id.id);
+ if (reg_id.mirror)
+ mlx4_multicast_detach(mdev->dev, &mqp->mqp, gid->raw,
+ prot, reg_id.mirror);
+err_malloc:
+ kfree(ib_steering);
+
+ return err;
+}
+
static struct mlx4_ib_gid_entry *find_gid_entry(struct mlx4_ib_qp *qp, u8 *raw)
{
struct mlx4_ib_gid_entry *ge;
@@ -1248,204 +2009,67 @@ static struct mlx4_ib_gid_entry *find_gid_entry(struct mlx4_ib_qp *qp, u8 *raw)
return ret;
}
-
-static int del_gid_entry(struct ib_qp *ibqp, union ib_gid *gid)
-{
- struct mlx4_ib_dev *mdev = to_mdev(ibqp->device);
- struct mlx4_ib_qp *mqp = to_mqp(ibqp);
- struct mlx4_ib_gid_entry *ge;
- struct net_device *ndev;
- u8 mac[6];
-
- mutex_lock(&mqp->mutex);
- ge = find_gid_entry(mqp, gid->raw);
- if (ge) {
- spin_lock(&mdev->iboe.lock);
- ndev = ge->added ? mdev->iboe.netdevs[ge->port - 1] : NULL;
- if (ndev)
- dev_hold(ndev);
- spin_unlock(&mdev->iboe.lock);
- rdma_get_mcast_mac((struct in6_addr *)gid, mac);
- if (ndev) {
- rtnl_lock();
- dev_mc_delete(mdev->iboe.netdevs[ge->port - 1], mac, 6, 0);
- rtnl_unlock();
- dev_put(ndev);
- }
- list_del(&ge->list);
- kfree(ge);
- } else
- pr_warn("could not find mgid entry\n");
-
- mutex_unlock(&mqp->mutex);
- return ge != NULL ? 0 : -EINVAL;
-}
-
-static int _mlx4_ib_mcg_detach(struct ib_qp *ibqp, union ib_gid *gid, u16 lid,
- int count)
+static int mlx4_ib_mcg_detach(struct ib_qp *ibqp, union ib_gid *gid, u16 lid)
{
int err;
struct mlx4_ib_dev *mdev = to_mdev(ibqp->device);
+ struct mlx4_dev *dev = mdev->dev;
struct mlx4_ib_qp *mqp = to_mqp(ibqp);
- u64 reg_id = 0;
- int record_err = 0;
+ struct net_device *ndev;
+ struct mlx4_ib_gid_entry *ge;
+ struct mlx4_flow_reg_id reg_id = {0, 0};
+ enum mlx4_protocol prot = MLX4_PROT_IB_IPV6;
if (mdev->dev->caps.steering_mode ==
MLX4_STEERING_MODE_DEVICE_MANAGED) {
struct mlx4_ib_steering *ib_steering;
- struct mlx4_ib_steering *tmp;
- LIST_HEAD(temp);
mutex_lock(&mqp->mutex);
- list_for_each_entry_safe(ib_steering, tmp, &mqp->steering_rules,
- list) {
- if (memcmp(ib_steering->gid.raw, gid->raw, 16))
- continue;
-
- if (--count < 0)
+ list_for_each_entry(ib_steering, &mqp->steering_rules, list) {
+ if (!memcmp(ib_steering->gid.raw, gid->raw, 16)) {
+ list_del(&ib_steering->list);
break;
-
- list_del(&ib_steering->list);
- list_add(&ib_steering->list, &temp);
- }
- mutex_unlock(&mqp->mutex);
- list_for_each_entry_safe(ib_steering, tmp, &temp,
- list) {
- reg_id = ib_steering->reg_id;
-
- err = mlx4_multicast_detach(mdev->dev, &mqp->mqp,
- gid->raw,
- (ibqp->qp_type == IB_QPT_RAW_PACKET) ?
- MLX4_PROT_ETH : MLX4_PROT_IB_IPV6,
- reg_id);
- if (err) {
- record_err = record_err ?: err;
- continue;
- }
-
- err = del_gid_entry(ibqp, gid);
- if (err) {
- record_err = record_err ?: err;
- continue;
}
-
- list_del(&ib_steering->list);
- kfree(ib_steering);
- }
- mutex_lock(&mqp->mutex);
- list_for_each_entry(ib_steering, &temp, list) {
- list_add(&ib_steering->list, &mqp->steering_rules);
}
mutex_unlock(&mqp->mutex);
- if (count) {
- pr_warn("Couldn't release all reg_ids for mgid. Steering rule is left attached\n");
+ if (&ib_steering->list == &mqp->steering_rules) {
+ pr_err("Couldn't find reg_id for mgid. Steering rule is left attached\n");
return -EINVAL;
}
+ reg_id = ib_steering->reg_id;
+ kfree(ib_steering);
+ }
- } else {
- if (mdev->dev->caps.steering_mode == MLX4_STEERING_MODE_B0 &&
- ibqp->qp_type == IB_QPT_RAW_PACKET)
- gid->raw[5] = mqp->port;
+ err = mlx4_multicast_detach(mdev->dev, &mqp->mqp, gid->raw,
+ prot, reg_id.id);
+ if (err)
+ return err;
+ if (mlx4_is_bonded(dev)) {
err = mlx4_multicast_detach(mdev->dev, &mqp->mqp, gid->raw,
- (ibqp->qp_type == IB_QPT_RAW_PACKET) ?
- MLX4_PROT_ETH : MLX4_PROT_IB_IPV6,
- reg_id);
+ prot, reg_id.mirror);
if (err)
return err;
-
- err = del_gid_entry(ibqp, gid);
-
- if (err)
- return err;
- }
-
- return record_err;
-}
-
-static int mlx4_ib_mcg_detach(struct ib_qp *ibqp, union ib_gid *gid, u16 lid)
-{
- struct mlx4_ib_dev *mdev = to_mdev(ibqp->device);
- int count = (mdev->dev->caps.steering_mode ==
- MLX4_STEERING_MODE_DEVICE_MANAGED) ?
- mdev->dev->caps.num_ports : 1;
-
- return _mlx4_ib_mcg_detach(ibqp, gid, lid, count);
-}
-
-static int mlx4_ib_mcg_attach(struct ib_qp *ibqp, union ib_gid *gid, u16 lid)
-{
- int err = -ENODEV;
- struct mlx4_ib_dev *mdev = to_mdev(ibqp->device);
- struct mlx4_ib_qp *mqp = to_mqp(ibqp);
- DECLARE_BITMAP(ports, MLX4_MAX_PORTS);
- int i = 0;
-
- if (mdev->dev->caps.steering_mode == MLX4_STEERING_MODE_B0 &&
- ibqp->qp_type == IB_QPT_RAW_PACKET)
- gid->raw[5] = mqp->port;
-
- if (mdev->dev->caps.steering_mode ==
- MLX4_STEERING_MODE_DEVICE_MANAGED) {
- bitmap_fill(ports, mdev->dev->caps.num_ports);
- } else {
- if (mqp->port <= mdev->dev->caps.num_ports) {
- bitmap_zero(ports, mdev->dev->caps.num_ports);
- set_bit(0, ports);
- } else {
- return -EINVAL;
- }
}
- for (; i < mdev->dev->caps.num_ports; i++) {
- u64 reg_id;
- struct mlx4_ib_steering *ib_steering = NULL;
- if (!test_bit(i, ports))
- continue;
- if (mdev->dev->caps.steering_mode ==
- MLX4_STEERING_MODE_DEVICE_MANAGED) {
- ib_steering = kmalloc(sizeof(*ib_steering), GFP_KERNEL);
- if (!ib_steering)
- goto err_add;
- }
-
- err = mlx4_multicast_attach(mdev->dev, &mqp->mqp,
- gid->raw, i + 1,
- !!(mqp->flags &
- MLX4_IB_QP_BLOCK_MULTICAST_LOOPBACK),
- (ibqp->qp_type == IB_QPT_RAW_PACKET) ?
- MLX4_PROT_ETH : MLX4_PROT_IB_IPV6,
- &reg_id);
- if (err) {
- kfree(ib_steering);
- goto err_add;
- }
-
- err = add_gid_entry(ibqp, gid);
- if (err) {
- mlx4_multicast_detach(mdev->dev, &mqp->mqp, gid->raw,
- MLX4_PROT_IB_IPV6, reg_id);
- kfree(ib_steering);
- goto err_add;
- }
-
- if (ib_steering) {
- memcpy(ib_steering->gid.raw, gid->raw, 16);
- mutex_lock(&mqp->mutex);
- list_add(&ib_steering->list, &mqp->steering_rules);
- mutex_unlock(&mqp->mutex);
- ib_steering->reg_id = reg_id;
- }
- }
+ mutex_lock(&mqp->mutex);
+ ge = find_gid_entry(mqp, gid->raw);
+ if (ge) {
+ spin_lock_bh(&mdev->iboe.lock);
+ ndev = ge->added ? mdev->iboe.netdevs[ge->port - 1] : NULL;
+ if (ndev)
+ dev_hold(ndev);
+ spin_unlock_bh(&mdev->iboe.lock);
+ if (ndev)
+ dev_put(ndev);
+ list_del(&ge->list);
+ kfree(ge);
+ } else
+ pr_warn("could not find mgid entry\n");
+ mutex_unlock(&mqp->mutex);
return 0;
-
-err_add:
- if (i > 0)
- _mlx4_ib_mcg_detach(ibqp, gid, lid, i);
-
- return err;
}
static int init_node_data(struct mlx4_ib_dev *dev)
@@ -1469,7 +2093,7 @@ static int init_node_data(struct mlx4_ib_dev *dev)
if (err)
goto out;
- memcpy(dev->ib_dev.node_desc, out_mad->data, 64);
+ memcpy(dev->ib_dev.node_desc, out_mad->data, IB_DEVICE_NODE_DESC_MAX);
in_mad->attr_id = IB_SMP_ATTR_NODE_INFO;
@@ -1494,16 +2118,6 @@ static ssize_t show_hca(struct device *device, struct device_attribute *attr,
return sprintf(buf, "MT%d\n", dev->dev->persist->pdev->device);
}
-static ssize_t show_fw_ver(struct device *device, struct device_attribute *attr,
- char *buf)
-{
- struct mlx4_ib_dev *dev =
- container_of(device, struct mlx4_ib_dev, ib_dev.dev);
- return sprintf(buf, "%d.%d.%d\n", (int) (dev->dev->caps.fw_ver >> 32),
- (int) (dev->dev->caps.fw_ver >> 16) & 0xffff,
- (int) dev->dev->caps.fw_ver & 0xffff);
-}
-
static ssize_t show_rev(struct device *device, struct device_attribute *attr,
char *buf)
{
@@ -1522,391 +2136,307 @@ static ssize_t show_board(struct device *device, struct device_attribute *attr,
}
static DEVICE_ATTR(hw_rev, S_IRUGO, show_rev, NULL);
-static DEVICE_ATTR(fw_ver, S_IRUGO, show_fw_ver, NULL);
static DEVICE_ATTR(hca_type, S_IRUGO, show_hca, NULL);
static DEVICE_ATTR(board_id, S_IRUGO, show_board, NULL);
static struct device_attribute *mlx4_class_attributes[] = {
&dev_attr_hw_rev,
- &dev_attr_fw_ver,
&dev_attr_hca_type,
&dev_attr_board_id
};
-static void mlx4_addrconf_ifid_eui48(u8 *eui, u16 vlan_id, struct net_device *dev, u8 port)
-{
- memcpy(eui, IF_LLADDR(dev), 3);
- memcpy(eui + 5, IF_LLADDR(dev) + 3, 3);
- if (vlan_id < 0x1000) {
- eui[3] = vlan_id >> 8;
- eui[4] = vlan_id & 0xff;
- } else {
- eui[3] = 0xff;
- eui[4] = 0xfe;
- }
- eui[0] ^= 2;
-}
-
-static void update_gids_task(struct work_struct *work)
-{
- struct update_gid_work *gw = container_of(work, struct update_gid_work, work);
- struct mlx4_cmd_mailbox *mailbox;
- union ib_gid *gids;
- int err;
- struct mlx4_dev *dev = gw->dev->dev;
+struct diag_counter {
+ const char *name;
+ u32 offset;
+};
+#define DIAG_COUNTER(_name, _offset) \
+ { .name = #_name, .offset = _offset }
+
+static const struct diag_counter diag_basic[] = {
+ DIAG_COUNTER(rq_num_lle, 0x00),
+ DIAG_COUNTER(sq_num_lle, 0x04),
+ DIAG_COUNTER(rq_num_lqpoe, 0x08),
+ DIAG_COUNTER(sq_num_lqpoe, 0x0C),
+ DIAG_COUNTER(rq_num_lpe, 0x18),
+ DIAG_COUNTER(sq_num_lpe, 0x1C),
+ DIAG_COUNTER(rq_num_wrfe, 0x20),
+ DIAG_COUNTER(sq_num_wrfe, 0x24),
+ DIAG_COUNTER(sq_num_mwbe, 0x2C),
+ DIAG_COUNTER(sq_num_bre, 0x34),
+ DIAG_COUNTER(sq_num_rire, 0x44),
+ DIAG_COUNTER(rq_num_rire, 0x48),
+ DIAG_COUNTER(sq_num_rae, 0x4C),
+ DIAG_COUNTER(rq_num_rae, 0x50),
+ DIAG_COUNTER(sq_num_roe, 0x54),
+ DIAG_COUNTER(sq_num_tree, 0x5C),
+ DIAG_COUNTER(sq_num_rree, 0x64),
+ DIAG_COUNTER(rq_num_rnr, 0x68),
+ DIAG_COUNTER(sq_num_rnr, 0x6C),
+ DIAG_COUNTER(rq_num_oos, 0x100),
+ DIAG_COUNTER(sq_num_oos, 0x104),
+};
- mailbox = mlx4_alloc_cmd_mailbox(dev);
- if (IS_ERR(mailbox)) {
- pr_warn("update gid table failed %ld\n", PTR_ERR(mailbox));
- goto free;
- }
+static const struct diag_counter diag_ext[] = {
+ DIAG_COUNTER(rq_num_dup, 0x130),
+ DIAG_COUNTER(sq_num_to, 0x134),
+};
- gids = mailbox->buf;
- memcpy(gids, gw->gids, sizeof gw->gids);
+static const struct diag_counter diag_device_only[] = {
+ DIAG_COUNTER(num_cqovf, 0x1A0),
+ DIAG_COUNTER(rq_num_udsdprd, 0x118),
+};
- if (mlx4_ib_port_link_layer(&gw->dev->ib_dev, gw->port) ==
- IB_LINK_LAYER_ETHERNET) {
- err = mlx4_cmd(dev, mailbox->dma,
- MLX4_SET_PORT_GID_TABLE << 8 | gw->port,
- 1, MLX4_CMD_SET_PORT, MLX4_CMD_TIME_CLASS_B,
- MLX4_CMD_WRAPPED);
+static struct rdma_hw_stats *mlx4_ib_alloc_hw_stats(struct ib_device *ibdev,
+ u8 port_num)
+{
+ struct mlx4_ib_dev *dev = to_mdev(ibdev);
+ struct mlx4_ib_diag_counters *diag = dev->diag_counters;
- if (err)
- pr_warn("set port command failed\n");
- else
- mlx4_ib_dispatch_event(gw->dev, gw->port,
- IB_EVENT_GID_CHANGE);
- }
+ if (!diag[!!port_num].name)
+ return NULL;
- mlx4_free_cmd_mailbox(dev, mailbox);
-free:
- kfree(gw);
+ return rdma_alloc_hw_stats_struct(diag[!!port_num].name,
+ diag[!!port_num].num_counters,
+ RDMA_HW_STATS_DEFAULT_LIFESPAN);
}
-static struct net_device *mlx4_ib_get_netdev(struct ib_device *device, u8 port_num)
+static int mlx4_ib_get_hw_stats(struct ib_device *ibdev,
+ struct rdma_hw_stats *stats,
+ u8 port, int index)
{
- struct mlx4_ib_dev *ibdev = to_mdev(device);
- return mlx4_get_protocol_dev(ibdev->dev, MLX4_PROT_ETH, port_num);
+ struct mlx4_ib_dev *dev = to_mdev(ibdev);
+ struct mlx4_ib_diag_counters *diag = dev->diag_counters;
+ u32 hw_value[ARRAY_SIZE(diag_device_only) +
+ ARRAY_SIZE(diag_ext) + ARRAY_SIZE(diag_basic)] = {};
+ int ret;
+ int i;
+
+ ret = mlx4_query_diag_counters(dev->dev,
+ MLX4_OP_MOD_QUERY_TRANSPORT_CI_ERRORS,
+ diag[!!port].offset, hw_value,
+ diag[!!port].num_counters, port);
+
+ if (ret)
+ return ret;
+
+ for (i = 0; i < diag[!!port].num_counters; i++)
+ stats->value[i] = hw_value[i];
+
+ return diag[!!port].num_counters;
}
-static void reset_gids_task(struct work_struct *work)
+static int __mlx4_ib_alloc_diag_counters(struct mlx4_ib_dev *ibdev,
+ const char ***name,
+ u32 **offset,
+ u32 *num,
+ bool port)
{
- struct update_gid_work *gw =
- container_of(work, struct update_gid_work, work);
- struct mlx4_cmd_mailbox *mailbox;
- union ib_gid *gids;
- int err;
- struct mlx4_dev *dev = gw->dev->dev;
+ u32 num_counters;
- mailbox = mlx4_alloc_cmd_mailbox(dev);
- if (IS_ERR(mailbox)) {
- pr_warn("reset gid table failed\n");
- goto free;
- }
+ num_counters = ARRAY_SIZE(diag_basic);
- gids = mailbox->buf;
- memcpy(gids, gw->gids, sizeof(gw->gids));
+ if (ibdev->dev->caps.flags2 & MLX4_DEV_CAP_FLAG2_DIAG_PER_PORT)
+ num_counters += ARRAY_SIZE(diag_ext);
- if (mlx4_ib_port_link_layer(&gw->dev->ib_dev, 1) ==
- IB_LINK_LAYER_ETHERNET &&
- dev->caps.num_ports > 0) {
- err = mlx4_cmd(dev, mailbox->dma,
- MLX4_SET_PORT_GID_TABLE << 8 | 1,
- 1, MLX4_CMD_SET_PORT, MLX4_CMD_TIME_CLASS_B,
- MLX4_CMD_WRAPPED);
- if (err)
- pr_warn("set port 1 command failed\n");
- }
+ if (!port)
+ num_counters += ARRAY_SIZE(diag_device_only);
- if (mlx4_ib_port_link_layer(&gw->dev->ib_dev, 2) ==
- IB_LINK_LAYER_ETHERNET &&
- dev->caps.num_ports > 1) {
- err = mlx4_cmd(dev, mailbox->dma,
- MLX4_SET_PORT_GID_TABLE << 8 | 2,
- 1, MLX4_CMD_SET_PORT, MLX4_CMD_TIME_CLASS_B,
- MLX4_CMD_WRAPPED);
- if (err)
- pr_warn("set port 2 command failed\n");
- }
+ *name = kcalloc(num_counters, sizeof(**name), GFP_KERNEL);
+ if (!*name)
+ return -ENOMEM;
- mlx4_free_cmd_mailbox(dev, mailbox);
-free:
- kfree(gw);
+ *offset = kcalloc(num_counters, sizeof(**offset), GFP_KERNEL);
+ if (!*offset)
+ goto err_name;
+
+ *num = num_counters;
+
+ return 0;
+
+err_name:
+ kfree(*name);
+ return -ENOMEM;
}
-static int update_gid_table(struct mlx4_ib_dev *dev, int port,
- union ib_gid *gid, int clear, int default_gid)
+static void mlx4_ib_fill_diag_counters(struct mlx4_ib_dev *ibdev,
+ const char **name,
+ u32 *offset,
+ bool port)
{
- struct update_gid_work *work;
int i;
- int need_update = 0;
- int free = -1;
- int found = -1;
- int max_gids;
- int start_index = !default_gid;
-
- max_gids = dev->dev->caps.gid_table_len[port];
- for (i = start_index; i < max_gids; ++i) {
- if (!memcmp(&dev->iboe.gid_table[port - 1][i], gid,
- sizeof(*gid)))
- found = i;
+ int j;
- if (clear) {
- if (found >= 0) {
- need_update = 1;
- dev->iboe.gid_table[port - 1][found] = zgid;
- break;
- }
- } else {
- if (found >= 0)
- break;
+ for (i = 0, j = 0; i < ARRAY_SIZE(diag_basic); i++, j++) {
+ name[i] = diag_basic[i].name;
+ offset[i] = diag_basic[i].offset;
+ }
- if (free < 0 &&
- !memcmp(&dev->iboe.gid_table[port - 1][i],
- &zgid, sizeof(*gid)))
- free = i;
+ if (ibdev->dev->caps.flags2 & MLX4_DEV_CAP_FLAG2_DIAG_PER_PORT) {
+ for (i = 0; i < ARRAY_SIZE(diag_ext); i++, j++) {
+ name[j] = diag_ext[i].name;
+ offset[j] = diag_ext[i].offset;
}
}
- if (found == -1 && !clear && free < 0) {
- pr_err("GID table of port %d is full. Can't add "GID_PRINT_FMT"\n",
- port, GID_PRINT_ARGS(gid));
- return -ENOMEM;
- }
- if (found == -1 && clear) {
- pr_err(GID_PRINT_FMT" is not in GID table of port %d\n", GID_PRINT_ARGS(gid), port);
- return -EINVAL;
- }
- if (found == -1 && !clear && free >= 0) {
- dev->iboe.gid_table[port - 1][free] = *gid;
- need_update = 1;
+ if (!port) {
+ for (i = 0; i < ARRAY_SIZE(diag_device_only); i++, j++) {
+ name[j] = diag_device_only[i].name;
+ offset[j] = diag_device_only[i].offset;
+ }
}
+}
- if (!need_update)
- return 0;
-
- work = kzalloc(sizeof *work, GFP_ATOMIC);
- if (!work)
- return -ENOMEM;
+static int mlx4_ib_alloc_diag_counters(struct mlx4_ib_dev *ibdev)
+{
+ struct mlx4_ib_diag_counters *diag = ibdev->diag_counters;
+ int i;
+ int ret;
+ bool per_port = !!(ibdev->dev->caps.flags2 &
+ MLX4_DEV_CAP_FLAG2_DIAG_PER_PORT);
- memcpy(work->gids, dev->iboe.gid_table[port - 1], sizeof(work->gids));
- INIT_WORK(&work->work, update_gids_task);
- work->port = port;
- work->dev = dev;
- queue_work(wq, &work->work);
+ if (mlx4_is_slave(ibdev->dev))
+ return 0;
- return 0;
-}
+ for (i = 0; i < MLX4_DIAG_COUNTERS_TYPES; i++) {
+ /* i == 1 means we are building port counters */
+ if (i && !per_port)
+ continue;
-static int reset_gid_table(struct mlx4_ib_dev *dev)
-{
- struct update_gid_work *work;
+ ret = __mlx4_ib_alloc_diag_counters(ibdev, &diag[i].name,
+ &diag[i].offset,
+ &diag[i].num_counters, i);
+ if (ret)
+ goto err_alloc;
+ mlx4_ib_fill_diag_counters(ibdev, diag[i].name,
+ diag[i].offset, i);
+ }
- work = kzalloc(sizeof(*work), GFP_ATOMIC);
- if (!work)
- return -ENOMEM;
+ ibdev->ib_dev.get_hw_stats = mlx4_ib_get_hw_stats;
+ ibdev->ib_dev.alloc_hw_stats = mlx4_ib_alloc_hw_stats;
- memset(dev->iboe.gid_table, 0, sizeof(dev->iboe.gid_table));
- memset(work->gids, 0, sizeof(work->gids));
- INIT_WORK(&work->work, reset_gids_task);
- work->dev = dev;
- queue_work(wq, &work->work);
return 0;
-}
-/* XXX BOND Related - stub (no support for these flags in FBSD)*/
-static inline int netif_is_bond_master(struct net_device *dev)
-{
-#if 0
- return (dev->flags & IFF_MASTER) && (dev->priv_flags & IFF_BONDING);
-#endif
- return 0;
-}
+err_alloc:
+ if (i) {
+ kfree(diag[i - 1].name);
+ kfree(diag[i - 1].offset);
+ }
-static void mlx4_make_default_gid(struct net_device *dev, union ib_gid *gid, u8 port)
-{
- gid->global.subnet_prefix = cpu_to_be64(0xfe80000000000000LL);
- mlx4_addrconf_ifid_eui48(&gid->raw[8], 0xffff, dev, port);
+ return ret;
}
-static u8 mlx4_ib_get_dev_port(struct net_device *dev, struct mlx4_ib_dev *ibdev)
+static void mlx4_ib_diag_cleanup(struct mlx4_ib_dev *ibdev)
{
- u8 port = 0;
- struct mlx4_ib_iboe *iboe;
- struct net_device *real_dev = rdma_vlan_dev_real_dev(dev) ?
- rdma_vlan_dev_real_dev(dev) : dev;
-
- iboe = &ibdev->iboe;
-
- for (port = 1; port <= MLX4_MAX_PORTS; ++port)
- if ((netif_is_bond_master(real_dev) && (real_dev == iboe->masters[port - 1])) ||
- (!netif_is_bond_master(real_dev) && (real_dev == iboe->netdevs[port - 1])))
- break;
+ int i;
- return port > MLX4_MAX_PORTS ? 0 : port;
+ for (i = 0; i < MLX4_DIAG_COUNTERS_TYPES; i++) {
+ kfree(ibdev->diag_counters[i].offset);
+ kfree(ibdev->diag_counters[i].name);
+ }
}
-static void mlx4_ib_get_dev_addr(struct net_device *dev, struct mlx4_ib_dev *ibdev, u8 port)
+#define MLX4_IB_INVALID_MAC ((u64)-1)
+static void mlx4_ib_update_qps(struct mlx4_ib_dev *ibdev,
+ struct net_device *dev,
+ int port)
{
- struct ifaddr *ifa;
-#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
- struct inet6_dev *in6_dev;
- union ib_gid *pgid;
- struct inet6_ifaddr *ifp;
-#endif
- union ib_gid gid;
+ u64 new_smac = 0;
+ u64 release_mac = MLX4_IB_INVALID_MAC;
+ struct mlx4_ib_qp *qp;
+
+ new_smac = mlx4_mac_to_u64(IF_LLADDR(dev));
+ atomic64_set(&ibdev->iboe.mac[port - 1], new_smac);
- if ((port == 0) || (port > MLX4_MAX_PORTS))
+ /* no need for update QP1 and mac registration in non-SRIOV */
+ if (!mlx4_is_mfunc(ibdev->dev))
return;
- /* IPv4 gids */
- TAILQ_FOREACH(ifa, &dev->if_addrhead, ifa_link) {
- if (ifa->ifa_addr && ifa->ifa_addr->sa_family == AF_INET){
- ipv6_addr_set_v4mapped(
- ((struct sockaddr_in *) ifa->ifa_addr)->sin_addr.s_addr,
- (struct in6_addr *)&gid);
- update_gid_table(ibdev, port, &gid, 0, 0);
- }
-
- }
-#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
- /* IPv6 gids */
- in6_dev = in6_dev_get(dev);
- if (in6_dev) {
- read_lock_bh(&in6_dev->lock);
- list_for_each_entry(ifp, &in6_dev->addr_list, if_list) {
- pgid = (union ib_gid *)&ifp->addr;
- update_gid_table(ibdev, port, pgid, 0, 0);
- }
- read_unlock_bh(&in6_dev->lock);
- in6_dev_put(in6_dev);
- }
-#endif
-}
+ mutex_lock(&ibdev->qp1_proxy_lock[port - 1]);
+ qp = ibdev->qp1_proxy[port - 1];
+ if (qp) {
+ int new_smac_index;
+ u64 old_smac;
+ struct mlx4_update_qp_params update_params;
-static void mlx4_set_default_gid(struct mlx4_ib_dev *ibdev,
- struct net_device *dev, u8 port)
-{
- union ib_gid gid;
- mlx4_make_default_gid(dev, &gid, port);
- update_gid_table(ibdev, port, &gid, 0, 1);
-}
+ mutex_lock(&qp->mutex);
+ old_smac = qp->pri.smac;
+ if (new_smac == old_smac)
+ goto unlock;
-static int mlx4_ib_init_gid_table(struct mlx4_ib_dev *ibdev)
-{
- struct net_device *dev;
+ new_smac_index = mlx4_register_mac(ibdev->dev, port, new_smac);
- if (reset_gid_table(ibdev))
- return -1;
+ if (new_smac_index < 0)
+ goto unlock;
- IFNET_RLOCK_NOSLEEP();
- TAILQ_FOREACH(dev, &V_ifnet, if_link) {
- u8 port = mlx4_ib_get_dev_port(dev, ibdev);
- if (port) {
- if (!rdma_vlan_dev_real_dev(dev) &&
- !netif_is_bond_master(dev))
- mlx4_set_default_gid(ibdev, dev, port);
- mlx4_ib_get_dev_addr(dev, ibdev, port);
+ update_params.smac_index = new_smac_index;
+ if (mlx4_update_qp(ibdev->dev, qp->mqp.qpn, MLX4_UPDATE_QP_SMAC,
+ &update_params)) {
+ release_mac = new_smac;
+ goto unlock;
}
+ /* if old port was zero, no mac was yet registered for this QP */
+ if (qp->pri.smac_port)
+ release_mac = old_smac;
+ qp->pri.smac = new_smac;
+ qp->pri.smac_port = port;
+ qp->pri.smac_index = new_smac_index;
}
- IFNET_RUNLOCK_NOSLEEP();
-
- return 0;
+unlock:
+ if (release_mac != MLX4_IB_INVALID_MAC)
+ mlx4_unregister_mac(ibdev->dev, port, release_mac);
+ if (qp)
+ mutex_unlock(&qp->mutex);
+ mutex_unlock(&ibdev->qp1_proxy_lock[port - 1]);
}
static void mlx4_ib_scan_netdevs(struct mlx4_ib_dev *ibdev,
- struct net_device *dev, unsigned long event)
+ struct net_device *dev,
+ unsigned long event)
+
{
struct mlx4_ib_iboe *iboe;
+ int update_qps_port = -1;
int port;
- int init = 0;
- unsigned long flags;
iboe = &ibdev->iboe;
- spin_lock_irqsave(&iboe->lock, flags);
+ spin_lock_bh(&iboe->lock);
mlx4_foreach_ib_transport_port(port, ibdev->dev) {
- struct net_device *old_netdev = iboe->netdevs[port - 1];
-/* XXX BOND related */
-#if 0
- struct net_device *old_master = iboe->masters[port - 1];
-#endif
- iboe->masters[port - 1] = NULL;
+
iboe->netdevs[port - 1] =
mlx4_get_protocol_dev(ibdev->dev, MLX4_PROT_ETH, port);
-
- if (old_netdev != iboe->netdevs[port - 1])
- init = 1;
if (dev == iboe->netdevs[port - 1] &&
- event == NETDEV_CHANGEADDR)
- init = 1;
-/* XXX BOND related */
-#if 0
- if (iboe->netdevs[port - 1] && netif_is_bond_slave(iboe->netdevs[port - 1]))
- iboe->masters[port - 1] = iboe->netdevs[port - 1]->master;
+ (event == NETDEV_CHANGEADDR || event == NETDEV_REGISTER ||
+ event == NETDEV_UP || event == NETDEV_CHANGE))
+ update_qps_port = port;
- /* if bonding is used it is possible that we add it to masters only after
- IP address is assigned to the net bonding interface */
- if (old_master != iboe->masters[port - 1])
- init = 1;
-#endif
}
+ spin_unlock_bh(&iboe->lock);
- spin_unlock_irqrestore(&iboe->lock, flags);
-
- if (init)
- if (mlx4_ib_init_gid_table(ibdev))
- pr_warn("Fail to reset gid table\n");
+ if (update_qps_port > 0)
+ mlx4_ib_update_qps(ibdev, dev, update_qps_port);
}
-static int mlx4_ib_netdev_event(struct notifier_block *this, unsigned long event,
- void *ptr)
+static int mlx4_ib_netdev_event(struct notifier_block *this,
+ unsigned long event, void *ptr)
{
- struct net_device *dev = ptr;
+ struct net_device *dev = netdev_notifier_info_to_dev(ptr);
struct mlx4_ib_dev *ibdev;
- ibdev = container_of(this, struct mlx4_ib_dev, iboe.nb);
+ if (!net_eq(dev_net(dev), &init_net))
+ return NOTIFY_DONE;
+ ibdev = container_of(this, struct mlx4_ib_dev, iboe.nb);
mlx4_ib_scan_netdevs(ibdev, dev, event);
return NOTIFY_DONE;
}
-/* This function initializes the gid table only if the event_netdev real device is an iboe
- * device, will be invoked by the inet/inet6 events */
-static int mlx4_ib_inet_event(struct notifier_block *this, unsigned long event,
- void *ptr)
-{
- struct net_device *event_netdev = ptr;
- struct mlx4_ib_dev *ibdev;
- struct mlx4_ib_iboe *ibdev_iboe;
- int port = 0;
-
- ibdev = container_of(this, struct mlx4_ib_dev, iboe.nb_inet);
-
- struct net_device *real_dev = rdma_vlan_dev_real_dev(event_netdev) ?
- rdma_vlan_dev_real_dev(event_netdev) :
- event_netdev;
-
- ibdev_iboe = &ibdev->iboe;
-
- port = mlx4_ib_get_dev_port(real_dev, ibdev);
-
- /* Perform init_gid_table if the event real_dev is the net_device which represents this port,
- * otherwise this event is not related and would be ignored.*/
- if(port && (real_dev == ibdev_iboe->netdevs[port - 1]))
- if (mlx4_ib_init_gid_table(ibdev))
- pr_warn("Fail to reset gid table\n");
-
- return NOTIFY_DONE;
-}
-
-
static void init_pkeys(struct mlx4_ib_dev *ibdev)
{
int port;
@@ -1990,122 +2520,6 @@ static void mlx4_ib_free_eqs(struct mlx4_dev *dev, struct mlx4_ib_dev *ibdev)
ibdev->eq_table = NULL;
}
-/*
- * create show function and a device_attribute struct pointing to
- * the function for _name
- */
-#define DEVICE_DIAG_RPRT_ATTR(_name, _offset, _op_mod) \
-static ssize_t show_rprt_##_name(struct device *dev, \
- struct device_attribute *attr, \
- char *buf){ \
- return show_diag_rprt(dev, buf, _offset, _op_mod); \
-} \
-static DEVICE_ATTR(_name, S_IRUGO, show_rprt_##_name, NULL);
-
-#define MLX4_DIAG_RPRT_CLEAR_DIAGS 3
-
-static size_t show_diag_rprt(struct device *device, char *buf,
- u32 offset, u8 op_modifier)
-{
- size_t ret;
- u32 counter_offset = offset;
- u32 diag_counter = 0;
- struct mlx4_ib_dev *dev = container_of(device, struct mlx4_ib_dev,
- ib_dev.dev);
-
- ret = mlx4_query_diag_counters(dev->dev, op_modifier,
- &counter_offset, &diag_counter, 1, 0);
- if (ret)
- return ret;
-
- return sprintf(buf, "%d\n", diag_counter);
-}
-
-static ssize_t clear_diag_counters(struct device *device,
- struct device_attribute *attr,
- const char *buf, size_t length)
-{
- size_t ret;
- struct mlx4_ib_dev *dev = container_of(device, struct mlx4_ib_dev,
- ib_dev.dev);
-
- ret = mlx4_query_diag_counters(dev->dev, MLX4_DIAG_RPRT_CLEAR_DIAGS,
- NULL, NULL, 0, 0);
- if (ret)
- return ret;
-
- return length;
-}
-
-DEVICE_DIAG_RPRT_ATTR(rq_num_lle , 0x00, 2);
-DEVICE_DIAG_RPRT_ATTR(sq_num_lle , 0x04, 2);
-DEVICE_DIAG_RPRT_ATTR(rq_num_lqpoe , 0x08, 2);
-DEVICE_DIAG_RPRT_ATTR(sq_num_lqpoe , 0x0C, 2);
-DEVICE_DIAG_RPRT_ATTR(rq_num_lpe , 0x18, 2);
-DEVICE_DIAG_RPRT_ATTR(sq_num_lpe , 0x1C, 2);
-DEVICE_DIAG_RPRT_ATTR(rq_num_wrfe , 0x20, 2);
-DEVICE_DIAG_RPRT_ATTR(sq_num_wrfe , 0x24, 2);
-DEVICE_DIAG_RPRT_ATTR(sq_num_mwbe , 0x2C, 2);
-DEVICE_DIAG_RPRT_ATTR(sq_num_bre , 0x34, 2);
-DEVICE_DIAG_RPRT_ATTR(rq_num_lae , 0x38, 2);
-DEVICE_DIAG_RPRT_ATTR(sq_num_rire , 0x44, 2);
-DEVICE_DIAG_RPRT_ATTR(rq_num_rire , 0x48, 2);
-DEVICE_DIAG_RPRT_ATTR(sq_num_rae , 0x4C, 2);
-DEVICE_DIAG_RPRT_ATTR(rq_num_rae , 0x50, 2);
-DEVICE_DIAG_RPRT_ATTR(sq_num_roe , 0x54, 2);
-DEVICE_DIAG_RPRT_ATTR(sq_num_tree , 0x5C, 2);
-DEVICE_DIAG_RPRT_ATTR(sq_num_rree , 0x64, 2);
-DEVICE_DIAG_RPRT_ATTR(rq_num_rnr , 0x68, 2);
-DEVICE_DIAG_RPRT_ATTR(sq_num_rnr , 0x6C, 2);
-DEVICE_DIAG_RPRT_ATTR(rq_num_oos , 0x100, 2);
-DEVICE_DIAG_RPRT_ATTR(sq_num_oos , 0x104, 2);
-DEVICE_DIAG_RPRT_ATTR(rq_num_mce , 0x108, 2);
-DEVICE_DIAG_RPRT_ATTR(rq_num_udsdprd , 0x118, 2);
-DEVICE_DIAG_RPRT_ATTR(rq_num_ucsdprd , 0x120, 2);
-DEVICE_DIAG_RPRT_ATTR(num_cqovf , 0x1A0, 2);
-DEVICE_DIAG_RPRT_ATTR(num_eqovf , 0x1A4, 2);
-DEVICE_DIAG_RPRT_ATTR(num_baddb , 0x1A8, 2);
-
-static DEVICE_ATTR(clear_diag, S_IWUSR, NULL, clear_diag_counters);
-
-static struct attribute *diag_rprt_attrs[] = {
- &dev_attr_rq_num_lle.attr,
- &dev_attr_sq_num_lle.attr,
- &dev_attr_rq_num_lqpoe.attr,
- &dev_attr_sq_num_lqpoe.attr,
- &dev_attr_rq_num_lpe.attr,
- &dev_attr_sq_num_lpe.attr,
- &dev_attr_rq_num_wrfe.attr,
- &dev_attr_sq_num_wrfe.attr,
- &dev_attr_sq_num_mwbe.attr,
- &dev_attr_sq_num_bre.attr,
- &dev_attr_rq_num_lae.attr,
- &dev_attr_sq_num_rire.attr,
- &dev_attr_rq_num_rire.attr,
- &dev_attr_sq_num_rae.attr,
- &dev_attr_rq_num_rae.attr,
- &dev_attr_sq_num_roe.attr,
- &dev_attr_sq_num_tree.attr,
- &dev_attr_sq_num_rree.attr,
- &dev_attr_rq_num_rnr.attr,
- &dev_attr_sq_num_rnr.attr,
- &dev_attr_rq_num_oos.attr,
- &dev_attr_sq_num_oos.attr,
- &dev_attr_rq_num_mce.attr,
- &dev_attr_rq_num_udsdprd.attr,
- &dev_attr_rq_num_ucsdprd.attr,
- &dev_attr_num_cqovf.attr,
- &dev_attr_num_eqovf.attr,
- &dev_attr_num_baddb.attr,
- &dev_attr_clear_diag.attr,
- NULL
-};
-
-static struct attribute_group diag_counters_group = {
- .name = "diag_counters",
- .attrs = diag_rprt_attrs
-};
-
static int mlx4_port_immutable(struct ib_device *ibdev, u8 port_num,
struct ib_port_immutable *immutable)
{
@@ -2113,41 +2527,55 @@ static int mlx4_port_immutable(struct ib_device *ibdev, u8 port_num,
struct mlx4_ib_dev *mdev = to_mdev(ibdev);
int err;
+ err = mlx4_ib_query_port(ibdev, port_num, &attr);
+ if (err)
+ return err;
+
+ immutable->pkey_tbl_len = attr.pkey_tbl_len;
+ immutable->gid_tbl_len = attr.gid_tbl_len;
+
if (mlx4_ib_port_link_layer(ibdev, port_num) == IB_LINK_LAYER_INFINIBAND) {
immutable->core_cap_flags = RDMA_CORE_PORT_IBA_IB;
- immutable->max_mad_size = IB_MGMT_MAD_SIZE;
} else {
if (mdev->dev->caps.flags & MLX4_DEV_CAP_FLAG_IBOE)
immutable->core_cap_flags = RDMA_CORE_PORT_IBA_ROCE;
if (mdev->dev->caps.flags2 & MLX4_DEV_CAP_FLAG2_ROCE_V1_V2)
immutable->core_cap_flags = RDMA_CORE_PORT_IBA_ROCE |
RDMA_CORE_PORT_IBA_ROCE_UDP_ENCAP;
- immutable->core_cap_flags |= RDMA_CORE_PORT_RAW_PACKET;
- if (immutable->core_cap_flags & (RDMA_CORE_PORT_IBA_ROCE |
- RDMA_CORE_PORT_IBA_ROCE_UDP_ENCAP))
- immutable->max_mad_size = IB_MGMT_MAD_SIZE;
}
- err = ib_query_port(ibdev, port_num, &attr);
- if (err)
- return err;
-
- immutable->pkey_tbl_len = attr.pkey_tbl_len;
- immutable->gid_tbl_len = attr.gid_tbl_len;
+ immutable->max_mad_size = IB_MGMT_MAD_SIZE;
return 0;
}
+static void get_fw_ver_str(struct ib_device *device, char *str,
+ size_t str_len)
+{
+ struct mlx4_ib_dev *dev =
+ container_of(device, struct mlx4_ib_dev, ib_dev);
+ snprintf(str, str_len, "%d.%d.%d",
+ (int) (dev->dev->caps.fw_ver >> 32),
+ (int) (dev->dev->caps.fw_ver >> 16) & 0xffff,
+ (int) dev->dev->caps.fw_ver & 0xffff);
+}
+
static void *mlx4_ib_add(struct mlx4_dev *dev)
{
struct mlx4_ib_dev *ibdev;
- int num_ports = 0;
+ int num_ports;
int i, j;
int err;
struct mlx4_ib_iboe *iboe;
+ int ib_num_ports = 0;
+ int num_req_counters;
+ int allocated;
+ u32 counter_index;
+ struct counter_index *new_counter_index = NULL;
- pr_info_once("%s", mlx4_ib_version);
+ pr_info_once("%s", mlx4_ib_version);
+ num_ports = 0;
mlx4_foreach_ib_transport_port(i, dev)
num_ports++;
@@ -2170,25 +2598,27 @@ static void *mlx4_ib_add(struct mlx4_dev *dev)
if (mlx4_uar_alloc(dev, &ibdev->priv_uar))
goto err_pd;
- ibdev->priv_uar.map = ioremap(ibdev->priv_uar.pfn << PAGE_SHIFT,
- PAGE_SIZE);
-
- if (!ibdev->priv_uar.map)
+ ibdev->uar_map = ioremap((phys_addr_t) ibdev->priv_uar.pfn << PAGE_SHIFT,
+ PAGE_SIZE);
+ if (!ibdev->uar_map)
goto err_uar;
-
MLX4_INIT_DOORBELL_LOCK(&ibdev->uar_lock);
ibdev->dev = dev;
+ ibdev->bond_next_port = 0;
strlcpy(ibdev->ib_dev.name, "mlx4_%d", IB_DEVICE_NAME_MAX);
-
ibdev->ib_dev.owner = THIS_MODULE;
ibdev->ib_dev.node_type = RDMA_NODE_IB_CA;
ibdev->ib_dev.local_dma_lkey = dev->caps.reserved_lkey;
ibdev->num_ports = num_ports;
- ibdev->ib_dev.phys_port_cnt = ibdev->num_ports;
+ ibdev->ib_dev.phys_port_cnt = mlx4_is_bonded(dev) ?
+ 1 : ibdev->num_ports;
ibdev->ib_dev.num_comp_vectors = dev->caps.num_comp_vectors;
ibdev->ib_dev.dma_device = &dev->persist->pdev->dev;
+ ibdev->ib_dev.get_netdev = mlx4_ib_get_netdev;
+ ibdev->ib_dev.add_gid = mlx4_ib_add_gid;
+ ibdev->ib_dev.del_gid = mlx4_ib_del_gid;
if (dev->caps.userspace_caps)
ibdev->ib_dev.uverbs_abi_ver = MLX4_IB_UVERBS_ABI_VERSION;
@@ -2202,6 +2632,7 @@ static void *mlx4_ib_add(struct mlx4_dev *dev)
(1ull << IB_USER_VERBS_CMD_ALLOC_PD) |
(1ull << IB_USER_VERBS_CMD_DEALLOC_PD) |
(1ull << IB_USER_VERBS_CMD_REG_MR) |
+ (1ull << IB_USER_VERBS_CMD_REREG_MR) |
(1ull << IB_USER_VERBS_CMD_DEREG_MR) |
(1ull << IB_USER_VERBS_CMD_CREATE_COMP_CHANNEL) |
(1ull << IB_USER_VERBS_CMD_CREATE_CQ) |
@@ -2230,10 +2661,6 @@ static void *mlx4_ib_add(struct mlx4_dev *dev)
ibdev->ib_dev.alloc_ucontext = mlx4_ib_alloc_ucontext;
ibdev->ib_dev.dealloc_ucontext = mlx4_ib_dealloc_ucontext;
ibdev->ib_dev.mmap = mlx4_ib_mmap;
-/* XXX FBSD has no support for get_unmapped_area function */
-#if 0
- ibdev->ib_dev.get_unmapped_area = mlx4_ib_get_unmapped_area;
-#endif
ibdev->ib_dev.alloc_pd = mlx4_ib_alloc_pd;
ibdev->ib_dev.dealloc_pd = mlx4_ib_dealloc_pd;
ibdev->ib_dev.create_ah = mlx4_ib_create_ah;
@@ -2258,17 +2685,17 @@ static void *mlx4_ib_add(struct mlx4_dev *dev)
ibdev->ib_dev.req_notify_cq = mlx4_ib_arm_cq;
ibdev->ib_dev.get_dma_mr = mlx4_ib_get_dma_mr;
ibdev->ib_dev.reg_user_mr = mlx4_ib_reg_user_mr;
+ ibdev->ib_dev.rereg_user_mr = mlx4_ib_rereg_user_mr;
+ ibdev->ib_dev.reg_phys_mr = mlx4_ib_reg_phys_mr;
ibdev->ib_dev.dereg_mr = mlx4_ib_dereg_mr;
- ibdev->ib_dev.alloc_fast_reg_mr = mlx4_ib_alloc_fast_reg_mr;
- ibdev->ib_dev.alloc_fast_reg_page_list = mlx4_ib_alloc_fast_reg_page_list;
- ibdev->ib_dev.free_fast_reg_page_list = mlx4_ib_free_fast_reg_page_list;
+ ibdev->ib_dev.alloc_mr = mlx4_ib_alloc_mr;
+ ibdev->ib_dev.map_mr_sg = mlx4_ib_map_mr_sg;
ibdev->ib_dev.attach_mcast = mlx4_ib_mcg_attach;
ibdev->ib_dev.detach_mcast = mlx4_ib_mcg_detach;
ibdev->ib_dev.process_mad = mlx4_ib_process_mad;
ibdev->ib_dev.get_port_immutable = mlx4_port_immutable;
- ibdev->ib_dev.get_netdev = mlx4_ib_get_netdev;
- ibdev->ib_dev.ioctl = mlx4_ib_ioctl;
- ibdev->ib_dev.query_values = mlx4_ib_query_values;
+ ibdev->ib_dev.get_dev_fw_str = get_fw_ver_str;
+ ibdev->ib_dev.disassociate_ucontext = mlx4_ib_disassociate_ucontext;
if (!mlx4_is_slave(ibdev->dev)) {
ibdev->ib_dev.alloc_fmr = mlx4_ib_fmr_alloc;
@@ -2277,9 +2704,9 @@ static void *mlx4_ib_add(struct mlx4_dev *dev)
ibdev->ib_dev.dealloc_fmr = mlx4_ib_fmr_dealloc;
}
- if (dev->caps.flags & MLX4_DEV_CAP_FLAG_MEM_WINDOW) {
+ if (dev->caps.flags & MLX4_DEV_CAP_FLAG_MEM_WINDOW ||
+ dev->caps.bmme_flags & MLX4_BMME_FLAG_TYPE_2_WIN) {
ibdev->ib_dev.alloc_mw = mlx4_ib_alloc_mw;
- ibdev->ib_dev.bind_mw = mlx4_ib_bind_mw;
ibdev->ib_dev.dealloc_mw = mlx4_ib_dealloc_mw;
ibdev->ib_dev.uverbs_cmd_mask |=
@@ -2295,28 +2722,20 @@ static void *mlx4_ib_add(struct mlx4_dev *dev)
(1ull << IB_USER_VERBS_CMD_CLOSE_XRCD);
}
- /*
- * Set experimental data
- */
- ibdev->ib_dev.uverbs_exp_cmd_mask =
- (1ull << IB_USER_VERBS_EXP_CMD_CREATE_QP) |
- (1ull << IB_USER_VERBS_EXP_CMD_MODIFY_CQ) |
- (1ull << IB_USER_VERBS_EXP_CMD_QUERY_DEVICE) |
- (1ull << IB_USER_VERBS_EXP_CMD_CREATE_CQ);
- ibdev->ib_dev.exp_create_qp = mlx4_ib_exp_create_qp;
- ibdev->ib_dev.exp_query_device = mlx4_ib_exp_query_device;
if (check_flow_steering_support(dev)) {
+ ibdev->steering_support = MLX4_STEERING_MODE_DEVICE_MANAGED;
+ ibdev->ib_dev.create_flow = mlx4_ib_create_flow;
+ ibdev->ib_dev.destroy_flow = mlx4_ib_destroy_flow;
+
ibdev->ib_dev.uverbs_ex_cmd_mask |=
(1ull << IB_USER_VERBS_EX_CMD_CREATE_FLOW) |
(1ull << IB_USER_VERBS_EX_CMD_DESTROY_FLOW);
- ibdev->ib_dev.create_flow = mlx4_ib_create_flow;
- ibdev->ib_dev.destroy_flow = mlx4_ib_destroy_flow;
- } else {
- pr_debug("Device managed flow steering is unavailable for this configuration.\n");
}
- /*
- * End of experimental data
- */
+
+ ibdev->ib_dev.uverbs_ex_cmd_mask |=
+ (1ull << IB_USER_VERBS_EX_CMD_QUERY_DEVICE) |
+ (1ull << IB_USER_VERBS_EX_CMD_CREATE_CQ) |
+ (1ull << IB_USER_VERBS_EX_CMD_CREATE_QP);
mlx4_ib_alloc_eqs(dev, ibdev);
@@ -2324,38 +2743,75 @@ static void *mlx4_ib_add(struct mlx4_dev *dev)
if (init_node_data(ibdev))
goto err_map;
+ mlx4_init_sl2vl_tbl(ibdev);
for (i = 0; i < ibdev->num_ports; ++i) {
+ mutex_init(&ibdev->counters_table[i].mutex);
+ INIT_LIST_HEAD(&ibdev->counters_table[i].counters_list);
+ }
+
+ num_req_counters = mlx4_is_bonded(dev) ? 1 : ibdev->num_ports;
+ for (i = 0; i < num_req_counters; ++i) {
+ mutex_init(&ibdev->qp1_proxy_lock[i]);
+ allocated = 0;
if (mlx4_ib_port_link_layer(&ibdev->ib_dev, i + 1) ==
IB_LINK_LAYER_ETHERNET) {
- if (mlx4_is_slave(dev)) {
- ibdev->counters[i].status = mlx4_counter_alloc(ibdev->dev,
- &ibdev->counters[i].counter_index);
- if (ibdev->counters[i].status)
- ibdev->counters[i].counter_index = mlx4_get_default_counter_index(dev,
+ err = mlx4_counter_alloc(ibdev->dev, &counter_index);
+ /* if failed to allocate a new counter, use default */
+ if (err)
+ counter_index =
+ mlx4_get_default_counter_index(dev,
+ i + 1);
+ else
+ allocated = 1;
+ } else { /* IB_LINK_LAYER_INFINIBAND use the default counter */
+ counter_index = mlx4_get_default_counter_index(dev,
i + 1);
- } else {/* allocating the PF IB default counter indices reserved in mlx4_init_counters_table */
- ibdev->counters[i].counter_index = ((i + 1) << 1) - 1;
- ibdev->counters[i].status = 0;
- }
-
- dev_info(&dev->persist->pdev->dev,
- "%s: allocated counter index %d for port %d\n",
- __func__, ibdev->counters[i].counter_index, i+1);
- } else {
- ibdev->counters[i].counter_index = MLX4_SINK_COUNTER_INDEX(dev);
- ibdev->counters[i].status = -ENOSPC;
}
- }
+ new_counter_index = kmalloc(sizeof(*new_counter_index),
+ GFP_KERNEL);
+ if (!new_counter_index) {
+ if (allocated)
+ mlx4_counter_free(ibdev->dev, counter_index);
+ goto err_counter;
+ }
+ new_counter_index->index = counter_index;
+ new_counter_index->allocated = allocated;
+ list_add_tail(&new_counter_index->list,
+ &ibdev->counters_table[i].counters_list);
+ ibdev->counters_table[i].default_counter = counter_index;
+ pr_info("counter index %d for port %d allocated %d\n",
+ counter_index, i + 1, allocated);
+ }
+ if (mlx4_is_bonded(dev))
+ for (i = 1; i < ibdev->num_ports ; ++i) {
+ new_counter_index =
+ kmalloc(sizeof(struct counter_index),
+ GFP_KERNEL);
+ if (!new_counter_index)
+ goto err_counter;
+ new_counter_index->index = counter_index;
+ new_counter_index->allocated = 0;
+ list_add_tail(&new_counter_index->list,
+ &ibdev->counters_table[i].counters_list);
+ ibdev->counters_table[i].default_counter =
+ counter_index;
+ }
+
+ mlx4_foreach_port(i, dev, MLX4_PORT_TYPE_IB)
+ ib_num_ports++;
spin_lock_init(&ibdev->sm_lock);
mutex_init(&ibdev->cap_mask_mutex);
+ INIT_LIST_HEAD(&ibdev->qp_list);
+ spin_lock_init(&ibdev->reset_flow_resource_lock);
- if (dev->caps.steering_mode == MLX4_STEERING_MODE_DEVICE_MANAGED &&
- !mlx4_is_mfunc(dev)) {
+ if (ibdev->steering_support == MLX4_STEERING_MODE_DEVICE_MANAGED &&
+ ib_num_ports) {
ibdev->steer_qpn_count = MLX4_IB_UC_MAX_NUM_QPS;
err = mlx4_qp_reserve_range(dev, ibdev->steer_qpn_count,
- MLX4_IB_UC_STEER_QPN_ALIGN, &ibdev->steer_qpn_base, 0);
+ MLX4_IB_UC_STEER_QPN_ALIGN,
+ &ibdev->steer_qpn_base, 0);
if (err)
goto err_counter;
@@ -2371,47 +2827,52 @@ static void *mlx4_ib_add(struct mlx4_dev *dev)
bitmap_zero(ibdev->ib_uc_qpns_bitmap, ibdev->steer_qpn_count);
- err = mlx4_FLOW_STEERING_IB_UC_QP_RANGE(dev, ibdev->steer_qpn_base,
- ibdev->steer_qpn_base + ibdev->steer_qpn_count - 1);
+ err = mlx4_FLOW_STEERING_IB_UC_QP_RANGE(
+ dev, ibdev->steer_qpn_base,
+ ibdev->steer_qpn_base +
+ ibdev->steer_qpn_count - 1);
if (err)
goto err_steer_free_bitmap;
}
- if (ib_register_device(&ibdev->ib_dev, NULL))
+ for (j = 1; j <= ibdev->dev->caps.num_ports; j++)
+ atomic64_set(&iboe->mac[j - 1], ibdev->dev->caps.def_mac[j]);
+
+ if (mlx4_ib_alloc_diag_counters(ibdev))
goto err_steer_free_bitmap;
+ if (ib_register_device(&ibdev->ib_dev, NULL))
+ goto err_diag_counters;
+
if (mlx4_ib_mad_init(ibdev))
goto err_reg;
if (mlx4_ib_init_sriov(ibdev))
goto err_mad;
- if (dev->caps.flags & MLX4_DEV_CAP_FLAG_IBOE) {
+ if (dev->caps.flags & MLX4_DEV_CAP_FLAG_IBOE ||
+ dev->caps.flags2 & MLX4_DEV_CAP_FLAG2_ROCE_V1_V2) {
if (!iboe->nb.notifier_call) {
iboe->nb.notifier_call = mlx4_ib_netdev_event;
err = register_netdevice_notifier(&iboe->nb);
if (err) {
iboe->nb.notifier_call = NULL;
- goto err_notify;
+ goto err_notif;
}
}
- if (!iboe->nb_inet.notifier_call) {
- iboe->nb_inet.notifier_call = mlx4_ib_inet_event;
- err = register_inetaddr_notifier(&iboe->nb_inet);
+ if (dev->caps.flags2 & MLX4_DEV_CAP_FLAG2_ROCE_V1_V2) {
+ err = mlx4_config_roce_v2_port(dev, ROCE_V2_UDP_DPORT);
if (err) {
- iboe->nb_inet.notifier_call = NULL;
- goto err_notify;
+ goto err_notif;
}
}
- mlx4_ib_scan_netdevs(ibdev, NULL, 0);
}
+
for (j = 0; j < ARRAY_SIZE(mlx4_class_attributes); ++j) {
if (device_create_file(&ibdev->ib_dev.dev,
mlx4_class_attributes[j]))
- goto err_notify;
+ goto err_notif;
}
- if (sysfs_create_group(&ibdev->ib_dev.dev.kobj, &diag_counters_group))
- goto err_notify;
ibdev->ib_active = true;
@@ -2429,22 +2890,12 @@ static void *mlx4_ib_add(struct mlx4_dev *dev)
}
return ibdev;
-err_notify:
- for (j = 0; j < ARRAY_SIZE(mlx4_class_attributes); ++j) {
- device_remove_file(&ibdev->ib_dev.dev,
- mlx4_class_attributes[j]);
- }
-
+err_notif:
if (ibdev->iboe.nb.notifier_call) {
if (unregister_netdevice_notifier(&ibdev->iboe.nb))
pr_warn("failure unregistering notifier\n");
ibdev->iboe.nb.notifier_call = NULL;
}
- if (ibdev->iboe.nb_inet.notifier_call) {
- if (unregister_inetaddr_notifier(&ibdev->iboe.nb_inet))
- pr_warn("failure unregistering notifier\n");
- ibdev->iboe.nb_inet.notifier_call = NULL;
- }
flush_workqueue(wq);
mlx4_ib_close_sriov(ibdev);
@@ -2455,25 +2906,22 @@ err_mad:
err_reg:
ib_unregister_device(&ibdev->ib_dev);
+err_diag_counters:
+ mlx4_ib_diag_cleanup(ibdev);
+
err_steer_free_bitmap:
kfree(ibdev->ib_uc_qpns_bitmap);
err_steer_qp_release:
- if (dev->caps.steering_mode == MLX4_STEERING_MODE_DEVICE_MANAGED)
+ if (ibdev->steering_support == MLX4_STEERING_MODE_DEVICE_MANAGED)
mlx4_qp_release_range(dev, ibdev->steer_qpn_base,
- ibdev->steer_qpn_count);
+ ibdev->steer_qpn_count);
err_counter:
- for (; i; --i) {
- if (mlx4_ib_port_link_layer(&ibdev->ib_dev, i) ==
- IB_LINK_LAYER_ETHERNET) {
- mlx4_counter_free(ibdev->dev,
- ibdev->counters[i - 1].counter_index);
- }
- }
+ for (i = 0; i < ibdev->num_ports; ++i)
+ mlx4_ib_delete_counters_table(ibdev, &ibdev->counters_table[i]);
err_map:
- iounmap(ibdev->priv_uar.map);
- mlx4_ib_free_eqs(dev, ibdev);
+ iounmap(ibdev->uar_map);
err_uar:
mlx4_uar_free(dev, &ibdev->priv_uar);
@@ -2506,13 +2954,14 @@ int mlx4_ib_steer_qp_alloc(struct mlx4_ib_dev *dev, int count, int *qpn)
void mlx4_ib_steer_qp_free(struct mlx4_ib_dev *dev, u32 qpn, int count)
{
if (!qpn ||
- dev->dev->caps.steering_mode != MLX4_STEERING_MODE_DEVICE_MANAGED)
+ dev->steering_support != MLX4_STEERING_MODE_DEVICE_MANAGED)
return;
BUG_ON(qpn < dev->steer_qpn_base);
bitmap_release_region(dev->ib_uc_qpns_bitmap,
- qpn - dev->steer_qpn_base, get_count_order(count));
+ qpn - dev->steer_qpn_base,
+ get_count_order(count));
}
int mlx4_ib_steer_qp_reg(struct mlx4_ib_dev *mdev, struct mlx4_ib_qp *mqp,
@@ -2535,8 +2984,8 @@ int mlx4_ib_steer_qp_reg(struct mlx4_ib_dev *mdev, struct mlx4_ib_qp *mqp,
ib_spec = (struct ib_flow_spec_ib *)(flow + 1);
ib_spec->type = IB_FLOW_SPEC_IB;
ib_spec->size = sizeof(struct ib_flow_spec_ib);
- ib_spec->val.l3_type_qpn = mqp->ibqp.qp_num;
- ib_spec->mask.l3_type_qpn = MLX4_IB_FLOW_QPN_MASK;
+ /* Add an empty rule for IB L2 */
+ memset(&ib_spec->mask, 0, sizeof(ib_spec->mask));
err = __mlx4_ib_create_flow(&mqp->ibqp, flow,
IB_FLOW_DOMAIN_NIC,
@@ -2552,46 +3001,31 @@ int mlx4_ib_steer_qp_reg(struct mlx4_ib_dev *mdev, struct mlx4_ib_qp *mqp,
static void mlx4_ib_remove(struct mlx4_dev *dev, void *ibdev_ptr)
{
struct mlx4_ib_dev *ibdev = ibdev_ptr;
- int p, j;
+ int p;
- if (ibdev->iboe.nb_inet.notifier_call) {
- if (unregister_inetaddr_notifier(&ibdev->iboe.nb_inet))
- pr_warn("failure unregistering notifier\n");
- ibdev->iboe.nb_inet.notifier_call = NULL;
- }
+ ibdev->ib_active = false;
+ flush_workqueue(wq);
mlx4_ib_close_sriov(ibdev);
- sysfs_remove_group(&ibdev->ib_dev.dev.kobj, &diag_counters_group);
mlx4_ib_mad_cleanup(ibdev);
-
- for (j = 0; j < ARRAY_SIZE(mlx4_class_attributes); ++j) {
- device_remove_file(&ibdev->ib_dev.dev,
- mlx4_class_attributes[j]);
- }
-
ib_unregister_device(&ibdev->ib_dev);
-
- if (dev->caps.steering_mode == MLX4_STEERING_MODE_DEVICE_MANAGED) {
- mlx4_qp_release_range(dev, ibdev->steer_qpn_base,
- ibdev->steer_qpn_count);
- kfree(ibdev->ib_uc_qpns_bitmap);
- }
-
+ mlx4_ib_diag_cleanup(ibdev);
if (ibdev->iboe.nb.notifier_call) {
if (unregister_netdevice_notifier(&ibdev->iboe.nb))
pr_warn("failure unregistering notifier\n");
ibdev->iboe.nb.notifier_call = NULL;
}
- iounmap(ibdev->priv_uar.map);
- for (p = 0; p < ibdev->num_ports; ++p) {
- if (mlx4_ib_port_link_layer(&ibdev->ib_dev, p + 1) ==
- IB_LINK_LAYER_ETHERNET) {
- mlx4_counter_free(ibdev->dev,
- ibdev->counters[p].counter_index);
- }
+ if (ibdev->steering_support == MLX4_STEERING_MODE_DEVICE_MANAGED) {
+ mlx4_qp_release_range(dev, ibdev->steer_qpn_base,
+ ibdev->steer_qpn_count);
+ kfree(ibdev->ib_uc_qpns_bitmap);
}
+ iounmap(ibdev->uar_map);
+ for (p = 0; p < ibdev->num_ports; ++p)
+ mlx4_ib_delete_counters_table(ibdev, &ibdev->counters_table[p]);
+
mlx4_foreach_port(p, dev, MLX4_PORT_TYPE_IB)
mlx4_CLOSE_PORT(dev, p);
@@ -2608,45 +3042,191 @@ static void do_slave_init(struct mlx4_ib_dev *ibdev, int slave, int do_init)
struct mlx4_dev *dev = ibdev->dev;
int i;
unsigned long flags;
+ struct mlx4_active_ports actv_ports;
+ unsigned int ports;
+ unsigned int first_port;
if (!mlx4_is_master(dev))
return;
- dm = kcalloc(dev->caps.num_ports, sizeof *dm, GFP_ATOMIC);
+ actv_ports = mlx4_get_active_ports(dev, slave);
+ ports = bitmap_weight(actv_ports.ports, dev->caps.num_ports);
+ first_port = find_first_bit(actv_ports.ports, dev->caps.num_ports);
+
+ dm = kcalloc(ports, sizeof(*dm), GFP_ATOMIC);
if (!dm) {
pr_err("failed to allocate memory for tunneling qp update\n");
- goto out;
+ return;
}
- for (i = 0; i < dev->caps.num_ports; i++) {
+ for (i = 0; i < ports; i++) {
dm[i] = kmalloc(sizeof (struct mlx4_ib_demux_work), GFP_ATOMIC);
if (!dm[i]) {
pr_err("failed to allocate memory for tunneling qp update work struct\n");
- for (i = 0; i < dev->caps.num_ports; i++) {
- if (dm[i])
- kfree(dm[i]);
- }
+ while (--i >= 0)
+ kfree(dm[i]);
goto out;
}
- }
- /* initialize or tear down tunnel QPs for the slave */
- for (i = 0; i < dev->caps.num_ports; i++) {
INIT_WORK(&dm[i]->work, mlx4_ib_tunnels_update_work);
- dm[i]->port = i + 1;
+ dm[i]->port = first_port + i + 1;
dm[i]->slave = slave;
dm[i]->do_init = do_init;
dm[i]->dev = ibdev;
- spin_lock_irqsave(&ibdev->sriov.going_down_lock, flags);
- if (!ibdev->sriov.is_going_down)
+ }
+ /* initialize or tear down tunnel QPs for the slave */
+ spin_lock_irqsave(&ibdev->sriov.going_down_lock, flags);
+ if (!ibdev->sriov.is_going_down) {
+ for (i = 0; i < ports; i++)
queue_work(ibdev->sriov.demux[i].ud_wq, &dm[i]->work);
spin_unlock_irqrestore(&ibdev->sriov.going_down_lock, flags);
+ } else {
+ spin_unlock_irqrestore(&ibdev->sriov.going_down_lock, flags);
+ for (i = 0; i < ports; i++)
+ kfree(dm[i]);
}
out:
- if (dm)
- kfree(dm);
+ kfree(dm);
return;
}
+static void mlx4_ib_handle_catas_error(struct mlx4_ib_dev *ibdev)
+{
+ struct mlx4_ib_qp *mqp;
+ unsigned long flags_qp;
+ unsigned long flags_cq;
+ struct mlx4_ib_cq *send_mcq, *recv_mcq;
+ struct list_head cq_notify_list;
+ struct mlx4_cq *mcq;
+ unsigned long flags;
+
+ pr_warn("mlx4_ib_handle_catas_error was started\n");
+ INIT_LIST_HEAD(&cq_notify_list);
+
+ /* Go over qp list reside on that ibdev, sync with create/destroy qp.*/
+ spin_lock_irqsave(&ibdev->reset_flow_resource_lock, flags);
+
+ list_for_each_entry(mqp, &ibdev->qp_list, qps_list) {
+ spin_lock_irqsave(&mqp->sq.lock, flags_qp);
+ if (mqp->sq.tail != mqp->sq.head) {
+ send_mcq = to_mcq(mqp->ibqp.send_cq);
+ spin_lock_irqsave(&send_mcq->lock, flags_cq);
+ if (send_mcq->mcq.comp &&
+ mqp->ibqp.send_cq->comp_handler) {
+ if (!send_mcq->mcq.reset_notify_added) {
+ send_mcq->mcq.reset_notify_added = 1;
+ list_add_tail(&send_mcq->mcq.reset_notify,
+ &cq_notify_list);
+ }
+ }
+ spin_unlock_irqrestore(&send_mcq->lock, flags_cq);
+ }
+ spin_unlock_irqrestore(&mqp->sq.lock, flags_qp);
+ /* Now, handle the QP's receive queue */
+ spin_lock_irqsave(&mqp->rq.lock, flags_qp);
+ /* no handling is needed for SRQ */
+ if (!mqp->ibqp.srq) {
+ if (mqp->rq.tail != mqp->rq.head) {
+ recv_mcq = to_mcq(mqp->ibqp.recv_cq);
+ spin_lock_irqsave(&recv_mcq->lock, flags_cq);
+ if (recv_mcq->mcq.comp &&
+ mqp->ibqp.recv_cq->comp_handler) {
+ if (!recv_mcq->mcq.reset_notify_added) {
+ recv_mcq->mcq.reset_notify_added = 1;
+ list_add_tail(&recv_mcq->mcq.reset_notify,
+ &cq_notify_list);
+ }
+ }
+ spin_unlock_irqrestore(&recv_mcq->lock,
+ flags_cq);
+ }
+ }
+ spin_unlock_irqrestore(&mqp->rq.lock, flags_qp);
+ }
+
+ list_for_each_entry(mcq, &cq_notify_list, reset_notify) {
+ mcq->comp(mcq);
+ }
+ spin_unlock_irqrestore(&ibdev->reset_flow_resource_lock, flags);
+ pr_warn("mlx4_ib_handle_catas_error ended\n");
+}
+
+static void handle_bonded_port_state_event(struct work_struct *work)
+{
+ struct ib_event_work *ew =
+ container_of(work, struct ib_event_work, work);
+ struct mlx4_ib_dev *ibdev = ew->ib_dev;
+ enum ib_port_state bonded_port_state = IB_PORT_NOP;
+ int i;
+ struct ib_event ibev;
+
+ kfree(ew);
+ spin_lock_bh(&ibdev->iboe.lock);
+ for (i = 0; i < MLX4_MAX_PORTS; ++i) {
+ struct net_device *curr_netdev = ibdev->iboe.netdevs[i];
+ enum ib_port_state curr_port_state;
+
+ if (!curr_netdev)
+ continue;
+
+ curr_port_state =
+ (netif_running(curr_netdev) &&
+ netif_carrier_ok(curr_netdev)) ?
+ IB_PORT_ACTIVE : IB_PORT_DOWN;
+
+ bonded_port_state = (bonded_port_state != IB_PORT_ACTIVE) ?
+ curr_port_state : IB_PORT_ACTIVE;
+ }
+ spin_unlock_bh(&ibdev->iboe.lock);
+
+ ibev.device = &ibdev->ib_dev;
+ ibev.element.port_num = 1;
+ ibev.event = (bonded_port_state == IB_PORT_ACTIVE) ?
+ IB_EVENT_PORT_ACTIVE : IB_EVENT_PORT_ERR;
+
+ ib_dispatch_event(&ibev);
+}
+
+void mlx4_ib_sl2vl_update(struct mlx4_ib_dev *mdev, int port)
+{
+ u64 sl2vl;
+ int err;
+
+ err = mlx4_ib_query_sl2vl(&mdev->ib_dev, port, &sl2vl);
+ if (err) {
+ pr_err("Unable to get current sl to vl mapping for port %d. Using all zeroes (%d)\n",
+ port, err);
+ sl2vl = 0;
+ }
+ atomic64_set(&mdev->sl2vl[port - 1], sl2vl);
+}
+
+static void ib_sl2vl_update_work(struct work_struct *work)
+{
+ struct ib_event_work *ew = container_of(work, struct ib_event_work, work);
+ struct mlx4_ib_dev *mdev = ew->ib_dev;
+ int port = ew->port;
+
+ mlx4_ib_sl2vl_update(mdev, port);
+
+ kfree(ew);
+}
+
+void mlx4_sched_ib_sl2vl_update_work(struct mlx4_ib_dev *ibdev,
+ int port)
+{
+ struct ib_event_work *ew;
+
+ ew = kmalloc(sizeof(*ew), GFP_ATOMIC);
+ if (ew) {
+ INIT_WORK(&ew->work, ib_sl2vl_update_work);
+ ew->port = port;
+ ew->ib_dev = ibdev;
+ queue_work(wq, &ew->work);
+ } else {
+ pr_err("failed to allocate memory for sl2vl update work\n");
+ }
+}
+
static void mlx4_ib_event(struct mlx4_dev *dev, void *ibdev_ptr,
enum mlx4_dev_event event, unsigned long param)
{
@@ -2656,6 +3236,18 @@ static void mlx4_ib_event(struct mlx4_dev *dev, void *ibdev_ptr,
struct ib_event_work *ew;
int p = 0;
+ if (mlx4_is_bonded(dev) &&
+ ((event == MLX4_DEV_EVENT_PORT_UP) ||
+ (event == MLX4_DEV_EVENT_PORT_DOWN))) {
+ ew = kmalloc(sizeof(*ew), GFP_ATOMIC);
+ if (!ew)
+ return;
+ INIT_WORK(&ew->work, handle_bonded_port_state_event);
+ ew->ib_dev = ibdev;
+ queue_work(wq, &ew->work);
+ return;
+ }
+
if (event == MLX4_DEV_EVENT_PORT_MGMT_CHANGE)
eqe = (struct mlx4_eqe *)param;
else
@@ -2665,27 +3257,28 @@ static void mlx4_ib_event(struct mlx4_dev *dev, void *ibdev_ptr,
case MLX4_DEV_EVENT_PORT_UP:
if (p > ibdev->num_ports)
return;
- if (mlx4_is_master(dev) &&
+ if (!mlx4_is_slave(dev) &&
rdma_port_get_link_layer(&ibdev->ib_dev, p) ==
IB_LINK_LAYER_INFINIBAND) {
- mlx4_ib_invalidate_all_guid_record(ibdev, p);
+ if (mlx4_is_master(dev))
+ mlx4_ib_invalidate_all_guid_record(ibdev, p);
+ if (ibdev->dev->flags & MLX4_FLAG_SECURE_HOST &&
+ !(ibdev->dev->caps.flags2 & MLX4_DEV_CAP_FLAG2_SL_TO_VL_CHANGE_EVENT))
+ mlx4_sched_ib_sl2vl_update_work(ibdev, p);
}
- mlx4_ib_info((struct ib_device *) ibdev_ptr,
- "Port %d logical link is up\n", p);
ibev.event = IB_EVENT_PORT_ACTIVE;
break;
case MLX4_DEV_EVENT_PORT_DOWN:
if (p > ibdev->num_ports)
return;
- mlx4_ib_info((struct ib_device *) ibdev_ptr,
- "Port %d logical link is down\n", p);
ibev.event = IB_EVENT_PORT_ERR;
break;
case MLX4_DEV_EVENT_CATASTROPHIC_ERROR:
ibdev->ib_active = false;
ibev.event = IB_EVENT_DEVICE_FATAL;
+ mlx4_ib_handle_catas_error(ibdev);
break;
case MLX4_DEV_EVENT_PORT_MGMT_CHANGE:
@@ -2708,9 +3301,31 @@ static void mlx4_ib_event(struct mlx4_dev *dev, void *ibdev_ptr,
case MLX4_DEV_EVENT_SLAVE_INIT:
/* here, p is the slave id */
do_slave_init(ibdev, p, 1);
+ if (mlx4_is_master(dev)) {
+ int i;
+
+ for (i = 1; i <= ibdev->num_ports; i++) {
+ if (rdma_port_get_link_layer(&ibdev->ib_dev, i)
+ == IB_LINK_LAYER_INFINIBAND)
+ mlx4_ib_slave_alias_guid_event(ibdev,
+ p, i,
+ 1);
+ }
+ }
return;
case MLX4_DEV_EVENT_SLAVE_SHUTDOWN:
+ if (mlx4_is_master(dev)) {
+ int i;
+
+ for (i = 1; i <= ibdev->num_ports; i++) {
+ if (rdma_port_get_link_layer(&ibdev->ib_dev, i)
+ == IB_LINK_LAYER_INFINIBAND)
+ mlx4_ib_slave_alias_guid_event(ibdev,
+ p, i,
+ 0);
+ }
+ }
/* here, p is the slave id */
do_slave_init(ibdev, p, 0);
return;
@@ -2720,7 +3335,7 @@ static void mlx4_ib_event(struct mlx4_dev *dev, void *ibdev_ptr,
}
ibev.device = ibdev_ptr;
- ibev.element.port_num = (u8) p;
+ ibev.element.port_num = mlx4_is_bonded(ibdev->dev) ? 1 : (u8)p;
ib_dispatch_event(&ibev);
}
@@ -2729,20 +3344,21 @@ static struct mlx4_interface mlx4_ib_interface = {
.add = mlx4_ib_add,
.remove = mlx4_ib_remove,
.event = mlx4_ib_event,
- .protocol = MLX4_PROT_IB_IPV6
+ .protocol = MLX4_PROT_IB_IPV6,
+ .flags = MLX4_INTFF_BONDING
};
static int __init mlx4_ib_init(void)
{
int err;
- wq = create_singlethread_workqueue("mlx4_ib");
+ wq = alloc_ordered_workqueue("mlx4_ib", WQ_MEM_RECLAIM);
if (!wq)
return -ENOMEM;
err = mlx4_ib_mcg_init();
if (err)
- goto clean_proc;
+ goto clean_wq;
err = mlx4_register_interface(&mlx4_ib_interface);
if (err)
@@ -2753,7 +3369,7 @@ static int __init mlx4_ib_init(void)
clean_mcg:
mlx4_ib_mcg_destroy();
-clean_proc:
+clean_wq:
destroy_workqueue(wq);
return err;
}
diff --git a/sys/dev/mlx4/mlx4_ib/mlx4_ib_mcg.c b/sys/dev/mlx4/mlx4_ib/mlx4_ib_mcg.c
index 391c3ee..45ead56 100644
--- a/sys/dev/mlx4/mlx4_ib/mlx4_ib_mcg.c
+++ b/sys/dev/mlx4/mlx4_ib/mlx4_ib_mcg.c
@@ -51,6 +51,10 @@
pr_warn("%s-%d: %16s (port %d): WARNING: " format, __func__, __LINE__,\
(group)->name, group->demux->port, ## arg)
+#define mcg_debug_group(group, format, arg...) \
+ pr_debug("%s-%d: %16s (port %d): WARNING: " format, __func__, __LINE__,\
+ (group)->name, (group)->demux->port, ## arg)
+
#define mcg_error_group(group, format, arg...) \
pr_err(" %16s: " format, (group)->name, ## arg)
@@ -92,7 +96,7 @@ struct ib_sa_mcmember_data {
u8 scope_join_state;
u8 proxy_join;
u8 reserved[2];
-};
+} __packed __aligned(4);
struct mcast_group {
struct ib_sa_mcmember_data rec;
@@ -206,17 +210,19 @@ static int send_mad_to_wire(struct mlx4_ib_demux_ctx *ctx, struct ib_mad *mad)
{
struct mlx4_ib_dev *dev = ctx->dev;
struct ib_ah_attr ah_attr;
+ unsigned long flags;
- spin_lock(&dev->sm_lock);
+ spin_lock_irqsave(&dev->sm_lock, flags);
if (!dev->sm_ah[ctx->port - 1]) {
/* port is not yet Active, sm_ah not ready */
- spin_unlock(&dev->sm_lock);
+ spin_unlock_irqrestore(&dev->sm_lock, flags);
return -EAGAIN;
}
mlx4_ib_query_ah(dev->sm_ah[ctx->port - 1], &ah_attr);
- spin_unlock(&dev->sm_lock);
- return mlx4_ib_send_to_wire(dev, mlx4_master_func_num(dev->dev), ctx->port,
- IB_QPT_GSI, 0, 1, IB_QP1_QKEY, &ah_attr, 0, mad);
+ spin_unlock_irqrestore(&dev->sm_lock, flags);
+ return mlx4_ib_send_to_wire(dev, mlx4_master_func_num(dev->dev),
+ ctx->port, IB_QPT_GSI, 0, 1, IB_QP1_QKEY,
+ &ah_attr, NULL, 0xffff, mad);
}
static int send_mad_to_slave(int slave, struct mlx4_ib_demux_ctx *ctx,
@@ -483,7 +489,7 @@ static u8 get_leave_state(struct mcast_group *group)
if (!group->members[i])
leave_state |= (1 << i);
- return leave_state & (group->rec.scope_join_state & 7);
+ return leave_state & (group->rec.scope_join_state & 0xf);
}
static int join_group(struct mcast_group *group, int slave, u8 join_mask)
@@ -558,8 +564,8 @@ static void mlx4_ib_mcg_timeout_handler(struct work_struct *work)
} else
mcg_warn_group(group, "DRIVER BUG\n");
} else if (group->state == MCAST_LEAVE_SENT) {
- if (group->rec.scope_join_state & 7)
- group->rec.scope_join_state &= 0xf8;
+ if (group->rec.scope_join_state & 0xf)
+ group->rec.scope_join_state &= 0xf0;
group->state = MCAST_IDLE;
mutex_unlock(&group->lock);
if (release_group(group, 1))
@@ -599,7 +605,7 @@ static int handle_leave_req(struct mcast_group *group, u8 leave_mask,
static int handle_join_req(struct mcast_group *group, u8 join_mask,
struct mcast_req *req)
{
- u8 group_join_state = group->rec.scope_join_state & 7;
+ u8 group_join_state = group->rec.scope_join_state & 0xf;
int ref = 0;
u16 status;
struct ib_sa_mcmember_data *sa_data = (struct ib_sa_mcmember_data *)req->sa_mad.data;
@@ -685,11 +691,11 @@ static void mlx4_ib_mcg_work_handler(struct work_struct *work)
u8 cur_join_state;
resp_join_state = ((struct ib_sa_mcmember_data *)
- group->response_sa_mad.data)->scope_join_state & 7;
- cur_join_state = group->rec.scope_join_state & 7;
+ group->response_sa_mad.data)->scope_join_state & 0xf;
+ cur_join_state = group->rec.scope_join_state & 0xf;
if (method == IB_MGMT_METHOD_GET_RESP) {
- /* successful join */
+ /* successfull join */
if (!cur_join_state && resp_join_state)
--rc;
} else if (!resp_join_state)
@@ -705,7 +711,7 @@ process_requests:
req = list_first_entry(&group->pending_list, struct mcast_req,
group_list);
sa_data = (struct ib_sa_mcmember_data *)req->sa_mad.data;
- req_join_state = sa_data->scope_join_state & 0x7;
+ req_join_state = sa_data->scope_join_state & 0xf;
/* For a leave request, we will immediately answer the VF, and
* update our internal counters. The actual leave will be sent
@@ -742,14 +748,11 @@ static struct mcast_group *search_relocate_mgid0_group(struct mlx4_ib_demux_ctx
__be64 tid,
union ib_gid *new_mgid)
{
- struct mcast_group *group = NULL, *cur_group;
+ struct mcast_group *group = NULL, *cur_group, *n;
struct mcast_req *req;
- struct list_head *pos;
- struct list_head *n;
mutex_lock(&ctx->mcg_table_lock);
- list_for_each_safe(pos, n, &ctx->mcg_mgid0_list) {
- group = list_entry(pos, struct mcast_group, mgid0_list);
+ list_for_each_entry_safe(group, n, &ctx->mcg_mgid0_list, mgid0_list) {
mutex_lock(&group->lock);
if (group->last_req_tid == tid) {
if (memcmp(new_mgid, &mgid0, sizeof mgid0)) {
@@ -963,8 +966,8 @@ int mlx4_ib_mcg_multiplex_handler(struct ib_device *ibdev, int port,
mutex_lock(&group->lock);
if (group->func[slave].num_pend_reqs > MAX_PEND_REQS_PER_FUNC) {
mutex_unlock(&group->lock);
- mcg_warn_group(group, "Port %d, Func %d has too many pending requests (%d), dropping\n",
- port, slave, MAX_PEND_REQS_PER_FUNC);
+ mcg_debug_group(group, "Port %d, Func %d has too many pending requests (%d), dropping\n",
+ port, slave, MAX_PEND_REQS_PER_FUNC);
release_group(group, 0);
kfree(req);
return -ENOMEM;
@@ -1046,7 +1049,7 @@ int mlx4_ib_mcg_port_init(struct mlx4_ib_demux_ctx *ctx)
atomic_set(&ctx->tid, 0);
sprintf(name, "mlx4_ib_mcg%d", ctx->port);
- ctx->mcg_wq = create_singlethread_workqueue(name);
+ ctx->mcg_wq = alloc_ordered_workqueue(name, WQ_MEM_RECLAIM);
if (!ctx->mcg_wq)
return -ENOMEM;
@@ -1247,7 +1250,7 @@ void clean_vf_mcast(struct mlx4_ib_demux_ctx *ctx, int slave)
int mlx4_ib_mcg_init(void)
{
- clean_wq = create_singlethread_workqueue("mlx4_ib_mcg");
+ clean_wq = alloc_ordered_workqueue("mlx4_ib_mcg", WQ_MEM_RECLAIM);
if (!clean_wq)
return -ENOMEM;
diff --git a/sys/dev/mlx4/mlx4_ib/mlx4_ib_mr.c b/sys/dev/mlx4/mlx4_ib/mlx4_ib_mr.c
index 9a2889d..3756602 100644
--- a/sys/dev/mlx4/mlx4_ib/mlx4_ib_mr.c
+++ b/sys/dev/mlx4/mlx4_ib/mlx4_ib_mr.c
@@ -35,6 +35,8 @@
#include <linux/module.h>
#include <linux/sched.h>
+#include <asm/atomic64.h>
+
#include "mlx4_ib.h"
static u32 convert_access(int acc)
@@ -43,71 +45,25 @@ static u32 convert_access(int acc)
(acc & IB_ACCESS_REMOTE_WRITE ? MLX4_PERM_REMOTE_WRITE : 0) |
(acc & IB_ACCESS_REMOTE_READ ? MLX4_PERM_REMOTE_READ : 0) |
(acc & IB_ACCESS_LOCAL_WRITE ? MLX4_PERM_LOCAL_WRITE : 0) |
- (acc & IB_ACCESS_MW_BIND ? MLX4_PERM_BIND_MW : 0) |
+ (acc & IB_ACCESS_MW_BIND ? MLX4_PERM_BIND_MW : 0) |
MLX4_PERM_LOCAL_READ;
}
-/* No suuport for Shared MR feature */
-#if 0
-static ssize_t shared_mr_proc_read(struct file *file,
- char __user *buffer,
- size_t len,
- loff_t *offset)
-{
-
- return -ENOSYS;
-
-}
-static ssize_t shared_mr_proc_write(struct file *file,
- const char __user *buffer,
- size_t len,
- loff_t *offset)
+static enum mlx4_mw_type to_mlx4_type(enum ib_mw_type type)
{
-
- return -ENOSYS;
-}
-
-static int shared_mr_mmap(struct file *filep, struct vm_area_struct *vma)
-{
-
- struct proc_dir_entry *pde = PDE(filep->f_path.dentry->d_inode);
- struct mlx4_shared_mr_info *smr_info =
- (struct mlx4_shared_mr_info *)pde->data;
-
- /* Prevent any mapping not on start of area */
- if (vma->vm_pgoff != 0)
- return -EINVAL;
-
- return ib_umem_map_to_vma(smr_info->umem,
- vma);
-
+ switch (type) {
+ case IB_MW_TYPE_1: return MLX4_MW_TYPE_1;
+ case IB_MW_TYPE_2: return MLX4_MW_TYPE_2;
+ default: return -1;
+ }
}
-static const struct file_operations shared_mr_proc_ops = {
- .owner = THIS_MODULE,
- .read = shared_mr_proc_read,
- .write = shared_mr_proc_write,
- .mmap = shared_mr_mmap
-};
-
-static mode_t convert_shared_access(int acc)
-{
-
- return (acc & IB_ACCESS_SHARED_MR_USER_READ ? S_IRUSR : 0) |
- (acc & IB_ACCESS_SHARED_MR_USER_WRITE ? S_IWUSR : 0) |
- (acc & IB_ACCESS_SHARED_MR_GROUP_READ ? S_IRGRP : 0) |
- (acc & IB_ACCESS_SHARED_MR_GROUP_WRITE ? S_IWGRP : 0) |
- (acc & IB_ACCESS_SHARED_MR_OTHER_READ ? S_IROTH : 0) |
- (acc & IB_ACCESS_SHARED_MR_OTHER_WRITE ? S_IWOTH : 0);
-
-}
-#endif
struct ib_mr *mlx4_ib_get_dma_mr(struct ib_pd *pd, int acc)
{
struct mlx4_ib_mr *mr;
int err;
- mr = kzalloc(sizeof *mr, GFP_KERNEL);
+ mr = kzalloc(sizeof(*mr), GFP_KERNEL);
if (!mr)
return ERR_PTR(-ENOMEM);
@@ -134,420 +90,78 @@ err_free:
return ERR_PTR(err);
}
-static int mlx4_ib_umem_write_mtt_block(struct mlx4_ib_dev *dev,
- struct mlx4_mtt *mtt,
- u64 mtt_size,
- u64 mtt_shift,
- u64 len,
- u64 cur_start_addr,
- u64 *pages,
- int *start_index,
- int *npages)
-{
- int k;
- int err = 0;
- u64 mtt_entries;
- u64 cur_end_addr = cur_start_addr + len;
- u64 cur_end_addr_aligned = 0;
-
- len += (cur_start_addr & (mtt_size-1ULL));
- cur_end_addr_aligned = round_up(cur_end_addr, mtt_size);
- len += (cur_end_addr_aligned - cur_end_addr);
- if (len & (mtt_size-1ULL)) {
- WARN(1 ,
- "write_block: len %llx is not aligned to mtt_size %llx\n",
- (unsigned long long)len, (unsigned long long)mtt_size);
- return -EINVAL;
- }
-
-
- mtt_entries = (len >> mtt_shift);
-
- /* Align the MTT start address to
- the mtt_size.
- Required to handle cases when the MR
- starts in the middle of an MTT record.
- Was not required in old code since
- the physical addresses provided by
- the dma subsystem were page aligned,
- which was also the MTT size.
- */
- cur_start_addr = round_down(cur_start_addr, mtt_size);
- /* A new block is started ...*/
- for (k = 0; k < mtt_entries; ++k) {
- pages[*npages] = cur_start_addr + (mtt_size * k);
- (*npages)++;
- /*
- * Be friendly to mlx4_write_mtt() and
- * pass it chunks of appropriate size.
- */
- if (*npages == PAGE_SIZE / sizeof(u64)) {
- err = mlx4_write_mtt(dev->dev,
- mtt, *start_index,
- *npages, pages);
- if (err)
- return err;
-
- (*start_index) += *npages;
- *npages = 0;
- }
- }
-
- return 0;
-}
-
int mlx4_ib_umem_write_mtt(struct mlx4_ib_dev *dev, struct mlx4_mtt *mtt,
struct ib_umem *umem)
{
u64 *pages;
- u64 len = 0;
+ int i, k, entry;
+ int n;
+ int len;
int err = 0;
- u64 mtt_size;
- u64 cur_start_addr = 0;
- u64 mtt_shift;
- int start_index = 0;
- int npages = 0;
struct scatterlist *sg;
- int i;
pages = (u64 *) __get_free_page(GFP_KERNEL);
if (!pages)
return -ENOMEM;
- mtt_shift = mtt->page_shift;
- mtt_size = 1ULL << mtt_shift;
-
- for_each_sg(umem->sg_head.sgl, sg, umem->nmap, i) {
- if (cur_start_addr + len ==
- sg_dma_address(sg)) {
- /* still the same block */
- len += sg_dma_len(sg);
- continue;
+ i = n = 0;
+
+ for_each_sg(umem->sg_head.sgl, sg, umem->nmap, entry) {
+ len = sg_dma_len(sg) >> mtt->page_shift;
+ for (k = 0; k < len; ++k) {
+ pages[i++] = sg_dma_address(sg) +
+ umem->page_size * k;
+ /*
+ * Be friendly to mlx4_write_mtt() and
+ * pass it chunks of appropriate size.
+ */
+ if (i == PAGE_SIZE / sizeof (u64)) {
+ err = mlx4_write_mtt(dev->dev, mtt, n,
+ i, pages);
+ if (err)
+ goto out;
+ n += i;
+ i = 0;
}
- /* A new block is started ...*/
- /* If len is malaligned, write an extra mtt entry to
- cover the misaligned area (round up the division)
- */
- err = mlx4_ib_umem_write_mtt_block(dev,
- mtt, mtt_size, mtt_shift,
- len, cur_start_addr,
- pages,
- &start_index,
- &npages);
- if (err)
- goto out;
-
- cur_start_addr =
- sg_dma_address(sg);
- len = sg_dma_len(sg);
- }
-
- /* Handle the last block */
- if (len > 0) {
- /* If len is malaligned, write an extra mtt entry to cover
- the misaligned area (round up the division)
- */
- err = mlx4_ib_umem_write_mtt_block(dev,
- mtt, mtt_size, mtt_shift,
- len, cur_start_addr,
- pages,
- &start_index,
- &npages);
- if (err)
- goto out;
+ }
}
-
- if (npages)
- err = mlx4_write_mtt(dev->dev, mtt, start_index, npages, pages);
+ if (i)
+ err = mlx4_write_mtt(dev->dev, mtt, n, i, pages);
out:
free_page((unsigned long) pages);
return err;
}
-static inline u64 alignment_of(u64 ptr)
-{
- return ilog2(ptr & (~(ptr-1)));
-}
-
-static int mlx4_ib_umem_calc_block_mtt(u64 next_block_start,
- u64 current_block_end,
- u64 block_shift)
-{
- /* Check whether the alignment of the new block
- is aligned as well as the previous block.
- Block address must start with zeros till size of entity_size.
- */
- if ((next_block_start & ((1ULL << block_shift) - 1ULL)) != 0)
- /* It is not as well aligned as the
- previous block-reduce the mtt size
- accordingly.
- Here we take the last right bit
- which is 1.
- */
- block_shift = alignment_of(next_block_start);
-
- /* Check whether the alignment of the
- end of previous block - is it aligned
- as well as the start of the block
- */
- if (((current_block_end) & ((1ULL << block_shift) - 1ULL)) != 0)
- /* It is not as well aligned as
- the start of the block - reduce the
- mtt size accordingly.
- */
- block_shift = alignment_of(current_block_end);
-
- return block_shift;
-}
-
-/* Calculate optimal mtt size based on contiguous pages.
-* Function will return also the number of pages that are not aligned to the
- calculated mtt_size to be added to total number
- of pages. For that we should check the first chunk length & last chunk
- length and if not aligned to mtt_size we should increment
- the non_aligned_pages number.
- All chunks in the middle already handled as part of mtt shift calculation
- for both their start & end addresses.
-*/
-int mlx4_ib_umem_calc_optimal_mtt_size(struct ib_umem *umem,
- u64 start_va,
- int *num_of_mtts)
-{
- u64 block_shift = 31;
- u64 current_block_len = 0;
- u64 current_block_start = 0;
- u64 misalignment_bits;
- u64 first_block_start = 0;
- u64 last_block_end = 0;
- u64 total_len = 0;
- u64 last_block_aligned_end = 0;
- u64 min_shift = ilog2(umem->page_size);
- struct scatterlist *sg;
- int i;
- u64 next_block_start;
- u64 current_block_end;
-
- for_each_sg(umem->sg_head.sgl, sg, umem->nmap, i) {
- /* Initialization - save the first chunk start as
- the current_block_start - block means contiguous pages.
- */
- if (current_block_len == 0 && current_block_start == 0) {
- first_block_start = current_block_start =
- sg_dma_address(sg);
- /* Find the bits that are different between
- the physical address and the virtual
- address for the start of the MR.
- */
- /* umem_get aligned the start_va to a page
- boundary. Therefore, we need to align the
- start va to the same boundary */
- /* misalignment_bits is needed to handle the
- case of a single memory region. In this
- case, the rest of the logic will not reduce
- the block size. If we use a block size
- which is bigger than the alignment of the
- misalignment bits, we might use the virtual
- page number instead of the physical page
- number, resulting in access to the wrong
- data. */
- misalignment_bits =
- (start_va & (~(((u64)(umem->page_size))-1ULL)))
- ^ current_block_start;
- block_shift = min(alignment_of(misalignment_bits)
- , block_shift);
- }
-
- /* Go over the scatter entries and check
- if they continue the previous scatter entry.
- */
- next_block_start =
- sg_dma_address(sg);
- current_block_end = current_block_start
- + current_block_len;
- /* If we have a split (non-contig.) between two block*/
- if (current_block_end != next_block_start) {
- block_shift = mlx4_ib_umem_calc_block_mtt(
- next_block_start,
- current_block_end,
- block_shift);
-
- /* If we reached the minimum shift for 4k
- page we stop the loop.
- */
- if (block_shift <= min_shift)
- goto end;
-
- /* If not saved yet we are in first block -
- we save the length of first block to
- calculate the non_aligned_pages number at
- * the end.
- */
- total_len += current_block_len;
-
- /* Start a new block */
- current_block_start = next_block_start;
- current_block_len =
- sg_dma_len(sg);
- continue;
- }
- /* The scatter entry is another part of
- the current block, increase the block size
- * An entry in the scatter can be larger than
- 4k (page) as of dma mapping
- which merge some blocks together.
- */
- current_block_len +=
- sg_dma_len(sg);
- }
-
- /* Account for the last block in the total len */
- total_len += current_block_len;
- /* Add to the first block the misalignment that it suffers from.*/
- total_len += (first_block_start & ((1ULL<<block_shift)-1ULL));
- last_block_end = current_block_start+current_block_len;
- last_block_aligned_end = round_up(last_block_end, 1<<block_shift);
- total_len += (last_block_aligned_end - last_block_end);
-
- WARN((total_len & ((1ULL<<block_shift)-1ULL)),
- " misaligned total length detected (%llu, %llu)!",
- (unsigned long long)total_len, (unsigned long long)block_shift);
-
- *num_of_mtts = total_len >> block_shift;
-end:
- if (block_shift < min_shift) {
- /* If shift is less than the min we set a WARN and
- return the min shift.
- */
- WARN(1,
- "mlx4_ib_umem_calc_optimal_mtt_size - unexpected shift %lld\n",
- (unsigned long long)block_shift);
-
- block_shift = min_shift;
- }
- return block_shift;
-
-}
-
-/* No suuport for Shared MR */
-#if 0
-static int prepare_shared_mr(struct mlx4_ib_mr *mr, int access_flags, int mr_id)
-{
-
- struct proc_dir_entry *mr_proc_entry;
- mode_t mode = S_IFREG;
- char name_buff[16];
-
- mode |= convert_shared_access(access_flags);
- sprintf(name_buff, "%X", mr_id);
- mr->smr_info = kmalloc(sizeof(struct mlx4_shared_mr_info), GFP_KERNEL);
- mr->smr_info->mr_id = mr_id;
- mr->smr_info->umem = mr->umem;
-
- mr_proc_entry = proc_create_data(name_buff, mode,
- mlx4_mrs_dir_entry,
- &shared_mr_proc_ops,
- mr->smr_info);
-
- if (!mr_proc_entry) {
- pr_err("prepare_shared_mr failed via proc\n");
- kfree(mr->smr_info);
- return -ENODEV;
- }
-
- current_uid_gid(&(mr_proc_entry->uid), &(mr_proc_entry->gid));
- mr_proc_entry->size = mr->umem->length;
- return 0;
-
-}
-static int is_shared_mr(int access_flags)
-{
- /* We should check whether IB_ACCESS_SHARED_MR_USER_READ or
- other shared bits were turned on.
- */
- return !!(access_flags & (IB_ACCESS_SHARED_MR_USER_READ |
- IB_ACCESS_SHARED_MR_USER_WRITE |
- IB_ACCESS_SHARED_MR_GROUP_READ |
- IB_ACCESS_SHARED_MR_GROUP_WRITE |
- IB_ACCESS_SHARED_MR_OTHER_READ |
- IB_ACCESS_SHARED_MR_OTHER_WRITE));
-
-}
-
-static void free_smr_info(struct mlx4_ib_mr *mr)
-{
- /* When master/parent shared mr is dereged there is
- no ability to share this mr any more - its mr_id will be
- returned to the kernel as part of ib_uverbs_dereg_mr
- and may be allocated again as part of other reg_mr.
- */
- char name_buff[16];
-
- sprintf(name_buff, "%X", mr->smr_info->mr_id);
- /* Remove proc entry is checking internally that no operation
- was strated on that proc fs file and if in the middle
- current process will wait till end of operation.
- That's why no sync mechanism is needed when we release
- below the shared umem.
- */
- remove_proc_entry(name_buff, mlx4_mrs_dir_entry);
- kfree(mr->smr_info);
- mr->smr_info = NULL;
-}
-#endif
-
-static void mlx4_invalidate_umem(void *invalidation_cookie,
- struct ib_umem *umem,
- unsigned long addr, size_t size)
-{
- struct mlx4_ib_mr *mr = (struct mlx4_ib_mr *)invalidation_cookie;
-
- /* This function is called under client peer lock so its resources are race protected */
- if (atomic_inc_return(&mr->invalidated) > 1) {
- umem->invalidation_ctx->inflight_invalidation = 1;
- goto end;
- }
-
- umem->invalidation_ctx->peer_callback = 1;
- mlx4_mr_free(to_mdev(mr->ibmr.device)->dev, &mr->mmr);
- ib_umem_release(umem);
- complete(&mr->invalidation_comp);
-
-end:
- return;
-
-}
-
struct ib_mr *mlx4_ib_reg_user_mr(struct ib_pd *pd, u64 start, u64 length,
u64 virt_addr, int access_flags,
- struct ib_udata *udata,
- int mr_id)
+ struct ib_udata *udata)
{
struct mlx4_ib_dev *dev = to_mdev(pd->device);
struct mlx4_ib_mr *mr;
int shift;
int err;
int n;
- struct ib_peer_memory_client *ib_peer_mem;
- mr = kzalloc(sizeof *mr, GFP_KERNEL);
+ mr = kzalloc(sizeof(*mr), GFP_KERNEL);
if (!mr)
return ERR_PTR(-ENOMEM);
- mr->umem = ib_umem_get_ex(pd->uobject->context, start, length,
- access_flags, 0, 1);
+ /* Force registering the memory as writable. */
+ /* Used for memory re-registeration. HCA protects the access */
+ mr->umem = ib_umem_get(pd->uobject->context, start, length,
+ access_flags | IB_ACCESS_LOCAL_WRITE, 0);
if (IS_ERR(mr->umem)) {
err = PTR_ERR(mr->umem);
goto err_free;
}
- ib_peer_mem = mr->umem->ib_peer_mem;
n = ib_umem_page_count(mr->umem);
- shift = mlx4_ib_umem_calc_optimal_mtt_size(mr->umem, start,
- &n);
+ shift = ilog2(mr->umem->page_size);
+
err = mlx4_mr_alloc(dev->dev, to_mpd(pd)->pdn, virt_addr, length,
- convert_access(access_flags), n, shift, &mr->mmr);
+ convert_access(access_flags), n, shift, &mr->mmr);
if (err)
goto err_umem;
@@ -560,46 +174,9 @@ struct ib_mr *mlx4_ib_reg_user_mr(struct ib_pd *pd, u64 start, u64 length,
goto err_mr;
mr->ibmr.rkey = mr->ibmr.lkey = mr->mmr.key;
-/* No suuport for Shared MR */
-#if 0
- /* Check whether MR should be shared */
- if (is_shared_mr(access_flags)) {
- /* start address and length must be aligned to page size in order
- to map a full page and preventing leakage of data */
- if (mr->umem->offset || (length & ~PAGE_MASK)) {
- err = -EINVAL;
- goto err_mr;
- }
- err = prepare_shared_mr(mr, access_flags, mr_id);
- if (err)
- goto err_mr;
- }
-#endif
- if (ib_peer_mem) {
- if (access_flags & IB_ACCESS_MW_BIND) {
- /* Prevent binding MW on peer clients.
- * mlx4_invalidate_umem must be void,
- * therefore, mlx4_mr_free should not fail
- * when using peer clients. */
- err = -ENOSYS;
- pr_err("MW is not supported with peer memory client");
- goto err_smr;
- }
- init_completion(&mr->invalidation_comp);
- ib_umem_activate_invalidation_notifier(mr->umem,
- mlx4_invalidate_umem, mr);
- }
-
- atomic_set(&mr->invalidated, 0);
return &mr->ibmr;
-err_smr:
-/* No suuport for Shared MR */
-#if 0
- if (mr->smr_info)
- free_smr_info(mr);
-#endif
err_mr:
(void) mlx4_mr_free(to_mdev(pd->device)->dev, &mr->mmr);
@@ -612,44 +189,159 @@ err_free:
return ERR_PTR(err);
}
-int mlx4_ib_dereg_mr(struct ib_mr *ibmr)
+int mlx4_ib_rereg_user_mr(struct ib_mr *mr, int flags,
+ u64 start, u64 length, u64 virt_addr,
+ int mr_access_flags, struct ib_pd *pd,
+ struct ib_udata *udata)
+{
+ struct mlx4_ib_dev *dev = to_mdev(mr->device);
+ struct mlx4_ib_mr *mmr = to_mmr(mr);
+ struct mlx4_mpt_entry *mpt_entry;
+ struct mlx4_mpt_entry **pmpt_entry = &mpt_entry;
+ int err;
+
+ /* Since we synchronize this call and mlx4_ib_dereg_mr via uverbs,
+ * we assume that the calls can't run concurrently. Otherwise, a
+ * race exists.
+ */
+ err = mlx4_mr_hw_get_mpt(dev->dev, &mmr->mmr, &pmpt_entry);
+
+ if (err)
+ return err;
+
+ if (flags & IB_MR_REREG_PD) {
+ err = mlx4_mr_hw_change_pd(dev->dev, *pmpt_entry,
+ to_mpd(pd)->pdn);
+
+ if (err)
+ goto release_mpt_entry;
+ }
+
+ if (flags & IB_MR_REREG_ACCESS) {
+ err = mlx4_mr_hw_change_access(dev->dev, *pmpt_entry,
+ convert_access(mr_access_flags));
+
+ if (err)
+ goto release_mpt_entry;
+ }
+
+ if (flags & IB_MR_REREG_TRANS) {
+ int shift;
+ int n;
+
+ mlx4_mr_rereg_mem_cleanup(dev->dev, &mmr->mmr);
+ ib_umem_release(mmr->umem);
+ mmr->umem = ib_umem_get(mr->uobject->context, start, length,
+ mr_access_flags |
+ IB_ACCESS_LOCAL_WRITE,
+ 0);
+ if (IS_ERR(mmr->umem)) {
+ err = PTR_ERR(mmr->umem);
+ /* Prevent mlx4_ib_dereg_mr from free'ing invalid pointer */
+ mmr->umem = NULL;
+ goto release_mpt_entry;
+ }
+ n = ib_umem_page_count(mmr->umem);
+ shift = ilog2(mmr->umem->page_size);
+
+ err = mlx4_mr_rereg_mem_write(dev->dev, &mmr->mmr,
+ virt_addr, length, n, shift,
+ *pmpt_entry);
+ if (err) {
+ ib_umem_release(mmr->umem);
+ goto release_mpt_entry;
+ }
+ mmr->mmr.iova = virt_addr;
+ mmr->mmr.size = length;
+
+ err = mlx4_ib_umem_write_mtt(dev, &mmr->mmr.mtt, mmr->umem);
+ if (err) {
+ mlx4_mr_rereg_mem_cleanup(dev->dev, &mmr->mmr);
+ ib_umem_release(mmr->umem);
+ goto release_mpt_entry;
+ }
+ }
+
+ /* If we couldn't transfer the MR to the HCA, just remember to
+ * return a failure. But dereg_mr will free the resources.
+ */
+ err = mlx4_mr_hw_write_mpt(dev->dev, &mmr->mmr, pmpt_entry);
+ if (!err && flags & IB_MR_REREG_ACCESS)
+ mmr->mmr.access = mr_access_flags;
+
+release_mpt_entry:
+ mlx4_mr_hw_put_mpt(dev->dev, pmpt_entry);
+
+ return err;
+}
+
+static int
+mlx4_alloc_priv_pages(struct ib_device *device,
+ struct mlx4_ib_mr *mr,
+ int max_pages)
{
- struct mlx4_ib_mr *mr = to_mmr(ibmr);
- struct ib_umem *umem = mr->umem;
int ret;
-/* No suuport for Shared MR */
-#if 0
- if (mr->smr_info)
- free_smr_info(mr);
-#endif
+ /* Ensure that size is aligned to DMA cacheline
+ * requirements.
+ * max_pages is limited to MLX4_MAX_FAST_REG_PAGES
+ * so page_map_size will never cross PAGE_SIZE.
+ */
+ mr->page_map_size = roundup(max_pages * sizeof(u64),
+ MLX4_MR_PAGES_ALIGN);
+
+ /* Prevent cross page boundary allocation. */
+ mr->pages = (__be64 *)get_zeroed_page(GFP_KERNEL);
+ if (!mr->pages)
+ return -ENOMEM;
- if (atomic_inc_return(&mr->invalidated) > 1) {
- wait_for_completion(&mr->invalidation_comp);
- goto end;
+ mr->page_map = dma_map_single(device->dma_device, mr->pages,
+ mr->page_map_size, DMA_TO_DEVICE);
+
+ if (dma_mapping_error(device->dma_device, mr->page_map)) {
+ ret = -ENOMEM;
+ goto err;
}
- ret = mlx4_mr_free(to_mdev(ibmr->device)->dev, &mr->mmr);
- if (ret) {
- /* Error is not expected here, except when memory windows
- * are bound to MR which is not supported with
- * peer memory clients */
- atomic_set(&mr->invalidated, 0);
- return ret;
+ return 0;
+
+err:
+ free_page((unsigned long)mr->pages);
+ return ret;
+}
+
+static void
+mlx4_free_priv_pages(struct mlx4_ib_mr *mr)
+{
+ if (mr->pages) {
+ struct ib_device *device = mr->ibmr.device;
+
+ dma_unmap_single(device->dma_device, mr->page_map,
+ mr->page_map_size, DMA_TO_DEVICE);
+ free_page((unsigned long)mr->pages);
+ mr->pages = NULL;
}
+}
- if (!umem)
- goto end;
+int mlx4_ib_dereg_mr(struct ib_mr *ibmr)
+{
+ struct mlx4_ib_mr *mr = to_mmr(ibmr);
+ int ret;
- ib_umem_release(mr->umem);
-end:
+ mlx4_free_priv_pages(mr);
+ ret = mlx4_mr_free(to_mdev(ibmr->device)->dev, &mr->mmr);
+ if (ret)
+ return ret;
+ if (mr->umem)
+ ib_umem_release(mr->umem);
kfree(mr);
return 0;
}
-struct ib_mw *mlx4_ib_alloc_mw(struct ib_pd *pd, enum ib_mw_type type)
+struct ib_mw *mlx4_ib_alloc_mw(struct ib_pd *pd, enum ib_mw_type type,
+ struct ib_udata *udata)
{
struct mlx4_ib_dev *dev = to_mdev(pd->device);
struct mlx4_ib_mw *mw;
@@ -659,7 +351,8 @@ struct ib_mw *mlx4_ib_alloc_mw(struct ib_pd *pd, enum ib_mw_type type)
if (!mw)
return ERR_PTR(-ENOMEM);
- err = mlx4_mw_alloc(dev->dev, to_mpd(pd)->pdn, (enum mlx4_mw_type)type, &mw->mmw);
+ err = mlx4_mw_alloc(dev->dev, to_mpd(pd)->pdn,
+ to_mlx4_type(type), &mw->mmw);
if (err)
goto err_free;
@@ -680,28 +373,6 @@ err_free:
return ERR_PTR(err);
}
-int mlx4_ib_bind_mw(struct ib_qp *qp, struct ib_mw *mw,
- struct ib_mw_bind *mw_bind)
-{
- struct ib_send_wr wr;
- struct ib_send_wr *bad_wr;
- int ret;
-
- memset(&wr, 0, sizeof(wr));
- wr.opcode = IB_WR_BIND_MW;
- wr.wr_id = mw_bind->wr_id;
- wr.send_flags = mw_bind->send_flags;
- wr.wr.bind_mw.mw = mw;
- wr.wr.bind_mw.bind_info = mw_bind->bind_info;
- wr.wr.bind_mw.rkey = ib_inc_rkey(mw->rkey);
-
- ret = mlx4_ib_post_send(qp, &wr, &bad_wr);
- if (!ret)
- mw->rkey = wr.wr.bind_mw.rkey;
-
- return ret;
-}
-
int mlx4_ib_dealloc_mw(struct ib_mw *ibmw)
{
struct mlx4_ib_mw *mw = to_mmw(ibmw);
@@ -712,85 +383,51 @@ int mlx4_ib_dealloc_mw(struct ib_mw *ibmw)
return 0;
}
-struct ib_mr *mlx4_ib_alloc_fast_reg_mr(struct ib_pd *pd,
- int max_page_list_len)
+struct ib_mr *mlx4_ib_alloc_mr(struct ib_pd *pd,
+ enum ib_mr_type mr_type,
+ u32 max_num_sg)
{
struct mlx4_ib_dev *dev = to_mdev(pd->device);
struct mlx4_ib_mr *mr;
int err;
- mr = kzalloc(sizeof *mr, GFP_KERNEL);
+ if (mr_type != IB_MR_TYPE_MEM_REG ||
+ max_num_sg > MLX4_MAX_FAST_REG_PAGES)
+ return ERR_PTR(-EINVAL);
+
+ mr = kzalloc(sizeof(*mr), GFP_KERNEL);
if (!mr)
return ERR_PTR(-ENOMEM);
err = mlx4_mr_alloc(dev->dev, to_mpd(pd)->pdn, 0, 0, 0,
- max_page_list_len, 0, &mr->mmr);
+ max_num_sg, 0, &mr->mmr);
if (err)
goto err_free;
+ err = mlx4_alloc_priv_pages(pd->device, mr, max_num_sg);
+ if (err)
+ goto err_free_mr;
+
+ mr->max_pages = max_num_sg;
+
err = mlx4_mr_enable(dev->dev, &mr->mmr);
if (err)
- goto err_mr;
+ goto err_free_pl;
mr->ibmr.rkey = mr->ibmr.lkey = mr->mmr.key;
mr->umem = NULL;
return &mr->ibmr;
-err_mr:
+err_free_pl:
+ mlx4_free_priv_pages(mr);
+err_free_mr:
(void) mlx4_mr_free(dev->dev, &mr->mmr);
-
err_free:
kfree(mr);
return ERR_PTR(err);
}
-struct ib_fast_reg_page_list *mlx4_ib_alloc_fast_reg_page_list(struct ib_device *ibdev,
- int page_list_len)
-{
- struct mlx4_ib_dev *dev = to_mdev(ibdev);
- struct mlx4_ib_fast_reg_page_list *mfrpl;
- int size = page_list_len * sizeof (u64);
-
- if (page_list_len > MLX4_MAX_FAST_REG_PAGES)
- return ERR_PTR(-EINVAL);
-
- mfrpl = kmalloc(sizeof *mfrpl, GFP_KERNEL);
- if (!mfrpl)
- return ERR_PTR(-ENOMEM);
-
- mfrpl->ibfrpl.page_list = kmalloc(size, GFP_KERNEL);
- if (!mfrpl->ibfrpl.page_list)
- goto err_free;
-
- mfrpl->mapped_page_list = dma_alloc_coherent(&dev->dev->persist->pdev->dev,
- size, &mfrpl->map,
- GFP_KERNEL);
- if (!mfrpl->mapped_page_list)
- goto err_free;
-
- WARN_ON(mfrpl->map & 0x3f);
-
- return &mfrpl->ibfrpl;
-
-err_free:
- kfree(mfrpl->ibfrpl.page_list);
- kfree(mfrpl);
- return ERR_PTR(-ENOMEM);
-}
-
-void mlx4_ib_free_fast_reg_page_list(struct ib_fast_reg_page_list *page_list)
-{
- struct mlx4_ib_dev *dev = to_mdev(page_list->device);
- struct mlx4_ib_fast_reg_page_list *mfrpl = to_mfrpl(page_list);
- int size = page_list->max_page_list_len * sizeof (u64);
-
- dma_free_coherent(&dev->dev->persist->pdev->dev, size, mfrpl->mapped_page_list,
- mfrpl->map);
- kfree(mfrpl->ibfrpl.page_list);
- kfree(mfrpl);
-}
-
struct ib_fmr *mlx4_ib_fmr_alloc(struct ib_pd *pd, int acc,
struct ib_fmr_attr *fmr_attr)
{
@@ -883,3 +520,135 @@ int mlx4_ib_fmr_dealloc(struct ib_fmr *ibfmr)
return err;
}
+
+static int mlx4_set_page(struct ib_mr *ibmr, u64 addr)
+{
+ struct mlx4_ib_mr *mr = to_mmr(ibmr);
+
+ if (unlikely(mr->npages == mr->max_pages))
+ return -ENOMEM;
+
+ mr->pages[mr->npages++] = cpu_to_be64(addr | MLX4_MTT_FLAG_PRESENT);
+
+ return 0;
+}
+
+int mlx4_ib_map_mr_sg(struct ib_mr *ibmr, struct scatterlist *sg, int sg_nents,
+ unsigned int *sg_offset)
+{
+ struct mlx4_ib_mr *mr = to_mmr(ibmr);
+ int rc;
+
+ mr->npages = 0;
+
+ ib_dma_sync_single_for_cpu(ibmr->device, mr->page_map,
+ mr->page_map_size, DMA_TO_DEVICE);
+
+ rc = ib_sg_to_pages(ibmr, sg, sg_nents, sg_offset, mlx4_set_page);
+
+ ib_dma_sync_single_for_device(ibmr->device, mr->page_map,
+ mr->page_map_size, DMA_TO_DEVICE);
+
+ return rc;
+}
+
+CTASSERT(sizeof(((struct ib_phys_buf *)0)->size) == 8);
+
+struct ib_mr *
+mlx4_ib_reg_phys_mr(struct ib_pd *pd,
+ struct ib_phys_buf *buffer_list,
+ int num_phys_buf,
+ int access_flags,
+ u64 *virt_addr)
+{
+ struct mlx4_ib_dev *dev = to_mdev(pd->device);
+ struct mlx4_ib_mr *mr;
+ u64 *pages;
+ u64 total_size;
+ unsigned long mask;
+ int shift;
+ int npages;
+ int err;
+ int i, j, n;
+
+ mask = buffer_list[0].addr ^ *virt_addr;
+ total_size = 0;
+ for (i = 0; i < num_phys_buf; ++i) {
+ if (i != 0)
+ mask |= buffer_list[i].addr;
+ if (i != num_phys_buf - 1)
+ mask |= buffer_list[i].addr + buffer_list[i].size;
+
+ total_size += buffer_list[i].size;
+ }
+
+ if (mask & ~PAGE_MASK)
+ return ERR_PTR(-EINVAL);
+
+ shift = __ffs(mask | 1 << 31);
+
+ buffer_list[0].size += buffer_list[0].addr & ((1ULL << shift) - 1);
+ buffer_list[0].addr &= ~0ULL << shift;
+
+ npages = 0;
+ for (i = 0; i < num_phys_buf; ++i)
+ npages += (buffer_list[i].size + (1ULL << shift) - 1) >> shift;
+
+ if (!npages)
+ return ERR_PTR(-EINVAL);
+
+ mr = kzalloc(sizeof *mr, GFP_KERNEL);
+ if (!mr)
+ return ERR_PTR(-ENOMEM);
+
+ pages = kzalloc(sizeof(pages[0]) * npages, GFP_KERNEL);
+ if (!pages) {
+ kfree(mr);
+ return ERR_PTR(-ENOMEM);
+ }
+
+ err = mlx4_mr_alloc(dev->dev, to_mpd(pd)->pdn, *virt_addr, total_size,
+ convert_access(access_flags), npages, shift, &mr->mmr);
+ if (err) {
+ kfree(mr);
+ kfree(pages);
+ return ERR_PTR(err);
+ }
+
+ n = 0;
+ for (i = 0; i < num_phys_buf; ++i) {
+ for (j = 0;
+ j < (buffer_list[i].size + (1ULL << shift) - 1) >> shift;
+ ++j) {
+ u64 temp = buffer_list[i].addr + ((u64) j << shift);
+ pages[n++] = temp;
+ }
+ }
+
+ mr->npages = npages;
+ mr->max_pages = npages;
+
+ err = mlx4_write_mtt(dev->dev, &mr->mmr.mtt, 0, npages, pages);
+ if (err)
+ goto err_mr;
+
+ err = mlx4_mr_enable(dev->dev, &mr->mmr);
+ if (err)
+ goto err_mr;
+
+ mr->umem = NULL;
+ mr->ibmr.lkey = mr->mmr.key;
+ mr->ibmr.rkey = mr->mmr.key;
+ mr->ibmr.length = total_size;
+
+ kfree(pages);
+
+ return &mr->ibmr;
+
+err_mr:
+ (void) mlx4_mr_free(dev->dev, &mr->mmr);
+ kfree(mr);
+ kfree(pages);
+
+ return ERR_PTR(err);
+}
diff --git a/sys/dev/mlx4/mlx4_ib/mlx4_ib_qp.c b/sys/dev/mlx4/mlx4_ib/mlx4_ib_qp.c
index 625f4b7..98c1a43 100644
--- a/sys/dev/mlx4/mlx4_ib/mlx4_ib_qp.c
+++ b/sys/dev/mlx4/mlx4_ib/mlx4_ib_qp.c
@@ -35,20 +35,26 @@
#include <linux/slab.h>
#include <linux/netdevice.h>
#include <linux/bitops.h>
+#include <linux/rcupdate.h>
+#include <linux/etherdevice.h>
#include <rdma/ib_cache.h>
#include <rdma/ib_pack.h>
#include <rdma/ib_addr.h>
#include <rdma/ib_mad.h>
+#include <dev/mlx4/cmd.h>
#include <dev/mlx4/qp.h>
#include <dev/mlx4/driver.h>
#include <linux/io.h>
#include "mlx4_ib.h"
-#include "user.h"
+#include <rdma/mlx4-abi.h>
-#define asm __asm
+static void mlx4_ib_lock_cqs(struct mlx4_ib_cq *send_cq,
+ struct mlx4_ib_cq *recv_cq);
+static void mlx4_ib_unlock_cqs(struct mlx4_ib_cq *send_cq,
+ struct mlx4_ib_cq *recv_cq);
enum {
MLX4_IB_ACK_REQ_FREQ = 8,
@@ -83,6 +89,7 @@ struct mlx4_ib_sqp {
u32 send_psn;
struct ib_ud_header ud_header;
u8 header_buf[MLX4_IB_UD_HEADER_SIZE];
+ struct ib_qp *roce_v2_gsi;
};
enum {
@@ -95,6 +102,10 @@ enum {
MLX4_RAW_QP_MSGMAX = 31,
};
+#ifndef ETH_ALEN
+#define ETH_ALEN 6
+#endif
+
static const __be32 mlx4_ib_opcode[] = {
[IB_WR_SEND] = cpu_to_be32(MLX4_OPCODE_SEND),
[IB_WR_LSO] = cpu_to_be32(MLX4_OPCODE_LSO),
@@ -106,25 +117,11 @@ static const __be32 mlx4_ib_opcode[] = {
[IB_WR_ATOMIC_FETCH_AND_ADD] = cpu_to_be32(MLX4_OPCODE_ATOMIC_FA),
[IB_WR_SEND_WITH_INV] = cpu_to_be32(MLX4_OPCODE_SEND_INVAL),
[IB_WR_LOCAL_INV] = cpu_to_be32(MLX4_OPCODE_LOCAL_INVAL),
- [IB_WR_FAST_REG_MR] = cpu_to_be32(MLX4_OPCODE_FMR),
+ [IB_WR_REG_MR] = cpu_to_be32(MLX4_OPCODE_FMR),
[IB_WR_MASKED_ATOMIC_CMP_AND_SWP] = cpu_to_be32(MLX4_OPCODE_MASKED_ATOMIC_CS),
[IB_WR_MASKED_ATOMIC_FETCH_AND_ADD] = cpu_to_be32(MLX4_OPCODE_MASKED_ATOMIC_FA),
- [IB_WR_BIND_MW] = cpu_to_be32(
- MLX4_OPCODE_BIND_MW),
};
-#ifndef wc_wmb
- #if defined(__i386__)
- #define wc_wmb() asm volatile("lock; addl $0,0(%%esp) " ::: "memory")
- #elif defined(__x86_64__)
- #define wc_wmb() asm volatile("sfence" ::: "memory")
- #elif defined(__ia64__)
- #define wc_wmb() asm volatile("fwb" ::: "memory")
- #else
- #define wc_wmb() wmb()
- #endif
-#endif
-
static struct mlx4_ib_sqp *to_msqp(struct mlx4_ib_qp *mqp)
{
return container_of(mqp, struct mlx4_ib_sqp, qp);
@@ -161,7 +158,10 @@ static int is_sqp(struct mlx4_ib_dev *dev, struct mlx4_ib_qp *qp)
}
}
}
- return proxy_sqp;
+ if (proxy_sqp)
+ return 1;
+
+ return !!(qp->flags & MLX4_IB_ROCE_V2_GSI_QP);
}
/* used for INIT/CLOSE port logic */
@@ -421,7 +421,8 @@ static int set_rq_size(struct mlx4_ib_dev *dev, struct ib_qp_cap *cap,
}
static int set_kernel_sq_size(struct mlx4_ib_dev *dev, struct ib_qp_cap *cap,
- enum mlx4_ib_qp_type type, struct mlx4_ib_qp *qp)
+ enum mlx4_ib_qp_type type, struct mlx4_ib_qp *qp,
+ bool shrink_wqe)
{
int s;
@@ -479,7 +480,7 @@ static int set_kernel_sq_size(struct mlx4_ib_dev *dev, struct ib_qp_cap *cap,
* We set WQE size to at least 64 bytes, this way stamping
* invalidates each WQE.
*/
- if (dev->dev->caps.fw_ver >= MLX4_FW_VER_WQE_CTRL_NEC &&
+ if (shrink_wqe && dev->dev->caps.fw_ver >= MLX4_FW_VER_WQE_CTRL_NEC &&
qp->sq_signal_bits && BITS_PER_LONG == 64 &&
type != MLX4_IB_QPT_SMI && type != MLX4_IB_QPT_GSI &&
!(type & (MLX4_IB_QPT_PROXY_SMI_OWNER | MLX4_IB_QPT_PROXY_SMI |
@@ -529,7 +530,8 @@ static int set_kernel_sq_size(struct mlx4_ib_dev *dev, struct ib_qp_cap *cap,
cap->max_send_sge = min(qp->sq.max_gs,
min(dev->dev->caps.max_sq_sg,
dev->dev->caps.max_rq_sg));
- qp->max_inline_data = cap->max_inline_data;
+ /* We don't support inline sends for kernel QPs (yet) */
+ cap->max_inline_data = 0;
return 0;
}
@@ -573,9 +575,7 @@ static int alloc_proxy_bufs(struct ib_device *dev, struct mlx4_ib_qp *qp)
ib_dma_map_single(dev, qp->sqp_proxy_rcv[i].addr,
sizeof (struct mlx4_ib_proxy_sqp_hdr),
DMA_FROM_DEVICE);
- if (unlikely(ib_dma_mapping_error(dev,
- qp->sqp_proxy_rcv[i].map))) {
- pr_warn("ib_dma_map_single failed\n");
+ if (ib_dma_mapping_error(dev, qp->sqp_proxy_rcv[i].map)) {
kfree(qp->sqp_proxy_rcv[i].addr);
goto err;
}
@@ -608,268 +608,49 @@ static void free_proxy_bufs(struct ib_device *dev, struct mlx4_ib_qp *qp)
kfree(qp->sqp_proxy_rcv);
}
-static int init_qpg_parent(struct mlx4_ib_dev *dev, struct mlx4_ib_qp *pqp,
- struct ib_qp_init_attr *attr, int *qpn)
-{
- struct mlx4_ib_qpg_data *qpg_data;
- int tss_num, rss_num;
- int tss_align_num, rss_align_num;
- int tss_base, rss_base = 0;
- int err;
-
- /* Parent is part of the TSS range (in SW TSS ARP is sent via parent) */
- tss_num = 1 + attr->parent_attrib.tss_child_count;
- tss_align_num = roundup_pow_of_two(tss_num);
- rss_num = attr->parent_attrib.rss_child_count;
- rss_align_num = roundup_pow_of_two(rss_num);
-
- if (rss_num > 1) {
- /* RSS is requested */
- if (!(dev->dev->caps.flags2 & MLX4_DEV_CAP_FLAG2_RSS))
- return -ENOSYS;
- if (rss_align_num > dev->dev->caps.max_rss_tbl_sz)
- return -EINVAL;
- /* We must work with power of two */
- attr->parent_attrib.rss_child_count = rss_align_num;
- }
-
- qpg_data = kzalloc(sizeof *qpg_data, GFP_KERNEL);
- if (!qpg_data)
- return -ENOMEM;
-
- if(pqp->flags & MLX4_IB_QP_NETIF)
- err = mlx4_ib_steer_qp_alloc(dev, tss_align_num, &tss_base);
- else
- err = mlx4_qp_reserve_range(dev->dev, tss_align_num,
- tss_align_num, &tss_base, MLX4_RESERVE_ETH_BF_QP);
- if (err)
- goto err1;
-
- if (tss_num > 1) {
- u32 alloc = BITS_TO_LONGS(tss_align_num) * sizeof(long);
- qpg_data->tss_bitmap = kzalloc(alloc, GFP_KERNEL);
- if (qpg_data->tss_bitmap == NULL) {
- err = -ENOMEM;
- goto err2;
- }
- bitmap_fill(qpg_data->tss_bitmap, tss_num);
- /* Note parent takes first index */
- clear_bit(0, qpg_data->tss_bitmap);
- }
-
- if (rss_num > 1) {
- u32 alloc = BITS_TO_LONGS(rss_align_num) * sizeof(long);
- err = mlx4_qp_reserve_range(dev->dev, rss_align_num,
- 1, &rss_base, 0);
- if (err)
- goto err3;
- qpg_data->rss_bitmap = kzalloc(alloc, GFP_KERNEL);
- if (qpg_data->rss_bitmap == NULL) {
- err = -ENOMEM;
- goto err4;
- }
- bitmap_fill(qpg_data->rss_bitmap, rss_align_num);
- }
-
- qpg_data->tss_child_count = attr->parent_attrib.tss_child_count;
- qpg_data->rss_child_count = attr->parent_attrib.rss_child_count;
- qpg_data->qpg_parent = pqp;
- qpg_data->qpg_tss_mask_sz = ilog2(tss_align_num);
- qpg_data->tss_qpn_base = tss_base;
- qpg_data->rss_qpn_base = rss_base;
-
- pqp->qpg_data = qpg_data;
- *qpn = tss_base;
-
- return 0;
-
-err4:
- mlx4_qp_release_range(dev->dev, rss_base, rss_align_num);
-
-err3:
- if (tss_num > 1)
- kfree(qpg_data->tss_bitmap);
-
-err2:
- if(pqp->flags & MLX4_IB_QP_NETIF)
- mlx4_ib_steer_qp_free(dev, tss_base, tss_align_num);
- else
- mlx4_qp_release_range(dev->dev, tss_base, tss_align_num);
-
-err1:
- kfree(qpg_data);
- return err;
-}
-
-static void free_qpg_parent(struct mlx4_ib_dev *dev, struct mlx4_ib_qp *pqp)
-{
- struct mlx4_ib_qpg_data *qpg_data = pqp->qpg_data;
- int align_num;
-
- if (qpg_data->tss_child_count > 1)
- kfree(qpg_data->tss_bitmap);
-
- align_num = roundup_pow_of_two(1 + qpg_data->tss_child_count);
- if(pqp->flags & MLX4_IB_QP_NETIF)
- mlx4_ib_steer_qp_free(dev, qpg_data->tss_qpn_base, align_num);
- else
- mlx4_qp_release_range(dev->dev, qpg_data->tss_qpn_base, align_num);
-
- if (qpg_data->rss_child_count > 1) {
- kfree(qpg_data->rss_bitmap);
- align_num = roundup_pow_of_two(qpg_data->rss_child_count);
- mlx4_qp_release_range(dev->dev, qpg_data->rss_qpn_base,
- align_num);
- }
-
- kfree(qpg_data);
-}
-
-static int alloc_qpg_qpn(struct ib_qp_init_attr *init_attr,
- struct mlx4_ib_qp *pqp, int *qpn)
+static int qp_has_rq(struct ib_qp_init_attr *attr)
{
- struct mlx4_ib_qp *mqp = to_mqp(init_attr->qpg_parent);
- struct mlx4_ib_qpg_data *qpg_data = mqp->qpg_data;
- u32 idx, old;
-
- switch (init_attr->qpg_type) {
- case IB_QPG_CHILD_TX:
- if (qpg_data->tss_child_count == 0)
- return -EINVAL;
- do {
- /* Parent took index 0 */
- idx = find_first_bit(qpg_data->tss_bitmap,
- qpg_data->tss_child_count + 1);
- if (idx >= qpg_data->tss_child_count + 1)
- return -ENOMEM;
- old = test_and_clear_bit(idx, qpg_data->tss_bitmap);
- } while (old == 0);
- idx += qpg_data->tss_qpn_base;
- break;
- case IB_QPG_CHILD_RX:
- if (qpg_data->rss_child_count == 0)
- return -EINVAL;
- do {
- idx = find_first_bit(qpg_data->rss_bitmap,
- qpg_data->rss_child_count);
- if (idx >= qpg_data->rss_child_count)
- return -ENOMEM;
- old = test_and_clear_bit(idx, qpg_data->rss_bitmap);
- } while (old == 0);
- idx += qpg_data->rss_qpn_base;
- break;
- default:
- return -EINVAL;
- }
-
- pqp->qpg_data = qpg_data;
- *qpn = idx;
+ if (attr->qp_type == IB_QPT_XRC_INI || attr->qp_type == IB_QPT_XRC_TGT)
+ return 0;
- return 0;
+ return !attr->srq;
}
-static void free_qpg_qpn(struct mlx4_ib_qp *mqp, int qpn)
+static int qp0_enabled_vf(struct mlx4_dev *dev, int qpn)
{
- struct mlx4_ib_qpg_data *qpg_data = mqp->qpg_data;
-
- switch (mqp->qpg_type) {
- case IB_QPG_CHILD_TX:
- /* Do range check */
- qpn -= qpg_data->tss_qpn_base;
- set_bit(qpn, qpg_data->tss_bitmap);
- break;
- case IB_QPG_CHILD_RX:
- qpn -= qpg_data->rss_qpn_base;
- set_bit(qpn, qpg_data->rss_bitmap);
- break;
- default:
- /* error */
- pr_warn("wrong qpg type (%d)\n", mqp->qpg_type);
- break;
- }
-}
-
-static int alloc_qpn_common(struct mlx4_ib_dev *dev, struct mlx4_ib_qp *qp,
- struct ib_qp_init_attr *attr, int *qpn)
-{
- int err = 0;
-
- switch (attr->qpg_type) {
- case IB_QPG_NONE:
- /* Raw packet QPNs may not have bits 6,7 set in their qp_num;
- * otherwise, the WQE BlueFlame setup flow wrongly causes
- * VLAN insertion. */
- if (attr->qp_type == IB_QPT_RAW_PACKET) {
- err = mlx4_qp_reserve_range(dev->dev, 1, 1, qpn,
- MLX4_RESERVE_ETH_BF_QP);
- } else {
- if(qp->flags & MLX4_IB_QP_NETIF)
- err = mlx4_ib_steer_qp_alloc(dev, 1, qpn);
- else
- err = mlx4_qp_reserve_range(dev->dev, 1, 1, qpn, 0);
- }
- break;
- case IB_QPG_PARENT:
- err = init_qpg_parent(dev, qp, attr, qpn);
- break;
- case IB_QPG_CHILD_TX:
- case IB_QPG_CHILD_RX:
- err = alloc_qpg_qpn(attr, qp, qpn);
- break;
- default:
- qp->qpg_type = IB_QPG_NONE;
- err = -EINVAL;
- break;
+ int i;
+ for (i = 0; i < dev->caps.num_ports; i++) {
+ if (qpn == dev->caps.qp0_proxy[i])
+ return !!dev->caps.qp0_qkey[i];
}
- if (err)
- return err;
- qp->qpg_type = attr->qpg_type;
return 0;
}
-static void free_qpn_common(struct mlx4_ib_dev *dev, struct mlx4_ib_qp *qp,
- enum ib_qpg_type qpg_type, int qpn)
+static void mlx4_ib_free_qp_counter(struct mlx4_ib_dev *dev,
+ struct mlx4_ib_qp *qp)
{
- switch (qpg_type) {
- case IB_QPG_NONE:
- if (qp->flags & MLX4_IB_QP_NETIF)
- mlx4_ib_steer_qp_free(dev, qpn, 1);
- else
- mlx4_qp_release_range(dev->dev, qpn, 1);
- break;
- case IB_QPG_PARENT:
- free_qpg_parent(dev, qp);
- break;
- case IB_QPG_CHILD_TX:
- case IB_QPG_CHILD_RX:
- free_qpg_qpn(qp, qpn);
- break;
- default:
- break;
- }
-}
+ mutex_lock(&dev->counters_table[qp->port - 1].mutex);
+ mlx4_counter_free(dev->dev, qp->counter_index->index);
+ list_del(&qp->counter_index->list);
+ mutex_unlock(&dev->counters_table[qp->port - 1].mutex);
-/* Revert allocation on create_qp_common */
-static void unalloc_qpn_common(struct mlx4_ib_dev *dev, struct mlx4_ib_qp *qp,
- struct ib_qp_init_attr *attr, int qpn)
-{
- free_qpn_common(dev, qp, attr->qpg_type, qpn);
-}
-
-static void release_qpn_common(struct mlx4_ib_dev *dev, struct mlx4_ib_qp *qp)
-{
- free_qpn_common(dev, qp, qp->qpg_type, qp->mqp.qpn);
+ kfree(qp->counter_index);
+ qp->counter_index = NULL;
}
static int create_qp_common(struct mlx4_ib_dev *dev, struct ib_pd *pd,
struct ib_qp_init_attr *init_attr,
- struct ib_udata *udata, int sqpn, struct mlx4_ib_qp **caller_qp)
+ struct ib_udata *udata, int sqpn, struct mlx4_ib_qp **caller_qp,
+ gfp_t gfp)
{
int qpn;
int err;
+ struct ib_qp_cap backup_cap;
struct mlx4_ib_sqp *sqp;
struct mlx4_ib_qp *qp;
enum mlx4_ib_qp_type qp_type = (enum mlx4_ib_qp_type) init_attr->qp_type;
+ struct mlx4_ib_cq *mcq;
+ unsigned long flags;
/* When tunneling special qps, we use a plain UD qp */
if (sqpn) {
@@ -878,10 +659,13 @@ static int create_qp_common(struct mlx4_ib_dev *dev, struct ib_pd *pd,
!(init_attr->create_flags & MLX4_IB_SRIOV_SQP))) {
if (init_attr->qp_type == IB_QPT_GSI)
qp_type = MLX4_IB_QPT_PROXY_GSI;
- else if (mlx4_is_master(dev->dev))
- qp_type = MLX4_IB_QPT_PROXY_SMI_OWNER;
- else
- qp_type = MLX4_IB_QPT_PROXY_SMI;
+ else {
+ if (mlx4_is_master(dev->dev) ||
+ qp0_enabled_vf(dev->dev, sqpn))
+ qp_type = MLX4_IB_QPT_PROXY_SMI_OWNER;
+ else
+ qp_type = MLX4_IB_QPT_PROXY_SMI;
+ }
}
qpn = sqpn;
/* add extra sg entry for tunneling */
@@ -896,7 +680,9 @@ static int create_qp_common(struct mlx4_ib_dev *dev, struct ib_pd *pd,
return -EINVAL;
if (tnl_init->proxy_qp_type == IB_QPT_GSI)
qp_type = MLX4_IB_QPT_TUN_GSI;
- else if (tnl_init->slave == mlx4_master_func_num(dev->dev))
+ else if (tnl_init->slave == mlx4_master_func_num(dev->dev) ||
+ mlx4_vf_smi_enabled(dev->dev, tnl_init->slave,
+ tnl_init->port))
qp_type = MLX4_IB_QPT_TUN_SMI_OWNER;
else
qp_type = MLX4_IB_QPT_TUN_SMI;
@@ -911,73 +697,46 @@ static int create_qp_common(struct mlx4_ib_dev *dev, struct ib_pd *pd,
if (qp_type == MLX4_IB_QPT_SMI || qp_type == MLX4_IB_QPT_GSI ||
(qp_type & (MLX4_IB_QPT_PROXY_SMI | MLX4_IB_QPT_PROXY_SMI_OWNER |
MLX4_IB_QPT_PROXY_GSI | MLX4_IB_QPT_TUN_SMI_OWNER))) {
- sqp = kzalloc(sizeof (struct mlx4_ib_sqp), GFP_KERNEL);
+ sqp = kzalloc(sizeof (struct mlx4_ib_sqp), gfp);
if (!sqp)
return -ENOMEM;
qp = &sqp->qp;
- qp->pri.vid = qp->alt.vid = 0xFFFF;
+ qp->pri.vid = 0xFFFF;
+ qp->alt.vid = 0xFFFF;
} else {
- qp = kzalloc(sizeof (struct mlx4_ib_qp), GFP_KERNEL);
+ qp = kzalloc(sizeof (struct mlx4_ib_qp), gfp);
if (!qp)
return -ENOMEM;
- qp->pri.vid = qp->alt.vid = 0xFFFF;
+ qp->pri.vid = 0xFFFF;
+ qp->alt.vid = 0xFFFF;
}
} else
qp = *caller_qp;
qp->mlx4_ib_qp_type = qp_type;
- if (init_attr->create_flags & IB_QP_CREATE_BLOCK_MULTICAST_LOOPBACK)
- qp->flags |= MLX4_IB_QP_BLOCK_MULTICAST_LOOPBACK;
-
- if (init_attr->create_flags & IB_QP_CREATE_IPOIB_UD_LSO)
- qp->flags |= MLX4_IB_QP_LSO;
-
- if (init_attr->create_flags & IB_QP_CREATE_NETIF_QP) {
- if (dev->dev->caps.steering_mode ==
- MLX4_STEERING_MODE_DEVICE_MANAGED &&
- !mlx4_is_mfunc(dev->dev))
- qp->flags |= MLX4_IB_QP_NETIF;
- else {
- err = -EINVAL;
- goto err;
- }
- }
-
mutex_init(&qp->mutex);
spin_lock_init(&qp->sq.lock);
spin_lock_init(&qp->rq.lock);
INIT_LIST_HEAD(&qp->gid_list);
INIT_LIST_HEAD(&qp->steering_rules);
- INIT_LIST_HEAD(&qp->rules_list);
qp->state = IB_QPS_RESET;
if (init_attr->sq_sig_type == IB_SIGNAL_ALL_WR)
qp->sq_signal_bits = cpu_to_be32(MLX4_WQE_CTRL_CQ_UPDATE);
- err = set_rq_size(dev, &init_attr->cap, !!pd->uobject, mlx4_ib_qp_has_rq(init_attr), qp);
+ err = set_rq_size(dev, &init_attr->cap, !!pd->uobject, qp_has_rq(init_attr), qp);
if (err)
goto err;
if (pd->uobject) {
struct mlx4_ib_create_qp ucmd;
- int shift;
- int n;
- if (!udata || ib_copy_from_udata(&ucmd, udata, sizeof(ucmd))) {
+ if (ib_copy_from_udata(&ucmd, udata, sizeof ucmd)) {
err = -EFAULT;
goto err;
}
- if (init_attr->create_flags & IB_QP_CREATE_CROSS_CHANNEL)
- qp->flags |= MLX4_IB_QP_CAP_CROSS_CHANNEL;
-
- if (init_attr->create_flags & IB_QP_CREATE_MANAGED_SEND)
- qp->flags |= MLX4_IB_QP_CAP_MANAGED_SEND;
-
- if (init_attr->create_flags & IB_QP_CREATE_MANAGED_RECV)
- qp->flags |= MLX4_IB_QP_CAP_MANAGED_RECV;
-
qp->sq_no_prefetch = ucmd.sq_no_prefetch;
err = set_user_sq_size(dev, qp, &ucmd);
@@ -991,10 +750,8 @@ static int create_qp_common(struct mlx4_ib_dev *dev, struct ib_pd *pd,
goto err;
}
- n = ib_umem_page_count(qp->umem);
- shift = mlx4_ib_umem_calc_optimal_mtt_size(qp->umem, 0, &n);
- err = mlx4_mtt_init(dev->dev, n, shift, &qp->mtt);
-
+ err = mlx4_mtt_init(dev->dev, ib_umem_page_count(qp->umem),
+ ilog2(qp->umem->page_size), &qp->mtt);
if (err)
goto err_buf;
@@ -1002,7 +759,7 @@ static int create_qp_common(struct mlx4_ib_dev *dev, struct ib_pd *pd,
if (err)
goto err_mtt;
- if (mlx4_ib_qp_has_rq(init_attr)) {
+ if (qp_has_rq(init_attr)) {
err = mlx4_ib_db_map_user(to_mucontext(pd->uobject->context),
ucmd.db_addr, &qp->db);
if (err)
@@ -1011,31 +768,45 @@ static int create_qp_common(struct mlx4_ib_dev *dev, struct ib_pd *pd,
} else {
qp->sq_no_prefetch = 0;
- err = set_kernel_sq_size(dev, &init_attr->cap, qp_type, qp);
+ if (init_attr->create_flags & IB_QP_CREATE_IPOIB_UD_LSO)
+ qp->flags |= MLX4_IB_QP_LSO;
+
+ if (init_attr->create_flags & IB_QP_CREATE_NETIF_QP) {
+ if (dev->steering_support ==
+ MLX4_STEERING_MODE_DEVICE_MANAGED)
+ qp->flags |= MLX4_IB_QP_NETIF;
+ else
+ goto err;
+ }
+
+ memcpy(&backup_cap, &init_attr->cap, sizeof(backup_cap));
+ err = set_kernel_sq_size(dev, &init_attr->cap,
+ qp_type, qp, true);
if (err)
goto err;
- if (mlx4_ib_qp_has_rq(init_attr)) {
- err = mlx4_db_alloc(dev->dev, &qp->db, 0, GFP_KERNEL);
+ if (qp_has_rq(init_attr)) {
+ err = mlx4_db_alloc(dev->dev, &qp->db, 0, gfp);
if (err)
goto err;
*qp->db.db = 0;
}
- if (qp->max_inline_data) {
- err = mlx4_bf_alloc(dev->dev, &qp->bf, 0);
- if (err) {
- pr_debug("failed to allocate blue flame"
- " register (%d)", err);
- qp->bf.uar = &dev->priv_uar;
- }
- } else
- qp->bf.uar = &dev->priv_uar;
+ if (mlx4_buf_alloc(dev->dev, qp->buf_size, qp->buf_size,
+ &qp->buf, gfp)) {
+ memcpy(&init_attr->cap, &backup_cap,
+ sizeof(backup_cap));
+ err = set_kernel_sq_size(dev, &init_attr->cap, qp_type,
+ qp, false);
+ if (err)
+ goto err_db;
- if (mlx4_buf_alloc(dev->dev, qp->buf_size, PAGE_SIZE * 2, &qp->buf, GFP_KERNEL)) {
- err = -ENOMEM;
- goto err_db;
+ if (mlx4_buf_alloc(dev->dev, qp->buf_size,
+ PAGE_SIZE * 2, &qp->buf, gfp)) {
+ err = -ENOMEM;
+ goto err_db;
+ }
}
err = mlx4_mtt_init(dev->dev, qp->buf.npages, qp->buf.page_shift,
@@ -1043,13 +814,20 @@ static int create_qp_common(struct mlx4_ib_dev *dev, struct ib_pd *pd,
if (err)
goto err_buf;
- err = mlx4_buf_write_mtt(dev->dev, &qp->mtt, &qp->buf, GFP_KERNEL);
+ err = mlx4_buf_write_mtt(dev->dev, &qp->mtt, &qp->buf, gfp);
if (err)
goto err_mtt;
- qp->sq.wrid = kmalloc(qp->sq.wqe_cnt * sizeof (u64), GFP_KERNEL);
- qp->rq.wrid = kmalloc(qp->rq.wqe_cnt * sizeof (u64), GFP_KERNEL);
-
+ qp->sq.wrid = kmalloc_array(qp->sq.wqe_cnt, sizeof(u64),
+ gfp | __GFP_NOWARN);
+ if (!qp->sq.wrid)
+ qp->sq.wrid = __vmalloc(qp->sq.wqe_cnt * sizeof(u64),
+ gfp, 0 /*PAGE_KERNEL*/);
+ qp->rq.wrid = kmalloc_array(qp->rq.wqe_cnt, sizeof(u64),
+ gfp | __GFP_NOWARN);
+ if (!qp->rq.wrid)
+ qp->rq.wrid = __vmalloc(qp->rq.wqe_cnt * sizeof(u64),
+ gfp, 0 /*PAGE_KERNEL*/);
if (!qp->sq.wrid || !qp->rq.wrid) {
err = -ENOMEM;
goto err_wrid;
@@ -1065,12 +843,29 @@ static int create_qp_common(struct mlx4_ib_dev *dev, struct ib_pd *pd,
}
}
} else {
- err = alloc_qpn_common(dev, qp, init_attr, &qpn);
+ /* Raw packet QPNs may not have bits 6,7 set in their qp_num;
+ * otherwise, the WQE BlueFlame setup flow wrongly causes
+ * VLAN insertion. */
+ if (init_attr->qp_type == IB_QPT_RAW_PACKET)
+ err = mlx4_qp_reserve_range(dev->dev, 1, 1, &qpn,
+ (init_attr->cap.max_send_wr ?
+ MLX4_RESERVE_ETH_BF_QP : 0) |
+ (init_attr->cap.max_recv_wr ?
+ MLX4_RESERVE_A0_QP : 0));
+ else
+ if (qp->flags & MLX4_IB_QP_NETIF)
+ err = mlx4_ib_steer_qp_alloc(dev, 1, &qpn);
+ else
+ err = mlx4_qp_reserve_range(dev->dev, 1, 1,
+ &qpn, 0);
if (err)
goto err_proxy;
}
- err = mlx4_qp_alloc(dev->dev, qpn, &qp->mqp, GFP_KERNEL);
+ if (init_attr->create_flags & IB_QP_CREATE_BLOCK_MULTICAST_LOOPBACK)
+ qp->flags |= MLX4_IB_QP_BLOCK_MULTICAST_LOOPBACK;
+
+ err = mlx4_qp_alloc(dev->dev, qpn, &qp->mqp, gfp);
if (err)
goto err_qpn;
@@ -1087,21 +882,43 @@ static int create_qp_common(struct mlx4_ib_dev *dev, struct ib_pd *pd,
qp->mqp.event = mlx4_ib_qp_event;
if (!*caller_qp)
*caller_qp = qp;
+
+ spin_lock_irqsave(&dev->reset_flow_resource_lock, flags);
+ mlx4_ib_lock_cqs(to_mcq(init_attr->send_cq),
+ to_mcq(init_attr->recv_cq));
+ /* Maintain device to QPs access, needed for further handling
+ * via reset flow
+ */
+ list_add_tail(&qp->qps_list, &dev->qp_list);
+ /* Maintain CQ to QPs access, needed for further handling
+ * via reset flow
+ */
+ mcq = to_mcq(init_attr->send_cq);
+ list_add_tail(&qp->cq_send_list, &mcq->send_qp_list);
+ mcq = to_mcq(init_attr->recv_cq);
+ list_add_tail(&qp->cq_recv_list, &mcq->recv_qp_list);
+ mlx4_ib_unlock_cqs(to_mcq(init_attr->send_cq),
+ to_mcq(init_attr->recv_cq));
+ spin_unlock_irqrestore(&dev->reset_flow_resource_lock, flags);
return 0;
err_qpn:
- unalloc_qpn_common(dev, qp, init_attr, qpn);
-
+ if (!sqpn) {
+ if (qp->flags & MLX4_IB_QP_NETIF)
+ mlx4_ib_steer_qp_free(dev, qpn, 1);
+ else
+ mlx4_qp_release_range(dev->dev, qpn, 1);
+ }
err_proxy:
if (qp->mlx4_ib_qp_type == MLX4_IB_QPT_PROXY_GSI)
free_proxy_bufs(pd->device, qp);
err_wrid:
if (pd->uobject) {
- if (mlx4_ib_qp_has_rq(init_attr))
+ if (qp_has_rq(init_attr))
mlx4_ib_db_unmap_user(to_mucontext(pd->uobject->context), &qp->db);
} else {
- kfree(qp->sq.wrid);
- kfree(qp->rq.wrid);
+ kvfree(qp->sq.wrid);
+ kvfree(qp->rq.wrid);
}
err_mtt:
@@ -1114,12 +931,9 @@ err_buf:
mlx4_buf_free(dev->dev, qp->buf_size, &qp->buf);
err_db:
- if (!pd->uobject && mlx4_ib_qp_has_rq(init_attr))
+ if (!pd->uobject && qp_has_rq(init_attr))
mlx4_db_free(dev->dev, &qp->db);
- if (qp->max_inline_data)
- mlx4_bf_free(dev->dev, &qp->bf);
-
err:
if (!*caller_qp)
kfree(qp);
@@ -1144,13 +958,13 @@ static void mlx4_ib_lock_cqs(struct mlx4_ib_cq *send_cq, struct mlx4_ib_cq *recv
__acquires(&send_cq->lock) __acquires(&recv_cq->lock)
{
if (send_cq == recv_cq) {
- spin_lock_irq(&send_cq->lock);
+ spin_lock(&send_cq->lock);
__acquire(&recv_cq->lock);
} else if (send_cq->mcq.cqn < recv_cq->mcq.cqn) {
- spin_lock_irq(&send_cq->lock);
+ spin_lock(&send_cq->lock);
spin_lock_nested(&recv_cq->lock, SINGLE_DEPTH_NESTING);
} else {
- spin_lock_irq(&recv_cq->lock);
+ spin_lock(&recv_cq->lock);
spin_lock_nested(&send_cq->lock, SINGLE_DEPTH_NESTING);
}
}
@@ -1160,13 +974,13 @@ static void mlx4_ib_unlock_cqs(struct mlx4_ib_cq *send_cq, struct mlx4_ib_cq *re
{
if (send_cq == recv_cq) {
__release(&recv_cq->lock);
- spin_unlock_irq(&send_cq->lock);
+ spin_unlock(&send_cq->lock);
} else if (send_cq->mcq.cqn < recv_cq->mcq.cqn) {
spin_unlock(&recv_cq->lock);
- spin_unlock_irq(&send_cq->lock);
+ spin_unlock(&send_cq->lock);
} else {
spin_unlock(&send_cq->lock);
- spin_unlock_irq(&recv_cq->lock);
+ spin_unlock(&recv_cq->lock);
}
}
@@ -1211,15 +1025,17 @@ static void destroy_qp_common(struct mlx4_ib_dev *dev, struct mlx4_ib_qp *qp,
int is_user)
{
struct mlx4_ib_cq *send_cq, *recv_cq;
+ unsigned long flags;
if (qp->state != IB_QPS_RESET) {
if (mlx4_qp_modify(dev->dev, NULL, to_mlx4_state(qp->state),
MLX4_QP_STATE_RST, NULL, 0, 0, &qp->mqp))
pr_warn("modify QP %06x to RESET failed.\n",
qp->mqp.qpn);
- if (qp->pri.smac) {
+ if (qp->pri.smac || (!qp->pri.smac && qp->pri.smac_port)) {
mlx4_unregister_mac(dev->dev, qp->pri.smac_port, qp->pri.smac);
qp->pri.smac = 0;
+ qp->pri.smac_port = 0;
}
if (qp->alt.smac) {
mlx4_unregister_mac(dev->dev, qp->alt.smac_port, qp->alt.smac);
@@ -1241,8 +1057,13 @@ static void destroy_qp_common(struct mlx4_ib_dev *dev, struct mlx4_ib_qp *qp,
get_cqs(qp, &send_cq, &recv_cq);
+ spin_lock_irqsave(&dev->reset_flow_resource_lock, flags);
mlx4_ib_lock_cqs(send_cq, recv_cq);
+ /* del from lists under both locks above to protect reset flow paths */
+ list_del(&qp->qps_list);
+ list_del(&qp->cq_send_list);
+ list_del(&qp->cq_recv_list);
if (!is_user) {
__mlx4_ib_cq_clean(recv_cq, qp->mqp.qpn,
qp->ibqp.srq ? to_msrq(qp->ibqp.srq): NULL);
@@ -1253,11 +1074,16 @@ static void destroy_qp_common(struct mlx4_ib_dev *dev, struct mlx4_ib_qp *qp,
mlx4_qp_remove(dev->dev, &qp->mqp);
mlx4_ib_unlock_cqs(send_cq, recv_cq);
+ spin_unlock_irqrestore(&dev->reset_flow_resource_lock, flags);
mlx4_qp_free(dev->dev, &qp->mqp);
- if (!is_sqp(dev, qp) && !is_tunnel_qp(dev, qp))
- release_qpn_common(dev, qp);
+ if (!is_sqp(dev, qp) && !is_tunnel_qp(dev, qp)) {
+ if (qp->flags & MLX4_IB_QP_NETIF)
+ mlx4_ib_steer_qp_free(dev, qp->mqp.qpn, 1);
+ else
+ mlx4_qp_release_range(dev->dev, qp->mqp.qpn, 1);
+ }
mlx4_mtt_cleanup(dev->dev, &qp->mtt);
@@ -1267,15 +1093,12 @@ static void destroy_qp_common(struct mlx4_ib_dev *dev, struct mlx4_ib_qp *qp,
&qp->db);
ib_umem_release(qp->umem);
} else {
- kfree(qp->sq.wrid);
- kfree(qp->rq.wrid);
+ kvfree(qp->sq.wrid);
+ kvfree(qp->rq.wrid);
if (qp->mlx4_ib_qp_type & (MLX4_IB_QPT_PROXY_SMI_OWNER |
MLX4_IB_QPT_PROXY_SMI | MLX4_IB_QPT_PROXY_GSI))
free_proxy_bufs(&dev->ib_dev, qp);
mlx4_buf_free(dev->dev, qp->buf_size, &qp->buf);
- if (qp->max_inline_data)
- mlx4_bf_free(dev->dev, &qp->bf);
-
if (qp->rq.wqe_cnt)
mlx4_db_free(dev->dev, &qp->db);
}
@@ -1300,136 +1123,51 @@ static u32 get_sqp_num(struct mlx4_ib_dev *dev, struct ib_qp_init_attr *attr)
return dev->dev->caps.qp1_proxy[attr->port_num - 1];
}
-static int check_qpg_attr(struct mlx4_ib_dev *dev,
- struct ib_qp_init_attr *attr)
-{
- if (attr->qpg_type == IB_QPG_NONE)
- return 0;
-
- if (attr->qp_type != IB_QPT_UD &&
- attr->qp_type != IB_QPT_RAW_PACKET)
- return -EINVAL;
-
- if (attr->qpg_type == IB_QPG_PARENT) {
- if (attr->parent_attrib.tss_child_count == 1)
- return -EINVAL; /* Doesn't make sense */
- if (attr->parent_attrib.rss_child_count == 1)
- return -EINVAL; /* Doesn't make sense */
- if ((attr->parent_attrib.tss_child_count == 0) &&
- (attr->parent_attrib.rss_child_count == 0))
- /* Should be called with IP_QPG_NONE */
- return -EINVAL;
- if (attr->parent_attrib.rss_child_count > 1) {
- int rss_align_num;
- if (!(dev->dev->caps.flags2 & MLX4_DEV_CAP_FLAG2_RSS))
- return -ENOSYS;
- rss_align_num = roundup_pow_of_two(
- attr->parent_attrib.rss_child_count);
- if (rss_align_num > dev->dev->caps.max_rss_tbl_sz)
- return -EINVAL;
- }
- } else {
- struct mlx4_ib_qpg_data *qpg_data;
- if (attr->qpg_parent == NULL)
- return -EINVAL;
- if (IS_ERR(attr->qpg_parent))
- return -EINVAL;
- qpg_data = to_mqp(attr->qpg_parent)->qpg_data;
- if (qpg_data == NULL)
- return -EINVAL;
- if (attr->qpg_type == IB_QPG_CHILD_TX &&
- !qpg_data->tss_child_count)
- return -EINVAL;
- if (attr->qpg_type == IB_QPG_CHILD_RX &&
- !qpg_data->rss_child_count)
- return -EINVAL;
- }
- return 0;
-}
-
-#define RESERVED_FLAGS_MASK ((((unsigned int)IB_QP_CREATE_RESERVED_END - 1) | IB_QP_CREATE_RESERVED_END) \
- & ~(IB_QP_CREATE_RESERVED_START - 1))
-
-static enum mlx4_ib_qp_flags to_mlx4_ib_qp_flags(enum ib_qp_create_flags ib_qp_flags)
-{
- enum mlx4_ib_qp_flags mlx4_ib_qp_flags = 0;
-
- if (ib_qp_flags & IB_QP_CREATE_IPOIB_UD_LSO)
- mlx4_ib_qp_flags |= MLX4_IB_QP_LSO;
-
- if (ib_qp_flags & IB_QP_CREATE_BLOCK_MULTICAST_LOOPBACK)
- mlx4_ib_qp_flags |= MLX4_IB_QP_BLOCK_MULTICAST_LOOPBACK;
-
- if (ib_qp_flags & IB_QP_CREATE_NETIF_QP)
- mlx4_ib_qp_flags |= MLX4_IB_QP_NETIF;
-
- if (ib_qp_flags & IB_QP_CREATE_CROSS_CHANNEL)
- mlx4_ib_qp_flags |= MLX4_IB_QP_CAP_CROSS_CHANNEL;
-
- if (ib_qp_flags & IB_QP_CREATE_MANAGED_SEND)
- mlx4_ib_qp_flags |= MLX4_IB_QP_CAP_MANAGED_SEND;
-
- if (ib_qp_flags & IB_QP_CREATE_MANAGED_RECV)
- mlx4_ib_qp_flags |= MLX4_IB_QP_CAP_MANAGED_RECV;
-
- /* reserved flags */
- mlx4_ib_qp_flags |= (ib_qp_flags & RESERVED_FLAGS_MASK);
-
- return mlx4_ib_qp_flags;
-}
-
-struct ib_qp *mlx4_ib_create_qp(struct ib_pd *pd,
- struct ib_qp_init_attr *init_attr,
- struct ib_udata *udata)
+static struct ib_qp *_mlx4_ib_create_qp(struct ib_pd *pd,
+ struct ib_qp_init_attr *init_attr,
+ struct ib_udata *udata)
{
struct mlx4_ib_qp *qp = NULL;
int err;
+ int sup_u_create_flags = MLX4_IB_QP_BLOCK_MULTICAST_LOOPBACK;
u16 xrcdn = 0;
- enum mlx4_ib_qp_flags mlx4_qp_flags = to_mlx4_ib_qp_flags(init_attr->create_flags);
- struct ib_device *device;
+ gfp_t gfp;
- /* see ib_core::ib_create_qp same handling */
- device = pd ? pd->device : init_attr->xrcd->device;
+ gfp = (init_attr->create_flags & MLX4_IB_QP_CREATE_USE_GFP_NOIO) ?
+ GFP_NOIO : GFP_KERNEL;
/*
* We only support LSO, vendor flag1, and multicast loopback blocking,
* and only for kernel UD QPs.
*/
- if (mlx4_qp_flags & ~(MLX4_IB_QP_LSO |
- MLX4_IB_QP_CAP_CROSS_CHANNEL |
- MLX4_IB_QP_CAP_MANAGED_SEND |
- MLX4_IB_QP_CAP_MANAGED_RECV |
+ if (init_attr->create_flags & ~(MLX4_IB_QP_LSO |
MLX4_IB_QP_BLOCK_MULTICAST_LOOPBACK |
- MLX4_IB_SRIOV_TUNNEL_QP | MLX4_IB_SRIOV_SQP |
- MLX4_IB_QP_NETIF))
+ MLX4_IB_SRIOV_TUNNEL_QP |
+ MLX4_IB_SRIOV_SQP |
+ MLX4_IB_QP_NETIF |
+ MLX4_IB_QP_CREATE_ROCE_V2_GSI |
+ MLX4_IB_QP_CREATE_USE_GFP_NOIO))
return ERR_PTR(-EINVAL);
if (init_attr->create_flags & IB_QP_CREATE_NETIF_QP) {
- if (init_attr->qp_type != IB_QPT_UD)
- return ERR_PTR(-EINVAL);
- }
-
- if (mlx4_qp_flags &
- (MLX4_IB_QP_CAP_CROSS_CHANNEL |
- MLX4_IB_QP_CAP_MANAGED_SEND |
- MLX4_IB_QP_CAP_MANAGED_RECV)) {
- pr_debug("%s Does not support cross-channel operations\n",
- to_mdev(device)->ib_dev.name);
- return ERR_PTR(-EINVAL);
+ if (init_attr->qp_type != IB_QPT_UD)
+ return ERR_PTR(-EINVAL);
}
- if ((init_attr->create_flags &
- ~(IB_QP_CREATE_CROSS_CHANNEL |
- IB_QP_CREATE_MANAGED_SEND |
- IB_QP_CREATE_MANAGED_RECV)) &&
- (((mlx4_qp_flags & ~MLX4_IB_SRIOV_SQP) &&
- init_attr->qp_type != IB_QPT_UD) ||
- ((mlx4_qp_flags & MLX4_IB_SRIOV_SQP) &&
- init_attr->qp_type > IB_QPT_GSI)))
- return ERR_PTR(-EINVAL);
+ if (init_attr->create_flags) {
+ if (udata && init_attr->create_flags & ~(sup_u_create_flags))
+ return ERR_PTR(-EINVAL);
- err = check_qpg_attr(to_mdev(device), init_attr);
- if (err)
- return ERR_PTR(err);
+ if ((init_attr->create_flags & ~(MLX4_IB_SRIOV_SQP |
+ MLX4_IB_QP_CREATE_USE_GFP_NOIO |
+ MLX4_IB_QP_CREATE_ROCE_V2_GSI |
+ MLX4_IB_QP_BLOCK_MULTICAST_LOOPBACK) &&
+ init_attr->qp_type != IB_QPT_UD) ||
+ (init_attr->create_flags & MLX4_IB_SRIOV_SQP &&
+ init_attr->qp_type > IB_QPT_GSI) ||
+ (init_attr->create_flags & MLX4_IB_QP_CREATE_ROCE_V2_GSI &&
+ init_attr->qp_type != IB_QPT_GSI))
+ return ERR_PTR(-EINVAL);
+ }
switch (init_attr->qp_type) {
case IB_QPT_XRC_TGT:
@@ -1438,21 +1176,23 @@ struct ib_qp *mlx4_ib_create_qp(struct ib_pd *pd,
init_attr->send_cq = to_mxrcd(init_attr->xrcd)->cq;
/* fall through */
case IB_QPT_XRC_INI:
- if (!(to_mdev(device)->dev->caps.flags & MLX4_DEV_CAP_FLAG_XRC))
+ if (!(to_mdev(pd->device)->dev->caps.flags & MLX4_DEV_CAP_FLAG_XRC))
return ERR_PTR(-ENOSYS);
init_attr->recv_cq = init_attr->send_cq;
/* fall through */
case IB_QPT_RC:
case IB_QPT_UC:
case IB_QPT_RAW_PACKET:
- qp = kzalloc(sizeof *qp, GFP_KERNEL);
+ qp = kzalloc(sizeof *qp, gfp);
if (!qp)
return ERR_PTR(-ENOMEM);
- qp->pri.vid = qp->alt.vid = 0xFFFF;
+ qp->pri.vid = 0xFFFF;
+ qp->alt.vid = 0xFFFF;
/* fall through */
case IB_QPT_UD:
{
- err = create_qp_common(to_mdev(device), pd, init_attr, udata, 0, &qp);
+ err = create_qp_common(to_mdev(pd->device), pd, init_attr,
+ udata, 0, &qp, gfp);
if (err) {
kfree(qp);
return ERR_PTR(err);
@@ -1466,19 +1206,29 @@ struct ib_qp *mlx4_ib_create_qp(struct ib_pd *pd,
case IB_QPT_SMI:
case IB_QPT_GSI:
{
+ int sqpn;
+
/* Userspace is not allowed to create special QPs: */
if (udata)
return ERR_PTR(-EINVAL);
+ if (init_attr->create_flags & MLX4_IB_QP_CREATE_ROCE_V2_GSI) {
+ int res = mlx4_qp_reserve_range(to_mdev(pd->device)->dev, 1, 1, &sqpn, 0);
+
+ if (res)
+ return ERR_PTR(res);
+ } else {
+ sqpn = get_sqp_num(to_mdev(pd->device), init_attr);
+ }
- err = create_qp_common(to_mdev(device), pd, init_attr, udata,
- get_sqp_num(to_mdev(device), init_attr),
- &qp);
+ err = create_qp_common(to_mdev(pd->device), pd, init_attr, udata,
+ sqpn,
+ &qp, gfp);
if (err)
return ERR_PTR(err);
qp->port = init_attr->port_num;
- qp->ibqp.qp_num = init_attr->qp_type == IB_QPT_SMI ? 0 : 1;
-
+ qp->ibqp.qp_num = init_attr->qp_type == IB_QPT_SMI ? 0 :
+ init_attr->create_flags & MLX4_IB_QP_CREATE_ROCE_V2_GSI ? sqpn : 1;
break;
}
default:
@@ -1489,7 +1239,41 @@ struct ib_qp *mlx4_ib_create_qp(struct ib_pd *pd,
return &qp->ibqp;
}
-int mlx4_ib_destroy_qp(struct ib_qp *qp)
+struct ib_qp *mlx4_ib_create_qp(struct ib_pd *pd,
+ struct ib_qp_init_attr *init_attr,
+ struct ib_udata *udata) {
+ struct ib_device *device = pd ? pd->device : init_attr->xrcd->device;
+ struct ib_qp *ibqp;
+ struct mlx4_ib_dev *dev = to_mdev(device);
+
+ ibqp = _mlx4_ib_create_qp(pd, init_attr, udata);
+
+ if (!IS_ERR(ibqp) &&
+ (init_attr->qp_type == IB_QPT_GSI) &&
+ !(init_attr->create_flags & MLX4_IB_QP_CREATE_ROCE_V2_GSI)) {
+ struct mlx4_ib_sqp *sqp = to_msqp((to_mqp(ibqp)));
+ int is_eth = rdma_cap_eth_ah(&dev->ib_dev, init_attr->port_num);
+
+ if (is_eth &&
+ dev->dev->caps.flags2 & MLX4_DEV_CAP_FLAG2_ROCE_V1_V2) {
+ init_attr->create_flags |= MLX4_IB_QP_CREATE_ROCE_V2_GSI;
+ sqp->roce_v2_gsi = ib_create_qp(pd, init_attr);
+
+ if (IS_ERR(sqp->roce_v2_gsi)) {
+ pr_err("Failed to create GSI QP for RoCEv2 (%ld)\n", PTR_ERR(sqp->roce_v2_gsi));
+ sqp->roce_v2_gsi = NULL;
+ } else {
+ sqp = to_msqp(to_mqp(sqp->roce_v2_gsi));
+ sqp->qp.flags |= MLX4_IB_ROCE_V2_GSI_QP;
+ }
+
+ init_attr->create_flags &= ~MLX4_IB_QP_CREATE_ROCE_V2_GSI;
+ }
+ }
+ return ibqp;
+}
+
+static int _mlx4_ib_destroy_qp(struct ib_qp *qp)
{
struct mlx4_ib_dev *dev = to_mdev(qp->device);
struct mlx4_ib_qp *mqp = to_mqp(qp);
@@ -1498,6 +1282,15 @@ int mlx4_ib_destroy_qp(struct ib_qp *qp)
if (is_qp0(dev, mqp))
mlx4_CLOSE_PORT(dev->dev, mqp->port);
+ if (dev->qp1_proxy[mqp->port - 1] == mqp) {
+ mutex_lock(&dev->qp1_proxy_lock[mqp->port - 1]);
+ dev->qp1_proxy[mqp->port - 1] = NULL;
+ mutex_unlock(&dev->qp1_proxy_lock[mqp->port - 1]);
+ }
+
+ if (mqp->counter_index)
+ mlx4_ib_free_qp_counter(dev, mqp);
+
pd = get_pd(mqp);
destroy_qp_common(dev, mqp, !!pd->ibpd.uobject);
@@ -1509,6 +1302,20 @@ int mlx4_ib_destroy_qp(struct ib_qp *qp)
return 0;
}
+int mlx4_ib_destroy_qp(struct ib_qp *qp)
+{
+ struct mlx4_ib_qp *mqp = to_mqp(qp);
+
+ if (mqp->mlx4_ib_qp_type == MLX4_IB_QPT_GSI) {
+ struct mlx4_ib_sqp *sqp = to_msqp(mqp);
+
+ if (sqp->roce_v2_gsi)
+ ib_destroy_qp(sqp->roce_v2_gsi);
+ }
+
+ return _mlx4_ib_destroy_qp(qp);
+}
+
static int to_mlx4_st(struct mlx4_ib_dev *dev, enum mlx4_ib_qp_type type)
{
switch (type) {
@@ -1579,52 +1386,40 @@ static void mlx4_set_sched(struct mlx4_qp_path *path, u8 port)
path->sched_queue = (path->sched_queue & 0xbf) | ((port - 1) << 6);
}
-static int ib_rate_to_mlx4(struct mlx4_ib_dev *dev, u8 rate)
-{
- if (rate == IB_RATE_PORT_CURRENT) {
- return 0;
- } else if (rate < IB_RATE_2_5_GBPS || rate > IB_RATE_300_GBPS) {
- return -EINVAL;
- } else {
- while (rate != IB_RATE_2_5_GBPS &&
- !(1 << (rate + MLX4_STAT_RATE_OFFSET) &
- dev->dev->caps.stat_rate_support))
- --rate;
- }
-
- return rate + MLX4_STAT_RATE_OFFSET;
-}
-
-static int mlx4_set_path(struct mlx4_ib_dev *dev, const struct ib_ah_attr *ah,
- u8 *smac, u16 vlan_id, struct mlx4_ib_qp *qp,
- struct mlx4_qp_path *path, u8 port, int is_primary)
+static int _mlx4_set_path(struct mlx4_ib_dev *dev, const struct ib_ah_attr *ah,
+ u64 smac, u16 vlan_tag, struct mlx4_qp_path *path,
+ struct mlx4_roce_smac_vlan_info *smac_info, u8 port)
{
int is_eth = rdma_port_get_link_layer(&dev->ib_dev, port) ==
IB_LINK_LAYER_ETHERNET;
- u16 vlan_tag;
int vidx;
int smac_index;
int err;
- u64 u64_mac;
- struct mlx4_roce_smac_vlan_info *smac_info;
+
path->grh_mylmc = ah->src_path_bits & 0x7f;
path->rlid = cpu_to_be16(ah->dlid);
-
- err = ib_rate_to_mlx4(dev, ah->static_rate);
- if (err < 0)
- return err;
- path->static_rate = err;
+ if (ah->static_rate) {
+ path->static_rate = ah->static_rate + MLX4_STAT_RATE_OFFSET;
+ while (path->static_rate > IB_RATE_2_5_GBPS + MLX4_STAT_RATE_OFFSET &&
+ !(1 << path->static_rate & dev->dev->caps.stat_rate_support))
+ --path->static_rate;
+ } else
+ path->static_rate = 0;
if (ah->ah_flags & IB_AH_GRH) {
- if (ah->grh.sgid_index >= dev->dev->caps.gid_table_len[port]) {
+ int real_sgid_index = mlx4_ib_gid_index_to_real_index(dev,
+ port,
+ ah->grh.sgid_index);
+
+ if (real_sgid_index >= dev->dev->caps.gid_table_len[port]) {
pr_err("sgid_index (%u) too large. max is %d\n",
- ah->grh.sgid_index, dev->dev->caps.gid_table_len[port] - 1);
+ real_sgid_index, dev->dev->caps.gid_table_len[port] - 1);
return -1;
}
path->grh_mylmc |= 1 << 7;
- path->mgid_index = ah->grh.sgid_index;
+ path->mgid_index = real_sgid_index;
path->hop_limit = ah->grh.hop_limit;
path->tclass_flowlabel =
cpu_to_be32((ah->grh.traffic_class << 20) |
@@ -1639,12 +1434,7 @@ static int mlx4_set_path(struct mlx4_ib_dev *dev, const struct ib_ah_attr *ah,
path->sched_queue = MLX4_IB_DEFAULT_SCHED_QUEUE |
((port - 1) << 6) | ((ah->sl & 7) << 3);
- if (is_primary)
- smac_info = &qp->pri;
- else
- smac_info = &qp->alt;
-
- vlan_tag = vlan_id;
+ path->feup |= MLX4_FEUP_FORCE_ETH_UP;
if (vlan_tag < 0x1000) {
if (smac_info->vid < 0x1000) {
/* both valid vlan ids */
@@ -1658,10 +1448,8 @@ static int mlx4_set_path(struct mlx4_ib_dev *dev, const struct ib_ah_attr *ah,
smac_info->candidate_vlan_port = port;
smac_info->update_vid = 1;
path->vlan_index = vidx;
- path->fl = 1 << 6;
} else {
path->vlan_index = smac_info->vlan_index;
- path->fl = 1 << 6;
}
} else {
/* no current vlan tag in qp */
@@ -1673,8 +1461,9 @@ static int mlx4_set_path(struct mlx4_ib_dev *dev, const struct ib_ah_attr *ah,
smac_info->candidate_vlan_port = port;
smac_info->update_vid = 1;
path->vlan_index = vidx;
- path->fl = 1 << 6;
}
+ path->feup |= MLX4_FVL_FORCE_ETH_VLAN;
+ path->fl = 1 << 6;
} else {
/* have current vlan tag. unregister it at modify-qp success */
if (smac_info->vid < 0x1000) {
@@ -1683,38 +1472,62 @@ static int mlx4_set_path(struct mlx4_ib_dev *dev, const struct ib_ah_attr *ah,
}
}
-
/* get smac_index for RoCE use.
* If no smac was yet assigned, register one.
* If one was already assigned, but the new mac differs,
* unregister the old one and register the new one.
*/
- u64_mac = mlx4_mac_to_u64(smac);
-
- if (!smac_info->smac || smac_info->smac != u64_mac) {
+ if ((!smac_info->smac && !smac_info->smac_port) ||
+ smac_info->smac != smac) {
/* register candidate now, unreg if needed, after success */
- smac_index = mlx4_register_mac(dev->dev, port, u64_mac);
+ smac_index = mlx4_register_mac(dev->dev, port, smac);
if (smac_index >= 0) {
smac_info->candidate_smac_index = smac_index;
- smac_info->candidate_smac = u64_mac;
+ smac_info->candidate_smac = smac;
smac_info->candidate_smac_port = port;
- } else
+ } else {
return -EINVAL;
- } else
+ }
+ } else {
smac_index = smac_info->smac_index;
+ }
memcpy(path->dmac, ah->dmac, 6);
path->ackto = MLX4_IB_LINK_TYPE_ETH;
/* put MAC table smac index for IBoE */
- path->grh_mylmc = (u8) (smac_index) | 0x80 ;
-
- } else
+ path->grh_mylmc = (u8) (smac_index) | 0x80;
+ } else {
path->sched_queue = MLX4_IB_DEFAULT_SCHED_QUEUE |
((port - 1) << 6) | ((ah->sl & 0xf) << 2);
+ }
return 0;
}
+static int mlx4_set_path(struct mlx4_ib_dev *dev, const struct ib_qp_attr *qp,
+ enum ib_qp_attr_mask qp_attr_mask,
+ struct mlx4_ib_qp *mqp,
+ struct mlx4_qp_path *path, u8 port,
+ u16 vlan_id, u8 *smac)
+{
+ return _mlx4_set_path(dev, &qp->ah_attr,
+ mlx4_mac_to_u64(smac),
+ vlan_id,
+ path, &mqp->pri, port);
+}
+
+static int mlx4_set_alt_path(struct mlx4_ib_dev *dev,
+ const struct ib_qp_attr *qp,
+ enum ib_qp_attr_mask qp_attr_mask,
+ struct mlx4_ib_qp *mqp,
+ struct mlx4_qp_path *path, u8 port)
+{
+ return _mlx4_set_path(dev, &qp->alt_ah_attr,
+ 0,
+ 0xffff,
+ path, &mqp->alt, port);
+}
+
static void update_mcg_macs(struct mlx4_ib_dev *dev, struct mlx4_ib_qp *qp)
{
struct mlx4_ib_gid_entry *ge, *tmp;
@@ -1727,35 +1540,82 @@ static void update_mcg_macs(struct mlx4_ib_dev *dev, struct mlx4_ib_qp *qp)
}
}
-static int handle_eth_ud_smac_index(struct mlx4_ib_dev *dev, struct mlx4_ib_qp *qp, const u8 *smac,
+static int handle_eth_ud_smac_index(struct mlx4_ib_dev *dev,
+ struct mlx4_ib_qp *qp,
struct mlx4_qp_context *context)
{
- struct net_device *ndev;
u64 u64_mac;
int smac_index;
-
- ndev = dev->iboe.netdevs[qp->port - 1];
- if (ndev) {
- smac = IF_LLADDR(ndev);
- u64_mac = mlx4_mac_to_u64(smac);
- } else {
- u64_mac = dev->dev->caps.def_mac[qp->port];
- }
+ u64_mac = atomic64_read(&dev->iboe.mac[qp->port - 1]);
context->pri_path.sched_queue = MLX4_IB_DEFAULT_SCHED_QUEUE | ((qp->port - 1) << 6);
- if (!qp->pri.smac) {
+ if (!qp->pri.smac && !qp->pri.smac_port) {
smac_index = mlx4_register_mac(dev->dev, qp->port, u64_mac);
if (smac_index >= 0) {
qp->pri.candidate_smac_index = smac_index;
qp->pri.candidate_smac = u64_mac;
qp->pri.candidate_smac_port = qp->port;
context->pri_path.grh_mylmc = 0x80 | (u8) smac_index;
- } else
+ } else {
return -ENOENT;
+ }
}
return 0;
}
+
+static int create_qp_lb_counter(struct mlx4_ib_dev *dev, struct mlx4_ib_qp *qp)
+{
+ struct counter_index *new_counter_index;
+ int err;
+ u32 tmp_idx;
+
+ if (rdma_port_get_link_layer(&dev->ib_dev, qp->port) !=
+ IB_LINK_LAYER_ETHERNET ||
+ !(qp->flags & MLX4_IB_QP_BLOCK_MULTICAST_LOOPBACK) ||
+ !(dev->dev->caps.flags2 & MLX4_DEV_CAP_FLAG2_LB_SRC_CHK))
+ return 0;
+
+ err = mlx4_counter_alloc(dev->dev, &tmp_idx);
+ if (err)
+ return err;
+
+ new_counter_index = kmalloc(sizeof(*new_counter_index), GFP_KERNEL);
+ if (!new_counter_index) {
+ mlx4_counter_free(dev->dev, tmp_idx);
+ return -ENOMEM;
+ }
+
+ new_counter_index->index = tmp_idx;
+ new_counter_index->allocated = 1;
+ qp->counter_index = new_counter_index;
+
+ mutex_lock(&dev->counters_table[qp->port - 1].mutex);
+ list_add_tail(&new_counter_index->list,
+ &dev->counters_table[qp->port - 1].counters_list);
+ mutex_unlock(&dev->counters_table[qp->port - 1].mutex);
+
+ return 0;
+}
+
+enum {
+ MLX4_QPC_ROCE_MODE_1 = 0,
+ MLX4_QPC_ROCE_MODE_2 = 2,
+ MLX4_QPC_ROCE_MODE_UNDEFINED = 0xff
+};
+
+static u8 gid_type_to_qpc(enum ib_gid_type gid_type)
+{
+ switch (gid_type) {
+ case IB_GID_TYPE_ROCE:
+ return MLX4_QPC_ROCE_MODE_1;
+ case IB_GID_TYPE_ROCE_UDP_ENCAP:
+ return MLX4_QPC_ROCE_MODE_2;
+ default:
+ return MLX4_QPC_ROCE_MODE_UNDEFINED;
+ }
+}
+
static int __mlx4_ib_modify_qp(struct ib_qp *ibqp,
const struct ib_qp_attr *attr, int attr_mask,
enum ib_qp_state cur_state, enum ib_qp_state new_state)
@@ -1769,7 +1629,13 @@ static int __mlx4_ib_modify_qp(struct ib_qp *ibqp,
int sqd_event;
int steer_qp = 0;
int err = -EINVAL;
- int is_eth = -1;
+ int counter_index;
+
+ /* APM is not supported under RoCE */
+ if (attr_mask & IB_QP_ALT_PATH &&
+ rdma_port_get_link_layer(&dev->ib_dev, qp->port) ==
+ IB_LINK_LAYER_ETHERNET)
+ return -ENOTSUPP;
context = kzalloc(sizeof *context, GFP_KERNEL);
if (!context)
@@ -1795,9 +1661,6 @@ static int __mlx4_ib_modify_qp(struct ib_qp *ibqp,
}
}
- if (qp->max_inlr_data)
- context->param3 |= cpu_to_be32(1 << 25);
-
if (ibqp->qp_type == IB_QPT_GSI || ibqp->qp_type == IB_QPT_SMI)
context->mtu_msgmax = (IB_MTU_4096 << 5) | 11;
else if (ibqp->qp_type == IB_QPT_RAW_PACKET)
@@ -1826,16 +1689,23 @@ static int __mlx4_ib_modify_qp(struct ib_qp *ibqp,
context->sq_size_stride = ilog2(qp->sq.wqe_cnt) << 3;
context->sq_size_stride |= qp->sq.wqe_shift - 4;
+ if (new_state == IB_QPS_RESET && qp->counter_index)
+ mlx4_ib_free_qp_counter(dev, qp);
+
if (cur_state == IB_QPS_RESET && new_state == IB_QPS_INIT) {
context->sq_size_stride |= !!qp->sq_no_prefetch << 7;
context->xrcd = cpu_to_be32((u32) qp->xrcdn);
- context->param3 |= cpu_to_be32(1 << 30);
+ if (ibqp->qp_type == IB_QPT_RAW_PACKET)
+ context->param3 |= cpu_to_be32(1 << 30);
}
if (qp->ibqp.uobject)
- context->usr_page = cpu_to_be32(to_mucontext(ibqp->uobject->context)->uar.index);
+ context->usr_page = cpu_to_be32(
+ mlx4_to_hw_uar_index(dev->dev,
+ to_mucontext(ibqp->uobject->context)->uar.index));
else
- context->usr_page = cpu_to_be32(qp->bf.uar->index);
+ context->usr_page = cpu_to_be32(
+ mlx4_to_hw_uar_index(dev->dev, dev->priv_uar.index));
if (attr_mask & IB_QP_DEST_QPN)
context->remote_qpn = cpu_to_be32(attr->dest_qp_num);
@@ -1849,19 +1719,40 @@ static int __mlx4_ib_modify_qp(struct ib_qp *ibqp,
}
if (cur_state == IB_QPS_INIT && new_state == IB_QPS_RTR) {
- if (dev->counters[qp->port - 1].counter_index != -1) {
- context->pri_path.counter_index =
- dev->counters[qp->port - 1].counter_index;
+ err = create_qp_lb_counter(dev, qp);
+ if (err)
+ goto out;
+
+ counter_index =
+ dev->counters_table[qp->port - 1].default_counter;
+ if (qp->counter_index)
+ counter_index = qp->counter_index->index;
+
+ if (counter_index != -1) {
+ context->pri_path.counter_index = counter_index;
optpar |= MLX4_QP_OPTPAR_COUNTER_INDEX;
- } else {
- context->pri_path.counter_index = 0xff;
- }
+ if (qp->counter_index) {
+ context->pri_path.fl |=
+ MLX4_FL_ETH_SRC_CHECK_MC_LB;
+ context->pri_path.vlan_control |=
+ MLX4_CTRL_ETH_SRC_CHECK_IF_COUNTER;
+ }
+ } else
+ context->pri_path.counter_index =
+ MLX4_SINK_COUNTER_INDEX(dev->dev);
- if (qp->flags & MLX4_IB_QP_NETIF &&
- (qp->qpg_type == IB_QPG_NONE || qp->qpg_type == IB_QPG_PARENT)) {
+ if (qp->flags & MLX4_IB_QP_NETIF) {
mlx4_ib_steer_qp_reg(dev, qp, 1);
steer_qp = 1;
}
+
+ if (ibqp->qp_type == IB_QPT_GSI) {
+ enum ib_gid_type gid_type = qp->flags & MLX4_IB_ROCE_V2_GSI_QP ?
+ IB_GID_TYPE_ROCE_UDP_ENCAP : IB_GID_TYPE_ROCE;
+ u8 qpc_roce_mode = gid_type_to_qpc(gid_type);
+
+ context->rlkey_roce_mode |= (qpc_roce_mode << 6);
+ }
}
if (attr_mask & IB_QP_PKEY_INDEX) {
@@ -1871,17 +1762,51 @@ static int __mlx4_ib_modify_qp(struct ib_qp *ibqp,
optpar |= MLX4_QP_OPTPAR_PKEY_INDEX;
}
- if ((attr_mask & IB_QP_AV) && (ibqp->qp_type != IB_QPT_RAW_PACKET)) {
- if (mlx4_set_path(dev, &attr->ah_attr, (u8 *)attr->smac,
- attr_mask & IB_QP_VID ?
- attr->vlan_id : 0xffff ,
- qp, &context->pri_path,
- attr_mask & IB_QP_PORT ?
- attr->port_num : qp->port, 1))
+ if (attr_mask & IB_QP_AV) {
+ u8 port_num = mlx4_is_bonded(to_mdev(ibqp->device)->dev) ? 1 :
+ attr_mask & IB_QP_PORT ? attr->port_num : qp->port;
+ union ib_gid gid;
+ struct ib_gid_attr gid_attr;
+ u16 vlan = 0xffff;
+ u8 smac[ETH_ALEN];
+ int status = 0;
+ int is_eth = rdma_cap_eth_ah(&dev->ib_dev, port_num) &&
+ attr->ah_attr.ah_flags & IB_AH_GRH;
+
+ if (is_eth) {
+ int index = attr->ah_attr.grh.sgid_index;
+
+ status = ib_get_cached_gid(ibqp->device, port_num,
+ index, &gid, &gid_attr);
+ if (!status && !memcmp(&gid, &zgid, sizeof(gid)))
+ status = -ENOENT;
+ if (!status && gid_attr.ndev) {
+ vlan = rdma_vlan_dev_vlan_id(gid_attr.ndev);
+ memcpy(smac, IF_LLADDR(gid_attr.ndev), ETH_ALEN);
+ dev_put(gid_attr.ndev);
+ }
+ }
+ if (status)
+ goto out;
+
+ if (mlx4_set_path(dev, attr, attr_mask, qp, &context->pri_path,
+ port_num, vlan, smac))
goto out;
optpar |= (MLX4_QP_OPTPAR_PRIMARY_ADDR_PATH |
MLX4_QP_OPTPAR_SCHED_QUEUE);
+
+ if (is_eth &&
+ (cur_state == IB_QPS_INIT && new_state == IB_QPS_RTR)) {
+ u8 qpc_roce_mode = gid_type_to_qpc(gid_attr.gid_type);
+
+ if (qpc_roce_mode == MLX4_QPC_ROCE_MODE_UNDEFINED) {
+ err = -EINVAL;
+ goto out;
+ }
+ context->rlkey_roce_mode |= (qpc_roce_mode << 6);
+ }
+
}
if (attr_mask & IB_QP_TIMEOUT) {
@@ -1898,16 +1823,13 @@ static int __mlx4_ib_modify_qp(struct ib_qp *ibqp,
dev->dev->caps.pkey_table_len[attr->alt_port_num])
goto out;
- if (mlx4_set_path(dev, &attr->alt_ah_attr, (u8 *)attr->smac,
- attr_mask & IB_QP_ALT_VID ?
- attr->alt_vlan_id : 0xffff,
- qp, &context->alt_path,
- attr->alt_port_num, 0))
+ if (mlx4_set_alt_path(dev, attr, attr_mask, qp,
+ &context->alt_path,
+ attr->alt_port_num))
goto out;
context->alt_path.pkey_index = attr->alt_pkey_index;
context->alt_path.ackto = attr->alt_timeout << 3;
- context->alt_path.counter_index = dev->counters[attr->alt_port_num - 1].counter_index;
optpar |= MLX4_QP_OPTPAR_ALT_ADDR_PATH;
}
@@ -2008,15 +1930,8 @@ static int __mlx4_ib_modify_qp(struct ib_qp *ibqp,
context->pri_path.fl = 0x80;
context->pri_path.sched_queue |= MLX4_IB_DEFAULT_SCHED_QUEUE;
}
- if (ibqp->qp_type == IB_QPT_RAW_PACKET &&
- (attr_mask & IB_QP_AV)) {
- context->pri_path.sched_queue |=
- ((attr->ah_attr.sl & 0xf) << 3);
- context->pri_path.feup = 1 << 6;
- }
- is_eth = rdma_port_get_link_layer(&dev->ib_dev, qp->port) ==
- IB_LINK_LAYER_ETHERNET;
- if (is_eth) {
+ if (rdma_port_get_link_layer(&dev->ib_dev, qp->port) ==
+ IB_LINK_LAYER_ETHERNET) {
if (qp->mlx4_ib_qp_type == MLX4_IB_QPT_TUN_GSI ||
qp->mlx4_ib_qp_type == MLX4_IB_QPT_GSI)
context->pri_path.feup = 1 << 7; /* don't fsm */
@@ -2024,18 +1939,37 @@ static int __mlx4_ib_modify_qp(struct ib_qp *ibqp,
if (qp->mlx4_ib_qp_type == MLX4_IB_QPT_UD ||
qp->mlx4_ib_qp_type == MLX4_IB_QPT_PROXY_GSI ||
qp->mlx4_ib_qp_type == MLX4_IB_QPT_TUN_GSI) {
- err = handle_eth_ud_smac_index(dev, qp, (const u8 *)attr->smac, context);
- if (err)
- return -EINVAL;
+ err = handle_eth_ud_smac_index(dev, qp, context);
+ if (err) {
+ err = -EINVAL;
+ goto out;
+ }
+ if (qp->mlx4_ib_qp_type == MLX4_IB_QPT_PROXY_GSI)
+ dev->qp1_proxy[qp->port - 1] = qp;
}
}
}
- if (ibqp->qp_type == IB_QPT_UD)
- if (is_eth && (new_state == IB_QPS_RTR)) {
+ if (qp->ibqp.qp_type == IB_QPT_RAW_PACKET) {
+ context->pri_path.ackto = (context->pri_path.ackto & 0xf8) |
+ MLX4_IB_LINK_TYPE_ETH;
+ if (dev->dev->caps.tunnel_offload_mode == MLX4_TUNNEL_OFFLOAD_MODE_VXLAN) {
+ /* set QP to receive both tunneled & non-tunneled packets */
+ if (!(context->flags & cpu_to_be32(1 << MLX4_RSS_QPC_FLAG_OFFSET)))
+ context->srqn = cpu_to_be32(7 << 28);
+ }
+ }
+
+ if (ibqp->qp_type == IB_QPT_UD && (new_state == IB_QPS_RTR)) {
+ int is_eth = rdma_port_get_link_layer(
+ &dev->ib_dev, qp->port) ==
+ IB_LINK_LAYER_ETHERNET;
+ if (is_eth) {
context->pri_path.ackto = MLX4_IB_LINK_TYPE_ETH;
optpar |= MLX4_QP_OPTPAR_PRIMARY_ADDR_PATH;
}
+ }
+
if (cur_state == IB_QPS_RTS && new_state == IB_QPS_SQD &&
attr_mask & IB_QP_EN_SQD_ASYNC_NOTIFY && attr->en_sqd_async_notify)
@@ -2046,43 +1980,6 @@ static int __mlx4_ib_modify_qp(struct ib_qp *ibqp,
if (!ibqp->uobject && cur_state == IB_QPS_RESET && new_state == IB_QPS_INIT)
context->rlkey_roce_mode |= (1 << 4);
- if ((attr_mask & IB_QP_GROUP_RSS) &&
- (qp->qpg_data->rss_child_count > 1)) {
- struct mlx4_ib_qpg_data *qpg_data = qp->qpg_data;
- void *rss_context_base = &context->pri_path;
- struct mlx4_rss_context *rss_context =
- (struct mlx4_rss_context *) (rss_context_base
- + MLX4_RSS_OFFSET_IN_QPC_PRI_PATH);
-
- context->flags |= cpu_to_be32(1 << MLX4_RSS_QPC_FLAG_OFFSET);
-
- /* This should be tbl_sz_base_qpn */
- rss_context->base_qpn = cpu_to_be32(qpg_data->rss_qpn_base |
- (ilog2(qpg_data->rss_child_count) << 24));
- rss_context->default_qpn = cpu_to_be32(qpg_data->rss_qpn_base);
- /* This should be flags_hash_fn */
- rss_context->flags = MLX4_RSS_TCP_IPV6 |
- MLX4_RSS_TCP_IPV4;
- if (dev->dev->caps.flags & MLX4_DEV_CAP_FLAG_UDP_RSS) {
- rss_context->base_qpn_udp = rss_context->default_qpn;
- rss_context->flags |= MLX4_RSS_IPV6 |
- MLX4_RSS_IPV4 |
- MLX4_RSS_UDP_IPV6 |
- MLX4_RSS_UDP_IPV4;
- }
- if (dev->dev->caps.flags2 & MLX4_DEV_CAP_FLAG2_RSS_TOP) {
- static const u32 rsskey[10] = { 0xD181C62C, 0xF7F4DB5B,
- 0x1983A2FC, 0x943E1ADB, 0xD9389E6B, 0xD1039C2C,
- 0xA74499AD, 0x593D56D9, 0xF3253C06, 0x2ADC1FFC};
- rss_context->hash_fn = MLX4_RSS_HASH_TOP;
- memcpy(rss_context->rss_key, rsskey,
- sizeof(rss_context->rss_key));
- } else {
- rss_context->hash_fn = MLX4_RSS_HASH_XOR;
- memset(rss_context->rss_key, 0,
- sizeof(rss_context->rss_key));
- }
- }
/*
* Before passing a kernel QP to the HW, make sure that the
* ownership bits of the send queue are set and the SQ
@@ -2097,17 +1994,13 @@ static int __mlx4_ib_modify_qp(struct ib_qp *ibqp,
ctrl = get_send_wqe(qp, i);
ctrl->owner_opcode = cpu_to_be32(1 << 31);
if (qp->sq_max_wqes_per_wr == 1)
- ctrl->fence_size = 1 << (qp->sq.wqe_shift - 4);
+ ctrl->fence_size =
+ 1 << (qp->sq.wqe_shift - 4);
stamp_send_wqe(qp, i, 1 << qp->sq.wqe_shift);
}
}
- if ((qp->port && rdma_port_get_link_layer(&dev->ib_dev, qp->port) ==
- IB_LINK_LAYER_ETHERNET) && (qp->ibqp.qp_type == IB_QPT_RAW_PACKET))
- context->pri_path.ackto = (context->pri_path.ackto & 0xf8) |
- MLX4_IB_LINK_TYPE_ETH;
-
err = mlx4_qp_modify(dev->dev, &qp->mtt, to_mlx4_state(cur_state),
to_mlx4_state(new_state), context, optpar,
sqd_event, &qp->mqp);
@@ -2164,14 +2057,13 @@ static int __mlx4_ib_modify_qp(struct ib_qp *ibqp,
if (qp->rq.wqe_cnt)
*qp->db.db = 0;
- if (qp->flags & MLX4_IB_QP_NETIF &&
- (qp->qpg_type == IB_QPG_NONE ||
- qp->qpg_type == IB_QPG_PARENT))
+ if (qp->flags & MLX4_IB_QP_NETIF)
mlx4_ib_steer_qp_reg(dev, qp, 0);
}
- if (qp->pri.smac) {
+ if (qp->pri.smac || (!qp->pri.smac && qp->pri.smac_port)) {
mlx4_unregister_mac(dev->dev, qp->pri.smac_port, qp->pri.smac);
qp->pri.smac = 0;
+ qp->pri.smac_port = 0;
}
if (qp->alt.smac) {
mlx4_unregister_mac(dev->dev, qp->alt.smac_port, qp->alt.smac);
@@ -2191,42 +2083,40 @@ static int __mlx4_ib_modify_qp(struct ib_qp *ibqp,
qp->alt.update_vid = 0;
}
}
-
out:
+ if (err && qp->counter_index)
+ mlx4_ib_free_qp_counter(dev, qp);
if (err && steer_qp)
mlx4_ib_steer_qp_reg(dev, qp, 0);
kfree(context);
- if (qp->pri.candidate_smac) {
- if (err)
+ if (qp->pri.candidate_smac ||
+ (!qp->pri.candidate_smac && qp->pri.candidate_smac_port)) {
+ if (err) {
mlx4_unregister_mac(dev->dev, qp->pri.candidate_smac_port, qp->pri.candidate_smac);
- else {
- if (qp->pri.smac) {
+ } else {
+ if (qp->pri.smac || (!qp->pri.smac && qp->pri.smac_port))
mlx4_unregister_mac(dev->dev, qp->pri.smac_port, qp->pri.smac);
- }
qp->pri.smac = qp->pri.candidate_smac;
qp->pri.smac_index = qp->pri.candidate_smac_index;
qp->pri.smac_port = qp->pri.candidate_smac_port;
-
}
qp->pri.candidate_smac = 0;
qp->pri.candidate_smac_index = 0;
qp->pri.candidate_smac_port = 0;
}
if (qp->alt.candidate_smac) {
- if (err)
- mlx4_unregister_mac(dev->dev, qp->alt.candidate_smac_port, qp->pri.candidate_smac);
- else {
- if (qp->pri.smac) {
+ if (err) {
+ mlx4_unregister_mac(dev->dev, qp->alt.candidate_smac_port, qp->alt.candidate_smac);
+ } else {
+ if (qp->alt.smac)
mlx4_unregister_mac(dev->dev, qp->alt.smac_port, qp->alt.smac);
- }
qp->alt.smac = qp->alt.candidate_smac;
qp->alt.smac_index = qp->alt.candidate_smac_index;
qp->alt.smac_port = qp->alt.candidate_smac_port;
-
}
- qp->pri.candidate_smac = 0;
- qp->pri.candidate_smac_index = 0;
- qp->pri.candidate_smac_port = 0;
+ qp->alt.candidate_smac = 0;
+ qp->alt.candidate_smac_index = 0;
+ qp->alt.candidate_smac_port = 0;
}
if (qp->pri.update_vid) {
@@ -2266,15 +2156,14 @@ out:
return err;
}
-int mlx4_ib_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr,
- int attr_mask, struct ib_udata *udata)
+static int _mlx4_ib_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr,
+ int attr_mask, struct ib_udata *udata)
{
struct mlx4_ib_dev *dev = to_mdev(ibqp->device);
struct mlx4_ib_qp *qp = to_mqp(ibqp);
enum ib_qp_state cur_state, new_state;
int err = -EINVAL;
int ll;
-
mutex_lock(&qp->mutex);
cur_state = attr_mask & IB_QP_CUR_STATE ? attr->cur_qp_state : qp->state;
@@ -2287,7 +2176,8 @@ int mlx4_ib_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr,
ll = rdma_port_get_link_layer(&dev->ib_dev, port);
}
- if (!ib_modify_qp_is_ok(cur_state, new_state, ibqp->qp_type, attr_mask, ll)) {
+ if (!ib_modify_qp_is_ok(cur_state, new_state, ibqp->qp_type,
+ attr_mask, ll)) {
pr_debug("qpn 0x%x: invalid attribute mask specified "
"for transition %d to %d. qp_type %d,"
" attr_mask 0x%x\n",
@@ -2296,6 +2186,22 @@ int mlx4_ib_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr,
goto out;
}
+ if (mlx4_is_bonded(dev->dev) && (attr_mask & IB_QP_PORT)) {
+ if ((cur_state == IB_QPS_RESET) && (new_state == IB_QPS_INIT)) {
+ if ((ibqp->qp_type == IB_QPT_RC) ||
+ (ibqp->qp_type == IB_QPT_UD) ||
+ (ibqp->qp_type == IB_QPT_UC) ||
+ (ibqp->qp_type == IB_QPT_RAW_PACKET) ||
+ (ibqp->qp_type == IB_QPT_XRC_INI)) {
+ attr->port_num = mlx4_ib_bond_next_port(dev);
+ }
+ } else {
+ /* no sense in changing port_num
+ * when ports are bonded */
+ attr_mask &= ~IB_QP_PORT;
+ }
+ }
+
if ((attr_mask & IB_QP_PORT) &&
(attr->port_num == 0 || attr->port_num > dev->num_ports)) {
pr_debug("qpn 0x%x: invalid port number (%d) specified "
@@ -2305,6 +2211,11 @@ int mlx4_ib_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr,
goto out;
}
+ if ((attr_mask & IB_QP_PORT) && (ibqp->qp_type == IB_QPT_RAW_PACKET) &&
+ (rdma_port_get_link_layer(&dev->ib_dev, attr->port_num) !=
+ IB_LINK_LAYER_ETHERNET))
+ goto out;
+
if (attr_mask & IB_QP_PKEY_INDEX) {
int p = attr_mask & IB_QP_PORT ? attr->port_num : qp->port;
if (attr->pkey_index >= dev->dev->caps.pkey_table_len[p]) {
@@ -2341,20 +2252,57 @@ int mlx4_ib_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr,
err = __mlx4_ib_modify_qp(ibqp, attr, attr_mask, cur_state, new_state);
+ if (mlx4_is_bonded(dev->dev) && (attr_mask & IB_QP_PORT))
+ attr->port_num = 1;
+
out:
mutex_unlock(&qp->mutex);
return err;
}
+int mlx4_ib_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr,
+ int attr_mask, struct ib_udata *udata)
+{
+ struct mlx4_ib_qp *mqp = to_mqp(ibqp);
+ int ret;
+
+ ret = _mlx4_ib_modify_qp(ibqp, attr, attr_mask, udata);
+
+ if (mqp->mlx4_ib_qp_type == MLX4_IB_QPT_GSI) {
+ struct mlx4_ib_sqp *sqp = to_msqp(mqp);
+ int err = 0;
+
+ if (sqp->roce_v2_gsi)
+ err = ib_modify_qp(sqp->roce_v2_gsi, attr, attr_mask);
+ if (err)
+ pr_err("Failed to modify GSI QP for RoCEv2 (%d)\n",
+ err);
+ }
+ return ret;
+}
+
+static int vf_get_qp0_qkey(struct mlx4_dev *dev, int qpn, u32 *qkey)
+{
+ int i;
+ for (i = 0; i < dev->caps.num_ports; i++) {
+ if (qpn == dev->caps.qp0_proxy[i] ||
+ qpn == dev->caps.qp0_tunnel[i]) {
+ *qkey = dev->caps.qp0_qkey[i];
+ return 0;
+ }
+ }
+ return -EINVAL;
+}
+
static int build_sriov_qp0_header(struct mlx4_ib_sqp *sqp,
- struct ib_send_wr *wr,
+ struct ib_ud_wr *wr,
void *wqe, unsigned *mlx_seg_len)
{
struct mlx4_ib_dev *mdev = to_mdev(sqp->qp.ibqp.device);
struct ib_device *ib_dev = &mdev->ib_dev;
struct mlx4_wqe_mlx_seg *mlx = wqe;
struct mlx4_wqe_inline_seg *inl = wqe + sizeof *mlx;
- struct mlx4_ib_ah *ah = to_mah(wr->wr.ud.ah);
+ struct mlx4_ib_ah *ah = to_mah(wr->ah);
u16 pkey;
u32 qkey;
int send_size;
@@ -2362,20 +2310,20 @@ static int build_sriov_qp0_header(struct mlx4_ib_sqp *sqp,
int spc;
int i;
- if (wr->opcode != IB_WR_SEND)
+ if (wr->wr.opcode != IB_WR_SEND)
return -EINVAL;
send_size = 0;
- for (i = 0; i < wr->num_sge; ++i)
- send_size += wr->sg_list[i].length;
+ for (i = 0; i < wr->wr.num_sge; ++i)
+ send_size += wr->wr.sg_list[i].length;
/* for proxy-qp0 sends, need to add in size of tunnel header */
/* for tunnel-qp0 sends, tunnel header is already in s/g list */
if (sqp->qp.mlx4_ib_qp_type == MLX4_IB_QPT_PROXY_SMI_OWNER)
send_size += sizeof (struct mlx4_ib_tunnel_header);
- ib_ud_header_init(send_size, 1, 0, 0, 0, 0, &sqp->ud_header);
+ ib_ud_header_init(send_size, 1, 0, 0, 0, 0, 0, 0, &sqp->ud_header);
if (sqp->qp.mlx4_ib_qp_type == MLX4_IB_QPT_PROXY_SMI_OWNER) {
sqp->ud_header.lrh.service_level =
@@ -2393,18 +2341,23 @@ static int build_sriov_qp0_header(struct mlx4_ib_sqp *sqp,
mlx->rlid = sqp->ud_header.lrh.destination_lid;
sqp->ud_header.lrh.virtual_lane = 0;
- sqp->ud_header.bth.solicited_event = !!(wr->send_flags & IB_SEND_SOLICITED);
+ sqp->ud_header.bth.solicited_event = !!(wr->wr.send_flags & IB_SEND_SOLICITED);
ib_get_cached_pkey(ib_dev, sqp->qp.port, 0, &pkey);
sqp->ud_header.bth.pkey = cpu_to_be16(pkey);
if (sqp->qp.mlx4_ib_qp_type == MLX4_IB_QPT_TUN_SMI_OWNER)
- sqp->ud_header.bth.destination_qpn = cpu_to_be32(wr->wr.ud.remote_qpn);
+ sqp->ud_header.bth.destination_qpn = cpu_to_be32(wr->remote_qpn);
else
sqp->ud_header.bth.destination_qpn =
cpu_to_be32(mdev->dev->caps.qp0_tunnel[sqp->qp.port - 1]);
sqp->ud_header.bth.psn = cpu_to_be32((sqp->send_psn++) & ((1 << 24) - 1));
- if (mlx4_get_parav_qkey(mdev->dev, sqp->qp.mqp.qpn, &qkey))
- return -EINVAL;
+ if (mlx4_is_master(mdev->dev)) {
+ if (mlx4_get_parav_qkey(mdev->dev, sqp->qp.mqp.qpn, &qkey))
+ return -EINVAL;
+ } else {
+ if (vf_get_qp0_qkey(mdev->dev, sqp->qp.mqp.qpn, &qkey))
+ return -EINVAL;
+ }
sqp->ud_header.deth.qkey = cpu_to_be32(qkey);
sqp->ud_header.deth.source_qpn = cpu_to_be32(sqp->qp.mqp.qpn);
@@ -2422,11 +2375,11 @@ static int build_sriov_qp0_header(struct mlx4_ib_sqp *sqp,
spc = MLX4_INLINE_ALIGN -
((unsigned long) (inl + 1) & (MLX4_INLINE_ALIGN - 1));
if (header_size <= spc) {
- inl->byte_count = cpu_to_be32(1 << 31 | header_size);
+ inl->byte_count = cpu_to_be32((1U << 31) | header_size);
memcpy(inl + 1, sqp->header_buf, header_size);
i = 1;
} else {
- inl->byte_count = cpu_to_be32(1 << 31 | spc);
+ inl->byte_count = cpu_to_be32((1U << 31) | spc);
memcpy(inl + 1, sqp->header_buf, spc);
inl = (void *) (inl + 1) + spc;
@@ -2445,7 +2398,7 @@ static int build_sriov_qp0_header(struct mlx4_ib_sqp *sqp,
* of 16 mod 64.
*/
wmb();
- inl->byte_count = cpu_to_be32(1 << 31 | (header_size - spc));
+ inl->byte_count = cpu_to_be32((1U << 31) | (header_size - spc));
i = 2;
}
@@ -2454,33 +2407,54 @@ static int build_sriov_qp0_header(struct mlx4_ib_sqp *sqp,
return 0;
}
-static int build_mlx_header(struct mlx4_ib_sqp *sqp, struct ib_send_wr *wr,
+static u8 sl_to_vl(struct mlx4_ib_dev *dev, u8 sl, int port_num)
+{
+ union sl2vl_tbl_to_u64 tmp_vltab;
+ u8 vl;
+
+ if (sl > 15)
+ return 0xf;
+ tmp_vltab.sl64 = atomic64_read(&dev->sl2vl[port_num - 1]);
+ vl = tmp_vltab.sl8[sl >> 1];
+ if (sl & 1)
+ vl &= 0x0f;
+ else
+ vl >>= 4;
+ return vl;
+}
+
+#define MLX4_ROCEV2_QP1_SPORT 0xC000
+static int build_mlx_header(struct mlx4_ib_sqp *sqp, struct ib_ud_wr *wr,
void *wqe, unsigned *mlx_seg_len)
{
struct ib_device *ib_dev = sqp->qp.ibqp.device;
struct mlx4_wqe_mlx_seg *mlx = wqe;
struct mlx4_wqe_ctrl_seg *ctrl = wqe;
struct mlx4_wqe_inline_seg *inl = wqe + sizeof *mlx;
- struct mlx4_ib_ah *ah = to_mah(wr->wr.ud.ah);
+ struct mlx4_ib_ah *ah = to_mah(wr->ah);
union ib_gid sgid;
u16 pkey;
int send_size;
int header_size;
int spc;
int i;
- int is_eth;
- int is_vlan = 0;
- int is_grh;
- u16 uninitialized_var(vlan);
int err = 0;
+ u16 vlan = 0xffff;
+ bool is_eth;
+ bool is_vlan = false;
+ bool is_grh;
+ bool is_udp = false;
+ int ip_version = 0;
send_size = 0;
- for (i = 0; i < wr->num_sge; ++i)
- send_size += wr->sg_list[i].length;
+ for (i = 0; i < wr->wr.num_sge; ++i)
+ send_size += wr->wr.sg_list[i].length;
is_eth = rdma_port_get_link_layer(sqp->qp.ibqp.device, sqp->qp.port) == IB_LINK_LAYER_ETHERNET;
is_grh = mlx4_ib_ah_grh_present(ah);
if (is_eth) {
+ struct ib_gid_attr gid_attr;
+
if (mlx4_is_mfunc(to_mdev(ib_dev)->dev)) {
/* When multi-function is enabled, the ib_core gid
* indexes don't necessarily match the hw ones, so
@@ -2493,17 +2467,36 @@ static int build_mlx_header(struct mlx4_ib_sqp *sqp, struct ib_send_wr *wr,
} else {
err = ib_get_cached_gid(ib_dev,
be32_to_cpu(ah->av.ib.port_pd) >> 24,
- ah->av.ib.gid_index, &sgid);
- if (err)
+ ah->av.ib.gid_index, &sgid,
+ &gid_attr);
+ if (!err) {
+ if (gid_attr.ndev)
+ dev_put(gid_attr.ndev);
+ if (!memcmp(&sgid, &zgid, sizeof(sgid)))
+ err = -ENOENT;
+ }
+ if (!err) {
+ is_udp = gid_attr.gid_type == IB_GID_TYPE_ROCE_UDP_ENCAP;
+ if (is_udp) {
+ if (ipv6_addr_v4mapped((struct in6_addr *)&sgid))
+ ip_version = 4;
+ else
+ ip_version = 6;
+ is_grh = false;
+ }
+ } else {
return err;
+ }
}
-
- if (is_eth && ah->av.eth.vlan != 0xffff) {
- vlan = cpu_to_be16(ah->av.eth.vlan) & 0x0fff;
+ if (ah->av.eth.vlan != cpu_to_be16(0xffff)) {
+ vlan = be16_to_cpu(ah->av.eth.vlan) & 0x0fff;
is_vlan = 1;
}
}
- ib_ud_header_init(send_size, !is_eth, is_eth, is_vlan, is_grh, 0, &sqp->ud_header);
+ err = ib_ud_header_init(send_size, !is_eth, is_eth, is_vlan, is_grh,
+ ip_version, is_udp, 0, &sqp->ud_header);
+ if (err)
+ return err;
if (!is_eth) {
sqp->ud_header.lrh.service_level =
@@ -2512,35 +2505,57 @@ static int build_mlx_header(struct mlx4_ib_sqp *sqp, struct ib_send_wr *wr,
sqp->ud_header.lrh.source_lid = cpu_to_be16(ah->av.ib.g_slid & 0x7f);
}
- if (is_grh) {
+ if (is_grh || (ip_version == 6)) {
sqp->ud_header.grh.traffic_class =
(be32_to_cpu(ah->av.ib.sl_tclass_flowlabel) >> 20) & 0xff;
sqp->ud_header.grh.flow_label =
ah->av.ib.sl_tclass_flowlabel & cpu_to_be32(0xfffff);
sqp->ud_header.grh.hop_limit = ah->av.ib.hop_limit;
- if (is_eth)
+ if (is_eth) {
memcpy(sqp->ud_header.grh.source_gid.raw, sgid.raw, 16);
- else {
- if (mlx4_is_mfunc(to_mdev(ib_dev)->dev)) {
- /* When multi-function is enabled, the ib_core gid
- * indexes don't necessarily match the hw ones, so
- * we must use our own cache */
- sqp->ud_header.grh.source_gid.global.subnet_prefix =
- to_mdev(ib_dev)->sriov.demux[sqp->qp.port - 1].
- subnet_prefix;
- sqp->ud_header.grh.source_gid.global.interface_id =
- to_mdev(ib_dev)->sriov.demux[sqp->qp.port - 1].
- guid_cache[ah->av.ib.gid_index];
- } else
- ib_get_cached_gid(ib_dev,
- be32_to_cpu(ah->av.ib.port_pd) >> 24,
- ah->av.ib.gid_index,
- &sqp->ud_header.grh.source_gid);
+ } else {
+ if (mlx4_is_mfunc(to_mdev(ib_dev)->dev)) {
+ /* When multi-function is enabled, the ib_core gid
+ * indexes don't necessarily match the hw ones, so
+ * we must use our own cache
+ */
+ sqp->ud_header.grh.source_gid.global.subnet_prefix =
+ cpu_to_be64(atomic64_read(&(to_mdev(ib_dev)->sriov.
+ demux[sqp->qp.port - 1].
+ subnet_prefix)));
+ sqp->ud_header.grh.source_gid.global.interface_id =
+ to_mdev(ib_dev)->sriov.demux[sqp->qp.port - 1].
+ guid_cache[ah->av.ib.gid_index];
+ } else {
+ ib_get_cached_gid(ib_dev,
+ be32_to_cpu(ah->av.ib.port_pd) >> 24,
+ ah->av.ib.gid_index,
+ &sqp->ud_header.grh.source_gid, NULL);
+ }
}
memcpy(sqp->ud_header.grh.destination_gid.raw,
ah->av.ib.dgid, 16);
}
+ if (ip_version == 4) {
+ sqp->ud_header.ip4.tos =
+ (be32_to_cpu(ah->av.ib.sl_tclass_flowlabel) >> 20) & 0xff;
+ sqp->ud_header.ip4.id = 0;
+ sqp->ud_header.ip4.frag_off = htons(IP_DF);
+ sqp->ud_header.ip4.ttl = ah->av.eth.hop_limit;
+
+ memcpy(&sqp->ud_header.ip4.saddr,
+ sgid.raw + 12, 4);
+ memcpy(&sqp->ud_header.ip4.daddr, ah->av.ib.dgid + 12, 4);
+ sqp->ud_header.ip4.check = ib_ud_ip4_csum(&sqp->ud_header);
+ }
+
+ if (is_udp) {
+ sqp->ud_header.udp.dport = htons(ROCE_V2_UDP_DPORT);
+ sqp->ud_header.udp.sport = htons(MLX4_ROCEV2_QP1_SPORT);
+ sqp->ud_header.udp.csum = 0;
+ }
+
mlx->flags &= cpu_to_be32(MLX4_WQE_CTRL_CQ_UPDATE);
if (!is_eth) {
@@ -2553,7 +2568,7 @@ static int build_mlx_header(struct mlx4_ib_sqp *sqp, struct ib_send_wr *wr,
mlx->rlid = sqp->ud_header.lrh.destination_lid;
}
- switch (wr->opcode) {
+ switch (wr->wr.opcode) {
case IB_WR_SEND:
sqp->ud_header.bth.opcode = IB_OPCODE_UD_SEND_ONLY;
sqp->ud_header.immediate_present = 0;
@@ -2561,55 +2576,57 @@ static int build_mlx_header(struct mlx4_ib_sqp *sqp, struct ib_send_wr *wr,
case IB_WR_SEND_WITH_IMM:
sqp->ud_header.bth.opcode = IB_OPCODE_UD_SEND_ONLY_WITH_IMMEDIATE;
sqp->ud_header.immediate_present = 1;
- sqp->ud_header.immediate_data = wr->ex.imm_data;
+ sqp->ud_header.immediate_data = wr->wr.ex.imm_data;
break;
default:
return -EINVAL;
}
if (is_eth) {
- u8 *smac;
struct in6_addr in6;
-
+ u16 ether_type;
u16 pcp = (be32_to_cpu(ah->av.ib.sl_tclass_flowlabel) >> 29) << 13;
+ ether_type = (!is_udp) ? MLX4_IB_IBOE_ETHERTYPE :
+ (ip_version == 4 ? ETHERTYPE_IP : ETHERTYPE_IPV6);
+
mlx->sched_prio = cpu_to_be16(pcp);
+ ether_addr_copy(sqp->ud_header.eth.smac_h, ah->av.eth.s_mac);
memcpy(sqp->ud_header.eth.dmac_h, ah->av.eth.mac, 6);
- /* FIXME: cache smac value? */
memcpy(&ctrl->srcrb_flags16[0], ah->av.eth.mac, 2);
memcpy(&ctrl->imm, ah->av.eth.mac + 2, 4);
memcpy(&in6, sgid.raw, sizeof(in6));
- if (!mlx4_is_mfunc(to_mdev(ib_dev)->dev))
- smac = IF_LLADDR(to_mdev(sqp->qp.ibqp.device)->iboe.netdevs[sqp->qp.port - 1]);
- else
- smac = ah->av.eth.s_mac; /* use the src mac of the tunnel */
- memcpy(sqp->ud_header.eth.smac_h, smac, 6);
if (!memcmp(sqp->ud_header.eth.smac_h, sqp->ud_header.eth.dmac_h, 6))
mlx->flags |= cpu_to_be32(MLX4_WQE_CTRL_FORCE_LOOPBACK);
if (!is_vlan) {
- sqp->ud_header.eth.type = cpu_to_be16(MLX4_IB_IBOE_ETHERTYPE);
+ sqp->ud_header.eth.type = cpu_to_be16(ether_type);
} else {
- sqp->ud_header.vlan.type = cpu_to_be16(MLX4_IB_IBOE_ETHERTYPE);
+ sqp->ud_header.vlan.type = cpu_to_be16(ether_type);
sqp->ud_header.vlan.tag = cpu_to_be16(vlan | pcp);
}
} else {
- sqp->ud_header.lrh.virtual_lane = !sqp->qp.ibqp.qp_num ? 15 : 0;
+ sqp->ud_header.lrh.virtual_lane = !sqp->qp.ibqp.qp_num ? 15 :
+ sl_to_vl(to_mdev(ib_dev),
+ sqp->ud_header.lrh.service_level,
+ sqp->qp.port);
+ if (sqp->qp.ibqp.qp_num && sqp->ud_header.lrh.virtual_lane == 15)
+ return -EINVAL;
if (sqp->ud_header.lrh.destination_lid == IB_LID_PERMISSIVE)
sqp->ud_header.lrh.source_lid = IB_LID_PERMISSIVE;
}
- sqp->ud_header.bth.solicited_event = !!(wr->send_flags & IB_SEND_SOLICITED);
+ sqp->ud_header.bth.solicited_event = !!(wr->wr.send_flags & IB_SEND_SOLICITED);
if (!sqp->qp.ibqp.qp_num)
ib_get_cached_pkey(ib_dev, sqp->qp.port, sqp->pkey_index, &pkey);
else
- ib_get_cached_pkey(ib_dev, sqp->qp.port, wr->wr.ud.pkey_index, &pkey);
+ ib_get_cached_pkey(ib_dev, sqp->qp.port, wr->pkey_index, &pkey);
sqp->ud_header.bth.pkey = cpu_to_be16(pkey);
- sqp->ud_header.bth.destination_qpn = cpu_to_be32(wr->wr.ud.remote_qpn);
+ sqp->ud_header.bth.destination_qpn = cpu_to_be32(wr->remote_qpn);
sqp->ud_header.bth.psn = cpu_to_be32((sqp->send_psn++) & ((1 << 24) - 1));
- sqp->ud_header.deth.qkey = cpu_to_be32(wr->wr.ud.remote_qkey & 0x80000000 ?
- sqp->qkey : wr->wr.ud.remote_qkey);
+ sqp->ud_header.deth.qkey = cpu_to_be32(wr->remote_qkey & 0x80000000 ?
+ sqp->qkey : wr->remote_qkey);
sqp->ud_header.deth.source_qpn = cpu_to_be32(sqp->qp.ibqp.qp_num);
header_size = ib_ud_header_pack(&sqp->ud_header, sqp->header_buf);
@@ -2697,53 +2714,26 @@ static __be32 convert_access(int acc)
cpu_to_be32(MLX4_WQE_FMR_PERM_LOCAL_READ);
}
-static void set_fmr_seg(struct mlx4_wqe_fmr_seg *fseg, struct ib_send_wr *wr)
+static void set_reg_seg(struct mlx4_wqe_fmr_seg *fseg,
+ struct ib_reg_wr *wr)
{
- struct mlx4_ib_fast_reg_page_list *mfrpl = to_mfrpl(wr->wr.fast_reg.page_list);
- int i;
+ struct mlx4_ib_mr *mr = to_mmr(wr->mr);
- for (i = 0; i < wr->wr.fast_reg.page_list_len; ++i)
- mfrpl->mapped_page_list[i] =
- cpu_to_be64(wr->wr.fast_reg.page_list->page_list[i] |
- MLX4_MTT_FLAG_PRESENT);
-
- fseg->flags = convert_access(wr->wr.fast_reg.access_flags);
- fseg->mem_key = cpu_to_be32(wr->wr.fast_reg.rkey);
- fseg->buf_list = cpu_to_be64(mfrpl->map);
- fseg->start_addr = cpu_to_be64(wr->wr.fast_reg.iova_start);
- fseg->reg_len = cpu_to_be64(wr->wr.fast_reg.length);
+ fseg->flags = convert_access(wr->access);
+ fseg->mem_key = cpu_to_be32(wr->key);
+ fseg->buf_list = cpu_to_be64(mr->page_map);
+ fseg->start_addr = cpu_to_be64(mr->ibmr.iova);
+ fseg->reg_len = cpu_to_be64(mr->ibmr.length);
fseg->offset = 0; /* XXX -- is this just for ZBVA? */
- fseg->page_size = cpu_to_be32(wr->wr.fast_reg.page_shift);
+ fseg->page_size = cpu_to_be32(ilog2(mr->ibmr.page_size));
fseg->reserved[0] = 0;
fseg->reserved[1] = 0;
}
-static void set_bind_seg(struct mlx4_wqe_bind_seg *bseg, struct ib_send_wr *wr)
-{
- bseg->flags1 =
- convert_access(wr->wr.bind_mw.bind_info.mw_access_flags) &
- cpu_to_be32(MLX4_WQE_FMR_AND_BIND_PERM_REMOTE_READ |
- MLX4_WQE_FMR_AND_BIND_PERM_REMOTE_WRITE |
- MLX4_WQE_FMR_AND_BIND_PERM_ATOMIC);
- bseg->flags2 = 0;
- if (wr->wr.bind_mw.mw->type == IB_MW_TYPE_2)
- bseg->flags2 |= cpu_to_be32(MLX4_WQE_BIND_TYPE_2);
- if (wr->wr.bind_mw.bind_info.mw_access_flags & IB_ZERO_BASED)
- bseg->flags2 |= cpu_to_be32(MLX4_WQE_BIND_ZERO_BASED);
- bseg->new_rkey = cpu_to_be32(wr->wr.bind_mw.rkey);
- bseg->lkey = cpu_to_be32(wr->wr.bind_mw.bind_info.mr->lkey);
- bseg->addr = cpu_to_be64(wr->wr.bind_mw.bind_info.addr);
- bseg->length = cpu_to_be64(wr->wr.bind_mw.bind_info.length);
-}
-
static void set_local_inv_seg(struct mlx4_wqe_local_inval_seg *iseg, u32 rkey)
{
+ memset(iseg, 0, sizeof(*iseg));
iseg->mem_key = cpu_to_be32(rkey);
-
- iseg->reserved1 = 0;
- iseg->reserved2 = 0;
- iseg->reserved3[0] = 0;
- iseg->reserved3[1] = 0;
}
static __always_inline void set_raddr_seg(struct mlx4_wqe_raddr_seg *rseg,
@@ -2754,45 +2744,47 @@ static __always_inline void set_raddr_seg(struct mlx4_wqe_raddr_seg *rseg,
rseg->reserved = 0;
}
-static void set_atomic_seg(struct mlx4_wqe_atomic_seg *aseg, struct ib_send_wr *wr)
+static void set_atomic_seg(struct mlx4_wqe_atomic_seg *aseg,
+ struct ib_atomic_wr *wr)
{
- if (wr->opcode == IB_WR_ATOMIC_CMP_AND_SWP) {
- aseg->swap_add = cpu_to_be64(wr->wr.atomic.swap);
- aseg->compare = cpu_to_be64(wr->wr.atomic.compare_add);
- } else if (wr->opcode == IB_WR_MASKED_ATOMIC_FETCH_AND_ADD) {
- aseg->swap_add = cpu_to_be64(wr->wr.atomic.compare_add);
- aseg->compare = cpu_to_be64(wr->wr.atomic.compare_add_mask);
+ if (wr->wr.opcode == IB_WR_ATOMIC_CMP_AND_SWP) {
+ aseg->swap_add = cpu_to_be64(wr->swap);
+ aseg->compare = cpu_to_be64(wr->compare_add);
+ } else if (wr->wr.opcode == IB_WR_MASKED_ATOMIC_FETCH_AND_ADD) {
+ aseg->swap_add = cpu_to_be64(wr->compare_add);
+ aseg->compare = cpu_to_be64(wr->compare_add_mask);
} else {
- aseg->swap_add = cpu_to_be64(wr->wr.atomic.compare_add);
+ aseg->swap_add = cpu_to_be64(wr->compare_add);
aseg->compare = 0;
}
}
static void set_masked_atomic_seg(struct mlx4_wqe_masked_atomic_seg *aseg,
- struct ib_send_wr *wr)
+ struct ib_atomic_wr *wr)
{
- aseg->swap_add = cpu_to_be64(wr->wr.atomic.swap);
- aseg->swap_add_mask = cpu_to_be64(wr->wr.atomic.swap_mask);
- aseg->compare = cpu_to_be64(wr->wr.atomic.compare_add);
- aseg->compare_mask = cpu_to_be64(wr->wr.atomic.compare_add_mask);
+ aseg->swap_add = cpu_to_be64(wr->swap);
+ aseg->swap_add_mask = cpu_to_be64(wr->swap_mask);
+ aseg->compare = cpu_to_be64(wr->compare_add);
+ aseg->compare_mask = cpu_to_be64(wr->compare_add_mask);
}
static void set_datagram_seg(struct mlx4_wqe_datagram_seg *dseg,
- struct ib_send_wr *wr)
+ struct ib_ud_wr *wr)
{
- memcpy(dseg->av, &to_mah(wr->wr.ud.ah)->av, sizeof (struct mlx4_av));
- dseg->dqpn = cpu_to_be32(wr->wr.ud.remote_qpn);
- dseg->qkey = cpu_to_be32(wr->wr.ud.remote_qkey);
- dseg->vlan = to_mah(wr->wr.ud.ah)->av.eth.vlan;
- memcpy(dseg->mac, to_mah(wr->wr.ud.ah)->av.eth.mac, 6);
+ memcpy(dseg->av, &to_mah(wr->ah)->av, sizeof (struct mlx4_av));
+ dseg->dqpn = cpu_to_be32(wr->remote_qpn);
+ dseg->qkey = cpu_to_be32(wr->remote_qkey);
+ dseg->vlan = to_mah(wr->ah)->av.eth.vlan;
+ memcpy(dseg->mac, to_mah(wr->ah)->av.eth.mac, 6);
}
static void set_tunnel_datagram_seg(struct mlx4_ib_dev *dev,
struct mlx4_wqe_datagram_seg *dseg,
- struct ib_send_wr *wr, enum ib_qp_type qpt)
+ struct ib_ud_wr *wr,
+ enum mlx4_ib_qp_type qpt)
{
- union mlx4_ext_av *av = &to_mah(wr->wr.ud.ah)->av;
+ union mlx4_ext_av *av = &to_mah(wr->ah)->av;
struct mlx4_av sqp_av = {0};
int port = *((u8 *) &av->ib.port_pd) & 0x3;
@@ -2803,43 +2795,45 @@ static void set_tunnel_datagram_seg(struct mlx4_ib_dev *dev,
cpu_to_be32(0xf0000000);
memcpy(dseg->av, &sqp_av, sizeof (struct mlx4_av));
- /* This function used only for sending on QP1 proxies */
- dseg->dqpn = cpu_to_be32(dev->dev->caps.qp1_tunnel[port - 1]);
+ if (qpt == MLX4_IB_QPT_PROXY_GSI)
+ dseg->dqpn = cpu_to_be32(dev->dev->caps.qp1_tunnel[port - 1]);
+ else
+ dseg->dqpn = cpu_to_be32(dev->dev->caps.qp0_tunnel[port - 1]);
/* Use QKEY from the QP context, which is set by master */
dseg->qkey = cpu_to_be32(IB_QP_SET_QKEY);
}
-static void build_tunnel_header(struct ib_send_wr *wr, void *wqe, unsigned *mlx_seg_len)
+static void build_tunnel_header(struct ib_ud_wr *wr, void *wqe, unsigned *mlx_seg_len)
{
struct mlx4_wqe_inline_seg *inl = wqe;
struct mlx4_ib_tunnel_header hdr;
- struct mlx4_ib_ah *ah = to_mah(wr->wr.ud.ah);
+ struct mlx4_ib_ah *ah = to_mah(wr->ah);
int spc;
int i;
memcpy(&hdr.av, &ah->av, sizeof hdr.av);
- hdr.remote_qpn = cpu_to_be32(wr->wr.ud.remote_qpn);
- hdr.pkey_index = cpu_to_be16(wr->wr.ud.pkey_index);
- hdr.qkey = cpu_to_be32(wr->wr.ud.remote_qkey);
+ hdr.remote_qpn = cpu_to_be32(wr->remote_qpn);
+ hdr.pkey_index = cpu_to_be16(wr->pkey_index);
+ hdr.qkey = cpu_to_be32(wr->remote_qkey);
memcpy(hdr.mac, ah->av.eth.mac, 6);
- hdr.vlan = cpu_to_be16(ah->av.eth.vlan);
+ hdr.vlan = ah->av.eth.vlan;
spc = MLX4_INLINE_ALIGN -
((unsigned long) (inl + 1) & (MLX4_INLINE_ALIGN - 1));
if (sizeof (hdr) <= spc) {
memcpy(inl + 1, &hdr, sizeof (hdr));
wmb();
- inl->byte_count = cpu_to_be32(1 << 31 | sizeof (hdr));
+ inl->byte_count = cpu_to_be32((1U << 31) | (u32)sizeof(hdr));
i = 1;
} else {
memcpy(inl + 1, &hdr, spc);
wmb();
- inl->byte_count = cpu_to_be32(1 << 31 | spc);
+ inl->byte_count = cpu_to_be32((1U << 31) | spc);
inl = (void *) (inl + 1) + spc;
memcpy(inl + 1, (void *) &hdr + spc, sizeof (hdr) - spc);
wmb();
- inl->byte_count = cpu_to_be32(1 << 31 | (sizeof (hdr) - spc));
+ inl->byte_count = cpu_to_be32((1U << 31) | (u32)(sizeof (hdr) - spc));
i = 2;
}
@@ -2864,7 +2858,7 @@ static void set_mlx_icrc_seg(void *dseg)
*/
wmb();
- iseg->byte_count = cpu_to_be32((1 << 31) | 4);
+ iseg->byte_count = cpu_to_be32((1U << 31) | 4);
}
static void set_data_seg(struct mlx4_wqe_data_seg *dseg, struct ib_sge *sg)
@@ -2892,23 +2886,22 @@ static void __set_data_seg(struct mlx4_wqe_data_seg *dseg, struct ib_sge *sg)
dseg->addr = cpu_to_be64(sg->addr);
}
-static int build_lso_seg(struct mlx4_wqe_lso_seg *wqe, struct ib_send_wr *wr,
+static int build_lso_seg(struct mlx4_wqe_lso_seg *wqe, struct ib_ud_wr *wr,
struct mlx4_ib_qp *qp, unsigned *lso_seg_len,
__be32 *lso_hdr_sz, __be32 *blh)
{
- unsigned halign = ALIGN(sizeof *wqe + wr->wr.ud.hlen, 16);
+ unsigned halign = ALIGN(sizeof *wqe + wr->hlen, 16);
if (unlikely(halign > MLX4_IB_CACHE_LINE_SIZE))
*blh = cpu_to_be32(1 << 6);
if (unlikely(!(qp->flags & MLX4_IB_QP_LSO) &&
- wr->num_sge > qp->sq.max_gs - (halign >> 4)))
+ wr->wr.num_sge > qp->sq.max_gs - (halign >> 4)))
return -EINVAL;
- memcpy(wqe->header, wr->wr.ud.header, wr->wr.ud.hlen);
+ memcpy(wqe->header, wr->header, wr->hlen);
- *lso_hdr_sz = cpu_to_be32((wr->wr.ud.mss - wr->wr.ud.hlen) << 16 |
- wr->wr.ud.hlen);
+ *lso_hdr_sz = cpu_to_be32(wr->mss << 16 | wr->hlen);
*lso_seg_len = halign;
return 0;
}
@@ -2932,89 +2925,7 @@ static void add_zero_len_inline(void *wqe)
{
struct mlx4_wqe_inline_seg *inl = wqe;
memset(wqe, 0, 16);
- inl->byte_count = cpu_to_be32(1 << 31);
-}
-
-static int lay_inline_data(struct mlx4_ib_qp *qp, struct ib_send_wr *wr,
- void *wqe, int *sz)
-{
- struct mlx4_wqe_inline_seg *seg;
- void *addr;
- int len, seg_len;
- int num_seg;
- int off, to_copy;
- int i;
- int inl = 0;
-
- seg = wqe;
- wqe += sizeof *seg;
- off = ((unsigned long)wqe) & (unsigned long)(MLX4_INLINE_ALIGN - 1);
- num_seg = 0;
- seg_len = 0;
-
- for (i = 0; i < wr->num_sge; ++i) {
- addr = (void *) (unsigned long)(wr->sg_list[i].addr);
- len = wr->sg_list[i].length;
- inl += len;
-
- if (inl > qp->max_inline_data) {
- inl = 0;
- return -1;
- }
-
- while (len >= MLX4_INLINE_ALIGN - off) {
- to_copy = MLX4_INLINE_ALIGN - off;
- memcpy(wqe, addr, to_copy);
- len -= to_copy;
- wqe += to_copy;
- addr += to_copy;
- seg_len += to_copy;
- wmb(); /* see comment below */
- seg->byte_count = htonl(MLX4_INLINE_SEG | seg_len);
- seg_len = 0;
- seg = wqe;
- wqe += sizeof *seg;
- off = sizeof *seg;
- ++num_seg;
- }
-
- memcpy(wqe, addr, len);
- wqe += len;
- seg_len += len;
- off += len;
- }
-
- if (seg_len) {
- ++num_seg;
- /*
- * Need a barrier here to make sure
- * all the data is visible before the
- * byte_count field is set. Otherwise
- * the HCA prefetcher could grab the
- * 64-byte chunk with this inline
- * segment and get a valid (!=
- * 0xffffffff) byte count but stale
- * data, and end up sending the wrong
- * data.
- */
- wmb();
- seg->byte_count = htonl(MLX4_INLINE_SEG | seg_len);
- }
-
- *sz = (inl + num_seg * sizeof *seg + 15) / 16;
-
- return 0;
-}
-
-/*
- * Avoid using memcpy() to copy to BlueFlame page, since memcpy()
- * implementations may use move-string-buffer assembler instructions,
- * which do not guarantee order of copying.
- */
-static void mlx4_bf_copy(unsigned long *dst, unsigned long *src,
- unsigned bytecnt)
-{
- __iowrite64_copy(dst, src, bytecnt / 8);
+ inl->byte_count = cpu_to_be32(1U << 31);
}
int mlx4_ib_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr,
@@ -3022,7 +2933,7 @@ int mlx4_ib_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr,
{
struct mlx4_ib_qp *qp = to_mqp(ibqp);
void *wqe;
- struct mlx4_wqe_ctrl_seg *uninitialized_var(ctrl);
+ struct mlx4_wqe_ctrl_seg *ctrl;
struct mlx4_wqe_data_seg *dseg;
unsigned long flags;
int nreq;
@@ -3033,11 +2944,41 @@ int mlx4_ib_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr,
unsigned uninitialized_var(seglen);
__be32 dummy;
__be32 *lso_wqe;
- __be32 uninitialized_var(lso_hdr_sz);
+ __be32 lso_hdr_sz = 0;
__be32 blh;
int i;
- int inl = 0;
+ struct mlx4_ib_dev *mdev = to_mdev(ibqp->device);
+
+ if (qp->mlx4_ib_qp_type == MLX4_IB_QPT_GSI) {
+ struct mlx4_ib_sqp *sqp = to_msqp(qp);
+
+ if (sqp->roce_v2_gsi) {
+ struct mlx4_ib_ah *ah = to_mah(ud_wr(wr)->ah);
+ struct ib_gid_attr gid_attr;
+ union ib_gid gid;
+
+ if (!ib_get_cached_gid(ibqp->device,
+ be32_to_cpu(ah->av.ib.port_pd) >> 24,
+ ah->av.ib.gid_index, &gid,
+ &gid_attr)) {
+ if (gid_attr.ndev)
+ dev_put(gid_attr.ndev);
+ qp = (gid_attr.gid_type == IB_GID_TYPE_ROCE_UDP_ENCAP) ?
+ to_mqp(sqp->roce_v2_gsi) : qp;
+ } else {
+ pr_err("Failed to get gid at index %d. RoCEv2 will not work properly\n",
+ ah->av.ib.gid_index);
+ }
+ }
+ }
+
spin_lock_irqsave(&qp->sq.lock, flags);
+ if (mdev->dev->persist->state & MLX4_DEVICE_STATE_INTERNAL_ERROR) {
+ err = -EIO;
+ *bad_wr = wr;
+ nreq = 0;
+ goto out;
+ }
ind = qp->sq_next_wqe;
@@ -3058,7 +2999,6 @@ int mlx4_ib_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr,
}
ctrl = wqe = get_send_wqe(qp, ind & (qp->sq.wqe_cnt - 1));
- *((u32 *) (&ctrl->vlan_tag)) = 0;
qp->sq.wrid[(qp->sq.head + nreq) & (qp->sq.wqe_cnt - 1)] = wr->wr_id;
ctrl->srcrb_flags =
@@ -3083,11 +3023,11 @@ int mlx4_ib_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr,
case IB_WR_ATOMIC_CMP_AND_SWP:
case IB_WR_ATOMIC_FETCH_AND_ADD:
case IB_WR_MASKED_ATOMIC_FETCH_AND_ADD:
- set_raddr_seg(wqe, wr->wr.atomic.remote_addr,
- wr->wr.atomic.rkey);
+ set_raddr_seg(wqe, atomic_wr(wr)->remote_addr,
+ atomic_wr(wr)->rkey);
wqe += sizeof (struct mlx4_wqe_raddr_seg);
- set_atomic_seg(wqe, wr);
+ set_atomic_seg(wqe, atomic_wr(wr));
wqe += sizeof (struct mlx4_wqe_atomic_seg);
size += (sizeof (struct mlx4_wqe_raddr_seg) +
@@ -3096,11 +3036,11 @@ int mlx4_ib_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr,
break;
case IB_WR_MASKED_ATOMIC_CMP_AND_SWP:
- set_raddr_seg(wqe, wr->wr.atomic.remote_addr,
- wr->wr.atomic.rkey);
+ set_raddr_seg(wqe, atomic_wr(wr)->remote_addr,
+ atomic_wr(wr)->rkey);
wqe += sizeof (struct mlx4_wqe_raddr_seg);
- set_masked_atomic_seg(wqe, wr);
+ set_masked_atomic_seg(wqe, atomic_wr(wr));
wqe += sizeof (struct mlx4_wqe_masked_atomic_seg);
size += (sizeof (struct mlx4_wqe_raddr_seg) +
@@ -3111,8 +3051,8 @@ int mlx4_ib_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr,
case IB_WR_RDMA_READ:
case IB_WR_RDMA_WRITE:
case IB_WR_RDMA_WRITE_WITH_IMM:
- set_raddr_seg(wqe, wr->wr.rdma.remote_addr,
- wr->wr.rdma.rkey);
+ set_raddr_seg(wqe, rdma_wr(wr)->remote_addr,
+ rdma_wr(wr)->rkey);
wqe += sizeof (struct mlx4_wqe_raddr_seg);
size += sizeof (struct mlx4_wqe_raddr_seg) / 16;
break;
@@ -3125,20 +3065,14 @@ int mlx4_ib_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr,
size += sizeof (struct mlx4_wqe_local_inval_seg) / 16;
break;
- case IB_WR_FAST_REG_MR:
+ case IB_WR_REG_MR:
ctrl->srcrb_flags |=
cpu_to_be32(MLX4_WQE_CTRL_STRONG_ORDER);
- set_fmr_seg(wqe, wr);
- wqe += sizeof (struct mlx4_wqe_fmr_seg);
- size += sizeof (struct mlx4_wqe_fmr_seg) / 16;
+ set_reg_seg(wqe, reg_wr(wr));
+ wqe += sizeof(struct mlx4_wqe_fmr_seg);
+ size += sizeof(struct mlx4_wqe_fmr_seg) / 16;
break;
- case IB_WR_BIND_MW:
- ctrl->srcrb_flags |=
- cpu_to_be32(MLX4_WQE_CTRL_STRONG_ORDER);
- set_bind_seg(wqe, wr);
- wqe += sizeof(struct mlx4_wqe_bind_seg);
- size += sizeof(struct mlx4_wqe_bind_seg) / 16;
default:
/* No extra segments required for sends */
break;
@@ -3146,7 +3080,8 @@ int mlx4_ib_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr,
break;
case MLX4_IB_QPT_TUN_SMI_OWNER:
- err = build_sriov_qp0_header(to_msqp(qp), wr, ctrl, &seglen);
+ err = build_sriov_qp0_header(to_msqp(qp), ud_wr(wr),
+ ctrl, &seglen);
if (unlikely(err)) {
*bad_wr = wr;
goto out;
@@ -3157,19 +3092,20 @@ int mlx4_ib_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr,
case MLX4_IB_QPT_TUN_SMI:
case MLX4_IB_QPT_TUN_GSI:
/* this is a UD qp used in MAD responses to slaves. */
- set_datagram_seg(wqe, wr);
+ set_datagram_seg(wqe, ud_wr(wr));
/* set the forced-loopback bit in the data seg av */
*(__be32 *) wqe |= cpu_to_be32(0x80000000);
wqe += sizeof (struct mlx4_wqe_datagram_seg);
size += sizeof (struct mlx4_wqe_datagram_seg) / 16;
break;
case MLX4_IB_QPT_UD:
- set_datagram_seg(wqe, wr);
+ set_datagram_seg(wqe, ud_wr(wr));
wqe += sizeof (struct mlx4_wqe_datagram_seg);
size += sizeof (struct mlx4_wqe_datagram_seg) / 16;
if (wr->opcode == IB_WR_LSO) {
- err = build_lso_seg(wqe, wr, qp, &seglen, &lso_hdr_sz, &blh);
+ err = build_lso_seg(wqe, ud_wr(wr), qp, &seglen,
+ &lso_hdr_sz, &blh);
if (unlikely(err)) {
*bad_wr = wr;
goto out;
@@ -3181,12 +3117,8 @@ int mlx4_ib_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr,
break;
case MLX4_IB_QPT_PROXY_SMI_OWNER:
- if (unlikely(!mlx4_is_master(to_mdev(ibqp->device)->dev))) {
- err = -ENOSYS;
- *bad_wr = wr;
- goto out;
- }
- err = build_sriov_qp0_header(to_msqp(qp), wr, ctrl, &seglen);
+ err = build_sriov_qp0_header(to_msqp(qp), ud_wr(wr),
+ ctrl, &seglen);
if (unlikely(err)) {
*bad_wr = wr;
goto out;
@@ -3197,31 +3129,30 @@ int mlx4_ib_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr,
add_zero_len_inline(wqe);
wqe += 16;
size++;
- build_tunnel_header(wr, wqe, &seglen);
+ build_tunnel_header(ud_wr(wr), wqe, &seglen);
wqe += seglen;
size += seglen / 16;
break;
case MLX4_IB_QPT_PROXY_SMI:
- /* don't allow QP0 sends on guests */
- err = -ENOSYS;
- *bad_wr = wr;
- goto out;
case MLX4_IB_QPT_PROXY_GSI:
/* If we are tunneling special qps, this is a UD qp.
* In this case we first add a UD segment targeting
* the tunnel qp, and then add a header with address
* information */
- set_tunnel_datagram_seg(to_mdev(ibqp->device), wqe, wr, ibqp->qp_type);
+ set_tunnel_datagram_seg(to_mdev(ibqp->device), wqe,
+ ud_wr(wr),
+ qp->mlx4_ib_qp_type);
wqe += sizeof (struct mlx4_wqe_datagram_seg);
size += sizeof (struct mlx4_wqe_datagram_seg) / 16;
- build_tunnel_header(wr, wqe, &seglen);
+ build_tunnel_header(ud_wr(wr), wqe, &seglen);
wqe += seglen;
size += seglen / 16;
break;
case MLX4_IB_QPT_SMI:
case MLX4_IB_QPT_GSI:
- err = build_mlx_header(to_msqp(qp), wr, ctrl, &seglen);
+ err = build_mlx_header(to_msqp(qp), ud_wr(wr), ctrl,
+ &seglen);
if (unlikely(err)) {
*bad_wr = wr;
goto out;
@@ -3240,8 +3171,10 @@ int mlx4_ib_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr,
* cacheline. This avoids issues with WQE
* prefetching.
*/
+
dseg = wqe;
dseg += wr->num_sge - 1;
+ size += wr->num_sge * (sizeof (struct mlx4_wqe_data_seg) / 16);
/* Add one more inline data segment for ICRC for MLX sends */
if (unlikely(qp->mlx4_ib_qp_type == MLX4_IB_QPT_SMI ||
@@ -3252,19 +3185,8 @@ int mlx4_ib_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr,
size += sizeof (struct mlx4_wqe_data_seg) / 16;
}
- if (wr->send_flags & IB_SEND_INLINE && wr->num_sge) {
- int sz;
- err = lay_inline_data(qp, wr, wqe, &sz);
- if (!err) {
- inl = 1;
- size += sz;
- }
- } else {
- size += wr->num_sge *
- (sizeof(struct mlx4_wqe_data_seg) / 16);
- for (i = wr->num_sge - 1; i >= 0; --i, --dseg)
- set_data_seg(dseg, wr->sg_list + i);
- }
+ for (i = wr->num_sge - 1; i >= 0; --i, --dseg)
+ set_data_seg(dseg, wr->sg_list + i);
/*
* Possibly overwrite stamping in cacheline with LSO
@@ -3273,8 +3195,9 @@ int mlx4_ib_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr,
*/
wmb();
*lso_wqe = lso_hdr_sz;
+
ctrl->fence_size = (wr->send_flags & IB_SEND_FENCE ?
- MLX4_WQE_CTRL_FENCE : 0) | size;
+ MLX4_WQE_CTRL_FENCE : 0) | size;
/*
* Make sure descriptor is fully written before
@@ -3311,27 +3234,7 @@ int mlx4_ib_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr,
}
out:
- if (nreq == 1 && inl && size > 1 && size < qp->bf.buf_size / 16) {
- ctrl->owner_opcode |= htonl((qp->sq_next_wqe & 0xffff) << 8);
- /* We set above doorbell_qpn bits to 0 as part of vlan
- * tag initialization, so |= should be correct.
- */
- *(u32 *) (&ctrl->vlan_tag) |= qp->doorbell_qpn;
- /*
- * Make sure that descriptor is written to memory
- * before writing to BlueFlame page.
- */
- wmb();
-
- ++qp->sq.head;
-
- mlx4_bf_copy(qp->bf.reg + qp->bf.offset, (unsigned long *) ctrl,
- ALIGN(size * 16, 64));
- wc_wmb();
-
- qp->bf.offset ^= qp->bf.buf_size;
-
- } else if (nreq) {
+ if (likely(nreq)) {
qp->sq.head += nreq;
/*
@@ -3340,7 +3243,8 @@ out:
*/
wmb();
- writel(qp->doorbell_qpn, qp->bf.uar->map + MLX4_SEND_DOORBELL);
+ writel(qp->doorbell_qpn,
+ to_mdev(ibqp->device)->uar_map + MLX4_SEND_DOORBELL);
/*
* Make sure doorbells don't leak out of SQ spinlock
@@ -3348,10 +3252,8 @@ out:
*/
mmiowb();
- }
-
- if (likely(nreq)) {
stamp_send_wqe(qp, stamp, size * 16);
+
ind = pad_wraparound(qp, ind);
qp->sq_next_wqe = ind;
}
@@ -3372,10 +3274,18 @@ int mlx4_ib_post_recv(struct ib_qp *ibqp, struct ib_recv_wr *wr,
int ind;
int max_gs;
int i;
+ struct mlx4_ib_dev *mdev = to_mdev(ibqp->device);
max_gs = qp->rq.max_gs;
spin_lock_irqsave(&qp->rq.lock, flags);
+ if (mdev->dev->persist->state & MLX4_DEVICE_STATE_INTERNAL_ERROR) {
+ err = -EIO;
+ *bad_wr = wr;
+ nreq = 0;
+ goto out;
+ }
+
ind = qp->rq.head & (qp->rq.wqe_cnt - 1);
for (nreq = 0; wr; ++nreq, wr = wr->next) {
@@ -3613,22 +3523,8 @@ done:
qp->sq_signal_bits == cpu_to_be32(MLX4_WQE_CTRL_CQ_UPDATE) ?
IB_SIGNAL_ALL_WR : IB_SIGNAL_REQ_WR;
- if (qp->flags & MLX4_IB_QP_CAP_CROSS_CHANNEL)
- qp_init_attr->create_flags |= IB_QP_CREATE_CROSS_CHANNEL;
-
- if (qp->flags & MLX4_IB_QP_CAP_MANAGED_SEND)
- qp_init_attr->create_flags |= IB_QP_CREATE_MANAGED_SEND;
-
- if (qp->flags & MLX4_IB_QP_CAP_MANAGED_RECV)
- qp_init_attr->create_flags |= IB_QP_CREATE_MANAGED_RECV;
-
- qp_init_attr->qpg_type = ibqp->qpg_type;
- if (ibqp->qpg_type == IB_QPG_PARENT)
- qp_init_attr->cap.qpg_tss_mask_sz = qp->qpg_data->qpg_tss_mask_sz;
- else
- qp_init_attr->cap.qpg_tss_mask_sz = 0;
-
out:
mutex_unlock(&qp->mutex);
return err;
}
+
diff --git a/sys/dev/mlx4/mlx4_ib/mlx4_ib_srq.c b/sys/dev/mlx4/mlx4_ib/mlx4_ib_srq.c
index f672c0c..a2e55db 100644
--- a/sys/dev/mlx4/mlx4_ib/mlx4_ib_srq.c
+++ b/sys/dev/mlx4/mlx4_ib/mlx4_ib_srq.c
@@ -36,7 +36,7 @@
#include <linux/slab.h>
#include "mlx4_ib.h"
-#include "user.h"
+#include <rdma/mlx4-abi.h>
static void *get_wqe(struct mlx4_ib_srq *srq, int n)
{
@@ -170,10 +170,15 @@ struct ib_srq *mlx4_ib_create_srq(struct ib_pd *pd,
if (err)
goto err_mtt;
- srq->wrid = kmalloc(srq->msrq.max * sizeof (u64), GFP_KERNEL);
+ srq->wrid = kmalloc_array(srq->msrq.max, sizeof(u64),
+ GFP_KERNEL | __GFP_NOWARN);
if (!srq->wrid) {
- err = -ENOMEM;
- goto err_mtt;
+ srq->wrid = __vmalloc(srq->msrq.max * sizeof(u64),
+ GFP_KERNEL, 0 /*PAGE_KERNEL*/);
+ if (!srq->wrid) {
+ err = -ENOMEM;
+ goto err_mtt;
+ }
}
}
@@ -204,7 +209,7 @@ err_wrid:
if (pd->uobject)
mlx4_ib_db_unmap_user(to_mucontext(pd->uobject->context), &srq->db);
else
- kfree(srq->wrid);
+ kvfree(srq->wrid);
err_mtt:
mlx4_mtt_cleanup(dev->dev, &srq->mtt);
@@ -281,7 +286,7 @@ int mlx4_ib_destroy_srq(struct ib_srq *srq)
mlx4_ib_db_unmap_user(to_mucontext(srq->uobject->context), &msrq->db);
ib_umem_release(msrq->umem);
} else {
- kfree(msrq->wrid);
+ kvfree(msrq->wrid);
mlx4_buf_free(dev->dev, msrq->msrq.max << msrq->msrq.wqe_shift,
&msrq->buf);
mlx4_db_free(dev->dev, &msrq->db);
@@ -316,8 +321,15 @@ int mlx4_ib_post_srq_recv(struct ib_srq *ibsrq, struct ib_recv_wr *wr,
int err = 0;
int nreq;
int i;
+ struct mlx4_ib_dev *mdev = to_mdev(ibsrq->device);
spin_lock_irqsave(&srq->lock, flags);
+ if (mdev->dev->persist->state & MLX4_DEVICE_STATE_INTERNAL_ERROR) {
+ err = -EIO;
+ *bad_wr = wr;
+ nreq = 0;
+ goto out;
+ }
for (nreq = 0; wr; ++nreq, wr = wr->next) {
if (unlikely(wr->num_sge > srq->msrq.max_gs)) {
@@ -362,6 +374,7 @@ int mlx4_ib_post_srq_recv(struct ib_srq *ibsrq, struct ib_recv_wr *wr,
*srq->db.db = cpu_to_be32(srq->wqe_ctr);
}
+out:
spin_unlock_irqrestore(&srq->lock, flags);
diff --git a/sys/dev/mlx4/mlx4_ib/mlx4_ib_sysfs.c b/sys/dev/mlx4/mlx4_ib/mlx4_ib_sysfs.c
index eac5d1c..af192fe 100644
--- a/sys/dev/mlx4/mlx4_ib/mlx4_ib_sysfs.c
+++ b/sys/dev/mlx4/mlx4_ib/mlx4_ib_sysfs.c
@@ -46,21 +46,17 @@
static ssize_t show_admin_alias_guid(struct device *dev,
struct device_attribute *attr, char *buf)
{
- int record_num;/*0-15*/
- int guid_index_in_rec; /*0 - 7*/
struct mlx4_ib_iov_sysfs_attr *mlx4_ib_iov_dentry =
container_of(attr, struct mlx4_ib_iov_sysfs_attr, dentry);
struct mlx4_ib_iov_port *port = mlx4_ib_iov_dentry->ctx;
struct mlx4_ib_dev *mdev = port->dev;
+ __be64 sysadmin_ag_val;
- record_num = mlx4_ib_iov_dentry->entry_num / 8 ;
- guid_index_in_rec = mlx4_ib_iov_dentry->entry_num % 8 ;
+ sysadmin_ag_val = mlx4_get_admin_guid(mdev->dev,
+ mlx4_ib_iov_dentry->entry_num,
+ port->num);
- return sprintf(buf, "%llx\n",
- (long long)be64_to_cpu(*(__be64 *)&mdev->sriov.alias_guid.
- ports_guid[port->num - 1].
- all_rec_per_port[record_num].
- all_recs[8 * guid_index_in_rec]));
+ return sprintf(buf, "%llx\n", (long long)be64_to_cpu(sysadmin_ag_val));
}
/* store_admin_alias_guid stores the (new) administratively assigned value of that GUID.
@@ -80,6 +76,7 @@ static ssize_t store_admin_alias_guid(struct device *dev,
struct mlx4_ib_iov_port *port = mlx4_ib_iov_dentry->ctx;
struct mlx4_ib_dev *mdev = port->dev;
unsigned long long sysadmin_ag_val;
+ unsigned long flags;
record_num = mlx4_ib_iov_dentry->entry_num / 8;
guid_index_in_rec = mlx4_ib_iov_dentry->entry_num % 8;
@@ -87,6 +84,7 @@ static ssize_t store_admin_alias_guid(struct device *dev,
pr_err("GUID 0 block 0 is RO\n");
return count;
}
+ spin_lock_irqsave(&mdev->sriov.alias_guid.ag_work_lock, flags);
sscanf(buf, "%llx", &sysadmin_ag_val);
*(__be64 *)&mdev->sriov.alias_guid.ports_guid[port->num - 1].
all_rec_per_port[record_num].
@@ -96,33 +94,15 @@ static ssize_t store_admin_alias_guid(struct device *dev,
/* Change the state to be pending for update */
mdev->sriov.alias_guid.ports_guid[port->num - 1].all_rec_per_port[record_num].status
= MLX4_GUID_INFO_STATUS_IDLE ;
-
- mdev->sriov.alias_guid.ports_guid[port->num - 1].all_rec_per_port[record_num].method
- = MLX4_GUID_INFO_RECORD_SET;
-
- switch (sysadmin_ag_val) {
- case MLX4_GUID_FOR_DELETE_VAL:
- mdev->sriov.alias_guid.ports_guid[port->num - 1].all_rec_per_port[record_num].method
- = MLX4_GUID_INFO_RECORD_DELETE;
- mdev->sriov.alias_guid.ports_guid[port->num - 1].all_rec_per_port[record_num].ownership
- = MLX4_GUID_SYSADMIN_ASSIGN;
- break;
- /* The sysadmin requests the SM to re-assign */
- case MLX4_NOT_SET_GUID:
- mdev->sriov.alias_guid.ports_guid[port->num - 1].all_rec_per_port[record_num].ownership
- = MLX4_GUID_DRIVER_ASSIGN;
- break;
- /* The sysadmin requests a specific value.*/
- default:
- mdev->sriov.alias_guid.ports_guid[port->num - 1].all_rec_per_port[record_num].ownership
- = MLX4_GUID_SYSADMIN_ASSIGN;
- break;
- }
+ mlx4_set_admin_guid(mdev->dev, cpu_to_be64(sysadmin_ag_val),
+ mlx4_ib_iov_dentry->entry_num,
+ port->num);
/* set the record index */
mdev->sriov.alias_guid.ports_guid[port->num - 1].all_rec_per_port[record_num].guid_indexes
- = mlx4_ib_get_aguid_comp_mask_from_ix(guid_index_in_rec);
+ |= mlx4_ib_get_aguid_comp_mask_from_ix(guid_index_in_rec);
+ spin_unlock_irqrestore(&mdev->sriov.alias_guid.ag_work_lock, flags);
mlx4_ib_init_alias_guid_work(mdev, port->num - 1);
return count;
@@ -389,8 +369,10 @@ struct mlx4_port {
struct mlx4_ib_dev *dev;
struct attribute_group pkey_group;
struct attribute_group gid_group;
- u8 port_num;
+ struct device_attribute enable_smi_admin;
+ struct device_attribute smi_enabled;
int slave;
+ u8 port_num;
};
@@ -558,6 +540,101 @@ err:
return NULL;
}
+static ssize_t sysfs_show_smi_enabled(struct device *dev,
+ struct device_attribute *attr, char *buf)
+{
+ struct mlx4_port *p =
+ container_of(attr, struct mlx4_port, smi_enabled);
+ ssize_t len = 0;
+
+ if (mlx4_vf_smi_enabled(p->dev->dev, p->slave, p->port_num))
+ len = sprintf(buf, "%d\n", 1);
+ else
+ len = sprintf(buf, "%d\n", 0);
+
+ return len;
+}
+
+static ssize_t sysfs_show_enable_smi_admin(struct device *dev,
+ struct device_attribute *attr,
+ char *buf)
+{
+ struct mlx4_port *p =
+ container_of(attr, struct mlx4_port, enable_smi_admin);
+ ssize_t len = 0;
+
+ if (mlx4_vf_get_enable_smi_admin(p->dev->dev, p->slave, p->port_num))
+ len = sprintf(buf, "%d\n", 1);
+ else
+ len = sprintf(buf, "%d\n", 0);
+
+ return len;
+}
+
+static ssize_t sysfs_store_enable_smi_admin(struct device *dev,
+ struct device_attribute *attr,
+ const char *buf, size_t count)
+{
+ struct mlx4_port *p =
+ container_of(attr, struct mlx4_port, enable_smi_admin);
+ int enable;
+
+ if (sscanf(buf, "%i", &enable) != 1 ||
+ enable < 0 || enable > 1)
+ return -EINVAL;
+
+ if (mlx4_vf_set_enable_smi_admin(p->dev->dev, p->slave, p->port_num, enable))
+ return -EINVAL;
+ return count;
+}
+
+static int add_vf_smi_entries(struct mlx4_port *p)
+{
+ int is_eth = rdma_port_get_link_layer(&p->dev->ib_dev, p->port_num) ==
+ IB_LINK_LAYER_ETHERNET;
+ int ret;
+
+ /* do not display entries if eth transport, or if master */
+ if (is_eth || p->slave == mlx4_master_func_num(p->dev->dev))
+ return 0;
+
+ sysfs_attr_init(&p->smi_enabled.attr);
+ p->smi_enabled.show = sysfs_show_smi_enabled;
+ p->smi_enabled.store = NULL;
+ p->smi_enabled.attr.name = "smi_enabled";
+ p->smi_enabled.attr.mode = 0444;
+ ret = sysfs_create_file(&p->kobj, &p->smi_enabled.attr);
+ if (ret) {
+ pr_err("failed to create smi_enabled\n");
+ return ret;
+ }
+
+ sysfs_attr_init(&p->enable_smi_admin.attr);
+ p->enable_smi_admin.show = sysfs_show_enable_smi_admin;
+ p->enable_smi_admin.store = sysfs_store_enable_smi_admin;
+ p->enable_smi_admin.attr.name = "enable_smi_admin";
+ p->enable_smi_admin.attr.mode = 0644;
+ ret = sysfs_create_file(&p->kobj, &p->enable_smi_admin.attr);
+ if (ret) {
+ pr_err("failed to create enable_smi_admin\n");
+ sysfs_remove_file(&p->kobj, &p->smi_enabled.attr);
+ return ret;
+ }
+ return 0;
+}
+
+static void remove_vf_smi_entries(struct mlx4_port *p)
+{
+ int is_eth = rdma_port_get_link_layer(&p->dev->ib_dev, p->port_num) ==
+ IB_LINK_LAYER_ETHERNET;
+
+ if (is_eth || p->slave == mlx4_master_func_num(p->dev->dev))
+ return;
+
+ sysfs_remove_file(&p->kobj, &p->smi_enabled.attr);
+ sysfs_remove_file(&p->kobj, &p->enable_smi_admin.attr);
+}
+
static int add_port(struct mlx4_ib_dev *dev, int port_num, int slave)
{
struct mlx4_port *p;
@@ -581,16 +658,14 @@ static int add_port(struct mlx4_ib_dev *dev, int port_num, int slave)
goto err_alloc;
p->pkey_group.name = "pkey_idx";
- if (is_eth)
- p->pkey_group.attrs =
- alloc_group_attrs(show_port_pkey, NULL,
- dev->dev->caps.pkey_table_len[port_num]);
- else
- p->pkey_group.attrs =
- alloc_group_attrs(show_port_pkey, store_port_pkey,
- dev->dev->caps.pkey_table_len[port_num]);
- if (!p->pkey_group.attrs)
+ p->pkey_group.attrs =
+ alloc_group_attrs(show_port_pkey,
+ is_eth ? NULL : store_port_pkey,
+ dev->dev->caps.pkey_table_len[port_num]);
+ if (!p->pkey_group.attrs) {
+ ret = -ENOMEM;
goto err_alloc;
+ }
ret = sysfs_create_group(&p->kobj, &p->pkey_group);
if (ret)
@@ -598,13 +673,19 @@ static int add_port(struct mlx4_ib_dev *dev, int port_num, int slave)
p->gid_group.name = "gid_idx";
p->gid_group.attrs = alloc_group_attrs(show_port_gid_idx, NULL, 1);
- if (!p->gid_group.attrs)
+ if (!p->gid_group.attrs) {
+ ret = -ENOMEM;
goto err_free_pkey;
+ }
ret = sysfs_create_group(&p->kobj, &p->gid_group);
if (ret)
goto err_free_gid;
+ ret = add_vf_smi_entries(p);
+ if (ret)
+ goto err_free_gid;
+
list_add_tail(&p->kobj.entry, &dev->pkeys.pkey_port_list[slave]);
return 0;
@@ -630,6 +711,7 @@ static int register_one_pkey_tree(struct mlx4_ib_dev *dev, int slave)
int port;
struct kobject *p, *t;
struct mlx4_port *mport;
+ struct mlx4_active_ports actv_ports;
get_name(dev, name, slave, sizeof name);
@@ -652,7 +734,11 @@ static int register_one_pkey_tree(struct mlx4_ib_dev *dev, int slave)
goto err_ports;
}
+ actv_ports = mlx4_get_active_ports(dev->dev, slave);
+
for (port = 1; port <= dev->dev->caps.num_ports; ++port) {
+ if (!test_bit(port - 1, actv_ports.ports))
+ continue;
err = add_port(dev, port, slave);
if (err)
goto err_add;
@@ -667,6 +753,7 @@ err_add:
mport = container_of(p, struct mlx4_port, kobj);
sysfs_remove_group(p, &mport->pkey_group);
sysfs_remove_group(p, &mport->gid_group);
+ remove_vf_smi_entries(mport);
kobject_put(p);
}
kobject_put(dev->dev_ports_parent[slave]);
@@ -711,6 +798,7 @@ static void unregister_pkey_tree(struct mlx4_ib_dev *device)
port = container_of(p, struct mlx4_port, kobj);
sysfs_remove_group(p, &port->pkey_group);
sysfs_remove_group(p, &port->gid_group);
+ remove_vf_smi_entries(port);
kobject_put(p);
kobject_put(device->dev_ports_parent[slave]);
}
@@ -739,7 +827,7 @@ int mlx4_ib_device_register_sysfs(struct mlx4_ib_dev *dev)
dev->ports_parent =
kobject_create_and_add("ports",
kobject_get(dev->iov_parent));
- if (!dev->iov_parent) {
+ if (!dev->ports_parent) {
ret = -ENOMEM;
goto err_ports;
}
diff --git a/sys/dev/mlx4/mlx4_ib/user.h b/sys/dev/mlx4/mlx4_ib/user.h
deleted file mode 100644
index 07e6769..0000000
--- a/sys/dev/mlx4/mlx4_ib/user.h
+++ /dev/null
@@ -1,107 +0,0 @@
-/*
- * Copyright (c) 2007 Cisco Systems, Inc. All rights reserved.
- * Copyright (c) 2007, 2008 Mellanox Technologies. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-#ifndef MLX4_IB_USER_H
-#define MLX4_IB_USER_H
-
-#include <linux/types.h>
-
-/*
- * Increment this value if any changes that break userspace ABI
- * compatibility are made.
- */
-
-#define MLX4_IB_UVERBS_NO_DEV_CAPS_ABI_VERSION 3
-#define MLX4_IB_UVERBS_ABI_VERSION 4
-
-/*
- * Make sure that all structs defined in this file remain laid out so
- * that they pack the same way on 32-bit and 64-bit architectures (to
- * avoid incompatibility between 32-bit userspace and 64-bit kernels).
- * In particular do not use pointer types -- pass pointers in __u64
- * instead.
- */
-
-struct mlx4_ib_alloc_ucontext_resp_v3 {
- __u32 qp_tab_size;
- __u16 bf_reg_size;
- __u16 bf_regs_per_page;
-};
-
-struct mlx4_ib_alloc_ucontext_resp {
- __u32 dev_caps;
- __u32 qp_tab_size;
- __u16 bf_reg_size;
- __u16 bf_regs_per_page;
- __u32 cqe_size;
-};
-
-struct mlx4_ib_alloc_pd_resp {
- __u32 pdn;
- __u32 reserved;
-};
-
-struct mlx4_ib_create_cq {
- __u64 buf_addr;
- __u64 db_addr;
-};
-
-struct mlx4_ib_create_cq_resp {
- __u32 cqn;
- __u32 reserved;
-};
-
-struct mlx4_ib_resize_cq {
- __u64 buf_addr;
-};
-
-struct mlx4_ib_create_srq {
- __u64 buf_addr;
- __u64 db_addr;
-};
-
-struct mlx4_ib_create_srq_resp {
- __u32 srqn;
- __u32 reserved;
-};
-
-struct mlx4_ib_create_qp {
- __u64 buf_addr;
- __u64 db_addr;
- __u8 log_sq_bb_count;
- __u8 log_sq_stride;
- __u8 sq_no_prefetch;
- __u8 reserved[5];
-};
-
-#endif /* MLX4_IB_USER_H */
diff --git a/sys/dev/mlx5/mlx5_ib/mlx5_ib.h b/sys/dev/mlx5/mlx5_ib/mlx5_ib.h
index 2ddae91..31f957d 100644
--- a/sys/dev/mlx5/mlx5_ib/mlx5_ib.h
+++ b/sys/dev/mlx5/mlx5_ib/mlx5_ib.h
@@ -30,31 +30,33 @@
#include <linux/kernel.h>
#include <linux/sched.h>
+#include <linux/printk.h>
#include <rdma/ib_verbs.h>
#include <rdma/ib_smi.h>
-#include <rdma/ib_addr.h>
-#include <dev/mlx5/device.h>
-#include <dev/mlx5/driver.h>
#include <dev/mlx5/cq.h>
#include <dev/mlx5/qp.h>
#include <dev/mlx5/srq.h>
#include <linux/types.h>
#include <dev/mlx5/mlx5_core/transobj.h>
+#include <rdma/ib_user_verbs.h>
+#include <rdma/mlx5-abi.h>
#define mlx5_ib_dbg(dev, format, arg...) \
-pr_debug("mlx5_dbg:%s:%s:%d:(pid %d): " format, (dev)->ib_dev.name, __func__, \
- __LINE__, curthread->td_proc->p_pid, ##arg)
+pr_debug("%s:%s:%d:(pid %d): " format, (dev)->ib_dev.name, __func__, \
+ __LINE__, current->pid, ##arg)
#define mlx5_ib_err(dev, format, arg...) \
-printf("mlx5_ib: ERR: ""mlx5_err:%s:%s:%d:(pid %d): " format, (dev)->ib_dev.name, __func__, \
- __LINE__, curthread->td_proc->p_pid, ##arg)
+pr_err("%s:%s:%d:(pid %d): " format, (dev)->ib_dev.name, __func__, \
+ __LINE__, current->pid, ##arg)
#define mlx5_ib_warn(dev, format, arg...) \
-printf("mlx5_ib: WARN: ""mlx5_warn:%s:%s:%d:(pid %d): " format, (dev)->ib_dev.name, __func__, \
- __LINE__, curthread->td_proc->p_pid, ##arg)
-#define BF_ENABLE 0
+pr_warn("%s:%s:%d:(pid %d): " format, (dev)->ib_dev.name, __func__, \
+ __LINE__, current->pid, ##arg)
-extern struct workqueue_struct *mlx5_ib_wq;
+#define field_avail(type, fld, sz) (offsetof(type, fld) + \
+ sizeof(((type *)0)->fld) <= (sz))
+#define MLX5_IB_DEFAULT_UIDX 0xffffff
+#define MLX5_USER_ASSIGNED_UIDX_MASK __mlx5_mask(qpc, user_index)
enum {
MLX5_IB_MMAP_CMD_SHIFT = 8,
@@ -66,13 +68,8 @@ enum mlx5_ib_mmap_cmd {
MLX5_IB_MMAP_GET_CONTIGUOUS_PAGES = 1,
MLX5_IB_MMAP_WC_PAGE = 2,
MLX5_IB_MMAP_NC_PAGE = 3,
- MLX5_IB_MMAP_MAP_DC_INFO_PAGE = 4,
-
- /* Use EXP mmap commands until it is pushed to upstream */
- MLX5_IB_EXP_MMAP_CORE_CLOCK = 0xFB,
- MLX5_IB_EXP_MMAP_GET_CONTIGUOUS_PAGES_CPU_NUMA = 0xFC,
- MLX5_IB_EXP_MMAP_GET_CONTIGUOUS_PAGES_DEV_NUMA = 0xFD,
- MLX5_IB_EXP_ALLOC_N_MMAP_WC = 0xFE,
+ /* 5 is chosen in order to be compatible with old versions of libmlx5 */
+ MLX5_IB_MMAP_CORE_CLOCK = 5,
};
enum {
@@ -82,11 +79,6 @@ enum {
MLX5_REQ_SCAT_DATA64_CQE = 0x22,
};
-enum {
- MLX5_DCT_CS_RES_64 = 2,
- MLX5_CNAK_RX_POLL_CQ_QUOTA = 256,
-};
-
enum mlx5_ib_latency_class {
MLX5_IB_LATENCY_CLASS_LOW,
MLX5_IB_LATENCY_CLASS_MEDIUM,
@@ -101,19 +93,17 @@ enum mlx5_ib_mad_ifc_flags {
};
enum {
- MLX5_CROSS_CHANNEL_UUAR = 0,
+ MLX5_CROSS_CHANNEL_UUAR = 0,
};
enum {
- MLX5_IB_MAX_CTX_DYNAMIC_UARS = 256,
- MLX5_IB_INVALID_UAR_INDEX = -1U
+ MLX5_CQE_VERSION_V0,
+ MLX5_CQE_VERSION_V1,
};
-enum {
- MLX5_MAX_SINGLE_STRIDE_LOG_NUM_BYTES = 13,
- MLX5_MIN_SINGLE_STRIDE_LOG_NUM_BYTES = 6,
- MLX5_MAX_SINGLE_WQE_LOG_NUM_STRIDES = 16,
- MLX5_MIN_SINGLE_WQE_LOG_NUM_STRIDES = 9,
+struct mlx5_ib_vma_private_data {
+ struct list_head list;
+ struct vm_area_struct *vma;
};
struct mlx5_ib_ucontext {
@@ -124,9 +114,10 @@ struct mlx5_ib_ucontext {
*/
struct mutex db_page_mutex;
struct mlx5_uuar_info uuari;
- u32 dynamic_wc_uar_index[MLX5_IB_MAX_CTX_DYNAMIC_UARS];
+ u8 cqe_version;
/* Transport Domain number */
u32 tdn;
+ struct list_head vma_private_list;
};
static inline struct mlx5_ib_ucontext *to_mucontext(struct ib_ucontext *ibucontext)
@@ -137,32 +128,83 @@ static inline struct mlx5_ib_ucontext *to_mucontext(struct ib_ucontext *ibuconte
struct mlx5_ib_pd {
struct ib_pd ibpd;
u32 pdn;
- u32 pa_lkey;
};
-struct wr_list {
- u16 opcode;
- u16 next;
+#define MLX5_IB_FLOW_MCAST_PRIO (MLX5_BY_PASS_NUM_PRIOS - 1)
+#define MLX5_IB_FLOW_LAST_PRIO (MLX5_BY_PASS_NUM_REGULAR_PRIOS - 1)
+#if (MLX5_IB_FLOW_LAST_PRIO <= 0)
+#error "Invalid number of bypass priorities"
+#endif
+#define MLX5_IB_FLOW_LEFTOVERS_PRIO (MLX5_IB_FLOW_MCAST_PRIO + 1)
+
+#define MLX5_IB_NUM_FLOW_FT (MLX5_IB_FLOW_LEFTOVERS_PRIO + 1)
+#define MLX5_IB_NUM_SNIFFER_FTS 2
+struct mlx5_ib_flow_prio {
+ struct mlx5_flow_table *flow_table;
+ unsigned int refcount;
};
-struct mlx5_swr_ctx {
- u64 wrid;
- u32 wr_data;
- struct wr_list w_list;
- u32 wqe_head;
- u8 sig_piped;
- u8 rsvd[11];
+struct mlx5_ib_flow_handler {
+ struct list_head list;
+ struct ib_flow ibflow;
+ struct mlx5_ib_flow_prio *prio;
+ struct mlx5_flow_rule *rule;
};
-struct mlx5_rwr_ctx {
- u64 wrid;
+struct mlx5_ib_flow_db {
+ struct mlx5_ib_flow_prio prios[MLX5_IB_NUM_FLOW_FT];
+ struct mlx5_ib_flow_prio sniffer[MLX5_IB_NUM_SNIFFER_FTS];
+ struct mlx5_flow_table *lag_demux_ft;
+ /* Protect flow steering bypass flow tables
+ * when add/del flow rules.
+ * only single add/removal of flow steering rule could be done
+ * simultaneously.
+ */
+ struct mutex lock;
+};
+
+/* Use macros here so that don't have to duplicate
+ * enum ib_send_flags and enum ib_qp_type for low-level driver
+ */
+
+#define MLX5_IB_SEND_UMR_UNREG IB_SEND_RESERVED_START
+#define MLX5_IB_SEND_UMR_FAIL_IF_FREE (IB_SEND_RESERVED_START << 1)
+#define MLX5_IB_SEND_UMR_UPDATE_MTT (IB_SEND_RESERVED_START << 2)
+
+#define MLX5_IB_SEND_UMR_UPDATE_TRANSLATION (IB_SEND_RESERVED_START << 3)
+#define MLX5_IB_SEND_UMR_UPDATE_PD (IB_SEND_RESERVED_START << 4)
+#define MLX5_IB_SEND_UMR_UPDATE_ACCESS IB_SEND_RESERVED_END
+
+#define MLX5_IB_QPT_REG_UMR IB_QPT_RESERVED1
+/*
+ * IB_QPT_GSI creates the software wrapper around GSI, and MLX5_IB_QPT_HW_GSI
+ * creates the actual hardware QP.
+ */
+#define MLX5_IB_QPT_HW_GSI IB_QPT_RESERVED2
+#define MLX5_IB_WR_UMR IB_WR_RESERVED1
+
+/* Private QP creation flags to be passed in ib_qp_init_attr.create_flags.
+ *
+ * These flags are intended for internal use by the mlx5_ib driver, and they
+ * rely on the range reserved for that use in the ib_qp_create_flags enum.
+ */
+
+/* Create a UD QP whose source QP number is 1 */
+static inline enum ib_qp_create_flags mlx5_ib_create_qp_sqpn_qp1(void)
+{
+ return IB_QP_CREATE_RESERVED_START;
+}
+
+struct wr_list {
+ u16 opcode;
+ u16 next;
};
struct mlx5_ib_wq {
- union {
- struct mlx5_swr_ctx *swr_ctx;
- struct mlx5_rwr_ctx *rwr_ctx;
- };
+ u64 *wrid;
+ u32 *wr_data;
+ struct wr_list *w_list;
+ unsigned *wqe_head;
u16 unsig_count;
/* serialize post to the work queue
@@ -180,6 +222,25 @@ struct mlx5_ib_wq {
void *qend;
};
+struct mlx5_ib_rwq {
+ struct ib_wq ibwq;
+ struct mlx5_core_qp core_qp;
+ u32 rq_num_pas;
+ u32 log_rq_stride;
+ u32 log_rq_size;
+ u32 rq_page_offset;
+ u32 log_page_size;
+ struct ib_umem *umem;
+ size_t buf_size;
+ unsigned int page_shift;
+ int create_type;
+ struct mlx5_db db;
+ u32 user_index;
+ u32 wqe_count;
+ u32 wqe_shift;
+ int wq_sig;
+};
+
enum {
MLX5_QP_USER,
MLX5_QP_KERNEL,
@@ -191,60 +252,103 @@ enum {
MLX5_WQ_KERNEL
};
-struct mlx5_ib_sqd {
- struct mlx5_ib_qp *qp;
+struct mlx5_ib_rwq_ind_table {
+ struct ib_rwq_ind_table ib_rwq_ind_tbl;
+ u32 rqtn;
+};
+
+/*
+ * Connect-IB can trigger up to four concurrent pagefaults
+ * per-QP.
+ */
+enum mlx5_ib_pagefault_context {
+ MLX5_IB_PAGEFAULT_RESPONDER_READ,
+ MLX5_IB_PAGEFAULT_REQUESTOR_READ,
+ MLX5_IB_PAGEFAULT_RESPONDER_WRITE,
+ MLX5_IB_PAGEFAULT_REQUESTOR_WRITE,
+ MLX5_IB_PAGEFAULT_CONTEXTS
+};
+
+static inline enum mlx5_ib_pagefault_context
+ mlx5_ib_get_pagefault_context(struct mlx5_pagefault *pagefault)
+{
+ return pagefault->flags & (MLX5_PFAULT_REQUESTOR | MLX5_PFAULT_WRITE);
+}
+
+struct mlx5_ib_pfault {
struct work_struct work;
+ struct mlx5_pagefault mpfault;
};
-struct mlx5_ib_mc_flows_list {
- struct list_head flows_list;
- /*Protect the flows_list*/
- struct mutex lock;
+struct mlx5_ib_ubuffer {
+ struct ib_umem *umem;
+ int buf_size;
+ u64 buf_addr;
};
-struct mlx5_ib_qp {
- struct ib_qp ibqp;
+struct mlx5_ib_qp_base {
+ struct mlx5_ib_qp *container_mibqp;
struct mlx5_core_qp mqp;
- struct mlx5_core_qp mrq;
- struct mlx5_core_qp msq;
- u32 tisn;
+ struct mlx5_ib_ubuffer ubuffer;
+};
+
+struct mlx5_ib_qp_trans {
+ struct mlx5_ib_qp_base base;
+ u16 xrcdn;
+ u8 alt_port;
+ u8 atomic_rd_en;
+ u8 resp_depth;
+};
+
+struct mlx5_ib_rss_qp {
+ u32 tirn;
+};
+
+struct mlx5_ib_rq {
+ struct mlx5_ib_qp_base base;
+ struct mlx5_ib_wq *rq;
+ struct mlx5_ib_ubuffer ubuffer;
+ struct mlx5_db *doorbell;
u32 tirn;
+ u8 state;
+};
+
+struct mlx5_ib_sq {
+ struct mlx5_ib_qp_base base;
+ struct mlx5_ib_wq *sq;
+ struct mlx5_ib_ubuffer ubuffer;
+ struct mlx5_db *doorbell;
+ u32 tisn;
+ u8 state;
+};
+
+struct mlx5_ib_raw_packet_qp {
+ struct mlx5_ib_sq sq;
+ struct mlx5_ib_rq rq;
+};
+
+struct mlx5_ib_qp {
+ struct ib_qp ibqp;
+ union {
+ struct mlx5_ib_qp_trans trans_qp;
+ struct mlx5_ib_raw_packet_qp raw_packet_qp;
+ struct mlx5_ib_rss_qp rss_qp;
+ };
struct mlx5_buf buf;
struct mlx5_db db;
struct mlx5_ib_wq rq;
- u32 doorbell_qpn;
u8 sq_signal_bits;
u8 fm_cache;
- int sq_max_wqes_per_wr;
- int sq_spare_wqes;
struct mlx5_ib_wq sq;
- struct ib_umem *umem;
- int buf_size;
- /* Raw Ethernet QP's SQ is allocated seperately
- * from the RQ's buffer in user-space.
- */
- struct ib_umem *sq_umem;
- int sq_buf_size;
- u64 sq_buf_addr;
- int allow_mp_wqe;
-
/* serialize qp state modifications
*/
struct mutex mutex;
- u16 xrcdn;
u32 flags;
u8 port;
- u8 alt_port;
- u8 atomic_rd_en;
- u8 resp_depth;
u8 state;
- /* Raw Ethernet QP's SQ and RQ states */
- u8 rq_state;
- u8 sq_state;
- int mlx_type;
int wq_sig;
int scat_cqe;
int max_inline_data;
@@ -257,16 +361,27 @@ struct mlx5_ib_qp {
int uuarn;
int create_type;
- u32 pa_lkey;
/* Store signature errors */
bool signature_en;
+#ifdef CONFIG_INFINIBAND_ON_DEMAND_PAGING
+ /*
+ * A flag that is true for QP's that are in a state that doesn't
+ * allow page faults, and shouldn't schedule any more faults.
+ */
+ int disable_page_faults;
+ /*
+ * The disable_page_faults_lock protects a QP's disable_page_faults
+ * field, allowing for a thread to atomically check whether the QP
+ * allows page faults, and if so schedule a page fault.
+ */
+ spinlock_t disable_page_faults_lock;
+ struct mlx5_ib_pfault pagefaults[MLX5_IB_PAGEFAULT_CONTEXTS];
+#endif
struct list_head qps_list;
struct list_head cq_recv_list;
struct list_head cq_send_list;
-
- struct mlx5_ib_mc_flows_list mc_flows_list;
};
struct mlx5_ib_cq_buf {
@@ -277,12 +392,20 @@ struct mlx5_ib_cq_buf {
};
enum mlx5_ib_qp_flags {
- MLX5_IB_QP_BLOCK_MULTICAST_LOOPBACK = 1 << 0,
- MLX5_IB_QP_SIGNATURE_HANDLING = 1 << 1,
- MLX5_IB_QP_CAP_RX_END_PADDING = 1 << 5,
+ MLX5_IB_QP_LSO = IB_QP_CREATE_IPOIB_UD_LSO,
+ MLX5_IB_QP_BLOCK_MULTICAST_LOOPBACK = IB_QP_CREATE_BLOCK_MULTICAST_LOOPBACK,
+ MLX5_IB_QP_CROSS_CHANNEL = IB_QP_CREATE_CROSS_CHANNEL,
+ MLX5_IB_QP_MANAGED_SEND = IB_QP_CREATE_MANAGED_SEND,
+ MLX5_IB_QP_MANAGED_RECV = IB_QP_CREATE_MANAGED_RECV,
+ MLX5_IB_QP_SIGNATURE_HANDLING = 1 << 5,
+ /* QP uses 1 as its source QP number */
+ MLX5_IB_QP_SQPN_QP1 = 1 << 6,
+ MLX5_IB_QP_CAP_SCATTER_FCS = 1 << 7,
+ MLX5_IB_QP_RSS = 1 << 8,
};
struct mlx5_umr_wr {
+ struct ib_send_wr wr;
union {
u64 virt_addr;
u64 offset;
@@ -290,11 +413,16 @@ struct mlx5_umr_wr {
struct ib_pd *pd;
unsigned int page_shift;
unsigned int npages;
- u64 length;
+ u32 length;
int access_flags;
u32 mkey;
};
+static inline struct mlx5_umr_wr *umr_wr(struct ib_send_wr *wr)
+{
+ return container_of(wr, struct mlx5_umr_wr, wr);
+}
+
struct mlx5_shared_mr_info {
int mr_id;
struct ib_umem *umem;
@@ -316,8 +444,17 @@ struct mlx5_ib_cq {
struct mlx5_ib_cq_buf *resize_buf;
struct ib_umem *resize_umem;
int cqe_size;
- struct list_head list_send_qp;
- struct list_head list_recv_qp;
+ struct list_head list_send_qp;
+ struct list_head list_recv_qp;
+ u32 create_flags;
+ struct list_head wc_list;
+ enum ib_cq_notify_flags notify_flags;
+ struct work_struct notify_work;
+};
+
+struct mlx5_ib_wc {
+ struct ib_wc wc;
+ struct list_head list;
};
struct mlx5_ib_srq {
@@ -353,44 +490,45 @@ enum mlx5_ib_mtt_access_flags {
struct mlx5_ib_mr {
struct ib_mr ibmr;
- struct mlx5_core_mr mmr;
+ void *descs;
+ dma_addr_t desc_map;
+ int ndescs;
+ int max_descs;
+ int desc_size;
+ int access_mode;
+ struct mlx5_core_mr mmkey;
struct ib_umem *umem;
struct mlx5_shared_mr_info *smr_info;
struct list_head list;
int order;
int umred;
- dma_addr_t dma;
int npages;
struct mlx5_ib_dev *dev;
- struct mlx5_create_mkey_mbox_out out;
+ u32 out[MLX5_ST_SZ_DW(create_mkey_out)];
struct mlx5_core_sig_ctx *sig;
- u32 max_reg_descriptors;
- u64 size;
- u64 page_count;
- struct mlx5_ib_mr **children;
- int nchild;
+ int live;
+ void *descs_alloc;
+ int access_flags; /* Needed for rereg MR */
};
-struct mlx5_ib_fast_reg_page_list {
- struct ib_fast_reg_page_list ibfrpl;
- __be64 *mapped_page_list;
- dma_addr_t map;
+struct mlx5_ib_mw {
+ struct ib_mw ibmw;
+ struct mlx5_core_mr mmkey;
};
struct mlx5_ib_umr_context {
+ struct ib_cqe cqe;
enum ib_wc_status status;
struct completion done;
};
-static inline void mlx5_ib_init_umr_context(struct mlx5_ib_umr_context *context)
-{
- context->status = -1;
- init_completion(&context->done);
-}
-
struct umr_common {
struct ib_pd *pd;
- struct ib_mr *mr;
+ struct ib_cq *cq;
+ struct ib_qp *qp;
+ /* control access to UMR QP
+ */
+ struct semaphore sem;
};
enum {
@@ -399,27 +537,6 @@ enum {
MLX5_FMR_BUSY,
};
-struct mlx5_ib_fmr {
- struct ib_fmr ibfmr;
- struct mlx5_core_mr mr;
- int access_flags;
- int state;
- /* protect fmr state
- */
- spinlock_t lock;
- u64 wrid;
- struct ib_send_wr wr[2];
- u8 page_shift;
- struct ib_fast_reg_page_list page_list;
-};
-
-struct cache_order {
- struct kobject kobj;
- int order;
- int index;
- struct mlx5_ib_dev *dev;
-};
-
struct mlx5_cache_ent {
struct list_head head;
/* sync access to the cahce entry
@@ -427,17 +544,23 @@ struct mlx5_cache_ent {
spinlock_t lock;
+ struct dentry *dir;
+ char name[4];
u32 order;
u32 size;
u32 cur;
u32 miss;
u32 limit;
+ struct dentry *fsize;
+ struct dentry *fcur;
+ struct dentry *fmiss;
+ struct dentry *flimit;
+
struct mlx5_ib_dev *dev;
struct work_struct work;
struct delayed_work dwork;
int pending;
- struct cache_order co;
};
struct mlx5_mr_cache {
@@ -445,9 +568,15 @@ struct mlx5_mr_cache {
struct mlx5_cache_ent ent[MAX_MR_CACHE_ENTRIES];
int stopped;
struct dentry *root;
- int last_add;
- int rel_timeout;
- int rel_imm;
+ unsigned long last_add;
+};
+
+struct mlx5_ib_gsi_qp;
+
+struct mlx5_ib_port_resources {
+ struct mlx5_ib_resources *devr;
+ struct mlx5_ib_gsi_qp *gsi;
+ struct work_struct pkey_change_work;
};
struct mlx5_ib_resources {
@@ -457,106 +586,58 @@ struct mlx5_ib_resources {
struct ib_pd *p0;
struct ib_srq *s0;
struct ib_srq *s1;
+ struct mlx5_ib_port_resources ports[2];
+ /* Protects changes to the port resources */
+ struct mutex mutex;
};
-struct mlx5_dc_tracer {
- struct page *pg;
- dma_addr_t dma;
- int size;
- int order;
-};
-
-struct mlx5_dc_desc {
- dma_addr_t dma;
- void *buf;
-};
-
-enum mlx5_op {
- MLX5_WR_OP_MLX = 1,
-};
-
-struct mlx5_mlx_wr {
- u8 sl;
- u16 dlid;
- int icrc;
-};
-
-struct mlx5_send_wr {
- struct ib_send_wr wr;
- union {
- struct mlx5_mlx_wr mlx;
- } sel;
-};
-
-struct mlx5_dc_data {
- struct ib_mr *mr;
- struct ib_qp *dcqp;
- struct ib_cq *rcq;
- struct ib_cq *scq;
- unsigned int rx_npages;
- unsigned int tx_npages;
- struct mlx5_dc_desc *rxdesc;
- struct mlx5_dc_desc *txdesc;
- unsigned int max_wqes;
- unsigned int cur_send;
- unsigned int last_send_completed;
- int tx_pending;
- struct mlx5_ib_dev *dev;
- int port;
- int initialized;
- struct kobject kobj;
- unsigned long connects;
- unsigned long cnaks;
- unsigned long discards;
- struct ib_wc wc_tbl[MLX5_CNAK_RX_POLL_CQ_QUOTA];
-};
-
-struct mlx5_ib_port_sysfs_group {
- struct kobject kobj;
- bool enabled;
- struct attribute_group counters;
-};
-
-#define MLX5_IB_GID_MAX 16
-
struct mlx5_ib_port {
- struct mlx5_ib_dev *dev;
- u8 port_num; /* 0 based */
- u8 port_gone; /* set when gone */
u16 q_cnt_id;
- struct mlx5_ib_port_sysfs_group group;
- union ib_gid gid_table[MLX5_IB_GID_MAX];
+};
+
+struct mlx5_roce {
+ /* Protect mlx5_ib_get_netdev from invoking dev_hold() with a NULL
+ * netdev pointer
+ */
+ rwlock_t netdev_lock;
+ struct net_device *netdev;
+ struct notifier_block nb;
+ atomic_t next_port;
};
struct mlx5_ib_dev {
struct ib_device ib_dev;
struct mlx5_core_dev *mdev;
+ struct mlx5_roce roce;
MLX5_DECLARE_DOORBELL_LOCK(uar_lock);
int num_ports;
/* serialize update of capability mask
*/
struct mutex cap_mask_mutex;
- bool ib_active;
+ bool ib_active;
struct umr_common umrc;
/* sync used page count stats
*/
struct mlx5_ib_resources devr;
- struct mutex slow_path_mutex;
- int enable_atomic_resp;
- enum ib_atomic_cap atomic_cap;
struct mlx5_mr_cache cache;
- struct kobject mr_cache;
- /* protect resources needed as part of reset flow */
- spinlock_t reset_flow_resource_lock;
- struct list_head qp_list;
struct timer_list delay_timer;
+ /* Prevents soft lock on massive reg MRs */
+ struct mutex slow_path_mutex;
int fill_delay;
- struct mlx5_dc_tracer dctr;
- struct mlx5_dc_data dcd[MLX5_MAX_PORTS];
- struct kobject *dc_kobj;
+#ifdef CONFIG_INFINIBAND_ON_DEMAND_PAGING
+ struct ib_odp_caps odp_caps;
+ /*
+ * Sleepable RCU that prevents destruction of MRs while they are still
+ * being used by a page fault handler.
+ */
+ struct srcu_struct mr_srcu;
+#endif
+ struct mlx5_ib_flow_db flow_db;
+ /* protect resources needed as part of reset flow */
+ spinlock_t reset_flow_resource_lock;
+ struct list_head qp_list;
/* Array with num_ports elements */
struct mlx5_ib_port *port;
- struct kobject *ports_parent;
};
static inline struct mlx5_ib_cq *to_mibcq(struct mlx5_core_cq *mcq)
@@ -574,11 +655,6 @@ static inline struct mlx5_ib_dev *to_mdev(struct ib_device *ibdev)
return container_of(ibdev, struct mlx5_ib_dev, ib_dev);
}
-static inline struct mlx5_ib_fmr *to_mfmr(struct ib_fmr *ibfmr)
-{
- return container_of(ibfmr, struct mlx5_ib_fmr, ibfmr);
-}
-
static inline struct mlx5_ib_cq *to_mcq(struct ib_cq *ibcq)
{
return container_of(ibcq, struct mlx5_ib_cq, ibcq);
@@ -586,22 +662,17 @@ static inline struct mlx5_ib_cq *to_mcq(struct ib_cq *ibcq)
static inline struct mlx5_ib_qp *to_mibqp(struct mlx5_core_qp *mqp)
{
- return container_of(mqp, struct mlx5_ib_qp, mqp);
-}
-
-static inline struct mlx5_ib_qp *sq_to_mibqp(struct mlx5_core_qp *msq)
-{
- return container_of(msq, struct mlx5_ib_qp, msq);
+ return container_of(mqp, struct mlx5_ib_qp_base, mqp)->container_mibqp;
}
-static inline struct mlx5_ib_qp *rq_to_mibqp(struct mlx5_core_qp *mrq)
+static inline struct mlx5_ib_rwq *to_mibrwq(struct mlx5_core_qp *core_qp)
{
- return container_of(mrq, struct mlx5_ib_qp, mrq);
+ return container_of(core_qp, struct mlx5_ib_rwq, core_qp);
}
-static inline struct mlx5_ib_mr *to_mibmr(struct mlx5_core_mr *mmr)
+static inline struct mlx5_ib_mr *to_mibmr(struct mlx5_core_mr *mmkey)
{
- return container_of(mmr, struct mlx5_ib_mr, mmr);
+ return container_of(mmkey, struct mlx5_ib_mr, mmkey);
}
static inline struct mlx5_ib_pd *to_mpd(struct ib_pd *ibpd)
@@ -619,6 +690,16 @@ static inline struct mlx5_ib_qp *to_mqp(struct ib_qp *ibqp)
return container_of(ibqp, struct mlx5_ib_qp, ibqp);
}
+static inline struct mlx5_ib_rwq *to_mrwq(struct ib_wq *ibwq)
+{
+ return container_of(ibwq, struct mlx5_ib_rwq, ibwq);
+}
+
+static inline struct mlx5_ib_rwq_ind_table *to_mrwq_ind_table(struct ib_rwq_ind_table *ib_rwq_ind_tbl)
+{
+ return container_of(ib_rwq_ind_tbl, struct mlx5_ib_rwq_ind_table, ib_rwq_ind_tbl);
+}
+
static inline struct mlx5_ib_srq *to_mibsrq(struct mlx5_core_srq *msrq)
{
return container_of(msrq, struct mlx5_ib_srq, msrq);
@@ -629,9 +710,9 @@ static inline struct mlx5_ib_mr *to_mmr(struct ib_mr *ibmr)
return container_of(ibmr, struct mlx5_ib_mr, ibmr);
}
-static inline struct mlx5_ib_fast_reg_page_list *to_mfrpl(struct ib_fast_reg_page_list *ibfrpl)
+static inline struct mlx5_ib_mw *to_mmw(struct ib_mw *ibmw)
{
- return container_of(ibfrpl, struct mlx5_ib_fast_reg_page_list, ibfrpl);
+ return container_of(ibmw, struct mlx5_ib_mw, ibmw);
}
struct mlx5_ib_ah {
@@ -644,17 +725,15 @@ static inline struct mlx5_ib_ah *to_mah(struct ib_ah *ibah)
return container_of(ibah, struct mlx5_ib_ah, ibah);
}
-int mlx5_ib_db_map_user(struct mlx5_ib_ucontext *context, uintptr_t virt,
+int mlx5_ib_db_map_user(struct mlx5_ib_ucontext *context, unsigned long virt,
struct mlx5_db *db);
void mlx5_ib_db_unmap_user(struct mlx5_ib_ucontext *context, struct mlx5_db *db);
void __mlx5_ib_cq_clean(struct mlx5_ib_cq *cq, u32 qpn, struct mlx5_ib_srq *srq);
void mlx5_ib_cq_clean(struct mlx5_ib_cq *cq, u32 qpn, struct mlx5_ib_srq *srq);
void mlx5_ib_free_srq_wqe(struct mlx5_ib_srq *srq, int wqe_index);
int mlx5_MAD_IFC(struct mlx5_ib_dev *dev, int ignore_mkey, int ignore_bkey,
- u8 port, struct ib_wc *in_wc, struct ib_grh *in_grh,
- void *in_mad, void *response_mad);
-struct ib_ah *create_ib_ah(struct mlx5_ib_dev *dev, struct ib_ah_attr *ah_attr,
- struct mlx5_ib_ah *ah, enum rdma_link_layer ll);
+ u8 port, const struct ib_wc *in_wc, const struct ib_grh *in_grh,
+ const void *in_mad, void *response_mad);
struct ib_ah *mlx5_ib_create_ah(struct ib_pd *pd, struct ib_ah_attr *ah_attr);
int mlx5_ib_query_ah(struct ib_ah *ibah, struct ib_ah_attr *ah_attr);
int mlx5_ib_destroy_ah(struct ib_ah *ah);
@@ -680,62 +759,67 @@ int mlx5_ib_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr,
int mlx5_ib_post_recv(struct ib_qp *ibqp, struct ib_recv_wr *wr,
struct ib_recv_wr **bad_wr);
void *mlx5_get_send_wqe(struct mlx5_ib_qp *qp, int n);
+int mlx5_ib_read_user_wqe(struct mlx5_ib_qp *qp, int send, int wqe_index,
+ void *buffer, u32 length,
+ struct mlx5_ib_qp_base *base);
struct ib_cq *mlx5_ib_create_cq(struct ib_device *ibdev,
- struct ib_cq_init_attr *attr,
+ const struct ib_cq_init_attr *attr,
struct ib_ucontext *context,
struct ib_udata *udata);
int mlx5_ib_destroy_cq(struct ib_cq *cq);
int mlx5_ib_poll_cq(struct ib_cq *ibcq, int num_entries, struct ib_wc *wc);
int mlx5_ib_arm_cq(struct ib_cq *ibcq, enum ib_cq_notify_flags flags);
-int mlx5_ib_modify_cq(struct ib_cq *cq, struct ib_cq_attr *attr, int cq_attr_mask);
+int mlx5_ib_modify_cq(struct ib_cq *cq, u16 cq_count, u16 cq_period);
int mlx5_ib_resize_cq(struct ib_cq *ibcq, int entries, struct ib_udata *udata);
struct ib_mr *mlx5_ib_get_dma_mr(struct ib_pd *pd, int acc);
struct ib_mr *mlx5_ib_reg_user_mr(struct ib_pd *pd, u64 start, u64 length,
u64 virt_addr, int access_flags,
- struct ib_udata *udata, int mr_id);
+ struct ib_udata *udata);
+struct ib_mw *mlx5_ib_alloc_mw(struct ib_pd *pd, enum ib_mw_type type,
+ struct ib_udata *udata);
+int mlx5_ib_dealloc_mw(struct ib_mw *mw);
+int mlx5_ib_update_mtt(struct mlx5_ib_mr *mr, u64 start_page_index,
+ int npages, int zap);
+int mlx5_ib_rereg_user_mr(struct ib_mr *ib_mr, int flags, u64 start,
+ u64 length, u64 virt_addr, int access_flags,
+ struct ib_pd *pd, struct ib_udata *udata);
struct ib_mr *mlx5_ib_reg_phys_mr(struct ib_pd *pd,
struct ib_phys_buf *buffer_list,
int num_phys_buf,
int access_flags,
u64 *virt_addr);
int mlx5_ib_dereg_mr(struct ib_mr *ibmr);
-int mlx5_ib_destroy_mr(struct ib_mr *ibmr);
-struct ib_mr *mlx5_ib_alloc_fast_reg_mr(struct ib_pd *pd,
- int max_page_list_len);
-struct ib_fast_reg_page_list *mlx5_ib_alloc_fast_reg_page_list(struct ib_device *ibdev,
- int page_list_len);
-void mlx5_ib_free_fast_reg_page_list(struct ib_fast_reg_page_list *page_list);
-
-struct ib_fmr *mlx5_ib_fmr_alloc(struct ib_pd *pd, int acc,
- struct ib_fmr_attr *fmr_attr);
-int mlx5_ib_map_phys_fmr(struct ib_fmr *ibfmr, u64 *page_list,
- int npages, u64 iova);
-int mlx5_ib_unmap_fmr(struct list_head *fmr_list);
-int mlx5_ib_fmr_dealloc(struct ib_fmr *ibfmr);
+struct ib_mr *mlx5_ib_alloc_mr(struct ib_pd *pd,
+ enum ib_mr_type mr_type,
+ u32 max_num_sg);
+int mlx5_ib_map_mr_sg(struct ib_mr *ibmr, struct scatterlist *sg, int sg_nents,
+ unsigned int *sg_offset);
int mlx5_ib_process_mad(struct ib_device *ibdev, int mad_flags, u8 port_num,
- struct ib_wc *in_wc, struct ib_grh *in_grh,
- struct ib_mad *in_mad, struct ib_mad *out_mad);
+ const struct ib_wc *in_wc, const struct ib_grh *in_grh,
+ const struct ib_mad_hdr *in, size_t in_mad_size,
+ struct ib_mad_hdr *out, size_t *out_mad_size,
+ u16 *out_mad_pkey_index);
struct ib_xrcd *mlx5_ib_alloc_xrcd(struct ib_device *ibdev,
struct ib_ucontext *context,
struct ib_udata *udata);
int mlx5_ib_dealloc_xrcd(struct ib_xrcd *xrcd);
int mlx5_ib_get_buf_offset(u64 addr, int page_shift, u32 *offset);
int mlx5_query_ext_port_caps(struct mlx5_ib_dev *dev, u8 port);
-int mlx5_query_smp_attr_node_info_mad_ifc(struct ib_device *ibdev,
+int mlx5_query_mad_ifc_smp_attr_node_info(struct ib_device *ibdev,
struct ib_smp *out_mad);
-int mlx5_query_system_image_guid_mad_ifc(struct ib_device *ibdev,
+int mlx5_query_mad_ifc_system_image_guid(struct ib_device *ibdev,
__be64 *sys_image_guid);
-int mlx5_query_max_pkeys_mad_ifc(struct ib_device *ibdev,
+int mlx5_query_mad_ifc_max_pkeys(struct ib_device *ibdev,
u16 *max_pkeys);
-int mlx5_query_vendor_id_mad_ifc(struct ib_device *ibdev,
+int mlx5_query_mad_ifc_vendor_id(struct ib_device *ibdev,
u32 *vendor_id);
-int mlx5_query_pkey_mad_ifc(struct ib_device *ibdev, u8 port, u16 index,
+int mlx5_query_mad_ifc_node_desc(struct mlx5_ib_dev *dev, char *node_desc);
+int mlx5_query_mad_ifc_node_guid(struct mlx5_ib_dev *dev, __be64 *node_guid);
+int mlx5_query_mad_ifc_pkey(struct ib_device *ibdev, u8 port, u16 index,
u16 *pkey);
-int mlx5_query_node_desc_mad_ifc(struct mlx5_ib_dev *dev, char *node_desc);
-int mlx5_query_node_guid_mad_ifc(struct mlx5_ib_dev *dev, u64 *node_guid);
-int mlx5_query_gids_mad_ifc(struct ib_device *ibdev, u8 port, int index,
+int mlx5_query_mad_ifc_gids(struct ib_device *ibdev, u8 port, int index,
union ib_gid *gid);
-int mlx5_query_port_mad_ifc(struct ib_device *ibdev, u8 port,
+int mlx5_query_mad_ifc_port(struct ib_device *ibdev, u8 port,
struct ib_port_attr *props);
int mlx5_ib_query_port(struct ib_device *ibdev, u8 port,
struct ib_port_attr *props);
@@ -743,29 +827,88 @@ int mlx5_ib_init_fmr(struct mlx5_ib_dev *dev);
void mlx5_ib_cleanup_fmr(struct mlx5_ib_dev *dev);
void mlx5_ib_cont_pages(struct ib_umem *umem, u64 addr, int *count, int *shift,
int *ncont, int *order);
+void __mlx5_ib_populate_pas(struct mlx5_ib_dev *dev, struct ib_umem *umem,
+ int page_shift, size_t offset, size_t num_pages,
+ __be64 *pas, int access_flags);
void mlx5_ib_populate_pas(struct mlx5_ib_dev *dev, struct ib_umem *umem,
- int page_shift, __be64 *pas, int umr);
+ int page_shift, __be64 *pas, int access_flags);
void mlx5_ib_copy_pas(u64 *old, u64 *new, int step, int num);
int mlx5_ib_get_cqe_size(struct mlx5_ib_dev *dev, struct ib_cq *ibcq);
int mlx5_mr_cache_init(struct mlx5_ib_dev *dev);
int mlx5_mr_cache_cleanup(struct mlx5_ib_dev *dev);
int mlx5_mr_ib_cont_pages(struct ib_umem *umem, u64 addr, int *count, int *shift);
-void mlx5_umr_cq_handler(struct ib_cq *cq, void *cq_context);
-int mlx5_query_port_roce(struct ib_device *ibdev, u8 port,
- struct ib_port_attr *props);
-__be16 mlx5_get_roce_udp_sport(struct mlx5_ib_dev *dev, u8 port, int index,
- __be16 ah_udp_s_port);
-int mlx5_get_roce_gid_type(struct mlx5_ib_dev *dev, u8 port,
- int index, int *gid_type);
-struct net_device *mlx5_ib_get_netdev(struct ib_device *ib_dev, u8 port);
-int modify_gid_roce(struct ib_device *ib_dev, u8 port, unsigned int index,
- const union ib_gid *gid, struct net_device *ndev);
-int query_gid_roce(struct ib_device *ib_dev, u8 port, int index,
- union ib_gid *gid);
-int mlx5_process_mad_mad_ifc(struct ib_device *ibdev, int mad_flags,
- u8 port_num, struct ib_wc *in_wc,
- struct ib_grh *in_grh, struct ib_mad *in_mad,
- struct ib_mad *out_mad);
+int mlx5_ib_check_mr_status(struct ib_mr *ibmr, u32 check_mask,
+ struct ib_mr_status *mr_status);
+struct ib_wq *mlx5_ib_create_wq(struct ib_pd *pd,
+ struct ib_wq_init_attr *init_attr,
+ struct ib_udata *udata);
+int mlx5_ib_destroy_wq(struct ib_wq *wq);
+int mlx5_ib_modify_wq(struct ib_wq *wq, struct ib_wq_attr *wq_attr,
+ u32 wq_attr_mask, struct ib_udata *udata);
+struct ib_rwq_ind_table *mlx5_ib_create_rwq_ind_table(struct ib_device *device,
+ struct ib_rwq_ind_table_init_attr *init_attr,
+ struct ib_udata *udata);
+int mlx5_ib_destroy_rwq_ind_table(struct ib_rwq_ind_table *wq_ind_table);
+
+#ifdef CONFIG_INFINIBAND_ON_DEMAND_PAGING
+extern struct workqueue_struct *mlx5_ib_page_fault_wq;
+
+void mlx5_ib_internal_fill_odp_caps(struct mlx5_ib_dev *dev);
+void mlx5_ib_mr_pfault_handler(struct mlx5_ib_qp *qp,
+ struct mlx5_ib_pfault *pfault);
+void mlx5_ib_odp_create_qp(struct mlx5_ib_qp *qp);
+int mlx5_ib_odp_init_one(struct mlx5_ib_dev *ibdev);
+void mlx5_ib_odp_remove_one(struct mlx5_ib_dev *ibdev);
+int __init mlx5_ib_odp_init(void);
+void mlx5_ib_odp_cleanup(void);
+void mlx5_ib_qp_disable_pagefaults(struct mlx5_ib_qp *qp);
+void mlx5_ib_qp_enable_pagefaults(struct mlx5_ib_qp *qp);
+void mlx5_ib_invalidate_range(struct ib_umem *umem, unsigned long start,
+ unsigned long end);
+#else /* CONFIG_INFINIBAND_ON_DEMAND_PAGING */
+static inline void mlx5_ib_internal_fill_odp_caps(struct mlx5_ib_dev *dev)
+{
+ return;
+}
+
+static inline void mlx5_ib_odp_create_qp(struct mlx5_ib_qp *qp) {}
+static inline int mlx5_ib_odp_init_one(struct mlx5_ib_dev *ibdev) { return 0; }
+static inline void mlx5_ib_odp_remove_one(struct mlx5_ib_dev *ibdev) {}
+static inline int mlx5_ib_odp_init(void) { return 0; }
+static inline void mlx5_ib_odp_cleanup(void) {}
+static inline void mlx5_ib_qp_disable_pagefaults(struct mlx5_ib_qp *qp) {}
+static inline void mlx5_ib_qp_enable_pagefaults(struct mlx5_ib_qp *qp) {}
+
+#endif /* CONFIG_INFINIBAND_ON_DEMAND_PAGING */
+
+int mlx5_ib_get_vf_config(struct ib_device *device, int vf,
+ u8 port, struct ifla_vf_info *info);
+int mlx5_ib_set_vf_link_state(struct ib_device *device, int vf,
+ u8 port, int state);
+int mlx5_ib_get_vf_stats(struct ib_device *device, int vf,
+ u8 port, struct ifla_vf_stats *stats);
+int mlx5_ib_set_vf_guid(struct ib_device *device, int vf, u8 port,
+ u64 guid, int type);
+
+__be16 mlx5_get_roce_udp_sport(struct mlx5_ib_dev *dev, u8 port_num,
+ int index);
+
+/* GSI QP helper functions */
+struct ib_qp *mlx5_ib_gsi_create_qp(struct ib_pd *pd,
+ struct ib_qp_init_attr *init_attr);
+int mlx5_ib_gsi_destroy_qp(struct ib_qp *qp);
+int mlx5_ib_gsi_modify_qp(struct ib_qp *qp, struct ib_qp_attr *attr,
+ int attr_mask);
+int mlx5_ib_gsi_query_qp(struct ib_qp *qp, struct ib_qp_attr *qp_attr,
+ int qp_attr_mask,
+ struct ib_qp_init_attr *qp_init_attr);
+int mlx5_ib_gsi_post_send(struct ib_qp *qp, struct ib_send_wr *wr,
+ struct ib_send_wr **bad_wr);
+int mlx5_ib_gsi_post_recv(struct ib_qp *qp, struct ib_recv_wr *wr,
+ struct ib_recv_wr **bad_wr);
+void mlx5_ib_gsi_pkey_change(struct mlx5_ib_gsi_qp *gsi);
+
+int mlx5_ib_generate_wc(struct ib_cq *ibcq, struct ib_wc *wc);
static inline void init_query_mad(struct ib_smp *mad)
{
@@ -784,7 +927,72 @@ static inline u8 convert_access(int acc)
MLX5_PERM_LOCAL_READ;
}
+static inline int is_qp1(enum ib_qp_type qp_type)
+{
+ return qp_type == MLX5_IB_QPT_HW_GSI;
+}
+
#define MLX5_MAX_UMR_SHIFT 16
#define MLX5_MAX_UMR_PAGES (1 << MLX5_MAX_UMR_SHIFT)
+static inline u32 check_cq_create_flags(u32 flags)
+{
+ /*
+ * It returns non-zero value for unsupported CQ
+ * create flags, otherwise it returns zero.
+ */
+ return (flags & ~(IB_CQ_FLAGS_IGNORE_OVERRUN |
+ IB_CQ_FLAGS_TIMESTAMP_COMPLETION));
+}
+
+static inline int verify_assign_uidx(u8 cqe_version, u32 cmd_uidx,
+ u32 *user_index)
+{
+ if (cqe_version) {
+ if ((cmd_uidx == MLX5_IB_DEFAULT_UIDX) ||
+ (cmd_uidx & ~MLX5_USER_ASSIGNED_UIDX_MASK))
+ return -EINVAL;
+ *user_index = cmd_uidx;
+ } else {
+ *user_index = MLX5_IB_DEFAULT_UIDX;
+ }
+
+ return 0;
+}
+
+static inline int get_qp_user_index(struct mlx5_ib_ucontext *ucontext,
+ struct mlx5_ib_create_qp *ucmd,
+ int inlen,
+ u32 *user_index)
+{
+ u8 cqe_version = ucontext->cqe_version;
+
+ if (field_avail(struct mlx5_ib_create_qp, uidx, inlen) &&
+ !cqe_version && (ucmd->uidx == MLX5_IB_DEFAULT_UIDX))
+ return 0;
+
+ if (!!(field_avail(struct mlx5_ib_create_qp, uidx, inlen) !=
+ !!cqe_version))
+ return -EINVAL;
+
+ return verify_assign_uidx(cqe_version, ucmd->uidx, user_index);
+}
+
+static inline int get_srq_user_index(struct mlx5_ib_ucontext *ucontext,
+ struct mlx5_ib_create_srq *ucmd,
+ int inlen,
+ u32 *user_index)
+{
+ u8 cqe_version = ucontext->cqe_version;
+
+ if (field_avail(struct mlx5_ib_create_srq, uidx, inlen) &&
+ !cqe_version && (ucmd->uidx == MLX5_IB_DEFAULT_UIDX))
+ return 0;
+
+ if (!!(field_avail(struct mlx5_ib_create_srq, uidx, inlen) !=
+ !!cqe_version))
+ return -EINVAL;
+
+ return verify_assign_uidx(cqe_version, ucmd->uidx, user_index);
+}
#endif /* MLX5_IB_H */
diff --git a/sys/dev/mlx5/mlx5_ib/mlx5_ib_ah.c b/sys/dev/mlx5/mlx5_ib/mlx5_ib_ah.c
index 73947b6..fc8d713 100644
--- a/sys/dev/mlx5/mlx5_ib/mlx5_ib_ah.c
+++ b/sys/dev/mlx5/mlx5_ib/mlx5_ib_ah.c
@@ -27,15 +27,11 @@
#include "mlx5_ib.h"
-#define IPV6_DEFAULT_HOPLIMIT 64
-
-struct ib_ah *create_ib_ah(struct mlx5_ib_dev *dev,
- struct ib_ah_attr *ah_attr,
- struct mlx5_ib_ah *ah, enum rdma_link_layer ll)
+static struct ib_ah *create_ib_ah(struct mlx5_ib_dev *dev,
+ struct mlx5_ib_ah *ah,
+ struct ib_ah_attr *ah_attr,
+ enum rdma_link_layer ll)
{
- int err;
- int gid_type;
-
if (ah_attr->ah_flags & IB_AH_GRH) {
memcpy(ah->av.rgid, &ah_attr->grh.dgid, 16);
ah->av.grh_gid_fl = cpu_to_be32(ah_attr->grh.flow_label |
@@ -48,21 +44,12 @@ struct ib_ah *create_ib_ah(struct mlx5_ib_dev *dev,
ah->av.stat_rate_sl = (ah_attr->static_rate << 4);
if (ll == IB_LINK_LAYER_ETHERNET) {
- err = mlx5_get_roce_gid_type(dev, ah_attr->port_num,
- ah_attr->grh.sgid_index,
- &gid_type);
- if (err)
- return ERR_PTR(err);
-
memcpy(ah->av.rmac, ah_attr->dmac, sizeof(ah_attr->dmac));
- ah->av.udp_sport = mlx5_get_roce_udp_sport(
- dev,
- ah_attr->port_num,
- ah_attr->grh.sgid_index,
- 0);
+ ah->av.udp_sport =
+ mlx5_get_roce_udp_sport(dev,
+ ah_attr->port_num,
+ ah_attr->grh.sgid_index);
ah->av.stat_rate_sl |= (ah_attr->sl & 0x7) << 1;
- ah->av.hop_limit = ah_attr->grh.hop_limit;
- /* TODO: initialize other eth fields */
} else {
ah->av.rlid = cpu_to_be16(ah_attr->dlid);
ah->av.fl_mlid = ah_attr->src_path_bits & 0x7f;
@@ -77,22 +64,17 @@ struct ib_ah *mlx5_ib_create_ah(struct ib_pd *pd, struct ib_ah_attr *ah_attr)
struct mlx5_ib_ah *ah;
struct mlx5_ib_dev *dev = to_mdev(pd->device);
enum rdma_link_layer ll;
- struct ib_ah *ret = ERR_PTR(-EINVAL);
-
- ah = kzalloc(sizeof(*ah), GFP_ATOMIC);
- if (!ah)
- return ERR_PTR(-ENOMEM);
ll = pd->device->get_link_layer(pd->device, ah_attr->port_num);
if (ll == IB_LINK_LAYER_ETHERNET && !(ah_attr->ah_flags & IB_AH_GRH))
- goto err_kfree_ah;
+ return ERR_PTR(-EINVAL);
- return create_ib_ah(dev, ah_attr, ah, ll); /* never fails */
+ ah = kzalloc(sizeof(*ah), GFP_ATOMIC);
+ if (!ah)
+ return ERR_PTR(-ENOMEM);
-err_kfree_ah:
- kfree(ah);
- return ret;
+ return create_ib_ah(dev, ah, ah_attr, ll); /* never fails */
}
int mlx5_ib_query_ah(struct ib_ah *ibah, struct ib_ah_attr *ah_attr)
diff --git a/sys/dev/mlx5/mlx5_ib/mlx5_ib_cq.c b/sys/dev/mlx5/mlx5_ib/mlx5_ib_cq.c
index 001e54d..52382b8 100644
--- a/sys/dev/mlx5/mlx5_ib/mlx5_ib_cq.c
+++ b/sys/dev/mlx5/mlx5_ib/mlx5_ib_cq.c
@@ -28,8 +28,8 @@
#include <linux/kref.h>
#include <rdma/ib_umem.h>
#include <rdma/ib_user_verbs.h>
+#include <rdma/ib_cache.h>
#include "mlx5_ib.h"
-#include "user.h"
static void mlx5_ib_cq_comp(struct mlx5_core_cq *cq)
{
@@ -96,15 +96,18 @@ static void *next_cqe_sw(struct mlx5_ib_cq *cq)
static enum ib_wc_opcode get_umr_comp(struct mlx5_ib_wq *wq, int idx)
{
- switch (wq->swr_ctx[idx].wr_data) {
+ switch (wq->wr_data[idx]) {
+ case MLX5_IB_WR_UMR:
+ return 0;
+
case IB_WR_LOCAL_INV:
return IB_WC_LOCAL_INV;
- case IB_WR_FAST_REG_MR:
- return IB_WC_FAST_REG_MR;
+ case IB_WR_REG_MR:
+ return IB_WC_REG_MR;
default:
- printf("mlx5_ib: WARN: ""unknown completion status\n");
+ pr_warn("unknown completion status\n");
return 0;
}
}
@@ -121,7 +124,6 @@ static void handle_good_req(struct ib_wc *wc, struct mlx5_cqe64 *cqe,
break;
case MLX5_OPCODE_SEND_IMM:
wc->wc_flags |= IB_WC_WITH_IMM;
- case MLX5_OPCODE_NOP:
case MLX5_OPCODE_SEND:
case MLX5_OPCODE_SEND_INVAL:
wc->opcode = IB_WC_SEND;
@@ -146,9 +148,6 @@ static void handle_good_req(struct ib_wc *wc, struct mlx5_cqe64 *cqe,
wc->opcode = IB_WC_MASKED_FETCH_ADD;
wc->byte_len = 8;
break;
- case MLX5_OPCODE_BIND_MW:
- wc->opcode = IB_WC_BIND_MW;
- break;
case MLX5_OPCODE_UMR:
wc->opcode = get_umr_comp(wq, idx);
break;
@@ -163,14 +162,12 @@ enum {
static void handle_responder(struct ib_wc *wc, struct mlx5_cqe64 *cqe,
struct mlx5_ib_qp *qp)
{
+ enum rdma_link_layer ll = rdma_port_get_link_layer(qp->ibqp.device, 1);
struct mlx5_ib_dev *dev = to_mdev(qp->ibqp.device);
struct mlx5_ib_srq *srq;
struct mlx5_ib_wq *wq;
u16 wqe_ctr;
u8 g;
-#if defined(DX_ROCE_V1_5) || defined(DX_WINDOWS)
- u8 udp_header_valid;
-#endif
if (qp->ibqp.srq || qp->ibqp.xrcd) {
struct mlx5_core_srq *msrq = NULL;
@@ -191,7 +188,7 @@ static void handle_responder(struct ib_wc *wc, struct mlx5_cqe64 *cqe,
}
} else {
wq = &qp->rq;
- wc->wr_id = wq->rwr_ctx[wq->tail & (wq->wqe_cnt - 1)].wrid;
+ wc->wr_id = wq->wrid[wq->tail & (wq->wqe_cnt - 1)];
++wq->tail;
}
wc->byte_len = be32_to_cpu(cqe->byte_cnt);
@@ -204,7 +201,10 @@ static void handle_responder(struct ib_wc *wc, struct mlx5_cqe64 *cqe,
break;
case MLX5_CQE_RESP_SEND:
wc->opcode = IB_WC_RECV;
- wc->wc_flags = 0;
+ wc->wc_flags = IB_WC_IP_CSUM_OK;
+ if (unlikely(!((cqe->hds_ip_ext & CQE_L3_OK) &&
+ (cqe->hds_ip_ext & CQE_L4_OK))))
+ wc->wc_flags = 0;
break;
case MLX5_CQE_RESP_SEND_IMM:
wc->opcode = IB_WC_RECV;
@@ -223,14 +223,30 @@ static void handle_responder(struct ib_wc *wc, struct mlx5_cqe64 *cqe,
wc->dlid_path_bits = cqe->ml_path;
g = (be32_to_cpu(cqe->flags_rqpn) >> 28) & 3;
wc->wc_flags |= g ? IB_WC_GRH : 0;
- wc->pkey_index = be32_to_cpu(cqe->imm_inval_pkey) & 0xffff;
+ if (unlikely(is_qp1(qp->ibqp.qp_type))) {
+ u16 pkey = be32_to_cpu(cqe->imm_inval_pkey) & 0xffff;
-#if defined(DX_ROCE_V1_5) || defined(DX_WINDOWS)
- udp_header_valid = wc->sl & 0x8;
- if (udp_header_valid)
- wc->wc_flags |= IB_WC_WITH_UDP_HDR;
+ ib_find_cached_pkey(&dev->ib_dev, qp->port, pkey,
+ &wc->pkey_index);
+ } else {
+ wc->pkey_index = 0;
+ }
+
+ if (ll != IB_LINK_LAYER_ETHERNET)
+ return;
-#endif
+ switch (wc->sl & 0x3) {
+ case MLX5_CQE_ROCE_L3_HEADER_TYPE_GRH:
+ wc->network_hdr_type = RDMA_NETWORK_IB;
+ break;
+ case MLX5_CQE_ROCE_L3_HEADER_TYPE_IPV6:
+ wc->network_hdr_type = RDMA_NETWORK_IPV6;
+ break;
+ case MLX5_CQE_ROCE_L3_HEADER_TYPE_IPV4:
+ wc->network_hdr_type = RDMA_NETWORK_IPV4;
+ break;
+ }
+ wc->wc_flags |= IB_WC_WITH_NETWORK_HDR_TYPE;
}
static void dump_cqe(struct mlx5_ib_dev *dev, struct mlx5_err_cqe *cqe)
@@ -240,7 +256,9 @@ static void dump_cqe(struct mlx5_ib_dev *dev, struct mlx5_err_cqe *cqe)
mlx5_ib_warn(dev, "dump error cqe\n");
for (i = 0; i < sizeof(*cqe) / 16; i++, p += 4)
- printf("mlx5_ib: INFO: ""%08x %08x %08x %08x\n", be32_to_cpu(p[0]), be32_to_cpu(p[1]), be32_to_cpu(p[2]), be32_to_cpu(p[3]));
+ pr_info("%08x %08x %08x %08x\n", be32_to_cpu(p[0]),
+ be32_to_cpu(p[1]), be32_to_cpu(p[2]),
+ be32_to_cpu(p[3]));
}
static void mlx5_handle_error_cqe(struct mlx5_ib_dev *dev,
@@ -302,14 +320,14 @@ static void mlx5_handle_error_cqe(struct mlx5_ib_dev *dev,
dump_cqe(dev, cqe);
}
-static int is_atomic_response(struct mlx5_ib_qp *qp, u16 idx)
+static int is_atomic_response(struct mlx5_ib_qp *qp, uint16_t idx)
{
/* TBD: waiting decision
*/
return 0;
}
-static void *mlx5_get_atomic_laddr(struct mlx5_ib_qp *qp, u16 idx)
+static void *mlx5_get_atomic_laddr(struct mlx5_ib_qp *qp, uint16_t idx)
{
struct mlx5_wqe_data_seg *dpseg;
void *addr;
@@ -317,12 +335,12 @@ static void *mlx5_get_atomic_laddr(struct mlx5_ib_qp *qp, u16 idx)
dpseg = mlx5_get_send_wqe(qp, idx) + sizeof(struct mlx5_wqe_ctrl_seg) +
sizeof(struct mlx5_wqe_raddr_seg) +
sizeof(struct mlx5_wqe_atomic_seg);
- addr = (void *)(uintptr_t)be64_to_cpu(dpseg->addr);
+ addr = (void *)(unsigned long)be64_to_cpu(dpseg->addr);
return addr;
}
static void handle_atomic(struct mlx5_ib_qp *qp, struct mlx5_cqe64 *cqe64,
- u16 idx)
+ uint16_t idx)
{
void *addr;
int byte_count;
@@ -335,10 +353,10 @@ static void handle_atomic(struct mlx5_ib_qp *qp, struct mlx5_cqe64 *cqe64,
addr = mlx5_get_atomic_laddr(qp, idx);
if (byte_count == 4) {
- *(u32 *)addr = be32_to_cpu(*((__be32 *)addr));
+ *(uint32_t *)addr = be32_to_cpu(*((__be32 *)addr));
} else {
for (i = 0; i < byte_count; i += 8) {
- *(u64 *)addr = be64_to_cpu(*((__be64 *)addr));
+ *(uint64_t *)addr = be64_to_cpu(*((__be64 *)addr));
addr += 8;
}
}
@@ -357,9 +375,9 @@ static void handle_atomics(struct mlx5_ib_qp *qp, struct mlx5_cqe64 *cqe64,
if (idx == head)
break;
- tail = qp->sq.swr_ctx[idx].w_list.next;
+ tail = qp->sq.w_list[idx].next;
} while (1);
- tail = qp->sq.swr_ctx[idx].w_list.next;
+ tail = qp->sq.w_list[idx].next;
qp->sq.last_poll = tail;
}
@@ -368,12 +386,44 @@ static void free_cq_buf(struct mlx5_ib_dev *dev, struct mlx5_ib_cq_buf *buf)
mlx5_buf_free(dev->mdev, &buf->buf);
}
+static void get_sig_err_item(struct mlx5_sig_err_cqe *cqe,
+ struct ib_sig_err *item)
+{
+ u16 syndrome = be16_to_cpu(cqe->syndrome);
+
+#define GUARD_ERR (1 << 13)
+#define APPTAG_ERR (1 << 12)
+#define REFTAG_ERR (1 << 11)
+
+ if (syndrome & GUARD_ERR) {
+ item->err_type = IB_SIG_BAD_GUARD;
+ item->expected = be32_to_cpu(cqe->expected_trans_sig) >> 16;
+ item->actual = be32_to_cpu(cqe->actual_trans_sig) >> 16;
+ } else
+ if (syndrome & REFTAG_ERR) {
+ item->err_type = IB_SIG_BAD_REFTAG;
+ item->expected = be32_to_cpu(cqe->expected_reftag);
+ item->actual = be32_to_cpu(cqe->actual_reftag);
+ } else
+ if (syndrome & APPTAG_ERR) {
+ item->err_type = IB_SIG_BAD_APPTAG;
+ item->expected = be32_to_cpu(cqe->expected_trans_sig) & 0xffff;
+ item->actual = be32_to_cpu(cqe->actual_trans_sig) & 0xffff;
+ } else {
+ pr_err("Got signature completion error with bad syndrome %04x\n",
+ syndrome);
+ }
+
+ item->sig_err_offset = be64_to_cpu(cqe->err_offset);
+ item->key = be32_to_cpu(cqe->mkey);
+}
+
static void sw_send_comp(struct mlx5_ib_qp *qp, int num_entries,
struct ib_wc *wc, int *npolled)
{
struct mlx5_ib_wq *wq;
- unsigned cur;
- unsigned idx;
+ unsigned int cur;
+ unsigned int idx;
int np;
int i;
@@ -386,14 +436,14 @@ static void sw_send_comp(struct mlx5_ib_qp *qp, int num_entries,
for (i = 0; i < cur && np < num_entries; i++) {
idx = wq->last_poll & (wq->wqe_cnt - 1);
- wc->wr_id = wq->swr_ctx[idx].wrid;
+ wc->wr_id = wq->wrid[idx];
wc->status = IB_WC_WR_FLUSH_ERR;
wc->vendor_err = MLX5_CQE_SYNDROME_WR_FLUSH_ERR;
wq->tail++;
np++;
wc->qp = &qp->ibqp;
wc++;
- wq->last_poll = wq->swr_ctx[idx].w_list.next;
+ wq->last_poll = wq->w_list[idx].next;
}
*npolled = np;
}
@@ -402,7 +452,7 @@ static void sw_recv_comp(struct mlx5_ib_qp *qp, int num_entries,
struct ib_wc *wc, int *npolled)
{
struct mlx5_ib_wq *wq;
- unsigned cur;
+ unsigned int cur;
int np;
int i;
@@ -414,7 +464,7 @@ static void sw_recv_comp(struct mlx5_ib_qp *qp, int num_entries,
return;
for (i = 0; i < cur && np < num_entries; i++) {
- wc->wr_id = wq->rwr_ctx[wq->tail & (wq->wqe_cnt - 1)].wrid;
+ wc->wr_id = wq->wrid[wq->tail & (wq->wqe_cnt - 1)];
wc->status = IB_WC_WR_FLUSH_ERR;
wc->vendor_err = MLX5_CQE_SYNDROME_WR_FLUSH_ERR;
wq->tail++;
@@ -445,11 +495,6 @@ static void mlx5_ib_poll_sw_comp(struct mlx5_ib_cq *cq, int num_entries,
}
}
-static inline u32 mlx5_ib_base_mkey(const u32 key)
-{
- return key & 0xffffff00u;
-}
-
static int mlx5_poll_one(struct mlx5_ib_cq *cq,
struct mlx5_ib_qp **cur_qp,
struct ib_wc *wc)
@@ -460,11 +505,11 @@ static int mlx5_poll_one(struct mlx5_ib_cq *cq,
struct mlx5_core_qp *mqp;
struct mlx5_ib_wq *wq;
struct mlx5_sig_err_cqe *sig_err_cqe;
- struct mlx5_core_mr *mmr;
+ struct mlx5_core_mr *mmkey;
struct mlx5_ib_mr *mr;
unsigned long flags;
- u8 opcode;
- u32 qpn;
+ uint8_t opcode;
+ uint32_t qpn;
u16 wqe_ctr;
void *cqe;
int idx;
@@ -503,12 +548,6 @@ repoll:
* from the table.
*/
mqp = __mlx5_qp_lookup(dev->mdev, qpn);
- if (unlikely(!mqp)) {
- mlx5_ib_warn(dev, "CQE@CQ %06x for unknown QPN %6x\n",
- cq->mcq.cqn, qpn);
- return -EINVAL;
- }
-
*cur_qp = to_mibqp(mqp);
}
@@ -520,13 +559,9 @@ repoll:
idx = wqe_ctr & (wq->wqe_cnt - 1);
handle_good_req(wc, cqe64, wq, idx);
handle_atomics(*cur_qp, cqe64, wq->last_poll, idx);
- wc->wr_id = wq->swr_ctx[idx].wrid;
- wq->tail = wq->swr_ctx[idx].wqe_head + 1;
- if (unlikely(wq->swr_ctx[idx].w_list.opcode &
- MLX5_OPCODE_SIGNATURE_CANCELED))
- wc->status = IB_WC_GENERAL_ERR;
- else
- wc->status = IB_WC_SUCCESS;
+ wc->wr_id = wq->wrid[idx];
+ wq->tail = wq->wqe_head[idx] + 1;
+ wc->status = IB_WC_SUCCESS;
break;
case MLX5_CQE_RESP_WR_IMM:
case MLX5_CQE_RESP_SEND:
@@ -550,8 +585,8 @@ repoll:
wq = &(*cur_qp)->sq;
wqe_ctr = be16_to_cpu(cqe64->wqe_counter);
idx = wqe_ctr & (wq->wqe_cnt - 1);
- wc->wr_id = wq->swr_ctx[idx].wrid;
- wq->tail = wq->swr_ctx[idx].wqe_head + 1;
+ wc->wr_id = wq->wrid[idx];
+ wq->tail = wq->wqe_head[idx] + 1;
} else {
struct mlx5_ib_srq *srq;
@@ -562,7 +597,7 @@ repoll:
mlx5_ib_free_srq_wqe(srq, wqe_ctr);
} else {
wq = &(*cur_qp)->rq;
- wc->wr_id = wq->rwr_ctx[wq->tail & (wq->wqe_cnt - 1)].wrid;
+ wc->wr_id = wq->wrid[wq->tail & (wq->wqe_cnt - 1)];
++wq->tail;
}
}
@@ -571,20 +606,19 @@ repoll:
sig_err_cqe = (struct mlx5_sig_err_cqe *)cqe64;
spin_lock_irqsave(&dev->mdev->priv.mr_table.lock, flags);
- mmr = __mlx5_mr_lookup(dev->mdev,
- mlx5_ib_base_mkey(be32_to_cpu(sig_err_cqe->mkey)));
- if (unlikely(!mmr)) {
- spin_unlock_irqrestore(&dev->mdev->priv.mr_table.lock, flags);
- mlx5_ib_warn(dev, "CQE@CQ %06x for unknown MR %6x\n",
- cq->mcq.cqn, be32_to_cpu(sig_err_cqe->mkey));
- return -EINVAL;
- }
-
- mr = to_mibmr(mmr);
+ mmkey = __mlx5_mr_lookup(dev->mdev,
+ mlx5_base_mkey(be32_to_cpu(sig_err_cqe->mkey)));
+ mr = to_mibmr(mmkey);
+ get_sig_err_item(sig_err_cqe, &mr->sig->err_item);
mr->sig->sig_err_exists = true;
mr->sig->sigerr_count++;
- mlx5_ib_warn(dev, "CQN: 0x%x Got SIGERR\n", cq->mcq.cqn);
+ mlx5_ib_warn(dev, "CQN: 0x%x Got SIGERR on key: 0x%x err_type %x err_offset %llx expected %x actual %x\n",
+ cq->mcq.cqn, mr->sig->err_item.key,
+ mr->sig->err_item.err_type,
+ (long long)mr->sig->err_item.sig_err_offset,
+ mr->sig->err_item.expected,
+ mr->sig->err_item.actual);
spin_unlock_irqrestore(&dev->mdev->priv.mr_table.lock, flags);
goto repoll;
@@ -593,6 +627,28 @@ repoll:
return 0;
}
+static int poll_soft_wc(struct mlx5_ib_cq *cq, int num_entries,
+ struct ib_wc *wc)
+{
+ struct mlx5_ib_dev *dev = to_mdev(cq->ibcq.device);
+ struct mlx5_ib_wc *soft_wc, *next;
+ int npolled = 0;
+
+ list_for_each_entry_safe(soft_wc, next, &cq->wc_list, list) {
+ if (npolled >= num_entries)
+ break;
+
+ mlx5_ib_dbg(dev, "polled software generated completion on CQ 0x%x\n",
+ cq->mcq.cqn);
+
+ wc[npolled++] = soft_wc->wc;
+ list_del(&soft_wc->list);
+ kfree(soft_wc);
+ }
+
+ return npolled;
+}
+
int mlx5_ib_poll_cq(struct ib_cq *ibcq, int num_entries, struct ib_wc *wc)
{
struct mlx5_ib_cq *cq = to_mcq(ibcq);
@@ -600,8 +656,8 @@ int mlx5_ib_poll_cq(struct ib_cq *ibcq, int num_entries, struct ib_wc *wc)
struct mlx5_ib_dev *dev = to_mdev(cq->ibcq.device);
struct mlx5_core_dev *mdev = dev->mdev;
unsigned long flags;
+ int soft_polled = 0;
int npolled;
- int err = 0;
spin_lock_irqsave(&cq->lock, flags);
if (mdev->state == MLX5_DEVICE_STATE_INTERNAL_ERROR) {
@@ -609,9 +665,11 @@ int mlx5_ib_poll_cq(struct ib_cq *ibcq, int num_entries, struct ib_wc *wc)
goto out;
}
- for (npolled = 0; npolled < num_entries; npolled++) {
- err = mlx5_poll_one(cq, &cur_qp, wc + npolled);
- if (err)
+ if (unlikely(!list_empty(&cq->wc_list)))
+ soft_polled = poll_soft_wc(cq, num_entries, wc);
+
+ for (npolled = 0; npolled < num_entries - soft_polled; npolled++) {
+ if (mlx5_poll_one(cq, &cur_qp, wc + soft_polled + npolled))
break;
}
@@ -620,26 +678,33 @@ int mlx5_ib_poll_cq(struct ib_cq *ibcq, int num_entries, struct ib_wc *wc)
out:
spin_unlock_irqrestore(&cq->lock, flags);
- if (err == 0 || err == -EAGAIN)
- return npolled;
- else
- return err;
+ return soft_polled + npolled;
}
int mlx5_ib_arm_cq(struct ib_cq *ibcq, enum ib_cq_notify_flags flags)
{
struct mlx5_core_dev *mdev = to_mdev(ibcq->device)->mdev;
+ struct mlx5_ib_cq *cq = to_mcq(ibcq);
void __iomem *uar_page = mdev->priv.uuari.uars[0].map;
+ unsigned long irq_flags;
+ int ret = 0;
+ spin_lock_irqsave(&cq->lock, irq_flags);
+ if (cq->notify_flags != IB_CQ_NEXT_COMP)
+ cq->notify_flags = flags & IB_CQ_SOLICITED_MASK;
- mlx5_cq_arm(&to_mcq(ibcq)->mcq,
+ if ((flags & IB_CQ_REPORT_MISSED_EVENTS) && !list_empty(&cq->wc_list))
+ ret = 1;
+ spin_unlock_irqrestore(&cq->lock, irq_flags);
+
+ mlx5_cq_arm(&cq->mcq,
(flags & IB_CQ_SOLICITED_MASK) == IB_CQ_SOLICITED ?
MLX5_CQ_DB_REQ_NOT_SOL : MLX5_CQ_DB_REQ_NOT,
uar_page,
MLX5_GET_DOORBELL_LOCK(&mdev->priv.cq_uar_lock),
to_mcq(ibcq)->mcq.cons_index);
- return 0;
+ return ret;
}
static int alloc_cq_buf(struct mlx5_ib_dev *dev, struct mlx5_ib_cq_buf *buf,
@@ -648,11 +713,9 @@ static int alloc_cq_buf(struct mlx5_ib_dev *dev, struct mlx5_ib_cq_buf *buf,
int err;
err = mlx5_buf_alloc(dev->mdev, nent * cqe_size,
- PAGE_SIZE * 2, &buf->buf);
- if (err) {
- mlx5_ib_err(dev, "alloc failed\n");
+ 2 * PAGE_SIZE, &buf->buf);
+ if (err)
return err;
- }
buf->cqe_size = cqe_size;
buf->nent = nent;
@@ -662,38 +725,32 @@ static int alloc_cq_buf(struct mlx5_ib_dev *dev, struct mlx5_ib_cq_buf *buf,
static int create_cq_user(struct mlx5_ib_dev *dev, struct ib_udata *udata,
struct ib_ucontext *context, struct mlx5_ib_cq *cq,
- int entries, struct mlx5_create_cq_mbox_in **cqb,
+ int entries, u32 **cqb,
int *cqe_size, int *index, int *inlen)
{
- struct mlx5_exp_ib_create_cq ucmd;
+ struct mlx5_ib_create_cq ucmd;
size_t ucmdlen;
int page_shift;
+ __be64 *pas;
int npages;
int ncont;
+ void *cqc;
int err;
- memset(&ucmd, 0, sizeof(ucmd));
-
ucmdlen =
(udata->inlen - sizeof(struct ib_uverbs_cmd_hdr) <
- sizeof(struct mlx5_ib_create_cq)) ?
- (sizeof(struct mlx5_ib_create_cq) - sizeof(ucmd.reserved)) :
- sizeof(struct mlx5_ib_create_cq);
+ sizeof(ucmd)) ? (sizeof(ucmd) -
+ sizeof(ucmd.reserved)) : sizeof(ucmd);
- if (ib_copy_from_udata(&ucmd, udata, ucmdlen)) {
- mlx5_ib_err(dev, "copy failed\n");
+ if (ib_copy_from_udata(&ucmd, udata, ucmdlen))
return -EFAULT;
- }
- if (ucmdlen == sizeof(ucmd) && ucmd.reserved != 0) {
- mlx5_ib_err(dev, "command corrupted\n");
+ if (ucmdlen == sizeof(ucmd) &&
+ ucmd.reserved != 0)
return -EINVAL;
- }
- if (ucmd.cqe_size != 64 && ucmd.cqe_size != 128) {
- mlx5_ib_warn(dev, "wrong CQE size %d\n", ucmd.cqe_size);
+ if (ucmd.cqe_size != 64 && ucmd.cqe_size != 128)
return -EINVAL;
- }
*cqe_size = ucmd.cqe_size;
@@ -707,41 +764,30 @@ static int create_cq_user(struct mlx5_ib_dev *dev, struct ib_udata *udata,
err = mlx5_ib_db_map_user(to_mucontext(context), ucmd.db_addr,
&cq->db);
- if (err) {
- mlx5_ib_warn(dev, "map failed\n");
+ if (err)
goto err_umem;
- }
mlx5_ib_cont_pages(cq->buf.umem, ucmd.buf_addr, &npages, &page_shift,
&ncont, NULL);
mlx5_ib_dbg(dev, "addr 0x%llx, size %u, npages %d, page_shift %d, ncont %d\n",
- (unsigned long long)ucmd.buf_addr, entries * ucmd.cqe_size,
- npages, page_shift, ncont);
+ (long long)ucmd.buf_addr, entries * ucmd.cqe_size, npages, page_shift, ncont);
- *inlen = sizeof(**cqb) + sizeof(*(*cqb)->pas) * ncont;
+ *inlen = MLX5_ST_SZ_BYTES(create_cq_in) +
+ MLX5_FLD_SZ_BYTES(create_cq_in, pas[0]) * ncont;
*cqb = mlx5_vzalloc(*inlen);
if (!*cqb) {
err = -ENOMEM;
goto err_db;
}
- mlx5_ib_populate_pas(dev, cq->buf.umem, page_shift, (*cqb)->pas, 0);
- (*cqb)->ctx.log_pg_sz = page_shift - MLX5_ADAPTER_PAGE_SHIFT;
+ pas = (__be64 *)MLX5_ADDR_OF(create_cq_in, *cqb, pas);
+ mlx5_ib_populate_pas(dev, cq->buf.umem, page_shift, pas, 0);
- *index = to_mucontext(context)->uuari.uars[0].index;
+ cqc = MLX5_ADDR_OF(create_cq_in, *cqb, cq_context);
+ MLX5_SET(cqc, cqc, log_page_size,
+ page_shift - MLX5_ADAPTER_PAGE_SHIFT);
- if (*cqe_size == 64 && MLX5_CAP_GEN(dev->mdev, cqe_compression)) {
- if (ucmd.exp_data.cqe_comp_en == 1 &&
- (ucmd.exp_data.comp_mask & MLX5_EXP_CREATE_CQ_MASK_CQE_COMP_EN)) {
- MLX5_SET(cqc, &(*cqb)->ctx, cqe_compression_en, 1);
- if (ucmd.exp_data.cqe_comp_recv_type ==
- MLX5_IB_CQE_FORMAT_CSUM &&
- (ucmd.exp_data.comp_mask &
- MLX5_EXP_CREATE_CQ_MASK_CQE_COMP_RECV_TYPE))
- MLX5_SET(cqc, &(*cqb)->ctx, mini_cqe_res_format,
- MLX5_IB_CQE_FORMAT_CSUM);
- }
- }
+ *index = to_mucontext(context)->uuari.uars[0].index;
return 0;
@@ -755,7 +801,6 @@ err_umem:
static void destroy_cq_user(struct mlx5_ib_cq *cq, struct ib_ucontext *context)
{
-
mlx5_ib_db_unmap_user(to_mucontext(context), &cq->db);
ib_umem_release(cq->buf.umem);
}
@@ -775,9 +820,10 @@ static void init_cq_buf(struct mlx5_ib_cq *cq, struct mlx5_ib_cq_buf *buf)
static int create_cq_kernel(struct mlx5_ib_dev *dev, struct mlx5_ib_cq *cq,
int entries, int cqe_size,
- struct mlx5_create_cq_mbox_in **cqb,
- int *index, int *inlen)
+ u32 **cqb, int *index, int *inlen)
{
+ __be64 *pas;
+ void *cqc;
int err;
err = mlx5_db_alloc(dev->mdev, &cq->db);
@@ -794,15 +840,21 @@ static int create_cq_kernel(struct mlx5_ib_dev *dev, struct mlx5_ib_cq *cq,
init_cq_buf(cq, &cq->buf);
- *inlen = sizeof(**cqb) + sizeof(*(*cqb)->pas) * cq->buf.buf.npages;
+ *inlen = MLX5_ST_SZ_BYTES(create_cq_in) +
+ MLX5_FLD_SZ_BYTES(create_cq_in, pas[0]) * cq->buf.buf.npages;
*cqb = mlx5_vzalloc(*inlen);
if (!*cqb) {
err = -ENOMEM;
goto err_buf;
}
- mlx5_fill_page_array(&cq->buf.buf, (*cqb)->pas);
- (*cqb)->ctx.log_pg_sz = cq->buf.buf.page_shift - MLX5_ADAPTER_PAGE_SHIFT;
+ pas = (__be64 *)MLX5_ADDR_OF(create_cq_in, *cqb, pas);
+ mlx5_fill_page_array(&cq->buf.buf, pas);
+
+ cqc = MLX5_ADDR_OF(create_cq_in, *cqb, cq_context);
+ MLX5_SET(cqc, cqc, log_page_size,
+ cq->buf.buf.page_shift - MLX5_ADAPTER_PAGE_SHIFT);
+
*index = dev->mdev->priv.uuari.uars[0].index;
return 0;
@@ -821,32 +873,42 @@ static void destroy_cq_kernel(struct mlx5_ib_dev *dev, struct mlx5_ib_cq *cq)
mlx5_db_free(dev->mdev, &cq->db);
}
+static void notify_soft_wc_handler(struct work_struct *work)
+{
+ struct mlx5_ib_cq *cq = container_of(work, struct mlx5_ib_cq,
+ notify_work);
+
+ cq->ibcq.comp_handler(&cq->ibcq, cq->ibcq.cq_context);
+}
+
struct ib_cq *mlx5_ib_create_cq(struct ib_device *ibdev,
- struct ib_cq_init_attr *attr,
+ const struct ib_cq_init_attr *attr,
struct ib_ucontext *context,
struct ib_udata *udata)
{
- struct mlx5_create_cq_mbox_in *cqb = NULL;
- struct mlx5_ib_dev *dev = to_mdev(ibdev);
- struct mlx5_ib_cq *cq;
int entries = attr->cqe;
int vector = attr->comp_vector;
+ struct mlx5_ib_dev *dev = to_mdev(ibdev);
+ struct mlx5_ib_cq *cq;
int uninitialized_var(index);
int uninitialized_var(inlen);
+ u32 *cqb = NULL;
+ void *cqc;
int cqe_size;
- int irqn;
+ unsigned int irqn;
int eqn;
int err;
- if (entries < 0 || roundup_pow_of_two(entries + 1) >
- (1 << MLX5_CAP_GEN(dev->mdev, log_max_cq_sz))) {
- mlx5_ib_warn(dev, "wrong entries number %d(%ld), max %d\n",
- entries, roundup_pow_of_two(entries + 1),
- 1 << MLX5_CAP_GEN(dev->mdev, log_max_cq_sz));
+ if (entries < 0 ||
+ (entries > (1 << MLX5_CAP_GEN(dev->mdev, log_max_cq_sz))))
return ERR_PTR(-EINVAL);
- }
+
+ if (check_cq_create_flags(attr->flags))
+ return ERR_PTR(-EOPNOTSUPP);
entries = roundup_pow_of_two(entries + 1);
+ if (entries > (1 << MLX5_CAP_GEN(dev->mdev, log_max_cq_sz)))
+ return ERR_PTR(-EINVAL);
cq = kzalloc(sizeof(*cq), GFP_KERNEL);
if (!cq)
@@ -857,7 +919,7 @@ struct ib_cq *mlx5_ib_create_cq(struct ib_device *ibdev,
spin_lock_init(&cq->lock);
cq->resize_buf = NULL;
cq->resize_umem = NULL;
-
+ cq->create_flags = attr->flags;
INIT_LIST_HEAD(&cq->list_send_qp);
INIT_LIST_HEAD(&cq->list_recv_qp);
@@ -867,24 +929,32 @@ struct ib_cq *mlx5_ib_create_cq(struct ib_device *ibdev,
if (err)
goto err_create;
} else {
- cqe_size = (cache_line_size() >= 128 ? 128 : 64);
+ cqe_size = cache_line_size() == 128 ? 128 : 64;
err = create_cq_kernel(dev, cq, entries, cqe_size, &cqb,
&index, &inlen);
if (err)
goto err_create;
+
+ INIT_WORK(&cq->notify_work, notify_soft_wc_handler);
}
- cq->cqe_size = cqe_size;
- cqb->ctx.cqe_sz_flags = cqe_sz_to_mlx_sz(cqe_size) << 5;
- cqb->ctx.log_sz_usr_page = cpu_to_be32((ilog2(entries) << 24) | index);
err = mlx5_vector2eqn(dev->mdev, vector, &eqn, &irqn);
if (err)
goto err_cqb;
- cqb->ctx.c_eqn = cpu_to_be16(eqn);
- cqb->ctx.db_record_addr = cpu_to_be64(cq->db.dma);
+ cq->cqe_size = cqe_size;
- err = mlx5_core_create_cq(dev->mdev, &cq->mcq, cqb, inlen);
+ cqc = MLX5_ADDR_OF(create_cq_in, cqb, cq_context);
+ MLX5_SET(cqc, cqc, cqe_sz, cqe_sz_to_mlx_sz(cqe_size));
+ MLX5_SET(cqc, cqc, log_cq_size, ilog2(entries));
+ MLX5_SET(cqc, cqc, uar_page, index);
+ MLX5_SET(cqc, cqc, c_eqn, eqn);
+ MLX5_SET64(cqc, cqc, dbr_addr, cq->db.dma);
+ if (cq->create_flags & IB_CQ_FLAGS_IGNORE_OVERRUN)
+ MLX5_SET(cqc, cqc, oi, 1);
+
+ err = mlx5_core_create_cq(dev->mdev, &cq->mcq,
+ (struct mlx5_create_cq_mbox_in *)cqb, inlen);
if (err)
goto err_cqb;
@@ -893,6 +963,8 @@ struct ib_cq *mlx5_ib_create_cq(struct ib_device *ibdev,
cq->mcq.comp = mlx5_ib_cq_comp;
cq->mcq.event = mlx5_ib_cq_event;
+ INIT_LIST_HEAD(&cq->wc_list);
+
if (context)
if (ib_copy_to_udata(udata, &cq->mcq.cqn, sizeof(__u32))) {
err = -EFAULT;
@@ -1006,44 +1078,17 @@ void mlx5_ib_cq_clean(struct mlx5_ib_cq *cq, u32 qpn, struct mlx5_ib_srq *srq)
spin_unlock_irq(&cq->lock);
}
-int mlx5_ib_modify_cq(struct ib_cq *cq, struct ib_cq_attr *attr, int cq_attr_mask)
+int mlx5_ib_modify_cq(struct ib_cq *cq, u16 cq_count, u16 cq_period)
{
- struct mlx5_modify_cq_mbox_in *in;
struct mlx5_ib_dev *dev = to_mdev(cq->device);
struct mlx5_ib_cq *mcq = to_mcq(cq);
- u16 cq_count = attr->moderation.cq_count;
- u16 cq_period = attr->moderation.cq_period;
-
int err;
- u32 fsel = 0;
-
- in = kzalloc(sizeof(*in), GFP_KERNEL);
- if (!in)
- return -ENOMEM;
- in->cqn = cpu_to_be32(mcq->mcq.cqn);
- if (cq_attr_mask & IB_CQ_MODERATION) {
- if (MLX5_CAP_GEN(dev->mdev, cq_moderation)) {
- fsel |= (MLX5_CQ_MODIFY_PERIOD | MLX5_CQ_MODIFY_COUNT);
- if (cq_period & 0xf000) {
- /* A value higher than 0xfff is required, better
- * use the largest value possible. */
- cq_period = 0xfff;
- printf("mlx5_ib: INFO: ""period supported is limited to 12 bits\n");
- }
-
- in->ctx.cq_period = cpu_to_be16(cq_period);
- in->ctx.cq_max_count = cpu_to_be16(cq_count);
- } else {
- err = -ENOSYS;
- goto out;
- }
- }
- in->field_select = cpu_to_be32(fsel);
- err = mlx5_core_modify_cq(dev->mdev, &mcq->mcq, in, sizeof(*in));
+ if (!MLX5_CAP_GEN(dev->mdev, cq_moderation))
+ return -ENOSYS;
-out:
- kfree(in);
+ err = mlx5_core_modify_cq_moderation(dev->mdev, &mcq->mcq,
+ cq_period, cq_count);
if (err)
mlx5_ib_warn(dev, "modify cq 0x%x failed\n", mcq->mcq.cqn);
@@ -1163,7 +1208,8 @@ static int copy_resize_cqes(struct mlx5_ib_cq *cq)
}
if (scqe == start_cqe) {
- printf("mlx5_ib: WARN: ""resize CQ failed to get resize CQE, CQN 0x%x\n", cq->mcq.cqn);
+ pr_warn("resize CQ failed to get resize CQE, CQN 0x%x\n",
+ cq->mcq.cqn);
return -ENOMEM;
}
}
@@ -1175,28 +1221,32 @@ int mlx5_ib_resize_cq(struct ib_cq *ibcq, int entries, struct ib_udata *udata)
{
struct mlx5_ib_dev *dev = to_mdev(ibcq->device);
struct mlx5_ib_cq *cq = to_mcq(ibcq);
- struct mlx5_modify_cq_mbox_in *in;
+ void *cqc;
+ u32 *in;
int err;
int npas;
+ __be64 *pas;
int page_shift;
int inlen;
int uninitialized_var(cqe_size);
unsigned long flags;
if (!MLX5_CAP_GEN(dev->mdev, cq_resize)) {
- mlx5_ib_warn(dev, "Firmware does not support resize CQ\n");
+ pr_info("Firmware does not support resize CQ\n");
return -ENOSYS;
}
- if (entries < 1 || roundup_pow_of_two(entries + 1) >
- (1 << MLX5_CAP_GEN(dev->mdev, log_max_cq_sz))) {
- mlx5_ib_warn(dev, "wrong entries number %d(%ld), max %d\n",
- entries, roundup_pow_of_two(entries + 1),
+ if (entries < 1 ||
+ entries > (1 << MLX5_CAP_GEN(dev->mdev, log_max_cq_sz))) {
+ mlx5_ib_warn(dev, "wrong entries number %d, max %d\n",
+ entries,
1 << MLX5_CAP_GEN(dev->mdev, log_max_cq_sz));
return -EINVAL;
}
entries = roundup_pow_of_two(entries + 1);
+ if (entries > (1 << MLX5_CAP_GEN(dev->mdev, log_max_cq_sz)) + 1)
+ return -EINVAL;
if (entries == ibcq->cqe + 1)
return 0;
@@ -1214,39 +1264,45 @@ int mlx5_ib_resize_cq(struct ib_cq *ibcq, int entries, struct ib_udata *udata)
}
}
- if (err) {
- mlx5_ib_warn(dev, "resize failed: %d\n", err);
+ if (err)
goto ex;
- }
- inlen = sizeof(*in) + npas * sizeof(in->pas[0]);
+ inlen = MLX5_ST_SZ_BYTES(modify_cq_in) +
+ MLX5_FLD_SZ_BYTES(modify_cq_in, pas[0]) * npas;
+
in = mlx5_vzalloc(inlen);
if (!in) {
err = -ENOMEM;
goto ex_resize;
}
+ pas = (__be64 *)MLX5_ADDR_OF(modify_cq_in, in, pas);
if (udata)
mlx5_ib_populate_pas(dev, cq->resize_umem, page_shift,
- in->pas, 0);
+ pas, 0);
else
- mlx5_fill_page_array(&cq->resize_buf->buf, in->pas);
-
- in->field_select = cpu_to_be32(MLX5_MODIFY_CQ_MASK_LOG_SIZE |
- MLX5_MODIFY_CQ_MASK_PG_OFFSET |
- MLX5_MODIFY_CQ_MASK_PG_SIZE);
- in->ctx.log_pg_sz = page_shift - MLX5_ADAPTER_PAGE_SHIFT;
- in->ctx.cqe_sz_flags = cqe_sz_to_mlx_sz(cqe_size) << 5;
- in->ctx.page_offset = 0;
- in->ctx.log_sz_usr_page = cpu_to_be32(ilog2(entries) << 24);
- in->hdr.opmod = cpu_to_be16(MLX5_CQ_OPMOD_RESIZE);
- in->cqn = cpu_to_be32(cq->mcq.cqn);
-
- err = mlx5_core_modify_cq(dev->mdev, &cq->mcq, in, inlen);
- if (err) {
- mlx5_ib_warn(dev, "modify cq failed: %d\n", err);
+ mlx5_fill_page_array(&cq->resize_buf->buf, pas);
+
+ MLX5_SET(modify_cq_in, in,
+ modify_field_select_resize_field_select.resize_field_select.resize_field_select,
+ MLX5_MODIFY_CQ_MASK_LOG_SIZE |
+ MLX5_MODIFY_CQ_MASK_PG_OFFSET |
+ MLX5_MODIFY_CQ_MASK_PG_SIZE);
+
+ cqc = MLX5_ADDR_OF(modify_cq_in, in, cq_context);
+
+ MLX5_SET(cqc, cqc, log_page_size,
+ page_shift - MLX5_ADAPTER_PAGE_SHIFT);
+ MLX5_SET(cqc, cqc, cqe_sz, cqe_sz_to_mlx_sz(cqe_size));
+ MLX5_SET(cqc, cqc, log_cq_size, ilog2(entries));
+
+ MLX5_SET(modify_cq_in, in, op_mod, MLX5_CQ_OPMOD_RESIZE);
+ MLX5_SET(modify_cq_in, in, cqn, cq->mcq.cqn);
+
+ err = mlx5_core_modify_cq(dev->mdev, &cq->mcq,
+ (struct mlx5_modify_cq_mbox_in *)in, inlen);
+ if (err)
goto ex_alloc;
- }
if (udata) {
cq->ibcq.cqe = entries - 1;
@@ -1301,3 +1357,27 @@ int mlx5_ib_get_cqe_size(struct mlx5_ib_dev *dev, struct ib_cq *ibcq)
cq = to_mcq(ibcq);
return cq->cqe_size;
}
+
+/* Called from atomic context */
+int mlx5_ib_generate_wc(struct ib_cq *ibcq, struct ib_wc *wc)
+{
+ struct mlx5_ib_wc *soft_wc;
+ struct mlx5_ib_cq *cq = to_mcq(ibcq);
+ unsigned long flags;
+
+ soft_wc = kmalloc(sizeof(*soft_wc), GFP_ATOMIC);
+ if (!soft_wc)
+ return -ENOMEM;
+
+ soft_wc->wc = *wc;
+ spin_lock_irqsave(&cq->lock, flags);
+ list_add_tail(&soft_wc->list, &cq->wc_list);
+ if (cq->notify_flags == IB_CQ_NEXT_COMP ||
+ wc->status != IB_WC_SUCCESS) {
+ cq->notify_flags = 0;
+ schedule_work(&cq->notify_work);
+ }
+ spin_unlock_irqrestore(&cq->lock, flags);
+
+ return 0;
+}
diff --git a/sys/dev/mlx5/mlx5_ib/mlx5_ib_doorbell.c b/sys/dev/mlx5/mlx5_ib/mlx5_ib_doorbell.c
index ecbf658..490363f 100644
--- a/sys/dev/mlx5/mlx5_ib/mlx5_ib_doorbell.c
+++ b/sys/dev/mlx5/mlx5_ib/mlx5_ib_doorbell.c
@@ -34,11 +34,11 @@
struct mlx5_ib_user_db_page {
struct list_head list;
struct ib_umem *umem;
- uintptr_t user_virt;
+ unsigned long user_virt;
int refcnt;
};
-int mlx5_ib_db_map_user(struct mlx5_ib_ucontext *context, uintptr_t virt,
+int mlx5_ib_db_map_user(struct mlx5_ib_ucontext *context, unsigned long virt,
struct mlx5_db *db)
{
struct mlx5_ib_user_db_page *page;
diff --git a/sys/dev/mlx5/mlx5_ib/mlx5_ib_gsi.c b/sys/dev/mlx5/mlx5_ib/mlx5_ib_gsi.c
new file mode 100644
index 0000000..31d1c11
--- /dev/null
+++ b/sys/dev/mlx5/mlx5_ib/mlx5_ib_gsi.c
@@ -0,0 +1,536 @@
+/*-
+ * Copyright (c) 2016, Mellanox Technologies, Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS `AS IS' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * $FreeBSD$
+ */
+
+#include "mlx5_ib.h"
+
+struct mlx5_ib_gsi_wr {
+ struct ib_cqe cqe;
+ struct ib_wc wc;
+ int send_flags;
+ bool completed:1;
+};
+
+struct mlx5_ib_gsi_qp {
+ struct ib_qp ibqp;
+ struct ib_qp *rx_qp;
+ u8 port_num;
+ struct ib_qp_cap cap;
+ enum ib_sig_type sq_sig_type;
+ /* Serialize qp state modifications */
+ struct mutex mutex;
+ struct ib_cq *cq;
+ struct mlx5_ib_gsi_wr *outstanding_wrs;
+ u32 outstanding_pi, outstanding_ci;
+ int num_qps;
+ /* Protects access to the tx_qps. Post send operations synchronize
+ * with tx_qp creation in setup_qp(). Also protects the
+ * outstanding_wrs array and indices.
+ */
+ spinlock_t lock;
+ struct ib_qp **tx_qps;
+};
+
+static struct mlx5_ib_gsi_qp *gsi_qp(struct ib_qp *qp)
+{
+ return container_of(qp, struct mlx5_ib_gsi_qp, ibqp);
+}
+
+static bool mlx5_ib_deth_sqpn_cap(struct mlx5_ib_dev *dev)
+{
+ return MLX5_CAP_GEN(dev->mdev, set_deth_sqpn);
+}
+
+/* Call with gsi->lock locked */
+static void generate_completions(struct mlx5_ib_gsi_qp *gsi)
+{
+ struct ib_cq *gsi_cq = gsi->ibqp.send_cq;
+ struct mlx5_ib_gsi_wr *wr;
+ u32 index;
+
+ for (index = gsi->outstanding_ci; index != gsi->outstanding_pi;
+ index++) {
+ wr = &gsi->outstanding_wrs[index % gsi->cap.max_send_wr];
+
+ if (!wr->completed)
+ break;
+
+ if (gsi->sq_sig_type == IB_SIGNAL_ALL_WR ||
+ wr->send_flags & IB_SEND_SIGNALED)
+ WARN_ON_ONCE(mlx5_ib_generate_wc(gsi_cq, &wr->wc));
+
+ wr->completed = false;
+ }
+
+ gsi->outstanding_ci = index;
+}
+
+static void handle_single_completion(struct ib_cq *cq, struct ib_wc *wc)
+{
+ struct mlx5_ib_gsi_qp *gsi = cq->cq_context;
+ struct mlx5_ib_gsi_wr *wr =
+ container_of(wc->wr_cqe, struct mlx5_ib_gsi_wr, cqe);
+ u64 wr_id;
+ unsigned long flags;
+
+ spin_lock_irqsave(&gsi->lock, flags);
+ wr->completed = true;
+ wr_id = wr->wc.wr_id;
+ wr->wc = *wc;
+ wr->wc.wr_id = wr_id;
+ wr->wc.qp = &gsi->ibqp;
+
+ generate_completions(gsi);
+ spin_unlock_irqrestore(&gsi->lock, flags);
+}
+
+struct ib_qp *mlx5_ib_gsi_create_qp(struct ib_pd *pd,
+ struct ib_qp_init_attr *init_attr)
+{
+ struct mlx5_ib_dev *dev = to_mdev(pd->device);
+ struct mlx5_ib_gsi_qp *gsi;
+ struct ib_qp_init_attr hw_init_attr = *init_attr;
+ const u8 port_num = init_attr->port_num;
+ const int num_pkeys = pd->device->attrs.max_pkeys;
+ const int num_qps = mlx5_ib_deth_sqpn_cap(dev) ? num_pkeys : 0;
+ int ret;
+
+ mlx5_ib_dbg(dev, "creating GSI QP\n");
+
+ if (port_num > ARRAY_SIZE(dev->devr.ports) || port_num < 1) {
+ mlx5_ib_warn(dev,
+ "invalid port number %d during GSI QP creation\n",
+ port_num);
+ return ERR_PTR(-EINVAL);
+ }
+
+ gsi = kzalloc(sizeof(*gsi), GFP_KERNEL);
+ if (!gsi)
+ return ERR_PTR(-ENOMEM);
+
+ gsi->tx_qps = kcalloc(num_qps, sizeof(*gsi->tx_qps), GFP_KERNEL);
+ if (!gsi->tx_qps) {
+ ret = -ENOMEM;
+ goto err_free;
+ }
+
+ gsi->outstanding_wrs = kcalloc(init_attr->cap.max_send_wr,
+ sizeof(*gsi->outstanding_wrs),
+ GFP_KERNEL);
+ if (!gsi->outstanding_wrs) {
+ ret = -ENOMEM;
+ goto err_free_tx;
+ }
+
+ mutex_init(&gsi->mutex);
+
+ mutex_lock(&dev->devr.mutex);
+
+ if (dev->devr.ports[port_num - 1].gsi) {
+ mlx5_ib_warn(dev, "GSI QP already exists on port %d\n",
+ port_num);
+ ret = -EBUSY;
+ goto err_free_wrs;
+ }
+ gsi->num_qps = num_qps;
+ spin_lock_init(&gsi->lock);
+
+ gsi->cap = init_attr->cap;
+ gsi->sq_sig_type = init_attr->sq_sig_type;
+ gsi->ibqp.qp_num = 1;
+ gsi->port_num = port_num;
+
+ gsi->cq = ib_alloc_cq(pd->device, gsi, init_attr->cap.max_send_wr, 0,
+ IB_POLL_SOFTIRQ);
+ if (IS_ERR(gsi->cq)) {
+ mlx5_ib_warn(dev, "unable to create send CQ for GSI QP. error %ld\n",
+ PTR_ERR(gsi->cq));
+ ret = PTR_ERR(gsi->cq);
+ goto err_free_wrs;
+ }
+
+ hw_init_attr.qp_type = MLX5_IB_QPT_HW_GSI;
+ hw_init_attr.send_cq = gsi->cq;
+ if (num_qps) {
+ hw_init_attr.cap.max_send_wr = 0;
+ hw_init_attr.cap.max_send_sge = 0;
+ hw_init_attr.cap.max_inline_data = 0;
+ }
+ gsi->rx_qp = ib_create_qp(pd, &hw_init_attr);
+ if (IS_ERR(gsi->rx_qp)) {
+ mlx5_ib_warn(dev, "unable to create hardware GSI QP. error %ld\n",
+ PTR_ERR(gsi->rx_qp));
+ ret = PTR_ERR(gsi->rx_qp);
+ goto err_destroy_cq;
+ }
+
+ dev->devr.ports[init_attr->port_num - 1].gsi = gsi;
+
+ mutex_unlock(&dev->devr.mutex);
+
+ return &gsi->ibqp;
+
+err_destroy_cq:
+ ib_free_cq(gsi->cq);
+err_free_wrs:
+ mutex_unlock(&dev->devr.mutex);
+ kfree(gsi->outstanding_wrs);
+err_free_tx:
+ kfree(gsi->tx_qps);
+err_free:
+ kfree(gsi);
+ return ERR_PTR(ret);
+}
+
+int mlx5_ib_gsi_destroy_qp(struct ib_qp *qp)
+{
+ struct mlx5_ib_dev *dev = to_mdev(qp->device);
+ struct mlx5_ib_gsi_qp *gsi = gsi_qp(qp);
+ const int port_num = gsi->port_num;
+ int qp_index;
+ int ret;
+
+ mlx5_ib_dbg(dev, "destroying GSI QP\n");
+
+ mutex_lock(&dev->devr.mutex);
+ ret = ib_destroy_qp(gsi->rx_qp);
+ if (ret) {
+ mlx5_ib_warn(dev, "unable to destroy hardware GSI QP. error %d\n",
+ ret);
+ mutex_unlock(&dev->devr.mutex);
+ return ret;
+ }
+ dev->devr.ports[port_num - 1].gsi = NULL;
+ mutex_unlock(&dev->devr.mutex);
+ gsi->rx_qp = NULL;
+
+ for (qp_index = 0; qp_index < gsi->num_qps; ++qp_index) {
+ if (!gsi->tx_qps[qp_index])
+ continue;
+ WARN_ON_ONCE(ib_destroy_qp(gsi->tx_qps[qp_index]));
+ gsi->tx_qps[qp_index] = NULL;
+ }
+
+ ib_free_cq(gsi->cq);
+
+ kfree(gsi->outstanding_wrs);
+ kfree(gsi->tx_qps);
+ kfree(gsi);
+
+ return 0;
+}
+
+static struct ib_qp *create_gsi_ud_qp(struct mlx5_ib_gsi_qp *gsi)
+{
+ struct ib_pd *pd = gsi->rx_qp->pd;
+ struct ib_qp_init_attr init_attr = {
+ .event_handler = gsi->rx_qp->event_handler,
+ .qp_context = gsi->rx_qp->qp_context,
+ .send_cq = gsi->cq,
+ .recv_cq = gsi->rx_qp->recv_cq,
+ .cap = {
+ .max_send_wr = gsi->cap.max_send_wr,
+ .max_send_sge = gsi->cap.max_send_sge,
+ .max_inline_data = gsi->cap.max_inline_data,
+ },
+ .sq_sig_type = gsi->sq_sig_type,
+ .qp_type = IB_QPT_UD,
+ .create_flags = mlx5_ib_create_qp_sqpn_qp1(),
+ };
+
+ return ib_create_qp(pd, &init_attr);
+}
+
+static int modify_to_rts(struct mlx5_ib_gsi_qp *gsi, struct ib_qp *qp,
+ u16 qp_index)
+{
+ struct mlx5_ib_dev *dev = to_mdev(qp->device);
+ struct ib_qp_attr attr;
+ int mask;
+ int ret;
+
+ mask = IB_QP_STATE | IB_QP_PKEY_INDEX | IB_QP_QKEY | IB_QP_PORT;
+ attr.qp_state = IB_QPS_INIT;
+ attr.pkey_index = qp_index;
+ attr.qkey = IB_QP1_QKEY;
+ attr.port_num = gsi->port_num;
+ ret = ib_modify_qp(qp, &attr, mask);
+ if (ret) {
+ mlx5_ib_err(dev, "could not change QP%d state to INIT: %d\n",
+ qp->qp_num, ret);
+ return ret;
+ }
+
+ attr.qp_state = IB_QPS_RTR;
+ ret = ib_modify_qp(qp, &attr, IB_QP_STATE);
+ if (ret) {
+ mlx5_ib_err(dev, "could not change QP%d state to RTR: %d\n",
+ qp->qp_num, ret);
+ return ret;
+ }
+
+ attr.qp_state = IB_QPS_RTS;
+ attr.sq_psn = 0;
+ ret = ib_modify_qp(qp, &attr, IB_QP_STATE | IB_QP_SQ_PSN);
+ if (ret) {
+ mlx5_ib_err(dev, "could not change QP%d state to RTS: %d\n",
+ qp->qp_num, ret);
+ return ret;
+ }
+
+ return 0;
+}
+
+static void setup_qp(struct mlx5_ib_gsi_qp *gsi, u16 qp_index)
+{
+ struct ib_device *device = gsi->rx_qp->device;
+ struct mlx5_ib_dev *dev = to_mdev(device);
+ struct ib_qp *qp;
+ unsigned long flags;
+ u16 pkey;
+ int ret;
+
+ ret = ib_query_pkey(device, gsi->port_num, qp_index, &pkey);
+ if (ret) {
+ mlx5_ib_warn(dev, "unable to read P_Key at port %d, index %d\n",
+ gsi->port_num, qp_index);
+ return;
+ }
+
+ if (!pkey) {
+ mlx5_ib_dbg(dev, "invalid P_Key at port %d, index %d. Skipping.\n",
+ gsi->port_num, qp_index);
+ return;
+ }
+
+ spin_lock_irqsave(&gsi->lock, flags);
+ qp = gsi->tx_qps[qp_index];
+ spin_unlock_irqrestore(&gsi->lock, flags);
+ if (qp) {
+ mlx5_ib_dbg(dev, "already existing GSI TX QP at port %d, index %d. Skipping\n",
+ gsi->port_num, qp_index);
+ return;
+ }
+
+ qp = create_gsi_ud_qp(gsi);
+ if (IS_ERR(qp)) {
+ mlx5_ib_warn(dev, "unable to create hardware UD QP for GSI: %ld\n",
+ PTR_ERR(qp));
+ return;
+ }
+
+ ret = modify_to_rts(gsi, qp, qp_index);
+ if (ret)
+ goto err_destroy_qp;
+
+ spin_lock_irqsave(&gsi->lock, flags);
+ WARN_ON_ONCE(gsi->tx_qps[qp_index]);
+ gsi->tx_qps[qp_index] = qp;
+ spin_unlock_irqrestore(&gsi->lock, flags);
+
+ return;
+
+err_destroy_qp:
+ WARN_ON_ONCE(qp);
+}
+
+static void setup_qps(struct mlx5_ib_gsi_qp *gsi)
+{
+ u16 qp_index;
+
+ for (qp_index = 0; qp_index < gsi->num_qps; ++qp_index)
+ setup_qp(gsi, qp_index);
+}
+
+int mlx5_ib_gsi_modify_qp(struct ib_qp *qp, struct ib_qp_attr *attr,
+ int attr_mask)
+{
+ struct mlx5_ib_dev *dev = to_mdev(qp->device);
+ struct mlx5_ib_gsi_qp *gsi = gsi_qp(qp);
+ int ret;
+
+ mlx5_ib_dbg(dev, "modifying GSI QP to state %d\n", attr->qp_state);
+
+ mutex_lock(&gsi->mutex);
+ ret = ib_modify_qp(gsi->rx_qp, attr, attr_mask);
+ if (ret) {
+ mlx5_ib_warn(dev, "unable to modify GSI rx QP: %d\n", ret);
+ goto unlock;
+ }
+
+ if (to_mqp(gsi->rx_qp)->state == IB_QPS_RTS)
+ setup_qps(gsi);
+
+unlock:
+ mutex_unlock(&gsi->mutex);
+
+ return ret;
+}
+
+int mlx5_ib_gsi_query_qp(struct ib_qp *qp, struct ib_qp_attr *qp_attr,
+ int qp_attr_mask,
+ struct ib_qp_init_attr *qp_init_attr)
+{
+ struct mlx5_ib_gsi_qp *gsi = gsi_qp(qp);
+ int ret;
+
+ mutex_lock(&gsi->mutex);
+ ret = ib_query_qp(gsi->rx_qp, qp_attr, qp_attr_mask, qp_init_attr);
+ qp_init_attr->cap = gsi->cap;
+ mutex_unlock(&gsi->mutex);
+
+ return ret;
+}
+
+/* Call with gsi->lock locked */
+static int mlx5_ib_add_outstanding_wr(struct mlx5_ib_gsi_qp *gsi,
+ struct ib_ud_wr *wr, struct ib_wc *wc)
+{
+ struct mlx5_ib_dev *dev = to_mdev(gsi->rx_qp->device);
+ struct mlx5_ib_gsi_wr *gsi_wr;
+
+ if (gsi->outstanding_pi == gsi->outstanding_ci + gsi->cap.max_send_wr) {
+ mlx5_ib_warn(dev, "no available GSI work request.\n");
+ return -ENOMEM;
+ }
+
+ gsi_wr = &gsi->outstanding_wrs[gsi->outstanding_pi %
+ gsi->cap.max_send_wr];
+ gsi->outstanding_pi++;
+
+ if (!wc) {
+ memset(&gsi_wr->wc, 0, sizeof(gsi_wr->wc));
+ gsi_wr->wc.pkey_index = wr->pkey_index;
+ gsi_wr->wc.wr_id = wr->wr.wr_id;
+ } else {
+ gsi_wr->wc = *wc;
+ gsi_wr->completed = true;
+ }
+
+ gsi_wr->cqe.done = &handle_single_completion;
+ wr->wr.wr_cqe = &gsi_wr->cqe;
+
+ return 0;
+}
+
+/* Call with gsi->lock locked */
+static int mlx5_ib_gsi_silent_drop(struct mlx5_ib_gsi_qp *gsi,
+ struct ib_ud_wr *wr)
+{
+ struct ib_wc wc = {
+ { .wr_id = wr->wr.wr_id },
+ .status = IB_WC_SUCCESS,
+ .opcode = IB_WC_SEND,
+ .qp = &gsi->ibqp,
+ };
+ int ret;
+
+ ret = mlx5_ib_add_outstanding_wr(gsi, wr, &wc);
+ if (ret)
+ return ret;
+
+ generate_completions(gsi);
+
+ return 0;
+}
+
+/* Call with gsi->lock locked */
+static struct ib_qp *get_tx_qp(struct mlx5_ib_gsi_qp *gsi, struct ib_ud_wr *wr)
+{
+ struct mlx5_ib_dev *dev = to_mdev(gsi->rx_qp->device);
+ int qp_index = wr->pkey_index;
+
+ if (!mlx5_ib_deth_sqpn_cap(dev))
+ return gsi->rx_qp;
+
+ if (qp_index >= gsi->num_qps)
+ return NULL;
+
+ return gsi->tx_qps[qp_index];
+}
+
+int mlx5_ib_gsi_post_send(struct ib_qp *qp, struct ib_send_wr *wr,
+ struct ib_send_wr **bad_wr)
+{
+ struct mlx5_ib_gsi_qp *gsi = gsi_qp(qp);
+ struct ib_qp *tx_qp;
+ unsigned long flags;
+ int ret;
+
+ for (; wr; wr = wr->next) {
+ struct ib_ud_wr cur_wr = *ud_wr(wr);
+
+ cur_wr.wr.next = NULL;
+
+ spin_lock_irqsave(&gsi->lock, flags);
+ tx_qp = get_tx_qp(gsi, &cur_wr);
+ if (!tx_qp) {
+ ret = mlx5_ib_gsi_silent_drop(gsi, &cur_wr);
+ if (ret)
+ goto err;
+ spin_unlock_irqrestore(&gsi->lock, flags);
+ continue;
+ }
+
+ ret = mlx5_ib_add_outstanding_wr(gsi, &cur_wr, NULL);
+ if (ret)
+ goto err;
+
+ ret = ib_post_send(tx_qp, &cur_wr.wr, bad_wr);
+ if (ret) {
+ /* Undo the effect of adding the outstanding wr */
+ gsi->outstanding_pi = (gsi->outstanding_pi - 1) %
+ gsi->cap.max_send_wr;
+ goto err;
+ }
+ spin_unlock_irqrestore(&gsi->lock, flags);
+ }
+
+ return 0;
+
+err:
+ spin_unlock_irqrestore(&gsi->lock, flags);
+ *bad_wr = wr;
+ return ret;
+}
+
+int mlx5_ib_gsi_post_recv(struct ib_qp *qp, struct ib_recv_wr *wr,
+ struct ib_recv_wr **bad_wr)
+{
+ struct mlx5_ib_gsi_qp *gsi = gsi_qp(qp);
+
+ return ib_post_recv(gsi->rx_qp, wr, bad_wr);
+}
+
+void mlx5_ib_gsi_pkey_change(struct mlx5_ib_gsi_qp *gsi)
+{
+ if (!gsi)
+ return;
+
+ mutex_lock(&gsi->mutex);
+ setup_qps(gsi);
+ mutex_unlock(&gsi->mutex);
+}
diff --git a/sys/dev/mlx5/mlx5_ib/mlx5_ib_mad.c b/sys/dev/mlx5/mlx5_ib/mlx5_ib_mad.c
index bf0ca9a..719cdde 100644
--- a/sys/dev/mlx5/mlx5_ib/mlx5_ib_mad.c
+++ b/sys/dev/mlx5/mlx5_ib/mlx5_ib_mad.c
@@ -25,11 +25,11 @@
* $FreeBSD$
*/
+#include <dev/mlx5/vport.h>
#include <rdma/ib_mad.h>
#include <rdma/ib_smi.h>
#include <rdma/ib_pma.h>
#include "mlx5_ib.h"
-#include <dev/mlx5/vport.h>
enum {
MLX5_IB_VENDOR_CLASS1 = 0x9,
@@ -37,8 +37,8 @@ enum {
};
int mlx5_MAD_IFC(struct mlx5_ib_dev *dev, int ignore_mkey, int ignore_bkey,
- u8 port, struct ib_wc *in_wc, struct ib_grh *in_grh,
- void *in_mad, void *response_mad)
+ u8 port, const struct ib_wc *in_wc, const struct ib_grh *in_grh,
+ const void *in_mad, void *response_mad)
{
u8 op_modifier = 0;
@@ -54,8 +54,8 @@ int mlx5_MAD_IFC(struct mlx5_ib_dev *dev, int ignore_mkey, int ignore_bkey,
}
static int process_mad(struct ib_device *ibdev, int mad_flags, u8 port_num,
- struct ib_wc *in_wc, struct ib_grh *in_grh,
- struct ib_mad *in_mad, struct ib_mad *out_mad)
+ const struct ib_wc *in_wc, const struct ib_grh *in_grh,
+ const struct ib_mad *in_mad, struct ib_mad *out_mad)
{
u16 slid;
int err;
@@ -106,89 +106,148 @@ static int process_mad(struct ib_device *ibdev, int mad_flags, u8 port_num,
}
static void pma_cnt_ext_assign(struct ib_pma_portcounters_ext *pma_cnt_ext,
- struct mlx5_vport_counters *vc)
+ void *out)
{
- pma_cnt_ext->port_xmit_data = cpu_to_be64((vc->transmitted_ib_unicast.octets +
- vc->transmitted_ib_multicast.octets) >> 2);
- pma_cnt_ext->port_rcv_data = cpu_to_be64((vc->received_ib_unicast.octets +
- vc->received_ib_multicast.octets) >> 2);
- pma_cnt_ext->port_xmit_packets = cpu_to_be64(vc->transmitted_ib_unicast.packets +
- vc->transmitted_ib_multicast.packets);
- pma_cnt_ext->port_rcv_packets = cpu_to_be64(vc->received_ib_unicast.packets +
- vc->received_ib_multicast.packets);
- pma_cnt_ext->port_unicast_xmit_packets = cpu_to_be64(vc->transmitted_ib_unicast.packets);
- pma_cnt_ext->port_unicast_rcv_packets = cpu_to_be64(vc->received_ib_unicast.packets);
- pma_cnt_ext->port_multicast_xmit_packets = cpu_to_be64(vc->transmitted_ib_multicast.packets);
- pma_cnt_ext->port_multicast_rcv_packets = cpu_to_be64(vc->received_ib_multicast.packets);
+#define MLX5_SUM_CNT(p, cntr1, cntr2) \
+ (MLX5_GET64(query_vport_counter_out, p, cntr1) + \
+ MLX5_GET64(query_vport_counter_out, p, cntr2))
+
+ pma_cnt_ext->port_xmit_data =
+ cpu_to_be64(MLX5_SUM_CNT(out, transmitted_ib_unicast.octets,
+ transmitted_ib_multicast.octets) >> 2);
+ pma_cnt_ext->port_rcv_data =
+ cpu_to_be64(MLX5_SUM_CNT(out, received_ib_unicast.octets,
+ received_ib_multicast.octets) >> 2);
+ pma_cnt_ext->port_xmit_packets =
+ cpu_to_be64(MLX5_SUM_CNT(out, transmitted_ib_unicast.packets,
+ transmitted_ib_multicast.packets));
+ pma_cnt_ext->port_rcv_packets =
+ cpu_to_be64(MLX5_SUM_CNT(out, received_ib_unicast.packets,
+ received_ib_multicast.packets));
+ pma_cnt_ext->port_unicast_xmit_packets =
+ MLX5_GET64_BE(query_vport_counter_out,
+ out, transmitted_ib_unicast.packets);
+ pma_cnt_ext->port_unicast_rcv_packets =
+ MLX5_GET64_BE(query_vport_counter_out,
+ out, received_ib_unicast.packets);
+ pma_cnt_ext->port_multicast_xmit_packets =
+ MLX5_GET64_BE(query_vport_counter_out,
+ out, transmitted_ib_multicast.packets);
+ pma_cnt_ext->port_multicast_rcv_packets =
+ MLX5_GET64_BE(query_vport_counter_out,
+ out, received_ib_multicast.packets);
}
static void pma_cnt_assign(struct ib_pma_portcounters *pma_cnt,
- struct mlx5_vport_counters *vc)
+ void *out)
{
- ASSIGN_32BIT_COUNTER(pma_cnt->port_xmit_data,
- (vc->transmitted_ib_unicast.octets +
- vc->transmitted_ib_multicast.octets) >> 2);
- ASSIGN_32BIT_COUNTER(pma_cnt->port_rcv_data,
- (vc->received_ib_unicast.octets +
- vc->received_ib_multicast.octets) >> 2);
- ASSIGN_32BIT_COUNTER(pma_cnt->port_xmit_packets,
- vc->transmitted_ib_unicast.packets +
- vc->transmitted_ib_multicast.packets);
- ASSIGN_32BIT_COUNTER(pma_cnt->port_rcv_packets,
- vc->received_ib_unicast.packets +
- vc->received_ib_multicast.packets);
+ /* Traffic counters will be reported in
+ * their 64bit form via ib_pma_portcounters_ext by default.
+ */
+ void *out_pma = MLX5_ADDR_OF(ppcnt_reg, out,
+ counter_set);
+
+#define MLX5_ASSIGN_PMA_CNTR(counter_var, counter_name) { \
+ counter_var = MLX5_GET_BE(typeof(counter_var), \
+ ib_port_cntrs_grp_data_layout, \
+ out_pma, counter_name); \
+ }
+
+ MLX5_ASSIGN_PMA_CNTR(pma_cnt->symbol_error_counter,
+ symbol_error_counter);
+ MLX5_ASSIGN_PMA_CNTR(pma_cnt->link_error_recovery_counter,
+ link_error_recovery_counter);
+ MLX5_ASSIGN_PMA_CNTR(pma_cnt->link_downed_counter,
+ link_downed_counter);
+ MLX5_ASSIGN_PMA_CNTR(pma_cnt->port_rcv_errors,
+ port_rcv_errors);
+ MLX5_ASSIGN_PMA_CNTR(pma_cnt->port_rcv_remphys_errors,
+ port_rcv_remote_physical_errors);
+ MLX5_ASSIGN_PMA_CNTR(pma_cnt->port_rcv_switch_relay_errors,
+ port_rcv_switch_relay_errors);
+ MLX5_ASSIGN_PMA_CNTR(pma_cnt->port_xmit_discards,
+ port_xmit_discards);
+ MLX5_ASSIGN_PMA_CNTR(pma_cnt->port_xmit_constraint_errors,
+ port_xmit_constraint_errors);
+ MLX5_ASSIGN_PMA_CNTR(pma_cnt->port_rcv_constraint_errors,
+ port_rcv_constraint_errors);
+ MLX5_ASSIGN_PMA_CNTR(pma_cnt->link_overrun_errors,
+ link_overrun_errors);
+ MLX5_ASSIGN_PMA_CNTR(pma_cnt->vl15_dropped,
+ vl_15_dropped);
}
static int process_pma_cmd(struct ib_device *ibdev, u8 port_num,
- struct ib_mad *in_mad, struct ib_mad *out_mad)
+ const struct ib_mad *in_mad, struct ib_mad *out_mad)
{
struct mlx5_ib_dev *dev = to_mdev(ibdev);
- struct mlx5_vport_counters *vc;
int err;
- int ext;
-
- vc = kzalloc(sizeof(*vc), GFP_KERNEL);
- if (!vc)
- return -ENOMEM;
+ void *out_cnt;
- ext = in_mad->mad_hdr.attr_id == IB_PMA_PORT_COUNTERS_EXT;
+ /* Decalring support of extended counters */
+ if (in_mad->mad_hdr.attr_id == IB_PMA_CLASS_PORT_INFO) {
+ struct ib_class_port_info cpi = {};
- err = mlx5_get_vport_counters(dev->mdev, port_num, vc);
- if (!err) {
- if (ext) {
- struct ib_pma_portcounters_ext *pma_cnt_ext =
- (struct ib_pma_portcounters_ext *)(out_mad->data + 40);
+ cpi.capability_mask = IB_PMA_CLASS_CAP_EXT_WIDTH;
+ memcpy((out_mad->data + 40), &cpi, sizeof(cpi));
+ return IB_MAD_RESULT_SUCCESS | IB_MAD_RESULT_REPLY;
+ }
- pma_cnt_ext_assign(pma_cnt_ext, vc);
- } else {
- struct ib_pma_portcounters *pma_cnt =
- (struct ib_pma_portcounters *)(out_mad->data + 40);
+ if (in_mad->mad_hdr.attr_id == IB_PMA_PORT_COUNTERS_EXT) {
+ struct ib_pma_portcounters_ext *pma_cnt_ext =
+ (struct ib_pma_portcounters_ext *)(out_mad->data + 40);
+ int sz = MLX5_ST_SZ_BYTES(query_vport_counter_out);
- ASSIGN_16BIT_COUNTER(pma_cnt->port_rcv_errors,
- (u16)vc->received_errors.packets);
+ out_cnt = mlx5_vzalloc(sz);
+ if (!out_cnt)
+ return IB_MAD_RESULT_FAILURE;
- pma_cnt_assign(pma_cnt, vc);
+ err = mlx5_core_query_vport_counter(dev->mdev, 0, 0,
+ port_num, out_cnt, sz);
+ if (!err)
+ pma_cnt_ext_assign(pma_cnt_ext, out_cnt);
+ } else {
+ struct ib_pma_portcounters *pma_cnt =
+ (struct ib_pma_portcounters *)(out_mad->data + 40);
+ int sz = MLX5_ST_SZ_BYTES(ppcnt_reg);
+
+ out_cnt = mlx5_vzalloc(sz);
+ if (!out_cnt)
+ return IB_MAD_RESULT_FAILURE;
+
+ err = mlx5_core_query_ib_ppcnt(dev->mdev, port_num,
+ out_cnt, sz);
+ if (!err)
+ pma_cnt_assign(pma_cnt, out_cnt);
}
- err = IB_MAD_RESULT_SUCCESS | IB_MAD_RESULT_REPLY;
- }
- kfree(vc);
- return err;
+ kvfree(out_cnt);
+ if (err)
+ return IB_MAD_RESULT_FAILURE;
+
+ return IB_MAD_RESULT_SUCCESS | IB_MAD_RESULT_REPLY;
}
int mlx5_ib_process_mad(struct ib_device *ibdev, int mad_flags, u8 port_num,
- struct ib_wc *in_wc, struct ib_grh *in_grh,
- struct ib_mad *in_mad, struct ib_mad *out_mad)
+ const struct ib_wc *in_wc, const struct ib_grh *in_grh,
+ const struct ib_mad_hdr *in, size_t in_mad_size,
+ struct ib_mad_hdr *out, size_t *out_mad_size,
+ u16 *out_mad_pkey_index)
{
struct mlx5_ib_dev *dev = to_mdev(ibdev);
struct mlx5_core_dev *mdev = dev->mdev;
+ const struct ib_mad *in_mad = (const struct ib_mad *)in;
+ struct ib_mad *out_mad = (struct ib_mad *)out;
+
+ if (WARN_ON_ONCE(in_mad_size != sizeof(*in_mad) ||
+ *out_mad_size != sizeof(*out_mad)))
+ return IB_MAD_RESULT_FAILURE;
memset(out_mad->data, 0, sizeof(out_mad->data));
if (MLX5_CAP_GEN(mdev, vport_counters) &&
in_mad->mad_hdr.mgmt_class == IB_MGMT_CLASS_PERF_MGMT &&
in_mad->mad_hdr.method == IB_MGMT_METHOD_GET) {
- /* TBD: read error counters from the PPCNT */
return process_pma_cmd(ibdev, port_num, in_mad, out_mad);
} else {
return process_mad(ibdev, mad_flags, port_num, in_wc, in_grh,
@@ -225,7 +284,7 @@ out:
return err;
}
-int mlx5_query_smp_attr_node_info_mad_ifc(struct ib_device *ibdev,
+int mlx5_query_mad_ifc_smp_attr_node_info(struct ib_device *ibdev,
struct ib_smp *out_mad)
{
struct ib_smp *in_mad = NULL;
@@ -245,7 +304,7 @@ int mlx5_query_smp_attr_node_info_mad_ifc(struct ib_device *ibdev,
return err;
}
-int mlx5_query_system_image_guid_mad_ifc(struct ib_device *ibdev,
+int mlx5_query_mad_ifc_system_image_guid(struct ib_device *ibdev,
__be64 *sys_image_guid)
{
struct ib_smp *out_mad = NULL;
@@ -255,7 +314,7 @@ int mlx5_query_system_image_guid_mad_ifc(struct ib_device *ibdev,
if (!out_mad)
return -ENOMEM;
- err = mlx5_query_smp_attr_node_info_mad_ifc(ibdev, out_mad);
+ err = mlx5_query_mad_ifc_smp_attr_node_info(ibdev, out_mad);
if (err)
goto out;
@@ -267,7 +326,7 @@ out:
return err;
}
-int mlx5_query_max_pkeys_mad_ifc(struct ib_device *ibdev,
+int mlx5_query_mad_ifc_max_pkeys(struct ib_device *ibdev,
u16 *max_pkeys)
{
struct ib_smp *out_mad = NULL;
@@ -277,7 +336,7 @@ int mlx5_query_max_pkeys_mad_ifc(struct ib_device *ibdev,
if (!out_mad)
return -ENOMEM;
- err = mlx5_query_smp_attr_node_info_mad_ifc(ibdev, out_mad);
+ err = mlx5_query_mad_ifc_smp_attr_node_info(ibdev, out_mad);
if (err)
goto out;
@@ -289,7 +348,7 @@ out:
return err;
}
-int mlx5_query_vendor_id_mad_ifc(struct ib_device *ibdev,
+int mlx5_query_mad_ifc_vendor_id(struct ib_device *ibdev,
u32 *vendor_id)
{
struct ib_smp *out_mad = NULL;
@@ -299,7 +358,7 @@ int mlx5_query_vendor_id_mad_ifc(struct ib_device *ibdev,
if (!out_mad)
return -ENOMEM;
- err = mlx5_query_smp_attr_node_info_mad_ifc(ibdev, out_mad);
+ err = mlx5_query_mad_ifc_smp_attr_node_info(ibdev, out_mad);
if (err)
goto out;
@@ -311,7 +370,7 @@ out:
return err;
}
-int mlx5_query_node_desc_mad_ifc(struct mlx5_ib_dev *dev, char *node_desc)
+int mlx5_query_mad_ifc_node_desc(struct mlx5_ib_dev *dev, char *node_desc)
{
struct ib_smp *in_mad = NULL;
struct ib_smp *out_mad = NULL;
@@ -329,14 +388,14 @@ int mlx5_query_node_desc_mad_ifc(struct mlx5_ib_dev *dev, char *node_desc)
if (err)
goto out;
- memcpy(node_desc, out_mad->data, 64);
+ memcpy(node_desc, out_mad->data, IB_DEVICE_NODE_DESC_MAX);
out:
kfree(in_mad);
kfree(out_mad);
return err;
}
-int mlx5_query_node_guid_mad_ifc(struct mlx5_ib_dev *dev, u64 *node_guid)
+int mlx5_query_mad_ifc_node_guid(struct mlx5_ib_dev *dev, __be64 *node_guid)
{
struct ib_smp *in_mad = NULL;
struct ib_smp *out_mad = NULL;
@@ -354,14 +413,14 @@ int mlx5_query_node_guid_mad_ifc(struct mlx5_ib_dev *dev, u64 *node_guid)
if (err)
goto out;
- memcpy(&dev->ib_dev.node_guid, out_mad->data + 12, 8);
+ memcpy(node_guid, out_mad->data + 12, 8);
out:
kfree(in_mad);
kfree(out_mad);
return err;
}
-int mlx5_query_pkey_mad_ifc(struct ib_device *ibdev, u8 port, u16 index,
+int mlx5_query_mad_ifc_pkey(struct ib_device *ibdev, u8 port, u16 index,
u16 *pkey)
{
struct ib_smp *in_mad = NULL;
@@ -390,7 +449,7 @@ out:
return err;
}
-int mlx5_query_gids_mad_ifc(struct ib_device *ibdev, u8 port, int index,
+int mlx5_query_mad_ifc_gids(struct ib_device *ibdev, u8 port, int index,
union ib_gid *gid)
{
struct ib_smp *in_mad = NULL;
@@ -430,7 +489,7 @@ out:
return err;
}
-int mlx5_query_port_mad_ifc(struct ib_device *ibdev, u8 port,
+int mlx5_query_mad_ifc_port(struct ib_device *ibdev, u8 port,
struct ib_port_attr *props)
{
struct mlx5_ib_dev *dev = to_mdev(ibdev);
diff --git a/sys/dev/mlx5/mlx5_ib/mlx5_ib_main.c b/sys/dev/mlx5/mlx5_ib/mlx5_ib_main.c
index 7f7d344..13a255c 100644
--- a/sys/dev/mlx5/mlx5_ib/mlx5_ib_main.c
+++ b/sys/dev/mlx5/mlx5_ib/mlx5_ib_main.c
@@ -25,36 +25,35 @@
* $FreeBSD$
*/
+#include <linux/module.h>
#include <linux/errno.h>
#include <linux/pci.h>
#include <linux/dma-mapping.h>
#include <linux/slab.h>
-#include <linux/io-mapping.h>
+#if defined(CONFIG_X86)
+#include <asm/pat.h>
+#endif
#include <linux/sched.h>
-#include <linux/netdevice.h>
-#include <linux/etherdevice.h>
-#include <linux/list.h>
-#include <dev/mlx5/driver.h>
-#include <dev/mlx5/port.h>
-#include <dev/mlx5/vport.h>
-#include <asm/pgtable.h>
+#include <linux/delay.h>
#include <linux/fs.h>
#undef inode
-
#include <rdma/ib_user_verbs.h>
+#include <rdma/ib_addr.h>
+#include <rdma/ib_cache.h>
+#include <dev/mlx5/port.h>
+#include <dev/mlx5/vport.h>
+#include <linux/list.h>
#include <rdma/ib_smi.h>
#include <rdma/ib_umem.h>
-#include "user.h"
+#include <linux/in.h>
+#include <linux/etherdevice.h>
+#include <dev/mlx5/fs.h>
#include "mlx5_ib.h"
-#include <sys/unistd.h>
-#include <sys/kthread.h>
-
#define DRIVER_NAME "mlx5_ib"
-#define DRIVER_VERSION "3.2-rc1"
-#define DRIVER_RELDATE "May 2016"
+#define DRIVER_VERSION "3.4.1-BETA"
+#define DRIVER_RELDATE "October 2017"
-MODULE_AUTHOR("Eli Cohen <eli@mellanox.com>");
MODULE_DESCRIPTION("Mellanox Connect-IB HCA IB driver");
MODULE_LICENSE("Dual BSD/GPL");
MODULE_DEPEND(mlx5ib, linuxkpi, 1, 1, 1);
@@ -66,73 +65,258 @@ static int deprecated_prof_sel = 2;
module_param_named(prof_sel, deprecated_prof_sel, int, 0444);
MODULE_PARM_DESC(prof_sel, "profile selector. Deprecated here. Moved to module mlx5_core");
+static char mlx5_version[] =
+ DRIVER_NAME ": Mellanox Connect-IB Infiniband driver v"
+ DRIVER_VERSION " (" DRIVER_RELDATE ")\n";
+
enum {
- MLX5_STANDARD_ATOMIC_SIZE = 0x8,
+ MLX5_ATOMIC_SIZE_QP_8BYTES = 1 << 3,
};
-struct workqueue_struct *mlx5_ib_wq;
+static enum rdma_link_layer
+mlx5_port_type_cap_to_rdma_ll(int port_type_cap)
+{
+ switch (port_type_cap) {
+ case MLX5_CAP_PORT_TYPE_IB:
+ return IB_LINK_LAYER_INFINIBAND;
+ case MLX5_CAP_PORT_TYPE_ETH:
+ return IB_LINK_LAYER_ETHERNET;
+ default:
+ return IB_LINK_LAYER_UNSPECIFIED;
+ }
+}
+
+static enum rdma_link_layer
+mlx5_ib_port_link_layer(struct ib_device *device, u8 port_num)
+{
+ struct mlx5_ib_dev *dev = to_mdev(device);
+ int port_type_cap = MLX5_CAP_GEN(dev->mdev, port_type);
-static char mlx5_version[] =
- DRIVER_NAME ": Mellanox Connect-IB Infiniband driver v"
- DRIVER_VERSION " (" DRIVER_RELDATE ")\n";
+ return mlx5_port_type_cap_to_rdma_ll(port_type_cap);
+}
-static void get_atomic_caps(struct mlx5_ib_dev *dev,
- struct ib_device_attr *props)
+static bool mlx5_netdev_match(struct net_device *ndev,
+ struct mlx5_core_dev *mdev,
+ const char *dname)
{
- int tmp;
- u8 atomic_operations;
- u8 atomic_size_qp;
- u8 atomic_req_endianess;
+ return ndev->if_type == IFT_ETHER &&
+ ndev->if_dname != NULL &&
+ strcmp(ndev->if_dname, dname) == 0 &&
+ ndev->if_softc != NULL &&
+ *(struct mlx5_core_dev **)ndev->if_softc == mdev;
+}
- atomic_operations = MLX5_CAP_ATOMIC(dev->mdev, atomic_operations);
- atomic_size_qp = MLX5_CAP_ATOMIC(dev->mdev, atomic_size_qp);
- atomic_req_endianess = MLX5_CAP_ATOMIC(dev->mdev,
- atomic_req_8B_endianess_mode) ||
- !mlx5_host_is_le();
+static int mlx5_netdev_event(struct notifier_block *this,
+ unsigned long event, void *ptr)
+{
+ struct net_device *ndev = netdev_notifier_info_to_dev(ptr);
+ struct mlx5_ib_dev *ibdev = container_of(this, struct mlx5_ib_dev,
+ roce.nb);
- tmp = MLX5_ATOMIC_OPS_CMP_SWAP | MLX5_ATOMIC_OPS_FETCH_ADD;
- if (((atomic_operations & tmp) == tmp)
- && (atomic_size_qp & 8)) {
- if (atomic_req_endianess) {
- props->atomic_cap = IB_ATOMIC_HCA;
- } else {
- props->atomic_cap = IB_ATOMIC_NONE;
+ switch (event) {
+ case NETDEV_REGISTER:
+ case NETDEV_UNREGISTER:
+ write_lock(&ibdev->roce.netdev_lock);
+ /* check if network interface belongs to mlx5en */
+ if (mlx5_netdev_match(ndev, ibdev->mdev, "mce"))
+ ibdev->roce.netdev = (event == NETDEV_UNREGISTER) ?
+ NULL : ndev;
+ write_unlock(&ibdev->roce.netdev_lock);
+ break;
+
+ case NETDEV_UP:
+ case NETDEV_DOWN: {
+ struct net_device *upper = NULL;
+
+ if ((upper == ndev || (!upper && ndev == ibdev->roce.netdev))
+ && ibdev->ib_active) {
+ struct ib_event ibev = {0};
+
+ ibev.device = &ibdev->ib_dev;
+ ibev.event = (event == NETDEV_UP) ?
+ IB_EVENT_PORT_ACTIVE : IB_EVENT_PORT_ERR;
+ ibev.element.port_num = 1;
+ ib_dispatch_event(&ibev);
}
- } else {
- props->atomic_cap = IB_ATOMIC_NONE;
+ break;
}
- tmp = MLX5_ATOMIC_OPS_MASKED_CMP_SWAP | MLX5_ATOMIC_OPS_MASKED_FETCH_ADD;
- if (((atomic_operations & tmp) == tmp)
- &&(atomic_size_qp & 8)) {
- if (atomic_req_endianess)
- props->masked_atomic_cap = IB_ATOMIC_HCA;
- else {
- props->masked_atomic_cap = IB_ATOMIC_NONE;
- }
- } else {
- props->masked_atomic_cap = IB_ATOMIC_NONE;
+ default:
+ break;
}
+
+ return NOTIFY_DONE;
}
-static enum rdma_link_layer
-mlx5_ib_port_link_layer(struct ib_device *device, u8 port_num)
+static struct net_device *mlx5_ib_get_netdev(struct ib_device *device,
+ u8 port_num)
+{
+ struct mlx5_ib_dev *ibdev = to_mdev(device);
+ struct net_device *ndev;
+
+ /* Ensure ndev does not disappear before we invoke dev_hold()
+ */
+ read_lock(&ibdev->roce.netdev_lock);
+ ndev = ibdev->roce.netdev;
+ if (ndev)
+ dev_hold(ndev);
+ read_unlock(&ibdev->roce.netdev_lock);
+
+ return ndev;
+}
+
+static int mlx5_query_port_roce(struct ib_device *device, u8 port_num,
+ struct ib_port_attr *props)
{
struct mlx5_ib_dev *dev = to_mdev(device);
+ struct net_device *ndev;
+ enum ib_mtu ndev_ib_mtu;
+ u16 qkey_viol_cntr;
+
+ memset(props, 0, sizeof(*props));
+
+ props->port_cap_flags |= IB_PORT_CM_SUP;
+ props->port_cap_flags |= IB_PORT_IP_BASED_GIDS;
+
+ props->gid_tbl_len = MLX5_CAP_ROCE(dev->mdev,
+ roce_address_table_size);
+ props->max_mtu = IB_MTU_4096;
+ props->max_msg_sz = 1 << MLX5_CAP_GEN(dev->mdev, log_max_msg);
+ props->pkey_tbl_len = 1;
+ props->state = IB_PORT_DOWN;
+ props->phys_state = 3;
+
+ mlx5_query_nic_vport_qkey_viol_cntr(dev->mdev, &qkey_viol_cntr);
+ props->qkey_viol_cntr = qkey_viol_cntr;
+
+ ndev = mlx5_ib_get_netdev(device, port_num);
+ if (!ndev)
+ return 0;
+
+ if (netif_running(ndev) && netif_carrier_ok(ndev)) {
+ props->state = IB_PORT_ACTIVE;
+ props->phys_state = 5;
+ }
+
+ ndev_ib_mtu = iboe_get_mtu(ndev->if_mtu);
+
+ dev_put(ndev);
+
+ props->active_mtu = min(props->max_mtu, ndev_ib_mtu);
+
+ props->active_width = IB_WIDTH_4X; /* TODO */
+ props->active_speed = IB_SPEED_QDR; /* TODO */
+
+ return 0;
+}
+
+static void ib_gid_to_mlx5_roce_addr(const union ib_gid *gid,
+ const struct ib_gid_attr *attr,
+ void *mlx5_addr)
+{
+#define MLX5_SET_RA(p, f, v) MLX5_SET(roce_addr_layout, p, f, v)
+ char *mlx5_addr_l3_addr = MLX5_ADDR_OF(roce_addr_layout, mlx5_addr,
+ source_l3_address);
+ void *mlx5_addr_mac = MLX5_ADDR_OF(roce_addr_layout, mlx5_addr,
+ source_mac_47_32);
+
+ if (!gid)
+ return;
+ ether_addr_copy(mlx5_addr_mac, IF_LLADDR(attr->ndev));
+
+ if (is_vlan_dev(attr->ndev)) {
+ MLX5_SET_RA(mlx5_addr, vlan_valid, 1);
+ MLX5_SET_RA(mlx5_addr, vlan_id, vlan_dev_vlan_id(attr->ndev));
+ }
+
+ switch (attr->gid_type) {
+ case IB_GID_TYPE_IB:
+ MLX5_SET_RA(mlx5_addr, roce_version, MLX5_ROCE_VERSION_1);
+ break;
+ case IB_GID_TYPE_ROCE_UDP_ENCAP:
+ MLX5_SET_RA(mlx5_addr, roce_version, MLX5_ROCE_VERSION_2);
+ break;
- switch (MLX5_CAP_GEN(dev->mdev, port_type)) {
- case MLX5_CAP_PORT_TYPE_IB:
- return IB_LINK_LAYER_INFINIBAND;
- case MLX5_CAP_PORT_TYPE_ETH:
- return IB_LINK_LAYER_ETHERNET;
default:
- return IB_LINK_LAYER_UNSPECIFIED;
+ WARN_ON(true);
+ }
+
+ if (attr->gid_type != IB_GID_TYPE_IB) {
+ if (ipv6_addr_v4mapped((void *)gid))
+ MLX5_SET_RA(mlx5_addr, roce_l3_type,
+ MLX5_ROCE_L3_TYPE_IPV4);
+ else
+ MLX5_SET_RA(mlx5_addr, roce_l3_type,
+ MLX5_ROCE_L3_TYPE_IPV6);
}
+
+ if ((attr->gid_type == IB_GID_TYPE_IB) ||
+ !ipv6_addr_v4mapped((void *)gid))
+ memcpy(mlx5_addr_l3_addr, gid, sizeof(*gid));
+ else
+ memcpy(&mlx5_addr_l3_addr[12], &gid->raw[12], 4);
+}
+
+static int set_roce_addr(struct ib_device *device, u8 port_num,
+ unsigned int index,
+ const union ib_gid *gid,
+ const struct ib_gid_attr *attr)
+{
+ struct mlx5_ib_dev *dev = to_mdev(device);
+ u32 in[MLX5_ST_SZ_DW(set_roce_address_in)] = {0};
+ u32 out[MLX5_ST_SZ_DW(set_roce_address_out)] = {0};
+ void *in_addr = MLX5_ADDR_OF(set_roce_address_in, in, roce_address);
+ enum rdma_link_layer ll = mlx5_ib_port_link_layer(device, port_num);
+
+ if (ll != IB_LINK_LAYER_ETHERNET)
+ return -EINVAL;
+
+ ib_gid_to_mlx5_roce_addr(gid, attr, in_addr);
+
+ MLX5_SET(set_roce_address_in, in, roce_address_index, index);
+ MLX5_SET(set_roce_address_in, in, opcode, MLX5_CMD_OP_SET_ROCE_ADDRESS);
+ return mlx5_cmd_exec(dev->mdev, in, sizeof(in), out, sizeof(out));
+}
+
+static int mlx5_ib_add_gid(struct ib_device *device, u8 port_num,
+ unsigned int index, const union ib_gid *gid,
+ const struct ib_gid_attr *attr,
+ __always_unused void **context)
+{
+ return set_roce_addr(device, port_num, index, gid, attr);
+}
+
+static int mlx5_ib_del_gid(struct ib_device *device, u8 port_num,
+ unsigned int index, __always_unused void **context)
+{
+ return set_roce_addr(device, port_num, index, NULL, NULL);
+}
+
+__be16 mlx5_get_roce_udp_sport(struct mlx5_ib_dev *dev, u8 port_num,
+ int index)
+{
+ struct ib_gid_attr attr;
+ union ib_gid gid;
+
+ if (ib_get_cached_gid(&dev->ib_dev, port_num, index, &gid, &attr))
+ return 0;
+
+ if (!attr.ndev)
+ return 0;
+
+ dev_put(attr.ndev);
+
+ if (attr.gid_type != IB_GID_TYPE_ROCE_UDP_ENCAP)
+ return 0;
+
+ return cpu_to_be16(MLX5_CAP_ROCE(dev->mdev, r_roce_min_src_udp_port));
}
static int mlx5_use_mad_ifc(struct mlx5_ib_dev *dev)
{
- return !dev->mdev->issi;
+ if (MLX5_CAP_GEN(dev->mdev, port_type) == MLX5_CAP_PORT_TYPE_IB)
+ return !MLX5_CAP_GEN(dev->mdev, ib_virt);
+ return 0;
}
enum {
@@ -153,6 +337,28 @@ static int mlx5_get_vport_access_method(struct ib_device *ibdev)
return MLX5_VPORT_ACCESS_METHOD_HCA;
}
+static void get_atomic_caps(struct mlx5_ib_dev *dev,
+ struct ib_device_attr *props)
+{
+ u8 tmp;
+ u8 atomic_operations = MLX5_CAP_ATOMIC(dev->mdev, atomic_operations);
+ u8 atomic_size_qp = MLX5_CAP_ATOMIC(dev->mdev, atomic_size_qp);
+ u8 atomic_req_8B_endianness_mode =
+ MLX5_CAP_ATOMIC(dev->mdev, atomic_req_8B_endianess_mode);
+
+ /* Check if HW supports 8 bytes standard atomic operations and capable
+ * of host endianness respond
+ */
+ tmp = MLX5_ATOMIC_OPS_CMP_SWAP | MLX5_ATOMIC_OPS_FETCH_ADD;
+ if (((atomic_operations & tmp) == tmp) &&
+ (atomic_size_qp & MLX5_ATOMIC_SIZE_QP_8BYTES) &&
+ (atomic_req_8B_endianness_mode)) {
+ props->atomic_cap = IB_ATOMIC_HCA;
+ } else {
+ props->atomic_cap = IB_ATOMIC_NONE;
+ }
+}
+
static int mlx5_query_system_image_guid(struct ib_device *ibdev,
__be64 *sys_image_guid)
{
@@ -163,24 +369,26 @@ static int mlx5_query_system_image_guid(struct ib_device *ibdev,
switch (mlx5_get_vport_access_method(ibdev)) {
case MLX5_VPORT_ACCESS_METHOD_MAD:
- return mlx5_query_system_image_guid_mad_ifc(ibdev,
+ return mlx5_query_mad_ifc_system_image_guid(ibdev,
sys_image_guid);
case MLX5_VPORT_ACCESS_METHOD_HCA:
err = mlx5_query_hca_vport_system_image_guid(mdev, &tmp);
- if (!err)
- *sys_image_guid = cpu_to_be64(tmp);
- return err;
+ break;
case MLX5_VPORT_ACCESS_METHOD_NIC:
err = mlx5_query_nic_vport_system_image_guid(mdev, &tmp);
- if (!err)
- *sys_image_guid = cpu_to_be64(tmp);
- return err;
+ break;
default:
return -EINVAL;
}
+
+ if (!err)
+ *sys_image_guid = cpu_to_be64(tmp);
+
+ return err;
+
}
static int mlx5_query_max_pkeys(struct ib_device *ibdev,
@@ -191,7 +399,7 @@ static int mlx5_query_max_pkeys(struct ib_device *ibdev,
switch (mlx5_get_vport_access_method(ibdev)) {
case MLX5_VPORT_ACCESS_METHOD_MAD:
- return mlx5_query_max_pkeys_mad_ifc(ibdev, max_pkeys);
+ return mlx5_query_mad_ifc_max_pkeys(ibdev, max_pkeys);
case MLX5_VPORT_ACCESS_METHOD_HCA:
case MLX5_VPORT_ACCESS_METHOD_NIC:
@@ -211,7 +419,7 @@ static int mlx5_query_vendor_id(struct ib_device *ibdev,
switch (mlx5_get_vport_access_method(ibdev)) {
case MLX5_VPORT_ACCESS_METHOD_MAD:
- return mlx5_query_vendor_id_mad_ifc(ibdev, vendor_id);
+ return mlx5_query_mad_ifc_vendor_id(ibdev, vendor_id);
case MLX5_VPORT_ACCESS_METHOD_HCA:
case MLX5_VPORT_ACCESS_METHOD_NIC:
@@ -230,27 +438,28 @@ static int mlx5_query_node_guid(struct mlx5_ib_dev *dev,
switch (mlx5_get_vport_access_method(&dev->ib_dev)) {
case MLX5_VPORT_ACCESS_METHOD_MAD:
- return mlx5_query_node_guid_mad_ifc(dev, node_guid);
+ return mlx5_query_mad_ifc_node_guid(dev, node_guid);
case MLX5_VPORT_ACCESS_METHOD_HCA:
err = mlx5_query_hca_vport_node_guid(dev->mdev, &tmp);
- if (!err)
- *node_guid = cpu_to_be64(tmp);
- return err;
+ break;
case MLX5_VPORT_ACCESS_METHOD_NIC:
err = mlx5_query_nic_vport_node_guid(dev->mdev, &tmp);
- if (!err)
- *node_guid = cpu_to_be64(tmp);
- return err;
+ break;
default:
return -EINVAL;
}
+
+ if (!err)
+ *node_guid = cpu_to_be64(tmp);
+
+ return err;
}
struct mlx5_reg_node_desc {
- u8 desc[64];
+ u8 desc[IB_DEVICE_NODE_DESC_MAX];
};
static int mlx5_query_node_desc(struct mlx5_ib_dev *dev, char *node_desc)
@@ -258,7 +467,7 @@ static int mlx5_query_node_desc(struct mlx5_ib_dev *dev, char *node_desc)
struct mlx5_reg_node_desc in;
if (mlx5_use_mad_ifc(dev))
- return mlx5_query_node_desc_mad_ifc(dev, node_desc);
+ return mlx5_query_mad_ifc_node_desc(dev, node_desc);
memset(&in, 0, sizeof(in));
@@ -268,18 +477,29 @@ static int mlx5_query_node_desc(struct mlx5_ib_dev *dev, char *node_desc)
}
static int mlx5_ib_query_device(struct ib_device *ibdev,
- struct ib_device_attr *props)
+ struct ib_device_attr *props,
+ struct ib_udata *uhw)
{
struct mlx5_ib_dev *dev = to_mdev(ibdev);
struct mlx5_core_dev *mdev = dev->mdev;
- int max_sq_desc;
+ int err = -ENOMEM;
int max_rq_sg;
int max_sq_sg;
- int err;
+ u64 min_page_size = 1ull << MLX5_CAP_GEN(mdev, log_pg_sz);
+ struct mlx5_ib_query_device_resp resp = {};
+ size_t resp_len;
+ u64 max_tso;
+ resp_len = sizeof(resp.comp_mask) + sizeof(resp.response_length);
+ if (uhw->outlen && uhw->outlen < resp_len)
+ return -EINVAL;
+ else
+ resp.response_length = resp_len;
- memset(props, 0, sizeof(*props));
+ if (uhw->inlen && !ib_is_udata_cleared(uhw, 0, uhw->inlen))
+ return -EINVAL;
+ memset(props, 0, sizeof(*props));
err = mlx5_query_system_image_guid(ibdev,
&props->sys_image_guid);
if (err)
@@ -294,7 +514,7 @@ static int mlx5_ib_query_device(struct ib_device *ibdev,
return err;
props->fw_ver = ((u64)fw_rev_maj(dev->mdev) << 32) |
- ((u64)fw_rev_min(dev->mdev) << 16) |
+ (fw_rev_min(dev->mdev) << 16) |
fw_rev_sub(dev->mdev);
props->device_cap_flags = IB_DEVICE_CHANGE_PHY_PORT |
IB_DEVICE_PORT_ACTIVE_EVENT |
@@ -307,27 +527,89 @@ static int mlx5_ib_query_device(struct ib_device *ibdev,
props->device_cap_flags |= IB_DEVICE_BAD_QKEY_CNTR;
if (MLX5_CAP_GEN(mdev, apm))
props->device_cap_flags |= IB_DEVICE_AUTO_PATH_MIG;
- props->device_cap_flags |= IB_DEVICE_LOCAL_DMA_LKEY;
if (MLX5_CAP_GEN(mdev, xrc))
props->device_cap_flags |= IB_DEVICE_XRC;
+ if (MLX5_CAP_GEN(mdev, imaicl)) {
+ props->device_cap_flags |= IB_DEVICE_MEM_WINDOW |
+ IB_DEVICE_MEM_WINDOW_TYPE_2B;
+ props->max_mw = 1 << MLX5_CAP_GEN(mdev, log_max_mkey);
+ /* We support 'Gappy' memory registration too */
+ props->device_cap_flags |= IB_DEVICE_SG_GAPS_REG;
+ }
props->device_cap_flags |= IB_DEVICE_MEM_MGT_EXTENSIONS;
+ if (MLX5_CAP_GEN(mdev, sho)) {
+ props->device_cap_flags |= IB_DEVICE_SIGNATURE_HANDOVER;
+ /* At this stage no support for signature handover */
+ props->sig_prot_cap = IB_PROT_T10DIF_TYPE_1 |
+ IB_PROT_T10DIF_TYPE_2 |
+ IB_PROT_T10DIF_TYPE_3;
+ props->sig_guard_cap = IB_GUARD_T10DIF_CRC |
+ IB_GUARD_T10DIF_CSUM;
+ }
if (MLX5_CAP_GEN(mdev, block_lb_mc))
props->device_cap_flags |= IB_DEVICE_BLOCK_MULTICAST_LOOPBACK;
+ if (MLX5_CAP_GEN(dev->mdev, eth_net_offloads)) {
+ if (MLX5_CAP_ETH(mdev, csum_cap))
+ props->device_cap_flags |= IB_DEVICE_RAW_IP_CSUM;
+
+ if (field_avail(typeof(resp), tso_caps, uhw->outlen)) {
+ max_tso = MLX5_CAP_ETH(mdev, max_lso_cap);
+ if (max_tso) {
+ resp.tso_caps.max_tso = 1 << max_tso;
+ resp.tso_caps.supported_qpts |=
+ 1 << IB_QPT_RAW_PACKET;
+ resp.response_length += sizeof(resp.tso_caps);
+ }
+ }
+
+ if (field_avail(typeof(resp), rss_caps, uhw->outlen)) {
+ resp.rss_caps.rx_hash_function =
+ MLX5_RX_HASH_FUNC_TOEPLITZ;
+ resp.rss_caps.rx_hash_fields_mask =
+ MLX5_RX_HASH_SRC_IPV4 |
+ MLX5_RX_HASH_DST_IPV4 |
+ MLX5_RX_HASH_SRC_IPV6 |
+ MLX5_RX_HASH_DST_IPV6 |
+ MLX5_RX_HASH_SRC_PORT_TCP |
+ MLX5_RX_HASH_DST_PORT_TCP |
+ MLX5_RX_HASH_SRC_PORT_UDP |
+ MLX5_RX_HASH_DST_PORT_UDP;
+ resp.response_length += sizeof(resp.rss_caps);
+ }
+ } else {
+ if (field_avail(typeof(resp), tso_caps, uhw->outlen))
+ resp.response_length += sizeof(resp.tso_caps);
+ if (field_avail(typeof(resp), rss_caps, uhw->outlen))
+ resp.response_length += sizeof(resp.rss_caps);
+ }
+
+ if (MLX5_CAP_GEN(mdev, ipoib_ipoib_offloads)) {
+ props->device_cap_flags |= IB_DEVICE_UD_IP_CSUM;
+ props->device_cap_flags |= IB_DEVICE_UD_TSO;
+ }
+
+ if (MLX5_CAP_GEN(dev->mdev, eth_net_offloads) &&
+ MLX5_CAP_ETH(dev->mdev, scatter_fcs))
+ props->device_cap_flags |= IB_DEVICE_RAW_SCATTER_FCS;
+
+ if (mlx5_get_flow_namespace(dev->mdev, MLX5_FLOW_NAMESPACE_BYPASS))
+ props->device_cap_flags |= IB_DEVICE_MANAGED_FLOW_STEERING;
+
props->vendor_part_id = mdev->pdev->device;
props->hw_ver = mdev->pdev->revision;
props->max_mr_size = ~0ull;
- props->page_size_cap = ~(u32)((1ull << MLX5_CAP_GEN(mdev, log_pg_sz)) -1);
+ props->page_size_cap = ~(min_page_size - 1);
props->max_qp = 1 << MLX5_CAP_GEN(mdev, log_max_qp);
props->max_qp_wr = 1 << MLX5_CAP_GEN(mdev, log_max_qp_sz);
max_rq_sg = MLX5_CAP_GEN(mdev, max_wqe_sz_rq) /
sizeof(struct mlx5_wqe_data_seg);
- max_sq_desc = min((int)MLX5_CAP_GEN(mdev, max_wqe_sz_sq), 512);
- max_sq_sg = (max_sq_desc -
- sizeof(struct mlx5_wqe_ctrl_seg) -
- sizeof(struct mlx5_wqe_raddr_seg)) / sizeof(struct mlx5_wqe_data_seg);
+ max_sq_sg = (MLX5_CAP_GEN(mdev, max_wqe_sz_sq) -
+ sizeof(struct mlx5_wqe_ctrl_seg)) /
+ sizeof(struct mlx5_wqe_data_seg);
props->max_sge = min(max_rq_sg, max_sq_sg);
+ props->max_sge_rd = MLX5_MAX_SGE_RD;
props->max_cq = 1 << MLX5_CAP_GEN(mdev, log_max_cq);
props->max_cqe = (1 << MLX5_CAP_GEN(mdev, log_max_cq_sz)) - 1;
props->max_mr = 1 << MLX5_CAP_GEN(mdev, log_max_mkey);
@@ -339,14 +621,47 @@ static int mlx5_ib_query_device(struct ib_device *ibdev,
props->local_ca_ack_delay = MLX5_CAP_GEN(mdev, local_ca_ack_delay);
props->max_res_rd_atom = props->max_qp_rd_atom * props->max_qp;
props->max_srq_sge = max_rq_sg - 1;
- props->max_fast_reg_page_list_len = (unsigned int)-1;
+ props->max_fast_reg_page_list_len =
+ 1 << MLX5_CAP_GEN(mdev, log_max_klm_list_size);
get_atomic_caps(dev, props);
+ props->masked_atomic_cap = IB_ATOMIC_NONE;
props->max_mcast_grp = 1 << MLX5_CAP_GEN(mdev, log_max_mcg);
props->max_mcast_qp_attach = MLX5_CAP_GEN(mdev, max_qp_mcg);
props->max_total_mcast_qp_attach = props->max_mcast_qp_attach *
props->max_mcast_grp;
props->max_map_per_fmr = INT_MAX; /* no limit in ConnectIB */
- props->max_ah = INT_MAX;
+ props->hca_core_clock = MLX5_CAP_GEN(mdev, device_frequency_khz);
+ props->timestamp_mask = 0x7FFFFFFFFFFFFFFFULL;
+
+#ifdef CONFIG_INFINIBAND_ON_DEMAND_PAGING
+ if (MLX5_CAP_GEN(mdev, pg))
+ props->device_cap_flags |= IB_DEVICE_ON_DEMAND_PAGING;
+ props->odp_caps = dev->odp_caps;
+#endif
+
+ if (MLX5_CAP_GEN(mdev, cd))
+ props->device_cap_flags |= IB_DEVICE_CROSS_CHANNEL;
+
+ if (!mlx5_core_is_pf(mdev))
+ props->device_cap_flags |= IB_DEVICE_VIRTUAL_FUNCTION;
+
+ if (mlx5_ib_port_link_layer(ibdev, 1) ==
+ IB_LINK_LAYER_ETHERNET) {
+ props->rss_caps.max_rwq_indirection_tables =
+ 1 << MLX5_CAP_GEN(dev->mdev, log_max_rqt);
+ props->rss_caps.max_rwq_indirection_table_size =
+ 1 << MLX5_CAP_GEN(dev->mdev, log_max_rqt_size);
+ props->rss_caps.supported_qpts = 1 << IB_QPT_RAW_PACKET;
+ props->max_wq_type_rq =
+ 1 << MLX5_CAP_GEN(dev->mdev, log_max_rq);
+ }
+
+ if (uhw->outlen) {
+ err = ib_copy_to_udata(uhw, &resp, resp.response_length);
+
+ if (err)
+ return err;
+ }
return 0;
}
@@ -368,8 +683,8 @@ static int translate_active_width(struct ib_device *ibdev, u8 active_width,
if (active_width & MLX5_IB_WIDTH_1X) {
*ib_width = IB_WIDTH_1X;
} else if (active_width & MLX5_IB_WIDTH_2X) {
- mlx5_ib_warn(dev, "active_width %d is not supported by IB spec\n",
- (int)active_width);
+ mlx5_ib_dbg(dev, "active_width %d is not supported by IB spec\n",
+ (int)active_width);
err = -EINVAL;
} else if (active_width & MLX5_IB_WIDTH_4X) {
*ib_width = IB_WIDTH_4X;
@@ -386,9 +701,6 @@ static int translate_active_width(struct ib_device *ibdev, u8 active_width,
return err;
}
-/*
- * TODO: Move to IB core
- */
enum ib_max_vl_num {
__IB_MAX_VL_0 = 1,
__IB_MAX_VL_0_1 = 2,
@@ -436,20 +748,20 @@ static int translate_max_vl_num(struct ib_device *ibdev, u8 vl_hw_cap,
return 0;
}
-static int mlx5_query_port_ib(struct ib_device *ibdev, u8 port,
- struct ib_port_attr *props)
+static int mlx5_query_hca_port(struct ib_device *ibdev, u8 port,
+ struct ib_port_attr *props)
{
struct mlx5_ib_dev *dev = to_mdev(ibdev);
struct mlx5_core_dev *mdev = dev->mdev;
u32 *rep;
- int outlen = MLX5_ST_SZ_BYTES(query_hca_vport_context_out);
+ int replen = MLX5_ST_SZ_BYTES(query_hca_vport_context_out);
struct mlx5_ptys_reg *ptys;
struct mlx5_pmtu_reg *pmtu;
struct mlx5_pvlc_reg pvlc;
void *ctx;
int err;
- rep = mlx5_vzalloc(outlen);
+ rep = mlx5_vzalloc(replen);
ptys = kzalloc(sizeof(*ptys), GFP_KERNEL);
pmtu = kzalloc(sizeof(*pmtu), GFP_KERNEL);
if (!rep || !ptys || !pmtu) {
@@ -459,8 +771,7 @@ static int mlx5_query_port_ib(struct ib_device *ibdev, u8 port,
memset(props, 0, sizeof(*props));
- /* what if I am pf with dual port */
- err = mlx5_query_hca_vport_context(mdev, port, 0, rep, outlen);
+ err = mlx5_query_hca_vport_context(mdev, port, 0, rep, replen);
if (err)
goto out;
@@ -478,13 +789,14 @@ static int mlx5_query_port_ib(struct ib_device *ibdev, u8 port,
props->max_msg_sz = 1 << MLX5_CAP_GEN(mdev, log_max_msg);
props->pkey_tbl_len = mlx5_to_sw_pkey_sz(MLX5_CAP_GEN(mdev, pkey_table_size));
props->bad_pkey_cntr = MLX5_GET(hca_vport_context, ctx,
- pkey_violation_counter);
+ pkey_violation_counter);
props->qkey_viol_cntr = MLX5_GET(hca_vport_context, ctx,
- qkey_violation_counter);
+ qkey_violation_counter);
props->subnet_timeout = MLX5_GET(hca_vport_context, ctx,
- subnet_timeout);
+ subnet_timeout);
props->init_type_reply = MLX5_GET(hca_vport_context, ctx,
- init_type_reply);
+ init_type_reply);
+ props->grh_required = MLX5_GET(hca_vport_context, ctx, grh_required);
ptys->proto_mask |= MLX5_PTYS_IB;
ptys->local_port = port;
@@ -527,10 +839,10 @@ int mlx5_ib_query_port(struct ib_device *ibdev, u8 port,
{
switch (mlx5_get_vport_access_method(ibdev)) {
case MLX5_VPORT_ACCESS_METHOD_MAD:
- return mlx5_query_port_mad_ifc(ibdev, port, props);
+ return mlx5_query_mad_ifc_port(ibdev, port, props);
case MLX5_VPORT_ACCESS_METHOD_HCA:
- return mlx5_query_port_ib(ibdev, port, props);
+ return mlx5_query_hca_port(ibdev, port, props);
case MLX5_VPORT_ACCESS_METHOD_NIC:
return mlx5_query_port_roce(ibdev, port, props);
@@ -540,155 +852,6 @@ int mlx5_ib_query_port(struct ib_device *ibdev, u8 port,
}
}
-static inline int
-mlx5_addrconf_ifid_eui48(u8 *eui, struct net_device *dev)
-{
- if (dev->if_addrlen != ETH_ALEN)
- return -1;
- memcpy(eui, IF_LLADDR(dev), 3);
- memcpy(eui + 5, IF_LLADDR(dev) + 3, 3);
-
- /* NOTE: The scope ID is added by the GID to IP conversion */
-
- eui[3] = 0xFF;
- eui[4] = 0xFE;
- eui[0] ^= 2;
- return 0;
-}
-
-static void
-mlx5_make_default_gid(struct net_device *dev, union ib_gid *gid)
-{
- gid->global.subnet_prefix = cpu_to_be64(0xfe80000000000000LL);
- mlx5_addrconf_ifid_eui48(&gid->raw[8], dev);
-}
-
-static void
-mlx5_ib_roce_port_update(void *arg)
-{
- struct mlx5_ib_port *port = (struct mlx5_ib_port *)arg;
- struct mlx5_ib_dev *dev = port->dev;
- struct mlx5_core_dev *mdev = dev->mdev;
- struct net_device *xdev[MLX5_IB_GID_MAX];
- struct net_device *idev;
- struct net_device *ndev;
- struct ifaddr *ifa;
- union ib_gid gid_temp;
-
- while (port->port_gone == 0) {
- int update = 0;
- int gid_index = 0;
- int j;
- int error;
-
- ndev = mlx5_get_protocol_dev(mdev, MLX5_INTERFACE_PROTOCOL_ETH);
- if (ndev == NULL) {
- pause("W", hz);
- continue;
- }
-
- CURVNET_SET_QUIET(ndev->if_vnet);
-
- memset(&gid_temp, 0, sizeof(gid_temp));
- mlx5_make_default_gid(ndev, &gid_temp);
- if (bcmp(&gid_temp, &port->gid_table[gid_index], sizeof(gid_temp))) {
- port->gid_table[gid_index] = gid_temp;
- update = 1;
- }
- xdev[gid_index] = ndev;
- gid_index++;
-
- IFNET_RLOCK();
- TAILQ_FOREACH(idev, &V_ifnet, if_link) {
- if (idev == ndev)
- break;
- }
- if (idev != NULL) {
- TAILQ_FOREACH(idev, &V_ifnet, if_link) {
- if (idev != ndev) {
- if (idev->if_type != IFT_L2VLAN)
- continue;
- if (ndev != rdma_vlan_dev_real_dev(idev))
- continue;
- }
- /* clone address information for IPv4 and IPv6 */
- IF_ADDR_RLOCK(idev);
- TAILQ_FOREACH(ifa, &idev->if_addrhead, ifa_link) {
- if (ifa->ifa_addr == NULL ||
- (ifa->ifa_addr->sa_family != AF_INET &&
- ifa->ifa_addr->sa_family != AF_INET6) ||
- gid_index >= MLX5_IB_GID_MAX)
- continue;
- memset(&gid_temp, 0, sizeof(gid_temp));
- rdma_ip2gid(ifa->ifa_addr, &gid_temp);
- /* check for existing entry */
- for (j = 0; j != gid_index; j++) {
- if (bcmp(&gid_temp, &port->gid_table[j], sizeof(gid_temp)) == 0)
- break;
- }
- /* check if new entry must be added */
- if (j == gid_index) {
- if (bcmp(&gid_temp, &port->gid_table[gid_index], sizeof(gid_temp))) {
- port->gid_table[gid_index] = gid_temp;
- update = 1;
- }
- xdev[gid_index] = idev;
- gid_index++;
- }
- }
- IF_ADDR_RUNLOCK(idev);
- }
- }
- IFNET_RUNLOCK();
- CURVNET_RESTORE();
-
- if (update != 0 &&
- mlx5_ib_port_link_layer(&dev->ib_dev, 1) == IB_LINK_LAYER_ETHERNET) {
- struct ib_event event = {
- .device = &dev->ib_dev,
- .element.port_num = port->port_num + 1,
- .event = IB_EVENT_GID_CHANGE,
- };
-
- /* add new entries, if any */
- for (j = 0; j != gid_index; j++) {
- error = modify_gid_roce(&dev->ib_dev, port->port_num, j,
- port->gid_table + j, xdev[j]);
- if (error != 0)
- printf("mlx5_ib: Failed to update ROCE GID table: %d\n", error);
- }
- memset(&gid_temp, 0, sizeof(gid_temp));
-
- /* clear old entries, if any */
- for (; j != MLX5_IB_GID_MAX; j++) {
- if (bcmp(&gid_temp, port->gid_table + j, sizeof(gid_temp)) == 0)
- continue;
- port->gid_table[j] = gid_temp;
- (void) modify_gid_roce(&dev->ib_dev, port->port_num, j,
- port->gid_table + j, ndev);
- }
-
- /* make sure ibcore gets updated */
- ib_dispatch_event(&event);
- }
- pause("W", hz);
- }
- do {
- struct ib_event event = {
- .device = &dev->ib_dev,
- .element.port_num = port->port_num + 1,
- .event = IB_EVENT_GID_CHANGE,
- };
- /* make sure ibcore gets updated */
- ib_dispatch_event(&event);
-
- /* wait a bit */
- pause("W", hz);
- } while (0);
- port->port_gone = 2;
- kthread_exit();
-}
-
static int mlx5_ib_query_gid(struct ib_device *ibdev, u8 port, int index,
union ib_gid *gid)
{
@@ -697,23 +860,15 @@ static int mlx5_ib_query_gid(struct ib_device *ibdev, u8 port, int index,
switch (mlx5_get_vport_access_method(ibdev)) {
case MLX5_VPORT_ACCESS_METHOD_MAD:
- return mlx5_query_gids_mad_ifc(ibdev, port, index, gid);
+ return mlx5_query_mad_ifc_gids(ibdev, port, index, gid);
case MLX5_VPORT_ACCESS_METHOD_HCA:
return mlx5_query_hca_vport_gid(mdev, port, 0, index, gid);
- case MLX5_VPORT_ACCESS_METHOD_NIC:
- if (port == 0 || port > MLX5_CAP_GEN(mdev, num_ports) ||
- index < 0 || index >= MLX5_IB_GID_MAX ||
- dev->port[port - 1].port_gone != 0)
- memset(gid, 0, sizeof(*gid));
- else
- *gid = dev->port[port - 1].gid_table[index];
- return 0;
-
default:
return -EINVAL;
}
+
}
static int mlx5_ib_query_pkey(struct ib_device *ibdev, u8 port, u16 index,
@@ -724,13 +879,12 @@ static int mlx5_ib_query_pkey(struct ib_device *ibdev, u8 port, u16 index,
switch (mlx5_get_vport_access_method(ibdev)) {
case MLX5_VPORT_ACCESS_METHOD_MAD:
- return mlx5_query_pkey_mad_ifc(ibdev, port, index, pkey);
+ return mlx5_query_mad_ifc_pkey(ibdev, port, index, pkey);
case MLX5_VPORT_ACCESS_METHOD_HCA:
case MLX5_VPORT_ACCESS_METHOD_NIC:
- return mlx5_query_hca_vport_pkey(mdev, 0, port, 0, index,
+ return mlx5_query_hca_vport_pkey(mdev, 0, port, 0, index,
pkey);
-
default:
return -EINVAL;
}
@@ -754,13 +908,13 @@ static int mlx5_ib_modify_device(struct ib_device *ibdev, int mask,
* If possible, pass node desc to FW, so it can generate
* a 144 trap. If cmd fails, just ignore.
*/
- memcpy(&in, props->node_desc, 64);
+ memcpy(&in, props->node_desc, IB_DEVICE_NODE_DESC_MAX);
err = mlx5_core_access_reg(dev->mdev, &in, sizeof(in), &out,
sizeof(out), MLX5_REG_NODE_DESC, 0, 1);
if (err)
return err;
- memcpy(ibdev->node_desc, props->node_desc, 64);
+ memcpy(ibdev->node_desc, props->node_desc, IB_DEVICE_NODE_DESC_MAX);
return err;
}
@@ -768,20 +922,11 @@ static int mlx5_ib_modify_device(struct ib_device *ibdev, int mask,
static int mlx5_ib_modify_port(struct ib_device *ibdev, u8 port, int mask,
struct ib_port_modify *props)
{
- u8 is_eth = (mlx5_ib_port_link_layer(ibdev, port) ==
- IB_LINK_LAYER_ETHERNET);
struct mlx5_ib_dev *dev = to_mdev(ibdev);
struct ib_port_attr attr;
u32 tmp;
int err;
- /* return OK if this is RoCE. CM calls ib_modify_port() regardless
- * of whether port link layer is ETH or IB. For ETH ports, qkey
- * violations and port capabilities are not valid.
- */
- if (is_eth)
- return 0;
-
mutex_lock(&dev->cap_mask_mutex);
err = mlx5_ib_query_port(ibdev, port, &attr);
@@ -798,22 +943,12 @@ out:
return err;
}
-enum mlx5_cap_flags {
- MLX5_CAP_COMPACT_AV = 1 << 0,
-};
-
-static void set_mlx5_flags(u32 *flags, struct mlx5_core_dev *dev)
-{
- *flags |= MLX5_CAP_GEN(dev, compact_address_vector) ?
- MLX5_CAP_COMPACT_AV : 0;
-}
-
static struct ib_ucontext *mlx5_ib_alloc_ucontext(struct ib_device *ibdev,
struct ib_udata *udata)
{
struct mlx5_ib_dev *dev = to_mdev(ibdev);
- struct mlx5_ib_alloc_ucontext_req_v2 req;
- struct mlx5_ib_alloc_ucontext_resp resp;
+ struct mlx5_ib_alloc_ucontext_req_v2 req = {};
+ struct mlx5_ib_alloc_ucontext_resp resp = {};
struct mlx5_ib_ucontext *context;
struct mlx5_uuar_info *uuari;
struct mlx5_uar *uars;
@@ -824,65 +959,65 @@ static struct ib_ucontext *mlx5_ib_alloc_ucontext(struct ib_device *ibdev,
int err;
int i;
size_t reqlen;
+ size_t min_req_v2 = offsetof(struct mlx5_ib_alloc_ucontext_req_v2,
+ max_cqe_version);
if (!dev->ib_active)
return ERR_PTR(-EAGAIN);
- memset(&req, 0, sizeof(req));
- memset(&resp, 0, sizeof(resp));
+ if (udata->inlen < sizeof(struct ib_uverbs_cmd_hdr))
+ return ERR_PTR(-EINVAL);
reqlen = udata->inlen - sizeof(struct ib_uverbs_cmd_hdr);
if (reqlen == sizeof(struct mlx5_ib_alloc_ucontext_req))
ver = 0;
- else if (reqlen == sizeof(struct mlx5_ib_alloc_ucontext_req_v2))
+ else if (reqlen >= min_req_v2)
ver = 2;
- else {
- mlx5_ib_err(dev, "request malformed, reqlen: %ld\n", (long)reqlen);
+ else
return ERR_PTR(-EINVAL);
- }
- err = ib_copy_from_udata(&req, udata, reqlen);
- if (err) {
- mlx5_ib_err(dev, "copy failed\n");
+ err = ib_copy_from_udata(&req, udata, min(reqlen, sizeof(req)));
+ if (err)
return ERR_PTR(err);
- }
- if (req.reserved) {
- mlx5_ib_err(dev, "request corrupted\n");
+ if (req.flags)
return ERR_PTR(-EINVAL);
- }
- if (req.total_num_uuars == 0 || req.total_num_uuars > MLX5_MAX_UUARS) {
- mlx5_ib_warn(dev, "wrong num_uuars: %d\n", req.total_num_uuars);
+ if (req.total_num_uuars > MLX5_MAX_UUARS)
return ERR_PTR(-ENOMEM);
- }
+
+ if (req.total_num_uuars == 0)
+ return ERR_PTR(-EINVAL);
+
+ if (req.comp_mask || req.reserved0 || req.reserved1 || req.reserved2)
+ return ERR_PTR(-EOPNOTSUPP);
+
+ if (reqlen > sizeof(req) &&
+ !ib_is_udata_cleared(udata, sizeof(req),
+ reqlen - sizeof(req)))
+ return ERR_PTR(-EOPNOTSUPP);
req.total_num_uuars = ALIGN(req.total_num_uuars,
MLX5_NON_FP_BF_REGS_PER_PAGE);
- if (req.num_low_latency_uuars > req.total_num_uuars - 1) {
- mlx5_ib_warn(dev, "wrong num_low_latency_uuars: %d ( > %d)\n",
- req.total_num_uuars, req.total_num_uuars);
+ if (req.num_low_latency_uuars > req.total_num_uuars - 1)
return ERR_PTR(-EINVAL);
- }
num_uars = req.total_num_uuars / MLX5_NON_FP_BF_REGS_PER_PAGE;
gross_uuars = num_uars * MLX5_BF_REGS_PER_PAGE;
resp.qp_tab_size = 1 << MLX5_CAP_GEN(dev->mdev, log_max_qp);
if (mlx5_core_is_pf(dev->mdev) && MLX5_CAP_GEN(dev->mdev, bf))
resp.bf_reg_size = 1 << MLX5_CAP_GEN(dev->mdev, log_bf_reg_size);
- resp.cache_line_size = L1_CACHE_BYTES;
+ resp.cache_line_size = cache_line_size();
resp.max_sq_desc_sz = MLX5_CAP_GEN(dev->mdev, max_wqe_sz_sq);
resp.max_rq_desc_sz = MLX5_CAP_GEN(dev->mdev, max_wqe_sz_rq);
resp.max_send_wqebb = 1 << MLX5_CAP_GEN(dev->mdev, log_max_qp_sz);
resp.max_recv_wr = 1 << MLX5_CAP_GEN(dev->mdev, log_max_qp_sz);
resp.max_srq_recv_wr = 1 << MLX5_CAP_GEN(dev->mdev, log_max_srq_sz);
- set_mlx5_flags(&resp.flags, dev->mdev);
-
- if (offsetof(struct mlx5_ib_alloc_ucontext_resp, max_desc_sz_sq_dc) < udata->outlen)
- resp.max_desc_sz_sq_dc = MLX5_CAP_GEN(dev->mdev, max_wqe_sz_sq_dc);
-
- if (offsetof(struct mlx5_ib_alloc_ucontext_resp, atomic_arg_sizes_dc) < udata->outlen)
- resp.atomic_arg_sizes_dc = MLX5_CAP_ATOMIC(dev->mdev, atomic_size_dc);
+ resp.cqe_version = min_t(__u8,
+ (__u8)MLX5_CAP_GEN(dev->mdev, cqe_version),
+ req.max_cqe_version);
+ resp.response_length = min(offsetof(typeof(resp), response_length) +
+ sizeof(resp.response_length), udata->outlen);
context = kzalloc(sizeof(*context), GFP_KERNEL);
if (!context)
@@ -920,41 +1055,73 @@ static struct ib_ucontext *mlx5_ib_alloc_ucontext(struct ib_device *ibdev,
for (i = 0; i < num_uars; i++) {
err = mlx5_cmd_alloc_uar(dev->mdev, &uars[i].index);
- if (err) {
- mlx5_ib_err(dev, "uar alloc failed at %d\n", i);
+ if (err)
+ goto out_count;
+ }
+
+#ifdef CONFIG_INFINIBAND_ON_DEMAND_PAGING
+ context->ibucontext.invalidate_range = &mlx5_ib_invalidate_range;
+#endif
+
+ if (MLX5_CAP_GEN(dev->mdev, log_max_transport_domain)) {
+ err = mlx5_alloc_transport_domain(dev->mdev,
+ &context->tdn);
+ if (err)
goto out_uars;
- }
}
- for (i = 0; i < MLX5_IB_MAX_CTX_DYNAMIC_UARS; i++)
- context->dynamic_wc_uar_index[i] = MLX5_IB_INVALID_UAR_INDEX;
+ INIT_LIST_HEAD(&context->vma_private_list);
INIT_LIST_HEAD(&context->db_page_list);
mutex_init(&context->db_page_mutex);
resp.tot_uuars = req.total_num_uuars;
resp.num_ports = MLX5_CAP_GEN(dev->mdev, num_ports);
- err = ib_copy_to_udata(udata, &resp,
- min_t(size_t, udata->outlen, sizeof(resp)));
+
+ if (field_avail(typeof(resp), cqe_version, udata->outlen))
+ resp.response_length += sizeof(resp.cqe_version);
+
+ if (field_avail(typeof(resp), cmds_supp_uhw, udata->outlen)) {
+ resp.cmds_supp_uhw |= MLX5_USER_CMDS_SUPP_UHW_QUERY_DEVICE;
+ resp.response_length += sizeof(resp.cmds_supp_uhw);
+ }
+
+ /*
+ * We don't want to expose information from the PCI bar that is located
+ * after 4096 bytes, so if the arch only supports larger pages, let's
+ * pretend we don't support reading the HCA's core clock. This is also
+ * forced by mmap function.
+ */
+ if (PAGE_SIZE <= 4096 &&
+ field_avail(typeof(resp), hca_core_clock_offset, udata->outlen)) {
+ resp.comp_mask |=
+ MLX5_IB_ALLOC_UCONTEXT_RESP_MASK_CORE_CLOCK_OFFSET;
+ resp.hca_core_clock_offset =
+ offsetof(struct mlx5_init_seg, internal_timer_h) %
+ PAGE_SIZE;
+ resp.response_length += sizeof(resp.hca_core_clock_offset) +
+ sizeof(resp.reserved2);
+ }
+
+ err = ib_copy_to_udata(udata, &resp, resp.response_length);
if (err)
- goto out_uars;
+ goto out_td;
uuari->ver = ver;
uuari->num_low_latency_uuars = req.num_low_latency_uuars;
uuari->uars = uars;
uuari->num_uars = num_uars;
-
- if (mlx5_ib_port_link_layer(&dev->ib_dev, 1) ==
- IB_LINK_LAYER_ETHERNET) {
- err = mlx5_alloc_transport_domain(dev->mdev, &context->tdn);
- if (err)
- goto out_uars;
- }
+ context->cqe_version = resp.cqe_version;
return &context->ibucontext;
+out_td:
+ if (MLX5_CAP_GEN(dev->mdev, log_max_transport_domain))
+ mlx5_dealloc_transport_domain(dev->mdev, context->tdn);
+
out_uars:
for (i--; i >= 0; i--)
mlx5_cmd_free_uar(dev->mdev, uars[i].index);
+out_count:
kfree(uuari->count);
out_bitmap:
@@ -975,18 +1142,13 @@ static int mlx5_ib_dealloc_ucontext(struct ib_ucontext *ibcontext)
struct mlx5_uuar_info *uuari = &context->uuari;
int i;
- if (mlx5_ib_port_link_layer(&dev->ib_dev, 1) ==
- IB_LINK_LAYER_ETHERNET)
+ if (MLX5_CAP_GEN(dev->mdev, log_max_transport_domain))
mlx5_dealloc_transport_domain(dev->mdev, context->tdn);
for (i = 0; i < uuari->num_uars; i++) {
if (mlx5_cmd_free_uar(dev->mdev, uuari->uars[i].index))
mlx5_ib_warn(dev, "failed to free UAR 0x%x\n", uuari->uars[i].index);
}
- for (i = 0; i < MLX5_IB_MAX_CTX_DYNAMIC_UARS; i++) {
- if (context->dynamic_wc_uar_index[i] != MLX5_IB_INVALID_UAR_INDEX)
- mlx5_cmd_free_uar(dev->mdev, context->dynamic_wc_uar_index[i]);
- }
kfree(uuari->count);
kfree(uuari->bitmap);
@@ -1016,128 +1178,248 @@ static int get_index(unsigned long offset)
return get_arg(offset);
}
-static int uar_mmap(struct vm_area_struct *vma, pgprot_t prot, bool is_wc,
- struct mlx5_uuar_info *uuari, struct mlx5_ib_dev *dev,
+static void mlx5_ib_vma_open(struct vm_area_struct *area)
+{
+ /* vma_open is called when a new VMA is created on top of our VMA. This
+ * is done through either mremap flow or split_vma (usually due to
+ * mlock, madvise, munmap, etc.) We do not support a clone of the VMA,
+ * as this VMA is strongly hardware related. Therefore we set the
+ * vm_ops of the newly created/cloned VMA to NULL, to prevent it from
+ * calling us again and trying to do incorrect actions. We assume that
+ * the original VMA size is exactly a single page, and therefore all
+ * "splitting" operation will not happen to it.
+ */
+ area->vm_ops = NULL;
+}
+
+static void mlx5_ib_vma_close(struct vm_area_struct *area)
+{
+ struct mlx5_ib_vma_private_data *mlx5_ib_vma_priv_data;
+
+ /* It's guaranteed that all VMAs opened on a FD are closed before the
+ * file itself is closed, therefore no sync is needed with the regular
+ * closing flow. (e.g. mlx5 ib_dealloc_ucontext)
+ * However need a sync with accessing the vma as part of
+ * mlx5_ib_disassociate_ucontext.
+ * The close operation is usually called under mm->mmap_sem except when
+ * process is exiting.
+ * The exiting case is handled explicitly as part of
+ * mlx5_ib_disassociate_ucontext.
+ */
+ mlx5_ib_vma_priv_data = (struct mlx5_ib_vma_private_data *)area->vm_private_data;
+
+ /* setting the vma context pointer to null in the mlx5_ib driver's
+ * private data, to protect a race condition in
+ * mlx5_ib_disassociate_ucontext().
+ */
+ mlx5_ib_vma_priv_data->vma = NULL;
+ list_del(&mlx5_ib_vma_priv_data->list);
+ kfree(mlx5_ib_vma_priv_data);
+}
+
+static const struct vm_operations_struct mlx5_ib_vm_ops = {
+ .open = mlx5_ib_vma_open,
+ .close = mlx5_ib_vma_close
+};
+
+static int mlx5_ib_set_vma_data(struct vm_area_struct *vma,
+ struct mlx5_ib_ucontext *ctx)
+{
+ struct mlx5_ib_vma_private_data *vma_prv;
+ struct list_head *vma_head = &ctx->vma_private_list;
+
+ vma_prv = kzalloc(sizeof(*vma_prv), GFP_KERNEL);
+ if (!vma_prv)
+ return -ENOMEM;
+
+ vma_prv->vma = vma;
+ vma->vm_private_data = vma_prv;
+ vma->vm_ops = &mlx5_ib_vm_ops;
+
+ list_add(&vma_prv->list, vma_head);
+
+ return 0;
+}
+
+static void mlx5_ib_disassociate_ucontext(struct ib_ucontext *ibcontext)
+{
+ int ret;
+ struct vm_area_struct *vma;
+ struct mlx5_ib_vma_private_data *vma_private, *n;
+ struct mlx5_ib_ucontext *context = to_mucontext(ibcontext);
+ struct task_struct *owning_process = NULL;
+ struct mm_struct *owning_mm = NULL;
+
+ owning_process = get_pid_task(ibcontext->tgid, PIDTYPE_PID);
+ if (!owning_process)
+ return;
+
+ owning_mm = get_task_mm(owning_process);
+ if (!owning_mm) {
+ pr_info("no mm, disassociate ucontext is pending task termination\n");
+ while (1) {
+ put_task_struct(owning_process);
+ usleep_range(1000, 2000);
+ owning_process = get_pid_task(ibcontext->tgid,
+ PIDTYPE_PID);
+ if (!owning_process /* ||
+ owning_process->state == TASK_DEAD */) {
+ pr_info("disassociate ucontext done, task was terminated\n");
+ /* in case task was dead need to release the
+ * task struct.
+ */
+ if (owning_process)
+ put_task_struct(owning_process);
+ return;
+ }
+ }
+ }
+
+ /* need to protect from a race on closing the vma as part of
+ * mlx5_ib_vma_close.
+ */
+ down_read(&owning_mm->mmap_sem);
+ list_for_each_entry_safe(vma_private, n, &context->vma_private_list,
+ list) {
+ vma = vma_private->vma;
+ ret = zap_vma_ptes(vma, vma->vm_start,
+ PAGE_SIZE);
+ WARN_ONCE(ret, "%s: zap_vma_ptes failed", __func__);
+ /* context going to be destroyed, should
+ * not access ops any more.
+ */
+ vma->vm_ops = NULL;
+ list_del(&vma_private->list);
+ kfree(vma_private);
+ }
+ up_read(&owning_mm->mmap_sem);
+ mmput(owning_mm);
+ put_task_struct(owning_process);
+}
+
+static inline char *mmap_cmd2str(enum mlx5_ib_mmap_cmd cmd)
+{
+ switch (cmd) {
+ case MLX5_IB_MMAP_WC_PAGE:
+ return "WC";
+ case MLX5_IB_MMAP_REGULAR_PAGE:
+ return "best effort WC";
+ case MLX5_IB_MMAP_NC_PAGE:
+ return "NC";
+ default:
+ return NULL;
+ }
+}
+
+static int uar_mmap(struct mlx5_ib_dev *dev, enum mlx5_ib_mmap_cmd cmd,
+ struct vm_area_struct *vma,
struct mlx5_ib_ucontext *context)
{
+ struct mlx5_uuar_info *uuari = &context->uuari;
+ int err;
unsigned long idx;
- phys_addr_t pfn;
+ phys_addr_t pfn, pa;
+ pgprot_t prot;
- if (vma->vm_end - vma->vm_start != PAGE_SIZE) {
- mlx5_ib_warn(dev, "wrong size, expected PAGE_SIZE(%ld) got %ld\n",
- (long)PAGE_SIZE, (long)(vma->vm_end - vma->vm_start));
+ switch (cmd) {
+ case MLX5_IB_MMAP_WC_PAGE:
+/* Some architectures don't support WC memory */
+#if defined(CONFIG_X86)
+ if (!pat_enabled())
+ return -EPERM;
+#elif !(defined(CONFIG_PPC) || (defined(CONFIG_ARM) && defined(CONFIG_MMU)))
+ return -EPERM;
+#endif
+ /* fall through */
+ case MLX5_IB_MMAP_REGULAR_PAGE:
+ /* For MLX5_IB_MMAP_REGULAR_PAGE do the best effort to get WC */
+ prot = pgprot_writecombine(vma->vm_page_prot);
+ break;
+ case MLX5_IB_MMAP_NC_PAGE:
+ prot = pgprot_noncached(vma->vm_page_prot);
+ break;
+ default:
return -EINVAL;
}
+ if (vma->vm_end - vma->vm_start != PAGE_SIZE)
+ return -EINVAL;
+
idx = get_index(vma->vm_pgoff);
- if (idx >= uuari->num_uars) {
- mlx5_ib_warn(dev, "wrong offset, idx:%ld num_uars:%d\n",
- idx, uuari->num_uars);
+ if (idx >= uuari->num_uars)
return -EINVAL;
- }
pfn = uar_index2pfn(dev, uuari->uars[idx].index);
- mlx5_ib_dbg(dev, "uar idx 0x%lx, pfn 0x%llx\n", idx,
- (unsigned long long)pfn);
+ mlx5_ib_dbg(dev, "uar idx 0x%lx, pfn %pa\n", idx, &pfn);
vma->vm_page_prot = prot;
- if (io_remap_pfn_range(vma, vma->vm_start, pfn,
- PAGE_SIZE, vma->vm_page_prot)) {
- mlx5_ib_err(dev, "io remap failed\n");
+ err = io_remap_pfn_range(vma, vma->vm_start, pfn,
+ PAGE_SIZE, vma->vm_page_prot);
+ if (err) {
+ mlx5_ib_err(dev, "io_remap_pfn_range failed with error=%d, vm_start=0x%llx, pfn=%pa, mmap_cmd=%s\n",
+ err, (unsigned long long)vma->vm_start, &pfn, mmap_cmd2str(cmd));
return -EAGAIN;
}
- mlx5_ib_dbg(dev, "mapped %s at 0x%lx, PA 0x%llx\n", is_wc ? "WC" : "NC",
- (long)vma->vm_start, (unsigned long long)pfn << PAGE_SHIFT);
+ pa = pfn << PAGE_SHIFT;
+ mlx5_ib_dbg(dev, "mapped %s at 0x%llx, PA %pa\n", mmap_cmd2str(cmd),
+ (unsigned long long)vma->vm_start, &pa);
- return 0;
+ return mlx5_ib_set_vma_data(vma, context);
}
static int mlx5_ib_mmap(struct ib_ucontext *ibcontext, struct vm_area_struct *vma)
{
struct mlx5_ib_ucontext *context = to_mucontext(ibcontext);
struct mlx5_ib_dev *dev = to_mdev(ibcontext->device);
- struct mlx5_uuar_info *uuari = &context->uuari;
unsigned long command;
+ phys_addr_t pfn;
command = get_command(vma->vm_pgoff);
switch (command) {
- case MLX5_IB_MMAP_REGULAR_PAGE:
- return uar_mmap(vma, pgprot_writecombine(vma->vm_page_prot),
- true,
- uuari, dev, context);
-
- break;
-
case MLX5_IB_MMAP_WC_PAGE:
- return uar_mmap(vma, pgprot_writecombine(vma->vm_page_prot),
- true, uuari, dev, context);
- break;
-
case MLX5_IB_MMAP_NC_PAGE:
- return uar_mmap(vma, pgprot_noncached(vma->vm_page_prot),
- false, uuari, dev, context);
- break;
+ case MLX5_IB_MMAP_REGULAR_PAGE:
+ return uar_mmap(dev, command, vma, context);
- default:
- return -EINVAL;
- }
+ case MLX5_IB_MMAP_GET_CONTIGUOUS_PAGES:
+ return -ENOSYS;
- return 0;
-}
+ case MLX5_IB_MMAP_CORE_CLOCK:
+ if (vma->vm_end - vma->vm_start != PAGE_SIZE)
+ return -EINVAL;
-static int alloc_pa_mkey(struct mlx5_ib_dev *dev, u32 *key, u32 pdn)
-{
- struct mlx5_create_mkey_mbox_in *in;
- struct mlx5_mkey_seg *seg;
- struct mlx5_core_mr mr;
- int err;
+ if (vma->vm_flags & VM_WRITE)
+ return -EPERM;
- in = kzalloc(sizeof(*in), GFP_KERNEL);
- if (!in)
- return -ENOMEM;
+ /* Don't expose to user-space information it shouldn't have */
+ if (PAGE_SIZE > 4096)
+ return -EOPNOTSUPP;
- seg = &in->seg;
- seg->flags = MLX5_PERM_LOCAL_READ | MLX5_ACCESS_MODE_PA;
- seg->flags_pd = cpu_to_be32(pdn | MLX5_MKEY_LEN64);
- seg->qpn_mkey7_0 = cpu_to_be32(0xffffff << 8);
- seg->start_addr = 0;
+ vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);
+ pfn = (dev->mdev->iseg_base +
+ offsetof(struct mlx5_init_seg, internal_timer_h)) >>
+ PAGE_SHIFT;
+ if (io_remap_pfn_range(vma, vma->vm_start, pfn,
+ PAGE_SIZE, vma->vm_page_prot))
+ return -EAGAIN;
- err = mlx5_core_create_mkey(dev->mdev, &mr, in, sizeof(*in),
- NULL, NULL, NULL);
- if (err) {
- mlx5_ib_warn(dev, "failed to create mkey, %d\n", err);
- goto err_in;
- }
+ mlx5_ib_dbg(dev, "mapped internal timer at 0x%llx, PA 0x%llx\n",
+ (unsigned long long)vma->vm_start,
+ (unsigned long long)pfn << PAGE_SHIFT);
+ break;
- kfree(in);
- *key = mr.key;
+ default:
+ return -EINVAL;
+ }
return 0;
-
-err_in:
- kfree(in);
-
- return err;
-}
-
-static void free_pa_mkey(struct mlx5_ib_dev *dev, u32 key)
-{
- struct mlx5_core_mr mr;
- int err;
-
- memset(&mr, 0, sizeof(mr));
- mr.key = key;
- err = mlx5_core_destroy_mkey(dev->mdev, &mr);
- if (err)
- mlx5_ib_warn(dev, "failed to destroy mkey 0x%x\n", key);
}
static struct ib_pd *mlx5_ib_alloc_pd(struct ib_device *ibdev,
struct ib_ucontext *context,
struct ib_udata *udata)
{
- struct mlx5_ib_dev *dev = to_mdev(ibdev);
struct mlx5_ib_alloc_pd_resp resp;
struct mlx5_ib_pd *pd;
int err;
@@ -1148,7 +1430,6 @@ static struct ib_pd *mlx5_ib_alloc_pd(struct ib_device *ibdev,
err = mlx5_core_alloc_pd(to_mdev(ibdev)->mdev, &pd->pdn);
if (err) {
- mlx5_ib_warn(dev, "pd alloc failed\n");
kfree(pd);
return ERR_PTR(err);
}
@@ -1156,19 +1437,10 @@ static struct ib_pd *mlx5_ib_alloc_pd(struct ib_device *ibdev,
if (context) {
resp.pdn = pd->pdn;
if (ib_copy_to_udata(udata, &resp, sizeof(resp))) {
- mlx5_ib_err(dev, "copy failed\n");
mlx5_core_dealloc_pd(to_mdev(ibdev)->mdev, pd->pdn);
kfree(pd);
return ERR_PTR(-EFAULT);
}
- } else {
- err = alloc_pa_mkey(to_mdev(ibdev), &pd->pa_lkey, pd->pdn);
- if (err) {
- mlx5_ib_err(dev, "alloc mkey failed\n");
- mlx5_core_dealloc_pd(to_mdev(ibdev)->mdev, pd->pdn);
- kfree(pd);
- return ERR_PTR(err);
- }
}
return &pd->ibpd;
@@ -1179,24 +1451,690 @@ static int mlx5_ib_dealloc_pd(struct ib_pd *pd)
struct mlx5_ib_dev *mdev = to_mdev(pd->device);
struct mlx5_ib_pd *mpd = to_mpd(pd);
- if (!pd->uobject)
- free_pa_mkey(mdev, mpd->pa_lkey);
-
mlx5_core_dealloc_pd(mdev->mdev, mpd->pdn);
kfree(mpd);
return 0;
}
+enum {
+ MATCH_CRITERIA_ENABLE_OUTER_BIT,
+ MATCH_CRITERIA_ENABLE_MISC_BIT,
+ MATCH_CRITERIA_ENABLE_INNER_BIT
+};
+
+#define HEADER_IS_ZERO(match_criteria, headers) \
+ !(memchr_inv(MLX5_ADDR_OF(fte_match_param, match_criteria, headers), \
+ 0, MLX5_FLD_SZ_BYTES(fte_match_param, headers))) \
+
+static u8 get_match_criteria_enable(u32 *match_criteria)
+{
+ u8 match_criteria_enable;
+
+ match_criteria_enable =
+ (!HEADER_IS_ZERO(match_criteria, outer_headers)) <<
+ MATCH_CRITERIA_ENABLE_OUTER_BIT;
+ match_criteria_enable |=
+ (!HEADER_IS_ZERO(match_criteria, misc_parameters)) <<
+ MATCH_CRITERIA_ENABLE_MISC_BIT;
+ match_criteria_enable |=
+ (!HEADER_IS_ZERO(match_criteria, inner_headers)) <<
+ MATCH_CRITERIA_ENABLE_INNER_BIT;
+
+ return match_criteria_enable;
+}
+
+static void set_proto(void *outer_c, void *outer_v, u8 mask, u8 val)
+{
+ MLX5_SET(fte_match_set_lyr_2_4, outer_c, ip_protocol, mask);
+ MLX5_SET(fte_match_set_lyr_2_4, outer_v, ip_protocol, val);
+}
+
+static void set_tos(void *outer_c, void *outer_v, u8 mask, u8 val)
+{
+ MLX5_SET(fte_match_set_lyr_2_4, outer_c, ip_ecn, mask);
+ MLX5_SET(fte_match_set_lyr_2_4, outer_v, ip_ecn, val);
+ MLX5_SET(fte_match_set_lyr_2_4, outer_c, ip_dscp, mask >> 2);
+ MLX5_SET(fte_match_set_lyr_2_4, outer_v, ip_dscp, val >> 2);
+}
+
+#define LAST_ETH_FIELD vlan_tag
+#define LAST_IB_FIELD sl
+#define LAST_IPV4_FIELD tos
+#define LAST_IPV6_FIELD traffic_class
+#define LAST_TCP_UDP_FIELD src_port
+
+/* Field is the last supported field */
+#define FIELDS_NOT_SUPPORTED(filter, field)\
+ memchr_inv((void *)&filter.field +\
+ sizeof(filter.field), 0,\
+ sizeof(filter) -\
+ offsetof(typeof(filter), field) -\
+ sizeof(filter.field))
+
+static int parse_flow_attr(u32 *match_c, u32 *match_v,
+ const union ib_flow_spec *ib_spec)
+{
+ void *outer_headers_c = MLX5_ADDR_OF(fte_match_param, match_c,
+ outer_headers);
+ void *outer_headers_v = MLX5_ADDR_OF(fte_match_param, match_v,
+ outer_headers);
+ void *misc_params_c = MLX5_ADDR_OF(fte_match_param, match_c,
+ misc_parameters);
+ void *misc_params_v = MLX5_ADDR_OF(fte_match_param, match_v,
+ misc_parameters);
+
+ switch (ib_spec->type) {
+ case IB_FLOW_SPEC_ETH:
+ if (FIELDS_NOT_SUPPORTED(ib_spec->eth.mask, LAST_ETH_FIELD))
+ return -ENOTSUPP;
+
+ ether_addr_copy(MLX5_ADDR_OF(fte_match_set_lyr_2_4, outer_headers_c,
+ dmac_47_16),
+ ib_spec->eth.mask.dst_mac);
+ ether_addr_copy(MLX5_ADDR_OF(fte_match_set_lyr_2_4, outer_headers_v,
+ dmac_47_16),
+ ib_spec->eth.val.dst_mac);
+
+ ether_addr_copy(MLX5_ADDR_OF(fte_match_set_lyr_2_4, outer_headers_c,
+ smac_47_16),
+ ib_spec->eth.mask.src_mac);
+ ether_addr_copy(MLX5_ADDR_OF(fte_match_set_lyr_2_4, outer_headers_v,
+ smac_47_16),
+ ib_spec->eth.val.src_mac);
+
+ if (ib_spec->eth.mask.vlan_tag) {
+ MLX5_SET(fte_match_set_lyr_2_4, outer_headers_c,
+ cvlan_tag, 1);
+ MLX5_SET(fte_match_set_lyr_2_4, outer_headers_v,
+ cvlan_tag, 1);
+
+ MLX5_SET(fte_match_set_lyr_2_4, outer_headers_c,
+ first_vid, ntohs(ib_spec->eth.mask.vlan_tag));
+ MLX5_SET(fte_match_set_lyr_2_4, outer_headers_v,
+ first_vid, ntohs(ib_spec->eth.val.vlan_tag));
+
+ MLX5_SET(fte_match_set_lyr_2_4, outer_headers_c,
+ first_cfi,
+ ntohs(ib_spec->eth.mask.vlan_tag) >> 12);
+ MLX5_SET(fte_match_set_lyr_2_4, outer_headers_v,
+ first_cfi,
+ ntohs(ib_spec->eth.val.vlan_tag) >> 12);
+
+ MLX5_SET(fte_match_set_lyr_2_4, outer_headers_c,
+ first_prio,
+ ntohs(ib_spec->eth.mask.vlan_tag) >> 13);
+ MLX5_SET(fte_match_set_lyr_2_4, outer_headers_v,
+ first_prio,
+ ntohs(ib_spec->eth.val.vlan_tag) >> 13);
+ }
+ MLX5_SET(fte_match_set_lyr_2_4, outer_headers_c,
+ ethertype, ntohs(ib_spec->eth.mask.ether_type));
+ MLX5_SET(fte_match_set_lyr_2_4, outer_headers_v,
+ ethertype, ntohs(ib_spec->eth.val.ether_type));
+ break;
+ case IB_FLOW_SPEC_IPV4:
+ if (FIELDS_NOT_SUPPORTED(ib_spec->ipv4.mask, LAST_IPV4_FIELD))
+ return -ENOTSUPP;
+
+ MLX5_SET(fte_match_set_lyr_2_4, outer_headers_c,
+ ethertype, 0xffff);
+ MLX5_SET(fte_match_set_lyr_2_4, outer_headers_v,
+ ethertype, ETH_P_IP);
+
+ memcpy(MLX5_ADDR_OF(fte_match_set_lyr_2_4, outer_headers_c,
+ src_ipv4_src_ipv6.ipv4_layout.ipv4),
+ &ib_spec->ipv4.mask.src_ip,
+ sizeof(ib_spec->ipv4.mask.src_ip));
+ memcpy(MLX5_ADDR_OF(fte_match_set_lyr_2_4, outer_headers_v,
+ src_ipv4_src_ipv6.ipv4_layout.ipv4),
+ &ib_spec->ipv4.val.src_ip,
+ sizeof(ib_spec->ipv4.val.src_ip));
+ memcpy(MLX5_ADDR_OF(fte_match_set_lyr_2_4, outer_headers_c,
+ dst_ipv4_dst_ipv6.ipv4_layout.ipv4),
+ &ib_spec->ipv4.mask.dst_ip,
+ sizeof(ib_spec->ipv4.mask.dst_ip));
+ memcpy(MLX5_ADDR_OF(fte_match_set_lyr_2_4, outer_headers_v,
+ dst_ipv4_dst_ipv6.ipv4_layout.ipv4),
+ &ib_spec->ipv4.val.dst_ip,
+ sizeof(ib_spec->ipv4.val.dst_ip));
+
+ set_tos(outer_headers_c, outer_headers_v,
+ ib_spec->ipv4.mask.tos, ib_spec->ipv4.val.tos);
+
+ set_proto(outer_headers_c, outer_headers_v,
+ ib_spec->ipv4.mask.proto, ib_spec->ipv4.val.proto);
+ break;
+ case IB_FLOW_SPEC_IPV6:
+ if (FIELDS_NOT_SUPPORTED(ib_spec->ipv6.mask, LAST_IPV6_FIELD))
+ return -ENOTSUPP;
+
+ MLX5_SET(fte_match_set_lyr_2_4, outer_headers_c,
+ ethertype, 0xffff);
+ MLX5_SET(fte_match_set_lyr_2_4, outer_headers_v,
+ ethertype, IPPROTO_IPV6);
+
+ memcpy(MLX5_ADDR_OF(fte_match_set_lyr_2_4, outer_headers_c,
+ src_ipv4_src_ipv6.ipv6_layout.ipv6),
+ &ib_spec->ipv6.mask.src_ip,
+ sizeof(ib_spec->ipv6.mask.src_ip));
+ memcpy(MLX5_ADDR_OF(fte_match_set_lyr_2_4, outer_headers_v,
+ src_ipv4_src_ipv6.ipv6_layout.ipv6),
+ &ib_spec->ipv6.val.src_ip,
+ sizeof(ib_spec->ipv6.val.src_ip));
+ memcpy(MLX5_ADDR_OF(fte_match_set_lyr_2_4, outer_headers_c,
+ dst_ipv4_dst_ipv6.ipv6_layout.ipv6),
+ &ib_spec->ipv6.mask.dst_ip,
+ sizeof(ib_spec->ipv6.mask.dst_ip));
+ memcpy(MLX5_ADDR_OF(fte_match_set_lyr_2_4, outer_headers_v,
+ dst_ipv4_dst_ipv6.ipv6_layout.ipv6),
+ &ib_spec->ipv6.val.dst_ip,
+ sizeof(ib_spec->ipv6.val.dst_ip));
+
+ set_tos(outer_headers_c, outer_headers_v,
+ ib_spec->ipv6.mask.traffic_class,
+ ib_spec->ipv6.val.traffic_class);
+
+ set_proto(outer_headers_c, outer_headers_v,
+ ib_spec->ipv6.mask.next_hdr,
+ ib_spec->ipv6.val.next_hdr);
+
+ MLX5_SET(fte_match_set_misc, misc_params_c,
+ outer_ipv6_flow_label,
+ ntohl(ib_spec->ipv6.mask.flow_label));
+ MLX5_SET(fte_match_set_misc, misc_params_v,
+ outer_ipv6_flow_label,
+ ntohl(ib_spec->ipv6.val.flow_label));
+ break;
+ case IB_FLOW_SPEC_TCP:
+ if (FIELDS_NOT_SUPPORTED(ib_spec->tcp_udp.mask,
+ LAST_TCP_UDP_FIELD))
+ return -ENOTSUPP;
+
+ MLX5_SET(fte_match_set_lyr_2_4, outer_headers_c, ip_protocol,
+ 0xff);
+ MLX5_SET(fte_match_set_lyr_2_4, outer_headers_v, ip_protocol,
+ IPPROTO_TCP);
+
+ MLX5_SET(fte_match_set_lyr_2_4, outer_headers_c, tcp_sport,
+ ntohs(ib_spec->tcp_udp.mask.src_port));
+ MLX5_SET(fte_match_set_lyr_2_4, outer_headers_v, tcp_sport,
+ ntohs(ib_spec->tcp_udp.val.src_port));
+
+ MLX5_SET(fte_match_set_lyr_2_4, outer_headers_c, tcp_dport,
+ ntohs(ib_spec->tcp_udp.mask.dst_port));
+ MLX5_SET(fte_match_set_lyr_2_4, outer_headers_v, tcp_dport,
+ ntohs(ib_spec->tcp_udp.val.dst_port));
+ break;
+ case IB_FLOW_SPEC_UDP:
+ if (FIELDS_NOT_SUPPORTED(ib_spec->tcp_udp.mask,
+ LAST_TCP_UDP_FIELD))
+ return -ENOTSUPP;
+
+ MLX5_SET(fte_match_set_lyr_2_4, outer_headers_c, ip_protocol,
+ 0xff);
+ MLX5_SET(fte_match_set_lyr_2_4, outer_headers_v, ip_protocol,
+ IPPROTO_UDP);
+
+ MLX5_SET(fte_match_set_lyr_2_4, outer_headers_c, udp_sport,
+ ntohs(ib_spec->tcp_udp.mask.src_port));
+ MLX5_SET(fte_match_set_lyr_2_4, outer_headers_v, udp_sport,
+ ntohs(ib_spec->tcp_udp.val.src_port));
+
+ MLX5_SET(fte_match_set_lyr_2_4, outer_headers_c, udp_dport,
+ ntohs(ib_spec->tcp_udp.mask.dst_port));
+ MLX5_SET(fte_match_set_lyr_2_4, outer_headers_v, udp_dport,
+ ntohs(ib_spec->tcp_udp.val.dst_port));
+ break;
+ default:
+ return -EINVAL;
+ }
+
+ return 0;
+}
+
+/* If a flow could catch both multicast and unicast packets,
+ * it won't fall into the multicast flow steering table and this rule
+ * could steal other multicast packets.
+ */
+static bool flow_is_multicast_only(struct ib_flow_attr *ib_attr)
+{
+ struct ib_flow_spec_eth *eth_spec;
+
+ if (ib_attr->type != IB_FLOW_ATTR_NORMAL ||
+ ib_attr->size < sizeof(struct ib_flow_attr) +
+ sizeof(struct ib_flow_spec_eth) ||
+ ib_attr->num_of_specs < 1)
+ return false;
+
+ eth_spec = (struct ib_flow_spec_eth *)(ib_attr + 1);
+ if (eth_spec->type != IB_FLOW_SPEC_ETH ||
+ eth_spec->size != sizeof(*eth_spec))
+ return false;
+
+ return is_multicast_ether_addr(eth_spec->mask.dst_mac) &&
+ is_multicast_ether_addr(eth_spec->val.dst_mac);
+}
+
+static bool is_valid_attr(const struct ib_flow_attr *flow_attr)
+{
+ union ib_flow_spec *ib_spec = (union ib_flow_spec *)(flow_attr + 1);
+ bool has_ipv4_spec = false;
+ bool eth_type_ipv4 = true;
+ unsigned int spec_index;
+
+ /* Validate that ethertype is correct */
+ for (spec_index = 0; spec_index < flow_attr->num_of_specs; spec_index++) {
+ if (ib_spec->type == IB_FLOW_SPEC_ETH &&
+ ib_spec->eth.mask.ether_type) {
+ if (!((ib_spec->eth.mask.ether_type == htons(0xffff)) &&
+ ib_spec->eth.val.ether_type == htons(ETH_P_IP)))
+ eth_type_ipv4 = false;
+ } else if (ib_spec->type == IB_FLOW_SPEC_IPV4) {
+ has_ipv4_spec = true;
+ }
+ ib_spec = (void *)ib_spec + ib_spec->size;
+ }
+ return !has_ipv4_spec || eth_type_ipv4;
+}
+
+static void put_flow_table(struct mlx5_ib_dev *dev,
+ struct mlx5_ib_flow_prio *prio, bool ft_added)
+{
+ prio->refcount -= !!ft_added;
+ if (!prio->refcount) {
+ mlx5_destroy_flow_table(prio->flow_table);
+ prio->flow_table = NULL;
+ }
+}
+
+static int mlx5_ib_destroy_flow(struct ib_flow *flow_id)
+{
+ struct mlx5_ib_dev *dev = to_mdev(flow_id->qp->device);
+ struct mlx5_ib_flow_handler *handler = container_of(flow_id,
+ struct mlx5_ib_flow_handler,
+ ibflow);
+ struct mlx5_ib_flow_handler *iter, *tmp;
+
+ mutex_lock(&dev->flow_db.lock);
+
+ list_for_each_entry_safe(iter, tmp, &handler->list, list) {
+ mlx5_del_flow_rule(iter->rule);
+ put_flow_table(dev, iter->prio, true);
+ list_del(&iter->list);
+ kfree(iter);
+ }
+
+ mlx5_del_flow_rule(handler->rule);
+ put_flow_table(dev, handler->prio, true);
+ mutex_unlock(&dev->flow_db.lock);
+
+ kfree(handler);
+
+ return 0;
+}
+
+static int ib_prio_to_core_prio(unsigned int priority, bool dont_trap)
+{
+ priority *= 2;
+ if (!dont_trap)
+ priority++;
+ return priority;
+}
+
+enum flow_table_type {
+ MLX5_IB_FT_RX,
+ MLX5_IB_FT_TX
+};
+
+#define MLX5_FS_MAX_TYPES 10
+#define MLX5_FS_MAX_ENTRIES 32000UL
+static struct mlx5_ib_flow_prio *get_flow_table(struct mlx5_ib_dev *dev,
+ struct ib_flow_attr *flow_attr,
+ enum flow_table_type ft_type)
+{
+ bool dont_trap = flow_attr->flags & IB_FLOW_ATTR_FLAGS_DONT_TRAP;
+ struct mlx5_flow_namespace *ns = NULL;
+ struct mlx5_ib_flow_prio *prio;
+ struct mlx5_flow_table *ft;
+ int num_entries;
+ int num_groups;
+ int priority;
+ int err = 0;
+
+ if (flow_attr->type == IB_FLOW_ATTR_NORMAL) {
+ if (flow_is_multicast_only(flow_attr) &&
+ !dont_trap)
+ priority = MLX5_IB_FLOW_MCAST_PRIO;
+ else
+ priority = ib_prio_to_core_prio(flow_attr->priority,
+ dont_trap);
+ ns = mlx5_get_flow_namespace(dev->mdev,
+ MLX5_FLOW_NAMESPACE_BYPASS);
+ num_entries = MLX5_FS_MAX_ENTRIES;
+ num_groups = MLX5_FS_MAX_TYPES;
+ prio = &dev->flow_db.prios[priority];
+ } else if (flow_attr->type == IB_FLOW_ATTR_ALL_DEFAULT ||
+ flow_attr->type == IB_FLOW_ATTR_MC_DEFAULT) {
+ ns = mlx5_get_flow_namespace(dev->mdev,
+ MLX5_FLOW_NAMESPACE_LEFTOVERS);
+ build_leftovers_ft_param("bypass", &priority,
+ &num_entries,
+ &num_groups);
+ prio = &dev->flow_db.prios[MLX5_IB_FLOW_LEFTOVERS_PRIO];
+ } else if (flow_attr->type == IB_FLOW_ATTR_SNIFFER) {
+ if (!MLX5_CAP_FLOWTABLE(dev->mdev,
+ allow_sniffer_and_nic_rx_shared_tir))
+ return ERR_PTR(-ENOTSUPP);
+
+ ns = mlx5_get_flow_namespace(dev->mdev, ft_type == MLX5_IB_FT_RX ?
+ MLX5_FLOW_NAMESPACE_SNIFFER_RX :
+ MLX5_FLOW_NAMESPACE_SNIFFER_TX);
+
+ prio = &dev->flow_db.sniffer[ft_type];
+ priority = 0;
+ num_entries = 1;
+ num_groups = 1;
+ }
+
+ if (!ns)
+ return ERR_PTR(-ENOTSUPP);
+
+ ft = prio->flow_table;
+ if (!ft) {
+ ft = mlx5_create_auto_grouped_flow_table(ns, priority, "bypass",
+ num_entries,
+ num_groups);
+
+ if (!IS_ERR(ft)) {
+ prio->refcount = 0;
+ prio->flow_table = ft;
+ } else {
+ err = PTR_ERR(ft);
+ }
+ }
+
+ return err ? ERR_PTR(err) : prio;
+}
+
+static struct mlx5_ib_flow_handler *create_flow_rule(struct mlx5_ib_dev *dev,
+ struct mlx5_ib_flow_prio *ft_prio,
+ const struct ib_flow_attr *flow_attr,
+ struct mlx5_flow_destination *dst)
+{
+ struct mlx5_flow_table *ft = ft_prio->flow_table;
+ struct mlx5_ib_flow_handler *handler;
+ struct mlx5_flow_spec *spec;
+ const void *ib_flow = (const void *)flow_attr + sizeof(*flow_attr);
+ unsigned int spec_index;
+ u32 action;
+ int err = 0;
+
+ if (!is_valid_attr(flow_attr))
+ return ERR_PTR(-EINVAL);
+
+ spec = mlx5_vzalloc(sizeof(*spec));
+ handler = kzalloc(sizeof(*handler), GFP_KERNEL);
+ if (!handler || !spec) {
+ err = -ENOMEM;
+ goto free;
+ }
+
+ INIT_LIST_HEAD(&handler->list);
+
+ for (spec_index = 0; spec_index < flow_attr->num_of_specs; spec_index++) {
+ err = parse_flow_attr(spec->match_criteria,
+ spec->match_value, ib_flow);
+ if (err < 0)
+ goto free;
+
+ ib_flow += ((union ib_flow_spec *)ib_flow)->size;
+ }
+
+ spec->match_criteria_enable = get_match_criteria_enable(spec->match_criteria);
+ action = dst ? MLX5_FLOW_CONTEXT_ACTION_FWD_DEST :
+ MLX5_FLOW_CONTEXT_ACTION_FWD_NEXT_PRIO;
+ handler->rule = mlx5_add_flow_rule(ft, spec->match_criteria_enable,
+ spec->match_criteria,
+ spec->match_value,
+ action,
+ MLX5_FS_DEFAULT_FLOW_TAG,
+ dst);
+
+ if (IS_ERR(handler->rule)) {
+ err = PTR_ERR(handler->rule);
+ goto free;
+ }
+
+ ft_prio->refcount++;
+ handler->prio = ft_prio;
+
+ ft_prio->flow_table = ft;
+free:
+ if (err)
+ kfree(handler);
+ kvfree(spec);
+ return err ? ERR_PTR(err) : handler;
+}
+
+static struct mlx5_ib_flow_handler *create_dont_trap_rule(struct mlx5_ib_dev *dev,
+ struct mlx5_ib_flow_prio *ft_prio,
+ struct ib_flow_attr *flow_attr,
+ struct mlx5_flow_destination *dst)
+{
+ struct mlx5_ib_flow_handler *handler_dst = NULL;
+ struct mlx5_ib_flow_handler *handler = NULL;
+
+ handler = create_flow_rule(dev, ft_prio, flow_attr, NULL);
+ if (!IS_ERR(handler)) {
+ handler_dst = create_flow_rule(dev, ft_prio,
+ flow_attr, dst);
+ if (IS_ERR(handler_dst)) {
+ mlx5_del_flow_rule(handler->rule);
+ ft_prio->refcount--;
+ kfree(handler);
+ handler = handler_dst;
+ } else {
+ list_add(&handler_dst->list, &handler->list);
+ }
+ }
+
+ return handler;
+}
+enum {
+ LEFTOVERS_MC,
+ LEFTOVERS_UC,
+};
+
+static struct mlx5_ib_flow_handler *create_leftovers_rule(struct mlx5_ib_dev *dev,
+ struct mlx5_ib_flow_prio *ft_prio,
+ struct ib_flow_attr *flow_attr,
+ struct mlx5_flow_destination *dst)
+{
+ struct mlx5_ib_flow_handler *handler_ucast = NULL;
+ struct mlx5_ib_flow_handler *handler = NULL;
+
+ static struct {
+ struct ib_flow_attr flow_attr;
+ struct ib_flow_spec_eth eth_flow;
+ } leftovers_specs[] = {
+ [LEFTOVERS_MC] = {
+ .flow_attr = {
+ .num_of_specs = 1,
+ .size = sizeof(leftovers_specs[0])
+ },
+ .eth_flow = {
+ .type = IB_FLOW_SPEC_ETH,
+ .size = sizeof(struct ib_flow_spec_eth),
+ .mask = {.dst_mac = {0x1} },
+ .val = {.dst_mac = {0x1} }
+ }
+ },
+ [LEFTOVERS_UC] = {
+ .flow_attr = {
+ .num_of_specs = 1,
+ .size = sizeof(leftovers_specs[0])
+ },
+ .eth_flow = {
+ .type = IB_FLOW_SPEC_ETH,
+ .size = sizeof(struct ib_flow_spec_eth),
+ .mask = {.dst_mac = {0x1} },
+ .val = {.dst_mac = {} }
+ }
+ }
+ };
+
+ handler = create_flow_rule(dev, ft_prio,
+ &leftovers_specs[LEFTOVERS_MC].flow_attr,
+ dst);
+ if (!IS_ERR(handler) &&
+ flow_attr->type == IB_FLOW_ATTR_ALL_DEFAULT) {
+ handler_ucast = create_flow_rule(dev, ft_prio,
+ &leftovers_specs[LEFTOVERS_UC].flow_attr,
+ dst);
+ if (IS_ERR(handler_ucast)) {
+ mlx5_del_flow_rule(handler->rule);
+ ft_prio->refcount--;
+ kfree(handler);
+ handler = handler_ucast;
+ } else {
+ list_add(&handler_ucast->list, &handler->list);
+ }
+ }
+
+ return handler;
+}
+
+static struct mlx5_ib_flow_handler *create_sniffer_rule(struct mlx5_ib_dev *dev,
+ struct mlx5_ib_flow_prio *ft_rx,
+ struct mlx5_ib_flow_prio *ft_tx,
+ struct mlx5_flow_destination *dst)
+{
+ struct mlx5_ib_flow_handler *handler_rx;
+ struct mlx5_ib_flow_handler *handler_tx;
+ int err;
+ static const struct ib_flow_attr flow_attr = {
+ .num_of_specs = 0,
+ .size = sizeof(flow_attr)
+ };
+
+ handler_rx = create_flow_rule(dev, ft_rx, &flow_attr, dst);
+ if (IS_ERR(handler_rx)) {
+ err = PTR_ERR(handler_rx);
+ goto err;
+ }
+
+ handler_tx = create_flow_rule(dev, ft_tx, &flow_attr, dst);
+ if (IS_ERR(handler_tx)) {
+ err = PTR_ERR(handler_tx);
+ goto err_tx;
+ }
+
+ list_add(&handler_tx->list, &handler_rx->list);
+
+ return handler_rx;
+
+err_tx:
+ mlx5_del_flow_rule(handler_rx->rule);
+ ft_rx->refcount--;
+ kfree(handler_rx);
+err:
+ return ERR_PTR(err);
+}
+
+static struct ib_flow *mlx5_ib_create_flow(struct ib_qp *qp,
+ struct ib_flow_attr *flow_attr,
+ int domain)
+{
+ struct mlx5_ib_dev *dev = to_mdev(qp->device);
+ struct mlx5_ib_qp *mqp = to_mqp(qp);
+ struct mlx5_ib_flow_handler *handler = NULL;
+ struct mlx5_flow_destination *dst = NULL;
+ struct mlx5_ib_flow_prio *ft_prio_tx = NULL;
+ struct mlx5_ib_flow_prio *ft_prio;
+ int err;
+
+ if (flow_attr->priority > MLX5_IB_FLOW_LAST_PRIO)
+ return ERR_PTR(-ENOSPC);
+
+ if (domain != IB_FLOW_DOMAIN_USER ||
+ flow_attr->port > MLX5_CAP_GEN(dev->mdev, num_ports) ||
+ (flow_attr->flags & ~IB_FLOW_ATTR_FLAGS_DONT_TRAP))
+ return ERR_PTR(-EINVAL);
+
+ dst = kzalloc(sizeof(*dst), GFP_KERNEL);
+ if (!dst)
+ return ERR_PTR(-ENOMEM);
+
+ mutex_lock(&dev->flow_db.lock);
+
+ ft_prio = get_flow_table(dev, flow_attr, MLX5_IB_FT_RX);
+ if (IS_ERR(ft_prio)) {
+ err = PTR_ERR(ft_prio);
+ goto unlock;
+ }
+ if (flow_attr->type == IB_FLOW_ATTR_SNIFFER) {
+ ft_prio_tx = get_flow_table(dev, flow_attr, MLX5_IB_FT_TX);
+ if (IS_ERR(ft_prio_tx)) {
+ err = PTR_ERR(ft_prio_tx);
+ ft_prio_tx = NULL;
+ goto destroy_ft;
+ }
+ }
+
+ dst->type = MLX5_FLOW_DESTINATION_TYPE_TIR;
+ if (mqp->flags & MLX5_IB_QP_RSS)
+ dst->tir_num = mqp->rss_qp.tirn;
+ else
+ dst->tir_num = mqp->raw_packet_qp.rq.tirn;
+
+ if (flow_attr->type == IB_FLOW_ATTR_NORMAL) {
+ if (flow_attr->flags & IB_FLOW_ATTR_FLAGS_DONT_TRAP) {
+ handler = create_dont_trap_rule(dev, ft_prio,
+ flow_attr, dst);
+ } else {
+ handler = create_flow_rule(dev, ft_prio, flow_attr,
+ dst);
+ }
+ } else if (flow_attr->type == IB_FLOW_ATTR_ALL_DEFAULT ||
+ flow_attr->type == IB_FLOW_ATTR_MC_DEFAULT) {
+ handler = create_leftovers_rule(dev, ft_prio, flow_attr,
+ dst);
+ } else if (flow_attr->type == IB_FLOW_ATTR_SNIFFER) {
+ handler = create_sniffer_rule(dev, ft_prio, ft_prio_tx, dst);
+ } else {
+ err = -EINVAL;
+ goto destroy_ft;
+ }
+
+ if (IS_ERR(handler)) {
+ err = PTR_ERR(handler);
+ handler = NULL;
+ goto destroy_ft;
+ }
+
+ mutex_unlock(&dev->flow_db.lock);
+ kfree(dst);
+
+ return &handler->ibflow;
+
+destroy_ft:
+ put_flow_table(dev, ft_prio, false);
+ if (ft_prio_tx)
+ put_flow_table(dev, ft_prio_tx, false);
+unlock:
+ mutex_unlock(&dev->flow_db.lock);
+ kfree(dst);
+ kfree(handler);
+ return ERR_PTR(err);
+}
+
static int mlx5_ib_mcg_attach(struct ib_qp *ibqp, union ib_gid *gid, u16 lid)
{
struct mlx5_ib_dev *dev = to_mdev(ibqp->device);
int err;
- if (ibqp->qp_type == IB_QPT_RAW_PACKET)
- err = -EOPNOTSUPP;
- else
- err = mlx5_core_attach_mcg(dev->mdev, gid, ibqp->qp_num);
+ err = mlx5_core_attach_mcg(dev->mdev, gid, ibqp->qp_num);
if (err)
mlx5_ib_warn(dev, "failed attaching QPN 0x%x, MGID %pI6\n",
ibqp->qp_num, gid->raw);
@@ -1209,10 +2147,7 @@ static int mlx5_ib_mcg_detach(struct ib_qp *ibqp, union ib_gid *gid, u16 lid)
struct mlx5_ib_dev *dev = to_mdev(ibqp->device);
int err;
- if (ibqp->qp_type == IB_QPT_RAW_PACKET)
- err = -EOPNOTSUPP;
- else
- err = mlx5_core_detach_mcg(dev->mdev, gid, ibqp->qp_num);
+ err = mlx5_core_detach_mcg(dev->mdev, gid, ibqp->qp_num);
if (err)
mlx5_ib_warn(dev, "failed detaching QPN 0x%x, MGID %pI6\n",
ibqp->qp_num, gid->raw);
@@ -1257,21 +2192,12 @@ static ssize_t show_hca(struct device *device, struct device_attribute *attr,
return sprintf(buf, "MT%d\n", dev->mdev->pdev->device);
}
-static ssize_t show_fw_ver(struct device *device, struct device_attribute *attr,
- char *buf)
-{
- struct mlx5_ib_dev *dev =
- container_of(device, struct mlx5_ib_dev, ib_dev.dev);
- return sprintf(buf, "%d.%d.%04d\n", fw_rev_maj(dev->mdev),
- fw_rev_min(dev->mdev), fw_rev_sub(dev->mdev));
-}
-
static ssize_t show_rev(struct device *device, struct device_attribute *attr,
char *buf)
{
struct mlx5_ib_dev *dev =
container_of(device, struct mlx5_ib_dev, ib_dev.dev);
- return sprintf(buf, "%x\n", (unsigned)dev->mdev->pdev->revision);
+ return sprintf(buf, "%x\n", dev->mdev->pdev->revision);
}
static ssize_t show_board(struct device *device, struct device_attribute *attr,
@@ -1284,7 +2210,6 @@ static ssize_t show_board(struct device *device, struct device_attribute *attr,
}
static DEVICE_ATTR(hw_rev, S_IRUGO, show_rev, NULL);
-static DEVICE_ATTR(fw_ver, S_IRUGO, show_fw_ver, NULL);
static DEVICE_ATTR(hca_type, S_IRUGO, show_hca, NULL);
static DEVICE_ATTR(board_id, S_IRUGO, show_board, NULL);
static DEVICE_ATTR(fw_pages, S_IRUGO, show_fw_pages, NULL);
@@ -1292,13 +2217,23 @@ static DEVICE_ATTR(reg_pages, S_IRUGO, show_reg_pages, NULL);
static struct device_attribute *mlx5_class_attributes[] = {
&dev_attr_hw_rev,
- &dev_attr_fw_ver,
&dev_attr_hca_type,
&dev_attr_board_id,
&dev_attr_fw_pages,
&dev_attr_reg_pages,
};
+static void pkey_change_handler(struct work_struct *work)
+{
+ struct mlx5_ib_port_resources *ports =
+ container_of(work, struct mlx5_ib_port_resources,
+ pkey_change_work);
+
+ mutex_lock(&ports->devr->mutex);
+ mlx5_ib_gsi_pkey_change(ports->gsi);
+ mutex_unlock(&ports->devr->mutex);
+}
+
static void mlx5_ib_handle_internal_error(struct mlx5_ib_dev *ibdev)
{
struct mlx5_ib_qp *mqp;
@@ -1309,7 +2244,6 @@ static void mlx5_ib_handle_internal_error(struct mlx5_ib_dev *ibdev)
unsigned long flags_cq;
unsigned long flags;
- mlx5_ib_warn(ibdev, " started\n");
INIT_LIST_HEAD(&cq_armed_list);
/* Go over qp list reside on that ibdev, sync with create/destroy qp.*/
@@ -1357,8 +2291,6 @@ static void mlx5_ib_handle_internal_error(struct mlx5_ib_dev *ibdev)
mcq->comp(mcq);
}
spin_unlock_irqrestore(&ibdev->reset_flow_resource_lock, flags);
- mlx5_ib_warn(ibdev, " ended\n");
- return;
}
static void mlx5_ib_event(struct mlx5_core_dev *dev, void *context,
@@ -1366,25 +2298,30 @@ static void mlx5_ib_event(struct mlx5_core_dev *dev, void *context,
{
struct mlx5_ib_dev *ibdev = (struct mlx5_ib_dev *)context;
struct ib_event ibev;
-
+ bool fatal = false;
u8 port = 0;
switch (event) {
case MLX5_DEV_EVENT_SYS_ERROR:
- ibdev->ib_active = false;
ibev.event = IB_EVENT_DEVICE_FATAL;
mlx5_ib_handle_internal_error(ibdev);
+ fatal = true;
break;
case MLX5_DEV_EVENT_PORT_UP:
- ibev.event = IB_EVENT_PORT_ACTIVE;
- port = (u8)param;
- break;
-
case MLX5_DEV_EVENT_PORT_DOWN:
case MLX5_DEV_EVENT_PORT_INITIALIZED:
- ibev.event = IB_EVENT_PORT_ERR;
port = (u8)param;
+
+ /* In RoCE, port up/down events are handled in
+ * mlx5_netdev_event().
+ */
+ if (mlx5_ib_port_link_layer(&ibdev->ib_dev, port) ==
+ IB_LINK_LAYER_ETHERNET)
+ return;
+
+ ibev.event = (event == MLX5_DEV_EVENT_PORT_UP) ?
+ IB_EVENT_PORT_ACTIVE : IB_EVENT_PORT_ERR;
break;
case MLX5_DEV_EVENT_LID_CHANGE:
@@ -1395,6 +2332,8 @@ static void mlx5_ib_event(struct mlx5_core_dev *dev, void *context,
case MLX5_DEV_EVENT_PKEY_CHANGE:
ibev.event = IB_EVENT_PKEY_CHANGE;
port = (u8)param;
+
+ schedule_work(&ibdev->devr.ports[port - 1].pkey_change_work);
break;
case MLX5_DEV_EVENT_GUID_CHANGE:
@@ -1414,14 +2353,16 @@ static void mlx5_ib_event(struct mlx5_core_dev *dev, void *context,
ibev.device = &ibdev->ib_dev;
ibev.element.port_num = port;
- if ((event != MLX5_DEV_EVENT_SYS_ERROR) &&
- (port < 1 || port > ibdev->num_ports)) {
+ if (port < 1 || port > ibdev->num_ports) {
mlx5_ib_warn(ibdev, "warning: event on port %d\n", port);
return;
}
if (ibdev->ib_active)
ib_dispatch_event(&ibev);
+
+ if (fatal)
+ ibdev->ib_active = false;
}
static void get_ext_port_caps(struct mlx5_ib_dev *dev)
@@ -1432,32 +2373,13 @@ static void get_ext_port_caps(struct mlx5_ib_dev *dev)
mlx5_query_ext_port_caps(dev, port);
}
-static void config_atomic_responder(struct mlx5_ib_dev *dev,
- struct ib_device_attr *props)
-{
- enum ib_atomic_cap cap = props->atomic_cap;
-
-#if 0
- if (cap == IB_ATOMIC_HCA ||
- cap == IB_ATOMIC_GLOB)
-#endif
- dev->enable_atomic_resp = 1;
-
- dev->atomic_cap = cap;
-}
-
-enum mlx5_addr_align {
- MLX5_ADDR_ALIGN_0 = 0,
- MLX5_ADDR_ALIGN_64 = 64,
- MLX5_ADDR_ALIGN_128 = 128,
-};
-
static int get_port_caps(struct mlx5_ib_dev *dev)
{
struct ib_device_attr *dprops = NULL;
struct ib_port_attr *pprops = NULL;
int err = -ENOMEM;
int port;
+ struct ib_udata uhw = {.inlen = 0, .outlen = 0};
pprops = kmalloc(sizeof(*pprops), GFP_KERNEL);
if (!pprops)
@@ -1467,12 +2389,11 @@ static int get_port_caps(struct mlx5_ib_dev *dev)
if (!dprops)
goto out;
- err = mlx5_ib_query_device(&dev->ib_dev, dprops);
+ err = mlx5_ib_query_device(&dev->ib_dev, dprops, &uhw);
if (err) {
mlx5_ib_warn(dev, "query_device failed %d\n", err);
goto out;
}
- config_atomic_responder(dev, dprops);
for (port = 1; port <= MLX5_CAP_GEN(dev->mdev, num_ports); port++) {
err = mlx5_ib_query_port(&dev->ib_dev, port, pprops);
@@ -1481,8 +2402,10 @@ static int get_port_caps(struct mlx5_ib_dev *dev)
port, err);
break;
}
- dev->mdev->port_caps[port - 1].pkey_table_len = dprops->max_pkeys;
- dev->mdev->port_caps[port - 1].gid_table_len = pprops->gid_tbl_len;
+ dev->mdev->port_caps[port - 1].pkey_table_len =
+ dprops->max_pkeys;
+ dev->mdev->port_caps[port - 1].gid_table_len =
+ pprops->gid_tbl_len;
mlx5_ib_dbg(dev, "pkey_table_len %d, gid_table_len %d\n",
dprops->max_pkeys, pprops->gid_tbl_len);
}
@@ -1502,7 +2425,8 @@ static void destroy_umrc_res(struct mlx5_ib_dev *dev)
if (err)
mlx5_ib_warn(dev, "mr cache cleanup failed\n");
- ib_dereg_mr(dev->umrc.mr);
+ mlx5_ib_destroy_qp(dev->umrc.qp);
+ ib_free_cq(dev->umrc.cq);
ib_dealloc_pd(dev->umrc.pd);
}
@@ -1512,40 +2436,107 @@ enum {
static int create_umr_res(struct mlx5_ib_dev *dev)
{
+ struct ib_qp_init_attr *init_attr = NULL;
+ struct ib_qp_attr *attr = NULL;
struct ib_pd *pd;
- struct ib_mr *mr;
+ struct ib_cq *cq;
+ struct ib_qp *qp;
int ret;
- pd = ib_alloc_pd(&dev->ib_dev);
+ attr = kzalloc(sizeof(*attr), GFP_KERNEL);
+ init_attr = kzalloc(sizeof(*init_attr), GFP_KERNEL);
+ if (!attr || !init_attr) {
+ ret = -ENOMEM;
+ goto error_0;
+ }
+
+ pd = ib_alloc_pd(&dev->ib_dev, 0);
if (IS_ERR(pd)) {
mlx5_ib_dbg(dev, "Couldn't create PD for sync UMR QP\n");
ret = PTR_ERR(pd);
goto error_0;
}
- mr = ib_get_dma_mr(pd, IB_ACCESS_LOCAL_WRITE);
- if (IS_ERR(mr)) {
- mlx5_ib_dbg(dev, "Couldn't create DMA MR for sync UMR QP\n");
- ret = PTR_ERR(mr);
- goto error_1;
+ cq = ib_alloc_cq(&dev->ib_dev, NULL, 128, 0, IB_POLL_SOFTIRQ);
+ if (IS_ERR(cq)) {
+ mlx5_ib_dbg(dev, "Couldn't create CQ for sync UMR QP\n");
+ ret = PTR_ERR(cq);
+ goto error_2;
+ }
+
+ init_attr->send_cq = cq;
+ init_attr->recv_cq = cq;
+ init_attr->sq_sig_type = IB_SIGNAL_ALL_WR;
+ init_attr->cap.max_send_wr = MAX_UMR_WR;
+ init_attr->cap.max_send_sge = 1;
+ init_attr->qp_type = MLX5_IB_QPT_REG_UMR;
+ init_attr->port_num = 1;
+ qp = mlx5_ib_create_qp(pd, init_attr, NULL);
+ if (IS_ERR(qp)) {
+ mlx5_ib_dbg(dev, "Couldn't create sync UMR QP\n");
+ ret = PTR_ERR(qp);
+ goto error_3;
+ }
+ qp->device = &dev->ib_dev;
+ qp->real_qp = qp;
+ qp->uobject = NULL;
+ qp->qp_type = MLX5_IB_QPT_REG_UMR;
+
+ attr->qp_state = IB_QPS_INIT;
+ attr->port_num = 1;
+ ret = mlx5_ib_modify_qp(qp, attr, IB_QP_STATE | IB_QP_PKEY_INDEX |
+ IB_QP_PORT, NULL);
+ if (ret) {
+ mlx5_ib_dbg(dev, "Couldn't modify UMR QP\n");
+ goto error_4;
}
- dev->umrc.mr = mr;
+ memset(attr, 0, sizeof(*attr));
+ attr->qp_state = IB_QPS_RTR;
+ attr->path_mtu = IB_MTU_256;
+
+ ret = mlx5_ib_modify_qp(qp, attr, IB_QP_STATE, NULL);
+ if (ret) {
+ mlx5_ib_dbg(dev, "Couldn't modify umr QP to rtr\n");
+ goto error_4;
+ }
+
+ memset(attr, 0, sizeof(*attr));
+ attr->qp_state = IB_QPS_RTS;
+ ret = mlx5_ib_modify_qp(qp, attr, IB_QP_STATE, NULL);
+ if (ret) {
+ mlx5_ib_dbg(dev, "Couldn't modify umr QP to rts\n");
+ goto error_4;
+ }
+
+ dev->umrc.qp = qp;
+ dev->umrc.cq = cq;
dev->umrc.pd = pd;
+ sema_init(&dev->umrc.sem, MAX_UMR_WR);
ret = mlx5_mr_cache_init(dev);
if (ret) {
mlx5_ib_warn(dev, "mr cache init failed %d\n", ret);
goto error_4;
}
+ kfree(attr);
+ kfree(init_attr);
+
return 0;
error_4:
- ib_dereg_mr(mr);
-error_1:
+ mlx5_ib_destroy_qp(qp);
+
+error_3:
+ ib_free_cq(cq);
+
+error_2:
ib_dealloc_pd(pd);
+
error_0:
+ kfree(attr);
+ kfree(init_attr);
return ret;
}
@@ -1553,11 +2544,14 @@ static int create_dev_resources(struct mlx5_ib_resources *devr)
{
struct ib_srq_init_attr attr;
struct mlx5_ib_dev *dev;
+ struct ib_cq_init_attr cq_attr = {.cqe = 1};
+ int port;
int ret = 0;
- struct ib_cq_init_attr cq_attr = { .cqe = 1 };
dev = container_of(devr, struct mlx5_ib_dev, devr);
+ mutex_init(&devr->mutex);
+
devr->p0 = mlx5_ib_alloc_pd(&dev->ib_dev, NULL, NULL);
if (IS_ERR(devr->p0)) {
ret = PTR_ERR(devr->p0);
@@ -1619,7 +2613,7 @@ static int create_dev_resources(struct mlx5_ib_resources *devr)
devr->s0->event_handler = NULL;
devr->s0->srq_context = NULL;
devr->s0->srq_type = IB_SRQT_XRC;
- devr->s0->ext.xrc.xrcd = devr->x0;
+ devr->s0->ext.xrc.xrcd = devr->x0;
devr->s0->ext.xrc.cq = devr->c0;
atomic_inc(&devr->s0->ext.xrc.xrcd->usecnt);
atomic_inc(&devr->s0->ext.xrc.cq->usecnt);
@@ -1643,7 +2637,13 @@ static int create_dev_resources(struct mlx5_ib_resources *devr)
devr->s1->srq_type = IB_SRQT_BASIC;
devr->s1->ext.xrc.cq = devr->c0;
atomic_inc(&devr->p0->usecnt);
- atomic_set(&devr->s1->usecnt, 0);
+ atomic_set(&devr->s0->usecnt, 0);
+
+ for (port = 0; port < ARRAY_SIZE(devr->ports); ++port) {
+ INIT_WORK(&devr->ports[port].pkey_change_work,
+ pkey_change_handler);
+ devr->ports[port].devr = devr;
+ }
return 0;
@@ -1663,12 +2663,20 @@ error0:
static void destroy_dev_resources(struct mlx5_ib_resources *devr)
{
+ struct mlx5_ib_dev *dev =
+ container_of(devr, struct mlx5_ib_dev, devr);
+ int port;
+
mlx5_ib_destroy_srq(devr->s1);
mlx5_ib_destroy_srq(devr->s0);
mlx5_ib_dealloc_xrcd(devr->x0);
mlx5_ib_dealloc_xrcd(devr->x1);
mlx5_ib_destroy_cq(devr->c0);
mlx5_ib_dealloc_pd(devr->p0);
+
+ /* Make sure no change P_Key work items are still executing */
+ for (port = 0; port < dev->num_ports; ++port)
+ cancel_work_sync(&devr->ports[port].pkey_change_work);
}
static u32 get_core_cap_flags(struct ib_device *ibdev)
@@ -1682,13 +2690,11 @@ static u32 get_core_cap_flags(struct ib_device *ibdev)
if (ll == IB_LINK_LAYER_INFINIBAND)
return RDMA_CORE_PORT_IBA_IB;
- ret = RDMA_CORE_PORT_RAW_PACKET;
-
if (!(l3_type_cap & MLX5_ROCE_L3_TYPE_IPV4_CAP))
- return ret;
+ return 0;
if (!(l3_type_cap & MLX5_ROCE_L3_TYPE_IPV6_CAP))
- return ret;
+ return 0;
if (roce_version_cap & MLX5_ROCE_VERSION_1_CAP)
ret |= RDMA_CORE_PORT_IBA_ROCE;
@@ -1703,117 +2709,99 @@ static int mlx5_port_immutable(struct ib_device *ibdev, u8 port_num,
struct ib_port_immutable *immutable)
{
struct ib_port_attr attr;
- struct mlx5_ib_dev *dev = to_mdev(ibdev);
- enum rdma_link_layer ll = mlx5_ib_port_link_layer(ibdev, port_num);
int err;
- immutable->core_cap_flags = get_core_cap_flags(ibdev);
-
- err = ib_query_port(ibdev, port_num, &attr);
+ err = mlx5_ib_query_port(ibdev, port_num, &attr);
if (err)
return err;
immutable->pkey_tbl_len = attr.pkey_tbl_len;
immutable->gid_tbl_len = attr.gid_tbl_len;
immutable->core_cap_flags = get_core_cap_flags(ibdev);
- if ((ll == IB_LINK_LAYER_INFINIBAND) || MLX5_CAP_GEN(dev->mdev, roce))
- immutable->max_mad_size = IB_MGMT_MAD_SIZE;
+ immutable->max_mad_size = IB_MGMT_MAD_SIZE;
return 0;
}
-static void enable_dc_tracer(struct mlx5_ib_dev *dev)
+static void get_dev_fw_str(struct ib_device *ibdev, char *str,
+ size_t str_len)
{
- struct device *device = dev->ib_dev.dma_device;
- struct mlx5_dc_tracer *dct = &dev->dctr;
- int order;
- void *tmp;
- int size;
- int err;
-
- size = MLX5_CAP_GEN(dev->mdev, num_ports) * 4096;
- if (size <= PAGE_SIZE)
- order = 0;
- else
- order = 1;
-
- dct->pg = alloc_pages(GFP_KERNEL, order);
- if (!dct->pg) {
- mlx5_ib_err(dev, "failed to allocate %d pages\n", order);
- return;
- }
+ struct mlx5_ib_dev *dev =
+ container_of(ibdev, struct mlx5_ib_dev, ib_dev);
+ snprintf(str, str_len, "%d.%d.%04d", fw_rev_maj(dev->mdev),
+ fw_rev_min(dev->mdev), fw_rev_sub(dev->mdev));
+}
- tmp = page_address(dct->pg);
- memset(tmp, 0xff, size);
+static int mlx5_roce_lag_init(struct mlx5_ib_dev *dev)
+{
+ return 0;
+}
- dct->size = size;
- dct->order = order;
- dct->dma = dma_map_page(device, dct->pg, 0, size, DMA_FROM_DEVICE);
- if (dma_mapping_error(device, dct->dma)) {
- mlx5_ib_err(dev, "dma mapping error\n");
- goto map_err;
- }
+static void mlx5_roce_lag_cleanup(struct mlx5_ib_dev *dev)
+{
+}
- err = mlx5_core_set_dc_cnak_trace(dev->mdev, 1, dct->dma);
- if (err) {
- mlx5_ib_warn(dev, "failed to enable DC tracer\n");
- goto cmd_err;
+static void mlx5_remove_roce_notifier(struct mlx5_ib_dev *dev)
+{
+ if (dev->roce.nb.notifier_call) {
+ unregister_netdevice_notifier(&dev->roce.nb);
+ dev->roce.nb.notifier_call = NULL;
}
-
- return;
-
-cmd_err:
- dma_unmap_page(device, dct->dma, size, DMA_FROM_DEVICE);
-map_err:
- __free_pages(dct->pg, dct->order);
- dct->pg = NULL;
}
-static void disable_dc_tracer(struct mlx5_ib_dev *dev)
+static int mlx5_enable_roce(struct mlx5_ib_dev *dev)
{
- struct device *device = dev->ib_dev.dma_device;
- struct mlx5_dc_tracer *dct = &dev->dctr;
+ VNET_ITERATOR_DECL(vnet_iter);
+ struct net_device *idev;
int err;
- if (!dct->pg)
- return;
+ /* Check if mlx5en net device already exists */
+ VNET_LIST_RLOCK();
+ VNET_FOREACH(vnet_iter) {
+ IFNET_RLOCK();
+ CURVNET_SET_QUIET(vnet_iter);
+ TAILQ_FOREACH(idev, &V_ifnet, if_link) {
+ /* check if network interface belongs to mlx5en */
+ if (!mlx5_netdev_match(idev, dev->mdev, "mce"))
+ continue;
+ write_lock(&dev->roce.netdev_lock);
+ dev->roce.netdev = idev;
+ write_unlock(&dev->roce.netdev_lock);
+ }
+ CURVNET_RESTORE();
+ IFNET_RUNLOCK();
+ }
+ VNET_LIST_RUNLOCK();
- err = mlx5_core_set_dc_cnak_trace(dev->mdev, 0, dct->dma);
+ dev->roce.nb.notifier_call = mlx5_netdev_event;
+ err = register_netdevice_notifier(&dev->roce.nb);
if (err) {
- mlx5_ib_warn(dev, "failed to disable DC tracer\n");
- return;
+ dev->roce.nb.notifier_call = NULL;
+ return err;
}
- dma_unmap_page(device, dct->dma, dct->size, DMA_FROM_DEVICE);
- __free_pages(dct->pg, dct->order);
- dct->pg = NULL;
-}
-
-enum {
- MLX5_DC_CNAK_SIZE = 128,
- MLX5_NUM_BUF_IN_PAGE = PAGE_SIZE / MLX5_DC_CNAK_SIZE,
- MLX5_CNAK_TX_CQ_SIGNAL_FACTOR = 128,
- MLX5_DC_CNAK_SL = 0,
- MLX5_DC_CNAK_VL = 0,
-};
+ err = mlx5_nic_vport_enable_roce(dev->mdev);
+ if (err)
+ goto err_unregister_netdevice_notifier;
-static int init_dc_improvements(struct mlx5_ib_dev *dev)
-{
- if (!mlx5_core_is_pf(dev->mdev))
- return 0;
+ err = mlx5_roce_lag_init(dev);
+ if (err)
+ goto err_disable_roce;
- if (!(MLX5_CAP_GEN(dev->mdev, dc_cnak_trace)))
- return 0;
+ return 0;
- enable_dc_tracer(dev);
+err_disable_roce:
+ mlx5_nic_vport_disable_roce(dev->mdev);
- return 0;
+err_unregister_netdevice_notifier:
+ mlx5_remove_roce_notifier(dev);
+ return err;
}
-static void cleanup_dc_improvements(struct mlx5_ib_dev *dev)
+static void mlx5_disable_roce(struct mlx5_ib_dev *dev)
{
-
- disable_dc_tracer(dev);
+ mlx5_roce_lag_cleanup(dev);
+ mlx5_nic_vport_disable_roce(dev->mdev);
}
static void mlx5_ib_dealloc_q_port_counter(struct mlx5_ib_dev *dev, u8 port_num)
@@ -1843,8 +2831,8 @@ static int mlx5_ib_alloc_q_counters(struct mlx5_ib_dev *dev)
&dev->port[i].q_cnt_id);
if (ret) {
mlx5_ib_warn(dev,
- "couldn't allocate queue counter for port %d\n",
- i + 1);
+ "couldn't allocate queue counter for port %d, err %d\n",
+ i + 1, ret);
goto dealloc_counters;
}
}
@@ -1858,199 +2846,93 @@ dealloc_counters:
return ret;
}
-struct port_attribute {
- struct attribute attr;
- ssize_t (*show)(struct mlx5_ib_port *,
- struct port_attribute *, char *buf);
- ssize_t (*store)(struct mlx5_ib_port *,
- struct port_attribute *,
- const char *buf, size_t count);
+static const char * const names[] = {
+ "rx_write_requests",
+ "rx_read_requests",
+ "rx_atomic_requests",
+ "out_of_buffer",
+ "out_of_sequence",
+ "duplicate_request",
+ "rnr_nak_retry_err",
+ "packet_seq_err",
+ "implied_nak_seq_err",
+ "local_ack_timeout_err",
};
-struct port_counter_attribute {
- struct port_attribute attr;
- size_t offset;
+static const size_t stats_offsets[] = {
+ MLX5_BYTE_OFF(query_q_counter_out, rx_write_requests),
+ MLX5_BYTE_OFF(query_q_counter_out, rx_read_requests),
+ MLX5_BYTE_OFF(query_q_counter_out, rx_atomic_requests),
+ MLX5_BYTE_OFF(query_q_counter_out, out_of_buffer),
+ MLX5_BYTE_OFF(query_q_counter_out, out_of_sequence),
+ MLX5_BYTE_OFF(query_q_counter_out, duplicate_request),
+ MLX5_BYTE_OFF(query_q_counter_out, rnr_nak_retry_err),
+ MLX5_BYTE_OFF(query_q_counter_out, packet_seq_err),
+ MLX5_BYTE_OFF(query_q_counter_out, implied_nak_seq_err),
+ MLX5_BYTE_OFF(query_q_counter_out, local_ack_timeout_err),
};
-static ssize_t port_attr_show(struct kobject *kobj,
- struct attribute *attr, char *buf)
+static struct rdma_hw_stats *mlx5_ib_alloc_hw_stats(struct ib_device *ibdev,
+ u8 port_num)
{
- struct port_attribute *port_attr =
- container_of(attr, struct port_attribute, attr);
- struct mlx5_ib_port_sysfs_group *p =
- container_of(kobj, struct mlx5_ib_port_sysfs_group,
- kobj);
- struct mlx5_ib_port *mibport = container_of(p, struct mlx5_ib_port,
- group);
+ BUILD_BUG_ON(ARRAY_SIZE(names) != ARRAY_SIZE(stats_offsets));
- if (!port_attr->show)
- return -EIO;
+ /* We support only per port stats */
+ if (port_num == 0)
+ return NULL;
- return port_attr->show(mibport, port_attr, buf);
+ return rdma_alloc_hw_stats_struct(names, ARRAY_SIZE(names),
+ RDMA_HW_STATS_DEFAULT_LIFESPAN);
}
-static ssize_t show_port_counter(struct mlx5_ib_port *p,
- struct port_attribute *port_attr,
- char *buf)
+static int mlx5_ib_get_hw_stats(struct ib_device *ibdev,
+ struct rdma_hw_stats *stats,
+ u8 port, int index)
{
+ struct mlx5_ib_dev *dev = to_mdev(ibdev);
int outlen = MLX5_ST_SZ_BYTES(query_q_counter_out);
- struct port_counter_attribute *counter_attr =
- container_of(port_attr, struct port_counter_attribute, attr);
void *out;
+ __be32 val;
int ret;
+ int i;
+
+ if (!port || !stats)
+ return -ENOSYS;
out = mlx5_vzalloc(outlen);
if (!out)
return -ENOMEM;
- ret = mlx5_vport_query_q_counter(p->dev->mdev,
- p->q_cnt_id, 0,
- out, outlen);
+ ret = mlx5_vport_query_q_counter(dev->mdev,
+ dev->port[port - 1].q_cnt_id, 0,
+ out, outlen);
if (ret)
goto free;
- ret = sprintf(buf, "%d\n",
- be32_to_cpu(*(__be32 *)(out + counter_attr->offset)));
-
-free:
- kfree(out);
- return ret;
-}
-
-#define PORT_COUNTER_ATTR(_name) \
-struct port_counter_attribute port_counter_attr_##_name = { \
- .attr = __ATTR(_name, S_IRUGO, show_port_counter, NULL), \
- .offset = MLX5_BYTE_OFF(query_q_counter_out, _name) \
-}
-
-static PORT_COUNTER_ATTR(rx_write_requests);
-static PORT_COUNTER_ATTR(rx_read_requests);
-static PORT_COUNTER_ATTR(rx_atomic_requests);
-static PORT_COUNTER_ATTR(rx_dct_connect);
-static PORT_COUNTER_ATTR(out_of_buffer);
-static PORT_COUNTER_ATTR(out_of_sequence);
-static PORT_COUNTER_ATTR(duplicate_request);
-static PORT_COUNTER_ATTR(rnr_nak_retry_err);
-static PORT_COUNTER_ATTR(packet_seq_err);
-static PORT_COUNTER_ATTR(implied_nak_seq_err);
-static PORT_COUNTER_ATTR(local_ack_timeout_err);
-
-static struct attribute *counter_attrs[] = {
- &port_counter_attr_rx_write_requests.attr.attr,
- &port_counter_attr_rx_read_requests.attr.attr,
- &port_counter_attr_rx_atomic_requests.attr.attr,
- &port_counter_attr_rx_dct_connect.attr.attr,
- &port_counter_attr_out_of_buffer.attr.attr,
- &port_counter_attr_out_of_sequence.attr.attr,
- &port_counter_attr_duplicate_request.attr.attr,
- &port_counter_attr_rnr_nak_retry_err.attr.attr,
- &port_counter_attr_packet_seq_err.attr.attr,
- &port_counter_attr_implied_nak_seq_err.attr.attr,
- &port_counter_attr_local_ack_timeout_err.attr.attr,
- NULL
-};
-
-static struct attribute_group port_counters_group = {
- .name = "counters",
- .attrs = counter_attrs
-};
-
-static const struct sysfs_ops port_sysfs_ops = {
- .show = port_attr_show
-};
-
-static struct kobj_type port_type = {
- .sysfs_ops = &port_sysfs_ops,
-};
-
-static int add_port_attrs(struct mlx5_ib_dev *dev,
- struct kobject *parent,
- struct mlx5_ib_port_sysfs_group *port,
- u8 port_num)
-{
- int ret;
-
- ret = kobject_init_and_add(&port->kobj, &port_type,
- parent,
- "%d", port_num);
- if (ret)
- return ret;
-
- if (MLX5_CAP_GEN(dev->mdev, out_of_seq_cnt) &&
- MLX5_CAP_GEN(dev->mdev, retransmission_q_counters)) {
- ret = sysfs_create_group(&port->kobj, &port_counters_group);
- if (ret)
- goto put_kobj;
- }
-
- port->enabled = true;
- return ret;
-
-put_kobj:
- kobject_put(&port->kobj);
- return ret;
-}
-
-static void destroy_ports_attrs(struct mlx5_ib_dev *dev,
- unsigned int num_ports)
-{
- unsigned int i;
-
- for (i = 0; i < num_ports; i++) {
- struct mlx5_ib_port_sysfs_group *port =
- &dev->port[i].group;
-
- if (!port->enabled)
- continue;
-
- if (MLX5_CAP_GEN(dev->mdev, out_of_seq_cnt) &&
- MLX5_CAP_GEN(dev->mdev, retransmission_q_counters))
- sysfs_remove_group(&port->kobj,
- &port_counters_group);
- kobject_put(&port->kobj);
- port->enabled = false;
- }
-
- if (dev->ports_parent) {
- kobject_put(dev->ports_parent);
- dev->ports_parent = NULL;
+ for (i = 0; i < ARRAY_SIZE(names); i++) {
+ val = *(__be32 *)(out + stats_offsets[i]);
+ stats->value[i] = (u64)be32_to_cpu(val);
}
-}
-
-static int create_port_attrs(struct mlx5_ib_dev *dev)
-{
- int ret = 0;
- unsigned int i = 0;
- struct device *device = &dev->ib_dev.dev;
-
- dev->ports_parent = kobject_create_and_add("mlx5_ports",
- &device->kobj);
- if (!dev->ports_parent)
- return -ENOMEM;
-
- for (i = 0; i < dev->num_ports; i++) {
- ret = add_port_attrs(dev,
- dev->ports_parent,
- &dev->port[i].group,
- i + 1);
-
- if (ret)
- goto _destroy_ports_attrs;
- }
-
- return 0;
-
-_destroy_ports_attrs:
- destroy_ports_attrs(dev, i);
- return ret;
+free:
+ kvfree(out);
+ return ARRAY_SIZE(names);
}
static void *mlx5_ib_add(struct mlx5_core_dev *mdev)
{
struct mlx5_ib_dev *dev;
+ enum rdma_link_layer ll;
+ int port_type_cap;
+ const char *name;
int err;
int i;
+ port_type_cap = MLX5_CAP_GEN(mdev, port_type);
+ ll = mlx5_port_type_cap_to_rdma_ll(port_type_cap);
+
+ if ((ll == IB_LINK_LAYER_ETHERNET) && !MLX5_CAP_GEN(mdev, roce))
+ return NULL;
+
printk_once(KERN_INFO "%s", mlx5_version);
dev = (struct mlx5_ib_dev *)ib_alloc_device(sizeof(*dev));
@@ -2060,17 +2942,11 @@ static void *mlx5_ib_add(struct mlx5_core_dev *mdev)
dev->mdev = mdev;
dev->port = kcalloc(MLX5_CAP_GEN(mdev, num_ports), sizeof(*dev->port),
- GFP_KERNEL);
+ GFP_KERNEL);
if (!dev->port)
goto err_dealloc;
- for (i = 0; i < MLX5_CAP_GEN(mdev, num_ports); i++) {
- dev->port[i].dev = dev;
- dev->port[i].port_num = i;
- dev->port[i].port_gone = 0;
- memset(dev->port[i].gid_table, 0, sizeof(dev->port[i].gid_table));
- }
-
+ rwlock_init(&dev->roce.netdev_lock);
err = get_port_caps(dev);
if (err)
goto err_free_port;
@@ -2078,23 +2954,14 @@ static void *mlx5_ib_add(struct mlx5_core_dev *mdev)
if (mlx5_use_mad_ifc(dev))
get_ext_port_caps(dev);
- if (mlx5_ib_port_link_layer(&dev->ib_dev, 1) ==
- IB_LINK_LAYER_ETHERNET) {
- if (MLX5_CAP_GEN(mdev, roce)) {
- err = mlx5_nic_vport_enable_roce(mdev);
- if (err)
- goto err_free_port;
- } else {
- goto err_free_port;
- }
- }
-
MLX5_INIT_DOORBELL_LOCK(&dev->uar_lock);
- strlcpy(dev->ib_dev.name, "mlx5_%d", IB_DEVICE_NAME_MAX);
+ name = "mlx5_%d";
+
+ strlcpy(dev->ib_dev.name, name, IB_DEVICE_NAME_MAX);
dev->ib_dev.owner = THIS_MODULE;
dev->ib_dev.node_type = RDMA_NODE_IB_CA;
- dev->ib_dev.local_dma_lkey = mdev->special_contexts.resd_lkey;
+ dev->ib_dev.local_dma_lkey = 0 /* not supported for now */;
dev->num_ports = MLX5_CAP_GEN(mdev, num_ports);
dev->ib_dev.phys_port_cnt = dev->num_ports;
dev->ib_dev.num_comp_vectors =
@@ -2109,6 +2976,7 @@ static void *mlx5_ib_add(struct mlx5_core_dev *mdev)
(1ull << IB_USER_VERBS_CMD_ALLOC_PD) |
(1ull << IB_USER_VERBS_CMD_DEALLOC_PD) |
(1ull << IB_USER_VERBS_CMD_REG_MR) |
+ (1ull << IB_USER_VERBS_CMD_REREG_MR) |
(1ull << IB_USER_VERBS_CMD_DEREG_MR) |
(1ull << IB_USER_VERBS_CMD_CREATE_COMP_CHANNEL) |
(1ull << IB_USER_VERBS_CMD_CREATE_CQ) |
@@ -2126,12 +2994,19 @@ static void *mlx5_ib_add(struct mlx5_core_dev *mdev)
(1ull << IB_USER_VERBS_CMD_DESTROY_SRQ) |
(1ull << IB_USER_VERBS_CMD_CREATE_XSRQ) |
(1ull << IB_USER_VERBS_CMD_OPEN_QP);
+ dev->ib_dev.uverbs_ex_cmd_mask =
+ (1ull << IB_USER_VERBS_EX_CMD_QUERY_DEVICE) |
+ (1ull << IB_USER_VERBS_EX_CMD_CREATE_CQ) |
+ (1ull << IB_USER_VERBS_EX_CMD_CREATE_QP);
dev->ib_dev.query_device = mlx5_ib_query_device;
dev->ib_dev.query_port = mlx5_ib_query_port;
dev->ib_dev.get_link_layer = mlx5_ib_port_link_layer;
- dev->ib_dev.get_netdev = mlx5_ib_get_netdev;
+ if (ll == IB_LINK_LAYER_ETHERNET)
+ dev->ib_dev.get_netdev = mlx5_ib_get_netdev;
dev->ib_dev.query_gid = mlx5_ib_query_gid;
+ dev->ib_dev.add_gid = mlx5_ib_add_gid;
+ dev->ib_dev.del_gid = mlx5_ib_del_gid;
dev->ib_dev.query_pkey = mlx5_ib_query_pkey;
dev->ib_dev.modify_device = mlx5_ib_modify_device;
dev->ib_dev.modify_port = mlx5_ib_modify_port;
@@ -2162,15 +3037,41 @@ static void *mlx5_ib_add(struct mlx5_core_dev *mdev)
dev->ib_dev.req_notify_cq = mlx5_ib_arm_cq;
dev->ib_dev.get_dma_mr = mlx5_ib_get_dma_mr;
dev->ib_dev.reg_user_mr = mlx5_ib_reg_user_mr;
+ dev->ib_dev.rereg_user_mr = mlx5_ib_rereg_user_mr;
dev->ib_dev.reg_phys_mr = mlx5_ib_reg_phys_mr;
dev->ib_dev.dereg_mr = mlx5_ib_dereg_mr;
dev->ib_dev.attach_mcast = mlx5_ib_mcg_attach;
dev->ib_dev.detach_mcast = mlx5_ib_mcg_detach;
dev->ib_dev.process_mad = mlx5_ib_process_mad;
+ dev->ib_dev.alloc_mr = mlx5_ib_alloc_mr;
+ dev->ib_dev.map_mr_sg = mlx5_ib_map_mr_sg;
+ dev->ib_dev.check_mr_status = mlx5_ib_check_mr_status;
dev->ib_dev.get_port_immutable = mlx5_port_immutable;
- dev->ib_dev.alloc_fast_reg_mr = mlx5_ib_alloc_fast_reg_mr;
- dev->ib_dev.alloc_fast_reg_page_list = mlx5_ib_alloc_fast_reg_page_list;
- dev->ib_dev.free_fast_reg_page_list = mlx5_ib_free_fast_reg_page_list;
+ dev->ib_dev.get_dev_fw_str = get_dev_fw_str;
+ if (mlx5_core_is_pf(mdev)) {
+ dev->ib_dev.get_vf_config = mlx5_ib_get_vf_config;
+ dev->ib_dev.set_vf_link_state = mlx5_ib_set_vf_link_state;
+ dev->ib_dev.get_vf_stats = mlx5_ib_get_vf_stats;
+ dev->ib_dev.set_vf_guid = mlx5_ib_set_vf_guid;
+ }
+
+ dev->ib_dev.disassociate_ucontext = mlx5_ib_disassociate_ucontext;
+
+ mlx5_ib_internal_fill_odp_caps(dev);
+
+ if (MLX5_CAP_GEN(mdev, imaicl)) {
+ dev->ib_dev.alloc_mw = mlx5_ib_alloc_mw;
+ dev->ib_dev.dealloc_mw = mlx5_ib_dealloc_mw;
+ dev->ib_dev.uverbs_cmd_mask |=
+ (1ull << IB_USER_VERBS_CMD_ALLOC_MW) |
+ (1ull << IB_USER_VERBS_CMD_DEALLOC_MW);
+ }
+
+ if (MLX5_CAP_GEN(dev->mdev, out_of_seq_cnt) &&
+ MLX5_CAP_GEN(dev->mdev, retransmission_q_counters)) {
+ dev->ib_dev.get_hw_stats = mlx5_ib_get_hw_stats;
+ dev->ib_dev.alloc_hw_stats = mlx5_ib_alloc_hw_stats;
+ }
if (MLX5_CAP_GEN(mdev, xrc)) {
dev->ib_dev.alloc_xrcd = mlx5_ib_alloc_xrcd;
@@ -2180,18 +3081,46 @@ static void *mlx5_ib_add(struct mlx5_core_dev *mdev)
(1ull << IB_USER_VERBS_CMD_CLOSE_XRCD);
}
+ if (mlx5_ib_port_link_layer(&dev->ib_dev, 1) ==
+ IB_LINK_LAYER_ETHERNET) {
+ dev->ib_dev.create_flow = mlx5_ib_create_flow;
+ dev->ib_dev.destroy_flow = mlx5_ib_destroy_flow;
+ dev->ib_dev.create_wq = mlx5_ib_create_wq;
+ dev->ib_dev.modify_wq = mlx5_ib_modify_wq;
+ dev->ib_dev.destroy_wq = mlx5_ib_destroy_wq;
+ dev->ib_dev.create_rwq_ind_table = mlx5_ib_create_rwq_ind_table;
+ dev->ib_dev.destroy_rwq_ind_table = mlx5_ib_destroy_rwq_ind_table;
+ dev->ib_dev.uverbs_ex_cmd_mask |=
+ (1ull << IB_USER_VERBS_EX_CMD_CREATE_FLOW) |
+ (1ull << IB_USER_VERBS_EX_CMD_DESTROY_FLOW) |
+ (1ull << IB_USER_VERBS_EX_CMD_CREATE_WQ) |
+ (1ull << IB_USER_VERBS_EX_CMD_MODIFY_WQ) |
+ (1ull << IB_USER_VERBS_EX_CMD_DESTROY_WQ) |
+ (1ull << IB_USER_VERBS_EX_CMD_CREATE_RWQ_IND_TBL) |
+ (1ull << IB_USER_VERBS_EX_CMD_DESTROY_RWQ_IND_TBL);
+ }
err = init_node_data(dev);
if (err)
- goto err_disable_roce;
+ goto err_free_port;
+ mutex_init(&dev->flow_db.lock);
mutex_init(&dev->cap_mask_mutex);
INIT_LIST_HEAD(&dev->qp_list);
spin_lock_init(&dev->reset_flow_resource_lock);
+ if (ll == IB_LINK_LAYER_ETHERNET) {
+ err = mlx5_enable_roce(dev);
+ if (err)
+ goto err_free_port;
+ }
+
err = create_dev_resources(&dev->devr);
if (err)
goto err_disable_roce;
+ err = mlx5_ib_odp_init_one(dev);
+ if (err)
+ goto err_rsrc;
err = mlx5_ib_alloc_q_counters(dev);
if (err)
@@ -2205,44 +3134,18 @@ static void *mlx5_ib_add(struct mlx5_core_dev *mdev)
if (err)
goto err_dev;
- if (MLX5_CAP_GEN(dev->mdev, port_type) ==
- MLX5_CAP_PORT_TYPE_IB) {
- if (init_dc_improvements(dev))
- mlx5_ib_dbg(dev, "init_dc_improvements - continuing\n");
- }
-
- err = create_port_attrs(dev);
- if (err)
- goto err_dc;
-
for (i = 0; i < ARRAY_SIZE(mlx5_class_attributes); i++) {
err = device_create_file(&dev->ib_dev.dev,
mlx5_class_attributes[i]);
if (err)
- goto err_port_attrs;
- }
-
- if (1) {
- struct thread *rl_thread = NULL;
- struct proc *rl_proc = NULL;
-
- for (i = 0; i < MLX5_CAP_GEN(mdev, num_ports); i++) {
- (void) kproc_kthread_add(mlx5_ib_roce_port_update, dev->port + i, &rl_proc, &rl_thread,
- RFHIGHPID, 0, "mlx5-ib-roce-port", "mlx5-ib-roce_port-%d", i);
- }
+ goto err_umrc;
}
dev->ib_active = true;
return dev;
-err_port_attrs:
- destroy_ports_attrs(dev, dev->num_ports);
-
-err_dc:
- if (MLX5_CAP_GEN(dev->mdev, port_type) ==
- MLX5_CAP_PORT_TYPE_IB)
- cleanup_dc_improvements(dev);
+err_umrc:
destroy_umrc_res(dev);
err_dev:
@@ -2252,12 +3155,17 @@ err_q_cnt:
mlx5_ib_dealloc_q_counters(dev);
err_odp:
+ mlx5_ib_odp_remove_one(dev);
+
+err_rsrc:
destroy_dev_resources(&dev->devr);
err_disable_roce:
- if (mlx5_ib_port_link_layer(&dev->ib_dev, 1) ==
- IB_LINK_LAYER_ETHERNET && MLX5_CAP_GEN(mdev, roce))
- mlx5_nic_vport_disable_roce(mdev);
+ if (ll == IB_LINK_LAYER_ETHERNET) {
+ mlx5_disable_roce(dev);
+ mlx5_remove_roce_notifier(dev);
+ }
+
err_free_port:
kfree(dev->port);
@@ -2270,32 +3178,16 @@ err_dealloc:
static void mlx5_ib_remove(struct mlx5_core_dev *mdev, void *context)
{
struct mlx5_ib_dev *dev = context;
- int i;
+ enum rdma_link_layer ll = mlx5_ib_port_link_layer(&dev->ib_dev, 1);
- for (i = 0; i < MLX5_CAP_GEN(mdev, num_ports); i++) {
- dev->port[i].port_gone = 1;
- while (dev->port[i].port_gone != 2)
- pause("W", hz);
- }
-
- for (i = 0; i < ARRAY_SIZE(mlx5_class_attributes); i++) {
- device_remove_file(&dev->ib_dev.dev,
- mlx5_class_attributes[i]);
- }
-
- destroy_ports_attrs(dev, dev->num_ports);
- if (MLX5_CAP_GEN(dev->mdev, port_type) ==
- MLX5_CAP_PORT_TYPE_IB)
- cleanup_dc_improvements(dev);
- mlx5_ib_dealloc_q_counters(dev);
+ mlx5_remove_roce_notifier(dev);
ib_unregister_device(&dev->ib_dev);
+ mlx5_ib_dealloc_q_counters(dev);
destroy_umrc_res(dev);
+ mlx5_ib_odp_remove_one(dev);
destroy_dev_resources(&dev->devr);
-
- if (mlx5_ib_port_link_layer(&dev->ib_dev, 1) ==
- IB_LINK_LAYER_ETHERNET && MLX5_CAP_GEN(mdev, roce))
- mlx5_nic_vport_disable_roce(mdev);
-
+ if (ll == IB_LINK_LAYER_ETHERNET)
+ mlx5_disable_roce(dev);
kfree(dev->port);
ib_dealloc_device(&dev->ib_dev);
}
@@ -2312,31 +3204,27 @@ static int __init mlx5_ib_init(void)
int err;
if (deprecated_prof_sel != 2)
- printf("mlx5_ib: WARN: ""prof_sel is deprecated for mlx5_ib, set it for mlx5_core\n");
+ pr_warn("prof_sel is deprecated for mlx5_ib, set it for mlx5_core\n");
+
+ err = mlx5_ib_odp_init();
+ if (err)
+ return err;
err = mlx5_register_interface(&mlx5_ib_interface);
if (err)
goto clean_odp;
- mlx5_ib_wq = create_singlethread_workqueue("mlx5_ib_wq");
- if (!mlx5_ib_wq) {
- printf("mlx5_ib: ERR: ""%s: failed to create mlx5_ib_wq\n", __func__);
- goto err_unreg;
- }
-
return err;
-err_unreg:
- mlx5_unregister_interface(&mlx5_ib_interface);
-
clean_odp:
+ mlx5_ib_odp_cleanup();
return err;
}
static void __exit mlx5_ib_cleanup(void)
{
- destroy_workqueue(mlx5_ib_wq);
mlx5_unregister_interface(&mlx5_ib_interface);
+ mlx5_ib_odp_cleanup();
}
module_init_order(mlx5_ib_init, SI_ORDER_THIRD);
diff --git a/sys/dev/mlx5/mlx5_ib/mlx5_ib_mem.c b/sys/dev/mlx5/mlx5_ib/mlx5_ib_mem.c
index f942f8b..58f985b 100644
--- a/sys/dev/mlx5/mlx5_ib/mlx5_ib_mem.c
+++ b/sys/dev/mlx5/mlx5_ib/mlx5_ib_mem.c
@@ -27,10 +27,9 @@
#include <linux/module.h>
#include <rdma/ib_umem.h>
+#include <rdma/ib_umem_odp.h>
#include "mlx5_ib.h"
-CTASSERT(sizeof(uintptr_t) == sizeof(unsigned long));
-
/* @umem: umem object to scan
* @addr: ib virtual address requested by the user
* @count: number of PAGE_SIZE pages covered by umem
@@ -38,7 +37,6 @@ CTASSERT(sizeof(uintptr_t) == sizeof(unsigned long));
* @ncont: number of compund pages
* @order: log2 of the number of compound pages
*/
-
void mlx5_ib_cont_pages(struct ib_umem *umem, u64 addr, int *count, int *shift,
int *ncont, int *order)
{
@@ -55,29 +53,38 @@ void mlx5_ib_cont_pages(struct ib_umem *umem, u64 addr, int *count, int *shift,
int entry;
unsigned long page_shift = ilog2(umem->page_size);
+ /* With ODP we must always match OS page size. */
+ if (umem->odp_data) {
+ *count = ib_umem_page_count(umem);
+ *shift = PAGE_SHIFT;
+ *ncont = *count;
+ if (order)
+ *order = ilog2(roundup_pow_of_two(*count));
+
+ return;
+ }
+
addr = addr >> page_shift;
- tmp = (uintptr_t)addr;
- m = find_first_bit(&tmp, 8 * sizeof(tmp));
+ tmp = (unsigned long)addr;
+ m = find_first_bit(&tmp, BITS_PER_LONG);
skip = 1 << m;
mask = skip - 1;
i = 0;
-
for_each_sg(umem->sg_head.sgl, sg, umem->nmap, entry) {
len = sg_dma_len(sg) >> page_shift;
pfn = sg_dma_address(sg) >> page_shift;
for (k = 0; k < len; k++) {
if (!(i & mask)) {
- tmp = (uintptr_t)pfn;
- m = min_t(unsigned long, m,
- find_first_bit(&tmp, 8 * sizeof(tmp)));
+ tmp = (unsigned long)pfn;
+ m = min_t(unsigned long, m, find_first_bit(&tmp, BITS_PER_LONG));
skip = 1 << m;
mask = skip - 1;
base = pfn;
p = 0;
} else {
if (base + p != pfn) {
- tmp = (uintptr_t)p;
- m = find_first_bit(&tmp, 8 * sizeof(tmp));
+ tmp = (unsigned long)p;
+ m = find_first_bit(&tmp, BITS_PER_LONG);
skip = 1 << m;
mask = skip - 1;
base = pfn;
@@ -108,6 +115,20 @@ void mlx5_ib_cont_pages(struct ib_umem *umem, u64 addr, int *count, int *shift,
*count = i;
}
+#ifdef CONFIG_INFINIBAND_ON_DEMAND_PAGING
+static u64 umem_dma_to_mtt(dma_addr_t umem_dma)
+{
+ u64 mtt_entry = umem_dma & ODP_DMA_ADDR_MASK;
+
+ if (umem_dma & ODP_READ_ALLOWED_BIT)
+ mtt_entry |= MLX5_IB_MTT_READ;
+ if (umem_dma & ODP_WRITE_ALLOWED_BIT)
+ mtt_entry |= MLX5_IB_MTT_WRITE;
+
+ return mtt_entry;
+}
+#endif
+
/*
* Populate the given array with bus addresses from the umem.
*
@@ -121,8 +142,8 @@ void mlx5_ib_cont_pages(struct ib_umem *umem, u64 addr, int *count, int *shift,
* access_flags - access flags to set on all present pages.
use enum mlx5_ib_mtt_access_flags for this.
*/
-static void __mlx5_ib_populate_pas(struct mlx5_ib_dev *dev, struct ib_umem *umem,
- int page_shift, size_t offset,
+void __mlx5_ib_populate_pas(struct mlx5_ib_dev *dev, struct ib_umem *umem,
+ int page_shift, size_t offset, size_t num_pages,
__be64 *pas, int access_flags)
{
unsigned long umem_page_shift = ilog2(umem->page_size);
@@ -134,6 +155,21 @@ static void __mlx5_ib_populate_pas(struct mlx5_ib_dev *dev, struct ib_umem *umem
int len;
struct scatterlist *sg;
int entry;
+#ifdef CONFIG_INFINIBAND_ON_DEMAND_PAGING
+ const bool odp = umem->odp_data != NULL;
+
+ if (odp) {
+ WARN_ON(shift != 0);
+ WARN_ON(access_flags != (MLX5_IB_MTT_READ | MLX5_IB_MTT_WRITE));
+
+ for (i = 0; i < num_pages; ++i) {
+ dma_addr_t pa = umem->odp_data->dma_list[offset + i];
+
+ pas[i] = cpu_to_be64(umem_dma_to_mtt(pa));
+ }
+ return;
+ }
+#endif
i = 0;
for_each_sg(umem->sg_head.sgl, sg, umem->nmap, entry) {
@@ -146,12 +182,10 @@ static void __mlx5_ib_populate_pas(struct mlx5_ib_dev *dev, struct ib_umem *umem
pas[i >> shift] = cpu_to_be64(cur);
mlx5_ib_dbg(dev, "pas[%d] 0x%llx\n",
- i >> shift, (unsigned long long)
- be64_to_cpu(pas[i >> shift]));
+ i >> shift, (long long)be64_to_cpu(pas[i >> shift]));
} else
mlx5_ib_dbg(dev, "=====> 0x%llx\n",
- (unsigned long long)
- (base + (k << umem_page_shift)));
+ (long long)(base + (k << umem_page_shift)));
i++;
}
}
@@ -161,10 +195,9 @@ void mlx5_ib_populate_pas(struct mlx5_ib_dev *dev, struct ib_umem *umem,
int page_shift, __be64 *pas, int access_flags)
{
return __mlx5_ib_populate_pas(dev, umem, page_shift, 0,
- pas,
+ ib_umem_num_pages(umem), pas,
access_flags);
}
-
int mlx5_ib_get_buf_offset(u64 addr, int page_shift, u32 *offset)
{
u64 page_size;
@@ -182,6 +215,6 @@ int mlx5_ib_get_buf_offset(u64 addr, int page_shift, u32 *offset)
if (buf_off & off_mask)
return -EINVAL;
- *offset = (u32)(buf_off >> ilog2(off_size));
+ *offset = buf_off >> ilog2(off_size);
return 0;
}
diff --git a/sys/dev/mlx5/mlx5_ib/mlx5_ib_mr.c b/sys/dev/mlx5/mlx5_ib/mlx5_ib_mr.c
index 72dcf63..709f99a 100644
--- a/sys/dev/mlx5/mlx5_ib/mlx5_ib_mr.c
+++ b/sys/dev/mlx5/mlx5_ib/mlx5_ib_mr.c
@@ -25,29 +25,37 @@
* $FreeBSD$
*/
-
#include <linux/kref.h>
#include <linux/random.h>
-#include <linux/fs.h>
#include <linux/delay.h>
+#include <linux/sched.h>
#include <rdma/ib_umem.h>
+#include <rdma/ib_umem_odp.h>
+#include <rdma/ib_verbs.h>
#include "mlx5_ib.h"
-CTASSERT((uintptr_t)PAGE_MASK > (uintptr_t)PAGE_SIZE);
-
enum {
MAX_PENDING_REG_MR = 8,
- MAX_MR_RELEASE_TIMEOUT = (60 * 20) /* Allow release timeout up to 20 min */
};
#define MLX5_UMR_ALIGN 2048
+#ifdef CONFIG_INFINIBAND_ON_DEMAND_PAGING
+static __be64 mlx5_ib_update_mtt_emergency_buffer[
+ MLX5_UMR_MTT_MIN_CHUNK_SIZE/sizeof(__be64)]
+ __aligned(MLX5_UMR_ALIGN);
+static DEFINE_MUTEX(mlx5_ib_update_mtt_emergency_buffer_mutex);
+#endif
-static int mlx5_mr_sysfs_init(struct mlx5_ib_dev *dev);
-static void mlx5_mr_sysfs_cleanup(struct mlx5_ib_dev *dev);
+static int clean_mr(struct mlx5_ib_mr *mr);
static int destroy_mkey(struct mlx5_ib_dev *dev, struct mlx5_ib_mr *mr)
{
- int err = mlx5_core_destroy_mkey(dev->mdev, &mr->mmr);
+ int err = mlx5_core_destroy_mkey(dev->mdev, &mr->mmkey);
+
+#ifdef CONFIG_INFINIBAND_ON_DEMAND_PAGING
+ /* Wait until all page fault handlers using the mr complete. */
+ synchronize_srcu(&dev->mr_srcu);
+#endif
return err;
}
@@ -62,6 +70,40 @@ static int order2idx(struct mlx5_ib_dev *dev, int order)
return order - cache->ent[0].order;
}
+static bool use_umr_mtt_update(struct mlx5_ib_mr *mr, u64 start, u64 length)
+{
+ return ((u64)1 << mr->order) * MLX5_ADAPTER_PAGE_SIZE >=
+ length + (start & (MLX5_ADAPTER_PAGE_SIZE - 1));
+}
+
+#ifdef CONFIG_INFINIBAND_ON_DEMAND_PAGING
+static void update_odp_mr(struct mlx5_ib_mr *mr)
+{
+ if (mr->umem->odp_data) {
+ /*
+ * This barrier prevents the compiler from moving the
+ * setting of umem->odp_data->private to point to our
+ * MR, before reg_umr finished, to ensure that the MR
+ * initialization have finished before starting to
+ * handle invalidations.
+ */
+ smp_wmb();
+ mr->umem->odp_data->private = mr;
+ /*
+ * Make sure we will see the new
+ * umem->odp_data->private value in the invalidation
+ * routines, before we can get page faults on the
+ * MR. Page faults can happen once we put the MR in
+ * the tree, below this line. Without the barrier,
+ * there can be a fault handling and an invalidation
+ * before umem->odp_data->private == mr is visible to
+ * the invalidation handler.
+ */
+ smp_wmb();
+ }
+}
+#endif
+
static void reg_mr_callback(int status, void *context)
{
struct mlx5_ib_mr *mr = context;
@@ -69,28 +111,16 @@ static void reg_mr_callback(int status, void *context)
struct mlx5_mr_cache *cache = &dev->cache;
int c = order2idx(dev, mr->order);
struct mlx5_cache_ent *ent = &cache->ent[c];
- struct mlx5_core_dev *mdev = dev->mdev;
- struct mlx5_core_mr *mmr = &mr->mmr;
- struct mlx5_mr_table *table = &dev->mdev->priv.mr_table;
+ u8 key;
unsigned long flags;
+ struct mlx5_mr_table *table = &dev->mdev->priv.mr_table;
int err;
- u8 key;
spin_lock_irqsave(&ent->lock, flags);
ent->pending--;
spin_unlock_irqrestore(&ent->lock, flags);
if (status) {
- mlx5_ib_warn(dev, "async reg mr failed. status %d, order %d\n", status, ent->order);
- kfree(mr);
- dev->fill_delay = 1;
- mod_timer(&dev->delay_timer, jiffies + HZ);
- return;
- }
-
- if (mr->out.hdr.status) {
- mlx5_ib_warn(dev, "failed - status %d, syndorme 0x%x\n",
- mr->out.hdr.status,
- be32_to_cpu(mr->out.hdr.syndrome));
+ mlx5_ib_warn(dev, "async reg mr failed. status %d\n", status);
kfree(mr);
dev->fill_delay = 1;
mod_timer(&dev->delay_timer, jiffies + HZ);
@@ -100,9 +130,7 @@ static void reg_mr_callback(int status, void *context)
spin_lock_irqsave(&dev->mdev->priv.mkey_lock, flags);
key = dev->mdev->priv.mkey_key++;
spin_unlock_irqrestore(&dev->mdev->priv.mkey_lock, flags);
- mmr->key = mlx5_idx_to_mkey(be32_to_cpu(mr->out.mkey) & 0xffffff) | key;
- mlx5_ib_dbg(dev, "callbacked mkey 0x%x created\n",
- be32_to_cpu(mr->out.mkey));
+ mr->mmkey.key = mlx5_idx_to_mkey(MLX5_GET(create_mkey_out, mr->out, mkey_index)) | key;
cache->last_add = jiffies;
@@ -113,29 +141,30 @@ static void reg_mr_callback(int status, void *context)
spin_unlock_irqrestore(&ent->lock, flags);
spin_lock_irqsave(&table->lock, flags);
- err = radix_tree_insert(&table->tree, mlx5_mkey_to_idx(mmr->key), mmr);
+ err = radix_tree_insert(&table->tree, mlx5_mkey_to_idx(mr->mmkey.key),
+ &mr->mmkey);
+ if (err)
+ pr_err("Error inserting to mkey tree. 0x%x\n", -err);
spin_unlock_irqrestore(&table->lock, flags);
- if (err) {
- mlx5_ib_warn(dev, "failed radix tree insert of mkey 0x%x, %d\n",
- mmr->key, err);
- mlx5_core_destroy_mkey(mdev, mmr);
- }
}
static int add_keys(struct mlx5_ib_dev *dev, int c, int num)
{
struct mlx5_mr_cache *cache = &dev->cache;
struct mlx5_cache_ent *ent = &cache->ent[c];
- struct mlx5_create_mkey_mbox_in *in;
+ int inlen = MLX5_ST_SZ_BYTES(create_mkey_in);
struct mlx5_ib_mr *mr;
int npages = 1 << ent->order;
+ void *mkc;
+ u32 *in;
int err = 0;
int i;
- in = kzalloc(sizeof(*in), GFP_KERNEL);
+ in = kzalloc(inlen, GFP_KERNEL);
if (!in)
return -ENOMEM;
+ mkc = MLX5_ADDR_OF(create_mkey_in, in, memory_key_mkey_entry);
for (i = 0; i < num; i++) {
if (ent->pending >= MAX_PENDING_REG_MR) {
err = -EAGAIN;
@@ -150,18 +179,22 @@ static int add_keys(struct mlx5_ib_dev *dev, int c, int num)
mr->order = ent->order;
mr->umred = 1;
mr->dev = dev;
- in->seg.status = MLX5_MKEY_STATUS_FREE;
- in->seg.xlt_oct_size = cpu_to_be32((npages + 1) / 2);
- in->seg.qpn_mkey7_0 = cpu_to_be32(0xffffff << 8);
- in->seg.flags = MLX5_ACCESS_MODE_MTT | MLX5_PERM_UMR_EN;
- in->seg.log2_page_size = 12;
+
+ MLX5_SET(mkc, mkc, free, 1);
+ MLX5_SET(mkc, mkc, umr_en, 1);
+ MLX5_SET(mkc, mkc, access_mode, MLX5_ACCESS_MODE_MTT);
+
+ MLX5_SET(mkc, mkc, qpn, 0xffffff);
+ MLX5_SET(mkc, mkc, translations_octword_size, (npages + 1) / 2);
+ MLX5_SET(mkc, mkc, log_page_size, 12);
spin_lock_irq(&ent->lock);
ent->pending++;
spin_unlock_irq(&ent->lock);
- err = mlx5_core_create_mkey(dev->mdev, &mr->mmr, in,
- sizeof(*in), reg_mr_callback,
- mr, &mr->out);
+ err = mlx5_core_create_mkey(dev->mdev, &mr->mmkey,
+ (struct mlx5_create_mkey_mbox_in *)in,
+ inlen, reg_mr_callback, mr,
+ (struct mlx5_create_mkey_mbox_out *)mr->out);
if (err) {
spin_lock_irq(&ent->lock);
ent->pending--;
@@ -215,25 +248,12 @@ static int someone_adding(struct mlx5_mr_cache *cache)
return 0;
}
-static int someone_releasing(struct mlx5_mr_cache *cache)
-{
- int i;
-
- for (i = 0; i < MAX_MR_CACHE_ENTRIES; i++) {
- if (cache->ent[i].cur > 2 * cache->ent[i].limit)
- return 1;
- }
-
- return 0;
-}
-
static void __cache_work_func(struct mlx5_cache_ent *ent)
{
struct mlx5_ib_dev *dev = ent->dev;
struct mlx5_mr_cache *cache = &dev->cache;
int i = order2idx(dev, ent->order);
int err;
- s64 dtime;
if (cache->stopped)
return;
@@ -245,39 +265,38 @@ static void __cache_work_func(struct mlx5_cache_ent *ent)
if (err == -EAGAIN) {
mlx5_ib_dbg(dev, "returned eagain, order %d\n",
i + 2);
- cancel_delayed_work(&ent->dwork);
- if (!queue_delayed_work(cache->wq, &ent->dwork,
- msecs_to_jiffies(3)))
- mlx5_ib_warn(dev, "failed queueing delayed work\n");
+ queue_delayed_work(cache->wq, &ent->dwork,
+ msecs_to_jiffies(3));
} else if (err) {
mlx5_ib_warn(dev, "command failed order %d, err %d\n",
i + 2, err);
- cancel_delayed_work(&ent->dwork);
- if (!queue_delayed_work(cache->wq, &ent->dwork,
- msecs_to_jiffies(1000)))
- mlx5_ib_warn(dev, "failed queueing delayed work\n");
+ queue_delayed_work(cache->wq, &ent->dwork,
+ msecs_to_jiffies(1000));
} else {
- if (!queue_work(cache->wq, &ent->work))
- mlx5_ib_warn(dev, "failed queueing work\n");
+ queue_work(cache->wq, &ent->work);
}
}
} else if (ent->cur > 2 * ent->limit) {
- dtime = (cache->last_add + (s64)cache->rel_timeout * HZ) - jiffies;
- if (cache->rel_imm ||
- (cache->rel_timeout >= 0 && !someone_adding(cache) && dtime <= 0)) {
+ /*
+ * The remove_keys() logic is performed as garbage collection
+ * task. Such task is intended to be run when no other active
+ * processes are running.
+ *
+ * The need_resched() will return TRUE if there are user tasks
+ * to be activated in near future.
+ *
+ * In such case, we don't execute remove_keys() and postpone
+ * the garbage collection work to try to run in next cycle,
+ * in order to free CPU resources to other tasks.
+ */
+ if (!need_resched() && !someone_adding(cache) &&
+ time_after(jiffies, cache->last_add + 300 * HZ)) {
remove_keys(dev, i, 1);
if (ent->cur > ent->limit)
- if (!queue_work(cache->wq, &ent->work))
- mlx5_ib_warn(dev, "failed queueing work\n");
- } else if (cache->rel_timeout >= 0) {
- dtime = max_t(s64, dtime, 0);
- dtime = min_t(s64, dtime, (MAX_MR_RELEASE_TIMEOUT * HZ));
- cancel_delayed_work(&ent->dwork);
- if (!queue_delayed_work(cache->wq, &ent->dwork, dtime))
- mlx5_ib_warn(dev, "failed queueing delayed work\n");
+ queue_work(cache->wq, &ent->work);
+ } else {
+ queue_delayed_work(cache->wq, &ent->dwork, 300 * HZ);
}
- } else if (cache->rel_imm && !someone_releasing(cache)) {
- cache->rel_imm = 0;
}
}
@@ -297,6 +316,47 @@ static void cache_work_func(struct work_struct *work)
__cache_work_func(ent);
}
+static struct mlx5_ib_mr *alloc_cached_mr(struct mlx5_ib_dev *dev, int order)
+{
+ struct mlx5_mr_cache *cache = &dev->cache;
+ struct mlx5_ib_mr *mr = NULL;
+ struct mlx5_cache_ent *ent;
+ int c;
+ int i;
+
+ c = order2idx(dev, order);
+ if (c < 0 || c >= MAX_MR_CACHE_ENTRIES) {
+ mlx5_ib_warn(dev, "order %d, cache index %d\n", order, c);
+ return NULL;
+ }
+
+ for (i = c; i < MAX_MR_CACHE_ENTRIES; i++) {
+ ent = &cache->ent[i];
+
+ mlx5_ib_dbg(dev, "order %d, cache index %d\n", ent->order, i);
+
+ spin_lock_irq(&ent->lock);
+ if (!list_empty(&ent->head)) {
+ mr = list_first_entry(&ent->head, struct mlx5_ib_mr,
+ list);
+ list_del(&mr->list);
+ ent->cur--;
+ spin_unlock_irq(&ent->lock);
+ if (ent->cur < ent->limit)
+ queue_work(cache->wq, &ent->work);
+ break;
+ }
+ spin_unlock_irq(&ent->lock);
+
+ queue_work(cache->wq, &ent->work);
+ }
+
+ if (!mr)
+ cache->ent[c].miss++;
+
+ return mr;
+}
+
static void free_cached_mr(struct mlx5_ib_dev *dev, struct mlx5_ib_mr *mr)
{
struct mlx5_mr_cache *cache = &dev->cache;
@@ -318,8 +378,7 @@ static void free_cached_mr(struct mlx5_ib_dev *dev, struct mlx5_ib_mr *mr)
spin_unlock_irq(&ent->lock);
if (shrink)
- if (!queue_work(cache->wq, &ent->work))
- mlx5_ib_warn(dev, "failed queueing work\n");
+ queue_work(cache->wq, &ent->work);
}
static void clean_keys(struct mlx5_ib_dev *dev, int c)
@@ -343,8 +402,7 @@ static void clean_keys(struct mlx5_ib_dev *dev, int c)
spin_unlock_irq(&ent->lock);
err = destroy_mkey(dev, mr);
if (err)
- mlx5_ib_warn(dev, "failed destroy mkey 0x%x from order %d\n",
- mr->mmr.key, ent->order);
+ mlx5_ib_warn(dev, "failed destroy mkey\n");
else
kfree(mr);
}
@@ -357,27 +415,21 @@ static void delay_time_func(unsigned long ctx)
dev->fill_delay = 0;
}
-enum {
- MLX5_VF_MR_LIMIT = 2,
-};
-
int mlx5_mr_cache_init(struct mlx5_ib_dev *dev)
{
struct mlx5_mr_cache *cache = &dev->cache;
struct mlx5_cache_ent *ent;
int limit;
- int err;
int i;
mutex_init(&dev->slow_path_mutex);
- cache->rel_timeout = 300;
- cache->wq = create_singlethread_workqueue("mkey_cache");
+ cache->wq = alloc_ordered_workqueue("mkey_cache", WQ_MEM_RECLAIM);
if (!cache->wq) {
mlx5_ib_warn(dev, "failed to create work queue\n");
return -ENOMEM;
}
- setup_timer(&dev->delay_timer, delay_time_func, (uintptr_t)dev);
+ setup_timer(&dev->delay_timer, delay_time_func, (unsigned long)dev);
for (i = 0; i < MAX_MR_CACHE_ENTRIES; i++) {
INIT_LIST_HEAD(&cache->ent[i].head);
spin_lock_init(&cache->ent[i].lock);
@@ -388,106 +440,79 @@ int mlx5_mr_cache_init(struct mlx5_ib_dev *dev)
ent->order = i + 2;
ent->dev = dev;
- if (dev->mdev->profile->mask & MLX5_PROF_MASK_MR_CACHE) {
- if (mlx5_core_is_pf(dev->mdev))
- limit = dev->mdev->profile->mr_cache[i].limit;
- else
- limit = MLX5_VF_MR_LIMIT;
- } else {
+ if (dev->mdev->profile->mask & MLX5_PROF_MASK_MR_CACHE)
+ limit = dev->mdev->profile->mr_cache[i].limit;
+ else
limit = 0;
- }
INIT_WORK(&ent->work, cache_work_func);
INIT_DELAYED_WORK(&ent->dwork, delayed_cache_work_func);
ent->limit = limit;
- if (!queue_work(cache->wq, &ent->work))
- mlx5_ib_warn(dev, "failed queueing work\n");
+ queue_work(cache->wq, &ent->work);
}
- err = mlx5_mr_sysfs_init(dev);
- if (err)
- mlx5_ib_warn(dev, "failed to init mr cache sysfs\n");
-
return 0;
}
-static void wait_for_async_commands(struct mlx5_ib_dev *dev)
-{
- struct mlx5_mr_cache *cache = &dev->cache;
- struct mlx5_cache_ent *ent;
- int total = 0;
- int i;
- int j;
-
- for (i = 0; i < MAX_MR_CACHE_ENTRIES; i++) {
- ent = &cache->ent[i];
- for (j = 0 ; j < 1000; j++) {
- if (!ent->pending)
- break;
- msleep(50);
- }
- }
- for (i = 0; i < MAX_MR_CACHE_ENTRIES; i++) {
- ent = &cache->ent[i];
- total += ent->pending;
- }
-
- if (total)
- mlx5_ib_dbg(dev, "aborted, %d pending requests\n", total);
- else
- mlx5_ib_dbg(dev, "done with all pending requests\n");
-}
-
int mlx5_mr_cache_cleanup(struct mlx5_ib_dev *dev)
{
int i;
dev->cache.stopped = 1;
flush_workqueue(dev->cache.wq);
- mlx5_mr_sysfs_cleanup(dev);
for (i = 0; i < MAX_MR_CACHE_ENTRIES; i++)
clean_keys(dev, i);
destroy_workqueue(dev->cache.wq);
- wait_for_async_commands(dev);
del_timer_sync(&dev->delay_timer);
+
return 0;
}
struct ib_mr *mlx5_ib_get_dma_mr(struct ib_pd *pd, int acc)
{
struct mlx5_ib_dev *dev = to_mdev(pd->device);
+ int inlen = MLX5_ST_SZ_BYTES(create_mkey_in);
struct mlx5_core_dev *mdev = dev->mdev;
- struct mlx5_create_mkey_mbox_in *in;
- struct mlx5_mkey_seg *seg;
struct mlx5_ib_mr *mr;
+ void *mkc;
+ u32 *in;
int err;
mr = kzalloc(sizeof(*mr), GFP_KERNEL);
if (!mr)
return ERR_PTR(-ENOMEM);
- in = kzalloc(sizeof(*in), GFP_KERNEL);
+ in = kzalloc(inlen, GFP_KERNEL);
if (!in) {
err = -ENOMEM;
goto err_free;
}
- seg = &in->seg;
- seg->flags = convert_access(acc) | MLX5_ACCESS_MODE_PA;
- seg->flags_pd = cpu_to_be32(to_mpd(pd)->pdn | MLX5_MKEY_LEN64);
- seg->qpn_mkey7_0 = cpu_to_be32(0xffffff << 8);
- seg->start_addr = 0;
+ mkc = MLX5_ADDR_OF(create_mkey_in, in, memory_key_mkey_entry);
+
+ MLX5_SET(mkc, mkc, access_mode, MLX5_ACCESS_MODE_PA);
+ MLX5_SET(mkc, mkc, a, !!(acc & IB_ACCESS_REMOTE_ATOMIC));
+ MLX5_SET(mkc, mkc, rw, !!(acc & IB_ACCESS_REMOTE_WRITE));
+ MLX5_SET(mkc, mkc, rr, !!(acc & IB_ACCESS_REMOTE_READ));
+ MLX5_SET(mkc, mkc, lw, !!(acc & IB_ACCESS_LOCAL_WRITE));
+ MLX5_SET(mkc, mkc, lr, 1);
- err = mlx5_core_create_mkey(mdev, &mr->mmr, in, sizeof(*in), NULL, NULL,
- NULL);
+ MLX5_SET(mkc, mkc, length64, 1);
+ MLX5_SET(mkc, mkc, pd, to_mpd(pd)->pdn);
+ MLX5_SET(mkc, mkc, qpn, 0xffffff);
+ MLX5_SET64(mkc, mkc, start_addr, 0);
+
+ err = mlx5_core_create_mkey(mdev, &mr->mmkey,
+ (struct mlx5_create_mkey_mbox_in *)in,
+ inlen, NULL, NULL, NULL);
if (err)
goto err_in;
kfree(in);
- mr->ibmr.lkey = mr->mmr.key;
- mr->ibmr.rkey = mr->mmr.key;
+ mr->ibmr.lkey = mr->mmkey.key;
+ mr->ibmr.rkey = mr->mmkey.key;
mr->umem = NULL;
return &mr->ibmr;
@@ -501,88 +526,415 @@ err_free:
return ERR_PTR(err);
}
-static int get_octo_len(u64 addr, u64 len, u64 page_size)
+static int get_octo_len(u64 addr, u64 len, int page_size)
{
u64 offset;
int npages;
- offset = addr & (page_size - 1ULL);
+ offset = addr & (page_size - 1);
npages = ALIGN(len + offset, page_size) >> ilog2(page_size);
return (npages + 1) / 2;
}
-void mlx5_umr_cq_handler(struct ib_cq *cq, void *cq_context)
+static int use_umr(int order)
{
- struct mlx5_ib_umr_context *context;
- struct ib_wc wc;
- int err;
+ return order <= MLX5_MAX_UMR_SHIFT;
+}
- while (1) {
- err = ib_poll_cq(cq, 1, &wc);
- if (err < 0) {
- printf("mlx5_ib: WARN: ""poll cq error %d\n", err);
- return;
- }
- if (err == 0)
+static int dma_map_mr_pas(struct mlx5_ib_dev *dev, struct ib_umem *umem,
+ int npages, int page_shift, int *size,
+ __be64 **mr_pas, dma_addr_t *dma)
+{
+ __be64 *pas;
+ struct device *ddev = dev->ib_dev.dma_device;
+
+ /*
+ * UMR copies MTTs in units of MLX5_UMR_MTT_ALIGNMENT bytes.
+ * To avoid copying garbage after the pas array, we allocate
+ * a little more.
+ */
+ *size = ALIGN(sizeof(u64) * npages, MLX5_UMR_MTT_ALIGNMENT);
+ *mr_pas = kmalloc(*size + MLX5_UMR_ALIGN - 1, GFP_KERNEL);
+ if (!(*mr_pas))
+ return -ENOMEM;
+
+ pas = PTR_ALIGN(*mr_pas, MLX5_UMR_ALIGN);
+ mlx5_ib_populate_pas(dev, umem, page_shift, pas, MLX5_IB_MTT_PRESENT);
+ /* Clear padding after the actual pages. */
+ memset(pas + npages, 0, *size - npages * sizeof(u64));
+
+ *dma = dma_map_single(ddev, pas, *size, DMA_TO_DEVICE);
+ if (dma_mapping_error(ddev, *dma)) {
+ kfree(*mr_pas);
+ return -ENOMEM;
+ }
+
+ return 0;
+}
+
+static void prep_umr_wqe_common(struct ib_pd *pd, struct ib_send_wr *wr,
+ struct ib_sge *sg, u64 dma, int n, u32 key,
+ int page_shift)
+{
+ struct mlx5_ib_dev *dev = to_mdev(pd->device);
+ struct mlx5_umr_wr *umrwr = umr_wr(wr);
+
+ sg->addr = dma;
+ sg->length = ALIGN(sizeof(u64) * n, 64);
+ sg->lkey = dev->umrc.pd->local_dma_lkey;
+
+ wr->next = NULL;
+ wr->sg_list = sg;
+ if (n)
+ wr->num_sge = 1;
+ else
+ wr->num_sge = 0;
+
+ wr->opcode = MLX5_IB_WR_UMR;
+
+ umrwr->npages = n;
+ umrwr->page_shift = page_shift;
+ umrwr->mkey = key;
+}
+
+static void prep_umr_reg_wqe(struct ib_pd *pd, struct ib_send_wr *wr,
+ struct ib_sge *sg, u64 dma, int n, u32 key,
+ int page_shift, u64 virt_addr, u64 len,
+ int access_flags)
+{
+ struct mlx5_umr_wr *umrwr = umr_wr(wr);
+
+ prep_umr_wqe_common(pd, wr, sg, dma, n, key, page_shift);
+
+ wr->send_flags = 0;
+
+ umrwr->target.virt_addr = virt_addr;
+ umrwr->length = len;
+ umrwr->access_flags = access_flags;
+ umrwr->pd = pd;
+}
+
+static void prep_umr_unreg_wqe(struct mlx5_ib_dev *dev,
+ struct ib_send_wr *wr, u32 key)
+{
+ struct mlx5_umr_wr *umrwr = umr_wr(wr);
+
+ wr->send_flags = MLX5_IB_SEND_UMR_UNREG | MLX5_IB_SEND_UMR_FAIL_IF_FREE;
+ wr->opcode = MLX5_IB_WR_UMR;
+ umrwr->mkey = key;
+}
+
+static struct ib_umem *mr_umem_get(struct ib_pd *pd, u64 start, u64 length,
+ int access_flags, int *npages,
+ int *page_shift, int *ncont, int *order)
+{
+ struct mlx5_ib_dev *dev = to_mdev(pd->device);
+ struct ib_umem *umem = ib_umem_get(pd->uobject->context, start, length,
+ access_flags, 0);
+ if (IS_ERR(umem)) {
+ mlx5_ib_err(dev, "umem get failed (%ld)\n", PTR_ERR(umem));
+ return (void *)umem;
+ }
+
+ mlx5_ib_cont_pages(umem, start, npages, page_shift, ncont, order);
+ if (!*npages) {
+ mlx5_ib_warn(dev, "avoid zero region\n");
+ ib_umem_release(umem);
+ return ERR_PTR(-EINVAL);
+ }
+
+ mlx5_ib_dbg(dev, "npages %d, ncont %d, order %d, page_shift %d\n",
+ *npages, *ncont, *order, *page_shift);
+
+ return umem;
+}
+
+static void mlx5_ib_umr_done(struct ib_cq *cq, struct ib_wc *wc)
+{
+ struct mlx5_ib_umr_context *context =
+ container_of(wc->wr_cqe, struct mlx5_ib_umr_context, cqe);
+
+ context->status = wc->status;
+ complete(&context->done);
+}
+
+static inline void mlx5_ib_init_umr_context(struct mlx5_ib_umr_context *context)
+{
+ context->cqe.done = mlx5_ib_umr_done;
+ context->status = -1;
+ init_completion(&context->done);
+}
+
+static struct mlx5_ib_mr *reg_umr(struct ib_pd *pd, struct ib_umem *umem,
+ u64 virt_addr, u64 len, int npages,
+ int page_shift, int order, int access_flags)
+{
+ struct mlx5_ib_dev *dev = to_mdev(pd->device);
+ struct device *ddev = dev->ib_dev.dma_device;
+ struct umr_common *umrc = &dev->umrc;
+ struct mlx5_ib_umr_context umr_context;
+ struct mlx5_umr_wr umrwr = {};
+ struct ib_send_wr *bad;
+ struct mlx5_ib_mr *mr;
+ struct ib_sge sg;
+ int size;
+ __be64 *mr_pas;
+ dma_addr_t dma;
+ int err = 0;
+ int i;
+
+ for (i = 0; i < 1; i++) {
+ mr = alloc_cached_mr(dev, order);
+ if (mr)
break;
- context = (struct mlx5_ib_umr_context *)(uintptr_t)wc.wr_id;
- context->status = wc.status;
- complete(&context->done);
+ err = add_keys(dev, order2idx(dev, order), 1);
+ if (err && err != -EAGAIN) {
+ mlx5_ib_warn(dev, "add_keys failed, err %d\n", err);
+ break;
+ }
+ }
+
+ if (!mr)
+ return ERR_PTR(-EAGAIN);
+
+ err = dma_map_mr_pas(dev, umem, npages, page_shift, &size, &mr_pas,
+ &dma);
+ if (err)
+ goto free_mr;
+
+ mlx5_ib_init_umr_context(&umr_context);
+
+ umrwr.wr.wr_cqe = &umr_context.cqe;
+ prep_umr_reg_wqe(pd, &umrwr.wr, &sg, dma, npages, mr->mmkey.key,
+ page_shift, virt_addr, len, access_flags);
+
+ down(&umrc->sem);
+ err = ib_post_send(umrc->qp, &umrwr.wr, &bad);
+ if (err) {
+ mlx5_ib_warn(dev, "post send failed, err %d\n", err);
+ goto unmap_dma;
+ } else {
+ wait_for_completion(&umr_context.done);
+ if (umr_context.status != IB_WC_SUCCESS) {
+ mlx5_ib_warn(dev, "reg umr failed\n");
+ err = -EFAULT;
+ }
+ }
+
+ mr->mmkey.iova = virt_addr;
+ mr->mmkey.size = len;
+ mr->mmkey.pd = to_mpd(pd)->pdn;
+
+ mr->live = 1;
+
+unmap_dma:
+ up(&umrc->sem);
+ dma_unmap_single(ddev, dma, size, DMA_TO_DEVICE);
+
+ kfree(mr_pas);
+
+free_mr:
+ if (err) {
+ free_cached_mr(dev, mr);
+ return ERR_PTR(err);
+ }
+
+ return mr;
+}
+
+#ifdef CONFIG_INFINIBAND_ON_DEMAND_PAGING
+int mlx5_ib_update_mtt(struct mlx5_ib_mr *mr, u64 start_page_index, int npages,
+ int zap)
+{
+ struct mlx5_ib_dev *dev = mr->dev;
+ struct device *ddev = dev->ib_dev.dma_device;
+ struct umr_common *umrc = &dev->umrc;
+ struct mlx5_ib_umr_context umr_context;
+ struct ib_umem *umem = mr->umem;
+ int size;
+ __be64 *pas;
+ dma_addr_t dma;
+ struct ib_send_wr *bad;
+ struct mlx5_umr_wr wr;
+ struct ib_sge sg;
+ int err = 0;
+ const int page_index_alignment = MLX5_UMR_MTT_ALIGNMENT / sizeof(u64);
+ const int page_index_mask = page_index_alignment - 1;
+ size_t pages_mapped = 0;
+ size_t pages_to_map = 0;
+ size_t pages_iter = 0;
+ int use_emergency_buf = 0;
+
+ /* UMR copies MTTs in units of MLX5_UMR_MTT_ALIGNMENT bytes,
+ * so we need to align the offset and length accordingly */
+ if (start_page_index & page_index_mask) {
+ npages += start_page_index & page_index_mask;
+ start_page_index &= ~page_index_mask;
+ }
+
+ pages_to_map = ALIGN(npages, page_index_alignment);
+
+ if (start_page_index + pages_to_map > MLX5_MAX_UMR_PAGES)
+ return -EINVAL;
+
+ size = sizeof(u64) * pages_to_map;
+ size = min_t(int, PAGE_SIZE, size);
+ /* We allocate with GFP_ATOMIC to avoid recursion into page-reclaim
+ * code, when we are called from an invalidation. The pas buffer must
+ * be 2k-aligned for Connect-IB. */
+ pas = (__be64 *)get_zeroed_page(GFP_ATOMIC);
+ if (!pas) {
+ mlx5_ib_warn(dev, "unable to allocate memory during MTT update, falling back to slower chunked mechanism.\n");
+ pas = mlx5_ib_update_mtt_emergency_buffer;
+ size = MLX5_UMR_MTT_MIN_CHUNK_SIZE;
+ use_emergency_buf = 1;
+ mutex_lock(&mlx5_ib_update_mtt_emergency_buffer_mutex);
+ memset(pas, 0, size);
+ }
+ pages_iter = size / sizeof(u64);
+ dma = dma_map_single(ddev, pas, size, DMA_TO_DEVICE);
+ if (dma_mapping_error(ddev, dma)) {
+ mlx5_ib_err(dev, "unable to map DMA during MTT update.\n");
+ err = -ENOMEM;
+ goto free_pas;
}
- ib_req_notify_cq(cq, IB_CQ_NEXT_COMP);
+
+ for (pages_mapped = 0;
+ pages_mapped < pages_to_map && !err;
+ pages_mapped += pages_iter, start_page_index += pages_iter) {
+ dma_sync_single_for_cpu(ddev, dma, size, DMA_TO_DEVICE);
+
+ npages = min_t(size_t,
+ pages_iter,
+ ib_umem_num_pages(umem) - start_page_index);
+
+ if (!zap) {
+ __mlx5_ib_populate_pas(dev, umem, PAGE_SHIFT,
+ start_page_index, npages, pas,
+ MLX5_IB_MTT_PRESENT);
+ /* Clear padding after the pages brought from the
+ * umem. */
+ memset(pas + npages, 0, size - npages * sizeof(u64));
+ }
+
+ dma_sync_single_for_device(ddev, dma, size, DMA_TO_DEVICE);
+
+ mlx5_ib_init_umr_context(&umr_context);
+
+ memset(&wr, 0, sizeof(wr));
+ wr.wr.wr_cqe = &umr_context.cqe;
+
+ sg.addr = dma;
+ sg.length = ALIGN(npages * sizeof(u64),
+ MLX5_UMR_MTT_ALIGNMENT);
+ sg.lkey = dev->umrc.pd->local_dma_lkey;
+
+ wr.wr.send_flags = MLX5_IB_SEND_UMR_FAIL_IF_FREE |
+ MLX5_IB_SEND_UMR_UPDATE_MTT;
+ wr.wr.sg_list = &sg;
+ wr.wr.num_sge = 1;
+ wr.wr.opcode = MLX5_IB_WR_UMR;
+ wr.npages = sg.length / sizeof(u64);
+ wr.page_shift = PAGE_SHIFT;
+ wr.mkey = mr->mmkey.key;
+ wr.target.offset = start_page_index;
+
+ down(&umrc->sem);
+ err = ib_post_send(umrc->qp, &wr.wr, &bad);
+ if (err) {
+ mlx5_ib_err(dev, "UMR post send failed, err %d\n", err);
+ } else {
+ wait_for_completion(&umr_context.done);
+ if (umr_context.status != IB_WC_SUCCESS) {
+ mlx5_ib_err(dev, "UMR completion failed, code %d\n",
+ umr_context.status);
+ err = -EFAULT;
+ }
+ }
+ up(&umrc->sem);
+ }
+ dma_unmap_single(ddev, dma, size, DMA_TO_DEVICE);
+
+free_pas:
+ if (!use_emergency_buf)
+ free_page((unsigned long)pas);
+ else
+ mutex_unlock(&mlx5_ib_update_mtt_emergency_buffer_mutex);
+
+ return err;
}
+#endif
-static struct mlx5_ib_mr *reg_create(struct ib_pd *pd, u64 virt_addr,
- u64 length, struct ib_umem *umem,
- int npages, int page_shift,
- int access_flags)
+/*
+ * If ibmr is NULL it will be allocated by reg_create.
+ * Else, the given ibmr will be used.
+ */
+static struct mlx5_ib_mr *reg_create(struct ib_mr *ibmr, struct ib_pd *pd,
+ u64 virt_addr, u64 length,
+ struct ib_umem *umem, int npages,
+ int page_shift, int access_flags)
{
struct mlx5_ib_dev *dev = to_mdev(pd->device);
- struct mlx5_create_mkey_mbox_in *in;
struct mlx5_ib_mr *mr;
+ __be64 *pas;
+ void *mkc;
int inlen;
+ u32 *in;
int err;
bool pg_cap = !!(MLX5_CAP_GEN(dev->mdev, pg));
- mr = kzalloc(sizeof(*mr), GFP_KERNEL);
+ mr = ibmr ? to_mmr(ibmr) : kzalloc(sizeof(*mr), GFP_KERNEL);
if (!mr)
return ERR_PTR(-ENOMEM);
- inlen = sizeof(*in) + sizeof(*in->pas) * ((npages + 1) / 2) * 2;
+ inlen = MLX5_ST_SZ_BYTES(create_mkey_in) +
+ sizeof(*pas) * ((npages + 1) / 2) * 2;
in = mlx5_vzalloc(inlen);
if (!in) {
err = -ENOMEM;
goto err_1;
}
- mlx5_ib_populate_pas(dev, umem, page_shift, in->pas,
+ pas = (__be64 *)MLX5_ADDR_OF(create_mkey_in, in, klm_pas_mtt);
+ mlx5_ib_populate_pas(dev, umem, page_shift, pas,
pg_cap ? MLX5_IB_MTT_PRESENT : 0);
- /* The MLX5_MKEY_INBOX_PG_ACCESS bit allows setting the access flags
+ /* The pg_access bit allows setting the access flags
* in the page list submitted with the command. */
- in->flags = pg_cap ? cpu_to_be32(MLX5_MKEY_INBOX_PG_ACCESS) : 0;
- in->seg.flags = convert_access(access_flags) |
- MLX5_ACCESS_MODE_MTT;
- in->seg.flags_pd = cpu_to_be32(to_mpd(pd)->pdn);
- in->seg.start_addr = cpu_to_be64(virt_addr);
- in->seg.len = cpu_to_be64(length);
- in->seg.bsfs_octo_size = 0;
- in->seg.xlt_oct_size = cpu_to_be32(get_octo_len(virt_addr, length, 1 << page_shift));
- in->seg.log2_page_size = page_shift;
- in->seg.qpn_mkey7_0 = cpu_to_be32(0xffffff << 8);
- in->xlat_oct_act_size = cpu_to_be32(get_octo_len(virt_addr, length,
- 1 << page_shift));
- err = mlx5_core_create_mkey(dev->mdev, &mr->mmr, in, inlen, NULL,
- NULL, NULL);
+ MLX5_SET(create_mkey_in, in, pg_access, !!(pg_cap));
+
+ mkc = MLX5_ADDR_OF(create_mkey_in, in, memory_key_mkey_entry);
+ MLX5_SET(mkc, mkc, access_mode, MLX5_ACCESS_MODE_MTT);
+ MLX5_SET(mkc, mkc, a, !!(access_flags & IB_ACCESS_REMOTE_ATOMIC));
+ MLX5_SET(mkc, mkc, rw, !!(access_flags & IB_ACCESS_REMOTE_WRITE));
+ MLX5_SET(mkc, mkc, rr, !!(access_flags & IB_ACCESS_REMOTE_READ));
+ MLX5_SET(mkc, mkc, lw, !!(access_flags & IB_ACCESS_LOCAL_WRITE));
+ MLX5_SET(mkc, mkc, lr, 1);
+
+ MLX5_SET64(mkc, mkc, start_addr, virt_addr);
+ MLX5_SET64(mkc, mkc, len, length);
+ MLX5_SET(mkc, mkc, pd, to_mpd(pd)->pdn);
+ MLX5_SET(mkc, mkc, bsf_octword_size, 0);
+ MLX5_SET(mkc, mkc, translations_octword_size,
+ get_octo_len(virt_addr, length, 1 << page_shift));
+ MLX5_SET(mkc, mkc, log_page_size, page_shift);
+ MLX5_SET(mkc, mkc, qpn, 0xffffff);
+ MLX5_SET(create_mkey_in, in, translations_octword_actual_size,
+ get_octo_len(virt_addr, length, 1 << page_shift));
+
+ err = mlx5_core_create_mkey(dev->mdev, &mr->mmkey,
+ (struct mlx5_create_mkey_mbox_in *)in,
+ inlen, NULL, NULL, NULL);
if (err) {
mlx5_ib_warn(dev, "create mkey failed\n");
goto err_2;
}
mr->umem = umem;
mr->dev = dev;
+ mr->live = 1;
kvfree(in);
- mlx5_ib_dbg(dev, "mkey = 0x%x\n", mr->mmr.key);
+ mlx5_ib_dbg(dev, "mkey = 0x%x\n", mr->mmkey.key);
return mr;
@@ -590,42 +942,26 @@ err_2:
kvfree(in);
err_1:
- kfree(mr);
+ if (!ibmr)
+ kfree(mr);
return ERR_PTR(err);
}
-enum {
- MLX5_MAX_REG_ORDER = MAX_MR_CACHE_ENTRIES + 1,
- MLX5_MAX_REG_SIZE = 2ul * 1024 * 1024 * 1024,
-};
-
-static int clean_mr(struct mlx5_ib_mr *mr)
+static void set_mr_fileds(struct mlx5_ib_dev *dev, struct mlx5_ib_mr *mr,
+ int npages, u64 length, int access_flags)
{
- struct mlx5_ib_dev *dev = to_mdev(mr->ibmr.device);
- int umred = mr->umred;
- int err;
- int i;
-
- if (!umred) {
- for (i = 0; i < mr->nchild; ++i) {
- free_cached_mr(dev, mr->children[i]);
- }
- kfree(mr->children);
-
- err = destroy_mkey(dev, mr);
- if (err) {
- mlx5_ib_warn(dev, "failed to destroy mkey 0x%x (%d)\n",
- mr->mmr.key, err);
- return err;
- }
- }
- return 0;
+ mr->npages = npages;
+ atomic_add(npages, &dev->mdev->priv.reg_pages);
+ mr->ibmr.lkey = mr->mmkey.key;
+ mr->ibmr.rkey = mr->mmkey.key;
+ mr->ibmr.length = length;
+ mr->access_flags = access_flags;
}
struct ib_mr *mlx5_ib_reg_user_mr(struct ib_pd *pd, u64 start, u64 length,
u64 virt_addr, int access_flags,
- struct ib_udata *udata, int mr_id)
+ struct ib_udata *udata)
{
struct mlx5_ib_dev *dev = to_mdev(pd->device);
struct mlx5_ib_mr *mr = NULL;
@@ -637,59 +973,342 @@ struct ib_mr *mlx5_ib_reg_user_mr(struct ib_pd *pd, u64 start, u64 length,
int err;
mlx5_ib_dbg(dev, "start 0x%llx, virt_addr 0x%llx, length 0x%llx, access_flags 0x%x\n",
- (unsigned long long)start, (unsigned long long)virt_addr,
- (unsigned long long)length, access_flags);
- umem = ib_umem_get(pd->uobject->context, start, length, access_flags, 0);
- if (IS_ERR(umem)) {
- mlx5_ib_warn(dev, "umem get failed (%ld)\n", PTR_ERR(umem));
+ (long long)start, (long long)virt_addr, (long long)length, access_flags);
+ umem = mr_umem_get(pd, start, length, access_flags, &npages,
+ &page_shift, &ncont, &order);
+
+ if (IS_ERR(umem))
return (void *)umem;
- }
- mlx5_ib_cont_pages(umem, start, &npages, &page_shift, &ncont, &order);
- if (!npages) {
- mlx5_ib_warn(dev, "avoid zero region\n");
+ if (use_umr(order)) {
+ mr = reg_umr(pd, umem, virt_addr, length, ncont, page_shift,
+ order, access_flags);
+ if (PTR_ERR(mr) == -EAGAIN) {
+ mlx5_ib_dbg(dev, "cache empty for order %d", order);
+ mr = NULL;
+ }
+ } else if (access_flags & IB_ACCESS_ON_DEMAND) {
err = -EINVAL;
+ pr_err("Got MR registration for ODP MR > 512MB, not supported for Connect-IB");
goto error;
}
- mlx5_ib_dbg(dev, "npages %d, ncont %d, order %d, page_shift %d\n",
- npages, ncont, order, page_shift);
-
- mutex_lock(&dev->slow_path_mutex);
- mr = reg_create(pd, virt_addr, length, umem, ncont, page_shift, access_flags);
- mutex_unlock(&dev->slow_path_mutex);
+ if (!mr) {
+ mutex_lock(&dev->slow_path_mutex);
+ mr = reg_create(NULL, pd, virt_addr, length, umem, ncont,
+ page_shift, access_flags);
+ mutex_unlock(&dev->slow_path_mutex);
+ }
if (IS_ERR(mr)) {
err = PTR_ERR(mr);
- mr = NULL;
goto error;
}
- mlx5_ib_dbg(dev, "mkey 0x%x\n", mr->mmr.key);
+ mlx5_ib_dbg(dev, "mkey 0x%x\n", mr->mmkey.key);
mr->umem = umem;
- mr->npages = npages;
- atomic_add(npages, &dev->mdev->priv.reg_pages);
- mr->ibmr.lkey = mr->mmr.key;
- mr->ibmr.rkey = mr->mmr.key;
+ set_mr_fileds(dev, mr, npages, length, access_flags);
+
+#ifdef CONFIG_INFINIBAND_ON_DEMAND_PAGING
+ update_odp_mr(mr);
+#endif
return &mr->ibmr;
error:
- /*
- * Destroy the umem *before* destroying the MR, to ensure we
- * will not have any in-flight notifiers when destroying the
- * MR.
- *
- * As the MR is completely invalid to begin with, and this
- * error path is only taken if we can't push the mr entry into
- * the pagefault tree, this is safe.
- */
-
ib_umem_release(umem);
return ERR_PTR(err);
}
+static int unreg_umr(struct mlx5_ib_dev *dev, struct mlx5_ib_mr *mr)
+{
+ struct mlx5_core_dev *mdev = dev->mdev;
+ struct umr_common *umrc = &dev->umrc;
+ struct mlx5_ib_umr_context umr_context;
+ struct mlx5_umr_wr umrwr = {};
+ struct ib_send_wr *bad;
+ int err;
+
+ if (mdev->state == MLX5_DEVICE_STATE_INTERNAL_ERROR)
+ return 0;
+
+ mlx5_ib_init_umr_context(&umr_context);
+
+ umrwr.wr.wr_cqe = &umr_context.cqe;
+ prep_umr_unreg_wqe(dev, &umrwr.wr, mr->mmkey.key);
+
+ down(&umrc->sem);
+ err = ib_post_send(umrc->qp, &umrwr.wr, &bad);
+ if (err) {
+ up(&umrc->sem);
+ mlx5_ib_dbg(dev, "err %d\n", err);
+ goto error;
+ } else {
+ wait_for_completion(&umr_context.done);
+ up(&umrc->sem);
+ }
+ if (umr_context.status != IB_WC_SUCCESS) {
+ mlx5_ib_warn(dev, "unreg umr failed\n");
+ err = -EFAULT;
+ goto error;
+ }
+ return 0;
+
+error:
+ return err;
+}
+
+static int rereg_umr(struct ib_pd *pd, struct mlx5_ib_mr *mr, u64 virt_addr,
+ u64 length, int npages, int page_shift, int order,
+ int access_flags, int flags)
+{
+ struct mlx5_ib_dev *dev = to_mdev(pd->device);
+ struct device *ddev = dev->ib_dev.dma_device;
+ struct mlx5_ib_umr_context umr_context;
+ struct ib_send_wr *bad;
+ struct mlx5_umr_wr umrwr = {};
+ struct ib_sge sg;
+ struct umr_common *umrc = &dev->umrc;
+ dma_addr_t dma = 0;
+ __be64 *mr_pas = NULL;
+ int size;
+ int err;
+
+ mlx5_ib_init_umr_context(&umr_context);
+
+ umrwr.wr.wr_cqe = &umr_context.cqe;
+ umrwr.wr.send_flags = MLX5_IB_SEND_UMR_FAIL_IF_FREE;
+
+ if (flags & IB_MR_REREG_TRANS) {
+ err = dma_map_mr_pas(dev, mr->umem, npages, page_shift, &size,
+ &mr_pas, &dma);
+ if (err)
+ return err;
+
+ umrwr.target.virt_addr = virt_addr;
+ umrwr.length = length;
+ umrwr.wr.send_flags |= MLX5_IB_SEND_UMR_UPDATE_TRANSLATION;
+ }
+
+ prep_umr_wqe_common(pd, &umrwr.wr, &sg, dma, npages, mr->mmkey.key,
+ page_shift);
+
+ if (flags & IB_MR_REREG_PD) {
+ umrwr.pd = pd;
+ umrwr.wr.send_flags |= MLX5_IB_SEND_UMR_UPDATE_PD;
+ }
+
+ if (flags & IB_MR_REREG_ACCESS) {
+ umrwr.access_flags = access_flags;
+ umrwr.wr.send_flags |= MLX5_IB_SEND_UMR_UPDATE_ACCESS;
+ }
+
+ /* post send request to UMR QP */
+ down(&umrc->sem);
+ err = ib_post_send(umrc->qp, &umrwr.wr, &bad);
+
+ if (err) {
+ mlx5_ib_warn(dev, "post send failed, err %d\n", err);
+ } else {
+ wait_for_completion(&umr_context.done);
+ if (umr_context.status != IB_WC_SUCCESS) {
+ mlx5_ib_warn(dev, "reg umr failed (%u)\n",
+ umr_context.status);
+ err = -EFAULT;
+ }
+ }
+
+ up(&umrc->sem);
+ if (flags & IB_MR_REREG_TRANS) {
+ dma_unmap_single(ddev, dma, size, DMA_TO_DEVICE);
+ kfree(mr_pas);
+ }
+ return err;
+}
+
+int mlx5_ib_rereg_user_mr(struct ib_mr *ib_mr, int flags, u64 start,
+ u64 length, u64 virt_addr, int new_access_flags,
+ struct ib_pd *new_pd, struct ib_udata *udata)
+{
+ struct mlx5_ib_dev *dev = to_mdev(ib_mr->device);
+ struct mlx5_ib_mr *mr = to_mmr(ib_mr);
+ struct ib_pd *pd = (flags & IB_MR_REREG_PD) ? new_pd : ib_mr->pd;
+ int access_flags = flags & IB_MR_REREG_ACCESS ?
+ new_access_flags :
+ mr->access_flags;
+ u64 addr = (flags & IB_MR_REREG_TRANS) ? virt_addr : mr->umem->address;
+ u64 len = (flags & IB_MR_REREG_TRANS) ? length : mr->umem->length;
+ int page_shift = 0;
+ int npages = 0;
+ int ncont = 0;
+ int order = 0;
+ int err;
+
+ mlx5_ib_dbg(dev, "start 0x%llx, virt_addr 0x%llx, length 0x%llx, access_flags 0x%x\n",
+ (long long)start, (long long)virt_addr, (long long)length, access_flags);
+
+ if (flags != IB_MR_REREG_PD) {
+ /*
+ * Replace umem. This needs to be done whether or not UMR is
+ * used.
+ */
+ flags |= IB_MR_REREG_TRANS;
+ ib_umem_release(mr->umem);
+ mr->umem = mr_umem_get(pd, addr, len, access_flags, &npages,
+ &page_shift, &ncont, &order);
+ if (IS_ERR(mr->umem)) {
+ err = PTR_ERR(mr->umem);
+ mr->umem = NULL;
+ return err;
+ }
+ }
+
+ if (flags & IB_MR_REREG_TRANS && !use_umr_mtt_update(mr, addr, len)) {
+ /*
+ * UMR can't be used - MKey needs to be replaced.
+ */
+ if (mr->umred) {
+ err = unreg_umr(dev, mr);
+ if (err)
+ mlx5_ib_warn(dev, "Failed to unregister MR\n");
+ } else {
+ err = destroy_mkey(dev, mr);
+ if (err)
+ mlx5_ib_warn(dev, "Failed to destroy MKey\n");
+ }
+ if (err)
+ return err;
+
+ mr = reg_create(ib_mr, pd, addr, len, mr->umem, ncont,
+ page_shift, access_flags);
+
+ if (IS_ERR(mr))
+ return PTR_ERR(mr);
+
+ mr->umred = 0;
+ } else {
+ /*
+ * Send a UMR WQE
+ */
+ err = rereg_umr(pd, mr, addr, len, npages, page_shift,
+ order, access_flags, flags);
+ if (err) {
+ mlx5_ib_warn(dev, "Failed to rereg UMR\n");
+ return err;
+ }
+ }
+
+ if (flags & IB_MR_REREG_PD) {
+ ib_mr->pd = pd;
+ mr->mmkey.pd = to_mpd(pd)->pdn;
+ }
+
+ if (flags & IB_MR_REREG_ACCESS)
+ mr->access_flags = access_flags;
+
+ if (flags & IB_MR_REREG_TRANS) {
+ atomic_sub(mr->npages, &dev->mdev->priv.reg_pages);
+ set_mr_fileds(dev, mr, npages, len, access_flags);
+ mr->mmkey.iova = addr;
+ mr->mmkey.size = len;
+ }
+#ifdef CONFIG_INFINIBAND_ON_DEMAND_PAGING
+ update_odp_mr(mr);
+#endif
+
+ return 0;
+}
+
+static int
+mlx5_alloc_priv_descs(struct ib_device *device,
+ struct mlx5_ib_mr *mr,
+ int ndescs,
+ int desc_size)
+{
+ int size = ndescs * desc_size;
+ int add_size;
+ int ret;
+
+ add_size = max_t(int, MLX5_UMR_ALIGN - 1, 0);
+
+ mr->descs_alloc = kzalloc(size + add_size, GFP_KERNEL);
+ if (!mr->descs_alloc)
+ return -ENOMEM;
+
+ mr->descs = PTR_ALIGN(mr->descs_alloc, MLX5_UMR_ALIGN);
+
+ mr->desc_map = dma_map_single(device->dma_device, mr->descs,
+ size, DMA_TO_DEVICE);
+ if (dma_mapping_error(device->dma_device, mr->desc_map)) {
+ ret = -ENOMEM;
+ goto err;
+ }
+
+ return 0;
+err:
+ kfree(mr->descs_alloc);
+
+ return ret;
+}
+
+static void
+mlx5_free_priv_descs(struct mlx5_ib_mr *mr)
+{
+ if (mr->descs) {
+ struct ib_device *device = mr->ibmr.device;
+ int size = mr->max_descs * mr->desc_size;
+
+ dma_unmap_single(device->dma_device, mr->desc_map,
+ size, DMA_TO_DEVICE);
+ kfree(mr->descs_alloc);
+ mr->descs = NULL;
+ }
+}
+
+static int clean_mr(struct mlx5_ib_mr *mr)
+{
+ struct mlx5_ib_dev *dev = to_mdev(mr->ibmr.device);
+ int umred = mr->umred;
+ int err;
+
+ if (mr->sig) {
+ if (mlx5_core_destroy_psv(dev->mdev,
+ mr->sig->psv_memory.psv_idx))
+ mlx5_ib_warn(dev, "failed to destroy mem psv %d\n",
+ mr->sig->psv_memory.psv_idx);
+ if (mlx5_core_destroy_psv(dev->mdev,
+ mr->sig->psv_wire.psv_idx))
+ mlx5_ib_warn(dev, "failed to destroy wire psv %d\n",
+ mr->sig->psv_wire.psv_idx);
+ kfree(mr->sig);
+ mr->sig = NULL;
+ }
+
+ mlx5_free_priv_descs(mr);
+
+ if (!umred) {
+ err = destroy_mkey(dev, mr);
+ if (err) {
+ mlx5_ib_warn(dev, "failed to destroy mkey 0x%x (%d)\n",
+ mr->mmkey.key, err);
+ return err;
+ }
+ } else {
+ err = unreg_umr(dev, mr);
+ if (err) {
+ mlx5_ib_warn(dev, "failed unregister\n");
+ return err;
+ }
+ free_cached_mr(dev, mr);
+ }
+
+ if (!umred)
+ kfree(mr);
+
+ return 0;
+}
+
CTASSERT(sizeof(((struct ib_phys_buf *)0)->size) == 8);
struct ib_mr *
@@ -700,8 +1319,10 @@ mlx5_ib_reg_phys_mr(struct ib_pd *pd,
u64 *virt_addr)
{
struct mlx5_ib_dev *dev = to_mdev(pd->device);
- struct mlx5_create_mkey_mbox_in *in;
struct mlx5_ib_mr *mr;
+ __be64 *pas;
+ void *mkc;
+ u32 *in;
u64 total_size;
u32 octo_len;
bool pg_cap = !!(MLX5_CAP_GEN(dev->mdev, pg));
@@ -747,12 +1368,13 @@ mlx5_ib_reg_phys_mr(struct ib_pd *pd,
octo_len = get_octo_len(*virt_addr, total_size, 1ULL << shift);
octo_len = ALIGN(octo_len, 4);
- inlen = sizeof(*in) + (octo_len * 16);
+ inlen = MLX5_ST_SZ_BYTES(create_mkey_in) + (octo_len * 16);
in = mlx5_vzalloc(inlen);
if (!in) {
kfree(mr);
return ERR_PTR(-ENOMEM);
}
+ pas = (__be64 *)MLX5_ADDR_OF(create_mkey_in, in, klm_pas_mtt);
n = 0;
for (i = 0; i < num_phys_buf; ++i) {
@@ -762,30 +1384,44 @@ mlx5_ib_reg_phys_mr(struct ib_pd *pd,
u64 temp = buffer_list[i].addr + ((u64) j << shift);
if (pg_cap)
temp |= MLX5_IB_MTT_PRESENT;
- in->pas[n++] = cpu_to_be64(temp);
+ pas[n++] = cpu_to_be64(temp);
}
}
- /* The MLX5_MKEY_INBOX_PG_ACCESS bit allows setting the access flags
- * in the page list submitted with the command. */
- in->flags = pg_cap ? cpu_to_be32(MLX5_MKEY_INBOX_PG_ACCESS) : 0;
- in->seg.flags = convert_access(access_flags) |
- MLX5_ACCESS_MODE_MTT;
- in->seg.flags_pd = cpu_to_be32(to_mpd(pd)->pdn);
- in->seg.start_addr = cpu_to_be64(*virt_addr);
- in->seg.len = cpu_to_be64(total_size);
- in->seg.bsfs_octo_size = 0;
- in->seg.xlt_oct_size = cpu_to_be32(octo_len);
- in->seg.log2_page_size = shift;
- in->seg.qpn_mkey7_0 = cpu_to_be32(0xffffff << 8);
- in->xlat_oct_act_size = cpu_to_be32(octo_len);
- err = mlx5_core_create_mkey(dev->mdev, &mr->mmr, in, inlen, NULL,
- NULL, NULL);
+ /*
+ * The MLX5_MKEY_INBOX_PG_ACCESS bit allows setting the access
+ * flags in the page list submitted with the command:
+ */
+ MLX5_SET(create_mkey_in, in, pg_access, !!(pg_cap));
+
+ mkc = MLX5_ADDR_OF(create_mkey_in, in, memory_key_mkey_entry);
+ MLX5_SET(mkc, mkc, access_mode, MLX5_ACCESS_MODE_MTT);
+ MLX5_SET(mkc, mkc, a, !!(access_flags & IB_ACCESS_REMOTE_ATOMIC));
+ MLX5_SET(mkc, mkc, rw, !!(access_flags & IB_ACCESS_REMOTE_WRITE));
+ MLX5_SET(mkc, mkc, rr, !!(access_flags & IB_ACCESS_REMOTE_READ));
+ MLX5_SET(mkc, mkc, lw, !!(access_flags & IB_ACCESS_LOCAL_WRITE));
+ MLX5_SET(mkc, mkc, lr, 1);
+
+ MLX5_SET64(mkc, mkc, start_addr, *virt_addr);
+ MLX5_SET64(mkc, mkc, len, total_size);
+ MLX5_SET(mkc, mkc, pd, to_mpd(pd)->pdn);
+ MLX5_SET(mkc, mkc, bsf_octword_size, 0);
+ MLX5_SET(mkc, mkc, translations_octword_size, octo_len);
+ MLX5_SET(mkc, mkc, log_page_size, shift);
+ MLX5_SET(mkc, mkc, qpn, 0xffffff);
+ MLX5_SET(create_mkey_in, in, translations_octword_actual_size, octo_len);
+
+ err = mlx5_core_create_mkey(dev->mdev, &mr->mmkey,
+ (struct mlx5_create_mkey_mbox_in *)in, inlen,
+ NULL, NULL, NULL);
mr->umem = NULL;
mr->dev = dev;
+ mr->live = 1;
mr->npages = npages;
- mr->ibmr.lkey = mr->mmr.key;
- mr->ibmr.rkey = mr->mmr.key;
+ mr->ibmr.lkey = mr->mmkey.key;
+ mr->ibmr.rkey = mr->mmkey.key;
+ mr->ibmr.length = total_size;
+ mr->access_flags = access_flags;
kvfree(in);
@@ -800,511 +1436,352 @@ int mlx5_ib_dereg_mr(struct ib_mr *ibmr)
{
struct mlx5_ib_dev *dev = to_mdev(ibmr->device);
struct mlx5_ib_mr *mr = to_mmr(ibmr);
- struct ib_umem *umem = mr->umem;
int npages = mr->npages;
- int umred = mr->umred;
- int err;
-
- err = clean_mr(mr);
- if (err)
- return err;
+ struct ib_umem *umem = mr->umem;
- if (umem) {
+#ifdef CONFIG_INFINIBAND_ON_DEMAND_PAGING
+ if (umem && umem->odp_data) {
+ /* Prevent new page faults from succeeding */
+ mr->live = 0;
+ /* Wait for all running page-fault handlers to finish. */
+ synchronize_srcu(&dev->mr_srcu);
+ /* Destroy all page mappings */
+ mlx5_ib_invalidate_range(umem, ib_umem_start(umem),
+ ib_umem_end(umem));
+ /*
+ * We kill the umem before the MR for ODP,
+ * so that there will not be any invalidations in
+ * flight, looking at the *mr struct.
+ */
ib_umem_release(umem);
atomic_sub(npages, &dev->mdev->priv.reg_pages);
- }
-
- if (umred)
- free_cached_mr(dev, mr);
- else
- kfree(mr);
-
- return 0;
-}
-int mlx5_ib_destroy_mr(struct ib_mr *ibmr)
-{
- struct mlx5_ib_dev *dev = to_mdev(ibmr->device);
- struct mlx5_ib_mr *mr = to_mmr(ibmr);
- int err;
-
- if (mr->sig) {
- if (mlx5_core_destroy_psv(dev->mdev,
- mr->sig->psv_memory.psv_idx))
- mlx5_ib_warn(dev, "failed to destroy mem psv %d\n",
- mr->sig->psv_memory.psv_idx);
- if (mlx5_core_destroy_psv(dev->mdev,
- mr->sig->psv_wire.psv_idx))
- mlx5_ib_warn(dev, "failed to destroy wire psv %d\n",
- mr->sig->psv_wire.psv_idx);
- kfree(mr->sig);
+ /* Avoid double-freeing the umem. */
+ umem = NULL;
}
+#endif
- err = destroy_mkey(dev, mr);
- if (err) {
- mlx5_ib_warn(dev, "failed to destroy mkey 0x%x (%d)\n",
- mr->mmr.key, err);
- return err;
- }
+ clean_mr(mr);
- kfree(mr);
+ if (umem) {
+ ib_umem_release(umem);
+ atomic_sub(npages, &dev->mdev->priv.reg_pages);
+ }
- return err;
+ return 0;
}
-struct ib_mr *mlx5_ib_alloc_fast_reg_mr(struct ib_pd *pd,
- int max_page_list_len)
+struct ib_mr *mlx5_ib_alloc_mr(struct ib_pd *pd,
+ enum ib_mr_type mr_type,
+ u32 max_num_sg)
{
struct mlx5_ib_dev *dev = to_mdev(pd->device);
- struct mlx5_create_mkey_mbox_in *in;
+ int inlen = MLX5_ST_SZ_BYTES(create_mkey_in);
+ int ndescs = ALIGN(max_num_sg, 4);
struct mlx5_ib_mr *mr;
+ void *mkc;
+ u32 *in;
int err;
mr = kzalloc(sizeof(*mr), GFP_KERNEL);
if (!mr)
return ERR_PTR(-ENOMEM);
- in = kzalloc(sizeof(*in), GFP_KERNEL);
+ in = kzalloc(inlen, GFP_KERNEL);
if (!in) {
err = -ENOMEM;
goto err_free;
}
- in->seg.status = MLX5_MKEY_STATUS_FREE;
- in->seg.xlt_oct_size = cpu_to_be32((max_page_list_len + 1) / 2);
- in->seg.qpn_mkey7_0 = cpu_to_be32(0xffffff << 8);
- in->seg.flags = MLX5_PERM_UMR_EN | MLX5_ACCESS_MODE_MTT;
- in->seg.flags_pd = cpu_to_be32(to_mpd(pd)->pdn);
- /*
- * TBD not needed - issue 197292 */
- in->seg.log2_page_size = PAGE_SHIFT;
-
- err = mlx5_core_create_mkey(dev->mdev, &mr->mmr, in, sizeof(*in), NULL,
- NULL, NULL);
- kfree(in);
- if (err) {
- mlx5_ib_warn(dev, "failed create mkey\n");
- goto err_free;
- }
+ mkc = MLX5_ADDR_OF(create_mkey_in, in, memory_key_mkey_entry);
+ MLX5_SET(mkc, mkc, free, 1);
+ MLX5_SET(mkc, mkc, translations_octword_size, ndescs);
+ MLX5_SET(mkc, mkc, qpn, 0xffffff);
+ MLX5_SET(mkc, mkc, pd, to_mpd(pd)->pdn);
+
+ if (mr_type == IB_MR_TYPE_MEM_REG) {
+ mr->access_mode = MLX5_ACCESS_MODE_MTT;
+ MLX5_SET(mkc, mkc, log_page_size, PAGE_SHIFT);
+ err = mlx5_alloc_priv_descs(pd->device, mr,
+ ndescs, sizeof(u64));
+ if (err)
+ goto err_free_in;
- mr->ibmr.lkey = mr->mmr.key;
- mr->ibmr.rkey = mr->mmr.key;
- mr->umem = NULL;
+ mr->desc_size = sizeof(u64);
+ mr->max_descs = ndescs;
+ } else if (mr_type == IB_MR_TYPE_SG_GAPS) {
+ mr->access_mode = MLX5_ACCESS_MODE_KLM;
- return &mr->ibmr;
+ err = mlx5_alloc_priv_descs(pd->device, mr,
+ ndescs, sizeof(struct mlx5_klm));
+ if (err)
+ goto err_free_in;
+ mr->desc_size = sizeof(struct mlx5_klm);
+ mr->max_descs = ndescs;
+ } else if (mr_type == IB_MR_TYPE_SIGNATURE) {
+ u32 psv_index[2];
+
+ MLX5_SET(mkc, mkc, bsf_en, 1);
+ MLX5_SET(mkc, mkc, bsf_octword_size, MLX5_MKEY_BSF_OCTO_SIZE);
+ mr->sig = kzalloc(sizeof(*mr->sig), GFP_KERNEL);
+ if (!mr->sig) {
+ err = -ENOMEM;
+ goto err_free_in;
+ }
-err_free:
- kfree(mr);
- return ERR_PTR(err);
-}
+ /* create mem & wire PSVs */
+ err = mlx5_core_create_psv(dev->mdev, to_mpd(pd)->pdn,
+ 2, psv_index);
+ if (err)
+ goto err_free_sig;
-struct ib_fast_reg_page_list *mlx5_ib_alloc_fast_reg_page_list(struct ib_device *ibdev,
- int page_list_len)
-{
- struct mlx5_ib_fast_reg_page_list *mfrpl;
- int size = page_list_len * sizeof(u64);
+ mr->access_mode = MLX5_ACCESS_MODE_KLM;
+ mr->sig->psv_memory.psv_idx = psv_index[0];
+ mr->sig->psv_wire.psv_idx = psv_index[1];
- mfrpl = kmalloc(sizeof(*mfrpl), GFP_KERNEL);
- if (!mfrpl)
- return ERR_PTR(-ENOMEM);
+ mr->sig->sig_status_checked = true;
+ mr->sig->sig_err_exists = false;
+ /* Next UMR, Arm SIGERR */
+ ++mr->sig->sigerr_count;
+ } else {
+ mlx5_ib_warn(dev, "Invalid mr type %d\n", mr_type);
+ err = -EINVAL;
+ goto err_free_in;
+ }
- mfrpl->ibfrpl.page_list = kmalloc(size, GFP_KERNEL);
- if (!mfrpl->ibfrpl.page_list)
- goto err_free;
+ MLX5_SET(mkc, mkc, access_mode, mr->access_mode);
+ MLX5_SET(mkc, mkc, umr_en, 1);
- mfrpl->mapped_page_list = dma_alloc_coherent(ibdev->dma_device,
- size, &mfrpl->map,
- GFP_KERNEL);
- if (!mfrpl->mapped_page_list)
- goto err_free;
+ err = mlx5_core_create_mkey(dev->mdev, &mr->mmkey,
+ (struct mlx5_create_mkey_mbox_in *)in,
+ inlen, NULL, NULL, NULL);
+ if (err)
+ goto err_destroy_psv;
- WARN_ON(mfrpl->map & 0x3f);
+ mr->ibmr.lkey = mr->mmkey.key;
+ mr->ibmr.rkey = mr->mmkey.key;
+ mr->umem = NULL;
+ kfree(in);
- return &mfrpl->ibfrpl;
+ return &mr->ibmr;
+err_destroy_psv:
+ if (mr->sig) {
+ if (mlx5_core_destroy_psv(dev->mdev,
+ mr->sig->psv_memory.psv_idx))
+ mlx5_ib_warn(dev, "failed to destroy mem psv %d\n",
+ mr->sig->psv_memory.psv_idx);
+ if (mlx5_core_destroy_psv(dev->mdev,
+ mr->sig->psv_wire.psv_idx))
+ mlx5_ib_warn(dev, "failed to destroy wire psv %d\n",
+ mr->sig->psv_wire.psv_idx);
+ }
+ mlx5_free_priv_descs(mr);
+err_free_sig:
+ kfree(mr->sig);
+err_free_in:
+ kfree(in);
err_free:
- kfree(mfrpl->ibfrpl.page_list);
- kfree(mfrpl);
- return ERR_PTR(-ENOMEM);
-}
-
-void mlx5_ib_free_fast_reg_page_list(struct ib_fast_reg_page_list *page_list)
-{
- struct mlx5_ib_fast_reg_page_list *mfrpl = to_mfrpl(page_list);
- struct mlx5_ib_dev *dev = to_mdev(page_list->device);
- int size = page_list->max_page_list_len * sizeof(u64);
-
- dma_free_coherent(&dev->mdev->pdev->dev, size, mfrpl->mapped_page_list,
- mfrpl->map);
- kfree(mfrpl->ibfrpl.page_list);
- kfree(mfrpl);
-}
-
-struct order_attribute {
- struct attribute attr;
- ssize_t (*show)(struct cache_order *, struct order_attribute *, char *buf);
- ssize_t (*store)(struct cache_order *, struct order_attribute *,
- const char *buf, size_t count);
-};
-
-static ssize_t cur_show(struct cache_order *co, struct order_attribute *oa,
- char *buf)
-{
- struct mlx5_ib_dev *dev = co->dev;
- struct mlx5_mr_cache *cache = &dev->cache;
- struct mlx5_cache_ent *ent = &cache->ent[co->index];
- int err;
-
- err = snprintf(buf, 20, "%d\n", ent->cur);
- return err;
-}
-
-static ssize_t limit_show(struct cache_order *co, struct order_attribute *oa,
- char *buf)
-{
- struct mlx5_ib_dev *dev = co->dev;
- struct mlx5_mr_cache *cache = &dev->cache;
- struct mlx5_cache_ent *ent = &cache->ent[co->index];
- int err;
-
- err = snprintf(buf, 20, "%d\n", ent->limit);
- return err;
+ kfree(mr);
+ return ERR_PTR(err);
}
-static ssize_t limit_store(struct cache_order *co, struct order_attribute *oa,
- const char *buf, size_t count)
+struct ib_mw *mlx5_ib_alloc_mw(struct ib_pd *pd, enum ib_mw_type type,
+ struct ib_udata *udata)
{
- struct mlx5_ib_dev *dev = co->dev;
- struct mlx5_mr_cache *cache = &dev->cache;
- struct mlx5_cache_ent *ent = &cache->ent[co->index];
- u32 var;
+ struct mlx5_ib_dev *dev = to_mdev(pd->device);
+ int inlen = MLX5_ST_SZ_BYTES(create_mkey_in);
+ struct mlx5_ib_mw *mw = NULL;
+ u32 *in = NULL;
+ void *mkc;
+ int ndescs;
int err;
+ struct mlx5_ib_alloc_mw req = {};
+ struct {
+ __u32 comp_mask;
+ __u32 response_length;
+ } resp = {};
-#define kstrtouint(a,b,c) ({*(c) = strtol(a,0,b); 0;})
-#define kstrtoint(a,b,c) ({*(c) = strtol(a,0,b); 0;})
+ err = ib_copy_from_udata(&req, udata, min(udata->inlen, sizeof(req)));
+ if (err)
+ return ERR_PTR(err);
- if (kstrtouint(buf, 0, &var))
- return -EINVAL;
+ if (req.comp_mask || req.reserved1 || req.reserved2)
+ return ERR_PTR(-EOPNOTSUPP);
- if (var > ent->size)
- return -EINVAL;
+ if (udata->inlen > sizeof(req) &&
+ !ib_is_udata_cleared(udata, sizeof(req),
+ udata->inlen - sizeof(req)))
+ return ERR_PTR(-EOPNOTSUPP);
- ent->limit = var;
+ ndescs = req.num_klms ? roundup(req.num_klms, 4) : roundup(1, 4);
- if (ent->cur < ent->limit) {
- err = add_keys(dev, co->index, 2 * ent->limit - ent->cur);
- if (err)
- return err;
+ mw = kzalloc(sizeof(*mw), GFP_KERNEL);
+ in = kzalloc(inlen, GFP_KERNEL);
+ if (!mw || !in) {
+ err = -ENOMEM;
+ goto free;
}
- return count;
-}
-
-static ssize_t miss_show(struct cache_order *co, struct order_attribute *oa,
- char *buf)
-{
- struct mlx5_ib_dev *dev = co->dev;
- struct mlx5_mr_cache *cache = &dev->cache;
- struct mlx5_cache_ent *ent = &cache->ent[co->index];
- int err;
-
- err = snprintf(buf, 20, "%d\n", ent->miss);
- return err;
-}
-
-static ssize_t miss_store(struct cache_order *co, struct order_attribute *oa,
- const char *buf, size_t count)
-{
- struct mlx5_ib_dev *dev = co->dev;
- struct mlx5_mr_cache *cache = &dev->cache;
- struct mlx5_cache_ent *ent = &cache->ent[co->index];
- u32 var;
-
- if (kstrtouint(buf, 0, &var))
- return -EINVAL;
-
- if (var != 0)
- return -EINVAL;
-
- ent->miss = var;
-
- return count;
-}
-
-static ssize_t size_show(struct cache_order *co, struct order_attribute *oa,
- char *buf)
-{
- struct mlx5_ib_dev *dev = co->dev;
- struct mlx5_mr_cache *cache = &dev->cache;
- struct mlx5_cache_ent *ent = &cache->ent[co->index];
- int err;
-
- err = snprintf(buf, 20, "%d\n", ent->size);
- return err;
-}
-
-static ssize_t size_store(struct cache_order *co, struct order_attribute *oa,
- const char *buf, size_t count)
-{
- struct mlx5_ib_dev *dev = co->dev;
- struct mlx5_mr_cache *cache = &dev->cache;
- struct mlx5_cache_ent *ent = &cache->ent[co->index];
- u32 var;
- int err;
+ mkc = MLX5_ADDR_OF(create_mkey_in, in, memory_key_mkey_entry);
- if (kstrtouint(buf, 0, &var))
- return -EINVAL;
+ MLX5_SET(mkc, mkc, free, 1);
+ MLX5_SET(mkc, mkc, translations_octword_size, ndescs);
+ MLX5_SET(mkc, mkc, pd, to_mpd(pd)->pdn);
+ MLX5_SET(mkc, mkc, umr_en, 1);
+ MLX5_SET(mkc, mkc, lr, 1);
+ MLX5_SET(mkc, mkc, access_mode, MLX5_ACCESS_MODE_KLM);
+ MLX5_SET(mkc, mkc, en_rinval, !!((type == IB_MW_TYPE_2)));
+ MLX5_SET(mkc, mkc, qpn, 0xffffff);
- if (var < ent->limit)
- return -EINVAL;
+ err = mlx5_core_create_mkey(dev->mdev, &mw->mmkey,
+ (struct mlx5_create_mkey_mbox_in *)in,
+ inlen, NULL, NULL, NULL);
+ if (err)
+ goto free;
- if (var > ent->size) {
- do {
- err = add_keys(dev, co->index, var - ent->size);
- if (err && err != -EAGAIN)
- return err;
+ mw->ibmw.rkey = mw->mmkey.key;
- usleep_range(3000, 5000);
- } while (err);
- } else if (var < ent->size) {
- remove_keys(dev, co->index, ent->size - var);
+ resp.response_length = min(offsetof(typeof(resp), response_length) +
+ sizeof(resp.response_length), udata->outlen);
+ if (resp.response_length) {
+ err = ib_copy_to_udata(udata, &resp, resp.response_length);
+ if (err) {
+ mlx5_core_destroy_mkey(dev->mdev, &mw->mmkey);
+ goto free;
+ }
}
- return count;
-}
-
-static ssize_t order_attr_show(struct kobject *kobj,
- struct attribute *attr, char *buf)
-{
- struct order_attribute *oa =
- container_of(attr, struct order_attribute, attr);
- struct cache_order *co = container_of(kobj, struct cache_order, kobj);
-
- if (!oa->show)
- return -EIO;
-
- return oa->show(co, oa, buf);
-}
-
-static ssize_t order_attr_store(struct kobject *kobj,
- struct attribute *attr, const char *buf, size_t size)
-{
- struct order_attribute *oa =
- container_of(attr, struct order_attribute, attr);
- struct cache_order *co = container_of(kobj, struct cache_order, kobj);
-
- if (!oa->store)
- return -EIO;
+ kfree(in);
+ return &mw->ibmw;
- return oa->store(co, oa, buf, size);
+free:
+ kfree(mw);
+ kfree(in);
+ return ERR_PTR(err);
}
-static const struct sysfs_ops order_sysfs_ops = {
- .show = order_attr_show,
- .store = order_attr_store,
-};
-
-#define ORDER_ATTR(_name) struct order_attribute order_attr_##_name = \
- __ATTR(_name, 0644, _name##_show, _name##_store)
-#define ORDER_ATTR_RO(_name) struct order_attribute order_attr_##_name = \
- __ATTR(_name, 0444, _name##_show, NULL)
-
-static ORDER_ATTR_RO(cur);
-static ORDER_ATTR(limit);
-static ORDER_ATTR(miss);
-static ORDER_ATTR(size);
-
-static struct attribute *order_default_attrs[] = {
- &order_attr_cur.attr,
- &order_attr_limit.attr,
- &order_attr_miss.attr,
- &order_attr_size.attr,
- NULL
-};
-
-static struct kobj_type order_type = {
- .sysfs_ops = &order_sysfs_ops,
- .default_attrs = order_default_attrs
-};
-
-
-
-struct cache_attribute {
- struct attribute attr;
- ssize_t (*show)(struct mlx5_ib_dev *dev, char *buf);
- ssize_t (*store)(struct mlx5_ib_dev *dev, const char *buf, size_t count);
-};
-
-static ssize_t rel_imm_show(struct mlx5_ib_dev *dev, char *buf)
+int mlx5_ib_dealloc_mw(struct ib_mw *mw)
{
- struct mlx5_mr_cache *cache = &dev->cache;
+ struct mlx5_ib_mw *mmw = to_mmw(mw);
int err;
- err = snprintf(buf, 20, "%d\n", cache->rel_imm);
+ err = mlx5_core_destroy_mkey((to_mdev(mw->device))->mdev,
+ &mmw->mmkey);
+ if (!err)
+ kfree(mmw);
return err;
}
-static ssize_t rel_imm_store(struct mlx5_ib_dev *dev, const char *buf, size_t count)
+int mlx5_ib_check_mr_status(struct ib_mr *ibmr, u32 check_mask,
+ struct ib_mr_status *mr_status)
{
- struct mlx5_mr_cache *cache = &dev->cache;
- u32 var;
- int i;
- int found = 0;
-
- if (kstrtouint(buf, 0, &var))
- return -EINVAL;
+ struct mlx5_ib_mr *mmr = to_mmr(ibmr);
+ int ret = 0;
- if (var > 1)
- return -EINVAL;
+ if (check_mask & ~IB_MR_CHECK_SIG_STATUS) {
+ pr_err("Invalid status check mask\n");
+ ret = -EINVAL;
+ goto done;
+ }
- if (var == cache->rel_imm)
- return count;
+ mr_status->fail_status = 0;
+ if (check_mask & IB_MR_CHECK_SIG_STATUS) {
+ if (!mmr->sig) {
+ ret = -EINVAL;
+ pr_err("signature status check requested on a non-signature enabled MR\n");
+ goto done;
+ }
- cache->rel_imm = var;
- if (cache->rel_imm == 1) {
- for (i = 0; i < MAX_MR_CACHE_ENTRIES; i++) {
- if (cache->ent[i].cur > 2 * cache->ent[i].limit) {
- queue_work(cache->wq, &cache->ent[i].work);
- found = 1;
- }
+ mmr->sig->sig_status_checked = true;
+ if (!mmr->sig->sig_err_exists)
+ goto done;
+
+ if (ibmr->lkey == mmr->sig->err_item.key)
+ memcpy(&mr_status->sig_err, &mmr->sig->err_item,
+ sizeof(mr_status->sig_err));
+ else {
+ mr_status->sig_err.err_type = IB_SIG_BAD_GUARD;
+ mr_status->sig_err.sig_err_offset = 0;
+ mr_status->sig_err.key = mmr->sig->err_item.key;
}
- if (!found)
- cache->rel_imm = 0;
- }
- return count;
-}
-static ssize_t rel_timeout_show(struct mlx5_ib_dev *dev, char *buf)
-{
- struct mlx5_mr_cache *cache = &dev->cache;
- int err;
+ mmr->sig->sig_err_exists = false;
+ mr_status->fail_status |= IB_MR_CHECK_SIG_STATUS;
+ }
- err = snprintf(buf, 20, "%d\n", cache->rel_timeout);
- return err;
+done:
+ return ret;
}
-static ssize_t rel_timeout_store(struct mlx5_ib_dev *dev, const char *buf, size_t count)
+static int
+mlx5_ib_sg_to_klms(struct mlx5_ib_mr *mr,
+ struct scatterlist *sgl,
+ unsigned short sg_nents,
+ unsigned int *sg_offset_p)
{
- struct mlx5_mr_cache *cache = &dev->cache;
- int var;
+ struct scatterlist *sg = sgl;
+ struct mlx5_klm *klms = mr->descs;
+ unsigned int sg_offset = sg_offset_p ? *sg_offset_p : 0;
+ u32 lkey = mr->ibmr.pd->local_dma_lkey;
int i;
- if (kstrtoint(buf, 0, &var))
- return -EINVAL;
-
- if (var < -1 || var > MAX_MR_RELEASE_TIMEOUT)
- return -EINVAL;
+ mr->ibmr.iova = sg_dma_address(sg) + sg_offset;
+ mr->ibmr.length = 0;
+ mr->ndescs = sg_nents;
- if (var == cache->rel_timeout)
- return count;
+ for_each_sg(sgl, sg, sg_nents, i) {
+ if (unlikely(i > mr->max_descs))
+ break;
+ klms[i].va = cpu_to_be64(sg_dma_address(sg) + sg_offset);
+ klms[i].bcount = cpu_to_be32(sg_dma_len(sg) - sg_offset);
+ klms[i].key = cpu_to_be32(lkey);
+ mr->ibmr.length += sg_dma_len(sg);
- if (cache->rel_timeout == -1 || (var < cache->rel_timeout && var != -1)) {
- cache->rel_timeout = var;
- for (i = 0; i < MAX_MR_CACHE_ENTRIES; i++) {
- if (cache->ent[i].cur > 2 * cache->ent[i].limit)
- queue_work(cache->wq, &cache->ent[i].work);
- }
- } else {
- cache->rel_timeout = var;
+ sg_offset = 0;
}
- return count;
-}
-
-static ssize_t cache_attr_show(struct kobject *kobj,
- struct attribute *attr, char *buf)
-{
- struct cache_attribute *ca =
- container_of(attr, struct cache_attribute, attr);
- struct mlx5_ib_dev *dev = container_of(kobj, struct mlx5_ib_dev, mr_cache);
-
- if (!ca->show)
- return -EIO;
+ if (sg_offset_p)
+ *sg_offset_p = sg_offset;
- return ca->show(dev, buf);
+ return i;
}
-static ssize_t cache_attr_store(struct kobject *kobj,
- struct attribute *attr, const char *buf, size_t size)
+static int mlx5_set_page(struct ib_mr *ibmr, u64 addr)
{
- struct cache_attribute *ca =
- container_of(attr, struct cache_attribute, attr);
- struct mlx5_ib_dev *dev = container_of(kobj, struct mlx5_ib_dev, mr_cache);
-
- if (!ca->store)
- return -EIO;
-
- return ca->store(dev, buf, size);
-}
-
-static const struct sysfs_ops cache_sysfs_ops = {
- .show = cache_attr_show,
- .store = cache_attr_store,
-};
-
-#define CACHE_ATTR(_name) struct cache_attribute cache_attr_##_name = \
- __ATTR(_name, 0644, _name##_show, _name##_store)
+ struct mlx5_ib_mr *mr = to_mmr(ibmr);
+ __be64 *descs;
-static CACHE_ATTR(rel_imm);
-static CACHE_ATTR(rel_timeout);
+ if (unlikely(mr->ndescs == mr->max_descs))
+ return -ENOMEM;
-static struct attribute *cache_default_attrs[] = {
- &cache_attr_rel_imm.attr,
- &cache_attr_rel_timeout.attr,
- NULL
-};
+ descs = mr->descs;
+ descs[mr->ndescs++] = cpu_to_be64(addr | MLX5_EN_RD | MLX5_EN_WR);
-static struct kobj_type cache_type = {
- .sysfs_ops = &cache_sysfs_ops,
- .default_attrs = cache_default_attrs
-};
+ return 0;
+}
-static int mlx5_mr_sysfs_init(struct mlx5_ib_dev *dev)
+int mlx5_ib_map_mr_sg(struct ib_mr *ibmr, struct scatterlist *sg, int sg_nents,
+ unsigned int *sg_offset)
{
- struct mlx5_mr_cache *cache = &dev->cache;
- struct device *device = &dev->ib_dev.dev;
- struct cache_order *co;
- int o;
- int i;
- int err;
-
- err = kobject_init_and_add(&dev->mr_cache, &cache_type,
- &device->kobj, "mr_cache");
- if (err)
- return -ENOMEM;
-
- for (o = 2, i = 0; i < MAX_MR_CACHE_ENTRIES; o++, i++) {
- co = &cache->ent[i].co;
- co->order = o;
- co->index = i;
- co->dev = dev;
- err = kobject_init_and_add(&co->kobj, &order_type,
- &dev->mr_cache, "%d", o);
- if (err)
- goto err_put;
- }
+ struct mlx5_ib_mr *mr = to_mmr(ibmr);
+ int n;
- return 0;
+ mr->ndescs = 0;
-err_put:
- for (; i >= 0; i--) {
- co = &cache->ent[i].co;
- kobject_put(&co->kobj);
- }
- kobject_put(&dev->mr_cache);
+ ib_dma_sync_single_for_cpu(ibmr->device, mr->desc_map,
+ mr->desc_size * mr->max_descs,
+ DMA_TO_DEVICE);
- return err;
-}
+ if (mr->access_mode == MLX5_ACCESS_MODE_KLM)
+ n = mlx5_ib_sg_to_klms(mr, sg, sg_nents, sg_offset);
+ else
+ n = ib_sg_to_pages(ibmr, sg, sg_nents, sg_offset,
+ mlx5_set_page);
-static void mlx5_mr_sysfs_cleanup(struct mlx5_ib_dev *dev)
-{
- struct mlx5_mr_cache *cache = &dev->cache;
- struct cache_order *co;
- int i;
+ ib_dma_sync_single_for_device(ibmr->device, mr->desc_map,
+ mr->desc_size * mr->max_descs,
+ DMA_TO_DEVICE);
- for (i = MAX_MR_CACHE_ENTRIES - 1; i >= 0; i--) {
- co = &cache->ent[i].co;
- kobject_put(&co->kobj);
- }
- kobject_put(&dev->mr_cache);
+ return n;
}
diff --git a/sys/dev/mlx5/mlx5_ib/mlx5_ib_qp.c b/sys/dev/mlx5/mlx5_ib/mlx5_ib_qp.c
index 761ac32..53b4e58 100644
--- a/sys/dev/mlx5/mlx5_ib/mlx5_ib_qp.c
+++ b/sys/dev/mlx5/mlx5_ib/mlx5_ib_qp.c
@@ -26,22 +26,13 @@
*/
#include <linux/module.h>
-#include <rdma/ib_cache.h>
#include <rdma/ib_umem.h>
+#include <rdma/ib_cache.h>
+#include <rdma/ib_user_verbs.h>
#include "mlx5_ib.h"
-#include "user.h"
-#include <dev/mlx5/mlx5_core/transobj.h>
-#include <sys/priv.h>
-
-#define IPV6_DEFAULT_HOPLIMIT 64
-
-
-static int __mlx5_ib_modify_qp(struct ib_qp *ibqp,
- const struct ib_qp_attr *attr, int attr_mask,
- enum ib_qp_state cur_state, enum ib_qp_state new_state);
/* not supported currently */
-static int workqueue_signature;
+static int wq_signature;
enum {
MLX5_IB_ACK_REQ_FREQ = 8,
@@ -56,11 +47,11 @@ enum {
enum {
MLX5_IB_SQ_STRIDE = 6,
- MLX5_IB_CACHE_LINE_SIZE = 64,
};
static const u32 mlx5_ib_opcode[] = {
[IB_WR_SEND] = MLX5_OPCODE_SEND,
+ [IB_WR_LSO] = MLX5_OPCODE_LSO,
[IB_WR_SEND_WITH_IMM] = MLX5_OPCODE_SEND_IMM,
[IB_WR_RDMA_WRITE] = MLX5_OPCODE_RDMA_WRITE,
[IB_WR_RDMA_WRITE_WITH_IMM] = MLX5_OPCODE_RDMA_WRITE_IMM,
@@ -69,31 +60,36 @@ static const u32 mlx5_ib_opcode[] = {
[IB_WR_ATOMIC_FETCH_AND_ADD] = MLX5_OPCODE_ATOMIC_FA,
[IB_WR_SEND_WITH_INV] = MLX5_OPCODE_SEND_INVAL,
[IB_WR_LOCAL_INV] = MLX5_OPCODE_UMR,
- [IB_WR_FAST_REG_MR] = MLX5_OPCODE_UMR,
+ [IB_WR_REG_MR] = MLX5_OPCODE_UMR,
[IB_WR_MASKED_ATOMIC_CMP_AND_SWP] = MLX5_OPCODE_ATOMIC_MASKED_CS,
[IB_WR_MASKED_ATOMIC_FETCH_AND_ADD] = MLX5_OPCODE_ATOMIC_MASKED_FA,
+ [MLX5_IB_WR_UMR] = MLX5_OPCODE_UMR,
};
-struct umr_wr {
- u64 virt_addr;
- struct ib_pd *pd;
- unsigned int page_shift;
- unsigned int npages;
- u32 length;
- int access_flags;
- u32 mkey;
+struct mlx5_wqe_eth_pad {
+ u8 rsvd0[16];
};
+enum raw_qp_set_mask_map {
+ MLX5_RAW_QP_MOD_SET_RQ_Q_CTR_ID = 1UL << 0,
+};
+
+struct mlx5_modify_raw_qp_param {
+ u16 operation;
+
+ u32 set_mask; /* raw_qp_set_mask_map */
+ u8 rq_q_ctr_id;
+};
+
+static void get_cqs(enum ib_qp_type qp_type,
+ struct ib_cq *ib_send_cq, struct ib_cq *ib_recv_cq,
+ struct mlx5_ib_cq **send_cq, struct mlx5_ib_cq **recv_cq);
+
static int is_qp0(enum ib_qp_type qp_type)
{
return qp_type == IB_QPT_SMI;
}
-static int is_qp1(enum ib_qp_type qp_type)
-{
- return qp_type == IB_QPT_GSI;
-}
-
static int is_sqp(enum ib_qp_type qp_type)
{
return is_qp0(qp_type) || is_qp1(qp_type);
@@ -114,90 +110,76 @@ void *mlx5_get_send_wqe(struct mlx5_ib_qp *qp, int n)
return get_wqe(qp, qp->sq.offset + (n << MLX5_IB_SQ_STRIDE));
}
-
-static int
-query_wqe_idx(struct mlx5_ib_qp *qp)
+/**
+ * mlx5_ib_read_user_wqe() - Copy a user-space WQE to kernel space.
+ *
+ * @qp: QP to copy from.
+ * @send: copy from the send queue when non-zero, use the receive queue
+ * otherwise.
+ * @wqe_index: index to start copying from. For send work queues, the
+ * wqe_index is in units of MLX5_SEND_WQE_BB.
+ * For receive work queue, it is the number of work queue
+ * element in the queue.
+ * @buffer: destination buffer.
+ * @length: maximum number of bytes to copy.
+ *
+ * Copies at least a single WQE, but may copy more data.
+ *
+ * Return: the number of bytes copied, or an error code.
+ */
+int mlx5_ib_read_user_wqe(struct mlx5_ib_qp *qp, int send, int wqe_index,
+ void *buffer, u32 length,
+ struct mlx5_ib_qp_base *base)
{
- struct mlx5_ib_dev *dev = to_mdev(qp->ibqp.device);
- struct mlx5_query_qp_mbox_out *outb;
- struct mlx5_qp_context *context;
+ struct ib_device *ibdev = qp->ibqp.device;
+ struct mlx5_ib_dev *dev = to_mdev(ibdev);
+ struct mlx5_ib_wq *wq = send ? &qp->sq : &qp->rq;
+ size_t offset;
+ size_t wq_end;
+ struct ib_umem *umem = base->ubuffer.umem;
+ u32 first_copy_length;
+ int wqe_length;
int ret;
- outb = kzalloc(sizeof(*outb), GFP_KERNEL);
- if (!outb)
- return -ENOMEM;
-
- context = &outb->ctx;
-
- mutex_lock(&qp->mutex);
- ret = mlx5_core_qp_query(dev->mdev, &qp->mqp, outb, sizeof(*outb));
- if (ret)
- goto out_free;
-
- ret = be16_to_cpu(context->hw_sq_wqe_counter) & (qp->sq.wqe_cnt - 1);
-
-out_free:
- mutex_unlock(&qp->mutex);
- kfree(outb);
-
- return ret;
-}
-
-static int mlx5_handle_sig_pipelining(struct mlx5_ib_qp *qp)
-{
- int wqe_idx;
-
- wqe_idx = query_wqe_idx(qp);
- if (wqe_idx < 0) {
- printf("mlx5_ib: ERR: ""Failed to query QP 0x%x wqe index\n", qp->mqp.qpn);
- return wqe_idx;
+ if (wq->wqe_cnt == 0) {
+ mlx5_ib_dbg(dev, "mlx5_ib_read_user_wqe for a QP with wqe_cnt == 0. qp_type: 0x%x\n",
+ qp->ibqp.qp_type);
+ return -EINVAL;
}
- if (qp->sq.swr_ctx[wqe_idx].sig_piped) {
- struct mlx5_ib_dev *dev = to_mdev(qp->ibqp.device);
- struct mlx5_wqe_ctrl_seg *cwqe;
+ offset = wq->offset + ((wqe_index % wq->wqe_cnt) << wq->wqe_shift);
+ wq_end = wq->offset + (wq->wqe_cnt << wq->wqe_shift);
- cwqe = mlx5_get_send_wqe(qp, wqe_idx);
- cwqe->opmod_idx_opcode = cpu_to_be32(be32_to_cpu(cwqe->opmod_idx_opcode) & 0xffffff00);
- qp->sq.swr_ctx[wqe_idx].w_list.opcode |= MLX5_OPCODE_SIGNATURE_CANCELED;
- mlx5_ib_dbg(dev, "Cancel QP 0x%x wqe_index 0x%x\n",
- qp->mqp.qpn, wqe_idx);
- }
-
- return 0;
-}
+ if (send && length < sizeof(struct mlx5_wqe_ctrl_seg))
+ return -EINVAL;
-static void mlx5_ib_sqd_work(struct work_struct *work)
-{
- struct mlx5_ib_sqd *sqd;
- struct mlx5_ib_qp *qp;
- struct ib_qp_attr qp_attr;
+ if (offset > umem->length ||
+ (send && offset + sizeof(struct mlx5_wqe_ctrl_seg) > umem->length))
+ return -EINVAL;
- sqd = container_of(work, struct mlx5_ib_sqd, work);
- qp = sqd->qp;
+ first_copy_length = min_t(u32, offset + length, wq_end) - offset;
+ ret = ib_umem_copy_from(buffer, umem, offset, first_copy_length);
+ if (ret)
+ return ret;
- if (mlx5_handle_sig_pipelining(qp))
- goto out;
+ if (send) {
+ struct mlx5_wqe_ctrl_seg *ctrl = buffer;
+ int ds = be32_to_cpu(ctrl->qpn_ds) & MLX5_WQE_CTRL_DS_MASK;
- mutex_lock(&qp->mutex);
- if (__mlx5_ib_modify_qp(&qp->ibqp, &qp_attr, 0, IB_QPS_SQD, IB_QPS_RTS))
- printf("mlx5_ib: ERR: ""Failed to resume QP 0x%x\n", qp->mqp.qpn);
- mutex_unlock(&qp->mutex);
-out:
- kfree(sqd);
-}
+ wqe_length = ds * MLX5_WQE_DS_UNITS;
+ } else {
+ wqe_length = 1 << wq->wqe_shift;
+ }
-static void mlx5_ib_sigerr_sqd_event(struct mlx5_ib_qp *qp)
-{
- struct mlx5_ib_sqd *sqd;
+ if (wqe_length <= first_copy_length)
+ return first_copy_length;
- sqd = kzalloc(sizeof(*sqd), GFP_ATOMIC);
- if (!sqd)
- return;
+ ret = ib_umem_copy_from(buffer + first_copy_length, umem, wq->offset,
+ wqe_length - first_copy_length);
+ if (ret)
+ return ret;
- sqd->qp = qp;
- INIT_WORK(&sqd->work, mlx5_ib_sqd_work);
- queue_work(mlx5_ib_wq, &sqd->work);
+ return wqe_length;
}
static void mlx5_ib_qp_event(struct mlx5_core_qp *qp, int type)
@@ -205,15 +187,11 @@ static void mlx5_ib_qp_event(struct mlx5_core_qp *qp, int type)
struct ib_qp *ibqp = &to_mibqp(qp)->ibqp;
struct ib_event event;
- if (type == MLX5_EVENT_TYPE_SQ_DRAINED &&
- to_mibqp(qp)->state != IB_QPS_SQD) {
- mlx5_ib_sigerr_sqd_event(to_mibqp(qp));
- return;
+ if (type == MLX5_EVENT_TYPE_PATH_MIG) {
+ /* This event is only valid for trans_qps */
+ to_mibqp(qp)->port = to_mibqp(qp)->trans_qp.alt_port;
}
- if (type == MLX5_EVENT_TYPE_PATH_MIG)
- to_mibqp(qp)->port = to_mibqp(qp)->alt_port;
-
if (ibqp->event_handler) {
event.device = ibqp->device;
event.element.qp = ibqp;
@@ -243,7 +221,7 @@ static void mlx5_ib_qp_event(struct mlx5_core_qp *qp, int type)
event.event = IB_EVENT_QP_ACCESS_ERR;
break;
default:
- printf("mlx5_ib: WARN: ""mlx5_ib: Unexpected event type %d on QP %06x\n", type, qp->qpn);
+ pr_warn("mlx5_ib: Unexpected event type %d on QP %06x\n", type, qp->qpn);
return;
}
@@ -296,20 +274,20 @@ static int set_rq_size(struct mlx5_ib_dev *dev, struct ib_qp_cap *cap,
return 0;
}
-static int sq_overhead(enum ib_qp_type qp_type)
+static int sq_overhead(struct ib_qp_init_attr *attr)
{
int size = 0;
- switch (qp_type) {
+ switch (attr->qp_type) {
case IB_QPT_XRC_INI:
size += sizeof(struct mlx5_wqe_xrc_seg);
/* fall through */
case IB_QPT_RC:
size += sizeof(struct mlx5_wqe_ctrl_seg) +
- sizeof(struct mlx5_wqe_atomic_seg) +
- sizeof(struct mlx5_wqe_raddr_seg) +
- sizeof(struct mlx5_wqe_umr_ctrl_seg) +
- sizeof(struct mlx5_mkey_seg);
+ max(sizeof(struct mlx5_wqe_atomic_seg) +
+ sizeof(struct mlx5_wqe_raddr_seg),
+ sizeof(struct mlx5_wqe_umr_ctrl_seg) +
+ sizeof(struct mlx5_mkey_seg));
break;
case IB_QPT_XRC_TGT:
@@ -317,18 +295,28 @@ static int sq_overhead(enum ib_qp_type qp_type)
case IB_QPT_UC:
size += sizeof(struct mlx5_wqe_ctrl_seg) +
- sizeof(struct mlx5_wqe_raddr_seg) +
- sizeof(struct mlx5_wqe_umr_ctrl_seg) +
- sizeof(struct mlx5_mkey_seg);
+ max(sizeof(struct mlx5_wqe_raddr_seg),
+ sizeof(struct mlx5_wqe_umr_ctrl_seg) +
+ sizeof(struct mlx5_mkey_seg));
break;
case IB_QPT_UD:
+ if (attr->create_flags & IB_QP_CREATE_IPOIB_UD_LSO)
+ size += sizeof(struct mlx5_wqe_eth_pad) +
+ sizeof(struct mlx5_wqe_eth_seg);
+ /* fall through */
case IB_QPT_SMI:
- case IB_QPT_GSI:
+ case MLX5_IB_QPT_HW_GSI:
size += sizeof(struct mlx5_wqe_ctrl_seg) +
sizeof(struct mlx5_wqe_datagram_seg);
break;
+ case MLX5_IB_QPT_REG_UMR:
+ size += sizeof(struct mlx5_wqe_ctrl_seg) +
+ sizeof(struct mlx5_wqe_umr_ctrl_seg) +
+ sizeof(struct mlx5_mkey_seg);
+ break;
+
default:
return -EINVAL;
}
@@ -341,7 +329,7 @@ static int calc_send_wqe(struct ib_qp_init_attr *attr)
int inl_size = 0;
int size;
- size = sq_overhead(attr->qp_type);
+ size = sq_overhead(attr);
if (size < 0)
return size;
@@ -351,30 +339,11 @@ static int calc_send_wqe(struct ib_qp_init_attr *attr)
}
size += attr->cap.max_send_sge * sizeof(struct mlx5_wqe_data_seg);
- return ALIGN(max_t(int, inl_size, size), MLX5_SEND_WQE_BB);
-}
-
-static int get_send_sge(struct ib_qp_init_attr *attr, int wqe_size)
-{
- int max_sge;
-
- if (attr->qp_type == IB_QPT_RC)
- max_sge = (min_t(int, wqe_size, 512) -
- sizeof(struct mlx5_wqe_ctrl_seg) -
- sizeof(struct mlx5_wqe_raddr_seg)) /
- sizeof(struct mlx5_wqe_data_seg);
- else if (attr->qp_type == IB_QPT_XRC_INI)
- max_sge = (min_t(int, wqe_size, 512) -
- sizeof(struct mlx5_wqe_ctrl_seg) -
- sizeof(struct mlx5_wqe_xrc_seg) -
- sizeof(struct mlx5_wqe_raddr_seg)) /
- sizeof(struct mlx5_wqe_data_seg);
+ if (attr->create_flags & IB_QP_CREATE_SIGNATURE_EN &&
+ ALIGN(max_t(int, inl_size, size), MLX5_SEND_WQE_BB) < MLX5_SIG_WQE_SIZE)
+ return MLX5_SIG_WQE_SIZE;
else
- max_sge = (wqe_size - sq_overhead(attr->qp_type)) /
- sizeof(struct mlx5_wqe_data_seg);
-
- return min_t(int, max_sge, wqe_size - sq_overhead(attr->qp_type) /
- sizeof(struct mlx5_wqe_data_seg));
+ return ALIGN(max_t(int, inl_size, size), MLX5_SEND_WQE_BB);
}
static int calc_sq_size(struct mlx5_ib_dev *dev, struct ib_qp_init_attr *attr,
@@ -392,32 +361,28 @@ static int calc_sq_size(struct mlx5_ib_dev *dev, struct ib_qp_init_attr *attr,
return wqe_size;
if (wqe_size > MLX5_CAP_GEN(dev->mdev, max_wqe_sz_sq)) {
- mlx5_ib_warn(dev, "wqe_size(%d) > max_sq_desc_sz(%d)\n",
- wqe_size, MLX5_CAP_GEN(dev->mdev, max_wqe_sz_sq));
+ mlx5_ib_dbg(dev, "wqe_size(%d) > max_sq_desc_sz(%d)\n",
+ wqe_size, MLX5_CAP_GEN(dev->mdev, max_wqe_sz_sq));
return -EINVAL;
}
- qp->max_inline_data = wqe_size - sq_overhead(attr->qp_type) -
- sizeof(struct mlx5_wqe_inline_seg);
+ qp->max_inline_data = wqe_size - sq_overhead(attr) -
+ sizeof(struct mlx5_wqe_inline_seg);
attr->cap.max_inline_data = qp->max_inline_data;
- wq_size = roundup_pow_of_two(attr->cap.max_send_wr * (u64)wqe_size);
+ if (attr->create_flags & IB_QP_CREATE_SIGNATURE_EN)
+ qp->signature_en = true;
+
+ wq_size = roundup_pow_of_two(attr->cap.max_send_wr * wqe_size);
qp->sq.wqe_cnt = wq_size / MLX5_SEND_WQE_BB;
if (qp->sq.wqe_cnt > (1 << MLX5_CAP_GEN(dev->mdev, log_max_qp_sz))) {
- mlx5_ib_warn(dev, "wqe count(%d) exceeds limits(%d)\n",
- qp->sq.wqe_cnt,
- 1 << MLX5_CAP_GEN(dev->mdev, log_max_qp_sz));
+ mlx5_ib_dbg(dev, "wqe count(%d) exceeds limits(%d)\n",
+ qp->sq.wqe_cnt,
+ 1 << MLX5_CAP_GEN(dev->mdev, log_max_qp_sz));
return -ENOMEM;
}
qp->sq.wqe_shift = ilog2(MLX5_SEND_WQE_BB);
- qp->sq.max_gs = get_send_sge(attr, wqe_size);
- if (qp->sq.max_gs < attr->cap.max_send_sge) {
- mlx5_ib_warn(dev, "max sge(%d) exceeds limits(%d)\n",
- qp->sq.max_gs, attr->cap.max_send_sge);
- return -ENOMEM;
- }
-
- attr->cap.max_send_sge = qp->sq.max_gs;
+ qp->sq.max_gs = attr->cap.max_send_sge;
qp->sq.max_post = wq_size / wqe_size;
attr->cap.max_send_wr = qp->sq.max_post;
@@ -427,6 +392,7 @@ static int calc_sq_size(struct mlx5_ib_dev *dev, struct ib_qp_init_attr *attr,
static int set_user_buf_size(struct mlx5_ib_dev *dev,
struct mlx5_ib_qp *qp,
struct mlx5_ib_create_qp *ucmd,
+ struct mlx5_ib_qp_base *base,
struct ib_qp_init_attr *attr)
{
int desc_sz = 1 << qp->sq.wqe_shift;
@@ -452,14 +418,12 @@ static int set_user_buf_size(struct mlx5_ib_dev *dev,
return -EINVAL;
}
-
if (attr->qp_type == IB_QPT_RAW_PACKET) {
- qp->buf_size = qp->rq.wqe_cnt << qp->rq.wqe_shift;
- qp->sq_buf_size = qp->sq.wqe_cnt << 6;
+ base->ubuffer.buf_size = qp->rq.wqe_cnt << qp->rq.wqe_shift;
+ qp->raw_packet_qp.sq.ubuffer.buf_size = qp->sq.wqe_cnt << 6;
} else {
- qp->buf_size = (qp->rq.wqe_cnt << qp->rq.wqe_shift) +
- (qp->sq.wqe_cnt << 6);
- qp->sq_buf_size = 0;
+ base->ubuffer.buf_size = (qp->rq.wqe_cnt << qp->rq.wqe_shift) +
+ (qp->sq.wqe_cnt << 6);
}
return 0;
@@ -469,6 +433,7 @@ static int qp_has_rq(struct ib_qp_init_attr *attr)
{
if (attr->qp_type == IB_QPT_XRC_INI ||
attr->qp_type == IB_QPT_XRC_TGT || attr->srq ||
+ attr->qp_type == MLX5_IB_QPT_REG_UMR ||
!attr->cap.max_recv_wr)
return 0;
@@ -547,7 +512,6 @@ static int alloc_med_class_uuar(struct mlx5_uuar_info *uuari)
}
uuari->count[minidx]++;
-
return minidx;
}
@@ -640,10 +604,11 @@ static int to_mlx5_st(enum ib_qp_type type)
case IB_QPT_RC: return MLX5_QP_ST_RC;
case IB_QPT_UC: return MLX5_QP_ST_UC;
case IB_QPT_UD: return MLX5_QP_ST_UD;
+ case MLX5_IB_QPT_REG_UMR: return MLX5_QP_ST_REG_UMR;
case IB_QPT_XRC_INI:
case IB_QPT_XRC_TGT: return MLX5_QP_ST_XRC;
case IB_QPT_SMI: return MLX5_QP_ST_QP0;
- case IB_QPT_GSI: return MLX5_QP_ST_QP1;
+ case MLX5_IB_QPT_HW_GSI: return MLX5_QP_ST_QP1;
case IB_QPT_RAW_IPV6: return MLX5_QP_ST_RAW_IPV6;
case IB_QPT_RAW_PACKET:
case IB_QPT_RAW_ETHERTYPE: return MLX5_QP_ST_RAW_ETHERTYPE;
@@ -662,48 +627,140 @@ static int uuarn_to_uar_index(struct mlx5_uuar_info *uuari, int uuarn)
return uuari->uars[uuarn / MLX5_BF_REGS_PER_PAGE].index;
}
+static int mlx5_ib_umem_get(struct mlx5_ib_dev *dev,
+ struct ib_pd *pd,
+ unsigned long addr, size_t size,
+ struct ib_umem **umem,
+ int *npages, int *page_shift, int *ncont,
+ u32 *offset)
+{
+ int err;
+
+ *umem = ib_umem_get(pd->uobject->context, addr, size, 0, 0);
+ if (IS_ERR(*umem)) {
+ mlx5_ib_dbg(dev, "umem_get failed\n");
+ return PTR_ERR(*umem);
+ }
+
+ mlx5_ib_cont_pages(*umem, addr, npages, page_shift, ncont, NULL);
+
+ err = mlx5_ib_get_buf_offset(addr, *page_shift, offset);
+ if (err) {
+ mlx5_ib_warn(dev, "bad offset\n");
+ goto err_umem;
+ }
+
+ mlx5_ib_dbg(dev, "addr 0x%lx, size %zu, npages %d, page_shift %d, ncont %d, offset %d\n",
+ addr, size, *npages, *page_shift, *ncont, *offset);
+
+ return 0;
+
+err_umem:
+ ib_umem_release(*umem);
+ *umem = NULL;
+
+ return err;
+}
+
+static void destroy_user_rq(struct ib_pd *pd, struct mlx5_ib_rwq *rwq)
+{
+ struct mlx5_ib_ucontext *context;
+
+ context = to_mucontext(pd->uobject->context);
+ mlx5_ib_db_unmap_user(context, &rwq->db);
+ if (rwq->umem)
+ ib_umem_release(rwq->umem);
+}
+
+static int create_user_rq(struct mlx5_ib_dev *dev, struct ib_pd *pd,
+ struct mlx5_ib_rwq *rwq,
+ struct mlx5_ib_create_wq *ucmd)
+{
+ struct mlx5_ib_ucontext *context;
+ int page_shift = 0;
+ int npages;
+ u32 offset = 0;
+ int ncont = 0;
+ int err;
+
+ if (!ucmd->buf_addr)
+ return -EINVAL;
+
+ context = to_mucontext(pd->uobject->context);
+ rwq->umem = ib_umem_get(pd->uobject->context, ucmd->buf_addr,
+ rwq->buf_size, 0, 0);
+ if (IS_ERR(rwq->umem)) {
+ mlx5_ib_dbg(dev, "umem_get failed\n");
+ err = PTR_ERR(rwq->umem);
+ return err;
+ }
+
+ mlx5_ib_cont_pages(rwq->umem, ucmd->buf_addr, &npages, &page_shift,
+ &ncont, NULL);
+ err = mlx5_ib_get_buf_offset(ucmd->buf_addr, page_shift,
+ &rwq->rq_page_offset);
+ if (err) {
+ mlx5_ib_warn(dev, "bad offset\n");
+ goto err_umem;
+ }
+
+ rwq->rq_num_pas = ncont;
+ rwq->page_shift = page_shift;
+ rwq->log_page_size = page_shift - MLX5_ADAPTER_PAGE_SHIFT;
+ rwq->wq_sig = !!(ucmd->flags & MLX5_WQ_FLAG_SIGNATURE);
+
+ mlx5_ib_dbg(dev, "addr 0x%llx, size %zd, npages %d, page_shift %d, ncont %d, offset %d\n",
+ (unsigned long long)ucmd->buf_addr, rwq->buf_size,
+ npages, page_shift, ncont, offset);
+
+ err = mlx5_ib_db_map_user(context, ucmd->db_addr, &rwq->db);
+ if (err) {
+ mlx5_ib_dbg(dev, "map failed\n");
+ goto err_umem;
+ }
+
+ rwq->create_type = MLX5_WQ_USER;
+ return 0;
+
+err_umem:
+ ib_umem_release(rwq->umem);
+ return err;
+}
+
static int create_user_qp(struct mlx5_ib_dev *dev, struct ib_pd *pd,
struct mlx5_ib_qp *qp, struct ib_udata *udata,
struct ib_qp_init_attr *attr,
- struct mlx5_create_qp_mbox_in **in,
- int *inlen,
- struct mlx5_exp_ib_create_qp *ucmd)
+ u32 **in,
+ struct mlx5_ib_create_qp_resp *resp, int *inlen,
+ struct mlx5_ib_qp_base *base)
{
- struct mlx5_exp_ib_create_qp_resp resp;
struct mlx5_ib_ucontext *context;
+ struct mlx5_ib_create_qp ucmd;
+ struct mlx5_ib_ubuffer *ubuffer = &base->ubuffer;
int page_shift = 0;
int uar_index;
int npages;
u32 offset = 0;
int uuarn;
int ncont = 0;
+ __be64 *pas;
+ void *qpc;
int err;
+ err = ib_copy_from_udata(&ucmd, udata, sizeof(ucmd));
+ if (err) {
+ mlx5_ib_dbg(dev, "copy failed\n");
+ return err;
+ }
+
context = to_mucontext(pd->uobject->context);
- memset(&resp, 0, sizeof(resp));
- resp.size_of_prefix = offsetof(struct mlx5_exp_ib_create_qp_resp, prefix_reserved);
/*
* TBD: should come from the verbs when we have the API
*/
- if (ucmd->exp.comp_mask & MLX5_EXP_CREATE_QP_MASK_WC_UAR_IDX) {
- if (ucmd->exp.wc_uar_index == MLX5_EXP_CREATE_QP_DB_ONLY_UUAR) {
- /* Assign LATENCY_CLASS_LOW (DB only UUAR) to this QP */
- uuarn = alloc_uuar(&context->uuari, MLX5_IB_LATENCY_CLASS_LOW);
- if (uuarn < 0) {
- mlx5_ib_warn(dev, "DB only uuar allocation failed\n");
- return uuarn;
- }
- uar_index = uuarn_to_uar_index(&context->uuari, uuarn);
- } else if (ucmd->exp.wc_uar_index >= MLX5_IB_MAX_CTX_DYNAMIC_UARS ||
- context->dynamic_wc_uar_index[ucmd->exp.wc_uar_index] ==
- MLX5_IB_INVALID_UAR_INDEX) {
- mlx5_ib_warn(dev, "dynamic uuar allocation failed\n");
- return -EINVAL;
- } else {
- uar_index = context->dynamic_wc_uar_index[ucmd->exp.wc_uar_index];
- uuarn = MLX5_EXP_INVALID_UUAR;
- }
- } else {
+ if (qp->flags & MLX5_IB_QP_CROSS_CHANNEL)
+ /* In CROSS_CHANNEL CQ and QP must use the same UAR */
+ uuarn = MLX5_CROSS_CHANNEL_UUAR;
+ else {
uuarn = alloc_uuar(&context->uuari, MLX5_IB_LATENCY_CLASS_HIGH);
if (uuarn < 0) {
mlx5_ib_dbg(dev, "failed to allocate low latency UUAR\n");
@@ -719,68 +776,61 @@ static int create_user_qp(struct mlx5_ib_dev *dev, struct ib_pd *pd,
}
}
}
- uar_index = uuarn_to_uar_index(&context->uuari, uuarn);
}
+
+ uar_index = uuarn_to_uar_index(&context->uuari, uuarn);
mlx5_ib_dbg(dev, "uuarn 0x%x, uar_index 0x%x\n", uuarn, uar_index);
qp->rq.offset = 0;
qp->sq.wqe_shift = ilog2(MLX5_SEND_WQE_BB);
qp->sq.offset = qp->rq.wqe_cnt << qp->rq.wqe_shift;
- err = set_user_buf_size(dev, qp, (struct mlx5_ib_create_qp *)ucmd, attr);
+ err = set_user_buf_size(dev, qp, &ucmd, base, attr);
if (err)
goto err_uuar;
- if (ucmd->buf_addr && qp->buf_size) {
- qp->umem = ib_umem_get(pd->uobject->context, ucmd->buf_addr,
- qp->buf_size, 0, 0);
- if (IS_ERR(qp->umem)) {
- mlx5_ib_warn(dev, "umem_get failed\n");
- err = PTR_ERR(qp->umem);
+ if (ucmd.buf_addr && ubuffer->buf_size) {
+ ubuffer->buf_addr = ucmd.buf_addr;
+ err = mlx5_ib_umem_get(dev, pd, ubuffer->buf_addr,
+ ubuffer->buf_size,
+ &ubuffer->umem, &npages, &page_shift,
+ &ncont, &offset);
+ if (err)
goto err_uuar;
- }
} else {
- qp->umem = NULL;
+ ubuffer->umem = NULL;
}
- if (qp->umem) {
- mlx5_ib_cont_pages(qp->umem, ucmd->buf_addr, &npages, &page_shift,
- &ncont, NULL);
- err = mlx5_ib_get_buf_offset(ucmd->buf_addr, page_shift, &offset);
- if (err) {
- mlx5_ib_warn(dev, "bad offset\n");
- goto err_umem;
- }
- mlx5_ib_dbg(dev, "addr 0x%llx, size %d, npages %d, page_shift %d, ncont %d, offset %d\n",
- (unsigned long long)ucmd->buf_addr, qp->buf_size,
- npages, page_shift, ncont, offset);
- }
-
- *inlen = sizeof(**in) + sizeof(*(*in)->pas) * ncont;
+ *inlen = MLX5_ST_SZ_BYTES(create_qp_in) +
+ MLX5_FLD_SZ_BYTES(create_qp_in, pas[0]) * ncont;
*in = mlx5_vzalloc(*inlen);
if (!*in) {
err = -ENOMEM;
goto err_umem;
}
- if (qp->umem)
- mlx5_ib_populate_pas(dev, qp->umem, page_shift, (*in)->pas, 0);
- (*in)->ctx.log_pg_sz_remote_qpn =
- cpu_to_be32((page_shift - MLX5_ADAPTER_PAGE_SHIFT) << 24);
- (*in)->ctx.params2 = cpu_to_be32(offset << 6);
- (*in)->ctx.qp_counter_set_usr_page = cpu_to_be32(uar_index);
- resp.uuar_index = uuarn;
+ pas = (__be64 *)MLX5_ADDR_OF(create_qp_in, *in, pas);
+ if (ubuffer->umem)
+ mlx5_ib_populate_pas(dev, ubuffer->umem, page_shift, pas, 0);
+
+ qpc = MLX5_ADDR_OF(create_qp_in, *in, qpc);
+
+ MLX5_SET(qpc, qpc, log_page_size, page_shift - MLX5_ADAPTER_PAGE_SHIFT);
+ MLX5_SET(qpc, qpc, page_offset, offset);
+
+ MLX5_SET(qpc, qpc, uar_page, uar_index);
+ resp->uuar_index = uuarn;
qp->uuarn = uuarn;
- err = mlx5_ib_db_map_user(context, ucmd->db_addr, &qp->db);
+ err = mlx5_ib_db_map_user(context, ucmd.db_addr, &qp->db);
if (err) {
- mlx5_ib_warn(dev, "map failed\n");
+ mlx5_ib_dbg(dev, "map failed\n");
goto err_free;
}
- err = ib_copy_to_udata(udata, &resp, sizeof(struct mlx5_ib_create_qp_resp));
+ err = ib_copy_to_udata(udata, resp, sizeof(*resp));
if (err) {
- mlx5_ib_err(dev, "copy failed\n");
+ mlx5_ib_dbg(dev, "copy failed\n");
goto err_unmap;
}
qp->create_type = MLX5_QP_USER;
@@ -794,50 +844,52 @@ err_free:
kvfree(*in);
err_umem:
- if (qp->umem)
- ib_umem_release(qp->umem);
+ if (ubuffer->umem)
+ ib_umem_release(ubuffer->umem);
err_uuar:
free_uuar(&context->uuari, uuarn);
return err;
}
-static void destroy_qp_user(struct ib_pd *pd, struct mlx5_ib_qp *qp)
+static void destroy_qp_user(struct ib_pd *pd, struct mlx5_ib_qp *qp,
+ struct mlx5_ib_qp_base *base)
{
struct mlx5_ib_ucontext *context;
context = to_mucontext(pd->uobject->context);
mlx5_ib_db_unmap_user(context, &qp->db);
- if (qp->umem)
- ib_umem_release(qp->umem);
- if (qp->sq_umem)
- ib_umem_release(qp->sq_umem);
- /*
- * Free only the UUARs handled by the kernel.
- * UUARs of UARs allocated dynamically are handled by user.
- */
- if (qp->uuarn != MLX5_EXP_INVALID_UUAR)
- free_uuar(&context->uuari, qp->uuarn);
+ if (base->ubuffer.umem)
+ ib_umem_release(base->ubuffer.umem);
+ free_uuar(&context->uuari, qp->uuarn);
}
static int create_kernel_qp(struct mlx5_ib_dev *dev,
struct ib_qp_init_attr *init_attr,
struct mlx5_ib_qp *qp,
- struct mlx5_create_qp_mbox_in **in, int *inlen)
+ u32 **in, int *inlen,
+ struct mlx5_ib_qp_base *base)
{
enum mlx5_ib_latency_class lc = MLX5_IB_LATENCY_CLASS_LOW;
struct mlx5_uuar_info *uuari;
int uar_index;
+ void *qpc;
int uuarn;
int err;
uuari = &dev->mdev->priv.uuari;
- if (init_attr->create_flags & ~(IB_QP_CREATE_BLOCK_MULTICAST_LOOPBACK))
+ if (init_attr->create_flags & ~(IB_QP_CREATE_SIGNATURE_EN |
+ IB_QP_CREATE_BLOCK_MULTICAST_LOOPBACK |
+ IB_QP_CREATE_IPOIB_UD_LSO |
+ mlx5_ib_create_qp_sqpn_qp1()))
return -EINVAL;
+ if (init_attr->qp_type == MLX5_IB_QPT_REG_UMR)
+ lc = MLX5_IB_LATENCY_CLASS_FAST_PATH;
+
uuarn = alloc_uuar(uuari, lc);
if (uuarn < 0) {
- mlx5_ib_warn(dev, "\n");
+ mlx5_ib_dbg(dev, "\n");
return -ENOMEM;
}
@@ -846,47 +898,60 @@ static int create_kernel_qp(struct mlx5_ib_dev *dev,
err = calc_sq_size(dev, init_attr, qp);
if (err < 0) {
- mlx5_ib_warn(dev, "err %d\n", err);
+ mlx5_ib_dbg(dev, "err %d\n", err);
goto err_uuar;
}
qp->rq.offset = 0;
qp->sq.offset = qp->rq.wqe_cnt << qp->rq.wqe_shift;
- qp->buf_size = err + (qp->rq.wqe_cnt << qp->rq.wqe_shift);
+ base->ubuffer.buf_size = err + (qp->rq.wqe_cnt << qp->rq.wqe_shift);
- err = mlx5_buf_alloc(dev->mdev, qp->buf_size, PAGE_SIZE * 2, &qp->buf);
+ err = mlx5_buf_alloc(dev->mdev, base->ubuffer.buf_size,
+ 2 * PAGE_SIZE, &qp->buf);
if (err) {
- mlx5_ib_warn(dev, "err %d\n", err);
+ mlx5_ib_dbg(dev, "err %d\n", err);
goto err_uuar;
}
qp->sq.qend = mlx5_get_send_wqe(qp, qp->sq.wqe_cnt);
- *inlen = sizeof(**in) + sizeof(*(*in)->pas) * qp->buf.npages;
+ *inlen = MLX5_ST_SZ_BYTES(create_qp_in) +
+ MLX5_FLD_SZ_BYTES(create_qp_in, pas[0]) * qp->buf.npages;
*in = mlx5_vzalloc(*inlen);
if (!*in) {
err = -ENOMEM;
goto err_buf;
}
- (*in)->ctx.qp_counter_set_usr_page = cpu_to_be32(uar_index);
- (*in)->ctx.log_pg_sz_remote_qpn =
- cpu_to_be32((qp->buf.page_shift - MLX5_ADAPTER_PAGE_SHIFT) << 24);
+
+ qpc = MLX5_ADDR_OF(create_qp_in, *in, qpc);
+ MLX5_SET(qpc, qpc, uar_page, uar_index);
+ MLX5_SET(qpc, qpc, log_page_size, qp->buf.page_shift - MLX5_ADAPTER_PAGE_SHIFT);
+
/* Set "fast registration enabled" for all kernel QPs */
- (*in)->ctx.params1 |= cpu_to_be32(1 << 11);
- (*in)->ctx.sq_crq_size |= cpu_to_be16(1 << 4);
+ MLX5_SET(qpc, qpc, fre, 1);
+ MLX5_SET(qpc, qpc, rlky, 1);
+
+ if (init_attr->create_flags & mlx5_ib_create_qp_sqpn_qp1()) {
+ MLX5_SET(qpc, qpc, deth_sqpn, 1);
+ qp->flags |= MLX5_IB_QP_SQPN_QP1;
+ }
- mlx5_fill_page_array(&qp->buf, (*in)->pas);
+ mlx5_fill_page_array(&qp->buf,
+ (__be64 *)MLX5_ADDR_OF(create_qp_in, *in, pas));
err = mlx5_db_alloc(dev->mdev, &qp->db);
if (err) {
- mlx5_ib_warn(dev, "err %d\n", err);
+ mlx5_ib_dbg(dev, "err %d\n", err);
goto err_free;
}
- qp->sq.swr_ctx = kcalloc(qp->sq.wqe_cnt, sizeof(*qp->sq.swr_ctx),
- GFP_KERNEL);
- qp->rq.rwr_ctx = kcalloc(qp->rq.wqe_cnt, sizeof(*qp->rq.rwr_ctx),
- GFP_KERNEL);
- if (!qp->sq.swr_ctx || !qp->rq.rwr_ctx) {
+ qp->sq.wrid = kmalloc(qp->sq.wqe_cnt * sizeof(*qp->sq.wrid), GFP_KERNEL);
+ qp->sq.wr_data = kmalloc(qp->sq.wqe_cnt * sizeof(*qp->sq.wr_data), GFP_KERNEL);
+ qp->rq.wrid = kmalloc(qp->rq.wqe_cnt * sizeof(*qp->rq.wrid), GFP_KERNEL);
+ qp->sq.w_list = kmalloc(qp->sq.wqe_cnt * sizeof(*qp->sq.w_list), GFP_KERNEL);
+ qp->sq.wqe_head = kmalloc(qp->sq.wqe_cnt * sizeof(*qp->sq.wqe_head), GFP_KERNEL);
+
+ if (!qp->sq.wrid || !qp->sq.wr_data || !qp->rq.wrid ||
+ !qp->sq.w_list || !qp->sq.wqe_head) {
err = -ENOMEM;
goto err_wrid;
}
@@ -896,8 +961,11 @@ static int create_kernel_qp(struct mlx5_ib_dev *dev,
err_wrid:
mlx5_db_free(dev->mdev, &qp->db);
- kfree(qp->sq.swr_ctx);
- kfree(qp->rq.rwr_ctx);
+ kfree(qp->sq.wqe_head);
+ kfree(qp->sq.w_list);
+ kfree(qp->sq.wrid);
+ kfree(qp->sq.wr_data);
+ kfree(qp->rq.wrid);
err_free:
kvfree(*in);
@@ -913,22 +981,24 @@ err_uuar:
static void destroy_qp_kernel(struct mlx5_ib_dev *dev, struct mlx5_ib_qp *qp)
{
mlx5_db_free(dev->mdev, &qp->db);
- kfree(qp->sq.swr_ctx);
- kfree(qp->rq.rwr_ctx);
+ kfree(qp->sq.wqe_head);
+ kfree(qp->sq.w_list);
+ kfree(qp->sq.wrid);
+ kfree(qp->sq.wr_data);
+ kfree(qp->rq.wrid);
mlx5_buf_free(dev->mdev, &qp->buf);
free_uuar(&dev->mdev->priv.uuari, qp->bf->uuarn);
}
-static __be32 get_rx_type(struct mlx5_ib_qp *qp, struct ib_qp_init_attr *attr)
+static u32 get_rx_type(struct mlx5_ib_qp *qp, struct ib_qp_init_attr *attr)
{
- enum ib_qp_type qt = attr->qp_type;
-
- if (attr->srq || (qt == IB_QPT_XRC_TGT) || (qt == IB_QPT_XRC_INI))
- return cpu_to_be32(MLX5_SRQ_RQ);
+ if (attr->srq || (attr->qp_type == IB_QPT_XRC_TGT) ||
+ (attr->qp_type == IB_QPT_XRC_INI))
+ return MLX5_SRQ_RQ;
else if (!qp->has_rq)
- return cpu_to_be32(MLX5_ZERO_LEN_RQ);
+ return MLX5_ZERO_LEN_RQ;
else
- return cpu_to_be32(MLX5_NON_ZERO_RQ);
+ return MLX5_NON_ZERO_RQ;
}
static int is_connected(enum ib_qp_type qp_type)
@@ -939,109 +1009,574 @@ static int is_connected(enum ib_qp_type qp_type)
return 0;
}
-static void get_cqs(enum ib_qp_type qp_type,
- struct ib_cq *ib_send_cq, struct ib_cq *ib_recv_cq,
- struct mlx5_ib_cq **send_cq, struct mlx5_ib_cq **recv_cq)
+static int create_raw_packet_qp_tis(struct mlx5_ib_dev *dev,
+ struct mlx5_ib_sq *sq, u32 tdn)
{
- switch (qp_type) {
- case IB_QPT_XRC_TGT:
- *send_cq = NULL;
- *recv_cq = NULL;
- break;
- case IB_QPT_XRC_INI:
- *send_cq = ib_send_cq ? to_mcq(ib_send_cq) : NULL;
- *recv_cq = NULL;
- break;
+ u32 in[MLX5_ST_SZ_DW(create_tis_in)] = {0};
+ void *tisc = MLX5_ADDR_OF(create_tis_in, in, ctx);
- case IB_QPT_SMI:
- case IB_QPT_GSI:
- case IB_QPT_RC:
- case IB_QPT_UC:
- case IB_QPT_UD:
- case IB_QPT_RAW_IPV6:
- case IB_QPT_RAW_ETHERTYPE:
- case IB_QPT_RAW_PACKET:
- *send_cq = ib_send_cq ? to_mcq(ib_send_cq) : NULL;
- *recv_cq = ib_recv_cq ? to_mcq(ib_recv_cq) : NULL;
- break;
+ MLX5_SET(tisc, tisc, transport_domain, tdn);
+ return mlx5_core_create_tis(dev->mdev, in, sizeof(in), &sq->tisn);
+}
- case IB_QPT_MAX:
- default:
- *send_cq = NULL;
- *recv_cq = NULL;
- break;
+static void destroy_raw_packet_qp_tis(struct mlx5_ib_dev *dev,
+ struct mlx5_ib_sq *sq)
+{
+ mlx5_core_destroy_tis(dev->mdev, sq->tisn);
+}
+
+static int create_raw_packet_qp_sq(struct mlx5_ib_dev *dev,
+ struct mlx5_ib_sq *sq, void *qpin,
+ struct ib_pd *pd)
+{
+ struct mlx5_ib_ubuffer *ubuffer = &sq->ubuffer;
+ __be64 *pas;
+ void *in;
+ void *sqc;
+ void *qpc = MLX5_ADDR_OF(create_qp_in, qpin, qpc);
+ void *wq;
+ int inlen;
+ int err;
+ int page_shift = 0;
+ int npages;
+ int ncont = 0;
+ u32 offset = 0;
+
+ err = mlx5_ib_umem_get(dev, pd, ubuffer->buf_addr, ubuffer->buf_size,
+ &sq->ubuffer.umem, &npages, &page_shift,
+ &ncont, &offset);
+ if (err)
+ return err;
+
+ inlen = MLX5_ST_SZ_BYTES(create_sq_in) + sizeof(u64) * ncont;
+ in = mlx5_vzalloc(inlen);
+ if (!in) {
+ err = -ENOMEM;
+ goto err_umem;
}
+
+ sqc = MLX5_ADDR_OF(create_sq_in, in, ctx);
+ MLX5_SET(sqc, sqc, flush_in_error_en, 1);
+ MLX5_SET(sqc, sqc, state, MLX5_SQC_STATE_RST);
+ MLX5_SET(sqc, sqc, user_index, MLX5_GET(qpc, qpc, user_index));
+ MLX5_SET(sqc, sqc, cqn, MLX5_GET(qpc, qpc, cqn_snd));
+ MLX5_SET(sqc, sqc, tis_lst_sz, 1);
+ MLX5_SET(sqc, sqc, tis_num_0, sq->tisn);
+
+ wq = MLX5_ADDR_OF(sqc, sqc, wq);
+ MLX5_SET(wq, wq, wq_type, MLX5_WQ_TYPE_CYCLIC);
+ MLX5_SET(wq, wq, pd, MLX5_GET(qpc, qpc, pd));
+ MLX5_SET(wq, wq, uar_page, MLX5_GET(qpc, qpc, uar_page));
+ MLX5_SET64(wq, wq, dbr_addr, MLX5_GET64(qpc, qpc, dbr_addr));
+ MLX5_SET(wq, wq, log_wq_stride, ilog2(MLX5_SEND_WQE_BB));
+ MLX5_SET(wq, wq, log_wq_sz, MLX5_GET(qpc, qpc, log_sq_size));
+ MLX5_SET(wq, wq, log_wq_pg_sz, page_shift - MLX5_ADAPTER_PAGE_SHIFT);
+ MLX5_SET(wq, wq, page_offset, offset);
+
+ pas = (__be64 *)MLX5_ADDR_OF(wq, wq, pas);
+ mlx5_ib_populate_pas(dev, sq->ubuffer.umem, page_shift, pas, 0);
+
+ err = mlx5_core_create_sq_tracked(dev->mdev, in, inlen, &sq->base.mqp);
+
+ kvfree(in);
+
+ if (err)
+ goto err_umem;
+
+ return 0;
+
+err_umem:
+ ib_umem_release(sq->ubuffer.umem);
+ sq->ubuffer.umem = NULL;
+
+ return err;
}
-enum {
- MLX5_QP_END_PAD_MODE_ALIGN = MLX5_WQ_END_PAD_MODE_ALIGN,
- MLX5_QP_END_PAD_MODE_NONE = MLX5_WQ_END_PAD_MODE_NONE,
-};
+static void destroy_raw_packet_qp_sq(struct mlx5_ib_dev *dev,
+ struct mlx5_ib_sq *sq)
+{
+ mlx5_core_destroy_sq_tracked(dev->mdev, &sq->base.mqp);
+ ib_umem_release(sq->ubuffer.umem);
+}
+
+static int get_rq_pas_size(void *qpc)
+{
+ u32 log_page_size = MLX5_GET(qpc, qpc, log_page_size) + 12;
+ u32 log_rq_stride = MLX5_GET(qpc, qpc, log_rq_stride);
+ u32 log_rq_size = MLX5_GET(qpc, qpc, log_rq_size);
+ u32 page_offset = MLX5_GET(qpc, qpc, page_offset);
+ u32 po_quanta = 1 << (log_page_size - 6);
+ u32 rq_sz = 1 << (log_rq_size + 4 + log_rq_stride);
+ u32 page_size = 1 << log_page_size;
+ u32 rq_sz_po = rq_sz + (page_offset * po_quanta);
+ u32 rq_num_pas = (rq_sz_po + page_size - 1) / page_size;
+
+ return rq_num_pas * sizeof(u64);
+}
+
+static int create_raw_packet_qp_rq(struct mlx5_ib_dev *dev,
+ struct mlx5_ib_rq *rq, void *qpin)
+{
+ struct mlx5_ib_qp *mqp = rq->base.container_mibqp;
+ __be64 *pas;
+ __be64 *qp_pas;
+ void *in;
+ void *rqc;
+ void *wq;
+ void *qpc = MLX5_ADDR_OF(create_qp_in, qpin, qpc);
+ int inlen;
+ int err;
+ u32 rq_pas_size = get_rq_pas_size(qpc);
+
+ inlen = MLX5_ST_SZ_BYTES(create_rq_in) + rq_pas_size;
+ in = mlx5_vzalloc(inlen);
+ if (!in)
+ return -ENOMEM;
+
+ rqc = MLX5_ADDR_OF(create_rq_in, in, ctx);
+ MLX5_SET(rqc, rqc, vlan_strip_disable, 1);
+ MLX5_SET(rqc, rqc, mem_rq_type, MLX5_RQC_RQ_TYPE_MEMORY_RQ_INLINE);
+ MLX5_SET(rqc, rqc, state, MLX5_RQC_STATE_RST);
+ MLX5_SET(rqc, rqc, flush_in_error_en, 1);
+ MLX5_SET(rqc, rqc, user_index, MLX5_GET(qpc, qpc, user_index));
+ MLX5_SET(rqc, rqc, cqn, MLX5_GET(qpc, qpc, cqn_rcv));
+
+ if (mqp->flags & MLX5_IB_QP_CAP_SCATTER_FCS)
+ MLX5_SET(rqc, rqc, scatter_fcs, 1);
+
+ wq = MLX5_ADDR_OF(rqc, rqc, wq);
+ MLX5_SET(wq, wq, wq_type, MLX5_WQ_TYPE_CYCLIC);
+ MLX5_SET(wq, wq, end_padding_mode,
+ MLX5_GET(qpc, qpc, end_padding_mode));
+ MLX5_SET(wq, wq, page_offset, MLX5_GET(qpc, qpc, page_offset));
+ MLX5_SET(wq, wq, pd, MLX5_GET(qpc, qpc, pd));
+ MLX5_SET64(wq, wq, dbr_addr, MLX5_GET64(qpc, qpc, dbr_addr));
+ MLX5_SET(wq, wq, log_wq_stride, MLX5_GET(qpc, qpc, log_rq_stride) + 4);
+ MLX5_SET(wq, wq, log_wq_pg_sz, MLX5_GET(qpc, qpc, log_page_size));
+ MLX5_SET(wq, wq, log_wq_sz, MLX5_GET(qpc, qpc, log_rq_size));
+
+ pas = (__be64 *)MLX5_ADDR_OF(wq, wq, pas);
+ qp_pas = (__be64 *)MLX5_ADDR_OF(create_qp_in, qpin, pas);
+ memcpy(pas, qp_pas, rq_pas_size);
+
+ err = mlx5_core_create_rq_tracked(dev->mdev, in, inlen, &rq->base.mqp);
+
+ kvfree(in);
+
+ return err;
+}
+
+static void destroy_raw_packet_qp_rq(struct mlx5_ib_dev *dev,
+ struct mlx5_ib_rq *rq)
+{
+ mlx5_core_destroy_rq_tracked(dev->mdev, &rq->base.mqp);
+}
+
+static int create_raw_packet_qp_tir(struct mlx5_ib_dev *dev,
+ struct mlx5_ib_rq *rq, u32 tdn)
+{
+ u32 *in;
+ void *tirc;
+ int inlen;
+ int err;
+
+ inlen = MLX5_ST_SZ_BYTES(create_tir_in);
+ in = mlx5_vzalloc(inlen);
+ if (!in)
+ return -ENOMEM;
+
+ tirc = MLX5_ADDR_OF(create_tir_in, in, tir_context);
+ MLX5_SET(tirc, tirc, disp_type, MLX5_TIRC_DISP_TYPE_DIRECT);
+ MLX5_SET(tirc, tirc, inline_rqn, rq->base.mqp.qpn);
+ MLX5_SET(tirc, tirc, transport_domain, tdn);
+
+ err = mlx5_core_create_tir(dev->mdev, in, inlen, &rq->tirn);
+
+ kvfree(in);
+
+ return err;
+}
+
+static void destroy_raw_packet_qp_tir(struct mlx5_ib_dev *dev,
+ struct mlx5_ib_rq *rq)
+{
+ mlx5_core_destroy_tir(dev->mdev, rq->tirn);
+}
+
+static int create_raw_packet_qp(struct mlx5_ib_dev *dev, struct mlx5_ib_qp *qp,
+ u32 *in,
+ struct ib_pd *pd)
+{
+ struct mlx5_ib_raw_packet_qp *raw_packet_qp = &qp->raw_packet_qp;
+ struct mlx5_ib_sq *sq = &raw_packet_qp->sq;
+ struct mlx5_ib_rq *rq = &raw_packet_qp->rq;
+ struct ib_uobject *uobj = pd->uobject;
+ struct ib_ucontext *ucontext = uobj->context;
+ struct mlx5_ib_ucontext *mucontext = to_mucontext(ucontext);
+ int err;
+ u32 tdn = mucontext->tdn;
+
+ if (qp->sq.wqe_cnt) {
+ err = create_raw_packet_qp_tis(dev, sq, tdn);
+ if (err)
+ return err;
+
+ err = create_raw_packet_qp_sq(dev, sq, in, pd);
+ if (err)
+ goto err_destroy_tis;
+
+ sq->base.container_mibqp = qp;
+ }
+
+ if (qp->rq.wqe_cnt) {
+ rq->base.container_mibqp = qp;
+
+ err = create_raw_packet_qp_rq(dev, rq, in);
+ if (err)
+ goto err_destroy_sq;
+
+
+ err = create_raw_packet_qp_tir(dev, rq, tdn);
+ if (err)
+ goto err_destroy_rq;
+ }
+
+ qp->trans_qp.base.mqp.qpn = qp->sq.wqe_cnt ? sq->base.mqp.qpn :
+ rq->base.mqp.qpn;
+
+ return 0;
+
+err_destroy_rq:
+ destroy_raw_packet_qp_rq(dev, rq);
+err_destroy_sq:
+ if (!qp->sq.wqe_cnt)
+ return err;
+ destroy_raw_packet_qp_sq(dev, sq);
+err_destroy_tis:
+ destroy_raw_packet_qp_tis(dev, sq);
+
+ return err;
+}
+
+static void destroy_raw_packet_qp(struct mlx5_ib_dev *dev,
+ struct mlx5_ib_qp *qp)
+{
+ struct mlx5_ib_raw_packet_qp *raw_packet_qp = &qp->raw_packet_qp;
+ struct mlx5_ib_sq *sq = &raw_packet_qp->sq;
+ struct mlx5_ib_rq *rq = &raw_packet_qp->rq;
+
+ if (qp->rq.wqe_cnt) {
+ destroy_raw_packet_qp_tir(dev, rq);
+ destroy_raw_packet_qp_rq(dev, rq);
+ }
+
+ if (qp->sq.wqe_cnt) {
+ destroy_raw_packet_qp_sq(dev, sq);
+ destroy_raw_packet_qp_tis(dev, sq);
+ }
+}
+
+static void raw_packet_qp_copy_info(struct mlx5_ib_qp *qp,
+ struct mlx5_ib_raw_packet_qp *raw_packet_qp)
+{
+ struct mlx5_ib_sq *sq = &raw_packet_qp->sq;
+ struct mlx5_ib_rq *rq = &raw_packet_qp->rq;
+
+ sq->sq = &qp->sq;
+ rq->rq = &qp->rq;
+ sq->doorbell = &qp->db;
+ rq->doorbell = &qp->db;
+}
+
+static void destroy_rss_raw_qp_tir(struct mlx5_ib_dev *dev, struct mlx5_ib_qp *qp)
+{
+ mlx5_core_destroy_tir(dev->mdev, qp->rss_qp.tirn);
+}
+
+static int create_rss_raw_qp_tir(struct mlx5_ib_dev *dev, struct mlx5_ib_qp *qp,
+ struct ib_pd *pd,
+ struct ib_qp_init_attr *init_attr,
+ struct ib_udata *udata)
+{
+ struct ib_uobject *uobj = pd->uobject;
+ struct ib_ucontext *ucontext = uobj->context;
+ struct mlx5_ib_ucontext *mucontext = to_mucontext(ucontext);
+ struct mlx5_ib_create_qp_resp resp = {};
+ int inlen;
+ int err;
+ u32 *in;
+ void *tirc;
+ void *hfso;
+ u32 selected_fields = 0;
+ size_t min_resp_len;
+ u32 tdn = mucontext->tdn;
+ struct mlx5_ib_create_qp_rss ucmd = {};
+ size_t required_cmd_sz;
+
+ if (init_attr->qp_type != IB_QPT_RAW_PACKET)
+ return -EOPNOTSUPP;
+
+ if (init_attr->create_flags || init_attr->send_cq)
+ return -EINVAL;
+
+ min_resp_len = offsetof(typeof(resp), uuar_index) + sizeof(resp.uuar_index);
+ if (udata->outlen < min_resp_len)
+ return -EINVAL;
+
+ required_cmd_sz = offsetof(typeof(ucmd), reserved1) + sizeof(ucmd.reserved1);
+ if (udata->inlen < required_cmd_sz) {
+ mlx5_ib_dbg(dev, "invalid inlen\n");
+ return -EINVAL;
+ }
+
+ if (udata->inlen > sizeof(ucmd) &&
+ !ib_is_udata_cleared(udata, sizeof(ucmd),
+ udata->inlen - sizeof(ucmd))) {
+ mlx5_ib_dbg(dev, "inlen is not supported\n");
+ return -EOPNOTSUPP;
+ }
+
+ if (ib_copy_from_udata(&ucmd, udata, min(sizeof(ucmd), udata->inlen))) {
+ mlx5_ib_dbg(dev, "copy failed\n");
+ return -EFAULT;
+ }
+
+ if (ucmd.comp_mask) {
+ mlx5_ib_dbg(dev, "invalid comp mask\n");
+ return -EOPNOTSUPP;
+ }
+
+ if (memchr_inv(ucmd.reserved, 0, sizeof(ucmd.reserved)) || ucmd.reserved1) {
+ mlx5_ib_dbg(dev, "invalid reserved\n");
+ return -EOPNOTSUPP;
+ }
+
+ err = ib_copy_to_udata(udata, &resp, min_resp_len);
+ if (err) {
+ mlx5_ib_dbg(dev, "copy failed\n");
+ return -EINVAL;
+ }
+
+ inlen = MLX5_ST_SZ_BYTES(create_tir_in);
+ in = mlx5_vzalloc(inlen);
+ if (!in)
+ return -ENOMEM;
+
+ tirc = MLX5_ADDR_OF(create_tir_in, in, tir_context);
+ MLX5_SET(tirc, tirc, disp_type,
+ MLX5_TIRC_DISP_TYPE_INDIRECT);
+ MLX5_SET(tirc, tirc, indirect_table,
+ init_attr->rwq_ind_tbl->ind_tbl_num);
+ MLX5_SET(tirc, tirc, transport_domain, tdn);
+
+ hfso = MLX5_ADDR_OF(tirc, tirc, rx_hash_field_selector_outer);
+ switch (ucmd.rx_hash_function) {
+ case MLX5_RX_HASH_FUNC_TOEPLITZ:
+ {
+ void *rss_key = MLX5_ADDR_OF(tirc, tirc, rx_hash_toeplitz_key);
+ size_t len = MLX5_FLD_SZ_BYTES(tirc, rx_hash_toeplitz_key);
+
+ if (len != ucmd.rx_key_len) {
+ err = -EINVAL;
+ goto err;
+ }
+
+ MLX5_SET(tirc, tirc, rx_hash_fn, MLX5_RX_HASH_FUNC_TOEPLITZ);
+ MLX5_SET(tirc, tirc, rx_hash_symmetric, 1);
+ memcpy(rss_key, ucmd.rx_hash_key, len);
+ break;
+ }
+ default:
+ err = -EOPNOTSUPP;
+ goto err;
+ }
+
+ if (!ucmd.rx_hash_fields_mask) {
+ /* special case when this TIR serves as steering entry without hashing */
+ if (!init_attr->rwq_ind_tbl->log_ind_tbl_size)
+ goto create_tir;
+ err = -EINVAL;
+ goto err;
+ }
+
+ if (((ucmd.rx_hash_fields_mask & MLX5_RX_HASH_SRC_IPV4) ||
+ (ucmd.rx_hash_fields_mask & MLX5_RX_HASH_DST_IPV4)) &&
+ ((ucmd.rx_hash_fields_mask & MLX5_RX_HASH_SRC_IPV6) ||
+ (ucmd.rx_hash_fields_mask & MLX5_RX_HASH_DST_IPV6))) {
+ err = -EINVAL;
+ goto err;
+ }
+
+ /* If none of IPV4 & IPV6 SRC/DST was set - this bit field is ignored */
+ if ((ucmd.rx_hash_fields_mask & MLX5_RX_HASH_SRC_IPV4) ||
+ (ucmd.rx_hash_fields_mask & MLX5_RX_HASH_DST_IPV4))
+ MLX5_SET(rx_hash_field_select, hfso, l3_prot_type,
+ MLX5_L3_PROT_TYPE_IPV4);
+ else if ((ucmd.rx_hash_fields_mask & MLX5_RX_HASH_SRC_IPV6) ||
+ (ucmd.rx_hash_fields_mask & MLX5_RX_HASH_DST_IPV6))
+ MLX5_SET(rx_hash_field_select, hfso, l3_prot_type,
+ MLX5_L3_PROT_TYPE_IPV6);
+
+ if (((ucmd.rx_hash_fields_mask & MLX5_RX_HASH_SRC_PORT_TCP) ||
+ (ucmd.rx_hash_fields_mask & MLX5_RX_HASH_DST_PORT_TCP)) &&
+ ((ucmd.rx_hash_fields_mask & MLX5_RX_HASH_SRC_PORT_UDP) ||
+ (ucmd.rx_hash_fields_mask & MLX5_RX_HASH_DST_PORT_UDP))) {
+ err = -EINVAL;
+ goto err;
+ }
+
+ /* If none of TCP & UDP SRC/DST was set - this bit field is ignored */
+ if ((ucmd.rx_hash_fields_mask & MLX5_RX_HASH_SRC_PORT_TCP) ||
+ (ucmd.rx_hash_fields_mask & MLX5_RX_HASH_DST_PORT_TCP))
+ MLX5_SET(rx_hash_field_select, hfso, l4_prot_type,
+ MLX5_L4_PROT_TYPE_TCP);
+ else if ((ucmd.rx_hash_fields_mask & MLX5_RX_HASH_SRC_PORT_UDP) ||
+ (ucmd.rx_hash_fields_mask & MLX5_RX_HASH_DST_PORT_UDP))
+ MLX5_SET(rx_hash_field_select, hfso, l4_prot_type,
+ MLX5_L4_PROT_TYPE_UDP);
+
+ if ((ucmd.rx_hash_fields_mask & MLX5_RX_HASH_SRC_IPV4) ||
+ (ucmd.rx_hash_fields_mask & MLX5_RX_HASH_SRC_IPV6))
+ selected_fields |= MLX5_HASH_FIELD_SEL_SRC_IP;
+
+ if ((ucmd.rx_hash_fields_mask & MLX5_RX_HASH_DST_IPV4) ||
+ (ucmd.rx_hash_fields_mask & MLX5_RX_HASH_DST_IPV6))
+ selected_fields |= MLX5_HASH_FIELD_SEL_DST_IP;
+
+ if ((ucmd.rx_hash_fields_mask & MLX5_RX_HASH_SRC_PORT_TCP) ||
+ (ucmd.rx_hash_fields_mask & MLX5_RX_HASH_SRC_PORT_UDP))
+ selected_fields |= MLX5_HASH_FIELD_SEL_L4_SPORT;
+
+ if ((ucmd.rx_hash_fields_mask & MLX5_RX_HASH_DST_PORT_TCP) ||
+ (ucmd.rx_hash_fields_mask & MLX5_RX_HASH_DST_PORT_UDP))
+ selected_fields |= MLX5_HASH_FIELD_SEL_L4_DPORT;
+
+ MLX5_SET(rx_hash_field_select, hfso, selected_fields, selected_fields);
+
+create_tir:
+ err = mlx5_core_create_tir(dev->mdev, in, inlen, &qp->rss_qp.tirn);
+
+ if (err)
+ goto err;
+
+ kvfree(in);
+ /* qpn is reserved for that QP */
+ qp->trans_qp.base.mqp.qpn = 0;
+ qp->flags |= MLX5_IB_QP_RSS;
+ return 0;
+
+err:
+ kvfree(in);
+ return err;
+}
static int create_qp_common(struct mlx5_ib_dev *dev, struct ib_pd *pd,
struct ib_qp_init_attr *init_attr,
struct ib_udata *udata, struct mlx5_ib_qp *qp)
{
struct mlx5_ib_resources *devr = &dev->devr;
+ int inlen = MLX5_ST_SZ_BYTES(create_qp_in);
struct mlx5_core_dev *mdev = dev->mdev;
- struct mlx5_create_qp_mbox_in *in = NULL;
- struct mlx5_exp_ib_create_qp ucmd;
- struct mlx5_ib_create_qp *pucmd = NULL;
+ struct mlx5_ib_create_qp_resp resp;
struct mlx5_ib_cq *send_cq;
struct mlx5_ib_cq *recv_cq;
unsigned long flags;
- int inlen = sizeof(*in);
- size_t ucmd_size;
- int err;
- int st;
- u32 uidx;
+ u32 uidx = MLX5_IB_DEFAULT_UIDX;
+ struct mlx5_ib_create_qp ucmd;
+ struct mlx5_ib_qp_base *base;
void *qpc;
+ u32 *in;
+ int err;
+
+ base = init_attr->qp_type == IB_QPT_RAW_PACKET ?
+ &qp->raw_packet_qp.rq.base :
+ &qp->trans_qp.base;
+
+ if (init_attr->qp_type != IB_QPT_RAW_PACKET)
+ mlx5_ib_odp_create_qp(qp);
mutex_init(&qp->mutex);
spin_lock_init(&qp->sq.lock);
spin_lock_init(&qp->rq.lock);
+ if (init_attr->rwq_ind_tbl) {
+ if (!udata)
+ return -ENOSYS;
+
+ err = create_rss_raw_qp_tir(dev, qp, pd, init_attr, udata);
+ return err;
+ }
+
if (init_attr->create_flags & IB_QP_CREATE_BLOCK_MULTICAST_LOOPBACK) {
if (!MLX5_CAP_GEN(mdev, block_lb_mc)) {
- mlx5_ib_warn(dev, "block multicast loopback isn't supported\n");
+ mlx5_ib_dbg(dev, "block multicast loopback isn't supported\n");
return -EINVAL;
} else {
qp->flags |= MLX5_IB_QP_BLOCK_MULTICAST_LOOPBACK;
}
}
+ if (init_attr->create_flags &
+ (IB_QP_CREATE_CROSS_CHANNEL |
+ IB_QP_CREATE_MANAGED_SEND |
+ IB_QP_CREATE_MANAGED_RECV)) {
+ if (!MLX5_CAP_GEN(mdev, cd)) {
+ mlx5_ib_dbg(dev, "cross-channel isn't supported\n");
+ return -EINVAL;
+ }
+ if (init_attr->create_flags & IB_QP_CREATE_CROSS_CHANNEL)
+ qp->flags |= MLX5_IB_QP_CROSS_CHANNEL;
+ if (init_attr->create_flags & IB_QP_CREATE_MANAGED_SEND)
+ qp->flags |= MLX5_IB_QP_MANAGED_SEND;
+ if (init_attr->create_flags & IB_QP_CREATE_MANAGED_RECV)
+ qp->flags |= MLX5_IB_QP_MANAGED_RECV;
+ }
+
+ if (init_attr->qp_type == IB_QPT_UD &&
+ (init_attr->create_flags & IB_QP_CREATE_IPOIB_UD_LSO))
+ if (!MLX5_CAP_GEN(mdev, ipoib_ipoib_offloads)) {
+ mlx5_ib_dbg(dev, "ipoib UD lso qp isn't supported\n");
+ return -EOPNOTSUPP;
+ }
+
+ if (init_attr->create_flags & IB_QP_CREATE_SCATTER_FCS) {
+ if (init_attr->qp_type != IB_QPT_RAW_PACKET) {
+ mlx5_ib_dbg(dev, "Scatter FCS is supported only for Raw Packet QPs");
+ return -EOPNOTSUPP;
+ }
+ if (!MLX5_CAP_GEN(dev->mdev, eth_net_offloads) ||
+ !MLX5_CAP_ETH(dev->mdev, scatter_fcs)) {
+ mlx5_ib_dbg(dev, "Scatter FCS isn't supported\n");
+ return -EOPNOTSUPP;
+ }
+ qp->flags |= MLX5_IB_QP_CAP_SCATTER_FCS;
+ }
+
if (init_attr->sq_sig_type == IB_SIGNAL_ALL_WR)
qp->sq_signal_bits = MLX5_WQE_CTRL_CQ_UPDATE;
if (pd && pd->uobject) {
- memset(&ucmd, 0, sizeof(ucmd));
- ucmd_size = sizeof(struct mlx5_ib_create_qp);
- if (ucmd_size > offsetof(struct mlx5_exp_ib_create_qp, size_of_prefix)) {
- mlx5_ib_warn(dev, "mlx5_ib_create_qp is too big to fit as prefix of mlx5_exp_ib_create_qp\n");
- return -EINVAL;
+ if (ib_copy_from_udata(&ucmd, udata, sizeof(ucmd))) {
+ mlx5_ib_dbg(dev, "copy failed\n");
+ return -EFAULT;
}
- err = ib_copy_from_udata(&ucmd, udata, min(udata->inlen, ucmd_size));
- if (err) {
- mlx5_ib_err(dev, "copy failed\n");
+
+ err = get_qp_user_index(to_mucontext(pd->uobject->context),
+ &ucmd, udata->inlen, &uidx);
+ if (err)
return err;
- }
- pucmd = (struct mlx5_ib_create_qp *)&ucmd;
- if (ucmd.exp.comp_mask & MLX5_EXP_CREATE_QP_MASK_UIDX)
- uidx = ucmd.exp.uidx;
- else
- uidx = 0xffffff;
qp->wq_sig = !!(ucmd.flags & MLX5_QP_FLAG_SIGNATURE);
+ qp->scat_cqe = !!(ucmd.flags & MLX5_QP_FLAG_SCATTER_CQE);
} else {
- qp->wq_sig = !!workqueue_signature;
- uidx = 0xffffff;
+ qp->wq_sig = !!wq_signature;
}
qp->has_rq = qp_has_rq(init_attr);
err = set_rq_size(dev, &init_attr->cap, qp->has_rq,
- qp, (pd && pd->uobject) ? pucmd : NULL);
+ qp, (pd && pd->uobject) ? &ucmd : NULL);
if (err) {
- mlx5_ib_warn(dev, "err %d\n", err);
+ mlx5_ib_dbg(dev, "err %d\n", err);
return err;
}
@@ -1052,34 +1587,34 @@ static int create_qp_common(struct mlx5_ib_dev *dev, struct ib_pd *pd,
mlx5_ib_dbg(dev, "requested sq_wqe_count (%d)\n", ucmd.sq_wqe_count);
if (ucmd.rq_wqe_shift != qp->rq.wqe_shift ||
ucmd.rq_wqe_count != qp->rq.wqe_cnt) {
- mlx5_ib_warn(dev, "invalid rq params\n");
+ mlx5_ib_dbg(dev, "invalid rq params\n");
return -EINVAL;
}
if (ucmd.sq_wqe_count > max_wqes) {
- mlx5_ib_warn(dev, "requested sq_wqe_count (%d) > max allowed (%d)\n",
- ucmd.sq_wqe_count, max_wqes);
+ mlx5_ib_dbg(dev, "requested sq_wqe_count (%d) > max allowed (%d)\n",
+ ucmd.sq_wqe_count, max_wqes);
+ return -EINVAL;
+ }
+ if (init_attr->create_flags &
+ mlx5_ib_create_qp_sqpn_qp1()) {
+ mlx5_ib_dbg(dev, "user-space is not allowed to create UD QPs spoofing as QP1\n");
return -EINVAL;
}
err = create_user_qp(dev, pd, qp, udata, init_attr, &in,
- &inlen, &ucmd);
+ &resp, &inlen, base);
if (err)
- mlx5_ib_warn(dev, "err %d\n", err);
+ mlx5_ib_dbg(dev, "err %d\n", err);
} else {
- if (init_attr->qp_type == IB_QPT_RAW_PACKET) {
- mlx5_ib_warn(dev, "Raw Eth QP is disabled for Kernel consumers\n");
- return -EINVAL;
- }
- err = create_kernel_qp(dev, init_attr, qp, &in, &inlen);
+ err = create_kernel_qp(dev, init_attr, qp, &in, &inlen,
+ base);
if (err)
- mlx5_ib_warn(dev, "err %d\n", err);
- else
- qp->pa_lkey = to_mpd(pd)->pa_lkey;
+ mlx5_ib_dbg(dev, "err %d\n", err);
}
if (err)
return err;
} else {
- in = mlx5_vzalloc(sizeof(*in));
+ in = mlx5_vzalloc(inlen);
if (!in)
return -ENOMEM;
@@ -1089,26 +1624,29 @@ static int create_qp_common(struct mlx5_ib_dev *dev, struct ib_pd *pd,
if (is_sqp(init_attr->qp_type))
qp->port = init_attr->port_num;
- st = to_mlx5_st(init_attr->qp_type);
- if (st < 0) {
- mlx5_ib_warn(dev, "invalid service type\n");
- err = st;
- goto err_create;
- }
- in->ctx.flags |= cpu_to_be32(st << 16 | MLX5_QP_PM_MIGRATED << 11);
+ qpc = MLX5_ADDR_OF(create_qp_in, in, qpc);
+
+ MLX5_SET(qpc, qpc, st, to_mlx5_st(init_attr->qp_type));
+ MLX5_SET(qpc, qpc, pm_state, MLX5_QP_PM_MIGRATED);
+
+ if (init_attr->qp_type != MLX5_IB_QPT_REG_UMR)
+ MLX5_SET(qpc, qpc, pd, to_mpd(pd ? pd : devr->p0)->pdn);
+ else
+ MLX5_SET(qpc, qpc, latency_sensitive, 1);
- in->ctx.flags_pd = cpu_to_be32(to_mpd(pd ? pd : devr->p0)->pdn);
if (qp->wq_sig)
- in->ctx.flags_pd |= cpu_to_be32(MLX5_QP_ENABLE_SIG);
+ MLX5_SET(qpc, qpc, wq_signature, 1);
if (qp->flags & MLX5_IB_QP_BLOCK_MULTICAST_LOOPBACK)
- in->ctx.flags_pd |= cpu_to_be32(MLX5_QP_BLOCK_MCAST);
+ MLX5_SET(qpc, qpc, block_lb_mc, 1);
- if (qp->flags & MLX5_IB_QP_CAP_RX_END_PADDING)
- in->ctx.flags |= cpu_to_be32(MLX5_QP_END_PAD_MODE_ALIGN << 2);
- else
- in->ctx.flags |= cpu_to_be32(MLX5_QP_END_PAD_MODE_NONE << 2);
+ if (qp->flags & MLX5_IB_QP_CROSS_CHANNEL)
+ MLX5_SET(qpc, qpc, cd_master, 1);
+ if (qp->flags & MLX5_IB_QP_MANAGED_SEND)
+ MLX5_SET(qpc, qpc, cd_slave_send, 1);
+ if (qp->flags & MLX5_IB_QP_MANAGED_RECV)
+ MLX5_SET(qpc, qpc, cd_slave_receive, 1);
if (qp->scat_cqe && is_connected(init_attr->qp_type)) {
int rcqe_sz;
@@ -1117,99 +1655,90 @@ static int create_qp_common(struct mlx5_ib_dev *dev, struct ib_pd *pd,
rcqe_sz = mlx5_ib_get_cqe_size(dev, init_attr->recv_cq);
scqe_sz = mlx5_ib_get_cqe_size(dev, init_attr->send_cq);
- if (rcqe_sz == 128) {
- in->ctx.cs_res = MLX5_RES_SCAT_DATA64_CQE;
- } else {
- in->ctx.cs_res = MLX5_RES_SCAT_DATA32_CQE;
- }
+ if (rcqe_sz == 128)
+ MLX5_SET(qpc, qpc, cs_res, MLX5_RES_SCAT_DATA64_CQE);
+ else
+ MLX5_SET(qpc, qpc, cs_res, MLX5_RES_SCAT_DATA32_CQE);
- if (init_attr->sq_sig_type != IB_SIGNAL_ALL_WR) {
- in->ctx.cs_req = 0;
- } else {
+ if (init_attr->sq_sig_type == IB_SIGNAL_ALL_WR) {
if (scqe_sz == 128)
- in->ctx.cs_req = MLX5_REQ_SCAT_DATA64_CQE;
+ MLX5_SET(qpc, qpc, cs_req, MLX5_REQ_SCAT_DATA64_CQE);
else
- in->ctx.cs_req = MLX5_REQ_SCAT_DATA32_CQE;
+ MLX5_SET(qpc, qpc, cs_req, MLX5_REQ_SCAT_DATA32_CQE);
}
}
if (qp->rq.wqe_cnt) {
- in->ctx.rq_size_stride = (qp->rq.wqe_shift - 4);
- in->ctx.rq_size_stride |= ilog2(qp->rq.wqe_cnt) << 3;
+ MLX5_SET(qpc, qpc, log_rq_stride, qp->rq.wqe_shift - 4);
+ MLX5_SET(qpc, qpc, log_rq_size, ilog2(qp->rq.wqe_cnt));
}
- in->ctx.rq_type_srqn = get_rx_type(qp, init_attr);
+ MLX5_SET(qpc, qpc, rq_type, get_rx_type(qp, init_attr));
if (qp->sq.wqe_cnt)
- in->ctx.sq_crq_size |= cpu_to_be16(ilog2(qp->sq.wqe_cnt) << 11);
+ MLX5_SET(qpc, qpc, log_sq_size, ilog2(qp->sq.wqe_cnt));
else
- in->ctx.sq_crq_size |= cpu_to_be16(0x8000);
+ MLX5_SET(qpc, qpc, no_sq, 1);
/* Set default resources */
switch (init_attr->qp_type) {
case IB_QPT_XRC_TGT:
- in->ctx.cqn_recv = cpu_to_be32(to_mcq(devr->c0)->mcq.cqn);
- in->ctx.cqn_send = cpu_to_be32(to_mcq(devr->c0)->mcq.cqn);
- in->ctx.rq_type_srqn |= cpu_to_be32(to_msrq(devr->s0)->msrq.srqn);
- in->ctx.xrcd = cpu_to_be32(to_mxrcd(init_attr->xrcd)->xrcdn);
+ MLX5_SET(qpc, qpc, cqn_rcv, to_mcq(devr->c0)->mcq.cqn);
+ MLX5_SET(qpc, qpc, cqn_snd, to_mcq(devr->c0)->mcq.cqn);
+ MLX5_SET(qpc, qpc, srqn_rmpn, to_msrq(devr->s0)->msrq.srqn);
+ MLX5_SET(qpc, qpc, xrcd, to_mxrcd(init_attr->xrcd)->xrcdn);
break;
case IB_QPT_XRC_INI:
- in->ctx.cqn_recv = cpu_to_be32(to_mcq(devr->c0)->mcq.cqn);
- in->ctx.xrcd = cpu_to_be32(to_mxrcd(devr->x1)->xrcdn);
- in->ctx.rq_type_srqn |= cpu_to_be32(to_msrq(devr->s0)->msrq.srqn);
+ MLX5_SET(qpc, qpc, cqn_rcv, to_mcq(devr->c0)->mcq.cqn);
+ MLX5_SET(qpc, qpc, xrcd, to_mxrcd(devr->x1)->xrcdn);
+ MLX5_SET(qpc, qpc, srqn_rmpn, to_msrq(devr->s0)->msrq.srqn);
break;
default:
if (init_attr->srq) {
- in->ctx.xrcd = cpu_to_be32(to_mxrcd(devr->x0)->xrcdn);
- in->ctx.rq_type_srqn |= cpu_to_be32(to_msrq(init_attr->srq)->msrq.srqn);
+ MLX5_SET(qpc, qpc, xrcd, to_mxrcd(devr->x0)->xrcdn);
+ MLX5_SET(qpc, qpc, srqn_rmpn, to_msrq(init_attr->srq)->msrq.srqn);
} else {
- in->ctx.xrcd = cpu_to_be32(to_mxrcd(devr->x1)->xrcdn);
- in->ctx.rq_type_srqn |= cpu_to_be32(to_msrq(devr->s1)->msrq.srqn);
+ MLX5_SET(qpc, qpc, xrcd, to_mxrcd(devr->x1)->xrcdn);
+ MLX5_SET(qpc, qpc, srqn_rmpn, to_msrq(devr->s1)->msrq.srqn);
}
}
if (init_attr->send_cq)
- in->ctx.cqn_send = cpu_to_be32(to_mcq(init_attr->send_cq)->mcq.cqn);
+ MLX5_SET(qpc, qpc, cqn_snd, to_mcq(init_attr->send_cq)->mcq.cqn);
if (init_attr->recv_cq)
- in->ctx.cqn_recv = cpu_to_be32(to_mcq(init_attr->recv_cq)->mcq.cqn);
+ MLX5_SET(qpc, qpc, cqn_rcv, to_mcq(init_attr->recv_cq)->mcq.cqn);
- in->ctx.db_rec_addr = cpu_to_be64(qp->db.dma);
+ MLX5_SET64(qpc, qpc, dbr_addr, qp->db.dma);
- if (MLX5_CAP_GEN(mdev, cqe_version)) {
- qpc = MLX5_ADDR_OF(create_qp_in, in, qpc);
- /* 0xffffff means we ask to work with cqe version 0 */
+ /* 0xffffff means we ask to work with cqe version 0 */
+ if (MLX5_CAP_GEN(mdev, cqe_version) == MLX5_CQE_VERSION_V1)
MLX5_SET(qpc, qpc, user_index, uidx);
+
+ /* we use IB_QP_CREATE_IPOIB_UD_LSO to indicates ipoib qp */
+ if (init_attr->qp_type == IB_QPT_UD &&
+ (init_attr->create_flags & IB_QP_CREATE_IPOIB_UD_LSO)) {
+ MLX5_SET(qpc, qpc, ulp_stateless_offload_mode, 1);
+ qp->flags |= MLX5_IB_QP_LSO;
}
if (init_attr->qp_type == IB_QPT_RAW_PACKET) {
- if (MLX5_CAP_GEN(dev->mdev, port_type) != MLX5_CAP_PORT_TYPE_ETH) {
- mlx5_ib_warn(dev, "Raw Ethernet QP is allowed only for Ethernet link layer\n");
- return -ENOSYS;
- }
- if (ucmd.exp.comp_mask & MLX5_EXP_CREATE_QP_MASK_SQ_BUFF_ADD) {
- qp->sq_buf_addr = ucmd.exp.sq_buf_addr;
- } else {
- mlx5_ib_warn(dev, "Raw Ethernet QP needs SQ buff address\n");
- return -EINVAL;
- }
- err = -EOPNOTSUPP;
+ qp->raw_packet_qp.sq.ubuffer.buf_addr = ucmd.sq_buf_addr;
+ raw_packet_qp_copy_info(qp, &qp->raw_packet_qp);
+ err = create_raw_packet_qp(dev, qp, in, pd);
} else {
- err = mlx5_core_create_qp(dev->mdev, &qp->mqp, in, inlen);
- qp->mqp.event = mlx5_ib_qp_event;
+ err = mlx5_core_create_qp(dev->mdev, &base->mqp, (struct mlx5_create_qp_mbox_in *)in, inlen);
}
if (err) {
- mlx5_ib_warn(dev, "create qp failed\n");
+ mlx5_ib_dbg(dev, "create qp failed\n");
goto err_create;
}
kvfree(in);
- /* Hardware wants QPN written in big-endian order (after
- * shifting) for send doorbell. Precompute this value to save
- * a little bit when posting sends.
- */
- qp->doorbell_qpn = swab32(qp->mqp.qpn << 8);
+
+ base->container_mibqp = qp;
+ base->mqp.event = mlx5_ib_qp_event;
get_cqs(init_attr->qp_type, init_attr->send_cq, init_attr->recv_cq,
&send_cq, &recv_cq);
@@ -1232,7 +1761,7 @@ static int create_qp_common(struct mlx5_ib_dev *dev, struct ib_pd *pd,
err_create:
if (qp->create_type == MLX5_QP_USER)
- destroy_qp_user(pd, qp);
+ destroy_qp_user(pd, qp, base);
else if (qp->create_type == MLX5_QP_KERNEL)
destroy_qp_kernel(dev, qp);
@@ -1303,24 +1832,86 @@ static struct mlx5_ib_pd *get_pd(struct mlx5_ib_qp *qp)
return to_mpd(qp->ibqp.pd);
}
+static void get_cqs(enum ib_qp_type qp_type,
+ struct ib_cq *ib_send_cq, struct ib_cq *ib_recv_cq,
+ struct mlx5_ib_cq **send_cq, struct mlx5_ib_cq **recv_cq)
+{
+ switch (qp_type) {
+ case IB_QPT_XRC_TGT:
+ *send_cq = NULL;
+ *recv_cq = NULL;
+ break;
+ case MLX5_IB_QPT_REG_UMR:
+ case IB_QPT_XRC_INI:
+ *send_cq = ib_send_cq ? to_mcq(ib_send_cq) : NULL;
+ *recv_cq = NULL;
+ break;
+
+ case IB_QPT_SMI:
+ case MLX5_IB_QPT_HW_GSI:
+ case IB_QPT_RC:
+ case IB_QPT_UC:
+ case IB_QPT_UD:
+ case IB_QPT_RAW_IPV6:
+ case IB_QPT_RAW_ETHERTYPE:
+ case IB_QPT_RAW_PACKET:
+ *send_cq = ib_send_cq ? to_mcq(ib_send_cq) : NULL;
+ *recv_cq = ib_recv_cq ? to_mcq(ib_recv_cq) : NULL;
+ break;
+
+ case IB_QPT_MAX:
+ default:
+ *send_cq = NULL;
+ *recv_cq = NULL;
+ break;
+ }
+}
+
+static int modify_raw_packet_qp(struct mlx5_ib_dev *dev, struct mlx5_ib_qp *qp,
+ const struct mlx5_modify_raw_qp_param *raw_qp_param,
+ u8 lag_tx_affinity);
+
static void destroy_qp_common(struct mlx5_ib_dev *dev, struct mlx5_ib_qp *qp)
{
struct mlx5_ib_cq *send_cq, *recv_cq;
- struct mlx5_modify_qp_mbox_in *in;
+ struct mlx5_ib_qp_base *base = &qp->trans_qp.base;
unsigned long flags;
int err;
- in = kzalloc(sizeof(*in), GFP_KERNEL);
- if (!in)
+ if (qp->ibqp.rwq_ind_tbl) {
+ destroy_rss_raw_qp_tir(dev, qp);
return;
+ }
+
+ base = qp->ibqp.qp_type == IB_QPT_RAW_PACKET ?
+ &qp->raw_packet_qp.rq.base :
+ &qp->trans_qp.base;
if (qp->state != IB_QPS_RESET) {
if (qp->ibqp.qp_type != IB_QPT_RAW_PACKET) {
- if (mlx5_core_qp_modify(dev->mdev, MLX5_CMD_OP_2RST_QP, in, 0,
- &qp->mqp))
- mlx5_ib_warn(dev, "mlx5_ib: modify QP %06x to RESET failed\n",
- qp->mqp.qpn);
+ struct mlx5_modify_qp_mbox_in *in;
+
+ mlx5_ib_qp_disable_pagefaults(qp);
+
+ in = kzalloc(sizeof(*in), GFP_KERNEL);
+ if (in != NULL) {
+ err = mlx5_core_qp_modify(dev->mdev,
+ MLX5_CMD_OP_2RST_QP,
+ in, 0, &base->mqp);
+ kfree(in);
+ } else {
+ err = -ENOMEM;
+ }
+ } else {
+ struct mlx5_modify_raw_qp_param raw_qp_param = {
+ .operation = MLX5_CMD_OP_2RST_QP
+ };
+
+ err = modify_raw_packet_qp(dev, qp, &raw_qp_param, 0);
}
+ if (err)
+ mlx5_ib_warn(dev, "mlx5_ib: modify QP 0x%06x to RESET failed\n",
+ base->mqp.qpn);
}
get_cqs(qp->ibqp.qp_type, qp->ibqp.send_cq, qp->ibqp.recv_cq,
@@ -1337,28 +1928,28 @@ static void destroy_qp_common(struct mlx5_ib_dev *dev, struct mlx5_ib_qp *qp)
list_del(&qp->cq_recv_list);
if (qp->create_type == MLX5_QP_KERNEL) {
- __mlx5_ib_cq_clean(recv_cq, qp->mqp.qpn,
+ __mlx5_ib_cq_clean(recv_cq, base->mqp.qpn,
qp->ibqp.srq ? to_msrq(qp->ibqp.srq) : NULL);
if (send_cq != recv_cq)
- __mlx5_ib_cq_clean(send_cq, qp->mqp.qpn, NULL);
+ __mlx5_ib_cq_clean(send_cq, base->mqp.qpn,
+ NULL);
}
mlx5_ib_unlock_cqs(send_cq, recv_cq);
spin_unlock_irqrestore(&dev->reset_flow_resource_lock, flags);
if (qp->ibqp.qp_type == IB_QPT_RAW_PACKET) {
+ destroy_raw_packet_qp(dev, qp);
} else {
- err = mlx5_core_destroy_qp(dev->mdev, &qp->mqp);
+ err = mlx5_core_destroy_qp(dev->mdev, &base->mqp);
if (err)
mlx5_ib_warn(dev, "failed to destroy QP 0x%x\n",
- qp->mqp.qpn);
+ base->mqp.qpn);
}
- kfree(in);
-
if (qp->create_type == MLX5_QP_KERNEL)
destroy_qp_kernel(dev, qp);
else if (qp->create_type == MLX5_QP_USER)
- destroy_qp_user(&get_pd(qp)->ibpd, qp);
+ destroy_qp_user(&get_pd(qp)->ibpd, qp, base);
}
static const char *ib_qp_type_str(enum ib_qp_type type)
@@ -1384,6 +1975,8 @@ static const char *ib_qp_type_str(enum ib_qp_type type)
return "IB_QPT_XRC_TGT";
case IB_QPT_RAW_PACKET:
return "IB_QPT_RAW_PACKET";
+ case MLX5_IB_QPT_REG_UMR:
+ return "MLX5_IB_QPT_REG_UMR";
case IB_QPT_MAX:
default:
return "Invalid QP type";
@@ -1398,17 +1991,25 @@ struct ib_qp *mlx5_ib_create_qp(struct ib_pd *pd,
struct mlx5_ib_qp *qp;
u16 xrcdn = 0;
int err;
- u32 rcqn;
- u32 scqn;
-
- init_attr->qpg_type = IB_QPG_NONE;
if (pd) {
dev = to_mdev(pd->device);
+
+ if (init_attr->qp_type == IB_QPT_RAW_PACKET) {
+ if (!pd->uobject) {
+ mlx5_ib_dbg(dev, "Raw Packet QP is not supported for kernel consumers\n");
+ return ERR_PTR(-EINVAL);
+ } else if (!to_mucontext(pd->uobject->context)->cqe_version) {
+ mlx5_ib_dbg(dev, "Raw Packet QP is only supported for CQE version > 0\n");
+ return ERR_PTR(-EINVAL);
+ }
+ }
} else {
/* being cautious here */
- if (init_attr->qp_type != IB_QPT_XRC_TGT) {
- printf("mlx5_ib: WARN: ""%s: no PD for transport %s\n", __func__, ib_qp_type_str(init_attr->qp_type));
+ if (init_attr->qp_type != IB_QPT_XRC_TGT &&
+ init_attr->qp_type != MLX5_IB_QPT_REG_UMR) {
+ pr_warn("%s: no PD for transport %s\n", __func__,
+ ib_qp_type_str(init_attr->qp_type));
return ERR_PTR(-EINVAL);
}
dev = to_mdev(to_mxrcd(init_attr->xrcd)->ibxrcd.device);
@@ -1418,7 +2019,7 @@ struct ib_qp *mlx5_ib_create_qp(struct ib_pd *pd,
case IB_QPT_XRC_TGT:
case IB_QPT_XRC_INI:
if (!MLX5_CAP_GEN(dev->mdev, xrc)) {
- mlx5_ib_warn(dev, "XRC not supported\n");
+ mlx5_ib_dbg(dev, "XRC not supported\n");
return ERR_PTR(-ENOSYS);
}
init_attr->recv_cq = NULL;
@@ -1428,20 +2029,20 @@ struct ib_qp *mlx5_ib_create_qp(struct ib_pd *pd,
}
/* fall through */
+ case IB_QPT_RAW_PACKET:
case IB_QPT_RC:
case IB_QPT_UC:
case IB_QPT_UD:
case IB_QPT_SMI:
- case IB_QPT_GSI:
- case IB_QPT_RAW_ETHERTYPE:
- case IB_QPT_RAW_PACKET:
+ case MLX5_IB_QPT_HW_GSI:
+ case MLX5_IB_QPT_REG_UMR:
qp = kzalloc(sizeof(*qp), GFP_KERNEL);
if (!qp)
return ERR_PTR(-ENOMEM);
err = create_qp_common(dev, pd, init_attr, udata, qp);
if (err) {
- mlx5_ib_warn(dev, "create_qp_common failed\n");
+ mlx5_ib_dbg(dev, "create_qp_common failed\n");
kfree(qp);
return ERR_PTR(err);
}
@@ -1451,22 +2052,26 @@ struct ib_qp *mlx5_ib_create_qp(struct ib_pd *pd,
else if (is_qp1(init_attr->qp_type))
qp->ibqp.qp_num = 1;
else
- qp->ibqp.qp_num = qp->mqp.qpn;
+ qp->ibqp.qp_num = qp->trans_qp.base.mqp.qpn;
- rcqn = init_attr->recv_cq ? to_mcq(init_attr->recv_cq)->mcq.cqn : -1;
- scqn = init_attr->send_cq ? to_mcq(init_attr->send_cq)->mcq.cqn : -1;
mlx5_ib_dbg(dev, "ib qpnum 0x%x, mlx qpn 0x%x, rcqn 0x%x, scqn 0x%x\n",
- qp->ibqp.qp_num, qp->mqp.qpn, rcqn, scqn);
+ qp->ibqp.qp_num, qp->trans_qp.base.mqp.qpn,
+ init_attr->recv_cq ? to_mcq(init_attr->recv_cq)->mcq.cqn : -1,
+ init_attr->send_cq ? to_mcq(init_attr->send_cq)->mcq.cqn : -1);
- qp->xrcdn = xrcdn;
+ qp->trans_qp.xrcdn = xrcdn;
break;
+ case IB_QPT_GSI:
+ return mlx5_ib_gsi_create_qp(pd, init_attr);
+
case IB_QPT_RAW_IPV6:
+ case IB_QPT_RAW_ETHERTYPE:
case IB_QPT_MAX:
default:
- mlx5_ib_warn(dev, "unsupported qp type %d\n",
- init_attr->qp_type);
+ mlx5_ib_dbg(dev, "unsupported qp type %d\n",
+ init_attr->qp_type);
/* Don't support raw QPs */
return ERR_PTR(-EINVAL);
}
@@ -1479,6 +2084,9 @@ int mlx5_ib_destroy_qp(struct ib_qp *qp)
struct mlx5_ib_dev *dev = to_mdev(qp->device);
struct mlx5_ib_qp *mqp = to_mqp(qp);
+ if (unlikely(qp->qp_type == IB_QPT_GSI))
+ return mlx5_ib_gsi_destroy_qp(qp);
+
destroy_qp_common(dev, mqp);
kfree(mqp);
@@ -1486,28 +2094,9 @@ int mlx5_ib_destroy_qp(struct ib_qp *qp)
return 0;
}
-static u32 atomic_mode_qp(struct mlx5_ib_dev *dev)
-{
- unsigned long mask;
- unsigned long tmp;
-
- mask = MLX5_CAP_ATOMIC(dev->mdev, atomic_size_qp) &
- MLX5_CAP_ATOMIC(dev->mdev, atomic_size_dc);
-
- tmp = find_last_bit(&mask, BITS_PER_LONG);
- if (tmp < 2 || tmp >= BITS_PER_LONG)
- return MLX5_ATOMIC_MODE_NONE;
-
- if (tmp == 2)
- return MLX5_ATOMIC_MODE_CX;
-
- return tmp << MLX5_ATOMIC_MODE_OFF;
-}
-
static __be32 to_mlx5_access_flags(struct mlx5_ib_qp *qp, const struct ib_qp_attr *attr,
int attr_mask)
{
- struct mlx5_ib_dev *dev = to_mdev(qp->ibqp.device);
u32 hw_access_flags = 0;
u8 dest_rd_atomic;
u32 access_flags;
@@ -1515,12 +2104,12 @@ static __be32 to_mlx5_access_flags(struct mlx5_ib_qp *qp, const struct ib_qp_att
if (attr_mask & IB_QP_MAX_DEST_RD_ATOMIC)
dest_rd_atomic = attr->max_dest_rd_atomic;
else
- dest_rd_atomic = qp->resp_depth;
+ dest_rd_atomic = qp->trans_qp.resp_depth;
if (attr_mask & IB_QP_ACCESS_FLAGS)
access_flags = attr->qp_access_flags;
else
- access_flags = qp->atomic_rd_en;
+ access_flags = qp->trans_qp.atomic_rd_en;
if (!dest_rd_atomic)
access_flags &= IB_ACCESS_REMOTE_WRITE;
@@ -1528,8 +2117,7 @@ static __be32 to_mlx5_access_flags(struct mlx5_ib_qp *qp, const struct ib_qp_att
if (access_flags & IB_ACCESS_REMOTE_READ)
hw_access_flags |= MLX5_QP_BIT_RRE;
if (access_flags & IB_ACCESS_REMOTE_ATOMIC)
- hw_access_flags |= (MLX5_QP_BIT_RAE |
- atomic_mode_qp(dev));
+ hw_access_flags |= (MLX5_QP_BIT_RAE | MLX5_ATOMIC_MODE_CX);
if (access_flags & IB_ACCESS_REMOTE_WRITE)
hw_access_flags |= MLX5_QP_BIT_RWE;
@@ -1558,20 +2146,75 @@ static int ib_rate_to_mlx5(struct mlx5_ib_dev *dev, u8 rate)
return rate + MLX5_STAT_RATE_OFFSET;
}
-static int mlx5_set_path(struct mlx5_ib_dev *dev, const struct ib_ah_attr *ah,
+static int modify_raw_packet_eth_prio(struct mlx5_core_dev *dev,
+ struct mlx5_ib_sq *sq, u8 sl)
+{
+ void *in;
+ void *tisc;
+ int inlen;
+ int err;
+
+ inlen = MLX5_ST_SZ_BYTES(modify_tis_in);
+ in = mlx5_vzalloc(inlen);
+ if (!in)
+ return -ENOMEM;
+
+ MLX5_SET(modify_tis_in, in, bitmask.prio, 1);
+
+ tisc = MLX5_ADDR_OF(modify_tis_in, in, ctx);
+ MLX5_SET(tisc, tisc, prio, ((sl & 0x7) << 1));
+
+ err = mlx5_core_modify_tis(dev, sq->tisn, in, inlen);
+
+ kvfree(in);
+
+ return err;
+}
+
+static int modify_raw_packet_tx_affinity(struct mlx5_core_dev *dev,
+ struct mlx5_ib_sq *sq, u8 tx_affinity)
+{
+ void *in;
+ void *tisc;
+ int inlen;
+ int err;
+
+ inlen = MLX5_ST_SZ_BYTES(modify_tis_in);
+ in = mlx5_vzalloc(inlen);
+ if (!in)
+ return -ENOMEM;
+
+ MLX5_SET(modify_tis_in, in, bitmask.lag_tx_port_affinity, 1);
+
+ tisc = MLX5_ADDR_OF(modify_tis_in, in, ctx);
+ MLX5_SET(tisc, tisc, lag_tx_port_affinity, tx_affinity);
+
+ err = mlx5_core_modify_tis(dev, sq->tisn, in, inlen);
+
+ kvfree(in);
+
+ return err;
+}
+
+static int mlx5_set_path(struct mlx5_ib_dev *dev, struct mlx5_ib_qp *qp,
+ const struct ib_ah_attr *ah,
struct mlx5_qp_path *path, u8 port, int attr_mask,
u32 path_flags, const struct ib_qp_attr *attr,
- int alt)
+ bool alt)
{
- enum rdma_link_layer ll = dev->ib_dev.get_link_layer(&dev->ib_dev,
- port);
+ enum rdma_link_layer ll = rdma_port_get_link_layer(&dev->ib_dev, port);
int err;
- int gid_type;
- if ((ll == IB_LINK_LAYER_ETHERNET) || (ah->ah_flags & IB_AH_GRH)) {
- int len = dev->mdev->port_caps[port - 1].gid_table_len;
- if (ah->grh.sgid_index >= len) {
- printf("mlx5_ib: ERR: ""sgid_index (%u) too large. max is %d\n", ah->grh.sgid_index, len - 1);
+ if (attr_mask & IB_QP_PKEY_INDEX)
+ path->pkey_index = cpu_to_be16(alt ? attr->alt_pkey_index :
+ attr->pkey_index);
+
+ if (ah->ah_flags & IB_AH_GRH) {
+ if (ah->grh.sgid_index >=
+ dev->mdev->port_caps[port - 1].gid_table_len) {
+ pr_err("sgid_index (%u) too large. max is %d\n",
+ ah->grh.sgid_index,
+ dev->mdev->port_caps[port - 1].gid_table_len);
return -EINVAL;
}
}
@@ -1579,32 +2222,21 @@ static int mlx5_set_path(struct mlx5_ib_dev *dev, const struct ib_ah_attr *ah,
if (ll == IB_LINK_LAYER_ETHERNET) {
if (!(ah->ah_flags & IB_AH_GRH))
return -EINVAL;
-
- err = mlx5_get_roce_gid_type(dev, port, ah->grh.sgid_index,
- &gid_type);
- if (err)
- return err;
memcpy(path->rmac, ah->dmac, sizeof(ah->dmac));
path->udp_sport = mlx5_get_roce_udp_sport(dev, port,
- ah->grh.sgid_index,
- 0);
- path->dci_cfi_prio_sl = (ah->sl & 0xf) << 4;
+ ah->grh.sgid_index);
+ path->dci_cfi_prio_sl = (ah->sl & 0x7) << 4;
} else {
path->fl_free_ar = (path_flags & MLX5_PATH_FLAG_FL) ? 0x80 : 0;
- path->grh_mlid = ah->src_path_bits & 0x7f;
- path->rlid = cpu_to_be16(ah->dlid);
+ path->fl_free_ar |=
+ (path_flags & MLX5_PATH_FLAG_FREE_AR) ? 0x40 : 0;
+ path->rlid = cpu_to_be16(ah->dlid);
+ path->grh_mlid = ah->src_path_bits & 0x7f;
if (ah->ah_flags & IB_AH_GRH)
path->grh_mlid |= 1 << 7;
- if (attr_mask & IB_QP_PKEY_INDEX)
- path->pkey_index = cpu_to_be16(alt ?
- attr->alt_pkey_index :
- attr->pkey_index);
-
path->dci_cfi_prio_sl = ah->sl & 0xf;
}
- path->fl_free_ar |= (path_flags & MLX5_PATH_FLAG_FREE_AR) ? 0x40 : 0;
-
if (ah->ah_flags & IB_AH_GRH) {
path->mgid_index = ah->grh.sgid_index;
path->hop_limit = ah->grh.hop_limit;
@@ -1621,7 +2253,12 @@ static int mlx5_set_path(struct mlx5_ib_dev *dev, const struct ib_ah_attr *ah,
path->port = port;
if (attr_mask & IB_QP_TIMEOUT)
- path->ackto_lt = alt ? attr->alt_timeout << 3 : attr->timeout << 3;
+ path->ackto_lt = (alt ? attr->alt_timeout : attr->timeout) << 3;
+
+ if ((qp->ibqp.qp_type == IB_QPT_RAW_PACKET) && qp->sq.wqe_cnt)
+ return modify_raw_packet_eth_prio(dev->mdev,
+ &qp->raw_packet_qp.sq,
+ ah->sl & 0xf);
return 0;
}
@@ -1640,10 +2277,6 @@ static enum mlx5_qp_optpar opt_mask[MLX5_QP_NUM_STATE][MLX5_QP_NUM_STATE][MLX5_Q
[MLX5_QP_ST_UD] = MLX5_QP_OPTPAR_PKEY_INDEX |
MLX5_QP_OPTPAR_Q_KEY |
MLX5_QP_OPTPAR_PRI_PORT,
- [MLX5_QP_ST_DCI] = MLX5_QP_OPTPAR_PRI_PORT |
- MLX5_QP_OPTPAR_DC_KEY |
- MLX5_QP_OPTPAR_PKEY_INDEX |
- MLX5_QP_OPTPAR_RAE,
},
[MLX5_QP_STATE_RTR] = {
[MLX5_QP_ST_RC] = MLX5_QP_OPTPAR_ALT_ADDR_PATH |
@@ -1663,9 +2296,6 @@ static enum mlx5_qp_optpar opt_mask[MLX5_QP_NUM_STATE][MLX5_QP_NUM_STATE][MLX5_Q
MLX5_QP_OPTPAR_RAE |
MLX5_QP_OPTPAR_RWE |
MLX5_QP_OPTPAR_PKEY_INDEX,
- [MLX5_QP_ST_DCI] = MLX5_QP_OPTPAR_PKEY_INDEX |
- MLX5_QP_OPTPAR_RAE |
- MLX5_QP_OPTPAR_DC_KEY,
},
},
[MLX5_QP_STATE_RTR] = {
@@ -1680,9 +2310,6 @@ static enum mlx5_qp_optpar opt_mask[MLX5_QP_NUM_STATE][MLX5_QP_NUM_STATE][MLX5_Q
MLX5_QP_OPTPAR_RWE |
MLX5_QP_OPTPAR_PM_STATE,
[MLX5_QP_ST_UD] = MLX5_QP_OPTPAR_Q_KEY,
- [MLX5_QP_ST_DCI] = MLX5_QP_OPTPAR_DC_KEY |
- MLX5_QP_OPTPAR_PM_STATE |
- MLX5_QP_OPTPAR_RAE,
},
},
[MLX5_QP_STATE_RTS] = {
@@ -1699,9 +2326,6 @@ static enum mlx5_qp_optpar opt_mask[MLX5_QP_NUM_STATE][MLX5_QP_NUM_STATE][MLX5_Q
[MLX5_QP_ST_UD] = MLX5_QP_OPTPAR_Q_KEY |
MLX5_QP_OPTPAR_SRQN |
MLX5_QP_OPTPAR_CQN_RCV,
- [MLX5_QP_ST_DCI] = MLX5_QP_OPTPAR_DC_KEY |
- MLX5_QP_OPTPAR_PM_STATE |
- MLX5_QP_OPTPAR_RAE,
},
},
[MLX5_QP_STATE_SQER] = {
@@ -1713,20 +2337,6 @@ static enum mlx5_qp_optpar opt_mask[MLX5_QP_NUM_STATE][MLX5_QP_NUM_STATE][MLX5_Q
MLX5_QP_OPTPAR_RWE |
MLX5_QP_OPTPAR_RAE |
MLX5_QP_OPTPAR_RRE,
- [MLX5_QP_ST_DCI] = MLX5_QP_OPTPAR_DC_KEY |
- MLX5_QP_OPTPAR_RAE,
-
- },
- },
- [MLX5_QP_STATE_SQD] = {
- [MLX5_QP_STATE_RTS] = {
- [MLX5_QP_ST_UD] = MLX5_QP_OPTPAR_Q_KEY,
- [MLX5_QP_ST_MLX] = MLX5_QP_OPTPAR_Q_KEY,
- [MLX5_QP_ST_UC] = MLX5_QP_OPTPAR_RWE,
- [MLX5_QP_ST_RC] = MLX5_QP_OPTPAR_RNR_TIMEOUT |
- MLX5_QP_OPTPAR_RWE |
- MLX5_QP_OPTPAR_RAE |
- MLX5_QP_OPTPAR_RRE,
},
},
};
@@ -1796,6 +2406,134 @@ static int ib_mask_to_mlx5_opt(int ib_mask)
return result;
}
+static int modify_raw_packet_qp_rq(struct mlx5_ib_dev *dev,
+ struct mlx5_ib_rq *rq, int new_state,
+ const struct mlx5_modify_raw_qp_param *raw_qp_param)
+{
+ void *in;
+ void *rqc;
+ int inlen;
+ int err;
+
+ inlen = MLX5_ST_SZ_BYTES(modify_rq_in);
+ in = mlx5_vzalloc(inlen);
+ if (!in)
+ return -ENOMEM;
+
+ MLX5_SET(modify_rq_in, in, rqn, rq->base.mqp.qpn);
+ MLX5_SET(modify_rq_in, in, rq_state, rq->state);
+
+ rqc = MLX5_ADDR_OF(modify_rq_in, in, ctx);
+ MLX5_SET(rqc, rqc, state, new_state);
+
+ if (raw_qp_param->set_mask & MLX5_RAW_QP_MOD_SET_RQ_Q_CTR_ID) {
+ if (MLX5_CAP_GEN(dev->mdev, modify_rq_counters_set_id)) {
+ MLX5_SET64(modify_rq_in, in, modify_bitmask,
+ MLX5_MODIFY_RQ_IN_MODIFY_BITMASK_MODIFY_RQ_COUNTER_SET_ID);
+ MLX5_SET(rqc, rqc, counter_set_id, raw_qp_param->rq_q_ctr_id);
+ } else
+ pr_info_once("%s: RAW PACKET QP counters are not supported on current FW\n",
+ dev->ib_dev.name);
+ }
+
+ err = mlx5_core_modify_rq(dev->mdev, in, inlen);
+ if (err)
+ goto out;
+
+ rq->state = new_state;
+
+out:
+ kvfree(in);
+ return err;
+}
+
+static int modify_raw_packet_qp_sq(struct mlx5_core_dev *dev,
+ struct mlx5_ib_sq *sq, int new_state)
+{
+ void *in;
+ void *sqc;
+ int inlen;
+ int err;
+
+ inlen = MLX5_ST_SZ_BYTES(modify_sq_in);
+ in = mlx5_vzalloc(inlen);
+ if (!in)
+ return -ENOMEM;
+
+ MLX5_SET(modify_sq_in, in, sqn, sq->base.mqp.qpn);
+ MLX5_SET(modify_sq_in, in, sq_state, sq->state);
+
+ sqc = MLX5_ADDR_OF(modify_sq_in, in, ctx);
+ MLX5_SET(sqc, sqc, state, new_state);
+
+ err = mlx5_core_modify_sq(dev, in, inlen);
+ if (err)
+ goto out;
+
+ sq->state = new_state;
+
+out:
+ kvfree(in);
+ return err;
+}
+
+static int modify_raw_packet_qp(struct mlx5_ib_dev *dev, struct mlx5_ib_qp *qp,
+ const struct mlx5_modify_raw_qp_param *raw_qp_param,
+ u8 tx_affinity)
+{
+ struct mlx5_ib_raw_packet_qp *raw_packet_qp = &qp->raw_packet_qp;
+ struct mlx5_ib_rq *rq = &raw_packet_qp->rq;
+ struct mlx5_ib_sq *sq = &raw_packet_qp->sq;
+ int rq_state;
+ int sq_state;
+ int err;
+
+ switch (raw_qp_param->operation) {
+ case MLX5_CMD_OP_RST2INIT_QP:
+ rq_state = MLX5_RQC_STATE_RDY;
+ sq_state = MLX5_SQC_STATE_RDY;
+ break;
+ case MLX5_CMD_OP_2ERR_QP:
+ rq_state = MLX5_RQC_STATE_ERR;
+ sq_state = MLX5_SQC_STATE_ERR;
+ break;
+ case MLX5_CMD_OP_2RST_QP:
+ rq_state = MLX5_RQC_STATE_RST;
+ sq_state = MLX5_SQC_STATE_RST;
+ break;
+ case MLX5_CMD_OP_INIT2INIT_QP:
+ case MLX5_CMD_OP_INIT2RTR_QP:
+ case MLX5_CMD_OP_RTR2RTS_QP:
+ case MLX5_CMD_OP_RTS2RTS_QP:
+ if (raw_qp_param->set_mask)
+ return -EINVAL;
+ else
+ return 0;
+ default:
+ WARN_ON(1);
+ return -EINVAL;
+ }
+
+ if (qp->rq.wqe_cnt) {
+ err = modify_raw_packet_qp_rq(dev, rq, rq_state, raw_qp_param);
+ if (err)
+ return err;
+ }
+
+ if (qp->sq.wqe_cnt) {
+ if (tx_affinity) {
+ err = modify_raw_packet_tx_affinity(dev->mdev, sq,
+ tx_affinity);
+ if (err)
+ return err;
+ }
+
+ return modify_raw_packet_qp_sq(dev->mdev, sq, sq_state);
+ }
+
+ return 0;
+}
+
static int __mlx5_ib_modify_qp(struct ib_qp *ibqp,
const struct ib_qp_attr *attr, int attr_mask,
enum ib_qp_state cur_state, enum ib_qp_state new_state)
@@ -1825,7 +2563,6 @@ static int __mlx5_ib_modify_qp(struct ib_qp *ibqp,
[MLX5_QP_STATE_SQD] = {
[MLX5_QP_STATE_RST] = MLX5_CMD_OP_2RST_QP,
[MLX5_QP_STATE_ERR] = MLX5_CMD_OP_2ERR_QP,
- [MLX5_QP_STATE_RTS] = MLX5_CMD_OP_SQD_RTS_QP,
},
[MLX5_QP_STATE_SQER] = {
[MLX5_QP_STATE_RST] = MLX5_CMD_OP_2RST_QP,
@@ -1840,10 +2577,12 @@ static int __mlx5_ib_modify_qp(struct ib_qp *ibqp,
struct mlx5_ib_dev *dev = to_mdev(ibqp->device);
struct mlx5_ib_qp *qp = to_mqp(ibqp);
+ struct mlx5_ib_qp_base *base = &qp->trans_qp.base;
struct mlx5_ib_cq *send_cq, *recv_cq;
struct mlx5_qp_context *context;
struct mlx5_modify_qp_mbox_in *in;
struct mlx5_ib_pd *pd;
+ struct mlx5_ib_port *mibport = NULL;
enum mlx5_qp_state mlx5_cur, mlx5_new;
enum mlx5_qp_optpar optpar;
int sqd_event;
@@ -1857,8 +2596,10 @@ static int __mlx5_ib_modify_qp(struct ib_qp *ibqp,
context = &in->ctx;
err = to_mlx5_st(ibqp->qp_type);
- if (err < 0)
+ if (err < 0) {
+ mlx5_ib_dbg(dev, "unsupported qp type %d\n", ibqp->qp_type);
goto out;
+ }
context->flags = cpu_to_be32(err << 16);
@@ -1878,9 +2619,10 @@ static int __mlx5_ib_modify_qp(struct ib_qp *ibqp,
}
}
- if (ibqp->qp_type == IB_QPT_GSI || ibqp->qp_type == IB_QPT_SMI) {
+ if (is_sqp(ibqp->qp_type)) {
context->mtu_msgmax = (IB_MTU_256 << 5) | 8;
- } else if (ibqp->qp_type == IB_QPT_UD) {
+ } else if (ibqp->qp_type == IB_QPT_UD ||
+ ibqp->qp_type == MLX5_IB_QPT_REG_UMR) {
context->mtu_msgmax = (IB_MTU_4096 << 5) | 12;
} else if (attr_mask & IB_QP_PATH_MTU) {
if (attr->path_mtu < IB_MTU_256 ||
@@ -1908,9 +2650,9 @@ static int __mlx5_ib_modify_qp(struct ib_qp *ibqp,
context->pri_path.port = attr->port_num;
if (attr_mask & IB_QP_AV) {
- err = mlx5_set_path(dev, &attr->ah_attr, &context->pri_path,
+ err = mlx5_set_path(dev, qp, &attr->ah_attr, &context->pri_path,
attr_mask & IB_QP_PORT ? attr->port_num : qp->port,
- attr_mask, 0, attr, 0);
+ attr_mask, 0, attr, false);
if (err)
goto out;
}
@@ -1919,10 +2661,11 @@ static int __mlx5_ib_modify_qp(struct ib_qp *ibqp,
context->pri_path.ackto_lt |= attr->timeout << 3;
if (attr_mask & IB_QP_ALT_PATH) {
- err = mlx5_set_path(dev, &attr->alt_ah_attr, &context->alt_path,
+ err = mlx5_set_path(dev, qp, &attr->alt_ah_attr,
+ &context->alt_path,
attr->alt_port_num,
- attr_mask | IB_QP_PKEY_INDEX | IB_QP_TIMEOUT,
- 0, attr, 1);
+ attr_mask | IB_QP_PKEY_INDEX | IB_QP_TIMEOUT,
+ 0, attr, true);
if (err)
goto out;
}
@@ -1949,7 +2692,7 @@ static int __mlx5_ib_modify_qp(struct ib_qp *ibqp,
}
if (attr_mask & IB_QP_SQ_PSN)
- context->next_send_psn = cpu_to_be32(attr->sq_psn & 0xffffff);
+ context->next_send_psn = cpu_to_be32(attr->sq_psn);
if (attr_mask & IB_QP_MAX_DEST_RD_ATOMIC) {
if (attr->max_dest_rd_atomic)
@@ -1957,14 +2700,6 @@ static int __mlx5_ib_modify_qp(struct ib_qp *ibqp,
cpu_to_be32(fls(attr->max_dest_rd_atomic - 1) << 21);
}
- if ((attr_mask & IB_QP_ACCESS_FLAGS) &&
- (attr->qp_access_flags & IB_ACCESS_REMOTE_ATOMIC) &&
- !dev->enable_atomic_resp) {
- mlx5_ib_warn(dev, "atomic responder is not supported\n");
- err = -EINVAL;
- goto out;
- }
-
if (attr_mask & (IB_QP_ACCESS_FLAGS | IB_QP_MAX_DEST_RD_ATOMIC))
context->params2 |= to_mlx5_access_flags(qp, attr, attr_mask);
@@ -1972,7 +2707,7 @@ static int __mlx5_ib_modify_qp(struct ib_qp *ibqp,
context->rnr_nextrecvpsn |= cpu_to_be32(attr->min_rnr_timer << 24);
if (attr_mask & IB_QP_RQ_PSN)
- context->rnr_nextrecvpsn |= cpu_to_be32(attr->rq_psn & 0xffffff);
+ context->rnr_nextrecvpsn |= cpu_to_be32(attr->rq_psn);
if (attr_mask & IB_QP_QKEY)
context->qkey = cpu_to_be32(attr->qkey);
@@ -1986,61 +2721,85 @@ static int __mlx5_ib_modify_qp(struct ib_qp *ibqp,
else
sqd_event = 0;
- if (!ibqp->uobject && cur_state == IB_QPS_RESET && new_state == IB_QPS_INIT)
- context->sq_crq_size |= cpu_to_be16(1 << 4);
-
if (cur_state == IB_QPS_RESET && new_state == IB_QPS_INIT) {
u8 port_num = (attr_mask & IB_QP_PORT ? attr->port_num :
qp->port) - 1;
- struct mlx5_ib_port *mibport = &dev->port[port_num];
-
+ mibport = &dev->port[port_num];
context->qp_counter_set_usr_page |=
- cpu_to_be32(mibport->q_cnt_id << 24);
+ cpu_to_be32((u32)(mibport->q_cnt_id) << 24);
}
+ if (!ibqp->uobject && cur_state == IB_QPS_RESET && new_state == IB_QPS_INIT)
+ context->sq_crq_size |= cpu_to_be16(1 << 4);
+
+ if (qp->flags & MLX5_IB_QP_SQPN_QP1)
+ context->deth_sqpn = cpu_to_be32(1);
+
mlx5_cur = to_mlx5_state(cur_state);
mlx5_new = to_mlx5_state(new_state);
mlx5_st = to_mlx5_st(ibqp->qp_type);
if (mlx5_st < 0)
goto out;
+ /* If moving to a reset or error state, we must disable page faults on
+ * this QP and flush all current page faults. Otherwise a stale page
+ * fault may attempt to work on this QP after it is reset and moved
+ * again to RTS, and may cause the driver and the device to get out of
+ * sync. */
+ if (cur_state != IB_QPS_RESET && cur_state != IB_QPS_ERR &&
+ (new_state == IB_QPS_RESET || new_state == IB_QPS_ERR) &&
+ (qp->ibqp.qp_type != IB_QPT_RAW_PACKET))
+ mlx5_ib_qp_disable_pagefaults(qp);
+
if (mlx5_cur >= MLX5_QP_NUM_STATE || mlx5_new >= MLX5_QP_NUM_STATE ||
!optab[mlx5_cur][mlx5_new])
- return -EINVAL;
+ goto out;
op = optab[mlx5_cur][mlx5_new];
optpar = ib_mask_to_mlx5_opt(attr_mask);
optpar &= opt_mask[mlx5_cur][mlx5_new][mlx5_st];
in->optparam = cpu_to_be32(optpar);
- if (qp->ibqp.qp_type == IB_QPT_RAW_PACKET)
- err = -EOPNOTSUPP;
- else
- err = mlx5_core_qp_modify(dev->mdev, op, in, sqd_event,
- &qp->mqp);
+ if (qp->ibqp.qp_type == IB_QPT_RAW_PACKET) {
+ struct mlx5_modify_raw_qp_param raw_qp_param = {};
+
+ raw_qp_param.operation = op;
+ if (cur_state == IB_QPS_RESET && new_state == IB_QPS_INIT) {
+ raw_qp_param.rq_q_ctr_id = mibport->q_cnt_id;
+ raw_qp_param.set_mask |= MLX5_RAW_QP_MOD_SET_RQ_Q_CTR_ID;
+ }
+ err = modify_raw_packet_qp(dev, qp, &raw_qp_param, 0);
+ } else {
+ err = mlx5_core_qp_modify(dev->mdev, op, in, 0, &base->mqp);
+ }
+
if (err)
goto out;
+ if (cur_state == IB_QPS_RESET && new_state == IB_QPS_INIT &&
+ (qp->ibqp.qp_type != IB_QPT_RAW_PACKET))
+ mlx5_ib_qp_enable_pagefaults(qp);
+
qp->state = new_state;
if (attr_mask & IB_QP_ACCESS_FLAGS)
- qp->atomic_rd_en = attr->qp_access_flags;
+ qp->trans_qp.atomic_rd_en = attr->qp_access_flags;
if (attr_mask & IB_QP_MAX_DEST_RD_ATOMIC)
- qp->resp_depth = attr->max_dest_rd_atomic;
+ qp->trans_qp.resp_depth = attr->max_dest_rd_atomic;
if (attr_mask & IB_QP_PORT)
qp->port = attr->port_num;
if (attr_mask & IB_QP_ALT_PATH)
- qp->alt_port = attr->alt_port_num;
+ qp->trans_qp.alt_port = attr->alt_port_num;
/*
* If we moved a kernel QP to RESET, clean up all old CQ
* entries and reinitialize the QP.
*/
if (new_state == IB_QPS_RESET && !ibqp->uobject) {
- mlx5_ib_cq_clean(recv_cq, qp->mqp.qpn,
+ mlx5_ib_cq_clean(recv_cq, base->mqp.qpn,
ibqp->srq ? to_msrq(ibqp->srq) : NULL);
if (send_cq != recv_cq)
- mlx5_ib_cq_clean(send_cq, qp->mqp.qpn, NULL);
+ mlx5_ib_cq_clean(send_cq, base->mqp.qpn, NULL);
qp->rq.head = 0;
qp->rq.tail = 0;
@@ -2048,10 +2807,8 @@ static int __mlx5_ib_modify_qp(struct ib_qp *ibqp,
qp->sq.tail = 0;
qp->sq.cur_post = 0;
qp->sq.last_poll = 0;
- if (qp->db.db) {
- qp->db.db[MLX5_RCV_DBR] = 0;
- qp->db.db[MLX5_SND_DBR] = 0;
- }
+ qp->db.db[MLX5_RCV_DBR] = 0;
+ qp->db.db[MLX5_SND_DBR] = 0;
}
out:
@@ -2059,56 +2816,76 @@ out:
return err;
}
-static int ignored_ts_check(enum ib_qp_type qp_type)
-{
- return 0;
-}
-
int mlx5_ib_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr,
int attr_mask, struct ib_udata *udata)
{
struct mlx5_ib_dev *dev = to_mdev(ibqp->device);
struct mlx5_ib_qp *qp = to_mqp(ibqp);
+ enum ib_qp_type qp_type;
enum ib_qp_state cur_state, new_state;
int err = -EINVAL;
int port;
enum rdma_link_layer ll = IB_LINK_LAYER_UNSPECIFIED;
-
+
+ if (ibqp->rwq_ind_tbl)
+ return -ENOSYS;
+
+ if (unlikely(ibqp->qp_type == IB_QPT_GSI))
+ return mlx5_ib_gsi_modify_qp(ibqp, attr, attr_mask);
+
+ qp_type = (unlikely(ibqp->qp_type == MLX5_IB_QPT_HW_GSI)) ?
+ IB_QPT_GSI : ibqp->qp_type;
+
mutex_lock(&qp->mutex);
cur_state = attr_mask & IB_QP_CUR_STATE ? attr->cur_qp_state : qp->state;
new_state = attr_mask & IB_QP_STATE ? attr->qp_state : cur_state;
-
+
if (!(cur_state == new_state && cur_state == IB_QPS_RESET)) {
port = attr_mask & IB_QP_PORT ? attr->port_num : qp->port;
ll = dev->ib_dev.get_link_layer(&dev->ib_dev, port);
}
- if (!ignored_ts_check(ibqp->qp_type) &&
- !ib_modify_qp_is_ok(cur_state, new_state, ibqp->qp_type, attr_mask, ll))
+ if (qp_type != MLX5_IB_QPT_REG_UMR &&
+ !ib_modify_qp_is_ok(cur_state, new_state, qp_type, attr_mask, ll)) {
+ mlx5_ib_dbg(dev, "invalid QP state transition from %d to %d, qp_type %d, attr_mask 0x%x\n",
+ cur_state, new_state, ibqp->qp_type, attr_mask);
goto out;
+ }
if ((attr_mask & IB_QP_PORT) &&
(attr->port_num == 0 ||
- attr->port_num > MLX5_CAP_GEN(dev->mdev, num_ports)))
+ attr->port_num > MLX5_CAP_GEN(dev->mdev, num_ports))) {
+ mlx5_ib_dbg(dev, "invalid port number %d. number of ports is %d\n",
+ attr->port_num, dev->num_ports);
goto out;
+ }
if (attr_mask & IB_QP_PKEY_INDEX) {
port = attr_mask & IB_QP_PORT ? attr->port_num : qp->port;
if (attr->pkey_index >=
- dev->mdev->port_caps[port - 1].pkey_table_len)
+ dev->mdev->port_caps[port - 1].pkey_table_len) {
+ mlx5_ib_dbg(dev, "invalid pkey index %d\n",
+ attr->pkey_index);
goto out;
+ }
}
if (attr_mask & IB_QP_MAX_QP_RD_ATOMIC &&
attr->max_rd_atomic >
- (1 << MLX5_CAP_GEN(dev->mdev, log_max_ra_res_qp)))
+ (1 << MLX5_CAP_GEN(dev->mdev, log_max_ra_res_qp))) {
+ mlx5_ib_dbg(dev, "invalid max_rd_atomic value %d\n",
+ attr->max_rd_atomic);
goto out;
+ }
if (attr_mask & IB_QP_MAX_DEST_RD_ATOMIC &&
attr->max_dest_rd_atomic >
- (1 << MLX5_CAP_GEN(dev->mdev, log_max_ra_req_qp)))
+ (1 << MLX5_CAP_GEN(dev->mdev, log_max_ra_req_qp))) {
+ mlx5_ib_dbg(dev, "invalid max_dest_rd_atomic value %d\n",
+ attr->max_dest_rd_atomic);
goto out;
+ }
if (cur_state == new_state && cur_state == IB_QPS_RESET) {
err = 0;
@@ -2147,12 +2924,65 @@ static __always_inline void set_raddr_seg(struct mlx5_wqe_raddr_seg *rseg,
rseg->reserved = 0;
}
+static void *set_eth_seg(struct mlx5_wqe_eth_seg *eseg,
+ struct ib_send_wr *wr, void *qend,
+ struct mlx5_ib_qp *qp, int *size)
+{
+ void *seg = eseg;
+
+ memset(eseg, 0, sizeof(struct mlx5_wqe_eth_seg));
+
+ if (wr->send_flags & IB_SEND_IP_CSUM)
+ eseg->cs_flags = MLX5_ETH_WQE_L3_CSUM |
+ MLX5_ETH_WQE_L4_CSUM;
+
+ seg += sizeof(struct mlx5_wqe_eth_seg);
+ *size += sizeof(struct mlx5_wqe_eth_seg) / 16;
+
+ if (wr->opcode == IB_WR_LSO) {
+ struct ib_ud_wr *ud_wr = container_of(wr, struct ib_ud_wr, wr);
+ int size_of_inl_hdr_start = sizeof(eseg->inline_hdr_start);
+ u64 left, leftlen, copysz;
+ void *pdata = ud_wr->header;
+
+ left = ud_wr->hlen;
+ eseg->mss = cpu_to_be16(ud_wr->mss);
+ eseg->inline_hdr_sz = cpu_to_be16(left);
+
+ /*
+ * check if there is space till the end of queue, if yes,
+ * copy all in one shot, otherwise copy till the end of queue,
+ * rollback and than the copy the left
+ */
+ leftlen = qend - (void *)eseg->inline_hdr_start;
+ copysz = min_t(u64, leftlen, left);
+
+ memcpy(seg - size_of_inl_hdr_start, pdata, copysz);
+
+ if (likely(copysz > size_of_inl_hdr_start)) {
+ seg += ALIGN(copysz - size_of_inl_hdr_start, 16);
+ *size += ALIGN(copysz - size_of_inl_hdr_start, 16) / 16;
+ }
+
+ if (unlikely(copysz < left)) { /* the last wqe in the queue */
+ seg = mlx5_get_send_wqe(qp, 0);
+ left -= copysz;
+ pdata += copysz;
+ memcpy(seg, pdata, left);
+ seg += ALIGN(left, 16);
+ *size += ALIGN(left, 16) / 16;
+ }
+ }
+
+ return seg;
+}
+
static void set_datagram_seg(struct mlx5_wqe_datagram_seg *dseg,
struct ib_send_wr *wr)
{
- memcpy(&dseg->av, &to_mah(wr->wr.ud.ah)->av, sizeof(struct mlx5_av));
- dseg->av.dqp_dct = cpu_to_be32(wr->wr.ud.remote_qpn | MLX5_EXTENDED_UD_AV);
- dseg->av.key.qkey.qkey = cpu_to_be32(wr->wr.ud.remote_qkey);
+ memcpy(&dseg->av, &to_mah(ud_wr(wr)->ah)->av, sizeof(struct mlx5_av));
+ dseg->av.dqp_dct = cpu_to_be32(ud_wr(wr)->remote_qpn | MLX5_EXTENDED_UD_AV);
+ dseg->av.key.qkey.qkey = cpu_to_be32(ud_wr(wr)->remote_qkey);
}
static void set_data_ptr_seg(struct mlx5_wqe_data_seg *dseg, struct ib_sge *sg)
@@ -2187,22 +3017,160 @@ static __be64 frwr_mkey_mask(void)
return cpu_to_be64(result);
}
-static void set_frwr_umr_segment(struct mlx5_wqe_umr_ctrl_seg *umr,
- struct ib_send_wr *wr, int li)
+static __be64 sig_mkey_mask(void)
{
+ u64 result;
+
+ result = MLX5_MKEY_MASK_LEN |
+ MLX5_MKEY_MASK_PAGE_SIZE |
+ MLX5_MKEY_MASK_START_ADDR |
+ MLX5_MKEY_MASK_EN_SIGERR |
+ MLX5_MKEY_MASK_EN_RINVAL |
+ MLX5_MKEY_MASK_KEY |
+ MLX5_MKEY_MASK_LR |
+ MLX5_MKEY_MASK_LW |
+ MLX5_MKEY_MASK_RR |
+ MLX5_MKEY_MASK_RW |
+ MLX5_MKEY_MASK_SMALL_FENCE |
+ MLX5_MKEY_MASK_FREE |
+ MLX5_MKEY_MASK_BSF_EN;
+
+ return cpu_to_be64(result);
+}
+
+static void set_reg_umr_seg(struct mlx5_wqe_umr_ctrl_seg *umr,
+ struct mlx5_ib_mr *mr)
+{
+ int ndescs = mr->ndescs;
+
memset(umr, 0, sizeof(*umr));
- if (li) {
- umr->mkey_mask = cpu_to_be64(MLX5_MKEY_MASK_FREE);
- umr->flags = 1 << 7;
- return;
- }
+ if (mr->access_mode == MLX5_ACCESS_MODE_KLM)
+ /* KLMs take twice the size of MTTs */
+ ndescs *= 2;
- umr->flags = (1 << 5); /* fail if not free */
- umr->klm_octowords = get_klm_octo(wr->wr.fast_reg.page_list_len);
+ umr->flags = MLX5_UMR_CHECK_NOT_FREE;
+ umr->klm_octowords = get_klm_octo(ndescs);
umr->mkey_mask = frwr_mkey_mask();
}
+static void set_linv_umr_seg(struct mlx5_wqe_umr_ctrl_seg *umr)
+{
+ memset(umr, 0, sizeof(*umr));
+ umr->mkey_mask = cpu_to_be64(MLX5_MKEY_MASK_FREE);
+ umr->flags = 1 << 7;
+}
+
+static __be64 get_umr_reg_mr_mask(void)
+{
+ u64 result;
+
+ result = MLX5_MKEY_MASK_LEN |
+ MLX5_MKEY_MASK_PAGE_SIZE |
+ MLX5_MKEY_MASK_START_ADDR |
+ MLX5_MKEY_MASK_PD |
+ MLX5_MKEY_MASK_LR |
+ MLX5_MKEY_MASK_LW |
+ MLX5_MKEY_MASK_KEY |
+ MLX5_MKEY_MASK_RR |
+ MLX5_MKEY_MASK_RW |
+ MLX5_MKEY_MASK_A |
+ MLX5_MKEY_MASK_FREE;
+
+ return cpu_to_be64(result);
+}
+
+static __be64 get_umr_unreg_mr_mask(void)
+{
+ u64 result;
+
+ result = MLX5_MKEY_MASK_FREE;
+
+ return cpu_to_be64(result);
+}
+
+static __be64 get_umr_update_mtt_mask(void)
+{
+ u64 result;
+
+ result = MLX5_MKEY_MASK_FREE;
+
+ return cpu_to_be64(result);
+}
+
+static __be64 get_umr_update_translation_mask(void)
+{
+ u64 result;
+
+ result = MLX5_MKEY_MASK_LEN |
+ MLX5_MKEY_MASK_PAGE_SIZE |
+ MLX5_MKEY_MASK_START_ADDR |
+ MLX5_MKEY_MASK_KEY |
+ MLX5_MKEY_MASK_FREE;
+
+ return cpu_to_be64(result);
+}
+
+static __be64 get_umr_update_access_mask(void)
+{
+ u64 result;
+
+ result = MLX5_MKEY_MASK_LW |
+ MLX5_MKEY_MASK_RR |
+ MLX5_MKEY_MASK_RW |
+ MLX5_MKEY_MASK_A |
+ MLX5_MKEY_MASK_KEY |
+ MLX5_MKEY_MASK_FREE;
+
+ return cpu_to_be64(result);
+}
+
+static __be64 get_umr_update_pd_mask(void)
+{
+ u64 result;
+
+ result = MLX5_MKEY_MASK_PD |
+ MLX5_MKEY_MASK_KEY |
+ MLX5_MKEY_MASK_FREE;
+
+ return cpu_to_be64(result);
+}
+
+static void set_reg_umr_segment(struct mlx5_wqe_umr_ctrl_seg *umr,
+ struct ib_send_wr *wr)
+{
+ struct mlx5_umr_wr *umrwr = umr_wr(wr);
+
+ memset(umr, 0, sizeof(*umr));
+
+ if (wr->send_flags & MLX5_IB_SEND_UMR_FAIL_IF_FREE)
+ umr->flags = MLX5_UMR_CHECK_FREE; /* fail if free */
+ else
+ umr->flags = MLX5_UMR_CHECK_NOT_FREE; /* fail if not free */
+
+ if (!(wr->send_flags & MLX5_IB_SEND_UMR_UNREG)) {
+ umr->klm_octowords = get_klm_octo(umrwr->npages);
+ if (wr->send_flags & MLX5_IB_SEND_UMR_UPDATE_MTT) {
+ umr->mkey_mask = get_umr_update_mtt_mask();
+ umr->bsf_octowords = get_klm_octo(umrwr->target.offset);
+ umr->flags |= MLX5_UMR_TRANSLATION_OFFSET_EN;
+ }
+ if (wr->send_flags & MLX5_IB_SEND_UMR_UPDATE_TRANSLATION)
+ umr->mkey_mask |= get_umr_update_translation_mask();
+ if (wr->send_flags & MLX5_IB_SEND_UMR_UPDATE_ACCESS)
+ umr->mkey_mask |= get_umr_update_access_mask();
+ if (wr->send_flags & MLX5_IB_SEND_UMR_UPDATE_PD)
+ umr->mkey_mask |= get_umr_update_pd_mask();
+ if (!umr->mkey_mask)
+ umr->mkey_mask = get_umr_reg_mr_mask();
+ } else {
+ umr->mkey_mask = get_umr_unreg_mr_mask();
+ }
+
+ if (!wr->num_sge)
+ umr->flags |= MLX5_UMR_INLINE;
+}
+
static u8 get_umr_flags(int acc)
{
return (acc & IB_ACCESS_REMOTE_ATOMIC ? MLX5_PERM_ATOMIC : 0) |
@@ -2212,42 +3180,65 @@ static u8 get_umr_flags(int acc)
MLX5_PERM_LOCAL_READ | MLX5_PERM_UMR_EN;
}
-static void set_mkey_segment(struct mlx5_mkey_seg *seg, struct ib_send_wr *wr,
- int li, int *writ)
+static void set_reg_mkey_seg(struct mlx5_mkey_seg *seg,
+ struct mlx5_ib_mr *mr,
+ u32 key, int access)
{
+ int ndescs = ALIGN(mr->ndescs, 8) >> 1;
+
memset(seg, 0, sizeof(*seg));
- if (li) {
+
+ if (mr->access_mode == MLX5_ACCESS_MODE_MTT)
+ seg->log2_page_size = ilog2(mr->ibmr.page_size);
+ else if (mr->access_mode == MLX5_ACCESS_MODE_KLM)
+ /* KLMs take twice the size of MTTs */
+ ndescs *= 2;
+
+ seg->flags = get_umr_flags(access) | mr->access_mode;
+ seg->qpn_mkey7_0 = cpu_to_be32((key & 0xff) | 0xffffff00);
+ seg->flags_pd = cpu_to_be32(MLX5_MKEY_REMOTE_INVAL);
+ seg->start_addr = cpu_to_be64(mr->ibmr.iova);
+ seg->len = cpu_to_be64(mr->ibmr.length);
+ seg->xlt_oct_size = cpu_to_be32(ndescs);
+}
+
+static void set_linv_mkey_seg(struct mlx5_mkey_seg *seg)
+{
+ memset(seg, 0, sizeof(*seg));
+ seg->status = MLX5_MKEY_STATUS_FREE;
+}
+
+static void set_reg_mkey_segment(struct mlx5_mkey_seg *seg, struct ib_send_wr *wr)
+{
+ struct mlx5_umr_wr *umrwr = umr_wr(wr);
+
+ memset(seg, 0, sizeof(*seg));
+ if (wr->send_flags & MLX5_IB_SEND_UMR_UNREG) {
seg->status = MLX5_MKEY_STATUS_FREE;
return;
}
- seg->flags = get_umr_flags(wr->wr.fast_reg.access_flags) |
- MLX5_ACCESS_MODE_MTT;
- *writ = seg->flags & (MLX5_PERM_LOCAL_WRITE | IB_ACCESS_REMOTE_WRITE);
- seg->qpn_mkey7_0 = cpu_to_be32((wr->wr.fast_reg.rkey & 0xff) | 0xffffff00);
- seg->flags_pd = cpu_to_be32(MLX5_MKEY_REMOTE_INVAL);
- seg->start_addr = cpu_to_be64(wr->wr.fast_reg.iova_start);
- seg->len = cpu_to_be64(wr->wr.fast_reg.length);
- seg->xlt_oct_size = cpu_to_be32((wr->wr.fast_reg.page_list_len + 1) / 2);
- seg->log2_page_size = wr->wr.fast_reg.page_shift;
+ seg->flags = convert_access(umrwr->access_flags);
+ if (!(wr->send_flags & MLX5_IB_SEND_UMR_UPDATE_MTT)) {
+ if (umrwr->pd)
+ seg->flags_pd = cpu_to_be32(to_mpd(umrwr->pd)->pdn);
+ seg->start_addr = cpu_to_be64(umrwr->target.virt_addr);
+ }
+ seg->len = cpu_to_be64(umrwr->length);
+ seg->log2_page_size = umrwr->page_shift;
+ seg->qpn_mkey7_0 = cpu_to_be32(0xffffff00 |
+ mlx5_mkey_variant(umrwr->mkey));
}
-static void set_frwr_pages(struct mlx5_wqe_data_seg *dseg,
- struct ib_send_wr *wr,
- struct mlx5_core_dev *mdev,
- struct mlx5_ib_pd *pd,
- int writ)
+static void set_reg_data_seg(struct mlx5_wqe_data_seg *dseg,
+ struct mlx5_ib_mr *mr,
+ struct mlx5_ib_pd *pd)
{
- struct mlx5_ib_fast_reg_page_list *mfrpl = to_mfrpl(wr->wr.fast_reg.page_list);
- u64 *page_list = wr->wr.fast_reg.page_list->page_list;
- u64 perm = MLX5_EN_RD | (writ ? MLX5_EN_WR : 0);
- int i;
+ int bcount = mr->desc_size * mr->ndescs;
- for (i = 0; i < wr->wr.fast_reg.page_list_len; i++)
- mfrpl->mapped_page_list[i] = cpu_to_be64(page_list[i] | perm);
- dseg->addr = cpu_to_be64(mfrpl->map);
- dseg->byte_count = cpu_to_be32(ALIGN(sizeof(u64) * wr->wr.fast_reg.page_list_len, 64));
- dseg->lkey = cpu_to_be32(pd->pa_lkey);
+ dseg->addr = cpu_to_be64(mr->desc_map);
+ dseg->byte_count = cpu_to_be32(ALIGN(bcount, 64));
+ dseg->lkey = cpu_to_be32(pd->ibpd.local_dma_lkey);
}
static __be32 send_ieth(struct ib_send_wr *wr)
@@ -2277,7 +3268,7 @@ static u8 calc_sig(void *wqe, int size)
return ~res;
}
-static u8 calc_wq_sig(void *wqe)
+static u8 wq_sig(void *wqe)
{
return calc_sig(wqe, (*((u8 *)wqe + 8) & 0x3f) << 4);
}
@@ -2296,7 +3287,7 @@ static int set_data_inl_seg(struct mlx5_ib_qp *qp, struct ib_send_wr *wr,
seg = wqe;
wqe += sizeof(*seg);
for (i = 0; i < wr->num_sge; i++) {
- addr = (void *)(uintptr_t)(wr->sg_list[i].addr);
+ addr = (void *)(unsigned long)(wr->sg_list[i].addr);
len = wr->sg_list[i].length;
inl += len;
@@ -2304,7 +3295,7 @@ static int set_data_inl_seg(struct mlx5_ib_qp *qp, struct ib_send_wr *wr,
return -ENOMEM;
if (unlikely(wqe + len > qend)) {
- copy = (int)(qend - wqe);
+ copy = qend - wqe;
memcpy(wqe, addr, copy);
addr += copy;
len -= copy;
@@ -2321,38 +3312,368 @@ static int set_data_inl_seg(struct mlx5_ib_qp *qp, struct ib_send_wr *wr,
return 0;
}
-static int set_frwr_li_wr(void **seg, struct ib_send_wr *wr, int *size,
- struct mlx5_core_dev *mdev, struct mlx5_ib_pd *pd, struct mlx5_ib_qp *qp)
+static u16 prot_field_size(enum ib_signature_type type)
+{
+ switch (type) {
+ case IB_SIG_TYPE_T10_DIF:
+ return MLX5_DIF_SIZE;
+ default:
+ return 0;
+ }
+}
+
+static u8 bs_selector(int block_size)
{
- int writ = 0;
- int li;
+ switch (block_size) {
+ case 512: return 0x1;
+ case 520: return 0x2;
+ case 4096: return 0x3;
+ case 4160: return 0x4;
+ case 1073741824: return 0x5;
+ default: return 0;
+ }
+}
- li = wr->opcode == IB_WR_LOCAL_INV ? 1 : 0;
- if (unlikely(wr->send_flags & IB_SEND_INLINE))
+static void mlx5_fill_inl_bsf(struct ib_sig_domain *domain,
+ struct mlx5_bsf_inl *inl)
+{
+ /* Valid inline section and allow BSF refresh */
+ inl->vld_refresh = cpu_to_be16(MLX5_BSF_INL_VALID |
+ MLX5_BSF_REFRESH_DIF);
+ inl->dif_apptag = cpu_to_be16(domain->sig.dif.app_tag);
+ inl->dif_reftag = cpu_to_be32(domain->sig.dif.ref_tag);
+ /* repeating block */
+ inl->rp_inv_seed = MLX5_BSF_REPEAT_BLOCK;
+ inl->sig_type = domain->sig.dif.bg_type == IB_T10DIF_CRC ?
+ MLX5_DIF_CRC : MLX5_DIF_IPCS;
+
+ if (domain->sig.dif.ref_remap)
+ inl->dif_inc_ref_guard_check |= MLX5_BSF_INC_REFTAG;
+
+ if (domain->sig.dif.app_escape) {
+ if (domain->sig.dif.ref_escape)
+ inl->dif_inc_ref_guard_check |= MLX5_BSF_APPREF_ESCAPE;
+ else
+ inl->dif_inc_ref_guard_check |= MLX5_BSF_APPTAG_ESCAPE;
+ }
+
+ inl->dif_app_bitmask_check =
+ cpu_to_be16(domain->sig.dif.apptag_check_mask);
+}
+
+static int mlx5_set_bsf(struct ib_mr *sig_mr,
+ struct ib_sig_attrs *sig_attrs,
+ struct mlx5_bsf *bsf, u32 data_size)
+{
+ struct mlx5_core_sig_ctx *msig = to_mmr(sig_mr)->sig;
+ struct mlx5_bsf_basic *basic = &bsf->basic;
+ struct ib_sig_domain *mem = &sig_attrs->mem;
+ struct ib_sig_domain *wire = &sig_attrs->wire;
+
+ memset(bsf, 0, sizeof(*bsf));
+
+ /* Basic + Extended + Inline */
+ basic->bsf_size_sbs = 1 << 7;
+ /* Input domain check byte mask */
+ basic->check_byte_mask = sig_attrs->check_mask;
+ basic->raw_data_size = cpu_to_be32(data_size);
+
+ /* Memory domain */
+ switch (sig_attrs->mem.sig_type) {
+ case IB_SIG_TYPE_NONE:
+ break;
+ case IB_SIG_TYPE_T10_DIF:
+ basic->mem.bs_selector = bs_selector(mem->sig.dif.pi_interval);
+ basic->m_bfs_psv = cpu_to_be32(msig->psv_memory.psv_idx);
+ mlx5_fill_inl_bsf(mem, &bsf->m_inl);
+ break;
+ default:
+ return -EINVAL;
+ }
+
+ /* Wire domain */
+ switch (sig_attrs->wire.sig_type) {
+ case IB_SIG_TYPE_NONE:
+ break;
+ case IB_SIG_TYPE_T10_DIF:
+ if (mem->sig.dif.pi_interval == wire->sig.dif.pi_interval &&
+ mem->sig_type == wire->sig_type) {
+ /* Same block structure */
+ basic->bsf_size_sbs |= 1 << 4;
+ if (mem->sig.dif.bg_type == wire->sig.dif.bg_type)
+ basic->wire.copy_byte_mask |= MLX5_CPY_GRD_MASK;
+ if (mem->sig.dif.app_tag == wire->sig.dif.app_tag)
+ basic->wire.copy_byte_mask |= MLX5_CPY_APP_MASK;
+ if (mem->sig.dif.ref_tag == wire->sig.dif.ref_tag)
+ basic->wire.copy_byte_mask |= MLX5_CPY_REF_MASK;
+ } else
+ basic->wire.bs_selector = bs_selector(wire->sig.dif.pi_interval);
+
+ basic->w_bfs_psv = cpu_to_be32(msig->psv_wire.psv_idx);
+ mlx5_fill_inl_bsf(wire, &bsf->w_inl);
+ break;
+ default:
+ return -EINVAL;
+ }
+
+ return 0;
+}
+
+static int set_sig_data_segment(struct ib_sig_handover_wr *wr,
+ struct mlx5_ib_qp *qp, void **seg, int *size)
+{
+ struct ib_sig_attrs *sig_attrs = wr->sig_attrs;
+ struct ib_mr *sig_mr = wr->sig_mr;
+ struct mlx5_bsf *bsf;
+ u32 data_len = wr->wr.sg_list->length;
+ u32 data_key = wr->wr.sg_list->lkey;
+ u64 data_va = wr->wr.sg_list->addr;
+ int ret;
+ int wqe_size;
+
+ if (!wr->prot ||
+ (data_key == wr->prot->lkey &&
+ data_va == wr->prot->addr &&
+ data_len == wr->prot->length)) {
+ /**
+ * Source domain doesn't contain signature information
+ * or data and protection are interleaved in memory.
+ * So need construct:
+ * ------------------
+ * | data_klm |
+ * ------------------
+ * | BSF |
+ * ------------------
+ **/
+ struct mlx5_klm *data_klm = *seg;
+
+ data_klm->bcount = cpu_to_be32(data_len);
+ data_klm->key = cpu_to_be32(data_key);
+ data_klm->va = cpu_to_be64(data_va);
+ wqe_size = ALIGN(sizeof(*data_klm), 64);
+ } else {
+ /**
+ * Source domain contains signature information
+ * So need construct a strided block format:
+ * ---------------------------
+ * | stride_block_ctrl |
+ * ---------------------------
+ * | data_klm |
+ * ---------------------------
+ * | prot_klm |
+ * ---------------------------
+ * | BSF |
+ * ---------------------------
+ **/
+ struct mlx5_stride_block_ctrl_seg *sblock_ctrl;
+ struct mlx5_stride_block_entry *data_sentry;
+ struct mlx5_stride_block_entry *prot_sentry;
+ u32 prot_key = wr->prot->lkey;
+ u64 prot_va = wr->prot->addr;
+ u16 block_size = sig_attrs->mem.sig.dif.pi_interval;
+ int prot_size;
+
+ sblock_ctrl = *seg;
+ data_sentry = (void *)sblock_ctrl + sizeof(*sblock_ctrl);
+ prot_sentry = (void *)data_sentry + sizeof(*data_sentry);
+
+ prot_size = prot_field_size(sig_attrs->mem.sig_type);
+ if (!prot_size) {
+ pr_err("Bad block size given: %u\n", block_size);
+ return -EINVAL;
+ }
+ sblock_ctrl->bcount_per_cycle = cpu_to_be32(block_size +
+ prot_size);
+ sblock_ctrl->op = cpu_to_be32(MLX5_STRIDE_BLOCK_OP);
+ sblock_ctrl->repeat_count = cpu_to_be32(data_len / block_size);
+ sblock_ctrl->num_entries = cpu_to_be16(2);
+
+ data_sentry->bcount = cpu_to_be16(block_size);
+ data_sentry->key = cpu_to_be32(data_key);
+ data_sentry->va = cpu_to_be64(data_va);
+ data_sentry->stride = cpu_to_be16(block_size);
+
+ prot_sentry->bcount = cpu_to_be16(prot_size);
+ prot_sentry->key = cpu_to_be32(prot_key);
+ prot_sentry->va = cpu_to_be64(prot_va);
+ prot_sentry->stride = cpu_to_be16(prot_size);
+
+ wqe_size = ALIGN(sizeof(*sblock_ctrl) + sizeof(*data_sentry) +
+ sizeof(*prot_sentry), 64);
+ }
+
+ *seg += wqe_size;
+ *size += wqe_size / 16;
+ if (unlikely((*seg == qp->sq.qend)))
+ *seg = mlx5_get_send_wqe(qp, 0);
+
+ bsf = *seg;
+ ret = mlx5_set_bsf(sig_mr, sig_attrs, bsf, data_len);
+ if (ret)
return -EINVAL;
- set_frwr_umr_segment(*seg, wr, li);
+ *seg += sizeof(*bsf);
+ *size += sizeof(*bsf) / 16;
+ if (unlikely((*seg == qp->sq.qend)))
+ *seg = mlx5_get_send_wqe(qp, 0);
+
+ return 0;
+}
+
+static void set_sig_mkey_segment(struct mlx5_mkey_seg *seg,
+ struct ib_sig_handover_wr *wr, u32 nelements,
+ u32 length, u32 pdn)
+{
+ struct ib_mr *sig_mr = wr->sig_mr;
+ u32 sig_key = sig_mr->rkey;
+ u8 sigerr = to_mmr(sig_mr)->sig->sigerr_count & 1;
+
+ memset(seg, 0, sizeof(*seg));
+
+ seg->flags = get_umr_flags(wr->access_flags) |
+ MLX5_ACCESS_MODE_KLM;
+ seg->qpn_mkey7_0 = cpu_to_be32((sig_key & 0xff) | 0xffffff00);
+ seg->flags_pd = cpu_to_be32(MLX5_MKEY_REMOTE_INVAL | sigerr << 26 |
+ MLX5_MKEY_BSF_EN | pdn);
+ seg->len = cpu_to_be64(length);
+ seg->xlt_oct_size = cpu_to_be32(be16_to_cpu(get_klm_octo(nelements)));
+ seg->bsfs_octo_size = cpu_to_be32(MLX5_MKEY_BSF_OCTO_SIZE);
+}
+
+static void set_sig_umr_segment(struct mlx5_wqe_umr_ctrl_seg *umr,
+ u32 nelements)
+{
+ memset(umr, 0, sizeof(*umr));
+
+ umr->flags = MLX5_FLAGS_INLINE | MLX5_FLAGS_CHECK_FREE;
+ umr->klm_octowords = get_klm_octo(nelements);
+ umr->bsf_octowords = cpu_to_be16(MLX5_MKEY_BSF_OCTO_SIZE);
+ umr->mkey_mask = sig_mkey_mask();
+}
+
+
+static int set_sig_umr_wr(struct ib_send_wr *send_wr, struct mlx5_ib_qp *qp,
+ void **seg, int *size)
+{
+ struct ib_sig_handover_wr *wr = sig_handover_wr(send_wr);
+ struct mlx5_ib_mr *sig_mr = to_mmr(wr->sig_mr);
+ u32 pdn = get_pd(qp)->pdn;
+ u32 klm_oct_size;
+ int region_len, ret;
+
+ if (unlikely(wr->wr.num_sge != 1) ||
+ unlikely(wr->access_flags & IB_ACCESS_REMOTE_ATOMIC) ||
+ unlikely(!sig_mr->sig) || unlikely(!qp->signature_en) ||
+ unlikely(!sig_mr->sig->sig_status_checked))
+ return -EINVAL;
+
+ /* length of the protected region, data + protection */
+ region_len = wr->wr.sg_list->length;
+ if (wr->prot &&
+ (wr->prot->lkey != wr->wr.sg_list->lkey ||
+ wr->prot->addr != wr->wr.sg_list->addr ||
+ wr->prot->length != wr->wr.sg_list->length))
+ region_len += wr->prot->length;
+
+ /**
+ * KLM octoword size - if protection was provided
+ * then we use strided block format (3 octowords),
+ * else we use single KLM (1 octoword)
+ **/
+ klm_oct_size = wr->prot ? 3 : 1;
+
+ set_sig_umr_segment(*seg, klm_oct_size);
*seg += sizeof(struct mlx5_wqe_umr_ctrl_seg);
*size += sizeof(struct mlx5_wqe_umr_ctrl_seg) / 16;
if (unlikely((*seg == qp->sq.qend)))
*seg = mlx5_get_send_wqe(qp, 0);
- set_mkey_segment(*seg, wr, li, &writ);
+
+ set_sig_mkey_segment(*seg, wr, klm_oct_size, region_len, pdn);
*seg += sizeof(struct mlx5_mkey_seg);
*size += sizeof(struct mlx5_mkey_seg) / 16;
if (unlikely((*seg == qp->sq.qend)))
*seg = mlx5_get_send_wqe(qp, 0);
- if (!li) {
- if (unlikely(wr->wr.fast_reg.page_list_len >
- wr->wr.fast_reg.page_list->max_page_list_len))
- return -ENOMEM;
- set_frwr_pages(*seg, wr, mdev, pd, writ);
- *seg += sizeof(struct mlx5_wqe_data_seg);
- *size += (sizeof(struct mlx5_wqe_data_seg) / 16);
+ ret = set_sig_data_segment(wr, qp, seg, size);
+ if (ret)
+ return ret;
+
+ sig_mr->sig->sig_status_checked = false;
+ return 0;
+}
+
+static int set_psv_wr(struct ib_sig_domain *domain,
+ u32 psv_idx, void **seg, int *size)
+{
+ struct mlx5_seg_set_psv *psv_seg = *seg;
+
+ memset(psv_seg, 0, sizeof(*psv_seg));
+ psv_seg->psv_num = cpu_to_be32(psv_idx);
+ switch (domain->sig_type) {
+ case IB_SIG_TYPE_NONE:
+ break;
+ case IB_SIG_TYPE_T10_DIF:
+ psv_seg->transient_sig = cpu_to_be32(domain->sig.dif.bg << 16 |
+ domain->sig.dif.app_tag);
+ psv_seg->ref_tag = cpu_to_be32(domain->sig.dif.ref_tag);
+ break;
+ default:
+ pr_err("Bad signature type given.\n");
+ return 1;
+ }
+
+ *seg += sizeof(*psv_seg);
+ *size += sizeof(*psv_seg) / 16;
+
+ return 0;
+}
+
+static int set_reg_wr(struct mlx5_ib_qp *qp,
+ struct ib_reg_wr *wr,
+ void **seg, int *size)
+{
+ struct mlx5_ib_mr *mr = to_mmr(wr->mr);
+ struct mlx5_ib_pd *pd = to_mpd(qp->ibqp.pd);
+
+ if (unlikely(wr->wr.send_flags & IB_SEND_INLINE)) {
+ mlx5_ib_warn(to_mdev(qp->ibqp.device),
+ "Invalid IB_SEND_INLINE send flag\n");
+ return -EINVAL;
}
+
+ set_reg_umr_seg(*seg, mr);
+ *seg += sizeof(struct mlx5_wqe_umr_ctrl_seg);
+ *size += sizeof(struct mlx5_wqe_umr_ctrl_seg) / 16;
+ if (unlikely((*seg == qp->sq.qend)))
+ *seg = mlx5_get_send_wqe(qp, 0);
+
+ set_reg_mkey_seg(*seg, mr, wr->key, wr->access);
+ *seg += sizeof(struct mlx5_mkey_seg);
+ *size += sizeof(struct mlx5_mkey_seg) / 16;
+ if (unlikely((*seg == qp->sq.qend)))
+ *seg = mlx5_get_send_wqe(qp, 0);
+
+ set_reg_data_seg(*seg, mr, pd);
+ *seg += sizeof(struct mlx5_wqe_data_seg);
+ *size += (sizeof(struct mlx5_wqe_data_seg) / 16);
+
return 0;
}
+static void set_linv_wr(struct mlx5_ib_qp *qp, void **seg, int *size)
+{
+ set_linv_umr_seg(*seg);
+ *seg += sizeof(struct mlx5_wqe_umr_ctrl_seg);
+ *size += sizeof(struct mlx5_wqe_umr_ctrl_seg) / 16;
+ if (unlikely((*seg == qp->sq.qend)))
+ *seg = mlx5_get_send_wqe(qp, 0);
+ set_linv_mkey_seg(*seg);
+ *seg += sizeof(struct mlx5_mkey_seg);
+ *size += sizeof(struct mlx5_mkey_seg) / 16;
+ if (unlikely((*seg == qp->sq.qend)))
+ *seg = mlx5_get_send_wqe(qp, 0);
+}
+
static void dump_wqe(struct mlx5_ib_qp *qp, int idx, int size_16)
{
__be32 *p = NULL;
@@ -2402,10 +3723,11 @@ static u8 get_fence(u8 fence, struct ib_send_wr *wr)
return MLX5_FENCE_MODE_SMALL_AND_FENCE;
else
return fence;
-
- } else {
- return 0;
+ } else if (unlikely(wr->send_flags & IB_SEND_FENCE)) {
+ return MLX5_FENCE_MODE_FENCE;
}
+
+ return 0;
}
static int begin_wqe(struct mlx5_ib_qp *qp, void **seg,
@@ -2413,18 +3735,13 @@ static int begin_wqe(struct mlx5_ib_qp *qp, void **seg,
struct ib_send_wr *wr, unsigned *idx,
int *size, int nreq)
{
- int err = 0;
-
- if (unlikely(mlx5_wq_overflow(&qp->sq, nreq, qp->ibqp.send_cq))) {
- mlx5_ib_warn(to_mdev(qp->ibqp.device), "work queue overflow\n");
- err = -ENOMEM;
- return err;
- }
+ if (unlikely(mlx5_wq_overflow(&qp->sq, nreq, qp->ibqp.send_cq)))
+ return -ENOMEM;
*idx = qp->sq.cur_post & (qp->sq.wqe_cnt - 1);
*seg = mlx5_get_send_wqe(qp, *idx);
*ctrl = *seg;
- *(u32 *)(*seg + 8) = 0;
+ *(uint32_t *)(*seg + 8) = 0;
(*ctrl)->imm = send_ieth(wr);
(*ctrl)->fm_ce_se = qp->sq_signal_bits |
(wr->send_flags & IB_SEND_SIGNALED ?
@@ -2435,13 +3752,12 @@ static int begin_wqe(struct mlx5_ib_qp *qp, void **seg,
*seg += sizeof(**ctrl);
*size = sizeof(**ctrl) / 16;
- return err;
+ return 0;
}
static void finish_wqe(struct mlx5_ib_qp *qp,
struct mlx5_wqe_ctrl_seg *ctrl,
- u8 size, unsigned idx,
- struct ib_send_wr *wr,
+ u8 size, unsigned idx, u64 wr_id,
int nreq, u8 fence, u8 next_fence,
u32 mlx5_opcode)
{
@@ -2449,32 +3765,33 @@ static void finish_wqe(struct mlx5_ib_qp *qp,
ctrl->opmod_idx_opcode = cpu_to_be32(((u32)(qp->sq.cur_post) << 8) |
mlx5_opcode | ((u32)opmod << 24));
- ctrl->qpn_ds = cpu_to_be32(size | (qp->mqp.qpn << 8));
+ ctrl->qpn_ds = cpu_to_be32(size | (qp->trans_qp.base.mqp.qpn << 8));
ctrl->fm_ce_se |= fence;
qp->fm_cache = next_fence;
if (unlikely(qp->wq_sig))
- ctrl->signature = calc_wq_sig(ctrl);
+ ctrl->signature = wq_sig(ctrl);
- qp->sq.swr_ctx[idx].wrid = wr->wr_id;
- qp->sq.swr_ctx[idx].w_list.opcode = mlx5_opcode;
- qp->sq.swr_ctx[idx].wqe_head = qp->sq.head + nreq;
+ qp->sq.wrid[idx] = wr_id;
+ qp->sq.w_list[idx].opcode = mlx5_opcode;
+ qp->sq.wqe_head[idx] = qp->sq.head + nreq;
qp->sq.cur_post += DIV_ROUND_UP(size * 16, MLX5_SEND_WQE_BB);
- qp->sq.swr_ctx[idx].w_list.next = qp->sq.cur_post;
- qp->sq.swr_ctx[idx].sig_piped = 0;
+ qp->sq.w_list[idx].next = qp->sq.cur_post;
}
+
int mlx5_ib_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr,
struct ib_send_wr **bad_wr)
{
struct mlx5_wqe_ctrl_seg *ctrl = NULL; /* compiler warning */
struct mlx5_ib_dev *dev = to_mdev(ibqp->device);
struct mlx5_core_dev *mdev = dev->mdev;
- struct mlx5_ib_qp *qp = to_mqp(ibqp);
+ struct mlx5_ib_qp *qp;
+ struct mlx5_ib_mr *mr;
struct mlx5_wqe_data_seg *dpseg;
struct mlx5_wqe_xrc_seg *xrc;
- struct mlx5_bf *bf = qp->bf;
+ struct mlx5_bf *bf;
int uninitialized_var(size);
- void *qend = qp->sq.qend;
+ void *qend;
unsigned long flags;
unsigned idx;
int err = 0;
@@ -2486,6 +3803,12 @@ int mlx5_ib_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr,
u8 next_fence = 0;
u8 fence;
+ if (unlikely(ibqp->qp_type == IB_QPT_GSI))
+ return mlx5_ib_gsi_post_send(ibqp, wr, bad_wr);
+
+ qp = to_mqp(ibqp);
+ bf = qp->bf;
+ qend = qp->sq.qend;
spin_lock_irqsave(&qp->sq.lock, flags);
@@ -2498,7 +3821,7 @@ int mlx5_ib_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr,
for (nreq = 0; wr; nreq++, wr = wr->next) {
if (unlikely(wr->opcode < 0 || wr->opcode >= ARRAY_SIZE(mlx5_ib_opcode))) {
- mlx5_ib_warn(dev, "Invalid opcode 0x%x\n", wr->opcode);
+ mlx5_ib_warn(dev, "\n");
err = -EINVAL;
*bad_wr = wr;
goto out;
@@ -2507,15 +3830,15 @@ int mlx5_ib_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr,
fence = qp->fm_cache;
num_sge = wr->num_sge;
if (unlikely(num_sge > qp->sq.max_gs)) {
- mlx5_ib_warn(dev, "Max gs exceeded %d (max = %d)\n", wr->num_sge, qp->sq.max_gs);
- err = -ENOMEM;
+ mlx5_ib_warn(dev, "\n");
+ err = -EINVAL;
*bad_wr = wr;
goto out;
}
err = begin_wqe(qp, &seg, &ctrl, wr, &idx, &size, nreq);
if (err) {
- mlx5_ib_warn(dev, "Failed to prepare WQE\n");
+ mlx5_ib_warn(dev, "\n");
err = -ENOMEM;
*bad_wr = wr;
goto out;
@@ -2524,7 +3847,6 @@ int mlx5_ib_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr,
switch (ibqp->qp_type) {
case IB_QPT_XRC_INI:
xrc = seg;
- xrc->xrc_srqn = htonl(wr->xrc_remote_srq_num);
seg += sizeof(*xrc);
size += sizeof(*xrc) / 16;
/* fall through */
@@ -2533,8 +3855,8 @@ int mlx5_ib_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr,
case IB_WR_RDMA_READ:
case IB_WR_RDMA_WRITE:
case IB_WR_RDMA_WRITE_WITH_IMM:
- set_raddr_seg(seg, wr->wr.rdma.remote_addr,
- wr->wr.rdma.rkey);
+ set_raddr_seg(seg, rdma_wr(wr)->remote_addr,
+ rdma_wr(wr)->rkey);
seg += sizeof(struct mlx5_wqe_raddr_seg);
size += sizeof(struct mlx5_wqe_raddr_seg) / 16;
break;
@@ -2549,29 +3871,90 @@ int mlx5_ib_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr,
case IB_WR_LOCAL_INV:
next_fence = MLX5_FENCE_MODE_INITIATOR_SMALL;
- qp->sq.swr_ctx[idx].wr_data = IB_WR_LOCAL_INV;
+ qp->sq.wr_data[idx] = IB_WR_LOCAL_INV;
ctrl->imm = cpu_to_be32(wr->ex.invalidate_rkey);
- err = set_frwr_li_wr(&seg, wr, &size, mdev, to_mpd(ibqp->pd), qp);
+ set_linv_wr(qp, &seg, &size);
+ num_sge = 0;
+ break;
+
+ case IB_WR_REG_MR:
+ next_fence = MLX5_FENCE_MODE_INITIATOR_SMALL;
+ qp->sq.wr_data[idx] = IB_WR_REG_MR;
+ ctrl->imm = cpu_to_be32(reg_wr(wr)->key);
+ err = set_reg_wr(qp, reg_wr(wr), &seg, &size);
if (err) {
- mlx5_ib_warn(dev, "Failed to prepare LOCAL_INV WQE\n");
*bad_wr = wr;
goto out;
}
num_sge = 0;
break;
- case IB_WR_FAST_REG_MR:
+ case IB_WR_REG_SIG_MR:
+ qp->sq.wr_data[idx] = IB_WR_REG_SIG_MR;
+ mr = to_mmr(sig_handover_wr(wr)->sig_mr);
+
+ ctrl->imm = cpu_to_be32(mr->ibmr.rkey);
+ err = set_sig_umr_wr(wr, qp, &seg, &size);
+ if (err) {
+ mlx5_ib_warn(dev, "\n");
+ *bad_wr = wr;
+ goto out;
+ }
+
+ finish_wqe(qp, ctrl, size, idx, wr->wr_id,
+ nreq, get_fence(fence, wr),
+ next_fence, MLX5_OPCODE_UMR);
+ /*
+ * SET_PSV WQEs are not signaled and solicited
+ * on error
+ */
+ wr->send_flags &= ~IB_SEND_SIGNALED;
+ wr->send_flags |= IB_SEND_SOLICITED;
+ err = begin_wqe(qp, &seg, &ctrl, wr,
+ &idx, &size, nreq);
+ if (err) {
+ mlx5_ib_warn(dev, "\n");
+ err = -ENOMEM;
+ *bad_wr = wr;
+ goto out;
+ }
+
+ err = set_psv_wr(&sig_handover_wr(wr)->sig_attrs->mem,
+ mr->sig->psv_memory.psv_idx, &seg,
+ &size);
+ if (err) {
+ mlx5_ib_warn(dev, "\n");
+ *bad_wr = wr;
+ goto out;
+ }
+
+ finish_wqe(qp, ctrl, size, idx, wr->wr_id,
+ nreq, get_fence(fence, wr),
+ next_fence, MLX5_OPCODE_SET_PSV);
+ err = begin_wqe(qp, &seg, &ctrl, wr,
+ &idx, &size, nreq);
+ if (err) {
+ mlx5_ib_warn(dev, "\n");
+ err = -ENOMEM;
+ *bad_wr = wr;
+ goto out;
+ }
+
next_fence = MLX5_FENCE_MODE_INITIATOR_SMALL;
- qp->sq.swr_ctx[idx].wr_data = IB_WR_FAST_REG_MR;
- ctrl->imm = cpu_to_be32(wr->wr.fast_reg.rkey);
- err = set_frwr_li_wr(&seg, wr, &size, mdev, to_mpd(ibqp->pd), qp);
+ err = set_psv_wr(&sig_handover_wr(wr)->sig_attrs->wire,
+ mr->sig->psv_wire.psv_idx, &seg,
+ &size);
if (err) {
- mlx5_ib_warn(dev, "Failed to prepare FAST_REG_MR WQE\n");
+ mlx5_ib_warn(dev, "\n");
*bad_wr = wr;
goto out;
}
+
+ finish_wqe(qp, ctrl, size, idx, wr->wr_id,
+ nreq, get_fence(fence, wr),
+ next_fence, MLX5_OPCODE_SET_PSV);
num_sge = 0;
- break;
+ goto skip_psv;
default:
break;
@@ -2582,8 +3965,8 @@ int mlx5_ib_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr,
switch (wr->opcode) {
case IB_WR_RDMA_WRITE:
case IB_WR_RDMA_WRITE_WITH_IMM:
- set_raddr_seg(seg, wr->wr.rdma.remote_addr,
- wr->wr.rdma.rkey);
+ set_raddr_seg(seg, rdma_wr(wr)->remote_addr,
+ rdma_wr(wr)->rkey);
seg += sizeof(struct mlx5_wqe_raddr_seg);
size += sizeof(struct mlx5_wqe_raddr_seg) / 16;
break;
@@ -2594,20 +3977,56 @@ int mlx5_ib_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr,
break;
case IB_QPT_SMI:
- if (!mlx5_core_is_pf(mdev)) {
- err = -EINVAL;
- mlx5_ib_warn(dev, "Only physical function is allowed to send SMP MADs\n");
- *bad_wr = wr;
- goto out;
- }
- case IB_QPT_GSI:
+ case MLX5_IB_QPT_HW_GSI:
+ set_datagram_seg(seg, wr);
+ seg += sizeof(struct mlx5_wqe_datagram_seg);
+ size += sizeof(struct mlx5_wqe_datagram_seg) / 16;
+ if (unlikely((seg == qend)))
+ seg = mlx5_get_send_wqe(qp, 0);
+ break;
case IB_QPT_UD:
set_datagram_seg(seg, wr);
seg += sizeof(struct mlx5_wqe_datagram_seg);
size += sizeof(struct mlx5_wqe_datagram_seg) / 16;
+
+ if (unlikely((seg == qend)))
+ seg = mlx5_get_send_wqe(qp, 0);
+
+ /* handle qp that supports ud offload */
+ if (qp->flags & IB_QP_CREATE_IPOIB_UD_LSO) {
+ struct mlx5_wqe_eth_pad *pad;
+
+ pad = seg;
+ memset(pad, 0, sizeof(struct mlx5_wqe_eth_pad));
+ seg += sizeof(struct mlx5_wqe_eth_pad);
+ size += sizeof(struct mlx5_wqe_eth_pad) / 16;
+
+ seg = set_eth_seg(seg, wr, qend, qp, &size);
+
+ if (unlikely((seg == qend)))
+ seg = mlx5_get_send_wqe(qp, 0);
+ }
+ break;
+ case MLX5_IB_QPT_REG_UMR:
+ if (wr->opcode != MLX5_IB_WR_UMR) {
+ err = -EINVAL;
+ mlx5_ib_warn(dev, "bad opcode\n");
+ goto out;
+ }
+ qp->sq.wr_data[idx] = MLX5_IB_WR_UMR;
+ ctrl->imm = cpu_to_be32(umr_wr(wr)->mkey);
+ set_reg_umr_segment(seg, wr);
+ seg += sizeof(struct mlx5_wqe_umr_ctrl_seg);
+ size += sizeof(struct mlx5_wqe_umr_ctrl_seg) / 16;
+ if (unlikely((seg == qend)))
+ seg = mlx5_get_send_wqe(qp, 0);
+ set_reg_mkey_segment(seg, wr);
+ seg += sizeof(struct mlx5_mkey_seg);
+ size += sizeof(struct mlx5_mkey_seg) / 16;
if (unlikely((seg == qend)))
seg = mlx5_get_send_wqe(qp, 0);
break;
+
default:
break;
}
@@ -2617,7 +4036,7 @@ int mlx5_ib_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr,
err = set_data_inl_seg(qp, wr, seg, &sz);
if (unlikely(err)) {
- mlx5_ib_warn(dev, "Failed to prepare inline data segment\n");
+ mlx5_ib_warn(dev, "\n");
*bad_wr = wr;
goto out;
}
@@ -2638,9 +4057,10 @@ int mlx5_ib_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr,
}
}
- finish_wqe(qp, ctrl, size, idx, wr, nreq,
+ finish_wqe(qp, ctrl, size, idx, wr->wr_id, nreq,
get_fence(fence, wr), next_fence,
mlx5_ib_opcode[wr->opcode]);
+skip_psv:
if (0)
dump_wqe(qp, idx, size);
}
@@ -2666,8 +4086,7 @@ out:
__acquire(&bf->lock);
/* TBD enable WC */
- if (BF_ENABLE && nreq == 1 && bf->uuarn && inl && size > 1 &&
- size <= bf->buf_size / 16) {
+ if (0 && nreq == 1 && bf->uuarn && inl && size > 1 && size <= bf->buf_size / 16) {
mlx5_bf_copy(bf->reg + bf->offset, (u64 *)ctrl, ALIGN(size * 16, 64), qp);
/* wc_wmb(); */
} else {
@@ -2709,6 +4128,9 @@ int mlx5_ib_post_recv(struct ib_qp *ibqp, struct ib_recv_wr *wr,
int ind;
int i;
+ if (unlikely(ibqp->qp_type == IB_QPT_GSI))
+ return mlx5_ib_gsi_post_recv(ibqp, wr, bad_wr);
+
spin_lock_irqsave(&qp->rq.lock, flags);
if (mdev->state == MLX5_DEVICE_STATE_INTERNAL_ERROR) {
@@ -2751,7 +4173,7 @@ int mlx5_ib_post_recv(struct ib_qp *ibqp, struct ib_recv_wr *wr,
set_sig_seg(sig, (qp->rq.max_gs + 1) << 2);
}
- qp->rq.rwr_ctx[ind].wrid = wr->wr_id;
+ qp->rq.wrid[ind] = wr->wr_id;
ind = (ind + 1) & (qp->rq.wqe_cnt - 1);
}
@@ -2842,74 +4264,232 @@ static void to_ib_ah_attr(struct mlx5_ib_dev *ibdev, struct ib_ah_attr *ib_ah_at
}
}
-int mlx5_ib_query_qp(struct ib_qp *ibqp, struct ib_qp_attr *qp_attr, int qp_attr_mask,
- struct ib_qp_init_attr *qp_init_attr)
+static int query_raw_packet_qp_sq_state(struct mlx5_ib_dev *dev,
+ struct mlx5_ib_sq *sq,
+ u8 *sq_state)
{
- struct mlx5_ib_dev *dev = to_mdev(ibqp->device);
- struct mlx5_ib_qp *qp = to_mqp(ibqp);
- struct mlx5_query_qp_mbox_out *outb;
+ void *out;
+ void *sqc;
+ int inlen;
+ int err;
+
+ inlen = MLX5_ST_SZ_BYTES(query_sq_out);
+ out = mlx5_vzalloc(inlen);
+ if (!out)
+ return -ENOMEM;
+
+ err = mlx5_core_query_sq(dev->mdev, sq->base.mqp.qpn, out);
+ if (err)
+ goto out;
+
+ sqc = MLX5_ADDR_OF(query_sq_out, out, sq_context);
+ *sq_state = MLX5_GET(sqc, sqc, state);
+ sq->state = *sq_state;
+
+out:
+ kvfree(out);
+ return err;
+}
+
+static int query_raw_packet_qp_rq_state(struct mlx5_ib_dev *dev,
+ struct mlx5_ib_rq *rq,
+ u8 *rq_state)
+{
+ void *out;
+ void *rqc;
+ int inlen;
+ int err;
+
+ inlen = MLX5_ST_SZ_BYTES(query_rq_out);
+ out = mlx5_vzalloc(inlen);
+ if (!out)
+ return -ENOMEM;
+
+ err = mlx5_core_query_rq(dev->mdev, rq->base.mqp.qpn, out);
+ if (err)
+ goto out;
+
+ rqc = MLX5_ADDR_OF(query_rq_out, out, rq_context);
+ *rq_state = MLX5_GET(rqc, rqc, state);
+ rq->state = *rq_state;
+
+out:
+ kvfree(out);
+ return err;
+}
+
+static int sqrq_state_to_qp_state(u8 sq_state, u8 rq_state,
+ struct mlx5_ib_qp *qp, u8 *qp_state)
+{
+ static const u8 sqrq_trans[MLX5_RQ_NUM_STATE][MLX5_SQ_NUM_STATE] = {
+ [MLX5_RQC_STATE_RST] = {
+ [MLX5_SQC_STATE_RST] = IB_QPS_RESET,
+ [MLX5_SQC_STATE_RDY] = MLX5_QP_STATE_BAD,
+ [MLX5_SQC_STATE_ERR] = MLX5_QP_STATE_BAD,
+ [MLX5_SQ_STATE_NA] = IB_QPS_RESET,
+ },
+ [MLX5_RQC_STATE_RDY] = {
+ [MLX5_SQC_STATE_RST] = MLX5_QP_STATE_BAD,
+ [MLX5_SQC_STATE_RDY] = MLX5_QP_STATE,
+ [MLX5_SQC_STATE_ERR] = IB_QPS_SQE,
+ [MLX5_SQ_STATE_NA] = MLX5_QP_STATE,
+ },
+ [MLX5_RQC_STATE_ERR] = {
+ [MLX5_SQC_STATE_RST] = MLX5_QP_STATE_BAD,
+ [MLX5_SQC_STATE_RDY] = MLX5_QP_STATE_BAD,
+ [MLX5_SQC_STATE_ERR] = IB_QPS_ERR,
+ [MLX5_SQ_STATE_NA] = IB_QPS_ERR,
+ },
+ [MLX5_RQ_STATE_NA] = {
+ [MLX5_SQC_STATE_RST] = IB_QPS_RESET,
+ [MLX5_SQC_STATE_RDY] = MLX5_QP_STATE,
+ [MLX5_SQC_STATE_ERR] = MLX5_QP_STATE,
+ [MLX5_SQ_STATE_NA] = MLX5_QP_STATE_BAD,
+ },
+ };
+
+ *qp_state = sqrq_trans[rq_state][sq_state];
+
+ if (*qp_state == MLX5_QP_STATE_BAD) {
+ WARN(1, "Buggy Raw Packet QP state, SQ 0x%x state: 0x%x, RQ 0x%x state: 0x%x",
+ qp->raw_packet_qp.sq.base.mqp.qpn, sq_state,
+ qp->raw_packet_qp.rq.base.mqp.qpn, rq_state);
+ return -EINVAL;
+ }
+
+ if (*qp_state == MLX5_QP_STATE)
+ *qp_state = qp->state;
+
+ return 0;
+}
+
+static int query_raw_packet_qp_state(struct mlx5_ib_dev *dev,
+ struct mlx5_ib_qp *qp,
+ u8 *raw_packet_qp_state)
+{
+ struct mlx5_ib_raw_packet_qp *raw_packet_qp = &qp->raw_packet_qp;
+ struct mlx5_ib_sq *sq = &raw_packet_qp->sq;
+ struct mlx5_ib_rq *rq = &raw_packet_qp->rq;
+ int err;
+ u8 sq_state = MLX5_SQ_STATE_NA;
+ u8 rq_state = MLX5_RQ_STATE_NA;
+
+ if (qp->sq.wqe_cnt) {
+ err = query_raw_packet_qp_sq_state(dev, sq, &sq_state);
+ if (err)
+ return err;
+ }
+
+ if (qp->rq.wqe_cnt) {
+ err = query_raw_packet_qp_rq_state(dev, rq, &rq_state);
+ if (err)
+ return err;
+ }
+
+ return sqrq_state_to_qp_state(sq_state, rq_state, qp,
+ raw_packet_qp_state);
+}
+
+static int query_qp_attr(struct mlx5_ib_dev *dev, struct mlx5_ib_qp *qp,
+ struct ib_qp_attr *qp_attr)
+{
+ int outlen = MLX5_ST_SZ_BYTES(query_qp_out);
struct mlx5_qp_context *context;
int mlx5_state;
+ u32 *outb;
int err = 0;
- mutex_lock(&qp->mutex);
- if (qp->ibqp.qp_type == IB_QPT_RAW_PACKET) {
- err = -EOPNOTSUPP;
+ outb = kzalloc(outlen, GFP_KERNEL);
+ if (!outb)
+ return -ENOMEM;
+
+ err = mlx5_core_qp_query(dev->mdev, &qp->trans_qp.base.mqp,
+ (struct mlx5_query_qp_mbox_out *)outb,
+ outlen);
+ if (err)
goto out;
- } else {
- outb = kzalloc(sizeof(*outb), GFP_KERNEL);
- if (!outb) {
- err = -ENOMEM;
- goto out;
- }
- context = &outb->ctx;
- err = mlx5_core_qp_query(dev->mdev, &qp->mqp, outb,
- sizeof(*outb));
- if (err) {
- kfree(outb);
- goto out;
- }
+ /* FIXME: use MLX5_GET rather than mlx5_qp_context manual struct */
+ context = (struct mlx5_qp_context *)MLX5_ADDR_OF(query_qp_out, outb, qpc);
+
+ mlx5_state = be32_to_cpu(context->flags) >> 28;
+
+ qp->state = to_ib_qp_state(mlx5_state);
+ qp_attr->path_mtu = context->mtu_msgmax >> 5;
+ qp_attr->path_mig_state =
+ to_ib_mig_state((be32_to_cpu(context->flags) >> 11) & 0x3);
+ qp_attr->qkey = be32_to_cpu(context->qkey);
+ qp_attr->rq_psn = be32_to_cpu(context->rnr_nextrecvpsn) & 0xffffff;
+ qp_attr->sq_psn = be32_to_cpu(context->next_send_psn) & 0xffffff;
+ qp_attr->dest_qp_num = be32_to_cpu(context->log_pg_sz_remote_qpn) & 0xffffff;
+ qp_attr->qp_access_flags =
+ to_ib_qp_access_flags(be32_to_cpu(context->params2));
+
+ if (qp->ibqp.qp_type == IB_QPT_RC || qp->ibqp.qp_type == IB_QPT_UC) {
+ to_ib_ah_attr(dev, &qp_attr->ah_attr, &context->pri_path);
+ to_ib_ah_attr(dev, &qp_attr->alt_ah_attr, &context->alt_path);
+ qp_attr->alt_pkey_index =
+ be16_to_cpu(context->alt_path.pkey_index);
+ qp_attr->alt_port_num = qp_attr->alt_ah_attr.port_num;
+ }
- mlx5_state = be32_to_cpu(context->flags) >> 28;
-
- qp->state = to_ib_qp_state(mlx5_state);
- qp_attr->path_mtu = context->mtu_msgmax >> 5;
- qp_attr->path_mig_state =
- to_ib_mig_state((be32_to_cpu(context->flags) >> 11) & 0x3);
- qp_attr->qkey = be32_to_cpu(context->qkey);
- qp_attr->rq_psn = be32_to_cpu(context->rnr_nextrecvpsn) & 0xffffff;
- qp_attr->sq_psn = be32_to_cpu(context->next_send_psn) & 0xffffff;
- qp_attr->dest_qp_num = be32_to_cpu(context->log_pg_sz_remote_qpn) & 0xffffff;
- qp_attr->qp_access_flags =
- to_ib_qp_access_flags(be32_to_cpu(context->params2));
-
- if (qp->ibqp.qp_type == IB_QPT_RC || qp->ibqp.qp_type == IB_QPT_UC) {
- to_ib_ah_attr(dev, &qp_attr->ah_attr, &context->pri_path);
- to_ib_ah_attr(dev, &qp_attr->alt_ah_attr, &context->alt_path);
- qp_attr->alt_pkey_index = be16_to_cpu(context->alt_path.pkey_index);
- qp_attr->alt_port_num = qp_attr->alt_ah_attr.port_num;
- }
+ qp_attr->pkey_index = be16_to_cpu(context->pri_path.pkey_index);
+ qp_attr->port_num = context->pri_path.port;
+
+ /* qp_attr->en_sqd_async_notify is only applicable in modify qp */
+ qp_attr->sq_draining = mlx5_state == MLX5_QP_STATE_SQ_DRAINING;
+
+ qp_attr->max_rd_atomic = 1 << ((be32_to_cpu(context->params1) >> 21) & 0x7);
+
+ qp_attr->max_dest_rd_atomic =
+ 1 << ((be32_to_cpu(context->params2) >> 21) & 0x7);
+ qp_attr->min_rnr_timer =
+ (be32_to_cpu(context->rnr_nextrecvpsn) >> 24) & 0x1f;
+ qp_attr->timeout = context->pri_path.ackto_lt >> 3;
+ qp_attr->retry_cnt = (be32_to_cpu(context->params1) >> 16) & 0x7;
+ qp_attr->rnr_retry = (be32_to_cpu(context->params1) >> 13) & 0x7;
+ qp_attr->alt_timeout = context->alt_path.ackto_lt >> 3;
+
+out:
+ kfree(outb);
+ return err;
+}
- qp_attr->pkey_index = be16_to_cpu(context->pri_path.pkey_index);
- qp_attr->port_num = context->pri_path.port;
+int mlx5_ib_query_qp(struct ib_qp *ibqp, struct ib_qp_attr *qp_attr,
+ int qp_attr_mask, struct ib_qp_init_attr *qp_init_attr)
+{
+ struct mlx5_ib_dev *dev = to_mdev(ibqp->device);
+ struct mlx5_ib_qp *qp = to_mqp(ibqp);
+ int err = 0;
+ u8 raw_packet_qp_state;
- /* qp_attr->en_sqd_async_notify is only applicable in modify qp */
- qp_attr->sq_draining = mlx5_state == MLX5_QP_STATE_SQ_DRAINING;
+ if (ibqp->rwq_ind_tbl)
+ return -ENOSYS;
- qp_attr->max_rd_atomic = 1 << ((be32_to_cpu(context->params1) >> 21) & 0x7);
+ if (unlikely(ibqp->qp_type == IB_QPT_GSI))
+ return mlx5_ib_gsi_query_qp(ibqp, qp_attr, qp_attr_mask,
+ qp_init_attr);
- qp_attr->max_dest_rd_atomic =
- 1 << ((be32_to_cpu(context->params2) >> 21) & 0x7);
- qp_attr->min_rnr_timer =
- (be32_to_cpu(context->rnr_nextrecvpsn) >> 24) & 0x1f;
- qp_attr->timeout = context->pri_path.ackto_lt >> 3;
- qp_attr->retry_cnt = (be32_to_cpu(context->params1) >> 16) & 0x7;
- qp_attr->rnr_retry = (be32_to_cpu(context->params1) >> 13) & 0x7;
- qp_attr->alt_timeout = context->alt_path.ackto_lt >> 3;
+#ifdef CONFIG_INFINIBAND_ON_DEMAND_PAGING
+ /*
+ * Wait for any outstanding page faults, in case the user frees memory
+ * based upon this query's result.
+ */
+ flush_workqueue(mlx5_ib_page_fault_wq);
+#endif
+ mutex_lock(&qp->mutex);
- kfree(outb);
+ if (qp->ibqp.qp_type == IB_QPT_RAW_PACKET) {
+ err = query_raw_packet_qp_state(dev, qp, &raw_packet_qp_state);
+ if (err)
+ goto out;
+ qp->state = raw_packet_qp_state;
+ qp_attr->port_num = 1;
+ } else {
+ err = query_qp_attr(dev, qp, qp_attr);
+ if (err)
+ goto out;
}
qp_attr->qp_state = qp->state;
@@ -2938,6 +4518,15 @@ int mlx5_ib_query_qp(struct ib_qp *ibqp, struct ib_qp_attr *qp_attr, int qp_attr
if (qp->flags & MLX5_IB_QP_BLOCK_MULTICAST_LOOPBACK)
qp_init_attr->create_flags |= IB_QP_CREATE_BLOCK_MULTICAST_LOOPBACK;
+ if (qp->flags & MLX5_IB_QP_CROSS_CHANNEL)
+ qp_init_attr->create_flags |= IB_QP_CREATE_CROSS_CHANNEL;
+ if (qp->flags & MLX5_IB_QP_MANAGED_SEND)
+ qp_init_attr->create_flags |= IB_QP_CREATE_MANAGED_SEND;
+ if (qp->flags & MLX5_IB_QP_MANAGED_RECV)
+ qp_init_attr->create_flags |= IB_QP_CREATE_MANAGED_RECV;
+ if (qp->flags & MLX5_IB_QP_SQPN_QP1)
+ qp_init_attr->create_flags |= mlx5_ib_create_qp_sqpn_qp1();
+
qp_init_attr->sq_sig_type = qp->sq_signal_bits & MLX5_WQE_CTRL_CQ_UPDATE ?
IB_SIGNAL_ALL_WR : IB_SIGNAL_REQ_WR;
@@ -2986,3 +4575,355 @@ int mlx5_ib_dealloc_xrcd(struct ib_xrcd *xrcd)
return 0;
}
+
+static void mlx5_ib_wq_event(struct mlx5_core_qp *core_qp, int type)
+{
+ struct mlx5_ib_rwq *rwq = to_mibrwq(core_qp);
+ struct mlx5_ib_dev *dev = to_mdev(rwq->ibwq.device);
+ struct ib_event event;
+
+ if (rwq->ibwq.event_handler) {
+ event.device = rwq->ibwq.device;
+ event.element.wq = &rwq->ibwq;
+ switch (type) {
+ case MLX5_EVENT_TYPE_WQ_CATAS_ERROR:
+ event.event = IB_EVENT_WQ_FATAL;
+ break;
+ default:
+ mlx5_ib_warn(dev, "Unexpected event type %d on WQ %06x\n", type, core_qp->qpn);
+ return;
+ }
+
+ rwq->ibwq.event_handler(&event, rwq->ibwq.wq_context);
+ }
+}
+
+static int create_rq(struct mlx5_ib_rwq *rwq, struct ib_pd *pd,
+ struct ib_wq_init_attr *init_attr)
+{
+ struct mlx5_ib_dev *dev;
+ __be64 *rq_pas0;
+ void *in;
+ void *rqc;
+ void *wq;
+ int inlen;
+ int err;
+
+ dev = to_mdev(pd->device);
+
+ inlen = MLX5_ST_SZ_BYTES(create_rq_in) + sizeof(u64) * rwq->rq_num_pas;
+ in = mlx5_vzalloc(inlen);
+ if (!in)
+ return -ENOMEM;
+
+ rqc = MLX5_ADDR_OF(create_rq_in, in, ctx);
+ MLX5_SET(rqc, rqc, mem_rq_type,
+ MLX5_RQC_RQ_TYPE_MEMORY_RQ_INLINE);
+ MLX5_SET(rqc, rqc, user_index, rwq->user_index);
+ MLX5_SET(rqc, rqc, cqn, to_mcq(init_attr->cq)->mcq.cqn);
+ MLX5_SET(rqc, rqc, state, MLX5_RQC_STATE_RST);
+ MLX5_SET(rqc, rqc, flush_in_error_en, 1);
+ wq = MLX5_ADDR_OF(rqc, rqc, wq);
+ MLX5_SET(wq, wq, wq_type, MLX5_WQ_TYPE_CYCLIC);
+ MLX5_SET(wq, wq, end_padding_mode, MLX5_WQ_END_PAD_MODE_ALIGN);
+ MLX5_SET(wq, wq, log_wq_stride, rwq->log_rq_stride);
+ MLX5_SET(wq, wq, log_wq_sz, rwq->log_rq_size);
+ MLX5_SET(wq, wq, pd, to_mpd(pd)->pdn);
+ MLX5_SET(wq, wq, page_offset, rwq->rq_page_offset);
+ MLX5_SET(wq, wq, log_wq_pg_sz, rwq->log_page_size);
+ MLX5_SET(wq, wq, wq_signature, rwq->wq_sig);
+ MLX5_SET64(wq, wq, dbr_addr, rwq->db.dma);
+ rq_pas0 = (__be64 *)MLX5_ADDR_OF(wq, wq, pas);
+ mlx5_ib_populate_pas(dev, rwq->umem, rwq->page_shift, rq_pas0, 0);
+ err = mlx5_core_create_rq_tracked(dev->mdev, in, inlen, &rwq->core_qp);
+ kvfree(in);
+ return err;
+}
+
+static int set_user_rq_size(struct mlx5_ib_dev *dev,
+ struct ib_wq_init_attr *wq_init_attr,
+ struct mlx5_ib_create_wq *ucmd,
+ struct mlx5_ib_rwq *rwq)
+{
+ /* Sanity check RQ size before proceeding */
+ if (wq_init_attr->max_wr > (1 << MLX5_CAP_GEN(dev->mdev, log_max_wq_sz)))
+ return -EINVAL;
+
+ if (!ucmd->rq_wqe_count)
+ return -EINVAL;
+
+ rwq->wqe_count = ucmd->rq_wqe_count;
+ rwq->wqe_shift = ucmd->rq_wqe_shift;
+ rwq->buf_size = (rwq->wqe_count << rwq->wqe_shift);
+ rwq->log_rq_stride = rwq->wqe_shift;
+ rwq->log_rq_size = ilog2(rwq->wqe_count);
+ return 0;
+}
+
+static int prepare_user_rq(struct ib_pd *pd,
+ struct ib_wq_init_attr *init_attr,
+ struct ib_udata *udata,
+ struct mlx5_ib_rwq *rwq)
+{
+ struct mlx5_ib_dev *dev = to_mdev(pd->device);
+ struct mlx5_ib_create_wq ucmd = {};
+ int err;
+ size_t required_cmd_sz;
+
+ required_cmd_sz = offsetof(typeof(ucmd), reserved) + sizeof(ucmd.reserved);
+ if (udata->inlen < required_cmd_sz) {
+ mlx5_ib_dbg(dev, "invalid inlen\n");
+ return -EINVAL;
+ }
+
+ if (udata->inlen > sizeof(ucmd) &&
+ !ib_is_udata_cleared(udata, sizeof(ucmd),
+ udata->inlen - sizeof(ucmd))) {
+ mlx5_ib_dbg(dev, "inlen is not supported\n");
+ return -EOPNOTSUPP;
+ }
+
+ if (ib_copy_from_udata(&ucmd, udata, min(sizeof(ucmd), udata->inlen))) {
+ mlx5_ib_dbg(dev, "copy failed\n");
+ return -EFAULT;
+ }
+
+ if (ucmd.comp_mask) {
+ mlx5_ib_dbg(dev, "invalid comp mask\n");
+ return -EOPNOTSUPP;
+ }
+
+ if (ucmd.reserved) {
+ mlx5_ib_dbg(dev, "invalid reserved\n");
+ return -EOPNOTSUPP;
+ }
+
+ err = set_user_rq_size(dev, init_attr, &ucmd, rwq);
+ if (err) {
+ mlx5_ib_dbg(dev, "err %d\n", err);
+ return err;
+ }
+
+ err = create_user_rq(dev, pd, rwq, &ucmd);
+ if (err) {
+ mlx5_ib_dbg(dev, "err %d\n", err);
+ if (err)
+ return err;
+ }
+
+ rwq->user_index = ucmd.user_index;
+ return 0;
+}
+
+struct ib_wq *mlx5_ib_create_wq(struct ib_pd *pd,
+ struct ib_wq_init_attr *init_attr,
+ struct ib_udata *udata)
+{
+ struct mlx5_ib_dev *dev;
+ struct mlx5_ib_rwq *rwq;
+ struct mlx5_ib_create_wq_resp resp = {};
+ size_t min_resp_len;
+ int err;
+
+ if (!udata)
+ return ERR_PTR(-ENOSYS);
+
+ min_resp_len = offsetof(typeof(resp), reserved) + sizeof(resp.reserved);
+ if (udata->outlen && udata->outlen < min_resp_len)
+ return ERR_PTR(-EINVAL);
+
+ dev = to_mdev(pd->device);
+ switch (init_attr->wq_type) {
+ case IB_WQT_RQ:
+ rwq = kzalloc(sizeof(*rwq), GFP_KERNEL);
+ if (!rwq)
+ return ERR_PTR(-ENOMEM);
+ err = prepare_user_rq(pd, init_attr, udata, rwq);
+ if (err)
+ goto err;
+ err = create_rq(rwq, pd, init_attr);
+ if (err)
+ goto err_user_rq;
+ break;
+ default:
+ mlx5_ib_dbg(dev, "unsupported wq type %d\n",
+ init_attr->wq_type);
+ return ERR_PTR(-EINVAL);
+ }
+
+ rwq->ibwq.wq_num = rwq->core_qp.qpn;
+ rwq->ibwq.state = IB_WQS_RESET;
+ if (udata->outlen) {
+ resp.response_length = offsetof(typeof(resp), response_length) +
+ sizeof(resp.response_length);
+ err = ib_copy_to_udata(udata, &resp, resp.response_length);
+ if (err)
+ goto err_copy;
+ }
+
+ rwq->core_qp.event = mlx5_ib_wq_event;
+ rwq->ibwq.event_handler = init_attr->event_handler;
+ return &rwq->ibwq;
+
+err_copy:
+ mlx5_core_destroy_rq_tracked(dev->mdev, &rwq->core_qp);
+err_user_rq:
+ destroy_user_rq(pd, rwq);
+err:
+ kfree(rwq);
+ return ERR_PTR(err);
+}
+
+int mlx5_ib_destroy_wq(struct ib_wq *wq)
+{
+ struct mlx5_ib_dev *dev = to_mdev(wq->device);
+ struct mlx5_ib_rwq *rwq = to_mrwq(wq);
+
+ mlx5_core_destroy_rq_tracked(dev->mdev, &rwq->core_qp);
+ destroy_user_rq(wq->pd, rwq);
+ kfree(rwq);
+
+ return 0;
+}
+
+struct ib_rwq_ind_table *mlx5_ib_create_rwq_ind_table(struct ib_device *device,
+ struct ib_rwq_ind_table_init_attr *init_attr,
+ struct ib_udata *udata)
+{
+ struct mlx5_ib_dev *dev = to_mdev(device);
+ struct mlx5_ib_rwq_ind_table *rwq_ind_tbl;
+ int sz = 1 << init_attr->log_ind_tbl_size;
+ struct mlx5_ib_create_rwq_ind_tbl_resp resp = {};
+ size_t min_resp_len;
+ int inlen;
+ int err;
+ int i;
+ u32 *in;
+ void *rqtc;
+
+ if (udata->inlen > 0 &&
+ !ib_is_udata_cleared(udata, 0,
+ udata->inlen))
+ return ERR_PTR(-EOPNOTSUPP);
+
+ if (init_attr->log_ind_tbl_size >
+ MLX5_CAP_GEN(dev->mdev, log_max_rqt_size)) {
+ mlx5_ib_dbg(dev, "log_ind_tbl_size = %d is bigger than supported = %d\n",
+ init_attr->log_ind_tbl_size,
+ MLX5_CAP_GEN(dev->mdev, log_max_rqt_size));
+ return ERR_PTR(-EINVAL);
+ }
+
+ min_resp_len = offsetof(typeof(resp), reserved) + sizeof(resp.reserved);
+ if (udata->outlen && udata->outlen < min_resp_len)
+ return ERR_PTR(-EINVAL);
+
+ rwq_ind_tbl = kzalloc(sizeof(*rwq_ind_tbl), GFP_KERNEL);
+ if (!rwq_ind_tbl)
+ return ERR_PTR(-ENOMEM);
+
+ inlen = MLX5_ST_SZ_BYTES(create_rqt_in) + sizeof(u32) * sz;
+ in = mlx5_vzalloc(inlen);
+ if (!in) {
+ err = -ENOMEM;
+ goto err;
+ }
+
+ rqtc = MLX5_ADDR_OF(create_rqt_in, in, rqt_context);
+
+ MLX5_SET(rqtc, rqtc, rqt_actual_size, sz);
+ MLX5_SET(rqtc, rqtc, rqt_max_size, sz);
+
+ for (i = 0; i < sz; i++)
+ MLX5_SET(rqtc, rqtc, rq_num[i], init_attr->ind_tbl[i]->wq_num);
+
+ err = mlx5_core_create_rqt(dev->mdev, in, inlen, &rwq_ind_tbl->rqtn);
+ kvfree(in);
+
+ if (err)
+ goto err;
+
+ rwq_ind_tbl->ib_rwq_ind_tbl.ind_tbl_num = rwq_ind_tbl->rqtn;
+ if (udata->outlen) {
+ resp.response_length = offsetof(typeof(resp), response_length) +
+ sizeof(resp.response_length);
+ err = ib_copy_to_udata(udata, &resp, resp.response_length);
+ if (err)
+ goto err_copy;
+ }
+
+ return &rwq_ind_tbl->ib_rwq_ind_tbl;
+
+err_copy:
+ mlx5_core_destroy_rqt(dev->mdev, rwq_ind_tbl->rqtn);
+err:
+ kfree(rwq_ind_tbl);
+ return ERR_PTR(err);
+}
+
+int mlx5_ib_destroy_rwq_ind_table(struct ib_rwq_ind_table *ib_rwq_ind_tbl)
+{
+ struct mlx5_ib_rwq_ind_table *rwq_ind_tbl = to_mrwq_ind_table(ib_rwq_ind_tbl);
+ struct mlx5_ib_dev *dev = to_mdev(ib_rwq_ind_tbl->device);
+
+ mlx5_core_destroy_rqt(dev->mdev, rwq_ind_tbl->rqtn);
+
+ kfree(rwq_ind_tbl);
+ return 0;
+}
+
+int mlx5_ib_modify_wq(struct ib_wq *wq, struct ib_wq_attr *wq_attr,
+ u32 wq_attr_mask, struct ib_udata *udata)
+{
+ struct mlx5_ib_dev *dev = to_mdev(wq->device);
+ struct mlx5_ib_rwq *rwq = to_mrwq(wq);
+ struct mlx5_ib_modify_wq ucmd = {};
+ size_t required_cmd_sz;
+ int curr_wq_state;
+ int wq_state;
+ int inlen;
+ int err;
+ void *rqc;
+ void *in;
+
+ required_cmd_sz = offsetof(typeof(ucmd), reserved) + sizeof(ucmd.reserved);
+ if (udata->inlen < required_cmd_sz)
+ return -EINVAL;
+
+ if (udata->inlen > sizeof(ucmd) &&
+ !ib_is_udata_cleared(udata, sizeof(ucmd),
+ udata->inlen - sizeof(ucmd)))
+ return -EOPNOTSUPP;
+
+ if (ib_copy_from_udata(&ucmd, udata, min(sizeof(ucmd), udata->inlen)))
+ return -EFAULT;
+
+ if (ucmd.comp_mask || ucmd.reserved)
+ return -EOPNOTSUPP;
+
+ inlen = MLX5_ST_SZ_BYTES(modify_rq_in);
+ in = mlx5_vzalloc(inlen);
+ if (!in)
+ return -ENOMEM;
+
+ rqc = MLX5_ADDR_OF(modify_rq_in, in, ctx);
+
+ MLX5_SET(modify_rq_in, in, rqn, rwq->core_qp.qpn);
+ curr_wq_state = (wq_attr_mask & IB_WQ_CUR_STATE) ?
+ wq_attr->curr_wq_state : wq->state;
+ wq_state = (wq_attr_mask & IB_WQ_STATE) ?
+ wq_attr->wq_state : curr_wq_state;
+ if (curr_wq_state == IB_WQS_ERR)
+ curr_wq_state = MLX5_RQC_STATE_ERR;
+ if (wq_state == IB_WQS_ERR)
+ wq_state = MLX5_RQC_STATE_ERR;
+ MLX5_SET(modify_rq_in, in, rq_state, curr_wq_state);
+ MLX5_SET(rqc, rqc, state, wq_state);
+
+ err = mlx5_core_modify_rq(dev->mdev, in, inlen);
+ kvfree(in);
+ if (!err)
+ rwq->ibwq.state = (wq_state == MLX5_RQC_STATE_ERR) ? IB_WQS_ERR : wq_state;
+
+ return err;
+}
diff --git a/sys/dev/mlx5/mlx5_ib/mlx5_ib_roce.c b/sys/dev/mlx5/mlx5_ib/mlx5_ib_roce.c
deleted file mode 100644
index f7b17c5..0000000
--- a/sys/dev/mlx5/mlx5_ib/mlx5_ib_roce.c
+++ /dev/null
@@ -1,252 +0,0 @@
-/*-
- * Copyright (c) 2013-2015, Mellanox Technologies, Ltd. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS `AS IS' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * $FreeBSD$
- */
-
-#include <linux/etherdevice.h>
-#include <linux/netdevice.h>
-#include <linux/inetdevice.h>
-#include <dev/mlx5/vport.h>
-#include <net/ipv6.h>
-#include <rdma/ib_addr.h>
-#include <rdma/ib_cache.h>
-#include "mlx5_ib.h"
-
-struct net_device *mlx5_ib_get_netdev(struct ib_device *ib_dev, u8 port)
-{
- struct mlx5_ib_dev *dev = to_mdev(ib_dev);
-
- return mlx5_get_protocol_dev(dev->mdev, MLX5_INTERFACE_PROTOCOL_ETH);
-}
-
-
-static void ib_gid_to_mlx5_roce_addr(const union ib_gid *gid,
- struct net_device *ndev,
- void *mlx5_addr)
-{
-#define MLX5_SET_RA(p, f, v) MLX5_SET(roce_addr_layout, p, f, v)
- char *mlx5_addr_l3_addr = MLX5_ADDR_OF(roce_addr_layout, mlx5_addr,
- source_l3_address);
- void *mlx5_addr_mac = MLX5_ADDR_OF(roce_addr_layout, mlx5_addr,
- source_mac_47_32);
- union ib_gid zgid;
- u16 vtag;
-
- memset(&zgid, 0, sizeof(zgid));
- if (0 == memcmp(gid, &zgid, sizeof(zgid)))
- return;
-
- ether_addr_copy(mlx5_addr_mac, IF_LLADDR(ndev));
-
- if (VLAN_TAG(ndev, &vtag) == 0) {
- MLX5_SET_RA(mlx5_addr, vlan_valid, 1);
- MLX5_SET_RA(mlx5_addr, vlan_id, vtag);
- }
-
-#ifndef MLX5_USE_ROCE_VERSION_2
- MLX5_SET_RA(mlx5_addr, roce_version, MLX5_ROCE_VERSION_1);
-
- memcpy(mlx5_addr_l3_addr, gid, sizeof(*gid));
-#else
- MLX5_SET_RA(mlx5_addr, roce_version, MLX5_ROCE_VERSION_2);
-
- if (ipv6_addr_v4mapped((void *)gid)) {
- MLX5_SET_RA(mlx5_addr, roce_l3_type,
- MLX5_ROCE_L3_TYPE_IPV4);
- memcpy(&mlx5_addr_l3_addr[12], &gid->raw[12], 4);
- } else {
- MLX5_SET_RA(mlx5_addr, roce_l3_type,
- MLX5_ROCE_L3_TYPE_IPV6);
- memcpy(mlx5_addr_l3_addr, gid, sizeof(*gid));
- }
-#endif
-}
-
-int modify_gid_roce(struct ib_device *ib_dev, u8 port, unsigned int index,
- const union ib_gid *gid, struct net_device *ndev)
-{
- struct mlx5_ib_dev *dev = to_mdev(ib_dev);
- u32 in[MLX5_ST_SZ_DW(set_roce_address_in)];
- u32 out[MLX5_ST_SZ_DW(set_roce_address_out)];
- void *in_addr = MLX5_ADDR_OF(set_roce_address_in, in, roce_address);
-
- memset(in, 0, sizeof(in));
-
- ib_gid_to_mlx5_roce_addr(gid, ndev, in_addr);
-
- MLX5_SET(set_roce_address_in, in, roce_address_index, index);
- MLX5_SET(set_roce_address_in, in, opcode, MLX5_CMD_OP_SET_ROCE_ADDRESS);
-
- memset(out, 0, sizeof(out));
- return mlx5_cmd_exec(dev->mdev, in, sizeof(in), out, sizeof(out));
-}
-
-static int translate_eth_proto_oper(u32 eth_proto_oper, u8 *active_speed,
- u8 *active_width)
-{
- switch (eth_proto_oper) {
- case MLX5_PROT_MASK(MLX5_1000BASE_CX_SGMII):
- case MLX5_PROT_MASK(MLX5_1000BASE_KX):
- case MLX5_PROT_MASK(MLX5_100BASE_TX):
- case MLX5_PROT_MASK(MLX5_1000BASE_T):
- *active_width = IB_WIDTH_1X;
- *active_speed = IB_SPEED_SDR;
- break;
- case MLX5_PROT_MASK(MLX5_10GBASE_T):
- case MLX5_PROT_MASK(MLX5_10GBASE_CX4):
- case MLX5_PROT_MASK(MLX5_10GBASE_KX4):
- case MLX5_PROT_MASK(MLX5_10GBASE_KR):
- case MLX5_PROT_MASK(MLX5_10GBASE_CR):
- case MLX5_PROT_MASK(MLX5_10GBASE_SR):
- case MLX5_PROT_MASK(MLX5_10GBASE_ER):
- *active_width = IB_WIDTH_1X;
- *active_speed = IB_SPEED_QDR;
- break;
- case MLX5_PROT_MASK(MLX5_25GBASE_CR):
- case MLX5_PROT_MASK(MLX5_25GBASE_KR):
- case MLX5_PROT_MASK(MLX5_25GBASE_SR):
- *active_width = IB_WIDTH_1X;
- *active_speed = IB_SPEED_EDR;
- break;
- case MLX5_PROT_MASK(MLX5_40GBASE_CR4):
- case MLX5_PROT_MASK(MLX5_40GBASE_KR4):
- case MLX5_PROT_MASK(MLX5_40GBASE_SR4):
- case MLX5_PROT_MASK(MLX5_40GBASE_LR4):
- *active_width = IB_WIDTH_4X;
- *active_speed = IB_SPEED_QDR;
- break;
- case MLX5_PROT_MASK(MLX5_50GBASE_CR2):
- case MLX5_PROT_MASK(MLX5_50GBASE_KR2):
- *active_width = IB_WIDTH_1X;
- *active_speed = IB_SPEED_FDR;
- break;
- case MLX5_PROT_MASK(MLX5_56GBASE_R4):
- *active_width = IB_WIDTH_4X;
- *active_speed = IB_SPEED_FDR;
- break;
- case MLX5_PROT_MASK(MLX5_100GBASE_CR4):
- case MLX5_PROT_MASK(MLX5_100GBASE_SR4):
- case MLX5_PROT_MASK(MLX5_100GBASE_KR4):
- case MLX5_PROT_MASK(MLX5_100GBASE_LR4):
- *active_width = IB_WIDTH_4X;
- *active_speed = IB_SPEED_EDR;
- break;
- default:
- return -EINVAL;
- }
-
- return 0;
-}
-
-static int mlx5_query_roce_port_ptys(struct ib_device *ib_dev,
- struct ib_port_attr *props, u8 port)
-{
- struct mlx5_ib_dev *dev = to_mdev(ib_dev);
- struct mlx5_core_dev *mdev = dev->mdev;
- struct mlx5_ptys_reg *ptys;
- int err;
-
- ptys = kzalloc(sizeof(*ptys), GFP_KERNEL);
- if (!ptys)
- return -ENOMEM;
-
- ptys->proto_mask |= MLX5_PTYS_EN;
- ptys->local_port = port;
-
- err = mlx5_core_access_ptys(mdev, ptys, 0);
- if (err)
- goto out;
-
- err = translate_eth_proto_oper(ptys->eth_proto_oper,
- &props->active_speed,
- &props->active_width);
-out:
- kfree(ptys);
- return err;
-}
-
-int mlx5_query_port_roce(struct ib_device *ib_dev, u8 port,
- struct ib_port_attr *props)
-{
- struct net_device *netdev = mlx5_ib_get_netdev(ib_dev, port);
- struct mlx5_ib_dev *dev = to_mdev(ib_dev);
- enum ib_mtu netdev_ib_mtu;
-
- memset(props, 0, sizeof(*props));
-
- props->port_cap_flags |= IB_PORT_CM_SUP;
-
- props->gid_tbl_len = MLX5_CAP_ROCE(dev->mdev,
- roce_address_table_size);
- props->max_mtu = IB_MTU_4096;
- props->max_msg_sz = 1 << MLX5_CAP_GEN(dev->mdev, log_max_msg);
- props->pkey_tbl_len = 1;
- props->state = IB_PORT_DOWN;
- props->phys_state = 3;
-
- if (mlx5_query_nic_vport_qkey_viol_cntr(dev->mdev,
- (u16 *)&props->qkey_viol_cntr))
- printf("mlx5_ib: WARN: ""%s failed to query qkey violations counter\n", __func__);
-
-
- if (!netdev)
- return 0;
-
- if (netif_running(netdev) && netif_carrier_ok(netdev)) {
- props->state = IB_PORT_ACTIVE;
- props->phys_state = 5;
- }
-
- netdev_ib_mtu = iboe_get_mtu(netdev->if_mtu);
- props->active_mtu = min(props->max_mtu, netdev_ib_mtu);
-
- mlx5_query_roce_port_ptys(ib_dev, props, port);
-
- return 0;
-}
-
-__be16 mlx5_get_roce_udp_sport(struct mlx5_ib_dev *dev, u8 port,
- int index, __be16 ah_s_udp_port)
-{
-#ifndef MLX5_USE_ROCE_VERSION_2
- return 0;
-#else
- return cpu_to_be16(MLX5_CAP_ROCE(dev->mdev, r_roce_min_src_udp_port));
-#endif
-}
-
-int mlx5_get_roce_gid_type(struct mlx5_ib_dev *dev, u8 port,
- int index, int *gid_type)
-{
- union ib_gid gid;
- int ret;
-
- ret = ib_get_cached_gid(&dev->ib_dev, port, index, &gid);
-
- if (!ret)
- *gid_type = -1;
-
- return ret;
-}
diff --git a/sys/dev/mlx5/mlx5_ib/mlx5_ib_srq.c b/sys/dev/mlx5/mlx5_ib/mlx5_ib_srq.c
index 93dec9c..c0b2ec1 100644
--- a/sys/dev/mlx5/mlx5_ib/mlx5_ib_srq.c
+++ b/sys/dev/mlx5/mlx5_ib/mlx5_ib_srq.c
@@ -33,7 +33,6 @@
#include <rdma/ib_user_verbs.h>
#include "mlx5_ib.h"
-#include "user.h"
/* not supported currently */
static int srq_signature;
@@ -59,7 +58,8 @@ static void mlx5_ib_srq_event(struct mlx5_core_srq *srq, int type)
event.event = IB_EVENT_SRQ_ERR;
break;
default:
- printf("mlx5_ib: WARN: ""mlx5_ib: Unexpected event type %d on SRQ %06x\n", type, srq->srqn);
+ pr_warn("mlx5_ib: Unexpected event type %d on SRQ %06x\n",
+ type, srq->srqn);
return;
}
@@ -69,31 +69,39 @@ static void mlx5_ib_srq_event(struct mlx5_core_srq *srq, int type)
static int create_srq_user(struct ib_pd *pd, struct mlx5_ib_srq *srq,
struct mlx5_create_srq_mbox_in **in,
- struct ib_udata *udata, int buf_size, int *inlen)
+ struct ib_udata *udata, int buf_size, int *inlen,
+ int type)
{
struct mlx5_ib_dev *dev = to_mdev(pd->device);
- struct mlx5_ib_create_srq ucmd;
+ struct mlx5_ib_create_srq ucmd = {};
size_t ucmdlen;
- void *xsrqc;
int err;
int npages;
int page_shift;
int ncont;
- int drv_data = udata->inlen - sizeof(struct ib_uverbs_cmd_hdr);
u32 offset;
+ u32 uidx = MLX5_IB_DEFAULT_UIDX;
- ucmdlen = (drv_data < sizeof(ucmd)) ?
- drv_data : sizeof(ucmd);
+ ucmdlen = min(udata->inlen, sizeof(ucmd));
if (ib_copy_from_udata(&ucmd, udata, ucmdlen)) {
- mlx5_ib_err(dev, "failed copy udata\n");
+ mlx5_ib_dbg(dev, "failed copy udata\n");
return -EFAULT;
}
- if (ucmdlen == sizeof(ucmd) &&
- ucmd.reserved1 != 0) {
- mlx5_ib_warn(dev, "corrupted ucmd\n");
+ if (ucmd.reserved0 || ucmd.reserved1)
return -EINVAL;
+
+ if (udata->inlen > sizeof(ucmd) &&
+ !ib_is_udata_cleared(udata, sizeof(ucmd),
+ udata->inlen - sizeof(ucmd)))
+ return -EINVAL;
+
+ if (type == IB_SRQT_XRC) {
+ err = get_srq_user_index(to_mucontext(pd->uobject->context),
+ &ucmd, udata->inlen, &uidx);
+ if (err)
+ return err;
}
srq->wq_sig = !!(ucmd.flags & MLX5_SRQ_FLAG_SIGNATURE);
@@ -101,7 +109,7 @@ static int create_srq_user(struct ib_pd *pd, struct mlx5_ib_srq *srq,
srq->umem = ib_umem_get(pd->uobject->context, ucmd.buf_addr, buf_size,
0, 0);
if (IS_ERR(srq->umem)) {
- mlx5_ib_warn(dev, "failed umem get, size %d\n", buf_size);
+ mlx5_ib_dbg(dev, "failed umem get, size %d\n", buf_size);
err = PTR_ERR(srq->umem);
return err;
}
@@ -118,7 +126,6 @@ static int create_srq_user(struct ib_pd *pd, struct mlx5_ib_srq *srq,
*inlen = sizeof(**in) + sizeof(*(*in)->pas) * ncont;
*in = mlx5_vzalloc(*inlen);
if (!(*in)) {
- mlx5_ib_err(dev, "failed allocate mbox\n");
err = -ENOMEM;
goto err_umem;
}
@@ -128,21 +135,18 @@ static int create_srq_user(struct ib_pd *pd, struct mlx5_ib_srq *srq,
err = mlx5_ib_db_map_user(to_mucontext(pd->uobject->context),
ucmd.db_addr, &srq->db);
if (err) {
- mlx5_ib_warn(dev, "map doorbell failed\n");
+ mlx5_ib_dbg(dev, "map doorbell failed\n");
goto err_in;
}
(*in)->ctx.log_pg_sz = page_shift - MLX5_ADAPTER_PAGE_SHIFT;
(*in)->ctx.pgoff_cqn = cpu_to_be32(offset << 26);
- if (MLX5_CAP_GEN(dev->mdev, cqe_version)) {
- xsrqc = MLX5_ADDR_OF(create_xrc_srq_in, *in,
- xrc_srq_context_entry);
- /* 0xffffff means we ask to work with cqe version 0 */
- if (drv_data > offsetof(struct mlx5_ib_create_srq, uidx))
- MLX5_SET(xrc_srqc, xsrqc, user_index, ucmd.uidx);
- else
- MLX5_SET(xrc_srqc, xsrqc, user_index, 0xffffff);
+ if (MLX5_CAP_GEN(dev->mdev, cqe_version) == MLX5_CQE_VERSION_V1 &&
+ type == IB_SRQT_XRC) {
+ void *xsrqc = MLX5_ADDR_OF(create_xrc_srq_in, *in,
+ xrc_srq_context_entry);
+ MLX5_SET(xrc_srqc, xsrqc, user_index, uidx);
}
return 0;
@@ -158,13 +162,13 @@ err_umem:
static int create_srq_kernel(struct mlx5_ib_dev *dev, struct mlx5_ib_srq *srq,
struct mlx5_create_srq_mbox_in **in, int buf_size,
- int *inlen)
+ int *inlen, int type)
{
int err;
int i;
struct mlx5_wqe_srq_next_seg *next;
int page_shift;
- void *xsrqc;
+ int npages;
err = mlx5_db_alloc(dev->mdev, &srq->db);
if (err) {
@@ -172,8 +176,8 @@ static int create_srq_kernel(struct mlx5_ib_dev *dev, struct mlx5_ib_srq *srq,
return err;
}
- if (mlx5_buf_alloc(dev->mdev, buf_size, PAGE_SIZE * 2, &srq->buf)) {
- mlx5_ib_err(dev, "buf alloc failed\n");
+ if (mlx5_buf_alloc(dev->mdev, buf_size, 2 * PAGE_SIZE, &srq->buf)) {
+ mlx5_ib_dbg(dev, "buf alloc failed\n");
err = -ENOMEM;
goto err_db;
}
@@ -189,10 +193,12 @@ static int create_srq_kernel(struct mlx5_ib_dev *dev, struct mlx5_ib_srq *srq,
cpu_to_be16((i + 1) & (srq->msrq.max - 1));
}
- *inlen = sizeof(**in) + sizeof(*(*in)->pas) * srq->buf.npages;
+ npages = DIV_ROUND_UP(srq->buf.npages, 1 << (page_shift - PAGE_SHIFT));
+ mlx5_ib_dbg(dev, "buf_size %d, page_shift %d, npages %d, calc npages %d\n",
+ buf_size, page_shift, srq->buf.npages, npages);
+ *inlen = sizeof(**in) + sizeof(*(*in)->pas) * npages;
*in = mlx5_vzalloc(*inlen);
if (!*in) {
- mlx5_ib_err(dev, "failed allocate mbox\n");
err = -ENOMEM;
goto err_buf;
}
@@ -200,6 +206,8 @@ static int create_srq_kernel(struct mlx5_ib_dev *dev, struct mlx5_ib_srq *srq,
srq->wrid = kmalloc(srq->msrq.max * sizeof(u64), GFP_KERNEL);
if (!srq->wrid) {
+ mlx5_ib_dbg(dev, "kmalloc failed %lu\n",
+ (unsigned long)(srq->msrq.max * sizeof(u64)));
err = -ENOMEM;
goto err_in;
}
@@ -207,11 +215,11 @@ static int create_srq_kernel(struct mlx5_ib_dev *dev, struct mlx5_ib_srq *srq,
(*in)->ctx.log_pg_sz = page_shift - MLX5_ADAPTER_PAGE_SHIFT;
- if (MLX5_CAP_GEN(dev->mdev, cqe_version)) {
- xsrqc = MLX5_ADDR_OF(create_xrc_srq_in, *in,
- xrc_srq_context_entry);
- /* 0xffffff means we ask to work with cqe version 0 */
- MLX5_SET(xrc_srqc, xsrqc, user_index, 0xffffff);
+ if (MLX5_CAP_GEN(dev->mdev, cqe_version) == MLX5_CQE_VERSION_V1 &&
+ type == IB_SRQT_XRC) {
+ void *xsrqc = MLX5_ADDR_OF(create_xrc_srq_in, *in,
+ xrc_srq_context_entry);
+ MLX5_SET(xrc_srqc, xsrqc, user_index, MLX5_IB_DEFAULT_UIDX);
}
return 0;
@@ -258,9 +266,9 @@ struct ib_srq *mlx5_ib_create_srq(struct ib_pd *pd,
/* Sanity check SRQ size before proceeding */
if (init_attr->attr.max_wr >= max_srq_wqes) {
- mlx5_ib_warn(dev, "max_wr %d, cap %d\n",
- init_attr->attr.max_wr,
- max_srq_wqes);
+ mlx5_ib_dbg(dev, "max_wr %d, cap %d\n",
+ init_attr->attr.max_wr,
+ max_srq_wqes);
return ERR_PTR(-EINVAL);
}
@@ -286,9 +294,9 @@ struct ib_srq *mlx5_ib_create_srq(struct ib_pd *pd,
srq->msrq.max_avail_gather);
if (pd->uobject)
- err = create_srq_user(pd, srq, &in, udata, buf_size, &inlen);
+ err = create_srq_user(pd, srq, &in, udata, buf_size, &inlen, init_attr->srq_type);
else
- err = create_srq_kernel(dev, srq, &in, buf_size, &inlen);
+ err = create_srq_kernel(dev, srq, &in, buf_size, &inlen, init_attr->srq_type);
if (err) {
mlx5_ib_warn(dev, "create srq %s failed, err %d\n",
@@ -315,7 +323,7 @@ struct ib_srq *mlx5_ib_create_srq(struct ib_pd *pd,
err = mlx5_core_create_srq(dev->mdev, &srq->msrq, in, inlen, is_xrc);
kvfree(in);
if (err) {
- mlx5_ib_warn(dev, "create SRQ failed, err %d\n", err);
+ mlx5_ib_dbg(dev, "create SRQ failed, err %d\n", err);
goto err_usr_kern_srq;
}
@@ -326,7 +334,7 @@ struct ib_srq *mlx5_ib_create_srq(struct ib_pd *pd,
if (pd->uobject)
if (ib_copy_to_udata(udata, &srq->msrq.srqn, sizeof(__u32))) {
- mlx5_ib_err(dev, "copy to user failed\n");
+ mlx5_ib_dbg(dev, "copy to user failed\n");
err = -EFAULT;
goto err_core;
}
@@ -450,7 +458,6 @@ int mlx5_ib_post_srq_recv(struct ib_srq *ibsrq, struct ib_recv_wr *wr,
if (mdev->state == MLX5_DEVICE_STATE_INTERNAL_ERROR) {
err = -EIO;
*bad_wr = wr;
- nreq = 0;
goto out;
}
diff --git a/sys/dev/mlx5/mlx5_ib/mlx5_ib_virt.c b/sys/dev/mlx5/mlx5_ib/mlx5_ib_virt.c
new file mode 100644
index 0000000..6088fb4
--- /dev/null
+++ b/sys/dev/mlx5/mlx5_ib/mlx5_ib_virt.c
@@ -0,0 +1,54 @@
+/*-
+ * Copyright (c) 2016, Mellanox Technologies, Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS `AS IS' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * $FreeBSD$
+ */
+
+#include <linux/module.h>
+#include <dev/mlx5/vport.h>
+#include "mlx5_ib.h"
+
+int mlx5_ib_get_vf_config(struct ib_device *device, int vf, u8 port,
+ struct ifla_vf_info *info)
+{
+ return -EOPNOTSUPP;
+}
+
+int mlx5_ib_set_vf_link_state(struct ib_device *device, int vf,
+ u8 port, int state)
+{
+ return -EOPNOTSUPP;
+}
+
+int mlx5_ib_get_vf_stats(struct ib_device *device, int vf,
+ u8 port, struct ifla_vf_stats *stats)
+{
+ return -EOPNOTSUPP;
+}
+
+int mlx5_ib_set_vf_guid(struct ib_device *device, int vf, u8 port,
+ u64 guid, int type)
+{
+ return -EOPNOTSUPP;
+}
diff --git a/sys/dev/mlx5/mlx5_ib/user.h b/sys/dev/mlx5/mlx5_ib/user.h
deleted file mode 100644
index bc55952..0000000
--- a/sys/dev/mlx5/mlx5_ib/user.h
+++ /dev/null
@@ -1,318 +0,0 @@
-/*-
- * Copyright (c) 2013-2015, Mellanox Technologies, Ltd. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS `AS IS' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * $FreeBSD$
- */
-
-#ifndef MLX5_IB_USER_H
-#define MLX5_IB_USER_H
-
-#include <linux/types.h>
-
-enum {
- MLX5_QP_FLAG_SIGNATURE = 1 << 0,
-};
-
-enum {
- MLX5_SRQ_FLAG_SIGNATURE = 1 << 0,
-};
-
-enum {
- MLX5_WQ_FLAG_SIGNATURE = 1 << 0,
-};
-
-
-/* Increment this value if any changes that break userspace ABI
- * compatibility are made.
- */
-#define MLX5_IB_UVERBS_ABI_VERSION 1
-
-/* Make sure that all structs defined in this file remain laid out so
- * that they pack the same way on 32-bit and 64-bit architectures (to
- * avoid incompatibility between 32-bit userspace and 64-bit kernels).
- * In particular do not use pointer types -- pass pointers in __u64
- * instead.
- */
-
-struct mlx5_ib_alloc_ucontext_req {
- __u32 total_num_uuars;
- __u32 num_low_latency_uuars;
-};
-
-struct mlx5_ib_alloc_ucontext_req_v2 {
- __u32 total_num_uuars;
- __u32 num_low_latency_uuars;
- __u32 flags;
- __u32 reserved;
-};
-
-struct mlx5_ib_alloc_ucontext_resp {
- __u32 qp_tab_size;
- __u32 bf_reg_size;
- __u32 tot_uuars;
- __u32 cache_line_size;
- __u16 max_sq_desc_sz;
- __u16 max_rq_desc_sz;
- __u32 max_send_wqebb;
- __u32 max_recv_wr;
- __u32 max_srq_recv_wr;
- __u16 num_ports;
- __u16 reserved;
- __u32 max_desc_sz_sq_dc;
- __u32 atomic_arg_sizes_dc;
- __u32 reserved1;
- __u32 flags;
- __u32 reserved2[5];
-};
-
-enum mlx5_exp_ib_alloc_ucontext_data_resp_mask {
- MLX5_EXP_ALLOC_CTX_RESP_MASK_CQE_COMP_MAX_NUM = 1 << 0,
- MLX5_EXP_ALLOC_CTX_RESP_MASK_CQE_VERSION = 1 << 1,
- MLX5_EXP_ALLOC_CTX_RESP_MASK_RROCE_UDP_SPORT_MIN = 1 << 2,
- MLX5_EXP_ALLOC_CTX_RESP_MASK_RROCE_UDP_SPORT_MAX = 1 << 3,
- MLX5_EXP_ALLOC_CTX_RESP_MASK_HCA_CORE_CLOCK_OFFSET = 1 << 4,
-};
-
-struct mlx5_exp_ib_alloc_ucontext_data_resp {
- __u32 comp_mask; /* use mlx5_ib_exp_alloc_ucontext_data_resp_mask */
- __u16 cqe_comp_max_num;
- __u8 cqe_version;
- __u8 reserved;
- __u16 rroce_udp_sport_min;
- __u16 rroce_udp_sport_max;
- __u32 hca_core_clock_offset;
-};
-
-struct mlx5_exp_ib_alloc_ucontext_resp {
- __u32 qp_tab_size;
- __u32 bf_reg_size;
- __u32 tot_uuars;
- __u32 cache_line_size;
- __u16 max_sq_desc_sz;
- __u16 max_rq_desc_sz;
- __u32 max_send_wqebb;
- __u32 max_recv_wr;
- __u32 max_srq_recv_wr;
- __u16 num_ports;
- __u16 reserved;
- __u32 max_desc_sz_sq_dc;
- __u32 atomic_arg_sizes_dc;
- __u32 reserved1;
- __u32 flags;
- __u32 reserved2[5];
- /* Some more reserved fields for
- * future growth of mlx5_ib_alloc_ucontext_resp */
- __u64 prefix_reserved[8];
- struct mlx5_exp_ib_alloc_ucontext_data_resp exp_data;
-};
-
-struct mlx5_ib_alloc_pd_resp {
- __u32 pdn;
-};
-
-struct mlx5_ib_create_cq {
- __u64 buf_addr;
- __u64 db_addr;
- __u32 cqe_size;
- __u32 reserved; /* explicit padding (optional on i386) */
-};
-
-enum mlx5_exp_ib_create_cq_mask {
- MLX5_EXP_CREATE_CQ_MASK_CQE_COMP_EN = 1 << 0,
- MLX5_EXP_CREATE_CQ_MASK_CQE_COMP_RECV_TYPE = 1 << 1,
- MLX5_EXP_CREATE_CQ_MASK_RESERVED = 1 << 2,
-};
-
-enum mlx5_exp_cqe_comp_recv_type {
- MLX5_IB_CQE_FORMAT_HASH,
- MLX5_IB_CQE_FORMAT_CSUM,
-};
-
-struct mlx5_exp_ib_create_cq_data {
- __u32 comp_mask; /* use mlx5_exp_ib_creaet_cq_mask */
- __u8 cqe_comp_en;
- __u8 cqe_comp_recv_type; /* use mlx5_exp_cqe_comp_recv_type */
- __u16 reserved;
-};
-
-struct mlx5_exp_ib_create_cq {
- __u64 buf_addr;
- __u64 db_addr;
- __u32 cqe_size;
- __u32 reserved; /* explicit padding (optional on i386) */
-
- /* Some more reserved fields for future growth of mlx5_ib_create_cq */
- __u64 prefix_reserved[8];
-
- /* sizeof prefix aligned with mlx5_ib_create_cq */
- __u64 size_of_prefix;
- struct mlx5_exp_ib_create_cq_data exp_data;
-};
-
-struct mlx5_ib_create_cq_resp {
- __u32 cqn;
- __u32 reserved;
-};
-
-struct mlx5_ib_resize_cq {
- __u64 buf_addr;
- __u16 cqe_size;
- __u16 reserved0;
- __u32 reserved1;
-};
-
-struct mlx5_ib_create_srq {
- __u64 buf_addr;
- __u64 db_addr;
- __u32 flags;
- __u32 reserved; /* explicit padding (optional on i386) */
- __u32 uidx;
- __u32 reserved1;
-};
-
-struct mlx5_ib_create_srq_resp {
- __u32 srqn;
- __u32 reserved;
-};
-
-struct mlx5_ib_create_qp {
- __u64 buf_addr;
- __u64 db_addr;
- __u32 sq_wqe_count;
- __u32 rq_wqe_count;
- __u32 rq_wqe_shift;
- __u32 flags;
-};
-
-enum mlx5_exp_ib_create_qp_mask {
- MLX5_EXP_CREATE_QP_MASK_UIDX = 1 << 0,
- MLX5_EXP_CREATE_QP_MASK_SQ_BUFF_ADD = 1 << 1,
- MLX5_EXP_CREATE_QP_MASK_WC_UAR_IDX = 1 << 2,
- MLX5_EXP_CREATE_QP_MASK_FLAGS_IDX = 1 << 3,
- MLX5_EXP_CREATE_QP_MASK_RESERVED = 1 << 4,
-};
-
-enum mlx5_exp_create_qp_flags {
- MLX5_EXP_CREATE_QP_MULTI_PACKET_WQE_REQ_FLAG = 1 << 0,
-};
-
-enum mlx5_exp_drv_create_qp_uar_idx {
- MLX5_EXP_CREATE_QP_DB_ONLY_UUAR = -1
-};
-
-struct mlx5_exp_ib_create_qp_data {
- __u32 comp_mask; /* use mlx5_exp_ib_create_qp_mask */
- __u32 uidx;
- __u64 sq_buf_addr;
- __u32 wc_uar_index;
- __u32 flags; /* use mlx5_exp_create_qp_flags */
-};
-
-struct mlx5_exp_ib_create_qp {
- /* To allow casting to mlx5_ib_create_qp the prefix is the same as
- * struct mlx5_ib_create_qp prefix
- */
- __u64 buf_addr;
- __u64 db_addr;
- __u32 sq_wqe_count;
- __u32 rq_wqe_count;
- __u32 rq_wqe_shift;
- __u32 flags;
-
- /* Some more reserved fields for future growth of mlx5_ib_create_qp */
- __u64 prefix_reserved[8];
-
- /* sizeof prefix aligned with mlx5_ib_create_qp */
- __u64 size_of_prefix;
-
- /* Experimental data
- * Add new experimental data only inside the exp struct
- */
- struct mlx5_exp_ib_create_qp_data exp;
-};
-
-enum {
- MLX5_EXP_INVALID_UUAR = -1,
-};
-
-struct mlx5_ib_create_qp_resp {
- __u32 uuar_index;
- __u32 rsvd;
-};
-
-enum mlx5_exp_ib_create_qp_resp_mask {
- MLX5_EXP_CREATE_QP_RESP_MASK_FLAGS_IDX = 1 << 0,
- MLX5_EXP_CREATE_QP_RESP_MASK_RESERVED = 1 << 1,
-};
-
-enum mlx5_exp_create_qp_resp_flags {
- MLX5_EXP_CREATE_QP_RESP_MULTI_PACKET_WQE_FLAG = 1 << 0,
-};
-
-struct mlx5_exp_ib_create_qp_resp_data {
- __u32 comp_mask; /* use mlx5_exp_ib_create_qp_resp_mask */
- __u32 flags; /* use mlx5_exp_create_qp_resp_flags */
-};
-
-struct mlx5_exp_ib_create_qp_resp {
- __u32 uuar_index;
- __u32 rsvd;
-
- /* Some more reserved fields for future growth of mlx5_ib_create_qp_resp */
- __u64 prefix_reserved[8];
-
- /* sizeof prefix aligned with mlx5_ib_create_qp_resp */
- __u64 size_of_prefix;
-
- /* Experimental data
- * Add new experimental data only inside the exp struct
- */
- struct mlx5_exp_ib_create_qp_resp_data exp;
-};
-
-struct mlx5_ib_create_dct {
- __u32 uidx;
- __u32 reserved;
-};
-
-struct mlx5_ib_arm_dct {
- __u64 reserved0;
- __u64 reserved1;
-};
-
-struct mlx5_ib_arm_dct_resp {
- __u64 reserved0;
- __u64 reserved1;
-};
-
-struct mlx5_ib_create_wq {
- __u64 buf_addr;
- __u64 db_addr;
- __u32 rq_wqe_count;
- __u32 rq_wqe_shift;
- __u32 user_index;
- __u32 flags;
-};
-
-#endif /* MLX5_IB_USER_H */
diff --git a/sys/dev/mlx5/qp.h b/sys/dev/mlx5/qp.h
index b91e3e0..c0116f7 100644
--- a/sys/dev/mlx5/qp.h
+++ b/sys/dev/mlx5/qp.h
@@ -110,10 +110,10 @@ enum {
};
enum {
- MLX5_NON_ZERO_RQ = 0 << 24,
- MLX5_SRQ_RQ = 1 << 24,
- MLX5_CRQ_RQ = 2 << 24,
- MLX5_ZERO_LEN_RQ = 3 << 24
+ MLX5_NON_ZERO_RQ = 0x0,
+ MLX5_SRQ_RQ = 0x1,
+ MLX5_CRQ_RQ = 0x2,
+ MLX5_ZERO_LEN_RQ = 0x3
};
enum {
diff --git a/sys/dev/mthca/mthca_allocator.c b/sys/dev/mthca/mthca_allocator.c
new file mode 100644
index 0000000..b4e0cf4
--- /dev/null
+++ b/sys/dev/mthca/mthca_allocator.c
@@ -0,0 +1,301 @@
+/*
+ * Copyright (c) 2004 Topspin Communications. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#include <linux/errno.h>
+#include <linux/slab.h>
+#include <linux/bitmap.h>
+
+#include "mthca_dev.h"
+
+/* Trivial bitmap-based allocator */
+u32 mthca_alloc(struct mthca_alloc *alloc)
+{
+ unsigned long flags;
+ u32 obj;
+
+ spin_lock_irqsave(&alloc->lock, flags);
+
+ obj = find_next_zero_bit(alloc->table, alloc->max, alloc->last);
+ if (obj >= alloc->max) {
+ alloc->top = (alloc->top + alloc->max) & alloc->mask;
+ obj = find_first_zero_bit(alloc->table, alloc->max);
+ }
+
+ if (obj < alloc->max) {
+ set_bit(obj, alloc->table);
+ obj |= alloc->top;
+ } else
+ obj = -1;
+
+ spin_unlock_irqrestore(&alloc->lock, flags);
+
+ return obj;
+}
+
+void mthca_free(struct mthca_alloc *alloc, u32 obj)
+{
+ unsigned long flags;
+
+ obj &= alloc->max - 1;
+
+ spin_lock_irqsave(&alloc->lock, flags);
+
+ clear_bit(obj, alloc->table);
+ alloc->last = min(alloc->last, obj);
+ alloc->top = (alloc->top + alloc->max) & alloc->mask;
+
+ spin_unlock_irqrestore(&alloc->lock, flags);
+}
+
+int mthca_alloc_init(struct mthca_alloc *alloc, u32 num, u32 mask,
+ u32 reserved)
+{
+ int i;
+
+ /* num must be a power of 2 */
+ if (num != 1 << (ffs(num) - 1))
+ return -EINVAL;
+
+ alloc->last = 0;
+ alloc->top = 0;
+ alloc->max = num;
+ alloc->mask = mask;
+ spin_lock_init(&alloc->lock);
+ alloc->table = kmalloc(BITS_TO_LONGS(num) * sizeof (long),
+ GFP_KERNEL);
+ if (!alloc->table)
+ return -ENOMEM;
+
+ bitmap_zero(alloc->table, num);
+ for (i = 0; i < reserved; ++i)
+ set_bit(i, alloc->table);
+
+ return 0;
+}
+
+void mthca_alloc_cleanup(struct mthca_alloc *alloc)
+{
+ kfree(alloc->table);
+}
+
+/*
+ * Array of pointers with lazy allocation of leaf pages. Callers of
+ * _get, _set and _clear methods must use a lock or otherwise
+ * serialize access to the array.
+ */
+
+#define MTHCA_ARRAY_MASK (PAGE_SIZE / sizeof (void *) - 1)
+
+void *mthca_array_get(struct mthca_array *array, int index)
+{
+ int p = (index * sizeof (void *)) >> PAGE_SHIFT;
+
+ if (array->page_list[p].page)
+ return array->page_list[p].page[index & MTHCA_ARRAY_MASK];
+ else
+ return NULL;
+}
+
+int mthca_array_set(struct mthca_array *array, int index, void *value)
+{
+ int p = (index * sizeof (void *)) >> PAGE_SHIFT;
+
+ /* Allocate with GFP_ATOMIC because we'll be called with locks held. */
+ if (!array->page_list[p].page)
+ array->page_list[p].page = (void **) get_zeroed_page(GFP_ATOMIC);
+
+ if (!array->page_list[p].page)
+ return -ENOMEM;
+
+ array->page_list[p].page[index & MTHCA_ARRAY_MASK] = value;
+ ++array->page_list[p].used;
+
+ return 0;
+}
+
+void mthca_array_clear(struct mthca_array *array, int index)
+{
+ int p = (index * sizeof (void *)) >> PAGE_SHIFT;
+
+ if (--array->page_list[p].used == 0) {
+ free_page((unsigned long) array->page_list[p].page);
+ array->page_list[p].page = NULL;
+ } else
+ array->page_list[p].page[index & MTHCA_ARRAY_MASK] = NULL;
+
+ if (array->page_list[p].used < 0)
+ pr_debug("Array %p index %d page %d with ref count %d < 0\n",
+ array, index, p, array->page_list[p].used);
+}
+
+int mthca_array_init(struct mthca_array *array, int nent)
+{
+ int npage = (nent * sizeof (void *) + PAGE_SIZE - 1) / PAGE_SIZE;
+ int i;
+
+ array->page_list = kmalloc(npage * sizeof *array->page_list, GFP_KERNEL);
+ if (!array->page_list)
+ return -ENOMEM;
+
+ for (i = 0; i < npage; ++i) {
+ array->page_list[i].page = NULL;
+ array->page_list[i].used = 0;
+ }
+
+ return 0;
+}
+
+void mthca_array_cleanup(struct mthca_array *array, int nent)
+{
+ int i;
+
+ for (i = 0; i < (nent * sizeof (void *) + PAGE_SIZE - 1) / PAGE_SIZE; ++i)
+ free_page((unsigned long) array->page_list[i].page);
+
+ kfree(array->page_list);
+}
+
+/*
+ * Handling for queue buffers -- we allocate a bunch of memory and
+ * register it in a memory region at HCA virtual address 0. If the
+ * requested size is > max_direct, we split the allocation into
+ * multiple pages, so we don't require too much contiguous memory.
+ */
+
+int mthca_buf_alloc(struct mthca_dev *dev, int size, int max_direct,
+ union mthca_buf *buf, int *is_direct, struct mthca_pd *pd,
+ int hca_write, struct mthca_mr *mr)
+{
+ int err = -ENOMEM;
+ int npages, shift;
+ u64 *dma_list = NULL;
+ dma_addr_t t;
+ int i;
+
+ if (size <= max_direct) {
+ *is_direct = 1;
+ npages = 1;
+ shift = get_order(size) + PAGE_SHIFT;
+
+ buf->direct.buf = dma_alloc_coherent(&dev->pdev->dev,
+ size, &t, GFP_KERNEL);
+ if (!buf->direct.buf)
+ return -ENOMEM;
+
+ dma_unmap_addr_set(&buf->direct, mapping, t);
+
+ memset(buf->direct.buf, 0, size);
+
+ while (t & ((1 << shift) - 1)) {
+ --shift;
+ npages *= 2;
+ }
+
+ dma_list = kmalloc(npages * sizeof *dma_list, GFP_KERNEL);
+ if (!dma_list)
+ goto err_free;
+
+ for (i = 0; i < npages; ++i)
+ dma_list[i] = t + i * (1 << shift);
+ } else {
+ *is_direct = 0;
+ npages = (size + PAGE_SIZE - 1) / PAGE_SIZE;
+ shift = PAGE_SHIFT;
+
+ dma_list = kmalloc(npages * sizeof *dma_list, GFP_KERNEL);
+ if (!dma_list)
+ return -ENOMEM;
+
+ buf->page_list = kmalloc(npages * sizeof *buf->page_list,
+ GFP_KERNEL);
+ if (!buf->page_list)
+ goto err_out;
+
+ for (i = 0; i < npages; ++i)
+ buf->page_list[i].buf = NULL;
+
+ for (i = 0; i < npages; ++i) {
+ buf->page_list[i].buf =
+ dma_alloc_coherent(&dev->pdev->dev, PAGE_SIZE,
+ &t, GFP_KERNEL);
+ if (!buf->page_list[i].buf)
+ goto err_free;
+
+ dma_list[i] = t;
+ dma_unmap_addr_set(&buf->page_list[i], mapping, t);
+
+ clear_page(buf->page_list[i].buf);
+ }
+ }
+
+ err = mthca_mr_alloc_phys(dev, pd->pd_num,
+ dma_list, shift, npages,
+ 0, size,
+ MTHCA_MPT_FLAG_LOCAL_READ |
+ (hca_write ? MTHCA_MPT_FLAG_LOCAL_WRITE : 0),
+ mr);
+ if (err)
+ goto err_free;
+
+ kfree(dma_list);
+
+ return 0;
+
+err_free:
+ mthca_buf_free(dev, size, buf, *is_direct, NULL);
+
+err_out:
+ kfree(dma_list);
+
+ return err;
+}
+
+void mthca_buf_free(struct mthca_dev *dev, int size, union mthca_buf *buf,
+ int is_direct, struct mthca_mr *mr)
+{
+ int i;
+
+ if (mr)
+ mthca_free_mr(dev, mr);
+
+ if (is_direct)
+ dma_free_coherent(&dev->pdev->dev, size, buf->direct.buf,
+ dma_unmap_addr(&buf->direct, mapping));
+ else {
+ for (i = 0; i < (size + PAGE_SIZE - 1) / PAGE_SIZE; ++i)
+ dma_free_coherent(&dev->pdev->dev, PAGE_SIZE,
+ buf->page_list[i].buf,
+ dma_unmap_addr(&buf->page_list[i],
+ mapping));
+ kfree(buf->page_list);
+ }
+}
diff --git a/sys/dev/mthca/mthca_av.c b/sys/dev/mthca/mthca_av.c
new file mode 100644
index 0000000..bcac294
--- /dev/null
+++ b/sys/dev/mthca/mthca_av.c
@@ -0,0 +1,374 @@
+/*
+ * Copyright (c) 2004 Topspin Communications. All rights reserved.
+ * Copyright (c) 2005 Sun Microsystems, Inc. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#include <linux/string.h>
+#include <linux/slab.h>
+
+#include <rdma/ib_verbs.h>
+#include <rdma/ib_cache.h>
+
+#include "mthca_dev.h"
+
+enum {
+ MTHCA_RATE_TAVOR_FULL = 0,
+ MTHCA_RATE_TAVOR_1X = 1,
+ MTHCA_RATE_TAVOR_4X = 2,
+ MTHCA_RATE_TAVOR_1X_DDR = 3
+};
+
+enum {
+ MTHCA_RATE_MEMFREE_FULL = 0,
+ MTHCA_RATE_MEMFREE_QUARTER = 1,
+ MTHCA_RATE_MEMFREE_EIGHTH = 2,
+ MTHCA_RATE_MEMFREE_HALF = 3
+};
+
+struct mthca_av {
+ __be32 port_pd;
+ u8 reserved1;
+ u8 g_slid;
+ __be16 dlid;
+ u8 reserved2;
+ u8 gid_index;
+ u8 msg_sr;
+ u8 hop_limit;
+ __be32 sl_tclass_flowlabel;
+ __be32 dgid[4];
+};
+
+static enum ib_rate memfree_rate_to_ib(u8 mthca_rate, u8 port_rate)
+{
+ switch (mthca_rate) {
+ case MTHCA_RATE_MEMFREE_EIGHTH:
+ return mult_to_ib_rate(port_rate >> 3);
+ case MTHCA_RATE_MEMFREE_QUARTER:
+ return mult_to_ib_rate(port_rate >> 2);
+ case MTHCA_RATE_MEMFREE_HALF:
+ return mult_to_ib_rate(port_rate >> 1);
+ case MTHCA_RATE_MEMFREE_FULL:
+ default:
+ return mult_to_ib_rate(port_rate);
+ }
+}
+
+static enum ib_rate tavor_rate_to_ib(u8 mthca_rate, u8 port_rate)
+{
+ switch (mthca_rate) {
+ case MTHCA_RATE_TAVOR_1X: return IB_RATE_2_5_GBPS;
+ case MTHCA_RATE_TAVOR_1X_DDR: return IB_RATE_5_GBPS;
+ case MTHCA_RATE_TAVOR_4X: return IB_RATE_10_GBPS;
+ default: return mult_to_ib_rate(port_rate);
+ }
+}
+
+enum ib_rate mthca_rate_to_ib(struct mthca_dev *dev, u8 mthca_rate, u8 port)
+{
+ if (mthca_is_memfree(dev)) {
+ /* Handle old Arbel FW */
+ if (dev->limits.stat_rate_support == 0x3 && mthca_rate)
+ return IB_RATE_2_5_GBPS;
+
+ return memfree_rate_to_ib(mthca_rate, dev->rate[port - 1]);
+ } else
+ return tavor_rate_to_ib(mthca_rate, dev->rate[port - 1]);
+}
+
+static u8 ib_rate_to_memfree(u8 req_rate, u8 cur_rate)
+{
+ if (cur_rate <= req_rate)
+ return 0;
+
+ /*
+ * Inter-packet delay (IPD) to get from rate X down to a rate
+ * no more than Y is (X - 1) / Y.
+ */
+ switch ((cur_rate - 1) / req_rate) {
+ case 0: return MTHCA_RATE_MEMFREE_FULL;
+ case 1: return MTHCA_RATE_MEMFREE_HALF;
+ case 2: /* fall through */
+ case 3: return MTHCA_RATE_MEMFREE_QUARTER;
+ default: return MTHCA_RATE_MEMFREE_EIGHTH;
+ }
+}
+
+static u8 ib_rate_to_tavor(u8 static_rate)
+{
+ switch (static_rate) {
+ case IB_RATE_2_5_GBPS: return MTHCA_RATE_TAVOR_1X;
+ case IB_RATE_5_GBPS: return MTHCA_RATE_TAVOR_1X_DDR;
+ case IB_RATE_10_GBPS: return MTHCA_RATE_TAVOR_4X;
+ default: return MTHCA_RATE_TAVOR_FULL;
+ }
+}
+
+u8 mthca_get_rate(struct mthca_dev *dev, int static_rate, u8 port)
+{
+ u8 rate;
+
+ if (!static_rate || ib_rate_to_mult(static_rate) >= dev->rate[port - 1])
+ return 0;
+
+ if (mthca_is_memfree(dev))
+ rate = ib_rate_to_memfree(ib_rate_to_mult(static_rate),
+ dev->rate[port - 1]);
+ else
+ rate = ib_rate_to_tavor(static_rate);
+
+ if (!(dev->limits.stat_rate_support & (1 << rate)))
+ rate = 1;
+
+ return rate;
+}
+
+int mthca_create_ah(struct mthca_dev *dev,
+ struct mthca_pd *pd,
+ struct ib_ah_attr *ah_attr,
+ struct mthca_ah *ah)
+{
+ u32 index = -1;
+ struct mthca_av *av = NULL;
+
+ ah->type = MTHCA_AH_PCI_POOL;
+
+ if (mthca_is_memfree(dev)) {
+ ah->av = kmalloc(sizeof *ah->av, GFP_ATOMIC);
+ if (!ah->av)
+ return -ENOMEM;
+
+ ah->type = MTHCA_AH_KMALLOC;
+ av = ah->av;
+ } else if (!atomic_read(&pd->sqp_count) &&
+ !(dev->mthca_flags & MTHCA_FLAG_DDR_HIDDEN)) {
+ index = mthca_alloc(&dev->av_table.alloc);
+
+ /* fall back to allocate in host memory */
+ if (index == -1)
+ goto on_hca_fail;
+
+ av = kmalloc(sizeof *av, GFP_ATOMIC);
+ if (!av)
+ goto on_hca_fail;
+
+ ah->type = MTHCA_AH_ON_HCA;
+ ah->avdma = dev->av_table.ddr_av_base +
+ index * MTHCA_AV_SIZE;
+ }
+
+on_hca_fail:
+ if (ah->type == MTHCA_AH_PCI_POOL) {
+ ah->av = pci_pool_alloc(dev->av_table.pool,
+ GFP_ATOMIC, &ah->avdma);
+ if (!ah->av)
+ return -ENOMEM;
+
+ av = ah->av;
+ }
+
+ ah->key = pd->ntmr.ibmr.lkey;
+
+ memset(av, 0, MTHCA_AV_SIZE);
+
+ av->port_pd = cpu_to_be32(pd->pd_num | (ah_attr->port_num << 24));
+ av->g_slid = ah_attr->src_path_bits;
+ av->dlid = cpu_to_be16(ah_attr->dlid);
+ av->msg_sr = (3 << 4) | /* 2K message */
+ mthca_get_rate(dev, ah_attr->static_rate, ah_attr->port_num);
+ av->sl_tclass_flowlabel = cpu_to_be32(ah_attr->sl << 28);
+ if (ah_attr->ah_flags & IB_AH_GRH) {
+ av->g_slid |= 0x80;
+ av->gid_index = (ah_attr->port_num - 1) * dev->limits.gid_table_len +
+ ah_attr->grh.sgid_index;
+ av->hop_limit = ah_attr->grh.hop_limit;
+ av->sl_tclass_flowlabel |=
+ cpu_to_be32((ah_attr->grh.traffic_class << 20) |
+ ah_attr->grh.flow_label);
+ memcpy(av->dgid, ah_attr->grh.dgid.raw, 16);
+ } else {
+ /* Arbel workaround -- low byte of GID must be 2 */
+ av->dgid[3] = cpu_to_be32(2);
+ }
+
+ if (0) {
+ int j;
+
+ mthca_dbg(dev, "Created UDAV at %p/%08lx:\n",
+ av, (unsigned long) ah->avdma);
+ for (j = 0; j < 8; ++j)
+ printk(KERN_DEBUG " [%2x] %08x\n",
+ j * 4, be32_to_cpu(((__be32 *) av)[j]));
+ }
+
+ if (ah->type == MTHCA_AH_ON_HCA) {
+ memcpy_toio(dev->av_table.av_map + index * MTHCA_AV_SIZE,
+ av, MTHCA_AV_SIZE);
+ kfree(av);
+ }
+
+ return 0;
+}
+
+int mthca_destroy_ah(struct mthca_dev *dev, struct mthca_ah *ah)
+{
+ switch (ah->type) {
+ case MTHCA_AH_ON_HCA:
+ mthca_free(&dev->av_table.alloc,
+ (ah->avdma - dev->av_table.ddr_av_base) /
+ MTHCA_AV_SIZE);
+ break;
+
+ case MTHCA_AH_PCI_POOL:
+ pci_pool_free(dev->av_table.pool, ah->av, ah->avdma);
+ break;
+
+ case MTHCA_AH_KMALLOC:
+ kfree(ah->av);
+ break;
+ }
+
+ return 0;
+}
+
+int mthca_ah_grh_present(struct mthca_ah *ah)
+{
+ return !!(ah->av->g_slid & 0x80);
+}
+
+int mthca_read_ah(struct mthca_dev *dev, struct mthca_ah *ah,
+ struct ib_ud_header *header)
+{
+ if (ah->type == MTHCA_AH_ON_HCA)
+ return -EINVAL;
+
+ header->lrh.service_level = be32_to_cpu(ah->av->sl_tclass_flowlabel) >> 28;
+ header->lrh.destination_lid = ah->av->dlid;
+ header->lrh.source_lid = cpu_to_be16(ah->av->g_slid & 0x7f);
+ if (mthca_ah_grh_present(ah)) {
+ header->grh.traffic_class =
+ (be32_to_cpu(ah->av->sl_tclass_flowlabel) >> 20) & 0xff;
+ header->grh.flow_label =
+ ah->av->sl_tclass_flowlabel & cpu_to_be32(0xfffff);
+ header->grh.hop_limit = ah->av->hop_limit;
+ ib_get_cached_gid(&dev->ib_dev,
+ be32_to_cpu(ah->av->port_pd) >> 24,
+ ah->av->gid_index % dev->limits.gid_table_len,
+ &header->grh.source_gid, NULL);
+ memcpy(header->grh.destination_gid.raw,
+ ah->av->dgid, 16);
+ }
+
+ return 0;
+}
+
+int mthca_ah_query(struct ib_ah *ibah, struct ib_ah_attr *attr)
+{
+ struct mthca_ah *ah = to_mah(ibah);
+ struct mthca_dev *dev = to_mdev(ibah->device);
+
+ /* Only implement for MAD and memfree ah for now. */
+ if (ah->type == MTHCA_AH_ON_HCA)
+ return -ENOSYS;
+
+ memset(attr, 0, sizeof *attr);
+ attr->dlid = be16_to_cpu(ah->av->dlid);
+ attr->sl = be32_to_cpu(ah->av->sl_tclass_flowlabel) >> 28;
+ attr->port_num = be32_to_cpu(ah->av->port_pd) >> 24;
+ attr->static_rate = mthca_rate_to_ib(dev, ah->av->msg_sr & 0x7,
+ attr->port_num);
+ attr->src_path_bits = ah->av->g_slid & 0x7F;
+ attr->ah_flags = mthca_ah_grh_present(ah) ? IB_AH_GRH : 0;
+
+ if (attr->ah_flags) {
+ attr->grh.traffic_class =
+ be32_to_cpu(ah->av->sl_tclass_flowlabel) >> 20;
+ attr->grh.flow_label =
+ be32_to_cpu(ah->av->sl_tclass_flowlabel) & 0xfffff;
+ attr->grh.hop_limit = ah->av->hop_limit;
+ attr->grh.sgid_index = ah->av->gid_index &
+ (dev->limits.gid_table_len - 1);
+ memcpy(attr->grh.dgid.raw, ah->av->dgid, 16);
+ }
+
+ return 0;
+}
+
+int mthca_init_av_table(struct mthca_dev *dev)
+{
+ int err;
+
+ if (mthca_is_memfree(dev))
+ return 0;
+
+ err = mthca_alloc_init(&dev->av_table.alloc,
+ dev->av_table.num_ddr_avs,
+ dev->av_table.num_ddr_avs - 1,
+ 0);
+ if (err)
+ return err;
+
+ dev->av_table.pool = pci_pool_create("mthca_av", dev->pdev,
+ MTHCA_AV_SIZE,
+ MTHCA_AV_SIZE, 0);
+ if (!dev->av_table.pool)
+ goto out_free_alloc;
+
+ if (!(dev->mthca_flags & MTHCA_FLAG_DDR_HIDDEN)) {
+ dev->av_table.av_map = ioremap(pci_resource_start(dev->pdev, 4) +
+ dev->av_table.ddr_av_base -
+ dev->ddr_start,
+ dev->av_table.num_ddr_avs *
+ MTHCA_AV_SIZE);
+ if (!dev->av_table.av_map)
+ goto out_free_pool;
+ } else
+ dev->av_table.av_map = NULL;
+
+ return 0;
+
+ out_free_pool:
+ pci_pool_destroy(dev->av_table.pool);
+
+ out_free_alloc:
+ mthca_alloc_cleanup(&dev->av_table.alloc);
+ return -ENOMEM;
+}
+
+void mthca_cleanup_av_table(struct mthca_dev *dev)
+{
+ if (mthca_is_memfree(dev))
+ return;
+
+ if (dev->av_table.av_map)
+ iounmap(dev->av_table.av_map);
+ pci_pool_destroy(dev->av_table.pool);
+ mthca_alloc_cleanup(&dev->av_table.alloc);
+}
diff --git a/sys/dev/mthca/mthca_catas.c b/sys/dev/mthca/mthca_catas.c
new file mode 100644
index 0000000..9a66e87
--- /dev/null
+++ b/sys/dev/mthca/mthca_catas.c
@@ -0,0 +1,202 @@
+/*
+ * Copyright (c) 2005 Cisco Systems. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#define LINUXKPI_PARAM_PREFIX mthca_
+
+#include <linux/jiffies.h>
+#include <linux/module.h>
+#include <linux/timer.h>
+#include <linux/workqueue.h>
+
+#include "mthca_dev.h"
+
+#define MTHCA_CATAS_POLL_INTERVAL (5 * HZ)
+
+enum {
+ MTHCA_CATAS_TYPE_INTERNAL = 0,
+ MTHCA_CATAS_TYPE_UPLINK = 3,
+ MTHCA_CATAS_TYPE_DDR = 4,
+ MTHCA_CATAS_TYPE_PARITY = 5,
+};
+
+static DEFINE_SPINLOCK(catas_lock);
+
+static LIST_HEAD(catas_list);
+static struct workqueue_struct *catas_wq;
+static struct work_struct catas_work;
+
+static int catas_reset_disable;
+module_param_named(catas_reset_disable, catas_reset_disable, int, 0644);
+MODULE_PARM_DESC(catas_reset_disable, "disable reset on catastrophic event if nonzero");
+
+static void catas_reset(struct work_struct *work)
+{
+ struct mthca_dev *dev, *tmpdev;
+ LIST_HEAD(tlist);
+ int ret;
+
+ mutex_lock(&mthca_device_mutex);
+
+ spin_lock_irq(&catas_lock);
+ list_splice_init(&catas_list, &tlist);
+ spin_unlock_irq(&catas_lock);
+
+ list_for_each_entry_safe(dev, tmpdev, &tlist, catas_err.list) {
+ struct pci_dev *pdev = dev->pdev;
+ ret = __mthca_restart_one(dev->pdev);
+ /* 'dev' now is not valid */
+ if (ret)
+ printk(KERN_ERR "mthca %s: Reset failed (%d)\n",
+ pci_name(pdev), ret);
+ else {
+ struct mthca_dev *d = pci_get_drvdata(pdev);
+ mthca_dbg(d, "Reset succeeded\n");
+ }
+ }
+
+ mutex_unlock(&mthca_device_mutex);
+}
+
+static void handle_catas(struct mthca_dev *dev)
+{
+ struct ib_event event;
+ unsigned long flags;
+ const char *type;
+ int i;
+
+ event.device = &dev->ib_dev;
+ event.event = IB_EVENT_DEVICE_FATAL;
+ event.element.port_num = 0;
+ dev->active = false;
+
+ ib_dispatch_event(&event);
+
+ switch (swab32(readl(dev->catas_err.map)) >> 24) {
+ case MTHCA_CATAS_TYPE_INTERNAL:
+ type = "internal error";
+ break;
+ case MTHCA_CATAS_TYPE_UPLINK:
+ type = "uplink bus error";
+ break;
+ case MTHCA_CATAS_TYPE_DDR:
+ type = "DDR data error";
+ break;
+ case MTHCA_CATAS_TYPE_PARITY:
+ type = "internal parity error";
+ break;
+ default:
+ type = "unknown error";
+ break;
+ }
+
+ mthca_err(dev, "Catastrophic error detected: %s\n", type);
+ for (i = 0; i < dev->catas_err.size; ++i)
+ mthca_err(dev, " buf[%02x]: %08x\n",
+ i, swab32(readl(dev->catas_err.map + i)));
+
+ if (catas_reset_disable)
+ return;
+
+ spin_lock_irqsave(&catas_lock, flags);
+ list_add(&dev->catas_err.list, &catas_list);
+ queue_work(catas_wq, &catas_work);
+ spin_unlock_irqrestore(&catas_lock, flags);
+}
+
+static void poll_catas(unsigned long dev_ptr)
+{
+ struct mthca_dev *dev = (struct mthca_dev *) dev_ptr;
+ int i;
+
+ for (i = 0; i < dev->catas_err.size; ++i)
+ if (readl(dev->catas_err.map + i)) {
+ handle_catas(dev);
+ return;
+ }
+
+ mod_timer(&dev->catas_err.timer,
+ round_jiffies(jiffies + MTHCA_CATAS_POLL_INTERVAL));
+}
+
+void mthca_start_catas_poll(struct mthca_dev *dev)
+{
+ phys_addr_t addr;
+
+ init_timer(&dev->catas_err.timer);
+ dev->catas_err.map = NULL;
+
+ addr = pci_resource_start(dev->pdev, 0) +
+ ((pci_resource_len(dev->pdev, 0) - 1) &
+ dev->catas_err.addr);
+
+ dev->catas_err.map = ioremap(addr, dev->catas_err.size * 4);
+ if (!dev->catas_err.map) {
+ mthca_warn(dev, "couldn't map catastrophic error region "
+ "at 0x%llx/0x%x\n", (unsigned long long) addr,
+ dev->catas_err.size * 4);
+ return;
+ }
+
+ dev->catas_err.timer.data = (unsigned long) dev;
+ dev->catas_err.timer.function = poll_catas;
+ dev->catas_err.timer.expires = jiffies + MTHCA_CATAS_POLL_INTERVAL;
+ INIT_LIST_HEAD(&dev->catas_err.list);
+ add_timer(&dev->catas_err.timer);
+}
+
+void mthca_stop_catas_poll(struct mthca_dev *dev)
+{
+ del_timer_sync(&dev->catas_err.timer);
+
+ if (dev->catas_err.map)
+ iounmap(dev->catas_err.map);
+
+ spin_lock_irq(&catas_lock);
+ list_del(&dev->catas_err.list);
+ spin_unlock_irq(&catas_lock);
+}
+
+int __init mthca_catas_init(void)
+{
+ INIT_WORK(&catas_work, catas_reset);
+
+ catas_wq = alloc_ordered_workqueue("mthca_catas", WQ_MEM_RECLAIM);
+ if (!catas_wq)
+ return -ENOMEM;
+
+ return 0;
+}
+
+void mthca_catas_cleanup(void)
+{
+ destroy_workqueue(catas_wq);
+}
diff --git a/sys/dev/mthca/mthca_cmd.c b/sys/dev/mthca/mthca_cmd.c
new file mode 100644
index 0000000..e75620a
--- /dev/null
+++ b/sys/dev/mthca/mthca_cmd.c
@@ -0,0 +1,1968 @@
+/*
+ * Copyright (c) 2004, 2005 Topspin Communications. All rights reserved.
+ * Copyright (c) 2005 Mellanox Technologies. All rights reserved.
+ * Copyright (c) 2005, 2006 Cisco Systems. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#define LINUXKPI_PARAM_PREFIX mthca_
+
+#include <linux/completion.h>
+#include <linux/pci.h>
+#include <linux/errno.h>
+#include <linux/sched.h>
+#include <linux/module.h>
+#include <linux/slab.h>
+#include <linux/page.h>
+#include <asm/io.h>
+#include <rdma/ib_mad.h>
+
+#include "mthca_dev.h"
+#include "mthca_config_reg.h"
+#include "mthca_cmd.h"
+#include "mthca_memfree.h"
+
+#define CMD_POLL_TOKEN 0xffff
+
+enum {
+ HCR_IN_PARAM_OFFSET = 0x00,
+ HCR_IN_MODIFIER_OFFSET = 0x08,
+ HCR_OUT_PARAM_OFFSET = 0x0c,
+ HCR_TOKEN_OFFSET = 0x14,
+ HCR_STATUS_OFFSET = 0x18,
+
+ HCR_OPMOD_SHIFT = 12,
+ HCA_E_BIT = 22,
+ HCR_GO_BIT = 23
+};
+
+enum {
+ /* initialization and general commands */
+ CMD_SYS_EN = 0x1,
+ CMD_SYS_DIS = 0x2,
+ CMD_MAP_FA = 0xfff,
+ CMD_UNMAP_FA = 0xffe,
+ CMD_RUN_FW = 0xff6,
+ CMD_MOD_STAT_CFG = 0x34,
+ CMD_QUERY_DEV_LIM = 0x3,
+ CMD_QUERY_FW = 0x4,
+ CMD_ENABLE_LAM = 0xff8,
+ CMD_DISABLE_LAM = 0xff7,
+ CMD_QUERY_DDR = 0x5,
+ CMD_QUERY_ADAPTER = 0x6,
+ CMD_INIT_HCA = 0x7,
+ CMD_CLOSE_HCA = 0x8,
+ CMD_INIT_IB = 0x9,
+ CMD_CLOSE_IB = 0xa,
+ CMD_QUERY_HCA = 0xb,
+ CMD_SET_IB = 0xc,
+ CMD_ACCESS_DDR = 0x2e,
+ CMD_MAP_ICM = 0xffa,
+ CMD_UNMAP_ICM = 0xff9,
+ CMD_MAP_ICM_AUX = 0xffc,
+ CMD_UNMAP_ICM_AUX = 0xffb,
+ CMD_SET_ICM_SIZE = 0xffd,
+
+ /* TPT commands */
+ CMD_SW2HW_MPT = 0xd,
+ CMD_QUERY_MPT = 0xe,
+ CMD_HW2SW_MPT = 0xf,
+ CMD_READ_MTT = 0x10,
+ CMD_WRITE_MTT = 0x11,
+ CMD_SYNC_TPT = 0x2f,
+
+ /* EQ commands */
+ CMD_MAP_EQ = 0x12,
+ CMD_SW2HW_EQ = 0x13,
+ CMD_HW2SW_EQ = 0x14,
+ CMD_QUERY_EQ = 0x15,
+
+ /* CQ commands */
+ CMD_SW2HW_CQ = 0x16,
+ CMD_HW2SW_CQ = 0x17,
+ CMD_QUERY_CQ = 0x18,
+ CMD_RESIZE_CQ = 0x2c,
+
+ /* SRQ commands */
+ CMD_SW2HW_SRQ = 0x35,
+ CMD_HW2SW_SRQ = 0x36,
+ CMD_QUERY_SRQ = 0x37,
+ CMD_ARM_SRQ = 0x40,
+
+ /* QP/EE commands */
+ CMD_RST2INIT_QPEE = 0x19,
+ CMD_INIT2RTR_QPEE = 0x1a,
+ CMD_RTR2RTS_QPEE = 0x1b,
+ CMD_RTS2RTS_QPEE = 0x1c,
+ CMD_SQERR2RTS_QPEE = 0x1d,
+ CMD_2ERR_QPEE = 0x1e,
+ CMD_RTS2SQD_QPEE = 0x1f,
+ CMD_SQD2SQD_QPEE = 0x38,
+ CMD_SQD2RTS_QPEE = 0x20,
+ CMD_ERR2RST_QPEE = 0x21,
+ CMD_QUERY_QPEE = 0x22,
+ CMD_INIT2INIT_QPEE = 0x2d,
+ CMD_SUSPEND_QPEE = 0x32,
+ CMD_UNSUSPEND_QPEE = 0x33,
+ /* special QPs and management commands */
+ CMD_CONF_SPECIAL_QP = 0x23,
+ CMD_MAD_IFC = 0x24,
+
+ /* multicast commands */
+ CMD_READ_MGM = 0x25,
+ CMD_WRITE_MGM = 0x26,
+ CMD_MGID_HASH = 0x27,
+
+ /* miscellaneous commands */
+ CMD_DIAG_RPRT = 0x30,
+ CMD_NOP = 0x31,
+
+ /* debug commands */
+ CMD_QUERY_DEBUG_MSG = 0x2a,
+ CMD_SET_DEBUG_MSG = 0x2b,
+};
+
+/*
+ * According to Mellanox code, FW may be starved and never complete
+ * commands. So we can't use strict timeouts described in PRM -- we
+ * just arbitrarily select 60 seconds for now.
+ */
+#if 0
+/*
+ * Round up and add 1 to make sure we get the full wait time (since we
+ * will be starting in the middle of a jiffy)
+ */
+enum {
+ CMD_TIME_CLASS_A = (HZ + 999) / 1000 + 1,
+ CMD_TIME_CLASS_B = (HZ + 99) / 100 + 1,
+ CMD_TIME_CLASS_C = (HZ + 9) / 10 + 1,
+ CMD_TIME_CLASS_D = 60 * HZ
+};
+#else
+#define CMD_TIME_CLASS_A (60 * HZ)
+#define CMD_TIME_CLASS_B (60 * HZ)
+#define CMD_TIME_CLASS_C (60 * HZ)
+#define CMD_TIME_CLASS_D (60 * HZ)
+#endif
+
+#define GO_BIT_TIMEOUT (HZ * 10)
+
+struct mthca_cmd_context {
+ struct completion done;
+ int result;
+ int next;
+ u64 out_param;
+ u16 token;
+ u8 status;
+};
+
+static int fw_cmd_doorbell = 0;
+module_param(fw_cmd_doorbell, int, 0644);
+MODULE_PARM_DESC(fw_cmd_doorbell, "post FW commands through doorbell page if nonzero "
+ "(and supported by FW)");
+
+static inline int go_bit(struct mthca_dev *dev)
+{
+ return readl(dev->hcr + HCR_STATUS_OFFSET) &
+ swab32(1 << HCR_GO_BIT);
+}
+
+static void mthca_cmd_post_dbell(struct mthca_dev *dev,
+ u64 in_param,
+ u64 out_param,
+ u32 in_modifier,
+ u8 op_modifier,
+ u16 op,
+ u16 token)
+{
+ void __iomem *ptr = dev->cmd.dbell_map;
+ u16 *offs = dev->cmd.dbell_offsets;
+
+ __raw_writel((__force u32) cpu_to_be32(in_param >> 32), ptr + offs[0]);
+ wmb();
+ __raw_writel((__force u32) cpu_to_be32(in_param & 0xfffffffful), ptr + offs[1]);
+ wmb();
+ __raw_writel((__force u32) cpu_to_be32(in_modifier), ptr + offs[2]);
+ wmb();
+ __raw_writel((__force u32) cpu_to_be32(out_param >> 32), ptr + offs[3]);
+ wmb();
+ __raw_writel((__force u32) cpu_to_be32(out_param & 0xfffffffful), ptr + offs[4]);
+ wmb();
+ __raw_writel((__force u32) cpu_to_be32(token << 16), ptr + offs[5]);
+ wmb();
+ __raw_writel((__force u32) cpu_to_be32((1 << HCR_GO_BIT) |
+ (1 << HCA_E_BIT) |
+ (op_modifier << HCR_OPMOD_SHIFT) |
+ op), ptr + offs[6]);
+ wmb();
+ __raw_writel((__force u32) 0, ptr + offs[7]);
+ wmb();
+}
+
+static int mthca_cmd_post_hcr(struct mthca_dev *dev,
+ u64 in_param,
+ u64 out_param,
+ u32 in_modifier,
+ u8 op_modifier,
+ u16 op,
+ u16 token,
+ int event)
+{
+ if (event) {
+ unsigned long end = jiffies + GO_BIT_TIMEOUT;
+
+ while (go_bit(dev) && time_before(jiffies, end)) {
+ set_current_state(TASK_RUNNING);
+ schedule();
+ }
+ }
+
+ if (go_bit(dev))
+ return -EAGAIN;
+
+ /*
+ * We use writel (instead of something like memcpy_toio)
+ * because writes of less than 32 bits to the HCR don't work
+ * (and some architectures such as ia64 implement memcpy_toio
+ * in terms of writeb).
+ */
+ __raw_writel((__force u32) cpu_to_be32(in_param >> 32), dev->hcr + 0 * 4);
+ __raw_writel((__force u32) cpu_to_be32(in_param & 0xfffffffful), dev->hcr + 1 * 4);
+ __raw_writel((__force u32) cpu_to_be32(in_modifier), dev->hcr + 2 * 4);
+ __raw_writel((__force u32) cpu_to_be32(out_param >> 32), dev->hcr + 3 * 4);
+ __raw_writel((__force u32) cpu_to_be32(out_param & 0xfffffffful), dev->hcr + 4 * 4);
+ __raw_writel((__force u32) cpu_to_be32(token << 16), dev->hcr + 5 * 4);
+
+ /* __raw_writel may not order writes. */
+ wmb();
+
+ __raw_writel((__force u32) cpu_to_be32((1 << HCR_GO_BIT) |
+ (event ? (1 << HCA_E_BIT) : 0) |
+ (op_modifier << HCR_OPMOD_SHIFT) |
+ op), dev->hcr + 6 * 4);
+
+ return 0;
+}
+
+static int mthca_cmd_post(struct mthca_dev *dev,
+ u64 in_param,
+ u64 out_param,
+ u32 in_modifier,
+ u8 op_modifier,
+ u16 op,
+ u16 token,
+ int event)
+{
+ int err = 0;
+
+ mutex_lock(&dev->cmd.hcr_mutex);
+
+ if (event && dev->cmd.flags & MTHCA_CMD_POST_DOORBELLS && fw_cmd_doorbell)
+ mthca_cmd_post_dbell(dev, in_param, out_param, in_modifier,
+ op_modifier, op, token);
+ else
+ err = mthca_cmd_post_hcr(dev, in_param, out_param, in_modifier,
+ op_modifier, op, token, event);
+
+ /*
+ * Make sure that our HCR writes don't get mixed in with
+ * writes from another CPU starting a FW command.
+ */
+ mmiowb();
+
+ mutex_unlock(&dev->cmd.hcr_mutex);
+ return err;
+}
+
+
+static int mthca_status_to_errno(u8 status)
+{
+ static const int trans_table[] = {
+ [MTHCA_CMD_STAT_INTERNAL_ERR] = -EIO,
+ [MTHCA_CMD_STAT_BAD_OP] = -EPERM,
+ [MTHCA_CMD_STAT_BAD_PARAM] = -EINVAL,
+ [MTHCA_CMD_STAT_BAD_SYS_STATE] = -ENXIO,
+ [MTHCA_CMD_STAT_BAD_RESOURCE] = -EBADF,
+ [MTHCA_CMD_STAT_RESOURCE_BUSY] = -EBUSY,
+ [MTHCA_CMD_STAT_DDR_MEM_ERR] = -ENOMEM,
+ [MTHCA_CMD_STAT_EXCEED_LIM] = -ENOMEM,
+ [MTHCA_CMD_STAT_BAD_RES_STATE] = -EBADF,
+ [MTHCA_CMD_STAT_BAD_INDEX] = -EBADF,
+ [MTHCA_CMD_STAT_BAD_NVMEM] = -EFAULT,
+ [MTHCA_CMD_STAT_BAD_QPEE_STATE] = -EINVAL,
+ [MTHCA_CMD_STAT_BAD_SEG_PARAM] = -EFAULT,
+ [MTHCA_CMD_STAT_REG_BOUND] = -EBUSY,
+ [MTHCA_CMD_STAT_LAM_NOT_PRE] = -EAGAIN,
+ [MTHCA_CMD_STAT_BAD_PKT] = -EBADMSG,
+ [MTHCA_CMD_STAT_BAD_SIZE] = -ENOMEM,
+ };
+
+ if (status >= ARRAY_SIZE(trans_table) ||
+ (status != MTHCA_CMD_STAT_OK
+ && trans_table[status] == 0))
+ return -EINVAL;
+
+ return trans_table[status];
+}
+
+
+static int mthca_cmd_poll(struct mthca_dev *dev,
+ u64 in_param,
+ u64 *out_param,
+ int out_is_imm,
+ u32 in_modifier,
+ u8 op_modifier,
+ u16 op,
+ unsigned long timeout)
+{
+ int err = 0;
+ unsigned long end;
+ u8 status;
+
+ down(&dev->cmd.poll_sem);
+
+ err = mthca_cmd_post(dev, in_param,
+ out_param ? *out_param : 0,
+ in_modifier, op_modifier,
+ op, CMD_POLL_TOKEN, 0);
+ if (err)
+ goto out;
+
+ end = timeout + jiffies;
+ while (go_bit(dev) && time_before(jiffies, end)) {
+ set_current_state(TASK_RUNNING);
+ schedule();
+ }
+
+ if (go_bit(dev)) {
+ err = -EBUSY;
+ goto out;
+ }
+
+ if (out_is_imm)
+ *out_param =
+ (u64) be32_to_cpu((__force __be32)
+ __raw_readl(dev->hcr + HCR_OUT_PARAM_OFFSET)) << 32 |
+ (u64) be32_to_cpu((__force __be32)
+ __raw_readl(dev->hcr + HCR_OUT_PARAM_OFFSET + 4));
+
+ status = be32_to_cpu((__force __be32) __raw_readl(dev->hcr + HCR_STATUS_OFFSET)) >> 24;
+ if (status) {
+ mthca_dbg(dev, "Command %02x completed with status %02x\n",
+ op, status);
+ err = mthca_status_to_errno(status);
+ }
+
+out:
+ up(&dev->cmd.poll_sem);
+ return err;
+}
+
+void mthca_cmd_event(struct mthca_dev *dev,
+ u16 token,
+ u8 status,
+ u64 out_param)
+{
+ struct mthca_cmd_context *context =
+ &dev->cmd.context[token & dev->cmd.token_mask];
+
+ /* previously timed out command completing at long last */
+ if (token != context->token)
+ return;
+
+ context->result = 0;
+ context->status = status;
+ context->out_param = out_param;
+
+ complete(&context->done);
+}
+
+static int mthca_cmd_wait(struct mthca_dev *dev,
+ u64 in_param,
+ u64 *out_param,
+ int out_is_imm,
+ u32 in_modifier,
+ u8 op_modifier,
+ u16 op,
+ unsigned long timeout)
+{
+ int err = 0;
+ struct mthca_cmd_context *context;
+
+ down(&dev->cmd.event_sem);
+
+ spin_lock(&dev->cmd.context_lock);
+ BUG_ON(dev->cmd.free_head < 0);
+ context = &dev->cmd.context[dev->cmd.free_head];
+ context->token += dev->cmd.token_mask + 1;
+ dev->cmd.free_head = context->next;
+ spin_unlock(&dev->cmd.context_lock);
+
+ init_completion(&context->done);
+
+ err = mthca_cmd_post(dev, in_param,
+ out_param ? *out_param : 0,
+ in_modifier, op_modifier,
+ op, context->token, 1);
+ if (err)
+ goto out;
+
+ if (!wait_for_completion_timeout(&context->done, timeout)) {
+ err = -EBUSY;
+ goto out;
+ }
+
+ err = context->result;
+ if (err)
+ goto out;
+
+ if (context->status) {
+ mthca_dbg(dev, "Command %02x completed with status %02x\n",
+ op, context->status);
+ err = mthca_status_to_errno(context->status);
+ }
+
+ if (out_is_imm)
+ *out_param = context->out_param;
+
+out:
+ spin_lock(&dev->cmd.context_lock);
+ context->next = dev->cmd.free_head;
+ dev->cmd.free_head = context - dev->cmd.context;
+ spin_unlock(&dev->cmd.context_lock);
+
+ up(&dev->cmd.event_sem);
+ return err;
+}
+
+/* Invoke a command with an output mailbox */
+static int mthca_cmd_box(struct mthca_dev *dev,
+ u64 in_param,
+ u64 out_param,
+ u32 in_modifier,
+ u8 op_modifier,
+ u16 op,
+ unsigned long timeout)
+{
+ if (dev->cmd.flags & MTHCA_CMD_USE_EVENTS)
+ return mthca_cmd_wait(dev, in_param, &out_param, 0,
+ in_modifier, op_modifier, op,
+ timeout);
+ else
+ return mthca_cmd_poll(dev, in_param, &out_param, 0,
+ in_modifier, op_modifier, op,
+ timeout);
+}
+
+/* Invoke a command with no output parameter */
+static int mthca_cmd(struct mthca_dev *dev,
+ u64 in_param,
+ u32 in_modifier,
+ u8 op_modifier,
+ u16 op,
+ unsigned long timeout)
+{
+ return mthca_cmd_box(dev, in_param, 0, in_modifier,
+ op_modifier, op, timeout);
+}
+
+/*
+ * Invoke a command with an immediate output parameter (and copy the
+ * output into the caller's out_param pointer after the command
+ * executes).
+ */
+static int mthca_cmd_imm(struct mthca_dev *dev,
+ u64 in_param,
+ u64 *out_param,
+ u32 in_modifier,
+ u8 op_modifier,
+ u16 op,
+ unsigned long timeout)
+{
+ if (dev->cmd.flags & MTHCA_CMD_USE_EVENTS)
+ return mthca_cmd_wait(dev, in_param, out_param, 1,
+ in_modifier, op_modifier, op,
+ timeout);
+ else
+ return mthca_cmd_poll(dev, in_param, out_param, 1,
+ in_modifier, op_modifier, op,
+ timeout);
+}
+
+int mthca_cmd_init(struct mthca_dev *dev)
+{
+ mutex_init(&dev->cmd.hcr_mutex);
+ sema_init(&dev->cmd.poll_sem, 1);
+ dev->cmd.flags = 0;
+
+ dev->hcr = ioremap(pci_resource_start(dev->pdev, 0) + MTHCA_HCR_BASE,
+ MTHCA_HCR_SIZE);
+ if (!dev->hcr) {
+ mthca_err(dev, "Couldn't map command register.");
+ return -ENOMEM;
+ }
+
+ dev->cmd.pool = pci_pool_create("mthca_cmd", dev->pdev,
+ MTHCA_MAILBOX_SIZE,
+ MTHCA_MAILBOX_SIZE, 0);
+ if (!dev->cmd.pool) {
+ iounmap(dev->hcr);
+ return -ENOMEM;
+ }
+
+ return 0;
+}
+
+void mthca_cmd_cleanup(struct mthca_dev *dev)
+{
+ pci_pool_destroy(dev->cmd.pool);
+ iounmap(dev->hcr);
+ if (dev->cmd.flags & MTHCA_CMD_POST_DOORBELLS)
+ iounmap(dev->cmd.dbell_map);
+}
+
+/*
+ * Switch to using events to issue FW commands (should be called after
+ * event queue to command events has been initialized).
+ */
+int mthca_cmd_use_events(struct mthca_dev *dev)
+{
+ int i;
+
+ dev->cmd.context = kmalloc(dev->cmd.max_cmds *
+ sizeof (struct mthca_cmd_context),
+ GFP_KERNEL);
+ if (!dev->cmd.context)
+ return -ENOMEM;
+
+ for (i = 0; i < dev->cmd.max_cmds; ++i) {
+ dev->cmd.context[i].token = i;
+ dev->cmd.context[i].next = i + 1;
+ }
+
+ dev->cmd.context[dev->cmd.max_cmds - 1].next = -1;
+ dev->cmd.free_head = 0;
+
+ sema_init(&dev->cmd.event_sem, dev->cmd.max_cmds);
+ spin_lock_init(&dev->cmd.context_lock);
+
+ for (dev->cmd.token_mask = 1;
+ dev->cmd.token_mask < dev->cmd.max_cmds;
+ dev->cmd.token_mask <<= 1)
+ ; /* nothing */
+ --dev->cmd.token_mask;
+
+ dev->cmd.flags |= MTHCA_CMD_USE_EVENTS;
+
+ down(&dev->cmd.poll_sem);
+
+ return 0;
+}
+
+/*
+ * Switch back to polling (used when shutting down the device)
+ */
+void mthca_cmd_use_polling(struct mthca_dev *dev)
+{
+ int i;
+
+ dev->cmd.flags &= ~MTHCA_CMD_USE_EVENTS;
+
+ for (i = 0; i < dev->cmd.max_cmds; ++i)
+ down(&dev->cmd.event_sem);
+
+ kfree(dev->cmd.context);
+
+ up(&dev->cmd.poll_sem);
+}
+
+struct mthca_mailbox *mthca_alloc_mailbox(struct mthca_dev *dev,
+ gfp_t gfp_mask)
+{
+ struct mthca_mailbox *mailbox;
+
+ mailbox = kmalloc(sizeof *mailbox, gfp_mask);
+ if (!mailbox)
+ return ERR_PTR(-ENOMEM);
+
+ mailbox->buf = pci_pool_alloc(dev->cmd.pool, gfp_mask, &mailbox->dma);
+ if (!mailbox->buf) {
+ kfree(mailbox);
+ return ERR_PTR(-ENOMEM);
+ }
+
+ return mailbox;
+}
+
+void mthca_free_mailbox(struct mthca_dev *dev, struct mthca_mailbox *mailbox)
+{
+ if (!mailbox)
+ return;
+
+ pci_pool_free(dev->cmd.pool, mailbox->buf, mailbox->dma);
+ kfree(mailbox);
+}
+
+int mthca_SYS_EN(struct mthca_dev *dev)
+{
+ u64 out;
+ int ret;
+
+ ret = mthca_cmd_imm(dev, 0, &out, 0, 0, CMD_SYS_EN, CMD_TIME_CLASS_D);
+
+ if (ret == -ENOMEM)
+ mthca_warn(dev, "SYS_EN DDR error: syn=%x, sock=%d, "
+ "sladdr=%d, SPD source=%s\n",
+ (int) (out >> 6) & 0xf, (int) (out >> 4) & 3,
+ (int) (out >> 1) & 7, (int) out & 1 ? "NVMEM" : "DIMM");
+
+ return ret;
+}
+
+int mthca_SYS_DIS(struct mthca_dev *dev)
+{
+ return mthca_cmd(dev, 0, 0, 0, CMD_SYS_DIS, CMD_TIME_CLASS_C);
+}
+
+static int mthca_map_cmd(struct mthca_dev *dev, u16 op, struct mthca_icm *icm,
+ u64 virt)
+{
+ struct mthca_mailbox *mailbox;
+ struct mthca_icm_iter iter;
+ __be64 *pages;
+ int lg;
+ int nent = 0;
+ int i;
+ int err = 0;
+ int ts = 0, tc = 0;
+
+ mailbox = mthca_alloc_mailbox(dev, GFP_KERNEL);
+ if (IS_ERR(mailbox))
+ return PTR_ERR(mailbox);
+ memset(mailbox->buf, 0, MTHCA_MAILBOX_SIZE);
+ pages = mailbox->buf;
+
+ for (mthca_icm_first(icm, &iter);
+ !mthca_icm_last(&iter);
+ mthca_icm_next(&iter)) {
+ /*
+ * We have to pass pages that are aligned to their
+ * size, so find the least significant 1 in the
+ * address or size and use that as our log2 size.
+ */
+ lg = ffs(mthca_icm_addr(&iter) | mthca_icm_size(&iter)) - 1;
+ if (lg < MTHCA_ICM_PAGE_SHIFT) {
+ mthca_warn(dev, "Got FW area not aligned to %d (%llx/%lx).\n",
+ MTHCA_ICM_PAGE_SIZE,
+ (unsigned long long) mthca_icm_addr(&iter),
+ mthca_icm_size(&iter));
+ err = -EINVAL;
+ goto out;
+ }
+ for (i = 0; i < mthca_icm_size(&iter) >> lg; ++i) {
+ if (virt != -1) {
+ pages[nent * 2] = cpu_to_be64(virt);
+ virt += 1 << lg;
+ }
+
+ pages[nent * 2 + 1] =
+ cpu_to_be64((mthca_icm_addr(&iter) + (i << lg)) |
+ (lg - MTHCA_ICM_PAGE_SHIFT));
+ ts += 1 << (lg - 10);
+ ++tc;
+
+ if (++nent == MTHCA_MAILBOX_SIZE / 16) {
+ err = mthca_cmd(dev, mailbox->dma, nent, 0, op,
+ CMD_TIME_CLASS_B);
+ if (err)
+ goto out;
+ nent = 0;
+ }
+ }
+ }
+
+ if (nent)
+ err = mthca_cmd(dev, mailbox->dma, nent, 0, op,
+ CMD_TIME_CLASS_B);
+
+ switch (op) {
+ case CMD_MAP_FA:
+ mthca_dbg(dev, "Mapped %d chunks/%d KB for FW.\n", tc, ts);
+ break;
+ case CMD_MAP_ICM_AUX:
+ mthca_dbg(dev, "Mapped %d chunks/%d KB for ICM aux.\n", tc, ts);
+ break;
+ case CMD_MAP_ICM:
+ mthca_dbg(dev, "Mapped %d chunks/%d KB at %llx for ICM.\n",
+ tc, ts, (unsigned long long) virt - (ts << 10));
+ break;
+ }
+
+out:
+ mthca_free_mailbox(dev, mailbox);
+ return err;
+}
+
+int mthca_MAP_FA(struct mthca_dev *dev, struct mthca_icm *icm)
+{
+ return mthca_map_cmd(dev, CMD_MAP_FA, icm, -1);
+}
+
+int mthca_UNMAP_FA(struct mthca_dev *dev)
+{
+ return mthca_cmd(dev, 0, 0, 0, CMD_UNMAP_FA, CMD_TIME_CLASS_B);
+}
+
+int mthca_RUN_FW(struct mthca_dev *dev)
+{
+ return mthca_cmd(dev, 0, 0, 0, CMD_RUN_FW, CMD_TIME_CLASS_A);
+}
+
+static void mthca_setup_cmd_doorbells(struct mthca_dev *dev, u64 base)
+{
+ phys_addr_t addr;
+ u16 max_off = 0;
+ int i;
+
+ for (i = 0; i < 8; ++i)
+ max_off = max(max_off, dev->cmd.dbell_offsets[i]);
+
+ if ((base & PAGE_MASK) != ((base + max_off) & PAGE_MASK)) {
+ mthca_warn(dev, "Firmware doorbell region at 0x%016llx, "
+ "length 0x%x crosses a page boundary\n",
+ (unsigned long long) base, max_off);
+ return;
+ }
+
+ addr = pci_resource_start(dev->pdev, 2) +
+ ((pci_resource_len(dev->pdev, 2) - 1) & base);
+ dev->cmd.dbell_map = ioremap(addr, max_off + sizeof(u32));
+ if (!dev->cmd.dbell_map)
+ return;
+
+ dev->cmd.flags |= MTHCA_CMD_POST_DOORBELLS;
+ mthca_dbg(dev, "Mapped doorbell page for posting FW commands\n");
+}
+
+int mthca_QUERY_FW(struct mthca_dev *dev)
+{
+ struct mthca_mailbox *mailbox;
+ u32 *outbox;
+ u64 base;
+ u32 tmp;
+ int err = 0;
+ u8 lg;
+ int i;
+
+#define QUERY_FW_OUT_SIZE 0x100
+#define QUERY_FW_VER_OFFSET 0x00
+#define QUERY_FW_MAX_CMD_OFFSET 0x0f
+#define QUERY_FW_ERR_START_OFFSET 0x30
+#define QUERY_FW_ERR_SIZE_OFFSET 0x38
+
+#define QUERY_FW_CMD_DB_EN_OFFSET 0x10
+#define QUERY_FW_CMD_DB_OFFSET 0x50
+#define QUERY_FW_CMD_DB_BASE 0x60
+
+#define QUERY_FW_START_OFFSET 0x20
+#define QUERY_FW_END_OFFSET 0x28
+
+#define QUERY_FW_SIZE_OFFSET 0x00
+#define QUERY_FW_CLR_INT_BASE_OFFSET 0x20
+#define QUERY_FW_EQ_ARM_BASE_OFFSET 0x40
+#define QUERY_FW_EQ_SET_CI_BASE_OFFSET 0x48
+
+ mailbox = mthca_alloc_mailbox(dev, GFP_KERNEL);
+ if (IS_ERR(mailbox))
+ return PTR_ERR(mailbox);
+ outbox = mailbox->buf;
+
+ err = mthca_cmd_box(dev, 0, mailbox->dma, 0, 0, CMD_QUERY_FW,
+ CMD_TIME_CLASS_A);
+
+ if (err)
+ goto out;
+
+ MTHCA_GET(dev->fw_ver, outbox, QUERY_FW_VER_OFFSET);
+ /*
+ * FW subminor version is at more significant bits than minor
+ * version, so swap here.
+ */
+ dev->fw_ver = (dev->fw_ver & 0xffff00000000ull) |
+ ((dev->fw_ver & 0xffff0000ull) >> 16) |
+ ((dev->fw_ver & 0x0000ffffull) << 16);
+
+ MTHCA_GET(lg, outbox, QUERY_FW_MAX_CMD_OFFSET);
+ dev->cmd.max_cmds = 1 << lg;
+
+ mthca_dbg(dev, "FW version %012llx, max commands %d\n",
+ (unsigned long long) dev->fw_ver, dev->cmd.max_cmds);
+
+ MTHCA_GET(dev->catas_err.addr, outbox, QUERY_FW_ERR_START_OFFSET);
+ MTHCA_GET(dev->catas_err.size, outbox, QUERY_FW_ERR_SIZE_OFFSET);
+
+ mthca_dbg(dev, "Catastrophic error buffer at 0x%llx, size 0x%x\n",
+ (unsigned long long) dev->catas_err.addr, dev->catas_err.size);
+
+ MTHCA_GET(tmp, outbox, QUERY_FW_CMD_DB_EN_OFFSET);
+ if (tmp & 0x1) {
+ mthca_dbg(dev, "FW supports commands through doorbells\n");
+
+ MTHCA_GET(base, outbox, QUERY_FW_CMD_DB_BASE);
+ for (i = 0; i < MTHCA_CMD_NUM_DBELL_DWORDS; ++i)
+ MTHCA_GET(dev->cmd.dbell_offsets[i], outbox,
+ QUERY_FW_CMD_DB_OFFSET + (i << 1));
+
+ mthca_setup_cmd_doorbells(dev, base);
+ }
+
+ if (mthca_is_memfree(dev)) {
+ MTHCA_GET(dev->fw.arbel.fw_pages, outbox, QUERY_FW_SIZE_OFFSET);
+ MTHCA_GET(dev->fw.arbel.clr_int_base, outbox, QUERY_FW_CLR_INT_BASE_OFFSET);
+ MTHCA_GET(dev->fw.arbel.eq_arm_base, outbox, QUERY_FW_EQ_ARM_BASE_OFFSET);
+ MTHCA_GET(dev->fw.arbel.eq_set_ci_base, outbox, QUERY_FW_EQ_SET_CI_BASE_OFFSET);
+ mthca_dbg(dev, "FW size %d KB\n", dev->fw.arbel.fw_pages << 2);
+
+ /*
+ * Round up number of system pages needed in case
+ * MTHCA_ICM_PAGE_SIZE < PAGE_SIZE.
+ */
+ dev->fw.arbel.fw_pages =
+ ALIGN(dev->fw.arbel.fw_pages, PAGE_SIZE / MTHCA_ICM_PAGE_SIZE) >>
+ (PAGE_SHIFT - MTHCA_ICM_PAGE_SHIFT);
+
+ mthca_dbg(dev, "Clear int @ %llx, EQ arm @ %llx, EQ set CI @ %llx\n",
+ (unsigned long long) dev->fw.arbel.clr_int_base,
+ (unsigned long long) dev->fw.arbel.eq_arm_base,
+ (unsigned long long) dev->fw.arbel.eq_set_ci_base);
+ } else {
+ MTHCA_GET(dev->fw.tavor.fw_start, outbox, QUERY_FW_START_OFFSET);
+ MTHCA_GET(dev->fw.tavor.fw_end, outbox, QUERY_FW_END_OFFSET);
+
+ mthca_dbg(dev, "FW size %d KB (start %llx, end %llx)\n",
+ (int) ((dev->fw.tavor.fw_end - dev->fw.tavor.fw_start) >> 10),
+ (unsigned long long) dev->fw.tavor.fw_start,
+ (unsigned long long) dev->fw.tavor.fw_end);
+ }
+
+out:
+ mthca_free_mailbox(dev, mailbox);
+ return err;
+}
+
+int mthca_ENABLE_LAM(struct mthca_dev *dev)
+{
+ struct mthca_mailbox *mailbox;
+ u8 info;
+ u32 *outbox;
+ int err = 0;
+
+#define ENABLE_LAM_OUT_SIZE 0x100
+#define ENABLE_LAM_START_OFFSET 0x00
+#define ENABLE_LAM_END_OFFSET 0x08
+#define ENABLE_LAM_INFO_OFFSET 0x13
+
+#define ENABLE_LAM_INFO_HIDDEN_FLAG (1 << 4)
+#define ENABLE_LAM_INFO_ECC_MASK 0x3
+
+ mailbox = mthca_alloc_mailbox(dev, GFP_KERNEL);
+ if (IS_ERR(mailbox))
+ return PTR_ERR(mailbox);
+ outbox = mailbox->buf;
+
+ err = mthca_cmd_box(dev, 0, mailbox->dma, 0, 0, CMD_ENABLE_LAM,
+ CMD_TIME_CLASS_C);
+
+ if (err)
+ goto out;
+
+ MTHCA_GET(dev->ddr_start, outbox, ENABLE_LAM_START_OFFSET);
+ MTHCA_GET(dev->ddr_end, outbox, ENABLE_LAM_END_OFFSET);
+ MTHCA_GET(info, outbox, ENABLE_LAM_INFO_OFFSET);
+
+ if (!!(info & ENABLE_LAM_INFO_HIDDEN_FLAG) !=
+ !!(dev->mthca_flags & MTHCA_FLAG_DDR_HIDDEN)) {
+ mthca_info(dev, "FW reports that HCA-attached memory "
+ "is %s hidden; does not match PCI config\n",
+ (info & ENABLE_LAM_INFO_HIDDEN_FLAG) ?
+ "" : "not");
+ }
+ if (info & ENABLE_LAM_INFO_HIDDEN_FLAG)
+ mthca_dbg(dev, "HCA-attached memory is hidden.\n");
+
+ mthca_dbg(dev, "HCA memory size %d KB (start %llx, end %llx)\n",
+ (int) ((dev->ddr_end - dev->ddr_start) >> 10),
+ (unsigned long long) dev->ddr_start,
+ (unsigned long long) dev->ddr_end);
+
+out:
+ mthca_free_mailbox(dev, mailbox);
+ return err;
+}
+
+int mthca_DISABLE_LAM(struct mthca_dev *dev)
+{
+ return mthca_cmd(dev, 0, 0, 0, CMD_SYS_DIS, CMD_TIME_CLASS_C);
+}
+
+int mthca_QUERY_DDR(struct mthca_dev *dev)
+{
+ struct mthca_mailbox *mailbox;
+ u8 info;
+ u32 *outbox;
+ int err = 0;
+
+#define QUERY_DDR_OUT_SIZE 0x100
+#define QUERY_DDR_START_OFFSET 0x00
+#define QUERY_DDR_END_OFFSET 0x08
+#define QUERY_DDR_INFO_OFFSET 0x13
+
+#define QUERY_DDR_INFO_HIDDEN_FLAG (1 << 4)
+#define QUERY_DDR_INFO_ECC_MASK 0x3
+
+ mailbox = mthca_alloc_mailbox(dev, GFP_KERNEL);
+ if (IS_ERR(mailbox))
+ return PTR_ERR(mailbox);
+ outbox = mailbox->buf;
+
+ err = mthca_cmd_box(dev, 0, mailbox->dma, 0, 0, CMD_QUERY_DDR,
+ CMD_TIME_CLASS_A);
+
+ if (err)
+ goto out;
+
+ MTHCA_GET(dev->ddr_start, outbox, QUERY_DDR_START_OFFSET);
+ MTHCA_GET(dev->ddr_end, outbox, QUERY_DDR_END_OFFSET);
+ MTHCA_GET(info, outbox, QUERY_DDR_INFO_OFFSET);
+
+ if (!!(info & QUERY_DDR_INFO_HIDDEN_FLAG) !=
+ !!(dev->mthca_flags & MTHCA_FLAG_DDR_HIDDEN)) {
+ mthca_info(dev, "FW reports that HCA-attached memory "
+ "is %s hidden; does not match PCI config\n",
+ (info & QUERY_DDR_INFO_HIDDEN_FLAG) ?
+ "" : "not");
+ }
+ if (info & QUERY_DDR_INFO_HIDDEN_FLAG)
+ mthca_dbg(dev, "HCA-attached memory is hidden.\n");
+
+ mthca_dbg(dev, "HCA memory size %d KB (start %llx, end %llx)\n",
+ (int) ((dev->ddr_end - dev->ddr_start) >> 10),
+ (unsigned long long) dev->ddr_start,
+ (unsigned long long) dev->ddr_end);
+
+out:
+ mthca_free_mailbox(dev, mailbox);
+ return err;
+}
+
+int mthca_QUERY_DEV_LIM(struct mthca_dev *dev,
+ struct mthca_dev_lim *dev_lim)
+{
+ struct mthca_mailbox *mailbox;
+ u32 *outbox;
+ u8 field;
+ u16 size;
+ u16 stat_rate;
+ int err;
+
+#define QUERY_DEV_LIM_OUT_SIZE 0x100
+#define QUERY_DEV_LIM_MAX_SRQ_SZ_OFFSET 0x10
+#define QUERY_DEV_LIM_MAX_QP_SZ_OFFSET 0x11
+#define QUERY_DEV_LIM_RSVD_QP_OFFSET 0x12
+#define QUERY_DEV_LIM_MAX_QP_OFFSET 0x13
+#define QUERY_DEV_LIM_RSVD_SRQ_OFFSET 0x14
+#define QUERY_DEV_LIM_MAX_SRQ_OFFSET 0x15
+#define QUERY_DEV_LIM_RSVD_EEC_OFFSET 0x16
+#define QUERY_DEV_LIM_MAX_EEC_OFFSET 0x17
+#define QUERY_DEV_LIM_MAX_CQ_SZ_OFFSET 0x19
+#define QUERY_DEV_LIM_RSVD_CQ_OFFSET 0x1a
+#define QUERY_DEV_LIM_MAX_CQ_OFFSET 0x1b
+#define QUERY_DEV_LIM_MAX_MPT_OFFSET 0x1d
+#define QUERY_DEV_LIM_RSVD_EQ_OFFSET 0x1e
+#define QUERY_DEV_LIM_MAX_EQ_OFFSET 0x1f
+#define QUERY_DEV_LIM_RSVD_MTT_OFFSET 0x20
+#define QUERY_DEV_LIM_MAX_MRW_SZ_OFFSET 0x21
+#define QUERY_DEV_LIM_RSVD_MRW_OFFSET 0x22
+#define QUERY_DEV_LIM_MAX_MTT_SEG_OFFSET 0x23
+#define QUERY_DEV_LIM_MAX_AV_OFFSET 0x27
+#define QUERY_DEV_LIM_MAX_REQ_QP_OFFSET 0x29
+#define QUERY_DEV_LIM_MAX_RES_QP_OFFSET 0x2b
+#define QUERY_DEV_LIM_MAX_RDMA_OFFSET 0x2f
+#define QUERY_DEV_LIM_RSZ_SRQ_OFFSET 0x33
+#define QUERY_DEV_LIM_ACK_DELAY_OFFSET 0x35
+#define QUERY_DEV_LIM_MTU_WIDTH_OFFSET 0x36
+#define QUERY_DEV_LIM_VL_PORT_OFFSET 0x37
+#define QUERY_DEV_LIM_MAX_GID_OFFSET 0x3b
+#define QUERY_DEV_LIM_RATE_SUPPORT_OFFSET 0x3c
+#define QUERY_DEV_LIM_MAX_PKEY_OFFSET 0x3f
+#define QUERY_DEV_LIM_FLAGS_OFFSET 0x44
+#define QUERY_DEV_LIM_RSVD_UAR_OFFSET 0x48
+#define QUERY_DEV_LIM_UAR_SZ_OFFSET 0x49
+#define QUERY_DEV_LIM_PAGE_SZ_OFFSET 0x4b
+#define QUERY_DEV_LIM_MAX_SG_OFFSET 0x51
+#define QUERY_DEV_LIM_MAX_DESC_SZ_OFFSET 0x52
+#define QUERY_DEV_LIM_MAX_SG_RQ_OFFSET 0x55
+#define QUERY_DEV_LIM_MAX_DESC_SZ_RQ_OFFSET 0x56
+#define QUERY_DEV_LIM_MAX_QP_MCG_OFFSET 0x61
+#define QUERY_DEV_LIM_RSVD_MCG_OFFSET 0x62
+#define QUERY_DEV_LIM_MAX_MCG_OFFSET 0x63
+#define QUERY_DEV_LIM_RSVD_PD_OFFSET 0x64
+#define QUERY_DEV_LIM_MAX_PD_OFFSET 0x65
+#define QUERY_DEV_LIM_RSVD_RDD_OFFSET 0x66
+#define QUERY_DEV_LIM_MAX_RDD_OFFSET 0x67
+#define QUERY_DEV_LIM_EEC_ENTRY_SZ_OFFSET 0x80
+#define QUERY_DEV_LIM_QPC_ENTRY_SZ_OFFSET 0x82
+#define QUERY_DEV_LIM_EEEC_ENTRY_SZ_OFFSET 0x84
+#define QUERY_DEV_LIM_EQPC_ENTRY_SZ_OFFSET 0x86
+#define QUERY_DEV_LIM_EQC_ENTRY_SZ_OFFSET 0x88
+#define QUERY_DEV_LIM_CQC_ENTRY_SZ_OFFSET 0x8a
+#define QUERY_DEV_LIM_SRQ_ENTRY_SZ_OFFSET 0x8c
+#define QUERY_DEV_LIM_UAR_ENTRY_SZ_OFFSET 0x8e
+#define QUERY_DEV_LIM_MTT_ENTRY_SZ_OFFSET 0x90
+#define QUERY_DEV_LIM_MPT_ENTRY_SZ_OFFSET 0x92
+#define QUERY_DEV_LIM_PBL_SZ_OFFSET 0x96
+#define QUERY_DEV_LIM_BMME_FLAGS_OFFSET 0x97
+#define QUERY_DEV_LIM_RSVD_LKEY_OFFSET 0x98
+#define QUERY_DEV_LIM_LAMR_OFFSET 0x9f
+#define QUERY_DEV_LIM_MAX_ICM_SZ_OFFSET 0xa0
+
+ mailbox = mthca_alloc_mailbox(dev, GFP_KERNEL);
+ if (IS_ERR(mailbox))
+ return PTR_ERR(mailbox);
+ outbox = mailbox->buf;
+
+ err = mthca_cmd_box(dev, 0, mailbox->dma, 0, 0, CMD_QUERY_DEV_LIM,
+ CMD_TIME_CLASS_A);
+
+ if (err)
+ goto out;
+
+ MTHCA_GET(field, outbox, QUERY_DEV_LIM_RSVD_QP_OFFSET);
+ dev_lim->reserved_qps = 1 << (field & 0xf);
+ MTHCA_GET(field, outbox, QUERY_DEV_LIM_MAX_QP_OFFSET);
+ dev_lim->max_qps = 1 << (field & 0x1f);
+ MTHCA_GET(field, outbox, QUERY_DEV_LIM_RSVD_SRQ_OFFSET);
+ dev_lim->reserved_srqs = 1 << (field >> 4);
+ MTHCA_GET(field, outbox, QUERY_DEV_LIM_MAX_SRQ_OFFSET);
+ dev_lim->max_srqs = 1 << (field & 0x1f);
+ MTHCA_GET(field, outbox, QUERY_DEV_LIM_RSVD_EEC_OFFSET);
+ dev_lim->reserved_eecs = 1 << (field & 0xf);
+ MTHCA_GET(field, outbox, QUERY_DEV_LIM_MAX_EEC_OFFSET);
+ dev_lim->max_eecs = 1 << (field & 0x1f);
+ MTHCA_GET(field, outbox, QUERY_DEV_LIM_MAX_CQ_SZ_OFFSET);
+ dev_lim->max_cq_sz = 1 << field;
+ MTHCA_GET(field, outbox, QUERY_DEV_LIM_RSVD_CQ_OFFSET);
+ dev_lim->reserved_cqs = 1 << (field & 0xf);
+ MTHCA_GET(field, outbox, QUERY_DEV_LIM_MAX_CQ_OFFSET);
+ dev_lim->max_cqs = 1 << (field & 0x1f);
+ MTHCA_GET(field, outbox, QUERY_DEV_LIM_MAX_MPT_OFFSET);
+ dev_lim->max_mpts = 1 << (field & 0x3f);
+ MTHCA_GET(field, outbox, QUERY_DEV_LIM_RSVD_EQ_OFFSET);
+ dev_lim->reserved_eqs = 1 << (field & 0xf);
+ MTHCA_GET(field, outbox, QUERY_DEV_LIM_MAX_EQ_OFFSET);
+ dev_lim->max_eqs = 1 << (field & 0x7);
+ MTHCA_GET(field, outbox, QUERY_DEV_LIM_RSVD_MTT_OFFSET);
+ if (mthca_is_memfree(dev))
+ dev_lim->reserved_mtts = ALIGN((1 << (field >> 4)) * sizeof(u64),
+ dev->limits.mtt_seg_size) / dev->limits.mtt_seg_size;
+ else
+ dev_lim->reserved_mtts = 1 << (field >> 4);
+ MTHCA_GET(field, outbox, QUERY_DEV_LIM_MAX_MRW_SZ_OFFSET);
+ dev_lim->max_mrw_sz = 1 << field;
+ MTHCA_GET(field, outbox, QUERY_DEV_LIM_RSVD_MRW_OFFSET);
+ dev_lim->reserved_mrws = 1 << (field & 0xf);
+ MTHCA_GET(field, outbox, QUERY_DEV_LIM_MAX_MTT_SEG_OFFSET);
+ dev_lim->max_mtt_seg = 1 << (field & 0x3f);
+ MTHCA_GET(field, outbox, QUERY_DEV_LIM_MAX_REQ_QP_OFFSET);
+ dev_lim->max_requester_per_qp = 1 << (field & 0x3f);
+ MTHCA_GET(field, outbox, QUERY_DEV_LIM_MAX_RES_QP_OFFSET);
+ dev_lim->max_responder_per_qp = 1 << (field & 0x3f);
+ MTHCA_GET(field, outbox, QUERY_DEV_LIM_MAX_RDMA_OFFSET);
+ dev_lim->max_rdma_global = 1 << (field & 0x3f);
+ MTHCA_GET(field, outbox, QUERY_DEV_LIM_ACK_DELAY_OFFSET);
+ dev_lim->local_ca_ack_delay = field & 0x1f;
+ MTHCA_GET(field, outbox, QUERY_DEV_LIM_MTU_WIDTH_OFFSET);
+ dev_lim->max_mtu = field >> 4;
+ dev_lim->max_port_width = field & 0xf;
+ MTHCA_GET(field, outbox, QUERY_DEV_LIM_VL_PORT_OFFSET);
+ dev_lim->max_vl = field >> 4;
+ dev_lim->num_ports = field & 0xf;
+ MTHCA_GET(field, outbox, QUERY_DEV_LIM_MAX_GID_OFFSET);
+ dev_lim->max_gids = 1 << (field & 0xf);
+ MTHCA_GET(stat_rate, outbox, QUERY_DEV_LIM_RATE_SUPPORT_OFFSET);
+ dev_lim->stat_rate_support = stat_rate;
+ MTHCA_GET(field, outbox, QUERY_DEV_LIM_MAX_PKEY_OFFSET);
+ dev_lim->max_pkeys = 1 << (field & 0xf);
+ MTHCA_GET(dev_lim->flags, outbox, QUERY_DEV_LIM_FLAGS_OFFSET);
+ MTHCA_GET(field, outbox, QUERY_DEV_LIM_RSVD_UAR_OFFSET);
+ dev_lim->reserved_uars = field >> 4;
+ MTHCA_GET(field, outbox, QUERY_DEV_LIM_UAR_SZ_OFFSET);
+ dev_lim->uar_size = 1 << ((field & 0x3f) + 20);
+ MTHCA_GET(field, outbox, QUERY_DEV_LIM_PAGE_SZ_OFFSET);
+ dev_lim->min_page_sz = 1 << field;
+ MTHCA_GET(field, outbox, QUERY_DEV_LIM_MAX_SG_OFFSET);
+ dev_lim->max_sg = field;
+
+ MTHCA_GET(size, outbox, QUERY_DEV_LIM_MAX_DESC_SZ_OFFSET);
+ dev_lim->max_desc_sz = size;
+
+ MTHCA_GET(field, outbox, QUERY_DEV_LIM_MAX_QP_MCG_OFFSET);
+ dev_lim->max_qp_per_mcg = 1 << field;
+ MTHCA_GET(field, outbox, QUERY_DEV_LIM_RSVD_MCG_OFFSET);
+ dev_lim->reserved_mgms = field & 0xf;
+ MTHCA_GET(field, outbox, QUERY_DEV_LIM_MAX_MCG_OFFSET);
+ dev_lim->max_mcgs = 1 << field;
+ MTHCA_GET(field, outbox, QUERY_DEV_LIM_RSVD_PD_OFFSET);
+ dev_lim->reserved_pds = field >> 4;
+ MTHCA_GET(field, outbox, QUERY_DEV_LIM_MAX_PD_OFFSET);
+ dev_lim->max_pds = 1 << (field & 0x3f);
+ MTHCA_GET(field, outbox, QUERY_DEV_LIM_RSVD_RDD_OFFSET);
+ dev_lim->reserved_rdds = field >> 4;
+ MTHCA_GET(field, outbox, QUERY_DEV_LIM_MAX_RDD_OFFSET);
+ dev_lim->max_rdds = 1 << (field & 0x3f);
+
+ MTHCA_GET(size, outbox, QUERY_DEV_LIM_EEC_ENTRY_SZ_OFFSET);
+ dev_lim->eec_entry_sz = size;
+ MTHCA_GET(size, outbox, QUERY_DEV_LIM_QPC_ENTRY_SZ_OFFSET);
+ dev_lim->qpc_entry_sz = size;
+ MTHCA_GET(size, outbox, QUERY_DEV_LIM_EEEC_ENTRY_SZ_OFFSET);
+ dev_lim->eeec_entry_sz = size;
+ MTHCA_GET(size, outbox, QUERY_DEV_LIM_EQPC_ENTRY_SZ_OFFSET);
+ dev_lim->eqpc_entry_sz = size;
+ MTHCA_GET(size, outbox, QUERY_DEV_LIM_EQC_ENTRY_SZ_OFFSET);
+ dev_lim->eqc_entry_sz = size;
+ MTHCA_GET(size, outbox, QUERY_DEV_LIM_CQC_ENTRY_SZ_OFFSET);
+ dev_lim->cqc_entry_sz = size;
+ MTHCA_GET(size, outbox, QUERY_DEV_LIM_SRQ_ENTRY_SZ_OFFSET);
+ dev_lim->srq_entry_sz = size;
+ MTHCA_GET(size, outbox, QUERY_DEV_LIM_UAR_ENTRY_SZ_OFFSET);
+ dev_lim->uar_scratch_entry_sz = size;
+
+ if (mthca_is_memfree(dev)) {
+ MTHCA_GET(field, outbox, QUERY_DEV_LIM_MAX_SRQ_SZ_OFFSET);
+ dev_lim->max_srq_sz = 1 << field;
+ MTHCA_GET(field, outbox, QUERY_DEV_LIM_MAX_QP_SZ_OFFSET);
+ dev_lim->max_qp_sz = 1 << field;
+ MTHCA_GET(field, outbox, QUERY_DEV_LIM_RSZ_SRQ_OFFSET);
+ dev_lim->hca.arbel.resize_srq = field & 1;
+ MTHCA_GET(field, outbox, QUERY_DEV_LIM_MAX_SG_RQ_OFFSET);
+ dev_lim->max_sg = min_t(int, field, dev_lim->max_sg);
+ MTHCA_GET(size, outbox, QUERY_DEV_LIM_MAX_DESC_SZ_RQ_OFFSET);
+ dev_lim->max_desc_sz = min_t(int, size, dev_lim->max_desc_sz);
+ MTHCA_GET(size, outbox, QUERY_DEV_LIM_MPT_ENTRY_SZ_OFFSET);
+ dev_lim->mpt_entry_sz = size;
+ MTHCA_GET(field, outbox, QUERY_DEV_LIM_PBL_SZ_OFFSET);
+ dev_lim->hca.arbel.max_pbl_sz = 1 << (field & 0x3f);
+ MTHCA_GET(dev_lim->hca.arbel.bmme_flags, outbox,
+ QUERY_DEV_LIM_BMME_FLAGS_OFFSET);
+ MTHCA_GET(dev_lim->hca.arbel.reserved_lkey, outbox,
+ QUERY_DEV_LIM_RSVD_LKEY_OFFSET);
+ MTHCA_GET(field, outbox, QUERY_DEV_LIM_LAMR_OFFSET);
+ dev_lim->hca.arbel.lam_required = field & 1;
+ MTHCA_GET(dev_lim->hca.arbel.max_icm_sz, outbox,
+ QUERY_DEV_LIM_MAX_ICM_SZ_OFFSET);
+
+ if (dev_lim->hca.arbel.bmme_flags & 1)
+ mthca_dbg(dev, "Base MM extensions: yes "
+ "(flags %d, max PBL %d, rsvd L_Key %08x)\n",
+ dev_lim->hca.arbel.bmme_flags,
+ dev_lim->hca.arbel.max_pbl_sz,
+ dev_lim->hca.arbel.reserved_lkey);
+ else
+ mthca_dbg(dev, "Base MM extensions: no\n");
+
+ mthca_dbg(dev, "Max ICM size %lld MB\n",
+ (unsigned long long) dev_lim->hca.arbel.max_icm_sz >> 20);
+ } else {
+ MTHCA_GET(field, outbox, QUERY_DEV_LIM_MAX_SRQ_SZ_OFFSET);
+ dev_lim->max_srq_sz = (1 << field) - 1;
+ MTHCA_GET(field, outbox, QUERY_DEV_LIM_MAX_QP_SZ_OFFSET);
+ dev_lim->max_qp_sz = (1 << field) - 1;
+ MTHCA_GET(field, outbox, QUERY_DEV_LIM_MAX_AV_OFFSET);
+ dev_lim->hca.tavor.max_avs = 1 << (field & 0x3f);
+ dev_lim->mpt_entry_sz = MTHCA_MPT_ENTRY_SIZE;
+ }
+
+ mthca_dbg(dev, "Max QPs: %d, reserved QPs: %d, entry size: %d\n",
+ dev_lim->max_qps, dev_lim->reserved_qps, dev_lim->qpc_entry_sz);
+ mthca_dbg(dev, "Max SRQs: %d, reserved SRQs: %d, entry size: %d\n",
+ dev_lim->max_srqs, dev_lim->reserved_srqs, dev_lim->srq_entry_sz);
+ mthca_dbg(dev, "Max CQs: %d, reserved CQs: %d, entry size: %d\n",
+ dev_lim->max_cqs, dev_lim->reserved_cqs, dev_lim->cqc_entry_sz);
+ mthca_dbg(dev, "Max EQs: %d, reserved EQs: %d, entry size: %d\n",
+ dev_lim->max_eqs, dev_lim->reserved_eqs, dev_lim->eqc_entry_sz);
+ mthca_dbg(dev, "reserved MPTs: %d, reserved MTTs: %d\n",
+ dev_lim->reserved_mrws, dev_lim->reserved_mtts);
+ mthca_dbg(dev, "Max PDs: %d, reserved PDs: %d, reserved UARs: %d\n",
+ dev_lim->max_pds, dev_lim->reserved_pds, dev_lim->reserved_uars);
+ mthca_dbg(dev, "Max QP/MCG: %d, reserved MGMs: %d\n",
+ dev_lim->max_pds, dev_lim->reserved_mgms);
+ mthca_dbg(dev, "Max CQEs: %d, max WQEs: %d, max SRQ WQEs: %d\n",
+ dev_lim->max_cq_sz, dev_lim->max_qp_sz, dev_lim->max_srq_sz);
+
+ mthca_dbg(dev, "Flags: %08x\n", dev_lim->flags);
+
+out:
+ mthca_free_mailbox(dev, mailbox);
+ return err;
+}
+
+static void get_board_id(void *vsd, char *board_id)
+{
+ int i;
+
+#define VSD_OFFSET_SIG1 0x00
+#define VSD_OFFSET_SIG2 0xde
+#define VSD_OFFSET_MLX_BOARD_ID 0xd0
+#define VSD_OFFSET_TS_BOARD_ID 0x20
+
+#define VSD_SIGNATURE_TOPSPIN 0x5ad
+
+ memset(board_id, 0, MTHCA_BOARD_ID_LEN);
+
+ if (be16_to_cpup(vsd + VSD_OFFSET_SIG1) == VSD_SIGNATURE_TOPSPIN &&
+ be16_to_cpup(vsd + VSD_OFFSET_SIG2) == VSD_SIGNATURE_TOPSPIN) {
+ strlcpy(board_id, vsd + VSD_OFFSET_TS_BOARD_ID, MTHCA_BOARD_ID_LEN);
+ } else {
+ /*
+ * The board ID is a string but the firmware byte
+ * swaps each 4-byte word before passing it back to
+ * us. Therefore we need to swab it before printing.
+ */
+ for (i = 0; i < 4; ++i)
+ ((u32 *) board_id)[i] =
+ swab32(*(u32 *) (vsd + VSD_OFFSET_MLX_BOARD_ID + i * 4));
+ }
+}
+
+int mthca_QUERY_ADAPTER(struct mthca_dev *dev,
+ struct mthca_adapter *adapter)
+{
+ struct mthca_mailbox *mailbox;
+ u32 *outbox;
+ int err;
+
+#define QUERY_ADAPTER_OUT_SIZE 0x100
+#define QUERY_ADAPTER_VENDOR_ID_OFFSET 0x00
+#define QUERY_ADAPTER_DEVICE_ID_OFFSET 0x04
+#define QUERY_ADAPTER_REVISION_ID_OFFSET 0x08
+#define QUERY_ADAPTER_INTA_PIN_OFFSET 0x10
+#define QUERY_ADAPTER_VSD_OFFSET 0x20
+
+ mailbox = mthca_alloc_mailbox(dev, GFP_KERNEL);
+ if (IS_ERR(mailbox))
+ return PTR_ERR(mailbox);
+ outbox = mailbox->buf;
+
+ err = mthca_cmd_box(dev, 0, mailbox->dma, 0, 0, CMD_QUERY_ADAPTER,
+ CMD_TIME_CLASS_A);
+
+ if (err)
+ goto out;
+
+ if (!mthca_is_memfree(dev)) {
+ MTHCA_GET(adapter->vendor_id, outbox,
+ QUERY_ADAPTER_VENDOR_ID_OFFSET);
+ MTHCA_GET(adapter->device_id, outbox,
+ QUERY_ADAPTER_DEVICE_ID_OFFSET);
+ MTHCA_GET(adapter->revision_id, outbox,
+ QUERY_ADAPTER_REVISION_ID_OFFSET);
+ }
+ MTHCA_GET(adapter->inta_pin, outbox, QUERY_ADAPTER_INTA_PIN_OFFSET);
+
+ get_board_id(outbox + QUERY_ADAPTER_VSD_OFFSET / 4,
+ adapter->board_id);
+
+out:
+ mthca_free_mailbox(dev, mailbox);
+ return err;
+}
+
+int mthca_INIT_HCA(struct mthca_dev *dev,
+ struct mthca_init_hca_param *param)
+{
+ struct mthca_mailbox *mailbox;
+ __be32 *inbox;
+ int err;
+
+#define INIT_HCA_IN_SIZE 0x200
+#define INIT_HCA_FLAGS1_OFFSET 0x00c
+#define INIT_HCA_FLAGS2_OFFSET 0x014
+#define INIT_HCA_QPC_OFFSET 0x020
+#define INIT_HCA_QPC_BASE_OFFSET (INIT_HCA_QPC_OFFSET + 0x10)
+#define INIT_HCA_LOG_QP_OFFSET (INIT_HCA_QPC_OFFSET + 0x17)
+#define INIT_HCA_EEC_BASE_OFFSET (INIT_HCA_QPC_OFFSET + 0x20)
+#define INIT_HCA_LOG_EEC_OFFSET (INIT_HCA_QPC_OFFSET + 0x27)
+#define INIT_HCA_SRQC_BASE_OFFSET (INIT_HCA_QPC_OFFSET + 0x28)
+#define INIT_HCA_LOG_SRQ_OFFSET (INIT_HCA_QPC_OFFSET + 0x2f)
+#define INIT_HCA_CQC_BASE_OFFSET (INIT_HCA_QPC_OFFSET + 0x30)
+#define INIT_HCA_LOG_CQ_OFFSET (INIT_HCA_QPC_OFFSET + 0x37)
+#define INIT_HCA_EQPC_BASE_OFFSET (INIT_HCA_QPC_OFFSET + 0x40)
+#define INIT_HCA_EEEC_BASE_OFFSET (INIT_HCA_QPC_OFFSET + 0x50)
+#define INIT_HCA_EQC_BASE_OFFSET (INIT_HCA_QPC_OFFSET + 0x60)
+#define INIT_HCA_LOG_EQ_OFFSET (INIT_HCA_QPC_OFFSET + 0x67)
+#define INIT_HCA_RDB_BASE_OFFSET (INIT_HCA_QPC_OFFSET + 0x70)
+#define INIT_HCA_UDAV_OFFSET 0x0b0
+#define INIT_HCA_UDAV_LKEY_OFFSET (INIT_HCA_UDAV_OFFSET + 0x0)
+#define INIT_HCA_UDAV_PD_OFFSET (INIT_HCA_UDAV_OFFSET + 0x4)
+#define INIT_HCA_MCAST_OFFSET 0x0c0
+#define INIT_HCA_MC_BASE_OFFSET (INIT_HCA_MCAST_OFFSET + 0x00)
+#define INIT_HCA_LOG_MC_ENTRY_SZ_OFFSET (INIT_HCA_MCAST_OFFSET + 0x12)
+#define INIT_HCA_MC_HASH_SZ_OFFSET (INIT_HCA_MCAST_OFFSET + 0x16)
+#define INIT_HCA_LOG_MC_TABLE_SZ_OFFSET (INIT_HCA_MCAST_OFFSET + 0x1b)
+#define INIT_HCA_TPT_OFFSET 0x0f0
+#define INIT_HCA_MPT_BASE_OFFSET (INIT_HCA_TPT_OFFSET + 0x00)
+#define INIT_HCA_MTT_SEG_SZ_OFFSET (INIT_HCA_TPT_OFFSET + 0x09)
+#define INIT_HCA_LOG_MPT_SZ_OFFSET (INIT_HCA_TPT_OFFSET + 0x0b)
+#define INIT_HCA_MTT_BASE_OFFSET (INIT_HCA_TPT_OFFSET + 0x10)
+#define INIT_HCA_UAR_OFFSET 0x120
+#define INIT_HCA_UAR_BASE_OFFSET (INIT_HCA_UAR_OFFSET + 0x00)
+#define INIT_HCA_UARC_SZ_OFFSET (INIT_HCA_UAR_OFFSET + 0x09)
+#define INIT_HCA_LOG_UAR_SZ_OFFSET (INIT_HCA_UAR_OFFSET + 0x0a)
+#define INIT_HCA_UAR_PAGE_SZ_OFFSET (INIT_HCA_UAR_OFFSET + 0x0b)
+#define INIT_HCA_UAR_SCATCH_BASE_OFFSET (INIT_HCA_UAR_OFFSET + 0x10)
+#define INIT_HCA_UAR_CTX_BASE_OFFSET (INIT_HCA_UAR_OFFSET + 0x18)
+
+ mailbox = mthca_alloc_mailbox(dev, GFP_KERNEL);
+ if (IS_ERR(mailbox))
+ return PTR_ERR(mailbox);
+ inbox = mailbox->buf;
+
+ memset(inbox, 0, INIT_HCA_IN_SIZE);
+
+ if (dev->mthca_flags & MTHCA_FLAG_SINAI_OPT)
+ MTHCA_PUT(inbox, 0x1, INIT_HCA_FLAGS1_OFFSET);
+
+#if defined(__LITTLE_ENDIAN)
+ *(inbox + INIT_HCA_FLAGS2_OFFSET / 4) &= ~cpu_to_be32(1 << 1);
+#elif defined(__BIG_ENDIAN)
+ *(inbox + INIT_HCA_FLAGS2_OFFSET / 4) |= cpu_to_be32(1 << 1);
+#else
+#error Host endianness not defined
+#endif
+ /* Check port for UD address vector: */
+ *(inbox + INIT_HCA_FLAGS2_OFFSET / 4) |= cpu_to_be32(1);
+
+ /* Enable IPoIB checksumming if we can: */
+ if (dev->device_cap_flags & IB_DEVICE_UD_IP_CSUM)
+ *(inbox + INIT_HCA_FLAGS2_OFFSET / 4) |= cpu_to_be32(7 << 3);
+
+ /* We leave wqe_quota, responder_exu, etc as 0 (default) */
+
+ /* QPC/EEC/CQC/EQC/RDB attributes */
+
+ MTHCA_PUT(inbox, param->qpc_base, INIT_HCA_QPC_BASE_OFFSET);
+ MTHCA_PUT(inbox, param->log_num_qps, INIT_HCA_LOG_QP_OFFSET);
+ MTHCA_PUT(inbox, param->eec_base, INIT_HCA_EEC_BASE_OFFSET);
+ MTHCA_PUT(inbox, param->log_num_eecs, INIT_HCA_LOG_EEC_OFFSET);
+ MTHCA_PUT(inbox, param->srqc_base, INIT_HCA_SRQC_BASE_OFFSET);
+ MTHCA_PUT(inbox, param->log_num_srqs, INIT_HCA_LOG_SRQ_OFFSET);
+ MTHCA_PUT(inbox, param->cqc_base, INIT_HCA_CQC_BASE_OFFSET);
+ MTHCA_PUT(inbox, param->log_num_cqs, INIT_HCA_LOG_CQ_OFFSET);
+ MTHCA_PUT(inbox, param->eqpc_base, INIT_HCA_EQPC_BASE_OFFSET);
+ MTHCA_PUT(inbox, param->eeec_base, INIT_HCA_EEEC_BASE_OFFSET);
+ MTHCA_PUT(inbox, param->eqc_base, INIT_HCA_EQC_BASE_OFFSET);
+ MTHCA_PUT(inbox, param->log_num_eqs, INIT_HCA_LOG_EQ_OFFSET);
+ MTHCA_PUT(inbox, param->rdb_base, INIT_HCA_RDB_BASE_OFFSET);
+
+ /* UD AV attributes */
+
+ /* multicast attributes */
+
+ MTHCA_PUT(inbox, param->mc_base, INIT_HCA_MC_BASE_OFFSET);
+ MTHCA_PUT(inbox, param->log_mc_entry_sz, INIT_HCA_LOG_MC_ENTRY_SZ_OFFSET);
+ MTHCA_PUT(inbox, param->mc_hash_sz, INIT_HCA_MC_HASH_SZ_OFFSET);
+ MTHCA_PUT(inbox, param->log_mc_table_sz, INIT_HCA_LOG_MC_TABLE_SZ_OFFSET);
+
+ /* TPT attributes */
+
+ MTHCA_PUT(inbox, param->mpt_base, INIT_HCA_MPT_BASE_OFFSET);
+ if (!mthca_is_memfree(dev))
+ MTHCA_PUT(inbox, param->mtt_seg_sz, INIT_HCA_MTT_SEG_SZ_OFFSET);
+ MTHCA_PUT(inbox, param->log_mpt_sz, INIT_HCA_LOG_MPT_SZ_OFFSET);
+ MTHCA_PUT(inbox, param->mtt_base, INIT_HCA_MTT_BASE_OFFSET);
+
+ /* UAR attributes */
+ {
+ u8 uar_page_sz = PAGE_SHIFT - 12;
+ MTHCA_PUT(inbox, uar_page_sz, INIT_HCA_UAR_PAGE_SZ_OFFSET);
+ }
+
+ MTHCA_PUT(inbox, param->uar_scratch_base, INIT_HCA_UAR_SCATCH_BASE_OFFSET);
+
+ if (mthca_is_memfree(dev)) {
+ MTHCA_PUT(inbox, param->log_uarc_sz, INIT_HCA_UARC_SZ_OFFSET);
+ MTHCA_PUT(inbox, param->log_uar_sz, INIT_HCA_LOG_UAR_SZ_OFFSET);
+ MTHCA_PUT(inbox, param->uarc_base, INIT_HCA_UAR_CTX_BASE_OFFSET);
+ }
+
+ err = mthca_cmd(dev, mailbox->dma, 0, 0,
+ CMD_INIT_HCA, CMD_TIME_CLASS_D);
+
+ mthca_free_mailbox(dev, mailbox);
+ return err;
+}
+
+int mthca_INIT_IB(struct mthca_dev *dev,
+ struct mthca_init_ib_param *param,
+ int port)
+{
+ struct mthca_mailbox *mailbox;
+ u32 *inbox;
+ int err;
+ u32 flags;
+
+#define INIT_IB_IN_SIZE 56
+#define INIT_IB_FLAGS_OFFSET 0x00
+#define INIT_IB_FLAG_SIG (1 << 18)
+#define INIT_IB_FLAG_NG (1 << 17)
+#define INIT_IB_FLAG_G0 (1 << 16)
+#define INIT_IB_VL_SHIFT 4
+#define INIT_IB_PORT_WIDTH_SHIFT 8
+#define INIT_IB_MTU_SHIFT 12
+#define INIT_IB_MAX_GID_OFFSET 0x06
+#define INIT_IB_MAX_PKEY_OFFSET 0x0a
+#define INIT_IB_GUID0_OFFSET 0x10
+#define INIT_IB_NODE_GUID_OFFSET 0x18
+#define INIT_IB_SI_GUID_OFFSET 0x20
+
+ mailbox = mthca_alloc_mailbox(dev, GFP_KERNEL);
+ if (IS_ERR(mailbox))
+ return PTR_ERR(mailbox);
+ inbox = mailbox->buf;
+
+ memset(inbox, 0, INIT_IB_IN_SIZE);
+
+ flags = 0;
+ flags |= param->set_guid0 ? INIT_IB_FLAG_G0 : 0;
+ flags |= param->set_node_guid ? INIT_IB_FLAG_NG : 0;
+ flags |= param->set_si_guid ? INIT_IB_FLAG_SIG : 0;
+ flags |= param->vl_cap << INIT_IB_VL_SHIFT;
+ flags |= param->port_width << INIT_IB_PORT_WIDTH_SHIFT;
+ flags |= param->mtu_cap << INIT_IB_MTU_SHIFT;
+ MTHCA_PUT(inbox, flags, INIT_IB_FLAGS_OFFSET);
+
+ MTHCA_PUT(inbox, param->gid_cap, INIT_IB_MAX_GID_OFFSET);
+ MTHCA_PUT(inbox, param->pkey_cap, INIT_IB_MAX_PKEY_OFFSET);
+ MTHCA_PUT(inbox, param->guid0, INIT_IB_GUID0_OFFSET);
+ MTHCA_PUT(inbox, param->node_guid, INIT_IB_NODE_GUID_OFFSET);
+ MTHCA_PUT(inbox, param->si_guid, INIT_IB_SI_GUID_OFFSET);
+
+ err = mthca_cmd(dev, mailbox->dma, port, 0, CMD_INIT_IB,
+ CMD_TIME_CLASS_A);
+
+ mthca_free_mailbox(dev, mailbox);
+ return err;
+}
+
+int mthca_CLOSE_IB(struct mthca_dev *dev, int port)
+{
+ return mthca_cmd(dev, 0, port, 0, CMD_CLOSE_IB, CMD_TIME_CLASS_A);
+}
+
+int mthca_CLOSE_HCA(struct mthca_dev *dev, int panic)
+{
+ return mthca_cmd(dev, 0, 0, panic, CMD_CLOSE_HCA, CMD_TIME_CLASS_C);
+}
+
+int mthca_SET_IB(struct mthca_dev *dev, struct mthca_set_ib_param *param,
+ int port)
+{
+ struct mthca_mailbox *mailbox;
+ u32 *inbox;
+ int err;
+ u32 flags = 0;
+
+#define SET_IB_IN_SIZE 0x40
+#define SET_IB_FLAGS_OFFSET 0x00
+#define SET_IB_FLAG_SIG (1 << 18)
+#define SET_IB_FLAG_RQK (1 << 0)
+#define SET_IB_CAP_MASK_OFFSET 0x04
+#define SET_IB_SI_GUID_OFFSET 0x08
+
+ mailbox = mthca_alloc_mailbox(dev, GFP_KERNEL);
+ if (IS_ERR(mailbox))
+ return PTR_ERR(mailbox);
+ inbox = mailbox->buf;
+
+ memset(inbox, 0, SET_IB_IN_SIZE);
+
+ flags |= param->set_si_guid ? SET_IB_FLAG_SIG : 0;
+ flags |= param->reset_qkey_viol ? SET_IB_FLAG_RQK : 0;
+ MTHCA_PUT(inbox, flags, SET_IB_FLAGS_OFFSET);
+
+ MTHCA_PUT(inbox, param->cap_mask, SET_IB_CAP_MASK_OFFSET);
+ MTHCA_PUT(inbox, param->si_guid, SET_IB_SI_GUID_OFFSET);
+
+ err = mthca_cmd(dev, mailbox->dma, port, 0, CMD_SET_IB,
+ CMD_TIME_CLASS_B);
+
+ mthca_free_mailbox(dev, mailbox);
+ return err;
+}
+
+int mthca_MAP_ICM(struct mthca_dev *dev, struct mthca_icm *icm, u64 virt)
+{
+ return mthca_map_cmd(dev, CMD_MAP_ICM, icm, virt);
+}
+
+int mthca_MAP_ICM_page(struct mthca_dev *dev, u64 dma_addr, u64 virt)
+{
+ struct mthca_mailbox *mailbox;
+ __be64 *inbox;
+ int err;
+
+ mailbox = mthca_alloc_mailbox(dev, GFP_KERNEL);
+ if (IS_ERR(mailbox))
+ return PTR_ERR(mailbox);
+ inbox = mailbox->buf;
+
+ inbox[0] = cpu_to_be64(virt);
+ inbox[1] = cpu_to_be64(dma_addr);
+
+ err = mthca_cmd(dev, mailbox->dma, 1, 0, CMD_MAP_ICM,
+ CMD_TIME_CLASS_B);
+
+ mthca_free_mailbox(dev, mailbox);
+
+ if (!err)
+ mthca_dbg(dev, "Mapped page at %llx to %llx for ICM.\n",
+ (unsigned long long) dma_addr, (unsigned long long) virt);
+
+ return err;
+}
+
+int mthca_UNMAP_ICM(struct mthca_dev *dev, u64 virt, u32 page_count)
+{
+ mthca_dbg(dev, "Unmapping %d pages at %llx from ICM.\n",
+ page_count, (unsigned long long) virt);
+
+ return mthca_cmd(dev, virt, page_count, 0,
+ CMD_UNMAP_ICM, CMD_TIME_CLASS_B);
+}
+
+int mthca_MAP_ICM_AUX(struct mthca_dev *dev, struct mthca_icm *icm)
+{
+ return mthca_map_cmd(dev, CMD_MAP_ICM_AUX, icm, -1);
+}
+
+int mthca_UNMAP_ICM_AUX(struct mthca_dev *dev)
+{
+ return mthca_cmd(dev, 0, 0, 0, CMD_UNMAP_ICM_AUX, CMD_TIME_CLASS_B);
+}
+
+int mthca_SET_ICM_SIZE(struct mthca_dev *dev, u64 icm_size, u64 *aux_pages)
+{
+ int ret = mthca_cmd_imm(dev, icm_size, aux_pages, 0,
+ 0, CMD_SET_ICM_SIZE, CMD_TIME_CLASS_A);
+
+ if (ret)
+ return ret;
+
+ /*
+ * Round up number of system pages needed in case
+ * MTHCA_ICM_PAGE_SIZE < PAGE_SIZE.
+ */
+ *aux_pages = ALIGN(*aux_pages, PAGE_SIZE / MTHCA_ICM_PAGE_SIZE) >>
+ (PAGE_SHIFT - MTHCA_ICM_PAGE_SHIFT);
+
+ return 0;
+}
+
+int mthca_SW2HW_MPT(struct mthca_dev *dev, struct mthca_mailbox *mailbox,
+ int mpt_index)
+{
+ return mthca_cmd(dev, mailbox->dma, mpt_index, 0, CMD_SW2HW_MPT,
+ CMD_TIME_CLASS_B);
+}
+
+int mthca_HW2SW_MPT(struct mthca_dev *dev, struct mthca_mailbox *mailbox,
+ int mpt_index)
+{
+ return mthca_cmd_box(dev, 0, mailbox ? mailbox->dma : 0, mpt_index,
+ !mailbox, CMD_HW2SW_MPT,
+ CMD_TIME_CLASS_B);
+}
+
+int mthca_WRITE_MTT(struct mthca_dev *dev, struct mthca_mailbox *mailbox,
+ int num_mtt)
+{
+ return mthca_cmd(dev, mailbox->dma, num_mtt, 0, CMD_WRITE_MTT,
+ CMD_TIME_CLASS_B);
+}
+
+int mthca_SYNC_TPT(struct mthca_dev *dev)
+{
+ return mthca_cmd(dev, 0, 0, 0, CMD_SYNC_TPT, CMD_TIME_CLASS_B);
+}
+
+int mthca_MAP_EQ(struct mthca_dev *dev, u64 event_mask, int unmap,
+ int eq_num)
+{
+ mthca_dbg(dev, "%s mask %016llx for eqn %d\n",
+ unmap ? "Clearing" : "Setting",
+ (unsigned long long) event_mask, eq_num);
+ return mthca_cmd(dev, event_mask, (unmap << 31) | eq_num,
+ 0, CMD_MAP_EQ, CMD_TIME_CLASS_B);
+}
+
+int mthca_SW2HW_EQ(struct mthca_dev *dev, struct mthca_mailbox *mailbox,
+ int eq_num)
+{
+ return mthca_cmd(dev, mailbox->dma, eq_num, 0, CMD_SW2HW_EQ,
+ CMD_TIME_CLASS_A);
+}
+
+int mthca_HW2SW_EQ(struct mthca_dev *dev, struct mthca_mailbox *mailbox,
+ int eq_num)
+{
+ return mthca_cmd_box(dev, 0, mailbox->dma, eq_num, 0,
+ CMD_HW2SW_EQ,
+ CMD_TIME_CLASS_A);
+}
+
+int mthca_SW2HW_CQ(struct mthca_dev *dev, struct mthca_mailbox *mailbox,
+ int cq_num)
+{
+ return mthca_cmd(dev, mailbox->dma, cq_num, 0, CMD_SW2HW_CQ,
+ CMD_TIME_CLASS_A);
+}
+
+int mthca_HW2SW_CQ(struct mthca_dev *dev, struct mthca_mailbox *mailbox,
+ int cq_num)
+{
+ return mthca_cmd_box(dev, 0, mailbox->dma, cq_num, 0,
+ CMD_HW2SW_CQ,
+ CMD_TIME_CLASS_A);
+}
+
+int mthca_RESIZE_CQ(struct mthca_dev *dev, int cq_num, u32 lkey, u8 log_size)
+{
+ struct mthca_mailbox *mailbox;
+ __be32 *inbox;
+ int err;
+
+#define RESIZE_CQ_IN_SIZE 0x40
+#define RESIZE_CQ_LOG_SIZE_OFFSET 0x0c
+#define RESIZE_CQ_LKEY_OFFSET 0x1c
+
+ mailbox = mthca_alloc_mailbox(dev, GFP_KERNEL);
+ if (IS_ERR(mailbox))
+ return PTR_ERR(mailbox);
+ inbox = mailbox->buf;
+
+ memset(inbox, 0, RESIZE_CQ_IN_SIZE);
+ /*
+ * Leave start address fields zeroed out -- mthca assumes that
+ * MRs for CQs always start at virtual address 0.
+ */
+ MTHCA_PUT(inbox, log_size, RESIZE_CQ_LOG_SIZE_OFFSET);
+ MTHCA_PUT(inbox, lkey, RESIZE_CQ_LKEY_OFFSET);
+
+ err = mthca_cmd(dev, mailbox->dma, cq_num, 1, CMD_RESIZE_CQ,
+ CMD_TIME_CLASS_B);
+
+ mthca_free_mailbox(dev, mailbox);
+ return err;
+}
+
+int mthca_SW2HW_SRQ(struct mthca_dev *dev, struct mthca_mailbox *mailbox,
+ int srq_num)
+{
+ return mthca_cmd(dev, mailbox->dma, srq_num, 0, CMD_SW2HW_SRQ,
+ CMD_TIME_CLASS_A);
+}
+
+int mthca_HW2SW_SRQ(struct mthca_dev *dev, struct mthca_mailbox *mailbox,
+ int srq_num)
+{
+ return mthca_cmd_box(dev, 0, mailbox->dma, srq_num, 0,
+ CMD_HW2SW_SRQ,
+ CMD_TIME_CLASS_A);
+}
+
+int mthca_QUERY_SRQ(struct mthca_dev *dev, u32 num,
+ struct mthca_mailbox *mailbox)
+{
+ return mthca_cmd_box(dev, 0, mailbox->dma, num, 0,
+ CMD_QUERY_SRQ, CMD_TIME_CLASS_A);
+}
+
+int mthca_ARM_SRQ(struct mthca_dev *dev, int srq_num, int limit)
+{
+ return mthca_cmd(dev, limit, srq_num, 0, CMD_ARM_SRQ,
+ CMD_TIME_CLASS_B);
+}
+
+int mthca_MODIFY_QP(struct mthca_dev *dev, enum ib_qp_state cur,
+ enum ib_qp_state next, u32 num, int is_ee,
+ struct mthca_mailbox *mailbox, u32 optmask)
+{
+ static const u16 op[IB_QPS_ERR + 1][IB_QPS_ERR + 1] = {
+ [IB_QPS_RESET] = {
+ [IB_QPS_RESET] = CMD_ERR2RST_QPEE,
+ [IB_QPS_ERR] = CMD_2ERR_QPEE,
+ [IB_QPS_INIT] = CMD_RST2INIT_QPEE,
+ },
+ [IB_QPS_INIT] = {
+ [IB_QPS_RESET] = CMD_ERR2RST_QPEE,
+ [IB_QPS_ERR] = CMD_2ERR_QPEE,
+ [IB_QPS_INIT] = CMD_INIT2INIT_QPEE,
+ [IB_QPS_RTR] = CMD_INIT2RTR_QPEE,
+ },
+ [IB_QPS_RTR] = {
+ [IB_QPS_RESET] = CMD_ERR2RST_QPEE,
+ [IB_QPS_ERR] = CMD_2ERR_QPEE,
+ [IB_QPS_RTS] = CMD_RTR2RTS_QPEE,
+ },
+ [IB_QPS_RTS] = {
+ [IB_QPS_RESET] = CMD_ERR2RST_QPEE,
+ [IB_QPS_ERR] = CMD_2ERR_QPEE,
+ [IB_QPS_RTS] = CMD_RTS2RTS_QPEE,
+ [IB_QPS_SQD] = CMD_RTS2SQD_QPEE,
+ },
+ [IB_QPS_SQD] = {
+ [IB_QPS_RESET] = CMD_ERR2RST_QPEE,
+ [IB_QPS_ERR] = CMD_2ERR_QPEE,
+ [IB_QPS_RTS] = CMD_SQD2RTS_QPEE,
+ [IB_QPS_SQD] = CMD_SQD2SQD_QPEE,
+ },
+ [IB_QPS_SQE] = {
+ [IB_QPS_RESET] = CMD_ERR2RST_QPEE,
+ [IB_QPS_ERR] = CMD_2ERR_QPEE,
+ [IB_QPS_RTS] = CMD_SQERR2RTS_QPEE,
+ },
+ [IB_QPS_ERR] = {
+ [IB_QPS_RESET] = CMD_ERR2RST_QPEE,
+ [IB_QPS_ERR] = CMD_2ERR_QPEE,
+ }
+ };
+
+ u8 op_mod = 0;
+ int my_mailbox = 0;
+ int err;
+
+ if (op[cur][next] == CMD_ERR2RST_QPEE) {
+ op_mod = 3; /* don't write outbox, any->reset */
+
+ /* For debugging */
+ if (!mailbox) {
+ mailbox = mthca_alloc_mailbox(dev, GFP_KERNEL);
+ if (!IS_ERR(mailbox)) {
+ my_mailbox = 1;
+ op_mod = 2; /* write outbox, any->reset */
+ } else
+ mailbox = NULL;
+ }
+
+ err = mthca_cmd_box(dev, 0, mailbox ? mailbox->dma : 0,
+ (!!is_ee << 24) | num, op_mod,
+ op[cur][next], CMD_TIME_CLASS_C);
+
+ if (0 && mailbox) {
+ int i;
+ mthca_dbg(dev, "Dumping QP context:\n");
+ printk(" %08x\n", be32_to_cpup(mailbox->buf));
+ for (i = 0; i < 0x100 / 4; ++i) {
+ if (i % 8 == 0)
+ printk("[%02x] ", i * 4);
+ printk(" %08x",
+ be32_to_cpu(((__be32 *) mailbox->buf)[i + 2]));
+ if ((i + 1) % 8 == 0)
+ printk("\n");
+ }
+ }
+
+ if (my_mailbox)
+ mthca_free_mailbox(dev, mailbox);
+ } else {
+ if (0) {
+ int i;
+ mthca_dbg(dev, "Dumping QP context:\n");
+ printk(" opt param mask: %08x\n", be32_to_cpup(mailbox->buf));
+ for (i = 0; i < 0x100 / 4; ++i) {
+ if (i % 8 == 0)
+ printk(" [%02x] ", i * 4);
+ printk(" %08x",
+ be32_to_cpu(((__be32 *) mailbox->buf)[i + 2]));
+ if ((i + 1) % 8 == 0)
+ printk("\n");
+ }
+ }
+
+ err = mthca_cmd(dev, mailbox->dma, optmask | (!!is_ee << 24) | num,
+ op_mod, op[cur][next], CMD_TIME_CLASS_C);
+ }
+
+ return err;
+}
+
+int mthca_QUERY_QP(struct mthca_dev *dev, u32 num, int is_ee,
+ struct mthca_mailbox *mailbox)
+{
+ return mthca_cmd_box(dev, 0, mailbox->dma, (!!is_ee << 24) | num, 0,
+ CMD_QUERY_QPEE, CMD_TIME_CLASS_A);
+}
+
+int mthca_CONF_SPECIAL_QP(struct mthca_dev *dev, int type, u32 qpn)
+{
+ u8 op_mod;
+
+ switch (type) {
+ case IB_QPT_SMI:
+ op_mod = 0;
+ break;
+ case IB_QPT_GSI:
+ op_mod = 1;
+ break;
+ case IB_QPT_RAW_IPV6:
+ op_mod = 2;
+ break;
+ case IB_QPT_RAW_ETHERTYPE:
+ op_mod = 3;
+ break;
+ default:
+ return -EINVAL;
+ }
+
+ return mthca_cmd(dev, 0, qpn, op_mod, CMD_CONF_SPECIAL_QP,
+ CMD_TIME_CLASS_B);
+}
+
+int mthca_MAD_IFC(struct mthca_dev *dev, int ignore_mkey, int ignore_bkey,
+ int port, const struct ib_wc *in_wc, const struct ib_grh *in_grh,
+ const void *in_mad, void *response_mad)
+{
+ struct mthca_mailbox *inmailbox, *outmailbox;
+ void *inbox;
+ int err;
+ u32 in_modifier = port;
+ u8 op_modifier = 0;
+
+#define MAD_IFC_BOX_SIZE 0x400
+#define MAD_IFC_MY_QPN_OFFSET 0x100
+#define MAD_IFC_RQPN_OFFSET 0x108
+#define MAD_IFC_SL_OFFSET 0x10c
+#define MAD_IFC_G_PATH_OFFSET 0x10d
+#define MAD_IFC_RLID_OFFSET 0x10e
+#define MAD_IFC_PKEY_OFFSET 0x112
+#define MAD_IFC_GRH_OFFSET 0x140
+
+ inmailbox = mthca_alloc_mailbox(dev, GFP_KERNEL);
+ if (IS_ERR(inmailbox))
+ return PTR_ERR(inmailbox);
+ inbox = inmailbox->buf;
+
+ outmailbox = mthca_alloc_mailbox(dev, GFP_KERNEL);
+ if (IS_ERR(outmailbox)) {
+ mthca_free_mailbox(dev, inmailbox);
+ return PTR_ERR(outmailbox);
+ }
+
+ memcpy(inbox, in_mad, 256);
+
+ /*
+ * Key check traps can't be generated unless we have in_wc to
+ * tell us where to send the trap.
+ */
+ if (ignore_mkey || !in_wc)
+ op_modifier |= 0x1;
+ if (ignore_bkey || !in_wc)
+ op_modifier |= 0x2;
+
+ if (in_wc) {
+ u8 val;
+
+ memset(inbox + 256, 0, 256);
+
+ MTHCA_PUT(inbox, in_wc->qp->qp_num, MAD_IFC_MY_QPN_OFFSET);
+ MTHCA_PUT(inbox, in_wc->src_qp, MAD_IFC_RQPN_OFFSET);
+
+ val = in_wc->sl << 4;
+ MTHCA_PUT(inbox, val, MAD_IFC_SL_OFFSET);
+
+ val = in_wc->dlid_path_bits |
+ (in_wc->wc_flags & IB_WC_GRH ? 0x80 : 0);
+ MTHCA_PUT(inbox, val, MAD_IFC_G_PATH_OFFSET);
+
+ MTHCA_PUT(inbox, in_wc->slid, MAD_IFC_RLID_OFFSET);
+ MTHCA_PUT(inbox, in_wc->pkey_index, MAD_IFC_PKEY_OFFSET);
+
+ if (in_grh)
+ memcpy(inbox + MAD_IFC_GRH_OFFSET, in_grh, 40);
+
+ op_modifier |= 0x4;
+
+ in_modifier |= in_wc->slid << 16;
+ }
+
+ err = mthca_cmd_box(dev, inmailbox->dma, outmailbox->dma,
+ in_modifier, op_modifier,
+ CMD_MAD_IFC, CMD_TIME_CLASS_C);
+
+ if (!err)
+ memcpy(response_mad, outmailbox->buf, 256);
+
+ mthca_free_mailbox(dev, inmailbox);
+ mthca_free_mailbox(dev, outmailbox);
+ return err;
+}
+
+int mthca_READ_MGM(struct mthca_dev *dev, int index,
+ struct mthca_mailbox *mailbox)
+{
+ return mthca_cmd_box(dev, 0, mailbox->dma, index, 0,
+ CMD_READ_MGM, CMD_TIME_CLASS_A);
+}
+
+int mthca_WRITE_MGM(struct mthca_dev *dev, int index,
+ struct mthca_mailbox *mailbox)
+{
+ return mthca_cmd(dev, mailbox->dma, index, 0, CMD_WRITE_MGM,
+ CMD_TIME_CLASS_A);
+}
+
+int mthca_MGID_HASH(struct mthca_dev *dev, struct mthca_mailbox *mailbox,
+ u16 *hash)
+{
+ u64 imm;
+ int err;
+
+ err = mthca_cmd_imm(dev, mailbox->dma, &imm, 0, 0, CMD_MGID_HASH,
+ CMD_TIME_CLASS_A);
+
+ *hash = imm;
+ return err;
+}
+
+int mthca_NOP(struct mthca_dev *dev)
+{
+ return mthca_cmd(dev, 0, 0x1f, 0, CMD_NOP, msecs_to_jiffies(100));
+}
diff --git a/sys/dev/mthca/mthca_cmd.h b/sys/dev/mthca/mthca_cmd.h
new file mode 100644
index 0000000..d2e5b19
--- /dev/null
+++ b/sys/dev/mthca/mthca_cmd.h
@@ -0,0 +1,325 @@
+/*
+ * Copyright (c) 2004, 2005 Topspin Communications. All rights reserved.
+ * Copyright (c) 2005 Mellanox Technologies. All rights reserved.
+ * Copyright (c) 2006 Cisco Systems. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#ifndef MTHCA_CMD_H
+#define MTHCA_CMD_H
+
+#include <rdma/ib_verbs.h>
+
+#define MTHCA_MAILBOX_SIZE 4096
+
+enum {
+ /* command completed successfully: */
+ MTHCA_CMD_STAT_OK = 0x00,
+ /* Internal error (such as a bus error) occurred while processing command: */
+ MTHCA_CMD_STAT_INTERNAL_ERR = 0x01,
+ /* Operation/command not supported or opcode modifier not supported: */
+ MTHCA_CMD_STAT_BAD_OP = 0x02,
+ /* Parameter not supported or parameter out of range: */
+ MTHCA_CMD_STAT_BAD_PARAM = 0x03,
+ /* System not enabled or bad system state: */
+ MTHCA_CMD_STAT_BAD_SYS_STATE = 0x04,
+ /* Attempt to access reserved or unallocaterd resource: */
+ MTHCA_CMD_STAT_BAD_RESOURCE = 0x05,
+ /* Requested resource is currently executing a command, or is otherwise busy: */
+ MTHCA_CMD_STAT_RESOURCE_BUSY = 0x06,
+ /* memory error: */
+ MTHCA_CMD_STAT_DDR_MEM_ERR = 0x07,
+ /* Required capability exceeds device limits: */
+ MTHCA_CMD_STAT_EXCEED_LIM = 0x08,
+ /* Resource is not in the appropriate state or ownership: */
+ MTHCA_CMD_STAT_BAD_RES_STATE = 0x09,
+ /* Index out of range: */
+ MTHCA_CMD_STAT_BAD_INDEX = 0x0a,
+ /* FW image corrupted: */
+ MTHCA_CMD_STAT_BAD_NVMEM = 0x0b,
+ /* Attempt to modify a QP/EE which is not in the presumed state: */
+ MTHCA_CMD_STAT_BAD_QPEE_STATE = 0x10,
+ /* Bad segment parameters (Address/Size): */
+ MTHCA_CMD_STAT_BAD_SEG_PARAM = 0x20,
+ /* Memory Region has Memory Windows bound to: */
+ MTHCA_CMD_STAT_REG_BOUND = 0x21,
+ /* HCA local attached memory not present: */
+ MTHCA_CMD_STAT_LAM_NOT_PRE = 0x22,
+ /* Bad management packet (silently discarded): */
+ MTHCA_CMD_STAT_BAD_PKT = 0x30,
+ /* More outstanding CQEs in CQ than new CQ size: */
+ MTHCA_CMD_STAT_BAD_SIZE = 0x40
+};
+
+enum {
+ MTHCA_TRANS_INVALID = 0,
+ MTHCA_TRANS_RST2INIT,
+ MTHCA_TRANS_INIT2INIT,
+ MTHCA_TRANS_INIT2RTR,
+ MTHCA_TRANS_RTR2RTS,
+ MTHCA_TRANS_RTS2RTS,
+ MTHCA_TRANS_SQERR2RTS,
+ MTHCA_TRANS_ANY2ERR,
+ MTHCA_TRANS_RTS2SQD,
+ MTHCA_TRANS_SQD2SQD,
+ MTHCA_TRANS_SQD2RTS,
+ MTHCA_TRANS_ANY2RST,
+};
+
+enum {
+ DEV_LIM_FLAG_RC = 1 << 0,
+ DEV_LIM_FLAG_UC = 1 << 1,
+ DEV_LIM_FLAG_UD = 1 << 2,
+ DEV_LIM_FLAG_RD = 1 << 3,
+ DEV_LIM_FLAG_RAW_IPV6 = 1 << 4,
+ DEV_LIM_FLAG_RAW_ETHER = 1 << 5,
+ DEV_LIM_FLAG_SRQ = 1 << 6,
+ DEV_LIM_FLAG_IPOIB_CSUM = 1 << 7,
+ DEV_LIM_FLAG_BAD_PKEY_CNTR = 1 << 8,
+ DEV_LIM_FLAG_BAD_QKEY_CNTR = 1 << 9,
+ DEV_LIM_FLAG_MW = 1 << 16,
+ DEV_LIM_FLAG_AUTO_PATH_MIG = 1 << 17,
+ DEV_LIM_FLAG_ATOMIC = 1 << 18,
+ DEV_LIM_FLAG_RAW_MULTI = 1 << 19,
+ DEV_LIM_FLAG_UD_AV_PORT_ENFORCE = 1 << 20,
+ DEV_LIM_FLAG_UD_MULTI = 1 << 21,
+};
+
+struct mthca_mailbox {
+ dma_addr_t dma;
+ void *buf;
+};
+
+struct mthca_dev_lim {
+ int max_srq_sz;
+ int max_qp_sz;
+ int reserved_qps;
+ int max_qps;
+ int reserved_srqs;
+ int max_srqs;
+ int reserved_eecs;
+ int max_eecs;
+ int max_cq_sz;
+ int reserved_cqs;
+ int max_cqs;
+ int max_mpts;
+ int reserved_eqs;
+ int max_eqs;
+ int reserved_mtts;
+ int max_mrw_sz;
+ int reserved_mrws;
+ int max_mtt_seg;
+ int max_requester_per_qp;
+ int max_responder_per_qp;
+ int max_rdma_global;
+ int local_ca_ack_delay;
+ int max_mtu;
+ int max_port_width;
+ int max_vl;
+ int num_ports;
+ int max_gids;
+ u16 stat_rate_support;
+ int max_pkeys;
+ u32 flags;
+ int reserved_uars;
+ int uar_size;
+ int min_page_sz;
+ int max_sg;
+ int max_desc_sz;
+ int max_qp_per_mcg;
+ int reserved_mgms;
+ int max_mcgs;
+ int reserved_pds;
+ int max_pds;
+ int reserved_rdds;
+ int max_rdds;
+ int eec_entry_sz;
+ int qpc_entry_sz;
+ int eeec_entry_sz;
+ int eqpc_entry_sz;
+ int eqc_entry_sz;
+ int cqc_entry_sz;
+ int srq_entry_sz;
+ int uar_scratch_entry_sz;
+ int mpt_entry_sz;
+ union {
+ struct {
+ int max_avs;
+ } tavor;
+ struct {
+ int resize_srq;
+ int max_pbl_sz;
+ u8 bmme_flags;
+ u32 reserved_lkey;
+ int lam_required;
+ u64 max_icm_sz;
+ } arbel;
+ } hca;
+};
+
+struct mthca_adapter {
+ u32 vendor_id;
+ u32 device_id;
+ u32 revision_id;
+ char board_id[MTHCA_BOARD_ID_LEN];
+ u8 inta_pin;
+};
+
+struct mthca_init_hca_param {
+ u64 qpc_base;
+ u64 eec_base;
+ u64 srqc_base;
+ u64 cqc_base;
+ u64 eqpc_base;
+ u64 eeec_base;
+ u64 eqc_base;
+ u64 rdb_base;
+ u64 mc_base;
+ u64 mpt_base;
+ u64 mtt_base;
+ u64 uar_scratch_base;
+ u64 uarc_base;
+ u16 log_mc_entry_sz;
+ u16 mc_hash_sz;
+ u8 log_num_qps;
+ u8 log_num_eecs;
+ u8 log_num_srqs;
+ u8 log_num_cqs;
+ u8 log_num_eqs;
+ u8 log_mc_table_sz;
+ u8 mtt_seg_sz;
+ u8 log_mpt_sz;
+ u8 log_uar_sz;
+ u8 log_uarc_sz;
+};
+
+struct mthca_init_ib_param {
+ int port_width;
+ int vl_cap;
+ int mtu_cap;
+ u16 gid_cap;
+ u16 pkey_cap;
+ int set_guid0;
+ u64 guid0;
+ int set_node_guid;
+ u64 node_guid;
+ int set_si_guid;
+ u64 si_guid;
+};
+
+struct mthca_set_ib_param {
+ int set_si_guid;
+ int reset_qkey_viol;
+ u64 si_guid;
+ u32 cap_mask;
+};
+
+int mthca_cmd_init(struct mthca_dev *dev);
+void mthca_cmd_cleanup(struct mthca_dev *dev);
+int mthca_cmd_use_events(struct mthca_dev *dev);
+void mthca_cmd_use_polling(struct mthca_dev *dev);
+void mthca_cmd_event(struct mthca_dev *dev, u16 token,
+ u8 status, u64 out_param);
+
+struct mthca_mailbox *mthca_alloc_mailbox(struct mthca_dev *dev,
+ gfp_t gfp_mask);
+void mthca_free_mailbox(struct mthca_dev *dev, struct mthca_mailbox *mailbox);
+
+int mthca_SYS_EN(struct mthca_dev *dev);
+int mthca_SYS_DIS(struct mthca_dev *dev);
+int mthca_MAP_FA(struct mthca_dev *dev, struct mthca_icm *icm);
+int mthca_UNMAP_FA(struct mthca_dev *dev);
+int mthca_RUN_FW(struct mthca_dev *dev);
+int mthca_QUERY_FW(struct mthca_dev *dev);
+int mthca_ENABLE_LAM(struct mthca_dev *dev);
+int mthca_DISABLE_LAM(struct mthca_dev *dev);
+int mthca_QUERY_DDR(struct mthca_dev *dev);
+int mthca_QUERY_DEV_LIM(struct mthca_dev *dev,
+ struct mthca_dev_lim *dev_lim);
+int mthca_QUERY_ADAPTER(struct mthca_dev *dev,
+ struct mthca_adapter *adapter);
+int mthca_INIT_HCA(struct mthca_dev *dev,
+ struct mthca_init_hca_param *param);
+int mthca_INIT_IB(struct mthca_dev *dev,
+ struct mthca_init_ib_param *param,
+ int port);
+int mthca_CLOSE_IB(struct mthca_dev *dev, int port);
+int mthca_CLOSE_HCA(struct mthca_dev *dev, int panic);
+int mthca_SET_IB(struct mthca_dev *dev, struct mthca_set_ib_param *param,
+ int port);
+int mthca_MAP_ICM(struct mthca_dev *dev, struct mthca_icm *icm, u64 virt);
+int mthca_MAP_ICM_page(struct mthca_dev *dev, u64 dma_addr, u64 virt);
+int mthca_UNMAP_ICM(struct mthca_dev *dev, u64 virt, u32 page_count);
+int mthca_MAP_ICM_AUX(struct mthca_dev *dev, struct mthca_icm *icm);
+int mthca_UNMAP_ICM_AUX(struct mthca_dev *dev);
+int mthca_SET_ICM_SIZE(struct mthca_dev *dev, u64 icm_size, u64 *aux_pages);
+int mthca_SW2HW_MPT(struct mthca_dev *dev, struct mthca_mailbox *mailbox,
+ int mpt_index);
+int mthca_HW2SW_MPT(struct mthca_dev *dev, struct mthca_mailbox *mailbox,
+ int mpt_index);
+int mthca_WRITE_MTT(struct mthca_dev *dev, struct mthca_mailbox *mailbox,
+ int num_mtt);
+int mthca_SYNC_TPT(struct mthca_dev *dev);
+int mthca_MAP_EQ(struct mthca_dev *dev, u64 event_mask, int unmap,
+ int eq_num);
+int mthca_SW2HW_EQ(struct mthca_dev *dev, struct mthca_mailbox *mailbox,
+ int eq_num);
+int mthca_HW2SW_EQ(struct mthca_dev *dev, struct mthca_mailbox *mailbox,
+ int eq_num);
+int mthca_SW2HW_CQ(struct mthca_dev *dev, struct mthca_mailbox *mailbox,
+ int cq_num);
+int mthca_HW2SW_CQ(struct mthca_dev *dev, struct mthca_mailbox *mailbox,
+ int cq_num);
+int mthca_RESIZE_CQ(struct mthca_dev *dev, int cq_num, u32 lkey, u8 log_size);
+int mthca_SW2HW_SRQ(struct mthca_dev *dev, struct mthca_mailbox *mailbox,
+ int srq_num);
+int mthca_HW2SW_SRQ(struct mthca_dev *dev, struct mthca_mailbox *mailbox,
+ int srq_num);
+int mthca_QUERY_SRQ(struct mthca_dev *dev, u32 num,
+ struct mthca_mailbox *mailbox);
+int mthca_ARM_SRQ(struct mthca_dev *dev, int srq_num, int limit);
+int mthca_MODIFY_QP(struct mthca_dev *dev, enum ib_qp_state cur,
+ enum ib_qp_state next, u32 num, int is_ee,
+ struct mthca_mailbox *mailbox, u32 optmask);
+int mthca_QUERY_QP(struct mthca_dev *dev, u32 num, int is_ee,
+ struct mthca_mailbox *mailbox);
+int mthca_CONF_SPECIAL_QP(struct mthca_dev *dev, int type, u32 qpn);
+int mthca_MAD_IFC(struct mthca_dev *dev, int ignore_mkey, int ignore_bkey,
+ int port, const struct ib_wc *in_wc, const struct ib_grh *in_grh,
+ const void *in_mad, void *response_mad);
+int mthca_READ_MGM(struct mthca_dev *dev, int index,
+ struct mthca_mailbox *mailbox);
+int mthca_WRITE_MGM(struct mthca_dev *dev, int index,
+ struct mthca_mailbox *mailbox);
+int mthca_MGID_HASH(struct mthca_dev *dev, struct mthca_mailbox *mailbox,
+ u16 *hash);
+int mthca_NOP(struct mthca_dev *dev);
+
+#endif /* MTHCA_CMD_H */
diff --git a/sys/dev/mthca/mthca_config_reg.h b/sys/dev/mthca/mthca_config_reg.h
new file mode 100644
index 0000000..155bc66
--- /dev/null
+++ b/sys/dev/mthca/mthca_config_reg.h
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2004 Topspin Communications. All rights reserved.
+ * Copyright (c) 2005 Mellanox Technologies. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#ifndef MTHCA_CONFIG_REG_H
+#define MTHCA_CONFIG_REG_H
+
+#define MTHCA_HCR_BASE 0x80680
+#define MTHCA_HCR_SIZE 0x0001c
+#define MTHCA_ECR_BASE 0x80700
+#define MTHCA_ECR_SIZE 0x00008
+#define MTHCA_ECR_CLR_BASE 0x80708
+#define MTHCA_ECR_CLR_SIZE 0x00008
+#define MTHCA_MAP_ECR_SIZE (MTHCA_ECR_SIZE + MTHCA_ECR_CLR_SIZE)
+#define MTHCA_CLR_INT_BASE 0xf00d8
+#define MTHCA_CLR_INT_SIZE 0x00008
+#define MTHCA_EQ_SET_CI_SIZE (8 * 32)
+
+#endif /* MTHCA_CONFIG_REG_H */
diff --git a/sys/dev/mthca/mthca_cq.c b/sys/dev/mthca/mthca_cq.c
new file mode 100644
index 0000000..a6531ff
--- /dev/null
+++ b/sys/dev/mthca/mthca_cq.c
@@ -0,0 +1,981 @@
+/*
+ * Copyright (c) 2004, 2005 Topspin Communications. All rights reserved.
+ * Copyright (c) 2005 Sun Microsystems, Inc. All rights reserved.
+ * Copyright (c) 2005, 2006 Cisco Systems, Inc. All rights reserved.
+ * Copyright (c) 2005 Mellanox Technologies. All rights reserved.
+ * Copyright (c) 2004 Voltaire, Inc. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#include <linux/gfp.h>
+#include <linux/hardirq.h>
+#include <linux/sched.h>
+
+#include <asm/io.h>
+
+#include <rdma/ib_pack.h>
+
+#include "mthca_dev.h"
+#include "mthca_cmd.h"
+#include "mthca_memfree.h"
+
+enum {
+ MTHCA_MAX_DIRECT_CQ_SIZE = 4 * PAGE_SIZE
+};
+
+enum {
+ MTHCA_CQ_ENTRY_SIZE = 0x20
+};
+
+enum {
+ MTHCA_ATOMIC_BYTE_LEN = 8
+};
+
+/*
+ * Must be packed because start is 64 bits but only aligned to 32 bits.
+ */
+struct mthca_cq_context {
+ __be32 flags;
+ __be64 start;
+ __be32 logsize_usrpage;
+ __be32 error_eqn; /* Tavor only */
+ __be32 comp_eqn;
+ __be32 pd;
+ __be32 lkey;
+ __be32 last_notified_index;
+ __be32 solicit_producer_index;
+ __be32 consumer_index;
+ __be32 producer_index;
+ __be32 cqn;
+ __be32 ci_db; /* Arbel only */
+ __be32 state_db; /* Arbel only */
+ u32 reserved;
+} __attribute__((packed));
+
+#define MTHCA_CQ_STATUS_OK ( 0 << 28)
+#define MTHCA_CQ_STATUS_OVERFLOW ( 9 << 28)
+#define MTHCA_CQ_STATUS_WRITE_FAIL (10 << 28)
+#define MTHCA_CQ_FLAG_TR ( 1 << 18)
+#define MTHCA_CQ_FLAG_OI ( 1 << 17)
+#define MTHCA_CQ_STATE_DISARMED ( 0 << 8)
+#define MTHCA_CQ_STATE_ARMED ( 1 << 8)
+#define MTHCA_CQ_STATE_ARMED_SOL ( 4 << 8)
+#define MTHCA_EQ_STATE_FIRED (10 << 8)
+
+enum {
+ MTHCA_ERROR_CQE_OPCODE_MASK = 0xfe
+};
+
+enum {
+ SYNDROME_LOCAL_LENGTH_ERR = 0x01,
+ SYNDROME_LOCAL_QP_OP_ERR = 0x02,
+ SYNDROME_LOCAL_EEC_OP_ERR = 0x03,
+ SYNDROME_LOCAL_PROT_ERR = 0x04,
+ SYNDROME_WR_FLUSH_ERR = 0x05,
+ SYNDROME_MW_BIND_ERR = 0x06,
+ SYNDROME_BAD_RESP_ERR = 0x10,
+ SYNDROME_LOCAL_ACCESS_ERR = 0x11,
+ SYNDROME_REMOTE_INVAL_REQ_ERR = 0x12,
+ SYNDROME_REMOTE_ACCESS_ERR = 0x13,
+ SYNDROME_REMOTE_OP_ERR = 0x14,
+ SYNDROME_RETRY_EXC_ERR = 0x15,
+ SYNDROME_RNR_RETRY_EXC_ERR = 0x16,
+ SYNDROME_LOCAL_RDD_VIOL_ERR = 0x20,
+ SYNDROME_REMOTE_INVAL_RD_REQ_ERR = 0x21,
+ SYNDROME_REMOTE_ABORTED_ERR = 0x22,
+ SYNDROME_INVAL_EECN_ERR = 0x23,
+ SYNDROME_INVAL_EEC_STATE_ERR = 0x24
+};
+
+struct mthca_cqe {
+ __be32 my_qpn;
+ __be32 my_ee;
+ __be32 rqpn;
+ u8 sl_ipok;
+ u8 g_mlpath;
+ __be16 rlid;
+ __be32 imm_etype_pkey_eec;
+ __be32 byte_cnt;
+ __be32 wqe;
+ u8 opcode;
+ u8 is_send;
+ u8 reserved;
+ u8 owner;
+};
+
+struct mthca_err_cqe {
+ __be32 my_qpn;
+ u32 reserved1[3];
+ u8 syndrome;
+ u8 vendor_err;
+ __be16 db_cnt;
+ u32 reserved2;
+ __be32 wqe;
+ u8 opcode;
+ u8 reserved3[2];
+ u8 owner;
+};
+
+#define MTHCA_CQ_ENTRY_OWNER_SW (0 << 7)
+#define MTHCA_CQ_ENTRY_OWNER_HW (1 << 7)
+
+#define MTHCA_TAVOR_CQ_DB_INC_CI (1 << 24)
+#define MTHCA_TAVOR_CQ_DB_REQ_NOT (2 << 24)
+#define MTHCA_TAVOR_CQ_DB_REQ_NOT_SOL (3 << 24)
+#define MTHCA_TAVOR_CQ_DB_SET_CI (4 << 24)
+#define MTHCA_TAVOR_CQ_DB_REQ_NOT_MULT (5 << 24)
+
+#define MTHCA_ARBEL_CQ_DB_REQ_NOT_SOL (1 << 24)
+#define MTHCA_ARBEL_CQ_DB_REQ_NOT (2 << 24)
+#define MTHCA_ARBEL_CQ_DB_REQ_NOT_MULT (3 << 24)
+
+static inline struct mthca_cqe *get_cqe_from_buf(struct mthca_cq_buf *buf,
+ int entry)
+{
+ if (buf->is_direct)
+ return buf->queue.direct.buf + (entry * MTHCA_CQ_ENTRY_SIZE);
+ else
+ return buf->queue.page_list[entry * MTHCA_CQ_ENTRY_SIZE / PAGE_SIZE].buf
+ + (entry * MTHCA_CQ_ENTRY_SIZE) % PAGE_SIZE;
+}
+
+static inline struct mthca_cqe *get_cqe(struct mthca_cq *cq, int entry)
+{
+ return get_cqe_from_buf(&cq->buf, entry);
+}
+
+static inline struct mthca_cqe *cqe_sw(struct mthca_cqe *cqe)
+{
+ return MTHCA_CQ_ENTRY_OWNER_HW & cqe->owner ? NULL : cqe;
+}
+
+static inline struct mthca_cqe *next_cqe_sw(struct mthca_cq *cq)
+{
+ return cqe_sw(get_cqe(cq, cq->cons_index & cq->ibcq.cqe));
+}
+
+static inline void set_cqe_hw(struct mthca_cqe *cqe)
+{
+ cqe->owner = MTHCA_CQ_ENTRY_OWNER_HW;
+}
+
+static void dump_cqe(struct mthca_dev *dev, void *cqe_ptr)
+{
+ __be32 *cqe = cqe_ptr;
+
+ (void) cqe; /* avoid warning if mthca_dbg compiled away... */
+ mthca_dbg(dev, "CQE contents %08x %08x %08x %08x %08x %08x %08x %08x\n",
+ be32_to_cpu(cqe[0]), be32_to_cpu(cqe[1]), be32_to_cpu(cqe[2]),
+ be32_to_cpu(cqe[3]), be32_to_cpu(cqe[4]), be32_to_cpu(cqe[5]),
+ be32_to_cpu(cqe[6]), be32_to_cpu(cqe[7]));
+}
+
+/*
+ * incr is ignored in native Arbel (mem-free) mode, so cq->cons_index
+ * should be correct before calling update_cons_index().
+ */
+static inline void update_cons_index(struct mthca_dev *dev, struct mthca_cq *cq,
+ int incr)
+{
+ if (mthca_is_memfree(dev)) {
+ *cq->set_ci_db = cpu_to_be32(cq->cons_index);
+ wmb();
+ } else {
+ mthca_write64(MTHCA_TAVOR_CQ_DB_INC_CI | cq->cqn, incr - 1,
+ dev->kar + MTHCA_CQ_DOORBELL,
+ MTHCA_GET_DOORBELL_LOCK(&dev->doorbell_lock));
+ /*
+ * Make sure doorbells don't leak out of CQ spinlock
+ * and reach the HCA out of order:
+ */
+ mmiowb();
+ }
+}
+
+void mthca_cq_completion(struct mthca_dev *dev, u32 cqn)
+{
+ struct mthca_cq *cq;
+
+ cq = mthca_array_get(&dev->cq_table.cq, cqn & (dev->limits.num_cqs - 1));
+
+ if (!cq) {
+ mthca_warn(dev, "Completion event for bogus CQ %08x\n", cqn);
+ return;
+ }
+
+ ++cq->arm_sn;
+
+ cq->ibcq.comp_handler(&cq->ibcq, cq->ibcq.cq_context);
+}
+
+void mthca_cq_event(struct mthca_dev *dev, u32 cqn,
+ enum ib_event_type event_type)
+{
+ struct mthca_cq *cq;
+ struct ib_event event;
+
+ spin_lock(&dev->cq_table.lock);
+
+ cq = mthca_array_get(&dev->cq_table.cq, cqn & (dev->limits.num_cqs - 1));
+ if (cq)
+ ++cq->refcount;
+
+ spin_unlock(&dev->cq_table.lock);
+
+ if (!cq) {
+ mthca_warn(dev, "Async event for bogus CQ %08x\n", cqn);
+ return;
+ }
+
+ event.device = &dev->ib_dev;
+ event.event = event_type;
+ event.element.cq = &cq->ibcq;
+ if (cq->ibcq.event_handler)
+ cq->ibcq.event_handler(&event, cq->ibcq.cq_context);
+
+ spin_lock(&dev->cq_table.lock);
+ if (!--cq->refcount)
+ wake_up(&cq->wait);
+ spin_unlock(&dev->cq_table.lock);
+}
+
+static inline int is_recv_cqe(struct mthca_cqe *cqe)
+{
+ if ((cqe->opcode & MTHCA_ERROR_CQE_OPCODE_MASK) ==
+ MTHCA_ERROR_CQE_OPCODE_MASK)
+ return !(cqe->opcode & 0x01);
+ else
+ return !(cqe->is_send & 0x80);
+}
+
+void mthca_cq_clean(struct mthca_dev *dev, struct mthca_cq *cq, u32 qpn,
+ struct mthca_srq *srq)
+{
+ struct mthca_cqe *cqe;
+ u32 prod_index;
+ int i, nfreed = 0;
+
+ spin_lock_irq(&cq->lock);
+
+ /*
+ * First we need to find the current producer index, so we
+ * know where to start cleaning from. It doesn't matter if HW
+ * adds new entries after this loop -- the QP we're worried
+ * about is already in RESET, so the new entries won't come
+ * from our QP and therefore don't need to be checked.
+ */
+ for (prod_index = cq->cons_index;
+ cqe_sw(get_cqe(cq, prod_index & cq->ibcq.cqe));
+ ++prod_index)
+ if (prod_index == cq->cons_index + cq->ibcq.cqe)
+ break;
+
+ if (0)
+ mthca_dbg(dev, "Cleaning QPN %06x from CQN %06x; ci %d, pi %d\n",
+ qpn, cq->cqn, cq->cons_index, prod_index);
+
+ /*
+ * Now sweep backwards through the CQ, removing CQ entries
+ * that match our QP by copying older entries on top of them.
+ */
+ while ((int) --prod_index - (int) cq->cons_index >= 0) {
+ cqe = get_cqe(cq, prod_index & cq->ibcq.cqe);
+ if (cqe->my_qpn == cpu_to_be32(qpn)) {
+ if (srq && is_recv_cqe(cqe))
+ mthca_free_srq_wqe(srq, be32_to_cpu(cqe->wqe));
+ ++nfreed;
+ } else if (nfreed)
+ memcpy(get_cqe(cq, (prod_index + nfreed) & cq->ibcq.cqe),
+ cqe, MTHCA_CQ_ENTRY_SIZE);
+ }
+
+ if (nfreed) {
+ for (i = 0; i < nfreed; ++i)
+ set_cqe_hw(get_cqe(cq, (cq->cons_index + i) & cq->ibcq.cqe));
+ wmb();
+ cq->cons_index += nfreed;
+ update_cons_index(dev, cq, nfreed);
+ }
+
+ spin_unlock_irq(&cq->lock);
+}
+
+void mthca_cq_resize_copy_cqes(struct mthca_cq *cq)
+{
+ int i;
+
+ /*
+ * In Tavor mode, the hardware keeps the consumer and producer
+ * indices mod the CQ size. Since we might be making the CQ
+ * bigger, we need to deal with the case where the producer
+ * index wrapped around before the CQ was resized.
+ */
+ if (!mthca_is_memfree(to_mdev(cq->ibcq.device)) &&
+ cq->ibcq.cqe < cq->resize_buf->cqe) {
+ cq->cons_index &= cq->ibcq.cqe;
+ if (cqe_sw(get_cqe(cq, cq->ibcq.cqe)))
+ cq->cons_index -= cq->ibcq.cqe + 1;
+ }
+
+ for (i = cq->cons_index; cqe_sw(get_cqe(cq, i & cq->ibcq.cqe)); ++i)
+ memcpy(get_cqe_from_buf(&cq->resize_buf->buf,
+ i & cq->resize_buf->cqe),
+ get_cqe(cq, i & cq->ibcq.cqe), MTHCA_CQ_ENTRY_SIZE);
+}
+
+int mthca_alloc_cq_buf(struct mthca_dev *dev, struct mthca_cq_buf *buf, int nent)
+{
+ int ret;
+ int i;
+
+ ret = mthca_buf_alloc(dev, nent * MTHCA_CQ_ENTRY_SIZE,
+ MTHCA_MAX_DIRECT_CQ_SIZE,
+ &buf->queue, &buf->is_direct,
+ &dev->driver_pd, 1, &buf->mr);
+ if (ret)
+ return ret;
+
+ for (i = 0; i < nent; ++i)
+ set_cqe_hw(get_cqe_from_buf(buf, i));
+
+ return 0;
+}
+
+void mthca_free_cq_buf(struct mthca_dev *dev, struct mthca_cq_buf *buf, int cqe)
+{
+ mthca_buf_free(dev, (cqe + 1) * MTHCA_CQ_ENTRY_SIZE, &buf->queue,
+ buf->is_direct, &buf->mr);
+}
+
+static void handle_error_cqe(struct mthca_dev *dev, struct mthca_cq *cq,
+ struct mthca_qp *qp, int wqe_index, int is_send,
+ struct mthca_err_cqe *cqe,
+ struct ib_wc *entry, int *free_cqe)
+{
+ int dbd;
+ __be32 new_wqe;
+
+ if (cqe->syndrome == SYNDROME_LOCAL_QP_OP_ERR) {
+ mthca_dbg(dev, "local QP operation err "
+ "(QPN %06x, WQE @ %08x, CQN %06x, index %d)\n",
+ be32_to_cpu(cqe->my_qpn), be32_to_cpu(cqe->wqe),
+ cq->cqn, cq->cons_index);
+ dump_cqe(dev, cqe);
+ }
+
+ /*
+ * For completions in error, only work request ID, status, vendor error
+ * (and freed resource count for RD) have to be set.
+ */
+ switch (cqe->syndrome) {
+ case SYNDROME_LOCAL_LENGTH_ERR:
+ entry->status = IB_WC_LOC_LEN_ERR;
+ break;
+ case SYNDROME_LOCAL_QP_OP_ERR:
+ entry->status = IB_WC_LOC_QP_OP_ERR;
+ break;
+ case SYNDROME_LOCAL_EEC_OP_ERR:
+ entry->status = IB_WC_LOC_EEC_OP_ERR;
+ break;
+ case SYNDROME_LOCAL_PROT_ERR:
+ entry->status = IB_WC_LOC_PROT_ERR;
+ break;
+ case SYNDROME_WR_FLUSH_ERR:
+ entry->status = IB_WC_WR_FLUSH_ERR;
+ break;
+ case SYNDROME_MW_BIND_ERR:
+ entry->status = IB_WC_MW_BIND_ERR;
+ break;
+ case SYNDROME_BAD_RESP_ERR:
+ entry->status = IB_WC_BAD_RESP_ERR;
+ break;
+ case SYNDROME_LOCAL_ACCESS_ERR:
+ entry->status = IB_WC_LOC_ACCESS_ERR;
+ break;
+ case SYNDROME_REMOTE_INVAL_REQ_ERR:
+ entry->status = IB_WC_REM_INV_REQ_ERR;
+ break;
+ case SYNDROME_REMOTE_ACCESS_ERR:
+ entry->status = IB_WC_REM_ACCESS_ERR;
+ break;
+ case SYNDROME_REMOTE_OP_ERR:
+ entry->status = IB_WC_REM_OP_ERR;
+ break;
+ case SYNDROME_RETRY_EXC_ERR:
+ entry->status = IB_WC_RETRY_EXC_ERR;
+ break;
+ case SYNDROME_RNR_RETRY_EXC_ERR:
+ entry->status = IB_WC_RNR_RETRY_EXC_ERR;
+ break;
+ case SYNDROME_LOCAL_RDD_VIOL_ERR:
+ entry->status = IB_WC_LOC_RDD_VIOL_ERR;
+ break;
+ case SYNDROME_REMOTE_INVAL_RD_REQ_ERR:
+ entry->status = IB_WC_REM_INV_RD_REQ_ERR;
+ break;
+ case SYNDROME_REMOTE_ABORTED_ERR:
+ entry->status = IB_WC_REM_ABORT_ERR;
+ break;
+ case SYNDROME_INVAL_EECN_ERR:
+ entry->status = IB_WC_INV_EECN_ERR;
+ break;
+ case SYNDROME_INVAL_EEC_STATE_ERR:
+ entry->status = IB_WC_INV_EEC_STATE_ERR;
+ break;
+ default:
+ entry->status = IB_WC_GENERAL_ERR;
+ break;
+ }
+
+ entry->vendor_err = cqe->vendor_err;
+
+ /*
+ * Mem-free HCAs always generate one CQE per WQE, even in the
+ * error case, so we don't have to check the doorbell count, etc.
+ */
+ if (mthca_is_memfree(dev))
+ return;
+
+ mthca_free_err_wqe(dev, qp, is_send, wqe_index, &dbd, &new_wqe);
+
+ /*
+ * If we're at the end of the WQE chain, or we've used up our
+ * doorbell count, free the CQE. Otherwise just update it for
+ * the next poll operation.
+ */
+ if (!(new_wqe & cpu_to_be32(0x3f)) || (!cqe->db_cnt && dbd))
+ return;
+
+ be16_add_cpu(&cqe->db_cnt, -dbd);
+ cqe->wqe = new_wqe;
+ cqe->syndrome = SYNDROME_WR_FLUSH_ERR;
+
+ *free_cqe = 0;
+}
+
+static inline int mthca_poll_one(struct mthca_dev *dev,
+ struct mthca_cq *cq,
+ struct mthca_qp **cur_qp,
+ int *freed,
+ struct ib_wc *entry)
+{
+ struct mthca_wq *wq;
+ struct mthca_cqe *cqe;
+ int wqe_index;
+ int is_error;
+ int is_send;
+ int free_cqe = 1;
+ int err = 0;
+ u16 checksum;
+
+ cqe = next_cqe_sw(cq);
+ if (!cqe)
+ return -EAGAIN;
+
+ /*
+ * Make sure we read CQ entry contents after we've checked the
+ * ownership bit.
+ */
+ rmb();
+
+ if (0) {
+ mthca_dbg(dev, "%x/%d: CQE -> QPN %06x, WQE @ %08x\n",
+ cq->cqn, cq->cons_index, be32_to_cpu(cqe->my_qpn),
+ be32_to_cpu(cqe->wqe));
+ dump_cqe(dev, cqe);
+ }
+
+ is_error = (cqe->opcode & MTHCA_ERROR_CQE_OPCODE_MASK) ==
+ MTHCA_ERROR_CQE_OPCODE_MASK;
+ is_send = is_error ? cqe->opcode & 0x01 : cqe->is_send & 0x80;
+
+ if (!*cur_qp || be32_to_cpu(cqe->my_qpn) != (*cur_qp)->qpn) {
+ /*
+ * We do not have to take the QP table lock here,
+ * because CQs will be locked while QPs are removed
+ * from the table.
+ */
+ *cur_qp = mthca_array_get(&dev->qp_table.qp,
+ be32_to_cpu(cqe->my_qpn) &
+ (dev->limits.num_qps - 1));
+ if (!*cur_qp) {
+ mthca_warn(dev, "CQ entry for unknown QP %06x\n",
+ be32_to_cpu(cqe->my_qpn) & 0xffffff);
+ err = -EINVAL;
+ goto out;
+ }
+ }
+
+ entry->qp = &(*cur_qp)->ibqp;
+
+ if (is_send) {
+ wq = &(*cur_qp)->sq;
+ wqe_index = ((be32_to_cpu(cqe->wqe) - (*cur_qp)->send_wqe_offset)
+ >> wq->wqe_shift);
+ entry->wr_id = (*cur_qp)->wrid[wqe_index +
+ (*cur_qp)->rq.max];
+ } else if ((*cur_qp)->ibqp.srq) {
+ struct mthca_srq *srq = to_msrq((*cur_qp)->ibqp.srq);
+ u32 wqe = be32_to_cpu(cqe->wqe);
+ wq = NULL;
+ wqe_index = wqe >> srq->wqe_shift;
+ entry->wr_id = srq->wrid[wqe_index];
+ mthca_free_srq_wqe(srq, wqe);
+ } else {
+ s32 wqe;
+ wq = &(*cur_qp)->rq;
+ wqe = be32_to_cpu(cqe->wqe);
+ wqe_index = wqe >> wq->wqe_shift;
+ /*
+ * WQE addr == base - 1 might be reported in receive completion
+ * with error instead of (rq size - 1) by Sinai FW 1.0.800 and
+ * Arbel FW 5.1.400. This bug should be fixed in later FW revs.
+ */
+ if (unlikely(wqe_index < 0))
+ wqe_index = wq->max - 1;
+ entry->wr_id = (*cur_qp)->wrid[wqe_index];
+ }
+
+ if (wq) {
+ if (wq->last_comp < wqe_index)
+ wq->tail += wqe_index - wq->last_comp;
+ else
+ wq->tail += wqe_index + wq->max - wq->last_comp;
+
+ wq->last_comp = wqe_index;
+ }
+
+ if (is_error) {
+ handle_error_cqe(dev, cq, *cur_qp, wqe_index, is_send,
+ (struct mthca_err_cqe *) cqe,
+ entry, &free_cqe);
+ goto out;
+ }
+
+ if (is_send) {
+ entry->wc_flags = 0;
+ switch (cqe->opcode) {
+ case MTHCA_OPCODE_RDMA_WRITE:
+ entry->opcode = IB_WC_RDMA_WRITE;
+ break;
+ case MTHCA_OPCODE_RDMA_WRITE_IMM:
+ entry->opcode = IB_WC_RDMA_WRITE;
+ entry->wc_flags |= IB_WC_WITH_IMM;
+ break;
+ case MTHCA_OPCODE_SEND:
+ entry->opcode = IB_WC_SEND;
+ break;
+ case MTHCA_OPCODE_SEND_IMM:
+ entry->opcode = IB_WC_SEND;
+ entry->wc_flags |= IB_WC_WITH_IMM;
+ break;
+ case MTHCA_OPCODE_RDMA_READ:
+ entry->opcode = IB_WC_RDMA_READ;
+ entry->byte_len = be32_to_cpu(cqe->byte_cnt);
+ break;
+ case MTHCA_OPCODE_ATOMIC_CS:
+ entry->opcode = IB_WC_COMP_SWAP;
+ entry->byte_len = MTHCA_ATOMIC_BYTE_LEN;
+ break;
+ case MTHCA_OPCODE_ATOMIC_FA:
+ entry->opcode = IB_WC_FETCH_ADD;
+ entry->byte_len = MTHCA_ATOMIC_BYTE_LEN;
+ break;
+ default:
+ entry->opcode = MTHCA_OPCODE_INVALID;
+ break;
+ }
+ } else {
+ entry->byte_len = be32_to_cpu(cqe->byte_cnt);
+ switch (cqe->opcode & 0x1f) {
+ case IB_OPCODE_SEND_LAST_WITH_IMMEDIATE:
+ case IB_OPCODE_SEND_ONLY_WITH_IMMEDIATE:
+ entry->wc_flags = IB_WC_WITH_IMM;
+ entry->ex.imm_data = cqe->imm_etype_pkey_eec;
+ entry->opcode = IB_WC_RECV;
+ break;
+ case IB_OPCODE_RDMA_WRITE_LAST_WITH_IMMEDIATE:
+ case IB_OPCODE_RDMA_WRITE_ONLY_WITH_IMMEDIATE:
+ entry->wc_flags = IB_WC_WITH_IMM;
+ entry->ex.imm_data = cqe->imm_etype_pkey_eec;
+ entry->opcode = IB_WC_RECV_RDMA_WITH_IMM;
+ break;
+ default:
+ entry->wc_flags = 0;
+ entry->opcode = IB_WC_RECV;
+ break;
+ }
+ entry->slid = be16_to_cpu(cqe->rlid);
+ entry->sl = cqe->sl_ipok >> 4;
+ entry->src_qp = be32_to_cpu(cqe->rqpn) & 0xffffff;
+ entry->dlid_path_bits = cqe->g_mlpath & 0x7f;
+ entry->pkey_index = be32_to_cpu(cqe->imm_etype_pkey_eec) >> 16;
+ entry->wc_flags |= cqe->g_mlpath & 0x80 ? IB_WC_GRH : 0;
+ checksum = (be32_to_cpu(cqe->rqpn) >> 24) |
+ ((be32_to_cpu(cqe->my_ee) >> 16) & 0xff00);
+ entry->wc_flags |= (cqe->sl_ipok & 1 && checksum == 0xffff) ?
+ IB_WC_IP_CSUM_OK : 0;
+ }
+
+ entry->status = IB_WC_SUCCESS;
+
+ out:
+ if (likely(free_cqe)) {
+ set_cqe_hw(cqe);
+ ++(*freed);
+ ++cq->cons_index;
+ }
+
+ return err;
+}
+
+int mthca_poll_cq(struct ib_cq *ibcq, int num_entries,
+ struct ib_wc *entry)
+{
+ struct mthca_dev *dev = to_mdev(ibcq->device);
+ struct mthca_cq *cq = to_mcq(ibcq);
+ struct mthca_qp *qp = NULL;
+ unsigned long flags;
+ int err = 0;
+ int freed = 0;
+ int npolled;
+
+ spin_lock_irqsave(&cq->lock, flags);
+
+ npolled = 0;
+repoll:
+ while (npolled < num_entries) {
+ err = mthca_poll_one(dev, cq, &qp,
+ &freed, entry + npolled);
+ if (err)
+ break;
+ ++npolled;
+ }
+
+ if (freed) {
+ wmb();
+ update_cons_index(dev, cq, freed);
+ }
+
+ /*
+ * If a CQ resize is in progress and we discovered that the
+ * old buffer is empty, then peek in the new buffer, and if
+ * it's not empty, switch to the new buffer and continue
+ * polling there.
+ */
+ if (unlikely(err == -EAGAIN && cq->resize_buf &&
+ cq->resize_buf->state == CQ_RESIZE_READY)) {
+ /*
+ * In Tavor mode, the hardware keeps the producer
+ * index modulo the CQ size. Since we might be making
+ * the CQ bigger, we need to mask our consumer index
+ * using the size of the old CQ buffer before looking
+ * in the new CQ buffer.
+ */
+ if (!mthca_is_memfree(dev))
+ cq->cons_index &= cq->ibcq.cqe;
+
+ if (cqe_sw(get_cqe_from_buf(&cq->resize_buf->buf,
+ cq->cons_index & cq->resize_buf->cqe))) {
+ struct mthca_cq_buf tbuf;
+ int tcqe;
+
+ tbuf = cq->buf;
+ tcqe = cq->ibcq.cqe;
+ cq->buf = cq->resize_buf->buf;
+ cq->ibcq.cqe = cq->resize_buf->cqe;
+
+ cq->resize_buf->buf = tbuf;
+ cq->resize_buf->cqe = tcqe;
+ cq->resize_buf->state = CQ_RESIZE_SWAPPED;
+
+ goto repoll;
+ }
+ }
+
+ spin_unlock_irqrestore(&cq->lock, flags);
+
+ return err == 0 || err == -EAGAIN ? npolled : err;
+}
+
+int mthca_tavor_arm_cq(struct ib_cq *cq, enum ib_cq_notify_flags flags)
+{
+ u32 dbhi = ((flags & IB_CQ_SOLICITED_MASK) == IB_CQ_SOLICITED ?
+ MTHCA_TAVOR_CQ_DB_REQ_NOT_SOL :
+ MTHCA_TAVOR_CQ_DB_REQ_NOT) |
+ to_mcq(cq)->cqn;
+
+ mthca_write64(dbhi, 0xffffffff, to_mdev(cq->device)->kar + MTHCA_CQ_DOORBELL,
+ MTHCA_GET_DOORBELL_LOCK(&to_mdev(cq->device)->doorbell_lock));
+
+ return 0;
+}
+
+int mthca_arbel_arm_cq(struct ib_cq *ibcq, enum ib_cq_notify_flags flags)
+{
+ struct mthca_cq *cq = to_mcq(ibcq);
+ __be32 db_rec[2];
+ u32 dbhi;
+ u32 sn = cq->arm_sn & 3;
+
+ db_rec[0] = cpu_to_be32(cq->cons_index);
+ db_rec[1] = cpu_to_be32((cq->cqn << 8) | (2 << 5) | (sn << 3) |
+ ((flags & IB_CQ_SOLICITED_MASK) ==
+ IB_CQ_SOLICITED ? 1 : 2));
+
+ mthca_write_db_rec(db_rec, cq->arm_db);
+
+ /*
+ * Make sure that the doorbell record in host memory is
+ * written before ringing the doorbell via PCI MMIO.
+ */
+ wmb();
+
+ dbhi = (sn << 28) |
+ ((flags & IB_CQ_SOLICITED_MASK) == IB_CQ_SOLICITED ?
+ MTHCA_ARBEL_CQ_DB_REQ_NOT_SOL :
+ MTHCA_ARBEL_CQ_DB_REQ_NOT) | cq->cqn;
+
+ mthca_write64(dbhi, cq->cons_index,
+ to_mdev(ibcq->device)->kar + MTHCA_CQ_DOORBELL,
+ MTHCA_GET_DOORBELL_LOCK(&to_mdev(ibcq->device)->doorbell_lock));
+
+ return 0;
+}
+
+int mthca_init_cq(struct mthca_dev *dev, int nent,
+ struct mthca_ucontext *ctx, u32 pdn,
+ struct mthca_cq *cq)
+{
+ struct mthca_mailbox *mailbox;
+ struct mthca_cq_context *cq_context;
+ int err = -ENOMEM;
+
+ cq->ibcq.cqe = nent - 1;
+ cq->is_kernel = !ctx;
+
+ cq->cqn = mthca_alloc(&dev->cq_table.alloc);
+ if (cq->cqn == -1)
+ return -ENOMEM;
+
+ if (mthca_is_memfree(dev)) {
+ err = mthca_table_get(dev, dev->cq_table.table, cq->cqn);
+ if (err)
+ goto err_out;
+
+ if (cq->is_kernel) {
+ cq->arm_sn = 1;
+
+ err = -ENOMEM;
+
+ cq->set_ci_db_index = mthca_alloc_db(dev, MTHCA_DB_TYPE_CQ_SET_CI,
+ cq->cqn, &cq->set_ci_db);
+ if (cq->set_ci_db_index < 0)
+ goto err_out_icm;
+
+ cq->arm_db_index = mthca_alloc_db(dev, MTHCA_DB_TYPE_CQ_ARM,
+ cq->cqn, &cq->arm_db);
+ if (cq->arm_db_index < 0)
+ goto err_out_ci;
+ }
+ }
+
+ mailbox = mthca_alloc_mailbox(dev, GFP_KERNEL);
+ if (IS_ERR(mailbox))
+ goto err_out_arm;
+
+ cq_context = mailbox->buf;
+
+ if (cq->is_kernel) {
+ err = mthca_alloc_cq_buf(dev, &cq->buf, nent);
+ if (err)
+ goto err_out_mailbox;
+ }
+
+ spin_lock_init(&cq->lock);
+ cq->refcount = 1;
+ init_waitqueue_head(&cq->wait);
+ mutex_init(&cq->mutex);
+
+ memset(cq_context, 0, sizeof *cq_context);
+ cq_context->flags = cpu_to_be32(MTHCA_CQ_STATUS_OK |
+ MTHCA_CQ_STATE_DISARMED |
+ MTHCA_CQ_FLAG_TR);
+ cq_context->logsize_usrpage = cpu_to_be32((ffs(nent) - 1) << 24);
+ if (ctx)
+ cq_context->logsize_usrpage |= cpu_to_be32(ctx->uar.index);
+ else
+ cq_context->logsize_usrpage |= cpu_to_be32(dev->driver_uar.index);
+ cq_context->error_eqn = cpu_to_be32(dev->eq_table.eq[MTHCA_EQ_ASYNC].eqn);
+ cq_context->comp_eqn = cpu_to_be32(dev->eq_table.eq[MTHCA_EQ_COMP].eqn);
+ cq_context->pd = cpu_to_be32(pdn);
+ cq_context->lkey = cpu_to_be32(cq->buf.mr.ibmr.lkey);
+ cq_context->cqn = cpu_to_be32(cq->cqn);
+
+ if (mthca_is_memfree(dev)) {
+ cq_context->ci_db = cpu_to_be32(cq->set_ci_db_index);
+ cq_context->state_db = cpu_to_be32(cq->arm_db_index);
+ }
+
+ err = mthca_SW2HW_CQ(dev, mailbox, cq->cqn);
+ if (err) {
+ mthca_warn(dev, "SW2HW_CQ failed (%d)\n", err);
+ goto err_out_free_mr;
+ }
+
+ spin_lock_irq(&dev->cq_table.lock);
+ if (mthca_array_set(&dev->cq_table.cq,
+ cq->cqn & (dev->limits.num_cqs - 1),
+ cq)) {
+ spin_unlock_irq(&dev->cq_table.lock);
+ goto err_out_free_mr;
+ }
+ spin_unlock_irq(&dev->cq_table.lock);
+
+ cq->cons_index = 0;
+
+ mthca_free_mailbox(dev, mailbox);
+
+ return 0;
+
+err_out_free_mr:
+ if (cq->is_kernel)
+ mthca_free_cq_buf(dev, &cq->buf, cq->ibcq.cqe);
+
+err_out_mailbox:
+ mthca_free_mailbox(dev, mailbox);
+
+err_out_arm:
+ if (cq->is_kernel && mthca_is_memfree(dev))
+ mthca_free_db(dev, MTHCA_DB_TYPE_CQ_ARM, cq->arm_db_index);
+
+err_out_ci:
+ if (cq->is_kernel && mthca_is_memfree(dev))
+ mthca_free_db(dev, MTHCA_DB_TYPE_CQ_SET_CI, cq->set_ci_db_index);
+
+err_out_icm:
+ mthca_table_put(dev, dev->cq_table.table, cq->cqn);
+
+err_out:
+ mthca_free(&dev->cq_table.alloc, cq->cqn);
+
+ return err;
+}
+
+static inline int get_cq_refcount(struct mthca_dev *dev, struct mthca_cq *cq)
+{
+ int c;
+
+ spin_lock_irq(&dev->cq_table.lock);
+ c = cq->refcount;
+ spin_unlock_irq(&dev->cq_table.lock);
+
+ return c;
+}
+
+void mthca_free_cq(struct mthca_dev *dev,
+ struct mthca_cq *cq)
+{
+ struct mthca_mailbox *mailbox;
+ int err;
+
+ mailbox = mthca_alloc_mailbox(dev, GFP_KERNEL);
+ if (IS_ERR(mailbox)) {
+ mthca_warn(dev, "No memory for mailbox to free CQ.\n");
+ return;
+ }
+
+ err = mthca_HW2SW_CQ(dev, mailbox, cq->cqn);
+ if (err)
+ mthca_warn(dev, "HW2SW_CQ failed (%d)\n", err);
+
+ if (0) {
+ __be32 *ctx = mailbox->buf;
+ int j;
+
+ printk(KERN_ERR "context for CQN %x (cons index %x, next sw %d)\n",
+ cq->cqn, cq->cons_index,
+ cq->is_kernel ? !!next_cqe_sw(cq) : 0);
+ for (j = 0; j < 16; ++j)
+ printk(KERN_ERR "[%2x] %08x\n", j * 4, be32_to_cpu(ctx[j]));
+ }
+
+ spin_lock_irq(&dev->cq_table.lock);
+ mthca_array_clear(&dev->cq_table.cq,
+ cq->cqn & (dev->limits.num_cqs - 1));
+ --cq->refcount;
+ spin_unlock_irq(&dev->cq_table.lock);
+
+ if (dev->mthca_flags & MTHCA_FLAG_MSI_X)
+ synchronize_irq(dev->eq_table.eq[MTHCA_EQ_COMP].msi_x_vector);
+ else
+ synchronize_irq(dev->pdev->irq);
+
+ wait_event(cq->wait, !get_cq_refcount(dev, cq));
+
+ if (cq->is_kernel) {
+ mthca_free_cq_buf(dev, &cq->buf, cq->ibcq.cqe);
+ if (mthca_is_memfree(dev)) {
+ mthca_free_db(dev, MTHCA_DB_TYPE_CQ_ARM, cq->arm_db_index);
+ mthca_free_db(dev, MTHCA_DB_TYPE_CQ_SET_CI, cq->set_ci_db_index);
+ }
+ }
+
+ mthca_table_put(dev, dev->cq_table.table, cq->cqn);
+ mthca_free(&dev->cq_table.alloc, cq->cqn);
+ mthca_free_mailbox(dev, mailbox);
+}
+
+int mthca_init_cq_table(struct mthca_dev *dev)
+{
+ int err;
+
+ spin_lock_init(&dev->cq_table.lock);
+
+ err = mthca_alloc_init(&dev->cq_table.alloc,
+ dev->limits.num_cqs,
+ (1 << 24) - 1,
+ dev->limits.reserved_cqs);
+ if (err)
+ return err;
+
+ err = mthca_array_init(&dev->cq_table.cq,
+ dev->limits.num_cqs);
+ if (err)
+ mthca_alloc_cleanup(&dev->cq_table.alloc);
+
+ return err;
+}
+
+void mthca_cleanup_cq_table(struct mthca_dev *dev)
+{
+ mthca_array_cleanup(&dev->cq_table.cq, dev->limits.num_cqs);
+ mthca_alloc_cleanup(&dev->cq_table.alloc);
+}
diff --git a/sys/dev/mthca/mthca_dev.h b/sys/dev/mthca/mthca_dev.h
new file mode 100644
index 0000000..854d37e
--- /dev/null
+++ b/sys/dev/mthca/mthca_dev.h
@@ -0,0 +1,599 @@
+/*
+ * Copyright (c) 2004, 2005 Topspin Communications. All rights reserved.
+ * Copyright (c) 2005 Sun Microsystems, Inc. All rights reserved.
+ * Copyright (c) 2005, 2006 Cisco Systems. All rights reserved.
+ * Copyright (c) 2005 Mellanox Technologies. All rights reserved.
+ * Copyright (c) 2004 Voltaire, Inc. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#ifndef MTHCA_DEV_H
+#define MTHCA_DEV_H
+
+#include <linux/spinlock.h>
+#include <linux/kernel.h>
+#include <linux/pci.h>
+#include <linux/dma-mapping.h>
+#include <linux/timer.h>
+#include <linux/mutex.h>
+#include <linux/list.h>
+#include <linux/semaphore.h>
+
+#include "mthca_provider.h"
+#include "mthca_doorbell.h"
+
+#define DRV_NAME "ib_mthca"
+#define PFX DRV_NAME ": "
+#ifndef DRV_VERSION
+#define DRV_VERSION "1.0"
+#endif
+#define DRV_RELDATE "April 4, 2008"
+
+enum {
+ MTHCA_FLAG_DDR_HIDDEN = 1 << 1,
+ MTHCA_FLAG_SRQ = 1 << 2,
+ MTHCA_FLAG_MSI_X = 1 << 3,
+ MTHCA_FLAG_NO_LAM = 1 << 4,
+ MTHCA_FLAG_FMR = 1 << 5,
+ MTHCA_FLAG_MEMFREE = 1 << 6,
+ MTHCA_FLAG_PCIE = 1 << 7,
+ MTHCA_FLAG_SINAI_OPT = 1 << 8
+};
+
+enum {
+ MTHCA_MAX_PORTS = 2
+};
+
+enum {
+ MTHCA_BOARD_ID_LEN = 64
+};
+
+enum {
+ MTHCA_EQ_CONTEXT_SIZE = 0x40,
+ MTHCA_CQ_CONTEXT_SIZE = 0x40,
+ MTHCA_QP_CONTEXT_SIZE = 0x200,
+ MTHCA_RDB_ENTRY_SIZE = 0x20,
+ MTHCA_AV_SIZE = 0x20,
+ MTHCA_MGM_ENTRY_SIZE = 0x100,
+
+ /* Arbel FW gives us these, but we need them for Tavor */
+ MTHCA_MPT_ENTRY_SIZE = 0x40,
+ MTHCA_MTT_SEG_SIZE = 0x40,
+
+ MTHCA_QP_PER_MGM = 4 * (MTHCA_MGM_ENTRY_SIZE / 16 - 2)
+};
+
+enum {
+ MTHCA_EQ_CMD,
+ MTHCA_EQ_ASYNC,
+ MTHCA_EQ_COMP,
+ MTHCA_NUM_EQ
+};
+
+enum {
+ MTHCA_OPCODE_NOP = 0x00,
+ MTHCA_OPCODE_RDMA_WRITE = 0x08,
+ MTHCA_OPCODE_RDMA_WRITE_IMM = 0x09,
+ MTHCA_OPCODE_SEND = 0x0a,
+ MTHCA_OPCODE_SEND_IMM = 0x0b,
+ MTHCA_OPCODE_RDMA_READ = 0x10,
+ MTHCA_OPCODE_ATOMIC_CS = 0x11,
+ MTHCA_OPCODE_ATOMIC_FA = 0x12,
+ MTHCA_OPCODE_BIND_MW = 0x18,
+ MTHCA_OPCODE_INVALID = 0xff
+};
+
+enum {
+ MTHCA_CMD_USE_EVENTS = 1 << 0,
+ MTHCA_CMD_POST_DOORBELLS = 1 << 1
+};
+
+enum {
+ MTHCA_CMD_NUM_DBELL_DWORDS = 8
+};
+
+struct mthca_cmd {
+ struct pci_pool *pool;
+ struct mutex hcr_mutex;
+ struct semaphore poll_sem;
+ struct semaphore event_sem;
+ int max_cmds;
+ spinlock_t context_lock;
+ int free_head;
+ struct mthca_cmd_context *context;
+ u16 token_mask;
+ u32 flags;
+ void __iomem *dbell_map;
+ u16 dbell_offsets[MTHCA_CMD_NUM_DBELL_DWORDS];
+};
+
+struct mthca_limits {
+ int num_ports;
+ int vl_cap;
+ int mtu_cap;
+ int gid_table_len;
+ int pkey_table_len;
+ int local_ca_ack_delay;
+ int num_uars;
+ int max_sg;
+ int num_qps;
+ int max_wqes;
+ int max_desc_sz;
+ int max_qp_init_rdma;
+ int reserved_qps;
+ int num_srqs;
+ int max_srq_wqes;
+ int max_srq_sge;
+ int reserved_srqs;
+ int num_eecs;
+ int reserved_eecs;
+ int num_cqs;
+ int max_cqes;
+ int reserved_cqs;
+ int num_eqs;
+ int reserved_eqs;
+ int num_mpts;
+ int num_mtt_segs;
+ int mtt_seg_size;
+ int fmr_reserved_mtts;
+ int reserved_mtts;
+ int reserved_mrws;
+ int reserved_uars;
+ int num_mgms;
+ int num_amgms;
+ int reserved_mcgs;
+ int num_pds;
+ int reserved_pds;
+ u32 page_size_cap;
+ u32 flags;
+ u16 stat_rate_support;
+ u8 port_width_cap;
+};
+
+struct mthca_alloc {
+ u32 last;
+ u32 top;
+ u32 max;
+ u32 mask;
+ spinlock_t lock;
+ unsigned long *table;
+};
+
+struct mthca_array {
+ struct {
+ void **page;
+ int used;
+ } *page_list;
+};
+
+struct mthca_uar_table {
+ struct mthca_alloc alloc;
+ u64 uarc_base;
+ int uarc_size;
+};
+
+struct mthca_pd_table {
+ struct mthca_alloc alloc;
+};
+
+struct mthca_buddy {
+ unsigned long **bits;
+ int *num_free;
+ int max_order;
+ spinlock_t lock;
+};
+
+struct mthca_mr_table {
+ struct mthca_alloc mpt_alloc;
+ struct mthca_buddy mtt_buddy;
+ struct mthca_buddy *fmr_mtt_buddy;
+ u64 mtt_base;
+ u64 mpt_base;
+ struct mthca_icm_table *mtt_table;
+ struct mthca_icm_table *mpt_table;
+ struct {
+ void __iomem *mpt_base;
+ void __iomem *mtt_base;
+ struct mthca_buddy mtt_buddy;
+ } tavor_fmr;
+};
+
+struct mthca_eq_table {
+ struct mthca_alloc alloc;
+ void __iomem *clr_int;
+ u32 clr_mask;
+ u32 arm_mask;
+ struct mthca_eq eq[MTHCA_NUM_EQ];
+ u64 icm_virt;
+ struct page *icm_page;
+ dma_addr_t icm_dma;
+ int have_irq;
+ u8 inta_pin;
+};
+
+struct mthca_cq_table {
+ struct mthca_alloc alloc;
+ spinlock_t lock;
+ struct mthca_array cq;
+ struct mthca_icm_table *table;
+};
+
+struct mthca_srq_table {
+ struct mthca_alloc alloc;
+ spinlock_t lock;
+ struct mthca_array srq;
+ struct mthca_icm_table *table;
+};
+
+struct mthca_qp_table {
+ struct mthca_alloc alloc;
+ u32 rdb_base;
+ int rdb_shift;
+ int sqp_start;
+ spinlock_t lock;
+ struct mthca_array qp;
+ struct mthca_icm_table *qp_table;
+ struct mthca_icm_table *eqp_table;
+ struct mthca_icm_table *rdb_table;
+};
+
+struct mthca_av_table {
+ struct pci_pool *pool;
+ int num_ddr_avs;
+ u64 ddr_av_base;
+ void __iomem *av_map;
+ struct mthca_alloc alloc;
+};
+
+struct mthca_mcg_table {
+ struct mutex mutex;
+ struct mthca_alloc alloc;
+ struct mthca_icm_table *table;
+};
+
+struct mthca_catas_err {
+ u64 addr;
+ u32 __iomem *map;
+ u32 size;
+ struct timer_list timer;
+ struct list_head list;
+};
+
+extern struct mutex mthca_device_mutex;
+
+struct mthca_dev {
+ struct ib_device ib_dev;
+ struct pci_dev *pdev;
+
+ int hca_type;
+ unsigned long mthca_flags;
+ unsigned long device_cap_flags;
+
+ u32 rev_id;
+ char board_id[MTHCA_BOARD_ID_LEN];
+
+ /* firmware info */
+ u64 fw_ver;
+ union {
+ struct {
+ u64 fw_start;
+ u64 fw_end;
+ } tavor;
+ struct {
+ u64 clr_int_base;
+ u64 eq_arm_base;
+ u64 eq_set_ci_base;
+ struct mthca_icm *fw_icm;
+ struct mthca_icm *aux_icm;
+ u16 fw_pages;
+ } arbel;
+ } fw;
+
+ u64 ddr_start;
+ u64 ddr_end;
+
+ MTHCA_DECLARE_DOORBELL_LOCK(doorbell_lock)
+ struct mutex cap_mask_mutex;
+
+ void __iomem *hcr;
+ void __iomem *kar;
+ void __iomem *clr_base;
+ union {
+ struct {
+ void __iomem *ecr_base;
+ } tavor;
+ struct {
+ void __iomem *eq_arm;
+ void __iomem *eq_set_ci_base;
+ } arbel;
+ } eq_regs;
+
+ struct mthca_cmd cmd;
+ struct mthca_limits limits;
+
+ struct mthca_uar_table uar_table;
+ struct mthca_pd_table pd_table;
+ struct mthca_mr_table mr_table;
+ struct mthca_eq_table eq_table;
+ struct mthca_cq_table cq_table;
+ struct mthca_srq_table srq_table;
+ struct mthca_qp_table qp_table;
+ struct mthca_av_table av_table;
+ struct mthca_mcg_table mcg_table;
+
+ struct mthca_catas_err catas_err;
+
+ struct mthca_uar driver_uar;
+ struct mthca_db_table *db_tab;
+ struct mthca_pd driver_pd;
+ struct mthca_mr driver_mr;
+
+ struct ib_mad_agent *send_agent[MTHCA_MAX_PORTS][2];
+ struct ib_ah *sm_ah[MTHCA_MAX_PORTS];
+ spinlock_t sm_lock;
+ u8 rate[MTHCA_MAX_PORTS];
+ bool active;
+};
+
+#ifdef CONFIG_INFINIBAND_MTHCA_DEBUG
+extern int mthca_debug_level;
+
+#define mthca_dbg(mdev, format, arg...) \
+ do { \
+ if (mthca_debug_level) \
+ dev_printk(KERN_DEBUG, &mdev->pdev->dev, format, ## arg); \
+ } while (0)
+
+#else /* CONFIG_INFINIBAND_MTHCA_DEBUG */
+
+#define mthca_dbg(mdev, format, arg...) do { (void) mdev; } while (0)
+
+#endif /* CONFIG_INFINIBAND_MTHCA_DEBUG */
+
+#define mthca_err(mdev, format, arg...) \
+ dev_err(&mdev->pdev->dev, format, ## arg)
+#define mthca_info(mdev, format, arg...) \
+ dev_info(&mdev->pdev->dev, format, ## arg)
+#define mthca_warn(mdev, format, arg...) \
+ dev_warn(&mdev->pdev->dev, format, ## arg)
+
+extern void __buggy_use_of_MTHCA_GET(void);
+extern void __buggy_use_of_MTHCA_PUT(void);
+
+#define MTHCA_GET(dest, source, offset) \
+ do { \
+ void *__p = (char *) (source) + (offset); \
+ switch (sizeof (dest)) { \
+ case 1: (dest) = *(u8 *) __p; break; \
+ case 2: (dest) = be16_to_cpup(__p); break; \
+ case 4: (dest) = be32_to_cpup(__p); break; \
+ case 8: (dest) = be64_to_cpup(__p); break; \
+ default: __buggy_use_of_MTHCA_GET(); \
+ } \
+ } while (0)
+
+#define MTHCA_PUT(dest, source, offset) \
+ do { \
+ void *__d = ((char *) (dest) + (offset)); \
+ switch (sizeof(source)) { \
+ case 1: *(u8 *) __d = (source); break; \
+ case 2: *(__be16 *) __d = cpu_to_be16(source); break; \
+ case 4: *(__be32 *) __d = cpu_to_be32(source); break; \
+ case 8: *(__be64 *) __d = cpu_to_be64(source); break; \
+ default: __buggy_use_of_MTHCA_PUT(); \
+ } \
+ } while (0)
+
+int mthca_reset(struct mthca_dev *mdev);
+
+u32 mthca_alloc(struct mthca_alloc *alloc);
+void mthca_free(struct mthca_alloc *alloc, u32 obj);
+int mthca_alloc_init(struct mthca_alloc *alloc, u32 num, u32 mask,
+ u32 reserved);
+void mthca_alloc_cleanup(struct mthca_alloc *alloc);
+void *mthca_array_get(struct mthca_array *array, int index);
+int mthca_array_set(struct mthca_array *array, int index, void *value);
+void mthca_array_clear(struct mthca_array *array, int index);
+int mthca_array_init(struct mthca_array *array, int nent);
+void mthca_array_cleanup(struct mthca_array *array, int nent);
+int mthca_buf_alloc(struct mthca_dev *dev, int size, int max_direct,
+ union mthca_buf *buf, int *is_direct, struct mthca_pd *pd,
+ int hca_write, struct mthca_mr *mr);
+void mthca_buf_free(struct mthca_dev *dev, int size, union mthca_buf *buf,
+ int is_direct, struct mthca_mr *mr);
+
+int mthca_init_uar_table(struct mthca_dev *dev);
+int mthca_init_pd_table(struct mthca_dev *dev);
+int mthca_init_mr_table(struct mthca_dev *dev);
+int mthca_init_eq_table(struct mthca_dev *dev);
+int mthca_init_cq_table(struct mthca_dev *dev);
+int mthca_init_srq_table(struct mthca_dev *dev);
+int mthca_init_qp_table(struct mthca_dev *dev);
+int mthca_init_av_table(struct mthca_dev *dev);
+int mthca_init_mcg_table(struct mthca_dev *dev);
+
+void mthca_cleanup_uar_table(struct mthca_dev *dev);
+void mthca_cleanup_pd_table(struct mthca_dev *dev);
+void mthca_cleanup_mr_table(struct mthca_dev *dev);
+void mthca_cleanup_eq_table(struct mthca_dev *dev);
+void mthca_cleanup_cq_table(struct mthca_dev *dev);
+void mthca_cleanup_srq_table(struct mthca_dev *dev);
+void mthca_cleanup_qp_table(struct mthca_dev *dev);
+void mthca_cleanup_av_table(struct mthca_dev *dev);
+void mthca_cleanup_mcg_table(struct mthca_dev *dev);
+
+int mthca_register_device(struct mthca_dev *dev);
+void mthca_unregister_device(struct mthca_dev *dev);
+
+void mthca_start_catas_poll(struct mthca_dev *dev);
+void mthca_stop_catas_poll(struct mthca_dev *dev);
+int __mthca_restart_one(struct pci_dev *pdev);
+int mthca_catas_init(void);
+void mthca_catas_cleanup(void);
+
+int mthca_uar_alloc(struct mthca_dev *dev, struct mthca_uar *uar);
+void mthca_uar_free(struct mthca_dev *dev, struct mthca_uar *uar);
+
+int mthca_pd_alloc(struct mthca_dev *dev, int privileged, struct mthca_pd *pd);
+void mthca_pd_free(struct mthca_dev *dev, struct mthca_pd *pd);
+
+int mthca_write_mtt_size(struct mthca_dev *dev);
+
+struct mthca_mtt *mthca_alloc_mtt(struct mthca_dev *dev, int size);
+void mthca_free_mtt(struct mthca_dev *dev, struct mthca_mtt *mtt);
+int mthca_write_mtt(struct mthca_dev *dev, struct mthca_mtt *mtt,
+ int start_index, u64 *buffer_list, int list_len);
+int mthca_mr_alloc(struct mthca_dev *dev, u32 pd, int buffer_size_shift,
+ u64 iova, u64 total_size, u32 access, struct mthca_mr *mr);
+int mthca_mr_alloc_notrans(struct mthca_dev *dev, u32 pd,
+ u32 access, struct mthca_mr *mr);
+int mthca_mr_alloc_phys(struct mthca_dev *dev, u32 pd,
+ u64 *buffer_list, int buffer_size_shift,
+ int list_len, u64 iova, u64 total_size,
+ u32 access, struct mthca_mr *mr);
+void mthca_free_mr(struct mthca_dev *dev, struct mthca_mr *mr);
+
+int mthca_fmr_alloc(struct mthca_dev *dev, u32 pd,
+ u32 access, struct mthca_fmr *fmr);
+int mthca_tavor_map_phys_fmr(struct ib_fmr *ibfmr, u64 *page_list,
+ int list_len, u64 iova);
+void mthca_tavor_fmr_unmap(struct mthca_dev *dev, struct mthca_fmr *fmr);
+int mthca_arbel_map_phys_fmr(struct ib_fmr *ibfmr, u64 *page_list,
+ int list_len, u64 iova);
+void mthca_arbel_fmr_unmap(struct mthca_dev *dev, struct mthca_fmr *fmr);
+int mthca_free_fmr(struct mthca_dev *dev, struct mthca_fmr *fmr);
+
+int mthca_map_eq_icm(struct mthca_dev *dev, u64 icm_virt);
+void mthca_unmap_eq_icm(struct mthca_dev *dev);
+
+int mthca_poll_cq(struct ib_cq *ibcq, int num_entries,
+ struct ib_wc *entry);
+int mthca_tavor_arm_cq(struct ib_cq *cq, enum ib_cq_notify_flags flags);
+int mthca_arbel_arm_cq(struct ib_cq *cq, enum ib_cq_notify_flags flags);
+int mthca_init_cq(struct mthca_dev *dev, int nent,
+ struct mthca_ucontext *ctx, u32 pdn,
+ struct mthca_cq *cq);
+void mthca_free_cq(struct mthca_dev *dev,
+ struct mthca_cq *cq);
+void mthca_cq_completion(struct mthca_dev *dev, u32 cqn);
+void mthca_cq_event(struct mthca_dev *dev, u32 cqn,
+ enum ib_event_type event_type);
+void mthca_cq_clean(struct mthca_dev *dev, struct mthca_cq *cq, u32 qpn,
+ struct mthca_srq *srq);
+void mthca_cq_resize_copy_cqes(struct mthca_cq *cq);
+int mthca_alloc_cq_buf(struct mthca_dev *dev, struct mthca_cq_buf *buf, int nent);
+void mthca_free_cq_buf(struct mthca_dev *dev, struct mthca_cq_buf *buf, int cqe);
+
+int mthca_alloc_srq(struct mthca_dev *dev, struct mthca_pd *pd,
+ struct ib_srq_attr *attr, struct mthca_srq *srq);
+void mthca_free_srq(struct mthca_dev *dev, struct mthca_srq *srq);
+int mthca_modify_srq(struct ib_srq *ibsrq, struct ib_srq_attr *attr,
+ enum ib_srq_attr_mask attr_mask, struct ib_udata *udata);
+int mthca_query_srq(struct ib_srq *srq, struct ib_srq_attr *srq_attr);
+int mthca_max_srq_sge(struct mthca_dev *dev);
+void mthca_srq_event(struct mthca_dev *dev, u32 srqn,
+ enum ib_event_type event_type);
+void mthca_free_srq_wqe(struct mthca_srq *srq, u32 wqe_addr);
+int mthca_tavor_post_srq_recv(struct ib_srq *srq, struct ib_recv_wr *wr,
+ struct ib_recv_wr **bad_wr);
+int mthca_arbel_post_srq_recv(struct ib_srq *srq, struct ib_recv_wr *wr,
+ struct ib_recv_wr **bad_wr);
+
+void mthca_qp_event(struct mthca_dev *dev, u32 qpn,
+ enum ib_event_type event_type);
+int mthca_query_qp(struct ib_qp *ibqp, struct ib_qp_attr *qp_attr, int qp_attr_mask,
+ struct ib_qp_init_attr *qp_init_attr);
+int mthca_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr, int attr_mask,
+ struct ib_udata *udata);
+int mthca_tavor_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr,
+ struct ib_send_wr **bad_wr);
+int mthca_tavor_post_receive(struct ib_qp *ibqp, struct ib_recv_wr *wr,
+ struct ib_recv_wr **bad_wr);
+int mthca_arbel_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr,
+ struct ib_send_wr **bad_wr);
+int mthca_arbel_post_receive(struct ib_qp *ibqp, struct ib_recv_wr *wr,
+ struct ib_recv_wr **bad_wr);
+void mthca_free_err_wqe(struct mthca_dev *dev, struct mthca_qp *qp, int is_send,
+ int index, int *dbd, __be32 *new_wqe);
+int mthca_alloc_qp(struct mthca_dev *dev,
+ struct mthca_pd *pd,
+ struct mthca_cq *send_cq,
+ struct mthca_cq *recv_cq,
+ enum ib_qp_type type,
+ enum ib_sig_type send_policy,
+ struct ib_qp_cap *cap,
+ struct mthca_qp *qp);
+int mthca_alloc_sqp(struct mthca_dev *dev,
+ struct mthca_pd *pd,
+ struct mthca_cq *send_cq,
+ struct mthca_cq *recv_cq,
+ enum ib_sig_type send_policy,
+ struct ib_qp_cap *cap,
+ int qpn,
+ int port,
+ struct mthca_sqp *sqp);
+void mthca_free_qp(struct mthca_dev *dev, struct mthca_qp *qp);
+int mthca_create_ah(struct mthca_dev *dev,
+ struct mthca_pd *pd,
+ struct ib_ah_attr *ah_attr,
+ struct mthca_ah *ah);
+int mthca_destroy_ah(struct mthca_dev *dev, struct mthca_ah *ah);
+int mthca_read_ah(struct mthca_dev *dev, struct mthca_ah *ah,
+ struct ib_ud_header *header);
+int mthca_ah_query(struct ib_ah *ibah, struct ib_ah_attr *attr);
+int mthca_ah_grh_present(struct mthca_ah *ah);
+u8 mthca_get_rate(struct mthca_dev *dev, int static_rate, u8 port);
+enum ib_rate mthca_rate_to_ib(struct mthca_dev *dev, u8 mthca_rate, u8 port);
+
+int mthca_multicast_attach(struct ib_qp *ibqp, union ib_gid *gid, u16 lid);
+int mthca_multicast_detach(struct ib_qp *ibqp, union ib_gid *gid, u16 lid);
+
+int mthca_process_mad(struct ib_device *ibdev,
+ int mad_flags,
+ u8 port_num,
+ const struct ib_wc *in_wc,
+ const struct ib_grh *in_grh,
+ const struct ib_mad_hdr *in, size_t in_mad_size,
+ struct ib_mad_hdr *out, size_t *out_mad_size,
+ u16 *out_mad_pkey_index);
+int mthca_create_agents(struct mthca_dev *dev);
+void mthca_free_agents(struct mthca_dev *dev);
+
+static inline struct mthca_dev *to_mdev(struct ib_device *ibdev)
+{
+ return container_of(ibdev, struct mthca_dev, ib_dev);
+}
+
+static inline int mthca_is_memfree(struct mthca_dev *dev)
+{
+ return dev->mthca_flags & MTHCA_FLAG_MEMFREE;
+}
+
+#endif /* MTHCA_DEV_H */
diff --git a/sys/ofed/drivers/infiniband/hw/mthca/mthca_doorbell.h b/sys/dev/mthca/mthca_doorbell.h
index 14f51ef..14f51ef 100644
--- a/sys/ofed/drivers/infiniband/hw/mthca/mthca_doorbell.h
+++ b/sys/dev/mthca/mthca_doorbell.h
diff --git a/sys/dev/mthca/mthca_eq.c b/sys/dev/mthca/mthca_eq.c
new file mode 100644
index 0000000..6902017
--- /dev/null
+++ b/sys/dev/mthca/mthca_eq.c
@@ -0,0 +1,905 @@
+/*
+ * Copyright (c) 2004, 2005 Topspin Communications. All rights reserved.
+ * Copyright (c) 2005 Mellanox Technologies. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#include <linux/errno.h>
+#include <linux/interrupt.h>
+#include <linux/pci.h>
+#include <linux/slab.h>
+
+#include "mthca_dev.h"
+#include "mthca_cmd.h"
+#include "mthca_config_reg.h"
+
+enum {
+ MTHCA_NUM_ASYNC_EQE = 0x80,
+ MTHCA_NUM_CMD_EQE = 0x80,
+ MTHCA_NUM_SPARE_EQE = 0x80,
+ MTHCA_EQ_ENTRY_SIZE = 0x20
+};
+
+/*
+ * Must be packed because start is 64 bits but only aligned to 32 bits.
+ */
+struct mthca_eq_context {
+ __be32 flags;
+ __be64 start;
+ __be32 logsize_usrpage;
+ __be32 tavor_pd; /* reserved for Arbel */
+ u8 reserved1[3];
+ u8 intr;
+ __be32 arbel_pd; /* lost_count for Tavor */
+ __be32 lkey;
+ u32 reserved2[2];
+ __be32 consumer_index;
+ __be32 producer_index;
+ u32 reserved3[4];
+} __attribute__((packed));
+
+#define MTHCA_EQ_STATUS_OK ( 0 << 28)
+#define MTHCA_EQ_STATUS_OVERFLOW ( 9 << 28)
+#define MTHCA_EQ_STATUS_WRITE_FAIL (10 << 28)
+#define MTHCA_EQ_OWNER_SW ( 0 << 24)
+#define MTHCA_EQ_OWNER_HW ( 1 << 24)
+#define MTHCA_EQ_FLAG_TR ( 1 << 18)
+#define MTHCA_EQ_FLAG_OI ( 1 << 17)
+#define MTHCA_EQ_STATE_ARMED ( 1 << 8)
+#define MTHCA_EQ_STATE_FIRED ( 2 << 8)
+#define MTHCA_EQ_STATE_ALWAYS_ARMED ( 3 << 8)
+#define MTHCA_EQ_STATE_ARBEL ( 8 << 8)
+
+enum {
+ MTHCA_EVENT_TYPE_COMP = 0x00,
+ MTHCA_EVENT_TYPE_PATH_MIG = 0x01,
+ MTHCA_EVENT_TYPE_COMM_EST = 0x02,
+ MTHCA_EVENT_TYPE_SQ_DRAINED = 0x03,
+ MTHCA_EVENT_TYPE_SRQ_QP_LAST_WQE = 0x13,
+ MTHCA_EVENT_TYPE_SRQ_LIMIT = 0x14,
+ MTHCA_EVENT_TYPE_CQ_ERROR = 0x04,
+ MTHCA_EVENT_TYPE_WQ_CATAS_ERROR = 0x05,
+ MTHCA_EVENT_TYPE_EEC_CATAS_ERROR = 0x06,
+ MTHCA_EVENT_TYPE_PATH_MIG_FAILED = 0x07,
+ MTHCA_EVENT_TYPE_WQ_INVAL_REQ_ERROR = 0x10,
+ MTHCA_EVENT_TYPE_WQ_ACCESS_ERROR = 0x11,
+ MTHCA_EVENT_TYPE_SRQ_CATAS_ERROR = 0x12,
+ MTHCA_EVENT_TYPE_LOCAL_CATAS_ERROR = 0x08,
+ MTHCA_EVENT_TYPE_PORT_CHANGE = 0x09,
+ MTHCA_EVENT_TYPE_EQ_OVERFLOW = 0x0f,
+ MTHCA_EVENT_TYPE_ECC_DETECT = 0x0e,
+ MTHCA_EVENT_TYPE_CMD = 0x0a
+};
+
+#define MTHCA_ASYNC_EVENT_MASK ((1ULL << MTHCA_EVENT_TYPE_PATH_MIG) | \
+ (1ULL << MTHCA_EVENT_TYPE_COMM_EST) | \
+ (1ULL << MTHCA_EVENT_TYPE_SQ_DRAINED) | \
+ (1ULL << MTHCA_EVENT_TYPE_CQ_ERROR) | \
+ (1ULL << MTHCA_EVENT_TYPE_WQ_CATAS_ERROR) | \
+ (1ULL << MTHCA_EVENT_TYPE_EEC_CATAS_ERROR) | \
+ (1ULL << MTHCA_EVENT_TYPE_PATH_MIG_FAILED) | \
+ (1ULL << MTHCA_EVENT_TYPE_WQ_INVAL_REQ_ERROR) | \
+ (1ULL << MTHCA_EVENT_TYPE_WQ_ACCESS_ERROR) | \
+ (1ULL << MTHCA_EVENT_TYPE_LOCAL_CATAS_ERROR) | \
+ (1ULL << MTHCA_EVENT_TYPE_PORT_CHANGE) | \
+ (1ULL << MTHCA_EVENT_TYPE_ECC_DETECT))
+#define MTHCA_SRQ_EVENT_MASK ((1ULL << MTHCA_EVENT_TYPE_SRQ_CATAS_ERROR) | \
+ (1ULL << MTHCA_EVENT_TYPE_SRQ_QP_LAST_WQE) | \
+ (1ULL << MTHCA_EVENT_TYPE_SRQ_LIMIT))
+#define MTHCA_CMD_EVENT_MASK (1ULL << MTHCA_EVENT_TYPE_CMD)
+
+#define MTHCA_EQ_DB_INC_CI (1 << 24)
+#define MTHCA_EQ_DB_REQ_NOT (2 << 24)
+#define MTHCA_EQ_DB_DISARM_CQ (3 << 24)
+#define MTHCA_EQ_DB_SET_CI (4 << 24)
+#define MTHCA_EQ_DB_ALWAYS_ARM (5 << 24)
+
+struct mthca_eqe {
+ u8 reserved1;
+ u8 type;
+ u8 reserved2;
+ u8 subtype;
+ union {
+ u32 raw[6];
+ struct {
+ __be32 cqn;
+ } __attribute__((packed)) comp;
+ struct {
+ u16 reserved1;
+ __be16 token;
+ u32 reserved2;
+ u8 reserved3[3];
+ u8 status;
+ __be64 out_param;
+ } __attribute__((packed)) cmd;
+ struct {
+ __be32 qpn;
+ } __attribute__((packed)) qp;
+ struct {
+ __be32 srqn;
+ } __attribute__((packed)) srq;
+ struct {
+ __be32 cqn;
+ u32 reserved1;
+ u8 reserved2[3];
+ u8 syndrome;
+ } __attribute__((packed)) cq_err;
+ struct {
+ u32 reserved1[2];
+ __be32 port;
+ } __attribute__((packed)) port_change;
+ } event;
+ u8 reserved3[3];
+ u8 owner;
+} __attribute__((packed));
+
+#define MTHCA_EQ_ENTRY_OWNER_SW (0 << 7)
+#define MTHCA_EQ_ENTRY_OWNER_HW (1 << 7)
+
+static inline u64 async_mask(struct mthca_dev *dev)
+{
+ return dev->mthca_flags & MTHCA_FLAG_SRQ ?
+ MTHCA_ASYNC_EVENT_MASK | MTHCA_SRQ_EVENT_MASK :
+ MTHCA_ASYNC_EVENT_MASK;
+}
+
+static inline void tavor_set_eq_ci(struct mthca_dev *dev, struct mthca_eq *eq, u32 ci)
+{
+ /*
+ * This barrier makes sure that all updates to ownership bits
+ * done by set_eqe_hw() hit memory before the consumer index
+ * is updated. set_eq_ci() allows the HCA to possibly write
+ * more EQ entries, and we want to avoid the exceedingly
+ * unlikely possibility of the HCA writing an entry and then
+ * having set_eqe_hw() overwrite the owner field.
+ */
+ wmb();
+ mthca_write64(MTHCA_EQ_DB_SET_CI | eq->eqn, ci & (eq->nent - 1),
+ dev->kar + MTHCA_EQ_DOORBELL,
+ MTHCA_GET_DOORBELL_LOCK(&dev->doorbell_lock));
+}
+
+static inline void arbel_set_eq_ci(struct mthca_dev *dev, struct mthca_eq *eq, u32 ci)
+{
+ /* See comment in tavor_set_eq_ci() above. */
+ wmb();
+ __raw_writel((__force u32) cpu_to_be32(ci),
+ dev->eq_regs.arbel.eq_set_ci_base + eq->eqn * 8);
+ /* We still want ordering, just not swabbing, so add a barrier */
+ mb();
+}
+
+static inline void set_eq_ci(struct mthca_dev *dev, struct mthca_eq *eq, u32 ci)
+{
+ if (mthca_is_memfree(dev))
+ arbel_set_eq_ci(dev, eq, ci);
+ else
+ tavor_set_eq_ci(dev, eq, ci);
+}
+
+static inline void tavor_eq_req_not(struct mthca_dev *dev, int eqn)
+{
+ mthca_write64(MTHCA_EQ_DB_REQ_NOT | eqn, 0,
+ dev->kar + MTHCA_EQ_DOORBELL,
+ MTHCA_GET_DOORBELL_LOCK(&dev->doorbell_lock));
+}
+
+static inline void arbel_eq_req_not(struct mthca_dev *dev, u32 eqn_mask)
+{
+ writel(eqn_mask, dev->eq_regs.arbel.eq_arm);
+}
+
+static inline void disarm_cq(struct mthca_dev *dev, int eqn, int cqn)
+{
+ if (!mthca_is_memfree(dev)) {
+ mthca_write64(MTHCA_EQ_DB_DISARM_CQ | eqn, cqn,
+ dev->kar + MTHCA_EQ_DOORBELL,
+ MTHCA_GET_DOORBELL_LOCK(&dev->doorbell_lock));
+ }
+}
+
+static inline struct mthca_eqe *get_eqe(struct mthca_eq *eq, u32 entry)
+{
+ unsigned long off = (entry & (eq->nent - 1)) * MTHCA_EQ_ENTRY_SIZE;
+ return eq->page_list[off / PAGE_SIZE].buf + off % PAGE_SIZE;
+}
+
+static inline struct mthca_eqe *next_eqe_sw(struct mthca_eq *eq)
+{
+ struct mthca_eqe *eqe;
+ eqe = get_eqe(eq, eq->cons_index);
+ return (MTHCA_EQ_ENTRY_OWNER_HW & eqe->owner) ? NULL : eqe;
+}
+
+static inline void set_eqe_hw(struct mthca_eqe *eqe)
+{
+ eqe->owner = MTHCA_EQ_ENTRY_OWNER_HW;
+}
+
+static void port_change(struct mthca_dev *dev, int port, int active)
+{
+ struct ib_event record;
+
+ mthca_dbg(dev, "Port change to %s for port %d\n",
+ active ? "active" : "down", port);
+
+ record.device = &dev->ib_dev;
+ record.event = active ? IB_EVENT_PORT_ACTIVE : IB_EVENT_PORT_ERR;
+ record.element.port_num = port;
+
+ ib_dispatch_event(&record);
+}
+
+static int mthca_eq_int(struct mthca_dev *dev, struct mthca_eq *eq)
+{
+ struct mthca_eqe *eqe;
+ int disarm_cqn;
+ int eqes_found = 0;
+ int set_ci = 0;
+
+ while ((eqe = next_eqe_sw(eq))) {
+ /*
+ * Make sure we read EQ entry contents after we've
+ * checked the ownership bit.
+ */
+ rmb();
+
+ switch (eqe->type) {
+ case MTHCA_EVENT_TYPE_COMP:
+ disarm_cqn = be32_to_cpu(eqe->event.comp.cqn) & 0xffffff;
+ disarm_cq(dev, eq->eqn, disarm_cqn);
+ mthca_cq_completion(dev, disarm_cqn);
+ break;
+
+ case MTHCA_EVENT_TYPE_PATH_MIG:
+ mthca_qp_event(dev, be32_to_cpu(eqe->event.qp.qpn) & 0xffffff,
+ IB_EVENT_PATH_MIG);
+ break;
+
+ case MTHCA_EVENT_TYPE_COMM_EST:
+ mthca_qp_event(dev, be32_to_cpu(eqe->event.qp.qpn) & 0xffffff,
+ IB_EVENT_COMM_EST);
+ break;
+
+ case MTHCA_EVENT_TYPE_SQ_DRAINED:
+ mthca_qp_event(dev, be32_to_cpu(eqe->event.qp.qpn) & 0xffffff,
+ IB_EVENT_SQ_DRAINED);
+ break;
+
+ case MTHCA_EVENT_TYPE_SRQ_QP_LAST_WQE:
+ mthca_qp_event(dev, be32_to_cpu(eqe->event.qp.qpn) & 0xffffff,
+ IB_EVENT_QP_LAST_WQE_REACHED);
+ break;
+
+ case MTHCA_EVENT_TYPE_SRQ_LIMIT:
+ mthca_srq_event(dev, be32_to_cpu(eqe->event.srq.srqn) & 0xffffff,
+ IB_EVENT_SRQ_LIMIT_REACHED);
+ break;
+
+ case MTHCA_EVENT_TYPE_WQ_CATAS_ERROR:
+ mthca_qp_event(dev, be32_to_cpu(eqe->event.qp.qpn) & 0xffffff,
+ IB_EVENT_QP_FATAL);
+ break;
+
+ case MTHCA_EVENT_TYPE_PATH_MIG_FAILED:
+ mthca_qp_event(dev, be32_to_cpu(eqe->event.qp.qpn) & 0xffffff,
+ IB_EVENT_PATH_MIG_ERR);
+ break;
+
+ case MTHCA_EVENT_TYPE_WQ_INVAL_REQ_ERROR:
+ mthca_qp_event(dev, be32_to_cpu(eqe->event.qp.qpn) & 0xffffff,
+ IB_EVENT_QP_REQ_ERR);
+ break;
+
+ case MTHCA_EVENT_TYPE_WQ_ACCESS_ERROR:
+ mthca_qp_event(dev, be32_to_cpu(eqe->event.qp.qpn) & 0xffffff,
+ IB_EVENT_QP_ACCESS_ERR);
+ break;
+
+ case MTHCA_EVENT_TYPE_CMD:
+ mthca_cmd_event(dev,
+ be16_to_cpu(eqe->event.cmd.token),
+ eqe->event.cmd.status,
+ be64_to_cpu(eqe->event.cmd.out_param));
+ break;
+
+ case MTHCA_EVENT_TYPE_PORT_CHANGE:
+ port_change(dev,
+ (be32_to_cpu(eqe->event.port_change.port) >> 28) & 3,
+ eqe->subtype == 0x4);
+ break;
+
+ case MTHCA_EVENT_TYPE_CQ_ERROR:
+ mthca_warn(dev, "CQ %s on CQN %06x\n",
+ eqe->event.cq_err.syndrome == 1 ?
+ "overrun" : "access violation",
+ be32_to_cpu(eqe->event.cq_err.cqn) & 0xffffff);
+ mthca_cq_event(dev, be32_to_cpu(eqe->event.cq_err.cqn),
+ IB_EVENT_CQ_ERR);
+ break;
+
+ case MTHCA_EVENT_TYPE_EQ_OVERFLOW:
+ mthca_warn(dev, "EQ overrun on EQN %d\n", eq->eqn);
+ break;
+
+ case MTHCA_EVENT_TYPE_EEC_CATAS_ERROR:
+ case MTHCA_EVENT_TYPE_SRQ_CATAS_ERROR:
+ case MTHCA_EVENT_TYPE_LOCAL_CATAS_ERROR:
+ case MTHCA_EVENT_TYPE_ECC_DETECT:
+ default:
+ mthca_warn(dev, "Unhandled event %02x(%02x) on EQ %d\n",
+ eqe->type, eqe->subtype, eq->eqn);
+ break;
+ }
+
+ set_eqe_hw(eqe);
+ ++eq->cons_index;
+ eqes_found = 1;
+ ++set_ci;
+
+ /*
+ * The HCA will think the queue has overflowed if we
+ * don't tell it we've been processing events. We
+ * create our EQs with MTHCA_NUM_SPARE_EQE extra
+ * entries, so we must update our consumer index at
+ * least that often.
+ */
+ if (unlikely(set_ci >= MTHCA_NUM_SPARE_EQE)) {
+ /*
+ * Conditional on hca_type is OK here because
+ * this is a rare case, not the fast path.
+ */
+ set_eq_ci(dev, eq, eq->cons_index);
+ set_ci = 0;
+ }
+ }
+
+ /*
+ * Rely on caller to set consumer index so that we don't have
+ * to test hca_type in our interrupt handling fast path.
+ */
+ return eqes_found;
+}
+
+static irqreturn_t mthca_tavor_interrupt(int irq, void *dev_ptr)
+{
+ struct mthca_dev *dev = dev_ptr;
+ u32 ecr;
+ int i;
+
+ if (dev->eq_table.clr_mask)
+ writel(dev->eq_table.clr_mask, dev->eq_table.clr_int);
+
+ ecr = readl(dev->eq_regs.tavor.ecr_base + 4);
+ if (!ecr)
+ return IRQ_NONE;
+
+ writel(ecr, dev->eq_regs.tavor.ecr_base +
+ MTHCA_ECR_CLR_BASE - MTHCA_ECR_BASE + 4);
+
+ for (i = 0; i < MTHCA_NUM_EQ; ++i)
+ if (ecr & dev->eq_table.eq[i].eqn_mask) {
+ if (mthca_eq_int(dev, &dev->eq_table.eq[i]))
+ tavor_set_eq_ci(dev, &dev->eq_table.eq[i],
+ dev->eq_table.eq[i].cons_index);
+ tavor_eq_req_not(dev, dev->eq_table.eq[i].eqn);
+ }
+
+ return IRQ_HANDLED;
+}
+
+static irqreturn_t mthca_tavor_msi_x_interrupt(int irq, void *eq_ptr)
+{
+ struct mthca_eq *eq = eq_ptr;
+ struct mthca_dev *dev = eq->dev;
+
+ mthca_eq_int(dev, eq);
+ tavor_set_eq_ci(dev, eq, eq->cons_index);
+ tavor_eq_req_not(dev, eq->eqn);
+
+ /* MSI-X vectors always belong to us */
+ return IRQ_HANDLED;
+}
+
+static irqreturn_t mthca_arbel_interrupt(int irq, void *dev_ptr)
+{
+ struct mthca_dev *dev = dev_ptr;
+ int work = 0;
+ int i;
+
+ if (dev->eq_table.clr_mask)
+ writel(dev->eq_table.clr_mask, dev->eq_table.clr_int);
+
+ for (i = 0; i < MTHCA_NUM_EQ; ++i)
+ if (mthca_eq_int(dev, &dev->eq_table.eq[i])) {
+ work = 1;
+ arbel_set_eq_ci(dev, &dev->eq_table.eq[i],
+ dev->eq_table.eq[i].cons_index);
+ }
+
+ arbel_eq_req_not(dev, dev->eq_table.arm_mask);
+
+ return IRQ_RETVAL(work);
+}
+
+static irqreturn_t mthca_arbel_msi_x_interrupt(int irq, void *eq_ptr)
+{
+ struct mthca_eq *eq = eq_ptr;
+ struct mthca_dev *dev = eq->dev;
+
+ mthca_eq_int(dev, eq);
+ arbel_set_eq_ci(dev, eq, eq->cons_index);
+ arbel_eq_req_not(dev, eq->eqn_mask);
+
+ /* MSI-X vectors always belong to us */
+ return IRQ_HANDLED;
+}
+
+static int mthca_create_eq(struct mthca_dev *dev,
+ int nent,
+ u8 intr,
+ struct mthca_eq *eq)
+{
+ int npages;
+ u64 *dma_list = NULL;
+ dma_addr_t t;
+ struct mthca_mailbox *mailbox;
+ struct mthca_eq_context *eq_context;
+ int err = -ENOMEM;
+ int i;
+
+ eq->dev = dev;
+ eq->nent = roundup_pow_of_two(max(nent, 2));
+ npages = ALIGN(eq->nent * MTHCA_EQ_ENTRY_SIZE, PAGE_SIZE) / PAGE_SIZE;
+
+ eq->page_list = kmalloc(npages * sizeof *eq->page_list,
+ GFP_KERNEL);
+ if (!eq->page_list)
+ goto err_out;
+
+ for (i = 0; i < npages; ++i)
+ eq->page_list[i].buf = NULL;
+
+ dma_list = kmalloc(npages * sizeof *dma_list, GFP_KERNEL);
+ if (!dma_list)
+ goto err_out_free;
+
+ mailbox = mthca_alloc_mailbox(dev, GFP_KERNEL);
+ if (IS_ERR(mailbox))
+ goto err_out_free;
+ eq_context = mailbox->buf;
+
+ for (i = 0; i < npages; ++i) {
+ eq->page_list[i].buf = dma_alloc_coherent(&dev->pdev->dev,
+ PAGE_SIZE, &t, GFP_KERNEL);
+ if (!eq->page_list[i].buf)
+ goto err_out_free_pages;
+
+ dma_list[i] = t;
+ dma_unmap_addr_set(&eq->page_list[i], mapping, t);
+
+ clear_page(eq->page_list[i].buf);
+ }
+
+ for (i = 0; i < eq->nent; ++i)
+ set_eqe_hw(get_eqe(eq, i));
+
+ eq->eqn = mthca_alloc(&dev->eq_table.alloc);
+ if (eq->eqn == -1)
+ goto err_out_free_pages;
+
+ err = mthca_mr_alloc_phys(dev, dev->driver_pd.pd_num,
+ dma_list, PAGE_SHIFT, npages,
+ 0, npages * PAGE_SIZE,
+ MTHCA_MPT_FLAG_LOCAL_WRITE |
+ MTHCA_MPT_FLAG_LOCAL_READ,
+ &eq->mr);
+ if (err)
+ goto err_out_free_eq;
+
+ memset(eq_context, 0, sizeof *eq_context);
+ eq_context->flags = cpu_to_be32(MTHCA_EQ_STATUS_OK |
+ MTHCA_EQ_OWNER_HW |
+ MTHCA_EQ_STATE_ARMED |
+ MTHCA_EQ_FLAG_TR);
+ if (mthca_is_memfree(dev))
+ eq_context->flags |= cpu_to_be32(MTHCA_EQ_STATE_ARBEL);
+
+ eq_context->logsize_usrpage = cpu_to_be32((ffs(eq->nent) - 1) << 24);
+ if (mthca_is_memfree(dev)) {
+ eq_context->arbel_pd = cpu_to_be32(dev->driver_pd.pd_num);
+ } else {
+ eq_context->logsize_usrpage |= cpu_to_be32(dev->driver_uar.index);
+ eq_context->tavor_pd = cpu_to_be32(dev->driver_pd.pd_num);
+ }
+ eq_context->intr = intr;
+ eq_context->lkey = cpu_to_be32(eq->mr.ibmr.lkey);
+
+ err = mthca_SW2HW_EQ(dev, mailbox, eq->eqn);
+ if (err) {
+ mthca_warn(dev, "SW2HW_EQ returned %d\n", err);
+ goto err_out_free_mr;
+ }
+
+ kfree(dma_list);
+ mthca_free_mailbox(dev, mailbox);
+
+ eq->eqn_mask = swab32(1 << eq->eqn);
+ eq->cons_index = 0;
+
+ dev->eq_table.arm_mask |= eq->eqn_mask;
+
+ mthca_dbg(dev, "Allocated EQ %d with %d entries\n",
+ eq->eqn, eq->nent);
+
+ return err;
+
+ err_out_free_mr:
+ mthca_free_mr(dev, &eq->mr);
+
+ err_out_free_eq:
+ mthca_free(&dev->eq_table.alloc, eq->eqn);
+
+ err_out_free_pages:
+ for (i = 0; i < npages; ++i)
+ if (eq->page_list[i].buf)
+ dma_free_coherent(&dev->pdev->dev, PAGE_SIZE,
+ eq->page_list[i].buf,
+ dma_unmap_addr(&eq->page_list[i],
+ mapping));
+
+ mthca_free_mailbox(dev, mailbox);
+
+ err_out_free:
+ kfree(eq->page_list);
+ kfree(dma_list);
+
+ err_out:
+ return err;
+}
+
+static void mthca_free_eq(struct mthca_dev *dev,
+ struct mthca_eq *eq)
+{
+ struct mthca_mailbox *mailbox;
+ int err;
+ int npages = (eq->nent * MTHCA_EQ_ENTRY_SIZE + PAGE_SIZE - 1) /
+ PAGE_SIZE;
+ int i;
+
+ mailbox = mthca_alloc_mailbox(dev, GFP_KERNEL);
+ if (IS_ERR(mailbox))
+ return;
+
+ err = mthca_HW2SW_EQ(dev, mailbox, eq->eqn);
+ if (err)
+ mthca_warn(dev, "HW2SW_EQ returned %d\n", err);
+
+ dev->eq_table.arm_mask &= ~eq->eqn_mask;
+
+ if (0) {
+ mthca_dbg(dev, "Dumping EQ context %02x:\n", eq->eqn);
+ for (i = 0; i < sizeof (struct mthca_eq_context) / 4; ++i) {
+ if (i % 4 == 0)
+ printk("[%02x] ", i * 4);
+ printk(" %08x", be32_to_cpup(mailbox->buf + i * 4));
+ if ((i + 1) % 4 == 0)
+ printk("\n");
+ }
+ }
+
+ mthca_free_mr(dev, &eq->mr);
+ for (i = 0; i < npages; ++i)
+ pci_free_consistent(dev->pdev, PAGE_SIZE,
+ eq->page_list[i].buf,
+ dma_unmap_addr(&eq->page_list[i], mapping));
+
+ kfree(eq->page_list);
+ mthca_free_mailbox(dev, mailbox);
+}
+
+static void mthca_free_irqs(struct mthca_dev *dev)
+{
+ int i;
+
+ if (dev->eq_table.have_irq)
+ free_irq(dev->pdev->irq, dev);
+ for (i = 0; i < MTHCA_NUM_EQ; ++i)
+ if (dev->eq_table.eq[i].have_irq) {
+ free_irq(dev->eq_table.eq[i].msi_x_vector,
+ dev->eq_table.eq + i);
+ dev->eq_table.eq[i].have_irq = 0;
+ }
+}
+
+static int mthca_map_reg(struct mthca_dev *dev,
+ unsigned long offset, unsigned long size,
+ void __iomem **map)
+{
+ phys_addr_t base = pci_resource_start(dev->pdev, 0);
+
+ *map = ioremap(base + offset, size);
+ if (!*map)
+ return -ENOMEM;
+
+ return 0;
+}
+
+static int mthca_map_eq_regs(struct mthca_dev *dev)
+{
+ if (mthca_is_memfree(dev)) {
+ /*
+ * We assume that the EQ arm and EQ set CI registers
+ * fall within the first BAR. We can't trust the
+ * values firmware gives us, since those addresses are
+ * valid on the HCA's side of the PCI bus but not
+ * necessarily the host side.
+ */
+ if (mthca_map_reg(dev, (pci_resource_len(dev->pdev, 0) - 1) &
+ dev->fw.arbel.clr_int_base, MTHCA_CLR_INT_SIZE,
+ &dev->clr_base)) {
+ mthca_err(dev, "Couldn't map interrupt clear register, "
+ "aborting.\n");
+ return -ENOMEM;
+ }
+
+ /*
+ * Add 4 because we limit ourselves to EQs 0 ... 31,
+ * so we only need the low word of the register.
+ */
+ if (mthca_map_reg(dev, ((pci_resource_len(dev->pdev, 0) - 1) &
+ dev->fw.arbel.eq_arm_base) + 4, 4,
+ &dev->eq_regs.arbel.eq_arm)) {
+ mthca_err(dev, "Couldn't map EQ arm register, aborting.\n");
+ iounmap(dev->clr_base);
+ return -ENOMEM;
+ }
+
+ if (mthca_map_reg(dev, (pci_resource_len(dev->pdev, 0) - 1) &
+ dev->fw.arbel.eq_set_ci_base,
+ MTHCA_EQ_SET_CI_SIZE,
+ &dev->eq_regs.arbel.eq_set_ci_base)) {
+ mthca_err(dev, "Couldn't map EQ CI register, aborting.\n");
+ iounmap(dev->eq_regs.arbel.eq_arm);
+ iounmap(dev->clr_base);
+ return -ENOMEM;
+ }
+ } else {
+ if (mthca_map_reg(dev, MTHCA_CLR_INT_BASE, MTHCA_CLR_INT_SIZE,
+ &dev->clr_base)) {
+ mthca_err(dev, "Couldn't map interrupt clear register, "
+ "aborting.\n");
+ return -ENOMEM;
+ }
+
+ if (mthca_map_reg(dev, MTHCA_ECR_BASE,
+ MTHCA_ECR_SIZE + MTHCA_ECR_CLR_SIZE,
+ &dev->eq_regs.tavor.ecr_base)) {
+ mthca_err(dev, "Couldn't map ecr register, "
+ "aborting.\n");
+ iounmap(dev->clr_base);
+ return -ENOMEM;
+ }
+ }
+
+ return 0;
+
+}
+
+static void mthca_unmap_eq_regs(struct mthca_dev *dev)
+{
+ if (mthca_is_memfree(dev)) {
+ iounmap(dev->eq_regs.arbel.eq_set_ci_base);
+ iounmap(dev->eq_regs.arbel.eq_arm);
+ iounmap(dev->clr_base);
+ } else {
+ iounmap(dev->eq_regs.tavor.ecr_base);
+ iounmap(dev->clr_base);
+ }
+}
+
+int mthca_map_eq_icm(struct mthca_dev *dev, u64 icm_virt)
+{
+ int ret;
+
+ /*
+ * We assume that mapping one page is enough for the whole EQ
+ * context table. This is fine with all current HCAs, because
+ * we only use 32 EQs and each EQ uses 32 bytes of context
+ * memory, or 1 KB total.
+ */
+ dev->eq_table.icm_virt = icm_virt;
+ dev->eq_table.icm_page = alloc_page(GFP_HIGHUSER);
+ if (!dev->eq_table.icm_page)
+ return -ENOMEM;
+ dev->eq_table.icm_dma = pci_map_page(dev->pdev, dev->eq_table.icm_page, 0,
+ PAGE_SIZE, PCI_DMA_BIDIRECTIONAL);
+ if (pci_dma_mapping_error(dev->pdev, dev->eq_table.icm_dma)) {
+ __free_page(dev->eq_table.icm_page);
+ return -ENOMEM;
+ }
+
+ ret = mthca_MAP_ICM_page(dev, dev->eq_table.icm_dma, icm_virt);
+ if (ret) {
+ pci_unmap_page(dev->pdev, dev->eq_table.icm_dma, PAGE_SIZE,
+ PCI_DMA_BIDIRECTIONAL);
+ __free_page(dev->eq_table.icm_page);
+ }
+
+ return ret;
+}
+
+void mthca_unmap_eq_icm(struct mthca_dev *dev)
+{
+ mthca_UNMAP_ICM(dev, dev->eq_table.icm_virt, 1);
+ pci_unmap_page(dev->pdev, dev->eq_table.icm_dma, PAGE_SIZE,
+ PCI_DMA_BIDIRECTIONAL);
+ __free_page(dev->eq_table.icm_page);
+}
+
+int mthca_init_eq_table(struct mthca_dev *dev)
+{
+ int err;
+ u8 intr;
+ int i;
+
+ err = mthca_alloc_init(&dev->eq_table.alloc,
+ dev->limits.num_eqs,
+ dev->limits.num_eqs - 1,
+ dev->limits.reserved_eqs);
+ if (err)
+ return err;
+
+ err = mthca_map_eq_regs(dev);
+ if (err)
+ goto err_out_free;
+
+ if (dev->mthca_flags & MTHCA_FLAG_MSI_X) {
+ dev->eq_table.clr_mask = 0;
+ } else {
+ dev->eq_table.clr_mask =
+ swab32(1 << (dev->eq_table.inta_pin & 31));
+ dev->eq_table.clr_int = dev->clr_base +
+ (dev->eq_table.inta_pin < 32 ? 4 : 0);
+ }
+
+ dev->eq_table.arm_mask = 0;
+
+ intr = dev->eq_table.inta_pin;
+
+ err = mthca_create_eq(dev, dev->limits.num_cqs + MTHCA_NUM_SPARE_EQE,
+ (dev->mthca_flags & MTHCA_FLAG_MSI_X) ? 128 : intr,
+ &dev->eq_table.eq[MTHCA_EQ_COMP]);
+ if (err)
+ goto err_out_unmap;
+
+ err = mthca_create_eq(dev, MTHCA_NUM_ASYNC_EQE + MTHCA_NUM_SPARE_EQE,
+ (dev->mthca_flags & MTHCA_FLAG_MSI_X) ? 129 : intr,
+ &dev->eq_table.eq[MTHCA_EQ_ASYNC]);
+ if (err)
+ goto err_out_comp;
+
+ err = mthca_create_eq(dev, MTHCA_NUM_CMD_EQE + MTHCA_NUM_SPARE_EQE,
+ (dev->mthca_flags & MTHCA_FLAG_MSI_X) ? 130 : intr,
+ &dev->eq_table.eq[MTHCA_EQ_CMD]);
+ if (err)
+ goto err_out_async;
+
+ if (dev->mthca_flags & MTHCA_FLAG_MSI_X) {
+ static const char *eq_name[] = {
+ [MTHCA_EQ_COMP] = DRV_NAME "-comp",
+ [MTHCA_EQ_ASYNC] = DRV_NAME "-async",
+ [MTHCA_EQ_CMD] = DRV_NAME "-cmd"
+ };
+
+ for (i = 0; i < MTHCA_NUM_EQ; ++i) {
+ snprintf(dev->eq_table.eq[i].irq_name,
+ IB_DEVICE_NAME_MAX,
+ "%s@pci:%s", eq_name[i],
+ pci_name(dev->pdev));
+ err = request_irq(dev->eq_table.eq[i].msi_x_vector,
+ mthca_is_memfree(dev) ?
+ mthca_arbel_msi_x_interrupt :
+ mthca_tavor_msi_x_interrupt,
+ 0, dev->eq_table.eq[i].irq_name,
+ dev->eq_table.eq + i);
+ if (err)
+ goto err_out_cmd;
+ dev->eq_table.eq[i].have_irq = 1;
+ }
+ } else {
+ snprintf(dev->eq_table.eq[0].irq_name, IB_DEVICE_NAME_MAX,
+ DRV_NAME "@pci:%s", pci_name(dev->pdev));
+ err = request_irq(dev->pdev->irq,
+ mthca_is_memfree(dev) ?
+ mthca_arbel_interrupt :
+ mthca_tavor_interrupt,
+ IRQF_SHARED, dev->eq_table.eq[0].irq_name, dev);
+ if (err)
+ goto err_out_cmd;
+ dev->eq_table.have_irq = 1;
+ }
+
+ err = mthca_MAP_EQ(dev, async_mask(dev),
+ 0, dev->eq_table.eq[MTHCA_EQ_ASYNC].eqn);
+ if (err)
+ mthca_warn(dev, "MAP_EQ for async EQ %d failed (%d)\n",
+ dev->eq_table.eq[MTHCA_EQ_ASYNC].eqn, err);
+
+ err = mthca_MAP_EQ(dev, MTHCA_CMD_EVENT_MASK,
+ 0, dev->eq_table.eq[MTHCA_EQ_CMD].eqn);
+ if (err)
+ mthca_warn(dev, "MAP_EQ for cmd EQ %d failed (%d)\n",
+ dev->eq_table.eq[MTHCA_EQ_CMD].eqn, err);
+
+ for (i = 0; i < MTHCA_NUM_EQ; ++i)
+ if (mthca_is_memfree(dev))
+ arbel_eq_req_not(dev, dev->eq_table.eq[i].eqn_mask);
+ else
+ tavor_eq_req_not(dev, dev->eq_table.eq[i].eqn);
+
+ return 0;
+
+err_out_cmd:
+ mthca_free_irqs(dev);
+ mthca_free_eq(dev, &dev->eq_table.eq[MTHCA_EQ_CMD]);
+
+err_out_async:
+ mthca_free_eq(dev, &dev->eq_table.eq[MTHCA_EQ_ASYNC]);
+
+err_out_comp:
+ mthca_free_eq(dev, &dev->eq_table.eq[MTHCA_EQ_COMP]);
+
+err_out_unmap:
+ mthca_unmap_eq_regs(dev);
+
+err_out_free:
+ mthca_alloc_cleanup(&dev->eq_table.alloc);
+ return err;
+}
+
+void mthca_cleanup_eq_table(struct mthca_dev *dev)
+{
+ int i;
+
+ mthca_free_irqs(dev);
+
+ mthca_MAP_EQ(dev, async_mask(dev),
+ 1, dev->eq_table.eq[MTHCA_EQ_ASYNC].eqn);
+ mthca_MAP_EQ(dev, MTHCA_CMD_EVENT_MASK,
+ 1, dev->eq_table.eq[MTHCA_EQ_CMD].eqn);
+
+ for (i = 0; i < MTHCA_NUM_EQ; ++i)
+ mthca_free_eq(dev, &dev->eq_table.eq[i]);
+
+ mthca_unmap_eq_regs(dev);
+
+ mthca_alloc_cleanup(&dev->eq_table.alloc);
+}
diff --git a/sys/dev/mthca/mthca_mad.c b/sys/dev/mthca/mthca_mad.c
new file mode 100644
index 0000000..9139405
--- /dev/null
+++ b/sys/dev/mthca/mthca_mad.c
@@ -0,0 +1,350 @@
+/*
+ * Copyright (c) 2004 Topspin Communications. All rights reserved.
+ * Copyright (c) 2005 Mellanox Technologies. All rights reserved.
+ * Copyright (c) 2004 Voltaire, Inc. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#include <linux/string.h>
+#include <linux/slab.h>
+
+#include <rdma/ib_verbs.h>
+#include <rdma/ib_mad.h>
+#include <rdma/ib_smi.h>
+
+#include "mthca_dev.h"
+#include "mthca_cmd.h"
+
+enum {
+ MTHCA_VENDOR_CLASS1 = 0x9,
+ MTHCA_VENDOR_CLASS2 = 0xa
+};
+
+static int mthca_update_rate(struct mthca_dev *dev, u8 port_num)
+{
+ struct ib_port_attr *tprops = NULL;
+ int ret;
+
+ tprops = kmalloc(sizeof *tprops, GFP_KERNEL);
+ if (!tprops)
+ return -ENOMEM;
+
+ ret = ib_query_port(&dev->ib_dev, port_num, tprops);
+ if (ret) {
+ printk(KERN_WARNING "ib_query_port failed (%d) for %s port %d\n",
+ ret, dev->ib_dev.name, port_num);
+ goto out;
+ }
+
+ dev->rate[port_num - 1] = tprops->active_speed *
+ ib_width_enum_to_int(tprops->active_width);
+
+out:
+ kfree(tprops);
+ return ret;
+}
+
+static void update_sm_ah(struct mthca_dev *dev,
+ u8 port_num, u16 lid, u8 sl)
+{
+ struct ib_ah *new_ah;
+ struct ib_ah_attr ah_attr;
+ unsigned long flags;
+
+ if (!dev->send_agent[port_num - 1][0])
+ return;
+
+ memset(&ah_attr, 0, sizeof ah_attr);
+ ah_attr.dlid = lid;
+ ah_attr.sl = sl;
+ ah_attr.port_num = port_num;
+
+ new_ah = ib_create_ah(dev->send_agent[port_num - 1][0]->qp->pd,
+ &ah_attr);
+ if (IS_ERR(new_ah))
+ return;
+
+ spin_lock_irqsave(&dev->sm_lock, flags);
+ if (dev->sm_ah[port_num - 1])
+ ib_destroy_ah(dev->sm_ah[port_num - 1]);
+ dev->sm_ah[port_num - 1] = new_ah;
+ spin_unlock_irqrestore(&dev->sm_lock, flags);
+}
+
+/*
+ * Snoop SM MADs for port info and P_Key table sets, so we can
+ * synthesize LID change and P_Key change events.
+ */
+static void smp_snoop(struct ib_device *ibdev,
+ u8 port_num,
+ const struct ib_mad *mad,
+ u16 prev_lid)
+{
+ struct ib_event event;
+
+ if ((mad->mad_hdr.mgmt_class == IB_MGMT_CLASS_SUBN_LID_ROUTED ||
+ mad->mad_hdr.mgmt_class == IB_MGMT_CLASS_SUBN_DIRECTED_ROUTE) &&
+ mad->mad_hdr.method == IB_MGMT_METHOD_SET) {
+ if (mad->mad_hdr.attr_id == IB_SMP_ATTR_PORT_INFO) {
+ struct ib_port_info *pinfo =
+ (struct ib_port_info *) ((struct ib_smp *) mad)->data;
+ u16 lid = be16_to_cpu(pinfo->lid);
+
+ mthca_update_rate(to_mdev(ibdev), port_num);
+ update_sm_ah(to_mdev(ibdev), port_num,
+ be16_to_cpu(pinfo->sm_lid),
+ pinfo->neighbormtu_mastersmsl & 0xf);
+
+ event.device = ibdev;
+ event.element.port_num = port_num;
+
+ if (pinfo->clientrereg_resv_subnetto & 0x80) {
+ event.event = IB_EVENT_CLIENT_REREGISTER;
+ ib_dispatch_event(&event);
+ }
+
+ if (prev_lid != lid) {
+ event.event = IB_EVENT_LID_CHANGE;
+ ib_dispatch_event(&event);
+ }
+ }
+
+ if (mad->mad_hdr.attr_id == IB_SMP_ATTR_PKEY_TABLE) {
+ event.device = ibdev;
+ event.event = IB_EVENT_PKEY_CHANGE;
+ event.element.port_num = port_num;
+ ib_dispatch_event(&event);
+ }
+ }
+}
+
+static void node_desc_override(struct ib_device *dev,
+ struct ib_mad *mad)
+{
+ if ((mad->mad_hdr.mgmt_class == IB_MGMT_CLASS_SUBN_LID_ROUTED ||
+ mad->mad_hdr.mgmt_class == IB_MGMT_CLASS_SUBN_DIRECTED_ROUTE) &&
+ mad->mad_hdr.method == IB_MGMT_METHOD_GET_RESP &&
+ mad->mad_hdr.attr_id == IB_SMP_ATTR_NODE_DESC) {
+ mutex_lock(&to_mdev(dev)->cap_mask_mutex);
+ memcpy(((struct ib_smp *) mad)->data, dev->node_desc,
+ IB_DEVICE_NODE_DESC_MAX);
+ mutex_unlock(&to_mdev(dev)->cap_mask_mutex);
+ }
+}
+
+static void forward_trap(struct mthca_dev *dev,
+ u8 port_num,
+ const struct ib_mad *mad)
+{
+ int qpn = mad->mad_hdr.mgmt_class != IB_MGMT_CLASS_SUBN_LID_ROUTED;
+ struct ib_mad_send_buf *send_buf;
+ struct ib_mad_agent *agent = dev->send_agent[port_num - 1][qpn];
+ int ret;
+ unsigned long flags;
+
+ if (agent) {
+ send_buf = ib_create_send_mad(agent, qpn, 0, 0, IB_MGMT_MAD_HDR,
+ IB_MGMT_MAD_DATA, GFP_ATOMIC,
+ IB_MGMT_BASE_VERSION);
+ if (IS_ERR(send_buf))
+ return;
+ /*
+ * We rely here on the fact that MLX QPs don't use the
+ * address handle after the send is posted (this is
+ * wrong following the IB spec strictly, but we know
+ * it's OK for our devices).
+ */
+ spin_lock_irqsave(&dev->sm_lock, flags);
+ memcpy(send_buf->mad, mad, sizeof *mad);
+ if ((send_buf->ah = dev->sm_ah[port_num - 1]))
+ ret = ib_post_send_mad(send_buf, NULL);
+ else
+ ret = -EINVAL;
+ spin_unlock_irqrestore(&dev->sm_lock, flags);
+
+ if (ret)
+ ib_free_send_mad(send_buf);
+ }
+}
+
+int mthca_process_mad(struct ib_device *ibdev,
+ int mad_flags,
+ u8 port_num,
+ const struct ib_wc *in_wc,
+ const struct ib_grh *in_grh,
+ const struct ib_mad_hdr *in, size_t in_mad_size,
+ struct ib_mad_hdr *out, size_t *out_mad_size,
+ u16 *out_mad_pkey_index)
+{
+ int err;
+ u16 slid = in_wc ? in_wc->slid : be16_to_cpu(IB_LID_PERMISSIVE);
+ u16 prev_lid = 0;
+ struct ib_port_attr pattr;
+ const struct ib_mad *in_mad = (const struct ib_mad *)in;
+ struct ib_mad *out_mad = (struct ib_mad *)out;
+
+ if (WARN_ON_ONCE(in_mad_size != sizeof(*in_mad) ||
+ *out_mad_size != sizeof(*out_mad)))
+ return IB_MAD_RESULT_FAILURE;
+
+ /* Forward locally generated traps to the SM */
+ if (in_mad->mad_hdr.method == IB_MGMT_METHOD_TRAP &&
+ slid == 0) {
+ forward_trap(to_mdev(ibdev), port_num, in_mad);
+ return IB_MAD_RESULT_SUCCESS | IB_MAD_RESULT_CONSUMED;
+ }
+
+ /*
+ * Only handle SM gets, sets and trap represses for SM class
+ *
+ * Only handle PMA and Mellanox vendor-specific class gets and
+ * sets for other classes.
+ */
+ if (in_mad->mad_hdr.mgmt_class == IB_MGMT_CLASS_SUBN_LID_ROUTED ||
+ in_mad->mad_hdr.mgmt_class == IB_MGMT_CLASS_SUBN_DIRECTED_ROUTE) {
+ if (in_mad->mad_hdr.method != IB_MGMT_METHOD_GET &&
+ in_mad->mad_hdr.method != IB_MGMT_METHOD_SET &&
+ in_mad->mad_hdr.method != IB_MGMT_METHOD_TRAP_REPRESS)
+ return IB_MAD_RESULT_SUCCESS;
+
+ /*
+ * Don't process SMInfo queries or vendor-specific
+ * MADs -- the SMA can't handle them.
+ */
+ if (in_mad->mad_hdr.attr_id == IB_SMP_ATTR_SM_INFO ||
+ ((in_mad->mad_hdr.attr_id & IB_SMP_ATTR_VENDOR_MASK) ==
+ IB_SMP_ATTR_VENDOR_MASK))
+ return IB_MAD_RESULT_SUCCESS;
+ } else if (in_mad->mad_hdr.mgmt_class == IB_MGMT_CLASS_PERF_MGMT ||
+ in_mad->mad_hdr.mgmt_class == MTHCA_VENDOR_CLASS1 ||
+ in_mad->mad_hdr.mgmt_class == MTHCA_VENDOR_CLASS2) {
+ if (in_mad->mad_hdr.method != IB_MGMT_METHOD_GET &&
+ in_mad->mad_hdr.method != IB_MGMT_METHOD_SET)
+ return IB_MAD_RESULT_SUCCESS;
+ } else
+ return IB_MAD_RESULT_SUCCESS;
+ if ((in_mad->mad_hdr.mgmt_class == IB_MGMT_CLASS_SUBN_LID_ROUTED ||
+ in_mad->mad_hdr.mgmt_class == IB_MGMT_CLASS_SUBN_DIRECTED_ROUTE) &&
+ in_mad->mad_hdr.method == IB_MGMT_METHOD_SET &&
+ in_mad->mad_hdr.attr_id == IB_SMP_ATTR_PORT_INFO &&
+ !ib_query_port(ibdev, port_num, &pattr))
+ prev_lid = pattr.lid;
+
+ err = mthca_MAD_IFC(to_mdev(ibdev),
+ mad_flags & IB_MAD_IGNORE_MKEY,
+ mad_flags & IB_MAD_IGNORE_BKEY,
+ port_num, in_wc, in_grh, in_mad, out_mad);
+ if (err == -EBADMSG)
+ return IB_MAD_RESULT_SUCCESS;
+ else if (err) {
+ mthca_err(to_mdev(ibdev), "MAD_IFC returned %d\n", err);
+ return IB_MAD_RESULT_FAILURE;
+ }
+
+ if (!out_mad->mad_hdr.status) {
+ smp_snoop(ibdev, port_num, in_mad, prev_lid);
+ node_desc_override(ibdev, out_mad);
+ }
+
+ /* set return bit in status of directed route responses */
+ if (in_mad->mad_hdr.mgmt_class == IB_MGMT_CLASS_SUBN_DIRECTED_ROUTE)
+ out_mad->mad_hdr.status |= cpu_to_be16(1 << 15);
+
+ if (in_mad->mad_hdr.method == IB_MGMT_METHOD_TRAP_REPRESS)
+ /* no response for trap repress */
+ return IB_MAD_RESULT_SUCCESS | IB_MAD_RESULT_CONSUMED;
+
+ return IB_MAD_RESULT_SUCCESS | IB_MAD_RESULT_REPLY;
+}
+
+static void send_handler(struct ib_mad_agent *agent,
+ struct ib_mad_send_wc *mad_send_wc)
+{
+ ib_free_send_mad(mad_send_wc->send_buf);
+}
+
+int mthca_create_agents(struct mthca_dev *dev)
+{
+ struct ib_mad_agent *agent;
+ int p, q;
+ int ret;
+
+ spin_lock_init(&dev->sm_lock);
+
+ for (p = 0; p < dev->limits.num_ports; ++p)
+ for (q = 0; q <= 1; ++q) {
+ agent = ib_register_mad_agent(&dev->ib_dev, p + 1,
+ q ? IB_QPT_GSI : IB_QPT_SMI,
+ NULL, 0, send_handler,
+ NULL, NULL, 0);
+ if (IS_ERR(agent)) {
+ ret = PTR_ERR(agent);
+ goto err;
+ }
+ dev->send_agent[p][q] = agent;
+ }
+
+
+ for (p = 1; p <= dev->limits.num_ports; ++p) {
+ ret = mthca_update_rate(dev, p);
+ if (ret) {
+ mthca_err(dev, "Failed to obtain port %d rate."
+ " aborting.\n", p);
+ goto err;
+ }
+ }
+
+ return 0;
+
+err:
+ for (p = 0; p < dev->limits.num_ports; ++p)
+ for (q = 0; q <= 1; ++q)
+ if (dev->send_agent[p][q])
+ ib_unregister_mad_agent(dev->send_agent[p][q]);
+
+ return ret;
+}
+
+void mthca_free_agents(struct mthca_dev *dev)
+{
+ struct ib_mad_agent *agent;
+ int p, q;
+
+ for (p = 0; p < dev->limits.num_ports; ++p) {
+ for (q = 0; q <= 1; ++q) {
+ agent = dev->send_agent[p][q];
+ dev->send_agent[p][q] = NULL;
+ ib_unregister_mad_agent(agent);
+ }
+
+ if (dev->sm_ah[p])
+ ib_destroy_ah(dev->sm_ah[p]);
+ }
+}
diff --git a/sys/dev/mthca/mthca_main.c b/sys/dev/mthca/mthca_main.c
new file mode 100644
index 0000000..d91d05d
--- /dev/null
+++ b/sys/dev/mthca/mthca_main.c
@@ -0,0 +1,1279 @@
+/*
+ * Copyright (c) 2004, 2005 Topspin Communications. All rights reserved.
+ * Copyright (c) 2005 Sun Microsystems, Inc. All rights reserved.
+ * Copyright (c) 2005 Mellanox Technologies. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#define LINUXKPI_PARAM_PREFIX mthca_
+
+#include <linux/module.h>
+#include <linux/errno.h>
+#include <linux/pci.h>
+#include <linux/interrupt.h>
+#include <linux/gfp.h>
+
+#include "mthca_dev.h"
+#include "mthca_config_reg.h"
+#include "mthca_cmd.h"
+#include "mthca_profile.h"
+#include "mthca_memfree.h"
+#include "mthca_wqe.h"
+
+MODULE_AUTHOR("Roland Dreier");
+MODULE_DESCRIPTION("Mellanox InfiniBand HCA low-level driver");
+MODULE_LICENSE("Dual BSD/GPL");
+
+#ifdef CONFIG_INFINIBAND_MTHCA_DEBUG
+
+int mthca_debug_level = 0;
+module_param_named(debug_level, mthca_debug_level, int, 0644);
+MODULE_PARM_DESC(debug_level, "Enable debug tracing if > 0");
+
+#endif /* CONFIG_INFINIBAND_MTHCA_DEBUG */
+
+#ifdef CONFIG_PCI_MSI
+
+static int msi_x = 1;
+module_param(msi_x, int, 0444);
+MODULE_PARM_DESC(msi_x, "attempt to use MSI-X if nonzero");
+
+#else /* CONFIG_PCI_MSI */
+
+#define msi_x (0)
+
+#endif /* CONFIG_PCI_MSI */
+
+static int tune_pci = 0;
+module_param(tune_pci, int, 0444);
+MODULE_PARM_DESC(tune_pci, "increase PCI burst from the default set by BIOS if nonzero");
+
+DEFINE_MUTEX(mthca_device_mutex);
+
+#define MTHCA_DEFAULT_NUM_QP (1 << 16)
+#define MTHCA_DEFAULT_RDB_PER_QP (1 << 2)
+#define MTHCA_DEFAULT_NUM_CQ (1 << 16)
+#define MTHCA_DEFAULT_NUM_MCG (1 << 13)
+#define MTHCA_DEFAULT_NUM_MPT (1 << 17)
+#define MTHCA_DEFAULT_NUM_MTT (1 << 20)
+#define MTHCA_DEFAULT_NUM_UDAV (1 << 15)
+#define MTHCA_DEFAULT_NUM_RESERVED_MTTS (1 << 18)
+#define MTHCA_DEFAULT_NUM_UARC_SIZE (1 << 18)
+
+static struct mthca_profile hca_profile = {
+ .num_qp = MTHCA_DEFAULT_NUM_QP,
+ .rdb_per_qp = MTHCA_DEFAULT_RDB_PER_QP,
+ .num_cq = MTHCA_DEFAULT_NUM_CQ,
+ .num_mcg = MTHCA_DEFAULT_NUM_MCG,
+ .num_mpt = MTHCA_DEFAULT_NUM_MPT,
+ .num_mtt = MTHCA_DEFAULT_NUM_MTT,
+ .num_udav = MTHCA_DEFAULT_NUM_UDAV, /* Tavor only */
+ .fmr_reserved_mtts = MTHCA_DEFAULT_NUM_RESERVED_MTTS, /* Tavor only */
+ .uarc_size = MTHCA_DEFAULT_NUM_UARC_SIZE, /* Arbel only */
+};
+
+module_param_named(num_qp, hca_profile.num_qp, int, 0444);
+MODULE_PARM_DESC(num_qp, "maximum number of QPs per HCA");
+
+module_param_named(rdb_per_qp, hca_profile.rdb_per_qp, int, 0444);
+MODULE_PARM_DESC(rdb_per_qp, "number of RDB buffers per QP");
+
+module_param_named(num_cq, hca_profile.num_cq, int, 0444);
+MODULE_PARM_DESC(num_cq, "maximum number of CQs per HCA");
+
+module_param_named(num_mcg, hca_profile.num_mcg, int, 0444);
+MODULE_PARM_DESC(num_mcg, "maximum number of multicast groups per HCA");
+
+module_param_named(num_mpt, hca_profile.num_mpt, int, 0444);
+MODULE_PARM_DESC(num_mpt,
+ "maximum number of memory protection table entries per HCA");
+
+module_param_named(num_mtt, hca_profile.num_mtt, int, 0444);
+MODULE_PARM_DESC(num_mtt,
+ "maximum number of memory translation table segments per HCA");
+
+module_param_named(num_udav, hca_profile.num_udav, int, 0444);
+MODULE_PARM_DESC(num_udav, "maximum number of UD address vectors per HCA");
+
+module_param_named(fmr_reserved_mtts, hca_profile.fmr_reserved_mtts, int, 0444);
+MODULE_PARM_DESC(fmr_reserved_mtts,
+ "number of memory translation table segments reserved for FMR");
+
+static int log_mtts_per_seg = ilog2(MTHCA_MTT_SEG_SIZE / 8);
+module_param_named(log_mtts_per_seg, log_mtts_per_seg, int, 0444);
+MODULE_PARM_DESC(log_mtts_per_seg, "Log2 number of MTT entries per segment (1-5)");
+
+static char mthca_version[] =
+ DRV_NAME ": Mellanox InfiniBand HCA driver v"
+ DRV_VERSION " (" DRV_RELDATE ")\n";
+
+static int mthca_tune_pci(struct mthca_dev *mdev)
+{
+ if (!tune_pci)
+ return 0;
+
+ /* First try to max out Read Byte Count */
+ if (pci_find_capability(mdev->pdev, PCI_CAP_ID_PCIX)) {
+ if (pcix_set_mmrbc(mdev->pdev, pcix_get_max_mmrbc(mdev->pdev))) {
+ mthca_err(mdev, "Couldn't set PCI-X max read count, "
+ "aborting.\n");
+ return -ENODEV;
+ }
+ } else if (!(mdev->mthca_flags & MTHCA_FLAG_PCIE))
+ mthca_info(mdev, "No PCI-X capability, not setting RBC.\n");
+
+ if (pci_is_pcie(mdev->pdev)) {
+ if (pcie_set_readrq(mdev->pdev, 4096)) {
+ mthca_err(mdev, "Couldn't write PCI Express read request, "
+ "aborting.\n");
+ return -ENODEV;
+ }
+ } else if (mdev->mthca_flags & MTHCA_FLAG_PCIE)
+ mthca_info(mdev, "No PCI Express capability, "
+ "not setting Max Read Request Size.\n");
+
+ return 0;
+}
+
+static int mthca_dev_lim(struct mthca_dev *mdev, struct mthca_dev_lim *dev_lim)
+{
+ int err;
+
+ mdev->limits.mtt_seg_size = (1 << log_mtts_per_seg) * 8;
+ err = mthca_QUERY_DEV_LIM(mdev, dev_lim);
+ if (err) {
+ mthca_err(mdev, "QUERY_DEV_LIM command returned %d"
+ ", aborting.\n", err);
+ return err;
+ }
+ if (dev_lim->min_page_sz > PAGE_SIZE) {
+ mthca_err(mdev, "HCA minimum page size of %d bigger than "
+ "kernel PAGE_SIZE of %ld, aborting.\n",
+ dev_lim->min_page_sz, (long)PAGE_SIZE);
+ return -ENODEV;
+ }
+ if (dev_lim->num_ports > MTHCA_MAX_PORTS) {
+ mthca_err(mdev, "HCA has %d ports, but we only support %d, "
+ "aborting.\n",
+ dev_lim->num_ports, MTHCA_MAX_PORTS);
+ return -ENODEV;
+ }
+
+ if (dev_lim->uar_size > pci_resource_len(mdev->pdev, 2)) {
+ mthca_err(mdev, "HCA reported UAR size of 0x%x bigger than "
+ "PCI resource 2 size of 0x%llx, aborting.\n",
+ dev_lim->uar_size,
+ (unsigned long long)pci_resource_len(mdev->pdev, 2));
+ return -ENODEV;
+ }
+
+ mdev->limits.num_ports = dev_lim->num_ports;
+ mdev->limits.vl_cap = dev_lim->max_vl;
+ mdev->limits.mtu_cap = dev_lim->max_mtu;
+ mdev->limits.gid_table_len = dev_lim->max_gids;
+ mdev->limits.pkey_table_len = dev_lim->max_pkeys;
+ mdev->limits.local_ca_ack_delay = dev_lim->local_ca_ack_delay;
+ /*
+ * Need to allow for worst case send WQE overhead and check
+ * whether max_desc_sz imposes a lower limit than max_sg; UD
+ * send has the biggest overhead.
+ */
+ mdev->limits.max_sg = min_t(int, dev_lim->max_sg,
+ (dev_lim->max_desc_sz -
+ sizeof (struct mthca_next_seg) -
+ (mthca_is_memfree(mdev) ?
+ sizeof (struct mthca_arbel_ud_seg) :
+ sizeof (struct mthca_tavor_ud_seg))) /
+ sizeof (struct mthca_data_seg));
+ mdev->limits.max_wqes = dev_lim->max_qp_sz;
+ mdev->limits.max_qp_init_rdma = dev_lim->max_requester_per_qp;
+ mdev->limits.reserved_qps = dev_lim->reserved_qps;
+ mdev->limits.max_srq_wqes = dev_lim->max_srq_sz;
+ mdev->limits.reserved_srqs = dev_lim->reserved_srqs;
+ mdev->limits.reserved_eecs = dev_lim->reserved_eecs;
+ mdev->limits.max_desc_sz = dev_lim->max_desc_sz;
+ mdev->limits.max_srq_sge = mthca_max_srq_sge(mdev);
+ /*
+ * Subtract 1 from the limit because we need to allocate a
+ * spare CQE so the HCA HW can tell the difference between an
+ * empty CQ and a full CQ.
+ */
+ mdev->limits.max_cqes = dev_lim->max_cq_sz - 1;
+ mdev->limits.reserved_cqs = dev_lim->reserved_cqs;
+ mdev->limits.reserved_eqs = dev_lim->reserved_eqs;
+ mdev->limits.reserved_mtts = dev_lim->reserved_mtts;
+ mdev->limits.reserved_mrws = dev_lim->reserved_mrws;
+ mdev->limits.reserved_uars = dev_lim->reserved_uars;
+ mdev->limits.reserved_pds = dev_lim->reserved_pds;
+ mdev->limits.port_width_cap = dev_lim->max_port_width;
+ mdev->limits.page_size_cap = ~(u32) (dev_lim->min_page_sz - 1);
+ mdev->limits.flags = dev_lim->flags;
+ /*
+ * For old FW that doesn't return static rate support, use a
+ * value of 0x3 (only static rate values of 0 or 1 are handled),
+ * except on Sinai, where even old FW can handle static rate
+ * values of 2 and 3.
+ */
+ if (dev_lim->stat_rate_support)
+ mdev->limits.stat_rate_support = dev_lim->stat_rate_support;
+ else if (mdev->mthca_flags & MTHCA_FLAG_SINAI_OPT)
+ mdev->limits.stat_rate_support = 0xf;
+ else
+ mdev->limits.stat_rate_support = 0x3;
+
+ /* IB_DEVICE_RESIZE_MAX_WR not supported by driver.
+ May be doable since hardware supports it for SRQ.
+
+ IB_DEVICE_N_NOTIFY_CQ is supported by hardware but not by driver.
+
+ IB_DEVICE_SRQ_RESIZE is supported by hardware but SRQ is not
+ supported by driver. */
+ mdev->device_cap_flags = IB_DEVICE_CHANGE_PHY_PORT |
+ IB_DEVICE_PORT_ACTIVE_EVENT |
+ IB_DEVICE_SYS_IMAGE_GUID |
+ IB_DEVICE_RC_RNR_NAK_GEN;
+
+ if (dev_lim->flags & DEV_LIM_FLAG_BAD_PKEY_CNTR)
+ mdev->device_cap_flags |= IB_DEVICE_BAD_PKEY_CNTR;
+
+ if (dev_lim->flags & DEV_LIM_FLAG_BAD_QKEY_CNTR)
+ mdev->device_cap_flags |= IB_DEVICE_BAD_QKEY_CNTR;
+
+ if (dev_lim->flags & DEV_LIM_FLAG_RAW_MULTI)
+ mdev->device_cap_flags |= IB_DEVICE_RAW_MULTI;
+
+ if (dev_lim->flags & DEV_LIM_FLAG_AUTO_PATH_MIG)
+ mdev->device_cap_flags |= IB_DEVICE_AUTO_PATH_MIG;
+
+ if (dev_lim->flags & DEV_LIM_FLAG_UD_AV_PORT_ENFORCE)
+ mdev->device_cap_flags |= IB_DEVICE_UD_AV_PORT_ENFORCE;
+
+ if (dev_lim->flags & DEV_LIM_FLAG_SRQ)
+ mdev->mthca_flags |= MTHCA_FLAG_SRQ;
+
+ if (mthca_is_memfree(mdev))
+ if (dev_lim->flags & DEV_LIM_FLAG_IPOIB_CSUM)
+ mdev->device_cap_flags |= IB_DEVICE_UD_IP_CSUM;
+
+ return 0;
+}
+
+static int mthca_init_tavor(struct mthca_dev *mdev)
+{
+ s64 size;
+ int err;
+ struct mthca_dev_lim dev_lim;
+ struct mthca_profile profile;
+ struct mthca_init_hca_param init_hca;
+
+ err = mthca_SYS_EN(mdev);
+ if (err) {
+ mthca_err(mdev, "SYS_EN command returned %d, aborting.\n", err);
+ return err;
+ }
+
+ err = mthca_QUERY_FW(mdev);
+ if (err) {
+ mthca_err(mdev, "QUERY_FW command returned %d,"
+ " aborting.\n", err);
+ goto err_disable;
+ }
+ err = mthca_QUERY_DDR(mdev);
+ if (err) {
+ mthca_err(mdev, "QUERY_DDR command returned %d, aborting.\n", err);
+ goto err_disable;
+ }
+
+ err = mthca_dev_lim(mdev, &dev_lim);
+ if (err) {
+ mthca_err(mdev, "QUERY_DEV_LIM command returned %d, aborting.\n", err);
+ goto err_disable;
+ }
+
+ profile = hca_profile;
+ profile.num_uar = dev_lim.uar_size / PAGE_SIZE;
+ profile.uarc_size = 0;
+ if (mdev->mthca_flags & MTHCA_FLAG_SRQ)
+ profile.num_srq = dev_lim.max_srqs;
+
+ size = mthca_make_profile(mdev, &profile, &dev_lim, &init_hca);
+ if (size < 0) {
+ err = size;
+ goto err_disable;
+ }
+
+ err = mthca_INIT_HCA(mdev, &init_hca);
+ if (err) {
+ mthca_err(mdev, "INIT_HCA command returned %d, aborting.\n", err);
+ goto err_disable;
+ }
+
+ return 0;
+
+err_disable:
+ mthca_SYS_DIS(mdev);
+
+ return err;
+}
+
+static int mthca_load_fw(struct mthca_dev *mdev)
+{
+ int err;
+
+ /* FIXME: use HCA-attached memory for FW if present */
+
+ mdev->fw.arbel.fw_icm =
+ mthca_alloc_icm(mdev, mdev->fw.arbel.fw_pages,
+ GFP_HIGHUSER | __GFP_NOWARN, 0);
+ if (!mdev->fw.arbel.fw_icm) {
+ mthca_err(mdev, "Couldn't allocate FW area, aborting.\n");
+ return -ENOMEM;
+ }
+
+ err = mthca_MAP_FA(mdev, mdev->fw.arbel.fw_icm);
+ if (err) {
+ mthca_err(mdev, "MAP_FA command returned %d, aborting.\n", err);
+ goto err_free;
+ }
+ err = mthca_RUN_FW(mdev);
+ if (err) {
+ mthca_err(mdev, "RUN_FW command returned %d, aborting.\n", err);
+ goto err_unmap_fa;
+ }
+
+ return 0;
+
+err_unmap_fa:
+ mthca_UNMAP_FA(mdev);
+
+err_free:
+ mthca_free_icm(mdev, mdev->fw.arbel.fw_icm, 0);
+ return err;
+}
+
+static int mthca_init_icm(struct mthca_dev *mdev,
+ struct mthca_dev_lim *dev_lim,
+ struct mthca_init_hca_param *init_hca,
+ u64 icm_size)
+{
+ u64 aux_pages;
+ int err;
+
+ err = mthca_SET_ICM_SIZE(mdev, icm_size, &aux_pages);
+ if (err) {
+ mthca_err(mdev, "SET_ICM_SIZE command returned %d, aborting.\n", err);
+ return err;
+ }
+
+ mthca_dbg(mdev, "%lld KB of HCA context requires %lld KB aux memory.\n",
+ (unsigned long long) icm_size >> 10,
+ (unsigned long long) aux_pages << 2);
+
+ mdev->fw.arbel.aux_icm = mthca_alloc_icm(mdev, aux_pages,
+ GFP_HIGHUSER | __GFP_NOWARN, 0);
+ if (!mdev->fw.arbel.aux_icm) {
+ mthca_err(mdev, "Couldn't allocate aux memory, aborting.\n");
+ return -ENOMEM;
+ }
+
+ err = mthca_MAP_ICM_AUX(mdev, mdev->fw.arbel.aux_icm);
+ if (err) {
+ mthca_err(mdev, "MAP_ICM_AUX returned %d, aborting.\n", err);
+ goto err_free_aux;
+ }
+
+ err = mthca_map_eq_icm(mdev, init_hca->eqc_base);
+ if (err) {
+ mthca_err(mdev, "Failed to map EQ context memory, aborting.\n");
+ goto err_unmap_aux;
+ }
+
+ /* CPU writes to non-reserved MTTs, while HCA might DMA to reserved mtts */
+ mdev->limits.reserved_mtts = ALIGN(mdev->limits.reserved_mtts * mdev->limits.mtt_seg_size,
+ dma_get_cache_alignment()) / mdev->limits.mtt_seg_size;
+
+ mdev->mr_table.mtt_table = mthca_alloc_icm_table(mdev, init_hca->mtt_base,
+ mdev->limits.mtt_seg_size,
+ mdev->limits.num_mtt_segs,
+ mdev->limits.reserved_mtts,
+ 1, 0);
+ if (!mdev->mr_table.mtt_table) {
+ mthca_err(mdev, "Failed to map MTT context memory, aborting.\n");
+ err = -ENOMEM;
+ goto err_unmap_eq;
+ }
+
+ mdev->mr_table.mpt_table = mthca_alloc_icm_table(mdev, init_hca->mpt_base,
+ dev_lim->mpt_entry_sz,
+ mdev->limits.num_mpts,
+ mdev->limits.reserved_mrws,
+ 1, 1);
+ if (!mdev->mr_table.mpt_table) {
+ mthca_err(mdev, "Failed to map MPT context memory, aborting.\n");
+ err = -ENOMEM;
+ goto err_unmap_mtt;
+ }
+
+ mdev->qp_table.qp_table = mthca_alloc_icm_table(mdev, init_hca->qpc_base,
+ dev_lim->qpc_entry_sz,
+ mdev->limits.num_qps,
+ mdev->limits.reserved_qps,
+ 0, 0);
+ if (!mdev->qp_table.qp_table) {
+ mthca_err(mdev, "Failed to map QP context memory, aborting.\n");
+ err = -ENOMEM;
+ goto err_unmap_mpt;
+ }
+
+ mdev->qp_table.eqp_table = mthca_alloc_icm_table(mdev, init_hca->eqpc_base,
+ dev_lim->eqpc_entry_sz,
+ mdev->limits.num_qps,
+ mdev->limits.reserved_qps,
+ 0, 0);
+ if (!mdev->qp_table.eqp_table) {
+ mthca_err(mdev, "Failed to map EQP context memory, aborting.\n");
+ err = -ENOMEM;
+ goto err_unmap_qp;
+ }
+
+ mdev->qp_table.rdb_table = mthca_alloc_icm_table(mdev, init_hca->rdb_base,
+ MTHCA_RDB_ENTRY_SIZE,
+ mdev->limits.num_qps <<
+ mdev->qp_table.rdb_shift, 0,
+ 0, 0);
+ if (!mdev->qp_table.rdb_table) {
+ mthca_err(mdev, "Failed to map RDB context memory, aborting\n");
+ err = -ENOMEM;
+ goto err_unmap_eqp;
+ }
+
+ mdev->cq_table.table = mthca_alloc_icm_table(mdev, init_hca->cqc_base,
+ dev_lim->cqc_entry_sz,
+ mdev->limits.num_cqs,
+ mdev->limits.reserved_cqs,
+ 0, 0);
+ if (!mdev->cq_table.table) {
+ mthca_err(mdev, "Failed to map CQ context memory, aborting.\n");
+ err = -ENOMEM;
+ goto err_unmap_rdb;
+ }
+
+ if (mdev->mthca_flags & MTHCA_FLAG_SRQ) {
+ mdev->srq_table.table =
+ mthca_alloc_icm_table(mdev, init_hca->srqc_base,
+ dev_lim->srq_entry_sz,
+ mdev->limits.num_srqs,
+ mdev->limits.reserved_srqs,
+ 0, 0);
+ if (!mdev->srq_table.table) {
+ mthca_err(mdev, "Failed to map SRQ context memory, "
+ "aborting.\n");
+ err = -ENOMEM;
+ goto err_unmap_cq;
+ }
+ }
+
+ /*
+ * It's not strictly required, but for simplicity just map the
+ * whole multicast group table now. The table isn't very big
+ * and it's a lot easier than trying to track ref counts.
+ */
+ mdev->mcg_table.table = mthca_alloc_icm_table(mdev, init_hca->mc_base,
+ MTHCA_MGM_ENTRY_SIZE,
+ mdev->limits.num_mgms +
+ mdev->limits.num_amgms,
+ mdev->limits.num_mgms +
+ mdev->limits.num_amgms,
+ 0, 0);
+ if (!mdev->mcg_table.table) {
+ mthca_err(mdev, "Failed to map MCG context memory, aborting.\n");
+ err = -ENOMEM;
+ goto err_unmap_srq;
+ }
+
+ return 0;
+
+err_unmap_srq:
+ if (mdev->mthca_flags & MTHCA_FLAG_SRQ)
+ mthca_free_icm_table(mdev, mdev->srq_table.table);
+
+err_unmap_cq:
+ mthca_free_icm_table(mdev, mdev->cq_table.table);
+
+err_unmap_rdb:
+ mthca_free_icm_table(mdev, mdev->qp_table.rdb_table);
+
+err_unmap_eqp:
+ mthca_free_icm_table(mdev, mdev->qp_table.eqp_table);
+
+err_unmap_qp:
+ mthca_free_icm_table(mdev, mdev->qp_table.qp_table);
+
+err_unmap_mpt:
+ mthca_free_icm_table(mdev, mdev->mr_table.mpt_table);
+
+err_unmap_mtt:
+ mthca_free_icm_table(mdev, mdev->mr_table.mtt_table);
+
+err_unmap_eq:
+ mthca_unmap_eq_icm(mdev);
+
+err_unmap_aux:
+ mthca_UNMAP_ICM_AUX(mdev);
+
+err_free_aux:
+ mthca_free_icm(mdev, mdev->fw.arbel.aux_icm, 0);
+
+ return err;
+}
+
+static void mthca_free_icms(struct mthca_dev *mdev)
+{
+
+ mthca_free_icm_table(mdev, mdev->mcg_table.table);
+ if (mdev->mthca_flags & MTHCA_FLAG_SRQ)
+ mthca_free_icm_table(mdev, mdev->srq_table.table);
+ mthca_free_icm_table(mdev, mdev->cq_table.table);
+ mthca_free_icm_table(mdev, mdev->qp_table.rdb_table);
+ mthca_free_icm_table(mdev, mdev->qp_table.eqp_table);
+ mthca_free_icm_table(mdev, mdev->qp_table.qp_table);
+ mthca_free_icm_table(mdev, mdev->mr_table.mpt_table);
+ mthca_free_icm_table(mdev, mdev->mr_table.mtt_table);
+ mthca_unmap_eq_icm(mdev);
+
+ mthca_UNMAP_ICM_AUX(mdev);
+ mthca_free_icm(mdev, mdev->fw.arbel.aux_icm, 0);
+}
+
+static int mthca_init_arbel(struct mthca_dev *mdev)
+{
+ struct mthca_dev_lim dev_lim;
+ struct mthca_profile profile;
+ struct mthca_init_hca_param init_hca;
+ s64 icm_size;
+ int err;
+
+ err = mthca_QUERY_FW(mdev);
+ if (err) {
+ mthca_err(mdev, "QUERY_FW command failed %d, aborting.\n", err);
+ return err;
+ }
+
+ err = mthca_ENABLE_LAM(mdev);
+ if (err == -EAGAIN) {
+ mthca_dbg(mdev, "No HCA-attached memory (running in MemFree mode)\n");
+ mdev->mthca_flags |= MTHCA_FLAG_NO_LAM;
+ } else if (err) {
+ mthca_err(mdev, "ENABLE_LAM returned %d, aborting.\n", err);
+ return err;
+ }
+
+ err = mthca_load_fw(mdev);
+ if (err) {
+ mthca_err(mdev, "Loading FW returned %d, aborting.\n", err);
+ goto err_disable;
+ }
+
+ err = mthca_dev_lim(mdev, &dev_lim);
+ if (err) {
+ mthca_err(mdev, "QUERY_DEV_LIM returned %d, aborting.\n", err);
+ goto err_stop_fw;
+ }
+
+ profile = hca_profile;
+ profile.num_uar = dev_lim.uar_size / PAGE_SIZE;
+ profile.num_udav = 0;
+ if (mdev->mthca_flags & MTHCA_FLAG_SRQ)
+ profile.num_srq = dev_lim.max_srqs;
+
+ icm_size = mthca_make_profile(mdev, &profile, &dev_lim, &init_hca);
+ if (icm_size < 0) {
+ err = icm_size;
+ goto err_stop_fw;
+ }
+
+ err = mthca_init_icm(mdev, &dev_lim, &init_hca, icm_size);
+ if (err)
+ goto err_stop_fw;
+
+ err = mthca_INIT_HCA(mdev, &init_hca);
+ if (err) {
+ mthca_err(mdev, "INIT_HCA command returned %d, aborting.\n", err);
+ goto err_free_icm;
+ }
+
+ return 0;
+
+err_free_icm:
+ mthca_free_icms(mdev);
+
+err_stop_fw:
+ mthca_UNMAP_FA(mdev);
+ mthca_free_icm(mdev, mdev->fw.arbel.fw_icm, 0);
+
+err_disable:
+ if (!(mdev->mthca_flags & MTHCA_FLAG_NO_LAM))
+ mthca_DISABLE_LAM(mdev);
+
+ return err;
+}
+
+static void mthca_close_hca(struct mthca_dev *mdev)
+{
+ mthca_CLOSE_HCA(mdev, 0);
+
+ if (mthca_is_memfree(mdev)) {
+ mthca_free_icms(mdev);
+
+ mthca_UNMAP_FA(mdev);
+ mthca_free_icm(mdev, mdev->fw.arbel.fw_icm, 0);
+
+ if (!(mdev->mthca_flags & MTHCA_FLAG_NO_LAM))
+ mthca_DISABLE_LAM(mdev);
+ } else
+ mthca_SYS_DIS(mdev);
+}
+
+static int mthca_init_hca(struct mthca_dev *mdev)
+{
+ int err;
+ struct mthca_adapter adapter;
+
+ if (mthca_is_memfree(mdev))
+ err = mthca_init_arbel(mdev);
+ else
+ err = mthca_init_tavor(mdev);
+
+ if (err)
+ return err;
+
+ err = mthca_QUERY_ADAPTER(mdev, &adapter);
+ if (err) {
+ mthca_err(mdev, "QUERY_ADAPTER command returned %d, aborting.\n", err);
+ goto err_close;
+ }
+
+ mdev->eq_table.inta_pin = adapter.inta_pin;
+ if (!mthca_is_memfree(mdev))
+ mdev->rev_id = adapter.revision_id;
+ memcpy(mdev->board_id, adapter.board_id, sizeof mdev->board_id);
+
+ return 0;
+
+err_close:
+ mthca_close_hca(mdev);
+ return err;
+}
+
+static int mthca_setup_hca(struct mthca_dev *dev)
+{
+ int err;
+
+ MTHCA_INIT_DOORBELL_LOCK(&dev->doorbell_lock);
+
+ err = mthca_init_uar_table(dev);
+ if (err) {
+ mthca_err(dev, "Failed to initialize "
+ "user access region table, aborting.\n");
+ return err;
+ }
+
+ err = mthca_uar_alloc(dev, &dev->driver_uar);
+ if (err) {
+ mthca_err(dev, "Failed to allocate driver access region, "
+ "aborting.\n");
+ goto err_uar_table_free;
+ }
+
+ dev->kar = ioremap((phys_addr_t) dev->driver_uar.pfn << PAGE_SHIFT, PAGE_SIZE);
+ if (!dev->kar) {
+ mthca_err(dev, "Couldn't map kernel access region, "
+ "aborting.\n");
+ err = -ENOMEM;
+ goto err_uar_free;
+ }
+
+ err = mthca_init_pd_table(dev);
+ if (err) {
+ mthca_err(dev, "Failed to initialize "
+ "protection domain table, aborting.\n");
+ goto err_kar_unmap;
+ }
+
+ err = mthca_init_mr_table(dev);
+ if (err) {
+ mthca_err(dev, "Failed to initialize "
+ "memory region table, aborting.\n");
+ goto err_pd_table_free;
+ }
+
+ err = mthca_pd_alloc(dev, 1, &dev->driver_pd);
+ if (err) {
+ mthca_err(dev, "Failed to create driver PD, "
+ "aborting.\n");
+ goto err_mr_table_free;
+ }
+
+ err = mthca_init_eq_table(dev);
+ if (err) {
+ mthca_err(dev, "Failed to initialize "
+ "event queue table, aborting.\n");
+ goto err_pd_free;
+ }
+
+ err = mthca_cmd_use_events(dev);
+ if (err) {
+ mthca_err(dev, "Failed to switch to event-driven "
+ "firmware commands, aborting.\n");
+ goto err_eq_table_free;
+ }
+
+ err = mthca_NOP(dev);
+ if (err) {
+ if (dev->mthca_flags & MTHCA_FLAG_MSI_X) {
+ mthca_warn(dev, "NOP command failed to generate interrupt "
+ "(IRQ %d).\n",
+ dev->eq_table.eq[MTHCA_EQ_CMD].msi_x_vector);
+ mthca_warn(dev, "Trying again with MSI-X disabled.\n");
+ } else {
+ mthca_err(dev, "NOP command failed to generate interrupt "
+ "(IRQ %d), aborting.\n",
+ dev->pdev->irq);
+ mthca_err(dev, "BIOS or ACPI interrupt routing problem?\n");
+ }
+
+ goto err_cmd_poll;
+ }
+
+ mthca_dbg(dev, "NOP command IRQ test passed\n");
+
+ err = mthca_init_cq_table(dev);
+ if (err) {
+ mthca_err(dev, "Failed to initialize "
+ "completion queue table, aborting.\n");
+ goto err_cmd_poll;
+ }
+
+ err = mthca_init_srq_table(dev);
+ if (err) {
+ mthca_err(dev, "Failed to initialize "
+ "shared receive queue table, aborting.\n");
+ goto err_cq_table_free;
+ }
+
+ err = mthca_init_qp_table(dev);
+ if (err) {
+ mthca_err(dev, "Failed to initialize "
+ "queue pair table, aborting.\n");
+ goto err_srq_table_free;
+ }
+
+ err = mthca_init_av_table(dev);
+ if (err) {
+ mthca_err(dev, "Failed to initialize "
+ "address vector table, aborting.\n");
+ goto err_qp_table_free;
+ }
+
+ err = mthca_init_mcg_table(dev);
+ if (err) {
+ mthca_err(dev, "Failed to initialize "
+ "multicast group table, aborting.\n");
+ goto err_av_table_free;
+ }
+
+ return 0;
+
+err_av_table_free:
+ mthca_cleanup_av_table(dev);
+
+err_qp_table_free:
+ mthca_cleanup_qp_table(dev);
+
+err_srq_table_free:
+ mthca_cleanup_srq_table(dev);
+
+err_cq_table_free:
+ mthca_cleanup_cq_table(dev);
+
+err_cmd_poll:
+ mthca_cmd_use_polling(dev);
+
+err_eq_table_free:
+ mthca_cleanup_eq_table(dev);
+
+err_pd_free:
+ mthca_pd_free(dev, &dev->driver_pd);
+
+err_mr_table_free:
+ mthca_cleanup_mr_table(dev);
+
+err_pd_table_free:
+ mthca_cleanup_pd_table(dev);
+
+err_kar_unmap:
+ iounmap(dev->kar);
+
+err_uar_free:
+ mthca_uar_free(dev, &dev->driver_uar);
+
+err_uar_table_free:
+ mthca_cleanup_uar_table(dev);
+ return err;
+}
+
+static int mthca_enable_msi_x(struct mthca_dev *mdev)
+{
+ struct msix_entry entries[3];
+ int err;
+
+ entries[0].entry = 0;
+ entries[1].entry = 1;
+ entries[2].entry = 2;
+
+ err = pci_enable_msix_range(mdev->pdev, entries, ARRAY_SIZE(entries), ARRAY_SIZE(entries));
+ if (err < 0)
+ return err;
+
+ mdev->eq_table.eq[MTHCA_EQ_COMP ].msi_x_vector = entries[0].vector;
+ mdev->eq_table.eq[MTHCA_EQ_ASYNC].msi_x_vector = entries[1].vector;
+ mdev->eq_table.eq[MTHCA_EQ_CMD ].msi_x_vector = entries[2].vector;
+
+ return 0;
+}
+
+/* Types of supported HCA */
+enum {
+ TAVOR, /* MT23108 */
+ ARBEL_COMPAT, /* MT25208 in Tavor compat mode */
+ ARBEL_NATIVE, /* MT25208 with extended features */
+ SINAI /* MT25204 */
+};
+
+#define MTHCA_FW_VER(major, minor, subminor) \
+ (((u64) (major) << 32) | ((u64) (minor) << 16) | (u64) (subminor))
+
+static struct {
+ u64 latest_fw;
+ u32 flags;
+} mthca_hca_table[] = {
+ [TAVOR] = { .latest_fw = MTHCA_FW_VER(3, 5, 0),
+ .flags = 0 },
+ [ARBEL_COMPAT] = { .latest_fw = MTHCA_FW_VER(4, 8, 200),
+ .flags = MTHCA_FLAG_PCIE },
+ [ARBEL_NATIVE] = { .latest_fw = MTHCA_FW_VER(5, 3, 0),
+ .flags = MTHCA_FLAG_MEMFREE |
+ MTHCA_FLAG_PCIE },
+ [SINAI] = { .latest_fw = MTHCA_FW_VER(1, 2, 0),
+ .flags = MTHCA_FLAG_MEMFREE |
+ MTHCA_FLAG_PCIE |
+ MTHCA_FLAG_SINAI_OPT }
+};
+
+static int __mthca_init_one(struct pci_dev *pdev, int hca_type)
+{
+ int ddr_hidden = 0;
+ int err;
+ struct mthca_dev *mdev;
+
+ printk(KERN_INFO PFX "Initializing %s\n",
+ pci_name(pdev));
+
+ err = pci_enable_device(pdev);
+ if (err) {
+ dev_err(&pdev->dev, "Cannot enable PCI device, "
+ "aborting.\n");
+ return err;
+ }
+
+ /*
+ * Check for BARs. We expect 0: 1MB, 2: 8MB, 4: DDR (may not
+ * be present)
+ */
+ if (!(pci_resource_flags(pdev, 0) & IORESOURCE_MEM) ||
+ pci_resource_len(pdev, 0) != 1 << 20) {
+ dev_err(&pdev->dev, "Missing DCS, aborting.\n");
+ err = -ENODEV;
+ goto err_disable_pdev;
+ }
+ if (!(pci_resource_flags(pdev, 2) & IORESOURCE_MEM)) {
+ dev_err(&pdev->dev, "Missing UAR, aborting.\n");
+ err = -ENODEV;
+ goto err_disable_pdev;
+ }
+ if (!(pci_resource_flags(pdev, 4) & IORESOURCE_MEM))
+ ddr_hidden = 1;
+
+ err = pci_request_regions(pdev, DRV_NAME);
+ if (err) {
+ dev_err(&pdev->dev, "Cannot obtain PCI resources, "
+ "aborting.\n");
+ goto err_disable_pdev;
+ }
+
+ pci_set_master(pdev);
+
+ err = pci_set_dma_mask(pdev, DMA_BIT_MASK(64));
+ if (err) {
+ dev_warn(&pdev->dev, "Warning: couldn't set 64-bit PCI DMA mask.\n");
+ err = pci_set_dma_mask(pdev, DMA_BIT_MASK(32));
+ if (err) {
+ dev_err(&pdev->dev, "Can't set PCI DMA mask, aborting.\n");
+ goto err_free_res;
+ }
+ }
+ err = pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(64));
+ if (err) {
+ dev_warn(&pdev->dev, "Warning: couldn't set 64-bit "
+ "consistent PCI DMA mask.\n");
+ err = pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(32));
+ if (err) {
+ dev_err(&pdev->dev, "Can't set consistent PCI DMA mask, "
+ "aborting.\n");
+ goto err_free_res;
+ }
+ }
+
+ /* We can handle large RDMA requests, so allow larger segments. */
+ dma_set_max_seg_size(&pdev->dev, 1024 * 1024 * 1024);
+
+ mdev = (struct mthca_dev *) ib_alloc_device(sizeof *mdev);
+ if (!mdev) {
+ dev_err(&pdev->dev, "Device struct alloc failed, "
+ "aborting.\n");
+ err = -ENOMEM;
+ goto err_free_res;
+ }
+
+ mdev->pdev = pdev;
+
+ mdev->mthca_flags = mthca_hca_table[hca_type].flags;
+ if (ddr_hidden)
+ mdev->mthca_flags |= MTHCA_FLAG_DDR_HIDDEN;
+
+ /*
+ * Now reset the HCA before we touch the PCI capabilities or
+ * attempt a firmware command, since a boot ROM may have left
+ * the HCA in an undefined state.
+ */
+ err = mthca_reset(mdev);
+ if (err) {
+ mthca_err(mdev, "Failed to reset HCA, aborting.\n");
+ goto err_free_dev;
+ }
+
+ if (mthca_cmd_init(mdev)) {
+ mthca_err(mdev, "Failed to init command interface, aborting.\n");
+ goto err_free_dev;
+ }
+
+ err = mthca_tune_pci(mdev);
+ if (err)
+ goto err_cmd;
+
+ err = mthca_init_hca(mdev);
+ if (err)
+ goto err_cmd;
+
+ if (mdev->fw_ver < mthca_hca_table[hca_type].latest_fw) {
+ mthca_warn(mdev, "HCA FW version %d.%d.%03d is old (%d.%d.%03d is current).\n",
+ (int) (mdev->fw_ver >> 32), (int) (mdev->fw_ver >> 16) & 0xffff,
+ (int) (mdev->fw_ver & 0xffff),
+ (int) (mthca_hca_table[hca_type].latest_fw >> 32),
+ (int) (mthca_hca_table[hca_type].latest_fw >> 16) & 0xffff,
+ (int) (mthca_hca_table[hca_type].latest_fw & 0xffff));
+ mthca_warn(mdev, "If you have problems, try updating your HCA FW.\n");
+ }
+
+ if (msi_x && !mthca_enable_msi_x(mdev))
+ mdev->mthca_flags |= MTHCA_FLAG_MSI_X;
+
+ err = mthca_setup_hca(mdev);
+ if (err == -EBUSY && (mdev->mthca_flags & MTHCA_FLAG_MSI_X)) {
+ if (mdev->mthca_flags & MTHCA_FLAG_MSI_X)
+ pci_disable_msix(pdev);
+ mdev->mthca_flags &= ~MTHCA_FLAG_MSI_X;
+
+ err = mthca_setup_hca(mdev);
+ }
+
+ if (err)
+ goto err_close;
+
+ err = mthca_register_device(mdev);
+ if (err)
+ goto err_cleanup;
+
+ err = mthca_create_agents(mdev);
+ if (err)
+ goto err_unregister;
+
+ pci_set_drvdata(pdev, mdev);
+ mdev->hca_type = hca_type;
+
+ mdev->active = true;
+
+ return 0;
+
+err_unregister:
+ mthca_unregister_device(mdev);
+
+err_cleanup:
+ mthca_cleanup_mcg_table(mdev);
+ mthca_cleanup_av_table(mdev);
+ mthca_cleanup_qp_table(mdev);
+ mthca_cleanup_srq_table(mdev);
+ mthca_cleanup_cq_table(mdev);
+ mthca_cmd_use_polling(mdev);
+ mthca_cleanup_eq_table(mdev);
+
+ mthca_pd_free(mdev, &mdev->driver_pd);
+
+ mthca_cleanup_mr_table(mdev);
+ mthca_cleanup_pd_table(mdev);
+ mthca_cleanup_uar_table(mdev);
+
+err_close:
+ if (mdev->mthca_flags & MTHCA_FLAG_MSI_X)
+ pci_disable_msix(pdev);
+
+ mthca_close_hca(mdev);
+
+err_cmd:
+ mthca_cmd_cleanup(mdev);
+
+err_free_dev:
+ ib_dealloc_device(&mdev->ib_dev);
+
+err_free_res:
+ pci_release_regions(pdev);
+
+err_disable_pdev:
+ pci_disable_device(pdev);
+ pci_set_drvdata(pdev, NULL);
+ return err;
+}
+
+static void __mthca_remove_one(struct pci_dev *pdev)
+{
+ struct mthca_dev *mdev = pci_get_drvdata(pdev);
+ int p;
+
+ if (mdev) {
+ mthca_free_agents(mdev);
+ mthca_unregister_device(mdev);
+
+ for (p = 1; p <= mdev->limits.num_ports; ++p)
+ mthca_CLOSE_IB(mdev, p);
+
+ mthca_cleanup_mcg_table(mdev);
+ mthca_cleanup_av_table(mdev);
+ mthca_cleanup_qp_table(mdev);
+ mthca_cleanup_srq_table(mdev);
+ mthca_cleanup_cq_table(mdev);
+ mthca_cmd_use_polling(mdev);
+ mthca_cleanup_eq_table(mdev);
+
+ mthca_pd_free(mdev, &mdev->driver_pd);
+
+ mthca_cleanup_mr_table(mdev);
+ mthca_cleanup_pd_table(mdev);
+
+ iounmap(mdev->kar);
+ mthca_uar_free(mdev, &mdev->driver_uar);
+ mthca_cleanup_uar_table(mdev);
+ mthca_close_hca(mdev);
+ mthca_cmd_cleanup(mdev);
+
+ if (mdev->mthca_flags & MTHCA_FLAG_MSI_X)
+ pci_disable_msix(pdev);
+
+ ib_dealloc_device(&mdev->ib_dev);
+ pci_release_regions(pdev);
+ pci_disable_device(pdev);
+ pci_set_drvdata(pdev, NULL);
+ }
+}
+
+int __mthca_restart_one(struct pci_dev *pdev)
+{
+ struct mthca_dev *mdev;
+ int hca_type;
+
+ mdev = pci_get_drvdata(pdev);
+ if (!mdev)
+ return -ENODEV;
+ hca_type = mdev->hca_type;
+ __mthca_remove_one(pdev);
+ return __mthca_init_one(pdev, hca_type);
+}
+
+static int mthca_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
+{
+ int ret;
+
+ mutex_lock(&mthca_device_mutex);
+
+ printk_once(KERN_INFO "%s", mthca_version);
+
+ if (id->driver_data >= ARRAY_SIZE(mthca_hca_table)) {
+ printk(KERN_ERR PFX "%s has invalid driver data %lx\n",
+ pci_name(pdev), (long)id->driver_data);
+ mutex_unlock(&mthca_device_mutex);
+ return -ENODEV;
+ }
+
+ ret = __mthca_init_one(pdev, id->driver_data);
+
+ mutex_unlock(&mthca_device_mutex);
+
+ return ret;
+}
+
+static void mthca_remove_one(struct pci_dev *pdev)
+{
+ mutex_lock(&mthca_device_mutex);
+ __mthca_remove_one(pdev);
+ mutex_unlock(&mthca_device_mutex);
+}
+
+static struct pci_device_id mthca_pci_table[] = {
+ { PCI_DEVICE(PCI_VENDOR_ID_MELLANOX, PCI_DEVICE_ID_MELLANOX_TAVOR),
+ .driver_data = TAVOR },
+ { PCI_DEVICE(PCI_VENDOR_ID_TOPSPIN, PCI_DEVICE_ID_MELLANOX_TAVOR),
+ .driver_data = TAVOR },
+ { PCI_DEVICE(PCI_VENDOR_ID_MELLANOX, PCI_DEVICE_ID_MELLANOX_ARBEL_COMPAT),
+ .driver_data = ARBEL_COMPAT },
+ { PCI_DEVICE(PCI_VENDOR_ID_TOPSPIN, PCI_DEVICE_ID_MELLANOX_ARBEL_COMPAT),
+ .driver_data = ARBEL_COMPAT },
+ { PCI_DEVICE(PCI_VENDOR_ID_MELLANOX, PCI_DEVICE_ID_MELLANOX_ARBEL),
+ .driver_data = ARBEL_NATIVE },
+ { PCI_DEVICE(PCI_VENDOR_ID_TOPSPIN, PCI_DEVICE_ID_MELLANOX_ARBEL),
+ .driver_data = ARBEL_NATIVE },
+ { PCI_DEVICE(PCI_VENDOR_ID_MELLANOX, PCI_DEVICE_ID_MELLANOX_SINAI),
+ .driver_data = SINAI },
+ { PCI_DEVICE(PCI_VENDOR_ID_TOPSPIN, PCI_DEVICE_ID_MELLANOX_SINAI),
+ .driver_data = SINAI },
+ { PCI_DEVICE(PCI_VENDOR_ID_MELLANOX, PCI_DEVICE_ID_MELLANOX_SINAI_OLD),
+ .driver_data = SINAI },
+ { PCI_DEVICE(PCI_VENDOR_ID_TOPSPIN, PCI_DEVICE_ID_MELLANOX_SINAI_OLD),
+ .driver_data = SINAI },
+ { 0, }
+};
+
+MODULE_DEVICE_TABLE(pci, mthca_pci_table);
+
+static struct pci_driver mthca_driver = {
+ .name = DRV_NAME,
+ .id_table = mthca_pci_table,
+ .probe = mthca_init_one,
+ .remove = mthca_remove_one,
+};
+
+static void __init __mthca_check_profile_val(const char *name, int *pval,
+ int pval_default)
+{
+ /* value must be positive and power of 2 */
+ int old_pval = *pval;
+
+ if (old_pval <= 0)
+ *pval = pval_default;
+ else
+ *pval = roundup_pow_of_two(old_pval);
+
+ if (old_pval != *pval) {
+ printk(KERN_WARNING PFX "Invalid value %d for %s in module parameter.\n",
+ old_pval, name);
+ printk(KERN_WARNING PFX "Corrected %s to %d.\n", name, *pval);
+ }
+}
+
+#define mthca_check_profile_val(name, default) \
+ __mthca_check_profile_val(#name, &hca_profile.name, default)
+
+static void __init mthca_validate_profile(void)
+{
+ mthca_check_profile_val(num_qp, MTHCA_DEFAULT_NUM_QP);
+ mthca_check_profile_val(rdb_per_qp, MTHCA_DEFAULT_RDB_PER_QP);
+ mthca_check_profile_val(num_cq, MTHCA_DEFAULT_NUM_CQ);
+ mthca_check_profile_val(num_mcg, MTHCA_DEFAULT_NUM_MCG);
+ mthca_check_profile_val(num_mpt, MTHCA_DEFAULT_NUM_MPT);
+ mthca_check_profile_val(num_mtt, MTHCA_DEFAULT_NUM_MTT);
+ mthca_check_profile_val(num_udav, MTHCA_DEFAULT_NUM_UDAV);
+ mthca_check_profile_val(fmr_reserved_mtts, MTHCA_DEFAULT_NUM_RESERVED_MTTS);
+
+ if (hca_profile.fmr_reserved_mtts >= hca_profile.num_mtt) {
+ printk(KERN_WARNING PFX "Invalid fmr_reserved_mtts module parameter %d.\n",
+ hca_profile.fmr_reserved_mtts);
+ printk(KERN_WARNING PFX "(Must be smaller than num_mtt %d)\n",
+ hca_profile.num_mtt);
+ hca_profile.fmr_reserved_mtts = hca_profile.num_mtt / 2;
+ printk(KERN_WARNING PFX "Corrected fmr_reserved_mtts to %d.\n",
+ hca_profile.fmr_reserved_mtts);
+ }
+
+ if ((log_mtts_per_seg < 1) || (log_mtts_per_seg > 5)) {
+ printk(KERN_WARNING PFX "bad log_mtts_per_seg (%d). Using default - %d\n",
+ log_mtts_per_seg, ilog2(MTHCA_MTT_SEG_SIZE / 8));
+ log_mtts_per_seg = ilog2(MTHCA_MTT_SEG_SIZE / 8);
+ }
+}
+
+static int __init mthca_init(void)
+{
+ int ret;
+
+ mthca_validate_profile();
+
+ ret = mthca_catas_init();
+ if (ret)
+ return ret;
+
+ ret = pci_register_driver(&mthca_driver);
+ if (ret < 0) {
+ mthca_catas_cleanup();
+ return ret;
+ }
+
+ return 0;
+}
+
+static void __exit mthca_cleanup(void)
+{
+ pci_unregister_driver(&mthca_driver);
+ mthca_catas_cleanup();
+}
+
+module_init_order(mthca_init, SI_ORDER_THIRD);
+module_exit(mthca_cleanup);
+
+MODULE_VERSION(mthca, 1);
+MODULE_DEPEND(mthca, ibcore, 1, 1, 1);
+MODULE_DEPEND(mthca, linuxkpi, 1, 1, 1);
diff --git a/sys/dev/mthca/mthca_mcg.c b/sys/dev/mthca/mthca_mcg.c
new file mode 100644
index 0000000..6304ae8
--- /dev/null
+++ b/sys/dev/mthca/mthca_mcg.c
@@ -0,0 +1,335 @@
+/*
+ * Copyright (c) 2004 Topspin Communications. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#include <linux/string.h>
+#include <linux/gfp.h>
+
+#include "mthca_dev.h"
+#include "mthca_cmd.h"
+
+struct mthca_mgm {
+ __be32 next_gid_index;
+ u32 reserved[3];
+ u8 gid[16];
+ __be32 qp[MTHCA_QP_PER_MGM];
+};
+
+static const u8 zero_gid[16]; /* automatically initialized to 0 */
+
+/*
+ * Caller must hold MCG table semaphore. gid and mgm parameters must
+ * be properly aligned for command interface.
+ *
+ * Returns 0 unless a firmware command error occurs.
+ *
+ * If GID is found in MGM or MGM is empty, *index = *hash, *prev = -1
+ * and *mgm holds MGM entry.
+ *
+ * if GID is found in AMGM, *index = index in AMGM, *prev = index of
+ * previous entry in hash chain and *mgm holds AMGM entry.
+ *
+ * If no AMGM exists for given gid, *index = -1, *prev = index of last
+ * entry in hash chain and *mgm holds end of hash chain.
+ */
+static int find_mgm(struct mthca_dev *dev,
+ u8 *gid, struct mthca_mailbox *mgm_mailbox,
+ u16 *hash, int *prev, int *index)
+{
+ struct mthca_mailbox *mailbox;
+ struct mthca_mgm *mgm = mgm_mailbox->buf;
+ u8 *mgid;
+ int err;
+
+ mailbox = mthca_alloc_mailbox(dev, GFP_KERNEL);
+ if (IS_ERR(mailbox))
+ return -ENOMEM;
+ mgid = mailbox->buf;
+
+ memcpy(mgid, gid, 16);
+
+ err = mthca_MGID_HASH(dev, mailbox, hash);
+ if (err) {
+ mthca_err(dev, "MGID_HASH failed (%d)\n", err);
+ goto out;
+ }
+
+ if (0)
+ mthca_dbg(dev, "Hash for %pI6 is %04x\n", gid, *hash);
+
+ *index = *hash;
+ *prev = -1;
+
+ do {
+ err = mthca_READ_MGM(dev, *index, mgm_mailbox);
+ if (err) {
+ mthca_err(dev, "READ_MGM failed (%d)\n", err);
+ goto out;
+ }
+
+ if (!memcmp(mgm->gid, zero_gid, 16)) {
+ if (*index != *hash) {
+ mthca_err(dev, "Found zero MGID in AMGM.\n");
+ err = -EINVAL;
+ }
+ goto out;
+ }
+
+ if (!memcmp(mgm->gid, gid, 16))
+ goto out;
+
+ *prev = *index;
+ *index = be32_to_cpu(mgm->next_gid_index) >> 6;
+ } while (*index);
+
+ *index = -1;
+
+ out:
+ mthca_free_mailbox(dev, mailbox);
+ return err;
+}
+
+int mthca_multicast_attach(struct ib_qp *ibqp, union ib_gid *gid, u16 lid)
+{
+ struct mthca_dev *dev = to_mdev(ibqp->device);
+ struct mthca_mailbox *mailbox;
+ struct mthca_mgm *mgm;
+ u16 hash;
+ int index, prev;
+ int link = 0;
+ int i;
+ int err;
+
+ mailbox = mthca_alloc_mailbox(dev, GFP_KERNEL);
+ if (IS_ERR(mailbox))
+ return PTR_ERR(mailbox);
+ mgm = mailbox->buf;
+
+ mutex_lock(&dev->mcg_table.mutex);
+
+ err = find_mgm(dev, gid->raw, mailbox, &hash, &prev, &index);
+ if (err)
+ goto out;
+
+ if (index != -1) {
+ if (!memcmp(mgm->gid, zero_gid, 16))
+ memcpy(mgm->gid, gid->raw, 16);
+ } else {
+ link = 1;
+
+ index = mthca_alloc(&dev->mcg_table.alloc);
+ if (index == -1) {
+ mthca_err(dev, "No AMGM entries left\n");
+ err = -ENOMEM;
+ goto out;
+ }
+
+ err = mthca_READ_MGM(dev, index, mailbox);
+ if (err) {
+ mthca_err(dev, "READ_MGM failed (%d)\n", err);
+ goto out;
+ }
+ memset(mgm, 0, sizeof *mgm);
+ memcpy(mgm->gid, gid->raw, 16);
+ }
+
+ for (i = 0; i < MTHCA_QP_PER_MGM; ++i)
+ if (mgm->qp[i] == cpu_to_be32(ibqp->qp_num | (1 << 31))) {
+ mthca_dbg(dev, "QP %06x already a member of MGM\n",
+ ibqp->qp_num);
+ err = 0;
+ goto out;
+ } else if (!(mgm->qp[i] & cpu_to_be32(1 << 31))) {
+ mgm->qp[i] = cpu_to_be32(ibqp->qp_num | (1 << 31));
+ break;
+ }
+
+ if (i == MTHCA_QP_PER_MGM) {
+ mthca_err(dev, "MGM at index %x is full.\n", index);
+ err = -ENOMEM;
+ goto out;
+ }
+
+ err = mthca_WRITE_MGM(dev, index, mailbox);
+ if (err) {
+ mthca_err(dev, "WRITE_MGM failed %d\n", err);
+ err = -EINVAL;
+ goto out;
+ }
+
+ if (!link)
+ goto out;
+
+ err = mthca_READ_MGM(dev, prev, mailbox);
+ if (err) {
+ mthca_err(dev, "READ_MGM failed %d\n", err);
+ goto out;
+ }
+
+ mgm->next_gid_index = cpu_to_be32(index << 6);
+
+ err = mthca_WRITE_MGM(dev, prev, mailbox);
+ if (err)
+ mthca_err(dev, "WRITE_MGM returned %d\n", err);
+
+ out:
+ if (err && link && index != -1) {
+ BUG_ON(index < dev->limits.num_mgms);
+ mthca_free(&dev->mcg_table.alloc, index);
+ }
+ mutex_unlock(&dev->mcg_table.mutex);
+
+ mthca_free_mailbox(dev, mailbox);
+ return err;
+}
+
+int mthca_multicast_detach(struct ib_qp *ibqp, union ib_gid *gid, u16 lid)
+{
+ struct mthca_dev *dev = to_mdev(ibqp->device);
+ struct mthca_mailbox *mailbox;
+ struct mthca_mgm *mgm;
+ u16 hash;
+ int prev, index;
+ int i, loc;
+ int err;
+
+ mailbox = mthca_alloc_mailbox(dev, GFP_KERNEL);
+ if (IS_ERR(mailbox))
+ return PTR_ERR(mailbox);
+ mgm = mailbox->buf;
+
+ mutex_lock(&dev->mcg_table.mutex);
+
+ err = find_mgm(dev, gid->raw, mailbox, &hash, &prev, &index);
+ if (err)
+ goto out;
+
+ if (index == -1) {
+ mthca_err(dev, "MGID %pI6 not found\n", gid->raw);
+ err = -EINVAL;
+ goto out;
+ }
+
+ for (loc = -1, i = 0; i < MTHCA_QP_PER_MGM; ++i) {
+ if (mgm->qp[i] == cpu_to_be32(ibqp->qp_num | (1 << 31)))
+ loc = i;
+ if (!(mgm->qp[i] & cpu_to_be32(1 << 31)))
+ break;
+ }
+
+ if (loc == -1) {
+ mthca_err(dev, "QP %06x not found in MGM\n", ibqp->qp_num);
+ err = -EINVAL;
+ goto out;
+ }
+
+ mgm->qp[loc] = mgm->qp[i - 1];
+ mgm->qp[i - 1] = 0;
+
+ err = mthca_WRITE_MGM(dev, index, mailbox);
+ if (err) {
+ mthca_err(dev, "WRITE_MGM returned %d\n", err);
+ goto out;
+ }
+
+ if (i != 1)
+ goto out;
+
+ if (prev == -1) {
+ /* Remove entry from MGM */
+ int amgm_index_to_free = be32_to_cpu(mgm->next_gid_index) >> 6;
+ if (amgm_index_to_free) {
+ err = mthca_READ_MGM(dev, amgm_index_to_free,
+ mailbox);
+ if (err) {
+ mthca_err(dev, "READ_MGM returned %d\n", err);
+ goto out;
+ }
+ } else
+ memset(mgm->gid, 0, 16);
+
+ err = mthca_WRITE_MGM(dev, index, mailbox);
+ if (err) {
+ mthca_err(dev, "WRITE_MGM returned %d\n", err);
+ goto out;
+ }
+ if (amgm_index_to_free) {
+ BUG_ON(amgm_index_to_free < dev->limits.num_mgms);
+ mthca_free(&dev->mcg_table.alloc, amgm_index_to_free);
+ }
+ } else {
+ /* Remove entry from AMGM */
+ int curr_next_index = be32_to_cpu(mgm->next_gid_index) >> 6;
+ err = mthca_READ_MGM(dev, prev, mailbox);
+ if (err) {
+ mthca_err(dev, "READ_MGM returned %d\n", err);
+ goto out;
+ }
+
+ mgm->next_gid_index = cpu_to_be32(curr_next_index << 6);
+
+ err = mthca_WRITE_MGM(dev, prev, mailbox);
+ if (err) {
+ mthca_err(dev, "WRITE_MGM returned %d\n", err);
+ goto out;
+ }
+ BUG_ON(index < dev->limits.num_mgms);
+ mthca_free(&dev->mcg_table.alloc, index);
+ }
+
+ out:
+ mutex_unlock(&dev->mcg_table.mutex);
+
+ mthca_free_mailbox(dev, mailbox);
+ return err;
+}
+
+int mthca_init_mcg_table(struct mthca_dev *dev)
+{
+ int err;
+ int table_size = dev->limits.num_mgms + dev->limits.num_amgms;
+
+ err = mthca_alloc_init(&dev->mcg_table.alloc,
+ table_size,
+ table_size - 1,
+ dev->limits.num_mgms);
+ if (err)
+ return err;
+
+ mutex_init(&dev->mcg_table.mutex);
+
+ return 0;
+}
+
+void mthca_cleanup_mcg_table(struct mthca_dev *dev)
+{
+ mthca_alloc_cleanup(&dev->mcg_table.alloc);
+}
diff --git a/sys/dev/mthca/mthca_memfree.c b/sys/dev/mthca/mthca_memfree.c
new file mode 100644
index 0000000..79bc78a
--- /dev/null
+++ b/sys/dev/mthca/mthca_memfree.c
@@ -0,0 +1,758 @@
+/*
+ * Copyright (c) 2004, 2005 Topspin Communications. All rights reserved.
+ * Copyright (c) 2005 Cisco Systems. All rights reserved.
+ * Copyright (c) 2005 Mellanox Technologies. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#include <linux/mm.h>
+#include <linux/scatterlist.h>
+#include <linux/sched.h>
+#include <linux/slab.h>
+#include <linux/page.h>
+
+#include "mthca_memfree.h"
+#include "mthca_dev.h"
+#include "mthca_cmd.h"
+
+/*
+ * We allocate in as big chunks as we can, up to a maximum of 256 KB
+ * per chunk.
+ */
+enum {
+ MTHCA_ICM_ALLOC_SIZE = 1 << 18,
+ MTHCA_TABLE_CHUNK_SIZE = 1 << 18
+};
+
+struct mthca_user_db_table {
+ struct mutex mutex;
+ struct {
+ u64 uvirt;
+ struct scatterlist mem;
+ int refcount;
+ } page[0];
+};
+
+static void mthca_free_icm_pages(struct mthca_dev *dev, struct mthca_icm_chunk *chunk)
+{
+ int i;
+
+ if (chunk->nsg > 0)
+ pci_unmap_sg(dev->pdev, chunk->mem, chunk->npages,
+ PCI_DMA_BIDIRECTIONAL);
+
+ for (i = 0; i < chunk->npages; ++i)
+ __free_pages(sg_page(&chunk->mem[i]),
+ get_order(chunk->mem[i].length));
+}
+
+static void mthca_free_icm_coherent(struct mthca_dev *dev, struct mthca_icm_chunk *chunk)
+{
+ int i;
+
+ for (i = 0; i < chunk->npages; ++i) {
+ dma_free_coherent(&dev->pdev->dev, chunk->mem[i].length,
+ lowmem_page_address(sg_page(&chunk->mem[i])),
+ sg_dma_address(&chunk->mem[i]));
+ }
+}
+
+void mthca_free_icm(struct mthca_dev *dev, struct mthca_icm *icm, int coherent)
+{
+ struct mthca_icm_chunk *chunk, *tmp;
+
+ if (!icm)
+ return;
+
+ list_for_each_entry_safe(chunk, tmp, &icm->chunk_list, list) {
+ if (coherent)
+ mthca_free_icm_coherent(dev, chunk);
+ else
+ mthca_free_icm_pages(dev, chunk);
+
+ kfree(chunk);
+ }
+
+ kfree(icm);
+}
+
+static int mthca_alloc_icm_pages(struct scatterlist *mem, int order, gfp_t gfp_mask)
+{
+ struct page *page;
+
+ /*
+ * Use __GFP_ZERO because buggy firmware assumes ICM pages are
+ * cleared, and subtle failures are seen if they aren't.
+ */
+ page = alloc_pages(gfp_mask | __GFP_ZERO, order);
+ if (!page)
+ return -ENOMEM;
+
+ sg_set_page(mem, page, PAGE_SIZE << order, 0);
+ return 0;
+}
+
+static int mthca_alloc_icm_coherent(struct device *dev, struct scatterlist *mem,
+ int order, gfp_t gfp_mask)
+{
+ void *buf = dma_alloc_coherent(dev, PAGE_SIZE << order, &sg_dma_address(mem),
+ gfp_mask);
+ if (!buf)
+ return -ENOMEM;
+
+ sg_set_buf(mem, buf, PAGE_SIZE << order);
+ BUG_ON(mem->offset);
+ sg_dma_len(mem) = PAGE_SIZE << order;
+ return 0;
+}
+
+struct mthca_icm *mthca_alloc_icm(struct mthca_dev *dev, int npages,
+ gfp_t gfp_mask, int coherent)
+{
+ struct mthca_icm *icm;
+ struct mthca_icm_chunk *chunk = NULL;
+ int cur_order;
+ int ret;
+
+ /* We use sg_set_buf for coherent allocs, which assumes low memory */
+ BUG_ON(coherent && (gfp_mask & __GFP_HIGHMEM));
+
+ icm = kmalloc(sizeof *icm, gfp_mask & ~(__GFP_HIGHMEM | __GFP_NOWARN));
+ if (!icm)
+ return icm;
+
+ icm->refcount = 0;
+ INIT_LIST_HEAD(&icm->chunk_list);
+
+ cur_order = get_order(MTHCA_ICM_ALLOC_SIZE);
+
+ while (npages > 0) {
+ if (!chunk) {
+ chunk = kmalloc(sizeof *chunk,
+ gfp_mask & ~(__GFP_HIGHMEM | __GFP_NOWARN));
+ if (!chunk)
+ goto fail;
+
+ sg_init_table(chunk->mem, MTHCA_ICM_CHUNK_LEN);
+ chunk->npages = 0;
+ chunk->nsg = 0;
+ list_add_tail(&chunk->list, &icm->chunk_list);
+ }
+
+ while (1 << cur_order > npages)
+ --cur_order;
+
+ if (coherent)
+ ret = mthca_alloc_icm_coherent(&dev->pdev->dev,
+ &chunk->mem[chunk->npages],
+ cur_order, gfp_mask);
+ else
+ ret = mthca_alloc_icm_pages(&chunk->mem[chunk->npages],
+ cur_order, gfp_mask);
+
+ if (!ret) {
+ ++chunk->npages;
+
+ if (coherent)
+ ++chunk->nsg;
+ else if (chunk->npages == MTHCA_ICM_CHUNK_LEN) {
+ chunk->nsg = pci_map_sg(dev->pdev, chunk->mem,
+ chunk->npages,
+ PCI_DMA_BIDIRECTIONAL);
+
+ if (chunk->nsg <= 0)
+ goto fail;
+ }
+
+ if (chunk->npages == MTHCA_ICM_CHUNK_LEN)
+ chunk = NULL;
+
+ npages -= 1 << cur_order;
+ } else {
+ --cur_order;
+ if (cur_order < 0)
+ goto fail;
+ }
+ }
+
+ if (!coherent && chunk) {
+ chunk->nsg = pci_map_sg(dev->pdev, chunk->mem,
+ chunk->npages,
+ PCI_DMA_BIDIRECTIONAL);
+
+ if (chunk->nsg <= 0)
+ goto fail;
+ }
+
+ return icm;
+
+fail:
+ mthca_free_icm(dev, icm, coherent);
+ return NULL;
+}
+
+int mthca_table_get(struct mthca_dev *dev, struct mthca_icm_table *table, int obj)
+{
+ int i = (obj & (table->num_obj - 1)) * table->obj_size / MTHCA_TABLE_CHUNK_SIZE;
+ int ret = 0;
+
+ mutex_lock(&table->mutex);
+
+ if (table->icm[i]) {
+ ++table->icm[i]->refcount;
+ goto out;
+ }
+
+ table->icm[i] = mthca_alloc_icm(dev, MTHCA_TABLE_CHUNK_SIZE >> PAGE_SHIFT,
+ (table->lowmem ? GFP_KERNEL : GFP_HIGHUSER) |
+ __GFP_NOWARN, table->coherent);
+ if (!table->icm[i]) {
+ ret = -ENOMEM;
+ goto out;
+ }
+
+ if (mthca_MAP_ICM(dev, table->icm[i],
+ table->virt + i * MTHCA_TABLE_CHUNK_SIZE)) {
+ mthca_free_icm(dev, table->icm[i], table->coherent);
+ table->icm[i] = NULL;
+ ret = -ENOMEM;
+ goto out;
+ }
+
+ ++table->icm[i]->refcount;
+
+out:
+ mutex_unlock(&table->mutex);
+ return ret;
+}
+
+void mthca_table_put(struct mthca_dev *dev, struct mthca_icm_table *table, int obj)
+{
+ int i;
+
+ if (!mthca_is_memfree(dev))
+ return;
+
+ i = (obj & (table->num_obj - 1)) * table->obj_size / MTHCA_TABLE_CHUNK_SIZE;
+
+ mutex_lock(&table->mutex);
+
+ if (--table->icm[i]->refcount == 0) {
+ mthca_UNMAP_ICM(dev, table->virt + i * MTHCA_TABLE_CHUNK_SIZE,
+ MTHCA_TABLE_CHUNK_SIZE / MTHCA_ICM_PAGE_SIZE);
+ mthca_free_icm(dev, table->icm[i], table->coherent);
+ table->icm[i] = NULL;
+ }
+
+ mutex_unlock(&table->mutex);
+}
+
+void *mthca_table_find(struct mthca_icm_table *table, int obj, dma_addr_t *dma_handle)
+{
+ int idx, offset, dma_offset, i;
+ struct mthca_icm_chunk *chunk;
+ struct mthca_icm *icm;
+ struct page *page = NULL;
+
+ if (!table->lowmem)
+ return NULL;
+
+ mutex_lock(&table->mutex);
+
+ idx = (obj & (table->num_obj - 1)) * table->obj_size;
+ icm = table->icm[idx / MTHCA_TABLE_CHUNK_SIZE];
+ dma_offset = offset = idx % MTHCA_TABLE_CHUNK_SIZE;
+
+ if (!icm)
+ goto out;
+
+ list_for_each_entry(chunk, &icm->chunk_list, list) {
+ for (i = 0; i < chunk->npages; ++i) {
+ if (dma_handle && dma_offset >= 0) {
+ if (sg_dma_len(&chunk->mem[i]) > dma_offset)
+ *dma_handle = sg_dma_address(&chunk->mem[i]) +
+ dma_offset;
+ dma_offset -= sg_dma_len(&chunk->mem[i]);
+ }
+ /* DMA mapping can merge pages but not split them,
+ * so if we found the page, dma_handle has already
+ * been assigned to. */
+ if (chunk->mem[i].length > offset) {
+ page = sg_page(&chunk->mem[i]);
+ goto out;
+ }
+ offset -= chunk->mem[i].length;
+ }
+ }
+
+out:
+ mutex_unlock(&table->mutex);
+ return page ? lowmem_page_address(page) + offset : NULL;
+}
+
+int mthca_table_get_range(struct mthca_dev *dev, struct mthca_icm_table *table,
+ int start, int end)
+{
+ int inc = MTHCA_TABLE_CHUNK_SIZE / table->obj_size;
+ int i, err;
+
+ for (i = start; i <= end; i += inc) {
+ err = mthca_table_get(dev, table, i);
+ if (err)
+ goto fail;
+ }
+
+ return 0;
+
+fail:
+ while (i > start) {
+ i -= inc;
+ mthca_table_put(dev, table, i);
+ }
+
+ return err;
+}
+
+void mthca_table_put_range(struct mthca_dev *dev, struct mthca_icm_table *table,
+ int start, int end)
+{
+ int i;
+
+ if (!mthca_is_memfree(dev))
+ return;
+
+ for (i = start; i <= end; i += MTHCA_TABLE_CHUNK_SIZE / table->obj_size)
+ mthca_table_put(dev, table, i);
+}
+
+struct mthca_icm_table *mthca_alloc_icm_table(struct mthca_dev *dev,
+ u64 virt, int obj_size,
+ int nobj, int reserved,
+ int use_lowmem, int use_coherent)
+{
+ struct mthca_icm_table *table;
+ int obj_per_chunk;
+ int num_icm;
+ unsigned chunk_size;
+ int i;
+
+ obj_per_chunk = MTHCA_TABLE_CHUNK_SIZE / obj_size;
+ num_icm = DIV_ROUND_UP(nobj, obj_per_chunk);
+
+ table = kmalloc(sizeof *table + num_icm * sizeof *table->icm, GFP_KERNEL);
+ if (!table)
+ return NULL;
+
+ table->virt = virt;
+ table->num_icm = num_icm;
+ table->num_obj = nobj;
+ table->obj_size = obj_size;
+ table->lowmem = use_lowmem;
+ table->coherent = use_coherent;
+ mutex_init(&table->mutex);
+
+ for (i = 0; i < num_icm; ++i)
+ table->icm[i] = NULL;
+
+ for (i = 0; i * MTHCA_TABLE_CHUNK_SIZE < reserved * obj_size; ++i) {
+ chunk_size = MTHCA_TABLE_CHUNK_SIZE;
+ if ((i + 1) * MTHCA_TABLE_CHUNK_SIZE > nobj * obj_size)
+ chunk_size = nobj * obj_size - i * MTHCA_TABLE_CHUNK_SIZE;
+
+ table->icm[i] = mthca_alloc_icm(dev, chunk_size >> PAGE_SHIFT,
+ (use_lowmem ? GFP_KERNEL : GFP_HIGHUSER) |
+ __GFP_NOWARN, use_coherent);
+ if (!table->icm[i])
+ goto err;
+ if (mthca_MAP_ICM(dev, table->icm[i],
+ virt + i * MTHCA_TABLE_CHUNK_SIZE)) {
+ mthca_free_icm(dev, table->icm[i], table->coherent);
+ table->icm[i] = NULL;
+ goto err;
+ }
+
+ /*
+ * Add a reference to this ICM chunk so that it never
+ * gets freed (since it contains reserved firmware objects).
+ */
+ ++table->icm[i]->refcount;
+ }
+
+ return table;
+
+err:
+ for (i = 0; i < num_icm; ++i)
+ if (table->icm[i]) {
+ mthca_UNMAP_ICM(dev, virt + i * MTHCA_TABLE_CHUNK_SIZE,
+ MTHCA_TABLE_CHUNK_SIZE / MTHCA_ICM_PAGE_SIZE);
+ mthca_free_icm(dev, table->icm[i], table->coherent);
+ }
+
+ kfree(table);
+
+ return NULL;
+}
+
+void mthca_free_icm_table(struct mthca_dev *dev, struct mthca_icm_table *table)
+{
+ int i;
+
+ for (i = 0; i < table->num_icm; ++i)
+ if (table->icm[i]) {
+ mthca_UNMAP_ICM(dev,
+ table->virt + i * MTHCA_TABLE_CHUNK_SIZE,
+ MTHCA_TABLE_CHUNK_SIZE / MTHCA_ICM_PAGE_SIZE);
+ mthca_free_icm(dev, table->icm[i], table->coherent);
+ }
+
+ kfree(table);
+}
+
+static u64 mthca_uarc_virt(struct mthca_dev *dev, struct mthca_uar *uar, int page)
+{
+ return dev->uar_table.uarc_base +
+ uar->index * dev->uar_table.uarc_size +
+ page * MTHCA_ICM_PAGE_SIZE;
+}
+
+int mthca_map_user_db(struct mthca_dev *dev, struct mthca_uar *uar,
+ struct mthca_user_db_table *db_tab, int index, u64 uaddr)
+{
+ struct page *pages[1];
+ int ret = 0;
+ int i;
+
+ if (!mthca_is_memfree(dev))
+ return 0;
+
+ if (index < 0 || index > dev->uar_table.uarc_size / 8)
+ return -EINVAL;
+
+ mutex_lock(&db_tab->mutex);
+
+ i = index / MTHCA_DB_REC_PER_PAGE;
+
+ if ((db_tab->page[i].refcount >= MTHCA_DB_REC_PER_PAGE) ||
+ (db_tab->page[i].uvirt && db_tab->page[i].uvirt != uaddr) ||
+ (uaddr & 4095)) {
+ ret = -EINVAL;
+ goto out;
+ }
+
+ if (db_tab->page[i].refcount) {
+ ++db_tab->page[i].refcount;
+ goto out;
+ }
+
+ ret = get_user_pages(uaddr & PAGE_MASK, 1, FOLL_WRITE, pages, NULL);
+ if (ret < 0)
+ goto out;
+
+ sg_set_page(&db_tab->page[i].mem, pages[0], MTHCA_ICM_PAGE_SIZE,
+ uaddr & ~PAGE_MASK);
+
+ ret = pci_map_sg(dev->pdev, &db_tab->page[i].mem, 1, PCI_DMA_TODEVICE);
+ if (ret < 0) {
+ put_page(pages[0]);
+ goto out;
+ }
+
+ ret = mthca_MAP_ICM_page(dev, sg_dma_address(&db_tab->page[i].mem),
+ mthca_uarc_virt(dev, uar, i));
+ if (ret) {
+ pci_unmap_sg(dev->pdev, &db_tab->page[i].mem, 1, PCI_DMA_TODEVICE);
+ put_page(sg_page(&db_tab->page[i].mem));
+ goto out;
+ }
+
+ db_tab->page[i].uvirt = uaddr;
+ db_tab->page[i].refcount = 1;
+
+out:
+ mutex_unlock(&db_tab->mutex);
+ return ret;
+}
+
+void mthca_unmap_user_db(struct mthca_dev *dev, struct mthca_uar *uar,
+ struct mthca_user_db_table *db_tab, int index)
+{
+ if (!mthca_is_memfree(dev))
+ return;
+
+ /*
+ * To make our bookkeeping simpler, we don't unmap DB
+ * pages until we clean up the whole db table.
+ */
+
+ mutex_lock(&db_tab->mutex);
+
+ --db_tab->page[index / MTHCA_DB_REC_PER_PAGE].refcount;
+
+ mutex_unlock(&db_tab->mutex);
+}
+
+struct mthca_user_db_table *mthca_init_user_db_tab(struct mthca_dev *dev)
+{
+ struct mthca_user_db_table *db_tab;
+ int npages;
+ int i;
+
+ if (!mthca_is_memfree(dev))
+ return NULL;
+
+ npages = dev->uar_table.uarc_size / MTHCA_ICM_PAGE_SIZE;
+ db_tab = kmalloc(sizeof *db_tab + npages * sizeof *db_tab->page, GFP_KERNEL);
+ if (!db_tab)
+ return ERR_PTR(-ENOMEM);
+
+ mutex_init(&db_tab->mutex);
+ for (i = 0; i < npages; ++i) {
+ db_tab->page[i].refcount = 0;
+ db_tab->page[i].uvirt = 0;
+ sg_init_table(&db_tab->page[i].mem, 1);
+ }
+
+ return db_tab;
+}
+
+void mthca_cleanup_user_db_tab(struct mthca_dev *dev, struct mthca_uar *uar,
+ struct mthca_user_db_table *db_tab)
+{
+ int i;
+
+ if (!mthca_is_memfree(dev))
+ return;
+
+ for (i = 0; i < dev->uar_table.uarc_size / MTHCA_ICM_PAGE_SIZE; ++i) {
+ if (db_tab->page[i].uvirt) {
+ mthca_UNMAP_ICM(dev, mthca_uarc_virt(dev, uar, i), 1);
+ pci_unmap_sg(dev->pdev, &db_tab->page[i].mem, 1, PCI_DMA_TODEVICE);
+ put_page(sg_page(&db_tab->page[i].mem));
+ }
+ }
+
+ kfree(db_tab);
+}
+
+int mthca_alloc_db(struct mthca_dev *dev, enum mthca_db_type type,
+ u32 qn, __be32 **db)
+{
+ int group;
+ int start, end, dir;
+ int i, j;
+ struct mthca_db_page *page;
+ int ret = 0;
+
+ mutex_lock(&dev->db_tab->mutex);
+
+ switch (type) {
+ case MTHCA_DB_TYPE_CQ_ARM:
+ case MTHCA_DB_TYPE_SQ:
+ group = 0;
+ start = 0;
+ end = dev->db_tab->max_group1;
+ dir = 1;
+ break;
+
+ case MTHCA_DB_TYPE_CQ_SET_CI:
+ case MTHCA_DB_TYPE_RQ:
+ case MTHCA_DB_TYPE_SRQ:
+ group = 1;
+ start = dev->db_tab->npages - 1;
+ end = dev->db_tab->min_group2;
+ dir = -1;
+ break;
+
+ default:
+ ret = -EINVAL;
+ goto out;
+ }
+
+ for (i = start; i != end; i += dir)
+ if (dev->db_tab->page[i].db_rec &&
+ !bitmap_full(dev->db_tab->page[i].used,
+ MTHCA_DB_REC_PER_PAGE)) {
+ page = dev->db_tab->page + i;
+ goto found;
+ }
+
+ for (i = start; i != end; i += dir)
+ if (!dev->db_tab->page[i].db_rec) {
+ page = dev->db_tab->page + i;
+ goto alloc;
+ }
+
+ if (dev->db_tab->max_group1 >= dev->db_tab->min_group2 - 1) {
+ ret = -ENOMEM;
+ goto out;
+ }
+
+ if (group == 0)
+ ++dev->db_tab->max_group1;
+ else
+ --dev->db_tab->min_group2;
+
+ page = dev->db_tab->page + end;
+
+alloc:
+ page->db_rec = dma_alloc_coherent(&dev->pdev->dev, MTHCA_ICM_PAGE_SIZE,
+ &page->mapping, GFP_KERNEL);
+ if (!page->db_rec) {
+ ret = -ENOMEM;
+ goto out;
+ }
+ memset(page->db_rec, 0, MTHCA_ICM_PAGE_SIZE);
+
+ ret = mthca_MAP_ICM_page(dev, page->mapping,
+ mthca_uarc_virt(dev, &dev->driver_uar, i));
+ if (ret) {
+ dma_free_coherent(&dev->pdev->dev, MTHCA_ICM_PAGE_SIZE,
+ page->db_rec, page->mapping);
+ goto out;
+ }
+
+ bitmap_zero(page->used, MTHCA_DB_REC_PER_PAGE);
+
+found:
+ j = find_first_zero_bit(page->used, MTHCA_DB_REC_PER_PAGE);
+ set_bit(j, page->used);
+
+ if (group == 1)
+ j = MTHCA_DB_REC_PER_PAGE - 1 - j;
+
+ ret = i * MTHCA_DB_REC_PER_PAGE + j;
+
+ page->db_rec[j] = cpu_to_be64((qn << 8) | (type << 5));
+
+ *db = (__be32 *) &page->db_rec[j];
+
+out:
+ mutex_unlock(&dev->db_tab->mutex);
+
+ return ret;
+}
+
+void mthca_free_db(struct mthca_dev *dev, int type, int db_index)
+{
+ int i, j;
+ struct mthca_db_page *page;
+
+ i = db_index / MTHCA_DB_REC_PER_PAGE;
+ j = db_index % MTHCA_DB_REC_PER_PAGE;
+
+ page = dev->db_tab->page + i;
+
+ mutex_lock(&dev->db_tab->mutex);
+
+ page->db_rec[j] = 0;
+ if (i >= dev->db_tab->min_group2)
+ j = MTHCA_DB_REC_PER_PAGE - 1 - j;
+ clear_bit(j, page->used);
+
+ if (bitmap_empty(page->used, MTHCA_DB_REC_PER_PAGE) &&
+ i >= dev->db_tab->max_group1 - 1) {
+ mthca_UNMAP_ICM(dev, mthca_uarc_virt(dev, &dev->driver_uar, i), 1);
+
+ dma_free_coherent(&dev->pdev->dev, MTHCA_ICM_PAGE_SIZE,
+ page->db_rec, page->mapping);
+ page->db_rec = NULL;
+
+ if (i == dev->db_tab->max_group1) {
+ --dev->db_tab->max_group1;
+ /* XXX may be able to unmap more pages now */
+ }
+ if (i == dev->db_tab->min_group2)
+ ++dev->db_tab->min_group2;
+ }
+
+ mutex_unlock(&dev->db_tab->mutex);
+}
+
+int mthca_init_db_tab(struct mthca_dev *dev)
+{
+ int i;
+
+ if (!mthca_is_memfree(dev))
+ return 0;
+
+ dev->db_tab = kmalloc(sizeof *dev->db_tab, GFP_KERNEL);
+ if (!dev->db_tab)
+ return -ENOMEM;
+
+ mutex_init(&dev->db_tab->mutex);
+
+ dev->db_tab->npages = dev->uar_table.uarc_size / MTHCA_ICM_PAGE_SIZE;
+ dev->db_tab->max_group1 = 0;
+ dev->db_tab->min_group2 = dev->db_tab->npages - 1;
+
+ dev->db_tab->page = kmalloc(dev->db_tab->npages *
+ sizeof *dev->db_tab->page,
+ GFP_KERNEL);
+ if (!dev->db_tab->page) {
+ kfree(dev->db_tab);
+ return -ENOMEM;
+ }
+
+ for (i = 0; i < dev->db_tab->npages; ++i)
+ dev->db_tab->page[i].db_rec = NULL;
+
+ return 0;
+}
+
+void mthca_cleanup_db_tab(struct mthca_dev *dev)
+{
+ int i;
+
+ if (!mthca_is_memfree(dev))
+ return;
+
+ /*
+ * Because we don't always free our UARC pages when they
+ * become empty to make mthca_free_db() simpler we need to
+ * make a sweep through the doorbell pages and free any
+ * leftover pages now.
+ */
+ for (i = 0; i < dev->db_tab->npages; ++i) {
+ if (!dev->db_tab->page[i].db_rec)
+ continue;
+
+ if (!bitmap_empty(dev->db_tab->page[i].used, MTHCA_DB_REC_PER_PAGE))
+ mthca_warn(dev, "Kernel UARC page %d not empty\n", i);
+
+ mthca_UNMAP_ICM(dev, mthca_uarc_virt(dev, &dev->driver_uar, i), 1);
+
+ dma_free_coherent(&dev->pdev->dev, MTHCA_ICM_PAGE_SIZE,
+ dev->db_tab->page[i].db_rec,
+ dev->db_tab->page[i].mapping);
+ }
+
+ kfree(dev->db_tab->page);
+ kfree(dev->db_tab);
+}
diff --git a/sys/ofed/drivers/infiniband/hw/mthca/mthca_memfree.h b/sys/dev/mthca/mthca_memfree.h
index da9b8f9..da9b8f9 100644
--- a/sys/ofed/drivers/infiniband/hw/mthca/mthca_memfree.h
+++ b/sys/dev/mthca/mthca_memfree.h
diff --git a/sys/dev/mthca/mthca_mr.c b/sys/dev/mthca/mthca_mr.c
new file mode 100644
index 0000000..ed9a989
--- /dev/null
+++ b/sys/dev/mthca/mthca_mr.c
@@ -0,0 +1,965 @@
+/*
+ * Copyright (c) 2004 Topspin Communications. All rights reserved.
+ * Copyright (c) 2005 Mellanox Technologies. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#include <linux/slab.h>
+#include <linux/errno.h>
+
+#include "mthca_dev.h"
+#include "mthca_cmd.h"
+#include "mthca_memfree.h"
+
+struct mthca_mtt {
+ struct mthca_buddy *buddy;
+ int order;
+ u32 first_seg;
+};
+
+/*
+ * Must be packed because mtt_seg is 64 bits but only aligned to 32 bits.
+ */
+struct mthca_mpt_entry {
+ __be32 flags;
+ __be32 page_size;
+ __be32 key;
+ __be32 pd;
+ __be64 start;
+ __be64 length;
+ __be32 lkey;
+ __be32 window_count;
+ __be32 window_count_limit;
+ __be64 mtt_seg;
+ __be32 mtt_sz; /* Arbel only */
+ u32 reserved[2];
+} __attribute__((packed));
+
+#define MTHCA_MPT_FLAG_SW_OWNS (0xfUL << 28)
+#define MTHCA_MPT_FLAG_MIO (1 << 17)
+#define MTHCA_MPT_FLAG_BIND_ENABLE (1 << 15)
+#define MTHCA_MPT_FLAG_PHYSICAL (1 << 9)
+#define MTHCA_MPT_FLAG_REGION (1 << 8)
+
+#define MTHCA_MTT_FLAG_PRESENT 1
+
+#define MTHCA_MPT_STATUS_SW 0xF0
+#define MTHCA_MPT_STATUS_HW 0x00
+
+#define SINAI_FMR_KEY_INC 0x1000000
+
+/*
+ * Buddy allocator for MTT segments (currently not very efficient
+ * since it doesn't keep a free list and just searches linearly
+ * through the bitmaps)
+ */
+
+static u32 mthca_buddy_alloc(struct mthca_buddy *buddy, int order)
+{
+ int o;
+ int m;
+ u32 seg;
+
+ spin_lock(&buddy->lock);
+
+ for (o = order; o <= buddy->max_order; ++o)
+ if (buddy->num_free[o]) {
+ m = 1 << (buddy->max_order - o);
+ seg = find_first_bit(buddy->bits[o], m);
+ if (seg < m)
+ goto found;
+ }
+
+ spin_unlock(&buddy->lock);
+ return -1;
+
+ found:
+ clear_bit(seg, buddy->bits[o]);
+ --buddy->num_free[o];
+
+ while (o > order) {
+ --o;
+ seg <<= 1;
+ set_bit(seg ^ 1, buddy->bits[o]);
+ ++buddy->num_free[o];
+ }
+
+ spin_unlock(&buddy->lock);
+
+ seg <<= order;
+
+ return seg;
+}
+
+static void mthca_buddy_free(struct mthca_buddy *buddy, u32 seg, int order)
+{
+ seg >>= order;
+
+ spin_lock(&buddy->lock);
+
+ while (test_bit(seg ^ 1, buddy->bits[order])) {
+ clear_bit(seg ^ 1, buddy->bits[order]);
+ --buddy->num_free[order];
+ seg >>= 1;
+ ++order;
+ }
+
+ set_bit(seg, buddy->bits[order]);
+ ++buddy->num_free[order];
+
+ spin_unlock(&buddy->lock);
+}
+
+static int mthca_buddy_init(struct mthca_buddy *buddy, int max_order)
+{
+ int i, s;
+
+ buddy->max_order = max_order;
+ spin_lock_init(&buddy->lock);
+
+ buddy->bits = kzalloc((buddy->max_order + 1) * sizeof (long *),
+ GFP_KERNEL);
+ buddy->num_free = kcalloc((buddy->max_order + 1), sizeof *buddy->num_free,
+ GFP_KERNEL);
+ if (!buddy->bits || !buddy->num_free)
+ goto err_out;
+
+ for (i = 0; i <= buddy->max_order; ++i) {
+ s = BITS_TO_LONGS(1 << (buddy->max_order - i));
+ buddy->bits[i] = kmalloc(s * sizeof (long), GFP_KERNEL);
+ if (!buddy->bits[i])
+ goto err_out_free;
+ bitmap_zero(buddy->bits[i],
+ 1 << (buddy->max_order - i));
+ }
+
+ set_bit(0, buddy->bits[buddy->max_order]);
+ buddy->num_free[buddy->max_order] = 1;
+
+ return 0;
+
+err_out_free:
+ for (i = 0; i <= buddy->max_order; ++i)
+ kfree(buddy->bits[i]);
+
+err_out:
+ kfree(buddy->bits);
+ kfree(buddy->num_free);
+
+ return -ENOMEM;
+}
+
+static void mthca_buddy_cleanup(struct mthca_buddy *buddy)
+{
+ int i;
+
+ for (i = 0; i <= buddy->max_order; ++i)
+ kfree(buddy->bits[i]);
+
+ kfree(buddy->bits);
+ kfree(buddy->num_free);
+}
+
+static u32 mthca_alloc_mtt_range(struct mthca_dev *dev, int order,
+ struct mthca_buddy *buddy)
+{
+ u32 seg = mthca_buddy_alloc(buddy, order);
+
+ if (seg == -1)
+ return -1;
+
+ if (mthca_is_memfree(dev))
+ if (mthca_table_get_range(dev, dev->mr_table.mtt_table, seg,
+ seg + (1 << order) - 1)) {
+ mthca_buddy_free(buddy, seg, order);
+ seg = -1;
+ }
+
+ return seg;
+}
+
+static struct mthca_mtt *__mthca_alloc_mtt(struct mthca_dev *dev, int size,
+ struct mthca_buddy *buddy)
+{
+ struct mthca_mtt *mtt;
+ int i;
+
+ if (size <= 0)
+ return ERR_PTR(-EINVAL);
+
+ mtt = kmalloc(sizeof *mtt, GFP_KERNEL);
+ if (!mtt)
+ return ERR_PTR(-ENOMEM);
+
+ mtt->buddy = buddy;
+ mtt->order = 0;
+ for (i = dev->limits.mtt_seg_size / 8; i < size; i <<= 1)
+ ++mtt->order;
+
+ mtt->first_seg = mthca_alloc_mtt_range(dev, mtt->order, buddy);
+ if (mtt->first_seg == -1) {
+ kfree(mtt);
+ return ERR_PTR(-ENOMEM);
+ }
+
+ return mtt;
+}
+
+struct mthca_mtt *mthca_alloc_mtt(struct mthca_dev *dev, int size)
+{
+ return __mthca_alloc_mtt(dev, size, &dev->mr_table.mtt_buddy);
+}
+
+void mthca_free_mtt(struct mthca_dev *dev, struct mthca_mtt *mtt)
+{
+ if (!mtt)
+ return;
+
+ mthca_buddy_free(mtt->buddy, mtt->first_seg, mtt->order);
+
+ mthca_table_put_range(dev, dev->mr_table.mtt_table,
+ mtt->first_seg,
+ mtt->first_seg + (1 << mtt->order) - 1);
+
+ kfree(mtt);
+}
+
+static int __mthca_write_mtt(struct mthca_dev *dev, struct mthca_mtt *mtt,
+ int start_index, u64 *buffer_list, int list_len)
+{
+ struct mthca_mailbox *mailbox;
+ __be64 *mtt_entry;
+ int err = 0;
+ int i;
+
+ mailbox = mthca_alloc_mailbox(dev, GFP_KERNEL);
+ if (IS_ERR(mailbox))
+ return PTR_ERR(mailbox);
+ mtt_entry = mailbox->buf;
+
+ while (list_len > 0) {
+ mtt_entry[0] = cpu_to_be64(dev->mr_table.mtt_base +
+ mtt->first_seg * dev->limits.mtt_seg_size +
+ start_index * 8);
+ mtt_entry[1] = 0;
+ for (i = 0; i < list_len && i < MTHCA_MAILBOX_SIZE / 8 - 2; ++i)
+ mtt_entry[i + 2] = cpu_to_be64(buffer_list[i] |
+ MTHCA_MTT_FLAG_PRESENT);
+
+ /*
+ * If we have an odd number of entries to write, add
+ * one more dummy entry for firmware efficiency.
+ */
+ if (i & 1)
+ mtt_entry[i + 2] = 0;
+
+ err = mthca_WRITE_MTT(dev, mailbox, (i + 1) & ~1);
+ if (err) {
+ mthca_warn(dev, "WRITE_MTT failed (%d)\n", err);
+ goto out;
+ }
+
+ list_len -= i;
+ start_index += i;
+ buffer_list += i;
+ }
+
+out:
+ mthca_free_mailbox(dev, mailbox);
+ return err;
+}
+
+int mthca_write_mtt_size(struct mthca_dev *dev)
+{
+ if (dev->mr_table.fmr_mtt_buddy != &dev->mr_table.mtt_buddy ||
+ !(dev->mthca_flags & MTHCA_FLAG_FMR))
+ /*
+ * Be friendly to WRITE_MTT command
+ * and leave two empty slots for the
+ * index and reserved fields of the
+ * mailbox.
+ */
+ return PAGE_SIZE / sizeof (u64) - 2;
+
+ /* For Arbel, all MTTs must fit in the same page. */
+ return mthca_is_memfree(dev) ? (PAGE_SIZE / sizeof (u64)) : 0x7ffffff;
+}
+
+static void mthca_tavor_write_mtt_seg(struct mthca_dev *dev,
+ struct mthca_mtt *mtt, int start_index,
+ u64 *buffer_list, int list_len)
+{
+ u64 __iomem *mtts;
+ int i;
+
+ mtts = dev->mr_table.tavor_fmr.mtt_base + mtt->first_seg * dev->limits.mtt_seg_size +
+ start_index * sizeof (u64);
+ for (i = 0; i < list_len; ++i)
+ mthca_write64_raw(cpu_to_be64(buffer_list[i] | MTHCA_MTT_FLAG_PRESENT),
+ mtts + i);
+}
+
+static void mthca_arbel_write_mtt_seg(struct mthca_dev *dev,
+ struct mthca_mtt *mtt, int start_index,
+ u64 *buffer_list, int list_len)
+{
+ __be64 *mtts;
+ dma_addr_t dma_handle;
+ int i;
+ int s = start_index * sizeof (u64);
+
+ /* For Arbel, all MTTs must fit in the same page. */
+ BUG_ON(s / PAGE_SIZE != (s + list_len * sizeof(u64) - 1) / PAGE_SIZE);
+ /* Require full segments */
+ BUG_ON(s % dev->limits.mtt_seg_size);
+
+ mtts = mthca_table_find(dev->mr_table.mtt_table, mtt->first_seg +
+ s / dev->limits.mtt_seg_size, &dma_handle);
+
+ BUG_ON(!mtts);
+
+ dma_sync_single_for_cpu(&dev->pdev->dev, dma_handle,
+ list_len * sizeof (u64), DMA_TO_DEVICE);
+
+ for (i = 0; i < list_len; ++i)
+ mtts[i] = cpu_to_be64(buffer_list[i] | MTHCA_MTT_FLAG_PRESENT);
+
+ dma_sync_single_for_device(&dev->pdev->dev, dma_handle,
+ list_len * sizeof (u64), DMA_TO_DEVICE);
+}
+
+int mthca_write_mtt(struct mthca_dev *dev, struct mthca_mtt *mtt,
+ int start_index, u64 *buffer_list, int list_len)
+{
+ int size = mthca_write_mtt_size(dev);
+ int chunk;
+
+ if (dev->mr_table.fmr_mtt_buddy != &dev->mr_table.mtt_buddy ||
+ !(dev->mthca_flags & MTHCA_FLAG_FMR))
+ return __mthca_write_mtt(dev, mtt, start_index, buffer_list, list_len);
+
+ while (list_len > 0) {
+ chunk = min(size, list_len);
+ if (mthca_is_memfree(dev))
+ mthca_arbel_write_mtt_seg(dev, mtt, start_index,
+ buffer_list, chunk);
+ else
+ mthca_tavor_write_mtt_seg(dev, mtt, start_index,
+ buffer_list, chunk);
+
+ list_len -= chunk;
+ start_index += chunk;
+ buffer_list += chunk;
+ }
+
+ return 0;
+}
+
+static inline u32 tavor_hw_index_to_key(u32 ind)
+{
+ return ind;
+}
+
+static inline u32 tavor_key_to_hw_index(u32 key)
+{
+ return key;
+}
+
+static inline u32 arbel_hw_index_to_key(u32 ind)
+{
+ return (ind >> 24) | (ind << 8);
+}
+
+static inline u32 arbel_key_to_hw_index(u32 key)
+{
+ return (key << 24) | (key >> 8);
+}
+
+static inline u32 hw_index_to_key(struct mthca_dev *dev, u32 ind)
+{
+ if (mthca_is_memfree(dev))
+ return arbel_hw_index_to_key(ind);
+ else
+ return tavor_hw_index_to_key(ind);
+}
+
+static inline u32 key_to_hw_index(struct mthca_dev *dev, u32 key)
+{
+ if (mthca_is_memfree(dev))
+ return arbel_key_to_hw_index(key);
+ else
+ return tavor_key_to_hw_index(key);
+}
+
+static inline u32 adjust_key(struct mthca_dev *dev, u32 key)
+{
+ if (dev->mthca_flags & MTHCA_FLAG_SINAI_OPT)
+ return ((key << 20) & 0x800000) | (key & 0x7fffff);
+ else
+ return key;
+}
+
+int mthca_mr_alloc(struct mthca_dev *dev, u32 pd, int buffer_size_shift,
+ u64 iova, u64 total_size, u32 access, struct mthca_mr *mr)
+{
+ struct mthca_mailbox *mailbox;
+ struct mthca_mpt_entry *mpt_entry;
+ u32 key;
+ int i;
+ int err;
+
+ WARN_ON(buffer_size_shift >= 32);
+
+ key = mthca_alloc(&dev->mr_table.mpt_alloc);
+ if (key == -1)
+ return -ENOMEM;
+ key = adjust_key(dev, key);
+ mr->ibmr.rkey = mr->ibmr.lkey = hw_index_to_key(dev, key);
+
+ if (mthca_is_memfree(dev)) {
+ err = mthca_table_get(dev, dev->mr_table.mpt_table, key);
+ if (err)
+ goto err_out_mpt_free;
+ }
+
+ mailbox = mthca_alloc_mailbox(dev, GFP_KERNEL);
+ if (IS_ERR(mailbox)) {
+ err = PTR_ERR(mailbox);
+ goto err_out_table;
+ }
+ mpt_entry = mailbox->buf;
+
+ mpt_entry->flags = cpu_to_be32(MTHCA_MPT_FLAG_SW_OWNS |
+ MTHCA_MPT_FLAG_MIO |
+ MTHCA_MPT_FLAG_REGION |
+ access);
+ if (!mr->mtt)
+ mpt_entry->flags |= cpu_to_be32(MTHCA_MPT_FLAG_PHYSICAL);
+
+ mpt_entry->page_size = cpu_to_be32(buffer_size_shift - 12);
+ mpt_entry->key = cpu_to_be32(key);
+ mpt_entry->pd = cpu_to_be32(pd);
+ mpt_entry->start = cpu_to_be64(iova);
+ mpt_entry->length = cpu_to_be64(total_size);
+
+ memset(&mpt_entry->lkey, 0,
+ sizeof *mpt_entry - offsetof(struct mthca_mpt_entry, lkey));
+
+ if (mr->mtt)
+ mpt_entry->mtt_seg =
+ cpu_to_be64(dev->mr_table.mtt_base +
+ mr->mtt->first_seg * dev->limits.mtt_seg_size);
+
+ if (0) {
+ mthca_dbg(dev, "Dumping MPT entry %08x:\n", mr->ibmr.lkey);
+ for (i = 0; i < sizeof (struct mthca_mpt_entry) / 4; ++i) {
+ if (i % 4 == 0)
+ printk("[%02x] ", i * 4);
+ printk(" %08x", be32_to_cpu(((__be32 *) mpt_entry)[i]));
+ if ((i + 1) % 4 == 0)
+ printk("\n");
+ }
+ }
+
+ err = mthca_SW2HW_MPT(dev, mailbox,
+ key & (dev->limits.num_mpts - 1));
+ if (err) {
+ mthca_warn(dev, "SW2HW_MPT failed (%d)\n", err);
+ goto err_out_mailbox;
+ }
+
+ mthca_free_mailbox(dev, mailbox);
+ return err;
+
+err_out_mailbox:
+ mthca_free_mailbox(dev, mailbox);
+
+err_out_table:
+ mthca_table_put(dev, dev->mr_table.mpt_table, key);
+
+err_out_mpt_free:
+ mthca_free(&dev->mr_table.mpt_alloc, key);
+ return err;
+}
+
+int mthca_mr_alloc_notrans(struct mthca_dev *dev, u32 pd,
+ u32 access, struct mthca_mr *mr)
+{
+ mr->mtt = NULL;
+ return mthca_mr_alloc(dev, pd, 12, 0, ~0ULL, access, mr);
+}
+
+int mthca_mr_alloc_phys(struct mthca_dev *dev, u32 pd,
+ u64 *buffer_list, int buffer_size_shift,
+ int list_len, u64 iova, u64 total_size,
+ u32 access, struct mthca_mr *mr)
+{
+ int err;
+
+ mr->mtt = mthca_alloc_mtt(dev, list_len);
+ if (IS_ERR(mr->mtt))
+ return PTR_ERR(mr->mtt);
+
+ err = mthca_write_mtt(dev, mr->mtt, 0, buffer_list, list_len);
+ if (err) {
+ mthca_free_mtt(dev, mr->mtt);
+ return err;
+ }
+
+ err = mthca_mr_alloc(dev, pd, buffer_size_shift, iova,
+ total_size, access, mr);
+ if (err)
+ mthca_free_mtt(dev, mr->mtt);
+
+ return err;
+}
+
+/* Free mr or fmr */
+static void mthca_free_region(struct mthca_dev *dev, u32 lkey)
+{
+ mthca_table_put(dev, dev->mr_table.mpt_table,
+ key_to_hw_index(dev, lkey));
+
+ mthca_free(&dev->mr_table.mpt_alloc, key_to_hw_index(dev, lkey));
+}
+
+void mthca_free_mr(struct mthca_dev *dev, struct mthca_mr *mr)
+{
+ int err;
+
+ err = mthca_HW2SW_MPT(dev, NULL,
+ key_to_hw_index(dev, mr->ibmr.lkey) &
+ (dev->limits.num_mpts - 1));
+ if (err)
+ mthca_warn(dev, "HW2SW_MPT failed (%d)\n", err);
+
+ mthca_free_region(dev, mr->ibmr.lkey);
+ mthca_free_mtt(dev, mr->mtt);
+}
+
+int mthca_fmr_alloc(struct mthca_dev *dev, u32 pd,
+ u32 access, struct mthca_fmr *mr)
+{
+ struct mthca_mpt_entry *mpt_entry;
+ struct mthca_mailbox *mailbox;
+ u64 mtt_seg;
+ u32 key, idx;
+ int list_len = mr->attr.max_pages;
+ int err = -ENOMEM;
+ int i;
+
+ if (mr->attr.page_shift < 12 || mr->attr.page_shift >= 32)
+ return -EINVAL;
+
+ /* For Arbel, all MTTs must fit in the same page. */
+ if (mthca_is_memfree(dev) &&
+ mr->attr.max_pages * sizeof *mr->mem.arbel.mtts > PAGE_SIZE)
+ return -EINVAL;
+
+ mr->maps = 0;
+
+ key = mthca_alloc(&dev->mr_table.mpt_alloc);
+ if (key == -1)
+ return -ENOMEM;
+ key = adjust_key(dev, key);
+
+ idx = key & (dev->limits.num_mpts - 1);
+ mr->ibmr.rkey = mr->ibmr.lkey = hw_index_to_key(dev, key);
+
+ if (mthca_is_memfree(dev)) {
+ err = mthca_table_get(dev, dev->mr_table.mpt_table, key);
+ if (err)
+ goto err_out_mpt_free;
+
+ mr->mem.arbel.mpt = mthca_table_find(dev->mr_table.mpt_table, key, NULL);
+ BUG_ON(!mr->mem.arbel.mpt);
+ } else
+ mr->mem.tavor.mpt = dev->mr_table.tavor_fmr.mpt_base +
+ sizeof *(mr->mem.tavor.mpt) * idx;
+
+ mr->mtt = __mthca_alloc_mtt(dev, list_len, dev->mr_table.fmr_mtt_buddy);
+ if (IS_ERR(mr->mtt)) {
+ err = PTR_ERR(mr->mtt);
+ goto err_out_table;
+ }
+
+ mtt_seg = mr->mtt->first_seg * dev->limits.mtt_seg_size;
+
+ if (mthca_is_memfree(dev)) {
+ mr->mem.arbel.mtts = mthca_table_find(dev->mr_table.mtt_table,
+ mr->mtt->first_seg,
+ &mr->mem.arbel.dma_handle);
+ BUG_ON(!mr->mem.arbel.mtts);
+ } else
+ mr->mem.tavor.mtts = dev->mr_table.tavor_fmr.mtt_base + mtt_seg;
+
+ mailbox = mthca_alloc_mailbox(dev, GFP_KERNEL);
+ if (IS_ERR(mailbox)) {
+ err = PTR_ERR(mailbox);
+ goto err_out_free_mtt;
+ }
+
+ mpt_entry = mailbox->buf;
+
+ mpt_entry->flags = cpu_to_be32(MTHCA_MPT_FLAG_SW_OWNS |
+ MTHCA_MPT_FLAG_MIO |
+ MTHCA_MPT_FLAG_REGION |
+ access);
+
+ mpt_entry->page_size = cpu_to_be32(mr->attr.page_shift - 12);
+ mpt_entry->key = cpu_to_be32(key);
+ mpt_entry->pd = cpu_to_be32(pd);
+ memset(&mpt_entry->start, 0,
+ sizeof *mpt_entry - offsetof(struct mthca_mpt_entry, start));
+ mpt_entry->mtt_seg = cpu_to_be64(dev->mr_table.mtt_base + mtt_seg);
+
+ if (0) {
+ mthca_dbg(dev, "Dumping MPT entry %08x:\n", mr->ibmr.lkey);
+ for (i = 0; i < sizeof (struct mthca_mpt_entry) / 4; ++i) {
+ if (i % 4 == 0)
+ printk("[%02x] ", i * 4);
+ printk(" %08x", be32_to_cpu(((__be32 *) mpt_entry)[i]));
+ if ((i + 1) % 4 == 0)
+ printk("\n");
+ }
+ }
+
+ err = mthca_SW2HW_MPT(dev, mailbox,
+ key & (dev->limits.num_mpts - 1));
+ if (err) {
+ mthca_warn(dev, "SW2HW_MPT failed (%d)\n", err);
+ goto err_out_mailbox_free;
+ }
+
+ mthca_free_mailbox(dev, mailbox);
+ return 0;
+
+err_out_mailbox_free:
+ mthca_free_mailbox(dev, mailbox);
+
+err_out_free_mtt:
+ mthca_free_mtt(dev, mr->mtt);
+
+err_out_table:
+ mthca_table_put(dev, dev->mr_table.mpt_table, key);
+
+err_out_mpt_free:
+ mthca_free(&dev->mr_table.mpt_alloc, key);
+ return err;
+}
+
+int mthca_free_fmr(struct mthca_dev *dev, struct mthca_fmr *fmr)
+{
+ if (fmr->maps)
+ return -EBUSY;
+
+ mthca_free_region(dev, fmr->ibmr.lkey);
+ mthca_free_mtt(dev, fmr->mtt);
+
+ return 0;
+}
+
+static inline int mthca_check_fmr(struct mthca_fmr *fmr, u64 *page_list,
+ int list_len, u64 iova)
+{
+ int i, page_mask;
+
+ if (list_len > fmr->attr.max_pages)
+ return -EINVAL;
+
+ page_mask = (1 << fmr->attr.page_shift) - 1;
+
+ /* We are getting page lists, so va must be page aligned. */
+ if (iova & page_mask)
+ return -EINVAL;
+
+ /* Trust the user not to pass misaligned data in page_list */
+ if (0)
+ for (i = 0; i < list_len; ++i) {
+ if (page_list[i] & ~page_mask)
+ return -EINVAL;
+ }
+
+ if (fmr->maps >= fmr->attr.max_maps)
+ return -EINVAL;
+
+ return 0;
+}
+
+
+int mthca_tavor_map_phys_fmr(struct ib_fmr *ibfmr, u64 *page_list,
+ int list_len, u64 iova)
+{
+ struct mthca_fmr *fmr = to_mfmr(ibfmr);
+ struct mthca_dev *dev = to_mdev(ibfmr->device);
+ struct mthca_mpt_entry mpt_entry;
+ u32 key;
+ int i, err;
+
+ err = mthca_check_fmr(fmr, page_list, list_len, iova);
+ if (err)
+ return err;
+
+ ++fmr->maps;
+
+ key = tavor_key_to_hw_index(fmr->ibmr.lkey);
+ key += dev->limits.num_mpts;
+ fmr->ibmr.lkey = fmr->ibmr.rkey = tavor_hw_index_to_key(key);
+
+ writeb(MTHCA_MPT_STATUS_SW, fmr->mem.tavor.mpt);
+
+ for (i = 0; i < list_len; ++i) {
+ __be64 mtt_entry = cpu_to_be64(page_list[i] |
+ MTHCA_MTT_FLAG_PRESENT);
+ mthca_write64_raw(mtt_entry, fmr->mem.tavor.mtts + i);
+ }
+
+ mpt_entry.lkey = cpu_to_be32(key);
+ mpt_entry.length = cpu_to_be64(list_len * (1ull << fmr->attr.page_shift));
+ mpt_entry.start = cpu_to_be64(iova);
+
+ __raw_writel((__force u32) mpt_entry.lkey, &fmr->mem.tavor.mpt->key);
+ memcpy_toio(&fmr->mem.tavor.mpt->start, &mpt_entry.start,
+ offsetof(struct mthca_mpt_entry, window_count) -
+ offsetof(struct mthca_mpt_entry, start));
+
+ writeb(MTHCA_MPT_STATUS_HW, fmr->mem.tavor.mpt);
+
+ return 0;
+}
+
+int mthca_arbel_map_phys_fmr(struct ib_fmr *ibfmr, u64 *page_list,
+ int list_len, u64 iova)
+{
+ struct mthca_fmr *fmr = to_mfmr(ibfmr);
+ struct mthca_dev *dev = to_mdev(ibfmr->device);
+ u32 key;
+ int i, err;
+
+ err = mthca_check_fmr(fmr, page_list, list_len, iova);
+ if (err)
+ return err;
+
+ ++fmr->maps;
+
+ key = arbel_key_to_hw_index(fmr->ibmr.lkey);
+ if (dev->mthca_flags & MTHCA_FLAG_SINAI_OPT)
+ key += SINAI_FMR_KEY_INC;
+ else
+ key += dev->limits.num_mpts;
+ fmr->ibmr.lkey = fmr->ibmr.rkey = arbel_hw_index_to_key(key);
+
+ *(u8 *) fmr->mem.arbel.mpt = MTHCA_MPT_STATUS_SW;
+
+ wmb();
+
+ dma_sync_single_for_cpu(&dev->pdev->dev, fmr->mem.arbel.dma_handle,
+ list_len * sizeof(u64), DMA_TO_DEVICE);
+
+ for (i = 0; i < list_len; ++i)
+ fmr->mem.arbel.mtts[i] = cpu_to_be64(page_list[i] |
+ MTHCA_MTT_FLAG_PRESENT);
+
+ dma_sync_single_for_device(&dev->pdev->dev, fmr->mem.arbel.dma_handle,
+ list_len * sizeof(u64), DMA_TO_DEVICE);
+
+ fmr->mem.arbel.mpt->key = cpu_to_be32(key);
+ fmr->mem.arbel.mpt->lkey = cpu_to_be32(key);
+ fmr->mem.arbel.mpt->length = cpu_to_be64(list_len * (1ull << fmr->attr.page_shift));
+ fmr->mem.arbel.mpt->start = cpu_to_be64(iova);
+
+ wmb();
+
+ *(u8 *) fmr->mem.arbel.mpt = MTHCA_MPT_STATUS_HW;
+
+ wmb();
+
+ return 0;
+}
+
+void mthca_tavor_fmr_unmap(struct mthca_dev *dev, struct mthca_fmr *fmr)
+{
+ if (!fmr->maps)
+ return;
+
+ fmr->maps = 0;
+
+ writeb(MTHCA_MPT_STATUS_SW, fmr->mem.tavor.mpt);
+}
+
+void mthca_arbel_fmr_unmap(struct mthca_dev *dev, struct mthca_fmr *fmr)
+{
+ if (!fmr->maps)
+ return;
+
+ fmr->maps = 0;
+
+ *(u8 *) fmr->mem.arbel.mpt = MTHCA_MPT_STATUS_SW;
+}
+
+int mthca_init_mr_table(struct mthca_dev *dev)
+{
+ phys_addr_t addr;
+ int mpts, mtts, err, i;
+
+ err = mthca_alloc_init(&dev->mr_table.mpt_alloc,
+ dev->limits.num_mpts,
+ ~0, dev->limits.reserved_mrws);
+ if (err)
+ return err;
+
+ if (!mthca_is_memfree(dev) &&
+ (dev->mthca_flags & MTHCA_FLAG_DDR_HIDDEN))
+ dev->limits.fmr_reserved_mtts = 0;
+ else
+ dev->mthca_flags |= MTHCA_FLAG_FMR;
+
+ if (dev->mthca_flags & MTHCA_FLAG_SINAI_OPT)
+ mthca_dbg(dev, "Memory key throughput optimization activated.\n");
+
+ err = mthca_buddy_init(&dev->mr_table.mtt_buddy,
+ fls(dev->limits.num_mtt_segs - 1));
+
+ if (err)
+ goto err_mtt_buddy;
+
+ dev->mr_table.tavor_fmr.mpt_base = NULL;
+ dev->mr_table.tavor_fmr.mtt_base = NULL;
+
+ if (dev->limits.fmr_reserved_mtts) {
+ i = fls(dev->limits.fmr_reserved_mtts - 1);
+
+ if (i >= 31) {
+ mthca_warn(dev, "Unable to reserve 2^31 FMR MTTs.\n");
+ err = -EINVAL;
+ goto err_fmr_mpt;
+ }
+ mpts = mtts = 1 << i;
+ } else {
+ mtts = dev->limits.num_mtt_segs;
+ mpts = dev->limits.num_mpts;
+ }
+
+ if (!mthca_is_memfree(dev) &&
+ (dev->mthca_flags & MTHCA_FLAG_FMR)) {
+
+ addr = pci_resource_start(dev->pdev, 4) +
+ ((pci_resource_len(dev->pdev, 4) - 1) &
+ dev->mr_table.mpt_base);
+
+ dev->mr_table.tavor_fmr.mpt_base =
+ ioremap(addr, mpts * sizeof(struct mthca_mpt_entry));
+
+ if (!dev->mr_table.tavor_fmr.mpt_base) {
+ mthca_warn(dev, "MPT ioremap for FMR failed.\n");
+ err = -ENOMEM;
+ goto err_fmr_mpt;
+ }
+
+ addr = pci_resource_start(dev->pdev, 4) +
+ ((pci_resource_len(dev->pdev, 4) - 1) &
+ dev->mr_table.mtt_base);
+
+ dev->mr_table.tavor_fmr.mtt_base =
+ ioremap(addr, mtts * dev->limits.mtt_seg_size);
+ if (!dev->mr_table.tavor_fmr.mtt_base) {
+ mthca_warn(dev, "MTT ioremap for FMR failed.\n");
+ err = -ENOMEM;
+ goto err_fmr_mtt;
+ }
+ }
+
+ if (dev->limits.fmr_reserved_mtts) {
+ err = mthca_buddy_init(&dev->mr_table.tavor_fmr.mtt_buddy, fls(mtts - 1));
+ if (err)
+ goto err_fmr_mtt_buddy;
+
+ /* Prevent regular MRs from using FMR keys */
+ err = mthca_buddy_alloc(&dev->mr_table.mtt_buddy, fls(mtts - 1));
+ if (err)
+ goto err_reserve_fmr;
+
+ dev->mr_table.fmr_mtt_buddy =
+ &dev->mr_table.tavor_fmr.mtt_buddy;
+ } else
+ dev->mr_table.fmr_mtt_buddy = &dev->mr_table.mtt_buddy;
+
+ /* FMR table is always the first, take reserved MTTs out of there */
+ if (dev->limits.reserved_mtts) {
+ i = fls(dev->limits.reserved_mtts - 1);
+
+ if (mthca_alloc_mtt_range(dev, i,
+ dev->mr_table.fmr_mtt_buddy) == -1) {
+ mthca_warn(dev, "MTT table of order %d is too small.\n",
+ dev->mr_table.fmr_mtt_buddy->max_order);
+ err = -ENOMEM;
+ goto err_reserve_mtts;
+ }
+ }
+
+ return 0;
+
+err_reserve_mtts:
+err_reserve_fmr:
+ if (dev->limits.fmr_reserved_mtts)
+ mthca_buddy_cleanup(&dev->mr_table.tavor_fmr.mtt_buddy);
+
+err_fmr_mtt_buddy:
+ if (dev->mr_table.tavor_fmr.mtt_base)
+ iounmap(dev->mr_table.tavor_fmr.mtt_base);
+
+err_fmr_mtt:
+ if (dev->mr_table.tavor_fmr.mpt_base)
+ iounmap(dev->mr_table.tavor_fmr.mpt_base);
+
+err_fmr_mpt:
+ mthca_buddy_cleanup(&dev->mr_table.mtt_buddy);
+
+err_mtt_buddy:
+ mthca_alloc_cleanup(&dev->mr_table.mpt_alloc);
+
+ return err;
+}
+
+void mthca_cleanup_mr_table(struct mthca_dev *dev)
+{
+ /* XXX check if any MRs are still allocated? */
+ if (dev->limits.fmr_reserved_mtts)
+ mthca_buddy_cleanup(&dev->mr_table.tavor_fmr.mtt_buddy);
+
+ mthca_buddy_cleanup(&dev->mr_table.mtt_buddy);
+
+ if (dev->mr_table.tavor_fmr.mtt_base)
+ iounmap(dev->mr_table.tavor_fmr.mtt_base);
+ if (dev->mr_table.tavor_fmr.mpt_base)
+ iounmap(dev->mr_table.tavor_fmr.mpt_base);
+
+ mthca_alloc_cleanup(&dev->mr_table.mpt_alloc);
+}
diff --git a/sys/ofed/drivers/infiniband/hw/mthca/mthca_pd.c b/sys/dev/mthca/mthca_pd.c
index 266f14e..266f14e 100644
--- a/sys/ofed/drivers/infiniband/hw/mthca/mthca_pd.c
+++ b/sys/dev/mthca/mthca_pd.c
diff --git a/sys/dev/mthca/mthca_profile.c b/sys/dev/mthca/mthca_profile.c
new file mode 100644
index 0000000..15d0644
--- /dev/null
+++ b/sys/dev/mthca/mthca_profile.c
@@ -0,0 +1,281 @@
+/*
+ * Copyright (c) 2004, 2005 Topspin Communications. All rights reserved.
+ * Copyright (c) 2005 Mellanox Technologies. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#include <linux/module.h>
+#include <linux/moduleparam.h>
+#include <linux/string.h>
+#include <linux/slab.h>
+
+#include "mthca_profile.h"
+
+enum {
+ MTHCA_RES_QP,
+ MTHCA_RES_EEC,
+ MTHCA_RES_SRQ,
+ MTHCA_RES_CQ,
+ MTHCA_RES_EQP,
+ MTHCA_RES_EEEC,
+ MTHCA_RES_EQ,
+ MTHCA_RES_RDB,
+ MTHCA_RES_MCG,
+ MTHCA_RES_MPT,
+ MTHCA_RES_MTT,
+ MTHCA_RES_UAR,
+ MTHCA_RES_UDAV,
+ MTHCA_RES_UARC,
+ MTHCA_RES_NUM
+};
+
+enum {
+ MTHCA_NUM_EQS = 32,
+ MTHCA_NUM_PDS = 1 << 15
+};
+
+s64 mthca_make_profile(struct mthca_dev *dev,
+ struct mthca_profile *request,
+ struct mthca_dev_lim *dev_lim,
+ struct mthca_init_hca_param *init_hca)
+{
+ struct mthca_resource {
+ u64 size;
+ u64 start;
+ int type;
+ int num;
+ int log_num;
+ };
+
+ u64 mem_base, mem_avail;
+ s64 total_size = 0;
+ struct mthca_resource *profile;
+ int i, j;
+
+ profile = kzalloc(MTHCA_RES_NUM * sizeof *profile, GFP_KERNEL);
+ if (!profile)
+ return -ENOMEM;
+
+ profile[MTHCA_RES_QP].size = dev_lim->qpc_entry_sz;
+ profile[MTHCA_RES_EEC].size = dev_lim->eec_entry_sz;
+ profile[MTHCA_RES_SRQ].size = dev_lim->srq_entry_sz;
+ profile[MTHCA_RES_CQ].size = dev_lim->cqc_entry_sz;
+ profile[MTHCA_RES_EQP].size = dev_lim->eqpc_entry_sz;
+ profile[MTHCA_RES_EEEC].size = dev_lim->eeec_entry_sz;
+ profile[MTHCA_RES_EQ].size = dev_lim->eqc_entry_sz;
+ profile[MTHCA_RES_RDB].size = MTHCA_RDB_ENTRY_SIZE;
+ profile[MTHCA_RES_MCG].size = MTHCA_MGM_ENTRY_SIZE;
+ profile[MTHCA_RES_MPT].size = dev_lim->mpt_entry_sz;
+ profile[MTHCA_RES_MTT].size = dev->limits.mtt_seg_size;
+ profile[MTHCA_RES_UAR].size = dev_lim->uar_scratch_entry_sz;
+ profile[MTHCA_RES_UDAV].size = MTHCA_AV_SIZE;
+ profile[MTHCA_RES_UARC].size = request->uarc_size;
+
+ profile[MTHCA_RES_QP].num = request->num_qp;
+ profile[MTHCA_RES_SRQ].num = request->num_srq;
+ profile[MTHCA_RES_EQP].num = request->num_qp;
+ profile[MTHCA_RES_RDB].num = request->num_qp * request->rdb_per_qp;
+ profile[MTHCA_RES_CQ].num = request->num_cq;
+ profile[MTHCA_RES_EQ].num = MTHCA_NUM_EQS;
+ profile[MTHCA_RES_MCG].num = request->num_mcg;
+ profile[MTHCA_RES_MPT].num = request->num_mpt;
+ profile[MTHCA_RES_MTT].num = request->num_mtt;
+ profile[MTHCA_RES_UAR].num = request->num_uar;
+ profile[MTHCA_RES_UARC].num = request->num_uar;
+ profile[MTHCA_RES_UDAV].num = request->num_udav;
+
+ for (i = 0; i < MTHCA_RES_NUM; ++i) {
+ profile[i].type = i;
+ profile[i].log_num = max(ffs(profile[i].num) - 1, 0);
+ profile[i].size *= profile[i].num;
+ if (mthca_is_memfree(dev))
+ profile[i].size = max(profile[i].size, (u64) PAGE_SIZE);
+ }
+
+ if (mthca_is_memfree(dev)) {
+ mem_base = 0;
+ mem_avail = dev_lim->hca.arbel.max_icm_sz;
+ } else {
+ mem_base = dev->ddr_start;
+ mem_avail = dev->fw.tavor.fw_start - dev->ddr_start;
+ }
+
+ /*
+ * Sort the resources in decreasing order of size. Since they
+ * all have sizes that are powers of 2, we'll be able to keep
+ * resources aligned to their size and pack them without gaps
+ * using the sorted order.
+ */
+ for (i = MTHCA_RES_NUM; i > 0; --i)
+ for (j = 1; j < i; ++j) {
+ if (profile[j].size > profile[j - 1].size)
+ swap(profile[j], profile[j - 1]);
+ }
+
+ for (i = 0; i < MTHCA_RES_NUM; ++i) {
+ if (profile[i].size) {
+ profile[i].start = mem_base + total_size;
+ total_size += profile[i].size;
+ }
+ if (total_size > mem_avail) {
+ mthca_err(dev, "Profile requires 0x%llx bytes; "
+ "won't fit in 0x%llx bytes of context memory.\n",
+ (unsigned long long) total_size,
+ (unsigned long long) mem_avail);
+ kfree(profile);
+ return -ENOMEM;
+ }
+
+ if (profile[i].size)
+ mthca_dbg(dev, "profile[%2d]--%2d/%2d @ 0x%16llx "
+ "(size 0x%8llx)\n",
+ i, profile[i].type, profile[i].log_num,
+ (unsigned long long) profile[i].start,
+ (unsigned long long) profile[i].size);
+ }
+
+ if (mthca_is_memfree(dev))
+ mthca_dbg(dev, "HCA context memory: reserving %d KB\n",
+ (int) (total_size >> 10));
+ else
+ mthca_dbg(dev, "HCA memory: allocated %d KB/%d KB (%d KB free)\n",
+ (int) (total_size >> 10), (int) (mem_avail >> 10),
+ (int) ((mem_avail - total_size) >> 10));
+
+ for (i = 0; i < MTHCA_RES_NUM; ++i) {
+ switch (profile[i].type) {
+ case MTHCA_RES_QP:
+ dev->limits.num_qps = profile[i].num;
+ init_hca->qpc_base = profile[i].start;
+ init_hca->log_num_qps = profile[i].log_num;
+ break;
+ case MTHCA_RES_EEC:
+ dev->limits.num_eecs = profile[i].num;
+ init_hca->eec_base = profile[i].start;
+ init_hca->log_num_eecs = profile[i].log_num;
+ break;
+ case MTHCA_RES_SRQ:
+ dev->limits.num_srqs = profile[i].num;
+ init_hca->srqc_base = profile[i].start;
+ init_hca->log_num_srqs = profile[i].log_num;
+ break;
+ case MTHCA_RES_CQ:
+ dev->limits.num_cqs = profile[i].num;
+ init_hca->cqc_base = profile[i].start;
+ init_hca->log_num_cqs = profile[i].log_num;
+ break;
+ case MTHCA_RES_EQP:
+ init_hca->eqpc_base = profile[i].start;
+ break;
+ case MTHCA_RES_EEEC:
+ init_hca->eeec_base = profile[i].start;
+ break;
+ case MTHCA_RES_EQ:
+ dev->limits.num_eqs = profile[i].num;
+ init_hca->eqc_base = profile[i].start;
+ init_hca->log_num_eqs = profile[i].log_num;
+ break;
+ case MTHCA_RES_RDB:
+ for (dev->qp_table.rdb_shift = 0;
+ request->num_qp << dev->qp_table.rdb_shift < profile[i].num;
+ ++dev->qp_table.rdb_shift)
+ ; /* nothing */
+ dev->qp_table.rdb_base = (u32) profile[i].start;
+ init_hca->rdb_base = profile[i].start;
+ break;
+ case MTHCA_RES_MCG:
+ dev->limits.num_mgms = profile[i].num >> 1;
+ dev->limits.num_amgms = profile[i].num >> 1;
+ init_hca->mc_base = profile[i].start;
+ init_hca->log_mc_entry_sz = ffs(MTHCA_MGM_ENTRY_SIZE) - 1;
+ init_hca->log_mc_table_sz = profile[i].log_num;
+ init_hca->mc_hash_sz = 1 << (profile[i].log_num - 1);
+ break;
+ case MTHCA_RES_MPT:
+ dev->limits.num_mpts = profile[i].num;
+ dev->mr_table.mpt_base = profile[i].start;
+ init_hca->mpt_base = profile[i].start;
+ init_hca->log_mpt_sz = profile[i].log_num;
+ break;
+ case MTHCA_RES_MTT:
+ dev->limits.num_mtt_segs = profile[i].num;
+ dev->mr_table.mtt_base = profile[i].start;
+ init_hca->mtt_base = profile[i].start;
+ init_hca->mtt_seg_sz = ffs(dev->limits.mtt_seg_size) - 7;
+ break;
+ case MTHCA_RES_UAR:
+ dev->limits.num_uars = profile[i].num;
+ init_hca->uar_scratch_base = profile[i].start;
+ break;
+ case MTHCA_RES_UDAV:
+ dev->av_table.ddr_av_base = profile[i].start;
+ dev->av_table.num_ddr_avs = profile[i].num;
+ break;
+ case MTHCA_RES_UARC:
+ dev->uar_table.uarc_size = request->uarc_size;
+ dev->uar_table.uarc_base = profile[i].start;
+ init_hca->uarc_base = profile[i].start;
+ init_hca->log_uarc_sz = ffs(request->uarc_size) - 13;
+ init_hca->log_uar_sz = ffs(request->num_uar) - 1;
+ break;
+ default:
+ break;
+ }
+ }
+
+ /*
+ * PDs don't take any HCA memory, but we assign them as part
+ * of the HCA profile anyway.
+ */
+ dev->limits.num_pds = MTHCA_NUM_PDS;
+
+ if (dev->mthca_flags & MTHCA_FLAG_SINAI_OPT &&
+ init_hca->log_mpt_sz > 23) {
+ mthca_warn(dev, "MPT table too large (requested size 2^%d >= 2^24)\n",
+ init_hca->log_mpt_sz);
+ mthca_warn(dev, "Disabling memory key throughput optimization.\n");
+ dev->mthca_flags &= ~MTHCA_FLAG_SINAI_OPT;
+ }
+
+ /*
+ * For Tavor, FMRs use ioremapped PCI memory. For 32 bit
+ * systems it may use too much vmalloc space to map all MTT
+ * memory, so we reserve some MTTs for FMR access, taking them
+ * out of the MR pool. They don't use additional memory, but
+ * we assign them as part of the HCA profile anyway.
+ */
+ if (mthca_is_memfree(dev) || BITS_PER_LONG == 64)
+ dev->limits.fmr_reserved_mtts = 0;
+ else
+ dev->limits.fmr_reserved_mtts = request->fmr_reserved_mtts;
+
+ kfree(profile);
+ return total_size;
+}
diff --git a/sys/ofed/drivers/infiniband/hw/mthca/mthca_profile.h b/sys/dev/mthca/mthca_profile.h
index 62b009c..62b009c 100644
--- a/sys/ofed/drivers/infiniband/hw/mthca/mthca_profile.h
+++ b/sys/dev/mthca/mthca_profile.h
diff --git a/sys/dev/mthca/mthca_provider.c b/sys/dev/mthca/mthca_provider.c
new file mode 100644
index 0000000..db747f9
--- /dev/null
+++ b/sys/dev/mthca/mthca_provider.c
@@ -0,0 +1,1318 @@
+/*
+ * Copyright (c) 2004, 2005 Topspin Communications. All rights reserved.
+ * Copyright (c) 2005 Sun Microsystems, Inc. All rights reserved.
+ * Copyright (c) 2005, 2006 Cisco Systems. All rights reserved.
+ * Copyright (c) 2005 Mellanox Technologies. All rights reserved.
+ * Copyright (c) 2004 Voltaire, Inc. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#include <rdma/ib_smi.h>
+#include <rdma/ib_umem.h>
+#include <rdma/ib_user_verbs.h>
+
+#include <linux/sched.h>
+#include <linux/slab.h>
+#include <linux/mm.h>
+#include <linux/fs.h>
+
+#include "mthca_dev.h"
+#include "mthca_cmd.h"
+#include <rdma/mthca-abi.h>
+#include "mthca_memfree.h"
+
+static void init_query_mad(struct ib_smp *mad)
+{
+ mad->base_version = 1;
+ mad->mgmt_class = IB_MGMT_CLASS_SUBN_LID_ROUTED;
+ mad->class_version = 1;
+ mad->method = IB_MGMT_METHOD_GET;
+}
+
+static int mthca_query_device(struct ib_device *ibdev, struct ib_device_attr *props,
+ struct ib_udata *uhw)
+{
+ struct ib_smp *in_mad = NULL;
+ struct ib_smp *out_mad = NULL;
+ int err = -ENOMEM;
+ struct mthca_dev *mdev = to_mdev(ibdev);
+
+ if (uhw->inlen || uhw->outlen)
+ return -EINVAL;
+
+ in_mad = kzalloc(sizeof *in_mad, GFP_KERNEL);
+ out_mad = kmalloc(sizeof *out_mad, GFP_KERNEL);
+ if (!in_mad || !out_mad)
+ goto out;
+
+ memset(props, 0, sizeof *props);
+
+ props->fw_ver = mdev->fw_ver;
+
+ init_query_mad(in_mad);
+ in_mad->attr_id = IB_SMP_ATTR_NODE_INFO;
+
+ err = mthca_MAD_IFC(mdev, 1, 1,
+ 1, NULL, NULL, in_mad, out_mad);
+ if (err)
+ goto out;
+
+ props->device_cap_flags = mdev->device_cap_flags;
+ props->vendor_id = be32_to_cpup((__be32 *) (out_mad->data + 36)) &
+ 0xffffff;
+ props->vendor_part_id = be16_to_cpup((__be16 *) (out_mad->data + 30));
+ props->hw_ver = be32_to_cpup((__be32 *) (out_mad->data + 32));
+ memcpy(&props->sys_image_guid, out_mad->data + 4, 8);
+
+ props->max_mr_size = ~0ull;
+ props->page_size_cap = mdev->limits.page_size_cap;
+ props->max_qp = mdev->limits.num_qps - mdev->limits.reserved_qps;
+ props->max_qp_wr = mdev->limits.max_wqes;
+ props->max_sge = mdev->limits.max_sg;
+ props->max_sge_rd = props->max_sge;
+ props->max_cq = mdev->limits.num_cqs - mdev->limits.reserved_cqs;
+ props->max_cqe = mdev->limits.max_cqes;
+ props->max_mr = mdev->limits.num_mpts - mdev->limits.reserved_mrws;
+ props->max_pd = mdev->limits.num_pds - mdev->limits.reserved_pds;
+ props->max_qp_rd_atom = 1 << mdev->qp_table.rdb_shift;
+ props->max_qp_init_rd_atom = mdev->limits.max_qp_init_rdma;
+ props->max_res_rd_atom = props->max_qp_rd_atom * props->max_qp;
+ props->max_srq = mdev->limits.num_srqs - mdev->limits.reserved_srqs;
+ props->max_srq_wr = mdev->limits.max_srq_wqes;
+ props->max_srq_sge = mdev->limits.max_srq_sge;
+ props->local_ca_ack_delay = mdev->limits.local_ca_ack_delay;
+ props->atomic_cap = mdev->limits.flags & DEV_LIM_FLAG_ATOMIC ?
+ IB_ATOMIC_HCA : IB_ATOMIC_NONE;
+ props->max_pkeys = mdev->limits.pkey_table_len;
+ props->max_mcast_grp = mdev->limits.num_mgms + mdev->limits.num_amgms;
+ props->max_mcast_qp_attach = MTHCA_QP_PER_MGM;
+ props->max_total_mcast_qp_attach = props->max_mcast_qp_attach *
+ props->max_mcast_grp;
+ /*
+ * If Sinai memory key optimization is being used, then only
+ * the 8-bit key portion will change. For other HCAs, the
+ * unused index bits will also be used for FMR remapping.
+ */
+ if (mdev->mthca_flags & MTHCA_FLAG_SINAI_OPT)
+ props->max_map_per_fmr = 255;
+ else
+ props->max_map_per_fmr =
+ (1 << (32 - ilog2(mdev->limits.num_mpts))) - 1;
+
+ err = 0;
+ out:
+ kfree(in_mad);
+ kfree(out_mad);
+ return err;
+}
+
+static int mthca_query_port(struct ib_device *ibdev,
+ u8 port, struct ib_port_attr *props)
+{
+ struct ib_smp *in_mad = NULL;
+ struct ib_smp *out_mad = NULL;
+ int err = -ENOMEM;
+
+ in_mad = kzalloc(sizeof *in_mad, GFP_KERNEL);
+ out_mad = kmalloc(sizeof *out_mad, GFP_KERNEL);
+ if (!in_mad || !out_mad)
+ goto out;
+
+ memset(props, 0, sizeof *props);
+
+ init_query_mad(in_mad);
+ in_mad->attr_id = IB_SMP_ATTR_PORT_INFO;
+ in_mad->attr_mod = cpu_to_be32(port);
+
+ err = mthca_MAD_IFC(to_mdev(ibdev), 1, 1,
+ port, NULL, NULL, in_mad, out_mad);
+ if (err)
+ goto out;
+
+ props->lid = be16_to_cpup((__be16 *) (out_mad->data + 16));
+ props->lmc = out_mad->data[34] & 0x7;
+ props->sm_lid = be16_to_cpup((__be16 *) (out_mad->data + 18));
+ props->sm_sl = out_mad->data[36] & 0xf;
+ props->state = out_mad->data[32] & 0xf;
+ props->phys_state = out_mad->data[33] >> 4;
+ props->port_cap_flags = be32_to_cpup((__be32 *) (out_mad->data + 20));
+ props->gid_tbl_len = to_mdev(ibdev)->limits.gid_table_len;
+ props->max_msg_sz = 0x80000000;
+ props->pkey_tbl_len = to_mdev(ibdev)->limits.pkey_table_len;
+ props->bad_pkey_cntr = be16_to_cpup((__be16 *) (out_mad->data + 46));
+ props->qkey_viol_cntr = be16_to_cpup((__be16 *) (out_mad->data + 48));
+ props->active_width = out_mad->data[31] & 0xf;
+ props->active_speed = out_mad->data[35] >> 4;
+ props->max_mtu = out_mad->data[41] & 0xf;
+ props->active_mtu = out_mad->data[36] >> 4;
+ props->subnet_timeout = out_mad->data[51] & 0x1f;
+ props->max_vl_num = out_mad->data[37] >> 4;
+ props->init_type_reply = out_mad->data[41] >> 4;
+
+ out:
+ kfree(in_mad);
+ kfree(out_mad);
+ return err;
+}
+
+static int mthca_modify_device(struct ib_device *ibdev,
+ int mask,
+ struct ib_device_modify *props)
+{
+ if (mask & ~IB_DEVICE_MODIFY_NODE_DESC)
+ return -EOPNOTSUPP;
+
+ if (mask & IB_DEVICE_MODIFY_NODE_DESC) {
+ if (mutex_lock_interruptible(&to_mdev(ibdev)->cap_mask_mutex))
+ return -ERESTARTSYS;
+ memcpy(ibdev->node_desc, props->node_desc,
+ IB_DEVICE_NODE_DESC_MAX);
+ mutex_unlock(&to_mdev(ibdev)->cap_mask_mutex);
+ }
+
+ return 0;
+}
+
+static int mthca_modify_port(struct ib_device *ibdev,
+ u8 port, int port_modify_mask,
+ struct ib_port_modify *props)
+{
+ struct mthca_set_ib_param set_ib;
+ struct ib_port_attr attr;
+ int err;
+
+ if (mutex_lock_interruptible(&to_mdev(ibdev)->cap_mask_mutex))
+ return -ERESTARTSYS;
+
+ err = mthca_query_port(ibdev, port, &attr);
+ if (err)
+ goto out;
+
+ set_ib.set_si_guid = 0;
+ set_ib.reset_qkey_viol = !!(port_modify_mask & IB_PORT_RESET_QKEY_CNTR);
+
+ set_ib.cap_mask = (attr.port_cap_flags | props->set_port_cap_mask) &
+ ~props->clr_port_cap_mask;
+
+ err = mthca_SET_IB(to_mdev(ibdev), &set_ib, port);
+ if (err)
+ goto out;
+out:
+ mutex_unlock(&to_mdev(ibdev)->cap_mask_mutex);
+ return err;
+}
+
+static int mthca_query_pkey(struct ib_device *ibdev,
+ u8 port, u16 index, u16 *pkey)
+{
+ struct ib_smp *in_mad = NULL;
+ struct ib_smp *out_mad = NULL;
+ int err = -ENOMEM;
+
+ in_mad = kzalloc(sizeof *in_mad, GFP_KERNEL);
+ out_mad = kmalloc(sizeof *out_mad, GFP_KERNEL);
+ if (!in_mad || !out_mad)
+ goto out;
+
+ init_query_mad(in_mad);
+ in_mad->attr_id = IB_SMP_ATTR_PKEY_TABLE;
+ in_mad->attr_mod = cpu_to_be32(index / 32);
+
+ err = mthca_MAD_IFC(to_mdev(ibdev), 1, 1,
+ port, NULL, NULL, in_mad, out_mad);
+ if (err)
+ goto out;
+
+ *pkey = be16_to_cpu(((__be16 *) out_mad->data)[index % 32]);
+
+ out:
+ kfree(in_mad);
+ kfree(out_mad);
+ return err;
+}
+
+static int mthca_query_gid(struct ib_device *ibdev, u8 port,
+ int index, union ib_gid *gid)
+{
+ struct ib_smp *in_mad = NULL;
+ struct ib_smp *out_mad = NULL;
+ int err = -ENOMEM;
+
+ in_mad = kzalloc(sizeof *in_mad, GFP_KERNEL);
+ out_mad = kmalloc(sizeof *out_mad, GFP_KERNEL);
+ if (!in_mad || !out_mad)
+ goto out;
+
+ init_query_mad(in_mad);
+ in_mad->attr_id = IB_SMP_ATTR_PORT_INFO;
+ in_mad->attr_mod = cpu_to_be32(port);
+
+ err = mthca_MAD_IFC(to_mdev(ibdev), 1, 1,
+ port, NULL, NULL, in_mad, out_mad);
+ if (err)
+ goto out;
+
+ memcpy(gid->raw, out_mad->data + 8, 8);
+
+ init_query_mad(in_mad);
+ in_mad->attr_id = IB_SMP_ATTR_GUID_INFO;
+ in_mad->attr_mod = cpu_to_be32(index / 8);
+
+ err = mthca_MAD_IFC(to_mdev(ibdev), 1, 1,
+ port, NULL, NULL, in_mad, out_mad);
+ if (err)
+ goto out;
+
+ memcpy(gid->raw + 8, out_mad->data + (index % 8) * 8, 8);
+
+ out:
+ kfree(in_mad);
+ kfree(out_mad);
+ return err;
+}
+
+static struct ib_ucontext *mthca_alloc_ucontext(struct ib_device *ibdev,
+ struct ib_udata *udata)
+{
+ struct mthca_alloc_ucontext_resp uresp;
+ struct mthca_ucontext *context;
+ int err;
+
+ if (!(to_mdev(ibdev)->active))
+ return ERR_PTR(-EAGAIN);
+
+ memset(&uresp, 0, sizeof uresp);
+
+ uresp.qp_tab_size = to_mdev(ibdev)->limits.num_qps;
+ if (mthca_is_memfree(to_mdev(ibdev)))
+ uresp.uarc_size = to_mdev(ibdev)->uar_table.uarc_size;
+ else
+ uresp.uarc_size = 0;
+
+ context = kmalloc(sizeof *context, GFP_KERNEL);
+ if (!context)
+ return ERR_PTR(-ENOMEM);
+
+ err = mthca_uar_alloc(to_mdev(ibdev), &context->uar);
+ if (err) {
+ kfree(context);
+ return ERR_PTR(err);
+ }
+
+ context->db_tab = mthca_init_user_db_tab(to_mdev(ibdev));
+ if (IS_ERR(context->db_tab)) {
+ err = PTR_ERR(context->db_tab);
+ mthca_uar_free(to_mdev(ibdev), &context->uar);
+ kfree(context);
+ return ERR_PTR(err);
+ }
+
+ if (ib_copy_to_udata(udata, &uresp, sizeof uresp)) {
+ mthca_cleanup_user_db_tab(to_mdev(ibdev), &context->uar, context->db_tab);
+ mthca_uar_free(to_mdev(ibdev), &context->uar);
+ kfree(context);
+ return ERR_PTR(-EFAULT);
+ }
+
+ context->reg_mr_warned = 0;
+
+ return &context->ibucontext;
+}
+
+static int mthca_dealloc_ucontext(struct ib_ucontext *context)
+{
+ mthca_cleanup_user_db_tab(to_mdev(context->device), &to_mucontext(context)->uar,
+ to_mucontext(context)->db_tab);
+ mthca_uar_free(to_mdev(context->device), &to_mucontext(context)->uar);
+ kfree(to_mucontext(context));
+
+ return 0;
+}
+
+static int mthca_mmap_uar(struct ib_ucontext *context,
+ struct vm_area_struct *vma)
+{
+ if (vma->vm_end - vma->vm_start != PAGE_SIZE)
+ return -EINVAL;
+
+ vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);
+
+ if (io_remap_pfn_range(vma, vma->vm_start,
+ to_mucontext(context)->uar.pfn,
+ PAGE_SIZE, vma->vm_page_prot))
+ return -EAGAIN;
+
+ return 0;
+}
+
+static struct ib_pd *mthca_alloc_pd(struct ib_device *ibdev,
+ struct ib_ucontext *context,
+ struct ib_udata *udata)
+{
+ struct mthca_pd *pd;
+ int err;
+
+ pd = kmalloc(sizeof *pd, GFP_KERNEL);
+ if (!pd)
+ return ERR_PTR(-ENOMEM);
+
+ err = mthca_pd_alloc(to_mdev(ibdev), !context, pd);
+ if (err) {
+ kfree(pd);
+ return ERR_PTR(err);
+ }
+
+ if (context) {
+ if (ib_copy_to_udata(udata, &pd->pd_num, sizeof (__u32))) {
+ mthca_pd_free(to_mdev(ibdev), pd);
+ kfree(pd);
+ return ERR_PTR(-EFAULT);
+ }
+ }
+
+ return &pd->ibpd;
+}
+
+static int mthca_dealloc_pd(struct ib_pd *pd)
+{
+ mthca_pd_free(to_mdev(pd->device), to_mpd(pd));
+ kfree(pd);
+
+ return 0;
+}
+
+static struct ib_ah *mthca_ah_create(struct ib_pd *pd,
+ struct ib_ah_attr *ah_attr)
+{
+ int err;
+ struct mthca_ah *ah;
+
+ ah = kmalloc(sizeof *ah, GFP_ATOMIC);
+ if (!ah)
+ return ERR_PTR(-ENOMEM);
+
+ err = mthca_create_ah(to_mdev(pd->device), to_mpd(pd), ah_attr, ah);
+ if (err) {
+ kfree(ah);
+ return ERR_PTR(err);
+ }
+
+ return &ah->ibah;
+}
+
+static int mthca_ah_destroy(struct ib_ah *ah)
+{
+ mthca_destroy_ah(to_mdev(ah->device), to_mah(ah));
+ kfree(ah);
+
+ return 0;
+}
+
+static struct ib_srq *mthca_create_srq(struct ib_pd *pd,
+ struct ib_srq_init_attr *init_attr,
+ struct ib_udata *udata)
+{
+ struct mthca_create_srq ucmd;
+ struct mthca_ucontext *context = NULL;
+ struct mthca_srq *srq;
+ int err;
+
+ if (init_attr->srq_type != IB_SRQT_BASIC)
+ return ERR_PTR(-ENOSYS);
+
+ srq = kmalloc(sizeof *srq, GFP_KERNEL);
+ if (!srq)
+ return ERR_PTR(-ENOMEM);
+
+ if (pd->uobject) {
+ context = to_mucontext(pd->uobject->context);
+
+ if (ib_copy_from_udata(&ucmd, udata, sizeof ucmd)) {
+ err = -EFAULT;
+ goto err_free;
+ }
+
+ err = mthca_map_user_db(to_mdev(pd->device), &context->uar,
+ context->db_tab, ucmd.db_index,
+ ucmd.db_page);
+
+ if (err)
+ goto err_free;
+
+ srq->mr.ibmr.lkey = ucmd.lkey;
+ srq->db_index = ucmd.db_index;
+ }
+
+ err = mthca_alloc_srq(to_mdev(pd->device), to_mpd(pd),
+ &init_attr->attr, srq);
+
+ if (err && pd->uobject)
+ mthca_unmap_user_db(to_mdev(pd->device), &context->uar,
+ context->db_tab, ucmd.db_index);
+
+ if (err)
+ goto err_free;
+
+ if (context && ib_copy_to_udata(udata, &srq->srqn, sizeof (__u32))) {
+ mthca_free_srq(to_mdev(pd->device), srq);
+ err = -EFAULT;
+ goto err_free;
+ }
+
+ return &srq->ibsrq;
+
+err_free:
+ kfree(srq);
+
+ return ERR_PTR(err);
+}
+
+static int mthca_destroy_srq(struct ib_srq *srq)
+{
+ struct mthca_ucontext *context;
+
+ if (srq->uobject) {
+ context = to_mucontext(srq->uobject->context);
+
+ mthca_unmap_user_db(to_mdev(srq->device), &context->uar,
+ context->db_tab, to_msrq(srq)->db_index);
+ }
+
+ mthca_free_srq(to_mdev(srq->device), to_msrq(srq));
+ kfree(srq);
+
+ return 0;
+}
+
+static struct ib_qp *mthca_create_qp(struct ib_pd *pd,
+ struct ib_qp_init_attr *init_attr,
+ struct ib_udata *udata)
+{
+ struct mthca_create_qp ucmd;
+ struct mthca_qp *qp;
+ int err;
+
+ if (init_attr->create_flags)
+ return ERR_PTR(-EINVAL);
+
+ switch (init_attr->qp_type) {
+ case IB_QPT_RC:
+ case IB_QPT_UC:
+ case IB_QPT_UD:
+ {
+ struct mthca_ucontext *context;
+
+ qp = kmalloc(sizeof *qp, GFP_KERNEL);
+ if (!qp)
+ return ERR_PTR(-ENOMEM);
+
+ if (pd->uobject) {
+ context = to_mucontext(pd->uobject->context);
+
+ if (ib_copy_from_udata(&ucmd, udata, sizeof ucmd)) {
+ kfree(qp);
+ return ERR_PTR(-EFAULT);
+ }
+
+ err = mthca_map_user_db(to_mdev(pd->device), &context->uar,
+ context->db_tab,
+ ucmd.sq_db_index, ucmd.sq_db_page);
+ if (err) {
+ kfree(qp);
+ return ERR_PTR(err);
+ }
+
+ err = mthca_map_user_db(to_mdev(pd->device), &context->uar,
+ context->db_tab,
+ ucmd.rq_db_index, ucmd.rq_db_page);
+ if (err) {
+ mthca_unmap_user_db(to_mdev(pd->device),
+ &context->uar,
+ context->db_tab,
+ ucmd.sq_db_index);
+ kfree(qp);
+ return ERR_PTR(err);
+ }
+
+ qp->mr.ibmr.lkey = ucmd.lkey;
+ qp->sq.db_index = ucmd.sq_db_index;
+ qp->rq.db_index = ucmd.rq_db_index;
+ }
+
+ err = mthca_alloc_qp(to_mdev(pd->device), to_mpd(pd),
+ to_mcq(init_attr->send_cq),
+ to_mcq(init_attr->recv_cq),
+ init_attr->qp_type, init_attr->sq_sig_type,
+ &init_attr->cap, qp);
+
+ if (err && pd->uobject) {
+ context = to_mucontext(pd->uobject->context);
+
+ mthca_unmap_user_db(to_mdev(pd->device),
+ &context->uar,
+ context->db_tab,
+ ucmd.sq_db_index);
+ mthca_unmap_user_db(to_mdev(pd->device),
+ &context->uar,
+ context->db_tab,
+ ucmd.rq_db_index);
+ }
+
+ qp->ibqp.qp_num = qp->qpn;
+ break;
+ }
+ case IB_QPT_SMI:
+ case IB_QPT_GSI:
+ {
+ /* Don't allow userspace to create special QPs */
+ if (pd->uobject)
+ return ERR_PTR(-EINVAL);
+
+ qp = kmalloc(sizeof (struct mthca_sqp), GFP_KERNEL);
+ if (!qp)
+ return ERR_PTR(-ENOMEM);
+
+ qp->ibqp.qp_num = init_attr->qp_type == IB_QPT_SMI ? 0 : 1;
+
+ err = mthca_alloc_sqp(to_mdev(pd->device), to_mpd(pd),
+ to_mcq(init_attr->send_cq),
+ to_mcq(init_attr->recv_cq),
+ init_attr->sq_sig_type, &init_attr->cap,
+ qp->ibqp.qp_num, init_attr->port_num,
+ to_msqp(qp));
+ break;
+ }
+ default:
+ /* Don't support raw QPs */
+ return ERR_PTR(-ENOSYS);
+ }
+
+ if (err) {
+ kfree(qp);
+ return ERR_PTR(err);
+ }
+
+ init_attr->cap.max_send_wr = qp->sq.max;
+ init_attr->cap.max_recv_wr = qp->rq.max;
+ init_attr->cap.max_send_sge = qp->sq.max_gs;
+ init_attr->cap.max_recv_sge = qp->rq.max_gs;
+ init_attr->cap.max_inline_data = qp->max_inline_data;
+
+ return &qp->ibqp;
+}
+
+static int mthca_destroy_qp(struct ib_qp *qp)
+{
+ if (qp->uobject) {
+ mthca_unmap_user_db(to_mdev(qp->device),
+ &to_mucontext(qp->uobject->context)->uar,
+ to_mucontext(qp->uobject->context)->db_tab,
+ to_mqp(qp)->sq.db_index);
+ mthca_unmap_user_db(to_mdev(qp->device),
+ &to_mucontext(qp->uobject->context)->uar,
+ to_mucontext(qp->uobject->context)->db_tab,
+ to_mqp(qp)->rq.db_index);
+ }
+ mthca_free_qp(to_mdev(qp->device), to_mqp(qp));
+ kfree(qp);
+ return 0;
+}
+
+static struct ib_cq *mthca_create_cq(struct ib_device *ibdev,
+ const struct ib_cq_init_attr *attr,
+ struct ib_ucontext *context,
+ struct ib_udata *udata)
+{
+ int entries = attr->cqe;
+ struct mthca_create_cq ucmd;
+ struct mthca_cq *cq;
+ int nent;
+ int err;
+
+ if (attr->flags)
+ return ERR_PTR(-EINVAL);
+
+ if (entries < 1 || entries > to_mdev(ibdev)->limits.max_cqes)
+ return ERR_PTR(-EINVAL);
+
+ if (context) {
+ if (ib_copy_from_udata(&ucmd, udata, sizeof ucmd))
+ return ERR_PTR(-EFAULT);
+
+ err = mthca_map_user_db(to_mdev(ibdev), &to_mucontext(context)->uar,
+ to_mucontext(context)->db_tab,
+ ucmd.set_db_index, ucmd.set_db_page);
+ if (err)
+ return ERR_PTR(err);
+
+ err = mthca_map_user_db(to_mdev(ibdev), &to_mucontext(context)->uar,
+ to_mucontext(context)->db_tab,
+ ucmd.arm_db_index, ucmd.arm_db_page);
+ if (err)
+ goto err_unmap_set;
+ }
+
+ cq = kmalloc(sizeof *cq, GFP_KERNEL);
+ if (!cq) {
+ err = -ENOMEM;
+ goto err_unmap_arm;
+ }
+
+ if (context) {
+ cq->buf.mr.ibmr.lkey = ucmd.lkey;
+ cq->set_ci_db_index = ucmd.set_db_index;
+ cq->arm_db_index = ucmd.arm_db_index;
+ }
+
+ for (nent = 1; nent <= entries; nent <<= 1)
+ ; /* nothing */
+
+ err = mthca_init_cq(to_mdev(ibdev), nent,
+ context ? to_mucontext(context) : NULL,
+ context ? ucmd.pdn : to_mdev(ibdev)->driver_pd.pd_num,
+ cq);
+ if (err)
+ goto err_free;
+
+ if (context && ib_copy_to_udata(udata, &cq->cqn, sizeof (__u32))) {
+ mthca_free_cq(to_mdev(ibdev), cq);
+ err = -EFAULT;
+ goto err_free;
+ }
+
+ cq->resize_buf = NULL;
+
+ return &cq->ibcq;
+
+err_free:
+ kfree(cq);
+
+err_unmap_arm:
+ if (context)
+ mthca_unmap_user_db(to_mdev(ibdev), &to_mucontext(context)->uar,
+ to_mucontext(context)->db_tab, ucmd.arm_db_index);
+
+err_unmap_set:
+ if (context)
+ mthca_unmap_user_db(to_mdev(ibdev), &to_mucontext(context)->uar,
+ to_mucontext(context)->db_tab, ucmd.set_db_index);
+
+ return ERR_PTR(err);
+}
+
+static int mthca_alloc_resize_buf(struct mthca_dev *dev, struct mthca_cq *cq,
+ int entries)
+{
+ int ret;
+
+ spin_lock_irq(&cq->lock);
+ if (cq->resize_buf) {
+ ret = -EBUSY;
+ goto unlock;
+ }
+
+ cq->resize_buf = kmalloc(sizeof *cq->resize_buf, GFP_ATOMIC);
+ if (!cq->resize_buf) {
+ ret = -ENOMEM;
+ goto unlock;
+ }
+
+ cq->resize_buf->state = CQ_RESIZE_ALLOC;
+
+ ret = 0;
+
+unlock:
+ spin_unlock_irq(&cq->lock);
+
+ if (ret)
+ return ret;
+
+ ret = mthca_alloc_cq_buf(dev, &cq->resize_buf->buf, entries);
+ if (ret) {
+ spin_lock_irq(&cq->lock);
+ kfree(cq->resize_buf);
+ cq->resize_buf = NULL;
+ spin_unlock_irq(&cq->lock);
+ return ret;
+ }
+
+ cq->resize_buf->cqe = entries - 1;
+
+ spin_lock_irq(&cq->lock);
+ cq->resize_buf->state = CQ_RESIZE_READY;
+ spin_unlock_irq(&cq->lock);
+
+ return 0;
+}
+
+static int mthca_resize_cq(struct ib_cq *ibcq, int entries, struct ib_udata *udata)
+{
+ struct mthca_dev *dev = to_mdev(ibcq->device);
+ struct mthca_cq *cq = to_mcq(ibcq);
+ struct mthca_resize_cq ucmd;
+ u32 lkey;
+ int ret;
+
+ if (entries < 1 || entries > dev->limits.max_cqes)
+ return -EINVAL;
+
+ mutex_lock(&cq->mutex);
+
+ entries = roundup_pow_of_two(entries + 1);
+ if (entries == ibcq->cqe + 1) {
+ ret = 0;
+ goto out;
+ }
+
+ if (cq->is_kernel) {
+ ret = mthca_alloc_resize_buf(dev, cq, entries);
+ if (ret)
+ goto out;
+ lkey = cq->resize_buf->buf.mr.ibmr.lkey;
+ } else {
+ if (ib_copy_from_udata(&ucmd, udata, sizeof ucmd)) {
+ ret = -EFAULT;
+ goto out;
+ }
+ lkey = ucmd.lkey;
+ }
+
+ ret = mthca_RESIZE_CQ(dev, cq->cqn, lkey, ilog2(entries));
+
+ if (ret) {
+ if (cq->resize_buf) {
+ mthca_free_cq_buf(dev, &cq->resize_buf->buf,
+ cq->resize_buf->cqe);
+ kfree(cq->resize_buf);
+ spin_lock_irq(&cq->lock);
+ cq->resize_buf = NULL;
+ spin_unlock_irq(&cq->lock);
+ }
+ goto out;
+ }
+
+ if (cq->is_kernel) {
+ struct mthca_cq_buf tbuf;
+ int tcqe;
+
+ spin_lock_irq(&cq->lock);
+ if (cq->resize_buf->state == CQ_RESIZE_READY) {
+ mthca_cq_resize_copy_cqes(cq);
+ tbuf = cq->buf;
+ tcqe = cq->ibcq.cqe;
+ cq->buf = cq->resize_buf->buf;
+ cq->ibcq.cqe = cq->resize_buf->cqe;
+ } else {
+ tbuf = cq->resize_buf->buf;
+ tcqe = cq->resize_buf->cqe;
+ }
+
+ kfree(cq->resize_buf);
+ cq->resize_buf = NULL;
+ spin_unlock_irq(&cq->lock);
+
+ mthca_free_cq_buf(dev, &tbuf, tcqe);
+ } else
+ ibcq->cqe = entries - 1;
+
+out:
+ mutex_unlock(&cq->mutex);
+
+ return ret;
+}
+
+static int mthca_destroy_cq(struct ib_cq *cq)
+{
+ if (cq->uobject) {
+ mthca_unmap_user_db(to_mdev(cq->device),
+ &to_mucontext(cq->uobject->context)->uar,
+ to_mucontext(cq->uobject->context)->db_tab,
+ to_mcq(cq)->arm_db_index);
+ mthca_unmap_user_db(to_mdev(cq->device),
+ &to_mucontext(cq->uobject->context)->uar,
+ to_mucontext(cq->uobject->context)->db_tab,
+ to_mcq(cq)->set_ci_db_index);
+ }
+ mthca_free_cq(to_mdev(cq->device), to_mcq(cq));
+ kfree(cq);
+
+ return 0;
+}
+
+static inline u32 convert_access(int acc)
+{
+ return (acc & IB_ACCESS_REMOTE_ATOMIC ? MTHCA_MPT_FLAG_ATOMIC : 0) |
+ (acc & IB_ACCESS_REMOTE_WRITE ? MTHCA_MPT_FLAG_REMOTE_WRITE : 0) |
+ (acc & IB_ACCESS_REMOTE_READ ? MTHCA_MPT_FLAG_REMOTE_READ : 0) |
+ (acc & IB_ACCESS_LOCAL_WRITE ? MTHCA_MPT_FLAG_LOCAL_WRITE : 0) |
+ MTHCA_MPT_FLAG_LOCAL_READ;
+}
+
+static struct ib_mr *mthca_get_dma_mr(struct ib_pd *pd, int acc)
+{
+ struct mthca_mr *mr;
+ int err;
+
+ mr = kmalloc(sizeof *mr, GFP_KERNEL);
+ if (!mr)
+ return ERR_PTR(-ENOMEM);
+
+ err = mthca_mr_alloc_notrans(to_mdev(pd->device),
+ to_mpd(pd)->pd_num,
+ convert_access(acc), mr);
+
+ if (err) {
+ kfree(mr);
+ return ERR_PTR(err);
+ }
+
+ mr->umem = NULL;
+
+ return &mr->ibmr;
+}
+
+static struct ib_mr *mthca_reg_user_mr(struct ib_pd *pd, u64 start, u64 length,
+ u64 virt, int acc, struct ib_udata *udata)
+{
+ struct mthca_dev *dev = to_mdev(pd->device);
+ struct scatterlist *sg;
+ struct mthca_mr *mr;
+ struct mthca_reg_mr ucmd;
+ u64 *pages;
+ int shift, n, len;
+ int i, k, entry;
+ int err = 0;
+ int write_mtt_size;
+
+ if (udata->inlen - sizeof (struct ib_uverbs_cmd_hdr) < sizeof ucmd) {
+ if (!to_mucontext(pd->uobject->context)->reg_mr_warned) {
+ mthca_warn(dev, "Process '%s' did not pass in MR attrs.\n",
+ current->comm);
+ mthca_warn(dev, " Update libmthca to fix this.\n");
+ }
+ ++to_mucontext(pd->uobject->context)->reg_mr_warned;
+ ucmd.mr_attrs = 0;
+ } else if (ib_copy_from_udata(&ucmd, udata, sizeof ucmd))
+ return ERR_PTR(-EFAULT);
+
+ mr = kmalloc(sizeof *mr, GFP_KERNEL);
+ if (!mr)
+ return ERR_PTR(-ENOMEM);
+
+ mr->umem = ib_umem_get(pd->uobject->context, start, length, acc,
+ ucmd.mr_attrs & MTHCA_MR_DMASYNC);
+
+ if (IS_ERR(mr->umem)) {
+ err = PTR_ERR(mr->umem);
+ goto err;
+ }
+
+ shift = ffs(mr->umem->page_size) - 1;
+ n = mr->umem->nmap;
+
+ mr->mtt = mthca_alloc_mtt(dev, n);
+ if (IS_ERR(mr->mtt)) {
+ err = PTR_ERR(mr->mtt);
+ goto err_umem;
+ }
+
+ pages = (u64 *) __get_free_page(GFP_KERNEL);
+ if (!pages) {
+ err = -ENOMEM;
+ goto err_mtt;
+ }
+
+ i = n = 0;
+
+ write_mtt_size = min(mthca_write_mtt_size(dev), (int) (PAGE_SIZE / sizeof *pages));
+
+ for_each_sg(mr->umem->sg_head.sgl, sg, mr->umem->nmap, entry) {
+ len = sg_dma_len(sg) >> shift;
+ for (k = 0; k < len; ++k) {
+ pages[i++] = sg_dma_address(sg) +
+ mr->umem->page_size * k;
+ /*
+ * Be friendly to write_mtt and pass it chunks
+ * of appropriate size.
+ */
+ if (i == write_mtt_size) {
+ err = mthca_write_mtt(dev, mr->mtt, n, pages, i);
+ if (err)
+ goto mtt_done;
+ n += i;
+ i = 0;
+ }
+ }
+ }
+
+ if (i)
+ err = mthca_write_mtt(dev, mr->mtt, n, pages, i);
+mtt_done:
+ free_page((unsigned long) pages);
+ if (err)
+ goto err_mtt;
+
+ err = mthca_mr_alloc(dev, to_mpd(pd)->pd_num, shift, virt, length,
+ convert_access(acc), mr);
+
+ if (err)
+ goto err_mtt;
+
+ return &mr->ibmr;
+
+err_mtt:
+ mthca_free_mtt(dev, mr->mtt);
+
+err_umem:
+ ib_umem_release(mr->umem);
+
+err:
+ kfree(mr);
+ return ERR_PTR(err);
+}
+
+static int mthca_dereg_mr(struct ib_mr *mr)
+{
+ struct mthca_mr *mmr = to_mmr(mr);
+
+ mthca_free_mr(to_mdev(mr->device), mmr);
+ if (mmr->umem)
+ ib_umem_release(mmr->umem);
+ kfree(mmr);
+
+ return 0;
+}
+
+static struct ib_fmr *mthca_alloc_fmr(struct ib_pd *pd, int mr_access_flags,
+ struct ib_fmr_attr *fmr_attr)
+{
+ struct mthca_fmr *fmr;
+ int err;
+
+ fmr = kmalloc(sizeof *fmr, GFP_KERNEL);
+ if (!fmr)
+ return ERR_PTR(-ENOMEM);
+
+ memcpy(&fmr->attr, fmr_attr, sizeof *fmr_attr);
+ err = mthca_fmr_alloc(to_mdev(pd->device), to_mpd(pd)->pd_num,
+ convert_access(mr_access_flags), fmr);
+
+ if (err) {
+ kfree(fmr);
+ return ERR_PTR(err);
+ }
+
+ return &fmr->ibmr;
+}
+
+static int mthca_dealloc_fmr(struct ib_fmr *fmr)
+{
+ struct mthca_fmr *mfmr = to_mfmr(fmr);
+ int err;
+
+ err = mthca_free_fmr(to_mdev(fmr->device), mfmr);
+ if (err)
+ return err;
+
+ kfree(mfmr);
+ return 0;
+}
+
+static int mthca_unmap_fmr(struct list_head *fmr_list)
+{
+ struct ib_fmr *fmr;
+ int err;
+ struct mthca_dev *mdev = NULL;
+
+ list_for_each_entry(fmr, fmr_list, list) {
+ if (mdev && to_mdev(fmr->device) != mdev)
+ return -EINVAL;
+ mdev = to_mdev(fmr->device);
+ }
+
+ if (!mdev)
+ return 0;
+
+ if (mthca_is_memfree(mdev)) {
+ list_for_each_entry(fmr, fmr_list, list)
+ mthca_arbel_fmr_unmap(mdev, to_mfmr(fmr));
+
+ wmb();
+ } else
+ list_for_each_entry(fmr, fmr_list, list)
+ mthca_tavor_fmr_unmap(mdev, to_mfmr(fmr));
+
+ err = mthca_SYNC_TPT(mdev);
+ return err;
+}
+
+static ssize_t show_rev(struct device *device, struct device_attribute *attr,
+ char *buf)
+{
+ struct mthca_dev *dev =
+ container_of(device, struct mthca_dev, ib_dev.dev);
+ return sprintf(buf, "%x\n", dev->rev_id);
+}
+
+static ssize_t show_hca(struct device *device, struct device_attribute *attr,
+ char *buf)
+{
+ struct mthca_dev *dev =
+ container_of(device, struct mthca_dev, ib_dev.dev);
+ switch (dev->pdev->device) {
+ case PCI_DEVICE_ID_MELLANOX_TAVOR:
+ return sprintf(buf, "MT23108\n");
+ case PCI_DEVICE_ID_MELLANOX_ARBEL_COMPAT:
+ return sprintf(buf, "MT25208 (MT23108 compat mode)\n");
+ case PCI_DEVICE_ID_MELLANOX_ARBEL:
+ return sprintf(buf, "MT25208\n");
+ case PCI_DEVICE_ID_MELLANOX_SINAI:
+ case PCI_DEVICE_ID_MELLANOX_SINAI_OLD:
+ return sprintf(buf, "MT25204\n");
+ default:
+ return sprintf(buf, "unknown\n");
+ }
+}
+
+static ssize_t show_board(struct device *device, struct device_attribute *attr,
+ char *buf)
+{
+ struct mthca_dev *dev =
+ container_of(device, struct mthca_dev, ib_dev.dev);
+ return sprintf(buf, "%.*s\n", MTHCA_BOARD_ID_LEN, dev->board_id);
+}
+
+static DEVICE_ATTR(hw_rev, S_IRUGO, show_rev, NULL);
+static DEVICE_ATTR(hca_type, S_IRUGO, show_hca, NULL);
+static DEVICE_ATTR(board_id, S_IRUGO, show_board, NULL);
+
+static struct device_attribute *mthca_dev_attributes[] = {
+ &dev_attr_hw_rev,
+ &dev_attr_hca_type,
+ &dev_attr_board_id
+};
+
+static int mthca_init_node_data(struct mthca_dev *dev)
+{
+ struct ib_smp *in_mad = NULL;
+ struct ib_smp *out_mad = NULL;
+ int err = -ENOMEM;
+
+ in_mad = kzalloc(sizeof *in_mad, GFP_KERNEL);
+ out_mad = kmalloc(sizeof *out_mad, GFP_KERNEL);
+ if (!in_mad || !out_mad)
+ goto out;
+
+ init_query_mad(in_mad);
+ in_mad->attr_id = IB_SMP_ATTR_NODE_DESC;
+
+ err = mthca_MAD_IFC(dev, 1, 1,
+ 1, NULL, NULL, in_mad, out_mad);
+ if (err)
+ goto out;
+
+ memcpy(dev->ib_dev.node_desc, out_mad->data, IB_DEVICE_NODE_DESC_MAX);
+
+ in_mad->attr_id = IB_SMP_ATTR_NODE_INFO;
+
+ err = mthca_MAD_IFC(dev, 1, 1,
+ 1, NULL, NULL, in_mad, out_mad);
+ if (err)
+ goto out;
+
+ if (mthca_is_memfree(dev))
+ dev->rev_id = be32_to_cpup((__be32 *) (out_mad->data + 32));
+ memcpy(&dev->ib_dev.node_guid, out_mad->data + 12, 8);
+
+out:
+ kfree(in_mad);
+ kfree(out_mad);
+ return err;
+}
+
+static int mthca_port_immutable(struct ib_device *ibdev, u8 port_num,
+ struct ib_port_immutable *immutable)
+{
+ struct ib_port_attr attr;
+ int err;
+
+ err = mthca_query_port(ibdev, port_num, &attr);
+ if (err)
+ return err;
+
+ immutable->pkey_tbl_len = attr.pkey_tbl_len;
+ immutable->gid_tbl_len = attr.gid_tbl_len;
+ immutable->core_cap_flags = RDMA_CORE_PORT_IBA_IB;
+ immutable->max_mad_size = IB_MGMT_MAD_SIZE;
+
+ return 0;
+}
+
+static void get_dev_fw_str(struct ib_device *device, char *str,
+ size_t str_len)
+{
+ struct mthca_dev *dev =
+ container_of(device, struct mthca_dev, ib_dev);
+ snprintf(str, str_len, "%d.%d.%d",
+ (int) (dev->fw_ver >> 32),
+ (int) (dev->fw_ver >> 16) & 0xffff,
+ (int) dev->fw_ver & 0xffff);
+}
+
+int mthca_register_device(struct mthca_dev *dev)
+{
+ int ret;
+ int i;
+
+ ret = mthca_init_node_data(dev);
+ if (ret)
+ return ret;
+
+ strlcpy(dev->ib_dev.name, "mthca%d", IB_DEVICE_NAME_MAX);
+ dev->ib_dev.owner = THIS_MODULE;
+
+ dev->ib_dev.uverbs_abi_ver = MTHCA_UVERBS_ABI_VERSION;
+ dev->ib_dev.uverbs_cmd_mask =
+ (1ull << IB_USER_VERBS_CMD_GET_CONTEXT) |
+ (1ull << IB_USER_VERBS_CMD_QUERY_DEVICE) |
+ (1ull << IB_USER_VERBS_CMD_QUERY_PORT) |
+ (1ull << IB_USER_VERBS_CMD_ALLOC_PD) |
+ (1ull << IB_USER_VERBS_CMD_DEALLOC_PD) |
+ (1ull << IB_USER_VERBS_CMD_REG_MR) |
+ (1ull << IB_USER_VERBS_CMD_DEREG_MR) |
+ (1ull << IB_USER_VERBS_CMD_CREATE_COMP_CHANNEL) |
+ (1ull << IB_USER_VERBS_CMD_CREATE_CQ) |
+ (1ull << IB_USER_VERBS_CMD_RESIZE_CQ) |
+ (1ull << IB_USER_VERBS_CMD_DESTROY_CQ) |
+ (1ull << IB_USER_VERBS_CMD_CREATE_QP) |
+ (1ull << IB_USER_VERBS_CMD_QUERY_QP) |
+ (1ull << IB_USER_VERBS_CMD_MODIFY_QP) |
+ (1ull << IB_USER_VERBS_CMD_DESTROY_QP) |
+ (1ull << IB_USER_VERBS_CMD_ATTACH_MCAST) |
+ (1ull << IB_USER_VERBS_CMD_DETACH_MCAST);
+ dev->ib_dev.node_type = RDMA_NODE_IB_CA;
+ dev->ib_dev.phys_port_cnt = dev->limits.num_ports;
+ dev->ib_dev.num_comp_vectors = 1;
+ dev->ib_dev.dma_device = &dev->pdev->dev;
+ dev->ib_dev.query_device = mthca_query_device;
+ dev->ib_dev.query_port = mthca_query_port;
+ dev->ib_dev.modify_device = mthca_modify_device;
+ dev->ib_dev.modify_port = mthca_modify_port;
+ dev->ib_dev.query_pkey = mthca_query_pkey;
+ dev->ib_dev.query_gid = mthca_query_gid;
+ dev->ib_dev.alloc_ucontext = mthca_alloc_ucontext;
+ dev->ib_dev.dealloc_ucontext = mthca_dealloc_ucontext;
+ dev->ib_dev.mmap = mthca_mmap_uar;
+ dev->ib_dev.alloc_pd = mthca_alloc_pd;
+ dev->ib_dev.dealloc_pd = mthca_dealloc_pd;
+ dev->ib_dev.create_ah = mthca_ah_create;
+ dev->ib_dev.query_ah = mthca_ah_query;
+ dev->ib_dev.destroy_ah = mthca_ah_destroy;
+
+ if (dev->mthca_flags & MTHCA_FLAG_SRQ) {
+ dev->ib_dev.create_srq = mthca_create_srq;
+ dev->ib_dev.modify_srq = mthca_modify_srq;
+ dev->ib_dev.query_srq = mthca_query_srq;
+ dev->ib_dev.destroy_srq = mthca_destroy_srq;
+ dev->ib_dev.uverbs_cmd_mask |=
+ (1ull << IB_USER_VERBS_CMD_CREATE_SRQ) |
+ (1ull << IB_USER_VERBS_CMD_MODIFY_SRQ) |
+ (1ull << IB_USER_VERBS_CMD_QUERY_SRQ) |
+ (1ull << IB_USER_VERBS_CMD_DESTROY_SRQ);
+
+ if (mthca_is_memfree(dev))
+ dev->ib_dev.post_srq_recv = mthca_arbel_post_srq_recv;
+ else
+ dev->ib_dev.post_srq_recv = mthca_tavor_post_srq_recv;
+ }
+
+ dev->ib_dev.create_qp = mthca_create_qp;
+ dev->ib_dev.modify_qp = mthca_modify_qp;
+ dev->ib_dev.query_qp = mthca_query_qp;
+ dev->ib_dev.destroy_qp = mthca_destroy_qp;
+ dev->ib_dev.create_cq = mthca_create_cq;
+ dev->ib_dev.resize_cq = mthca_resize_cq;
+ dev->ib_dev.destroy_cq = mthca_destroy_cq;
+ dev->ib_dev.poll_cq = mthca_poll_cq;
+ dev->ib_dev.get_dma_mr = mthca_get_dma_mr;
+ dev->ib_dev.reg_user_mr = mthca_reg_user_mr;
+ dev->ib_dev.dereg_mr = mthca_dereg_mr;
+ dev->ib_dev.get_port_immutable = mthca_port_immutable;
+ dev->ib_dev.get_dev_fw_str = get_dev_fw_str;
+
+ if (dev->mthca_flags & MTHCA_FLAG_FMR) {
+ dev->ib_dev.alloc_fmr = mthca_alloc_fmr;
+ dev->ib_dev.unmap_fmr = mthca_unmap_fmr;
+ dev->ib_dev.dealloc_fmr = mthca_dealloc_fmr;
+ if (mthca_is_memfree(dev))
+ dev->ib_dev.map_phys_fmr = mthca_arbel_map_phys_fmr;
+ else
+ dev->ib_dev.map_phys_fmr = mthca_tavor_map_phys_fmr;
+ }
+
+ dev->ib_dev.attach_mcast = mthca_multicast_attach;
+ dev->ib_dev.detach_mcast = mthca_multicast_detach;
+ dev->ib_dev.process_mad = mthca_process_mad;
+
+ if (mthca_is_memfree(dev)) {
+ dev->ib_dev.req_notify_cq = mthca_arbel_arm_cq;
+ dev->ib_dev.post_send = mthca_arbel_post_send;
+ dev->ib_dev.post_recv = mthca_arbel_post_receive;
+ } else {
+ dev->ib_dev.req_notify_cq = mthca_tavor_arm_cq;
+ dev->ib_dev.post_send = mthca_tavor_post_send;
+ dev->ib_dev.post_recv = mthca_tavor_post_receive;
+ }
+
+ mutex_init(&dev->cap_mask_mutex);
+
+ ret = ib_register_device(&dev->ib_dev, NULL);
+ if (ret)
+ return ret;
+
+ for (i = 0; i < ARRAY_SIZE(mthca_dev_attributes); ++i) {
+ ret = device_create_file(&dev->ib_dev.dev,
+ mthca_dev_attributes[i]);
+ if (ret) {
+ ib_unregister_device(&dev->ib_dev);
+ return ret;
+ }
+ }
+
+ mthca_start_catas_poll(dev);
+
+ return 0;
+}
+
+void mthca_unregister_device(struct mthca_dev *dev)
+{
+ mthca_stop_catas_poll(dev);
+ ib_unregister_device(&dev->ib_dev);
+}
diff --git a/sys/dev/mthca/mthca_provider.h b/sys/dev/mthca/mthca_provider.h
new file mode 100644
index 0000000..3cc3e3e
--- /dev/null
+++ b/sys/dev/mthca/mthca_provider.h
@@ -0,0 +1,346 @@
+/*
+ * Copyright (c) 2004 Topspin Communications. All rights reserved.
+ * Copyright (c) 2005, 2006 Cisco Systems. All rights reserved.
+ * Copyright (c) 2005 Mellanox Technologies. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#ifndef MTHCA_PROVIDER_H
+#define MTHCA_PROVIDER_H
+
+#include <rdma/ib_verbs.h>
+#include <rdma/ib_pack.h>
+
+#include <linux/wait.h>
+
+#define MTHCA_MPT_FLAG_ATOMIC (1 << 14)
+#define MTHCA_MPT_FLAG_REMOTE_WRITE (1 << 13)
+#define MTHCA_MPT_FLAG_REMOTE_READ (1 << 12)
+#define MTHCA_MPT_FLAG_LOCAL_WRITE (1 << 11)
+#define MTHCA_MPT_FLAG_LOCAL_READ (1 << 10)
+
+struct mthca_buf_list {
+ void *buf;
+ DEFINE_DMA_UNMAP_ADDR(mapping);
+};
+
+union mthca_buf {
+ struct mthca_buf_list direct;
+ struct mthca_buf_list *page_list;
+};
+
+struct mthca_uar {
+ unsigned long pfn;
+ int index;
+};
+
+struct mthca_user_db_table;
+
+struct mthca_ucontext {
+ struct ib_ucontext ibucontext;
+ struct mthca_uar uar;
+ struct mthca_user_db_table *db_tab;
+ int reg_mr_warned;
+};
+
+struct mthca_mtt;
+
+struct mthca_mr {
+ struct ib_mr ibmr;
+ struct ib_umem *umem;
+ struct mthca_mtt *mtt;
+};
+
+struct mthca_fmr {
+ struct ib_fmr ibmr;
+ struct ib_fmr_attr attr;
+ struct mthca_mtt *mtt;
+ int maps;
+ union {
+ struct {
+ struct mthca_mpt_entry __iomem *mpt;
+ u64 __iomem *mtts;
+ } tavor;
+ struct {
+ struct mthca_mpt_entry *mpt;
+ __be64 *mtts;
+ dma_addr_t dma_handle;
+ } arbel;
+ } mem;
+};
+
+struct mthca_pd {
+ struct ib_pd ibpd;
+ u32 pd_num;
+ atomic_t sqp_count;
+ struct mthca_mr ntmr;
+ int privileged;
+};
+
+struct mthca_eq {
+ struct mthca_dev *dev;
+ int eqn;
+ u32 eqn_mask;
+ u32 cons_index;
+ u16 msi_x_vector;
+ u16 msi_x_entry;
+ int have_irq;
+ int nent;
+ struct mthca_buf_list *page_list;
+ struct mthca_mr mr;
+ char irq_name[IB_DEVICE_NAME_MAX];
+};
+
+struct mthca_av;
+
+enum mthca_ah_type {
+ MTHCA_AH_ON_HCA,
+ MTHCA_AH_PCI_POOL,
+ MTHCA_AH_KMALLOC
+};
+
+struct mthca_ah {
+ struct ib_ah ibah;
+ enum mthca_ah_type type;
+ u32 key;
+ struct mthca_av *av;
+ dma_addr_t avdma;
+};
+
+/*
+ * Quick description of our CQ/QP locking scheme:
+ *
+ * We have one global lock that protects dev->cq/qp_table. Each
+ * struct mthca_cq/qp also has its own lock. An individual qp lock
+ * may be taken inside of an individual cq lock. Both cqs attached to
+ * a qp may be locked, with the cq with the lower cqn locked first.
+ * No other nesting should be done.
+ *
+ * Each struct mthca_cq/qp also has an ref count, protected by the
+ * corresponding table lock. The pointer from the cq/qp_table to the
+ * struct counts as one reference. This reference also is good for
+ * access through the consumer API, so modifying the CQ/QP etc doesn't
+ * need to take another reference. Access to a QP because of a
+ * completion being polled does not need a reference either.
+ *
+ * Finally, each struct mthca_cq/qp has a wait_queue_head_t for the
+ * destroy function to sleep on.
+ *
+ * This means that access from the consumer API requires nothing but
+ * taking the struct's lock.
+ *
+ * Access because of a completion event should go as follows:
+ * - lock cq/qp_table and look up struct
+ * - increment ref count in struct
+ * - drop cq/qp_table lock
+ * - lock struct, do your thing, and unlock struct
+ * - decrement ref count; if zero, wake up waiters
+ *
+ * To destroy a CQ/QP, we can do the following:
+ * - lock cq/qp_table
+ * - remove pointer and decrement ref count
+ * - unlock cq/qp_table lock
+ * - wait_event until ref count is zero
+ *
+ * It is the consumer's responsibilty to make sure that no QP
+ * operations (WQE posting or state modification) are pending when a
+ * QP is destroyed. Also, the consumer must make sure that calls to
+ * qp_modify are serialized. Similarly, the consumer is responsible
+ * for ensuring that no CQ resize operations are pending when a CQ
+ * is destroyed.
+ *
+ * Possible optimizations (wait for profile data to see if/where we
+ * have locks bouncing between CPUs):
+ * - split cq/qp table lock into n separate (cache-aligned) locks,
+ * indexed (say) by the page in the table
+ * - split QP struct lock into three (one for common info, one for the
+ * send queue and one for the receive queue)
+ */
+
+struct mthca_cq_buf {
+ union mthca_buf queue;
+ struct mthca_mr mr;
+ int is_direct;
+};
+
+struct mthca_cq_resize {
+ struct mthca_cq_buf buf;
+ int cqe;
+ enum {
+ CQ_RESIZE_ALLOC,
+ CQ_RESIZE_READY,
+ CQ_RESIZE_SWAPPED
+ } state;
+};
+
+struct mthca_cq {
+ struct ib_cq ibcq;
+ spinlock_t lock;
+ int refcount;
+ int cqn;
+ u32 cons_index;
+ struct mthca_cq_buf buf;
+ struct mthca_cq_resize *resize_buf;
+ int is_kernel;
+
+ /* Next fields are Arbel only */
+ int set_ci_db_index;
+ __be32 *set_ci_db;
+ int arm_db_index;
+ __be32 *arm_db;
+ int arm_sn;
+
+ wait_queue_head_t wait;
+ struct mutex mutex;
+};
+
+struct mthca_srq {
+ struct ib_srq ibsrq;
+ spinlock_t lock;
+ int refcount;
+ int srqn;
+ int max;
+ int max_gs;
+ int wqe_shift;
+ int first_free;
+ int last_free;
+ u16 counter; /* Arbel only */
+ int db_index; /* Arbel only */
+ __be32 *db; /* Arbel only */
+ void *last;
+
+ int is_direct;
+ u64 *wrid;
+ union mthca_buf queue;
+ struct mthca_mr mr;
+
+ wait_queue_head_t wait;
+ struct mutex mutex;
+};
+
+struct mthca_wq {
+ spinlock_t lock;
+ int max;
+ unsigned next_ind;
+ unsigned last_comp;
+ unsigned head;
+ unsigned tail;
+ void *last;
+ int max_gs;
+ int wqe_shift;
+
+ int db_index; /* Arbel only */
+ __be32 *db;
+};
+
+struct mthca_qp {
+ struct ib_qp ibqp;
+ int refcount;
+ u32 qpn;
+ int is_direct;
+ u8 port; /* for SQP and memfree use only */
+ u8 alt_port; /* for memfree use only */
+ u8 transport;
+ u8 state;
+ u8 atomic_rd_en;
+ u8 resp_depth;
+
+ struct mthca_mr mr;
+
+ struct mthca_wq rq;
+ struct mthca_wq sq;
+ enum ib_sig_type sq_policy;
+ int send_wqe_offset;
+ int max_inline_data;
+
+ u64 *wrid;
+ union mthca_buf queue;
+
+ wait_queue_head_t wait;
+ struct mutex mutex;
+};
+
+struct mthca_sqp {
+ struct mthca_qp qp;
+ int pkey_index;
+ u32 qkey;
+ u32 send_psn;
+ struct ib_ud_header ud_header;
+ int header_buf_size;
+ void *header_buf;
+ dma_addr_t header_dma;
+};
+
+static inline struct mthca_ucontext *to_mucontext(struct ib_ucontext *ibucontext)
+{
+ return container_of(ibucontext, struct mthca_ucontext, ibucontext);
+}
+
+static inline struct mthca_fmr *to_mfmr(struct ib_fmr *ibmr)
+{
+ return container_of(ibmr, struct mthca_fmr, ibmr);
+}
+
+static inline struct mthca_mr *to_mmr(struct ib_mr *ibmr)
+{
+ return container_of(ibmr, struct mthca_mr, ibmr);
+}
+
+static inline struct mthca_pd *to_mpd(struct ib_pd *ibpd)
+{
+ return container_of(ibpd, struct mthca_pd, ibpd);
+}
+
+static inline struct mthca_ah *to_mah(struct ib_ah *ibah)
+{
+ return container_of(ibah, struct mthca_ah, ibah);
+}
+
+static inline struct mthca_cq *to_mcq(struct ib_cq *ibcq)
+{
+ return container_of(ibcq, struct mthca_cq, ibcq);
+}
+
+static inline struct mthca_srq *to_msrq(struct ib_srq *ibsrq)
+{
+ return container_of(ibsrq, struct mthca_srq, ibsrq);
+}
+
+static inline struct mthca_qp *to_mqp(struct ib_qp *ibqp)
+{
+ return container_of(ibqp, struct mthca_qp, ibqp);
+}
+
+static inline struct mthca_sqp *to_msqp(struct mthca_qp *qp)
+{
+ return container_of(qp, struct mthca_sqp, qp);
+}
+
+#endif /* MTHCA_PROVIDER_H */
diff --git a/sys/dev/mthca/mthca_qp.c b/sys/dev/mthca/mthca_qp.c
new file mode 100644
index 0000000..96e5fb9
--- /dev/null
+++ b/sys/dev/mthca/mthca_qp.c
@@ -0,0 +1,2311 @@
+/*
+ * Copyright (c) 2004 Topspin Communications. All rights reserved.
+ * Copyright (c) 2005 Cisco Systems. All rights reserved.
+ * Copyright (c) 2005 Mellanox Technologies. All rights reserved.
+ * Copyright (c) 2004 Voltaire, Inc. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#include <linux/string.h>
+#include <linux/slab.h>
+#include <linux/sched.h>
+
+#include <asm/io.h>
+
+#include <rdma/ib_verbs.h>
+#include <rdma/ib_cache.h>
+#include <rdma/ib_pack.h>
+
+#include "mthca_dev.h"
+#include "mthca_cmd.h"
+#include "mthca_memfree.h"
+#include "mthca_wqe.h"
+
+enum {
+ MTHCA_MAX_DIRECT_QP_SIZE = 4 * PAGE_SIZE,
+ MTHCA_ACK_REQ_FREQ = 10,
+ MTHCA_FLIGHT_LIMIT = 9,
+ MTHCA_UD_HEADER_SIZE = 72, /* largest UD header possible */
+ MTHCA_INLINE_HEADER_SIZE = 4, /* data segment overhead for inline */
+ MTHCA_INLINE_CHUNK_SIZE = 16 /* inline data segment chunk */
+};
+
+enum {
+ MTHCA_QP_STATE_RST = 0,
+ MTHCA_QP_STATE_INIT = 1,
+ MTHCA_QP_STATE_RTR = 2,
+ MTHCA_QP_STATE_RTS = 3,
+ MTHCA_QP_STATE_SQE = 4,
+ MTHCA_QP_STATE_SQD = 5,
+ MTHCA_QP_STATE_ERR = 6,
+ MTHCA_QP_STATE_DRAINING = 7
+};
+
+enum {
+ MTHCA_QP_ST_RC = 0x0,
+ MTHCA_QP_ST_UC = 0x1,
+ MTHCA_QP_ST_RD = 0x2,
+ MTHCA_QP_ST_UD = 0x3,
+ MTHCA_QP_ST_MLX = 0x7
+};
+
+enum {
+ MTHCA_QP_PM_MIGRATED = 0x3,
+ MTHCA_QP_PM_ARMED = 0x0,
+ MTHCA_QP_PM_REARM = 0x1
+};
+
+enum {
+ /* qp_context flags */
+ MTHCA_QP_BIT_DE = 1 << 8,
+ /* params1 */
+ MTHCA_QP_BIT_SRE = 1 << 15,
+ MTHCA_QP_BIT_SWE = 1 << 14,
+ MTHCA_QP_BIT_SAE = 1 << 13,
+ MTHCA_QP_BIT_SIC = 1 << 4,
+ MTHCA_QP_BIT_SSC = 1 << 3,
+ /* params2 */
+ MTHCA_QP_BIT_RRE = 1 << 15,
+ MTHCA_QP_BIT_RWE = 1 << 14,
+ MTHCA_QP_BIT_RAE = 1 << 13,
+ MTHCA_QP_BIT_RIC = 1 << 4,
+ MTHCA_QP_BIT_RSC = 1 << 3
+};
+
+enum {
+ MTHCA_SEND_DOORBELL_FENCE = 1 << 5
+};
+
+struct mthca_qp_path {
+ __be32 port_pkey;
+ u8 rnr_retry;
+ u8 g_mylmc;
+ __be16 rlid;
+ u8 ackto;
+ u8 mgid_index;
+ u8 static_rate;
+ u8 hop_limit;
+ __be32 sl_tclass_flowlabel;
+ u8 rgid[16];
+} __attribute__((packed));
+
+struct mthca_qp_context {
+ __be32 flags;
+ __be32 tavor_sched_queue; /* Reserved on Arbel */
+ u8 mtu_msgmax;
+ u8 rq_size_stride; /* Reserved on Tavor */
+ u8 sq_size_stride; /* Reserved on Tavor */
+ u8 rlkey_arbel_sched_queue; /* Reserved on Tavor */
+ __be32 usr_page;
+ __be32 local_qpn;
+ __be32 remote_qpn;
+ u32 reserved1[2];
+ struct mthca_qp_path pri_path;
+ struct mthca_qp_path alt_path;
+ __be32 rdd;
+ __be32 pd;
+ __be32 wqe_base;
+ __be32 wqe_lkey;
+ __be32 params1;
+ __be32 reserved2;
+ __be32 next_send_psn;
+ __be32 cqn_snd;
+ __be32 snd_wqe_base_l; /* Next send WQE on Tavor */
+ __be32 snd_db_index; /* (debugging only entries) */
+ __be32 last_acked_psn;
+ __be32 ssn;
+ __be32 params2;
+ __be32 rnr_nextrecvpsn;
+ __be32 ra_buff_indx;
+ __be32 cqn_rcv;
+ __be32 rcv_wqe_base_l; /* Next recv WQE on Tavor */
+ __be32 rcv_db_index; /* (debugging only entries) */
+ __be32 qkey;
+ __be32 srqn;
+ __be32 rmsn;
+ __be16 rq_wqe_counter; /* reserved on Tavor */
+ __be16 sq_wqe_counter; /* reserved on Tavor */
+ u32 reserved3[18];
+} __attribute__((packed));
+
+struct mthca_qp_param {
+ __be32 opt_param_mask;
+ u32 reserved1;
+ struct mthca_qp_context context;
+ u32 reserved2[62];
+} __attribute__((packed));
+
+enum {
+ MTHCA_QP_OPTPAR_ALT_ADDR_PATH = 1 << 0,
+ MTHCA_QP_OPTPAR_RRE = 1 << 1,
+ MTHCA_QP_OPTPAR_RAE = 1 << 2,
+ MTHCA_QP_OPTPAR_RWE = 1 << 3,
+ MTHCA_QP_OPTPAR_PKEY_INDEX = 1 << 4,
+ MTHCA_QP_OPTPAR_Q_KEY = 1 << 5,
+ MTHCA_QP_OPTPAR_RNR_TIMEOUT = 1 << 6,
+ MTHCA_QP_OPTPAR_PRIMARY_ADDR_PATH = 1 << 7,
+ MTHCA_QP_OPTPAR_SRA_MAX = 1 << 8,
+ MTHCA_QP_OPTPAR_RRA_MAX = 1 << 9,
+ MTHCA_QP_OPTPAR_PM_STATE = 1 << 10,
+ MTHCA_QP_OPTPAR_PORT_NUM = 1 << 11,
+ MTHCA_QP_OPTPAR_RETRY_COUNT = 1 << 12,
+ MTHCA_QP_OPTPAR_ALT_RNR_RETRY = 1 << 13,
+ MTHCA_QP_OPTPAR_ACK_TIMEOUT = 1 << 14,
+ MTHCA_QP_OPTPAR_RNR_RETRY = 1 << 15,
+ MTHCA_QP_OPTPAR_SCHED_QUEUE = 1 << 16
+};
+
+static const u8 mthca_opcode[] = {
+ [IB_WR_SEND] = MTHCA_OPCODE_SEND,
+ [IB_WR_SEND_WITH_IMM] = MTHCA_OPCODE_SEND_IMM,
+ [IB_WR_RDMA_WRITE] = MTHCA_OPCODE_RDMA_WRITE,
+ [IB_WR_RDMA_WRITE_WITH_IMM] = MTHCA_OPCODE_RDMA_WRITE_IMM,
+ [IB_WR_RDMA_READ] = MTHCA_OPCODE_RDMA_READ,
+ [IB_WR_ATOMIC_CMP_AND_SWP] = MTHCA_OPCODE_ATOMIC_CS,
+ [IB_WR_ATOMIC_FETCH_AND_ADD] = MTHCA_OPCODE_ATOMIC_FA,
+};
+
+static int is_sqp(struct mthca_dev *dev, struct mthca_qp *qp)
+{
+ return qp->qpn >= dev->qp_table.sqp_start &&
+ qp->qpn <= dev->qp_table.sqp_start + 3;
+}
+
+static int is_qp0(struct mthca_dev *dev, struct mthca_qp *qp)
+{
+ return qp->qpn >= dev->qp_table.sqp_start &&
+ qp->qpn <= dev->qp_table.sqp_start + 1;
+}
+
+static void *get_recv_wqe(struct mthca_qp *qp, int n)
+{
+ if (qp->is_direct)
+ return qp->queue.direct.buf + (n << qp->rq.wqe_shift);
+ else
+ return qp->queue.page_list[(n << qp->rq.wqe_shift) >> PAGE_SHIFT].buf +
+ ((n << qp->rq.wqe_shift) & (PAGE_SIZE - 1));
+}
+
+static void *get_send_wqe(struct mthca_qp *qp, int n)
+{
+ if (qp->is_direct)
+ return qp->queue.direct.buf + qp->send_wqe_offset +
+ (n << qp->sq.wqe_shift);
+ else
+ return qp->queue.page_list[(qp->send_wqe_offset +
+ (n << qp->sq.wqe_shift)) >>
+ PAGE_SHIFT].buf +
+ ((qp->send_wqe_offset + (n << qp->sq.wqe_shift)) &
+ (PAGE_SIZE - 1));
+}
+
+static void mthca_wq_reset(struct mthca_wq *wq)
+{
+ wq->next_ind = 0;
+ wq->last_comp = wq->max - 1;
+ wq->head = 0;
+ wq->tail = 0;
+}
+
+void mthca_qp_event(struct mthca_dev *dev, u32 qpn,
+ enum ib_event_type event_type)
+{
+ struct mthca_qp *qp;
+ struct ib_event event;
+
+ spin_lock(&dev->qp_table.lock);
+ qp = mthca_array_get(&dev->qp_table.qp, qpn & (dev->limits.num_qps - 1));
+ if (qp)
+ ++qp->refcount;
+ spin_unlock(&dev->qp_table.lock);
+
+ if (!qp) {
+ mthca_warn(dev, "Async event %d for bogus QP %08x\n",
+ event_type, qpn);
+ return;
+ }
+
+ if (event_type == IB_EVENT_PATH_MIG)
+ qp->port = qp->alt_port;
+
+ event.device = &dev->ib_dev;
+ event.event = event_type;
+ event.element.qp = &qp->ibqp;
+ if (qp->ibqp.event_handler)
+ qp->ibqp.event_handler(&event, qp->ibqp.qp_context);
+
+ spin_lock(&dev->qp_table.lock);
+ if (!--qp->refcount)
+ wake_up(&qp->wait);
+ spin_unlock(&dev->qp_table.lock);
+}
+
+static int to_mthca_state(enum ib_qp_state ib_state)
+{
+ switch (ib_state) {
+ case IB_QPS_RESET: return MTHCA_QP_STATE_RST;
+ case IB_QPS_INIT: return MTHCA_QP_STATE_INIT;
+ case IB_QPS_RTR: return MTHCA_QP_STATE_RTR;
+ case IB_QPS_RTS: return MTHCA_QP_STATE_RTS;
+ case IB_QPS_SQD: return MTHCA_QP_STATE_SQD;
+ case IB_QPS_SQE: return MTHCA_QP_STATE_SQE;
+ case IB_QPS_ERR: return MTHCA_QP_STATE_ERR;
+ default: return -1;
+ }
+}
+
+enum { RC, UC, UD, RD, RDEE, MLX, NUM_TRANS };
+
+static int to_mthca_st(int transport)
+{
+ switch (transport) {
+ case RC: return MTHCA_QP_ST_RC;
+ case UC: return MTHCA_QP_ST_UC;
+ case UD: return MTHCA_QP_ST_UD;
+ case RD: return MTHCA_QP_ST_RD;
+ case MLX: return MTHCA_QP_ST_MLX;
+ default: return -1;
+ }
+}
+
+static void store_attrs(struct mthca_sqp *sqp, const struct ib_qp_attr *attr,
+ int attr_mask)
+{
+ if (attr_mask & IB_QP_PKEY_INDEX)
+ sqp->pkey_index = attr->pkey_index;
+ if (attr_mask & IB_QP_QKEY)
+ sqp->qkey = attr->qkey;
+ if (attr_mask & IB_QP_SQ_PSN)
+ sqp->send_psn = attr->sq_psn;
+}
+
+static void init_port(struct mthca_dev *dev, int port)
+{
+ int err;
+ struct mthca_init_ib_param param;
+
+ memset(&param, 0, sizeof param);
+
+ param.port_width = dev->limits.port_width_cap;
+ param.vl_cap = dev->limits.vl_cap;
+ param.mtu_cap = dev->limits.mtu_cap;
+ param.gid_cap = dev->limits.gid_table_len;
+ param.pkey_cap = dev->limits.pkey_table_len;
+
+ err = mthca_INIT_IB(dev, &param, port);
+ if (err)
+ mthca_warn(dev, "INIT_IB failed, return code %d.\n", err);
+}
+
+static __be32 get_hw_access_flags(struct mthca_qp *qp, const struct ib_qp_attr *attr,
+ int attr_mask)
+{
+ u8 dest_rd_atomic;
+ u32 access_flags;
+ u32 hw_access_flags = 0;
+
+ if (attr_mask & IB_QP_MAX_DEST_RD_ATOMIC)
+ dest_rd_atomic = attr->max_dest_rd_atomic;
+ else
+ dest_rd_atomic = qp->resp_depth;
+
+ if (attr_mask & IB_QP_ACCESS_FLAGS)
+ access_flags = attr->qp_access_flags;
+ else
+ access_flags = qp->atomic_rd_en;
+
+ if (!dest_rd_atomic)
+ access_flags &= IB_ACCESS_REMOTE_WRITE;
+
+ if (access_flags & IB_ACCESS_REMOTE_READ)
+ hw_access_flags |= MTHCA_QP_BIT_RRE;
+ if (access_flags & IB_ACCESS_REMOTE_ATOMIC)
+ hw_access_flags |= MTHCA_QP_BIT_RAE;
+ if (access_flags & IB_ACCESS_REMOTE_WRITE)
+ hw_access_flags |= MTHCA_QP_BIT_RWE;
+
+ return cpu_to_be32(hw_access_flags);
+}
+
+static inline enum ib_qp_state to_ib_qp_state(int mthca_state)
+{
+ switch (mthca_state) {
+ case MTHCA_QP_STATE_RST: return IB_QPS_RESET;
+ case MTHCA_QP_STATE_INIT: return IB_QPS_INIT;
+ case MTHCA_QP_STATE_RTR: return IB_QPS_RTR;
+ case MTHCA_QP_STATE_RTS: return IB_QPS_RTS;
+ case MTHCA_QP_STATE_DRAINING:
+ case MTHCA_QP_STATE_SQD: return IB_QPS_SQD;
+ case MTHCA_QP_STATE_SQE: return IB_QPS_SQE;
+ case MTHCA_QP_STATE_ERR: return IB_QPS_ERR;
+ default: return -1;
+ }
+}
+
+static inline enum ib_mig_state to_ib_mig_state(int mthca_mig_state)
+{
+ switch (mthca_mig_state) {
+ case 0: return IB_MIG_ARMED;
+ case 1: return IB_MIG_REARM;
+ case 3: return IB_MIG_MIGRATED;
+ default: return -1;
+ }
+}
+
+static int to_ib_qp_access_flags(int mthca_flags)
+{
+ int ib_flags = 0;
+
+ if (mthca_flags & MTHCA_QP_BIT_RRE)
+ ib_flags |= IB_ACCESS_REMOTE_READ;
+ if (mthca_flags & MTHCA_QP_BIT_RWE)
+ ib_flags |= IB_ACCESS_REMOTE_WRITE;
+ if (mthca_flags & MTHCA_QP_BIT_RAE)
+ ib_flags |= IB_ACCESS_REMOTE_ATOMIC;
+
+ return ib_flags;
+}
+
+static void to_ib_ah_attr(struct mthca_dev *dev, struct ib_ah_attr *ib_ah_attr,
+ struct mthca_qp_path *path)
+{
+ memset(ib_ah_attr, 0, sizeof *ib_ah_attr);
+ ib_ah_attr->port_num = (be32_to_cpu(path->port_pkey) >> 24) & 0x3;
+
+ if (ib_ah_attr->port_num == 0 || ib_ah_attr->port_num > dev->limits.num_ports)
+ return;
+
+ ib_ah_attr->dlid = be16_to_cpu(path->rlid);
+ ib_ah_attr->sl = be32_to_cpu(path->sl_tclass_flowlabel) >> 28;
+ ib_ah_attr->src_path_bits = path->g_mylmc & 0x7f;
+ ib_ah_attr->static_rate = mthca_rate_to_ib(dev,
+ path->static_rate & 0xf,
+ ib_ah_attr->port_num);
+ ib_ah_attr->ah_flags = (path->g_mylmc & (1 << 7)) ? IB_AH_GRH : 0;
+ if (ib_ah_attr->ah_flags) {
+ ib_ah_attr->grh.sgid_index = path->mgid_index & (dev->limits.gid_table_len - 1);
+ ib_ah_attr->grh.hop_limit = path->hop_limit;
+ ib_ah_attr->grh.traffic_class =
+ (be32_to_cpu(path->sl_tclass_flowlabel) >> 20) & 0xff;
+ ib_ah_attr->grh.flow_label =
+ be32_to_cpu(path->sl_tclass_flowlabel) & 0xfffff;
+ memcpy(ib_ah_attr->grh.dgid.raw,
+ path->rgid, sizeof ib_ah_attr->grh.dgid.raw);
+ }
+}
+
+int mthca_query_qp(struct ib_qp *ibqp, struct ib_qp_attr *qp_attr, int qp_attr_mask,
+ struct ib_qp_init_attr *qp_init_attr)
+{
+ struct mthca_dev *dev = to_mdev(ibqp->device);
+ struct mthca_qp *qp = to_mqp(ibqp);
+ int err = 0;
+ struct mthca_mailbox *mailbox = NULL;
+ struct mthca_qp_param *qp_param;
+ struct mthca_qp_context *context;
+ int mthca_state;
+
+ mutex_lock(&qp->mutex);
+
+ if (qp->state == IB_QPS_RESET) {
+ qp_attr->qp_state = IB_QPS_RESET;
+ goto done;
+ }
+
+ mailbox = mthca_alloc_mailbox(dev, GFP_KERNEL);
+ if (IS_ERR(mailbox)) {
+ err = PTR_ERR(mailbox);
+ goto out;
+ }
+
+ err = mthca_QUERY_QP(dev, qp->qpn, 0, mailbox);
+ if (err) {
+ mthca_warn(dev, "QUERY_QP failed (%d)\n", err);
+ goto out_mailbox;
+ }
+
+ qp_param = mailbox->buf;
+ context = &qp_param->context;
+ mthca_state = be32_to_cpu(context->flags) >> 28;
+
+ qp->state = to_ib_qp_state(mthca_state);
+ qp_attr->qp_state = qp->state;
+ qp_attr->path_mtu = context->mtu_msgmax >> 5;
+ qp_attr->path_mig_state =
+ to_ib_mig_state((be32_to_cpu(context->flags) >> 11) & 0x3);
+ qp_attr->qkey = be32_to_cpu(context->qkey);
+ qp_attr->rq_psn = be32_to_cpu(context->rnr_nextrecvpsn) & 0xffffff;
+ qp_attr->sq_psn = be32_to_cpu(context->next_send_psn) & 0xffffff;
+ qp_attr->dest_qp_num = be32_to_cpu(context->remote_qpn) & 0xffffff;
+ qp_attr->qp_access_flags =
+ to_ib_qp_access_flags(be32_to_cpu(context->params2));
+
+ if (qp->transport == RC || qp->transport == UC) {
+ to_ib_ah_attr(dev, &qp_attr->ah_attr, &context->pri_path);
+ to_ib_ah_attr(dev, &qp_attr->alt_ah_attr, &context->alt_path);
+ qp_attr->alt_pkey_index =
+ be32_to_cpu(context->alt_path.port_pkey) & 0x7f;
+ qp_attr->alt_port_num = qp_attr->alt_ah_attr.port_num;
+ }
+
+ qp_attr->pkey_index = be32_to_cpu(context->pri_path.port_pkey) & 0x7f;
+ qp_attr->port_num =
+ (be32_to_cpu(context->pri_path.port_pkey) >> 24) & 0x3;
+
+ /* qp_attr->en_sqd_async_notify is only applicable in modify qp */
+ qp_attr->sq_draining = mthca_state == MTHCA_QP_STATE_DRAINING;
+
+ qp_attr->max_rd_atomic = 1 << ((be32_to_cpu(context->params1) >> 21) & 0x7);
+
+ qp_attr->max_dest_rd_atomic =
+ 1 << ((be32_to_cpu(context->params2) >> 21) & 0x7);
+ qp_attr->min_rnr_timer =
+ (be32_to_cpu(context->rnr_nextrecvpsn) >> 24) & 0x1f;
+ qp_attr->timeout = context->pri_path.ackto >> 3;
+ qp_attr->retry_cnt = (be32_to_cpu(context->params1) >> 16) & 0x7;
+ qp_attr->rnr_retry = context->pri_path.rnr_retry >> 5;
+ qp_attr->alt_timeout = context->alt_path.ackto >> 3;
+
+done:
+ qp_attr->cur_qp_state = qp_attr->qp_state;
+ qp_attr->cap.max_send_wr = qp->sq.max;
+ qp_attr->cap.max_recv_wr = qp->rq.max;
+ qp_attr->cap.max_send_sge = qp->sq.max_gs;
+ qp_attr->cap.max_recv_sge = qp->rq.max_gs;
+ qp_attr->cap.max_inline_data = qp->max_inline_data;
+
+ qp_init_attr->cap = qp_attr->cap;
+ qp_init_attr->sq_sig_type = qp->sq_policy;
+
+out_mailbox:
+ mthca_free_mailbox(dev, mailbox);
+
+out:
+ mutex_unlock(&qp->mutex);
+ return err;
+}
+
+static int mthca_path_set(struct mthca_dev *dev, const struct ib_ah_attr *ah,
+ struct mthca_qp_path *path, u8 port)
+{
+ path->g_mylmc = ah->src_path_bits & 0x7f;
+ path->rlid = cpu_to_be16(ah->dlid);
+ path->static_rate = mthca_get_rate(dev, ah->static_rate, port);
+
+ if (ah->ah_flags & IB_AH_GRH) {
+ if (ah->grh.sgid_index >= dev->limits.gid_table_len) {
+ mthca_dbg(dev, "sgid_index (%u) too large. max is %d\n",
+ ah->grh.sgid_index, dev->limits.gid_table_len-1);
+ return -1;
+ }
+
+ path->g_mylmc |= 1 << 7;
+ path->mgid_index = ah->grh.sgid_index;
+ path->hop_limit = ah->grh.hop_limit;
+ path->sl_tclass_flowlabel =
+ cpu_to_be32((ah->sl << 28) |
+ (ah->grh.traffic_class << 20) |
+ (ah->grh.flow_label));
+ memcpy(path->rgid, ah->grh.dgid.raw, 16);
+ } else
+ path->sl_tclass_flowlabel = cpu_to_be32(ah->sl << 28);
+
+ return 0;
+}
+
+static int __mthca_modify_qp(struct ib_qp *ibqp,
+ const struct ib_qp_attr *attr, int attr_mask,
+ enum ib_qp_state cur_state, enum ib_qp_state new_state)
+{
+ struct mthca_dev *dev = to_mdev(ibqp->device);
+ struct mthca_qp *qp = to_mqp(ibqp);
+ struct mthca_mailbox *mailbox;
+ struct mthca_qp_param *qp_param;
+ struct mthca_qp_context *qp_context;
+ u32 sqd_event = 0;
+ int err = -EINVAL;
+
+ mailbox = mthca_alloc_mailbox(dev, GFP_KERNEL);
+ if (IS_ERR(mailbox)) {
+ err = PTR_ERR(mailbox);
+ goto out;
+ }
+ qp_param = mailbox->buf;
+ qp_context = &qp_param->context;
+ memset(qp_param, 0, sizeof *qp_param);
+
+ qp_context->flags = cpu_to_be32((to_mthca_state(new_state) << 28) |
+ (to_mthca_st(qp->transport) << 16));
+ qp_context->flags |= cpu_to_be32(MTHCA_QP_BIT_DE);
+ if (!(attr_mask & IB_QP_PATH_MIG_STATE))
+ qp_context->flags |= cpu_to_be32(MTHCA_QP_PM_MIGRATED << 11);
+ else {
+ qp_param->opt_param_mask |= cpu_to_be32(MTHCA_QP_OPTPAR_PM_STATE);
+ switch (attr->path_mig_state) {
+ case IB_MIG_MIGRATED:
+ qp_context->flags |= cpu_to_be32(MTHCA_QP_PM_MIGRATED << 11);
+ break;
+ case IB_MIG_REARM:
+ qp_context->flags |= cpu_to_be32(MTHCA_QP_PM_REARM << 11);
+ break;
+ case IB_MIG_ARMED:
+ qp_context->flags |= cpu_to_be32(MTHCA_QP_PM_ARMED << 11);
+ break;
+ }
+ }
+
+ /* leave tavor_sched_queue as 0 */
+
+ if (qp->transport == MLX || qp->transport == UD)
+ qp_context->mtu_msgmax = (IB_MTU_2048 << 5) | 11;
+ else if (attr_mask & IB_QP_PATH_MTU) {
+ if (attr->path_mtu < IB_MTU_256 || attr->path_mtu > IB_MTU_2048) {
+ mthca_dbg(dev, "path MTU (%u) is invalid\n",
+ attr->path_mtu);
+ goto out_mailbox;
+ }
+ qp_context->mtu_msgmax = (attr->path_mtu << 5) | 31;
+ }
+
+ if (mthca_is_memfree(dev)) {
+ if (qp->rq.max)
+ qp_context->rq_size_stride = ilog2(qp->rq.max) << 3;
+ qp_context->rq_size_stride |= qp->rq.wqe_shift - 4;
+
+ if (qp->sq.max)
+ qp_context->sq_size_stride = ilog2(qp->sq.max) << 3;
+ qp_context->sq_size_stride |= qp->sq.wqe_shift - 4;
+ }
+
+ /* leave arbel_sched_queue as 0 */
+
+ if (qp->ibqp.uobject)
+ qp_context->usr_page =
+ cpu_to_be32(to_mucontext(qp->ibqp.uobject->context)->uar.index);
+ else
+ qp_context->usr_page = cpu_to_be32(dev->driver_uar.index);
+ qp_context->local_qpn = cpu_to_be32(qp->qpn);
+ if (attr_mask & IB_QP_DEST_QPN) {
+ qp_context->remote_qpn = cpu_to_be32(attr->dest_qp_num);
+ }
+
+ if (qp->transport == MLX)
+ qp_context->pri_path.port_pkey |=
+ cpu_to_be32(qp->port << 24);
+ else {
+ if (attr_mask & IB_QP_PORT) {
+ qp_context->pri_path.port_pkey |=
+ cpu_to_be32(attr->port_num << 24);
+ qp_param->opt_param_mask |= cpu_to_be32(MTHCA_QP_OPTPAR_PORT_NUM);
+ }
+ }
+
+ if (attr_mask & IB_QP_PKEY_INDEX) {
+ qp_context->pri_path.port_pkey |=
+ cpu_to_be32(attr->pkey_index);
+ qp_param->opt_param_mask |= cpu_to_be32(MTHCA_QP_OPTPAR_PKEY_INDEX);
+ }
+
+ if (attr_mask & IB_QP_RNR_RETRY) {
+ qp_context->alt_path.rnr_retry = qp_context->pri_path.rnr_retry =
+ attr->rnr_retry << 5;
+ qp_param->opt_param_mask |= cpu_to_be32(MTHCA_QP_OPTPAR_RNR_RETRY |
+ MTHCA_QP_OPTPAR_ALT_RNR_RETRY);
+ }
+
+ if (attr_mask & IB_QP_AV) {
+ if (mthca_path_set(dev, &attr->ah_attr, &qp_context->pri_path,
+ attr_mask & IB_QP_PORT ? attr->port_num : qp->port))
+ goto out_mailbox;
+
+ qp_param->opt_param_mask |= cpu_to_be32(MTHCA_QP_OPTPAR_PRIMARY_ADDR_PATH);
+ }
+
+ if (ibqp->qp_type == IB_QPT_RC &&
+ cur_state == IB_QPS_INIT && new_state == IB_QPS_RTR) {
+ u8 sched_queue = ibqp->uobject ? 0x2 : 0x1;
+
+ if (mthca_is_memfree(dev))
+ qp_context->rlkey_arbel_sched_queue |= sched_queue;
+ else
+ qp_context->tavor_sched_queue |= cpu_to_be32(sched_queue);
+
+ qp_param->opt_param_mask |=
+ cpu_to_be32(MTHCA_QP_OPTPAR_SCHED_QUEUE);
+ }
+
+ if (attr_mask & IB_QP_TIMEOUT) {
+ qp_context->pri_path.ackto = attr->timeout << 3;
+ qp_param->opt_param_mask |= cpu_to_be32(MTHCA_QP_OPTPAR_ACK_TIMEOUT);
+ }
+
+ if (attr_mask & IB_QP_ALT_PATH) {
+ if (attr->alt_pkey_index >= dev->limits.pkey_table_len) {
+ mthca_dbg(dev, "Alternate P_Key index (%u) too large. max is %d\n",
+ attr->alt_pkey_index, dev->limits.pkey_table_len-1);
+ goto out_mailbox;
+ }
+
+ if (attr->alt_port_num == 0 || attr->alt_port_num > dev->limits.num_ports) {
+ mthca_dbg(dev, "Alternate port number (%u) is invalid\n",
+ attr->alt_port_num);
+ goto out_mailbox;
+ }
+
+ if (mthca_path_set(dev, &attr->alt_ah_attr, &qp_context->alt_path,
+ attr->alt_ah_attr.port_num))
+ goto out_mailbox;
+
+ qp_context->alt_path.port_pkey |= cpu_to_be32(attr->alt_pkey_index |
+ attr->alt_port_num << 24);
+ qp_context->alt_path.ackto = attr->alt_timeout << 3;
+ qp_param->opt_param_mask |= cpu_to_be32(MTHCA_QP_OPTPAR_ALT_ADDR_PATH);
+ }
+
+ /* leave rdd as 0 */
+ qp_context->pd = cpu_to_be32(to_mpd(ibqp->pd)->pd_num);
+ /* leave wqe_base as 0 (we always create an MR based at 0 for WQs) */
+ qp_context->wqe_lkey = cpu_to_be32(qp->mr.ibmr.lkey);
+ qp_context->params1 = cpu_to_be32((MTHCA_ACK_REQ_FREQ << 28) |
+ (MTHCA_FLIGHT_LIMIT << 24) |
+ MTHCA_QP_BIT_SWE);
+ if (qp->sq_policy == IB_SIGNAL_ALL_WR)
+ qp_context->params1 |= cpu_to_be32(MTHCA_QP_BIT_SSC);
+ if (attr_mask & IB_QP_RETRY_CNT) {
+ qp_context->params1 |= cpu_to_be32(attr->retry_cnt << 16);
+ qp_param->opt_param_mask |= cpu_to_be32(MTHCA_QP_OPTPAR_RETRY_COUNT);
+ }
+
+ if (attr_mask & IB_QP_MAX_QP_RD_ATOMIC) {
+ if (attr->max_rd_atomic) {
+ qp_context->params1 |=
+ cpu_to_be32(MTHCA_QP_BIT_SRE |
+ MTHCA_QP_BIT_SAE);
+ qp_context->params1 |=
+ cpu_to_be32(fls(attr->max_rd_atomic - 1) << 21);
+ }
+ qp_param->opt_param_mask |= cpu_to_be32(MTHCA_QP_OPTPAR_SRA_MAX);
+ }
+
+ if (attr_mask & IB_QP_SQ_PSN)
+ qp_context->next_send_psn = cpu_to_be32(attr->sq_psn);
+ qp_context->cqn_snd = cpu_to_be32(to_mcq(ibqp->send_cq)->cqn);
+
+ if (mthca_is_memfree(dev)) {
+ qp_context->snd_wqe_base_l = cpu_to_be32(qp->send_wqe_offset);
+ qp_context->snd_db_index = cpu_to_be32(qp->sq.db_index);
+ }
+
+ if (attr_mask & IB_QP_MAX_DEST_RD_ATOMIC) {
+ if (attr->max_dest_rd_atomic)
+ qp_context->params2 |=
+ cpu_to_be32(fls(attr->max_dest_rd_atomic - 1) << 21);
+
+ qp_param->opt_param_mask |= cpu_to_be32(MTHCA_QP_OPTPAR_RRA_MAX);
+ }
+
+ if (attr_mask & (IB_QP_ACCESS_FLAGS | IB_QP_MAX_DEST_RD_ATOMIC)) {
+ qp_context->params2 |= get_hw_access_flags(qp, attr, attr_mask);
+ qp_param->opt_param_mask |= cpu_to_be32(MTHCA_QP_OPTPAR_RWE |
+ MTHCA_QP_OPTPAR_RRE |
+ MTHCA_QP_OPTPAR_RAE);
+ }
+
+ qp_context->params2 |= cpu_to_be32(MTHCA_QP_BIT_RSC);
+
+ if (ibqp->srq)
+ qp_context->params2 |= cpu_to_be32(MTHCA_QP_BIT_RIC);
+
+ if (attr_mask & IB_QP_MIN_RNR_TIMER) {
+ qp_context->rnr_nextrecvpsn |= cpu_to_be32(attr->min_rnr_timer << 24);
+ qp_param->opt_param_mask |= cpu_to_be32(MTHCA_QP_OPTPAR_RNR_TIMEOUT);
+ }
+ if (attr_mask & IB_QP_RQ_PSN)
+ qp_context->rnr_nextrecvpsn |= cpu_to_be32(attr->rq_psn);
+
+ qp_context->ra_buff_indx =
+ cpu_to_be32(dev->qp_table.rdb_base +
+ ((qp->qpn & (dev->limits.num_qps - 1)) * MTHCA_RDB_ENTRY_SIZE <<
+ dev->qp_table.rdb_shift));
+
+ qp_context->cqn_rcv = cpu_to_be32(to_mcq(ibqp->recv_cq)->cqn);
+
+ if (mthca_is_memfree(dev))
+ qp_context->rcv_db_index = cpu_to_be32(qp->rq.db_index);
+
+ if (attr_mask & IB_QP_QKEY) {
+ qp_context->qkey = cpu_to_be32(attr->qkey);
+ qp_param->opt_param_mask |= cpu_to_be32(MTHCA_QP_OPTPAR_Q_KEY);
+ }
+
+ if (ibqp->srq)
+ qp_context->srqn = cpu_to_be32(1 << 24 |
+ to_msrq(ibqp->srq)->srqn);
+
+ if (cur_state == IB_QPS_RTS && new_state == IB_QPS_SQD &&
+ attr_mask & IB_QP_EN_SQD_ASYNC_NOTIFY &&
+ attr->en_sqd_async_notify)
+ sqd_event = 1 << 31;
+
+ err = mthca_MODIFY_QP(dev, cur_state, new_state, qp->qpn, 0,
+ mailbox, sqd_event);
+ if (err) {
+ mthca_warn(dev, "modify QP %d->%d returned %d.\n",
+ cur_state, new_state, err);
+ goto out_mailbox;
+ }
+
+ qp->state = new_state;
+ if (attr_mask & IB_QP_ACCESS_FLAGS)
+ qp->atomic_rd_en = attr->qp_access_flags;
+ if (attr_mask & IB_QP_MAX_DEST_RD_ATOMIC)
+ qp->resp_depth = attr->max_dest_rd_atomic;
+ if (attr_mask & IB_QP_PORT)
+ qp->port = attr->port_num;
+ if (attr_mask & IB_QP_ALT_PATH)
+ qp->alt_port = attr->alt_port_num;
+
+ if (is_sqp(dev, qp))
+ store_attrs(to_msqp(qp), attr, attr_mask);
+
+ /*
+ * If we moved QP0 to RTR, bring the IB link up; if we moved
+ * QP0 to RESET or ERROR, bring the link back down.
+ */
+ if (is_qp0(dev, qp)) {
+ if (cur_state != IB_QPS_RTR &&
+ new_state == IB_QPS_RTR)
+ init_port(dev, qp->port);
+
+ if (cur_state != IB_QPS_RESET &&
+ cur_state != IB_QPS_ERR &&
+ (new_state == IB_QPS_RESET ||
+ new_state == IB_QPS_ERR))
+ mthca_CLOSE_IB(dev, qp->port);
+ }
+
+ /*
+ * If we moved a kernel QP to RESET, clean up all old CQ
+ * entries and reinitialize the QP.
+ */
+ if (new_state == IB_QPS_RESET && !qp->ibqp.uobject) {
+ mthca_cq_clean(dev, to_mcq(qp->ibqp.recv_cq), qp->qpn,
+ qp->ibqp.srq ? to_msrq(qp->ibqp.srq) : NULL);
+ if (qp->ibqp.send_cq != qp->ibqp.recv_cq)
+ mthca_cq_clean(dev, to_mcq(qp->ibqp.send_cq), qp->qpn, NULL);
+
+ mthca_wq_reset(&qp->sq);
+ qp->sq.last = get_send_wqe(qp, qp->sq.max - 1);
+
+ mthca_wq_reset(&qp->rq);
+ qp->rq.last = get_recv_wqe(qp, qp->rq.max - 1);
+
+ if (mthca_is_memfree(dev)) {
+ *qp->sq.db = 0;
+ *qp->rq.db = 0;
+ }
+ }
+
+out_mailbox:
+ mthca_free_mailbox(dev, mailbox);
+out:
+ return err;
+}
+
+int mthca_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr, int attr_mask,
+ struct ib_udata *udata)
+{
+ struct mthca_dev *dev = to_mdev(ibqp->device);
+ struct mthca_qp *qp = to_mqp(ibqp);
+ enum ib_qp_state cur_state, new_state;
+ int err = -EINVAL;
+
+ mutex_lock(&qp->mutex);
+ if (attr_mask & IB_QP_CUR_STATE) {
+ cur_state = attr->cur_qp_state;
+ } else {
+ spin_lock_irq(&qp->sq.lock);
+ spin_lock(&qp->rq.lock);
+ cur_state = qp->state;
+ spin_unlock(&qp->rq.lock);
+ spin_unlock_irq(&qp->sq.lock);
+ }
+
+ new_state = attr_mask & IB_QP_STATE ? attr->qp_state : cur_state;
+
+ if (!ib_modify_qp_is_ok(cur_state, new_state, ibqp->qp_type, attr_mask,
+ IB_LINK_LAYER_UNSPECIFIED)) {
+ mthca_dbg(dev, "Bad QP transition (transport %d) "
+ "%d->%d with attr 0x%08x\n",
+ qp->transport, cur_state, new_state,
+ attr_mask);
+ goto out;
+ }
+
+ if ((attr_mask & IB_QP_PKEY_INDEX) &&
+ attr->pkey_index >= dev->limits.pkey_table_len) {
+ mthca_dbg(dev, "P_Key index (%u) too large. max is %d\n",
+ attr->pkey_index, dev->limits.pkey_table_len-1);
+ goto out;
+ }
+
+ if ((attr_mask & IB_QP_PORT) &&
+ (attr->port_num == 0 || attr->port_num > dev->limits.num_ports)) {
+ mthca_dbg(dev, "Port number (%u) is invalid\n", attr->port_num);
+ goto out;
+ }
+
+ if (attr_mask & IB_QP_MAX_QP_RD_ATOMIC &&
+ attr->max_rd_atomic > dev->limits.max_qp_init_rdma) {
+ mthca_dbg(dev, "Max rdma_atomic as initiator %u too large (max is %d)\n",
+ attr->max_rd_atomic, dev->limits.max_qp_init_rdma);
+ goto out;
+ }
+
+ if (attr_mask & IB_QP_MAX_DEST_RD_ATOMIC &&
+ attr->max_dest_rd_atomic > 1 << dev->qp_table.rdb_shift) {
+ mthca_dbg(dev, "Max rdma_atomic as responder %u too large (max %d)\n",
+ attr->max_dest_rd_atomic, 1 << dev->qp_table.rdb_shift);
+ goto out;
+ }
+
+ if (cur_state == new_state && cur_state == IB_QPS_RESET) {
+ err = 0;
+ goto out;
+ }
+
+ err = __mthca_modify_qp(ibqp, attr, attr_mask, cur_state, new_state);
+
+out:
+ mutex_unlock(&qp->mutex);
+ return err;
+}
+
+static int mthca_max_data_size(struct mthca_dev *dev, struct mthca_qp *qp, int desc_sz)
+{
+ /*
+ * Calculate the maximum size of WQE s/g segments, excluding
+ * the next segment and other non-data segments.
+ */
+ int max_data_size = desc_sz - sizeof (struct mthca_next_seg);
+
+ switch (qp->transport) {
+ case MLX:
+ max_data_size -= 2 * sizeof (struct mthca_data_seg);
+ break;
+
+ case UD:
+ if (mthca_is_memfree(dev))
+ max_data_size -= sizeof (struct mthca_arbel_ud_seg);
+ else
+ max_data_size -= sizeof (struct mthca_tavor_ud_seg);
+ break;
+
+ default:
+ max_data_size -= sizeof (struct mthca_raddr_seg);
+ break;
+ }
+
+ return max_data_size;
+}
+
+static inline int mthca_max_inline_data(struct mthca_pd *pd, int max_data_size)
+{
+ /* We don't support inline data for kernel QPs (yet). */
+ return pd->ibpd.uobject ? max_data_size - MTHCA_INLINE_HEADER_SIZE : 0;
+}
+
+static void mthca_adjust_qp_caps(struct mthca_dev *dev,
+ struct mthca_pd *pd,
+ struct mthca_qp *qp)
+{
+ int max_data_size = mthca_max_data_size(dev, qp,
+ min(dev->limits.max_desc_sz,
+ 1 << qp->sq.wqe_shift));
+
+ qp->max_inline_data = mthca_max_inline_data(pd, max_data_size);
+
+ qp->sq.max_gs = min_t(int, dev->limits.max_sg,
+ max_data_size / sizeof (struct mthca_data_seg));
+ qp->rq.max_gs = min_t(int, dev->limits.max_sg,
+ (min(dev->limits.max_desc_sz, 1 << qp->rq.wqe_shift) -
+ sizeof (struct mthca_next_seg)) /
+ sizeof (struct mthca_data_seg));
+}
+
+/*
+ * Allocate and register buffer for WQEs. qp->rq.max, sq.max,
+ * rq.max_gs and sq.max_gs must all be assigned.
+ * mthca_alloc_wqe_buf will calculate rq.wqe_shift and
+ * sq.wqe_shift (as well as send_wqe_offset, is_direct, and
+ * queue)
+ */
+static int mthca_alloc_wqe_buf(struct mthca_dev *dev,
+ struct mthca_pd *pd,
+ struct mthca_qp *qp)
+{
+ int size;
+ int err = -ENOMEM;
+
+ size = sizeof (struct mthca_next_seg) +
+ qp->rq.max_gs * sizeof (struct mthca_data_seg);
+
+ if (size > dev->limits.max_desc_sz)
+ return -EINVAL;
+
+ for (qp->rq.wqe_shift = 6; 1 << qp->rq.wqe_shift < size;
+ qp->rq.wqe_shift++)
+ ; /* nothing */
+
+ size = qp->sq.max_gs * sizeof (struct mthca_data_seg);
+ switch (qp->transport) {
+ case MLX:
+ size += 2 * sizeof (struct mthca_data_seg);
+ break;
+
+ case UD:
+ size += mthca_is_memfree(dev) ?
+ sizeof (struct mthca_arbel_ud_seg) :
+ sizeof (struct mthca_tavor_ud_seg);
+ break;
+
+ case UC:
+ size += sizeof (struct mthca_raddr_seg);
+ break;
+
+ case RC:
+ size += sizeof (struct mthca_raddr_seg);
+ /*
+ * An atomic op will require an atomic segment, a
+ * remote address segment and one scatter entry.
+ */
+ size = max_t(int, size,
+ sizeof (struct mthca_atomic_seg) +
+ sizeof (struct mthca_raddr_seg) +
+ sizeof (struct mthca_data_seg));
+ break;
+
+ default:
+ break;
+ }
+
+ /* Make sure that we have enough space for a bind request */
+ size = max_t(int, size, sizeof (struct mthca_bind_seg));
+
+ size += sizeof (struct mthca_next_seg);
+
+ if (size > dev->limits.max_desc_sz)
+ return -EINVAL;
+
+ for (qp->sq.wqe_shift = 6; 1 << qp->sq.wqe_shift < size;
+ qp->sq.wqe_shift++)
+ ; /* nothing */
+
+ qp->send_wqe_offset = ALIGN(qp->rq.max << qp->rq.wqe_shift,
+ 1 << qp->sq.wqe_shift);
+
+ /*
+ * If this is a userspace QP, we don't actually have to
+ * allocate anything. All we need is to calculate the WQE
+ * sizes and the send_wqe_offset, so we're done now.
+ */
+ if (pd->ibpd.uobject)
+ return 0;
+
+ size = PAGE_ALIGN(qp->send_wqe_offset +
+ (qp->sq.max << qp->sq.wqe_shift));
+
+ qp->wrid = kmalloc((qp->rq.max + qp->sq.max) * sizeof (u64),
+ GFP_KERNEL);
+ if (!qp->wrid)
+ goto err_out;
+
+ err = mthca_buf_alloc(dev, size, MTHCA_MAX_DIRECT_QP_SIZE,
+ &qp->queue, &qp->is_direct, pd, 0, &qp->mr);
+ if (err)
+ goto err_out;
+
+ return 0;
+
+err_out:
+ kfree(qp->wrid);
+ return err;
+}
+
+static void mthca_free_wqe_buf(struct mthca_dev *dev,
+ struct mthca_qp *qp)
+{
+ mthca_buf_free(dev, PAGE_ALIGN(qp->send_wqe_offset +
+ (qp->sq.max << qp->sq.wqe_shift)),
+ &qp->queue, qp->is_direct, &qp->mr);
+ kfree(qp->wrid);
+}
+
+static int mthca_map_memfree(struct mthca_dev *dev,
+ struct mthca_qp *qp)
+{
+ int ret;
+
+ if (mthca_is_memfree(dev)) {
+ ret = mthca_table_get(dev, dev->qp_table.qp_table, qp->qpn);
+ if (ret)
+ return ret;
+
+ ret = mthca_table_get(dev, dev->qp_table.eqp_table, qp->qpn);
+ if (ret)
+ goto err_qpc;
+
+ ret = mthca_table_get(dev, dev->qp_table.rdb_table,
+ qp->qpn << dev->qp_table.rdb_shift);
+ if (ret)
+ goto err_eqpc;
+
+ }
+
+ return 0;
+
+err_eqpc:
+ mthca_table_put(dev, dev->qp_table.eqp_table, qp->qpn);
+
+err_qpc:
+ mthca_table_put(dev, dev->qp_table.qp_table, qp->qpn);
+
+ return ret;
+}
+
+static void mthca_unmap_memfree(struct mthca_dev *dev,
+ struct mthca_qp *qp)
+{
+ mthca_table_put(dev, dev->qp_table.rdb_table,
+ qp->qpn << dev->qp_table.rdb_shift);
+ mthca_table_put(dev, dev->qp_table.eqp_table, qp->qpn);
+ mthca_table_put(dev, dev->qp_table.qp_table, qp->qpn);
+}
+
+static int mthca_alloc_memfree(struct mthca_dev *dev,
+ struct mthca_qp *qp)
+{
+ if (mthca_is_memfree(dev)) {
+ qp->rq.db_index = mthca_alloc_db(dev, MTHCA_DB_TYPE_RQ,
+ qp->qpn, &qp->rq.db);
+ if (qp->rq.db_index < 0)
+ return -ENOMEM;
+
+ qp->sq.db_index = mthca_alloc_db(dev, MTHCA_DB_TYPE_SQ,
+ qp->qpn, &qp->sq.db);
+ if (qp->sq.db_index < 0) {
+ mthca_free_db(dev, MTHCA_DB_TYPE_RQ, qp->rq.db_index);
+ return -ENOMEM;
+ }
+ }
+
+ return 0;
+}
+
+static void mthca_free_memfree(struct mthca_dev *dev,
+ struct mthca_qp *qp)
+{
+ if (mthca_is_memfree(dev)) {
+ mthca_free_db(dev, MTHCA_DB_TYPE_SQ, qp->sq.db_index);
+ mthca_free_db(dev, MTHCA_DB_TYPE_RQ, qp->rq.db_index);
+ }
+}
+
+static int mthca_alloc_qp_common(struct mthca_dev *dev,
+ struct mthca_pd *pd,
+ struct mthca_cq *send_cq,
+ struct mthca_cq *recv_cq,
+ enum ib_sig_type send_policy,
+ struct mthca_qp *qp)
+{
+ int ret;
+ int i;
+ struct mthca_next_seg *next;
+
+ qp->refcount = 1;
+ init_waitqueue_head(&qp->wait);
+ mutex_init(&qp->mutex);
+ qp->state = IB_QPS_RESET;
+ qp->atomic_rd_en = 0;
+ qp->resp_depth = 0;
+ qp->sq_policy = send_policy;
+ mthca_wq_reset(&qp->sq);
+ mthca_wq_reset(&qp->rq);
+
+ spin_lock_init(&qp->sq.lock);
+ spin_lock_init(&qp->rq.lock);
+
+ ret = mthca_map_memfree(dev, qp);
+ if (ret)
+ return ret;
+
+ ret = mthca_alloc_wqe_buf(dev, pd, qp);
+ if (ret) {
+ mthca_unmap_memfree(dev, qp);
+ return ret;
+ }
+
+ mthca_adjust_qp_caps(dev, pd, qp);
+
+ /*
+ * If this is a userspace QP, we're done now. The doorbells
+ * will be allocated and buffers will be initialized in
+ * userspace.
+ */
+ if (pd->ibpd.uobject)
+ return 0;
+
+ ret = mthca_alloc_memfree(dev, qp);
+ if (ret) {
+ mthca_free_wqe_buf(dev, qp);
+ mthca_unmap_memfree(dev, qp);
+ return ret;
+ }
+
+ if (mthca_is_memfree(dev)) {
+ struct mthca_data_seg *scatter;
+ int size = (sizeof (struct mthca_next_seg) +
+ qp->rq.max_gs * sizeof (struct mthca_data_seg)) / 16;
+
+ for (i = 0; i < qp->rq.max; ++i) {
+ next = get_recv_wqe(qp, i);
+ next->nda_op = cpu_to_be32(((i + 1) & (qp->rq.max - 1)) <<
+ qp->rq.wqe_shift);
+ next->ee_nds = cpu_to_be32(size);
+
+ for (scatter = (void *) (next + 1);
+ (void *) scatter < (void *) next + (1 << qp->rq.wqe_shift);
+ ++scatter)
+ scatter->lkey = cpu_to_be32(MTHCA_INVAL_LKEY);
+ }
+
+ for (i = 0; i < qp->sq.max; ++i) {
+ next = get_send_wqe(qp, i);
+ next->nda_op = cpu_to_be32((((i + 1) & (qp->sq.max - 1)) <<
+ qp->sq.wqe_shift) +
+ qp->send_wqe_offset);
+ }
+ } else {
+ for (i = 0; i < qp->rq.max; ++i) {
+ next = get_recv_wqe(qp, i);
+ next->nda_op = htonl((((i + 1) % qp->rq.max) <<
+ qp->rq.wqe_shift) | 1);
+ }
+
+ }
+
+ qp->sq.last = get_send_wqe(qp, qp->sq.max - 1);
+ qp->rq.last = get_recv_wqe(qp, qp->rq.max - 1);
+
+ return 0;
+}
+
+static int mthca_set_qp_size(struct mthca_dev *dev, struct ib_qp_cap *cap,
+ struct mthca_pd *pd, struct mthca_qp *qp)
+{
+ int max_data_size = mthca_max_data_size(dev, qp, dev->limits.max_desc_sz);
+
+ /* Sanity check QP size before proceeding */
+ if (cap->max_send_wr > dev->limits.max_wqes ||
+ cap->max_recv_wr > dev->limits.max_wqes ||
+ cap->max_send_sge > dev->limits.max_sg ||
+ cap->max_recv_sge > dev->limits.max_sg ||
+ cap->max_inline_data > mthca_max_inline_data(pd, max_data_size))
+ return -EINVAL;
+
+ /*
+ * For MLX transport we need 2 extra send gather entries:
+ * one for the header and one for the checksum at the end
+ */
+ if (qp->transport == MLX && cap->max_send_sge + 2 > dev->limits.max_sg)
+ return -EINVAL;
+
+ if (mthca_is_memfree(dev)) {
+ qp->rq.max = cap->max_recv_wr ?
+ roundup_pow_of_two(cap->max_recv_wr) : 0;
+ qp->sq.max = cap->max_send_wr ?
+ roundup_pow_of_two(cap->max_send_wr) : 0;
+ } else {
+ qp->rq.max = cap->max_recv_wr;
+ qp->sq.max = cap->max_send_wr;
+ }
+
+ qp->rq.max_gs = cap->max_recv_sge;
+ qp->sq.max_gs = max_t(int, cap->max_send_sge,
+ ALIGN(cap->max_inline_data + MTHCA_INLINE_HEADER_SIZE,
+ MTHCA_INLINE_CHUNK_SIZE) /
+ sizeof (struct mthca_data_seg));
+
+ return 0;
+}
+
+int mthca_alloc_qp(struct mthca_dev *dev,
+ struct mthca_pd *pd,
+ struct mthca_cq *send_cq,
+ struct mthca_cq *recv_cq,
+ enum ib_qp_type type,
+ enum ib_sig_type send_policy,
+ struct ib_qp_cap *cap,
+ struct mthca_qp *qp)
+{
+ int err;
+
+ switch (type) {
+ case IB_QPT_RC: qp->transport = RC; break;
+ case IB_QPT_UC: qp->transport = UC; break;
+ case IB_QPT_UD: qp->transport = UD; break;
+ default: return -EINVAL;
+ }
+
+ err = mthca_set_qp_size(dev, cap, pd, qp);
+ if (err)
+ return err;
+
+ qp->qpn = mthca_alloc(&dev->qp_table.alloc);
+ if (qp->qpn == -1)
+ return -ENOMEM;
+
+ /* initialize port to zero for error-catching. */
+ qp->port = 0;
+
+ err = mthca_alloc_qp_common(dev, pd, send_cq, recv_cq,
+ send_policy, qp);
+ if (err) {
+ mthca_free(&dev->qp_table.alloc, qp->qpn);
+ return err;
+ }
+
+ spin_lock_irq(&dev->qp_table.lock);
+ mthca_array_set(&dev->qp_table.qp,
+ qp->qpn & (dev->limits.num_qps - 1), qp);
+ spin_unlock_irq(&dev->qp_table.lock);
+
+ return 0;
+}
+
+static void mthca_lock_cqs(struct mthca_cq *send_cq, struct mthca_cq *recv_cq)
+ __acquires(&send_cq->lock) __acquires(&recv_cq->lock)
+{
+ if (send_cq == recv_cq) {
+ spin_lock_irq(&send_cq->lock);
+ __acquire(&recv_cq->lock);
+ } else if (send_cq->cqn < recv_cq->cqn) {
+ spin_lock_irq(&send_cq->lock);
+ spin_lock_nested(&recv_cq->lock, SINGLE_DEPTH_NESTING);
+ } else {
+ spin_lock_irq(&recv_cq->lock);
+ spin_lock_nested(&send_cq->lock, SINGLE_DEPTH_NESTING);
+ }
+}
+
+static void mthca_unlock_cqs(struct mthca_cq *send_cq, struct mthca_cq *recv_cq)
+ __releases(&send_cq->lock) __releases(&recv_cq->lock)
+{
+ if (send_cq == recv_cq) {
+ __release(&recv_cq->lock);
+ spin_unlock_irq(&send_cq->lock);
+ } else if (send_cq->cqn < recv_cq->cqn) {
+ spin_unlock(&recv_cq->lock);
+ spin_unlock_irq(&send_cq->lock);
+ } else {
+ spin_unlock(&send_cq->lock);
+ spin_unlock_irq(&recv_cq->lock);
+ }
+}
+
+int mthca_alloc_sqp(struct mthca_dev *dev,
+ struct mthca_pd *pd,
+ struct mthca_cq *send_cq,
+ struct mthca_cq *recv_cq,
+ enum ib_sig_type send_policy,
+ struct ib_qp_cap *cap,
+ int qpn,
+ int port,
+ struct mthca_sqp *sqp)
+{
+ u32 mqpn = qpn * 2 + dev->qp_table.sqp_start + port - 1;
+ int err;
+
+ sqp->qp.transport = MLX;
+ err = mthca_set_qp_size(dev, cap, pd, &sqp->qp);
+ if (err)
+ return err;
+
+ sqp->header_buf_size = sqp->qp.sq.max * MTHCA_UD_HEADER_SIZE;
+ sqp->header_buf = dma_alloc_coherent(&dev->pdev->dev, sqp->header_buf_size,
+ &sqp->header_dma, GFP_KERNEL);
+ if (!sqp->header_buf)
+ return -ENOMEM;
+
+ spin_lock_irq(&dev->qp_table.lock);
+ if (mthca_array_get(&dev->qp_table.qp, mqpn))
+ err = -EBUSY;
+ else
+ mthca_array_set(&dev->qp_table.qp, mqpn, sqp);
+ spin_unlock_irq(&dev->qp_table.lock);
+
+ if (err)
+ goto err_out;
+
+ sqp->qp.port = port;
+ sqp->qp.qpn = mqpn;
+ sqp->qp.transport = MLX;
+
+ err = mthca_alloc_qp_common(dev, pd, send_cq, recv_cq,
+ send_policy, &sqp->qp);
+ if (err)
+ goto err_out_free;
+
+ atomic_inc(&pd->sqp_count);
+
+ return 0;
+
+ err_out_free:
+ /*
+ * Lock CQs here, so that CQ polling code can do QP lookup
+ * without taking a lock.
+ */
+ mthca_lock_cqs(send_cq, recv_cq);
+
+ spin_lock(&dev->qp_table.lock);
+ mthca_array_clear(&dev->qp_table.qp, mqpn);
+ spin_unlock(&dev->qp_table.lock);
+
+ mthca_unlock_cqs(send_cq, recv_cq);
+
+ err_out:
+ dma_free_coherent(&dev->pdev->dev, sqp->header_buf_size,
+ sqp->header_buf, sqp->header_dma);
+
+ return err;
+}
+
+static inline int get_qp_refcount(struct mthca_dev *dev, struct mthca_qp *qp)
+{
+ int c;
+
+ spin_lock_irq(&dev->qp_table.lock);
+ c = qp->refcount;
+ spin_unlock_irq(&dev->qp_table.lock);
+
+ return c;
+}
+
+void mthca_free_qp(struct mthca_dev *dev,
+ struct mthca_qp *qp)
+{
+ struct mthca_cq *send_cq;
+ struct mthca_cq *recv_cq;
+
+ send_cq = to_mcq(qp->ibqp.send_cq);
+ recv_cq = to_mcq(qp->ibqp.recv_cq);
+
+ /*
+ * Lock CQs here, so that CQ polling code can do QP lookup
+ * without taking a lock.
+ */
+ mthca_lock_cqs(send_cq, recv_cq);
+
+ spin_lock(&dev->qp_table.lock);
+ mthca_array_clear(&dev->qp_table.qp,
+ qp->qpn & (dev->limits.num_qps - 1));
+ --qp->refcount;
+ spin_unlock(&dev->qp_table.lock);
+
+ mthca_unlock_cqs(send_cq, recv_cq);
+
+ wait_event(qp->wait, !get_qp_refcount(dev, qp));
+
+ if (qp->state != IB_QPS_RESET)
+ mthca_MODIFY_QP(dev, qp->state, IB_QPS_RESET, qp->qpn, 0,
+ NULL, 0);
+
+ /*
+ * If this is a userspace QP, the buffers, MR, CQs and so on
+ * will be cleaned up in userspace, so all we have to do is
+ * unref the mem-free tables and free the QPN in our table.
+ */
+ if (!qp->ibqp.uobject) {
+ mthca_cq_clean(dev, recv_cq, qp->qpn,
+ qp->ibqp.srq ? to_msrq(qp->ibqp.srq) : NULL);
+ if (send_cq != recv_cq)
+ mthca_cq_clean(dev, send_cq, qp->qpn, NULL);
+
+ mthca_free_memfree(dev, qp);
+ mthca_free_wqe_buf(dev, qp);
+ }
+
+ mthca_unmap_memfree(dev, qp);
+
+ if (is_sqp(dev, qp)) {
+ atomic_dec(&(to_mpd(qp->ibqp.pd)->sqp_count));
+ dma_free_coherent(&dev->pdev->dev,
+ to_msqp(qp)->header_buf_size,
+ to_msqp(qp)->header_buf,
+ to_msqp(qp)->header_dma);
+ } else
+ mthca_free(&dev->qp_table.alloc, qp->qpn);
+}
+
+/* Create UD header for an MLX send and build a data segment for it */
+static int build_mlx_header(struct mthca_dev *dev, struct mthca_sqp *sqp,
+ int ind, struct ib_ud_wr *wr,
+ struct mthca_mlx_seg *mlx,
+ struct mthca_data_seg *data)
+{
+ int header_size;
+ int err;
+ u16 pkey;
+
+ ib_ud_header_init(256, /* assume a MAD */ 1, 0, 0,
+ mthca_ah_grh_present(to_mah(wr->ah)), 0, 0, 0,
+ &sqp->ud_header);
+
+ err = mthca_read_ah(dev, to_mah(wr->ah), &sqp->ud_header);
+ if (err)
+ return err;
+ mlx->flags &= ~cpu_to_be32(MTHCA_NEXT_SOLICIT | 1);
+ mlx->flags |= cpu_to_be32((!sqp->qp.ibqp.qp_num ? MTHCA_MLX_VL15 : 0) |
+ (sqp->ud_header.lrh.destination_lid ==
+ IB_LID_PERMISSIVE ? MTHCA_MLX_SLR : 0) |
+ (sqp->ud_header.lrh.service_level << 8));
+ mlx->rlid = sqp->ud_header.lrh.destination_lid;
+ mlx->vcrc = 0;
+
+ switch (wr->wr.opcode) {
+ case IB_WR_SEND:
+ sqp->ud_header.bth.opcode = IB_OPCODE_UD_SEND_ONLY;
+ sqp->ud_header.immediate_present = 0;
+ break;
+ case IB_WR_SEND_WITH_IMM:
+ sqp->ud_header.bth.opcode = IB_OPCODE_UD_SEND_ONLY_WITH_IMMEDIATE;
+ sqp->ud_header.immediate_present = 1;
+ sqp->ud_header.immediate_data = wr->wr.ex.imm_data;
+ break;
+ default:
+ return -EINVAL;
+ }
+
+ sqp->ud_header.lrh.virtual_lane = !sqp->qp.ibqp.qp_num ? 15 : 0;
+ if (sqp->ud_header.lrh.destination_lid == IB_LID_PERMISSIVE)
+ sqp->ud_header.lrh.source_lid = IB_LID_PERMISSIVE;
+ sqp->ud_header.bth.solicited_event = !!(wr->wr.send_flags & IB_SEND_SOLICITED);
+ if (!sqp->qp.ibqp.qp_num)
+ ib_get_cached_pkey(&dev->ib_dev, sqp->qp.port,
+ sqp->pkey_index, &pkey);
+ else
+ ib_get_cached_pkey(&dev->ib_dev, sqp->qp.port,
+ wr->pkey_index, &pkey);
+ sqp->ud_header.bth.pkey = cpu_to_be16(pkey);
+ sqp->ud_header.bth.destination_qpn = cpu_to_be32(wr->remote_qpn);
+ sqp->ud_header.bth.psn = cpu_to_be32((sqp->send_psn++) & ((1 << 24) - 1));
+ sqp->ud_header.deth.qkey = cpu_to_be32(wr->remote_qkey & 0x80000000 ?
+ sqp->qkey : wr->remote_qkey);
+ sqp->ud_header.deth.source_qpn = cpu_to_be32(sqp->qp.ibqp.qp_num);
+
+ header_size = ib_ud_header_pack(&sqp->ud_header,
+ sqp->header_buf +
+ ind * MTHCA_UD_HEADER_SIZE);
+
+ data->byte_count = cpu_to_be32(header_size);
+ data->lkey = cpu_to_be32(to_mpd(sqp->qp.ibqp.pd)->ntmr.ibmr.lkey);
+ data->addr = cpu_to_be64(sqp->header_dma +
+ ind * MTHCA_UD_HEADER_SIZE);
+
+ return 0;
+}
+
+static inline int mthca_wq_overflow(struct mthca_wq *wq, int nreq,
+ struct ib_cq *ib_cq)
+{
+ unsigned cur;
+ struct mthca_cq *cq;
+
+ cur = wq->head - wq->tail;
+ if (likely(cur + nreq < wq->max))
+ return 0;
+
+ cq = to_mcq(ib_cq);
+ spin_lock(&cq->lock);
+ cur = wq->head - wq->tail;
+ spin_unlock(&cq->lock);
+
+ return cur + nreq >= wq->max;
+}
+
+static __always_inline void set_raddr_seg(struct mthca_raddr_seg *rseg,
+ u64 remote_addr, u32 rkey)
+{
+ rseg->raddr = cpu_to_be64(remote_addr);
+ rseg->rkey = cpu_to_be32(rkey);
+ rseg->reserved = 0;
+}
+
+static __always_inline void set_atomic_seg(struct mthca_atomic_seg *aseg,
+ struct ib_atomic_wr *wr)
+{
+ if (wr->wr.opcode == IB_WR_ATOMIC_CMP_AND_SWP) {
+ aseg->swap_add = cpu_to_be64(wr->swap);
+ aseg->compare = cpu_to_be64(wr->compare_add);
+ } else {
+ aseg->swap_add = cpu_to_be64(wr->compare_add);
+ aseg->compare = 0;
+ }
+
+}
+
+static void set_tavor_ud_seg(struct mthca_tavor_ud_seg *useg,
+ struct ib_ud_wr *wr)
+{
+ useg->lkey = cpu_to_be32(to_mah(wr->ah)->key);
+ useg->av_addr = cpu_to_be64(to_mah(wr->ah)->avdma);
+ useg->dqpn = cpu_to_be32(wr->remote_qpn);
+ useg->qkey = cpu_to_be32(wr->remote_qkey);
+
+}
+
+static void set_arbel_ud_seg(struct mthca_arbel_ud_seg *useg,
+ struct ib_ud_wr *wr)
+{
+ memcpy(useg->av, to_mah(wr->ah)->av, MTHCA_AV_SIZE);
+ useg->dqpn = cpu_to_be32(wr->remote_qpn);
+ useg->qkey = cpu_to_be32(wr->remote_qkey);
+}
+
+int mthca_tavor_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr,
+ struct ib_send_wr **bad_wr)
+{
+ struct mthca_dev *dev = to_mdev(ibqp->device);
+ struct mthca_qp *qp = to_mqp(ibqp);
+ void *wqe;
+ void *prev_wqe;
+ unsigned long flags;
+ int err = 0;
+ int nreq;
+ int i;
+ int size;
+ /*
+ * f0 and size0 are only used if nreq != 0, and they will
+ * always be initialized the first time through the main loop
+ * before nreq is incremented. So nreq cannot become non-zero
+ * without initializing f0 and size0, and they are in fact
+ * never used uninitialized.
+ */
+ int uninitialized_var(size0);
+ u32 uninitialized_var(f0);
+ int ind;
+ u8 op0 = 0;
+
+ spin_lock_irqsave(&qp->sq.lock, flags);
+
+ /* XXX check that state is OK to post send */
+
+ ind = qp->sq.next_ind;
+
+ for (nreq = 0; wr; ++nreq, wr = wr->next) {
+ if (mthca_wq_overflow(&qp->sq, nreq, qp->ibqp.send_cq)) {
+ mthca_err(dev, "SQ %06x full (%u head, %u tail,"
+ " %d max, %d nreq)\n", qp->qpn,
+ qp->sq.head, qp->sq.tail,
+ qp->sq.max, nreq);
+ err = -ENOMEM;
+ *bad_wr = wr;
+ goto out;
+ }
+
+ wqe = get_send_wqe(qp, ind);
+ prev_wqe = qp->sq.last;
+ qp->sq.last = wqe;
+
+ ((struct mthca_next_seg *) wqe)->nda_op = 0;
+ ((struct mthca_next_seg *) wqe)->ee_nds = 0;
+ ((struct mthca_next_seg *) wqe)->flags =
+ ((wr->send_flags & IB_SEND_SIGNALED) ?
+ cpu_to_be32(MTHCA_NEXT_CQ_UPDATE) : 0) |
+ ((wr->send_flags & IB_SEND_SOLICITED) ?
+ cpu_to_be32(MTHCA_NEXT_SOLICIT) : 0) |
+ cpu_to_be32(1);
+ if (wr->opcode == IB_WR_SEND_WITH_IMM ||
+ wr->opcode == IB_WR_RDMA_WRITE_WITH_IMM)
+ ((struct mthca_next_seg *) wqe)->imm = wr->ex.imm_data;
+
+ wqe += sizeof (struct mthca_next_seg);
+ size = sizeof (struct mthca_next_seg) / 16;
+
+ switch (qp->transport) {
+ case RC:
+ switch (wr->opcode) {
+ case IB_WR_ATOMIC_CMP_AND_SWP:
+ case IB_WR_ATOMIC_FETCH_AND_ADD:
+ set_raddr_seg(wqe, atomic_wr(wr)->remote_addr,
+ atomic_wr(wr)->rkey);
+ wqe += sizeof (struct mthca_raddr_seg);
+
+ set_atomic_seg(wqe, atomic_wr(wr));
+ wqe += sizeof (struct mthca_atomic_seg);
+ size += (sizeof (struct mthca_raddr_seg) +
+ sizeof (struct mthca_atomic_seg)) / 16;
+ break;
+
+ case IB_WR_RDMA_WRITE:
+ case IB_WR_RDMA_WRITE_WITH_IMM:
+ case IB_WR_RDMA_READ:
+ set_raddr_seg(wqe, rdma_wr(wr)->remote_addr,
+ rdma_wr(wr)->rkey);
+ wqe += sizeof (struct mthca_raddr_seg);
+ size += sizeof (struct mthca_raddr_seg) / 16;
+ break;
+
+ default:
+ /* No extra segments required for sends */
+ break;
+ }
+
+ break;
+
+ case UC:
+ switch (wr->opcode) {
+ case IB_WR_RDMA_WRITE:
+ case IB_WR_RDMA_WRITE_WITH_IMM:
+ set_raddr_seg(wqe, rdma_wr(wr)->remote_addr,
+ rdma_wr(wr)->rkey);
+ wqe += sizeof (struct mthca_raddr_seg);
+ size += sizeof (struct mthca_raddr_seg) / 16;
+ break;
+
+ default:
+ /* No extra segments required for sends */
+ break;
+ }
+
+ break;
+
+ case UD:
+ set_tavor_ud_seg(wqe, ud_wr(wr));
+ wqe += sizeof (struct mthca_tavor_ud_seg);
+ size += sizeof (struct mthca_tavor_ud_seg) / 16;
+ break;
+
+ case MLX:
+ err = build_mlx_header(dev, to_msqp(qp), ind, ud_wr(wr),
+ wqe - sizeof (struct mthca_next_seg),
+ wqe);
+ if (err) {
+ *bad_wr = wr;
+ goto out;
+ }
+ wqe += sizeof (struct mthca_data_seg);
+ size += sizeof (struct mthca_data_seg) / 16;
+ break;
+ }
+
+ if (wr->num_sge > qp->sq.max_gs) {
+ mthca_err(dev, "too many gathers\n");
+ err = -EINVAL;
+ *bad_wr = wr;
+ goto out;
+ }
+
+ for (i = 0; i < wr->num_sge; ++i) {
+ mthca_set_data_seg(wqe, wr->sg_list + i);
+ wqe += sizeof (struct mthca_data_seg);
+ size += sizeof (struct mthca_data_seg) / 16;
+ }
+
+ /* Add one more inline data segment for ICRC */
+ if (qp->transport == MLX) {
+ ((struct mthca_data_seg *) wqe)->byte_count =
+ cpu_to_be32((1 << 31) | 4);
+ ((u32 *) wqe)[1] = 0;
+ wqe += sizeof (struct mthca_data_seg);
+ size += sizeof (struct mthca_data_seg) / 16;
+ }
+
+ qp->wrid[ind + qp->rq.max] = wr->wr_id;
+
+ if (wr->opcode >= ARRAY_SIZE(mthca_opcode)) {
+ mthca_err(dev, "opcode invalid\n");
+ err = -EINVAL;
+ *bad_wr = wr;
+ goto out;
+ }
+
+ ((struct mthca_next_seg *) prev_wqe)->nda_op =
+ cpu_to_be32(((ind << qp->sq.wqe_shift) +
+ qp->send_wqe_offset) |
+ mthca_opcode[wr->opcode]);
+ wmb();
+ ((struct mthca_next_seg *) prev_wqe)->ee_nds =
+ cpu_to_be32((nreq ? 0 : MTHCA_NEXT_DBD) | size |
+ ((wr->send_flags & IB_SEND_FENCE) ?
+ MTHCA_NEXT_FENCE : 0));
+
+ if (!nreq) {
+ size0 = size;
+ op0 = mthca_opcode[wr->opcode];
+ f0 = wr->send_flags & IB_SEND_FENCE ?
+ MTHCA_SEND_DOORBELL_FENCE : 0;
+ }
+
+ ++ind;
+ if (unlikely(ind >= qp->sq.max))
+ ind -= qp->sq.max;
+ }
+
+out:
+ if (likely(nreq)) {
+ wmb();
+
+ mthca_write64(((qp->sq.next_ind << qp->sq.wqe_shift) +
+ qp->send_wqe_offset) | f0 | op0,
+ (qp->qpn << 8) | size0,
+ dev->kar + MTHCA_SEND_DOORBELL,
+ MTHCA_GET_DOORBELL_LOCK(&dev->doorbell_lock));
+ /*
+ * Make sure doorbells don't leak out of SQ spinlock
+ * and reach the HCA out of order:
+ */
+ mmiowb();
+ }
+
+ qp->sq.next_ind = ind;
+ qp->sq.head += nreq;
+
+ spin_unlock_irqrestore(&qp->sq.lock, flags);
+ return err;
+}
+
+int mthca_tavor_post_receive(struct ib_qp *ibqp, struct ib_recv_wr *wr,
+ struct ib_recv_wr **bad_wr)
+{
+ struct mthca_dev *dev = to_mdev(ibqp->device);
+ struct mthca_qp *qp = to_mqp(ibqp);
+ unsigned long flags;
+ int err = 0;
+ int nreq;
+ int i;
+ int size;
+ /*
+ * size0 is only used if nreq != 0, and it will always be
+ * initialized the first time through the main loop before
+ * nreq is incremented. So nreq cannot become non-zero
+ * without initializing size0, and it is in fact never used
+ * uninitialized.
+ */
+ int uninitialized_var(size0);
+ int ind;
+ void *wqe;
+ void *prev_wqe;
+
+ spin_lock_irqsave(&qp->rq.lock, flags);
+
+ /* XXX check that state is OK to post receive */
+
+ ind = qp->rq.next_ind;
+
+ for (nreq = 0; wr; wr = wr->next) {
+ if (mthca_wq_overflow(&qp->rq, nreq, qp->ibqp.recv_cq)) {
+ mthca_err(dev, "RQ %06x full (%u head, %u tail,"
+ " %d max, %d nreq)\n", qp->qpn,
+ qp->rq.head, qp->rq.tail,
+ qp->rq.max, nreq);
+ err = -ENOMEM;
+ *bad_wr = wr;
+ goto out;
+ }
+
+ wqe = get_recv_wqe(qp, ind);
+ prev_wqe = qp->rq.last;
+ qp->rq.last = wqe;
+
+ ((struct mthca_next_seg *) wqe)->ee_nds =
+ cpu_to_be32(MTHCA_NEXT_DBD);
+ ((struct mthca_next_seg *) wqe)->flags = 0;
+
+ wqe += sizeof (struct mthca_next_seg);
+ size = sizeof (struct mthca_next_seg) / 16;
+
+ if (unlikely(wr->num_sge > qp->rq.max_gs)) {
+ err = -EINVAL;
+ *bad_wr = wr;
+ goto out;
+ }
+
+ for (i = 0; i < wr->num_sge; ++i) {
+ mthca_set_data_seg(wqe, wr->sg_list + i);
+ wqe += sizeof (struct mthca_data_seg);
+ size += sizeof (struct mthca_data_seg) / 16;
+ }
+
+ qp->wrid[ind] = wr->wr_id;
+
+ ((struct mthca_next_seg *) prev_wqe)->ee_nds =
+ cpu_to_be32(MTHCA_NEXT_DBD | size);
+
+ if (!nreq)
+ size0 = size;
+
+ ++ind;
+ if (unlikely(ind >= qp->rq.max))
+ ind -= qp->rq.max;
+
+ ++nreq;
+ if (unlikely(nreq == MTHCA_TAVOR_MAX_WQES_PER_RECV_DB)) {
+ nreq = 0;
+
+ wmb();
+
+ mthca_write64((qp->rq.next_ind << qp->rq.wqe_shift) | size0,
+ qp->qpn << 8, dev->kar + MTHCA_RECEIVE_DOORBELL,
+ MTHCA_GET_DOORBELL_LOCK(&dev->doorbell_lock));
+
+ qp->rq.next_ind = ind;
+ qp->rq.head += MTHCA_TAVOR_MAX_WQES_PER_RECV_DB;
+ }
+ }
+
+out:
+ if (likely(nreq)) {
+ wmb();
+
+ mthca_write64((qp->rq.next_ind << qp->rq.wqe_shift) | size0,
+ qp->qpn << 8 | nreq, dev->kar + MTHCA_RECEIVE_DOORBELL,
+ MTHCA_GET_DOORBELL_LOCK(&dev->doorbell_lock));
+ }
+
+ qp->rq.next_ind = ind;
+ qp->rq.head += nreq;
+
+ /*
+ * Make sure doorbells don't leak out of RQ spinlock and reach
+ * the HCA out of order:
+ */
+ mmiowb();
+
+ spin_unlock_irqrestore(&qp->rq.lock, flags);
+ return err;
+}
+
+int mthca_arbel_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr,
+ struct ib_send_wr **bad_wr)
+{
+ struct mthca_dev *dev = to_mdev(ibqp->device);
+ struct mthca_qp *qp = to_mqp(ibqp);
+ u32 dbhi;
+ void *wqe;
+ void *prev_wqe;
+ unsigned long flags;
+ int err = 0;
+ int nreq;
+ int i;
+ int size;
+ /*
+ * f0 and size0 are only used if nreq != 0, and they will
+ * always be initialized the first time through the main loop
+ * before nreq is incremented. So nreq cannot become non-zero
+ * without initializing f0 and size0, and they are in fact
+ * never used uninitialized.
+ */
+ int uninitialized_var(size0);
+ u32 uninitialized_var(f0);
+ int ind;
+ u8 op0 = 0;
+
+ spin_lock_irqsave(&qp->sq.lock, flags);
+
+ /* XXX check that state is OK to post send */
+
+ ind = qp->sq.head & (qp->sq.max - 1);
+
+ for (nreq = 0; wr; ++nreq, wr = wr->next) {
+ if (unlikely(nreq == MTHCA_ARBEL_MAX_WQES_PER_SEND_DB)) {
+ nreq = 0;
+
+ dbhi = (MTHCA_ARBEL_MAX_WQES_PER_SEND_DB << 24) |
+ ((qp->sq.head & 0xffff) << 8) | f0 | op0;
+
+ qp->sq.head += MTHCA_ARBEL_MAX_WQES_PER_SEND_DB;
+
+ /*
+ * Make sure that descriptors are written before
+ * doorbell record.
+ */
+ wmb();
+ *qp->sq.db = cpu_to_be32(qp->sq.head & 0xffff);
+
+ /*
+ * Make sure doorbell record is written before we
+ * write MMIO send doorbell.
+ */
+ wmb();
+
+ mthca_write64(dbhi, (qp->qpn << 8) | size0,
+ dev->kar + MTHCA_SEND_DOORBELL,
+ MTHCA_GET_DOORBELL_LOCK(&dev->doorbell_lock));
+ }
+
+ if (mthca_wq_overflow(&qp->sq, nreq, qp->ibqp.send_cq)) {
+ mthca_err(dev, "SQ %06x full (%u head, %u tail,"
+ " %d max, %d nreq)\n", qp->qpn,
+ qp->sq.head, qp->sq.tail,
+ qp->sq.max, nreq);
+ err = -ENOMEM;
+ *bad_wr = wr;
+ goto out;
+ }
+
+ wqe = get_send_wqe(qp, ind);
+ prev_wqe = qp->sq.last;
+ qp->sq.last = wqe;
+
+ ((struct mthca_next_seg *) wqe)->flags =
+ ((wr->send_flags & IB_SEND_SIGNALED) ?
+ cpu_to_be32(MTHCA_NEXT_CQ_UPDATE) : 0) |
+ ((wr->send_flags & IB_SEND_SOLICITED) ?
+ cpu_to_be32(MTHCA_NEXT_SOLICIT) : 0) |
+ ((wr->send_flags & IB_SEND_IP_CSUM) ?
+ cpu_to_be32(MTHCA_NEXT_IP_CSUM | MTHCA_NEXT_TCP_UDP_CSUM) : 0) |
+ cpu_to_be32(1);
+ if (wr->opcode == IB_WR_SEND_WITH_IMM ||
+ wr->opcode == IB_WR_RDMA_WRITE_WITH_IMM)
+ ((struct mthca_next_seg *) wqe)->imm = wr->ex.imm_data;
+
+ wqe += sizeof (struct mthca_next_seg);
+ size = sizeof (struct mthca_next_seg) / 16;
+
+ switch (qp->transport) {
+ case RC:
+ switch (wr->opcode) {
+ case IB_WR_ATOMIC_CMP_AND_SWP:
+ case IB_WR_ATOMIC_FETCH_AND_ADD:
+ set_raddr_seg(wqe, atomic_wr(wr)->remote_addr,
+ atomic_wr(wr)->rkey);
+ wqe += sizeof (struct mthca_raddr_seg);
+
+ set_atomic_seg(wqe, atomic_wr(wr));
+ wqe += sizeof (struct mthca_atomic_seg);
+ size += (sizeof (struct mthca_raddr_seg) +
+ sizeof (struct mthca_atomic_seg)) / 16;
+ break;
+
+ case IB_WR_RDMA_READ:
+ case IB_WR_RDMA_WRITE:
+ case IB_WR_RDMA_WRITE_WITH_IMM:
+ set_raddr_seg(wqe, rdma_wr(wr)->remote_addr,
+ rdma_wr(wr)->rkey);
+ wqe += sizeof (struct mthca_raddr_seg);
+ size += sizeof (struct mthca_raddr_seg) / 16;
+ break;
+
+ default:
+ /* No extra segments required for sends */
+ break;
+ }
+
+ break;
+
+ case UC:
+ switch (wr->opcode) {
+ case IB_WR_RDMA_WRITE:
+ case IB_WR_RDMA_WRITE_WITH_IMM:
+ set_raddr_seg(wqe, rdma_wr(wr)->remote_addr,
+ rdma_wr(wr)->rkey);
+ wqe += sizeof (struct mthca_raddr_seg);
+ size += sizeof (struct mthca_raddr_seg) / 16;
+ break;
+
+ default:
+ /* No extra segments required for sends */
+ break;
+ }
+
+ break;
+
+ case UD:
+ set_arbel_ud_seg(wqe, ud_wr(wr));
+ wqe += sizeof (struct mthca_arbel_ud_seg);
+ size += sizeof (struct mthca_arbel_ud_seg) / 16;
+ break;
+
+ case MLX:
+ err = build_mlx_header(dev, to_msqp(qp), ind, ud_wr(wr),
+ wqe - sizeof (struct mthca_next_seg),
+ wqe);
+ if (err) {
+ *bad_wr = wr;
+ goto out;
+ }
+ wqe += sizeof (struct mthca_data_seg);
+ size += sizeof (struct mthca_data_seg) / 16;
+ break;
+ }
+
+ if (wr->num_sge > qp->sq.max_gs) {
+ mthca_err(dev, "too many gathers\n");
+ err = -EINVAL;
+ *bad_wr = wr;
+ goto out;
+ }
+
+ for (i = 0; i < wr->num_sge; ++i) {
+ mthca_set_data_seg(wqe, wr->sg_list + i);
+ wqe += sizeof (struct mthca_data_seg);
+ size += sizeof (struct mthca_data_seg) / 16;
+ }
+
+ /* Add one more inline data segment for ICRC */
+ if (qp->transport == MLX) {
+ ((struct mthca_data_seg *) wqe)->byte_count =
+ cpu_to_be32((1 << 31) | 4);
+ ((u32 *) wqe)[1] = 0;
+ wqe += sizeof (struct mthca_data_seg);
+ size += sizeof (struct mthca_data_seg) / 16;
+ }
+
+ qp->wrid[ind + qp->rq.max] = wr->wr_id;
+
+ if (wr->opcode >= ARRAY_SIZE(mthca_opcode)) {
+ mthca_err(dev, "opcode invalid\n");
+ err = -EINVAL;
+ *bad_wr = wr;
+ goto out;
+ }
+
+ ((struct mthca_next_seg *) prev_wqe)->nda_op =
+ cpu_to_be32(((ind << qp->sq.wqe_shift) +
+ qp->send_wqe_offset) |
+ mthca_opcode[wr->opcode]);
+ wmb();
+ ((struct mthca_next_seg *) prev_wqe)->ee_nds =
+ cpu_to_be32(MTHCA_NEXT_DBD | size |
+ ((wr->send_flags & IB_SEND_FENCE) ?
+ MTHCA_NEXT_FENCE : 0));
+
+ if (!nreq) {
+ size0 = size;
+ op0 = mthca_opcode[wr->opcode];
+ f0 = wr->send_flags & IB_SEND_FENCE ?
+ MTHCA_SEND_DOORBELL_FENCE : 0;
+ }
+
+ ++ind;
+ if (unlikely(ind >= qp->sq.max))
+ ind -= qp->sq.max;
+ }
+
+out:
+ if (likely(nreq)) {
+ dbhi = (nreq << 24) | ((qp->sq.head & 0xffff) << 8) | f0 | op0;
+
+ qp->sq.head += nreq;
+
+ /*
+ * Make sure that descriptors are written before
+ * doorbell record.
+ */
+ wmb();
+ *qp->sq.db = cpu_to_be32(qp->sq.head & 0xffff);
+
+ /*
+ * Make sure doorbell record is written before we
+ * write MMIO send doorbell.
+ */
+ wmb();
+
+ mthca_write64(dbhi, (qp->qpn << 8) | size0, dev->kar + MTHCA_SEND_DOORBELL,
+ MTHCA_GET_DOORBELL_LOCK(&dev->doorbell_lock));
+ }
+
+ /*
+ * Make sure doorbells don't leak out of SQ spinlock and reach
+ * the HCA out of order:
+ */
+ mmiowb();
+
+ spin_unlock_irqrestore(&qp->sq.lock, flags);
+ return err;
+}
+
+int mthca_arbel_post_receive(struct ib_qp *ibqp, struct ib_recv_wr *wr,
+ struct ib_recv_wr **bad_wr)
+{
+ struct mthca_dev *dev = to_mdev(ibqp->device);
+ struct mthca_qp *qp = to_mqp(ibqp);
+ unsigned long flags;
+ int err = 0;
+ int nreq;
+ int ind;
+ int i;
+ void *wqe;
+
+ spin_lock_irqsave(&qp->rq.lock, flags);
+
+ /* XXX check that state is OK to post receive */
+
+ ind = qp->rq.head & (qp->rq.max - 1);
+
+ for (nreq = 0; wr; ++nreq, wr = wr->next) {
+ if (mthca_wq_overflow(&qp->rq, nreq, qp->ibqp.recv_cq)) {
+ mthca_err(dev, "RQ %06x full (%u head, %u tail,"
+ " %d max, %d nreq)\n", qp->qpn,
+ qp->rq.head, qp->rq.tail,
+ qp->rq.max, nreq);
+ err = -ENOMEM;
+ *bad_wr = wr;
+ goto out;
+ }
+
+ wqe = get_recv_wqe(qp, ind);
+
+ ((struct mthca_next_seg *) wqe)->flags = 0;
+
+ wqe += sizeof (struct mthca_next_seg);
+
+ if (unlikely(wr->num_sge > qp->rq.max_gs)) {
+ err = -EINVAL;
+ *bad_wr = wr;
+ goto out;
+ }
+
+ for (i = 0; i < wr->num_sge; ++i) {
+ mthca_set_data_seg(wqe, wr->sg_list + i);
+ wqe += sizeof (struct mthca_data_seg);
+ }
+
+ if (i < qp->rq.max_gs)
+ mthca_set_data_seg_inval(wqe);
+
+ qp->wrid[ind] = wr->wr_id;
+
+ ++ind;
+ if (unlikely(ind >= qp->rq.max))
+ ind -= qp->rq.max;
+ }
+out:
+ if (likely(nreq)) {
+ qp->rq.head += nreq;
+
+ /*
+ * Make sure that descriptors are written before
+ * doorbell record.
+ */
+ wmb();
+ *qp->rq.db = cpu_to_be32(qp->rq.head & 0xffff);
+ }
+
+ spin_unlock_irqrestore(&qp->rq.lock, flags);
+ return err;
+}
+
+void mthca_free_err_wqe(struct mthca_dev *dev, struct mthca_qp *qp, int is_send,
+ int index, int *dbd, __be32 *new_wqe)
+{
+ struct mthca_next_seg *next;
+
+ /*
+ * For SRQs, all receive WQEs generate a CQE, so we're always
+ * at the end of the doorbell chain.
+ */
+ if (qp->ibqp.srq && !is_send) {
+ *new_wqe = 0;
+ return;
+ }
+
+ if (is_send)
+ next = get_send_wqe(qp, index);
+ else
+ next = get_recv_wqe(qp, index);
+
+ *dbd = !!(next->ee_nds & cpu_to_be32(MTHCA_NEXT_DBD));
+ if (next->ee_nds & cpu_to_be32(0x3f))
+ *new_wqe = (next->nda_op & cpu_to_be32(~0x3f)) |
+ (next->ee_nds & cpu_to_be32(0x3f));
+ else
+ *new_wqe = 0;
+}
+
+int mthca_init_qp_table(struct mthca_dev *dev)
+{
+ int err;
+ int i;
+
+ spin_lock_init(&dev->qp_table.lock);
+
+ /*
+ * We reserve 2 extra QPs per port for the special QPs. The
+ * special QP for port 1 has to be even, so round up.
+ */
+ dev->qp_table.sqp_start = (dev->limits.reserved_qps + 1) & ~1UL;
+ err = mthca_alloc_init(&dev->qp_table.alloc,
+ dev->limits.num_qps,
+ (1 << 24) - 1,
+ dev->qp_table.sqp_start +
+ MTHCA_MAX_PORTS * 2);
+ if (err)
+ return err;
+
+ err = mthca_array_init(&dev->qp_table.qp,
+ dev->limits.num_qps);
+ if (err) {
+ mthca_alloc_cleanup(&dev->qp_table.alloc);
+ return err;
+ }
+
+ for (i = 0; i < 2; ++i) {
+ err = mthca_CONF_SPECIAL_QP(dev, i ? IB_QPT_GSI : IB_QPT_SMI,
+ dev->qp_table.sqp_start + i * 2);
+ if (err) {
+ mthca_warn(dev, "CONF_SPECIAL_QP returned "
+ "%d, aborting.\n", err);
+ goto err_out;
+ }
+ }
+ return 0;
+
+ err_out:
+ for (i = 0; i < 2; ++i)
+ mthca_CONF_SPECIAL_QP(dev, i, 0);
+
+ mthca_array_cleanup(&dev->qp_table.qp, dev->limits.num_qps);
+ mthca_alloc_cleanup(&dev->qp_table.alloc);
+
+ return err;
+}
+
+void mthca_cleanup_qp_table(struct mthca_dev *dev)
+{
+ int i;
+
+ for (i = 0; i < 2; ++i)
+ mthca_CONF_SPECIAL_QP(dev, i, 0);
+
+ mthca_array_cleanup(&dev->qp_table.qp, dev->limits.num_qps);
+ mthca_alloc_cleanup(&dev->qp_table.alloc);
+}
diff --git a/sys/ofed/drivers/infiniband/hw/mthca/mthca_reset.c b/sys/dev/mthca/mthca_reset.c
index f571bd6..f571bd6 100644
--- a/sys/ofed/drivers/infiniband/hw/mthca/mthca_reset.c
+++ b/sys/dev/mthca/mthca_reset.c
diff --git a/sys/dev/mthca/mthca_srq.c b/sys/dev/mthca/mthca_srq.c
new file mode 100644
index 0000000..d22f970
--- /dev/null
+++ b/sys/dev/mthca/mthca_srq.c
@@ -0,0 +1,696 @@
+/*
+ * Copyright (c) 2005 Cisco Systems. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#include <linux/slab.h>
+#include <linux/string.h>
+#include <linux/sched.h>
+
+#include <asm/io.h>
+
+#include "mthca_dev.h"
+#include "mthca_cmd.h"
+#include "mthca_memfree.h"
+#include "mthca_wqe.h"
+
+enum {
+ MTHCA_MAX_DIRECT_SRQ_SIZE = 4 * PAGE_SIZE
+};
+
+struct mthca_tavor_srq_context {
+ __be64 wqe_base_ds; /* low 6 bits is descriptor size */
+ __be32 state_pd;
+ __be32 lkey;
+ __be32 uar;
+ __be16 limit_watermark;
+ __be16 wqe_cnt;
+ u32 reserved[2];
+};
+
+struct mthca_arbel_srq_context {
+ __be32 state_logsize_srqn;
+ __be32 lkey;
+ __be32 db_index;
+ __be32 logstride_usrpage;
+ __be64 wqe_base;
+ __be32 eq_pd;
+ __be16 limit_watermark;
+ __be16 wqe_cnt;
+ u16 reserved1;
+ __be16 wqe_counter;
+ u32 reserved2[3];
+};
+
+static void *get_wqe(struct mthca_srq *srq, int n)
+{
+ if (srq->is_direct)
+ return srq->queue.direct.buf + (n << srq->wqe_shift);
+ else
+ return srq->queue.page_list[(n << srq->wqe_shift) >> PAGE_SHIFT].buf +
+ ((n << srq->wqe_shift) & (PAGE_SIZE - 1));
+}
+
+/*
+ * Return a pointer to the location within a WQE that we're using as a
+ * link when the WQE is in the free list. We use the imm field
+ * because in the Tavor case, posting a WQE may overwrite the next
+ * segment of the previous WQE, but a receive WQE will never touch the
+ * imm field. This avoids corrupting our free list if the previous
+ * WQE has already completed and been put on the free list when we
+ * post the next WQE.
+ */
+static inline int *wqe_to_link(void *wqe)
+{
+ return (int *) (wqe + offsetof(struct mthca_next_seg, imm));
+}
+
+static void mthca_tavor_init_srq_context(struct mthca_dev *dev,
+ struct mthca_pd *pd,
+ struct mthca_srq *srq,
+ struct mthca_tavor_srq_context *context)
+{
+ memset(context, 0, sizeof *context);
+
+ context->wqe_base_ds = cpu_to_be64(1 << (srq->wqe_shift - 4));
+ context->state_pd = cpu_to_be32(pd->pd_num);
+ context->lkey = cpu_to_be32(srq->mr.ibmr.lkey);
+
+ if (pd->ibpd.uobject)
+ context->uar =
+ cpu_to_be32(to_mucontext(pd->ibpd.uobject->context)->uar.index);
+ else
+ context->uar = cpu_to_be32(dev->driver_uar.index);
+}
+
+static void mthca_arbel_init_srq_context(struct mthca_dev *dev,
+ struct mthca_pd *pd,
+ struct mthca_srq *srq,
+ struct mthca_arbel_srq_context *context)
+{
+ int logsize, max;
+
+ memset(context, 0, sizeof *context);
+
+ /*
+ * Put max in a temporary variable to work around gcc bug
+ * triggered by ilog2() on sparc64.
+ */
+ max = srq->max;
+ logsize = ilog2(max);
+ context->state_logsize_srqn = cpu_to_be32(logsize << 24 | srq->srqn);
+ context->lkey = cpu_to_be32(srq->mr.ibmr.lkey);
+ context->db_index = cpu_to_be32(srq->db_index);
+ context->logstride_usrpage = cpu_to_be32((srq->wqe_shift - 4) << 29);
+ if (pd->ibpd.uobject)
+ context->logstride_usrpage |=
+ cpu_to_be32(to_mucontext(pd->ibpd.uobject->context)->uar.index);
+ else
+ context->logstride_usrpage |= cpu_to_be32(dev->driver_uar.index);
+ context->eq_pd = cpu_to_be32(MTHCA_EQ_ASYNC << 24 | pd->pd_num);
+}
+
+static void mthca_free_srq_buf(struct mthca_dev *dev, struct mthca_srq *srq)
+{
+ mthca_buf_free(dev, srq->max << srq->wqe_shift, &srq->queue,
+ srq->is_direct, &srq->mr);
+ kfree(srq->wrid);
+}
+
+static int mthca_alloc_srq_buf(struct mthca_dev *dev, struct mthca_pd *pd,
+ struct mthca_srq *srq)
+{
+ struct mthca_data_seg *scatter;
+ void *wqe;
+ int err;
+ int i;
+
+ if (pd->ibpd.uobject)
+ return 0;
+
+ srq->wrid = kmalloc(srq->max * sizeof (u64), GFP_KERNEL);
+ if (!srq->wrid)
+ return -ENOMEM;
+
+ err = mthca_buf_alloc(dev, srq->max << srq->wqe_shift,
+ MTHCA_MAX_DIRECT_SRQ_SIZE,
+ &srq->queue, &srq->is_direct, pd, 1, &srq->mr);
+ if (err) {
+ kfree(srq->wrid);
+ return err;
+ }
+
+ /*
+ * Now initialize the SRQ buffer so that all of the WQEs are
+ * linked into the list of free WQEs. In addition, set the
+ * scatter list L_Keys to the sentry value of 0x100.
+ */
+ for (i = 0; i < srq->max; ++i) {
+ struct mthca_next_seg *next;
+
+ next = wqe = get_wqe(srq, i);
+
+ if (i < srq->max - 1) {
+ *wqe_to_link(wqe) = i + 1;
+ next->nda_op = htonl(((i + 1) << srq->wqe_shift) | 1);
+ } else {
+ *wqe_to_link(wqe) = -1;
+ next->nda_op = 0;
+ }
+
+ for (scatter = wqe + sizeof (struct mthca_next_seg);
+ (void *) scatter < wqe + (1 << srq->wqe_shift);
+ ++scatter)
+ scatter->lkey = cpu_to_be32(MTHCA_INVAL_LKEY);
+ }
+
+ srq->last = get_wqe(srq, srq->max - 1);
+
+ return 0;
+}
+
+int mthca_alloc_srq(struct mthca_dev *dev, struct mthca_pd *pd,
+ struct ib_srq_attr *attr, struct mthca_srq *srq)
+{
+ struct mthca_mailbox *mailbox;
+ int ds;
+ int err;
+
+ /* Sanity check SRQ size before proceeding */
+ if (attr->max_wr > dev->limits.max_srq_wqes ||
+ attr->max_sge > dev->limits.max_srq_sge)
+ return -EINVAL;
+
+ srq->max = attr->max_wr;
+ srq->max_gs = attr->max_sge;
+ srq->counter = 0;
+
+ if (mthca_is_memfree(dev))
+ srq->max = roundup_pow_of_two(srq->max + 1);
+ else
+ srq->max = srq->max + 1;
+
+ ds = max(64UL,
+ roundup_pow_of_two(sizeof (struct mthca_next_seg) +
+ srq->max_gs * sizeof (struct mthca_data_seg)));
+
+ if (!mthca_is_memfree(dev) && (ds > dev->limits.max_desc_sz))
+ return -EINVAL;
+
+ srq->wqe_shift = ilog2(ds);
+
+ srq->srqn = mthca_alloc(&dev->srq_table.alloc);
+ if (srq->srqn == -1)
+ return -ENOMEM;
+
+ if (mthca_is_memfree(dev)) {
+ err = mthca_table_get(dev, dev->srq_table.table, srq->srqn);
+ if (err)
+ goto err_out;
+
+ if (!pd->ibpd.uobject) {
+ srq->db_index = mthca_alloc_db(dev, MTHCA_DB_TYPE_SRQ,
+ srq->srqn, &srq->db);
+ if (srq->db_index < 0) {
+ err = -ENOMEM;
+ goto err_out_icm;
+ }
+ }
+ }
+
+ mailbox = mthca_alloc_mailbox(dev, GFP_KERNEL);
+ if (IS_ERR(mailbox)) {
+ err = PTR_ERR(mailbox);
+ goto err_out_db;
+ }
+
+ err = mthca_alloc_srq_buf(dev, pd, srq);
+ if (err)
+ goto err_out_mailbox;
+
+ spin_lock_init(&srq->lock);
+ srq->refcount = 1;
+ init_waitqueue_head(&srq->wait);
+ mutex_init(&srq->mutex);
+
+ if (mthca_is_memfree(dev))
+ mthca_arbel_init_srq_context(dev, pd, srq, mailbox->buf);
+ else
+ mthca_tavor_init_srq_context(dev, pd, srq, mailbox->buf);
+
+ err = mthca_SW2HW_SRQ(dev, mailbox, srq->srqn);
+
+ if (err) {
+ mthca_warn(dev, "SW2HW_SRQ failed (%d)\n", err);
+ goto err_out_free_buf;
+ }
+
+ spin_lock_irq(&dev->srq_table.lock);
+ if (mthca_array_set(&dev->srq_table.srq,
+ srq->srqn & (dev->limits.num_srqs - 1),
+ srq)) {
+ spin_unlock_irq(&dev->srq_table.lock);
+ goto err_out_free_srq;
+ }
+ spin_unlock_irq(&dev->srq_table.lock);
+
+ mthca_free_mailbox(dev, mailbox);
+
+ srq->first_free = 0;
+ srq->last_free = srq->max - 1;
+
+ attr->max_wr = srq->max - 1;
+ attr->max_sge = srq->max_gs;
+
+ return 0;
+
+err_out_free_srq:
+ err = mthca_HW2SW_SRQ(dev, mailbox, srq->srqn);
+ if (err)
+ mthca_warn(dev, "HW2SW_SRQ failed (%d)\n", err);
+
+err_out_free_buf:
+ if (!pd->ibpd.uobject)
+ mthca_free_srq_buf(dev, srq);
+
+err_out_mailbox:
+ mthca_free_mailbox(dev, mailbox);
+
+err_out_db:
+ if (!pd->ibpd.uobject && mthca_is_memfree(dev))
+ mthca_free_db(dev, MTHCA_DB_TYPE_SRQ, srq->db_index);
+
+err_out_icm:
+ mthca_table_put(dev, dev->srq_table.table, srq->srqn);
+
+err_out:
+ mthca_free(&dev->srq_table.alloc, srq->srqn);
+
+ return err;
+}
+
+static inline int get_srq_refcount(struct mthca_dev *dev, struct mthca_srq *srq)
+{
+ int c;
+
+ spin_lock_irq(&dev->srq_table.lock);
+ c = srq->refcount;
+ spin_unlock_irq(&dev->srq_table.lock);
+
+ return c;
+}
+
+void mthca_free_srq(struct mthca_dev *dev, struct mthca_srq *srq)
+{
+ struct mthca_mailbox *mailbox;
+ int err;
+
+ mailbox = mthca_alloc_mailbox(dev, GFP_KERNEL);
+ if (IS_ERR(mailbox)) {
+ mthca_warn(dev, "No memory for mailbox to free SRQ.\n");
+ return;
+ }
+
+ err = mthca_HW2SW_SRQ(dev, mailbox, srq->srqn);
+ if (err)
+ mthca_warn(dev, "HW2SW_SRQ failed (%d)\n", err);
+
+ spin_lock_irq(&dev->srq_table.lock);
+ mthca_array_clear(&dev->srq_table.srq,
+ srq->srqn & (dev->limits.num_srqs - 1));
+ --srq->refcount;
+ spin_unlock_irq(&dev->srq_table.lock);
+
+ wait_event(srq->wait, !get_srq_refcount(dev, srq));
+
+ if (!srq->ibsrq.uobject) {
+ mthca_free_srq_buf(dev, srq);
+ if (mthca_is_memfree(dev))
+ mthca_free_db(dev, MTHCA_DB_TYPE_SRQ, srq->db_index);
+ }
+
+ mthca_table_put(dev, dev->srq_table.table, srq->srqn);
+ mthca_free(&dev->srq_table.alloc, srq->srqn);
+ mthca_free_mailbox(dev, mailbox);
+}
+
+int mthca_modify_srq(struct ib_srq *ibsrq, struct ib_srq_attr *attr,
+ enum ib_srq_attr_mask attr_mask, struct ib_udata *udata)
+{
+ struct mthca_dev *dev = to_mdev(ibsrq->device);
+ struct mthca_srq *srq = to_msrq(ibsrq);
+ int ret = 0;
+
+ /* We don't support resizing SRQs (yet?) */
+ if (attr_mask & IB_SRQ_MAX_WR)
+ return -EINVAL;
+
+ if (attr_mask & IB_SRQ_LIMIT) {
+ u32 max_wr = mthca_is_memfree(dev) ? srq->max - 1 : srq->max;
+ if (attr->srq_limit > max_wr)
+ return -EINVAL;
+
+ mutex_lock(&srq->mutex);
+ ret = mthca_ARM_SRQ(dev, srq->srqn, attr->srq_limit);
+ mutex_unlock(&srq->mutex);
+ }
+
+ return ret;
+}
+
+int mthca_query_srq(struct ib_srq *ibsrq, struct ib_srq_attr *srq_attr)
+{
+ struct mthca_dev *dev = to_mdev(ibsrq->device);
+ struct mthca_srq *srq = to_msrq(ibsrq);
+ struct mthca_mailbox *mailbox;
+ struct mthca_arbel_srq_context *arbel_ctx;
+ struct mthca_tavor_srq_context *tavor_ctx;
+ int err;
+
+ mailbox = mthca_alloc_mailbox(dev, GFP_KERNEL);
+ if (IS_ERR(mailbox))
+ return PTR_ERR(mailbox);
+
+ err = mthca_QUERY_SRQ(dev, srq->srqn, mailbox);
+ if (err)
+ goto out;
+
+ if (mthca_is_memfree(dev)) {
+ arbel_ctx = mailbox->buf;
+ srq_attr->srq_limit = be16_to_cpu(arbel_ctx->limit_watermark);
+ } else {
+ tavor_ctx = mailbox->buf;
+ srq_attr->srq_limit = be16_to_cpu(tavor_ctx->limit_watermark);
+ }
+
+ srq_attr->max_wr = srq->max - 1;
+ srq_attr->max_sge = srq->max_gs;
+
+out:
+ mthca_free_mailbox(dev, mailbox);
+
+ return err;
+}
+
+void mthca_srq_event(struct mthca_dev *dev, u32 srqn,
+ enum ib_event_type event_type)
+{
+ struct mthca_srq *srq;
+ struct ib_event event;
+
+ spin_lock(&dev->srq_table.lock);
+ srq = mthca_array_get(&dev->srq_table.srq, srqn & (dev->limits.num_srqs - 1));
+ if (srq)
+ ++srq->refcount;
+ spin_unlock(&dev->srq_table.lock);
+
+ if (!srq) {
+ mthca_warn(dev, "Async event for bogus SRQ %08x\n", srqn);
+ return;
+ }
+
+ if (!srq->ibsrq.event_handler)
+ goto out;
+
+ event.device = &dev->ib_dev;
+ event.event = event_type;
+ event.element.srq = &srq->ibsrq;
+ srq->ibsrq.event_handler(&event, srq->ibsrq.srq_context);
+
+out:
+ spin_lock(&dev->srq_table.lock);
+ if (!--srq->refcount)
+ wake_up(&srq->wait);
+ spin_unlock(&dev->srq_table.lock);
+}
+
+/*
+ * This function must be called with IRQs disabled.
+ */
+void mthca_free_srq_wqe(struct mthca_srq *srq, u32 wqe_addr)
+{
+ int ind;
+ struct mthca_next_seg *last_free;
+
+ ind = wqe_addr >> srq->wqe_shift;
+
+ spin_lock(&srq->lock);
+
+ last_free = get_wqe(srq, srq->last_free);
+ *wqe_to_link(last_free) = ind;
+ last_free->nda_op = htonl((ind << srq->wqe_shift) | 1);
+ *wqe_to_link(get_wqe(srq, ind)) = -1;
+ srq->last_free = ind;
+
+ spin_unlock(&srq->lock);
+}
+
+int mthca_tavor_post_srq_recv(struct ib_srq *ibsrq, struct ib_recv_wr *wr,
+ struct ib_recv_wr **bad_wr)
+{
+ struct mthca_dev *dev = to_mdev(ibsrq->device);
+ struct mthca_srq *srq = to_msrq(ibsrq);
+ unsigned long flags;
+ int err = 0;
+ int first_ind;
+ int ind;
+ int next_ind;
+ int nreq;
+ int i;
+ void *wqe;
+ void *prev_wqe;
+
+ spin_lock_irqsave(&srq->lock, flags);
+
+ first_ind = srq->first_free;
+
+ for (nreq = 0; wr; wr = wr->next) {
+ ind = srq->first_free;
+ wqe = get_wqe(srq, ind);
+ next_ind = *wqe_to_link(wqe);
+
+ if (unlikely(next_ind < 0)) {
+ mthca_err(dev, "SRQ %06x full\n", srq->srqn);
+ err = -ENOMEM;
+ *bad_wr = wr;
+ break;
+ }
+
+ prev_wqe = srq->last;
+ srq->last = wqe;
+
+ ((struct mthca_next_seg *) wqe)->ee_nds = 0;
+ /* flags field will always remain 0 */
+
+ wqe += sizeof (struct mthca_next_seg);
+
+ if (unlikely(wr->num_sge > srq->max_gs)) {
+ err = -EINVAL;
+ *bad_wr = wr;
+ srq->last = prev_wqe;
+ break;
+ }
+
+ for (i = 0; i < wr->num_sge; ++i) {
+ mthca_set_data_seg(wqe, wr->sg_list + i);
+ wqe += sizeof (struct mthca_data_seg);
+ }
+
+ if (i < srq->max_gs)
+ mthca_set_data_seg_inval(wqe);
+
+ ((struct mthca_next_seg *) prev_wqe)->ee_nds =
+ cpu_to_be32(MTHCA_NEXT_DBD);
+
+ srq->wrid[ind] = wr->wr_id;
+ srq->first_free = next_ind;
+
+ ++nreq;
+ if (unlikely(nreq == MTHCA_TAVOR_MAX_WQES_PER_RECV_DB)) {
+ nreq = 0;
+
+ /*
+ * Make sure that descriptors are written
+ * before doorbell is rung.
+ */
+ wmb();
+
+ mthca_write64(first_ind << srq->wqe_shift, srq->srqn << 8,
+ dev->kar + MTHCA_RECEIVE_DOORBELL,
+ MTHCA_GET_DOORBELL_LOCK(&dev->doorbell_lock));
+
+ first_ind = srq->first_free;
+ }
+ }
+
+ if (likely(nreq)) {
+ /*
+ * Make sure that descriptors are written before
+ * doorbell is rung.
+ */
+ wmb();
+
+ mthca_write64(first_ind << srq->wqe_shift, (srq->srqn << 8) | nreq,
+ dev->kar + MTHCA_RECEIVE_DOORBELL,
+ MTHCA_GET_DOORBELL_LOCK(&dev->doorbell_lock));
+ }
+
+ /*
+ * Make sure doorbells don't leak out of SRQ spinlock and
+ * reach the HCA out of order:
+ */
+ mmiowb();
+
+ spin_unlock_irqrestore(&srq->lock, flags);
+ return err;
+}
+
+int mthca_arbel_post_srq_recv(struct ib_srq *ibsrq, struct ib_recv_wr *wr,
+ struct ib_recv_wr **bad_wr)
+{
+ struct mthca_dev *dev = to_mdev(ibsrq->device);
+ struct mthca_srq *srq = to_msrq(ibsrq);
+ unsigned long flags;
+ int err = 0;
+ int ind;
+ int next_ind;
+ int nreq;
+ int i;
+ void *wqe;
+
+ spin_lock_irqsave(&srq->lock, flags);
+
+ for (nreq = 0; wr; ++nreq, wr = wr->next) {
+ ind = srq->first_free;
+ wqe = get_wqe(srq, ind);
+ next_ind = *wqe_to_link(wqe);
+
+ if (unlikely(next_ind < 0)) {
+ mthca_err(dev, "SRQ %06x full\n", srq->srqn);
+ err = -ENOMEM;
+ *bad_wr = wr;
+ break;
+ }
+
+ ((struct mthca_next_seg *) wqe)->ee_nds = 0;
+ /* flags field will always remain 0 */
+
+ wqe += sizeof (struct mthca_next_seg);
+
+ if (unlikely(wr->num_sge > srq->max_gs)) {
+ err = -EINVAL;
+ *bad_wr = wr;
+ break;
+ }
+
+ for (i = 0; i < wr->num_sge; ++i) {
+ mthca_set_data_seg(wqe, wr->sg_list + i);
+ wqe += sizeof (struct mthca_data_seg);
+ }
+
+ if (i < srq->max_gs)
+ mthca_set_data_seg_inval(wqe);
+
+ srq->wrid[ind] = wr->wr_id;
+ srq->first_free = next_ind;
+ }
+
+ if (likely(nreq)) {
+ srq->counter += nreq;
+
+ /*
+ * Make sure that descriptors are written before
+ * we write doorbell record.
+ */
+ wmb();
+ *srq->db = cpu_to_be32(srq->counter);
+ }
+
+ spin_unlock_irqrestore(&srq->lock, flags);
+ return err;
+}
+
+int mthca_max_srq_sge(struct mthca_dev *dev)
+{
+ if (mthca_is_memfree(dev))
+ return dev->limits.max_sg;
+
+ /*
+ * SRQ allocations are based on powers of 2 for Tavor,
+ * (although they only need to be multiples of 16 bytes).
+ *
+ * Therefore, we need to base the max number of sg entries on
+ * the largest power of 2 descriptor size that is <= to the
+ * actual max WQE descriptor size, rather than return the
+ * max_sg value given by the firmware (which is based on WQE
+ * sizes as multiples of 16, not powers of 2).
+ *
+ * If SRQ implementation is changed for Tavor to be based on
+ * multiples of 16, the calculation below can be deleted and
+ * the FW max_sg value returned.
+ */
+ return min_t(int, dev->limits.max_sg,
+ ((1 << (fls(dev->limits.max_desc_sz) - 1)) -
+ sizeof (struct mthca_next_seg)) /
+ sizeof (struct mthca_data_seg));
+}
+
+int mthca_init_srq_table(struct mthca_dev *dev)
+{
+ int err;
+
+ if (!(dev->mthca_flags & MTHCA_FLAG_SRQ))
+ return 0;
+
+ spin_lock_init(&dev->srq_table.lock);
+
+ err = mthca_alloc_init(&dev->srq_table.alloc,
+ dev->limits.num_srqs,
+ dev->limits.num_srqs - 1,
+ dev->limits.reserved_srqs);
+ if (err)
+ return err;
+
+ err = mthca_array_init(&dev->srq_table.srq,
+ dev->limits.num_srqs);
+ if (err)
+ mthca_alloc_cleanup(&dev->srq_table.alloc);
+
+ return err;
+}
+
+void mthca_cleanup_srq_table(struct mthca_dev *dev)
+{
+ if (!(dev->mthca_flags & MTHCA_FLAG_SRQ))
+ return;
+
+ mthca_array_cleanup(&dev->srq_table.srq, dev->limits.num_srqs);
+ mthca_alloc_cleanup(&dev->srq_table.alloc);
+}
diff --git a/sys/dev/mthca/mthca_uar.c b/sys/dev/mthca/mthca_uar.c
new file mode 100644
index 0000000..40a7b73
--- /dev/null
+++ b/sys/dev/mthca/mthca_uar.c
@@ -0,0 +1,76 @@
+/*
+ * Copyright (c) 2005 Topspin Communications. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#include "mthca_dev.h"
+#include "mthca_memfree.h"
+
+int mthca_uar_alloc(struct mthca_dev *dev, struct mthca_uar *uar)
+{
+ uar->index = mthca_alloc(&dev->uar_table.alloc);
+ if (uar->index == -1)
+ return -ENOMEM;
+
+ uar->pfn = (pci_resource_start(dev->pdev, 2) >> PAGE_SHIFT) + uar->index;
+
+ return 0;
+}
+
+void mthca_uar_free(struct mthca_dev *dev, struct mthca_uar *uar)
+{
+ mthca_free(&dev->uar_table.alloc, uar->index);
+}
+
+int mthca_init_uar_table(struct mthca_dev *dev)
+{
+ int ret;
+
+ ret = mthca_alloc_init(&dev->uar_table.alloc,
+ dev->limits.num_uars,
+ dev->limits.num_uars - 1,
+ dev->limits.reserved_uars + 1);
+ if (ret)
+ return ret;
+
+ ret = mthca_init_db_tab(dev);
+ if (ret)
+ mthca_alloc_cleanup(&dev->uar_table.alloc);
+
+ return ret;
+}
+
+void mthca_cleanup_uar_table(struct mthca_dev *dev)
+{
+ mthca_cleanup_db_tab(dev);
+
+ /* XXX check if any UARs are still allocated? */
+ mthca_alloc_cleanup(&dev->uar_table.alloc);
+}
diff --git a/sys/ofed/drivers/infiniband/hw/mthca/mthca_user.h b/sys/dev/mthca/mthca_user.h
index 5fe56e8..5fe56e8 100644
--- a/sys/ofed/drivers/infiniband/hw/mthca/mthca_user.h
+++ b/sys/dev/mthca/mthca_user.h
diff --git a/sys/ofed/drivers/infiniband/hw/mthca/mthca_wqe.h b/sys/dev/mthca/mthca_wqe.h
index 341a5ae..341a5ae 100644
--- a/sys/ofed/drivers/infiniband/hw/mthca/mthca_wqe.h
+++ b/sys/dev/mthca/mthca_wqe.h
diff --git a/sys/i386/conf/NOTES b/sys/i386/conf/NOTES
index 2b9733e..a274bbe 100644
--- a/sys/i386/conf/NOTES
+++ b/sys/i386/conf/NOTES
@@ -580,9 +580,9 @@ hint.mse.0.irq="5"
# iwn: Intel Wireless WiFi Link 1000/105/135/2000/4965/5000/6000/6050 abgn
# 802.11 network adapters
# Requires the iwn firmware module
+# mthca: Mellanox HCA InfiniBand
# mlx4ib: Mellanox ConnectX HCA InfiniBand
# mlx4en: Mellanox ConnectX HCA Ethernet
-# mthca: Mellanox HCA InfiniBand
# nfe: nVidia nForce MCP on-board Ethernet Networking (BSD open source)
# sbni: Granch SBNI12-xx ISA and PCI adapters
# vmx: VMware VMXNET3 Ethernet (BSD open source)
@@ -626,10 +626,10 @@ hint.le.0.at="isa"
hint.le.0.port="0x280"
hint.le.0.irq="10"
hint.le.0.drq="0"
+device mthca # Mellanox HCA InfiniBand
device mlx4 # Shared code module between IB and Ethernet
device mlx4ib # Mellanox ConnectX HCA InfiniBand
device mlx4en # Mellanox ConnectX HCA Ethernet
-device mthca # Mellanox HCA InfiniBand
device nfe # nVidia nForce MCP on-board Ethernet
device sbni
hint.sbni.0.at="isa"
diff --git a/sys/modules/Makefile b/sys/modules/Makefile
index 0e0434d..abd7566 100644
--- a/sys/modules/Makefile
+++ b/sys/modules/Makefile
@@ -677,13 +677,11 @@ _mlx4en= mlx4en
_mlx5en= mlx5en
.endif
.if ${MK_OFED} != "no" || defined(ALL_MODULES)
+_mthca= mthca
_mlx4ib= mlx4ib
_mlx5ib= mlx5ib
.endif
_mly= mly
-.if ${MK_OFED} != "no" || defined(ALL_MODULES)
-_mthca= mthca
-.endif
_nfe= nfe
_nvd= nvd
_nvme= nvme
diff --git a/sys/modules/cxgb/Makefile b/sys/modules/cxgb/Makefile
index f286b79..6dc7268 100644
--- a/sys/modules/cxgb/Makefile
+++ b/sys/modules/cxgb/Makefile
@@ -6,13 +6,13 @@ SYSDIR?=${SRCTOP}/sys
SUBDIR= cxgb
SUBDIR+= cxgb_t3fw
SUBDIR+= ${_tom}
-SUBDIR+= ${_iw_cxgb}
+#SUBDIR+= ${_iw_cxgb}
.if ${MACHINE_CPUARCH} == "amd64" || ${MACHINE_CPUARCH} == "i386"
_tom= tom
-.if ${MK_OFED} != "no" || defined(ALL_MODULES)
-_iw_cxgb= iw_cxgb
-.endif
+#.if ${MK_OFED} != "no" || defined(ALL_MODULES)
+#_iw_cxgb= iw_cxgb
+#.endif
.endif
.include <bsd.subdir.mk>
diff --git a/sys/modules/cxgbe/iw_cxgbe/Makefile b/sys/modules/cxgbe/iw_cxgbe/Makefile
index b07fe1b..e21281e 100644
--- a/sys/modules/cxgbe/iw_cxgbe/Makefile
+++ b/sys/modules/cxgbe/iw_cxgbe/Makefile
@@ -24,6 +24,9 @@ SRCS+= resource.c
SRCS+= vnode_if.h
CFLAGS+= -I${CXGBE} -I${SRCTOP}/sys/ofed/include -DLINUX_TYPES_DEFINED
+CFLAGS+= -I${SRCTOP}/sys/ofed/include/uapi
CFLAGS+= -I${SRCTOP}/sys/compat/linuxkpi/common/include
+CFLAGS+= -DCONFIG_INFINIBAND_USER_MEM
+CFLAGS+= -DINET6 -DINET
.include <bsd.kmod.mk>
diff --git a/sys/modules/ibcore/Makefile b/sys/modules/ibcore/Makefile
index 1845378..77a5f24 100644
--- a/sys/modules/ibcore/Makefile
+++ b/sys/modules/ibcore/Makefile
@@ -2,21 +2,40 @@
.PATH: ${SRCTOP}/sys/ofed/drivers/infiniband/core
KMOD= ibcore
-SRCS= addr.c iwcm.c sa_query.c ucma.c uverbs_cmd.c \
- agent.c multicast.c smi.c ud_header.c uverbs_main.c \
- mad.c peer_mem.c umem.c uverbs_marshall.c \
- cache.c device.c packer.c sysfs.c user_mad.c verbs.c \
- cm.c fmr_pool.c mad_rmpp.c ucm.c cma.c \
- vnode_if.h device_if.h bus_if.h pci_if.h \
- opt_inet.h opt_inet6.h
+SRCS= vnode_if.h device_if.h bus_if.h pci_if.h \
+ opt_inet.h opt_inet6.h \
+ ib_addr.c \
+ ib_agent.c \
+ ib_cache.c \
+ ib_cm.c \
+ ib_cma.c \
+ ib_cq.c \
+ ib_device.c \
+ ib_fmr_pool.c \
+ ib_iwcm.c \
+ ib_iwpm_msg.c \
+ ib_iwpm_util.c \
+ ib_mad.c \
+ ib_mad_rmpp.c \
+ ib_multicast.c \
+ ib_packer.c \
+ ib_roce_gid_mgmt.c \
+ ib_sa_query.c \
+ ib_smi.c \
+ ib_sysfs.c \
+ ib_ucm.c \
+ ib_ucma.c \
+ ib_ud_header.c \
+ ib_umem.c \
+ ib_user_mad.c \
+ ib_uverbs_cmd.c \
+ ib_uverbs_main.c \
+ ib_uverbs_marshall.c \
+ ib_verbs.c
-CFLAGS+= -I${SRCTOP}/sys/ofed/drivers/infiniband/core
CFLAGS+= -I${SRCTOP}/sys/ofed/include
+CFLAGS+= -I${SRCTOP}/sys/ofed/include/uapi
CFLAGS+= -I${SRCTOP}/sys/compat/linuxkpi/common/include
-CFLAGS+= -DINET6 -DINET
+CFLAGS+= -DINET6 -DINET -DCONFIG_INFINIBAND_USER_MEM
.include <bsd.kmod.mk>
-
-CFLAGS+= -Wno-cast-qual -Wno-pointer-arith
-
-CWARNFLAGS.cm.c= -Wno-unused-function
diff --git a/sys/modules/ipoib/Makefile b/sys/modules/ipoib/Makefile
index 11751ec..5b1a771 100644
--- a/sys/modules/ipoib/Makefile
+++ b/sys/modules/ipoib/Makefile
@@ -9,6 +9,7 @@ SRCS= device_if.h bus_if.h vnode_if.h pci_if.h \
CFLAGS+= -I${SRCTOP}/sys/ofed/drivers/infiniband/ulp/ipoib
CFLAGS+= -I${SRCTOP}/sys/ofed/include
+CFLAGS+= -I${SRCTOP}/sys/ofed/include/uapi
CFLAGS+= -I${SRCTOP}/sys/compat/linuxkpi/common/include
.include <bsd.kmod.mk>
diff --git a/sys/modules/iser/Makefile b/sys/modules/iser/Makefile
index bb2fd01..094ed06 100644
--- a/sys/modules/iser/Makefile
+++ b/sys/modules/iser/Makefile
@@ -20,6 +20,7 @@ SRCS+= icl_conn_if.h
CFLAGS+= -I${SRCTOP}/sys/
CFLAGS+= -I${SYSDIR}/ofed/include
+CFLAGS+= -I${SYSDIR}/ofed/include/uapi
CFLAGS+= -I${SYSDIR}/compat/linuxkpi/common/include
CFLAGS+= -DCONFIG_INFINIBAND_USER_MEM
CFLAGS+= -DINET6 -DINET
diff --git a/sys/modules/mlx4/Makefile b/sys/modules/mlx4/Makefile
index d71f79b..c2ade96 100644
--- a/sys/modules/mlx4/Makefile
+++ b/sys/modules/mlx4/Makefile
@@ -26,6 +26,7 @@ SRCS= device_if.h bus_if.h vnode_if.h pci_if.h \
mlx4_resource_tracker.c
CFLAGS+= -I${SRCTOP}/sys/ofed/include
+CFLAGS+= -I${SRCTOP}/sys/ofed/include/uapi
CFLAGS+= -I${SRCTOP}/sys/compat/linuxkpi/common/include
.include <bsd.kmod.mk>
diff --git a/sys/modules/mlx4ib/Makefile b/sys/modules/mlx4ib/Makefile
index 653b0f6..1d8ebf8 100644
--- a/sys/modules/mlx4ib/Makefile
+++ b/sys/modules/mlx4ib/Makefile
@@ -9,7 +9,6 @@ SRCS= device_if.h bus_if.h vnode_if.h pci_if.h \
mlx4_ib_sysfs.c \
mlx4_ib_ah.c \
mlx4_ib_cq.c \
- mlx4_ib_exp.c \
mlx4_ib_doorbell.c \
mlx4_ib_mad.c \
mlx4_ib_main.c \
@@ -20,6 +19,7 @@ SRCS= device_if.h bus_if.h vnode_if.h pci_if.h \
mlx4_ib_cm.c
CFLAGS+= -I${SRCTOP}/sys/ofed/include
+CFLAGS+= -I${SRCTOP}/sys/ofed/include/uapi
CFLAGS+= -I${SRCTOP}/sys/compat/linuxkpi/common/include
CFLAGS+= -DCONFIG_INFINIBAND_USER_MEM
CFLAGS+= -DINET6 -DINET
diff --git a/sys/modules/mlx5ib/Makefile b/sys/modules/mlx5ib/Makefile
index bc554ee..066d27a 100644
--- a/sys/modules/mlx5ib/Makefile
+++ b/sys/modules/mlx5ib/Makefile
@@ -6,18 +6,22 @@ SRCS= \
mlx5_ib_ah.c \
mlx5_ib_cq.c \
mlx5_ib_doorbell.c \
+mlx5_ib_gsi.c \
mlx5_ib_mad.c \
mlx5_ib_main.c \
mlx5_ib_mem.c \
mlx5_ib_mr.c \
mlx5_ib_qp.c \
-mlx5_ib_roce.c \
mlx5_ib_srq.c \
+mlx5_ib_virt.c \
device_if.h bus_if.h vnode_if.h pci_if.h \
opt_inet.h opt_inet6.h
CFLAGS+= -I${SRCTOP}/sys/ofed/include
+CFLAGS+= -I${SRCTOP}/sys/ofed/include/uapi
CFLAGS+= -I${SRCTOP}/sys/compat/linuxkpi/common/include
+CFLAGS+= -DCONFIG_INFINIBAND_USER_MEM
+CFLAGS+= -DINET -DINET6
.include <bsd.kmod.mk>
diff --git a/sys/modules/mthca/Makefile b/sys/modules/mthca/Makefile
index 2c057f2..ef436cc 100644
--- a/sys/modules/mthca/Makefile
+++ b/sys/modules/mthca/Makefile
@@ -1,16 +1,34 @@
# $FreeBSD$
-.PATH: ${SRCTOP}/sys/ofed/drivers/infiniband/hw/mthca
+.PATH: ${SRCTOP}/sys/dev/mthca
-KMOD = mthca
-SRCS = device_if.h bus_if.h pci_if.h vnode_if.h
-SRCS+= mthca_allocator.c mthca_av.c mthca_catas.c mthca_cmd.c mthca_cq.c
-SRCS+= mthca_eq.c mthca_mad.c mthca_main.c mthca_mcg.c mthca_memfree.c
-SRCS+= mthca_mr.c mthca_pd.c mthca_profile.c mthca_provider.c mthca_qp.c
-SRCS+= mthca_reset.c mthca_srq.c mthca_uar.c
-SRCS+= opt_inet.h opt_inet6.h
+KMOD= mthca
+SRCS= \
+mthca_allocator.c \
+mthca_av.c \
+mthca_catas.c \
+mthca_cmd.c \
+mthca_cq.c \
+mthca_eq.c \
+mthca_mad.c \
+mthca_main.c \
+mthca_mcg.c \
+mthca_memfree.c \
+mthca_mr.c \
+mthca_pd.c \
+mthca_profile.c \
+mthca_provider.c \
+mthca_qp.c \
+mthca_reset.c \
+mthca_srq.c \
+mthca_uar.c \
+device_if.h bus_if.h vnode_if.h pci_if.h \
+ opt_inet.h opt_inet6.h
CFLAGS+= -I${SRCTOP}/sys/ofed/include
+CFLAGS+= -I${SRCTOP}/sys/ofed/include/uapi
CFLAGS+= -I${SRCTOP}/sys/compat/linuxkpi/common/include
+CFLAGS+= -DCONFIG_INFINIBAND_USER_MEM
+CFLAGS+= -DINET6 -DINET
.include <bsd.kmod.mk>
diff --git a/sys/modules/rdma/krping/Makefile b/sys/modules/rdma/krping/Makefile
index 9f530e0..2adff09 100644
--- a/sys/modules/rdma/krping/Makefile
+++ b/sys/modules/rdma/krping/Makefile
@@ -6,6 +6,7 @@ SRCS= krping.c krping_dev.c getopt.c
SRCS+= bus_if.h device_if.h pci_if.h pcib_if.h vnode_if.h
SRCS+= opt_sched.h opt_inet.h opt_inet6.h
CFLAGS+= -I${SRCTOP}/sys/ofed/include
+CFLAGS+= -I${SRCTOP}/sys/ofed/include/uapi
CFLAGS+= -I${SRCTOP}/sys/compat/linuxkpi/common/include
.include <bsd.kmod.mk>
diff --git a/sys/modules/rdma/krping_compat/Makefile b/sys/modules/rdma/krping_compat/Makefile
new file mode 100644
index 0000000..0028cc8
--- /dev/null
+++ b/sys/modules/rdma/krping_compat/Makefile
@@ -0,0 +1,12 @@
+# $FreeBSD$
+.PATH: ${SRCTOP}/sys/contrib/rdma/krping_compat
+
+KMOD= krping_compat
+SRCS= krping.c krping_dev.c getopt.c
+SRCS+= bus_if.h device_if.h pci_if.h pcib_if.h vnode_if.h
+SRCS+= opt_sched.h opt_inet.h opt_inet6.h
+CFLAGS+= -I${SRCTOP}/sys/ofed/include
+CFLAGS+= -I${SRCTOP}/sys/ofed/include/uapi
+CFLAGS+= -I${SRCTOP}/sys/compat/linuxkpi/common/include
+
+.include <bsd.kmod.mk>
diff --git a/sys/ofed/drivers/infiniband/Kconfig b/sys/ofed/drivers/infiniband/Kconfig
deleted file mode 100644
index 0a2ef11..0000000
--- a/sys/ofed/drivers/infiniband/Kconfig
+++ /dev/null
@@ -1,66 +0,0 @@
-menuconfig INFINIBAND
- tristate "InfiniBand support"
- depends on PCI || BROKEN
- depends on HAS_IOMEM
- ---help---
- Core support for InfiniBand (IB). Make sure to also select
- any protocols you wish to use as well as drivers for your
- InfiniBand hardware.
-
-if INFINIBAND
-
-config INFINIBAND_USER_MAD
- tristate "InfiniBand userspace MAD support"
- depends on INFINIBAND
- ---help---
- Userspace InfiniBand Management Datagram (MAD) support. This
- is the kernel side of the userspace MAD support, which allows
- userspace processes to send and receive MADs. You will also
- need libibumad from <http://www.openib.org>.
-
-config INFINIBAND_USER_ACCESS
- tristate "InfiniBand userspace access (verbs and CM)"
- ---help---
- Userspace InfiniBand access support. This enables the
- kernel side of userspace verbs and the userspace
- communication manager (CM). This allows userspace processes
- to set up connections and directly access InfiniBand
- hardware for fast-path operations. You will also need
- libibverbs, libibcm and a hardware driver library from
- <http://www.openib.org>.
-
-config INFINIBAND_USER_MEM
- bool
- depends on INFINIBAND_USER_ACCESS != n
- default y
-
-config INFINIBAND_ADDR_TRANS
- bool
- depends on INET
- depends on !(INFINIBAND = y && IPV6 = m)
- default y
-
-source "drivers/infiniband/hw/mthca/Kconfig"
-source "drivers/infiniband/hw/ipath/Kconfig"
-source "drivers/infiniband/hw/qib/Kconfig"
-source "drivers/infiniband/hw/ehca/Kconfig"
-source "drivers/infiniband/hw/amso1100/Kconfig"
-source "drivers/infiniband/hw/cxgb3/Kconfig"
-source "drivers/infiniband/hw/mlx4/Kconfig"
-source "drivers/infiniband/hw/nes/Kconfig"
-
-source "drivers/infiniband/ulp/ipoib/Kconfig"
-
-source "drivers/infiniband/ulp/srp/Kconfig"
-
-source "drivers/infiniband/ulp/srpt/Kconfig"
-
-source "drivers/infiniband/ulp/iser/Kconfig"
-
-source "drivers/infiniband/ulp/sdp/Kconfig"
-
-source "drivers/infiniband/ulp/qlgc_vnic/Kconfig"
-
-source "drivers/infiniband/util/Kconfig"
-
-endif # INFINIBAND
diff --git a/sys/ofed/drivers/infiniband/Makefile b/sys/ofed/drivers/infiniband/Makefile
deleted file mode 100644
index ea5dbe0..0000000
--- a/sys/ofed/drivers/infiniband/Makefile
+++ /dev/null
@@ -1,17 +0,0 @@
-obj-$(CONFIG_INFINIBAND) += core/
-obj-$(CONFIG_INFINIBAND_MTHCA) += hw/mthca/
-obj-$(CONFIG_INFINIBAND_IPATH) += hw/ipath/
-obj-$(CONFIG_INFINIBAND_QIB) += hw/qib/
-obj-$(CONFIG_INFINIBAND_EHCA) += hw/ehca/
-obj-$(CONFIG_INFINIBAND_AMSO1100) += hw/amso1100/
-obj-$(CONFIG_INFINIBAND_CXGB3) += hw/cxgb3/
-obj-$(CONFIG_INFINIBAND_NES) += hw/nes/
-obj-$(CONFIG_MLX4_INFINIBAND) += hw/mlx4/
-obj-$(CONFIG_INFINIBAND_NES) += hw/nes/
-obj-$(CONFIG_INFINIBAND_IPOIB) += ulp/ipoib/
-obj-$(CONFIG_INFINIBAND_SRP) += ulp/srp/
-obj-$(CONFIG_INFINIBAND_SRPT) += ulp/srpt/
-obj-$(CONFIG_INFINIBAND_ISER) += ulp/iser/
-obj-$(CONFIG_INFINIBAND_SDP) += ulp/sdp/
-obj-$(CONFIG_INFINIBAND_QLGC_VNIC) += ulp/qlgc_vnic/
-obj-$(CONFIG_INFINIBAND_MADEYE) += util/
diff --git a/sys/ofed/drivers/infiniband/core/addr.c b/sys/ofed/drivers/infiniband/core/addr.c
deleted file mode 100644
index a95e86a..0000000
--- a/sys/ofed/drivers/infiniband/core/addr.c
+++ /dev/null
@@ -1,610 +0,0 @@
-/*
- * Copyright (c) 2005 Voltaire Inc. All rights reserved.
- * Copyright (c) 2002-2005, Network Appliance, Inc. All rights reserved.
- * Copyright (c) 1999-2005, Mellanox Technologies, Inc. All rights reserved.
- * Copyright (c) 2005 Intel Corporation. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-#include <linux/mutex.h>
-#include <linux/inetdevice.h>
-#include <linux/slab.h>
-#include <linux/workqueue.h>
-#include <linux/module.h>
-#include <linux/notifier.h>
-#include <net/route.h>
-#include <net/netevent.h>
-#include <rdma/ib_addr.h>
-#include <netinet/if_ether.h>
-#include <netinet6/scope6_var.h>
-
-
-MODULE_AUTHOR("Sean Hefty");
-MODULE_DESCRIPTION("IB Address Translation");
-MODULE_LICENSE("Dual BSD/GPL");
-
-struct addr_req {
- struct list_head list;
- struct sockaddr_storage src_addr;
- struct sockaddr_storage dst_addr;
- struct rdma_dev_addr *addr;
- struct rdma_addr_client *client;
- void *context;
- void (*callback)(int status, struct sockaddr *src_addr,
- struct rdma_dev_addr *addr, void *context);
- unsigned long timeout;
- int status;
-};
-
-static void process_req(struct work_struct *work);
-
-static DEFINE_MUTEX(lock);
-static LIST_HEAD(req_list);
-static struct delayed_work work;
-static struct workqueue_struct *addr_wq;
-
-static struct rdma_addr_client self;
-void rdma_addr_register_client(struct rdma_addr_client *client)
-{
- atomic_set(&client->refcount, 1);
- init_completion(&client->comp);
-}
-EXPORT_SYMBOL(rdma_addr_register_client);
-
-static inline void put_client(struct rdma_addr_client *client)
-{
- if (atomic_dec_and_test(&client->refcount))
- complete(&client->comp);
-}
-
-void rdma_addr_unregister_client(struct rdma_addr_client *client)
-{
- put_client(client);
- wait_for_completion(&client->comp);
-}
-EXPORT_SYMBOL(rdma_addr_unregister_client);
-
-int rdma_copy_addr(struct rdma_dev_addr *dev_addr, struct ifnet *dev,
- const unsigned char *dst_dev_addr)
-{
- if (dev->if_type == IFT_INFINIBAND)
- dev_addr->dev_type = ARPHRD_INFINIBAND;
- else if (dev->if_type == IFT_ETHER)
- dev_addr->dev_type = ARPHRD_ETHER;
- else
- dev_addr->dev_type = 0;
- memcpy(dev_addr->src_dev_addr, IF_LLADDR(dev), dev->if_addrlen);
- memcpy(dev_addr->broadcast, __DECONST(char *, dev->if_broadcastaddr),
- dev->if_addrlen);
- if (dst_dev_addr)
- memcpy(dev_addr->dst_dev_addr, dst_dev_addr, dev->if_addrlen);
- dev_addr->bound_dev_if = dev->if_index;
- return 0;
-}
-EXPORT_SYMBOL(rdma_copy_addr);
-
-int rdma_translate_ip(struct sockaddr *addr, struct rdma_dev_addr *dev_addr,
- u16 *vlan_id)
-{
- struct net_device *dev;
- int ret = -EADDRNOTAVAIL;
-
- if (dev_addr->bound_dev_if) {
- dev = dev_get_by_index(&init_net, dev_addr->bound_dev_if);
- if (!dev)
- return -ENODEV;
- ret = rdma_copy_addr(dev_addr, dev, NULL);
- dev_put(dev);
- return ret;
- }
-
- switch (addr->sa_family) {
- case AF_INET:
- dev = ip_dev_find(&init_net,
- ((struct sockaddr_in *) addr)->sin_addr.s_addr);
-
- if (!dev)
- return ret;
-
- ret = rdma_copy_addr(dev_addr, dev, NULL);
- if (vlan_id)
- *vlan_id = rdma_vlan_dev_vlan_id(dev);
- dev_put(dev);
- break;
-
-#if defined(INET6)
- case AF_INET6:
- dev = ip6_dev_find(&init_net,
- ((const struct sockaddr_in6 *)addr)->sin6_addr);
-
- if (!dev)
- return ret;
-
- ret = rdma_copy_addr(dev_addr, dev, NULL);
- if (vlan_id)
- *vlan_id = rdma_vlan_dev_vlan_id(dev);
- dev_put(dev);
- break;
-#endif
- default:
- break;
- }
- return ret;
-}
-EXPORT_SYMBOL(rdma_translate_ip);
-
-static void set_timeout(unsigned long time)
-{
- int delay; /* under FreeBSD ticks are 32-bit */
-
- delay = time - jiffies;
- if (delay <= 0)
- delay = 1;
-
- mod_delayed_work(addr_wq, &work, delay);
-}
-
-static void queue_req(struct addr_req *req)
-{
- struct addr_req *temp_req;
-
- mutex_lock(&lock);
- list_for_each_entry_reverse(temp_req, &req_list, list) {
- if (time_after_eq(req->timeout, temp_req->timeout))
- break;
- }
-
- list_add(&req->list, &temp_req->list);
-
- if (req_list.next == &req->list)
- set_timeout(req->timeout);
- mutex_unlock(&lock);
-}
-
-static int addr_resolve(struct sockaddr *src_in,
- struct sockaddr *dst_in,
- struct rdma_dev_addr *addr)
-{
- struct sockaddr_in *sin;
- struct sockaddr_in6 *sin6;
- struct ifaddr *ifa;
- struct ifnet *ifp;
- struct rtentry *rte;
-#if defined(INET6)
- struct sockaddr_in6 dstv6_tmp;
-#endif
- u_char edst[MAX_ADDR_LEN];
- int multi;
- int bcast;
- int is_gw = 0;
- int error = 0;
-
- CURVNET_SET_QUIET(&init_net);
-
- /*
- * Determine whether the address is unicast, multicast, or broadcast
- * and whether the source interface is valid.
- */
- multi = 0;
- bcast = 0;
- sin = NULL;
- sin6 = NULL;
- ifp = NULL;
- rte = NULL;
- ifa = NULL;
- memset(edst, 0, sizeof(edst));
-
- switch (dst_in->sa_family) {
-#ifdef INET
- case AF_INET:
- sin = (struct sockaddr_in *)dst_in;
- if (sin->sin_addr.s_addr == INADDR_BROADCAST)
- bcast = 1;
- if (IN_MULTICAST(ntohl(sin->sin_addr.s_addr)))
- multi = 1;
- sin = (struct sockaddr_in *)src_in;
- if (sin->sin_addr.s_addr != INADDR_ANY) {
- ifp = ip_dev_find(&init_net, sin->sin_addr.s_addr);
- if (ifp == NULL) {
- error = ENETUNREACH;
- goto done;
- }
- if (bcast || multi)
- goto mcast;
- }
- break;
-#endif
-#ifdef INET6
- case AF_INET6:
- /* Make destination socket address writeable */
- dstv6_tmp = *(struct sockaddr_in6 *)dst_in;
- dst_in = (struct sockaddr *)&dstv6_tmp;
- sin6 = (struct sockaddr_in6 *)dst_in;
- if (IN6_IS_ADDR_MULTICAST(&sin6->sin6_addr))
- multi = 1;
- /*
- * Make sure the scope ID gets embedded, else rtalloc1() will
- * resolve to the loopback interface.
- */
- sin6->sin6_scope_id = addr->bound_dev_if;
- sa6_embedscope(sin6, 0);
-
- sin6 = (struct sockaddr_in6 *)src_in;
- if (!IN6_IS_ADDR_UNSPECIFIED(&sin6->sin6_addr)) {
- ifp = ip6_dev_find(&init_net, sin6->sin6_addr);
- if (ifp == NULL) {
- error = ENETUNREACH;
- goto done;
- }
- if (bcast || multi)
- goto mcast;
- }
- break;
-#endif
- default:
- error = EINVAL;
- goto done;
- }
- /*
- * Make sure the route exists and has a valid link.
- */
- rte = rtalloc1(dst_in, 1, 0);
- if (rte == NULL || rte->rt_ifp == NULL ||
- RT_LINK_IS_UP(rte->rt_ifp) == 0 ||
- rte->rt_ifp == V_loif) {
- if (rte != NULL) {
- RTFREE_LOCKED(rte);
- rte = NULL;
- }
- error = EHOSTUNREACH;
- goto done;
- }
- if (rte->rt_flags & RTF_GATEWAY)
- is_gw = 1;
- /*
- * If it's not multicast or broadcast and the route doesn't match the
- * requested interface return unreachable. Otherwise fetch the
- * correct interface pointer and unlock the route.
- */
- if (multi || bcast) {
- /* rt_ifa holds the route answer source address */
- ifa = rte->rt_ifa;
-
- if (ifp == NULL) {
- ifp = rte->rt_ifp;
- dev_hold(ifp);
- }
- RTFREE_LOCKED(rte);
- rte = NULL;
- } else if (ifp != NULL && ifp != rte->rt_ifp) {
- RTFREE_LOCKED(rte);
- rte = NULL;
- error = ENETUNREACH;
- goto done;
- } else {
- /* rt_ifa holds the route answer source address */
- ifa = rte->rt_ifa;
-
- if (ifp == NULL) {
- ifp = rte->rt_ifp;
- dev_hold(ifp);
- }
- RT_UNLOCK(rte);
- }
-#if defined(INET) || defined(INET6)
-mcast:
-#endif
- if (bcast) {
- memcpy(edst, ifp->if_broadcastaddr, ifp->if_addrlen);
- goto done;
- } else if (multi) {
- struct sockaddr *llsa;
- struct sockaddr_dl sdl;
-
- sdl.sdl_len = sizeof(sdl);
- llsa = (struct sockaddr *)&sdl;
-
- if (ifp->if_resolvemulti == NULL) {
- error = EOPNOTSUPP;
- goto done;
- }
- error = ifp->if_resolvemulti(ifp, &llsa, dst_in);
- if (error == 0) {
- memcpy(edst, LLADDR((struct sockaddr_dl *)llsa),
- ifp->if_addrlen);
- }
- goto done;
- }
- /*
- * Resolve the link local address.
- */
- switch (dst_in->sa_family) {
-#ifdef INET
- case AF_INET:
- error = arpresolve(ifp, is_gw, NULL,
- is_gw ? rte->rt_gateway : dst_in, edst, NULL, NULL);
- break;
-#endif
-#ifdef INET6
- case AF_INET6:
- error = nd6_resolve(ifp, is_gw, NULL,
- is_gw ? rte->rt_gateway : dst_in, edst, NULL, NULL);
- break;
-#endif
- default:
- KASSERT(0, ("rdma_addr_resolve: Unreachable"));
- error = EINVAL;
- break;
- }
-done:
- if (error == 0)
- error = -rdma_copy_addr(addr, ifp, edst);
- if (error == 0)
- memcpy(src_in, ifa->ifa_addr, ip_addr_size(ifa->ifa_addr));
- if (error == EWOULDBLOCK)
- error = ENODATA;
- if (rte != NULL)
- RTFREE(rte);
- if (ifp != NULL)
- dev_put(ifp);
-
- CURVNET_RESTORE();
- return -error;
-}
-
-static void process_req(struct work_struct *work)
-{
- struct addr_req *req, *temp_req;
- struct sockaddr *src_in, *dst_in;
- struct list_head done_list;
-
- INIT_LIST_HEAD(&done_list);
-
- mutex_lock(&lock);
- list_for_each_entry_safe(req, temp_req, &req_list, list) {
- if (req->status == -ENODATA) {
- src_in = (struct sockaddr *) &req->src_addr;
- dst_in = (struct sockaddr *) &req->dst_addr;
- req->status = addr_resolve(src_in, dst_in, req->addr);
- if (req->status && time_after_eq(jiffies, req->timeout))
- req->status = -ETIMEDOUT;
- else if (req->status == -ENODATA)
- continue;
- }
- list_move_tail(&req->list, &done_list);
- }
-
- if (!list_empty(&req_list)) {
- req = list_entry(req_list.next, struct addr_req, list);
- set_timeout(req->timeout);
- }
- mutex_unlock(&lock);
-
- list_for_each_entry_safe(req, temp_req, &done_list, list) {
- list_del(&req->list);
- req->callback(req->status, (struct sockaddr *) &req->src_addr,
- req->addr, req->context);
- put_client(req->client);
- kfree(req);
- }
-}
-
-int rdma_resolve_ip(struct rdma_addr_client *client,
- struct sockaddr *src_addr, struct sockaddr *dst_addr,
- struct rdma_dev_addr *addr, int timeout_ms,
- void (*callback)(int status, struct sockaddr *src_addr,
- struct rdma_dev_addr *addr, void *context),
- void *context)
-{
- struct sockaddr *src_in, *dst_in;
- struct addr_req *req;
- int ret = 0;
-
- req = kzalloc(sizeof *req, GFP_KERNEL);
- if (!req)
- return -ENOMEM;
-
- src_in = (struct sockaddr *) &req->src_addr;
- dst_in = (struct sockaddr *) &req->dst_addr;
-
- if (src_addr) {
- if (src_addr->sa_family != dst_addr->sa_family) {
- ret = -EINVAL;
- goto err;
- }
-
- memcpy(src_in, src_addr, ip_addr_size(src_addr));
- } else {
- src_in->sa_family = dst_addr->sa_family;
- }
-
- memcpy(dst_in, dst_addr, ip_addr_size(dst_addr));
- req->addr = addr;
- req->callback = callback;
- req->context = context;
- req->client = client;
- atomic_inc(&client->refcount);
-
- req->status = addr_resolve(src_in, dst_in, addr);
- switch (req->status) {
- case 0:
- req->timeout = jiffies;
- queue_req(req);
- break;
- case -ENODATA:
- req->timeout = msecs_to_jiffies(timeout_ms) + jiffies;
- queue_req(req);
- break;
- default:
- ret = req->status;
- atomic_dec(&client->refcount);
- goto err;
- }
- return ret;
-err:
- kfree(req);
- return ret;
-}
-EXPORT_SYMBOL(rdma_resolve_ip);
-
-void rdma_addr_cancel(struct rdma_dev_addr *addr)
-{
- struct addr_req *req, *temp_req;
-
- mutex_lock(&lock);
- list_for_each_entry_safe(req, temp_req, &req_list, list) {
- if (req->addr == addr) {
- req->status = -ECANCELED;
- req->timeout = jiffies;
- list_move(&req->list, &req_list);
- set_timeout(req->timeout);
- break;
- }
- }
- mutex_unlock(&lock);
-}
-EXPORT_SYMBOL(rdma_addr_cancel);
-
-struct resolve_cb_context {
- struct rdma_dev_addr *addr;
- struct completion comp;
-};
-
-static void resolve_cb(int status, struct sockaddr *src_addr,
- struct rdma_dev_addr *addr, void *context)
-{
- memcpy(((struct resolve_cb_context *)context)->addr, addr, sizeof(struct
- rdma_dev_addr));
- complete(&((struct resolve_cb_context *)context)->comp);
-}
-
-int rdma_addr_find_dmac_by_grh(union ib_gid *sgid, union ib_gid *dgid, u8 *dmac,
- u16 *vlan_id, int *if_index)
-{
- int ret = 0;
- struct rdma_dev_addr dev_addr;
- struct resolve_cb_context ctx;
- struct net_device *dev;
-
- union {
- struct sockaddr _sockaddr;
- struct sockaddr_in _sockaddr_in;
- struct sockaddr_in6 _sockaddr_in6;
- } sgid_addr, dgid_addr;
-
- ret = rdma_gid2ip(&sgid_addr._sockaddr, sgid);
- if (ret)
- return ret;
-
- ret = rdma_gid2ip(&dgid_addr._sockaddr, dgid);
- if (ret)
- return ret;
-
- memset(&dev_addr, 0, sizeof(dev_addr));
- if (if_index)
- dev_addr.bound_dev_if = *if_index;
-
- ctx.addr = &dev_addr;
- init_completion(&ctx.comp);
- ret = rdma_resolve_ip(&self, &sgid_addr._sockaddr, &dgid_addr._sockaddr,
- &dev_addr, 1000, resolve_cb, &ctx);
- if (ret)
- return ret;
-
- wait_for_completion(&ctx.comp);
-
- memcpy(dmac, dev_addr.dst_dev_addr, ETH_ALEN);
- dev = dev_get_by_index(&init_net, dev_addr.bound_dev_if);
- if (!dev)
- return -ENODEV;
- if (vlan_id)
- *vlan_id = rdma_vlan_dev_vlan_id(dev);
- dev_put(dev);
- return ret;
-}
-EXPORT_SYMBOL(rdma_addr_find_dmac_by_grh);
-
-int rdma_addr_find_smac_by_sgid(union ib_gid *sgid, u8 *smac, u16 *vlan_id)
-{
- int ret = 0;
- struct rdma_dev_addr dev_addr;
- union {
- struct sockaddr _sockaddr;
- struct sockaddr_in _sockaddr_in;
- struct sockaddr_in6 _sockaddr_in6;
- } gid_addr;
-
- ret = rdma_gid2ip(&gid_addr._sockaddr, sgid);
- if (ret)
- return ret;
- memset(&dev_addr, 0, sizeof(dev_addr));
- ret = rdma_translate_ip(&gid_addr._sockaddr, &dev_addr, vlan_id);
- if (ret)
- return ret;
-
- memcpy(smac, dev_addr.src_dev_addr, ETH_ALEN);
- return ret;
-}
-EXPORT_SYMBOL(rdma_addr_find_smac_by_sgid);
-
-static int netevent_callback(struct notifier_block *self, unsigned long event,
- void *ctx)
-{
- if (event == NETEVENT_NEIGH_UPDATE) {
- set_timeout(jiffies);
- }
- return 0;
-}
-
-static struct notifier_block nb = {
- .notifier_call = netevent_callback
-};
-
-static int __init addr_init(void)
-{
- INIT_DELAYED_WORK(&work, process_req);
- addr_wq = create_singlethread_workqueue("ib_addr");
- if (!addr_wq)
- return -ENOMEM;
-
- register_netevent_notifier(&nb);
- rdma_addr_register_client(&self);
- return 0;
-}
-
-static void __exit addr_cleanup(void)
-{
- rdma_addr_unregister_client(&self);
- unregister_netevent_notifier(&nb);
- destroy_workqueue(addr_wq);
-}
-
-module_init(addr_init);
-module_exit(addr_cleanup);
diff --git a/sys/ofed/drivers/infiniband/core/agent.c b/sys/ofed/drivers/infiniband/core/agent.c
deleted file mode 100644
index 2bc7f5a..0000000
--- a/sys/ofed/drivers/infiniband/core/agent.c
+++ /dev/null
@@ -1,217 +0,0 @@
-/*
- * Copyright (c) 2004, 2005 Mellanox Technologies Ltd. All rights reserved.
- * Copyright (c) 2004, 2005 Infinicon Corporation. All rights reserved.
- * Copyright (c) 2004, 2005 Intel Corporation. All rights reserved.
- * Copyright (c) 2004, 2005 Topspin Corporation. All rights reserved.
- * Copyright (c) 2004-2007 Voltaire Corporation. All rights reserved.
- * Copyright (c) 2005 Sun Microsystems, Inc. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- */
-
-#include <linux/slab.h>
-#include <linux/string.h>
-
-#include "agent.h"
-#include "smi.h"
-#include "mad_priv.h"
-
-#define SPFX "ib_agent: "
-
-struct ib_agent_port_private {
- struct list_head port_list;
- struct ib_mad_agent *agent[2];
-};
-
-static DEFINE_SPINLOCK(ib_agent_port_list_lock);
-static LIST_HEAD(ib_agent_port_list);
-
-static struct ib_agent_port_private *
-__ib_get_agent_port(struct ib_device *device, int port_num)
-{
- struct ib_agent_port_private *entry;
-
- list_for_each_entry(entry, &ib_agent_port_list, port_list) {
- if (entry->agent[1]->device == device &&
- entry->agent[1]->port_num == port_num)
- return entry;
- }
- return NULL;
-}
-
-static struct ib_agent_port_private *
-ib_get_agent_port(struct ib_device *device, int port_num)
-{
- struct ib_agent_port_private *entry;
- unsigned long flags;
-
- spin_lock_irqsave(&ib_agent_port_list_lock, flags);
- entry = __ib_get_agent_port(device, port_num);
- spin_unlock_irqrestore(&ib_agent_port_list_lock, flags);
- return entry;
-}
-
-void agent_send_response(struct ib_mad *mad, struct ib_grh *grh,
- struct ib_wc *wc, struct ib_device *device,
- int port_num, int qpn)
-{
- struct ib_agent_port_private *port_priv;
- struct ib_mad_agent *agent;
- struct ib_mad_send_buf *send_buf;
- struct ib_ah *ah;
- struct ib_mad_send_wr_private *mad_send_wr;
-
- if (device->node_type == RDMA_NODE_IB_SWITCH)
- port_priv = ib_get_agent_port(device, 0);
- else
- port_priv = ib_get_agent_port(device, port_num);
-
- if (!port_priv) {
- printk(KERN_ERR SPFX "Unable to find port agent\n");
- return;
- }
-
- agent = port_priv->agent[qpn];
- ah = ib_create_ah_from_wc(agent->qp->pd, wc, grh, port_num);
- if (IS_ERR(ah)) {
- printk(KERN_ERR SPFX "ib_create_ah_from_wc error %ld\n",
- PTR_ERR(ah));
- return;
- }
-
- send_buf = ib_create_send_mad(agent, wc->src_qp, wc->pkey_index, 0,
- IB_MGMT_MAD_HDR, IB_MGMT_MAD_DATA,
- GFP_KERNEL);
- if (IS_ERR(send_buf)) {
- printk(KERN_ERR SPFX "ib_create_send_mad error\n");
- goto err1;
- }
-
- memcpy(send_buf->mad, mad, sizeof *mad);
- send_buf->ah = ah;
-
- if (device->node_type == RDMA_NODE_IB_SWITCH) {
- mad_send_wr = container_of(send_buf,
- struct ib_mad_send_wr_private,
- send_buf);
- mad_send_wr->send_wr.wr.ud.port_num = port_num;
- }
-
- if (ib_post_send_mad(send_buf, NULL)) {
- printk(KERN_ERR SPFX "ib_post_send_mad error\n");
- goto err2;
- }
- return;
-err2:
- ib_free_send_mad(send_buf);
-err1:
- ib_destroy_ah(ah);
-}
-
-static void agent_send_handler(struct ib_mad_agent *mad_agent,
- struct ib_mad_send_wc *mad_send_wc)
-{
- ib_destroy_ah(mad_send_wc->send_buf->ah);
- ib_free_send_mad(mad_send_wc->send_buf);
-}
-
-int ib_agent_port_open(struct ib_device *device, int port_num)
-{
- struct ib_agent_port_private *port_priv;
- unsigned long flags;
- int ret;
-
- /* Create new device info */
- port_priv = kzalloc(sizeof *port_priv, GFP_KERNEL);
- if (!port_priv) {
- printk(KERN_ERR SPFX "No memory for ib_agent_port_private\n");
- ret = -ENOMEM;
- goto error1;
- }
-
- if (rdma_port_get_link_layer(device, port_num) == IB_LINK_LAYER_INFINIBAND) {
- /* Obtain send only MAD agent for SMI QP */
- port_priv->agent[0] = ib_register_mad_agent(device, port_num,
- IB_QPT_SMI, NULL, 0,
- &agent_send_handler,
- NULL, NULL);
- if (IS_ERR(port_priv->agent[0])) {
- ret = PTR_ERR(port_priv->agent[0]);
- goto error2;
- }
- }
-
- /* Obtain send only MAD agent for GSI QP */
- port_priv->agent[1] = ib_register_mad_agent(device, port_num,
- IB_QPT_GSI, NULL, 0,
- &agent_send_handler,
- NULL, NULL);
- if (IS_ERR(port_priv->agent[1])) {
- ret = PTR_ERR(port_priv->agent[1]);
- goto error3;
- }
-
- spin_lock_irqsave(&ib_agent_port_list_lock, flags);
- list_add_tail(&port_priv->port_list, &ib_agent_port_list);
- spin_unlock_irqrestore(&ib_agent_port_list_lock, flags);
-
- return 0;
-
-error3:
- if (port_priv->agent[0])
- ib_unregister_mad_agent(port_priv->agent[0]);
-error2:
- kfree(port_priv);
-error1:
- return ret;
-}
-
-int ib_agent_port_close(struct ib_device *device, int port_num)
-{
- struct ib_agent_port_private *port_priv;
- unsigned long flags;
-
- spin_lock_irqsave(&ib_agent_port_list_lock, flags);
- port_priv = __ib_get_agent_port(device, port_num);
- if (port_priv == NULL) {
- spin_unlock_irqrestore(&ib_agent_port_list_lock, flags);
- printk(KERN_ERR SPFX "Port %d not found\n", port_num);
- return -ENODEV;
- }
- list_del(&port_priv->port_list);
- spin_unlock_irqrestore(&ib_agent_port_list_lock, flags);
-
- ib_unregister_mad_agent(port_priv->agent[1]);
- if (port_priv->agent[0])
- ib_unregister_mad_agent(port_priv->agent[0]);
-
- kfree(port_priv);
- return 0;
-}
diff --git a/sys/ofed/drivers/infiniband/core/agent.h b/sys/ofed/drivers/infiniband/core/agent.h
index 6669287..65f92be 100644
--- a/sys/ofed/drivers/infiniband/core/agent.h
+++ b/sys/ofed/drivers/infiniband/core/agent.h
@@ -44,8 +44,8 @@ extern int ib_agent_port_open(struct ib_device *device, int port_num);
extern int ib_agent_port_close(struct ib_device *device, int port_num);
-extern void agent_send_response(struct ib_mad *mad, struct ib_grh *grh,
- struct ib_wc *wc, struct ib_device *device,
- int port_num, int qpn);
+extern void agent_send_response(const struct ib_mad_hdr *mad_hdr, const struct ib_grh *grh,
+ const struct ib_wc *wc, const struct ib_device *device,
+ int port_num, int qpn, size_t resp_mad_len, bool opa);
#endif /* __AGENT_H_ */
diff --git a/sys/ofed/drivers/infiniband/core/cache.c b/sys/ofed/drivers/infiniband/core/cache.c
deleted file mode 100644
index d11e7c2..0000000
--- a/sys/ofed/drivers/infiniband/core/cache.c
+++ /dev/null
@@ -1,467 +0,0 @@
-/*
- * Copyright (c) 2004 Topspin Communications. All rights reserved.
- * Copyright (c) 2005 Intel Corporation. All rights reserved.
- * Copyright (c) 2005 Sun Microsystems, Inc. All rights reserved.
- * Copyright (c) 2005 Voltaire, Inc. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-#include <linux/module.h>
-#include <linux/errno.h>
-#include <linux/slab.h>
-#include <linux/workqueue.h>
-
-#include <rdma/ib_cache.h>
-
-#include "core_priv.h"
-
-struct ib_pkey_cache {
- int table_len;
- u16 table[0];
-};
-
-struct ib_gid_cache {
- int table_len;
- union ib_gid table[0];
-};
-
-struct ib_update_work {
- struct work_struct work;
- struct ib_device *device;
- u8 port_num;
-};
-
-static inline int start_port(struct ib_device *device)
-{
- return (device->node_type == RDMA_NODE_IB_SWITCH) ? 0 : 1;
-}
-
-static inline int end_port(struct ib_device *device)
-{
- return (device->node_type == RDMA_NODE_IB_SWITCH) ?
- 0 : device->phys_port_cnt;
-}
-
-int ib_get_cached_gid(struct ib_device *device,
- u8 port_num,
- int index,
- union ib_gid *gid)
-{
- struct ib_gid_cache *cache;
- unsigned long flags;
- int ret = -EINVAL;
-
- if (port_num < start_port(device) || port_num > end_port(device))
- return -EINVAL;
-
- read_lock_irqsave(&device->cache.lock, flags);
-
- if (device->cache.gid_cache) {
- cache = device->cache.gid_cache[port_num - start_port(device)];
-
- if (cache && index >= 0 && index < cache->table_len) {
- *gid = cache->table[index];
- ret = 0;
- }
- }
-
- read_unlock_irqrestore(&device->cache.lock, flags);
-
- return ret;
-}
-EXPORT_SYMBOL(ib_get_cached_gid);
-
-int ib_find_cached_gid(struct ib_device *device,
- union ib_gid *gid,
- u8 *port_num,
- u16 *index)
-{
- struct ib_gid_cache *cache;
- unsigned long flags;
- int p, i;
- int ret = -ENOENT;
-
- *port_num = -1;
- if (index)
- *index = -1;
-
- read_lock_irqsave(&device->cache.lock, flags);
- if (!device->cache.gid_cache)
- goto out;
- for (p = 0; p <= end_port(device) - start_port(device); ++p) {
- cache = device->cache.gid_cache[p];
- if (!cache)
- continue;
- for (i = 0; i < cache->table_len; ++i) {
- if (!memcmp(gid, &cache->table[i], sizeof *gid)) {
- *port_num = p + start_port(device);
- if (index)
- *index = i;
- ret = 0;
- goto out;
- }
- }
- }
-out:
- read_unlock_irqrestore(&device->cache.lock, flags);
- return ret;
-}
-EXPORT_SYMBOL(ib_find_cached_gid);
-
-int ib_get_cached_pkey(struct ib_device *device,
- u8 port_num,
- int index,
- u16 *pkey)
-{
- struct ib_pkey_cache *cache;
- unsigned long flags;
- int ret = -EINVAL;
-
- if (port_num < start_port(device) || port_num > end_port(device))
- return -EINVAL;
-
- read_lock_irqsave(&device->cache.lock, flags);
-
- if (device->cache.pkey_cache) {
- cache = device->cache.pkey_cache[port_num - start_port(device)];
-
- if (cache && index >= 0 && index < cache->table_len) {
- *pkey = cache->table[index];
- ret = 0;
- }
- }
-
- read_unlock_irqrestore(&device->cache.lock, flags);
-
- return ret;
-}
-EXPORT_SYMBOL(ib_get_cached_pkey);
-
-int ib_find_cached_pkey(struct ib_device *device,
- u8 port_num,
- u16 pkey,
- u16 *index)
-{
- struct ib_pkey_cache *cache;
- unsigned long flags;
- int i;
- int ret = -ENOENT;
- int partial_ix = -1;
-
- if (port_num < start_port(device) || port_num > end_port(device))
- return -EINVAL;
-
- *index = -1;
-
- read_lock_irqsave(&device->cache.lock, flags);
-
- if (!device->cache.pkey_cache)
- goto out;
-
- cache = device->cache.pkey_cache[port_num - start_port(device)];
- if (!cache)
- goto out;
-
- for (i = 0; i < cache->table_len; ++i)
- if ((cache->table[i] & 0x7fff) == (pkey & 0x7fff)) {
- if (cache->table[i] & 0x8000) {
- *index = i;
- ret = 0;
- break;
- } else
- partial_ix = i;
- }
-
- if (ret && partial_ix >= 0) {
- *index = partial_ix;
- ret = 0;
- }
-out:
- read_unlock_irqrestore(&device->cache.lock, flags);
- return ret;
-}
-EXPORT_SYMBOL(ib_find_cached_pkey);
-
-int ib_find_exact_cached_pkey(struct ib_device *device,
- u8 port_num,
- u16 pkey,
- u16 *index)
-{
- struct ib_pkey_cache *cache;
- unsigned long flags;
- int i;
- int ret = -ENOENT;
-
- if (port_num < start_port(device) || port_num > end_port(device))
- return -EINVAL;
-
- *index = -1;
-
- read_lock_irqsave(&device->cache.lock, flags);
-
- if (!device->cache.pkey_cache)
- goto out;
-
- cache = device->cache.pkey_cache[port_num - start_port(device)];
- if (!cache)
- goto out;
-
- for (i = 0; i < cache->table_len; ++i)
- if (cache->table[i] == pkey) {
- *index = i;
- ret = 0;
- break;
- }
-out:
- read_unlock_irqrestore(&device->cache.lock, flags);
- return ret;
-}
-EXPORT_SYMBOL(ib_find_exact_cached_pkey);
-
-int ib_get_cached_lmc(struct ib_device *device,
- u8 port_num,
- u8 *lmc)
-{
- unsigned long flags;
- int ret = -EINVAL;
-
- if (port_num < start_port(device) || port_num > end_port(device))
- return -EINVAL;
-
- read_lock_irqsave(&device->cache.lock, flags);
- if (device->cache.lmc_cache) {
- *lmc = device->cache.lmc_cache[port_num - start_port(device)];
- ret = 0;
- }
- read_unlock_irqrestore(&device->cache.lock, flags);
-
- return ret;
-}
-EXPORT_SYMBOL(ib_get_cached_lmc);
-
-static void ib_cache_update(struct ib_device *device,
- u8 port)
-{
- struct ib_port_attr *tprops = NULL;
- struct ib_pkey_cache *pkey_cache = NULL, *old_pkey_cache;
- struct ib_gid_cache *gid_cache = NULL, *old_gid_cache;
- int i;
- int ret;
-
- if (!(device->cache.pkey_cache && device->cache.gid_cache &&
- device->cache.lmc_cache))
- return;
-
- tprops = kmalloc(sizeof *tprops, GFP_KERNEL);
- if (!tprops)
- return;
-
- ret = ib_query_port(device, port, tprops);
- if (ret) {
- printk(KERN_WARNING "ib_query_port failed (%d) for %s\n",
- ret, device->name);
- goto err;
- }
-
- pkey_cache = kmalloc(sizeof *pkey_cache + tprops->pkey_tbl_len *
- sizeof *pkey_cache->table, GFP_KERNEL);
- if (!pkey_cache)
- goto err;
-
- pkey_cache->table_len = tprops->pkey_tbl_len;
-
- gid_cache = kmalloc(sizeof *gid_cache + tprops->gid_tbl_len *
- sizeof *gid_cache->table, GFP_KERNEL);
- if (!gid_cache)
- goto err;
-
- gid_cache->table_len = tprops->gid_tbl_len;
-
- for (i = 0; i < pkey_cache->table_len; ++i) {
- ret = ib_query_pkey(device, port, i, pkey_cache->table + i);
- if (ret) {
- printk(KERN_WARNING "ib_query_pkey failed (%d) for %s (index %d)\n",
- ret, device->name, i);
- goto err;
- }
- }
-
- for (i = 0; i < gid_cache->table_len; ++i) {
- ret = ib_query_gid(device, port, i, gid_cache->table + i);
- if (ret) {
- printk(KERN_WARNING "ib_query_gid failed (%d) for %s (index %d)\n",
- ret, device->name, i);
- goto err;
- }
- }
-
- write_lock_irq(&device->cache.lock);
-
- old_pkey_cache = device->cache.pkey_cache[port - start_port(device)];
- old_gid_cache = device->cache.gid_cache [port - start_port(device)];
-
- device->cache.pkey_cache[port - start_port(device)] = pkey_cache;
- device->cache.gid_cache [port - start_port(device)] = gid_cache;
-
- device->cache.lmc_cache[port - start_port(device)] = tprops->lmc;
-
- write_unlock_irq(&device->cache.lock);
-
- kfree(old_pkey_cache);
- kfree(old_gid_cache);
- kfree(tprops);
- return;
-
-err:
- kfree(pkey_cache);
- kfree(gid_cache);
- kfree(tprops);
-}
-
-static void ib_cache_task(struct work_struct *_work)
-{
- struct ib_update_work *work =
- container_of(_work, struct ib_update_work, work);
-
- ib_cache_update(work->device, work->port_num);
- kfree(work);
-}
-
-static void ib_cache_event(struct ib_event_handler *handler,
- struct ib_event *event)
-{
- struct ib_update_work *work;
-
- if (event->event == IB_EVENT_PORT_ERR ||
- event->event == IB_EVENT_PORT_ACTIVE ||
- event->event == IB_EVENT_LID_CHANGE ||
- event->event == IB_EVENT_PKEY_CHANGE ||
- event->event == IB_EVENT_SM_CHANGE ||
- event->event == IB_EVENT_CLIENT_REREGISTER ||
- event->event == IB_EVENT_GID_CHANGE) {
- work = kmalloc(sizeof *work, GFP_ATOMIC);
- if (work) {
- INIT_WORK(&work->work, ib_cache_task);
- work->device = event->device;
- work->port_num = event->element.port_num;
- queue_work(ib_wq, &work->work);
- }
- }
-}
-
-static void ib_cache_setup_one(struct ib_device *device)
-{
- int p;
-
- rwlock_init(&device->cache.lock);
-
- device->cache.pkey_cache =
- kmalloc(sizeof *device->cache.pkey_cache *
- (end_port(device) - start_port(device) + 1), GFP_KERNEL);
- device->cache.gid_cache =
- kmalloc(sizeof *device->cache.gid_cache *
- (end_port(device) - start_port(device) + 1), GFP_KERNEL);
-
- device->cache.lmc_cache = kmalloc(sizeof *device->cache.lmc_cache *
- (end_port(device) -
- start_port(device) + 1),
- GFP_KERNEL);
-
- if (!device->cache.pkey_cache || !device->cache.gid_cache ||
- !device->cache.lmc_cache) {
- printk(KERN_WARNING "Couldn't allocate cache "
- "for %s\n", device->name);
- goto err;
- }
-
- for (p = 0; p <= end_port(device) - start_port(device); ++p) {
- device->cache.pkey_cache[p] = NULL;
- device->cache.gid_cache [p] = NULL;
- ib_cache_update(device, p + start_port(device));
- }
-
- INIT_IB_EVENT_HANDLER(&device->cache.event_handler,
- device, ib_cache_event);
- if (ib_register_event_handler(&device->cache.event_handler))
- goto err_cache;
-
- return;
-
-err_cache:
- for (p = 0; p <= end_port(device) - start_port(device); ++p) {
- kfree(device->cache.pkey_cache[p]);
- kfree(device->cache.gid_cache[p]);
- }
-
-err:
- kfree(device->cache.pkey_cache);
- kfree(device->cache.gid_cache);
- kfree(device->cache.lmc_cache);
- device->cache.pkey_cache = NULL;
- device->cache.gid_cache = NULL;
- device->cache.lmc_cache = NULL;
-}
-
-static void ib_cache_cleanup_one(struct ib_device *device)
-{
- int p;
-
- if (!(device->cache.pkey_cache && device->cache.gid_cache &&
- device->cache.lmc_cache))
- return;
-
- ib_unregister_event_handler(&device->cache.event_handler);
- flush_workqueue(ib_wq);
-
- for (p = 0; p <= end_port(device) - start_port(device); ++p) {
- kfree(device->cache.pkey_cache[p]);
- kfree(device->cache.gid_cache[p]);
- }
-
- kfree(device->cache.pkey_cache);
- kfree(device->cache.gid_cache);
- kfree(device->cache.lmc_cache);
-}
-
-static struct ib_client cache_client = {
- .name = "cache",
- .add = ib_cache_setup_one,
- .remove = ib_cache_cleanup_one
-};
-
-int __init ib_cache_setup(void)
-{
- return ib_register_client(&cache_client);
-}
-
-void __exit ib_cache_cleanup(void)
-{
- ib_unregister_client(&cache_client);
-}
diff --git a/sys/ofed/drivers/infiniband/core/cm.c b/sys/ofed/drivers/infiniband/core/cm.c
deleted file mode 100644
index 5d3f5f6..0000000
--- a/sys/ofed/drivers/infiniband/core/cm.c
+++ /dev/null
@@ -1,3986 +0,0 @@
-/*
- * Copyright (c) 2004-2007 Intel Corporation. All rights reserved.
- * Copyright (c) 2004 Topspin Corporation. All rights reserved.
- * Copyright (c) 2004, 2005 Voltaire Corporation. All rights reserved.
- * Copyright (c) 2005 Sun Microsystems, Inc. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-#include <linux/completion.h>
-#include <linux/dma-mapping.h>
-#include <linux/device.h>
-#include <linux/module.h>
-#include <linux/err.h>
-#include <linux/idr.h>
-#include <linux/interrupt.h>
-#include <linux/random.h>
-#include <linux/rbtree.h>
-#include <linux/spinlock.h>
-#include <linux/slab.h>
-#include <linux/sysfs.h>
-#include <linux/workqueue.h>
-#include <linux/kdev_t.h>
-#include <linux/string.h>
-#include <linux/etherdevice.h>
-
-#include <asm/atomic-long.h>
-
-#include <rdma/ib_cache.h>
-#include <rdma/ib_cm.h>
-#include "cm_msgs.h"
-
-MODULE_AUTHOR("Sean Hefty");
-MODULE_DESCRIPTION("InfiniBand CM");
-MODULE_LICENSE("Dual BSD/GPL");
-
-#ifdef pr_fmt
-#undef pr_fmt
-#endif
-#define pr_fmt(fmt) "%s:%s: " fmt, KBUILD_MODNAME, __func__
-
-static void cm_add_one(struct ib_device *device);
-static void cm_remove_one(struct ib_device *device);
-
-static struct ib_client cm_client = {
- .name = "cm",
- .add = cm_add_one,
- .remove = cm_remove_one
-};
-
-static struct ib_cm {
- spinlock_t lock;
- struct list_head device_list;
- rwlock_t device_lock;
- struct rb_root listen_service_table;
- u64 listen_service_id;
- /* struct rb_root peer_service_table; todo: fix peer to peer */
- struct rb_root remote_qp_table;
- struct rb_root remote_id_table;
- struct rb_root remote_sidr_table;
- struct idr local_id_table;
- __be32 random_id_operand;
- struct list_head timewait_list;
- struct workqueue_struct *wq;
-} cm;
-
-/* Counter indexes ordered by attribute ID */
-enum {
- CM_REQ_COUNTER,
- CM_MRA_COUNTER,
- CM_REJ_COUNTER,
- CM_REP_COUNTER,
- CM_RTU_COUNTER,
- CM_DREQ_COUNTER,
- CM_DREP_COUNTER,
- CM_SIDR_REQ_COUNTER,
- CM_SIDR_REP_COUNTER,
- CM_LAP_COUNTER,
- CM_APR_COUNTER,
- CM_ATTR_COUNT,
- CM_ATTR_ID_OFFSET = 0x0010,
-};
-
-enum {
- CM_XMIT,
- CM_XMIT_RETRIES,
- CM_RECV,
- CM_RECV_DUPLICATES,
- CM_COUNTER_GROUPS
-};
-
-static char const counter_group_names[CM_COUNTER_GROUPS]
- [sizeof("cm_rx_duplicates")] = {
- "cm_tx_msgs", "cm_tx_retries",
- "cm_rx_msgs", "cm_rx_duplicates"
-};
-
-struct cm_counter_group {
- struct kobject obj;
- atomic_long_t counter[CM_ATTR_COUNT];
-};
-
-struct cm_counter_attribute {
- struct attribute attr;
- int index;
-};
-
-#define CM_COUNTER_ATTR(_name, _index) \
-struct cm_counter_attribute cm_##_name##_counter_attr = { \
- .attr = { .name = __stringify(_name), .mode = 0444 }, \
- .index = _index \
-}
-
-static CM_COUNTER_ATTR(req, CM_REQ_COUNTER);
-static CM_COUNTER_ATTR(mra, CM_MRA_COUNTER);
-static CM_COUNTER_ATTR(rej, CM_REJ_COUNTER);
-static CM_COUNTER_ATTR(rep, CM_REP_COUNTER);
-static CM_COUNTER_ATTR(rtu, CM_RTU_COUNTER);
-static CM_COUNTER_ATTR(dreq, CM_DREQ_COUNTER);
-static CM_COUNTER_ATTR(drep, CM_DREP_COUNTER);
-static CM_COUNTER_ATTR(sidr_req, CM_SIDR_REQ_COUNTER);
-static CM_COUNTER_ATTR(sidr_rep, CM_SIDR_REP_COUNTER);
-static CM_COUNTER_ATTR(lap, CM_LAP_COUNTER);
-static CM_COUNTER_ATTR(apr, CM_APR_COUNTER);
-
-static struct attribute *cm_counter_default_attrs[] = {
- &cm_req_counter_attr.attr,
- &cm_mra_counter_attr.attr,
- &cm_rej_counter_attr.attr,
- &cm_rep_counter_attr.attr,
- &cm_rtu_counter_attr.attr,
- &cm_dreq_counter_attr.attr,
- &cm_drep_counter_attr.attr,
- &cm_sidr_req_counter_attr.attr,
- &cm_sidr_rep_counter_attr.attr,
- &cm_lap_counter_attr.attr,
- &cm_apr_counter_attr.attr,
- NULL
-};
-
-struct cm_port {
- struct cm_device *cm_dev;
- struct ib_mad_agent *mad_agent;
- struct kobject port_obj;
- u8 port_num;
- struct cm_counter_group counter_group[CM_COUNTER_GROUPS];
-};
-
-struct cm_device {
- struct list_head list;
- struct ib_device *ib_device;
- struct device *device;
- u8 ack_delay;
- struct cm_port *port[0];
-};
-
-struct cm_av {
- struct cm_port *port;
- union ib_gid dgid;
- struct ib_ah_attr ah_attr;
- u16 pkey_index;
- u8 timeout;
- u8 valid;
- u8 smac[ETH_ALEN];
-};
-
-struct cm_work {
- struct delayed_work work;
- struct list_head list;
- struct cm_port *port;
- struct ib_mad_recv_wc *mad_recv_wc; /* Received MADs */
- __be32 local_id; /* Established / timewait */
- __be32 remote_id;
- struct ib_cm_event cm_event;
- struct ib_sa_path_rec path[0];
-};
-
-struct cm_timewait_info {
- struct cm_work work; /* Must be first. */
- struct list_head list;
- struct rb_node remote_qp_node;
- struct rb_node remote_id_node;
- __be64 remote_ca_guid;
- __be32 remote_qpn;
- u8 inserted_remote_qp;
- u8 inserted_remote_id;
-};
-
-struct cm_id_private {
- struct ib_cm_id id;
-
- struct rb_node service_node;
- struct rb_node sidr_id_node;
- spinlock_t lock; /* Do not acquire inside cm.lock */
- struct completion comp;
- atomic_t refcount;
-
- struct ib_mad_send_buf *msg;
- struct cm_timewait_info *timewait_info;
- /* todo: use alternate port on send failure */
- struct cm_av av;
- struct cm_av alt_av;
- struct ib_cm_compare_data *compare_data;
-
- void *private_data;
- __be64 tid;
- __be32 local_qpn;
- __be32 remote_qpn;
- enum ib_qp_type qp_type;
- __be32 sq_psn;
- __be32 rq_psn;
- int timeout_ms;
- enum ib_mtu path_mtu;
- __be16 pkey;
- u8 private_data_len;
- u8 max_cm_retries;
- u8 peer_to_peer;
- u8 responder_resources;
- u8 initiator_depth;
- u8 retry_count;
- u8 rnr_retry_count;
- u8 service_timeout;
- u8 target_ack_delay;
-
- struct list_head work_list;
- atomic_t work_count;
-};
-
-static void cm_work_handler(struct work_struct *work);
-
-static inline void cm_deref_id(struct cm_id_private *cm_id_priv)
-{
- if (atomic_dec_and_test(&cm_id_priv->refcount))
- complete(&cm_id_priv->comp);
-}
-
-static int cm_alloc_msg(struct cm_id_private *cm_id_priv,
- struct ib_mad_send_buf **msg)
-{
- struct ib_mad_agent *mad_agent;
- struct ib_mad_send_buf *m;
- struct ib_ah *ah;
-
- mad_agent = cm_id_priv->av.port->mad_agent;
- ah = ib_create_ah(mad_agent->qp->pd, &cm_id_priv->av.ah_attr);
- if (IS_ERR(ah))
- return PTR_ERR(ah);
-
- m = ib_create_send_mad(mad_agent, cm_id_priv->id.remote_cm_qpn,
- cm_id_priv->av.pkey_index,
- 0, IB_MGMT_MAD_HDR, IB_MGMT_MAD_DATA,
- GFP_ATOMIC);
- if (IS_ERR(m)) {
- ib_destroy_ah(ah);
- return PTR_ERR(m);
- }
-
- /* Timeout set by caller if response is expected. */
- m->ah = ah;
- m->retries = cm_id_priv->max_cm_retries;
-
- atomic_inc(&cm_id_priv->refcount);
- m->context[0] = cm_id_priv;
- *msg = m;
- return 0;
-}
-
-static int cm_alloc_response_msg(struct cm_port *port,
- struct ib_mad_recv_wc *mad_recv_wc,
- struct ib_mad_send_buf **msg)
-{
- struct ib_mad_send_buf *m;
- struct ib_ah *ah;
-
- ah = ib_create_ah_from_wc(port->mad_agent->qp->pd, mad_recv_wc->wc,
- mad_recv_wc->recv_buf.grh, port->port_num);
- if (IS_ERR(ah))
- return PTR_ERR(ah);
-
- m = ib_create_send_mad(port->mad_agent, 1, mad_recv_wc->wc->pkey_index,
- 0, IB_MGMT_MAD_HDR, IB_MGMT_MAD_DATA,
- GFP_ATOMIC);
- if (IS_ERR(m)) {
- ib_destroy_ah(ah);
- return PTR_ERR(m);
- }
- m->ah = ah;
- *msg = m;
- return 0;
-}
-
-static void cm_free_msg(struct ib_mad_send_buf *msg)
-{
- ib_destroy_ah(msg->ah);
- if (msg->context[0])
- cm_deref_id(msg->context[0]);
- ib_free_send_mad(msg);
-}
-
-static void * cm_copy_private_data(const void *private_data,
- u8 private_data_len)
-{
- void *data;
-
- if (!private_data || !private_data_len)
- return NULL;
-
- data = kmemdup(private_data, private_data_len, GFP_KERNEL);
- if (!data)
- return ERR_PTR(-ENOMEM);
-
- return data;
-}
-
-static void cm_set_private_data(struct cm_id_private *cm_id_priv,
- void *private_data, u8 private_data_len)
-{
- if (cm_id_priv->private_data && cm_id_priv->private_data_len)
- kfree(cm_id_priv->private_data);
-
- cm_id_priv->private_data = private_data;
- cm_id_priv->private_data_len = private_data_len;
-}
-
-static void cm_init_av_for_response(struct cm_port *port, struct ib_wc *wc,
- struct ib_grh *grh, struct cm_av *av)
-{
- av->port = port;
- av->pkey_index = wc->pkey_index;
- ib_init_ah_from_wc(port->cm_dev->ib_device, port->port_num, wc,
- grh, &av->ah_attr);
-}
-
-int ib_update_cm_av(struct ib_cm_id *id, const u8 *smac, const u8 *alt_smac)
-{
- struct cm_id_private *cm_id_priv;
-
- cm_id_priv = container_of(id, struct cm_id_private, id);
-
- if (smac != NULL)
- memcpy(cm_id_priv->av.smac, smac, sizeof(cm_id_priv->av.smac));
-
- if (alt_smac != NULL)
- memcpy(cm_id_priv->alt_av.smac, alt_smac,
- sizeof(cm_id_priv->alt_av.smac));
-
- return 0;
-}
-EXPORT_SYMBOL(ib_update_cm_av);
-
-static int cm_init_av_by_path(struct ib_sa_path_rec *path, struct cm_av *av)
-{
- struct cm_device *cm_dev;
- struct cm_port *port = NULL;
- unsigned long flags;
- int ret;
- u8 p;
-
- read_lock_irqsave(&cm.device_lock, flags);
- list_for_each_entry(cm_dev, &cm.device_list, list) {
- if (!ib_find_cached_gid(cm_dev->ib_device, &path->sgid,
- &p, NULL)) {
- port = cm_dev->port[p-1];
- break;
- }
- }
- read_unlock_irqrestore(&cm.device_lock, flags);
-
- if (!port)
- return -EINVAL;
-
- ret = ib_find_cached_pkey(cm_dev->ib_device, port->port_num,
- be16_to_cpu(path->pkey), &av->pkey_index);
- if (ret)
- return ret;
-
- av->port = port;
- ib_init_ah_from_path(cm_dev->ib_device, port->port_num, path,
- &av->ah_attr);
- av->timeout = path->packet_life_time + 1;
- memcpy(av->smac, path->smac, sizeof(av->smac));
-
- av->valid = 1;
- return 0;
-}
-
-static int cm_alloc_id(struct cm_id_private *cm_id_priv)
-{
- unsigned long flags;
- int ret, id;
- static int next_id;
-
- do {
- spin_lock_irqsave(&cm.lock, flags);
- ret = idr_get_new_above(&cm.local_id_table, cm_id_priv,
- next_id, &id);
- if (!ret)
- next_id = ((unsigned) id + 1) & MAX_IDR_MASK;
- spin_unlock_irqrestore(&cm.lock, flags);
- } while( (ret == -EAGAIN) && idr_pre_get(&cm.local_id_table, GFP_KERNEL) );
-
- cm_id_priv->id.local_id = (__force __be32)id ^ cm.random_id_operand;
- return ret;
-}
-
-static void cm_free_id(__be32 local_id)
-{
- spin_lock_irq(&cm.lock);
- idr_remove(&cm.local_id_table,
- (__force int) (local_id ^ cm.random_id_operand));
- spin_unlock_irq(&cm.lock);
-}
-
-static struct cm_id_private * cm_get_id(__be32 local_id, __be32 remote_id)
-{
- struct cm_id_private *cm_id_priv;
-
- cm_id_priv = idr_find(&cm.local_id_table,
- (__force int) (local_id ^ cm.random_id_operand));
- if (cm_id_priv) {
- if (cm_id_priv->id.remote_id == remote_id)
- atomic_inc(&cm_id_priv->refcount);
- else
- cm_id_priv = NULL;
- }
-
- return cm_id_priv;
-}
-
-static struct cm_id_private * cm_acquire_id(__be32 local_id, __be32 remote_id)
-{
- struct cm_id_private *cm_id_priv;
-
- spin_lock_irq(&cm.lock);
- cm_id_priv = cm_get_id(local_id, remote_id);
- spin_unlock_irq(&cm.lock);
-
- return cm_id_priv;
-}
-
-static void cm_mask_copy(u8 *dst, u8 *src, u8 *mask)
-{
- int i;
-
- for (i = 0; i < IB_CM_COMPARE_SIZE / sizeof(unsigned long); i++)
- ((unsigned long *) dst)[i] = ((unsigned long *) src)[i] &
- ((unsigned long *) mask)[i];
-}
-
-static int cm_compare_data(struct ib_cm_compare_data *src_data,
- struct ib_cm_compare_data *dst_data)
-{
- u8 src[IB_CM_COMPARE_SIZE];
- u8 dst[IB_CM_COMPARE_SIZE];
-
- if (!src_data || !dst_data)
- return 0;
-
- cm_mask_copy(src, src_data->data, dst_data->mask);
- cm_mask_copy(dst, dst_data->data, src_data->mask);
- return memcmp(src, dst, IB_CM_COMPARE_SIZE);
-}
-
-static int cm_compare_private_data(u8 *private_data,
- struct ib_cm_compare_data *dst_data)
-{
- u8 src[IB_CM_COMPARE_SIZE];
-
- if (!dst_data)
- return 0;
-
- cm_mask_copy(src, private_data, dst_data->mask);
- return memcmp(src, dst_data->data, IB_CM_COMPARE_SIZE);
-}
-
-/*
- * Trivial helpers to strip endian annotation and compare; the
- * endianness doesn't actually matter since we just need a stable
- * order for the RB tree.
- */
-static int be32_lt(__be32 a, __be32 b)
-{
- return (__force u32) a < (__force u32) b;
-}
-
-static int be32_gt(__be32 a, __be32 b)
-{
- return (__force u32) a > (__force u32) b;
-}
-
-static int be64_lt(__be64 a, __be64 b)
-{
- return (__force u64) a < (__force u64) b;
-}
-
-static int be64_gt(__be64 a, __be64 b)
-{
- return (__force u64) a > (__force u64) b;
-}
-
-static struct cm_id_private * cm_insert_listen(struct cm_id_private *cm_id_priv)
-{
- struct rb_node **link = &cm.listen_service_table.rb_node;
- struct rb_node *parent = NULL;
- struct cm_id_private *cur_cm_id_priv;
- __be64 service_id = cm_id_priv->id.service_id;
- __be64 service_mask = cm_id_priv->id.service_mask;
- int data_cmp;
-
- while (*link) {
- parent = *link;
- cur_cm_id_priv = rb_entry(parent, struct cm_id_private,
- service_node);
- data_cmp = cm_compare_data(cm_id_priv->compare_data,
- cur_cm_id_priv->compare_data);
- if ((cur_cm_id_priv->id.service_mask & service_id) ==
- (service_mask & cur_cm_id_priv->id.service_id) &&
- (cm_id_priv->id.device == cur_cm_id_priv->id.device) &&
- !data_cmp)
- return cur_cm_id_priv;
-
- if (cm_id_priv->id.device < cur_cm_id_priv->id.device)
- link = &(*link)->rb_left;
- else if (cm_id_priv->id.device > cur_cm_id_priv->id.device)
- link = &(*link)->rb_right;
- else if (be64_lt(service_id, cur_cm_id_priv->id.service_id))
- link = &(*link)->rb_left;
- else if (be64_gt(service_id, cur_cm_id_priv->id.service_id))
- link = &(*link)->rb_right;
- else if (data_cmp < 0)
- link = &(*link)->rb_left;
- else
- link = &(*link)->rb_right;
- }
- rb_link_node(&cm_id_priv->service_node, parent, link);
- rb_insert_color(&cm_id_priv->service_node, &cm.listen_service_table);
- return NULL;
-}
-
-static struct cm_id_private * cm_find_listen(struct ib_device *device,
- __be64 service_id,
- u8 *private_data)
-{
- struct rb_node *node = cm.listen_service_table.rb_node;
- struct cm_id_private *cm_id_priv;
- int data_cmp;
-
- while (node) {
- cm_id_priv = rb_entry(node, struct cm_id_private, service_node);
- data_cmp = cm_compare_private_data(private_data,
- cm_id_priv->compare_data);
- if ((cm_id_priv->id.service_mask & service_id) ==
- cm_id_priv->id.service_id &&
- (cm_id_priv->id.device == device) && !data_cmp)
- return cm_id_priv;
-
- if (device < cm_id_priv->id.device)
- node = node->rb_left;
- else if (device > cm_id_priv->id.device)
- node = node->rb_right;
- else if (be64_lt(service_id, cm_id_priv->id.service_id))
- node = node->rb_left;
- else if (be64_gt(service_id, cm_id_priv->id.service_id))
- node = node->rb_right;
- else if (data_cmp < 0)
- node = node->rb_left;
- else
- node = node->rb_right;
- }
- return NULL;
-}
-
-static struct cm_timewait_info * cm_insert_remote_id(struct cm_timewait_info
- *timewait_info)
-{
- struct rb_node **link = &cm.remote_id_table.rb_node;
- struct rb_node *parent = NULL;
- struct cm_timewait_info *cur_timewait_info;
- __be64 remote_ca_guid = timewait_info->remote_ca_guid;
- __be32 remote_id = timewait_info->work.remote_id;
-
- while (*link) {
- parent = *link;
- cur_timewait_info = rb_entry(parent, struct cm_timewait_info,
- remote_id_node);
- if (be32_lt(remote_id, cur_timewait_info->work.remote_id))
- link = &(*link)->rb_left;
- else if (be32_gt(remote_id, cur_timewait_info->work.remote_id))
- link = &(*link)->rb_right;
- else if (be64_lt(remote_ca_guid, cur_timewait_info->remote_ca_guid))
- link = &(*link)->rb_left;
- else if (be64_gt(remote_ca_guid, cur_timewait_info->remote_ca_guid))
- link = &(*link)->rb_right;
- else
- return cur_timewait_info;
- }
- timewait_info->inserted_remote_id = 1;
- rb_link_node(&timewait_info->remote_id_node, parent, link);
- rb_insert_color(&timewait_info->remote_id_node, &cm.remote_id_table);
- return NULL;
-}
-
-static struct cm_timewait_info * cm_find_remote_id(__be64 remote_ca_guid,
- __be32 remote_id)
-{
- struct rb_node *node = cm.remote_id_table.rb_node;
- struct cm_timewait_info *timewait_info;
-
- while (node) {
- timewait_info = rb_entry(node, struct cm_timewait_info,
- remote_id_node);
- if (be32_lt(remote_id, timewait_info->work.remote_id))
- node = node->rb_left;
- else if (be32_gt(remote_id, timewait_info->work.remote_id))
- node = node->rb_right;
- else if (be64_lt(remote_ca_guid, timewait_info->remote_ca_guid))
- node = node->rb_left;
- else if (be64_gt(remote_ca_guid, timewait_info->remote_ca_guid))
- node = node->rb_right;
- else
- return timewait_info;
- }
- return NULL;
-}
-
-static struct cm_timewait_info * cm_insert_remote_qpn(struct cm_timewait_info
- *timewait_info)
-{
- struct rb_node **link = &cm.remote_qp_table.rb_node;
- struct rb_node *parent = NULL;
- struct cm_timewait_info *cur_timewait_info;
- __be64 remote_ca_guid = timewait_info->remote_ca_guid;
- __be32 remote_qpn = timewait_info->remote_qpn;
-
- while (*link) {
- parent = *link;
- cur_timewait_info = rb_entry(parent, struct cm_timewait_info,
- remote_qp_node);
- if (be32_lt(remote_qpn, cur_timewait_info->remote_qpn))
- link = &(*link)->rb_left;
- else if (be32_gt(remote_qpn, cur_timewait_info->remote_qpn))
- link = &(*link)->rb_right;
- else if (be64_lt(remote_ca_guid, cur_timewait_info->remote_ca_guid))
- link = &(*link)->rb_left;
- else if (be64_gt(remote_ca_guid, cur_timewait_info->remote_ca_guid))
- link = &(*link)->rb_right;
- else
- return cur_timewait_info;
- }
- timewait_info->inserted_remote_qp = 1;
- rb_link_node(&timewait_info->remote_qp_node, parent, link);
- rb_insert_color(&timewait_info->remote_qp_node, &cm.remote_qp_table);
- return NULL;
-}
-
-static struct cm_id_private * cm_insert_remote_sidr(struct cm_id_private
- *cm_id_priv)
-{
- struct rb_node **link = &cm.remote_sidr_table.rb_node;
- struct rb_node *parent = NULL;
- struct cm_id_private *cur_cm_id_priv;
- union ib_gid *port_gid = &cm_id_priv->av.dgid;
- __be32 remote_id = cm_id_priv->id.remote_id;
-
- while (*link) {
- parent = *link;
- cur_cm_id_priv = rb_entry(parent, struct cm_id_private,
- sidr_id_node);
- if (be32_lt(remote_id, cur_cm_id_priv->id.remote_id))
- link = &(*link)->rb_left;
- else if (be32_gt(remote_id, cur_cm_id_priv->id.remote_id))
- link = &(*link)->rb_right;
- else {
- int cmp;
- cmp = memcmp(port_gid, &cur_cm_id_priv->av.dgid,
- sizeof *port_gid);
- if (cmp < 0)
- link = &(*link)->rb_left;
- else if (cmp > 0)
- link = &(*link)->rb_right;
- else
- return cur_cm_id_priv;
- }
- }
- rb_link_node(&cm_id_priv->sidr_id_node, parent, link);
- rb_insert_color(&cm_id_priv->sidr_id_node, &cm.remote_sidr_table);
- return NULL;
-}
-
-static void cm_reject_sidr_req(struct cm_id_private *cm_id_priv,
- enum ib_cm_sidr_status status)
-{
- struct ib_cm_sidr_rep_param param;
-
- memset(&param, 0, sizeof param);
- param.status = status;
- ib_send_cm_sidr_rep(&cm_id_priv->id, &param);
-}
-
-struct ib_cm_id *ib_create_cm_id(struct ib_device *device,
- ib_cm_handler cm_handler,
- void *context)
-{
- struct cm_id_private *cm_id_priv;
- int ret;
-
- cm_id_priv = kzalloc(sizeof *cm_id_priv, GFP_KERNEL);
- if (!cm_id_priv)
- return ERR_PTR(-ENOMEM);
-
- cm_id_priv->id.state = IB_CM_IDLE;
- cm_id_priv->id.device = device;
- cm_id_priv->id.cm_handler = cm_handler;
- cm_id_priv->id.context = context;
- cm_id_priv->id.remote_cm_qpn = 1;
- ret = cm_alloc_id(cm_id_priv);
- if (ret)
- goto error;
-
- spin_lock_init(&cm_id_priv->lock);
- init_completion(&cm_id_priv->comp);
- INIT_LIST_HEAD(&cm_id_priv->work_list);
- atomic_set(&cm_id_priv->work_count, -1);
- atomic_set(&cm_id_priv->refcount, 1);
- return &cm_id_priv->id;
-
-error:
- kfree(cm_id_priv);
- return ERR_PTR(-ENOMEM);
-}
-EXPORT_SYMBOL(ib_create_cm_id);
-
-static struct cm_work * cm_dequeue_work(struct cm_id_private *cm_id_priv)
-{
- struct cm_work *work;
-
- if (list_empty(&cm_id_priv->work_list))
- return NULL;
-
- work = list_entry(cm_id_priv->work_list.next, struct cm_work, list);
- list_del(&work->list);
- return work;
-}
-
-static void cm_free_work(struct cm_work *work)
-{
- if (work->mad_recv_wc)
- ib_free_recv_mad(work->mad_recv_wc);
- kfree(work);
-}
-
-static inline int cm_convert_to_ms(int iba_time)
-{
- /* approximate conversion to ms from 4.096us x 2^iba_time */
- return 1 << max(iba_time - 8, 0);
-}
-
-/*
- * calculate: 4.096x2^ack_timeout = 4.096x2^ack_delay + 2x4.096x2^life_time
- * Because of how ack_timeout is stored, adding one doubles the timeout.
- * To avoid large timeouts, select the max(ack_delay, life_time + 1), and
- * increment it (round up) only if the other is within 50%.
- */
-static u8 cm_ack_timeout(u8 ca_ack_delay, u8 packet_life_time)
-{
- int ack_timeout = packet_life_time + 1;
-
- if (ack_timeout >= ca_ack_delay)
- ack_timeout += (ca_ack_delay >= (ack_timeout - 1));
- else
- ack_timeout = ca_ack_delay +
- (ack_timeout >= (ca_ack_delay - 1));
-
- return min(31, ack_timeout);
-}
-
-static void cm_cleanup_timewait(struct cm_timewait_info *timewait_info)
-{
- if (timewait_info->inserted_remote_id) {
- rb_erase(&timewait_info->remote_id_node, &cm.remote_id_table);
- timewait_info->inserted_remote_id = 0;
- }
-
- if (timewait_info->inserted_remote_qp) {
- rb_erase(&timewait_info->remote_qp_node, &cm.remote_qp_table);
- timewait_info->inserted_remote_qp = 0;
- }
-}
-
-static struct cm_timewait_info * cm_create_timewait_info(__be32 local_id, gfp_t flags)
-{
- struct cm_timewait_info *timewait_info;
-
- timewait_info = kzalloc(sizeof *timewait_info, flags);
- if (!timewait_info)
- return ERR_PTR(-ENOMEM);
-
- timewait_info->work.local_id = local_id;
- INIT_DELAYED_WORK(&timewait_info->work.work, cm_work_handler);
- timewait_info->work.cm_event.event = IB_CM_TIMEWAIT_EXIT;
- return timewait_info;
-}
-
-static void cm_enter_timewait(struct cm_id_private *cm_id_priv)
-{
- int wait_time;
- unsigned long flags;
-
- spin_lock_irqsave(&cm.lock, flags);
- cm_cleanup_timewait(cm_id_priv->timewait_info);
- list_add_tail(&cm_id_priv->timewait_info->list, &cm.timewait_list);
- spin_unlock_irqrestore(&cm.lock, flags);
-
- /*
- * The cm_id could be destroyed by the user before we exit timewait.
- * To protect against this, we search for the cm_id after exiting
- * timewait before notifying the user that we've exited timewait.
- */
- cm_id_priv->id.state = IB_CM_TIMEWAIT;
- wait_time = cm_convert_to_ms(cm_id_priv->av.timeout);
- queue_delayed_work(cm.wq, &cm_id_priv->timewait_info->work.work,
- msecs_to_jiffies(wait_time));
- cm_id_priv->timewait_info = NULL;
-}
-
-static void cm_reset_to_idle(struct cm_id_private *cm_id_priv)
-{
- unsigned long flags;
-
- cm_id_priv->id.state = IB_CM_IDLE;
- if (cm_id_priv->timewait_info) {
- spin_lock_irqsave(&cm.lock, flags);
- cm_cleanup_timewait(cm_id_priv->timewait_info);
- spin_unlock_irqrestore(&cm.lock, flags);
- kfree(cm_id_priv->timewait_info);
- cm_id_priv->timewait_info = NULL;
- }
-}
-
-static void cm_destroy_id(struct ib_cm_id *cm_id, int err)
-{
- struct cm_id_private *cm_id_priv;
- struct cm_work *work;
-
- cm_id_priv = container_of(cm_id, struct cm_id_private, id);
-retest:
- spin_lock_irq(&cm_id_priv->lock);
- switch (cm_id->state) {
- case IB_CM_LISTEN:
- cm_id->state = IB_CM_IDLE;
- spin_unlock_irq(&cm_id_priv->lock);
- spin_lock_irq(&cm.lock);
- rb_erase(&cm_id_priv->service_node, &cm.listen_service_table);
- spin_unlock_irq(&cm.lock);
- break;
- case IB_CM_SIDR_REQ_SENT:
- cm_id->state = IB_CM_IDLE;
- ib_cancel_mad(cm_id_priv->av.port->mad_agent, cm_id_priv->msg);
- spin_unlock_irq(&cm_id_priv->lock);
- break;
- case IB_CM_SIDR_REQ_RCVD:
- spin_unlock_irq(&cm_id_priv->lock);
- cm_reject_sidr_req(cm_id_priv, IB_SIDR_REJECT);
- break;
- case IB_CM_REQ_SENT:
- case IB_CM_MRA_REQ_RCVD:
- ib_cancel_mad(cm_id_priv->av.port->mad_agent, cm_id_priv->msg);
- spin_unlock_irq(&cm_id_priv->lock);
- ib_send_cm_rej(cm_id, IB_CM_REJ_TIMEOUT,
- &cm_id_priv->id.device->node_guid,
- sizeof cm_id_priv->id.device->node_guid,
- NULL, 0);
- break;
- case IB_CM_REQ_RCVD:
- if (err == -ENOMEM) {
- /* Do not reject to allow future retries. */
- cm_reset_to_idle(cm_id_priv);
- spin_unlock_irq(&cm_id_priv->lock);
- } else {
- spin_unlock_irq(&cm_id_priv->lock);
- ib_send_cm_rej(cm_id, IB_CM_REJ_CONSUMER_DEFINED,
- NULL, 0, NULL, 0);
- }
- break;
- case IB_CM_REP_SENT:
- case IB_CM_MRA_REP_RCVD:
- ib_cancel_mad(cm_id_priv->av.port->mad_agent, cm_id_priv->msg);
- /* Fall through */
- case IB_CM_MRA_REQ_SENT:
- case IB_CM_REP_RCVD:
- case IB_CM_MRA_REP_SENT:
- spin_unlock_irq(&cm_id_priv->lock);
- ib_send_cm_rej(cm_id, IB_CM_REJ_CONSUMER_DEFINED,
- NULL, 0, NULL, 0);
- break;
- case IB_CM_ESTABLISHED:
- spin_unlock_irq(&cm_id_priv->lock);
- if (cm_id_priv->qp_type == IB_QPT_XRC_TGT)
- break;
- ib_send_cm_dreq(cm_id, NULL, 0);
- goto retest;
- case IB_CM_DREQ_SENT:
- ib_cancel_mad(cm_id_priv->av.port->mad_agent, cm_id_priv->msg);
- cm_enter_timewait(cm_id_priv);
- spin_unlock_irq(&cm_id_priv->lock);
- break;
- case IB_CM_DREQ_RCVD:
- spin_unlock_irq(&cm_id_priv->lock);
- ib_send_cm_drep(cm_id, NULL, 0);
- break;
- default:
- spin_unlock_irq(&cm_id_priv->lock);
- break;
- }
-
- cm_free_id(cm_id->local_id);
- cm_deref_id(cm_id_priv);
- wait_for_completion(&cm_id_priv->comp);
- while ((work = cm_dequeue_work(cm_id_priv)) != NULL)
- cm_free_work(work);
- kfree(cm_id_priv->compare_data);
- kfree(cm_id_priv->private_data);
- kfree(cm_id_priv);
-}
-
-void ib_destroy_cm_id(struct ib_cm_id *cm_id)
-{
- cm_destroy_id(cm_id, 0);
-}
-EXPORT_SYMBOL(ib_destroy_cm_id);
-
-int ib_cm_listen(struct ib_cm_id *cm_id, __be64 service_id, __be64 service_mask,
- struct ib_cm_compare_data *compare_data)
-{
- struct cm_id_private *cm_id_priv, *cur_cm_id_priv;
- unsigned long flags;
- int ret = 0;
-
- service_mask = service_mask ? service_mask : ~cpu_to_be64(0);
- service_id &= service_mask;
- if ((service_id & IB_SERVICE_ID_AGN_MASK) == IB_CM_ASSIGN_SERVICE_ID &&
- (service_id != IB_CM_ASSIGN_SERVICE_ID))
- return -EINVAL;
-
- cm_id_priv = container_of(cm_id, struct cm_id_private, id);
- if (cm_id->state != IB_CM_IDLE)
- return -EINVAL;
-
- if (compare_data) {
- cm_id_priv->compare_data = kzalloc(sizeof *compare_data,
- GFP_KERNEL);
- if (!cm_id_priv->compare_data)
- return -ENOMEM;
- cm_mask_copy(cm_id_priv->compare_data->data,
- compare_data->data, compare_data->mask);
- memcpy(cm_id_priv->compare_data->mask, compare_data->mask,
- IB_CM_COMPARE_SIZE);
- }
-
- cm_id->state = IB_CM_LISTEN;
-
- spin_lock_irqsave(&cm.lock, flags);
- if (service_id == IB_CM_ASSIGN_SERVICE_ID) {
- cm_id->service_id = cpu_to_be64(cm.listen_service_id++);
- cm_id->service_mask = ~cpu_to_be64(0);
- } else {
- cm_id->service_id = service_id;
- cm_id->service_mask = service_mask;
- }
- cur_cm_id_priv = cm_insert_listen(cm_id_priv);
- spin_unlock_irqrestore(&cm.lock, flags);
-
- if (cur_cm_id_priv) {
- cm_id->state = IB_CM_IDLE;
- kfree(cm_id_priv->compare_data);
- cm_id_priv->compare_data = NULL;
- ret = -EBUSY;
- }
- return ret;
-}
-EXPORT_SYMBOL(ib_cm_listen);
-
-static __be64 cm_form_tid(struct cm_id_private *cm_id_priv,
- enum cm_msg_sequence msg_seq)
-{
- u64 hi_tid, low_tid;
-
- hi_tid = ((u64) cm_id_priv->av.port->mad_agent->hi_tid) << 32;
- low_tid = (u64) ((__force u32)cm_id_priv->id.local_id |
- (msg_seq << 30));
- return cpu_to_be64(hi_tid | low_tid);
-}
-
-static void cm_format_mad_hdr(struct ib_mad_hdr *hdr,
- __be16 attr_id, __be64 tid)
-{
- hdr->base_version = IB_MGMT_BASE_VERSION;
- hdr->mgmt_class = IB_MGMT_CLASS_CM;
- hdr->class_version = IB_CM_CLASS_VERSION;
- hdr->method = IB_MGMT_METHOD_SEND;
- hdr->attr_id = attr_id;
- hdr->tid = tid;
-}
-
-static void cm_format_req(struct cm_req_msg *req_msg,
- struct cm_id_private *cm_id_priv,
- struct ib_cm_req_param *param)
-{
- struct ib_sa_path_rec *pri_path = param->primary_path;
- struct ib_sa_path_rec *alt_path = param->alternate_path;
-
- cm_format_mad_hdr(&req_msg->hdr, CM_REQ_ATTR_ID,
- cm_form_tid(cm_id_priv, CM_MSG_SEQUENCE_REQ));
-
- req_msg->local_comm_id = cm_id_priv->id.local_id;
- req_msg->service_id = param->service_id;
- req_msg->local_ca_guid = cm_id_priv->id.device->node_guid;
- cm_req_set_local_qpn(req_msg, cpu_to_be32(param->qp_num));
- cm_req_set_init_depth(req_msg, param->initiator_depth);
- cm_req_set_remote_resp_timeout(req_msg,
- param->remote_cm_response_timeout);
- cm_req_set_qp_type(req_msg, param->qp_type);
- cm_req_set_flow_ctrl(req_msg, param->flow_control);
- cm_req_set_starting_psn(req_msg, cpu_to_be32(param->starting_psn));
- cm_req_set_local_resp_timeout(req_msg,
- param->local_cm_response_timeout);
- req_msg->pkey = param->primary_path->pkey;
- cm_req_set_path_mtu(req_msg, param->primary_path->mtu);
- cm_req_set_max_cm_retries(req_msg, param->max_cm_retries);
-
- if (param->qp_type != IB_QPT_XRC_INI) {
- cm_req_set_resp_res(req_msg, param->responder_resources);
- cm_req_set_retry_count(req_msg, param->retry_count);
- cm_req_set_rnr_retry_count(req_msg, param->rnr_retry_count);
- cm_req_set_srq(req_msg, param->srq);
- }
-
- if (pri_path->hop_limit <= 1) {
- req_msg->primary_local_lid = pri_path->slid;
- req_msg->primary_remote_lid = pri_path->dlid;
- } else {
- /* Work-around until there's a way to obtain remote LID info */
- req_msg->primary_local_lid = IB_LID_PERMISSIVE;
- req_msg->primary_remote_lid = IB_LID_PERMISSIVE;
- }
- req_msg->primary_local_gid = pri_path->sgid;
- req_msg->primary_remote_gid = pri_path->dgid;
- cm_req_set_primary_flow_label(req_msg, pri_path->flow_label);
- cm_req_set_primary_packet_rate(req_msg, pri_path->rate);
- req_msg->primary_traffic_class = pri_path->traffic_class;
- req_msg->primary_hop_limit = pri_path->hop_limit;
- cm_req_set_primary_sl(req_msg, pri_path->sl);
- cm_req_set_primary_subnet_local(req_msg, (pri_path->hop_limit <= 1));
- cm_req_set_primary_local_ack_timeout(req_msg,
- cm_ack_timeout(cm_id_priv->av.port->cm_dev->ack_delay,
- pri_path->packet_life_time));
-
- if (alt_path) {
- if (alt_path->hop_limit <= 1) {
- req_msg->alt_local_lid = alt_path->slid;
- req_msg->alt_remote_lid = alt_path->dlid;
- } else {
- req_msg->alt_local_lid = IB_LID_PERMISSIVE;
- req_msg->alt_remote_lid = IB_LID_PERMISSIVE;
- }
- req_msg->alt_local_gid = alt_path->sgid;
- req_msg->alt_remote_gid = alt_path->dgid;
- cm_req_set_alt_flow_label(req_msg,
- alt_path->flow_label);
- cm_req_set_alt_packet_rate(req_msg, alt_path->rate);
- req_msg->alt_traffic_class = alt_path->traffic_class;
- req_msg->alt_hop_limit = alt_path->hop_limit;
- cm_req_set_alt_sl(req_msg, alt_path->sl);
- cm_req_set_alt_subnet_local(req_msg, (alt_path->hop_limit <= 1));
- cm_req_set_alt_local_ack_timeout(req_msg,
- cm_ack_timeout(cm_id_priv->av.port->cm_dev->ack_delay,
- alt_path->packet_life_time));
- }
-
- if (param->private_data && param->private_data_len)
- memcpy(req_msg->private_data, param->private_data,
- param->private_data_len);
-}
-
-static int cm_validate_req_param(struct ib_cm_req_param *param)
-{
- /* peer-to-peer not supported */
- if (param->peer_to_peer)
- return -EINVAL;
-
- if (!param->primary_path)
- return -EINVAL;
-
- if (param->qp_type != IB_QPT_RC && param->qp_type != IB_QPT_UC &&
- param->qp_type != IB_QPT_XRC_INI)
- return -EINVAL;
-
- if (param->private_data &&
- param->private_data_len > IB_CM_REQ_PRIVATE_DATA_SIZE)
- return -EINVAL;
-
- if (param->alternate_path &&
- (param->alternate_path->pkey != param->primary_path->pkey ||
- param->alternate_path->mtu != param->primary_path->mtu))
- return -EINVAL;
-
- return 0;
-}
-
-int ib_send_cm_req(struct ib_cm_id *cm_id,
- struct ib_cm_req_param *param)
-{
- struct cm_id_private *cm_id_priv;
- struct cm_req_msg *req_msg;
- unsigned long flags;
- int ret;
-
- ret = cm_validate_req_param(param);
- if (ret)
- return ret;
-
- /* Verify that we're not in timewait. */
- cm_id_priv = container_of(cm_id, struct cm_id_private, id);
- spin_lock_irqsave(&cm_id_priv->lock, flags);
- if (cm_id->state != IB_CM_IDLE) {
- spin_unlock_irqrestore(&cm_id_priv->lock, flags);
- return -EINVAL;
- }
-
- cm_id_priv->timewait_info = cm_create_timewait_info(cm_id_priv->
- id.local_id,
- GFP_ATOMIC);
- if (IS_ERR(cm_id_priv->timewait_info)) {
- spin_unlock_irqrestore(&cm_id_priv->lock, flags);
- return (PTR_ERR(cm_id_priv->timewait_info));
- }
-
- ret = cm_init_av_by_path(param->primary_path, &cm_id_priv->av);
- if (!ret && param->alternate_path) {
- ret = cm_init_av_by_path(param->alternate_path,
- &cm_id_priv->alt_av);
- }
- if (ret) {
- spin_unlock_irqrestore(&cm_id_priv->lock, flags);
- goto error1;
- }
- spin_unlock_irqrestore(&cm_id_priv->lock, flags);
-
- cm_id->service_id = param->service_id;
- cm_id->service_mask = ~cpu_to_be64(0);
- cm_id_priv->timeout_ms = cm_convert_to_ms(
- param->primary_path->packet_life_time) * 2 +
- cm_convert_to_ms(
- param->remote_cm_response_timeout);
- cm_id_priv->max_cm_retries = param->max_cm_retries;
- cm_id_priv->initiator_depth = param->initiator_depth;
- cm_id_priv->responder_resources = param->responder_resources;
- cm_id_priv->retry_count = param->retry_count;
- cm_id_priv->path_mtu = param->primary_path->mtu;
- cm_id_priv->pkey = param->primary_path->pkey;
- cm_id_priv->qp_type = param->qp_type;
-
- ret = cm_alloc_msg(cm_id_priv, &cm_id_priv->msg);
- if (ret)
- goto error1;
-
- req_msg = (struct cm_req_msg *) cm_id_priv->msg->mad;
- cm_format_req(req_msg, cm_id_priv, param);
- cm_id_priv->tid = req_msg->hdr.tid;
- cm_id_priv->msg->timeout_ms = cm_id_priv->timeout_ms;
- cm_id_priv->msg->context[1] = (void *) (unsigned long) IB_CM_REQ_SENT;
-
- cm_id_priv->local_qpn = cm_req_get_local_qpn(req_msg);
- cm_id_priv->rq_psn = cm_req_get_starting_psn(req_msg);
-
- spin_lock_irqsave(&cm_id_priv->lock, flags);
- ret = ib_post_send_mad(cm_id_priv->msg, NULL);
- if (ret) {
- spin_unlock_irqrestore(&cm_id_priv->lock, flags);
- goto error2;
- }
- BUG_ON(cm_id->state != IB_CM_IDLE);
- cm_id->state = IB_CM_REQ_SENT;
- spin_unlock_irqrestore(&cm_id_priv->lock, flags);
- return 0;
-
-error2:
- cm_free_msg(cm_id_priv->msg);
-error1:
- kfree(cm_id_priv->timewait_info);
- return ret;
-}
-EXPORT_SYMBOL(ib_send_cm_req);
-
-static int cm_issue_rej(struct cm_port *port,
- struct ib_mad_recv_wc *mad_recv_wc,
- enum ib_cm_rej_reason reason,
- enum cm_msg_response msg_rejected,
- void *ari, u8 ari_length)
-{
- struct ib_mad_send_buf *msg = NULL;
- struct cm_rej_msg *rej_msg, *rcv_msg;
- int ret;
-
- ret = cm_alloc_response_msg(port, mad_recv_wc, &msg);
- if (ret)
- return ret;
-
- /* We just need common CM header information. Cast to any message. */
- rcv_msg = (struct cm_rej_msg *) mad_recv_wc->recv_buf.mad;
- rej_msg = (struct cm_rej_msg *) msg->mad;
-
- cm_format_mad_hdr(&rej_msg->hdr, CM_REJ_ATTR_ID, rcv_msg->hdr.tid);
- rej_msg->remote_comm_id = rcv_msg->local_comm_id;
- rej_msg->local_comm_id = rcv_msg->remote_comm_id;
- cm_rej_set_msg_rejected(rej_msg, msg_rejected);
- rej_msg->reason = cpu_to_be16(reason);
-
- if (ari && ari_length) {
- cm_rej_set_reject_info_len(rej_msg, ari_length);
- memcpy(rej_msg->ari, ari, ari_length);
- }
-
- ret = ib_post_send_mad(msg, NULL);
- if (ret)
- cm_free_msg(msg);
-
- return ret;
-}
-
-static inline int cm_is_active_peer(__be64 local_ca_guid, __be64 remote_ca_guid,
- __be32 local_qpn, __be32 remote_qpn)
-{
- return (be64_to_cpu(local_ca_guid) > be64_to_cpu(remote_ca_guid) ||
- ((local_ca_guid == remote_ca_guid) &&
- (be32_to_cpu(local_qpn) > be32_to_cpu(remote_qpn))));
-}
-
-static void cm_format_paths_from_req(struct cm_req_msg *req_msg,
- struct ib_sa_path_rec *primary_path,
- struct ib_sa_path_rec *alt_path)
-{
- memset(primary_path, 0, sizeof *primary_path);
- primary_path->dgid = req_msg->primary_local_gid;
- primary_path->sgid = req_msg->primary_remote_gid;
- primary_path->dlid = req_msg->primary_local_lid;
- primary_path->slid = req_msg->primary_remote_lid;
- primary_path->flow_label = cm_req_get_primary_flow_label(req_msg);
- primary_path->hop_limit = req_msg->primary_hop_limit;
- primary_path->traffic_class = req_msg->primary_traffic_class;
- primary_path->reversible = 1;
- primary_path->pkey = req_msg->pkey;
- primary_path->sl = cm_req_get_primary_sl(req_msg);
- primary_path->mtu_selector = IB_SA_EQ;
- primary_path->mtu = cm_req_get_path_mtu(req_msg);
- primary_path->rate_selector = IB_SA_EQ;
- primary_path->rate = cm_req_get_primary_packet_rate(req_msg);
- primary_path->packet_life_time_selector = IB_SA_EQ;
- primary_path->packet_life_time =
- cm_req_get_primary_local_ack_timeout(req_msg);
- primary_path->packet_life_time -= (primary_path->packet_life_time > 0);
-
- if (req_msg->alt_local_lid) {
- memset(alt_path, 0, sizeof *alt_path);
- alt_path->dgid = req_msg->alt_local_gid;
- alt_path->sgid = req_msg->alt_remote_gid;
- alt_path->dlid = req_msg->alt_local_lid;
- alt_path->slid = req_msg->alt_remote_lid;
- alt_path->flow_label = cm_req_get_alt_flow_label(req_msg);
- alt_path->hop_limit = req_msg->alt_hop_limit;
- alt_path->traffic_class = req_msg->alt_traffic_class;
- alt_path->reversible = 1;
- alt_path->pkey = req_msg->pkey;
- alt_path->sl = cm_req_get_alt_sl(req_msg);
- alt_path->mtu_selector = IB_SA_EQ;
- alt_path->mtu = cm_req_get_path_mtu(req_msg);
- alt_path->rate_selector = IB_SA_EQ;
- alt_path->rate = cm_req_get_alt_packet_rate(req_msg);
- alt_path->packet_life_time_selector = IB_SA_EQ;
- alt_path->packet_life_time =
- cm_req_get_alt_local_ack_timeout(req_msg);
- alt_path->packet_life_time -= (alt_path->packet_life_time > 0);
- }
-}
-
-static void cm_format_req_event(struct cm_work *work,
- struct cm_id_private *cm_id_priv,
- struct ib_cm_id *listen_id)
-{
- struct cm_req_msg *req_msg;
- struct ib_cm_req_event_param *param;
-
- req_msg = (struct cm_req_msg *)work->mad_recv_wc->recv_buf.mad;
- param = &work->cm_event.param.req_rcvd;
- param->listen_id = listen_id;
- param->port = cm_id_priv->av.port->port_num;
- param->primary_path = &work->path[0];
- if (req_msg->alt_local_lid)
- param->alternate_path = &work->path[1];
- else
- param->alternate_path = NULL;
- param->remote_ca_guid = req_msg->local_ca_guid;
- param->remote_qkey = be32_to_cpu(req_msg->local_qkey);
- param->remote_qpn = be32_to_cpu(cm_req_get_local_qpn(req_msg));
- param->qp_type = cm_req_get_qp_type(req_msg);
- param->starting_psn = be32_to_cpu(cm_req_get_starting_psn(req_msg));
- param->responder_resources = cm_req_get_init_depth(req_msg);
- param->initiator_depth = cm_req_get_resp_res(req_msg);
- param->local_cm_response_timeout =
- cm_req_get_remote_resp_timeout(req_msg);
- param->flow_control = cm_req_get_flow_ctrl(req_msg);
- param->remote_cm_response_timeout =
- cm_req_get_local_resp_timeout(req_msg);
- param->retry_count = cm_req_get_retry_count(req_msg);
- param->rnr_retry_count = cm_req_get_rnr_retry_count(req_msg);
- param->srq = cm_req_get_srq(req_msg);
- work->cm_event.private_data = &req_msg->private_data;
-}
-
-static void cm_process_work(struct cm_id_private *cm_id_priv,
- struct cm_work *work)
-{
- int ret;
-
- /* We will typically only have the current event to report. */
- ret = cm_id_priv->id.cm_handler(&cm_id_priv->id, &work->cm_event);
- cm_free_work(work);
-
- while (!ret && !atomic_add_negative(-1, &cm_id_priv->work_count)) {
- spin_lock_irq(&cm_id_priv->lock);
- work = cm_dequeue_work(cm_id_priv);
- spin_unlock_irq(&cm_id_priv->lock);
- BUG_ON(!work);
- ret = cm_id_priv->id.cm_handler(&cm_id_priv->id,
- &work->cm_event);
- cm_free_work(work);
- }
- cm_deref_id(cm_id_priv);
- if (ret)
- cm_destroy_id(&cm_id_priv->id, ret);
-}
-
-static void cm_format_mra(struct cm_mra_msg *mra_msg,
- struct cm_id_private *cm_id_priv,
- enum cm_msg_response msg_mraed, u8 service_timeout,
- const void *private_data, u8 private_data_len)
-{
- cm_format_mad_hdr(&mra_msg->hdr, CM_MRA_ATTR_ID, cm_id_priv->tid);
- cm_mra_set_msg_mraed(mra_msg, msg_mraed);
- mra_msg->local_comm_id = cm_id_priv->id.local_id;
- mra_msg->remote_comm_id = cm_id_priv->id.remote_id;
- cm_mra_set_service_timeout(mra_msg, service_timeout);
-
- if (private_data && private_data_len)
- memcpy(mra_msg->private_data, private_data, private_data_len);
-}
-
-static void cm_format_rej(struct cm_rej_msg *rej_msg,
- struct cm_id_private *cm_id_priv,
- enum ib_cm_rej_reason reason,
- void *ari,
- u8 ari_length,
- const void *private_data,
- u8 private_data_len)
-{
- cm_format_mad_hdr(&rej_msg->hdr, CM_REJ_ATTR_ID, cm_id_priv->tid);
- rej_msg->remote_comm_id = cm_id_priv->id.remote_id;
-
- switch(cm_id_priv->id.state) {
- case IB_CM_REQ_RCVD:
- rej_msg->local_comm_id = 0;
- cm_rej_set_msg_rejected(rej_msg, CM_MSG_RESPONSE_REQ);
- break;
- case IB_CM_MRA_REQ_SENT:
- rej_msg->local_comm_id = cm_id_priv->id.local_id;
- cm_rej_set_msg_rejected(rej_msg, CM_MSG_RESPONSE_REQ);
- break;
- case IB_CM_REP_RCVD:
- case IB_CM_MRA_REP_SENT:
- rej_msg->local_comm_id = cm_id_priv->id.local_id;
- cm_rej_set_msg_rejected(rej_msg, CM_MSG_RESPONSE_REP);
- break;
- default:
- rej_msg->local_comm_id = cm_id_priv->id.local_id;
- cm_rej_set_msg_rejected(rej_msg, CM_MSG_RESPONSE_OTHER);
- break;
- }
-
- rej_msg->reason = cpu_to_be16(reason);
- if (ari && ari_length) {
- cm_rej_set_reject_info_len(rej_msg, ari_length);
- memcpy(rej_msg->ari, ari, ari_length);
- }
-
- if (private_data && private_data_len)
- memcpy(rej_msg->private_data, private_data, private_data_len);
-}
-
-static void cm_dup_req_handler(struct cm_work *work,
- struct cm_id_private *cm_id_priv)
-{
- struct ib_mad_send_buf *msg = NULL;
- int ret;
-
- atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
- counter[CM_REQ_COUNTER]);
-
- /* Quick state check to discard duplicate REQs. */
- if (cm_id_priv->id.state == IB_CM_REQ_RCVD)
- return;
-
- ret = cm_alloc_response_msg(work->port, work->mad_recv_wc, &msg);
- if (ret)
- return;
-
- spin_lock_irq(&cm_id_priv->lock);
- switch (cm_id_priv->id.state) {
- case IB_CM_MRA_REQ_SENT:
- cm_format_mra((struct cm_mra_msg *) msg->mad, cm_id_priv,
- CM_MSG_RESPONSE_REQ, cm_id_priv->service_timeout,
- cm_id_priv->private_data,
- cm_id_priv->private_data_len);
- break;
- case IB_CM_TIMEWAIT:
- cm_format_rej((struct cm_rej_msg *) msg->mad, cm_id_priv,
- IB_CM_REJ_STALE_CONN, NULL, 0, NULL, 0);
- break;
- default:
- goto unlock;
- }
- spin_unlock_irq(&cm_id_priv->lock);
-
- ret = ib_post_send_mad(msg, NULL);
- if (ret)
- goto free;
- return;
-
-unlock: spin_unlock_irq(&cm_id_priv->lock);
-free: cm_free_msg(msg);
-}
-
-static struct cm_id_private * cm_match_req(struct cm_work *work,
- struct cm_id_private *cm_id_priv)
-{
- struct cm_id_private *listen_cm_id_priv, *cur_cm_id_priv;
- struct cm_timewait_info *timewait_info;
- struct cm_req_msg *req_msg;
-
- req_msg = (struct cm_req_msg *)work->mad_recv_wc->recv_buf.mad;
-
- /* Check for possible duplicate REQ. */
- spin_lock_irq(&cm.lock);
- timewait_info = cm_insert_remote_id(cm_id_priv->timewait_info);
- if (timewait_info) {
- cur_cm_id_priv = cm_get_id(timewait_info->work.local_id,
- timewait_info->work.remote_id);
- spin_unlock_irq(&cm.lock);
- if (cur_cm_id_priv) {
- cm_dup_req_handler(work, cur_cm_id_priv);
- cm_deref_id(cur_cm_id_priv);
- }
- return NULL;
- }
-
- /* Check for stale connections. */
- timewait_info = cm_insert_remote_qpn(cm_id_priv->timewait_info);
- if (timewait_info) {
- cm_cleanup_timewait(cm_id_priv->timewait_info);
- spin_unlock_irq(&cm.lock);
- cm_issue_rej(work->port, work->mad_recv_wc,
- IB_CM_REJ_STALE_CONN, CM_MSG_RESPONSE_REQ,
- NULL, 0);
- return NULL;
- }
-
- /* Find matching listen request. */
- listen_cm_id_priv = cm_find_listen(cm_id_priv->id.device,
- req_msg->service_id,
- req_msg->private_data);
- if (!listen_cm_id_priv) {
- cm_cleanup_timewait(cm_id_priv->timewait_info);
- spin_unlock_irq(&cm.lock);
- cm_issue_rej(work->port, work->mad_recv_wc,
- IB_CM_REJ_INVALID_SERVICE_ID, CM_MSG_RESPONSE_REQ,
- NULL, 0);
- goto out;
- }
- atomic_inc(&listen_cm_id_priv->refcount);
- atomic_inc(&cm_id_priv->refcount);
- cm_id_priv->id.state = IB_CM_REQ_RCVD;
- atomic_inc(&cm_id_priv->work_count);
- spin_unlock_irq(&cm.lock);
-out:
- return listen_cm_id_priv;
-}
-
-/*
- * Work-around for inter-subnet connections. If the LIDs are permissive,
- * we need to override the LID/SL data in the REQ with the LID information
- * in the work completion.
- */
-static void cm_process_routed_req(struct cm_req_msg *req_msg, struct ib_wc *wc)
-{
- if (!cm_req_get_primary_subnet_local(req_msg)) {
- if (req_msg->primary_local_lid == IB_LID_PERMISSIVE) {
- req_msg->primary_local_lid = cpu_to_be16(wc->slid);
- cm_req_set_primary_sl(req_msg, wc->sl);
- }
-
- if (req_msg->primary_remote_lid == IB_LID_PERMISSIVE)
- req_msg->primary_remote_lid = cpu_to_be16(wc->dlid_path_bits);
- }
-
- if (!cm_req_get_alt_subnet_local(req_msg)) {
- if (req_msg->alt_local_lid == IB_LID_PERMISSIVE) {
- req_msg->alt_local_lid = cpu_to_be16(wc->slid);
- cm_req_set_alt_sl(req_msg, wc->sl);
- }
-
- if (req_msg->alt_remote_lid == IB_LID_PERMISSIVE)
- req_msg->alt_remote_lid = cpu_to_be16(wc->dlid_path_bits);
- }
-}
-
-static int cm_req_handler(struct cm_work *work)
-{
- struct ib_cm_id *cm_id;
- struct cm_id_private *cm_id_priv, *listen_cm_id_priv;
- struct cm_req_msg *req_msg;
- int ret;
-
- req_msg = (struct cm_req_msg *)work->mad_recv_wc->recv_buf.mad;
-
- cm_id = ib_create_cm_id(work->port->cm_dev->ib_device, NULL, NULL);
- if (IS_ERR(cm_id))
- return PTR_ERR(cm_id);
-
- cm_id_priv = container_of(cm_id, struct cm_id_private, id);
- cm_id_priv->id.remote_id = req_msg->local_comm_id;
- cm_init_av_for_response(work->port, work->mad_recv_wc->wc,
- work->mad_recv_wc->recv_buf.grh,
- &cm_id_priv->av);
- cm_id_priv->timewait_info = cm_create_timewait_info(cm_id_priv->
- id.local_id,
- GFP_KERNEL);
- if (IS_ERR(cm_id_priv->timewait_info)) {
- ret = PTR_ERR(cm_id_priv->timewait_info);
- goto destroy;
- }
- cm_id_priv->timewait_info->work.remote_id = req_msg->local_comm_id;
- cm_id_priv->timewait_info->remote_ca_guid = req_msg->local_ca_guid;
- cm_id_priv->timewait_info->remote_qpn = cm_req_get_local_qpn(req_msg);
-
- listen_cm_id_priv = cm_match_req(work, cm_id_priv);
- if (!listen_cm_id_priv) {
- ret = -EINVAL;
- kfree(cm_id_priv->timewait_info);
- goto destroy;
- }
-
- cm_id_priv->id.cm_handler = listen_cm_id_priv->id.cm_handler;
- cm_id_priv->id.context = listen_cm_id_priv->id.context;
- cm_id_priv->id.service_id = req_msg->service_id;
- cm_id_priv->id.service_mask = ~cpu_to_be64(0);
-
- cm_process_routed_req(req_msg, work->mad_recv_wc->wc);
- cm_format_paths_from_req(req_msg, &work->path[0], &work->path[1]);
-
- /* Workarround: path in req_msg doesn't contain MAC, take it from wc */
- memcpy(work->path[0].dmac, cm_id_priv->av.ah_attr.dmac, 6);
- work->path[0].vlan_id = cm_id_priv->av.ah_attr.vlan_id;
- ret = cm_init_av_by_path(&work->path[0], &cm_id_priv->av);
- if (ret) {
- ib_get_cached_gid(work->port->cm_dev->ib_device,
- work->port->port_num, 0, &work->path[0].sgid);
- ib_send_cm_rej(cm_id, IB_CM_REJ_INVALID_GID,
- &work->path[0].sgid, sizeof work->path[0].sgid,
- NULL, 0);
- goto rejected;
- }
- if (req_msg->alt_local_lid) {
- ret = cm_init_av_by_path(&work->path[1], &cm_id_priv->alt_av);
- if (ret) {
- ib_send_cm_rej(cm_id, IB_CM_REJ_INVALID_ALT_GID,
- &work->path[0].sgid,
- sizeof work->path[0].sgid, NULL, 0);
- goto rejected;
- }
- }
- cm_id_priv->tid = req_msg->hdr.tid;
- cm_id_priv->timeout_ms = cm_convert_to_ms(
- cm_req_get_local_resp_timeout(req_msg));
- cm_id_priv->max_cm_retries = cm_req_get_max_cm_retries(req_msg);
- cm_id_priv->remote_qpn = cm_req_get_local_qpn(req_msg);
- cm_id_priv->initiator_depth = cm_req_get_resp_res(req_msg);
- cm_id_priv->responder_resources = cm_req_get_init_depth(req_msg);
- cm_id_priv->path_mtu = cm_req_get_path_mtu(req_msg);
- cm_id_priv->pkey = req_msg->pkey;
- cm_id_priv->sq_psn = cm_req_get_starting_psn(req_msg);
- cm_id_priv->retry_count = cm_req_get_retry_count(req_msg);
- cm_id_priv->rnr_retry_count = cm_req_get_rnr_retry_count(req_msg);
- cm_id_priv->qp_type = cm_req_get_qp_type(req_msg);
-
- cm_format_req_event(work, cm_id_priv, &listen_cm_id_priv->id);
- cm_process_work(cm_id_priv, work);
- cm_deref_id(listen_cm_id_priv);
- return 0;
-
-rejected:
- atomic_dec(&cm_id_priv->refcount);
- cm_deref_id(listen_cm_id_priv);
-destroy:
- ib_destroy_cm_id(cm_id);
- return ret;
-}
-
-static void cm_format_rep(struct cm_rep_msg *rep_msg,
- struct cm_id_private *cm_id_priv,
- struct ib_cm_rep_param *param)
-{
- cm_format_mad_hdr(&rep_msg->hdr, CM_REP_ATTR_ID, cm_id_priv->tid);
- rep_msg->local_comm_id = cm_id_priv->id.local_id;
- rep_msg->remote_comm_id = cm_id_priv->id.remote_id;
- cm_rep_set_starting_psn(rep_msg, cpu_to_be32(param->starting_psn));
- rep_msg->resp_resources = param->responder_resources;
- cm_rep_set_target_ack_delay(rep_msg,
- cm_id_priv->av.port->cm_dev->ack_delay);
- cm_rep_set_failover(rep_msg, param->failover_accepted);
- cm_rep_set_rnr_retry_count(rep_msg, param->rnr_retry_count);
- rep_msg->local_ca_guid = cm_id_priv->id.device->node_guid;
-
- if (cm_id_priv->qp_type != IB_QPT_XRC_TGT) {
- rep_msg->initiator_depth = param->initiator_depth;
- cm_rep_set_flow_ctrl(rep_msg, param->flow_control);
- cm_rep_set_srq(rep_msg, param->srq);
- cm_rep_set_local_qpn(rep_msg, cpu_to_be32(param->qp_num));
- } else {
- cm_rep_set_srq(rep_msg, 1);
- cm_rep_set_local_eecn(rep_msg, cpu_to_be32(param->qp_num));
- }
-
- if (param->private_data && param->private_data_len)
- memcpy(rep_msg->private_data, param->private_data,
- param->private_data_len);
-}
-
-int ib_send_cm_rep(struct ib_cm_id *cm_id,
- struct ib_cm_rep_param *param)
-{
- struct cm_id_private *cm_id_priv;
- struct ib_mad_send_buf *msg;
- struct cm_rep_msg *rep_msg;
- unsigned long flags;
- int ret;
-
- if (param->private_data &&
- param->private_data_len > IB_CM_REP_PRIVATE_DATA_SIZE)
- return -EINVAL;
-
- cm_id_priv = container_of(cm_id, struct cm_id_private, id);
- spin_lock_irqsave(&cm_id_priv->lock, flags);
- if (cm_id->state != IB_CM_REQ_RCVD &&
- cm_id->state != IB_CM_MRA_REQ_SENT) {
- pr_debug("cm_id->state: %d\n", cm_id->state);
- ret = -EINVAL;
- goto out;
- }
-
- ret = cm_alloc_msg(cm_id_priv, &msg);
- if (ret)
- goto out;
-
- rep_msg = (struct cm_rep_msg *) msg->mad;
- cm_format_rep(rep_msg, cm_id_priv, param);
- msg->timeout_ms = cm_id_priv->timeout_ms;
- msg->context[1] = (void *) (unsigned long) IB_CM_REP_SENT;
-
- ret = ib_post_send_mad(msg, NULL);
- if (ret) {
- spin_unlock_irqrestore(&cm_id_priv->lock, flags);
- cm_free_msg(msg);
- return ret;
- }
-
- cm_id->state = IB_CM_REP_SENT;
- cm_id_priv->msg = msg;
- cm_id_priv->initiator_depth = param->initiator_depth;
- cm_id_priv->responder_resources = param->responder_resources;
- cm_id_priv->rq_psn = cm_rep_get_starting_psn(rep_msg);
- cm_id_priv->local_qpn = cpu_to_be32(param->qp_num & 0xFFFFFF);
-
-out: spin_unlock_irqrestore(&cm_id_priv->lock, flags);
- return ret;
-}
-EXPORT_SYMBOL(ib_send_cm_rep);
-
-static void cm_format_rtu(struct cm_rtu_msg *rtu_msg,
- struct cm_id_private *cm_id_priv,
- const void *private_data,
- u8 private_data_len)
-{
- cm_format_mad_hdr(&rtu_msg->hdr, CM_RTU_ATTR_ID, cm_id_priv->tid);
- rtu_msg->local_comm_id = cm_id_priv->id.local_id;
- rtu_msg->remote_comm_id = cm_id_priv->id.remote_id;
-
- if (private_data && private_data_len)
- memcpy(rtu_msg->private_data, private_data, private_data_len);
-}
-
-int ib_send_cm_rtu(struct ib_cm_id *cm_id,
- const void *private_data,
- u8 private_data_len)
-{
- struct cm_id_private *cm_id_priv;
- struct ib_mad_send_buf *msg;
- unsigned long flags;
- void *data;
- int ret;
-
- if (private_data && private_data_len > IB_CM_RTU_PRIVATE_DATA_SIZE)
- return -EINVAL;
-
- data = cm_copy_private_data(private_data, private_data_len);
- if (IS_ERR(data))
- return PTR_ERR(data);
-
- cm_id_priv = container_of(cm_id, struct cm_id_private, id);
- spin_lock_irqsave(&cm_id_priv->lock, flags);
- if (cm_id->state != IB_CM_REP_RCVD &&
- cm_id->state != IB_CM_MRA_REP_SENT) {
- pr_debug("cm_id->state: %d\n", cm_id->state);
- ret = -EINVAL;
- goto error;
- }
-
- ret = cm_alloc_msg(cm_id_priv, &msg);
- if (ret)
- goto error;
-
- cm_format_rtu((struct cm_rtu_msg *) msg->mad, cm_id_priv,
- private_data, private_data_len);
-
- ret = ib_post_send_mad(msg, NULL);
- if (ret) {
- spin_unlock_irqrestore(&cm_id_priv->lock, flags);
- cm_free_msg(msg);
- kfree(data);
- return ret;
- }
-
- cm_id->state = IB_CM_ESTABLISHED;
- cm_set_private_data(cm_id_priv, data, private_data_len);
- spin_unlock_irqrestore(&cm_id_priv->lock, flags);
- return 0;
-
-error: spin_unlock_irqrestore(&cm_id_priv->lock, flags);
- kfree(data);
- return ret;
-}
-EXPORT_SYMBOL(ib_send_cm_rtu);
-
-static void cm_format_rep_event(struct cm_work *work, enum ib_qp_type qp_type)
-{
- struct cm_rep_msg *rep_msg;
- struct ib_cm_rep_event_param *param;
-
- rep_msg = (struct cm_rep_msg *)work->mad_recv_wc->recv_buf.mad;
- param = &work->cm_event.param.rep_rcvd;
- param->remote_ca_guid = rep_msg->local_ca_guid;
- param->remote_qkey = be32_to_cpu(rep_msg->local_qkey);
- param->remote_qpn = be32_to_cpu(cm_rep_get_qpn(rep_msg, qp_type));
- param->starting_psn = be32_to_cpu(cm_rep_get_starting_psn(rep_msg));
- param->responder_resources = rep_msg->initiator_depth;
- param->initiator_depth = rep_msg->resp_resources;
- param->target_ack_delay = cm_rep_get_target_ack_delay(rep_msg);
- param->failover_accepted = cm_rep_get_failover(rep_msg);
- param->flow_control = cm_rep_get_flow_ctrl(rep_msg);
- param->rnr_retry_count = cm_rep_get_rnr_retry_count(rep_msg);
- param->srq = cm_rep_get_srq(rep_msg);
- work->cm_event.private_data = &rep_msg->private_data;
-}
-
-static void cm_dup_rep_handler(struct cm_work *work)
-{
- struct cm_id_private *cm_id_priv;
- struct cm_rep_msg *rep_msg;
- struct ib_mad_send_buf *msg = NULL;
- int ret;
-
- rep_msg = (struct cm_rep_msg *) work->mad_recv_wc->recv_buf.mad;
- cm_id_priv = cm_acquire_id(rep_msg->remote_comm_id,
- rep_msg->local_comm_id);
- if (!cm_id_priv)
- return;
-
- atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
- counter[CM_REP_COUNTER]);
- ret = cm_alloc_response_msg(work->port, work->mad_recv_wc, &msg);
- if (ret)
- goto deref;
-
- spin_lock_irq(&cm_id_priv->lock);
- if (cm_id_priv->id.state == IB_CM_ESTABLISHED)
- cm_format_rtu((struct cm_rtu_msg *) msg->mad, cm_id_priv,
- cm_id_priv->private_data,
- cm_id_priv->private_data_len);
- else if (cm_id_priv->id.state == IB_CM_MRA_REP_SENT)
- cm_format_mra((struct cm_mra_msg *) msg->mad, cm_id_priv,
- CM_MSG_RESPONSE_REP, cm_id_priv->service_timeout,
- cm_id_priv->private_data,
- cm_id_priv->private_data_len);
- else
- goto unlock;
- spin_unlock_irq(&cm_id_priv->lock);
-
- ret = ib_post_send_mad(msg, NULL);
- if (ret)
- goto free;
- goto deref;
-
-unlock: spin_unlock_irq(&cm_id_priv->lock);
-free: cm_free_msg(msg);
-deref: cm_deref_id(cm_id_priv);
-}
-
-static int cm_rep_handler(struct cm_work *work)
-{
- struct cm_id_private *cm_id_priv;
- struct cm_rep_msg *rep_msg;
- int ret;
-
- rep_msg = (struct cm_rep_msg *)work->mad_recv_wc->recv_buf.mad;
- cm_id_priv = cm_acquire_id(rep_msg->remote_comm_id, 0);
- if (!cm_id_priv) {
- cm_dup_rep_handler(work);
- pr_debug("no cm_id_priv\n");
- return -EINVAL;
- }
-
- cm_format_rep_event(work, cm_id_priv->qp_type);
-
- spin_lock_irq(&cm_id_priv->lock);
- switch (cm_id_priv->id.state) {
- case IB_CM_REQ_SENT:
- case IB_CM_MRA_REQ_RCVD:
- break;
- default:
- spin_unlock_irq(&cm_id_priv->lock);
- ret = -EINVAL;
- pr_debug("cm_id_priv->id.state: %d\n", cm_id_priv->id.state);
- goto error;
- }
-
- cm_id_priv->timewait_info->work.remote_id = rep_msg->local_comm_id;
- cm_id_priv->timewait_info->remote_ca_guid = rep_msg->local_ca_guid;
- cm_id_priv->timewait_info->remote_qpn = cm_rep_get_qpn(rep_msg, cm_id_priv->qp_type);
-
- spin_lock(&cm.lock);
- /* Check for duplicate REP. */
- if (cm_insert_remote_id(cm_id_priv->timewait_info)) {
- spin_unlock(&cm.lock);
- spin_unlock_irq(&cm_id_priv->lock);
- ret = -EINVAL;
- pr_debug("Failed to insert remote id\n");
- goto error;
- }
- /* Check for a stale connection. */
- if (cm_insert_remote_qpn(cm_id_priv->timewait_info)) {
- rb_erase(&cm_id_priv->timewait_info->remote_id_node,
- &cm.remote_id_table);
- cm_id_priv->timewait_info->inserted_remote_id = 0;
- spin_unlock(&cm.lock);
- spin_unlock_irq(&cm_id_priv->lock);
- cm_issue_rej(work->port, work->mad_recv_wc,
- IB_CM_REJ_STALE_CONN, CM_MSG_RESPONSE_REP,
- NULL, 0);
- ret = -EINVAL;
- pr_debug("Stale connection.\n");
- goto error;
- }
- spin_unlock(&cm.lock);
-
- cm_id_priv->id.state = IB_CM_REP_RCVD;
- cm_id_priv->id.remote_id = rep_msg->local_comm_id;
- cm_id_priv->remote_qpn = cm_rep_get_qpn(rep_msg, cm_id_priv->qp_type);
- cm_id_priv->initiator_depth = rep_msg->resp_resources;
- cm_id_priv->responder_resources = rep_msg->initiator_depth;
- cm_id_priv->sq_psn = cm_rep_get_starting_psn(rep_msg);
- cm_id_priv->rnr_retry_count = cm_rep_get_rnr_retry_count(rep_msg);
- cm_id_priv->target_ack_delay = cm_rep_get_target_ack_delay(rep_msg);
- cm_id_priv->av.timeout =
- cm_ack_timeout(cm_id_priv->target_ack_delay,
- cm_id_priv->av.timeout - 1);
- cm_id_priv->alt_av.timeout =
- cm_ack_timeout(cm_id_priv->target_ack_delay,
- cm_id_priv->alt_av.timeout - 1);
-
- /* todo: handle peer_to_peer */
-
- ib_cancel_mad(cm_id_priv->av.port->mad_agent, cm_id_priv->msg);
- ret = atomic_inc_and_test(&cm_id_priv->work_count);
- if (!ret)
- list_add_tail(&work->list, &cm_id_priv->work_list);
- spin_unlock_irq(&cm_id_priv->lock);
-
- if (ret)
- cm_process_work(cm_id_priv, work);
- else
- cm_deref_id(cm_id_priv);
- return 0;
-
-error:
- cm_deref_id(cm_id_priv);
- return ret;
-}
-
-static int cm_establish_handler(struct cm_work *work)
-{
- struct cm_id_private *cm_id_priv;
- int ret;
-
- /* See comment in cm_establish about lookup. */
- cm_id_priv = cm_acquire_id(work->local_id, work->remote_id);
- if (!cm_id_priv)
- return -EINVAL;
-
- spin_lock_irq(&cm_id_priv->lock);
- if (cm_id_priv->id.state != IB_CM_ESTABLISHED) {
- spin_unlock_irq(&cm_id_priv->lock);
- goto out;
- }
-
- ib_cancel_mad(cm_id_priv->av.port->mad_agent, cm_id_priv->msg);
- ret = atomic_inc_and_test(&cm_id_priv->work_count);
- if (!ret)
- list_add_tail(&work->list, &cm_id_priv->work_list);
- spin_unlock_irq(&cm_id_priv->lock);
-
- if (ret)
- cm_process_work(cm_id_priv, work);
- else
- cm_deref_id(cm_id_priv);
- return 0;
-out:
- cm_deref_id(cm_id_priv);
- return -EINVAL;
-}
-
-static int cm_rtu_handler(struct cm_work *work)
-{
- struct cm_id_private *cm_id_priv;
- struct cm_rtu_msg *rtu_msg;
- int ret;
-
- rtu_msg = (struct cm_rtu_msg *)work->mad_recv_wc->recv_buf.mad;
- cm_id_priv = cm_acquire_id(rtu_msg->remote_comm_id,
- rtu_msg->local_comm_id);
- if (!cm_id_priv)
- return -EINVAL;
-
- work->cm_event.private_data = &rtu_msg->private_data;
-
- spin_lock_irq(&cm_id_priv->lock);
- if (cm_id_priv->id.state != IB_CM_REP_SENT &&
- cm_id_priv->id.state != IB_CM_MRA_REP_RCVD) {
- spin_unlock_irq(&cm_id_priv->lock);
- atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
- counter[CM_RTU_COUNTER]);
- goto out;
- }
- cm_id_priv->id.state = IB_CM_ESTABLISHED;
-
- ib_cancel_mad(cm_id_priv->av.port->mad_agent, cm_id_priv->msg);
- ret = atomic_inc_and_test(&cm_id_priv->work_count);
- if (!ret)
- list_add_tail(&work->list, &cm_id_priv->work_list);
- spin_unlock_irq(&cm_id_priv->lock);
-
- if (ret)
- cm_process_work(cm_id_priv, work);
- else
- cm_deref_id(cm_id_priv);
- return 0;
-out:
- cm_deref_id(cm_id_priv);
- return -EINVAL;
-}
-
-static void cm_format_dreq(struct cm_dreq_msg *dreq_msg,
- struct cm_id_private *cm_id_priv,
- const void *private_data,
- u8 private_data_len)
-{
- cm_format_mad_hdr(&dreq_msg->hdr, CM_DREQ_ATTR_ID,
- cm_form_tid(cm_id_priv, CM_MSG_SEQUENCE_DREQ));
- dreq_msg->local_comm_id = cm_id_priv->id.local_id;
- dreq_msg->remote_comm_id = cm_id_priv->id.remote_id;
- cm_dreq_set_remote_qpn(dreq_msg, cm_id_priv->remote_qpn);
-
- if (private_data && private_data_len)
- memcpy(dreq_msg->private_data, private_data, private_data_len);
-}
-
-int ib_send_cm_dreq(struct ib_cm_id *cm_id,
- const void *private_data,
- u8 private_data_len)
-{
- struct cm_id_private *cm_id_priv;
- struct ib_mad_send_buf *msg;
- unsigned long flags;
- int ret;
-
- if (private_data && private_data_len > IB_CM_DREQ_PRIVATE_DATA_SIZE)
- return -EINVAL;
-
- cm_id_priv = container_of(cm_id, struct cm_id_private, id);
- spin_lock_irqsave(&cm_id_priv->lock, flags);
- if (cm_id->state != IB_CM_ESTABLISHED) {
- pr_debug("cm_id->state: %d\n", cm_id->state);
- ret = -EINVAL;
- goto out;
- }
-
- if (cm_id->lap_state == IB_CM_LAP_SENT ||
- cm_id->lap_state == IB_CM_MRA_LAP_RCVD)
- ib_cancel_mad(cm_id_priv->av.port->mad_agent, cm_id_priv->msg);
-
- ret = cm_alloc_msg(cm_id_priv, &msg);
- if (ret) {
- cm_enter_timewait(cm_id_priv);
- goto out;
- }
-
- cm_format_dreq((struct cm_dreq_msg *) msg->mad, cm_id_priv,
- private_data, private_data_len);
- msg->timeout_ms = cm_id_priv->timeout_ms;
- msg->context[1] = (void *) (unsigned long) IB_CM_DREQ_SENT;
-
- ret = ib_post_send_mad(msg, NULL);
- if (ret) {
- cm_enter_timewait(cm_id_priv);
- spin_unlock_irqrestore(&cm_id_priv->lock, flags);
- cm_free_msg(msg);
- return ret;
- }
-
- cm_id->state = IB_CM_DREQ_SENT;
- cm_id_priv->msg = msg;
-out: spin_unlock_irqrestore(&cm_id_priv->lock, flags);
- return ret;
-}
-EXPORT_SYMBOL(ib_send_cm_dreq);
-
-static void cm_format_drep(struct cm_drep_msg *drep_msg,
- struct cm_id_private *cm_id_priv,
- const void *private_data,
- u8 private_data_len)
-{
- cm_format_mad_hdr(&drep_msg->hdr, CM_DREP_ATTR_ID, cm_id_priv->tid);
- drep_msg->local_comm_id = cm_id_priv->id.local_id;
- drep_msg->remote_comm_id = cm_id_priv->id.remote_id;
-
- if (private_data && private_data_len)
- memcpy(drep_msg->private_data, private_data, private_data_len);
-}
-
-int ib_send_cm_drep(struct ib_cm_id *cm_id,
- const void *private_data,
- u8 private_data_len)
-{
- struct cm_id_private *cm_id_priv;
- struct ib_mad_send_buf *msg;
- unsigned long flags;
- void *data;
- int ret;
-
- if (private_data && private_data_len > IB_CM_DREP_PRIVATE_DATA_SIZE)
- return -EINVAL;
-
- data = cm_copy_private_data(private_data, private_data_len);
- if (IS_ERR(data))
- return PTR_ERR(data);
-
- cm_id_priv = container_of(cm_id, struct cm_id_private, id);
- spin_lock_irqsave(&cm_id_priv->lock, flags);
- if (cm_id->state != IB_CM_DREQ_RCVD) {
- spin_unlock_irqrestore(&cm_id_priv->lock, flags);
- kfree(data);
- pr_debug("cm_id->state(%d) != IB_CM_DREQ_RCVD\n", cm_id->state);
- return -EINVAL;
- }
-
- cm_set_private_data(cm_id_priv, data, private_data_len);
- cm_enter_timewait(cm_id_priv);
-
- ret = cm_alloc_msg(cm_id_priv, &msg);
- if (ret)
- goto out;
-
- cm_format_drep((struct cm_drep_msg *) msg->mad, cm_id_priv,
- private_data, private_data_len);
-
- ret = ib_post_send_mad(msg, NULL);
- if (ret) {
- spin_unlock_irqrestore(&cm_id_priv->lock, flags);
- cm_free_msg(msg);
- return ret;
- }
-
-out: spin_unlock_irqrestore(&cm_id_priv->lock, flags);
- return ret;
-}
-EXPORT_SYMBOL(ib_send_cm_drep);
-
-static int cm_issue_drep(struct cm_port *port,
- struct ib_mad_recv_wc *mad_recv_wc)
-{
- struct ib_mad_send_buf *msg = NULL;
- struct cm_dreq_msg *dreq_msg;
- struct cm_drep_msg *drep_msg;
- int ret;
-
- ret = cm_alloc_response_msg(port, mad_recv_wc, &msg);
- if (ret)
- return ret;
-
- dreq_msg = (struct cm_dreq_msg *) mad_recv_wc->recv_buf.mad;
- drep_msg = (struct cm_drep_msg *) msg->mad;
-
- cm_format_mad_hdr(&drep_msg->hdr, CM_DREP_ATTR_ID, dreq_msg->hdr.tid);
- drep_msg->remote_comm_id = dreq_msg->local_comm_id;
- drep_msg->local_comm_id = dreq_msg->remote_comm_id;
-
- ret = ib_post_send_mad(msg, NULL);
- if (ret)
- cm_free_msg(msg);
-
- return ret;
-}
-
-static int cm_dreq_handler(struct cm_work *work)
-{
- struct cm_id_private *cm_id_priv;
- struct cm_dreq_msg *dreq_msg;
- struct ib_mad_send_buf *msg = NULL;
- int ret;
-
- dreq_msg = (struct cm_dreq_msg *)work->mad_recv_wc->recv_buf.mad;
- cm_id_priv = cm_acquire_id(dreq_msg->remote_comm_id,
- dreq_msg->local_comm_id);
- if (!cm_id_priv) {
- atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
- counter[CM_DREQ_COUNTER]);
- cm_issue_drep(work->port, work->mad_recv_wc);
- pr_debug("no cm_id_priv\n");
- return -EINVAL;
- }
-
- work->cm_event.private_data = &dreq_msg->private_data;
-
- spin_lock_irq(&cm_id_priv->lock);
- if (cm_id_priv->local_qpn != cm_dreq_get_remote_qpn(dreq_msg))
- goto unlock;
-
- switch (cm_id_priv->id.state) {
- case IB_CM_REP_SENT:
- case IB_CM_DREQ_SENT:
- ib_cancel_mad(cm_id_priv->av.port->mad_agent, cm_id_priv->msg);
- break;
- case IB_CM_ESTABLISHED:
- if (cm_id_priv->id.lap_state == IB_CM_LAP_SENT ||
- cm_id_priv->id.lap_state == IB_CM_MRA_LAP_RCVD)
- ib_cancel_mad(cm_id_priv->av.port->mad_agent, cm_id_priv->msg);
- break;
- case IB_CM_MRA_REP_RCVD:
- break;
- case IB_CM_TIMEWAIT:
- atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
- counter[CM_DREQ_COUNTER]);
- if (cm_alloc_response_msg(work->port, work->mad_recv_wc, &msg))
- goto unlock;
-
- cm_format_drep((struct cm_drep_msg *) msg->mad, cm_id_priv,
- cm_id_priv->private_data,
- cm_id_priv->private_data_len);
- spin_unlock_irq(&cm_id_priv->lock);
-
- if (ib_post_send_mad(msg, NULL))
- cm_free_msg(msg);
- goto deref;
- case IB_CM_DREQ_RCVD:
- atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
- counter[CM_DREQ_COUNTER]);
- goto unlock;
- default:
- pr_debug("cm_id_priv->id.state: %d\n", cm_id_priv->id.state);
- goto unlock;
- }
- cm_id_priv->id.state = IB_CM_DREQ_RCVD;
- cm_id_priv->tid = dreq_msg->hdr.tid;
- ret = atomic_inc_and_test(&cm_id_priv->work_count);
- if (!ret)
- list_add_tail(&work->list, &cm_id_priv->work_list);
- spin_unlock_irq(&cm_id_priv->lock);
-
- if (ret)
- cm_process_work(cm_id_priv, work);
- else
- cm_deref_id(cm_id_priv);
- return 0;
-
-unlock: spin_unlock_irq(&cm_id_priv->lock);
-deref: cm_deref_id(cm_id_priv);
- return -EINVAL;
-}
-
-static int cm_drep_handler(struct cm_work *work)
-{
- struct cm_id_private *cm_id_priv;
- struct cm_drep_msg *drep_msg;
- int ret;
-
- drep_msg = (struct cm_drep_msg *)work->mad_recv_wc->recv_buf.mad;
- cm_id_priv = cm_acquire_id(drep_msg->remote_comm_id,
- drep_msg->local_comm_id);
- if (!cm_id_priv)
- return -EINVAL;
-
- work->cm_event.private_data = &drep_msg->private_data;
-
- spin_lock_irq(&cm_id_priv->lock);
- if (cm_id_priv->id.state != IB_CM_DREQ_SENT &&
- cm_id_priv->id.state != IB_CM_DREQ_RCVD) {
- spin_unlock_irq(&cm_id_priv->lock);
- goto out;
- }
- cm_enter_timewait(cm_id_priv);
-
- ib_cancel_mad(cm_id_priv->av.port->mad_agent, cm_id_priv->msg);
- ret = atomic_inc_and_test(&cm_id_priv->work_count);
- if (!ret)
- list_add_tail(&work->list, &cm_id_priv->work_list);
- spin_unlock_irq(&cm_id_priv->lock);
-
- if (ret)
- cm_process_work(cm_id_priv, work);
- else
- cm_deref_id(cm_id_priv);
- return 0;
-out:
- cm_deref_id(cm_id_priv);
- return -EINVAL;
-}
-
-int ib_send_cm_rej(struct ib_cm_id *cm_id,
- enum ib_cm_rej_reason reason,
- void *ari,
- u8 ari_length,
- const void *private_data,
- u8 private_data_len)
-{
- struct cm_id_private *cm_id_priv;
- struct ib_mad_send_buf *msg;
- unsigned long flags;
- int ret;
-
- if ((private_data && private_data_len > IB_CM_REJ_PRIVATE_DATA_SIZE) ||
- (ari && ari_length > IB_CM_REJ_ARI_LENGTH))
- return -EINVAL;
-
- cm_id_priv = container_of(cm_id, struct cm_id_private, id);
-
- spin_lock_irqsave(&cm_id_priv->lock, flags);
- switch (cm_id->state) {
- case IB_CM_REQ_SENT:
- case IB_CM_MRA_REQ_RCVD:
- case IB_CM_REQ_RCVD:
- case IB_CM_MRA_REQ_SENT:
- case IB_CM_REP_RCVD:
- case IB_CM_MRA_REP_SENT:
- ret = cm_alloc_msg(cm_id_priv, &msg);
- if (!ret)
- cm_format_rej((struct cm_rej_msg *) msg->mad,
- cm_id_priv, reason, ari, ari_length,
- private_data, private_data_len);
-
- cm_reset_to_idle(cm_id_priv);
- break;
- case IB_CM_REP_SENT:
- case IB_CM_MRA_REP_RCVD:
- ret = cm_alloc_msg(cm_id_priv, &msg);
- if (!ret)
- cm_format_rej((struct cm_rej_msg *) msg->mad,
- cm_id_priv, reason, ari, ari_length,
- private_data, private_data_len);
-
- cm_enter_timewait(cm_id_priv);
- break;
- default:
- pr_debug("cm_id->state: 0x%x\n", cm_id->state);
- ret = -EINVAL;
- goto out;
- }
-
- if (ret)
- goto out;
-
- ret = ib_post_send_mad(msg, NULL);
- if (ret)
- cm_free_msg(msg);
-
-out: spin_unlock_irqrestore(&cm_id_priv->lock, flags);
- return ret;
-}
-EXPORT_SYMBOL(ib_send_cm_rej);
-
-static void cm_format_rej_event(struct cm_work *work)
-{
- struct cm_rej_msg *rej_msg;
- struct ib_cm_rej_event_param *param;
-
- rej_msg = (struct cm_rej_msg *)work->mad_recv_wc->recv_buf.mad;
- param = &work->cm_event.param.rej_rcvd;
- param->ari = rej_msg->ari;
- param->ari_length = cm_rej_get_reject_info_len(rej_msg);
- param->reason = __be16_to_cpu(rej_msg->reason);
- work->cm_event.private_data = &rej_msg->private_data;
-}
-
-static struct cm_id_private * cm_acquire_rejected_id(struct cm_rej_msg *rej_msg)
-{
- struct cm_timewait_info *timewait_info;
- struct cm_id_private *cm_id_priv;
- __be32 remote_id;
-
- remote_id = rej_msg->local_comm_id;
-
- if (__be16_to_cpu(rej_msg->reason) == IB_CM_REJ_TIMEOUT) {
- spin_lock_irq(&cm.lock);
- timewait_info = cm_find_remote_id( *((__be64 *) rej_msg->ari),
- remote_id);
- if (!timewait_info) {
- spin_unlock_irq(&cm.lock);
- return NULL;
- }
- cm_id_priv = idr_find(&cm.local_id_table, (__force int)
- (timewait_info->work.local_id ^
- cm.random_id_operand));
- if (cm_id_priv) {
- if (cm_id_priv->id.remote_id == remote_id)
- atomic_inc(&cm_id_priv->refcount);
- else
- cm_id_priv = NULL;
- }
- spin_unlock_irq(&cm.lock);
- } else if (cm_rej_get_msg_rejected(rej_msg) == CM_MSG_RESPONSE_REQ)
- cm_id_priv = cm_acquire_id(rej_msg->remote_comm_id, 0);
- else
- cm_id_priv = cm_acquire_id(rej_msg->remote_comm_id, remote_id);
-
- return cm_id_priv;
-}
-
-static int cm_rej_handler(struct cm_work *work)
-{
- struct cm_id_private *cm_id_priv;
- struct cm_rej_msg *rej_msg;
- int ret;
-
- rej_msg = (struct cm_rej_msg *)work->mad_recv_wc->recv_buf.mad;
- cm_id_priv = cm_acquire_rejected_id(rej_msg);
- if (!cm_id_priv)
- return -EINVAL;
-
- cm_format_rej_event(work);
-
- spin_lock_irq(&cm_id_priv->lock);
- switch (cm_id_priv->id.state) {
- case IB_CM_REQ_SENT:
- case IB_CM_MRA_REQ_RCVD:
- case IB_CM_REP_SENT:
- case IB_CM_MRA_REP_RCVD:
- ib_cancel_mad(cm_id_priv->av.port->mad_agent, cm_id_priv->msg);
- /* fall through */
- case IB_CM_REQ_RCVD:
- case IB_CM_MRA_REQ_SENT:
- if (__be16_to_cpu(rej_msg->reason) == IB_CM_REJ_STALE_CONN)
- cm_enter_timewait(cm_id_priv);
- else
- cm_reset_to_idle(cm_id_priv);
- break;
- case IB_CM_DREQ_SENT:
- ib_cancel_mad(cm_id_priv->av.port->mad_agent, cm_id_priv->msg);
- /* fall through */
- case IB_CM_REP_RCVD:
- case IB_CM_MRA_REP_SENT:
- cm_enter_timewait(cm_id_priv);
- break;
- case IB_CM_ESTABLISHED:
- if (cm_id_priv->id.lap_state == IB_CM_LAP_UNINIT ||
- cm_id_priv->id.lap_state == IB_CM_LAP_SENT) {
- if (cm_id_priv->id.lap_state == IB_CM_LAP_SENT)
- ib_cancel_mad(cm_id_priv->av.port->mad_agent,
- cm_id_priv->msg);
- cm_enter_timewait(cm_id_priv);
- break;
- }
- /* fall through */
- default:
- spin_unlock_irq(&cm_id_priv->lock);
- pr_debug("cm_id_priv->id.state: 0x%x\n", cm_id_priv->id.state);
- ret = -EINVAL;
- goto out;
- }
-
- ret = atomic_inc_and_test(&cm_id_priv->work_count);
- if (!ret)
- list_add_tail(&work->list, &cm_id_priv->work_list);
- spin_unlock_irq(&cm_id_priv->lock);
-
- if (ret)
- cm_process_work(cm_id_priv, work);
- else
- cm_deref_id(cm_id_priv);
- return 0;
-out:
- cm_deref_id(cm_id_priv);
- return -EINVAL;
-}
-
-int ib_send_cm_mra(struct ib_cm_id *cm_id,
- u8 service_timeout,
- const void *private_data,
- u8 private_data_len)
-{
- struct cm_id_private *cm_id_priv;
- struct ib_mad_send_buf *msg;
- enum ib_cm_state cm_state;
- enum ib_cm_lap_state lap_state;
- enum cm_msg_response msg_response;
- void *data;
- unsigned long flags;
- int ret;
-
- if (private_data && private_data_len > IB_CM_MRA_PRIVATE_DATA_SIZE)
- return -EINVAL;
-
- data = cm_copy_private_data(private_data, private_data_len);
- if (IS_ERR(data))
- return PTR_ERR(data);
-
- cm_id_priv = container_of(cm_id, struct cm_id_private, id);
-
- spin_lock_irqsave(&cm_id_priv->lock, flags);
- switch(cm_id_priv->id.state) {
- case IB_CM_REQ_RCVD:
- cm_state = IB_CM_MRA_REQ_SENT;
- lap_state = cm_id->lap_state;
- msg_response = CM_MSG_RESPONSE_REQ;
- break;
- case IB_CM_REP_RCVD:
- cm_state = IB_CM_MRA_REP_SENT;
- lap_state = cm_id->lap_state;
- msg_response = CM_MSG_RESPONSE_REP;
- break;
- case IB_CM_ESTABLISHED:
- if (cm_id->lap_state == IB_CM_LAP_RCVD) {
- cm_state = cm_id->state;
- lap_state = IB_CM_MRA_LAP_SENT;
- msg_response = CM_MSG_RESPONSE_OTHER;
- break;
- }
- default:
- pr_debug("cm_id_priv->id.state: 0x%x\n", cm_id_priv->id.state);
- ret = -EINVAL;
- goto error1;
- }
-
- if (!(service_timeout & IB_CM_MRA_FLAG_DELAY)) {
- ret = cm_alloc_msg(cm_id_priv, &msg);
- if (ret)
- goto error1;
-
- cm_format_mra((struct cm_mra_msg *) msg->mad, cm_id_priv,
- msg_response, service_timeout,
- private_data, private_data_len);
- ret = ib_post_send_mad(msg, NULL);
- if (ret)
- goto error2;
- }
-
- cm_id->state = cm_state;
- cm_id->lap_state = lap_state;
- cm_id_priv->service_timeout = service_timeout;
- cm_set_private_data(cm_id_priv, data, private_data_len);
- spin_unlock_irqrestore(&cm_id_priv->lock, flags);
- return 0;
-
-error1: spin_unlock_irqrestore(&cm_id_priv->lock, flags);
- kfree(data);
- return ret;
-
-error2: spin_unlock_irqrestore(&cm_id_priv->lock, flags);
- kfree(data);
- cm_free_msg(msg);
- return ret;
-}
-EXPORT_SYMBOL(ib_send_cm_mra);
-
-static struct cm_id_private * cm_acquire_mraed_id(struct cm_mra_msg *mra_msg)
-{
- switch (cm_mra_get_msg_mraed(mra_msg)) {
- case CM_MSG_RESPONSE_REQ:
- return cm_acquire_id(mra_msg->remote_comm_id, 0);
- case CM_MSG_RESPONSE_REP:
- case CM_MSG_RESPONSE_OTHER:
- return cm_acquire_id(mra_msg->remote_comm_id,
- mra_msg->local_comm_id);
- default:
- return NULL;
- }
-}
-
-static int cm_mra_handler(struct cm_work *work)
-{
- struct cm_id_private *cm_id_priv;
- struct cm_mra_msg *mra_msg;
- int timeout, ret;
-
- mra_msg = (struct cm_mra_msg *)work->mad_recv_wc->recv_buf.mad;
- cm_id_priv = cm_acquire_mraed_id(mra_msg);
- if (!cm_id_priv)
- return -EINVAL;
-
- work->cm_event.private_data = &mra_msg->private_data;
- work->cm_event.param.mra_rcvd.service_timeout =
- cm_mra_get_service_timeout(mra_msg);
- timeout = cm_convert_to_ms(cm_mra_get_service_timeout(mra_msg)) +
- cm_convert_to_ms(cm_id_priv->av.timeout);
-
- spin_lock_irq(&cm_id_priv->lock);
- switch (cm_id_priv->id.state) {
- case IB_CM_REQ_SENT:
- if (cm_mra_get_msg_mraed(mra_msg) != CM_MSG_RESPONSE_REQ ||
- ib_modify_mad(cm_id_priv->av.port->mad_agent,
- cm_id_priv->msg, timeout))
- goto out;
- cm_id_priv->id.state = IB_CM_MRA_REQ_RCVD;
- break;
- case IB_CM_REP_SENT:
- if (cm_mra_get_msg_mraed(mra_msg) != CM_MSG_RESPONSE_REP ||
- ib_modify_mad(cm_id_priv->av.port->mad_agent,
- cm_id_priv->msg, timeout))
- goto out;
- cm_id_priv->id.state = IB_CM_MRA_REP_RCVD;
- break;
- case IB_CM_ESTABLISHED:
- if (cm_mra_get_msg_mraed(mra_msg) != CM_MSG_RESPONSE_OTHER ||
- cm_id_priv->id.lap_state != IB_CM_LAP_SENT ||
- ib_modify_mad(cm_id_priv->av.port->mad_agent,
- cm_id_priv->msg, timeout)) {
- if (cm_id_priv->id.lap_state == IB_CM_MRA_LAP_RCVD)
- atomic_long_inc(&work->port->
- counter_group[CM_RECV_DUPLICATES].
- counter[CM_MRA_COUNTER]);
- goto out;
- }
- cm_id_priv->id.lap_state = IB_CM_MRA_LAP_RCVD;
- break;
- case IB_CM_MRA_REQ_RCVD:
- case IB_CM_MRA_REP_RCVD:
- atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
- counter[CM_MRA_COUNTER]);
- /* fall through */
- default:
- pr_debug("cm_id_priv->id.state: 0x%x\n", cm_id_priv->id.state);
- goto out;
- }
-
- cm_id_priv->msg->context[1] = (void *) (unsigned long)
- cm_id_priv->id.state;
- ret = atomic_inc_and_test(&cm_id_priv->work_count);
- if (!ret)
- list_add_tail(&work->list, &cm_id_priv->work_list);
- spin_unlock_irq(&cm_id_priv->lock);
-
- if (ret)
- cm_process_work(cm_id_priv, work);
- else
- cm_deref_id(cm_id_priv);
- return 0;
-out:
- spin_unlock_irq(&cm_id_priv->lock);
- cm_deref_id(cm_id_priv);
- return -EINVAL;
-}
-
-static void cm_format_lap(struct cm_lap_msg *lap_msg,
- struct cm_id_private *cm_id_priv,
- struct ib_sa_path_rec *alternate_path,
- const void *private_data,
- u8 private_data_len)
-{
- cm_format_mad_hdr(&lap_msg->hdr, CM_LAP_ATTR_ID,
- cm_form_tid(cm_id_priv, CM_MSG_SEQUENCE_LAP));
- lap_msg->local_comm_id = cm_id_priv->id.local_id;
- lap_msg->remote_comm_id = cm_id_priv->id.remote_id;
- cm_lap_set_remote_qpn(lap_msg, cm_id_priv->remote_qpn);
- /* todo: need remote CM response timeout */
- cm_lap_set_remote_resp_timeout(lap_msg, 0x1F);
- lap_msg->alt_local_lid = alternate_path->slid;
- lap_msg->alt_remote_lid = alternate_path->dlid;
- lap_msg->alt_local_gid = alternate_path->sgid;
- lap_msg->alt_remote_gid = alternate_path->dgid;
- cm_lap_set_flow_label(lap_msg, alternate_path->flow_label);
- cm_lap_set_traffic_class(lap_msg, alternate_path->traffic_class);
- lap_msg->alt_hop_limit = alternate_path->hop_limit;
- cm_lap_set_packet_rate(lap_msg, alternate_path->rate);
- cm_lap_set_sl(lap_msg, alternate_path->sl);
- cm_lap_set_subnet_local(lap_msg, 1); /* local only... */
- cm_lap_set_local_ack_timeout(lap_msg,
- cm_ack_timeout(cm_id_priv->av.port->cm_dev->ack_delay,
- alternate_path->packet_life_time));
-
- if (private_data && private_data_len)
- memcpy(lap_msg->private_data, private_data, private_data_len);
-}
-
-int ib_send_cm_lap(struct ib_cm_id *cm_id,
- struct ib_sa_path_rec *alternate_path,
- const void *private_data,
- u8 private_data_len)
-{
- struct cm_id_private *cm_id_priv;
- struct ib_mad_send_buf *msg;
- unsigned long flags;
- int ret;
-
- if (private_data && private_data_len > IB_CM_LAP_PRIVATE_DATA_SIZE)
- return -EINVAL;
-
- cm_id_priv = container_of(cm_id, struct cm_id_private, id);
- spin_lock_irqsave(&cm_id_priv->lock, flags);
- if (cm_id->state != IB_CM_ESTABLISHED ||
- (cm_id->lap_state != IB_CM_LAP_UNINIT &&
- cm_id->lap_state != IB_CM_LAP_IDLE)) {
- ret = -EINVAL;
- goto out;
- }
-
- ret = cm_init_av_by_path(alternate_path, &cm_id_priv->alt_av);
- if (ret)
- goto out;
- cm_id_priv->alt_av.timeout =
- cm_ack_timeout(cm_id_priv->target_ack_delay,
- cm_id_priv->alt_av.timeout - 1);
-
- ret = cm_alloc_msg(cm_id_priv, &msg);
- if (ret)
- goto out;
-
- cm_format_lap((struct cm_lap_msg *) msg->mad, cm_id_priv,
- alternate_path, private_data, private_data_len);
- msg->timeout_ms = cm_id_priv->timeout_ms;
- msg->context[1] = (void *) (unsigned long) IB_CM_ESTABLISHED;
-
- ret = ib_post_send_mad(msg, NULL);
- if (ret) {
- spin_unlock_irqrestore(&cm_id_priv->lock, flags);
- cm_free_msg(msg);
- return ret;
- }
-
- cm_id->lap_state = IB_CM_LAP_SENT;
- cm_id_priv->msg = msg;
-
-out: spin_unlock_irqrestore(&cm_id_priv->lock, flags);
- return ret;
-}
-EXPORT_SYMBOL(ib_send_cm_lap);
-
-static void cm_format_path_from_lap(struct cm_id_private *cm_id_priv,
- struct ib_sa_path_rec *path,
- struct cm_lap_msg *lap_msg)
-{
- memset(path, 0, sizeof *path);
- path->dgid = lap_msg->alt_local_gid;
- path->sgid = lap_msg->alt_remote_gid;
- path->dlid = lap_msg->alt_local_lid;
- path->slid = lap_msg->alt_remote_lid;
- path->flow_label = cm_lap_get_flow_label(lap_msg);
- path->hop_limit = lap_msg->alt_hop_limit;
- path->traffic_class = cm_lap_get_traffic_class(lap_msg);
- path->reversible = 1;
- path->pkey = cm_id_priv->pkey;
- path->sl = cm_lap_get_sl(lap_msg);
- path->mtu_selector = IB_SA_EQ;
- path->mtu = cm_id_priv->path_mtu;
- path->rate_selector = IB_SA_EQ;
- path->rate = cm_lap_get_packet_rate(lap_msg);
- path->packet_life_time_selector = IB_SA_EQ;
- path->packet_life_time = cm_lap_get_local_ack_timeout(lap_msg);
- path->packet_life_time -= (path->packet_life_time > 0);
-}
-
-static int cm_lap_handler(struct cm_work *work)
-{
- struct cm_id_private *cm_id_priv;
- struct cm_lap_msg *lap_msg;
- struct ib_cm_lap_event_param *param;
- struct ib_mad_send_buf *msg = NULL;
- int ret;
-
- /* todo: verify LAP request and send reject APR if invalid. */
- lap_msg = (struct cm_lap_msg *)work->mad_recv_wc->recv_buf.mad;
- cm_id_priv = cm_acquire_id(lap_msg->remote_comm_id,
- lap_msg->local_comm_id);
- if (!cm_id_priv)
- return -EINVAL;
-
- param = &work->cm_event.param.lap_rcvd;
- param->alternate_path = &work->path[0];
- cm_format_path_from_lap(cm_id_priv, param->alternate_path, lap_msg);
- work->cm_event.private_data = &lap_msg->private_data;
-
- spin_lock_irq(&cm_id_priv->lock);
- if (cm_id_priv->id.state != IB_CM_ESTABLISHED)
- goto unlock;
-
- switch (cm_id_priv->id.lap_state) {
- case IB_CM_LAP_UNINIT:
- case IB_CM_LAP_IDLE:
- break;
- case IB_CM_MRA_LAP_SENT:
- atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
- counter[CM_LAP_COUNTER]);
- if (cm_alloc_response_msg(work->port, work->mad_recv_wc, &msg))
- goto unlock;
-
- cm_format_mra((struct cm_mra_msg *) msg->mad, cm_id_priv,
- CM_MSG_RESPONSE_OTHER,
- cm_id_priv->service_timeout,
- cm_id_priv->private_data,
- cm_id_priv->private_data_len);
- spin_unlock_irq(&cm_id_priv->lock);
-
- if (ib_post_send_mad(msg, NULL))
- cm_free_msg(msg);
- goto deref;
- case IB_CM_LAP_RCVD:
- atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
- counter[CM_LAP_COUNTER]);
- goto unlock;
- default:
- goto unlock;
- }
-
- cm_id_priv->id.lap_state = IB_CM_LAP_RCVD;
- cm_id_priv->tid = lap_msg->hdr.tid;
- cm_init_av_for_response(work->port, work->mad_recv_wc->wc,
- work->mad_recv_wc->recv_buf.grh,
- &cm_id_priv->av);
- if (cm_init_av_by_path(param->alternate_path, &cm_id_priv->alt_av))
- goto unlock;
- ret = atomic_inc_and_test(&cm_id_priv->work_count);
- if (!ret)
- list_add_tail(&work->list, &cm_id_priv->work_list);
- spin_unlock_irq(&cm_id_priv->lock);
-
- if (ret)
- cm_process_work(cm_id_priv, work);
- else
- cm_deref_id(cm_id_priv);
- return 0;
-
-unlock: spin_unlock_irq(&cm_id_priv->lock);
-deref: cm_deref_id(cm_id_priv);
- return -EINVAL;
-}
-
-static void cm_format_apr(struct cm_apr_msg *apr_msg,
- struct cm_id_private *cm_id_priv,
- enum ib_cm_apr_status status,
- void *info,
- u8 info_length,
- const void *private_data,
- u8 private_data_len)
-{
- cm_format_mad_hdr(&apr_msg->hdr, CM_APR_ATTR_ID, cm_id_priv->tid);
- apr_msg->local_comm_id = cm_id_priv->id.local_id;
- apr_msg->remote_comm_id = cm_id_priv->id.remote_id;
- apr_msg->ap_status = (u8) status;
-
- if (info && info_length) {
- apr_msg->info_length = info_length;
- memcpy(apr_msg->info, info, info_length);
- }
-
- if (private_data && private_data_len)
- memcpy(apr_msg->private_data, private_data, private_data_len);
-}
-
-int ib_send_cm_apr(struct ib_cm_id *cm_id,
- enum ib_cm_apr_status status,
- void *info,
- u8 info_length,
- const void *private_data,
- u8 private_data_len)
-{
- struct cm_id_private *cm_id_priv;
- struct ib_mad_send_buf *msg;
- unsigned long flags;
- int ret;
-
- if ((private_data && private_data_len > IB_CM_APR_PRIVATE_DATA_SIZE) ||
- (info && info_length > IB_CM_APR_INFO_LENGTH))
- return -EINVAL;
-
- cm_id_priv = container_of(cm_id, struct cm_id_private, id);
- spin_lock_irqsave(&cm_id_priv->lock, flags);
- if (cm_id->state != IB_CM_ESTABLISHED ||
- (cm_id->lap_state != IB_CM_LAP_RCVD &&
- cm_id->lap_state != IB_CM_MRA_LAP_SENT)) {
- ret = -EINVAL;
- goto out;
- }
-
- ret = cm_alloc_msg(cm_id_priv, &msg);
- if (ret)
- goto out;
-
- cm_format_apr((struct cm_apr_msg *) msg->mad, cm_id_priv, status,
- info, info_length, private_data, private_data_len);
- ret = ib_post_send_mad(msg, NULL);
- if (ret) {
- spin_unlock_irqrestore(&cm_id_priv->lock, flags);
- cm_free_msg(msg);
- return ret;
- }
-
- cm_id->lap_state = IB_CM_LAP_IDLE;
-out: spin_unlock_irqrestore(&cm_id_priv->lock, flags);
- return ret;
-}
-EXPORT_SYMBOL(ib_send_cm_apr);
-
-static int cm_apr_handler(struct cm_work *work)
-{
- struct cm_id_private *cm_id_priv;
- struct cm_apr_msg *apr_msg;
- int ret;
-
- apr_msg = (struct cm_apr_msg *)work->mad_recv_wc->recv_buf.mad;
- cm_id_priv = cm_acquire_id(apr_msg->remote_comm_id,
- apr_msg->local_comm_id);
- if (!cm_id_priv)
- return -EINVAL; /* Unmatched reply. */
-
- work->cm_event.param.apr_rcvd.ap_status = apr_msg->ap_status;
- work->cm_event.param.apr_rcvd.apr_info = &apr_msg->info;
- work->cm_event.param.apr_rcvd.info_len = apr_msg->info_length;
- work->cm_event.private_data = &apr_msg->private_data;
-
- spin_lock_irq(&cm_id_priv->lock);
- if (cm_id_priv->id.state != IB_CM_ESTABLISHED ||
- (cm_id_priv->id.lap_state != IB_CM_LAP_SENT &&
- cm_id_priv->id.lap_state != IB_CM_MRA_LAP_RCVD)) {
- spin_unlock_irq(&cm_id_priv->lock);
- goto out;
- }
- cm_id_priv->id.lap_state = IB_CM_LAP_IDLE;
- ib_cancel_mad(cm_id_priv->av.port->mad_agent, cm_id_priv->msg);
- cm_id_priv->msg = NULL;
-
- ret = atomic_inc_and_test(&cm_id_priv->work_count);
- if (!ret)
- list_add_tail(&work->list, &cm_id_priv->work_list);
- spin_unlock_irq(&cm_id_priv->lock);
-
- if (ret)
- cm_process_work(cm_id_priv, work);
- else
- cm_deref_id(cm_id_priv);
- return 0;
-out:
- cm_deref_id(cm_id_priv);
- return -EINVAL;
-}
-
-static int cm_timewait_handler(struct cm_work *work)
-{
- struct cm_timewait_info *timewait_info;
- struct cm_id_private *cm_id_priv;
- int ret;
-
- timewait_info = (struct cm_timewait_info *)work;
- spin_lock_irq(&cm.lock);
- list_del(&timewait_info->list);
- spin_unlock_irq(&cm.lock);
-
- cm_id_priv = cm_acquire_id(timewait_info->work.local_id,
- timewait_info->work.remote_id);
- if (!cm_id_priv)
- return -EINVAL;
-
- spin_lock_irq(&cm_id_priv->lock);
- if (cm_id_priv->id.state != IB_CM_TIMEWAIT ||
- cm_id_priv->remote_qpn != timewait_info->remote_qpn) {
- spin_unlock_irq(&cm_id_priv->lock);
- goto out;
- }
- cm_id_priv->id.state = IB_CM_IDLE;
- ret = atomic_inc_and_test(&cm_id_priv->work_count);
- if (!ret)
- list_add_tail(&work->list, &cm_id_priv->work_list);
- spin_unlock_irq(&cm_id_priv->lock);
-
- if (ret)
- cm_process_work(cm_id_priv, work);
- else
- cm_deref_id(cm_id_priv);
- return 0;
-out:
- cm_deref_id(cm_id_priv);
- return -EINVAL;
-}
-
-static void cm_format_sidr_req(struct cm_sidr_req_msg *sidr_req_msg,
- struct cm_id_private *cm_id_priv,
- struct ib_cm_sidr_req_param *param)
-{
- cm_format_mad_hdr(&sidr_req_msg->hdr, CM_SIDR_REQ_ATTR_ID,
- cm_form_tid(cm_id_priv, CM_MSG_SEQUENCE_SIDR));
- sidr_req_msg->request_id = cm_id_priv->id.local_id;
- sidr_req_msg->pkey = param->path->pkey;
- sidr_req_msg->service_id = param->service_id;
-
- if (param->private_data && param->private_data_len)
- memcpy(sidr_req_msg->private_data, param->private_data,
- param->private_data_len);
-}
-
-int ib_send_cm_sidr_req(struct ib_cm_id *cm_id,
- struct ib_cm_sidr_req_param *param)
-{
- struct cm_id_private *cm_id_priv;
- struct ib_mad_send_buf *msg;
- unsigned long flags;
- int ret;
-
- if (!param->path || (param->private_data &&
- param->private_data_len > IB_CM_SIDR_REQ_PRIVATE_DATA_SIZE))
- return -EINVAL;
-
- cm_id_priv = container_of(cm_id, struct cm_id_private, id);
-
- spin_lock_irqsave(&cm_id_priv->lock, flags);
-
- ret = cm_init_av_by_path(param->path, &cm_id_priv->av);
- if (ret)
- goto out;
-
- cm_id->service_id = param->service_id;
- cm_id->service_mask = ~cpu_to_be64(0);
- cm_id_priv->timeout_ms = param->timeout_ms;
- cm_id_priv->max_cm_retries = param->max_cm_retries;
- ret = cm_alloc_msg(cm_id_priv, &msg);
- if (ret)
- goto out;
-
- cm_format_sidr_req((struct cm_sidr_req_msg *) msg->mad, cm_id_priv,
- param);
- msg->timeout_ms = cm_id_priv->timeout_ms;
- msg->context[1] = (void *) (unsigned long) IB_CM_SIDR_REQ_SENT;
-
- if (cm_id->state == IB_CM_IDLE)
- ret = ib_post_send_mad(msg, NULL);
- else
- ret = -EINVAL;
-
- if (ret) {
- cm_free_msg(msg);
- goto out;
- }
- cm_id->state = IB_CM_SIDR_REQ_SENT;
- cm_id_priv->msg = msg;
-out:
- spin_unlock_irqrestore(&cm_id_priv->lock, flags);
- return ret;
-}
-EXPORT_SYMBOL(ib_send_cm_sidr_req);
-
-static void cm_format_sidr_req_event(struct cm_work *work,
- struct ib_cm_id *listen_id)
-{
- struct cm_sidr_req_msg *sidr_req_msg;
- struct ib_cm_sidr_req_event_param *param;
-
- sidr_req_msg = (struct cm_sidr_req_msg *)
- work->mad_recv_wc->recv_buf.mad;
- param = &work->cm_event.param.sidr_req_rcvd;
- param->pkey = __be16_to_cpu(sidr_req_msg->pkey);
- param->listen_id = listen_id;
- param->port = work->port->port_num;
- work->cm_event.private_data = &sidr_req_msg->private_data;
-}
-
-static int cm_sidr_req_handler(struct cm_work *work)
-{
- struct ib_cm_id *cm_id;
- struct cm_id_private *cm_id_priv, *cur_cm_id_priv;
- struct cm_sidr_req_msg *sidr_req_msg;
- struct ib_wc *wc;
-
- cm_id = ib_create_cm_id(work->port->cm_dev->ib_device, NULL, NULL);
- if (IS_ERR(cm_id))
- return PTR_ERR(cm_id);
- cm_id_priv = container_of(cm_id, struct cm_id_private, id);
-
- /* Record SGID/SLID and request ID for lookup. */
- sidr_req_msg = (struct cm_sidr_req_msg *)
- work->mad_recv_wc->recv_buf.mad;
- wc = work->mad_recv_wc->wc;
- cm_id_priv->av.dgid.global.subnet_prefix = cpu_to_be64(wc->slid);
- cm_id_priv->av.dgid.global.interface_id = 0;
- cm_init_av_for_response(work->port, work->mad_recv_wc->wc,
- work->mad_recv_wc->recv_buf.grh,
- &cm_id_priv->av);
- cm_id_priv->id.remote_id = sidr_req_msg->request_id;
- cm_id_priv->tid = sidr_req_msg->hdr.tid;
- atomic_inc(&cm_id_priv->work_count);
-
- spin_lock_irq(&cm.lock);
- cur_cm_id_priv = cm_insert_remote_sidr(cm_id_priv);
- if (cur_cm_id_priv) {
- spin_unlock_irq(&cm.lock);
- atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
- counter[CM_SIDR_REQ_COUNTER]);
- goto out; /* Duplicate message. */
- }
- cm_id_priv->id.state = IB_CM_SIDR_REQ_RCVD;
- cur_cm_id_priv = cm_find_listen(cm_id->device,
- sidr_req_msg->service_id,
- sidr_req_msg->private_data);
- if (!cur_cm_id_priv) {
- spin_unlock_irq(&cm.lock);
- cm_reject_sidr_req(cm_id_priv, IB_SIDR_UNSUPPORTED);
- goto out; /* No match. */
- }
- atomic_inc(&cur_cm_id_priv->refcount);
- atomic_inc(&cm_id_priv->refcount);
- spin_unlock_irq(&cm.lock);
-
- cm_id_priv->id.cm_handler = cur_cm_id_priv->id.cm_handler;
- cm_id_priv->id.context = cur_cm_id_priv->id.context;
- cm_id_priv->id.service_id = sidr_req_msg->service_id;
- cm_id_priv->id.service_mask = ~cpu_to_be64(0);
-
- cm_format_sidr_req_event(work, &cur_cm_id_priv->id);
- cm_process_work(cm_id_priv, work);
- cm_deref_id(cur_cm_id_priv);
- return 0;
-out:
- ib_destroy_cm_id(&cm_id_priv->id);
- return -EINVAL;
-}
-
-static void cm_format_sidr_rep(struct cm_sidr_rep_msg *sidr_rep_msg,
- struct cm_id_private *cm_id_priv,
- struct ib_cm_sidr_rep_param *param)
-{
- cm_format_mad_hdr(&sidr_rep_msg->hdr, CM_SIDR_REP_ATTR_ID,
- cm_id_priv->tid);
- sidr_rep_msg->request_id = cm_id_priv->id.remote_id;
- sidr_rep_msg->status = param->status;
- cm_sidr_rep_set_qpn(sidr_rep_msg, cpu_to_be32(param->qp_num));
- sidr_rep_msg->service_id = cm_id_priv->id.service_id;
- sidr_rep_msg->qkey = cpu_to_be32(param->qkey);
-
- if (param->info && param->info_length)
- memcpy(sidr_rep_msg->info, param->info, param->info_length);
-
- if (param->private_data && param->private_data_len)
- memcpy(sidr_rep_msg->private_data, param->private_data,
- param->private_data_len);
-}
-
-int ib_send_cm_sidr_rep(struct ib_cm_id *cm_id,
- struct ib_cm_sidr_rep_param *param)
-{
- struct cm_id_private *cm_id_priv;
- struct ib_mad_send_buf *msg;
- unsigned long flags;
- int ret;
-
- if ((param->info && param->info_length > IB_CM_SIDR_REP_INFO_LENGTH) ||
- (param->private_data &&
- param->private_data_len > IB_CM_SIDR_REP_PRIVATE_DATA_SIZE))
- return -EINVAL;
-
- cm_id_priv = container_of(cm_id, struct cm_id_private, id);
- spin_lock_irqsave(&cm_id_priv->lock, flags);
- if (cm_id->state != IB_CM_SIDR_REQ_RCVD) {
- ret = -EINVAL;
- goto error;
- }
-
- ret = cm_alloc_msg(cm_id_priv, &msg);
- if (ret)
- goto error;
-
- cm_format_sidr_rep((struct cm_sidr_rep_msg *) msg->mad, cm_id_priv,
- param);
- ret = ib_post_send_mad(msg, NULL);
- if (ret) {
- spin_unlock_irqrestore(&cm_id_priv->lock, flags);
- cm_free_msg(msg);
- return ret;
- }
- cm_id->state = IB_CM_IDLE;
- spin_unlock_irqrestore(&cm_id_priv->lock, flags);
-
- spin_lock_irqsave(&cm.lock, flags);
- rb_erase(&cm_id_priv->sidr_id_node, &cm.remote_sidr_table);
- spin_unlock_irqrestore(&cm.lock, flags);
- return 0;
-
-error: spin_unlock_irqrestore(&cm_id_priv->lock, flags);
- return ret;
-}
-EXPORT_SYMBOL(ib_send_cm_sidr_rep);
-
-static void cm_format_sidr_rep_event(struct cm_work *work)
-{
- struct cm_sidr_rep_msg *sidr_rep_msg;
- struct ib_cm_sidr_rep_event_param *param;
-
- sidr_rep_msg = (struct cm_sidr_rep_msg *)
- work->mad_recv_wc->recv_buf.mad;
- param = &work->cm_event.param.sidr_rep_rcvd;
- param->status = sidr_rep_msg->status;
- param->qkey = be32_to_cpu(sidr_rep_msg->qkey);
- param->qpn = be32_to_cpu(cm_sidr_rep_get_qpn(sidr_rep_msg));
- param->info = &sidr_rep_msg->info;
- param->info_len = sidr_rep_msg->info_length;
- work->cm_event.private_data = &sidr_rep_msg->private_data;
-}
-
-static int cm_sidr_rep_handler(struct cm_work *work)
-{
- struct cm_sidr_rep_msg *sidr_rep_msg;
- struct cm_id_private *cm_id_priv;
-
- sidr_rep_msg = (struct cm_sidr_rep_msg *)
- work->mad_recv_wc->recv_buf.mad;
- cm_id_priv = cm_acquire_id(sidr_rep_msg->request_id, 0);
- if (!cm_id_priv)
- return -EINVAL; /* Unmatched reply. */
-
- spin_lock_irq(&cm_id_priv->lock);
- if (cm_id_priv->id.state != IB_CM_SIDR_REQ_SENT) {
- spin_unlock_irq(&cm_id_priv->lock);
- goto out;
- }
- cm_id_priv->id.state = IB_CM_IDLE;
- ib_cancel_mad(cm_id_priv->av.port->mad_agent, cm_id_priv->msg);
- spin_unlock_irq(&cm_id_priv->lock);
-
- cm_format_sidr_rep_event(work);
- cm_process_work(cm_id_priv, work);
- return 0;
-out:
- cm_deref_id(cm_id_priv);
- return -EINVAL;
-}
-
-static void cm_process_send_error(struct ib_mad_send_buf *msg,
- enum ib_wc_status wc_status)
-{
- struct cm_id_private *cm_id_priv;
- struct ib_cm_event cm_event;
- enum ib_cm_state state;
- int ret;
-
- memset(&cm_event, 0, sizeof cm_event);
- cm_id_priv = msg->context[0];
-
- /* Discard old sends or ones without a response. */
- spin_lock_irq(&cm_id_priv->lock);
- state = (enum ib_cm_state) (unsigned long) msg->context[1];
- if (msg != cm_id_priv->msg || state != cm_id_priv->id.state)
- goto discard;
-
- switch (state) {
- case IB_CM_REQ_SENT:
- case IB_CM_MRA_REQ_RCVD:
- cm_reset_to_idle(cm_id_priv);
- cm_event.event = IB_CM_REQ_ERROR;
- break;
- case IB_CM_REP_SENT:
- case IB_CM_MRA_REP_RCVD:
- cm_reset_to_idle(cm_id_priv);
- cm_event.event = IB_CM_REP_ERROR;
- break;
- case IB_CM_DREQ_SENT:
- cm_enter_timewait(cm_id_priv);
- cm_event.event = IB_CM_DREQ_ERROR;
- break;
- case IB_CM_SIDR_REQ_SENT:
- cm_id_priv->id.state = IB_CM_IDLE;
- cm_event.event = IB_CM_SIDR_REQ_ERROR;
- break;
- default:
- goto discard;
- }
- spin_unlock_irq(&cm_id_priv->lock);
- cm_event.param.send_status = wc_status;
-
- /* No other events can occur on the cm_id at this point. */
- ret = cm_id_priv->id.cm_handler(&cm_id_priv->id, &cm_event);
- cm_free_msg(msg);
- if (ret)
- ib_destroy_cm_id(&cm_id_priv->id);
- return;
-discard:
- spin_unlock_irq(&cm_id_priv->lock);
- cm_free_msg(msg);
-}
-
-static void cm_send_handler(struct ib_mad_agent *mad_agent,
- struct ib_mad_send_wc *mad_send_wc)
-{
- struct ib_mad_send_buf *msg = mad_send_wc->send_buf;
- struct cm_port *port;
- u16 attr_index;
-
- port = mad_agent->context;
- attr_index = be16_to_cpu(((struct ib_mad_hdr *)
- msg->mad)->attr_id) - CM_ATTR_ID_OFFSET;
-
- /*
- * If the send was in response to a received message (context[0] is not
- * set to a cm_id), and is not a REJ, then it is a send that was
- * manually retried.
- */
- if (!msg->context[0] && (attr_index != CM_REJ_COUNTER))
- msg->retries = 1;
-
- atomic_long_add(1 + msg->retries,
- &port->counter_group[CM_XMIT].counter[attr_index]);
- if (msg->retries)
- atomic_long_add(msg->retries,
- &port->counter_group[CM_XMIT_RETRIES].
- counter[attr_index]);
-
- switch (mad_send_wc->status) {
- case IB_WC_SUCCESS:
- case IB_WC_WR_FLUSH_ERR:
- cm_free_msg(msg);
- break;
- default:
- if (msg->context[0] && msg->context[1])
- cm_process_send_error(msg, mad_send_wc->status);
- else
- cm_free_msg(msg);
- break;
- }
-}
-
-static void cm_work_handler(struct work_struct *_work)
-{
- struct cm_work *work = container_of(_work, struct cm_work, work.work);
- int ret;
-
- switch (work->cm_event.event) {
- case IB_CM_REQ_RECEIVED:
- ret = cm_req_handler(work);
- break;
- case IB_CM_MRA_RECEIVED:
- ret = cm_mra_handler(work);
- break;
- case IB_CM_REJ_RECEIVED:
- ret = cm_rej_handler(work);
- break;
- case IB_CM_REP_RECEIVED:
- ret = cm_rep_handler(work);
- break;
- case IB_CM_RTU_RECEIVED:
- ret = cm_rtu_handler(work);
- break;
- case IB_CM_USER_ESTABLISHED:
- ret = cm_establish_handler(work);
- break;
- case IB_CM_DREQ_RECEIVED:
- ret = cm_dreq_handler(work);
- break;
- case IB_CM_DREP_RECEIVED:
- ret = cm_drep_handler(work);
- break;
- case IB_CM_SIDR_REQ_RECEIVED:
- ret = cm_sidr_req_handler(work);
- break;
- case IB_CM_SIDR_REP_RECEIVED:
- ret = cm_sidr_rep_handler(work);
- break;
- case IB_CM_LAP_RECEIVED:
- ret = cm_lap_handler(work);
- break;
- case IB_CM_APR_RECEIVED:
- ret = cm_apr_handler(work);
- break;
- case IB_CM_TIMEWAIT_EXIT:
- ret = cm_timewait_handler(work);
- break;
- default:
- pr_debug("work->cm_event.event: 0x%x\n", work->cm_event.event);
- ret = -EINVAL;
- break;
- }
- if (ret)
- cm_free_work(work);
-}
-
-static int cm_establish(struct ib_cm_id *cm_id)
-{
- struct cm_id_private *cm_id_priv;
- struct cm_work *work;
- unsigned long flags;
- int ret = 0;
-
- work = kmalloc(sizeof *work, GFP_ATOMIC);
- if (!work)
- return -ENOMEM;
-
- cm_id_priv = container_of(cm_id, struct cm_id_private, id);
- spin_lock_irqsave(&cm_id_priv->lock, flags);
- switch (cm_id->state)
- {
- case IB_CM_REP_SENT:
- case IB_CM_MRA_REP_RCVD:
- cm_id->state = IB_CM_ESTABLISHED;
- break;
- case IB_CM_ESTABLISHED:
- ret = -EISCONN;
- break;
- default:
- pr_debug("cm_id->state: 0x%x\n", cm_id->state);
- ret = -EINVAL;
- break;
- }
- spin_unlock_irqrestore(&cm_id_priv->lock, flags);
-
- if (ret) {
- kfree(work);
- goto out;
- }
-
- /*
- * The CM worker thread may try to destroy the cm_id before it
- * can execute this work item. To prevent potential deadlock,
- * we need to find the cm_id once we're in the context of the
- * worker thread, rather than holding a reference on it.
- */
- INIT_DELAYED_WORK(&work->work, cm_work_handler);
- work->local_id = cm_id->local_id;
- work->remote_id = cm_id->remote_id;
- work->mad_recv_wc = NULL;
- work->cm_event.event = IB_CM_USER_ESTABLISHED;
- queue_delayed_work(cm.wq, &work->work, 0);
-out:
- return ret;
-}
-
-static int cm_migrate(struct ib_cm_id *cm_id)
-{
- struct cm_id_private *cm_id_priv;
- unsigned long flags;
- int ret = 0;
-
- cm_id_priv = container_of(cm_id, struct cm_id_private, id);
- spin_lock_irqsave(&cm_id_priv->lock, flags);
- if (cm_id->state == IB_CM_ESTABLISHED &&
- (cm_id->lap_state == IB_CM_LAP_UNINIT ||
- cm_id->lap_state == IB_CM_LAP_IDLE)) {
- cm_id->lap_state = IB_CM_LAP_IDLE;
- cm_id_priv->av = cm_id_priv->alt_av;
- } else
- ret = -EINVAL;
- spin_unlock_irqrestore(&cm_id_priv->lock, flags);
-
- return ret;
-}
-
-int ib_cm_notify(struct ib_cm_id *cm_id, enum ib_event_type event)
-{
- int ret;
-
- switch (event) {
- case IB_EVENT_COMM_EST:
- ret = cm_establish(cm_id);
- break;
- case IB_EVENT_PATH_MIG:
- ret = cm_migrate(cm_id);
- break;
- default:
- ret = -EINVAL;
- }
- return ret;
-}
-EXPORT_SYMBOL(ib_cm_notify);
-
-static void cm_recv_handler(struct ib_mad_agent *mad_agent,
- struct ib_mad_recv_wc *mad_recv_wc)
-{
- struct cm_port *port = mad_agent->context;
- struct cm_work *work;
- enum ib_cm_event_type event;
- u16 attr_id;
- int paths = 0;
-
- switch (mad_recv_wc->recv_buf.mad->mad_hdr.attr_id) {
- case CM_REQ_ATTR_ID:
- paths = 1 + (((struct cm_req_msg *) mad_recv_wc->recv_buf.mad)->
- alt_local_lid != 0);
- event = IB_CM_REQ_RECEIVED;
- break;
- case CM_MRA_ATTR_ID:
- event = IB_CM_MRA_RECEIVED;
- break;
- case CM_REJ_ATTR_ID:
- event = IB_CM_REJ_RECEIVED;
- break;
- case CM_REP_ATTR_ID:
- event = IB_CM_REP_RECEIVED;
- break;
- case CM_RTU_ATTR_ID:
- event = IB_CM_RTU_RECEIVED;
- break;
- case CM_DREQ_ATTR_ID:
- event = IB_CM_DREQ_RECEIVED;
- break;
- case CM_DREP_ATTR_ID:
- event = IB_CM_DREP_RECEIVED;
- break;
- case CM_SIDR_REQ_ATTR_ID:
- event = IB_CM_SIDR_REQ_RECEIVED;
- break;
- case CM_SIDR_REP_ATTR_ID:
- event = IB_CM_SIDR_REP_RECEIVED;
- break;
- case CM_LAP_ATTR_ID:
- paths = 1;
- event = IB_CM_LAP_RECEIVED;
- break;
- case CM_APR_ATTR_ID:
- event = IB_CM_APR_RECEIVED;
- break;
- default:
- ib_free_recv_mad(mad_recv_wc);
- return;
- }
-
- attr_id = be16_to_cpu(mad_recv_wc->recv_buf.mad->mad_hdr.attr_id);
- atomic_long_inc(&port->counter_group[CM_RECV].
- counter[attr_id - CM_ATTR_ID_OFFSET]);
-
- work = kmalloc(sizeof *work + sizeof(struct ib_sa_path_rec) * paths,
- GFP_KERNEL);
- if (!work) {
- ib_free_recv_mad(mad_recv_wc);
- return;
- }
-
- INIT_DELAYED_WORK(&work->work, cm_work_handler);
- work->cm_event.event = event;
- work->mad_recv_wc = mad_recv_wc;
- work->port = port;
- queue_delayed_work(cm.wq, &work->work, 0);
-}
-
-static int cm_init_qp_init_attr(struct cm_id_private *cm_id_priv,
- struct ib_qp_attr *qp_attr,
- int *qp_attr_mask)
-{
- unsigned long flags;
- int ret;
-
- spin_lock_irqsave(&cm_id_priv->lock, flags);
- switch (cm_id_priv->id.state) {
- case IB_CM_REQ_SENT:
- case IB_CM_MRA_REQ_RCVD:
- case IB_CM_REQ_RCVD:
- case IB_CM_MRA_REQ_SENT:
- case IB_CM_REP_RCVD:
- case IB_CM_MRA_REP_SENT:
- case IB_CM_REP_SENT:
- case IB_CM_MRA_REP_RCVD:
- case IB_CM_ESTABLISHED:
- *qp_attr_mask = IB_QP_STATE | IB_QP_ACCESS_FLAGS |
- IB_QP_PKEY_INDEX | IB_QP_PORT;
- qp_attr->qp_access_flags = IB_ACCESS_REMOTE_WRITE;
- if (cm_id_priv->responder_resources)
- qp_attr->qp_access_flags |= IB_ACCESS_REMOTE_READ |
- IB_ACCESS_REMOTE_ATOMIC;
- qp_attr->pkey_index = cm_id_priv->av.pkey_index;
- qp_attr->port_num = cm_id_priv->av.port->port_num;
- ret = 0;
- break;
- default:
- pr_debug("cm_id_priv->id.state: 0x%x\n", cm_id_priv->id.state);
- ret = -EINVAL;
- break;
- }
- spin_unlock_irqrestore(&cm_id_priv->lock, flags);
- return ret;
-}
-
-static int cm_init_qp_rtr_attr(struct cm_id_private *cm_id_priv,
- struct ib_qp_attr *qp_attr,
- int *qp_attr_mask)
-{
- unsigned long flags;
- int ret;
-
- spin_lock_irqsave(&cm_id_priv->lock, flags);
- switch (cm_id_priv->id.state) {
- case IB_CM_REQ_RCVD:
- case IB_CM_MRA_REQ_SENT:
- case IB_CM_REP_RCVD:
- case IB_CM_MRA_REP_SENT:
- case IB_CM_REP_SENT:
- case IB_CM_MRA_REP_RCVD:
- case IB_CM_ESTABLISHED:
- *qp_attr_mask = IB_QP_STATE | IB_QP_AV | IB_QP_PATH_MTU |
- IB_QP_DEST_QPN | IB_QP_RQ_PSN;
- qp_attr->ah_attr = cm_id_priv->av.ah_attr;
- if (!cm_id_priv->av.valid)
- return -EINVAL;
- if (cm_id_priv->av.ah_attr.vlan_id != 0xffff) {
- qp_attr->vlan_id = cm_id_priv->av.ah_attr.vlan_id;
- *qp_attr_mask |= IB_QP_VID;
- }
- if (!is_zero_ether_addr(cm_id_priv->av.smac)) {
- memcpy(qp_attr->smac, cm_id_priv->av.smac,
- sizeof(qp_attr->smac));
- *qp_attr_mask |= IB_QP_SMAC;
- }
- if (cm_id_priv->alt_av.valid) {
- if (cm_id_priv->alt_av.ah_attr.vlan_id != 0xffff) {
- qp_attr->alt_vlan_id =
- cm_id_priv->alt_av.ah_attr.vlan_id;
- *qp_attr_mask |= IB_QP_ALT_VID;
- }
- if (!is_zero_ether_addr(cm_id_priv->alt_av.smac)) {
- memcpy(qp_attr->alt_smac,
- cm_id_priv->alt_av.smac,
- sizeof(qp_attr->alt_smac));
- *qp_attr_mask |= IB_QP_ALT_SMAC;
- }
- }
-
- qp_attr->path_mtu = cm_id_priv->path_mtu;
- qp_attr->dest_qp_num = be32_to_cpu(cm_id_priv->remote_qpn);
- qp_attr->rq_psn = be32_to_cpu(cm_id_priv->rq_psn);
- if (cm_id_priv->qp_type == IB_QPT_RC ||
- cm_id_priv->qp_type == IB_QPT_XRC_TGT) {
- *qp_attr_mask |= IB_QP_MAX_DEST_RD_ATOMIC |
- IB_QP_MIN_RNR_TIMER;
- qp_attr->max_dest_rd_atomic =
- cm_id_priv->responder_resources;
- qp_attr->min_rnr_timer = 0;
- }
- if (cm_id_priv->alt_av.ah_attr.dlid) {
- *qp_attr_mask |= IB_QP_ALT_PATH;
- qp_attr->alt_port_num = cm_id_priv->alt_av.port->port_num;
- qp_attr->alt_pkey_index = cm_id_priv->alt_av.pkey_index;
- qp_attr->alt_timeout = cm_id_priv->alt_av.timeout;
- qp_attr->alt_ah_attr = cm_id_priv->alt_av.ah_attr;
- }
- ret = 0;
- break;
- default:
- pr_debug("cm_id_priv->id.state: 0x%x\n", cm_id_priv->id.state);
- ret = -EINVAL;
- break;
- }
- spin_unlock_irqrestore(&cm_id_priv->lock, flags);
- return ret;
-}
-
-static int cm_init_qp_rts_attr(struct cm_id_private *cm_id_priv,
- struct ib_qp_attr *qp_attr,
- int *qp_attr_mask)
-{
- unsigned long flags;
- int ret;
-
- spin_lock_irqsave(&cm_id_priv->lock, flags);
- switch (cm_id_priv->id.state) {
- /* Allow transition to RTS before sending REP */
- case IB_CM_REQ_RCVD:
- case IB_CM_MRA_REQ_SENT:
-
- case IB_CM_REP_RCVD:
- case IB_CM_MRA_REP_SENT:
- case IB_CM_REP_SENT:
- case IB_CM_MRA_REP_RCVD:
- case IB_CM_ESTABLISHED:
- if (cm_id_priv->id.lap_state == IB_CM_LAP_UNINIT) {
- *qp_attr_mask = IB_QP_STATE | IB_QP_SQ_PSN;
- qp_attr->sq_psn = be32_to_cpu(cm_id_priv->sq_psn);
- switch (cm_id_priv->qp_type) {
- case IB_QPT_RC:
- case IB_QPT_XRC_INI:
- *qp_attr_mask |= IB_QP_RETRY_CNT | IB_QP_RNR_RETRY |
- IB_QP_MAX_QP_RD_ATOMIC;
- qp_attr->retry_cnt = cm_id_priv->retry_count;
- qp_attr->rnr_retry = cm_id_priv->rnr_retry_count;
- qp_attr->max_rd_atomic = cm_id_priv->initiator_depth;
- /* fall through */
- case IB_QPT_XRC_TGT:
- *qp_attr_mask |= IB_QP_TIMEOUT;
- qp_attr->timeout = cm_id_priv->av.timeout;
- break;
- default:
- break;
- }
- if (cm_id_priv->alt_av.ah_attr.dlid) {
- *qp_attr_mask |= IB_QP_PATH_MIG_STATE;
- qp_attr->path_mig_state = IB_MIG_REARM;
- }
- } else {
- *qp_attr_mask = IB_QP_ALT_PATH | IB_QP_PATH_MIG_STATE;
- qp_attr->alt_port_num = cm_id_priv->alt_av.port->port_num;
- qp_attr->alt_pkey_index = cm_id_priv->alt_av.pkey_index;
- qp_attr->alt_timeout = cm_id_priv->alt_av.timeout;
- qp_attr->alt_ah_attr = cm_id_priv->alt_av.ah_attr;
- qp_attr->path_mig_state = IB_MIG_REARM;
- }
- ret = 0;
- break;
- default:
- pr_debug("cm_id_priv->id.state: 0x%x\n", cm_id_priv->id.state);
- ret = -EINVAL;
- break;
- }
- spin_unlock_irqrestore(&cm_id_priv->lock, flags);
- return ret;
-}
-
-int ib_cm_init_qp_attr(struct ib_cm_id *cm_id,
- struct ib_qp_attr *qp_attr,
- int *qp_attr_mask)
-{
- struct cm_id_private *cm_id_priv;
- int ret;
-
- cm_id_priv = container_of(cm_id, struct cm_id_private, id);
- switch (qp_attr->qp_state) {
- case IB_QPS_INIT:
- ret = cm_init_qp_init_attr(cm_id_priv, qp_attr, qp_attr_mask);
- break;
- case IB_QPS_RTR:
- ret = cm_init_qp_rtr_attr(cm_id_priv, qp_attr, qp_attr_mask);
- break;
- case IB_QPS_RTS:
- ret = cm_init_qp_rts_attr(cm_id_priv, qp_attr, qp_attr_mask);
- break;
- default:
- pr_debug("qp_attr->qp_state: 0x%x\n", qp_attr->qp_state);
- ret = -EINVAL;
- break;
- }
- return ret;
-}
-EXPORT_SYMBOL(ib_cm_init_qp_attr);
-
-static void cm_get_ack_delay(struct cm_device *cm_dev)
-{
- struct ib_device_attr attr;
-
- if (ib_query_device(cm_dev->ib_device, &attr))
- cm_dev->ack_delay = 0; /* acks will rely on packet life time */
- else
- cm_dev->ack_delay = attr.local_ca_ack_delay;
-}
-
-static ssize_t cm_show_counter(struct kobject *obj, struct attribute *attr,
- char *buf)
-{
- struct cm_counter_group *group;
- struct cm_counter_attribute *cm_attr;
-
- group = container_of(obj, struct cm_counter_group, obj);
- cm_attr = container_of(attr, struct cm_counter_attribute, attr);
-
- return sprintf(buf, "%ld\n",
- atomic_long_read(&group->counter[cm_attr->index]));
-}
-
-static const struct sysfs_ops cm_counter_ops = {
- .show = cm_show_counter
-};
-
-static struct kobj_type cm_counter_obj_type = {
- .sysfs_ops = &cm_counter_ops,
- .default_attrs = cm_counter_default_attrs
-};
-
-static void cm_release_port_obj(struct kobject *obj)
-{
- struct cm_port *cm_port;
-
- cm_port = container_of(obj, struct cm_port, port_obj);
- kfree(cm_port);
-}
-
-static struct kobj_type cm_port_obj_type = {
- .release = cm_release_port_obj
-};
-
-static char *cm_devnode(struct device *dev, umode_t *mode)
-{
- if (mode)
- *mode = 0666;
- return kasprintf(GFP_KERNEL, "infiniband/%s", dev_name(dev));
-}
-
-struct class cm_class = {
- .owner = THIS_MODULE,
- .name = "infiniband_cm",
- .devnode = cm_devnode,
-};
-EXPORT_SYMBOL(cm_class);
-
-static int cm_create_port_fs(struct cm_port *port)
-{
- int i, ret;
-
- ret = kobject_init_and_add(&port->port_obj, &cm_port_obj_type,
- &port->cm_dev->device->kobj,
- "%d", port->port_num);
- if (ret) {
- kfree(port);
- return ret;
- }
-
- for (i = 0; i < CM_COUNTER_GROUPS; i++) {
- ret = kobject_init_and_add(&port->counter_group[i].obj,
- &cm_counter_obj_type,
- &port->port_obj,
- "%s", counter_group_names[i]);
- if (ret)
- goto error;
- }
-
- return 0;
-
-error:
- while (i--)
- kobject_put(&port->counter_group[i].obj);
- kobject_put(&port->port_obj);
- return ret;
-
-}
-
-static void cm_remove_port_fs(struct cm_port *port)
-{
- int i;
-
- for (i = 0; i < CM_COUNTER_GROUPS; i++)
- kobject_put(&port->counter_group[i].obj);
-
- kobject_put(&port->port_obj);
-}
-
-static void cm_add_one(struct ib_device *ib_device)
-{
- struct cm_device *cm_dev;
- struct cm_port *port;
- struct ib_mad_reg_req reg_req = {
- .mgmt_class = IB_MGMT_CLASS_CM,
- .mgmt_class_version = IB_CM_CLASS_VERSION
- };
- struct ib_port_modify port_modify = {
- .set_port_cap_mask = IB_PORT_CM_SUP
- };
- unsigned long flags;
- int ret;
- u8 i;
-
- if (rdma_node_get_transport(ib_device->node_type) != RDMA_TRANSPORT_IB)
- return;
-
- cm_dev = kzalloc(sizeof(*cm_dev) + sizeof(*port) *
- ib_device->phys_port_cnt, GFP_KERNEL);
- if (!cm_dev)
- return;
-
- cm_dev->ib_device = ib_device;
- cm_get_ack_delay(cm_dev);
-
- cm_dev->device = device_create(&cm_class, &ib_device->dev,
- MKDEV(0, 0), NULL,
- "%s", ib_device->name);
- if (IS_ERR(cm_dev->device)) {
- kfree(cm_dev);
- return;
- }
-
- set_bit(IB_MGMT_METHOD_SEND, reg_req.method_mask);
- for (i = 1; i <= ib_device->phys_port_cnt; i++) {
- port = kzalloc(sizeof *port, GFP_KERNEL);
- if (!port)
- goto error1;
-
- cm_dev->port[i-1] = port;
- port->cm_dev = cm_dev;
- port->port_num = i;
-
- ret = cm_create_port_fs(port);
- if (ret)
- goto error1;
-
- port->mad_agent = ib_register_mad_agent(ib_device, i,
- IB_QPT_GSI,
- &reg_req,
- 0,
- cm_send_handler,
- cm_recv_handler,
- port);
- if (IS_ERR(port->mad_agent))
- goto error2;
-
- ret = ib_modify_port(ib_device, i, 0, &port_modify);
- if (ret)
- goto error3;
- }
- ib_set_client_data(ib_device, &cm_client, cm_dev);
-
- write_lock_irqsave(&cm.device_lock, flags);
- list_add_tail(&cm_dev->list, &cm.device_list);
- write_unlock_irqrestore(&cm.device_lock, flags);
- return;
-
-error3:
- ib_unregister_mad_agent(port->mad_agent);
-error2:
- cm_remove_port_fs(port);
-error1:
- port_modify.set_port_cap_mask = 0;
- port_modify.clr_port_cap_mask = IB_PORT_CM_SUP;
- while (--i) {
- port = cm_dev->port[i-1];
- ib_modify_port(ib_device, port->port_num, 0, &port_modify);
- ib_unregister_mad_agent(port->mad_agent);
- cm_remove_port_fs(port);
- }
- device_unregister(cm_dev->device);
- kfree(cm_dev);
-}
-
-static void cm_remove_one(struct ib_device *ib_device)
-{
- struct cm_device *cm_dev;
- struct cm_port *port;
- struct ib_port_modify port_modify = {
- .clr_port_cap_mask = IB_PORT_CM_SUP
- };
- unsigned long flags;
- int i;
-
- cm_dev = ib_get_client_data(ib_device, &cm_client);
- if (!cm_dev)
- return;
-
- write_lock_irqsave(&cm.device_lock, flags);
- list_del(&cm_dev->list);
- write_unlock_irqrestore(&cm.device_lock, flags);
-
- for (i = 1; i <= ib_device->phys_port_cnt; i++) {
- port = cm_dev->port[i-1];
- ib_modify_port(ib_device, port->port_num, 0, &port_modify);
- ib_unregister_mad_agent(port->mad_agent);
- flush_workqueue(cm.wq);
- cm_remove_port_fs(port);
- }
- device_unregister(cm_dev->device);
- kfree(cm_dev);
-}
-
-static int __init ib_cm_init(void)
-{
- int ret;
-
- memset(&cm, 0, sizeof cm);
- INIT_LIST_HEAD(&cm.device_list);
- rwlock_init(&cm.device_lock);
- spin_lock_init(&cm.lock);
- cm.listen_service_table = RB_ROOT;
- cm.listen_service_id = be64_to_cpu(IB_CM_ASSIGN_SERVICE_ID);
- cm.remote_id_table = RB_ROOT;
- cm.remote_qp_table = RB_ROOT;
- cm.remote_sidr_table = RB_ROOT;
- idr_init(&cm.local_id_table);
- get_random_bytes(&cm.random_id_operand, sizeof cm.random_id_operand);
- if (!idr_pre_get(&cm.local_id_table, GFP_KERNEL))
- return -ENOMEM;
- INIT_LIST_HEAD(&cm.timewait_list);
-
- ret = class_register(&cm_class);
- if (ret) {
- ret = -ENOMEM;
- goto error1;
- }
-
- cm.wq = create_workqueue("ib_cm");
- if (!cm.wq) {
- ret = -ENOMEM;
- goto error2;
- }
-
- ret = ib_register_client(&cm_client);
- if (ret)
- goto error3;
-
- return 0;
-error3:
- destroy_workqueue(cm.wq);
-error2:
- class_unregister(&cm_class);
-error1:
- idr_destroy(&cm.local_id_table);
- return ret;
-}
-
-static void __exit ib_cm_cleanup(void)
-{
- struct cm_timewait_info *timewait_info, *tmp;
-
- spin_lock_irq(&cm.lock);
- list_for_each_entry(timewait_info, &cm.timewait_list, list)
- cancel_delayed_work(&timewait_info->work.work);
- spin_unlock_irq(&cm.lock);
-
- ib_unregister_client(&cm_client);
- destroy_workqueue(cm.wq);
-
- list_for_each_entry_safe(timewait_info, tmp, &cm.timewait_list, list) {
- list_del(&timewait_info->list);
- kfree(timewait_info);
- }
-
- class_unregister(&cm_class);
- idr_destroy(&cm.local_id_table);
-}
-
-module_init_order(ib_cm_init, SI_ORDER_SECOND);
-module_exit_order(ib_cm_cleanup, SI_ORDER_FIRST);
-
diff --git a/sys/ofed/drivers/infiniband/core/cm_msgs.h b/sys/ofed/drivers/infiniband/core/cm_msgs.h
index be068f4..8b76f0e 100644
--- a/sys/ofed/drivers/infiniband/core/cm_msgs.h
+++ b/sys/ofed/drivers/infiniband/core/cm_msgs.h
@@ -103,7 +103,7 @@ struct cm_req_msg {
/* local ACK timeout:5, rsvd:3 */
u8 alt_offset139;
- u8 private_data[IB_CM_REQ_PRIVATE_DATA_SIZE];
+ u32 private_data[IB_CM_REQ_PRIVATE_DATA_SIZE / sizeof(u32)];
} __attribute__ ((packed));
@@ -801,7 +801,7 @@ struct cm_sidr_req_msg {
__be16 rsvd;
__be64 service_id;
- u8 private_data[IB_CM_SIDR_REQ_PRIVATE_DATA_SIZE];
+ u32 private_data[IB_CM_SIDR_REQ_PRIVATE_DATA_SIZE / sizeof(u32)];
} __attribute__ ((packed));
struct cm_sidr_rep_msg {
diff --git a/sys/ofed/drivers/infiniband/core/cma.c b/sys/ofed/drivers/infiniband/core/cma.c
deleted file mode 100644
index 40ff109..0000000
--- a/sys/ofed/drivers/infiniband/core/cma.c
+++ /dev/null
@@ -1,3854 +0,0 @@
-/*
- * Copyright (c) 2005 Voltaire Inc. All rights reserved.
- * Copyright (c) 2002-2005, Network Appliance, Inc. All rights reserved.
- * Copyright (c) 1999-2005, Mellanox Technologies, Inc. All rights reserved.
- * Copyright (c) 2005-2006 Intel Corporation. All rights reserved.
- * Copyright (c) 2016 Chelsio Communications. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-#define LINUXKPI_PARAM_PREFIX ibcore_
-
-#include <linux/completion.h>
-#include <linux/in.h>
-#include <linux/in6.h>
-#include <linux/mutex.h>
-#include <linux/random.h>
-#include <linux/idr.h>
-#include <linux/inetdevice.h>
-#include <linux/slab.h>
-#include <linux/module.h>
-#include <linux/string.h>
-#include <net/route.h>
-
-#include <net/tcp.h>
-#include <net/ipv6.h>
-
-#include <netinet6/scope6_var.h>
-#include <netinet6/ip6_var.h>
-
-#include <rdma/rdma_cm.h>
-#include <rdma/rdma_cm_ib.h>
-#include <rdma/ib_cache.h>
-#include <rdma/ib_cm.h>
-#include <rdma/ib_sa.h>
-#include <rdma/iw_cm.h>
-
-MODULE_AUTHOR("Sean Hefty");
-MODULE_DESCRIPTION("Generic RDMA CM Agent");
-MODULE_LICENSE("Dual BSD/GPL");
-
-#define CMA_CM_RESPONSE_TIMEOUT 20
-#define CMA_MAX_CM_RETRIES 15
-#define CMA_CM_MRA_SETTING (IB_CM_MRA_FLAG_DELAY | 24)
-#define CMA_IBOE_PACKET_LIFETIME 18
-
-static int cma_response_timeout = CMA_CM_RESPONSE_TIMEOUT;
-module_param_named(cma_response_timeout, cma_response_timeout, int, 0644);
-MODULE_PARM_DESC(cma_response_timeout, "CMA_CM_RESPONSE_TIMEOUT (default=20)");
-
-static int def_prec2sl = 3;
-module_param_named(def_prec2sl, def_prec2sl, int, 0644);
-MODULE_PARM_DESC(def_prec2sl, "Default value for SL priority with RoCE. Valid values 0 - 7");
-
-static int debug_level = 0;
-#define cma_pr(level, priv, format, arg...) \
- printk(level "CMA: %p: %s: " format, ((struct rdma_id_priv *) priv) , __func__, ## arg)
-
-#define cma_dbg(priv, format, arg...) \
- do { if (debug_level) cma_pr(KERN_DEBUG, priv, format, ## arg); } while (0)
-
-#define cma_warn(priv, format, arg...) \
- cma_pr(KERN_WARNING, priv, format, ## arg)
-
-#define CMA_GID_FMT "%2.2x%2.2x:%2.2x%2.2x"
-#define CMA_GID_RAW_ARG(gid) ((u8 *)(gid))[12],\
- ((u8 *)(gid))[13],\
- ((u8 *)(gid))[14],\
- ((u8 *)(gid))[15]
-
-#define CMA_GID_ARG(gid) CMA_GID_RAW_ARG((gid).raw)
-#define cma_debug_path(priv, pfx, p) \
- cma_dbg(priv, pfx "sgid=" CMA_GID_FMT ",dgid=" \
- CMA_GID_FMT "\n", CMA_GID_ARG(p.sgid), \
- CMA_GID_ARG(p.dgid))
-
-#define cma_debug_gid(priv, g) \
- cma_dbg(priv, "gid=" CMA_GID_FMT "\n", CMA_GID_ARG(g)
-
-module_param_named(debug_level, debug_level, int, 0644);
-MODULE_PARM_DESC(debug_level, "debug level default=0");
-
-static void cma_add_one(struct ib_device *device);
-static void cma_remove_one(struct ib_device *device);
-
-static struct ib_client cma_client = {
- .name = "cma",
- .add = cma_add_one,
- .remove = cma_remove_one
-};
-
-static struct ib_sa_client sa_client;
-static struct rdma_addr_client addr_client;
-static LIST_HEAD(dev_list);
-static LIST_HEAD(listen_any_list);
-static DEFINE_MUTEX(lock);
-static struct workqueue_struct *cma_wq;
-static struct workqueue_struct *cma_free_wq;
-static DEFINE_IDR(sdp_ps);
-static DEFINE_IDR(tcp_ps);
-static DEFINE_IDR(udp_ps);
-static DEFINE_IDR(ipoib_ps);
-static DEFINE_IDR(ib_ps);
-
-struct cma_device {
- struct list_head list;
- struct ib_device *device;
- struct completion comp;
- atomic_t refcount;
- struct list_head id_list;
-};
-
-struct rdma_bind_list {
- struct idr *ps;
- struct hlist_head owners;
- unsigned short port;
-};
-
-enum {
- CMA_OPTION_AFONLY,
-};
-
-/*
- * Device removal can occur at anytime, so we need extra handling to
- * serialize notifying the user of device removal with other callbacks.
- * We do this by disabling removal notification while a callback is in process,
- * and reporting it after the callback completes.
- */
-struct rdma_id_private {
- struct rdma_cm_id id;
-
- struct rdma_bind_list *bind_list;
- struct socket *sock;
- struct hlist_node node;
- struct list_head list; /* listen_any_list or cma_device.list */
- struct list_head listen_list; /* per device listens */
- struct cma_device *cma_dev;
- struct list_head mc_list;
-
- int internal_id;
- enum rdma_cm_state state;
- spinlock_t lock;
- spinlock_t cm_lock;
- struct mutex qp_mutex;
-
- struct completion comp;
- atomic_t refcount;
- struct mutex handler_mutex;
- struct work_struct work; /* garbage coll */
-
- int backlog;
- int timeout_ms;
- struct ib_sa_query *query;
- int query_id;
- union {
- struct ib_cm_id *ib;
- struct iw_cm_id *iw;
- } cm_id;
-
- u32 seq_num;
- u32 qkey;
- u32 qp_num;
- pid_t owner;
- u32 options;
- u8 srq;
- u8 tos;
- u8 reuseaddr;
- u8 afonly;
- int qp_timeout;
- /* cache for mc record params */
- struct ib_sa_mcmember_rec rec;
- int is_valid_rec;
- int unify_ps_tcp;
-};
-
-struct cma_multicast {
- struct rdma_id_private *id_priv;
- union {
- struct ib_sa_multicast *ib;
- } multicast;
- struct list_head list;
- void *context;
- struct sockaddr_storage addr;
- struct kref mcref;
-};
-
-struct cma_work {
- struct work_struct work;
- struct rdma_id_private *id;
- enum rdma_cm_state old_state;
- enum rdma_cm_state new_state;
- struct rdma_cm_event event;
-};
-
-struct cma_ndev_work {
- struct work_struct work;
- struct rdma_id_private *id;
- struct rdma_cm_event event;
-};
-
-struct iboe_mcast_work {
- struct work_struct work;
- struct rdma_id_private *id;
- struct cma_multicast *mc;
-};
-
-union cma_ip_addr {
- struct in6_addr ip6;
- struct {
- __be32 pad[3];
- __be32 addr;
- } ip4;
-};
-
-struct cma_hdr {
- u8 cma_version;
- u8 ip_version; /* IP version: 7:4 */
- __be16 port;
- union cma_ip_addr src_addr;
- union cma_ip_addr dst_addr;
-};
-
-struct sdp_hh {
- u8 bsdh[16];
- u8 sdp_version; /* Major version: 7:4 */
- u8 ip_version; /* IP version: 7:4 */
- u8 sdp_specific1[10];
- __be16 port;
- __be16 sdp_specific2;
- union cma_ip_addr src_addr;
- union cma_ip_addr dst_addr;
-};
-
-struct sdp_hah {
- u8 bsdh[16];
- u8 sdp_version;
-};
-
-#define CMA_VERSION 0x00
-#define SDP_MAJ_VERSION 0x2
-
-static int cma_comp(struct rdma_id_private *id_priv, enum rdma_cm_state comp)
-{
- unsigned long flags;
- int ret;
-
- spin_lock_irqsave(&id_priv->lock, flags);
- ret = (id_priv->state == comp);
- spin_unlock_irqrestore(&id_priv->lock, flags);
- return ret;
-}
-
-static int cma_comp_exch(struct rdma_id_private *id_priv,
- enum rdma_cm_state comp, enum rdma_cm_state exch)
-{
- unsigned long flags;
- int ret;
-
- spin_lock_irqsave(&id_priv->lock, flags);
- if ((ret = (id_priv->state == comp)))
- id_priv->state = exch;
- spin_unlock_irqrestore(&id_priv->lock, flags);
- return ret;
-}
-
-static enum rdma_cm_state cma_exch(struct rdma_id_private *id_priv,
- enum rdma_cm_state exch)
-{
- unsigned long flags;
- enum rdma_cm_state old;
-
- spin_lock_irqsave(&id_priv->lock, flags);
- old = id_priv->state;
- id_priv->state = exch;
- spin_unlock_irqrestore(&id_priv->lock, flags);
- return old;
-}
-
-static inline u8 cma_get_ip_ver(struct cma_hdr *hdr)
-{
- return hdr->ip_version >> 4;
-}
-
-static inline void cma_set_ip_ver(struct cma_hdr *hdr, u8 ip_ver)
-{
- hdr->ip_version = (ip_ver << 4) | (hdr->ip_version & 0xF);
-}
-
-static inline u8 sdp_get_majv(u8 sdp_version)
-{
- return sdp_version >> 4;
-}
-
-static inline u8 sdp_get_ip_ver(struct sdp_hh *hh)
-{
- return hh->ip_version >> 4;
-}
-
-static inline void sdp_set_ip_ver(struct sdp_hh *hh, u8 ip_ver)
-{
- hh->ip_version = (ip_ver << 4) | (hh->ip_version & 0xF);
-}
-
-static void cma_attach_to_dev(struct rdma_id_private *id_priv,
- struct cma_device *cma_dev)
-{
- atomic_inc(&cma_dev->refcount);
- id_priv->cma_dev = cma_dev;
- id_priv->id.device = cma_dev->device;
- id_priv->id.route.addr.dev_addr.transport =
- rdma_node_get_transport(cma_dev->device->node_type);
- list_add_tail(&id_priv->list, &cma_dev->id_list);
-}
-
-static inline void cma_deref_dev(struct cma_device *cma_dev)
-{
- if (atomic_dec_and_test(&cma_dev->refcount))
- complete(&cma_dev->comp);
-}
-
-static inline void release_mc(struct kref *kref)
-{
- struct cma_multicast *mc = container_of(kref, struct cma_multicast, mcref);
-
- kfree(mc->multicast.ib);
- kfree(mc);
-}
-
-static void cma_release_dev(struct rdma_id_private *id_priv)
-{
- mutex_lock(&lock);
- list_del(&id_priv->list);
- cma_deref_dev(id_priv->cma_dev);
- id_priv->cma_dev = NULL;
- mutex_unlock(&lock);
-}
-
-static int cma_set_qkey(struct rdma_id_private *id_priv)
-{
- struct ib_sa_mcmember_rec rec;
- int ret = 0;
-
- if (id_priv->qkey)
- return 0;
-
- switch (id_priv->id.ps) {
- case RDMA_PS_UDP:
- id_priv->qkey = RDMA_UDP_QKEY;
- break;
- case RDMA_PS_IPOIB:
- ib_addr_get_mgid(&id_priv->id.route.addr.dev_addr, &rec.mgid);
- ret = ib_sa_get_mcmember_rec(id_priv->id.device,
- id_priv->id.port_num, &rec.mgid,
- &rec);
- if (!ret)
- id_priv->qkey = be32_to_cpu(rec.qkey);
- break;
- default:
- break;
- }
- return ret;
-}
-
-static int find_gid_port(struct ib_device *device, union ib_gid *gid, u8 port_num)
-{
- int i;
- int err;
- struct ib_port_attr props;
- union ib_gid tmp;
-
- err = ib_query_port(device, port_num, &props);
- if (err)
- return 1;
-
- for (i = 0; i < props.gid_tbl_len; ++i) {
- err = ib_query_gid(device, port_num, i, &tmp);
- if (err)
- return 1;
- if (!memcmp(&tmp, gid, sizeof tmp))
- return 0;
- }
-
- return -EAGAIN;
-}
-
-int
-rdma_find_cmid_laddr(struct sockaddr_in *local_addr, unsigned short dev_type,
- void **cm_id)
-{
- int ret;
- u8 port;
- int found_dev = 0, found_cmid = 0;
- struct rdma_id_private *id_priv;
- struct rdma_id_private *dev_id_priv;
- struct cma_device *cma_dev;
- struct rdma_dev_addr dev_addr;
- union ib_gid gid;
- enum rdma_link_layer dev_ll = dev_type == ARPHRD_INFINIBAND ?
- IB_LINK_LAYER_INFINIBAND : IB_LINK_LAYER_ETHERNET;
-
- memset(&dev_addr, 0, sizeof(dev_addr));
-
- ret = rdma_translate_ip((struct sockaddr *)local_addr,
- &dev_addr, NULL);
- if (ret)
- goto err;
-
- /* find rdma device based on MAC address/gid */
- mutex_lock(&lock);
-
- memcpy(&gid, dev_addr.src_dev_addr +
- rdma_addr_gid_offset(&dev_addr), sizeof(gid));
-
- list_for_each_entry(cma_dev, &dev_list, list)
- for (port = 1; port <= cma_dev->device->phys_port_cnt; ++port)
- if ((rdma_port_get_link_layer(cma_dev->device, port) ==
- dev_ll) &&
- (rdma_node_get_transport(cma_dev->device->node_type) ==
- RDMA_TRANSPORT_IWARP)) {
- ret = find_gid_port(cma_dev->device,
- &gid, port);
- if (!ret) {
- found_dev = 1;
- goto out;
- } else if (ret == 1) {
- mutex_unlock(&lock);
- goto err;
- }
- }
-out:
- mutex_unlock(&lock);
-
- if (!found_dev)
- goto err;
-
- /* Traverse through the list of listening cm_id's to find the
- * desired cm_id based on rdma device & port number.
- */
- list_for_each_entry(id_priv, &listen_any_list, list)
- list_for_each_entry(dev_id_priv, &id_priv->listen_list,
- listen_list)
- if (dev_id_priv->cma_dev == cma_dev)
- if (dev_id_priv->cm_id.iw->local_addr.sin_port
- == local_addr->sin_port) {
- *cm_id = (void *)dev_id_priv->cm_id.iw;
- found_cmid = 1;
- }
- return found_cmid ? 0 : -ENODEV;
-
-err:
- return -ENODEV;
-}
-EXPORT_SYMBOL(rdma_find_cmid_laddr);
-
-static int cma_acquire_dev(struct rdma_id_private *id_priv)
-{
- struct rdma_dev_addr *dev_addr = &id_priv->id.route.addr.dev_addr;
- struct cma_device *cma_dev;
- union ib_gid gid, iboe_gid;
- int ret = -ENODEV;
- u8 port;
- enum rdma_link_layer dev_ll = dev_addr->dev_type == ARPHRD_INFINIBAND ?
- IB_LINK_LAYER_INFINIBAND : IB_LINK_LAYER_ETHERNET;
-
- if (dev_ll != IB_LINK_LAYER_INFINIBAND &&
- id_priv->id.ps == RDMA_PS_IPOIB)
- return -EINVAL;
-
- mutex_lock(&lock);
- rdma_ip2gid((struct sockaddr *)&id_priv->id.route.addr.src_addr,
- &iboe_gid);
-
- memcpy(&gid, dev_addr->src_dev_addr +
- rdma_addr_gid_offset(dev_addr), sizeof gid);
- list_for_each_entry(cma_dev, &dev_list, list) {
- for (port = 1; port <= cma_dev->device->phys_port_cnt; ++port) {
- if (rdma_port_get_link_layer(cma_dev->device, port) == dev_ll) {
- if (rdma_node_get_transport(cma_dev->device->node_type) == RDMA_TRANSPORT_IB &&
- rdma_port_get_link_layer(cma_dev->device, port) == IB_LINK_LAYER_ETHERNET)
- ret = find_gid_port(cma_dev->device, &iboe_gid, port);
- else
- ret = find_gid_port(cma_dev->device, &gid, port);
-
- if (!ret) {
- id_priv->id.port_num = port;
- goto out;
- } else if (ret == 1)
- break;
- }
- }
- }
-
-out:
- if (!ret)
- cma_attach_to_dev(id_priv, cma_dev);
-
- mutex_unlock(&lock);
- return ret;
-}
-
-static void cma_deref_id(struct rdma_id_private *id_priv)
-{
- if (atomic_dec_and_test(&id_priv->refcount))
- complete(&id_priv->comp);
-}
-
-static int cma_disable_callback(struct rdma_id_private *id_priv,
- enum rdma_cm_state state)
-{
- mutex_lock(&id_priv->handler_mutex);
- if (id_priv->state != state) {
- mutex_unlock(&id_priv->handler_mutex);
- return -EINVAL;
- }
- return 0;
-}
-
-struct rdma_cm_id *rdma_create_id(rdma_cm_event_handler event_handler,
- void *context, enum rdma_port_space ps,
- enum ib_qp_type qp_type)
-{
- struct rdma_id_private *id_priv;
-
- id_priv = kzalloc(sizeof *id_priv, GFP_KERNEL);
- if (!id_priv)
- return ERR_PTR(-ENOMEM);
-
- id_priv->owner = curthread->td_proc->p_pid;
- id_priv->state = RDMA_CM_IDLE;
- id_priv->id.context = context;
- id_priv->id.event_handler = event_handler;
- id_priv->id.ps = ps;
- id_priv->id.qp_type = qp_type;
- spin_lock_init(&id_priv->lock);
- spin_lock_init(&id_priv->cm_lock);
- mutex_init(&id_priv->qp_mutex);
- init_completion(&id_priv->comp);
- atomic_set(&id_priv->refcount, 1);
- mutex_init(&id_priv->handler_mutex);
- INIT_LIST_HEAD(&id_priv->listen_list);
- INIT_LIST_HEAD(&id_priv->mc_list);
- get_random_bytes(&id_priv->seq_num, sizeof id_priv->seq_num);
-
- return &id_priv->id;
-}
-EXPORT_SYMBOL(rdma_create_id);
-
-static int cma_init_ud_qp(struct rdma_id_private *id_priv, struct ib_qp *qp)
-{
- struct ib_qp_attr qp_attr;
- int qp_attr_mask, ret;
-
- qp_attr.qp_state = IB_QPS_INIT;
- ret = rdma_init_qp_attr(&id_priv->id, &qp_attr, &qp_attr_mask);
- if (ret)
- return ret;
-
- ret = ib_modify_qp(qp, &qp_attr, qp_attr_mask);
- if (ret)
- return ret;
-
- qp_attr.qp_state = IB_QPS_RTR;
- ret = ib_modify_qp(qp, &qp_attr, IB_QP_STATE);
- if (ret)
- return ret;
-
- qp_attr.qp_state = IB_QPS_RTS;
- qp_attr.sq_psn = 0;
- ret = ib_modify_qp(qp, &qp_attr, IB_QP_STATE | IB_QP_SQ_PSN);
-
- return ret;
-}
-
-static int cma_init_conn_qp(struct rdma_id_private *id_priv, struct ib_qp *qp)
-{
- struct ib_qp_attr qp_attr;
- int qp_attr_mask, ret;
-
- qp_attr.qp_state = IB_QPS_INIT;
- ret = rdma_init_qp_attr(&id_priv->id, &qp_attr, &qp_attr_mask);
- if (ret)
- return ret;
-
- return ib_modify_qp(qp, &qp_attr, qp_attr_mask);
-}
-
-int rdma_create_qp(struct rdma_cm_id *id, struct ib_pd *pd,
- struct ib_qp_init_attr *qp_init_attr)
-{
- struct rdma_id_private *id_priv;
- struct ib_qp *qp;
- int ret;
-
- id_priv = container_of(id, struct rdma_id_private, id);
- if (id->device != pd->device)
- return -EINVAL;
-
- qp = ib_create_qp(pd, qp_init_attr);
- if (IS_ERR(qp))
- return PTR_ERR(qp);
-
- if (id->qp_type == IB_QPT_UD)
- ret = cma_init_ud_qp(id_priv, qp);
- else
- ret = cma_init_conn_qp(id_priv, qp);
- if (ret)
- goto err;
-
- id->qp = qp;
- id_priv->qp_num = qp->qp_num;
- id_priv->srq = (qp->srq != NULL);
- return 0;
-err:
- ib_destroy_qp(qp);
- return ret;
-}
-EXPORT_SYMBOL(rdma_create_qp);
-
-void rdma_destroy_qp(struct rdma_cm_id *id)
-{
- struct rdma_id_private *id_priv;
-
- id_priv = container_of(id, struct rdma_id_private, id);
- mutex_lock(&id_priv->qp_mutex);
- ib_destroy_qp(id_priv->id.qp);
- id_priv->id.qp = NULL;
- mutex_unlock(&id_priv->qp_mutex);
-}
-EXPORT_SYMBOL(rdma_destroy_qp);
-
-static int cma_modify_qp_rtr(struct rdma_id_private *id_priv,
- struct rdma_conn_param *conn_param)
-{
- struct ib_qp_attr qp_attr;
- int qp_attr_mask, ret;
- union ib_gid sgid;
-
- mutex_lock(&id_priv->qp_mutex);
- if (!id_priv->id.qp) {
- ret = 0;
- goto out;
- }
-
- /* Need to update QP attributes from default values. */
- qp_attr.qp_state = IB_QPS_INIT;
- ret = rdma_init_qp_attr(&id_priv->id, &qp_attr, &qp_attr_mask);
- if (ret)
- goto out;
-
- ret = ib_modify_qp(id_priv->id.qp, &qp_attr, qp_attr_mask);
- if (ret)
- goto out;
-
- qp_attr.qp_state = IB_QPS_RTR;
- ret = rdma_init_qp_attr(&id_priv->id, &qp_attr, &qp_attr_mask);
- if (ret)
- goto out;
- ret = ib_query_gid(id_priv->id.device, id_priv->id.port_num,
- qp_attr.ah_attr.grh.sgid_index, &sgid);
- if (ret)
- goto out;
-
- if (rdma_node_get_transport(id_priv->cma_dev->device->node_type)
- == RDMA_TRANSPORT_IB &&
- rdma_port_get_link_layer(id_priv->id.device, id_priv->id.port_num)
- == IB_LINK_LAYER_ETHERNET) {
- ret = rdma_addr_find_smac_by_sgid(&sgid, qp_attr.smac, NULL);
- if (ret)
- goto out;
- }
-
- if (conn_param)
- qp_attr.max_dest_rd_atomic = conn_param->responder_resources;
- ret = ib_modify_qp(id_priv->id.qp, &qp_attr, qp_attr_mask);
-out:
- mutex_unlock(&id_priv->qp_mutex);
- return ret;
-}
-
-static int cma_modify_qp_rts(struct rdma_id_private *id_priv,
- struct rdma_conn_param *conn_param)
-{
- struct ib_qp_attr qp_attr;
- int qp_attr_mask, ret;
-
- mutex_lock(&id_priv->qp_mutex);
- if (!id_priv->id.qp) {
- ret = 0;
- goto out;
- }
-
- qp_attr.qp_state = IB_QPS_RTS;
- ret = rdma_init_qp_attr(&id_priv->id, &qp_attr, &qp_attr_mask);
- if (ret)
- goto out;
-
- if (conn_param)
- qp_attr.max_rd_atomic = conn_param->initiator_depth;
-
- if (id_priv->qp_timeout && id_priv->id.qp->qp_type == IB_QPT_RC) {
- qp_attr.timeout = id_priv->qp_timeout;
- qp_attr_mask |= IB_QP_TIMEOUT;
- }
-
- ret = ib_modify_qp(id_priv->id.qp, &qp_attr, qp_attr_mask);
-out:
- mutex_unlock(&id_priv->qp_mutex);
- return ret;
-}
-
-static int cma_modify_qp_err(struct rdma_id_private *id_priv)
-{
- struct ib_qp_attr qp_attr;
- int ret;
-
- mutex_lock(&id_priv->qp_mutex);
- if (!id_priv->id.qp) {
- ret = 0;
- goto out;
- }
-
- qp_attr.qp_state = IB_QPS_ERR;
- ret = ib_modify_qp(id_priv->id.qp, &qp_attr, IB_QP_STATE);
-out:
- mutex_unlock(&id_priv->qp_mutex);
- return ret;
-}
-
-static int cma_ib_init_qp_attr(struct rdma_id_private *id_priv,
- struct ib_qp_attr *qp_attr, int *qp_attr_mask)
-{
- struct rdma_dev_addr *dev_addr = &id_priv->id.route.addr.dev_addr;
- int ret;
- u16 pkey;
-
- if (rdma_port_get_link_layer(id_priv->id.device, id_priv->id.port_num) ==
- IB_LINK_LAYER_INFINIBAND)
- pkey = ib_addr_get_pkey(dev_addr);
- else
- pkey = 0xffff;
-
- ret = ib_find_cached_pkey(id_priv->id.device, id_priv->id.port_num,
- pkey, &qp_attr->pkey_index);
- if (ret)
- return ret;
-
- qp_attr->port_num = id_priv->id.port_num;
- *qp_attr_mask = IB_QP_STATE | IB_QP_PKEY_INDEX | IB_QP_PORT;
-
- if (id_priv->id.qp_type == IB_QPT_UD) {
- ret = cma_set_qkey(id_priv);
- if (ret)
- return ret;
-
- qp_attr->qkey = id_priv->qkey;
- *qp_attr_mask |= IB_QP_QKEY;
- } else {
- qp_attr->qp_access_flags = 0;
- *qp_attr_mask |= IB_QP_ACCESS_FLAGS;
- }
- return 0;
-}
-
-int rdma_init_qp_attr(struct rdma_cm_id *id, struct ib_qp_attr *qp_attr,
- int *qp_attr_mask)
-{
- struct rdma_id_private *id_priv;
- int ret = 0;
-
- id_priv = container_of(id, struct rdma_id_private, id);
- if (rdma_cap_ib_cm(id->device, id->port_num)) {
- if (!id_priv->cm_id.ib || (id_priv->id.qp_type == IB_QPT_UD))
- ret = cma_ib_init_qp_attr(id_priv, qp_attr, qp_attr_mask);
- else
- ret = ib_cm_init_qp_attr(id_priv->cm_id.ib, qp_attr,
- qp_attr_mask);
-
- if (qp_attr->qp_state == IB_QPS_RTR)
- qp_attr->rq_psn = id_priv->seq_num;
- } else if (rdma_cap_iw_cm(id->device, id->port_num)) {
- if (!id_priv->cm_id.iw) {
- qp_attr->qp_access_flags = 0;
- *qp_attr_mask = IB_QP_STATE | IB_QP_ACCESS_FLAGS;
- } else
- ret = iw_cm_init_qp_attr(id_priv->cm_id.iw, qp_attr,
- qp_attr_mask);
- } else
- ret = -ENOSYS;
-
- return ret;
-}
-EXPORT_SYMBOL(rdma_init_qp_attr);
-
-static inline int cma_zero_addr(struct sockaddr *addr)
-{
- struct in6_addr *ip6;
-
- if (addr->sa_family == AF_INET)
- return ipv4_is_zeronet(
- ((struct sockaddr_in *)addr)->sin_addr.s_addr);
- else {
- ip6 = &((struct sockaddr_in6 *) addr)->sin6_addr;
- return (ip6->s6_addr32[0] | ip6->s6_addr32[1] |
- ip6->s6_addr32[2] | ip6->s6_addr32[3]) == 0;
- }
-}
-
-static inline int cma_loopback_addr(struct sockaddr *addr)
-{
- if (addr->sa_family == AF_INET)
- return ipv4_is_loopback(
- ((struct sockaddr_in *) addr)->sin_addr.s_addr);
- else
- return ipv6_addr_loopback(
- &((struct sockaddr_in6 *) addr)->sin6_addr);
-}
-
-static inline int cma_any_addr(struct sockaddr *addr)
-{
- return cma_zero_addr(addr) || cma_loopback_addr(addr);
-}
-int
-rdma_cma_any_addr(struct sockaddr *addr)
-{
- return cma_any_addr(addr);
-}
-EXPORT_SYMBOL(rdma_cma_any_addr);
-
-static int cma_addr_cmp(struct sockaddr *src, struct sockaddr *dst)
-{
- if (src->sa_family != dst->sa_family)
- return -1;
-
- switch (src->sa_family) {
- case AF_INET:
- return ((struct sockaddr_in *) src)->sin_addr.s_addr !=
- ((struct sockaddr_in *) dst)->sin_addr.s_addr;
- default:
- return ipv6_addr_cmp(&((struct sockaddr_in6 *) src)->sin6_addr,
- &((struct sockaddr_in6 *) dst)->sin6_addr);
- }
-}
-
-static inline __be16 cma_port(struct sockaddr *addr)
-{
- if (addr->sa_family == AF_INET)
- return ((struct sockaddr_in *) addr)->sin_port;
- else
- return ((struct sockaddr_in6 *) addr)->sin6_port;
-}
-
-static inline int cma_any_port(struct sockaddr *addr)
-{
- return !cma_port(addr);
-}
-
-static int cma_get_net_info(void *hdr, enum rdma_port_space ps,
- u8 *ip_ver, __be16 *port,
- union cma_ip_addr **src, union cma_ip_addr **dst)
-{
- switch (ps) {
- case RDMA_PS_SDP:
- if (sdp_get_majv(((struct sdp_hh *) hdr)->sdp_version) !=
- SDP_MAJ_VERSION)
- return -EINVAL;
-
- *ip_ver = sdp_get_ip_ver(hdr);
- *port = ((struct sdp_hh *) hdr)->port;
- *src = &((struct sdp_hh *) hdr)->src_addr;
- *dst = &((struct sdp_hh *) hdr)->dst_addr;
- break;
- default:
- if (((struct cma_hdr *) hdr)->cma_version != CMA_VERSION)
- return -EINVAL;
-
- *ip_ver = cma_get_ip_ver(hdr);
- *port = ((struct cma_hdr *) hdr)->port;
- *src = &((struct cma_hdr *) hdr)->src_addr;
- *dst = &((struct cma_hdr *) hdr)->dst_addr;
- break;
- }
-
- if (*ip_ver != 4 && *ip_ver != 6)
- return -EINVAL;
- return 0;
-}
-
-static void cma_ip6_clear_scope_id(struct in6_addr *addr)
-{
- /* make sure link local scope ID gets zeroed */
- if (IN6_IS_SCOPE_LINKLOCAL(addr) ||
- IN6_IS_ADDR_MC_INTFACELOCAL(addr)) {
- /* use byte-access to be alignment safe */
- addr->s6_addr[2] = 0;
- addr->s6_addr[3] = 0;
- }
-}
-
-static void cma_save_net_info(struct rdma_addr *addr,
- struct rdma_addr *listen_addr,
- u8 ip_ver, __be16 port,
- union cma_ip_addr *src, union cma_ip_addr *dst)
-{
- struct sockaddr_in *listen4, *ip4;
- struct sockaddr_in6 *listen6, *ip6;
-
- switch (ip_ver) {
- case 4:
- listen4 = (struct sockaddr_in *) &listen_addr->src_addr;
- ip4 = (struct sockaddr_in *) &addr->src_addr;
- ip4->sin_family = listen4->sin_family;
- ip4->sin_addr.s_addr = dst->ip4.addr;
- ip4->sin_port = listen4->sin_port;
- ip4->sin_len = sizeof(struct sockaddr_in);
- memset(ip4->sin_zero, 0, sizeof(ip4->sin_zero));
-
- ip4 = (struct sockaddr_in *) &addr->dst_addr;
- ip4->sin_family = listen4->sin_family;
- ip4->sin_addr.s_addr = src->ip4.addr;
- ip4->sin_port = port;
- ip4->sin_len = sizeof(struct sockaddr_in);
- memset(ip4->sin_zero, 0, sizeof(ip4->sin_zero));
- break;
- case 6:
- listen6 = (struct sockaddr_in6 *) &listen_addr->src_addr;
- ip6 = (struct sockaddr_in6 *) &addr->src_addr;
- ip6->sin6_family = listen6->sin6_family;
- ip6->sin6_addr = dst->ip6;
- ip6->sin6_port = listen6->sin6_port;
- ip6->sin6_len = sizeof(struct sockaddr_in6);
- ip6->sin6_scope_id = listen6->sin6_scope_id;
- cma_ip6_clear_scope_id(&ip6->sin6_addr);
-
- ip6 = (struct sockaddr_in6 *) &addr->dst_addr;
- ip6->sin6_family = listen6->sin6_family;
- ip6->sin6_addr = src->ip6;
- ip6->sin6_port = port;
- ip6->sin6_len = sizeof(struct sockaddr_in6);
- ip6->sin6_scope_id = listen6->sin6_scope_id;
- cma_ip6_clear_scope_id(&ip6->sin6_addr);
- break;
- default:
- break;
- }
-}
-
-static inline int cma_user_data_offset(enum rdma_port_space ps)
-{
- switch (ps) {
- case RDMA_PS_SDP:
- return 0;
- default:
- return sizeof(struct cma_hdr);
- }
-}
-
-static void cma_cancel_route(struct rdma_id_private *id_priv)
-{
- switch (rdma_port_get_link_layer(id_priv->id.device, id_priv->id.port_num)) {
- case IB_LINK_LAYER_INFINIBAND:
- if (id_priv->query)
- ib_sa_cancel_query(id_priv->query_id, id_priv->query);
- break;
- default:
- break;
- }
-}
-
-static void cma_cancel_listens(struct rdma_id_private *id_priv)
-{
- struct rdma_id_private *dev_id_priv;
-
- /*
- * Remove from listen_any_list to prevent added devices from spawning
- * additional listen requests.
- */
- mutex_lock(&lock);
- list_del(&id_priv->list);
-
- while (!list_empty(&id_priv->listen_list)) {
- dev_id_priv = list_entry(id_priv->listen_list.next,
- struct rdma_id_private, listen_list);
- /* sync with device removal to avoid duplicate destruction */
- list_del_init(&dev_id_priv->list);
- list_del(&dev_id_priv->listen_list);
- mutex_unlock(&lock);
-
- rdma_destroy_id(&dev_id_priv->id);
- mutex_lock(&lock);
- }
- mutex_unlock(&lock);
-}
-
-static void cma_cancel_operation(struct rdma_id_private *id_priv,
- enum rdma_cm_state state)
-{
- switch (state) {
- case RDMA_CM_ADDR_QUERY:
- rdma_addr_cancel(&id_priv->id.route.addr.dev_addr);
- break;
- case RDMA_CM_ROUTE_QUERY:
- cma_cancel_route(id_priv);
- break;
- case RDMA_CM_LISTEN:
- if (cma_any_addr((struct sockaddr *) &id_priv->id.route.addr.src_addr)
- && !id_priv->cma_dev)
- cma_cancel_listens(id_priv);
- break;
- default:
- break;
- }
-}
-
-static void cma_release_port(struct rdma_id_private *id_priv)
-{
- struct rdma_bind_list *bind_list;
-
- mutex_lock(&lock);
- bind_list = id_priv->bind_list;
- if (!bind_list) {
- mutex_unlock(&lock);
- return;
- }
- hlist_del(&id_priv->node);
- id_priv->bind_list = NULL;
- if (hlist_empty(&bind_list->owners)) {
- idr_remove(bind_list->ps, bind_list->port);
- kfree(bind_list);
- }
- mutex_unlock(&lock);
-}
-
-static void cma_leave_mc_groups(struct rdma_id_private *id_priv)
-{
- struct cma_multicast *mc;
-
- while (!list_empty(&id_priv->mc_list)) {
- mc = container_of(id_priv->mc_list.next,
- struct cma_multicast, list);
- list_del(&mc->list);
- switch (rdma_port_get_link_layer(id_priv->cma_dev->device, id_priv->id.port_num)) {
- case IB_LINK_LAYER_INFINIBAND:
- ib_sa_free_multicast(mc->multicast.ib);
- kfree(mc);
- break;
- case IB_LINK_LAYER_ETHERNET:
- kref_put(&mc->mcref, release_mc);
- break;
- default:
- break;
- }
- }
-}
-static void __rdma_free(struct work_struct *work)
-{
- struct rdma_id_private *id_priv;
- id_priv = container_of(work, struct rdma_id_private, work);
-
- wait_for_completion(&id_priv->comp);
-
- if (id_priv->internal_id)
- cma_deref_id(id_priv->id.context);
-
- if (id_priv->sock != NULL && !id_priv->internal_id &&
- !id_priv->unify_ps_tcp)
- sock_release(id_priv->sock);
-
- kfree(id_priv->id.route.path_rec);
- kfree(id_priv);
-}
-
-void rdma_destroy_id(struct rdma_cm_id *id)
-{
- struct rdma_id_private *id_priv;
- enum rdma_cm_state state;
- unsigned long flags;
- struct ib_cm_id *ib;
-
- id_priv = container_of(id, struct rdma_id_private, id);
- state = cma_exch(id_priv, RDMA_CM_DESTROYING);
- cma_cancel_operation(id_priv, state);
-
- /*
- * Wait for any active callback to finish. New callbacks will find
- * the id_priv state set to destroying and abort.
- */
- mutex_lock(&id_priv->handler_mutex);
- mutex_unlock(&id_priv->handler_mutex);
-
- if (id_priv->cma_dev) {
- if (rdma_cap_ib_cm(id_priv->id.device, 1)) {
- spin_lock_irqsave(&id_priv->cm_lock, flags);
- if (id_priv->cm_id.ib && !IS_ERR(id_priv->cm_id.ib)) {
- ib = id_priv->cm_id.ib;
- id_priv->cm_id.ib = NULL;
- spin_unlock_irqrestore(&id_priv->cm_lock, flags);
- ib_destroy_cm_id(ib);
- } else
- spin_unlock_irqrestore(&id_priv->cm_lock, flags);
- } else if (rdma_cap_iw_cm(id_priv->id.device, 1)) {
- if (id_priv->cm_id.iw)
- iw_destroy_cm_id(id_priv->cm_id.iw);
- }
- cma_leave_mc_groups(id_priv);
- cma_release_dev(id_priv);
- }
-
- cma_release_port(id_priv);
- cma_deref_id(id_priv);
- INIT_WORK(&id_priv->work, __rdma_free);
- queue_work(cma_free_wq, &id_priv->work);
-}
-EXPORT_SYMBOL(rdma_destroy_id);
-
-static int cma_rep_recv(struct rdma_id_private *id_priv)
-{
- int ret;
-
- ret = cma_modify_qp_rtr(id_priv, NULL);
- if (ret)
- goto reject;
-
- ret = cma_modify_qp_rts(id_priv, NULL);
- if (ret)
- goto reject;
-
- cma_dbg(id_priv, "sending RTU\n");
- ret = ib_send_cm_rtu(id_priv->cm_id.ib, NULL, 0);
- if (ret)
- goto reject;
-
- return 0;
-reject:
- cma_modify_qp_err(id_priv);
- cma_dbg(id_priv, "sending REJ\n");
- ib_send_cm_rej(id_priv->cm_id.ib, IB_CM_REJ_CONSUMER_DEFINED,
- NULL, 0, NULL, 0);
- return ret;
-}
-
-static int cma_verify_rep(struct rdma_id_private *id_priv, void *data)
-{
- if (id_priv->id.ps == RDMA_PS_SDP &&
- sdp_get_majv(((struct sdp_hah *) data)->sdp_version) !=
- SDP_MAJ_VERSION)
- return -EINVAL;
-
- return 0;
-}
-
-static void cma_set_rep_event_data(struct rdma_cm_event *event,
- struct ib_cm_rep_event_param *rep_data,
- void *private_data)
-{
- event->param.conn.private_data = private_data;
- event->param.conn.private_data_len = IB_CM_REP_PRIVATE_DATA_SIZE;
- event->param.conn.responder_resources = rep_data->responder_resources;
- event->param.conn.initiator_depth = rep_data->initiator_depth;
- event->param.conn.flow_control = rep_data->flow_control;
- event->param.conn.rnr_retry_count = rep_data->rnr_retry_count;
- event->param.conn.srq = rep_data->srq;
- event->param.conn.qp_num = rep_data->remote_qpn;
-}
-
-static int cma_ib_handler(struct ib_cm_id *cm_id, struct ib_cm_event *ib_event)
-{
- struct rdma_id_private *id_priv = cm_id->context;
- struct rdma_cm_event event;
- int ret = 0;
-
- if ((ib_event->event != IB_CM_TIMEWAIT_EXIT &&
- cma_disable_callback(id_priv, RDMA_CM_CONNECT)) ||
- (ib_event->event == IB_CM_TIMEWAIT_EXIT &&
- cma_disable_callback(id_priv, RDMA_CM_DISCONNECT)))
- return 0;
- memset(&event, 0, sizeof event);
- switch (ib_event->event) {
- case IB_CM_REQ_ERROR:
- case IB_CM_REP_ERROR:
- event.event = RDMA_CM_EVENT_UNREACHABLE;
- event.status = -ETIMEDOUT;
- break;
- case IB_CM_REP_RECEIVED:
- event.status = cma_verify_rep(id_priv, ib_event->private_data);
- if (event.status)
- event.event = RDMA_CM_EVENT_CONNECT_ERROR;
- else if (id_priv->id.qp && id_priv->id.ps != RDMA_PS_SDP) {
- event.status = cma_rep_recv(id_priv);
- event.event = event.status ? RDMA_CM_EVENT_CONNECT_ERROR :
- RDMA_CM_EVENT_ESTABLISHED;
- } else
- event.event = RDMA_CM_EVENT_CONNECT_RESPONSE;
- cma_set_rep_event_data(&event, &ib_event->param.rep_rcvd,
- ib_event->private_data);
- break;
- case IB_CM_RTU_RECEIVED:
- case IB_CM_USER_ESTABLISHED:
- event.event = RDMA_CM_EVENT_ESTABLISHED;
- break;
- case IB_CM_DREQ_ERROR:
- event.status = -ETIMEDOUT; /* fall through */
- case IB_CM_DREQ_RECEIVED:
- case IB_CM_DREP_RECEIVED:
- if (!cma_comp_exch(id_priv, RDMA_CM_CONNECT,
- RDMA_CM_DISCONNECT))
- goto out;
- event.event = RDMA_CM_EVENT_DISCONNECTED;
- break;
- case IB_CM_TIMEWAIT_EXIT:
- event.event = RDMA_CM_EVENT_TIMEWAIT_EXIT;
- break;
- case IB_CM_MRA_RECEIVED:
- /* ignore event */
- goto out;
- case IB_CM_REJ_RECEIVED:
- cma_modify_qp_err(id_priv);
- event.status = ib_event->param.rej_rcvd.reason;
- event.event = RDMA_CM_EVENT_REJECTED;
- event.param.conn.private_data = ib_event->private_data;
- event.param.conn.private_data_len = IB_CM_REJ_PRIVATE_DATA_SIZE;
- break;
- default:
- printk(KERN_ERR "RDMA CMA: unexpected IB CM event: %d\n",
- ib_event->event);
- goto out;
- }
-
- ret = id_priv->id.event_handler(&id_priv->id, &event);
- if (ret) {
- /* Destroy the CM ID by returning a non-zero value. */
- id_priv->cm_id.ib = NULL;
- cma_exch(id_priv, RDMA_CM_DESTROYING);
- mutex_unlock(&id_priv->handler_mutex);
- rdma_destroy_id(&id_priv->id);
- return ret;
- }
-out:
- mutex_unlock(&id_priv->handler_mutex);
- return ret;
-}
-
-static struct rdma_id_private *cma_new_conn_id(struct rdma_cm_id *listen_id,
- struct ib_cm_event *ib_event)
-{
- struct rdma_id_private *id_priv;
- struct rdma_cm_id *id;
- struct rdma_route *rt;
- union cma_ip_addr *src, *dst;
- __be16 port;
- u8 ip_ver;
- int ret;
-
- if (cma_get_net_info(ib_event->private_data, listen_id->ps,
- &ip_ver, &port, &src, &dst))
- return NULL;
-
- id = rdma_create_id(listen_id->event_handler, listen_id->context,
- listen_id->ps, ib_event->param.req_rcvd.qp_type);
- if (IS_ERR(id))
- return NULL;
-
- cma_save_net_info(&id->route.addr, &listen_id->route.addr,
- ip_ver, port, src, dst);
-
- rt = &id->route;
- rt->num_paths = ib_event->param.req_rcvd.alternate_path ? 2 : 1;
- rt->path_rec = kmalloc(sizeof *rt->path_rec * rt->num_paths,
- GFP_KERNEL);
- if (!rt->path_rec)
- goto err;
-
- rt->path_rec[0] = *ib_event->param.req_rcvd.primary_path;
- if (rt->num_paths == 2)
- rt->path_rec[1] = *ib_event->param.req_rcvd.alternate_path;
-
- if (cma_any_addr((struct sockaddr *) &rt->addr.src_addr)) {
- rt->addr.dev_addr.dev_type = ARPHRD_INFINIBAND;
- rdma_addr_set_sgid(&rt->addr.dev_addr, &rt->path_rec[0].sgid);
- ib_addr_set_pkey(&rt->addr.dev_addr, be16_to_cpu(rt->path_rec[0].pkey));
- } else {
- ret = rdma_translate_ip((struct sockaddr *) &rt->addr.src_addr,
- &rt->addr.dev_addr, NULL);
- if (ret)
- goto err;
- }
- rdma_addr_set_dgid(&rt->addr.dev_addr, &rt->path_rec[0].dgid);
-
- id_priv = container_of(id, struct rdma_id_private, id);
- id_priv->state = RDMA_CM_CONNECT;
- return id_priv;
-
-err:
- rdma_destroy_id(id);
- return NULL;
-}
-
-static struct rdma_id_private *cma_new_udp_id(struct rdma_cm_id *listen_id,
- struct ib_cm_event *ib_event)
-{
- struct rdma_id_private *id_priv;
- struct rdma_cm_id *id;
- union cma_ip_addr *src, *dst;
- __be16 port;
- u8 ip_ver;
- int ret;
-
- id = rdma_create_id(listen_id->event_handler, listen_id->context,
- listen_id->ps, IB_QPT_UD);
- if (IS_ERR(id))
- return NULL;
-
-
- if (cma_get_net_info(ib_event->private_data, listen_id->ps,
- &ip_ver, &port, &src, &dst))
- goto err;
-
- cma_save_net_info(&id->route.addr, &listen_id->route.addr,
- ip_ver, port, src, dst);
-
- if (!cma_any_addr((struct sockaddr *) &id->route.addr.src_addr)) {
- ret = rdma_translate_ip((struct sockaddr *) &id->route.addr.src_addr,
- &id->route.addr.dev_addr, NULL);
- if (ret)
- goto err;
- }
-
- id_priv = container_of(id, struct rdma_id_private, id);
- id_priv->state = RDMA_CM_CONNECT;
- return id_priv;
-err:
- rdma_destroy_id(id);
- return NULL;
-}
-
-static void cma_set_req_event_data(struct rdma_cm_event *event,
- struct ib_cm_req_event_param *req_data,
- void *private_data, int offset)
-{
- event->param.conn.private_data = private_data + offset;
- event->param.conn.private_data_len = IB_CM_REQ_PRIVATE_DATA_SIZE - offset;
- event->param.conn.responder_resources = req_data->responder_resources;
- event->param.conn.initiator_depth = req_data->initiator_depth;
- event->param.conn.flow_control = req_data->flow_control;
- event->param.conn.retry_count = req_data->retry_count;
- event->param.conn.rnr_retry_count = req_data->rnr_retry_count;
- event->param.conn.srq = req_data->srq;
- event->param.conn.qp_num = req_data->remote_qpn;
-}
-
-static int cma_check_req_qp_type(struct rdma_cm_id *id, struct ib_cm_event *ib_event)
-{
- return (((ib_event->event == IB_CM_REQ_RECEIVED) &&
- (ib_event->param.req_rcvd.qp_type == id->qp_type)) ||
- ((ib_event->event == IB_CM_SIDR_REQ_RECEIVED) &&
- (id->qp_type == IB_QPT_UD)) ||
- (!id->qp_type));
-}
-
-static int cma_req_handler(struct ib_cm_id *cm_id, struct ib_cm_event *ib_event)
-{
- struct rdma_id_private *listen_id, *conn_id;
- struct rdma_cm_event event;
- int offset, ret;
- u8 smac[ETH_ALEN];
- u8 alt_smac[ETH_ALEN];
- u8 *psmac = smac;
- u8 *palt_smac = alt_smac;
- int is_iboe = ((rdma_node_get_transport(cm_id->device->node_type) ==
- RDMA_TRANSPORT_IB) &&
- (rdma_port_get_link_layer(cm_id->device,
- ib_event->param.req_rcvd.port) ==
- IB_LINK_LAYER_ETHERNET));
- int is_sidr = 0;
-
- listen_id = cm_id->context;
- if (!cma_check_req_qp_type(&listen_id->id, ib_event))
- return -EINVAL;
-
- if (cma_disable_callback(listen_id, RDMA_CM_LISTEN))
- return -ECONNABORTED;
-
- memset(&event, 0, sizeof event);
- offset = cma_user_data_offset(listen_id->id.ps);
- event.event = RDMA_CM_EVENT_CONNECT_REQUEST;
- if (ib_event->event == IB_CM_SIDR_REQ_RECEIVED) {
- is_sidr = 1;
- conn_id = cma_new_udp_id(&listen_id->id, ib_event);
- event.param.ud.private_data = ib_event->private_data + offset;
- event.param.ud.private_data_len =
- IB_CM_SIDR_REQ_PRIVATE_DATA_SIZE - offset;
- } else {
- conn_id = cma_new_conn_id(&listen_id->id, ib_event);
- cma_set_req_event_data(&event, &ib_event->param.req_rcvd,
- ib_event->private_data, offset);
- }
- if (!conn_id) {
- ret = -ENOMEM;
- goto err1;
- }
-
- mutex_lock_nested(&conn_id->handler_mutex, SINGLE_DEPTH_NESTING);
- ret = cma_acquire_dev(conn_id);
- if (ret)
- goto err2;
-
- conn_id->cm_id.ib = cm_id;
- cm_id->context = conn_id;
- cm_id->cm_handler = cma_ib_handler;
-
- /*
- * Protect against the user destroying conn_id from another thread
- * until we're done accessing it.
- */
- atomic_inc(&conn_id->refcount);
- ret = conn_id->id.event_handler(&conn_id->id, &event);
- if (ret)
- goto err3;
-
- if (is_iboe && !is_sidr) {
- if (ib_event->param.req_rcvd.primary_path != NULL)
- rdma_addr_find_smac_by_sgid(
- &ib_event->param.req_rcvd.primary_path->sgid,
- psmac, NULL);
- else
- psmac = NULL;
- if (ib_event->param.req_rcvd.alternate_path != NULL)
- rdma_addr_find_smac_by_sgid(
- &ib_event->param.req_rcvd.alternate_path->sgid,
- palt_smac, NULL);
- else
- palt_smac = NULL;
- }
- /*
- * Acquire mutex to prevent user executing rdma_destroy_id()
- * while we're accessing the cm_id.
- */
- mutex_lock(&lock);
- if (is_iboe && !is_sidr)
- ib_update_cm_av(cm_id, psmac, palt_smac);
- if (cma_comp(conn_id, RDMA_CM_CONNECT) && (conn_id->id.qp_type != IB_QPT_UD)) {
- cma_dbg(container_of(&conn_id->id, struct rdma_id_private, id), "sending MRA\n");
- ib_send_cm_mra(cm_id, CMA_CM_MRA_SETTING, NULL, 0);
- }
- mutex_unlock(&lock);
- mutex_unlock(&conn_id->handler_mutex);
- mutex_unlock(&listen_id->handler_mutex);
- cma_deref_id(conn_id);
- return 0;
-
-err3:
- cma_deref_id(conn_id);
- /* Destroy the CM ID by returning a non-zero value. */
- conn_id->cm_id.ib = NULL;
-err2:
- cma_exch(conn_id, RDMA_CM_DESTROYING);
- mutex_unlock(&conn_id->handler_mutex);
-err1:
- mutex_unlock(&listen_id->handler_mutex);
- if (conn_id)
- rdma_destroy_id(&conn_id->id);
- return ret;
-}
-
-static __be64 cma_get_service_id(enum rdma_port_space ps, struct sockaddr *addr)
-{
- return cpu_to_be64(((u64)ps << 16) + be16_to_cpu(cma_port(addr)));
-}
-
-static void cma_set_compare_data(enum rdma_port_space ps, struct sockaddr *addr,
- struct ib_cm_compare_data *compare)
-{
- struct cma_hdr *cma_data, *cma_mask;
- struct sdp_hh *sdp_data, *sdp_mask;
- __be32 ip4_addr;
- struct in6_addr ip6_addr;
-
- memset(compare, 0, sizeof *compare);
- cma_data = (void *) compare->data;
- cma_mask = (void *) compare->mask;
- sdp_data = (void *) compare->data;
- sdp_mask = (void *) compare->mask;
-
- switch (addr->sa_family) {
- case AF_INET:
- ip4_addr = ((struct sockaddr_in *) addr)->sin_addr.s_addr;
- if (ps == RDMA_PS_SDP) {
- sdp_set_ip_ver(sdp_data, 4);
- sdp_set_ip_ver(sdp_mask, 0xF);
- if (!cma_any_addr(addr)) {
- sdp_data->dst_addr.ip4.addr = ip4_addr;
- sdp_mask->dst_addr.ip4.addr = htonl(~0);
- }
- } else {
- cma_set_ip_ver(cma_data, 4);
- cma_set_ip_ver(cma_mask, 0xF);
- if (!cma_any_addr(addr)) {
- cma_data->dst_addr.ip4.addr = ip4_addr;
- cma_mask->dst_addr.ip4.addr = htonl(~0);
- }
- }
- break;
- case AF_INET6:
- ip6_addr = ((struct sockaddr_in6 *) addr)->sin6_addr;
- cma_ip6_clear_scope_id(&ip6_addr);
- if (ps == RDMA_PS_SDP) {
- sdp_set_ip_ver(sdp_data, 6);
- sdp_set_ip_ver(sdp_mask, 0xF);
- if (!cma_any_addr(addr)) {
- sdp_data->dst_addr.ip6 = ip6_addr;
- memset(&sdp_mask->dst_addr.ip6, 0xFF,
- sizeof(sdp_mask->dst_addr.ip6));
- }
- } else {
- cma_set_ip_ver(cma_data, 6);
- cma_set_ip_ver(cma_mask, 0xF);
- if (!cma_any_addr(addr)) {
- cma_data->dst_addr.ip6 = ip6_addr;
- memset(&cma_mask->dst_addr.ip6, 0xFF,
- sizeof(cma_mask->dst_addr.ip6));
- }
- }
- break;
- default:
- break;
- }
-}
-
-static int cma_iw_handler(struct iw_cm_id *iw_id, struct iw_cm_event *iw_event)
-{
- struct rdma_id_private *id_priv = iw_id->context;
- struct rdma_cm_event event;
- struct sockaddr_in *sin;
- int ret = 0;
-
- if (cma_disable_callback(id_priv, RDMA_CM_CONNECT))
- return 0;
-
- memset(&event, 0, sizeof event);
- switch (iw_event->event) {
- case IW_CM_EVENT_CLOSE:
- event.event = RDMA_CM_EVENT_DISCONNECTED;
- break;
- case IW_CM_EVENT_CONNECT_REPLY:
- sin = (struct sockaddr_in *) &id_priv->id.route.addr.src_addr;
- *sin = iw_event->local_addr;
- sin = (struct sockaddr_in *) &id_priv->id.route.addr.dst_addr;
- *sin = iw_event->remote_addr;
- switch ((int)iw_event->status) {
- case 0:
- event.event = RDMA_CM_EVENT_ESTABLISHED;
- event.param.conn.initiator_depth = iw_event->ird;
- event.param.conn.responder_resources = iw_event->ord;
- break;
- case -ECONNRESET:
- case -ECONNREFUSED:
- event.event = RDMA_CM_EVENT_REJECTED;
- break;
- case -ETIMEDOUT:
- event.event = RDMA_CM_EVENT_UNREACHABLE;
- break;
- default:
- event.event = RDMA_CM_EVENT_CONNECT_ERROR;
- break;
- }
- break;
- case IW_CM_EVENT_ESTABLISHED:
- event.event = RDMA_CM_EVENT_ESTABLISHED;
- event.param.conn.initiator_depth = iw_event->ird;
- event.param.conn.responder_resources = iw_event->ord;
- break;
- default:
- BUG_ON(1);
- }
-
- event.status = iw_event->status;
- event.param.conn.private_data = iw_event->private_data;
- event.param.conn.private_data_len = iw_event->private_data_len;
- ret = id_priv->id.event_handler(&id_priv->id, &event);
- if (ret) {
- /* Destroy the CM ID by returning a non-zero value. */
- id_priv->cm_id.iw = NULL;
- cma_exch(id_priv, RDMA_CM_DESTROYING);
- mutex_unlock(&id_priv->handler_mutex);
- rdma_destroy_id(&id_priv->id);
- return ret;
- }
-
- mutex_unlock(&id_priv->handler_mutex);
- return ret;
-}
-
-static int iw_conn_req_handler(struct iw_cm_id *cm_id,
- struct iw_cm_event *iw_event)
-{
- struct rdma_cm_id *new_cm_id;
- struct rdma_id_private *listen_id, *conn_id;
- struct sockaddr_in *sin;
- struct net_device *dev = NULL;
- struct rdma_cm_event event;
- int ret;
- struct ib_device_attr attr;
-
- listen_id = cm_id->context;
- if (cma_disable_callback(listen_id, RDMA_CM_LISTEN))
- return -ECONNABORTED;
-
- /* Create a new RDMA id for the new IW CM ID */
- new_cm_id = rdma_create_id(listen_id->id.event_handler,
- listen_id->id.context,
- RDMA_PS_TCP, IB_QPT_RC);
- if (IS_ERR(new_cm_id)) {
- ret = -ENOMEM;
- goto out;
- }
- conn_id = container_of(new_cm_id, struct rdma_id_private, id);
- mutex_lock_nested(&conn_id->handler_mutex, SINGLE_DEPTH_NESTING);
- conn_id->state = RDMA_CM_CONNECT;
-
- dev = ip_dev_find(&init_net, iw_event->local_addr.sin_addr.s_addr);
- if (!dev) {
- ret = -EADDRNOTAVAIL;
- mutex_unlock(&conn_id->handler_mutex);
- rdma_destroy_id(new_cm_id);
- goto out;
- }
- ret = rdma_copy_addr(&conn_id->id.route.addr.dev_addr, dev, NULL);
- if (ret) {
- mutex_unlock(&conn_id->handler_mutex);
- rdma_destroy_id(new_cm_id);
- goto out;
- }
-
- ret = cma_acquire_dev(conn_id);
- if (ret) {
- mutex_unlock(&conn_id->handler_mutex);
- rdma_destroy_id(new_cm_id);
- goto out;
- }
-
- conn_id->cm_id.iw = cm_id;
- cm_id->context = conn_id;
- cm_id->cm_handler = cma_iw_handler;
-
- sin = (struct sockaddr_in *) &new_cm_id->route.addr.src_addr;
- *sin = iw_event->local_addr;
- sin = (struct sockaddr_in *) &new_cm_id->route.addr.dst_addr;
- *sin = iw_event->remote_addr;
-
- ret = ib_query_device(conn_id->id.device, &attr);
- if (ret) {
- mutex_unlock(&conn_id->handler_mutex);
- rdma_destroy_id(new_cm_id);
- goto out;
- }
-
- memset(&event, 0, sizeof event);
- event.event = RDMA_CM_EVENT_CONNECT_REQUEST;
- event.param.conn.private_data = iw_event->private_data;
- event.param.conn.private_data_len = iw_event->private_data_len;
- event.param.conn.initiator_depth = iw_event->ird;
- event.param.conn.responder_resources = iw_event->ord;
-
- /*
- * Protect against the user destroying conn_id from another thread
- * until we're done accessing it.
- */
- atomic_inc(&conn_id->refcount);
- ret = conn_id->id.event_handler(&conn_id->id, &event);
- if (ret) {
- /* User wants to destroy the CM ID */
- conn_id->cm_id.iw = NULL;
- cma_exch(conn_id, RDMA_CM_DESTROYING);
- mutex_unlock(&conn_id->handler_mutex);
- cma_deref_id(conn_id);
- rdma_destroy_id(&conn_id->id);
- goto out;
- }
-
- mutex_unlock(&conn_id->handler_mutex);
- cma_deref_id(conn_id);
-
-out:
- if (dev)
- dev_put(dev);
- mutex_unlock(&listen_id->handler_mutex);
- return ret;
-}
-
-static int cma_ib_listen(struct rdma_id_private *id_priv)
-{
- struct ib_cm_compare_data compare_data;
- struct sockaddr *addr;
- struct ib_cm_id *id;
- __be64 svc_id;
- int ret;
-
- id = ib_create_cm_id(id_priv->id.device, cma_req_handler, id_priv);
- if (IS_ERR(id))
- return PTR_ERR(id);
-
- id_priv->cm_id.ib = id;
-
- addr = (struct sockaddr *) &id_priv->id.route.addr.src_addr;
- svc_id = cma_get_service_id(id_priv->id.ps, addr);
- if (cma_any_addr(addr) && !id_priv->afonly)
- ret = ib_cm_listen(id_priv->cm_id.ib, svc_id, 0, NULL);
- else {
- cma_set_compare_data(id_priv->id.ps, addr, &compare_data);
- ret = ib_cm_listen(id_priv->cm_id.ib, svc_id, 0, &compare_data);
- }
-
- if (ret) {
- ib_destroy_cm_id(id_priv->cm_id.ib);
- id_priv->cm_id.ib = NULL;
- }
-
- return ret;
-}
-
-static int cma_iw_listen(struct rdma_id_private *id_priv, int backlog)
-{
- int ret;
- struct sockaddr_in *sin;
- struct iw_cm_id *id;
-
- id = iw_create_cm_id(id_priv->id.device,
- id_priv->sock,
- iw_conn_req_handler,
- id_priv);
- if (IS_ERR(id))
- return PTR_ERR(id);
-
- id_priv->cm_id.iw = id;
-
- sin = (struct sockaddr_in *) &id_priv->id.route.addr.src_addr;
- id_priv->cm_id.iw->local_addr = *sin;
-
- ret = iw_cm_listen(id_priv->cm_id.iw, backlog);
-
- if (ret) {
- iw_destroy_cm_id(id_priv->cm_id.iw);
- id_priv->cm_id.iw = NULL;
- }
-
- return ret;
-}
-
-static int cma_listen_handler(struct rdma_cm_id *id,
- struct rdma_cm_event *event)
-{
- struct rdma_id_private *id_priv = id->context;
-
- id->context = id_priv->id.context;
- id->event_handler = id_priv->id.event_handler;
- return id_priv->id.event_handler(id, event);
-}
-
-static void cma_listen_on_dev(struct rdma_id_private *id_priv,
- struct cma_device *cma_dev)
-{
- struct rdma_id_private *dev_id_priv;
- struct rdma_cm_id *id;
- int ret;
-
- id = rdma_create_id(cma_listen_handler, id_priv, id_priv->id.ps,
- id_priv->id.qp_type);
- if (IS_ERR(id))
- return;
-
- dev_id_priv = container_of(id, struct rdma_id_private, id);
-
- dev_id_priv->state = RDMA_CM_ADDR_BOUND;
- dev_id_priv->sock = id_priv->sock;
- memcpy(&id->route.addr.src_addr, &id_priv->id.route.addr.src_addr,
- ip_addr_size((struct sockaddr *) &id_priv->id.route.addr.src_addr));
-
- cma_attach_to_dev(dev_id_priv, cma_dev);
- list_add_tail(&dev_id_priv->listen_list, &id_priv->listen_list);
- atomic_inc(&id_priv->refcount);
- dev_id_priv->internal_id = 1;
- dev_id_priv->afonly = id_priv->afonly;
-
- ret = rdma_listen(id, id_priv->backlog);
- if (ret)
- cma_warn(id_priv, "cma_listen_on_dev, error %d, listening on device %s\n", ret, cma_dev->device->name);
-}
-
-static void cma_listen_on_all(struct rdma_id_private *id_priv)
-{
- struct cma_device *cma_dev;
-
- mutex_lock(&lock);
- list_add_tail(&id_priv->list, &listen_any_list);
- list_for_each_entry(cma_dev, &dev_list, list)
- cma_listen_on_dev(id_priv, cma_dev);
- mutex_unlock(&lock);
-}
-
-void rdma_set_service_type(struct rdma_cm_id *id, int tos)
-{
- struct rdma_id_private *id_priv;
-
- id_priv = container_of(id, struct rdma_id_private, id);
- id_priv->tos = (u8) tos;
-}
-EXPORT_SYMBOL(rdma_set_service_type);
-
-void rdma_set_timeout(struct rdma_cm_id *id, int timeout)
-{
- struct rdma_id_private *id_priv;
-
- id_priv = container_of(id, struct rdma_id_private, id);
- id_priv->qp_timeout = (u8) timeout;
-}
-EXPORT_SYMBOL(rdma_set_timeout);
-
-static void cma_query_handler(int status, struct ib_sa_path_rec *path_rec,
- void *context)
-{
- struct cma_work *work = context;
- struct rdma_route *route;
-
- route = &work->id->id.route;
-
- if (!status) {
- route->num_paths = 1;
- *route->path_rec = *path_rec;
- } else {
- work->old_state = RDMA_CM_ROUTE_QUERY;
- work->new_state = RDMA_CM_ADDR_RESOLVED;
- work->event.event = RDMA_CM_EVENT_ROUTE_ERROR;
- work->event.status = status;
- }
-
- queue_work(cma_wq, &work->work);
-}
-
-static int cma_query_ib_route(struct rdma_id_private *id_priv, int timeout_ms,
- struct cma_work *work)
-{
- struct rdma_addr *addr = &id_priv->id.route.addr;
- struct ib_sa_path_rec path_rec;
- ib_sa_comp_mask comp_mask;
- struct sockaddr_in6 *sin6;
-
- memset(&path_rec, 0, sizeof path_rec);
- rdma_addr_get_sgid(&addr->dev_addr, &path_rec.sgid);
- rdma_addr_get_dgid(&addr->dev_addr, &path_rec.dgid);
- path_rec.pkey = cpu_to_be16(ib_addr_get_pkey(&addr->dev_addr));
- path_rec.numb_path = 1;
- path_rec.reversible = 1;
- path_rec.service_id = cma_get_service_id(id_priv->id.ps,
- (struct sockaddr *) &addr->dst_addr);
-
- comp_mask = IB_SA_PATH_REC_DGID | IB_SA_PATH_REC_SGID |
- IB_SA_PATH_REC_PKEY | IB_SA_PATH_REC_NUMB_PATH |
- IB_SA_PATH_REC_REVERSIBLE | IB_SA_PATH_REC_SERVICE_ID;
-
- if (addr->src_addr.ss_family == AF_INET) {
- path_rec.qos_class = cpu_to_be16((u16) id_priv->tos);
- comp_mask |= IB_SA_PATH_REC_QOS_CLASS;
- } else {
- sin6 = (struct sockaddr_in6 *) &addr->src_addr;
- path_rec.traffic_class = (u8) (be32_to_cpu(sin6->sin6_flowinfo) >> 20);
- comp_mask |= IB_SA_PATH_REC_TRAFFIC_CLASS;
- }
-
- id_priv->query_id = ib_sa_path_rec_get(&sa_client, id_priv->id.device,
- id_priv->id.port_num, &path_rec,
- comp_mask, timeout_ms,
- GFP_KERNEL, cma_query_handler,
- work, &id_priv->query);
-
- return (id_priv->query_id < 0) ? id_priv->query_id : 0;
-}
-
-static void cma_work_handler(struct work_struct *_work)
-{
- struct cma_work *work = container_of(_work, struct cma_work, work);
- struct rdma_id_private *id_priv = work->id;
- int destroy = 0;
-
- mutex_lock(&id_priv->handler_mutex);
- if (!cma_comp_exch(id_priv, work->old_state, work->new_state))
- goto out;
-
- if (id_priv->id.event_handler(&id_priv->id, &work->event)) {
- cma_exch(id_priv, RDMA_CM_DESTROYING);
- destroy = 1;
- }
-out:
- mutex_unlock(&id_priv->handler_mutex);
- cma_deref_id(id_priv);
- if (destroy)
- rdma_destroy_id(&id_priv->id);
- kfree(work);
-}
-
-static void cma_ndev_work_handler(struct work_struct *_work)
-{
- struct cma_ndev_work *work = container_of(_work, struct cma_ndev_work, work);
- struct rdma_id_private *id_priv = work->id;
- int destroy = 0;
-
- mutex_lock(&id_priv->handler_mutex);
- if (id_priv->state == RDMA_CM_DESTROYING ||
- id_priv->state == RDMA_CM_DEVICE_REMOVAL)
- goto out;
-
- if (id_priv->id.event_handler(&id_priv->id, &work->event)) {
- cma_exch(id_priv, RDMA_CM_DESTROYING);
- destroy = 1;
- }
-
-out:
- mutex_unlock(&id_priv->handler_mutex);
- cma_deref_id(id_priv);
- if (destroy)
- rdma_destroy_id(&id_priv->id);
- kfree(work);
-}
-
-static int cma_resolve_ib_route(struct rdma_id_private *id_priv, int timeout_ms)
-{
- struct rdma_route *route = &id_priv->id.route;
- struct cma_work *work;
- int ret;
-
- work = kzalloc(sizeof *work, GFP_KERNEL);
- if (!work)
- return -ENOMEM;
-
- work->id = id_priv;
- INIT_WORK(&work->work, cma_work_handler);
- work->old_state = RDMA_CM_ROUTE_QUERY;
- work->new_state = RDMA_CM_ROUTE_RESOLVED;
- work->event.event = RDMA_CM_EVENT_ROUTE_RESOLVED;
-
- route->path_rec = kmalloc(sizeof *route->path_rec, GFP_KERNEL);
- if (!route->path_rec) {
- ret = -ENOMEM;
- goto err1;
- }
-
- ret = cma_query_ib_route(id_priv, timeout_ms, work);
- if (ret)
- goto err2;
-
- return 0;
-err2:
- kfree(route->path_rec);
- route->path_rec = NULL;
-err1:
- kfree(work);
- return ret;
-}
-
-int rdma_set_ib_paths(struct rdma_cm_id *id,
- struct ib_sa_path_rec *path_rec, int num_paths)
-{
- struct rdma_id_private *id_priv;
- int ret;
-
- id_priv = container_of(id, struct rdma_id_private, id);
- if (!cma_comp_exch(id_priv, RDMA_CM_ADDR_RESOLVED,
- RDMA_CM_ROUTE_RESOLVED))
- return -EINVAL;
-
- id->route.path_rec = kmemdup(path_rec, sizeof *path_rec * num_paths,
- GFP_KERNEL);
- if (!id->route.path_rec) {
- ret = -ENOMEM;
- goto err;
- }
-
- id->route.num_paths = num_paths;
- return 0;
-err:
- cma_comp_exch(id_priv, RDMA_CM_ROUTE_RESOLVED, RDMA_CM_ADDR_RESOLVED);
- return ret;
-}
-EXPORT_SYMBOL(rdma_set_ib_paths);
-
-static int cma_resolve_iw_route(struct rdma_id_private *id_priv, int timeout_ms)
-{
- struct cma_work *work;
-
- work = kzalloc(sizeof *work, GFP_KERNEL);
- if (!work)
- return -ENOMEM;
-
- work->id = id_priv;
- INIT_WORK(&work->work, cma_work_handler);
- work->old_state = RDMA_CM_ROUTE_QUERY;
- work->new_state = RDMA_CM_ROUTE_RESOLVED;
- work->event.event = RDMA_CM_EVENT_ROUTE_RESOLVED;
- queue_work(cma_wq, &work->work);
- return 0;
-}
-
-static u8 tos_to_sl(u8 tos)
-{
- return def_prec2sl & 7;
-}
-
-static int cma_resolve_iboe_route(struct rdma_id_private *id_priv)
-{
- struct rdma_route *route = &id_priv->id.route;
- struct rdma_addr *addr = &route->addr;
- struct cma_work *work;
- int ret;
- struct sockaddr_in *src_addr = (struct sockaddr_in *)&route->addr.src_addr;
- struct sockaddr_in *dst_addr = (struct sockaddr_in *)&route->addr.dst_addr;
- struct net_device *ndev = NULL;
-
-
- if (src_addr->sin_family != dst_addr->sin_family)
- return -EINVAL;
-
- work = kzalloc(sizeof *work, GFP_KERNEL);
- if (!work)
- return -ENOMEM;
-
- work->id = id_priv;
- INIT_WORK(&work->work, cma_work_handler);
-
- route->path_rec = kzalloc(sizeof *route->path_rec, GFP_KERNEL);
- if (!route->path_rec) {
- ret = -ENOMEM;
- goto err1;
- }
-
- route->num_paths = 1;
-
- if (addr->dev_addr.bound_dev_if)
- ndev = dev_get_by_index(&init_net, addr->dev_addr.bound_dev_if);
- if (!ndev) {
- ret = -ENODEV;
- goto err2;
- }
-
- route->path_rec->vlan_id = rdma_vlan_dev_vlan_id(ndev);
- memcpy(route->path_rec->dmac, addr->dev_addr.dst_dev_addr, ETH_ALEN);
- memcpy(route->path_rec->smac, IF_LLADDR(ndev), ndev->if_addrlen);
-
-
- rdma_ip2gid((struct sockaddr *)&id_priv->id.route.addr.src_addr,
- &route->path_rec->sgid);
- rdma_ip2gid((struct sockaddr *)&id_priv->id.route.addr.dst_addr,
- &route->path_rec->dgid);
-
- route->path_rec->hop_limit = 1;
- route->path_rec->reversible = 1;
- route->path_rec->pkey = cpu_to_be16(0xffff);
- route->path_rec->mtu_selector = IB_SA_EQ;
- route->path_rec->sl = tos_to_sl(id_priv->tos);
-
- route->path_rec->mtu = iboe_get_mtu(ndev->if_mtu);
- route->path_rec->rate_selector = IB_SA_EQ;
- route->path_rec->rate = iboe_get_rate(ndev);
- dev_put(ndev);
- route->path_rec->packet_life_time_selector = IB_SA_EQ;
- route->path_rec->packet_life_time = CMA_IBOE_PACKET_LIFETIME;
- if (!route->path_rec->mtu) {
- ret = -EINVAL;
- goto err2;
- }
-
- work->old_state = RDMA_CM_ROUTE_QUERY;
- work->new_state = RDMA_CM_ROUTE_RESOLVED;
- work->event.event = RDMA_CM_EVENT_ROUTE_RESOLVED;
- work->event.status = 0;
-
- queue_work(cma_wq, &work->work);
-
- return 0;
-
-err2:
- kfree(route->path_rec);
- route->path_rec = NULL;
-err1:
- kfree(work);
- return ret;
-}
-
-int rdma_resolve_route(struct rdma_cm_id *id, int timeout_ms)
-{
- struct rdma_id_private *id_priv;
- int ret;
-
- id_priv = container_of(id, struct rdma_id_private, id);
- if (!cma_comp_exch(id_priv, RDMA_CM_ADDR_RESOLVED, RDMA_CM_ROUTE_QUERY))
- return -EINVAL;
-
- atomic_inc(&id_priv->refcount);
- if (rdma_cap_ib_sa(id->device, id->port_num))
- ret = cma_resolve_ib_route(id_priv, timeout_ms);
- else if (rdma_protocol_roce(id->device, id->port_num))
- ret = cma_resolve_iboe_route(id_priv);
- else if (rdma_protocol_iwarp(id->device, id->port_num))
- ret = cma_resolve_iw_route(id_priv, timeout_ms);
- else
- ret = -ENOSYS;
-
- if (ret)
- goto err;
-
- return 0;
-err:
- cma_comp_exch(id_priv, RDMA_CM_ROUTE_QUERY, RDMA_CM_ADDR_RESOLVED);
- cma_deref_id(id_priv);
- return ret;
-}
-EXPORT_SYMBOL(rdma_resolve_route);
-
-int rdma_enable_apm(struct rdma_cm_id *id, enum alt_path_type alt_type)
-{
- /* APM is not supported yet */
- return -EINVAL;
-}
-EXPORT_SYMBOL(rdma_enable_apm);
-
-static int cma_bind_loopback(struct rdma_id_private *id_priv)
-{
- struct cma_device *cma_dev;
- struct ib_port_attr port_attr;
- union ib_gid gid;
- u16 pkey;
- int ret;
- u8 p;
-
- mutex_lock(&lock);
- if (list_empty(&dev_list)) {
- ret = -ENODEV;
- goto out;
- }
- list_for_each_entry(cma_dev, &dev_list, list)
- for (p = 1; p <= cma_dev->device->phys_port_cnt; ++p)
- if (!ib_query_port(cma_dev->device, p, &port_attr) &&
- port_attr.state == IB_PORT_ACTIVE)
- goto port_found;
-
- p = 1;
- cma_dev = list_entry(dev_list.next, struct cma_device, list);
-
-port_found:
- ret = ib_get_cached_gid(cma_dev->device, p, 0, &gid);
- if (ret)
- goto out;
-
- ret = ib_get_cached_pkey(cma_dev->device, p, 0, &pkey);
- if (ret)
- goto out;
-
- id_priv->id.route.addr.dev_addr.dev_type =
- (rdma_port_get_link_layer(cma_dev->device, p) == IB_LINK_LAYER_INFINIBAND) ?
- ARPHRD_INFINIBAND : ARPHRD_ETHER;
-
- rdma_addr_set_sgid(&id_priv->id.route.addr.dev_addr, &gid);
- ib_addr_set_pkey(&id_priv->id.route.addr.dev_addr, pkey);
- id_priv->id.port_num = p;
- cma_attach_to_dev(id_priv, cma_dev);
-out:
- mutex_unlock(&lock);
- return ret;
-}
-
-static void addr_handler(int status, struct sockaddr *src_addr,
- struct rdma_dev_addr *dev_addr, void *context)
-{
- struct rdma_id_private *id_priv = context;
- struct rdma_cm_event event;
-
- memset(&event, 0, sizeof event);
- mutex_lock(&id_priv->handler_mutex);
- if (!cma_comp_exch(id_priv, RDMA_CM_ADDR_QUERY,
- RDMA_CM_ADDR_RESOLVED))
- goto out;
-
- memcpy(&id_priv->id.route.addr.src_addr, src_addr,
- ip_addr_size(src_addr));
- if (!status && !id_priv->cma_dev)
- status = cma_acquire_dev(id_priv);
-
- if (status) {
- if (!cma_comp_exch(id_priv, RDMA_CM_ADDR_RESOLVED,
- RDMA_CM_ADDR_BOUND))
- goto out;
- event.event = RDMA_CM_EVENT_ADDR_ERROR;
- event.status = status;
- } else
- event.event = RDMA_CM_EVENT_ADDR_RESOLVED;
-
- if (id_priv->id.event_handler(&id_priv->id, &event)) {
- cma_exch(id_priv, RDMA_CM_DESTROYING);
- mutex_unlock(&id_priv->handler_mutex);
- cma_deref_id(id_priv);
- rdma_destroy_id(&id_priv->id);
- return;
- }
-out:
- mutex_unlock(&id_priv->handler_mutex);
- cma_deref_id(id_priv);
-}
-
-static int cma_resolve_loopback(struct rdma_id_private *id_priv)
-{
- struct cma_work *work;
- struct sockaddr *src, *dst;
- union ib_gid gid;
- int ret;
-
- work = kzalloc(sizeof *work, GFP_KERNEL);
- if (!work)
- return -ENOMEM;
-
- if (!id_priv->cma_dev) {
- ret = cma_bind_loopback(id_priv);
- if (ret)
- goto err;
- }
-
- rdma_addr_get_sgid(&id_priv->id.route.addr.dev_addr, &gid);
- rdma_addr_set_dgid(&id_priv->id.route.addr.dev_addr, &gid);
-
- src = (struct sockaddr *) &id_priv->id.route.addr.src_addr;
- if (cma_zero_addr(src)) {
- dst = (struct sockaddr *) &id_priv->id.route.addr.dst_addr;
- if ((src->sa_family = dst->sa_family) == AF_INET) {
- ((struct sockaddr_in *)src)->sin_addr =
- ((struct sockaddr_in *)dst)->sin_addr;
- } else {
- ((struct sockaddr_in6 *)src)->sin6_addr =
- ((struct sockaddr_in6 *)dst)->sin6_addr;
- }
- }
-
- work->id = id_priv;
- INIT_WORK(&work->work, cma_work_handler);
- work->old_state = RDMA_CM_ADDR_QUERY;
- work->new_state = RDMA_CM_ADDR_RESOLVED;
- work->event.event = RDMA_CM_EVENT_ADDR_RESOLVED;
- queue_work(cma_wq, &work->work);
- return 0;
-err:
- kfree(work);
- return ret;
-}
-
-static int cma_resolve_scif(struct rdma_id_private *id_priv)
-{
- struct cma_work *work;
-
- work = kzalloc(sizeof *work, GFP_KERNEL);
- if (!work)
- return -ENOMEM;
-
- /* we probably can leave it empty here */
-
- work->id = id_priv;
- INIT_WORK(&work->work, cma_work_handler);
- work->old_state = RDMA_CM_ADDR_QUERY;
- work->new_state = RDMA_CM_ADDR_RESOLVED;
- work->event.event = RDMA_CM_EVENT_ADDR_RESOLVED;
- queue_work(cma_wq, &work->work);
- return 0;
-}
-
-static int cma_bind_addr(struct rdma_cm_id *id, struct sockaddr *src_addr,
- struct sockaddr *dst_addr)
-{
- if (!src_addr || !src_addr->sa_family) {
- src_addr = (struct sockaddr *) &id->route.addr.src_addr;
- src_addr->sa_family = dst_addr->sa_family;
-#ifdef INET6
- if (dst_addr->sa_family == AF_INET6) {
- struct sockaddr_in6 *src_addr6 = (struct sockaddr_in6 *) src_addr;
- struct sockaddr_in6 *dst_addr6 = (struct sockaddr_in6 *) dst_addr;
- src_addr6->sin6_scope_id = dst_addr6->sin6_scope_id;
- if (IN6_IS_SCOPE_LINKLOCAL(&dst_addr6->sin6_addr) ||
- IN6_IS_ADDR_MC_INTFACELOCAL(&dst_addr6->sin6_addr))
- id->route.addr.dev_addr.bound_dev_if = dst_addr6->sin6_scope_id;
- }
-#endif
- }
- if (!cma_any_addr(src_addr))
- return rdma_bind_addr(id, src_addr);
- else {
-#if defined(INET6) || defined(INET)
- union {
-#ifdef INET
- struct sockaddr_in in;
-#endif
-#ifdef INET6
- struct sockaddr_in6 in6;
-#endif
- } addr;
-#endif
-
- switch(dst_addr->sa_family) {
-#ifdef INET
- case AF_INET:
- memset(&addr.in, 0, sizeof(addr.in));
- addr.in.sin_family = dst_addr->sa_family;
- addr.in.sin_len = sizeof(addr.in);
- return rdma_bind_addr(id, (struct sockaddr *)&addr.in);
-#endif
-#ifdef INET6
- case AF_INET6:
- memset(&addr.in6, 0, sizeof(addr.in6));
- addr.in6.sin6_family = dst_addr->sa_family;
- addr.in6.sin6_len = sizeof(addr.in6);
- addr.in6.sin6_scope_id =
- ((struct sockaddr_in6 *)dst_addr)->sin6_scope_id;
- return rdma_bind_addr(id, (struct sockaddr *)&addr.in6);
-#endif
- default:
- return -EINVAL;
- }
- }
-}
-
-int rdma_resolve_addr(struct rdma_cm_id *id, struct sockaddr *src_addr,
- struct sockaddr *dst_addr, int timeout_ms)
-{
- struct rdma_id_private *id_priv;
- int ret;
-
- id_priv = container_of(id, struct rdma_id_private, id);
- if (id_priv->state == RDMA_CM_IDLE) {
- ret = cma_bind_addr(id, src_addr, dst_addr);
- if (ret)
- return ret;
- }
-
- if (!cma_comp_exch(id_priv, RDMA_CM_ADDR_BOUND, RDMA_CM_ADDR_QUERY))
- return -EINVAL;
-
- atomic_inc(&id_priv->refcount);
- memcpy(&id->route.addr.dst_addr, dst_addr, ip_addr_size(dst_addr));
- if (cma_any_addr(dst_addr))
- ret = cma_resolve_loopback(id_priv);
- else if (id_priv->id.device &&
- rdma_node_get_transport(id_priv->id.device->node_type) == RDMA_TRANSPORT_SCIF)
- ret = cma_resolve_scif(id_priv);
- else
- ret = rdma_resolve_ip(&addr_client, (struct sockaddr *) &id->route.addr.src_addr,
- dst_addr, &id->route.addr.dev_addr,
- timeout_ms, addr_handler, id_priv);
- if (ret)
- goto err;
-
- return 0;
-err:
- cma_comp_exch(id_priv, RDMA_CM_ADDR_QUERY, RDMA_CM_ADDR_BOUND);
- cma_deref_id(id_priv);
- return ret;
-}
-EXPORT_SYMBOL(rdma_resolve_addr);
-
-int rdma_set_reuseaddr(struct rdma_cm_id *id, int reuse)
-{
- struct rdma_id_private *id_priv;
- unsigned long flags;
- int ret;
-
- id_priv = container_of(id, struct rdma_id_private, id);
- spin_lock_irqsave(&id_priv->lock, flags);
- if (id_priv->state == RDMA_CM_IDLE) {
- id_priv->reuseaddr = reuse;
- ret = 0;
- } else {
- ret = -EINVAL;
- }
- spin_unlock_irqrestore(&id_priv->lock, flags);
- return ret;
-}
-EXPORT_SYMBOL(rdma_set_reuseaddr);
-
-int rdma_set_afonly(struct rdma_cm_id *id, int afonly)
-{
- struct rdma_id_private *id_priv;
- unsigned long flags;
- int ret;
-
- id_priv = container_of(id, struct rdma_id_private, id);
- spin_lock_irqsave(&id_priv->lock, flags);
- if (id_priv->state == RDMA_CM_IDLE || id_priv->state == RDMA_CM_ADDR_BOUND) {
- id_priv->options |= (1 << CMA_OPTION_AFONLY);
- id_priv->afonly = afonly;
- ret = 0;
- } else {
- ret = -EINVAL;
- }
- spin_unlock_irqrestore(&id_priv->lock, flags);
- return ret;
-}
-EXPORT_SYMBOL(rdma_set_afonly);
-
-static void cma_bind_port(struct rdma_bind_list *bind_list,
- struct rdma_id_private *id_priv)
-{
- struct sockaddr_in *sin;
-
- sin = (struct sockaddr_in *) &id_priv->id.route.addr.src_addr;
- sin->sin_port = htons(bind_list->port);
- id_priv->bind_list = bind_list;
- hlist_add_head(&id_priv->node, &bind_list->owners);
-}
-
-static int cma_alloc_port(struct idr *ps, struct rdma_id_private *id_priv,
- unsigned short snum)
-{
- struct rdma_bind_list *bind_list;
- int port, ret;
-
- bind_list = kzalloc(sizeof *bind_list, GFP_KERNEL);
- if (!bind_list)
- return -ENOMEM;
-
- do {
- ret = idr_get_new_above(ps, bind_list, snum, &port);
- } while ((ret == -EAGAIN) && idr_pre_get(ps, GFP_KERNEL));
-
- if (ret)
- goto err1;
-
- if (port != snum) {
- ret = -EADDRNOTAVAIL;
- goto err2;
- }
-
- bind_list->ps = ps;
- bind_list->port = (unsigned short) port;
- cma_bind_port(bind_list, id_priv);
- return 0;
-err2:
- idr_remove(ps, port);
-err1:
- kfree(bind_list);
- return ret;
-}
-
-static int cma_alloc_any_port(struct idr *ps, struct rdma_id_private *id_priv)
-{
- static unsigned int last_used_port;
- int low, high, remaining;
- unsigned int rover;
-
- inet_get_local_port_range(&init_net, &low, &high);
- remaining = (high - low) + 1;
- rover = random() % remaining + low;
-retry:
- if (last_used_port != rover &&
- !idr_find(ps, (unsigned short) rover)) {
- int ret = cma_alloc_port(ps, id_priv, rover);
- /*
- * Remember previously used port number in order to avoid
- * re-using same port immediately after it is closed.
- */
- if (!ret)
- last_used_port = rover;
- if (ret != -EADDRNOTAVAIL)
- return ret;
- }
- if (--remaining) {
- rover++;
- if ((rover < low) || (rover > high))
- rover = low;
- goto retry;
- }
- return -EADDRNOTAVAIL;
-}
-
-/*
- * Check that the requested port is available. This is called when trying to
- * bind to a specific port, or when trying to listen on a bound port. In
- * the latter case, the provided id_priv may already be on the bind_list, but
- * we still need to check that it's okay to start listening.
- */
-static int cma_check_port(struct rdma_bind_list *bind_list,
- struct rdma_id_private *id_priv, uint8_t reuseaddr)
-{
- struct rdma_id_private *cur_id;
- struct sockaddr *addr, *cur_addr;
-
- addr = (struct sockaddr *) &id_priv->id.route.addr.src_addr;
- hlist_for_each_entry(cur_id, &bind_list->owners, node) {
- if (id_priv == cur_id)
- continue;
-
- if ((cur_id->state != RDMA_CM_LISTEN) && reuseaddr &&
- cur_id->reuseaddr)
- continue;
-
- cur_addr = (struct sockaddr *) &cur_id->id.route.addr.src_addr;
- if (id_priv->afonly && cur_id->afonly &&
- (addr->sa_family != cur_addr->sa_family))
- continue;
-
- if (cma_any_addr(addr) || cma_any_addr(cur_addr))
- return -EADDRNOTAVAIL;
-
- if (!cma_addr_cmp(addr, cur_addr))
- return -EADDRINUSE;
- }
- return 0;
-}
-
-static int cma_use_port(struct idr *ps, struct rdma_id_private *id_priv)
-{
- struct rdma_bind_list *bind_list;
- unsigned short snum;
- int ret;
-
- snum = ntohs(cma_port((struct sockaddr *) &id_priv->id.route.addr.src_addr));
-
- bind_list = idr_find(ps, snum);
- if (!bind_list) {
- ret = cma_alloc_port(ps, id_priv, snum);
- } else {
- ret = cma_check_port(bind_list, id_priv, id_priv->reuseaddr);
- if (!ret)
- cma_bind_port(bind_list, id_priv);
- }
- return ret;
-}
-
-static int cma_bind_listen(struct rdma_id_private *id_priv)
-{
- struct rdma_bind_list *bind_list = id_priv->bind_list;
- int ret = 0;
-
- mutex_lock(&lock);
- if (bind_list->owners.first->next)
- ret = cma_check_port(bind_list, id_priv, 0);
- mutex_unlock(&lock);
- return ret;
-}
-
-static int cma_get_tcp_port(struct rdma_id_private *id_priv)
-{
- int ret;
- int size;
- struct socket *sock;
- struct sockaddr *src_addr = (struct sockaddr *)&id_priv->id.route.addr.src_addr;
-
- switch (src_addr->sa_family) {
- case AF_INET:
- case AF_INET6:
- break;
- default:
- /* other address families are not handled by iWarp */
- id_priv->unify_ps_tcp = 0;
- return (0);
- }
-
- ret = sock_create_kern(src_addr->sa_family, SOCK_STREAM, IPPROTO_TCP, &sock);
- if (ret)
- return ret;
-#ifdef __linux__
- ret = sock->ops->bind(sock, src_addr, ip_addr_size(src_addr));
-#else
- SOCK_LOCK(sock);
- sock->so_options |= SO_REUSEADDR;
- SOCK_UNLOCK(sock);
-
- ret = -sobind(sock, src_addr, curthread);
-#endif
- if (ret) {
- sock_release(sock);
- return ret;
- }
-
- size = ip_addr_size(src_addr);
- ret = sock_getname(sock, src_addr, &size, 0);
- if (ret) {
- sock_release(sock);
- return ret;
- }
-
- id_priv->sock = sock;
- return 0;
-}
-
-static int cma_get_port(struct rdma_id_private *id_priv)
-{
- struct cma_device *cma_dev;
- struct idr *ps;
- int ret;
-
- switch (id_priv->id.ps) {
- case RDMA_PS_SDP:
- ps = &sdp_ps;
- break;
- case RDMA_PS_TCP:
- ps = &tcp_ps;
-
- mutex_lock(&lock);
- /* check if there are any iWarp IB devices present */
- list_for_each_entry(cma_dev, &dev_list, list) {
- if (rdma_protocol_iwarp(cma_dev->device, 1)) {
- id_priv->unify_ps_tcp = 1;
- break;
- }
- }
- mutex_unlock(&lock);
-
- if (id_priv->unify_ps_tcp) {
- ret = cma_get_tcp_port(id_priv);
- if (ret)
- goto out;
- }
- break;
- case RDMA_PS_UDP:
- ps = &udp_ps;
- break;
- case RDMA_PS_IPOIB:
- ps = &ipoib_ps;
- break;
- case RDMA_PS_IB:
- ps = &ib_ps;
- break;
- default:
- return -EPROTONOSUPPORT;
- }
-
- mutex_lock(&lock);
- if (cma_any_port((struct sockaddr *) &id_priv->id.route.addr.src_addr))
- ret = cma_alloc_any_port(ps, id_priv);
- else
- ret = cma_use_port(ps, id_priv);
- mutex_unlock(&lock);
-out:
- return ret;
-}
-
-static int cma_check_linklocal(struct rdma_dev_addr *dev_addr,
- struct sockaddr *addr)
-{
-#ifdef INET6
- struct sockaddr_in6 sin6;
-
- if (addr->sa_family != AF_INET6)
- return 0;
-
- sin6 = *(struct sockaddr_in6 *)addr;
-
- if (IN6_IS_SCOPE_LINKLOCAL(&sin6.sin6_addr) ||
- IN6_IS_ADDR_MC_INTFACELOCAL(&sin6.sin6_addr)) {
- /* check if IPv6 scope ID is set */
- if (sa6_recoverscope(&sin6) || sin6.sin6_scope_id == 0)
- return -EINVAL;
- dev_addr->bound_dev_if = sin6.sin6_scope_id;
- }
-#endif
- return (0);
-}
-
-int rdma_listen(struct rdma_cm_id *id, int backlog)
-{
- struct rdma_id_private *id_priv;
- int ret;
-
- id_priv = container_of(id, struct rdma_id_private, id);
- if (id_priv->state == RDMA_CM_IDLE) {
- ((struct sockaddr *) &id->route.addr.src_addr)->sa_family = AF_INET;
- ret = rdma_bind_addr(id, (struct sockaddr *) &id->route.addr.src_addr);
- if (ret)
- return ret;
- }
-
- if (!cma_comp_exch(id_priv, RDMA_CM_ADDR_BOUND, RDMA_CM_LISTEN))
- return -EINVAL;
-
- if (id_priv->reuseaddr) {
- ret = cma_bind_listen(id_priv);
- if (ret)
- goto err;
- }
-
- id_priv->backlog = backlog;
- if (id->device) {
- if (rdma_cap_ib_cm(id->device, 1)) {
- ret = cma_ib_listen(id_priv);
- if (ret)
- goto err;
- } else if (rdma_cap_iw_cm(id->device, 1)) {
- ret = cma_iw_listen(id_priv, backlog);
- if (ret)
- goto err;
- } else {
- ret = -ENOSYS;
- goto err;
- }
- } else
- cma_listen_on_all(id_priv);
-
- return 0;
-err:
- id_priv->backlog = 0;
- cma_comp_exch(id_priv, RDMA_CM_LISTEN, RDMA_CM_ADDR_BOUND);
- return ret;
-}
-EXPORT_SYMBOL(rdma_listen);
-
-int rdma_bind_addr(struct rdma_cm_id *id, struct sockaddr *addr)
-{
- struct rdma_id_private *id_priv;
- int ret;
-
- if (addr->sa_family != AF_INET && addr->sa_family != AF_INET6)
- return -EAFNOSUPPORT;
-
- id_priv = container_of(id, struct rdma_id_private, id);
- if (!cma_comp_exch(id_priv, RDMA_CM_IDLE, RDMA_CM_ADDR_BOUND))
- return -EINVAL;
-
- ret = cma_check_linklocal(&id->route.addr.dev_addr, addr);
- if (ret)
- goto err1;
-
- memcpy(&id->route.addr.src_addr, addr, ip_addr_size(addr));
- if (!cma_any_addr(addr)) {
- ret = rdma_translate_ip(addr, &id->route.addr.dev_addr, NULL);
- if (ret)
- goto err1;
-
- ret = cma_acquire_dev(id_priv);
- if (ret)
- goto err1;
- }
-
- if (!(id_priv->options & (1 << CMA_OPTION_AFONLY))) {
- if (addr->sa_family == AF_INET)
- id_priv->afonly = 1;
-#if defined(INET6)
- else if (addr->sa_family == AF_INET6) {
- CURVNET_SET_QUIET(&init_net);
- id_priv->afonly = V_ip6_v6only;
- CURVNET_RESTORE();
- }
-#endif
- }
- ret = cma_get_port(id_priv);
- if (ret)
- goto err2;
-
- return 0;
-err2:
- if (id_priv->cma_dev)
- cma_release_dev(id_priv);
-err1:
- cma_comp_exch(id_priv, RDMA_CM_ADDR_BOUND, RDMA_CM_IDLE);
- return ret;
-}
-EXPORT_SYMBOL(rdma_bind_addr);
-
-static int cma_format_hdr(void *hdr, enum rdma_port_space ps,
- struct rdma_route *route)
-{
- struct cma_hdr *cma_hdr;
- struct sdp_hh *sdp_hdr;
-
- if (route->addr.src_addr.ss_family == AF_INET) {
- struct sockaddr_in *src4, *dst4;
-
- src4 = (struct sockaddr_in *) &route->addr.src_addr;
- dst4 = (struct sockaddr_in *) &route->addr.dst_addr;
-
- switch (ps) {
- case RDMA_PS_SDP:
- sdp_hdr = hdr;
- if (sdp_get_majv(sdp_hdr->sdp_version) != SDP_MAJ_VERSION)
- return -EINVAL;
- sdp_set_ip_ver(sdp_hdr, 4);
- sdp_hdr->src_addr.ip4.addr = src4->sin_addr.s_addr;
- sdp_hdr->dst_addr.ip4.addr = dst4->sin_addr.s_addr;
- sdp_hdr->port = src4->sin_port;
- break;
- default:
- cma_hdr = hdr;
- cma_hdr->cma_version = CMA_VERSION;
- cma_set_ip_ver(cma_hdr, 4);
- cma_hdr->src_addr.ip4.addr = src4->sin_addr.s_addr;
- cma_hdr->dst_addr.ip4.addr = dst4->sin_addr.s_addr;
- cma_hdr->port = src4->sin_port;
- break;
- }
- } else {
- struct sockaddr_in6 *src6, *dst6;
-
- src6 = (struct sockaddr_in6 *) &route->addr.src_addr;
- dst6 = (struct sockaddr_in6 *) &route->addr.dst_addr;
-
- switch (ps) {
- case RDMA_PS_SDP:
- sdp_hdr = hdr;
- if (sdp_get_majv(sdp_hdr->sdp_version) != SDP_MAJ_VERSION)
- return -EINVAL;
- sdp_set_ip_ver(sdp_hdr, 6);
- sdp_hdr->src_addr.ip6 = src6->sin6_addr;
- sdp_hdr->dst_addr.ip6 = dst6->sin6_addr;
- sdp_hdr->port = src6->sin6_port;
- break;
- default:
- cma_hdr = hdr;
- cma_hdr->cma_version = CMA_VERSION;
- cma_set_ip_ver(cma_hdr, 6);
- cma_hdr->src_addr.ip6 = src6->sin6_addr;
- cma_hdr->dst_addr.ip6 = dst6->sin6_addr;
- cma_hdr->port = src6->sin6_port;
- cma_ip6_clear_scope_id(&cma_hdr->src_addr.ip6);
- cma_ip6_clear_scope_id(&cma_hdr->dst_addr.ip6);
- break;
- }
- }
- return 0;
-}
-
-static int cma_sidr_rep_handler(struct ib_cm_id *cm_id,
- struct ib_cm_event *ib_event)
-{
- struct rdma_id_private *id_priv = cm_id->context;
- struct rdma_cm_event event;
- struct ib_cm_sidr_rep_event_param *rep = &ib_event->param.sidr_rep_rcvd;
- int ret = 0;
-
- if (cma_disable_callback(id_priv, RDMA_CM_CONNECT))
- return 0;
-
- memset(&event, 0, sizeof event);
- switch (ib_event->event) {
- case IB_CM_SIDR_REQ_ERROR:
- event.event = RDMA_CM_EVENT_UNREACHABLE;
- event.status = -ETIMEDOUT;
- break;
- case IB_CM_SIDR_REP_RECEIVED:
- event.param.ud.private_data = ib_event->private_data;
- event.param.ud.private_data_len = IB_CM_SIDR_REP_PRIVATE_DATA_SIZE;
- if (rep->status != IB_SIDR_SUCCESS) {
- event.event = RDMA_CM_EVENT_UNREACHABLE;
- event.status = ib_event->param.sidr_rep_rcvd.status;
- break;
- }
- ret = cma_set_qkey(id_priv);
- if (ret) {
- event.event = RDMA_CM_EVENT_ADDR_ERROR;
- event.status = -EINVAL;
- break;
- }
- if (id_priv->qkey != rep->qkey) {
- event.event = RDMA_CM_EVENT_UNREACHABLE;
- event.status = -EINVAL;
- break;
- }
- ib_init_ah_from_path(id_priv->id.device, id_priv->id.port_num,
- id_priv->id.route.path_rec,
- &event.param.ud.ah_attr);
- event.param.ud.qp_num = rep->qpn;
- event.param.ud.qkey = rep->qkey;
- event.event = RDMA_CM_EVENT_ESTABLISHED;
- event.status = 0;
- break;
- default:
- printk(KERN_ERR "RDMA CMA: unexpected IB CM event: %d\n",
- ib_event->event);
- goto out;
- }
-
- ret = id_priv->id.event_handler(&id_priv->id, &event);
- if (ret) {
- /* Destroy the CM ID by returning a non-zero value. */
- id_priv->cm_id.ib = NULL;
- cma_exch(id_priv, RDMA_CM_DESTROYING);
- mutex_unlock(&id_priv->handler_mutex);
- rdma_destroy_id(&id_priv->id);
- return ret;
- }
-out:
- mutex_unlock(&id_priv->handler_mutex);
- return ret;
-}
-
-static int cma_resolve_ib_udp(struct rdma_id_private *id_priv,
- struct rdma_conn_param *conn_param)
-{
- struct ib_cm_sidr_req_param req;
- struct rdma_route *route;
- struct ib_cm_id *id;
- int ret;
-
- req.private_data_len = sizeof(struct cma_hdr) +
- conn_param->private_data_len;
- if (req.private_data_len < conn_param->private_data_len)
- return -EINVAL;
-
- req.private_data = kzalloc(req.private_data_len, GFP_ATOMIC);
- if (!req.private_data)
- return -ENOMEM;
-
- if (conn_param->private_data && conn_param->private_data_len)
- memcpy((void *) req.private_data + sizeof(struct cma_hdr),
- conn_param->private_data, conn_param->private_data_len);
-
- route = &id_priv->id.route;
- ret = cma_format_hdr((void *) req.private_data, id_priv->id.ps, route);
- if (ret)
- goto out;
-
- id = ib_create_cm_id(id_priv->id.device, cma_sidr_rep_handler,
- id_priv);
- if (IS_ERR(id)) {
- ret = PTR_ERR(id);
- goto out;
- }
- id_priv->cm_id.ib = id;
-
- req.path = route->path_rec;
- req.service_id = cma_get_service_id(id_priv->id.ps,
- (struct sockaddr *) &route->addr.dst_addr);
- req.timeout_ms = 1 << (cma_response_timeout - 8);
- req.max_cm_retries = CMA_MAX_CM_RETRIES;
-
- cma_dbg(id_priv, "sending SIDR\n");
- ret = ib_send_cm_sidr_req(id_priv->cm_id.ib, &req);
- if (ret) {
- ib_destroy_cm_id(id_priv->cm_id.ib);
- id_priv->cm_id.ib = NULL;
- }
-out:
- kfree(req.private_data);
- return ret;
-}
-
-static int cma_connect_ib(struct rdma_id_private *id_priv,
- struct rdma_conn_param *conn_param)
-{
- struct ib_cm_req_param req;
- struct rdma_route *route;
- void *private_data;
- struct ib_cm_id *id;
- int offset, ret;
-
- memset(&req, 0, sizeof req);
- offset = cma_user_data_offset(id_priv->id.ps);
- req.private_data_len = offset + conn_param->private_data_len;
- if (req.private_data_len < conn_param->private_data_len)
- return -EINVAL;
-
- private_data = kzalloc(req.private_data_len, GFP_ATOMIC);
- if (!private_data)
- return -ENOMEM;
-
- if (conn_param->private_data && conn_param->private_data_len)
- memcpy(private_data + offset, conn_param->private_data,
- conn_param->private_data_len);
-
- id = ib_create_cm_id(id_priv->id.device, cma_ib_handler, id_priv);
- if (IS_ERR(id)) {
- ret = PTR_ERR(id);
- goto out;
- }
- id_priv->cm_id.ib = id;
-
- route = &id_priv->id.route;
- ret = cma_format_hdr(private_data, id_priv->id.ps, route);
- if (ret)
- goto out;
- req.private_data = private_data;
-
- req.primary_path = &route->path_rec[0];
- if (route->num_paths == 2)
- req.alternate_path = &route->path_rec[1];
-
- req.service_id = cma_get_service_id(id_priv->id.ps,
- (struct sockaddr *) &route->addr.dst_addr);
- req.qp_num = id_priv->qp_num;
- req.qp_type = id_priv->id.qp_type;
- req.starting_psn = id_priv->seq_num;
- req.responder_resources = conn_param->responder_resources;
- req.initiator_depth = conn_param->initiator_depth;
- req.flow_control = conn_param->flow_control;
- req.retry_count = min_t(u8, 7, conn_param->retry_count);
- req.rnr_retry_count = min_t(u8, 7, conn_param->rnr_retry_count);
- req.remote_cm_response_timeout = cma_response_timeout;
- req.local_cm_response_timeout = cma_response_timeout;
- req.max_cm_retries = CMA_MAX_CM_RETRIES;
- req.srq = id_priv->srq ? 1 : 0;
-
- cma_dbg(id_priv, "sending REQ\n");
- ret = ib_send_cm_req(id_priv->cm_id.ib, &req);
-out:
- if (ret && !IS_ERR(id)) {
- ib_destroy_cm_id(id);
- id_priv->cm_id.ib = NULL;
- }
-
- kfree(private_data);
- return ret;
-}
-
-static int cma_connect_iw(struct rdma_id_private *id_priv,
- struct rdma_conn_param *conn_param)
-{
- struct iw_cm_id *cm_id;
- struct sockaddr_in* sin;
- int ret;
- struct iw_cm_conn_param iw_param;
-
- cm_id = iw_create_cm_id(id_priv->id.device, id_priv->sock,
- cma_iw_handler, id_priv);
- if (IS_ERR(cm_id))
- return PTR_ERR(cm_id);
-
- id_priv->cm_id.iw = cm_id;
-
- sin = (struct sockaddr_in*) &id_priv->id.route.addr.src_addr;
- cm_id->local_addr = *sin;
-
- sin = (struct sockaddr_in*) &id_priv->id.route.addr.dst_addr;
- cm_id->remote_addr = *sin;
-
- ret = cma_modify_qp_rtr(id_priv, conn_param);
- if (ret)
- goto out;
-
- if (conn_param) {
- iw_param.ord = conn_param->initiator_depth;
- iw_param.ird = conn_param->responder_resources;
- iw_param.private_data = conn_param->private_data;
- iw_param.private_data_len = conn_param->private_data_len;
- iw_param.qpn = id_priv->id.qp ? id_priv->qp_num : conn_param->qp_num;
- } else {
- memset(&iw_param, 0, sizeof iw_param);
- iw_param.qpn = id_priv->qp_num;
- }
- ret = iw_cm_connect(cm_id, &iw_param);
-out:
- if (ret) {
- iw_destroy_cm_id(cm_id);
- id_priv->cm_id.iw = NULL;
- }
- return ret;
-}
-
-int rdma_connect(struct rdma_cm_id *id, struct rdma_conn_param *conn_param)
-{
- struct rdma_id_private *id_priv;
- int ret;
-
- id_priv = container_of(id, struct rdma_id_private, id);
- if (!cma_comp_exch(id_priv, RDMA_CM_ROUTE_RESOLVED, RDMA_CM_CONNECT))
- return -EINVAL;
-
- if (!id->qp) {
- id_priv->qp_num = conn_param->qp_num;
- id_priv->srq = conn_param->srq;
- }
-
- if (rdma_cap_ib_cm(id->device, id->port_num)) {
- if (id->qp_type == IB_QPT_UD)
- ret = cma_resolve_ib_udp(id_priv, conn_param);
- else
- ret = cma_connect_ib(id_priv, conn_param);
- } else if (rdma_cap_iw_cm(id->device, id->port_num))
- ret = cma_connect_iw(id_priv, conn_param);
- else
- ret = -ENOSYS;
- if (ret)
- goto err;
-
- return 0;
-err:
- cma_comp_exch(id_priv, RDMA_CM_CONNECT, RDMA_CM_ROUTE_RESOLVED);
- return ret;
-}
-EXPORT_SYMBOL(rdma_connect);
-
-static int cma_accept_ib(struct rdma_id_private *id_priv,
- struct rdma_conn_param *conn_param)
-{
- struct ib_cm_rep_param rep;
- int ret;
-
- ret = cma_modify_qp_rtr(id_priv, conn_param);
- if (ret)
- goto out;
-
- ret = cma_modify_qp_rts(id_priv, conn_param);
- if (ret)
- goto out;
-
- memset(&rep, 0, sizeof rep);
- rep.qp_num = id_priv->qp_num;
- rep.starting_psn = id_priv->seq_num;
- rep.private_data = conn_param->private_data;
- rep.private_data_len = conn_param->private_data_len;
- rep.responder_resources = conn_param->responder_resources;
- rep.initiator_depth = conn_param->initiator_depth;
- rep.failover_accepted = 0;
- rep.flow_control = conn_param->flow_control;
- rep.rnr_retry_count = min_t(u8, 7, conn_param->rnr_retry_count);
- rep.srq = id_priv->srq ? 1 : 0;
- cma_dbg(id_priv, "sending REP\n");
- ret = ib_send_cm_rep(id_priv->cm_id.ib, &rep);
-out:
- return ret;
-}
-
-static int cma_accept_iw(struct rdma_id_private *id_priv,
- struct rdma_conn_param *conn_param)
-{
- struct iw_cm_conn_param iw_param;
- int ret;
-
- if (!conn_param)
- return -EINVAL;
-
- ret = cma_modify_qp_rtr(id_priv, conn_param);
- if (ret)
- return ret;
-
- iw_param.ord = conn_param->initiator_depth;
- iw_param.ird = conn_param->responder_resources;
- iw_param.private_data = conn_param->private_data;
- iw_param.private_data_len = conn_param->private_data_len;
- if (id_priv->id.qp) {
- iw_param.qpn = id_priv->qp_num;
- } else
- iw_param.qpn = conn_param->qp_num;
-
- return iw_cm_accept(id_priv->cm_id.iw, &iw_param);
-}
-
-static int cma_send_sidr_rep(struct rdma_id_private *id_priv,
- enum ib_cm_sidr_status status,
- const void *private_data, int private_data_len)
-{
- struct ib_cm_sidr_rep_param rep;
- int ret;
-
- memset(&rep, 0, sizeof rep);
- rep.status = status;
- if (status == IB_SIDR_SUCCESS) {
- ret = cma_set_qkey(id_priv);
- if (ret)
- return ret;
- rep.qp_num = id_priv->qp_num;
- rep.qkey = id_priv->qkey;
- }
- rep.private_data = private_data;
- rep.private_data_len = private_data_len;
-
- cma_dbg(id_priv, "sending SIDR\n");
- return ib_send_cm_sidr_rep(id_priv->cm_id.ib, &rep);
-}
-
-int rdma_accept(struct rdma_cm_id *id, struct rdma_conn_param *conn_param)
-{
- struct rdma_id_private *id_priv;
- int ret;
-
- id_priv = container_of(id, struct rdma_id_private, id);
-
- id_priv->owner = curthread->td_proc->p_pid;
- if (!cma_comp(id_priv, RDMA_CM_CONNECT))
- return -EINVAL;
-
- if (!id->qp && conn_param) {
- id_priv->qp_num = conn_param->qp_num;
- id_priv->srq = conn_param->srq;
- }
-
- if (rdma_cap_ib_cm(id->device, id->port_num)) {
- if (id->qp_type == IB_QPT_UD) {
- if (conn_param)
- ret = cma_send_sidr_rep(id_priv, IB_SIDR_SUCCESS,
- conn_param->private_data,
- conn_param->private_data_len);
- else
- ret = cma_send_sidr_rep(id_priv, IB_SIDR_SUCCESS,
- NULL, 0);
- } else {
- if (conn_param)
- ret = cma_accept_ib(id_priv, conn_param);
- else
- ret = cma_rep_recv(id_priv);
- }
- } else if (rdma_cap_iw_cm(id->device, id->port_num))
- ret = cma_accept_iw(id_priv, conn_param);
- else
- ret = -ENOSYS;
-
- if (ret)
- goto reject;
-
- return 0;
-reject:
- cma_modify_qp_err(id_priv);
- rdma_reject(id, NULL, 0);
- return ret;
-}
-EXPORT_SYMBOL(rdma_accept);
-
-int rdma_notify(struct rdma_cm_id *id, enum ib_event_type event)
-{
- struct rdma_id_private *id_priv;
- int ret;
-
- id_priv = container_of(id, struct rdma_id_private, id);
- if (!id_priv->cm_id.ib)
- return -EINVAL;
-
- switch (id->device->node_type) {
- case RDMA_NODE_IB_CA:
- ret = ib_cm_notify(id_priv->cm_id.ib, event);
- break;
- default:
- ret = 0;
- break;
- }
- return ret;
-}
-EXPORT_SYMBOL(rdma_notify);
-
-int rdma_reject(struct rdma_cm_id *id, const void *private_data,
- u8 private_data_len)
-{
- struct rdma_id_private *id_priv;
- int ret;
-
- id_priv = container_of(id, struct rdma_id_private, id);
- if (!id_priv->cm_id.ib)
- return -EINVAL;
-
- if (rdma_cap_ib_cm(id->device, id->port_num)) {
- if (id->qp_type == IB_QPT_UD)
- ret = cma_send_sidr_rep(id_priv, IB_SIDR_REJECT,
- private_data, private_data_len);
- else {
- cma_dbg(id_priv, "sending REJ\n");
- ret = ib_send_cm_rej(id_priv->cm_id.ib,
- IB_CM_REJ_CONSUMER_DEFINED, NULL,
- 0, private_data, private_data_len);
- }
- } else if (rdma_cap_iw_cm(id->device, id->port_num)) {
- ret = iw_cm_reject(id_priv->cm_id.iw,
- private_data, private_data_len);
- } else
- ret = -ENOSYS;
-
- return ret;
-}
-EXPORT_SYMBOL(rdma_reject);
-
-int rdma_disconnect(struct rdma_cm_id *id)
-{
- struct rdma_id_private *id_priv;
- int ret;
-
- id_priv = container_of(id, struct rdma_id_private, id);
- if (!id_priv->cm_id.ib)
- return -EINVAL;
-
- if (rdma_cap_ib_cm(id->device, id->port_num)) {
- ret = cma_modify_qp_err(id_priv);
- if (ret)
- goto out;
- /* Initiate or respond to a disconnect. */
- cma_dbg(id_priv, "sending DREQ\n");
- if (ib_send_cm_dreq(id_priv->cm_id.ib, NULL, 0)) {
- cma_dbg(id_priv, "sending DREP\n");
- ib_send_cm_drep(id_priv->cm_id.ib, NULL, 0);
- }
- } else if (rdma_cap_iw_cm(id->device, id->port_num)) {
- ret = iw_cm_disconnect(id_priv->cm_id.iw, 0);
- } else
- ret = -EINVAL;
-
-out:
- return ret;
-}
-EXPORT_SYMBOL(rdma_disconnect);
-
-static int cma_ib_mc_handler(int status, struct ib_sa_multicast *multicast)
-{
- struct rdma_id_private *id_priv;
- struct cma_multicast *mc = multicast->context;
- struct rdma_cm_event event;
- struct rdma_dev_addr *dev_addr;
- int ret;
- struct net_device *ndev = NULL;
- u16 vlan;
-
- id_priv = mc->id_priv;
- dev_addr = &id_priv->id.route.addr.dev_addr;
- if (cma_disable_callback(id_priv, RDMA_CM_ADDR_BOUND) &&
- cma_disable_callback(id_priv, RDMA_CM_ADDR_RESOLVED))
- return 0;
-
- mutex_lock(&id_priv->qp_mutex);
- if (!status && id_priv->id.qp)
- status = ib_attach_mcast(id_priv->id.qp, &multicast->rec.mgid,
- be16_to_cpu(multicast->rec.mlid));
- mutex_unlock(&id_priv->qp_mutex);
-
- memset(&event, 0, sizeof event);
- event.status = status;
- event.param.ud.private_data = mc->context;
- ndev = dev_get_by_index(&init_net, dev_addr->bound_dev_if);
- if (!ndev) {
- status = -ENODEV;
- } else {
- vlan = rdma_vlan_dev_vlan_id(ndev);
- dev_put(ndev);
- }
- if (!status) {
- event.event = RDMA_CM_EVENT_MULTICAST_JOIN;
- ib_init_ah_from_mcmember(id_priv->id.device,
- id_priv->id.port_num, &multicast->rec,
- &event.param.ud.ah_attr);
- event.param.ud.ah_attr.vlan_id = vlan;
- event.param.ud.qp_num = 0xFFFFFF;
- event.param.ud.qkey = be32_to_cpu(multicast->rec.qkey);
- } else {
- event.event = RDMA_CM_EVENT_MULTICAST_ERROR;
-
- /* mark that the cached record is no longer valid */
- if (status != -ENETRESET && status != -EAGAIN) {
- spin_lock(&id_priv->lock);
- id_priv->is_valid_rec = 0;
- spin_unlock(&id_priv->lock);
- }
- }
-
- ret = id_priv->id.event_handler(&id_priv->id, &event);
- if (ret) {
- cma_exch(id_priv, RDMA_CM_DESTROYING);
- mutex_unlock(&id_priv->handler_mutex);
- rdma_destroy_id(&id_priv->id);
- return 0;
- }
-
- mutex_unlock(&id_priv->handler_mutex);
- return 0;
-}
-
-static void cma_set_mgid(struct rdma_id_private *id_priv,
- struct sockaddr *addr, union ib_gid *mgid)
-{
- unsigned char mc_map[MAX_ADDR_LEN];
- struct rdma_dev_addr *dev_addr = &id_priv->id.route.addr.dev_addr;
- struct sockaddr_in *sin = (struct sockaddr_in *) addr;
-#if defined(INET6)
- struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *) addr;
-#endif
-
- if (cma_any_addr(addr)) {
- memset(mgid, 0, sizeof *mgid);
-#if defined(INET6)
- } else if ((addr->sa_family == AF_INET6) &&
- ((be32_to_cpu(sin6->sin6_addr.s6_addr32[0]) & 0xFFF0FFFF) ==
- 0xFF10A01B)) {
- /* IPv6 address is an SA assigned MGID. */
- memcpy(mgid, &sin6->sin6_addr, sizeof *mgid);
- } else if (addr->sa_family == AF_INET6) {
- ipv6_ib_mc_map(&sin6->sin6_addr, dev_addr->broadcast, mc_map);
- if (id_priv->id.ps == RDMA_PS_UDP)
- mc_map[7] = 0x01; /* Use RDMA CM signature */
- *mgid = *(union ib_gid *) (mc_map + 4);
-#endif
- } else {
- ip_ib_mc_map(sin->sin_addr.s_addr, dev_addr->broadcast, mc_map);
- if (id_priv->id.ps == RDMA_PS_UDP)
- mc_map[7] = 0x01; /* Use RDMA CM signature */
- *mgid = *(union ib_gid *) (mc_map + 4);
- }
-}
-
-static int cma_join_ib_multicast(struct rdma_id_private *id_priv,
- struct cma_multicast *mc)
-{
- struct ib_sa_mcmember_rec rec;
- struct rdma_dev_addr *dev_addr = &id_priv->id.route.addr.dev_addr;
- ib_sa_comp_mask comp_mask;
- int ret = 0;
-
- ib_addr_get_mgid(dev_addr, &id_priv->rec.mgid);
-
- /* cache ipoib bc record */
- spin_lock(&id_priv->lock);
- if (!id_priv->is_valid_rec)
- ret = ib_sa_get_mcmember_rec(id_priv->id.device,
- id_priv->id.port_num,
- &id_priv->rec.mgid,
- &id_priv->rec);
- if (ret) {
- id_priv->is_valid_rec = 0;
- spin_unlock(&id_priv->lock);
- return ret;
- } else {
- rec = id_priv->rec;
- id_priv->is_valid_rec = 1;
- }
- spin_unlock(&id_priv->lock);
-
- cma_set_mgid(id_priv, (struct sockaddr *) &mc->addr, &rec.mgid);
- if (id_priv->id.ps == RDMA_PS_UDP)
- rec.qkey = cpu_to_be32(RDMA_UDP_QKEY);
- rdma_addr_get_sgid(dev_addr, &rec.port_gid);
- rec.pkey = cpu_to_be16(ib_addr_get_pkey(dev_addr));
- rec.join_state = 1;
-
- comp_mask = IB_SA_MCMEMBER_REC_MGID | IB_SA_MCMEMBER_REC_PORT_GID |
- IB_SA_MCMEMBER_REC_PKEY | IB_SA_MCMEMBER_REC_JOIN_STATE |
- IB_SA_MCMEMBER_REC_QKEY | IB_SA_MCMEMBER_REC_SL |
- IB_SA_MCMEMBER_REC_FLOW_LABEL |
- IB_SA_MCMEMBER_REC_TRAFFIC_CLASS;
-
- if (id_priv->id.ps == RDMA_PS_IPOIB)
- comp_mask |= IB_SA_MCMEMBER_REC_RATE |
- IB_SA_MCMEMBER_REC_RATE_SELECTOR |
- IB_SA_MCMEMBER_REC_MTU_SELECTOR |
- IB_SA_MCMEMBER_REC_MTU |
- IB_SA_MCMEMBER_REC_HOP_LIMIT;
-
- mc->multicast.ib = ib_sa_join_multicast(&sa_client, id_priv->id.device,
- id_priv->id.port_num, &rec,
- comp_mask, GFP_KERNEL,
- cma_ib_mc_handler, mc);
- return PTR_RET(mc->multicast.ib);
-}
-
-static void iboe_mcast_work_handler(struct work_struct *work)
-{
- struct iboe_mcast_work *mw = container_of(work, struct iboe_mcast_work, work);
- struct cma_multicast *mc = mw->mc;
- struct ib_sa_multicast *m = mc->multicast.ib;
-
- mc->multicast.ib->context = mc;
- cma_ib_mc_handler(0, m);
- kref_put(&mc->mcref, release_mc);
- kfree(mw);
-}
-
-static void cma_iboe_set_mgid(struct sockaddr *addr, union ib_gid *mgid)
-{
- struct sockaddr_in *sin = (struct sockaddr_in *)addr;
- struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *)addr;
-
- if (cma_any_addr(addr)) {
- memset(mgid, 0, sizeof *mgid);
- } else if (addr->sa_family == AF_INET6) {
- memcpy(mgid, &sin6->sin6_addr, sizeof *mgid);
- } else {
- mgid->raw[0] = 0xff;
- mgid->raw[1] = 0x0e;
- mgid->raw[2] = 0;
- mgid->raw[3] = 0;
- mgid->raw[4] = 0;
- mgid->raw[5] = 0;
- mgid->raw[6] = 0;
- mgid->raw[7] = 0;
- mgid->raw[8] = 0;
- mgid->raw[9] = 0;
- mgid->raw[10] = 0xff;
- mgid->raw[11] = 0xff;
- *(__be32 *)(&mgid->raw[12]) = sin->sin_addr.s_addr;
- }
-}
-
-static int cma_iboe_join_multicast(struct rdma_id_private *id_priv,
- struct cma_multicast *mc)
-{
- struct iboe_mcast_work *work;
- struct rdma_dev_addr *dev_addr = &id_priv->id.route.addr.dev_addr;
- int err;
- struct sockaddr *addr = (struct sockaddr *)&mc->addr;
- struct net_device *ndev = NULL;
-
- if (cma_zero_addr((struct sockaddr *)&mc->addr))
- return -EINVAL;
-
- work = kzalloc(sizeof *work, GFP_KERNEL);
- if (!work)
- return -ENOMEM;
-
- mc->multicast.ib = kzalloc(sizeof(struct ib_sa_multicast), GFP_KERNEL);
- if (!mc->multicast.ib) {
- err = -ENOMEM;
- goto out1;
- }
-
- cma_iboe_set_mgid(addr, &mc->multicast.ib->rec.mgid);
-
- mc->multicast.ib->rec.pkey = cpu_to_be16(0xffff);
- if (id_priv->id.ps == RDMA_PS_UDP)
- mc->multicast.ib->rec.qkey = cpu_to_be32(RDMA_UDP_QKEY);
-
- if (dev_addr->bound_dev_if)
- ndev = dev_get_by_index(&init_net, dev_addr->bound_dev_if);
- if (!ndev) {
- err = -ENODEV;
- goto out2;
- }
- mc->multicast.ib->rec.rate = iboe_get_rate(ndev);
- mc->multicast.ib->rec.hop_limit = 1;
- mc->multicast.ib->rec.mtu = iboe_get_mtu(ndev->if_mtu);
- dev_put(ndev);
- if (!mc->multicast.ib->rec.mtu) {
- err = -EINVAL;
- goto out2;
- }
- rdma_ip2gid((struct sockaddr *)&id_priv->id.route.addr.src_addr,
- &mc->multicast.ib->rec.port_gid);
- work->id = id_priv;
- work->mc = mc;
- INIT_WORK(&work->work, iboe_mcast_work_handler);
- kref_get(&mc->mcref);
- queue_work(cma_wq, &work->work);
-
- return 0;
-
-out2:
- kfree(mc->multicast.ib);
-out1:
- kfree(work);
- return err;
-}
-
-int rdma_join_multicast(struct rdma_cm_id *id, struct sockaddr *addr,
- void *context)
-{
- struct rdma_id_private *id_priv;
- struct cma_multicast *mc;
- int ret;
-
- id_priv = container_of(id, struct rdma_id_private, id);
- if (!cma_comp(id_priv, RDMA_CM_ADDR_BOUND) &&
- !cma_comp(id_priv, RDMA_CM_ADDR_RESOLVED))
- return -EINVAL;
-
- mc = kmalloc(sizeof *mc, GFP_KERNEL);
- if (!mc)
- return -ENOMEM;
-
- memcpy(&mc->addr, addr, ip_addr_size(addr));
- mc->context = context;
- mc->id_priv = id_priv;
-
- spin_lock(&id_priv->lock);
- list_add(&mc->list, &id_priv->mc_list);
- spin_unlock(&id_priv->lock);
-
- switch (rdma_node_get_transport(id->device->node_type)) {
- case RDMA_TRANSPORT_IB:
- switch (rdma_port_get_link_layer(id->device, id->port_num)) {
- case IB_LINK_LAYER_INFINIBAND:
- ret = cma_join_ib_multicast(id_priv, mc);
- break;
- case IB_LINK_LAYER_ETHERNET:
- kref_init(&mc->mcref);
- ret = cma_iboe_join_multicast(id_priv, mc);
- break;
- default:
- ret = -EINVAL;
- }
- break;
- default:
- ret = -ENOSYS;
- break;
- }
-
- if (ret) {
- spin_lock_irq(&id_priv->lock);
- list_del(&mc->list);
- spin_unlock_irq(&id_priv->lock);
- kfree(mc);
- }
- return ret;
-}
-EXPORT_SYMBOL(rdma_join_multicast);
-
-void rdma_leave_multicast(struct rdma_cm_id *id, struct sockaddr *addr)
-{
- struct rdma_id_private *id_priv;
- struct cma_multicast *mc;
-
- id_priv = container_of(id, struct rdma_id_private, id);
- spin_lock_irq(&id_priv->lock);
- list_for_each_entry(mc, &id_priv->mc_list, list) {
- if (!memcmp(&mc->addr, addr, ip_addr_size(addr))) {
- list_del(&mc->list);
- spin_unlock_irq(&id_priv->lock);
-
- if (id->qp)
- ib_detach_mcast(id->qp,
- &mc->multicast.ib->rec.mgid,
- be16_to_cpu(mc->multicast.ib->rec.mlid));
- if (rdma_node_get_transport(id_priv->cma_dev->device->node_type) == RDMA_TRANSPORT_IB) {
- switch (rdma_port_get_link_layer(id->device, id->port_num)) {
- case IB_LINK_LAYER_INFINIBAND:
- ib_sa_free_multicast(mc->multicast.ib);
- kfree(mc);
- break;
- case IB_LINK_LAYER_ETHERNET:
- kref_put(&mc->mcref, release_mc);
- break;
- default:
- break;
- }
- }
- return;
- }
- }
- spin_unlock_irq(&id_priv->lock);
-}
-EXPORT_SYMBOL(rdma_leave_multicast);
-
-static int cma_netdev_change(struct net_device *ndev, struct rdma_id_private *id_priv)
-{
- struct rdma_dev_addr *dev_addr;
- struct cma_ndev_work *work;
-
- dev_addr = &id_priv->id.route.addr.dev_addr;
-
- if ((dev_addr->bound_dev_if == ndev->if_index) &&
- memcmp(dev_addr->src_dev_addr, IF_LLADDR(ndev), ndev->if_addrlen)) {
- printk(KERN_INFO "RDMA CM addr change for ndev %s used by id %p\n",
- ndev->if_xname, &id_priv->id);
- work = kzalloc(sizeof *work, GFP_KERNEL);
- if (!work)
- return -ENOMEM;
-
- INIT_WORK(&work->work, cma_ndev_work_handler);
- work->id = id_priv;
- work->event.event = RDMA_CM_EVENT_ADDR_CHANGE;
- atomic_inc(&id_priv->refcount);
- queue_work(cma_wq, &work->work);
- }
-
- return 0;
-}
-
-static int cma_netdev_callback(struct notifier_block *self, unsigned long event,
- void *ctx)
-{
- struct net_device *ndev = (struct net_device *)ctx;
- struct cma_device *cma_dev;
- struct rdma_id_private *id_priv;
- int ret = NOTIFY_DONE;
-
-/* BONDING related, commented out until the bonding is resolved */
-#if 0
- if (dev_net(ndev) != &init_net)
- return NOTIFY_DONE;
-
- if (event != NETDEV_BONDING_FAILOVER)
- return NOTIFY_DONE;
-
- if (!(ndev->flags & IFF_MASTER) || !(ndev->priv_flags & IFF_BONDING))
- return NOTIFY_DONE;
-#endif
- if (event != NETDEV_DOWN && event != NETDEV_UNREGISTER)
- return NOTIFY_DONE;
-
- mutex_lock(&lock);
- list_for_each_entry(cma_dev, &dev_list, list)
- list_for_each_entry(id_priv, &cma_dev->id_list, list) {
- ret = cma_netdev_change(ndev, id_priv);
- if (ret)
- goto out;
- }
-
-out:
- mutex_unlock(&lock);
- return ret;
-}
-
-static struct notifier_block cma_nb = {
- .notifier_call = cma_netdev_callback
-};
-
-static void cma_add_one(struct ib_device *device)
-{
- struct cma_device *cma_dev;
- struct rdma_id_private *id_priv;
-
- cma_dev = kmalloc(sizeof *cma_dev, GFP_KERNEL);
- if (!cma_dev)
- return;
-
- cma_dev->device = device;
-
- init_completion(&cma_dev->comp);
- atomic_set(&cma_dev->refcount, 1);
- INIT_LIST_HEAD(&cma_dev->id_list);
- ib_set_client_data(device, &cma_client, cma_dev);
-
- mutex_lock(&lock);
- list_add_tail(&cma_dev->list, &dev_list);
- list_for_each_entry(id_priv, &listen_any_list, list)
- cma_listen_on_dev(id_priv, cma_dev);
- mutex_unlock(&lock);
-}
-
-static int cma_remove_id_dev(struct rdma_id_private *id_priv)
-{
- struct rdma_cm_event event;
- enum rdma_cm_state state;
- int ret = 0;
-
- /* Record that we want to remove the device */
- state = cma_exch(id_priv, RDMA_CM_DEVICE_REMOVAL);
- if (state == RDMA_CM_DESTROYING)
- return 0;
-
- cma_cancel_operation(id_priv, state);
- mutex_lock(&id_priv->handler_mutex);
-
- /* Check for destruction from another callback. */
- if (!cma_comp(id_priv, RDMA_CM_DEVICE_REMOVAL))
- goto out;
-
- memset(&event, 0, sizeof event);
- event.event = RDMA_CM_EVENT_DEVICE_REMOVAL;
- ret = id_priv->id.event_handler(&id_priv->id, &event);
-out:
- mutex_unlock(&id_priv->handler_mutex);
- return ret;
-}
-
-static void cma_process_remove(struct cma_device *cma_dev)
-{
- struct rdma_id_private *id_priv;
- int ret;
-
- mutex_lock(&lock);
- while (!list_empty(&cma_dev->id_list)) {
- id_priv = list_entry(cma_dev->id_list.next,
- struct rdma_id_private, list);
-
- list_del(&id_priv->listen_list);
- list_del_init(&id_priv->list);
- atomic_inc(&id_priv->refcount);
- mutex_unlock(&lock);
-
- ret = id_priv->internal_id ? 1 : cma_remove_id_dev(id_priv);
- cma_deref_id(id_priv);
- if (ret)
- rdma_destroy_id(&id_priv->id);
-
- mutex_lock(&lock);
- }
- mutex_unlock(&lock);
-
- cma_deref_dev(cma_dev);
- wait_for_completion(&cma_dev->comp);
-}
-
-static void cma_remove_one(struct ib_device *device)
-{
- struct cma_device *cma_dev;
-
- cma_dev = ib_get_client_data(device, &cma_client);
- if (!cma_dev)
- return;
-
- mutex_lock(&lock);
- list_del(&cma_dev->list);
- mutex_unlock(&lock);
-
- cma_process_remove(cma_dev);
- kfree(cma_dev);
-}
-
-static int __init cma_init(void)
-{
- int ret = -ENOMEM;
-
- cma_wq = create_singlethread_workqueue("rdma_cm");
- if (!cma_wq)
- return -ENOMEM;
-
- cma_free_wq = create_singlethread_workqueue("rdma_cm_fr");
- if (!cma_free_wq)
- goto err1;
-
- ib_sa_register_client(&sa_client);
- rdma_addr_register_client(&addr_client);
- register_netdevice_notifier(&cma_nb);
-
- ret = ib_register_client(&cma_client);
- if (ret)
- goto err;
-
- return 0;
-
-err:
- unregister_netdevice_notifier(&cma_nb);
- rdma_addr_unregister_client(&addr_client);
- ib_sa_unregister_client(&sa_client);
-
- destroy_workqueue(cma_free_wq);
-err1:
- destroy_workqueue(cma_wq);
- return ret;
-}
-
-static void __exit cma_cleanup(void)
-{
- ib_unregister_client(&cma_client);
- unregister_netdevice_notifier(&cma_nb);
- rdma_addr_unregister_client(&addr_client);
- ib_sa_unregister_client(&sa_client);
- flush_workqueue(cma_free_wq);
- destroy_workqueue(cma_free_wq);
- destroy_workqueue(cma_wq);
- idr_destroy(&sdp_ps);
- idr_destroy(&tcp_ps);
- idr_destroy(&udp_ps);
- idr_destroy(&ipoib_ps);
- idr_destroy(&ib_ps);
-}
-
-module_init(cma_init);
-module_exit(cma_cleanup);
diff --git a/sys/ofed/drivers/infiniband/core/core_priv.h b/sys/ofed/drivers/infiniband/core/core_priv.h
index 001bbbe..830f61e 100644
--- a/sys/ofed/drivers/infiniband/core/core_priv.h
+++ b/sys/ofed/drivers/infiniband/core/core_priv.h
@@ -38,15 +38,112 @@
#include <rdma/ib_verbs.h>
+#include <net/if_vlan_var.h>
+
+#ifdef CONFIG_INFINIBAND_ADDR_TRANS_CONFIGFS
+int cma_configfs_init(void);
+void cma_configfs_exit(void);
+#else
+static inline int cma_configfs_init(void)
+{
+ return 0;
+}
+
+static inline void cma_configfs_exit(void)
+{
+}
+#endif
+struct cma_device;
+void cma_ref_dev(struct cma_device *cma_dev);
+void cma_deref_dev(struct cma_device *cma_dev);
+typedef bool (*cma_device_filter)(struct ib_device *, void *);
+struct cma_device *cma_enum_devices_by_ibdev(cma_device_filter filter,
+ void *cookie);
+int cma_get_default_gid_type(struct cma_device *cma_dev,
+ unsigned int port);
+int cma_set_default_gid_type(struct cma_device *cma_dev,
+ unsigned int port,
+ enum ib_gid_type default_gid_type);
+struct ib_device *cma_get_ib_dev(struct cma_device *cma_dev);
+
int ib_device_register_sysfs(struct ib_device *device,
int (*port_callback)(struct ib_device *,
- u8, struct kobject *));
+ u8, struct kobject *));
void ib_device_unregister_sysfs(struct ib_device *device);
-int ib_sysfs_setup(void);
-void ib_sysfs_cleanup(void);
-
-int ib_cache_setup(void);
+void ib_cache_setup(void);
void ib_cache_cleanup(void);
+int ib_resolve_eth_dmac(struct ib_qp *qp,
+ struct ib_qp_attr *qp_attr, int *qp_attr_mask);
+
+typedef void (*roce_netdev_callback)(struct ib_device *device, u8 port,
+ struct net_device *idev, void *cookie);
+
+typedef int (*roce_netdev_filter)(struct ib_device *device, u8 port,
+ struct net_device *idev, void *cookie);
+
+void ib_enum_roce_netdev(struct ib_device *ib_dev,
+ roce_netdev_filter filter,
+ void *filter_cookie,
+ roce_netdev_callback cb,
+ void *cookie);
+void ib_enum_all_roce_netdevs(roce_netdev_filter filter,
+ void *filter_cookie,
+ roce_netdev_callback cb,
+ void *cookie);
+
+enum ib_cache_gid_default_mode {
+ IB_CACHE_GID_DEFAULT_MODE_SET,
+ IB_CACHE_GID_DEFAULT_MODE_DELETE
+};
+
+int ib_cache_gid_parse_type_str(const char *buf);
+
+const char *ib_cache_gid_type_str(enum ib_gid_type gid_type);
+
+void ib_cache_gid_set_default_gid(struct ib_device *ib_dev, u8 port,
+ struct net_device *ndev,
+ unsigned long gid_type_mask,
+ enum ib_cache_gid_default_mode mode);
+
+int ib_cache_gid_add(struct ib_device *ib_dev, u8 port,
+ union ib_gid *gid, struct ib_gid_attr *attr);
+
+int ib_cache_gid_del(struct ib_device *ib_dev, u8 port,
+ union ib_gid *gid, struct ib_gid_attr *attr);
+
+int ib_cache_gid_del_all_netdev_gids(struct ib_device *ib_dev, u8 port,
+ struct net_device *ndev);
+void ib_cache_gid_del_all_by_netdev(struct net_device *ndev);
+
+int roce_gid_mgmt_init(void);
+void roce_gid_mgmt_cleanup(void);
+
+int roce_rescan_device(struct ib_device *ib_dev);
+unsigned long roce_gid_type_mask_support(struct ib_device *ib_dev, u8 port);
+
+int ib_cache_setup_one(struct ib_device *device);
+void ib_cache_cleanup_one(struct ib_device *device);
+void ib_cache_release_one(struct ib_device *device);
+
+static inline bool rdma_is_upper_dev_rcu(struct net_device *dev,
+ struct net_device *upper)
+{
+
+ /* TODO: add support for LAGG */
+ upper = VLAN_TRUNKDEV(upper);
+
+ return (dev == upper);
+}
+
+int addr_init(void);
+void addr_cleanup(void);
+
+int ib_mad_init(void);
+void ib_mad_cleanup(void);
+
+int ib_sa_init(void);
+void ib_sa_cleanup(void);
+
#endif /* _CORE_PRIV_H */
diff --git a/sys/ofed/drivers/infiniband/core/device.c b/sys/ofed/drivers/infiniband/core/device.c
deleted file mode 100644
index bb580ed..0000000
--- a/sys/ofed/drivers/infiniband/core/device.c
+++ /dev/null
@@ -1,791 +0,0 @@
-/*
- * Copyright (c) 2004 Topspin Communications. All rights reserved.
- * Copyright (c) 2005 Sun Microsystems, Inc. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-#include <linux/module.h>
-#include <linux/string.h>
-#include <linux/errno.h>
-#include <linux/kernel.h>
-#include <linux/slab.h>
-#include <linux/mutex.h>
-
-#include "core_priv.h"
-
-MODULE_AUTHOR("Roland Dreier");
-MODULE_DESCRIPTION("core kernel InfiniBand API");
-MODULE_LICENSE("Dual BSD/GPL");
-
-struct ib_client_data {
- struct list_head list;
- struct ib_client *client;
- void * data;
-};
-
-struct workqueue_struct *ib_wq;
-EXPORT_SYMBOL_GPL(ib_wq);
-
-static LIST_HEAD(device_list);
-static LIST_HEAD(client_list);
-
-/*
- * device_mutex protects access to both device_list and client_list.
- * There's no real point to using multiple locks or something fancier
- * like an rwsem: we always access both lists, and we're always
- * modifying one list or the other list. In any case this is not a
- * hot path so there's no point in trying to optimize.
- */
-static DEFINE_MUTEX(device_mutex);
-
-static int ib_device_check_mandatory(struct ib_device *device)
-{
-#define IB_MANDATORY_FUNC(x) { offsetof(struct ib_device, x), #x }
- static const struct {
- size_t offset;
- char *name;
- } mandatory_table[] = {
- IB_MANDATORY_FUNC(query_device),
- IB_MANDATORY_FUNC(query_port),
- IB_MANDATORY_FUNC(query_pkey),
- IB_MANDATORY_FUNC(query_gid),
- IB_MANDATORY_FUNC(alloc_pd),
- IB_MANDATORY_FUNC(dealloc_pd),
- IB_MANDATORY_FUNC(create_ah),
- IB_MANDATORY_FUNC(destroy_ah),
- IB_MANDATORY_FUNC(create_qp),
- IB_MANDATORY_FUNC(modify_qp),
- IB_MANDATORY_FUNC(destroy_qp),
- IB_MANDATORY_FUNC(post_send),
- IB_MANDATORY_FUNC(post_recv),
- IB_MANDATORY_FUNC(create_cq),
- IB_MANDATORY_FUNC(destroy_cq),
- IB_MANDATORY_FUNC(poll_cq),
- IB_MANDATORY_FUNC(req_notify_cq),
- IB_MANDATORY_FUNC(get_dma_mr),
- IB_MANDATORY_FUNC(dereg_mr),
- IB_MANDATORY_FUNC(get_port_immutable)
- };
- int i;
-
- for (i = 0; i < ARRAY_SIZE(mandatory_table); ++i) {
- if (!*(void **) ((void *) device + mandatory_table[i].offset)) {
- printk(KERN_WARNING "Device %s is missing mandatory function %s\n",
- device->name, mandatory_table[i].name);
- return -EINVAL;
- }
- }
-
- return 0;
-}
-
-static struct ib_device *__ib_device_get_by_name(const char *name)
-{
- struct ib_device *device;
-
- list_for_each_entry(device, &device_list, core_list)
- if (!strncmp(name, device->name, IB_DEVICE_NAME_MAX))
- return device;
-
- return NULL;
-}
-
-
-static int alloc_name(char *name)
-{
- unsigned long *inuse;
- char buf[IB_DEVICE_NAME_MAX];
- struct ib_device *device;
- int i;
-
- inuse = (unsigned long *) get_zeroed_page(GFP_KERNEL);
- if (!inuse)
- return -ENOMEM;
-
- list_for_each_entry(device, &device_list, core_list) {
- if (!sscanf(device->name, name, &i))
- continue;
- if (i < 0 || i >= PAGE_SIZE * 8)
- continue;
- snprintf(buf, sizeof buf, name, i);
- if (!strncmp(buf, device->name, IB_DEVICE_NAME_MAX))
- set_bit(i, inuse);
- }
-
- i = find_first_zero_bit(inuse, PAGE_SIZE * 8);
- free_page((unsigned long) inuse);
- snprintf(buf, sizeof buf, name, i);
-
- if (__ib_device_get_by_name(buf))
- return -ENFILE;
-
- strlcpy(name, buf, IB_DEVICE_NAME_MAX);
- return 0;
-}
-
-static int rdma_start_port(struct ib_device *device)
-{
- return (device->node_type == RDMA_NODE_IB_SWITCH) ? 0 : 1;
-}
-
-
-static int rdma_end_port(struct ib_device *device)
-{
- return (device->node_type == RDMA_NODE_IB_SWITCH) ?
- 0 : device->phys_port_cnt;
-}
-
-/**
- * ib_alloc_device - allocate an IB device struct
- * @size:size of structure to allocate
- *
- * Low-level drivers should use ib_alloc_device() to allocate &struct
- * ib_device. @size is the size of the structure to be allocated,
- * including any private data used by the low-level driver.
- * ib_dealloc_device() must be used to free structures allocated with
- * ib_alloc_device().
- */
-struct ib_device *ib_alloc_device(size_t size)
-{
- struct ib_device *dev;
-
- BUG_ON(size < sizeof (struct ib_device));
-
- dev = kzalloc(size, GFP_KERNEL);
- spin_lock_init(&dev->cmd_perf_lock);
-
- return dev;
-}
-EXPORT_SYMBOL(ib_alloc_device);
-
-/**
- * ib_dealloc_device - free an IB device struct
- * @device:structure to free
- *
- * Free a structure allocated with ib_alloc_device().
- */
-void ib_dealloc_device(struct ib_device *device)
-{
- if (device->reg_state == IB_DEV_UNINITIALIZED) {
- kfree(device->port_immutable);
- kfree(device);
- return;
- }
-
- BUG_ON(device->reg_state != IB_DEV_UNREGISTERED);
-
- kobject_put(&device->dev.kobj);
-}
-EXPORT_SYMBOL(ib_dealloc_device);
-
-static int add_client_context(struct ib_device *device, struct ib_client *client)
-{
- struct ib_client_data *context;
- unsigned long flags;
-
- context = kmalloc(sizeof *context, GFP_KERNEL);
- if (!context) {
- printk(KERN_WARNING "Couldn't allocate client context for %s/%s\n",
- device->name, client->name);
- return -ENOMEM;
- }
-
- context->client = client;
- context->data = NULL;
-
- spin_lock_irqsave(&device->client_data_lock, flags);
- list_add(&context->list, &device->client_data_list);
- spin_unlock_irqrestore(&device->client_data_lock, flags);
-
- return 0;
-}
-
-static int verify_immutable(const struct ib_device *dev, u8 port)
-{
- return WARN_ON(!rdma_cap_ib_mad(dev, port) &&
- rdma_max_mad_size(dev, port) != 0);
-}
-
-static int read_port_immutable(struct ib_device *device)
-{
- int ret;
- u8 start_port = rdma_start_port(device);
- u8 end_port = rdma_end_port(device);
- u8 port;
-
- /**
- * device->port_immutable is indexed directly by the port number to make
- * access to this data as efficient as possible.
- *
- * Therefore port_immutable is declared as a 1 based array with
- * potential empty slots at the beginning.
- */
- device->port_immutable = kzalloc(sizeof(*device->port_immutable)
- * (end_port + 1),
- GFP_KERNEL);
- if (!device->port_immutable)
- return -ENOMEM;
-
- for (port = start_port; port <= end_port; ++port) {
- ret = device->get_port_immutable(device, port,
- &device->port_immutable[port]);
- if (ret)
- return ret;
-
- if (verify_immutable(device, port))
- return -EINVAL;
- }
- return 0;
-}
-
-/**
- * ib_register_device - Register an IB device with IB core
- * @device:Device to register
- *
- * Low-level drivers use ib_register_device() to register their
- * devices with the IB core. All registered clients will receive a
- * callback for each device that is added. @device must be allocated
- * with ib_alloc_device().
- */
-int ib_register_device(struct ib_device *device,
- int (*port_callback)(struct ib_device *,
- u8, struct kobject *))
-{
- int ret;
-
- mutex_lock(&device_mutex);
-
- if (strchr(device->name, '%')) {
- ret = alloc_name(device->name);
- if (ret)
- goto out;
- }
-
- if (ib_device_check_mandatory(device)) {
- ret = -EINVAL;
- goto out;
- }
-
- INIT_LIST_HEAD(&device->event_handler_list);
- INIT_LIST_HEAD(&device->client_data_list);
- spin_lock_init(&device->event_handler_lock);
- spin_lock_init(&device->client_data_lock);
-
-
- ret = read_port_immutable(device);
- if (ret) {
- printk(KERN_WARNING "Couldn't create per port immutable data %s\n",
- device->name);
- goto out;
- }
-
- ret = ib_device_register_sysfs(device, port_callback);
- if (ret) {
- printk(KERN_WARNING "Couldn't register device %s with driver model\n",
- device->name);
- kfree(device->port_immutable);
- goto out;
- }
-
- list_add_tail(&device->core_list, &device_list);
-
- device->reg_state = IB_DEV_REGISTERED;
-
- {
- struct ib_client *client;
-
- list_for_each_entry(client, &client_list, list)
- if (client->add && !add_client_context(device, client))
- client->add(device);
- }
-
- out:
- mutex_unlock(&device_mutex);
- return ret;
-}
-EXPORT_SYMBOL(ib_register_device);
-
-/**
- * ib_unregister_device - Unregister an IB device
- * @device:Device to unregister
- *
- * Unregister an IB device. All clients will receive a remove callback.
- */
-void ib_unregister_device(struct ib_device *device)
-{
- struct ib_client *client;
- struct ib_client_data *context, *tmp;
- unsigned long flags;
-
- mutex_lock(&device_mutex);
-
- list_for_each_entry_reverse(client, &client_list, list)
- if (client->remove)
- client->remove(device);
-
- list_del(&device->core_list);
-
- mutex_unlock(&device_mutex);
-
- ib_device_unregister_sysfs(device);
-
- spin_lock_irqsave(&device->client_data_lock, flags);
- list_for_each_entry_safe(context, tmp, &device->client_data_list, list)
- kfree(context);
- spin_unlock_irqrestore(&device->client_data_lock, flags);
-
- device->reg_state = IB_DEV_UNREGISTERED;
-}
-EXPORT_SYMBOL(ib_unregister_device);
-
-/**
- * ib_register_client - Register an IB client
- * @client:Client to register
- *
- * Upper level users of the IB drivers can use ib_register_client() to
- * register callbacks for IB device addition and removal. When an IB
- * device is added, each registered client's add method will be called
- * (in the order the clients were registered), and when a device is
- * removed, each client's remove method will be called (in the reverse
- * order that clients were registered). In addition, when
- * ib_register_client() is called, the client will receive an add
- * callback for all devices already registered.
- */
-int ib_register_client(struct ib_client *client)
-{
- struct ib_device *device;
-
- mutex_lock(&device_mutex);
-
- list_add_tail(&client->list, &client_list);
- list_for_each_entry(device, &device_list, core_list)
- if (client->add && !add_client_context(device, client))
- client->add(device);
-
- mutex_unlock(&device_mutex);
-
- return 0;
-}
-EXPORT_SYMBOL(ib_register_client);
-
-/**
- * ib_unregister_client - Unregister an IB client
- * @client:Client to unregister
- *
- * Upper level users use ib_unregister_client() to remove their client
- * registration. When ib_unregister_client() is called, the client
- * will receive a remove callback for each IB device still registered.
- */
-void ib_unregister_client(struct ib_client *client)
-{
- struct ib_client_data *context, *tmp;
- struct ib_device *device;
- unsigned long flags;
-
- mutex_lock(&device_mutex);
-
- list_for_each_entry(device, &device_list, core_list) {
- if (client->remove)
- client->remove(device);
-
- spin_lock_irqsave(&device->client_data_lock, flags);
- list_for_each_entry_safe(context, tmp, &device->client_data_list, list)
- if (context->client == client) {
- list_del(&context->list);
- kfree(context);
- }
- spin_unlock_irqrestore(&device->client_data_lock, flags);
- }
- list_del(&client->list);
-
- mutex_unlock(&device_mutex);
-}
-EXPORT_SYMBOL(ib_unregister_client);
-
-/**
- * ib_get_client_data - Get IB client context
- * @device:Device to get context for
- * @client:Client to get context for
- *
- * ib_get_client_data() returns client context set with
- * ib_set_client_data().
- */
-void *ib_get_client_data(struct ib_device *device, struct ib_client *client)
-{
- struct ib_client_data *context;
- void *ret = NULL;
- unsigned long flags;
-
- spin_lock_irqsave(&device->client_data_lock, flags);
- list_for_each_entry(context, &device->client_data_list, list)
- if (context->client == client) {
- ret = context->data;
- break;
- }
- spin_unlock_irqrestore(&device->client_data_lock, flags);
-
- return ret;
-}
-EXPORT_SYMBOL(ib_get_client_data);
-
-/**
- * ib_set_client_data - Set IB client context
- * @device:Device to set context for
- * @client:Client to set context for
- * @data:Context to set
- *
- * ib_set_client_data() sets client context that can be retrieved with
- * ib_get_client_data().
- */
-void ib_set_client_data(struct ib_device *device, struct ib_client *client,
- void *data)
-{
- struct ib_client_data *context;
- unsigned long flags;
-
- spin_lock_irqsave(&device->client_data_lock, flags);
- list_for_each_entry(context, &device->client_data_list, list)
- if (context->client == client) {
- context->data = data;
- goto out;
- }
-
- printk(KERN_WARNING "No client context found for %s/%s\n",
- device->name, client->name);
-
-out:
- spin_unlock_irqrestore(&device->client_data_lock, flags);
-}
-EXPORT_SYMBOL(ib_set_client_data);
-
-/**
- * ib_register_event_handler - Register an IB event handler
- * @event_handler:Handler to register
- *
- * ib_register_event_handler() registers an event handler that will be
- * called back when asynchronous IB events occur (as defined in
- * chapter 11 of the InfiniBand Architecture Specification). This
- * callback may occur in interrupt context.
- */
-int ib_register_event_handler (struct ib_event_handler *event_handler)
-{
- unsigned long flags;
-
- spin_lock_irqsave(&event_handler->device->event_handler_lock, flags);
- list_add_tail(&event_handler->list,
- &event_handler->device->event_handler_list);
- spin_unlock_irqrestore(&event_handler->device->event_handler_lock, flags);
-
- return 0;
-}
-EXPORT_SYMBOL(ib_register_event_handler);
-
-/**
- * ib_unregister_event_handler - Unregister an event handler
- * @event_handler:Handler to unregister
- *
- * Unregister an event handler registered with
- * ib_register_event_handler().
- */
-int ib_unregister_event_handler(struct ib_event_handler *event_handler)
-{
- unsigned long flags;
-
- spin_lock_irqsave(&event_handler->device->event_handler_lock, flags);
- list_del(&event_handler->list);
- spin_unlock_irqrestore(&event_handler->device->event_handler_lock, flags);
-
- return 0;
-}
-EXPORT_SYMBOL(ib_unregister_event_handler);
-
-/**
- * ib_dispatch_event - Dispatch an asynchronous event
- * @event:Event to dispatch
- *
- * Low-level drivers must call ib_dispatch_event() to dispatch the
- * event to all registered event handlers when an asynchronous event
- * occurs.
- */
-void ib_dispatch_event(struct ib_event *event)
-{
- unsigned long flags;
- struct ib_event_handler *handler;
-
- spin_lock_irqsave(&event->device->event_handler_lock, flags);
-
- list_for_each_entry(handler, &event->device->event_handler_list, list)
- handler->handler(handler, event);
-
- spin_unlock_irqrestore(&event->device->event_handler_lock, flags);
-}
-EXPORT_SYMBOL(ib_dispatch_event);
-
-/**
- * ib_query_device - Query IB device attributes
- * @device:Device to query
- * @device_attr:Device attributes
- *
- * ib_query_device() returns the attributes of a device through the
- * @device_attr pointer.
- */
-int ib_query_device(struct ib_device *device,
- struct ib_device_attr *device_attr)
-{
- return device->query_device(device, device_attr);
-}
-EXPORT_SYMBOL(ib_query_device);
-
-/**
- * ib_query_port - Query IB port attributes
- * @device:Device to query
- * @port_num:Port number to query
- * @port_attr:Port attributes
- *
- * ib_query_port() returns the attributes of a port through the
- * @port_attr pointer.
- */
-int ib_query_port(struct ib_device *device,
- u8 port_num,
- struct ib_port_attr *port_attr)
-{
- if (port_num < rdma_start_port(device) || port_num > rdma_end_port(device))
- return -EINVAL;
-
- return device->query_port(device, port_num, port_attr);
-}
-EXPORT_SYMBOL(ib_query_port);
-
-/**
- * ib_query_gid - Get GID table entry
- * @device:Device to query
- * @port_num:Port number to query
- * @index:GID table index to query
- * @gid:Returned GID
- *
- * ib_query_gid() fetches the specified GID table entry.
- */
-int ib_query_gid(struct ib_device *device,
- u8 port_num, int index, union ib_gid *gid)
-{
- return device->query_gid(device, port_num, index, gid);
-}
-EXPORT_SYMBOL(ib_query_gid);
-
-/**
- * ib_query_pkey - Get P_Key table entry
- * @device:Device to query
- * @port_num:Port number to query
- * @index:P_Key table index to query
- * @pkey:Returned P_Key
- *
- * ib_query_pkey() fetches the specified P_Key table entry.
- */
-int ib_query_pkey(struct ib_device *device,
- u8 port_num, u16 index, u16 *pkey)
-{
- return device->query_pkey(device, port_num, index, pkey);
-}
-EXPORT_SYMBOL(ib_query_pkey);
-
-/**
- * ib_modify_device - Change IB device attributes
- * @device:Device to modify
- * @device_modify_mask:Mask of attributes to change
- * @device_modify:New attribute values
- *
- * ib_modify_device() changes a device's attributes as specified by
- * the @device_modify_mask and @device_modify structure.
- */
-int ib_modify_device(struct ib_device *device,
- int device_modify_mask,
- struct ib_device_modify *device_modify)
-{
- if (!device->modify_device)
- return -ENOSYS;
-
- return device->modify_device(device, device_modify_mask,
- device_modify);
-}
-EXPORT_SYMBOL(ib_modify_device);
-
-/**
- * ib_modify_port - Modifies the attributes for the specified port.
- * @device: The device to modify.
- * @port_num: The number of the port to modify.
- * @port_modify_mask: Mask used to specify which attributes of the port
- * to change.
- * @port_modify: New attribute values for the port.
- *
- * ib_modify_port() changes a port's attributes as specified by the
- * @port_modify_mask and @port_modify structure.
- */
-int ib_modify_port(struct ib_device *device,
- u8 port_num, int port_modify_mask,
- struct ib_port_modify *port_modify)
-{
- if (!device->modify_port)
- return -ENOSYS;
-
- if (port_num < rdma_start_port(device) || port_num > rdma_end_port(device))
- return -EINVAL;
-
- return device->modify_port(device, port_num, port_modify_mask,
- port_modify);
-}
-EXPORT_SYMBOL(ib_modify_port);
-
-/**
- * ib_find_gid - Returns the port number and GID table index where
- * a specified GID value occurs.
- * @device: The device to query.
- * @gid: The GID value to search for.
- * @port_num: The port number of the device where the GID value was found.
- * @index: The index into the GID table where the GID was found. This
- * parameter may be NULL.
- */
-int ib_find_gid(struct ib_device *device, union ib_gid *gid,
- u8 *port_num, u16 *index)
-{
- union ib_gid tmp_gid;
- int ret, port, i;
-
- for (port = rdma_start_port(device); port <= rdma_end_port(device); ++port) {
- for (i = 0; i < device->port_immutable[port].gid_tbl_len; ++i) {
- ret = ib_query_gid(device, port, i, &tmp_gid);
- if (ret)
- return ret;
- if (!memcmp(&tmp_gid, gid, sizeof *gid)) {
- *port_num = port;
- if (index)
- *index = i;
- return 0;
- }
- }
- }
-
- return -ENOENT;
-}
-EXPORT_SYMBOL(ib_find_gid);
-
-/**
- * ib_find_pkey - Returns the PKey table index where a specified
- * PKey value occurs.
- * @device: The device to query.
- * @port_num: The port number of the device to search for the PKey.
- * @pkey: The PKey value to search for.
- * @index: The index into the PKey table where the PKey was found.
- */
-int ib_find_pkey(struct ib_device *device,
- u8 port_num, u16 pkey, u16 *index)
-{
- int ret, i;
- u16 tmp_pkey;
- int partial_ix = -1;
-
- for (i = 0; i < device->port_immutable[port_num].pkey_tbl_len; ++i) {
- ret = ib_query_pkey(device, port_num, i, &tmp_pkey);
- if (ret)
- return ret;
- if ((pkey & 0x7fff) == (tmp_pkey & 0x7fff)) {
- /* if there is full-member pkey take it.*/
- if (tmp_pkey & 0x8000) {
- *index = i;
- return 0;
- }
- if (partial_ix < 0)
- partial_ix = i;
- }
- }
-
- /*no full-member, if exists take the limited*/
- if (partial_ix >= 0) {
- *index = partial_ix;
- return 0;
- }
- return -ENOENT;
-}
-EXPORT_SYMBOL(ib_find_pkey);
-
-static int __init ib_core_init(void)
-{
- int ret;
-
- ib_wq = create_workqueue("infiniband");
- if (!ib_wq)
- return -ENOMEM;
-
- ret = ib_sysfs_setup();
- if (ret) {
- printk(KERN_WARNING "Couldn't create InfiniBand device class\n");
- goto err;
- }
-
- ret = ib_cache_setup();
- if (ret) {
- printk(KERN_WARNING "Couldn't set up InfiniBand P_Key/GID cache\n");
- goto err_sysfs;
- }
-
- return 0;
-
-err_sysfs:
- ib_sysfs_cleanup();
-
-err:
- destroy_workqueue(ib_wq);
- return ret;
-}
-
-static void __exit ib_core_cleanup(void)
-{
- ib_cache_cleanup();
- ib_sysfs_cleanup();
- /* Make sure that any pending umem accounting work is done. */
- destroy_workqueue(ib_wq);
-}
-
-module_init(ib_core_init);
-module_exit(ib_core_cleanup);
-
-static int
-ibcore_evhand(module_t mod, int event, void *arg)
-{
- return (0);
-}
-
-static moduledata_t ibcore_mod = {
- .name = "ibcore",
- .evhand = ibcore_evhand,
-};
-
-MODULE_VERSION(ibcore, 1);
-MODULE_DEPEND(ibcore, linuxkpi, 1, 1, 1);
-DECLARE_MODULE(ibcore, ibcore_mod, SI_SUB_LAST, SI_ORDER_ANY);
diff --git a/sys/ofed/drivers/infiniband/core/fmr_pool.c b/sys/ofed/drivers/infiniband/core/fmr_pool.c
deleted file mode 100644
index 733aa38..0000000
--- a/sys/ofed/drivers/infiniband/core/fmr_pool.c
+++ /dev/null
@@ -1,545 +0,0 @@
-/*
- * Copyright (c) 2004 Topspin Communications. All rights reserved.
- * Copyright (c) 2005 Sun Microsystems, Inc. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-#include <linux/errno.h>
-#include <linux/spinlock.h>
-#include <linux/module.h>
-#include <linux/slab.h>
-#include <linux/jhash.h>
-#include <linux/kthread.h>
-#include <linux/wait.h>
-
-#include <rdma/ib_fmr_pool.h>
-
-#include "core_priv.h"
-
-#define PFX "fmr_pool: "
-
-enum {
- IB_FMR_MAX_REMAPS = 32,
-
- IB_FMR_HASH_BITS = 8,
- IB_FMR_HASH_SIZE = 1 << IB_FMR_HASH_BITS,
- IB_FMR_HASH_MASK = IB_FMR_HASH_SIZE - 1
-};
-
-/*
- * If an FMR is not in use, then the list member will point to either
- * its pool's free_list (if the FMR can be mapped again; that is,
- * remap_count < pool->max_remaps) or its pool's dirty_list (if the
- * FMR needs to be unmapped before being remapped). In either of
- * these cases it is a bug if the ref_count is not 0. In other words,
- * if ref_count is > 0, then the list member must not be linked into
- * either free_list or dirty_list.
- *
- * The cache_node member is used to link the FMR into a cache bucket
- * (if caching is enabled). This is independent of the reference
- * count of the FMR. When a valid FMR is released, its ref_count is
- * decremented, and if ref_count reaches 0, the FMR is placed in
- * either free_list or dirty_list as appropriate. However, it is not
- * removed from the cache and may be "revived" if a call to
- * ib_fmr_register_physical() occurs before the FMR is remapped. In
- * this case we just increment the ref_count and remove the FMR from
- * free_list/dirty_list.
- *
- * Before we remap an FMR from free_list, we remove it from the cache
- * (to prevent another user from obtaining a stale FMR). When an FMR
- * is released, we add it to the tail of the free list, so that our
- * cache eviction policy is "least recently used."
- *
- * All manipulation of ref_count, list and cache_node is protected by
- * pool_lock to maintain consistency.
- */
-
-struct ib_fmr_pool {
- spinlock_t pool_lock;
-
- int pool_size;
- int max_pages;
- int max_remaps;
- int dirty_watermark;
- int dirty_len;
- struct list_head free_list;
- struct list_head dirty_list;
- struct hlist_head *cache_bucket;
-
- void (*flush_function)(struct ib_fmr_pool *pool,
- void * arg);
- void *flush_arg;
-
- struct task_struct *thread;
-
- atomic_t req_ser;
- atomic_t flush_ser;
-
- wait_queue_head_t force_wait;
-};
-
-static inline u32 ib_fmr_hash(u64 first_page)
-{
- return jhash_2words((u32) first_page, (u32) (first_page >> 32), 0) &
- (IB_FMR_HASH_SIZE - 1);
-}
-
-/* Caller must hold pool_lock */
-static inline struct ib_pool_fmr *ib_fmr_cache_lookup(struct ib_fmr_pool *pool,
- u64 *page_list,
- int page_list_len,
- u64 io_virtual_address)
-{
- struct hlist_head *bucket;
- struct ib_pool_fmr *fmr;
-
- if (!pool->cache_bucket)
- return NULL;
-
- bucket = pool->cache_bucket + ib_fmr_hash(*page_list);
-
- hlist_for_each_entry(fmr, bucket, cache_node)
- if (io_virtual_address == fmr->io_virtual_address &&
- page_list_len == fmr->page_list_len &&
- !memcmp(page_list, fmr->page_list,
- page_list_len * sizeof *page_list))
- return fmr;
-
- return NULL;
-}
-
-static void ib_fmr_batch_release(struct ib_fmr_pool *pool)
-{
- int ret;
- struct ib_pool_fmr *fmr;
- LIST_HEAD(unmap_list);
- LIST_HEAD(fmr_list);
-
- spin_lock_irq(&pool->pool_lock);
-
- list_for_each_entry(fmr, &pool->dirty_list, list) {
- hlist_del_init(&fmr->cache_node);
- fmr->remap_count = 0;
- list_add_tail(&fmr->fmr->list, &fmr_list);
-
-#ifdef DEBUG
- if (fmr->ref_count !=0) {
- printk(KERN_WARNING PFX "Unmapping FMR %p with ref count %d\n",
- fmr, fmr->ref_count);
- }
-#endif
- }
-
- list_splice_init(&pool->dirty_list, &unmap_list);
- pool->dirty_len = 0;
-
- spin_unlock_irq(&pool->pool_lock);
-
- if (list_empty(&unmap_list)) {
- return;
- }
-
- ret = ib_unmap_fmr(&fmr_list);
- if (ret)
- printk(KERN_WARNING PFX "ib_unmap_fmr returned %d\n", ret);
-
- spin_lock_irq(&pool->pool_lock);
- list_splice(&unmap_list, &pool->free_list);
- spin_unlock_irq(&pool->pool_lock);
-}
-
-static int ib_fmr_cleanup_thread(void *pool_ptr)
-{
- struct ib_fmr_pool *pool = pool_ptr;
-
- do {
- if (atomic_read(&pool->flush_ser) - atomic_read(&pool->req_ser) < 0) {
- ib_fmr_batch_release(pool);
-
- atomic_inc(&pool->flush_ser);
- wake_up_interruptible(&pool->force_wait);
-
- if (pool->flush_function)
- pool->flush_function(pool, pool->flush_arg);
- }
-
- set_current_state(TASK_INTERRUPTIBLE);
- if (atomic_read(&pool->flush_ser) - atomic_read(&pool->req_ser) >= 0 &&
- !kthread_should_stop())
- schedule();
- __set_current_state(TASK_RUNNING);
- } while (!kthread_should_stop());
-
- return 0;
-}
-
-/**
- * ib_create_fmr_pool - Create an FMR pool
- * @pd:Protection domain for FMRs
- * @params:FMR pool parameters
- *
- * Create a pool of FMRs. Return value is pointer to new pool or
- * error code if creation failed.
- */
-struct ib_fmr_pool *ib_create_fmr_pool(struct ib_pd *pd,
- struct ib_fmr_pool_param *params)
-{
- struct ib_device *device;
- struct ib_fmr_pool *pool;
- struct ib_device_attr *attr;
- int i;
- int ret;
- int max_remaps;
-
- if (!params)
- return ERR_PTR(-EINVAL);
-
- device = pd->device;
- if (!device->alloc_fmr || !device->dealloc_fmr ||
- !device->map_phys_fmr || !device->unmap_fmr) {
- printk(KERN_INFO PFX "Device %s does not support FMRs\n",
- device->name);
- return ERR_PTR(-ENOSYS);
- }
-
- attr = kmalloc(sizeof *attr, GFP_KERNEL);
- if (!attr) {
- printk(KERN_WARNING PFX "couldn't allocate device attr struct\n");
- return ERR_PTR(-ENOMEM);
- }
-
- ret = ib_query_device(device, attr);
- if (ret) {
- printk(KERN_WARNING PFX "couldn't query device: %d\n", ret);
- kfree(attr);
- return ERR_PTR(ret);
- }
-
- if (!attr->max_map_per_fmr)
- max_remaps = IB_FMR_MAX_REMAPS;
- else
- max_remaps = attr->max_map_per_fmr;
-
- kfree(attr);
-
- pool = kmalloc(sizeof *pool, GFP_KERNEL);
- if (!pool) {
- printk(KERN_WARNING PFX "couldn't allocate pool struct\n");
- return ERR_PTR(-ENOMEM);
- }
-
- pool->cache_bucket = NULL;
-
- pool->flush_function = params->flush_function;
- pool->flush_arg = params->flush_arg;
-
- INIT_LIST_HEAD(&pool->free_list);
- INIT_LIST_HEAD(&pool->dirty_list);
-
- if (params->cache) {
- pool->cache_bucket =
- kmalloc(IB_FMR_HASH_SIZE * sizeof *pool->cache_bucket,
- GFP_KERNEL);
- if (!pool->cache_bucket) {
- printk(KERN_WARNING PFX "Failed to allocate cache in pool\n");
- ret = -ENOMEM;
- goto out_free_pool;
- }
-
- for (i = 0; i < IB_FMR_HASH_SIZE; ++i)
- INIT_HLIST_HEAD(pool->cache_bucket + i);
- }
-
- pool->pool_size = 0;
- pool->max_pages = params->max_pages_per_fmr;
- pool->max_remaps = max_remaps;
- pool->dirty_watermark = params->dirty_watermark;
- pool->dirty_len = 0;
- spin_lock_init(&pool->pool_lock);
- atomic_set(&pool->req_ser, 0);
- atomic_set(&pool->flush_ser, 0);
- init_waitqueue_head(&pool->force_wait);
-
- pool->thread = kthread_run(ib_fmr_cleanup_thread,
- pool,
- "ib_fmr(%s)",
- device->name);
- if (IS_ERR(pool->thread)) {
- printk(KERN_WARNING PFX "couldn't start cleanup thread\n");
- ret = PTR_ERR(pool->thread);
- goto out_free_pool;
- }
-
- {
- struct ib_pool_fmr *fmr;
- struct ib_fmr_attr fmr_attr = {
- .max_pages = params->max_pages_per_fmr,
- .max_maps = pool->max_remaps,
- .page_shift = params->page_shift
- };
- int bytes_per_fmr = sizeof *fmr;
-
- if (pool->cache_bucket)
- bytes_per_fmr += params->max_pages_per_fmr * sizeof (u64);
-
- for (i = 0; i < params->pool_size; ++i) {
- fmr = kmalloc(bytes_per_fmr, GFP_KERNEL);
- if (!fmr) {
- printk(KERN_WARNING PFX "failed to allocate fmr "
- "struct for FMR %d\n", i);
- goto out_fail;
- }
-
- fmr->pool = pool;
- fmr->remap_count = 0;
- fmr->ref_count = 0;
- INIT_HLIST_NODE(&fmr->cache_node);
-
- fmr->fmr = ib_alloc_fmr(pd, params->access, &fmr_attr);
- if (IS_ERR(fmr->fmr)) {
- printk(KERN_WARNING PFX "fmr_create failed "
- "for FMR %d\n", i);
- kfree(fmr);
- goto out_fail;
- }
-
- list_add_tail(&fmr->list, &pool->free_list);
- ++pool->pool_size;
- }
- }
-
- return pool;
-
- out_free_pool:
- kfree(pool->cache_bucket);
- kfree(pool);
-
- return ERR_PTR(ret);
-
- out_fail:
- ib_destroy_fmr_pool(pool);
-
- return ERR_PTR(-ENOMEM);
-}
-EXPORT_SYMBOL(ib_create_fmr_pool);
-
-/**
- * ib_destroy_fmr_pool - Free FMR pool
- * @pool:FMR pool to free
- *
- * Destroy an FMR pool and free all associated resources.
- */
-void ib_destroy_fmr_pool(struct ib_fmr_pool *pool)
-{
- struct ib_pool_fmr *fmr;
- struct ib_pool_fmr *tmp;
- LIST_HEAD(fmr_list);
- int i;
-
- kthread_stop(pool->thread);
- ib_fmr_batch_release(pool);
-
- i = 0;
- list_for_each_entry_safe(fmr, tmp, &pool->free_list, list) {
- if (fmr->remap_count) {
- INIT_LIST_HEAD(&fmr_list);
- list_add_tail(&fmr->fmr->list, &fmr_list);
- ib_unmap_fmr(&fmr_list);
- }
- ib_dealloc_fmr(fmr->fmr);
- list_del(&fmr->list);
- kfree(fmr);
- ++i;
- }
-
- if (i < pool->pool_size)
- printk(KERN_WARNING PFX "pool still has %d regions registered\n",
- pool->pool_size - i);
-
- kfree(pool->cache_bucket);
- kfree(pool);
-}
-EXPORT_SYMBOL(ib_destroy_fmr_pool);
-
-/**
- * ib_flush_fmr_pool - Invalidate all unmapped FMRs
- * @pool:FMR pool to flush
- *
- * Ensure that all unmapped FMRs are fully invalidated.
- */
-int ib_flush_fmr_pool(struct ib_fmr_pool *pool)
-{
- int serial;
- struct ib_pool_fmr *fmr, *next;
-
- /*
- * The free_list holds FMRs that may have been used
- * but have not been remapped enough times to be dirty.
- * Put them on the dirty list now so that the cleanup
- * thread will reap them too.
- */
- spin_lock_irq(&pool->pool_lock);
- list_for_each_entry_safe(fmr, next, &pool->free_list, list) {
- if (fmr->remap_count > 0)
- list_move(&fmr->list, &pool->dirty_list);
- }
- spin_unlock_irq(&pool->pool_lock);
-
- serial = atomic_inc_return(&pool->req_ser);
- wake_up_process(pool->thread);
-
- if (wait_event_interruptible(pool->force_wait,
- atomic_read(&pool->flush_ser) - serial >= 0))
- return -EINTR;
-
- return 0;
-}
-EXPORT_SYMBOL(ib_flush_fmr_pool);
-
-/**
- * ib_fmr_pool_map_phys -
- * @pool:FMR pool to allocate FMR from
- * @page_list:List of pages to map
- * @list_len:Number of pages in @page_list
- * @io_virtual_address:I/O virtual address for new FMR
- *
- * Map an FMR from an FMR pool.
- */
-struct ib_pool_fmr *ib_fmr_pool_map_phys(struct ib_fmr_pool *pool_handle,
- u64 *page_list,
- int list_len,
- u64 io_virtual_address)
-{
- struct ib_fmr_pool *pool = pool_handle;
- struct ib_pool_fmr *fmr;
- unsigned long flags;
- int result;
-
- if (list_len < 1 || list_len > pool->max_pages)
- return ERR_PTR(-EINVAL);
-
- spin_lock_irqsave(&pool->pool_lock, flags);
- fmr = ib_fmr_cache_lookup(pool,
- page_list,
- list_len,
- io_virtual_address);
- if (fmr) {
- /* found in cache */
- ++fmr->ref_count;
- if (fmr->ref_count == 1) {
- list_del(&fmr->list);
- }
-
- spin_unlock_irqrestore(&pool->pool_lock, flags);
-
- return fmr;
- }
-
- if (list_empty(&pool->free_list)) {
- spin_unlock_irqrestore(&pool->pool_lock, flags);
- return ERR_PTR(-EAGAIN);
- }
-
- fmr = list_entry(pool->free_list.next, struct ib_pool_fmr, list);
- list_del(&fmr->list);
- hlist_del_init(&fmr->cache_node);
- spin_unlock_irqrestore(&pool->pool_lock, flags);
-
- result = ib_map_phys_fmr(fmr->fmr, page_list, list_len,
- io_virtual_address);
-
- if (result) {
- spin_lock_irqsave(&pool->pool_lock, flags);
- list_add(&fmr->list, &pool->free_list);
- spin_unlock_irqrestore(&pool->pool_lock, flags);
-
- printk(KERN_WARNING PFX "fmr_map returns %d\n", result);
-
- return ERR_PTR(result);
- }
-
- ++fmr->remap_count;
- fmr->ref_count = 1;
-
- if (pool->cache_bucket) {
- fmr->io_virtual_address = io_virtual_address;
- fmr->page_list_len = list_len;
- memcpy(fmr->page_list, page_list, list_len * sizeof(*page_list));
-
- spin_lock_irqsave(&pool->pool_lock, flags);
- hlist_add_head(&fmr->cache_node,
- pool->cache_bucket + ib_fmr_hash(fmr->page_list[0]));
- spin_unlock_irqrestore(&pool->pool_lock, flags);
- }
-
- return fmr;
-}
-EXPORT_SYMBOL(ib_fmr_pool_map_phys);
-
-/**
- * ib_fmr_pool_unmap - Unmap FMR
- * @fmr:FMR to unmap
- *
- * Unmap an FMR. The FMR mapping may remain valid until the FMR is
- * reused (or until ib_flush_fmr_pool() is called).
- */
-int ib_fmr_pool_unmap(struct ib_pool_fmr *fmr)
-{
- struct ib_fmr_pool *pool;
- unsigned long flags;
-
- pool = fmr->pool;
-
- spin_lock_irqsave(&pool->pool_lock, flags);
-
- --fmr->ref_count;
- if (!fmr->ref_count) {
- if (fmr->remap_count < pool->max_remaps) {
- list_add_tail(&fmr->list, &pool->free_list);
- } else {
- list_add_tail(&fmr->list, &pool->dirty_list);
- if (++pool->dirty_len >= pool->dirty_watermark) {
- atomic_inc(&pool->req_ser);
- wake_up_process(pool->thread);
- }
- }
- }
-
-#ifdef DEBUG
- if (fmr->ref_count < 0)
- printk(KERN_WARNING PFX "FMR %p has ref count %d < 0\n",
- fmr, fmr->ref_count);
-#endif
-
- spin_unlock_irqrestore(&pool->pool_lock, flags);
-
- return 0;
-}
-EXPORT_SYMBOL(ib_fmr_pool_unmap);
diff --git a/sys/ofed/drivers/infiniband/core/ib_addr.c b/sys/ofed/drivers/infiniband/core/ib_addr.c
new file mode 100644
index 0000000..ccd323a
--- /dev/null
+++ b/sys/ofed/drivers/infiniband/core/ib_addr.c
@@ -0,0 +1,819 @@
+/*
+ * Copyright (c) 2005 Voltaire Inc. All rights reserved.
+ * Copyright (c) 2002-2005, Network Appliance, Inc. All rights reserved.
+ * Copyright (c) 1999-2005, Mellanox Technologies, Inc. All rights reserved.
+ * Copyright (c) 2005 Intel Corporation. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#include <linux/mutex.h>
+#include <linux/inetdevice.h>
+#include <linux/slab.h>
+#include <linux/workqueue.h>
+#include <linux/module.h>
+#include <net/route.h>
+#include <net/netevent.h>
+#include <rdma/ib_addr.h>
+#include <rdma/ib.h>
+
+#include <netinet/if_ether.h>
+#include <netinet/ip_var.h>
+#include <netinet6/scope6_var.h>
+#include <netinet6/in6_pcb.h>
+
+#include "core_priv.h"
+
+struct addr_req {
+ struct list_head list;
+ struct sockaddr_storage src_addr;
+ struct sockaddr_storage dst_addr;
+ struct rdma_dev_addr *addr;
+ struct rdma_addr_client *client;
+ void *context;
+ void (*callback)(int status, struct sockaddr *src_addr,
+ struct rdma_dev_addr *addr, void *context);
+ unsigned long timeout;
+ int status;
+};
+
+static void process_req(struct work_struct *work);
+
+static DEFINE_MUTEX(lock);
+static LIST_HEAD(req_list);
+static DECLARE_DELAYED_WORK(work, process_req);
+static struct workqueue_struct *addr_wq;
+
+int rdma_addr_size(struct sockaddr *addr)
+{
+ switch (addr->sa_family) {
+ case AF_INET:
+ return sizeof(struct sockaddr_in);
+ case AF_INET6:
+ return sizeof(struct sockaddr_in6);
+ case AF_IB:
+ return sizeof(struct sockaddr_ib);
+ default:
+ return 0;
+ }
+}
+EXPORT_SYMBOL(rdma_addr_size);
+
+static struct rdma_addr_client self;
+
+void rdma_addr_register_client(struct rdma_addr_client *client)
+{
+ atomic_set(&client->refcount, 1);
+ init_completion(&client->comp);
+}
+EXPORT_SYMBOL(rdma_addr_register_client);
+
+static inline void put_client(struct rdma_addr_client *client)
+{
+ if (atomic_dec_and_test(&client->refcount))
+ complete(&client->comp);
+}
+
+void rdma_addr_unregister_client(struct rdma_addr_client *client)
+{
+ put_client(client);
+ wait_for_completion(&client->comp);
+}
+EXPORT_SYMBOL(rdma_addr_unregister_client);
+
+static inline void
+rdma_copy_addr_sub(u8 *dst, const u8 *src, unsigned min, unsigned max)
+{
+ if (min > max)
+ min = max;
+ memcpy(dst, src, min);
+ memset(dst + min, 0, max - min);
+}
+
+int rdma_copy_addr(struct rdma_dev_addr *dev_addr, struct net_device *dev,
+ const unsigned char *dst_dev_addr)
+{
+ if (dev->if_type == IFT_INFINIBAND)
+ dev_addr->dev_type = ARPHRD_INFINIBAND;
+ else if (dev->if_type == IFT_ETHER)
+ dev_addr->dev_type = ARPHRD_ETHER;
+ else
+ dev_addr->dev_type = 0;
+ rdma_copy_addr_sub(dev_addr->src_dev_addr, IF_LLADDR(dev),
+ dev->if_addrlen, MAX_ADDR_LEN);
+ rdma_copy_addr_sub(dev_addr->broadcast, dev->if_broadcastaddr,
+ dev->if_addrlen, MAX_ADDR_LEN);
+ if (dst_dev_addr != NULL) {
+ rdma_copy_addr_sub(dev_addr->dst_dev_addr, dst_dev_addr,
+ dev->if_addrlen, MAX_ADDR_LEN);
+ }
+ dev_addr->bound_dev_if = dev->if_index;
+ return 0;
+}
+EXPORT_SYMBOL(rdma_copy_addr);
+
+int rdma_translate_ip(const struct sockaddr *addr,
+ struct rdma_dev_addr *dev_addr,
+ u16 *vlan_id)
+{
+ struct net_device *dev = NULL;
+ int ret = -EADDRNOTAVAIL;
+
+ if (dev_addr->bound_dev_if) {
+ dev = dev_get_by_index(dev_addr->net, dev_addr->bound_dev_if);
+ if (!dev)
+ return -ENODEV;
+ ret = rdma_copy_addr(dev_addr, dev, NULL);
+ dev_put(dev);
+ return ret;
+ }
+
+ switch (addr->sa_family) {
+#ifdef INET
+ case AF_INET:
+ dev = ip_dev_find(dev_addr->net,
+ ((const struct sockaddr_in *)addr)->sin_addr.s_addr);
+ break;
+#endif
+#ifdef INET6
+ case AF_INET6:
+ dev = ip6_dev_find(dev_addr->net,
+ ((const struct sockaddr_in6 *)addr)->sin6_addr);
+ break;
+#endif
+ default:
+ break;
+ }
+
+ if (dev != NULL) {
+ ret = rdma_copy_addr(dev_addr, dev, NULL);
+ if (vlan_id)
+ *vlan_id = rdma_vlan_dev_vlan_id(dev);
+ dev_put(dev);
+ }
+ return ret;
+}
+EXPORT_SYMBOL(rdma_translate_ip);
+
+static void set_timeout(unsigned long time)
+{
+ int delay; /* under FreeBSD ticks are 32-bit */
+
+ delay = time - jiffies;
+ if (delay <= 0)
+ delay = 1;
+
+ mod_delayed_work(addr_wq, &work, delay);
+}
+
+static void queue_req(struct addr_req *req)
+{
+ struct addr_req *temp_req;
+
+ mutex_lock(&lock);
+ list_for_each_entry_reverse(temp_req, &req_list, list) {
+ if (time_after_eq(req->timeout, temp_req->timeout))
+ break;
+ }
+
+ list_add(&req->list, &temp_req->list);
+
+ if (req_list.next == &req->list)
+ set_timeout(req->timeout);
+ mutex_unlock(&lock);
+}
+
+#if defined(INET) || defined(INET6)
+static int addr_resolve_multi(u8 *edst, struct ifnet *ifp, struct sockaddr *dst_in)
+{
+ struct sockaddr *llsa;
+ struct sockaddr_dl sdl;
+ int error;
+
+ sdl.sdl_len = sizeof(sdl);
+ llsa = (struct sockaddr *)&sdl;
+
+ if (ifp->if_resolvemulti == NULL) {
+ error = EOPNOTSUPP;
+ } else {
+ error = ifp->if_resolvemulti(ifp, &llsa, dst_in);
+ if (error == 0) {
+ rdma_copy_addr_sub(edst, LLADDR((struct sockaddr_dl *)llsa),
+ ifp->if_addrlen, MAX_ADDR_LEN);
+ }
+ }
+ return (error);
+}
+#endif
+
+#ifdef INET
+static int addr4_resolve(struct sockaddr_in *src_in,
+ const struct sockaddr_in *dst_in,
+ struct rdma_dev_addr *addr,
+ struct ifnet **ifpp)
+{
+ struct sockaddr_in dst_tmp = *dst_in;
+ u8 edst[MAX_ADDR_LEN];
+ in_port_t src_port;
+ struct sockaddr *saddr;
+ struct rtentry *rte;
+ struct ifnet *ifp;
+ int error;
+ int type;
+
+ /* set VNET, if any */
+ CURVNET_SET(addr->net);
+
+ /* set default TTL limit */
+ addr->hoplimit = V_ip_defttl;
+
+ type = 0;
+ if (src_in->sin_addr.s_addr == INADDR_ANY)
+ type |= 1;
+ if (dst_tmp.sin_addr.s_addr == INADDR_ANY)
+ type |= 2;
+
+ /*
+ * Make sure the socket address length field
+ * is set, else rtalloc1() will fail.
+ */
+ dst_tmp.sin_len = sizeof(dst_tmp);
+
+ /* Step 1 - lookup destination route if any */
+ switch (type) {
+ case 0:
+ case 1:
+ /* regular destination route lookup */
+ rte = rtalloc1((struct sockaddr *)&dst_tmp, 1, 0);
+ if (rte == NULL) {
+ error = EHOSTUNREACH;
+ goto done;
+ } else if (rte->rt_ifp == NULL || rte->rt_ifp == V_loif ||
+ RT_LINK_IS_UP(rte->rt_ifp) == 0) {
+ RTFREE_LOCKED(rte);
+ error = EHOSTUNREACH;
+ goto done;
+ }
+ RT_UNLOCK(rte);
+ break;
+ default:
+ error = ENETUNREACH;
+ goto done;
+ }
+
+ /* Step 2 - find outgoing network interface */
+ switch (type) {
+ case 0:
+ /* source check */
+ ifp = ip_dev_find(addr->net, src_in->sin_addr.s_addr);
+ if (ifp == NULL) {
+ error = ENETUNREACH;
+ goto error_rt_free;
+ } else if (ifp != rte->rt_ifp) {
+ error = ENETUNREACH;
+ goto error_put_ifp;
+ }
+ break;
+ case 1:
+ /* get destination network interface from route */
+ ifp = rte->rt_ifp;
+ dev_hold(ifp);
+ saddr = rte->rt_ifa->ifa_addr;
+
+ src_port = src_in->sin_port;
+ memcpy(src_in, saddr, rdma_addr_size(saddr));
+ src_in->sin_port = src_port; /* preserve port number */
+ break;
+ default:
+ break;
+ }
+
+ /*
+ * Step 3 - resolve destination MAC address
+ */
+ if (dst_tmp.sin_addr.s_addr == INADDR_BROADCAST) {
+ rdma_copy_addr_sub(edst, ifp->if_broadcastaddr,
+ ifp->if_addrlen, MAX_ADDR_LEN);
+ } else if (IN_MULTICAST(ntohl(dst_tmp.sin_addr.s_addr))) {
+ error = addr_resolve_multi(edst, ifp, (struct sockaddr *)&dst_tmp);
+ if (error != 0)
+ goto error_put_ifp;
+ } else {
+ bool is_gw = (rte->rt_flags & RTF_GATEWAY) != 0;
+ memset(edst, 0, sizeof(edst));
+ error = arpresolve(ifp, is_gw, NULL, is_gw ?
+ rte->rt_gateway : (const struct sockaddr *)&dst_tmp,
+ edst, NULL, NULL);
+ if (error != 0)
+ goto error_put_ifp;
+ else if (is_gw != 0)
+ addr->network = RDMA_NETWORK_IPV4;
+ }
+
+ /*
+ * Step 4 - copy destination and source MAC addresses
+ */
+ error = -rdma_copy_addr(addr, ifp, edst);
+ if (error != 0)
+ goto error_put_ifp;
+
+ if (rte != NULL)
+ RTFREE(rte);
+
+ *ifpp = ifp;
+
+ goto done;
+
+error_put_ifp:
+ dev_put(ifp);
+error_rt_free:
+ RTFREE(rte);
+done:
+ CURVNET_RESTORE();
+
+ if (error == EWOULDBLOCK || error == EAGAIN)
+ error = ENODATA;
+ return (-error);
+}
+#else
+static int addr4_resolve(struct sockaddr_in *src_in,
+ const struct sockaddr_in *dst_in,
+ struct rdma_dev_addr *addr,
+ struct ifnet **ifpp)
+{
+ return -EADDRNOTAVAIL;
+}
+#endif
+
+#ifdef INET6
+static int addr6_resolve(struct sockaddr_in6 *src_in,
+ const struct sockaddr_in6 *dst_in,
+ struct rdma_dev_addr *addr,
+ struct ifnet **ifpp)
+{
+ struct sockaddr_in6 dst_tmp = *dst_in;
+ u8 edst[MAX_ADDR_LEN];
+ in_port_t src_port;
+ struct sockaddr *saddr;
+ struct rtentry *rte;
+ struct ifnet *ifp;
+ int error;
+ int type;
+
+ /* set VNET, if any */
+ CURVNET_SET(addr->net);
+
+ /* set default TTL limit */
+ addr->hoplimit = V_ip_defttl;
+
+ type = 0;
+ if (ipv6_addr_any(&src_in->sin6_addr))
+ type |= 1;
+ if (ipv6_addr_any(&dst_tmp.sin6_addr))
+ type |= 2;
+
+ /*
+ * Make sure the socket address length field
+ * is set, else rtalloc1() will fail.
+ */
+ dst_tmp.sin6_len = sizeof(dst_tmp);
+
+ /* Step 1 - lookup destination route if any */
+ switch (type) {
+ case 0:
+ /* sanity check for IPv4 addresses */
+ if (ipv6_addr_v4mapped(&src_in->sin6_addr) !=
+ ipv6_addr_v4mapped(&dst_tmp.sin6_addr)) {
+ error = EAFNOSUPPORT;
+ goto done;
+ }
+ /* FALLTHROUGH */
+ case 1:
+ /* regular destination route lookup */
+ rte = rtalloc1((struct sockaddr *)&dst_tmp, 1, 0);
+ if (rte == NULL) {
+ error = EHOSTUNREACH;
+ goto done;
+ } else if (rte->rt_ifp == NULL || rte->rt_ifp == V_loif ||
+ RT_LINK_IS_UP(rte->rt_ifp) == 0) {
+ RTFREE_LOCKED(rte);
+ error = EHOSTUNREACH;
+ goto done;
+ }
+ RT_UNLOCK(rte);
+ break;
+ default:
+ error = ENETUNREACH;
+ goto done;
+ }
+
+ /* Step 2 - find outgoing network interface */
+ switch (type) {
+ case 0:
+ /* source check */
+ ifp = ip6_dev_find(addr->net, src_in->sin6_addr);
+ if (ifp == NULL) {
+ error = ENETUNREACH;
+ goto error_rt_free;
+ } else if (ifp != rte->rt_ifp) {
+ error = ENETUNREACH;
+ goto error_put_ifp;
+ }
+ break;
+ case 1:
+ /* get destination network interface from route */
+ ifp = rte->rt_ifp;
+ dev_hold(ifp);
+ saddr = rte->rt_ifa->ifa_addr;
+
+ src_port = src_in->sin6_port;
+ memcpy(src_in, saddr, rdma_addr_size(saddr));
+ src_in->sin6_port = src_port; /* preserve port number */
+ break;
+ default:
+ break;
+ }
+
+ /*
+ * Step 3 - resolve destination MAC address
+ */
+ if (IN6_IS_ADDR_MULTICAST(&dst_tmp.sin6_addr)) {
+ error = addr_resolve_multi(edst, ifp,
+ (struct sockaddr *)&dst_tmp);
+ if (error != 0)
+ goto error_put_ifp;
+ } else {
+ bool is_gw = (rte->rt_flags & RTF_GATEWAY) != 0;
+ memset(edst, 0, sizeof(edst));
+ error = nd6_resolve(ifp, is_gw, NULL, is_gw ?
+ rte->rt_gateway : (const struct sockaddr *)&dst_tmp,
+ edst, NULL, NULL);
+ if (error != 0)
+ goto error_put_ifp;
+ else if (is_gw != 0)
+ addr->network = RDMA_NETWORK_IPV6;
+ }
+
+ /*
+ * Step 4 - copy destination and source MAC addresses
+ */
+ error = -rdma_copy_addr(addr, ifp, edst);
+ if (error != 0)
+ goto error_put_ifp;
+
+ if (rte != NULL)
+ RTFREE(rte);
+
+ *ifpp = ifp;
+
+ goto done;
+
+error_put_ifp:
+ dev_put(ifp);
+error_rt_free:
+ RTFREE(rte);
+done:
+ CURVNET_RESTORE();
+
+ if (error == EWOULDBLOCK || error == EAGAIN)
+ error = ENODATA;
+ return (-error);
+}
+#else
+static int addr6_resolve(struct sockaddr_in6 *src_in,
+ const struct sockaddr_in6 *dst_in,
+ struct rdma_dev_addr *addr,
+ struct ifnet **ifpp)
+{
+ return -EADDRNOTAVAIL;
+}
+#endif
+
+static int addr_resolve_neigh(struct ifnet *dev,
+ const struct sockaddr *dst_in,
+ struct rdma_dev_addr *addr)
+{
+ if (dev->if_flags & IFF_LOOPBACK) {
+ int ret;
+
+ ret = rdma_translate_ip(dst_in, addr, NULL);
+ if (!ret)
+ memcpy(addr->dst_dev_addr, addr->src_dev_addr,
+ MAX_ADDR_LEN);
+
+ return ret;
+ }
+
+ /* If the device doesn't do ARP internally */
+ if (!(dev->if_flags & IFF_NOARP))
+ return 0;
+
+ return rdma_copy_addr(addr, dev, NULL);
+}
+
+static int addr_resolve(struct sockaddr *src_in,
+ const struct sockaddr *dst_in,
+ struct rdma_dev_addr *addr,
+ bool resolve_neigh)
+{
+ struct net_device *ndev = NULL;
+ int ret;
+
+ if (dst_in->sa_family != src_in->sa_family)
+ return -EINVAL;
+
+ if (src_in->sa_family == AF_INET) {
+ ret = addr4_resolve((struct sockaddr_in *)src_in,
+ (const struct sockaddr_in *)dst_in,
+ addr, &ndev);
+ if (ret)
+ return ret;
+
+ if (resolve_neigh)
+ ret = addr_resolve_neigh(ndev, dst_in, addr);
+ } else {
+ ret = addr6_resolve((struct sockaddr_in6 *)src_in,
+ (const struct sockaddr_in6 *)dst_in, addr,
+ &ndev);
+ if (ret)
+ return ret;
+
+ if (resolve_neigh)
+ ret = addr_resolve_neigh(ndev, dst_in, addr);
+ }
+
+ addr->bound_dev_if = ndev->if_index;
+ addr->net = dev_net(ndev);
+ dev_put(ndev);
+
+ return ret;
+}
+
+static void process_req(struct work_struct *work)
+{
+ struct addr_req *req, *temp_req;
+ struct sockaddr *src_in, *dst_in;
+ struct list_head done_list;
+
+ INIT_LIST_HEAD(&done_list);
+
+ mutex_lock(&lock);
+ list_for_each_entry_safe(req, temp_req, &req_list, list) {
+ if (req->status == -ENODATA) {
+ src_in = (struct sockaddr *) &req->src_addr;
+ dst_in = (struct sockaddr *) &req->dst_addr;
+ req->status = addr_resolve(src_in, dst_in, req->addr,
+ true);
+ if (req->status && time_after_eq(jiffies, req->timeout))
+ req->status = -ETIMEDOUT;
+ else if (req->status == -ENODATA)
+ continue;
+ }
+ list_move_tail(&req->list, &done_list);
+ }
+
+ if (!list_empty(&req_list)) {
+ req = list_entry(req_list.next, struct addr_req, list);
+ set_timeout(req->timeout);
+ }
+ mutex_unlock(&lock);
+
+ list_for_each_entry_safe(req, temp_req, &done_list, list) {
+ list_del(&req->list);
+ req->callback(req->status, (struct sockaddr *) &req->src_addr,
+ req->addr, req->context);
+ put_client(req->client);
+ kfree(req);
+ }
+}
+
+int rdma_resolve_ip(struct rdma_addr_client *client,
+ struct sockaddr *src_addr, struct sockaddr *dst_addr,
+ struct rdma_dev_addr *addr, int timeout_ms,
+ void (*callback)(int status, struct sockaddr *src_addr,
+ struct rdma_dev_addr *addr, void *context),
+ void *context)
+{
+ struct sockaddr *src_in, *dst_in;
+ struct addr_req *req;
+ int ret = 0;
+
+ req = kzalloc(sizeof *req, GFP_KERNEL);
+ if (!req)
+ return -ENOMEM;
+
+ src_in = (struct sockaddr *) &req->src_addr;
+ dst_in = (struct sockaddr *) &req->dst_addr;
+
+ if (src_addr) {
+ if (src_addr->sa_family != dst_addr->sa_family) {
+ ret = -EINVAL;
+ goto err;
+ }
+
+ memcpy(src_in, src_addr, rdma_addr_size(src_addr));
+ } else {
+ src_in->sa_family = dst_addr->sa_family;
+ }
+
+ memcpy(dst_in, dst_addr, rdma_addr_size(dst_addr));
+ req->addr = addr;
+ req->callback = callback;
+ req->context = context;
+ req->client = client;
+ atomic_inc(&client->refcount);
+
+ req->status = addr_resolve(src_in, dst_in, addr, true);
+ switch (req->status) {
+ case 0:
+ req->timeout = jiffies;
+ queue_req(req);
+ break;
+ case -ENODATA:
+ req->timeout = msecs_to_jiffies(timeout_ms) + jiffies;
+ queue_req(req);
+ break;
+ default:
+ ret = req->status;
+ atomic_dec(&client->refcount);
+ goto err;
+ }
+ return ret;
+err:
+ kfree(req);
+ return ret;
+}
+EXPORT_SYMBOL(rdma_resolve_ip);
+
+int rdma_resolve_ip_route(struct sockaddr *src_addr,
+ const struct sockaddr *dst_addr,
+ struct rdma_dev_addr *addr)
+{
+ struct sockaddr_storage ssrc_addr = {};
+ struct sockaddr *src_in = (struct sockaddr *)&ssrc_addr;
+
+ if (src_addr) {
+ if (src_addr->sa_family != dst_addr->sa_family)
+ return -EINVAL;
+
+ memcpy(src_in, src_addr, rdma_addr_size(src_addr));
+ } else {
+ src_in->sa_family = dst_addr->sa_family;
+ }
+
+ return addr_resolve(src_in, dst_addr, addr, false);
+}
+EXPORT_SYMBOL(rdma_resolve_ip_route);
+
+void rdma_addr_cancel(struct rdma_dev_addr *addr)
+{
+ struct addr_req *req, *temp_req;
+
+ mutex_lock(&lock);
+ list_for_each_entry_safe(req, temp_req, &req_list, list) {
+ if (req->addr == addr) {
+ req->status = -ECANCELED;
+ req->timeout = jiffies;
+ list_move(&req->list, &req_list);
+ set_timeout(req->timeout);
+ break;
+ }
+ }
+ mutex_unlock(&lock);
+}
+EXPORT_SYMBOL(rdma_addr_cancel);
+
+struct resolve_cb_context {
+ struct rdma_dev_addr *addr;
+ struct completion comp;
+ int status;
+};
+
+static void resolve_cb(int status, struct sockaddr *src_addr,
+ struct rdma_dev_addr *addr, void *context)
+{
+ if (!status)
+ memcpy(((struct resolve_cb_context *)context)->addr,
+ addr, sizeof(struct rdma_dev_addr));
+ ((struct resolve_cb_context *)context)->status = status;
+ complete(&((struct resolve_cb_context *)context)->comp);
+}
+
+int rdma_addr_find_l2_eth_by_grh(const union ib_gid *sgid,
+ const union ib_gid *dgid,
+ u8 *dmac, u16 *vlan_id, int *if_index,
+ int *hoplimit)
+{
+ int ret = 0;
+ struct rdma_dev_addr dev_addr;
+ struct resolve_cb_context ctx;
+ struct net_device *dev;
+
+ union {
+ struct sockaddr _sockaddr;
+ struct sockaddr_in _sockaddr_in;
+ struct sockaddr_in6 _sockaddr_in6;
+ } sgid_addr, dgid_addr;
+
+
+ rdma_gid2ip(&sgid_addr._sockaddr, sgid);
+ rdma_gid2ip(&dgid_addr._sockaddr, dgid);
+
+ memset(&dev_addr, 0, sizeof(dev_addr));
+ if (if_index)
+ dev_addr.bound_dev_if = *if_index;
+ dev_addr.net = TD_TO_VNET(curthread);
+
+ ctx.addr = &dev_addr;
+ init_completion(&ctx.comp);
+ ret = rdma_resolve_ip(&self, &sgid_addr._sockaddr, &dgid_addr._sockaddr,
+ &dev_addr, 1000, resolve_cb, &ctx);
+ if (ret)
+ return ret;
+
+ wait_for_completion(&ctx.comp);
+
+ ret = ctx.status;
+ if (ret)
+ return ret;
+
+ memcpy(dmac, dev_addr.dst_dev_addr, ETH_ALEN);
+ dev = dev_get_by_index(dev_addr.net, dev_addr.bound_dev_if);
+ if (!dev)
+ return -ENODEV;
+ if (if_index)
+ *if_index = dev_addr.bound_dev_if;
+ if (vlan_id)
+ *vlan_id = rdma_vlan_dev_vlan_id(dev);
+ if (hoplimit)
+ *hoplimit = dev_addr.hoplimit;
+ dev_put(dev);
+ return ret;
+}
+EXPORT_SYMBOL(rdma_addr_find_l2_eth_by_grh);
+
+int rdma_addr_find_smac_by_sgid(union ib_gid *sgid, u8 *smac, u16 *vlan_id)
+{
+ int ret = 0;
+ struct rdma_dev_addr dev_addr;
+ union {
+ struct sockaddr _sockaddr;
+ struct sockaddr_in _sockaddr_in;
+ struct sockaddr_in6 _sockaddr_in6;
+ } gid_addr;
+
+ rdma_gid2ip(&gid_addr._sockaddr, sgid);
+
+ memset(&dev_addr, 0, sizeof(dev_addr));
+ dev_addr.net = TD_TO_VNET(curthread);
+ ret = rdma_translate_ip(&gid_addr._sockaddr, &dev_addr, vlan_id);
+ if (ret)
+ return ret;
+
+ memcpy(smac, dev_addr.src_dev_addr, ETH_ALEN);
+ return ret;
+}
+EXPORT_SYMBOL(rdma_addr_find_smac_by_sgid);
+
+int addr_init(void)
+{
+ addr_wq = alloc_workqueue("ib_addr", WQ_MEM_RECLAIM, 0);
+ if (!addr_wq)
+ return -ENOMEM;
+
+ rdma_addr_register_client(&self);
+
+ return 0;
+}
+
+void addr_cleanup(void)
+{
+ rdma_addr_unregister_client(&self);
+ destroy_workqueue(addr_wq);
+}
diff --git a/sys/ofed/drivers/infiniband/core/ib_agent.c b/sys/ofed/drivers/infiniband/core/ib_agent.c
new file mode 100644
index 0000000..4fa524d
--- /dev/null
+++ b/sys/ofed/drivers/infiniband/core/ib_agent.c
@@ -0,0 +1,222 @@
+/*
+ * Copyright (c) 2004, 2005 Mellanox Technologies Ltd. All rights reserved.
+ * Copyright (c) 2004, 2005 Infinicon Corporation. All rights reserved.
+ * Copyright (c) 2004, 2005 Intel Corporation. All rights reserved.
+ * Copyright (c) 2004, 2005 Topspin Corporation. All rights reserved.
+ * Copyright (c) 2004-2007 Voltaire Corporation. All rights reserved.
+ * Copyright (c) 2005 Sun Microsystems, Inc. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+#include <linux/slab.h>
+#include <linux/string.h>
+
+#include "agent.h"
+#include "smi.h"
+#include "mad_priv.h"
+
+#define SPFX "ib_agent: "
+
+struct ib_agent_port_private {
+ struct list_head port_list;
+ struct ib_mad_agent *agent[2];
+};
+
+static DEFINE_SPINLOCK(ib_agent_port_list_lock);
+static LIST_HEAD(ib_agent_port_list);
+
+static struct ib_agent_port_private *
+__ib_get_agent_port(const struct ib_device *device, int port_num)
+{
+ struct ib_agent_port_private *entry;
+
+ list_for_each_entry(entry, &ib_agent_port_list, port_list) {
+ if (entry->agent[1]->device == device &&
+ entry->agent[1]->port_num == port_num)
+ return entry;
+ }
+ return NULL;
+}
+
+static struct ib_agent_port_private *
+ib_get_agent_port(const struct ib_device *device, int port_num)
+{
+ struct ib_agent_port_private *entry;
+ unsigned long flags;
+
+ spin_lock_irqsave(&ib_agent_port_list_lock, flags);
+ entry = __ib_get_agent_port(device, port_num);
+ spin_unlock_irqrestore(&ib_agent_port_list_lock, flags);
+ return entry;
+}
+
+void agent_send_response(const struct ib_mad_hdr *mad_hdr, const struct ib_grh *grh,
+ const struct ib_wc *wc, const struct ib_device *device,
+ int port_num, int qpn, size_t resp_mad_len, bool opa)
+{
+ struct ib_agent_port_private *port_priv;
+ struct ib_mad_agent *agent;
+ struct ib_mad_send_buf *send_buf;
+ struct ib_ah *ah;
+ struct ib_mad_send_wr_private *mad_send_wr;
+
+ if (rdma_cap_ib_switch(device))
+ port_priv = ib_get_agent_port(device, 0);
+ else
+ port_priv = ib_get_agent_port(device, port_num);
+
+ if (!port_priv) {
+ dev_err(&device->dev, "Unable to find port agent\n");
+ return;
+ }
+
+ agent = port_priv->agent[qpn];
+ ah = ib_create_ah_from_wc(agent->qp->pd, wc, grh, port_num);
+ if (IS_ERR(ah)) {
+ dev_err(&device->dev, "ib_create_ah_from_wc error %ld\n",
+ PTR_ERR(ah));
+ return;
+ }
+
+ if (opa && mad_hdr->base_version != OPA_MGMT_BASE_VERSION)
+ resp_mad_len = IB_MGMT_MAD_SIZE;
+
+ send_buf = ib_create_send_mad(agent, wc->src_qp, wc->pkey_index, 0,
+ IB_MGMT_MAD_HDR,
+ resp_mad_len - IB_MGMT_MAD_HDR,
+ GFP_KERNEL,
+ mad_hdr->base_version);
+ if (IS_ERR(send_buf)) {
+ dev_err(&device->dev, "ib_create_send_mad error\n");
+ goto err1;
+ }
+
+ memcpy(send_buf->mad, mad_hdr, resp_mad_len);
+ send_buf->ah = ah;
+
+ if (rdma_cap_ib_switch(device)) {
+ mad_send_wr = container_of(send_buf,
+ struct ib_mad_send_wr_private,
+ send_buf);
+ mad_send_wr->send_wr.port_num = port_num;
+ }
+
+ if (ib_post_send_mad(send_buf, NULL)) {
+ dev_err(&device->dev, "ib_post_send_mad error\n");
+ goto err2;
+ }
+ return;
+err2:
+ ib_free_send_mad(send_buf);
+err1:
+ ib_destroy_ah(ah);
+}
+
+static void agent_send_handler(struct ib_mad_agent *mad_agent,
+ struct ib_mad_send_wc *mad_send_wc)
+{
+ ib_destroy_ah(mad_send_wc->send_buf->ah);
+ ib_free_send_mad(mad_send_wc->send_buf);
+}
+
+int ib_agent_port_open(struct ib_device *device, int port_num)
+{
+ struct ib_agent_port_private *port_priv;
+ unsigned long flags;
+ int ret;
+
+ /* Create new device info */
+ port_priv = kzalloc(sizeof *port_priv, GFP_KERNEL);
+ if (!port_priv) {
+ dev_err(&device->dev, "No memory for ib_agent_port_private\n");
+ ret = -ENOMEM;
+ goto error1;
+ }
+
+ if (rdma_cap_ib_smi(device, port_num)) {
+ /* Obtain send only MAD agent for SMI QP */
+ port_priv->agent[0] = ib_register_mad_agent(device, port_num,
+ IB_QPT_SMI, NULL, 0,
+ &agent_send_handler,
+ NULL, NULL, 0);
+ if (IS_ERR(port_priv->agent[0])) {
+ ret = PTR_ERR(port_priv->agent[0]);
+ goto error2;
+ }
+ }
+
+ /* Obtain send only MAD agent for GSI QP */
+ port_priv->agent[1] = ib_register_mad_agent(device, port_num,
+ IB_QPT_GSI, NULL, 0,
+ &agent_send_handler,
+ NULL, NULL, 0);
+ if (IS_ERR(port_priv->agent[1])) {
+ ret = PTR_ERR(port_priv->agent[1]);
+ goto error3;
+ }
+
+ spin_lock_irqsave(&ib_agent_port_list_lock, flags);
+ list_add_tail(&port_priv->port_list, &ib_agent_port_list);
+ spin_unlock_irqrestore(&ib_agent_port_list_lock, flags);
+
+ return 0;
+
+error3:
+ if (port_priv->agent[0])
+ ib_unregister_mad_agent(port_priv->agent[0]);
+error2:
+ kfree(port_priv);
+error1:
+ return ret;
+}
+
+int ib_agent_port_close(struct ib_device *device, int port_num)
+{
+ struct ib_agent_port_private *port_priv;
+ unsigned long flags;
+
+ spin_lock_irqsave(&ib_agent_port_list_lock, flags);
+ port_priv = __ib_get_agent_port(device, port_num);
+ if (port_priv == NULL) {
+ spin_unlock_irqrestore(&ib_agent_port_list_lock, flags);
+ dev_err(&device->dev, "Port %d not found\n", port_num);
+ return -ENODEV;
+ }
+ list_del(&port_priv->port_list);
+ spin_unlock_irqrestore(&ib_agent_port_list_lock, flags);
+
+ ib_unregister_mad_agent(port_priv->agent[1]);
+ if (port_priv->agent[0])
+ ib_unregister_mad_agent(port_priv->agent[0]);
+
+ kfree(port_priv);
+ return 0;
+}
diff --git a/sys/ofed/drivers/infiniband/core/ib_cache.c b/sys/ofed/drivers/infiniband/core/ib_cache.c
new file mode 100644
index 0000000..016fc11
--- /dev/null
+++ b/sys/ofed/drivers/infiniband/core/ib_cache.c
@@ -0,0 +1,1258 @@
+/*
+ * Copyright (c) 2004 Topspin Communications. All rights reserved.
+ * Copyright (c) 2005 Intel Corporation. All rights reserved.
+ * Copyright (c) 2005 Sun Microsystems, Inc. All rights reserved.
+ * Copyright (c) 2005 Voltaire, Inc. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#include <linux/module.h>
+#include <linux/errno.h>
+#include <linux/slab.h>
+#include <linux/workqueue.h>
+#include <linux/netdevice.h>
+
+#include <rdma/ib_cache.h>
+
+#include "core_priv.h"
+
+struct ib_pkey_cache {
+ int table_len;
+ u16 table[0];
+};
+
+struct ib_update_work {
+ struct work_struct work;
+ struct ib_device *device;
+ u8 port_num;
+};
+
+union ib_gid zgid;
+EXPORT_SYMBOL(zgid);
+
+static const struct ib_gid_attr zattr;
+
+enum gid_attr_find_mask {
+ GID_ATTR_FIND_MASK_GID = 1UL << 0,
+ GID_ATTR_FIND_MASK_NETDEV = 1UL << 1,
+ GID_ATTR_FIND_MASK_DEFAULT = 1UL << 2,
+ GID_ATTR_FIND_MASK_GID_TYPE = 1UL << 3,
+};
+
+enum gid_table_entry_props {
+ GID_TABLE_ENTRY_INVALID = 1UL << 0,
+ GID_TABLE_ENTRY_DEFAULT = 1UL << 1,
+};
+
+enum gid_table_write_action {
+ GID_TABLE_WRITE_ACTION_ADD,
+ GID_TABLE_WRITE_ACTION_DEL,
+ /* MODIFY only updates the GID table. Currently only used by
+ * ib_cache_update.
+ */
+ GID_TABLE_WRITE_ACTION_MODIFY
+};
+
+struct ib_gid_table_entry {
+ unsigned long props;
+ union ib_gid gid;
+ struct ib_gid_attr attr;
+ void *context;
+};
+
+struct ib_gid_table {
+ int sz;
+ /* In RoCE, adding a GID to the table requires:
+ * (a) Find if this GID is already exists.
+ * (b) Find a free space.
+ * (c) Write the new GID
+ *
+ * Delete requires different set of operations:
+ * (a) Find the GID
+ * (b) Delete it.
+ *
+ * Add/delete should be carried out atomically.
+ * This is done by locking this mutex from multiple
+ * writers. We don't need this lock for IB, as the MAD
+ * layer replaces all entries. All data_vec entries
+ * are locked by this lock.
+ **/
+ struct mutex lock;
+ /* This lock protects the table entries from being
+ * read and written simultaneously.
+ */
+ rwlock_t rwlock;
+ struct ib_gid_table_entry *data_vec;
+};
+
+static void dispatch_gid_change_event(struct ib_device *ib_dev, u8 port)
+{
+ if (rdma_cap_roce_gid_table(ib_dev, port)) {
+ struct ib_event event;
+
+ event.device = ib_dev;
+ event.element.port_num = port;
+ event.event = IB_EVENT_GID_CHANGE;
+
+ ib_dispatch_event(&event);
+ }
+}
+
+static const char * const gid_type_str[] = {
+ [IB_GID_TYPE_IB] = "IB/RoCE v1",
+ [IB_GID_TYPE_ROCE_UDP_ENCAP] = "RoCE v2",
+};
+
+const char *ib_cache_gid_type_str(enum ib_gid_type gid_type)
+{
+ if (gid_type < ARRAY_SIZE(gid_type_str) && gid_type_str[gid_type])
+ return gid_type_str[gid_type];
+
+ return "Invalid GID type";
+}
+EXPORT_SYMBOL(ib_cache_gid_type_str);
+
+int ib_cache_gid_parse_type_str(const char *buf)
+{
+ unsigned int i;
+ size_t len;
+ int err = -EINVAL;
+
+ len = strlen(buf);
+ if (len == 0)
+ return -EINVAL;
+
+ if (buf[len - 1] == '\n')
+ len--;
+
+ for (i = 0; i < ARRAY_SIZE(gid_type_str); ++i)
+ if (gid_type_str[i] && !strncmp(buf, gid_type_str[i], len) &&
+ len == strlen(gid_type_str[i])) {
+ err = i;
+ break;
+ }
+
+ return err;
+}
+EXPORT_SYMBOL(ib_cache_gid_parse_type_str);
+
+/* This function expects that rwlock will be write locked in all
+ * scenarios and that lock will be locked in sleep-able (RoCE)
+ * scenarios.
+ */
+static int write_gid(struct ib_device *ib_dev, u8 port,
+ struct ib_gid_table *table, int ix,
+ const union ib_gid *gid,
+ const struct ib_gid_attr *attr,
+ enum gid_table_write_action action,
+ bool default_gid)
+ __releases(&table->rwlock) __acquires(&table->rwlock)
+{
+ int ret = 0;
+ struct net_device *old_net_dev;
+ enum ib_gid_type old_gid_type;
+
+ /* in rdma_cap_roce_gid_table, this funciton should be protected by a
+ * sleep-able lock.
+ */
+
+ if (rdma_cap_roce_gid_table(ib_dev, port)) {
+ table->data_vec[ix].props |= GID_TABLE_ENTRY_INVALID;
+ write_unlock_irq(&table->rwlock);
+ /* GID_TABLE_WRITE_ACTION_MODIFY currently isn't supported by
+ * RoCE providers and thus only updates the cache.
+ */
+ if (action == GID_TABLE_WRITE_ACTION_ADD)
+ ret = ib_dev->add_gid(ib_dev, port, ix, gid, attr,
+ &table->data_vec[ix].context);
+ else if (action == GID_TABLE_WRITE_ACTION_DEL)
+ ret = ib_dev->del_gid(ib_dev, port, ix,
+ &table->data_vec[ix].context);
+ write_lock_irq(&table->rwlock);
+ }
+
+ old_net_dev = table->data_vec[ix].attr.ndev;
+ old_gid_type = table->data_vec[ix].attr.gid_type;
+ if (old_net_dev && old_net_dev != attr->ndev)
+ dev_put(old_net_dev);
+ /* if modify_gid failed, just delete the old gid */
+ if (ret || action == GID_TABLE_WRITE_ACTION_DEL) {
+ gid = &zgid;
+ attr = &zattr;
+ table->data_vec[ix].context = NULL;
+ }
+
+ memcpy(&table->data_vec[ix].gid, gid, sizeof(*gid));
+ memcpy(&table->data_vec[ix].attr, attr, sizeof(*attr));
+ if (default_gid) {
+ table->data_vec[ix].props |= GID_TABLE_ENTRY_DEFAULT;
+ if (action == GID_TABLE_WRITE_ACTION_DEL)
+ table->data_vec[ix].attr.gid_type = old_gid_type;
+ }
+ if (table->data_vec[ix].attr.ndev &&
+ table->data_vec[ix].attr.ndev != old_net_dev)
+ dev_hold(table->data_vec[ix].attr.ndev);
+
+ table->data_vec[ix].props &= ~GID_TABLE_ENTRY_INVALID;
+
+ return ret;
+}
+
+static int add_gid(struct ib_device *ib_dev, u8 port,
+ struct ib_gid_table *table, int ix,
+ const union ib_gid *gid,
+ const struct ib_gid_attr *attr,
+ bool default_gid) {
+ return write_gid(ib_dev, port, table, ix, gid, attr,
+ GID_TABLE_WRITE_ACTION_ADD, default_gid);
+}
+
+static int modify_gid(struct ib_device *ib_dev, u8 port,
+ struct ib_gid_table *table, int ix,
+ const union ib_gid *gid,
+ const struct ib_gid_attr *attr,
+ bool default_gid) {
+ return write_gid(ib_dev, port, table, ix, gid, attr,
+ GID_TABLE_WRITE_ACTION_MODIFY, default_gid);
+}
+
+static int del_gid(struct ib_device *ib_dev, u8 port,
+ struct ib_gid_table *table, int ix,
+ bool default_gid) {
+ return write_gid(ib_dev, port, table, ix, &zgid, &zattr,
+ GID_TABLE_WRITE_ACTION_DEL, default_gid);
+}
+
+/* rwlock should be read locked */
+static int find_gid(struct ib_gid_table *table, const union ib_gid *gid,
+ const struct ib_gid_attr *val, bool default_gid,
+ unsigned long mask, int *pempty)
+{
+ int i = 0;
+ int found = -1;
+ int empty = pempty ? -1 : 0;
+
+ while (i < table->sz && (found < 0 || empty < 0)) {
+ struct ib_gid_table_entry *data = &table->data_vec[i];
+ struct ib_gid_attr *attr = &data->attr;
+ int curr_index = i;
+
+ i++;
+
+ if (data->props & GID_TABLE_ENTRY_INVALID)
+ continue;
+
+ if (empty < 0)
+ if (!memcmp(&data->gid, &zgid, sizeof(*gid)) &&
+ !memcmp(attr, &zattr, sizeof(*attr)) &&
+ !data->props)
+ empty = curr_index;
+
+ if (found >= 0)
+ continue;
+
+ if (mask & GID_ATTR_FIND_MASK_GID_TYPE &&
+ attr->gid_type != val->gid_type)
+ continue;
+
+ if (mask & GID_ATTR_FIND_MASK_GID &&
+ memcmp(gid, &data->gid, sizeof(*gid)))
+ continue;
+
+ if (mask & GID_ATTR_FIND_MASK_NETDEV &&
+ attr->ndev != val->ndev)
+ continue;
+
+ if (mask & GID_ATTR_FIND_MASK_DEFAULT &&
+ !!(data->props & GID_TABLE_ENTRY_DEFAULT) !=
+ default_gid)
+ continue;
+
+ found = curr_index;
+ }
+
+ if (pempty)
+ *pempty = empty;
+
+ return found;
+}
+
+static void addrconf_ifid_eui48(u8 *eui, struct net_device *dev)
+{
+ if (dev->if_addrlen != ETH_ALEN)
+ return;
+ memcpy(eui, IF_LLADDR(dev), 3);
+ memcpy(eui + 5, IF_LLADDR(dev) + 3, 3);
+
+ /* NOTE: The scope ID is added by the GID to IP conversion */
+
+ eui[3] = 0xFF;
+ eui[4] = 0xFE;
+ eui[0] ^= 2;
+}
+
+static void make_default_gid(struct net_device *dev, union ib_gid *gid)
+{
+ gid->global.subnet_prefix = cpu_to_be64(0xfe80000000000000LL);
+ addrconf_ifid_eui48(&gid->raw[8], dev);
+}
+
+int ib_cache_gid_add(struct ib_device *ib_dev, u8 port,
+ union ib_gid *gid, struct ib_gid_attr *attr)
+{
+ struct ib_gid_table **ports_table = ib_dev->cache.gid_cache;
+ struct ib_gid_table *table;
+ int ix;
+ int ret = 0;
+ struct net_device *idev;
+ int empty;
+
+ table = ports_table[port - rdma_start_port(ib_dev)];
+
+ if (!memcmp(gid, &zgid, sizeof(*gid)))
+ return -EINVAL;
+
+ if (ib_dev->get_netdev) {
+ idev = ib_dev->get_netdev(ib_dev, port);
+ if (idev && attr->ndev != idev) {
+ union ib_gid default_gid;
+
+ /* Adding default GIDs in not permitted */
+ make_default_gid(idev, &default_gid);
+ if (!memcmp(gid, &default_gid, sizeof(*gid))) {
+ dev_put(idev);
+ return -EPERM;
+ }
+ }
+ if (idev)
+ dev_put(idev);
+ }
+
+ mutex_lock(&table->lock);
+ write_lock_irq(&table->rwlock);
+
+ ix = find_gid(table, gid, attr, false, GID_ATTR_FIND_MASK_GID |
+ GID_ATTR_FIND_MASK_GID_TYPE |
+ GID_ATTR_FIND_MASK_NETDEV, &empty);
+ if (ix >= 0)
+ goto out_unlock;
+
+ if (empty < 0) {
+ ret = -ENOSPC;
+ goto out_unlock;
+ }
+
+ ret = add_gid(ib_dev, port, table, empty, gid, attr, false);
+ if (!ret)
+ dispatch_gid_change_event(ib_dev, port);
+
+out_unlock:
+ write_unlock_irq(&table->rwlock);
+ mutex_unlock(&table->lock);
+ return ret;
+}
+
+int ib_cache_gid_del(struct ib_device *ib_dev, u8 port,
+ union ib_gid *gid, struct ib_gid_attr *attr)
+{
+ struct ib_gid_table **ports_table = ib_dev->cache.gid_cache;
+ struct ib_gid_table *table;
+ int ix;
+
+ table = ports_table[port - rdma_start_port(ib_dev)];
+
+ mutex_lock(&table->lock);
+ write_lock_irq(&table->rwlock);
+
+ ix = find_gid(table, gid, attr, false,
+ GID_ATTR_FIND_MASK_GID |
+ GID_ATTR_FIND_MASK_GID_TYPE |
+ GID_ATTR_FIND_MASK_NETDEV |
+ GID_ATTR_FIND_MASK_DEFAULT,
+ NULL);
+ if (ix < 0)
+ goto out_unlock;
+
+ if (!del_gid(ib_dev, port, table, ix, false))
+ dispatch_gid_change_event(ib_dev, port);
+
+out_unlock:
+ write_unlock_irq(&table->rwlock);
+ mutex_unlock(&table->lock);
+ return 0;
+}
+
+int ib_cache_gid_del_all_netdev_gids(struct ib_device *ib_dev, u8 port,
+ struct net_device *ndev)
+{
+ struct ib_gid_table **ports_table = ib_dev->cache.gid_cache;
+ struct ib_gid_table *table;
+ int ix;
+ bool deleted = false;
+
+ table = ports_table[port - rdma_start_port(ib_dev)];
+
+ mutex_lock(&table->lock);
+ write_lock_irq(&table->rwlock);
+
+ for (ix = 0; ix < table->sz; ix++)
+ if (table->data_vec[ix].attr.ndev == ndev)
+ if (!del_gid(ib_dev, port, table, ix,
+ !!(table->data_vec[ix].props &
+ GID_TABLE_ENTRY_DEFAULT)))
+ deleted = true;
+
+ write_unlock_irq(&table->rwlock);
+ mutex_unlock(&table->lock);
+
+ if (deleted)
+ dispatch_gid_change_event(ib_dev, port);
+
+ return 0;
+}
+
+static int __ib_cache_gid_get(struct ib_device *ib_dev, u8 port, int index,
+ union ib_gid *gid, struct ib_gid_attr *attr)
+{
+ struct ib_gid_table **ports_table = ib_dev->cache.gid_cache;
+ struct ib_gid_table *table;
+
+ table = ports_table[port - rdma_start_port(ib_dev)];
+
+ if (index < 0 || index >= table->sz)
+ return -EINVAL;
+
+ if (table->data_vec[index].props & GID_TABLE_ENTRY_INVALID)
+ return -EAGAIN;
+
+ memcpy(gid, &table->data_vec[index].gid, sizeof(*gid));
+ if (attr) {
+ memcpy(attr, &table->data_vec[index].attr, sizeof(*attr));
+ /* make sure network device is valid and attached */
+ if (attr->ndev != NULL &&
+ (attr->ndev->if_flags & IFF_DYING) == 0 &&
+ attr->ndev->if_addr != NULL)
+ dev_hold(attr->ndev);
+ else
+ attr->ndev = NULL;
+ }
+
+ return 0;
+}
+
+static int _ib_cache_gid_table_find(struct ib_device *ib_dev,
+ const union ib_gid *gid,
+ const struct ib_gid_attr *val,
+ unsigned long mask,
+ u8 *port, u16 *index)
+{
+ struct ib_gid_table **ports_table = ib_dev->cache.gid_cache;
+ struct ib_gid_table *table;
+ u8 p;
+ int local_index;
+ unsigned long flags;
+
+ for (p = 0; p < ib_dev->phys_port_cnt; p++) {
+ table = ports_table[p];
+ read_lock_irqsave(&table->rwlock, flags);
+ local_index = find_gid(table, gid, val, false, mask, NULL);
+ if (local_index >= 0) {
+ if (index)
+ *index = local_index;
+ if (port)
+ *port = p + rdma_start_port(ib_dev);
+ read_unlock_irqrestore(&table->rwlock, flags);
+ return 0;
+ }
+ read_unlock_irqrestore(&table->rwlock, flags);
+ }
+
+ return -ENOENT;
+}
+
+static int ib_cache_gid_find(struct ib_device *ib_dev,
+ const union ib_gid *gid,
+ enum ib_gid_type gid_type,
+ struct net_device *ndev, u8 *port,
+ u16 *index)
+{
+ unsigned long mask = GID_ATTR_FIND_MASK_GID |
+ GID_ATTR_FIND_MASK_GID_TYPE;
+ struct ib_gid_attr gid_attr_val = {.ndev = ndev, .gid_type = gid_type};
+
+ if (ndev)
+ mask |= GID_ATTR_FIND_MASK_NETDEV;
+
+ return _ib_cache_gid_table_find(ib_dev, gid, &gid_attr_val,
+ mask, port, index);
+}
+
+int ib_find_cached_gid_by_port(struct ib_device *ib_dev,
+ const union ib_gid *gid,
+ enum ib_gid_type gid_type,
+ u8 port, struct net_device *ndev,
+ u16 *index)
+{
+ int local_index;
+ struct ib_gid_table **ports_table = ib_dev->cache.gid_cache;
+ struct ib_gid_table *table;
+ unsigned long mask = GID_ATTR_FIND_MASK_GID |
+ GID_ATTR_FIND_MASK_GID_TYPE;
+ struct ib_gid_attr val = {.ndev = ndev, .gid_type = gid_type};
+ unsigned long flags;
+
+ if (port < rdma_start_port(ib_dev) ||
+ port > rdma_end_port(ib_dev))
+ return -ENOENT;
+
+ table = ports_table[port - rdma_start_port(ib_dev)];
+
+ if (ndev)
+ mask |= GID_ATTR_FIND_MASK_NETDEV;
+
+ read_lock_irqsave(&table->rwlock, flags);
+ local_index = find_gid(table, gid, &val, false, mask, NULL);
+ if (local_index >= 0) {
+ if (index)
+ *index = local_index;
+ read_unlock_irqrestore(&table->rwlock, flags);
+ return 0;
+ }
+
+ read_unlock_irqrestore(&table->rwlock, flags);
+ return -ENOENT;
+}
+EXPORT_SYMBOL(ib_find_cached_gid_by_port);
+
+/**
+ * ib_find_gid_by_filter - Returns the GID table index where a specified
+ * GID value occurs
+ * @device: The device to query.
+ * @gid: The GID value to search for.
+ * @port_num: The port number of the device where the GID value could be
+ * searched.
+ * @filter: The filter function is executed on any matching GID in the table.
+ * If the filter function returns true, the corresponding index is returned,
+ * otherwise, we continue searching the GID table. It's guaranteed that
+ * while filter is executed, ndev field is valid and the structure won't
+ * change. filter is executed in an atomic context. filter must not be NULL.
+ * @index: The index into the cached GID table where the GID was found. This
+ * parameter may be NULL.
+ *
+ * ib_cache_gid_find_by_filter() searches for the specified GID value
+ * of which the filter function returns true in the port's GID table.
+ * This function is only supported on RoCE ports.
+ *
+ */
+static int ib_cache_gid_find_by_filter(struct ib_device *ib_dev,
+ const union ib_gid *gid,
+ u8 port,
+ bool (*filter)(const union ib_gid *,
+ const struct ib_gid_attr *,
+ void *),
+ void *context,
+ u16 *index)
+{
+ struct ib_gid_table **ports_table = ib_dev->cache.gid_cache;
+ struct ib_gid_table *table;
+ unsigned int i;
+ unsigned long flags;
+ bool found = false;
+
+ if (!ports_table)
+ return -EOPNOTSUPP;
+
+ if (port < rdma_start_port(ib_dev) ||
+ port > rdma_end_port(ib_dev) ||
+ !rdma_protocol_roce(ib_dev, port))
+ return -EPROTONOSUPPORT;
+
+ table = ports_table[port - rdma_start_port(ib_dev)];
+
+ read_lock_irqsave(&table->rwlock, flags);
+ for (i = 0; i < table->sz; i++) {
+ struct ib_gid_attr attr;
+
+ if (table->data_vec[i].props & GID_TABLE_ENTRY_INVALID)
+ goto next;
+
+ if (memcmp(gid, &table->data_vec[i].gid, sizeof(*gid)))
+ goto next;
+
+ memcpy(&attr, &table->data_vec[i].attr, sizeof(attr));
+
+ if (filter(gid, &attr, context))
+ found = true;
+
+next:
+ if (found)
+ break;
+ }
+ read_unlock_irqrestore(&table->rwlock, flags);
+
+ if (!found)
+ return -ENOENT;
+
+ if (index)
+ *index = i;
+ return 0;
+}
+
+static struct ib_gid_table *alloc_gid_table(int sz)
+{
+ struct ib_gid_table *table =
+ kzalloc(sizeof(struct ib_gid_table), GFP_KERNEL);
+
+ if (!table)
+ return NULL;
+
+ table->data_vec = kcalloc(sz, sizeof(*table->data_vec), GFP_KERNEL);
+ if (!table->data_vec)
+ goto err_free_table;
+
+ mutex_init(&table->lock);
+
+ table->sz = sz;
+ rwlock_init(&table->rwlock);
+
+ return table;
+
+err_free_table:
+ kfree(table);
+ return NULL;
+}
+
+static void release_gid_table(struct ib_gid_table *table)
+{
+ if (table) {
+ kfree(table->data_vec);
+ kfree(table);
+ }
+}
+
+static void cleanup_gid_table_port(struct ib_device *ib_dev, u8 port,
+ struct ib_gid_table *table)
+{
+ int i;
+ bool deleted = false;
+
+ if (!table)
+ return;
+
+ write_lock_irq(&table->rwlock);
+ for (i = 0; i < table->sz; ++i) {
+ if (memcmp(&table->data_vec[i].gid, &zgid,
+ sizeof(table->data_vec[i].gid)))
+ if (!del_gid(ib_dev, port, table, i,
+ table->data_vec[i].props &
+ GID_ATTR_FIND_MASK_DEFAULT))
+ deleted = true;
+ }
+ write_unlock_irq(&table->rwlock);
+
+ if (deleted)
+ dispatch_gid_change_event(ib_dev, port);
+}
+
+void ib_cache_gid_set_default_gid(struct ib_device *ib_dev, u8 port,
+ struct net_device *ndev,
+ unsigned long gid_type_mask,
+ enum ib_cache_gid_default_mode mode)
+{
+ struct ib_gid_table **ports_table = ib_dev->cache.gid_cache;
+ union ib_gid gid;
+ struct ib_gid_attr gid_attr;
+ struct ib_gid_attr zattr_type = zattr;
+ struct ib_gid_table *table;
+ unsigned int gid_type;
+
+ table = ports_table[port - rdma_start_port(ib_dev)];
+
+ make_default_gid(ndev, &gid);
+ memset(&gid_attr, 0, sizeof(gid_attr));
+ gid_attr.ndev = ndev;
+
+ for (gid_type = 0; gid_type < IB_GID_TYPE_SIZE; ++gid_type) {
+ int ix;
+ union ib_gid current_gid;
+ struct ib_gid_attr current_gid_attr = {};
+
+ if (1UL << gid_type & ~gid_type_mask)
+ continue;
+
+ gid_attr.gid_type = gid_type;
+
+ mutex_lock(&table->lock);
+ write_lock_irq(&table->rwlock);
+ ix = find_gid(table, NULL, &gid_attr, true,
+ GID_ATTR_FIND_MASK_GID_TYPE |
+ GID_ATTR_FIND_MASK_DEFAULT,
+ NULL);
+
+ /* Coudn't find default GID location */
+ if (WARN_ON(ix < 0))
+ goto release;
+
+ zattr_type.gid_type = gid_type;
+
+ if (!__ib_cache_gid_get(ib_dev, port, ix,
+ &current_gid, &current_gid_attr) &&
+ mode == IB_CACHE_GID_DEFAULT_MODE_SET &&
+ !memcmp(&gid, &current_gid, sizeof(gid)) &&
+ !memcmp(&gid_attr, &current_gid_attr, sizeof(gid_attr)))
+ goto release;
+
+ if (memcmp(&current_gid, &zgid, sizeof(current_gid)) ||
+ memcmp(&current_gid_attr, &zattr_type,
+ sizeof(current_gid_attr))) {
+ if (del_gid(ib_dev, port, table, ix, true)) {
+ pr_warn("ib_cache_gid: can't delete index %d for default gid %pI6\n",
+ ix, gid.raw);
+ goto release;
+ } else {
+ dispatch_gid_change_event(ib_dev, port);
+ }
+ }
+
+ if (mode == IB_CACHE_GID_DEFAULT_MODE_SET) {
+ if (add_gid(ib_dev, port, table, ix, &gid, &gid_attr, true))
+ pr_warn("ib_cache_gid: unable to add default gid %pI6\n",
+ gid.raw);
+ else
+ dispatch_gid_change_event(ib_dev, port);
+ }
+
+release:
+ if (current_gid_attr.ndev)
+ dev_put(current_gid_attr.ndev);
+ write_unlock_irq(&table->rwlock);
+ mutex_unlock(&table->lock);
+ }
+}
+
+static int gid_table_reserve_default(struct ib_device *ib_dev, u8 port,
+ struct ib_gid_table *table)
+{
+ unsigned int i;
+ unsigned long roce_gid_type_mask;
+ unsigned int num_default_gids;
+ unsigned int current_gid = 0;
+
+ roce_gid_type_mask = roce_gid_type_mask_support(ib_dev, port);
+ num_default_gids = hweight_long(roce_gid_type_mask);
+ for (i = 0; i < num_default_gids && i < table->sz; i++) {
+ struct ib_gid_table_entry *entry =
+ &table->data_vec[i];
+
+ entry->props |= GID_TABLE_ENTRY_DEFAULT;
+ current_gid = find_next_bit(&roce_gid_type_mask,
+ BITS_PER_LONG,
+ current_gid);
+ entry->attr.gid_type = current_gid++;
+ }
+
+ return 0;
+}
+
+static int _gid_table_setup_one(struct ib_device *ib_dev)
+{
+ u8 port;
+ struct ib_gid_table **table;
+ int err = 0;
+
+ table = kcalloc(ib_dev->phys_port_cnt, sizeof(*table), GFP_KERNEL);
+
+ if (!table) {
+ pr_warn("failed to allocate ib gid cache for %s\n",
+ ib_dev->name);
+ return -ENOMEM;
+ }
+
+ for (port = 0; port < ib_dev->phys_port_cnt; port++) {
+ u8 rdma_port = port + rdma_start_port(ib_dev);
+
+ table[port] =
+ alloc_gid_table(
+ ib_dev->port_immutable[rdma_port].gid_tbl_len);
+ if (!table[port]) {
+ err = -ENOMEM;
+ goto rollback_table_setup;
+ }
+
+ err = gid_table_reserve_default(ib_dev,
+ port + rdma_start_port(ib_dev),
+ table[port]);
+ if (err)
+ goto rollback_table_setup;
+ }
+
+ ib_dev->cache.gid_cache = table;
+ return 0;
+
+rollback_table_setup:
+ for (port = 0; port < ib_dev->phys_port_cnt; port++) {
+ cleanup_gid_table_port(ib_dev, port + rdma_start_port(ib_dev),
+ table[port]);
+ release_gid_table(table[port]);
+ }
+
+ kfree(table);
+ return err;
+}
+
+static void gid_table_release_one(struct ib_device *ib_dev)
+{
+ struct ib_gid_table **table = ib_dev->cache.gid_cache;
+ u8 port;
+
+ if (!table)
+ return;
+
+ for (port = 0; port < ib_dev->phys_port_cnt; port++)
+ release_gid_table(table[port]);
+
+ kfree(table);
+ ib_dev->cache.gid_cache = NULL;
+}
+
+static void gid_table_cleanup_one(struct ib_device *ib_dev)
+{
+ struct ib_gid_table **table = ib_dev->cache.gid_cache;
+ u8 port;
+
+ if (!table)
+ return;
+
+ for (port = 0; port < ib_dev->phys_port_cnt; port++)
+ cleanup_gid_table_port(ib_dev, port + rdma_start_port(ib_dev),
+ table[port]);
+}
+
+static int gid_table_setup_one(struct ib_device *ib_dev)
+{
+ int err;
+
+ err = _gid_table_setup_one(ib_dev);
+
+ if (err)
+ return err;
+
+ err = roce_rescan_device(ib_dev);
+
+ if (err) {
+ gid_table_cleanup_one(ib_dev);
+ gid_table_release_one(ib_dev);
+ }
+
+ return err;
+}
+
+int ib_get_cached_gid(struct ib_device *device,
+ u8 port_num,
+ int index,
+ union ib_gid *gid,
+ struct ib_gid_attr *gid_attr)
+{
+ int res;
+ unsigned long flags;
+ struct ib_gid_table **ports_table = device->cache.gid_cache;
+ struct ib_gid_table *table = ports_table[port_num - rdma_start_port(device)];
+
+ if (port_num < rdma_start_port(device) || port_num > rdma_end_port(device))
+ return -EINVAL;
+
+ read_lock_irqsave(&table->rwlock, flags);
+ res = __ib_cache_gid_get(device, port_num, index, gid, gid_attr);
+ read_unlock_irqrestore(&table->rwlock, flags);
+
+ return res;
+}
+EXPORT_SYMBOL(ib_get_cached_gid);
+
+int ib_find_cached_gid(struct ib_device *device,
+ const union ib_gid *gid,
+ enum ib_gid_type gid_type,
+ struct net_device *ndev,
+ u8 *port_num,
+ u16 *index)
+{
+ return ib_cache_gid_find(device, gid, gid_type, ndev, port_num, index);
+}
+EXPORT_SYMBOL(ib_find_cached_gid);
+
+int ib_find_gid_by_filter(struct ib_device *device,
+ const union ib_gid *gid,
+ u8 port_num,
+ bool (*filter)(const union ib_gid *gid,
+ const struct ib_gid_attr *,
+ void *),
+ void *context, u16 *index)
+{
+ /* Only RoCE GID table supports filter function */
+ if (!rdma_cap_roce_gid_table(device, port_num) && filter)
+ return -EPROTONOSUPPORT;
+
+ return ib_cache_gid_find_by_filter(device, gid,
+ port_num, filter,
+ context, index);
+}
+EXPORT_SYMBOL(ib_find_gid_by_filter);
+
+int ib_get_cached_pkey(struct ib_device *device,
+ u8 port_num,
+ int index,
+ u16 *pkey)
+{
+ struct ib_pkey_cache *cache;
+ unsigned long flags;
+ int ret = 0;
+
+ if (port_num < rdma_start_port(device) || port_num > rdma_end_port(device))
+ return -EINVAL;
+
+ read_lock_irqsave(&device->cache.lock, flags);
+
+ cache = device->cache.pkey_cache[port_num - rdma_start_port(device)];
+
+ if (index < 0 || index >= cache->table_len)
+ ret = -EINVAL;
+ else
+ *pkey = cache->table[index];
+
+ read_unlock_irqrestore(&device->cache.lock, flags);
+
+ return ret;
+}
+EXPORT_SYMBOL(ib_get_cached_pkey);
+
+int ib_find_cached_pkey(struct ib_device *device,
+ u8 port_num,
+ u16 pkey,
+ u16 *index)
+{
+ struct ib_pkey_cache *cache;
+ unsigned long flags;
+ int i;
+ int ret = -ENOENT;
+ int partial_ix = -1;
+
+ if (port_num < rdma_start_port(device) || port_num > rdma_end_port(device))
+ return -EINVAL;
+
+ read_lock_irqsave(&device->cache.lock, flags);
+
+ cache = device->cache.pkey_cache[port_num - rdma_start_port(device)];
+
+ *index = -1;
+
+ for (i = 0; i < cache->table_len; ++i)
+ if ((cache->table[i] & 0x7fff) == (pkey & 0x7fff)) {
+ if (cache->table[i] & 0x8000) {
+ *index = i;
+ ret = 0;
+ break;
+ } else
+ partial_ix = i;
+ }
+
+ if (ret && partial_ix >= 0) {
+ *index = partial_ix;
+ ret = 0;
+ }
+
+ read_unlock_irqrestore(&device->cache.lock, flags);
+
+ return ret;
+}
+EXPORT_SYMBOL(ib_find_cached_pkey);
+
+int ib_find_exact_cached_pkey(struct ib_device *device,
+ u8 port_num,
+ u16 pkey,
+ u16 *index)
+{
+ struct ib_pkey_cache *cache;
+ unsigned long flags;
+ int i;
+ int ret = -ENOENT;
+
+ if (port_num < rdma_start_port(device) || port_num > rdma_end_port(device))
+ return -EINVAL;
+
+ read_lock_irqsave(&device->cache.lock, flags);
+
+ cache = device->cache.pkey_cache[port_num - rdma_start_port(device)];
+
+ *index = -1;
+
+ for (i = 0; i < cache->table_len; ++i)
+ if (cache->table[i] == pkey) {
+ *index = i;
+ ret = 0;
+ break;
+ }
+
+ read_unlock_irqrestore(&device->cache.lock, flags);
+
+ return ret;
+}
+EXPORT_SYMBOL(ib_find_exact_cached_pkey);
+
+int ib_get_cached_lmc(struct ib_device *device,
+ u8 port_num,
+ u8 *lmc)
+{
+ unsigned long flags;
+ int ret = 0;
+
+ if (port_num < rdma_start_port(device) || port_num > rdma_end_port(device))
+ return -EINVAL;
+
+ read_lock_irqsave(&device->cache.lock, flags);
+ *lmc = device->cache.lmc_cache[port_num - rdma_start_port(device)];
+ read_unlock_irqrestore(&device->cache.lock, flags);
+
+ return ret;
+}
+EXPORT_SYMBOL(ib_get_cached_lmc);
+
+static void ib_cache_update(struct ib_device *device,
+ u8 port)
+{
+ struct ib_port_attr *tprops = NULL;
+ struct ib_pkey_cache *pkey_cache = NULL, *old_pkey_cache;
+ struct ib_gid_cache {
+ int table_len;
+ union ib_gid table[0];
+ } *gid_cache = NULL;
+ int i;
+ int ret;
+ struct ib_gid_table *table;
+ struct ib_gid_table **ports_table = device->cache.gid_cache;
+ bool use_roce_gid_table =
+ rdma_cap_roce_gid_table(device, port);
+
+ if (port < rdma_start_port(device) || port > rdma_end_port(device))
+ return;
+
+ table = ports_table[port - rdma_start_port(device)];
+
+ tprops = kmalloc(sizeof *tprops, GFP_KERNEL);
+ if (!tprops)
+ return;
+
+ ret = ib_query_port(device, port, tprops);
+ if (ret) {
+ pr_warn("ib_query_port failed (%d) for %s\n",
+ ret, device->name);
+ goto err;
+ }
+
+ pkey_cache = kmalloc(sizeof *pkey_cache + tprops->pkey_tbl_len *
+ sizeof *pkey_cache->table, GFP_KERNEL);
+ if (!pkey_cache)
+ goto err;
+
+ pkey_cache->table_len = tprops->pkey_tbl_len;
+
+ if (!use_roce_gid_table) {
+ gid_cache = kmalloc(sizeof(*gid_cache) + tprops->gid_tbl_len *
+ sizeof(*gid_cache->table), GFP_KERNEL);
+ if (!gid_cache)
+ goto err;
+
+ gid_cache->table_len = tprops->gid_tbl_len;
+ }
+
+ for (i = 0; i < pkey_cache->table_len; ++i) {
+ ret = ib_query_pkey(device, port, i, pkey_cache->table + i);
+ if (ret) {
+ pr_warn("ib_query_pkey failed (%d) for %s (index %d)\n",
+ ret, device->name, i);
+ goto err;
+ }
+ }
+
+ if (!use_roce_gid_table) {
+ for (i = 0; i < gid_cache->table_len; ++i) {
+ ret = ib_query_gid(device, port, i,
+ gid_cache->table + i, NULL);
+ if (ret) {
+ pr_warn("ib_query_gid failed (%d) for %s (index %d)\n",
+ ret, device->name, i);
+ goto err;
+ }
+ }
+ }
+
+ write_lock_irq(&device->cache.lock);
+
+ old_pkey_cache = device->cache.pkey_cache[port - rdma_start_port(device)];
+
+ device->cache.pkey_cache[port - rdma_start_port(device)] = pkey_cache;
+ if (!use_roce_gid_table) {
+ write_lock(&table->rwlock);
+ for (i = 0; i < gid_cache->table_len; i++) {
+ modify_gid(device, port, table, i, gid_cache->table + i,
+ &zattr, false);
+ }
+ write_unlock(&table->rwlock);
+ }
+
+ device->cache.lmc_cache[port - rdma_start_port(device)] = tprops->lmc;
+
+ write_unlock_irq(&device->cache.lock);
+
+ kfree(gid_cache);
+ kfree(old_pkey_cache);
+ kfree(tprops);
+ return;
+
+err:
+ kfree(pkey_cache);
+ kfree(gid_cache);
+ kfree(tprops);
+}
+
+static void ib_cache_task(struct work_struct *_work)
+{
+ struct ib_update_work *work =
+ container_of(_work, struct ib_update_work, work);
+
+ ib_cache_update(work->device, work->port_num);
+ kfree(work);
+}
+
+static void ib_cache_event(struct ib_event_handler *handler,
+ struct ib_event *event)
+{
+ struct ib_update_work *work;
+
+ if (event->event == IB_EVENT_PORT_ERR ||
+ event->event == IB_EVENT_PORT_ACTIVE ||
+ event->event == IB_EVENT_LID_CHANGE ||
+ event->event == IB_EVENT_PKEY_CHANGE ||
+ event->event == IB_EVENT_SM_CHANGE ||
+ event->event == IB_EVENT_CLIENT_REREGISTER ||
+ event->event == IB_EVENT_GID_CHANGE) {
+ work = kmalloc(sizeof *work, GFP_ATOMIC);
+ if (work) {
+ INIT_WORK(&work->work, ib_cache_task);
+ work->device = event->device;
+ work->port_num = event->element.port_num;
+ queue_work(ib_wq, &work->work);
+ }
+ }
+}
+
+int ib_cache_setup_one(struct ib_device *device)
+{
+ int p;
+ int err;
+
+ rwlock_init(&device->cache.lock);
+
+ device->cache.pkey_cache =
+ kzalloc(sizeof *device->cache.pkey_cache *
+ (rdma_end_port(device) - rdma_start_port(device) + 1), GFP_KERNEL);
+ device->cache.lmc_cache = kmalloc(sizeof *device->cache.lmc_cache *
+ (rdma_end_port(device) -
+ rdma_start_port(device) + 1),
+ GFP_KERNEL);
+ if (!device->cache.pkey_cache ||
+ !device->cache.lmc_cache) {
+ pr_warn("Couldn't allocate cache for %s\n", device->name);
+ return -ENOMEM;
+ }
+
+ err = gid_table_setup_one(device);
+ if (err)
+ /* Allocated memory will be cleaned in the release function */
+ return err;
+
+ for (p = 0; p <= rdma_end_port(device) - rdma_start_port(device); ++p)
+ ib_cache_update(device, p + rdma_start_port(device));
+
+ INIT_IB_EVENT_HANDLER(&device->cache.event_handler,
+ device, ib_cache_event);
+ err = ib_register_event_handler(&device->cache.event_handler);
+ if (err)
+ goto err;
+
+ return 0;
+
+err:
+ gid_table_cleanup_one(device);
+ return err;
+}
+
+void ib_cache_release_one(struct ib_device *device)
+{
+ int p;
+
+ /*
+ * The release function frees all the cache elements.
+ * This function should be called as part of freeing
+ * all the device's resources when the cache could no
+ * longer be accessed.
+ */
+ if (device->cache.pkey_cache)
+ for (p = 0;
+ p <= rdma_end_port(device) - rdma_start_port(device); ++p)
+ kfree(device->cache.pkey_cache[p]);
+
+ gid_table_release_one(device);
+ kfree(device->cache.pkey_cache);
+ kfree(device->cache.lmc_cache);
+}
+
+void ib_cache_cleanup_one(struct ib_device *device)
+{
+ /* The cleanup function unregisters the event handler,
+ * waits for all in-progress workqueue elements and cleans
+ * up the GID cache. This function should be called after
+ * the device was removed from the devices list and all
+ * clients were removed, so the cache exists but is
+ * non-functional and shouldn't be updated anymore.
+ */
+ ib_unregister_event_handler(&device->cache.event_handler);
+ flush_workqueue(ib_wq);
+ gid_table_cleanup_one(device);
+}
+
+void __init ib_cache_setup(void)
+{
+ roce_gid_mgmt_init();
+}
+
+void __exit ib_cache_cleanup(void)
+{
+ roce_gid_mgmt_cleanup();
+}
diff --git a/sys/ofed/drivers/infiniband/core/ib_cm.c b/sys/ofed/drivers/infiniband/core/ib_cm.c
new file mode 100644
index 0000000..253881f
--- /dev/null
+++ b/sys/ofed/drivers/infiniband/core/ib_cm.c
@@ -0,0 +1,4141 @@
+/*
+ * Copyright (c) 2004-2007 Intel Corporation. All rights reserved.
+ * Copyright (c) 2004 Topspin Corporation. All rights reserved.
+ * Copyright (c) 2004, 2005 Voltaire Corporation. All rights reserved.
+ * Copyright (c) 2005 Sun Microsystems, Inc. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#include <linux/completion.h>
+#include <linux/dma-mapping.h>
+#include <linux/device.h>
+#include <linux/module.h>
+#include <linux/err.h>
+#include <linux/idr.h>
+#include <linux/interrupt.h>
+#include <linux/random.h>
+#include <linux/rbtree.h>
+#include <linux/spinlock.h>
+#include <linux/slab.h>
+#include <linux/sysfs.h>
+#include <linux/workqueue.h>
+#include <linux/kdev_t.h>
+#include <linux/etherdevice.h>
+
+#include <asm/atomic-long.h>
+
+#include <rdma/ib_cache.h>
+#include <rdma/ib_cm.h>
+#include "cm_msgs.h"
+
+MODULE_AUTHOR("Sean Hefty");
+MODULE_DESCRIPTION("InfiniBand CM");
+MODULE_LICENSE("Dual BSD/GPL");
+
+static void cm_add_one(struct ib_device *device);
+static void cm_remove_one(struct ib_device *device, void *client_data);
+
+static struct ib_client cm_client = {
+ .name = "cm",
+ .add = cm_add_one,
+ .remove = cm_remove_one
+};
+
+static struct ib_cm {
+ spinlock_t lock;
+ struct list_head device_list;
+ rwlock_t device_lock;
+ struct rb_root listen_service_table;
+ u64 listen_service_id;
+ /* struct rb_root peer_service_table; todo: fix peer to peer */
+ struct rb_root remote_qp_table;
+ struct rb_root remote_id_table;
+ struct rb_root remote_sidr_table;
+ struct idr local_id_table;
+ __be32 random_id_operand;
+ struct list_head timewait_list;
+ struct workqueue_struct *wq;
+ /* Sync on cm change port state */
+ spinlock_t state_lock;
+} cm;
+
+/* Counter indexes ordered by attribute ID */
+enum {
+ CM_REQ_COUNTER,
+ CM_MRA_COUNTER,
+ CM_REJ_COUNTER,
+ CM_REP_COUNTER,
+ CM_RTU_COUNTER,
+ CM_DREQ_COUNTER,
+ CM_DREP_COUNTER,
+ CM_SIDR_REQ_COUNTER,
+ CM_SIDR_REP_COUNTER,
+ CM_LAP_COUNTER,
+ CM_APR_COUNTER,
+ CM_ATTR_COUNT,
+ CM_ATTR_ID_OFFSET = 0x0010,
+};
+
+enum {
+ CM_XMIT,
+ CM_XMIT_RETRIES,
+ CM_RECV,
+ CM_RECV_DUPLICATES,
+ CM_COUNTER_GROUPS
+};
+
+static char const counter_group_names[CM_COUNTER_GROUPS]
+ [sizeof("cm_rx_duplicates")] = {
+ "cm_tx_msgs", "cm_tx_retries",
+ "cm_rx_msgs", "cm_rx_duplicates"
+};
+
+struct cm_counter_group {
+ struct kobject obj;
+ atomic_long_t counter[CM_ATTR_COUNT];
+};
+
+struct cm_counter_attribute {
+ struct attribute attr;
+ int index;
+};
+
+#define CM_COUNTER_ATTR(_name, _index) \
+struct cm_counter_attribute cm_##_name##_counter_attr = { \
+ .attr = { .name = __stringify(_name), .mode = 0444 }, \
+ .index = _index \
+}
+
+static CM_COUNTER_ATTR(req, CM_REQ_COUNTER);
+static CM_COUNTER_ATTR(mra, CM_MRA_COUNTER);
+static CM_COUNTER_ATTR(rej, CM_REJ_COUNTER);
+static CM_COUNTER_ATTR(rep, CM_REP_COUNTER);
+static CM_COUNTER_ATTR(rtu, CM_RTU_COUNTER);
+static CM_COUNTER_ATTR(dreq, CM_DREQ_COUNTER);
+static CM_COUNTER_ATTR(drep, CM_DREP_COUNTER);
+static CM_COUNTER_ATTR(sidr_req, CM_SIDR_REQ_COUNTER);
+static CM_COUNTER_ATTR(sidr_rep, CM_SIDR_REP_COUNTER);
+static CM_COUNTER_ATTR(lap, CM_LAP_COUNTER);
+static CM_COUNTER_ATTR(apr, CM_APR_COUNTER);
+
+static struct attribute *cm_counter_default_attrs[] = {
+ &cm_req_counter_attr.attr,
+ &cm_mra_counter_attr.attr,
+ &cm_rej_counter_attr.attr,
+ &cm_rep_counter_attr.attr,
+ &cm_rtu_counter_attr.attr,
+ &cm_dreq_counter_attr.attr,
+ &cm_drep_counter_attr.attr,
+ &cm_sidr_req_counter_attr.attr,
+ &cm_sidr_rep_counter_attr.attr,
+ &cm_lap_counter_attr.attr,
+ &cm_apr_counter_attr.attr,
+ NULL
+};
+
+struct cm_port {
+ struct cm_device *cm_dev;
+ struct ib_mad_agent *mad_agent;
+ struct kobject port_obj;
+ u8 port_num;
+ struct list_head cm_priv_prim_list;
+ struct list_head cm_priv_altr_list;
+ struct cm_counter_group counter_group[CM_COUNTER_GROUPS];
+};
+
+struct cm_device {
+ struct list_head list;
+ struct ib_device *ib_device;
+ struct device *device;
+ u8 ack_delay;
+ int going_down;
+ struct cm_port *port[0];
+};
+
+struct cm_av {
+ struct cm_port *port;
+ union ib_gid dgid;
+ struct ib_ah_attr ah_attr;
+ u16 pkey_index;
+ u8 timeout;
+};
+
+struct cm_work {
+ struct delayed_work work;
+ struct list_head list;
+ struct cm_port *port;
+ struct ib_mad_recv_wc *mad_recv_wc; /* Received MADs */
+ __be32 local_id; /* Established / timewait */
+ __be32 remote_id;
+ struct ib_cm_event cm_event;
+ struct ib_sa_path_rec path[0];
+};
+
+struct cm_timewait_info {
+ struct cm_work work; /* Must be first. */
+ struct list_head list;
+ struct rb_node remote_qp_node;
+ struct rb_node remote_id_node;
+ __be64 remote_ca_guid;
+ __be32 remote_qpn;
+ u8 inserted_remote_qp;
+ u8 inserted_remote_id;
+};
+
+struct cm_id_private {
+ struct ib_cm_id id;
+
+ struct rb_node service_node;
+ struct rb_node sidr_id_node;
+ spinlock_t lock; /* Do not acquire inside cm.lock */
+ struct completion comp;
+ atomic_t refcount;
+ /* Number of clients sharing this ib_cm_id. Only valid for listeners.
+ * Protected by the cm.lock spinlock. */
+ int listen_sharecount;
+
+ struct ib_mad_send_buf *msg;
+ struct cm_timewait_info *timewait_info;
+ /* todo: use alternate port on send failure */
+ struct cm_av av;
+ struct cm_av alt_av;
+
+ void *private_data;
+ __be64 tid;
+ __be32 local_qpn;
+ __be32 remote_qpn;
+ enum ib_qp_type qp_type;
+ __be32 sq_psn;
+ __be32 rq_psn;
+ int timeout_ms;
+ enum ib_mtu path_mtu;
+ __be16 pkey;
+ u8 private_data_len;
+ u8 max_cm_retries;
+ u8 peer_to_peer;
+ u8 responder_resources;
+ u8 initiator_depth;
+ u8 retry_count;
+ u8 rnr_retry_count;
+ u8 service_timeout;
+ u8 target_ack_delay;
+
+ struct list_head prim_list;
+ struct list_head altr_list;
+ /* Indicates that the send port mad is registered and av is set */
+ int prim_send_port_not_ready;
+ int altr_send_port_not_ready;
+
+ struct list_head work_list;
+ atomic_t work_count;
+};
+
+static void cm_work_handler(struct work_struct *work);
+
+static inline void cm_deref_id(struct cm_id_private *cm_id_priv)
+{
+ if (atomic_dec_and_test(&cm_id_priv->refcount))
+ complete(&cm_id_priv->comp);
+}
+
+static int cm_alloc_msg(struct cm_id_private *cm_id_priv,
+ struct ib_mad_send_buf **msg)
+{
+ struct ib_mad_agent *mad_agent;
+ struct ib_mad_send_buf *m;
+ struct ib_ah *ah;
+ struct cm_av *av;
+ unsigned long flags, flags2;
+ int ret = 0;
+
+ /* don't let the port to be released till the agent is down */
+ spin_lock_irqsave(&cm.state_lock, flags2);
+ spin_lock_irqsave(&cm.lock, flags);
+ if (!cm_id_priv->prim_send_port_not_ready)
+ av = &cm_id_priv->av;
+ else if (!cm_id_priv->altr_send_port_not_ready &&
+ (cm_id_priv->alt_av.port))
+ av = &cm_id_priv->alt_av;
+ else {
+ pr_info("%s: not valid CM id\n", __func__);
+ ret = -ENODEV;
+ spin_unlock_irqrestore(&cm.lock, flags);
+ goto out;
+ }
+ spin_unlock_irqrestore(&cm.lock, flags);
+ /* Make sure the port haven't released the mad yet */
+ mad_agent = cm_id_priv->av.port->mad_agent;
+ if (!mad_agent) {
+ pr_info("%s: not a valid MAD agent\n", __func__);
+ ret = -ENODEV;
+ goto out;
+ }
+ ah = ib_create_ah(mad_agent->qp->pd, &av->ah_attr);
+ if (IS_ERR(ah)) {
+ ret = PTR_ERR(ah);
+ goto out;
+ }
+
+ m = ib_create_send_mad(mad_agent, cm_id_priv->id.remote_cm_qpn,
+ av->pkey_index,
+ 0, IB_MGMT_MAD_HDR, IB_MGMT_MAD_DATA,
+ GFP_ATOMIC,
+ IB_MGMT_BASE_VERSION);
+ if (IS_ERR(m)) {
+ ib_destroy_ah(ah);
+ ret = PTR_ERR(m);
+ goto out;
+ }
+
+ /* Timeout set by caller if response is expected. */
+ m->ah = ah;
+ m->retries = cm_id_priv->max_cm_retries;
+
+ atomic_inc(&cm_id_priv->refcount);
+ m->context[0] = cm_id_priv;
+ *msg = m;
+
+out:
+ spin_unlock_irqrestore(&cm.state_lock, flags2);
+ return ret;
+}
+
+static int cm_alloc_response_msg(struct cm_port *port,
+ struct ib_mad_recv_wc *mad_recv_wc,
+ struct ib_mad_send_buf **msg)
+{
+ struct ib_mad_send_buf *m;
+ struct ib_ah *ah;
+
+ ah = ib_create_ah_from_wc(port->mad_agent->qp->pd, mad_recv_wc->wc,
+ mad_recv_wc->recv_buf.grh, port->port_num);
+ if (IS_ERR(ah))
+ return PTR_ERR(ah);
+
+ m = ib_create_send_mad(port->mad_agent, 1, mad_recv_wc->wc->pkey_index,
+ 0, IB_MGMT_MAD_HDR, IB_MGMT_MAD_DATA,
+ GFP_ATOMIC,
+ IB_MGMT_BASE_VERSION);
+ if (IS_ERR(m)) {
+ ib_destroy_ah(ah);
+ return PTR_ERR(m);
+ }
+ m->ah = ah;
+ *msg = m;
+ return 0;
+}
+
+static void cm_free_msg(struct ib_mad_send_buf *msg)
+{
+ ib_destroy_ah(msg->ah);
+ if (msg->context[0])
+ cm_deref_id(msg->context[0]);
+ ib_free_send_mad(msg);
+}
+
+static void * cm_copy_private_data(const void *private_data,
+ u8 private_data_len)
+{
+ void *data;
+
+ if (!private_data || !private_data_len)
+ return NULL;
+
+ data = kmemdup(private_data, private_data_len, GFP_KERNEL);
+ if (!data)
+ return ERR_PTR(-ENOMEM);
+
+ return data;
+}
+
+static void cm_set_private_data(struct cm_id_private *cm_id_priv,
+ void *private_data, u8 private_data_len)
+{
+ if (cm_id_priv->private_data && cm_id_priv->private_data_len)
+ kfree(cm_id_priv->private_data);
+
+ cm_id_priv->private_data = private_data;
+ cm_id_priv->private_data_len = private_data_len;
+}
+
+static void cm_init_av_for_response(struct cm_port *port, struct ib_wc *wc,
+ struct ib_grh *grh, struct cm_av *av)
+{
+ av->port = port;
+ av->pkey_index = wc->pkey_index;
+ ib_init_ah_from_wc(port->cm_dev->ib_device, port->port_num, wc,
+ grh, &av->ah_attr);
+}
+
+static int cm_init_av_by_path(struct ib_sa_path_rec *path, struct cm_av *av,
+ struct cm_id_private *cm_id_priv)
+{
+ struct cm_device *cm_dev;
+ struct cm_port *port = NULL;
+ unsigned long flags;
+ int ret;
+ u8 p;
+ struct net_device *ndev = ib_get_ndev_from_path(path);
+
+ read_lock_irqsave(&cm.device_lock, flags);
+ list_for_each_entry(cm_dev, &cm.device_list, list) {
+ if (!ib_find_cached_gid(cm_dev->ib_device, &path->sgid,
+ path->gid_type, ndev, &p, NULL)) {
+ port = cm_dev->port[p-1];
+ break;
+ }
+ }
+ read_unlock_irqrestore(&cm.device_lock, flags);
+
+ if (ndev)
+ dev_put(ndev);
+
+ if (!port)
+ return -EINVAL;
+
+ ret = ib_find_cached_pkey(cm_dev->ib_device, port->port_num,
+ be16_to_cpu(path->pkey), &av->pkey_index);
+ if (ret)
+ return ret;
+
+ av->port = port;
+ ret = ib_init_ah_from_path(cm_dev->ib_device, port->port_num,
+ path, &av->ah_attr);
+ if (ret)
+ return ret;
+
+ av->timeout = path->packet_life_time + 1;
+
+ spin_lock_irqsave(&cm.lock, flags);
+ if (&cm_id_priv->av == av)
+ list_add_tail(&cm_id_priv->prim_list, &port->cm_priv_prim_list);
+ else if (&cm_id_priv->alt_av == av)
+ list_add_tail(&cm_id_priv->altr_list, &port->cm_priv_altr_list);
+ else
+ ret = -EINVAL;
+
+ spin_unlock_irqrestore(&cm.lock, flags);
+
+ return ret;
+}
+
+static int cm_alloc_id(struct cm_id_private *cm_id_priv)
+{
+ unsigned long flags;
+ int id;
+
+ idr_preload(GFP_KERNEL);
+ spin_lock_irqsave(&cm.lock, flags);
+
+ id = idr_alloc_cyclic(&cm.local_id_table, cm_id_priv, 0, 0, GFP_NOWAIT);
+
+ spin_unlock_irqrestore(&cm.lock, flags);
+ idr_preload_end();
+
+ cm_id_priv->id.local_id = (__force __be32)id ^ cm.random_id_operand;
+ return id < 0 ? id : 0;
+}
+
+static void cm_free_id(__be32 local_id)
+{
+ spin_lock_irq(&cm.lock);
+ idr_remove(&cm.local_id_table,
+ (__force int) (local_id ^ cm.random_id_operand));
+ spin_unlock_irq(&cm.lock);
+}
+
+static struct cm_id_private * cm_get_id(__be32 local_id, __be32 remote_id)
+{
+ struct cm_id_private *cm_id_priv;
+
+ cm_id_priv = idr_find(&cm.local_id_table,
+ (__force int) (local_id ^ cm.random_id_operand));
+ if (cm_id_priv) {
+ if (cm_id_priv->id.remote_id == remote_id)
+ atomic_inc(&cm_id_priv->refcount);
+ else
+ cm_id_priv = NULL;
+ }
+
+ return cm_id_priv;
+}
+
+static struct cm_id_private * cm_acquire_id(__be32 local_id, __be32 remote_id)
+{
+ struct cm_id_private *cm_id_priv;
+
+ spin_lock_irq(&cm.lock);
+ cm_id_priv = cm_get_id(local_id, remote_id);
+ spin_unlock_irq(&cm.lock);
+
+ return cm_id_priv;
+}
+
+/*
+ * Trivial helpers to strip endian annotation and compare; the
+ * endianness doesn't actually matter since we just need a stable
+ * order for the RB tree.
+ */
+static int be32_lt(__be32 a, __be32 b)
+{
+ return (__force u32) a < (__force u32) b;
+}
+
+static int be32_gt(__be32 a, __be32 b)
+{
+ return (__force u32) a > (__force u32) b;
+}
+
+static int be64_lt(__be64 a, __be64 b)
+{
+ return (__force u64) a < (__force u64) b;
+}
+
+static int be64_gt(__be64 a, __be64 b)
+{
+ return (__force u64) a > (__force u64) b;
+}
+
+static struct cm_id_private * cm_insert_listen(struct cm_id_private *cm_id_priv)
+{
+ struct rb_node **link = &cm.listen_service_table.rb_node;
+ struct rb_node *parent = NULL;
+ struct cm_id_private *cur_cm_id_priv;
+ __be64 service_id = cm_id_priv->id.service_id;
+ __be64 service_mask = cm_id_priv->id.service_mask;
+
+ while (*link) {
+ parent = *link;
+ cur_cm_id_priv = rb_entry(parent, struct cm_id_private,
+ service_node);
+ if ((cur_cm_id_priv->id.service_mask & service_id) ==
+ (service_mask & cur_cm_id_priv->id.service_id) &&
+ (cm_id_priv->id.device == cur_cm_id_priv->id.device))
+ return cur_cm_id_priv;
+
+ if (cm_id_priv->id.device < cur_cm_id_priv->id.device)
+ link = &(*link)->rb_left;
+ else if (cm_id_priv->id.device > cur_cm_id_priv->id.device)
+ link = &(*link)->rb_right;
+ else if (be64_lt(service_id, cur_cm_id_priv->id.service_id))
+ link = &(*link)->rb_left;
+ else if (be64_gt(service_id, cur_cm_id_priv->id.service_id))
+ link = &(*link)->rb_right;
+ else
+ link = &(*link)->rb_right;
+ }
+ rb_link_node(&cm_id_priv->service_node, parent, link);
+ rb_insert_color(&cm_id_priv->service_node, &cm.listen_service_table);
+ return NULL;
+}
+
+static struct cm_id_private * cm_find_listen(struct ib_device *device,
+ __be64 service_id)
+{
+ struct rb_node *node = cm.listen_service_table.rb_node;
+ struct cm_id_private *cm_id_priv;
+
+ while (node) {
+ cm_id_priv = rb_entry(node, struct cm_id_private, service_node);
+ if ((cm_id_priv->id.service_mask & service_id) ==
+ cm_id_priv->id.service_id &&
+ (cm_id_priv->id.device == device))
+ return cm_id_priv;
+
+ if (device < cm_id_priv->id.device)
+ node = node->rb_left;
+ else if (device > cm_id_priv->id.device)
+ node = node->rb_right;
+ else if (be64_lt(service_id, cm_id_priv->id.service_id))
+ node = node->rb_left;
+ else if (be64_gt(service_id, cm_id_priv->id.service_id))
+ node = node->rb_right;
+ else
+ node = node->rb_right;
+ }
+ return NULL;
+}
+
+static struct cm_timewait_info * cm_insert_remote_id(struct cm_timewait_info
+ *timewait_info)
+{
+ struct rb_node **link = &cm.remote_id_table.rb_node;
+ struct rb_node *parent = NULL;
+ struct cm_timewait_info *cur_timewait_info;
+ __be64 remote_ca_guid = timewait_info->remote_ca_guid;
+ __be32 remote_id = timewait_info->work.remote_id;
+
+ while (*link) {
+ parent = *link;
+ cur_timewait_info = rb_entry(parent, struct cm_timewait_info,
+ remote_id_node);
+ if (be32_lt(remote_id, cur_timewait_info->work.remote_id))
+ link = &(*link)->rb_left;
+ else if (be32_gt(remote_id, cur_timewait_info->work.remote_id))
+ link = &(*link)->rb_right;
+ else if (be64_lt(remote_ca_guid, cur_timewait_info->remote_ca_guid))
+ link = &(*link)->rb_left;
+ else if (be64_gt(remote_ca_guid, cur_timewait_info->remote_ca_guid))
+ link = &(*link)->rb_right;
+ else
+ return cur_timewait_info;
+ }
+ timewait_info->inserted_remote_id = 1;
+ rb_link_node(&timewait_info->remote_id_node, parent, link);
+ rb_insert_color(&timewait_info->remote_id_node, &cm.remote_id_table);
+ return NULL;
+}
+
+static struct cm_timewait_info * cm_find_remote_id(__be64 remote_ca_guid,
+ __be32 remote_id)
+{
+ struct rb_node *node = cm.remote_id_table.rb_node;
+ struct cm_timewait_info *timewait_info;
+
+ while (node) {
+ timewait_info = rb_entry(node, struct cm_timewait_info,
+ remote_id_node);
+ if (be32_lt(remote_id, timewait_info->work.remote_id))
+ node = node->rb_left;
+ else if (be32_gt(remote_id, timewait_info->work.remote_id))
+ node = node->rb_right;
+ else if (be64_lt(remote_ca_guid, timewait_info->remote_ca_guid))
+ node = node->rb_left;
+ else if (be64_gt(remote_ca_guid, timewait_info->remote_ca_guid))
+ node = node->rb_right;
+ else
+ return timewait_info;
+ }
+ return NULL;
+}
+
+static struct cm_timewait_info * cm_insert_remote_qpn(struct cm_timewait_info
+ *timewait_info)
+{
+ struct rb_node **link = &cm.remote_qp_table.rb_node;
+ struct rb_node *parent = NULL;
+ struct cm_timewait_info *cur_timewait_info;
+ __be64 remote_ca_guid = timewait_info->remote_ca_guid;
+ __be32 remote_qpn = timewait_info->remote_qpn;
+
+ while (*link) {
+ parent = *link;
+ cur_timewait_info = rb_entry(parent, struct cm_timewait_info,
+ remote_qp_node);
+ if (be32_lt(remote_qpn, cur_timewait_info->remote_qpn))
+ link = &(*link)->rb_left;
+ else if (be32_gt(remote_qpn, cur_timewait_info->remote_qpn))
+ link = &(*link)->rb_right;
+ else if (be64_lt(remote_ca_guid, cur_timewait_info->remote_ca_guid))
+ link = &(*link)->rb_left;
+ else if (be64_gt(remote_ca_guid, cur_timewait_info->remote_ca_guid))
+ link = &(*link)->rb_right;
+ else
+ return cur_timewait_info;
+ }
+ timewait_info->inserted_remote_qp = 1;
+ rb_link_node(&timewait_info->remote_qp_node, parent, link);
+ rb_insert_color(&timewait_info->remote_qp_node, &cm.remote_qp_table);
+ return NULL;
+}
+
+static struct cm_id_private * cm_insert_remote_sidr(struct cm_id_private
+ *cm_id_priv)
+{
+ struct rb_node **link = &cm.remote_sidr_table.rb_node;
+ struct rb_node *parent = NULL;
+ struct cm_id_private *cur_cm_id_priv;
+ union ib_gid *port_gid = &cm_id_priv->av.dgid;
+ __be32 remote_id = cm_id_priv->id.remote_id;
+
+ while (*link) {
+ parent = *link;
+ cur_cm_id_priv = rb_entry(parent, struct cm_id_private,
+ sidr_id_node);
+ if (be32_lt(remote_id, cur_cm_id_priv->id.remote_id))
+ link = &(*link)->rb_left;
+ else if (be32_gt(remote_id, cur_cm_id_priv->id.remote_id))
+ link = &(*link)->rb_right;
+ else {
+ int cmp;
+ cmp = memcmp(port_gid, &cur_cm_id_priv->av.dgid,
+ sizeof *port_gid);
+ if (cmp < 0)
+ link = &(*link)->rb_left;
+ else if (cmp > 0)
+ link = &(*link)->rb_right;
+ else
+ return cur_cm_id_priv;
+ }
+ }
+ rb_link_node(&cm_id_priv->sidr_id_node, parent, link);
+ rb_insert_color(&cm_id_priv->sidr_id_node, &cm.remote_sidr_table);
+ return NULL;
+}
+
+static void cm_reject_sidr_req(struct cm_id_private *cm_id_priv,
+ enum ib_cm_sidr_status status)
+{
+ struct ib_cm_sidr_rep_param param;
+
+ memset(&param, 0, sizeof param);
+ param.status = status;
+ ib_send_cm_sidr_rep(&cm_id_priv->id, &param);
+}
+
+struct ib_cm_id *ib_create_cm_id(struct ib_device *device,
+ ib_cm_handler cm_handler,
+ void *context)
+{
+ struct cm_id_private *cm_id_priv;
+ int ret;
+
+ cm_id_priv = kzalloc(sizeof *cm_id_priv, GFP_KERNEL);
+ if (!cm_id_priv)
+ return ERR_PTR(-ENOMEM);
+
+ cm_id_priv->id.state = IB_CM_IDLE;
+ cm_id_priv->id.device = device;
+ cm_id_priv->id.cm_handler = cm_handler;
+ cm_id_priv->id.context = context;
+ cm_id_priv->id.remote_cm_qpn = 1;
+ ret = cm_alloc_id(cm_id_priv);
+ if (ret)
+ goto error;
+
+ spin_lock_init(&cm_id_priv->lock);
+ init_completion(&cm_id_priv->comp);
+ INIT_LIST_HEAD(&cm_id_priv->work_list);
+ INIT_LIST_HEAD(&cm_id_priv->prim_list);
+ INIT_LIST_HEAD(&cm_id_priv->altr_list);
+ atomic_set(&cm_id_priv->work_count, -1);
+ atomic_set(&cm_id_priv->refcount, 1);
+ return &cm_id_priv->id;
+
+error:
+ kfree(cm_id_priv);
+ return ERR_PTR(-ENOMEM);
+}
+EXPORT_SYMBOL(ib_create_cm_id);
+
+static struct cm_work * cm_dequeue_work(struct cm_id_private *cm_id_priv)
+{
+ struct cm_work *work;
+
+ if (list_empty(&cm_id_priv->work_list))
+ return NULL;
+
+ work = list_entry(cm_id_priv->work_list.next, struct cm_work, list);
+ list_del(&work->list);
+ return work;
+}
+
+static void cm_free_work(struct cm_work *work)
+{
+ if (work->mad_recv_wc)
+ ib_free_recv_mad(work->mad_recv_wc);
+ kfree(work);
+}
+
+static inline int cm_convert_to_ms(int iba_time)
+{
+ /* approximate conversion to ms from 4.096us x 2^iba_time */
+ return 1 << max(iba_time - 8, 0);
+}
+
+/*
+ * calculate: 4.096x2^ack_timeout = 4.096x2^ack_delay + 2x4.096x2^life_time
+ * Because of how ack_timeout is stored, adding one doubles the timeout.
+ * To avoid large timeouts, select the max(ack_delay, life_time + 1), and
+ * increment it (round up) only if the other is within 50%.
+ */
+static u8 cm_ack_timeout(u8 ca_ack_delay, u8 packet_life_time)
+{
+ int ack_timeout = packet_life_time + 1;
+
+ if (ack_timeout >= ca_ack_delay)
+ ack_timeout += (ca_ack_delay >= (ack_timeout - 1));
+ else
+ ack_timeout = ca_ack_delay +
+ (ack_timeout >= (ca_ack_delay - 1));
+
+ return min(31, ack_timeout);
+}
+
+static void cm_cleanup_timewait(struct cm_timewait_info *timewait_info)
+{
+ if (timewait_info->inserted_remote_id) {
+ rb_erase(&timewait_info->remote_id_node, &cm.remote_id_table);
+ timewait_info->inserted_remote_id = 0;
+ }
+
+ if (timewait_info->inserted_remote_qp) {
+ rb_erase(&timewait_info->remote_qp_node, &cm.remote_qp_table);
+ timewait_info->inserted_remote_qp = 0;
+ }
+}
+
+static struct cm_timewait_info * cm_create_timewait_info(__be32 local_id)
+{
+ struct cm_timewait_info *timewait_info;
+
+ timewait_info = kzalloc(sizeof *timewait_info, GFP_KERNEL);
+ if (!timewait_info)
+ return ERR_PTR(-ENOMEM);
+
+ timewait_info->work.local_id = local_id;
+ INIT_DELAYED_WORK(&timewait_info->work.work, cm_work_handler);
+ timewait_info->work.cm_event.event = IB_CM_TIMEWAIT_EXIT;
+ return timewait_info;
+}
+
+static void cm_enter_timewait(struct cm_id_private *cm_id_priv)
+{
+ int wait_time;
+ unsigned long flags;
+ struct cm_device *cm_dev;
+
+ cm_dev = ib_get_client_data(cm_id_priv->id.device, &cm_client);
+ if (!cm_dev)
+ return;
+
+ spin_lock_irqsave(&cm.lock, flags);
+ cm_cleanup_timewait(cm_id_priv->timewait_info);
+ list_add_tail(&cm_id_priv->timewait_info->list, &cm.timewait_list);
+ spin_unlock_irqrestore(&cm.lock, flags);
+
+ /*
+ * The cm_id could be destroyed by the user before we exit timewait.
+ * To protect against this, we search for the cm_id after exiting
+ * timewait before notifying the user that we've exited timewait.
+ */
+ cm_id_priv->id.state = IB_CM_TIMEWAIT;
+ wait_time = cm_convert_to_ms(cm_id_priv->av.timeout);
+
+ /* Check if the device started its remove_one */
+ spin_lock_irqsave(&cm.lock, flags);
+ if (!cm_dev->going_down)
+ queue_delayed_work(cm.wq, &cm_id_priv->timewait_info->work.work,
+ msecs_to_jiffies(wait_time));
+ spin_unlock_irqrestore(&cm.lock, flags);
+
+ cm_id_priv->timewait_info = NULL;
+}
+
+static void cm_reset_to_idle(struct cm_id_private *cm_id_priv)
+{
+ unsigned long flags;
+
+ cm_id_priv->id.state = IB_CM_IDLE;
+ if (cm_id_priv->timewait_info) {
+ spin_lock_irqsave(&cm.lock, flags);
+ cm_cleanup_timewait(cm_id_priv->timewait_info);
+ spin_unlock_irqrestore(&cm.lock, flags);
+ kfree(cm_id_priv->timewait_info);
+ cm_id_priv->timewait_info = NULL;
+ }
+}
+
+static void cm_destroy_id(struct ib_cm_id *cm_id, int err)
+{
+ struct cm_id_private *cm_id_priv;
+ struct cm_work *work;
+
+ cm_id_priv = container_of(cm_id, struct cm_id_private, id);
+retest:
+ spin_lock_irq(&cm_id_priv->lock);
+ switch (cm_id->state) {
+ case IB_CM_LISTEN:
+ spin_unlock_irq(&cm_id_priv->lock);
+
+ spin_lock_irq(&cm.lock);
+ if (--cm_id_priv->listen_sharecount > 0) {
+ /* The id is still shared. */
+ cm_deref_id(cm_id_priv);
+ spin_unlock_irq(&cm.lock);
+ return;
+ }
+ rb_erase(&cm_id_priv->service_node, &cm.listen_service_table);
+ spin_unlock_irq(&cm.lock);
+ break;
+ case IB_CM_SIDR_REQ_SENT:
+ cm_id->state = IB_CM_IDLE;
+ ib_cancel_mad(cm_id_priv->av.port->mad_agent, cm_id_priv->msg);
+ spin_unlock_irq(&cm_id_priv->lock);
+ break;
+ case IB_CM_SIDR_REQ_RCVD:
+ spin_unlock_irq(&cm_id_priv->lock);
+ cm_reject_sidr_req(cm_id_priv, IB_SIDR_REJECT);
+ spin_lock_irq(&cm.lock);
+ if (!RB_EMPTY_NODE(&cm_id_priv->sidr_id_node))
+ rb_erase(&cm_id_priv->sidr_id_node,
+ &cm.remote_sidr_table);
+ spin_unlock_irq(&cm.lock);
+ break;
+ case IB_CM_REQ_SENT:
+ case IB_CM_MRA_REQ_RCVD:
+ ib_cancel_mad(cm_id_priv->av.port->mad_agent, cm_id_priv->msg);
+ spin_unlock_irq(&cm_id_priv->lock);
+ ib_send_cm_rej(cm_id, IB_CM_REJ_TIMEOUT,
+ &cm_id_priv->id.device->node_guid,
+ sizeof cm_id_priv->id.device->node_guid,
+ NULL, 0);
+ break;
+ case IB_CM_REQ_RCVD:
+ if (err == -ENOMEM) {
+ /* Do not reject to allow future retries. */
+ cm_reset_to_idle(cm_id_priv);
+ spin_unlock_irq(&cm_id_priv->lock);
+ } else {
+ spin_unlock_irq(&cm_id_priv->lock);
+ ib_send_cm_rej(cm_id, IB_CM_REJ_CONSUMER_DEFINED,
+ NULL, 0, NULL, 0);
+ }
+ break;
+ case IB_CM_REP_SENT:
+ case IB_CM_MRA_REP_RCVD:
+ ib_cancel_mad(cm_id_priv->av.port->mad_agent, cm_id_priv->msg);
+ /* Fall through */
+ case IB_CM_MRA_REQ_SENT:
+ case IB_CM_REP_RCVD:
+ case IB_CM_MRA_REP_SENT:
+ spin_unlock_irq(&cm_id_priv->lock);
+ ib_send_cm_rej(cm_id, IB_CM_REJ_CONSUMER_DEFINED,
+ NULL, 0, NULL, 0);
+ break;
+ case IB_CM_ESTABLISHED:
+ spin_unlock_irq(&cm_id_priv->lock);
+ if (cm_id_priv->qp_type == IB_QPT_XRC_TGT)
+ break;
+ ib_send_cm_dreq(cm_id, NULL, 0);
+ goto retest;
+ case IB_CM_DREQ_SENT:
+ ib_cancel_mad(cm_id_priv->av.port->mad_agent, cm_id_priv->msg);
+ cm_enter_timewait(cm_id_priv);
+ spin_unlock_irq(&cm_id_priv->lock);
+ break;
+ case IB_CM_DREQ_RCVD:
+ spin_unlock_irq(&cm_id_priv->lock);
+ ib_send_cm_drep(cm_id, NULL, 0);
+ break;
+ default:
+ spin_unlock_irq(&cm_id_priv->lock);
+ break;
+ }
+
+ spin_lock_irq(&cm.lock);
+ if (!list_empty(&cm_id_priv->altr_list) &&
+ (!cm_id_priv->altr_send_port_not_ready))
+ list_del(&cm_id_priv->altr_list);
+ if (!list_empty(&cm_id_priv->prim_list) &&
+ (!cm_id_priv->prim_send_port_not_ready))
+ list_del(&cm_id_priv->prim_list);
+ spin_unlock_irq(&cm.lock);
+
+ cm_free_id(cm_id->local_id);
+ cm_deref_id(cm_id_priv);
+ wait_for_completion(&cm_id_priv->comp);
+ while ((work = cm_dequeue_work(cm_id_priv)) != NULL)
+ cm_free_work(work);
+ kfree(cm_id_priv->private_data);
+ kfree(cm_id_priv);
+}
+
+void ib_destroy_cm_id(struct ib_cm_id *cm_id)
+{
+ cm_destroy_id(cm_id, 0);
+}
+EXPORT_SYMBOL(ib_destroy_cm_id);
+
+/**
+ * __ib_cm_listen - Initiates listening on the specified service ID for
+ * connection and service ID resolution requests.
+ * @cm_id: Connection identifier associated with the listen request.
+ * @service_id: Service identifier matched against incoming connection
+ * and service ID resolution requests. The service ID should be specified
+ * network-byte order. If set to IB_CM_ASSIGN_SERVICE_ID, the CM will
+ * assign a service ID to the caller.
+ * @service_mask: Mask applied to service ID used to listen across a
+ * range of service IDs. If set to 0, the service ID is matched
+ * exactly. This parameter is ignored if %service_id is set to
+ * IB_CM_ASSIGN_SERVICE_ID.
+ */
+static int __ib_cm_listen(struct ib_cm_id *cm_id, __be64 service_id,
+ __be64 service_mask)
+{
+ struct cm_id_private *cm_id_priv, *cur_cm_id_priv;
+ int ret = 0;
+
+ service_mask = service_mask ? service_mask : ~cpu_to_be64(0);
+ service_id &= service_mask;
+ if ((service_id & IB_SERVICE_ID_AGN_MASK) == IB_CM_ASSIGN_SERVICE_ID &&
+ (service_id != IB_CM_ASSIGN_SERVICE_ID))
+ return -EINVAL;
+
+ cm_id_priv = container_of(cm_id, struct cm_id_private, id);
+ if (cm_id->state != IB_CM_IDLE)
+ return -EINVAL;
+
+ cm_id->state = IB_CM_LISTEN;
+ ++cm_id_priv->listen_sharecount;
+
+ if (service_id == IB_CM_ASSIGN_SERVICE_ID) {
+ cm_id->service_id = cpu_to_be64(cm.listen_service_id++);
+ cm_id->service_mask = ~cpu_to_be64(0);
+ } else {
+ cm_id->service_id = service_id;
+ cm_id->service_mask = service_mask;
+ }
+ cur_cm_id_priv = cm_insert_listen(cm_id_priv);
+
+ if (cur_cm_id_priv) {
+ cm_id->state = IB_CM_IDLE;
+ --cm_id_priv->listen_sharecount;
+ ret = -EBUSY;
+ }
+ return ret;
+}
+
+int ib_cm_listen(struct ib_cm_id *cm_id, __be64 service_id, __be64 service_mask)
+{
+ unsigned long flags;
+ int ret;
+
+ spin_lock_irqsave(&cm.lock, flags);
+ ret = __ib_cm_listen(cm_id, service_id, service_mask);
+ spin_unlock_irqrestore(&cm.lock, flags);
+
+ return ret;
+}
+EXPORT_SYMBOL(ib_cm_listen);
+
+/**
+ * Create a new listening ib_cm_id and listen on the given service ID.
+ *
+ * If there's an existing ID listening on that same device and service ID,
+ * return it.
+ *
+ * @device: Device associated with the cm_id. All related communication will
+ * be associated with the specified device.
+ * @cm_handler: Callback invoked to notify the user of CM events.
+ * @service_id: Service identifier matched against incoming connection
+ * and service ID resolution requests. The service ID should be specified
+ * network-byte order. If set to IB_CM_ASSIGN_SERVICE_ID, the CM will
+ * assign a service ID to the caller.
+ *
+ * Callers should call ib_destroy_cm_id when done with the listener ID.
+ */
+struct ib_cm_id *ib_cm_insert_listen(struct ib_device *device,
+ ib_cm_handler cm_handler,
+ __be64 service_id)
+{
+ struct cm_id_private *cm_id_priv;
+ struct ib_cm_id *cm_id;
+ unsigned long flags;
+ int err = 0;
+
+ /* Create an ID in advance, since the creation may sleep */
+ cm_id = ib_create_cm_id(device, cm_handler, NULL);
+ if (IS_ERR(cm_id))
+ return cm_id;
+
+ spin_lock_irqsave(&cm.lock, flags);
+
+ if (service_id == IB_CM_ASSIGN_SERVICE_ID)
+ goto new_id;
+
+ /* Find an existing ID */
+ cm_id_priv = cm_find_listen(device, service_id);
+ if (cm_id_priv) {
+ if (cm_id->cm_handler != cm_handler || cm_id->context) {
+ /* Sharing an ib_cm_id with different handlers is not
+ * supported */
+ spin_unlock_irqrestore(&cm.lock, flags);
+ return ERR_PTR(-EINVAL);
+ }
+ atomic_inc(&cm_id_priv->refcount);
+ ++cm_id_priv->listen_sharecount;
+ spin_unlock_irqrestore(&cm.lock, flags);
+
+ ib_destroy_cm_id(cm_id);
+ cm_id = &cm_id_priv->id;
+ return cm_id;
+ }
+
+new_id:
+ /* Use newly created ID */
+ err = __ib_cm_listen(cm_id, service_id, 0);
+
+ spin_unlock_irqrestore(&cm.lock, flags);
+
+ if (err) {
+ ib_destroy_cm_id(cm_id);
+ return ERR_PTR(err);
+ }
+ return cm_id;
+}
+EXPORT_SYMBOL(ib_cm_insert_listen);
+
+static __be64 cm_form_tid(struct cm_id_private *cm_id_priv,
+ enum cm_msg_sequence msg_seq)
+{
+ u64 hi_tid, low_tid;
+
+ hi_tid = ((u64) cm_id_priv->av.port->mad_agent->hi_tid) << 32;
+ low_tid = (u64) ((__force u32)cm_id_priv->id.local_id |
+ (msg_seq << 30));
+ return cpu_to_be64(hi_tid | low_tid);
+}
+
+static void cm_format_mad_hdr(struct ib_mad_hdr *hdr,
+ __be16 attr_id, __be64 tid)
+{
+ hdr->base_version = IB_MGMT_BASE_VERSION;
+ hdr->mgmt_class = IB_MGMT_CLASS_CM;
+ hdr->class_version = IB_CM_CLASS_VERSION;
+ hdr->method = IB_MGMT_METHOD_SEND;
+ hdr->attr_id = attr_id;
+ hdr->tid = tid;
+}
+
+static void cm_format_req(struct cm_req_msg *req_msg,
+ struct cm_id_private *cm_id_priv,
+ struct ib_cm_req_param *param)
+{
+ struct ib_sa_path_rec *pri_path = param->primary_path;
+ struct ib_sa_path_rec *alt_path = param->alternate_path;
+
+ cm_format_mad_hdr(&req_msg->hdr, CM_REQ_ATTR_ID,
+ cm_form_tid(cm_id_priv, CM_MSG_SEQUENCE_REQ));
+
+ req_msg->local_comm_id = cm_id_priv->id.local_id;
+ req_msg->service_id = param->service_id;
+ req_msg->local_ca_guid = cm_id_priv->id.device->node_guid;
+ cm_req_set_local_qpn(req_msg, cpu_to_be32(param->qp_num));
+ cm_req_set_init_depth(req_msg, param->initiator_depth);
+ cm_req_set_remote_resp_timeout(req_msg,
+ param->remote_cm_response_timeout);
+ cm_req_set_qp_type(req_msg, param->qp_type);
+ cm_req_set_flow_ctrl(req_msg, param->flow_control);
+ cm_req_set_starting_psn(req_msg, cpu_to_be32(param->starting_psn));
+ cm_req_set_local_resp_timeout(req_msg,
+ param->local_cm_response_timeout);
+ req_msg->pkey = param->primary_path->pkey;
+ cm_req_set_path_mtu(req_msg, param->primary_path->mtu);
+ cm_req_set_max_cm_retries(req_msg, param->max_cm_retries);
+
+ if (param->qp_type != IB_QPT_XRC_INI) {
+ cm_req_set_resp_res(req_msg, param->responder_resources);
+ cm_req_set_retry_count(req_msg, param->retry_count);
+ cm_req_set_rnr_retry_count(req_msg, param->rnr_retry_count);
+ cm_req_set_srq(req_msg, param->srq);
+ }
+
+ if (pri_path->hop_limit <= 1) {
+ req_msg->primary_local_lid = pri_path->slid;
+ req_msg->primary_remote_lid = pri_path->dlid;
+ } else {
+ /* Work-around until there's a way to obtain remote LID info */
+ req_msg->primary_local_lid = IB_LID_PERMISSIVE;
+ req_msg->primary_remote_lid = IB_LID_PERMISSIVE;
+ }
+ req_msg->primary_local_gid = pri_path->sgid;
+ req_msg->primary_remote_gid = pri_path->dgid;
+ cm_req_set_primary_flow_label(req_msg, pri_path->flow_label);
+ cm_req_set_primary_packet_rate(req_msg, pri_path->rate);
+ req_msg->primary_traffic_class = pri_path->traffic_class;
+ req_msg->primary_hop_limit = pri_path->hop_limit;
+ cm_req_set_primary_sl(req_msg, pri_path->sl);
+ cm_req_set_primary_subnet_local(req_msg, (pri_path->hop_limit <= 1));
+ cm_req_set_primary_local_ack_timeout(req_msg,
+ cm_ack_timeout(cm_id_priv->av.port->cm_dev->ack_delay,
+ pri_path->packet_life_time));
+
+ if (alt_path) {
+ if (alt_path->hop_limit <= 1) {
+ req_msg->alt_local_lid = alt_path->slid;
+ req_msg->alt_remote_lid = alt_path->dlid;
+ } else {
+ req_msg->alt_local_lid = IB_LID_PERMISSIVE;
+ req_msg->alt_remote_lid = IB_LID_PERMISSIVE;
+ }
+ req_msg->alt_local_gid = alt_path->sgid;
+ req_msg->alt_remote_gid = alt_path->dgid;
+ cm_req_set_alt_flow_label(req_msg,
+ alt_path->flow_label);
+ cm_req_set_alt_packet_rate(req_msg, alt_path->rate);
+ req_msg->alt_traffic_class = alt_path->traffic_class;
+ req_msg->alt_hop_limit = alt_path->hop_limit;
+ cm_req_set_alt_sl(req_msg, alt_path->sl);
+ cm_req_set_alt_subnet_local(req_msg, (alt_path->hop_limit <= 1));
+ cm_req_set_alt_local_ack_timeout(req_msg,
+ cm_ack_timeout(cm_id_priv->av.port->cm_dev->ack_delay,
+ alt_path->packet_life_time));
+ }
+
+ if (param->private_data && param->private_data_len)
+ memcpy(req_msg->private_data, param->private_data,
+ param->private_data_len);
+}
+
+static int cm_validate_req_param(struct ib_cm_req_param *param)
+{
+ /* peer-to-peer not supported */
+ if (param->peer_to_peer)
+ return -EINVAL;
+
+ if (!param->primary_path)
+ return -EINVAL;
+
+ if (param->qp_type != IB_QPT_RC && param->qp_type != IB_QPT_UC &&
+ param->qp_type != IB_QPT_XRC_INI)
+ return -EINVAL;
+
+ if (param->private_data &&
+ param->private_data_len > IB_CM_REQ_PRIVATE_DATA_SIZE)
+ return -EINVAL;
+
+ if (param->alternate_path &&
+ (param->alternate_path->pkey != param->primary_path->pkey ||
+ param->alternate_path->mtu != param->primary_path->mtu))
+ return -EINVAL;
+
+ return 0;
+}
+
+int ib_send_cm_req(struct ib_cm_id *cm_id,
+ struct ib_cm_req_param *param)
+{
+ struct cm_id_private *cm_id_priv;
+ struct cm_req_msg *req_msg;
+ unsigned long flags;
+ int ret;
+
+ ret = cm_validate_req_param(param);
+ if (ret)
+ return ret;
+
+ /* Verify that we're not in timewait. */
+ cm_id_priv = container_of(cm_id, struct cm_id_private, id);
+ spin_lock_irqsave(&cm_id_priv->lock, flags);
+ if (cm_id->state != IB_CM_IDLE) {
+ spin_unlock_irqrestore(&cm_id_priv->lock, flags);
+ ret = -EINVAL;
+ goto out;
+ }
+ spin_unlock_irqrestore(&cm_id_priv->lock, flags);
+
+ cm_id_priv->timewait_info = cm_create_timewait_info(cm_id_priv->
+ id.local_id);
+ if (IS_ERR(cm_id_priv->timewait_info)) {
+ ret = PTR_ERR(cm_id_priv->timewait_info);
+ goto out;
+ }
+
+ ret = cm_init_av_by_path(param->primary_path, &cm_id_priv->av,
+ cm_id_priv);
+ if (ret)
+ goto error1;
+ if (param->alternate_path) {
+ ret = cm_init_av_by_path(param->alternate_path,
+ &cm_id_priv->alt_av, cm_id_priv);
+ if (ret)
+ goto error1;
+ }
+ cm_id->service_id = param->service_id;
+ cm_id->service_mask = ~cpu_to_be64(0);
+ cm_id_priv->timeout_ms = cm_convert_to_ms(
+ param->primary_path->packet_life_time) * 2 +
+ cm_convert_to_ms(
+ param->remote_cm_response_timeout);
+ cm_id_priv->max_cm_retries = param->max_cm_retries;
+ cm_id_priv->initiator_depth = param->initiator_depth;
+ cm_id_priv->responder_resources = param->responder_resources;
+ cm_id_priv->retry_count = param->retry_count;
+ cm_id_priv->path_mtu = param->primary_path->mtu;
+ cm_id_priv->pkey = param->primary_path->pkey;
+ cm_id_priv->qp_type = param->qp_type;
+
+ ret = cm_alloc_msg(cm_id_priv, &cm_id_priv->msg);
+ if (ret)
+ goto error1;
+
+ req_msg = (struct cm_req_msg *) cm_id_priv->msg->mad;
+ cm_format_req(req_msg, cm_id_priv, param);
+ cm_id_priv->tid = req_msg->hdr.tid;
+ cm_id_priv->msg->timeout_ms = cm_id_priv->timeout_ms;
+ cm_id_priv->msg->context[1] = (void *) (unsigned long) IB_CM_REQ_SENT;
+
+ cm_id_priv->local_qpn = cm_req_get_local_qpn(req_msg);
+ cm_id_priv->rq_psn = cm_req_get_starting_psn(req_msg);
+
+ spin_lock_irqsave(&cm_id_priv->lock, flags);
+ ret = ib_post_send_mad(cm_id_priv->msg, NULL);
+ if (ret) {
+ spin_unlock_irqrestore(&cm_id_priv->lock, flags);
+ goto error2;
+ }
+ BUG_ON(cm_id->state != IB_CM_IDLE);
+ cm_id->state = IB_CM_REQ_SENT;
+ spin_unlock_irqrestore(&cm_id_priv->lock, flags);
+ return 0;
+
+error2: cm_free_msg(cm_id_priv->msg);
+error1: kfree(cm_id_priv->timewait_info);
+out: return ret;
+}
+EXPORT_SYMBOL(ib_send_cm_req);
+
+static int cm_issue_rej(struct cm_port *port,
+ struct ib_mad_recv_wc *mad_recv_wc,
+ enum ib_cm_rej_reason reason,
+ enum cm_msg_response msg_rejected,
+ void *ari, u8 ari_length)
+{
+ struct ib_mad_send_buf *msg = NULL;
+ struct cm_rej_msg *rej_msg, *rcv_msg;
+ int ret;
+
+ ret = cm_alloc_response_msg(port, mad_recv_wc, &msg);
+ if (ret)
+ return ret;
+
+ /* We just need common CM header information. Cast to any message. */
+ rcv_msg = (struct cm_rej_msg *) mad_recv_wc->recv_buf.mad;
+ rej_msg = (struct cm_rej_msg *) msg->mad;
+
+ cm_format_mad_hdr(&rej_msg->hdr, CM_REJ_ATTR_ID, rcv_msg->hdr.tid);
+ rej_msg->remote_comm_id = rcv_msg->local_comm_id;
+ rej_msg->local_comm_id = rcv_msg->remote_comm_id;
+ cm_rej_set_msg_rejected(rej_msg, msg_rejected);
+ rej_msg->reason = cpu_to_be16(reason);
+
+ if (ari && ari_length) {
+ cm_rej_set_reject_info_len(rej_msg, ari_length);
+ memcpy(rej_msg->ari, ari, ari_length);
+ }
+
+ ret = ib_post_send_mad(msg, NULL);
+ if (ret)
+ cm_free_msg(msg);
+
+ return ret;
+}
+
+static void cm_format_paths_from_req(struct cm_req_msg *req_msg,
+ struct ib_sa_path_rec *primary_path,
+ struct ib_sa_path_rec *alt_path)
+{
+ memset(primary_path, 0, sizeof *primary_path);
+ primary_path->dgid = req_msg->primary_local_gid;
+ primary_path->sgid = req_msg->primary_remote_gid;
+ primary_path->dlid = req_msg->primary_local_lid;
+ primary_path->slid = req_msg->primary_remote_lid;
+ primary_path->flow_label = cm_req_get_primary_flow_label(req_msg);
+ primary_path->hop_limit = req_msg->primary_hop_limit;
+ primary_path->traffic_class = req_msg->primary_traffic_class;
+ primary_path->reversible = 1;
+ primary_path->pkey = req_msg->pkey;
+ primary_path->sl = cm_req_get_primary_sl(req_msg);
+ primary_path->mtu_selector = IB_SA_EQ;
+ primary_path->mtu = cm_req_get_path_mtu(req_msg);
+ primary_path->rate_selector = IB_SA_EQ;
+ primary_path->rate = cm_req_get_primary_packet_rate(req_msg);
+ primary_path->packet_life_time_selector = IB_SA_EQ;
+ primary_path->packet_life_time =
+ cm_req_get_primary_local_ack_timeout(req_msg);
+ primary_path->packet_life_time -= (primary_path->packet_life_time > 0);
+ primary_path->service_id = req_msg->service_id;
+
+ if (req_msg->alt_local_lid) {
+ memset(alt_path, 0, sizeof *alt_path);
+ alt_path->dgid = req_msg->alt_local_gid;
+ alt_path->sgid = req_msg->alt_remote_gid;
+ alt_path->dlid = req_msg->alt_local_lid;
+ alt_path->slid = req_msg->alt_remote_lid;
+ alt_path->flow_label = cm_req_get_alt_flow_label(req_msg);
+ alt_path->hop_limit = req_msg->alt_hop_limit;
+ alt_path->traffic_class = req_msg->alt_traffic_class;
+ alt_path->reversible = 1;
+ alt_path->pkey = req_msg->pkey;
+ alt_path->sl = cm_req_get_alt_sl(req_msg);
+ alt_path->mtu_selector = IB_SA_EQ;
+ alt_path->mtu = cm_req_get_path_mtu(req_msg);
+ alt_path->rate_selector = IB_SA_EQ;
+ alt_path->rate = cm_req_get_alt_packet_rate(req_msg);
+ alt_path->packet_life_time_selector = IB_SA_EQ;
+ alt_path->packet_life_time =
+ cm_req_get_alt_local_ack_timeout(req_msg);
+ alt_path->packet_life_time -= (alt_path->packet_life_time > 0);
+ alt_path->service_id = req_msg->service_id;
+ }
+}
+
+static u16 cm_get_bth_pkey(struct cm_work *work)
+{
+ struct ib_device *ib_dev = work->port->cm_dev->ib_device;
+ u8 port_num = work->port->port_num;
+ u16 pkey_index = work->mad_recv_wc->wc->pkey_index;
+ u16 pkey;
+ int ret;
+
+ ret = ib_get_cached_pkey(ib_dev, port_num, pkey_index, &pkey);
+ if (ret) {
+ dev_warn_ratelimited(&ib_dev->dev, "ib_cm: Couldn't retrieve pkey for incoming request (port %d, pkey index %d). %d\n",
+ port_num, pkey_index, ret);
+ return 0;
+ }
+
+ return pkey;
+}
+
+static void cm_format_req_event(struct cm_work *work,
+ struct cm_id_private *cm_id_priv,
+ struct ib_cm_id *listen_id)
+{
+ struct cm_req_msg *req_msg;
+ struct ib_cm_req_event_param *param;
+
+ req_msg = (struct cm_req_msg *)work->mad_recv_wc->recv_buf.mad;
+ param = &work->cm_event.param.req_rcvd;
+ param->listen_id = listen_id;
+ param->bth_pkey = cm_get_bth_pkey(work);
+ param->port = cm_id_priv->av.port->port_num;
+ param->primary_path = &work->path[0];
+ if (req_msg->alt_local_lid)
+ param->alternate_path = &work->path[1];
+ else
+ param->alternate_path = NULL;
+ param->remote_ca_guid = req_msg->local_ca_guid;
+ param->remote_qkey = be32_to_cpu(req_msg->local_qkey);
+ param->remote_qpn = be32_to_cpu(cm_req_get_local_qpn(req_msg));
+ param->qp_type = cm_req_get_qp_type(req_msg);
+ param->starting_psn = be32_to_cpu(cm_req_get_starting_psn(req_msg));
+ param->responder_resources = cm_req_get_init_depth(req_msg);
+ param->initiator_depth = cm_req_get_resp_res(req_msg);
+ param->local_cm_response_timeout =
+ cm_req_get_remote_resp_timeout(req_msg);
+ param->flow_control = cm_req_get_flow_ctrl(req_msg);
+ param->remote_cm_response_timeout =
+ cm_req_get_local_resp_timeout(req_msg);
+ param->retry_count = cm_req_get_retry_count(req_msg);
+ param->rnr_retry_count = cm_req_get_rnr_retry_count(req_msg);
+ param->srq = cm_req_get_srq(req_msg);
+ work->cm_event.private_data = &req_msg->private_data;
+}
+
+static void cm_process_work(struct cm_id_private *cm_id_priv,
+ struct cm_work *work)
+{
+ int ret;
+
+ /* We will typically only have the current event to report. */
+ ret = cm_id_priv->id.cm_handler(&cm_id_priv->id, &work->cm_event);
+ cm_free_work(work);
+
+ while (!ret && !atomic_add_negative(-1, &cm_id_priv->work_count)) {
+ spin_lock_irq(&cm_id_priv->lock);
+ work = cm_dequeue_work(cm_id_priv);
+ spin_unlock_irq(&cm_id_priv->lock);
+ BUG_ON(!work);
+ ret = cm_id_priv->id.cm_handler(&cm_id_priv->id,
+ &work->cm_event);
+ cm_free_work(work);
+ }
+ cm_deref_id(cm_id_priv);
+ if (ret)
+ cm_destroy_id(&cm_id_priv->id, ret);
+}
+
+static void cm_format_mra(struct cm_mra_msg *mra_msg,
+ struct cm_id_private *cm_id_priv,
+ enum cm_msg_response msg_mraed, u8 service_timeout,
+ const void *private_data, u8 private_data_len)
+{
+ cm_format_mad_hdr(&mra_msg->hdr, CM_MRA_ATTR_ID, cm_id_priv->tid);
+ cm_mra_set_msg_mraed(mra_msg, msg_mraed);
+ mra_msg->local_comm_id = cm_id_priv->id.local_id;
+ mra_msg->remote_comm_id = cm_id_priv->id.remote_id;
+ cm_mra_set_service_timeout(mra_msg, service_timeout);
+
+ if (private_data && private_data_len)
+ memcpy(mra_msg->private_data, private_data, private_data_len);
+}
+
+static void cm_format_rej(struct cm_rej_msg *rej_msg,
+ struct cm_id_private *cm_id_priv,
+ enum ib_cm_rej_reason reason,
+ void *ari,
+ u8 ari_length,
+ const void *private_data,
+ u8 private_data_len)
+{
+ cm_format_mad_hdr(&rej_msg->hdr, CM_REJ_ATTR_ID, cm_id_priv->tid);
+ rej_msg->remote_comm_id = cm_id_priv->id.remote_id;
+
+ switch(cm_id_priv->id.state) {
+ case IB_CM_REQ_RCVD:
+ rej_msg->local_comm_id = 0;
+ cm_rej_set_msg_rejected(rej_msg, CM_MSG_RESPONSE_REQ);
+ break;
+ case IB_CM_MRA_REQ_SENT:
+ rej_msg->local_comm_id = cm_id_priv->id.local_id;
+ cm_rej_set_msg_rejected(rej_msg, CM_MSG_RESPONSE_REQ);
+ break;
+ case IB_CM_REP_RCVD:
+ case IB_CM_MRA_REP_SENT:
+ rej_msg->local_comm_id = cm_id_priv->id.local_id;
+ cm_rej_set_msg_rejected(rej_msg, CM_MSG_RESPONSE_REP);
+ break;
+ default:
+ rej_msg->local_comm_id = cm_id_priv->id.local_id;
+ cm_rej_set_msg_rejected(rej_msg, CM_MSG_RESPONSE_OTHER);
+ break;
+ }
+
+ rej_msg->reason = cpu_to_be16(reason);
+ if (ari && ari_length) {
+ cm_rej_set_reject_info_len(rej_msg, ari_length);
+ memcpy(rej_msg->ari, ari, ari_length);
+ }
+
+ if (private_data && private_data_len)
+ memcpy(rej_msg->private_data, private_data, private_data_len);
+}
+
+static void cm_dup_req_handler(struct cm_work *work,
+ struct cm_id_private *cm_id_priv)
+{
+ struct ib_mad_send_buf *msg = NULL;
+ int ret;
+
+ atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
+ counter[CM_REQ_COUNTER]);
+
+ /* Quick state check to discard duplicate REQs. */
+ if (cm_id_priv->id.state == IB_CM_REQ_RCVD)
+ return;
+
+ ret = cm_alloc_response_msg(work->port, work->mad_recv_wc, &msg);
+ if (ret)
+ return;
+
+ spin_lock_irq(&cm_id_priv->lock);
+ switch (cm_id_priv->id.state) {
+ case IB_CM_MRA_REQ_SENT:
+ cm_format_mra((struct cm_mra_msg *) msg->mad, cm_id_priv,
+ CM_MSG_RESPONSE_REQ, cm_id_priv->service_timeout,
+ cm_id_priv->private_data,
+ cm_id_priv->private_data_len);
+ break;
+ case IB_CM_TIMEWAIT:
+ cm_format_rej((struct cm_rej_msg *) msg->mad, cm_id_priv,
+ IB_CM_REJ_STALE_CONN, NULL, 0, NULL, 0);
+ break;
+ default:
+ goto unlock;
+ }
+ spin_unlock_irq(&cm_id_priv->lock);
+
+ ret = ib_post_send_mad(msg, NULL);
+ if (ret)
+ goto free;
+ return;
+
+unlock: spin_unlock_irq(&cm_id_priv->lock);
+free: cm_free_msg(msg);
+}
+
+static struct cm_id_private * cm_match_req(struct cm_work *work,
+ struct cm_id_private *cm_id_priv)
+{
+ struct cm_id_private *listen_cm_id_priv, *cur_cm_id_priv;
+ struct cm_timewait_info *timewait_info;
+ struct cm_req_msg *req_msg;
+
+ req_msg = (struct cm_req_msg *)work->mad_recv_wc->recv_buf.mad;
+
+ /* Check for possible duplicate REQ. */
+ spin_lock_irq(&cm.lock);
+ timewait_info = cm_insert_remote_id(cm_id_priv->timewait_info);
+ if (timewait_info) {
+ cur_cm_id_priv = cm_get_id(timewait_info->work.local_id,
+ timewait_info->work.remote_id);
+ spin_unlock_irq(&cm.lock);
+ if (cur_cm_id_priv) {
+ cm_dup_req_handler(work, cur_cm_id_priv);
+ cm_deref_id(cur_cm_id_priv);
+ }
+ return NULL;
+ }
+
+ /* Check for stale connections. */
+ timewait_info = cm_insert_remote_qpn(cm_id_priv->timewait_info);
+ if (timewait_info) {
+ cm_cleanup_timewait(cm_id_priv->timewait_info);
+ spin_unlock_irq(&cm.lock);
+ cm_issue_rej(work->port, work->mad_recv_wc,
+ IB_CM_REJ_STALE_CONN, CM_MSG_RESPONSE_REQ,
+ NULL, 0);
+ return NULL;
+ }
+
+ /* Find matching listen request. */
+ listen_cm_id_priv = cm_find_listen(cm_id_priv->id.device,
+ req_msg->service_id);
+ if (!listen_cm_id_priv) {
+ cm_cleanup_timewait(cm_id_priv->timewait_info);
+ spin_unlock_irq(&cm.lock);
+ cm_issue_rej(work->port, work->mad_recv_wc,
+ IB_CM_REJ_INVALID_SERVICE_ID, CM_MSG_RESPONSE_REQ,
+ NULL, 0);
+ goto out;
+ }
+ atomic_inc(&listen_cm_id_priv->refcount);
+ atomic_inc(&cm_id_priv->refcount);
+ cm_id_priv->id.state = IB_CM_REQ_RCVD;
+ atomic_inc(&cm_id_priv->work_count);
+ spin_unlock_irq(&cm.lock);
+out:
+ return listen_cm_id_priv;
+}
+
+/*
+ * Work-around for inter-subnet connections. If the LIDs are permissive,
+ * we need to override the LID/SL data in the REQ with the LID information
+ * in the work completion.
+ */
+static void cm_process_routed_req(struct cm_req_msg *req_msg, struct ib_wc *wc)
+{
+ if (!cm_req_get_primary_subnet_local(req_msg)) {
+ if (req_msg->primary_local_lid == IB_LID_PERMISSIVE) {
+ req_msg->primary_local_lid = cpu_to_be16(wc->slid);
+ cm_req_set_primary_sl(req_msg, wc->sl);
+ }
+
+ if (req_msg->primary_remote_lid == IB_LID_PERMISSIVE)
+ req_msg->primary_remote_lid = cpu_to_be16(wc->dlid_path_bits);
+ }
+
+ if (!cm_req_get_alt_subnet_local(req_msg)) {
+ if (req_msg->alt_local_lid == IB_LID_PERMISSIVE) {
+ req_msg->alt_local_lid = cpu_to_be16(wc->slid);
+ cm_req_set_alt_sl(req_msg, wc->sl);
+ }
+
+ if (req_msg->alt_remote_lid == IB_LID_PERMISSIVE)
+ req_msg->alt_remote_lid = cpu_to_be16(wc->dlid_path_bits);
+ }
+}
+
+static int cm_req_handler(struct cm_work *work)
+{
+ struct ib_cm_id *cm_id;
+ struct cm_id_private *cm_id_priv, *listen_cm_id_priv;
+ struct cm_req_msg *req_msg;
+ union ib_gid gid;
+ struct ib_gid_attr gid_attr;
+ int ret;
+
+ req_msg = (struct cm_req_msg *)work->mad_recv_wc->recv_buf.mad;
+
+ cm_id = ib_create_cm_id(work->port->cm_dev->ib_device, NULL, NULL);
+ if (IS_ERR(cm_id))
+ return PTR_ERR(cm_id);
+
+ cm_id_priv = container_of(cm_id, struct cm_id_private, id);
+ cm_id_priv->id.remote_id = req_msg->local_comm_id;
+ cm_init_av_for_response(work->port, work->mad_recv_wc->wc,
+ work->mad_recv_wc->recv_buf.grh,
+ &cm_id_priv->av);
+ cm_id_priv->timewait_info = cm_create_timewait_info(cm_id_priv->
+ id.local_id);
+ if (IS_ERR(cm_id_priv->timewait_info)) {
+ ret = PTR_ERR(cm_id_priv->timewait_info);
+ goto destroy;
+ }
+ cm_id_priv->timewait_info->work.remote_id = req_msg->local_comm_id;
+ cm_id_priv->timewait_info->remote_ca_guid = req_msg->local_ca_guid;
+ cm_id_priv->timewait_info->remote_qpn = cm_req_get_local_qpn(req_msg);
+
+ listen_cm_id_priv = cm_match_req(work, cm_id_priv);
+ if (!listen_cm_id_priv) {
+ ret = -EINVAL;
+ kfree(cm_id_priv->timewait_info);
+ goto destroy;
+ }
+
+ cm_id_priv->id.cm_handler = listen_cm_id_priv->id.cm_handler;
+ cm_id_priv->id.context = listen_cm_id_priv->id.context;
+ cm_id_priv->id.service_id = req_msg->service_id;
+ cm_id_priv->id.service_mask = ~cpu_to_be64(0);
+
+ cm_process_routed_req(req_msg, work->mad_recv_wc->wc);
+ cm_format_paths_from_req(req_msg, &work->path[0], &work->path[1]);
+
+ memcpy(work->path[0].dmac, cm_id_priv->av.ah_attr.dmac, ETH_ALEN);
+ work->path[0].hop_limit = cm_id_priv->av.ah_attr.grh.hop_limit;
+ ret = ib_get_cached_gid(work->port->cm_dev->ib_device,
+ work->port->port_num,
+ cm_id_priv->av.ah_attr.grh.sgid_index,
+ &gid, &gid_attr);
+ if (!ret) {
+ if (gid_attr.ndev) {
+ work->path[0].ifindex = gid_attr.ndev->if_index;
+ work->path[0].net = dev_net(gid_attr.ndev);
+ dev_put(gid_attr.ndev);
+ }
+ work->path[0].gid_type = gid_attr.gid_type;
+ ret = cm_init_av_by_path(&work->path[0], &cm_id_priv->av,
+ cm_id_priv);
+ }
+ if (ret) {
+ int err = ib_get_cached_gid(work->port->cm_dev->ib_device,
+ work->port->port_num, 0,
+ &work->path[0].sgid,
+ &gid_attr);
+ if (!err && gid_attr.ndev) {
+ work->path[0].ifindex = gid_attr.ndev->if_index;
+ work->path[0].net = dev_net(gid_attr.ndev);
+ dev_put(gid_attr.ndev);
+ }
+ work->path[0].gid_type = gid_attr.gid_type;
+ ib_send_cm_rej(cm_id, IB_CM_REJ_INVALID_GID,
+ &work->path[0].sgid, sizeof work->path[0].sgid,
+ NULL, 0);
+ goto rejected;
+ }
+ if (req_msg->alt_local_lid) {
+ ret = cm_init_av_by_path(&work->path[1], &cm_id_priv->alt_av,
+ cm_id_priv);
+ if (ret) {
+ ib_send_cm_rej(cm_id, IB_CM_REJ_INVALID_ALT_GID,
+ &work->path[0].sgid,
+ sizeof work->path[0].sgid, NULL, 0);
+ goto rejected;
+ }
+ }
+ cm_id_priv->tid = req_msg->hdr.tid;
+ cm_id_priv->timeout_ms = cm_convert_to_ms(
+ cm_req_get_local_resp_timeout(req_msg));
+ cm_id_priv->max_cm_retries = cm_req_get_max_cm_retries(req_msg);
+ cm_id_priv->remote_qpn = cm_req_get_local_qpn(req_msg);
+ cm_id_priv->initiator_depth = cm_req_get_resp_res(req_msg);
+ cm_id_priv->responder_resources = cm_req_get_init_depth(req_msg);
+ cm_id_priv->path_mtu = cm_req_get_path_mtu(req_msg);
+ cm_id_priv->pkey = req_msg->pkey;
+ cm_id_priv->sq_psn = cm_req_get_starting_psn(req_msg);
+ cm_id_priv->retry_count = cm_req_get_retry_count(req_msg);
+ cm_id_priv->rnr_retry_count = cm_req_get_rnr_retry_count(req_msg);
+ cm_id_priv->qp_type = cm_req_get_qp_type(req_msg);
+
+ cm_format_req_event(work, cm_id_priv, &listen_cm_id_priv->id);
+ cm_process_work(cm_id_priv, work);
+ cm_deref_id(listen_cm_id_priv);
+ return 0;
+
+rejected:
+ atomic_dec(&cm_id_priv->refcount);
+ cm_deref_id(listen_cm_id_priv);
+destroy:
+ ib_destroy_cm_id(cm_id);
+ return ret;
+}
+
+static void cm_format_rep(struct cm_rep_msg *rep_msg,
+ struct cm_id_private *cm_id_priv,
+ struct ib_cm_rep_param *param)
+{
+ cm_format_mad_hdr(&rep_msg->hdr, CM_REP_ATTR_ID, cm_id_priv->tid);
+ rep_msg->local_comm_id = cm_id_priv->id.local_id;
+ rep_msg->remote_comm_id = cm_id_priv->id.remote_id;
+ cm_rep_set_starting_psn(rep_msg, cpu_to_be32(param->starting_psn));
+ rep_msg->resp_resources = param->responder_resources;
+ cm_rep_set_target_ack_delay(rep_msg,
+ cm_id_priv->av.port->cm_dev->ack_delay);
+ cm_rep_set_failover(rep_msg, param->failover_accepted);
+ cm_rep_set_rnr_retry_count(rep_msg, param->rnr_retry_count);
+ rep_msg->local_ca_guid = cm_id_priv->id.device->node_guid;
+
+ if (cm_id_priv->qp_type != IB_QPT_XRC_TGT) {
+ rep_msg->initiator_depth = param->initiator_depth;
+ cm_rep_set_flow_ctrl(rep_msg, param->flow_control);
+ cm_rep_set_srq(rep_msg, param->srq);
+ cm_rep_set_local_qpn(rep_msg, cpu_to_be32(param->qp_num));
+ } else {
+ cm_rep_set_srq(rep_msg, 1);
+ cm_rep_set_local_eecn(rep_msg, cpu_to_be32(param->qp_num));
+ }
+
+ if (param->private_data && param->private_data_len)
+ memcpy(rep_msg->private_data, param->private_data,
+ param->private_data_len);
+}
+
+int ib_send_cm_rep(struct ib_cm_id *cm_id,
+ struct ib_cm_rep_param *param)
+{
+ struct cm_id_private *cm_id_priv;
+ struct ib_mad_send_buf *msg;
+ struct cm_rep_msg *rep_msg;
+ unsigned long flags;
+ int ret;
+
+ if (param->private_data &&
+ param->private_data_len > IB_CM_REP_PRIVATE_DATA_SIZE)
+ return -EINVAL;
+
+ cm_id_priv = container_of(cm_id, struct cm_id_private, id);
+ spin_lock_irqsave(&cm_id_priv->lock, flags);
+ if (cm_id->state != IB_CM_REQ_RCVD &&
+ cm_id->state != IB_CM_MRA_REQ_SENT) {
+ ret = -EINVAL;
+ goto out;
+ }
+
+ ret = cm_alloc_msg(cm_id_priv, &msg);
+ if (ret)
+ goto out;
+
+ rep_msg = (struct cm_rep_msg *) msg->mad;
+ cm_format_rep(rep_msg, cm_id_priv, param);
+ msg->timeout_ms = cm_id_priv->timeout_ms;
+ msg->context[1] = (void *) (unsigned long) IB_CM_REP_SENT;
+
+ ret = ib_post_send_mad(msg, NULL);
+ if (ret) {
+ spin_unlock_irqrestore(&cm_id_priv->lock, flags);
+ cm_free_msg(msg);
+ return ret;
+ }
+
+ cm_id->state = IB_CM_REP_SENT;
+ cm_id_priv->msg = msg;
+ cm_id_priv->initiator_depth = param->initiator_depth;
+ cm_id_priv->responder_resources = param->responder_resources;
+ cm_id_priv->rq_psn = cm_rep_get_starting_psn(rep_msg);
+ cm_id_priv->local_qpn = cpu_to_be32(param->qp_num & 0xFFFFFF);
+
+out: spin_unlock_irqrestore(&cm_id_priv->lock, flags);
+ return ret;
+}
+EXPORT_SYMBOL(ib_send_cm_rep);
+
+static void cm_format_rtu(struct cm_rtu_msg *rtu_msg,
+ struct cm_id_private *cm_id_priv,
+ const void *private_data,
+ u8 private_data_len)
+{
+ cm_format_mad_hdr(&rtu_msg->hdr, CM_RTU_ATTR_ID, cm_id_priv->tid);
+ rtu_msg->local_comm_id = cm_id_priv->id.local_id;
+ rtu_msg->remote_comm_id = cm_id_priv->id.remote_id;
+
+ if (private_data && private_data_len)
+ memcpy(rtu_msg->private_data, private_data, private_data_len);
+}
+
+int ib_send_cm_rtu(struct ib_cm_id *cm_id,
+ const void *private_data,
+ u8 private_data_len)
+{
+ struct cm_id_private *cm_id_priv;
+ struct ib_mad_send_buf *msg;
+ unsigned long flags;
+ void *data;
+ int ret;
+
+ if (private_data && private_data_len > IB_CM_RTU_PRIVATE_DATA_SIZE)
+ return -EINVAL;
+
+ data = cm_copy_private_data(private_data, private_data_len);
+ if (IS_ERR(data))
+ return PTR_ERR(data);
+
+ cm_id_priv = container_of(cm_id, struct cm_id_private, id);
+ spin_lock_irqsave(&cm_id_priv->lock, flags);
+ if (cm_id->state != IB_CM_REP_RCVD &&
+ cm_id->state != IB_CM_MRA_REP_SENT) {
+ ret = -EINVAL;
+ goto error;
+ }
+
+ ret = cm_alloc_msg(cm_id_priv, &msg);
+ if (ret)
+ goto error;
+
+ cm_format_rtu((struct cm_rtu_msg *) msg->mad, cm_id_priv,
+ private_data, private_data_len);
+
+ ret = ib_post_send_mad(msg, NULL);
+ if (ret) {
+ spin_unlock_irqrestore(&cm_id_priv->lock, flags);
+ cm_free_msg(msg);
+ kfree(data);
+ return ret;
+ }
+
+ cm_id->state = IB_CM_ESTABLISHED;
+ cm_set_private_data(cm_id_priv, data, private_data_len);
+ spin_unlock_irqrestore(&cm_id_priv->lock, flags);
+ return 0;
+
+error: spin_unlock_irqrestore(&cm_id_priv->lock, flags);
+ kfree(data);
+ return ret;
+}
+EXPORT_SYMBOL(ib_send_cm_rtu);
+
+static void cm_format_rep_event(struct cm_work *work, enum ib_qp_type qp_type)
+{
+ struct cm_rep_msg *rep_msg;
+ struct ib_cm_rep_event_param *param;
+
+ rep_msg = (struct cm_rep_msg *)work->mad_recv_wc->recv_buf.mad;
+ param = &work->cm_event.param.rep_rcvd;
+ param->remote_ca_guid = rep_msg->local_ca_guid;
+ param->remote_qkey = be32_to_cpu(rep_msg->local_qkey);
+ param->remote_qpn = be32_to_cpu(cm_rep_get_qpn(rep_msg, qp_type));
+ param->starting_psn = be32_to_cpu(cm_rep_get_starting_psn(rep_msg));
+ param->responder_resources = rep_msg->initiator_depth;
+ param->initiator_depth = rep_msg->resp_resources;
+ param->target_ack_delay = cm_rep_get_target_ack_delay(rep_msg);
+ param->failover_accepted = cm_rep_get_failover(rep_msg);
+ param->flow_control = cm_rep_get_flow_ctrl(rep_msg);
+ param->rnr_retry_count = cm_rep_get_rnr_retry_count(rep_msg);
+ param->srq = cm_rep_get_srq(rep_msg);
+ work->cm_event.private_data = &rep_msg->private_data;
+}
+
+static void cm_dup_rep_handler(struct cm_work *work)
+{
+ struct cm_id_private *cm_id_priv;
+ struct cm_rep_msg *rep_msg;
+ struct ib_mad_send_buf *msg = NULL;
+ int ret;
+
+ rep_msg = (struct cm_rep_msg *) work->mad_recv_wc->recv_buf.mad;
+ cm_id_priv = cm_acquire_id(rep_msg->remote_comm_id,
+ rep_msg->local_comm_id);
+ if (!cm_id_priv)
+ return;
+
+ atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
+ counter[CM_REP_COUNTER]);
+ ret = cm_alloc_response_msg(work->port, work->mad_recv_wc, &msg);
+ if (ret)
+ goto deref;
+
+ spin_lock_irq(&cm_id_priv->lock);
+ if (cm_id_priv->id.state == IB_CM_ESTABLISHED)
+ cm_format_rtu((struct cm_rtu_msg *) msg->mad, cm_id_priv,
+ cm_id_priv->private_data,
+ cm_id_priv->private_data_len);
+ else if (cm_id_priv->id.state == IB_CM_MRA_REP_SENT)
+ cm_format_mra((struct cm_mra_msg *) msg->mad, cm_id_priv,
+ CM_MSG_RESPONSE_REP, cm_id_priv->service_timeout,
+ cm_id_priv->private_data,
+ cm_id_priv->private_data_len);
+ else
+ goto unlock;
+ spin_unlock_irq(&cm_id_priv->lock);
+
+ ret = ib_post_send_mad(msg, NULL);
+ if (ret)
+ goto free;
+ goto deref;
+
+unlock: spin_unlock_irq(&cm_id_priv->lock);
+free: cm_free_msg(msg);
+deref: cm_deref_id(cm_id_priv);
+}
+
+static int cm_rep_handler(struct cm_work *work)
+{
+ struct cm_id_private *cm_id_priv;
+ struct cm_rep_msg *rep_msg;
+ int ret;
+
+ rep_msg = (struct cm_rep_msg *)work->mad_recv_wc->recv_buf.mad;
+ cm_id_priv = cm_acquire_id(rep_msg->remote_comm_id, 0);
+ if (!cm_id_priv) {
+ cm_dup_rep_handler(work);
+ return -EINVAL;
+ }
+
+ cm_format_rep_event(work, cm_id_priv->qp_type);
+
+ spin_lock_irq(&cm_id_priv->lock);
+ switch (cm_id_priv->id.state) {
+ case IB_CM_REQ_SENT:
+ case IB_CM_MRA_REQ_RCVD:
+ break;
+ default:
+ spin_unlock_irq(&cm_id_priv->lock);
+ ret = -EINVAL;
+ goto error;
+ }
+
+ cm_id_priv->timewait_info->work.remote_id = rep_msg->local_comm_id;
+ cm_id_priv->timewait_info->remote_ca_guid = rep_msg->local_ca_guid;
+ cm_id_priv->timewait_info->remote_qpn = cm_rep_get_qpn(rep_msg, cm_id_priv->qp_type);
+
+ spin_lock(&cm.lock);
+ /* Check for duplicate REP. */
+ if (cm_insert_remote_id(cm_id_priv->timewait_info)) {
+ spin_unlock(&cm.lock);
+ spin_unlock_irq(&cm_id_priv->lock);
+ ret = -EINVAL;
+ goto error;
+ }
+ /* Check for a stale connection. */
+ if (cm_insert_remote_qpn(cm_id_priv->timewait_info)) {
+ rb_erase(&cm_id_priv->timewait_info->remote_id_node,
+ &cm.remote_id_table);
+ cm_id_priv->timewait_info->inserted_remote_id = 0;
+ spin_unlock(&cm.lock);
+ spin_unlock_irq(&cm_id_priv->lock);
+ cm_issue_rej(work->port, work->mad_recv_wc,
+ IB_CM_REJ_STALE_CONN, CM_MSG_RESPONSE_REP,
+ NULL, 0);
+ ret = -EINVAL;
+ goto error;
+ }
+ spin_unlock(&cm.lock);
+
+ cm_id_priv->id.state = IB_CM_REP_RCVD;
+ cm_id_priv->id.remote_id = rep_msg->local_comm_id;
+ cm_id_priv->remote_qpn = cm_rep_get_qpn(rep_msg, cm_id_priv->qp_type);
+ cm_id_priv->initiator_depth = rep_msg->resp_resources;
+ cm_id_priv->responder_resources = rep_msg->initiator_depth;
+ cm_id_priv->sq_psn = cm_rep_get_starting_psn(rep_msg);
+ cm_id_priv->rnr_retry_count = cm_rep_get_rnr_retry_count(rep_msg);
+ cm_id_priv->target_ack_delay = cm_rep_get_target_ack_delay(rep_msg);
+ cm_id_priv->av.timeout =
+ cm_ack_timeout(cm_id_priv->target_ack_delay,
+ cm_id_priv->av.timeout - 1);
+ cm_id_priv->alt_av.timeout =
+ cm_ack_timeout(cm_id_priv->target_ack_delay,
+ cm_id_priv->alt_av.timeout - 1);
+
+ /* todo: handle peer_to_peer */
+
+ ib_cancel_mad(cm_id_priv->av.port->mad_agent, cm_id_priv->msg);
+ ret = atomic_inc_and_test(&cm_id_priv->work_count);
+ if (!ret)
+ list_add_tail(&work->list, &cm_id_priv->work_list);
+ spin_unlock_irq(&cm_id_priv->lock);
+
+ if (ret)
+ cm_process_work(cm_id_priv, work);
+ else
+ cm_deref_id(cm_id_priv);
+ return 0;
+
+error:
+ cm_deref_id(cm_id_priv);
+ return ret;
+}
+
+static int cm_establish_handler(struct cm_work *work)
+{
+ struct cm_id_private *cm_id_priv;
+ int ret;
+
+ /* See comment in cm_establish about lookup. */
+ cm_id_priv = cm_acquire_id(work->local_id, work->remote_id);
+ if (!cm_id_priv)
+ return -EINVAL;
+
+ spin_lock_irq(&cm_id_priv->lock);
+ if (cm_id_priv->id.state != IB_CM_ESTABLISHED) {
+ spin_unlock_irq(&cm_id_priv->lock);
+ goto out;
+ }
+
+ ib_cancel_mad(cm_id_priv->av.port->mad_agent, cm_id_priv->msg);
+ ret = atomic_inc_and_test(&cm_id_priv->work_count);
+ if (!ret)
+ list_add_tail(&work->list, &cm_id_priv->work_list);
+ spin_unlock_irq(&cm_id_priv->lock);
+
+ if (ret)
+ cm_process_work(cm_id_priv, work);
+ else
+ cm_deref_id(cm_id_priv);
+ return 0;
+out:
+ cm_deref_id(cm_id_priv);
+ return -EINVAL;
+}
+
+static int cm_rtu_handler(struct cm_work *work)
+{
+ struct cm_id_private *cm_id_priv;
+ struct cm_rtu_msg *rtu_msg;
+ int ret;
+
+ rtu_msg = (struct cm_rtu_msg *)work->mad_recv_wc->recv_buf.mad;
+ cm_id_priv = cm_acquire_id(rtu_msg->remote_comm_id,
+ rtu_msg->local_comm_id);
+ if (!cm_id_priv)
+ return -EINVAL;
+
+ work->cm_event.private_data = &rtu_msg->private_data;
+
+ spin_lock_irq(&cm_id_priv->lock);
+ if (cm_id_priv->id.state != IB_CM_REP_SENT &&
+ cm_id_priv->id.state != IB_CM_MRA_REP_RCVD) {
+ spin_unlock_irq(&cm_id_priv->lock);
+ atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
+ counter[CM_RTU_COUNTER]);
+ goto out;
+ }
+ cm_id_priv->id.state = IB_CM_ESTABLISHED;
+
+ ib_cancel_mad(cm_id_priv->av.port->mad_agent, cm_id_priv->msg);
+ ret = atomic_inc_and_test(&cm_id_priv->work_count);
+ if (!ret)
+ list_add_tail(&work->list, &cm_id_priv->work_list);
+ spin_unlock_irq(&cm_id_priv->lock);
+
+ if (ret)
+ cm_process_work(cm_id_priv, work);
+ else
+ cm_deref_id(cm_id_priv);
+ return 0;
+out:
+ cm_deref_id(cm_id_priv);
+ return -EINVAL;
+}
+
+static void cm_format_dreq(struct cm_dreq_msg *dreq_msg,
+ struct cm_id_private *cm_id_priv,
+ const void *private_data,
+ u8 private_data_len)
+{
+ cm_format_mad_hdr(&dreq_msg->hdr, CM_DREQ_ATTR_ID,
+ cm_form_tid(cm_id_priv, CM_MSG_SEQUENCE_DREQ));
+ dreq_msg->local_comm_id = cm_id_priv->id.local_id;
+ dreq_msg->remote_comm_id = cm_id_priv->id.remote_id;
+ cm_dreq_set_remote_qpn(dreq_msg, cm_id_priv->remote_qpn);
+
+ if (private_data && private_data_len)
+ memcpy(dreq_msg->private_data, private_data, private_data_len);
+}
+
+int ib_send_cm_dreq(struct ib_cm_id *cm_id,
+ const void *private_data,
+ u8 private_data_len)
+{
+ struct cm_id_private *cm_id_priv;
+ struct ib_mad_send_buf *msg;
+ unsigned long flags;
+ int ret;
+
+ if (private_data && private_data_len > IB_CM_DREQ_PRIVATE_DATA_SIZE)
+ return -EINVAL;
+
+ cm_id_priv = container_of(cm_id, struct cm_id_private, id);
+ spin_lock_irqsave(&cm_id_priv->lock, flags);
+ if (cm_id->state != IB_CM_ESTABLISHED) {
+ ret = -EINVAL;
+ goto out;
+ }
+
+ if (cm_id->lap_state == IB_CM_LAP_SENT ||
+ cm_id->lap_state == IB_CM_MRA_LAP_RCVD)
+ ib_cancel_mad(cm_id_priv->av.port->mad_agent, cm_id_priv->msg);
+
+ ret = cm_alloc_msg(cm_id_priv, &msg);
+ if (ret) {
+ cm_enter_timewait(cm_id_priv);
+ goto out;
+ }
+
+ cm_format_dreq((struct cm_dreq_msg *) msg->mad, cm_id_priv,
+ private_data, private_data_len);
+ msg->timeout_ms = cm_id_priv->timeout_ms;
+ msg->context[1] = (void *) (unsigned long) IB_CM_DREQ_SENT;
+
+ ret = ib_post_send_mad(msg, NULL);
+ if (ret) {
+ cm_enter_timewait(cm_id_priv);
+ spin_unlock_irqrestore(&cm_id_priv->lock, flags);
+ cm_free_msg(msg);
+ return ret;
+ }
+
+ cm_id->state = IB_CM_DREQ_SENT;
+ cm_id_priv->msg = msg;
+out: spin_unlock_irqrestore(&cm_id_priv->lock, flags);
+ return ret;
+}
+EXPORT_SYMBOL(ib_send_cm_dreq);
+
+static void cm_format_drep(struct cm_drep_msg *drep_msg,
+ struct cm_id_private *cm_id_priv,
+ const void *private_data,
+ u8 private_data_len)
+{
+ cm_format_mad_hdr(&drep_msg->hdr, CM_DREP_ATTR_ID, cm_id_priv->tid);
+ drep_msg->local_comm_id = cm_id_priv->id.local_id;
+ drep_msg->remote_comm_id = cm_id_priv->id.remote_id;
+
+ if (private_data && private_data_len)
+ memcpy(drep_msg->private_data, private_data, private_data_len);
+}
+
+int ib_send_cm_drep(struct ib_cm_id *cm_id,
+ const void *private_data,
+ u8 private_data_len)
+{
+ struct cm_id_private *cm_id_priv;
+ struct ib_mad_send_buf *msg;
+ unsigned long flags;
+ void *data;
+ int ret;
+
+ if (private_data && private_data_len > IB_CM_DREP_PRIVATE_DATA_SIZE)
+ return -EINVAL;
+
+ data = cm_copy_private_data(private_data, private_data_len);
+ if (IS_ERR(data))
+ return PTR_ERR(data);
+
+ cm_id_priv = container_of(cm_id, struct cm_id_private, id);
+ spin_lock_irqsave(&cm_id_priv->lock, flags);
+ if (cm_id->state != IB_CM_DREQ_RCVD) {
+ spin_unlock_irqrestore(&cm_id_priv->lock, flags);
+ kfree(data);
+ return -EINVAL;
+ }
+
+ cm_set_private_data(cm_id_priv, data, private_data_len);
+ cm_enter_timewait(cm_id_priv);
+
+ ret = cm_alloc_msg(cm_id_priv, &msg);
+ if (ret)
+ goto out;
+
+ cm_format_drep((struct cm_drep_msg *) msg->mad, cm_id_priv,
+ private_data, private_data_len);
+
+ ret = ib_post_send_mad(msg, NULL);
+ if (ret) {
+ spin_unlock_irqrestore(&cm_id_priv->lock, flags);
+ cm_free_msg(msg);
+ return ret;
+ }
+
+out: spin_unlock_irqrestore(&cm_id_priv->lock, flags);
+ return ret;
+}
+EXPORT_SYMBOL(ib_send_cm_drep);
+
+static int cm_issue_drep(struct cm_port *port,
+ struct ib_mad_recv_wc *mad_recv_wc)
+{
+ struct ib_mad_send_buf *msg = NULL;
+ struct cm_dreq_msg *dreq_msg;
+ struct cm_drep_msg *drep_msg;
+ int ret;
+
+ ret = cm_alloc_response_msg(port, mad_recv_wc, &msg);
+ if (ret)
+ return ret;
+
+ dreq_msg = (struct cm_dreq_msg *) mad_recv_wc->recv_buf.mad;
+ drep_msg = (struct cm_drep_msg *) msg->mad;
+
+ cm_format_mad_hdr(&drep_msg->hdr, CM_DREP_ATTR_ID, dreq_msg->hdr.tid);
+ drep_msg->remote_comm_id = dreq_msg->local_comm_id;
+ drep_msg->local_comm_id = dreq_msg->remote_comm_id;
+
+ ret = ib_post_send_mad(msg, NULL);
+ if (ret)
+ cm_free_msg(msg);
+
+ return ret;
+}
+
+static int cm_dreq_handler(struct cm_work *work)
+{
+ struct cm_id_private *cm_id_priv;
+ struct cm_dreq_msg *dreq_msg;
+ struct ib_mad_send_buf *msg = NULL;
+ int ret;
+
+ dreq_msg = (struct cm_dreq_msg *)work->mad_recv_wc->recv_buf.mad;
+ cm_id_priv = cm_acquire_id(dreq_msg->remote_comm_id,
+ dreq_msg->local_comm_id);
+ if (!cm_id_priv) {
+ atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
+ counter[CM_DREQ_COUNTER]);
+ cm_issue_drep(work->port, work->mad_recv_wc);
+ return -EINVAL;
+ }
+
+ work->cm_event.private_data = &dreq_msg->private_data;
+
+ spin_lock_irq(&cm_id_priv->lock);
+ if (cm_id_priv->local_qpn != cm_dreq_get_remote_qpn(dreq_msg))
+ goto unlock;
+
+ switch (cm_id_priv->id.state) {
+ case IB_CM_REP_SENT:
+ case IB_CM_DREQ_SENT:
+ ib_cancel_mad(cm_id_priv->av.port->mad_agent, cm_id_priv->msg);
+ break;
+ case IB_CM_ESTABLISHED:
+ if (cm_id_priv->id.lap_state == IB_CM_LAP_SENT ||
+ cm_id_priv->id.lap_state == IB_CM_MRA_LAP_RCVD)
+ ib_cancel_mad(cm_id_priv->av.port->mad_agent, cm_id_priv->msg);
+ break;
+ case IB_CM_MRA_REP_RCVD:
+ break;
+ case IB_CM_TIMEWAIT:
+ atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
+ counter[CM_DREQ_COUNTER]);
+ if (cm_alloc_response_msg(work->port, work->mad_recv_wc, &msg))
+ goto unlock;
+
+ cm_format_drep((struct cm_drep_msg *) msg->mad, cm_id_priv,
+ cm_id_priv->private_data,
+ cm_id_priv->private_data_len);
+ spin_unlock_irq(&cm_id_priv->lock);
+
+ if (ib_post_send_mad(msg, NULL))
+ cm_free_msg(msg);
+ goto deref;
+ case IB_CM_DREQ_RCVD:
+ atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
+ counter[CM_DREQ_COUNTER]);
+ goto unlock;
+ default:
+ goto unlock;
+ }
+ cm_id_priv->id.state = IB_CM_DREQ_RCVD;
+ cm_id_priv->tid = dreq_msg->hdr.tid;
+ ret = atomic_inc_and_test(&cm_id_priv->work_count);
+ if (!ret)
+ list_add_tail(&work->list, &cm_id_priv->work_list);
+ spin_unlock_irq(&cm_id_priv->lock);
+
+ if (ret)
+ cm_process_work(cm_id_priv, work);
+ else
+ cm_deref_id(cm_id_priv);
+ return 0;
+
+unlock: spin_unlock_irq(&cm_id_priv->lock);
+deref: cm_deref_id(cm_id_priv);
+ return -EINVAL;
+}
+
+static int cm_drep_handler(struct cm_work *work)
+{
+ struct cm_id_private *cm_id_priv;
+ struct cm_drep_msg *drep_msg;
+ int ret;
+
+ drep_msg = (struct cm_drep_msg *)work->mad_recv_wc->recv_buf.mad;
+ cm_id_priv = cm_acquire_id(drep_msg->remote_comm_id,
+ drep_msg->local_comm_id);
+ if (!cm_id_priv)
+ return -EINVAL;
+
+ work->cm_event.private_data = &drep_msg->private_data;
+
+ spin_lock_irq(&cm_id_priv->lock);
+ if (cm_id_priv->id.state != IB_CM_DREQ_SENT &&
+ cm_id_priv->id.state != IB_CM_DREQ_RCVD) {
+ spin_unlock_irq(&cm_id_priv->lock);
+ goto out;
+ }
+ cm_enter_timewait(cm_id_priv);
+
+ ib_cancel_mad(cm_id_priv->av.port->mad_agent, cm_id_priv->msg);
+ ret = atomic_inc_and_test(&cm_id_priv->work_count);
+ if (!ret)
+ list_add_tail(&work->list, &cm_id_priv->work_list);
+ spin_unlock_irq(&cm_id_priv->lock);
+
+ if (ret)
+ cm_process_work(cm_id_priv, work);
+ else
+ cm_deref_id(cm_id_priv);
+ return 0;
+out:
+ cm_deref_id(cm_id_priv);
+ return -EINVAL;
+}
+
+int ib_send_cm_rej(struct ib_cm_id *cm_id,
+ enum ib_cm_rej_reason reason,
+ void *ari,
+ u8 ari_length,
+ const void *private_data,
+ u8 private_data_len)
+{
+ struct cm_id_private *cm_id_priv;
+ struct ib_mad_send_buf *msg;
+ unsigned long flags;
+ int ret;
+
+ if ((private_data && private_data_len > IB_CM_REJ_PRIVATE_DATA_SIZE) ||
+ (ari && ari_length > IB_CM_REJ_ARI_LENGTH))
+ return -EINVAL;
+
+ cm_id_priv = container_of(cm_id, struct cm_id_private, id);
+
+ spin_lock_irqsave(&cm_id_priv->lock, flags);
+ switch (cm_id->state) {
+ case IB_CM_REQ_SENT:
+ case IB_CM_MRA_REQ_RCVD:
+ case IB_CM_REQ_RCVD:
+ case IB_CM_MRA_REQ_SENT:
+ case IB_CM_REP_RCVD:
+ case IB_CM_MRA_REP_SENT:
+ ret = cm_alloc_msg(cm_id_priv, &msg);
+ if (!ret)
+ cm_format_rej((struct cm_rej_msg *) msg->mad,
+ cm_id_priv, reason, ari, ari_length,
+ private_data, private_data_len);
+
+ cm_reset_to_idle(cm_id_priv);
+ break;
+ case IB_CM_REP_SENT:
+ case IB_CM_MRA_REP_RCVD:
+ ret = cm_alloc_msg(cm_id_priv, &msg);
+ if (!ret)
+ cm_format_rej((struct cm_rej_msg *) msg->mad,
+ cm_id_priv, reason, ari, ari_length,
+ private_data, private_data_len);
+
+ cm_enter_timewait(cm_id_priv);
+ break;
+ default:
+ ret = -EINVAL;
+ goto out;
+ }
+
+ if (ret)
+ goto out;
+
+ ret = ib_post_send_mad(msg, NULL);
+ if (ret)
+ cm_free_msg(msg);
+
+out: spin_unlock_irqrestore(&cm_id_priv->lock, flags);
+ return ret;
+}
+EXPORT_SYMBOL(ib_send_cm_rej);
+
+static void cm_format_rej_event(struct cm_work *work)
+{
+ struct cm_rej_msg *rej_msg;
+ struct ib_cm_rej_event_param *param;
+
+ rej_msg = (struct cm_rej_msg *)work->mad_recv_wc->recv_buf.mad;
+ param = &work->cm_event.param.rej_rcvd;
+ param->ari = rej_msg->ari;
+ param->ari_length = cm_rej_get_reject_info_len(rej_msg);
+ param->reason = __be16_to_cpu(rej_msg->reason);
+ work->cm_event.private_data = &rej_msg->private_data;
+}
+
+static struct cm_id_private * cm_acquire_rejected_id(struct cm_rej_msg *rej_msg)
+{
+ struct cm_timewait_info *timewait_info;
+ struct cm_id_private *cm_id_priv;
+ __be32 remote_id;
+
+ remote_id = rej_msg->local_comm_id;
+
+ if (__be16_to_cpu(rej_msg->reason) == IB_CM_REJ_TIMEOUT) {
+ spin_lock_irq(&cm.lock);
+ timewait_info = cm_find_remote_id( *((__be64 *) rej_msg->ari),
+ remote_id);
+ if (!timewait_info) {
+ spin_unlock_irq(&cm.lock);
+ return NULL;
+ }
+ cm_id_priv = idr_find(&cm.local_id_table, (__force int)
+ (timewait_info->work.local_id ^
+ cm.random_id_operand));
+ if (cm_id_priv) {
+ if (cm_id_priv->id.remote_id == remote_id)
+ atomic_inc(&cm_id_priv->refcount);
+ else
+ cm_id_priv = NULL;
+ }
+ spin_unlock_irq(&cm.lock);
+ } else if (cm_rej_get_msg_rejected(rej_msg) == CM_MSG_RESPONSE_REQ)
+ cm_id_priv = cm_acquire_id(rej_msg->remote_comm_id, 0);
+ else
+ cm_id_priv = cm_acquire_id(rej_msg->remote_comm_id, remote_id);
+
+ return cm_id_priv;
+}
+
+static int cm_rej_handler(struct cm_work *work)
+{
+ struct cm_id_private *cm_id_priv;
+ struct cm_rej_msg *rej_msg;
+ int ret;
+
+ rej_msg = (struct cm_rej_msg *)work->mad_recv_wc->recv_buf.mad;
+ cm_id_priv = cm_acquire_rejected_id(rej_msg);
+ if (!cm_id_priv)
+ return -EINVAL;
+
+ cm_format_rej_event(work);
+
+ spin_lock_irq(&cm_id_priv->lock);
+ switch (cm_id_priv->id.state) {
+ case IB_CM_REQ_SENT:
+ case IB_CM_MRA_REQ_RCVD:
+ case IB_CM_REP_SENT:
+ case IB_CM_MRA_REP_RCVD:
+ ib_cancel_mad(cm_id_priv->av.port->mad_agent, cm_id_priv->msg);
+ /* fall through */
+ case IB_CM_REQ_RCVD:
+ case IB_CM_MRA_REQ_SENT:
+ if (__be16_to_cpu(rej_msg->reason) == IB_CM_REJ_STALE_CONN)
+ cm_enter_timewait(cm_id_priv);
+ else
+ cm_reset_to_idle(cm_id_priv);
+ break;
+ case IB_CM_DREQ_SENT:
+ ib_cancel_mad(cm_id_priv->av.port->mad_agent, cm_id_priv->msg);
+ /* fall through */
+ case IB_CM_REP_RCVD:
+ case IB_CM_MRA_REP_SENT:
+ cm_enter_timewait(cm_id_priv);
+ break;
+ case IB_CM_ESTABLISHED:
+ if (cm_id_priv->id.lap_state == IB_CM_LAP_UNINIT ||
+ cm_id_priv->id.lap_state == IB_CM_LAP_SENT) {
+ if (cm_id_priv->id.lap_state == IB_CM_LAP_SENT)
+ ib_cancel_mad(cm_id_priv->av.port->mad_agent,
+ cm_id_priv->msg);
+ cm_enter_timewait(cm_id_priv);
+ break;
+ }
+ /* fall through */
+ default:
+ spin_unlock_irq(&cm_id_priv->lock);
+ ret = -EINVAL;
+ goto out;
+ }
+
+ ret = atomic_inc_and_test(&cm_id_priv->work_count);
+ if (!ret)
+ list_add_tail(&work->list, &cm_id_priv->work_list);
+ spin_unlock_irq(&cm_id_priv->lock);
+
+ if (ret)
+ cm_process_work(cm_id_priv, work);
+ else
+ cm_deref_id(cm_id_priv);
+ return 0;
+out:
+ cm_deref_id(cm_id_priv);
+ return -EINVAL;
+}
+
+int ib_send_cm_mra(struct ib_cm_id *cm_id,
+ u8 service_timeout,
+ const void *private_data,
+ u8 private_data_len)
+{
+ struct cm_id_private *cm_id_priv;
+ struct ib_mad_send_buf *msg;
+ enum ib_cm_state cm_state;
+ enum ib_cm_lap_state lap_state;
+ enum cm_msg_response msg_response;
+ void *data;
+ unsigned long flags;
+ int ret;
+
+ if (private_data && private_data_len > IB_CM_MRA_PRIVATE_DATA_SIZE)
+ return -EINVAL;
+
+ data = cm_copy_private_data(private_data, private_data_len);
+ if (IS_ERR(data))
+ return PTR_ERR(data);
+
+ cm_id_priv = container_of(cm_id, struct cm_id_private, id);
+
+ spin_lock_irqsave(&cm_id_priv->lock, flags);
+ switch(cm_id_priv->id.state) {
+ case IB_CM_REQ_RCVD:
+ cm_state = IB_CM_MRA_REQ_SENT;
+ lap_state = cm_id->lap_state;
+ msg_response = CM_MSG_RESPONSE_REQ;
+ break;
+ case IB_CM_REP_RCVD:
+ cm_state = IB_CM_MRA_REP_SENT;
+ lap_state = cm_id->lap_state;
+ msg_response = CM_MSG_RESPONSE_REP;
+ break;
+ case IB_CM_ESTABLISHED:
+ if (cm_id->lap_state == IB_CM_LAP_RCVD) {
+ cm_state = cm_id->state;
+ lap_state = IB_CM_MRA_LAP_SENT;
+ msg_response = CM_MSG_RESPONSE_OTHER;
+ break;
+ }
+ default:
+ ret = -EINVAL;
+ goto error1;
+ }
+
+ if (!(service_timeout & IB_CM_MRA_FLAG_DELAY)) {
+ ret = cm_alloc_msg(cm_id_priv, &msg);
+ if (ret)
+ goto error1;
+
+ cm_format_mra((struct cm_mra_msg *) msg->mad, cm_id_priv,
+ msg_response, service_timeout,
+ private_data, private_data_len);
+ ret = ib_post_send_mad(msg, NULL);
+ if (ret)
+ goto error2;
+ }
+
+ cm_id->state = cm_state;
+ cm_id->lap_state = lap_state;
+ cm_id_priv->service_timeout = service_timeout;
+ cm_set_private_data(cm_id_priv, data, private_data_len);
+ spin_unlock_irqrestore(&cm_id_priv->lock, flags);
+ return 0;
+
+error1: spin_unlock_irqrestore(&cm_id_priv->lock, flags);
+ kfree(data);
+ return ret;
+
+error2: spin_unlock_irqrestore(&cm_id_priv->lock, flags);
+ kfree(data);
+ cm_free_msg(msg);
+ return ret;
+}
+EXPORT_SYMBOL(ib_send_cm_mra);
+
+static struct cm_id_private * cm_acquire_mraed_id(struct cm_mra_msg *mra_msg)
+{
+ switch (cm_mra_get_msg_mraed(mra_msg)) {
+ case CM_MSG_RESPONSE_REQ:
+ return cm_acquire_id(mra_msg->remote_comm_id, 0);
+ case CM_MSG_RESPONSE_REP:
+ case CM_MSG_RESPONSE_OTHER:
+ return cm_acquire_id(mra_msg->remote_comm_id,
+ mra_msg->local_comm_id);
+ default:
+ return NULL;
+ }
+}
+
+static int cm_mra_handler(struct cm_work *work)
+{
+ struct cm_id_private *cm_id_priv;
+ struct cm_mra_msg *mra_msg;
+ int timeout, ret;
+
+ mra_msg = (struct cm_mra_msg *)work->mad_recv_wc->recv_buf.mad;
+ cm_id_priv = cm_acquire_mraed_id(mra_msg);
+ if (!cm_id_priv)
+ return -EINVAL;
+
+ work->cm_event.private_data = &mra_msg->private_data;
+ work->cm_event.param.mra_rcvd.service_timeout =
+ cm_mra_get_service_timeout(mra_msg);
+ timeout = cm_convert_to_ms(cm_mra_get_service_timeout(mra_msg)) +
+ cm_convert_to_ms(cm_id_priv->av.timeout);
+
+ spin_lock_irq(&cm_id_priv->lock);
+ switch (cm_id_priv->id.state) {
+ case IB_CM_REQ_SENT:
+ if (cm_mra_get_msg_mraed(mra_msg) != CM_MSG_RESPONSE_REQ ||
+ ib_modify_mad(cm_id_priv->av.port->mad_agent,
+ cm_id_priv->msg, timeout))
+ goto out;
+ cm_id_priv->id.state = IB_CM_MRA_REQ_RCVD;
+ break;
+ case IB_CM_REP_SENT:
+ if (cm_mra_get_msg_mraed(mra_msg) != CM_MSG_RESPONSE_REP ||
+ ib_modify_mad(cm_id_priv->av.port->mad_agent,
+ cm_id_priv->msg, timeout))
+ goto out;
+ cm_id_priv->id.state = IB_CM_MRA_REP_RCVD;
+ break;
+ case IB_CM_ESTABLISHED:
+ if (cm_mra_get_msg_mraed(mra_msg) != CM_MSG_RESPONSE_OTHER ||
+ cm_id_priv->id.lap_state != IB_CM_LAP_SENT ||
+ ib_modify_mad(cm_id_priv->av.port->mad_agent,
+ cm_id_priv->msg, timeout)) {
+ if (cm_id_priv->id.lap_state == IB_CM_MRA_LAP_RCVD)
+ atomic_long_inc(&work->port->
+ counter_group[CM_RECV_DUPLICATES].
+ counter[CM_MRA_COUNTER]);
+ goto out;
+ }
+ cm_id_priv->id.lap_state = IB_CM_MRA_LAP_RCVD;
+ break;
+ case IB_CM_MRA_REQ_RCVD:
+ case IB_CM_MRA_REP_RCVD:
+ atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
+ counter[CM_MRA_COUNTER]);
+ /* fall through */
+ default:
+ goto out;
+ }
+
+ cm_id_priv->msg->context[1] = (void *) (unsigned long)
+ cm_id_priv->id.state;
+ ret = atomic_inc_and_test(&cm_id_priv->work_count);
+ if (!ret)
+ list_add_tail(&work->list, &cm_id_priv->work_list);
+ spin_unlock_irq(&cm_id_priv->lock);
+
+ if (ret)
+ cm_process_work(cm_id_priv, work);
+ else
+ cm_deref_id(cm_id_priv);
+ return 0;
+out:
+ spin_unlock_irq(&cm_id_priv->lock);
+ cm_deref_id(cm_id_priv);
+ return -EINVAL;
+}
+
+static void cm_format_lap(struct cm_lap_msg *lap_msg,
+ struct cm_id_private *cm_id_priv,
+ struct ib_sa_path_rec *alternate_path,
+ const void *private_data,
+ u8 private_data_len)
+{
+ cm_format_mad_hdr(&lap_msg->hdr, CM_LAP_ATTR_ID,
+ cm_form_tid(cm_id_priv, CM_MSG_SEQUENCE_LAP));
+ lap_msg->local_comm_id = cm_id_priv->id.local_id;
+ lap_msg->remote_comm_id = cm_id_priv->id.remote_id;
+ cm_lap_set_remote_qpn(lap_msg, cm_id_priv->remote_qpn);
+ /* todo: need remote CM response timeout */
+ cm_lap_set_remote_resp_timeout(lap_msg, 0x1F);
+ lap_msg->alt_local_lid = alternate_path->slid;
+ lap_msg->alt_remote_lid = alternate_path->dlid;
+ lap_msg->alt_local_gid = alternate_path->sgid;
+ lap_msg->alt_remote_gid = alternate_path->dgid;
+ cm_lap_set_flow_label(lap_msg, alternate_path->flow_label);
+ cm_lap_set_traffic_class(lap_msg, alternate_path->traffic_class);
+ lap_msg->alt_hop_limit = alternate_path->hop_limit;
+ cm_lap_set_packet_rate(lap_msg, alternate_path->rate);
+ cm_lap_set_sl(lap_msg, alternate_path->sl);
+ cm_lap_set_subnet_local(lap_msg, 1); /* local only... */
+ cm_lap_set_local_ack_timeout(lap_msg,
+ cm_ack_timeout(cm_id_priv->av.port->cm_dev->ack_delay,
+ alternate_path->packet_life_time));
+
+ if (private_data && private_data_len)
+ memcpy(lap_msg->private_data, private_data, private_data_len);
+}
+
+int ib_send_cm_lap(struct ib_cm_id *cm_id,
+ struct ib_sa_path_rec *alternate_path,
+ const void *private_data,
+ u8 private_data_len)
+{
+ struct cm_id_private *cm_id_priv;
+ struct ib_mad_send_buf *msg;
+ unsigned long flags;
+ int ret;
+
+ if (private_data && private_data_len > IB_CM_LAP_PRIVATE_DATA_SIZE)
+ return -EINVAL;
+
+ cm_id_priv = container_of(cm_id, struct cm_id_private, id);
+ spin_lock_irqsave(&cm_id_priv->lock, flags);
+ if (cm_id->state != IB_CM_ESTABLISHED ||
+ (cm_id->lap_state != IB_CM_LAP_UNINIT &&
+ cm_id->lap_state != IB_CM_LAP_IDLE)) {
+ ret = -EINVAL;
+ goto out;
+ }
+
+ ret = cm_init_av_by_path(alternate_path, &cm_id_priv->alt_av,
+ cm_id_priv);
+ if (ret)
+ goto out;
+ cm_id_priv->alt_av.timeout =
+ cm_ack_timeout(cm_id_priv->target_ack_delay,
+ cm_id_priv->alt_av.timeout - 1);
+
+ ret = cm_alloc_msg(cm_id_priv, &msg);
+ if (ret)
+ goto out;
+
+ cm_format_lap((struct cm_lap_msg *) msg->mad, cm_id_priv,
+ alternate_path, private_data, private_data_len);
+ msg->timeout_ms = cm_id_priv->timeout_ms;
+ msg->context[1] = (void *) (unsigned long) IB_CM_ESTABLISHED;
+
+ ret = ib_post_send_mad(msg, NULL);
+ if (ret) {
+ spin_unlock_irqrestore(&cm_id_priv->lock, flags);
+ cm_free_msg(msg);
+ return ret;
+ }
+
+ cm_id->lap_state = IB_CM_LAP_SENT;
+ cm_id_priv->msg = msg;
+
+out: spin_unlock_irqrestore(&cm_id_priv->lock, flags);
+ return ret;
+}
+EXPORT_SYMBOL(ib_send_cm_lap);
+
+static void cm_format_path_from_lap(struct cm_id_private *cm_id_priv,
+ struct ib_sa_path_rec *path,
+ struct cm_lap_msg *lap_msg)
+{
+ memset(path, 0, sizeof *path);
+ path->dgid = lap_msg->alt_local_gid;
+ path->sgid = lap_msg->alt_remote_gid;
+ path->dlid = lap_msg->alt_local_lid;
+ path->slid = lap_msg->alt_remote_lid;
+ path->flow_label = cm_lap_get_flow_label(lap_msg);
+ path->hop_limit = lap_msg->alt_hop_limit;
+ path->traffic_class = cm_lap_get_traffic_class(lap_msg);
+ path->reversible = 1;
+ path->pkey = cm_id_priv->pkey;
+ path->sl = cm_lap_get_sl(lap_msg);
+ path->mtu_selector = IB_SA_EQ;
+ path->mtu = cm_id_priv->path_mtu;
+ path->rate_selector = IB_SA_EQ;
+ path->rate = cm_lap_get_packet_rate(lap_msg);
+ path->packet_life_time_selector = IB_SA_EQ;
+ path->packet_life_time = cm_lap_get_local_ack_timeout(lap_msg);
+ path->packet_life_time -= (path->packet_life_time > 0);
+}
+
+static int cm_lap_handler(struct cm_work *work)
+{
+ struct cm_id_private *cm_id_priv;
+ struct cm_lap_msg *lap_msg;
+ struct ib_cm_lap_event_param *param;
+ struct ib_mad_send_buf *msg = NULL;
+ int ret;
+
+ /* todo: verify LAP request and send reject APR if invalid. */
+ lap_msg = (struct cm_lap_msg *)work->mad_recv_wc->recv_buf.mad;
+ cm_id_priv = cm_acquire_id(lap_msg->remote_comm_id,
+ lap_msg->local_comm_id);
+ if (!cm_id_priv)
+ return -EINVAL;
+
+ param = &work->cm_event.param.lap_rcvd;
+ param->alternate_path = &work->path[0];
+ cm_format_path_from_lap(cm_id_priv, param->alternate_path, lap_msg);
+ work->cm_event.private_data = &lap_msg->private_data;
+
+ spin_lock_irq(&cm_id_priv->lock);
+ if (cm_id_priv->id.state != IB_CM_ESTABLISHED)
+ goto unlock;
+
+ switch (cm_id_priv->id.lap_state) {
+ case IB_CM_LAP_UNINIT:
+ case IB_CM_LAP_IDLE:
+ break;
+ case IB_CM_MRA_LAP_SENT:
+ atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
+ counter[CM_LAP_COUNTER]);
+ if (cm_alloc_response_msg(work->port, work->mad_recv_wc, &msg))
+ goto unlock;
+
+ cm_format_mra((struct cm_mra_msg *) msg->mad, cm_id_priv,
+ CM_MSG_RESPONSE_OTHER,
+ cm_id_priv->service_timeout,
+ cm_id_priv->private_data,
+ cm_id_priv->private_data_len);
+ spin_unlock_irq(&cm_id_priv->lock);
+
+ if (ib_post_send_mad(msg, NULL))
+ cm_free_msg(msg);
+ goto deref;
+ case IB_CM_LAP_RCVD:
+ atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
+ counter[CM_LAP_COUNTER]);
+ goto unlock;
+ default:
+ goto unlock;
+ }
+
+ cm_id_priv->id.lap_state = IB_CM_LAP_RCVD;
+ cm_id_priv->tid = lap_msg->hdr.tid;
+ cm_init_av_for_response(work->port, work->mad_recv_wc->wc,
+ work->mad_recv_wc->recv_buf.grh,
+ &cm_id_priv->av);
+ cm_init_av_by_path(param->alternate_path, &cm_id_priv->alt_av,
+ cm_id_priv);
+ ret = atomic_inc_and_test(&cm_id_priv->work_count);
+ if (!ret)
+ list_add_tail(&work->list, &cm_id_priv->work_list);
+ spin_unlock_irq(&cm_id_priv->lock);
+
+ if (ret)
+ cm_process_work(cm_id_priv, work);
+ else
+ cm_deref_id(cm_id_priv);
+ return 0;
+
+unlock: spin_unlock_irq(&cm_id_priv->lock);
+deref: cm_deref_id(cm_id_priv);
+ return -EINVAL;
+}
+
+static void cm_format_apr(struct cm_apr_msg *apr_msg,
+ struct cm_id_private *cm_id_priv,
+ enum ib_cm_apr_status status,
+ void *info,
+ u8 info_length,
+ const void *private_data,
+ u8 private_data_len)
+{
+ cm_format_mad_hdr(&apr_msg->hdr, CM_APR_ATTR_ID, cm_id_priv->tid);
+ apr_msg->local_comm_id = cm_id_priv->id.local_id;
+ apr_msg->remote_comm_id = cm_id_priv->id.remote_id;
+ apr_msg->ap_status = (u8) status;
+
+ if (info && info_length) {
+ apr_msg->info_length = info_length;
+ memcpy(apr_msg->info, info, info_length);
+ }
+
+ if (private_data && private_data_len)
+ memcpy(apr_msg->private_data, private_data, private_data_len);
+}
+
+int ib_send_cm_apr(struct ib_cm_id *cm_id,
+ enum ib_cm_apr_status status,
+ void *info,
+ u8 info_length,
+ const void *private_data,
+ u8 private_data_len)
+{
+ struct cm_id_private *cm_id_priv;
+ struct ib_mad_send_buf *msg;
+ unsigned long flags;
+ int ret;
+
+ if ((private_data && private_data_len > IB_CM_APR_PRIVATE_DATA_SIZE) ||
+ (info && info_length > IB_CM_APR_INFO_LENGTH))
+ return -EINVAL;
+
+ cm_id_priv = container_of(cm_id, struct cm_id_private, id);
+ spin_lock_irqsave(&cm_id_priv->lock, flags);
+ if (cm_id->state != IB_CM_ESTABLISHED ||
+ (cm_id->lap_state != IB_CM_LAP_RCVD &&
+ cm_id->lap_state != IB_CM_MRA_LAP_SENT)) {
+ ret = -EINVAL;
+ goto out;
+ }
+
+ ret = cm_alloc_msg(cm_id_priv, &msg);
+ if (ret)
+ goto out;
+
+ cm_format_apr((struct cm_apr_msg *) msg->mad, cm_id_priv, status,
+ info, info_length, private_data, private_data_len);
+ ret = ib_post_send_mad(msg, NULL);
+ if (ret) {
+ spin_unlock_irqrestore(&cm_id_priv->lock, flags);
+ cm_free_msg(msg);
+ return ret;
+ }
+
+ cm_id->lap_state = IB_CM_LAP_IDLE;
+out: spin_unlock_irqrestore(&cm_id_priv->lock, flags);
+ return ret;
+}
+EXPORT_SYMBOL(ib_send_cm_apr);
+
+static int cm_apr_handler(struct cm_work *work)
+{
+ struct cm_id_private *cm_id_priv;
+ struct cm_apr_msg *apr_msg;
+ int ret;
+
+ apr_msg = (struct cm_apr_msg *)work->mad_recv_wc->recv_buf.mad;
+ cm_id_priv = cm_acquire_id(apr_msg->remote_comm_id,
+ apr_msg->local_comm_id);
+ if (!cm_id_priv)
+ return -EINVAL; /* Unmatched reply. */
+
+ work->cm_event.param.apr_rcvd.ap_status = apr_msg->ap_status;
+ work->cm_event.param.apr_rcvd.apr_info = &apr_msg->info;
+ work->cm_event.param.apr_rcvd.info_len = apr_msg->info_length;
+ work->cm_event.private_data = &apr_msg->private_data;
+
+ spin_lock_irq(&cm_id_priv->lock);
+ if (cm_id_priv->id.state != IB_CM_ESTABLISHED ||
+ (cm_id_priv->id.lap_state != IB_CM_LAP_SENT &&
+ cm_id_priv->id.lap_state != IB_CM_MRA_LAP_RCVD)) {
+ spin_unlock_irq(&cm_id_priv->lock);
+ goto out;
+ }
+ cm_id_priv->id.lap_state = IB_CM_LAP_IDLE;
+ ib_cancel_mad(cm_id_priv->av.port->mad_agent, cm_id_priv->msg);
+ cm_id_priv->msg = NULL;
+
+ ret = atomic_inc_and_test(&cm_id_priv->work_count);
+ if (!ret)
+ list_add_tail(&work->list, &cm_id_priv->work_list);
+ spin_unlock_irq(&cm_id_priv->lock);
+
+ if (ret)
+ cm_process_work(cm_id_priv, work);
+ else
+ cm_deref_id(cm_id_priv);
+ return 0;
+out:
+ cm_deref_id(cm_id_priv);
+ return -EINVAL;
+}
+
+static int cm_timewait_handler(struct cm_work *work)
+{
+ struct cm_timewait_info *timewait_info;
+ struct cm_id_private *cm_id_priv;
+ int ret;
+
+ timewait_info = (struct cm_timewait_info *)work;
+ spin_lock_irq(&cm.lock);
+ list_del(&timewait_info->list);
+ spin_unlock_irq(&cm.lock);
+
+ cm_id_priv = cm_acquire_id(timewait_info->work.local_id,
+ timewait_info->work.remote_id);
+ if (!cm_id_priv)
+ return -EINVAL;
+
+ spin_lock_irq(&cm_id_priv->lock);
+ if (cm_id_priv->id.state != IB_CM_TIMEWAIT ||
+ cm_id_priv->remote_qpn != timewait_info->remote_qpn) {
+ spin_unlock_irq(&cm_id_priv->lock);
+ goto out;
+ }
+ cm_id_priv->id.state = IB_CM_IDLE;
+ ret = atomic_inc_and_test(&cm_id_priv->work_count);
+ if (!ret)
+ list_add_tail(&work->list, &cm_id_priv->work_list);
+ spin_unlock_irq(&cm_id_priv->lock);
+
+ if (ret)
+ cm_process_work(cm_id_priv, work);
+ else
+ cm_deref_id(cm_id_priv);
+ return 0;
+out:
+ cm_deref_id(cm_id_priv);
+ return -EINVAL;
+}
+
+static void cm_format_sidr_req(struct cm_sidr_req_msg *sidr_req_msg,
+ struct cm_id_private *cm_id_priv,
+ struct ib_cm_sidr_req_param *param)
+{
+ cm_format_mad_hdr(&sidr_req_msg->hdr, CM_SIDR_REQ_ATTR_ID,
+ cm_form_tid(cm_id_priv, CM_MSG_SEQUENCE_SIDR));
+ sidr_req_msg->request_id = cm_id_priv->id.local_id;
+ sidr_req_msg->pkey = param->path->pkey;
+ sidr_req_msg->service_id = param->service_id;
+
+ if (param->private_data && param->private_data_len)
+ memcpy(sidr_req_msg->private_data, param->private_data,
+ param->private_data_len);
+}
+
+int ib_send_cm_sidr_req(struct ib_cm_id *cm_id,
+ struct ib_cm_sidr_req_param *param)
+{
+ struct cm_id_private *cm_id_priv;
+ struct ib_mad_send_buf *msg;
+ unsigned long flags;
+ int ret;
+
+ if (!param->path || (param->private_data &&
+ param->private_data_len > IB_CM_SIDR_REQ_PRIVATE_DATA_SIZE))
+ return -EINVAL;
+
+ cm_id_priv = container_of(cm_id, struct cm_id_private, id);
+ ret = cm_init_av_by_path(param->path, &cm_id_priv->av, cm_id_priv);
+ if (ret)
+ goto out;
+
+ cm_id->service_id = param->service_id;
+ cm_id->service_mask = ~cpu_to_be64(0);
+ cm_id_priv->timeout_ms = param->timeout_ms;
+ cm_id_priv->max_cm_retries = param->max_cm_retries;
+ ret = cm_alloc_msg(cm_id_priv, &msg);
+ if (ret)
+ goto out;
+
+ cm_format_sidr_req((struct cm_sidr_req_msg *) msg->mad, cm_id_priv,
+ param);
+ msg->timeout_ms = cm_id_priv->timeout_ms;
+ msg->context[1] = (void *) (unsigned long) IB_CM_SIDR_REQ_SENT;
+
+ spin_lock_irqsave(&cm_id_priv->lock, flags);
+ if (cm_id->state == IB_CM_IDLE)
+ ret = ib_post_send_mad(msg, NULL);
+ else
+ ret = -EINVAL;
+
+ if (ret) {
+ spin_unlock_irqrestore(&cm_id_priv->lock, flags);
+ cm_free_msg(msg);
+ goto out;
+ }
+ cm_id->state = IB_CM_SIDR_REQ_SENT;
+ cm_id_priv->msg = msg;
+ spin_unlock_irqrestore(&cm_id_priv->lock, flags);
+out:
+ return ret;
+}
+EXPORT_SYMBOL(ib_send_cm_sidr_req);
+
+static void cm_format_sidr_req_event(struct cm_work *work,
+ struct ib_cm_id *listen_id)
+{
+ struct cm_sidr_req_msg *sidr_req_msg;
+ struct ib_cm_sidr_req_event_param *param;
+
+ sidr_req_msg = (struct cm_sidr_req_msg *)
+ work->mad_recv_wc->recv_buf.mad;
+ param = &work->cm_event.param.sidr_req_rcvd;
+ param->pkey = __be16_to_cpu(sidr_req_msg->pkey);
+ param->listen_id = listen_id;
+ param->service_id = sidr_req_msg->service_id;
+ param->bth_pkey = cm_get_bth_pkey(work);
+ param->port = work->port->port_num;
+ work->cm_event.private_data = &sidr_req_msg->private_data;
+}
+
+static int cm_sidr_req_handler(struct cm_work *work)
+{
+ struct ib_cm_id *cm_id;
+ struct cm_id_private *cm_id_priv, *cur_cm_id_priv;
+ struct cm_sidr_req_msg *sidr_req_msg;
+ struct ib_wc *wc;
+
+ cm_id = ib_create_cm_id(work->port->cm_dev->ib_device, NULL, NULL);
+ if (IS_ERR(cm_id))
+ return PTR_ERR(cm_id);
+ cm_id_priv = container_of(cm_id, struct cm_id_private, id);
+
+ /* Record SGID/SLID and request ID for lookup. */
+ sidr_req_msg = (struct cm_sidr_req_msg *)
+ work->mad_recv_wc->recv_buf.mad;
+ wc = work->mad_recv_wc->wc;
+ cm_id_priv->av.dgid.global.subnet_prefix = cpu_to_be64(wc->slid);
+ cm_id_priv->av.dgid.global.interface_id = 0;
+ cm_init_av_for_response(work->port, work->mad_recv_wc->wc,
+ work->mad_recv_wc->recv_buf.grh,
+ &cm_id_priv->av);
+ cm_id_priv->id.remote_id = sidr_req_msg->request_id;
+ cm_id_priv->tid = sidr_req_msg->hdr.tid;
+ atomic_inc(&cm_id_priv->work_count);
+
+ spin_lock_irq(&cm.lock);
+ cur_cm_id_priv = cm_insert_remote_sidr(cm_id_priv);
+ if (cur_cm_id_priv) {
+ spin_unlock_irq(&cm.lock);
+ atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
+ counter[CM_SIDR_REQ_COUNTER]);
+ goto out; /* Duplicate message. */
+ }
+ cm_id_priv->id.state = IB_CM_SIDR_REQ_RCVD;
+ cur_cm_id_priv = cm_find_listen(cm_id->device,
+ sidr_req_msg->service_id);
+ if (!cur_cm_id_priv) {
+ spin_unlock_irq(&cm.lock);
+ cm_reject_sidr_req(cm_id_priv, IB_SIDR_UNSUPPORTED);
+ goto out; /* No match. */
+ }
+ atomic_inc(&cur_cm_id_priv->refcount);
+ atomic_inc(&cm_id_priv->refcount);
+ spin_unlock_irq(&cm.lock);
+
+ cm_id_priv->id.cm_handler = cur_cm_id_priv->id.cm_handler;
+ cm_id_priv->id.context = cur_cm_id_priv->id.context;
+ cm_id_priv->id.service_id = sidr_req_msg->service_id;
+ cm_id_priv->id.service_mask = ~cpu_to_be64(0);
+
+ cm_format_sidr_req_event(work, &cur_cm_id_priv->id);
+ cm_process_work(cm_id_priv, work);
+ cm_deref_id(cur_cm_id_priv);
+ return 0;
+out:
+ ib_destroy_cm_id(&cm_id_priv->id);
+ return -EINVAL;
+}
+
+static void cm_format_sidr_rep(struct cm_sidr_rep_msg *sidr_rep_msg,
+ struct cm_id_private *cm_id_priv,
+ struct ib_cm_sidr_rep_param *param)
+{
+ cm_format_mad_hdr(&sidr_rep_msg->hdr, CM_SIDR_REP_ATTR_ID,
+ cm_id_priv->tid);
+ sidr_rep_msg->request_id = cm_id_priv->id.remote_id;
+ sidr_rep_msg->status = param->status;
+ cm_sidr_rep_set_qpn(sidr_rep_msg, cpu_to_be32(param->qp_num));
+ sidr_rep_msg->service_id = cm_id_priv->id.service_id;
+ sidr_rep_msg->qkey = cpu_to_be32(param->qkey);
+
+ if (param->info && param->info_length)
+ memcpy(sidr_rep_msg->info, param->info, param->info_length);
+
+ if (param->private_data && param->private_data_len)
+ memcpy(sidr_rep_msg->private_data, param->private_data,
+ param->private_data_len);
+}
+
+int ib_send_cm_sidr_rep(struct ib_cm_id *cm_id,
+ struct ib_cm_sidr_rep_param *param)
+{
+ struct cm_id_private *cm_id_priv;
+ struct ib_mad_send_buf *msg;
+ unsigned long flags;
+ int ret;
+
+ if ((param->info && param->info_length > IB_CM_SIDR_REP_INFO_LENGTH) ||
+ (param->private_data &&
+ param->private_data_len > IB_CM_SIDR_REP_PRIVATE_DATA_SIZE))
+ return -EINVAL;
+
+ cm_id_priv = container_of(cm_id, struct cm_id_private, id);
+ spin_lock_irqsave(&cm_id_priv->lock, flags);
+ if (cm_id->state != IB_CM_SIDR_REQ_RCVD) {
+ ret = -EINVAL;
+ goto error;
+ }
+
+ ret = cm_alloc_msg(cm_id_priv, &msg);
+ if (ret)
+ goto error;
+
+ cm_format_sidr_rep((struct cm_sidr_rep_msg *) msg->mad, cm_id_priv,
+ param);
+ ret = ib_post_send_mad(msg, NULL);
+ if (ret) {
+ spin_unlock_irqrestore(&cm_id_priv->lock, flags);
+ cm_free_msg(msg);
+ return ret;
+ }
+ cm_id->state = IB_CM_IDLE;
+ spin_unlock_irqrestore(&cm_id_priv->lock, flags);
+
+ spin_lock_irqsave(&cm.lock, flags);
+ if (!RB_EMPTY_NODE(&cm_id_priv->sidr_id_node)) {
+ rb_erase(&cm_id_priv->sidr_id_node, &cm.remote_sidr_table);
+ RB_CLEAR_NODE(&cm_id_priv->sidr_id_node);
+ }
+ spin_unlock_irqrestore(&cm.lock, flags);
+ return 0;
+
+error: spin_unlock_irqrestore(&cm_id_priv->lock, flags);
+ return ret;
+}
+EXPORT_SYMBOL(ib_send_cm_sidr_rep);
+
+static void cm_format_sidr_rep_event(struct cm_work *work)
+{
+ struct cm_sidr_rep_msg *sidr_rep_msg;
+ struct ib_cm_sidr_rep_event_param *param;
+
+ sidr_rep_msg = (struct cm_sidr_rep_msg *)
+ work->mad_recv_wc->recv_buf.mad;
+ param = &work->cm_event.param.sidr_rep_rcvd;
+ param->status = sidr_rep_msg->status;
+ param->qkey = be32_to_cpu(sidr_rep_msg->qkey);
+ param->qpn = be32_to_cpu(cm_sidr_rep_get_qpn(sidr_rep_msg));
+ param->info = &sidr_rep_msg->info;
+ param->info_len = sidr_rep_msg->info_length;
+ work->cm_event.private_data = &sidr_rep_msg->private_data;
+}
+
+static int cm_sidr_rep_handler(struct cm_work *work)
+{
+ struct cm_sidr_rep_msg *sidr_rep_msg;
+ struct cm_id_private *cm_id_priv;
+
+ sidr_rep_msg = (struct cm_sidr_rep_msg *)
+ work->mad_recv_wc->recv_buf.mad;
+ cm_id_priv = cm_acquire_id(sidr_rep_msg->request_id, 0);
+ if (!cm_id_priv)
+ return -EINVAL; /* Unmatched reply. */
+
+ spin_lock_irq(&cm_id_priv->lock);
+ if (cm_id_priv->id.state != IB_CM_SIDR_REQ_SENT) {
+ spin_unlock_irq(&cm_id_priv->lock);
+ goto out;
+ }
+ cm_id_priv->id.state = IB_CM_IDLE;
+ ib_cancel_mad(cm_id_priv->av.port->mad_agent, cm_id_priv->msg);
+ spin_unlock_irq(&cm_id_priv->lock);
+
+ cm_format_sidr_rep_event(work);
+ cm_process_work(cm_id_priv, work);
+ return 0;
+out:
+ cm_deref_id(cm_id_priv);
+ return -EINVAL;
+}
+
+static void cm_process_send_error(struct ib_mad_send_buf *msg,
+ enum ib_wc_status wc_status)
+{
+ struct cm_id_private *cm_id_priv;
+ struct ib_cm_event cm_event;
+ enum ib_cm_state state;
+ int ret;
+
+ memset(&cm_event, 0, sizeof cm_event);
+ cm_id_priv = msg->context[0];
+
+ /* Discard old sends or ones without a response. */
+ spin_lock_irq(&cm_id_priv->lock);
+ state = (enum ib_cm_state) (unsigned long) msg->context[1];
+ if (msg != cm_id_priv->msg || state != cm_id_priv->id.state)
+ goto discard;
+
+ switch (state) {
+ case IB_CM_REQ_SENT:
+ case IB_CM_MRA_REQ_RCVD:
+ cm_reset_to_idle(cm_id_priv);
+ cm_event.event = IB_CM_REQ_ERROR;
+ break;
+ case IB_CM_REP_SENT:
+ case IB_CM_MRA_REP_RCVD:
+ cm_reset_to_idle(cm_id_priv);
+ cm_event.event = IB_CM_REP_ERROR;
+ break;
+ case IB_CM_DREQ_SENT:
+ cm_enter_timewait(cm_id_priv);
+ cm_event.event = IB_CM_DREQ_ERROR;
+ break;
+ case IB_CM_SIDR_REQ_SENT:
+ cm_id_priv->id.state = IB_CM_IDLE;
+ cm_event.event = IB_CM_SIDR_REQ_ERROR;
+ break;
+ default:
+ goto discard;
+ }
+ spin_unlock_irq(&cm_id_priv->lock);
+ cm_event.param.send_status = wc_status;
+
+ /* No other events can occur on the cm_id at this point. */
+ ret = cm_id_priv->id.cm_handler(&cm_id_priv->id, &cm_event);
+ cm_free_msg(msg);
+ if (ret)
+ ib_destroy_cm_id(&cm_id_priv->id);
+ return;
+discard:
+ spin_unlock_irq(&cm_id_priv->lock);
+ cm_free_msg(msg);
+}
+
+static void cm_send_handler(struct ib_mad_agent *mad_agent,
+ struct ib_mad_send_wc *mad_send_wc)
+{
+ struct ib_mad_send_buf *msg = mad_send_wc->send_buf;
+ struct cm_port *port;
+ u16 attr_index;
+
+ port = mad_agent->context;
+ attr_index = be16_to_cpu(((struct ib_mad_hdr *)
+ msg->mad)->attr_id) - CM_ATTR_ID_OFFSET;
+
+ /*
+ * If the send was in response to a received message (context[0] is not
+ * set to a cm_id), and is not a REJ, then it is a send that was
+ * manually retried.
+ */
+ if (!msg->context[0] && (attr_index != CM_REJ_COUNTER))
+ msg->retries = 1;
+
+ atomic_long_add(1 + msg->retries,
+ &port->counter_group[CM_XMIT].counter[attr_index]);
+ if (msg->retries)
+ atomic_long_add(msg->retries,
+ &port->counter_group[CM_XMIT_RETRIES].
+ counter[attr_index]);
+
+ switch (mad_send_wc->status) {
+ case IB_WC_SUCCESS:
+ case IB_WC_WR_FLUSH_ERR:
+ cm_free_msg(msg);
+ break;
+ default:
+ if (msg->context[0] && msg->context[1])
+ cm_process_send_error(msg, mad_send_wc->status);
+ else
+ cm_free_msg(msg);
+ break;
+ }
+}
+
+static void cm_work_handler(struct work_struct *_work)
+{
+ struct cm_work *work = container_of(_work, struct cm_work, work.work);
+ int ret;
+
+ switch (work->cm_event.event) {
+ case IB_CM_REQ_RECEIVED:
+ ret = cm_req_handler(work);
+ break;
+ case IB_CM_MRA_RECEIVED:
+ ret = cm_mra_handler(work);
+ break;
+ case IB_CM_REJ_RECEIVED:
+ ret = cm_rej_handler(work);
+ break;
+ case IB_CM_REP_RECEIVED:
+ ret = cm_rep_handler(work);
+ break;
+ case IB_CM_RTU_RECEIVED:
+ ret = cm_rtu_handler(work);
+ break;
+ case IB_CM_USER_ESTABLISHED:
+ ret = cm_establish_handler(work);
+ break;
+ case IB_CM_DREQ_RECEIVED:
+ ret = cm_dreq_handler(work);
+ break;
+ case IB_CM_DREP_RECEIVED:
+ ret = cm_drep_handler(work);
+ break;
+ case IB_CM_SIDR_REQ_RECEIVED:
+ ret = cm_sidr_req_handler(work);
+ break;
+ case IB_CM_SIDR_REP_RECEIVED:
+ ret = cm_sidr_rep_handler(work);
+ break;
+ case IB_CM_LAP_RECEIVED:
+ ret = cm_lap_handler(work);
+ break;
+ case IB_CM_APR_RECEIVED:
+ ret = cm_apr_handler(work);
+ break;
+ case IB_CM_TIMEWAIT_EXIT:
+ ret = cm_timewait_handler(work);
+ break;
+ default:
+ ret = -EINVAL;
+ break;
+ }
+ if (ret)
+ cm_free_work(work);
+}
+
+static int cm_establish(struct ib_cm_id *cm_id)
+{
+ struct cm_id_private *cm_id_priv;
+ struct cm_work *work;
+ unsigned long flags;
+ int ret = 0;
+ struct cm_device *cm_dev;
+
+ cm_dev = ib_get_client_data(cm_id->device, &cm_client);
+ if (!cm_dev)
+ return -ENODEV;
+
+ work = kmalloc(sizeof *work, GFP_ATOMIC);
+ if (!work)
+ return -ENOMEM;
+
+ cm_id_priv = container_of(cm_id, struct cm_id_private, id);
+ spin_lock_irqsave(&cm_id_priv->lock, flags);
+ switch (cm_id->state)
+ {
+ case IB_CM_REP_SENT:
+ case IB_CM_MRA_REP_RCVD:
+ cm_id->state = IB_CM_ESTABLISHED;
+ break;
+ case IB_CM_ESTABLISHED:
+ ret = -EISCONN;
+ break;
+ default:
+ ret = -EINVAL;
+ break;
+ }
+ spin_unlock_irqrestore(&cm_id_priv->lock, flags);
+
+ if (ret) {
+ kfree(work);
+ goto out;
+ }
+
+ /*
+ * The CM worker thread may try to destroy the cm_id before it
+ * can execute this work item. To prevent potential deadlock,
+ * we need to find the cm_id once we're in the context of the
+ * worker thread, rather than holding a reference on it.
+ */
+ INIT_DELAYED_WORK(&work->work, cm_work_handler);
+ work->local_id = cm_id->local_id;
+ work->remote_id = cm_id->remote_id;
+ work->mad_recv_wc = NULL;
+ work->cm_event.event = IB_CM_USER_ESTABLISHED;
+
+ /* Check if the device started its remove_one */
+ spin_lock_irqsave(&cm.lock, flags);
+ if (!cm_dev->going_down) {
+ queue_delayed_work(cm.wq, &work->work, 0);
+ } else {
+ kfree(work);
+ ret = -ENODEV;
+ }
+ spin_unlock_irqrestore(&cm.lock, flags);
+
+out:
+ return ret;
+}
+
+static int cm_migrate(struct ib_cm_id *cm_id)
+{
+ struct cm_id_private *cm_id_priv;
+ struct cm_av tmp_av;
+ unsigned long flags;
+ int tmp_send_port_not_ready;
+ int ret = 0;
+
+ cm_id_priv = container_of(cm_id, struct cm_id_private, id);
+ spin_lock_irqsave(&cm_id_priv->lock, flags);
+ if (cm_id->state == IB_CM_ESTABLISHED &&
+ (cm_id->lap_state == IB_CM_LAP_UNINIT ||
+ cm_id->lap_state == IB_CM_LAP_IDLE)) {
+ cm_id->lap_state = IB_CM_LAP_IDLE;
+ /* Swap address vector */
+ tmp_av = cm_id_priv->av;
+ cm_id_priv->av = cm_id_priv->alt_av;
+ cm_id_priv->alt_av = tmp_av;
+ /* Swap port send ready state */
+ tmp_send_port_not_ready = cm_id_priv->prim_send_port_not_ready;
+ cm_id_priv->prim_send_port_not_ready = cm_id_priv->altr_send_port_not_ready;
+ cm_id_priv->altr_send_port_not_ready = tmp_send_port_not_ready;
+ } else
+ ret = -EINVAL;
+ spin_unlock_irqrestore(&cm_id_priv->lock, flags);
+
+ return ret;
+}
+
+int ib_cm_notify(struct ib_cm_id *cm_id, enum ib_event_type event)
+{
+ int ret;
+
+ switch (event) {
+ case IB_EVENT_COMM_EST:
+ ret = cm_establish(cm_id);
+ break;
+ case IB_EVENT_PATH_MIG:
+ ret = cm_migrate(cm_id);
+ break;
+ default:
+ ret = -EINVAL;
+ }
+ return ret;
+}
+EXPORT_SYMBOL(ib_cm_notify);
+
+static void cm_recv_handler(struct ib_mad_agent *mad_agent,
+ struct ib_mad_send_buf *send_buf,
+ struct ib_mad_recv_wc *mad_recv_wc)
+{
+ struct cm_port *port = mad_agent->context;
+ struct cm_work *work;
+ enum ib_cm_event_type event;
+ u16 attr_id;
+ int paths = 0;
+ int going_down = 0;
+
+ switch (mad_recv_wc->recv_buf.mad->mad_hdr.attr_id) {
+ case CM_REQ_ATTR_ID:
+ paths = 1 + (((struct cm_req_msg *) mad_recv_wc->recv_buf.mad)->
+ alt_local_lid != 0);
+ event = IB_CM_REQ_RECEIVED;
+ break;
+ case CM_MRA_ATTR_ID:
+ event = IB_CM_MRA_RECEIVED;
+ break;
+ case CM_REJ_ATTR_ID:
+ event = IB_CM_REJ_RECEIVED;
+ break;
+ case CM_REP_ATTR_ID:
+ event = IB_CM_REP_RECEIVED;
+ break;
+ case CM_RTU_ATTR_ID:
+ event = IB_CM_RTU_RECEIVED;
+ break;
+ case CM_DREQ_ATTR_ID:
+ event = IB_CM_DREQ_RECEIVED;
+ break;
+ case CM_DREP_ATTR_ID:
+ event = IB_CM_DREP_RECEIVED;
+ break;
+ case CM_SIDR_REQ_ATTR_ID:
+ event = IB_CM_SIDR_REQ_RECEIVED;
+ break;
+ case CM_SIDR_REP_ATTR_ID:
+ event = IB_CM_SIDR_REP_RECEIVED;
+ break;
+ case CM_LAP_ATTR_ID:
+ paths = 1;
+ event = IB_CM_LAP_RECEIVED;
+ break;
+ case CM_APR_ATTR_ID:
+ event = IB_CM_APR_RECEIVED;
+ break;
+ default:
+ ib_free_recv_mad(mad_recv_wc);
+ return;
+ }
+
+ attr_id = be16_to_cpu(mad_recv_wc->recv_buf.mad->mad_hdr.attr_id);
+ atomic_long_inc(&port->counter_group[CM_RECV].
+ counter[attr_id - CM_ATTR_ID_OFFSET]);
+
+ work = kmalloc(sizeof *work + sizeof(struct ib_sa_path_rec) * paths,
+ GFP_KERNEL);
+ if (!work) {
+ ib_free_recv_mad(mad_recv_wc);
+ return;
+ }
+
+ INIT_DELAYED_WORK(&work->work, cm_work_handler);
+ work->cm_event.event = event;
+ work->mad_recv_wc = mad_recv_wc;
+ work->port = port;
+
+ /* Check if the device started its remove_one */
+ spin_lock_irq(&cm.lock);
+ if (!port->cm_dev->going_down)
+ queue_delayed_work(cm.wq, &work->work, 0);
+ else
+ going_down = 1;
+ spin_unlock_irq(&cm.lock);
+
+ if (going_down) {
+ kfree(work);
+ ib_free_recv_mad(mad_recv_wc);
+ }
+}
+
+static int cm_init_qp_init_attr(struct cm_id_private *cm_id_priv,
+ struct ib_qp_attr *qp_attr,
+ int *qp_attr_mask)
+{
+ unsigned long flags;
+ int ret;
+
+ spin_lock_irqsave(&cm_id_priv->lock, flags);
+ switch (cm_id_priv->id.state) {
+ case IB_CM_REQ_SENT:
+ case IB_CM_MRA_REQ_RCVD:
+ case IB_CM_REQ_RCVD:
+ case IB_CM_MRA_REQ_SENT:
+ case IB_CM_REP_RCVD:
+ case IB_CM_MRA_REP_SENT:
+ case IB_CM_REP_SENT:
+ case IB_CM_MRA_REP_RCVD:
+ case IB_CM_ESTABLISHED:
+ *qp_attr_mask = IB_QP_STATE | IB_QP_ACCESS_FLAGS |
+ IB_QP_PKEY_INDEX | IB_QP_PORT;
+ qp_attr->qp_access_flags = IB_ACCESS_REMOTE_WRITE;
+ if (cm_id_priv->responder_resources)
+ qp_attr->qp_access_flags |= IB_ACCESS_REMOTE_READ |
+ IB_ACCESS_REMOTE_ATOMIC;
+ qp_attr->pkey_index = cm_id_priv->av.pkey_index;
+ qp_attr->port_num = cm_id_priv->av.port->port_num;
+ ret = 0;
+ break;
+ default:
+ ret = -EINVAL;
+ break;
+ }
+ spin_unlock_irqrestore(&cm_id_priv->lock, flags);
+ return ret;
+}
+
+static int cm_init_qp_rtr_attr(struct cm_id_private *cm_id_priv,
+ struct ib_qp_attr *qp_attr,
+ int *qp_attr_mask)
+{
+ unsigned long flags;
+ int ret;
+
+ spin_lock_irqsave(&cm_id_priv->lock, flags);
+ switch (cm_id_priv->id.state) {
+ case IB_CM_REQ_RCVD:
+ case IB_CM_MRA_REQ_SENT:
+ case IB_CM_REP_RCVD:
+ case IB_CM_MRA_REP_SENT:
+ case IB_CM_REP_SENT:
+ case IB_CM_MRA_REP_RCVD:
+ case IB_CM_ESTABLISHED:
+ *qp_attr_mask = IB_QP_STATE | IB_QP_AV | IB_QP_PATH_MTU |
+ IB_QP_DEST_QPN | IB_QP_RQ_PSN;
+ qp_attr->ah_attr = cm_id_priv->av.ah_attr;
+ qp_attr->path_mtu = cm_id_priv->path_mtu;
+ qp_attr->dest_qp_num = be32_to_cpu(cm_id_priv->remote_qpn);
+ qp_attr->rq_psn = be32_to_cpu(cm_id_priv->rq_psn);
+ if (cm_id_priv->qp_type == IB_QPT_RC ||
+ cm_id_priv->qp_type == IB_QPT_XRC_TGT) {
+ *qp_attr_mask |= IB_QP_MAX_DEST_RD_ATOMIC |
+ IB_QP_MIN_RNR_TIMER;
+ qp_attr->max_dest_rd_atomic =
+ cm_id_priv->responder_resources;
+ qp_attr->min_rnr_timer = 0;
+ }
+ if (cm_id_priv->alt_av.ah_attr.dlid) {
+ *qp_attr_mask |= IB_QP_ALT_PATH;
+ qp_attr->alt_port_num = cm_id_priv->alt_av.port->port_num;
+ qp_attr->alt_pkey_index = cm_id_priv->alt_av.pkey_index;
+ qp_attr->alt_timeout = cm_id_priv->alt_av.timeout;
+ qp_attr->alt_ah_attr = cm_id_priv->alt_av.ah_attr;
+ }
+ ret = 0;
+ break;
+ default:
+ ret = -EINVAL;
+ break;
+ }
+ spin_unlock_irqrestore(&cm_id_priv->lock, flags);
+ return ret;
+}
+
+static int cm_init_qp_rts_attr(struct cm_id_private *cm_id_priv,
+ struct ib_qp_attr *qp_attr,
+ int *qp_attr_mask)
+{
+ unsigned long flags;
+ int ret;
+
+ spin_lock_irqsave(&cm_id_priv->lock, flags);
+ switch (cm_id_priv->id.state) {
+ /* Allow transition to RTS before sending REP */
+ case IB_CM_REQ_RCVD:
+ case IB_CM_MRA_REQ_SENT:
+
+ case IB_CM_REP_RCVD:
+ case IB_CM_MRA_REP_SENT:
+ case IB_CM_REP_SENT:
+ case IB_CM_MRA_REP_RCVD:
+ case IB_CM_ESTABLISHED:
+ if (cm_id_priv->id.lap_state == IB_CM_LAP_UNINIT) {
+ *qp_attr_mask = IB_QP_STATE | IB_QP_SQ_PSN;
+ qp_attr->sq_psn = be32_to_cpu(cm_id_priv->sq_psn);
+ switch (cm_id_priv->qp_type) {
+ case IB_QPT_RC:
+ case IB_QPT_XRC_INI:
+ *qp_attr_mask |= IB_QP_RETRY_CNT | IB_QP_RNR_RETRY |
+ IB_QP_MAX_QP_RD_ATOMIC;
+ qp_attr->retry_cnt = cm_id_priv->retry_count;
+ qp_attr->rnr_retry = cm_id_priv->rnr_retry_count;
+ qp_attr->max_rd_atomic = cm_id_priv->initiator_depth;
+ /* fall through */
+ case IB_QPT_XRC_TGT:
+ *qp_attr_mask |= IB_QP_TIMEOUT;
+ qp_attr->timeout = cm_id_priv->av.timeout;
+ break;
+ default:
+ break;
+ }
+ if (cm_id_priv->alt_av.ah_attr.dlid) {
+ *qp_attr_mask |= IB_QP_PATH_MIG_STATE;
+ qp_attr->path_mig_state = IB_MIG_REARM;
+ }
+ } else {
+ *qp_attr_mask = IB_QP_ALT_PATH | IB_QP_PATH_MIG_STATE;
+ qp_attr->alt_port_num = cm_id_priv->alt_av.port->port_num;
+ qp_attr->alt_pkey_index = cm_id_priv->alt_av.pkey_index;
+ qp_attr->alt_timeout = cm_id_priv->alt_av.timeout;
+ qp_attr->alt_ah_attr = cm_id_priv->alt_av.ah_attr;
+ qp_attr->path_mig_state = IB_MIG_REARM;
+ }
+ ret = 0;
+ break;
+ default:
+ ret = -EINVAL;
+ break;
+ }
+ spin_unlock_irqrestore(&cm_id_priv->lock, flags);
+ return ret;
+}
+
+int ib_cm_init_qp_attr(struct ib_cm_id *cm_id,
+ struct ib_qp_attr *qp_attr,
+ int *qp_attr_mask)
+{
+ struct cm_id_private *cm_id_priv;
+ int ret;
+
+ cm_id_priv = container_of(cm_id, struct cm_id_private, id);
+ switch (qp_attr->qp_state) {
+ case IB_QPS_INIT:
+ ret = cm_init_qp_init_attr(cm_id_priv, qp_attr, qp_attr_mask);
+ break;
+ case IB_QPS_RTR:
+ ret = cm_init_qp_rtr_attr(cm_id_priv, qp_attr, qp_attr_mask);
+ break;
+ case IB_QPS_RTS:
+ ret = cm_init_qp_rts_attr(cm_id_priv, qp_attr, qp_attr_mask);
+ break;
+ default:
+ ret = -EINVAL;
+ break;
+ }
+ return ret;
+}
+EXPORT_SYMBOL(ib_cm_init_qp_attr);
+
+static ssize_t cm_show_counter(struct kobject *obj, struct attribute *attr,
+ char *buf)
+{
+ struct cm_counter_group *group;
+ struct cm_counter_attribute *cm_attr;
+
+ group = container_of(obj, struct cm_counter_group, obj);
+ cm_attr = container_of(attr, struct cm_counter_attribute, attr);
+
+ return sprintf(buf, "%ld\n",
+ atomic_long_read(&group->counter[cm_attr->index]));
+}
+
+static const struct sysfs_ops cm_counter_ops = {
+ .show = cm_show_counter
+};
+
+static struct kobj_type cm_counter_obj_type = {
+ .sysfs_ops = &cm_counter_ops,
+ .default_attrs = cm_counter_default_attrs
+};
+
+static void cm_release_port_obj(struct kobject *obj)
+{
+ struct cm_port *cm_port;
+
+ cm_port = container_of(obj, struct cm_port, port_obj);
+ kfree(cm_port);
+}
+
+static struct kobj_type cm_port_obj_type = {
+ .release = cm_release_port_obj
+};
+
+static char *cm_devnode(struct device *dev, umode_t *mode)
+{
+ if (mode)
+ *mode = 0666;
+ return kasprintf(GFP_KERNEL, "infiniband/%s", dev_name(dev));
+}
+
+struct class cm_class = {
+ .owner = THIS_MODULE,
+ .name = "infiniband_cm",
+ .devnode = cm_devnode,
+};
+EXPORT_SYMBOL(cm_class);
+
+static int cm_create_port_fs(struct cm_port *port)
+{
+ int i, ret;
+
+ ret = kobject_init_and_add(&port->port_obj, &cm_port_obj_type,
+ &port->cm_dev->device->kobj,
+ "%d", port->port_num);
+ if (ret) {
+ kfree(port);
+ return ret;
+ }
+
+ for (i = 0; i < CM_COUNTER_GROUPS; i++) {
+ ret = kobject_init_and_add(&port->counter_group[i].obj,
+ &cm_counter_obj_type,
+ &port->port_obj,
+ "%s", counter_group_names[i]);
+ if (ret)
+ goto error;
+ }
+
+ return 0;
+
+error:
+ while (i--)
+ kobject_put(&port->counter_group[i].obj);
+ kobject_put(&port->port_obj);
+ return ret;
+
+}
+
+static void cm_remove_port_fs(struct cm_port *port)
+{
+ int i;
+
+ for (i = 0; i < CM_COUNTER_GROUPS; i++)
+ kobject_put(&port->counter_group[i].obj);
+
+ kobject_put(&port->port_obj);
+}
+
+static void cm_add_one(struct ib_device *ib_device)
+{
+ struct cm_device *cm_dev;
+ struct cm_port *port;
+ struct ib_mad_reg_req reg_req = {
+ .mgmt_class = IB_MGMT_CLASS_CM,
+ .mgmt_class_version = IB_CM_CLASS_VERSION,
+ };
+ struct ib_port_modify port_modify = {
+ .set_port_cap_mask = IB_PORT_CM_SUP
+ };
+ unsigned long flags;
+ int ret;
+ int count = 0;
+ u8 i;
+
+ cm_dev = kzalloc(sizeof(*cm_dev) + sizeof(*port) *
+ ib_device->phys_port_cnt, GFP_KERNEL);
+ if (!cm_dev)
+ return;
+
+ cm_dev->ib_device = ib_device;
+ cm_dev->ack_delay = ib_device->attrs.local_ca_ack_delay;
+ cm_dev->going_down = 0;
+ cm_dev->device = device_create(&cm_class, &ib_device->dev,
+ MKDEV(0, 0), NULL,
+ "%s", ib_device->name);
+ if (IS_ERR(cm_dev->device)) {
+ kfree(cm_dev);
+ return;
+ }
+
+ set_bit(IB_MGMT_METHOD_SEND, reg_req.method_mask);
+ for (i = 1; i <= ib_device->phys_port_cnt; i++) {
+ if (!rdma_cap_ib_cm(ib_device, i))
+ continue;
+
+ port = kzalloc(sizeof *port, GFP_KERNEL);
+ if (!port)
+ goto error1;
+
+ cm_dev->port[i-1] = port;
+ port->cm_dev = cm_dev;
+ port->port_num = i;
+
+ INIT_LIST_HEAD(&port->cm_priv_prim_list);
+ INIT_LIST_HEAD(&port->cm_priv_altr_list);
+
+ ret = cm_create_port_fs(port);
+ if (ret)
+ goto error1;
+
+ port->mad_agent = ib_register_mad_agent(ib_device, i,
+ IB_QPT_GSI,
+ &reg_req,
+ 0,
+ cm_send_handler,
+ cm_recv_handler,
+ port,
+ 0);
+ if (IS_ERR(port->mad_agent))
+ goto error2;
+
+ ret = ib_modify_port(ib_device, i, 0, &port_modify);
+ if (ret)
+ goto error3;
+
+ count++;
+ }
+
+ if (!count)
+ goto free;
+
+ ib_set_client_data(ib_device, &cm_client, cm_dev);
+
+ write_lock_irqsave(&cm.device_lock, flags);
+ list_add_tail(&cm_dev->list, &cm.device_list);
+ write_unlock_irqrestore(&cm.device_lock, flags);
+ return;
+
+error3:
+ ib_unregister_mad_agent(port->mad_agent);
+error2:
+ cm_remove_port_fs(port);
+error1:
+ port_modify.set_port_cap_mask = 0;
+ port_modify.clr_port_cap_mask = IB_PORT_CM_SUP;
+ while (--i) {
+ if (!rdma_cap_ib_cm(ib_device, i))
+ continue;
+
+ port = cm_dev->port[i-1];
+ ib_modify_port(ib_device, port->port_num, 0, &port_modify);
+ ib_unregister_mad_agent(port->mad_agent);
+ cm_remove_port_fs(port);
+ }
+free:
+ device_unregister(cm_dev->device);
+ kfree(cm_dev);
+}
+
+static void cm_remove_one(struct ib_device *ib_device, void *client_data)
+{
+ struct cm_device *cm_dev = client_data;
+ struct cm_port *port;
+ struct cm_id_private *cm_id_priv;
+ struct ib_mad_agent *cur_mad_agent;
+ struct ib_port_modify port_modify = {
+ .clr_port_cap_mask = IB_PORT_CM_SUP
+ };
+ unsigned long flags;
+ int i;
+
+ if (!cm_dev)
+ return;
+
+ write_lock_irqsave(&cm.device_lock, flags);
+ list_del(&cm_dev->list);
+ write_unlock_irqrestore(&cm.device_lock, flags);
+
+ spin_lock_irq(&cm.lock);
+ cm_dev->going_down = 1;
+ spin_unlock_irq(&cm.lock);
+
+ for (i = 1; i <= ib_device->phys_port_cnt; i++) {
+ if (!rdma_cap_ib_cm(ib_device, i))
+ continue;
+
+ port = cm_dev->port[i-1];
+ ib_modify_port(ib_device, port->port_num, 0, &port_modify);
+ /* Mark all the cm_id's as not valid */
+ spin_lock_irq(&cm.lock);
+ list_for_each_entry(cm_id_priv, &port->cm_priv_altr_list, altr_list)
+ cm_id_priv->altr_send_port_not_ready = 1;
+ list_for_each_entry(cm_id_priv, &port->cm_priv_prim_list, prim_list)
+ cm_id_priv->prim_send_port_not_ready = 1;
+ spin_unlock_irq(&cm.lock);
+ /*
+ * We flush the queue here after the going_down set, this
+ * verify that no new works will be queued in the recv handler,
+ * after that we can call the unregister_mad_agent
+ */
+ flush_workqueue(cm.wq);
+ spin_lock_irq(&cm.state_lock);
+ cur_mad_agent = port->mad_agent;
+ port->mad_agent = NULL;
+ spin_unlock_irq(&cm.state_lock);
+ ib_unregister_mad_agent(cur_mad_agent);
+ cm_remove_port_fs(port);
+ }
+
+ device_unregister(cm_dev->device);
+ kfree(cm_dev);
+}
+
+static int __init ib_cm_init(void)
+{
+ int ret;
+
+ memset(&cm, 0, sizeof cm);
+ INIT_LIST_HEAD(&cm.device_list);
+ rwlock_init(&cm.device_lock);
+ spin_lock_init(&cm.lock);
+ spin_lock_init(&cm.state_lock);
+ cm.listen_service_table = RB_ROOT;
+ cm.listen_service_id = be64_to_cpu(IB_CM_ASSIGN_SERVICE_ID);
+ cm.remote_id_table = RB_ROOT;
+ cm.remote_qp_table = RB_ROOT;
+ cm.remote_sidr_table = RB_ROOT;
+ idr_init(&cm.local_id_table);
+ get_random_bytes(&cm.random_id_operand, sizeof cm.random_id_operand);
+ INIT_LIST_HEAD(&cm.timewait_list);
+
+ ret = class_register(&cm_class);
+ if (ret) {
+ ret = -ENOMEM;
+ goto error1;
+ }
+
+ cm.wq = create_workqueue("ib_cm");
+ if (!cm.wq) {
+ ret = -ENOMEM;
+ goto error2;
+ }
+
+ ret = ib_register_client(&cm_client);
+ if (ret)
+ goto error3;
+
+ return 0;
+error3:
+ destroy_workqueue(cm.wq);
+error2:
+ class_unregister(&cm_class);
+error1:
+ idr_destroy(&cm.local_id_table);
+ return ret;
+}
+
+static void __exit ib_cm_cleanup(void)
+{
+ struct cm_timewait_info *timewait_info, *tmp;
+
+ spin_lock_irq(&cm.lock);
+ list_for_each_entry(timewait_info, &cm.timewait_list, list)
+ cancel_delayed_work(&timewait_info->work.work);
+ spin_unlock_irq(&cm.lock);
+
+ ib_unregister_client(&cm_client);
+ destroy_workqueue(cm.wq);
+
+ list_for_each_entry_safe(timewait_info, tmp, &cm.timewait_list, list) {
+ list_del(&timewait_info->list);
+ kfree(timewait_info);
+ }
+
+ class_unregister(&cm_class);
+ idr_destroy(&cm.local_id_table);
+}
+
+module_init_order(ib_cm_init, SI_ORDER_SECOND);
+module_exit_order(ib_cm_cleanup, SI_ORDER_FIRST);
+
diff --git a/sys/ofed/drivers/infiniband/core/ib_cma.c b/sys/ofed/drivers/infiniband/core/ib_cma.c
new file mode 100644
index 0000000..13650b6
--- /dev/null
+++ b/sys/ofed/drivers/infiniband/core/ib_cma.c
@@ -0,0 +1,4312 @@
+/*
+ * Copyright (c) 2005 Voltaire Inc. All rights reserved.
+ * Copyright (c) 2002-2005, Network Appliance, Inc. All rights reserved.
+ * Copyright (c) 1999-2005, Mellanox Technologies, Inc. All rights reserved.
+ * Copyright (c) 2005-2006 Intel Corporation. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#define LINUXKPI_PARAM_PREFIX ibcore_
+
+#include <linux/completion.h>
+#include <linux/in.h>
+#include <linux/in6.h>
+#include <linux/mutex.h>
+#include <linux/random.h>
+#include <linux/idr.h>
+#include <linux/inetdevice.h>
+#include <linux/slab.h>
+#include <linux/module.h>
+#include <net/route.h>
+
+#include <net/tcp.h>
+#include <net/ipv6.h>
+
+#include <netinet6/scope6_var.h>
+#include <netinet6/ip6_var.h>
+
+#include <rdma/rdma_cm.h>
+#include <rdma/rdma_cm_ib.h>
+#include <rdma/ib.h>
+#include <rdma/ib_addr.h>
+#include <rdma/ib_cache.h>
+#include <rdma/ib_cm.h>
+#include <rdma/ib_sa.h>
+#include <rdma/iw_cm.h>
+
+#include <sys/priv.h>
+
+#include "core_priv.h"
+
+MODULE_AUTHOR("Sean Hefty");
+MODULE_DESCRIPTION("Generic RDMA CM Agent");
+MODULE_LICENSE("Dual BSD/GPL");
+
+#define CMA_CM_RESPONSE_TIMEOUT 20
+#define CMA_QUERY_CLASSPORT_INFO_TIMEOUT 3000
+#define CMA_MAX_CM_RETRIES 15
+#define CMA_CM_MRA_SETTING (IB_CM_MRA_FLAG_DELAY | 24)
+#define CMA_IBOE_PACKET_LIFETIME 18
+
+static const char * const cma_events[] = {
+ [RDMA_CM_EVENT_ADDR_RESOLVED] = "address resolved",
+ [RDMA_CM_EVENT_ADDR_ERROR] = "address error",
+ [RDMA_CM_EVENT_ROUTE_RESOLVED] = "route resolved ",
+ [RDMA_CM_EVENT_ROUTE_ERROR] = "route error",
+ [RDMA_CM_EVENT_CONNECT_REQUEST] = "connect request",
+ [RDMA_CM_EVENT_CONNECT_RESPONSE] = "connect response",
+ [RDMA_CM_EVENT_CONNECT_ERROR] = "connect error",
+ [RDMA_CM_EVENT_UNREACHABLE] = "unreachable",
+ [RDMA_CM_EVENT_REJECTED] = "rejected",
+ [RDMA_CM_EVENT_ESTABLISHED] = "established",
+ [RDMA_CM_EVENT_DISCONNECTED] = "disconnected",
+ [RDMA_CM_EVENT_DEVICE_REMOVAL] = "device removal",
+ [RDMA_CM_EVENT_MULTICAST_JOIN] = "multicast join",
+ [RDMA_CM_EVENT_MULTICAST_ERROR] = "multicast error",
+ [RDMA_CM_EVENT_ADDR_CHANGE] = "address change",
+ [RDMA_CM_EVENT_TIMEWAIT_EXIT] = "timewait exit",
+};
+
+const char *__attribute_const__ rdma_event_msg(enum rdma_cm_event_type event)
+{
+ size_t index = event;
+
+ return (index < ARRAY_SIZE(cma_events) && cma_events[index]) ?
+ cma_events[index] : "unrecognized event";
+}
+EXPORT_SYMBOL(rdma_event_msg);
+
+static void cma_add_one(struct ib_device *device);
+static void cma_remove_one(struct ib_device *device, void *client_data);
+
+static struct ib_client cma_client = {
+ .name = "cma",
+ .add = cma_add_one,
+ .remove = cma_remove_one
+};
+
+static struct ib_sa_client sa_client;
+static struct rdma_addr_client addr_client;
+static LIST_HEAD(dev_list);
+static LIST_HEAD(listen_any_list);
+static DEFINE_MUTEX(lock);
+static struct workqueue_struct *cma_wq;
+
+struct cma_pernet {
+ struct idr tcp_ps;
+ struct idr udp_ps;
+ struct idr ipoib_ps;
+ struct idr ib_ps;
+};
+
+VNET_DEFINE(struct cma_pernet, cma_pernet);
+
+static struct cma_pernet *cma_pernet_ptr(struct vnet *vnet)
+{
+ struct cma_pernet *retval;
+
+ CURVNET_SET_QUIET(vnet);
+ retval = &VNET(cma_pernet);
+ CURVNET_RESTORE();
+
+ return (retval);
+}
+
+static struct idr *cma_pernet_idr(struct vnet *net, enum rdma_port_space ps)
+{
+ struct cma_pernet *pernet = cma_pernet_ptr(net);
+
+ switch (ps) {
+ case RDMA_PS_TCP:
+ return &pernet->tcp_ps;
+ case RDMA_PS_UDP:
+ return &pernet->udp_ps;
+ case RDMA_PS_IPOIB:
+ return &pernet->ipoib_ps;
+ case RDMA_PS_IB:
+ return &pernet->ib_ps;
+ default:
+ return NULL;
+ }
+}
+
+struct cma_device {
+ struct list_head list;
+ struct ib_device *device;
+ struct completion comp;
+ atomic_t refcount;
+ struct list_head id_list;
+ struct sysctl_ctx_list sysctl_ctx;
+ enum ib_gid_type *default_gid_type;
+};
+
+struct rdma_bind_list {
+ enum rdma_port_space ps;
+ struct hlist_head owners;
+ unsigned short port;
+};
+
+struct class_port_info_context {
+ struct ib_class_port_info *class_port_info;
+ struct ib_device *device;
+ struct completion done;
+ struct ib_sa_query *sa_query;
+ u8 port_num;
+};
+
+static int cma_ps_alloc(struct vnet *vnet, enum rdma_port_space ps,
+ struct rdma_bind_list *bind_list, int snum)
+{
+ struct idr *idr = cma_pernet_idr(vnet, ps);
+
+ return idr_alloc(idr, bind_list, snum, snum + 1, GFP_KERNEL);
+}
+
+static struct rdma_bind_list *cma_ps_find(struct vnet *net,
+ enum rdma_port_space ps, int snum)
+{
+ struct idr *idr = cma_pernet_idr(net, ps);
+
+ return idr_find(idr, snum);
+}
+
+static void cma_ps_remove(struct vnet *net, enum rdma_port_space ps, int snum)
+{
+ struct idr *idr = cma_pernet_idr(net, ps);
+
+ idr_remove(idr, snum);
+}
+
+enum {
+ CMA_OPTION_AFONLY,
+};
+
+void cma_ref_dev(struct cma_device *cma_dev)
+{
+ atomic_inc(&cma_dev->refcount);
+}
+
+struct cma_device *cma_enum_devices_by_ibdev(cma_device_filter filter,
+ void *cookie)
+{
+ struct cma_device *cma_dev;
+ struct cma_device *found_cma_dev = NULL;
+
+ mutex_lock(&lock);
+
+ list_for_each_entry(cma_dev, &dev_list, list)
+ if (filter(cma_dev->device, cookie)) {
+ found_cma_dev = cma_dev;
+ break;
+ }
+
+ if (found_cma_dev)
+ cma_ref_dev(found_cma_dev);
+ mutex_unlock(&lock);
+ return found_cma_dev;
+}
+
+int cma_get_default_gid_type(struct cma_device *cma_dev,
+ unsigned int port)
+{
+ if (port < rdma_start_port(cma_dev->device) ||
+ port > rdma_end_port(cma_dev->device))
+ return -EINVAL;
+
+ return cma_dev->default_gid_type[port - rdma_start_port(cma_dev->device)];
+}
+
+int cma_set_default_gid_type(struct cma_device *cma_dev,
+ unsigned int port,
+ enum ib_gid_type default_gid_type)
+{
+ unsigned long supported_gids;
+
+ if (port < rdma_start_port(cma_dev->device) ||
+ port > rdma_end_port(cma_dev->device))
+ return -EINVAL;
+
+ supported_gids = roce_gid_type_mask_support(cma_dev->device, port);
+
+ if (!(supported_gids & 1 << default_gid_type))
+ return -EINVAL;
+
+ cma_dev->default_gid_type[port - rdma_start_port(cma_dev->device)] =
+ default_gid_type;
+
+ return 0;
+}
+
+struct ib_device *cma_get_ib_dev(struct cma_device *cma_dev)
+{
+ return cma_dev->device;
+}
+
+/*
+ * Device removal can occur at anytime, so we need extra handling to
+ * serialize notifying the user of device removal with other callbacks.
+ * We do this by disabling removal notification while a callback is in process,
+ * and reporting it after the callback completes.
+ */
+struct rdma_id_private {
+ struct rdma_cm_id id;
+
+ struct rdma_bind_list *bind_list;
+ struct hlist_node node;
+ struct list_head list; /* listen_any_list or cma_device.list */
+ struct list_head listen_list; /* per device listens */
+ struct cma_device *cma_dev;
+ struct list_head mc_list;
+
+ int internal_id;
+ enum rdma_cm_state state;
+ spinlock_t lock;
+ struct mutex qp_mutex;
+
+ struct completion comp;
+ atomic_t refcount;
+ struct mutex handler_mutex;
+
+ int backlog;
+ int timeout_ms;
+ struct ib_sa_query *query;
+ int query_id;
+ union {
+ struct ib_cm_id *ib;
+ struct iw_cm_id *iw;
+ } cm_id;
+
+ u32 seq_num;
+ u32 qkey;
+ u32 qp_num;
+ pid_t owner;
+ u32 options;
+ u8 srq;
+ u8 tos;
+ u8 reuseaddr;
+ u8 afonly;
+ enum ib_gid_type gid_type;
+};
+
+struct cma_multicast {
+ struct rdma_id_private *id_priv;
+ union {
+ struct ib_sa_multicast *ib;
+ } multicast;
+ struct list_head list;
+ void *context;
+ struct sockaddr_storage addr;
+ struct kref mcref;
+ bool igmp_joined;
+ u8 join_state;
+};
+
+struct cma_work {
+ struct work_struct work;
+ struct rdma_id_private *id;
+ enum rdma_cm_state old_state;
+ enum rdma_cm_state new_state;
+ struct rdma_cm_event event;
+};
+
+struct cma_ndev_work {
+ struct work_struct work;
+ struct rdma_id_private *id;
+ struct rdma_cm_event event;
+};
+
+struct iboe_mcast_work {
+ struct work_struct work;
+ struct rdma_id_private *id;
+ struct cma_multicast *mc;
+};
+
+union cma_ip_addr {
+ struct in6_addr ip6;
+ struct {
+ __be32 pad[3];
+ __be32 addr;
+ } ip4;
+};
+
+struct cma_hdr {
+ u8 cma_version;
+ u8 ip_version; /* IP version: 7:4 */
+ __be16 port;
+ union cma_ip_addr src_addr;
+ union cma_ip_addr dst_addr;
+};
+
+#define CMA_VERSION 0x00
+
+struct cma_req_info {
+ struct ib_device *device;
+ int port;
+ union ib_gid local_gid;
+ __be64 service_id;
+ u16 pkey;
+ bool has_gid:1;
+};
+
+static int cma_comp(struct rdma_id_private *id_priv, enum rdma_cm_state comp)
+{
+ unsigned long flags;
+ int ret;
+
+ spin_lock_irqsave(&id_priv->lock, flags);
+ ret = (id_priv->state == comp);
+ spin_unlock_irqrestore(&id_priv->lock, flags);
+ return ret;
+}
+
+static int cma_comp_exch(struct rdma_id_private *id_priv,
+ enum rdma_cm_state comp, enum rdma_cm_state exch)
+{
+ unsigned long flags;
+ int ret;
+
+ spin_lock_irqsave(&id_priv->lock, flags);
+ if ((ret = (id_priv->state == comp)))
+ id_priv->state = exch;
+ spin_unlock_irqrestore(&id_priv->lock, flags);
+ return ret;
+}
+
+static enum rdma_cm_state cma_exch(struct rdma_id_private *id_priv,
+ enum rdma_cm_state exch)
+{
+ unsigned long flags;
+ enum rdma_cm_state old;
+
+ spin_lock_irqsave(&id_priv->lock, flags);
+ old = id_priv->state;
+ id_priv->state = exch;
+ spin_unlock_irqrestore(&id_priv->lock, flags);
+ return old;
+}
+
+static inline u8 cma_get_ip_ver(const struct cma_hdr *hdr)
+{
+ return hdr->ip_version >> 4;
+}
+
+static inline void cma_set_ip_ver(struct cma_hdr *hdr, u8 ip_ver)
+{
+ hdr->ip_version = (ip_ver << 4) | (hdr->ip_version & 0xF);
+}
+
+static void _cma_attach_to_dev(struct rdma_id_private *id_priv,
+ struct cma_device *cma_dev)
+{
+ cma_ref_dev(cma_dev);
+ id_priv->cma_dev = cma_dev;
+ id_priv->gid_type = 0;
+ id_priv->id.device = cma_dev->device;
+ id_priv->id.route.addr.dev_addr.transport =
+ rdma_node_get_transport(cma_dev->device->node_type);
+ list_add_tail(&id_priv->list, &cma_dev->id_list);
+}
+
+static void cma_attach_to_dev(struct rdma_id_private *id_priv,
+ struct cma_device *cma_dev)
+{
+ _cma_attach_to_dev(id_priv, cma_dev);
+ id_priv->gid_type =
+ cma_dev->default_gid_type[id_priv->id.port_num -
+ rdma_start_port(cma_dev->device)];
+}
+
+void cma_deref_dev(struct cma_device *cma_dev)
+{
+ if (atomic_dec_and_test(&cma_dev->refcount))
+ complete(&cma_dev->comp);
+}
+
+static inline void release_mc(struct kref *kref)
+{
+ struct cma_multicast *mc = container_of(kref, struct cma_multicast, mcref);
+
+ kfree(mc->multicast.ib);
+ kfree(mc);
+}
+
+static void cma_release_dev(struct rdma_id_private *id_priv)
+{
+ mutex_lock(&lock);
+ list_del(&id_priv->list);
+ cma_deref_dev(id_priv->cma_dev);
+ id_priv->cma_dev = NULL;
+ mutex_unlock(&lock);
+}
+
+static inline struct sockaddr *cma_src_addr(struct rdma_id_private *id_priv)
+{
+ return (struct sockaddr *) &id_priv->id.route.addr.src_addr;
+}
+
+static inline struct sockaddr *cma_dst_addr(struct rdma_id_private *id_priv)
+{
+ return (struct sockaddr *) &id_priv->id.route.addr.dst_addr;
+}
+
+static inline unsigned short cma_family(struct rdma_id_private *id_priv)
+{
+ return id_priv->id.route.addr.src_addr.ss_family;
+}
+
+static int cma_set_qkey(struct rdma_id_private *id_priv, u32 qkey)
+{
+ struct ib_sa_mcmember_rec rec;
+ int ret = 0;
+
+ if (id_priv->qkey) {
+ if (qkey && id_priv->qkey != qkey)
+ return -EINVAL;
+ return 0;
+ }
+
+ if (qkey) {
+ id_priv->qkey = qkey;
+ return 0;
+ }
+
+ switch (id_priv->id.ps) {
+ case RDMA_PS_UDP:
+ case RDMA_PS_IB:
+ id_priv->qkey = RDMA_UDP_QKEY;
+ break;
+ case RDMA_PS_IPOIB:
+ ib_addr_get_mgid(&id_priv->id.route.addr.dev_addr, &rec.mgid);
+ ret = ib_sa_get_mcmember_rec(id_priv->id.device,
+ id_priv->id.port_num, &rec.mgid,
+ &rec);
+ if (!ret)
+ id_priv->qkey = be32_to_cpu(rec.qkey);
+ break;
+ default:
+ break;
+ }
+ return ret;
+}
+
+static void cma_translate_ib(struct sockaddr_ib *sib, struct rdma_dev_addr *dev_addr)
+{
+ dev_addr->dev_type = ARPHRD_INFINIBAND;
+ rdma_addr_set_sgid(dev_addr, (union ib_gid *) &sib->sib_addr);
+ ib_addr_set_pkey(dev_addr, ntohs(sib->sib_pkey));
+}
+
+static int cma_translate_addr(struct sockaddr *addr, struct rdma_dev_addr *dev_addr)
+{
+ int ret;
+
+ if (addr->sa_family != AF_IB) {
+ ret = rdma_translate_ip(addr, dev_addr, NULL);
+ } else {
+ cma_translate_ib((struct sockaddr_ib *) addr, dev_addr);
+ ret = 0;
+ }
+
+ return ret;
+}
+
+static inline int cma_validate_port(struct ib_device *device, u8 port,
+ enum ib_gid_type gid_type,
+ union ib_gid *gid, int dev_type,
+ struct vnet *net,
+ int bound_if_index)
+{
+ int ret = -ENODEV;
+ struct net_device *ndev = NULL;
+
+ if ((dev_type == ARPHRD_INFINIBAND) && !rdma_protocol_ib(device, port))
+ return ret;
+
+ if ((dev_type != ARPHRD_INFINIBAND) && rdma_protocol_ib(device, port))
+ return ret;
+
+ if (dev_type == ARPHRD_ETHER && rdma_protocol_roce(device, port)) {
+ ndev = dev_get_by_index(net, bound_if_index);
+ if (ndev && ndev->if_flags & IFF_LOOPBACK) {
+ pr_info("detected loopback device\n");
+ dev_put(ndev);
+
+ if (!device->get_netdev)
+ return -EOPNOTSUPP;
+
+ ndev = device->get_netdev(device, port);
+ if (!ndev)
+ return -ENODEV;
+ }
+ } else {
+ gid_type = IB_GID_TYPE_IB;
+ }
+
+ ret = ib_find_cached_gid_by_port(device, gid, gid_type, port,
+ ndev, NULL);
+
+ if (ndev)
+ dev_put(ndev);
+
+ return ret;
+}
+
+static int cma_acquire_dev(struct rdma_id_private *id_priv,
+ struct rdma_id_private *listen_id_priv)
+{
+ struct rdma_dev_addr *dev_addr = &id_priv->id.route.addr.dev_addr;
+ struct cma_device *cma_dev;
+ union ib_gid gid, iboe_gid, *gidp;
+ int ret = -ENODEV;
+ u8 port;
+
+ if (dev_addr->dev_type != ARPHRD_INFINIBAND &&
+ id_priv->id.ps == RDMA_PS_IPOIB)
+ return -EINVAL;
+
+ mutex_lock(&lock);
+ rdma_ip2gid((struct sockaddr *)&id_priv->id.route.addr.src_addr,
+ &iboe_gid);
+
+ memcpy(&gid, dev_addr->src_dev_addr +
+ rdma_addr_gid_offset(dev_addr), sizeof gid);
+
+ if (listen_id_priv) {
+ cma_dev = listen_id_priv->cma_dev;
+ port = listen_id_priv->id.port_num;
+ gidp = rdma_protocol_roce(cma_dev->device, port) ?
+ &iboe_gid : &gid;
+
+ ret = cma_validate_port(cma_dev->device, port,
+ rdma_protocol_ib(cma_dev->device, port) ?
+ IB_GID_TYPE_IB :
+ listen_id_priv->gid_type, gidp,
+ dev_addr->dev_type,
+ dev_addr->net,
+ dev_addr->bound_dev_if);
+ if (!ret) {
+ id_priv->id.port_num = port;
+ goto out;
+ }
+ }
+
+ list_for_each_entry(cma_dev, &dev_list, list) {
+ for (port = 1; port <= cma_dev->device->phys_port_cnt; ++port) {
+ if (listen_id_priv &&
+ listen_id_priv->cma_dev == cma_dev &&
+ listen_id_priv->id.port_num == port)
+ continue;
+
+ gidp = rdma_protocol_roce(cma_dev->device, port) ?
+ &iboe_gid : &gid;
+
+ ret = cma_validate_port(cma_dev->device, port,
+ rdma_protocol_ib(cma_dev->device, port) ?
+ IB_GID_TYPE_IB :
+ cma_dev->default_gid_type[port - 1],
+ gidp, dev_addr->dev_type,
+ dev_addr->net,
+ dev_addr->bound_dev_if);
+ if (!ret) {
+ id_priv->id.port_num = port;
+ goto out;
+ }
+ }
+ }
+
+out:
+ if (!ret)
+ cma_attach_to_dev(id_priv, cma_dev);
+
+ mutex_unlock(&lock);
+ return ret;
+}
+
+/*
+ * Select the source IB device and address to reach the destination IB address.
+ */
+static int cma_resolve_ib_dev(struct rdma_id_private *id_priv)
+{
+ struct cma_device *cma_dev, *cur_dev;
+ struct sockaddr_ib *addr;
+ union ib_gid gid, sgid, *dgid;
+ u16 pkey, index;
+ u8 p;
+ int i;
+
+ cma_dev = NULL;
+ addr = (struct sockaddr_ib *) cma_dst_addr(id_priv);
+ dgid = (union ib_gid *) &addr->sib_addr;
+ pkey = ntohs(addr->sib_pkey);
+
+ list_for_each_entry(cur_dev, &dev_list, list) {
+ for (p = 1; p <= cur_dev->device->phys_port_cnt; ++p) {
+ if (!rdma_cap_af_ib(cur_dev->device, p))
+ continue;
+
+ if (ib_find_cached_pkey(cur_dev->device, p, pkey, &index))
+ continue;
+
+ for (i = 0; !ib_get_cached_gid(cur_dev->device, p, i,
+ &gid, NULL);
+ i++) {
+ if (!memcmp(&gid, dgid, sizeof(gid))) {
+ cma_dev = cur_dev;
+ sgid = gid;
+ id_priv->id.port_num = p;
+ goto found;
+ }
+
+ if (!cma_dev && (gid.global.subnet_prefix ==
+ dgid->global.subnet_prefix)) {
+ cma_dev = cur_dev;
+ sgid = gid;
+ id_priv->id.port_num = p;
+ }
+ }
+ }
+ }
+
+ if (!cma_dev)
+ return -ENODEV;
+
+found:
+ cma_attach_to_dev(id_priv, cma_dev);
+ addr = (struct sockaddr_ib *) cma_src_addr(id_priv);
+ memcpy(&addr->sib_addr, &sgid, sizeof sgid);
+ cma_translate_ib(addr, &id_priv->id.route.addr.dev_addr);
+ return 0;
+}
+
+static void cma_deref_id(struct rdma_id_private *id_priv)
+{
+ if (atomic_dec_and_test(&id_priv->refcount))
+ complete(&id_priv->comp);
+}
+
+struct rdma_cm_id *rdma_create_id(struct vnet *net,
+ rdma_cm_event_handler event_handler,
+ void *context, enum rdma_port_space ps,
+ enum ib_qp_type qp_type)
+{
+ struct rdma_id_private *id_priv;
+
+ id_priv = kzalloc(sizeof *id_priv, GFP_KERNEL);
+ if (!id_priv)
+ return ERR_PTR(-ENOMEM);
+
+ id_priv->owner = task_pid_nr(current);
+ id_priv->state = RDMA_CM_IDLE;
+ id_priv->id.context = context;
+ id_priv->id.event_handler = event_handler;
+ id_priv->id.ps = ps;
+ id_priv->id.qp_type = qp_type;
+ spin_lock_init(&id_priv->lock);
+ mutex_init(&id_priv->qp_mutex);
+ init_completion(&id_priv->comp);
+ atomic_set(&id_priv->refcount, 1);
+ mutex_init(&id_priv->handler_mutex);
+ INIT_LIST_HEAD(&id_priv->listen_list);
+ INIT_LIST_HEAD(&id_priv->mc_list);
+ get_random_bytes(&id_priv->seq_num, sizeof id_priv->seq_num);
+ id_priv->id.route.addr.dev_addr.net = TD_TO_VNET(curthread);
+
+ return &id_priv->id;
+}
+EXPORT_SYMBOL(rdma_create_id);
+
+static int cma_init_ud_qp(struct rdma_id_private *id_priv, struct ib_qp *qp)
+{
+ struct ib_qp_attr qp_attr;
+ int qp_attr_mask, ret;
+
+ qp_attr.qp_state = IB_QPS_INIT;
+ ret = rdma_init_qp_attr(&id_priv->id, &qp_attr, &qp_attr_mask);
+ if (ret)
+ return ret;
+
+ ret = ib_modify_qp(qp, &qp_attr, qp_attr_mask);
+ if (ret)
+ return ret;
+
+ qp_attr.qp_state = IB_QPS_RTR;
+ ret = ib_modify_qp(qp, &qp_attr, IB_QP_STATE);
+ if (ret)
+ return ret;
+
+ qp_attr.qp_state = IB_QPS_RTS;
+ qp_attr.sq_psn = 0;
+ ret = ib_modify_qp(qp, &qp_attr, IB_QP_STATE | IB_QP_SQ_PSN);
+
+ return ret;
+}
+
+static int cma_init_conn_qp(struct rdma_id_private *id_priv, struct ib_qp *qp)
+{
+ struct ib_qp_attr qp_attr;
+ int qp_attr_mask, ret;
+
+ qp_attr.qp_state = IB_QPS_INIT;
+ ret = rdma_init_qp_attr(&id_priv->id, &qp_attr, &qp_attr_mask);
+ if (ret)
+ return ret;
+
+ return ib_modify_qp(qp, &qp_attr, qp_attr_mask);
+}
+
+int rdma_create_qp(struct rdma_cm_id *id, struct ib_pd *pd,
+ struct ib_qp_init_attr *qp_init_attr)
+{
+ struct rdma_id_private *id_priv;
+ struct ib_qp *qp;
+ int ret;
+
+ id_priv = container_of(id, struct rdma_id_private, id);
+ if (id->device != pd->device)
+ return -EINVAL;
+
+ qp_init_attr->port_num = id->port_num;
+ qp = ib_create_qp(pd, qp_init_attr);
+ if (IS_ERR(qp))
+ return PTR_ERR(qp);
+
+ if (id->qp_type == IB_QPT_UD)
+ ret = cma_init_ud_qp(id_priv, qp);
+ else
+ ret = cma_init_conn_qp(id_priv, qp);
+ if (ret)
+ goto err;
+
+ id->qp = qp;
+ id_priv->qp_num = qp->qp_num;
+ id_priv->srq = (qp->srq != NULL);
+ return 0;
+err:
+ ib_destroy_qp(qp);
+ return ret;
+}
+EXPORT_SYMBOL(rdma_create_qp);
+
+void rdma_destroy_qp(struct rdma_cm_id *id)
+{
+ struct rdma_id_private *id_priv;
+
+ id_priv = container_of(id, struct rdma_id_private, id);
+ mutex_lock(&id_priv->qp_mutex);
+ ib_destroy_qp(id_priv->id.qp);
+ id_priv->id.qp = NULL;
+ mutex_unlock(&id_priv->qp_mutex);
+}
+EXPORT_SYMBOL(rdma_destroy_qp);
+
+static int cma_modify_qp_rtr(struct rdma_id_private *id_priv,
+ struct rdma_conn_param *conn_param)
+{
+ struct ib_qp_attr qp_attr;
+ int qp_attr_mask, ret;
+ union ib_gid sgid;
+
+ mutex_lock(&id_priv->qp_mutex);
+ if (!id_priv->id.qp) {
+ ret = 0;
+ goto out;
+ }
+
+ /* Need to update QP attributes from default values. */
+ qp_attr.qp_state = IB_QPS_INIT;
+ ret = rdma_init_qp_attr(&id_priv->id, &qp_attr, &qp_attr_mask);
+ if (ret)
+ goto out;
+
+ ret = ib_modify_qp(id_priv->id.qp, &qp_attr, qp_attr_mask);
+ if (ret)
+ goto out;
+
+ qp_attr.qp_state = IB_QPS_RTR;
+ ret = rdma_init_qp_attr(&id_priv->id, &qp_attr, &qp_attr_mask);
+ if (ret)
+ goto out;
+
+ ret = ib_query_gid(id_priv->id.device, id_priv->id.port_num,
+ qp_attr.ah_attr.grh.sgid_index, &sgid, NULL);
+ if (ret)
+ goto out;
+
+ BUG_ON(id_priv->cma_dev->device != id_priv->id.device);
+
+ if (conn_param)
+ qp_attr.max_dest_rd_atomic = conn_param->responder_resources;
+ ret = ib_modify_qp(id_priv->id.qp, &qp_attr, qp_attr_mask);
+out:
+ mutex_unlock(&id_priv->qp_mutex);
+ return ret;
+}
+
+static int cma_modify_qp_rts(struct rdma_id_private *id_priv,
+ struct rdma_conn_param *conn_param)
+{
+ struct ib_qp_attr qp_attr;
+ int qp_attr_mask, ret;
+
+ mutex_lock(&id_priv->qp_mutex);
+ if (!id_priv->id.qp) {
+ ret = 0;
+ goto out;
+ }
+
+ qp_attr.qp_state = IB_QPS_RTS;
+ ret = rdma_init_qp_attr(&id_priv->id, &qp_attr, &qp_attr_mask);
+ if (ret)
+ goto out;
+
+ if (conn_param)
+ qp_attr.max_rd_atomic = conn_param->initiator_depth;
+ ret = ib_modify_qp(id_priv->id.qp, &qp_attr, qp_attr_mask);
+out:
+ mutex_unlock(&id_priv->qp_mutex);
+ return ret;
+}
+
+static int cma_modify_qp_err(struct rdma_id_private *id_priv)
+{
+ struct ib_qp_attr qp_attr;
+ int ret;
+
+ mutex_lock(&id_priv->qp_mutex);
+ if (!id_priv->id.qp) {
+ ret = 0;
+ goto out;
+ }
+
+ qp_attr.qp_state = IB_QPS_ERR;
+ ret = ib_modify_qp(id_priv->id.qp, &qp_attr, IB_QP_STATE);
+out:
+ mutex_unlock(&id_priv->qp_mutex);
+ return ret;
+}
+
+static int cma_ib_init_qp_attr(struct rdma_id_private *id_priv,
+ struct ib_qp_attr *qp_attr, int *qp_attr_mask)
+{
+ struct rdma_dev_addr *dev_addr = &id_priv->id.route.addr.dev_addr;
+ int ret;
+ u16 pkey;
+
+ if (rdma_cap_eth_ah(id_priv->id.device, id_priv->id.port_num))
+ pkey = 0xffff;
+ else
+ pkey = ib_addr_get_pkey(dev_addr);
+
+ ret = ib_find_cached_pkey(id_priv->id.device, id_priv->id.port_num,
+ pkey, &qp_attr->pkey_index);
+ if (ret)
+ return ret;
+
+ qp_attr->port_num = id_priv->id.port_num;
+ *qp_attr_mask = IB_QP_STATE | IB_QP_PKEY_INDEX | IB_QP_PORT;
+
+ if (id_priv->id.qp_type == IB_QPT_UD) {
+ ret = cma_set_qkey(id_priv, 0);
+ if (ret)
+ return ret;
+
+ qp_attr->qkey = id_priv->qkey;
+ *qp_attr_mask |= IB_QP_QKEY;
+ } else {
+ qp_attr->qp_access_flags = 0;
+ *qp_attr_mask |= IB_QP_ACCESS_FLAGS;
+ }
+ return 0;
+}
+
+int rdma_init_qp_attr(struct rdma_cm_id *id, struct ib_qp_attr *qp_attr,
+ int *qp_attr_mask)
+{
+ struct rdma_id_private *id_priv;
+ int ret = 0;
+
+ id_priv = container_of(id, struct rdma_id_private, id);
+ if (rdma_cap_ib_cm(id->device, id->port_num)) {
+ if (!id_priv->cm_id.ib || (id_priv->id.qp_type == IB_QPT_UD))
+ ret = cma_ib_init_qp_attr(id_priv, qp_attr, qp_attr_mask);
+ else
+ ret = ib_cm_init_qp_attr(id_priv->cm_id.ib, qp_attr,
+ qp_attr_mask);
+
+ if (qp_attr->qp_state == IB_QPS_RTR)
+ qp_attr->rq_psn = id_priv->seq_num;
+ } else if (rdma_cap_iw_cm(id->device, id->port_num)) {
+ if (!id_priv->cm_id.iw) {
+ qp_attr->qp_access_flags = 0;
+ *qp_attr_mask = IB_QP_STATE | IB_QP_ACCESS_FLAGS;
+ } else
+ ret = iw_cm_init_qp_attr(id_priv->cm_id.iw, qp_attr,
+ qp_attr_mask);
+ } else
+ ret = -ENOSYS;
+
+ return ret;
+}
+EXPORT_SYMBOL(rdma_init_qp_attr);
+
+static inline int cma_zero_addr(struct sockaddr *addr)
+{
+ switch (addr->sa_family) {
+ case AF_INET:
+ return ipv4_is_zeronet(((struct sockaddr_in *)addr)->sin_addr.s_addr);
+ case AF_INET6:
+ return ipv6_addr_any(&((struct sockaddr_in6 *) addr)->sin6_addr);
+ case AF_IB:
+ return ib_addr_any(&((struct sockaddr_ib *) addr)->sib_addr);
+ default:
+ return 0;
+ }
+}
+
+static inline int cma_loopback_addr(struct sockaddr *addr)
+{
+ switch (addr->sa_family) {
+ case AF_INET:
+ return ipv4_is_loopback(((struct sockaddr_in *) addr)->sin_addr.s_addr);
+ case AF_INET6:
+ return ipv6_addr_loopback(&((struct sockaddr_in6 *) addr)->sin6_addr);
+ case AF_IB:
+ return ib_addr_loopback(&((struct sockaddr_ib *) addr)->sib_addr);
+ default:
+ return 0;
+ }
+}
+
+static inline int cma_any_addr(struct sockaddr *addr)
+{
+ return cma_zero_addr(addr) || cma_loopback_addr(addr);
+}
+
+static int cma_addr_cmp(struct sockaddr *src, struct sockaddr *dst)
+{
+ if (src->sa_family != dst->sa_family)
+ return -1;
+
+ switch (src->sa_family) {
+ case AF_INET:
+ return ((struct sockaddr_in *) src)->sin_addr.s_addr !=
+ ((struct sockaddr_in *) dst)->sin_addr.s_addr;
+ case AF_INET6:
+ return ipv6_addr_cmp(&((struct sockaddr_in6 *) src)->sin6_addr,
+ &((struct sockaddr_in6 *) dst)->sin6_addr);
+ default:
+ return ib_addr_cmp(&((struct sockaddr_ib *) src)->sib_addr,
+ &((struct sockaddr_ib *) dst)->sib_addr);
+ }
+}
+
+static __be16 cma_port(struct sockaddr *addr)
+{
+ struct sockaddr_ib *sib;
+
+ switch (addr->sa_family) {
+ case AF_INET:
+ return ((struct sockaddr_in *) addr)->sin_port;
+ case AF_INET6:
+ return ((struct sockaddr_in6 *) addr)->sin6_port;
+ case AF_IB:
+ sib = (struct sockaddr_ib *) addr;
+ return htons((u16) (be64_to_cpu(sib->sib_sid) &
+ be64_to_cpu(sib->sib_sid_mask)));
+ default:
+ return 0;
+ }
+}
+
+static inline int cma_any_port(struct sockaddr *addr)
+{
+ return !cma_port(addr);
+}
+
+static void cma_save_ib_info(struct sockaddr *src_addr,
+ struct sockaddr *dst_addr,
+ struct rdma_cm_id *listen_id,
+ struct ib_sa_path_rec *path)
+{
+ struct sockaddr_ib *listen_ib, *ib;
+
+ listen_ib = (struct sockaddr_ib *) &listen_id->route.addr.src_addr;
+ if (src_addr) {
+ ib = (struct sockaddr_ib *)src_addr;
+ ib->sib_family = AF_IB;
+ if (path) {
+ ib->sib_pkey = path->pkey;
+ ib->sib_flowinfo = path->flow_label;
+ memcpy(&ib->sib_addr, &path->sgid, 16);
+ ib->sib_sid = path->service_id;
+ ib->sib_scope_id = 0;
+ } else {
+ ib->sib_pkey = listen_ib->sib_pkey;
+ ib->sib_flowinfo = listen_ib->sib_flowinfo;
+ ib->sib_addr = listen_ib->sib_addr;
+ ib->sib_sid = listen_ib->sib_sid;
+ ib->sib_scope_id = listen_ib->sib_scope_id;
+ }
+ ib->sib_sid_mask = cpu_to_be64(0xffffffffffffffffULL);
+ }
+ if (dst_addr) {
+ ib = (struct sockaddr_ib *)dst_addr;
+ ib->sib_family = AF_IB;
+ if (path) {
+ ib->sib_pkey = path->pkey;
+ ib->sib_flowinfo = path->flow_label;
+ memcpy(&ib->sib_addr, &path->dgid, 16);
+ }
+ }
+}
+
+static void cma_save_ip4_info(struct sockaddr_in *src_addr,
+ struct sockaddr_in *dst_addr,
+ struct cma_hdr *hdr,
+ __be16 local_port)
+{
+ if (src_addr) {
+ *src_addr = (struct sockaddr_in) {
+ .sin_len = sizeof(struct sockaddr_in),
+ .sin_family = AF_INET,
+ .sin_addr.s_addr = hdr->dst_addr.ip4.addr,
+ .sin_port = local_port,
+ };
+ }
+
+ if (dst_addr) {
+ *dst_addr = (struct sockaddr_in) {
+ .sin_len = sizeof(struct sockaddr_in),
+ .sin_family = AF_INET,
+ .sin_addr.s_addr = hdr->src_addr.ip4.addr,
+ .sin_port = hdr->port,
+ };
+ }
+}
+
+static void cma_save_ip6_info(struct sockaddr_in6 *src_addr,
+ struct sockaddr_in6 *dst_addr,
+ struct cma_hdr *hdr,
+ __be16 local_port)
+{
+ if (src_addr) {
+ *src_addr = (struct sockaddr_in6) {
+ .sin6_len = sizeof(struct sockaddr_in6),
+ .sin6_family = AF_INET6,
+ .sin6_addr = hdr->dst_addr.ip6,
+ .sin6_port = local_port,
+ };
+ }
+
+ if (dst_addr) {
+ *dst_addr = (struct sockaddr_in6) {
+ .sin6_len = sizeof(struct sockaddr_in6),
+ .sin6_family = AF_INET6,
+ .sin6_addr = hdr->src_addr.ip6,
+ .sin6_port = hdr->port,
+ };
+ }
+}
+
+static u16 cma_port_from_service_id(__be64 service_id)
+{
+ return (u16)be64_to_cpu(service_id);
+}
+
+static int cma_save_ip_info(struct sockaddr *src_addr,
+ struct sockaddr *dst_addr,
+ struct ib_cm_event *ib_event,
+ __be64 service_id)
+{
+ struct cma_hdr *hdr;
+ __be16 port;
+
+ hdr = ib_event->private_data;
+ if (hdr->cma_version != CMA_VERSION)
+ return -EINVAL;
+
+ port = htons(cma_port_from_service_id(service_id));
+
+ switch (cma_get_ip_ver(hdr)) {
+ case 4:
+ cma_save_ip4_info((struct sockaddr_in *)src_addr,
+ (struct sockaddr_in *)dst_addr, hdr, port);
+ break;
+ case 6:
+ cma_save_ip6_info((struct sockaddr_in6 *)src_addr,
+ (struct sockaddr_in6 *)dst_addr, hdr, port);
+ break;
+ default:
+ return -EAFNOSUPPORT;
+ }
+
+ return 0;
+}
+
+static int cma_save_net_info(struct sockaddr *src_addr,
+ struct sockaddr *dst_addr,
+ struct rdma_cm_id *listen_id,
+ struct ib_cm_event *ib_event,
+ sa_family_t sa_family, __be64 service_id)
+{
+ if (sa_family == AF_IB) {
+ if (ib_event->event == IB_CM_REQ_RECEIVED)
+ cma_save_ib_info(src_addr, dst_addr, listen_id,
+ ib_event->param.req_rcvd.primary_path);
+ else if (ib_event->event == IB_CM_SIDR_REQ_RECEIVED)
+ cma_save_ib_info(src_addr, dst_addr, listen_id, NULL);
+ return 0;
+ }
+
+ return cma_save_ip_info(src_addr, dst_addr, ib_event, service_id);
+}
+
+static int cma_save_req_info(const struct ib_cm_event *ib_event,
+ struct cma_req_info *req)
+{
+ const struct ib_cm_req_event_param *req_param =
+ &ib_event->param.req_rcvd;
+ const struct ib_cm_sidr_req_event_param *sidr_param =
+ &ib_event->param.sidr_req_rcvd;
+
+ switch (ib_event->event) {
+ case IB_CM_REQ_RECEIVED:
+ req->device = req_param->listen_id->device;
+ req->port = req_param->port;
+ memcpy(&req->local_gid, &req_param->primary_path->sgid,
+ sizeof(req->local_gid));
+ req->has_gid = true;
+ req->service_id = req_param->primary_path->service_id;
+ req->pkey = be16_to_cpu(req_param->primary_path->pkey);
+ if (req->pkey != req_param->bth_pkey)
+ pr_warn_ratelimited("RDMA CMA: got different BTH P_Key (0x%x) and primary path P_Key (0x%x)\n"
+ "RDMA CMA: in the future this may cause the request to be dropped\n",
+ req_param->bth_pkey, req->pkey);
+ break;
+ case IB_CM_SIDR_REQ_RECEIVED:
+ req->device = sidr_param->listen_id->device;
+ req->port = sidr_param->port;
+ req->has_gid = false;
+ req->service_id = sidr_param->service_id;
+ req->pkey = sidr_param->pkey;
+ if (req->pkey != sidr_param->bth_pkey)
+ pr_warn_ratelimited("RDMA CMA: got different BTH P_Key (0x%x) and SIDR request payload P_Key (0x%x)\n"
+ "RDMA CMA: in the future this may cause the request to be dropped\n",
+ sidr_param->bth_pkey, req->pkey);
+ break;
+ default:
+ return -EINVAL;
+ }
+
+ return 0;
+}
+
+static bool validate_ipv4_net_dev(struct net_device *net_dev,
+ const struct sockaddr_in *dst_addr,
+ const struct sockaddr_in *src_addr)
+{
+#ifdef INET
+ struct sockaddr_in dst_tmp = *dst_addr;
+ __be32 daddr = dst_addr->sin_addr.s_addr,
+ saddr = src_addr->sin_addr.s_addr;
+ struct net_device *src_dev;
+ struct rtentry *rte;
+ bool ret;
+
+ if (ipv4_is_multicast(saddr) || ipv4_is_lbcast(saddr) ||
+ ipv4_is_lbcast(daddr) || ipv4_is_zeronet(saddr) ||
+ ipv4_is_zeronet(daddr) || ipv4_is_loopback(daddr) ||
+ ipv4_is_loopback(saddr))
+ return false;
+
+ src_dev = ip_dev_find(net_dev->if_vnet, saddr);
+ if (src_dev != net_dev) {
+ if (src_dev != NULL)
+ dev_put(src_dev);
+ return false;
+ }
+ dev_put(src_dev);
+
+ /*
+ * Make sure the socket address length field
+ * is set, else rtalloc1() will fail.
+ */
+ dst_tmp.sin_len = sizeof(dst_tmp);
+
+ CURVNET_SET(net_dev->if_vnet);
+ rte = rtalloc1((struct sockaddr *)&dst_tmp, 1, 0);
+ CURVNET_RESTORE();
+ if (rte != NULL) {
+ ret = (rte->rt_ifp == net_dev);
+ RTFREE_LOCKED(rte);
+ } else {
+ ret = false;
+ }
+ return ret;
+#else
+ return false;
+#endif
+}
+
+static bool validate_ipv6_net_dev(struct net_device *net_dev,
+ const struct sockaddr_in6 *dst_addr,
+ const struct sockaddr_in6 *src_addr)
+{
+#ifdef INET6
+ struct sockaddr_in6 dst_tmp = *dst_addr;
+ struct in6_addr in6_addr = src_addr->sin6_addr;
+ struct net_device *src_dev;
+ struct rtentry *rte;
+ bool ret;
+
+ src_dev = ip6_dev_find(net_dev->if_vnet, in6_addr);
+ if (src_dev != net_dev)
+ return false;
+
+ /*
+ * Make sure the socket address length field
+ * is set, else rtalloc1() will fail.
+ */
+ dst_tmp.sin6_len = sizeof(dst_tmp);
+
+ CURVNET_SET(net_dev->if_vnet);
+ rte = rtalloc1((struct sockaddr *)&dst_tmp, 1, 0);
+ CURVNET_RESTORE();
+ if (rte != NULL) {
+ ret = (rte->rt_ifp == net_dev);
+ RTFREE_LOCKED(rte);
+ } else {
+ ret = false;
+ }
+ return ret;
+#else
+ return false;
+#endif
+}
+
+static bool validate_net_dev(struct net_device *net_dev,
+ const struct sockaddr *daddr,
+ const struct sockaddr *saddr)
+{
+ const struct sockaddr_in *daddr4 = (const struct sockaddr_in *)daddr;
+ const struct sockaddr_in *saddr4 = (const struct sockaddr_in *)saddr;
+ const struct sockaddr_in6 *daddr6 = (const struct sockaddr_in6 *)daddr;
+ const struct sockaddr_in6 *saddr6 = (const struct sockaddr_in6 *)saddr;
+
+ switch (daddr->sa_family) {
+ case AF_INET:
+ return saddr->sa_family == AF_INET &&
+ validate_ipv4_net_dev(net_dev, daddr4, saddr4);
+
+ case AF_INET6:
+ return saddr->sa_family == AF_INET6 &&
+ validate_ipv6_net_dev(net_dev, daddr6, saddr6);
+
+ default:
+ return false;
+ }
+}
+
+static struct net_device *cma_get_net_dev(struct ib_cm_event *ib_event,
+ const struct cma_req_info *req)
+{
+ struct sockaddr_storage listen_addr_storage, src_addr_storage;
+ struct sockaddr *listen_addr = (struct sockaddr *)&listen_addr_storage,
+ *src_addr = (struct sockaddr *)&src_addr_storage;
+ struct net_device *net_dev;
+ const union ib_gid *gid = req->has_gid ? &req->local_gid : NULL;
+ int err;
+
+ err = cma_save_ip_info(listen_addr, src_addr, ib_event,
+ req->service_id);
+ if (err)
+ return ERR_PTR(err);
+
+ net_dev = ib_get_net_dev_by_params(req->device, req->port, req->pkey,
+ gid, listen_addr);
+ if (!net_dev)
+ return ERR_PTR(-ENODEV);
+
+ if (!validate_net_dev(net_dev, listen_addr, src_addr)) {
+ dev_put(net_dev);
+ return ERR_PTR(-EHOSTUNREACH);
+ }
+
+ return net_dev;
+}
+
+static enum rdma_port_space rdma_ps_from_service_id(__be64 service_id)
+{
+ return (be64_to_cpu(service_id) >> 16) & 0xffff;
+}
+
+static bool cma_match_private_data(struct rdma_id_private *id_priv,
+ const struct cma_hdr *hdr)
+{
+ struct sockaddr *addr = cma_src_addr(id_priv);
+ __be32 ip4_addr;
+ struct in6_addr ip6_addr;
+
+ if (cma_any_addr(addr) && !id_priv->afonly)
+ return true;
+
+ switch (addr->sa_family) {
+ case AF_INET:
+ ip4_addr = ((struct sockaddr_in *)addr)->sin_addr.s_addr;
+ if (cma_get_ip_ver(hdr) != 4)
+ return false;
+ if (!cma_any_addr(addr) &&
+ hdr->dst_addr.ip4.addr != ip4_addr)
+ return false;
+ break;
+ case AF_INET6:
+ ip6_addr = ((struct sockaddr_in6 *)addr)->sin6_addr;
+ if (cma_get_ip_ver(hdr) != 6)
+ return false;
+ if (!cma_any_addr(addr) &&
+ memcmp(&hdr->dst_addr.ip6, &ip6_addr, sizeof(ip6_addr)))
+ return false;
+ break;
+ case AF_IB:
+ return true;
+ default:
+ return false;
+ }
+
+ return true;
+}
+
+static bool cma_protocol_roce_dev_port(struct ib_device *device, int port_num)
+{
+ enum rdma_link_layer ll = rdma_port_get_link_layer(device, port_num);
+ enum rdma_transport_type transport =
+ rdma_node_get_transport(device->node_type);
+
+ return ll == IB_LINK_LAYER_ETHERNET && transport == RDMA_TRANSPORT_IB;
+}
+
+static bool cma_protocol_roce(const struct rdma_cm_id *id)
+{
+ struct ib_device *device = id->device;
+ const int port_num = id->port_num ?: rdma_start_port(device);
+
+ return cma_protocol_roce_dev_port(device, port_num);
+}
+
+static bool cma_match_net_dev(const struct rdma_cm_id *id,
+ const struct net_device *net_dev,
+ u8 port_num)
+{
+ const struct rdma_addr *addr = &id->route.addr;
+
+ if (!net_dev)
+ /* This request is an AF_IB request or a RoCE request */
+ return (!id->port_num || id->port_num == port_num) &&
+ (addr->src_addr.ss_family == AF_IB ||
+ cma_protocol_roce_dev_port(id->device, port_num));
+
+ return !addr->dev_addr.bound_dev_if ||
+ (net_eq(dev_net(net_dev), addr->dev_addr.net) &&
+ addr->dev_addr.bound_dev_if == net_dev->if_index);
+}
+
+static struct rdma_id_private *cma_find_listener(
+ const struct rdma_bind_list *bind_list,
+ const struct ib_cm_id *cm_id,
+ const struct ib_cm_event *ib_event,
+ const struct cma_req_info *req,
+ const struct net_device *net_dev)
+{
+ struct rdma_id_private *id_priv, *id_priv_dev;
+
+ if (!bind_list)
+ return ERR_PTR(-EINVAL);
+
+ hlist_for_each_entry(id_priv, &bind_list->owners, node) {
+ if (cma_match_private_data(id_priv, ib_event->private_data)) {
+ if (id_priv->id.device == cm_id->device &&
+ cma_match_net_dev(&id_priv->id, net_dev, req->port))
+ return id_priv;
+ list_for_each_entry(id_priv_dev,
+ &id_priv->listen_list,
+ listen_list) {
+ if (id_priv_dev->id.device == cm_id->device &&
+ cma_match_net_dev(&id_priv_dev->id, net_dev, req->port))
+ return id_priv_dev;
+ }
+ }
+ }
+
+ return ERR_PTR(-EINVAL);
+}
+
+static struct rdma_id_private *cma_id_from_event(struct ib_cm_id *cm_id,
+ struct ib_cm_event *ib_event,
+ struct net_device **net_dev)
+{
+ struct cma_req_info req;
+ struct rdma_bind_list *bind_list;
+ struct rdma_id_private *id_priv;
+ int err;
+
+ err = cma_save_req_info(ib_event, &req);
+ if (err)
+ return ERR_PTR(err);
+
+ *net_dev = cma_get_net_dev(ib_event, &req);
+ if (IS_ERR(*net_dev)) {
+ if (PTR_ERR(*net_dev) == -EAFNOSUPPORT) {
+ /* Assuming the protocol is AF_IB */
+ *net_dev = NULL;
+ } else if (cma_protocol_roce_dev_port(req.device, req.port)) {
+ /* TODO find the net dev matching the request parameters
+ * through the RoCE GID table */
+ *net_dev = NULL;
+ } else {
+ return ERR_CAST(*net_dev);
+ }
+ }
+
+ bind_list = cma_ps_find(*net_dev ? dev_net(*net_dev) : &init_net,
+ rdma_ps_from_service_id(req.service_id),
+ cma_port_from_service_id(req.service_id));
+ id_priv = cma_find_listener(bind_list, cm_id, ib_event, &req, *net_dev);
+ if (IS_ERR(id_priv) && *net_dev) {
+ dev_put(*net_dev);
+ *net_dev = NULL;
+ }
+
+ return id_priv;
+}
+
+static inline int cma_user_data_offset(struct rdma_id_private *id_priv)
+{
+ return cma_family(id_priv) == AF_IB ? 0 : sizeof(struct cma_hdr);
+}
+
+static void cma_cancel_route(struct rdma_id_private *id_priv)
+{
+ if (rdma_cap_ib_sa(id_priv->id.device, id_priv->id.port_num)) {
+ if (id_priv->query)
+ ib_sa_cancel_query(id_priv->query_id, id_priv->query);
+ }
+}
+
+static void cma_cancel_listens(struct rdma_id_private *id_priv)
+{
+ struct rdma_id_private *dev_id_priv;
+
+ /*
+ * Remove from listen_any_list to prevent added devices from spawning
+ * additional listen requests.
+ */
+ mutex_lock(&lock);
+ list_del(&id_priv->list);
+
+ while (!list_empty(&id_priv->listen_list)) {
+ dev_id_priv = list_entry(id_priv->listen_list.next,
+ struct rdma_id_private, listen_list);
+ /* sync with device removal to avoid duplicate destruction */
+ list_del_init(&dev_id_priv->list);
+ list_del(&dev_id_priv->listen_list);
+ mutex_unlock(&lock);
+
+ rdma_destroy_id(&dev_id_priv->id);
+ mutex_lock(&lock);
+ }
+ mutex_unlock(&lock);
+}
+
+static void cma_cancel_operation(struct rdma_id_private *id_priv,
+ enum rdma_cm_state state)
+{
+ switch (state) {
+ case RDMA_CM_ADDR_QUERY:
+ rdma_addr_cancel(&id_priv->id.route.addr.dev_addr);
+ break;
+ case RDMA_CM_ROUTE_QUERY:
+ cma_cancel_route(id_priv);
+ break;
+ case RDMA_CM_LISTEN:
+ if (cma_any_addr(cma_src_addr(id_priv)) && !id_priv->cma_dev)
+ cma_cancel_listens(id_priv);
+ break;
+ default:
+ break;
+ }
+}
+
+static void cma_release_port(struct rdma_id_private *id_priv)
+{
+ struct rdma_bind_list *bind_list = id_priv->bind_list;
+ struct vnet *net = id_priv->id.route.addr.dev_addr.net;
+
+ if (!bind_list)
+ return;
+
+ mutex_lock(&lock);
+ hlist_del(&id_priv->node);
+ if (hlist_empty(&bind_list->owners)) {
+ cma_ps_remove(net, bind_list->ps, bind_list->port);
+ kfree(bind_list);
+ }
+ mutex_unlock(&lock);
+}
+
+static void cma_leave_mc_groups(struct rdma_id_private *id_priv)
+{
+ struct cma_multicast *mc;
+
+ while (!list_empty(&id_priv->mc_list)) {
+ mc = container_of(id_priv->mc_list.next,
+ struct cma_multicast, list);
+ list_del(&mc->list);
+ if (rdma_cap_ib_mcast(id_priv->cma_dev->device,
+ id_priv->id.port_num)) {
+ ib_sa_free_multicast(mc->multicast.ib);
+ kfree(mc);
+ } else {
+ if (mc->igmp_joined) {
+ struct rdma_dev_addr *dev_addr =
+ &id_priv->id.route.addr.dev_addr;
+ struct net_device *ndev = NULL;
+
+ if (dev_addr->bound_dev_if)
+ ndev = dev_get_by_index(dev_addr->net,
+ dev_addr->bound_dev_if);
+ if (ndev) {
+ dev_put(ndev);
+ }
+ }
+ kref_put(&mc->mcref, release_mc);
+ }
+ }
+}
+
+void rdma_destroy_id(struct rdma_cm_id *id)
+{
+ struct rdma_id_private *id_priv;
+ enum rdma_cm_state state;
+
+ id_priv = container_of(id, struct rdma_id_private, id);
+ state = cma_exch(id_priv, RDMA_CM_DESTROYING);
+ cma_cancel_operation(id_priv, state);
+
+ /*
+ * Wait for any active callback to finish. New callbacks will find
+ * the id_priv state set to destroying and abort.
+ */
+ mutex_lock(&id_priv->handler_mutex);
+ mutex_unlock(&id_priv->handler_mutex);
+
+ if (id_priv->cma_dev) {
+ if (rdma_cap_ib_cm(id_priv->id.device, 1)) {
+ if (id_priv->cm_id.ib)
+ ib_destroy_cm_id(id_priv->cm_id.ib);
+ } else if (rdma_cap_iw_cm(id_priv->id.device, 1)) {
+ if (id_priv->cm_id.iw)
+ iw_destroy_cm_id(id_priv->cm_id.iw);
+ }
+ cma_leave_mc_groups(id_priv);
+ cma_release_dev(id_priv);
+ }
+
+ cma_release_port(id_priv);
+ cma_deref_id(id_priv);
+ wait_for_completion(&id_priv->comp);
+
+ if (id_priv->internal_id)
+ cma_deref_id(id_priv->id.context);
+
+ kfree(id_priv->id.route.path_rec);
+ kfree(id_priv);
+}
+EXPORT_SYMBOL(rdma_destroy_id);
+
+static int cma_rep_recv(struct rdma_id_private *id_priv)
+{
+ int ret;
+
+ ret = cma_modify_qp_rtr(id_priv, NULL);
+ if (ret)
+ goto reject;
+
+ ret = cma_modify_qp_rts(id_priv, NULL);
+ if (ret)
+ goto reject;
+
+ ret = ib_send_cm_rtu(id_priv->cm_id.ib, NULL, 0);
+ if (ret)
+ goto reject;
+
+ return 0;
+reject:
+ cma_modify_qp_err(id_priv);
+ ib_send_cm_rej(id_priv->cm_id.ib, IB_CM_REJ_CONSUMER_DEFINED,
+ NULL, 0, NULL, 0);
+ return ret;
+}
+
+static void cma_set_rep_event_data(struct rdma_cm_event *event,
+ struct ib_cm_rep_event_param *rep_data,
+ void *private_data)
+{
+ event->param.conn.private_data = private_data;
+ event->param.conn.private_data_len = IB_CM_REP_PRIVATE_DATA_SIZE;
+ event->param.conn.responder_resources = rep_data->responder_resources;
+ event->param.conn.initiator_depth = rep_data->initiator_depth;
+ event->param.conn.flow_control = rep_data->flow_control;
+ event->param.conn.rnr_retry_count = rep_data->rnr_retry_count;
+ event->param.conn.srq = rep_data->srq;
+ event->param.conn.qp_num = rep_data->remote_qpn;
+}
+
+static int cma_ib_handler(struct ib_cm_id *cm_id, struct ib_cm_event *ib_event)
+{
+ struct rdma_id_private *id_priv = cm_id->context;
+ struct rdma_cm_event event;
+ int ret = 0;
+
+ mutex_lock(&id_priv->handler_mutex);
+ if ((ib_event->event != IB_CM_TIMEWAIT_EXIT &&
+ id_priv->state != RDMA_CM_CONNECT) ||
+ (ib_event->event == IB_CM_TIMEWAIT_EXIT &&
+ id_priv->state != RDMA_CM_DISCONNECT))
+ goto out;
+
+ memset(&event, 0, sizeof event);
+ switch (ib_event->event) {
+ case IB_CM_REQ_ERROR:
+ case IB_CM_REP_ERROR:
+ event.event = RDMA_CM_EVENT_UNREACHABLE;
+ event.status = -ETIMEDOUT;
+ break;
+ case IB_CM_REP_RECEIVED:
+ if (id_priv->id.qp) {
+ event.status = cma_rep_recv(id_priv);
+ event.event = event.status ? RDMA_CM_EVENT_CONNECT_ERROR :
+ RDMA_CM_EVENT_ESTABLISHED;
+ } else {
+ event.event = RDMA_CM_EVENT_CONNECT_RESPONSE;
+ }
+ cma_set_rep_event_data(&event, &ib_event->param.rep_rcvd,
+ ib_event->private_data);
+ break;
+ case IB_CM_RTU_RECEIVED:
+ case IB_CM_USER_ESTABLISHED:
+ event.event = RDMA_CM_EVENT_ESTABLISHED;
+ break;
+ case IB_CM_DREQ_ERROR:
+ event.status = -ETIMEDOUT; /* fall through */
+ case IB_CM_DREQ_RECEIVED:
+ case IB_CM_DREP_RECEIVED:
+ if (!cma_comp_exch(id_priv, RDMA_CM_CONNECT,
+ RDMA_CM_DISCONNECT))
+ goto out;
+ event.event = RDMA_CM_EVENT_DISCONNECTED;
+ break;
+ case IB_CM_TIMEWAIT_EXIT:
+ event.event = RDMA_CM_EVENT_TIMEWAIT_EXIT;
+ break;
+ case IB_CM_MRA_RECEIVED:
+ /* ignore event */
+ goto out;
+ case IB_CM_REJ_RECEIVED:
+ cma_modify_qp_err(id_priv);
+ event.status = ib_event->param.rej_rcvd.reason;
+ event.event = RDMA_CM_EVENT_REJECTED;
+ event.param.conn.private_data = ib_event->private_data;
+ event.param.conn.private_data_len = IB_CM_REJ_PRIVATE_DATA_SIZE;
+ break;
+ default:
+ pr_err("RDMA CMA: unexpected IB CM event: %d\n",
+ ib_event->event);
+ goto out;
+ }
+
+ ret = id_priv->id.event_handler(&id_priv->id, &event);
+ if (ret) {
+ /* Destroy the CM ID by returning a non-zero value. */
+ id_priv->cm_id.ib = NULL;
+ cma_exch(id_priv, RDMA_CM_DESTROYING);
+ mutex_unlock(&id_priv->handler_mutex);
+ rdma_destroy_id(&id_priv->id);
+ return ret;
+ }
+out:
+ mutex_unlock(&id_priv->handler_mutex);
+ return ret;
+}
+
+static struct rdma_id_private *cma_new_conn_id(struct rdma_cm_id *listen_id,
+ struct ib_cm_event *ib_event,
+ struct net_device *net_dev)
+{
+ struct rdma_id_private *id_priv;
+ struct rdma_cm_id *id;
+ struct rdma_route *rt;
+ const sa_family_t ss_family = listen_id->route.addr.src_addr.ss_family;
+ const __be64 service_id =
+ ib_event->param.req_rcvd.primary_path->service_id;
+ int ret;
+
+ id = rdma_create_id(listen_id->route.addr.dev_addr.net,
+ listen_id->event_handler, listen_id->context,
+ listen_id->ps, ib_event->param.req_rcvd.qp_type);
+ if (IS_ERR(id))
+ return NULL;
+
+ id_priv = container_of(id, struct rdma_id_private, id);
+ if (cma_save_net_info((struct sockaddr *)&id->route.addr.src_addr,
+ (struct sockaddr *)&id->route.addr.dst_addr,
+ listen_id, ib_event, ss_family, service_id))
+ goto err;
+
+ rt = &id->route;
+ rt->num_paths = ib_event->param.req_rcvd.alternate_path ? 2 : 1;
+ rt->path_rec = kmalloc(sizeof *rt->path_rec * rt->num_paths,
+ GFP_KERNEL);
+ if (!rt->path_rec)
+ goto err;
+
+ rt->path_rec[0] = *ib_event->param.req_rcvd.primary_path;
+ if (rt->num_paths == 2)
+ rt->path_rec[1] = *ib_event->param.req_rcvd.alternate_path;
+
+ if (net_dev) {
+ ret = rdma_copy_addr(&rt->addr.dev_addr, net_dev, NULL);
+ if (ret)
+ goto err;
+ } else {
+ if (!cma_protocol_roce(listen_id) &&
+ cma_any_addr(cma_src_addr(id_priv))) {
+ rt->addr.dev_addr.dev_type = ARPHRD_INFINIBAND;
+ rdma_addr_set_sgid(&rt->addr.dev_addr, &rt->path_rec[0].sgid);
+ ib_addr_set_pkey(&rt->addr.dev_addr, be16_to_cpu(rt->path_rec[0].pkey));
+ } else if (!cma_any_addr(cma_src_addr(id_priv))) {
+ ret = cma_translate_addr(cma_src_addr(id_priv), &rt->addr.dev_addr);
+ if (ret)
+ goto err;
+ }
+ }
+ rdma_addr_set_dgid(&rt->addr.dev_addr, &rt->path_rec[0].dgid);
+
+ id_priv->state = RDMA_CM_CONNECT;
+ return id_priv;
+
+err:
+ rdma_destroy_id(id);
+ return NULL;
+}
+
+static struct rdma_id_private *cma_new_udp_id(struct rdma_cm_id *listen_id,
+ struct ib_cm_event *ib_event,
+ struct net_device *net_dev)
+{
+ struct rdma_id_private *id_priv;
+ struct rdma_cm_id *id;
+ const sa_family_t ss_family = listen_id->route.addr.src_addr.ss_family;
+ struct vnet *net = listen_id->route.addr.dev_addr.net;
+ int ret;
+
+ id = rdma_create_id(net, listen_id->event_handler, listen_id->context,
+ listen_id->ps, IB_QPT_UD);
+ if (IS_ERR(id))
+ return NULL;
+
+ id_priv = container_of(id, struct rdma_id_private, id);
+ if (cma_save_net_info((struct sockaddr *)&id->route.addr.src_addr,
+ (struct sockaddr *)&id->route.addr.dst_addr,
+ listen_id, ib_event, ss_family,
+ ib_event->param.sidr_req_rcvd.service_id))
+ goto err;
+
+ if (net_dev) {
+ ret = rdma_copy_addr(&id->route.addr.dev_addr, net_dev, NULL);
+ if (ret)
+ goto err;
+ } else {
+ if (!cma_any_addr(cma_src_addr(id_priv))) {
+ ret = cma_translate_addr(cma_src_addr(id_priv),
+ &id->route.addr.dev_addr);
+ if (ret)
+ goto err;
+ }
+ }
+
+ id_priv->state = RDMA_CM_CONNECT;
+ return id_priv;
+err:
+ rdma_destroy_id(id);
+ return NULL;
+}
+
+static void cma_set_req_event_data(struct rdma_cm_event *event,
+ struct ib_cm_req_event_param *req_data,
+ void *private_data, int offset)
+{
+ event->param.conn.private_data = (char *)private_data + offset;
+ event->param.conn.private_data_len = IB_CM_REQ_PRIVATE_DATA_SIZE - offset;
+ event->param.conn.responder_resources = req_data->responder_resources;
+ event->param.conn.initiator_depth = req_data->initiator_depth;
+ event->param.conn.flow_control = req_data->flow_control;
+ event->param.conn.retry_count = req_data->retry_count;
+ event->param.conn.rnr_retry_count = req_data->rnr_retry_count;
+ event->param.conn.srq = req_data->srq;
+ event->param.conn.qp_num = req_data->remote_qpn;
+}
+
+static int cma_check_req_qp_type(struct rdma_cm_id *id, struct ib_cm_event *ib_event)
+{
+ return (((ib_event->event == IB_CM_REQ_RECEIVED) &&
+ (ib_event->param.req_rcvd.qp_type == id->qp_type)) ||
+ ((ib_event->event == IB_CM_SIDR_REQ_RECEIVED) &&
+ (id->qp_type == IB_QPT_UD)) ||
+ (!id->qp_type));
+}
+
+static int cma_req_handler(struct ib_cm_id *cm_id, struct ib_cm_event *ib_event)
+{
+ struct rdma_id_private *listen_id, *conn_id = NULL;
+ struct rdma_cm_event event;
+ struct net_device *net_dev;
+ int offset, ret;
+
+ listen_id = cma_id_from_event(cm_id, ib_event, &net_dev);
+ if (IS_ERR(listen_id))
+ return PTR_ERR(listen_id);
+
+ if (!cma_check_req_qp_type(&listen_id->id, ib_event)) {
+ ret = -EINVAL;
+ goto net_dev_put;
+ }
+
+ mutex_lock(&listen_id->handler_mutex);
+ if (listen_id->state != RDMA_CM_LISTEN) {
+ ret = -ECONNABORTED;
+ goto err1;
+ }
+
+ memset(&event, 0, sizeof event);
+ offset = cma_user_data_offset(listen_id);
+ event.event = RDMA_CM_EVENT_CONNECT_REQUEST;
+ if (ib_event->event == IB_CM_SIDR_REQ_RECEIVED) {
+ conn_id = cma_new_udp_id(&listen_id->id, ib_event, net_dev);
+ event.param.ud.private_data = (char *)ib_event->private_data + offset;
+ event.param.ud.private_data_len =
+ IB_CM_SIDR_REQ_PRIVATE_DATA_SIZE - offset;
+ } else {
+ conn_id = cma_new_conn_id(&listen_id->id, ib_event, net_dev);
+ cma_set_req_event_data(&event, &ib_event->param.req_rcvd,
+ ib_event->private_data, offset);
+ }
+ if (!conn_id) {
+ ret = -ENOMEM;
+ goto err1;
+ }
+
+ mutex_lock_nested(&conn_id->handler_mutex, SINGLE_DEPTH_NESTING);
+ ret = cma_acquire_dev(conn_id, listen_id);
+ if (ret)
+ goto err2;
+
+ conn_id->cm_id.ib = cm_id;
+ cm_id->context = conn_id;
+ cm_id->cm_handler = cma_ib_handler;
+
+ /*
+ * Protect against the user destroying conn_id from another thread
+ * until we're done accessing it.
+ */
+ atomic_inc(&conn_id->refcount);
+ ret = conn_id->id.event_handler(&conn_id->id, &event);
+ if (ret)
+ goto err3;
+ /*
+ * Acquire mutex to prevent user executing rdma_destroy_id()
+ * while we're accessing the cm_id.
+ */
+ mutex_lock(&lock);
+ if (cma_comp(conn_id, RDMA_CM_CONNECT) &&
+ (conn_id->id.qp_type != IB_QPT_UD))
+ ib_send_cm_mra(cm_id, CMA_CM_MRA_SETTING, NULL, 0);
+ mutex_unlock(&lock);
+ mutex_unlock(&conn_id->handler_mutex);
+ mutex_unlock(&listen_id->handler_mutex);
+ cma_deref_id(conn_id);
+ if (net_dev)
+ dev_put(net_dev);
+ return 0;
+
+err3:
+ cma_deref_id(conn_id);
+ /* Destroy the CM ID by returning a non-zero value. */
+ conn_id->cm_id.ib = NULL;
+err2:
+ cma_exch(conn_id, RDMA_CM_DESTROYING);
+ mutex_unlock(&conn_id->handler_mutex);
+err1:
+ mutex_unlock(&listen_id->handler_mutex);
+ if (conn_id)
+ rdma_destroy_id(&conn_id->id);
+
+net_dev_put:
+ if (net_dev)
+ dev_put(net_dev);
+
+ return ret;
+}
+
+__be64 rdma_get_service_id(struct rdma_cm_id *id, struct sockaddr *addr)
+{
+ if (addr->sa_family == AF_IB)
+ return ((struct sockaddr_ib *) addr)->sib_sid;
+
+ return cpu_to_be64(((u64)id->ps << 16) + be16_to_cpu(cma_port(addr)));
+}
+EXPORT_SYMBOL(rdma_get_service_id);
+
+static int cma_iw_handler(struct iw_cm_id *iw_id, struct iw_cm_event *iw_event)
+{
+ struct rdma_id_private *id_priv = iw_id->context;
+ struct rdma_cm_event event;
+ int ret = 0;
+ struct sockaddr *laddr = (struct sockaddr *)&iw_event->local_addr;
+ struct sockaddr *raddr = (struct sockaddr *)&iw_event->remote_addr;
+
+ mutex_lock(&id_priv->handler_mutex);
+ if (id_priv->state != RDMA_CM_CONNECT)
+ goto out;
+
+ memset(&event, 0, sizeof event);
+ switch (iw_event->event) {
+ case IW_CM_EVENT_CLOSE:
+ event.event = RDMA_CM_EVENT_DISCONNECTED;
+ break;
+ case IW_CM_EVENT_CONNECT_REPLY:
+ memcpy(cma_src_addr(id_priv), laddr,
+ rdma_addr_size(laddr));
+ memcpy(cma_dst_addr(id_priv), raddr,
+ rdma_addr_size(raddr));
+ switch (iw_event->status) {
+ case 0:
+ event.event = RDMA_CM_EVENT_ESTABLISHED;
+ event.param.conn.initiator_depth = iw_event->ird;
+ event.param.conn.responder_resources = iw_event->ord;
+ break;
+ case -ECONNRESET:
+ case -ECONNREFUSED:
+ event.event = RDMA_CM_EVENT_REJECTED;
+ break;
+ case -ETIMEDOUT:
+ event.event = RDMA_CM_EVENT_UNREACHABLE;
+ break;
+ default:
+ event.event = RDMA_CM_EVENT_CONNECT_ERROR;
+ break;
+ }
+ break;
+ case IW_CM_EVENT_ESTABLISHED:
+ event.event = RDMA_CM_EVENT_ESTABLISHED;
+ event.param.conn.initiator_depth = iw_event->ird;
+ event.param.conn.responder_resources = iw_event->ord;
+ break;
+ default:
+ BUG_ON(1);
+ }
+
+ event.status = iw_event->status;
+ event.param.conn.private_data = iw_event->private_data;
+ event.param.conn.private_data_len = iw_event->private_data_len;
+ ret = id_priv->id.event_handler(&id_priv->id, &event);
+ if (ret) {
+ /* Destroy the CM ID by returning a non-zero value. */
+ id_priv->cm_id.iw = NULL;
+ cma_exch(id_priv, RDMA_CM_DESTROYING);
+ mutex_unlock(&id_priv->handler_mutex);
+ rdma_destroy_id(&id_priv->id);
+ return ret;
+ }
+
+out:
+ mutex_unlock(&id_priv->handler_mutex);
+ return ret;
+}
+
+static int iw_conn_req_handler(struct iw_cm_id *cm_id,
+ struct iw_cm_event *iw_event)
+{
+ struct rdma_cm_id *new_cm_id;
+ struct rdma_id_private *listen_id, *conn_id;
+ struct rdma_cm_event event;
+ int ret = -ECONNABORTED;
+ struct sockaddr *laddr = (struct sockaddr *)&iw_event->local_addr;
+ struct sockaddr *raddr = (struct sockaddr *)&iw_event->remote_addr;
+
+ listen_id = cm_id->context;
+
+ mutex_lock(&listen_id->handler_mutex);
+ if (listen_id->state != RDMA_CM_LISTEN)
+ goto out;
+
+ /* Create a new RDMA id for the new IW CM ID */
+ new_cm_id = rdma_create_id(listen_id->id.route.addr.dev_addr.net,
+ listen_id->id.event_handler,
+ listen_id->id.context,
+ RDMA_PS_TCP, IB_QPT_RC);
+ if (IS_ERR(new_cm_id)) {
+ ret = -ENOMEM;
+ goto out;
+ }
+ conn_id = container_of(new_cm_id, struct rdma_id_private, id);
+ mutex_lock_nested(&conn_id->handler_mutex, SINGLE_DEPTH_NESTING);
+ conn_id->state = RDMA_CM_CONNECT;
+
+ ret = rdma_translate_ip(laddr, &conn_id->id.route.addr.dev_addr, NULL);
+ if (ret) {
+ mutex_unlock(&conn_id->handler_mutex);
+ rdma_destroy_id(new_cm_id);
+ goto out;
+ }
+
+ ret = cma_acquire_dev(conn_id, listen_id);
+ if (ret) {
+ mutex_unlock(&conn_id->handler_mutex);
+ rdma_destroy_id(new_cm_id);
+ goto out;
+ }
+
+ conn_id->cm_id.iw = cm_id;
+ cm_id->context = conn_id;
+ cm_id->cm_handler = cma_iw_handler;
+
+ memcpy(cma_src_addr(conn_id), laddr, rdma_addr_size(laddr));
+ memcpy(cma_dst_addr(conn_id), raddr, rdma_addr_size(raddr));
+
+ memset(&event, 0, sizeof event);
+ event.event = RDMA_CM_EVENT_CONNECT_REQUEST;
+ event.param.conn.private_data = iw_event->private_data;
+ event.param.conn.private_data_len = iw_event->private_data_len;
+ event.param.conn.initiator_depth = iw_event->ird;
+ event.param.conn.responder_resources = iw_event->ord;
+
+ /*
+ * Protect against the user destroying conn_id from another thread
+ * until we're done accessing it.
+ */
+ atomic_inc(&conn_id->refcount);
+ ret = conn_id->id.event_handler(&conn_id->id, &event);
+ if (ret) {
+ /* User wants to destroy the CM ID */
+ conn_id->cm_id.iw = NULL;
+ cma_exch(conn_id, RDMA_CM_DESTROYING);
+ mutex_unlock(&conn_id->handler_mutex);
+ cma_deref_id(conn_id);
+ rdma_destroy_id(&conn_id->id);
+ goto out;
+ }
+
+ mutex_unlock(&conn_id->handler_mutex);
+ cma_deref_id(conn_id);
+
+out:
+ mutex_unlock(&listen_id->handler_mutex);
+ return ret;
+}
+
+static int cma_ib_listen(struct rdma_id_private *id_priv)
+{
+ struct sockaddr *addr;
+ struct ib_cm_id *id;
+ __be64 svc_id;
+
+ addr = cma_src_addr(id_priv);
+ svc_id = rdma_get_service_id(&id_priv->id, addr);
+ id = ib_cm_insert_listen(id_priv->id.device, cma_req_handler, svc_id);
+ if (IS_ERR(id))
+ return PTR_ERR(id);
+ id_priv->cm_id.ib = id;
+
+ return 0;
+}
+
+static int cma_iw_listen(struct rdma_id_private *id_priv, int backlog)
+{
+ int ret;
+ struct iw_cm_id *id;
+
+ id = iw_create_cm_id(id_priv->id.device,
+ iw_conn_req_handler,
+ id_priv);
+ if (IS_ERR(id))
+ return PTR_ERR(id);
+
+ id->tos = id_priv->tos;
+ id_priv->cm_id.iw = id;
+
+ memcpy(&id_priv->cm_id.iw->local_addr, cma_src_addr(id_priv),
+ rdma_addr_size(cma_src_addr(id_priv)));
+
+ ret = iw_cm_listen(id_priv->cm_id.iw, backlog);
+
+ if (ret) {
+ iw_destroy_cm_id(id_priv->cm_id.iw);
+ id_priv->cm_id.iw = NULL;
+ }
+
+ return ret;
+}
+
+static int cma_listen_handler(struct rdma_cm_id *id,
+ struct rdma_cm_event *event)
+{
+ struct rdma_id_private *id_priv = id->context;
+
+ id->context = id_priv->id.context;
+ id->event_handler = id_priv->id.event_handler;
+ return id_priv->id.event_handler(id, event);
+}
+
+static void cma_listen_on_dev(struct rdma_id_private *id_priv,
+ struct cma_device *cma_dev)
+{
+ struct rdma_id_private *dev_id_priv;
+ struct rdma_cm_id *id;
+ struct vnet *net = id_priv->id.route.addr.dev_addr.net;
+ int ret;
+
+ if (cma_family(id_priv) == AF_IB && !rdma_cap_ib_cm(cma_dev->device, 1))
+ return;
+
+ id = rdma_create_id(net, cma_listen_handler, id_priv, id_priv->id.ps,
+ id_priv->id.qp_type);
+ if (IS_ERR(id))
+ return;
+
+ dev_id_priv = container_of(id, struct rdma_id_private, id);
+
+ dev_id_priv->state = RDMA_CM_ADDR_BOUND;
+ memcpy(cma_src_addr(dev_id_priv), cma_src_addr(id_priv),
+ rdma_addr_size(cma_src_addr(id_priv)));
+
+ _cma_attach_to_dev(dev_id_priv, cma_dev);
+ list_add_tail(&dev_id_priv->listen_list, &id_priv->listen_list);
+ atomic_inc(&id_priv->refcount);
+ dev_id_priv->internal_id = 1;
+ dev_id_priv->afonly = id_priv->afonly;
+
+ ret = rdma_listen(id, id_priv->backlog);
+ if (ret)
+ pr_warn("RDMA CMA: cma_listen_on_dev, error %d, listening on device %s\n",
+ ret, cma_dev->device->name);
+}
+
+static void cma_listen_on_all(struct rdma_id_private *id_priv)
+{
+ struct cma_device *cma_dev;
+
+ mutex_lock(&lock);
+ list_add_tail(&id_priv->list, &listen_any_list);
+ list_for_each_entry(cma_dev, &dev_list, list)
+ cma_listen_on_dev(id_priv, cma_dev);
+ mutex_unlock(&lock);
+}
+
+void rdma_set_service_type(struct rdma_cm_id *id, int tos)
+{
+ struct rdma_id_private *id_priv;
+
+ id_priv = container_of(id, struct rdma_id_private, id);
+ id_priv->tos = (u8) tos;
+}
+EXPORT_SYMBOL(rdma_set_service_type);
+
+static void cma_query_handler(int status, struct ib_sa_path_rec *path_rec,
+ void *context)
+{
+ struct cma_work *work = context;
+ struct rdma_route *route;
+
+ route = &work->id->id.route;
+
+ if (!status) {
+ route->num_paths = 1;
+ *route->path_rec = *path_rec;
+ } else {
+ work->old_state = RDMA_CM_ROUTE_QUERY;
+ work->new_state = RDMA_CM_ADDR_RESOLVED;
+ work->event.event = RDMA_CM_EVENT_ROUTE_ERROR;
+ work->event.status = status;
+ }
+
+ queue_work(cma_wq, &work->work);
+}
+
+static int cma_query_ib_route(struct rdma_id_private *id_priv, int timeout_ms,
+ struct cma_work *work)
+{
+ struct rdma_dev_addr *dev_addr = &id_priv->id.route.addr.dev_addr;
+ struct ib_sa_path_rec path_rec;
+ ib_sa_comp_mask comp_mask;
+ struct sockaddr_in6 *sin6;
+ struct sockaddr_ib *sib;
+
+ memset(&path_rec, 0, sizeof path_rec);
+ rdma_addr_get_sgid(dev_addr, &path_rec.sgid);
+ rdma_addr_get_dgid(dev_addr, &path_rec.dgid);
+ path_rec.pkey = cpu_to_be16(ib_addr_get_pkey(dev_addr));
+ path_rec.numb_path = 1;
+ path_rec.reversible = 1;
+ path_rec.service_id = rdma_get_service_id(&id_priv->id, cma_dst_addr(id_priv));
+
+ comp_mask = IB_SA_PATH_REC_DGID | IB_SA_PATH_REC_SGID |
+ IB_SA_PATH_REC_PKEY | IB_SA_PATH_REC_NUMB_PATH |
+ IB_SA_PATH_REC_REVERSIBLE | IB_SA_PATH_REC_SERVICE_ID;
+
+ switch (cma_family(id_priv)) {
+ case AF_INET:
+ path_rec.qos_class = cpu_to_be16((u16) id_priv->tos);
+ comp_mask |= IB_SA_PATH_REC_QOS_CLASS;
+ break;
+ case AF_INET6:
+ sin6 = (struct sockaddr_in6 *) cma_src_addr(id_priv);
+ path_rec.traffic_class = (u8) (be32_to_cpu(sin6->sin6_flowinfo) >> 20);
+ comp_mask |= IB_SA_PATH_REC_TRAFFIC_CLASS;
+ break;
+ case AF_IB:
+ sib = (struct sockaddr_ib *) cma_src_addr(id_priv);
+ path_rec.traffic_class = (u8) (be32_to_cpu(sib->sib_flowinfo) >> 20);
+ comp_mask |= IB_SA_PATH_REC_TRAFFIC_CLASS;
+ break;
+ }
+
+ id_priv->query_id = ib_sa_path_rec_get(&sa_client, id_priv->id.device,
+ id_priv->id.port_num, &path_rec,
+ comp_mask, timeout_ms,
+ GFP_KERNEL, cma_query_handler,
+ work, &id_priv->query);
+
+ return (id_priv->query_id < 0) ? id_priv->query_id : 0;
+}
+
+static void cma_work_handler(struct work_struct *_work)
+{
+ struct cma_work *work = container_of(_work, struct cma_work, work);
+ struct rdma_id_private *id_priv = work->id;
+ int destroy = 0;
+
+ mutex_lock(&id_priv->handler_mutex);
+ if (!cma_comp_exch(id_priv, work->old_state, work->new_state))
+ goto out;
+
+ if (id_priv->id.event_handler(&id_priv->id, &work->event)) {
+ cma_exch(id_priv, RDMA_CM_DESTROYING);
+ destroy = 1;
+ }
+out:
+ mutex_unlock(&id_priv->handler_mutex);
+ cma_deref_id(id_priv);
+ if (destroy)
+ rdma_destroy_id(&id_priv->id);
+ kfree(work);
+}
+
+static int cma_resolve_ib_route(struct rdma_id_private *id_priv, int timeout_ms)
+{
+ struct rdma_route *route = &id_priv->id.route;
+ struct cma_work *work;
+ int ret;
+
+ work = kzalloc(sizeof *work, GFP_KERNEL);
+ if (!work)
+ return -ENOMEM;
+
+ work->id = id_priv;
+ INIT_WORK(&work->work, cma_work_handler);
+ work->old_state = RDMA_CM_ROUTE_QUERY;
+ work->new_state = RDMA_CM_ROUTE_RESOLVED;
+ work->event.event = RDMA_CM_EVENT_ROUTE_RESOLVED;
+
+ route->path_rec = kmalloc(sizeof *route->path_rec, GFP_KERNEL);
+ if (!route->path_rec) {
+ ret = -ENOMEM;
+ goto err1;
+ }
+
+ ret = cma_query_ib_route(id_priv, timeout_ms, work);
+ if (ret)
+ goto err2;
+
+ return 0;
+err2:
+ kfree(route->path_rec);
+ route->path_rec = NULL;
+err1:
+ kfree(work);
+ return ret;
+}
+
+int rdma_set_ib_paths(struct rdma_cm_id *id,
+ struct ib_sa_path_rec *path_rec, int num_paths)
+{
+ struct rdma_id_private *id_priv;
+ int ret;
+
+ id_priv = container_of(id, struct rdma_id_private, id);
+ if (!cma_comp_exch(id_priv, RDMA_CM_ADDR_RESOLVED,
+ RDMA_CM_ROUTE_RESOLVED))
+ return -EINVAL;
+
+ id->route.path_rec = kmemdup(path_rec, sizeof *path_rec * num_paths,
+ GFP_KERNEL);
+ if (!id->route.path_rec) {
+ ret = -ENOMEM;
+ goto err;
+ }
+
+ id->route.num_paths = num_paths;
+ return 0;
+err:
+ cma_comp_exch(id_priv, RDMA_CM_ROUTE_RESOLVED, RDMA_CM_ADDR_RESOLVED);
+ return ret;
+}
+EXPORT_SYMBOL(rdma_set_ib_paths);
+
+static int cma_resolve_iw_route(struct rdma_id_private *id_priv, int timeout_ms)
+{
+ struct cma_work *work;
+
+ work = kzalloc(sizeof *work, GFP_KERNEL);
+ if (!work)
+ return -ENOMEM;
+
+ work->id = id_priv;
+ INIT_WORK(&work->work, cma_work_handler);
+ work->old_state = RDMA_CM_ROUTE_QUERY;
+ work->new_state = RDMA_CM_ROUTE_RESOLVED;
+ work->event.event = RDMA_CM_EVENT_ROUTE_RESOLVED;
+ queue_work(cma_wq, &work->work);
+ return 0;
+}
+
+static int iboe_tos_to_sl(struct net_device *ndev, int tos)
+{
+ /* TODO: Implement this function */
+ return 0;
+}
+
+static enum ib_gid_type cma_route_gid_type(enum rdma_network_type network_type,
+ unsigned long supported_gids,
+ enum ib_gid_type default_gid)
+{
+ if ((network_type == RDMA_NETWORK_IPV4 ||
+ network_type == RDMA_NETWORK_IPV6) &&
+ test_bit(IB_GID_TYPE_ROCE_UDP_ENCAP, &supported_gids))
+ return IB_GID_TYPE_ROCE_UDP_ENCAP;
+
+ return default_gid;
+}
+
+static int cma_resolve_iboe_route(struct rdma_id_private *id_priv)
+{
+ struct rdma_route *route = &id_priv->id.route;
+ struct rdma_addr *addr = &route->addr;
+ struct cma_work *work;
+ int ret;
+ struct net_device *ndev = NULL;
+
+
+ work = kzalloc(sizeof *work, GFP_KERNEL);
+ if (!work)
+ return -ENOMEM;
+
+ work->id = id_priv;
+ INIT_WORK(&work->work, cma_work_handler);
+
+ route->path_rec = kzalloc(sizeof *route->path_rec, GFP_KERNEL);
+ if (!route->path_rec) {
+ ret = -ENOMEM;
+ goto err1;
+ }
+
+ route->num_paths = 1;
+
+ if (addr->dev_addr.bound_dev_if) {
+ unsigned long supported_gids;
+
+ ndev = dev_get_by_index(addr->dev_addr.net,
+ addr->dev_addr.bound_dev_if);
+ if (!ndev) {
+ ret = -ENODEV;
+ goto err2;
+ }
+
+ if (ndev->if_flags & IFF_LOOPBACK) {
+ dev_put(ndev);
+ if (!id_priv->id.device->get_netdev) {
+ ret = -EOPNOTSUPP;
+ goto err2;
+ }
+
+ ndev = id_priv->id.device->get_netdev(id_priv->id.device,
+ id_priv->id.port_num);
+ if (!ndev) {
+ ret = -ENODEV;
+ goto err2;
+ }
+ }
+
+ route->path_rec->net = ndev->if_vnet;
+ route->path_rec->ifindex = ndev->if_index;
+ supported_gids = roce_gid_type_mask_support(id_priv->id.device,
+ id_priv->id.port_num);
+ route->path_rec->gid_type =
+ cma_route_gid_type(addr->dev_addr.network,
+ supported_gids,
+ id_priv->gid_type);
+ }
+ if (!ndev) {
+ ret = -ENODEV;
+ goto err2;
+ }
+
+ memcpy(route->path_rec->dmac, addr->dev_addr.dst_dev_addr, ETH_ALEN);
+
+ rdma_ip2gid((struct sockaddr *)&id_priv->id.route.addr.src_addr,
+ &route->path_rec->sgid);
+ rdma_ip2gid((struct sockaddr *)&id_priv->id.route.addr.dst_addr,
+ &route->path_rec->dgid);
+
+ /* Use the hint from IP Stack to select GID Type */
+ if (route->path_rec->gid_type < ib_network_to_gid_type(addr->dev_addr.network))
+ route->path_rec->gid_type = ib_network_to_gid_type(addr->dev_addr.network);
+ if (((struct sockaddr *)&id_priv->id.route.addr.dst_addr)->sa_family != AF_IB)
+ /* TODO: get the hoplimit from the inet/inet6 device */
+ route->path_rec->hop_limit = addr->dev_addr.hoplimit;
+ else
+ route->path_rec->hop_limit = 1;
+ route->path_rec->reversible = 1;
+ route->path_rec->pkey = cpu_to_be16(0xffff);
+ route->path_rec->mtu_selector = IB_SA_EQ;
+ route->path_rec->sl = iboe_tos_to_sl(ndev, id_priv->tos);
+ route->path_rec->mtu = iboe_get_mtu(ndev->if_mtu);
+ route->path_rec->rate_selector = IB_SA_EQ;
+ route->path_rec->rate = iboe_get_rate(ndev);
+ dev_put(ndev);
+ route->path_rec->packet_life_time_selector = IB_SA_EQ;
+ route->path_rec->packet_life_time = CMA_IBOE_PACKET_LIFETIME;
+ if (!route->path_rec->mtu) {
+ ret = -EINVAL;
+ goto err2;
+ }
+
+ work->old_state = RDMA_CM_ROUTE_QUERY;
+ work->new_state = RDMA_CM_ROUTE_RESOLVED;
+ work->event.event = RDMA_CM_EVENT_ROUTE_RESOLVED;
+ work->event.status = 0;
+
+ queue_work(cma_wq, &work->work);
+
+ return 0;
+
+err2:
+ kfree(route->path_rec);
+ route->path_rec = NULL;
+err1:
+ kfree(work);
+ return ret;
+}
+
+int rdma_resolve_route(struct rdma_cm_id *id, int timeout_ms)
+{
+ struct rdma_id_private *id_priv;
+ int ret;
+
+ id_priv = container_of(id, struct rdma_id_private, id);
+ if (!cma_comp_exch(id_priv, RDMA_CM_ADDR_RESOLVED, RDMA_CM_ROUTE_QUERY))
+ return -EINVAL;
+
+ atomic_inc(&id_priv->refcount);
+ if (rdma_cap_ib_sa(id->device, id->port_num))
+ ret = cma_resolve_ib_route(id_priv, timeout_ms);
+ else if (rdma_protocol_roce(id->device, id->port_num))
+ ret = cma_resolve_iboe_route(id_priv);
+ else if (rdma_protocol_iwarp(id->device, id->port_num))
+ ret = cma_resolve_iw_route(id_priv, timeout_ms);
+ else
+ ret = -ENOSYS;
+
+ if (ret)
+ goto err;
+
+ return 0;
+err:
+ cma_comp_exch(id_priv, RDMA_CM_ROUTE_QUERY, RDMA_CM_ADDR_RESOLVED);
+ cma_deref_id(id_priv);
+ return ret;
+}
+EXPORT_SYMBOL(rdma_resolve_route);
+
+static void cma_set_loopback(struct sockaddr *addr)
+{
+ switch (addr->sa_family) {
+ case AF_INET:
+ ((struct sockaddr_in *) addr)->sin_addr.s_addr = htonl(INADDR_LOOPBACK);
+ break;
+ case AF_INET6:
+ ipv6_addr_set(&((struct sockaddr_in6 *) addr)->sin6_addr,
+ 0, 0, 0, htonl(1));
+ break;
+ default:
+ ib_addr_set(&((struct sockaddr_ib *) addr)->sib_addr,
+ 0, 0, 0, htonl(1));
+ break;
+ }
+}
+
+static int cma_bind_loopback(struct rdma_id_private *id_priv)
+{
+ struct cma_device *cma_dev, *cur_dev;
+ struct ib_port_attr port_attr;
+ union ib_gid gid;
+ u16 pkey;
+ int ret;
+ u8 p;
+
+ cma_dev = NULL;
+ mutex_lock(&lock);
+ list_for_each_entry(cur_dev, &dev_list, list) {
+ if (cma_family(id_priv) == AF_IB &&
+ !rdma_cap_ib_cm(cur_dev->device, 1))
+ continue;
+
+ if (!cma_dev)
+ cma_dev = cur_dev;
+
+ for (p = 1; p <= cur_dev->device->phys_port_cnt; ++p) {
+ if (!ib_query_port(cur_dev->device, p, &port_attr) &&
+ port_attr.state == IB_PORT_ACTIVE) {
+ cma_dev = cur_dev;
+ goto port_found;
+ }
+ }
+ }
+
+ if (!cma_dev) {
+ ret = -ENODEV;
+ goto out;
+ }
+
+ p = 1;
+
+port_found:
+ ret = ib_get_cached_gid(cma_dev->device, p, 0, &gid, NULL);
+ if (ret)
+ goto out;
+
+ ret = ib_get_cached_pkey(cma_dev->device, p, 0, &pkey);
+ if (ret)
+ goto out;
+
+ id_priv->id.route.addr.dev_addr.dev_type =
+ (rdma_protocol_ib(cma_dev->device, p)) ?
+ ARPHRD_INFINIBAND : ARPHRD_ETHER;
+
+ rdma_addr_set_sgid(&id_priv->id.route.addr.dev_addr, &gid);
+ ib_addr_set_pkey(&id_priv->id.route.addr.dev_addr, pkey);
+ id_priv->id.port_num = p;
+ cma_attach_to_dev(id_priv, cma_dev);
+ cma_set_loopback(cma_src_addr(id_priv));
+out:
+ mutex_unlock(&lock);
+ return ret;
+}
+
+static void addr_handler(int status, struct sockaddr *src_addr,
+ struct rdma_dev_addr *dev_addr, void *context)
+{
+ struct rdma_id_private *id_priv = context;
+ struct rdma_cm_event event;
+
+ memset(&event, 0, sizeof event);
+ mutex_lock(&id_priv->handler_mutex);
+ if (!cma_comp_exch(id_priv, RDMA_CM_ADDR_QUERY,
+ RDMA_CM_ADDR_RESOLVED))
+ goto out;
+
+ memcpy(cma_src_addr(id_priv), src_addr, rdma_addr_size(src_addr));
+ if (!status && !id_priv->cma_dev)
+ status = cma_acquire_dev(id_priv, NULL);
+
+ if (status) {
+ if (!cma_comp_exch(id_priv, RDMA_CM_ADDR_RESOLVED,
+ RDMA_CM_ADDR_BOUND))
+ goto out;
+ event.event = RDMA_CM_EVENT_ADDR_ERROR;
+ event.status = status;
+ } else
+ event.event = RDMA_CM_EVENT_ADDR_RESOLVED;
+
+ if (id_priv->id.event_handler(&id_priv->id, &event)) {
+ cma_exch(id_priv, RDMA_CM_DESTROYING);
+ mutex_unlock(&id_priv->handler_mutex);
+ cma_deref_id(id_priv);
+ rdma_destroy_id(&id_priv->id);
+ return;
+ }
+out:
+ mutex_unlock(&id_priv->handler_mutex);
+ cma_deref_id(id_priv);
+}
+
+static int cma_resolve_loopback(struct rdma_id_private *id_priv)
+{
+ struct cma_work *work;
+ union ib_gid gid;
+ int ret;
+
+ work = kzalloc(sizeof *work, GFP_KERNEL);
+ if (!work)
+ return -ENOMEM;
+
+ if (!id_priv->cma_dev) {
+ ret = cma_bind_loopback(id_priv);
+ if (ret)
+ goto err;
+ }
+
+ rdma_addr_get_sgid(&id_priv->id.route.addr.dev_addr, &gid);
+ rdma_addr_set_dgid(&id_priv->id.route.addr.dev_addr, &gid);
+
+ work->id = id_priv;
+ INIT_WORK(&work->work, cma_work_handler);
+ work->old_state = RDMA_CM_ADDR_QUERY;
+ work->new_state = RDMA_CM_ADDR_RESOLVED;
+ work->event.event = RDMA_CM_EVENT_ADDR_RESOLVED;
+ queue_work(cma_wq, &work->work);
+ return 0;
+err:
+ kfree(work);
+ return ret;
+}
+
+static int cma_resolve_ib_addr(struct rdma_id_private *id_priv)
+{
+ struct cma_work *work;
+ int ret;
+
+ work = kzalloc(sizeof *work, GFP_KERNEL);
+ if (!work)
+ return -ENOMEM;
+
+ if (!id_priv->cma_dev) {
+ ret = cma_resolve_ib_dev(id_priv);
+ if (ret)
+ goto err;
+ }
+
+ rdma_addr_set_dgid(&id_priv->id.route.addr.dev_addr, (union ib_gid *)
+ &(((struct sockaddr_ib *) &id_priv->id.route.addr.dst_addr)->sib_addr));
+
+ work->id = id_priv;
+ INIT_WORK(&work->work, cma_work_handler);
+ work->old_state = RDMA_CM_ADDR_QUERY;
+ work->new_state = RDMA_CM_ADDR_RESOLVED;
+ work->event.event = RDMA_CM_EVENT_ADDR_RESOLVED;
+ queue_work(cma_wq, &work->work);
+ return 0;
+err:
+ kfree(work);
+ return ret;
+}
+
+static int cma_bind_addr(struct rdma_cm_id *id, struct sockaddr *src_addr,
+ struct sockaddr *dst_addr)
+{
+ if (!src_addr || !src_addr->sa_family) {
+ src_addr = (struct sockaddr *) &id->route.addr.src_addr;
+ src_addr->sa_family = dst_addr->sa_family;
+ if (dst_addr->sa_family == AF_INET6) {
+ struct sockaddr_in6 *src_addr6 = (struct sockaddr_in6 *) src_addr;
+ struct sockaddr_in6 *dst_addr6 = (struct sockaddr_in6 *) dst_addr;
+ src_addr6->sin6_scope_id = dst_addr6->sin6_scope_id;
+ if (IN6_IS_SCOPE_LINKLOCAL(&dst_addr6->sin6_addr))
+ id->route.addr.dev_addr.bound_dev_if = dst_addr6->sin6_scope_id;
+ } else if (dst_addr->sa_family == AF_IB) {
+ ((struct sockaddr_ib *) src_addr)->sib_pkey =
+ ((struct sockaddr_ib *) dst_addr)->sib_pkey;
+ }
+ }
+ return rdma_bind_addr(id, src_addr);
+}
+
+int rdma_resolve_addr(struct rdma_cm_id *id, struct sockaddr *src_addr,
+ struct sockaddr *dst_addr, int timeout_ms)
+{
+ struct rdma_id_private *id_priv;
+ int ret;
+
+ id_priv = container_of(id, struct rdma_id_private, id);
+ if (id_priv->state == RDMA_CM_IDLE) {
+ ret = cma_bind_addr(id, src_addr, dst_addr);
+ if (ret)
+ return ret;
+ }
+
+ if (cma_family(id_priv) != dst_addr->sa_family)
+ return -EINVAL;
+
+ if (!cma_comp_exch(id_priv, RDMA_CM_ADDR_BOUND, RDMA_CM_ADDR_QUERY))
+ return -EINVAL;
+
+ atomic_inc(&id_priv->refcount);
+ memcpy(cma_dst_addr(id_priv), dst_addr, rdma_addr_size(dst_addr));
+ if (cma_any_addr(dst_addr)) {
+ ret = cma_resolve_loopback(id_priv);
+ } else {
+ if (dst_addr->sa_family == AF_IB) {
+ ret = cma_resolve_ib_addr(id_priv);
+ } else {
+ ret = rdma_resolve_ip(&addr_client, cma_src_addr(id_priv),
+ dst_addr, &id->route.addr.dev_addr,
+ timeout_ms, addr_handler, id_priv);
+ }
+ }
+ if (ret)
+ goto err;
+
+ return 0;
+err:
+ cma_comp_exch(id_priv, RDMA_CM_ADDR_QUERY, RDMA_CM_ADDR_BOUND);
+ cma_deref_id(id_priv);
+ return ret;
+}
+EXPORT_SYMBOL(rdma_resolve_addr);
+
+int rdma_set_reuseaddr(struct rdma_cm_id *id, int reuse)
+{
+ struct rdma_id_private *id_priv;
+ unsigned long flags;
+ int ret;
+
+ id_priv = container_of(id, struct rdma_id_private, id);
+ spin_lock_irqsave(&id_priv->lock, flags);
+ if (reuse || id_priv->state == RDMA_CM_IDLE) {
+ id_priv->reuseaddr = reuse;
+ ret = 0;
+ } else {
+ ret = -EINVAL;
+ }
+ spin_unlock_irqrestore(&id_priv->lock, flags);
+ return ret;
+}
+EXPORT_SYMBOL(rdma_set_reuseaddr);
+
+int rdma_set_afonly(struct rdma_cm_id *id, int afonly)
+{
+ struct rdma_id_private *id_priv;
+ unsigned long flags;
+ int ret;
+
+ id_priv = container_of(id, struct rdma_id_private, id);
+ spin_lock_irqsave(&id_priv->lock, flags);
+ if (id_priv->state == RDMA_CM_IDLE || id_priv->state == RDMA_CM_ADDR_BOUND) {
+ id_priv->options |= (1 << CMA_OPTION_AFONLY);
+ id_priv->afonly = afonly;
+ ret = 0;
+ } else {
+ ret = -EINVAL;
+ }
+ spin_unlock_irqrestore(&id_priv->lock, flags);
+ return ret;
+}
+EXPORT_SYMBOL(rdma_set_afonly);
+
+static void cma_bind_port(struct rdma_bind_list *bind_list,
+ struct rdma_id_private *id_priv)
+{
+ struct sockaddr *addr;
+ struct sockaddr_ib *sib;
+ u64 sid, mask;
+ __be16 port;
+
+ addr = cma_src_addr(id_priv);
+ port = htons(bind_list->port);
+
+ switch (addr->sa_family) {
+ case AF_INET:
+ ((struct sockaddr_in *) addr)->sin_port = port;
+ break;
+ case AF_INET6:
+ ((struct sockaddr_in6 *) addr)->sin6_port = port;
+ break;
+ case AF_IB:
+ sib = (struct sockaddr_ib *) addr;
+ sid = be64_to_cpu(sib->sib_sid);
+ mask = be64_to_cpu(sib->sib_sid_mask);
+ sib->sib_sid = cpu_to_be64((sid & mask) | (u64) ntohs(port));
+ sib->sib_sid_mask = cpu_to_be64(~0ULL);
+ break;
+ }
+ id_priv->bind_list = bind_list;
+ hlist_add_head(&id_priv->node, &bind_list->owners);
+}
+
+static int cma_alloc_port(enum rdma_port_space ps,
+ struct rdma_id_private *id_priv, unsigned short snum)
+{
+ struct rdma_bind_list *bind_list;
+ int ret;
+
+ bind_list = kzalloc(sizeof *bind_list, GFP_KERNEL);
+ if (!bind_list)
+ return -ENOMEM;
+
+ ret = cma_ps_alloc(id_priv->id.route.addr.dev_addr.net, ps, bind_list,
+ snum);
+ if (ret < 0)
+ goto err;
+
+ bind_list->ps = ps;
+ bind_list->port = (unsigned short)ret;
+ cma_bind_port(bind_list, id_priv);
+ return 0;
+err:
+ kfree(bind_list);
+ return ret == -ENOSPC ? -EADDRNOTAVAIL : ret;
+}
+
+static int cma_alloc_any_port(enum rdma_port_space ps,
+ struct rdma_id_private *id_priv)
+{
+ static unsigned int last_used_port;
+ int low, high, remaining;
+ unsigned int rover;
+ struct vnet *net = id_priv->id.route.addr.dev_addr.net;
+ u32 rand;
+
+ inet_get_local_port_range(net, &low, &high);
+ remaining = (high - low) + 1;
+ get_random_bytes(&rand, sizeof(rand));
+ rover = rand % remaining + low;
+retry:
+ if (last_used_port != rover &&
+ !cma_ps_find(net, ps, (unsigned short)rover)) {
+ int ret = cma_alloc_port(ps, id_priv, rover);
+ /*
+ * Remember previously used port number in order to avoid
+ * re-using same port immediately after it is closed.
+ */
+ if (!ret)
+ last_used_port = rover;
+ if (ret != -EADDRNOTAVAIL)
+ return ret;
+ }
+ if (--remaining) {
+ rover++;
+ if ((rover < low) || (rover > high))
+ rover = low;
+ goto retry;
+ }
+ return -EADDRNOTAVAIL;
+}
+
+/*
+ * Check that the requested port is available. This is called when trying to
+ * bind to a specific port, or when trying to listen on a bound port. In
+ * the latter case, the provided id_priv may already be on the bind_list, but
+ * we still need to check that it's okay to start listening.
+ */
+static int cma_check_port(struct rdma_bind_list *bind_list,
+ struct rdma_id_private *id_priv, uint8_t reuseaddr)
+{
+ struct rdma_id_private *cur_id;
+ struct sockaddr *addr, *cur_addr;
+
+ addr = cma_src_addr(id_priv);
+ hlist_for_each_entry(cur_id, &bind_list->owners, node) {
+ if (id_priv == cur_id)
+ continue;
+
+ if ((cur_id->state != RDMA_CM_LISTEN) && reuseaddr &&
+ cur_id->reuseaddr)
+ continue;
+
+ cur_addr = cma_src_addr(cur_id);
+ if (id_priv->afonly && cur_id->afonly &&
+ (addr->sa_family != cur_addr->sa_family))
+ continue;
+
+ if (cma_any_addr(addr) || cma_any_addr(cur_addr))
+ return -EADDRNOTAVAIL;
+
+ if (!cma_addr_cmp(addr, cur_addr))
+ return -EADDRINUSE;
+ }
+ return 0;
+}
+
+static int cma_use_port(enum rdma_port_space ps,
+ struct rdma_id_private *id_priv)
+{
+ struct rdma_bind_list *bind_list;
+ unsigned short snum;
+ int ret;
+
+ snum = ntohs(cma_port(cma_src_addr(id_priv)));
+ if (snum < IPPORT_RESERVED &&
+ priv_check(curthread, PRIV_NETINET_BINDANY) != 0)
+ return -EACCES;
+
+ bind_list = cma_ps_find(id_priv->id.route.addr.dev_addr.net, ps, snum);
+ if (!bind_list) {
+ ret = cma_alloc_port(ps, id_priv, snum);
+ } else {
+ ret = cma_check_port(bind_list, id_priv, id_priv->reuseaddr);
+ if (!ret)
+ cma_bind_port(bind_list, id_priv);
+ }
+ return ret;
+}
+
+static int cma_bind_listen(struct rdma_id_private *id_priv)
+{
+ struct rdma_bind_list *bind_list = id_priv->bind_list;
+ int ret = 0;
+
+ mutex_lock(&lock);
+ if (bind_list->owners.first->next)
+ ret = cma_check_port(bind_list, id_priv, 0);
+ mutex_unlock(&lock);
+ return ret;
+}
+
+static enum rdma_port_space cma_select_inet_ps(
+ struct rdma_id_private *id_priv)
+{
+ switch (id_priv->id.ps) {
+ case RDMA_PS_TCP:
+ case RDMA_PS_UDP:
+ case RDMA_PS_IPOIB:
+ case RDMA_PS_IB:
+ return id_priv->id.ps;
+ default:
+
+ return 0;
+ }
+}
+
+static enum rdma_port_space cma_select_ib_ps(struct rdma_id_private *id_priv)
+{
+ enum rdma_port_space ps = 0;
+ struct sockaddr_ib *sib;
+ u64 sid_ps, mask, sid;
+
+ sib = (struct sockaddr_ib *) cma_src_addr(id_priv);
+ mask = be64_to_cpu(sib->sib_sid_mask) & RDMA_IB_IP_PS_MASK;
+ sid = be64_to_cpu(sib->sib_sid) & mask;
+
+ if ((id_priv->id.ps == RDMA_PS_IB) && (sid == (RDMA_IB_IP_PS_IB & mask))) {
+ sid_ps = RDMA_IB_IP_PS_IB;
+ ps = RDMA_PS_IB;
+ } else if (((id_priv->id.ps == RDMA_PS_IB) || (id_priv->id.ps == RDMA_PS_TCP)) &&
+ (sid == (RDMA_IB_IP_PS_TCP & mask))) {
+ sid_ps = RDMA_IB_IP_PS_TCP;
+ ps = RDMA_PS_TCP;
+ } else if (((id_priv->id.ps == RDMA_PS_IB) || (id_priv->id.ps == RDMA_PS_UDP)) &&
+ (sid == (RDMA_IB_IP_PS_UDP & mask))) {
+ sid_ps = RDMA_IB_IP_PS_UDP;
+ ps = RDMA_PS_UDP;
+ }
+
+ if (ps) {
+ sib->sib_sid = cpu_to_be64(sid_ps | ntohs(cma_port((struct sockaddr *) sib)));
+ sib->sib_sid_mask = cpu_to_be64(RDMA_IB_IP_PS_MASK |
+ be64_to_cpu(sib->sib_sid_mask));
+ }
+ return ps;
+}
+
+static int cma_get_port(struct rdma_id_private *id_priv)
+{
+ enum rdma_port_space ps;
+ int ret;
+
+ if (cma_family(id_priv) != AF_IB)
+ ps = cma_select_inet_ps(id_priv);
+ else
+ ps = cma_select_ib_ps(id_priv);
+ if (!ps)
+ return -EPROTONOSUPPORT;
+
+ mutex_lock(&lock);
+ if (cma_any_port(cma_src_addr(id_priv)))
+ ret = cma_alloc_any_port(ps, id_priv);
+ else
+ ret = cma_use_port(ps, id_priv);
+ mutex_unlock(&lock);
+
+ return ret;
+}
+
+static int cma_check_linklocal(struct rdma_dev_addr *dev_addr,
+ struct sockaddr *addr)
+{
+#ifdef INET6
+ struct sockaddr_in6 sin6;
+
+ if (addr->sa_family != AF_INET6)
+ return 0;
+
+ sin6 = *(struct sockaddr_in6 *)addr;
+
+ if (!(IN6_IS_SCOPE_LINKLOCAL(&sin6.sin6_addr)))
+ return 0;
+
+ if (sa6_recoverscope(&sin6) || sin6.sin6_scope_id == 0)
+ return -EINVAL;
+
+ dev_addr->bound_dev_if = sin6.sin6_scope_id;
+#endif
+ return 0;
+}
+
+int rdma_listen(struct rdma_cm_id *id, int backlog)
+{
+ struct rdma_id_private *id_priv;
+ int ret;
+
+ id_priv = container_of(id, struct rdma_id_private, id);
+ if (id_priv->state == RDMA_CM_IDLE) {
+ id->route.addr.src_addr.ss_family = AF_INET;
+ ret = rdma_bind_addr(id, cma_src_addr(id_priv));
+ if (ret)
+ return ret;
+ }
+
+ if (!cma_comp_exch(id_priv, RDMA_CM_ADDR_BOUND, RDMA_CM_LISTEN))
+ return -EINVAL;
+
+ if (id_priv->reuseaddr) {
+ ret = cma_bind_listen(id_priv);
+ if (ret)
+ goto err;
+ }
+
+ id_priv->backlog = backlog;
+ if (id->device) {
+ if (rdma_cap_ib_cm(id->device, 1)) {
+ ret = cma_ib_listen(id_priv);
+ if (ret)
+ goto err;
+ } else if (rdma_cap_iw_cm(id->device, 1)) {
+ ret = cma_iw_listen(id_priv, backlog);
+ if (ret)
+ goto err;
+ } else {
+ ret = -ENOSYS;
+ goto err;
+ }
+ } else
+ cma_listen_on_all(id_priv);
+
+ return 0;
+err:
+ id_priv->backlog = 0;
+ cma_comp_exch(id_priv, RDMA_CM_LISTEN, RDMA_CM_ADDR_BOUND);
+ return ret;
+}
+EXPORT_SYMBOL(rdma_listen);
+
+int rdma_bind_addr(struct rdma_cm_id *id, struct sockaddr *addr)
+{
+ struct rdma_id_private *id_priv;
+ int ret;
+
+ if (addr->sa_family != AF_INET && addr->sa_family != AF_INET6 &&
+ addr->sa_family != AF_IB)
+ return -EAFNOSUPPORT;
+
+ id_priv = container_of(id, struct rdma_id_private, id);
+ if (!cma_comp_exch(id_priv, RDMA_CM_IDLE, RDMA_CM_ADDR_BOUND))
+ return -EINVAL;
+
+ ret = cma_check_linklocal(&id->route.addr.dev_addr, addr);
+ if (ret)
+ goto err1;
+
+ memcpy(cma_src_addr(id_priv), addr, rdma_addr_size(addr));
+ if (!cma_any_addr(addr)) {
+ ret = cma_translate_addr(addr, &id->route.addr.dev_addr);
+ if (ret)
+ goto err1;
+
+ ret = cma_acquire_dev(id_priv, NULL);
+ if (ret)
+ goto err1;
+ }
+
+ if (!(id_priv->options & (1 << CMA_OPTION_AFONLY))) {
+ if (addr->sa_family == AF_INET)
+ id_priv->afonly = 1;
+#ifdef INET6
+ else if (addr->sa_family == AF_INET6) {
+ CURVNET_SET_QUIET(id_priv->id.route.addr.dev_addr.net);
+ id_priv->afonly = V_ip6_v6only;
+ CURVNET_RESTORE();
+ }
+#endif
+ }
+ ret = cma_get_port(id_priv);
+ if (ret)
+ goto err2;
+
+ return 0;
+err2:
+ if (id_priv->cma_dev)
+ cma_release_dev(id_priv);
+err1:
+ cma_comp_exch(id_priv, RDMA_CM_ADDR_BOUND, RDMA_CM_IDLE);
+ return ret;
+}
+EXPORT_SYMBOL(rdma_bind_addr);
+
+static int cma_format_hdr(void *hdr, struct rdma_id_private *id_priv)
+{
+ struct cma_hdr *cma_hdr;
+
+ cma_hdr = hdr;
+ cma_hdr->cma_version = CMA_VERSION;
+ if (cma_family(id_priv) == AF_INET) {
+ struct sockaddr_in *src4, *dst4;
+
+ src4 = (struct sockaddr_in *) cma_src_addr(id_priv);
+ dst4 = (struct sockaddr_in *) cma_dst_addr(id_priv);
+
+ cma_set_ip_ver(cma_hdr, 4);
+ cma_hdr->src_addr.ip4.addr = src4->sin_addr.s_addr;
+ cma_hdr->dst_addr.ip4.addr = dst4->sin_addr.s_addr;
+ cma_hdr->port = src4->sin_port;
+ } else if (cma_family(id_priv) == AF_INET6) {
+ struct sockaddr_in6 *src6, *dst6;
+
+ src6 = (struct sockaddr_in6 *) cma_src_addr(id_priv);
+ dst6 = (struct sockaddr_in6 *) cma_dst_addr(id_priv);
+
+ cma_set_ip_ver(cma_hdr, 6);
+ cma_hdr->src_addr.ip6 = src6->sin6_addr;
+ cma_hdr->dst_addr.ip6 = dst6->sin6_addr;
+ cma_hdr->port = src6->sin6_port;
+ }
+ return 0;
+}
+
+static int cma_sidr_rep_handler(struct ib_cm_id *cm_id,
+ struct ib_cm_event *ib_event)
+{
+ struct rdma_id_private *id_priv = cm_id->context;
+ struct rdma_cm_event event;
+ struct ib_cm_sidr_rep_event_param *rep = &ib_event->param.sidr_rep_rcvd;
+ int ret = 0;
+
+ mutex_lock(&id_priv->handler_mutex);
+ if (id_priv->state != RDMA_CM_CONNECT)
+ goto out;
+
+ memset(&event, 0, sizeof event);
+ switch (ib_event->event) {
+ case IB_CM_SIDR_REQ_ERROR:
+ event.event = RDMA_CM_EVENT_UNREACHABLE;
+ event.status = -ETIMEDOUT;
+ break;
+ case IB_CM_SIDR_REP_RECEIVED:
+ event.param.ud.private_data = ib_event->private_data;
+ event.param.ud.private_data_len = IB_CM_SIDR_REP_PRIVATE_DATA_SIZE;
+ if (rep->status != IB_SIDR_SUCCESS) {
+ event.event = RDMA_CM_EVENT_UNREACHABLE;
+ event.status = ib_event->param.sidr_rep_rcvd.status;
+ break;
+ }
+ ret = cma_set_qkey(id_priv, rep->qkey);
+ if (ret) {
+ event.event = RDMA_CM_EVENT_ADDR_ERROR;
+ event.status = ret;
+ break;
+ }
+ ret = ib_init_ah_from_path(id_priv->id.device,
+ id_priv->id.port_num,
+ id_priv->id.route.path_rec,
+ &event.param.ud.ah_attr);
+ if (ret) {
+ event.event = RDMA_CM_EVENT_ADDR_ERROR;
+ event.status = ret;
+ break;
+ }
+ event.param.ud.qp_num = rep->qpn;
+ event.param.ud.qkey = rep->qkey;
+ event.event = RDMA_CM_EVENT_ESTABLISHED;
+ event.status = 0;
+ break;
+ default:
+ pr_err("RDMA CMA: unexpected IB CM event: %d\n",
+ ib_event->event);
+ goto out;
+ }
+
+ ret = id_priv->id.event_handler(&id_priv->id, &event);
+ if (ret) {
+ /* Destroy the CM ID by returning a non-zero value. */
+ id_priv->cm_id.ib = NULL;
+ cma_exch(id_priv, RDMA_CM_DESTROYING);
+ mutex_unlock(&id_priv->handler_mutex);
+ rdma_destroy_id(&id_priv->id);
+ return ret;
+ }
+out:
+ mutex_unlock(&id_priv->handler_mutex);
+ return ret;
+}
+
+static int cma_resolve_ib_udp(struct rdma_id_private *id_priv,
+ struct rdma_conn_param *conn_param)
+{
+ struct ib_cm_sidr_req_param req;
+ struct ib_cm_id *id;
+ void *private_data;
+ int offset, ret;
+
+ memset(&req, 0, sizeof req);
+ offset = cma_user_data_offset(id_priv);
+ req.private_data_len = offset + conn_param->private_data_len;
+ if (req.private_data_len < conn_param->private_data_len)
+ return -EINVAL;
+
+ if (req.private_data_len) {
+ private_data = kzalloc(req.private_data_len, GFP_ATOMIC);
+ if (!private_data)
+ return -ENOMEM;
+ } else {
+ private_data = NULL;
+ }
+
+ if (conn_param->private_data && conn_param->private_data_len)
+ memcpy((char *)private_data + offset, conn_param->private_data,
+ conn_param->private_data_len);
+
+ if (private_data) {
+ ret = cma_format_hdr(private_data, id_priv);
+ if (ret)
+ goto out;
+ req.private_data = private_data;
+ }
+
+ id = ib_create_cm_id(id_priv->id.device, cma_sidr_rep_handler,
+ id_priv);
+ if (IS_ERR(id)) {
+ ret = PTR_ERR(id);
+ goto out;
+ }
+ id_priv->cm_id.ib = id;
+
+ req.path = id_priv->id.route.path_rec;
+ req.service_id = rdma_get_service_id(&id_priv->id, cma_dst_addr(id_priv));
+ req.timeout_ms = 1 << (CMA_CM_RESPONSE_TIMEOUT - 8);
+ req.max_cm_retries = CMA_MAX_CM_RETRIES;
+
+ ret = ib_send_cm_sidr_req(id_priv->cm_id.ib, &req);
+ if (ret) {
+ ib_destroy_cm_id(id_priv->cm_id.ib);
+ id_priv->cm_id.ib = NULL;
+ }
+out:
+ kfree(private_data);
+ return ret;
+}
+
+static int cma_connect_ib(struct rdma_id_private *id_priv,
+ struct rdma_conn_param *conn_param)
+{
+ struct ib_cm_req_param req;
+ struct rdma_route *route;
+ void *private_data;
+ struct ib_cm_id *id;
+ int offset, ret;
+
+ memset(&req, 0, sizeof req);
+ offset = cma_user_data_offset(id_priv);
+ req.private_data_len = offset + conn_param->private_data_len;
+ if (req.private_data_len < conn_param->private_data_len)
+ return -EINVAL;
+
+ if (req.private_data_len) {
+ private_data = kzalloc(req.private_data_len, GFP_ATOMIC);
+ if (!private_data)
+ return -ENOMEM;
+ } else {
+ private_data = NULL;
+ }
+
+ if (conn_param->private_data && conn_param->private_data_len)
+ memcpy((char *)private_data + offset, conn_param->private_data,
+ conn_param->private_data_len);
+
+ id = ib_create_cm_id(id_priv->id.device, cma_ib_handler, id_priv);
+ if (IS_ERR(id)) {
+ ret = PTR_ERR(id);
+ goto out;
+ }
+ id_priv->cm_id.ib = id;
+
+ route = &id_priv->id.route;
+ if (private_data) {
+ ret = cma_format_hdr(private_data, id_priv);
+ if (ret)
+ goto out;
+ req.private_data = private_data;
+ }
+
+ req.primary_path = &route->path_rec[0];
+ if (route->num_paths == 2)
+ req.alternate_path = &route->path_rec[1];
+
+ req.service_id = rdma_get_service_id(&id_priv->id, cma_dst_addr(id_priv));
+ req.qp_num = id_priv->qp_num;
+ req.qp_type = id_priv->id.qp_type;
+ req.starting_psn = id_priv->seq_num;
+ req.responder_resources = conn_param->responder_resources;
+ req.initiator_depth = conn_param->initiator_depth;
+ req.flow_control = conn_param->flow_control;
+ req.retry_count = min_t(u8, 7, conn_param->retry_count);
+ req.rnr_retry_count = min_t(u8, 7, conn_param->rnr_retry_count);
+ req.remote_cm_response_timeout = CMA_CM_RESPONSE_TIMEOUT;
+ req.local_cm_response_timeout = CMA_CM_RESPONSE_TIMEOUT;
+ req.max_cm_retries = CMA_MAX_CM_RETRIES;
+ req.srq = id_priv->srq ? 1 : 0;
+
+ ret = ib_send_cm_req(id_priv->cm_id.ib, &req);
+out:
+ if (ret && !IS_ERR(id)) {
+ ib_destroy_cm_id(id);
+ id_priv->cm_id.ib = NULL;
+ }
+
+ kfree(private_data);
+ return ret;
+}
+
+static int cma_connect_iw(struct rdma_id_private *id_priv,
+ struct rdma_conn_param *conn_param)
+{
+ struct iw_cm_id *cm_id;
+ int ret;
+ struct iw_cm_conn_param iw_param;
+
+ cm_id = iw_create_cm_id(id_priv->id.device, cma_iw_handler, id_priv);
+ if (IS_ERR(cm_id))
+ return PTR_ERR(cm_id);
+
+ cm_id->tos = id_priv->tos;
+ id_priv->cm_id.iw = cm_id;
+
+ memcpy(&cm_id->local_addr, cma_src_addr(id_priv),
+ rdma_addr_size(cma_src_addr(id_priv)));
+ memcpy(&cm_id->remote_addr, cma_dst_addr(id_priv),
+ rdma_addr_size(cma_dst_addr(id_priv)));
+
+ ret = cma_modify_qp_rtr(id_priv, conn_param);
+ if (ret)
+ goto out;
+
+ if (conn_param) {
+ iw_param.ord = conn_param->initiator_depth;
+ iw_param.ird = conn_param->responder_resources;
+ iw_param.private_data = conn_param->private_data;
+ iw_param.private_data_len = conn_param->private_data_len;
+ iw_param.qpn = id_priv->id.qp ? id_priv->qp_num : conn_param->qp_num;
+ } else {
+ memset(&iw_param, 0, sizeof iw_param);
+ iw_param.qpn = id_priv->qp_num;
+ }
+ ret = iw_cm_connect(cm_id, &iw_param);
+out:
+ if (ret) {
+ iw_destroy_cm_id(cm_id);
+ id_priv->cm_id.iw = NULL;
+ }
+ return ret;
+}
+
+int rdma_connect(struct rdma_cm_id *id, struct rdma_conn_param *conn_param)
+{
+ struct rdma_id_private *id_priv;
+ int ret;
+
+ id_priv = container_of(id, struct rdma_id_private, id);
+ if (!cma_comp_exch(id_priv, RDMA_CM_ROUTE_RESOLVED, RDMA_CM_CONNECT))
+ return -EINVAL;
+
+ if (!id->qp) {
+ id_priv->qp_num = conn_param->qp_num;
+ id_priv->srq = conn_param->srq;
+ }
+
+ if (rdma_cap_ib_cm(id->device, id->port_num)) {
+ if (id->qp_type == IB_QPT_UD)
+ ret = cma_resolve_ib_udp(id_priv, conn_param);
+ else
+ ret = cma_connect_ib(id_priv, conn_param);
+ } else if (rdma_cap_iw_cm(id->device, id->port_num))
+ ret = cma_connect_iw(id_priv, conn_param);
+ else
+ ret = -ENOSYS;
+ if (ret)
+ goto err;
+
+ return 0;
+err:
+ cma_comp_exch(id_priv, RDMA_CM_CONNECT, RDMA_CM_ROUTE_RESOLVED);
+ return ret;
+}
+EXPORT_SYMBOL(rdma_connect);
+
+static int cma_accept_ib(struct rdma_id_private *id_priv,
+ struct rdma_conn_param *conn_param)
+{
+ struct ib_cm_rep_param rep;
+ int ret;
+
+ ret = cma_modify_qp_rtr(id_priv, conn_param);
+ if (ret)
+ goto out;
+
+ ret = cma_modify_qp_rts(id_priv, conn_param);
+ if (ret)
+ goto out;
+
+ memset(&rep, 0, sizeof rep);
+ rep.qp_num = id_priv->qp_num;
+ rep.starting_psn = id_priv->seq_num;
+ rep.private_data = conn_param->private_data;
+ rep.private_data_len = conn_param->private_data_len;
+ rep.responder_resources = conn_param->responder_resources;
+ rep.initiator_depth = conn_param->initiator_depth;
+ rep.failover_accepted = 0;
+ rep.flow_control = conn_param->flow_control;
+ rep.rnr_retry_count = min_t(u8, 7, conn_param->rnr_retry_count);
+ rep.srq = id_priv->srq ? 1 : 0;
+
+ ret = ib_send_cm_rep(id_priv->cm_id.ib, &rep);
+out:
+ return ret;
+}
+
+static int cma_accept_iw(struct rdma_id_private *id_priv,
+ struct rdma_conn_param *conn_param)
+{
+ struct iw_cm_conn_param iw_param;
+ int ret;
+
+ ret = cma_modify_qp_rtr(id_priv, conn_param);
+ if (ret)
+ return ret;
+
+ iw_param.ord = conn_param->initiator_depth;
+ iw_param.ird = conn_param->responder_resources;
+ iw_param.private_data = conn_param->private_data;
+ iw_param.private_data_len = conn_param->private_data_len;
+ if (id_priv->id.qp) {
+ iw_param.qpn = id_priv->qp_num;
+ } else
+ iw_param.qpn = conn_param->qp_num;
+
+ return iw_cm_accept(id_priv->cm_id.iw, &iw_param);
+}
+
+static int cma_send_sidr_rep(struct rdma_id_private *id_priv,
+ enum ib_cm_sidr_status status, u32 qkey,
+ const void *private_data, int private_data_len)
+{
+ struct ib_cm_sidr_rep_param rep;
+ int ret;
+
+ memset(&rep, 0, sizeof rep);
+ rep.status = status;
+ if (status == IB_SIDR_SUCCESS) {
+ ret = cma_set_qkey(id_priv, qkey);
+ if (ret)
+ return ret;
+ rep.qp_num = id_priv->qp_num;
+ rep.qkey = id_priv->qkey;
+ }
+ rep.private_data = private_data;
+ rep.private_data_len = private_data_len;
+
+ return ib_send_cm_sidr_rep(id_priv->cm_id.ib, &rep);
+}
+
+int rdma_accept(struct rdma_cm_id *id, struct rdma_conn_param *conn_param)
+{
+ struct rdma_id_private *id_priv;
+ int ret;
+
+ id_priv = container_of(id, struct rdma_id_private, id);
+
+ id_priv->owner = task_pid_nr(current);
+
+ if (!cma_comp(id_priv, RDMA_CM_CONNECT))
+ return -EINVAL;
+
+ if (!id->qp && conn_param) {
+ id_priv->qp_num = conn_param->qp_num;
+ id_priv->srq = conn_param->srq;
+ }
+
+ if (rdma_cap_ib_cm(id->device, id->port_num)) {
+ if (id->qp_type == IB_QPT_UD) {
+ if (conn_param)
+ ret = cma_send_sidr_rep(id_priv, IB_SIDR_SUCCESS,
+ conn_param->qkey,
+ conn_param->private_data,
+ conn_param->private_data_len);
+ else
+ ret = cma_send_sidr_rep(id_priv, IB_SIDR_SUCCESS,
+ 0, NULL, 0);
+ } else {
+ if (conn_param)
+ ret = cma_accept_ib(id_priv, conn_param);
+ else
+ ret = cma_rep_recv(id_priv);
+ }
+ } else if (rdma_cap_iw_cm(id->device, id->port_num))
+ ret = cma_accept_iw(id_priv, conn_param);
+ else
+ ret = -ENOSYS;
+
+ if (ret)
+ goto reject;
+
+ return 0;
+reject:
+ cma_modify_qp_err(id_priv);
+ rdma_reject(id, NULL, 0);
+ return ret;
+}
+EXPORT_SYMBOL(rdma_accept);
+
+int rdma_notify(struct rdma_cm_id *id, enum ib_event_type event)
+{
+ struct rdma_id_private *id_priv;
+ int ret;
+
+ id_priv = container_of(id, struct rdma_id_private, id);
+ if (!id_priv->cm_id.ib)
+ return -EINVAL;
+
+ switch (id->device->node_type) {
+ case RDMA_NODE_IB_CA:
+ ret = ib_cm_notify(id_priv->cm_id.ib, event);
+ break;
+ default:
+ ret = 0;
+ break;
+ }
+ return ret;
+}
+EXPORT_SYMBOL(rdma_notify);
+
+int rdma_reject(struct rdma_cm_id *id, const void *private_data,
+ u8 private_data_len)
+{
+ struct rdma_id_private *id_priv;
+ int ret;
+
+ id_priv = container_of(id, struct rdma_id_private, id);
+ if (!id_priv->cm_id.ib)
+ return -EINVAL;
+
+ if (rdma_cap_ib_cm(id->device, id->port_num)) {
+ if (id->qp_type == IB_QPT_UD)
+ ret = cma_send_sidr_rep(id_priv, IB_SIDR_REJECT, 0,
+ private_data, private_data_len);
+ else
+ ret = ib_send_cm_rej(id_priv->cm_id.ib,
+ IB_CM_REJ_CONSUMER_DEFINED, NULL,
+ 0, private_data, private_data_len);
+ } else if (rdma_cap_iw_cm(id->device, id->port_num)) {
+ ret = iw_cm_reject(id_priv->cm_id.iw,
+ private_data, private_data_len);
+ } else
+ ret = -ENOSYS;
+
+ return ret;
+}
+EXPORT_SYMBOL(rdma_reject);
+
+int rdma_disconnect(struct rdma_cm_id *id)
+{
+ struct rdma_id_private *id_priv;
+ int ret;
+
+ id_priv = container_of(id, struct rdma_id_private, id);
+ if (!id_priv->cm_id.ib)
+ return -EINVAL;
+
+ if (rdma_cap_ib_cm(id->device, id->port_num)) {
+ ret = cma_modify_qp_err(id_priv);
+ if (ret)
+ goto out;
+ /* Initiate or respond to a disconnect. */
+ if (ib_send_cm_dreq(id_priv->cm_id.ib, NULL, 0))
+ ib_send_cm_drep(id_priv->cm_id.ib, NULL, 0);
+ } else if (rdma_cap_iw_cm(id->device, id->port_num)) {
+ ret = iw_cm_disconnect(id_priv->cm_id.iw, 0);
+ } else
+ ret = -EINVAL;
+
+out:
+ return ret;
+}
+EXPORT_SYMBOL(rdma_disconnect);
+
+static int cma_ib_mc_handler(int status, struct ib_sa_multicast *multicast)
+{
+ struct rdma_id_private *id_priv;
+ struct cma_multicast *mc = multicast->context;
+ struct rdma_cm_event event;
+ int ret = 0;
+
+ id_priv = mc->id_priv;
+ mutex_lock(&id_priv->handler_mutex);
+ if (id_priv->state != RDMA_CM_ADDR_BOUND &&
+ id_priv->state != RDMA_CM_ADDR_RESOLVED)
+ goto out;
+
+ if (!status)
+ status = cma_set_qkey(id_priv, be32_to_cpu(multicast->rec.qkey));
+ mutex_lock(&id_priv->qp_mutex);
+ if (!status && id_priv->id.qp)
+ status = ib_attach_mcast(id_priv->id.qp, &multicast->rec.mgid,
+ be16_to_cpu(multicast->rec.mlid));
+ mutex_unlock(&id_priv->qp_mutex);
+
+ memset(&event, 0, sizeof event);
+ event.status = status;
+ event.param.ud.private_data = mc->context;
+ if (!status) {
+ struct rdma_dev_addr *dev_addr =
+ &id_priv->id.route.addr.dev_addr;
+ struct net_device *ndev =
+ dev_get_by_index(dev_addr->net, dev_addr->bound_dev_if);
+ enum ib_gid_type gid_type =
+ id_priv->cma_dev->default_gid_type[id_priv->id.port_num -
+ rdma_start_port(id_priv->cma_dev->device)];
+
+ event.event = RDMA_CM_EVENT_MULTICAST_JOIN;
+ ib_init_ah_from_mcmember(id_priv->id.device,
+ id_priv->id.port_num, &multicast->rec,
+ ndev, gid_type,
+ &event.param.ud.ah_attr);
+ event.param.ud.qp_num = 0xFFFFFF;
+ event.param.ud.qkey = be32_to_cpu(multicast->rec.qkey);
+ if (ndev)
+ dev_put(ndev);
+ } else
+ event.event = RDMA_CM_EVENT_MULTICAST_ERROR;
+
+ ret = id_priv->id.event_handler(&id_priv->id, &event);
+ if (ret) {
+ cma_exch(id_priv, RDMA_CM_DESTROYING);
+ mutex_unlock(&id_priv->handler_mutex);
+ rdma_destroy_id(&id_priv->id);
+ return 0;
+ }
+
+out:
+ mutex_unlock(&id_priv->handler_mutex);
+ return 0;
+}
+
+static void cma_set_mgid(struct rdma_id_private *id_priv,
+ struct sockaddr *addr, union ib_gid *mgid)
+{
+ unsigned char mc_map[MAX_ADDR_LEN];
+ struct rdma_dev_addr *dev_addr = &id_priv->id.route.addr.dev_addr;
+ struct sockaddr_in *sin = (struct sockaddr_in *) addr;
+ struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *) addr;
+
+ if (cma_any_addr(addr)) {
+ memset(mgid, 0, sizeof *mgid);
+ } else if ((addr->sa_family == AF_INET6) &&
+ ((be32_to_cpu(sin6->sin6_addr.s6_addr32[0]) & 0xFFF0FFFF) ==
+ 0xFF10A01B)) {
+ /* IPv6 address is an SA assigned MGID. */
+ memcpy(mgid, &sin6->sin6_addr, sizeof *mgid);
+ } else if (addr->sa_family == AF_IB) {
+ memcpy(mgid, &((struct sockaddr_ib *) addr)->sib_addr, sizeof *mgid);
+ } else if (addr->sa_family == AF_INET6) {
+ ipv6_ib_mc_map(&sin6->sin6_addr, dev_addr->broadcast, mc_map);
+ if (id_priv->id.ps == RDMA_PS_UDP)
+ mc_map[7] = 0x01; /* Use RDMA CM signature */
+ *mgid = *(union ib_gid *) (mc_map + 4);
+ } else {
+ ip_ib_mc_map(sin->sin_addr.s_addr, dev_addr->broadcast, mc_map);
+ if (id_priv->id.ps == RDMA_PS_UDP)
+ mc_map[7] = 0x01; /* Use RDMA CM signature */
+ *mgid = *(union ib_gid *) (mc_map + 4);
+ }
+}
+
+static void cma_query_sa_classport_info_cb(int status,
+ struct ib_class_port_info *rec,
+ void *context)
+{
+ struct class_port_info_context *cb_ctx = context;
+
+ WARN_ON(!context);
+
+ if (status || !rec) {
+ pr_debug("RDMA CM: %s port %u failed query ClassPortInfo status: %d\n",
+ cb_ctx->device->name, cb_ctx->port_num, status);
+ goto out;
+ }
+
+ memcpy(cb_ctx->class_port_info, rec, sizeof(struct ib_class_port_info));
+
+out:
+ complete(&cb_ctx->done);
+}
+
+static int cma_query_sa_classport_info(struct ib_device *device, u8 port_num,
+ struct ib_class_port_info *class_port_info)
+{
+ struct class_port_info_context *cb_ctx;
+ int ret;
+
+ cb_ctx = kmalloc(sizeof(*cb_ctx), GFP_KERNEL);
+ if (!cb_ctx)
+ return -ENOMEM;
+
+ cb_ctx->device = device;
+ cb_ctx->class_port_info = class_port_info;
+ cb_ctx->port_num = port_num;
+ init_completion(&cb_ctx->done);
+
+ ret = ib_sa_classport_info_rec_query(&sa_client, device, port_num,
+ CMA_QUERY_CLASSPORT_INFO_TIMEOUT,
+ GFP_KERNEL, cma_query_sa_classport_info_cb,
+ cb_ctx, &cb_ctx->sa_query);
+ if (ret < 0) {
+ pr_err("RDMA CM: %s port %u failed to send ClassPortInfo query, ret: %d\n",
+ device->name, port_num, ret);
+ goto out;
+ }
+
+ wait_for_completion(&cb_ctx->done);
+
+out:
+ kfree(cb_ctx);
+ return ret;
+}
+
+static int cma_join_ib_multicast(struct rdma_id_private *id_priv,
+ struct cma_multicast *mc)
+{
+ struct ib_sa_mcmember_rec rec;
+ struct ib_class_port_info class_port_info;
+ struct rdma_dev_addr *dev_addr = &id_priv->id.route.addr.dev_addr;
+ ib_sa_comp_mask comp_mask;
+ int ret;
+
+ ib_addr_get_mgid(dev_addr, &rec.mgid);
+ ret = ib_sa_get_mcmember_rec(id_priv->id.device, id_priv->id.port_num,
+ &rec.mgid, &rec);
+ if (ret)
+ return ret;
+
+ ret = cma_set_qkey(id_priv, 0);
+ if (ret)
+ return ret;
+
+ cma_set_mgid(id_priv, (struct sockaddr *) &mc->addr, &rec.mgid);
+ rec.qkey = cpu_to_be32(id_priv->qkey);
+ rdma_addr_get_sgid(dev_addr, &rec.port_gid);
+ rec.pkey = cpu_to_be16(ib_addr_get_pkey(dev_addr));
+ rec.join_state = mc->join_state;
+
+ if (rec.join_state == BIT(SENDONLY_FULLMEMBER_JOIN)) {
+ ret = cma_query_sa_classport_info(id_priv->id.device,
+ id_priv->id.port_num,
+ &class_port_info);
+
+ if (ret)
+ return ret;
+
+ if (!(ib_get_cpi_capmask2(&class_port_info) &
+ IB_SA_CAP_MASK2_SENDONLY_FULL_MEM_SUPPORT)) {
+ pr_warn("RDMA CM: %s port %u Unable to multicast join\n"
+ "RDMA CM: SM doesn't support Send Only Full Member option\n",
+ id_priv->id.device->name, id_priv->id.port_num);
+ return -EOPNOTSUPP;
+ }
+ }
+
+ comp_mask = IB_SA_MCMEMBER_REC_MGID | IB_SA_MCMEMBER_REC_PORT_GID |
+ IB_SA_MCMEMBER_REC_PKEY | IB_SA_MCMEMBER_REC_JOIN_STATE |
+ IB_SA_MCMEMBER_REC_QKEY | IB_SA_MCMEMBER_REC_SL |
+ IB_SA_MCMEMBER_REC_FLOW_LABEL |
+ IB_SA_MCMEMBER_REC_TRAFFIC_CLASS;
+
+ if (id_priv->id.ps == RDMA_PS_IPOIB)
+ comp_mask |= IB_SA_MCMEMBER_REC_RATE |
+ IB_SA_MCMEMBER_REC_RATE_SELECTOR |
+ IB_SA_MCMEMBER_REC_MTU_SELECTOR |
+ IB_SA_MCMEMBER_REC_MTU |
+ IB_SA_MCMEMBER_REC_HOP_LIMIT;
+
+ mc->multicast.ib = ib_sa_join_multicast(&sa_client, id_priv->id.device,
+ id_priv->id.port_num, &rec,
+ comp_mask, GFP_KERNEL,
+ cma_ib_mc_handler, mc);
+ return PTR_ERR_OR_ZERO(mc->multicast.ib);
+}
+
+static void iboe_mcast_work_handler(struct work_struct *work)
+{
+ struct iboe_mcast_work *mw = container_of(work, struct iboe_mcast_work, work);
+ struct cma_multicast *mc = mw->mc;
+ struct ib_sa_multicast *m = mc->multicast.ib;
+
+ mc->multicast.ib->context = mc;
+ cma_ib_mc_handler(0, m);
+ kref_put(&mc->mcref, release_mc);
+ kfree(mw);
+}
+
+static void cma_iboe_set_mgid(struct sockaddr *addr, union ib_gid *mgid)
+{
+ struct sockaddr_in *sin = (struct sockaddr_in *)addr;
+ struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *)addr;
+
+ if (cma_any_addr(addr)) {
+ memset(mgid, 0, sizeof *mgid);
+ } else if (addr->sa_family == AF_INET6) {
+ memcpy(mgid, &sin6->sin6_addr, sizeof *mgid);
+ } else {
+ mgid->raw[0] = 0xff;
+ mgid->raw[1] = 0x0e;
+ mgid->raw[2] = 0;
+ mgid->raw[3] = 0;
+ mgid->raw[4] = 0;
+ mgid->raw[5] = 0;
+ mgid->raw[6] = 0;
+ mgid->raw[7] = 0;
+ mgid->raw[8] = 0;
+ mgid->raw[9] = 0;
+ mgid->raw[10] = 0xff;
+ mgid->raw[11] = 0xff;
+ *(__be32 *)(&mgid->raw[12]) = sin->sin_addr.s_addr;
+ }
+}
+
+static int cma_iboe_join_multicast(struct rdma_id_private *id_priv,
+ struct cma_multicast *mc)
+{
+ struct iboe_mcast_work *work;
+ struct rdma_dev_addr *dev_addr = &id_priv->id.route.addr.dev_addr;
+ int err = 0;
+ struct sockaddr *addr = (struct sockaddr *)&mc->addr;
+ struct net_device *ndev = NULL;
+ enum ib_gid_type gid_type;
+ bool send_only;
+
+ send_only = mc->join_state == BIT(SENDONLY_FULLMEMBER_JOIN);
+
+ if (cma_zero_addr((struct sockaddr *)&mc->addr))
+ return -EINVAL;
+
+ work = kzalloc(sizeof *work, GFP_KERNEL);
+ if (!work)
+ return -ENOMEM;
+
+ mc->multicast.ib = kzalloc(sizeof(struct ib_sa_multicast), GFP_KERNEL);
+ if (!mc->multicast.ib) {
+ err = -ENOMEM;
+ goto out1;
+ }
+
+ cma_iboe_set_mgid(addr, &mc->multicast.ib->rec.mgid);
+
+ mc->multicast.ib->rec.pkey = cpu_to_be16(0xffff);
+ if (id_priv->id.ps == RDMA_PS_UDP)
+ mc->multicast.ib->rec.qkey = cpu_to_be32(RDMA_UDP_QKEY);
+
+ if (dev_addr->bound_dev_if)
+ ndev = dev_get_by_index(dev_addr->net, dev_addr->bound_dev_if);
+ if (!ndev) {
+ err = -ENODEV;
+ goto out2;
+ }
+ mc->multicast.ib->rec.rate = iboe_get_rate(ndev);
+ mc->multicast.ib->rec.hop_limit = 1;
+ mc->multicast.ib->rec.mtu = iboe_get_mtu(ndev->if_mtu);
+
+ gid_type = id_priv->cma_dev->default_gid_type[id_priv->id.port_num -
+ rdma_start_port(id_priv->cma_dev->device)];
+ if (addr->sa_family == AF_INET) {
+ if (gid_type == IB_GID_TYPE_ROCE_UDP_ENCAP) {
+ mc->multicast.ib->rec.hop_limit = IPV6_DEFAULT_HOPLIMIT;
+ if (!send_only) {
+ mc->igmp_joined = true;
+ }
+ }
+ } else {
+ if (gid_type == IB_GID_TYPE_ROCE_UDP_ENCAP)
+ err = -ENOTSUPP;
+ }
+ dev_put(ndev);
+ if (err || !mc->multicast.ib->rec.mtu) {
+ if (!err)
+ err = -EINVAL;
+ goto out2;
+ }
+ rdma_ip2gid((struct sockaddr *)&id_priv->id.route.addr.src_addr,
+ &mc->multicast.ib->rec.port_gid);
+ work->id = id_priv;
+ work->mc = mc;
+ INIT_WORK(&work->work, iboe_mcast_work_handler);
+ kref_get(&mc->mcref);
+ queue_work(cma_wq, &work->work);
+
+ return 0;
+
+out2:
+ kfree(mc->multicast.ib);
+out1:
+ kfree(work);
+ return err;
+}
+
+int rdma_join_multicast(struct rdma_cm_id *id, struct sockaddr *addr,
+ u8 join_state, void *context)
+{
+ struct rdma_id_private *id_priv;
+ struct cma_multicast *mc;
+ int ret;
+
+ id_priv = container_of(id, struct rdma_id_private, id);
+ if (!cma_comp(id_priv, RDMA_CM_ADDR_BOUND) &&
+ !cma_comp(id_priv, RDMA_CM_ADDR_RESOLVED))
+ return -EINVAL;
+
+ mc = kmalloc(sizeof *mc, GFP_KERNEL);
+ if (!mc)
+ return -ENOMEM;
+
+ memcpy(&mc->addr, addr, rdma_addr_size(addr));
+ mc->context = context;
+ mc->id_priv = id_priv;
+ mc->igmp_joined = false;
+ mc->join_state = join_state;
+ spin_lock(&id_priv->lock);
+ list_add(&mc->list, &id_priv->mc_list);
+ spin_unlock(&id_priv->lock);
+
+ if (rdma_protocol_roce(id->device, id->port_num)) {
+ kref_init(&mc->mcref);
+ ret = cma_iboe_join_multicast(id_priv, mc);
+ } else if (rdma_cap_ib_mcast(id->device, id->port_num))
+ ret = cma_join_ib_multicast(id_priv, mc);
+ else
+ ret = -ENOSYS;
+
+ if (ret) {
+ spin_lock_irq(&id_priv->lock);
+ list_del(&mc->list);
+ spin_unlock_irq(&id_priv->lock);
+ kfree(mc);
+ }
+ return ret;
+}
+EXPORT_SYMBOL(rdma_join_multicast);
+
+void rdma_leave_multicast(struct rdma_cm_id *id, struct sockaddr *addr)
+{
+ struct rdma_id_private *id_priv;
+ struct cma_multicast *mc;
+
+ id_priv = container_of(id, struct rdma_id_private, id);
+ spin_lock_irq(&id_priv->lock);
+ list_for_each_entry(mc, &id_priv->mc_list, list) {
+ if (!memcmp(&mc->addr, addr, rdma_addr_size(addr))) {
+ list_del(&mc->list);
+ spin_unlock_irq(&id_priv->lock);
+
+ if (id->qp)
+ ib_detach_mcast(id->qp,
+ &mc->multicast.ib->rec.mgid,
+ be16_to_cpu(mc->multicast.ib->rec.mlid));
+
+ BUG_ON(id_priv->cma_dev->device != id->device);
+
+ if (rdma_cap_ib_mcast(id->device, id->port_num)) {
+ ib_sa_free_multicast(mc->multicast.ib);
+ kfree(mc);
+ } else if (rdma_protocol_roce(id->device, id->port_num)) {
+ if (mc->igmp_joined) {
+ struct rdma_dev_addr *dev_addr =
+ &id->route.addr.dev_addr;
+ struct net_device *ndev = NULL;
+
+ if (dev_addr->bound_dev_if)
+ ndev = dev_get_by_index(dev_addr->net,
+ dev_addr->bound_dev_if);
+ if (ndev) {
+ dev_put(ndev);
+ }
+ mc->igmp_joined = false;
+ }
+ kref_put(&mc->mcref, release_mc);
+ }
+ return;
+ }
+ }
+ spin_unlock_irq(&id_priv->lock);
+}
+EXPORT_SYMBOL(rdma_leave_multicast);
+
+static int
+sysctl_cma_default_roce_mode(SYSCTL_HANDLER_ARGS)
+{
+ struct cma_device *cma_dev = arg1;
+ const int port = arg2;
+ char buf[64];
+ int error;
+
+ strlcpy(buf, ib_cache_gid_type_str(
+ cma_get_default_gid_type(cma_dev, port)), sizeof(buf));
+
+ error = sysctl_handle_string(oidp, buf, sizeof(buf), req);
+ if (error != 0 || req->newptr == NULL)
+ goto done;
+
+ error = ib_cache_gid_parse_type_str(buf);
+ if (error < 0) {
+ error = EINVAL;
+ goto done;
+ }
+
+ cma_set_default_gid_type(cma_dev, port, error);
+ error = 0;
+done:
+ return (error);
+}
+
+static void cma_add_one(struct ib_device *device)
+{
+ struct cma_device *cma_dev;
+ struct rdma_id_private *id_priv;
+ unsigned int i;
+ unsigned long supported_gids = 0;
+
+ cma_dev = kmalloc(sizeof *cma_dev, GFP_KERNEL);
+ if (!cma_dev)
+ return;
+
+ sysctl_ctx_init(&cma_dev->sysctl_ctx);
+
+ cma_dev->device = device;
+ cma_dev->default_gid_type = kcalloc(device->phys_port_cnt,
+ sizeof(*cma_dev->default_gid_type),
+ GFP_KERNEL);
+ if (!cma_dev->default_gid_type) {
+ kfree(cma_dev);
+ return;
+ }
+ for (i = rdma_start_port(device); i <= rdma_end_port(device); i++) {
+ supported_gids = roce_gid_type_mask_support(device, i);
+ WARN_ON(!supported_gids);
+ cma_dev->default_gid_type[i - rdma_start_port(device)] =
+ find_first_bit(&supported_gids, BITS_PER_LONG);
+ }
+
+ init_completion(&cma_dev->comp);
+ atomic_set(&cma_dev->refcount, 1);
+ INIT_LIST_HEAD(&cma_dev->id_list);
+ ib_set_client_data(device, &cma_client, cma_dev);
+
+ mutex_lock(&lock);
+ list_add_tail(&cma_dev->list, &dev_list);
+ list_for_each_entry(id_priv, &listen_any_list, list)
+ cma_listen_on_dev(id_priv, cma_dev);
+ mutex_unlock(&lock);
+
+ for (i = rdma_start_port(device); i <= rdma_end_port(device); i++) {
+ char buf[64];
+
+ snprintf(buf, sizeof(buf), "default_roce_mode_port%d", i);
+
+ (void) SYSCTL_ADD_PROC(&cma_dev->sysctl_ctx,
+ SYSCTL_CHILDREN(device->ports_parent->parent->oidp),
+ OID_AUTO, buf, CTLTYPE_STRING | CTLFLAG_RWTUN | CTLFLAG_MPSAFE,
+ cma_dev, i, &sysctl_cma_default_roce_mode, "A",
+ "Default RoCE mode. Valid values: IB/RoCE v1 and RoCE v2");
+ }
+}
+
+static int cma_remove_id_dev(struct rdma_id_private *id_priv)
+{
+ struct rdma_cm_event event;
+ enum rdma_cm_state state;
+ int ret = 0;
+
+ /* Record that we want to remove the device */
+ state = cma_exch(id_priv, RDMA_CM_DEVICE_REMOVAL);
+ if (state == RDMA_CM_DESTROYING)
+ return 0;
+
+ cma_cancel_operation(id_priv, state);
+ mutex_lock(&id_priv->handler_mutex);
+
+ /* Check for destruction from another callback. */
+ if (!cma_comp(id_priv, RDMA_CM_DEVICE_REMOVAL))
+ goto out;
+
+ memset(&event, 0, sizeof event);
+ event.event = RDMA_CM_EVENT_DEVICE_REMOVAL;
+ ret = id_priv->id.event_handler(&id_priv->id, &event);
+out:
+ mutex_unlock(&id_priv->handler_mutex);
+ return ret;
+}
+
+static void cma_process_remove(struct cma_device *cma_dev)
+{
+ struct rdma_id_private *id_priv;
+ int ret;
+
+ mutex_lock(&lock);
+ while (!list_empty(&cma_dev->id_list)) {
+ id_priv = list_entry(cma_dev->id_list.next,
+ struct rdma_id_private, list);
+
+ list_del(&id_priv->listen_list);
+ list_del_init(&id_priv->list);
+ atomic_inc(&id_priv->refcount);
+ mutex_unlock(&lock);
+
+ ret = id_priv->internal_id ? 1 : cma_remove_id_dev(id_priv);
+ cma_deref_id(id_priv);
+ if (ret)
+ rdma_destroy_id(&id_priv->id);
+
+ mutex_lock(&lock);
+ }
+ mutex_unlock(&lock);
+
+ cma_deref_dev(cma_dev);
+ wait_for_completion(&cma_dev->comp);
+}
+
+static void cma_remove_one(struct ib_device *device, void *client_data)
+{
+ struct cma_device *cma_dev = client_data;
+
+ if (!cma_dev)
+ return;
+
+ mutex_lock(&lock);
+ list_del(&cma_dev->list);
+ mutex_unlock(&lock);
+
+ cma_process_remove(cma_dev);
+ sysctl_ctx_free(&cma_dev->sysctl_ctx);
+ kfree(cma_dev->default_gid_type);
+ kfree(cma_dev);
+}
+
+static void cma_init_vnet(void *arg)
+{
+ struct cma_pernet *pernet = &VNET(cma_pernet);
+
+ idr_init(&pernet->tcp_ps);
+ idr_init(&pernet->udp_ps);
+ idr_init(&pernet->ipoib_ps);
+ idr_init(&pernet->ib_ps);
+}
+VNET_SYSINIT(cma_init_vnet, SI_SUB_OFED_MODINIT - 1, SI_ORDER_FIRST, cma_init_vnet, NULL);
+
+static void cma_destroy_vnet(void *arg)
+{
+ struct cma_pernet *pernet = &VNET(cma_pernet);
+
+ idr_destroy(&pernet->tcp_ps);
+ idr_destroy(&pernet->udp_ps);
+ idr_destroy(&pernet->ipoib_ps);
+ idr_destroy(&pernet->ib_ps);
+}
+VNET_SYSUNINIT(cma_destroy_vnet, SI_SUB_OFED_MODINIT - 1, SI_ORDER_SECOND, cma_destroy_vnet, NULL);
+
+static int __init cma_init(void)
+{
+ int ret;
+
+ cma_wq = alloc_ordered_workqueue("rdma_cm", WQ_MEM_RECLAIM);
+ if (!cma_wq)
+ return -ENOMEM;
+
+ ib_sa_register_client(&sa_client);
+ rdma_addr_register_client(&addr_client);
+
+ ret = ib_register_client(&cma_client);
+ if (ret)
+ goto err;
+
+ cma_configfs_init();
+
+ return 0;
+
+err:
+ rdma_addr_unregister_client(&addr_client);
+ ib_sa_unregister_client(&sa_client);
+ destroy_workqueue(cma_wq);
+ return ret;
+}
+
+static void __exit cma_cleanup(void)
+{
+ cma_configfs_exit();
+ ib_unregister_client(&cma_client);
+ rdma_addr_unregister_client(&addr_client);
+ ib_sa_unregister_client(&sa_client);
+ destroy_workqueue(cma_wq);
+}
+
+module_init(cma_init);
+module_exit(cma_cleanup);
diff --git a/sys/ofed/drivers/infiniband/core/ib_cq.c b/sys/ofed/drivers/infiniband/core/ib_cq.c
new file mode 100644
index 0000000..9f79f73
--- /dev/null
+++ b/sys/ofed/drivers/infiniband/core/ib_cq.c
@@ -0,0 +1,154 @@
+/*
+ * Copyright (c) 2017 Mellanox Technologies Ltd. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#include <linux/module.h>
+#include <linux/err.h>
+#include <linux/slab.h>
+
+#include <rdma/ib_verbs.h>
+
+#define IB_CQ_POLL_MAX 16
+/* maximum number of completions per poll loop */
+#define IB_CQ_POLL_BUDGET 65536
+#define IB_CQ_POLL_FLAGS (IB_CQ_NEXT_COMP | IB_CQ_REPORT_MISSED_EVENTS)
+
+static void
+ib_cq_poll_work(struct work_struct *work)
+{
+ struct ib_wc ib_wc[IB_CQ_POLL_MAX];
+ struct ib_cq *cq = container_of(work, struct ib_cq, work);
+ int total = 0;
+ int i;
+ int n;
+
+ while (1) {
+ n = ib_poll_cq(cq, IB_CQ_POLL_MAX, ib_wc);
+ for (i = 0; i < n; i++) {
+ struct ib_wc *wc = ib_wc + i;
+
+ if (wc->wr_cqe != NULL)
+ wc->wr_cqe->done(cq, wc);
+ }
+
+ if (n != IB_CQ_POLL_MAX) {
+ if (ib_req_notify_cq(cq, IB_CQ_POLL_FLAGS) > 0)
+ break;
+ else
+ return;
+ }
+ total += n;
+ if (total >= IB_CQ_POLL_BUDGET)
+ break;
+ }
+
+ /* give other work structs a chance */
+ queue_work(ib_comp_wq, &cq->work);
+}
+
+static void
+ib_cq_completion_workqueue(struct ib_cq *cq, void *private)
+{
+ queue_work(ib_comp_wq, &cq->work);
+}
+
+struct ib_cq *
+ib_alloc_cq(struct ib_device *dev, void *private,
+ int nr_cqe, int comp_vector, enum ib_poll_context poll_ctx)
+{
+ struct ib_cq_init_attr cq_attr = {
+ .cqe = nr_cqe,
+ .comp_vector = comp_vector,
+ };
+ struct ib_cq *cq;
+
+ /*
+ * Check for invalid parameters early on to avoid
+ * extra error handling code:
+ */
+ switch (poll_ctx) {
+ case IB_POLL_DIRECT:
+ case IB_POLL_SOFTIRQ:
+ case IB_POLL_WORKQUEUE:
+ break;
+ default:
+ return (ERR_PTR(-EINVAL));
+ }
+
+ cq = dev->create_cq(dev, &cq_attr, NULL, NULL);
+ if (IS_ERR(cq))
+ return (cq);
+
+ cq->device = dev;
+ cq->uobject = NULL;
+ cq->event_handler = NULL;
+ cq->cq_context = private;
+ cq->poll_ctx = poll_ctx;
+ atomic_set(&cq->usecnt, 0);
+
+ switch (poll_ctx) {
+ case IB_POLL_DIRECT:
+ cq->comp_handler = NULL; /* no hardware completions */
+ break;
+ case IB_POLL_SOFTIRQ:
+ case IB_POLL_WORKQUEUE:
+ cq->comp_handler = ib_cq_completion_workqueue;
+ INIT_WORK(&cq->work, ib_cq_poll_work);
+ ib_req_notify_cq(cq, IB_CQ_NEXT_COMP);
+ break;
+ default:
+ break;
+ }
+ return (cq);
+}
+EXPORT_SYMBOL(ib_alloc_cq);
+
+void
+ib_free_cq(struct ib_cq *cq)
+{
+
+ if (WARN_ON_ONCE(atomic_read(&cq->usecnt) != 0))
+ return;
+
+ switch (cq->poll_ctx) {
+ case IB_POLL_DIRECT:
+ break;
+ case IB_POLL_SOFTIRQ:
+ case IB_POLL_WORKQUEUE:
+ flush_work(&cq->work);
+ break;
+ default:
+ break;
+ }
+
+ (void)cq->device->destroy_cq(cq);
+}
+EXPORT_SYMBOL(ib_free_cq);
diff --git a/sys/ofed/drivers/infiniband/core/ib_device.c b/sys/ofed/drivers/infiniband/core/ib_device.c
new file mode 100644
index 0000000..9a7c8a0
--- /dev/null
+++ b/sys/ofed/drivers/infiniband/core/ib_device.c
@@ -0,0 +1,1048 @@
+/*
+ * Copyright (c) 2004 Topspin Communications. All rights reserved.
+ * Copyright (c) 2005 Sun Microsystems, Inc. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#include <linux/module.h>
+#include <linux/string.h>
+#include <linux/errno.h>
+#include <linux/kernel.h>
+#include <linux/slab.h>
+#include <linux/mutex.h>
+#include <linux/netdevice.h>
+#include <rdma/ib_addr.h>
+#include <rdma/ib_cache.h>
+
+#include "core_priv.h"
+
+MODULE_AUTHOR("Roland Dreier");
+MODULE_DESCRIPTION("core kernel InfiniBand API");
+MODULE_LICENSE("Dual BSD/GPL");
+
+struct ib_client_data {
+ struct list_head list;
+ struct ib_client *client;
+ void * data;
+ /* The device or client is going down. Do not call client or device
+ * callbacks other than remove(). */
+ bool going_down;
+};
+
+struct workqueue_struct *ib_comp_wq;
+struct workqueue_struct *ib_wq;
+EXPORT_SYMBOL_GPL(ib_wq);
+
+/* The device_list and client_list contain devices and clients after their
+ * registration has completed, and the devices and clients are removed
+ * during unregistration. */
+static LIST_HEAD(device_list);
+static LIST_HEAD(client_list);
+
+/*
+ * device_mutex and lists_rwsem protect access to both device_list and
+ * client_list. device_mutex protects writer access by device and client
+ * registration / de-registration. lists_rwsem protects reader access to
+ * these lists. Iterators of these lists must lock it for read, while updates
+ * to the lists must be done with a write lock. A special case is when the
+ * device_mutex is locked. In this case locking the lists for read access is
+ * not necessary as the device_mutex implies it.
+ *
+ * lists_rwsem also protects access to the client data list.
+ */
+static DEFINE_MUTEX(device_mutex);
+static DECLARE_RWSEM(lists_rwsem);
+
+
+static int ib_device_check_mandatory(struct ib_device *device)
+{
+#define IB_MANDATORY_FUNC(x) { offsetof(struct ib_device, x), #x }
+ static const struct {
+ size_t offset;
+ char *name;
+ } mandatory_table[] = {
+ IB_MANDATORY_FUNC(query_device),
+ IB_MANDATORY_FUNC(query_port),
+ IB_MANDATORY_FUNC(query_pkey),
+ IB_MANDATORY_FUNC(query_gid),
+ IB_MANDATORY_FUNC(alloc_pd),
+ IB_MANDATORY_FUNC(dealloc_pd),
+ IB_MANDATORY_FUNC(create_ah),
+ IB_MANDATORY_FUNC(destroy_ah),
+ IB_MANDATORY_FUNC(create_qp),
+ IB_MANDATORY_FUNC(modify_qp),
+ IB_MANDATORY_FUNC(destroy_qp),
+ IB_MANDATORY_FUNC(post_send),
+ IB_MANDATORY_FUNC(post_recv),
+ IB_MANDATORY_FUNC(create_cq),
+ IB_MANDATORY_FUNC(destroy_cq),
+ IB_MANDATORY_FUNC(poll_cq),
+ IB_MANDATORY_FUNC(req_notify_cq),
+ IB_MANDATORY_FUNC(get_dma_mr),
+ IB_MANDATORY_FUNC(dereg_mr),
+ IB_MANDATORY_FUNC(get_port_immutable)
+ };
+ int i;
+
+ for (i = 0; i < ARRAY_SIZE(mandatory_table); ++i) {
+ if (!*(void **) ((char *) device + mandatory_table[i].offset)) {
+ pr_warn("Device %s is missing mandatory function %s\n",
+ device->name, mandatory_table[i].name);
+ return -EINVAL;
+ }
+ }
+
+ return 0;
+}
+
+static struct ib_device *__ib_device_get_by_name(const char *name)
+{
+ struct ib_device *device;
+
+ list_for_each_entry(device, &device_list, core_list)
+ if (!strncmp(name, device->name, IB_DEVICE_NAME_MAX))
+ return device;
+
+ return NULL;
+}
+
+
+static int alloc_name(char *name)
+{
+ unsigned long *inuse;
+ char buf[IB_DEVICE_NAME_MAX];
+ struct ib_device *device;
+ int i;
+
+ inuse = (unsigned long *) get_zeroed_page(GFP_KERNEL);
+ if (!inuse)
+ return -ENOMEM;
+
+ list_for_each_entry(device, &device_list, core_list) {
+ if (!sscanf(device->name, name, &i))
+ continue;
+ if (i < 0 || i >= PAGE_SIZE * 8)
+ continue;
+ snprintf(buf, sizeof buf, name, i);
+ if (!strncmp(buf, device->name, IB_DEVICE_NAME_MAX))
+ set_bit(i, inuse);
+ }
+
+ i = find_first_zero_bit(inuse, PAGE_SIZE * 8);
+ free_page((unsigned long) inuse);
+ snprintf(buf, sizeof buf, name, i);
+
+ if (__ib_device_get_by_name(buf))
+ return -ENFILE;
+
+ strlcpy(name, buf, IB_DEVICE_NAME_MAX);
+ return 0;
+}
+
+static void ib_device_release(struct device *device)
+{
+ struct ib_device *dev = container_of(device, struct ib_device, dev);
+
+ ib_cache_release_one(dev);
+ kfree(dev->port_immutable);
+ kfree(dev);
+}
+
+static struct class ib_class = {
+ .name = "infiniband",
+ .dev_release = ib_device_release,
+};
+
+/**
+ * ib_alloc_device - allocate an IB device struct
+ * @size:size of structure to allocate
+ *
+ * Low-level drivers should use ib_alloc_device() to allocate &struct
+ * ib_device. @size is the size of the structure to be allocated,
+ * including any private data used by the low-level driver.
+ * ib_dealloc_device() must be used to free structures allocated with
+ * ib_alloc_device().
+ */
+struct ib_device *ib_alloc_device(size_t size)
+{
+ struct ib_device *device;
+
+ if (WARN_ON(size < sizeof(struct ib_device)))
+ return NULL;
+
+ device = kzalloc(size, GFP_KERNEL);
+ if (!device)
+ return NULL;
+
+ device->dev.parent = &linux_root_device;
+ device->dev.class = &ib_class;
+ device_initialize(&device->dev);
+
+ dev_set_drvdata(&device->dev, device);
+
+ INIT_LIST_HEAD(&device->event_handler_list);
+ spin_lock_init(&device->event_handler_lock);
+ spin_lock_init(&device->client_data_lock);
+ INIT_LIST_HEAD(&device->client_data_list);
+ INIT_LIST_HEAD(&device->port_list);
+
+ return device;
+}
+EXPORT_SYMBOL(ib_alloc_device);
+
+/**
+ * ib_dealloc_device - free an IB device struct
+ * @device:structure to free
+ *
+ * Free a structure allocated with ib_alloc_device().
+ */
+void ib_dealloc_device(struct ib_device *device)
+{
+ WARN_ON(device->reg_state != IB_DEV_UNREGISTERED &&
+ device->reg_state != IB_DEV_UNINITIALIZED);
+ kobject_put(&device->dev.kobj);
+}
+EXPORT_SYMBOL(ib_dealloc_device);
+
+static int add_client_context(struct ib_device *device, struct ib_client *client)
+{
+ struct ib_client_data *context;
+ unsigned long flags;
+
+ context = kmalloc(sizeof *context, GFP_KERNEL);
+ if (!context) {
+ pr_warn("Couldn't allocate client context for %s/%s\n",
+ device->name, client->name);
+ return -ENOMEM;
+ }
+
+ context->client = client;
+ context->data = NULL;
+ context->going_down = false;
+
+ down_write(&lists_rwsem);
+ spin_lock_irqsave(&device->client_data_lock, flags);
+ list_add(&context->list, &device->client_data_list);
+ spin_unlock_irqrestore(&device->client_data_lock, flags);
+ up_write(&lists_rwsem);
+
+ return 0;
+}
+
+static int verify_immutable(const struct ib_device *dev, u8 port)
+{
+ return WARN_ON(!rdma_cap_ib_mad(dev, port) &&
+ rdma_max_mad_size(dev, port) != 0);
+}
+
+static int read_port_immutable(struct ib_device *device)
+{
+ int ret;
+ u8 start_port = rdma_start_port(device);
+ u8 end_port = rdma_end_port(device);
+ u8 port;
+
+ /**
+ * device->port_immutable is indexed directly by the port number to make
+ * access to this data as efficient as possible.
+ *
+ * Therefore port_immutable is declared as a 1 based array with
+ * potential empty slots at the beginning.
+ */
+ device->port_immutable = kzalloc(sizeof(*device->port_immutable)
+ * (end_port + 1),
+ GFP_KERNEL);
+ if (!device->port_immutable)
+ return -ENOMEM;
+
+ for (port = start_port; port <= end_port; ++port) {
+ ret = device->get_port_immutable(device, port,
+ &device->port_immutable[port]);
+ if (ret)
+ return ret;
+
+ if (verify_immutable(device, port))
+ return -EINVAL;
+ }
+ return 0;
+}
+
+void ib_get_device_fw_str(struct ib_device *dev, char *str, size_t str_len)
+{
+ if (dev->get_dev_fw_str)
+ dev->get_dev_fw_str(dev, str, str_len);
+ else
+ str[0] = '\0';
+}
+EXPORT_SYMBOL(ib_get_device_fw_str);
+
+/**
+ * ib_register_device - Register an IB device with IB core
+ * @device:Device to register
+ *
+ * Low-level drivers use ib_register_device() to register their
+ * devices with the IB core. All registered clients will receive a
+ * callback for each device that is added. @device must be allocated
+ * with ib_alloc_device().
+ */
+int ib_register_device(struct ib_device *device,
+ int (*port_callback)(struct ib_device *,
+ u8, struct kobject *))
+{
+ int ret;
+ struct ib_client *client;
+ struct ib_udata uhw = {.outlen = 0, .inlen = 0};
+
+ mutex_lock(&device_mutex);
+
+ if (strchr(device->name, '%')) {
+ ret = alloc_name(device->name);
+ if (ret)
+ goto out;
+ }
+
+ if (ib_device_check_mandatory(device)) {
+ ret = -EINVAL;
+ goto out;
+ }
+
+ ret = read_port_immutable(device);
+ if (ret) {
+ pr_warn("Couldn't create per port immutable data %s\n",
+ device->name);
+ goto out;
+ }
+
+ ret = ib_cache_setup_one(device);
+ if (ret) {
+ pr_warn("Couldn't set up InfiniBand P_Key/GID cache\n");
+ goto out;
+ }
+
+ memset(&device->attrs, 0, sizeof(device->attrs));
+ ret = device->query_device(device, &device->attrs, &uhw);
+ if (ret) {
+ pr_warn("Couldn't query the device attributes\n");
+ ib_cache_cleanup_one(device);
+ goto out;
+ }
+
+ ret = ib_device_register_sysfs(device, port_callback);
+ if (ret) {
+ pr_warn("Couldn't register device %s with driver model\n",
+ device->name);
+ ib_cache_cleanup_one(device);
+ goto out;
+ }
+
+ device->reg_state = IB_DEV_REGISTERED;
+
+ list_for_each_entry(client, &client_list, list)
+ if (client->add && !add_client_context(device, client))
+ client->add(device);
+
+ down_write(&lists_rwsem);
+ list_add_tail(&device->core_list, &device_list);
+ up_write(&lists_rwsem);
+out:
+ mutex_unlock(&device_mutex);
+ return ret;
+}
+EXPORT_SYMBOL(ib_register_device);
+
+/**
+ * ib_unregister_device - Unregister an IB device
+ * @device:Device to unregister
+ *
+ * Unregister an IB device. All clients will receive a remove callback.
+ */
+void ib_unregister_device(struct ib_device *device)
+{
+ struct ib_client_data *context, *tmp;
+ unsigned long flags;
+
+ mutex_lock(&device_mutex);
+
+ down_write(&lists_rwsem);
+ list_del(&device->core_list);
+ spin_lock_irqsave(&device->client_data_lock, flags);
+ list_for_each_entry_safe(context, tmp, &device->client_data_list, list)
+ context->going_down = true;
+ spin_unlock_irqrestore(&device->client_data_lock, flags);
+ downgrade_write(&lists_rwsem);
+
+ list_for_each_entry_safe(context, tmp, &device->client_data_list,
+ list) {
+ if (context->client->remove)
+ context->client->remove(device, context->data);
+ }
+ up_read(&lists_rwsem);
+
+ mutex_unlock(&device_mutex);
+
+ ib_device_unregister_sysfs(device);
+ ib_cache_cleanup_one(device);
+
+ down_write(&lists_rwsem);
+ spin_lock_irqsave(&device->client_data_lock, flags);
+ list_for_each_entry_safe(context, tmp, &device->client_data_list, list)
+ kfree(context);
+ spin_unlock_irqrestore(&device->client_data_lock, flags);
+ up_write(&lists_rwsem);
+
+ device->reg_state = IB_DEV_UNREGISTERED;
+}
+EXPORT_SYMBOL(ib_unregister_device);
+
+/**
+ * ib_register_client - Register an IB client
+ * @client:Client to register
+ *
+ * Upper level users of the IB drivers can use ib_register_client() to
+ * register callbacks for IB device addition and removal. When an IB
+ * device is added, each registered client's add method will be called
+ * (in the order the clients were registered), and when a device is
+ * removed, each client's remove method will be called (in the reverse
+ * order that clients were registered). In addition, when
+ * ib_register_client() is called, the client will receive an add
+ * callback for all devices already registered.
+ */
+int ib_register_client(struct ib_client *client)
+{
+ struct ib_device *device;
+
+ mutex_lock(&device_mutex);
+
+ list_for_each_entry(device, &device_list, core_list)
+ if (client->add && !add_client_context(device, client))
+ client->add(device);
+
+ down_write(&lists_rwsem);
+ list_add_tail(&client->list, &client_list);
+ up_write(&lists_rwsem);
+
+ mutex_unlock(&device_mutex);
+
+ return 0;
+}
+EXPORT_SYMBOL(ib_register_client);
+
+/**
+ * ib_unregister_client - Unregister an IB client
+ * @client:Client to unregister
+ *
+ * Upper level users use ib_unregister_client() to remove their client
+ * registration. When ib_unregister_client() is called, the client
+ * will receive a remove callback for each IB device still registered.
+ */
+void ib_unregister_client(struct ib_client *client)
+{
+ struct ib_client_data *context, *tmp;
+ struct ib_device *device;
+ unsigned long flags;
+
+ mutex_lock(&device_mutex);
+
+ down_write(&lists_rwsem);
+ list_del(&client->list);
+ up_write(&lists_rwsem);
+
+ list_for_each_entry(device, &device_list, core_list) {
+ struct ib_client_data *found_context = NULL;
+
+ down_write(&lists_rwsem);
+ spin_lock_irqsave(&device->client_data_lock, flags);
+ list_for_each_entry_safe(context, tmp, &device->client_data_list, list)
+ if (context->client == client) {
+ context->going_down = true;
+ found_context = context;
+ break;
+ }
+ spin_unlock_irqrestore(&device->client_data_lock, flags);
+ up_write(&lists_rwsem);
+
+ if (client->remove)
+ client->remove(device, found_context ?
+ found_context->data : NULL);
+
+ if (!found_context) {
+ pr_warn("No client context found for %s/%s\n",
+ device->name, client->name);
+ continue;
+ }
+
+ down_write(&lists_rwsem);
+ spin_lock_irqsave(&device->client_data_lock, flags);
+ list_del(&found_context->list);
+ kfree(found_context);
+ spin_unlock_irqrestore(&device->client_data_lock, flags);
+ up_write(&lists_rwsem);
+ }
+
+ mutex_unlock(&device_mutex);
+}
+EXPORT_SYMBOL(ib_unregister_client);
+
+/**
+ * ib_get_client_data - Get IB client context
+ * @device:Device to get context for
+ * @client:Client to get context for
+ *
+ * ib_get_client_data() returns client context set with
+ * ib_set_client_data().
+ */
+void *ib_get_client_data(struct ib_device *device, struct ib_client *client)
+{
+ struct ib_client_data *context;
+ void *ret = NULL;
+ unsigned long flags;
+
+ spin_lock_irqsave(&device->client_data_lock, flags);
+ list_for_each_entry(context, &device->client_data_list, list)
+ if (context->client == client) {
+ ret = context->data;
+ break;
+ }
+ spin_unlock_irqrestore(&device->client_data_lock, flags);
+
+ return ret;
+}
+EXPORT_SYMBOL(ib_get_client_data);
+
+/**
+ * ib_set_client_data - Set IB client context
+ * @device:Device to set context for
+ * @client:Client to set context for
+ * @data:Context to set
+ *
+ * ib_set_client_data() sets client context that can be retrieved with
+ * ib_get_client_data().
+ */
+void ib_set_client_data(struct ib_device *device, struct ib_client *client,
+ void *data)
+{
+ struct ib_client_data *context;
+ unsigned long flags;
+
+ spin_lock_irqsave(&device->client_data_lock, flags);
+ list_for_each_entry(context, &device->client_data_list, list)
+ if (context->client == client) {
+ context->data = data;
+ goto out;
+ }
+
+ pr_warn("No client context found for %s/%s\n",
+ device->name, client->name);
+
+out:
+ spin_unlock_irqrestore(&device->client_data_lock, flags);
+}
+EXPORT_SYMBOL(ib_set_client_data);
+
+/**
+ * ib_register_event_handler - Register an IB event handler
+ * @event_handler:Handler to register
+ *
+ * ib_register_event_handler() registers an event handler that will be
+ * called back when asynchronous IB events occur (as defined in
+ * chapter 11 of the InfiniBand Architecture Specification). This
+ * callback may occur in interrupt context.
+ */
+int ib_register_event_handler (struct ib_event_handler *event_handler)
+{
+ unsigned long flags;
+
+ spin_lock_irqsave(&event_handler->device->event_handler_lock, flags);
+ list_add_tail(&event_handler->list,
+ &event_handler->device->event_handler_list);
+ spin_unlock_irqrestore(&event_handler->device->event_handler_lock, flags);
+
+ return 0;
+}
+EXPORT_SYMBOL(ib_register_event_handler);
+
+/**
+ * ib_unregister_event_handler - Unregister an event handler
+ * @event_handler:Handler to unregister
+ *
+ * Unregister an event handler registered with
+ * ib_register_event_handler().
+ */
+int ib_unregister_event_handler(struct ib_event_handler *event_handler)
+{
+ unsigned long flags;
+
+ spin_lock_irqsave(&event_handler->device->event_handler_lock, flags);
+ list_del(&event_handler->list);
+ spin_unlock_irqrestore(&event_handler->device->event_handler_lock, flags);
+
+ return 0;
+}
+EXPORT_SYMBOL(ib_unregister_event_handler);
+
+/**
+ * ib_dispatch_event - Dispatch an asynchronous event
+ * @event:Event to dispatch
+ *
+ * Low-level drivers must call ib_dispatch_event() to dispatch the
+ * event to all registered event handlers when an asynchronous event
+ * occurs.
+ */
+void ib_dispatch_event(struct ib_event *event)
+{
+ unsigned long flags;
+ struct ib_event_handler *handler;
+
+ spin_lock_irqsave(&event->device->event_handler_lock, flags);
+
+ list_for_each_entry(handler, &event->device->event_handler_list, list)
+ handler->handler(handler, event);
+
+ spin_unlock_irqrestore(&event->device->event_handler_lock, flags);
+}
+EXPORT_SYMBOL(ib_dispatch_event);
+
+/**
+ * ib_query_port - Query IB port attributes
+ * @device:Device to query
+ * @port_num:Port number to query
+ * @port_attr:Port attributes
+ *
+ * ib_query_port() returns the attributes of a port through the
+ * @port_attr pointer.
+ */
+int ib_query_port(struct ib_device *device,
+ u8 port_num,
+ struct ib_port_attr *port_attr)
+{
+ union ib_gid gid;
+ int err;
+
+ if (port_num < rdma_start_port(device) || port_num > rdma_end_port(device))
+ return -EINVAL;
+
+ memset(port_attr, 0, sizeof(*port_attr));
+ err = device->query_port(device, port_num, port_attr);
+ if (err || port_attr->subnet_prefix)
+ return err;
+
+ if (rdma_port_get_link_layer(device, port_num) != IB_LINK_LAYER_INFINIBAND)
+ return 0;
+
+ err = ib_query_gid(device, port_num, 0, &gid, NULL);
+ if (err)
+ return err;
+
+ port_attr->subnet_prefix = be64_to_cpu(gid.global.subnet_prefix);
+ return 0;
+}
+EXPORT_SYMBOL(ib_query_port);
+
+/**
+ * ib_query_gid - Get GID table entry
+ * @device:Device to query
+ * @port_num:Port number to query
+ * @index:GID table index to query
+ * @gid:Returned GID
+ * @attr: Returned GID attributes related to this GID index (only in RoCE).
+ * NULL means ignore.
+ *
+ * ib_query_gid() fetches the specified GID table entry.
+ */
+int ib_query_gid(struct ib_device *device,
+ u8 port_num, int index, union ib_gid *gid,
+ struct ib_gid_attr *attr)
+{
+ if (rdma_cap_roce_gid_table(device, port_num))
+ return ib_get_cached_gid(device, port_num, index, gid, attr);
+
+ if (attr)
+ return -EINVAL;
+
+ return device->query_gid(device, port_num, index, gid);
+}
+EXPORT_SYMBOL(ib_query_gid);
+
+/**
+ * ib_enum_roce_netdev - enumerate all RoCE ports
+ * @ib_dev : IB device we want to query
+ * @filter: Should we call the callback?
+ * @filter_cookie: Cookie passed to filter
+ * @cb: Callback to call for each found RoCE ports
+ * @cookie: Cookie passed back to the callback
+ *
+ * Enumerates all of the physical RoCE ports of ib_dev
+ * which are related to netdevice and calls callback() on each
+ * device for which filter() function returns non zero.
+ */
+void ib_enum_roce_netdev(struct ib_device *ib_dev,
+ roce_netdev_filter filter,
+ void *filter_cookie,
+ roce_netdev_callback cb,
+ void *cookie)
+{
+ u8 port;
+
+ for (port = rdma_start_port(ib_dev); port <= rdma_end_port(ib_dev);
+ port++)
+ if (rdma_protocol_roce(ib_dev, port)) {
+ struct net_device *idev = NULL;
+
+ if (ib_dev->get_netdev)
+ idev = ib_dev->get_netdev(ib_dev, port);
+
+ if (idev && (idev->if_flags & IFF_DYING)) {
+ dev_put(idev);
+ idev = NULL;
+ }
+
+ if (filter(ib_dev, port, idev, filter_cookie))
+ cb(ib_dev, port, idev, cookie);
+
+ if (idev)
+ dev_put(idev);
+ }
+}
+
+/**
+ * ib_enum_all_roce_netdevs - enumerate all RoCE devices
+ * @filter: Should we call the callback?
+ * @filter_cookie: Cookie passed to filter
+ * @cb: Callback to call for each found RoCE ports
+ * @cookie: Cookie passed back to the callback
+ *
+ * Enumerates all RoCE devices' physical ports which are related
+ * to netdevices and calls callback() on each device for which
+ * filter() function returns non zero.
+ */
+void ib_enum_all_roce_netdevs(roce_netdev_filter filter,
+ void *filter_cookie,
+ roce_netdev_callback cb,
+ void *cookie)
+{
+ struct ib_device *dev;
+
+ down_read(&lists_rwsem);
+ list_for_each_entry(dev, &device_list, core_list)
+ ib_enum_roce_netdev(dev, filter, filter_cookie, cb, cookie);
+ up_read(&lists_rwsem);
+}
+
+/**
+ * ib_cache_gid_del_all_by_netdev - delete GIDs belonging a netdevice
+ *
+ * @ndev: Pointer to netdevice
+ */
+void ib_cache_gid_del_all_by_netdev(struct net_device *ndev)
+{
+ struct ib_device *ib_dev;
+ u8 port;
+
+ down_read(&lists_rwsem);
+ list_for_each_entry(ib_dev, &device_list, core_list) {
+ for (port = rdma_start_port(ib_dev);
+ port <= rdma_end_port(ib_dev);
+ port++) {
+ if (rdma_protocol_roce(ib_dev, port) == 0)
+ continue;
+ (void) ib_cache_gid_del_all_netdev_gids(ib_dev, port, ndev);
+ }
+ }
+ up_read(&lists_rwsem);
+}
+
+/**
+ * ib_query_pkey - Get P_Key table entry
+ * @device:Device to query
+ * @port_num:Port number to query
+ * @index:P_Key table index to query
+ * @pkey:Returned P_Key
+ *
+ * ib_query_pkey() fetches the specified P_Key table entry.
+ */
+int ib_query_pkey(struct ib_device *device,
+ u8 port_num, u16 index, u16 *pkey)
+{
+ return device->query_pkey(device, port_num, index, pkey);
+}
+EXPORT_SYMBOL(ib_query_pkey);
+
+/**
+ * ib_modify_device - Change IB device attributes
+ * @device:Device to modify
+ * @device_modify_mask:Mask of attributes to change
+ * @device_modify:New attribute values
+ *
+ * ib_modify_device() changes a device's attributes as specified by
+ * the @device_modify_mask and @device_modify structure.
+ */
+int ib_modify_device(struct ib_device *device,
+ int device_modify_mask,
+ struct ib_device_modify *device_modify)
+{
+ if (!device->modify_device)
+ return -ENOSYS;
+
+ return device->modify_device(device, device_modify_mask,
+ device_modify);
+}
+EXPORT_SYMBOL(ib_modify_device);
+
+/**
+ * ib_modify_port - Modifies the attributes for the specified port.
+ * @device: The device to modify.
+ * @port_num: The number of the port to modify.
+ * @port_modify_mask: Mask used to specify which attributes of the port
+ * to change.
+ * @port_modify: New attribute values for the port.
+ *
+ * ib_modify_port() changes a port's attributes as specified by the
+ * @port_modify_mask and @port_modify structure.
+ */
+int ib_modify_port(struct ib_device *device,
+ u8 port_num, int port_modify_mask,
+ struct ib_port_modify *port_modify)
+{
+ if (!device->modify_port)
+ return -ENOSYS;
+
+ if (port_num < rdma_start_port(device) || port_num > rdma_end_port(device))
+ return -EINVAL;
+
+ return device->modify_port(device, port_num, port_modify_mask,
+ port_modify);
+}
+EXPORT_SYMBOL(ib_modify_port);
+
+/**
+ * ib_find_gid - Returns the port number and GID table index where
+ * a specified GID value occurs.
+ * @device: The device to query.
+ * @gid: The GID value to search for.
+ * @gid_type: Type of GID.
+ * @ndev: The ndev related to the GID to search for.
+ * @port_num: The port number of the device where the GID value was found.
+ * @index: The index into the GID table where the GID was found. This
+ * parameter may be NULL.
+ */
+int ib_find_gid(struct ib_device *device, union ib_gid *gid,
+ enum ib_gid_type gid_type, struct net_device *ndev,
+ u8 *port_num, u16 *index)
+{
+ union ib_gid tmp_gid;
+ int ret, port, i;
+
+ for (port = rdma_start_port(device); port <= rdma_end_port(device); ++port) {
+ if (rdma_cap_roce_gid_table(device, port)) {
+ if (!ib_find_cached_gid_by_port(device, gid, gid_type, port,
+ ndev, index)) {
+ *port_num = port;
+ return 0;
+ }
+ }
+
+ if (gid_type != IB_GID_TYPE_IB)
+ continue;
+
+ for (i = 0; i < device->port_immutable[port].gid_tbl_len; ++i) {
+ ret = ib_query_gid(device, port, i, &tmp_gid, NULL);
+ if (ret)
+ return ret;
+ if (!memcmp(&tmp_gid, gid, sizeof *gid)) {
+ *port_num = port;
+ if (index)
+ *index = i;
+ return 0;
+ }
+ }
+ }
+
+ return -ENOENT;
+}
+EXPORT_SYMBOL(ib_find_gid);
+
+/**
+ * ib_find_pkey - Returns the PKey table index where a specified
+ * PKey value occurs.
+ * @device: The device to query.
+ * @port_num: The port number of the device to search for the PKey.
+ * @pkey: The PKey value to search for.
+ * @index: The index into the PKey table where the PKey was found.
+ */
+int ib_find_pkey(struct ib_device *device,
+ u8 port_num, u16 pkey, u16 *index)
+{
+ int ret, i;
+ u16 tmp_pkey;
+ int partial_ix = -1;
+
+ for (i = 0; i < device->port_immutable[port_num].pkey_tbl_len; ++i) {
+ ret = ib_query_pkey(device, port_num, i, &tmp_pkey);
+ if (ret)
+ return ret;
+ if ((pkey & 0x7fff) == (tmp_pkey & 0x7fff)) {
+ /* if there is full-member pkey take it.*/
+ if (tmp_pkey & 0x8000) {
+ *index = i;
+ return 0;
+ }
+ if (partial_ix < 0)
+ partial_ix = i;
+ }
+ }
+
+ /*no full-member, if exists take the limited*/
+ if (partial_ix >= 0) {
+ *index = partial_ix;
+ return 0;
+ }
+ return -ENOENT;
+}
+EXPORT_SYMBOL(ib_find_pkey);
+
+/**
+ * ib_get_net_dev_by_params() - Return the appropriate net_dev
+ * for a received CM request
+ * @dev: An RDMA device on which the request has been received.
+ * @port: Port number on the RDMA device.
+ * @pkey: The Pkey the request came on.
+ * @gid: A GID that the net_dev uses to communicate.
+ * @addr: Contains the IP address that the request specified as its
+ * destination.
+ */
+struct net_device *ib_get_net_dev_by_params(struct ib_device *dev,
+ u8 port,
+ u16 pkey,
+ const union ib_gid *gid,
+ const struct sockaddr *addr)
+{
+ struct net_device *net_dev = NULL;
+ struct ib_client_data *context;
+
+ if (!rdma_protocol_ib(dev, port))
+ return NULL;
+
+ down_read(&lists_rwsem);
+
+ list_for_each_entry(context, &dev->client_data_list, list) {
+ struct ib_client *client = context->client;
+
+ if (context->going_down)
+ continue;
+
+ if (client->get_net_dev_by_params) {
+ net_dev = client->get_net_dev_by_params(dev, port, pkey,
+ gid, addr,
+ context->data);
+ if (net_dev)
+ break;
+ }
+ }
+
+ up_read(&lists_rwsem);
+
+ return net_dev;
+}
+EXPORT_SYMBOL(ib_get_net_dev_by_params);
+
+static int __init ib_core_init(void)
+{
+ int ret;
+
+ ib_wq = alloc_workqueue("infiniband", 0, 0);
+ if (!ib_wq)
+ return -ENOMEM;
+
+ ib_comp_wq = alloc_workqueue("ib-comp-wq",
+ WQ_UNBOUND | WQ_HIGHPRI | WQ_MEM_RECLAIM,
+ mp_ncpus * 4 /* WQ_UNBOUND_MAX_ACTIVE */);
+ if (!ib_comp_wq) {
+ ret = -ENOMEM;
+ goto err;
+ }
+
+ ret = class_register(&ib_class);
+ if (ret) {
+ pr_warn("Couldn't create InfiniBand device class\n");
+ goto err_comp;
+ }
+
+ ret = addr_init();
+ if (ret) {
+ pr_warn("Could't init IB address resolution\n");
+ goto err_sysfs;
+ }
+
+ ret = ib_mad_init();
+ if (ret) {
+ pr_warn("Couldn't init IB MAD\n");
+ goto err_addr;
+ }
+
+ ret = ib_sa_init();
+ if (ret) {
+ pr_warn("Couldn't init SA\n");
+ goto err_mad;
+ }
+
+ ib_cache_setup();
+
+ return 0;
+
+err_mad:
+ ib_mad_cleanup();
+err_addr:
+ addr_cleanup();
+err_sysfs:
+ class_unregister(&ib_class);
+err_comp:
+ destroy_workqueue(ib_comp_wq);
+err:
+ destroy_workqueue(ib_wq);
+ return ret;
+}
+
+static void __exit ib_core_cleanup(void)
+{
+ ib_cache_cleanup();
+ ib_sa_cleanup();
+ ib_mad_cleanup();
+ addr_cleanup();
+ class_unregister(&ib_class);
+ destroy_workqueue(ib_comp_wq);
+ /* Make sure that any pending umem accounting work is done. */
+ destroy_workqueue(ib_wq);
+}
+
+module_init(ib_core_init);
+module_exit(ib_core_cleanup);
+
+MODULE_VERSION(ibcore, 1);
+MODULE_DEPEND(ibcore, linuxkpi, 1, 1, 1);
diff --git a/sys/ofed/drivers/infiniband/core/ib_fmr_pool.c b/sys/ofed/drivers/infiniband/core/ib_fmr_pool.c
new file mode 100644
index 0000000..708b2be
--- /dev/null
+++ b/sys/ofed/drivers/infiniband/core/ib_fmr_pool.c
@@ -0,0 +1,521 @@
+/*
+ * Copyright (c) 2004 Topspin Communications. All rights reserved.
+ * Copyright (c) 2005 Sun Microsystems, Inc. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#include <linux/errno.h>
+#include <linux/spinlock.h>
+#include <linux/slab.h>
+#include <linux/jhash.h>
+#include <linux/kthread.h>
+#include <linux/wait.h>
+
+#include <rdma/ib_fmr_pool.h>
+
+#include "core_priv.h"
+
+#define PFX "fmr_pool: "
+
+enum {
+ IB_FMR_MAX_REMAPS = 32,
+
+ IB_FMR_HASH_BITS = 8,
+ IB_FMR_HASH_SIZE = 1 << IB_FMR_HASH_BITS,
+ IB_FMR_HASH_MASK = IB_FMR_HASH_SIZE - 1
+};
+
+/*
+ * If an FMR is not in use, then the list member will point to either
+ * its pool's free_list (if the FMR can be mapped again; that is,
+ * remap_count < pool->max_remaps) or its pool's dirty_list (if the
+ * FMR needs to be unmapped before being remapped). In either of
+ * these cases it is a bug if the ref_count is not 0. In other words,
+ * if ref_count is > 0, then the list member must not be linked into
+ * either free_list or dirty_list.
+ *
+ * The cache_node member is used to link the FMR into a cache bucket
+ * (if caching is enabled). This is independent of the reference
+ * count of the FMR. When a valid FMR is released, its ref_count is
+ * decremented, and if ref_count reaches 0, the FMR is placed in
+ * either free_list or dirty_list as appropriate. However, it is not
+ * removed from the cache and may be "revived" if a call to
+ * ib_fmr_register_physical() occurs before the FMR is remapped. In
+ * this case we just increment the ref_count and remove the FMR from
+ * free_list/dirty_list.
+ *
+ * Before we remap an FMR from free_list, we remove it from the cache
+ * (to prevent another user from obtaining a stale FMR). When an FMR
+ * is released, we add it to the tail of the free list, so that our
+ * cache eviction policy is "least recently used."
+ *
+ * All manipulation of ref_count, list and cache_node is protected by
+ * pool_lock to maintain consistency.
+ */
+
+struct ib_fmr_pool {
+ spinlock_t pool_lock;
+
+ int pool_size;
+ int max_pages;
+ int max_remaps;
+ int dirty_watermark;
+ int dirty_len;
+ struct list_head free_list;
+ struct list_head dirty_list;
+ struct hlist_head *cache_bucket;
+
+ void (*flush_function)(struct ib_fmr_pool *pool,
+ void * arg);
+ void *flush_arg;
+
+ struct task_struct *thread;
+
+ atomic_t req_ser;
+ atomic_t flush_ser;
+
+ wait_queue_head_t force_wait;
+};
+
+static inline u32 ib_fmr_hash(u64 first_page)
+{
+ return jhash_2words((u32) first_page, (u32) (first_page >> 32), 0) &
+ (IB_FMR_HASH_SIZE - 1);
+}
+
+/* Caller must hold pool_lock */
+static inline struct ib_pool_fmr *ib_fmr_cache_lookup(struct ib_fmr_pool *pool,
+ u64 *page_list,
+ int page_list_len,
+ u64 io_virtual_address)
+{
+ struct hlist_head *bucket;
+ struct ib_pool_fmr *fmr;
+
+ if (!pool->cache_bucket)
+ return NULL;
+
+ bucket = pool->cache_bucket + ib_fmr_hash(*page_list);
+
+ hlist_for_each_entry(fmr, bucket, cache_node)
+ if (io_virtual_address == fmr->io_virtual_address &&
+ page_list_len == fmr->page_list_len &&
+ !memcmp(page_list, fmr->page_list,
+ page_list_len * sizeof *page_list))
+ return fmr;
+
+ return NULL;
+}
+
+static void ib_fmr_batch_release(struct ib_fmr_pool *pool)
+{
+ int ret;
+ struct ib_pool_fmr *fmr;
+ LIST_HEAD(unmap_list);
+ LIST_HEAD(fmr_list);
+
+ spin_lock_irq(&pool->pool_lock);
+
+ list_for_each_entry(fmr, &pool->dirty_list, list) {
+ hlist_del_init(&fmr->cache_node);
+ fmr->remap_count = 0;
+ list_add_tail(&fmr->fmr->list, &fmr_list);
+
+#ifdef DEBUG
+ if (fmr->ref_count !=0) {
+ pr_warn(PFX "Unmapping FMR %p with ref count %d\n",
+ fmr, (int)fmr->ref_count);
+ }
+#endif
+ }
+
+ list_splice_init(&pool->dirty_list, &unmap_list);
+ pool->dirty_len = 0;
+
+ spin_unlock_irq(&pool->pool_lock);
+
+ if (list_empty(&unmap_list)) {
+ return;
+ }
+
+ ret = ib_unmap_fmr(&fmr_list);
+ if (ret)
+ pr_warn(PFX "ib_unmap_fmr returned %d\n", ret);
+
+ spin_lock_irq(&pool->pool_lock);
+ list_splice(&unmap_list, &pool->free_list);
+ spin_unlock_irq(&pool->pool_lock);
+}
+
+static int ib_fmr_cleanup_thread(void *pool_ptr)
+{
+ struct ib_fmr_pool *pool = pool_ptr;
+
+ do {
+ if (atomic_read(&pool->flush_ser) - atomic_read(&pool->req_ser) < 0) {
+ ib_fmr_batch_release(pool);
+
+ atomic_inc(&pool->flush_ser);
+ wake_up_interruptible(&pool->force_wait);
+
+ if (pool->flush_function)
+ pool->flush_function(pool, pool->flush_arg);
+ }
+
+ set_current_state(TASK_INTERRUPTIBLE);
+ if (atomic_read(&pool->flush_ser) - atomic_read(&pool->req_ser) >= 0 &&
+ !kthread_should_stop())
+ schedule();
+ __set_current_state(TASK_RUNNING);
+ } while (!kthread_should_stop());
+
+ return 0;
+}
+
+/**
+ * ib_create_fmr_pool - Create an FMR pool
+ * @pd:Protection domain for FMRs
+ * @params:FMR pool parameters
+ *
+ * Create a pool of FMRs. Return value is pointer to new pool or
+ * error code if creation failed.
+ */
+struct ib_fmr_pool *ib_create_fmr_pool(struct ib_pd *pd,
+ struct ib_fmr_pool_param *params)
+{
+ struct ib_device *device;
+ struct ib_fmr_pool *pool;
+ int i;
+ int ret;
+ int max_remaps;
+
+ if (!params)
+ return ERR_PTR(-EINVAL);
+
+ device = pd->device;
+ if (!device->alloc_fmr || !device->dealloc_fmr ||
+ !device->map_phys_fmr || !device->unmap_fmr) {
+ pr_info(PFX "Device %s does not support FMRs\n", device->name);
+ return ERR_PTR(-ENOSYS);
+ }
+
+ if (!device->attrs.max_map_per_fmr)
+ max_remaps = IB_FMR_MAX_REMAPS;
+ else
+ max_remaps = device->attrs.max_map_per_fmr;
+
+ pool = kmalloc(sizeof *pool, GFP_KERNEL);
+ if (!pool)
+ return ERR_PTR(-ENOMEM);
+
+ pool->cache_bucket = NULL;
+ pool->flush_function = params->flush_function;
+ pool->flush_arg = params->flush_arg;
+
+ INIT_LIST_HEAD(&pool->free_list);
+ INIT_LIST_HEAD(&pool->dirty_list);
+
+ if (params->cache) {
+ pool->cache_bucket =
+ kmalloc(IB_FMR_HASH_SIZE * sizeof *pool->cache_bucket,
+ GFP_KERNEL);
+ if (!pool->cache_bucket) {
+ pr_warn(PFX "Failed to allocate cache in pool\n");
+ ret = -ENOMEM;
+ goto out_free_pool;
+ }
+
+ for (i = 0; i < IB_FMR_HASH_SIZE; ++i)
+ INIT_HLIST_HEAD(pool->cache_bucket + i);
+ }
+
+ pool->pool_size = 0;
+ pool->max_pages = params->max_pages_per_fmr;
+ pool->max_remaps = max_remaps;
+ pool->dirty_watermark = params->dirty_watermark;
+ pool->dirty_len = 0;
+ spin_lock_init(&pool->pool_lock);
+ atomic_set(&pool->req_ser, 0);
+ atomic_set(&pool->flush_ser, 0);
+ init_waitqueue_head(&pool->force_wait);
+
+ pool->thread = kthread_run(ib_fmr_cleanup_thread,
+ pool,
+ "ib_fmr(%s)",
+ device->name);
+ if (IS_ERR(pool->thread)) {
+ pr_warn(PFX "couldn't start cleanup thread\n");
+ ret = PTR_ERR(pool->thread);
+ goto out_free_pool;
+ }
+
+ {
+ struct ib_pool_fmr *fmr;
+ struct ib_fmr_attr fmr_attr = {
+ .max_pages = params->max_pages_per_fmr,
+ .max_maps = pool->max_remaps,
+ .page_shift = params->page_shift
+ };
+ int bytes_per_fmr = sizeof *fmr;
+
+ if (pool->cache_bucket)
+ bytes_per_fmr += params->max_pages_per_fmr * sizeof (u64);
+
+ for (i = 0; i < params->pool_size; ++i) {
+ fmr = kmalloc(bytes_per_fmr, GFP_KERNEL);
+ if (!fmr)
+ goto out_fail;
+
+ fmr->pool = pool;
+ fmr->remap_count = 0;
+ fmr->ref_count = 0;
+ INIT_HLIST_NODE(&fmr->cache_node);
+
+ fmr->fmr = ib_alloc_fmr(pd, params->access, &fmr_attr);
+ if (IS_ERR(fmr->fmr)) {
+ pr_warn(PFX "fmr_create failed for FMR %d\n",
+ i);
+ kfree(fmr);
+ goto out_fail;
+ }
+
+ list_add_tail(&fmr->list, &pool->free_list);
+ ++pool->pool_size;
+ }
+ }
+
+ return pool;
+
+ out_free_pool:
+ kfree(pool->cache_bucket);
+ kfree(pool);
+
+ return ERR_PTR(ret);
+
+ out_fail:
+ ib_destroy_fmr_pool(pool);
+
+ return ERR_PTR(-ENOMEM);
+}
+EXPORT_SYMBOL(ib_create_fmr_pool);
+
+/**
+ * ib_destroy_fmr_pool - Free FMR pool
+ * @pool:FMR pool to free
+ *
+ * Destroy an FMR pool and free all associated resources.
+ */
+void ib_destroy_fmr_pool(struct ib_fmr_pool *pool)
+{
+ struct ib_pool_fmr *fmr;
+ struct ib_pool_fmr *tmp;
+ LIST_HEAD(fmr_list);
+ int i;
+
+ kthread_stop(pool->thread);
+ ib_fmr_batch_release(pool);
+
+ i = 0;
+ list_for_each_entry_safe(fmr, tmp, &pool->free_list, list) {
+ if (fmr->remap_count) {
+ INIT_LIST_HEAD(&fmr_list);
+ list_add_tail(&fmr->fmr->list, &fmr_list);
+ ib_unmap_fmr(&fmr_list);
+ }
+ ib_dealloc_fmr(fmr->fmr);
+ list_del(&fmr->list);
+ kfree(fmr);
+ ++i;
+ }
+
+ if (i < pool->pool_size)
+ pr_warn(PFX "pool still has %d regions registered\n",
+ pool->pool_size - i);
+
+ kfree(pool->cache_bucket);
+ kfree(pool);
+}
+EXPORT_SYMBOL(ib_destroy_fmr_pool);
+
+/**
+ * ib_flush_fmr_pool - Invalidate all unmapped FMRs
+ * @pool:FMR pool to flush
+ *
+ * Ensure that all unmapped FMRs are fully invalidated.
+ */
+int ib_flush_fmr_pool(struct ib_fmr_pool *pool)
+{
+ int serial;
+ struct ib_pool_fmr *fmr, *next;
+
+ /*
+ * The free_list holds FMRs that may have been used
+ * but have not been remapped enough times to be dirty.
+ * Put them on the dirty list now so that the cleanup
+ * thread will reap them too.
+ */
+ spin_lock_irq(&pool->pool_lock);
+ list_for_each_entry_safe(fmr, next, &pool->free_list, list) {
+ if (fmr->remap_count > 0)
+ list_move(&fmr->list, &pool->dirty_list);
+ }
+ spin_unlock_irq(&pool->pool_lock);
+
+ serial = atomic_inc_return(&pool->req_ser);
+ wake_up_process(pool->thread);
+
+ if (wait_event_interruptible(pool->force_wait,
+ atomic_read(&pool->flush_ser) - serial >= 0))
+ return -EINTR;
+
+ return 0;
+}
+EXPORT_SYMBOL(ib_flush_fmr_pool);
+
+/**
+ * ib_fmr_pool_map_phys -
+ * @pool:FMR pool to allocate FMR from
+ * @page_list:List of pages to map
+ * @list_len:Number of pages in @page_list
+ * @io_virtual_address:I/O virtual address for new FMR
+ *
+ * Map an FMR from an FMR pool.
+ */
+struct ib_pool_fmr *ib_fmr_pool_map_phys(struct ib_fmr_pool *pool_handle,
+ u64 *page_list,
+ int list_len,
+ u64 io_virtual_address)
+{
+ struct ib_fmr_pool *pool = pool_handle;
+ struct ib_pool_fmr *fmr;
+ unsigned long flags;
+ int result;
+
+ if (list_len < 1 || list_len > pool->max_pages)
+ return ERR_PTR(-EINVAL);
+
+ spin_lock_irqsave(&pool->pool_lock, flags);
+ fmr = ib_fmr_cache_lookup(pool,
+ page_list,
+ list_len,
+ io_virtual_address);
+ if (fmr) {
+ /* found in cache */
+ ++fmr->ref_count;
+ if (fmr->ref_count == 1) {
+ list_del(&fmr->list);
+ }
+
+ spin_unlock_irqrestore(&pool->pool_lock, flags);
+
+ return fmr;
+ }
+
+ if (list_empty(&pool->free_list)) {
+ spin_unlock_irqrestore(&pool->pool_lock, flags);
+ return ERR_PTR(-EAGAIN);
+ }
+
+ fmr = list_entry(pool->free_list.next, struct ib_pool_fmr, list);
+ list_del(&fmr->list);
+ hlist_del_init(&fmr->cache_node);
+ spin_unlock_irqrestore(&pool->pool_lock, flags);
+
+ result = ib_map_phys_fmr(fmr->fmr, page_list, list_len,
+ io_virtual_address);
+
+ if (result) {
+ spin_lock_irqsave(&pool->pool_lock, flags);
+ list_add(&fmr->list, &pool->free_list);
+ spin_unlock_irqrestore(&pool->pool_lock, flags);
+
+ pr_warn(PFX "fmr_map returns %d\n", result);
+
+ return ERR_PTR(result);
+ }
+
+ ++fmr->remap_count;
+ fmr->ref_count = 1;
+
+ if (pool->cache_bucket) {
+ fmr->io_virtual_address = io_virtual_address;
+ fmr->page_list_len = list_len;
+ memcpy(fmr->page_list, page_list, list_len * sizeof(*page_list));
+
+ spin_lock_irqsave(&pool->pool_lock, flags);
+ hlist_add_head(&fmr->cache_node,
+ pool->cache_bucket + ib_fmr_hash(fmr->page_list[0]));
+ spin_unlock_irqrestore(&pool->pool_lock, flags);
+ }
+
+ return fmr;
+}
+EXPORT_SYMBOL(ib_fmr_pool_map_phys);
+
+/**
+ * ib_fmr_pool_unmap - Unmap FMR
+ * @fmr:FMR to unmap
+ *
+ * Unmap an FMR. The FMR mapping may remain valid until the FMR is
+ * reused (or until ib_flush_fmr_pool() is called).
+ */
+int ib_fmr_pool_unmap(struct ib_pool_fmr *fmr)
+{
+ struct ib_fmr_pool *pool;
+ unsigned long flags;
+
+ pool = fmr->pool;
+
+ spin_lock_irqsave(&pool->pool_lock, flags);
+
+ --fmr->ref_count;
+ if (!fmr->ref_count) {
+ if (fmr->remap_count < pool->max_remaps) {
+ list_add_tail(&fmr->list, &pool->free_list);
+ } else {
+ list_add_tail(&fmr->list, &pool->dirty_list);
+ if (++pool->dirty_len >= pool->dirty_watermark) {
+ atomic_inc(&pool->req_ser);
+ wake_up_process(pool->thread);
+ }
+ }
+ }
+
+#ifdef DEBUG
+ if (fmr->ref_count < 0)
+ pr_warn(PFX "FMR %p has ref count %d < 0\n",
+ fmr, fmr->ref_count);
+#endif
+
+ spin_unlock_irqrestore(&pool->pool_lock, flags);
+
+ return 0;
+}
+EXPORT_SYMBOL(ib_fmr_pool_unmap);
diff --git a/sys/ofed/drivers/infiniband/core/ib_iwcm.c b/sys/ofed/drivers/infiniband/core/ib_iwcm.c
new file mode 100644
index 0000000..9fd1227
--- /dev/null
+++ b/sys/ofed/drivers/infiniband/core/ib_iwcm.c
@@ -0,0 +1,1051 @@
+/*
+ * Copyright (c) 2004, 2005 Intel Corporation. All rights reserved.
+ * Copyright (c) 2004 Topspin Corporation. All rights reserved.
+ * Copyright (c) 2004, 2005 Voltaire Corporation. All rights reserved.
+ * Copyright (c) 2005 Sun Microsystems, Inc. All rights reserved.
+ * Copyright (c) 2005 Open Grid Computing, Inc. All rights reserved.
+ * Copyright (c) 2005 Network Appliance, Inc. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+#include <linux/dma-mapping.h>
+#include <linux/err.h>
+#include <linux/idr.h>
+#include <linux/interrupt.h>
+#include <linux/rbtree.h>
+#include <linux/sched.h>
+#include <linux/spinlock.h>
+#include <linux/workqueue.h>
+#include <linux/completion.h>
+#include <linux/slab.h>
+#include <linux/module.h>
+#include <linux/wait.h>
+
+#include <rdma/iw_cm.h>
+#include <rdma/ib_addr.h>
+#include <rdma/iw_portmap.h>
+
+#include "iwcm.h"
+
+MODULE_AUTHOR("Tom Tucker");
+MODULE_DESCRIPTION("iWARP CM");
+MODULE_LICENSE("Dual BSD/GPL");
+
+static struct workqueue_struct *iwcm_wq;
+struct iwcm_work {
+ struct work_struct work;
+ struct iwcm_id_private *cm_id;
+ struct list_head list;
+ struct iw_cm_event event;
+ struct list_head free_list;
+};
+
+static unsigned int default_backlog = 256;
+
+/*
+ * The following services provide a mechanism for pre-allocating iwcm_work
+ * elements. The design pre-allocates them based on the cm_id type:
+ * LISTENING IDS: Get enough elements preallocated to handle the
+ * listen backlog.
+ * ACTIVE IDS: 4: CONNECT_REPLY, ESTABLISHED, DISCONNECT, CLOSE
+ * PASSIVE IDS: 3: ESTABLISHED, DISCONNECT, CLOSE
+ *
+ * Allocating them in connect and listen avoids having to deal
+ * with allocation failures on the event upcall from the provider (which
+ * is called in the interrupt context).
+ *
+ * One exception is when creating the cm_id for incoming connection requests.
+ * There are two cases:
+ * 1) in the event upcall, cm_event_handler(), for a listening cm_id. If
+ * the backlog is exceeded, then no more connection request events will
+ * be processed. cm_event_handler() returns -ENOMEM in this case. Its up
+ * to the provider to reject the connection request.
+ * 2) in the connection request workqueue handler, cm_conn_req_handler().
+ * If work elements cannot be allocated for the new connect request cm_id,
+ * then IWCM will call the provider reject method. This is ok since
+ * cm_conn_req_handler() runs in the workqueue thread context.
+ */
+
+static struct iwcm_work *get_work(struct iwcm_id_private *cm_id_priv)
+{
+ struct iwcm_work *work;
+
+ if (list_empty(&cm_id_priv->work_free_list))
+ return NULL;
+ work = list_entry(cm_id_priv->work_free_list.next, struct iwcm_work,
+ free_list);
+ list_del_init(&work->free_list);
+ return work;
+}
+
+static void put_work(struct iwcm_work *work)
+{
+ list_add(&work->free_list, &work->cm_id->work_free_list);
+}
+
+static void dealloc_work_entries(struct iwcm_id_private *cm_id_priv)
+{
+ struct list_head *e, *tmp;
+
+ list_for_each_safe(e, tmp, &cm_id_priv->work_free_list)
+ kfree(list_entry(e, struct iwcm_work, free_list));
+}
+
+static int alloc_work_entries(struct iwcm_id_private *cm_id_priv, int count)
+{
+ struct iwcm_work *work;
+
+ BUG_ON(!list_empty(&cm_id_priv->work_free_list));
+ while (count--) {
+ work = kmalloc(sizeof(struct iwcm_work), GFP_KERNEL);
+ if (!work) {
+ dealloc_work_entries(cm_id_priv);
+ return -ENOMEM;
+ }
+ work->cm_id = cm_id_priv;
+ INIT_LIST_HEAD(&work->list);
+ put_work(work);
+ }
+ return 0;
+}
+
+/*
+ * Save private data from incoming connection requests to
+ * iw_cm_event, so the low level driver doesn't have to. Adjust
+ * the event ptr to point to the local copy.
+ */
+static int copy_private_data(struct iw_cm_event *event)
+{
+ void *p;
+
+ p = kmemdup(event->private_data, event->private_data_len, GFP_ATOMIC);
+ if (!p)
+ return -ENOMEM;
+ event->private_data = p;
+ return 0;
+}
+
+static void free_cm_id(struct iwcm_id_private *cm_id_priv)
+{
+ dealloc_work_entries(cm_id_priv);
+ kfree(cm_id_priv);
+}
+
+/*
+ * Release a reference on cm_id. If the last reference is being
+ * released, free the cm_id and return 1.
+ */
+static int iwcm_deref_id(struct iwcm_id_private *cm_id_priv)
+{
+ BUG_ON(atomic_read(&cm_id_priv->refcount)==0);
+ if (atomic_dec_and_test(&cm_id_priv->refcount)) {
+ BUG_ON(!list_empty(&cm_id_priv->work_list));
+ free_cm_id(cm_id_priv);
+ return 1;
+ }
+
+ return 0;
+}
+
+static void add_ref(struct iw_cm_id *cm_id)
+{
+ struct iwcm_id_private *cm_id_priv;
+ cm_id_priv = container_of(cm_id, struct iwcm_id_private, id);
+ atomic_inc(&cm_id_priv->refcount);
+}
+
+static void rem_ref(struct iw_cm_id *cm_id)
+{
+ struct iwcm_id_private *cm_id_priv;
+
+ cm_id_priv = container_of(cm_id, struct iwcm_id_private, id);
+
+ (void)iwcm_deref_id(cm_id_priv);
+}
+
+static int cm_event_handler(struct iw_cm_id *cm_id, struct iw_cm_event *event);
+
+struct iw_cm_id *iw_create_cm_id(struct ib_device *device,
+ iw_cm_handler cm_handler,
+ void *context)
+{
+ struct iwcm_id_private *cm_id_priv;
+
+ cm_id_priv = kzalloc(sizeof(*cm_id_priv), GFP_KERNEL);
+ if (!cm_id_priv)
+ return ERR_PTR(-ENOMEM);
+
+ cm_id_priv->state = IW_CM_STATE_IDLE;
+ cm_id_priv->id.device = device;
+ cm_id_priv->id.cm_handler = cm_handler;
+ cm_id_priv->id.context = context;
+ cm_id_priv->id.event_handler = cm_event_handler;
+ cm_id_priv->id.add_ref = add_ref;
+ cm_id_priv->id.rem_ref = rem_ref;
+ spin_lock_init(&cm_id_priv->lock);
+ atomic_set(&cm_id_priv->refcount, 1);
+ init_waitqueue_head(&cm_id_priv->connect_wait);
+ init_completion(&cm_id_priv->destroy_comp);
+ INIT_LIST_HEAD(&cm_id_priv->work_list);
+ INIT_LIST_HEAD(&cm_id_priv->work_free_list);
+
+ return &cm_id_priv->id;
+}
+EXPORT_SYMBOL(iw_create_cm_id);
+
+
+static int iwcm_modify_qp_err(struct ib_qp *qp)
+{
+ struct ib_qp_attr qp_attr;
+
+ if (!qp)
+ return -EINVAL;
+
+ qp_attr.qp_state = IB_QPS_ERR;
+ return ib_modify_qp(qp, &qp_attr, IB_QP_STATE);
+}
+
+/*
+ * This is really the RDMAC CLOSING state. It is most similar to the
+ * IB SQD QP state.
+ */
+static int iwcm_modify_qp_sqd(struct ib_qp *qp)
+{
+ struct ib_qp_attr qp_attr;
+
+ BUG_ON(qp == NULL);
+ qp_attr.qp_state = IB_QPS_SQD;
+ return ib_modify_qp(qp, &qp_attr, IB_QP_STATE);
+}
+
+/*
+ * CM_ID <-- CLOSING
+ *
+ * Block if a passive or active connection is currently being processed. Then
+ * process the event as follows:
+ * - If we are ESTABLISHED, move to CLOSING and modify the QP state
+ * based on the abrupt flag
+ * - If the connection is already in the CLOSING or IDLE state, the peer is
+ * disconnecting concurrently with us and we've already seen the
+ * DISCONNECT event -- ignore the request and return 0
+ * - Disconnect on a listening endpoint returns -EINVAL
+ */
+int iw_cm_disconnect(struct iw_cm_id *cm_id, int abrupt)
+{
+ struct iwcm_id_private *cm_id_priv;
+ unsigned long flags;
+ int ret = 0;
+ struct ib_qp *qp = NULL;
+
+ cm_id_priv = container_of(cm_id, struct iwcm_id_private, id);
+ /* Wait if we're currently in a connect or accept downcall */
+ wait_event(cm_id_priv->connect_wait,
+ !test_bit(IWCM_F_CONNECT_WAIT, &cm_id_priv->flags));
+
+ spin_lock_irqsave(&cm_id_priv->lock, flags);
+ switch (cm_id_priv->state) {
+ case IW_CM_STATE_ESTABLISHED:
+ cm_id_priv->state = IW_CM_STATE_CLOSING;
+
+ /* QP could be <nul> for user-mode client */
+ if (cm_id_priv->qp)
+ qp = cm_id_priv->qp;
+ else
+ ret = -EINVAL;
+ break;
+ case IW_CM_STATE_LISTEN:
+ ret = -EINVAL;
+ break;
+ case IW_CM_STATE_CLOSING:
+ /* remote peer closed first */
+ case IW_CM_STATE_IDLE:
+ /* accept or connect returned !0 */
+ break;
+ case IW_CM_STATE_CONN_RECV:
+ /*
+ * App called disconnect before/without calling accept after
+ * connect_request event delivered.
+ */
+ break;
+ case IW_CM_STATE_CONN_SENT:
+ /* Can only get here if wait above fails */
+ default:
+ BUG();
+ }
+ spin_unlock_irqrestore(&cm_id_priv->lock, flags);
+
+ if (qp) {
+ if (abrupt)
+ ret = iwcm_modify_qp_err(qp);
+ else
+ ret = iwcm_modify_qp_sqd(qp);
+
+ /*
+ * If both sides are disconnecting the QP could
+ * already be in ERR or SQD states
+ */
+ ret = 0;
+ }
+
+ return ret;
+}
+EXPORT_SYMBOL(iw_cm_disconnect);
+
+/*
+ * CM_ID <-- DESTROYING
+ *
+ * Clean up all resources associated with the connection and release
+ * the initial reference taken by iw_create_cm_id.
+ */
+static void destroy_cm_id(struct iw_cm_id *cm_id)
+{
+ struct iwcm_id_private *cm_id_priv;
+ unsigned long flags;
+
+ cm_id_priv = container_of(cm_id, struct iwcm_id_private, id);
+ /*
+ * Wait if we're currently in a connect or accept downcall. A
+ * listening endpoint should never block here.
+ */
+ wait_event(cm_id_priv->connect_wait,
+ !test_bit(IWCM_F_CONNECT_WAIT, &cm_id_priv->flags));
+
+ /*
+ * Since we're deleting the cm_id, drop any events that
+ * might arrive before the last dereference.
+ */
+ set_bit(IWCM_F_DROP_EVENTS, &cm_id_priv->flags);
+
+ spin_lock_irqsave(&cm_id_priv->lock, flags);
+ switch (cm_id_priv->state) {
+ case IW_CM_STATE_LISTEN:
+ cm_id_priv->state = IW_CM_STATE_DESTROYING;
+ spin_unlock_irqrestore(&cm_id_priv->lock, flags);
+ /* destroy the listening endpoint */
+ cm_id->device->iwcm->destroy_listen(cm_id);
+ spin_lock_irqsave(&cm_id_priv->lock, flags);
+ break;
+ case IW_CM_STATE_ESTABLISHED:
+ cm_id_priv->state = IW_CM_STATE_DESTROYING;
+ spin_unlock_irqrestore(&cm_id_priv->lock, flags);
+ /* Abrupt close of the connection */
+ (void)iwcm_modify_qp_err(cm_id_priv->qp);
+ spin_lock_irqsave(&cm_id_priv->lock, flags);
+ break;
+ case IW_CM_STATE_IDLE:
+ case IW_CM_STATE_CLOSING:
+ cm_id_priv->state = IW_CM_STATE_DESTROYING;
+ break;
+ case IW_CM_STATE_CONN_RECV:
+ /*
+ * App called destroy before/without calling accept after
+ * receiving connection request event notification or
+ * returned non zero from the event callback function.
+ * In either case, must tell the provider to reject.
+ */
+ cm_id_priv->state = IW_CM_STATE_DESTROYING;
+ spin_unlock_irqrestore(&cm_id_priv->lock, flags);
+ cm_id->device->iwcm->reject(cm_id, NULL, 0);
+ spin_lock_irqsave(&cm_id_priv->lock, flags);
+ break;
+ case IW_CM_STATE_CONN_SENT:
+ case IW_CM_STATE_DESTROYING:
+ default:
+ BUG();
+ break;
+ }
+ if (cm_id_priv->qp) {
+ cm_id_priv->id.device->iwcm->rem_ref(cm_id_priv->qp);
+ cm_id_priv->qp = NULL;
+ }
+ spin_unlock_irqrestore(&cm_id_priv->lock, flags);
+
+ (void)iwcm_deref_id(cm_id_priv);
+}
+
+/*
+ * This function is only called by the application thread and cannot
+ * be called by the event thread. The function will wait for all
+ * references to be released on the cm_id and then kfree the cm_id
+ * object.
+ */
+void iw_destroy_cm_id(struct iw_cm_id *cm_id)
+{
+ struct iwcm_id_private *cm_id_priv;
+
+ cm_id_priv = container_of(cm_id, struct iwcm_id_private, id);
+ destroy_cm_id(cm_id);
+}
+EXPORT_SYMBOL(iw_destroy_cm_id);
+
+/**
+ * iw_cm_map - Use portmapper to map the ports
+ * @cm_id: connection manager pointer
+ * @active: Indicates the active side when true
+ * returns nonzero for error only if iwpm_create_mapinfo() fails
+ *
+ * Tries to add a mapping for a port using the Portmapper. If
+ * successful in mapping the IP/Port it will check the remote
+ * mapped IP address for a wildcard IP address and replace the
+ * zero IP address with the remote_addr.
+ */
+static int iw_cm_map(struct iw_cm_id *cm_id, bool active)
+{
+ cm_id->m_local_addr = cm_id->local_addr;
+ cm_id->m_remote_addr = cm_id->remote_addr;
+
+ return 0;
+}
+
+/*
+ * CM_ID <-- LISTEN
+ *
+ * Start listening for connect requests. Generates one CONNECT_REQUEST
+ * event for each inbound connect request.
+ */
+int iw_cm_listen(struct iw_cm_id *cm_id, int backlog)
+{
+ struct iwcm_id_private *cm_id_priv;
+ unsigned long flags;
+ int ret;
+
+ cm_id_priv = container_of(cm_id, struct iwcm_id_private, id);
+
+ if (!backlog)
+ backlog = default_backlog;
+
+ ret = alloc_work_entries(cm_id_priv, backlog);
+ if (ret)
+ return ret;
+
+ spin_lock_irqsave(&cm_id_priv->lock, flags);
+ switch (cm_id_priv->state) {
+ case IW_CM_STATE_IDLE:
+ cm_id_priv->state = IW_CM_STATE_LISTEN;
+ spin_unlock_irqrestore(&cm_id_priv->lock, flags);
+ ret = iw_cm_map(cm_id, false);
+ if (!ret)
+ ret = cm_id->device->iwcm->create_listen(cm_id, backlog);
+ if (ret)
+ cm_id_priv->state = IW_CM_STATE_IDLE;
+ spin_lock_irqsave(&cm_id_priv->lock, flags);
+ break;
+ default:
+ ret = -EINVAL;
+ }
+ spin_unlock_irqrestore(&cm_id_priv->lock, flags);
+
+ return ret;
+}
+EXPORT_SYMBOL(iw_cm_listen);
+
+/*
+ * CM_ID <-- IDLE
+ *
+ * Rejects an inbound connection request. No events are generated.
+ */
+int iw_cm_reject(struct iw_cm_id *cm_id,
+ const void *private_data,
+ u8 private_data_len)
+{
+ struct iwcm_id_private *cm_id_priv;
+ unsigned long flags;
+ int ret;
+
+ cm_id_priv = container_of(cm_id, struct iwcm_id_private, id);
+ set_bit(IWCM_F_CONNECT_WAIT, &cm_id_priv->flags);
+
+ spin_lock_irqsave(&cm_id_priv->lock, flags);
+ if (cm_id_priv->state != IW_CM_STATE_CONN_RECV) {
+ spin_unlock_irqrestore(&cm_id_priv->lock, flags);
+ clear_bit(IWCM_F_CONNECT_WAIT, &cm_id_priv->flags);
+ wake_up_all(&cm_id_priv->connect_wait);
+ return -EINVAL;
+ }
+ cm_id_priv->state = IW_CM_STATE_IDLE;
+ spin_unlock_irqrestore(&cm_id_priv->lock, flags);
+
+ ret = cm_id->device->iwcm->reject(cm_id, private_data,
+ private_data_len);
+
+ clear_bit(IWCM_F_CONNECT_WAIT, &cm_id_priv->flags);
+ wake_up_all(&cm_id_priv->connect_wait);
+
+ return ret;
+}
+EXPORT_SYMBOL(iw_cm_reject);
+
+/*
+ * CM_ID <-- ESTABLISHED
+ *
+ * Accepts an inbound connection request and generates an ESTABLISHED
+ * event. Callers of iw_cm_disconnect and iw_destroy_cm_id will block
+ * until the ESTABLISHED event is received from the provider.
+ */
+int iw_cm_accept(struct iw_cm_id *cm_id,
+ struct iw_cm_conn_param *iw_param)
+{
+ struct iwcm_id_private *cm_id_priv;
+ struct ib_qp *qp;
+ unsigned long flags;
+ int ret;
+
+ cm_id_priv = container_of(cm_id, struct iwcm_id_private, id);
+ set_bit(IWCM_F_CONNECT_WAIT, &cm_id_priv->flags);
+
+ spin_lock_irqsave(&cm_id_priv->lock, flags);
+ if (cm_id_priv->state != IW_CM_STATE_CONN_RECV) {
+ spin_unlock_irqrestore(&cm_id_priv->lock, flags);
+ clear_bit(IWCM_F_CONNECT_WAIT, &cm_id_priv->flags);
+ wake_up_all(&cm_id_priv->connect_wait);
+ return -EINVAL;
+ }
+ /* Get the ib_qp given the QPN */
+ qp = cm_id->device->iwcm->get_qp(cm_id->device, iw_param->qpn);
+ if (!qp) {
+ spin_unlock_irqrestore(&cm_id_priv->lock, flags);
+ clear_bit(IWCM_F_CONNECT_WAIT, &cm_id_priv->flags);
+ wake_up_all(&cm_id_priv->connect_wait);
+ return -EINVAL;
+ }
+ cm_id->device->iwcm->add_ref(qp);
+ cm_id_priv->qp = qp;
+ spin_unlock_irqrestore(&cm_id_priv->lock, flags);
+
+ ret = cm_id->device->iwcm->accept(cm_id, iw_param);
+ if (ret) {
+ /* An error on accept precludes provider events */
+ BUG_ON(cm_id_priv->state != IW_CM_STATE_CONN_RECV);
+ cm_id_priv->state = IW_CM_STATE_IDLE;
+ spin_lock_irqsave(&cm_id_priv->lock, flags);
+ if (cm_id_priv->qp) {
+ cm_id->device->iwcm->rem_ref(qp);
+ cm_id_priv->qp = NULL;
+ }
+ spin_unlock_irqrestore(&cm_id_priv->lock, flags);
+ clear_bit(IWCM_F_CONNECT_WAIT, &cm_id_priv->flags);
+ wake_up_all(&cm_id_priv->connect_wait);
+ }
+
+ return ret;
+}
+EXPORT_SYMBOL(iw_cm_accept);
+
+/*
+ * Active Side: CM_ID <-- CONN_SENT
+ *
+ * If successful, results in the generation of a CONNECT_REPLY
+ * event. iw_cm_disconnect and iw_cm_destroy will block until the
+ * CONNECT_REPLY event is received from the provider.
+ */
+int iw_cm_connect(struct iw_cm_id *cm_id, struct iw_cm_conn_param *iw_param)
+{
+ struct iwcm_id_private *cm_id_priv;
+ int ret;
+ unsigned long flags;
+ struct ib_qp *qp;
+
+ cm_id_priv = container_of(cm_id, struct iwcm_id_private, id);
+
+ ret = alloc_work_entries(cm_id_priv, 4);
+ if (ret)
+ return ret;
+
+ set_bit(IWCM_F_CONNECT_WAIT, &cm_id_priv->flags);
+ spin_lock_irqsave(&cm_id_priv->lock, flags);
+
+ if (cm_id_priv->state != IW_CM_STATE_IDLE) {
+ ret = -EINVAL;
+ goto err;
+ }
+
+ /* Get the ib_qp given the QPN */
+ qp = cm_id->device->iwcm->get_qp(cm_id->device, iw_param->qpn);
+ if (!qp) {
+ ret = -EINVAL;
+ goto err;
+ }
+ cm_id->device->iwcm->add_ref(qp);
+ cm_id_priv->qp = qp;
+ cm_id_priv->state = IW_CM_STATE_CONN_SENT;
+ spin_unlock_irqrestore(&cm_id_priv->lock, flags);
+
+ ret = iw_cm_map(cm_id, true);
+ if (!ret)
+ ret = cm_id->device->iwcm->connect(cm_id, iw_param);
+ if (!ret)
+ return 0; /* success */
+
+ spin_lock_irqsave(&cm_id_priv->lock, flags);
+ if (cm_id_priv->qp) {
+ cm_id->device->iwcm->rem_ref(qp);
+ cm_id_priv->qp = NULL;
+ }
+ cm_id_priv->state = IW_CM_STATE_IDLE;
+err:
+ spin_unlock_irqrestore(&cm_id_priv->lock, flags);
+ clear_bit(IWCM_F_CONNECT_WAIT, &cm_id_priv->flags);
+ wake_up_all(&cm_id_priv->connect_wait);
+ return ret;
+}
+EXPORT_SYMBOL(iw_cm_connect);
+
+/*
+ * Passive Side: new CM_ID <-- CONN_RECV
+ *
+ * Handles an inbound connect request. The function creates a new
+ * iw_cm_id to represent the new connection and inherits the client
+ * callback function and other attributes from the listening parent.
+ *
+ * The work item contains a pointer to the listen_cm_id and the event. The
+ * listen_cm_id contains the client cm_handler, context and
+ * device. These are copied when the device is cloned. The event
+ * contains the new four tuple.
+ *
+ * An error on the child should not affect the parent, so this
+ * function does not return a value.
+ */
+static void cm_conn_req_handler(struct iwcm_id_private *listen_id_priv,
+ struct iw_cm_event *iw_event)
+{
+ unsigned long flags;
+ struct iw_cm_id *cm_id;
+ struct iwcm_id_private *cm_id_priv;
+ int ret;
+
+ /*
+ * The provider should never generate a connection request
+ * event with a bad status.
+ */
+ BUG_ON(iw_event->status);
+
+ cm_id = iw_create_cm_id(listen_id_priv->id.device,
+ listen_id_priv->id.cm_handler,
+ listen_id_priv->id.context);
+ /* If the cm_id could not be created, ignore the request */
+ if (IS_ERR(cm_id))
+ goto out;
+
+ cm_id->provider_data = iw_event->provider_data;
+ cm_id->m_local_addr = iw_event->local_addr;
+ cm_id->m_remote_addr = iw_event->remote_addr;
+ cm_id->local_addr = listen_id_priv->id.local_addr;
+ cm_id->remote_addr = iw_event->remote_addr;
+ cm_id_priv = container_of(cm_id, struct iwcm_id_private, id);
+ cm_id_priv->state = IW_CM_STATE_CONN_RECV;
+
+ /*
+ * We could be destroying the listening id. If so, ignore this
+ * upcall.
+ */
+ spin_lock_irqsave(&listen_id_priv->lock, flags);
+ if (listen_id_priv->state != IW_CM_STATE_LISTEN) {
+ spin_unlock_irqrestore(&listen_id_priv->lock, flags);
+ iw_cm_reject(cm_id, NULL, 0);
+ iw_destroy_cm_id(cm_id);
+ goto out;
+ }
+ spin_unlock_irqrestore(&listen_id_priv->lock, flags);
+
+ ret = alloc_work_entries(cm_id_priv, 3);
+ if (ret) {
+ iw_cm_reject(cm_id, NULL, 0);
+ iw_destroy_cm_id(cm_id);
+ goto out;
+ }
+
+ /* Call the client CM handler */
+ ret = cm_id->cm_handler(cm_id, iw_event);
+ if (ret) {
+ iw_cm_reject(cm_id, NULL, 0);
+ iw_destroy_cm_id(cm_id);
+ }
+
+out:
+ if (iw_event->private_data_len)
+ kfree(iw_event->private_data);
+}
+
+/*
+ * Passive Side: CM_ID <-- ESTABLISHED
+ *
+ * The provider generated an ESTABLISHED event which means that
+ * the MPA negotion has completed successfully and we are now in MPA
+ * FPDU mode.
+ *
+ * This event can only be received in the CONN_RECV state. If the
+ * remote peer closed, the ESTABLISHED event would be received followed
+ * by the CLOSE event. If the app closes, it will block until we wake
+ * it up after processing this event.
+ */
+static int cm_conn_est_handler(struct iwcm_id_private *cm_id_priv,
+ struct iw_cm_event *iw_event)
+{
+ unsigned long flags;
+ int ret;
+
+ spin_lock_irqsave(&cm_id_priv->lock, flags);
+
+ /*
+ * We clear the CONNECT_WAIT bit here to allow the callback
+ * function to call iw_cm_disconnect. Calling iw_destroy_cm_id
+ * from a callback handler is not allowed.
+ */
+ clear_bit(IWCM_F_CONNECT_WAIT, &cm_id_priv->flags);
+ BUG_ON(cm_id_priv->state != IW_CM_STATE_CONN_RECV);
+ cm_id_priv->state = IW_CM_STATE_ESTABLISHED;
+ spin_unlock_irqrestore(&cm_id_priv->lock, flags);
+ ret = cm_id_priv->id.cm_handler(&cm_id_priv->id, iw_event);
+ wake_up_all(&cm_id_priv->connect_wait);
+
+ return ret;
+}
+
+/*
+ * Active Side: CM_ID <-- ESTABLISHED
+ *
+ * The app has called connect and is waiting for the established event to
+ * post it's requests to the server. This event will wake up anyone
+ * blocked in iw_cm_disconnect or iw_destroy_id.
+ */
+static int cm_conn_rep_handler(struct iwcm_id_private *cm_id_priv,
+ struct iw_cm_event *iw_event)
+{
+ unsigned long flags;
+ int ret;
+
+ spin_lock_irqsave(&cm_id_priv->lock, flags);
+ /*
+ * Clear the connect wait bit so a callback function calling
+ * iw_cm_disconnect will not wait and deadlock this thread
+ */
+ clear_bit(IWCM_F_CONNECT_WAIT, &cm_id_priv->flags);
+ BUG_ON(cm_id_priv->state != IW_CM_STATE_CONN_SENT);
+ if (iw_event->status == 0) {
+ cm_id_priv->id.m_local_addr = iw_event->local_addr;
+ cm_id_priv->id.m_remote_addr = iw_event->remote_addr;
+ iw_event->local_addr = cm_id_priv->id.local_addr;
+ iw_event->remote_addr = cm_id_priv->id.remote_addr;
+ cm_id_priv->state = IW_CM_STATE_ESTABLISHED;
+ } else {
+ /* REJECTED or RESET */
+ cm_id_priv->id.device->iwcm->rem_ref(cm_id_priv->qp);
+ cm_id_priv->qp = NULL;
+ cm_id_priv->state = IW_CM_STATE_IDLE;
+ }
+ spin_unlock_irqrestore(&cm_id_priv->lock, flags);
+ ret = cm_id_priv->id.cm_handler(&cm_id_priv->id, iw_event);
+
+ if (iw_event->private_data_len)
+ kfree(iw_event->private_data);
+
+ /* Wake up waiters on connect complete */
+ wake_up_all(&cm_id_priv->connect_wait);
+
+ return ret;
+}
+
+/*
+ * CM_ID <-- CLOSING
+ *
+ * If in the ESTABLISHED state, move to CLOSING.
+ */
+static void cm_disconnect_handler(struct iwcm_id_private *cm_id_priv,
+ struct iw_cm_event *iw_event)
+{
+ unsigned long flags;
+
+ spin_lock_irqsave(&cm_id_priv->lock, flags);
+ if (cm_id_priv->state == IW_CM_STATE_ESTABLISHED)
+ cm_id_priv->state = IW_CM_STATE_CLOSING;
+ spin_unlock_irqrestore(&cm_id_priv->lock, flags);
+}
+
+/*
+ * CM_ID <-- IDLE
+ *
+ * If in the ESTBLISHED or CLOSING states, the QP will have have been
+ * moved by the provider to the ERR state. Disassociate the CM_ID from
+ * the QP, move to IDLE, and remove the 'connected' reference.
+ *
+ * If in some other state, the cm_id was destroyed asynchronously.
+ * This is the last reference that will result in waking up
+ * the app thread blocked in iw_destroy_cm_id.
+ */
+static int cm_close_handler(struct iwcm_id_private *cm_id_priv,
+ struct iw_cm_event *iw_event)
+{
+ unsigned long flags;
+ int ret = 0;
+ spin_lock_irqsave(&cm_id_priv->lock, flags);
+
+ if (cm_id_priv->qp) {
+ cm_id_priv->id.device->iwcm->rem_ref(cm_id_priv->qp);
+ cm_id_priv->qp = NULL;
+ }
+ switch (cm_id_priv->state) {
+ case IW_CM_STATE_ESTABLISHED:
+ case IW_CM_STATE_CLOSING:
+ cm_id_priv->state = IW_CM_STATE_IDLE;
+ spin_unlock_irqrestore(&cm_id_priv->lock, flags);
+ ret = cm_id_priv->id.cm_handler(&cm_id_priv->id, iw_event);
+ spin_lock_irqsave(&cm_id_priv->lock, flags);
+ break;
+ case IW_CM_STATE_DESTROYING:
+ break;
+ default:
+ BUG();
+ }
+ spin_unlock_irqrestore(&cm_id_priv->lock, flags);
+
+ return ret;
+}
+
+static int process_event(struct iwcm_id_private *cm_id_priv,
+ struct iw_cm_event *iw_event)
+{
+ int ret = 0;
+
+ switch (iw_event->event) {
+ case IW_CM_EVENT_CONNECT_REQUEST:
+ cm_conn_req_handler(cm_id_priv, iw_event);
+ break;
+ case IW_CM_EVENT_CONNECT_REPLY:
+ ret = cm_conn_rep_handler(cm_id_priv, iw_event);
+ break;
+ case IW_CM_EVENT_ESTABLISHED:
+ ret = cm_conn_est_handler(cm_id_priv, iw_event);
+ break;
+ case IW_CM_EVENT_DISCONNECT:
+ cm_disconnect_handler(cm_id_priv, iw_event);
+ break;
+ case IW_CM_EVENT_CLOSE:
+ ret = cm_close_handler(cm_id_priv, iw_event);
+ break;
+ default:
+ BUG();
+ }
+
+ return ret;
+}
+
+/*
+ * Process events on the work_list for the cm_id. If the callback
+ * function requests that the cm_id be deleted, a flag is set in the
+ * cm_id flags to indicate that when the last reference is
+ * removed, the cm_id is to be destroyed. This is necessary to
+ * distinguish between an object that will be destroyed by the app
+ * thread asleep on the destroy_comp list vs. an object destroyed
+ * here synchronously when the last reference is removed.
+ */
+static void cm_work_handler(struct work_struct *_work)
+{
+ struct iwcm_work *work = container_of(_work, struct iwcm_work, work);
+ struct iw_cm_event levent;
+ struct iwcm_id_private *cm_id_priv = work->cm_id;
+ unsigned long flags;
+ int empty;
+ int ret = 0;
+
+ spin_lock_irqsave(&cm_id_priv->lock, flags);
+ empty = list_empty(&cm_id_priv->work_list);
+ while (!empty) {
+ work = list_entry(cm_id_priv->work_list.next,
+ struct iwcm_work, list);
+ list_del_init(&work->list);
+ empty = list_empty(&cm_id_priv->work_list);
+ levent = work->event;
+ put_work(work);
+ spin_unlock_irqrestore(&cm_id_priv->lock, flags);
+
+ if (!test_bit(IWCM_F_DROP_EVENTS, &cm_id_priv->flags)) {
+ ret = process_event(cm_id_priv, &levent);
+ if (ret)
+ destroy_cm_id(&cm_id_priv->id);
+ } else
+ pr_debug("dropping event %d\n", levent.event);
+ if (iwcm_deref_id(cm_id_priv))
+ return;
+ if (empty)
+ return;
+ spin_lock_irqsave(&cm_id_priv->lock, flags);
+ }
+ spin_unlock_irqrestore(&cm_id_priv->lock, flags);
+}
+
+/*
+ * This function is called on interrupt context. Schedule events on
+ * the iwcm_wq thread to allow callback functions to downcall into
+ * the CM and/or block. Events are queued to a per-CM_ID
+ * work_list. If this is the first event on the work_list, the work
+ * element is also queued on the iwcm_wq thread.
+ *
+ * Each event holds a reference on the cm_id. Until the last posted
+ * event has been delivered and processed, the cm_id cannot be
+ * deleted.
+ *
+ * Returns:
+ * 0 - the event was handled.
+ * -ENOMEM - the event was not handled due to lack of resources.
+ */
+static int cm_event_handler(struct iw_cm_id *cm_id,
+ struct iw_cm_event *iw_event)
+{
+ struct iwcm_work *work;
+ struct iwcm_id_private *cm_id_priv;
+ unsigned long flags;
+ int ret = 0;
+
+ cm_id_priv = container_of(cm_id, struct iwcm_id_private, id);
+
+ spin_lock_irqsave(&cm_id_priv->lock, flags);
+ work = get_work(cm_id_priv);
+ if (!work) {
+ ret = -ENOMEM;
+ goto out;
+ }
+
+ INIT_WORK(&work->work, cm_work_handler);
+ work->cm_id = cm_id_priv;
+ work->event = *iw_event;
+
+ if ((work->event.event == IW_CM_EVENT_CONNECT_REQUEST ||
+ work->event.event == IW_CM_EVENT_CONNECT_REPLY) &&
+ work->event.private_data_len) {
+ ret = copy_private_data(&work->event);
+ if (ret) {
+ put_work(work);
+ goto out;
+ }
+ }
+
+ atomic_inc(&cm_id_priv->refcount);
+ if (list_empty(&cm_id_priv->work_list)) {
+ list_add_tail(&work->list, &cm_id_priv->work_list);
+ queue_work(iwcm_wq, &work->work);
+ } else
+ list_add_tail(&work->list, &cm_id_priv->work_list);
+out:
+ spin_unlock_irqrestore(&cm_id_priv->lock, flags);
+ return ret;
+}
+
+static int iwcm_init_qp_init_attr(struct iwcm_id_private *cm_id_priv,
+ struct ib_qp_attr *qp_attr,
+ int *qp_attr_mask)
+{
+ unsigned long flags;
+ int ret;
+
+ spin_lock_irqsave(&cm_id_priv->lock, flags);
+ switch (cm_id_priv->state) {
+ case IW_CM_STATE_IDLE:
+ case IW_CM_STATE_CONN_SENT:
+ case IW_CM_STATE_CONN_RECV:
+ case IW_CM_STATE_ESTABLISHED:
+ *qp_attr_mask = IB_QP_STATE | IB_QP_ACCESS_FLAGS;
+ qp_attr->qp_access_flags = IB_ACCESS_REMOTE_WRITE|
+ IB_ACCESS_REMOTE_READ;
+ ret = 0;
+ break;
+ default:
+ ret = -EINVAL;
+ break;
+ }
+ spin_unlock_irqrestore(&cm_id_priv->lock, flags);
+ return ret;
+}
+
+static int iwcm_init_qp_rts_attr(struct iwcm_id_private *cm_id_priv,
+ struct ib_qp_attr *qp_attr,
+ int *qp_attr_mask)
+{
+ unsigned long flags;
+ int ret;
+
+ spin_lock_irqsave(&cm_id_priv->lock, flags);
+ switch (cm_id_priv->state) {
+ case IW_CM_STATE_IDLE:
+ case IW_CM_STATE_CONN_SENT:
+ case IW_CM_STATE_CONN_RECV:
+ case IW_CM_STATE_ESTABLISHED:
+ *qp_attr_mask = 0;
+ ret = 0;
+ break;
+ default:
+ ret = -EINVAL;
+ break;
+ }
+ spin_unlock_irqrestore(&cm_id_priv->lock, flags);
+ return ret;
+}
+
+int iw_cm_init_qp_attr(struct iw_cm_id *cm_id,
+ struct ib_qp_attr *qp_attr,
+ int *qp_attr_mask)
+{
+ struct iwcm_id_private *cm_id_priv;
+ int ret;
+
+ cm_id_priv = container_of(cm_id, struct iwcm_id_private, id);
+ switch (qp_attr->qp_state) {
+ case IB_QPS_INIT:
+ case IB_QPS_RTR:
+ ret = iwcm_init_qp_init_attr(cm_id_priv,
+ qp_attr, qp_attr_mask);
+ break;
+ case IB_QPS_RTS:
+ ret = iwcm_init_qp_rts_attr(cm_id_priv,
+ qp_attr, qp_attr_mask);
+ break;
+ default:
+ ret = -EINVAL;
+ break;
+ }
+ return ret;
+}
+EXPORT_SYMBOL(iw_cm_init_qp_attr);
+
+static int __init iw_cm_init(void)
+{
+ iwcm_wq = alloc_ordered_workqueue("iw_cm_wq", WQ_MEM_RECLAIM);
+ if (!iwcm_wq)
+ return -ENOMEM;
+
+ return 0;
+}
+
+static void __exit iw_cm_cleanup(void)
+{
+ destroy_workqueue(iwcm_wq);
+}
+
+module_init(iw_cm_init);
+module_exit(iw_cm_cleanup);
diff --git a/sys/ofed/drivers/infiniband/core/ib_iwpm_msg.c b/sys/ofed/drivers/infiniband/core/ib_iwpm_msg.c
new file mode 100644
index 0000000..158b977
--- /dev/null
+++ b/sys/ofed/drivers/infiniband/core/ib_iwpm_msg.c
@@ -0,0 +1,43 @@
+/*
+ * Copyright (c) 2014 Intel Corporation. All rights reserved.
+ * Copyright (c) 2014 Chelsio, Inc. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#include "iwpm_util.h"
+
+static int iwpm_user_pid = IWPM_PID_UNDEFINED;
+
+int iwpm_valid_pid(void)
+{
+ return iwpm_user_pid > 0;
+}
+EXPORT_SYMBOL(iwpm_valid_pid);
+
diff --git a/sys/ofed/drivers/infiniband/core/ib_iwpm_util.c b/sys/ofed/drivers/infiniband/core/ib_iwpm_util.c
new file mode 100644
index 0000000..13eef42
--- /dev/null
+++ b/sys/ofed/drivers/infiniband/core/ib_iwpm_util.c
@@ -0,0 +1,97 @@
+/*
+ * Copyright (c) 2014 Chelsio, Inc. All rights reserved.
+ * Copyright (c) 2014 Intel Corporation. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#include "iwpm_util.h"
+
+#define IWPM_MAPINFO_HASH_SIZE 512
+#define IWPM_MAPINFO_HASH_MASK (IWPM_MAPINFO_HASH_SIZE - 1)
+#define IWPM_REMINFO_HASH_SIZE 64
+#define IWPM_REMINFO_HASH_MASK (IWPM_REMINFO_HASH_SIZE - 1)
+#define IWPM_MSG_SIZE 512
+
+int iwpm_compare_sockaddr(struct sockaddr_storage *a_sockaddr,
+ struct sockaddr_storage *b_sockaddr)
+{
+ if (a_sockaddr->ss_family != b_sockaddr->ss_family)
+ return 1;
+ if (a_sockaddr->ss_family == AF_INET) {
+ struct sockaddr_in *a4_sockaddr =
+ (struct sockaddr_in *)a_sockaddr;
+ struct sockaddr_in *b4_sockaddr =
+ (struct sockaddr_in *)b_sockaddr;
+ if (!memcmp(&a4_sockaddr->sin_addr,
+ &b4_sockaddr->sin_addr, sizeof(struct in_addr))
+ && a4_sockaddr->sin_port == b4_sockaddr->sin_port)
+ return 0;
+
+ } else if (a_sockaddr->ss_family == AF_INET6) {
+ struct sockaddr_in6 *a6_sockaddr =
+ (struct sockaddr_in6 *)a_sockaddr;
+ struct sockaddr_in6 *b6_sockaddr =
+ (struct sockaddr_in6 *)b_sockaddr;
+ if (!memcmp(&a6_sockaddr->sin6_addr,
+ &b6_sockaddr->sin6_addr, sizeof(struct in6_addr))
+ && a6_sockaddr->sin6_port == b6_sockaddr->sin6_port)
+ return 0;
+
+ } else {
+ pr_err("%s: Invalid sockaddr family\n", __func__);
+ }
+ return 1;
+}
+
+void iwpm_print_sockaddr(struct sockaddr_storage *sockaddr, char *msg)
+{
+ struct sockaddr_in6 *sockaddr_v6;
+ struct sockaddr_in *sockaddr_v4;
+
+ switch (sockaddr->ss_family) {
+ case AF_INET:
+ sockaddr_v4 = (struct sockaddr_in *)sockaddr;
+ pr_debug("%s IPV4 %pI4: %u(0x%04X)\n",
+ msg, &sockaddr_v4->sin_addr,
+ ntohs(sockaddr_v4->sin_port),
+ ntohs(sockaddr_v4->sin_port));
+ break;
+ case AF_INET6:
+ sockaddr_v6 = (struct sockaddr_in6 *)sockaddr;
+ pr_debug("%s IPV6 %pI6: %u(0x%04X)\n",
+ msg, &sockaddr_v6->sin6_addr,
+ ntohs(sockaddr_v6->sin6_port),
+ ntohs(sockaddr_v6->sin6_port));
+ break;
+ default:
+ break;
+ }
+}
+
diff --git a/sys/ofed/drivers/infiniband/core/ib_mad.c b/sys/ofed/drivers/infiniband/core/ib_mad.c
new file mode 100644
index 0000000..97439a3
--- /dev/null
+++ b/sys/ofed/drivers/infiniband/core/ib_mad.c
@@ -0,0 +1,3339 @@
+/*
+ * Copyright (c) 2004-2007 Voltaire, Inc. All rights reserved.
+ * Copyright (c) 2005 Intel Corporation. All rights reserved.
+ * Copyright (c) 2005 Mellanox Technologies Ltd. All rights reserved.
+ * Copyright (c) 2009 HNR Consulting. All rights reserved.
+ * Copyright (c) 2014 Intel Corporation. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+#define LINUXKPI_PARAM_PREFIX ibcore_
+#define KBUILD_MODNAME "ibcore"
+
+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+
+#include <linux/dma-mapping.h>
+#include <linux/slab.h>
+#include <linux/module.h>
+#include <rdma/ib_cache.h>
+
+#include "mad_priv.h"
+#include "mad_rmpp.h"
+#include "smi.h"
+#include "opa_smi.h"
+#include "agent.h"
+#include "core_priv.h"
+
+static int mad_sendq_size = IB_MAD_QP_SEND_SIZE;
+static int mad_recvq_size = IB_MAD_QP_RECV_SIZE;
+
+module_param_named(send_queue_size, mad_sendq_size, int, 0444);
+MODULE_PARM_DESC(send_queue_size, "Size of send queue in number of work requests");
+module_param_named(recv_queue_size, mad_recvq_size, int, 0444);
+MODULE_PARM_DESC(recv_queue_size, "Size of receive queue in number of work requests");
+
+static struct list_head ib_mad_port_list;
+static u32 ib_mad_client_id = 0;
+
+/* Port list lock */
+static DEFINE_SPINLOCK(ib_mad_port_list_lock);
+
+/* Forward declarations */
+static int method_in_use(struct ib_mad_mgmt_method_table **method,
+ struct ib_mad_reg_req *mad_reg_req);
+static void remove_mad_reg_req(struct ib_mad_agent_private *priv);
+static struct ib_mad_agent_private *find_mad_agent(
+ struct ib_mad_port_private *port_priv,
+ const struct ib_mad_hdr *mad);
+static int ib_mad_post_receive_mads(struct ib_mad_qp_info *qp_info,
+ struct ib_mad_private *mad);
+static void cancel_mads(struct ib_mad_agent_private *mad_agent_priv);
+static void timeout_sends(struct work_struct *work);
+static void local_completions(struct work_struct *work);
+static int add_nonoui_reg_req(struct ib_mad_reg_req *mad_reg_req,
+ struct ib_mad_agent_private *agent_priv,
+ u8 mgmt_class);
+static int add_oui_reg_req(struct ib_mad_reg_req *mad_reg_req,
+ struct ib_mad_agent_private *agent_priv);
+static bool ib_mad_send_error(struct ib_mad_port_private *port_priv,
+ struct ib_wc *wc);
+static void ib_mad_send_done(struct ib_cq *cq, struct ib_wc *wc);
+
+/*
+ * Returns a ib_mad_port_private structure or NULL for a device/port
+ * Assumes ib_mad_port_list_lock is being held
+ */
+static inline struct ib_mad_port_private *
+__ib_get_mad_port(struct ib_device *device, int port_num)
+{
+ struct ib_mad_port_private *entry;
+
+ list_for_each_entry(entry, &ib_mad_port_list, port_list) {
+ if (entry->device == device && entry->port_num == port_num)
+ return entry;
+ }
+ return NULL;
+}
+
+/*
+ * Wrapper function to return a ib_mad_port_private structure or NULL
+ * for a device/port
+ */
+static inline struct ib_mad_port_private *
+ib_get_mad_port(struct ib_device *device, int port_num)
+{
+ struct ib_mad_port_private *entry;
+ unsigned long flags;
+
+ spin_lock_irqsave(&ib_mad_port_list_lock, flags);
+ entry = __ib_get_mad_port(device, port_num);
+ spin_unlock_irqrestore(&ib_mad_port_list_lock, flags);
+
+ return entry;
+}
+
+static inline u8 convert_mgmt_class(u8 mgmt_class)
+{
+ /* Alias IB_MGMT_CLASS_SUBN_DIRECTED_ROUTE to 0 */
+ return mgmt_class == IB_MGMT_CLASS_SUBN_DIRECTED_ROUTE ?
+ 0 : mgmt_class;
+}
+
+static int get_spl_qp_index(enum ib_qp_type qp_type)
+{
+ switch (qp_type)
+ {
+ case IB_QPT_SMI:
+ return 0;
+ case IB_QPT_GSI:
+ return 1;
+ default:
+ return -1;
+ }
+}
+
+static int vendor_class_index(u8 mgmt_class)
+{
+ return mgmt_class - IB_MGMT_CLASS_VENDOR_RANGE2_START;
+}
+
+static int is_vendor_class(u8 mgmt_class)
+{
+ if ((mgmt_class < IB_MGMT_CLASS_VENDOR_RANGE2_START) ||
+ (mgmt_class > IB_MGMT_CLASS_VENDOR_RANGE2_END))
+ return 0;
+ return 1;
+}
+
+static int is_vendor_oui(char *oui)
+{
+ if (oui[0] || oui[1] || oui[2])
+ return 1;
+ return 0;
+}
+
+static int is_vendor_method_in_use(
+ struct ib_mad_mgmt_vendor_class *vendor_class,
+ struct ib_mad_reg_req *mad_reg_req)
+{
+ struct ib_mad_mgmt_method_table *method;
+ int i;
+
+ for (i = 0; i < MAX_MGMT_OUI; i++) {
+ if (!memcmp(vendor_class->oui[i], mad_reg_req->oui, 3)) {
+ method = vendor_class->method_table[i];
+ if (method) {
+ if (method_in_use(&method, mad_reg_req))
+ return 1;
+ else
+ break;
+ }
+ }
+ }
+ return 0;
+}
+
+int ib_response_mad(const struct ib_mad_hdr *hdr)
+{
+ return ((hdr->method & IB_MGMT_METHOD_RESP) ||
+ (hdr->method == IB_MGMT_METHOD_TRAP_REPRESS) ||
+ ((hdr->mgmt_class == IB_MGMT_CLASS_BM) &&
+ (hdr->attr_mod & IB_BM_ATTR_MOD_RESP)));
+}
+EXPORT_SYMBOL(ib_response_mad);
+
+/*
+ * ib_register_mad_agent - Register to send/receive MADs
+ */
+struct ib_mad_agent *ib_register_mad_agent(struct ib_device *device,
+ u8 port_num,
+ enum ib_qp_type qp_type,
+ struct ib_mad_reg_req *mad_reg_req,
+ u8 rmpp_version,
+ ib_mad_send_handler send_handler,
+ ib_mad_recv_handler recv_handler,
+ void *context,
+ u32 registration_flags)
+{
+ struct ib_mad_port_private *port_priv;
+ struct ib_mad_agent *ret = ERR_PTR(-EINVAL);
+ struct ib_mad_agent_private *mad_agent_priv;
+ struct ib_mad_reg_req *reg_req = NULL;
+ struct ib_mad_mgmt_class_table *class;
+ struct ib_mad_mgmt_vendor_class_table *vendor;
+ struct ib_mad_mgmt_vendor_class *vendor_class;
+ struct ib_mad_mgmt_method_table *method;
+ int ret2, qpn;
+ unsigned long flags;
+ u8 mgmt_class, vclass;
+
+ /* Validate parameters */
+ qpn = get_spl_qp_index(qp_type);
+ if (qpn == -1) {
+ dev_notice(&device->dev,
+ "ib_register_mad_agent: invalid QP Type %d\n",
+ qp_type);
+ goto error1;
+ }
+
+ if (rmpp_version && rmpp_version != IB_MGMT_RMPP_VERSION) {
+ dev_notice(&device->dev,
+ "ib_register_mad_agent: invalid RMPP Version %u\n",
+ rmpp_version);
+ goto error1;
+ }
+
+ /* Validate MAD registration request if supplied */
+ if (mad_reg_req) {
+ if (mad_reg_req->mgmt_class_version >= MAX_MGMT_VERSION) {
+ dev_notice(&device->dev,
+ "ib_register_mad_agent: invalid Class Version %u\n",
+ mad_reg_req->mgmt_class_version);
+ goto error1;
+ }
+ if (!recv_handler) {
+ dev_notice(&device->dev,
+ "ib_register_mad_agent: no recv_handler\n");
+ goto error1;
+ }
+ if (mad_reg_req->mgmt_class >= MAX_MGMT_CLASS) {
+ /*
+ * IB_MGMT_CLASS_SUBN_DIRECTED_ROUTE is the only
+ * one in this range currently allowed
+ */
+ if (mad_reg_req->mgmt_class !=
+ IB_MGMT_CLASS_SUBN_DIRECTED_ROUTE) {
+ dev_notice(&device->dev,
+ "ib_register_mad_agent: Invalid Mgmt Class 0x%x\n",
+ mad_reg_req->mgmt_class);
+ goto error1;
+ }
+ } else if (mad_reg_req->mgmt_class == 0) {
+ /*
+ * Class 0 is reserved in IBA and is used for
+ * aliasing of IB_MGMT_CLASS_SUBN_DIRECTED_ROUTE
+ */
+ dev_notice(&device->dev,
+ "ib_register_mad_agent: Invalid Mgmt Class 0\n");
+ goto error1;
+ } else if (is_vendor_class(mad_reg_req->mgmt_class)) {
+ /*
+ * If class is in "new" vendor range,
+ * ensure supplied OUI is not zero
+ */
+ if (!is_vendor_oui(mad_reg_req->oui)) {
+ dev_notice(&device->dev,
+ "ib_register_mad_agent: No OUI specified for class 0x%x\n",
+ mad_reg_req->mgmt_class);
+ goto error1;
+ }
+ }
+ /* Make sure class supplied is consistent with RMPP */
+ if (!ib_is_mad_class_rmpp(mad_reg_req->mgmt_class)) {
+ if (rmpp_version) {
+ dev_notice(&device->dev,
+ "ib_register_mad_agent: RMPP version for non-RMPP class 0x%x\n",
+ mad_reg_req->mgmt_class);
+ goto error1;
+ }
+ }
+
+ /* Make sure class supplied is consistent with QP type */
+ if (qp_type == IB_QPT_SMI) {
+ if ((mad_reg_req->mgmt_class !=
+ IB_MGMT_CLASS_SUBN_LID_ROUTED) &&
+ (mad_reg_req->mgmt_class !=
+ IB_MGMT_CLASS_SUBN_DIRECTED_ROUTE)) {
+ dev_notice(&device->dev,
+ "ib_register_mad_agent: Invalid SM QP type: class 0x%x\n",
+ mad_reg_req->mgmt_class);
+ goto error1;
+ }
+ } else {
+ if ((mad_reg_req->mgmt_class ==
+ IB_MGMT_CLASS_SUBN_LID_ROUTED) ||
+ (mad_reg_req->mgmt_class ==
+ IB_MGMT_CLASS_SUBN_DIRECTED_ROUTE)) {
+ dev_notice(&device->dev,
+ "ib_register_mad_agent: Invalid GS QP type: class 0x%x\n",
+ mad_reg_req->mgmt_class);
+ goto error1;
+ }
+ }
+ } else {
+ /* No registration request supplied */
+ if (!send_handler)
+ goto error1;
+ if (registration_flags & IB_MAD_USER_RMPP)
+ goto error1;
+ }
+
+ /* Validate device and port */
+ port_priv = ib_get_mad_port(device, port_num);
+ if (!port_priv) {
+ dev_notice(&device->dev, "ib_register_mad_agent: Invalid port\n");
+ ret = ERR_PTR(-ENODEV);
+ goto error1;
+ }
+
+ /* Verify the QP requested is supported. For example, Ethernet devices
+ * will not have QP0 */
+ if (!port_priv->qp_info[qpn].qp) {
+ dev_notice(&device->dev,
+ "ib_register_mad_agent: QP %d not supported\n", qpn);
+ ret = ERR_PTR(-EPROTONOSUPPORT);
+ goto error1;
+ }
+
+ /* Allocate structures */
+ mad_agent_priv = kzalloc(sizeof *mad_agent_priv, GFP_KERNEL);
+ if (!mad_agent_priv) {
+ ret = ERR_PTR(-ENOMEM);
+ goto error1;
+ }
+
+ if (mad_reg_req) {
+ reg_req = kmemdup(mad_reg_req, sizeof *reg_req, GFP_KERNEL);
+ if (!reg_req) {
+ ret = ERR_PTR(-ENOMEM);
+ goto error3;
+ }
+ }
+
+ /* Now, fill in the various structures */
+ mad_agent_priv->qp_info = &port_priv->qp_info[qpn];
+ mad_agent_priv->reg_req = reg_req;
+ mad_agent_priv->agent.rmpp_version = rmpp_version;
+ mad_agent_priv->agent.device = device;
+ mad_agent_priv->agent.recv_handler = recv_handler;
+ mad_agent_priv->agent.send_handler = send_handler;
+ mad_agent_priv->agent.context = context;
+ mad_agent_priv->agent.qp = port_priv->qp_info[qpn].qp;
+ mad_agent_priv->agent.port_num = port_num;
+ mad_agent_priv->agent.flags = registration_flags;
+ spin_lock_init(&mad_agent_priv->lock);
+ INIT_LIST_HEAD(&mad_agent_priv->send_list);
+ INIT_LIST_HEAD(&mad_agent_priv->wait_list);
+ INIT_LIST_HEAD(&mad_agent_priv->done_list);
+ INIT_LIST_HEAD(&mad_agent_priv->rmpp_list);
+ INIT_DELAYED_WORK(&mad_agent_priv->timed_work, timeout_sends);
+ INIT_LIST_HEAD(&mad_agent_priv->local_list);
+ INIT_WORK(&mad_agent_priv->local_work, local_completions);
+ atomic_set(&mad_agent_priv->refcount, 1);
+ init_completion(&mad_agent_priv->comp);
+
+ spin_lock_irqsave(&port_priv->reg_lock, flags);
+ mad_agent_priv->agent.hi_tid = ++ib_mad_client_id;
+
+ /*
+ * Make sure MAD registration (if supplied)
+ * is non overlapping with any existing ones
+ */
+ if (mad_reg_req) {
+ mgmt_class = convert_mgmt_class(mad_reg_req->mgmt_class);
+ if (!is_vendor_class(mgmt_class)) {
+ class = port_priv->version[mad_reg_req->
+ mgmt_class_version].class;
+ if (class) {
+ method = class->method_table[mgmt_class];
+ if (method) {
+ if (method_in_use(&method,
+ mad_reg_req))
+ goto error4;
+ }
+ }
+ ret2 = add_nonoui_reg_req(mad_reg_req, mad_agent_priv,
+ mgmt_class);
+ } else {
+ /* "New" vendor class range */
+ vendor = port_priv->version[mad_reg_req->
+ mgmt_class_version].vendor;
+ if (vendor) {
+ vclass = vendor_class_index(mgmt_class);
+ vendor_class = vendor->vendor_class[vclass];
+ if (vendor_class) {
+ if (is_vendor_method_in_use(
+ vendor_class,
+ mad_reg_req))
+ goto error4;
+ }
+ }
+ ret2 = add_oui_reg_req(mad_reg_req, mad_agent_priv);
+ }
+ if (ret2) {
+ ret = ERR_PTR(ret2);
+ goto error4;
+ }
+ }
+
+ /* Add mad agent into port's agent list */
+ list_add_tail(&mad_agent_priv->agent_list, &port_priv->agent_list);
+ spin_unlock_irqrestore(&port_priv->reg_lock, flags);
+
+ return &mad_agent_priv->agent;
+
+error4:
+ spin_unlock_irqrestore(&port_priv->reg_lock, flags);
+ kfree(reg_req);
+error3:
+ kfree(mad_agent_priv);
+error1:
+ return ret;
+}
+EXPORT_SYMBOL(ib_register_mad_agent);
+
+static inline int is_snooping_sends(int mad_snoop_flags)
+{
+ return (mad_snoop_flags &
+ (/*IB_MAD_SNOOP_POSTED_SENDS |
+ IB_MAD_SNOOP_RMPP_SENDS |*/
+ IB_MAD_SNOOP_SEND_COMPLETIONS /*|
+ IB_MAD_SNOOP_RMPP_SEND_COMPLETIONS*/));
+}
+
+static inline int is_snooping_recvs(int mad_snoop_flags)
+{
+ return (mad_snoop_flags &
+ (IB_MAD_SNOOP_RECVS /*|
+ IB_MAD_SNOOP_RMPP_RECVS*/));
+}
+
+static int register_snoop_agent(struct ib_mad_qp_info *qp_info,
+ struct ib_mad_snoop_private *mad_snoop_priv)
+{
+ struct ib_mad_snoop_private **new_snoop_table;
+ unsigned long flags;
+ int i;
+
+ spin_lock_irqsave(&qp_info->snoop_lock, flags);
+ /* Check for empty slot in array. */
+ for (i = 0; i < qp_info->snoop_table_size; i++)
+ if (!qp_info->snoop_table[i])
+ break;
+
+ if (i == qp_info->snoop_table_size) {
+ /* Grow table. */
+ new_snoop_table = krealloc(qp_info->snoop_table,
+ sizeof mad_snoop_priv *
+ (qp_info->snoop_table_size + 1),
+ GFP_ATOMIC);
+ if (!new_snoop_table) {
+ i = -ENOMEM;
+ goto out;
+ }
+
+ qp_info->snoop_table = new_snoop_table;
+ qp_info->snoop_table_size++;
+ }
+ qp_info->snoop_table[i] = mad_snoop_priv;
+ atomic_inc(&qp_info->snoop_count);
+out:
+ spin_unlock_irqrestore(&qp_info->snoop_lock, flags);
+ return i;
+}
+
+struct ib_mad_agent *ib_register_mad_snoop(struct ib_device *device,
+ u8 port_num,
+ enum ib_qp_type qp_type,
+ int mad_snoop_flags,
+ ib_mad_snoop_handler snoop_handler,
+ ib_mad_recv_handler recv_handler,
+ void *context)
+{
+ struct ib_mad_port_private *port_priv;
+ struct ib_mad_agent *ret;
+ struct ib_mad_snoop_private *mad_snoop_priv;
+ int qpn;
+
+ /* Validate parameters */
+ if ((is_snooping_sends(mad_snoop_flags) && !snoop_handler) ||
+ (is_snooping_recvs(mad_snoop_flags) && !recv_handler)) {
+ ret = ERR_PTR(-EINVAL);
+ goto error1;
+ }
+ qpn = get_spl_qp_index(qp_type);
+ if (qpn == -1) {
+ ret = ERR_PTR(-EINVAL);
+ goto error1;
+ }
+ port_priv = ib_get_mad_port(device, port_num);
+ if (!port_priv) {
+ ret = ERR_PTR(-ENODEV);
+ goto error1;
+ }
+ /* Allocate structures */
+ mad_snoop_priv = kzalloc(sizeof *mad_snoop_priv, GFP_KERNEL);
+ if (!mad_snoop_priv) {
+ ret = ERR_PTR(-ENOMEM);
+ goto error1;
+ }
+
+ /* Now, fill in the various structures */
+ mad_snoop_priv->qp_info = &port_priv->qp_info[qpn];
+ mad_snoop_priv->agent.device = device;
+ mad_snoop_priv->agent.recv_handler = recv_handler;
+ mad_snoop_priv->agent.snoop_handler = snoop_handler;
+ mad_snoop_priv->agent.context = context;
+ mad_snoop_priv->agent.qp = port_priv->qp_info[qpn].qp;
+ mad_snoop_priv->agent.port_num = port_num;
+ mad_snoop_priv->mad_snoop_flags = mad_snoop_flags;
+ init_completion(&mad_snoop_priv->comp);
+ mad_snoop_priv->snoop_index = register_snoop_agent(
+ &port_priv->qp_info[qpn],
+ mad_snoop_priv);
+ if (mad_snoop_priv->snoop_index < 0) {
+ ret = ERR_PTR(mad_snoop_priv->snoop_index);
+ goto error2;
+ }
+
+ atomic_set(&mad_snoop_priv->refcount, 1);
+ return &mad_snoop_priv->agent;
+
+error2:
+ kfree(mad_snoop_priv);
+error1:
+ return ret;
+}
+EXPORT_SYMBOL(ib_register_mad_snoop);
+
+static inline void deref_mad_agent(struct ib_mad_agent_private *mad_agent_priv)
+{
+ if (atomic_dec_and_test(&mad_agent_priv->refcount))
+ complete(&mad_agent_priv->comp);
+}
+
+static inline void deref_snoop_agent(struct ib_mad_snoop_private *mad_snoop_priv)
+{
+ if (atomic_dec_and_test(&mad_snoop_priv->refcount))
+ complete(&mad_snoop_priv->comp);
+}
+
+static void unregister_mad_agent(struct ib_mad_agent_private *mad_agent_priv)
+{
+ struct ib_mad_port_private *port_priv;
+ unsigned long flags;
+
+ /* Note that we could still be handling received MADs */
+
+ /*
+ * Canceling all sends results in dropping received response
+ * MADs, preventing us from queuing additional work
+ */
+ cancel_mads(mad_agent_priv);
+ port_priv = mad_agent_priv->qp_info->port_priv;
+ cancel_delayed_work(&mad_agent_priv->timed_work);
+
+ spin_lock_irqsave(&port_priv->reg_lock, flags);
+ remove_mad_reg_req(mad_agent_priv);
+ list_del(&mad_agent_priv->agent_list);
+ spin_unlock_irqrestore(&port_priv->reg_lock, flags);
+
+ flush_workqueue(port_priv->wq);
+ ib_cancel_rmpp_recvs(mad_agent_priv);
+
+ deref_mad_agent(mad_agent_priv);
+ wait_for_completion(&mad_agent_priv->comp);
+
+ kfree(mad_agent_priv->reg_req);
+ kfree(mad_agent_priv);
+}
+
+static void unregister_mad_snoop(struct ib_mad_snoop_private *mad_snoop_priv)
+{
+ struct ib_mad_qp_info *qp_info;
+ unsigned long flags;
+
+ qp_info = mad_snoop_priv->qp_info;
+ spin_lock_irqsave(&qp_info->snoop_lock, flags);
+ qp_info->snoop_table[mad_snoop_priv->snoop_index] = NULL;
+ atomic_dec(&qp_info->snoop_count);
+ spin_unlock_irqrestore(&qp_info->snoop_lock, flags);
+
+ deref_snoop_agent(mad_snoop_priv);
+ wait_for_completion(&mad_snoop_priv->comp);
+
+ kfree(mad_snoop_priv);
+}
+
+/*
+ * ib_unregister_mad_agent - Unregisters a client from using MAD services
+ */
+int ib_unregister_mad_agent(struct ib_mad_agent *mad_agent)
+{
+ struct ib_mad_agent_private *mad_agent_priv;
+ struct ib_mad_snoop_private *mad_snoop_priv;
+
+ /* If the TID is zero, the agent can only snoop. */
+ if (mad_agent->hi_tid) {
+ mad_agent_priv = container_of(mad_agent,
+ struct ib_mad_agent_private,
+ agent);
+ unregister_mad_agent(mad_agent_priv);
+ } else {
+ mad_snoop_priv = container_of(mad_agent,
+ struct ib_mad_snoop_private,
+ agent);
+ unregister_mad_snoop(mad_snoop_priv);
+ }
+ return 0;
+}
+EXPORT_SYMBOL(ib_unregister_mad_agent);
+
+static void dequeue_mad(struct ib_mad_list_head *mad_list)
+{
+ struct ib_mad_queue *mad_queue;
+ unsigned long flags;
+
+ BUG_ON(!mad_list->mad_queue);
+ mad_queue = mad_list->mad_queue;
+ spin_lock_irqsave(&mad_queue->lock, flags);
+ list_del(&mad_list->list);
+ mad_queue->count--;
+ spin_unlock_irqrestore(&mad_queue->lock, flags);
+}
+
+static void snoop_send(struct ib_mad_qp_info *qp_info,
+ struct ib_mad_send_buf *send_buf,
+ struct ib_mad_send_wc *mad_send_wc,
+ int mad_snoop_flags)
+{
+ struct ib_mad_snoop_private *mad_snoop_priv;
+ unsigned long flags;
+ int i;
+
+ spin_lock_irqsave(&qp_info->snoop_lock, flags);
+ for (i = 0; i < qp_info->snoop_table_size; i++) {
+ mad_snoop_priv = qp_info->snoop_table[i];
+ if (!mad_snoop_priv ||
+ !(mad_snoop_priv->mad_snoop_flags & mad_snoop_flags))
+ continue;
+
+ atomic_inc(&mad_snoop_priv->refcount);
+ spin_unlock_irqrestore(&qp_info->snoop_lock, flags);
+ mad_snoop_priv->agent.snoop_handler(&mad_snoop_priv->agent,
+ send_buf, mad_send_wc);
+ deref_snoop_agent(mad_snoop_priv);
+ spin_lock_irqsave(&qp_info->snoop_lock, flags);
+ }
+ spin_unlock_irqrestore(&qp_info->snoop_lock, flags);
+}
+
+static void snoop_recv(struct ib_mad_qp_info *qp_info,
+ struct ib_mad_recv_wc *mad_recv_wc,
+ int mad_snoop_flags)
+{
+ struct ib_mad_snoop_private *mad_snoop_priv;
+ unsigned long flags;
+ int i;
+
+ spin_lock_irqsave(&qp_info->snoop_lock, flags);
+ for (i = 0; i < qp_info->snoop_table_size; i++) {
+ mad_snoop_priv = qp_info->snoop_table[i];
+ if (!mad_snoop_priv ||
+ !(mad_snoop_priv->mad_snoop_flags & mad_snoop_flags))
+ continue;
+
+ atomic_inc(&mad_snoop_priv->refcount);
+ spin_unlock_irqrestore(&qp_info->snoop_lock, flags);
+ mad_snoop_priv->agent.recv_handler(&mad_snoop_priv->agent, NULL,
+ mad_recv_wc);
+ deref_snoop_agent(mad_snoop_priv);
+ spin_lock_irqsave(&qp_info->snoop_lock, flags);
+ }
+ spin_unlock_irqrestore(&qp_info->snoop_lock, flags);
+}
+
+static void build_smp_wc(struct ib_qp *qp, struct ib_cqe *cqe, u16 slid,
+ u16 pkey_index, u8 port_num, struct ib_wc *wc)
+{
+ memset(wc, 0, sizeof *wc);
+ wc->wr_cqe = cqe;
+ wc->status = IB_WC_SUCCESS;
+ wc->opcode = IB_WC_RECV;
+ wc->pkey_index = pkey_index;
+ wc->byte_len = sizeof(struct ib_mad) + sizeof(struct ib_grh);
+ wc->src_qp = IB_QP0;
+ wc->qp = qp;
+ wc->slid = slid;
+ wc->sl = 0;
+ wc->dlid_path_bits = 0;
+ wc->port_num = port_num;
+}
+
+static size_t mad_priv_size(const struct ib_mad_private *mp)
+{
+ return sizeof(struct ib_mad_private) + mp->mad_size;
+}
+
+static struct ib_mad_private *alloc_mad_private(size_t mad_size, gfp_t flags)
+{
+ size_t size = sizeof(struct ib_mad_private) + mad_size;
+ struct ib_mad_private *ret = kzalloc(size, flags);
+
+ if (ret)
+ ret->mad_size = mad_size;
+
+ return ret;
+}
+
+static size_t port_mad_size(const struct ib_mad_port_private *port_priv)
+{
+ return rdma_max_mad_size(port_priv->device, port_priv->port_num);
+}
+
+static size_t mad_priv_dma_size(const struct ib_mad_private *mp)
+{
+ return sizeof(struct ib_grh) + mp->mad_size;
+}
+
+/*
+ * Return 0 if SMP is to be sent
+ * Return 1 if SMP was consumed locally (whether or not solicited)
+ * Return < 0 if error
+ */
+static int handle_outgoing_dr_smp(struct ib_mad_agent_private *mad_agent_priv,
+ struct ib_mad_send_wr_private *mad_send_wr)
+{
+ int ret = 0;
+ struct ib_smp *smp = mad_send_wr->send_buf.mad;
+ struct opa_smp *opa_smp = (struct opa_smp *)smp;
+ unsigned long flags;
+ struct ib_mad_local_private *local;
+ struct ib_mad_private *mad_priv;
+ struct ib_mad_port_private *port_priv;
+ struct ib_mad_agent_private *recv_mad_agent = NULL;
+ struct ib_device *device = mad_agent_priv->agent.device;
+ u8 port_num;
+ struct ib_wc mad_wc;
+ struct ib_ud_wr *send_wr = &mad_send_wr->send_wr;
+ size_t mad_size = port_mad_size(mad_agent_priv->qp_info->port_priv);
+ u16 out_mad_pkey_index = 0;
+ u16 drslid;
+ bool opa = rdma_cap_opa_mad(mad_agent_priv->qp_info->port_priv->device,
+ mad_agent_priv->qp_info->port_priv->port_num);
+
+ if (rdma_cap_ib_switch(device) &&
+ smp->mgmt_class == IB_MGMT_CLASS_SUBN_DIRECTED_ROUTE)
+ port_num = send_wr->port_num;
+ else
+ port_num = mad_agent_priv->agent.port_num;
+
+ /*
+ * Directed route handling starts if the initial LID routed part of
+ * a request or the ending LID routed part of a response is empty.
+ * If we are at the start of the LID routed part, don't update the
+ * hop_ptr or hop_cnt. See section 14.2.2, Vol 1 IB spec.
+ */
+ if (opa && smp->class_version == OPA_SMP_CLASS_VERSION) {
+ u32 opa_drslid;
+
+ if ((opa_get_smp_direction(opa_smp)
+ ? opa_smp->route.dr.dr_dlid : opa_smp->route.dr.dr_slid) ==
+ OPA_LID_PERMISSIVE &&
+ opa_smi_handle_dr_smp_send(opa_smp,
+ rdma_cap_ib_switch(device),
+ port_num) == IB_SMI_DISCARD) {
+ ret = -EINVAL;
+ dev_err(&device->dev, "OPA Invalid directed route\n");
+ goto out;
+ }
+ opa_drslid = be32_to_cpu(opa_smp->route.dr.dr_slid);
+ if (opa_drslid != be32_to_cpu(OPA_LID_PERMISSIVE) &&
+ opa_drslid & 0xffff0000) {
+ ret = -EINVAL;
+ dev_err(&device->dev, "OPA Invalid dr_slid 0x%x\n",
+ opa_drslid);
+ goto out;
+ }
+ drslid = (u16)(opa_drslid & 0x0000ffff);
+
+ /* Check to post send on QP or process locally */
+ if (opa_smi_check_local_smp(opa_smp, device) == IB_SMI_DISCARD &&
+ opa_smi_check_local_returning_smp(opa_smp, device) == IB_SMI_DISCARD)
+ goto out;
+ } else {
+ if ((ib_get_smp_direction(smp) ? smp->dr_dlid : smp->dr_slid) ==
+ IB_LID_PERMISSIVE &&
+ smi_handle_dr_smp_send(smp, rdma_cap_ib_switch(device), port_num) ==
+ IB_SMI_DISCARD) {
+ ret = -EINVAL;
+ dev_err(&device->dev, "Invalid directed route\n");
+ goto out;
+ }
+ drslid = be16_to_cpu(smp->dr_slid);
+
+ /* Check to post send on QP or process locally */
+ if (smi_check_local_smp(smp, device) == IB_SMI_DISCARD &&
+ smi_check_local_returning_smp(smp, device) == IB_SMI_DISCARD)
+ goto out;
+ }
+
+ local = kmalloc(sizeof *local, GFP_ATOMIC);
+ if (!local) {
+ ret = -ENOMEM;
+ dev_err(&device->dev, "No memory for ib_mad_local_private\n");
+ goto out;
+ }
+ local->mad_priv = NULL;
+ local->recv_mad_agent = NULL;
+ mad_priv = alloc_mad_private(mad_size, GFP_ATOMIC);
+ if (!mad_priv) {
+ ret = -ENOMEM;
+ dev_err(&device->dev, "No memory for local response MAD\n");
+ kfree(local);
+ goto out;
+ }
+
+ build_smp_wc(mad_agent_priv->agent.qp,
+ send_wr->wr.wr_cqe, drslid,
+ send_wr->pkey_index,
+ send_wr->port_num, &mad_wc);
+
+ if (opa && smp->base_version == OPA_MGMT_BASE_VERSION) {
+ mad_wc.byte_len = mad_send_wr->send_buf.hdr_len
+ + mad_send_wr->send_buf.data_len
+ + sizeof(struct ib_grh);
+ }
+
+ /* No GRH for DR SMP */
+ ret = device->process_mad(device, 0, port_num, &mad_wc, NULL,
+ (const struct ib_mad_hdr *)smp, mad_size,
+ (struct ib_mad_hdr *)mad_priv->mad,
+ &mad_size, &out_mad_pkey_index);
+ switch (ret)
+ {
+ case IB_MAD_RESULT_SUCCESS | IB_MAD_RESULT_REPLY:
+ if (ib_response_mad((const struct ib_mad_hdr *)mad_priv->mad) &&
+ mad_agent_priv->agent.recv_handler) {
+ local->mad_priv = mad_priv;
+ local->recv_mad_agent = mad_agent_priv;
+ /*
+ * Reference MAD agent until receive
+ * side of local completion handled
+ */
+ atomic_inc(&mad_agent_priv->refcount);
+ } else
+ kfree(mad_priv);
+ break;
+ case IB_MAD_RESULT_SUCCESS | IB_MAD_RESULT_CONSUMED:
+ kfree(mad_priv);
+ break;
+ case IB_MAD_RESULT_SUCCESS:
+ /* Treat like an incoming receive MAD */
+ port_priv = ib_get_mad_port(mad_agent_priv->agent.device,
+ mad_agent_priv->agent.port_num);
+ if (port_priv) {
+ memcpy(mad_priv->mad, smp, mad_priv->mad_size);
+ recv_mad_agent = find_mad_agent(port_priv,
+ (const struct ib_mad_hdr *)mad_priv->mad);
+ }
+ if (!port_priv || !recv_mad_agent) {
+ /*
+ * No receiving agent so drop packet and
+ * generate send completion.
+ */
+ kfree(mad_priv);
+ break;
+ }
+ local->mad_priv = mad_priv;
+ local->recv_mad_agent = recv_mad_agent;
+ break;
+ default:
+ kfree(mad_priv);
+ kfree(local);
+ ret = -EINVAL;
+ goto out;
+ }
+
+ local->mad_send_wr = mad_send_wr;
+ if (opa) {
+ local->mad_send_wr->send_wr.pkey_index = out_mad_pkey_index;
+ local->return_wc_byte_len = mad_size;
+ }
+ /* Reference MAD agent until send side of local completion handled */
+ atomic_inc(&mad_agent_priv->refcount);
+ /* Queue local completion to local list */
+ spin_lock_irqsave(&mad_agent_priv->lock, flags);
+ list_add_tail(&local->completion_list, &mad_agent_priv->local_list);
+ spin_unlock_irqrestore(&mad_agent_priv->lock, flags);
+ queue_work(mad_agent_priv->qp_info->port_priv->wq,
+ &mad_agent_priv->local_work);
+ ret = 1;
+out:
+ return ret;
+}
+
+static int get_pad_size(int hdr_len, int data_len, size_t mad_size)
+{
+ int seg_size, pad;
+
+ seg_size = mad_size - hdr_len;
+ if (data_len && seg_size) {
+ pad = seg_size - data_len % seg_size;
+ return pad == seg_size ? 0 : pad;
+ } else
+ return seg_size;
+}
+
+static void free_send_rmpp_list(struct ib_mad_send_wr_private *mad_send_wr)
+{
+ struct ib_rmpp_segment *s, *t;
+
+ list_for_each_entry_safe(s, t, &mad_send_wr->rmpp_list, list) {
+ list_del(&s->list);
+ kfree(s);
+ }
+}
+
+static int alloc_send_rmpp_list(struct ib_mad_send_wr_private *send_wr,
+ size_t mad_size, gfp_t gfp_mask)
+{
+ struct ib_mad_send_buf *send_buf = &send_wr->send_buf;
+ struct ib_rmpp_mad *rmpp_mad = send_buf->mad;
+ struct ib_rmpp_segment *seg = NULL;
+ int left, seg_size, pad;
+
+ send_buf->seg_size = mad_size - send_buf->hdr_len;
+ send_buf->seg_rmpp_size = mad_size - IB_MGMT_RMPP_HDR;
+ seg_size = send_buf->seg_size;
+ pad = send_wr->pad;
+
+ /* Allocate data segments. */
+ for (left = send_buf->data_len + pad; left > 0; left -= seg_size) {
+ seg = kmalloc(sizeof (*seg) + seg_size, gfp_mask);
+ if (!seg) {
+ dev_err(&send_buf->mad_agent->device->dev,
+ "alloc_send_rmpp_segs: RMPP mem alloc failed for len %zd, gfp %#x\n",
+ sizeof (*seg) + seg_size, gfp_mask);
+ free_send_rmpp_list(send_wr);
+ return -ENOMEM;
+ }
+ seg->num = ++send_buf->seg_count;
+ list_add_tail(&seg->list, &send_wr->rmpp_list);
+ }
+
+ /* Zero any padding */
+ if (pad)
+ memset(seg->data + seg_size - pad, 0, pad);
+
+ rmpp_mad->rmpp_hdr.rmpp_version = send_wr->mad_agent_priv->
+ agent.rmpp_version;
+ rmpp_mad->rmpp_hdr.rmpp_type = IB_MGMT_RMPP_TYPE_DATA;
+ ib_set_rmpp_flags(&rmpp_mad->rmpp_hdr, IB_MGMT_RMPP_FLAG_ACTIVE);
+
+ send_wr->cur_seg = container_of(send_wr->rmpp_list.next,
+ struct ib_rmpp_segment, list);
+ send_wr->last_ack_seg = send_wr->cur_seg;
+ return 0;
+}
+
+int ib_mad_kernel_rmpp_agent(const struct ib_mad_agent *agent)
+{
+ return agent->rmpp_version && !(agent->flags & IB_MAD_USER_RMPP);
+}
+EXPORT_SYMBOL(ib_mad_kernel_rmpp_agent);
+
+struct ib_mad_send_buf * ib_create_send_mad(struct ib_mad_agent *mad_agent,
+ u32 remote_qpn, u16 pkey_index,
+ int rmpp_active,
+ int hdr_len, int data_len,
+ gfp_t gfp_mask,
+ u8 base_version)
+{
+ struct ib_mad_agent_private *mad_agent_priv;
+ struct ib_mad_send_wr_private *mad_send_wr;
+ int pad, message_size, ret, size;
+ void *buf;
+ size_t mad_size;
+ bool opa;
+
+ mad_agent_priv = container_of(mad_agent, struct ib_mad_agent_private,
+ agent);
+
+ opa = rdma_cap_opa_mad(mad_agent->device, mad_agent->port_num);
+
+ if (opa && base_version == OPA_MGMT_BASE_VERSION)
+ mad_size = sizeof(struct opa_mad);
+ else
+ mad_size = sizeof(struct ib_mad);
+
+ pad = get_pad_size(hdr_len, data_len, mad_size);
+ message_size = hdr_len + data_len + pad;
+
+ if (ib_mad_kernel_rmpp_agent(mad_agent)) {
+ if (!rmpp_active && message_size > mad_size)
+ return ERR_PTR(-EINVAL);
+ } else
+ if (rmpp_active || message_size > mad_size)
+ return ERR_PTR(-EINVAL);
+
+ size = rmpp_active ? hdr_len : mad_size;
+ buf = kzalloc(sizeof *mad_send_wr + size, gfp_mask);
+ if (!buf)
+ return ERR_PTR(-ENOMEM);
+
+ mad_send_wr = (struct ib_mad_send_wr_private *)((char *)buf + size);
+ INIT_LIST_HEAD(&mad_send_wr->rmpp_list);
+ mad_send_wr->send_buf.mad = buf;
+ mad_send_wr->send_buf.hdr_len = hdr_len;
+ mad_send_wr->send_buf.data_len = data_len;
+ mad_send_wr->pad = pad;
+
+ mad_send_wr->mad_agent_priv = mad_agent_priv;
+ mad_send_wr->sg_list[0].length = hdr_len;
+ mad_send_wr->sg_list[0].lkey = mad_agent->qp->pd->local_dma_lkey;
+
+ /* OPA MADs don't have to be the full 2048 bytes */
+ if (opa && base_version == OPA_MGMT_BASE_VERSION &&
+ data_len < mad_size - hdr_len)
+ mad_send_wr->sg_list[1].length = data_len;
+ else
+ mad_send_wr->sg_list[1].length = mad_size - hdr_len;
+
+ mad_send_wr->sg_list[1].lkey = mad_agent->qp->pd->local_dma_lkey;
+
+ mad_send_wr->mad_list.cqe.done = ib_mad_send_done;
+
+ mad_send_wr->send_wr.wr.wr_cqe = &mad_send_wr->mad_list.cqe;
+ mad_send_wr->send_wr.wr.sg_list = mad_send_wr->sg_list;
+ mad_send_wr->send_wr.wr.num_sge = 2;
+ mad_send_wr->send_wr.wr.opcode = IB_WR_SEND;
+ mad_send_wr->send_wr.wr.send_flags = IB_SEND_SIGNALED;
+ mad_send_wr->send_wr.remote_qpn = remote_qpn;
+ mad_send_wr->send_wr.remote_qkey = IB_QP_SET_QKEY;
+ mad_send_wr->send_wr.pkey_index = pkey_index;
+
+ if (rmpp_active) {
+ ret = alloc_send_rmpp_list(mad_send_wr, mad_size, gfp_mask);
+ if (ret) {
+ kfree(buf);
+ return ERR_PTR(ret);
+ }
+ }
+
+ mad_send_wr->send_buf.mad_agent = mad_agent;
+ atomic_inc(&mad_agent_priv->refcount);
+ return &mad_send_wr->send_buf;
+}
+EXPORT_SYMBOL(ib_create_send_mad);
+
+int ib_get_mad_data_offset(u8 mgmt_class)
+{
+ if (mgmt_class == IB_MGMT_CLASS_SUBN_ADM)
+ return IB_MGMT_SA_HDR;
+ else if ((mgmt_class == IB_MGMT_CLASS_DEVICE_MGMT) ||
+ (mgmt_class == IB_MGMT_CLASS_DEVICE_ADM) ||
+ (mgmt_class == IB_MGMT_CLASS_BIS))
+ return IB_MGMT_DEVICE_HDR;
+ else if ((mgmt_class >= IB_MGMT_CLASS_VENDOR_RANGE2_START) &&
+ (mgmt_class <= IB_MGMT_CLASS_VENDOR_RANGE2_END))
+ return IB_MGMT_VENDOR_HDR;
+ else
+ return IB_MGMT_MAD_HDR;
+}
+EXPORT_SYMBOL(ib_get_mad_data_offset);
+
+int ib_is_mad_class_rmpp(u8 mgmt_class)
+{
+ if ((mgmt_class == IB_MGMT_CLASS_SUBN_ADM) ||
+ (mgmt_class == IB_MGMT_CLASS_DEVICE_MGMT) ||
+ (mgmt_class == IB_MGMT_CLASS_DEVICE_ADM) ||
+ (mgmt_class == IB_MGMT_CLASS_BIS) ||
+ ((mgmt_class >= IB_MGMT_CLASS_VENDOR_RANGE2_START) &&
+ (mgmt_class <= IB_MGMT_CLASS_VENDOR_RANGE2_END)))
+ return 1;
+ return 0;
+}
+EXPORT_SYMBOL(ib_is_mad_class_rmpp);
+
+void *ib_get_rmpp_segment(struct ib_mad_send_buf *send_buf, int seg_num)
+{
+ struct ib_mad_send_wr_private *mad_send_wr;
+ struct list_head *list;
+
+ mad_send_wr = container_of(send_buf, struct ib_mad_send_wr_private,
+ send_buf);
+ list = &mad_send_wr->cur_seg->list;
+
+ if (mad_send_wr->cur_seg->num < seg_num) {
+ list_for_each_entry(mad_send_wr->cur_seg, list, list)
+ if (mad_send_wr->cur_seg->num == seg_num)
+ break;
+ } else if (mad_send_wr->cur_seg->num > seg_num) {
+ list_for_each_entry_reverse(mad_send_wr->cur_seg, list, list)
+ if (mad_send_wr->cur_seg->num == seg_num)
+ break;
+ }
+ return mad_send_wr->cur_seg->data;
+}
+EXPORT_SYMBOL(ib_get_rmpp_segment);
+
+static inline void *ib_get_payload(struct ib_mad_send_wr_private *mad_send_wr)
+{
+ if (mad_send_wr->send_buf.seg_count)
+ return ib_get_rmpp_segment(&mad_send_wr->send_buf,
+ mad_send_wr->seg_num);
+ else
+ return (char *)mad_send_wr->send_buf.mad +
+ mad_send_wr->send_buf.hdr_len;
+}
+
+void ib_free_send_mad(struct ib_mad_send_buf *send_buf)
+{
+ struct ib_mad_agent_private *mad_agent_priv;
+ struct ib_mad_send_wr_private *mad_send_wr;
+
+ mad_agent_priv = container_of(send_buf->mad_agent,
+ struct ib_mad_agent_private, agent);
+ mad_send_wr = container_of(send_buf, struct ib_mad_send_wr_private,
+ send_buf);
+
+ free_send_rmpp_list(mad_send_wr);
+ kfree(send_buf->mad);
+ deref_mad_agent(mad_agent_priv);
+}
+EXPORT_SYMBOL(ib_free_send_mad);
+
+int ib_send_mad(struct ib_mad_send_wr_private *mad_send_wr)
+{
+ struct ib_mad_qp_info *qp_info;
+ struct list_head *list;
+ struct ib_send_wr *bad_send_wr;
+ struct ib_mad_agent *mad_agent;
+ struct ib_sge *sge;
+ unsigned long flags;
+ int ret;
+
+ /* Set WR ID to find mad_send_wr upon completion */
+ qp_info = mad_send_wr->mad_agent_priv->qp_info;
+ mad_send_wr->mad_list.mad_queue = &qp_info->send_queue;
+ mad_send_wr->mad_list.cqe.done = ib_mad_send_done;
+ mad_send_wr->send_wr.wr.wr_cqe = &mad_send_wr->mad_list.cqe;
+
+ mad_agent = mad_send_wr->send_buf.mad_agent;
+ sge = mad_send_wr->sg_list;
+ sge[0].addr = ib_dma_map_single(mad_agent->device,
+ mad_send_wr->send_buf.mad,
+ sge[0].length,
+ DMA_TO_DEVICE);
+ if (unlikely(ib_dma_mapping_error(mad_agent->device, sge[0].addr)))
+ return -ENOMEM;
+
+ mad_send_wr->header_mapping = sge[0].addr;
+
+ sge[1].addr = ib_dma_map_single(mad_agent->device,
+ ib_get_payload(mad_send_wr),
+ sge[1].length,
+ DMA_TO_DEVICE);
+ if (unlikely(ib_dma_mapping_error(mad_agent->device, sge[1].addr))) {
+ ib_dma_unmap_single(mad_agent->device,
+ mad_send_wr->header_mapping,
+ sge[0].length, DMA_TO_DEVICE);
+ return -ENOMEM;
+ }
+ mad_send_wr->payload_mapping = sge[1].addr;
+
+ spin_lock_irqsave(&qp_info->send_queue.lock, flags);
+ if (qp_info->send_queue.count < qp_info->send_queue.max_active) {
+ ret = ib_post_send(mad_agent->qp, &mad_send_wr->send_wr.wr,
+ &bad_send_wr);
+ list = &qp_info->send_queue.list;
+ } else {
+ ret = 0;
+ list = &qp_info->overflow_list;
+ }
+
+ if (!ret) {
+ qp_info->send_queue.count++;
+ list_add_tail(&mad_send_wr->mad_list.list, list);
+ }
+ spin_unlock_irqrestore(&qp_info->send_queue.lock, flags);
+ if (ret) {
+ ib_dma_unmap_single(mad_agent->device,
+ mad_send_wr->header_mapping,
+ sge[0].length, DMA_TO_DEVICE);
+ ib_dma_unmap_single(mad_agent->device,
+ mad_send_wr->payload_mapping,
+ sge[1].length, DMA_TO_DEVICE);
+ }
+ return ret;
+}
+
+/*
+ * ib_post_send_mad - Posts MAD(s) to the send queue of the QP associated
+ * with the registered client
+ */
+int ib_post_send_mad(struct ib_mad_send_buf *send_buf,
+ struct ib_mad_send_buf **bad_send_buf)
+{
+ struct ib_mad_agent_private *mad_agent_priv;
+ struct ib_mad_send_buf *next_send_buf;
+ struct ib_mad_send_wr_private *mad_send_wr;
+ unsigned long flags;
+ int ret = -EINVAL;
+
+ /* Walk list of send WRs and post each on send list */
+ for (; send_buf; send_buf = next_send_buf) {
+
+ mad_send_wr = container_of(send_buf,
+ struct ib_mad_send_wr_private,
+ send_buf);
+ mad_agent_priv = mad_send_wr->mad_agent_priv;
+
+ if (!send_buf->mad_agent->send_handler ||
+ (send_buf->timeout_ms &&
+ !send_buf->mad_agent->recv_handler)) {
+ ret = -EINVAL;
+ goto error;
+ }
+
+ if (!ib_is_mad_class_rmpp(((struct ib_mad_hdr *) send_buf->mad)->mgmt_class)) {
+ if (mad_agent_priv->agent.rmpp_version) {
+ ret = -EINVAL;
+ goto error;
+ }
+ }
+
+ /*
+ * Save pointer to next work request to post in case the
+ * current one completes, and the user modifies the work
+ * request associated with the completion
+ */
+ next_send_buf = send_buf->next;
+ mad_send_wr->send_wr.ah = send_buf->ah;
+
+ if (((struct ib_mad_hdr *) send_buf->mad)->mgmt_class ==
+ IB_MGMT_CLASS_SUBN_DIRECTED_ROUTE) {
+ ret = handle_outgoing_dr_smp(mad_agent_priv,
+ mad_send_wr);
+ if (ret < 0) /* error */
+ goto error;
+ else if (ret == 1) /* locally consumed */
+ continue;
+ }
+
+ mad_send_wr->tid = ((struct ib_mad_hdr *) send_buf->mad)->tid;
+ /* Timeout will be updated after send completes */
+ mad_send_wr->timeout = msecs_to_jiffies(send_buf->timeout_ms);
+ mad_send_wr->max_retries = send_buf->retries;
+ mad_send_wr->retries_left = send_buf->retries;
+ send_buf->retries = 0;
+ /* Reference for work request to QP + response */
+ mad_send_wr->refcount = 1 + (mad_send_wr->timeout > 0);
+ mad_send_wr->status = IB_WC_SUCCESS;
+
+ /* Reference MAD agent until send completes */
+ atomic_inc(&mad_agent_priv->refcount);
+ spin_lock_irqsave(&mad_agent_priv->lock, flags);
+ list_add_tail(&mad_send_wr->agent_list,
+ &mad_agent_priv->send_list);
+ spin_unlock_irqrestore(&mad_agent_priv->lock, flags);
+
+ if (ib_mad_kernel_rmpp_agent(&mad_agent_priv->agent)) {
+ ret = ib_send_rmpp_mad(mad_send_wr);
+ if (ret >= 0 && ret != IB_RMPP_RESULT_CONSUMED)
+ ret = ib_send_mad(mad_send_wr);
+ } else
+ ret = ib_send_mad(mad_send_wr);
+ if (ret < 0) {
+ /* Fail send request */
+ spin_lock_irqsave(&mad_agent_priv->lock, flags);
+ list_del(&mad_send_wr->agent_list);
+ spin_unlock_irqrestore(&mad_agent_priv->lock, flags);
+ atomic_dec(&mad_agent_priv->refcount);
+ goto error;
+ }
+ }
+ return 0;
+error:
+ if (bad_send_buf)
+ *bad_send_buf = send_buf;
+ return ret;
+}
+EXPORT_SYMBOL(ib_post_send_mad);
+
+/*
+ * ib_free_recv_mad - Returns data buffers used to receive
+ * a MAD to the access layer
+ */
+void ib_free_recv_mad(struct ib_mad_recv_wc *mad_recv_wc)
+{
+ struct ib_mad_recv_buf *mad_recv_buf, *temp_recv_buf;
+ struct ib_mad_private_header *mad_priv_hdr;
+ struct ib_mad_private *priv;
+ struct list_head free_list;
+
+ INIT_LIST_HEAD(&free_list);
+ list_splice_init(&mad_recv_wc->rmpp_list, &free_list);
+
+ list_for_each_entry_safe(mad_recv_buf, temp_recv_buf,
+ &free_list, list) {
+ mad_recv_wc = container_of(mad_recv_buf, struct ib_mad_recv_wc,
+ recv_buf);
+ mad_priv_hdr = container_of(mad_recv_wc,
+ struct ib_mad_private_header,
+ recv_wc);
+ priv = container_of(mad_priv_hdr, struct ib_mad_private,
+ header);
+ kfree(priv);
+ }
+}
+EXPORT_SYMBOL(ib_free_recv_mad);
+
+struct ib_mad_agent *ib_redirect_mad_qp(struct ib_qp *qp,
+ u8 rmpp_version,
+ ib_mad_send_handler send_handler,
+ ib_mad_recv_handler recv_handler,
+ void *context)
+{
+ return ERR_PTR(-EINVAL); /* XXX: for now */
+}
+EXPORT_SYMBOL(ib_redirect_mad_qp);
+
+int ib_process_mad_wc(struct ib_mad_agent *mad_agent,
+ struct ib_wc *wc)
+{
+ dev_err(&mad_agent->device->dev,
+ "ib_process_mad_wc() not implemented yet\n");
+ return 0;
+}
+EXPORT_SYMBOL(ib_process_mad_wc);
+
+static int method_in_use(struct ib_mad_mgmt_method_table **method,
+ struct ib_mad_reg_req *mad_reg_req)
+{
+ int i;
+
+ for_each_set_bit(i, mad_reg_req->method_mask, IB_MGMT_MAX_METHODS) {
+ if ((*method)->agent[i]) {
+ pr_err("Method %d already in use\n", i);
+ return -EINVAL;
+ }
+ }
+ return 0;
+}
+
+static int allocate_method_table(struct ib_mad_mgmt_method_table **method)
+{
+ /* Allocate management method table */
+ *method = kzalloc(sizeof **method, GFP_ATOMIC);
+ if (!*method) {
+ pr_err("No memory for ib_mad_mgmt_method_table\n");
+ return -ENOMEM;
+ }
+
+ return 0;
+}
+
+/*
+ * Check to see if there are any methods still in use
+ */
+static int check_method_table(struct ib_mad_mgmt_method_table *method)
+{
+ int i;
+
+ for (i = 0; i < IB_MGMT_MAX_METHODS; i++)
+ if (method->agent[i])
+ return 1;
+ return 0;
+}
+
+/*
+ * Check to see if there are any method tables for this class still in use
+ */
+static int check_class_table(struct ib_mad_mgmt_class_table *class)
+{
+ int i;
+
+ for (i = 0; i < MAX_MGMT_CLASS; i++)
+ if (class->method_table[i])
+ return 1;
+ return 0;
+}
+
+static int check_vendor_class(struct ib_mad_mgmt_vendor_class *vendor_class)
+{
+ int i;
+
+ for (i = 0; i < MAX_MGMT_OUI; i++)
+ if (vendor_class->method_table[i])
+ return 1;
+ return 0;
+}
+
+static int find_vendor_oui(struct ib_mad_mgmt_vendor_class *vendor_class,
+ const char *oui)
+{
+ int i;
+
+ for (i = 0; i < MAX_MGMT_OUI; i++)
+ /* Is there matching OUI for this vendor class ? */
+ if (!memcmp(vendor_class->oui[i], oui, 3))
+ return i;
+
+ return -1;
+}
+
+static int check_vendor_table(struct ib_mad_mgmt_vendor_class_table *vendor)
+{
+ int i;
+
+ for (i = 0; i < MAX_MGMT_VENDOR_RANGE2; i++)
+ if (vendor->vendor_class[i])
+ return 1;
+
+ return 0;
+}
+
+static void remove_methods_mad_agent(struct ib_mad_mgmt_method_table *method,
+ struct ib_mad_agent_private *agent)
+{
+ int i;
+
+ /* Remove any methods for this mad agent */
+ for (i = 0; i < IB_MGMT_MAX_METHODS; i++) {
+ if (method->agent[i] == agent) {
+ method->agent[i] = NULL;
+ }
+ }
+}
+
+static int add_nonoui_reg_req(struct ib_mad_reg_req *mad_reg_req,
+ struct ib_mad_agent_private *agent_priv,
+ u8 mgmt_class)
+{
+ struct ib_mad_port_private *port_priv;
+ struct ib_mad_mgmt_class_table **class;
+ struct ib_mad_mgmt_method_table **method;
+ int i, ret;
+
+ port_priv = agent_priv->qp_info->port_priv;
+ class = &port_priv->version[mad_reg_req->mgmt_class_version].class;
+ if (!*class) {
+ /* Allocate management class table for "new" class version */
+ *class = kzalloc(sizeof **class, GFP_ATOMIC);
+ if (!*class) {
+ dev_err(&agent_priv->agent.device->dev,
+ "No memory for ib_mad_mgmt_class_table\n");
+ ret = -ENOMEM;
+ goto error1;
+ }
+
+ /* Allocate method table for this management class */
+ method = &(*class)->method_table[mgmt_class];
+ if ((ret = allocate_method_table(method)))
+ goto error2;
+ } else {
+ method = &(*class)->method_table[mgmt_class];
+ if (!*method) {
+ /* Allocate method table for this management class */
+ if ((ret = allocate_method_table(method)))
+ goto error1;
+ }
+ }
+
+ /* Now, make sure methods are not already in use */
+ if (method_in_use(method, mad_reg_req))
+ goto error3;
+
+ /* Finally, add in methods being registered */
+ for_each_set_bit(i, mad_reg_req->method_mask, IB_MGMT_MAX_METHODS)
+ (*method)->agent[i] = agent_priv;
+
+ return 0;
+
+error3:
+ /* Remove any methods for this mad agent */
+ remove_methods_mad_agent(*method, agent_priv);
+ /* Now, check to see if there are any methods in use */
+ if (!check_method_table(*method)) {
+ /* If not, release management method table */
+ kfree(*method);
+ *method = NULL;
+ }
+ ret = -EINVAL;
+ goto error1;
+error2:
+ kfree(*class);
+ *class = NULL;
+error1:
+ return ret;
+}
+
+static int add_oui_reg_req(struct ib_mad_reg_req *mad_reg_req,
+ struct ib_mad_agent_private *agent_priv)
+{
+ struct ib_mad_port_private *port_priv;
+ struct ib_mad_mgmt_vendor_class_table **vendor_table;
+ struct ib_mad_mgmt_vendor_class_table *vendor = NULL;
+ struct ib_mad_mgmt_vendor_class *vendor_class = NULL;
+ struct ib_mad_mgmt_method_table **method;
+ int i, ret = -ENOMEM;
+ u8 vclass;
+
+ /* "New" vendor (with OUI) class */
+ vclass = vendor_class_index(mad_reg_req->mgmt_class);
+ port_priv = agent_priv->qp_info->port_priv;
+ vendor_table = &port_priv->version[
+ mad_reg_req->mgmt_class_version].vendor;
+ if (!*vendor_table) {
+ /* Allocate mgmt vendor class table for "new" class version */
+ vendor = kzalloc(sizeof *vendor, GFP_ATOMIC);
+ if (!vendor) {
+ dev_err(&agent_priv->agent.device->dev,
+ "No memory for ib_mad_mgmt_vendor_class_table\n");
+ goto error1;
+ }
+
+ *vendor_table = vendor;
+ }
+ if (!(*vendor_table)->vendor_class[vclass]) {
+ /* Allocate table for this management vendor class */
+ vendor_class = kzalloc(sizeof *vendor_class, GFP_ATOMIC);
+ if (!vendor_class) {
+ dev_err(&agent_priv->agent.device->dev,
+ "No memory for ib_mad_mgmt_vendor_class\n");
+ goto error2;
+ }
+
+ (*vendor_table)->vendor_class[vclass] = vendor_class;
+ }
+ for (i = 0; i < MAX_MGMT_OUI; i++) {
+ /* Is there matching OUI for this vendor class ? */
+ if (!memcmp((*vendor_table)->vendor_class[vclass]->oui[i],
+ mad_reg_req->oui, 3)) {
+ method = &(*vendor_table)->vendor_class[
+ vclass]->method_table[i];
+ BUG_ON(!*method);
+ goto check_in_use;
+ }
+ }
+ for (i = 0; i < MAX_MGMT_OUI; i++) {
+ /* OUI slot available ? */
+ if (!is_vendor_oui((*vendor_table)->vendor_class[
+ vclass]->oui[i])) {
+ method = &(*vendor_table)->vendor_class[
+ vclass]->method_table[i];
+ BUG_ON(*method);
+ /* Allocate method table for this OUI */
+ if ((ret = allocate_method_table(method)))
+ goto error3;
+ memcpy((*vendor_table)->vendor_class[vclass]->oui[i],
+ mad_reg_req->oui, 3);
+ goto check_in_use;
+ }
+ }
+ dev_err(&agent_priv->agent.device->dev, "All OUI slots in use\n");
+ goto error3;
+
+check_in_use:
+ /* Now, make sure methods are not already in use */
+ if (method_in_use(method, mad_reg_req))
+ goto error4;
+
+ /* Finally, add in methods being registered */
+ for_each_set_bit(i, mad_reg_req->method_mask, IB_MGMT_MAX_METHODS)
+ (*method)->agent[i] = agent_priv;
+
+ return 0;
+
+error4:
+ /* Remove any methods for this mad agent */
+ remove_methods_mad_agent(*method, agent_priv);
+ /* Now, check to see if there are any methods in use */
+ if (!check_method_table(*method)) {
+ /* If not, release management method table */
+ kfree(*method);
+ *method = NULL;
+ }
+ ret = -EINVAL;
+error3:
+ if (vendor_class) {
+ (*vendor_table)->vendor_class[vclass] = NULL;
+ kfree(vendor_class);
+ }
+error2:
+ if (vendor) {
+ *vendor_table = NULL;
+ kfree(vendor);
+ }
+error1:
+ return ret;
+}
+
+static void remove_mad_reg_req(struct ib_mad_agent_private *agent_priv)
+{
+ struct ib_mad_port_private *port_priv;
+ struct ib_mad_mgmt_class_table *class;
+ struct ib_mad_mgmt_method_table *method;
+ struct ib_mad_mgmt_vendor_class_table *vendor;
+ struct ib_mad_mgmt_vendor_class *vendor_class;
+ int index;
+ u8 mgmt_class;
+
+ /*
+ * Was MAD registration request supplied
+ * with original registration ?
+ */
+ if (!agent_priv->reg_req) {
+ goto out;
+ }
+
+ port_priv = agent_priv->qp_info->port_priv;
+ mgmt_class = convert_mgmt_class(agent_priv->reg_req->mgmt_class);
+ class = port_priv->version[
+ agent_priv->reg_req->mgmt_class_version].class;
+ if (!class)
+ goto vendor_check;
+
+ method = class->method_table[mgmt_class];
+ if (method) {
+ /* Remove any methods for this mad agent */
+ remove_methods_mad_agent(method, agent_priv);
+ /* Now, check to see if there are any methods still in use */
+ if (!check_method_table(method)) {
+ /* If not, release management method table */
+ kfree(method);
+ class->method_table[mgmt_class] = NULL;
+ /* Any management classes left ? */
+ if (!check_class_table(class)) {
+ /* If not, release management class table */
+ kfree(class);
+ port_priv->version[
+ agent_priv->reg_req->
+ mgmt_class_version].class = NULL;
+ }
+ }
+ }
+
+vendor_check:
+ if (!is_vendor_class(mgmt_class))
+ goto out;
+
+ /* normalize mgmt_class to vendor range 2 */
+ mgmt_class = vendor_class_index(agent_priv->reg_req->mgmt_class);
+ vendor = port_priv->version[
+ agent_priv->reg_req->mgmt_class_version].vendor;
+
+ if (!vendor)
+ goto out;
+
+ vendor_class = vendor->vendor_class[mgmt_class];
+ if (vendor_class) {
+ index = find_vendor_oui(vendor_class, agent_priv->reg_req->oui);
+ if (index < 0)
+ goto out;
+ method = vendor_class->method_table[index];
+ if (method) {
+ /* Remove any methods for this mad agent */
+ remove_methods_mad_agent(method, agent_priv);
+ /*
+ * Now, check to see if there are
+ * any methods still in use
+ */
+ if (!check_method_table(method)) {
+ /* If not, release management method table */
+ kfree(method);
+ vendor_class->method_table[index] = NULL;
+ memset(vendor_class->oui[index], 0, 3);
+ /* Any OUIs left ? */
+ if (!check_vendor_class(vendor_class)) {
+ /* If not, release vendor class table */
+ kfree(vendor_class);
+ vendor->vendor_class[mgmt_class] = NULL;
+ /* Any other vendor classes left ? */
+ if (!check_vendor_table(vendor)) {
+ kfree(vendor);
+ port_priv->version[
+ agent_priv->reg_req->
+ mgmt_class_version].
+ vendor = NULL;
+ }
+ }
+ }
+ }
+ }
+
+out:
+ return;
+}
+
+static struct ib_mad_agent_private *
+find_mad_agent(struct ib_mad_port_private *port_priv,
+ const struct ib_mad_hdr *mad_hdr)
+{
+ struct ib_mad_agent_private *mad_agent = NULL;
+ unsigned long flags;
+
+ spin_lock_irqsave(&port_priv->reg_lock, flags);
+ if (ib_response_mad(mad_hdr)) {
+ u32 hi_tid;
+ struct ib_mad_agent_private *entry;
+
+ /*
+ * Routing is based on high 32 bits of transaction ID
+ * of MAD.
+ */
+ hi_tid = be64_to_cpu(mad_hdr->tid) >> 32;
+ list_for_each_entry(entry, &port_priv->agent_list, agent_list) {
+ if (entry->agent.hi_tid == hi_tid) {
+ mad_agent = entry;
+ break;
+ }
+ }
+ } else {
+ struct ib_mad_mgmt_class_table *class;
+ struct ib_mad_mgmt_method_table *method;
+ struct ib_mad_mgmt_vendor_class_table *vendor;
+ struct ib_mad_mgmt_vendor_class *vendor_class;
+ const struct ib_vendor_mad *vendor_mad;
+ int index;
+
+ /*
+ * Routing is based on version, class, and method
+ * For "newer" vendor MADs, also based on OUI
+ */
+ if (mad_hdr->class_version >= MAX_MGMT_VERSION)
+ goto out;
+ if (!is_vendor_class(mad_hdr->mgmt_class)) {
+ class = port_priv->version[
+ mad_hdr->class_version].class;
+ if (!class)
+ goto out;
+ if (convert_mgmt_class(mad_hdr->mgmt_class) >=
+ IB_MGMT_MAX_METHODS)
+ goto out;
+ method = class->method_table[convert_mgmt_class(
+ mad_hdr->mgmt_class)];
+ if (method)
+ mad_agent = method->agent[mad_hdr->method &
+ ~IB_MGMT_METHOD_RESP];
+ } else {
+ vendor = port_priv->version[
+ mad_hdr->class_version].vendor;
+ if (!vendor)
+ goto out;
+ vendor_class = vendor->vendor_class[vendor_class_index(
+ mad_hdr->mgmt_class)];
+ if (!vendor_class)
+ goto out;
+ /* Find matching OUI */
+ vendor_mad = (const struct ib_vendor_mad *)mad_hdr;
+ index = find_vendor_oui(vendor_class, vendor_mad->oui);
+ if (index == -1)
+ goto out;
+ method = vendor_class->method_table[index];
+ if (method) {
+ mad_agent = method->agent[mad_hdr->method &
+ ~IB_MGMT_METHOD_RESP];
+ }
+ }
+ }
+
+ if (mad_agent) {
+ if (mad_agent->agent.recv_handler)
+ atomic_inc(&mad_agent->refcount);
+ else {
+ dev_notice(&port_priv->device->dev,
+ "No receive handler for client %p on port %d\n",
+ &mad_agent->agent, port_priv->port_num);
+ mad_agent = NULL;
+ }
+ }
+out:
+ spin_unlock_irqrestore(&port_priv->reg_lock, flags);
+
+ return mad_agent;
+}
+
+static int validate_mad(const struct ib_mad_hdr *mad_hdr,
+ const struct ib_mad_qp_info *qp_info,
+ bool opa)
+{
+ int valid = 0;
+ u32 qp_num = qp_info->qp->qp_num;
+
+ /* Make sure MAD base version is understood */
+ if (mad_hdr->base_version != IB_MGMT_BASE_VERSION &&
+ (!opa || mad_hdr->base_version != OPA_MGMT_BASE_VERSION)) {
+ pr_err("MAD received with unsupported base version %d %s\n",
+ mad_hdr->base_version, opa ? "(opa)" : "");
+ goto out;
+ }
+
+ /* Filter SMI packets sent to other than QP0 */
+ if ((mad_hdr->mgmt_class == IB_MGMT_CLASS_SUBN_LID_ROUTED) ||
+ (mad_hdr->mgmt_class == IB_MGMT_CLASS_SUBN_DIRECTED_ROUTE)) {
+ if (qp_num == 0)
+ valid = 1;
+ } else {
+ /* CM attributes other than ClassPortInfo only use Send method */
+ if ((mad_hdr->mgmt_class == IB_MGMT_CLASS_CM) &&
+ (mad_hdr->attr_id != IB_MGMT_CLASSPORTINFO_ATTR_ID) &&
+ (mad_hdr->method != IB_MGMT_METHOD_SEND))
+ goto out;
+ /* Filter GSI packets sent to QP0 */
+ if (qp_num != 0)
+ valid = 1;
+ }
+
+out:
+ return valid;
+}
+
+static int is_rmpp_data_mad(const struct ib_mad_agent_private *mad_agent_priv,
+ const struct ib_mad_hdr *mad_hdr)
+{
+ const struct ib_rmpp_mad *rmpp_mad;
+
+ rmpp_mad = (const struct ib_rmpp_mad *)mad_hdr;
+ return !mad_agent_priv->agent.rmpp_version ||
+ !ib_mad_kernel_rmpp_agent(&mad_agent_priv->agent) ||
+ !(ib_get_rmpp_flags(&rmpp_mad->rmpp_hdr) &
+ IB_MGMT_RMPP_FLAG_ACTIVE) ||
+ (rmpp_mad->rmpp_hdr.rmpp_type == IB_MGMT_RMPP_TYPE_DATA);
+}
+
+static inline int rcv_has_same_class(const struct ib_mad_send_wr_private *wr,
+ const struct ib_mad_recv_wc *rwc)
+{
+ return ((struct ib_mad_hdr *)(wr->send_buf.mad))->mgmt_class ==
+ rwc->recv_buf.mad->mad_hdr.mgmt_class;
+}
+
+static inline int rcv_has_same_gid(const struct ib_mad_agent_private *mad_agent_priv,
+ const struct ib_mad_send_wr_private *wr,
+ const struct ib_mad_recv_wc *rwc )
+{
+ struct ib_ah_attr attr;
+ u8 send_resp, rcv_resp;
+ union ib_gid sgid;
+ struct ib_device *device = mad_agent_priv->agent.device;
+ u8 port_num = mad_agent_priv->agent.port_num;
+ u8 lmc;
+
+ send_resp = ib_response_mad((struct ib_mad_hdr *)wr->send_buf.mad);
+ rcv_resp = ib_response_mad(&rwc->recv_buf.mad->mad_hdr);
+
+ if (send_resp == rcv_resp)
+ /* both requests, or both responses. GIDs different */
+ return 0;
+
+ if (ib_query_ah(wr->send_buf.ah, &attr))
+ /* Assume not equal, to avoid false positives. */
+ return 0;
+
+ if (!!(attr.ah_flags & IB_AH_GRH) !=
+ !!(rwc->wc->wc_flags & IB_WC_GRH))
+ /* one has GID, other does not. Assume different */
+ return 0;
+
+ if (!send_resp && rcv_resp) {
+ /* is request/response. */
+ if (!(attr.ah_flags & IB_AH_GRH)) {
+ if (ib_get_cached_lmc(device, port_num, &lmc))
+ return 0;
+ return (!lmc || !((attr.src_path_bits ^
+ rwc->wc->dlid_path_bits) &
+ ((1 << lmc) - 1)));
+ } else {
+ if (ib_get_cached_gid(device, port_num,
+ attr.grh.sgid_index, &sgid, NULL))
+ return 0;
+ return !memcmp(sgid.raw, rwc->recv_buf.grh->dgid.raw,
+ 16);
+ }
+ }
+
+ if (!(attr.ah_flags & IB_AH_GRH))
+ return attr.dlid == rwc->wc->slid;
+ else
+ return !memcmp(attr.grh.dgid.raw, rwc->recv_buf.grh->sgid.raw,
+ 16);
+}
+
+static inline int is_direct(u8 class)
+{
+ return (class == IB_MGMT_CLASS_SUBN_DIRECTED_ROUTE);
+}
+
+struct ib_mad_send_wr_private*
+ib_find_send_mad(const struct ib_mad_agent_private *mad_agent_priv,
+ const struct ib_mad_recv_wc *wc)
+{
+ struct ib_mad_send_wr_private *wr;
+ const struct ib_mad_hdr *mad_hdr;
+
+ mad_hdr = &wc->recv_buf.mad->mad_hdr;
+
+ list_for_each_entry(wr, &mad_agent_priv->wait_list, agent_list) {
+ if ((wr->tid == mad_hdr->tid) &&
+ rcv_has_same_class(wr, wc) &&
+ /*
+ * Don't check GID for direct routed MADs.
+ * These might have permissive LIDs.
+ */
+ (is_direct(mad_hdr->mgmt_class) ||
+ rcv_has_same_gid(mad_agent_priv, wr, wc)))
+ return (wr->status == IB_WC_SUCCESS) ? wr : NULL;
+ }
+
+ /*
+ * It's possible to receive the response before we've
+ * been notified that the send has completed
+ */
+ list_for_each_entry(wr, &mad_agent_priv->send_list, agent_list) {
+ if (is_rmpp_data_mad(mad_agent_priv, wr->send_buf.mad) &&
+ wr->tid == mad_hdr->tid &&
+ wr->timeout &&
+ rcv_has_same_class(wr, wc) &&
+ /*
+ * Don't check GID for direct routed MADs.
+ * These might have permissive LIDs.
+ */
+ (is_direct(mad_hdr->mgmt_class) ||
+ rcv_has_same_gid(mad_agent_priv, wr, wc)))
+ /* Verify request has not been canceled */
+ return (wr->status == IB_WC_SUCCESS) ? wr : NULL;
+ }
+ return NULL;
+}
+
+void ib_mark_mad_done(struct ib_mad_send_wr_private *mad_send_wr)
+{
+ mad_send_wr->timeout = 0;
+ if (mad_send_wr->refcount == 1)
+ list_move_tail(&mad_send_wr->agent_list,
+ &mad_send_wr->mad_agent_priv->done_list);
+}
+
+static void ib_mad_complete_recv(struct ib_mad_agent_private *mad_agent_priv,
+ struct ib_mad_recv_wc *mad_recv_wc)
+{
+ struct ib_mad_send_wr_private *mad_send_wr;
+ struct ib_mad_send_wc mad_send_wc;
+ unsigned long flags;
+
+ INIT_LIST_HEAD(&mad_recv_wc->rmpp_list);
+ list_add(&mad_recv_wc->recv_buf.list, &mad_recv_wc->rmpp_list);
+ if (ib_mad_kernel_rmpp_agent(&mad_agent_priv->agent)) {
+ mad_recv_wc = ib_process_rmpp_recv_wc(mad_agent_priv,
+ mad_recv_wc);
+ if (!mad_recv_wc) {
+ deref_mad_agent(mad_agent_priv);
+ return;
+ }
+ }
+
+ /* Complete corresponding request */
+ if (ib_response_mad(&mad_recv_wc->recv_buf.mad->mad_hdr)) {
+ spin_lock_irqsave(&mad_agent_priv->lock, flags);
+ mad_send_wr = ib_find_send_mad(mad_agent_priv, mad_recv_wc);
+ if (!mad_send_wr) {
+ spin_unlock_irqrestore(&mad_agent_priv->lock, flags);
+ if (!ib_mad_kernel_rmpp_agent(&mad_agent_priv->agent)
+ && ib_is_mad_class_rmpp(mad_recv_wc->recv_buf.mad->mad_hdr.mgmt_class)
+ && (ib_get_rmpp_flags(&((struct ib_rmpp_mad *)mad_recv_wc->recv_buf.mad)->rmpp_hdr)
+ & IB_MGMT_RMPP_FLAG_ACTIVE)) {
+ /* user rmpp is in effect
+ * and this is an active RMPP MAD
+ */
+ mad_agent_priv->agent.recv_handler(
+ &mad_agent_priv->agent, NULL,
+ mad_recv_wc);
+ atomic_dec(&mad_agent_priv->refcount);
+ } else {
+ /* not user rmpp, revert to normal behavior and
+ * drop the mad */
+ ib_free_recv_mad(mad_recv_wc);
+ deref_mad_agent(mad_agent_priv);
+ return;
+ }
+ } else {
+ ib_mark_mad_done(mad_send_wr);
+ spin_unlock_irqrestore(&mad_agent_priv->lock, flags);
+
+ /* Defined behavior is to complete response before request */
+ mad_agent_priv->agent.recv_handler(
+ &mad_agent_priv->agent,
+ &mad_send_wr->send_buf,
+ mad_recv_wc);
+ atomic_dec(&mad_agent_priv->refcount);
+
+ mad_send_wc.status = IB_WC_SUCCESS;
+ mad_send_wc.vendor_err = 0;
+ mad_send_wc.send_buf = &mad_send_wr->send_buf;
+ ib_mad_complete_send_wr(mad_send_wr, &mad_send_wc);
+ }
+ } else {
+ mad_agent_priv->agent.recv_handler(&mad_agent_priv->agent, NULL,
+ mad_recv_wc);
+ deref_mad_agent(mad_agent_priv);
+ }
+}
+
+static enum smi_action handle_ib_smi(const struct ib_mad_port_private *port_priv,
+ const struct ib_mad_qp_info *qp_info,
+ const struct ib_wc *wc,
+ int port_num,
+ struct ib_mad_private *recv,
+ struct ib_mad_private *response)
+{
+ enum smi_forward_action retsmi;
+ struct ib_smp *smp = (struct ib_smp *)recv->mad;
+
+ if (smi_handle_dr_smp_recv(smp,
+ rdma_cap_ib_switch(port_priv->device),
+ port_num,
+ port_priv->device->phys_port_cnt) ==
+ IB_SMI_DISCARD)
+ return IB_SMI_DISCARD;
+
+ retsmi = smi_check_forward_dr_smp(smp);
+ if (retsmi == IB_SMI_LOCAL)
+ return IB_SMI_HANDLE;
+
+ if (retsmi == IB_SMI_SEND) { /* don't forward */
+ if (smi_handle_dr_smp_send(smp,
+ rdma_cap_ib_switch(port_priv->device),
+ port_num) == IB_SMI_DISCARD)
+ return IB_SMI_DISCARD;
+
+ if (smi_check_local_smp(smp, port_priv->device) == IB_SMI_DISCARD)
+ return IB_SMI_DISCARD;
+ } else if (rdma_cap_ib_switch(port_priv->device)) {
+ /* forward case for switches */
+ memcpy(response, recv, mad_priv_size(response));
+ response->header.recv_wc.wc = &response->header.wc;
+ response->header.recv_wc.recv_buf.mad = (struct ib_mad *)response->mad;
+ response->header.recv_wc.recv_buf.grh = &response->grh;
+
+ agent_send_response((const struct ib_mad_hdr *)response->mad,
+ &response->grh, wc,
+ port_priv->device,
+ smi_get_fwd_port(smp),
+ qp_info->qp->qp_num,
+ response->mad_size,
+ false);
+
+ return IB_SMI_DISCARD;
+ }
+ return IB_SMI_HANDLE;
+}
+
+static bool generate_unmatched_resp(const struct ib_mad_private *recv,
+ struct ib_mad_private *response,
+ size_t *resp_len, bool opa)
+{
+ const struct ib_mad_hdr *recv_hdr = (const struct ib_mad_hdr *)recv->mad;
+ struct ib_mad_hdr *resp_hdr = (struct ib_mad_hdr *)response->mad;
+
+ if (recv_hdr->method == IB_MGMT_METHOD_GET ||
+ recv_hdr->method == IB_MGMT_METHOD_SET) {
+ memcpy(response, recv, mad_priv_size(response));
+ response->header.recv_wc.wc = &response->header.wc;
+ response->header.recv_wc.recv_buf.mad = (struct ib_mad *)response->mad;
+ response->header.recv_wc.recv_buf.grh = &response->grh;
+ resp_hdr->method = IB_MGMT_METHOD_GET_RESP;
+ resp_hdr->status = cpu_to_be16(IB_MGMT_MAD_STATUS_UNSUPPORTED_METHOD_ATTRIB);
+ if (recv_hdr->mgmt_class == IB_MGMT_CLASS_SUBN_DIRECTED_ROUTE)
+ resp_hdr->status |= IB_SMP_DIRECTION;
+
+ if (opa && recv_hdr->base_version == OPA_MGMT_BASE_VERSION) {
+ if (recv_hdr->mgmt_class ==
+ IB_MGMT_CLASS_SUBN_LID_ROUTED ||
+ recv_hdr->mgmt_class ==
+ IB_MGMT_CLASS_SUBN_DIRECTED_ROUTE)
+ *resp_len = opa_get_smp_header_size(
+ (const struct opa_smp *)recv->mad);
+ else
+ *resp_len = sizeof(struct ib_mad_hdr);
+ }
+
+ return true;
+ } else {
+ return false;
+ }
+}
+
+static enum smi_action
+handle_opa_smi(struct ib_mad_port_private *port_priv,
+ struct ib_mad_qp_info *qp_info,
+ struct ib_wc *wc,
+ int port_num,
+ struct ib_mad_private *recv,
+ struct ib_mad_private *response)
+{
+ enum smi_forward_action retsmi;
+ struct opa_smp *smp = (struct opa_smp *)recv->mad;
+
+ if (opa_smi_handle_dr_smp_recv(smp,
+ rdma_cap_ib_switch(port_priv->device),
+ port_num,
+ port_priv->device->phys_port_cnt) ==
+ IB_SMI_DISCARD)
+ return IB_SMI_DISCARD;
+
+ retsmi = opa_smi_check_forward_dr_smp(smp);
+ if (retsmi == IB_SMI_LOCAL)
+ return IB_SMI_HANDLE;
+
+ if (retsmi == IB_SMI_SEND) { /* don't forward */
+ if (opa_smi_handle_dr_smp_send(smp,
+ rdma_cap_ib_switch(port_priv->device),
+ port_num) == IB_SMI_DISCARD)
+ return IB_SMI_DISCARD;
+
+ if (opa_smi_check_local_smp(smp, port_priv->device) ==
+ IB_SMI_DISCARD)
+ return IB_SMI_DISCARD;
+
+ } else if (rdma_cap_ib_switch(port_priv->device)) {
+ /* forward case for switches */
+ memcpy(response, recv, mad_priv_size(response));
+ response->header.recv_wc.wc = &response->header.wc;
+ response->header.recv_wc.recv_buf.opa_mad =
+ (struct opa_mad *)response->mad;
+ response->header.recv_wc.recv_buf.grh = &response->grh;
+
+ agent_send_response((const struct ib_mad_hdr *)response->mad,
+ &response->grh, wc,
+ port_priv->device,
+ opa_smi_get_fwd_port(smp),
+ qp_info->qp->qp_num,
+ recv->header.wc.byte_len,
+ true);
+
+ return IB_SMI_DISCARD;
+ }
+
+ return IB_SMI_HANDLE;
+}
+
+static enum smi_action
+handle_smi(struct ib_mad_port_private *port_priv,
+ struct ib_mad_qp_info *qp_info,
+ struct ib_wc *wc,
+ int port_num,
+ struct ib_mad_private *recv,
+ struct ib_mad_private *response,
+ bool opa)
+{
+ struct ib_mad_hdr *mad_hdr = (struct ib_mad_hdr *)recv->mad;
+
+ if (opa && mad_hdr->base_version == OPA_MGMT_BASE_VERSION &&
+ mad_hdr->class_version == OPA_SMI_CLASS_VERSION)
+ return handle_opa_smi(port_priv, qp_info, wc, port_num, recv,
+ response);
+
+ return handle_ib_smi(port_priv, qp_info, wc, port_num, recv, response);
+}
+
+static void ib_mad_recv_done(struct ib_cq *cq, struct ib_wc *wc)
+{
+ struct ib_mad_port_private *port_priv = cq->cq_context;
+ struct ib_mad_list_head *mad_list =
+ container_of(wc->wr_cqe, struct ib_mad_list_head, cqe);
+ struct ib_mad_qp_info *qp_info;
+ struct ib_mad_private_header *mad_priv_hdr;
+ struct ib_mad_private *recv, *response = NULL;
+ struct ib_mad_agent_private *mad_agent;
+ int port_num;
+ int ret = IB_MAD_RESULT_SUCCESS;
+ size_t mad_size;
+ u16 resp_mad_pkey_index = 0;
+ bool opa;
+
+ if (list_empty_careful(&port_priv->port_list))
+ return;
+
+ if (wc->status != IB_WC_SUCCESS) {
+ /*
+ * Receive errors indicate that the QP has entered the error
+ * state - error handling/shutdown code will cleanup
+ */
+ return;
+ }
+
+ qp_info = mad_list->mad_queue->qp_info;
+ dequeue_mad(mad_list);
+
+ opa = rdma_cap_opa_mad(qp_info->port_priv->device,
+ qp_info->port_priv->port_num);
+
+ mad_priv_hdr = container_of(mad_list, struct ib_mad_private_header,
+ mad_list);
+ recv = container_of(mad_priv_hdr, struct ib_mad_private, header);
+ ib_dma_unmap_single(port_priv->device,
+ recv->header.mapping,
+ mad_priv_dma_size(recv),
+ DMA_FROM_DEVICE);
+
+ /* Setup MAD receive work completion from "normal" work completion */
+ recv->header.wc = *wc;
+ recv->header.recv_wc.wc = &recv->header.wc;
+
+ if (opa && ((struct ib_mad_hdr *)(recv->mad))->base_version == OPA_MGMT_BASE_VERSION) {
+ recv->header.recv_wc.mad_len = wc->byte_len - sizeof(struct ib_grh);
+ recv->header.recv_wc.mad_seg_size = sizeof(struct opa_mad);
+ } else {
+ recv->header.recv_wc.mad_len = sizeof(struct ib_mad);
+ recv->header.recv_wc.mad_seg_size = sizeof(struct ib_mad);
+ }
+
+ recv->header.recv_wc.recv_buf.mad = (struct ib_mad *)recv->mad;
+ recv->header.recv_wc.recv_buf.grh = &recv->grh;
+
+ if (atomic_read(&qp_info->snoop_count))
+ snoop_recv(qp_info, &recv->header.recv_wc, IB_MAD_SNOOP_RECVS);
+
+ /* Validate MAD */
+ if (!validate_mad((const struct ib_mad_hdr *)recv->mad, qp_info, opa))
+ goto out;
+
+ mad_size = recv->mad_size;
+ response = alloc_mad_private(mad_size, GFP_KERNEL);
+ if (!response) {
+ dev_err(&port_priv->device->dev,
+ "%s: no memory for response buffer\n", __func__);
+ goto out;
+ }
+
+ if (rdma_cap_ib_switch(port_priv->device))
+ port_num = wc->port_num;
+ else
+ port_num = port_priv->port_num;
+
+ if (((struct ib_mad_hdr *)recv->mad)->mgmt_class ==
+ IB_MGMT_CLASS_SUBN_DIRECTED_ROUTE) {
+ if (handle_smi(port_priv, qp_info, wc, port_num, recv,
+ response, opa)
+ == IB_SMI_DISCARD)
+ goto out;
+ }
+
+ /* Give driver "right of first refusal" on incoming MAD */
+ if (port_priv->device->process_mad) {
+ ret = port_priv->device->process_mad(port_priv->device, 0,
+ port_priv->port_num,
+ wc, &recv->grh,
+ (const struct ib_mad_hdr *)recv->mad,
+ recv->mad_size,
+ (struct ib_mad_hdr *)response->mad,
+ &mad_size, &resp_mad_pkey_index);
+
+ if (opa)
+ wc->pkey_index = resp_mad_pkey_index;
+
+ if (ret & IB_MAD_RESULT_SUCCESS) {
+ if (ret & IB_MAD_RESULT_CONSUMED)
+ goto out;
+ if (ret & IB_MAD_RESULT_REPLY) {
+ agent_send_response((const struct ib_mad_hdr *)response->mad,
+ &recv->grh, wc,
+ port_priv->device,
+ port_num,
+ qp_info->qp->qp_num,
+ mad_size, opa);
+ goto out;
+ }
+ }
+ }
+
+ mad_agent = find_mad_agent(port_priv, (const struct ib_mad_hdr *)recv->mad);
+ if (mad_agent) {
+ ib_mad_complete_recv(mad_agent, &recv->header.recv_wc);
+ /*
+ * recv is freed up in error cases in ib_mad_complete_recv
+ * or via recv_handler in ib_mad_complete_recv()
+ */
+ recv = NULL;
+ } else if ((ret & IB_MAD_RESULT_SUCCESS) &&
+ generate_unmatched_resp(recv, response, &mad_size, opa)) {
+ agent_send_response((const struct ib_mad_hdr *)response->mad, &recv->grh, wc,
+ port_priv->device, port_num,
+ qp_info->qp->qp_num, mad_size, opa);
+ }
+
+out:
+ /* Post another receive request for this QP */
+ if (response) {
+ ib_mad_post_receive_mads(qp_info, response);
+ kfree(recv);
+ } else
+ ib_mad_post_receive_mads(qp_info, recv);
+}
+
+static void adjust_timeout(struct ib_mad_agent_private *mad_agent_priv)
+{
+ struct ib_mad_send_wr_private *mad_send_wr;
+ unsigned long delay;
+
+ if (list_empty(&mad_agent_priv->wait_list)) {
+ cancel_delayed_work(&mad_agent_priv->timed_work);
+ } else {
+ mad_send_wr = list_entry(mad_agent_priv->wait_list.next,
+ struct ib_mad_send_wr_private,
+ agent_list);
+
+ if (time_after(mad_agent_priv->timeout,
+ mad_send_wr->timeout)) {
+ mad_agent_priv->timeout = mad_send_wr->timeout;
+ delay = mad_send_wr->timeout - jiffies;
+ if ((long)delay <= 0)
+ delay = 1;
+ mod_delayed_work(mad_agent_priv->qp_info->port_priv->wq,
+ &mad_agent_priv->timed_work, delay);
+ }
+ }
+}
+
+static void wait_for_response(struct ib_mad_send_wr_private *mad_send_wr)
+{
+ struct ib_mad_agent_private *mad_agent_priv;
+ struct ib_mad_send_wr_private *temp_mad_send_wr;
+ struct list_head *list_item;
+ unsigned long delay;
+
+ mad_agent_priv = mad_send_wr->mad_agent_priv;
+ list_del(&mad_send_wr->agent_list);
+
+ delay = mad_send_wr->timeout;
+ mad_send_wr->timeout += jiffies;
+
+ if (delay) {
+ list_for_each_prev(list_item, &mad_agent_priv->wait_list) {
+ temp_mad_send_wr = list_entry(list_item,
+ struct ib_mad_send_wr_private,
+ agent_list);
+ if (time_after(mad_send_wr->timeout,
+ temp_mad_send_wr->timeout))
+ break;
+ }
+ }
+ else
+ list_item = &mad_agent_priv->wait_list;
+ list_add(&mad_send_wr->agent_list, list_item);
+
+ /* Reschedule a work item if we have a shorter timeout */
+ if (mad_agent_priv->wait_list.next == &mad_send_wr->agent_list)
+ mod_delayed_work(mad_agent_priv->qp_info->port_priv->wq,
+ &mad_agent_priv->timed_work, delay);
+}
+
+void ib_reset_mad_timeout(struct ib_mad_send_wr_private *mad_send_wr,
+ int timeout_ms)
+{
+ mad_send_wr->timeout = msecs_to_jiffies(timeout_ms);
+ wait_for_response(mad_send_wr);
+}
+
+/*
+ * Process a send work completion
+ */
+void ib_mad_complete_send_wr(struct ib_mad_send_wr_private *mad_send_wr,
+ struct ib_mad_send_wc *mad_send_wc)
+{
+ struct ib_mad_agent_private *mad_agent_priv;
+ unsigned long flags;
+ int ret;
+
+ mad_agent_priv = mad_send_wr->mad_agent_priv;
+ spin_lock_irqsave(&mad_agent_priv->lock, flags);
+ if (ib_mad_kernel_rmpp_agent(&mad_agent_priv->agent)) {
+ ret = ib_process_rmpp_send_wc(mad_send_wr, mad_send_wc);
+ if (ret == IB_RMPP_RESULT_CONSUMED)
+ goto done;
+ } else
+ ret = IB_RMPP_RESULT_UNHANDLED;
+
+ if (mad_send_wc->status != IB_WC_SUCCESS &&
+ mad_send_wr->status == IB_WC_SUCCESS) {
+ mad_send_wr->status = mad_send_wc->status;
+ mad_send_wr->refcount -= (mad_send_wr->timeout > 0);
+ }
+
+ if (--mad_send_wr->refcount > 0) {
+ if (mad_send_wr->refcount == 1 && mad_send_wr->timeout &&
+ mad_send_wr->status == IB_WC_SUCCESS) {
+ wait_for_response(mad_send_wr);
+ }
+ goto done;
+ }
+
+ /* Remove send from MAD agent and notify client of completion */
+ list_del(&mad_send_wr->agent_list);
+ adjust_timeout(mad_agent_priv);
+ spin_unlock_irqrestore(&mad_agent_priv->lock, flags);
+
+ if (mad_send_wr->status != IB_WC_SUCCESS )
+ mad_send_wc->status = mad_send_wr->status;
+ if (ret == IB_RMPP_RESULT_INTERNAL)
+ ib_rmpp_send_handler(mad_send_wc);
+ else
+ mad_agent_priv->agent.send_handler(&mad_agent_priv->agent,
+ mad_send_wc);
+
+ /* Release reference on agent taken when sending */
+ deref_mad_agent(mad_agent_priv);
+ return;
+done:
+ spin_unlock_irqrestore(&mad_agent_priv->lock, flags);
+}
+
+static void ib_mad_send_done(struct ib_cq *cq, struct ib_wc *wc)
+{
+ struct ib_mad_port_private *port_priv = cq->cq_context;
+ struct ib_mad_list_head *mad_list =
+ container_of(wc->wr_cqe, struct ib_mad_list_head, cqe);
+ struct ib_mad_send_wr_private *mad_send_wr, *queued_send_wr;
+ struct ib_mad_qp_info *qp_info;
+ struct ib_mad_queue *send_queue;
+ struct ib_send_wr *bad_send_wr;
+ struct ib_mad_send_wc mad_send_wc;
+ unsigned long flags;
+ int ret;
+
+ if (list_empty_careful(&port_priv->port_list))
+ return;
+
+ if (wc->status != IB_WC_SUCCESS) {
+ if (!ib_mad_send_error(port_priv, wc))
+ return;
+ }
+
+ mad_send_wr = container_of(mad_list, struct ib_mad_send_wr_private,
+ mad_list);
+ send_queue = mad_list->mad_queue;
+ qp_info = send_queue->qp_info;
+
+retry:
+ ib_dma_unmap_single(mad_send_wr->send_buf.mad_agent->device,
+ mad_send_wr->header_mapping,
+ mad_send_wr->sg_list[0].length, DMA_TO_DEVICE);
+ ib_dma_unmap_single(mad_send_wr->send_buf.mad_agent->device,
+ mad_send_wr->payload_mapping,
+ mad_send_wr->sg_list[1].length, DMA_TO_DEVICE);
+ queued_send_wr = NULL;
+ spin_lock_irqsave(&send_queue->lock, flags);
+ list_del(&mad_list->list);
+
+ /* Move queued send to the send queue */
+ if (send_queue->count-- > send_queue->max_active) {
+ mad_list = container_of(qp_info->overflow_list.next,
+ struct ib_mad_list_head, list);
+ queued_send_wr = container_of(mad_list,
+ struct ib_mad_send_wr_private,
+ mad_list);
+ list_move_tail(&mad_list->list, &send_queue->list);
+ }
+ spin_unlock_irqrestore(&send_queue->lock, flags);
+
+ mad_send_wc.send_buf = &mad_send_wr->send_buf;
+ mad_send_wc.status = wc->status;
+ mad_send_wc.vendor_err = wc->vendor_err;
+ if (atomic_read(&qp_info->snoop_count))
+ snoop_send(qp_info, &mad_send_wr->send_buf, &mad_send_wc,
+ IB_MAD_SNOOP_SEND_COMPLETIONS);
+ ib_mad_complete_send_wr(mad_send_wr, &mad_send_wc);
+
+ if (queued_send_wr) {
+ ret = ib_post_send(qp_info->qp, &queued_send_wr->send_wr.wr,
+ &bad_send_wr);
+ if (ret) {
+ dev_err(&port_priv->device->dev,
+ "ib_post_send failed: %d\n", ret);
+ mad_send_wr = queued_send_wr;
+ wc->status = IB_WC_LOC_QP_OP_ERR;
+ goto retry;
+ }
+ }
+}
+
+static void mark_sends_for_retry(struct ib_mad_qp_info *qp_info)
+{
+ struct ib_mad_send_wr_private *mad_send_wr;
+ struct ib_mad_list_head *mad_list;
+ unsigned long flags;
+
+ spin_lock_irqsave(&qp_info->send_queue.lock, flags);
+ list_for_each_entry(mad_list, &qp_info->send_queue.list, list) {
+ mad_send_wr = container_of(mad_list,
+ struct ib_mad_send_wr_private,
+ mad_list);
+ mad_send_wr->retry = 1;
+ }
+ spin_unlock_irqrestore(&qp_info->send_queue.lock, flags);
+}
+
+static bool ib_mad_send_error(struct ib_mad_port_private *port_priv,
+ struct ib_wc *wc)
+{
+ struct ib_mad_list_head *mad_list =
+ container_of(wc->wr_cqe, struct ib_mad_list_head, cqe);
+ struct ib_mad_qp_info *qp_info = mad_list->mad_queue->qp_info;
+ struct ib_mad_send_wr_private *mad_send_wr;
+ int ret;
+
+ /*
+ * Send errors will transition the QP to SQE - move
+ * QP to RTS and repost flushed work requests
+ */
+ mad_send_wr = container_of(mad_list, struct ib_mad_send_wr_private,
+ mad_list);
+ if (wc->status == IB_WC_WR_FLUSH_ERR) {
+ if (mad_send_wr->retry) {
+ /* Repost send */
+ struct ib_send_wr *bad_send_wr;
+
+ mad_send_wr->retry = 0;
+ ret = ib_post_send(qp_info->qp, &mad_send_wr->send_wr.wr,
+ &bad_send_wr);
+ if (!ret)
+ return false;
+ }
+ } else {
+ struct ib_qp_attr *attr;
+
+ /* Transition QP to RTS and fail offending send */
+ attr = kmalloc(sizeof *attr, GFP_KERNEL);
+ if (attr) {
+ attr->qp_state = IB_QPS_RTS;
+ attr->cur_qp_state = IB_QPS_SQE;
+ ret = ib_modify_qp(qp_info->qp, attr,
+ IB_QP_STATE | IB_QP_CUR_STATE);
+ kfree(attr);
+ if (ret)
+ dev_err(&port_priv->device->dev,
+ "%s - ib_modify_qp to RTS: %d\n",
+ __func__, ret);
+ else
+ mark_sends_for_retry(qp_info);
+ }
+ }
+
+ return true;
+}
+
+static void cancel_mads(struct ib_mad_agent_private *mad_agent_priv)
+{
+ unsigned long flags;
+ struct ib_mad_send_wr_private *mad_send_wr, *temp_mad_send_wr;
+ struct ib_mad_send_wc mad_send_wc;
+ struct list_head cancel_list;
+
+ INIT_LIST_HEAD(&cancel_list);
+
+ spin_lock_irqsave(&mad_agent_priv->lock, flags);
+ list_for_each_entry_safe(mad_send_wr, temp_mad_send_wr,
+ &mad_agent_priv->send_list, agent_list) {
+ if (mad_send_wr->status == IB_WC_SUCCESS) {
+ mad_send_wr->status = IB_WC_WR_FLUSH_ERR;
+ mad_send_wr->refcount -= (mad_send_wr->timeout > 0);
+ }
+ }
+
+ /* Empty wait list to prevent receives from finding a request */
+ list_splice_init(&mad_agent_priv->wait_list, &cancel_list);
+ spin_unlock_irqrestore(&mad_agent_priv->lock, flags);
+
+ /* Report all cancelled requests */
+ mad_send_wc.status = IB_WC_WR_FLUSH_ERR;
+ mad_send_wc.vendor_err = 0;
+
+ list_for_each_entry_safe(mad_send_wr, temp_mad_send_wr,
+ &cancel_list, agent_list) {
+ mad_send_wc.send_buf = &mad_send_wr->send_buf;
+ list_del(&mad_send_wr->agent_list);
+ mad_agent_priv->agent.send_handler(&mad_agent_priv->agent,
+ &mad_send_wc);
+ atomic_dec(&mad_agent_priv->refcount);
+ }
+}
+
+static struct ib_mad_send_wr_private*
+find_send_wr(struct ib_mad_agent_private *mad_agent_priv,
+ struct ib_mad_send_buf *send_buf)
+{
+ struct ib_mad_send_wr_private *mad_send_wr;
+
+ list_for_each_entry(mad_send_wr, &mad_agent_priv->wait_list,
+ agent_list) {
+ if (&mad_send_wr->send_buf == send_buf)
+ return mad_send_wr;
+ }
+
+ list_for_each_entry(mad_send_wr, &mad_agent_priv->send_list,
+ agent_list) {
+ if (is_rmpp_data_mad(mad_agent_priv,
+ mad_send_wr->send_buf.mad) &&
+ &mad_send_wr->send_buf == send_buf)
+ return mad_send_wr;
+ }
+ return NULL;
+}
+
+int ib_modify_mad(struct ib_mad_agent *mad_agent,
+ struct ib_mad_send_buf *send_buf, u32 timeout_ms)
+{
+ struct ib_mad_agent_private *mad_agent_priv;
+ struct ib_mad_send_wr_private *mad_send_wr;
+ unsigned long flags;
+ int active;
+
+ mad_agent_priv = container_of(mad_agent, struct ib_mad_agent_private,
+ agent);
+ spin_lock_irqsave(&mad_agent_priv->lock, flags);
+ mad_send_wr = find_send_wr(mad_agent_priv, send_buf);
+ if (!mad_send_wr || mad_send_wr->status != IB_WC_SUCCESS) {
+ spin_unlock_irqrestore(&mad_agent_priv->lock, flags);
+ return -EINVAL;
+ }
+
+ active = (!mad_send_wr->timeout || mad_send_wr->refcount > 1);
+ if (!timeout_ms) {
+ mad_send_wr->status = IB_WC_WR_FLUSH_ERR;
+ mad_send_wr->refcount -= (mad_send_wr->timeout > 0);
+ }
+
+ mad_send_wr->send_buf.timeout_ms = timeout_ms;
+ if (active)
+ mad_send_wr->timeout = msecs_to_jiffies(timeout_ms);
+ else
+ ib_reset_mad_timeout(mad_send_wr, timeout_ms);
+
+ spin_unlock_irqrestore(&mad_agent_priv->lock, flags);
+ return 0;
+}
+EXPORT_SYMBOL(ib_modify_mad);
+
+void ib_cancel_mad(struct ib_mad_agent *mad_agent,
+ struct ib_mad_send_buf *send_buf)
+{
+ ib_modify_mad(mad_agent, send_buf, 0);
+}
+EXPORT_SYMBOL(ib_cancel_mad);
+
+static void local_completions(struct work_struct *work)
+{
+ struct ib_mad_agent_private *mad_agent_priv;
+ struct ib_mad_local_private *local;
+ struct ib_mad_agent_private *recv_mad_agent;
+ unsigned long flags;
+ int free_mad;
+ struct ib_wc wc;
+ struct ib_mad_send_wc mad_send_wc;
+ bool opa;
+
+ mad_agent_priv =
+ container_of(work, struct ib_mad_agent_private, local_work);
+
+ opa = rdma_cap_opa_mad(mad_agent_priv->qp_info->port_priv->device,
+ mad_agent_priv->qp_info->port_priv->port_num);
+
+ spin_lock_irqsave(&mad_agent_priv->lock, flags);
+ while (!list_empty(&mad_agent_priv->local_list)) {
+ local = list_entry(mad_agent_priv->local_list.next,
+ struct ib_mad_local_private,
+ completion_list);
+ list_del(&local->completion_list);
+ spin_unlock_irqrestore(&mad_agent_priv->lock, flags);
+ free_mad = 0;
+ if (local->mad_priv) {
+ u8 base_version;
+ recv_mad_agent = local->recv_mad_agent;
+ if (!recv_mad_agent) {
+ dev_err(&mad_agent_priv->agent.device->dev,
+ "No receive MAD agent for local completion\n");
+ free_mad = 1;
+ goto local_send_completion;
+ }
+
+ /*
+ * Defined behavior is to complete response
+ * before request
+ */
+ build_smp_wc(recv_mad_agent->agent.qp,
+ local->mad_send_wr->send_wr.wr.wr_cqe,
+ be16_to_cpu(IB_LID_PERMISSIVE),
+ local->mad_send_wr->send_wr.pkey_index,
+ recv_mad_agent->agent.port_num, &wc);
+
+ local->mad_priv->header.recv_wc.wc = &wc;
+
+ base_version = ((struct ib_mad_hdr *)(local->mad_priv->mad))->base_version;
+ if (opa && base_version == OPA_MGMT_BASE_VERSION) {
+ local->mad_priv->header.recv_wc.mad_len = local->return_wc_byte_len;
+ local->mad_priv->header.recv_wc.mad_seg_size = sizeof(struct opa_mad);
+ } else {
+ local->mad_priv->header.recv_wc.mad_len = sizeof(struct ib_mad);
+ local->mad_priv->header.recv_wc.mad_seg_size = sizeof(struct ib_mad);
+ }
+
+ INIT_LIST_HEAD(&local->mad_priv->header.recv_wc.rmpp_list);
+ list_add(&local->mad_priv->header.recv_wc.recv_buf.list,
+ &local->mad_priv->header.recv_wc.rmpp_list);
+ local->mad_priv->header.recv_wc.recv_buf.grh = NULL;
+ local->mad_priv->header.recv_wc.recv_buf.mad =
+ (struct ib_mad *)local->mad_priv->mad;
+ if (atomic_read(&recv_mad_agent->qp_info->snoop_count))
+ snoop_recv(recv_mad_agent->qp_info,
+ &local->mad_priv->header.recv_wc,
+ IB_MAD_SNOOP_RECVS);
+ recv_mad_agent->agent.recv_handler(
+ &recv_mad_agent->agent,
+ &local->mad_send_wr->send_buf,
+ &local->mad_priv->header.recv_wc);
+ spin_lock_irqsave(&recv_mad_agent->lock, flags);
+ atomic_dec(&recv_mad_agent->refcount);
+ spin_unlock_irqrestore(&recv_mad_agent->lock, flags);
+ }
+
+local_send_completion:
+ /* Complete send */
+ mad_send_wc.status = IB_WC_SUCCESS;
+ mad_send_wc.vendor_err = 0;
+ mad_send_wc.send_buf = &local->mad_send_wr->send_buf;
+ if (atomic_read(&mad_agent_priv->qp_info->snoop_count))
+ snoop_send(mad_agent_priv->qp_info,
+ &local->mad_send_wr->send_buf,
+ &mad_send_wc, IB_MAD_SNOOP_SEND_COMPLETIONS);
+ mad_agent_priv->agent.send_handler(&mad_agent_priv->agent,
+ &mad_send_wc);
+
+ spin_lock_irqsave(&mad_agent_priv->lock, flags);
+ atomic_dec(&mad_agent_priv->refcount);
+ if (free_mad)
+ kfree(local->mad_priv);
+ kfree(local);
+ }
+ spin_unlock_irqrestore(&mad_agent_priv->lock, flags);
+}
+
+static int retry_send(struct ib_mad_send_wr_private *mad_send_wr)
+{
+ int ret;
+
+ if (!mad_send_wr->retries_left)
+ return -ETIMEDOUT;
+
+ mad_send_wr->retries_left--;
+ mad_send_wr->send_buf.retries++;
+
+ mad_send_wr->timeout = msecs_to_jiffies(mad_send_wr->send_buf.timeout_ms);
+
+ if (ib_mad_kernel_rmpp_agent(&mad_send_wr->mad_agent_priv->agent)) {
+ ret = ib_retry_rmpp(mad_send_wr);
+ switch (ret) {
+ case IB_RMPP_RESULT_UNHANDLED:
+ ret = ib_send_mad(mad_send_wr);
+ break;
+ case IB_RMPP_RESULT_CONSUMED:
+ ret = 0;
+ break;
+ default:
+ ret = -ECOMM;
+ break;
+ }
+ } else
+ ret = ib_send_mad(mad_send_wr);
+
+ if (!ret) {
+ mad_send_wr->refcount++;
+ list_add_tail(&mad_send_wr->agent_list,
+ &mad_send_wr->mad_agent_priv->send_list);
+ }
+ return ret;
+}
+
+static void timeout_sends(struct work_struct *work)
+{
+ struct ib_mad_agent_private *mad_agent_priv;
+ struct ib_mad_send_wr_private *mad_send_wr;
+ struct ib_mad_send_wc mad_send_wc;
+ unsigned long flags, delay;
+
+ mad_agent_priv = container_of(work, struct ib_mad_agent_private,
+ timed_work.work);
+ mad_send_wc.vendor_err = 0;
+
+ spin_lock_irqsave(&mad_agent_priv->lock, flags);
+ while (!list_empty(&mad_agent_priv->wait_list)) {
+ mad_send_wr = list_entry(mad_agent_priv->wait_list.next,
+ struct ib_mad_send_wr_private,
+ agent_list);
+
+ if (time_after(mad_send_wr->timeout, jiffies)) {
+ delay = mad_send_wr->timeout - jiffies;
+ if ((long)delay <= 0)
+ delay = 1;
+ queue_delayed_work(mad_agent_priv->qp_info->
+ port_priv->wq,
+ &mad_agent_priv->timed_work, delay);
+ break;
+ }
+
+ list_del(&mad_send_wr->agent_list);
+ if (mad_send_wr->status == IB_WC_SUCCESS &&
+ !retry_send(mad_send_wr))
+ continue;
+
+ spin_unlock_irqrestore(&mad_agent_priv->lock, flags);
+
+ if (mad_send_wr->status == IB_WC_SUCCESS)
+ mad_send_wc.status = IB_WC_RESP_TIMEOUT_ERR;
+ else
+ mad_send_wc.status = mad_send_wr->status;
+ mad_send_wc.send_buf = &mad_send_wr->send_buf;
+ mad_agent_priv->agent.send_handler(&mad_agent_priv->agent,
+ &mad_send_wc);
+
+ atomic_dec(&mad_agent_priv->refcount);
+ spin_lock_irqsave(&mad_agent_priv->lock, flags);
+ }
+ spin_unlock_irqrestore(&mad_agent_priv->lock, flags);
+}
+
+/*
+ * Allocate receive MADs and post receive WRs for them
+ */
+static int ib_mad_post_receive_mads(struct ib_mad_qp_info *qp_info,
+ struct ib_mad_private *mad)
+{
+ unsigned long flags;
+ int post, ret;
+ struct ib_mad_private *mad_priv;
+ struct ib_sge sg_list;
+ struct ib_recv_wr recv_wr, *bad_recv_wr;
+ struct ib_mad_queue *recv_queue = &qp_info->recv_queue;
+
+ /* Initialize common scatter list fields */
+ sg_list.lkey = qp_info->port_priv->pd->local_dma_lkey;
+
+ /* Initialize common receive WR fields */
+ recv_wr.next = NULL;
+ recv_wr.sg_list = &sg_list;
+ recv_wr.num_sge = 1;
+
+ do {
+ /* Allocate and map receive buffer */
+ if (mad) {
+ mad_priv = mad;
+ mad = NULL;
+ } else {
+ mad_priv = alloc_mad_private(port_mad_size(qp_info->port_priv),
+ GFP_ATOMIC);
+ if (!mad_priv) {
+ dev_err(&qp_info->port_priv->device->dev,
+ "No memory for receive buffer\n");
+ ret = -ENOMEM;
+ break;
+ }
+ }
+ sg_list.length = mad_priv_dma_size(mad_priv);
+ sg_list.addr = ib_dma_map_single(qp_info->port_priv->device,
+ &mad_priv->grh,
+ mad_priv_dma_size(mad_priv),
+ DMA_FROM_DEVICE);
+ if (unlikely(ib_dma_mapping_error(qp_info->port_priv->device,
+ sg_list.addr))) {
+ ret = -ENOMEM;
+ break;
+ }
+ mad_priv->header.mapping = sg_list.addr;
+ mad_priv->header.mad_list.mad_queue = recv_queue;
+ mad_priv->header.mad_list.cqe.done = ib_mad_recv_done;
+ recv_wr.wr_cqe = &mad_priv->header.mad_list.cqe;
+
+ /* Post receive WR */
+ spin_lock_irqsave(&recv_queue->lock, flags);
+ post = (++recv_queue->count < recv_queue->max_active);
+ list_add_tail(&mad_priv->header.mad_list.list, &recv_queue->list);
+ spin_unlock_irqrestore(&recv_queue->lock, flags);
+ ret = ib_post_recv(qp_info->qp, &recv_wr, &bad_recv_wr);
+ if (ret) {
+ spin_lock_irqsave(&recv_queue->lock, flags);
+ list_del(&mad_priv->header.mad_list.list);
+ recv_queue->count--;
+ spin_unlock_irqrestore(&recv_queue->lock, flags);
+ ib_dma_unmap_single(qp_info->port_priv->device,
+ mad_priv->header.mapping,
+ mad_priv_dma_size(mad_priv),
+ DMA_FROM_DEVICE);
+ kfree(mad_priv);
+ dev_err(&qp_info->port_priv->device->dev,
+ "ib_post_recv failed: %d\n", ret);
+ break;
+ }
+ } while (post);
+
+ return ret;
+}
+
+/*
+ * Return all the posted receive MADs
+ */
+static void cleanup_recv_queue(struct ib_mad_qp_info *qp_info)
+{
+ struct ib_mad_private_header *mad_priv_hdr;
+ struct ib_mad_private *recv;
+ struct ib_mad_list_head *mad_list;
+
+ if (!qp_info->qp)
+ return;
+
+ while (!list_empty(&qp_info->recv_queue.list)) {
+
+ mad_list = list_entry(qp_info->recv_queue.list.next,
+ struct ib_mad_list_head, list);
+ mad_priv_hdr = container_of(mad_list,
+ struct ib_mad_private_header,
+ mad_list);
+ recv = container_of(mad_priv_hdr, struct ib_mad_private,
+ header);
+
+ /* Remove from posted receive MAD list */
+ list_del(&mad_list->list);
+
+ ib_dma_unmap_single(qp_info->port_priv->device,
+ recv->header.mapping,
+ mad_priv_dma_size(recv),
+ DMA_FROM_DEVICE);
+ kfree(recv);
+ }
+
+ qp_info->recv_queue.count = 0;
+}
+
+/*
+ * Start the port
+ */
+static int ib_mad_port_start(struct ib_mad_port_private *port_priv)
+{
+ int ret, i;
+ struct ib_qp_attr *attr;
+ struct ib_qp *qp;
+ u16 pkey_index;
+
+ attr = kmalloc(sizeof *attr, GFP_KERNEL);
+ if (!attr) {
+ dev_err(&port_priv->device->dev,
+ "Couldn't kmalloc ib_qp_attr\n");
+ return -ENOMEM;
+ }
+
+ ret = ib_find_pkey(port_priv->device, port_priv->port_num,
+ IB_DEFAULT_PKEY_FULL, &pkey_index);
+ if (ret)
+ pkey_index = 0;
+
+ for (i = 0; i < IB_MAD_QPS_CORE; i++) {
+ qp = port_priv->qp_info[i].qp;
+ if (!qp)
+ continue;
+
+ /*
+ * PKey index for QP1 is irrelevant but
+ * one is needed for the Reset to Init transition
+ */
+ attr->qp_state = IB_QPS_INIT;
+ attr->pkey_index = pkey_index;
+ attr->qkey = (qp->qp_num == 0) ? 0 : IB_QP1_QKEY;
+ ret = ib_modify_qp(qp, attr, IB_QP_STATE |
+ IB_QP_PKEY_INDEX | IB_QP_QKEY);
+ if (ret) {
+ dev_err(&port_priv->device->dev,
+ "Couldn't change QP%d state to INIT: %d\n",
+ i, ret);
+ goto out;
+ }
+
+ attr->qp_state = IB_QPS_RTR;
+ ret = ib_modify_qp(qp, attr, IB_QP_STATE);
+ if (ret) {
+ dev_err(&port_priv->device->dev,
+ "Couldn't change QP%d state to RTR: %d\n",
+ i, ret);
+ goto out;
+ }
+
+ attr->qp_state = IB_QPS_RTS;
+ attr->sq_psn = IB_MAD_SEND_Q_PSN;
+ ret = ib_modify_qp(qp, attr, IB_QP_STATE | IB_QP_SQ_PSN);
+ if (ret) {
+ dev_err(&port_priv->device->dev,
+ "Couldn't change QP%d state to RTS: %d\n",
+ i, ret);
+ goto out;
+ }
+ }
+
+ ret = ib_req_notify_cq(port_priv->cq, IB_CQ_NEXT_COMP);
+ if (ret) {
+ dev_err(&port_priv->device->dev,
+ "Failed to request completion notification: %d\n",
+ ret);
+ goto out;
+ }
+
+ for (i = 0; i < IB_MAD_QPS_CORE; i++) {
+ if (!port_priv->qp_info[i].qp)
+ continue;
+
+ ret = ib_mad_post_receive_mads(&port_priv->qp_info[i], NULL);
+ if (ret) {
+ dev_err(&port_priv->device->dev,
+ "Couldn't post receive WRs\n");
+ goto out;
+ }
+ }
+out:
+ kfree(attr);
+ return ret;
+}
+
+static void qp_event_handler(struct ib_event *event, void *qp_context)
+{
+ struct ib_mad_qp_info *qp_info = qp_context;
+
+ /* It's worse than that! He's dead, Jim! */
+ dev_err(&qp_info->port_priv->device->dev,
+ "Fatal error (%d) on MAD QP (%d)\n",
+ event->event, qp_info->qp->qp_num);
+}
+
+static void init_mad_queue(struct ib_mad_qp_info *qp_info,
+ struct ib_mad_queue *mad_queue)
+{
+ mad_queue->qp_info = qp_info;
+ mad_queue->count = 0;
+ spin_lock_init(&mad_queue->lock);
+ INIT_LIST_HEAD(&mad_queue->list);
+}
+
+static void init_mad_qp(struct ib_mad_port_private *port_priv,
+ struct ib_mad_qp_info *qp_info)
+{
+ qp_info->port_priv = port_priv;
+ init_mad_queue(qp_info, &qp_info->send_queue);
+ init_mad_queue(qp_info, &qp_info->recv_queue);
+ INIT_LIST_HEAD(&qp_info->overflow_list);
+ spin_lock_init(&qp_info->snoop_lock);
+ qp_info->snoop_table = NULL;
+ qp_info->snoop_table_size = 0;
+ atomic_set(&qp_info->snoop_count, 0);
+}
+
+static int create_mad_qp(struct ib_mad_qp_info *qp_info,
+ enum ib_qp_type qp_type)
+{
+ struct ib_qp_init_attr qp_init_attr;
+ int ret;
+
+ memset(&qp_init_attr, 0, sizeof qp_init_attr);
+ qp_init_attr.send_cq = qp_info->port_priv->cq;
+ qp_init_attr.recv_cq = qp_info->port_priv->cq;
+ qp_init_attr.sq_sig_type = IB_SIGNAL_ALL_WR;
+ qp_init_attr.cap.max_send_wr = mad_sendq_size;
+ qp_init_attr.cap.max_recv_wr = mad_recvq_size;
+ qp_init_attr.cap.max_send_sge = IB_MAD_SEND_REQ_MAX_SG;
+ qp_init_attr.cap.max_recv_sge = IB_MAD_RECV_REQ_MAX_SG;
+ qp_init_attr.qp_type = qp_type;
+ qp_init_attr.port_num = qp_info->port_priv->port_num;
+ qp_init_attr.qp_context = qp_info;
+ qp_init_attr.event_handler = qp_event_handler;
+ qp_info->qp = ib_create_qp(qp_info->port_priv->pd, &qp_init_attr);
+ if (IS_ERR(qp_info->qp)) {
+ dev_err(&qp_info->port_priv->device->dev,
+ "Couldn't create ib_mad QP%d\n",
+ get_spl_qp_index(qp_type));
+ ret = PTR_ERR(qp_info->qp);
+ goto error;
+ }
+ /* Use minimum queue sizes unless the CQ is resized */
+ qp_info->send_queue.max_active = mad_sendq_size;
+ qp_info->recv_queue.max_active = mad_recvq_size;
+ return 0;
+
+error:
+ return ret;
+}
+
+static void destroy_mad_qp(struct ib_mad_qp_info *qp_info)
+{
+ if (!qp_info->qp)
+ return;
+
+ ib_destroy_qp(qp_info->qp);
+ kfree(qp_info->snoop_table);
+}
+
+/*
+ * Open the port
+ * Create the QP, PD, MR, and CQ if needed
+ */
+static int ib_mad_port_open(struct ib_device *device,
+ int port_num)
+{
+ int ret, cq_size;
+ struct ib_mad_port_private *port_priv;
+ unsigned long flags;
+ char name[sizeof "ib_mad123"];
+ int has_smi;
+
+ if (WARN_ON(rdma_max_mad_size(device, port_num) < IB_MGMT_MAD_SIZE))
+ return -EFAULT;
+
+ if (WARN_ON(rdma_cap_opa_mad(device, port_num) &&
+ rdma_max_mad_size(device, port_num) < OPA_MGMT_MAD_SIZE))
+ return -EFAULT;
+
+ /* Create new device info */
+ port_priv = kzalloc(sizeof *port_priv, GFP_KERNEL);
+ if (!port_priv) {
+ dev_err(&device->dev, "No memory for ib_mad_port_private\n");
+ return -ENOMEM;
+ }
+
+ port_priv->device = device;
+ port_priv->port_num = port_num;
+ spin_lock_init(&port_priv->reg_lock);
+ INIT_LIST_HEAD(&port_priv->agent_list);
+ init_mad_qp(port_priv, &port_priv->qp_info[0]);
+ init_mad_qp(port_priv, &port_priv->qp_info[1]);
+
+ cq_size = mad_sendq_size + mad_recvq_size;
+ has_smi = rdma_cap_ib_smi(device, port_num);
+ if (has_smi)
+ cq_size *= 2;
+
+ port_priv->cq = ib_alloc_cq(port_priv->device, port_priv, cq_size, 0,
+ IB_POLL_WORKQUEUE);
+ if (IS_ERR(port_priv->cq)) {
+ dev_err(&device->dev, "Couldn't create ib_mad CQ\n");
+ ret = PTR_ERR(port_priv->cq);
+ goto error3;
+ }
+
+ port_priv->pd = ib_alloc_pd(device, 0);
+ if (IS_ERR(port_priv->pd)) {
+ dev_err(&device->dev, "Couldn't create ib_mad PD\n");
+ ret = PTR_ERR(port_priv->pd);
+ goto error4;
+ }
+
+ if (has_smi) {
+ ret = create_mad_qp(&port_priv->qp_info[0], IB_QPT_SMI);
+ if (ret)
+ goto error6;
+ }
+ ret = create_mad_qp(&port_priv->qp_info[1], IB_QPT_GSI);
+ if (ret)
+ goto error7;
+
+ snprintf(name, sizeof name, "ib_mad%d", port_num);
+ port_priv->wq = alloc_ordered_workqueue(name, WQ_MEM_RECLAIM);
+ if (!port_priv->wq) {
+ ret = -ENOMEM;
+ goto error8;
+ }
+
+ spin_lock_irqsave(&ib_mad_port_list_lock, flags);
+ list_add_tail(&port_priv->port_list, &ib_mad_port_list);
+ spin_unlock_irqrestore(&ib_mad_port_list_lock, flags);
+
+ ret = ib_mad_port_start(port_priv);
+ if (ret) {
+ dev_err(&device->dev, "Couldn't start port\n");
+ goto error9;
+ }
+
+ return 0;
+
+error9:
+ spin_lock_irqsave(&ib_mad_port_list_lock, flags);
+ list_del_init(&port_priv->port_list);
+ spin_unlock_irqrestore(&ib_mad_port_list_lock, flags);
+
+ destroy_workqueue(port_priv->wq);
+error8:
+ destroy_mad_qp(&port_priv->qp_info[1]);
+error7:
+ destroy_mad_qp(&port_priv->qp_info[0]);
+error6:
+ ib_dealloc_pd(port_priv->pd);
+error4:
+ ib_free_cq(port_priv->cq);
+ cleanup_recv_queue(&port_priv->qp_info[1]);
+ cleanup_recv_queue(&port_priv->qp_info[0]);
+error3:
+ kfree(port_priv);
+
+ return ret;
+}
+
+/*
+ * Close the port
+ * If there are no classes using the port, free the port
+ * resources (CQ, MR, PD, QP) and remove the port's info structure
+ */
+static int ib_mad_port_close(struct ib_device *device, int port_num)
+{
+ struct ib_mad_port_private *port_priv;
+ unsigned long flags;
+
+ spin_lock_irqsave(&ib_mad_port_list_lock, flags);
+ port_priv = __ib_get_mad_port(device, port_num);
+ if (port_priv == NULL) {
+ spin_unlock_irqrestore(&ib_mad_port_list_lock, flags);
+ dev_err(&device->dev, "Port %d not found\n", port_num);
+ return -ENODEV;
+ }
+ list_del_init(&port_priv->port_list);
+ spin_unlock_irqrestore(&ib_mad_port_list_lock, flags);
+
+ destroy_workqueue(port_priv->wq);
+ destroy_mad_qp(&port_priv->qp_info[1]);
+ destroy_mad_qp(&port_priv->qp_info[0]);
+ ib_dealloc_pd(port_priv->pd);
+ ib_free_cq(port_priv->cq);
+ cleanup_recv_queue(&port_priv->qp_info[1]);
+ cleanup_recv_queue(&port_priv->qp_info[0]);
+ /* XXX: Handle deallocation of MAD registration tables */
+
+ kfree(port_priv);
+
+ return 0;
+}
+
+static void ib_mad_init_device(struct ib_device *device)
+{
+ int start, i;
+
+ start = rdma_start_port(device);
+
+ for (i = start; i <= rdma_end_port(device); i++) {
+ if (!rdma_cap_ib_mad(device, i))
+ continue;
+
+ if (ib_mad_port_open(device, i)) {
+ dev_err(&device->dev, "Couldn't open port %d\n", i);
+ goto error;
+ }
+ if (ib_agent_port_open(device, i)) {
+ dev_err(&device->dev,
+ "Couldn't open port %d for agents\n", i);
+ goto error_agent;
+ }
+ }
+ return;
+
+error_agent:
+ if (ib_mad_port_close(device, i))
+ dev_err(&device->dev, "Couldn't close port %d\n", i);
+
+error:
+ while (--i >= start) {
+ if (!rdma_cap_ib_mad(device, i))
+ continue;
+
+ if (ib_agent_port_close(device, i))
+ dev_err(&device->dev,
+ "Couldn't close port %d for agents\n", i);
+ if (ib_mad_port_close(device, i))
+ dev_err(&device->dev, "Couldn't close port %d\n", i);
+ }
+}
+
+static void ib_mad_remove_device(struct ib_device *device, void *client_data)
+{
+ int i;
+
+ for (i = rdma_start_port(device); i <= rdma_end_port(device); i++) {
+ if (!rdma_cap_ib_mad(device, i))
+ continue;
+
+ if (ib_agent_port_close(device, i))
+ dev_err(&device->dev,
+ "Couldn't close port %d for agents\n", i);
+ if (ib_mad_port_close(device, i))
+ dev_err(&device->dev, "Couldn't close port %d\n", i);
+ }
+}
+
+static struct ib_client mad_client = {
+ .name = "mad",
+ .add = ib_mad_init_device,
+ .remove = ib_mad_remove_device
+};
+
+int ib_mad_init(void)
+{
+ mad_recvq_size = min(mad_recvq_size, IB_MAD_QP_MAX_SIZE);
+ mad_recvq_size = max(mad_recvq_size, IB_MAD_QP_MIN_SIZE);
+
+ mad_sendq_size = min(mad_sendq_size, IB_MAD_QP_MAX_SIZE);
+ mad_sendq_size = max(mad_sendq_size, IB_MAD_QP_MIN_SIZE);
+
+ INIT_LIST_HEAD(&ib_mad_port_list);
+
+ if (ib_register_client(&mad_client)) {
+ pr_err("Couldn't register ib_mad client\n");
+ return -EINVAL;
+ }
+
+ return 0;
+}
+
+void ib_mad_cleanup(void)
+{
+ ib_unregister_client(&mad_client);
+}
diff --git a/sys/ofed/drivers/infiniband/core/ib_mad_rmpp.c b/sys/ofed/drivers/infiniband/core/ib_mad_rmpp.c
new file mode 100644
index 0000000..382941b
--- /dev/null
+++ b/sys/ofed/drivers/infiniband/core/ib_mad_rmpp.c
@@ -0,0 +1,968 @@
+/*
+ * Copyright (c) 2005 Intel Inc. All rights reserved.
+ * Copyright (c) 2005-2006 Voltaire, Inc. All rights reserved.
+ * Copyright (c) 2014 Intel Corporation. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#include <linux/slab.h>
+
+#include "mad_priv.h"
+#include "mad_rmpp.h"
+
+enum rmpp_state {
+ RMPP_STATE_ACTIVE,
+ RMPP_STATE_TIMEOUT,
+ RMPP_STATE_COMPLETE,
+ RMPP_STATE_CANCELING
+};
+
+struct mad_rmpp_recv {
+ struct ib_mad_agent_private *agent;
+ struct list_head list;
+ struct delayed_work timeout_work;
+ struct delayed_work cleanup_work;
+ struct completion comp;
+ enum rmpp_state state;
+ spinlock_t lock;
+ atomic_t refcount;
+
+ struct ib_ah *ah;
+ struct ib_mad_recv_wc *rmpp_wc;
+ struct ib_mad_recv_buf *cur_seg_buf;
+ int last_ack;
+ int seg_num;
+ int newwin;
+ int repwin;
+
+ __be64 tid;
+ u32 src_qp;
+ u16 slid;
+ u8 mgmt_class;
+ u8 class_version;
+ u8 method;
+ u8 base_version;
+};
+
+static inline void deref_rmpp_recv(struct mad_rmpp_recv *rmpp_recv)
+{
+ if (atomic_dec_and_test(&rmpp_recv->refcount))
+ complete(&rmpp_recv->comp);
+}
+
+static void destroy_rmpp_recv(struct mad_rmpp_recv *rmpp_recv)
+{
+ deref_rmpp_recv(rmpp_recv);
+ wait_for_completion(&rmpp_recv->comp);
+ ib_destroy_ah(rmpp_recv->ah);
+ kfree(rmpp_recv);
+}
+
+void ib_cancel_rmpp_recvs(struct ib_mad_agent_private *agent)
+{
+ struct mad_rmpp_recv *rmpp_recv, *temp_rmpp_recv;
+ unsigned long flags;
+
+ spin_lock_irqsave(&agent->lock, flags);
+ list_for_each_entry(rmpp_recv, &agent->rmpp_list, list) {
+ if (rmpp_recv->state != RMPP_STATE_COMPLETE)
+ ib_free_recv_mad(rmpp_recv->rmpp_wc);
+ rmpp_recv->state = RMPP_STATE_CANCELING;
+ }
+ spin_unlock_irqrestore(&agent->lock, flags);
+
+ list_for_each_entry(rmpp_recv, &agent->rmpp_list, list) {
+ cancel_delayed_work(&rmpp_recv->timeout_work);
+ cancel_delayed_work(&rmpp_recv->cleanup_work);
+ }
+
+ flush_workqueue(agent->qp_info->port_priv->wq);
+
+ list_for_each_entry_safe(rmpp_recv, temp_rmpp_recv,
+ &agent->rmpp_list, list) {
+ list_del(&rmpp_recv->list);
+ destroy_rmpp_recv(rmpp_recv);
+ }
+}
+
+static void format_ack(struct ib_mad_send_buf *msg,
+ struct ib_rmpp_mad *data,
+ struct mad_rmpp_recv *rmpp_recv)
+{
+ struct ib_rmpp_mad *ack = msg->mad;
+ unsigned long flags;
+
+ memcpy(ack, &data->mad_hdr, msg->hdr_len);
+
+ ack->mad_hdr.method ^= IB_MGMT_METHOD_RESP;
+ ack->rmpp_hdr.rmpp_type = IB_MGMT_RMPP_TYPE_ACK;
+ ib_set_rmpp_flags(&ack->rmpp_hdr, IB_MGMT_RMPP_FLAG_ACTIVE);
+
+ spin_lock_irqsave(&rmpp_recv->lock, flags);
+ rmpp_recv->last_ack = rmpp_recv->seg_num;
+ ack->rmpp_hdr.seg_num = cpu_to_be32(rmpp_recv->seg_num);
+ ack->rmpp_hdr.paylen_newwin = cpu_to_be32(rmpp_recv->newwin);
+ spin_unlock_irqrestore(&rmpp_recv->lock, flags);
+}
+
+static void ack_recv(struct mad_rmpp_recv *rmpp_recv,
+ struct ib_mad_recv_wc *recv_wc)
+{
+ struct ib_mad_send_buf *msg;
+ int ret, hdr_len;
+
+ hdr_len = ib_get_mad_data_offset(recv_wc->recv_buf.mad->mad_hdr.mgmt_class);
+ msg = ib_create_send_mad(&rmpp_recv->agent->agent, recv_wc->wc->src_qp,
+ recv_wc->wc->pkey_index, 1, hdr_len,
+ 0, GFP_KERNEL,
+ IB_MGMT_BASE_VERSION);
+ if (IS_ERR(msg))
+ return;
+
+ format_ack(msg, (struct ib_rmpp_mad *) recv_wc->recv_buf.mad, rmpp_recv);
+ msg->ah = rmpp_recv->ah;
+ ret = ib_post_send_mad(msg, NULL);
+ if (ret)
+ ib_free_send_mad(msg);
+}
+
+static struct ib_mad_send_buf *alloc_response_msg(struct ib_mad_agent *agent,
+ struct ib_mad_recv_wc *recv_wc)
+{
+ struct ib_mad_send_buf *msg;
+ struct ib_ah *ah;
+ int hdr_len;
+
+ ah = ib_create_ah_from_wc(agent->qp->pd, recv_wc->wc,
+ recv_wc->recv_buf.grh, agent->port_num);
+ if (IS_ERR(ah))
+ return (void *) ah;
+
+ hdr_len = ib_get_mad_data_offset(recv_wc->recv_buf.mad->mad_hdr.mgmt_class);
+ msg = ib_create_send_mad(agent, recv_wc->wc->src_qp,
+ recv_wc->wc->pkey_index, 1,
+ hdr_len, 0, GFP_KERNEL,
+ IB_MGMT_BASE_VERSION);
+ if (IS_ERR(msg))
+ ib_destroy_ah(ah);
+ else {
+ msg->ah = ah;
+ msg->context[0] = ah;
+ }
+
+ return msg;
+}
+
+static void ack_ds_ack(struct ib_mad_agent_private *agent,
+ struct ib_mad_recv_wc *recv_wc)
+{
+ struct ib_mad_send_buf *msg;
+ struct ib_rmpp_mad *rmpp_mad;
+ int ret;
+
+ msg = alloc_response_msg(&agent->agent, recv_wc);
+ if (IS_ERR(msg))
+ return;
+
+ rmpp_mad = msg->mad;
+ memcpy(rmpp_mad, recv_wc->recv_buf.mad, msg->hdr_len);
+
+ rmpp_mad->mad_hdr.method ^= IB_MGMT_METHOD_RESP;
+ ib_set_rmpp_flags(&rmpp_mad->rmpp_hdr, IB_MGMT_RMPP_FLAG_ACTIVE);
+ rmpp_mad->rmpp_hdr.seg_num = 0;
+ rmpp_mad->rmpp_hdr.paylen_newwin = cpu_to_be32(1);
+
+ ret = ib_post_send_mad(msg, NULL);
+ if (ret) {
+ ib_destroy_ah(msg->ah);
+ ib_free_send_mad(msg);
+ }
+}
+
+void ib_rmpp_send_handler(struct ib_mad_send_wc *mad_send_wc)
+{
+ if (mad_send_wc->send_buf->context[0] == mad_send_wc->send_buf->ah)
+ ib_destroy_ah(mad_send_wc->send_buf->ah);
+ ib_free_send_mad(mad_send_wc->send_buf);
+}
+
+static void nack_recv(struct ib_mad_agent_private *agent,
+ struct ib_mad_recv_wc *recv_wc, u8 rmpp_status)
+{
+ struct ib_mad_send_buf *msg;
+ struct ib_rmpp_mad *rmpp_mad;
+ int ret;
+
+ msg = alloc_response_msg(&agent->agent, recv_wc);
+ if (IS_ERR(msg))
+ return;
+
+ rmpp_mad = msg->mad;
+ memcpy(rmpp_mad, recv_wc->recv_buf.mad, msg->hdr_len);
+
+ rmpp_mad->mad_hdr.method ^= IB_MGMT_METHOD_RESP;
+ rmpp_mad->rmpp_hdr.rmpp_version = IB_MGMT_RMPP_VERSION;
+ rmpp_mad->rmpp_hdr.rmpp_type = IB_MGMT_RMPP_TYPE_ABORT;
+ ib_set_rmpp_flags(&rmpp_mad->rmpp_hdr, IB_MGMT_RMPP_FLAG_ACTIVE);
+ rmpp_mad->rmpp_hdr.rmpp_status = rmpp_status;
+ rmpp_mad->rmpp_hdr.seg_num = 0;
+ rmpp_mad->rmpp_hdr.paylen_newwin = 0;
+
+ ret = ib_post_send_mad(msg, NULL);
+ if (ret) {
+ ib_destroy_ah(msg->ah);
+ ib_free_send_mad(msg);
+ }
+}
+
+static void recv_timeout_handler(struct work_struct *work)
+{
+ struct mad_rmpp_recv *rmpp_recv =
+ container_of(work, struct mad_rmpp_recv, timeout_work.work);
+ struct ib_mad_recv_wc *rmpp_wc;
+ unsigned long flags;
+
+ spin_lock_irqsave(&rmpp_recv->agent->lock, flags);
+ if (rmpp_recv->state != RMPP_STATE_ACTIVE) {
+ spin_unlock_irqrestore(&rmpp_recv->agent->lock, flags);
+ return;
+ }
+ rmpp_recv->state = RMPP_STATE_TIMEOUT;
+ list_del(&rmpp_recv->list);
+ spin_unlock_irqrestore(&rmpp_recv->agent->lock, flags);
+
+ rmpp_wc = rmpp_recv->rmpp_wc;
+ nack_recv(rmpp_recv->agent, rmpp_wc, IB_MGMT_RMPP_STATUS_T2L);
+ destroy_rmpp_recv(rmpp_recv);
+ ib_free_recv_mad(rmpp_wc);
+}
+
+static void recv_cleanup_handler(struct work_struct *work)
+{
+ struct mad_rmpp_recv *rmpp_recv =
+ container_of(work, struct mad_rmpp_recv, cleanup_work.work);
+ unsigned long flags;
+
+ spin_lock_irqsave(&rmpp_recv->agent->lock, flags);
+ if (rmpp_recv->state == RMPP_STATE_CANCELING) {
+ spin_unlock_irqrestore(&rmpp_recv->agent->lock, flags);
+ return;
+ }
+ list_del(&rmpp_recv->list);
+ spin_unlock_irqrestore(&rmpp_recv->agent->lock, flags);
+ destroy_rmpp_recv(rmpp_recv);
+}
+
+static struct mad_rmpp_recv *
+create_rmpp_recv(struct ib_mad_agent_private *agent,
+ struct ib_mad_recv_wc *mad_recv_wc)
+{
+ struct mad_rmpp_recv *rmpp_recv;
+ struct ib_mad_hdr *mad_hdr;
+
+ rmpp_recv = kmalloc(sizeof *rmpp_recv, GFP_KERNEL);
+ if (!rmpp_recv)
+ return NULL;
+
+ rmpp_recv->ah = ib_create_ah_from_wc(agent->agent.qp->pd,
+ mad_recv_wc->wc,
+ mad_recv_wc->recv_buf.grh,
+ agent->agent.port_num);
+ if (IS_ERR(rmpp_recv->ah))
+ goto error;
+
+ rmpp_recv->agent = agent;
+ init_completion(&rmpp_recv->comp);
+ INIT_DELAYED_WORK(&rmpp_recv->timeout_work, recv_timeout_handler);
+ INIT_DELAYED_WORK(&rmpp_recv->cleanup_work, recv_cleanup_handler);
+ spin_lock_init(&rmpp_recv->lock);
+ rmpp_recv->state = RMPP_STATE_ACTIVE;
+ atomic_set(&rmpp_recv->refcount, 1);
+
+ rmpp_recv->rmpp_wc = mad_recv_wc;
+ rmpp_recv->cur_seg_buf = &mad_recv_wc->recv_buf;
+ rmpp_recv->newwin = 1;
+ rmpp_recv->seg_num = 1;
+ rmpp_recv->last_ack = 0;
+ rmpp_recv->repwin = 1;
+
+ mad_hdr = &mad_recv_wc->recv_buf.mad->mad_hdr;
+ rmpp_recv->tid = mad_hdr->tid;
+ rmpp_recv->src_qp = mad_recv_wc->wc->src_qp;
+ rmpp_recv->slid = mad_recv_wc->wc->slid;
+ rmpp_recv->mgmt_class = mad_hdr->mgmt_class;
+ rmpp_recv->class_version = mad_hdr->class_version;
+ rmpp_recv->method = mad_hdr->method;
+ rmpp_recv->base_version = mad_hdr->base_version;
+ return rmpp_recv;
+
+error: kfree(rmpp_recv);
+ return NULL;
+}
+
+static struct mad_rmpp_recv *
+find_rmpp_recv(struct ib_mad_agent_private *agent,
+ struct ib_mad_recv_wc *mad_recv_wc)
+{
+ struct mad_rmpp_recv *rmpp_recv;
+ struct ib_mad_hdr *mad_hdr = &mad_recv_wc->recv_buf.mad->mad_hdr;
+
+ list_for_each_entry(rmpp_recv, &agent->rmpp_list, list) {
+ if (rmpp_recv->tid == mad_hdr->tid &&
+ rmpp_recv->src_qp == mad_recv_wc->wc->src_qp &&
+ rmpp_recv->slid == mad_recv_wc->wc->slid &&
+ rmpp_recv->mgmt_class == mad_hdr->mgmt_class &&
+ rmpp_recv->class_version == mad_hdr->class_version &&
+ rmpp_recv->method == mad_hdr->method)
+ return rmpp_recv;
+ }
+ return NULL;
+}
+
+static struct mad_rmpp_recv *
+acquire_rmpp_recv(struct ib_mad_agent_private *agent,
+ struct ib_mad_recv_wc *mad_recv_wc)
+{
+ struct mad_rmpp_recv *rmpp_recv;
+ unsigned long flags;
+
+ spin_lock_irqsave(&agent->lock, flags);
+ rmpp_recv = find_rmpp_recv(agent, mad_recv_wc);
+ if (rmpp_recv)
+ atomic_inc(&rmpp_recv->refcount);
+ spin_unlock_irqrestore(&agent->lock, flags);
+ return rmpp_recv;
+}
+
+static struct mad_rmpp_recv *
+insert_rmpp_recv(struct ib_mad_agent_private *agent,
+ struct mad_rmpp_recv *rmpp_recv)
+{
+ struct mad_rmpp_recv *cur_rmpp_recv;
+
+ cur_rmpp_recv = find_rmpp_recv(agent, rmpp_recv->rmpp_wc);
+ if (!cur_rmpp_recv)
+ list_add_tail(&rmpp_recv->list, &agent->rmpp_list);
+
+ return cur_rmpp_recv;
+}
+
+static inline int get_last_flag(struct ib_mad_recv_buf *seg)
+{
+ struct ib_rmpp_mad *rmpp_mad;
+
+ rmpp_mad = (struct ib_rmpp_mad *) seg->mad;
+ return ib_get_rmpp_flags(&rmpp_mad->rmpp_hdr) & IB_MGMT_RMPP_FLAG_LAST;
+}
+
+static inline int get_seg_num(struct ib_mad_recv_buf *seg)
+{
+ struct ib_rmpp_mad *rmpp_mad;
+
+ rmpp_mad = (struct ib_rmpp_mad *) seg->mad;
+ return be32_to_cpu(rmpp_mad->rmpp_hdr.seg_num);
+}
+
+static inline struct ib_mad_recv_buf * get_next_seg(struct list_head *rmpp_list,
+ struct ib_mad_recv_buf *seg)
+{
+ if (seg->list.next == rmpp_list)
+ return NULL;
+
+ return container_of(seg->list.next, struct ib_mad_recv_buf, list);
+}
+
+static inline int window_size(struct ib_mad_agent_private *agent)
+{
+ return max(agent->qp_info->recv_queue.max_active >> 3, 1);
+}
+
+static struct ib_mad_recv_buf * find_seg_location(struct list_head *rmpp_list,
+ int seg_num)
+{
+ struct ib_mad_recv_buf *seg_buf;
+ int cur_seg_num;
+
+ list_for_each_entry_reverse(seg_buf, rmpp_list, list) {
+ cur_seg_num = get_seg_num(seg_buf);
+ if (seg_num > cur_seg_num)
+ return seg_buf;
+ if (seg_num == cur_seg_num)
+ break;
+ }
+ return NULL;
+}
+
+static void update_seg_num(struct mad_rmpp_recv *rmpp_recv,
+ struct ib_mad_recv_buf *new_buf)
+{
+ struct list_head *rmpp_list = &rmpp_recv->rmpp_wc->rmpp_list;
+
+ while (new_buf && (get_seg_num(new_buf) == rmpp_recv->seg_num + 1)) {
+ rmpp_recv->cur_seg_buf = new_buf;
+ rmpp_recv->seg_num++;
+ new_buf = get_next_seg(rmpp_list, new_buf);
+ }
+}
+
+static inline int get_mad_len(struct mad_rmpp_recv *rmpp_recv)
+{
+ struct ib_rmpp_mad *rmpp_mad;
+ int hdr_size, data_size, pad;
+ bool opa = rdma_cap_opa_mad(rmpp_recv->agent->qp_info->port_priv->device,
+ rmpp_recv->agent->qp_info->port_priv->port_num);
+
+ rmpp_mad = (struct ib_rmpp_mad *)rmpp_recv->cur_seg_buf->mad;
+
+ hdr_size = ib_get_mad_data_offset(rmpp_mad->mad_hdr.mgmt_class);
+ if (opa && rmpp_recv->base_version == OPA_MGMT_BASE_VERSION) {
+ data_size = sizeof(struct opa_rmpp_mad) - hdr_size;
+ pad = OPA_MGMT_RMPP_DATA - be32_to_cpu(rmpp_mad->rmpp_hdr.paylen_newwin);
+ if (pad > OPA_MGMT_RMPP_DATA || pad < 0)
+ pad = 0;
+ } else {
+ data_size = sizeof(struct ib_rmpp_mad) - hdr_size;
+ pad = IB_MGMT_RMPP_DATA - be32_to_cpu(rmpp_mad->rmpp_hdr.paylen_newwin);
+ if (pad > IB_MGMT_RMPP_DATA || pad < 0)
+ pad = 0;
+ }
+
+ return hdr_size + rmpp_recv->seg_num * data_size - pad;
+}
+
+static struct ib_mad_recv_wc * complete_rmpp(struct mad_rmpp_recv *rmpp_recv)
+{
+ struct ib_mad_recv_wc *rmpp_wc;
+
+ ack_recv(rmpp_recv, rmpp_recv->rmpp_wc);
+ if (rmpp_recv->seg_num > 1)
+ cancel_delayed_work(&rmpp_recv->timeout_work);
+
+ rmpp_wc = rmpp_recv->rmpp_wc;
+ rmpp_wc->mad_len = get_mad_len(rmpp_recv);
+ /* 10 seconds until we can find the packet lifetime */
+ queue_delayed_work(rmpp_recv->agent->qp_info->port_priv->wq,
+ &rmpp_recv->cleanup_work, msecs_to_jiffies(10000));
+ return rmpp_wc;
+}
+
+static struct ib_mad_recv_wc *
+continue_rmpp(struct ib_mad_agent_private *agent,
+ struct ib_mad_recv_wc *mad_recv_wc)
+{
+ struct mad_rmpp_recv *rmpp_recv;
+ struct ib_mad_recv_buf *prev_buf;
+ struct ib_mad_recv_wc *done_wc;
+ int seg_num;
+ unsigned long flags;
+
+ rmpp_recv = acquire_rmpp_recv(agent, mad_recv_wc);
+ if (!rmpp_recv)
+ goto drop1;
+
+ seg_num = get_seg_num(&mad_recv_wc->recv_buf);
+
+ spin_lock_irqsave(&rmpp_recv->lock, flags);
+ if ((rmpp_recv->state == RMPP_STATE_TIMEOUT) ||
+ (seg_num > rmpp_recv->newwin))
+ goto drop3;
+
+ if ((seg_num <= rmpp_recv->last_ack) ||
+ (rmpp_recv->state == RMPP_STATE_COMPLETE)) {
+ spin_unlock_irqrestore(&rmpp_recv->lock, flags);
+ ack_recv(rmpp_recv, mad_recv_wc);
+ goto drop2;
+ }
+
+ prev_buf = find_seg_location(&rmpp_recv->rmpp_wc->rmpp_list, seg_num);
+ if (!prev_buf)
+ goto drop3;
+
+ done_wc = NULL;
+ list_add(&mad_recv_wc->recv_buf.list, &prev_buf->list);
+ if (rmpp_recv->cur_seg_buf == prev_buf) {
+ update_seg_num(rmpp_recv, &mad_recv_wc->recv_buf);
+ if (get_last_flag(rmpp_recv->cur_seg_buf)) {
+ rmpp_recv->state = RMPP_STATE_COMPLETE;
+ spin_unlock_irqrestore(&rmpp_recv->lock, flags);
+ done_wc = complete_rmpp(rmpp_recv);
+ goto out;
+ } else if (rmpp_recv->seg_num == rmpp_recv->newwin) {
+ rmpp_recv->newwin += window_size(agent);
+ spin_unlock_irqrestore(&rmpp_recv->lock, flags);
+ ack_recv(rmpp_recv, mad_recv_wc);
+ goto out;
+ }
+ }
+ spin_unlock_irqrestore(&rmpp_recv->lock, flags);
+out:
+ deref_rmpp_recv(rmpp_recv);
+ return done_wc;
+
+drop3: spin_unlock_irqrestore(&rmpp_recv->lock, flags);
+drop2: deref_rmpp_recv(rmpp_recv);
+drop1: ib_free_recv_mad(mad_recv_wc);
+ return NULL;
+}
+
+static struct ib_mad_recv_wc *
+start_rmpp(struct ib_mad_agent_private *agent,
+ struct ib_mad_recv_wc *mad_recv_wc)
+{
+ struct mad_rmpp_recv *rmpp_recv;
+ unsigned long flags;
+
+ rmpp_recv = create_rmpp_recv(agent, mad_recv_wc);
+ if (!rmpp_recv) {
+ ib_free_recv_mad(mad_recv_wc);
+ return NULL;
+ }
+
+ spin_lock_irqsave(&agent->lock, flags);
+ if (insert_rmpp_recv(agent, rmpp_recv)) {
+ spin_unlock_irqrestore(&agent->lock, flags);
+ /* duplicate first MAD */
+ destroy_rmpp_recv(rmpp_recv);
+ return continue_rmpp(agent, mad_recv_wc);
+ }
+ atomic_inc(&rmpp_recv->refcount);
+
+ if (get_last_flag(&mad_recv_wc->recv_buf)) {
+ rmpp_recv->state = RMPP_STATE_COMPLETE;
+ spin_unlock_irqrestore(&agent->lock, flags);
+ complete_rmpp(rmpp_recv);
+ } else {
+ spin_unlock_irqrestore(&agent->lock, flags);
+ /* 40 seconds until we can find the packet lifetimes */
+ queue_delayed_work(agent->qp_info->port_priv->wq,
+ &rmpp_recv->timeout_work,
+ msecs_to_jiffies(40000));
+ rmpp_recv->newwin += window_size(agent);
+ ack_recv(rmpp_recv, mad_recv_wc);
+ mad_recv_wc = NULL;
+ }
+ deref_rmpp_recv(rmpp_recv);
+ return mad_recv_wc;
+}
+
+static int send_next_seg(struct ib_mad_send_wr_private *mad_send_wr)
+{
+ struct ib_rmpp_mad *rmpp_mad;
+ int timeout;
+ u32 paylen = 0;
+
+ rmpp_mad = mad_send_wr->send_buf.mad;
+ ib_set_rmpp_flags(&rmpp_mad->rmpp_hdr, IB_MGMT_RMPP_FLAG_ACTIVE);
+ rmpp_mad->rmpp_hdr.seg_num = cpu_to_be32(++mad_send_wr->seg_num);
+
+ if (mad_send_wr->seg_num == 1) {
+ rmpp_mad->rmpp_hdr.rmpp_rtime_flags |= IB_MGMT_RMPP_FLAG_FIRST;
+ paylen = (mad_send_wr->send_buf.seg_count *
+ mad_send_wr->send_buf.seg_rmpp_size) -
+ mad_send_wr->pad;
+ }
+
+ if (mad_send_wr->seg_num == mad_send_wr->send_buf.seg_count) {
+ rmpp_mad->rmpp_hdr.rmpp_rtime_flags |= IB_MGMT_RMPP_FLAG_LAST;
+ paylen = mad_send_wr->send_buf.seg_rmpp_size - mad_send_wr->pad;
+ }
+ rmpp_mad->rmpp_hdr.paylen_newwin = cpu_to_be32(paylen);
+
+ /* 2 seconds for an ACK until we can find the packet lifetime */
+ timeout = mad_send_wr->send_buf.timeout_ms;
+ if (!timeout || timeout > 2000)
+ mad_send_wr->timeout = msecs_to_jiffies(2000);
+
+ return ib_send_mad(mad_send_wr);
+}
+
+static void abort_send(struct ib_mad_agent_private *agent,
+ struct ib_mad_recv_wc *mad_recv_wc, u8 rmpp_status)
+{
+ struct ib_mad_send_wr_private *mad_send_wr;
+ struct ib_mad_send_wc wc;
+ unsigned long flags;
+
+ spin_lock_irqsave(&agent->lock, flags);
+ mad_send_wr = ib_find_send_mad(agent, mad_recv_wc);
+ if (!mad_send_wr)
+ goto out; /* Unmatched send */
+
+ if ((mad_send_wr->last_ack == mad_send_wr->send_buf.seg_count) ||
+ (!mad_send_wr->timeout) || (mad_send_wr->status != IB_WC_SUCCESS))
+ goto out; /* Send is already done */
+
+ ib_mark_mad_done(mad_send_wr);
+ spin_unlock_irqrestore(&agent->lock, flags);
+
+ wc.status = IB_WC_REM_ABORT_ERR;
+ wc.vendor_err = rmpp_status;
+ wc.send_buf = &mad_send_wr->send_buf;
+ ib_mad_complete_send_wr(mad_send_wr, &wc);
+ return;
+out:
+ spin_unlock_irqrestore(&agent->lock, flags);
+}
+
+static inline void adjust_last_ack(struct ib_mad_send_wr_private *wr,
+ int seg_num)
+{
+ struct list_head *list;
+
+ wr->last_ack = seg_num;
+ list = &wr->last_ack_seg->list;
+ list_for_each_entry(wr->last_ack_seg, list, list)
+ if (wr->last_ack_seg->num == seg_num)
+ break;
+}
+
+static void process_ds_ack(struct ib_mad_agent_private *agent,
+ struct ib_mad_recv_wc *mad_recv_wc, int newwin)
+{
+ struct mad_rmpp_recv *rmpp_recv;
+
+ rmpp_recv = find_rmpp_recv(agent, mad_recv_wc);
+ if (rmpp_recv && rmpp_recv->state == RMPP_STATE_COMPLETE)
+ rmpp_recv->repwin = newwin;
+}
+
+static void process_rmpp_ack(struct ib_mad_agent_private *agent,
+ struct ib_mad_recv_wc *mad_recv_wc)
+{
+ struct ib_mad_send_wr_private *mad_send_wr;
+ struct ib_rmpp_mad *rmpp_mad;
+ unsigned long flags;
+ int seg_num, newwin, ret;
+
+ rmpp_mad = (struct ib_rmpp_mad *)mad_recv_wc->recv_buf.mad;
+ if (rmpp_mad->rmpp_hdr.rmpp_status) {
+ abort_send(agent, mad_recv_wc, IB_MGMT_RMPP_STATUS_BAD_STATUS);
+ nack_recv(agent, mad_recv_wc, IB_MGMT_RMPP_STATUS_BAD_STATUS);
+ return;
+ }
+
+ seg_num = be32_to_cpu(rmpp_mad->rmpp_hdr.seg_num);
+ newwin = be32_to_cpu(rmpp_mad->rmpp_hdr.paylen_newwin);
+ if (newwin < seg_num) {
+ abort_send(agent, mad_recv_wc, IB_MGMT_RMPP_STATUS_W2S);
+ nack_recv(agent, mad_recv_wc, IB_MGMT_RMPP_STATUS_W2S);
+ return;
+ }
+
+ spin_lock_irqsave(&agent->lock, flags);
+ mad_send_wr = ib_find_send_mad(agent, mad_recv_wc);
+ if (!mad_send_wr) {
+ if (!seg_num)
+ process_ds_ack(agent, mad_recv_wc, newwin);
+ goto out; /* Unmatched or DS RMPP ACK */
+ }
+
+ if ((mad_send_wr->last_ack == mad_send_wr->send_buf.seg_count) &&
+ (mad_send_wr->timeout)) {
+ spin_unlock_irqrestore(&agent->lock, flags);
+ ack_ds_ack(agent, mad_recv_wc);
+ return; /* Repeated ACK for DS RMPP transaction */
+ }
+
+ if ((mad_send_wr->last_ack == mad_send_wr->send_buf.seg_count) ||
+ (!mad_send_wr->timeout) || (mad_send_wr->status != IB_WC_SUCCESS))
+ goto out; /* Send is already done */
+
+ if (seg_num > mad_send_wr->send_buf.seg_count ||
+ seg_num > mad_send_wr->newwin) {
+ spin_unlock_irqrestore(&agent->lock, flags);
+ abort_send(agent, mad_recv_wc, IB_MGMT_RMPP_STATUS_S2B);
+ nack_recv(agent, mad_recv_wc, IB_MGMT_RMPP_STATUS_S2B);
+ return;
+ }
+
+ if (newwin < mad_send_wr->newwin || seg_num < mad_send_wr->last_ack)
+ goto out; /* Old ACK */
+
+ if (seg_num > mad_send_wr->last_ack) {
+ adjust_last_ack(mad_send_wr, seg_num);
+ mad_send_wr->retries_left = mad_send_wr->max_retries;
+ }
+ mad_send_wr->newwin = newwin;
+ if (mad_send_wr->last_ack == mad_send_wr->send_buf.seg_count) {
+ /* If no response is expected, the ACK completes the send */
+ if (!mad_send_wr->send_buf.timeout_ms) {
+ struct ib_mad_send_wc wc;
+
+ ib_mark_mad_done(mad_send_wr);
+ spin_unlock_irqrestore(&agent->lock, flags);
+
+ wc.status = IB_WC_SUCCESS;
+ wc.vendor_err = 0;
+ wc.send_buf = &mad_send_wr->send_buf;
+ ib_mad_complete_send_wr(mad_send_wr, &wc);
+ return;
+ }
+ if (mad_send_wr->refcount == 1)
+ ib_reset_mad_timeout(mad_send_wr,
+ mad_send_wr->send_buf.timeout_ms);
+ spin_unlock_irqrestore(&agent->lock, flags);
+ ack_ds_ack(agent, mad_recv_wc);
+ return;
+ } else if (mad_send_wr->refcount == 1 &&
+ mad_send_wr->seg_num < mad_send_wr->newwin &&
+ mad_send_wr->seg_num < mad_send_wr->send_buf.seg_count) {
+ /* Send failure will just result in a timeout/retry */
+ ret = send_next_seg(mad_send_wr);
+ if (ret)
+ goto out;
+
+ mad_send_wr->refcount++;
+ list_move_tail(&mad_send_wr->agent_list,
+ &mad_send_wr->mad_agent_priv->send_list);
+ }
+out:
+ spin_unlock_irqrestore(&agent->lock, flags);
+}
+
+static struct ib_mad_recv_wc *
+process_rmpp_data(struct ib_mad_agent_private *agent,
+ struct ib_mad_recv_wc *mad_recv_wc)
+{
+ struct ib_rmpp_hdr *rmpp_hdr;
+ u8 rmpp_status;
+
+ rmpp_hdr = &((struct ib_rmpp_mad *)mad_recv_wc->recv_buf.mad)->rmpp_hdr;
+
+ if (rmpp_hdr->rmpp_status) {
+ rmpp_status = IB_MGMT_RMPP_STATUS_BAD_STATUS;
+ goto bad;
+ }
+
+ if (rmpp_hdr->seg_num == cpu_to_be32(1)) {
+ if (!(ib_get_rmpp_flags(rmpp_hdr) & IB_MGMT_RMPP_FLAG_FIRST)) {
+ rmpp_status = IB_MGMT_RMPP_STATUS_BAD_SEG;
+ goto bad;
+ }
+ return start_rmpp(agent, mad_recv_wc);
+ } else {
+ if (ib_get_rmpp_flags(rmpp_hdr) & IB_MGMT_RMPP_FLAG_FIRST) {
+ rmpp_status = IB_MGMT_RMPP_STATUS_BAD_SEG;
+ goto bad;
+ }
+ return continue_rmpp(agent, mad_recv_wc);
+ }
+bad:
+ nack_recv(agent, mad_recv_wc, rmpp_status);
+ ib_free_recv_mad(mad_recv_wc);
+ return NULL;
+}
+
+static void process_rmpp_stop(struct ib_mad_agent_private *agent,
+ struct ib_mad_recv_wc *mad_recv_wc)
+{
+ struct ib_rmpp_mad *rmpp_mad;
+
+ rmpp_mad = (struct ib_rmpp_mad *)mad_recv_wc->recv_buf.mad;
+
+ if (rmpp_mad->rmpp_hdr.rmpp_status != IB_MGMT_RMPP_STATUS_RESX) {
+ abort_send(agent, mad_recv_wc, IB_MGMT_RMPP_STATUS_BAD_STATUS);
+ nack_recv(agent, mad_recv_wc, IB_MGMT_RMPP_STATUS_BAD_STATUS);
+ } else
+ abort_send(agent, mad_recv_wc, rmpp_mad->rmpp_hdr.rmpp_status);
+}
+
+static void process_rmpp_abort(struct ib_mad_agent_private *agent,
+ struct ib_mad_recv_wc *mad_recv_wc)
+{
+ struct ib_rmpp_mad *rmpp_mad;
+
+ rmpp_mad = (struct ib_rmpp_mad *)mad_recv_wc->recv_buf.mad;
+
+ if (rmpp_mad->rmpp_hdr.rmpp_status < IB_MGMT_RMPP_STATUS_ABORT_MIN ||
+ rmpp_mad->rmpp_hdr.rmpp_status > IB_MGMT_RMPP_STATUS_ABORT_MAX) {
+ abort_send(agent, mad_recv_wc, IB_MGMT_RMPP_STATUS_BAD_STATUS);
+ nack_recv(agent, mad_recv_wc, IB_MGMT_RMPP_STATUS_BAD_STATUS);
+ } else
+ abort_send(agent, mad_recv_wc, rmpp_mad->rmpp_hdr.rmpp_status);
+}
+
+struct ib_mad_recv_wc *
+ib_process_rmpp_recv_wc(struct ib_mad_agent_private *agent,
+ struct ib_mad_recv_wc *mad_recv_wc)
+{
+ struct ib_rmpp_mad *rmpp_mad;
+
+ rmpp_mad = (struct ib_rmpp_mad *)mad_recv_wc->recv_buf.mad;
+ if (!(rmpp_mad->rmpp_hdr.rmpp_rtime_flags & IB_MGMT_RMPP_FLAG_ACTIVE))
+ return mad_recv_wc;
+
+ if (rmpp_mad->rmpp_hdr.rmpp_version != IB_MGMT_RMPP_VERSION) {
+ abort_send(agent, mad_recv_wc, IB_MGMT_RMPP_STATUS_UNV);
+ nack_recv(agent, mad_recv_wc, IB_MGMT_RMPP_STATUS_UNV);
+ goto out;
+ }
+
+ switch (rmpp_mad->rmpp_hdr.rmpp_type) {
+ case IB_MGMT_RMPP_TYPE_DATA:
+ return process_rmpp_data(agent, mad_recv_wc);
+ case IB_MGMT_RMPP_TYPE_ACK:
+ process_rmpp_ack(agent, mad_recv_wc);
+ break;
+ case IB_MGMT_RMPP_TYPE_STOP:
+ process_rmpp_stop(agent, mad_recv_wc);
+ break;
+ case IB_MGMT_RMPP_TYPE_ABORT:
+ process_rmpp_abort(agent, mad_recv_wc);
+ break;
+ default:
+ abort_send(agent, mad_recv_wc, IB_MGMT_RMPP_STATUS_BADT);
+ nack_recv(agent, mad_recv_wc, IB_MGMT_RMPP_STATUS_BADT);
+ break;
+ }
+out:
+ ib_free_recv_mad(mad_recv_wc);
+ return NULL;
+}
+
+static int init_newwin(struct ib_mad_send_wr_private *mad_send_wr)
+{
+ struct ib_mad_agent_private *agent = mad_send_wr->mad_agent_priv;
+ struct ib_mad_hdr *mad_hdr = mad_send_wr->send_buf.mad;
+ struct mad_rmpp_recv *rmpp_recv;
+ struct ib_ah_attr ah_attr;
+ unsigned long flags;
+ int newwin = 1;
+
+ if (!(mad_hdr->method & IB_MGMT_METHOD_RESP))
+ goto out;
+
+ spin_lock_irqsave(&agent->lock, flags);
+ list_for_each_entry(rmpp_recv, &agent->rmpp_list, list) {
+ if (rmpp_recv->tid != mad_hdr->tid ||
+ rmpp_recv->mgmt_class != mad_hdr->mgmt_class ||
+ rmpp_recv->class_version != mad_hdr->class_version ||
+ (rmpp_recv->method & IB_MGMT_METHOD_RESP))
+ continue;
+
+ if (ib_query_ah(mad_send_wr->send_buf.ah, &ah_attr))
+ continue;
+
+ if (rmpp_recv->slid == ah_attr.dlid) {
+ newwin = rmpp_recv->repwin;
+ break;
+ }
+ }
+ spin_unlock_irqrestore(&agent->lock, flags);
+out:
+ return newwin;
+}
+
+int ib_send_rmpp_mad(struct ib_mad_send_wr_private *mad_send_wr)
+{
+ struct ib_rmpp_mad *rmpp_mad;
+ int ret;
+
+ rmpp_mad = mad_send_wr->send_buf.mad;
+ if (!(ib_get_rmpp_flags(&rmpp_mad->rmpp_hdr) &
+ IB_MGMT_RMPP_FLAG_ACTIVE))
+ return IB_RMPP_RESULT_UNHANDLED;
+
+ if (rmpp_mad->rmpp_hdr.rmpp_type != IB_MGMT_RMPP_TYPE_DATA) {
+ mad_send_wr->seg_num = 1;
+ return IB_RMPP_RESULT_INTERNAL;
+ }
+
+ mad_send_wr->newwin = init_newwin(mad_send_wr);
+
+ /* We need to wait for the final ACK even if there isn't a response */
+ mad_send_wr->refcount += (mad_send_wr->timeout == 0);
+ ret = send_next_seg(mad_send_wr);
+ if (!ret)
+ return IB_RMPP_RESULT_CONSUMED;
+ return ret;
+}
+
+int ib_process_rmpp_send_wc(struct ib_mad_send_wr_private *mad_send_wr,
+ struct ib_mad_send_wc *mad_send_wc)
+{
+ struct ib_rmpp_mad *rmpp_mad;
+ int ret;
+
+ rmpp_mad = mad_send_wr->send_buf.mad;
+ if (!(ib_get_rmpp_flags(&rmpp_mad->rmpp_hdr) &
+ IB_MGMT_RMPP_FLAG_ACTIVE))
+ return IB_RMPP_RESULT_UNHANDLED; /* RMPP not active */
+
+ if (rmpp_mad->rmpp_hdr.rmpp_type != IB_MGMT_RMPP_TYPE_DATA)
+ return IB_RMPP_RESULT_INTERNAL; /* ACK, STOP, or ABORT */
+
+ if (mad_send_wc->status != IB_WC_SUCCESS ||
+ mad_send_wr->status != IB_WC_SUCCESS)
+ return IB_RMPP_RESULT_PROCESSED; /* Canceled or send error */
+
+ if (!mad_send_wr->timeout)
+ return IB_RMPP_RESULT_PROCESSED; /* Response received */
+
+ if (mad_send_wr->last_ack == mad_send_wr->send_buf.seg_count) {
+ mad_send_wr->timeout =
+ msecs_to_jiffies(mad_send_wr->send_buf.timeout_ms);
+ return IB_RMPP_RESULT_PROCESSED; /* Send done */
+ }
+
+ if (mad_send_wr->seg_num == mad_send_wr->newwin ||
+ mad_send_wr->seg_num == mad_send_wr->send_buf.seg_count)
+ return IB_RMPP_RESULT_PROCESSED; /* Wait for ACK */
+
+ ret = send_next_seg(mad_send_wr);
+ if (ret) {
+ mad_send_wc->status = IB_WC_GENERAL_ERR;
+ return IB_RMPP_RESULT_PROCESSED;
+ }
+ return IB_RMPP_RESULT_CONSUMED;
+}
+
+int ib_retry_rmpp(struct ib_mad_send_wr_private *mad_send_wr)
+{
+ struct ib_rmpp_mad *rmpp_mad;
+ int ret;
+
+ rmpp_mad = mad_send_wr->send_buf.mad;
+ if (!(ib_get_rmpp_flags(&rmpp_mad->rmpp_hdr) &
+ IB_MGMT_RMPP_FLAG_ACTIVE))
+ return IB_RMPP_RESULT_UNHANDLED; /* RMPP not active */
+
+ if (mad_send_wr->last_ack == mad_send_wr->send_buf.seg_count)
+ return IB_RMPP_RESULT_PROCESSED;
+
+ mad_send_wr->seg_num = mad_send_wr->last_ack;
+ mad_send_wr->cur_seg = mad_send_wr->last_ack_seg;
+
+ ret = send_next_seg(mad_send_wr);
+ if (ret)
+ return IB_RMPP_RESULT_PROCESSED;
+
+ return IB_RMPP_RESULT_CONSUMED;
+}
diff --git a/sys/ofed/drivers/infiniband/core/ib_multicast.c b/sys/ofed/drivers/infiniband/core/ib_multicast.c
new file mode 100644
index 0000000..1fa90d4
--- /dev/null
+++ b/sys/ofed/drivers/infiniband/core/ib_multicast.c
@@ -0,0 +1,900 @@
+/*
+ * Copyright (c) 2006 Intel Corporation. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#define LINUXKPI_PARAM_PREFIX ibcore_
+
+#include <linux/completion.h>
+#include <linux/dma-mapping.h>
+#include <linux/err.h>
+#include <linux/interrupt.h>
+#include <linux/slab.h>
+#include <linux/bitops.h>
+#include <linux/random.h>
+#include <linux/rbtree.h>
+
+#include <rdma/ib_cache.h>
+#include "sa.h"
+
+static void mcast_add_one(struct ib_device *device);
+static void mcast_remove_one(struct ib_device *device, void *client_data);
+
+static struct ib_client mcast_client = {
+ .name = "ib_multicast",
+ .add = mcast_add_one,
+ .remove = mcast_remove_one
+};
+
+static struct ib_sa_client sa_client;
+static struct workqueue_struct *mcast_wq;
+static union ib_gid mgid0;
+
+struct mcast_device;
+
+struct mcast_port {
+ struct mcast_device *dev;
+ spinlock_t lock;
+ struct rb_root table;
+ atomic_t refcount;
+ struct completion comp;
+ u8 port_num;
+};
+
+struct mcast_device {
+ struct ib_device *device;
+ struct ib_event_handler event_handler;
+ int start_port;
+ int end_port;
+ struct mcast_port port[0];
+};
+
+enum mcast_state {
+ MCAST_JOINING,
+ MCAST_MEMBER,
+ MCAST_ERROR,
+};
+
+enum mcast_group_state {
+ MCAST_IDLE,
+ MCAST_BUSY,
+ MCAST_GROUP_ERROR,
+ MCAST_PKEY_EVENT
+};
+
+enum {
+ MCAST_INVALID_PKEY_INDEX = 0xFFFF
+};
+
+struct mcast_member;
+
+struct mcast_group {
+ struct ib_sa_mcmember_rec rec;
+ struct rb_node node;
+ struct mcast_port *port;
+ spinlock_t lock;
+ struct work_struct work;
+ struct list_head pending_list;
+ struct list_head active_list;
+ struct mcast_member *last_join;
+ int members[NUM_JOIN_MEMBERSHIP_TYPES];
+ atomic_t refcount;
+ enum mcast_group_state state;
+ struct ib_sa_query *query;
+ u16 pkey_index;
+ u8 leave_state;
+ int retries;
+};
+
+struct mcast_member {
+ struct ib_sa_multicast multicast;
+ struct ib_sa_client *client;
+ struct mcast_group *group;
+ struct list_head list;
+ enum mcast_state state;
+ atomic_t refcount;
+ struct completion comp;
+};
+
+static void join_handler(int status, struct ib_sa_mcmember_rec *rec,
+ void *context);
+static void leave_handler(int status, struct ib_sa_mcmember_rec *rec,
+ void *context);
+
+static struct mcast_group *mcast_find(struct mcast_port *port,
+ union ib_gid *mgid)
+{
+ struct rb_node *node = port->table.rb_node;
+ struct mcast_group *group;
+ int ret;
+
+ while (node) {
+ group = rb_entry(node, struct mcast_group, node);
+ ret = memcmp(mgid->raw, group->rec.mgid.raw, sizeof *mgid);
+ if (!ret)
+ return group;
+
+ if (ret < 0)
+ node = node->rb_left;
+ else
+ node = node->rb_right;
+ }
+ return NULL;
+}
+
+static struct mcast_group *mcast_insert(struct mcast_port *port,
+ struct mcast_group *group,
+ int allow_duplicates)
+{
+ struct rb_node **link = &port->table.rb_node;
+ struct rb_node *parent = NULL;
+ struct mcast_group *cur_group;
+ int ret;
+
+ while (*link) {
+ parent = *link;
+ cur_group = rb_entry(parent, struct mcast_group, node);
+
+ ret = memcmp(group->rec.mgid.raw, cur_group->rec.mgid.raw,
+ sizeof group->rec.mgid);
+ if (ret < 0)
+ link = &(*link)->rb_left;
+ else if (ret > 0)
+ link = &(*link)->rb_right;
+ else if (allow_duplicates)
+ link = &(*link)->rb_left;
+ else
+ return cur_group;
+ }
+ rb_link_node(&group->node, parent, link);
+ rb_insert_color(&group->node, &port->table);
+ return NULL;
+}
+
+static void deref_port(struct mcast_port *port)
+{
+ if (atomic_dec_and_test(&port->refcount))
+ complete(&port->comp);
+}
+
+static void release_group(struct mcast_group *group)
+{
+ struct mcast_port *port = group->port;
+ unsigned long flags;
+
+ spin_lock_irqsave(&port->lock, flags);
+ if (atomic_dec_and_test(&group->refcount)) {
+ rb_erase(&group->node, &port->table);
+ spin_unlock_irqrestore(&port->lock, flags);
+ kfree(group);
+ deref_port(port);
+ } else
+ spin_unlock_irqrestore(&port->lock, flags);
+}
+
+static void deref_member(struct mcast_member *member)
+{
+ if (atomic_dec_and_test(&member->refcount))
+ complete(&member->comp);
+}
+
+static void queue_join(struct mcast_member *member)
+{
+ struct mcast_group *group = member->group;
+ unsigned long flags;
+
+ spin_lock_irqsave(&group->lock, flags);
+ list_add_tail(&member->list, &group->pending_list);
+ if (group->state == MCAST_IDLE) {
+ group->state = MCAST_BUSY;
+ atomic_inc(&group->refcount);
+ queue_work(mcast_wq, &group->work);
+ }
+ spin_unlock_irqrestore(&group->lock, flags);
+}
+
+/*
+ * A multicast group has four types of members: full member, non member,
+ * sendonly non member and sendonly full member.
+ * We need to keep track of the number of members of each
+ * type based on their join state. Adjust the number of members the belong to
+ * the specified join states.
+ */
+static void adjust_membership(struct mcast_group *group, u8 join_state, int inc)
+{
+ int i;
+
+ for (i = 0; i < NUM_JOIN_MEMBERSHIP_TYPES; i++, join_state >>= 1)
+ if (join_state & 0x1)
+ group->members[i] += inc;
+}
+
+/*
+ * If a multicast group has zero members left for a particular join state, but
+ * the group is still a member with the SA, we need to leave that join state.
+ * Determine which join states we still belong to, but that do not have any
+ * active members.
+ */
+static u8 get_leave_state(struct mcast_group *group)
+{
+ u8 leave_state = 0;
+ int i;
+
+ for (i = 0; i < NUM_JOIN_MEMBERSHIP_TYPES; i++)
+ if (!group->members[i])
+ leave_state |= (0x1 << i);
+
+ return leave_state & group->rec.join_state;
+}
+
+static int check_selector(ib_sa_comp_mask comp_mask,
+ ib_sa_comp_mask selector_mask,
+ ib_sa_comp_mask value_mask,
+ u8 selector, u8 src_value, u8 dst_value)
+{
+ int err;
+
+ if (!(comp_mask & selector_mask) || !(comp_mask & value_mask))
+ return 0;
+
+ switch (selector) {
+ case IB_SA_GT:
+ err = (src_value <= dst_value);
+ break;
+ case IB_SA_LT:
+ err = (src_value >= dst_value);
+ break;
+ case IB_SA_EQ:
+ err = (src_value != dst_value);
+ break;
+ default:
+ err = 0;
+ break;
+ }
+
+ return err;
+}
+
+static int cmp_rec(struct ib_sa_mcmember_rec *src,
+ struct ib_sa_mcmember_rec *dst, ib_sa_comp_mask comp_mask)
+{
+ /* MGID must already match */
+
+ if (comp_mask & IB_SA_MCMEMBER_REC_PORT_GID &&
+ memcmp(&src->port_gid, &dst->port_gid, sizeof src->port_gid))
+ return -EINVAL;
+ if (comp_mask & IB_SA_MCMEMBER_REC_QKEY && src->qkey != dst->qkey)
+ return -EINVAL;
+ if (comp_mask & IB_SA_MCMEMBER_REC_MLID && src->mlid != dst->mlid)
+ return -EINVAL;
+ if (check_selector(comp_mask, IB_SA_MCMEMBER_REC_MTU_SELECTOR,
+ IB_SA_MCMEMBER_REC_MTU, dst->mtu_selector,
+ src->mtu, dst->mtu))
+ return -EINVAL;
+ if (comp_mask & IB_SA_MCMEMBER_REC_TRAFFIC_CLASS &&
+ src->traffic_class != dst->traffic_class)
+ return -EINVAL;
+ if (comp_mask & IB_SA_MCMEMBER_REC_PKEY && src->pkey != dst->pkey)
+ return -EINVAL;
+ if (check_selector(comp_mask, IB_SA_MCMEMBER_REC_RATE_SELECTOR,
+ IB_SA_MCMEMBER_REC_RATE, dst->rate_selector,
+ src->rate, dst->rate))
+ return -EINVAL;
+ if (check_selector(comp_mask,
+ IB_SA_MCMEMBER_REC_PACKET_LIFE_TIME_SELECTOR,
+ IB_SA_MCMEMBER_REC_PACKET_LIFE_TIME,
+ dst->packet_life_time_selector,
+ src->packet_life_time, dst->packet_life_time))
+ return -EINVAL;
+ if (comp_mask & IB_SA_MCMEMBER_REC_SL && src->sl != dst->sl)
+ return -EINVAL;
+ if (comp_mask & IB_SA_MCMEMBER_REC_FLOW_LABEL &&
+ src->flow_label != dst->flow_label)
+ return -EINVAL;
+ if (comp_mask & IB_SA_MCMEMBER_REC_HOP_LIMIT &&
+ src->hop_limit != dst->hop_limit)
+ return -EINVAL;
+ if (comp_mask & IB_SA_MCMEMBER_REC_SCOPE && src->scope != dst->scope)
+ return -EINVAL;
+
+ /* join_state checked separately, proxy_join ignored */
+
+ return 0;
+}
+
+static int send_join(struct mcast_group *group, struct mcast_member *member)
+{
+ struct mcast_port *port = group->port;
+ int ret;
+
+ group->last_join = member;
+ ret = ib_sa_mcmember_rec_query(&sa_client, port->dev->device,
+ port->port_num, IB_MGMT_METHOD_SET,
+ &member->multicast.rec,
+ member->multicast.comp_mask,
+ 3000, GFP_KERNEL, join_handler, group,
+ &group->query);
+ return (ret > 0) ? 0 : ret;
+}
+
+static int send_leave(struct mcast_group *group, u8 leave_state)
+{
+ struct mcast_port *port = group->port;
+ struct ib_sa_mcmember_rec rec;
+ int ret;
+
+ rec = group->rec;
+ rec.join_state = leave_state;
+ group->leave_state = leave_state;
+
+ ret = ib_sa_mcmember_rec_query(&sa_client, port->dev->device,
+ port->port_num, IB_SA_METHOD_DELETE, &rec,
+ IB_SA_MCMEMBER_REC_MGID |
+ IB_SA_MCMEMBER_REC_PORT_GID |
+ IB_SA_MCMEMBER_REC_JOIN_STATE,
+ 3000, GFP_KERNEL, leave_handler,
+ group, &group->query);
+ return (ret > 0) ? 0 : ret;
+}
+
+static void join_group(struct mcast_group *group, struct mcast_member *member,
+ u8 join_state)
+{
+ member->state = MCAST_MEMBER;
+ adjust_membership(group, join_state, 1);
+ group->rec.join_state |= join_state;
+ member->multicast.rec = group->rec;
+ member->multicast.rec.join_state = join_state;
+ list_move(&member->list, &group->active_list);
+}
+
+static int fail_join(struct mcast_group *group, struct mcast_member *member,
+ int status)
+{
+ spin_lock_irq(&group->lock);
+ list_del_init(&member->list);
+ spin_unlock_irq(&group->lock);
+ return member->multicast.callback(status, &member->multicast);
+}
+
+static void process_group_error(struct mcast_group *group)
+{
+ struct mcast_member *member;
+ int ret = 0;
+ u16 pkey_index;
+
+ if (group->state == MCAST_PKEY_EVENT)
+ ret = ib_find_pkey(group->port->dev->device,
+ group->port->port_num,
+ be16_to_cpu(group->rec.pkey), &pkey_index);
+
+ spin_lock_irq(&group->lock);
+ if (group->state == MCAST_PKEY_EVENT && !ret &&
+ group->pkey_index == pkey_index)
+ goto out;
+
+ while (!list_empty(&group->active_list)) {
+ member = list_entry(group->active_list.next,
+ struct mcast_member, list);
+ atomic_inc(&member->refcount);
+ list_del_init(&member->list);
+ adjust_membership(group, member->multicast.rec.join_state, -1);
+ member->state = MCAST_ERROR;
+ spin_unlock_irq(&group->lock);
+
+ ret = member->multicast.callback(-ENETRESET,
+ &member->multicast);
+ deref_member(member);
+ if (ret)
+ ib_sa_free_multicast(&member->multicast);
+ spin_lock_irq(&group->lock);
+ }
+
+ group->rec.join_state = 0;
+out:
+ group->state = MCAST_BUSY;
+ spin_unlock_irq(&group->lock);
+}
+
+static void mcast_work_handler(struct work_struct *work)
+{
+ struct mcast_group *group;
+ struct mcast_member *member;
+ struct ib_sa_multicast *multicast;
+ int status, ret;
+ u8 join_state;
+
+ group = container_of(work, typeof(*group), work);
+retest:
+ spin_lock_irq(&group->lock);
+ while (!list_empty(&group->pending_list) ||
+ (group->state != MCAST_BUSY)) {
+
+ if (group->state != MCAST_BUSY) {
+ spin_unlock_irq(&group->lock);
+ process_group_error(group);
+ goto retest;
+ }
+
+ member = list_entry(group->pending_list.next,
+ struct mcast_member, list);
+ multicast = &member->multicast;
+ join_state = multicast->rec.join_state;
+ atomic_inc(&member->refcount);
+
+ if (join_state == (group->rec.join_state & join_state)) {
+ status = cmp_rec(&group->rec, &multicast->rec,
+ multicast->comp_mask);
+ if (!status)
+ join_group(group, member, join_state);
+ else
+ list_del_init(&member->list);
+ spin_unlock_irq(&group->lock);
+ ret = multicast->callback(status, multicast);
+ } else {
+ spin_unlock_irq(&group->lock);
+ status = send_join(group, member);
+ if (!status) {
+ deref_member(member);
+ return;
+ }
+ ret = fail_join(group, member, status);
+ }
+
+ deref_member(member);
+ if (ret)
+ ib_sa_free_multicast(&member->multicast);
+ spin_lock_irq(&group->lock);
+ }
+
+ join_state = get_leave_state(group);
+ if (join_state) {
+ group->rec.join_state &= ~join_state;
+ spin_unlock_irq(&group->lock);
+ if (send_leave(group, join_state))
+ goto retest;
+ } else {
+ group->state = MCAST_IDLE;
+ spin_unlock_irq(&group->lock);
+ release_group(group);
+ }
+}
+
+/*
+ * Fail a join request if it is still active - at the head of the pending queue.
+ */
+static void process_join_error(struct mcast_group *group, int status)
+{
+ struct mcast_member *member;
+ int ret;
+
+ spin_lock_irq(&group->lock);
+ member = list_entry(group->pending_list.next,
+ struct mcast_member, list);
+ if (group->last_join == member) {
+ atomic_inc(&member->refcount);
+ list_del_init(&member->list);
+ spin_unlock_irq(&group->lock);
+ ret = member->multicast.callback(status, &member->multicast);
+ deref_member(member);
+ if (ret)
+ ib_sa_free_multicast(&member->multicast);
+ } else
+ spin_unlock_irq(&group->lock);
+}
+
+static void join_handler(int status, struct ib_sa_mcmember_rec *rec,
+ void *context)
+{
+ struct mcast_group *group = context;
+ u16 pkey_index = MCAST_INVALID_PKEY_INDEX;
+
+ if (status)
+ process_join_error(group, status);
+ else {
+ int mgids_changed, is_mgid0;
+ ib_find_pkey(group->port->dev->device, group->port->port_num,
+ be16_to_cpu(rec->pkey), &pkey_index);
+
+ spin_lock_irq(&group->port->lock);
+ if (group->state == MCAST_BUSY &&
+ group->pkey_index == MCAST_INVALID_PKEY_INDEX)
+ group->pkey_index = pkey_index;
+ mgids_changed = memcmp(&rec->mgid, &group->rec.mgid,
+ sizeof(group->rec.mgid));
+ group->rec = *rec;
+ if (mgids_changed) {
+ rb_erase(&group->node, &group->port->table);
+ is_mgid0 = !memcmp(&mgid0, &group->rec.mgid,
+ sizeof(mgid0));
+ mcast_insert(group->port, group, is_mgid0);
+ }
+ spin_unlock_irq(&group->port->lock);
+ }
+ mcast_work_handler(&group->work);
+}
+
+static void leave_handler(int status, struct ib_sa_mcmember_rec *rec,
+ void *context)
+{
+ struct mcast_group *group = context;
+
+ if (status && group->retries > 0 &&
+ !send_leave(group, group->leave_state))
+ group->retries--;
+ else
+ mcast_work_handler(&group->work);
+}
+
+static struct mcast_group *acquire_group(struct mcast_port *port,
+ union ib_gid *mgid, gfp_t gfp_mask)
+{
+ struct mcast_group *group, *cur_group;
+ unsigned long flags;
+ int is_mgid0;
+
+ is_mgid0 = !memcmp(&mgid0, mgid, sizeof mgid0);
+ if (!is_mgid0) {
+ spin_lock_irqsave(&port->lock, flags);
+ group = mcast_find(port, mgid);
+ if (group)
+ goto found;
+ spin_unlock_irqrestore(&port->lock, flags);
+ }
+
+ group = kzalloc(sizeof *group, gfp_mask);
+ if (!group)
+ return NULL;
+
+ group->retries = 3;
+ group->port = port;
+ group->rec.mgid = *mgid;
+ group->pkey_index = MCAST_INVALID_PKEY_INDEX;
+ INIT_LIST_HEAD(&group->pending_list);
+ INIT_LIST_HEAD(&group->active_list);
+ INIT_WORK(&group->work, mcast_work_handler);
+ spin_lock_init(&group->lock);
+
+ spin_lock_irqsave(&port->lock, flags);
+ cur_group = mcast_insert(port, group, is_mgid0);
+ if (cur_group) {
+ kfree(group);
+ group = cur_group;
+ } else
+ atomic_inc(&port->refcount);
+found:
+ atomic_inc(&group->refcount);
+ spin_unlock_irqrestore(&port->lock, flags);
+ return group;
+}
+
+/*
+ * We serialize all join requests to a single group to make our lives much
+ * easier. Otherwise, two users could try to join the same group
+ * simultaneously, with different configurations, one could leave while the
+ * join is in progress, etc., which makes locking around error recovery
+ * difficult.
+ */
+struct ib_sa_multicast *
+ib_sa_join_multicast(struct ib_sa_client *client,
+ struct ib_device *device, u8 port_num,
+ struct ib_sa_mcmember_rec *rec,
+ ib_sa_comp_mask comp_mask, gfp_t gfp_mask,
+ int (*callback)(int status,
+ struct ib_sa_multicast *multicast),
+ void *context)
+{
+ struct mcast_device *dev;
+ struct mcast_member *member;
+ struct ib_sa_multicast *multicast;
+ int ret;
+
+ dev = ib_get_client_data(device, &mcast_client);
+ if (!dev)
+ return ERR_PTR(-ENODEV);
+
+ member = kmalloc(sizeof *member, gfp_mask);
+ if (!member)
+ return ERR_PTR(-ENOMEM);
+
+ ib_sa_client_get(client);
+ member->client = client;
+ member->multicast.rec = *rec;
+ member->multicast.comp_mask = comp_mask;
+ member->multicast.callback = callback;
+ member->multicast.context = context;
+ init_completion(&member->comp);
+ atomic_set(&member->refcount, 1);
+ member->state = MCAST_JOINING;
+
+ member->group = acquire_group(&dev->port[port_num - dev->start_port],
+ &rec->mgid, gfp_mask);
+ if (!member->group) {
+ ret = -ENOMEM;
+ goto err;
+ }
+
+ /*
+ * The user will get the multicast structure in their callback. They
+ * could then free the multicast structure before we can return from
+ * this routine. So we save the pointer to return before queuing
+ * any callback.
+ */
+ multicast = &member->multicast;
+ queue_join(member);
+ return multicast;
+
+err:
+ ib_sa_client_put(client);
+ kfree(member);
+ return ERR_PTR(ret);
+}
+EXPORT_SYMBOL(ib_sa_join_multicast);
+
+void ib_sa_free_multicast(struct ib_sa_multicast *multicast)
+{
+ struct mcast_member *member;
+ struct mcast_group *group;
+
+ member = container_of(multicast, struct mcast_member, multicast);
+ group = member->group;
+
+ spin_lock_irq(&group->lock);
+ if (member->state == MCAST_MEMBER)
+ adjust_membership(group, multicast->rec.join_state, -1);
+
+ list_del_init(&member->list);
+
+ if (group->state == MCAST_IDLE) {
+ group->state = MCAST_BUSY;
+ spin_unlock_irq(&group->lock);
+ /* Continue to hold reference on group until callback */
+ queue_work(mcast_wq, &group->work);
+ } else {
+ spin_unlock_irq(&group->lock);
+ release_group(group);
+ }
+
+ deref_member(member);
+ wait_for_completion(&member->comp);
+ ib_sa_client_put(member->client);
+ kfree(member);
+}
+EXPORT_SYMBOL(ib_sa_free_multicast);
+
+int ib_sa_get_mcmember_rec(struct ib_device *device, u8 port_num,
+ union ib_gid *mgid, struct ib_sa_mcmember_rec *rec)
+{
+ struct mcast_device *dev;
+ struct mcast_port *port;
+ struct mcast_group *group;
+ unsigned long flags;
+ int ret = 0;
+
+ dev = ib_get_client_data(device, &mcast_client);
+ if (!dev)
+ return -ENODEV;
+
+ port = &dev->port[port_num - dev->start_port];
+ spin_lock_irqsave(&port->lock, flags);
+ group = mcast_find(port, mgid);
+ if (group)
+ *rec = group->rec;
+ else
+ ret = -EADDRNOTAVAIL;
+ spin_unlock_irqrestore(&port->lock, flags);
+
+ return ret;
+}
+EXPORT_SYMBOL(ib_sa_get_mcmember_rec);
+
+int ib_init_ah_from_mcmember(struct ib_device *device, u8 port_num,
+ struct ib_sa_mcmember_rec *rec,
+ struct net_device *ndev,
+ enum ib_gid_type gid_type,
+ struct ib_ah_attr *ah_attr)
+{
+ int ret;
+ u16 gid_index;
+ u8 p;
+
+ if (rdma_protocol_roce(device, port_num)) {
+ ret = ib_find_cached_gid_by_port(device, &rec->port_gid,
+ gid_type, port_num,
+ ndev,
+ &gid_index);
+ } else if (rdma_protocol_ib(device, port_num)) {
+ ret = ib_find_cached_gid(device, &rec->port_gid,
+ IB_GID_TYPE_IB, NULL, &p,
+ &gid_index);
+ } else {
+ ret = -EINVAL;
+ }
+
+ if (ret)
+ return ret;
+
+ memset(ah_attr, 0, sizeof *ah_attr);
+ ah_attr->dlid = be16_to_cpu(rec->mlid);
+ ah_attr->sl = rec->sl;
+ ah_attr->port_num = port_num;
+ ah_attr->static_rate = rec->rate;
+
+ ah_attr->ah_flags = IB_AH_GRH;
+ ah_attr->grh.dgid = rec->mgid;
+
+ ah_attr->grh.sgid_index = (u8) gid_index;
+ ah_attr->grh.flow_label = be32_to_cpu(rec->flow_label);
+ ah_attr->grh.hop_limit = rec->hop_limit;
+ ah_attr->grh.traffic_class = rec->traffic_class;
+
+ return 0;
+}
+EXPORT_SYMBOL(ib_init_ah_from_mcmember);
+
+static void mcast_groups_event(struct mcast_port *port,
+ enum mcast_group_state state)
+{
+ struct mcast_group *group;
+ struct rb_node *node;
+ unsigned long flags;
+
+ spin_lock_irqsave(&port->lock, flags);
+ for (node = rb_first(&port->table); node; node = rb_next(node)) {
+ group = rb_entry(node, struct mcast_group, node);
+ spin_lock(&group->lock);
+ if (group->state == MCAST_IDLE) {
+ atomic_inc(&group->refcount);
+ queue_work(mcast_wq, &group->work);
+ }
+ if (group->state != MCAST_GROUP_ERROR)
+ group->state = state;
+ spin_unlock(&group->lock);
+ }
+ spin_unlock_irqrestore(&port->lock, flags);
+}
+
+static void mcast_event_handler(struct ib_event_handler *handler,
+ struct ib_event *event)
+{
+ struct mcast_device *dev;
+ int index;
+
+ dev = container_of(handler, struct mcast_device, event_handler);
+ if (!rdma_cap_ib_mcast(dev->device, event->element.port_num))
+ return;
+
+ index = event->element.port_num - dev->start_port;
+
+ switch (event->event) {
+ case IB_EVENT_PORT_ERR:
+ case IB_EVENT_LID_CHANGE:
+ case IB_EVENT_SM_CHANGE:
+ case IB_EVENT_CLIENT_REREGISTER:
+ mcast_groups_event(&dev->port[index], MCAST_GROUP_ERROR);
+ break;
+ case IB_EVENT_PKEY_CHANGE:
+ mcast_groups_event(&dev->port[index], MCAST_PKEY_EVENT);
+ break;
+ default:
+ break;
+ }
+}
+
+static void mcast_add_one(struct ib_device *device)
+{
+ struct mcast_device *dev;
+ struct mcast_port *port;
+ int i;
+ int count = 0;
+
+ dev = kmalloc(sizeof *dev + device->phys_port_cnt * sizeof *port,
+ GFP_KERNEL);
+ if (!dev)
+ return;
+
+ dev->start_port = rdma_start_port(device);
+ dev->end_port = rdma_end_port(device);
+
+ for (i = 0; i <= dev->end_port - dev->start_port; i++) {
+ if (!rdma_cap_ib_mcast(device, dev->start_port + i))
+ continue;
+ port = &dev->port[i];
+ port->dev = dev;
+ port->port_num = dev->start_port + i;
+ spin_lock_init(&port->lock);
+ port->table = RB_ROOT;
+ init_completion(&port->comp);
+ atomic_set(&port->refcount, 1);
+ ++count;
+ }
+
+ if (!count) {
+ kfree(dev);
+ return;
+ }
+
+ dev->device = device;
+ ib_set_client_data(device, &mcast_client, dev);
+
+ INIT_IB_EVENT_HANDLER(&dev->event_handler, device, mcast_event_handler);
+ ib_register_event_handler(&dev->event_handler);
+}
+
+static void mcast_remove_one(struct ib_device *device, void *client_data)
+{
+ struct mcast_device *dev = client_data;
+ struct mcast_port *port;
+ int i;
+
+ if (!dev)
+ return;
+
+ ib_unregister_event_handler(&dev->event_handler);
+ flush_workqueue(mcast_wq);
+
+ for (i = 0; i <= dev->end_port - dev->start_port; i++) {
+ if (rdma_cap_ib_mcast(device, dev->start_port + i)) {
+ port = &dev->port[i];
+ deref_port(port);
+ wait_for_completion(&port->comp);
+ }
+ }
+
+ kfree(dev);
+}
+
+int mcast_init(void)
+{
+ int ret;
+
+ mcast_wq = alloc_ordered_workqueue("ib_mcast", WQ_MEM_RECLAIM);
+ if (!mcast_wq)
+ return -ENOMEM;
+
+ ib_sa_register_client(&sa_client);
+
+ ret = ib_register_client(&mcast_client);
+ if (ret)
+ goto err;
+ return 0;
+
+err:
+ ib_sa_unregister_client(&sa_client);
+ destroy_workqueue(mcast_wq);
+ return ret;
+}
+
+void mcast_cleanup(void)
+{
+ ib_unregister_client(&mcast_client);
+ ib_sa_unregister_client(&sa_client);
+ destroy_workqueue(mcast_wq);
+}
diff --git a/sys/ofed/drivers/infiniband/core/ib_packer.c b/sys/ofed/drivers/infiniband/core/ib_packer.c
new file mode 100644
index 0000000..31c566b
--- /dev/null
+++ b/sys/ofed/drivers/infiniband/core/ib_packer.c
@@ -0,0 +1,200 @@
+/*
+ * Copyright (c) 2004 Topspin Corporation. All rights reserved.
+ * Copyright (c) 2005 Sun Microsystems, Inc. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#include <linux/string.h>
+
+#include <rdma/ib_pack.h>
+
+static u64 value_read(int offset, int size, void *structure)
+{
+ switch (size) {
+ case 1: return *(u8 *) ((char *)structure + offset);
+ case 2: return be16_to_cpup((__be16 *) ((char *)structure + offset));
+ case 4: return be32_to_cpup((__be32 *) ((char *)structure + offset));
+ case 8: return be64_to_cpup((__be64 *) ((char *)structure + offset));
+ default:
+ pr_warn("Field size %d bits not handled\n", size * 8);
+ return 0;
+ }
+}
+
+/**
+ * ib_pack - Pack a structure into a buffer
+ * @desc:Array of structure field descriptions
+ * @desc_len:Number of entries in @desc
+ * @structure:Structure to pack from
+ * @buf:Buffer to pack into
+ *
+ * ib_pack() packs a list of structure fields into a buffer,
+ * controlled by the array of fields in @desc.
+ */
+void ib_pack(const struct ib_field *desc,
+ int desc_len,
+ void *structure,
+ void *buf)
+{
+ int i;
+
+ for (i = 0; i < desc_len; ++i) {
+ if (desc[i].size_bits <= 32) {
+ int shift;
+ u32 val;
+ __be32 mask;
+ __be32 *addr;
+
+ shift = 32 - desc[i].offset_bits - desc[i].size_bits;
+ if (desc[i].struct_size_bytes)
+ val = value_read(desc[i].struct_offset_bytes,
+ desc[i].struct_size_bytes,
+ structure) << shift;
+ else
+ val = 0;
+
+ mask = cpu_to_be32(((1ull << desc[i].size_bits) - 1) << shift);
+ addr = (__be32 *) buf + desc[i].offset_words;
+ *addr = (*addr & ~mask) | (cpu_to_be32(val) & mask);
+ } else if (desc[i].size_bits <= 64) {
+ int shift;
+ u64 val;
+ __be64 mask;
+ __be64 *addr;
+
+ shift = 64 - desc[i].offset_bits - desc[i].size_bits;
+ if (desc[i].struct_size_bytes)
+ val = value_read(desc[i].struct_offset_bytes,
+ desc[i].struct_size_bytes,
+ structure) << shift;
+ else
+ val = 0;
+
+ mask = cpu_to_be64((~0ull >> (64 - desc[i].size_bits)) << shift);
+ addr = (__be64 *) ((__be32 *) buf + desc[i].offset_words);
+ *addr = (*addr & ~mask) | (cpu_to_be64(val) & mask);
+ } else {
+ if (desc[i].offset_bits % 8 ||
+ desc[i].size_bits % 8) {
+ pr_warn("Structure field %s of size %d bits is not byte-aligned\n",
+ desc[i].field_name, desc[i].size_bits);
+ }
+
+ if (desc[i].struct_size_bytes)
+ memcpy((char *)buf + desc[i].offset_words * 4 +
+ desc[i].offset_bits / 8,
+ (char *)structure + desc[i].struct_offset_bytes,
+ desc[i].size_bits / 8);
+ else
+ memset((char *)buf + desc[i].offset_words * 4 +
+ desc[i].offset_bits / 8,
+ 0,
+ desc[i].size_bits / 8);
+ }
+ }
+}
+EXPORT_SYMBOL(ib_pack);
+
+static void value_write(int offset, int size, u64 val, void *structure)
+{
+ switch (size * 8) {
+ case 8: *( u8 *) ((char *)structure + offset) = val; break;
+ case 16: *(__be16 *) ((char *)structure + offset) = cpu_to_be16(val); break;
+ case 32: *(__be32 *) ((char *)structure + offset) = cpu_to_be32(val); break;
+ case 64: *(__be64 *) ((char *)structure + offset) = cpu_to_be64(val); break;
+ default:
+ pr_warn("Field size %d bits not handled\n", size * 8);
+ }
+}
+
+/**
+ * ib_unpack - Unpack a buffer into a structure
+ * @desc:Array of structure field descriptions
+ * @desc_len:Number of entries in @desc
+ * @buf:Buffer to unpack from
+ * @structure:Structure to unpack into
+ *
+ * ib_pack() unpacks a list of structure fields from a buffer,
+ * controlled by the array of fields in @desc.
+ */
+void ib_unpack(const struct ib_field *desc,
+ int desc_len,
+ void *buf,
+ void *structure)
+{
+ int i;
+
+ for (i = 0; i < desc_len; ++i) {
+ if (!desc[i].struct_size_bytes)
+ continue;
+
+ if (desc[i].size_bits <= 32) {
+ int shift;
+ u32 val;
+ u32 mask;
+ __be32 *addr;
+
+ shift = 32 - desc[i].offset_bits - desc[i].size_bits;
+ mask = ((1ull << desc[i].size_bits) - 1) << shift;
+ addr = (__be32 *) buf + desc[i].offset_words;
+ val = (be32_to_cpup(addr) & mask) >> shift;
+ value_write(desc[i].struct_offset_bytes,
+ desc[i].struct_size_bytes,
+ val,
+ structure);
+ } else if (desc[i].size_bits <= 64) {
+ int shift;
+ u64 val;
+ u64 mask;
+ __be64 *addr;
+
+ shift = 64 - desc[i].offset_bits - desc[i].size_bits;
+ mask = (~0ull >> (64 - desc[i].size_bits)) << shift;
+ addr = (__be64 *) buf + desc[i].offset_words;
+ val = (be64_to_cpup(addr) & mask) >> shift;
+ value_write(desc[i].struct_offset_bytes,
+ desc[i].struct_size_bytes,
+ val,
+ structure);
+ } else {
+ if (desc[i].offset_bits % 8 ||
+ desc[i].size_bits % 8) {
+ pr_warn("Structure field %s of size %d bits is not byte-aligned\n",
+ desc[i].field_name, desc[i].size_bits);
+ }
+
+ memcpy((char *)structure + desc[i].struct_offset_bytes,
+ (char *)buf + desc[i].offset_words * 4 +
+ desc[i].offset_bits / 8,
+ desc[i].size_bits / 8);
+ }
+ }
+}
+EXPORT_SYMBOL(ib_unpack);
diff --git a/sys/ofed/drivers/infiniband/core/ib_roce_gid_mgmt.c b/sys/ofed/drivers/infiniband/core/ib_roce_gid_mgmt.c
new file mode 100644
index 0000000..0cfad3b
--- /dev/null
+++ b/sys/ofed/drivers/infiniband/core/ib_roce_gid_mgmt.c
@@ -0,0 +1,447 @@
+/*
+ * Copyright (c) 2015-2017, Mellanox Technologies inc. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#include "core_priv.h"
+
+#include <linux/in.h>
+#include <linux/in6.h>
+#include <linux/rcupdate.h>
+
+#include <rdma/ib_cache.h>
+#include <rdma/ib_addr.h>
+
+#include <netinet6/scope6_var.h>
+
+static struct workqueue_struct *roce_gid_mgmt_wq;
+
+enum gid_op_type {
+ GID_DEL = 0,
+ GID_ADD
+};
+
+struct roce_netdev_event_work {
+ struct work_struct work;
+ struct net_device *ndev;
+};
+
+struct roce_rescan_work {
+ struct work_struct work;
+ struct ib_device *ib_dev;
+};
+
+static const struct {
+ bool (*is_supported)(const struct ib_device *device, u8 port_num);
+ enum ib_gid_type gid_type;
+} PORT_CAP_TO_GID_TYPE[] = {
+ {rdma_protocol_roce_eth_encap, IB_GID_TYPE_ROCE},
+ {rdma_protocol_roce_udp_encap, IB_GID_TYPE_ROCE_UDP_ENCAP},
+};
+
+#define CAP_TO_GID_TABLE_SIZE ARRAY_SIZE(PORT_CAP_TO_GID_TYPE)
+
+unsigned long roce_gid_type_mask_support(struct ib_device *ib_dev, u8 port)
+{
+ int i;
+ unsigned int ret_flags = 0;
+
+ if (!rdma_protocol_roce(ib_dev, port))
+ return 1UL << IB_GID_TYPE_IB;
+
+ for (i = 0; i < CAP_TO_GID_TABLE_SIZE; i++)
+ if (PORT_CAP_TO_GID_TYPE[i].is_supported(ib_dev, port))
+ ret_flags |= 1UL << PORT_CAP_TO_GID_TYPE[i].gid_type;
+
+ return ret_flags;
+}
+EXPORT_SYMBOL(roce_gid_type_mask_support);
+
+static void update_gid(enum gid_op_type gid_op, struct ib_device *ib_dev,
+ u8 port, union ib_gid *gid, struct net_device *ndev)
+{
+ int i;
+ unsigned long gid_type_mask = roce_gid_type_mask_support(ib_dev, port);
+ struct ib_gid_attr gid_attr;
+
+ memset(&gid_attr, 0, sizeof(gid_attr));
+ gid_attr.ndev = ndev;
+
+ for (i = 0; i != IB_GID_TYPE_SIZE; i++) {
+ if ((1UL << i) & gid_type_mask) {
+ gid_attr.gid_type = i;
+ switch (gid_op) {
+ case GID_ADD:
+ ib_cache_gid_add(ib_dev, port,
+ gid, &gid_attr);
+ break;
+ case GID_DEL:
+ ib_cache_gid_del(ib_dev, port,
+ gid, &gid_attr);
+ break;
+ }
+ }
+ }
+}
+
+static int
+roce_gid_match_netdev(struct ib_device *ib_dev, u8 port,
+ struct net_device *idev, void *cookie)
+{
+ struct net_device *ndev = (struct net_device *)cookie;
+ if (idev == NULL)
+ return (0);
+ return (ndev == idev);
+}
+
+static int
+roce_gid_match_all(struct ib_device *ib_dev, u8 port,
+ struct net_device *idev, void *cookie)
+{
+ if (idev == NULL)
+ return (0);
+ return (1);
+}
+
+static int
+roce_gid_enum_netdev_default(struct ib_device *ib_dev,
+ u8 port, struct net_device *idev)
+{
+ unsigned long gid_type_mask;
+
+ gid_type_mask = roce_gid_type_mask_support(ib_dev, port);
+
+ ib_cache_gid_set_default_gid(ib_dev, port, idev, gid_type_mask,
+ IB_CACHE_GID_DEFAULT_MODE_SET);
+
+ return (hweight_long(gid_type_mask));
+}
+
+#define ETH_IPOIB_DRV_NAME "ib"
+
+static inline int
+is_eth_ipoib_intf(struct net_device *dev)
+{
+ if (strcmp(dev->if_dname, ETH_IPOIB_DRV_NAME))
+ return 0;
+ return 1;
+}
+
+static void
+roce_gid_update_addr_callback(struct ib_device *device, u8 port,
+ struct net_device *ndev, void *cookie)
+{
+ struct ipx_entry {
+ STAILQ_ENTRY(ipx_entry) entry;
+ union ipx_addr {
+ struct sockaddr sa[0];
+ struct sockaddr_in v4;
+ struct sockaddr_in6 v6;
+ } ipx_addr;
+ };
+ struct ipx_entry *entry;
+ struct net_device *idev;
+#if defined(INET) || defined(INET6)
+ struct ifaddr *ifa;
+#endif
+ union ib_gid gid;
+ int default_gids;
+ u16 index_num;
+ int i;
+
+ STAILQ_HEAD(, ipx_entry) ipx_head;
+
+ STAILQ_INIT(&ipx_head);
+
+ /* make sure default GIDs are in */
+ default_gids = roce_gid_enum_netdev_default(device, port, ndev);
+
+ CURVNET_SET(ndev->if_vnet);
+ IFNET_RLOCK();
+ TAILQ_FOREACH(idev, &V_ifnet, if_link) {
+ if (idev != ndev) {
+ if (idev->if_type != IFT_L2VLAN)
+ continue;
+ if (ndev != rdma_vlan_dev_real_dev(idev))
+ continue;
+ }
+
+ /* clone address information for IPv4 and IPv6 */
+ IF_ADDR_RLOCK(idev);
+#if defined(INET)
+ TAILQ_FOREACH(ifa, &idev->if_addrhead, ifa_link) {
+ if (ifa->ifa_addr == NULL ||
+ ifa->ifa_addr->sa_family != AF_INET)
+ continue;
+ entry = kzalloc(sizeof(*entry), GFP_ATOMIC);
+ if (entry == NULL) {
+ pr_warn("roce_gid_update_addr_callback: "
+ "couldn't allocate entry for IPv4 update\n");
+ continue;
+ }
+ entry->ipx_addr.v4 = *((struct sockaddr_in *)ifa->ifa_addr);
+ STAILQ_INSERT_TAIL(&ipx_head, entry, entry);
+ }
+#endif
+#if defined(INET6)
+ TAILQ_FOREACH(ifa, &idev->if_addrhead, ifa_link) {
+ if (ifa->ifa_addr == NULL ||
+ ifa->ifa_addr->sa_family != AF_INET6)
+ continue;
+ entry = kzalloc(sizeof(*entry), GFP_ATOMIC);
+ if (entry == NULL) {
+ pr_warn("roce_gid_update_addr_callback: "
+ "couldn't allocate entry for IPv6 update\n");
+ continue;
+ }
+ entry->ipx_addr.v6 = *((struct sockaddr_in6 *)ifa->ifa_addr);
+
+ /* trash IPv6 scope ID */
+ sa6_recoverscope(&entry->ipx_addr.v6);
+ entry->ipx_addr.v6.sin6_scope_id = 0;
+
+ STAILQ_INSERT_TAIL(&ipx_head, entry, entry);
+ }
+#endif
+ IF_ADDR_RUNLOCK(idev);
+ }
+ IFNET_RUNLOCK();
+ CURVNET_RESTORE();
+
+ /* add missing GIDs, if any */
+ STAILQ_FOREACH(entry, &ipx_head, entry) {
+ unsigned long gid_type_mask = roce_gid_type_mask_support(device, port);
+
+ if (rdma_ip2gid(&entry->ipx_addr.sa[0], &gid) != 0)
+ continue;
+
+ for (i = 0; i != IB_GID_TYPE_SIZE; i++) {
+ if (!((1UL << i) & gid_type_mask))
+ continue;
+ /* check if entry found */
+ if (ib_find_cached_gid_by_port(device, &gid, i,
+ port, ndev, &index_num) == 0)
+ break;
+ }
+ if (i != IB_GID_TYPE_SIZE)
+ continue;
+ /* add new GID */
+ update_gid(GID_ADD, device, port, &gid, ndev);
+ }
+
+ /* remove stale GIDs, if any */
+ for (i = default_gids; ib_get_cached_gid(device, port, i, &gid, NULL) == 0; i++) {
+ union ipx_addr ipx;
+
+ /* don't delete empty entries */
+ if (memcmp(&gid, &zgid, sizeof(zgid)) == 0)
+ continue;
+
+ /* zero default */
+ memset(&ipx, 0, sizeof(ipx));
+
+ rdma_gid2ip(&ipx.sa[0], &gid);
+
+ STAILQ_FOREACH(entry, &ipx_head, entry) {
+ if (memcmp(&entry->ipx_addr, &ipx, sizeof(ipx)) == 0)
+ break;
+ }
+ /* check if entry found */
+ if (entry != NULL)
+ continue;
+
+ /* remove GID */
+ update_gid(GID_DEL, device, port, &gid, ndev);
+ }
+
+ while ((entry = STAILQ_FIRST(&ipx_head))) {
+ STAILQ_REMOVE_HEAD(&ipx_head, entry);
+ kfree(entry);
+ }
+}
+
+static void
+roce_gid_queue_scan_event_handler(struct work_struct *_work)
+{
+ struct roce_netdev_event_work *work =
+ container_of(_work, struct roce_netdev_event_work, work);
+
+ ib_enum_all_roce_netdevs(roce_gid_match_netdev, work->ndev,
+ roce_gid_update_addr_callback, NULL);
+
+ dev_put(work->ndev);
+ kfree(work);
+}
+
+static void
+roce_gid_queue_scan_event(struct net_device *ndev)
+{
+ struct roce_netdev_event_work *work;
+
+retry:
+ if (is_eth_ipoib_intf(ndev))
+ return;
+
+ if (ndev->if_type != IFT_ETHER) {
+ if (ndev->if_type == IFT_L2VLAN) {
+ ndev = rdma_vlan_dev_real_dev(ndev);
+ if (ndev != NULL)
+ goto retry;
+ }
+ return;
+ }
+
+ work = kmalloc(sizeof(*work), GFP_ATOMIC);
+ if (!work) {
+ pr_warn("roce_gid_mgmt: Couldn't allocate work for addr_event\n");
+ return;
+ }
+
+ INIT_WORK(&work->work, roce_gid_queue_scan_event_handler);
+ dev_hold(ndev);
+
+ work->ndev = ndev;
+
+ queue_work(roce_gid_mgmt_wq, &work->work);
+}
+
+static void
+roce_gid_delete_all_event_handler(struct work_struct *_work)
+{
+ struct roce_netdev_event_work *work =
+ container_of(_work, struct roce_netdev_event_work, work);
+
+ ib_cache_gid_del_all_by_netdev(work->ndev);
+ dev_put(work->ndev);
+ kfree(work);
+}
+
+static void
+roce_gid_delete_all_event(struct net_device *ndev)
+{
+ struct roce_netdev_event_work *work;
+
+ work = kmalloc(sizeof(*work), GFP_ATOMIC);
+ if (!work) {
+ pr_warn("roce_gid_mgmt: Couldn't allocate work for addr_event\n");
+ return;
+ }
+
+ INIT_WORK(&work->work, roce_gid_delete_all_event_handler);
+ dev_hold(ndev);
+ work->ndev = ndev;
+ queue_work(roce_gid_mgmt_wq, &work->work);
+}
+
+static int
+inetaddr_event(struct notifier_block *this, unsigned long event, void *ptr)
+{
+ struct net_device *ndev = ptr;
+
+ switch (event) {
+ case NETDEV_UNREGISTER:
+ roce_gid_delete_all_event(ndev);
+ break;
+ case NETDEV_REGISTER:
+ case NETDEV_CHANGEADDR:
+ case NETDEV_CHANGEIFADDR:
+ roce_gid_queue_scan_event(ndev);
+ break;
+ default:
+ break;
+ }
+ return NOTIFY_DONE;
+}
+
+static struct notifier_block nb_inetaddr = {
+ .notifier_call = inetaddr_event
+};
+
+static void
+roce_rescan_device_handler(struct work_struct *_work)
+{
+ struct roce_rescan_work *work =
+ container_of(_work, struct roce_rescan_work, work);
+
+ ib_enum_roce_netdev(work->ib_dev, roce_gid_match_all, NULL,
+ roce_gid_update_addr_callback, NULL);
+ kfree(work);
+}
+
+/* Caller must flush system workqueue before removing the ib_device */
+int roce_rescan_device(struct ib_device *ib_dev)
+{
+ struct roce_rescan_work *work = kmalloc(sizeof(*work), GFP_KERNEL);
+
+ if (!work)
+ return -ENOMEM;
+
+ work->ib_dev = ib_dev;
+ INIT_WORK(&work->work, roce_rescan_device_handler);
+ queue_work(roce_gid_mgmt_wq, &work->work);
+
+ return 0;
+}
+
+int __init roce_gid_mgmt_init(void)
+{
+ roce_gid_mgmt_wq = alloc_ordered_workqueue("roce_gid_mgmt_wq", 0);
+ if (!roce_gid_mgmt_wq) {
+ pr_warn("roce_gid_mgmt: can't allocate work queue\n");
+ return -ENOMEM;
+ }
+
+ register_inetaddr_notifier(&nb_inetaddr);
+
+ /*
+ * We rely on the netdevice notifier to enumerate all existing
+ * devices in the system. Register to this notifier last to
+ * make sure we will not miss any IP add/del callbacks.
+ */
+ register_netdevice_notifier(&nb_inetaddr);
+
+ return 0;
+}
+
+void __exit roce_gid_mgmt_cleanup(void)
+{
+ unregister_inetaddr_notifier(&nb_inetaddr);
+ unregister_netdevice_notifier(&nb_inetaddr);
+
+ /*
+ * Ensure all gid deletion tasks complete before we go down,
+ * to avoid any reference to free'd memory. By the time
+ * ib-core is removed, all physical devices have been removed,
+ * so no issue with remaining hardware contexts.
+ */
+ synchronize_rcu();
+ drain_workqueue(roce_gid_mgmt_wq);
+ destroy_workqueue(roce_gid_mgmt_wq);
+}
diff --git a/sys/ofed/drivers/infiniband/core/ib_sa_query.c b/sys/ofed/drivers/infiniband/core/ib_sa_query.c
new file mode 100644
index 0000000..d818bad
--- /dev/null
+++ b/sys/ofed/drivers/infiniband/core/ib_sa_query.c
@@ -0,0 +1,1580 @@
+/*
+ * Copyright (c) 2004 Topspin Communications. All rights reserved.
+ * Copyright (c) 2005 Voltaire, Inc. All rights reserved.
+ * Copyright (c) 2006 Intel Corporation. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#include <linux/module.h>
+#include <linux/err.h>
+#include <linux/random.h>
+#include <linux/spinlock.h>
+#include <linux/slab.h>
+#include <linux/dma-mapping.h>
+#include <linux/kref.h>
+#include <linux/idr.h>
+#include <linux/workqueue.h>
+#include <linux/etherdevice.h>
+#include <rdma/ib_pack.h>
+#include <rdma/ib_cache.h>
+#include <rdma/ib_user_sa.h>
+#include <rdma/ib_marshall.h>
+#include <rdma/ib_addr.h>
+#include "sa.h"
+#include "core_priv.h"
+
+#define IB_SA_LOCAL_SVC_TIMEOUT_MIN 100
+#define IB_SA_LOCAL_SVC_TIMEOUT_DEFAULT 2000
+#define IB_SA_LOCAL_SVC_TIMEOUT_MAX 200000
+
+struct ib_sa_sm_ah {
+ struct ib_ah *ah;
+ struct kref ref;
+ u16 pkey_index;
+ u8 src_path_mask;
+};
+
+struct ib_sa_classport_cache {
+ bool valid;
+ struct ib_class_port_info data;
+};
+
+struct ib_sa_port {
+ struct ib_mad_agent *agent;
+ struct ib_sa_sm_ah *sm_ah;
+ struct work_struct update_task;
+ struct ib_sa_classport_cache classport_info;
+ spinlock_t classport_lock; /* protects class port info set */
+ spinlock_t ah_lock;
+ u8 port_num;
+};
+
+struct ib_sa_device {
+ int start_port, end_port;
+ struct ib_event_handler event_handler;
+ struct ib_sa_port port[0];
+};
+
+struct ib_sa_query {
+ void (*callback)(struct ib_sa_query *, int, struct ib_sa_mad *);
+ void (*release)(struct ib_sa_query *);
+ struct ib_sa_client *client;
+ struct ib_sa_port *port;
+ struct ib_mad_send_buf *mad_buf;
+ struct ib_sa_sm_ah *sm_ah;
+ int id;
+ u32 flags;
+ struct list_head list; /* Local svc request list */
+ u32 seq; /* Local svc request sequence number */
+ unsigned long timeout; /* Local svc timeout */
+ u8 path_use; /* How will the pathrecord be used */
+};
+
+#define IB_SA_ENABLE_LOCAL_SERVICE 0x00000001
+#define IB_SA_CANCEL 0x00000002
+
+struct ib_sa_service_query {
+ void (*callback)(int, struct ib_sa_service_rec *, void *);
+ void *context;
+ struct ib_sa_query sa_query;
+};
+
+struct ib_sa_path_query {
+ void (*callback)(int, struct ib_sa_path_rec *, void *);
+ void *context;
+ struct ib_sa_query sa_query;
+};
+
+struct ib_sa_guidinfo_query {
+ void (*callback)(int, struct ib_sa_guidinfo_rec *, void *);
+ void *context;
+ struct ib_sa_query sa_query;
+};
+
+struct ib_sa_classport_info_query {
+ void (*callback)(int, struct ib_class_port_info *, void *);
+ void *context;
+ struct ib_sa_query sa_query;
+};
+
+struct ib_sa_mcmember_query {
+ void (*callback)(int, struct ib_sa_mcmember_rec *, void *);
+ void *context;
+ struct ib_sa_query sa_query;
+};
+
+static void ib_sa_add_one(struct ib_device *device);
+static void ib_sa_remove_one(struct ib_device *device, void *client_data);
+
+static struct ib_client sa_client = {
+ .name = "sa",
+ .add = ib_sa_add_one,
+ .remove = ib_sa_remove_one
+};
+
+static DEFINE_SPINLOCK(idr_lock);
+static DEFINE_IDR(query_idr);
+
+static DEFINE_SPINLOCK(tid_lock);
+static u32 tid;
+
+#define PATH_REC_FIELD(field) \
+ .struct_offset_bytes = offsetof(struct ib_sa_path_rec, field), \
+ .struct_size_bytes = sizeof ((struct ib_sa_path_rec *) 0)->field, \
+ .field_name = "sa_path_rec:" #field
+
+static const struct ib_field path_rec_table[] = {
+ { PATH_REC_FIELD(service_id),
+ .offset_words = 0,
+ .offset_bits = 0,
+ .size_bits = 64 },
+ { PATH_REC_FIELD(dgid),
+ .offset_words = 2,
+ .offset_bits = 0,
+ .size_bits = 128 },
+ { PATH_REC_FIELD(sgid),
+ .offset_words = 6,
+ .offset_bits = 0,
+ .size_bits = 128 },
+ { PATH_REC_FIELD(dlid),
+ .offset_words = 10,
+ .offset_bits = 0,
+ .size_bits = 16 },
+ { PATH_REC_FIELD(slid),
+ .offset_words = 10,
+ .offset_bits = 16,
+ .size_bits = 16 },
+ { PATH_REC_FIELD(raw_traffic),
+ .offset_words = 11,
+ .offset_bits = 0,
+ .size_bits = 1 },
+ { RESERVED,
+ .offset_words = 11,
+ .offset_bits = 1,
+ .size_bits = 3 },
+ { PATH_REC_FIELD(flow_label),
+ .offset_words = 11,
+ .offset_bits = 4,
+ .size_bits = 20 },
+ { PATH_REC_FIELD(hop_limit),
+ .offset_words = 11,
+ .offset_bits = 24,
+ .size_bits = 8 },
+ { PATH_REC_FIELD(traffic_class),
+ .offset_words = 12,
+ .offset_bits = 0,
+ .size_bits = 8 },
+ { PATH_REC_FIELD(reversible),
+ .offset_words = 12,
+ .offset_bits = 8,
+ .size_bits = 1 },
+ { PATH_REC_FIELD(numb_path),
+ .offset_words = 12,
+ .offset_bits = 9,
+ .size_bits = 7 },
+ { PATH_REC_FIELD(pkey),
+ .offset_words = 12,
+ .offset_bits = 16,
+ .size_bits = 16 },
+ { PATH_REC_FIELD(qos_class),
+ .offset_words = 13,
+ .offset_bits = 0,
+ .size_bits = 12 },
+ { PATH_REC_FIELD(sl),
+ .offset_words = 13,
+ .offset_bits = 12,
+ .size_bits = 4 },
+ { PATH_REC_FIELD(mtu_selector),
+ .offset_words = 13,
+ .offset_bits = 16,
+ .size_bits = 2 },
+ { PATH_REC_FIELD(mtu),
+ .offset_words = 13,
+ .offset_bits = 18,
+ .size_bits = 6 },
+ { PATH_REC_FIELD(rate_selector),
+ .offset_words = 13,
+ .offset_bits = 24,
+ .size_bits = 2 },
+ { PATH_REC_FIELD(rate),
+ .offset_words = 13,
+ .offset_bits = 26,
+ .size_bits = 6 },
+ { PATH_REC_FIELD(packet_life_time_selector),
+ .offset_words = 14,
+ .offset_bits = 0,
+ .size_bits = 2 },
+ { PATH_REC_FIELD(packet_life_time),
+ .offset_words = 14,
+ .offset_bits = 2,
+ .size_bits = 6 },
+ { PATH_REC_FIELD(preference),
+ .offset_words = 14,
+ .offset_bits = 8,
+ .size_bits = 8 },
+ { RESERVED,
+ .offset_words = 14,
+ .offset_bits = 16,
+ .size_bits = 48 },
+};
+
+#define MCMEMBER_REC_FIELD(field) \
+ .struct_offset_bytes = offsetof(struct ib_sa_mcmember_rec, field), \
+ .struct_size_bytes = sizeof ((struct ib_sa_mcmember_rec *) 0)->field, \
+ .field_name = "sa_mcmember_rec:" #field
+
+static const struct ib_field mcmember_rec_table[] = {
+ { MCMEMBER_REC_FIELD(mgid),
+ .offset_words = 0,
+ .offset_bits = 0,
+ .size_bits = 128 },
+ { MCMEMBER_REC_FIELD(port_gid),
+ .offset_words = 4,
+ .offset_bits = 0,
+ .size_bits = 128 },
+ { MCMEMBER_REC_FIELD(qkey),
+ .offset_words = 8,
+ .offset_bits = 0,
+ .size_bits = 32 },
+ { MCMEMBER_REC_FIELD(mlid),
+ .offset_words = 9,
+ .offset_bits = 0,
+ .size_bits = 16 },
+ { MCMEMBER_REC_FIELD(mtu_selector),
+ .offset_words = 9,
+ .offset_bits = 16,
+ .size_bits = 2 },
+ { MCMEMBER_REC_FIELD(mtu),
+ .offset_words = 9,
+ .offset_bits = 18,
+ .size_bits = 6 },
+ { MCMEMBER_REC_FIELD(traffic_class),
+ .offset_words = 9,
+ .offset_bits = 24,
+ .size_bits = 8 },
+ { MCMEMBER_REC_FIELD(pkey),
+ .offset_words = 10,
+ .offset_bits = 0,
+ .size_bits = 16 },
+ { MCMEMBER_REC_FIELD(rate_selector),
+ .offset_words = 10,
+ .offset_bits = 16,
+ .size_bits = 2 },
+ { MCMEMBER_REC_FIELD(rate),
+ .offset_words = 10,
+ .offset_bits = 18,
+ .size_bits = 6 },
+ { MCMEMBER_REC_FIELD(packet_life_time_selector),
+ .offset_words = 10,
+ .offset_bits = 24,
+ .size_bits = 2 },
+ { MCMEMBER_REC_FIELD(packet_life_time),
+ .offset_words = 10,
+ .offset_bits = 26,
+ .size_bits = 6 },
+ { MCMEMBER_REC_FIELD(sl),
+ .offset_words = 11,
+ .offset_bits = 0,
+ .size_bits = 4 },
+ { MCMEMBER_REC_FIELD(flow_label),
+ .offset_words = 11,
+ .offset_bits = 4,
+ .size_bits = 20 },
+ { MCMEMBER_REC_FIELD(hop_limit),
+ .offset_words = 11,
+ .offset_bits = 24,
+ .size_bits = 8 },
+ { MCMEMBER_REC_FIELD(scope),
+ .offset_words = 12,
+ .offset_bits = 0,
+ .size_bits = 4 },
+ { MCMEMBER_REC_FIELD(join_state),
+ .offset_words = 12,
+ .offset_bits = 4,
+ .size_bits = 4 },
+ { MCMEMBER_REC_FIELD(proxy_join),
+ .offset_words = 12,
+ .offset_bits = 8,
+ .size_bits = 1 },
+ { RESERVED,
+ .offset_words = 12,
+ .offset_bits = 9,
+ .size_bits = 23 },
+};
+
+#define SERVICE_REC_FIELD(field) \
+ .struct_offset_bytes = offsetof(struct ib_sa_service_rec, field), \
+ .struct_size_bytes = sizeof ((struct ib_sa_service_rec *) 0)->field, \
+ .field_name = "sa_service_rec:" #field
+
+static const struct ib_field service_rec_table[] = {
+ { SERVICE_REC_FIELD(id),
+ .offset_words = 0,
+ .offset_bits = 0,
+ .size_bits = 64 },
+ { SERVICE_REC_FIELD(gid),
+ .offset_words = 2,
+ .offset_bits = 0,
+ .size_bits = 128 },
+ { SERVICE_REC_FIELD(pkey),
+ .offset_words = 6,
+ .offset_bits = 0,
+ .size_bits = 16 },
+ { SERVICE_REC_FIELD(lease),
+ .offset_words = 7,
+ .offset_bits = 0,
+ .size_bits = 32 },
+ { SERVICE_REC_FIELD(key),
+ .offset_words = 8,
+ .offset_bits = 0,
+ .size_bits = 128 },
+ { SERVICE_REC_FIELD(name),
+ .offset_words = 12,
+ .offset_bits = 0,
+ .size_bits = 64*8 },
+ { SERVICE_REC_FIELD(data8),
+ .offset_words = 28,
+ .offset_bits = 0,
+ .size_bits = 16*8 },
+ { SERVICE_REC_FIELD(data16),
+ .offset_words = 32,
+ .offset_bits = 0,
+ .size_bits = 8*16 },
+ { SERVICE_REC_FIELD(data32),
+ .offset_words = 36,
+ .offset_bits = 0,
+ .size_bits = 4*32 },
+ { SERVICE_REC_FIELD(data64),
+ .offset_words = 40,
+ .offset_bits = 0,
+ .size_bits = 2*64 },
+};
+
+#define CLASSPORTINFO_REC_FIELD(field) \
+ .struct_offset_bytes = offsetof(struct ib_class_port_info, field), \
+ .struct_size_bytes = sizeof((struct ib_class_port_info *)0)->field, \
+ .field_name = "ib_class_port_info:" #field
+
+static const struct ib_field classport_info_rec_table[] = {
+ { CLASSPORTINFO_REC_FIELD(base_version),
+ .offset_words = 0,
+ .offset_bits = 0,
+ .size_bits = 8 },
+ { CLASSPORTINFO_REC_FIELD(class_version),
+ .offset_words = 0,
+ .offset_bits = 8,
+ .size_bits = 8 },
+ { CLASSPORTINFO_REC_FIELD(capability_mask),
+ .offset_words = 0,
+ .offset_bits = 16,
+ .size_bits = 16 },
+ { CLASSPORTINFO_REC_FIELD(cap_mask2_resp_time),
+ .offset_words = 1,
+ .offset_bits = 0,
+ .size_bits = 32 },
+ { CLASSPORTINFO_REC_FIELD(redirect_gid),
+ .offset_words = 2,
+ .offset_bits = 0,
+ .size_bits = 128 },
+ { CLASSPORTINFO_REC_FIELD(redirect_tcslfl),
+ .offset_words = 6,
+ .offset_bits = 0,
+ .size_bits = 32 },
+ { CLASSPORTINFO_REC_FIELD(redirect_lid),
+ .offset_words = 7,
+ .offset_bits = 0,
+ .size_bits = 16 },
+ { CLASSPORTINFO_REC_FIELD(redirect_pkey),
+ .offset_words = 7,
+ .offset_bits = 16,
+ .size_bits = 16 },
+
+ { CLASSPORTINFO_REC_FIELD(redirect_qp),
+ .offset_words = 8,
+ .offset_bits = 0,
+ .size_bits = 32 },
+ { CLASSPORTINFO_REC_FIELD(redirect_qkey),
+ .offset_words = 9,
+ .offset_bits = 0,
+ .size_bits = 32 },
+
+ { CLASSPORTINFO_REC_FIELD(trap_gid),
+ .offset_words = 10,
+ .offset_bits = 0,
+ .size_bits = 128 },
+ { CLASSPORTINFO_REC_FIELD(trap_tcslfl),
+ .offset_words = 14,
+ .offset_bits = 0,
+ .size_bits = 32 },
+
+ { CLASSPORTINFO_REC_FIELD(trap_lid),
+ .offset_words = 15,
+ .offset_bits = 0,
+ .size_bits = 16 },
+ { CLASSPORTINFO_REC_FIELD(trap_pkey),
+ .offset_words = 15,
+ .offset_bits = 16,
+ .size_bits = 16 },
+
+ { CLASSPORTINFO_REC_FIELD(trap_hlqp),
+ .offset_words = 16,
+ .offset_bits = 0,
+ .size_bits = 32 },
+ { CLASSPORTINFO_REC_FIELD(trap_qkey),
+ .offset_words = 17,
+ .offset_bits = 0,
+ .size_bits = 32 },
+};
+
+#define GUIDINFO_REC_FIELD(field) \
+ .struct_offset_bytes = offsetof(struct ib_sa_guidinfo_rec, field), \
+ .struct_size_bytes = sizeof((struct ib_sa_guidinfo_rec *) 0)->field, \
+ .field_name = "sa_guidinfo_rec:" #field
+
+static const struct ib_field guidinfo_rec_table[] = {
+ { GUIDINFO_REC_FIELD(lid),
+ .offset_words = 0,
+ .offset_bits = 0,
+ .size_bits = 16 },
+ { GUIDINFO_REC_FIELD(block_num),
+ .offset_words = 0,
+ .offset_bits = 16,
+ .size_bits = 8 },
+ { GUIDINFO_REC_FIELD(res1),
+ .offset_words = 0,
+ .offset_bits = 24,
+ .size_bits = 8 },
+ { GUIDINFO_REC_FIELD(res2),
+ .offset_words = 1,
+ .offset_bits = 0,
+ .size_bits = 32 },
+ { GUIDINFO_REC_FIELD(guid_info_list),
+ .offset_words = 2,
+ .offset_bits = 0,
+ .size_bits = 512 },
+};
+
+static inline void ib_sa_disable_local_svc(struct ib_sa_query *query)
+{
+ query->flags &= ~IB_SA_ENABLE_LOCAL_SERVICE;
+}
+
+static void free_sm_ah(struct kref *kref)
+{
+ struct ib_sa_sm_ah *sm_ah = container_of(kref, struct ib_sa_sm_ah, ref);
+
+ ib_destroy_ah(sm_ah->ah);
+ kfree(sm_ah);
+}
+
+static void update_sm_ah(struct work_struct *work)
+{
+ struct ib_sa_port *port =
+ container_of(work, struct ib_sa_port, update_task);
+ struct ib_sa_sm_ah *new_ah;
+ struct ib_port_attr port_attr;
+ struct ib_ah_attr ah_attr;
+
+ if (ib_query_port(port->agent->device, port->port_num, &port_attr)) {
+ pr_warn("Couldn't query port\n");
+ return;
+ }
+
+ new_ah = kmalloc(sizeof *new_ah, GFP_KERNEL);
+ if (!new_ah) {
+ return;
+ }
+
+ kref_init(&new_ah->ref);
+ new_ah->src_path_mask = (1 << port_attr.lmc) - 1;
+
+ new_ah->pkey_index = 0;
+ if (ib_find_pkey(port->agent->device, port->port_num,
+ IB_DEFAULT_PKEY_FULL, &new_ah->pkey_index))
+ pr_err("Couldn't find index for default PKey\n");
+
+ memset(&ah_attr, 0, sizeof ah_attr);
+ ah_attr.dlid = port_attr.sm_lid;
+ ah_attr.sl = port_attr.sm_sl;
+ ah_attr.port_num = port->port_num;
+ if (port_attr.grh_required) {
+ ah_attr.ah_flags = IB_AH_GRH;
+ ah_attr.grh.dgid.global.subnet_prefix = cpu_to_be64(port_attr.subnet_prefix);
+ ah_attr.grh.dgid.global.interface_id = cpu_to_be64(IB_SA_WELL_KNOWN_GUID);
+ }
+
+ new_ah->ah = ib_create_ah(port->agent->qp->pd, &ah_attr);
+ if (IS_ERR(new_ah->ah)) {
+ pr_warn("Couldn't create new SM AH\n");
+ kfree(new_ah);
+ return;
+ }
+
+ spin_lock_irq(&port->ah_lock);
+ if (port->sm_ah)
+ kref_put(&port->sm_ah->ref, free_sm_ah);
+ port->sm_ah = new_ah;
+ spin_unlock_irq(&port->ah_lock);
+
+}
+
+static void ib_sa_event(struct ib_event_handler *handler, struct ib_event *event)
+{
+ if (event->event == IB_EVENT_PORT_ERR ||
+ event->event == IB_EVENT_PORT_ACTIVE ||
+ event->event == IB_EVENT_LID_CHANGE ||
+ event->event == IB_EVENT_PKEY_CHANGE ||
+ event->event == IB_EVENT_SM_CHANGE ||
+ event->event == IB_EVENT_CLIENT_REREGISTER) {
+ unsigned long flags;
+ struct ib_sa_device *sa_dev =
+ container_of(handler, typeof(*sa_dev), event_handler);
+ struct ib_sa_port *port =
+ &sa_dev->port[event->element.port_num - sa_dev->start_port];
+
+ if (!rdma_cap_ib_sa(handler->device, port->port_num))
+ return;
+
+ spin_lock_irqsave(&port->ah_lock, flags);
+ if (port->sm_ah)
+ kref_put(&port->sm_ah->ref, free_sm_ah);
+ port->sm_ah = NULL;
+ spin_unlock_irqrestore(&port->ah_lock, flags);
+
+ if (event->event == IB_EVENT_SM_CHANGE ||
+ event->event == IB_EVENT_CLIENT_REREGISTER ||
+ event->event == IB_EVENT_LID_CHANGE) {
+ spin_lock_irqsave(&port->classport_lock, flags);
+ port->classport_info.valid = false;
+ spin_unlock_irqrestore(&port->classport_lock, flags);
+ }
+ queue_work(ib_wq, &sa_dev->port[event->element.port_num -
+ sa_dev->start_port].update_task);
+ }
+}
+
+void ib_sa_register_client(struct ib_sa_client *client)
+{
+ atomic_set(&client->users, 1);
+ init_completion(&client->comp);
+}
+EXPORT_SYMBOL(ib_sa_register_client);
+
+void ib_sa_unregister_client(struct ib_sa_client *client)
+{
+ ib_sa_client_put(client);
+ wait_for_completion(&client->comp);
+}
+EXPORT_SYMBOL(ib_sa_unregister_client);
+
+/**
+ * ib_sa_cancel_query - try to cancel an SA query
+ * @id:ID of query to cancel
+ * @query:query pointer to cancel
+ *
+ * Try to cancel an SA query. If the id and query don't match up or
+ * the query has already completed, nothing is done. Otherwise the
+ * query is canceled and will complete with a status of -EINTR.
+ */
+void ib_sa_cancel_query(int id, struct ib_sa_query *query)
+{
+ unsigned long flags;
+ struct ib_mad_agent *agent;
+ struct ib_mad_send_buf *mad_buf;
+
+ spin_lock_irqsave(&idr_lock, flags);
+ if (idr_find(&query_idr, id) != query) {
+ spin_unlock_irqrestore(&idr_lock, flags);
+ return;
+ }
+ agent = query->port->agent;
+ mad_buf = query->mad_buf;
+ spin_unlock_irqrestore(&idr_lock, flags);
+}
+EXPORT_SYMBOL(ib_sa_cancel_query);
+
+static u8 get_src_path_mask(struct ib_device *device, u8 port_num)
+{
+ struct ib_sa_device *sa_dev;
+ struct ib_sa_port *port;
+ unsigned long flags;
+ u8 src_path_mask;
+
+ sa_dev = ib_get_client_data(device, &sa_client);
+ if (!sa_dev)
+ return 0x7f;
+
+ port = &sa_dev->port[port_num - sa_dev->start_port];
+ spin_lock_irqsave(&port->ah_lock, flags);
+ src_path_mask = port->sm_ah ? port->sm_ah->src_path_mask : 0x7f;
+ spin_unlock_irqrestore(&port->ah_lock, flags);
+
+ return src_path_mask;
+}
+
+int ib_init_ah_from_path(struct ib_device *device, u8 port_num,
+ struct ib_sa_path_rec *rec, struct ib_ah_attr *ah_attr)
+{
+ int ret;
+ u16 gid_index;
+ int use_roce;
+ struct net_device *ndev = NULL;
+
+ memset(ah_attr, 0, sizeof *ah_attr);
+ ah_attr->dlid = be16_to_cpu(rec->dlid);
+ ah_attr->sl = rec->sl;
+ ah_attr->src_path_bits = be16_to_cpu(rec->slid) &
+ get_src_path_mask(device, port_num);
+ ah_attr->port_num = port_num;
+ ah_attr->static_rate = rec->rate;
+
+ use_roce = rdma_cap_eth_ah(device, port_num);
+
+ if (use_roce) {
+ struct net_device *idev;
+ struct net_device *resolved_dev;
+ struct rdma_dev_addr dev_addr = {.bound_dev_if = rec->ifindex,
+ .net = rec->net ? rec->net :
+ &init_net};
+ union {
+ struct sockaddr _sockaddr;
+ struct sockaddr_in _sockaddr_in;
+ struct sockaddr_in6 _sockaddr_in6;
+ } sgid_addr, dgid_addr;
+
+ if (!device->get_netdev)
+ return -EOPNOTSUPP;
+
+ rdma_gid2ip(&sgid_addr._sockaddr, &rec->sgid);
+ rdma_gid2ip(&dgid_addr._sockaddr, &rec->dgid);
+
+ /* validate the route */
+ ret = rdma_resolve_ip_route(&sgid_addr._sockaddr,
+ &dgid_addr._sockaddr, &dev_addr);
+ if (ret)
+ return ret;
+
+ if ((dev_addr.network == RDMA_NETWORK_IPV4 ||
+ dev_addr.network == RDMA_NETWORK_IPV6) &&
+ rec->gid_type != IB_GID_TYPE_ROCE_UDP_ENCAP)
+ return -EINVAL;
+
+ idev = device->get_netdev(device, port_num);
+ if (!idev)
+ return -ENODEV;
+
+ resolved_dev = dev_get_by_index(dev_addr.net,
+ dev_addr.bound_dev_if);
+ if (resolved_dev->if_flags & IFF_LOOPBACK) {
+ dev_put(resolved_dev);
+ resolved_dev = idev;
+ dev_hold(resolved_dev);
+ }
+ ndev = ib_get_ndev_from_path(rec);
+ rcu_read_lock();
+ if ((ndev && ndev != resolved_dev) ||
+ (resolved_dev != idev &&
+ !rdma_is_upper_dev_rcu(idev, resolved_dev)))
+ ret = -EHOSTUNREACH;
+ rcu_read_unlock();
+ dev_put(idev);
+ dev_put(resolved_dev);
+ if (ret) {
+ if (ndev)
+ dev_put(ndev);
+ return ret;
+ }
+ }
+
+ if (rec->hop_limit > 0 || use_roce) {
+ ah_attr->ah_flags = IB_AH_GRH;
+ ah_attr->grh.dgid = rec->dgid;
+
+ ret = ib_find_cached_gid_by_port(device, &rec->sgid,
+ rec->gid_type, port_num, ndev,
+ &gid_index);
+ if (ret) {
+ if (ndev)
+ dev_put(ndev);
+ return ret;
+ }
+
+ ah_attr->grh.sgid_index = gid_index;
+ ah_attr->grh.flow_label = be32_to_cpu(rec->flow_label);
+ ah_attr->grh.hop_limit = rec->hop_limit;
+ ah_attr->grh.traffic_class = rec->traffic_class;
+ if (ndev)
+ dev_put(ndev);
+ }
+
+ if (use_roce)
+ memcpy(ah_attr->dmac, rec->dmac, ETH_ALEN);
+
+ return 0;
+}
+EXPORT_SYMBOL(ib_init_ah_from_path);
+
+static int alloc_mad(struct ib_sa_query *query, gfp_t gfp_mask)
+{
+ unsigned long flags;
+
+ spin_lock_irqsave(&query->port->ah_lock, flags);
+ if (!query->port->sm_ah) {
+ spin_unlock_irqrestore(&query->port->ah_lock, flags);
+ return -EAGAIN;
+ }
+ kref_get(&query->port->sm_ah->ref);
+ query->sm_ah = query->port->sm_ah;
+ spin_unlock_irqrestore(&query->port->ah_lock, flags);
+
+ query->mad_buf = ib_create_send_mad(query->port->agent, 1,
+ query->sm_ah->pkey_index,
+ 0, IB_MGMT_SA_HDR, IB_MGMT_SA_DATA,
+ gfp_mask,
+ IB_MGMT_BASE_VERSION);
+ if (IS_ERR(query->mad_buf)) {
+ kref_put(&query->sm_ah->ref, free_sm_ah);
+ return -ENOMEM;
+ }
+
+ query->mad_buf->ah = query->sm_ah->ah;
+
+ return 0;
+}
+
+static void free_mad(struct ib_sa_query *query)
+{
+ ib_free_send_mad(query->mad_buf);
+ kref_put(&query->sm_ah->ref, free_sm_ah);
+}
+
+static void init_mad(struct ib_sa_mad *mad, struct ib_mad_agent *agent)
+{
+ unsigned long flags;
+
+ memset(mad, 0, sizeof *mad);
+
+ mad->mad_hdr.base_version = IB_MGMT_BASE_VERSION;
+ mad->mad_hdr.mgmt_class = IB_MGMT_CLASS_SUBN_ADM;
+ mad->mad_hdr.class_version = IB_SA_CLASS_VERSION;
+
+ spin_lock_irqsave(&tid_lock, flags);
+ mad->mad_hdr.tid =
+ cpu_to_be64(((u64) agent->hi_tid) << 32 | tid++);
+ spin_unlock_irqrestore(&tid_lock, flags);
+}
+
+static int send_mad(struct ib_sa_query *query, int timeout_ms, gfp_t gfp_mask)
+{
+ bool preload = gfpflags_allow_blocking(gfp_mask);
+ unsigned long flags;
+ int ret, id;
+
+ if (preload)
+ idr_preload(gfp_mask);
+ spin_lock_irqsave(&idr_lock, flags);
+
+ id = idr_alloc(&query_idr, query, 0, 0, GFP_NOWAIT);
+
+ spin_unlock_irqrestore(&idr_lock, flags);
+ if (preload)
+ idr_preload_end();
+ if (id < 0)
+ return id;
+
+ query->mad_buf->timeout_ms = timeout_ms;
+ query->mad_buf->context[0] = query;
+ query->id = id;
+
+ if (query->flags & IB_SA_ENABLE_LOCAL_SERVICE) {
+ ib_sa_disable_local_svc(query);
+ }
+
+ ret = ib_post_send_mad(query->mad_buf, NULL);
+ if (ret) {
+ spin_lock_irqsave(&idr_lock, flags);
+ idr_remove(&query_idr, id);
+ spin_unlock_irqrestore(&idr_lock, flags);
+ }
+
+ /*
+ * It's not safe to dereference query any more, because the
+ * send may already have completed and freed the query in
+ * another context.
+ */
+ return ret ? ret : id;
+}
+
+void ib_sa_unpack_path(void *attribute, struct ib_sa_path_rec *rec)
+{
+ ib_unpack(path_rec_table, ARRAY_SIZE(path_rec_table), attribute, rec);
+}
+EXPORT_SYMBOL(ib_sa_unpack_path);
+
+void ib_sa_pack_path(struct ib_sa_path_rec *rec, void *attribute)
+{
+ ib_pack(path_rec_table, ARRAY_SIZE(path_rec_table), rec, attribute);
+}
+EXPORT_SYMBOL(ib_sa_pack_path);
+
+static void ib_sa_path_rec_callback(struct ib_sa_query *sa_query,
+ int status,
+ struct ib_sa_mad *mad)
+{
+ struct ib_sa_path_query *query =
+ container_of(sa_query, struct ib_sa_path_query, sa_query);
+
+ if (mad) {
+ struct ib_sa_path_rec rec;
+
+ ib_unpack(path_rec_table, ARRAY_SIZE(path_rec_table),
+ mad->data, &rec);
+ rec.net = NULL;
+ rec.ifindex = 0;
+ rec.gid_type = IB_GID_TYPE_IB;
+ eth_zero_addr(rec.dmac);
+ query->callback(status, &rec, query->context);
+ } else
+ query->callback(status, NULL, query->context);
+}
+
+static void ib_sa_path_rec_release(struct ib_sa_query *sa_query)
+{
+ kfree(container_of(sa_query, struct ib_sa_path_query, sa_query));
+}
+
+/**
+ * ib_sa_path_rec_get - Start a Path get query
+ * @client:SA client
+ * @device:device to send query on
+ * @port_num: port number to send query on
+ * @rec:Path Record to send in query
+ * @comp_mask:component mask to send in query
+ * @timeout_ms:time to wait for response
+ * @gfp_mask:GFP mask to use for internal allocations
+ * @callback:function called when query completes, times out or is
+ * canceled
+ * @context:opaque user context passed to callback
+ * @sa_query:query context, used to cancel query
+ *
+ * Send a Path Record Get query to the SA to look up a path. The
+ * callback function will be called when the query completes (or
+ * fails); status is 0 for a successful response, -EINTR if the query
+ * is canceled, -ETIMEDOUT is the query timed out, or -EIO if an error
+ * occurred sending the query. The resp parameter of the callback is
+ * only valid if status is 0.
+ *
+ * If the return value of ib_sa_path_rec_get() is negative, it is an
+ * error code. Otherwise it is a query ID that can be used to cancel
+ * the query.
+ */
+int ib_sa_path_rec_get(struct ib_sa_client *client,
+ struct ib_device *device, u8 port_num,
+ struct ib_sa_path_rec *rec,
+ ib_sa_comp_mask comp_mask,
+ int timeout_ms, gfp_t gfp_mask,
+ void (*callback)(int status,
+ struct ib_sa_path_rec *resp,
+ void *context),
+ void *context,
+ struct ib_sa_query **sa_query)
+{
+ struct ib_sa_path_query *query;
+ struct ib_sa_device *sa_dev = ib_get_client_data(device, &sa_client);
+ struct ib_sa_port *port;
+ struct ib_mad_agent *agent;
+ struct ib_sa_mad *mad;
+ int ret;
+
+ if (!sa_dev)
+ return -ENODEV;
+
+ port = &sa_dev->port[port_num - sa_dev->start_port];
+ agent = port->agent;
+
+ query = kzalloc(sizeof(*query), gfp_mask);
+ if (!query)
+ return -ENOMEM;
+
+ query->sa_query.port = port;
+ ret = alloc_mad(&query->sa_query, gfp_mask);
+ if (ret)
+ goto err1;
+
+ ib_sa_client_get(client);
+ query->sa_query.client = client;
+ query->callback = callback;
+ query->context = context;
+
+ mad = query->sa_query.mad_buf->mad;
+ init_mad(mad, agent);
+
+ query->sa_query.callback = callback ? ib_sa_path_rec_callback : NULL;
+ query->sa_query.release = ib_sa_path_rec_release;
+ mad->mad_hdr.method = IB_MGMT_METHOD_GET;
+ mad->mad_hdr.attr_id = cpu_to_be16(IB_SA_ATTR_PATH_REC);
+ mad->sa_hdr.comp_mask = comp_mask;
+
+ ib_pack(path_rec_table, ARRAY_SIZE(path_rec_table), rec, mad->data);
+
+ *sa_query = &query->sa_query;
+
+ query->sa_query.flags |= IB_SA_ENABLE_LOCAL_SERVICE;
+ query->sa_query.mad_buf->context[1] = rec;
+
+ ret = send_mad(&query->sa_query, timeout_ms, gfp_mask);
+ if (ret < 0)
+ goto err2;
+
+ return ret;
+
+err2:
+ *sa_query = NULL;
+ ib_sa_client_put(query->sa_query.client);
+ free_mad(&query->sa_query);
+
+err1:
+ kfree(query);
+ return ret;
+}
+EXPORT_SYMBOL(ib_sa_path_rec_get);
+
+static void ib_sa_service_rec_callback(struct ib_sa_query *sa_query,
+ int status,
+ struct ib_sa_mad *mad)
+{
+ struct ib_sa_service_query *query =
+ container_of(sa_query, struct ib_sa_service_query, sa_query);
+
+ if (mad) {
+ struct ib_sa_service_rec rec;
+
+ ib_unpack(service_rec_table, ARRAY_SIZE(service_rec_table),
+ mad->data, &rec);
+ query->callback(status, &rec, query->context);
+ } else
+ query->callback(status, NULL, query->context);
+}
+
+static void ib_sa_service_rec_release(struct ib_sa_query *sa_query)
+{
+ kfree(container_of(sa_query, struct ib_sa_service_query, sa_query));
+}
+
+/**
+ * ib_sa_service_rec_query - Start Service Record operation
+ * @client:SA client
+ * @device:device to send request on
+ * @port_num: port number to send request on
+ * @method:SA method - should be get, set, or delete
+ * @rec:Service Record to send in request
+ * @comp_mask:component mask to send in request
+ * @timeout_ms:time to wait for response
+ * @gfp_mask:GFP mask to use for internal allocations
+ * @callback:function called when request completes, times out or is
+ * canceled
+ * @context:opaque user context passed to callback
+ * @sa_query:request context, used to cancel request
+ *
+ * Send a Service Record set/get/delete to the SA to register,
+ * unregister or query a service record.
+ * The callback function will be called when the request completes (or
+ * fails); status is 0 for a successful response, -EINTR if the query
+ * is canceled, -ETIMEDOUT is the query timed out, or -EIO if an error
+ * occurred sending the query. The resp parameter of the callback is
+ * only valid if status is 0.
+ *
+ * If the return value of ib_sa_service_rec_query() is negative, it is an
+ * error code. Otherwise it is a request ID that can be used to cancel
+ * the query.
+ */
+int ib_sa_service_rec_query(struct ib_sa_client *client,
+ struct ib_device *device, u8 port_num, u8 method,
+ struct ib_sa_service_rec *rec,
+ ib_sa_comp_mask comp_mask,
+ int timeout_ms, gfp_t gfp_mask,
+ void (*callback)(int status,
+ struct ib_sa_service_rec *resp,
+ void *context),
+ void *context,
+ struct ib_sa_query **sa_query)
+{
+ struct ib_sa_service_query *query;
+ struct ib_sa_device *sa_dev = ib_get_client_data(device, &sa_client);
+ struct ib_sa_port *port;
+ struct ib_mad_agent *agent;
+ struct ib_sa_mad *mad;
+ int ret;
+
+ if (!sa_dev)
+ return -ENODEV;
+
+ port = &sa_dev->port[port_num - sa_dev->start_port];
+ agent = port->agent;
+
+ if (method != IB_MGMT_METHOD_GET &&
+ method != IB_MGMT_METHOD_SET &&
+ method != IB_SA_METHOD_DELETE)
+ return -EINVAL;
+
+ query = kzalloc(sizeof(*query), gfp_mask);
+ if (!query)
+ return -ENOMEM;
+
+ query->sa_query.port = port;
+ ret = alloc_mad(&query->sa_query, gfp_mask);
+ if (ret)
+ goto err1;
+
+ ib_sa_client_get(client);
+ query->sa_query.client = client;
+ query->callback = callback;
+ query->context = context;
+
+ mad = query->sa_query.mad_buf->mad;
+ init_mad(mad, agent);
+
+ query->sa_query.callback = callback ? ib_sa_service_rec_callback : NULL;
+ query->sa_query.release = ib_sa_service_rec_release;
+ mad->mad_hdr.method = method;
+ mad->mad_hdr.attr_id = cpu_to_be16(IB_SA_ATTR_SERVICE_REC);
+ mad->sa_hdr.comp_mask = comp_mask;
+
+ ib_pack(service_rec_table, ARRAY_SIZE(service_rec_table),
+ rec, mad->data);
+
+ *sa_query = &query->sa_query;
+
+ ret = send_mad(&query->sa_query, timeout_ms, gfp_mask);
+ if (ret < 0)
+ goto err2;
+
+ return ret;
+
+err2:
+ *sa_query = NULL;
+ ib_sa_client_put(query->sa_query.client);
+ free_mad(&query->sa_query);
+
+err1:
+ kfree(query);
+ return ret;
+}
+EXPORT_SYMBOL(ib_sa_service_rec_query);
+
+static void ib_sa_mcmember_rec_callback(struct ib_sa_query *sa_query,
+ int status,
+ struct ib_sa_mad *mad)
+{
+ struct ib_sa_mcmember_query *query =
+ container_of(sa_query, struct ib_sa_mcmember_query, sa_query);
+
+ if (mad) {
+ struct ib_sa_mcmember_rec rec;
+
+ ib_unpack(mcmember_rec_table, ARRAY_SIZE(mcmember_rec_table),
+ mad->data, &rec);
+ query->callback(status, &rec, query->context);
+ } else
+ query->callback(status, NULL, query->context);
+}
+
+static void ib_sa_mcmember_rec_release(struct ib_sa_query *sa_query)
+{
+ kfree(container_of(sa_query, struct ib_sa_mcmember_query, sa_query));
+}
+
+int ib_sa_mcmember_rec_query(struct ib_sa_client *client,
+ struct ib_device *device, u8 port_num,
+ u8 method,
+ struct ib_sa_mcmember_rec *rec,
+ ib_sa_comp_mask comp_mask,
+ int timeout_ms, gfp_t gfp_mask,
+ void (*callback)(int status,
+ struct ib_sa_mcmember_rec *resp,
+ void *context),
+ void *context,
+ struct ib_sa_query **sa_query)
+{
+ struct ib_sa_mcmember_query *query;
+ struct ib_sa_device *sa_dev = ib_get_client_data(device, &sa_client);
+ struct ib_sa_port *port;
+ struct ib_mad_agent *agent;
+ struct ib_sa_mad *mad;
+ int ret;
+
+ if (!sa_dev)
+ return -ENODEV;
+
+ port = &sa_dev->port[port_num - sa_dev->start_port];
+ agent = port->agent;
+
+ query = kzalloc(sizeof(*query), gfp_mask);
+ if (!query)
+ return -ENOMEM;
+
+ query->sa_query.port = port;
+ ret = alloc_mad(&query->sa_query, gfp_mask);
+ if (ret)
+ goto err1;
+
+ ib_sa_client_get(client);
+ query->sa_query.client = client;
+ query->callback = callback;
+ query->context = context;
+
+ mad = query->sa_query.mad_buf->mad;
+ init_mad(mad, agent);
+
+ query->sa_query.callback = callback ? ib_sa_mcmember_rec_callback : NULL;
+ query->sa_query.release = ib_sa_mcmember_rec_release;
+ mad->mad_hdr.method = method;
+ mad->mad_hdr.attr_id = cpu_to_be16(IB_SA_ATTR_MC_MEMBER_REC);
+ mad->sa_hdr.comp_mask = comp_mask;
+
+ ib_pack(mcmember_rec_table, ARRAY_SIZE(mcmember_rec_table),
+ rec, mad->data);
+
+ *sa_query = &query->sa_query;
+
+ ret = send_mad(&query->sa_query, timeout_ms, gfp_mask);
+ if (ret < 0)
+ goto err2;
+
+ return ret;
+
+err2:
+ *sa_query = NULL;
+ ib_sa_client_put(query->sa_query.client);
+ free_mad(&query->sa_query);
+
+err1:
+ kfree(query);
+ return ret;
+}
+
+/* Support GuidInfoRecord */
+static void ib_sa_guidinfo_rec_callback(struct ib_sa_query *sa_query,
+ int status,
+ struct ib_sa_mad *mad)
+{
+ struct ib_sa_guidinfo_query *query =
+ container_of(sa_query, struct ib_sa_guidinfo_query, sa_query);
+
+ if (mad) {
+ struct ib_sa_guidinfo_rec rec;
+
+ ib_unpack(guidinfo_rec_table, ARRAY_SIZE(guidinfo_rec_table),
+ mad->data, &rec);
+ query->callback(status, &rec, query->context);
+ } else
+ query->callback(status, NULL, query->context);
+}
+
+static void ib_sa_guidinfo_rec_release(struct ib_sa_query *sa_query)
+{
+ kfree(container_of(sa_query, struct ib_sa_guidinfo_query, sa_query));
+}
+
+int ib_sa_guid_info_rec_query(struct ib_sa_client *client,
+ struct ib_device *device, u8 port_num,
+ struct ib_sa_guidinfo_rec *rec,
+ ib_sa_comp_mask comp_mask, u8 method,
+ int timeout_ms, gfp_t gfp_mask,
+ void (*callback)(int status,
+ struct ib_sa_guidinfo_rec *resp,
+ void *context),
+ void *context,
+ struct ib_sa_query **sa_query)
+{
+ struct ib_sa_guidinfo_query *query;
+ struct ib_sa_device *sa_dev = ib_get_client_data(device, &sa_client);
+ struct ib_sa_port *port;
+ struct ib_mad_agent *agent;
+ struct ib_sa_mad *mad;
+ int ret;
+
+ if (!sa_dev)
+ return -ENODEV;
+
+ if (method != IB_MGMT_METHOD_GET &&
+ method != IB_MGMT_METHOD_SET &&
+ method != IB_SA_METHOD_DELETE) {
+ return -EINVAL;
+ }
+
+ port = &sa_dev->port[port_num - sa_dev->start_port];
+ agent = port->agent;
+
+ query = kzalloc(sizeof(*query), gfp_mask);
+ if (!query)
+ return -ENOMEM;
+
+ query->sa_query.port = port;
+ ret = alloc_mad(&query->sa_query, gfp_mask);
+ if (ret)
+ goto err1;
+
+ ib_sa_client_get(client);
+ query->sa_query.client = client;
+ query->callback = callback;
+ query->context = context;
+
+ mad = query->sa_query.mad_buf->mad;
+ init_mad(mad, agent);
+
+ query->sa_query.callback = callback ? ib_sa_guidinfo_rec_callback : NULL;
+ query->sa_query.release = ib_sa_guidinfo_rec_release;
+
+ mad->mad_hdr.method = method;
+ mad->mad_hdr.attr_id = cpu_to_be16(IB_SA_ATTR_GUID_INFO_REC);
+ mad->sa_hdr.comp_mask = comp_mask;
+
+ ib_pack(guidinfo_rec_table, ARRAY_SIZE(guidinfo_rec_table), rec,
+ mad->data);
+
+ *sa_query = &query->sa_query;
+
+ ret = send_mad(&query->sa_query, timeout_ms, gfp_mask);
+ if (ret < 0)
+ goto err2;
+
+ return ret;
+
+err2:
+ *sa_query = NULL;
+ ib_sa_client_put(query->sa_query.client);
+ free_mad(&query->sa_query);
+
+err1:
+ kfree(query);
+ return ret;
+}
+EXPORT_SYMBOL(ib_sa_guid_info_rec_query);
+
+/* Support get SA ClassPortInfo */
+static void ib_sa_classport_info_rec_callback(struct ib_sa_query *sa_query,
+ int status,
+ struct ib_sa_mad *mad)
+{
+ unsigned long flags;
+ struct ib_sa_classport_info_query *query =
+ container_of(sa_query, struct ib_sa_classport_info_query, sa_query);
+
+ if (mad) {
+ struct ib_class_port_info rec;
+
+ ib_unpack(classport_info_rec_table,
+ ARRAY_SIZE(classport_info_rec_table),
+ mad->data, &rec);
+
+ spin_lock_irqsave(&sa_query->port->classport_lock, flags);
+ if (!status && !sa_query->port->classport_info.valid) {
+ memcpy(&sa_query->port->classport_info.data, &rec,
+ sizeof(sa_query->port->classport_info.data));
+
+ sa_query->port->classport_info.valid = true;
+ }
+ spin_unlock_irqrestore(&sa_query->port->classport_lock, flags);
+
+ query->callback(status, &rec, query->context);
+ } else {
+ query->callback(status, NULL, query->context);
+ }
+}
+
+static void ib_sa_portclass_info_rec_release(struct ib_sa_query *sa_query)
+{
+ kfree(container_of(sa_query, struct ib_sa_classport_info_query,
+ sa_query));
+}
+
+int ib_sa_classport_info_rec_query(struct ib_sa_client *client,
+ struct ib_device *device, u8 port_num,
+ int timeout_ms, gfp_t gfp_mask,
+ void (*callback)(int status,
+ struct ib_class_port_info *resp,
+ void *context),
+ void *context,
+ struct ib_sa_query **sa_query)
+{
+ struct ib_sa_classport_info_query *query;
+ struct ib_sa_device *sa_dev = ib_get_client_data(device, &sa_client);
+ struct ib_sa_port *port;
+ struct ib_mad_agent *agent;
+ struct ib_sa_mad *mad;
+ struct ib_class_port_info cached_class_port_info;
+ int ret;
+ unsigned long flags;
+
+ if (!sa_dev)
+ return -ENODEV;
+
+ port = &sa_dev->port[port_num - sa_dev->start_port];
+ agent = port->agent;
+
+ /* Use cached ClassPortInfo attribute if valid instead of sending mad */
+ spin_lock_irqsave(&port->classport_lock, flags);
+ if (port->classport_info.valid && callback) {
+ memcpy(&cached_class_port_info, &port->classport_info.data,
+ sizeof(cached_class_port_info));
+ spin_unlock_irqrestore(&port->classport_lock, flags);
+ callback(0, &cached_class_port_info, context);
+ return 0;
+ }
+ spin_unlock_irqrestore(&port->classport_lock, flags);
+
+ query = kzalloc(sizeof(*query), gfp_mask);
+ if (!query)
+ return -ENOMEM;
+
+ query->sa_query.port = port;
+ ret = alloc_mad(&query->sa_query, gfp_mask);
+ if (ret)
+ goto err1;
+
+ ib_sa_client_get(client);
+ query->sa_query.client = client;
+ query->callback = callback;
+ query->context = context;
+
+ mad = query->sa_query.mad_buf->mad;
+ init_mad(mad, agent);
+
+ query->sa_query.callback = callback ? ib_sa_classport_info_rec_callback : NULL;
+
+ query->sa_query.release = ib_sa_portclass_info_rec_release;
+ /* support GET only */
+ mad->mad_hdr.method = IB_MGMT_METHOD_GET;
+ mad->mad_hdr.attr_id = cpu_to_be16(IB_SA_ATTR_CLASS_PORTINFO);
+ mad->sa_hdr.comp_mask = 0;
+ *sa_query = &query->sa_query;
+
+ ret = send_mad(&query->sa_query, timeout_ms, gfp_mask);
+ if (ret < 0)
+ goto err2;
+
+ return ret;
+
+err2:
+ *sa_query = NULL;
+ ib_sa_client_put(query->sa_query.client);
+ free_mad(&query->sa_query);
+
+err1:
+ kfree(query);
+ return ret;
+}
+EXPORT_SYMBOL(ib_sa_classport_info_rec_query);
+
+static void send_handler(struct ib_mad_agent *agent,
+ struct ib_mad_send_wc *mad_send_wc)
+{
+ struct ib_sa_query *query = mad_send_wc->send_buf->context[0];
+ unsigned long flags;
+
+ if (query->callback)
+ switch (mad_send_wc->status) {
+ case IB_WC_SUCCESS:
+ /* No callback -- already got recv */
+ break;
+ case IB_WC_RESP_TIMEOUT_ERR:
+ query->callback(query, -ETIMEDOUT, NULL);
+ break;
+ case IB_WC_WR_FLUSH_ERR:
+ query->callback(query, -EINTR, NULL);
+ break;
+ default:
+ query->callback(query, -EIO, NULL);
+ break;
+ }
+
+ spin_lock_irqsave(&idr_lock, flags);
+ idr_remove(&query_idr, query->id);
+ spin_unlock_irqrestore(&idr_lock, flags);
+
+ free_mad(query);
+ ib_sa_client_put(query->client);
+ query->release(query);
+}
+
+static void recv_handler(struct ib_mad_agent *mad_agent,
+ struct ib_mad_send_buf *send_buf,
+ struct ib_mad_recv_wc *mad_recv_wc)
+{
+ struct ib_sa_query *query;
+
+ if (!send_buf)
+ return;
+
+ query = send_buf->context[0];
+ if (query->callback) {
+ if (mad_recv_wc->wc->status == IB_WC_SUCCESS)
+ query->callback(query,
+ mad_recv_wc->recv_buf.mad->mad_hdr.status ?
+ -EINVAL : 0,
+ (struct ib_sa_mad *) mad_recv_wc->recv_buf.mad);
+ else
+ query->callback(query, -EIO, NULL);
+ }
+
+ ib_free_recv_mad(mad_recv_wc);
+}
+
+static void ib_sa_add_one(struct ib_device *device)
+{
+ struct ib_sa_device *sa_dev;
+ int s, e, i;
+ int count = 0;
+
+ s = rdma_start_port(device);
+ e = rdma_end_port(device);
+
+ sa_dev = kzalloc(sizeof *sa_dev +
+ (e - s + 1) * sizeof (struct ib_sa_port),
+ GFP_KERNEL);
+ if (!sa_dev)
+ return;
+
+ sa_dev->start_port = s;
+ sa_dev->end_port = e;
+
+ for (i = 0; i <= e - s; ++i) {
+ spin_lock_init(&sa_dev->port[i].ah_lock);
+ if (!rdma_cap_ib_sa(device, i + 1))
+ continue;
+
+ sa_dev->port[i].sm_ah = NULL;
+ sa_dev->port[i].port_num = i + s;
+
+ spin_lock_init(&sa_dev->port[i].classport_lock);
+ sa_dev->port[i].classport_info.valid = false;
+
+ sa_dev->port[i].agent =
+ ib_register_mad_agent(device, i + s, IB_QPT_GSI,
+ NULL, 0, send_handler,
+ recv_handler, sa_dev, 0);
+ if (IS_ERR(sa_dev->port[i].agent))
+ goto err;
+
+ INIT_WORK(&sa_dev->port[i].update_task, update_sm_ah);
+
+ count++;
+ }
+
+ if (!count)
+ goto free;
+
+ ib_set_client_data(device, &sa_client, sa_dev);
+
+ /*
+ * We register our event handler after everything is set up,
+ * and then update our cached info after the event handler is
+ * registered to avoid any problems if a port changes state
+ * during our initialization.
+ */
+
+ INIT_IB_EVENT_HANDLER(&sa_dev->event_handler, device, ib_sa_event);
+ if (ib_register_event_handler(&sa_dev->event_handler))
+ goto err;
+
+ for (i = 0; i <= e - s; ++i) {
+ if (rdma_cap_ib_sa(device, i + 1))
+ update_sm_ah(&sa_dev->port[i].update_task);
+ }
+
+ return;
+
+err:
+ while (--i >= 0) {
+ if (rdma_cap_ib_sa(device, i + 1))
+ ib_unregister_mad_agent(sa_dev->port[i].agent);
+ }
+free:
+ kfree(sa_dev);
+ return;
+}
+
+static void ib_sa_remove_one(struct ib_device *device, void *client_data)
+{
+ struct ib_sa_device *sa_dev = client_data;
+ int i;
+
+ if (!sa_dev)
+ return;
+
+ ib_unregister_event_handler(&sa_dev->event_handler);
+
+ flush_workqueue(ib_wq);
+
+ for (i = 0; i <= sa_dev->end_port - sa_dev->start_port; ++i) {
+ if (rdma_cap_ib_sa(device, i + 1)) {
+ ib_unregister_mad_agent(sa_dev->port[i].agent);
+ if (sa_dev->port[i].sm_ah)
+ kref_put(&sa_dev->port[i].sm_ah->ref, free_sm_ah);
+ }
+
+ }
+
+ kfree(sa_dev);
+}
+
+int ib_sa_init(void)
+{
+ int ret;
+
+ get_random_bytes(&tid, sizeof tid);
+
+ ret = ib_register_client(&sa_client);
+ if (ret) {
+ pr_err("Couldn't register ib_sa client\n");
+ goto err1;
+ }
+
+ ret = mcast_init();
+ if (ret) {
+ pr_err("Couldn't initialize multicast handling\n");
+ goto err2;
+ }
+
+ return 0;
+
+err2:
+ ib_unregister_client(&sa_client);
+err1:
+ return ret;
+}
+
+void ib_sa_cleanup(void)
+{
+ mcast_cleanup();
+ ib_unregister_client(&sa_client);
+ idr_destroy(&query_idr);
+}
diff --git a/sys/ofed/drivers/infiniband/core/ib_smi.c b/sys/ofed/drivers/infiniband/core/ib_smi.c
new file mode 100644
index 0000000..f19b238
--- /dev/null
+++ b/sys/ofed/drivers/infiniband/core/ib_smi.c
@@ -0,0 +1,338 @@
+/*
+ * Copyright (c) 2004, 2005 Mellanox Technologies Ltd. All rights reserved.
+ * Copyright (c) 2004, 2005 Infinicon Corporation. All rights reserved.
+ * Copyright (c) 2004, 2005 Intel Corporation. All rights reserved.
+ * Copyright (c) 2004, 2005 Topspin Corporation. All rights reserved.
+ * Copyright (c) 2004-2007 Voltaire Corporation. All rights reserved.
+ * Copyright (c) 2005 Sun Microsystems, Inc. All rights reserved.
+ * Copyright (c) 2014 Intel Corporation. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+#include <rdma/ib_smi.h>
+#include "smi.h"
+#include "opa_smi.h"
+
+static enum smi_action __smi_handle_dr_smp_send(bool is_switch, int port_num,
+ u8 *hop_ptr, u8 hop_cnt,
+ const u8 *initial_path,
+ const u8 *return_path,
+ u8 direction,
+ bool dr_dlid_is_permissive,
+ bool dr_slid_is_permissive)
+{
+ /* See section 14.2.2.2, Vol 1 IB spec */
+ /* C14-6 -- valid hop_cnt values are from 0 to 63 */
+ if (hop_cnt >= IB_SMP_MAX_PATH_HOPS)
+ return IB_SMI_DISCARD;
+
+ if (!direction) {
+ /* C14-9:1 */
+ if (hop_cnt && *hop_ptr == 0) {
+ (*hop_ptr)++;
+ return (initial_path[*hop_ptr] ==
+ port_num ? IB_SMI_HANDLE : IB_SMI_DISCARD);
+ }
+
+ /* C14-9:2 */
+ if (*hop_ptr && *hop_ptr < hop_cnt) {
+ if (!is_switch)
+ return IB_SMI_DISCARD;
+
+ /* return_path set when received */
+ (*hop_ptr)++;
+ return (initial_path[*hop_ptr] ==
+ port_num ? IB_SMI_HANDLE : IB_SMI_DISCARD);
+ }
+
+ /* C14-9:3 -- We're at the end of the DR segment of path */
+ if (*hop_ptr == hop_cnt) {
+ /* return_path set when received */
+ (*hop_ptr)++;
+ return (is_switch ||
+ dr_dlid_is_permissive ?
+ IB_SMI_HANDLE : IB_SMI_DISCARD);
+ }
+
+ /* C14-9:4 -- hop_ptr = hop_cnt + 1 -> give to SMA/SM */
+ /* C14-9:5 -- Fail unreasonable hop pointer */
+ return (*hop_ptr == hop_cnt + 1 ? IB_SMI_HANDLE : IB_SMI_DISCARD);
+
+ } else {
+ /* C14-13:1 */
+ if (hop_cnt && *hop_ptr == hop_cnt + 1) {
+ (*hop_ptr)--;
+ return (return_path[*hop_ptr] ==
+ port_num ? IB_SMI_HANDLE : IB_SMI_DISCARD);
+ }
+
+ /* C14-13:2 */
+ if (2 <= *hop_ptr && *hop_ptr <= hop_cnt) {
+ if (!is_switch)
+ return IB_SMI_DISCARD;
+
+ (*hop_ptr)--;
+ return (return_path[*hop_ptr] ==
+ port_num ? IB_SMI_HANDLE : IB_SMI_DISCARD);
+ }
+
+ /* C14-13:3 -- at the end of the DR segment of path */
+ if (*hop_ptr == 1) {
+ (*hop_ptr)--;
+ /* C14-13:3 -- SMPs destined for SM shouldn't be here */
+ return (is_switch ||
+ dr_slid_is_permissive ?
+ IB_SMI_HANDLE : IB_SMI_DISCARD);
+ }
+
+ /* C14-13:4 -- hop_ptr = 0 -> should have gone to SM */
+ if (*hop_ptr == 0)
+ return IB_SMI_HANDLE;
+
+ /* C14-13:5 -- Check for unreasonable hop pointer */
+ return IB_SMI_DISCARD;
+ }
+}
+
+/*
+ * Fixup a directed route SMP for sending
+ * Return IB_SMI_DISCARD if the SMP should be discarded
+ */
+enum smi_action smi_handle_dr_smp_send(struct ib_smp *smp,
+ bool is_switch, int port_num)
+{
+ return __smi_handle_dr_smp_send(is_switch, port_num,
+ &smp->hop_ptr, smp->hop_cnt,
+ smp->initial_path,
+ smp->return_path,
+ ib_get_smp_direction(smp),
+ smp->dr_dlid == IB_LID_PERMISSIVE,
+ smp->dr_slid == IB_LID_PERMISSIVE);
+}
+
+enum smi_action opa_smi_handle_dr_smp_send(struct opa_smp *smp,
+ bool is_switch, int port_num)
+{
+ return __smi_handle_dr_smp_send(is_switch, port_num,
+ &smp->hop_ptr, smp->hop_cnt,
+ smp->route.dr.initial_path,
+ smp->route.dr.return_path,
+ opa_get_smp_direction(smp),
+ smp->route.dr.dr_dlid ==
+ OPA_LID_PERMISSIVE,
+ smp->route.dr.dr_slid ==
+ OPA_LID_PERMISSIVE);
+}
+
+static enum smi_action __smi_handle_dr_smp_recv(bool is_switch, int port_num,
+ int phys_port_cnt,
+ u8 *hop_ptr, u8 hop_cnt,
+ const u8 *initial_path,
+ u8 *return_path,
+ u8 direction,
+ bool dr_dlid_is_permissive,
+ bool dr_slid_is_permissive)
+{
+ /* See section 14.2.2.2, Vol 1 IB spec */
+ /* C14-6 -- valid hop_cnt values are from 0 to 63 */
+ if (hop_cnt >= IB_SMP_MAX_PATH_HOPS)
+ return IB_SMI_DISCARD;
+
+ if (!direction) {
+ /* C14-9:1 -- sender should have incremented hop_ptr */
+ if (hop_cnt && *hop_ptr == 0)
+ return IB_SMI_DISCARD;
+
+ /* C14-9:2 -- intermediate hop */
+ if (*hop_ptr && *hop_ptr < hop_cnt) {
+ if (!is_switch)
+ return IB_SMI_DISCARD;
+
+ return_path[*hop_ptr] = port_num;
+ /* hop_ptr updated when sending */
+ return (initial_path[*hop_ptr+1] <= phys_port_cnt ?
+ IB_SMI_HANDLE : IB_SMI_DISCARD);
+ }
+
+ /* C14-9:3 -- We're at the end of the DR segment of path */
+ if (*hop_ptr == hop_cnt) {
+ if (hop_cnt)
+ return_path[*hop_ptr] = port_num;
+ /* hop_ptr updated when sending */
+
+ return (is_switch ||
+ dr_dlid_is_permissive ?
+ IB_SMI_HANDLE : IB_SMI_DISCARD);
+ }
+
+ /* C14-9:4 -- hop_ptr = hop_cnt + 1 -> give to SMA/SM */
+ /* C14-9:5 -- fail unreasonable hop pointer */
+ return (*hop_ptr == hop_cnt + 1 ? IB_SMI_HANDLE : IB_SMI_DISCARD);
+
+ } else {
+
+ /* C14-13:1 */
+ if (hop_cnt && *hop_ptr == hop_cnt + 1) {
+ (*hop_ptr)--;
+ return (return_path[*hop_ptr] ==
+ port_num ? IB_SMI_HANDLE : IB_SMI_DISCARD);
+ }
+
+ /* C14-13:2 */
+ if (2 <= *hop_ptr && *hop_ptr <= hop_cnt) {
+ if (!is_switch)
+ return IB_SMI_DISCARD;
+
+ /* hop_ptr updated when sending */
+ return (return_path[*hop_ptr-1] <= phys_port_cnt ?
+ IB_SMI_HANDLE : IB_SMI_DISCARD);
+ }
+
+ /* C14-13:3 -- We're at the end of the DR segment of path */
+ if (*hop_ptr == 1) {
+ if (dr_slid_is_permissive) {
+ /* giving SMP to SM - update hop_ptr */
+ (*hop_ptr)--;
+ return IB_SMI_HANDLE;
+ }
+ /* hop_ptr updated when sending */
+ return (is_switch ? IB_SMI_HANDLE : IB_SMI_DISCARD);
+ }
+
+ /* C14-13:4 -- hop_ptr = 0 -> give to SM */
+ /* C14-13:5 -- Check for unreasonable hop pointer */
+ return (*hop_ptr == 0 ? IB_SMI_HANDLE : IB_SMI_DISCARD);
+ }
+}
+
+/*
+ * Adjust information for a received SMP
+ * Return IB_SMI_DISCARD if the SMP should be dropped
+ */
+enum smi_action smi_handle_dr_smp_recv(struct ib_smp *smp, bool is_switch,
+ int port_num, int phys_port_cnt)
+{
+ return __smi_handle_dr_smp_recv(is_switch, port_num, phys_port_cnt,
+ &smp->hop_ptr, smp->hop_cnt,
+ smp->initial_path,
+ smp->return_path,
+ ib_get_smp_direction(smp),
+ smp->dr_dlid == IB_LID_PERMISSIVE,
+ smp->dr_slid == IB_LID_PERMISSIVE);
+}
+
+/*
+ * Adjust information for a received SMP
+ * Return IB_SMI_DISCARD if the SMP should be dropped
+ */
+enum smi_action opa_smi_handle_dr_smp_recv(struct opa_smp *smp, bool is_switch,
+ int port_num, int phys_port_cnt)
+{
+ return __smi_handle_dr_smp_recv(is_switch, port_num, phys_port_cnt,
+ &smp->hop_ptr, smp->hop_cnt,
+ smp->route.dr.initial_path,
+ smp->route.dr.return_path,
+ opa_get_smp_direction(smp),
+ smp->route.dr.dr_dlid ==
+ OPA_LID_PERMISSIVE,
+ smp->route.dr.dr_slid ==
+ OPA_LID_PERMISSIVE);
+}
+
+static enum smi_forward_action __smi_check_forward_dr_smp(u8 hop_ptr, u8 hop_cnt,
+ u8 direction,
+ bool dr_dlid_is_permissive,
+ bool dr_slid_is_permissive)
+{
+ if (!direction) {
+ /* C14-9:2 -- intermediate hop */
+ if (hop_ptr && hop_ptr < hop_cnt)
+ return IB_SMI_FORWARD;
+
+ /* C14-9:3 -- at the end of the DR segment of path */
+ if (hop_ptr == hop_cnt)
+ return (dr_dlid_is_permissive ?
+ IB_SMI_SEND : IB_SMI_LOCAL);
+
+ /* C14-9:4 -- hop_ptr = hop_cnt + 1 -> give to SMA/SM */
+ if (hop_ptr == hop_cnt + 1)
+ return IB_SMI_SEND;
+ } else {
+ /* C14-13:2 -- intermediate hop */
+ if (2 <= hop_ptr && hop_ptr <= hop_cnt)
+ return IB_SMI_FORWARD;
+
+ /* C14-13:3 -- at the end of the DR segment of path */
+ if (hop_ptr == 1)
+ return (!dr_slid_is_permissive ?
+ IB_SMI_SEND : IB_SMI_LOCAL);
+ }
+ return IB_SMI_LOCAL;
+
+}
+
+enum smi_forward_action smi_check_forward_dr_smp(struct ib_smp *smp)
+{
+ return __smi_check_forward_dr_smp(smp->hop_ptr, smp->hop_cnt,
+ ib_get_smp_direction(smp),
+ smp->dr_dlid == IB_LID_PERMISSIVE,
+ smp->dr_slid == IB_LID_PERMISSIVE);
+}
+
+enum smi_forward_action opa_smi_check_forward_dr_smp(struct opa_smp *smp)
+{
+ return __smi_check_forward_dr_smp(smp->hop_ptr, smp->hop_cnt,
+ opa_get_smp_direction(smp),
+ smp->route.dr.dr_dlid ==
+ OPA_LID_PERMISSIVE,
+ smp->route.dr.dr_slid ==
+ OPA_LID_PERMISSIVE);
+}
+
+/*
+ * Return the forwarding port number from initial_path for outgoing SMP and
+ * from return_path for returning SMP
+ */
+int smi_get_fwd_port(struct ib_smp *smp)
+{
+ return (!ib_get_smp_direction(smp) ? smp->initial_path[smp->hop_ptr+1] :
+ smp->return_path[smp->hop_ptr-1]);
+}
+
+/*
+ * Return the forwarding port number from initial_path for outgoing SMP and
+ * from return_path for returning SMP
+ */
+int opa_smi_get_fwd_port(struct opa_smp *smp)
+{
+ return !opa_get_smp_direction(smp) ? smp->route.dr.initial_path[smp->hop_ptr+1] :
+ smp->route.dr.return_path[smp->hop_ptr-1];
+}
diff --git a/sys/ofed/drivers/infiniband/core/ib_sysfs.c b/sys/ofed/drivers/infiniband/core/ib_sysfs.c
new file mode 100644
index 0000000..3527a72
--- /dev/null
+++ b/sys/ofed/drivers/infiniband/core/ib_sysfs.c
@@ -0,0 +1,1327 @@
+/*
+ * Copyright (c) 2004, 2005 Topspin Communications. All rights reserved.
+ * Copyright (c) 2005 Mellanox Technologies Ltd. All rights reserved.
+ * Copyright (c) 2005 Sun Microsystems, Inc. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#include "core_priv.h"
+
+#include <linux/slab.h>
+#include <linux/string.h>
+#include <linux/netdevice.h>
+#include <linux/fs.h>
+#include <linux/printk.h>
+
+#include <rdma/ib_mad.h>
+#include <rdma/ib_pma.h>
+
+struct ib_port;
+
+struct gid_attr_group {
+ struct ib_port *port;
+ struct kobject kobj;
+ struct attribute_group ndev;
+ struct attribute_group type;
+};
+struct ib_port {
+ struct kobject kobj;
+ struct ib_device *ibdev;
+ struct gid_attr_group *gid_attr_group;
+ struct attribute_group gid_group;
+ struct attribute_group pkey_group;
+ struct attribute_group *pma_table;
+ struct attribute_group *hw_stats_ag;
+ struct rdma_hw_stats *hw_stats;
+ u8 port_num;
+};
+
+struct port_attribute {
+ struct attribute attr;
+ ssize_t (*show)(struct ib_port *, struct port_attribute *, char *buf);
+ ssize_t (*store)(struct ib_port *, struct port_attribute *,
+ const char *buf, size_t count);
+};
+
+#define PORT_ATTR(_name, _mode, _show, _store) \
+struct port_attribute port_attr_##_name = __ATTR(_name, _mode, _show, _store)
+
+#define PORT_ATTR_RO(_name) \
+struct port_attribute port_attr_##_name = __ATTR_RO(_name)
+
+struct port_table_attribute {
+ struct port_attribute attr;
+ char name[8];
+ int index;
+ __be16 attr_id;
+};
+
+struct hw_stats_attribute {
+ struct attribute attr;
+ ssize_t (*show)(struct kobject *kobj,
+ struct attribute *attr, char *buf);
+ ssize_t (*store)(struct kobject *kobj,
+ struct attribute *attr,
+ const char *buf,
+ size_t count);
+ int index;
+ u8 port_num;
+};
+
+static ssize_t port_attr_show(struct kobject *kobj,
+ struct attribute *attr, char *buf)
+{
+ struct port_attribute *port_attr =
+ container_of(attr, struct port_attribute, attr);
+ struct ib_port *p = container_of(kobj, struct ib_port, kobj);
+
+ if (!port_attr->show)
+ return -EIO;
+
+ return port_attr->show(p, port_attr, buf);
+}
+
+static const struct sysfs_ops port_sysfs_ops = {
+ .show = port_attr_show
+};
+
+static ssize_t gid_attr_show(struct kobject *kobj,
+ struct attribute *attr, char *buf)
+{
+ struct port_attribute *port_attr =
+ container_of(attr, struct port_attribute, attr);
+ struct ib_port *p = container_of(kobj, struct gid_attr_group,
+ kobj)->port;
+
+ if (!port_attr->show)
+ return -EIO;
+
+ return port_attr->show(p, port_attr, buf);
+}
+
+static const struct sysfs_ops gid_attr_sysfs_ops = {
+ .show = gid_attr_show
+};
+
+static ssize_t state_show(struct ib_port *p, struct port_attribute *unused,
+ char *buf)
+{
+ struct ib_port_attr attr;
+ ssize_t ret;
+
+ static const char *state_name[] = {
+ [IB_PORT_NOP] = "NOP",
+ [IB_PORT_DOWN] = "DOWN",
+ [IB_PORT_INIT] = "INIT",
+ [IB_PORT_ARMED] = "ARMED",
+ [IB_PORT_ACTIVE] = "ACTIVE",
+ [IB_PORT_ACTIVE_DEFER] = "ACTIVE_DEFER"
+ };
+
+ ret = ib_query_port(p->ibdev, p->port_num, &attr);
+ if (ret)
+ return ret;
+
+ return sprintf(buf, "%d: %s\n", attr.state,
+ attr.state >= 0 && attr.state < ARRAY_SIZE(state_name) ?
+ state_name[attr.state] : "UNKNOWN");
+}
+
+static ssize_t lid_show(struct ib_port *p, struct port_attribute *unused,
+ char *buf)
+{
+ struct ib_port_attr attr;
+ ssize_t ret;
+
+ ret = ib_query_port(p->ibdev, p->port_num, &attr);
+ if (ret)
+ return ret;
+
+ return sprintf(buf, "0x%x\n", attr.lid);
+}
+
+static ssize_t lid_mask_count_show(struct ib_port *p,
+ struct port_attribute *unused,
+ char *buf)
+{
+ struct ib_port_attr attr;
+ ssize_t ret;
+
+ ret = ib_query_port(p->ibdev, p->port_num, &attr);
+ if (ret)
+ return ret;
+
+ return sprintf(buf, "%d\n", attr.lmc);
+}
+
+static ssize_t sm_lid_show(struct ib_port *p, struct port_attribute *unused,
+ char *buf)
+{
+ struct ib_port_attr attr;
+ ssize_t ret;
+
+ ret = ib_query_port(p->ibdev, p->port_num, &attr);
+ if (ret)
+ return ret;
+
+ return sprintf(buf, "0x%x\n", attr.sm_lid);
+}
+
+static ssize_t sm_sl_show(struct ib_port *p, struct port_attribute *unused,
+ char *buf)
+{
+ struct ib_port_attr attr;
+ ssize_t ret;
+
+ ret = ib_query_port(p->ibdev, p->port_num, &attr);
+ if (ret)
+ return ret;
+
+ return sprintf(buf, "%d\n", attr.sm_sl);
+}
+
+static ssize_t cap_mask_show(struct ib_port *p, struct port_attribute *unused,
+ char *buf)
+{
+ struct ib_port_attr attr;
+ ssize_t ret;
+
+ ret = ib_query_port(p->ibdev, p->port_num, &attr);
+ if (ret)
+ return ret;
+
+ return sprintf(buf, "0x%08x\n", attr.port_cap_flags);
+}
+
+static ssize_t rate_show(struct ib_port *p, struct port_attribute *unused,
+ char *buf)
+{
+ struct ib_port_attr attr;
+ char *speed = "";
+ int rate; /* in deci-Gb/sec */
+ ssize_t ret;
+
+ ret = ib_query_port(p->ibdev, p->port_num, &attr);
+ if (ret)
+ return ret;
+
+ switch (attr.active_speed) {
+ case IB_SPEED_DDR:
+ speed = " DDR";
+ rate = 50;
+ break;
+ case IB_SPEED_QDR:
+ speed = " QDR";
+ rate = 100;
+ break;
+ case IB_SPEED_FDR10:
+ speed = " FDR10";
+ rate = 100;
+ break;
+ case IB_SPEED_FDR:
+ speed = " FDR";
+ rate = 140;
+ break;
+ case IB_SPEED_EDR:
+ speed = " EDR";
+ rate = 250;
+ break;
+ case IB_SPEED_SDR:
+ default: /* default to SDR for invalid rates */
+ rate = 25;
+ break;
+ }
+
+ rate *= ib_width_enum_to_int(attr.active_width);
+ if (rate < 0)
+ return -EINVAL;
+
+ return sprintf(buf, "%d%s Gb/sec (%dX%s)\n",
+ rate / 10, rate % 10 ? ".5" : "",
+ ib_width_enum_to_int(attr.active_width), speed);
+}
+
+static ssize_t phys_state_show(struct ib_port *p, struct port_attribute *unused,
+ char *buf)
+{
+ struct ib_port_attr attr;
+
+ ssize_t ret;
+
+ ret = ib_query_port(p->ibdev, p->port_num, &attr);
+ if (ret)
+ return ret;
+
+ switch (attr.phys_state) {
+ case 1: return sprintf(buf, "1: Sleep\n");
+ case 2: return sprintf(buf, "2: Polling\n");
+ case 3: return sprintf(buf, "3: Disabled\n");
+ case 4: return sprintf(buf, "4: PortConfigurationTraining\n");
+ case 5: return sprintf(buf, "5: LinkUp\n");
+ case 6: return sprintf(buf, "6: LinkErrorRecovery\n");
+ case 7: return sprintf(buf, "7: Phy Test\n");
+ default: return sprintf(buf, "%d: <unknown>\n", attr.phys_state);
+ }
+}
+
+static ssize_t link_layer_show(struct ib_port *p, struct port_attribute *unused,
+ char *buf)
+{
+ switch (rdma_port_get_link_layer(p->ibdev, p->port_num)) {
+ case IB_LINK_LAYER_INFINIBAND:
+ return sprintf(buf, "%s\n", "InfiniBand");
+ case IB_LINK_LAYER_ETHERNET:
+ return sprintf(buf, "%s\n", "Ethernet");
+ default:
+ return sprintf(buf, "%s\n", "Unknown");
+ }
+}
+
+static PORT_ATTR_RO(state);
+static PORT_ATTR_RO(lid);
+static PORT_ATTR_RO(lid_mask_count);
+static PORT_ATTR_RO(sm_lid);
+static PORT_ATTR_RO(sm_sl);
+static PORT_ATTR_RO(cap_mask);
+static PORT_ATTR_RO(rate);
+static PORT_ATTR_RO(phys_state);
+static PORT_ATTR_RO(link_layer);
+
+static struct attribute *port_default_attrs[] = {
+ &port_attr_state.attr,
+ &port_attr_lid.attr,
+ &port_attr_lid_mask_count.attr,
+ &port_attr_sm_lid.attr,
+ &port_attr_sm_sl.attr,
+ &port_attr_cap_mask.attr,
+ &port_attr_rate.attr,
+ &port_attr_phys_state.attr,
+ &port_attr_link_layer.attr,
+ NULL
+};
+
+static size_t print_ndev(struct ib_gid_attr *gid_attr, char *buf)
+{
+ if (!gid_attr->ndev)
+ return -EINVAL;
+
+ return sprintf(buf, "%s\n", if_name(gid_attr->ndev));
+}
+
+static size_t print_gid_type(struct ib_gid_attr *gid_attr, char *buf)
+{
+ return sprintf(buf, "%s\n", ib_cache_gid_type_str(gid_attr->gid_type));
+}
+
+static ssize_t _show_port_gid_attr(struct ib_port *p,
+ struct port_attribute *attr,
+ char *buf,
+ size_t (*print)(struct ib_gid_attr *gid_attr,
+ char *buf))
+{
+ struct port_table_attribute *tab_attr =
+ container_of(attr, struct port_table_attribute, attr);
+ union ib_gid gid;
+ struct ib_gid_attr gid_attr = {};
+ ssize_t ret;
+
+ ret = ib_query_gid(p->ibdev, p->port_num, tab_attr->index, &gid,
+ &gid_attr);
+ if (ret)
+ goto err;
+
+ ret = print(&gid_attr, buf);
+
+err:
+ if (gid_attr.ndev)
+ dev_put(gid_attr.ndev);
+ return ret;
+}
+
+static ssize_t show_port_gid(struct ib_port *p, struct port_attribute *attr,
+ char *buf)
+{
+ struct port_table_attribute *tab_attr =
+ container_of(attr, struct port_table_attribute, attr);
+ union ib_gid gid;
+ ssize_t ret;
+
+ ret = ib_query_gid(p->ibdev, p->port_num, tab_attr->index, &gid, NULL);
+ if (ret)
+ return ret;
+
+ return sprintf(buf, GID_PRINT_FMT"\n", GID_PRINT_ARGS(gid.raw));
+}
+
+static ssize_t show_port_gid_attr_ndev(struct ib_port *p,
+ struct port_attribute *attr, char *buf)
+{
+ return _show_port_gid_attr(p, attr, buf, print_ndev);
+}
+
+static ssize_t show_port_gid_attr_gid_type(struct ib_port *p,
+ struct port_attribute *attr,
+ char *buf)
+{
+ return _show_port_gid_attr(p, attr, buf, print_gid_type);
+}
+
+static ssize_t show_port_pkey(struct ib_port *p, struct port_attribute *attr,
+ char *buf)
+{
+ struct port_table_attribute *tab_attr =
+ container_of(attr, struct port_table_attribute, attr);
+ u16 pkey;
+ ssize_t ret;
+
+ ret = ib_query_pkey(p->ibdev, p->port_num, tab_attr->index, &pkey);
+ if (ret)
+ return ret;
+
+ return sprintf(buf, "0x%04x\n", pkey);
+}
+
+#define PORT_PMA_ATTR(_name, _counter, _width, _offset) \
+struct port_table_attribute port_pma_attr_##_name = { \
+ .attr = __ATTR(_name, S_IRUGO, show_pma_counter, NULL), \
+ .index = (_offset) | ((_width) << 16) | ((_counter) << 24), \
+ .attr_id = IB_PMA_PORT_COUNTERS , \
+}
+
+#define PORT_PMA_ATTR_EXT(_name, _width, _offset) \
+struct port_table_attribute port_pma_attr_ext_##_name = { \
+ .attr = __ATTR(_name, S_IRUGO, show_pma_counter, NULL), \
+ .index = (_offset) | ((_width) << 16), \
+ .attr_id = IB_PMA_PORT_COUNTERS_EXT , \
+}
+
+/*
+ * Get a Perfmgmt MAD block of data.
+ * Returns error code or the number of bytes retrieved.
+ */
+static int get_perf_mad(struct ib_device *dev, int port_num, __be16 attr,
+ void *data, int offset, size_t size)
+{
+ struct ib_mad *in_mad;
+ struct ib_mad *out_mad;
+ size_t mad_size = sizeof(*out_mad);
+ u16 out_mad_pkey_index = 0;
+ ssize_t ret;
+
+ if (!dev->process_mad)
+ return -ENOSYS;
+
+ in_mad = kzalloc(sizeof *in_mad, GFP_KERNEL);
+ out_mad = kmalloc(sizeof *out_mad, GFP_KERNEL);
+ if (!in_mad || !out_mad) {
+ ret = -ENOMEM;
+ goto out;
+ }
+
+ in_mad->mad_hdr.base_version = 1;
+ in_mad->mad_hdr.mgmt_class = IB_MGMT_CLASS_PERF_MGMT;
+ in_mad->mad_hdr.class_version = 1;
+ in_mad->mad_hdr.method = IB_MGMT_METHOD_GET;
+ in_mad->mad_hdr.attr_id = attr;
+
+ if (attr != IB_PMA_CLASS_PORT_INFO)
+ in_mad->data[41] = port_num; /* PortSelect field */
+
+ if ((dev->process_mad(dev, IB_MAD_IGNORE_MKEY,
+ port_num, NULL, NULL,
+ (const struct ib_mad_hdr *)in_mad, mad_size,
+ (struct ib_mad_hdr *)out_mad, &mad_size,
+ &out_mad_pkey_index) &
+ (IB_MAD_RESULT_SUCCESS | IB_MAD_RESULT_REPLY)) !=
+ (IB_MAD_RESULT_SUCCESS | IB_MAD_RESULT_REPLY)) {
+ ret = -EINVAL;
+ goto out;
+ }
+ memcpy(data, out_mad->data + offset, size);
+ ret = size;
+out:
+ kfree(in_mad);
+ kfree(out_mad);
+ return ret;
+}
+
+static ssize_t show_pma_counter(struct ib_port *p, struct port_attribute *attr,
+ char *buf)
+{
+ struct port_table_attribute *tab_attr =
+ container_of(attr, struct port_table_attribute, attr);
+ int offset = tab_attr->index & 0xffff;
+ int width = (tab_attr->index >> 16) & 0xff;
+ ssize_t ret;
+ u8 data[8];
+
+ ret = get_perf_mad(p->ibdev, p->port_num, tab_attr->attr_id, &data,
+ 40 + offset / 8, sizeof(data));
+ if (ret < 0)
+ return sprintf(buf, "N/A (no PMA)\n");
+
+ switch (width) {
+ case 4:
+ ret = sprintf(buf, "%u\n", (*data >>
+ (4 - (offset % 8))) & 0xf);
+ break;
+ case 8:
+ ret = sprintf(buf, "%u\n", *data);
+ break;
+ case 16:
+ ret = sprintf(buf, "%u\n",
+ be16_to_cpup((__be16 *)data));
+ break;
+ case 32:
+ ret = sprintf(buf, "%u\n",
+ be32_to_cpup((__be32 *)data));
+ break;
+ case 64:
+ ret = sprintf(buf, "%llu\n",
+ (unsigned long long)be64_to_cpup((__be64 *)data));
+ break;
+
+ default:
+ ret = 0;
+ }
+
+ return ret;
+}
+
+static PORT_PMA_ATTR(symbol_error , 0, 16, 32);
+static PORT_PMA_ATTR(link_error_recovery , 1, 8, 48);
+static PORT_PMA_ATTR(link_downed , 2, 8, 56);
+static PORT_PMA_ATTR(port_rcv_errors , 3, 16, 64);
+static PORT_PMA_ATTR(port_rcv_remote_physical_errors, 4, 16, 80);
+static PORT_PMA_ATTR(port_rcv_switch_relay_errors , 5, 16, 96);
+static PORT_PMA_ATTR(port_xmit_discards , 6, 16, 112);
+static PORT_PMA_ATTR(port_xmit_constraint_errors , 7, 8, 128);
+static PORT_PMA_ATTR(port_rcv_constraint_errors , 8, 8, 136);
+static PORT_PMA_ATTR(local_link_integrity_errors , 9, 4, 152);
+static PORT_PMA_ATTR(excessive_buffer_overrun_errors, 10, 4, 156);
+static PORT_PMA_ATTR(VL15_dropped , 11, 16, 176);
+static PORT_PMA_ATTR(port_xmit_data , 12, 32, 192);
+static PORT_PMA_ATTR(port_rcv_data , 13, 32, 224);
+static PORT_PMA_ATTR(port_xmit_packets , 14, 32, 256);
+static PORT_PMA_ATTR(port_rcv_packets , 15, 32, 288);
+static PORT_PMA_ATTR(port_xmit_wait , 0, 32, 320);
+
+/*
+ * Counters added by extended set
+ */
+static PORT_PMA_ATTR_EXT(port_xmit_data , 64, 64);
+static PORT_PMA_ATTR_EXT(port_rcv_data , 64, 128);
+static PORT_PMA_ATTR_EXT(port_xmit_packets , 64, 192);
+static PORT_PMA_ATTR_EXT(port_rcv_packets , 64, 256);
+static PORT_PMA_ATTR_EXT(unicast_xmit_packets , 64, 320);
+static PORT_PMA_ATTR_EXT(unicast_rcv_packets , 64, 384);
+static PORT_PMA_ATTR_EXT(multicast_xmit_packets , 64, 448);
+static PORT_PMA_ATTR_EXT(multicast_rcv_packets , 64, 512);
+
+static struct attribute *pma_attrs[] = {
+ &port_pma_attr_symbol_error.attr.attr,
+ &port_pma_attr_link_error_recovery.attr.attr,
+ &port_pma_attr_link_downed.attr.attr,
+ &port_pma_attr_port_rcv_errors.attr.attr,
+ &port_pma_attr_port_rcv_remote_physical_errors.attr.attr,
+ &port_pma_attr_port_rcv_switch_relay_errors.attr.attr,
+ &port_pma_attr_port_xmit_discards.attr.attr,
+ &port_pma_attr_port_xmit_constraint_errors.attr.attr,
+ &port_pma_attr_port_rcv_constraint_errors.attr.attr,
+ &port_pma_attr_local_link_integrity_errors.attr.attr,
+ &port_pma_attr_excessive_buffer_overrun_errors.attr.attr,
+ &port_pma_attr_VL15_dropped.attr.attr,
+ &port_pma_attr_port_xmit_data.attr.attr,
+ &port_pma_attr_port_rcv_data.attr.attr,
+ &port_pma_attr_port_xmit_packets.attr.attr,
+ &port_pma_attr_port_rcv_packets.attr.attr,
+ &port_pma_attr_port_xmit_wait.attr.attr,
+ NULL
+};
+
+static struct attribute *pma_attrs_ext[] = {
+ &port_pma_attr_symbol_error.attr.attr,
+ &port_pma_attr_link_error_recovery.attr.attr,
+ &port_pma_attr_link_downed.attr.attr,
+ &port_pma_attr_port_rcv_errors.attr.attr,
+ &port_pma_attr_port_rcv_remote_physical_errors.attr.attr,
+ &port_pma_attr_port_rcv_switch_relay_errors.attr.attr,
+ &port_pma_attr_port_xmit_discards.attr.attr,
+ &port_pma_attr_port_xmit_constraint_errors.attr.attr,
+ &port_pma_attr_port_rcv_constraint_errors.attr.attr,
+ &port_pma_attr_local_link_integrity_errors.attr.attr,
+ &port_pma_attr_excessive_buffer_overrun_errors.attr.attr,
+ &port_pma_attr_VL15_dropped.attr.attr,
+ &port_pma_attr_ext_port_xmit_data.attr.attr,
+ &port_pma_attr_ext_port_rcv_data.attr.attr,
+ &port_pma_attr_ext_port_xmit_packets.attr.attr,
+ &port_pma_attr_port_xmit_wait.attr.attr,
+ &port_pma_attr_ext_port_rcv_packets.attr.attr,
+ &port_pma_attr_ext_unicast_rcv_packets.attr.attr,
+ &port_pma_attr_ext_unicast_xmit_packets.attr.attr,
+ &port_pma_attr_ext_multicast_rcv_packets.attr.attr,
+ &port_pma_attr_ext_multicast_xmit_packets.attr.attr,
+ NULL
+};
+
+static struct attribute *pma_attrs_noietf[] = {
+ &port_pma_attr_symbol_error.attr.attr,
+ &port_pma_attr_link_error_recovery.attr.attr,
+ &port_pma_attr_link_downed.attr.attr,
+ &port_pma_attr_port_rcv_errors.attr.attr,
+ &port_pma_attr_port_rcv_remote_physical_errors.attr.attr,
+ &port_pma_attr_port_rcv_switch_relay_errors.attr.attr,
+ &port_pma_attr_port_xmit_discards.attr.attr,
+ &port_pma_attr_port_xmit_constraint_errors.attr.attr,
+ &port_pma_attr_port_rcv_constraint_errors.attr.attr,
+ &port_pma_attr_local_link_integrity_errors.attr.attr,
+ &port_pma_attr_excessive_buffer_overrun_errors.attr.attr,
+ &port_pma_attr_VL15_dropped.attr.attr,
+ &port_pma_attr_ext_port_xmit_data.attr.attr,
+ &port_pma_attr_ext_port_rcv_data.attr.attr,
+ &port_pma_attr_ext_port_xmit_packets.attr.attr,
+ &port_pma_attr_ext_port_rcv_packets.attr.attr,
+ &port_pma_attr_port_xmit_wait.attr.attr,
+ NULL
+};
+
+static struct attribute_group pma_group = {
+ .name = "counters",
+ .attrs = pma_attrs
+};
+
+static struct attribute_group pma_group_ext = {
+ .name = "counters",
+ .attrs = pma_attrs_ext
+};
+
+static struct attribute_group pma_group_noietf = {
+ .name = "counters",
+ .attrs = pma_attrs_noietf
+};
+
+static void ib_port_release(struct kobject *kobj)
+{
+ struct ib_port *p = container_of(kobj, struct ib_port, kobj);
+ struct attribute *a;
+ int i;
+
+ if (p->gid_group.attrs) {
+ for (i = 0; (a = p->gid_group.attrs[i]); ++i)
+ kfree(a);
+
+ kfree(p->gid_group.attrs);
+ }
+
+ if (p->pkey_group.attrs) {
+ for (i = 0; (a = p->pkey_group.attrs[i]); ++i)
+ kfree(a);
+
+ kfree(p->pkey_group.attrs);
+ }
+
+ kfree(p);
+}
+
+static void ib_port_gid_attr_release(struct kobject *kobj)
+{
+ struct gid_attr_group *g = container_of(kobj, struct gid_attr_group,
+ kobj);
+ struct attribute *a;
+ int i;
+
+ if (g->ndev.attrs) {
+ for (i = 0; (a = g->ndev.attrs[i]); ++i)
+ kfree(a);
+
+ kfree(g->ndev.attrs);
+ }
+
+ if (g->type.attrs) {
+ for (i = 0; (a = g->type.attrs[i]); ++i)
+ kfree(a);
+
+ kfree(g->type.attrs);
+ }
+
+ kfree(g);
+}
+
+static struct kobj_type port_type = {
+ .release = ib_port_release,
+ .sysfs_ops = &port_sysfs_ops,
+ .default_attrs = port_default_attrs
+};
+
+static struct kobj_type gid_attr_type = {
+ .sysfs_ops = &gid_attr_sysfs_ops,
+ .release = ib_port_gid_attr_release
+};
+
+static struct attribute **
+alloc_group_attrs(ssize_t (*show)(struct ib_port *,
+ struct port_attribute *, char *buf),
+ int len)
+{
+ struct attribute **tab_attr;
+ struct port_table_attribute *element;
+ int i;
+
+ tab_attr = kcalloc(1 + len, sizeof(struct attribute *), GFP_KERNEL);
+ if (!tab_attr)
+ return NULL;
+
+ for (i = 0; i < len; i++) {
+ element = kzalloc(sizeof(struct port_table_attribute),
+ GFP_KERNEL);
+ if (!element)
+ goto err;
+
+ if (snprintf(element->name, sizeof(element->name),
+ "%d", i) >= sizeof(element->name)) {
+ kfree(element);
+ goto err;
+ }
+
+ element->attr.attr.name = element->name;
+ element->attr.attr.mode = S_IRUGO;
+ element->attr.show = show;
+ element->index = i;
+ sysfs_attr_init(&element->attr.attr);
+
+ tab_attr[i] = &element->attr.attr;
+ }
+
+ return tab_attr;
+
+err:
+ while (--i >= 0)
+ kfree(tab_attr[i]);
+ kfree(tab_attr);
+ return NULL;
+}
+
+/*
+ * Figure out which counter table to use depending on
+ * the device capabilities.
+ */
+static struct attribute_group *get_counter_table(struct ib_device *dev,
+ int port_num)
+{
+ struct ib_class_port_info cpi;
+
+ if (get_perf_mad(dev, port_num, IB_PMA_CLASS_PORT_INFO,
+ &cpi, 40, sizeof(cpi)) >= 0) {
+ if (cpi.capability_mask & IB_PMA_CLASS_CAP_EXT_WIDTH)
+ /* We have extended counters */
+ return &pma_group_ext;
+
+ if (cpi.capability_mask & IB_PMA_CLASS_CAP_EXT_WIDTH_NOIETF)
+ /* But not the IETF ones */
+ return &pma_group_noietf;
+ }
+
+ /* Fall back to normal counters */
+ return &pma_group;
+}
+
+static int update_hw_stats(struct ib_device *dev, struct rdma_hw_stats *stats,
+ u8 port_num, int index)
+{
+ int ret;
+
+ if (time_is_after_eq_jiffies(stats->timestamp + stats->lifespan))
+ return 0;
+ ret = dev->get_hw_stats(dev, stats, port_num, index);
+ if (ret < 0)
+ return ret;
+ if (ret == stats->num_counters)
+ stats->timestamp = jiffies;
+
+ return 0;
+}
+
+static ssize_t print_hw_stat(struct rdma_hw_stats *stats, int index, char *buf)
+{
+ return sprintf(buf, "%llu\n", (unsigned long long)stats->value[index]);
+}
+
+static ssize_t show_hw_stats(struct kobject *kobj, struct attribute *attr,
+ char *buf)
+{
+ struct ib_device *dev;
+ struct ib_port *port;
+ struct hw_stats_attribute *hsa;
+ struct rdma_hw_stats *stats;
+ int ret;
+
+ hsa = container_of(attr, struct hw_stats_attribute, attr);
+ if (!hsa->port_num) {
+ dev = container_of((struct device *)kobj,
+ struct ib_device, dev);
+ stats = dev->hw_stats;
+ } else {
+ port = container_of(kobj, struct ib_port, kobj);
+ dev = port->ibdev;
+ stats = port->hw_stats;
+ }
+ ret = update_hw_stats(dev, stats, hsa->port_num, hsa->index);
+ if (ret)
+ return ret;
+ return print_hw_stat(stats, hsa->index, buf);
+}
+
+static ssize_t show_stats_lifespan(struct kobject *kobj,
+ struct attribute *attr,
+ char *buf)
+{
+ struct hw_stats_attribute *hsa;
+ int msecs;
+
+ hsa = container_of(attr, struct hw_stats_attribute, attr);
+ if (!hsa->port_num) {
+ struct ib_device *dev = container_of((struct device *)kobj,
+ struct ib_device, dev);
+ msecs = jiffies_to_msecs(dev->hw_stats->lifespan);
+ } else {
+ struct ib_port *p = container_of(kobj, struct ib_port, kobj);
+ msecs = jiffies_to_msecs(p->hw_stats->lifespan);
+ }
+ return sprintf(buf, "%d\n", msecs);
+}
+
+static ssize_t set_stats_lifespan(struct kobject *kobj,
+ struct attribute *attr,
+ const char *buf, size_t count)
+{
+ struct hw_stats_attribute *hsa;
+ int msecs;
+ int jiffies;
+ int ret;
+
+ ret = kstrtoint(buf, 10, &msecs);
+ if (ret)
+ return ret;
+ if (msecs < 0 || msecs > 10000)
+ return -EINVAL;
+ jiffies = msecs_to_jiffies(msecs);
+ hsa = container_of(attr, struct hw_stats_attribute, attr);
+ if (!hsa->port_num) {
+ struct ib_device *dev = container_of((struct device *)kobj,
+ struct ib_device, dev);
+ dev->hw_stats->lifespan = jiffies;
+ } else {
+ struct ib_port *p = container_of(kobj, struct ib_port, kobj);
+ p->hw_stats->lifespan = jiffies;
+ }
+ return count;
+}
+
+static void free_hsag(struct kobject *kobj, struct attribute_group *attr_group)
+{
+ struct attribute **attr;
+
+ sysfs_remove_group(kobj, attr_group);
+
+ for (attr = attr_group->attrs; *attr; attr++)
+ kfree(*attr);
+ kfree(attr_group);
+}
+
+static struct attribute *alloc_hsa(int index, u8 port_num, const char *name)
+{
+ struct hw_stats_attribute *hsa;
+
+ hsa = kmalloc(sizeof(*hsa), GFP_KERNEL);
+ if (!hsa)
+ return NULL;
+
+ hsa->attr.name = __DECONST(char *, name);
+ hsa->attr.mode = S_IRUGO;
+ hsa->show = show_hw_stats;
+ hsa->store = NULL;
+ hsa->index = index;
+ hsa->port_num = port_num;
+
+ return &hsa->attr;
+}
+
+static struct attribute *alloc_hsa_lifespan(char *name, u8 port_num)
+{
+ struct hw_stats_attribute *hsa;
+
+ hsa = kmalloc(sizeof(*hsa), GFP_KERNEL);
+ if (!hsa)
+ return NULL;
+
+ hsa->attr.name = name;
+ hsa->attr.mode = S_IWUSR | S_IRUGO;
+ hsa->show = show_stats_lifespan;
+ hsa->store = set_stats_lifespan;
+ hsa->index = 0;
+ hsa->port_num = port_num;
+
+ return &hsa->attr;
+}
+
+static void setup_hw_stats(struct ib_device *device, struct ib_port *port,
+ u8 port_num)
+{
+ struct attribute_group *hsag;
+ struct rdma_hw_stats *stats;
+ int i, ret;
+
+ stats = device->alloc_hw_stats(device, port_num);
+
+ if (!stats)
+ return;
+
+ if (!stats->names || stats->num_counters <= 0)
+ goto err_free_stats;
+
+ /*
+ * Two extra attribue elements here, one for the lifespan entry and
+ * one to NULL terminate the list for the sysfs core code
+ */
+ hsag = kzalloc(sizeof(*hsag) +
+ sizeof(void *) * (stats->num_counters + 2),
+ GFP_KERNEL);
+ if (!hsag)
+ goto err_free_stats;
+
+ ret = device->get_hw_stats(device, stats, port_num,
+ stats->num_counters);
+ if (ret != stats->num_counters)
+ goto err_free_hsag;
+
+ stats->timestamp = jiffies;
+
+ hsag->name = "hw_counters";
+ hsag->attrs = (void *)((char *)hsag + sizeof(*hsag));
+
+ for (i = 0; i < stats->num_counters; i++) {
+ hsag->attrs[i] = alloc_hsa(i, port_num, stats->names[i]);
+ if (!hsag->attrs[i])
+ goto err;
+ sysfs_attr_init(hsag->attrs[i]);
+ }
+
+ /* treat an error here as non-fatal */
+ hsag->attrs[i] = alloc_hsa_lifespan("lifespan", port_num);
+ if (hsag->attrs[i])
+ sysfs_attr_init(hsag->attrs[i]);
+
+ if (port) {
+ struct kobject *kobj = &port->kobj;
+ ret = sysfs_create_group(kobj, hsag);
+ if (ret)
+ goto err;
+ port->hw_stats_ag = hsag;
+ port->hw_stats = stats;
+ } else {
+ struct kobject *kobj = &device->dev.kobj;
+ ret = sysfs_create_group(kobj, hsag);
+ if (ret)
+ goto err;
+ device->hw_stats_ag = hsag;
+ device->hw_stats = stats;
+ }
+
+ return;
+
+err:
+ for (; i >= 0; i--)
+ kfree(hsag->attrs[i]);
+err_free_hsag:
+ kfree(hsag);
+err_free_stats:
+ kfree(stats);
+ return;
+}
+
+static int add_port(struct ib_device *device, int port_num,
+ int (*port_callback)(struct ib_device *,
+ u8, struct kobject *))
+{
+ struct ib_port *p;
+ struct ib_port_attr attr;
+ int i;
+ int ret;
+
+ ret = ib_query_port(device, port_num, &attr);
+ if (ret)
+ return ret;
+
+ p = kzalloc(sizeof *p, GFP_KERNEL);
+ if (!p)
+ return -ENOMEM;
+
+ p->ibdev = device;
+ p->port_num = port_num;
+
+ ret = kobject_init_and_add(&p->kobj, &port_type,
+ device->ports_parent,
+ "%d", port_num);
+ if (ret) {
+ kfree(p);
+ return ret;
+ }
+
+ p->gid_attr_group = kzalloc(sizeof(*p->gid_attr_group), GFP_KERNEL);
+ if (!p->gid_attr_group) {
+ ret = -ENOMEM;
+ goto err_put;
+ }
+
+ p->gid_attr_group->port = p;
+ ret = kobject_init_and_add(&p->gid_attr_group->kobj, &gid_attr_type,
+ &p->kobj, "gid_attrs");
+ if (ret) {
+ kfree(p->gid_attr_group);
+ goto err_put;
+ }
+
+ p->pma_table = get_counter_table(device, port_num);
+ ret = sysfs_create_group(&p->kobj, p->pma_table);
+ if (ret)
+ goto err_put_gid_attrs;
+
+ p->gid_group.name = "gids";
+ p->gid_group.attrs = alloc_group_attrs(show_port_gid, attr.gid_tbl_len);
+ if (!p->gid_group.attrs) {
+ ret = -ENOMEM;
+ goto err_remove_pma;
+ }
+
+ ret = sysfs_create_group(&p->kobj, &p->gid_group);
+ if (ret)
+ goto err_free_gid;
+
+ p->gid_attr_group->ndev.name = "ndevs";
+ p->gid_attr_group->ndev.attrs = alloc_group_attrs(show_port_gid_attr_ndev,
+ attr.gid_tbl_len);
+ if (!p->gid_attr_group->ndev.attrs) {
+ ret = -ENOMEM;
+ goto err_remove_gid;
+ }
+
+ ret = sysfs_create_group(&p->gid_attr_group->kobj,
+ &p->gid_attr_group->ndev);
+ if (ret)
+ goto err_free_gid_ndev;
+
+ p->gid_attr_group->type.name = "types";
+ p->gid_attr_group->type.attrs = alloc_group_attrs(show_port_gid_attr_gid_type,
+ attr.gid_tbl_len);
+ if (!p->gid_attr_group->type.attrs) {
+ ret = -ENOMEM;
+ goto err_remove_gid_ndev;
+ }
+
+ ret = sysfs_create_group(&p->gid_attr_group->kobj,
+ &p->gid_attr_group->type);
+ if (ret)
+ goto err_free_gid_type;
+
+ p->pkey_group.name = "pkeys";
+ p->pkey_group.attrs = alloc_group_attrs(show_port_pkey,
+ attr.pkey_tbl_len);
+ if (!p->pkey_group.attrs) {
+ ret = -ENOMEM;
+ goto err_remove_gid_type;
+ }
+
+ ret = sysfs_create_group(&p->kobj, &p->pkey_group);
+ if (ret)
+ goto err_free_pkey;
+
+ if (port_callback) {
+ ret = port_callback(device, port_num, &p->kobj);
+ if (ret)
+ goto err_remove_pkey;
+ }
+
+ /*
+ * If port == 0, it means we have only one port and the parent
+ * device, not this port device, should be the holder of the
+ * hw_counters
+ */
+ if (device->alloc_hw_stats && port_num)
+ setup_hw_stats(device, p, port_num);
+
+ list_add_tail(&p->kobj.entry, &device->port_list);
+
+ return 0;
+
+err_remove_pkey:
+ sysfs_remove_group(&p->kobj, &p->pkey_group);
+
+err_free_pkey:
+ for (i = 0; i < attr.pkey_tbl_len; ++i)
+ kfree(p->pkey_group.attrs[i]);
+
+ kfree(p->pkey_group.attrs);
+ p->pkey_group.attrs = NULL;
+
+err_remove_gid_type:
+ sysfs_remove_group(&p->gid_attr_group->kobj,
+ &p->gid_attr_group->type);
+
+err_free_gid_type:
+ for (i = 0; i < attr.gid_tbl_len; ++i)
+ kfree(p->gid_attr_group->type.attrs[i]);
+
+ kfree(p->gid_attr_group->type.attrs);
+ p->gid_attr_group->type.attrs = NULL;
+
+err_remove_gid_ndev:
+ sysfs_remove_group(&p->gid_attr_group->kobj,
+ &p->gid_attr_group->ndev);
+
+err_free_gid_ndev:
+ for (i = 0; i < attr.gid_tbl_len; ++i)
+ kfree(p->gid_attr_group->ndev.attrs[i]);
+
+ kfree(p->gid_attr_group->ndev.attrs);
+ p->gid_attr_group->ndev.attrs = NULL;
+
+err_remove_gid:
+ sysfs_remove_group(&p->kobj, &p->gid_group);
+
+err_free_gid:
+ for (i = 0; i < attr.gid_tbl_len; ++i)
+ kfree(p->gid_group.attrs[i]);
+
+ kfree(p->gid_group.attrs);
+ p->gid_group.attrs = NULL;
+
+err_remove_pma:
+ sysfs_remove_group(&p->kobj, p->pma_table);
+
+err_put_gid_attrs:
+ kobject_put(&p->gid_attr_group->kobj);
+
+err_put:
+ kobject_put(&p->kobj);
+ return ret;
+}
+
+static ssize_t show_node_type(struct device *device,
+ struct device_attribute *attr, char *buf)
+{
+ struct ib_device *dev = container_of(device, struct ib_device, dev);
+
+ switch (dev->node_type) {
+ case RDMA_NODE_IB_CA: return sprintf(buf, "%d: CA\n", dev->node_type);
+ case RDMA_NODE_RNIC: return sprintf(buf, "%d: RNIC\n", dev->node_type);
+ case RDMA_NODE_USNIC: return sprintf(buf, "%d: usNIC\n", dev->node_type);
+ case RDMA_NODE_USNIC_UDP: return sprintf(buf, "%d: usNIC UDP\n", dev->node_type);
+ case RDMA_NODE_IB_SWITCH: return sprintf(buf, "%d: switch\n", dev->node_type);
+ case RDMA_NODE_IB_ROUTER: return sprintf(buf, "%d: router\n", dev->node_type);
+ default: return sprintf(buf, "%d: <unknown>\n", dev->node_type);
+ }
+}
+
+static ssize_t show_sys_image_guid(struct device *device,
+ struct device_attribute *dev_attr, char *buf)
+{
+ struct ib_device *dev = container_of(device, struct ib_device, dev);
+
+ return sprintf(buf, "%04x:%04x:%04x:%04x\n",
+ be16_to_cpu(((__be16 *) &dev->attrs.sys_image_guid)[0]),
+ be16_to_cpu(((__be16 *) &dev->attrs.sys_image_guid)[1]),
+ be16_to_cpu(((__be16 *) &dev->attrs.sys_image_guid)[2]),
+ be16_to_cpu(((__be16 *) &dev->attrs.sys_image_guid)[3]));
+}
+
+static ssize_t show_node_guid(struct device *device,
+ struct device_attribute *attr, char *buf)
+{
+ struct ib_device *dev = container_of(device, struct ib_device, dev);
+
+ return sprintf(buf, "%04x:%04x:%04x:%04x\n",
+ be16_to_cpu(((__be16 *) &dev->node_guid)[0]),
+ be16_to_cpu(((__be16 *) &dev->node_guid)[1]),
+ be16_to_cpu(((__be16 *) &dev->node_guid)[2]),
+ be16_to_cpu(((__be16 *) &dev->node_guid)[3]));
+}
+
+static ssize_t show_node_desc(struct device *device,
+ struct device_attribute *attr, char *buf)
+{
+ struct ib_device *dev = container_of(device, struct ib_device, dev);
+
+ return sprintf(buf, "%.64s\n", dev->node_desc);
+}
+
+static ssize_t set_node_desc(struct device *device,
+ struct device_attribute *attr,
+ const char *buf, size_t count)
+{
+ struct ib_device *dev = container_of(device, struct ib_device, dev);
+ struct ib_device_modify desc = {};
+ int ret;
+
+ if (!dev->modify_device)
+ return -EIO;
+
+ memcpy(desc.node_desc, buf, min_t(int, count, IB_DEVICE_NODE_DESC_MAX));
+ ret = ib_modify_device(dev, IB_DEVICE_MODIFY_NODE_DESC, &desc);
+ if (ret)
+ return ret;
+
+ return count;
+}
+
+static ssize_t show_fw_ver(struct device *device, struct device_attribute *attr,
+ char *buf)
+{
+ struct ib_device *dev = container_of(device, struct ib_device, dev);
+
+ ib_get_device_fw_str(dev, buf, PAGE_SIZE);
+ strlcat(buf, "\n", PAGE_SIZE);
+ return strlen(buf);
+}
+
+static DEVICE_ATTR(node_type, S_IRUGO, show_node_type, NULL);
+static DEVICE_ATTR(sys_image_guid, S_IRUGO, show_sys_image_guid, NULL);
+static DEVICE_ATTR(node_guid, S_IRUGO, show_node_guid, NULL);
+static DEVICE_ATTR(node_desc, S_IRUGO | S_IWUSR, show_node_desc, set_node_desc);
+static DEVICE_ATTR(fw_ver, S_IRUGO, show_fw_ver, NULL);
+
+static struct device_attribute *ib_class_attributes[] = {
+ &dev_attr_node_type,
+ &dev_attr_sys_image_guid,
+ &dev_attr_node_guid,
+ &dev_attr_node_desc,
+ &dev_attr_fw_ver,
+};
+
+static void free_port_list_attributes(struct ib_device *device)
+{
+ struct kobject *p, *t;
+
+ list_for_each_entry_safe(p, t, &device->port_list, entry) {
+ struct ib_port *port = container_of(p, struct ib_port, kobj);
+ list_del(&p->entry);
+ if (port->hw_stats) {
+ kfree(port->hw_stats);
+ free_hsag(&port->kobj, port->hw_stats_ag);
+ }
+ sysfs_remove_group(p, port->pma_table);
+ sysfs_remove_group(p, &port->pkey_group);
+ sysfs_remove_group(p, &port->gid_group);
+ sysfs_remove_group(&port->gid_attr_group->kobj,
+ &port->gid_attr_group->ndev);
+ sysfs_remove_group(&port->gid_attr_group->kobj,
+ &port->gid_attr_group->type);
+ kobject_put(&port->gid_attr_group->kobj);
+ kobject_put(p);
+ }
+
+ kobject_put(device->ports_parent);
+}
+
+int ib_device_register_sysfs(struct ib_device *device,
+ int (*port_callback)(struct ib_device *,
+ u8, struct kobject *))
+{
+ struct device *class_dev = &device->dev;
+ int ret;
+ int i;
+
+ device->dev.parent = device->dma_device;
+ ret = dev_set_name(class_dev, "%s", device->name);
+ if (ret)
+ return ret;
+
+ ret = device_add(class_dev);
+ if (ret)
+ goto err;
+
+ for (i = 0; i < ARRAY_SIZE(ib_class_attributes); ++i) {
+ ret = device_create_file(class_dev, ib_class_attributes[i]);
+ if (ret)
+ goto err_unregister;
+ }
+
+ device->ports_parent = kobject_create_and_add("ports",
+ &class_dev->kobj);
+ if (!device->ports_parent) {
+ ret = -ENOMEM;
+ goto err_put;
+ }
+
+ if (rdma_cap_ib_switch(device)) {
+ ret = add_port(device, 0, port_callback);
+ if (ret)
+ goto err_put;
+ } else {
+ for (i = 1; i <= device->phys_port_cnt; ++i) {
+ ret = add_port(device, i, port_callback);
+ if (ret)
+ goto err_put;
+ }
+ }
+
+ if (device->alloc_hw_stats)
+ setup_hw_stats(device, NULL, 0);
+
+ return 0;
+
+err_put:
+ free_port_list_attributes(device);
+
+err_unregister:
+ device_unregister(class_dev);
+
+err:
+ return ret;
+}
+
+void ib_device_unregister_sysfs(struct ib_device *device)
+{
+ int i;
+
+ /* Hold kobject until ib_dealloc_device() */
+ kobject_get(&device->dev.kobj);
+
+ free_port_list_attributes(device);
+
+ if (device->hw_stats) {
+ kfree(device->hw_stats);
+ free_hsag(&device->dev.kobj, device->hw_stats_ag);
+ }
+
+ for (i = 0; i < ARRAY_SIZE(ib_class_attributes); ++i)
+ device_remove_file(&device->dev, ib_class_attributes[i]);
+
+ device_unregister(&device->dev);
+}
diff --git a/sys/ofed/drivers/infiniband/core/ib_ucm.c b/sys/ofed/drivers/infiniband/core/ib_ucm.c
new file mode 100644
index 0000000..edc1099
--- /dev/null
+++ b/sys/ofed/drivers/infiniband/core/ib_ucm.c
@@ -0,0 +1,1370 @@
+/*
+ * Copyright (c) 2005 Topspin Communications. All rights reserved.
+ * Copyright (c) 2005 Intel Corporation. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#include <linux/completion.h>
+#include <linux/fs.h>
+#include <linux/module.h>
+#include <linux/device.h>
+#include <linux/err.h>
+#include <linux/poll.h>
+#include <linux/sched.h>
+#include <linux/file.h>
+#include <linux/cdev.h>
+#include <linux/idr.h>
+#include <linux/mutex.h>
+#include <linux/slab.h>
+
+#include <asm/uaccess.h>
+
+#include <rdma/ib.h>
+#include <rdma/ib_cm.h>
+#include <rdma/ib_user_cm.h>
+#include <rdma/ib_marshall.h>
+
+MODULE_AUTHOR("Libor Michalek");
+MODULE_DESCRIPTION("InfiniBand userspace Connection Manager access");
+MODULE_LICENSE("Dual BSD/GPL");
+
+struct ib_ucm_device {
+ int devnum;
+ struct cdev cdev;
+ struct device dev;
+ struct ib_device *ib_dev;
+};
+
+struct ib_ucm_file {
+ struct mutex file_mutex;
+ struct file *filp;
+ struct ib_ucm_device *device;
+
+ struct list_head ctxs;
+ struct list_head events;
+ wait_queue_head_t poll_wait;
+};
+
+struct ib_ucm_context {
+ int id;
+ struct completion comp;
+ atomic_t ref;
+ int events_reported;
+
+ struct ib_ucm_file *file;
+ struct ib_cm_id *cm_id;
+ __u64 uid;
+
+ struct list_head events; /* list of pending events. */
+ struct list_head file_list; /* member in file ctx list */
+};
+
+struct ib_ucm_event {
+ struct ib_ucm_context *ctx;
+ struct list_head file_list; /* member in file event list */
+ struct list_head ctx_list; /* member in ctx event list */
+
+ struct ib_cm_id *cm_id;
+ struct ib_ucm_event_resp resp;
+ void *data;
+ void *info;
+ int data_len;
+ int info_len;
+};
+
+enum {
+ IB_UCM_MAJOR = 231,
+ IB_UCM_BASE_MINOR = 224,
+ IB_UCM_MAX_DEVICES = 32
+};
+
+#define IB_UCM_BASE_DEV MKDEV(IB_UCM_MAJOR, IB_UCM_BASE_MINOR)
+
+static void ib_ucm_add_one(struct ib_device *device);
+static void ib_ucm_remove_one(struct ib_device *device, void *client_data);
+
+static struct ib_client ucm_client = {
+ .name = "ucm",
+ .add = ib_ucm_add_one,
+ .remove = ib_ucm_remove_one
+};
+
+static DEFINE_MUTEX(ctx_id_mutex);
+static DEFINE_IDR(ctx_id_table);
+static DECLARE_BITMAP(dev_map, IB_UCM_MAX_DEVICES);
+
+static struct ib_ucm_context *ib_ucm_ctx_get(struct ib_ucm_file *file, int id)
+{
+ struct ib_ucm_context *ctx;
+
+ mutex_lock(&ctx_id_mutex);
+ ctx = idr_find(&ctx_id_table, id);
+ if (!ctx)
+ ctx = ERR_PTR(-ENOENT);
+ else if (ctx->file != file)
+ ctx = ERR_PTR(-EINVAL);
+ else
+ atomic_inc(&ctx->ref);
+ mutex_unlock(&ctx_id_mutex);
+
+ return ctx;
+}
+
+static void ib_ucm_ctx_put(struct ib_ucm_context *ctx)
+{
+ if (atomic_dec_and_test(&ctx->ref))
+ complete(&ctx->comp);
+}
+
+static inline int ib_ucm_new_cm_id(int event)
+{
+ return event == IB_CM_REQ_RECEIVED || event == IB_CM_SIDR_REQ_RECEIVED;
+}
+
+static void ib_ucm_cleanup_events(struct ib_ucm_context *ctx)
+{
+ struct ib_ucm_event *uevent;
+
+ mutex_lock(&ctx->file->file_mutex);
+ list_del(&ctx->file_list);
+ while (!list_empty(&ctx->events)) {
+
+ uevent = list_entry(ctx->events.next,
+ struct ib_ucm_event, ctx_list);
+ list_del(&uevent->file_list);
+ list_del(&uevent->ctx_list);
+ mutex_unlock(&ctx->file->file_mutex);
+
+ /* clear incoming connections. */
+ if (ib_ucm_new_cm_id(uevent->resp.event))
+ ib_destroy_cm_id(uevent->cm_id);
+
+ kfree(uevent);
+ mutex_lock(&ctx->file->file_mutex);
+ }
+ mutex_unlock(&ctx->file->file_mutex);
+}
+
+static struct ib_ucm_context *ib_ucm_ctx_alloc(struct ib_ucm_file *file)
+{
+ struct ib_ucm_context *ctx;
+
+ ctx = kzalloc(sizeof *ctx, GFP_KERNEL);
+ if (!ctx)
+ return NULL;
+
+ atomic_set(&ctx->ref, 1);
+ init_completion(&ctx->comp);
+ ctx->file = file;
+ INIT_LIST_HEAD(&ctx->events);
+
+ mutex_lock(&ctx_id_mutex);
+ ctx->id = idr_alloc(&ctx_id_table, ctx, 0, 0, GFP_KERNEL);
+ mutex_unlock(&ctx_id_mutex);
+ if (ctx->id < 0)
+ goto error;
+
+ list_add_tail(&ctx->file_list, &file->ctxs);
+ return ctx;
+
+error:
+ kfree(ctx);
+ return NULL;
+}
+
+static void ib_ucm_event_req_get(struct ib_ucm_req_event_resp *ureq,
+ struct ib_cm_req_event_param *kreq)
+{
+ ureq->remote_ca_guid = kreq->remote_ca_guid;
+ ureq->remote_qkey = kreq->remote_qkey;
+ ureq->remote_qpn = kreq->remote_qpn;
+ ureq->qp_type = kreq->qp_type;
+ ureq->starting_psn = kreq->starting_psn;
+ ureq->responder_resources = kreq->responder_resources;
+ ureq->initiator_depth = kreq->initiator_depth;
+ ureq->local_cm_response_timeout = kreq->local_cm_response_timeout;
+ ureq->flow_control = kreq->flow_control;
+ ureq->remote_cm_response_timeout = kreq->remote_cm_response_timeout;
+ ureq->retry_count = kreq->retry_count;
+ ureq->rnr_retry_count = kreq->rnr_retry_count;
+ ureq->srq = kreq->srq;
+ ureq->port = kreq->port;
+
+ ib_copy_path_rec_to_user(&ureq->primary_path, kreq->primary_path);
+ if (kreq->alternate_path)
+ ib_copy_path_rec_to_user(&ureq->alternate_path,
+ kreq->alternate_path);
+}
+
+static void ib_ucm_event_rep_get(struct ib_ucm_rep_event_resp *urep,
+ struct ib_cm_rep_event_param *krep)
+{
+ urep->remote_ca_guid = krep->remote_ca_guid;
+ urep->remote_qkey = krep->remote_qkey;
+ urep->remote_qpn = krep->remote_qpn;
+ urep->starting_psn = krep->starting_psn;
+ urep->responder_resources = krep->responder_resources;
+ urep->initiator_depth = krep->initiator_depth;
+ urep->target_ack_delay = krep->target_ack_delay;
+ urep->failover_accepted = krep->failover_accepted;
+ urep->flow_control = krep->flow_control;
+ urep->rnr_retry_count = krep->rnr_retry_count;
+ urep->srq = krep->srq;
+}
+
+static void ib_ucm_event_sidr_rep_get(struct ib_ucm_sidr_rep_event_resp *urep,
+ struct ib_cm_sidr_rep_event_param *krep)
+{
+ urep->status = krep->status;
+ urep->qkey = krep->qkey;
+ urep->qpn = krep->qpn;
+};
+
+static int ib_ucm_event_process(struct ib_cm_event *evt,
+ struct ib_ucm_event *uvt)
+{
+ void *info = NULL;
+
+ switch (evt->event) {
+ case IB_CM_REQ_RECEIVED:
+ ib_ucm_event_req_get(&uvt->resp.u.req_resp,
+ &evt->param.req_rcvd);
+ uvt->data_len = IB_CM_REQ_PRIVATE_DATA_SIZE;
+ uvt->resp.present = IB_UCM_PRES_PRIMARY;
+ uvt->resp.present |= (evt->param.req_rcvd.alternate_path ?
+ IB_UCM_PRES_ALTERNATE : 0);
+ break;
+ case IB_CM_REP_RECEIVED:
+ ib_ucm_event_rep_get(&uvt->resp.u.rep_resp,
+ &evt->param.rep_rcvd);
+ uvt->data_len = IB_CM_REP_PRIVATE_DATA_SIZE;
+ break;
+ case IB_CM_RTU_RECEIVED:
+ uvt->data_len = IB_CM_RTU_PRIVATE_DATA_SIZE;
+ uvt->resp.u.send_status = evt->param.send_status;
+ break;
+ case IB_CM_DREQ_RECEIVED:
+ uvt->data_len = IB_CM_DREQ_PRIVATE_DATA_SIZE;
+ uvt->resp.u.send_status = evt->param.send_status;
+ break;
+ case IB_CM_DREP_RECEIVED:
+ uvt->data_len = IB_CM_DREP_PRIVATE_DATA_SIZE;
+ uvt->resp.u.send_status = evt->param.send_status;
+ break;
+ case IB_CM_MRA_RECEIVED:
+ uvt->resp.u.mra_resp.timeout =
+ evt->param.mra_rcvd.service_timeout;
+ uvt->data_len = IB_CM_MRA_PRIVATE_DATA_SIZE;
+ break;
+ case IB_CM_REJ_RECEIVED:
+ uvt->resp.u.rej_resp.reason = evt->param.rej_rcvd.reason;
+ uvt->data_len = IB_CM_REJ_PRIVATE_DATA_SIZE;
+ uvt->info_len = evt->param.rej_rcvd.ari_length;
+ info = evt->param.rej_rcvd.ari;
+ break;
+ case IB_CM_LAP_RECEIVED:
+ ib_copy_path_rec_to_user(&uvt->resp.u.lap_resp.path,
+ evt->param.lap_rcvd.alternate_path);
+ uvt->data_len = IB_CM_LAP_PRIVATE_DATA_SIZE;
+ uvt->resp.present = IB_UCM_PRES_ALTERNATE;
+ break;
+ case IB_CM_APR_RECEIVED:
+ uvt->resp.u.apr_resp.status = evt->param.apr_rcvd.ap_status;
+ uvt->data_len = IB_CM_APR_PRIVATE_DATA_SIZE;
+ uvt->info_len = evt->param.apr_rcvd.info_len;
+ info = evt->param.apr_rcvd.apr_info;
+ break;
+ case IB_CM_SIDR_REQ_RECEIVED:
+ uvt->resp.u.sidr_req_resp.pkey =
+ evt->param.sidr_req_rcvd.pkey;
+ uvt->resp.u.sidr_req_resp.port =
+ evt->param.sidr_req_rcvd.port;
+ uvt->data_len = IB_CM_SIDR_REQ_PRIVATE_DATA_SIZE;
+ break;
+ case IB_CM_SIDR_REP_RECEIVED:
+ ib_ucm_event_sidr_rep_get(&uvt->resp.u.sidr_rep_resp,
+ &evt->param.sidr_rep_rcvd);
+ uvt->data_len = IB_CM_SIDR_REP_PRIVATE_DATA_SIZE;
+ uvt->info_len = evt->param.sidr_rep_rcvd.info_len;
+ info = evt->param.sidr_rep_rcvd.info;
+ break;
+ default:
+ uvt->resp.u.send_status = evt->param.send_status;
+ break;
+ }
+
+ if (uvt->data_len) {
+ uvt->data = kmemdup(evt->private_data, uvt->data_len, GFP_KERNEL);
+ if (!uvt->data)
+ goto err1;
+
+ uvt->resp.present |= IB_UCM_PRES_DATA;
+ }
+
+ if (uvt->info_len) {
+ uvt->info = kmemdup(info, uvt->info_len, GFP_KERNEL);
+ if (!uvt->info)
+ goto err2;
+
+ uvt->resp.present |= IB_UCM_PRES_INFO;
+ }
+ return 0;
+
+err2:
+ kfree(uvt->data);
+err1:
+ return -ENOMEM;
+}
+
+static int ib_ucm_event_handler(struct ib_cm_id *cm_id,
+ struct ib_cm_event *event)
+{
+ struct ib_ucm_event *uevent;
+ struct ib_ucm_context *ctx;
+ int result = 0;
+
+ ctx = cm_id->context;
+
+ uevent = kzalloc(sizeof *uevent, GFP_KERNEL);
+ if (!uevent)
+ goto err1;
+
+ uevent->ctx = ctx;
+ uevent->cm_id = cm_id;
+ uevent->resp.uid = ctx->uid;
+ uevent->resp.id = ctx->id;
+ uevent->resp.event = event->event;
+
+ result = ib_ucm_event_process(event, uevent);
+ if (result)
+ goto err2;
+
+ mutex_lock(&ctx->file->file_mutex);
+ list_add_tail(&uevent->file_list, &ctx->file->events);
+ list_add_tail(&uevent->ctx_list, &ctx->events);
+ wake_up_interruptible(&ctx->file->poll_wait);
+ mutex_unlock(&ctx->file->file_mutex);
+ return 0;
+
+err2:
+ kfree(uevent);
+err1:
+ /* Destroy new cm_id's */
+ return ib_ucm_new_cm_id(event->event);
+}
+
+static ssize_t ib_ucm_event(struct ib_ucm_file *file,
+ const char __user *inbuf,
+ int in_len, int out_len)
+{
+ struct ib_ucm_context *ctx;
+ struct ib_ucm_event_get cmd;
+ struct ib_ucm_event *uevent;
+ int result = 0;
+
+ if (out_len < sizeof(struct ib_ucm_event_resp))
+ return -ENOSPC;
+
+ if (copy_from_user(&cmd, inbuf, sizeof(cmd)))
+ return -EFAULT;
+
+ mutex_lock(&file->file_mutex);
+ while (list_empty(&file->events)) {
+ mutex_unlock(&file->file_mutex);
+
+ if (file->filp->f_flags & O_NONBLOCK)
+ return -EAGAIN;
+
+ if (wait_event_interruptible(file->poll_wait,
+ !list_empty(&file->events)))
+ return -ERESTARTSYS;
+
+ mutex_lock(&file->file_mutex);
+ }
+
+ uevent = list_entry(file->events.next, struct ib_ucm_event, file_list);
+
+ if (ib_ucm_new_cm_id(uevent->resp.event)) {
+ ctx = ib_ucm_ctx_alloc(file);
+ if (!ctx) {
+ result = -ENOMEM;
+ goto done;
+ }
+
+ ctx->cm_id = uevent->cm_id;
+ ctx->cm_id->context = ctx;
+ uevent->resp.id = ctx->id;
+ }
+
+ if (copy_to_user((void __user *)(unsigned long)cmd.response,
+ &uevent->resp, sizeof(uevent->resp))) {
+ result = -EFAULT;
+ goto done;
+ }
+
+ if (uevent->data) {
+ if (cmd.data_len < uevent->data_len) {
+ result = -ENOMEM;
+ goto done;
+ }
+ if (copy_to_user((void __user *)(unsigned long)cmd.data,
+ uevent->data, uevent->data_len)) {
+ result = -EFAULT;
+ goto done;
+ }
+ }
+
+ if (uevent->info) {
+ if (cmd.info_len < uevent->info_len) {
+ result = -ENOMEM;
+ goto done;
+ }
+ if (copy_to_user((void __user *)(unsigned long)cmd.info,
+ uevent->info, uevent->info_len)) {
+ result = -EFAULT;
+ goto done;
+ }
+ }
+
+ list_del(&uevent->file_list);
+ list_del(&uevent->ctx_list);
+ uevent->ctx->events_reported++;
+
+ kfree(uevent->data);
+ kfree(uevent->info);
+ kfree(uevent);
+done:
+ mutex_unlock(&file->file_mutex);
+ return result;
+}
+
+static ssize_t ib_ucm_create_id(struct ib_ucm_file *file,
+ const char __user *inbuf,
+ int in_len, int out_len)
+{
+ struct ib_ucm_create_id cmd;
+ struct ib_ucm_create_id_resp resp;
+ struct ib_ucm_context *ctx;
+ int result;
+
+ if (out_len < sizeof(resp))
+ return -ENOSPC;
+
+ if (copy_from_user(&cmd, inbuf, sizeof(cmd)))
+ return -EFAULT;
+
+ mutex_lock(&file->file_mutex);
+ ctx = ib_ucm_ctx_alloc(file);
+ mutex_unlock(&file->file_mutex);
+ if (!ctx)
+ return -ENOMEM;
+
+ ctx->uid = cmd.uid;
+ ctx->cm_id = ib_create_cm_id(file->device->ib_dev,
+ ib_ucm_event_handler, ctx);
+ if (IS_ERR(ctx->cm_id)) {
+ result = PTR_ERR(ctx->cm_id);
+ goto err1;
+ }
+
+ resp.id = ctx->id;
+ if (copy_to_user((void __user *)(unsigned long)cmd.response,
+ &resp, sizeof(resp))) {
+ result = -EFAULT;
+ goto err2;
+ }
+ return 0;
+
+err2:
+ ib_destroy_cm_id(ctx->cm_id);
+err1:
+ mutex_lock(&ctx_id_mutex);
+ idr_remove(&ctx_id_table, ctx->id);
+ mutex_unlock(&ctx_id_mutex);
+ kfree(ctx);
+ return result;
+}
+
+static ssize_t ib_ucm_destroy_id(struct ib_ucm_file *file,
+ const char __user *inbuf,
+ int in_len, int out_len)
+{
+ struct ib_ucm_destroy_id cmd;
+ struct ib_ucm_destroy_id_resp resp;
+ struct ib_ucm_context *ctx;
+ int result = 0;
+
+ if (out_len < sizeof(resp))
+ return -ENOSPC;
+
+ if (copy_from_user(&cmd, inbuf, sizeof(cmd)))
+ return -EFAULT;
+
+ mutex_lock(&ctx_id_mutex);
+ ctx = idr_find(&ctx_id_table, cmd.id);
+ if (!ctx)
+ ctx = ERR_PTR(-ENOENT);
+ else if (ctx->file != file)
+ ctx = ERR_PTR(-EINVAL);
+ else
+ idr_remove(&ctx_id_table, ctx->id);
+ mutex_unlock(&ctx_id_mutex);
+
+ if (IS_ERR(ctx))
+ return PTR_ERR(ctx);
+
+ ib_ucm_ctx_put(ctx);
+ wait_for_completion(&ctx->comp);
+
+ /* No new events will be generated after destroying the cm_id. */
+ ib_destroy_cm_id(ctx->cm_id);
+ /* Cleanup events not yet reported to the user. */
+ ib_ucm_cleanup_events(ctx);
+
+ resp.events_reported = ctx->events_reported;
+ if (copy_to_user((void __user *)(unsigned long)cmd.response,
+ &resp, sizeof(resp)))
+ result = -EFAULT;
+
+ kfree(ctx);
+ return result;
+}
+
+static ssize_t ib_ucm_attr_id(struct ib_ucm_file *file,
+ const char __user *inbuf,
+ int in_len, int out_len)
+{
+ struct ib_ucm_attr_id_resp resp;
+ struct ib_ucm_attr_id cmd;
+ struct ib_ucm_context *ctx;
+ int result = 0;
+
+ if (out_len < sizeof(resp))
+ return -ENOSPC;
+
+ if (copy_from_user(&cmd, inbuf, sizeof(cmd)))
+ return -EFAULT;
+
+ ctx = ib_ucm_ctx_get(file, cmd.id);
+ if (IS_ERR(ctx))
+ return PTR_ERR(ctx);
+
+ resp.service_id = ctx->cm_id->service_id;
+ resp.service_mask = ctx->cm_id->service_mask;
+ resp.local_id = ctx->cm_id->local_id;
+ resp.remote_id = ctx->cm_id->remote_id;
+
+ if (copy_to_user((void __user *)(unsigned long)cmd.response,
+ &resp, sizeof(resp)))
+ result = -EFAULT;
+
+ ib_ucm_ctx_put(ctx);
+ return result;
+}
+
+static ssize_t ib_ucm_init_qp_attr(struct ib_ucm_file *file,
+ const char __user *inbuf,
+ int in_len, int out_len)
+{
+ struct ib_uverbs_qp_attr resp;
+ struct ib_ucm_init_qp_attr cmd;
+ struct ib_ucm_context *ctx;
+ struct ib_qp_attr qp_attr;
+ int result = 0;
+
+ if (out_len < sizeof(resp))
+ return -ENOSPC;
+
+ if (copy_from_user(&cmd, inbuf, sizeof(cmd)))
+ return -EFAULT;
+
+ ctx = ib_ucm_ctx_get(file, cmd.id);
+ if (IS_ERR(ctx))
+ return PTR_ERR(ctx);
+
+ resp.qp_attr_mask = 0;
+ memset(&qp_attr, 0, sizeof qp_attr);
+ qp_attr.qp_state = cmd.qp_state;
+ result = ib_cm_init_qp_attr(ctx->cm_id, &qp_attr, &resp.qp_attr_mask);
+ if (result)
+ goto out;
+
+ ib_copy_qp_attr_to_user(&resp, &qp_attr);
+
+ if (copy_to_user((void __user *)(unsigned long)cmd.response,
+ &resp, sizeof(resp)))
+ result = -EFAULT;
+
+out:
+ ib_ucm_ctx_put(ctx);
+ return result;
+}
+
+static int ucm_validate_listen(__be64 service_id, __be64 service_mask)
+{
+ service_id &= service_mask;
+
+ if (((service_id & IB_CMA_SERVICE_ID_MASK) == IB_CMA_SERVICE_ID) ||
+ ((service_id & IB_SDP_SERVICE_ID_MASK) == IB_SDP_SERVICE_ID))
+ return -EINVAL;
+
+ return 0;
+}
+
+static ssize_t ib_ucm_listen(struct ib_ucm_file *file,
+ const char __user *inbuf,
+ int in_len, int out_len)
+{
+ struct ib_ucm_listen cmd;
+ struct ib_ucm_context *ctx;
+ int result;
+
+ if (copy_from_user(&cmd, inbuf, sizeof(cmd)))
+ return -EFAULT;
+
+ ctx = ib_ucm_ctx_get(file, cmd.id);
+ if (IS_ERR(ctx))
+ return PTR_ERR(ctx);
+
+ result = ucm_validate_listen(cmd.service_id, cmd.service_mask);
+ if (result)
+ goto out;
+
+ result = ib_cm_listen(ctx->cm_id, cmd.service_id, cmd.service_mask);
+out:
+ ib_ucm_ctx_put(ctx);
+ return result;
+}
+
+static ssize_t ib_ucm_notify(struct ib_ucm_file *file,
+ const char __user *inbuf,
+ int in_len, int out_len)
+{
+ struct ib_ucm_notify cmd;
+ struct ib_ucm_context *ctx;
+ int result;
+
+ if (copy_from_user(&cmd, inbuf, sizeof(cmd)))
+ return -EFAULT;
+
+ ctx = ib_ucm_ctx_get(file, cmd.id);
+ if (IS_ERR(ctx))
+ return PTR_ERR(ctx);
+
+ result = ib_cm_notify(ctx->cm_id, (enum ib_event_type) cmd.event);
+ ib_ucm_ctx_put(ctx);
+ return result;
+}
+
+static int ib_ucm_alloc_data(const void **dest, u64 src, u32 len)
+{
+ void *data;
+
+ *dest = NULL;
+
+ if (!len)
+ return 0;
+
+ data = memdup_user((void __user *)(unsigned long)src, len);
+ if (IS_ERR(data))
+ return PTR_ERR(data);
+
+ *dest = data;
+ return 0;
+}
+
+static int ib_ucm_path_get(struct ib_sa_path_rec **path, u64 src)
+{
+ struct ib_user_path_rec upath;
+ struct ib_sa_path_rec *sa_path;
+
+ *path = NULL;
+
+ if (!src)
+ return 0;
+
+ sa_path = kmalloc(sizeof(*sa_path), GFP_KERNEL);
+ if (!sa_path)
+ return -ENOMEM;
+
+ if (copy_from_user(&upath, (void __user *)(unsigned long)src,
+ sizeof(upath))) {
+
+ kfree(sa_path);
+ return -EFAULT;
+ }
+
+ ib_copy_path_rec_from_user(sa_path, &upath);
+ *path = sa_path;
+ return 0;
+}
+
+static ssize_t ib_ucm_send_req(struct ib_ucm_file *file,
+ const char __user *inbuf,
+ int in_len, int out_len)
+{
+ struct ib_cm_req_param param;
+ struct ib_ucm_context *ctx;
+ struct ib_ucm_req cmd;
+ int result;
+
+ param.private_data = NULL;
+ param.primary_path = NULL;
+ param.alternate_path = NULL;
+
+ if (copy_from_user(&cmd, inbuf, sizeof(cmd)))
+ return -EFAULT;
+
+ result = ib_ucm_alloc_data(&param.private_data, cmd.data, cmd.len);
+ if (result)
+ goto done;
+
+ result = ib_ucm_path_get(&param.primary_path, cmd.primary_path);
+ if (result)
+ goto done;
+
+ result = ib_ucm_path_get(&param.alternate_path, cmd.alternate_path);
+ if (result)
+ goto done;
+
+ param.private_data_len = cmd.len;
+ param.service_id = cmd.sid;
+ param.qp_num = cmd.qpn;
+ param.qp_type = cmd.qp_type;
+ param.starting_psn = cmd.psn;
+ param.peer_to_peer = cmd.peer_to_peer;
+ param.responder_resources = cmd.responder_resources;
+ param.initiator_depth = cmd.initiator_depth;
+ param.remote_cm_response_timeout = cmd.remote_cm_response_timeout;
+ param.flow_control = cmd.flow_control;
+ param.local_cm_response_timeout = cmd.local_cm_response_timeout;
+ param.retry_count = cmd.retry_count;
+ param.rnr_retry_count = cmd.rnr_retry_count;
+ param.max_cm_retries = cmd.max_cm_retries;
+ param.srq = cmd.srq;
+
+ ctx = ib_ucm_ctx_get(file, cmd.id);
+ if (!IS_ERR(ctx)) {
+ result = ib_send_cm_req(ctx->cm_id, &param);
+ ib_ucm_ctx_put(ctx);
+ } else
+ result = PTR_ERR(ctx);
+
+done:
+ kfree(param.private_data);
+ kfree(param.primary_path);
+ kfree(param.alternate_path);
+ return result;
+}
+
+static ssize_t ib_ucm_send_rep(struct ib_ucm_file *file,
+ const char __user *inbuf,
+ int in_len, int out_len)
+{
+ struct ib_cm_rep_param param;
+ struct ib_ucm_context *ctx;
+ struct ib_ucm_rep cmd;
+ int result;
+
+ param.private_data = NULL;
+
+ if (copy_from_user(&cmd, inbuf, sizeof(cmd)))
+ return -EFAULT;
+
+ result = ib_ucm_alloc_data(&param.private_data, cmd.data, cmd.len);
+ if (result)
+ return result;
+
+ param.qp_num = cmd.qpn;
+ param.starting_psn = cmd.psn;
+ param.private_data_len = cmd.len;
+ param.responder_resources = cmd.responder_resources;
+ param.initiator_depth = cmd.initiator_depth;
+ param.failover_accepted = cmd.failover_accepted;
+ param.flow_control = cmd.flow_control;
+ param.rnr_retry_count = cmd.rnr_retry_count;
+ param.srq = cmd.srq;
+
+ ctx = ib_ucm_ctx_get(file, cmd.id);
+ if (!IS_ERR(ctx)) {
+ ctx->uid = cmd.uid;
+ result = ib_send_cm_rep(ctx->cm_id, &param);
+ ib_ucm_ctx_put(ctx);
+ } else
+ result = PTR_ERR(ctx);
+
+ kfree(param.private_data);
+ return result;
+}
+
+static ssize_t ib_ucm_send_private_data(struct ib_ucm_file *file,
+ const char __user *inbuf, int in_len,
+ int (*func)(struct ib_cm_id *cm_id,
+ const void *private_data,
+ u8 private_data_len))
+{
+ struct ib_ucm_private_data cmd;
+ struct ib_ucm_context *ctx;
+ const void *private_data = NULL;
+ int result;
+
+ if (copy_from_user(&cmd, inbuf, sizeof(cmd)))
+ return -EFAULT;
+
+ result = ib_ucm_alloc_data(&private_data, cmd.data, cmd.len);
+ if (result)
+ return result;
+
+ ctx = ib_ucm_ctx_get(file, cmd.id);
+ if (!IS_ERR(ctx)) {
+ result = func(ctx->cm_id, private_data, cmd.len);
+ ib_ucm_ctx_put(ctx);
+ } else
+ result = PTR_ERR(ctx);
+
+ kfree(private_data);
+ return result;
+}
+
+static ssize_t ib_ucm_send_rtu(struct ib_ucm_file *file,
+ const char __user *inbuf,
+ int in_len, int out_len)
+{
+ return ib_ucm_send_private_data(file, inbuf, in_len, ib_send_cm_rtu);
+}
+
+static ssize_t ib_ucm_send_dreq(struct ib_ucm_file *file,
+ const char __user *inbuf,
+ int in_len, int out_len)
+{
+ return ib_ucm_send_private_data(file, inbuf, in_len, ib_send_cm_dreq);
+}
+
+static ssize_t ib_ucm_send_drep(struct ib_ucm_file *file,
+ const char __user *inbuf,
+ int in_len, int out_len)
+{
+ return ib_ucm_send_private_data(file, inbuf, in_len, ib_send_cm_drep);
+}
+
+static ssize_t ib_ucm_send_info(struct ib_ucm_file *file,
+ const char __user *inbuf, int in_len,
+ int (*func)(struct ib_cm_id *cm_id,
+ int status,
+ const void *info,
+ u8 info_len,
+ const void *data,
+ u8 data_len))
+{
+ struct ib_ucm_context *ctx;
+ struct ib_ucm_info cmd;
+ const void *data = NULL;
+ const void *info = NULL;
+ int result;
+
+ if (copy_from_user(&cmd, inbuf, sizeof(cmd)))
+ return -EFAULT;
+
+ result = ib_ucm_alloc_data(&data, cmd.data, cmd.data_len);
+ if (result)
+ goto done;
+
+ result = ib_ucm_alloc_data(&info, cmd.info, cmd.info_len);
+ if (result)
+ goto done;
+
+ ctx = ib_ucm_ctx_get(file, cmd.id);
+ if (!IS_ERR(ctx)) {
+ result = func(ctx->cm_id, cmd.status, info, cmd.info_len,
+ data, cmd.data_len);
+ ib_ucm_ctx_put(ctx);
+ } else
+ result = PTR_ERR(ctx);
+
+done:
+ kfree(data);
+ kfree(info);
+ return result;
+}
+
+static ssize_t ib_ucm_send_rej(struct ib_ucm_file *file,
+ const char __user *inbuf,
+ int in_len, int out_len)
+{
+ return ib_ucm_send_info(file, inbuf, in_len, (void *)ib_send_cm_rej);
+}
+
+static ssize_t ib_ucm_send_apr(struct ib_ucm_file *file,
+ const char __user *inbuf,
+ int in_len, int out_len)
+{
+ return ib_ucm_send_info(file, inbuf, in_len, (void *)ib_send_cm_apr);
+}
+
+static ssize_t ib_ucm_send_mra(struct ib_ucm_file *file,
+ const char __user *inbuf,
+ int in_len, int out_len)
+{
+ struct ib_ucm_context *ctx;
+ struct ib_ucm_mra cmd;
+ const void *data = NULL;
+ int result;
+
+ if (copy_from_user(&cmd, inbuf, sizeof(cmd)))
+ return -EFAULT;
+
+ result = ib_ucm_alloc_data(&data, cmd.data, cmd.len);
+ if (result)
+ return result;
+
+ ctx = ib_ucm_ctx_get(file, cmd.id);
+ if (!IS_ERR(ctx)) {
+ result = ib_send_cm_mra(ctx->cm_id, cmd.timeout, data, cmd.len);
+ ib_ucm_ctx_put(ctx);
+ } else
+ result = PTR_ERR(ctx);
+
+ kfree(data);
+ return result;
+}
+
+static ssize_t ib_ucm_send_lap(struct ib_ucm_file *file,
+ const char __user *inbuf,
+ int in_len, int out_len)
+{
+ struct ib_ucm_context *ctx;
+ struct ib_sa_path_rec *path = NULL;
+ struct ib_ucm_lap cmd;
+ const void *data = NULL;
+ int result;
+
+ if (copy_from_user(&cmd, inbuf, sizeof(cmd)))
+ return -EFAULT;
+
+ result = ib_ucm_alloc_data(&data, cmd.data, cmd.len);
+ if (result)
+ goto done;
+
+ result = ib_ucm_path_get(&path, cmd.path);
+ if (result)
+ goto done;
+
+ ctx = ib_ucm_ctx_get(file, cmd.id);
+ if (!IS_ERR(ctx)) {
+ result = ib_send_cm_lap(ctx->cm_id, path, data, cmd.len);
+ ib_ucm_ctx_put(ctx);
+ } else
+ result = PTR_ERR(ctx);
+
+done:
+ kfree(data);
+ kfree(path);
+ return result;
+}
+
+static ssize_t ib_ucm_send_sidr_req(struct ib_ucm_file *file,
+ const char __user *inbuf,
+ int in_len, int out_len)
+{
+ struct ib_cm_sidr_req_param param;
+ struct ib_ucm_context *ctx;
+ struct ib_ucm_sidr_req cmd;
+ int result;
+
+ param.private_data = NULL;
+ param.path = NULL;
+
+ if (copy_from_user(&cmd, inbuf, sizeof(cmd)))
+ return -EFAULT;
+
+ result = ib_ucm_alloc_data(&param.private_data, cmd.data, cmd.len);
+ if (result)
+ goto done;
+
+ result = ib_ucm_path_get(&param.path, cmd.path);
+ if (result)
+ goto done;
+
+ param.private_data_len = cmd.len;
+ param.service_id = cmd.sid;
+ param.timeout_ms = cmd.timeout;
+ param.max_cm_retries = cmd.max_cm_retries;
+
+ ctx = ib_ucm_ctx_get(file, cmd.id);
+ if (!IS_ERR(ctx)) {
+ result = ib_send_cm_sidr_req(ctx->cm_id, &param);
+ ib_ucm_ctx_put(ctx);
+ } else
+ result = PTR_ERR(ctx);
+
+done:
+ kfree(param.private_data);
+ kfree(param.path);
+ return result;
+}
+
+static ssize_t ib_ucm_send_sidr_rep(struct ib_ucm_file *file,
+ const char __user *inbuf,
+ int in_len, int out_len)
+{
+ struct ib_cm_sidr_rep_param param;
+ struct ib_ucm_sidr_rep cmd;
+ struct ib_ucm_context *ctx;
+ int result;
+
+ param.info = NULL;
+
+ if (copy_from_user(&cmd, inbuf, sizeof(cmd)))
+ return -EFAULT;
+
+ result = ib_ucm_alloc_data(&param.private_data,
+ cmd.data, cmd.data_len);
+ if (result)
+ goto done;
+
+ result = ib_ucm_alloc_data(&param.info, cmd.info, cmd.info_len);
+ if (result)
+ goto done;
+
+ param.qp_num = cmd.qpn;
+ param.qkey = cmd.qkey;
+ param.status = cmd.status;
+ param.info_length = cmd.info_len;
+ param.private_data_len = cmd.data_len;
+
+ ctx = ib_ucm_ctx_get(file, cmd.id);
+ if (!IS_ERR(ctx)) {
+ result = ib_send_cm_sidr_rep(ctx->cm_id, &param);
+ ib_ucm_ctx_put(ctx);
+ } else
+ result = PTR_ERR(ctx);
+
+done:
+ kfree(param.private_data);
+ kfree(param.info);
+ return result;
+}
+
+static ssize_t (*ucm_cmd_table[])(struct ib_ucm_file *file,
+ const char __user *inbuf,
+ int in_len, int out_len) = {
+ [IB_USER_CM_CMD_CREATE_ID] = ib_ucm_create_id,
+ [IB_USER_CM_CMD_DESTROY_ID] = ib_ucm_destroy_id,
+ [IB_USER_CM_CMD_ATTR_ID] = ib_ucm_attr_id,
+ [IB_USER_CM_CMD_LISTEN] = ib_ucm_listen,
+ [IB_USER_CM_CMD_NOTIFY] = ib_ucm_notify,
+ [IB_USER_CM_CMD_SEND_REQ] = ib_ucm_send_req,
+ [IB_USER_CM_CMD_SEND_REP] = ib_ucm_send_rep,
+ [IB_USER_CM_CMD_SEND_RTU] = ib_ucm_send_rtu,
+ [IB_USER_CM_CMD_SEND_DREQ] = ib_ucm_send_dreq,
+ [IB_USER_CM_CMD_SEND_DREP] = ib_ucm_send_drep,
+ [IB_USER_CM_CMD_SEND_REJ] = ib_ucm_send_rej,
+ [IB_USER_CM_CMD_SEND_MRA] = ib_ucm_send_mra,
+ [IB_USER_CM_CMD_SEND_LAP] = ib_ucm_send_lap,
+ [IB_USER_CM_CMD_SEND_APR] = ib_ucm_send_apr,
+ [IB_USER_CM_CMD_SEND_SIDR_REQ] = ib_ucm_send_sidr_req,
+ [IB_USER_CM_CMD_SEND_SIDR_REP] = ib_ucm_send_sidr_rep,
+ [IB_USER_CM_CMD_EVENT] = ib_ucm_event,
+ [IB_USER_CM_CMD_INIT_QP_ATTR] = ib_ucm_init_qp_attr,
+};
+
+static ssize_t ib_ucm_write(struct file *filp, const char __user *buf,
+ size_t len, loff_t *pos)
+{
+ struct ib_ucm_file *file = filp->private_data;
+ struct ib_ucm_cmd_hdr hdr;
+ ssize_t result;
+
+ if (WARN_ON_ONCE(!ib_safe_file_access(filp)))
+ return -EACCES;
+
+ if (len < sizeof(hdr))
+ return -EINVAL;
+
+ if (copy_from_user(&hdr, buf, sizeof(hdr)))
+ return -EFAULT;
+
+ if (hdr.cmd >= ARRAY_SIZE(ucm_cmd_table))
+ return -EINVAL;
+
+ if (hdr.in + sizeof(hdr) > len)
+ return -EINVAL;
+
+ result = ucm_cmd_table[hdr.cmd](file, buf + sizeof(hdr),
+ hdr.in, hdr.out);
+ if (!result)
+ result = len;
+
+ return result;
+}
+
+static unsigned int ib_ucm_poll(struct file *filp,
+ struct poll_table_struct *wait)
+{
+ struct ib_ucm_file *file = filp->private_data;
+ unsigned int mask = 0;
+
+ poll_wait(filp, &file->poll_wait, wait);
+
+ if (!list_empty(&file->events))
+ mask = POLLIN | POLLRDNORM;
+
+ return mask;
+}
+
+/*
+ * ib_ucm_open() does not need the BKL:
+ *
+ * - no global state is referred to;
+ * - there is no ioctl method to race against;
+ * - no further module initialization is required for open to work
+ * after the device is registered.
+ */
+static int ib_ucm_open(struct inode *inode, struct file *filp)
+{
+ struct ib_ucm_file *file;
+
+ file = kmalloc(sizeof(*file), GFP_KERNEL);
+ if (!file)
+ return -ENOMEM;
+
+ INIT_LIST_HEAD(&file->events);
+ INIT_LIST_HEAD(&file->ctxs);
+ init_waitqueue_head(&file->poll_wait);
+
+ mutex_init(&file->file_mutex);
+
+ filp->private_data = file;
+ file->filp = filp;
+ file->device = container_of(inode->i_cdev->si_drv1, struct ib_ucm_device, cdev);
+
+ return nonseekable_open(inode, filp);
+}
+
+static int ib_ucm_close(struct inode *inode, struct file *filp)
+{
+ struct ib_ucm_file *file = filp->private_data;
+ struct ib_ucm_context *ctx;
+
+ mutex_lock(&file->file_mutex);
+ while (!list_empty(&file->ctxs)) {
+ ctx = list_entry(file->ctxs.next,
+ struct ib_ucm_context, file_list);
+ mutex_unlock(&file->file_mutex);
+
+ mutex_lock(&ctx_id_mutex);
+ idr_remove(&ctx_id_table, ctx->id);
+ mutex_unlock(&ctx_id_mutex);
+
+ ib_destroy_cm_id(ctx->cm_id);
+ ib_ucm_cleanup_events(ctx);
+ kfree(ctx);
+
+ mutex_lock(&file->file_mutex);
+ }
+ mutex_unlock(&file->file_mutex);
+ kfree(file);
+ return 0;
+}
+
+static DECLARE_BITMAP(overflow_map, IB_UCM_MAX_DEVICES);
+static void ib_ucm_release_dev(struct device *dev)
+{
+ struct ib_ucm_device *ucm_dev;
+
+ ucm_dev = container_of(dev, struct ib_ucm_device, dev);
+ cdev_del(&ucm_dev->cdev);
+ if (ucm_dev->devnum < IB_UCM_MAX_DEVICES)
+ clear_bit(ucm_dev->devnum, dev_map);
+ else
+ clear_bit(ucm_dev->devnum - IB_UCM_MAX_DEVICES, overflow_map);
+ kfree(ucm_dev);
+}
+
+static const struct file_operations ucm_fops = {
+ .owner = THIS_MODULE,
+ .open = ib_ucm_open,
+ .release = ib_ucm_close,
+ .write = ib_ucm_write,
+ .poll = ib_ucm_poll,
+ .llseek = no_llseek,
+};
+
+static ssize_t show_ibdev(struct device *dev, struct device_attribute *attr,
+ char *buf)
+{
+ struct ib_ucm_device *ucm_dev;
+
+ ucm_dev = container_of(dev, struct ib_ucm_device, dev);
+ return sprintf(buf, "%s\n", ucm_dev->ib_dev->name);
+}
+static DEVICE_ATTR(ibdev, S_IRUGO, show_ibdev, NULL);
+
+static dev_t overflow_maj;
+static int find_overflow_devnum(void)
+{
+ int ret;
+
+ if (!overflow_maj) {
+ ret = alloc_chrdev_region(&overflow_maj, 0, IB_UCM_MAX_DEVICES,
+ "infiniband_cm");
+ if (ret) {
+ pr_err("ucm: couldn't register dynamic device number\n");
+ return ret;
+ }
+ }
+
+ ret = find_first_zero_bit(overflow_map, IB_UCM_MAX_DEVICES);
+ if (ret >= IB_UCM_MAX_DEVICES)
+ return -1;
+
+ return ret;
+}
+
+static void ib_ucm_add_one(struct ib_device *device)
+{
+ int devnum;
+ dev_t base;
+ struct ib_ucm_device *ucm_dev;
+
+ if (!device->alloc_ucontext || !rdma_cap_ib_cm(device, 1))
+ return;
+
+ ucm_dev = kzalloc(sizeof *ucm_dev, GFP_KERNEL);
+ if (!ucm_dev)
+ return;
+
+ ucm_dev->ib_dev = device;
+
+ devnum = find_first_zero_bit(dev_map, IB_UCM_MAX_DEVICES);
+ if (devnum >= IB_UCM_MAX_DEVICES) {
+ devnum = find_overflow_devnum();
+ if (devnum < 0)
+ goto err;
+
+ ucm_dev->devnum = devnum + IB_UCM_MAX_DEVICES;
+ base = devnum + overflow_maj;
+ set_bit(devnum, overflow_map);
+ } else {
+ ucm_dev->devnum = devnum;
+ base = devnum + IB_UCM_BASE_DEV;
+ set_bit(devnum, dev_map);
+ }
+
+ cdev_init(&ucm_dev->cdev, &ucm_fops);
+ ucm_dev->cdev.owner = THIS_MODULE;
+ kobject_set_name(&ucm_dev->cdev.kobj, "ucm%d", ucm_dev->devnum);
+ if (cdev_add(&ucm_dev->cdev, base, 1))
+ goto err;
+
+ ucm_dev->dev.class = &cm_class;
+ ucm_dev->dev.parent = device->dma_device;
+ ucm_dev->dev.devt = ucm_dev->cdev.dev;
+ ucm_dev->dev.release = ib_ucm_release_dev;
+ dev_set_name(&ucm_dev->dev, "ucm%d", ucm_dev->devnum);
+ if (device_register(&ucm_dev->dev))
+ goto err_cdev;
+
+ if (device_create_file(&ucm_dev->dev, &dev_attr_ibdev))
+ goto err_dev;
+
+ ib_set_client_data(device, &ucm_client, ucm_dev);
+ return;
+
+err_dev:
+ device_unregister(&ucm_dev->dev);
+err_cdev:
+ cdev_del(&ucm_dev->cdev);
+ if (ucm_dev->devnum < IB_UCM_MAX_DEVICES)
+ clear_bit(devnum, dev_map);
+ else
+ clear_bit(devnum, overflow_map);
+err:
+ kfree(ucm_dev);
+ return;
+}
+
+static void ib_ucm_remove_one(struct ib_device *device, void *client_data)
+{
+ struct ib_ucm_device *ucm_dev = client_data;
+
+ if (!ucm_dev)
+ return;
+
+ device_unregister(&ucm_dev->dev);
+}
+
+static CLASS_ATTR_STRING(abi_version, S_IRUGO,
+ __stringify(IB_USER_CM_ABI_VERSION));
+
+static int __init ib_ucm_init(void)
+{
+ int ret;
+
+ ret = register_chrdev_region(IB_UCM_BASE_DEV, IB_UCM_MAX_DEVICES,
+ "infiniband_cm");
+ if (ret) {
+ pr_err("ucm: couldn't register device number\n");
+ goto error1;
+ }
+
+ ret = class_create_file(&cm_class, &class_attr_abi_version.attr);
+ if (ret) {
+ pr_err("ucm: couldn't create abi_version attribute\n");
+ goto error2;
+ }
+
+ ret = ib_register_client(&ucm_client);
+ if (ret) {
+ pr_err("ucm: couldn't register client\n");
+ goto error3;
+ }
+ return 0;
+
+error3:
+ class_remove_file(&cm_class, &class_attr_abi_version.attr);
+error2:
+ unregister_chrdev_region(IB_UCM_BASE_DEV, IB_UCM_MAX_DEVICES);
+error1:
+ return ret;
+}
+
+static void __exit ib_ucm_cleanup(void)
+{
+ ib_unregister_client(&ucm_client);
+ class_remove_file(&cm_class, &class_attr_abi_version.attr);
+ unregister_chrdev_region(IB_UCM_BASE_DEV, IB_UCM_MAX_DEVICES);
+ if (overflow_maj)
+ unregister_chrdev_region(overflow_maj, IB_UCM_MAX_DEVICES);
+ idr_destroy(&ctx_id_table);
+}
+
+module_init_order(ib_ucm_init, SI_ORDER_THIRD);
+module_exit(ib_ucm_cleanup);
diff --git a/sys/ofed/drivers/infiniband/core/ib_ucma.c b/sys/ofed/drivers/infiniband/core/ib_ucma.c
new file mode 100644
index 0000000..081b1cf
--- /dev/null
+++ b/sys/ofed/drivers/infiniband/core/ib_ucma.c
@@ -0,0 +1,1754 @@
+/*
+ * Copyright (c) 2005-2006 Intel Corporation. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#include <linux/completion.h>
+#include <linux/file.h>
+#include <linux/mutex.h>
+#include <linux/poll.h>
+#include <linux/sched.h>
+#include <linux/idr.h>
+#include <linux/in.h>
+#include <linux/in6.h>
+#include <linux/miscdevice.h>
+#include <linux/slab.h>
+#include <linux/module.h>
+
+#include <sys/filio.h>
+
+#include <rdma/rdma_user_cm.h>
+#include <rdma/ib_marshall.h>
+#include <rdma/rdma_cm.h>
+#include <rdma/rdma_cm_ib.h>
+#include <rdma/ib_addr.h>
+#include <rdma/ib.h>
+
+MODULE_AUTHOR("Sean Hefty");
+MODULE_DESCRIPTION("RDMA Userspace Connection Manager Access");
+MODULE_LICENSE("Dual BSD/GPL");
+
+static unsigned int max_backlog = 1024;
+
+struct ucma_file {
+ struct mutex mut;
+ struct file *filp;
+ struct list_head ctx_list;
+ struct list_head event_list;
+ wait_queue_head_t poll_wait;
+ struct workqueue_struct *close_wq;
+};
+
+struct ucma_context {
+ int id;
+ struct completion comp;
+ atomic_t ref;
+ int events_reported;
+ int backlog;
+
+ struct ucma_file *file;
+ struct rdma_cm_id *cm_id;
+ u64 uid;
+
+ struct list_head list;
+ struct list_head mc_list;
+ /* mark that device is in process of destroying the internal HW
+ * resources, protected by the global mut
+ */
+ int closing;
+ /* sync between removal event and id destroy, protected by file mut */
+ int destroying;
+ struct work_struct close_work;
+};
+
+struct ucma_multicast {
+ struct ucma_context *ctx;
+ int id;
+ int events_reported;
+
+ u64 uid;
+ u8 join_state;
+ struct list_head list;
+ struct sockaddr_storage addr;
+};
+
+struct ucma_event {
+ struct ucma_context *ctx;
+ struct ucma_multicast *mc;
+ struct list_head list;
+ struct rdma_cm_id *cm_id;
+ struct rdma_ucm_event_resp resp;
+ struct work_struct close_work;
+};
+
+static DEFINE_MUTEX(mut);
+static DEFINE_IDR(ctx_idr);
+static DEFINE_IDR(multicast_idr);
+
+static inline struct ucma_context *_ucma_find_context(int id,
+ struct ucma_file *file)
+{
+ struct ucma_context *ctx;
+
+ ctx = idr_find(&ctx_idr, id);
+ if (!ctx)
+ ctx = ERR_PTR(-ENOENT);
+ else if (ctx->file != file)
+ ctx = ERR_PTR(-EINVAL);
+ return ctx;
+}
+
+static struct ucma_context *ucma_get_ctx(struct ucma_file *file, int id)
+{
+ struct ucma_context *ctx;
+
+ mutex_lock(&mut);
+ ctx = _ucma_find_context(id, file);
+ if (!IS_ERR(ctx)) {
+ if (ctx->closing)
+ ctx = ERR_PTR(-EIO);
+ else
+ atomic_inc(&ctx->ref);
+ }
+ mutex_unlock(&mut);
+ return ctx;
+}
+
+static void ucma_put_ctx(struct ucma_context *ctx)
+{
+ if (atomic_dec_and_test(&ctx->ref))
+ complete(&ctx->comp);
+}
+
+static void ucma_close_event_id(struct work_struct *work)
+{
+ struct ucma_event *uevent_close = container_of(work, struct ucma_event, close_work);
+
+ rdma_destroy_id(uevent_close->cm_id);
+ kfree(uevent_close);
+}
+
+static void ucma_close_id(struct work_struct *work)
+{
+ struct ucma_context *ctx = container_of(work, struct ucma_context, close_work);
+
+ /* once all inflight tasks are finished, we close all underlying
+ * resources. The context is still alive till its explicit destryoing
+ * by its creator.
+ */
+ ucma_put_ctx(ctx);
+ wait_for_completion(&ctx->comp);
+ /* No new events will be generated after destroying the id. */
+ rdma_destroy_id(ctx->cm_id);
+}
+
+static struct ucma_context *ucma_alloc_ctx(struct ucma_file *file)
+{
+ struct ucma_context *ctx;
+
+ ctx = kzalloc(sizeof(*ctx), GFP_KERNEL);
+ if (!ctx)
+ return NULL;
+
+ INIT_WORK(&ctx->close_work, ucma_close_id);
+ atomic_set(&ctx->ref, 1);
+ init_completion(&ctx->comp);
+ INIT_LIST_HEAD(&ctx->mc_list);
+ ctx->file = file;
+
+ mutex_lock(&mut);
+ ctx->id = idr_alloc(&ctx_idr, ctx, 0, 0, GFP_KERNEL);
+ mutex_unlock(&mut);
+ if (ctx->id < 0)
+ goto error;
+
+ list_add_tail(&ctx->list, &file->ctx_list);
+ return ctx;
+
+error:
+ kfree(ctx);
+ return NULL;
+}
+
+static struct ucma_multicast* ucma_alloc_multicast(struct ucma_context *ctx)
+{
+ struct ucma_multicast *mc;
+
+ mc = kzalloc(sizeof(*mc), GFP_KERNEL);
+ if (!mc)
+ return NULL;
+
+ mutex_lock(&mut);
+ mc->id = idr_alloc(&multicast_idr, mc, 0, 0, GFP_KERNEL);
+ mutex_unlock(&mut);
+ if (mc->id < 0)
+ goto error;
+
+ mc->ctx = ctx;
+ list_add_tail(&mc->list, &ctx->mc_list);
+ return mc;
+
+error:
+ kfree(mc);
+ return NULL;
+}
+
+static void ucma_copy_conn_event(struct rdma_ucm_conn_param *dst,
+ struct rdma_conn_param *src)
+{
+ if (src->private_data_len)
+ memcpy(dst->private_data, src->private_data,
+ src->private_data_len);
+ dst->private_data_len = src->private_data_len;
+ dst->responder_resources =src->responder_resources;
+ dst->initiator_depth = src->initiator_depth;
+ dst->flow_control = src->flow_control;
+ dst->retry_count = src->retry_count;
+ dst->rnr_retry_count = src->rnr_retry_count;
+ dst->srq = src->srq;
+ dst->qp_num = src->qp_num;
+}
+
+static void ucma_copy_ud_event(struct rdma_ucm_ud_param *dst,
+ struct rdma_ud_param *src)
+{
+ if (src->private_data_len)
+ memcpy(dst->private_data, src->private_data,
+ src->private_data_len);
+ dst->private_data_len = src->private_data_len;
+ ib_copy_ah_attr_to_user(&dst->ah_attr, &src->ah_attr);
+ dst->qp_num = src->qp_num;
+ dst->qkey = src->qkey;
+}
+
+static void ucma_set_event_context(struct ucma_context *ctx,
+ struct rdma_cm_event *event,
+ struct ucma_event *uevent)
+{
+ uevent->ctx = ctx;
+ switch (event->event) {
+ case RDMA_CM_EVENT_MULTICAST_JOIN:
+ case RDMA_CM_EVENT_MULTICAST_ERROR:
+ uevent->mc = __DECONST(struct ucma_multicast *,
+ event->param.ud.private_data);
+ uevent->resp.uid = uevent->mc->uid;
+ uevent->resp.id = uevent->mc->id;
+ break;
+ default:
+ uevent->resp.uid = ctx->uid;
+ uevent->resp.id = ctx->id;
+ break;
+ }
+}
+
+/* Called with file->mut locked for the relevant context. */
+static void ucma_removal_event_handler(struct rdma_cm_id *cm_id)
+{
+ struct ucma_context *ctx = cm_id->context;
+ struct ucma_event *con_req_eve;
+ int event_found = 0;
+
+ if (ctx->destroying)
+ return;
+
+ /* only if context is pointing to cm_id that it owns it and can be
+ * queued to be closed, otherwise that cm_id is an inflight one that
+ * is part of that context event list pending to be detached and
+ * reattached to its new context as part of ucma_get_event,
+ * handled separately below.
+ */
+ if (ctx->cm_id == cm_id) {
+ mutex_lock(&mut);
+ ctx->closing = 1;
+ mutex_unlock(&mut);
+ queue_work(ctx->file->close_wq, &ctx->close_work);
+ return;
+ }
+
+ list_for_each_entry(con_req_eve, &ctx->file->event_list, list) {
+ if (con_req_eve->cm_id == cm_id &&
+ con_req_eve->resp.event == RDMA_CM_EVENT_CONNECT_REQUEST) {
+ list_del(&con_req_eve->list);
+ INIT_WORK(&con_req_eve->close_work, ucma_close_event_id);
+ queue_work(ctx->file->close_wq, &con_req_eve->close_work);
+ event_found = 1;
+ break;
+ }
+ }
+ if (!event_found)
+ pr_err("ucma_removal_event_handler: warning: connect request event wasn't found\n");
+}
+
+static int ucma_event_handler(struct rdma_cm_id *cm_id,
+ struct rdma_cm_event *event)
+{
+ struct ucma_event *uevent;
+ struct ucma_context *ctx = cm_id->context;
+ int ret = 0;
+
+ uevent = kzalloc(sizeof(*uevent), GFP_KERNEL);
+ if (!uevent)
+ return event->event == RDMA_CM_EVENT_CONNECT_REQUEST;
+
+ mutex_lock(&ctx->file->mut);
+ uevent->cm_id = cm_id;
+ ucma_set_event_context(ctx, event, uevent);
+ uevent->resp.event = event->event;
+ uevent->resp.status = event->status;
+ if (cm_id->qp_type == IB_QPT_UD)
+ ucma_copy_ud_event(&uevent->resp.param.ud, &event->param.ud);
+ else
+ ucma_copy_conn_event(&uevent->resp.param.conn,
+ &event->param.conn);
+
+ if (event->event == RDMA_CM_EVENT_CONNECT_REQUEST) {
+ if (!ctx->backlog) {
+ ret = -ENOMEM;
+ kfree(uevent);
+ goto out;
+ }
+ ctx->backlog--;
+ } else if (!ctx->uid || ctx->cm_id != cm_id) {
+ /*
+ * We ignore events for new connections until userspace has set
+ * their context. This can only happen if an error occurs on a
+ * new connection before the user accepts it. This is okay,
+ * since the accept will just fail later. However, we do need
+ * to release the underlying HW resources in case of a device
+ * removal event.
+ */
+ if (event->event == RDMA_CM_EVENT_DEVICE_REMOVAL)
+ ucma_removal_event_handler(cm_id);
+
+ kfree(uevent);
+ goto out;
+ }
+
+ list_add_tail(&uevent->list, &ctx->file->event_list);
+ wake_up_interruptible(&ctx->file->poll_wait);
+ if (event->event == RDMA_CM_EVENT_DEVICE_REMOVAL)
+ ucma_removal_event_handler(cm_id);
+out:
+ mutex_unlock(&ctx->file->mut);
+ return ret;
+}
+
+static ssize_t ucma_get_event(struct ucma_file *file, const char __user *inbuf,
+ int in_len, int out_len)
+{
+ struct ucma_context *ctx;
+ struct rdma_ucm_get_event cmd;
+ struct ucma_event *uevent;
+ int ret = 0;
+
+ if (out_len < sizeof uevent->resp)
+ return -ENOSPC;
+
+ if (copy_from_user(&cmd, inbuf, sizeof(cmd)))
+ return -EFAULT;
+
+ mutex_lock(&file->mut);
+ while (list_empty(&file->event_list)) {
+ mutex_unlock(&file->mut);
+
+ if (file->filp->f_flags & O_NONBLOCK)
+ return -EAGAIN;
+
+ if (wait_event_interruptible(file->poll_wait,
+ !list_empty(&file->event_list)))
+ return -ERESTARTSYS;
+
+ mutex_lock(&file->mut);
+ }
+
+ uevent = list_entry(file->event_list.next, struct ucma_event, list);
+
+ if (uevent->resp.event == RDMA_CM_EVENT_CONNECT_REQUEST) {
+ ctx = ucma_alloc_ctx(file);
+ if (!ctx) {
+ ret = -ENOMEM;
+ goto done;
+ }
+ uevent->ctx->backlog++;
+ ctx->cm_id = uevent->cm_id;
+ ctx->cm_id->context = ctx;
+ uevent->resp.id = ctx->id;
+ }
+
+ if (copy_to_user((void __user *)(unsigned long)cmd.response,
+ &uevent->resp, sizeof uevent->resp)) {
+ ret = -EFAULT;
+ goto done;
+ }
+
+ list_del(&uevent->list);
+ uevent->ctx->events_reported++;
+ if (uevent->mc)
+ uevent->mc->events_reported++;
+ kfree(uevent);
+done:
+ mutex_unlock(&file->mut);
+ return ret;
+}
+
+static int ucma_get_qp_type(struct rdma_ucm_create_id *cmd, enum ib_qp_type *qp_type)
+{
+ switch (cmd->ps) {
+ case RDMA_PS_TCP:
+ *qp_type = IB_QPT_RC;
+ return 0;
+ case RDMA_PS_UDP:
+ case RDMA_PS_IPOIB:
+ *qp_type = IB_QPT_UD;
+ return 0;
+ case RDMA_PS_IB:
+ *qp_type = cmd->qp_type;
+ return 0;
+ default:
+ return -EINVAL;
+ }
+}
+
+static ssize_t ucma_create_id(struct ucma_file *file, const char __user *inbuf,
+ int in_len, int out_len)
+{
+ struct rdma_ucm_create_id cmd;
+ struct rdma_ucm_create_id_resp resp;
+ struct ucma_context *ctx;
+ enum ib_qp_type qp_type;
+ int ret;
+
+ if (out_len < sizeof(resp))
+ return -ENOSPC;
+
+ if (copy_from_user(&cmd, inbuf, sizeof(cmd)))
+ return -EFAULT;
+
+ ret = ucma_get_qp_type(&cmd, &qp_type);
+ if (ret)
+ return ret;
+
+ mutex_lock(&file->mut);
+ ctx = ucma_alloc_ctx(file);
+ mutex_unlock(&file->mut);
+ if (!ctx)
+ return -ENOMEM;
+
+ ctx->uid = cmd.uid;
+ ctx->cm_id = rdma_create_id(TD_TO_VNET(curthread),
+ ucma_event_handler, ctx, cmd.ps, qp_type);
+ if (IS_ERR(ctx->cm_id)) {
+ ret = PTR_ERR(ctx->cm_id);
+ goto err1;
+ }
+
+ resp.id = ctx->id;
+ if (copy_to_user((void __user *)(unsigned long)cmd.response,
+ &resp, sizeof(resp))) {
+ ret = -EFAULT;
+ goto err2;
+ }
+ return 0;
+
+err2:
+ rdma_destroy_id(ctx->cm_id);
+err1:
+ mutex_lock(&mut);
+ idr_remove(&ctx_idr, ctx->id);
+ mutex_unlock(&mut);
+ kfree(ctx);
+ return ret;
+}
+
+static void ucma_cleanup_multicast(struct ucma_context *ctx)
+{
+ struct ucma_multicast *mc, *tmp;
+
+ mutex_lock(&mut);
+ list_for_each_entry_safe(mc, tmp, &ctx->mc_list, list) {
+ list_del(&mc->list);
+ idr_remove(&multicast_idr, mc->id);
+ kfree(mc);
+ }
+ mutex_unlock(&mut);
+}
+
+static void ucma_cleanup_mc_events(struct ucma_multicast *mc)
+{
+ struct ucma_event *uevent, *tmp;
+
+ list_for_each_entry_safe(uevent, tmp, &mc->ctx->file->event_list, list) {
+ if (uevent->mc != mc)
+ continue;
+
+ list_del(&uevent->list);
+ kfree(uevent);
+ }
+}
+
+/*
+ * ucma_free_ctx is called after the underlying rdma CM-ID is destroyed. At
+ * this point, no new events will be reported from the hardware. However, we
+ * still need to cleanup the UCMA context for this ID. Specifically, there
+ * might be events that have not yet been consumed by the user space software.
+ * These might include pending connect requests which we have not completed
+ * processing. We cannot call rdma_destroy_id while holding the lock of the
+ * context (file->mut), as it might cause a deadlock. We therefore extract all
+ * relevant events from the context pending events list while holding the
+ * mutex. After that we release them as needed.
+ */
+static int ucma_free_ctx(struct ucma_context *ctx)
+{
+ int events_reported;
+ struct ucma_event *uevent, *tmp;
+ LIST_HEAD(list);
+
+
+ ucma_cleanup_multicast(ctx);
+
+ /* Cleanup events not yet reported to the user. */
+ mutex_lock(&ctx->file->mut);
+ list_for_each_entry_safe(uevent, tmp, &ctx->file->event_list, list) {
+ if (uevent->ctx == ctx)
+ list_move_tail(&uevent->list, &list);
+ }
+ list_del(&ctx->list);
+ mutex_unlock(&ctx->file->mut);
+
+ list_for_each_entry_safe(uevent, tmp, &list, list) {
+ list_del(&uevent->list);
+ if (uevent->resp.event == RDMA_CM_EVENT_CONNECT_REQUEST)
+ rdma_destroy_id(uevent->cm_id);
+ kfree(uevent);
+ }
+
+ events_reported = ctx->events_reported;
+ kfree(ctx);
+ return events_reported;
+}
+
+static ssize_t ucma_destroy_id(struct ucma_file *file, const char __user *inbuf,
+ int in_len, int out_len)
+{
+ struct rdma_ucm_destroy_id cmd;
+ struct rdma_ucm_destroy_id_resp resp;
+ struct ucma_context *ctx;
+ int ret = 0;
+
+ if (out_len < sizeof(resp))
+ return -ENOSPC;
+
+ if (copy_from_user(&cmd, inbuf, sizeof(cmd)))
+ return -EFAULT;
+
+ mutex_lock(&mut);
+ ctx = _ucma_find_context(cmd.id, file);
+ if (!IS_ERR(ctx))
+ idr_remove(&ctx_idr, ctx->id);
+ mutex_unlock(&mut);
+
+ if (IS_ERR(ctx))
+ return PTR_ERR(ctx);
+
+ mutex_lock(&ctx->file->mut);
+ ctx->destroying = 1;
+ mutex_unlock(&ctx->file->mut);
+
+ flush_workqueue(ctx->file->close_wq);
+ /* At this point it's guaranteed that there is no inflight
+ * closing task */
+ mutex_lock(&mut);
+ if (!ctx->closing) {
+ mutex_unlock(&mut);
+ ucma_put_ctx(ctx);
+ wait_for_completion(&ctx->comp);
+ rdma_destroy_id(ctx->cm_id);
+ } else {
+ mutex_unlock(&mut);
+ }
+
+ resp.events_reported = ucma_free_ctx(ctx);
+ if (copy_to_user((void __user *)(unsigned long)cmd.response,
+ &resp, sizeof(resp)))
+ ret = -EFAULT;
+
+ return ret;
+}
+
+static ssize_t ucma_bind_ip(struct ucma_file *file, const char __user *inbuf,
+ int in_len, int out_len)
+{
+ struct rdma_ucm_bind_ip cmd;
+ struct ucma_context *ctx;
+ int ret;
+
+ if (copy_from_user(&cmd, inbuf, sizeof(cmd)))
+ return -EFAULT;
+
+ ctx = ucma_get_ctx(file, cmd.id);
+ if (IS_ERR(ctx))
+ return PTR_ERR(ctx);
+
+ ret = rdma_bind_addr(ctx->cm_id, (struct sockaddr *) &cmd.addr);
+ ucma_put_ctx(ctx);
+ return ret;
+}
+
+static ssize_t ucma_bind(struct ucma_file *file, const char __user *inbuf,
+ int in_len, int out_len)
+{
+ struct rdma_ucm_bind cmd;
+ struct sockaddr *addr;
+ struct ucma_context *ctx;
+ int ret;
+
+ if (copy_from_user(&cmd, inbuf, sizeof(cmd)))
+ return -EFAULT;
+
+ addr = (struct sockaddr *) &cmd.addr;
+ if (cmd.reserved || !cmd.addr_size || (cmd.addr_size != rdma_addr_size(addr)))
+ return -EINVAL;
+
+ ctx = ucma_get_ctx(file, cmd.id);
+ if (IS_ERR(ctx))
+ return PTR_ERR(ctx);
+
+ ret = rdma_bind_addr(ctx->cm_id, addr);
+ ucma_put_ctx(ctx);
+ return ret;
+}
+
+static ssize_t ucma_resolve_ip(struct ucma_file *file,
+ const char __user *inbuf,
+ int in_len, int out_len)
+{
+ struct rdma_ucm_resolve_ip cmd;
+ struct ucma_context *ctx;
+ int ret;
+
+ if (copy_from_user(&cmd, inbuf, sizeof(cmd)))
+ return -EFAULT;
+
+ ctx = ucma_get_ctx(file, cmd.id);
+ if (IS_ERR(ctx))
+ return PTR_ERR(ctx);
+
+ ret = rdma_resolve_addr(ctx->cm_id, (struct sockaddr *) &cmd.src_addr,
+ (struct sockaddr *) &cmd.dst_addr,
+ cmd.timeout_ms);
+ ucma_put_ctx(ctx);
+ return ret;
+}
+
+static ssize_t ucma_resolve_addr(struct ucma_file *file,
+ const char __user *inbuf,
+ int in_len, int out_len)
+{
+ struct rdma_ucm_resolve_addr cmd;
+ struct sockaddr *src, *dst;
+ struct ucma_context *ctx;
+ int ret;
+
+ if (copy_from_user(&cmd, inbuf, sizeof(cmd)))
+ return -EFAULT;
+
+ src = (struct sockaddr *) &cmd.src_addr;
+ dst = (struct sockaddr *) &cmd.dst_addr;
+ if (cmd.reserved || (cmd.src_size && (cmd.src_size != rdma_addr_size(src))) ||
+ !cmd.dst_size || (cmd.dst_size != rdma_addr_size(dst)))
+ return -EINVAL;
+
+ ctx = ucma_get_ctx(file, cmd.id);
+ if (IS_ERR(ctx))
+ return PTR_ERR(ctx);
+
+ ret = rdma_resolve_addr(ctx->cm_id, src, dst, cmd.timeout_ms);
+ ucma_put_ctx(ctx);
+ return ret;
+}
+
+static ssize_t ucma_resolve_route(struct ucma_file *file,
+ const char __user *inbuf,
+ int in_len, int out_len)
+{
+ struct rdma_ucm_resolve_route cmd;
+ struct ucma_context *ctx;
+ int ret;
+
+ if (copy_from_user(&cmd, inbuf, sizeof(cmd)))
+ return -EFAULT;
+
+ ctx = ucma_get_ctx(file, cmd.id);
+ if (IS_ERR(ctx))
+ return PTR_ERR(ctx);
+
+ ret = rdma_resolve_route(ctx->cm_id, cmd.timeout_ms);
+ ucma_put_ctx(ctx);
+ return ret;
+}
+
+static void ucma_copy_ib_route(struct rdma_ucm_query_route_resp *resp,
+ struct rdma_route *route)
+{
+ struct rdma_dev_addr *dev_addr;
+
+ resp->num_paths = route->num_paths;
+ switch (route->num_paths) {
+ case 0:
+ dev_addr = &route->addr.dev_addr;
+ rdma_addr_get_dgid(dev_addr,
+ (union ib_gid *) &resp->ib_route[0].dgid);
+ rdma_addr_get_sgid(dev_addr,
+ (union ib_gid *) &resp->ib_route[0].sgid);
+ resp->ib_route[0].pkey = cpu_to_be16(ib_addr_get_pkey(dev_addr));
+ break;
+ case 2:
+ ib_copy_path_rec_to_user(&resp->ib_route[1],
+ &route->path_rec[1]);
+ /* fall through */
+ case 1:
+ ib_copy_path_rec_to_user(&resp->ib_route[0],
+ &route->path_rec[0]);
+ break;
+ default:
+ break;
+ }
+}
+
+static void ucma_copy_iboe_route(struct rdma_ucm_query_route_resp *resp,
+ struct rdma_route *route)
+{
+
+ resp->num_paths = route->num_paths;
+ switch (route->num_paths) {
+ case 0:
+ rdma_ip2gid((struct sockaddr *)&route->addr.dst_addr,
+ (union ib_gid *)&resp->ib_route[0].dgid);
+ rdma_ip2gid((struct sockaddr *)&route->addr.src_addr,
+ (union ib_gid *)&resp->ib_route[0].sgid);
+ resp->ib_route[0].pkey = cpu_to_be16(0xffff);
+ break;
+ case 2:
+ ib_copy_path_rec_to_user(&resp->ib_route[1],
+ &route->path_rec[1]);
+ /* fall through */
+ case 1:
+ ib_copy_path_rec_to_user(&resp->ib_route[0],
+ &route->path_rec[0]);
+ break;
+ default:
+ break;
+ }
+}
+
+static void ucma_copy_iw_route(struct rdma_ucm_query_route_resp *resp,
+ struct rdma_route *route)
+{
+ struct rdma_dev_addr *dev_addr;
+
+ dev_addr = &route->addr.dev_addr;
+ rdma_addr_get_dgid(dev_addr, (union ib_gid *) &resp->ib_route[0].dgid);
+ rdma_addr_get_sgid(dev_addr, (union ib_gid *) &resp->ib_route[0].sgid);
+}
+
+static ssize_t ucma_query_route(struct ucma_file *file,
+ const char __user *inbuf,
+ int in_len, int out_len)
+{
+ struct rdma_ucm_query cmd;
+ struct rdma_ucm_query_route_resp resp;
+ struct ucma_context *ctx;
+ struct sockaddr *addr;
+ int ret = 0;
+
+ if (out_len < sizeof(resp))
+ return -ENOSPC;
+
+ if (copy_from_user(&cmd, inbuf, sizeof(cmd)))
+ return -EFAULT;
+
+ ctx = ucma_get_ctx(file, cmd.id);
+ if (IS_ERR(ctx))
+ return PTR_ERR(ctx);
+
+ memset(&resp, 0, sizeof resp);
+ addr = (struct sockaddr *) &ctx->cm_id->route.addr.src_addr;
+ memcpy(&resp.src_addr, addr, addr->sa_family == AF_INET ?
+ sizeof(struct sockaddr_in) :
+ sizeof(struct sockaddr_in6));
+ addr = (struct sockaddr *) &ctx->cm_id->route.addr.dst_addr;
+ memcpy(&resp.dst_addr, addr, addr->sa_family == AF_INET ?
+ sizeof(struct sockaddr_in) :
+ sizeof(struct sockaddr_in6));
+ if (!ctx->cm_id->device)
+ goto out;
+
+ resp.node_guid = (__force __u64) ctx->cm_id->device->node_guid;
+ resp.port_num = ctx->cm_id->port_num;
+
+ if (rdma_cap_ib_sa(ctx->cm_id->device, ctx->cm_id->port_num))
+ ucma_copy_ib_route(&resp, &ctx->cm_id->route);
+ else if (rdma_protocol_roce(ctx->cm_id->device, ctx->cm_id->port_num))
+ ucma_copy_iboe_route(&resp, &ctx->cm_id->route);
+ else if (rdma_protocol_iwarp(ctx->cm_id->device, ctx->cm_id->port_num))
+ ucma_copy_iw_route(&resp, &ctx->cm_id->route);
+
+out:
+ if (copy_to_user((void __user *)(unsigned long)cmd.response,
+ &resp, sizeof(resp)))
+ ret = -EFAULT;
+
+ ucma_put_ctx(ctx);
+ return ret;
+}
+
+static void ucma_query_device_addr(struct rdma_cm_id *cm_id,
+ struct rdma_ucm_query_addr_resp *resp)
+{
+ if (!cm_id->device)
+ return;
+
+ resp->node_guid = (__force __u64) cm_id->device->node_guid;
+ resp->port_num = cm_id->port_num;
+ resp->pkey = (__force __u16) cpu_to_be16(
+ ib_addr_get_pkey(&cm_id->route.addr.dev_addr));
+}
+
+static ssize_t ucma_query_addr(struct ucma_context *ctx,
+ void __user *response, int out_len)
+{
+ struct rdma_ucm_query_addr_resp resp;
+ struct sockaddr *addr;
+ int ret = 0;
+
+ if (out_len < sizeof(resp))
+ return -ENOSPC;
+
+ memset(&resp, 0, sizeof resp);
+
+ addr = (struct sockaddr *) &ctx->cm_id->route.addr.src_addr;
+ resp.src_size = rdma_addr_size(addr);
+ memcpy(&resp.src_addr, addr, resp.src_size);
+
+ addr = (struct sockaddr *) &ctx->cm_id->route.addr.dst_addr;
+ resp.dst_size = rdma_addr_size(addr);
+ memcpy(&resp.dst_addr, addr, resp.dst_size);
+
+ ucma_query_device_addr(ctx->cm_id, &resp);
+
+ if (copy_to_user(response, &resp, sizeof(resp)))
+ ret = -EFAULT;
+
+ return ret;
+}
+
+static ssize_t ucma_query_path(struct ucma_context *ctx,
+ void __user *response, int out_len)
+{
+ struct rdma_ucm_query_path_resp *resp;
+ int i, ret = 0;
+
+ if (out_len < sizeof(*resp))
+ return -ENOSPC;
+
+ resp = kzalloc(out_len, GFP_KERNEL);
+ if (!resp)
+ return -ENOMEM;
+
+ resp->num_paths = ctx->cm_id->route.num_paths;
+ for (i = 0, out_len -= sizeof(*resp);
+ i < resp->num_paths && out_len > sizeof(struct ib_path_rec_data);
+ i++, out_len -= sizeof(struct ib_path_rec_data)) {
+
+ resp->path_data[i].flags = IB_PATH_GMP | IB_PATH_PRIMARY |
+ IB_PATH_BIDIRECTIONAL;
+ ib_sa_pack_path(&ctx->cm_id->route.path_rec[i],
+ &resp->path_data[i].path_rec);
+ }
+
+ if (copy_to_user(response, resp,
+ sizeof(*resp) + (i * sizeof(struct ib_path_rec_data))))
+ ret = -EFAULT;
+
+ kfree(resp);
+ return ret;
+}
+
+static ssize_t ucma_query_gid(struct ucma_context *ctx,
+ void __user *response, int out_len)
+{
+ struct rdma_ucm_query_addr_resp resp;
+ struct sockaddr_ib *addr;
+ int ret = 0;
+
+ if (out_len < sizeof(resp))
+ return -ENOSPC;
+
+ memset(&resp, 0, sizeof resp);
+
+ ucma_query_device_addr(ctx->cm_id, &resp);
+
+ addr = (struct sockaddr_ib *) &resp.src_addr;
+ resp.src_size = sizeof(*addr);
+ if (ctx->cm_id->route.addr.src_addr.ss_family == AF_IB) {
+ memcpy(addr, &ctx->cm_id->route.addr.src_addr, resp.src_size);
+ } else {
+ addr->sib_family = AF_IB;
+ addr->sib_pkey = (__force __be16) resp.pkey;
+ rdma_addr_get_sgid(&ctx->cm_id->route.addr.dev_addr,
+ (union ib_gid *) &addr->sib_addr);
+ addr->sib_sid = rdma_get_service_id(ctx->cm_id, (struct sockaddr *)
+ &ctx->cm_id->route.addr.src_addr);
+ }
+
+ addr = (struct sockaddr_ib *) &resp.dst_addr;
+ resp.dst_size = sizeof(*addr);
+ if (ctx->cm_id->route.addr.dst_addr.ss_family == AF_IB) {
+ memcpy(addr, &ctx->cm_id->route.addr.dst_addr, resp.dst_size);
+ } else {
+ addr->sib_family = AF_IB;
+ addr->sib_pkey = (__force __be16) resp.pkey;
+ rdma_addr_get_dgid(&ctx->cm_id->route.addr.dev_addr,
+ (union ib_gid *) &addr->sib_addr);
+ addr->sib_sid = rdma_get_service_id(ctx->cm_id, (struct sockaddr *)
+ &ctx->cm_id->route.addr.dst_addr);
+ }
+
+ if (copy_to_user(response, &resp, sizeof(resp)))
+ ret = -EFAULT;
+
+ return ret;
+}
+
+static ssize_t ucma_query(struct ucma_file *file,
+ const char __user *inbuf,
+ int in_len, int out_len)
+{
+ struct rdma_ucm_query cmd;
+ struct ucma_context *ctx;
+ void __user *response;
+ int ret;
+
+ if (copy_from_user(&cmd, inbuf, sizeof(cmd)))
+ return -EFAULT;
+
+ response = (void __user *)(unsigned long) cmd.response;
+ ctx = ucma_get_ctx(file, cmd.id);
+ if (IS_ERR(ctx))
+ return PTR_ERR(ctx);
+
+ switch (cmd.option) {
+ case RDMA_USER_CM_QUERY_ADDR:
+ ret = ucma_query_addr(ctx, response, out_len);
+ break;
+ case RDMA_USER_CM_QUERY_PATH:
+ ret = ucma_query_path(ctx, response, out_len);
+ break;
+ case RDMA_USER_CM_QUERY_GID:
+ ret = ucma_query_gid(ctx, response, out_len);
+ break;
+ default:
+ ret = -ENOSYS;
+ break;
+ }
+
+ ucma_put_ctx(ctx);
+ return ret;
+}
+
+static void ucma_copy_conn_param(struct rdma_cm_id *id,
+ struct rdma_conn_param *dst,
+ struct rdma_ucm_conn_param *src)
+{
+ dst->private_data = src->private_data;
+ dst->private_data_len = src->private_data_len;
+ dst->responder_resources =src->responder_resources;
+ dst->initiator_depth = src->initiator_depth;
+ dst->flow_control = src->flow_control;
+ dst->retry_count = src->retry_count;
+ dst->rnr_retry_count = src->rnr_retry_count;
+ dst->srq = src->srq;
+ dst->qp_num = src->qp_num;
+ dst->qkey = (id->route.addr.src_addr.ss_family == AF_IB) ? src->qkey : 0;
+}
+
+static ssize_t ucma_connect(struct ucma_file *file, const char __user *inbuf,
+ int in_len, int out_len)
+{
+ struct rdma_ucm_connect cmd;
+ struct rdma_conn_param conn_param;
+ struct ucma_context *ctx;
+ int ret;
+
+ if (copy_from_user(&cmd, inbuf, sizeof(cmd)))
+ return -EFAULT;
+
+ if (!cmd.conn_param.valid)
+ return -EINVAL;
+
+ ctx = ucma_get_ctx(file, cmd.id);
+ if (IS_ERR(ctx))
+ return PTR_ERR(ctx);
+
+ ucma_copy_conn_param(ctx->cm_id, &conn_param, &cmd.conn_param);
+ ret = rdma_connect(ctx->cm_id, &conn_param);
+ ucma_put_ctx(ctx);
+ return ret;
+}
+
+static ssize_t ucma_listen(struct ucma_file *file, const char __user *inbuf,
+ int in_len, int out_len)
+{
+ struct rdma_ucm_listen cmd;
+ struct ucma_context *ctx;
+ int ret;
+
+ if (copy_from_user(&cmd, inbuf, sizeof(cmd)))
+ return -EFAULT;
+
+ ctx = ucma_get_ctx(file, cmd.id);
+ if (IS_ERR(ctx))
+ return PTR_ERR(ctx);
+
+ ctx->backlog = cmd.backlog > 0 && cmd.backlog < max_backlog ?
+ cmd.backlog : max_backlog;
+ ret = rdma_listen(ctx->cm_id, ctx->backlog);
+ ucma_put_ctx(ctx);
+ return ret;
+}
+
+static ssize_t ucma_accept(struct ucma_file *file, const char __user *inbuf,
+ int in_len, int out_len)
+{
+ struct rdma_ucm_accept cmd;
+ struct rdma_conn_param conn_param;
+ struct ucma_context *ctx;
+ int ret;
+
+ if (copy_from_user(&cmd, inbuf, sizeof(cmd)))
+ return -EFAULT;
+
+ ctx = ucma_get_ctx(file, cmd.id);
+ if (IS_ERR(ctx))
+ return PTR_ERR(ctx);
+
+ if (cmd.conn_param.valid) {
+ ucma_copy_conn_param(ctx->cm_id, &conn_param, &cmd.conn_param);
+ mutex_lock(&file->mut);
+ ret = rdma_accept(ctx->cm_id, &conn_param);
+ if (!ret)
+ ctx->uid = cmd.uid;
+ mutex_unlock(&file->mut);
+ } else
+ ret = rdma_accept(ctx->cm_id, NULL);
+
+ ucma_put_ctx(ctx);
+ return ret;
+}
+
+static ssize_t ucma_reject(struct ucma_file *file, const char __user *inbuf,
+ int in_len, int out_len)
+{
+ struct rdma_ucm_reject cmd;
+ struct ucma_context *ctx;
+ int ret;
+
+ if (copy_from_user(&cmd, inbuf, sizeof(cmd)))
+ return -EFAULT;
+
+ ctx = ucma_get_ctx(file, cmd.id);
+ if (IS_ERR(ctx))
+ return PTR_ERR(ctx);
+
+ ret = rdma_reject(ctx->cm_id, cmd.private_data, cmd.private_data_len);
+ ucma_put_ctx(ctx);
+ return ret;
+}
+
+static ssize_t ucma_disconnect(struct ucma_file *file, const char __user *inbuf,
+ int in_len, int out_len)
+{
+ struct rdma_ucm_disconnect cmd;
+ struct ucma_context *ctx;
+ int ret;
+
+ if (copy_from_user(&cmd, inbuf, sizeof(cmd)))
+ return -EFAULT;
+
+ ctx = ucma_get_ctx(file, cmd.id);
+ if (IS_ERR(ctx))
+ return PTR_ERR(ctx);
+
+ ret = rdma_disconnect(ctx->cm_id);
+ ucma_put_ctx(ctx);
+ return ret;
+}
+
+static ssize_t ucma_init_qp_attr(struct ucma_file *file,
+ const char __user *inbuf,
+ int in_len, int out_len)
+{
+ struct rdma_ucm_init_qp_attr cmd;
+ struct ib_uverbs_qp_attr resp;
+ struct ucma_context *ctx;
+ struct ib_qp_attr qp_attr;
+ int ret;
+
+ if (out_len < sizeof(resp))
+ return -ENOSPC;
+
+ if (copy_from_user(&cmd, inbuf, sizeof(cmd)))
+ return -EFAULT;
+
+ ctx = ucma_get_ctx(file, cmd.id);
+ if (IS_ERR(ctx))
+ return PTR_ERR(ctx);
+
+ resp.qp_attr_mask = 0;
+ memset(&qp_attr, 0, sizeof qp_attr);
+ qp_attr.qp_state = cmd.qp_state;
+ ret = rdma_init_qp_attr(ctx->cm_id, &qp_attr, &resp.qp_attr_mask);
+ if (ret)
+ goto out;
+
+ ib_copy_qp_attr_to_user(&resp, &qp_attr);
+ if (copy_to_user((void __user *)(unsigned long)cmd.response,
+ &resp, sizeof(resp)))
+ ret = -EFAULT;
+
+out:
+ ucma_put_ctx(ctx);
+ return ret;
+}
+
+static int ucma_set_option_id(struct ucma_context *ctx, int optname,
+ void *optval, size_t optlen)
+{
+ int ret = 0;
+
+ switch (optname) {
+ case RDMA_OPTION_ID_TOS:
+ if (optlen != sizeof(u8)) {
+ ret = -EINVAL;
+ break;
+ }
+ rdma_set_service_type(ctx->cm_id, *((u8 *) optval));
+ break;
+ case RDMA_OPTION_ID_REUSEADDR:
+ if (optlen != sizeof(int)) {
+ ret = -EINVAL;
+ break;
+ }
+ ret = rdma_set_reuseaddr(ctx->cm_id, *((int *) optval) ? 1 : 0);
+ break;
+ case RDMA_OPTION_ID_AFONLY:
+ if (optlen != sizeof(int)) {
+ ret = -EINVAL;
+ break;
+ }
+ ret = rdma_set_afonly(ctx->cm_id, *((int *) optval) ? 1 : 0);
+ break;
+ default:
+ ret = -ENOSYS;
+ }
+
+ return ret;
+}
+
+static int ucma_set_ib_path(struct ucma_context *ctx,
+ struct ib_path_rec_data *path_data, size_t optlen)
+{
+ struct ib_sa_path_rec sa_path;
+ struct rdma_cm_event event;
+ int ret;
+
+ if (optlen % sizeof(*path_data))
+ return -EINVAL;
+
+ for (; optlen; optlen -= sizeof(*path_data), path_data++) {
+ if (path_data->flags == (IB_PATH_GMP | IB_PATH_PRIMARY |
+ IB_PATH_BIDIRECTIONAL))
+ break;
+ }
+
+ if (!optlen)
+ return -EINVAL;
+
+ memset(&sa_path, 0, sizeof(sa_path));
+
+ ib_sa_unpack_path(path_data->path_rec, &sa_path);
+ ret = rdma_set_ib_paths(ctx->cm_id, &sa_path, 1);
+ if (ret)
+ return ret;
+
+ memset(&event, 0, sizeof event);
+ event.event = RDMA_CM_EVENT_ROUTE_RESOLVED;
+ return ucma_event_handler(ctx->cm_id, &event);
+}
+
+static int ucma_set_option_ib(struct ucma_context *ctx, int optname,
+ void *optval, size_t optlen)
+{
+ int ret;
+
+ switch (optname) {
+ case RDMA_OPTION_IB_PATH:
+ ret = ucma_set_ib_path(ctx, optval, optlen);
+ break;
+ default:
+ ret = -ENOSYS;
+ }
+
+ return ret;
+}
+
+static int ucma_set_option_level(struct ucma_context *ctx, int level,
+ int optname, void *optval, size_t optlen)
+{
+ int ret;
+
+ switch (level) {
+ case RDMA_OPTION_ID:
+ ret = ucma_set_option_id(ctx, optname, optval, optlen);
+ break;
+ case RDMA_OPTION_IB:
+ ret = ucma_set_option_ib(ctx, optname, optval, optlen);
+ break;
+ default:
+ ret = -ENOSYS;
+ }
+
+ return ret;
+}
+
+static ssize_t ucma_set_option(struct ucma_file *file, const char __user *inbuf,
+ int in_len, int out_len)
+{
+ struct rdma_ucm_set_option cmd;
+ struct ucma_context *ctx;
+ void *optval;
+ int ret;
+
+ if (copy_from_user(&cmd, inbuf, sizeof(cmd)))
+ return -EFAULT;
+
+ ctx = ucma_get_ctx(file, cmd.id);
+ if (IS_ERR(ctx))
+ return PTR_ERR(ctx);
+
+ optval = memdup_user((void __user *) (unsigned long) cmd.optval,
+ cmd.optlen);
+ if (IS_ERR(optval)) {
+ ret = PTR_ERR(optval);
+ goto out;
+ }
+
+ ret = ucma_set_option_level(ctx, cmd.level, cmd.optname, optval,
+ cmd.optlen);
+ kfree(optval);
+
+out:
+ ucma_put_ctx(ctx);
+ return ret;
+}
+
+static ssize_t ucma_notify(struct ucma_file *file, const char __user *inbuf,
+ int in_len, int out_len)
+{
+ struct rdma_ucm_notify cmd;
+ struct ucma_context *ctx;
+ int ret;
+
+ if (copy_from_user(&cmd, inbuf, sizeof(cmd)))
+ return -EFAULT;
+
+ ctx = ucma_get_ctx(file, cmd.id);
+ if (IS_ERR(ctx))
+ return PTR_ERR(ctx);
+
+ ret = rdma_notify(ctx->cm_id, (enum ib_event_type) cmd.event);
+ ucma_put_ctx(ctx);
+ return ret;
+}
+
+static ssize_t ucma_process_join(struct ucma_file *file,
+ struct rdma_ucm_join_mcast *cmd, int out_len)
+{
+ struct rdma_ucm_create_id_resp resp;
+ struct ucma_context *ctx;
+ struct ucma_multicast *mc;
+ struct sockaddr *addr;
+ int ret;
+ u8 join_state;
+
+ if (out_len < sizeof(resp))
+ return -ENOSPC;
+
+ addr = (struct sockaddr *) &cmd->addr;
+ if (!cmd->addr_size || (cmd->addr_size != rdma_addr_size(addr)))
+ return -EINVAL;
+
+ if (cmd->join_flags == RDMA_MC_JOIN_FLAG_FULLMEMBER)
+ join_state = BIT(FULLMEMBER_JOIN);
+ else if (cmd->join_flags == RDMA_MC_JOIN_FLAG_SENDONLY_FULLMEMBER)
+ join_state = BIT(SENDONLY_FULLMEMBER_JOIN);
+ else
+ return -EINVAL;
+
+ ctx = ucma_get_ctx(file, cmd->id);
+ if (IS_ERR(ctx))
+ return PTR_ERR(ctx);
+
+ mutex_lock(&file->mut);
+ mc = ucma_alloc_multicast(ctx);
+ if (!mc) {
+ ret = -ENOMEM;
+ goto err1;
+ }
+ mc->join_state = join_state;
+ mc->uid = cmd->uid;
+ memcpy(&mc->addr, addr, cmd->addr_size);
+ ret = rdma_join_multicast(ctx->cm_id, (struct sockaddr *)&mc->addr,
+ join_state, mc);
+ if (ret)
+ goto err2;
+
+ resp.id = mc->id;
+ if (copy_to_user((void __user *)(unsigned long) cmd->response,
+ &resp, sizeof(resp))) {
+ ret = -EFAULT;
+ goto err3;
+ }
+
+ mutex_unlock(&file->mut);
+ ucma_put_ctx(ctx);
+ return 0;
+
+err3:
+ rdma_leave_multicast(ctx->cm_id, (struct sockaddr *) &mc->addr);
+ ucma_cleanup_mc_events(mc);
+err2:
+ mutex_lock(&mut);
+ idr_remove(&multicast_idr, mc->id);
+ mutex_unlock(&mut);
+ list_del(&mc->list);
+ kfree(mc);
+err1:
+ mutex_unlock(&file->mut);
+ ucma_put_ctx(ctx);
+ return ret;
+}
+
+static ssize_t ucma_join_ip_multicast(struct ucma_file *file,
+ const char __user *inbuf,
+ int in_len, int out_len)
+{
+ struct rdma_ucm_join_ip_mcast cmd;
+ struct rdma_ucm_join_mcast join_cmd;
+
+ if (copy_from_user(&cmd, inbuf, sizeof(cmd)))
+ return -EFAULT;
+
+ join_cmd.response = cmd.response;
+ join_cmd.uid = cmd.uid;
+ join_cmd.id = cmd.id;
+ join_cmd.addr_size = rdma_addr_size((struct sockaddr *) &cmd.addr);
+ join_cmd.join_flags = RDMA_MC_JOIN_FLAG_FULLMEMBER;
+ memcpy(&join_cmd.addr, &cmd.addr, join_cmd.addr_size);
+
+ return ucma_process_join(file, &join_cmd, out_len);
+}
+
+static ssize_t ucma_join_multicast(struct ucma_file *file,
+ const char __user *inbuf,
+ int in_len, int out_len)
+{
+ struct rdma_ucm_join_mcast cmd;
+
+ if (copy_from_user(&cmd, inbuf, sizeof(cmd)))
+ return -EFAULT;
+
+ return ucma_process_join(file, &cmd, out_len);
+}
+
+static ssize_t ucma_leave_multicast(struct ucma_file *file,
+ const char __user *inbuf,
+ int in_len, int out_len)
+{
+ struct rdma_ucm_destroy_id cmd;
+ struct rdma_ucm_destroy_id_resp resp;
+ struct ucma_multicast *mc;
+ int ret = 0;
+
+ if (out_len < sizeof(resp))
+ return -ENOSPC;
+
+ if (copy_from_user(&cmd, inbuf, sizeof(cmd)))
+ return -EFAULT;
+
+ mutex_lock(&mut);
+ mc = idr_find(&multicast_idr, cmd.id);
+ if (!mc)
+ mc = ERR_PTR(-ENOENT);
+ else if (mc->ctx->file != file)
+ mc = ERR_PTR(-EINVAL);
+ else if (!atomic_inc_not_zero(&mc->ctx->ref))
+ mc = ERR_PTR(-ENXIO);
+ else
+ idr_remove(&multicast_idr, mc->id);
+ mutex_unlock(&mut);
+
+ if (IS_ERR(mc)) {
+ ret = PTR_ERR(mc);
+ goto out;
+ }
+
+ rdma_leave_multicast(mc->ctx->cm_id, (struct sockaddr *) &mc->addr);
+ mutex_lock(&mc->ctx->file->mut);
+ ucma_cleanup_mc_events(mc);
+ list_del(&mc->list);
+ mutex_unlock(&mc->ctx->file->mut);
+
+ ucma_put_ctx(mc->ctx);
+ resp.events_reported = mc->events_reported;
+ kfree(mc);
+
+ if (copy_to_user((void __user *)(unsigned long)cmd.response,
+ &resp, sizeof(resp)))
+ ret = -EFAULT;
+out:
+ return ret;
+}
+
+static void ucma_lock_files(struct ucma_file *file1, struct ucma_file *file2)
+{
+ /* Acquire mutex's based on pointer comparison to prevent deadlock. */
+ if (file1 < file2) {
+ mutex_lock(&file1->mut);
+ mutex_lock_nested(&file2->mut, SINGLE_DEPTH_NESTING);
+ } else {
+ mutex_lock(&file2->mut);
+ mutex_lock_nested(&file1->mut, SINGLE_DEPTH_NESTING);
+ }
+}
+
+static void ucma_unlock_files(struct ucma_file *file1, struct ucma_file *file2)
+{
+ if (file1 < file2) {
+ mutex_unlock(&file2->mut);
+ mutex_unlock(&file1->mut);
+ } else {
+ mutex_unlock(&file1->mut);
+ mutex_unlock(&file2->mut);
+ }
+}
+
+static void ucma_move_events(struct ucma_context *ctx, struct ucma_file *file)
+{
+ struct ucma_event *uevent, *tmp;
+
+ list_for_each_entry_safe(uevent, tmp, &ctx->file->event_list, list)
+ if (uevent->ctx == ctx)
+ list_move_tail(&uevent->list, &file->event_list);
+}
+
+static ssize_t ucma_migrate_id(struct ucma_file *new_file,
+ const char __user *inbuf,
+ int in_len, int out_len)
+{
+ struct rdma_ucm_migrate_id cmd;
+ struct rdma_ucm_migrate_resp resp;
+ struct ucma_context *ctx;
+ struct fd f;
+ struct ucma_file *cur_file;
+ int ret = 0;
+
+ if (copy_from_user(&cmd, inbuf, sizeof(cmd)))
+ return -EFAULT;
+
+ /* Get current fd to protect against it being closed */
+ f = fdget(cmd.fd);
+ if (!f.file)
+ return -ENOENT;
+
+ /* Validate current fd and prevent destruction of id. */
+ ctx = ucma_get_ctx(f.file->private_data, cmd.id);
+ if (IS_ERR(ctx)) {
+ ret = PTR_ERR(ctx);
+ goto file_put;
+ }
+
+ cur_file = ctx->file;
+ if (cur_file == new_file) {
+ resp.events_reported = ctx->events_reported;
+ goto response;
+ }
+
+ /*
+ * Migrate events between fd's, maintaining order, and avoiding new
+ * events being added before existing events.
+ */
+ ucma_lock_files(cur_file, new_file);
+ mutex_lock(&mut);
+
+ list_move_tail(&ctx->list, &new_file->ctx_list);
+ ucma_move_events(ctx, new_file);
+ ctx->file = new_file;
+ resp.events_reported = ctx->events_reported;
+
+ mutex_unlock(&mut);
+ ucma_unlock_files(cur_file, new_file);
+
+response:
+ if (copy_to_user((void __user *)(unsigned long)cmd.response,
+ &resp, sizeof(resp)))
+ ret = -EFAULT;
+
+ ucma_put_ctx(ctx);
+file_put:
+ fdput(f);
+ return ret;
+}
+
+static ssize_t (*ucma_cmd_table[])(struct ucma_file *file,
+ const char __user *inbuf,
+ int in_len, int out_len) = {
+ [RDMA_USER_CM_CMD_CREATE_ID] = ucma_create_id,
+ [RDMA_USER_CM_CMD_DESTROY_ID] = ucma_destroy_id,
+ [RDMA_USER_CM_CMD_BIND_IP] = ucma_bind_ip,
+ [RDMA_USER_CM_CMD_RESOLVE_IP] = ucma_resolve_ip,
+ [RDMA_USER_CM_CMD_RESOLVE_ROUTE] = ucma_resolve_route,
+ [RDMA_USER_CM_CMD_QUERY_ROUTE] = ucma_query_route,
+ [RDMA_USER_CM_CMD_CONNECT] = ucma_connect,
+ [RDMA_USER_CM_CMD_LISTEN] = ucma_listen,
+ [RDMA_USER_CM_CMD_ACCEPT] = ucma_accept,
+ [RDMA_USER_CM_CMD_REJECT] = ucma_reject,
+ [RDMA_USER_CM_CMD_DISCONNECT] = ucma_disconnect,
+ [RDMA_USER_CM_CMD_INIT_QP_ATTR] = ucma_init_qp_attr,
+ [RDMA_USER_CM_CMD_GET_EVENT] = ucma_get_event,
+ [RDMA_USER_CM_CMD_GET_OPTION] = NULL,
+ [RDMA_USER_CM_CMD_SET_OPTION] = ucma_set_option,
+ [RDMA_USER_CM_CMD_NOTIFY] = ucma_notify,
+ [RDMA_USER_CM_CMD_JOIN_IP_MCAST] = ucma_join_ip_multicast,
+ [RDMA_USER_CM_CMD_LEAVE_MCAST] = ucma_leave_multicast,
+ [RDMA_USER_CM_CMD_MIGRATE_ID] = ucma_migrate_id,
+ [RDMA_USER_CM_CMD_QUERY] = ucma_query,
+ [RDMA_USER_CM_CMD_BIND] = ucma_bind,
+ [RDMA_USER_CM_CMD_RESOLVE_ADDR] = ucma_resolve_addr,
+ [RDMA_USER_CM_CMD_JOIN_MCAST] = ucma_join_multicast
+};
+
+static ssize_t ucma_write(struct file *filp, const char __user *buf,
+ size_t len, loff_t *pos)
+{
+ struct ucma_file *file = filp->private_data;
+ struct rdma_ucm_cmd_hdr hdr;
+ ssize_t ret;
+
+ if (WARN_ON_ONCE(!ib_safe_file_access(filp)))
+ return -EACCES;
+
+ if (len < sizeof(hdr))
+ return -EINVAL;
+
+ if (copy_from_user(&hdr, buf, sizeof(hdr)))
+ return -EFAULT;
+
+ if (hdr.cmd >= ARRAY_SIZE(ucma_cmd_table))
+ return -EINVAL;
+
+ if (hdr.in + sizeof(hdr) > len)
+ return -EINVAL;
+
+ if (!ucma_cmd_table[hdr.cmd])
+ return -ENOSYS;
+
+ ret = ucma_cmd_table[hdr.cmd](file, buf + sizeof(hdr), hdr.in, hdr.out);
+ if (!ret)
+ ret = len;
+
+ return ret;
+}
+
+static unsigned int ucma_poll(struct file *filp, struct poll_table_struct *wait)
+{
+ struct ucma_file *file = filp->private_data;
+ unsigned int mask = 0;
+
+ poll_wait(filp, &file->poll_wait, wait);
+
+ if (!list_empty(&file->event_list))
+ mask = POLLIN | POLLRDNORM;
+
+ return mask;
+}
+
+/*
+ * ucma_open() does not need the BKL:
+ *
+ * - no global state is referred to;
+ * - there is no ioctl method to race against;
+ * - no further module initialization is required for open to work
+ * after the device is registered.
+ */
+static int ucma_open(struct inode *inode, struct file *filp)
+{
+ struct ucma_file *file;
+
+ file = kmalloc(sizeof *file, GFP_KERNEL);
+ if (!file)
+ return -ENOMEM;
+
+ file->close_wq = alloc_ordered_workqueue("ucma_close_id",
+ WQ_MEM_RECLAIM);
+ if (!file->close_wq) {
+ kfree(file);
+ return -ENOMEM;
+ }
+
+ INIT_LIST_HEAD(&file->event_list);
+ INIT_LIST_HEAD(&file->ctx_list);
+ init_waitqueue_head(&file->poll_wait);
+ mutex_init(&file->mut);
+
+ filp->private_data = file;
+ file->filp = filp;
+
+ return nonseekable_open(inode, filp);
+}
+
+static int ucma_close(struct inode *inode, struct file *filp)
+{
+ struct ucma_file *file = filp->private_data;
+ struct ucma_context *ctx, *tmp;
+
+ mutex_lock(&file->mut);
+ list_for_each_entry_safe(ctx, tmp, &file->ctx_list, list) {
+ ctx->destroying = 1;
+ mutex_unlock(&file->mut);
+
+ mutex_lock(&mut);
+ idr_remove(&ctx_idr, ctx->id);
+ mutex_unlock(&mut);
+
+ flush_workqueue(file->close_wq);
+ /* At that step once ctx was marked as destroying and workqueue
+ * was flushed we are safe from any inflights handlers that
+ * might put other closing task.
+ */
+ mutex_lock(&mut);
+ if (!ctx->closing) {
+ mutex_unlock(&mut);
+ /* rdma_destroy_id ensures that no event handlers are
+ * inflight for that id before releasing it.
+ */
+ rdma_destroy_id(ctx->cm_id);
+ } else {
+ mutex_unlock(&mut);
+ }
+
+ ucma_free_ctx(ctx);
+ mutex_lock(&file->mut);
+ }
+ mutex_unlock(&file->mut);
+ destroy_workqueue(file->close_wq);
+ kfree(file);
+ return 0;
+}
+
+static long
+ucma_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
+{
+
+ switch (cmd) {
+ case FIONBIO:
+ case FIOASYNC:
+ return (0);
+ default:
+ return (-ENOTTY);
+ }
+}
+
+static const struct file_operations ucma_fops = {
+ .owner = THIS_MODULE,
+ .open = ucma_open,
+ .release = ucma_close,
+ .write = ucma_write,
+ .unlocked_ioctl = ucma_ioctl,
+ .poll = ucma_poll,
+ .llseek = no_llseek,
+};
+
+static struct miscdevice ucma_misc = {
+ .minor = MISC_DYNAMIC_MINOR,
+ .name = "rdma_cm",
+ .nodename = "infiniband/rdma_cm",
+ .mode = 0666,
+ .fops = &ucma_fops,
+};
+
+static ssize_t show_abi_version(struct device *dev,
+ struct device_attribute *attr,
+ char *buf)
+{
+ return sprintf(buf, "%d\n", RDMA_USER_CM_ABI_VERSION);
+}
+static DEVICE_ATTR(abi_version, S_IRUGO, show_abi_version, NULL);
+
+static int __init ucma_init(void)
+{
+ int ret;
+
+ ret = misc_register(&ucma_misc);
+ if (ret)
+ return ret;
+
+ ret = device_create_file(ucma_misc.this_device, &dev_attr_abi_version);
+ if (ret) {
+ pr_err("rdma_ucm: couldn't create abi_version attr\n");
+ goto err1;
+ }
+
+ return 0;
+err1:
+ misc_deregister(&ucma_misc);
+ return ret;
+}
+
+static void __exit ucma_cleanup(void)
+{
+ device_remove_file(ucma_misc.this_device, &dev_attr_abi_version);
+ misc_deregister(&ucma_misc);
+ idr_destroy(&ctx_idr);
+ idr_destroy(&multicast_idr);
+}
+
+module_init(ucma_init);
+module_exit(ucma_cleanup);
diff --git a/sys/ofed/drivers/infiniband/core/ib_ud_header.c b/sys/ofed/drivers/infiniband/core/ib_ud_header.c
new file mode 100644
index 0000000..02f179b
--- /dev/null
+++ b/sys/ofed/drivers/infiniband/core/ib_ud_header.c
@@ -0,0 +1,551 @@
+/*
+ * Copyright (c) 2004 Topspin Corporation. All rights reserved.
+ * Copyright (c) 2005 Sun Microsystems, Inc. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#include <linux/errno.h>
+#include <linux/string.h>
+#include <linux/if_ether.h>
+
+#include <rdma/ib_pack.h>
+
+#include <machine/in_cksum.h>
+
+#define STRUCT_FIELD(header, field) \
+ .struct_offset_bytes = offsetof(struct ib_unpacked_ ## header, field), \
+ .struct_size_bytes = sizeof ((struct ib_unpacked_ ## header *) 0)->field, \
+ .field_name = #header ":" #field
+
+static const struct ib_field lrh_table[] = {
+ { STRUCT_FIELD(lrh, virtual_lane),
+ .offset_words = 0,
+ .offset_bits = 0,
+ .size_bits = 4 },
+ { STRUCT_FIELD(lrh, link_version),
+ .offset_words = 0,
+ .offset_bits = 4,
+ .size_bits = 4 },
+ { STRUCT_FIELD(lrh, service_level),
+ .offset_words = 0,
+ .offset_bits = 8,
+ .size_bits = 4 },
+ { RESERVED,
+ .offset_words = 0,
+ .offset_bits = 12,
+ .size_bits = 2 },
+ { STRUCT_FIELD(lrh, link_next_header),
+ .offset_words = 0,
+ .offset_bits = 14,
+ .size_bits = 2 },
+ { STRUCT_FIELD(lrh, destination_lid),
+ .offset_words = 0,
+ .offset_bits = 16,
+ .size_bits = 16 },
+ { RESERVED,
+ .offset_words = 1,
+ .offset_bits = 0,
+ .size_bits = 5 },
+ { STRUCT_FIELD(lrh, packet_length),
+ .offset_words = 1,
+ .offset_bits = 5,
+ .size_bits = 11 },
+ { STRUCT_FIELD(lrh, source_lid),
+ .offset_words = 1,
+ .offset_bits = 16,
+ .size_bits = 16 }
+};
+
+static const struct ib_field eth_table[] = {
+ { STRUCT_FIELD(eth, dmac_h),
+ .offset_words = 0,
+ .offset_bits = 0,
+ .size_bits = 32 },
+ { STRUCT_FIELD(eth, dmac_l),
+ .offset_words = 1,
+ .offset_bits = 0,
+ .size_bits = 16 },
+ { STRUCT_FIELD(eth, smac_h),
+ .offset_words = 1,
+ .offset_bits = 16,
+ .size_bits = 16 },
+ { STRUCT_FIELD(eth, smac_l),
+ .offset_words = 2,
+ .offset_bits = 0,
+ .size_bits = 32 },
+ { STRUCT_FIELD(eth, type),
+ .offset_words = 3,
+ .offset_bits = 0,
+ .size_bits = 16 }
+};
+
+static const struct ib_field vlan_table[] = {
+ { STRUCT_FIELD(vlan, tag),
+ .offset_words = 0,
+ .offset_bits = 0,
+ .size_bits = 16 },
+ { STRUCT_FIELD(vlan, type),
+ .offset_words = 0,
+ .offset_bits = 16,
+ .size_bits = 16 }
+};
+
+static const struct ib_field ip4_table[] = {
+ { STRUCT_FIELD(ip4, ver),
+ .offset_words = 0,
+ .offset_bits = 0,
+ .size_bits = 4 },
+ { STRUCT_FIELD(ip4, hdr_len),
+ .offset_words = 0,
+ .offset_bits = 4,
+ .size_bits = 4 },
+ { STRUCT_FIELD(ip4, tos),
+ .offset_words = 0,
+ .offset_bits = 8,
+ .size_bits = 8 },
+ { STRUCT_FIELD(ip4, tot_len),
+ .offset_words = 0,
+ .offset_bits = 16,
+ .size_bits = 16 },
+ { STRUCT_FIELD(ip4, id),
+ .offset_words = 1,
+ .offset_bits = 0,
+ .size_bits = 16 },
+ { STRUCT_FIELD(ip4, frag_off),
+ .offset_words = 1,
+ .offset_bits = 16,
+ .size_bits = 16 },
+ { STRUCT_FIELD(ip4, ttl),
+ .offset_words = 2,
+ .offset_bits = 0,
+ .size_bits = 8 },
+ { STRUCT_FIELD(ip4, protocol),
+ .offset_words = 2,
+ .offset_bits = 8,
+ .size_bits = 8 },
+ { STRUCT_FIELD(ip4, check),
+ .offset_words = 2,
+ .offset_bits = 16,
+ .size_bits = 16 },
+ { STRUCT_FIELD(ip4, saddr),
+ .offset_words = 3,
+ .offset_bits = 0,
+ .size_bits = 32 },
+ { STRUCT_FIELD(ip4, daddr),
+ .offset_words = 4,
+ .offset_bits = 0,
+ .size_bits = 32 }
+};
+
+static const struct ib_field udp_table[] = {
+ { STRUCT_FIELD(udp, sport),
+ .offset_words = 0,
+ .offset_bits = 0,
+ .size_bits = 16 },
+ { STRUCT_FIELD(udp, dport),
+ .offset_words = 0,
+ .offset_bits = 16,
+ .size_bits = 16 },
+ { STRUCT_FIELD(udp, length),
+ .offset_words = 1,
+ .offset_bits = 0,
+ .size_bits = 16 },
+ { STRUCT_FIELD(udp, csum),
+ .offset_words = 1,
+ .offset_bits = 16,
+ .size_bits = 16 }
+};
+
+static const struct ib_field grh_table[] = {
+ { STRUCT_FIELD(grh, ip_version),
+ .offset_words = 0,
+ .offset_bits = 0,
+ .size_bits = 4 },
+ { STRUCT_FIELD(grh, traffic_class),
+ .offset_words = 0,
+ .offset_bits = 4,
+ .size_bits = 8 },
+ { STRUCT_FIELD(grh, flow_label),
+ .offset_words = 0,
+ .offset_bits = 12,
+ .size_bits = 20 },
+ { STRUCT_FIELD(grh, payload_length),
+ .offset_words = 1,
+ .offset_bits = 0,
+ .size_bits = 16 },
+ { STRUCT_FIELD(grh, next_header),
+ .offset_words = 1,
+ .offset_bits = 16,
+ .size_bits = 8 },
+ { STRUCT_FIELD(grh, hop_limit),
+ .offset_words = 1,
+ .offset_bits = 24,
+ .size_bits = 8 },
+ { STRUCT_FIELD(grh, source_gid),
+ .offset_words = 2,
+ .offset_bits = 0,
+ .size_bits = 128 },
+ { STRUCT_FIELD(grh, destination_gid),
+ .offset_words = 6,
+ .offset_bits = 0,
+ .size_bits = 128 }
+};
+
+static const struct ib_field bth_table[] = {
+ { STRUCT_FIELD(bth, opcode),
+ .offset_words = 0,
+ .offset_bits = 0,
+ .size_bits = 8 },
+ { STRUCT_FIELD(bth, solicited_event),
+ .offset_words = 0,
+ .offset_bits = 8,
+ .size_bits = 1 },
+ { STRUCT_FIELD(bth, mig_req),
+ .offset_words = 0,
+ .offset_bits = 9,
+ .size_bits = 1 },
+ { STRUCT_FIELD(bth, pad_count),
+ .offset_words = 0,
+ .offset_bits = 10,
+ .size_bits = 2 },
+ { STRUCT_FIELD(bth, transport_header_version),
+ .offset_words = 0,
+ .offset_bits = 12,
+ .size_bits = 4 },
+ { STRUCT_FIELD(bth, pkey),
+ .offset_words = 0,
+ .offset_bits = 16,
+ .size_bits = 16 },
+ { RESERVED,
+ .offset_words = 1,
+ .offset_bits = 0,
+ .size_bits = 8 },
+ { STRUCT_FIELD(bth, destination_qpn),
+ .offset_words = 1,
+ .offset_bits = 8,
+ .size_bits = 24 },
+ { STRUCT_FIELD(bth, ack_req),
+ .offset_words = 2,
+ .offset_bits = 0,
+ .size_bits = 1 },
+ { RESERVED,
+ .offset_words = 2,
+ .offset_bits = 1,
+ .size_bits = 7 },
+ { STRUCT_FIELD(bth, psn),
+ .offset_words = 2,
+ .offset_bits = 8,
+ .size_bits = 24 }
+};
+
+static const struct ib_field deth_table[] = {
+ { STRUCT_FIELD(deth, qkey),
+ .offset_words = 0,
+ .offset_bits = 0,
+ .size_bits = 32 },
+ { RESERVED,
+ .offset_words = 1,
+ .offset_bits = 0,
+ .size_bits = 8 },
+ { STRUCT_FIELD(deth, source_qpn),
+ .offset_words = 1,
+ .offset_bits = 8,
+ .size_bits = 24 }
+};
+
+__sum16 ib_ud_ip4_csum(struct ib_ud_header *header)
+{
+#if defined(INET) || defined(INET6)
+ struct ip iph;
+
+ iph.ip_hl = 5;
+ iph.ip_v = 4;
+ iph.ip_tos = header->ip4.tos;
+ iph.ip_len = header->ip4.tot_len;
+ iph.ip_id = header->ip4.id;
+ iph.ip_off = header->ip4.frag_off;
+ iph.ip_ttl = header->ip4.ttl;
+ iph.ip_p = header->ip4.protocol;
+ iph.ip_sum = 0;
+ iph.ip_src.s_addr = header->ip4.saddr;
+ iph.ip_dst.s_addr = header->ip4.daddr;
+
+ return in_cksum_hdr(&iph);
+#else
+ return 0;
+#endif
+}
+EXPORT_SYMBOL(ib_ud_ip4_csum);
+
+/**
+ * ib_ud_header_init - Initialize UD header structure
+ * @payload_bytes:Length of packet payload
+ * @lrh_present: specify if LRH is present
+ * @eth_present: specify if Eth header is present
+ * @vlan_present: packet is tagged vlan
+ * @grh_present: GRH flag (if non-zero, GRH will be included)
+ * @ip_version: if non-zero, IP header, V4 or V6, will be included
+ * @udp_present :if non-zero, UDP header will be included
+ * @immediate_present: specify if immediate data is present
+ * @header:Structure to initialize
+ */
+int ib_ud_header_init(int payload_bytes,
+ int lrh_present,
+ int eth_present,
+ int vlan_present,
+ int grh_present,
+ int ip_version,
+ int udp_present,
+ int immediate_present,
+ struct ib_ud_header *header)
+{
+ size_t udp_bytes = udp_present ? IB_UDP_BYTES : 0;
+
+ grh_present = grh_present && !ip_version;
+ memset(header, 0, sizeof *header);
+
+ /*
+ * UDP header without IP header doesn't make sense
+ */
+ if (udp_present && ip_version != 4 && ip_version != 6)
+ return -EINVAL;
+
+ if (lrh_present) {
+ u16 packet_length;
+
+ header->lrh.link_version = 0;
+ header->lrh.link_next_header =
+ grh_present ? IB_LNH_IBA_GLOBAL : IB_LNH_IBA_LOCAL;
+ packet_length = (IB_LRH_BYTES +
+ IB_BTH_BYTES +
+ IB_DETH_BYTES +
+ (grh_present ? IB_GRH_BYTES : 0) +
+ payload_bytes +
+ 4 + /* ICRC */
+ 3) / 4; /* round up */
+ header->lrh.packet_length = cpu_to_be16(packet_length);
+ }
+
+ if (vlan_present)
+ header->eth.type = cpu_to_be16(ETH_P_8021Q);
+
+ if (ip_version == 6 || grh_present) {
+ header->grh.ip_version = 6;
+ header->grh.payload_length =
+ cpu_to_be16((udp_bytes +
+ IB_BTH_BYTES +
+ IB_DETH_BYTES +
+ payload_bytes +
+ 4 + /* ICRC */
+ 3) & ~3); /* round up */
+ header->grh.next_header = udp_present ? IPPROTO_UDP : 0x1b;
+ }
+
+ if (ip_version == 4) {
+ header->ip4.ver = 4; /* version 4 */
+ header->ip4.hdr_len = 5; /* 5 words */
+ header->ip4.tot_len =
+ cpu_to_be16(IB_IP4_BYTES +
+ udp_bytes +
+ IB_BTH_BYTES +
+ IB_DETH_BYTES +
+ payload_bytes +
+ 4); /* ICRC */
+ header->ip4.protocol = IPPROTO_UDP;
+ }
+ if (udp_present && ip_version)
+ header->udp.length =
+ cpu_to_be16(IB_UDP_BYTES +
+ IB_BTH_BYTES +
+ IB_DETH_BYTES +
+ payload_bytes +
+ 4); /* ICRC */
+
+ if (immediate_present)
+ header->bth.opcode = IB_OPCODE_UD_SEND_ONLY_WITH_IMMEDIATE;
+ else
+ header->bth.opcode = IB_OPCODE_UD_SEND_ONLY;
+ header->bth.pad_count = (4 - payload_bytes) & 3;
+ header->bth.transport_header_version = 0;
+
+ header->lrh_present = lrh_present;
+ header->eth_present = eth_present;
+ header->vlan_present = vlan_present;
+ header->grh_present = grh_present || (ip_version == 6);
+ header->ipv4_present = ip_version == 4;
+ header->udp_present = udp_present;
+ header->immediate_present = immediate_present;
+ return 0;
+}
+EXPORT_SYMBOL(ib_ud_header_init);
+
+/**
+ * ib_ud_header_pack - Pack UD header struct into wire format
+ * @header:UD header struct
+ * @buf:Buffer to pack into
+ *
+ * ib_ud_header_pack() packs the UD header structure @header into wire
+ * format in the buffer @buf.
+ */
+int ib_ud_header_pack(struct ib_ud_header *header,
+ void *buf)
+{
+ int len = 0;
+
+ if (header->lrh_present) {
+ ib_pack(lrh_table, ARRAY_SIZE(lrh_table),
+ &header->lrh, (char *)buf + len);
+ len += IB_LRH_BYTES;
+ }
+ if (header->eth_present) {
+ ib_pack(eth_table, ARRAY_SIZE(eth_table),
+ &header->eth, (char *)buf + len);
+ len += IB_ETH_BYTES;
+ }
+ if (header->vlan_present) {
+ ib_pack(vlan_table, ARRAY_SIZE(vlan_table),
+ &header->vlan, (char *)buf + len);
+ len += IB_VLAN_BYTES;
+ }
+ if (header->grh_present) {
+ ib_pack(grh_table, ARRAY_SIZE(grh_table),
+ &header->grh, (char *)buf + len);
+ len += IB_GRH_BYTES;
+ }
+ if (header->ipv4_present) {
+ ib_pack(ip4_table, ARRAY_SIZE(ip4_table),
+ &header->ip4, (char *)buf + len);
+ len += IB_IP4_BYTES;
+ }
+ if (header->udp_present) {
+ ib_pack(udp_table, ARRAY_SIZE(udp_table),
+ &header->udp, (char *)buf + len);
+ len += IB_UDP_BYTES;
+ }
+
+ ib_pack(bth_table, ARRAY_SIZE(bth_table),
+ &header->bth, (char *)buf + len);
+ len += IB_BTH_BYTES;
+
+ ib_pack(deth_table, ARRAY_SIZE(deth_table),
+ &header->deth, (char *)buf + len);
+ len += IB_DETH_BYTES;
+
+ if (header->immediate_present) {
+ memcpy((char *)buf + len, &header->immediate_data, sizeof header->immediate_data);
+ len += sizeof header->immediate_data;
+ }
+
+ return len;
+}
+EXPORT_SYMBOL(ib_ud_header_pack);
+
+/**
+ * ib_ud_header_unpack - Unpack UD header struct from wire format
+ * @header:UD header struct
+ * @buf:Buffer to pack into
+ *
+ * ib_ud_header_pack() unpacks the UD header structure @header from wire
+ * format in the buffer @buf.
+ */
+int ib_ud_header_unpack(void *buf,
+ struct ib_ud_header *header)
+{
+ ib_unpack(lrh_table, ARRAY_SIZE(lrh_table),
+ buf, &header->lrh);
+ buf = (char *)buf + IB_LRH_BYTES;
+
+ if (header->lrh.link_version != 0) {
+ pr_warn("Invalid LRH.link_version %d\n",
+ header->lrh.link_version);
+ return -EINVAL;
+ }
+
+ switch (header->lrh.link_next_header) {
+ case IB_LNH_IBA_LOCAL:
+ header->grh_present = 0;
+ break;
+
+ case IB_LNH_IBA_GLOBAL:
+ header->grh_present = 1;
+ ib_unpack(grh_table, ARRAY_SIZE(grh_table),
+ buf, &header->grh);
+ buf = (char *)buf + IB_GRH_BYTES;
+
+ if (header->grh.ip_version != 6) {
+ pr_warn("Invalid GRH.ip_version %d\n",
+ header->grh.ip_version);
+ return -EINVAL;
+ }
+ if (header->grh.next_header != 0x1b) {
+ pr_warn("Invalid GRH.next_header 0x%02x\n",
+ header->grh.next_header);
+ return -EINVAL;
+ }
+ break;
+
+ default:
+ pr_warn("Invalid LRH.link_next_header %d\n",
+ header->lrh.link_next_header);
+ return -EINVAL;
+ }
+
+ ib_unpack(bth_table, ARRAY_SIZE(bth_table),
+ buf, &header->bth);
+ buf = (char *)buf + IB_BTH_BYTES;
+
+ switch (header->bth.opcode) {
+ case IB_OPCODE_UD_SEND_ONLY:
+ header->immediate_present = 0;
+ break;
+ case IB_OPCODE_UD_SEND_ONLY_WITH_IMMEDIATE:
+ header->immediate_present = 1;
+ break;
+ default:
+ pr_warn("Invalid BTH.opcode 0x%02x\n", header->bth.opcode);
+ return -EINVAL;
+ }
+
+ if (header->bth.transport_header_version != 0) {
+ pr_warn("Invalid BTH.transport_header_version %d\n",
+ header->bth.transport_header_version);
+ return -EINVAL;
+ }
+
+ ib_unpack(deth_table, ARRAY_SIZE(deth_table),
+ buf, &header->deth);
+ buf = (char *)buf + IB_DETH_BYTES;
+
+ if (header->immediate_present)
+ memcpy(&header->immediate_data, buf, sizeof header->immediate_data);
+
+ return 0;
+}
+EXPORT_SYMBOL(ib_ud_header_unpack);
diff --git a/sys/ofed/drivers/infiniband/core/ib_umem.c b/sys/ofed/drivers/infiniband/core/ib_umem.c
new file mode 100644
index 0000000..76a776a
--- /dev/null
+++ b/sys/ofed/drivers/infiniband/core/ib_umem.c
@@ -0,0 +1,352 @@
+/*
+ * Copyright (c) 2005 Topspin Communications. All rights reserved.
+ * Copyright (c) 2005 Cisco Systems. All rights reserved.
+ * Copyright (c) 2005 Mellanox Technologies. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#define LINUXKPI_PARAM_PREFIX ibcore_
+
+#include <linux/mm.h>
+#include <linux/dma-mapping.h>
+#include <linux/sched.h>
+#include <linux/slab.h>
+#include <linux/wait.h>
+#include <rdma/ib_umem_odp.h>
+
+#include "uverbs.h"
+
+#include <sys/priv.h>
+
+static void __ib_umem_release(struct ib_device *dev, struct ib_umem *umem, int dirty)
+{
+ struct scatterlist *sg;
+ struct page *page;
+ int i;
+
+ if (umem->nmap > 0)
+ ib_dma_unmap_sg(dev, umem->sg_head.sgl,
+ umem->nmap,
+ DMA_BIDIRECTIONAL);
+
+ for_each_sg(umem->sg_head.sgl, sg, umem->npages, i) {
+
+ page = sg_page(sg);
+ put_page(page);
+ }
+
+ sg_free_table(&umem->sg_head);
+ return;
+
+}
+
+/**
+ * ib_umem_get - Pin and DMA map userspace memory.
+ *
+ * If access flags indicate ODP memory, avoid pinning. Instead, stores
+ * the mm for future page fault handling in conjunction with MMU notifiers.
+ *
+ * @context: userspace context to pin memory for
+ * @addr: userspace virtual address to start at
+ * @size: length of region to pin
+ * @access: IB_ACCESS_xxx flags for memory being pinned
+ * @dmasync: flush in-flight DMA when the memory region is written
+ */
+struct ib_umem *ib_umem_get(struct ib_ucontext *context, unsigned long addr,
+ size_t size, int access, int dmasync)
+{
+ struct ib_umem *umem;
+ struct page **page_list;
+ struct vm_area_struct **vma_list;
+ unsigned long locked;
+ unsigned long cur_base;
+ unsigned long npages;
+ int ret;
+ int i;
+ struct dma_attrs dma_attrs = { 0 };
+ struct scatterlist *sg, *sg_list_start;
+ int need_release = 0;
+ unsigned int gup_flags = FOLL_WRITE;
+
+ if (dmasync)
+ dma_attrs.flags |= DMA_ATTR_WRITE_BARRIER;
+
+ if (!size)
+ return ERR_PTR(-EINVAL);
+
+ /*
+ * If the combination of the addr and size requested for this memory
+ * region causes an integer overflow, return error.
+ */
+ if (((addr + size) < addr) ||
+ PAGE_ALIGN(addr + size) < (addr + size))
+ return ERR_PTR(-EINVAL);
+
+ if (priv_check(curthread, PRIV_VM_MLOCK) != 0)
+ return ERR_PTR(-EPERM);
+
+ umem = kzalloc(sizeof *umem, GFP_KERNEL);
+ if (!umem)
+ return ERR_PTR(-ENOMEM);
+
+ umem->context = context;
+ umem->length = size;
+ umem->address = addr;
+ umem->page_size = PAGE_SIZE;
+ umem->pid = get_pid(task_pid(current));
+ /*
+ * We ask for writable memory if any of the following
+ * access flags are set. "Local write" and "remote write"
+ * obviously require write access. "Remote atomic" can do
+ * things like fetch and add, which will modify memory, and
+ * "MW bind" can change permissions by binding a window.
+ */
+ umem->writable = !!(access &
+ (IB_ACCESS_LOCAL_WRITE | IB_ACCESS_REMOTE_WRITE |
+ IB_ACCESS_REMOTE_ATOMIC | IB_ACCESS_MW_BIND));
+
+ if (access & IB_ACCESS_ON_DEMAND) {
+ ret = ib_umem_odp_get(context, umem);
+ if (ret) {
+ kfree(umem);
+ return ERR_PTR(ret);
+ }
+ return umem;
+ }
+
+ umem->odp_data = NULL;
+
+ page_list = (struct page **) __get_free_page(GFP_KERNEL);
+ if (!page_list) {
+ kfree(umem);
+ return ERR_PTR(-ENOMEM);
+ }
+
+ vma_list = (struct vm_area_struct **) __get_free_page(GFP_KERNEL);
+
+ npages = ib_umem_num_pages(umem);
+
+ down_write(&current->mm->mmap_sem);
+
+ locked = npages + current->mm->pinned_vm;
+
+ cur_base = addr & PAGE_MASK;
+
+ if (npages == 0 || npages > UINT_MAX) {
+ ret = -EINVAL;
+ goto out;
+ }
+
+ ret = sg_alloc_table(&umem->sg_head, npages, GFP_KERNEL);
+ if (ret)
+ goto out;
+
+ if (!umem->writable)
+ gup_flags |= FOLL_FORCE;
+
+ need_release = 1;
+ sg_list_start = umem->sg_head.sgl;
+
+ while (npages) {
+ ret = get_user_pages(cur_base,
+ min_t(unsigned long, npages,
+ PAGE_SIZE / sizeof (struct page *)),
+ gup_flags, page_list, vma_list);
+
+ if (ret < 0)
+ goto out;
+
+ umem->npages += ret;
+ cur_base += ret * PAGE_SIZE;
+ npages -= ret;
+
+ for_each_sg(sg_list_start, sg, ret, i) {
+ sg_set_page(sg, page_list[i], PAGE_SIZE, 0);
+ }
+
+ /* preparing for next loop */
+ sg_list_start = sg;
+ }
+
+ umem->nmap = ib_dma_map_sg_attrs(context->device,
+ umem->sg_head.sgl,
+ umem->npages,
+ DMA_BIDIRECTIONAL,
+ &dma_attrs);
+
+ if (umem->nmap <= 0) {
+ ret = -ENOMEM;
+ goto out;
+ }
+
+ ret = 0;
+
+out:
+ if (ret < 0) {
+ if (need_release)
+ __ib_umem_release(context->device, umem, 0);
+ put_pid(umem->pid);
+ kfree(umem);
+ } else
+ current->mm->pinned_vm = locked;
+
+ up_write(&current->mm->mmap_sem);
+ if (vma_list)
+ free_page((unsigned long) vma_list);
+ free_page((unsigned long) page_list);
+
+ return ret < 0 ? ERR_PTR(ret) : umem;
+}
+EXPORT_SYMBOL(ib_umem_get);
+
+static void ib_umem_account(struct work_struct *work)
+{
+ struct ib_umem *umem = container_of(work, struct ib_umem, work);
+
+ down_write(&umem->mm->mmap_sem);
+ umem->mm->pinned_vm -= umem->diff;
+ up_write(&umem->mm->mmap_sem);
+ mmput(umem->mm);
+ kfree(umem);
+}
+
+/**
+ * ib_umem_release - release memory pinned with ib_umem_get
+ * @umem: umem struct to release
+ */
+void ib_umem_release(struct ib_umem *umem)
+{
+ struct ib_ucontext *context = umem->context;
+ struct mm_struct *mm;
+ struct task_struct *task;
+ unsigned long diff;
+
+ if (umem->odp_data) {
+ ib_umem_odp_release(umem);
+ return;
+ }
+
+ __ib_umem_release(umem->context->device, umem, 1);
+
+ task = get_pid_task(umem->pid, PIDTYPE_PID);
+ put_pid(umem->pid);
+ if (!task)
+ goto out;
+ mm = get_task_mm(task);
+ put_task_struct(task);
+ if (!mm)
+ goto out;
+
+ diff = ib_umem_num_pages(umem);
+
+ /*
+ * We may be called with the mm's mmap_sem already held. This
+ * can happen when a userspace munmap() is the call that drops
+ * the last reference to our file and calls our release
+ * method. If there are memory regions to destroy, we'll end
+ * up here and not be able to take the mmap_sem. In that case
+ * we defer the vm_locked accounting to the system workqueue.
+ */
+ if (context->closing) {
+ if (!down_write_trylock(&mm->mmap_sem)) {
+ INIT_WORK(&umem->work, ib_umem_account);
+ umem->mm = mm;
+ umem->diff = diff;
+
+ queue_work(ib_wq, &umem->work);
+ return;
+ }
+ } else
+ down_write(&mm->mmap_sem);
+
+ mm->pinned_vm -= diff;
+ up_write(&mm->mmap_sem);
+ mmput(mm);
+out:
+ kfree(umem);
+}
+EXPORT_SYMBOL(ib_umem_release);
+
+int ib_umem_page_count(struct ib_umem *umem)
+{
+ int shift;
+ int i;
+ int n;
+ struct scatterlist *sg;
+
+ if (umem->odp_data)
+ return ib_umem_num_pages(umem);
+
+ shift = ilog2(umem->page_size);
+
+ n = 0;
+ for_each_sg(umem->sg_head.sgl, sg, umem->nmap, i)
+ n += sg_dma_len(sg) >> shift;
+
+ return n;
+}
+EXPORT_SYMBOL(ib_umem_page_count);
+
+/*
+ * Copy from the given ib_umem's pages to the given buffer.
+ *
+ * umem - the umem to copy from
+ * offset - offset to start copying from
+ * dst - destination buffer
+ * length - buffer length
+ *
+ * Returns 0 on success, or an error code.
+ */
+int ib_umem_copy_from(void *dst, struct ib_umem *umem, size_t offset,
+ size_t length)
+{
+ size_t end = offset + length;
+ int ret;
+
+ if (offset > umem->length || length > umem->length - offset) {
+ pr_err("ib_umem_copy_from not in range. offset: %zd umem length: %zd end: %zd\n",
+ offset, umem->length, end);
+ return -EINVAL;
+ }
+
+#ifdef __linux__
+ ret = sg_pcopy_to_buffer(umem->sg_head.sgl, umem->nmap, dst, length,
+ offset + ib_umem_offset(umem));
+#else
+ ret = 0;
+#endif
+ if (ret < 0)
+ return ret;
+ else if (ret != length)
+ return -EINVAL;
+ else
+ return 0;
+}
+EXPORT_SYMBOL(ib_umem_copy_from);
diff --git a/sys/ofed/drivers/infiniband/core/ib_umem_odp.c b/sys/ofed/drivers/infiniband/core/ib_umem_odp.c
new file mode 100644
index 0000000..bf00214
--- /dev/null
+++ b/sys/ofed/drivers/infiniband/core/ib_umem_odp.c
@@ -0,0 +1,667 @@
+/*
+ * Copyright (c) 2014 Mellanox Technologies. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#include <linux/types.h>
+#include <linux/sched.h>
+#include <linux/slab.h>
+#include <linux/vmalloc.h>
+
+#include <rdma/ib_verbs.h>
+#include <rdma/ib_umem.h>
+#include <rdma/ib_umem_odp.h>
+
+static void ib_umem_notifier_start_account(struct ib_umem *item)
+{
+ mutex_lock(&item->odp_data->umem_mutex);
+
+ /* Only update private counters for this umem if it has them.
+ * Otherwise skip it. All page faults will be delayed for this umem. */
+ if (item->odp_data->mn_counters_active) {
+ int notifiers_count = item->odp_data->notifiers_count++;
+
+ if (notifiers_count == 0)
+ /* Initialize the completion object for waiting on
+ * notifiers. Since notifier_count is zero, no one
+ * should be waiting right now. */
+ reinit_completion(&item->odp_data->notifier_completion);
+ }
+ mutex_unlock(&item->odp_data->umem_mutex);
+}
+
+static void ib_umem_notifier_end_account(struct ib_umem *item)
+{
+ mutex_lock(&item->odp_data->umem_mutex);
+
+ /* Only update private counters for this umem if it has them.
+ * Otherwise skip it. All page faults will be delayed for this umem. */
+ if (item->odp_data->mn_counters_active) {
+ /*
+ * This sequence increase will notify the QP page fault that
+ * the page that is going to be mapped in the spte could have
+ * been freed.
+ */
+ ++item->odp_data->notifiers_seq;
+ if (--item->odp_data->notifiers_count == 0)
+ complete_all(&item->odp_data->notifier_completion);
+ }
+ mutex_unlock(&item->odp_data->umem_mutex);
+}
+
+/* Account for a new mmu notifier in an ib_ucontext. */
+static void ib_ucontext_notifier_start_account(struct ib_ucontext *context)
+{
+ atomic_inc(&context->notifier_count);
+}
+
+/* Account for a terminating mmu notifier in an ib_ucontext.
+ *
+ * Must be called with the ib_ucontext->umem_rwsem semaphore unlocked, since
+ * the function takes the semaphore itself. */
+static void ib_ucontext_notifier_end_account(struct ib_ucontext *context)
+{
+ int zero_notifiers = atomic_dec_and_test(&context->notifier_count);
+
+ if (zero_notifiers &&
+ !list_empty(&context->no_private_counters)) {
+ /* No currently running mmu notifiers. Now is the chance to
+ * add private accounting to all previously added umems. */
+ struct ib_umem_odp *odp_data, *next;
+
+ /* Prevent concurrent mmu notifiers from working on the
+ * no_private_counters list. */
+ down_write(&context->umem_rwsem);
+
+ /* Read the notifier_count again, with the umem_rwsem
+ * semaphore taken for write. */
+ if (!atomic_read(&context->notifier_count)) {
+ list_for_each_entry_safe(odp_data, next,
+ &context->no_private_counters,
+ no_private_counters) {
+ mutex_lock(&odp_data->umem_mutex);
+ odp_data->mn_counters_active = true;
+ list_del(&odp_data->no_private_counters);
+ complete_all(&odp_data->notifier_completion);
+ mutex_unlock(&odp_data->umem_mutex);
+ }
+ }
+
+ up_write(&context->umem_rwsem);
+ }
+}
+
+static int ib_umem_notifier_release_trampoline(struct ib_umem *item, u64 start,
+ u64 end, void *cookie) {
+ /*
+ * Increase the number of notifiers running, to
+ * prevent any further fault handling on this MR.
+ */
+ ib_umem_notifier_start_account(item);
+ item->odp_data->dying = 1;
+ /* Make sure that the fact the umem is dying is out before we release
+ * all pending page faults. */
+ smp_wmb();
+ complete_all(&item->odp_data->notifier_completion);
+ item->context->invalidate_range(item, ib_umem_start(item),
+ ib_umem_end(item));
+ return 0;
+}
+
+static void ib_umem_notifier_release(struct mmu_notifier *mn,
+ struct mm_struct *mm)
+{
+ struct ib_ucontext *context = container_of(mn, struct ib_ucontext, mn);
+
+ if (!context->invalidate_range)
+ return;
+
+ ib_ucontext_notifier_start_account(context);
+ down_read(&context->umem_rwsem);
+ rbt_ib_umem_for_each_in_range(&context->umem_tree, 0,
+ ULLONG_MAX,
+ ib_umem_notifier_release_trampoline,
+ NULL);
+ up_read(&context->umem_rwsem);
+}
+
+static int invalidate_page_trampoline(struct ib_umem *item, u64 start,
+ u64 end, void *cookie)
+{
+ ib_umem_notifier_start_account(item);
+ item->context->invalidate_range(item, start, start + PAGE_SIZE);
+ ib_umem_notifier_end_account(item);
+ return 0;
+}
+
+static void ib_umem_notifier_invalidate_page(struct mmu_notifier *mn,
+ struct mm_struct *mm,
+ unsigned long address)
+{
+ struct ib_ucontext *context = container_of(mn, struct ib_ucontext, mn);
+
+ if (!context->invalidate_range)
+ return;
+
+ ib_ucontext_notifier_start_account(context);
+ down_read(&context->umem_rwsem);
+ rbt_ib_umem_for_each_in_range(&context->umem_tree, address,
+ address + PAGE_SIZE,
+ invalidate_page_trampoline, NULL);
+ up_read(&context->umem_rwsem);
+ ib_ucontext_notifier_end_account(context);
+}
+
+static int invalidate_range_start_trampoline(struct ib_umem *item, u64 start,
+ u64 end, void *cookie)
+{
+ ib_umem_notifier_start_account(item);
+ item->context->invalidate_range(item, start, end);
+ return 0;
+}
+
+static void ib_umem_notifier_invalidate_range_start(struct mmu_notifier *mn,
+ struct mm_struct *mm,
+ unsigned long start,
+ unsigned long end)
+{
+ struct ib_ucontext *context = container_of(mn, struct ib_ucontext, mn);
+
+ if (!context->invalidate_range)
+ return;
+
+ ib_ucontext_notifier_start_account(context);
+ down_read(&context->umem_rwsem);
+ rbt_ib_umem_for_each_in_range(&context->umem_tree, start,
+ end,
+ invalidate_range_start_trampoline, NULL);
+ up_read(&context->umem_rwsem);
+}
+
+static int invalidate_range_end_trampoline(struct ib_umem *item, u64 start,
+ u64 end, void *cookie)
+{
+ ib_umem_notifier_end_account(item);
+ return 0;
+}
+
+static void ib_umem_notifier_invalidate_range_end(struct mmu_notifier *mn,
+ struct mm_struct *mm,
+ unsigned long start,
+ unsigned long end)
+{
+ struct ib_ucontext *context = container_of(mn, struct ib_ucontext, mn);
+
+ if (!context->invalidate_range)
+ return;
+
+ down_read(&context->umem_rwsem);
+ rbt_ib_umem_for_each_in_range(&context->umem_tree, start,
+ end,
+ invalidate_range_end_trampoline, NULL);
+ up_read(&context->umem_rwsem);
+ ib_ucontext_notifier_end_account(context);
+}
+
+static const struct mmu_notifier_ops ib_umem_notifiers = {
+ .release = ib_umem_notifier_release,
+ .invalidate_page = ib_umem_notifier_invalidate_page,
+ .invalidate_range_start = ib_umem_notifier_invalidate_range_start,
+ .invalidate_range_end = ib_umem_notifier_invalidate_range_end,
+};
+
+int ib_umem_odp_get(struct ib_ucontext *context, struct ib_umem *umem)
+{
+ int ret_val;
+ pid_t our_pid;
+ struct mm_struct *mm = get_task_mm(current);
+
+ if (!mm)
+ return -EINVAL;
+
+ /* Prevent creating ODP MRs in child processes */
+ rcu_read_lock();
+ our_pid = get_pid(task_pid_group_leader(current));
+ rcu_read_unlock();
+ put_pid(our_pid);
+ if (context->tgid != our_pid) {
+ ret_val = -EINVAL;
+ goto out_mm;
+ }
+
+ umem->odp_data = kzalloc(sizeof(*umem->odp_data), GFP_KERNEL);
+ if (!umem->odp_data) {
+ ret_val = -ENOMEM;
+ goto out_mm;
+ }
+ umem->odp_data->umem = umem;
+
+ mutex_init(&umem->odp_data->umem_mutex);
+
+ init_completion(&umem->odp_data->notifier_completion);
+
+ umem->odp_data->page_list = vzalloc(ib_umem_num_pages(umem) *
+ sizeof(*umem->odp_data->page_list));
+ if (!umem->odp_data->page_list) {
+ ret_val = -ENOMEM;
+ goto out_odp_data;
+ }
+
+ umem->odp_data->dma_list = vzalloc(ib_umem_num_pages(umem) *
+ sizeof(*umem->odp_data->dma_list));
+ if (!umem->odp_data->dma_list) {
+ ret_val = -ENOMEM;
+ goto out_page_list;
+ }
+
+ /*
+ * When using MMU notifiers, we will get a
+ * notification before the "current" task (and MM) is
+ * destroyed. We use the umem_rwsem semaphore to synchronize.
+ */
+ down_write(&context->umem_rwsem);
+ context->odp_mrs_count++;
+ if (likely(ib_umem_start(umem) != ib_umem_end(umem)))
+ rbt_ib_umem_insert(&umem->odp_data->interval_tree,
+ &context->umem_tree);
+ if (likely(!atomic_read(&context->notifier_count)) ||
+ context->odp_mrs_count == 1)
+ umem->odp_data->mn_counters_active = true;
+ else
+ list_add(&umem->odp_data->no_private_counters,
+ &context->no_private_counters);
+ downgrade_write(&context->umem_rwsem);
+
+ if (context->odp_mrs_count == 1) {
+ /*
+ * Note that at this point, no MMU notifier is running
+ * for this context!
+ */
+ atomic_set(&context->notifier_count, 0);
+ INIT_HLIST_NODE(&context->mn.hlist);
+ context->mn.ops = &ib_umem_notifiers;
+ /*
+ * Lock-dep detects a false positive for mmap_sem vs.
+ * umem_rwsem, due to not grasping downgrade_write correctly.
+ */
+ ret_val = mmu_notifier_register(&context->mn, mm);
+ if (ret_val) {
+ pr_err("Failed to register mmu_notifier %d\n", ret_val);
+ ret_val = -EBUSY;
+ goto out_mutex;
+ }
+ }
+
+ up_read(&context->umem_rwsem);
+
+ /*
+ * Note that doing an mmput can cause a notifier for the relevant mm.
+ * If the notifier is called while we hold the umem_rwsem, this will
+ * cause a deadlock. Therefore, we release the reference only after we
+ * released the semaphore.
+ */
+ mmput(mm);
+ return 0;
+
+out_mutex:
+ up_read(&context->umem_rwsem);
+ vfree(umem->odp_data->dma_list);
+out_page_list:
+ vfree(umem->odp_data->page_list);
+out_odp_data:
+ kfree(umem->odp_data);
+out_mm:
+ mmput(mm);
+ return ret_val;
+}
+
+void ib_umem_odp_release(struct ib_umem *umem)
+{
+ struct ib_ucontext *context = umem->context;
+
+ /*
+ * Ensure that no more pages are mapped in the umem.
+ *
+ * It is the driver's responsibility to ensure, before calling us,
+ * that the hardware will not attempt to access the MR any more.
+ */
+ ib_umem_odp_unmap_dma_pages(umem, ib_umem_start(umem),
+ ib_umem_end(umem));
+
+ down_write(&context->umem_rwsem);
+ if (likely(ib_umem_start(umem) != ib_umem_end(umem)))
+ rbt_ib_umem_remove(&umem->odp_data->interval_tree,
+ &context->umem_tree);
+ context->odp_mrs_count--;
+ if (!umem->odp_data->mn_counters_active) {
+ list_del(&umem->odp_data->no_private_counters);
+ complete_all(&umem->odp_data->notifier_completion);
+ }
+
+ /*
+ * Downgrade the lock to a read lock. This ensures that the notifiers
+ * (who lock the mutex for reading) will be able to finish, and we
+ * will be able to enventually obtain the mmu notifiers SRCU. Note
+ * that since we are doing it atomically, no other user could register
+ * and unregister while we do the check.
+ */
+ downgrade_write(&context->umem_rwsem);
+ if (!context->odp_mrs_count) {
+ struct task_struct *owning_process = NULL;
+ struct mm_struct *owning_mm = NULL;
+
+ owning_process = get_pid_task(context->tgid,
+ PIDTYPE_PID);
+ if (owning_process == NULL)
+ /*
+ * The process is already dead, notifier were removed
+ * already.
+ */
+ goto out;
+
+ owning_mm = get_task_mm(owning_process);
+ if (owning_mm == NULL)
+ /*
+ * The process' mm is already dead, notifier were
+ * removed already.
+ */
+ goto out_put_task;
+ mmu_notifier_unregister(&context->mn, owning_mm);
+
+ mmput(owning_mm);
+
+out_put_task:
+ put_task_struct(owning_process);
+ }
+out:
+ up_read(&context->umem_rwsem);
+
+ vfree(umem->odp_data->dma_list);
+ vfree(umem->odp_data->page_list);
+ kfree(umem->odp_data);
+ kfree(umem);
+}
+
+/*
+ * Map for DMA and insert a single page into the on-demand paging page tables.
+ *
+ * @umem: the umem to insert the page to.
+ * @page_index: index in the umem to add the page to.
+ * @page: the page struct to map and add.
+ * @access_mask: access permissions needed for this page.
+ * @current_seq: sequence number for synchronization with invalidations.
+ * the sequence number is taken from
+ * umem->odp_data->notifiers_seq.
+ *
+ * The function returns -EFAULT if the DMA mapping operation fails. It returns
+ * -EAGAIN if a concurrent invalidation prevents us from updating the page.
+ *
+ * The page is released via put_page even if the operation failed. For
+ * on-demand pinning, the page is released whenever it isn't stored in the
+ * umem.
+ */
+static int ib_umem_odp_map_dma_single_page(
+ struct ib_umem *umem,
+ int page_index,
+ u64 base_virt_addr,
+ struct page *page,
+ u64 access_mask,
+ unsigned long current_seq)
+{
+ struct ib_device *dev = umem->context->device;
+ dma_addr_t dma_addr;
+ int stored_page = 0;
+ int remove_existing_mapping = 0;
+ int ret = 0;
+
+ /*
+ * Note: we avoid writing if seq is different from the initial seq, to
+ * handle case of a racing notifier. This check also allows us to bail
+ * early if we have a notifier running in parallel with us.
+ */
+ if (ib_umem_mmu_notifier_retry(umem, current_seq)) {
+ ret = -EAGAIN;
+ goto out;
+ }
+ if (!(umem->odp_data->dma_list[page_index])) {
+ dma_addr = ib_dma_map_page(dev,
+ page,
+ 0, PAGE_SIZE,
+ DMA_BIDIRECTIONAL);
+ if (ib_dma_mapping_error(dev, dma_addr)) {
+ ret = -EFAULT;
+ goto out;
+ }
+ umem->odp_data->dma_list[page_index] = dma_addr | access_mask;
+ umem->odp_data->page_list[page_index] = page;
+ stored_page = 1;
+ } else if (umem->odp_data->page_list[page_index] == page) {
+ umem->odp_data->dma_list[page_index] |= access_mask;
+ } else {
+ pr_err("error: got different pages in IB device and from get_user_pages. IB device page: %p, gup page: %p\n",
+ umem->odp_data->page_list[page_index], page);
+ /* Better remove the mapping now, to prevent any further
+ * damage. */
+ remove_existing_mapping = 1;
+ }
+
+out:
+ /* On Demand Paging - avoid pinning the page */
+ if (umem->context->invalidate_range || !stored_page)
+ put_page(page);
+
+ if (remove_existing_mapping && umem->context->invalidate_range) {
+ invalidate_page_trampoline(
+ umem,
+ base_virt_addr + (page_index * PAGE_SIZE),
+ base_virt_addr + ((page_index+1)*PAGE_SIZE),
+ NULL);
+ ret = -EAGAIN;
+ }
+
+ return ret;
+}
+
+/**
+ * ib_umem_odp_map_dma_pages - Pin and DMA map userspace memory in an ODP MR.
+ *
+ * Pins the range of pages passed in the argument, and maps them to
+ * DMA addresses. The DMA addresses of the mapped pages is updated in
+ * umem->odp_data->dma_list.
+ *
+ * Returns the number of pages mapped in success, negative error code
+ * for failure.
+ * An -EAGAIN error code is returned when a concurrent mmu notifier prevents
+ * the function from completing its task.
+ *
+ * @umem: the umem to map and pin
+ * @user_virt: the address from which we need to map.
+ * @bcnt: the minimal number of bytes to pin and map. The mapping might be
+ * bigger due to alignment, and may also be smaller in case of an error
+ * pinning or mapping a page. The actual pages mapped is returned in
+ * the return value.
+ * @access_mask: bit mask of the requested access permissions for the given
+ * range.
+ * @current_seq: the MMU notifiers sequance value for synchronization with
+ * invalidations. the sequance number is read from
+ * umem->odp_data->notifiers_seq before calling this function
+ */
+int ib_umem_odp_map_dma_pages(struct ib_umem *umem, u64 user_virt, u64 bcnt,
+ u64 access_mask, unsigned long current_seq)
+{
+ struct task_struct *owning_process = NULL;
+ struct mm_struct *owning_mm = NULL;
+ struct page **local_page_list = NULL;
+ u64 off;
+ int j, k, ret = 0, start_idx, npages = 0;
+ u64 base_virt_addr;
+ unsigned int flags = 0;
+
+ if (access_mask == 0)
+ return -EINVAL;
+
+ if (user_virt < ib_umem_start(umem) ||
+ user_virt + bcnt > ib_umem_end(umem))
+ return -EFAULT;
+
+ local_page_list = (struct page **)__get_free_page(GFP_KERNEL);
+ if (!local_page_list)
+ return -ENOMEM;
+
+ off = user_virt & (~PAGE_MASK);
+ user_virt = user_virt & PAGE_MASK;
+ base_virt_addr = user_virt;
+ bcnt += off; /* Charge for the first page offset as well. */
+
+ owning_process = get_pid_task(umem->context->tgid, PIDTYPE_PID);
+ if (owning_process == NULL) {
+ ret = -EINVAL;
+ goto out_no_task;
+ }
+
+ owning_mm = get_task_mm(owning_process);
+ if (owning_mm == NULL) {
+ ret = -EINVAL;
+ goto out_put_task;
+ }
+
+ if (access_mask & ODP_WRITE_ALLOWED_BIT)
+ flags |= FOLL_WRITE;
+
+ start_idx = (user_virt - ib_umem_start(umem)) >> PAGE_SHIFT;
+ k = start_idx;
+
+ while (bcnt > 0) {
+ const size_t gup_num_pages =
+ min_t(size_t, ALIGN(bcnt, PAGE_SIZE) / PAGE_SIZE,
+ PAGE_SIZE / sizeof(struct page *));
+
+ down_read(&owning_mm->mmap_sem);
+ /*
+ * Note: this might result in redundent page getting. We can
+ * avoid this by checking dma_list to be 0 before calling
+ * get_user_pages. However, this make the code much more
+ * complex (and doesn't gain us much performance in most use
+ * cases).
+ */
+ npages = get_user_pages_remote(owning_process, owning_mm,
+ user_virt, gup_num_pages,
+ flags, local_page_list, NULL);
+ up_read(&owning_mm->mmap_sem);
+
+ if (npages < 0)
+ break;
+
+ bcnt -= min_t(size_t, npages << PAGE_SHIFT, bcnt);
+ user_virt += npages << PAGE_SHIFT;
+ mutex_lock(&umem->odp_data->umem_mutex);
+ for (j = 0; j < npages; ++j) {
+ ret = ib_umem_odp_map_dma_single_page(
+ umem, k, base_virt_addr, local_page_list[j],
+ access_mask, current_seq);
+ if (ret < 0)
+ break;
+ k++;
+ }
+ mutex_unlock(&umem->odp_data->umem_mutex);
+
+ if (ret < 0) {
+ /* Release left over pages when handling errors. */
+ for (++j; j < npages; ++j)
+ put_page(local_page_list[j]);
+ break;
+ }
+ }
+
+ if (ret >= 0) {
+ if (npages < 0 && k == start_idx)
+ ret = npages;
+ else
+ ret = k - start_idx;
+ }
+
+ mmput(owning_mm);
+out_put_task:
+ put_task_struct(owning_process);
+out_no_task:
+ free_page((unsigned long)local_page_list);
+ return ret;
+}
+EXPORT_SYMBOL(ib_umem_odp_map_dma_pages);
+
+void ib_umem_odp_unmap_dma_pages(struct ib_umem *umem, u64 virt,
+ u64 bound)
+{
+ int idx;
+ u64 addr;
+ struct ib_device *dev = umem->context->device;
+
+ virt = max_t(u64, virt, ib_umem_start(umem));
+ bound = min_t(u64, bound, ib_umem_end(umem));
+ /* Note that during the run of this function, the
+ * notifiers_count of the MR is > 0, preventing any racing
+ * faults from completion. We might be racing with other
+ * invalidations, so we must make sure we free each page only
+ * once. */
+ mutex_lock(&umem->odp_data->umem_mutex);
+ for (addr = virt; addr < bound; addr += (u64)umem->page_size) {
+ idx = (addr - ib_umem_start(umem)) / PAGE_SIZE;
+ if (umem->odp_data->page_list[idx]) {
+ struct page *page = umem->odp_data->page_list[idx];
+ dma_addr_t dma = umem->odp_data->dma_list[idx];
+ dma_addr_t dma_addr = dma & ODP_DMA_ADDR_MASK;
+
+ WARN_ON(!dma_addr);
+
+ ib_dma_unmap_page(dev, dma_addr, PAGE_SIZE,
+ DMA_BIDIRECTIONAL);
+ if (dma & ODP_WRITE_ALLOWED_BIT) {
+ struct page *head_page = compound_head(page);
+ /*
+ * set_page_dirty prefers being called with
+ * the page lock. However, MMU notifiers are
+ * called sometimes with and sometimes without
+ * the lock. We rely on the umem_mutex instead
+ * to prevent other mmu notifiers from
+ * continuing and allowing the page mapping to
+ * be removed.
+ */
+ set_page_dirty(head_page);
+ }
+ /* on demand pinning support */
+ if (!umem->context->invalidate_range)
+ put_page(page);
+ umem->odp_data->page_list[idx] = NULL;
+ umem->odp_data->dma_list[idx] = 0;
+ }
+ }
+ mutex_unlock(&umem->odp_data->umem_mutex);
+}
+EXPORT_SYMBOL(ib_umem_odp_unmap_dma_pages);
diff --git a/sys/ofed/drivers/infiniband/core/ib_umem_rbtree.c b/sys/ofed/drivers/infiniband/core/ib_umem_rbtree.c
new file mode 100644
index 0000000..c927729
--- /dev/null
+++ b/sys/ofed/drivers/infiniband/core/ib_umem_rbtree.c
@@ -0,0 +1,93 @@
+/*
+ * Copyright (c) 2014 Mellanox Technologies. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/sched.h>
+#include <linux/gfp.h>
+#include <rdma/ib_umem_odp.h>
+
+/*
+ * The ib_umem list keeps track of memory regions for which the HW
+ * device request to receive notification when the related memory
+ * mapping is changed.
+ *
+ * ib_umem_lock protects the list.
+ */
+
+static inline u64 node_start(struct umem_odp_node *n)
+{
+ struct ib_umem_odp *umem_odp =
+ container_of(n, struct ib_umem_odp, interval_tree);
+
+ return ib_umem_start(umem_odp->umem);
+}
+
+/* Note that the representation of the intervals in the interval tree
+ * considers the ending point as contained in the interval, while the
+ * function ib_umem_end returns the first address which is not contained
+ * in the umem.
+ */
+static inline u64 node_last(struct umem_odp_node *n)
+{
+ struct ib_umem_odp *umem_odp =
+ container_of(n, struct ib_umem_odp, interval_tree);
+
+ return ib_umem_end(umem_odp->umem) - 1;
+}
+
+INTERVAL_TREE_DEFINE(struct umem_odp_node, rb, u64, __subtree_last,
+ node_start, node_last, , rbt_ib_umem)
+
+/* @last is not a part of the interval. See comment for function
+ * node_last.
+ */
+int rbt_ib_umem_for_each_in_range(struct rb_root *root,
+ u64 start, u64 last,
+ umem_call_back cb,
+ void *cookie)
+{
+ int ret_val = 0;
+ struct umem_odp_node *node;
+ struct ib_umem_odp *umem;
+
+ if (unlikely(start == last))
+ return ret_val;
+
+ for (node = rbt_ib_umem_iter_first(root, start, last - 1); node;
+ node = rbt_ib_umem_iter_next(node, start, last - 1)) {
+ umem = container_of(node, struct ib_umem_odp, interval_tree);
+ ret_val = cb(umem->umem, start, last, cookie) || ret_val;
+ }
+
+ return ret_val;
+}
diff --git a/sys/ofed/drivers/infiniband/core/ib_user_mad.c b/sys/ofed/drivers/infiniband/core/ib_user_mad.c
new file mode 100644
index 0000000..2fb032b
--- /dev/null
+++ b/sys/ofed/drivers/infiniband/core/ib_user_mad.c
@@ -0,0 +1,1401 @@
+/*
+ * Copyright (c) 2004 Topspin Communications. All rights reserved.
+ * Copyright (c) 2005 Voltaire, Inc. All rights reserved.
+ * Copyright (c) 2005 Sun Microsystems, Inc. All rights reserved.
+ * Copyright (c) 2008 Cisco. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#define pr_fmt(fmt) "user_mad: " fmt
+
+#include <linux/module.h>
+#include <linux/device.h>
+#include <linux/err.h>
+#include <linux/fs.h>
+#include <linux/cdev.h>
+#include <linux/dma-mapping.h>
+#include <linux/poll.h>
+#include <linux/mutex.h>
+#include <linux/kref.h>
+#include <linux/compat.h>
+#include <linux/sched.h>
+#include <linux/semaphore.h>
+#include <linux/slab.h>
+
+#include <asm/uaccess.h>
+
+#include <rdma/ib_mad.h>
+#include <rdma/ib_user_mad.h>
+
+MODULE_AUTHOR("Roland Dreier");
+MODULE_DESCRIPTION("InfiniBand userspace MAD packet access");
+MODULE_LICENSE("Dual BSD/GPL");
+
+enum {
+ IB_UMAD_MAX_PORTS = 64,
+ IB_UMAD_MAX_AGENTS = 32,
+
+ IB_UMAD_MAJOR = 231,
+ IB_UMAD_MINOR_BASE = 0
+};
+
+/*
+ * Our lifetime rules for these structs are the following:
+ * device special file is opened, we take a reference on the
+ * ib_umad_port's struct ib_umad_device. We drop these
+ * references in the corresponding close().
+ *
+ * In addition to references coming from open character devices, there
+ * is one more reference to each ib_umad_device representing the
+ * module's reference taken when allocating the ib_umad_device in
+ * ib_umad_add_one().
+ *
+ * When destroying an ib_umad_device, we drop the module's reference.
+ */
+
+struct ib_umad_port {
+ struct cdev cdev;
+ struct device *dev;
+
+ struct cdev sm_cdev;
+ struct device *sm_dev;
+ struct semaphore sm_sem;
+
+ struct mutex file_mutex;
+ struct list_head file_list;
+
+ struct ib_device *ib_dev;
+ struct ib_umad_device *umad_dev;
+ int dev_num;
+ u8 port_num;
+};
+
+struct ib_umad_device {
+ struct kobject kobj;
+ struct ib_umad_port port[0];
+};
+
+struct ib_umad_file {
+ struct mutex mutex;
+ struct ib_umad_port *port;
+ struct list_head recv_list;
+ struct list_head send_list;
+ struct list_head port_list;
+ spinlock_t send_lock;
+ wait_queue_head_t recv_wait;
+ struct ib_mad_agent *agent[IB_UMAD_MAX_AGENTS];
+ int agents_dead;
+ u8 use_pkey_index;
+ u8 already_used;
+};
+
+struct ib_umad_packet {
+ struct ib_mad_send_buf *msg;
+ struct ib_mad_recv_wc *recv_wc;
+ struct list_head list;
+ int length;
+ struct ib_user_mad mad;
+};
+
+static struct class *umad_class;
+
+static const dev_t base_dev = MKDEV(IB_UMAD_MAJOR, IB_UMAD_MINOR_BASE);
+
+static DEFINE_SPINLOCK(port_lock);
+static DECLARE_BITMAP(dev_map, IB_UMAD_MAX_PORTS);
+
+static void ib_umad_add_one(struct ib_device *device);
+static void ib_umad_remove_one(struct ib_device *device, void *client_data);
+
+static void ib_umad_release_dev(struct kobject *kobj)
+{
+ struct ib_umad_device *dev =
+ container_of(kobj, struct ib_umad_device, kobj);
+
+ kfree(dev);
+}
+
+static struct kobj_type ib_umad_dev_ktype = {
+ .release = ib_umad_release_dev,
+};
+
+static int hdr_size(struct ib_umad_file *file)
+{
+ return file->use_pkey_index ? sizeof (struct ib_user_mad_hdr) :
+ sizeof (struct ib_user_mad_hdr_old);
+}
+
+/* caller must hold file->mutex */
+static struct ib_mad_agent *__get_agent(struct ib_umad_file *file, int id)
+{
+ return file->agents_dead ? NULL : file->agent[id];
+}
+
+static int queue_packet(struct ib_umad_file *file,
+ struct ib_mad_agent *agent,
+ struct ib_umad_packet *packet)
+{
+ int ret = 1;
+
+ mutex_lock(&file->mutex);
+
+ for (packet->mad.hdr.id = 0;
+ packet->mad.hdr.id < IB_UMAD_MAX_AGENTS;
+ packet->mad.hdr.id++)
+ if (agent == __get_agent(file, packet->mad.hdr.id)) {
+ list_add_tail(&packet->list, &file->recv_list);
+ wake_up_interruptible(&file->recv_wait);
+ ret = 0;
+ break;
+ }
+
+ mutex_unlock(&file->mutex);
+
+ return ret;
+}
+
+static void dequeue_send(struct ib_umad_file *file,
+ struct ib_umad_packet *packet)
+{
+ spin_lock_irq(&file->send_lock);
+ list_del(&packet->list);
+ spin_unlock_irq(&file->send_lock);
+}
+
+static void send_handler(struct ib_mad_agent *agent,
+ struct ib_mad_send_wc *send_wc)
+{
+ struct ib_umad_file *file = agent->context;
+ struct ib_umad_packet *packet = send_wc->send_buf->context[0];
+
+ dequeue_send(file, packet);
+ ib_destroy_ah(packet->msg->ah);
+ ib_free_send_mad(packet->msg);
+
+ if (send_wc->status == IB_WC_RESP_TIMEOUT_ERR) {
+ packet->length = IB_MGMT_MAD_HDR;
+ packet->mad.hdr.status = ETIMEDOUT;
+ if (!queue_packet(file, agent, packet))
+ return;
+ }
+ kfree(packet);
+}
+
+static void recv_handler(struct ib_mad_agent *agent,
+ struct ib_mad_send_buf *send_buf,
+ struct ib_mad_recv_wc *mad_recv_wc)
+{
+ struct ib_umad_file *file = agent->context;
+ struct ib_umad_packet *packet;
+
+ if (mad_recv_wc->wc->status != IB_WC_SUCCESS)
+ goto err1;
+
+ packet = kzalloc(sizeof *packet, GFP_KERNEL);
+ if (!packet)
+ goto err1;
+
+ packet->length = mad_recv_wc->mad_len;
+ packet->recv_wc = mad_recv_wc;
+
+ packet->mad.hdr.status = 0;
+ packet->mad.hdr.length = hdr_size(file) + mad_recv_wc->mad_len;
+ packet->mad.hdr.qpn = cpu_to_be32(mad_recv_wc->wc->src_qp);
+ packet->mad.hdr.lid = cpu_to_be16(mad_recv_wc->wc->slid);
+ packet->mad.hdr.sl = mad_recv_wc->wc->sl;
+ packet->mad.hdr.path_bits = mad_recv_wc->wc->dlid_path_bits;
+ packet->mad.hdr.pkey_index = mad_recv_wc->wc->pkey_index;
+ packet->mad.hdr.grh_present = !!(mad_recv_wc->wc->wc_flags & IB_WC_GRH);
+ if (packet->mad.hdr.grh_present) {
+ struct ib_ah_attr ah_attr;
+
+ ib_init_ah_from_wc(agent->device, agent->port_num,
+ mad_recv_wc->wc, mad_recv_wc->recv_buf.grh,
+ &ah_attr);
+
+ packet->mad.hdr.gid_index = ah_attr.grh.sgid_index;
+ packet->mad.hdr.hop_limit = ah_attr.grh.hop_limit;
+ packet->mad.hdr.traffic_class = ah_attr.grh.traffic_class;
+ memcpy(packet->mad.hdr.gid, &ah_attr.grh.dgid, 16);
+ packet->mad.hdr.flow_label = cpu_to_be32(ah_attr.grh.flow_label);
+ }
+
+ if (queue_packet(file, agent, packet))
+ goto err2;
+ return;
+
+err2:
+ kfree(packet);
+err1:
+ ib_free_recv_mad(mad_recv_wc);
+}
+
+static ssize_t copy_recv_mad(struct ib_umad_file *file, char __user *buf,
+ struct ib_umad_packet *packet, size_t count)
+{
+ struct ib_mad_recv_buf *recv_buf;
+ int left, seg_payload, offset, max_seg_payload;
+ size_t seg_size;
+
+ recv_buf = &packet->recv_wc->recv_buf;
+ seg_size = packet->recv_wc->mad_seg_size;
+
+ /* We need enough room to copy the first (or only) MAD segment. */
+ if ((packet->length <= seg_size &&
+ count < hdr_size(file) + packet->length) ||
+ (packet->length > seg_size &&
+ count < hdr_size(file) + seg_size))
+ return -EINVAL;
+
+ if (copy_to_user(buf, &packet->mad, hdr_size(file)))
+ return -EFAULT;
+
+ buf += hdr_size(file);
+ seg_payload = min_t(int, packet->length, seg_size);
+ if (copy_to_user(buf, recv_buf->mad, seg_payload))
+ return -EFAULT;
+
+ if (seg_payload < packet->length) {
+ /*
+ * Multipacket RMPP MAD message. Copy remainder of message.
+ * Note that last segment may have a shorter payload.
+ */
+ if (count < hdr_size(file) + packet->length) {
+ /*
+ * The buffer is too small, return the first RMPP segment,
+ * which includes the RMPP message length.
+ */
+ return -ENOSPC;
+ }
+ offset = ib_get_mad_data_offset(recv_buf->mad->mad_hdr.mgmt_class);
+ max_seg_payload = seg_size - offset;
+
+ for (left = packet->length - seg_payload, buf += seg_payload;
+ left; left -= seg_payload, buf += seg_payload) {
+ recv_buf = container_of(recv_buf->list.next,
+ struct ib_mad_recv_buf, list);
+ seg_payload = min(left, max_seg_payload);
+ if (copy_to_user(buf, (char *)recv_buf->mad + offset,
+ seg_payload))
+ return -EFAULT;
+ }
+ }
+ return hdr_size(file) + packet->length;
+}
+
+static ssize_t copy_send_mad(struct ib_umad_file *file, char __user *buf,
+ struct ib_umad_packet *packet, size_t count)
+{
+ ssize_t size = hdr_size(file) + packet->length;
+
+ if (count < size)
+ return -EINVAL;
+
+ if (copy_to_user(buf, &packet->mad, hdr_size(file)))
+ return -EFAULT;
+
+ buf += hdr_size(file);
+
+ if (copy_to_user(buf, packet->mad.data, packet->length))
+ return -EFAULT;
+
+ return size;
+}
+
+static ssize_t ib_umad_read(struct file *filp, char __user *buf,
+ size_t count, loff_t *pos)
+{
+ struct ib_umad_file *file = filp->private_data;
+ struct ib_umad_packet *packet;
+ ssize_t ret;
+
+ if (count < hdr_size(file))
+ return -EINVAL;
+
+ mutex_lock(&file->mutex);
+
+ while (list_empty(&file->recv_list)) {
+ mutex_unlock(&file->mutex);
+
+ if (filp->f_flags & O_NONBLOCK)
+ return -EAGAIN;
+
+ if (wait_event_interruptible(file->recv_wait,
+ !list_empty(&file->recv_list)))
+ return -ERESTARTSYS;
+
+ mutex_lock(&file->mutex);
+ }
+
+ packet = list_entry(file->recv_list.next, struct ib_umad_packet, list);
+ list_del(&packet->list);
+
+ mutex_unlock(&file->mutex);
+
+ if (packet->recv_wc)
+ ret = copy_recv_mad(file, buf, packet, count);
+ else
+ ret = copy_send_mad(file, buf, packet, count);
+
+ if (ret < 0) {
+ /* Requeue packet */
+ mutex_lock(&file->mutex);
+ list_add(&packet->list, &file->recv_list);
+ mutex_unlock(&file->mutex);
+ } else {
+ if (packet->recv_wc)
+ ib_free_recv_mad(packet->recv_wc);
+ kfree(packet);
+ }
+ return ret;
+}
+
+static int copy_rmpp_mad(struct ib_mad_send_buf *msg, const char __user *buf)
+{
+ int left, seg;
+
+ /* Copy class specific header */
+ if ((msg->hdr_len > IB_MGMT_RMPP_HDR) &&
+ copy_from_user((char *)msg->mad + IB_MGMT_RMPP_HDR, buf + IB_MGMT_RMPP_HDR,
+ msg->hdr_len - IB_MGMT_RMPP_HDR))
+ return -EFAULT;
+
+ /* All headers are in place. Copy data segments. */
+ for (seg = 1, left = msg->data_len, buf += msg->hdr_len; left > 0;
+ seg++, left -= msg->seg_size, buf += msg->seg_size) {
+ if (copy_from_user(ib_get_rmpp_segment(msg, seg), buf,
+ min(left, msg->seg_size)))
+ return -EFAULT;
+ }
+ return 0;
+}
+
+static int same_destination(struct ib_user_mad_hdr *hdr1,
+ struct ib_user_mad_hdr *hdr2)
+{
+ if (!hdr1->grh_present && !hdr2->grh_present)
+ return (hdr1->lid == hdr2->lid);
+
+ if (hdr1->grh_present && hdr2->grh_present)
+ return !memcmp(hdr1->gid, hdr2->gid, 16);
+
+ return 0;
+}
+
+static int is_duplicate(struct ib_umad_file *file,
+ struct ib_umad_packet *packet)
+{
+ struct ib_umad_packet *sent_packet;
+ struct ib_mad_hdr *sent_hdr, *hdr;
+
+ hdr = (struct ib_mad_hdr *) packet->mad.data;
+ list_for_each_entry(sent_packet, &file->send_list, list) {
+ sent_hdr = (struct ib_mad_hdr *) sent_packet->mad.data;
+
+ if ((hdr->tid != sent_hdr->tid) ||
+ (hdr->mgmt_class != sent_hdr->mgmt_class))
+ continue;
+
+ /*
+ * No need to be overly clever here. If two new operations have
+ * the same TID, reject the second as a duplicate. This is more
+ * restrictive than required by the spec.
+ */
+ if (!ib_response_mad(hdr)) {
+ if (!ib_response_mad(sent_hdr))
+ return 1;
+ continue;
+ } else if (!ib_response_mad(sent_hdr))
+ continue;
+
+ if (same_destination(&packet->mad.hdr, &sent_packet->mad.hdr))
+ return 1;
+ }
+
+ return 0;
+}
+
+static ssize_t ib_umad_write(struct file *filp, const char __user *buf,
+ size_t count, loff_t *pos)
+{
+ struct ib_umad_file *file = filp->private_data;
+ struct ib_umad_packet *packet;
+ struct ib_mad_agent *agent;
+ struct ib_ah_attr ah_attr;
+ struct ib_ah *ah;
+ struct ib_rmpp_mad *rmpp_mad;
+ __be64 *tid;
+ int ret, data_len, hdr_len, copy_offset, rmpp_active;
+ u8 base_version;
+
+ if (count < hdr_size(file) + IB_MGMT_RMPP_HDR)
+ return -EINVAL;
+
+ packet = kzalloc(sizeof *packet + IB_MGMT_RMPP_HDR, GFP_KERNEL);
+ if (!packet)
+ return -ENOMEM;
+
+ if (copy_from_user(&packet->mad, buf, hdr_size(file))) {
+ ret = -EFAULT;
+ goto err;
+ }
+
+ if (packet->mad.hdr.id >= IB_UMAD_MAX_AGENTS) {
+ ret = -EINVAL;
+ goto err;
+ }
+
+ buf += hdr_size(file);
+
+ if (copy_from_user(packet->mad.data, buf, IB_MGMT_RMPP_HDR)) {
+ ret = -EFAULT;
+ goto err;
+ }
+
+ mutex_lock(&file->mutex);
+
+ agent = __get_agent(file, packet->mad.hdr.id);
+ if (!agent) {
+ ret = -EINVAL;
+ goto err_up;
+ }
+
+ memset(&ah_attr, 0, sizeof ah_attr);
+ ah_attr.dlid = be16_to_cpu(packet->mad.hdr.lid);
+ ah_attr.sl = packet->mad.hdr.sl;
+ ah_attr.src_path_bits = packet->mad.hdr.path_bits;
+ ah_attr.port_num = file->port->port_num;
+ if (packet->mad.hdr.grh_present) {
+ ah_attr.ah_flags = IB_AH_GRH;
+ memcpy(ah_attr.grh.dgid.raw, packet->mad.hdr.gid, 16);
+ ah_attr.grh.sgid_index = packet->mad.hdr.gid_index;
+ ah_attr.grh.flow_label = be32_to_cpu(packet->mad.hdr.flow_label);
+ ah_attr.grh.hop_limit = packet->mad.hdr.hop_limit;
+ ah_attr.grh.traffic_class = packet->mad.hdr.traffic_class;
+ }
+
+ ah = ib_create_ah(agent->qp->pd, &ah_attr);
+ if (IS_ERR(ah)) {
+ ret = PTR_ERR(ah);
+ goto err_up;
+ }
+
+ rmpp_mad = (struct ib_rmpp_mad *) packet->mad.data;
+ hdr_len = ib_get_mad_data_offset(rmpp_mad->mad_hdr.mgmt_class);
+
+ if (ib_is_mad_class_rmpp(rmpp_mad->mad_hdr.mgmt_class)
+ && ib_mad_kernel_rmpp_agent(agent)) {
+ copy_offset = IB_MGMT_RMPP_HDR;
+ rmpp_active = ib_get_rmpp_flags(&rmpp_mad->rmpp_hdr) &
+ IB_MGMT_RMPP_FLAG_ACTIVE;
+ } else {
+ copy_offset = IB_MGMT_MAD_HDR;
+ rmpp_active = 0;
+ }
+
+ base_version = ((struct ib_mad_hdr *)&packet->mad.data)->base_version;
+ data_len = count - hdr_size(file) - hdr_len;
+ packet->msg = ib_create_send_mad(agent,
+ be32_to_cpu(packet->mad.hdr.qpn),
+ packet->mad.hdr.pkey_index, rmpp_active,
+ hdr_len, data_len, GFP_KERNEL,
+ base_version);
+ if (IS_ERR(packet->msg)) {
+ ret = PTR_ERR(packet->msg);
+ goto err_ah;
+ }
+
+ packet->msg->ah = ah;
+ packet->msg->timeout_ms = packet->mad.hdr.timeout_ms;
+ packet->msg->retries = packet->mad.hdr.retries;
+ packet->msg->context[0] = packet;
+
+ /* Copy MAD header. Any RMPP header is already in place. */
+ memcpy(packet->msg->mad, packet->mad.data, IB_MGMT_MAD_HDR);
+
+ if (!rmpp_active) {
+ if (copy_from_user((char *)packet->msg->mad + copy_offset,
+ buf + copy_offset,
+ hdr_len + data_len - copy_offset)) {
+ ret = -EFAULT;
+ goto err_msg;
+ }
+ } else {
+ ret = copy_rmpp_mad(packet->msg, buf);
+ if (ret)
+ goto err_msg;
+ }
+
+ /*
+ * Set the high-order part of the transaction ID to make MADs from
+ * different agents unique, and allow routing responses back to the
+ * original requestor.
+ */
+ if (!ib_response_mad(packet->msg->mad)) {
+ tid = &((struct ib_mad_hdr *) packet->msg->mad)->tid;
+ *tid = cpu_to_be64(((u64) agent->hi_tid) << 32 |
+ (be64_to_cpup(tid) & 0xffffffff));
+ rmpp_mad->mad_hdr.tid = *tid;
+ }
+
+ if (!ib_mad_kernel_rmpp_agent(agent)
+ && ib_is_mad_class_rmpp(rmpp_mad->mad_hdr.mgmt_class)
+ && (ib_get_rmpp_flags(&rmpp_mad->rmpp_hdr) & IB_MGMT_RMPP_FLAG_ACTIVE)) {
+ spin_lock_irq(&file->send_lock);
+ list_add_tail(&packet->list, &file->send_list);
+ spin_unlock_irq(&file->send_lock);
+ } else {
+ spin_lock_irq(&file->send_lock);
+ ret = is_duplicate(file, packet);
+ if (!ret)
+ list_add_tail(&packet->list, &file->send_list);
+ spin_unlock_irq(&file->send_lock);
+ if (ret) {
+ ret = -EINVAL;
+ goto err_msg;
+ }
+ }
+
+ ret = ib_post_send_mad(packet->msg, NULL);
+ if (ret)
+ goto err_send;
+
+ mutex_unlock(&file->mutex);
+ return count;
+
+err_send:
+ dequeue_send(file, packet);
+err_msg:
+ ib_free_send_mad(packet->msg);
+err_ah:
+ ib_destroy_ah(ah);
+err_up:
+ mutex_unlock(&file->mutex);
+err:
+ kfree(packet);
+ return ret;
+}
+
+static unsigned int ib_umad_poll(struct file *filp, struct poll_table_struct *wait)
+{
+ struct ib_umad_file *file = filp->private_data;
+
+ /* we will always be able to post a MAD send */
+ unsigned int mask = POLLOUT | POLLWRNORM;
+
+ poll_wait(filp, &file->recv_wait, wait);
+
+ if (!list_empty(&file->recv_list))
+ mask |= POLLIN | POLLRDNORM;
+
+ return mask;
+}
+
+static int ib_umad_reg_agent(struct ib_umad_file *file, void __user *arg,
+ int compat_method_mask)
+{
+ struct ib_user_mad_reg_req ureq;
+ struct ib_mad_reg_req req;
+ struct ib_mad_agent *agent = NULL;
+ int agent_id;
+ int ret;
+
+ mutex_lock(&file->port->file_mutex);
+ mutex_lock(&file->mutex);
+
+ if (!file->port->ib_dev) {
+ dev_notice(file->port->dev,
+ "ib_umad_reg_agent: invalid device\n");
+ ret = -EPIPE;
+ goto out;
+ }
+
+ if (copy_from_user(&ureq, arg, sizeof ureq)) {
+ ret = -EFAULT;
+ goto out;
+ }
+
+ if (ureq.qpn != 0 && ureq.qpn != 1) {
+ dev_notice(file->port->dev,
+ "ib_umad_reg_agent: invalid QPN %d specified\n",
+ ureq.qpn);
+ ret = -EINVAL;
+ goto out;
+ }
+
+ for (agent_id = 0; agent_id < IB_UMAD_MAX_AGENTS; ++agent_id)
+ if (!__get_agent(file, agent_id))
+ goto found;
+
+ dev_notice(file->port->dev,
+ "ib_umad_reg_agent: Max Agents (%u) reached\n",
+ IB_UMAD_MAX_AGENTS);
+ ret = -ENOMEM;
+ goto out;
+
+found:
+ if (ureq.mgmt_class) {
+ memset(&req, 0, sizeof(req));
+ req.mgmt_class = ureq.mgmt_class;
+ req.mgmt_class_version = ureq.mgmt_class_version;
+ memcpy(req.oui, ureq.oui, sizeof req.oui);
+
+ if (compat_method_mask) {
+ u32 *umm = (u32 *) ureq.method_mask;
+ int i;
+
+ for (i = 0; i < BITS_TO_LONGS(IB_MGMT_MAX_METHODS); ++i)
+ req.method_mask[i] =
+ umm[i * 2] | ((u64) umm[i * 2 + 1] << 32);
+ } else
+ memcpy(req.method_mask, ureq.method_mask,
+ sizeof req.method_mask);
+ }
+
+ agent = ib_register_mad_agent(file->port->ib_dev, file->port->port_num,
+ ureq.qpn ? IB_QPT_GSI : IB_QPT_SMI,
+ ureq.mgmt_class ? &req : NULL,
+ ureq.rmpp_version,
+ send_handler, recv_handler, file, 0);
+ if (IS_ERR(agent)) {
+ ret = PTR_ERR(agent);
+ agent = NULL;
+ goto out;
+ }
+
+ if (put_user(agent_id,
+ (u32 __user *) ((char *)arg + offsetof(struct ib_user_mad_reg_req, id)))) {
+ ret = -EFAULT;
+ goto out;
+ }
+
+ if (!file->already_used) {
+ file->already_used = 1;
+ if (!file->use_pkey_index) {
+ dev_warn(file->port->dev,
+ "process %s did not enable P_Key index support.\n",
+ current->comm);
+ dev_warn(file->port->dev,
+ " Documentation/infiniband/user_mad.txt has info on the new ABI.\n");
+ }
+ }
+
+ file->agent[agent_id] = agent;
+ ret = 0;
+
+out:
+ mutex_unlock(&file->mutex);
+
+ if (ret && agent)
+ ib_unregister_mad_agent(agent);
+
+ mutex_unlock(&file->port->file_mutex);
+
+ return ret;
+}
+
+static int ib_umad_reg_agent2(struct ib_umad_file *file, void __user *arg)
+{
+ struct ib_user_mad_reg_req2 ureq;
+ struct ib_mad_reg_req req;
+ struct ib_mad_agent *agent = NULL;
+ int agent_id;
+ int ret;
+
+ mutex_lock(&file->port->file_mutex);
+ mutex_lock(&file->mutex);
+
+ if (!file->port->ib_dev) {
+ dev_notice(file->port->dev,
+ "ib_umad_reg_agent2: invalid device\n");
+ ret = -EPIPE;
+ goto out;
+ }
+
+ if (copy_from_user(&ureq, arg, sizeof(ureq))) {
+ ret = -EFAULT;
+ goto out;
+ }
+
+ if (ureq.qpn != 0 && ureq.qpn != 1) {
+ dev_notice(file->port->dev,
+ "ib_umad_reg_agent2: invalid QPN %d specified\n",
+ ureq.qpn);
+ ret = -EINVAL;
+ goto out;
+ }
+
+ if (ureq.flags & ~IB_USER_MAD_REG_FLAGS_CAP) {
+ const u32 flags = IB_USER_MAD_REG_FLAGS_CAP;
+ dev_notice(file->port->dev,
+ "ib_umad_reg_agent2 failed: invalid registration flags specified 0x%x; supported 0x%x\n",
+ ureq.flags, IB_USER_MAD_REG_FLAGS_CAP);
+ ret = -EINVAL;
+
+ if (put_user(flags,
+ (u32 __user *) ((char *)arg + offsetof(struct
+ ib_user_mad_reg_req2, flags))))
+ ret = -EFAULT;
+
+ goto out;
+ }
+
+ for (agent_id = 0; agent_id < IB_UMAD_MAX_AGENTS; ++agent_id)
+ if (!__get_agent(file, agent_id))
+ goto found;
+
+ dev_notice(file->port->dev,
+ "ib_umad_reg_agent2: Max Agents (%u) reached\n",
+ IB_UMAD_MAX_AGENTS);
+ ret = -ENOMEM;
+ goto out;
+
+found:
+ if (ureq.mgmt_class) {
+ memset(&req, 0, sizeof(req));
+ req.mgmt_class = ureq.mgmt_class;
+ req.mgmt_class_version = ureq.mgmt_class_version;
+ if (ureq.oui & 0xff000000) {
+ dev_notice(file->port->dev,
+ "ib_umad_reg_agent2 failed: oui invalid 0x%08x\n",
+ ureq.oui);
+ ret = -EINVAL;
+ goto out;
+ }
+ req.oui[2] = ureq.oui & 0x0000ff;
+ req.oui[1] = (ureq.oui & 0x00ff00) >> 8;
+ req.oui[0] = (ureq.oui & 0xff0000) >> 16;
+ memcpy(req.method_mask, ureq.method_mask,
+ sizeof(req.method_mask));
+ }
+
+ agent = ib_register_mad_agent(file->port->ib_dev, file->port->port_num,
+ ureq.qpn ? IB_QPT_GSI : IB_QPT_SMI,
+ ureq.mgmt_class ? &req : NULL,
+ ureq.rmpp_version,
+ send_handler, recv_handler, file,
+ ureq.flags);
+ if (IS_ERR(agent)) {
+ ret = PTR_ERR(agent);
+ agent = NULL;
+ goto out;
+ }
+
+ if (put_user(agent_id,
+ (u32 __user *)((char *)arg +
+ offsetof(struct ib_user_mad_reg_req2, id)))) {
+ ret = -EFAULT;
+ goto out;
+ }
+
+ if (!file->already_used) {
+ file->already_used = 1;
+ file->use_pkey_index = 1;
+ }
+
+ file->agent[agent_id] = agent;
+ ret = 0;
+
+out:
+ mutex_unlock(&file->mutex);
+
+ if (ret && agent)
+ ib_unregister_mad_agent(agent);
+
+ mutex_unlock(&file->port->file_mutex);
+
+ return ret;
+}
+
+
+static int ib_umad_unreg_agent(struct ib_umad_file *file, u32 __user *arg)
+{
+ struct ib_mad_agent *agent = NULL;
+ u32 id;
+ int ret = 0;
+
+ if (get_user(id, arg))
+ return -EFAULT;
+
+ mutex_lock(&file->port->file_mutex);
+ mutex_lock(&file->mutex);
+
+ if (id >= IB_UMAD_MAX_AGENTS || !__get_agent(file, id)) {
+ ret = -EINVAL;
+ goto out;
+ }
+
+ agent = file->agent[id];
+ file->agent[id] = NULL;
+
+out:
+ mutex_unlock(&file->mutex);
+
+ if (agent)
+ ib_unregister_mad_agent(agent);
+
+ mutex_unlock(&file->port->file_mutex);
+
+ return ret;
+}
+
+static long ib_umad_enable_pkey(struct ib_umad_file *file)
+{
+ int ret = 0;
+
+ mutex_lock(&file->mutex);
+ if (file->already_used)
+ ret = -EINVAL;
+ else
+ file->use_pkey_index = 1;
+ mutex_unlock(&file->mutex);
+
+ return ret;
+}
+
+static long ib_umad_ioctl(struct file *filp, unsigned int cmd,
+ unsigned long arg)
+{
+ switch (cmd) {
+ case IB_USER_MAD_REGISTER_AGENT:
+ return ib_umad_reg_agent(filp->private_data, (void __user *) arg, 0);
+ case IB_USER_MAD_UNREGISTER_AGENT:
+ return ib_umad_unreg_agent(filp->private_data, (__u32 __user *) arg);
+ case IB_USER_MAD_ENABLE_PKEY:
+ return ib_umad_enable_pkey(filp->private_data);
+ case IB_USER_MAD_REGISTER_AGENT2:
+ return ib_umad_reg_agent2(filp->private_data, (void __user *) arg);
+ default:
+ return -ENOIOCTLCMD;
+ }
+}
+
+#ifdef CONFIG_COMPAT
+static long ib_umad_compat_ioctl(struct file *filp, unsigned int cmd,
+ unsigned long arg)
+{
+ switch (cmd) {
+ case IB_USER_MAD_REGISTER_AGENT:
+ return ib_umad_reg_agent(filp->private_data, compat_ptr(arg), 1);
+ case IB_USER_MAD_UNREGISTER_AGENT:
+ return ib_umad_unreg_agent(filp->private_data, compat_ptr(arg));
+ case IB_USER_MAD_ENABLE_PKEY:
+ return ib_umad_enable_pkey(filp->private_data);
+ case IB_USER_MAD_REGISTER_AGENT2:
+ return ib_umad_reg_agent2(filp->private_data, compat_ptr(arg));
+ default:
+ return -ENOIOCTLCMD;
+ }
+}
+#endif
+
+/*
+ * ib_umad_open() does not need the BKL:
+ *
+ * - the ib_umad_port structures are properly reference counted, and
+ * everything else is purely local to the file being created, so
+ * races against other open calls are not a problem;
+ * - the ioctl method does not affect any global state outside of the
+ * file structure being operated on;
+ */
+static int ib_umad_open(struct inode *inode, struct file *filp)
+{
+ struct ib_umad_port *port;
+ struct ib_umad_file *file;
+ int ret = -ENXIO;
+
+ port = container_of(inode->i_cdev->si_drv1, struct ib_umad_port, cdev);
+
+ mutex_lock(&port->file_mutex);
+
+ if (!port->ib_dev)
+ goto out;
+
+ ret = -ENOMEM;
+ file = kzalloc(sizeof *file, GFP_KERNEL);
+ if (!file)
+ goto out;
+
+ mutex_init(&file->mutex);
+ spin_lock_init(&file->send_lock);
+ INIT_LIST_HEAD(&file->recv_list);
+ INIT_LIST_HEAD(&file->send_list);
+ init_waitqueue_head(&file->recv_wait);
+
+ file->port = port;
+ filp->private_data = file;
+
+ list_add_tail(&file->port_list, &port->file_list);
+
+ ret = nonseekable_open(inode, filp);
+ if (ret) {
+ list_del(&file->port_list);
+ kfree(file);
+ goto out;
+ }
+
+ kobject_get(&port->umad_dev->kobj);
+
+out:
+ mutex_unlock(&port->file_mutex);
+ return ret;
+}
+
+static int ib_umad_close(struct inode *inode, struct file *filp)
+{
+ struct ib_umad_file *file = filp->private_data;
+ struct ib_umad_device *dev = file->port->umad_dev;
+ struct ib_umad_packet *packet, *tmp;
+ int already_dead;
+ int i;
+
+ mutex_lock(&file->port->file_mutex);
+ mutex_lock(&file->mutex);
+
+ already_dead = file->agents_dead;
+ file->agents_dead = 1;
+
+ list_for_each_entry_safe(packet, tmp, &file->recv_list, list) {
+ if (packet->recv_wc)
+ ib_free_recv_mad(packet->recv_wc);
+ kfree(packet);
+ }
+
+ list_del(&file->port_list);
+
+ mutex_unlock(&file->mutex);
+
+ if (!already_dead)
+ for (i = 0; i < IB_UMAD_MAX_AGENTS; ++i)
+ if (file->agent[i])
+ ib_unregister_mad_agent(file->agent[i]);
+
+ mutex_unlock(&file->port->file_mutex);
+
+ kfree(file);
+ kobject_put(&dev->kobj);
+
+ return 0;
+}
+
+static const struct file_operations umad_fops = {
+ .owner = THIS_MODULE,
+ .read = ib_umad_read,
+ .write = ib_umad_write,
+ .poll = ib_umad_poll,
+ .unlocked_ioctl = ib_umad_ioctl,
+#ifdef CONFIG_COMPAT
+ .compat_ioctl = ib_umad_compat_ioctl,
+#endif
+ .open = ib_umad_open,
+ .release = ib_umad_close,
+ .llseek = no_llseek,
+};
+
+static int ib_umad_sm_open(struct inode *inode, struct file *filp)
+{
+ struct ib_umad_port *port;
+ struct ib_port_modify props = {
+ .set_port_cap_mask = IB_PORT_SM
+ };
+ int ret;
+
+ port = container_of(inode->i_cdev->si_drv1, struct ib_umad_port, sm_cdev);
+
+ if (filp->f_flags & O_NONBLOCK) {
+ if (down_trylock(&port->sm_sem)) {
+ ret = -EAGAIN;
+ goto fail;
+ }
+ } else {
+ if (down_interruptible(&port->sm_sem)) {
+ ret = -ERESTARTSYS;
+ goto fail;
+ }
+ }
+
+ ret = ib_modify_port(port->ib_dev, port->port_num, 0, &props);
+ if (ret)
+ goto err_up_sem;
+
+ filp->private_data = port;
+
+ ret = nonseekable_open(inode, filp);
+ if (ret)
+ goto err_clr_sm_cap;
+
+ kobject_get(&port->umad_dev->kobj);
+
+ return 0;
+
+err_clr_sm_cap:
+ swap(props.set_port_cap_mask, props.clr_port_cap_mask);
+ ib_modify_port(port->ib_dev, port->port_num, 0, &props);
+
+err_up_sem:
+ up(&port->sm_sem);
+
+fail:
+ return ret;
+}
+
+static int ib_umad_sm_close(struct inode *inode, struct file *filp)
+{
+ struct ib_umad_port *port = filp->private_data;
+ struct ib_port_modify props = {
+ .clr_port_cap_mask = IB_PORT_SM
+ };
+ int ret = 0;
+
+ mutex_lock(&port->file_mutex);
+ if (port->ib_dev)
+ ret = ib_modify_port(port->ib_dev, port->port_num, 0, &props);
+ mutex_unlock(&port->file_mutex);
+
+ up(&port->sm_sem);
+
+ kobject_put(&port->umad_dev->kobj);
+
+ return ret;
+}
+
+static const struct file_operations umad_sm_fops = {
+ .owner = THIS_MODULE,
+ .open = ib_umad_sm_open,
+ .release = ib_umad_sm_close,
+ .llseek = no_llseek,
+};
+
+static struct ib_client umad_client = {
+ .name = "umad",
+ .add = ib_umad_add_one,
+ .remove = ib_umad_remove_one
+};
+
+static ssize_t show_ibdev(struct device *dev, struct device_attribute *attr,
+ char *buf)
+{
+ struct ib_umad_port *port = dev_get_drvdata(dev);
+
+ if (!port)
+ return -ENODEV;
+
+ return sprintf(buf, "%s\n", port->ib_dev->name);
+}
+static DEVICE_ATTR(ibdev, S_IRUGO, show_ibdev, NULL);
+
+static ssize_t show_port(struct device *dev, struct device_attribute *attr,
+ char *buf)
+{
+ struct ib_umad_port *port = dev_get_drvdata(dev);
+
+ if (!port)
+ return -ENODEV;
+
+ return sprintf(buf, "%d\n", port->port_num);
+}
+static DEVICE_ATTR(port, S_IRUGO, show_port, NULL);
+
+static CLASS_ATTR_STRING(abi_version, S_IRUGO,
+ __stringify(IB_USER_MAD_ABI_VERSION));
+
+static dev_t overflow_maj;
+static DECLARE_BITMAP(overflow_map, IB_UMAD_MAX_PORTS);
+static int find_overflow_devnum(struct ib_device *device)
+{
+ int ret;
+
+ if (!overflow_maj) {
+ ret = alloc_chrdev_region(&overflow_maj, 0, IB_UMAD_MAX_PORTS * 2,
+ "infiniband_mad");
+ if (ret) {
+ dev_err(&device->dev,
+ "couldn't register dynamic device number\n");
+ return ret;
+ }
+ }
+
+ ret = find_first_zero_bit(overflow_map, IB_UMAD_MAX_PORTS);
+ if (ret >= IB_UMAD_MAX_PORTS)
+ return -1;
+
+ return ret;
+}
+
+static int ib_umad_init_port(struct ib_device *device, int port_num,
+ struct ib_umad_device *umad_dev,
+ struct ib_umad_port *port)
+{
+ int devnum;
+ dev_t base;
+
+ spin_lock(&port_lock);
+ devnum = find_first_zero_bit(dev_map, IB_UMAD_MAX_PORTS);
+ if (devnum >= IB_UMAD_MAX_PORTS) {
+ spin_unlock(&port_lock);
+ devnum = find_overflow_devnum(device);
+ if (devnum < 0)
+ return -1;
+
+ spin_lock(&port_lock);
+ port->dev_num = devnum + IB_UMAD_MAX_PORTS;
+ base = devnum + overflow_maj;
+ set_bit(devnum, overflow_map);
+ } else {
+ port->dev_num = devnum;
+ base = devnum + base_dev;
+ set_bit(devnum, dev_map);
+ }
+ spin_unlock(&port_lock);
+
+ port->ib_dev = device;
+ port->port_num = port_num;
+ sema_init(&port->sm_sem, 1);
+ mutex_init(&port->file_mutex);
+ INIT_LIST_HEAD(&port->file_list);
+
+ cdev_init(&port->cdev, &umad_fops);
+ port->cdev.owner = THIS_MODULE;
+ port->cdev.kobj.parent = &umad_dev->kobj;
+ kobject_set_name(&port->cdev.kobj, "umad%d", port->dev_num);
+ if (cdev_add(&port->cdev, base, 1))
+ goto err_cdev;
+
+ port->dev = device_create(umad_class, device->dma_device,
+ port->cdev.dev, port,
+ "umad%d", port->dev_num);
+ if (IS_ERR(port->dev))
+ goto err_cdev;
+
+ if (device_create_file(port->dev, &dev_attr_ibdev))
+ goto err_dev;
+ if (device_create_file(port->dev, &dev_attr_port))
+ goto err_dev;
+
+ base += IB_UMAD_MAX_PORTS;
+ cdev_init(&port->sm_cdev, &umad_sm_fops);
+ port->sm_cdev.owner = THIS_MODULE;
+ port->sm_cdev.kobj.parent = &umad_dev->kobj;
+ kobject_set_name(&port->sm_cdev.kobj, "issm%d", port->dev_num);
+ if (cdev_add(&port->sm_cdev, base, 1))
+ goto err_sm_cdev;
+
+ port->sm_dev = device_create(umad_class, device->dma_device,
+ port->sm_cdev.dev, port,
+ "issm%d", port->dev_num);
+ if (IS_ERR(port->sm_dev))
+ goto err_sm_cdev;
+
+ if (device_create_file(port->sm_dev, &dev_attr_ibdev))
+ goto err_sm_dev;
+ if (device_create_file(port->sm_dev, &dev_attr_port))
+ goto err_sm_dev;
+
+ return 0;
+
+err_sm_dev:
+ device_destroy(umad_class, port->sm_cdev.dev);
+
+err_sm_cdev:
+ cdev_del(&port->sm_cdev);
+
+err_dev:
+ device_destroy(umad_class, port->cdev.dev);
+
+err_cdev:
+ cdev_del(&port->cdev);
+ if (port->dev_num < IB_UMAD_MAX_PORTS)
+ clear_bit(devnum, dev_map);
+ else
+ clear_bit(devnum, overflow_map);
+
+ return -1;
+}
+
+static void ib_umad_kill_port(struct ib_umad_port *port)
+{
+ struct ib_umad_file *file;
+ int id;
+
+ dev_set_drvdata(port->dev, NULL);
+ dev_set_drvdata(port->sm_dev, NULL);
+
+ device_destroy(umad_class, port->cdev.dev);
+ device_destroy(umad_class, port->sm_cdev.dev);
+
+ cdev_del(&port->cdev);
+ cdev_del(&port->sm_cdev);
+
+ mutex_lock(&port->file_mutex);
+
+ port->ib_dev = NULL;
+
+ list_for_each_entry(file, &port->file_list, port_list) {
+ mutex_lock(&file->mutex);
+ file->agents_dead = 1;
+ mutex_unlock(&file->mutex);
+
+ for (id = 0; id < IB_UMAD_MAX_AGENTS; ++id)
+ if (file->agent[id])
+ ib_unregister_mad_agent(file->agent[id]);
+ }
+
+ mutex_unlock(&port->file_mutex);
+
+ if (port->dev_num < IB_UMAD_MAX_PORTS)
+ clear_bit(port->dev_num, dev_map);
+ else
+ clear_bit(port->dev_num - IB_UMAD_MAX_PORTS, overflow_map);
+}
+
+static void ib_umad_add_one(struct ib_device *device)
+{
+ struct ib_umad_device *umad_dev;
+ int s, e, i;
+ int count = 0;
+
+ s = rdma_start_port(device);
+ e = rdma_end_port(device);
+
+ umad_dev = kzalloc(sizeof *umad_dev +
+ (e - s + 1) * sizeof (struct ib_umad_port),
+ GFP_KERNEL);
+ if (!umad_dev)
+ return;
+
+ kobject_init(&umad_dev->kobj, &ib_umad_dev_ktype);
+
+ for (i = s; i <= e; ++i) {
+ if (!rdma_cap_ib_mad(device, i))
+ continue;
+
+ umad_dev->port[i - s].umad_dev = umad_dev;
+
+ if (ib_umad_init_port(device, i, umad_dev,
+ &umad_dev->port[i - s]))
+ goto err;
+
+ count++;
+ }
+
+ if (!count)
+ goto free;
+
+ ib_set_client_data(device, &umad_client, umad_dev);
+
+ return;
+
+err:
+ while (--i >= s) {
+ if (!rdma_cap_ib_mad(device, i))
+ continue;
+
+ ib_umad_kill_port(&umad_dev->port[i - s]);
+ }
+free:
+ kobject_put(&umad_dev->kobj);
+}
+
+static void ib_umad_remove_one(struct ib_device *device, void *client_data)
+{
+ struct ib_umad_device *umad_dev = client_data;
+ int i;
+
+ if (!umad_dev)
+ return;
+
+ for (i = 0; i <= rdma_end_port(device) - rdma_start_port(device); ++i) {
+ if (rdma_cap_ib_mad(device, i + rdma_start_port(device)))
+ ib_umad_kill_port(&umad_dev->port[i]);
+ }
+
+ kobject_put(&umad_dev->kobj);
+}
+
+static char *umad_devnode(struct device *dev, umode_t *mode)
+{
+ return kasprintf(GFP_KERNEL, "infiniband/%s", dev_name(dev));
+}
+
+static int __init ib_umad_init(void)
+{
+ int ret;
+
+ ret = register_chrdev_region(base_dev, IB_UMAD_MAX_PORTS * 2,
+ "infiniband_mad");
+ if (ret) {
+ pr_err("couldn't register device number\n");
+ goto out;
+ }
+
+ umad_class = class_create(THIS_MODULE, "infiniband_mad");
+ if (IS_ERR(umad_class)) {
+ ret = PTR_ERR(umad_class);
+ pr_err("couldn't create class infiniband_mad\n");
+ goto out_chrdev;
+ }
+
+ umad_class->devnode = umad_devnode;
+
+ ret = class_create_file(umad_class, &class_attr_abi_version.attr);
+ if (ret) {
+ pr_err("couldn't create abi_version attribute\n");
+ goto out_class;
+ }
+
+ ret = ib_register_client(&umad_client);
+ if (ret) {
+ pr_err("couldn't register ib_umad client\n");
+ goto out_class;
+ }
+
+ return 0;
+
+out_class:
+ class_destroy(umad_class);
+
+out_chrdev:
+ unregister_chrdev_region(base_dev, IB_UMAD_MAX_PORTS * 2);
+
+out:
+ return ret;
+}
+
+static void __exit ib_umad_cleanup(void)
+{
+ ib_unregister_client(&umad_client);
+ class_destroy(umad_class);
+ unregister_chrdev_region(base_dev, IB_UMAD_MAX_PORTS * 2);
+ if (overflow_maj)
+ unregister_chrdev_region(overflow_maj, IB_UMAD_MAX_PORTS * 2);
+}
+
+module_init_order(ib_umad_init, SI_ORDER_THIRD);
+module_exit(ib_umad_cleanup);
diff --git a/sys/ofed/drivers/infiniband/core/ib_uverbs_cmd.c b/sys/ofed/drivers/infiniband/core/ib_uverbs_cmd.c
new file mode 100644
index 0000000..3289259
--- /dev/null
+++ b/sys/ofed/drivers/infiniband/core/ib_uverbs_cmd.c
@@ -0,0 +1,4251 @@
+/*
+ * Copyright (c) 2005 Topspin Communications. All rights reserved.
+ * Copyright (c) 2005, 2006, 2007 Cisco Systems. All rights reserved.
+ * Copyright (c) 2005 PathScale, Inc. All rights reserved.
+ * Copyright (c) 2006 Mellanox Technologies. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#define LINUXKPI_PARAM_PREFIX ibcore_
+
+#include <linux/file.h>
+#include <linux/fs.h>
+#include <linux/slab.h>
+#include <linux/sched.h>
+#include <linux/rbtree.h>
+
+#include <asm/uaccess.h>
+
+#include "uverbs.h"
+#include "core_priv.h"
+
+#include <sys/priv.h>
+
+struct uverbs_lock_class {
+ char name[16];
+};
+
+static struct uverbs_lock_class pd_lock_class = { .name = "PD-uobj" };
+static struct uverbs_lock_class mr_lock_class = { .name = "MR-uobj" };
+static struct uverbs_lock_class mw_lock_class = { .name = "MW-uobj" };
+static struct uverbs_lock_class cq_lock_class = { .name = "CQ-uobj" };
+static struct uverbs_lock_class qp_lock_class = { .name = "QP-uobj" };
+static struct uverbs_lock_class ah_lock_class = { .name = "AH-uobj" };
+static struct uverbs_lock_class srq_lock_class = { .name = "SRQ-uobj" };
+static struct uverbs_lock_class xrcd_lock_class = { .name = "XRCD-uobj" };
+static struct uverbs_lock_class rule_lock_class = { .name = "RULE-uobj" };
+static struct uverbs_lock_class wq_lock_class = { .name = "WQ-uobj" };
+static struct uverbs_lock_class rwq_ind_table_lock_class = { .name = "IND_TBL-uobj" };
+
+/*
+ * The ib_uobject locking scheme is as follows:
+ *
+ * - ib_uverbs_idr_lock protects the uverbs idrs themselves, so it
+ * needs to be held during all idr write operations. When an object is
+ * looked up, a reference must be taken on the object's kref before
+ * dropping this lock. For read operations, the rcu_read_lock()
+ * and rcu_write_lock() but similarly the kref reference is grabbed
+ * before the rcu_read_unlock().
+ *
+ * - Each object also has an rwsem. This rwsem must be held for
+ * reading while an operation that uses the object is performed.
+ * For example, while registering an MR, the associated PD's
+ * uobject.mutex must be held for reading. The rwsem must be held
+ * for writing while initializing or destroying an object.
+ *
+ * - In addition, each object has a "live" flag. If this flag is not
+ * set, then lookups of the object will fail even if it is found in
+ * the idr. This handles a reader that blocks and does not acquire
+ * the rwsem until after the object is destroyed. The destroy
+ * operation will set the live flag to 0 and then drop the rwsem;
+ * this will allow the reader to acquire the rwsem, see that the
+ * live flag is 0, and then drop the rwsem and its reference to
+ * object. The underlying storage will not be freed until the last
+ * reference to the object is dropped.
+ */
+
+static void init_uobj(struct ib_uobject *uobj, u64 user_handle,
+ struct ib_ucontext *context, struct uverbs_lock_class *c)
+{
+ uobj->user_handle = user_handle;
+ uobj->context = context;
+ kref_init(&uobj->ref);
+ init_rwsem(&uobj->mutex);
+ uobj->live = 0;
+}
+
+static void release_uobj(struct kref *kref)
+{
+ kfree_rcu(container_of(kref, struct ib_uobject, ref), rcu);
+}
+
+static void put_uobj(struct ib_uobject *uobj)
+{
+ kref_put(&uobj->ref, release_uobj);
+}
+
+static void put_uobj_read(struct ib_uobject *uobj)
+{
+ up_read(&uobj->mutex);
+ put_uobj(uobj);
+}
+
+static void put_uobj_write(struct ib_uobject *uobj)
+{
+ up_write(&uobj->mutex);
+ put_uobj(uobj);
+}
+
+static int idr_add_uobj(struct idr *idr, struct ib_uobject *uobj)
+{
+ int ret;
+
+ idr_preload(GFP_KERNEL);
+ spin_lock(&ib_uverbs_idr_lock);
+
+ ret = idr_alloc(idr, uobj, 0, 0, GFP_NOWAIT);
+ if (ret >= 0)
+ uobj->id = ret;
+
+ spin_unlock(&ib_uverbs_idr_lock);
+ idr_preload_end();
+
+ return ret < 0 ? ret : 0;
+}
+
+void idr_remove_uobj(struct idr *idr, struct ib_uobject *uobj)
+{
+ spin_lock(&ib_uverbs_idr_lock);
+ idr_remove(idr, uobj->id);
+ spin_unlock(&ib_uverbs_idr_lock);
+}
+
+static struct ib_uobject *__idr_get_uobj(struct idr *idr, int id,
+ struct ib_ucontext *context)
+{
+ struct ib_uobject *uobj;
+
+ rcu_read_lock();
+ uobj = idr_find(idr, id);
+ if (uobj) {
+ if (uobj->context == context)
+ kref_get(&uobj->ref);
+ else
+ uobj = NULL;
+ }
+ rcu_read_unlock();
+
+ return uobj;
+}
+
+static struct ib_uobject *idr_read_uobj(struct idr *idr, int id,
+ struct ib_ucontext *context, int nested)
+{
+ struct ib_uobject *uobj;
+
+ uobj = __idr_get_uobj(idr, id, context);
+ if (!uobj)
+ return NULL;
+
+ if (nested)
+ down_read_nested(&uobj->mutex, SINGLE_DEPTH_NESTING);
+ else
+ down_read(&uobj->mutex);
+ if (!uobj->live) {
+ put_uobj_read(uobj);
+ return NULL;
+ }
+
+ return uobj;
+}
+
+static struct ib_uobject *idr_write_uobj(struct idr *idr, int id,
+ struct ib_ucontext *context)
+{
+ struct ib_uobject *uobj;
+
+ uobj = __idr_get_uobj(idr, id, context);
+ if (!uobj)
+ return NULL;
+
+ down_write(&uobj->mutex);
+ if (!uobj->live) {
+ put_uobj_write(uobj);
+ return NULL;
+ }
+
+ return uobj;
+}
+
+static void *idr_read_obj(struct idr *idr, int id, struct ib_ucontext *context,
+ int nested)
+{
+ struct ib_uobject *uobj;
+
+ uobj = idr_read_uobj(idr, id, context, nested);
+ return uobj ? uobj->object : NULL;
+}
+
+static struct ib_pd *idr_read_pd(int pd_handle, struct ib_ucontext *context)
+{
+ return idr_read_obj(&ib_uverbs_pd_idr, pd_handle, context, 0);
+}
+
+static void put_pd_read(struct ib_pd *pd)
+{
+ put_uobj_read(pd->uobject);
+}
+
+static struct ib_cq *idr_read_cq(int cq_handle, struct ib_ucontext *context, int nested)
+{
+ return idr_read_obj(&ib_uverbs_cq_idr, cq_handle, context, nested);
+}
+
+static void put_cq_read(struct ib_cq *cq)
+{
+ put_uobj_read(cq->uobject);
+}
+
+static struct ib_ah *idr_read_ah(int ah_handle, struct ib_ucontext *context)
+{
+ return idr_read_obj(&ib_uverbs_ah_idr, ah_handle, context, 0);
+}
+
+static void put_ah_read(struct ib_ah *ah)
+{
+ put_uobj_read(ah->uobject);
+}
+
+static struct ib_qp *idr_read_qp(int qp_handle, struct ib_ucontext *context)
+{
+ return idr_read_obj(&ib_uverbs_qp_idr, qp_handle, context, 0);
+}
+
+static struct ib_wq *idr_read_wq(int wq_handle, struct ib_ucontext *context)
+{
+ return idr_read_obj(&ib_uverbs_wq_idr, wq_handle, context, 0);
+}
+
+static void put_wq_read(struct ib_wq *wq)
+{
+ put_uobj_read(wq->uobject);
+}
+
+static struct ib_rwq_ind_table *idr_read_rwq_indirection_table(int ind_table_handle,
+ struct ib_ucontext *context)
+{
+ return idr_read_obj(&ib_uverbs_rwq_ind_tbl_idr, ind_table_handle, context, 0);
+}
+
+static void put_rwq_indirection_table_read(struct ib_rwq_ind_table *ind_table)
+{
+ put_uobj_read(ind_table->uobject);
+}
+
+static struct ib_qp *idr_write_qp(int qp_handle, struct ib_ucontext *context)
+{
+ struct ib_uobject *uobj;
+
+ uobj = idr_write_uobj(&ib_uverbs_qp_idr, qp_handle, context);
+ return uobj ? uobj->object : NULL;
+}
+
+static void put_qp_read(struct ib_qp *qp)
+{
+ put_uobj_read(qp->uobject);
+}
+
+static void put_qp_write(struct ib_qp *qp)
+{
+ put_uobj_write(qp->uobject);
+}
+
+static struct ib_srq *idr_read_srq(int srq_handle, struct ib_ucontext *context)
+{
+ return idr_read_obj(&ib_uverbs_srq_idr, srq_handle, context, 0);
+}
+
+static void put_srq_read(struct ib_srq *srq)
+{
+ put_uobj_read(srq->uobject);
+}
+
+static struct ib_xrcd *idr_read_xrcd(int xrcd_handle, struct ib_ucontext *context,
+ struct ib_uobject **uobj)
+{
+ *uobj = idr_read_uobj(&ib_uverbs_xrcd_idr, xrcd_handle, context, 0);
+ return *uobj ? (*uobj)->object : NULL;
+}
+
+static void put_xrcd_read(struct ib_uobject *uobj)
+{
+ put_uobj_read(uobj);
+}
+
+ssize_t ib_uverbs_get_context(struct ib_uverbs_file *file,
+ struct ib_device *ib_dev,
+ const char __user *buf,
+ int in_len, int out_len)
+{
+ struct ib_uverbs_get_context cmd;
+ struct ib_uverbs_get_context_resp resp;
+ struct ib_udata udata;
+ struct ib_ucontext *ucontext;
+ struct file *filp;
+ int ret;
+
+ if (out_len < sizeof resp)
+ return -ENOSPC;
+
+ if (copy_from_user(&cmd, buf, sizeof cmd))
+ return -EFAULT;
+
+ mutex_lock(&file->mutex);
+
+ if (file->ucontext) {
+ ret = -EINVAL;
+ goto err;
+ }
+
+ INIT_UDATA(&udata, buf + sizeof cmd,
+ (unsigned long) cmd.response + sizeof resp,
+ in_len - sizeof cmd, out_len - sizeof resp);
+
+ ucontext = ib_dev->alloc_ucontext(ib_dev, &udata);
+ if (IS_ERR(ucontext)) {
+ ret = PTR_ERR(ucontext);
+ goto err;
+ }
+
+ ucontext->device = ib_dev;
+ INIT_LIST_HEAD(&ucontext->pd_list);
+ INIT_LIST_HEAD(&ucontext->mr_list);
+ INIT_LIST_HEAD(&ucontext->mw_list);
+ INIT_LIST_HEAD(&ucontext->cq_list);
+ INIT_LIST_HEAD(&ucontext->qp_list);
+ INIT_LIST_HEAD(&ucontext->srq_list);
+ INIT_LIST_HEAD(&ucontext->ah_list);
+ INIT_LIST_HEAD(&ucontext->wq_list);
+ INIT_LIST_HEAD(&ucontext->rwq_ind_tbl_list);
+ INIT_LIST_HEAD(&ucontext->xrcd_list);
+ INIT_LIST_HEAD(&ucontext->rule_list);
+ rcu_read_lock();
+ ucontext->tgid = get_pid(task_pid_group_leader(current));
+ rcu_read_unlock();
+ ucontext->closing = 0;
+
+#ifdef CONFIG_INFINIBAND_ON_DEMAND_PAGING
+ ucontext->umem_tree = RB_ROOT;
+ init_rwsem(&ucontext->umem_rwsem);
+ ucontext->odp_mrs_count = 0;
+ INIT_LIST_HEAD(&ucontext->no_private_counters);
+
+ if (!(ib_dev->attrs.device_cap_flags & IB_DEVICE_ON_DEMAND_PAGING))
+ ucontext->invalidate_range = NULL;
+
+#endif
+
+ resp.num_comp_vectors = file->device->num_comp_vectors;
+
+ ret = get_unused_fd_flags(O_CLOEXEC);
+ if (ret < 0)
+ goto err_free;
+ resp.async_fd = ret;
+
+ filp = ib_uverbs_alloc_event_file(file, ib_dev, 1);
+ if (IS_ERR(filp)) {
+ ret = PTR_ERR(filp);
+ goto err_fd;
+ }
+
+ if (copy_to_user((void __user *) (unsigned long) cmd.response,
+ &resp, sizeof resp)) {
+ ret = -EFAULT;
+ goto err_file;
+ }
+
+ file->ucontext = ucontext;
+
+ fd_install(resp.async_fd, filp);
+
+ mutex_unlock(&file->mutex);
+
+ return in_len;
+
+err_file:
+ ib_uverbs_free_async_event_file(file);
+ fput(filp);
+
+err_fd:
+ put_unused_fd(resp.async_fd);
+
+err_free:
+ put_pid(ucontext->tgid);
+ ib_dev->dealloc_ucontext(ucontext);
+
+err:
+ mutex_unlock(&file->mutex);
+ return ret;
+}
+
+static void copy_query_dev_fields(struct ib_uverbs_file *file,
+ struct ib_device *ib_dev,
+ struct ib_uverbs_query_device_resp *resp,
+ struct ib_device_attr *attr)
+{
+ resp->fw_ver = attr->fw_ver;
+ resp->node_guid = ib_dev->node_guid;
+ resp->sys_image_guid = attr->sys_image_guid;
+ resp->max_mr_size = attr->max_mr_size;
+ resp->page_size_cap = attr->page_size_cap;
+ resp->vendor_id = attr->vendor_id;
+ resp->vendor_part_id = attr->vendor_part_id;
+ resp->hw_ver = attr->hw_ver;
+ resp->max_qp = attr->max_qp;
+ resp->max_qp_wr = attr->max_qp_wr;
+ resp->device_cap_flags = (u32)(attr->device_cap_flags);
+ resp->max_sge = attr->max_sge;
+ resp->max_sge_rd = attr->max_sge_rd;
+ resp->max_cq = attr->max_cq;
+ resp->max_cqe = attr->max_cqe;
+ resp->max_mr = attr->max_mr;
+ resp->max_pd = attr->max_pd;
+ resp->max_qp_rd_atom = attr->max_qp_rd_atom;
+ resp->max_ee_rd_atom = attr->max_ee_rd_atom;
+ resp->max_res_rd_atom = attr->max_res_rd_atom;
+ resp->max_qp_init_rd_atom = attr->max_qp_init_rd_atom;
+ resp->max_ee_init_rd_atom = attr->max_ee_init_rd_atom;
+ resp->atomic_cap = attr->atomic_cap;
+ resp->max_ee = attr->max_ee;
+ resp->max_rdd = attr->max_rdd;
+ resp->max_mw = attr->max_mw;
+ resp->max_raw_ipv6_qp = attr->max_raw_ipv6_qp;
+ resp->max_raw_ethy_qp = attr->max_raw_ethy_qp;
+ resp->max_mcast_grp = attr->max_mcast_grp;
+ resp->max_mcast_qp_attach = attr->max_mcast_qp_attach;
+ resp->max_total_mcast_qp_attach = attr->max_total_mcast_qp_attach;
+ resp->max_ah = attr->max_ah;
+ resp->max_fmr = attr->max_fmr;
+ resp->max_map_per_fmr = attr->max_map_per_fmr;
+ resp->max_srq = attr->max_srq;
+ resp->max_srq_wr = attr->max_srq_wr;
+ resp->max_srq_sge = attr->max_srq_sge;
+ resp->max_pkeys = attr->max_pkeys;
+ resp->local_ca_ack_delay = attr->local_ca_ack_delay;
+ resp->phys_port_cnt = ib_dev->phys_port_cnt;
+}
+
+ssize_t ib_uverbs_query_device(struct ib_uverbs_file *file,
+ struct ib_device *ib_dev,
+ const char __user *buf,
+ int in_len, int out_len)
+{
+ struct ib_uverbs_query_device cmd;
+ struct ib_uverbs_query_device_resp resp;
+
+ if (out_len < sizeof resp)
+ return -ENOSPC;
+
+ if (copy_from_user(&cmd, buf, sizeof cmd))
+ return -EFAULT;
+
+ memset(&resp, 0, sizeof resp);
+ copy_query_dev_fields(file, ib_dev, &resp, &ib_dev->attrs);
+
+ if (copy_to_user((void __user *) (unsigned long) cmd.response,
+ &resp, sizeof resp))
+ return -EFAULT;
+
+ return in_len;
+}
+
+ssize_t ib_uverbs_query_port(struct ib_uverbs_file *file,
+ struct ib_device *ib_dev,
+ const char __user *buf,
+ int in_len, int out_len)
+{
+ struct ib_uverbs_query_port cmd;
+ struct ib_uverbs_query_port_resp resp;
+ struct ib_port_attr attr;
+ int ret;
+
+ if (out_len < sizeof resp)
+ return -ENOSPC;
+
+ if (copy_from_user(&cmd, buf, sizeof cmd))
+ return -EFAULT;
+
+ ret = ib_query_port(ib_dev, cmd.port_num, &attr);
+ if (ret)
+ return ret;
+
+ memset(&resp, 0, sizeof resp);
+
+ resp.state = attr.state;
+ resp.max_mtu = attr.max_mtu;
+ resp.active_mtu = attr.active_mtu;
+ resp.gid_tbl_len = attr.gid_tbl_len;
+ resp.port_cap_flags = attr.port_cap_flags;
+ resp.max_msg_sz = attr.max_msg_sz;
+ resp.bad_pkey_cntr = attr.bad_pkey_cntr;
+ resp.qkey_viol_cntr = attr.qkey_viol_cntr;
+ resp.pkey_tbl_len = attr.pkey_tbl_len;
+ resp.lid = attr.lid;
+ resp.sm_lid = attr.sm_lid;
+ resp.lmc = attr.lmc;
+ resp.max_vl_num = attr.max_vl_num;
+ resp.sm_sl = attr.sm_sl;
+ resp.subnet_timeout = attr.subnet_timeout;
+ resp.init_type_reply = attr.init_type_reply;
+ resp.active_width = attr.active_width;
+ resp.active_speed = attr.active_speed;
+ resp.phys_state = attr.phys_state;
+ resp.link_layer = rdma_port_get_link_layer(ib_dev,
+ cmd.port_num);
+
+ if (copy_to_user((void __user *) (unsigned long) cmd.response,
+ &resp, sizeof resp))
+ return -EFAULT;
+
+ return in_len;
+}
+
+ssize_t ib_uverbs_alloc_pd(struct ib_uverbs_file *file,
+ struct ib_device *ib_dev,
+ const char __user *buf,
+ int in_len, int out_len)
+{
+ struct ib_uverbs_alloc_pd cmd;
+ struct ib_uverbs_alloc_pd_resp resp;
+ struct ib_udata udata;
+ struct ib_uobject *uobj;
+ struct ib_pd *pd;
+ int ret;
+
+ if (out_len < sizeof resp)
+ return -ENOSPC;
+
+ if (copy_from_user(&cmd, buf, sizeof cmd))
+ return -EFAULT;
+
+ INIT_UDATA(&udata, buf + sizeof cmd,
+ (unsigned long) cmd.response + sizeof resp,
+ in_len - sizeof cmd, out_len - sizeof resp);
+
+ uobj = kmalloc(sizeof *uobj, GFP_KERNEL);
+ if (!uobj)
+ return -ENOMEM;
+
+ init_uobj(uobj, 0, file->ucontext, &pd_lock_class);
+ down_write(&uobj->mutex);
+
+ pd = ib_dev->alloc_pd(ib_dev, file->ucontext, &udata);
+ if (IS_ERR(pd)) {
+ ret = PTR_ERR(pd);
+ goto err;
+ }
+
+ pd->device = ib_dev;
+ pd->uobject = uobj;
+ pd->__internal_mr = NULL;
+ atomic_set(&pd->usecnt, 0);
+
+ uobj->object = pd;
+ ret = idr_add_uobj(&ib_uverbs_pd_idr, uobj);
+ if (ret)
+ goto err_idr;
+
+ memset(&resp, 0, sizeof resp);
+ resp.pd_handle = uobj->id;
+
+ if (copy_to_user((void __user *) (unsigned long) cmd.response,
+ &resp, sizeof resp)) {
+ ret = -EFAULT;
+ goto err_copy;
+ }
+
+ mutex_lock(&file->mutex);
+ list_add_tail(&uobj->list, &file->ucontext->pd_list);
+ mutex_unlock(&file->mutex);
+
+ uobj->live = 1;
+
+ up_write(&uobj->mutex);
+
+ return in_len;
+
+err_copy:
+ idr_remove_uobj(&ib_uverbs_pd_idr, uobj);
+
+err_idr:
+ ib_dealloc_pd(pd);
+
+err:
+ put_uobj_write(uobj);
+ return ret;
+}
+
+ssize_t ib_uverbs_dealloc_pd(struct ib_uverbs_file *file,
+ struct ib_device *ib_dev,
+ const char __user *buf,
+ int in_len, int out_len)
+{
+ struct ib_uverbs_dealloc_pd cmd;
+ struct ib_uobject *uobj;
+ struct ib_pd *pd;
+ int ret;
+
+ if (copy_from_user(&cmd, buf, sizeof cmd))
+ return -EFAULT;
+
+ uobj = idr_write_uobj(&ib_uverbs_pd_idr, cmd.pd_handle, file->ucontext);
+ if (!uobj)
+ return -EINVAL;
+ pd = uobj->object;
+
+ if (atomic_read(&pd->usecnt)) {
+ ret = -EBUSY;
+ goto err_put;
+ }
+
+ ret = pd->device->dealloc_pd(uobj->object);
+ WARN_ONCE(ret, "Infiniband HW driver failed dealloc_pd");
+ if (ret)
+ goto err_put;
+
+ uobj->live = 0;
+ put_uobj_write(uobj);
+
+ idr_remove_uobj(&ib_uverbs_pd_idr, uobj);
+
+ mutex_lock(&file->mutex);
+ list_del(&uobj->list);
+ mutex_unlock(&file->mutex);
+
+ put_uobj(uobj);
+
+ return in_len;
+
+err_put:
+ put_uobj_write(uobj);
+ return ret;
+}
+
+struct xrcd_table_entry {
+ struct rb_node node;
+ struct ib_xrcd *xrcd;
+ struct inode *inode;
+};
+
+static int xrcd_table_insert(struct ib_uverbs_device *dev,
+ struct inode *inode,
+ struct ib_xrcd *xrcd)
+{
+ struct xrcd_table_entry *entry, *scan;
+ struct rb_node **p = &dev->xrcd_tree.rb_node;
+ struct rb_node *parent = NULL;
+
+ entry = kmalloc(sizeof *entry, GFP_KERNEL);
+ if (!entry)
+ return -ENOMEM;
+
+ entry->xrcd = xrcd;
+ entry->inode = inode;
+
+ while (*p) {
+ parent = *p;
+ scan = rb_entry(parent, struct xrcd_table_entry, node);
+
+ if (inode < scan->inode) {
+ p = &(*p)->rb_left;
+ } else if (inode > scan->inode) {
+ p = &(*p)->rb_right;
+ } else {
+ kfree(entry);
+ return -EEXIST;
+ }
+ }
+
+ rb_link_node(&entry->node, parent, p);
+ rb_insert_color(&entry->node, &dev->xrcd_tree);
+ igrab(inode);
+ return 0;
+}
+
+static struct xrcd_table_entry *xrcd_table_search(struct ib_uverbs_device *dev,
+ struct inode *inode)
+{
+ struct xrcd_table_entry *entry;
+ struct rb_node *p = dev->xrcd_tree.rb_node;
+
+ while (p) {
+ entry = rb_entry(p, struct xrcd_table_entry, node);
+
+ if (inode < entry->inode)
+ p = p->rb_left;
+ else if (inode > entry->inode)
+ p = p->rb_right;
+ else
+ return entry;
+ }
+
+ return NULL;
+}
+
+static struct ib_xrcd *find_xrcd(struct ib_uverbs_device *dev, struct inode *inode)
+{
+ struct xrcd_table_entry *entry;
+
+ entry = xrcd_table_search(dev, inode);
+ if (!entry)
+ return NULL;
+
+ return entry->xrcd;
+}
+
+static void xrcd_table_delete(struct ib_uverbs_device *dev,
+ struct inode *inode)
+{
+ struct xrcd_table_entry *entry;
+
+ entry = xrcd_table_search(dev, inode);
+ if (entry) {
+ iput(inode);
+ rb_erase(&entry->node, &dev->xrcd_tree);
+ kfree(entry);
+ }
+}
+
+ssize_t ib_uverbs_open_xrcd(struct ib_uverbs_file *file,
+ struct ib_device *ib_dev,
+ const char __user *buf, int in_len,
+ int out_len)
+{
+ struct ib_uverbs_open_xrcd cmd;
+ struct ib_uverbs_open_xrcd_resp resp;
+ struct ib_udata udata;
+ struct ib_uxrcd_object *obj;
+ struct ib_xrcd *xrcd = NULL;
+ struct fd f = {NULL};
+ struct inode *inode = NULL;
+ int ret = 0;
+ int new_xrcd = 0;
+
+ if (out_len < sizeof resp)
+ return -ENOSPC;
+
+ if (copy_from_user(&cmd, buf, sizeof cmd))
+ return -EFAULT;
+
+ INIT_UDATA(&udata, buf + sizeof cmd,
+ (unsigned long) cmd.response + sizeof resp,
+ in_len - sizeof cmd, out_len - sizeof resp);
+
+ mutex_lock(&file->device->xrcd_tree_mutex);
+
+ if (cmd.fd != -1) {
+ /* search for file descriptor */
+ f = fdget(cmd.fd);
+ if (!f.file) {
+ ret = -EBADF;
+ goto err_tree_mutex_unlock;
+ }
+
+ inode = f.file->f_dentry->d_inode;
+ xrcd = find_xrcd(file->device, inode);
+ if (!xrcd && !(cmd.oflags & O_CREAT)) {
+ /* no file descriptor. Need CREATE flag */
+ ret = -EAGAIN;
+ goto err_tree_mutex_unlock;
+ }
+
+ if (xrcd && cmd.oflags & O_EXCL) {
+ ret = -EINVAL;
+ goto err_tree_mutex_unlock;
+ }
+ }
+
+ obj = kmalloc(sizeof *obj, GFP_KERNEL);
+ if (!obj) {
+ ret = -ENOMEM;
+ goto err_tree_mutex_unlock;
+ }
+
+ init_uobj(&obj->uobject, 0, file->ucontext, &xrcd_lock_class);
+
+ down_write(&obj->uobject.mutex);
+
+ if (!xrcd) {
+ xrcd = ib_dev->alloc_xrcd(ib_dev, file->ucontext, &udata);
+ if (IS_ERR(xrcd)) {
+ ret = PTR_ERR(xrcd);
+ goto err;
+ }
+
+ xrcd->inode = inode;
+ xrcd->device = ib_dev;
+ atomic_set(&xrcd->usecnt, 0);
+ mutex_init(&xrcd->tgt_qp_mutex);
+ INIT_LIST_HEAD(&xrcd->tgt_qp_list);
+ new_xrcd = 1;
+ }
+
+ atomic_set(&obj->refcnt, 0);
+ obj->uobject.object = xrcd;
+ ret = idr_add_uobj(&ib_uverbs_xrcd_idr, &obj->uobject);
+ if (ret)
+ goto err_idr;
+
+ memset(&resp, 0, sizeof resp);
+ resp.xrcd_handle = obj->uobject.id;
+
+ if (inode) {
+ if (new_xrcd) {
+ /* create new inode/xrcd table entry */
+ ret = xrcd_table_insert(file->device, inode, xrcd);
+ if (ret)
+ goto err_insert_xrcd;
+ }
+ atomic_inc(&xrcd->usecnt);
+ }
+
+ if (copy_to_user((void __user *) (unsigned long) cmd.response,
+ &resp, sizeof resp)) {
+ ret = -EFAULT;
+ goto err_copy;
+ }
+
+ if (f.file)
+ fdput(f);
+
+ mutex_lock(&file->mutex);
+ list_add_tail(&obj->uobject.list, &file->ucontext->xrcd_list);
+ mutex_unlock(&file->mutex);
+
+ obj->uobject.live = 1;
+ up_write(&obj->uobject.mutex);
+
+ mutex_unlock(&file->device->xrcd_tree_mutex);
+ return in_len;
+
+err_copy:
+ if (inode) {
+ if (new_xrcd)
+ xrcd_table_delete(file->device, inode);
+ atomic_dec(&xrcd->usecnt);
+ }
+
+err_insert_xrcd:
+ idr_remove_uobj(&ib_uverbs_xrcd_idr, &obj->uobject);
+
+err_idr:
+ ib_dealloc_xrcd(xrcd);
+
+err:
+ put_uobj_write(&obj->uobject);
+
+err_tree_mutex_unlock:
+ if (f.file)
+ fdput(f);
+
+ mutex_unlock(&file->device->xrcd_tree_mutex);
+
+ return ret;
+}
+
+ssize_t ib_uverbs_close_xrcd(struct ib_uverbs_file *file,
+ struct ib_device *ib_dev,
+ const char __user *buf, int in_len,
+ int out_len)
+{
+ struct ib_uverbs_close_xrcd cmd;
+ struct ib_uobject *uobj;
+ struct ib_xrcd *xrcd = NULL;
+ struct inode *inode = NULL;
+ struct ib_uxrcd_object *obj;
+ int live;
+ int ret = 0;
+
+ if (copy_from_user(&cmd, buf, sizeof cmd))
+ return -EFAULT;
+
+ mutex_lock(&file->device->xrcd_tree_mutex);
+ uobj = idr_write_uobj(&ib_uverbs_xrcd_idr, cmd.xrcd_handle, file->ucontext);
+ if (!uobj) {
+ ret = -EINVAL;
+ goto out;
+ }
+
+ xrcd = uobj->object;
+ inode = xrcd->inode;
+ obj = container_of(uobj, struct ib_uxrcd_object, uobject);
+ if (atomic_read(&obj->refcnt)) {
+ put_uobj_write(uobj);
+ ret = -EBUSY;
+ goto out;
+ }
+
+ if (!inode || atomic_dec_and_test(&xrcd->usecnt)) {
+ ret = ib_dealloc_xrcd(uobj->object);
+ if (!ret)
+ uobj->live = 0;
+ }
+
+ live = uobj->live;
+ if (inode && ret)
+ atomic_inc(&xrcd->usecnt);
+
+ put_uobj_write(uobj);
+
+ if (ret)
+ goto out;
+
+ if (inode && !live)
+ xrcd_table_delete(file->device, inode);
+
+ idr_remove_uobj(&ib_uverbs_xrcd_idr, uobj);
+ mutex_lock(&file->mutex);
+ list_del(&uobj->list);
+ mutex_unlock(&file->mutex);
+
+ put_uobj(uobj);
+ ret = in_len;
+
+out:
+ mutex_unlock(&file->device->xrcd_tree_mutex);
+ return ret;
+}
+
+void ib_uverbs_dealloc_xrcd(struct ib_uverbs_device *dev,
+ struct ib_xrcd *xrcd)
+{
+ struct inode *inode;
+
+ inode = xrcd->inode;
+ if (inode && !atomic_dec_and_test(&xrcd->usecnt))
+ return;
+
+ ib_dealloc_xrcd(xrcd);
+
+ if (inode)
+ xrcd_table_delete(dev, inode);
+}
+
+ssize_t ib_uverbs_reg_mr(struct ib_uverbs_file *file,
+ struct ib_device *ib_dev,
+ const char __user *buf, int in_len,
+ int out_len)
+{
+ struct ib_uverbs_reg_mr cmd;
+ struct ib_uverbs_reg_mr_resp resp;
+ struct ib_udata udata;
+ struct ib_uobject *uobj;
+ struct ib_pd *pd;
+ struct ib_mr *mr;
+ int ret;
+
+ if (out_len < sizeof resp)
+ return -ENOSPC;
+
+ if (copy_from_user(&cmd, buf, sizeof cmd))
+ return -EFAULT;
+
+ INIT_UDATA(&udata, buf + sizeof cmd,
+ (unsigned long) cmd.response + sizeof resp,
+ in_len - sizeof cmd, out_len - sizeof resp);
+
+ if ((cmd.start & ~PAGE_MASK) != (cmd.hca_va & ~PAGE_MASK))
+ return -EINVAL;
+
+ ret = ib_check_mr_access(cmd.access_flags);
+ if (ret)
+ return ret;
+
+ uobj = kmalloc(sizeof *uobj, GFP_KERNEL);
+ if (!uobj)
+ return -ENOMEM;
+
+ init_uobj(uobj, 0, file->ucontext, &mr_lock_class);
+ down_write(&uobj->mutex);
+
+ pd = idr_read_pd(cmd.pd_handle, file->ucontext);
+ if (!pd) {
+ ret = -EINVAL;
+ goto err_free;
+ }
+
+ if (cmd.access_flags & IB_ACCESS_ON_DEMAND) {
+ if (!(pd->device->attrs.device_cap_flags &
+ IB_DEVICE_ON_DEMAND_PAGING)) {
+ pr_debug("ODP support not available\n");
+ ret = -EINVAL;
+ goto err_put;
+ }
+ }
+
+ mr = pd->device->reg_user_mr(pd, cmd.start, cmd.length, cmd.hca_va,
+ cmd.access_flags, &udata);
+ if (IS_ERR(mr)) {
+ ret = PTR_ERR(mr);
+ goto err_put;
+ }
+
+ mr->device = pd->device;
+ mr->pd = pd;
+ mr->uobject = uobj;
+ atomic_inc(&pd->usecnt);
+
+ uobj->object = mr;
+ ret = idr_add_uobj(&ib_uverbs_mr_idr, uobj);
+ if (ret)
+ goto err_unreg;
+
+ memset(&resp, 0, sizeof resp);
+ resp.lkey = mr->lkey;
+ resp.rkey = mr->rkey;
+ resp.mr_handle = uobj->id;
+
+ if (copy_to_user((void __user *) (unsigned long) cmd.response,
+ &resp, sizeof resp)) {
+ ret = -EFAULT;
+ goto err_copy;
+ }
+
+ put_pd_read(pd);
+
+ mutex_lock(&file->mutex);
+ list_add_tail(&uobj->list, &file->ucontext->mr_list);
+ mutex_unlock(&file->mutex);
+
+ uobj->live = 1;
+
+ up_write(&uobj->mutex);
+
+ return in_len;
+
+err_copy:
+ idr_remove_uobj(&ib_uverbs_mr_idr, uobj);
+
+err_unreg:
+ ib_dereg_mr(mr);
+
+err_put:
+ put_pd_read(pd);
+
+err_free:
+ put_uobj_write(uobj);
+ return ret;
+}
+
+ssize_t ib_uverbs_rereg_mr(struct ib_uverbs_file *file,
+ struct ib_device *ib_dev,
+ const char __user *buf, int in_len,
+ int out_len)
+{
+ struct ib_uverbs_rereg_mr cmd;
+ struct ib_uverbs_rereg_mr_resp resp;
+ struct ib_udata udata;
+ struct ib_pd *pd = NULL;
+ struct ib_mr *mr;
+ struct ib_pd *old_pd;
+ int ret;
+ struct ib_uobject *uobj;
+
+ if (out_len < sizeof(resp))
+ return -ENOSPC;
+
+ if (copy_from_user(&cmd, buf, sizeof(cmd)))
+ return -EFAULT;
+
+ INIT_UDATA(&udata, buf + sizeof(cmd),
+ (unsigned long) cmd.response + sizeof(resp),
+ in_len - sizeof(cmd), out_len - sizeof(resp));
+
+ if (cmd.flags & ~IB_MR_REREG_SUPPORTED || !cmd.flags)
+ return -EINVAL;
+
+ if ((cmd.flags & IB_MR_REREG_TRANS) &&
+ (!cmd.start || !cmd.hca_va || 0 >= cmd.length ||
+ (cmd.start & ~PAGE_MASK) != (cmd.hca_va & ~PAGE_MASK)))
+ return -EINVAL;
+
+ uobj = idr_write_uobj(&ib_uverbs_mr_idr, cmd.mr_handle,
+ file->ucontext);
+
+ if (!uobj)
+ return -EINVAL;
+
+ mr = uobj->object;
+
+ if (cmd.flags & IB_MR_REREG_ACCESS) {
+ ret = ib_check_mr_access(cmd.access_flags);
+ if (ret)
+ goto put_uobjs;
+ }
+
+ if (cmd.flags & IB_MR_REREG_PD) {
+ pd = idr_read_pd(cmd.pd_handle, file->ucontext);
+ if (!pd) {
+ ret = -EINVAL;
+ goto put_uobjs;
+ }
+ }
+
+ old_pd = mr->pd;
+ ret = mr->device->rereg_user_mr(mr, cmd.flags, cmd.start,
+ cmd.length, cmd.hca_va,
+ cmd.access_flags, pd, &udata);
+ if (!ret) {
+ if (cmd.flags & IB_MR_REREG_PD) {
+ atomic_inc(&pd->usecnt);
+ mr->pd = pd;
+ atomic_dec(&old_pd->usecnt);
+ }
+ } else {
+ goto put_uobj_pd;
+ }
+
+ memset(&resp, 0, sizeof(resp));
+ resp.lkey = mr->lkey;
+ resp.rkey = mr->rkey;
+
+ if (copy_to_user((void __user *)(unsigned long)cmd.response,
+ &resp, sizeof(resp)))
+ ret = -EFAULT;
+ else
+ ret = in_len;
+
+put_uobj_pd:
+ if (cmd.flags & IB_MR_REREG_PD)
+ put_pd_read(pd);
+
+put_uobjs:
+
+ put_uobj_write(mr->uobject);
+
+ return ret;
+}
+
+ssize_t ib_uverbs_dereg_mr(struct ib_uverbs_file *file,
+ struct ib_device *ib_dev,
+ const char __user *buf, int in_len,
+ int out_len)
+{
+ struct ib_uverbs_dereg_mr cmd;
+ struct ib_mr *mr;
+ struct ib_uobject *uobj;
+ int ret = -EINVAL;
+
+ if (copy_from_user(&cmd, buf, sizeof cmd))
+ return -EFAULT;
+
+ uobj = idr_write_uobj(&ib_uverbs_mr_idr, cmd.mr_handle, file->ucontext);
+ if (!uobj)
+ return -EINVAL;
+
+ mr = uobj->object;
+
+ ret = ib_dereg_mr(mr);
+ if (!ret)
+ uobj->live = 0;
+
+ put_uobj_write(uobj);
+
+ if (ret)
+ return ret;
+
+ idr_remove_uobj(&ib_uverbs_mr_idr, uobj);
+
+ mutex_lock(&file->mutex);
+ list_del(&uobj->list);
+ mutex_unlock(&file->mutex);
+
+ put_uobj(uobj);
+
+ return in_len;
+}
+
+ssize_t ib_uverbs_alloc_mw(struct ib_uverbs_file *file,
+ struct ib_device *ib_dev,
+ const char __user *buf, int in_len,
+ int out_len)
+{
+ struct ib_uverbs_alloc_mw cmd;
+ struct ib_uverbs_alloc_mw_resp resp;
+ struct ib_uobject *uobj;
+ struct ib_pd *pd;
+ struct ib_mw *mw;
+ struct ib_udata udata;
+ int ret;
+
+ if (out_len < sizeof(resp))
+ return -ENOSPC;
+
+ if (copy_from_user(&cmd, buf, sizeof(cmd)))
+ return -EFAULT;
+
+ uobj = kmalloc(sizeof(*uobj), GFP_KERNEL);
+ if (!uobj)
+ return -ENOMEM;
+
+ init_uobj(uobj, 0, file->ucontext, &mw_lock_class);
+ down_write(&uobj->mutex);
+
+ pd = idr_read_pd(cmd.pd_handle, file->ucontext);
+ if (!pd) {
+ ret = -EINVAL;
+ goto err_free;
+ }
+
+ INIT_UDATA(&udata, buf + sizeof(cmd),
+ (unsigned long)cmd.response + sizeof(resp),
+ in_len - sizeof(cmd) - sizeof(struct ib_uverbs_cmd_hdr),
+ out_len - sizeof(resp));
+
+ mw = pd->device->alloc_mw(pd, cmd.mw_type, &udata);
+ if (IS_ERR(mw)) {
+ ret = PTR_ERR(mw);
+ goto err_put;
+ }
+
+ mw->device = pd->device;
+ mw->pd = pd;
+ mw->uobject = uobj;
+ atomic_inc(&pd->usecnt);
+
+ uobj->object = mw;
+ ret = idr_add_uobj(&ib_uverbs_mw_idr, uobj);
+ if (ret)
+ goto err_unalloc;
+
+ memset(&resp, 0, sizeof(resp));
+ resp.rkey = mw->rkey;
+ resp.mw_handle = uobj->id;
+
+ if (copy_to_user((void __user *)(unsigned long)cmd.response,
+ &resp, sizeof(resp))) {
+ ret = -EFAULT;
+ goto err_copy;
+ }
+
+ put_pd_read(pd);
+
+ mutex_lock(&file->mutex);
+ list_add_tail(&uobj->list, &file->ucontext->mw_list);
+ mutex_unlock(&file->mutex);
+
+ uobj->live = 1;
+
+ up_write(&uobj->mutex);
+
+ return in_len;
+
+err_copy:
+ idr_remove_uobj(&ib_uverbs_mw_idr, uobj);
+
+err_unalloc:
+ uverbs_dealloc_mw(mw);
+
+err_put:
+ put_pd_read(pd);
+
+err_free:
+ put_uobj_write(uobj);
+ return ret;
+}
+
+ssize_t ib_uverbs_dealloc_mw(struct ib_uverbs_file *file,
+ struct ib_device *ib_dev,
+ const char __user *buf, int in_len,
+ int out_len)
+{
+ struct ib_uverbs_dealloc_mw cmd;
+ struct ib_mw *mw;
+ struct ib_uobject *uobj;
+ int ret = -EINVAL;
+
+ if (copy_from_user(&cmd, buf, sizeof(cmd)))
+ return -EFAULT;
+
+ uobj = idr_write_uobj(&ib_uverbs_mw_idr, cmd.mw_handle, file->ucontext);
+ if (!uobj)
+ return -EINVAL;
+
+ mw = uobj->object;
+
+ ret = uverbs_dealloc_mw(mw);
+ if (!ret)
+ uobj->live = 0;
+
+ put_uobj_write(uobj);
+
+ if (ret)
+ return ret;
+
+ idr_remove_uobj(&ib_uverbs_mw_idr, uobj);
+
+ mutex_lock(&file->mutex);
+ list_del(&uobj->list);
+ mutex_unlock(&file->mutex);
+
+ put_uobj(uobj);
+
+ return in_len;
+}
+
+ssize_t ib_uverbs_create_comp_channel(struct ib_uverbs_file *file,
+ struct ib_device *ib_dev,
+ const char __user *buf, int in_len,
+ int out_len)
+{
+ struct ib_uverbs_create_comp_channel cmd;
+ struct ib_uverbs_create_comp_channel_resp resp;
+ struct file *filp;
+ int ret;
+
+ if (out_len < sizeof resp)
+ return -ENOSPC;
+
+ if (copy_from_user(&cmd, buf, sizeof cmd))
+ return -EFAULT;
+
+ ret = get_unused_fd_flags(O_CLOEXEC);
+ if (ret < 0)
+ return ret;
+ resp.fd = ret;
+
+ filp = ib_uverbs_alloc_event_file(file, ib_dev, 0);
+ if (IS_ERR(filp)) {
+ put_unused_fd(resp.fd);
+ return PTR_ERR(filp);
+ }
+
+ if (copy_to_user((void __user *) (unsigned long) cmd.response,
+ &resp, sizeof resp)) {
+ put_unused_fd(resp.fd);
+ fput(filp);
+ return -EFAULT;
+ }
+
+ fd_install(resp.fd, filp);
+ return in_len;
+}
+
+static struct ib_ucq_object *create_cq(struct ib_uverbs_file *file,
+ struct ib_device *ib_dev,
+ struct ib_udata *ucore,
+ struct ib_udata *uhw,
+ struct ib_uverbs_ex_create_cq *cmd,
+ size_t cmd_sz,
+ int (*cb)(struct ib_uverbs_file *file,
+ struct ib_ucq_object *obj,
+ struct ib_uverbs_ex_create_cq_resp *resp,
+ struct ib_udata *udata,
+ void *context),
+ void *context)
+{
+ struct ib_ucq_object *obj;
+ struct ib_uverbs_event_file *ev_file = NULL;
+ struct ib_cq *cq;
+ int ret;
+ struct ib_uverbs_ex_create_cq_resp resp;
+ struct ib_cq_init_attr attr = {};
+
+ if (cmd->comp_vector >= file->device->num_comp_vectors)
+ return ERR_PTR(-EINVAL);
+
+ obj = kmalloc(sizeof *obj, GFP_KERNEL);
+ if (!obj)
+ return ERR_PTR(-ENOMEM);
+
+ init_uobj(&obj->uobject, cmd->user_handle, file->ucontext, &cq_lock_class);
+ down_write(&obj->uobject.mutex);
+
+ if (cmd->comp_channel >= 0) {
+ ev_file = ib_uverbs_lookup_comp_file(cmd->comp_channel);
+ if (!ev_file) {
+ ret = -EINVAL;
+ goto err;
+ }
+ }
+
+ obj->uverbs_file = file;
+ obj->comp_events_reported = 0;
+ obj->async_events_reported = 0;
+ INIT_LIST_HEAD(&obj->comp_list);
+ INIT_LIST_HEAD(&obj->async_list);
+
+ attr.cqe = cmd->cqe;
+ attr.comp_vector = cmd->comp_vector;
+
+ if (cmd_sz > offsetof(typeof(*cmd), flags) + sizeof(cmd->flags))
+ attr.flags = cmd->flags;
+
+ cq = ib_dev->create_cq(ib_dev, &attr,
+ file->ucontext, uhw);
+ if (IS_ERR(cq)) {
+ ret = PTR_ERR(cq);
+ goto err_file;
+ }
+
+ cq->device = ib_dev;
+ cq->uobject = &obj->uobject;
+ cq->comp_handler = ib_uverbs_comp_handler;
+ cq->event_handler = ib_uverbs_cq_event_handler;
+ cq->cq_context = ev_file;
+ atomic_set(&cq->usecnt, 0);
+
+ obj->uobject.object = cq;
+ ret = idr_add_uobj(&ib_uverbs_cq_idr, &obj->uobject);
+ if (ret)
+ goto err_free;
+
+ memset(&resp, 0, sizeof resp);
+ resp.base.cq_handle = obj->uobject.id;
+ resp.base.cqe = cq->cqe;
+
+ resp.response_length = offsetof(typeof(resp), response_length) +
+ sizeof(resp.response_length);
+
+ ret = cb(file, obj, &resp, ucore, context);
+ if (ret)
+ goto err_cb;
+
+ mutex_lock(&file->mutex);
+ list_add_tail(&obj->uobject.list, &file->ucontext->cq_list);
+ mutex_unlock(&file->mutex);
+
+ obj->uobject.live = 1;
+
+ up_write(&obj->uobject.mutex);
+
+ return obj;
+
+err_cb:
+ idr_remove_uobj(&ib_uverbs_cq_idr, &obj->uobject);
+
+err_free:
+ ib_destroy_cq(cq);
+
+err_file:
+ if (ev_file)
+ ib_uverbs_release_ucq(file, ev_file, obj);
+
+err:
+ put_uobj_write(&obj->uobject);
+
+ return ERR_PTR(ret);
+}
+
+static int ib_uverbs_create_cq_cb(struct ib_uverbs_file *file,
+ struct ib_ucq_object *obj,
+ struct ib_uverbs_ex_create_cq_resp *resp,
+ struct ib_udata *ucore, void *context)
+{
+ if (ib_copy_to_udata(ucore, &resp->base, sizeof(resp->base)))
+ return -EFAULT;
+
+ return 0;
+}
+
+ssize_t ib_uverbs_create_cq(struct ib_uverbs_file *file,
+ struct ib_device *ib_dev,
+ const char __user *buf, int in_len,
+ int out_len)
+{
+ struct ib_uverbs_create_cq cmd;
+ struct ib_uverbs_ex_create_cq cmd_ex;
+ struct ib_uverbs_create_cq_resp resp;
+ struct ib_udata ucore;
+ struct ib_udata uhw;
+ struct ib_ucq_object *obj;
+
+ if (out_len < sizeof(resp))
+ return -ENOSPC;
+
+ if (copy_from_user(&cmd, buf, sizeof(cmd)))
+ return -EFAULT;
+
+ INIT_UDATA(&ucore, buf, (unsigned long)cmd.response, sizeof(cmd), sizeof(resp));
+
+ INIT_UDATA(&uhw, buf + sizeof(cmd),
+ (unsigned long)cmd.response + sizeof(resp),
+ in_len - sizeof(cmd), out_len - sizeof(resp));
+
+ memset(&cmd_ex, 0, sizeof(cmd_ex));
+ cmd_ex.user_handle = cmd.user_handle;
+ cmd_ex.cqe = cmd.cqe;
+ cmd_ex.comp_vector = cmd.comp_vector;
+ cmd_ex.comp_channel = cmd.comp_channel;
+
+ obj = create_cq(file, ib_dev, &ucore, &uhw, &cmd_ex,
+ offsetof(typeof(cmd_ex), comp_channel) +
+ sizeof(cmd.comp_channel), ib_uverbs_create_cq_cb,
+ NULL);
+
+ if (IS_ERR(obj))
+ return PTR_ERR(obj);
+
+ return in_len;
+}
+
+static int ib_uverbs_ex_create_cq_cb(struct ib_uverbs_file *file,
+ struct ib_ucq_object *obj,
+ struct ib_uverbs_ex_create_cq_resp *resp,
+ struct ib_udata *ucore, void *context)
+{
+ if (ib_copy_to_udata(ucore, resp, resp->response_length))
+ return -EFAULT;
+
+ return 0;
+}
+
+int ib_uverbs_ex_create_cq(struct ib_uverbs_file *file,
+ struct ib_device *ib_dev,
+ struct ib_udata *ucore,
+ struct ib_udata *uhw)
+{
+ struct ib_uverbs_ex_create_cq_resp resp;
+ struct ib_uverbs_ex_create_cq cmd;
+ struct ib_ucq_object *obj;
+ int err;
+
+ if (ucore->inlen < sizeof(cmd))
+ return -EINVAL;
+
+ err = ib_copy_from_udata(&cmd, ucore, sizeof(cmd));
+ if (err)
+ return err;
+
+ if (cmd.comp_mask)
+ return -EINVAL;
+
+ if (cmd.reserved)
+ return -EINVAL;
+
+ if (ucore->outlen < (offsetof(typeof(resp), response_length) +
+ sizeof(resp.response_length)))
+ return -ENOSPC;
+
+ obj = create_cq(file, ib_dev, ucore, uhw, &cmd,
+ min(ucore->inlen, sizeof(cmd)),
+ ib_uverbs_ex_create_cq_cb, NULL);
+
+ if (IS_ERR(obj))
+ return PTR_ERR(obj);
+
+ return 0;
+}
+
+ssize_t ib_uverbs_resize_cq(struct ib_uverbs_file *file,
+ struct ib_device *ib_dev,
+ const char __user *buf, int in_len,
+ int out_len)
+{
+ struct ib_uverbs_resize_cq cmd;
+ struct ib_uverbs_resize_cq_resp resp;
+ struct ib_udata udata;
+ struct ib_cq *cq;
+ int ret = -EINVAL;
+
+ if (copy_from_user(&cmd, buf, sizeof cmd))
+ return -EFAULT;
+
+ INIT_UDATA(&udata, buf + sizeof cmd,
+ (unsigned long) cmd.response + sizeof resp,
+ in_len - sizeof cmd, out_len - sizeof resp);
+
+ cq = idr_read_cq(cmd.cq_handle, file->ucontext, 0);
+ if (!cq)
+ return -EINVAL;
+
+ ret = cq->device->resize_cq(cq, cmd.cqe, &udata);
+ if (ret)
+ goto out;
+
+ resp.cqe = cq->cqe;
+
+ if (copy_to_user((void __user *) (unsigned long) cmd.response,
+ &resp, sizeof resp.cqe))
+ ret = -EFAULT;
+
+out:
+ put_cq_read(cq);
+
+ return ret ? ret : in_len;
+}
+
+static int copy_wc_to_user(void __user *dest, struct ib_wc *wc)
+{
+ struct ib_uverbs_wc tmp;
+
+ tmp.wr_id = wc->wr_id;
+ tmp.status = wc->status;
+ tmp.opcode = wc->opcode;
+ tmp.vendor_err = wc->vendor_err;
+ tmp.byte_len = wc->byte_len;
+ tmp.ex.imm_data = (__u32 __force) wc->ex.imm_data;
+ tmp.qp_num = wc->qp->qp_num;
+ tmp.src_qp = wc->src_qp;
+ tmp.wc_flags = wc->wc_flags;
+ tmp.pkey_index = wc->pkey_index;
+ tmp.slid = wc->slid;
+ tmp.sl = wc->sl;
+ tmp.dlid_path_bits = wc->dlid_path_bits;
+ tmp.port_num = wc->port_num;
+ tmp.reserved = 0;
+
+ if (copy_to_user(dest, &tmp, sizeof tmp))
+ return -EFAULT;
+
+ return 0;
+}
+
+ssize_t ib_uverbs_poll_cq(struct ib_uverbs_file *file,
+ struct ib_device *ib_dev,
+ const char __user *buf, int in_len,
+ int out_len)
+{
+ struct ib_uverbs_poll_cq cmd;
+ struct ib_uverbs_poll_cq_resp resp;
+ u8 __user *header_ptr;
+ u8 __user *data_ptr;
+ struct ib_cq *cq;
+ struct ib_wc wc;
+ int ret;
+
+ if (copy_from_user(&cmd, buf, sizeof cmd))
+ return -EFAULT;
+
+ cq = idr_read_cq(cmd.cq_handle, file->ucontext, 0);
+ if (!cq)
+ return -EINVAL;
+
+ /* we copy a struct ib_uverbs_poll_cq_resp to user space */
+ header_ptr = (void __user *)(unsigned long) cmd.response;
+ data_ptr = header_ptr + sizeof resp;
+
+ memset(&resp, 0, sizeof resp);
+ while (resp.count < cmd.ne) {
+ ret = ib_poll_cq(cq, 1, &wc);
+ if (ret < 0)
+ goto out_put;
+ if (!ret)
+ break;
+
+ ret = copy_wc_to_user(data_ptr, &wc);
+ if (ret)
+ goto out_put;
+
+ data_ptr += sizeof(struct ib_uverbs_wc);
+ ++resp.count;
+ }
+
+ if (copy_to_user(header_ptr, &resp, sizeof resp)) {
+ ret = -EFAULT;
+ goto out_put;
+ }
+
+ ret = in_len;
+
+out_put:
+ put_cq_read(cq);
+ return ret;
+}
+
+ssize_t ib_uverbs_req_notify_cq(struct ib_uverbs_file *file,
+ struct ib_device *ib_dev,
+ const char __user *buf, int in_len,
+ int out_len)
+{
+ struct ib_uverbs_req_notify_cq cmd;
+ struct ib_cq *cq;
+
+ if (copy_from_user(&cmd, buf, sizeof cmd))
+ return -EFAULT;
+
+ cq = idr_read_cq(cmd.cq_handle, file->ucontext, 0);
+ if (!cq)
+ return -EINVAL;
+
+ ib_req_notify_cq(cq, cmd.solicited_only ?
+ IB_CQ_SOLICITED : IB_CQ_NEXT_COMP);
+
+ put_cq_read(cq);
+
+ return in_len;
+}
+
+ssize_t ib_uverbs_destroy_cq(struct ib_uverbs_file *file,
+ struct ib_device *ib_dev,
+ const char __user *buf, int in_len,
+ int out_len)
+{
+ struct ib_uverbs_destroy_cq cmd;
+ struct ib_uverbs_destroy_cq_resp resp;
+ struct ib_uobject *uobj;
+ struct ib_cq *cq;
+ struct ib_ucq_object *obj;
+ struct ib_uverbs_event_file *ev_file;
+ int ret = -EINVAL;
+
+ if (copy_from_user(&cmd, buf, sizeof cmd))
+ return -EFAULT;
+
+ uobj = idr_write_uobj(&ib_uverbs_cq_idr, cmd.cq_handle, file->ucontext);
+ if (!uobj)
+ return -EINVAL;
+ cq = uobj->object;
+ ev_file = cq->cq_context;
+ obj = container_of(cq->uobject, struct ib_ucq_object, uobject);
+
+ ret = ib_destroy_cq(cq);
+ if (!ret)
+ uobj->live = 0;
+
+ put_uobj_write(uobj);
+
+ if (ret)
+ return ret;
+
+ idr_remove_uobj(&ib_uverbs_cq_idr, uobj);
+
+ mutex_lock(&file->mutex);
+ list_del(&uobj->list);
+ mutex_unlock(&file->mutex);
+
+ ib_uverbs_release_ucq(file, ev_file, obj);
+
+ memset(&resp, 0, sizeof resp);
+ resp.comp_events_reported = obj->comp_events_reported;
+ resp.async_events_reported = obj->async_events_reported;
+
+ put_uobj(uobj);
+
+ if (copy_to_user((void __user *) (unsigned long) cmd.response,
+ &resp, sizeof resp))
+ return -EFAULT;
+
+ return in_len;
+}
+
+static int create_qp(struct ib_uverbs_file *file,
+ struct ib_udata *ucore,
+ struct ib_udata *uhw,
+ struct ib_uverbs_ex_create_qp *cmd,
+ size_t cmd_sz,
+ int (*cb)(struct ib_uverbs_file *file,
+ struct ib_uverbs_ex_create_qp_resp *resp,
+ struct ib_udata *udata),
+ void *context)
+{
+ struct ib_uqp_object *obj;
+ struct ib_device *device;
+ struct ib_pd *pd = NULL;
+ struct ib_xrcd *xrcd = NULL;
+ struct ib_uobject *uninitialized_var(xrcd_uobj);
+ struct ib_cq *scq = NULL, *rcq = NULL;
+ struct ib_srq *srq = NULL;
+ struct ib_qp *qp;
+ char *buf;
+ struct ib_qp_init_attr attr = {};
+ struct ib_uverbs_ex_create_qp_resp resp;
+ int ret;
+ struct ib_rwq_ind_table *ind_tbl = NULL;
+ bool has_sq = true;
+
+ if (cmd->qp_type == IB_QPT_RAW_PACKET && priv_check(curthread, PRIV_NET_RAW) != 0)
+ return -EPERM;
+
+ obj = kzalloc(sizeof *obj, GFP_KERNEL);
+ if (!obj)
+ return -ENOMEM;
+
+ init_uobj(&obj->uevent.uobject, cmd->user_handle, file->ucontext,
+ &qp_lock_class);
+ down_write(&obj->uevent.uobject.mutex);
+ if (cmd_sz >= offsetof(typeof(*cmd), rwq_ind_tbl_handle) +
+ sizeof(cmd->rwq_ind_tbl_handle) &&
+ (cmd->comp_mask & IB_UVERBS_CREATE_QP_MASK_IND_TABLE)) {
+ ind_tbl = idr_read_rwq_indirection_table(cmd->rwq_ind_tbl_handle,
+ file->ucontext);
+ if (!ind_tbl) {
+ ret = -EINVAL;
+ goto err_put;
+ }
+
+ attr.rwq_ind_tbl = ind_tbl;
+ }
+
+ if ((cmd_sz >= offsetof(typeof(*cmd), reserved1) +
+ sizeof(cmd->reserved1)) && cmd->reserved1) {
+ ret = -EOPNOTSUPP;
+ goto err_put;
+ }
+
+ if (ind_tbl && (cmd->max_recv_wr || cmd->max_recv_sge || cmd->is_srq)) {
+ ret = -EINVAL;
+ goto err_put;
+ }
+
+ if (ind_tbl && !cmd->max_send_wr)
+ has_sq = false;
+
+ if (cmd->qp_type == IB_QPT_XRC_TGT) {
+ xrcd = idr_read_xrcd(cmd->pd_handle, file->ucontext,
+ &xrcd_uobj);
+ if (!xrcd) {
+ ret = -EINVAL;
+ goto err_put;
+ }
+ device = xrcd->device;
+ } else {
+ if (cmd->qp_type == IB_QPT_XRC_INI) {
+ cmd->max_recv_wr = 0;
+ cmd->max_recv_sge = 0;
+ } else {
+ if (cmd->is_srq) {
+ srq = idr_read_srq(cmd->srq_handle,
+ file->ucontext);
+ if (!srq || srq->srq_type != IB_SRQT_BASIC) {
+ ret = -EINVAL;
+ goto err_put;
+ }
+ }
+
+ if (!ind_tbl) {
+ if (cmd->recv_cq_handle != cmd->send_cq_handle) {
+ rcq = idr_read_cq(cmd->recv_cq_handle,
+ file->ucontext, 0);
+ if (!rcq) {
+ ret = -EINVAL;
+ goto err_put;
+ }
+ }
+ }
+ }
+
+ if (has_sq)
+ scq = idr_read_cq(cmd->send_cq_handle, file->ucontext, !!rcq);
+ if (!ind_tbl)
+ rcq = rcq ?: scq;
+ pd = idr_read_pd(cmd->pd_handle, file->ucontext);
+ if (!pd || (!scq && has_sq)) {
+ ret = -EINVAL;
+ goto err_put;
+ }
+
+ device = pd->device;
+ }
+
+ attr.event_handler = ib_uverbs_qp_event_handler;
+ attr.qp_context = file;
+ attr.send_cq = scq;
+ attr.recv_cq = rcq;
+ attr.srq = srq;
+ attr.xrcd = xrcd;
+ attr.sq_sig_type = cmd->sq_sig_all ? IB_SIGNAL_ALL_WR :
+ IB_SIGNAL_REQ_WR;
+ attr.qp_type = cmd->qp_type;
+ attr.create_flags = 0;
+
+ attr.cap.max_send_wr = cmd->max_send_wr;
+ attr.cap.max_recv_wr = cmd->max_recv_wr;
+ attr.cap.max_send_sge = cmd->max_send_sge;
+ attr.cap.max_recv_sge = cmd->max_recv_sge;
+ attr.cap.max_inline_data = cmd->max_inline_data;
+
+ obj->uevent.events_reported = 0;
+ INIT_LIST_HEAD(&obj->uevent.event_list);
+ INIT_LIST_HEAD(&obj->mcast_list);
+
+ if (cmd_sz >= offsetof(typeof(*cmd), create_flags) +
+ sizeof(cmd->create_flags))
+ attr.create_flags = cmd->create_flags;
+
+ if (attr.create_flags & ~(IB_QP_CREATE_BLOCK_MULTICAST_LOOPBACK |
+ IB_QP_CREATE_CROSS_CHANNEL |
+ IB_QP_CREATE_MANAGED_SEND |
+ IB_QP_CREATE_MANAGED_RECV |
+ IB_QP_CREATE_SCATTER_FCS)) {
+ ret = -EINVAL;
+ goto err_put;
+ }
+
+ buf = (char *)cmd + sizeof(*cmd);
+ if (cmd_sz > sizeof(*cmd))
+ if (!(buf[0] == 0 && !memcmp(buf, buf + 1,
+ cmd_sz - sizeof(*cmd) - 1))) {
+ ret = -EINVAL;
+ goto err_put;
+ }
+
+ if (cmd->qp_type == IB_QPT_XRC_TGT)
+ qp = ib_create_qp(pd, &attr);
+ else
+ qp = device->create_qp(pd, &attr, uhw);
+
+ if (IS_ERR(qp)) {
+ ret = PTR_ERR(qp);
+ goto err_put;
+ }
+
+ if (cmd->qp_type != IB_QPT_XRC_TGT) {
+ qp->real_qp = qp;
+ qp->device = device;
+ qp->pd = pd;
+ qp->send_cq = attr.send_cq;
+ qp->recv_cq = attr.recv_cq;
+ qp->srq = attr.srq;
+ qp->rwq_ind_tbl = ind_tbl;
+ qp->event_handler = attr.event_handler;
+ qp->qp_context = attr.qp_context;
+ qp->qp_type = attr.qp_type;
+ atomic_set(&qp->usecnt, 0);
+ atomic_inc(&pd->usecnt);
+ if (attr.send_cq)
+ atomic_inc(&attr.send_cq->usecnt);
+ if (attr.recv_cq)
+ atomic_inc(&attr.recv_cq->usecnt);
+ if (attr.srq)
+ atomic_inc(&attr.srq->usecnt);
+ if (ind_tbl)
+ atomic_inc(&ind_tbl->usecnt);
+ }
+ qp->uobject = &obj->uevent.uobject;
+
+ obj->uevent.uobject.object = qp;
+ ret = idr_add_uobj(&ib_uverbs_qp_idr, &obj->uevent.uobject);
+ if (ret)
+ goto err_destroy;
+
+ memset(&resp, 0, sizeof resp);
+ resp.base.qpn = qp->qp_num;
+ resp.base.qp_handle = obj->uevent.uobject.id;
+ resp.base.max_recv_sge = attr.cap.max_recv_sge;
+ resp.base.max_send_sge = attr.cap.max_send_sge;
+ resp.base.max_recv_wr = attr.cap.max_recv_wr;
+ resp.base.max_send_wr = attr.cap.max_send_wr;
+ resp.base.max_inline_data = attr.cap.max_inline_data;
+
+ resp.response_length = offsetof(typeof(resp), response_length) +
+ sizeof(resp.response_length);
+
+ ret = cb(file, &resp, ucore);
+ if (ret)
+ goto err_cb;
+
+ if (xrcd) {
+ obj->uxrcd = container_of(xrcd_uobj, struct ib_uxrcd_object,
+ uobject);
+ atomic_inc(&obj->uxrcd->refcnt);
+ put_xrcd_read(xrcd_uobj);
+ }
+
+ if (pd)
+ put_pd_read(pd);
+ if (scq)
+ put_cq_read(scq);
+ if (rcq && rcq != scq)
+ put_cq_read(rcq);
+ if (srq)
+ put_srq_read(srq);
+ if (ind_tbl)
+ put_rwq_indirection_table_read(ind_tbl);
+
+ mutex_lock(&file->mutex);
+ list_add_tail(&obj->uevent.uobject.list, &file->ucontext->qp_list);
+ mutex_unlock(&file->mutex);
+
+ obj->uevent.uobject.live = 1;
+
+ up_write(&obj->uevent.uobject.mutex);
+
+ return 0;
+err_cb:
+ idr_remove_uobj(&ib_uverbs_qp_idr, &obj->uevent.uobject);
+
+err_destroy:
+ ib_destroy_qp(qp);
+
+err_put:
+ if (xrcd)
+ put_xrcd_read(xrcd_uobj);
+ if (pd)
+ put_pd_read(pd);
+ if (scq)
+ put_cq_read(scq);
+ if (rcq && rcq != scq)
+ put_cq_read(rcq);
+ if (srq)
+ put_srq_read(srq);
+ if (ind_tbl)
+ put_rwq_indirection_table_read(ind_tbl);
+
+ put_uobj_write(&obj->uevent.uobject);
+ return ret;
+}
+
+static int ib_uverbs_create_qp_cb(struct ib_uverbs_file *file,
+ struct ib_uverbs_ex_create_qp_resp *resp,
+ struct ib_udata *ucore)
+{
+ if (ib_copy_to_udata(ucore, &resp->base, sizeof(resp->base)))
+ return -EFAULT;
+
+ return 0;
+}
+
+ssize_t ib_uverbs_create_qp(struct ib_uverbs_file *file,
+ struct ib_device *ib_dev,
+ const char __user *buf, int in_len,
+ int out_len)
+{
+ struct ib_uverbs_create_qp cmd;
+ struct ib_uverbs_ex_create_qp cmd_ex;
+ struct ib_udata ucore;
+ struct ib_udata uhw;
+ ssize_t resp_size = sizeof(struct ib_uverbs_create_qp_resp);
+ int err;
+
+ if (out_len < resp_size)
+ return -ENOSPC;
+
+ if (copy_from_user(&cmd, buf, sizeof(cmd)))
+ return -EFAULT;
+
+ INIT_UDATA(&ucore, buf, (unsigned long)cmd.response, sizeof(cmd),
+ resp_size);
+ INIT_UDATA(&uhw, buf + sizeof(cmd),
+ (unsigned long)cmd.response + resp_size,
+ in_len - sizeof(cmd) - sizeof(struct ib_uverbs_cmd_hdr),
+ out_len - resp_size);
+
+ memset(&cmd_ex, 0, sizeof(cmd_ex));
+ cmd_ex.user_handle = cmd.user_handle;
+ cmd_ex.pd_handle = cmd.pd_handle;
+ cmd_ex.send_cq_handle = cmd.send_cq_handle;
+ cmd_ex.recv_cq_handle = cmd.recv_cq_handle;
+ cmd_ex.srq_handle = cmd.srq_handle;
+ cmd_ex.max_send_wr = cmd.max_send_wr;
+ cmd_ex.max_recv_wr = cmd.max_recv_wr;
+ cmd_ex.max_send_sge = cmd.max_send_sge;
+ cmd_ex.max_recv_sge = cmd.max_recv_sge;
+ cmd_ex.max_inline_data = cmd.max_inline_data;
+ cmd_ex.sq_sig_all = cmd.sq_sig_all;
+ cmd_ex.qp_type = cmd.qp_type;
+ cmd_ex.is_srq = cmd.is_srq;
+
+ err = create_qp(file, &ucore, &uhw, &cmd_ex,
+ offsetof(typeof(cmd_ex), is_srq) +
+ sizeof(cmd.is_srq), ib_uverbs_create_qp_cb,
+ NULL);
+
+ if (err)
+ return err;
+
+ return in_len;
+}
+
+static int ib_uverbs_ex_create_qp_cb(struct ib_uverbs_file *file,
+ struct ib_uverbs_ex_create_qp_resp *resp,
+ struct ib_udata *ucore)
+{
+ if (ib_copy_to_udata(ucore, resp, resp->response_length))
+ return -EFAULT;
+
+ return 0;
+}
+
+int ib_uverbs_ex_create_qp(struct ib_uverbs_file *file,
+ struct ib_device *ib_dev,
+ struct ib_udata *ucore,
+ struct ib_udata *uhw)
+{
+ struct ib_uverbs_ex_create_qp_resp resp;
+ struct ib_uverbs_ex_create_qp cmd = {0};
+ int err;
+
+ if (ucore->inlen < (offsetof(typeof(cmd), comp_mask) +
+ sizeof(cmd.comp_mask)))
+ return -EINVAL;
+
+ err = ib_copy_from_udata(&cmd, ucore, min(sizeof(cmd), ucore->inlen));
+ if (err)
+ return err;
+
+ if (cmd.comp_mask & ~IB_UVERBS_CREATE_QP_SUP_COMP_MASK)
+ return -EINVAL;
+
+ if (cmd.reserved)
+ return -EINVAL;
+
+ if (ucore->outlen < (offsetof(typeof(resp), response_length) +
+ sizeof(resp.response_length)))
+ return -ENOSPC;
+
+ err = create_qp(file, ucore, uhw, &cmd,
+ min(ucore->inlen, sizeof(cmd)),
+ ib_uverbs_ex_create_qp_cb, NULL);
+
+ if (err)
+ return err;
+
+ return 0;
+}
+
+ssize_t ib_uverbs_open_qp(struct ib_uverbs_file *file,
+ struct ib_device *ib_dev,
+ const char __user *buf, int in_len, int out_len)
+{
+ struct ib_uverbs_open_qp cmd;
+ struct ib_uverbs_create_qp_resp resp;
+ struct ib_udata udata;
+ struct ib_uqp_object *obj;
+ struct ib_xrcd *xrcd;
+ struct ib_uobject *uninitialized_var(xrcd_uobj);
+ struct ib_qp *qp;
+ struct ib_qp_open_attr attr;
+ int ret;
+
+ if (out_len < sizeof resp)
+ return -ENOSPC;
+
+ if (copy_from_user(&cmd, buf, sizeof cmd))
+ return -EFAULT;
+
+ INIT_UDATA(&udata, buf + sizeof cmd,
+ (unsigned long) cmd.response + sizeof resp,
+ in_len - sizeof cmd, out_len - sizeof resp);
+
+ obj = kmalloc(sizeof *obj, GFP_KERNEL);
+ if (!obj)
+ return -ENOMEM;
+
+ init_uobj(&obj->uevent.uobject, cmd.user_handle, file->ucontext, &qp_lock_class);
+ down_write(&obj->uevent.uobject.mutex);
+
+ xrcd = idr_read_xrcd(cmd.pd_handle, file->ucontext, &xrcd_uobj);
+ if (!xrcd) {
+ ret = -EINVAL;
+ goto err_put;
+ }
+
+ attr.event_handler = ib_uverbs_qp_event_handler;
+ attr.qp_context = file;
+ attr.qp_num = cmd.qpn;
+ attr.qp_type = cmd.qp_type;
+
+ obj->uevent.events_reported = 0;
+ INIT_LIST_HEAD(&obj->uevent.event_list);
+ INIT_LIST_HEAD(&obj->mcast_list);
+
+ qp = ib_open_qp(xrcd, &attr);
+ if (IS_ERR(qp)) {
+ ret = PTR_ERR(qp);
+ goto err_put;
+ }
+
+ qp->uobject = &obj->uevent.uobject;
+
+ obj->uevent.uobject.object = qp;
+ ret = idr_add_uobj(&ib_uverbs_qp_idr, &obj->uevent.uobject);
+ if (ret)
+ goto err_destroy;
+
+ memset(&resp, 0, sizeof resp);
+ resp.qpn = qp->qp_num;
+ resp.qp_handle = obj->uevent.uobject.id;
+
+ if (copy_to_user((void __user *) (unsigned long) cmd.response,
+ &resp, sizeof resp)) {
+ ret = -EFAULT;
+ goto err_remove;
+ }
+
+ obj->uxrcd = container_of(xrcd_uobj, struct ib_uxrcd_object, uobject);
+ atomic_inc(&obj->uxrcd->refcnt);
+ put_xrcd_read(xrcd_uobj);
+
+ mutex_lock(&file->mutex);
+ list_add_tail(&obj->uevent.uobject.list, &file->ucontext->qp_list);
+ mutex_unlock(&file->mutex);
+
+ obj->uevent.uobject.live = 1;
+
+ up_write(&obj->uevent.uobject.mutex);
+
+ return in_len;
+
+err_remove:
+ idr_remove_uobj(&ib_uverbs_qp_idr, &obj->uevent.uobject);
+
+err_destroy:
+ ib_destroy_qp(qp);
+
+err_put:
+ put_xrcd_read(xrcd_uobj);
+ put_uobj_write(&obj->uevent.uobject);
+ return ret;
+}
+
+ssize_t ib_uverbs_query_qp(struct ib_uverbs_file *file,
+ struct ib_device *ib_dev,
+ const char __user *buf, int in_len,
+ int out_len)
+{
+ struct ib_uverbs_query_qp cmd;
+ struct ib_uverbs_query_qp_resp resp;
+ struct ib_qp *qp;
+ struct ib_qp_attr *attr;
+ struct ib_qp_init_attr *init_attr;
+ int ret;
+
+ if (copy_from_user(&cmd, buf, sizeof cmd))
+ return -EFAULT;
+
+ attr = kmalloc(sizeof *attr, GFP_KERNEL);
+ init_attr = kmalloc(sizeof *init_attr, GFP_KERNEL);
+ if (!attr || !init_attr) {
+ ret = -ENOMEM;
+ goto out;
+ }
+
+ qp = idr_read_qp(cmd.qp_handle, file->ucontext);
+ if (!qp) {
+ ret = -EINVAL;
+ goto out;
+ }
+
+ ret = ib_query_qp(qp, attr, cmd.attr_mask, init_attr);
+
+ put_qp_read(qp);
+
+ if (ret)
+ goto out;
+
+ memset(&resp, 0, sizeof resp);
+
+ resp.qp_state = attr->qp_state;
+ resp.cur_qp_state = attr->cur_qp_state;
+ resp.path_mtu = attr->path_mtu;
+ resp.path_mig_state = attr->path_mig_state;
+ resp.qkey = attr->qkey;
+ resp.rq_psn = attr->rq_psn;
+ resp.sq_psn = attr->sq_psn;
+ resp.dest_qp_num = attr->dest_qp_num;
+ resp.qp_access_flags = attr->qp_access_flags;
+ resp.pkey_index = attr->pkey_index;
+ resp.alt_pkey_index = attr->alt_pkey_index;
+ resp.sq_draining = attr->sq_draining;
+ resp.max_rd_atomic = attr->max_rd_atomic;
+ resp.max_dest_rd_atomic = attr->max_dest_rd_atomic;
+ resp.min_rnr_timer = attr->min_rnr_timer;
+ resp.port_num = attr->port_num;
+ resp.timeout = attr->timeout;
+ resp.retry_cnt = attr->retry_cnt;
+ resp.rnr_retry = attr->rnr_retry;
+ resp.alt_port_num = attr->alt_port_num;
+ resp.alt_timeout = attr->alt_timeout;
+
+ memcpy(resp.dest.dgid, attr->ah_attr.grh.dgid.raw, 16);
+ resp.dest.flow_label = attr->ah_attr.grh.flow_label;
+ resp.dest.sgid_index = attr->ah_attr.grh.sgid_index;
+ resp.dest.hop_limit = attr->ah_attr.grh.hop_limit;
+ resp.dest.traffic_class = attr->ah_attr.grh.traffic_class;
+ resp.dest.dlid = attr->ah_attr.dlid;
+ resp.dest.sl = attr->ah_attr.sl;
+ resp.dest.src_path_bits = attr->ah_attr.src_path_bits;
+ resp.dest.static_rate = attr->ah_attr.static_rate;
+ resp.dest.is_global = !!(attr->ah_attr.ah_flags & IB_AH_GRH);
+ resp.dest.port_num = attr->ah_attr.port_num;
+
+ memcpy(resp.alt_dest.dgid, attr->alt_ah_attr.grh.dgid.raw, 16);
+ resp.alt_dest.flow_label = attr->alt_ah_attr.grh.flow_label;
+ resp.alt_dest.sgid_index = attr->alt_ah_attr.grh.sgid_index;
+ resp.alt_dest.hop_limit = attr->alt_ah_attr.grh.hop_limit;
+ resp.alt_dest.traffic_class = attr->alt_ah_attr.grh.traffic_class;
+ resp.alt_dest.dlid = attr->alt_ah_attr.dlid;
+ resp.alt_dest.sl = attr->alt_ah_attr.sl;
+ resp.alt_dest.src_path_bits = attr->alt_ah_attr.src_path_bits;
+ resp.alt_dest.static_rate = attr->alt_ah_attr.static_rate;
+ resp.alt_dest.is_global = !!(attr->alt_ah_attr.ah_flags & IB_AH_GRH);
+ resp.alt_dest.port_num = attr->alt_ah_attr.port_num;
+
+ resp.max_send_wr = init_attr->cap.max_send_wr;
+ resp.max_recv_wr = init_attr->cap.max_recv_wr;
+ resp.max_send_sge = init_attr->cap.max_send_sge;
+ resp.max_recv_sge = init_attr->cap.max_recv_sge;
+ resp.max_inline_data = init_attr->cap.max_inline_data;
+ resp.sq_sig_all = init_attr->sq_sig_type == IB_SIGNAL_ALL_WR;
+
+ if (copy_to_user((void __user *) (unsigned long) cmd.response,
+ &resp, sizeof resp))
+ ret = -EFAULT;
+
+out:
+ kfree(attr);
+ kfree(init_attr);
+
+ return ret ? ret : in_len;
+}
+
+/* Remove ignored fields set in the attribute mask */
+static int modify_qp_mask(enum ib_qp_type qp_type, int mask)
+{
+ switch (qp_type) {
+ case IB_QPT_XRC_INI:
+ return mask & ~(IB_QP_MAX_DEST_RD_ATOMIC | IB_QP_MIN_RNR_TIMER);
+ case IB_QPT_XRC_TGT:
+ return mask & ~(IB_QP_MAX_QP_RD_ATOMIC | IB_QP_RETRY_CNT |
+ IB_QP_RNR_RETRY);
+ default:
+ return mask;
+ }
+}
+
+ssize_t ib_uverbs_modify_qp(struct ib_uverbs_file *file,
+ struct ib_device *ib_dev,
+ const char __user *buf, int in_len,
+ int out_len)
+{
+ struct ib_uverbs_modify_qp cmd;
+ struct ib_udata udata;
+ struct ib_qp *qp;
+ struct ib_qp_attr *attr;
+ int ret;
+
+ if (copy_from_user(&cmd, buf, sizeof cmd))
+ return -EFAULT;
+
+ INIT_UDATA(&udata, buf + sizeof cmd, NULL, in_len - sizeof cmd,
+ out_len);
+
+ attr = kmalloc(sizeof *attr, GFP_KERNEL);
+ if (!attr)
+ return -ENOMEM;
+
+ qp = idr_read_qp(cmd.qp_handle, file->ucontext);
+ if (!qp) {
+ ret = -EINVAL;
+ goto out;
+ }
+
+ attr->qp_state = cmd.qp_state;
+ attr->cur_qp_state = cmd.cur_qp_state;
+ attr->path_mtu = cmd.path_mtu;
+ attr->path_mig_state = cmd.path_mig_state;
+ attr->qkey = cmd.qkey;
+ attr->rq_psn = cmd.rq_psn;
+ attr->sq_psn = cmd.sq_psn;
+ attr->dest_qp_num = cmd.dest_qp_num;
+ attr->qp_access_flags = cmd.qp_access_flags;
+ attr->pkey_index = cmd.pkey_index;
+ attr->alt_pkey_index = cmd.alt_pkey_index;
+ attr->en_sqd_async_notify = cmd.en_sqd_async_notify;
+ attr->max_rd_atomic = cmd.max_rd_atomic;
+ attr->max_dest_rd_atomic = cmd.max_dest_rd_atomic;
+ attr->min_rnr_timer = cmd.min_rnr_timer;
+ attr->port_num = cmd.port_num;
+ attr->timeout = cmd.timeout;
+ attr->retry_cnt = cmd.retry_cnt;
+ attr->rnr_retry = cmd.rnr_retry;
+ attr->alt_port_num = cmd.alt_port_num;
+ attr->alt_timeout = cmd.alt_timeout;
+
+ memcpy(attr->ah_attr.grh.dgid.raw, cmd.dest.dgid, 16);
+ attr->ah_attr.grh.flow_label = cmd.dest.flow_label;
+ attr->ah_attr.grh.sgid_index = cmd.dest.sgid_index;
+ attr->ah_attr.grh.hop_limit = cmd.dest.hop_limit;
+ attr->ah_attr.grh.traffic_class = cmd.dest.traffic_class;
+ attr->ah_attr.dlid = cmd.dest.dlid;
+ attr->ah_attr.sl = cmd.dest.sl;
+ attr->ah_attr.src_path_bits = cmd.dest.src_path_bits;
+ attr->ah_attr.static_rate = cmd.dest.static_rate;
+ attr->ah_attr.ah_flags = cmd.dest.is_global ? IB_AH_GRH : 0;
+ attr->ah_attr.port_num = cmd.dest.port_num;
+
+ memcpy(attr->alt_ah_attr.grh.dgid.raw, cmd.alt_dest.dgid, 16);
+ attr->alt_ah_attr.grh.flow_label = cmd.alt_dest.flow_label;
+ attr->alt_ah_attr.grh.sgid_index = cmd.alt_dest.sgid_index;
+ attr->alt_ah_attr.grh.hop_limit = cmd.alt_dest.hop_limit;
+ attr->alt_ah_attr.grh.traffic_class = cmd.alt_dest.traffic_class;
+ attr->alt_ah_attr.dlid = cmd.alt_dest.dlid;
+ attr->alt_ah_attr.sl = cmd.alt_dest.sl;
+ attr->alt_ah_attr.src_path_bits = cmd.alt_dest.src_path_bits;
+ attr->alt_ah_attr.static_rate = cmd.alt_dest.static_rate;
+ attr->alt_ah_attr.ah_flags = cmd.alt_dest.is_global ? IB_AH_GRH : 0;
+ attr->alt_ah_attr.port_num = cmd.alt_dest.port_num;
+
+ if (qp->real_qp == qp) {
+ ret = ib_resolve_eth_dmac(qp, attr, &cmd.attr_mask);
+ if (ret)
+ goto release_qp;
+ ret = qp->device->modify_qp(qp, attr,
+ modify_qp_mask(qp->qp_type, cmd.attr_mask), &udata);
+ } else {
+ ret = ib_modify_qp(qp, attr, modify_qp_mask(qp->qp_type, cmd.attr_mask));
+ }
+
+ if (ret)
+ goto release_qp;
+
+ ret = in_len;
+
+release_qp:
+ put_qp_read(qp);
+
+out:
+ kfree(attr);
+
+ return ret;
+}
+
+ssize_t ib_uverbs_destroy_qp(struct ib_uverbs_file *file,
+ struct ib_device *ib_dev,
+ const char __user *buf, int in_len,
+ int out_len)
+{
+ struct ib_uverbs_destroy_qp cmd;
+ struct ib_uverbs_destroy_qp_resp resp;
+ struct ib_uobject *uobj;
+ struct ib_qp *qp;
+ struct ib_uqp_object *obj;
+ int ret = -EINVAL;
+
+ if (copy_from_user(&cmd, buf, sizeof cmd))
+ return -EFAULT;
+
+ memset(&resp, 0, sizeof resp);
+
+ uobj = idr_write_uobj(&ib_uverbs_qp_idr, cmd.qp_handle, file->ucontext);
+ if (!uobj)
+ return -EINVAL;
+ qp = uobj->object;
+ obj = container_of(uobj, struct ib_uqp_object, uevent.uobject);
+
+ if (!list_empty(&obj->mcast_list)) {
+ put_uobj_write(uobj);
+ return -EBUSY;
+ }
+
+ ret = ib_destroy_qp(qp);
+ if (!ret)
+ uobj->live = 0;
+
+ put_uobj_write(uobj);
+
+ if (ret)
+ return ret;
+
+ if (obj->uxrcd)
+ atomic_dec(&obj->uxrcd->refcnt);
+
+ idr_remove_uobj(&ib_uverbs_qp_idr, uobj);
+
+ mutex_lock(&file->mutex);
+ list_del(&uobj->list);
+ mutex_unlock(&file->mutex);
+
+ ib_uverbs_release_uevent(file, &obj->uevent);
+
+ resp.events_reported = obj->uevent.events_reported;
+
+ put_uobj(uobj);
+
+ if (copy_to_user((void __user *) (unsigned long) cmd.response,
+ &resp, sizeof resp))
+ return -EFAULT;
+
+ return in_len;
+}
+
+static void *alloc_wr(size_t wr_size, __u32 num_sge)
+{
+ return kmalloc(ALIGN(wr_size, sizeof (struct ib_sge)) +
+ num_sge * sizeof (struct ib_sge), GFP_KERNEL);
+};
+
+ssize_t ib_uverbs_post_send(struct ib_uverbs_file *file,
+ struct ib_device *ib_dev,
+ const char __user *buf, int in_len,
+ int out_len)
+{
+ struct ib_uverbs_post_send cmd;
+ struct ib_uverbs_post_send_resp resp;
+ struct ib_uverbs_send_wr *user_wr;
+ struct ib_send_wr *wr = NULL, *last, *next, *bad_wr;
+ struct ib_qp *qp;
+ int i, sg_ind;
+ int is_ud;
+ ssize_t ret = -EINVAL;
+ size_t next_size;
+
+ if (copy_from_user(&cmd, buf, sizeof cmd))
+ return -EFAULT;
+
+ if (in_len < sizeof cmd + cmd.wqe_size * cmd.wr_count +
+ cmd.sge_count * sizeof (struct ib_uverbs_sge))
+ return -EINVAL;
+
+ if (cmd.wqe_size < sizeof (struct ib_uverbs_send_wr))
+ return -EINVAL;
+
+ user_wr = kmalloc(cmd.wqe_size, GFP_KERNEL);
+ if (!user_wr)
+ return -ENOMEM;
+
+ qp = idr_read_qp(cmd.qp_handle, file->ucontext);
+ if (!qp)
+ goto out;
+
+ is_ud = qp->qp_type == IB_QPT_UD;
+ sg_ind = 0;
+ last = NULL;
+ for (i = 0; i < cmd.wr_count; ++i) {
+ if (copy_from_user(user_wr,
+ buf + sizeof cmd + i * cmd.wqe_size,
+ cmd.wqe_size)) {
+ ret = -EFAULT;
+ goto out_put;
+ }
+
+ if (user_wr->num_sge + sg_ind > cmd.sge_count) {
+ ret = -EINVAL;
+ goto out_put;
+ }
+
+ if (is_ud) {
+ struct ib_ud_wr *ud;
+
+ if (user_wr->opcode != IB_WR_SEND &&
+ user_wr->opcode != IB_WR_SEND_WITH_IMM) {
+ ret = -EINVAL;
+ goto out_put;
+ }
+
+ next_size = sizeof(*ud);
+ ud = alloc_wr(next_size, user_wr->num_sge);
+ if (!ud) {
+ ret = -ENOMEM;
+ goto out_put;
+ }
+
+ ud->ah = idr_read_ah(user_wr->wr.ud.ah, file->ucontext);
+ if (!ud->ah) {
+ kfree(ud);
+ ret = -EINVAL;
+ goto out_put;
+ }
+ ud->remote_qpn = user_wr->wr.ud.remote_qpn;
+ ud->remote_qkey = user_wr->wr.ud.remote_qkey;
+
+ next = &ud->wr;
+ } else if (user_wr->opcode == IB_WR_RDMA_WRITE_WITH_IMM ||
+ user_wr->opcode == IB_WR_RDMA_WRITE ||
+ user_wr->opcode == IB_WR_RDMA_READ) {
+ struct ib_rdma_wr *rdma;
+
+ next_size = sizeof(*rdma);
+ rdma = alloc_wr(next_size, user_wr->num_sge);
+ if (!rdma) {
+ ret = -ENOMEM;
+ goto out_put;
+ }
+
+ rdma->remote_addr = user_wr->wr.rdma.remote_addr;
+ rdma->rkey = user_wr->wr.rdma.rkey;
+
+ next = &rdma->wr;
+ } else if (user_wr->opcode == IB_WR_ATOMIC_CMP_AND_SWP ||
+ user_wr->opcode == IB_WR_ATOMIC_FETCH_AND_ADD) {
+ struct ib_atomic_wr *atomic;
+
+ next_size = sizeof(*atomic);
+ atomic = alloc_wr(next_size, user_wr->num_sge);
+ if (!atomic) {
+ ret = -ENOMEM;
+ goto out_put;
+ }
+
+ atomic->remote_addr = user_wr->wr.atomic.remote_addr;
+ atomic->compare_add = user_wr->wr.atomic.compare_add;
+ atomic->swap = user_wr->wr.atomic.swap;
+ atomic->rkey = user_wr->wr.atomic.rkey;
+
+ next = &atomic->wr;
+ } else if (user_wr->opcode == IB_WR_SEND ||
+ user_wr->opcode == IB_WR_SEND_WITH_IMM ||
+ user_wr->opcode == IB_WR_SEND_WITH_INV) {
+ next_size = sizeof(*next);
+ next = alloc_wr(next_size, user_wr->num_sge);
+ if (!next) {
+ ret = -ENOMEM;
+ goto out_put;
+ }
+ } else {
+ ret = -EINVAL;
+ goto out_put;
+ }
+
+ if (user_wr->opcode == IB_WR_SEND_WITH_IMM ||
+ user_wr->opcode == IB_WR_RDMA_WRITE_WITH_IMM) {
+ next->ex.imm_data =
+ (__be32 __force) user_wr->ex.imm_data;
+ } else if (user_wr->opcode == IB_WR_SEND_WITH_INV) {
+ next->ex.invalidate_rkey = user_wr->ex.invalidate_rkey;
+ }
+
+ if (!last)
+ wr = next;
+ else
+ last->next = next;
+ last = next;
+
+ next->next = NULL;
+ next->wr_id = user_wr->wr_id;
+ next->num_sge = user_wr->num_sge;
+ next->opcode = user_wr->opcode;
+ next->send_flags = user_wr->send_flags;
+
+ if (next->num_sge) {
+ next->sg_list = (void *)((char *)next +
+ ALIGN(next_size, sizeof(struct ib_sge)));
+ if (copy_from_user(next->sg_list,
+ (const char *)buf + sizeof cmd +
+ cmd.wr_count * cmd.wqe_size +
+ sg_ind * sizeof (struct ib_sge),
+ next->num_sge * sizeof (struct ib_sge))) {
+ ret = -EFAULT;
+ goto out_put;
+ }
+ sg_ind += next->num_sge;
+ } else
+ next->sg_list = NULL;
+ }
+
+ resp.bad_wr = 0;
+ ret = qp->device->post_send(qp->real_qp, wr, &bad_wr);
+ if (ret)
+ for (next = wr; next; next = next->next) {
+ ++resp.bad_wr;
+ if (next == bad_wr)
+ break;
+ }
+
+ if (copy_to_user((void __user *) (unsigned long) cmd.response,
+ &resp, sizeof resp))
+ ret = -EFAULT;
+
+out_put:
+ put_qp_read(qp);
+
+ while (wr) {
+ if (is_ud && ud_wr(wr)->ah)
+ put_ah_read(ud_wr(wr)->ah);
+ next = wr->next;
+ kfree(wr);
+ wr = next;
+ }
+
+out:
+ kfree(user_wr);
+
+ return ret ? ret : in_len;
+}
+
+static struct ib_recv_wr *ib_uverbs_unmarshall_recv(const char __user *buf,
+ int in_len,
+ u32 wr_count,
+ u32 sge_count,
+ u32 wqe_size)
+{
+ struct ib_uverbs_recv_wr *user_wr;
+ struct ib_recv_wr *wr = NULL, *last, *next;
+ int sg_ind;
+ int i;
+ int ret;
+
+ if (in_len < wqe_size * wr_count +
+ sge_count * sizeof (struct ib_uverbs_sge))
+ return ERR_PTR(-EINVAL);
+
+ if (wqe_size < sizeof (struct ib_uverbs_recv_wr))
+ return ERR_PTR(-EINVAL);
+
+ user_wr = kmalloc(wqe_size, GFP_KERNEL);
+ if (!user_wr)
+ return ERR_PTR(-ENOMEM);
+
+ sg_ind = 0;
+ last = NULL;
+ for (i = 0; i < wr_count; ++i) {
+ if (copy_from_user(user_wr, buf + i * wqe_size,
+ wqe_size)) {
+ ret = -EFAULT;
+ goto err;
+ }
+
+ if (user_wr->num_sge + sg_ind > sge_count) {
+ ret = -EINVAL;
+ goto err;
+ }
+
+ next = kmalloc(ALIGN(sizeof *next, sizeof (struct ib_sge)) +
+ user_wr->num_sge * sizeof (struct ib_sge),
+ GFP_KERNEL);
+ if (!next) {
+ ret = -ENOMEM;
+ goto err;
+ }
+
+ if (!last)
+ wr = next;
+ else
+ last->next = next;
+ last = next;
+
+ next->next = NULL;
+ next->wr_id = user_wr->wr_id;
+ next->num_sge = user_wr->num_sge;
+
+ if (next->num_sge) {
+ next->sg_list = (void *)((char *)next +
+ ALIGN(sizeof *next, sizeof (struct ib_sge)));
+ if (copy_from_user(next->sg_list,
+ (const char *)buf + wr_count * wqe_size +
+ sg_ind * sizeof (struct ib_sge),
+ next->num_sge * sizeof (struct ib_sge))) {
+ ret = -EFAULT;
+ goto err;
+ }
+ sg_ind += next->num_sge;
+ } else
+ next->sg_list = NULL;
+ }
+
+ kfree(user_wr);
+ return wr;
+
+err:
+ kfree(user_wr);
+
+ while (wr) {
+ next = wr->next;
+ kfree(wr);
+ wr = next;
+ }
+
+ return ERR_PTR(ret);
+}
+
+ssize_t ib_uverbs_post_recv(struct ib_uverbs_file *file,
+ struct ib_device *ib_dev,
+ const char __user *buf, int in_len,
+ int out_len)
+{
+ struct ib_uverbs_post_recv cmd;
+ struct ib_uverbs_post_recv_resp resp;
+ struct ib_recv_wr *wr, *next, *bad_wr;
+ struct ib_qp *qp;
+ ssize_t ret = -EINVAL;
+
+ if (copy_from_user(&cmd, buf, sizeof cmd))
+ return -EFAULT;
+
+ wr = ib_uverbs_unmarshall_recv(buf + sizeof cmd,
+ in_len - sizeof cmd, cmd.wr_count,
+ cmd.sge_count, cmd.wqe_size);
+ if (IS_ERR(wr))
+ return PTR_ERR(wr);
+
+ qp = idr_read_qp(cmd.qp_handle, file->ucontext);
+ if (!qp)
+ goto out;
+
+ resp.bad_wr = 0;
+ ret = qp->device->post_recv(qp->real_qp, wr, &bad_wr);
+
+ put_qp_read(qp);
+
+ if (ret)
+ for (next = wr; next; next = next->next) {
+ ++resp.bad_wr;
+ if (next == bad_wr)
+ break;
+ }
+
+ if (copy_to_user((void __user *) (unsigned long) cmd.response,
+ &resp, sizeof resp))
+ ret = -EFAULT;
+
+out:
+ while (wr) {
+ next = wr->next;
+ kfree(wr);
+ wr = next;
+ }
+
+ return ret ? ret : in_len;
+}
+
+ssize_t ib_uverbs_post_srq_recv(struct ib_uverbs_file *file,
+ struct ib_device *ib_dev,
+ const char __user *buf, int in_len,
+ int out_len)
+{
+ struct ib_uverbs_post_srq_recv cmd;
+ struct ib_uverbs_post_srq_recv_resp resp;
+ struct ib_recv_wr *wr, *next, *bad_wr;
+ struct ib_srq *srq;
+ ssize_t ret = -EINVAL;
+
+ if (copy_from_user(&cmd, buf, sizeof cmd))
+ return -EFAULT;
+
+ wr = ib_uverbs_unmarshall_recv(buf + sizeof cmd,
+ in_len - sizeof cmd, cmd.wr_count,
+ cmd.sge_count, cmd.wqe_size);
+ if (IS_ERR(wr))
+ return PTR_ERR(wr);
+
+ srq = idr_read_srq(cmd.srq_handle, file->ucontext);
+ if (!srq)
+ goto out;
+
+ resp.bad_wr = 0;
+ ret = srq->device->post_srq_recv(srq, wr, &bad_wr);
+
+ put_srq_read(srq);
+
+ if (ret)
+ for (next = wr; next; next = next->next) {
+ ++resp.bad_wr;
+ if (next == bad_wr)
+ break;
+ }
+
+ if (copy_to_user((void __user *) (unsigned long) cmd.response,
+ &resp, sizeof resp))
+ ret = -EFAULT;
+
+out:
+ while (wr) {
+ next = wr->next;
+ kfree(wr);
+ wr = next;
+ }
+
+ return ret ? ret : in_len;
+}
+
+ssize_t ib_uverbs_create_ah(struct ib_uverbs_file *file,
+ struct ib_device *ib_dev,
+ const char __user *buf, int in_len,
+ int out_len)
+{
+ struct ib_uverbs_create_ah cmd;
+ struct ib_uverbs_create_ah_resp resp;
+ struct ib_uobject *uobj;
+ struct ib_pd *pd;
+ struct ib_ah *ah;
+ struct ib_ah_attr attr;
+ int ret;
+
+ if (out_len < sizeof resp)
+ return -ENOSPC;
+
+ if (copy_from_user(&cmd, buf, sizeof cmd))
+ return -EFAULT;
+
+ uobj = kmalloc(sizeof *uobj, GFP_KERNEL);
+ if (!uobj)
+ return -ENOMEM;
+
+ init_uobj(uobj, cmd.user_handle, file->ucontext, &ah_lock_class);
+ down_write(&uobj->mutex);
+
+ pd = idr_read_pd(cmd.pd_handle, file->ucontext);
+ if (!pd) {
+ ret = -EINVAL;
+ goto err;
+ }
+
+ attr.dlid = cmd.attr.dlid;
+ attr.sl = cmd.attr.sl;
+ attr.src_path_bits = cmd.attr.src_path_bits;
+ attr.static_rate = cmd.attr.static_rate;
+ attr.ah_flags = cmd.attr.is_global ? IB_AH_GRH : 0;
+ attr.port_num = cmd.attr.port_num;
+ attr.grh.flow_label = cmd.attr.grh.flow_label;
+ attr.grh.sgid_index = cmd.attr.grh.sgid_index;
+ attr.grh.hop_limit = cmd.attr.grh.hop_limit;
+ attr.grh.traffic_class = cmd.attr.grh.traffic_class;
+ memset(&attr.dmac, 0, sizeof(attr.dmac));
+ memcpy(attr.grh.dgid.raw, cmd.attr.grh.dgid, 16);
+
+ ah = ib_create_ah(pd, &attr);
+ if (IS_ERR(ah)) {
+ ret = PTR_ERR(ah);
+ goto err_put;
+ }
+
+ ah->uobject = uobj;
+ uobj->object = ah;
+
+ ret = idr_add_uobj(&ib_uverbs_ah_idr, uobj);
+ if (ret)
+ goto err_destroy;
+
+ resp.ah_handle = uobj->id;
+
+ if (copy_to_user((void __user *) (unsigned long) cmd.response,
+ &resp, sizeof resp)) {
+ ret = -EFAULT;
+ goto err_copy;
+ }
+
+ put_pd_read(pd);
+
+ mutex_lock(&file->mutex);
+ list_add_tail(&uobj->list, &file->ucontext->ah_list);
+ mutex_unlock(&file->mutex);
+
+ uobj->live = 1;
+
+ up_write(&uobj->mutex);
+
+ return in_len;
+
+err_copy:
+ idr_remove_uobj(&ib_uverbs_ah_idr, uobj);
+
+err_destroy:
+ ib_destroy_ah(ah);
+
+err_put:
+ put_pd_read(pd);
+
+err:
+ put_uobj_write(uobj);
+ return ret;
+}
+
+ssize_t ib_uverbs_destroy_ah(struct ib_uverbs_file *file,
+ struct ib_device *ib_dev,
+ const char __user *buf, int in_len, int out_len)
+{
+ struct ib_uverbs_destroy_ah cmd;
+ struct ib_ah *ah;
+ struct ib_uobject *uobj;
+ int ret;
+
+ if (copy_from_user(&cmd, buf, sizeof cmd))
+ return -EFAULT;
+
+ uobj = idr_write_uobj(&ib_uverbs_ah_idr, cmd.ah_handle, file->ucontext);
+ if (!uobj)
+ return -EINVAL;
+ ah = uobj->object;
+
+ ret = ib_destroy_ah(ah);
+ if (!ret)
+ uobj->live = 0;
+
+ put_uobj_write(uobj);
+
+ if (ret)
+ return ret;
+
+ idr_remove_uobj(&ib_uverbs_ah_idr, uobj);
+
+ mutex_lock(&file->mutex);
+ list_del(&uobj->list);
+ mutex_unlock(&file->mutex);
+
+ put_uobj(uobj);
+
+ return in_len;
+}
+
+ssize_t ib_uverbs_attach_mcast(struct ib_uverbs_file *file,
+ struct ib_device *ib_dev,
+ const char __user *buf, int in_len,
+ int out_len)
+{
+ struct ib_uverbs_attach_mcast cmd;
+ struct ib_qp *qp;
+ struct ib_uqp_object *obj;
+ struct ib_uverbs_mcast_entry *mcast;
+ int ret;
+
+ if (copy_from_user(&cmd, buf, sizeof cmd))
+ return -EFAULT;
+
+ qp = idr_write_qp(cmd.qp_handle, file->ucontext);
+ if (!qp)
+ return -EINVAL;
+
+ obj = container_of(qp->uobject, struct ib_uqp_object, uevent.uobject);
+
+ list_for_each_entry(mcast, &obj->mcast_list, list)
+ if (cmd.mlid == mcast->lid &&
+ !memcmp(cmd.gid, mcast->gid.raw, sizeof mcast->gid.raw)) {
+ ret = 0;
+ goto out_put;
+ }
+
+ mcast = kmalloc(sizeof *mcast, GFP_KERNEL);
+ if (!mcast) {
+ ret = -ENOMEM;
+ goto out_put;
+ }
+
+ mcast->lid = cmd.mlid;
+ memcpy(mcast->gid.raw, cmd.gid, sizeof mcast->gid.raw);
+
+ ret = ib_attach_mcast(qp, &mcast->gid, cmd.mlid);
+ if (!ret)
+ list_add_tail(&mcast->list, &obj->mcast_list);
+ else
+ kfree(mcast);
+
+out_put:
+ put_qp_write(qp);
+
+ return ret ? ret : in_len;
+}
+
+ssize_t ib_uverbs_detach_mcast(struct ib_uverbs_file *file,
+ struct ib_device *ib_dev,
+ const char __user *buf, int in_len,
+ int out_len)
+{
+ struct ib_uverbs_detach_mcast cmd;
+ struct ib_uqp_object *obj;
+ struct ib_qp *qp;
+ struct ib_uverbs_mcast_entry *mcast;
+ int ret = -EINVAL;
+
+ if (copy_from_user(&cmd, buf, sizeof cmd))
+ return -EFAULT;
+
+ qp = idr_write_qp(cmd.qp_handle, file->ucontext);
+ if (!qp)
+ return -EINVAL;
+
+ ret = ib_detach_mcast(qp, (union ib_gid *) cmd.gid, cmd.mlid);
+ if (ret)
+ goto out_put;
+
+ obj = container_of(qp->uobject, struct ib_uqp_object, uevent.uobject);
+
+ list_for_each_entry(mcast, &obj->mcast_list, list)
+ if (cmd.mlid == mcast->lid &&
+ !memcmp(cmd.gid, mcast->gid.raw, sizeof mcast->gid.raw)) {
+ list_del(&mcast->list);
+ kfree(mcast);
+ break;
+ }
+
+out_put:
+ put_qp_write(qp);
+
+ return ret ? ret : in_len;
+}
+
+static size_t kern_spec_filter_sz(struct ib_uverbs_flow_spec_hdr *spec)
+{
+ /* Returns user space filter size, includes padding */
+ return (spec->size - sizeof(struct ib_uverbs_flow_spec_hdr)) / 2;
+}
+
+static ssize_t spec_filter_size(void *kern_spec_filter, u16 kern_filter_size,
+ u16 ib_real_filter_sz)
+{
+ /*
+ * User space filter structures must be 64 bit aligned, otherwise this
+ * may pass, but we won't handle additional new attributes.
+ */
+
+ if (kern_filter_size > ib_real_filter_sz) {
+ if (memchr_inv((char *)kern_spec_filter +
+ ib_real_filter_sz, 0,
+ kern_filter_size - ib_real_filter_sz))
+ return -EINVAL;
+ return ib_real_filter_sz;
+ }
+ return kern_filter_size;
+}
+
+static int kern_spec_to_ib_spec(struct ib_uverbs_flow_spec *kern_spec,
+ union ib_flow_spec *ib_spec)
+{
+ ssize_t actual_filter_sz;
+ ssize_t kern_filter_sz;
+ ssize_t ib_filter_sz;
+ void *kern_spec_mask;
+ void *kern_spec_val;
+
+ if (kern_spec->reserved)
+ return -EINVAL;
+
+ ib_spec->type = kern_spec->type;
+
+ kern_filter_sz = kern_spec_filter_sz(&kern_spec->hdr);
+ /* User flow spec size must be aligned to 4 bytes */
+ if (kern_filter_sz != ALIGN(kern_filter_sz, 4))
+ return -EINVAL;
+
+ kern_spec_val = (char *)kern_spec +
+ sizeof(struct ib_uverbs_flow_spec_hdr);
+ kern_spec_mask = (char *)kern_spec_val + kern_filter_sz;
+
+ switch (ib_spec->type) {
+ case IB_FLOW_SPEC_ETH:
+ ib_filter_sz = offsetof(struct ib_flow_eth_filter, real_sz);
+ actual_filter_sz = spec_filter_size(kern_spec_mask,
+ kern_filter_sz,
+ ib_filter_sz);
+ if (actual_filter_sz <= 0)
+ return -EINVAL;
+ ib_spec->size = sizeof(struct ib_flow_spec_eth);
+ memcpy(&ib_spec->eth.val, kern_spec_val, actual_filter_sz);
+ memcpy(&ib_spec->eth.mask, kern_spec_mask, actual_filter_sz);
+ break;
+ case IB_FLOW_SPEC_IPV4:
+ ib_filter_sz = offsetof(struct ib_flow_ipv4_filter, real_sz);
+ actual_filter_sz = spec_filter_size(kern_spec_mask,
+ kern_filter_sz,
+ ib_filter_sz);
+ if (actual_filter_sz <= 0)
+ return -EINVAL;
+ ib_spec->size = sizeof(struct ib_flow_spec_ipv4);
+ memcpy(&ib_spec->ipv4.val, kern_spec_val, actual_filter_sz);
+ memcpy(&ib_spec->ipv4.mask, kern_spec_mask, actual_filter_sz);
+ break;
+ case IB_FLOW_SPEC_IPV6:
+ ib_filter_sz = offsetof(struct ib_flow_ipv6_filter, real_sz);
+ actual_filter_sz = spec_filter_size(kern_spec_mask,
+ kern_filter_sz,
+ ib_filter_sz);
+ if (actual_filter_sz <= 0)
+ return -EINVAL;
+ ib_spec->size = sizeof(struct ib_flow_spec_ipv6);
+ memcpy(&ib_spec->ipv6.val, kern_spec_val, actual_filter_sz);
+ memcpy(&ib_spec->ipv6.mask, kern_spec_mask, actual_filter_sz);
+
+ if ((ntohl(ib_spec->ipv6.mask.flow_label)) >= BIT(20) ||
+ (ntohl(ib_spec->ipv6.val.flow_label)) >= BIT(20))
+ return -EINVAL;
+ break;
+ case IB_FLOW_SPEC_TCP:
+ case IB_FLOW_SPEC_UDP:
+ ib_filter_sz = offsetof(struct ib_flow_tcp_udp_filter, real_sz);
+ actual_filter_sz = spec_filter_size(kern_spec_mask,
+ kern_filter_sz,
+ ib_filter_sz);
+ if (actual_filter_sz <= 0)
+ return -EINVAL;
+ ib_spec->size = sizeof(struct ib_flow_spec_tcp_udp);
+ memcpy(&ib_spec->tcp_udp.val, kern_spec_val, actual_filter_sz);
+ memcpy(&ib_spec->tcp_udp.mask, kern_spec_mask, actual_filter_sz);
+ break;
+ default:
+ return -EINVAL;
+ }
+ return 0;
+}
+
+int ib_uverbs_ex_create_wq(struct ib_uverbs_file *file,
+ struct ib_device *ib_dev,
+ struct ib_udata *ucore,
+ struct ib_udata *uhw)
+{
+ struct ib_uverbs_ex_create_wq cmd = {};
+ struct ib_uverbs_ex_create_wq_resp resp = {};
+ struct ib_uwq_object *obj;
+ int err = 0;
+ struct ib_cq *cq;
+ struct ib_pd *pd;
+ struct ib_wq *wq;
+ struct ib_wq_init_attr wq_init_attr = {};
+ size_t required_cmd_sz;
+ size_t required_resp_len;
+
+ required_cmd_sz = offsetof(typeof(cmd), max_sge) + sizeof(cmd.max_sge);
+ required_resp_len = offsetof(typeof(resp), wqn) + sizeof(resp.wqn);
+
+ if (ucore->inlen < required_cmd_sz)
+ return -EINVAL;
+
+ if (ucore->outlen < required_resp_len)
+ return -ENOSPC;
+
+ if (ucore->inlen > sizeof(cmd) &&
+ !ib_is_udata_cleared(ucore, sizeof(cmd),
+ ucore->inlen - sizeof(cmd)))
+ return -EOPNOTSUPP;
+
+ err = ib_copy_from_udata(&cmd, ucore, min(sizeof(cmd), ucore->inlen));
+ if (err)
+ return err;
+
+ if (cmd.comp_mask)
+ return -EOPNOTSUPP;
+
+ obj = kmalloc(sizeof(*obj), GFP_KERNEL);
+ if (!obj)
+ return -ENOMEM;
+
+ init_uobj(&obj->uevent.uobject, cmd.user_handle, file->ucontext,
+ &wq_lock_class);
+ down_write(&obj->uevent.uobject.mutex);
+ pd = idr_read_pd(cmd.pd_handle, file->ucontext);
+ if (!pd) {
+ err = -EINVAL;
+ goto err_uobj;
+ }
+
+ cq = idr_read_cq(cmd.cq_handle, file->ucontext, 0);
+ if (!cq) {
+ err = -EINVAL;
+ goto err_put_pd;
+ }
+
+ wq_init_attr.cq = cq;
+ wq_init_attr.max_sge = cmd.max_sge;
+ wq_init_attr.max_wr = cmd.max_wr;
+ wq_init_attr.wq_context = file;
+ wq_init_attr.wq_type = cmd.wq_type;
+ wq_init_attr.event_handler = ib_uverbs_wq_event_handler;
+ obj->uevent.events_reported = 0;
+ INIT_LIST_HEAD(&obj->uevent.event_list);
+ wq = pd->device->create_wq(pd, &wq_init_attr, uhw);
+ if (IS_ERR(wq)) {
+ err = PTR_ERR(wq);
+ goto err_put_cq;
+ }
+
+ wq->uobject = &obj->uevent.uobject;
+ obj->uevent.uobject.object = wq;
+ wq->wq_type = wq_init_attr.wq_type;
+ wq->cq = cq;
+ wq->pd = pd;
+ wq->device = pd->device;
+ wq->wq_context = wq_init_attr.wq_context;
+ atomic_set(&wq->usecnt, 0);
+ atomic_inc(&pd->usecnt);
+ atomic_inc(&cq->usecnt);
+ wq->uobject = &obj->uevent.uobject;
+ obj->uevent.uobject.object = wq;
+ err = idr_add_uobj(&ib_uverbs_wq_idr, &obj->uevent.uobject);
+ if (err)
+ goto destroy_wq;
+
+ memset(&resp, 0, sizeof(resp));
+ resp.wq_handle = obj->uevent.uobject.id;
+ resp.max_sge = wq_init_attr.max_sge;
+ resp.max_wr = wq_init_attr.max_wr;
+ resp.wqn = wq->wq_num;
+ resp.response_length = required_resp_len;
+ err = ib_copy_to_udata(ucore,
+ &resp, resp.response_length);
+ if (err)
+ goto err_copy;
+
+ put_pd_read(pd);
+ put_cq_read(cq);
+
+ mutex_lock(&file->mutex);
+ list_add_tail(&obj->uevent.uobject.list, &file->ucontext->wq_list);
+ mutex_unlock(&file->mutex);
+
+ obj->uevent.uobject.live = 1;
+ up_write(&obj->uevent.uobject.mutex);
+ return 0;
+
+err_copy:
+ idr_remove_uobj(&ib_uverbs_wq_idr, &obj->uevent.uobject);
+destroy_wq:
+ ib_destroy_wq(wq);
+err_put_cq:
+ put_cq_read(cq);
+err_put_pd:
+ put_pd_read(pd);
+err_uobj:
+ put_uobj_write(&obj->uevent.uobject);
+
+ return err;
+}
+
+int ib_uverbs_ex_destroy_wq(struct ib_uverbs_file *file,
+ struct ib_device *ib_dev,
+ struct ib_udata *ucore,
+ struct ib_udata *uhw)
+{
+ struct ib_uverbs_ex_destroy_wq cmd = {};
+ struct ib_uverbs_ex_destroy_wq_resp resp = {};
+ struct ib_wq *wq;
+ struct ib_uobject *uobj;
+ struct ib_uwq_object *obj;
+ size_t required_cmd_sz;
+ size_t required_resp_len;
+ int ret;
+
+ required_cmd_sz = offsetof(typeof(cmd), wq_handle) + sizeof(cmd.wq_handle);
+ required_resp_len = offsetof(typeof(resp), reserved) + sizeof(resp.reserved);
+
+ if (ucore->inlen < required_cmd_sz)
+ return -EINVAL;
+
+ if (ucore->outlen < required_resp_len)
+ return -ENOSPC;
+
+ if (ucore->inlen > sizeof(cmd) &&
+ !ib_is_udata_cleared(ucore, sizeof(cmd),
+ ucore->inlen - sizeof(cmd)))
+ return -EOPNOTSUPP;
+
+ ret = ib_copy_from_udata(&cmd, ucore, min(sizeof(cmd), ucore->inlen));
+ if (ret)
+ return ret;
+
+ if (cmd.comp_mask)
+ return -EOPNOTSUPP;
+
+ resp.response_length = required_resp_len;
+ uobj = idr_write_uobj(&ib_uverbs_wq_idr, cmd.wq_handle,
+ file->ucontext);
+ if (!uobj)
+ return -EINVAL;
+
+ wq = uobj->object;
+ obj = container_of(uobj, struct ib_uwq_object, uevent.uobject);
+ ret = ib_destroy_wq(wq);
+ if (!ret)
+ uobj->live = 0;
+
+ put_uobj_write(uobj);
+ if (ret)
+ return ret;
+
+ idr_remove_uobj(&ib_uverbs_wq_idr, uobj);
+
+ mutex_lock(&file->mutex);
+ list_del(&uobj->list);
+ mutex_unlock(&file->mutex);
+
+ ib_uverbs_release_uevent(file, &obj->uevent);
+ resp.events_reported = obj->uevent.events_reported;
+ put_uobj(uobj);
+
+ ret = ib_copy_to_udata(ucore, &resp, resp.response_length);
+ if (ret)
+ return ret;
+
+ return 0;
+}
+
+int ib_uverbs_ex_modify_wq(struct ib_uverbs_file *file,
+ struct ib_device *ib_dev,
+ struct ib_udata *ucore,
+ struct ib_udata *uhw)
+{
+ struct ib_uverbs_ex_modify_wq cmd = {};
+ struct ib_wq *wq;
+ struct ib_wq_attr wq_attr = {};
+ size_t required_cmd_sz;
+ int ret;
+
+ required_cmd_sz = offsetof(typeof(cmd), curr_wq_state) + sizeof(cmd.curr_wq_state);
+ if (ucore->inlen < required_cmd_sz)
+ return -EINVAL;
+
+ if (ucore->inlen > sizeof(cmd) &&
+ !ib_is_udata_cleared(ucore, sizeof(cmd),
+ ucore->inlen - sizeof(cmd)))
+ return -EOPNOTSUPP;
+
+ ret = ib_copy_from_udata(&cmd, ucore, min(sizeof(cmd), ucore->inlen));
+ if (ret)
+ return ret;
+
+ if (!cmd.attr_mask)
+ return -EINVAL;
+
+ if (cmd.attr_mask > (IB_WQ_STATE | IB_WQ_CUR_STATE))
+ return -EINVAL;
+
+ wq = idr_read_wq(cmd.wq_handle, file->ucontext);
+ if (!wq)
+ return -EINVAL;
+
+ wq_attr.curr_wq_state = cmd.curr_wq_state;
+ wq_attr.wq_state = cmd.wq_state;
+ ret = wq->device->modify_wq(wq, &wq_attr, cmd.attr_mask, uhw);
+ put_wq_read(wq);
+ return ret;
+}
+
+int ib_uverbs_ex_create_rwq_ind_table(struct ib_uverbs_file *file,
+ struct ib_device *ib_dev,
+ struct ib_udata *ucore,
+ struct ib_udata *uhw)
+{
+ struct ib_uverbs_ex_create_rwq_ind_table cmd = {};
+ struct ib_uverbs_ex_create_rwq_ind_table_resp resp = {};
+ struct ib_uobject *uobj;
+ int err = 0;
+ struct ib_rwq_ind_table_init_attr init_attr = {};
+ struct ib_rwq_ind_table *rwq_ind_tbl;
+ struct ib_wq **wqs = NULL;
+ u32 *wqs_handles = NULL;
+ struct ib_wq *wq = NULL;
+ int i, j, num_read_wqs;
+ u32 num_wq_handles;
+ u32 expected_in_size;
+ size_t required_cmd_sz_header;
+ size_t required_resp_len;
+
+ required_cmd_sz_header = offsetof(typeof(cmd), log_ind_tbl_size) + sizeof(cmd.log_ind_tbl_size);
+ required_resp_len = offsetof(typeof(resp), ind_tbl_num) + sizeof(resp.ind_tbl_num);
+
+ if (ucore->inlen < required_cmd_sz_header)
+ return -EINVAL;
+
+ if (ucore->outlen < required_resp_len)
+ return -ENOSPC;
+
+ err = ib_copy_from_udata(&cmd, ucore, required_cmd_sz_header);
+ if (err)
+ return err;
+
+ ucore->inbuf = (const char *)ucore->inbuf + required_cmd_sz_header;
+ ucore->inlen -= required_cmd_sz_header;
+
+ if (cmd.comp_mask)
+ return -EOPNOTSUPP;
+
+ if (cmd.log_ind_tbl_size > IB_USER_VERBS_MAX_LOG_IND_TBL_SIZE)
+ return -EINVAL;
+
+ num_wq_handles = 1 << cmd.log_ind_tbl_size;
+ expected_in_size = num_wq_handles * sizeof(__u32);
+ if (num_wq_handles == 1)
+ /* input size for wq handles is u64 aligned */
+ expected_in_size += sizeof(__u32);
+
+ if (ucore->inlen < expected_in_size)
+ return -EINVAL;
+
+ if (ucore->inlen > expected_in_size &&
+ !ib_is_udata_cleared(ucore, expected_in_size,
+ ucore->inlen - expected_in_size))
+ return -EOPNOTSUPP;
+
+ wqs_handles = kcalloc(num_wq_handles, sizeof(*wqs_handles),
+ GFP_KERNEL);
+ if (!wqs_handles)
+ return -ENOMEM;
+
+ err = ib_copy_from_udata(wqs_handles, ucore,
+ num_wq_handles * sizeof(__u32));
+ if (err)
+ goto err_free;
+
+ wqs = kcalloc(num_wq_handles, sizeof(*wqs), GFP_KERNEL);
+ if (!wqs) {
+ err = -ENOMEM;
+ goto err_free;
+ }
+
+ for (num_read_wqs = 0; num_read_wqs < num_wq_handles;
+ num_read_wqs++) {
+ wq = idr_read_wq(wqs_handles[num_read_wqs], file->ucontext);
+ if (!wq) {
+ err = -EINVAL;
+ goto put_wqs;
+ }
+
+ wqs[num_read_wqs] = wq;
+ }
+
+ uobj = kmalloc(sizeof(*uobj), GFP_KERNEL);
+ if (!uobj) {
+ err = -ENOMEM;
+ goto put_wqs;
+ }
+
+ init_uobj(uobj, 0, file->ucontext, &rwq_ind_table_lock_class);
+ down_write(&uobj->mutex);
+ init_attr.log_ind_tbl_size = cmd.log_ind_tbl_size;
+ init_attr.ind_tbl = wqs;
+ rwq_ind_tbl = ib_dev->create_rwq_ind_table(ib_dev, &init_attr, uhw);
+
+ if (IS_ERR(rwq_ind_tbl)) {
+ err = PTR_ERR(rwq_ind_tbl);
+ goto err_uobj;
+ }
+
+ rwq_ind_tbl->ind_tbl = wqs;
+ rwq_ind_tbl->log_ind_tbl_size = init_attr.log_ind_tbl_size;
+ rwq_ind_tbl->uobject = uobj;
+ uobj->object = rwq_ind_tbl;
+ rwq_ind_tbl->device = ib_dev;
+ atomic_set(&rwq_ind_tbl->usecnt, 0);
+
+ for (i = 0; i < num_wq_handles; i++)
+ atomic_inc(&wqs[i]->usecnt);
+
+ err = idr_add_uobj(&ib_uverbs_rwq_ind_tbl_idr, uobj);
+ if (err)
+ goto destroy_ind_tbl;
+
+ resp.ind_tbl_handle = uobj->id;
+ resp.ind_tbl_num = rwq_ind_tbl->ind_tbl_num;
+ resp.response_length = required_resp_len;
+
+ err = ib_copy_to_udata(ucore,
+ &resp, resp.response_length);
+ if (err)
+ goto err_copy;
+
+ kfree(wqs_handles);
+
+ for (j = 0; j < num_read_wqs; j++)
+ put_wq_read(wqs[j]);
+
+ mutex_lock(&file->mutex);
+ list_add_tail(&uobj->list, &file->ucontext->rwq_ind_tbl_list);
+ mutex_unlock(&file->mutex);
+
+ uobj->live = 1;
+
+ up_write(&uobj->mutex);
+ return 0;
+
+err_copy:
+ idr_remove_uobj(&ib_uverbs_rwq_ind_tbl_idr, uobj);
+destroy_ind_tbl:
+ ib_destroy_rwq_ind_table(rwq_ind_tbl);
+err_uobj:
+ put_uobj_write(uobj);
+put_wqs:
+ for (j = 0; j < num_read_wqs; j++)
+ put_wq_read(wqs[j]);
+err_free:
+ kfree(wqs_handles);
+ kfree(wqs);
+ return err;
+}
+
+int ib_uverbs_ex_destroy_rwq_ind_table(struct ib_uverbs_file *file,
+ struct ib_device *ib_dev,
+ struct ib_udata *ucore,
+ struct ib_udata *uhw)
+{
+ struct ib_uverbs_ex_destroy_rwq_ind_table cmd = {};
+ struct ib_rwq_ind_table *rwq_ind_tbl;
+ struct ib_uobject *uobj;
+ int ret;
+ struct ib_wq **ind_tbl;
+ size_t required_cmd_sz;
+
+ required_cmd_sz = offsetof(typeof(cmd), ind_tbl_handle) + sizeof(cmd.ind_tbl_handle);
+
+ if (ucore->inlen < required_cmd_sz)
+ return -EINVAL;
+
+ if (ucore->inlen > sizeof(cmd) &&
+ !ib_is_udata_cleared(ucore, sizeof(cmd),
+ ucore->inlen - sizeof(cmd)))
+ return -EOPNOTSUPP;
+
+ ret = ib_copy_from_udata(&cmd, ucore, min(sizeof(cmd), ucore->inlen));
+ if (ret)
+ return ret;
+
+ if (cmd.comp_mask)
+ return -EOPNOTSUPP;
+
+ uobj = idr_write_uobj(&ib_uverbs_rwq_ind_tbl_idr, cmd.ind_tbl_handle,
+ file->ucontext);
+ if (!uobj)
+ return -EINVAL;
+ rwq_ind_tbl = uobj->object;
+ ind_tbl = rwq_ind_tbl->ind_tbl;
+
+ ret = ib_destroy_rwq_ind_table(rwq_ind_tbl);
+ if (!ret)
+ uobj->live = 0;
+
+ put_uobj_write(uobj);
+
+ if (ret)
+ return ret;
+
+ idr_remove_uobj(&ib_uverbs_rwq_ind_tbl_idr, uobj);
+
+ mutex_lock(&file->mutex);
+ list_del(&uobj->list);
+ mutex_unlock(&file->mutex);
+
+ put_uobj(uobj);
+ kfree(ind_tbl);
+ return ret;
+}
+
+int ib_uverbs_ex_create_flow(struct ib_uverbs_file *file,
+ struct ib_device *ib_dev,
+ struct ib_udata *ucore,
+ struct ib_udata *uhw)
+{
+ struct ib_uverbs_create_flow cmd;
+ struct ib_uverbs_create_flow_resp resp;
+ struct ib_uobject *uobj;
+ struct ib_flow *flow_id;
+ struct ib_uverbs_flow_attr *kern_flow_attr;
+ struct ib_flow_attr *flow_attr;
+ struct ib_qp *qp;
+ int err = 0;
+ void *kern_spec;
+ void *ib_spec;
+ int i;
+
+ if (ucore->inlen < sizeof(cmd))
+ return -EINVAL;
+
+ if (ucore->outlen < sizeof(resp))
+ return -ENOSPC;
+
+ err = ib_copy_from_udata(&cmd, ucore, sizeof(cmd));
+ if (err)
+ return err;
+
+ ucore->inbuf = (const char *)ucore->inbuf + sizeof(cmd);
+ ucore->inlen -= sizeof(cmd);
+
+ if (cmd.comp_mask)
+ return -EINVAL;
+
+ if (priv_check(curthread, PRIV_NET_RAW) != 0)
+ return -EPERM;
+
+ if (cmd.flow_attr.flags >= IB_FLOW_ATTR_FLAGS_RESERVED)
+ return -EINVAL;
+
+ if ((cmd.flow_attr.flags & IB_FLOW_ATTR_FLAGS_DONT_TRAP) &&
+ ((cmd.flow_attr.type == IB_FLOW_ATTR_ALL_DEFAULT) ||
+ (cmd.flow_attr.type == IB_FLOW_ATTR_MC_DEFAULT)))
+ return -EINVAL;
+
+ if (cmd.flow_attr.num_of_specs > IB_FLOW_SPEC_SUPPORT_LAYERS)
+ return -EINVAL;
+
+ if (cmd.flow_attr.size > ucore->inlen ||
+ cmd.flow_attr.size >
+ (cmd.flow_attr.num_of_specs * sizeof(struct ib_uverbs_flow_spec)))
+ return -EINVAL;
+
+ if (cmd.flow_attr.reserved[0] ||
+ cmd.flow_attr.reserved[1])
+ return -EINVAL;
+
+ if (cmd.flow_attr.num_of_specs) {
+ kern_flow_attr = kmalloc(sizeof(*kern_flow_attr) + cmd.flow_attr.size,
+ GFP_KERNEL);
+ if (!kern_flow_attr)
+ return -ENOMEM;
+
+ memcpy(kern_flow_attr, &cmd.flow_attr, sizeof(*kern_flow_attr));
+ err = ib_copy_from_udata(kern_flow_attr + 1, ucore,
+ cmd.flow_attr.size);
+ if (err)
+ goto err_free_attr;
+ } else {
+ kern_flow_attr = &cmd.flow_attr;
+ }
+
+ uobj = kmalloc(sizeof(*uobj), GFP_KERNEL);
+ if (!uobj) {
+ err = -ENOMEM;
+ goto err_free_attr;
+ }
+ init_uobj(uobj, 0, file->ucontext, &rule_lock_class);
+ down_write(&uobj->mutex);
+
+ qp = idr_read_qp(cmd.qp_handle, file->ucontext);
+ if (!qp) {
+ err = -EINVAL;
+ goto err_uobj;
+ }
+
+ flow_attr = kzalloc(sizeof(*flow_attr) + cmd.flow_attr.num_of_specs *
+ sizeof(union ib_flow_spec), GFP_KERNEL);
+ if (!flow_attr) {
+ err = -ENOMEM;
+ goto err_put;
+ }
+
+ flow_attr->type = kern_flow_attr->type;
+ flow_attr->priority = kern_flow_attr->priority;
+ flow_attr->num_of_specs = kern_flow_attr->num_of_specs;
+ flow_attr->port = kern_flow_attr->port;
+ flow_attr->flags = kern_flow_attr->flags;
+ flow_attr->size = sizeof(*flow_attr);
+
+ kern_spec = kern_flow_attr + 1;
+ ib_spec = flow_attr + 1;
+ for (i = 0; i < flow_attr->num_of_specs &&
+ cmd.flow_attr.size > offsetof(struct ib_uverbs_flow_spec, reserved) &&
+ cmd.flow_attr.size >=
+ ((struct ib_uverbs_flow_spec *)kern_spec)->size; i++) {
+ err = kern_spec_to_ib_spec(kern_spec, ib_spec);
+ if (err)
+ goto err_free;
+ flow_attr->size +=
+ ((union ib_flow_spec *) ib_spec)->size;
+ cmd.flow_attr.size -= ((struct ib_uverbs_flow_spec *)kern_spec)->size;
+ kern_spec = (char *)kern_spec + ((struct ib_uverbs_flow_spec *) kern_spec)->size;
+ ib_spec = (char *)ib_spec + ((union ib_flow_spec *)ib_spec)->size;
+ }
+ if (cmd.flow_attr.size || (i != flow_attr->num_of_specs)) {
+ pr_warn("create flow failed, flow %d: %d bytes left from uverb cmd\n",
+ i, cmd.flow_attr.size);
+ err = -EINVAL;
+ goto err_free;
+ }
+ flow_id = ib_create_flow(qp, flow_attr, IB_FLOW_DOMAIN_USER);
+ if (IS_ERR(flow_id)) {
+ err = PTR_ERR(flow_id);
+ goto err_free;
+ }
+ flow_id->qp = qp;
+ flow_id->uobject = uobj;
+ uobj->object = flow_id;
+
+ err = idr_add_uobj(&ib_uverbs_rule_idr, uobj);
+ if (err)
+ goto destroy_flow;
+
+ memset(&resp, 0, sizeof(resp));
+ resp.flow_handle = uobj->id;
+
+ err = ib_copy_to_udata(ucore,
+ &resp, sizeof(resp));
+ if (err)
+ goto err_copy;
+
+ put_qp_read(qp);
+ mutex_lock(&file->mutex);
+ list_add_tail(&uobj->list, &file->ucontext->rule_list);
+ mutex_unlock(&file->mutex);
+
+ uobj->live = 1;
+
+ up_write(&uobj->mutex);
+ kfree(flow_attr);
+ if (cmd.flow_attr.num_of_specs)
+ kfree(kern_flow_attr);
+ return 0;
+err_copy:
+ idr_remove_uobj(&ib_uverbs_rule_idr, uobj);
+destroy_flow:
+ ib_destroy_flow(flow_id);
+err_free:
+ kfree(flow_attr);
+err_put:
+ put_qp_read(qp);
+err_uobj:
+ put_uobj_write(uobj);
+err_free_attr:
+ if (cmd.flow_attr.num_of_specs)
+ kfree(kern_flow_attr);
+ return err;
+}
+
+int ib_uverbs_ex_destroy_flow(struct ib_uverbs_file *file,
+ struct ib_device *ib_dev,
+ struct ib_udata *ucore,
+ struct ib_udata *uhw)
+{
+ struct ib_uverbs_destroy_flow cmd;
+ struct ib_flow *flow_id;
+ struct ib_uobject *uobj;
+ int ret;
+
+ if (ucore->inlen < sizeof(cmd))
+ return -EINVAL;
+
+ ret = ib_copy_from_udata(&cmd, ucore, sizeof(cmd));
+ if (ret)
+ return ret;
+
+ if (cmd.comp_mask)
+ return -EINVAL;
+
+ uobj = idr_write_uobj(&ib_uverbs_rule_idr, cmd.flow_handle,
+ file->ucontext);
+ if (!uobj)
+ return -EINVAL;
+ flow_id = uobj->object;
+
+ ret = ib_destroy_flow(flow_id);
+ if (!ret)
+ uobj->live = 0;
+
+ put_uobj_write(uobj);
+
+ idr_remove_uobj(&ib_uverbs_rule_idr, uobj);
+
+ mutex_lock(&file->mutex);
+ list_del(&uobj->list);
+ mutex_unlock(&file->mutex);
+
+ put_uobj(uobj);
+
+ return ret;
+}
+
+static int __uverbs_create_xsrq(struct ib_uverbs_file *file,
+ struct ib_device *ib_dev,
+ struct ib_uverbs_create_xsrq *cmd,
+ struct ib_udata *udata)
+{
+ struct ib_uverbs_create_srq_resp resp;
+ struct ib_usrq_object *obj;
+ struct ib_pd *pd;
+ struct ib_srq *srq;
+ struct ib_uobject *uninitialized_var(xrcd_uobj);
+ struct ib_srq_init_attr attr;
+ int ret;
+
+ obj = kmalloc(sizeof *obj, GFP_KERNEL);
+ if (!obj)
+ return -ENOMEM;
+
+ init_uobj(&obj->uevent.uobject, cmd->user_handle, file->ucontext, &srq_lock_class);
+ down_write(&obj->uevent.uobject.mutex);
+
+ if (cmd->srq_type == IB_SRQT_XRC) {
+ attr.ext.xrc.xrcd = idr_read_xrcd(cmd->xrcd_handle, file->ucontext, &xrcd_uobj);
+ if (!attr.ext.xrc.xrcd) {
+ ret = -EINVAL;
+ goto err;
+ }
+
+ obj->uxrcd = container_of(xrcd_uobj, struct ib_uxrcd_object, uobject);
+ atomic_inc(&obj->uxrcd->refcnt);
+
+ attr.ext.xrc.cq = idr_read_cq(cmd->cq_handle, file->ucontext, 0);
+ if (!attr.ext.xrc.cq) {
+ ret = -EINVAL;
+ goto err_put_xrcd;
+ }
+ }
+
+ pd = idr_read_pd(cmd->pd_handle, file->ucontext);
+ if (!pd) {
+ ret = -EINVAL;
+ goto err_put_cq;
+ }
+
+ attr.event_handler = ib_uverbs_srq_event_handler;
+ attr.srq_context = file;
+ attr.srq_type = cmd->srq_type;
+ attr.attr.max_wr = cmd->max_wr;
+ attr.attr.max_sge = cmd->max_sge;
+ attr.attr.srq_limit = cmd->srq_limit;
+
+ obj->uevent.events_reported = 0;
+ INIT_LIST_HEAD(&obj->uevent.event_list);
+
+ srq = pd->device->create_srq(pd, &attr, udata);
+ if (IS_ERR(srq)) {
+ ret = PTR_ERR(srq);
+ goto err_put;
+ }
+
+ srq->device = pd->device;
+ srq->pd = pd;
+ srq->srq_type = cmd->srq_type;
+ srq->uobject = &obj->uevent.uobject;
+ srq->event_handler = attr.event_handler;
+ srq->srq_context = attr.srq_context;
+
+ if (cmd->srq_type == IB_SRQT_XRC) {
+ srq->ext.xrc.cq = attr.ext.xrc.cq;
+ srq->ext.xrc.xrcd = attr.ext.xrc.xrcd;
+ atomic_inc(&attr.ext.xrc.cq->usecnt);
+ atomic_inc(&attr.ext.xrc.xrcd->usecnt);
+ }
+
+ atomic_inc(&pd->usecnt);
+ atomic_set(&srq->usecnt, 0);
+
+ obj->uevent.uobject.object = srq;
+ ret = idr_add_uobj(&ib_uverbs_srq_idr, &obj->uevent.uobject);
+ if (ret)
+ goto err_destroy;
+
+ memset(&resp, 0, sizeof resp);
+ resp.srq_handle = obj->uevent.uobject.id;
+ resp.max_wr = attr.attr.max_wr;
+ resp.max_sge = attr.attr.max_sge;
+ if (cmd->srq_type == IB_SRQT_XRC)
+ resp.srqn = srq->ext.xrc.srq_num;
+
+ if (copy_to_user((void __user *) (unsigned long) cmd->response,
+ &resp, sizeof resp)) {
+ ret = -EFAULT;
+ goto err_copy;
+ }
+
+ if (cmd->srq_type == IB_SRQT_XRC) {
+ put_uobj_read(xrcd_uobj);
+ put_cq_read(attr.ext.xrc.cq);
+ }
+ put_pd_read(pd);
+
+ mutex_lock(&file->mutex);
+ list_add_tail(&obj->uevent.uobject.list, &file->ucontext->srq_list);
+ mutex_unlock(&file->mutex);
+
+ obj->uevent.uobject.live = 1;
+
+ up_write(&obj->uevent.uobject.mutex);
+
+ return 0;
+
+err_copy:
+ idr_remove_uobj(&ib_uverbs_srq_idr, &obj->uevent.uobject);
+
+err_destroy:
+ ib_destroy_srq(srq);
+
+err_put:
+ put_pd_read(pd);
+
+err_put_cq:
+ if (cmd->srq_type == IB_SRQT_XRC)
+ put_cq_read(attr.ext.xrc.cq);
+
+err_put_xrcd:
+ if (cmd->srq_type == IB_SRQT_XRC) {
+ atomic_dec(&obj->uxrcd->refcnt);
+ put_uobj_read(xrcd_uobj);
+ }
+
+err:
+ put_uobj_write(&obj->uevent.uobject);
+ return ret;
+}
+
+ssize_t ib_uverbs_create_srq(struct ib_uverbs_file *file,
+ struct ib_device *ib_dev,
+ const char __user *buf, int in_len,
+ int out_len)
+{
+ struct ib_uverbs_create_srq cmd;
+ struct ib_uverbs_create_xsrq xcmd;
+ struct ib_uverbs_create_srq_resp resp;
+ struct ib_udata udata;
+ int ret;
+
+ if (out_len < sizeof resp)
+ return -ENOSPC;
+
+ if (copy_from_user(&cmd, buf, sizeof cmd))
+ return -EFAULT;
+
+ xcmd.response = cmd.response;
+ xcmd.user_handle = cmd.user_handle;
+ xcmd.srq_type = IB_SRQT_BASIC;
+ xcmd.pd_handle = cmd.pd_handle;
+ xcmd.max_wr = cmd.max_wr;
+ xcmd.max_sge = cmd.max_sge;
+ xcmd.srq_limit = cmd.srq_limit;
+
+ INIT_UDATA(&udata, buf + sizeof cmd,
+ (unsigned long) cmd.response + sizeof resp,
+ in_len - sizeof cmd - sizeof(struct ib_uverbs_cmd_hdr),
+ out_len - sizeof resp);
+
+ ret = __uverbs_create_xsrq(file, ib_dev, &xcmd, &udata);
+ if (ret)
+ return ret;
+
+ return in_len;
+}
+
+ssize_t ib_uverbs_create_xsrq(struct ib_uverbs_file *file,
+ struct ib_device *ib_dev,
+ const char __user *buf, int in_len, int out_len)
+{
+ struct ib_uverbs_create_xsrq cmd;
+ struct ib_uverbs_create_srq_resp resp;
+ struct ib_udata udata;
+ int ret;
+
+ if (out_len < sizeof resp)
+ return -ENOSPC;
+
+ if (copy_from_user(&cmd, buf, sizeof cmd))
+ return -EFAULT;
+
+ INIT_UDATA(&udata, buf + sizeof cmd,
+ (unsigned long) cmd.response + sizeof resp,
+ in_len - sizeof cmd - sizeof(struct ib_uverbs_cmd_hdr),
+ out_len - sizeof resp);
+
+ ret = __uverbs_create_xsrq(file, ib_dev, &cmd, &udata);
+ if (ret)
+ return ret;
+
+ return in_len;
+}
+
+ssize_t ib_uverbs_modify_srq(struct ib_uverbs_file *file,
+ struct ib_device *ib_dev,
+ const char __user *buf, int in_len,
+ int out_len)
+{
+ struct ib_uverbs_modify_srq cmd;
+ struct ib_udata udata;
+ struct ib_srq *srq;
+ struct ib_srq_attr attr;
+ int ret;
+
+ if (copy_from_user(&cmd, buf, sizeof cmd))
+ return -EFAULT;
+
+ INIT_UDATA(&udata, buf + sizeof cmd, NULL, in_len - sizeof cmd,
+ out_len);
+
+ srq = idr_read_srq(cmd.srq_handle, file->ucontext);
+ if (!srq)
+ return -EINVAL;
+
+ attr.max_wr = cmd.max_wr;
+ attr.srq_limit = cmd.srq_limit;
+
+ ret = srq->device->modify_srq(srq, &attr, cmd.attr_mask, &udata);
+
+ put_srq_read(srq);
+
+ return ret ? ret : in_len;
+}
+
+ssize_t ib_uverbs_query_srq(struct ib_uverbs_file *file,
+ struct ib_device *ib_dev,
+ const char __user *buf,
+ int in_len, int out_len)
+{
+ struct ib_uverbs_query_srq cmd;
+ struct ib_uverbs_query_srq_resp resp;
+ struct ib_srq_attr attr;
+ struct ib_srq *srq;
+ int ret;
+
+ if (out_len < sizeof resp)
+ return -ENOSPC;
+
+ if (copy_from_user(&cmd, buf, sizeof cmd))
+ return -EFAULT;
+
+ srq = idr_read_srq(cmd.srq_handle, file->ucontext);
+ if (!srq)
+ return -EINVAL;
+
+ ret = ib_query_srq(srq, &attr);
+
+ put_srq_read(srq);
+
+ if (ret)
+ return ret;
+
+ memset(&resp, 0, sizeof resp);
+
+ resp.max_wr = attr.max_wr;
+ resp.max_sge = attr.max_sge;
+ resp.srq_limit = attr.srq_limit;
+
+ if (copy_to_user((void __user *) (unsigned long) cmd.response,
+ &resp, sizeof resp))
+ return -EFAULT;
+
+ return in_len;
+}
+
+ssize_t ib_uverbs_destroy_srq(struct ib_uverbs_file *file,
+ struct ib_device *ib_dev,
+ const char __user *buf, int in_len,
+ int out_len)
+{
+ struct ib_uverbs_destroy_srq cmd;
+ struct ib_uverbs_destroy_srq_resp resp;
+ struct ib_uobject *uobj;
+ struct ib_srq *srq;
+ struct ib_uevent_object *obj;
+ int ret = -EINVAL;
+ struct ib_usrq_object *us;
+ enum ib_srq_type srq_type;
+
+ if (copy_from_user(&cmd, buf, sizeof cmd))
+ return -EFAULT;
+
+ uobj = idr_write_uobj(&ib_uverbs_srq_idr, cmd.srq_handle, file->ucontext);
+ if (!uobj)
+ return -EINVAL;
+ srq = uobj->object;
+ obj = container_of(uobj, struct ib_uevent_object, uobject);
+ srq_type = srq->srq_type;
+
+ ret = ib_destroy_srq(srq);
+ if (!ret)
+ uobj->live = 0;
+
+ put_uobj_write(uobj);
+
+ if (ret)
+ return ret;
+
+ if (srq_type == IB_SRQT_XRC) {
+ us = container_of(obj, struct ib_usrq_object, uevent);
+ atomic_dec(&us->uxrcd->refcnt);
+ }
+
+ idr_remove_uobj(&ib_uverbs_srq_idr, uobj);
+
+ mutex_lock(&file->mutex);
+ list_del(&uobj->list);
+ mutex_unlock(&file->mutex);
+
+ ib_uverbs_release_uevent(file, obj);
+
+ memset(&resp, 0, sizeof resp);
+ resp.events_reported = obj->events_reported;
+
+ put_uobj(uobj);
+
+ if (copy_to_user((void __user *) (unsigned long) cmd.response,
+ &resp, sizeof resp))
+ ret = -EFAULT;
+
+ return ret ? ret : in_len;
+}
+
+int ib_uverbs_ex_query_device(struct ib_uverbs_file *file,
+ struct ib_device *ib_dev,
+ struct ib_udata *ucore,
+ struct ib_udata *uhw)
+{
+ struct ib_uverbs_ex_query_device_resp resp = { {0} };
+ struct ib_uverbs_ex_query_device cmd;
+ struct ib_device_attr attr = {0};
+ int err;
+
+ if (ucore->inlen < sizeof(cmd))
+ return -EINVAL;
+
+ err = ib_copy_from_udata(&cmd, ucore, sizeof(cmd));
+ if (err)
+ return err;
+
+ if (cmd.comp_mask)
+ return -EINVAL;
+
+ if (cmd.reserved)
+ return -EINVAL;
+
+ resp.response_length = offsetof(typeof(resp), odp_caps);
+
+ if (ucore->outlen < resp.response_length)
+ return -ENOSPC;
+
+ err = ib_dev->query_device(ib_dev, &attr, uhw);
+ if (err)
+ return err;
+
+ copy_query_dev_fields(file, ib_dev, &resp.base, &attr);
+
+ if (ucore->outlen < resp.response_length + sizeof(resp.odp_caps))
+ goto end;
+
+#ifdef CONFIG_INFINIBAND_ON_DEMAND_PAGING
+ resp.odp_caps.general_caps = attr.odp_caps.general_caps;
+ resp.odp_caps.per_transport_caps.rc_odp_caps =
+ attr.odp_caps.per_transport_caps.rc_odp_caps;
+ resp.odp_caps.per_transport_caps.uc_odp_caps =
+ attr.odp_caps.per_transport_caps.uc_odp_caps;
+ resp.odp_caps.per_transport_caps.ud_odp_caps =
+ attr.odp_caps.per_transport_caps.ud_odp_caps;
+#endif
+ resp.response_length += sizeof(resp.odp_caps);
+
+ if (ucore->outlen < resp.response_length + sizeof(resp.timestamp_mask))
+ goto end;
+
+ resp.timestamp_mask = attr.timestamp_mask;
+ resp.response_length += sizeof(resp.timestamp_mask);
+
+ if (ucore->outlen < resp.response_length + sizeof(resp.hca_core_clock))
+ goto end;
+
+ resp.hca_core_clock = attr.hca_core_clock;
+ resp.response_length += sizeof(resp.hca_core_clock);
+
+ if (ucore->outlen < resp.response_length + sizeof(resp.device_cap_flags_ex))
+ goto end;
+
+ resp.device_cap_flags_ex = attr.device_cap_flags;
+ resp.response_length += sizeof(resp.device_cap_flags_ex);
+
+ if (ucore->outlen < resp.response_length + sizeof(resp.rss_caps))
+ goto end;
+
+ resp.rss_caps.supported_qpts = attr.rss_caps.supported_qpts;
+ resp.rss_caps.max_rwq_indirection_tables =
+ attr.rss_caps.max_rwq_indirection_tables;
+ resp.rss_caps.max_rwq_indirection_table_size =
+ attr.rss_caps.max_rwq_indirection_table_size;
+
+ resp.response_length += sizeof(resp.rss_caps);
+
+ if (ucore->outlen < resp.response_length + sizeof(resp.max_wq_type_rq))
+ goto end;
+
+ resp.max_wq_type_rq = attr.max_wq_type_rq;
+ resp.response_length += sizeof(resp.max_wq_type_rq);
+end:
+ err = ib_copy_to_udata(ucore, &resp, resp.response_length);
+ return err;
+}
diff --git a/sys/ofed/drivers/infiniband/core/ib_uverbs_main.c b/sys/ofed/drivers/infiniband/core/ib_uverbs_main.c
new file mode 100644
index 0000000..331a3c9
--- /dev/null
+++ b/sys/ofed/drivers/infiniband/core/ib_uverbs_main.c
@@ -0,0 +1,1430 @@
+/*
+ * Copyright (c) 2005 Topspin Communications. All rights reserved.
+ * Copyright (c) 2005, 2006 Cisco Systems. All rights reserved.
+ * Copyright (c) 2005 Mellanox Technologies. All rights reserved.
+ * Copyright (c) 2005 Voltaire, Inc. All rights reserved.
+ * Copyright (c) 2005 PathScale, Inc. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#include <linux/module.h>
+#include <linux/device.h>
+#include <linux/err.h>
+#include <linux/fs.h>
+#include <linux/poll.h>
+#include <linux/sched.h>
+#include <linux/file.h>
+#include <linux/cdev.h>
+#include <linux/slab.h>
+#include <linux/pci.h>
+
+#include <asm/uaccess.h>
+
+#include <rdma/ib.h>
+
+#include "uverbs.h"
+
+MODULE_AUTHOR("Roland Dreier");
+MODULE_DESCRIPTION("InfiniBand userspace verbs access");
+MODULE_LICENSE("Dual BSD/GPL");
+
+enum {
+ IB_UVERBS_MAJOR = 231,
+ IB_UVERBS_BASE_MINOR = 192,
+ IB_UVERBS_MAX_DEVICES = 32
+};
+
+#define IB_UVERBS_BASE_DEV MKDEV(IB_UVERBS_MAJOR, IB_UVERBS_BASE_MINOR)
+
+static struct class *uverbs_class;
+
+DEFINE_SPINLOCK(ib_uverbs_idr_lock);
+DEFINE_IDR(ib_uverbs_pd_idr);
+DEFINE_IDR(ib_uverbs_mr_idr);
+DEFINE_IDR(ib_uverbs_mw_idr);
+DEFINE_IDR(ib_uverbs_ah_idr);
+DEFINE_IDR(ib_uverbs_cq_idr);
+DEFINE_IDR(ib_uverbs_qp_idr);
+DEFINE_IDR(ib_uverbs_srq_idr);
+DEFINE_IDR(ib_uverbs_xrcd_idr);
+DEFINE_IDR(ib_uverbs_rule_idr);
+DEFINE_IDR(ib_uverbs_wq_idr);
+DEFINE_IDR(ib_uverbs_rwq_ind_tbl_idr);
+
+static DEFINE_SPINLOCK(map_lock);
+static DECLARE_BITMAP(dev_map, IB_UVERBS_MAX_DEVICES);
+
+static ssize_t (*uverbs_cmd_table[])(struct ib_uverbs_file *file,
+ struct ib_device *ib_dev,
+ const char __user *buf, int in_len,
+ int out_len) = {
+ [IB_USER_VERBS_CMD_GET_CONTEXT] = ib_uverbs_get_context,
+ [IB_USER_VERBS_CMD_QUERY_DEVICE] = ib_uverbs_query_device,
+ [IB_USER_VERBS_CMD_QUERY_PORT] = ib_uverbs_query_port,
+ [IB_USER_VERBS_CMD_ALLOC_PD] = ib_uverbs_alloc_pd,
+ [IB_USER_VERBS_CMD_DEALLOC_PD] = ib_uverbs_dealloc_pd,
+ [IB_USER_VERBS_CMD_REG_MR] = ib_uverbs_reg_mr,
+ [IB_USER_VERBS_CMD_REREG_MR] = ib_uverbs_rereg_mr,
+ [IB_USER_VERBS_CMD_DEREG_MR] = ib_uverbs_dereg_mr,
+ [IB_USER_VERBS_CMD_ALLOC_MW] = ib_uverbs_alloc_mw,
+ [IB_USER_VERBS_CMD_DEALLOC_MW] = ib_uverbs_dealloc_mw,
+ [IB_USER_VERBS_CMD_CREATE_COMP_CHANNEL] = ib_uverbs_create_comp_channel,
+ [IB_USER_VERBS_CMD_CREATE_CQ] = ib_uverbs_create_cq,
+ [IB_USER_VERBS_CMD_RESIZE_CQ] = ib_uverbs_resize_cq,
+ [IB_USER_VERBS_CMD_POLL_CQ] = ib_uverbs_poll_cq,
+ [IB_USER_VERBS_CMD_REQ_NOTIFY_CQ] = ib_uverbs_req_notify_cq,
+ [IB_USER_VERBS_CMD_DESTROY_CQ] = ib_uverbs_destroy_cq,
+ [IB_USER_VERBS_CMD_CREATE_QP] = ib_uverbs_create_qp,
+ [IB_USER_VERBS_CMD_QUERY_QP] = ib_uverbs_query_qp,
+ [IB_USER_VERBS_CMD_MODIFY_QP] = ib_uverbs_modify_qp,
+ [IB_USER_VERBS_CMD_DESTROY_QP] = ib_uverbs_destroy_qp,
+ [IB_USER_VERBS_CMD_POST_SEND] = ib_uverbs_post_send,
+ [IB_USER_VERBS_CMD_POST_RECV] = ib_uverbs_post_recv,
+ [IB_USER_VERBS_CMD_POST_SRQ_RECV] = ib_uverbs_post_srq_recv,
+ [IB_USER_VERBS_CMD_CREATE_AH] = ib_uverbs_create_ah,
+ [IB_USER_VERBS_CMD_DESTROY_AH] = ib_uverbs_destroy_ah,
+ [IB_USER_VERBS_CMD_ATTACH_MCAST] = ib_uverbs_attach_mcast,
+ [IB_USER_VERBS_CMD_DETACH_MCAST] = ib_uverbs_detach_mcast,
+ [IB_USER_VERBS_CMD_CREATE_SRQ] = ib_uverbs_create_srq,
+ [IB_USER_VERBS_CMD_MODIFY_SRQ] = ib_uverbs_modify_srq,
+ [IB_USER_VERBS_CMD_QUERY_SRQ] = ib_uverbs_query_srq,
+ [IB_USER_VERBS_CMD_DESTROY_SRQ] = ib_uverbs_destroy_srq,
+ [IB_USER_VERBS_CMD_OPEN_XRCD] = ib_uverbs_open_xrcd,
+ [IB_USER_VERBS_CMD_CLOSE_XRCD] = ib_uverbs_close_xrcd,
+ [IB_USER_VERBS_CMD_CREATE_XSRQ] = ib_uverbs_create_xsrq,
+ [IB_USER_VERBS_CMD_OPEN_QP] = ib_uverbs_open_qp,
+};
+
+static int (*uverbs_ex_cmd_table[])(struct ib_uverbs_file *file,
+ struct ib_device *ib_dev,
+ struct ib_udata *ucore,
+ struct ib_udata *uhw) = {
+ [IB_USER_VERBS_EX_CMD_CREATE_FLOW] = ib_uverbs_ex_create_flow,
+ [IB_USER_VERBS_EX_CMD_DESTROY_FLOW] = ib_uverbs_ex_destroy_flow,
+ [IB_USER_VERBS_EX_CMD_QUERY_DEVICE] = ib_uverbs_ex_query_device,
+ [IB_USER_VERBS_EX_CMD_CREATE_CQ] = ib_uverbs_ex_create_cq,
+ [IB_USER_VERBS_EX_CMD_CREATE_QP] = ib_uverbs_ex_create_qp,
+ [IB_USER_VERBS_EX_CMD_CREATE_WQ] = ib_uverbs_ex_create_wq,
+ [IB_USER_VERBS_EX_CMD_MODIFY_WQ] = ib_uverbs_ex_modify_wq,
+ [IB_USER_VERBS_EX_CMD_DESTROY_WQ] = ib_uverbs_ex_destroy_wq,
+ [IB_USER_VERBS_EX_CMD_CREATE_RWQ_IND_TBL] = ib_uverbs_ex_create_rwq_ind_table,
+ [IB_USER_VERBS_EX_CMD_DESTROY_RWQ_IND_TBL] = ib_uverbs_ex_destroy_rwq_ind_table,
+};
+
+static void ib_uverbs_add_one(struct ib_device *device);
+static void ib_uverbs_remove_one(struct ib_device *device, void *client_data);
+
+int uverbs_dealloc_mw(struct ib_mw *mw)
+{
+ struct ib_pd *pd = mw->pd;
+ int ret;
+
+ ret = mw->device->dealloc_mw(mw);
+ if (!ret)
+ atomic_dec(&pd->usecnt);
+ return ret;
+}
+
+static void ib_uverbs_release_dev(struct kobject *kobj)
+{
+ struct ib_uverbs_device *dev =
+ container_of(kobj, struct ib_uverbs_device, kobj);
+
+ cleanup_srcu_struct(&dev->disassociate_srcu);
+ kfree(dev);
+}
+
+static struct kobj_type ib_uverbs_dev_ktype = {
+ .release = ib_uverbs_release_dev,
+};
+
+static void ib_uverbs_release_event_file(struct kref *ref)
+{
+ struct ib_uverbs_event_file *file =
+ container_of(ref, struct ib_uverbs_event_file, ref);
+
+ kfree(file);
+}
+
+void ib_uverbs_release_ucq(struct ib_uverbs_file *file,
+ struct ib_uverbs_event_file *ev_file,
+ struct ib_ucq_object *uobj)
+{
+ struct ib_uverbs_event *evt, *tmp;
+
+ if (ev_file) {
+ spin_lock_irq(&ev_file->lock);
+ list_for_each_entry_safe(evt, tmp, &uobj->comp_list, obj_list) {
+ list_del(&evt->list);
+ kfree(evt);
+ }
+ spin_unlock_irq(&ev_file->lock);
+
+ kref_put(&ev_file->ref, ib_uverbs_release_event_file);
+ }
+
+ spin_lock_irq(&file->async_file->lock);
+ list_for_each_entry_safe(evt, tmp, &uobj->async_list, obj_list) {
+ list_del(&evt->list);
+ kfree(evt);
+ }
+ spin_unlock_irq(&file->async_file->lock);
+}
+
+void ib_uverbs_release_uevent(struct ib_uverbs_file *file,
+ struct ib_uevent_object *uobj)
+{
+ struct ib_uverbs_event *evt, *tmp;
+
+ spin_lock_irq(&file->async_file->lock);
+ list_for_each_entry_safe(evt, tmp, &uobj->event_list, obj_list) {
+ list_del(&evt->list);
+ kfree(evt);
+ }
+ spin_unlock_irq(&file->async_file->lock);
+}
+
+static void ib_uverbs_detach_umcast(struct ib_qp *qp,
+ struct ib_uqp_object *uobj)
+{
+ struct ib_uverbs_mcast_entry *mcast, *tmp;
+
+ list_for_each_entry_safe(mcast, tmp, &uobj->mcast_list, list) {
+ ib_detach_mcast(qp, &mcast->gid, mcast->lid);
+ list_del(&mcast->list);
+ kfree(mcast);
+ }
+}
+
+static int ib_uverbs_cleanup_ucontext(struct ib_uverbs_file *file,
+ struct ib_ucontext *context)
+{
+ struct ib_uobject *uobj, *tmp;
+
+ context->closing = 1;
+
+ list_for_each_entry_safe(uobj, tmp, &context->ah_list, list) {
+ struct ib_ah *ah = uobj->object;
+
+ idr_remove_uobj(&ib_uverbs_ah_idr, uobj);
+ ib_destroy_ah(ah);
+ kfree(uobj);
+ }
+
+ /* Remove MWs before QPs, in order to support type 2A MWs. */
+ list_for_each_entry_safe(uobj, tmp, &context->mw_list, list) {
+ struct ib_mw *mw = uobj->object;
+
+ idr_remove_uobj(&ib_uverbs_mw_idr, uobj);
+ uverbs_dealloc_mw(mw);
+ kfree(uobj);
+ }
+
+ list_for_each_entry_safe(uobj, tmp, &context->rule_list, list) {
+ struct ib_flow *flow_id = uobj->object;
+
+ idr_remove_uobj(&ib_uverbs_rule_idr, uobj);
+ ib_destroy_flow(flow_id);
+ kfree(uobj);
+ }
+
+ list_for_each_entry_safe(uobj, tmp, &context->qp_list, list) {
+ struct ib_qp *qp = uobj->object;
+ struct ib_uqp_object *uqp =
+ container_of(uobj, struct ib_uqp_object, uevent.uobject);
+
+ idr_remove_uobj(&ib_uverbs_qp_idr, uobj);
+ if (qp == qp->real_qp)
+ ib_uverbs_detach_umcast(qp, uqp);
+ ib_destroy_qp(qp);
+ ib_uverbs_release_uevent(file, &uqp->uevent);
+ kfree(uqp);
+ }
+
+ list_for_each_entry_safe(uobj, tmp, &context->rwq_ind_tbl_list, list) {
+ struct ib_rwq_ind_table *rwq_ind_tbl = uobj->object;
+ struct ib_wq **ind_tbl = rwq_ind_tbl->ind_tbl;
+
+ idr_remove_uobj(&ib_uverbs_rwq_ind_tbl_idr, uobj);
+ ib_destroy_rwq_ind_table(rwq_ind_tbl);
+ kfree(ind_tbl);
+ kfree(uobj);
+ }
+
+ list_for_each_entry_safe(uobj, tmp, &context->wq_list, list) {
+ struct ib_wq *wq = uobj->object;
+ struct ib_uwq_object *uwq =
+ container_of(uobj, struct ib_uwq_object, uevent.uobject);
+
+ idr_remove_uobj(&ib_uverbs_wq_idr, uobj);
+ ib_destroy_wq(wq);
+ ib_uverbs_release_uevent(file, &uwq->uevent);
+ kfree(uwq);
+ }
+
+ list_for_each_entry_safe(uobj, tmp, &context->srq_list, list) {
+ struct ib_srq *srq = uobj->object;
+ struct ib_uevent_object *uevent =
+ container_of(uobj, struct ib_uevent_object, uobject);
+
+ idr_remove_uobj(&ib_uverbs_srq_idr, uobj);
+ ib_destroy_srq(srq);
+ ib_uverbs_release_uevent(file, uevent);
+ kfree(uevent);
+ }
+
+ list_for_each_entry_safe(uobj, tmp, &context->cq_list, list) {
+ struct ib_cq *cq = uobj->object;
+ struct ib_uverbs_event_file *ev_file = cq->cq_context;
+ struct ib_ucq_object *ucq =
+ container_of(uobj, struct ib_ucq_object, uobject);
+
+ idr_remove_uobj(&ib_uverbs_cq_idr, uobj);
+ ib_destroy_cq(cq);
+ ib_uverbs_release_ucq(file, ev_file, ucq);
+ kfree(ucq);
+ }
+
+ list_for_each_entry_safe(uobj, tmp, &context->mr_list, list) {
+ struct ib_mr *mr = uobj->object;
+
+ idr_remove_uobj(&ib_uverbs_mr_idr, uobj);
+ ib_dereg_mr(mr);
+ kfree(uobj);
+ }
+
+ mutex_lock(&file->device->xrcd_tree_mutex);
+ list_for_each_entry_safe(uobj, tmp, &context->xrcd_list, list) {
+ struct ib_xrcd *xrcd = uobj->object;
+ struct ib_uxrcd_object *uxrcd =
+ container_of(uobj, struct ib_uxrcd_object, uobject);
+
+ idr_remove_uobj(&ib_uverbs_xrcd_idr, uobj);
+ ib_uverbs_dealloc_xrcd(file->device, xrcd);
+ kfree(uxrcd);
+ }
+ mutex_unlock(&file->device->xrcd_tree_mutex);
+
+ list_for_each_entry_safe(uobj, tmp, &context->pd_list, list) {
+ struct ib_pd *pd = uobj->object;
+
+ idr_remove_uobj(&ib_uverbs_pd_idr, uobj);
+ ib_dealloc_pd(pd);
+ kfree(uobj);
+ }
+
+ put_pid(context->tgid);
+
+ return context->device->dealloc_ucontext(context);
+}
+
+static void ib_uverbs_comp_dev(struct ib_uverbs_device *dev)
+{
+ complete(&dev->comp);
+}
+
+static void ib_uverbs_release_file(struct kref *ref)
+{
+ struct ib_uverbs_file *file =
+ container_of(ref, struct ib_uverbs_file, ref);
+ struct ib_device *ib_dev;
+ int srcu_key;
+
+ srcu_key = srcu_read_lock(&file->device->disassociate_srcu);
+ ib_dev = srcu_dereference(file->device->ib_dev,
+ &file->device->disassociate_srcu);
+ if (ib_dev && !ib_dev->disassociate_ucontext)
+ module_put(ib_dev->owner);
+ srcu_read_unlock(&file->device->disassociate_srcu, srcu_key);
+
+ if (atomic_dec_and_test(&file->device->refcount))
+ ib_uverbs_comp_dev(file->device);
+
+ kfree(file);
+}
+
+static ssize_t ib_uverbs_event_read(struct file *filp, char __user *buf,
+ size_t count, loff_t *pos)
+{
+ struct ib_uverbs_event_file *file = filp->private_data;
+ struct ib_uverbs_event *event;
+ int eventsz;
+ int ret = 0;
+
+ spin_lock_irq(&file->lock);
+
+ while (list_empty(&file->event_list)) {
+ spin_unlock_irq(&file->lock);
+
+ if (filp->f_flags & O_NONBLOCK)
+ return -EAGAIN;
+
+ if (wait_event_interruptible(file->poll_wait,
+ (!list_empty(&file->event_list) ||
+ /* The barriers built into wait_event_interruptible()
+ * and wake_up() guarentee this will see the null set
+ * without using RCU
+ */
+ !file->uverbs_file->device->ib_dev)))
+ return -ERESTARTSYS;
+
+ /* If device was disassociated and no event exists set an error */
+ if (list_empty(&file->event_list) &&
+ !file->uverbs_file->device->ib_dev)
+ return -EIO;
+
+ spin_lock_irq(&file->lock);
+ }
+
+ event = list_entry(file->event_list.next, struct ib_uverbs_event, list);
+
+ if (file->is_async)
+ eventsz = sizeof (struct ib_uverbs_async_event_desc);
+ else
+ eventsz = sizeof (struct ib_uverbs_comp_event_desc);
+
+ if (eventsz > count) {
+ ret = -EINVAL;
+ event = NULL;
+ } else {
+ list_del(file->event_list.next);
+ if (event->counter) {
+ ++(*event->counter);
+ list_del(&event->obj_list);
+ }
+ }
+
+ spin_unlock_irq(&file->lock);
+
+ if (event) {
+ if (copy_to_user(buf, event, eventsz))
+ ret = -EFAULT;
+ else
+ ret = eventsz;
+ }
+
+ kfree(event);
+
+ return ret;
+}
+
+static unsigned int ib_uverbs_event_poll(struct file *filp,
+ struct poll_table_struct *wait)
+{
+ unsigned int pollflags = 0;
+ struct ib_uverbs_event_file *file = filp->private_data;
+
+ poll_wait(filp, &file->poll_wait, wait);
+
+ spin_lock_irq(&file->lock);
+ if (!list_empty(&file->event_list))
+ pollflags = POLLIN | POLLRDNORM;
+ spin_unlock_irq(&file->lock);
+
+ return pollflags;
+}
+
+static int ib_uverbs_event_fasync(int fd, struct file *filp, int on)
+{
+ struct ib_uverbs_event_file *file = filp->private_data;
+
+ return fasync_helper(fd, filp, on, &file->async_queue);
+}
+
+static int ib_uverbs_event_close(struct inode *inode, struct file *filp)
+{
+ struct ib_uverbs_event_file *file = filp->private_data;
+ struct ib_uverbs_event *entry, *tmp;
+ int closed_already = 0;
+
+ mutex_lock(&file->uverbs_file->device->lists_mutex);
+ spin_lock_irq(&file->lock);
+ closed_already = file->is_closed;
+ file->is_closed = 1;
+ list_for_each_entry_safe(entry, tmp, &file->event_list, list) {
+ if (entry->counter)
+ list_del(&entry->obj_list);
+ kfree(entry);
+ }
+ spin_unlock_irq(&file->lock);
+ if (!closed_already) {
+ list_del(&file->list);
+ if (file->is_async)
+ ib_unregister_event_handler(&file->uverbs_file->
+ event_handler);
+ }
+ mutex_unlock(&file->uverbs_file->device->lists_mutex);
+
+ kref_put(&file->uverbs_file->ref, ib_uverbs_release_file);
+ kref_put(&file->ref, ib_uverbs_release_event_file);
+
+ return 0;
+}
+
+static const struct file_operations uverbs_event_fops = {
+ .owner = THIS_MODULE,
+ .read = ib_uverbs_event_read,
+ .poll = ib_uverbs_event_poll,
+ .release = ib_uverbs_event_close,
+ .fasync = ib_uverbs_event_fasync,
+ .llseek = no_llseek,
+};
+
+void ib_uverbs_comp_handler(struct ib_cq *cq, void *cq_context)
+{
+ struct ib_uverbs_event_file *file = cq_context;
+ struct ib_ucq_object *uobj;
+ struct ib_uverbs_event *entry;
+ unsigned long flags;
+
+ if (!file)
+ return;
+
+ spin_lock_irqsave(&file->lock, flags);
+ if (file->is_closed) {
+ spin_unlock_irqrestore(&file->lock, flags);
+ return;
+ }
+
+ entry = kmalloc(sizeof *entry, GFP_ATOMIC);
+ if (!entry) {
+ spin_unlock_irqrestore(&file->lock, flags);
+ return;
+ }
+
+ uobj = container_of(cq->uobject, struct ib_ucq_object, uobject);
+
+ entry->desc.comp.cq_handle = cq->uobject->user_handle;
+ entry->counter = &uobj->comp_events_reported;
+
+ list_add_tail(&entry->list, &file->event_list);
+ list_add_tail(&entry->obj_list, &uobj->comp_list);
+ spin_unlock_irqrestore(&file->lock, flags);
+
+ wake_up_interruptible(&file->poll_wait);
+ kill_fasync(&file->async_queue, SIGIO, POLL_IN);
+}
+
+static void ib_uverbs_async_handler(struct ib_uverbs_file *file,
+ __u64 element, __u64 event,
+ struct list_head *obj_list,
+ u32 *counter)
+{
+ struct ib_uverbs_event *entry;
+ unsigned long flags;
+
+ spin_lock_irqsave(&file->async_file->lock, flags);
+ if (file->async_file->is_closed) {
+ spin_unlock_irqrestore(&file->async_file->lock, flags);
+ return;
+ }
+
+ entry = kmalloc(sizeof *entry, GFP_ATOMIC);
+ if (!entry) {
+ spin_unlock_irqrestore(&file->async_file->lock, flags);
+ return;
+ }
+
+ entry->desc.async.element = element;
+ entry->desc.async.event_type = event;
+ entry->desc.async.reserved = 0;
+ entry->counter = counter;
+
+ list_add_tail(&entry->list, &file->async_file->event_list);
+ if (obj_list)
+ list_add_tail(&entry->obj_list, obj_list);
+ spin_unlock_irqrestore(&file->async_file->lock, flags);
+
+ wake_up_interruptible(&file->async_file->poll_wait);
+ kill_fasync(&file->async_file->async_queue, SIGIO, POLL_IN);
+}
+
+void ib_uverbs_cq_event_handler(struct ib_event *event, void *context_ptr)
+{
+ struct ib_ucq_object *uobj = container_of(event->element.cq->uobject,
+ struct ib_ucq_object, uobject);
+
+ ib_uverbs_async_handler(uobj->uverbs_file, uobj->uobject.user_handle,
+ event->event, &uobj->async_list,
+ &uobj->async_events_reported);
+}
+
+void ib_uverbs_qp_event_handler(struct ib_event *event, void *context_ptr)
+{
+ struct ib_uevent_object *uobj;
+
+ /* for XRC target qp's, check that qp is live */
+ if (!event->element.qp->uobject || !event->element.qp->uobject->live)
+ return;
+
+ uobj = container_of(event->element.qp->uobject,
+ struct ib_uevent_object, uobject);
+
+ ib_uverbs_async_handler(context_ptr, uobj->uobject.user_handle,
+ event->event, &uobj->event_list,
+ &uobj->events_reported);
+}
+
+void ib_uverbs_wq_event_handler(struct ib_event *event, void *context_ptr)
+{
+ struct ib_uevent_object *uobj = container_of(event->element.wq->uobject,
+ struct ib_uevent_object, uobject);
+
+ ib_uverbs_async_handler(context_ptr, uobj->uobject.user_handle,
+ event->event, &uobj->event_list,
+ &uobj->events_reported);
+}
+
+void ib_uverbs_srq_event_handler(struct ib_event *event, void *context_ptr)
+{
+ struct ib_uevent_object *uobj;
+
+ uobj = container_of(event->element.srq->uobject,
+ struct ib_uevent_object, uobject);
+
+ ib_uverbs_async_handler(context_ptr, uobj->uobject.user_handle,
+ event->event, &uobj->event_list,
+ &uobj->events_reported);
+}
+
+void ib_uverbs_event_handler(struct ib_event_handler *handler,
+ struct ib_event *event)
+{
+ struct ib_uverbs_file *file =
+ container_of(handler, struct ib_uverbs_file, event_handler);
+
+ ib_uverbs_async_handler(file, event->element.port_num, event->event,
+ NULL, NULL);
+}
+
+void ib_uverbs_free_async_event_file(struct ib_uverbs_file *file)
+{
+ kref_put(&file->async_file->ref, ib_uverbs_release_event_file);
+ file->async_file = NULL;
+}
+
+struct file *ib_uverbs_alloc_event_file(struct ib_uverbs_file *uverbs_file,
+ struct ib_device *ib_dev,
+ int is_async)
+{
+ struct ib_uverbs_event_file *ev_file;
+ struct file *filp;
+ int ret;
+
+ ev_file = kzalloc(sizeof(*ev_file), GFP_KERNEL);
+ if (!ev_file)
+ return ERR_PTR(-ENOMEM);
+
+ kref_init(&ev_file->ref);
+ spin_lock_init(&ev_file->lock);
+ INIT_LIST_HEAD(&ev_file->event_list);
+ init_waitqueue_head(&ev_file->poll_wait);
+ ev_file->uverbs_file = uverbs_file;
+ kref_get(&ev_file->uverbs_file->ref);
+ ev_file->async_queue = NULL;
+ ev_file->is_closed = 0;
+
+ /*
+ * fops_get() can't fail here, because we're coming from a
+ * system call on a uverbs file, which will already have a
+ * module reference.
+ */
+ filp = alloc_file(FMODE_READ, fops_get(&uverbs_event_fops));
+ if (IS_ERR(filp))
+ goto err_put_refs;
+ filp->private_data = ev_file;
+
+ mutex_lock(&uverbs_file->device->lists_mutex);
+ list_add_tail(&ev_file->list,
+ &uverbs_file->device->uverbs_events_file_list);
+ mutex_unlock(&uverbs_file->device->lists_mutex);
+
+ if (is_async) {
+ WARN_ON(uverbs_file->async_file);
+ uverbs_file->async_file = ev_file;
+ kref_get(&uverbs_file->async_file->ref);
+ INIT_IB_EVENT_HANDLER(&uverbs_file->event_handler,
+ ib_dev,
+ ib_uverbs_event_handler);
+ ret = ib_register_event_handler(&uverbs_file->event_handler);
+ if (ret)
+ goto err_put_file;
+
+ /* At that point async file stuff was fully set */
+ ev_file->is_async = 1;
+ }
+
+ return filp;
+
+err_put_file:
+ fput(filp);
+ kref_put(&uverbs_file->async_file->ref, ib_uverbs_release_event_file);
+ uverbs_file->async_file = NULL;
+ return ERR_PTR(ret);
+
+err_put_refs:
+ kref_put(&ev_file->uverbs_file->ref, ib_uverbs_release_file);
+ kref_put(&ev_file->ref, ib_uverbs_release_event_file);
+ return filp;
+}
+
+/*
+ * Look up a completion event file by FD. If lookup is successful,
+ * takes a ref to the event file struct that it returns; if
+ * unsuccessful, returns NULL.
+ */
+struct ib_uverbs_event_file *ib_uverbs_lookup_comp_file(int fd)
+{
+ struct ib_uverbs_event_file *ev_file = NULL;
+ struct fd f = fdget(fd);
+
+ if (!f.file)
+ return NULL;
+
+ if (f.file->f_op != &uverbs_event_fops)
+ goto out;
+
+ ev_file = f.file->private_data;
+ if (ev_file->is_async) {
+ ev_file = NULL;
+ goto out;
+ }
+
+ kref_get(&ev_file->ref);
+
+out:
+ fdput(f);
+ return ev_file;
+}
+
+static int verify_command_mask(struct ib_device *ib_dev, __u32 command)
+{
+ u64 mask;
+
+ if (command <= IB_USER_VERBS_CMD_OPEN_QP)
+ mask = ib_dev->uverbs_cmd_mask;
+ else
+ mask = ib_dev->uverbs_ex_cmd_mask;
+
+ if (mask & ((u64)1 << command))
+ return 0;
+
+ return -1;
+}
+
+static ssize_t ib_uverbs_write(struct file *filp, const char __user *buf,
+ size_t count, loff_t *pos)
+{
+ struct ib_uverbs_file *file = filp->private_data;
+ struct ib_device *ib_dev;
+ struct ib_uverbs_cmd_hdr hdr;
+ __u32 command;
+ __u32 flags;
+ int srcu_key;
+ ssize_t ret;
+
+ if (WARN_ON_ONCE(!ib_safe_file_access(filp)))
+ return -EACCES;
+
+ if (count < sizeof hdr)
+ return -EINVAL;
+
+ if (copy_from_user(&hdr, buf, sizeof hdr))
+ return -EFAULT;
+
+ srcu_key = srcu_read_lock(&file->device->disassociate_srcu);
+ ib_dev = srcu_dereference(file->device->ib_dev,
+ &file->device->disassociate_srcu);
+ if (!ib_dev) {
+ ret = -EIO;
+ goto out;
+ }
+
+ if (hdr.command & ~(__u32)(IB_USER_VERBS_CMD_FLAGS_MASK |
+ IB_USER_VERBS_CMD_COMMAND_MASK)) {
+ ret = -EINVAL;
+ goto out;
+ }
+
+ command = hdr.command & IB_USER_VERBS_CMD_COMMAND_MASK;
+ if (verify_command_mask(ib_dev, command)) {
+ ret = -EOPNOTSUPP;
+ goto out;
+ }
+
+ if (!file->ucontext &&
+ command != IB_USER_VERBS_CMD_GET_CONTEXT) {
+ ret = -EINVAL;
+ goto out;
+ }
+
+ flags = (hdr.command &
+ IB_USER_VERBS_CMD_FLAGS_MASK) >> IB_USER_VERBS_CMD_FLAGS_SHIFT;
+
+ if (!flags) {
+ if (command >= ARRAY_SIZE(uverbs_cmd_table) ||
+ !uverbs_cmd_table[command]) {
+ ret = -EINVAL;
+ goto out;
+ }
+
+ if (hdr.in_words * 4 != count) {
+ ret = -EINVAL;
+ goto out;
+ }
+
+ ret = uverbs_cmd_table[command](file, ib_dev,
+ buf + sizeof(hdr),
+ hdr.in_words * 4,
+ hdr.out_words * 4);
+
+ } else if (flags == IB_USER_VERBS_CMD_FLAG_EXTENDED) {
+ struct ib_uverbs_ex_cmd_hdr ex_hdr;
+ struct ib_udata ucore;
+ struct ib_udata uhw;
+ size_t written_count = count;
+
+ if (command >= ARRAY_SIZE(uverbs_ex_cmd_table) ||
+ !uverbs_ex_cmd_table[command]) {
+ ret = -ENOSYS;
+ goto out;
+ }
+
+ if (!file->ucontext) {
+ ret = -EINVAL;
+ goto out;
+ }
+
+ if (count < (sizeof(hdr) + sizeof(ex_hdr))) {
+ ret = -EINVAL;
+ goto out;
+ }
+
+ if (copy_from_user(&ex_hdr, buf + sizeof(hdr), sizeof(ex_hdr))) {
+ ret = -EFAULT;
+ goto out;
+ }
+
+ count -= sizeof(hdr) + sizeof(ex_hdr);
+ buf += sizeof(hdr) + sizeof(ex_hdr);
+
+ if ((hdr.in_words + ex_hdr.provider_in_words) * 8 != count) {
+ ret = -EINVAL;
+ goto out;
+ }
+
+ if (ex_hdr.cmd_hdr_reserved) {
+ ret = -EINVAL;
+ goto out;
+ }
+
+ if (ex_hdr.response) {
+ if (!hdr.out_words && !ex_hdr.provider_out_words) {
+ ret = -EINVAL;
+ goto out;
+ }
+
+ if (!access_ok(VERIFY_WRITE,
+ (void __user *) (unsigned long) ex_hdr.response,
+ (hdr.out_words + ex_hdr.provider_out_words) * 8)) {
+ ret = -EFAULT;
+ goto out;
+ }
+ } else {
+ if (hdr.out_words || ex_hdr.provider_out_words) {
+ ret = -EINVAL;
+ goto out;
+ }
+ }
+
+ INIT_UDATA_BUF_OR_NULL(&ucore, buf, (unsigned long) ex_hdr.response,
+ hdr.in_words * 8, hdr.out_words * 8);
+
+ INIT_UDATA_BUF_OR_NULL(&uhw,
+ buf + ucore.inlen,
+ (unsigned long) ex_hdr.response + ucore.outlen,
+ ex_hdr.provider_in_words * 8,
+ ex_hdr.provider_out_words * 8);
+
+ ret = uverbs_ex_cmd_table[command](file,
+ ib_dev,
+ &ucore,
+ &uhw);
+ if (!ret)
+ ret = written_count;
+ } else {
+ ret = -ENOSYS;
+ }
+
+out:
+ srcu_read_unlock(&file->device->disassociate_srcu, srcu_key);
+ return ret;
+}
+
+static int ib_uverbs_mmap(struct file *filp, struct vm_area_struct *vma)
+{
+ struct ib_uverbs_file *file = filp->private_data;
+ struct ib_device *ib_dev;
+ int ret = 0;
+ int srcu_key;
+
+ srcu_key = srcu_read_lock(&file->device->disassociate_srcu);
+ ib_dev = srcu_dereference(file->device->ib_dev,
+ &file->device->disassociate_srcu);
+ if (!ib_dev) {
+ ret = -EIO;
+ goto out;
+ }
+
+ if (!file->ucontext)
+ ret = -ENODEV;
+ else
+ ret = ib_dev->mmap(file->ucontext, vma);
+out:
+ srcu_read_unlock(&file->device->disassociate_srcu, srcu_key);
+ return ret;
+}
+
+/*
+ * ib_uverbs_open() does not need the BKL:
+ *
+ * - the ib_uverbs_device structures are properly reference counted and
+ * everything else is purely local to the file being created, so
+ * races against other open calls are not a problem;
+ * - there is no ioctl method to race against;
+ * - the open method will either immediately run -ENXIO, or all
+ * required initialization will be done.
+ */
+static int ib_uverbs_open(struct inode *inode, struct file *filp)
+{
+ struct ib_uverbs_device *dev;
+ struct ib_uverbs_file *file;
+ struct ib_device *ib_dev;
+ int ret;
+ int module_dependent;
+ int srcu_key;
+
+ dev = container_of(inode->i_cdev->si_drv1, struct ib_uverbs_device, cdev);
+ if (!atomic_inc_not_zero(&dev->refcount))
+ return -ENXIO;
+
+ srcu_key = srcu_read_lock(&dev->disassociate_srcu);
+ mutex_lock(&dev->lists_mutex);
+ ib_dev = srcu_dereference(dev->ib_dev,
+ &dev->disassociate_srcu);
+ if (!ib_dev) {
+ ret = -EIO;
+ goto err;
+ }
+
+ /* In case IB device supports disassociate ucontext, there is no hard
+ * dependency between uverbs device and its low level device.
+ */
+ module_dependent = !(ib_dev->disassociate_ucontext);
+
+ if (module_dependent) {
+ if (!try_module_get(ib_dev->owner)) {
+ ret = -ENODEV;
+ goto err;
+ }
+ }
+
+ file = kzalloc(sizeof(*file), GFP_KERNEL);
+ if (!file) {
+ ret = -ENOMEM;
+ if (module_dependent)
+ goto err_module;
+
+ goto err;
+ }
+
+ file->device = dev;
+ file->ucontext = NULL;
+ file->async_file = NULL;
+ kref_init(&file->ref);
+ mutex_init(&file->mutex);
+ mutex_init(&file->cleanup_mutex);
+
+ filp->private_data = file;
+ kobject_get(&dev->kobj);
+ list_add_tail(&file->list, &dev->uverbs_file_list);
+ mutex_unlock(&dev->lists_mutex);
+ srcu_read_unlock(&dev->disassociate_srcu, srcu_key);
+
+ return nonseekable_open(inode, filp);
+
+err_module:
+ module_put(ib_dev->owner);
+
+err:
+ mutex_unlock(&dev->lists_mutex);
+ srcu_read_unlock(&dev->disassociate_srcu, srcu_key);
+ if (atomic_dec_and_test(&dev->refcount))
+ ib_uverbs_comp_dev(dev);
+
+ return ret;
+}
+
+static int ib_uverbs_close(struct inode *inode, struct file *filp)
+{
+ struct ib_uverbs_file *file = filp->private_data;
+ struct ib_uverbs_device *dev = file->device;
+
+ mutex_lock(&file->cleanup_mutex);
+ if (file->ucontext) {
+ ib_uverbs_cleanup_ucontext(file, file->ucontext);
+ file->ucontext = NULL;
+ }
+ mutex_unlock(&file->cleanup_mutex);
+
+ mutex_lock(&file->device->lists_mutex);
+ if (!file->is_closed) {
+ list_del(&file->list);
+ file->is_closed = 1;
+ }
+ mutex_unlock(&file->device->lists_mutex);
+
+ if (file->async_file)
+ kref_put(&file->async_file->ref, ib_uverbs_release_event_file);
+
+ kref_put(&file->ref, ib_uverbs_release_file);
+ kobject_put(&dev->kobj);
+
+ return 0;
+}
+
+static const struct file_operations uverbs_fops = {
+ .owner = THIS_MODULE,
+ .write = ib_uverbs_write,
+ .open = ib_uverbs_open,
+ .release = ib_uverbs_close,
+ .llseek = no_llseek,
+};
+
+static const struct file_operations uverbs_mmap_fops = {
+ .owner = THIS_MODULE,
+ .write = ib_uverbs_write,
+ .mmap = ib_uverbs_mmap,
+ .open = ib_uverbs_open,
+ .release = ib_uverbs_close,
+ .llseek = no_llseek,
+};
+
+static struct ib_client uverbs_client = {
+ .name = "uverbs",
+ .add = ib_uverbs_add_one,
+ .remove = ib_uverbs_remove_one
+};
+
+static ssize_t show_ibdev(struct device *device, struct device_attribute *attr,
+ char *buf)
+{
+ int ret = -ENODEV;
+ int srcu_key;
+ struct ib_uverbs_device *dev = dev_get_drvdata(device);
+ struct ib_device *ib_dev;
+
+ if (!dev)
+ return -ENODEV;
+
+ srcu_key = srcu_read_lock(&dev->disassociate_srcu);
+ ib_dev = srcu_dereference(dev->ib_dev, &dev->disassociate_srcu);
+ if (ib_dev)
+ ret = sprintf(buf, "%s\n", ib_dev->name);
+ srcu_read_unlock(&dev->disassociate_srcu, srcu_key);
+
+ return ret;
+}
+static DEVICE_ATTR(ibdev, S_IRUGO, show_ibdev, NULL);
+
+static ssize_t show_dev_abi_version(struct device *device,
+ struct device_attribute *attr, char *buf)
+{
+ struct ib_uverbs_device *dev = dev_get_drvdata(device);
+ int ret = -ENODEV;
+ int srcu_key;
+ struct ib_device *ib_dev;
+
+ if (!dev)
+ return -ENODEV;
+ srcu_key = srcu_read_lock(&dev->disassociate_srcu);
+ ib_dev = srcu_dereference(dev->ib_dev, &dev->disassociate_srcu);
+ if (ib_dev)
+ ret = sprintf(buf, "%d\n", ib_dev->uverbs_abi_ver);
+ srcu_read_unlock(&dev->disassociate_srcu, srcu_key);
+
+ return ret;
+}
+static DEVICE_ATTR(abi_version, S_IRUGO, show_dev_abi_version, NULL);
+
+static CLASS_ATTR_STRING(abi_version, S_IRUGO,
+ __stringify(IB_USER_VERBS_ABI_VERSION));
+
+static dev_t overflow_maj;
+static DECLARE_BITMAP(overflow_map, IB_UVERBS_MAX_DEVICES);
+
+/*
+ * If we have more than IB_UVERBS_MAX_DEVICES, dynamically overflow by
+ * requesting a new major number and doubling the number of max devices we
+ * support. It's stupid, but simple.
+ */
+static int find_overflow_devnum(void)
+{
+ int ret;
+
+ if (!overflow_maj) {
+ ret = alloc_chrdev_region(&overflow_maj, 0, IB_UVERBS_MAX_DEVICES,
+ "infiniband_verbs");
+ if (ret) {
+ pr_err("user_verbs: couldn't register dynamic device number\n");
+ return ret;
+ }
+ }
+
+ ret = find_first_zero_bit(overflow_map, IB_UVERBS_MAX_DEVICES);
+ if (ret >= IB_UVERBS_MAX_DEVICES)
+ return -1;
+
+ return ret;
+}
+
+static ssize_t
+show_dev_device(struct device *device, struct device_attribute *attr, char *buf)
+{
+ struct ib_uverbs_device *dev = dev_get_drvdata(device);
+
+ if (!dev || !dev->ib_dev->dma_device)
+ return -ENODEV;
+
+ return sprintf(buf, "0x%04x\n",
+ ((struct pci_dev *)dev->ib_dev->dma_device)->device);
+}
+static DEVICE_ATTR(device, S_IRUGO, show_dev_device, NULL);
+
+static ssize_t
+show_dev_vendor(struct device *device, struct device_attribute *attr, char *buf)
+{
+ struct ib_uverbs_device *dev = dev_get_drvdata(device);
+
+ if (!dev || !dev->ib_dev->dma_device)
+ return -ENODEV;
+
+ return sprintf(buf, "0x%04x\n",
+ ((struct pci_dev *)dev->ib_dev->dma_device)->vendor);
+}
+static DEVICE_ATTR(vendor, S_IRUGO, show_dev_vendor, NULL);
+
+struct attribute *device_attrs[] =
+{
+ &dev_attr_device.attr,
+ &dev_attr_vendor.attr,
+ NULL
+};
+
+static struct attribute_group device_group = {
+ .name = "device",
+ .attrs = device_attrs
+};
+
+static void ib_uverbs_add_one(struct ib_device *device)
+{
+ int devnum;
+ dev_t base;
+ struct ib_uverbs_device *uverbs_dev;
+ int ret;
+
+ if (!device->alloc_ucontext)
+ return;
+
+ uverbs_dev = kzalloc(sizeof *uverbs_dev, GFP_KERNEL);
+ if (!uverbs_dev)
+ return;
+
+ ret = init_srcu_struct(&uverbs_dev->disassociate_srcu);
+ if (ret) {
+ kfree(uverbs_dev);
+ return;
+ }
+
+ atomic_set(&uverbs_dev->refcount, 1);
+ init_completion(&uverbs_dev->comp);
+ uverbs_dev->xrcd_tree = RB_ROOT;
+ mutex_init(&uverbs_dev->xrcd_tree_mutex);
+ kobject_init(&uverbs_dev->kobj, &ib_uverbs_dev_ktype);
+ mutex_init(&uverbs_dev->lists_mutex);
+ INIT_LIST_HEAD(&uverbs_dev->uverbs_file_list);
+ INIT_LIST_HEAD(&uverbs_dev->uverbs_events_file_list);
+
+ spin_lock(&map_lock);
+ devnum = find_first_zero_bit(dev_map, IB_UVERBS_MAX_DEVICES);
+ if (devnum >= IB_UVERBS_MAX_DEVICES) {
+ spin_unlock(&map_lock);
+ devnum = find_overflow_devnum();
+ if (devnum < 0)
+ goto err;
+
+ spin_lock(&map_lock);
+ uverbs_dev->devnum = devnum + IB_UVERBS_MAX_DEVICES;
+ base = devnum + overflow_maj;
+ set_bit(devnum, overflow_map);
+ } else {
+ uverbs_dev->devnum = devnum;
+ base = devnum + IB_UVERBS_BASE_DEV;
+ set_bit(devnum, dev_map);
+ }
+ spin_unlock(&map_lock);
+
+ rcu_assign_pointer(uverbs_dev->ib_dev, device);
+ uverbs_dev->num_comp_vectors = device->num_comp_vectors;
+
+ cdev_init(&uverbs_dev->cdev, NULL);
+ uverbs_dev->cdev.owner = THIS_MODULE;
+ uverbs_dev->cdev.ops = device->mmap ? &uverbs_mmap_fops : &uverbs_fops;
+ uverbs_dev->cdev.kobj.parent = &uverbs_dev->kobj;
+ kobject_set_name(&uverbs_dev->cdev.kobj, "uverbs%d", uverbs_dev->devnum);
+ if (cdev_add(&uverbs_dev->cdev, base, 1))
+ goto err_cdev;
+
+ uverbs_dev->dev = device_create(uverbs_class, device->dma_device,
+ uverbs_dev->cdev.dev, uverbs_dev,
+ "uverbs%d", uverbs_dev->devnum);
+ if (IS_ERR(uverbs_dev->dev))
+ goto err_cdev;
+
+ if (device_create_file(uverbs_dev->dev, &dev_attr_ibdev))
+ goto err_class;
+ if (device_create_file(uverbs_dev->dev, &dev_attr_abi_version))
+ goto err_class;
+ if (sysfs_create_group(&uverbs_dev->dev->kobj, &device_group))
+ goto err_class;
+
+ ib_set_client_data(device, &uverbs_client, uverbs_dev);
+
+ return;
+
+err_class:
+ device_destroy(uverbs_class, uverbs_dev->cdev.dev);
+
+err_cdev:
+ cdev_del(&uverbs_dev->cdev);
+ if (uverbs_dev->devnum < IB_UVERBS_MAX_DEVICES)
+ clear_bit(devnum, dev_map);
+ else
+ clear_bit(devnum, overflow_map);
+
+err:
+ if (atomic_dec_and_test(&uverbs_dev->refcount))
+ ib_uverbs_comp_dev(uverbs_dev);
+ wait_for_completion(&uverbs_dev->comp);
+ kobject_put(&uverbs_dev->kobj);
+ return;
+}
+
+static void ib_uverbs_free_hw_resources(struct ib_uverbs_device *uverbs_dev,
+ struct ib_device *ib_dev)
+{
+ struct ib_uverbs_file *file;
+ struct ib_uverbs_event_file *event_file;
+ struct ib_event event;
+
+ /* Pending running commands to terminate */
+ synchronize_srcu(&uverbs_dev->disassociate_srcu);
+ event.event = IB_EVENT_DEVICE_FATAL;
+ event.element.port_num = 0;
+ event.device = ib_dev;
+
+ mutex_lock(&uverbs_dev->lists_mutex);
+ while (!list_empty(&uverbs_dev->uverbs_file_list)) {
+ struct ib_ucontext *ucontext;
+ file = list_first_entry(&uverbs_dev->uverbs_file_list,
+ struct ib_uverbs_file, list);
+ file->is_closed = 1;
+ list_del(&file->list);
+ kref_get(&file->ref);
+ mutex_unlock(&uverbs_dev->lists_mutex);
+
+ ib_uverbs_event_handler(&file->event_handler, &event);
+
+ mutex_lock(&file->cleanup_mutex);
+ ucontext = file->ucontext;
+ file->ucontext = NULL;
+ mutex_unlock(&file->cleanup_mutex);
+
+ /* At this point ib_uverbs_close cannot be running
+ * ib_uverbs_cleanup_ucontext
+ */
+ if (ucontext) {
+ /* We must release the mutex before going ahead and
+ * calling disassociate_ucontext. disassociate_ucontext
+ * might end up indirectly calling uverbs_close,
+ * for example due to freeing the resources
+ * (e.g mmput).
+ */
+ ib_dev->disassociate_ucontext(ucontext);
+ ib_uverbs_cleanup_ucontext(file, ucontext);
+ }
+
+ mutex_lock(&uverbs_dev->lists_mutex);
+ kref_put(&file->ref, ib_uverbs_release_file);
+ }
+
+ while (!list_empty(&uverbs_dev->uverbs_events_file_list)) {
+ event_file = list_first_entry(&uverbs_dev->
+ uverbs_events_file_list,
+ struct ib_uverbs_event_file,
+ list);
+ spin_lock_irq(&event_file->lock);
+ event_file->is_closed = 1;
+ spin_unlock_irq(&event_file->lock);
+
+ list_del(&event_file->list);
+ if (event_file->is_async) {
+ ib_unregister_event_handler(&event_file->uverbs_file->
+ event_handler);
+ event_file->uverbs_file->event_handler.device = NULL;
+ }
+
+ wake_up_interruptible(&event_file->poll_wait);
+ kill_fasync(&event_file->async_queue, SIGIO, POLL_IN);
+ }
+ mutex_unlock(&uverbs_dev->lists_mutex);
+}
+
+static void ib_uverbs_remove_one(struct ib_device *device, void *client_data)
+{
+ struct ib_uverbs_device *uverbs_dev = client_data;
+ int wait_clients = 1;
+
+ if (!uverbs_dev)
+ return;
+
+ sysfs_remove_group(&uverbs_dev->dev->kobj, &device_group);
+ dev_set_drvdata(uverbs_dev->dev, NULL);
+ device_destroy(uverbs_class, uverbs_dev->cdev.dev);
+ cdev_del(&uverbs_dev->cdev);
+
+ if (uverbs_dev->devnum < IB_UVERBS_MAX_DEVICES)
+ clear_bit(uverbs_dev->devnum, dev_map);
+ else
+ clear_bit(uverbs_dev->devnum - IB_UVERBS_MAX_DEVICES, overflow_map);
+
+ if (device->disassociate_ucontext) {
+ /* We disassociate HW resources and immediately return.
+ * Userspace will see a EIO errno for all future access.
+ * Upon returning, ib_device may be freed internally and is not
+ * valid any more.
+ * uverbs_device is still available until all clients close
+ * their files, then the uverbs device ref count will be zero
+ * and its resources will be freed.
+ * Note: At this point no more files can be opened since the
+ * cdev was deleted, however active clients can still issue
+ * commands and close their open files.
+ */
+ rcu_assign_pointer(uverbs_dev->ib_dev, NULL);
+ ib_uverbs_free_hw_resources(uverbs_dev, device);
+ wait_clients = 0;
+ }
+
+ if (atomic_dec_and_test(&uverbs_dev->refcount))
+ ib_uverbs_comp_dev(uverbs_dev);
+ if (wait_clients)
+ wait_for_completion(&uverbs_dev->comp);
+ kobject_put(&uverbs_dev->kobj);
+}
+
+static char *uverbs_devnode(struct device *dev, umode_t *mode)
+{
+ if (mode)
+ *mode = 0666;
+ return kasprintf(GFP_KERNEL, "infiniband/%s", dev_name(dev));
+}
+
+static int __init ib_uverbs_init(void)
+{
+ int ret;
+
+ ret = register_chrdev_region(IB_UVERBS_BASE_DEV, IB_UVERBS_MAX_DEVICES,
+ "infiniband_verbs");
+ if (ret) {
+ pr_err("user_verbs: couldn't register device number\n");
+ goto out;
+ }
+
+ uverbs_class = class_create(THIS_MODULE, "infiniband_verbs");
+ if (IS_ERR(uverbs_class)) {
+ ret = PTR_ERR(uverbs_class);
+ pr_err("user_verbs: couldn't create class infiniband_verbs\n");
+ goto out_chrdev;
+ }
+
+ uverbs_class->devnode = uverbs_devnode;
+
+ ret = class_create_file(uverbs_class, &class_attr_abi_version.attr);
+ if (ret) {
+ pr_err("user_verbs: couldn't create abi_version attribute\n");
+ goto out_class;
+ }
+
+ ret = ib_register_client(&uverbs_client);
+ if (ret) {
+ pr_err("user_verbs: couldn't register client\n");
+ goto out_class;
+ }
+
+ return 0;
+
+out_class:
+ class_destroy(uverbs_class);
+
+out_chrdev:
+ unregister_chrdev_region(IB_UVERBS_BASE_DEV, IB_UVERBS_MAX_DEVICES);
+
+out:
+ return ret;
+}
+
+static void __exit ib_uverbs_cleanup(void)
+{
+ ib_unregister_client(&uverbs_client);
+ class_destroy(uverbs_class);
+ unregister_chrdev_region(IB_UVERBS_BASE_DEV, IB_UVERBS_MAX_DEVICES);
+ if (overflow_maj)
+ unregister_chrdev_region(overflow_maj, IB_UVERBS_MAX_DEVICES);
+ idr_destroy(&ib_uverbs_pd_idr);
+ idr_destroy(&ib_uverbs_mr_idr);
+ idr_destroy(&ib_uverbs_mw_idr);
+ idr_destroy(&ib_uverbs_ah_idr);
+ idr_destroy(&ib_uverbs_cq_idr);
+ idr_destroy(&ib_uverbs_qp_idr);
+ idr_destroy(&ib_uverbs_srq_idr);
+}
+
+module_init_order(ib_uverbs_init, SI_ORDER_THIRD);
+module_exit(ib_uverbs_cleanup);
diff --git a/sys/ofed/drivers/infiniband/core/ib_uverbs_marshall.c b/sys/ofed/drivers/infiniband/core/ib_uverbs_marshall.c
new file mode 100644
index 0000000..db86547
--- /dev/null
+++ b/sys/ofed/drivers/infiniband/core/ib_uverbs_marshall.c
@@ -0,0 +1,148 @@
+/*
+ * Copyright (c) 2005 Intel Corporation. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#include <rdma/ib_marshall.h>
+
+void ib_copy_ah_attr_to_user(struct ib_uverbs_ah_attr *dst,
+ struct ib_ah_attr *src)
+{
+ memcpy(dst->grh.dgid, src->grh.dgid.raw, sizeof src->grh.dgid);
+ dst->grh.flow_label = src->grh.flow_label;
+ dst->grh.sgid_index = src->grh.sgid_index;
+ dst->grh.hop_limit = src->grh.hop_limit;
+ dst->grh.traffic_class = src->grh.traffic_class;
+ memset(&dst->grh.reserved, 0, sizeof(dst->grh.reserved));
+ dst->dlid = src->dlid;
+ dst->sl = src->sl;
+ dst->src_path_bits = src->src_path_bits;
+ dst->static_rate = src->static_rate;
+ dst->is_global = src->ah_flags & IB_AH_GRH ? 1 : 0;
+ dst->port_num = src->port_num;
+ dst->reserved = 0;
+}
+EXPORT_SYMBOL(ib_copy_ah_attr_to_user);
+
+void ib_copy_qp_attr_to_user(struct ib_uverbs_qp_attr *dst,
+ struct ib_qp_attr *src)
+{
+ dst->qp_state = src->qp_state;
+ dst->cur_qp_state = src->cur_qp_state;
+ dst->path_mtu = src->path_mtu;
+ dst->path_mig_state = src->path_mig_state;
+ dst->qkey = src->qkey;
+ dst->rq_psn = src->rq_psn;
+ dst->sq_psn = src->sq_psn;
+ dst->dest_qp_num = src->dest_qp_num;
+ dst->qp_access_flags = src->qp_access_flags;
+
+ dst->max_send_wr = src->cap.max_send_wr;
+ dst->max_recv_wr = src->cap.max_recv_wr;
+ dst->max_send_sge = src->cap.max_send_sge;
+ dst->max_recv_sge = src->cap.max_recv_sge;
+ dst->max_inline_data = src->cap.max_inline_data;
+
+ ib_copy_ah_attr_to_user(&dst->ah_attr, &src->ah_attr);
+ ib_copy_ah_attr_to_user(&dst->alt_ah_attr, &src->alt_ah_attr);
+
+ dst->pkey_index = src->pkey_index;
+ dst->alt_pkey_index = src->alt_pkey_index;
+ dst->en_sqd_async_notify = src->en_sqd_async_notify;
+ dst->sq_draining = src->sq_draining;
+ dst->max_rd_atomic = src->max_rd_atomic;
+ dst->max_dest_rd_atomic = src->max_dest_rd_atomic;
+ dst->min_rnr_timer = src->min_rnr_timer;
+ dst->port_num = src->port_num;
+ dst->timeout = src->timeout;
+ dst->retry_cnt = src->retry_cnt;
+ dst->rnr_retry = src->rnr_retry;
+ dst->alt_port_num = src->alt_port_num;
+ dst->alt_timeout = src->alt_timeout;
+ memset(dst->reserved, 0, sizeof(dst->reserved));
+}
+EXPORT_SYMBOL(ib_copy_qp_attr_to_user);
+
+void ib_copy_path_rec_to_user(struct ib_user_path_rec *dst,
+ struct ib_sa_path_rec *src)
+{
+ memcpy(dst->dgid, src->dgid.raw, sizeof src->dgid);
+ memcpy(dst->sgid, src->sgid.raw, sizeof src->sgid);
+
+ dst->dlid = src->dlid;
+ dst->slid = src->slid;
+ dst->raw_traffic = src->raw_traffic;
+ dst->flow_label = src->flow_label;
+ dst->hop_limit = src->hop_limit;
+ dst->traffic_class = src->traffic_class;
+ dst->reversible = src->reversible;
+ dst->numb_path = src->numb_path;
+ dst->pkey = src->pkey;
+ dst->sl = src->sl;
+ dst->mtu_selector = src->mtu_selector;
+ dst->mtu = src->mtu;
+ dst->rate_selector = src->rate_selector;
+ dst->rate = src->rate;
+ dst->packet_life_time = src->packet_life_time;
+ dst->preference = src->preference;
+ dst->packet_life_time_selector = src->packet_life_time_selector;
+}
+EXPORT_SYMBOL(ib_copy_path_rec_to_user);
+
+void ib_copy_path_rec_from_user(struct ib_sa_path_rec *dst,
+ struct ib_user_path_rec *src)
+{
+ memcpy(dst->dgid.raw, src->dgid, sizeof dst->dgid);
+ memcpy(dst->sgid.raw, src->sgid, sizeof dst->sgid);
+
+ dst->dlid = src->dlid;
+ dst->slid = src->slid;
+ dst->raw_traffic = src->raw_traffic;
+ dst->flow_label = src->flow_label;
+ dst->hop_limit = src->hop_limit;
+ dst->traffic_class = src->traffic_class;
+ dst->reversible = src->reversible;
+ dst->numb_path = src->numb_path;
+ dst->pkey = src->pkey;
+ dst->sl = src->sl;
+ dst->mtu_selector = src->mtu_selector;
+ dst->mtu = src->mtu;
+ dst->rate_selector = src->rate_selector;
+ dst->rate = src->rate;
+ dst->packet_life_time = src->packet_life_time;
+ dst->preference = src->preference;
+ dst->packet_life_time_selector = src->packet_life_time_selector;
+
+ memset(dst->dmac, 0, sizeof(dst->dmac));
+ dst->net = NULL;
+ dst->ifindex = 0;
+ dst->gid_type = IB_GID_TYPE_IB;
+}
+EXPORT_SYMBOL(ib_copy_path_rec_from_user);
diff --git a/sys/ofed/drivers/infiniband/core/ib_verbs.c b/sys/ofed/drivers/infiniband/core/ib_verbs.c
new file mode 100644
index 0000000..9e5b164
--- /dev/null
+++ b/sys/ofed/drivers/infiniband/core/ib_verbs.c
@@ -0,0 +1,2068 @@
+/*
+ * Copyright (c) 2004 Mellanox Technologies Ltd. All rights reserved.
+ * Copyright (c) 2004 Infinicon Corporation. All rights reserved.
+ * Copyright (c) 2004 Intel Corporation. All rights reserved.
+ * Copyright (c) 2004 Topspin Corporation. All rights reserved.
+ * Copyright (c) 2004 Voltaire Corporation. All rights reserved.
+ * Copyright (c) 2005 Sun Microsystems, Inc. All rights reserved.
+ * Copyright (c) 2005, 2006 Cisco Systems. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#include <linux/errno.h>
+#include <linux/err.h>
+#include <linux/string.h>
+#include <linux/slab.h>
+#include <linux/in.h>
+#include <linux/in6.h>
+
+#include <rdma/ib_verbs.h>
+#include <rdma/ib_cache.h>
+#include <rdma/ib_addr.h>
+
+#include <netinet/ip.h>
+#include <netinet/ip6.h>
+
+#include <machine/in_cksum.h>
+
+#include "core_priv.h"
+
+static const char * const ib_events[] = {
+ [IB_EVENT_CQ_ERR] = "CQ error",
+ [IB_EVENT_QP_FATAL] = "QP fatal error",
+ [IB_EVENT_QP_REQ_ERR] = "QP request error",
+ [IB_EVENT_QP_ACCESS_ERR] = "QP access error",
+ [IB_EVENT_COMM_EST] = "communication established",
+ [IB_EVENT_SQ_DRAINED] = "send queue drained",
+ [IB_EVENT_PATH_MIG] = "path migration successful",
+ [IB_EVENT_PATH_MIG_ERR] = "path migration error",
+ [IB_EVENT_DEVICE_FATAL] = "device fatal error",
+ [IB_EVENT_PORT_ACTIVE] = "port active",
+ [IB_EVENT_PORT_ERR] = "port error",
+ [IB_EVENT_LID_CHANGE] = "LID change",
+ [IB_EVENT_PKEY_CHANGE] = "P_key change",
+ [IB_EVENT_SM_CHANGE] = "SM change",
+ [IB_EVENT_SRQ_ERR] = "SRQ error",
+ [IB_EVENT_SRQ_LIMIT_REACHED] = "SRQ limit reached",
+ [IB_EVENT_QP_LAST_WQE_REACHED] = "last WQE reached",
+ [IB_EVENT_CLIENT_REREGISTER] = "client reregister",
+ [IB_EVENT_GID_CHANGE] = "GID changed",
+};
+
+const char *__attribute_const__ ib_event_msg(enum ib_event_type event)
+{
+ size_t index = event;
+
+ return (index < ARRAY_SIZE(ib_events) && ib_events[index]) ?
+ ib_events[index] : "unrecognized event";
+}
+EXPORT_SYMBOL(ib_event_msg);
+
+static const char * const wc_statuses[] = {
+ [IB_WC_SUCCESS] = "success",
+ [IB_WC_LOC_LEN_ERR] = "local length error",
+ [IB_WC_LOC_QP_OP_ERR] = "local QP operation error",
+ [IB_WC_LOC_EEC_OP_ERR] = "local EE context operation error",
+ [IB_WC_LOC_PROT_ERR] = "local protection error",
+ [IB_WC_WR_FLUSH_ERR] = "WR flushed",
+ [IB_WC_MW_BIND_ERR] = "memory management operation error",
+ [IB_WC_BAD_RESP_ERR] = "bad response error",
+ [IB_WC_LOC_ACCESS_ERR] = "local access error",
+ [IB_WC_REM_INV_REQ_ERR] = "invalid request error",
+ [IB_WC_REM_ACCESS_ERR] = "remote access error",
+ [IB_WC_REM_OP_ERR] = "remote operation error",
+ [IB_WC_RETRY_EXC_ERR] = "transport retry counter exceeded",
+ [IB_WC_RNR_RETRY_EXC_ERR] = "RNR retry counter exceeded",
+ [IB_WC_LOC_RDD_VIOL_ERR] = "local RDD violation error",
+ [IB_WC_REM_INV_RD_REQ_ERR] = "remote invalid RD request",
+ [IB_WC_REM_ABORT_ERR] = "operation aborted",
+ [IB_WC_INV_EECN_ERR] = "invalid EE context number",
+ [IB_WC_INV_EEC_STATE_ERR] = "invalid EE context state",
+ [IB_WC_FATAL_ERR] = "fatal error",
+ [IB_WC_RESP_TIMEOUT_ERR] = "response timeout error",
+ [IB_WC_GENERAL_ERR] = "general error",
+};
+
+const char *__attribute_const__ ib_wc_status_msg(enum ib_wc_status status)
+{
+ size_t index = status;
+
+ return (index < ARRAY_SIZE(wc_statuses) && wc_statuses[index]) ?
+ wc_statuses[index] : "unrecognized status";
+}
+EXPORT_SYMBOL(ib_wc_status_msg);
+
+__attribute_const__ int ib_rate_to_mult(enum ib_rate rate)
+{
+ switch (rate) {
+ case IB_RATE_2_5_GBPS: return 1;
+ case IB_RATE_5_GBPS: return 2;
+ case IB_RATE_10_GBPS: return 4;
+ case IB_RATE_20_GBPS: return 8;
+ case IB_RATE_30_GBPS: return 12;
+ case IB_RATE_40_GBPS: return 16;
+ case IB_RATE_60_GBPS: return 24;
+ case IB_RATE_80_GBPS: return 32;
+ case IB_RATE_120_GBPS: return 48;
+ default: return -1;
+ }
+}
+EXPORT_SYMBOL(ib_rate_to_mult);
+
+__attribute_const__ enum ib_rate mult_to_ib_rate(int mult)
+{
+ switch (mult) {
+ case 1: return IB_RATE_2_5_GBPS;
+ case 2: return IB_RATE_5_GBPS;
+ case 4: return IB_RATE_10_GBPS;
+ case 8: return IB_RATE_20_GBPS;
+ case 12: return IB_RATE_30_GBPS;
+ case 16: return IB_RATE_40_GBPS;
+ case 24: return IB_RATE_60_GBPS;
+ case 32: return IB_RATE_80_GBPS;
+ case 48: return IB_RATE_120_GBPS;
+ default: return IB_RATE_PORT_CURRENT;
+ }
+}
+EXPORT_SYMBOL(mult_to_ib_rate);
+
+__attribute_const__ int ib_rate_to_mbps(enum ib_rate rate)
+{
+ switch (rate) {
+ case IB_RATE_2_5_GBPS: return 2500;
+ case IB_RATE_5_GBPS: return 5000;
+ case IB_RATE_10_GBPS: return 10000;
+ case IB_RATE_20_GBPS: return 20000;
+ case IB_RATE_30_GBPS: return 30000;
+ case IB_RATE_40_GBPS: return 40000;
+ case IB_RATE_60_GBPS: return 60000;
+ case IB_RATE_80_GBPS: return 80000;
+ case IB_RATE_120_GBPS: return 120000;
+ case IB_RATE_14_GBPS: return 14062;
+ case IB_RATE_56_GBPS: return 56250;
+ case IB_RATE_112_GBPS: return 112500;
+ case IB_RATE_168_GBPS: return 168750;
+ case IB_RATE_25_GBPS: return 25781;
+ case IB_RATE_100_GBPS: return 103125;
+ case IB_RATE_200_GBPS: return 206250;
+ case IB_RATE_300_GBPS: return 309375;
+ default: return -1;
+ }
+}
+EXPORT_SYMBOL(ib_rate_to_mbps);
+
+__attribute_const__ enum rdma_transport_type
+rdma_node_get_transport(enum rdma_node_type node_type)
+{
+ switch (node_type) {
+ case RDMA_NODE_IB_CA:
+ case RDMA_NODE_IB_SWITCH:
+ case RDMA_NODE_IB_ROUTER:
+ return RDMA_TRANSPORT_IB;
+ case RDMA_NODE_RNIC:
+ return RDMA_TRANSPORT_IWARP;
+ case RDMA_NODE_USNIC:
+ return RDMA_TRANSPORT_USNIC;
+ case RDMA_NODE_USNIC_UDP:
+ return RDMA_TRANSPORT_USNIC_UDP;
+ default:
+ BUG();
+ return 0;
+ }
+}
+EXPORT_SYMBOL(rdma_node_get_transport);
+
+enum rdma_link_layer rdma_port_get_link_layer(struct ib_device *device, u8 port_num)
+{
+ if (device->get_link_layer)
+ return device->get_link_layer(device, port_num);
+
+ switch (rdma_node_get_transport(device->node_type)) {
+ case RDMA_TRANSPORT_IB:
+ return IB_LINK_LAYER_INFINIBAND;
+ case RDMA_TRANSPORT_IWARP:
+ case RDMA_TRANSPORT_USNIC:
+ case RDMA_TRANSPORT_USNIC_UDP:
+ return IB_LINK_LAYER_ETHERNET;
+ default:
+ return IB_LINK_LAYER_UNSPECIFIED;
+ }
+}
+EXPORT_SYMBOL(rdma_port_get_link_layer);
+
+/* Protection domains */
+
+/**
+ * ib_alloc_pd - Allocates an unused protection domain.
+ * @device: The device on which to allocate the protection domain.
+ *
+ * A protection domain object provides an association between QPs, shared
+ * receive queues, address handles, memory regions, and memory windows.
+ *
+ * Every PD has a local_dma_lkey which can be used as the lkey value for local
+ * memory operations.
+ */
+struct ib_pd *__ib_alloc_pd(struct ib_device *device, unsigned int flags,
+ const char *caller)
+{
+ struct ib_pd *pd;
+ int mr_access_flags = 0;
+
+ pd = device->alloc_pd(device, NULL, NULL);
+ if (IS_ERR(pd))
+ return pd;
+
+ pd->device = device;
+ pd->uobject = NULL;
+ pd->__internal_mr = NULL;
+ atomic_set(&pd->usecnt, 0);
+ pd->flags = flags;
+
+ if (device->attrs.device_cap_flags & IB_DEVICE_LOCAL_DMA_LKEY)
+ pd->local_dma_lkey = device->local_dma_lkey;
+ else
+ mr_access_flags |= IB_ACCESS_LOCAL_WRITE;
+
+ if (flags & IB_PD_UNSAFE_GLOBAL_RKEY) {
+ pr_warn("%s: enabling unsafe global rkey\n", caller);
+ mr_access_flags |= IB_ACCESS_REMOTE_READ | IB_ACCESS_REMOTE_WRITE;
+ }
+
+ if (mr_access_flags) {
+ struct ib_mr *mr;
+
+ mr = pd->device->get_dma_mr(pd, mr_access_flags);
+ if (IS_ERR(mr)) {
+ ib_dealloc_pd(pd);
+ return ERR_CAST(mr);
+ }
+
+ mr->device = pd->device;
+ mr->pd = pd;
+ mr->uobject = NULL;
+ mr->need_inval = false;
+
+ pd->__internal_mr = mr;
+
+ if (!(device->attrs.device_cap_flags & IB_DEVICE_LOCAL_DMA_LKEY))
+ pd->local_dma_lkey = pd->__internal_mr->lkey;
+
+ if (flags & IB_PD_UNSAFE_GLOBAL_RKEY)
+ pd->unsafe_global_rkey = pd->__internal_mr->rkey;
+ }
+
+ return pd;
+}
+EXPORT_SYMBOL(__ib_alloc_pd);
+
+/**
+ * ib_dealloc_pd - Deallocates a protection domain.
+ * @pd: The protection domain to deallocate.
+ *
+ * It is an error to call this function while any resources in the pd still
+ * exist. The caller is responsible to synchronously destroy them and
+ * guarantee no new allocations will happen.
+ */
+void ib_dealloc_pd(struct ib_pd *pd)
+{
+ int ret;
+
+ if (pd->__internal_mr) {
+ ret = pd->device->dereg_mr(pd->__internal_mr);
+ WARN_ON(ret);
+ pd->__internal_mr = NULL;
+ }
+
+ /* uverbs manipulates usecnt with proper locking, while the kabi
+ requires the caller to guarantee we can't race here. */
+ WARN_ON(atomic_read(&pd->usecnt));
+
+ /* Making delalloc_pd a void return is a WIP, no driver should return
+ an error here. */
+ ret = pd->device->dealloc_pd(pd);
+ WARN_ONCE(ret, "Infiniband HW driver failed dealloc_pd");
+}
+EXPORT_SYMBOL(ib_dealloc_pd);
+
+/* Address handles */
+
+struct ib_ah *ib_create_ah(struct ib_pd *pd, struct ib_ah_attr *ah_attr)
+{
+ struct ib_ah *ah;
+
+ ah = pd->device->create_ah(pd, ah_attr);
+
+ if (!IS_ERR(ah)) {
+ ah->device = pd->device;
+ ah->pd = pd;
+ ah->uobject = NULL;
+ atomic_inc(&pd->usecnt);
+ }
+
+ return ah;
+}
+EXPORT_SYMBOL(ib_create_ah);
+
+static int ib_get_header_version(const union rdma_network_hdr *hdr)
+{
+ const struct ip *ip4h = (const struct ip *)&hdr->roce4grh;
+ struct ip ip4h_checked;
+ const struct ip6_hdr *ip6h = (const struct ip6_hdr *)&hdr->ibgrh;
+
+ /* If it's IPv6, the version must be 6, otherwise, the first
+ * 20 bytes (before the IPv4 header) are garbled.
+ */
+ if ((ip6h->ip6_vfc & IPV6_VERSION_MASK) != IPV6_VERSION)
+ return (ip4h->ip_v == 4) ? 4 : 0;
+ /* version may be 6 or 4 because the first 20 bytes could be garbled */
+
+ /* RoCE v2 requires no options, thus header length
+ * must be 5 words
+ */
+ if (ip4h->ip_hl != 5)
+ return 6;
+
+ /* Verify checksum.
+ * We can't write on scattered buffers so we need to copy to
+ * temp buffer.
+ */
+ memcpy(&ip4h_checked, ip4h, sizeof(ip4h_checked));
+ ip4h_checked.ip_sum = 0;
+#if defined(INET) || defined(INET6)
+ ip4h_checked.ip_sum = in_cksum_hdr(&ip4h_checked);
+#endif
+ /* if IPv4 header checksum is OK, believe it */
+ if (ip4h->ip_sum == ip4h_checked.ip_sum)
+ return 4;
+ return 6;
+}
+
+static enum rdma_network_type ib_get_net_type_by_grh(struct ib_device *device,
+ u8 port_num,
+ const struct ib_grh *grh)
+{
+ int grh_version;
+
+ if (rdma_protocol_ib(device, port_num))
+ return RDMA_NETWORK_IB;
+
+ grh_version = ib_get_header_version((const union rdma_network_hdr *)grh);
+
+ if (grh_version == 4)
+ return RDMA_NETWORK_IPV4;
+
+ if (grh->next_hdr == IPPROTO_UDP)
+ return RDMA_NETWORK_IPV6;
+
+ return RDMA_NETWORK_ROCE_V1;
+}
+
+struct find_gid_index_context {
+ u16 vlan_id;
+ enum ib_gid_type gid_type;
+};
+
+static bool find_gid_index(const union ib_gid *gid,
+ const struct ib_gid_attr *gid_attr,
+ void *context)
+{
+ struct find_gid_index_context *ctx =
+ (struct find_gid_index_context *)context;
+
+ if (ctx->gid_type != gid_attr->gid_type)
+ return false;
+
+ if ((!!(ctx->vlan_id != 0xffff) == !is_vlan_dev(gid_attr->ndev)) ||
+ (is_vlan_dev(gid_attr->ndev) &&
+ vlan_dev_vlan_id(gid_attr->ndev) != ctx->vlan_id))
+ return false;
+
+ return true;
+}
+
+static int get_sgid_index_from_eth(struct ib_device *device, u8 port_num,
+ u16 vlan_id, const union ib_gid *sgid,
+ enum ib_gid_type gid_type,
+ u16 *gid_index)
+{
+ struct find_gid_index_context context = {.vlan_id = vlan_id,
+ .gid_type = gid_type};
+
+ return ib_find_gid_by_filter(device, sgid, port_num, find_gid_index,
+ &context, gid_index);
+}
+
+static int get_gids_from_rdma_hdr(const union rdma_network_hdr *hdr,
+ enum rdma_network_type net_type,
+ union ib_gid *sgid, union ib_gid *dgid)
+{
+ struct sockaddr_in src_in;
+ struct sockaddr_in dst_in;
+ __be32 src_saddr, dst_saddr;
+
+ if (!sgid || !dgid)
+ return -EINVAL;
+
+ if (net_type == RDMA_NETWORK_IPV4) {
+ memcpy(&src_in.sin_addr.s_addr,
+ &hdr->roce4grh.ip_src, 4);
+ memcpy(&dst_in.sin_addr.s_addr,
+ &hdr->roce4grh.ip_dst, 4);
+ src_saddr = src_in.sin_addr.s_addr;
+ dst_saddr = dst_in.sin_addr.s_addr;
+ ipv6_addr_set_v4mapped(src_saddr,
+ (struct in6_addr *)sgid);
+ ipv6_addr_set_v4mapped(dst_saddr,
+ (struct in6_addr *)dgid);
+ return 0;
+ } else if (net_type == RDMA_NETWORK_IPV6 ||
+ net_type == RDMA_NETWORK_IB) {
+ *dgid = hdr->ibgrh.dgid;
+ *sgid = hdr->ibgrh.sgid;
+ return 0;
+ } else {
+ return -EINVAL;
+ }
+}
+
+int ib_init_ah_from_wc(struct ib_device *device, u8 port_num,
+ const struct ib_wc *wc, const struct ib_grh *grh,
+ struct ib_ah_attr *ah_attr)
+{
+ u32 flow_class;
+ u16 gid_index;
+ int ret;
+ enum rdma_network_type net_type = RDMA_NETWORK_IB;
+ enum ib_gid_type gid_type = IB_GID_TYPE_IB;
+ int hoplimit = 0xff;
+ union ib_gid dgid;
+ union ib_gid sgid;
+
+ memset(ah_attr, 0, sizeof *ah_attr);
+ if (rdma_cap_eth_ah(device, port_num)) {
+ if (wc->wc_flags & IB_WC_WITH_NETWORK_HDR_TYPE)
+ net_type = wc->network_hdr_type;
+ else
+ net_type = ib_get_net_type_by_grh(device, port_num, grh);
+ gid_type = ib_network_to_gid_type(net_type);
+ }
+ ret = get_gids_from_rdma_hdr((const union rdma_network_hdr *)grh, net_type,
+ &sgid, &dgid);
+ if (ret)
+ return ret;
+
+ if (rdma_protocol_roce(device, port_num)) {
+ int if_index = 0;
+ u16 vlan_id = wc->wc_flags & IB_WC_WITH_VLAN ?
+ wc->vlan_id : 0xffff;
+ struct net_device *idev;
+ struct net_device *resolved_dev;
+
+ if (!(wc->wc_flags & IB_WC_GRH))
+ return -EPROTOTYPE;
+
+ if (!device->get_netdev)
+ return -EOPNOTSUPP;
+
+ idev = device->get_netdev(device, port_num);
+ if (!idev)
+ return -ENODEV;
+
+ ret = rdma_addr_find_l2_eth_by_grh(&dgid, &sgid,
+ ah_attr->dmac,
+ wc->wc_flags & IB_WC_WITH_VLAN ?
+ NULL : &vlan_id,
+ &if_index, &hoplimit);
+ if (ret) {
+ dev_put(idev);
+ return ret;
+ }
+
+ resolved_dev = dev_get_by_index(&init_net, if_index);
+ if (resolved_dev->if_flags & IFF_LOOPBACK) {
+ dev_put(resolved_dev);
+ resolved_dev = idev;
+ dev_hold(resolved_dev);
+ }
+ rcu_read_lock();
+ if (resolved_dev != idev && !rdma_is_upper_dev_rcu(idev,
+ resolved_dev))
+ ret = -EHOSTUNREACH;
+ rcu_read_unlock();
+ dev_put(idev);
+ dev_put(resolved_dev);
+ if (ret)
+ return ret;
+
+ ret = get_sgid_index_from_eth(device, port_num, vlan_id,
+ &dgid, gid_type, &gid_index);
+ if (ret)
+ return ret;
+ }
+
+ ah_attr->dlid = wc->slid;
+ ah_attr->sl = wc->sl;
+ ah_attr->src_path_bits = wc->dlid_path_bits;
+ ah_attr->port_num = port_num;
+
+ if (wc->wc_flags & IB_WC_GRH) {
+ ah_attr->ah_flags = IB_AH_GRH;
+ ah_attr->grh.dgid = sgid;
+
+ if (!rdma_cap_eth_ah(device, port_num)) {
+ if (dgid.global.interface_id != cpu_to_be64(IB_SA_WELL_KNOWN_GUID)) {
+ ret = ib_find_cached_gid_by_port(device, &dgid,
+ IB_GID_TYPE_IB,
+ port_num, NULL,
+ &gid_index);
+ if (ret)
+ return ret;
+ } else {
+ gid_index = 0;
+ }
+ }
+
+ ah_attr->grh.sgid_index = (u8) gid_index;
+ flow_class = be32_to_cpu(grh->version_tclass_flow);
+ ah_attr->grh.flow_label = flow_class & 0xFFFFF;
+ ah_attr->grh.hop_limit = hoplimit;
+ ah_attr->grh.traffic_class = (flow_class >> 20) & 0xFF;
+ }
+ return 0;
+}
+EXPORT_SYMBOL(ib_init_ah_from_wc);
+
+struct ib_ah *ib_create_ah_from_wc(struct ib_pd *pd, const struct ib_wc *wc,
+ const struct ib_grh *grh, u8 port_num)
+{
+ struct ib_ah_attr ah_attr;
+ int ret;
+
+ ret = ib_init_ah_from_wc(pd->device, port_num, wc, grh, &ah_attr);
+ if (ret)
+ return ERR_PTR(ret);
+
+ return ib_create_ah(pd, &ah_attr);
+}
+EXPORT_SYMBOL(ib_create_ah_from_wc);
+
+int ib_modify_ah(struct ib_ah *ah, struct ib_ah_attr *ah_attr)
+{
+ return ah->device->modify_ah ?
+ ah->device->modify_ah(ah, ah_attr) :
+ -ENOSYS;
+}
+EXPORT_SYMBOL(ib_modify_ah);
+
+int ib_query_ah(struct ib_ah *ah, struct ib_ah_attr *ah_attr)
+{
+ return ah->device->query_ah ?
+ ah->device->query_ah(ah, ah_attr) :
+ -ENOSYS;
+}
+EXPORT_SYMBOL(ib_query_ah);
+
+int ib_destroy_ah(struct ib_ah *ah)
+{
+ struct ib_pd *pd;
+ int ret;
+
+ pd = ah->pd;
+ ret = ah->device->destroy_ah(ah);
+ if (!ret)
+ atomic_dec(&pd->usecnt);
+
+ return ret;
+}
+EXPORT_SYMBOL(ib_destroy_ah);
+
+/* Shared receive queues */
+
+struct ib_srq *ib_create_srq(struct ib_pd *pd,
+ struct ib_srq_init_attr *srq_init_attr)
+{
+ struct ib_srq *srq;
+
+ if (!pd->device->create_srq)
+ return ERR_PTR(-ENOSYS);
+
+ srq = pd->device->create_srq(pd, srq_init_attr, NULL);
+
+ if (!IS_ERR(srq)) {
+ srq->device = pd->device;
+ srq->pd = pd;
+ srq->uobject = NULL;
+ srq->event_handler = srq_init_attr->event_handler;
+ srq->srq_context = srq_init_attr->srq_context;
+ srq->srq_type = srq_init_attr->srq_type;
+ if (srq->srq_type == IB_SRQT_XRC) {
+ srq->ext.xrc.xrcd = srq_init_attr->ext.xrc.xrcd;
+ srq->ext.xrc.cq = srq_init_attr->ext.xrc.cq;
+ atomic_inc(&srq->ext.xrc.xrcd->usecnt);
+ atomic_inc(&srq->ext.xrc.cq->usecnt);
+ }
+ atomic_inc(&pd->usecnt);
+ atomic_set(&srq->usecnt, 0);
+ }
+
+ return srq;
+}
+EXPORT_SYMBOL(ib_create_srq);
+
+int ib_modify_srq(struct ib_srq *srq,
+ struct ib_srq_attr *srq_attr,
+ enum ib_srq_attr_mask srq_attr_mask)
+{
+ return srq->device->modify_srq ?
+ srq->device->modify_srq(srq, srq_attr, srq_attr_mask, NULL) :
+ -ENOSYS;
+}
+EXPORT_SYMBOL(ib_modify_srq);
+
+int ib_query_srq(struct ib_srq *srq,
+ struct ib_srq_attr *srq_attr)
+{
+ return srq->device->query_srq ?
+ srq->device->query_srq(srq, srq_attr) : -ENOSYS;
+}
+EXPORT_SYMBOL(ib_query_srq);
+
+int ib_destroy_srq(struct ib_srq *srq)
+{
+ struct ib_pd *pd;
+ enum ib_srq_type srq_type;
+ struct ib_xrcd *uninitialized_var(xrcd);
+ struct ib_cq *uninitialized_var(cq);
+ int ret;
+
+ if (atomic_read(&srq->usecnt))
+ return -EBUSY;
+
+ pd = srq->pd;
+ srq_type = srq->srq_type;
+ if (srq_type == IB_SRQT_XRC) {
+ xrcd = srq->ext.xrc.xrcd;
+ cq = srq->ext.xrc.cq;
+ }
+
+ ret = srq->device->destroy_srq(srq);
+ if (!ret) {
+ atomic_dec(&pd->usecnt);
+ if (srq_type == IB_SRQT_XRC) {
+ atomic_dec(&xrcd->usecnt);
+ atomic_dec(&cq->usecnt);
+ }
+ }
+
+ return ret;
+}
+EXPORT_SYMBOL(ib_destroy_srq);
+
+/* Queue pairs */
+
+static void __ib_shared_qp_event_handler(struct ib_event *event, void *context)
+{
+ struct ib_qp *qp = context;
+ unsigned long flags;
+
+ spin_lock_irqsave(&qp->device->event_handler_lock, flags);
+ list_for_each_entry(event->element.qp, &qp->open_list, open_list)
+ if (event->element.qp->event_handler)
+ event->element.qp->event_handler(event, event->element.qp->qp_context);
+ spin_unlock_irqrestore(&qp->device->event_handler_lock, flags);
+}
+
+static void __ib_insert_xrcd_qp(struct ib_xrcd *xrcd, struct ib_qp *qp)
+{
+ mutex_lock(&xrcd->tgt_qp_mutex);
+ list_add(&qp->xrcd_list, &xrcd->tgt_qp_list);
+ mutex_unlock(&xrcd->tgt_qp_mutex);
+}
+
+static struct ib_qp *__ib_open_qp(struct ib_qp *real_qp,
+ void (*event_handler)(struct ib_event *, void *),
+ void *qp_context)
+{
+ struct ib_qp *qp;
+ unsigned long flags;
+
+ qp = kzalloc(sizeof *qp, GFP_KERNEL);
+ if (!qp)
+ return ERR_PTR(-ENOMEM);
+
+ qp->real_qp = real_qp;
+ atomic_inc(&real_qp->usecnt);
+ qp->device = real_qp->device;
+ qp->event_handler = event_handler;
+ qp->qp_context = qp_context;
+ qp->qp_num = real_qp->qp_num;
+ qp->qp_type = real_qp->qp_type;
+
+ spin_lock_irqsave(&real_qp->device->event_handler_lock, flags);
+ list_add(&qp->open_list, &real_qp->open_list);
+ spin_unlock_irqrestore(&real_qp->device->event_handler_lock, flags);
+
+ return qp;
+}
+
+struct ib_qp *ib_open_qp(struct ib_xrcd *xrcd,
+ struct ib_qp_open_attr *qp_open_attr)
+{
+ struct ib_qp *qp, *real_qp;
+
+ if (qp_open_attr->qp_type != IB_QPT_XRC_TGT)
+ return ERR_PTR(-EINVAL);
+
+ qp = ERR_PTR(-EINVAL);
+ mutex_lock(&xrcd->tgt_qp_mutex);
+ list_for_each_entry(real_qp, &xrcd->tgt_qp_list, xrcd_list) {
+ if (real_qp->qp_num == qp_open_attr->qp_num) {
+ qp = __ib_open_qp(real_qp, qp_open_attr->event_handler,
+ qp_open_attr->qp_context);
+ break;
+ }
+ }
+ mutex_unlock(&xrcd->tgt_qp_mutex);
+ return qp;
+}
+EXPORT_SYMBOL(ib_open_qp);
+
+static struct ib_qp *ib_create_xrc_qp(struct ib_qp *qp,
+ struct ib_qp_init_attr *qp_init_attr)
+{
+ struct ib_qp *real_qp = qp;
+
+ qp->event_handler = __ib_shared_qp_event_handler;
+ qp->qp_context = qp;
+ qp->pd = NULL;
+ qp->send_cq = qp->recv_cq = NULL;
+ qp->srq = NULL;
+ qp->xrcd = qp_init_attr->xrcd;
+ atomic_inc(&qp_init_attr->xrcd->usecnt);
+ INIT_LIST_HEAD(&qp->open_list);
+
+ qp = __ib_open_qp(real_qp, qp_init_attr->event_handler,
+ qp_init_attr->qp_context);
+ if (!IS_ERR(qp))
+ __ib_insert_xrcd_qp(qp_init_attr->xrcd, real_qp);
+ else
+ real_qp->device->destroy_qp(real_qp);
+ return qp;
+}
+
+struct ib_qp *ib_create_qp(struct ib_pd *pd,
+ struct ib_qp_init_attr *qp_init_attr)
+{
+ struct ib_device *device = pd ? pd->device : qp_init_attr->xrcd->device;
+ struct ib_qp *qp;
+
+ if (qp_init_attr->rwq_ind_tbl &&
+ (qp_init_attr->recv_cq ||
+ qp_init_attr->srq || qp_init_attr->cap.max_recv_wr ||
+ qp_init_attr->cap.max_recv_sge))
+ return ERR_PTR(-EINVAL);
+
+ qp = device->create_qp(pd, qp_init_attr, NULL);
+ if (IS_ERR(qp))
+ return qp;
+
+ qp->device = device;
+ qp->real_qp = qp;
+ qp->uobject = NULL;
+ qp->qp_type = qp_init_attr->qp_type;
+ qp->rwq_ind_tbl = qp_init_attr->rwq_ind_tbl;
+
+ atomic_set(&qp->usecnt, 0);
+ spin_lock_init(&qp->mr_lock);
+
+ if (qp_init_attr->qp_type == IB_QPT_XRC_TGT)
+ return ib_create_xrc_qp(qp, qp_init_attr);
+
+ qp->event_handler = qp_init_attr->event_handler;
+ qp->qp_context = qp_init_attr->qp_context;
+ if (qp_init_attr->qp_type == IB_QPT_XRC_INI) {
+ qp->recv_cq = NULL;
+ qp->srq = NULL;
+ } else {
+ qp->recv_cq = qp_init_attr->recv_cq;
+ if (qp_init_attr->recv_cq)
+ atomic_inc(&qp_init_attr->recv_cq->usecnt);
+ qp->srq = qp_init_attr->srq;
+ if (qp->srq)
+ atomic_inc(&qp_init_attr->srq->usecnt);
+ }
+
+ qp->pd = pd;
+ qp->send_cq = qp_init_attr->send_cq;
+ qp->xrcd = NULL;
+
+ atomic_inc(&pd->usecnt);
+ if (qp_init_attr->send_cq)
+ atomic_inc(&qp_init_attr->send_cq->usecnt);
+ if (qp_init_attr->rwq_ind_tbl)
+ atomic_inc(&qp->rwq_ind_tbl->usecnt);
+
+ /*
+ * Note: all hw drivers guarantee that max_send_sge is lower than
+ * the device RDMA WRITE SGE limit but not all hw drivers ensure that
+ * max_send_sge <= max_sge_rd.
+ */
+ qp->max_write_sge = qp_init_attr->cap.max_send_sge;
+ qp->max_read_sge = min_t(u32, qp_init_attr->cap.max_send_sge,
+ device->attrs.max_sge_rd);
+
+ return qp;
+}
+EXPORT_SYMBOL(ib_create_qp);
+
+static const struct {
+ int valid;
+ enum ib_qp_attr_mask req_param[IB_QPT_MAX];
+ enum ib_qp_attr_mask opt_param[IB_QPT_MAX];
+} qp_state_table[IB_QPS_ERR + 1][IB_QPS_ERR + 1] = {
+ [IB_QPS_RESET] = {
+ [IB_QPS_RESET] = { .valid = 1 },
+ [IB_QPS_INIT] = {
+ .valid = 1,
+ .req_param = {
+ [IB_QPT_UD] = (IB_QP_PKEY_INDEX |
+ IB_QP_PORT |
+ IB_QP_QKEY),
+ [IB_QPT_RAW_PACKET] = IB_QP_PORT,
+ [IB_QPT_UC] = (IB_QP_PKEY_INDEX |
+ IB_QP_PORT |
+ IB_QP_ACCESS_FLAGS),
+ [IB_QPT_RC] = (IB_QP_PKEY_INDEX |
+ IB_QP_PORT |
+ IB_QP_ACCESS_FLAGS),
+ [IB_QPT_XRC_INI] = (IB_QP_PKEY_INDEX |
+ IB_QP_PORT |
+ IB_QP_ACCESS_FLAGS),
+ [IB_QPT_XRC_TGT] = (IB_QP_PKEY_INDEX |
+ IB_QP_PORT |
+ IB_QP_ACCESS_FLAGS),
+ [IB_QPT_SMI] = (IB_QP_PKEY_INDEX |
+ IB_QP_QKEY),
+ [IB_QPT_GSI] = (IB_QP_PKEY_INDEX |
+ IB_QP_QKEY),
+ }
+ },
+ },
+ [IB_QPS_INIT] = {
+ [IB_QPS_RESET] = { .valid = 1 },
+ [IB_QPS_ERR] = { .valid = 1 },
+ [IB_QPS_INIT] = {
+ .valid = 1,
+ .opt_param = {
+ [IB_QPT_UD] = (IB_QP_PKEY_INDEX |
+ IB_QP_PORT |
+ IB_QP_QKEY),
+ [IB_QPT_UC] = (IB_QP_PKEY_INDEX |
+ IB_QP_PORT |
+ IB_QP_ACCESS_FLAGS),
+ [IB_QPT_RC] = (IB_QP_PKEY_INDEX |
+ IB_QP_PORT |
+ IB_QP_ACCESS_FLAGS),
+ [IB_QPT_XRC_INI] = (IB_QP_PKEY_INDEX |
+ IB_QP_PORT |
+ IB_QP_ACCESS_FLAGS),
+ [IB_QPT_XRC_TGT] = (IB_QP_PKEY_INDEX |
+ IB_QP_PORT |
+ IB_QP_ACCESS_FLAGS),
+ [IB_QPT_SMI] = (IB_QP_PKEY_INDEX |
+ IB_QP_QKEY),
+ [IB_QPT_GSI] = (IB_QP_PKEY_INDEX |
+ IB_QP_QKEY),
+ }
+ },
+ [IB_QPS_RTR] = {
+ .valid = 1,
+ .req_param = {
+ [IB_QPT_UC] = (IB_QP_AV |
+ IB_QP_PATH_MTU |
+ IB_QP_DEST_QPN |
+ IB_QP_RQ_PSN),
+ [IB_QPT_RC] = (IB_QP_AV |
+ IB_QP_PATH_MTU |
+ IB_QP_DEST_QPN |
+ IB_QP_RQ_PSN |
+ IB_QP_MAX_DEST_RD_ATOMIC |
+ IB_QP_MIN_RNR_TIMER),
+ [IB_QPT_XRC_INI] = (IB_QP_AV |
+ IB_QP_PATH_MTU |
+ IB_QP_DEST_QPN |
+ IB_QP_RQ_PSN),
+ [IB_QPT_XRC_TGT] = (IB_QP_AV |
+ IB_QP_PATH_MTU |
+ IB_QP_DEST_QPN |
+ IB_QP_RQ_PSN |
+ IB_QP_MAX_DEST_RD_ATOMIC |
+ IB_QP_MIN_RNR_TIMER),
+ },
+ .opt_param = {
+ [IB_QPT_UD] = (IB_QP_PKEY_INDEX |
+ IB_QP_QKEY),
+ [IB_QPT_UC] = (IB_QP_ALT_PATH |
+ IB_QP_ACCESS_FLAGS |
+ IB_QP_PKEY_INDEX),
+ [IB_QPT_RC] = (IB_QP_ALT_PATH |
+ IB_QP_ACCESS_FLAGS |
+ IB_QP_PKEY_INDEX),
+ [IB_QPT_XRC_INI] = (IB_QP_ALT_PATH |
+ IB_QP_ACCESS_FLAGS |
+ IB_QP_PKEY_INDEX),
+ [IB_QPT_XRC_TGT] = (IB_QP_ALT_PATH |
+ IB_QP_ACCESS_FLAGS |
+ IB_QP_PKEY_INDEX),
+ [IB_QPT_SMI] = (IB_QP_PKEY_INDEX |
+ IB_QP_QKEY),
+ [IB_QPT_GSI] = (IB_QP_PKEY_INDEX |
+ IB_QP_QKEY),
+ },
+ },
+ },
+ [IB_QPS_RTR] = {
+ [IB_QPS_RESET] = { .valid = 1 },
+ [IB_QPS_ERR] = { .valid = 1 },
+ [IB_QPS_RTS] = {
+ .valid = 1,
+ .req_param = {
+ [IB_QPT_UD] = IB_QP_SQ_PSN,
+ [IB_QPT_UC] = IB_QP_SQ_PSN,
+ [IB_QPT_RC] = (IB_QP_TIMEOUT |
+ IB_QP_RETRY_CNT |
+ IB_QP_RNR_RETRY |
+ IB_QP_SQ_PSN |
+ IB_QP_MAX_QP_RD_ATOMIC),
+ [IB_QPT_XRC_INI] = (IB_QP_TIMEOUT |
+ IB_QP_RETRY_CNT |
+ IB_QP_RNR_RETRY |
+ IB_QP_SQ_PSN |
+ IB_QP_MAX_QP_RD_ATOMIC),
+ [IB_QPT_XRC_TGT] = (IB_QP_TIMEOUT |
+ IB_QP_SQ_PSN),
+ [IB_QPT_SMI] = IB_QP_SQ_PSN,
+ [IB_QPT_GSI] = IB_QP_SQ_PSN,
+ },
+ .opt_param = {
+ [IB_QPT_UD] = (IB_QP_CUR_STATE |
+ IB_QP_QKEY),
+ [IB_QPT_UC] = (IB_QP_CUR_STATE |
+ IB_QP_ALT_PATH |
+ IB_QP_ACCESS_FLAGS |
+ IB_QP_PATH_MIG_STATE),
+ [IB_QPT_RC] = (IB_QP_CUR_STATE |
+ IB_QP_ALT_PATH |
+ IB_QP_ACCESS_FLAGS |
+ IB_QP_MIN_RNR_TIMER |
+ IB_QP_PATH_MIG_STATE),
+ [IB_QPT_XRC_INI] = (IB_QP_CUR_STATE |
+ IB_QP_ALT_PATH |
+ IB_QP_ACCESS_FLAGS |
+ IB_QP_PATH_MIG_STATE),
+ [IB_QPT_XRC_TGT] = (IB_QP_CUR_STATE |
+ IB_QP_ALT_PATH |
+ IB_QP_ACCESS_FLAGS |
+ IB_QP_MIN_RNR_TIMER |
+ IB_QP_PATH_MIG_STATE),
+ [IB_QPT_SMI] = (IB_QP_CUR_STATE |
+ IB_QP_QKEY),
+ [IB_QPT_GSI] = (IB_QP_CUR_STATE |
+ IB_QP_QKEY),
+ }
+ }
+ },
+ [IB_QPS_RTS] = {
+ [IB_QPS_RESET] = { .valid = 1 },
+ [IB_QPS_ERR] = { .valid = 1 },
+ [IB_QPS_RTS] = {
+ .valid = 1,
+ .opt_param = {
+ [IB_QPT_UD] = (IB_QP_CUR_STATE |
+ IB_QP_QKEY),
+ [IB_QPT_UC] = (IB_QP_CUR_STATE |
+ IB_QP_ACCESS_FLAGS |
+ IB_QP_ALT_PATH |
+ IB_QP_PATH_MIG_STATE),
+ [IB_QPT_RC] = (IB_QP_CUR_STATE |
+ IB_QP_ACCESS_FLAGS |
+ IB_QP_ALT_PATH |
+ IB_QP_PATH_MIG_STATE |
+ IB_QP_MIN_RNR_TIMER),
+ [IB_QPT_XRC_INI] = (IB_QP_CUR_STATE |
+ IB_QP_ACCESS_FLAGS |
+ IB_QP_ALT_PATH |
+ IB_QP_PATH_MIG_STATE),
+ [IB_QPT_XRC_TGT] = (IB_QP_CUR_STATE |
+ IB_QP_ACCESS_FLAGS |
+ IB_QP_ALT_PATH |
+ IB_QP_PATH_MIG_STATE |
+ IB_QP_MIN_RNR_TIMER),
+ [IB_QPT_SMI] = (IB_QP_CUR_STATE |
+ IB_QP_QKEY),
+ [IB_QPT_GSI] = (IB_QP_CUR_STATE |
+ IB_QP_QKEY),
+ }
+ },
+ [IB_QPS_SQD] = {
+ .valid = 1,
+ .opt_param = {
+ [IB_QPT_UD] = IB_QP_EN_SQD_ASYNC_NOTIFY,
+ [IB_QPT_UC] = IB_QP_EN_SQD_ASYNC_NOTIFY,
+ [IB_QPT_RC] = IB_QP_EN_SQD_ASYNC_NOTIFY,
+ [IB_QPT_XRC_INI] = IB_QP_EN_SQD_ASYNC_NOTIFY,
+ [IB_QPT_XRC_TGT] = IB_QP_EN_SQD_ASYNC_NOTIFY, /* ??? */
+ [IB_QPT_SMI] = IB_QP_EN_SQD_ASYNC_NOTIFY,
+ [IB_QPT_GSI] = IB_QP_EN_SQD_ASYNC_NOTIFY
+ }
+ },
+ },
+ [IB_QPS_SQD] = {
+ [IB_QPS_RESET] = { .valid = 1 },
+ [IB_QPS_ERR] = { .valid = 1 },
+ [IB_QPS_RTS] = {
+ .valid = 1,
+ .opt_param = {
+ [IB_QPT_UD] = (IB_QP_CUR_STATE |
+ IB_QP_QKEY),
+ [IB_QPT_UC] = (IB_QP_CUR_STATE |
+ IB_QP_ALT_PATH |
+ IB_QP_ACCESS_FLAGS |
+ IB_QP_PATH_MIG_STATE),
+ [IB_QPT_RC] = (IB_QP_CUR_STATE |
+ IB_QP_ALT_PATH |
+ IB_QP_ACCESS_FLAGS |
+ IB_QP_MIN_RNR_TIMER |
+ IB_QP_PATH_MIG_STATE),
+ [IB_QPT_XRC_INI] = (IB_QP_CUR_STATE |
+ IB_QP_ALT_PATH |
+ IB_QP_ACCESS_FLAGS |
+ IB_QP_PATH_MIG_STATE),
+ [IB_QPT_XRC_TGT] = (IB_QP_CUR_STATE |
+ IB_QP_ALT_PATH |
+ IB_QP_ACCESS_FLAGS |
+ IB_QP_MIN_RNR_TIMER |
+ IB_QP_PATH_MIG_STATE),
+ [IB_QPT_SMI] = (IB_QP_CUR_STATE |
+ IB_QP_QKEY),
+ [IB_QPT_GSI] = (IB_QP_CUR_STATE |
+ IB_QP_QKEY),
+ }
+ },
+ [IB_QPS_SQD] = {
+ .valid = 1,
+ .opt_param = {
+ [IB_QPT_UD] = (IB_QP_PKEY_INDEX |
+ IB_QP_QKEY),
+ [IB_QPT_UC] = (IB_QP_AV |
+ IB_QP_ALT_PATH |
+ IB_QP_ACCESS_FLAGS |
+ IB_QP_PKEY_INDEX |
+ IB_QP_PATH_MIG_STATE),
+ [IB_QPT_RC] = (IB_QP_PORT |
+ IB_QP_AV |
+ IB_QP_TIMEOUT |
+ IB_QP_RETRY_CNT |
+ IB_QP_RNR_RETRY |
+ IB_QP_MAX_QP_RD_ATOMIC |
+ IB_QP_MAX_DEST_RD_ATOMIC |
+ IB_QP_ALT_PATH |
+ IB_QP_ACCESS_FLAGS |
+ IB_QP_PKEY_INDEX |
+ IB_QP_MIN_RNR_TIMER |
+ IB_QP_PATH_MIG_STATE),
+ [IB_QPT_XRC_INI] = (IB_QP_PORT |
+ IB_QP_AV |
+ IB_QP_TIMEOUT |
+ IB_QP_RETRY_CNT |
+ IB_QP_RNR_RETRY |
+ IB_QP_MAX_QP_RD_ATOMIC |
+ IB_QP_ALT_PATH |
+ IB_QP_ACCESS_FLAGS |
+ IB_QP_PKEY_INDEX |
+ IB_QP_PATH_MIG_STATE),
+ [IB_QPT_XRC_TGT] = (IB_QP_PORT |
+ IB_QP_AV |
+ IB_QP_TIMEOUT |
+ IB_QP_MAX_DEST_RD_ATOMIC |
+ IB_QP_ALT_PATH |
+ IB_QP_ACCESS_FLAGS |
+ IB_QP_PKEY_INDEX |
+ IB_QP_MIN_RNR_TIMER |
+ IB_QP_PATH_MIG_STATE),
+ [IB_QPT_SMI] = (IB_QP_PKEY_INDEX |
+ IB_QP_QKEY),
+ [IB_QPT_GSI] = (IB_QP_PKEY_INDEX |
+ IB_QP_QKEY),
+ }
+ }
+ },
+ [IB_QPS_SQE] = {
+ [IB_QPS_RESET] = { .valid = 1 },
+ [IB_QPS_ERR] = { .valid = 1 },
+ [IB_QPS_RTS] = {
+ .valid = 1,
+ .opt_param = {
+ [IB_QPT_UD] = (IB_QP_CUR_STATE |
+ IB_QP_QKEY),
+ [IB_QPT_UC] = (IB_QP_CUR_STATE |
+ IB_QP_ACCESS_FLAGS),
+ [IB_QPT_SMI] = (IB_QP_CUR_STATE |
+ IB_QP_QKEY),
+ [IB_QPT_GSI] = (IB_QP_CUR_STATE |
+ IB_QP_QKEY),
+ }
+ }
+ },
+ [IB_QPS_ERR] = {
+ [IB_QPS_RESET] = { .valid = 1 },
+ [IB_QPS_ERR] = { .valid = 1 }
+ }
+};
+
+int ib_modify_qp_is_ok(enum ib_qp_state cur_state, enum ib_qp_state next_state,
+ enum ib_qp_type type, enum ib_qp_attr_mask mask,
+ enum rdma_link_layer ll)
+{
+ enum ib_qp_attr_mask req_param, opt_param;
+
+ if (cur_state < 0 || cur_state > IB_QPS_ERR ||
+ next_state < 0 || next_state > IB_QPS_ERR)
+ return 0;
+
+ if (mask & IB_QP_CUR_STATE &&
+ cur_state != IB_QPS_RTR && cur_state != IB_QPS_RTS &&
+ cur_state != IB_QPS_SQD && cur_state != IB_QPS_SQE)
+ return 0;
+
+ if (!qp_state_table[cur_state][next_state].valid)
+ return 0;
+
+ req_param = qp_state_table[cur_state][next_state].req_param[type];
+ opt_param = qp_state_table[cur_state][next_state].opt_param[type];
+
+ if ((mask & req_param) != req_param)
+ return 0;
+
+ if (mask & ~(req_param | opt_param | IB_QP_STATE))
+ return 0;
+
+ return 1;
+}
+EXPORT_SYMBOL(ib_modify_qp_is_ok);
+
+int ib_resolve_eth_dmac(struct ib_qp *qp,
+ struct ib_qp_attr *qp_attr, int *qp_attr_mask)
+{
+ int ret = 0;
+
+ if (*qp_attr_mask & IB_QP_AV) {
+ if (qp_attr->ah_attr.port_num < rdma_start_port(qp->device) ||
+ qp_attr->ah_attr.port_num > rdma_end_port(qp->device))
+ return -EINVAL;
+
+ if (!rdma_cap_eth_ah(qp->device, qp_attr->ah_attr.port_num))
+ return 0;
+
+ if (rdma_link_local_addr((struct in6_addr *)qp_attr->ah_attr.grh.dgid.raw)) {
+ rdma_get_ll_mac((struct in6_addr *)qp_attr->ah_attr.grh.dgid.raw,
+ qp_attr->ah_attr.dmac);
+ } else {
+ union ib_gid sgid;
+ struct ib_gid_attr sgid_attr;
+ int ifindex;
+ int hop_limit;
+
+ ret = ib_query_gid(qp->device,
+ qp_attr->ah_attr.port_num,
+ qp_attr->ah_attr.grh.sgid_index,
+ &sgid, &sgid_attr);
+
+ if (ret || !sgid_attr.ndev) {
+ if (!ret)
+ ret = -ENXIO;
+ goto out;
+ }
+
+ ifindex = sgid_attr.ndev->if_index;
+
+ ret = rdma_addr_find_l2_eth_by_grh(&sgid,
+ &qp_attr->ah_attr.grh.dgid,
+ qp_attr->ah_attr.dmac,
+ NULL, &ifindex, &hop_limit);
+
+ dev_put(sgid_attr.ndev);
+
+ qp_attr->ah_attr.grh.hop_limit = hop_limit;
+ }
+ }
+out:
+ return ret;
+}
+EXPORT_SYMBOL(ib_resolve_eth_dmac);
+
+
+int ib_modify_qp(struct ib_qp *qp,
+ struct ib_qp_attr *qp_attr,
+ int qp_attr_mask)
+{
+ int ret;
+
+ ret = ib_resolve_eth_dmac(qp, qp_attr, &qp_attr_mask);
+ if (ret)
+ return ret;
+
+ return qp->device->modify_qp(qp->real_qp, qp_attr, qp_attr_mask, NULL);
+}
+EXPORT_SYMBOL(ib_modify_qp);
+
+int ib_query_qp(struct ib_qp *qp,
+ struct ib_qp_attr *qp_attr,
+ int qp_attr_mask,
+ struct ib_qp_init_attr *qp_init_attr)
+{
+ return qp->device->query_qp ?
+ qp->device->query_qp(qp->real_qp, qp_attr, qp_attr_mask, qp_init_attr) :
+ -ENOSYS;
+}
+EXPORT_SYMBOL(ib_query_qp);
+
+int ib_close_qp(struct ib_qp *qp)
+{
+ struct ib_qp *real_qp;
+ unsigned long flags;
+
+ real_qp = qp->real_qp;
+ if (real_qp == qp)
+ return -EINVAL;
+
+ spin_lock_irqsave(&real_qp->device->event_handler_lock, flags);
+ list_del(&qp->open_list);
+ spin_unlock_irqrestore(&real_qp->device->event_handler_lock, flags);
+
+ atomic_dec(&real_qp->usecnt);
+ kfree(qp);
+
+ return 0;
+}
+EXPORT_SYMBOL(ib_close_qp);
+
+static int __ib_destroy_shared_qp(struct ib_qp *qp)
+{
+ struct ib_xrcd *xrcd;
+ struct ib_qp *real_qp;
+ int ret;
+
+ real_qp = qp->real_qp;
+ xrcd = real_qp->xrcd;
+
+ mutex_lock(&xrcd->tgt_qp_mutex);
+ ib_close_qp(qp);
+ if (atomic_read(&real_qp->usecnt) == 0)
+ list_del(&real_qp->xrcd_list);
+ else
+ real_qp = NULL;
+ mutex_unlock(&xrcd->tgt_qp_mutex);
+
+ if (real_qp) {
+ ret = ib_destroy_qp(real_qp);
+ if (!ret)
+ atomic_dec(&xrcd->usecnt);
+ else
+ __ib_insert_xrcd_qp(xrcd, real_qp);
+ }
+
+ return 0;
+}
+
+int ib_destroy_qp(struct ib_qp *qp)
+{
+ struct ib_pd *pd;
+ struct ib_cq *scq, *rcq;
+ struct ib_srq *srq;
+ struct ib_rwq_ind_table *ind_tbl;
+ int ret;
+
+ if (atomic_read(&qp->usecnt))
+ return -EBUSY;
+
+ if (qp->real_qp != qp)
+ return __ib_destroy_shared_qp(qp);
+
+ pd = qp->pd;
+ scq = qp->send_cq;
+ rcq = qp->recv_cq;
+ srq = qp->srq;
+ ind_tbl = qp->rwq_ind_tbl;
+
+ ret = qp->device->destroy_qp(qp);
+ if (!ret) {
+ if (pd)
+ atomic_dec(&pd->usecnt);
+ if (scq)
+ atomic_dec(&scq->usecnt);
+ if (rcq)
+ atomic_dec(&rcq->usecnt);
+ if (srq)
+ atomic_dec(&srq->usecnt);
+ if (ind_tbl)
+ atomic_dec(&ind_tbl->usecnt);
+ }
+
+ return ret;
+}
+EXPORT_SYMBOL(ib_destroy_qp);
+
+/* Completion queues */
+
+struct ib_cq *ib_create_cq(struct ib_device *device,
+ ib_comp_handler comp_handler,
+ void (*event_handler)(struct ib_event *, void *),
+ void *cq_context,
+ const struct ib_cq_init_attr *cq_attr)
+{
+ struct ib_cq *cq;
+
+ cq = device->create_cq(device, cq_attr, NULL, NULL);
+
+ if (!IS_ERR(cq)) {
+ cq->device = device;
+ cq->uobject = NULL;
+ cq->comp_handler = comp_handler;
+ cq->event_handler = event_handler;
+ cq->cq_context = cq_context;
+ atomic_set(&cq->usecnt, 0);
+ }
+
+ return cq;
+}
+EXPORT_SYMBOL(ib_create_cq);
+
+int ib_modify_cq(struct ib_cq *cq, u16 cq_count, u16 cq_period)
+{
+ return cq->device->modify_cq ?
+ cq->device->modify_cq(cq, cq_count, cq_period) : -ENOSYS;
+}
+EXPORT_SYMBOL(ib_modify_cq);
+
+int ib_destroy_cq(struct ib_cq *cq)
+{
+ if (atomic_read(&cq->usecnt))
+ return -EBUSY;
+
+ return cq->device->destroy_cq(cq);
+}
+EXPORT_SYMBOL(ib_destroy_cq);
+
+int ib_resize_cq(struct ib_cq *cq, int cqe)
+{
+ return cq->device->resize_cq ?
+ cq->device->resize_cq(cq, cqe, NULL) : -ENOSYS;
+}
+EXPORT_SYMBOL(ib_resize_cq);
+
+/* Memory regions */
+
+int ib_dereg_mr(struct ib_mr *mr)
+{
+ struct ib_pd *pd = mr->pd;
+ int ret;
+
+ ret = mr->device->dereg_mr(mr);
+ if (!ret)
+ atomic_dec(&pd->usecnt);
+
+ return ret;
+}
+EXPORT_SYMBOL(ib_dereg_mr);
+
+/**
+ * ib_alloc_mr() - Allocates a memory region
+ * @pd: protection domain associated with the region
+ * @mr_type: memory region type
+ * @max_num_sg: maximum sg entries available for registration.
+ *
+ * Notes:
+ * Memory registeration page/sg lists must not exceed max_num_sg.
+ * For mr_type IB_MR_TYPE_MEM_REG, the total length cannot exceed
+ * max_num_sg * used_page_size.
+ *
+ */
+struct ib_mr *ib_alloc_mr(struct ib_pd *pd,
+ enum ib_mr_type mr_type,
+ u32 max_num_sg)
+{
+ struct ib_mr *mr;
+
+ if (!pd->device->alloc_mr)
+ return ERR_PTR(-ENOSYS);
+
+ mr = pd->device->alloc_mr(pd, mr_type, max_num_sg);
+ if (!IS_ERR(mr)) {
+ mr->device = pd->device;
+ mr->pd = pd;
+ mr->uobject = NULL;
+ atomic_inc(&pd->usecnt);
+ mr->need_inval = false;
+ }
+
+ return mr;
+}
+EXPORT_SYMBOL(ib_alloc_mr);
+
+/* "Fast" memory regions */
+
+struct ib_fmr *ib_alloc_fmr(struct ib_pd *pd,
+ int mr_access_flags,
+ struct ib_fmr_attr *fmr_attr)
+{
+ struct ib_fmr *fmr;
+
+ if (!pd->device->alloc_fmr)
+ return ERR_PTR(-ENOSYS);
+
+ fmr = pd->device->alloc_fmr(pd, mr_access_flags, fmr_attr);
+ if (!IS_ERR(fmr)) {
+ fmr->device = pd->device;
+ fmr->pd = pd;
+ atomic_inc(&pd->usecnt);
+ }
+
+ return fmr;
+}
+EXPORT_SYMBOL(ib_alloc_fmr);
+
+int ib_unmap_fmr(struct list_head *fmr_list)
+{
+ struct ib_fmr *fmr;
+
+ if (list_empty(fmr_list))
+ return 0;
+
+ fmr = list_entry(fmr_list->next, struct ib_fmr, list);
+ return fmr->device->unmap_fmr(fmr_list);
+}
+EXPORT_SYMBOL(ib_unmap_fmr);
+
+int ib_dealloc_fmr(struct ib_fmr *fmr)
+{
+ struct ib_pd *pd;
+ int ret;
+
+ pd = fmr->pd;
+ ret = fmr->device->dealloc_fmr(fmr);
+ if (!ret)
+ atomic_dec(&pd->usecnt);
+
+ return ret;
+}
+EXPORT_SYMBOL(ib_dealloc_fmr);
+
+/* Multicast groups */
+
+int ib_attach_mcast(struct ib_qp *qp, union ib_gid *gid, u16 lid)
+{
+ int ret;
+
+ if (!qp->device->attach_mcast)
+ return -ENOSYS;
+ if (gid->raw[0] != 0xff || qp->qp_type != IB_QPT_UD)
+ return -EINVAL;
+
+ ret = qp->device->attach_mcast(qp, gid, lid);
+ if (!ret)
+ atomic_inc(&qp->usecnt);
+ return ret;
+}
+EXPORT_SYMBOL(ib_attach_mcast);
+
+int ib_detach_mcast(struct ib_qp *qp, union ib_gid *gid, u16 lid)
+{
+ int ret;
+
+ if (!qp->device->detach_mcast)
+ return -ENOSYS;
+ if (gid->raw[0] != 0xff || qp->qp_type != IB_QPT_UD)
+ return -EINVAL;
+
+ ret = qp->device->detach_mcast(qp, gid, lid);
+ if (!ret)
+ atomic_dec(&qp->usecnt);
+ return ret;
+}
+EXPORT_SYMBOL(ib_detach_mcast);
+
+struct ib_xrcd *ib_alloc_xrcd(struct ib_device *device)
+{
+ struct ib_xrcd *xrcd;
+
+ if (!device->alloc_xrcd)
+ return ERR_PTR(-ENOSYS);
+
+ xrcd = device->alloc_xrcd(device, NULL, NULL);
+ if (!IS_ERR(xrcd)) {
+ xrcd->device = device;
+ xrcd->inode = NULL;
+ atomic_set(&xrcd->usecnt, 0);
+ mutex_init(&xrcd->tgt_qp_mutex);
+ INIT_LIST_HEAD(&xrcd->tgt_qp_list);
+ }
+
+ return xrcd;
+}
+EXPORT_SYMBOL(ib_alloc_xrcd);
+
+int ib_dealloc_xrcd(struct ib_xrcd *xrcd)
+{
+ struct ib_qp *qp;
+ int ret;
+
+ if (atomic_read(&xrcd->usecnt))
+ return -EBUSY;
+
+ while (!list_empty(&xrcd->tgt_qp_list)) {
+ qp = list_entry(xrcd->tgt_qp_list.next, struct ib_qp, xrcd_list);
+ ret = ib_destroy_qp(qp);
+ if (ret)
+ return ret;
+ }
+
+ return xrcd->device->dealloc_xrcd(xrcd);
+}
+EXPORT_SYMBOL(ib_dealloc_xrcd);
+
+/**
+ * ib_create_wq - Creates a WQ associated with the specified protection
+ * domain.
+ * @pd: The protection domain associated with the WQ.
+ * @wq_init_attr: A list of initial attributes required to create the
+ * WQ. If WQ creation succeeds, then the attributes are updated to
+ * the actual capabilities of the created WQ.
+ *
+ * wq_init_attr->max_wr and wq_init_attr->max_sge determine
+ * the requested size of the WQ, and set to the actual values allocated
+ * on return.
+ * If ib_create_wq() succeeds, then max_wr and max_sge will always be
+ * at least as large as the requested values.
+ */
+struct ib_wq *ib_create_wq(struct ib_pd *pd,
+ struct ib_wq_init_attr *wq_attr)
+{
+ struct ib_wq *wq;
+
+ if (!pd->device->create_wq)
+ return ERR_PTR(-ENOSYS);
+
+ wq = pd->device->create_wq(pd, wq_attr, NULL);
+ if (!IS_ERR(wq)) {
+ wq->event_handler = wq_attr->event_handler;
+ wq->wq_context = wq_attr->wq_context;
+ wq->wq_type = wq_attr->wq_type;
+ wq->cq = wq_attr->cq;
+ wq->device = pd->device;
+ wq->pd = pd;
+ wq->uobject = NULL;
+ atomic_inc(&pd->usecnt);
+ atomic_inc(&wq_attr->cq->usecnt);
+ atomic_set(&wq->usecnt, 0);
+ }
+ return wq;
+}
+EXPORT_SYMBOL(ib_create_wq);
+
+/**
+ * ib_destroy_wq - Destroys the specified WQ.
+ * @wq: The WQ to destroy.
+ */
+int ib_destroy_wq(struct ib_wq *wq)
+{
+ int err;
+ struct ib_cq *cq = wq->cq;
+ struct ib_pd *pd = wq->pd;
+
+ if (atomic_read(&wq->usecnt))
+ return -EBUSY;
+
+ err = wq->device->destroy_wq(wq);
+ if (!err) {
+ atomic_dec(&pd->usecnt);
+ atomic_dec(&cq->usecnt);
+ }
+ return err;
+}
+EXPORT_SYMBOL(ib_destroy_wq);
+
+/**
+ * ib_modify_wq - Modifies the specified WQ.
+ * @wq: The WQ to modify.
+ * @wq_attr: On input, specifies the WQ attributes to modify.
+ * @wq_attr_mask: A bit-mask used to specify which attributes of the WQ
+ * are being modified.
+ * On output, the current values of selected WQ attributes are returned.
+ */
+int ib_modify_wq(struct ib_wq *wq, struct ib_wq_attr *wq_attr,
+ u32 wq_attr_mask)
+{
+ int err;
+
+ if (!wq->device->modify_wq)
+ return -ENOSYS;
+
+ err = wq->device->modify_wq(wq, wq_attr, wq_attr_mask, NULL);
+ return err;
+}
+EXPORT_SYMBOL(ib_modify_wq);
+
+/*
+ * ib_create_rwq_ind_table - Creates a RQ Indirection Table.
+ * @device: The device on which to create the rwq indirection table.
+ * @ib_rwq_ind_table_init_attr: A list of initial attributes required to
+ * create the Indirection Table.
+ *
+ * Note: The life time of ib_rwq_ind_table_init_attr->ind_tbl is not less
+ * than the created ib_rwq_ind_table object and the caller is responsible
+ * for its memory allocation/free.
+ */
+struct ib_rwq_ind_table *ib_create_rwq_ind_table(struct ib_device *device,
+ struct ib_rwq_ind_table_init_attr *init_attr)
+{
+ struct ib_rwq_ind_table *rwq_ind_table;
+ int i;
+ u32 table_size;
+
+ if (!device->create_rwq_ind_table)
+ return ERR_PTR(-ENOSYS);
+
+ table_size = (1 << init_attr->log_ind_tbl_size);
+ rwq_ind_table = device->create_rwq_ind_table(device,
+ init_attr, NULL);
+ if (IS_ERR(rwq_ind_table))
+ return rwq_ind_table;
+
+ rwq_ind_table->ind_tbl = init_attr->ind_tbl;
+ rwq_ind_table->log_ind_tbl_size = init_attr->log_ind_tbl_size;
+ rwq_ind_table->device = device;
+ rwq_ind_table->uobject = NULL;
+ atomic_set(&rwq_ind_table->usecnt, 0);
+
+ for (i = 0; i < table_size; i++)
+ atomic_inc(&rwq_ind_table->ind_tbl[i]->usecnt);
+
+ return rwq_ind_table;
+}
+EXPORT_SYMBOL(ib_create_rwq_ind_table);
+
+/*
+ * ib_destroy_rwq_ind_table - Destroys the specified Indirection Table.
+ * @wq_ind_table: The Indirection Table to destroy.
+*/
+int ib_destroy_rwq_ind_table(struct ib_rwq_ind_table *rwq_ind_table)
+{
+ int err, i;
+ u32 table_size = (1 << rwq_ind_table->log_ind_tbl_size);
+ struct ib_wq **ind_tbl = rwq_ind_table->ind_tbl;
+
+ if (atomic_read(&rwq_ind_table->usecnt))
+ return -EBUSY;
+
+ err = rwq_ind_table->device->destroy_rwq_ind_table(rwq_ind_table);
+ if (!err) {
+ for (i = 0; i < table_size; i++)
+ atomic_dec(&ind_tbl[i]->usecnt);
+ }
+
+ return err;
+}
+EXPORT_SYMBOL(ib_destroy_rwq_ind_table);
+
+struct ib_flow *ib_create_flow(struct ib_qp *qp,
+ struct ib_flow_attr *flow_attr,
+ int domain)
+{
+ struct ib_flow *flow_id;
+ if (!qp->device->create_flow)
+ return ERR_PTR(-ENOSYS);
+
+ flow_id = qp->device->create_flow(qp, flow_attr, domain);
+ if (!IS_ERR(flow_id))
+ atomic_inc(&qp->usecnt);
+ return flow_id;
+}
+EXPORT_SYMBOL(ib_create_flow);
+
+int ib_destroy_flow(struct ib_flow *flow_id)
+{
+ int err;
+ struct ib_qp *qp = flow_id->qp;
+
+ err = qp->device->destroy_flow(flow_id);
+ if (!err)
+ atomic_dec(&qp->usecnt);
+ return err;
+}
+EXPORT_SYMBOL(ib_destroy_flow);
+
+int ib_check_mr_status(struct ib_mr *mr, u32 check_mask,
+ struct ib_mr_status *mr_status)
+{
+ return mr->device->check_mr_status ?
+ mr->device->check_mr_status(mr, check_mask, mr_status) : -ENOSYS;
+}
+EXPORT_SYMBOL(ib_check_mr_status);
+
+int ib_set_vf_link_state(struct ib_device *device, int vf, u8 port,
+ int state)
+{
+ if (!device->set_vf_link_state)
+ return -ENOSYS;
+
+ return device->set_vf_link_state(device, vf, port, state);
+}
+EXPORT_SYMBOL(ib_set_vf_link_state);
+
+int ib_get_vf_config(struct ib_device *device, int vf, u8 port,
+ struct ifla_vf_info *info)
+{
+ if (!device->get_vf_config)
+ return -ENOSYS;
+
+ return device->get_vf_config(device, vf, port, info);
+}
+EXPORT_SYMBOL(ib_get_vf_config);
+
+int ib_get_vf_stats(struct ib_device *device, int vf, u8 port,
+ struct ifla_vf_stats *stats)
+{
+ if (!device->get_vf_stats)
+ return -ENOSYS;
+
+ return device->get_vf_stats(device, vf, port, stats);
+}
+EXPORT_SYMBOL(ib_get_vf_stats);
+
+int ib_set_vf_guid(struct ib_device *device, int vf, u8 port, u64 guid,
+ int type)
+{
+ if (!device->set_vf_guid)
+ return -ENOSYS;
+
+ return device->set_vf_guid(device, vf, port, guid, type);
+}
+EXPORT_SYMBOL(ib_set_vf_guid);
+
+/**
+ * ib_map_mr_sg() - Map the largest prefix of a dma mapped SG list
+ * and set it the memory region.
+ * @mr: memory region
+ * @sg: dma mapped scatterlist
+ * @sg_nents: number of entries in sg
+ * @sg_offset: offset in bytes into sg
+ * @page_size: page vector desired page size
+ *
+ * Constraints:
+ * - The first sg element is allowed to have an offset.
+ * - Each sg element must either be aligned to page_size or virtually
+ * contiguous to the previous element. In case an sg element has a
+ * non-contiguous offset, the mapping prefix will not include it.
+ * - The last sg element is allowed to have length less than page_size.
+ * - If sg_nents total byte length exceeds the mr max_num_sge * page_size
+ * then only max_num_sg entries will be mapped.
+ * - If the MR was allocated with type IB_MR_TYPE_SG_GAPS, none of these
+ * constraints holds and the page_size argument is ignored.
+ *
+ * Returns the number of sg elements that were mapped to the memory region.
+ *
+ * After this completes successfully, the memory region
+ * is ready for registration.
+ */
+int ib_map_mr_sg(struct ib_mr *mr, struct scatterlist *sg, int sg_nents,
+ unsigned int *sg_offset, unsigned int page_size)
+{
+ if (unlikely(!mr->device->map_mr_sg))
+ return -ENOSYS;
+
+ mr->page_size = page_size;
+
+ return mr->device->map_mr_sg(mr, sg, sg_nents, sg_offset);
+}
+EXPORT_SYMBOL(ib_map_mr_sg);
+
+/**
+ * ib_sg_to_pages() - Convert the largest prefix of a sg list
+ * to a page vector
+ * @mr: memory region
+ * @sgl: dma mapped scatterlist
+ * @sg_nents: number of entries in sg
+ * @sg_offset_p: IN: start offset in bytes into sg
+ * OUT: offset in bytes for element n of the sg of the first
+ * byte that has not been processed where n is the return
+ * value of this function.
+ * @set_page: driver page assignment function pointer
+ *
+ * Core service helper for drivers to convert the largest
+ * prefix of given sg list to a page vector. The sg list
+ * prefix converted is the prefix that meet the requirements
+ * of ib_map_mr_sg.
+ *
+ * Returns the number of sg elements that were assigned to
+ * a page vector.
+ */
+int ib_sg_to_pages(struct ib_mr *mr, struct scatterlist *sgl, int sg_nents,
+ unsigned int *sg_offset_p, int (*set_page)(struct ib_mr *, u64))
+{
+ struct scatterlist *sg;
+ u64 last_end_dma_addr = 0;
+ unsigned int sg_offset = sg_offset_p ? *sg_offset_p : 0;
+ unsigned int last_page_off = 0;
+ u64 page_mask = ~((u64)mr->page_size - 1);
+ int i, ret;
+
+ if (unlikely(sg_nents <= 0 || sg_offset > sg_dma_len(&sgl[0])))
+ return -EINVAL;
+
+ mr->iova = sg_dma_address(&sgl[0]) + sg_offset;
+ mr->length = 0;
+
+ for_each_sg(sgl, sg, sg_nents, i) {
+ u64 dma_addr = sg_dma_address(sg) + sg_offset;
+ u64 prev_addr = dma_addr;
+ unsigned int dma_len = sg_dma_len(sg) - sg_offset;
+ u64 end_dma_addr = dma_addr + dma_len;
+ u64 page_addr = dma_addr & page_mask;
+
+ /*
+ * For the second and later elements, check whether either the
+ * end of element i-1 or the start of element i is not aligned
+ * on a page boundary.
+ */
+ if (i && (last_page_off != 0 || page_addr != dma_addr)) {
+ /* Stop mapping if there is a gap. */
+ if (last_end_dma_addr != dma_addr)
+ break;
+
+ /*
+ * Coalesce this element with the last. If it is small
+ * enough just update mr->length. Otherwise start
+ * mapping from the next page.
+ */
+ goto next_page;
+ }
+
+ do {
+ ret = set_page(mr, page_addr);
+ if (unlikely(ret < 0)) {
+ sg_offset = prev_addr - sg_dma_address(sg);
+ mr->length += prev_addr - dma_addr;
+ if (sg_offset_p)
+ *sg_offset_p = sg_offset;
+ return i || sg_offset ? i : ret;
+ }
+ prev_addr = page_addr;
+next_page:
+ page_addr += mr->page_size;
+ } while (page_addr < end_dma_addr);
+
+ mr->length += dma_len;
+ last_end_dma_addr = end_dma_addr;
+ last_page_off = end_dma_addr & ~page_mask;
+
+ sg_offset = 0;
+ }
+
+ if (sg_offset_p)
+ *sg_offset_p = 0;
+ return i;
+}
+EXPORT_SYMBOL(ib_sg_to_pages);
+
+struct ib_drain_cqe {
+ struct ib_cqe cqe;
+ struct completion done;
+};
+
+static void ib_drain_qp_done(struct ib_cq *cq, struct ib_wc *wc)
+{
+ struct ib_drain_cqe *cqe = container_of(wc->wr_cqe, struct ib_drain_cqe,
+ cqe);
+
+ complete(&cqe->done);
+}
+
+/*
+ * Post a WR and block until its completion is reaped for the SQ.
+ */
+static void __ib_drain_sq(struct ib_qp *qp)
+{
+ struct ib_qp_attr attr = { .qp_state = IB_QPS_ERR };
+ struct ib_drain_cqe sdrain;
+ struct ib_send_wr swr = {}, *bad_swr;
+ int ret;
+
+ if (qp->send_cq->poll_ctx == IB_POLL_DIRECT) {
+ WARN_ONCE(qp->send_cq->poll_ctx == IB_POLL_DIRECT,
+ "IB_POLL_DIRECT poll_ctx not supported for drain\n");
+ return;
+ }
+
+ swr.wr_cqe = &sdrain.cqe;
+ sdrain.cqe.done = ib_drain_qp_done;
+ init_completion(&sdrain.done);
+
+ ret = ib_modify_qp(qp, &attr, IB_QP_STATE);
+ if (ret) {
+ WARN_ONCE(ret, "failed to drain send queue: %d\n", ret);
+ return;
+ }
+
+ ret = ib_post_send(qp, &swr, &bad_swr);
+ if (ret) {
+ WARN_ONCE(ret, "failed to drain send queue: %d\n", ret);
+ return;
+ }
+
+ wait_for_completion(&sdrain.done);
+}
+
+/*
+ * Post a WR and block until its completion is reaped for the RQ.
+ */
+static void __ib_drain_rq(struct ib_qp *qp)
+{
+ struct ib_qp_attr attr = { .qp_state = IB_QPS_ERR };
+ struct ib_drain_cqe rdrain;
+ struct ib_recv_wr rwr = {}, *bad_rwr;
+ int ret;
+
+ if (qp->recv_cq->poll_ctx == IB_POLL_DIRECT) {
+ WARN_ONCE(qp->recv_cq->poll_ctx == IB_POLL_DIRECT,
+ "IB_POLL_DIRECT poll_ctx not supported for drain\n");
+ return;
+ }
+
+ rwr.wr_cqe = &rdrain.cqe;
+ rdrain.cqe.done = ib_drain_qp_done;
+ init_completion(&rdrain.done);
+
+ ret = ib_modify_qp(qp, &attr, IB_QP_STATE);
+ if (ret) {
+ WARN_ONCE(ret, "failed to drain recv queue: %d\n", ret);
+ return;
+ }
+
+ ret = ib_post_recv(qp, &rwr, &bad_rwr);
+ if (ret) {
+ WARN_ONCE(ret, "failed to drain recv queue: %d\n", ret);
+ return;
+ }
+
+ wait_for_completion(&rdrain.done);
+}
+
+/**
+ * ib_drain_sq() - Block until all SQ CQEs have been consumed by the
+ * application.
+ * @qp: queue pair to drain
+ *
+ * If the device has a provider-specific drain function, then
+ * call that. Otherwise call the generic drain function
+ * __ib_drain_sq().
+ *
+ * The caller must:
+ *
+ * ensure there is room in the CQ and SQ for the drain work request and
+ * completion.
+ *
+ * allocate the CQ using ib_alloc_cq() and the CQ poll context cannot be
+ * IB_POLL_DIRECT.
+ *
+ * ensure that there are no other contexts that are posting WRs concurrently.
+ * Otherwise the drain is not guaranteed.
+ */
+void ib_drain_sq(struct ib_qp *qp)
+{
+ if (qp->device->drain_sq)
+ qp->device->drain_sq(qp);
+ else
+ __ib_drain_sq(qp);
+}
+EXPORT_SYMBOL(ib_drain_sq);
+
+/**
+ * ib_drain_rq() - Block until all RQ CQEs have been consumed by the
+ * application.
+ * @qp: queue pair to drain
+ *
+ * If the device has a provider-specific drain function, then
+ * call that. Otherwise call the generic drain function
+ * __ib_drain_rq().
+ *
+ * The caller must:
+ *
+ * ensure there is room in the CQ and RQ for the drain work request and
+ * completion.
+ *
+ * allocate the CQ using ib_alloc_cq() and the CQ poll context cannot be
+ * IB_POLL_DIRECT.
+ *
+ * ensure that there are no other contexts that are posting WRs concurrently.
+ * Otherwise the drain is not guaranteed.
+ */
+void ib_drain_rq(struct ib_qp *qp)
+{
+ if (qp->device->drain_rq)
+ qp->device->drain_rq(qp);
+ else
+ __ib_drain_rq(qp);
+}
+EXPORT_SYMBOL(ib_drain_rq);
+
+/**
+ * ib_drain_qp() - Block until all CQEs have been consumed by the
+ * application on both the RQ and SQ.
+ * @qp: queue pair to drain
+ *
+ * The caller must:
+ *
+ * ensure there is room in the CQ(s), SQ, and RQ for drain work requests
+ * and completions.
+ *
+ * allocate the CQs using ib_alloc_cq() and the CQ poll context cannot be
+ * IB_POLL_DIRECT.
+ *
+ * ensure that there are no other contexts that are posting WRs concurrently.
+ * Otherwise the drain is not guaranteed.
+ */
+void ib_drain_qp(struct ib_qp *qp)
+{
+ ib_drain_sq(qp);
+ if (!qp->srq)
+ ib_drain_rq(qp);
+}
+EXPORT_SYMBOL(ib_drain_qp);
diff --git a/sys/ofed/drivers/infiniband/core/iwcm.c b/sys/ofed/drivers/infiniband/core/iwcm.c
deleted file mode 100644
index 764754b..0000000
--- a/sys/ofed/drivers/infiniband/core/iwcm.c
+++ /dev/null
@@ -1,1317 +0,0 @@
-/*
- * Copyright (c) 2004, 2005 Intel Corporation. All rights reserved.
- * Copyright (c) 2004 Topspin Corporation. All rights reserved.
- * Copyright (c) 2004, 2005 Voltaire Corporation. All rights reserved.
- * Copyright (c) 2005 Sun Microsystems, Inc. All rights reserved.
- * Copyright (c) 2005 Open Grid Computing, Inc. All rights reserved.
- * Copyright (c) 2005 Network Appliance, Inc. All rights reserved.
- * Copyright (c) 2016 Chelsio Communications. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- */
-#include "opt_inet.h"
-
-#include <linux/dma-mapping.h>
-#include <linux/err.h>
-#include <linux/idr.h>
-#include <linux/interrupt.h>
-#include <linux/rbtree.h>
-#include <linux/sched.h>
-#include <linux/spinlock.h>
-#include <linux/workqueue.h>
-#include <linux/completion.h>
-#include <linux/slab.h>
-#include <linux/module.h>
-#include <linux/string.h>
-#include <linux/wait.h>
-#include <netinet/tcp.h>
-#include <sys/mutex.h>
-
-#include <rdma/rdma_cm.h>
-#include <rdma/iw_cm.h>
-#include <rdma/ib_addr.h>
-
-#include "iwcm.h"
-
-MODULE_AUTHOR("Tom Tucker");
-MODULE_DESCRIPTION("iWARP CM");
-MODULE_LICENSE("Dual BSD/GPL");
-
-static struct workqueue_struct *iwcm_wq;
-struct iwcm_work {
- struct work_struct work;
- struct iwcm_id_private *cm_id;
- struct list_head list;
- struct iw_cm_event event;
- struct list_head free_list;
-};
-struct iwcm_listen_work {
- struct work_struct work;
- struct iw_cm_id *cm_id;
-};
-
-static LIST_HEAD(listen_port_list);
-
-static DEFINE_MUTEX(listen_port_mutex);
-
-struct listen_port_info {
- struct list_head list;
- uint16_t port_num;
- uint32_t refcnt;
-};
-
-static int32_t
-add_port_to_listenlist(uint16_t port)
-{
- struct listen_port_info *port_info;
- int err = 0;
-
- mutex_lock(&listen_port_mutex);
-
- list_for_each_entry(port_info, &listen_port_list, list)
- if (port_info->port_num == port)
- goto found_port;
-
- port_info = kmalloc(sizeof(*port_info), GFP_KERNEL);
- if (!port_info) {
- err = -ENOMEM;
- mutex_unlock(&listen_port_mutex);
- goto out;
- }
-
- port_info->port_num = port;
- port_info->refcnt = 0;
-
- list_add(&port_info->list, &listen_port_list);
-
-found_port:
- ++(port_info->refcnt);
- mutex_unlock(&listen_port_mutex);
- return port_info->refcnt;
-out:
- return err;
-}
-
-static int32_t
-rem_port_from_listenlist(uint16_t port)
-{
- struct listen_port_info *port_info;
- int ret, found_port = 0;
-
- mutex_lock(&listen_port_mutex);
-
- list_for_each_entry(port_info, &listen_port_list, list)
- if (port_info->port_num == port) {
- found_port = 1;
- break;
- }
-
- if (found_port) {
- --(port_info->refcnt);
- ret = port_info->refcnt;
- if (port_info->refcnt == 0) {
- /* Remove this entry from the list as there are no
- * more listeners for this port_num.
- */
- list_del(&port_info->list);
- kfree(port_info);
- }
- } else {
- ret = -EINVAL;
- }
- mutex_unlock(&listen_port_mutex);
- return ret;
-
-}
-
-/*
- * The following services provide a mechanism for pre-allocating iwcm_work
- * elements. The design pre-allocates them based on the cm_id type:
- * LISTENING IDS: Get enough elements preallocated to handle the
- * listen backlog.
- * ACTIVE IDS: 4: CONNECT_REPLY, ESTABLISHED, DISCONNECT, CLOSE
- * PASSIVE IDS: 3: ESTABLISHED, DISCONNECT, CLOSE
- *
- * Allocating them in connect and listen avoids having to deal
- * with allocation failures on the event upcall from the provider (which
- * is called in the interrupt context).
- *
- * One exception is when creating the cm_id for incoming connection requests.
- * There are two cases:
- * 1) in the event upcall, cm_event_handler(), for a listening cm_id. If
- * the backlog is exceeded, then no more connection request events will
- * be processed. cm_event_handler() returns -ENOMEM in this case. Its up
- * to the provider to reject the connection request.
- * 2) in the connection request workqueue handler, cm_conn_req_handler().
- * If work elements cannot be allocated for the new connect request cm_id,
- * then IWCM will call the provider reject method. This is ok since
- * cm_conn_req_handler() runs in the workqueue thread context.
- */
-
-static struct iwcm_work *get_work(struct iwcm_id_private *cm_id_priv)
-{
- struct iwcm_work *work;
-
- if (list_empty(&cm_id_priv->work_free_list))
- return NULL;
- work = list_entry(cm_id_priv->work_free_list.next, struct iwcm_work,
- free_list);
- list_del_init(&work->free_list);
- return work;
-}
-
-static void put_work(struct iwcm_work *work)
-{
- list_add(&work->free_list, &work->cm_id->work_free_list);
-}
-
-static void dealloc_work_entries(struct iwcm_id_private *cm_id_priv)
-{
- struct list_head *e, *tmp;
-
- list_for_each_safe(e, tmp, &cm_id_priv->work_free_list)
- kfree(list_entry(e, struct iwcm_work, free_list));
-}
-
-static int alloc_work_entries(struct iwcm_id_private *cm_id_priv, int count)
-{
- struct iwcm_work *work;
-
- BUG_ON(!list_empty(&cm_id_priv->work_free_list));
- while (count--) {
- work = kmalloc(sizeof(struct iwcm_work), GFP_KERNEL);
- if (!work) {
- dealloc_work_entries(cm_id_priv);
- return -ENOMEM;
- }
- work->cm_id = cm_id_priv;
- INIT_LIST_HEAD(&work->list);
- put_work(work);
- }
- return 0;
-}
-
-/*
- * Save private data from incoming connection requests to
- * iw_cm_event, so the low level driver doesn't have to. Adjust
- * the event ptr to point to the local copy.
- */
-static int copy_private_data(struct iw_cm_event *event)
-{
- void *p;
-
- p = kmemdup(event->private_data, event->private_data_len, GFP_ATOMIC);
- if (!p)
- return -ENOMEM;
- event->private_data = p;
- return 0;
-}
-
-static void free_cm_id(struct iwcm_id_private *cm_id_priv)
-{
- dealloc_work_entries(cm_id_priv);
- kfree(cm_id_priv);
-}
-
-/*
- * Release a reference on cm_id. If the last reference is being
- * released, enable the waiting thread (in iw_destroy_cm_id) to
- * get woken up, and return 1 if a thread is already waiting.
- */
-static int iwcm_deref_id(struct iwcm_id_private *cm_id_priv)
-{
- BUG_ON(atomic_read(&cm_id_priv->refcount)==0);
- if (atomic_dec_and_test(&cm_id_priv->refcount)) {
- BUG_ON(!list_empty(&cm_id_priv->work_list));
- complete(&cm_id_priv->destroy_comp);
- return 1;
- }
-
- return 0;
-}
-
-static void add_ref(struct iw_cm_id *cm_id)
-{
- struct iwcm_id_private *cm_id_priv;
- cm_id_priv = container_of(cm_id, struct iwcm_id_private, id);
- atomic_inc(&cm_id_priv->refcount);
-}
-
-static void rem_ref(struct iw_cm_id *cm_id)
-{
- struct iwcm_id_private *cm_id_priv;
- int cb_destroy;
-
- cm_id_priv = container_of(cm_id, struct iwcm_id_private, id);
-
- /*
- * Test bit before deref in case the cm_id gets freed on another
- * thread.
- */
- cb_destroy = test_bit(IWCM_F_CALLBACK_DESTROY, &cm_id_priv->flags);
- if (iwcm_deref_id(cm_id_priv) && cb_destroy) {
- BUG_ON(!list_empty(&cm_id_priv->work_list));
- free_cm_id(cm_id_priv);
- }
-}
-
-static int cm_event_handler(struct iw_cm_id *cm_id, struct iw_cm_event *event);
-
-struct iw_cm_id *iw_create_cm_id(struct ib_device *device,
- struct socket *so,
- iw_cm_handler cm_handler,
- void *context)
-{
- struct iwcm_id_private *cm_id_priv;
-
- cm_id_priv = kzalloc(sizeof(*cm_id_priv), GFP_KERNEL);
- if (!cm_id_priv)
- return ERR_PTR(-ENOMEM);
-
- cm_id_priv->state = IW_CM_STATE_IDLE;
- cm_id_priv->id.device = device;
- cm_id_priv->id.cm_handler = cm_handler;
- cm_id_priv->id.context = context;
- cm_id_priv->id.event_handler = cm_event_handler;
- cm_id_priv->id.add_ref = add_ref;
- cm_id_priv->id.rem_ref = rem_ref;
- cm_id_priv->id.so = so;
- spin_lock_init(&cm_id_priv->lock);
- atomic_set(&cm_id_priv->refcount, 1);
- init_waitqueue_head(&cm_id_priv->connect_wait);
- init_completion(&cm_id_priv->destroy_comp);
- INIT_LIST_HEAD(&cm_id_priv->work_list);
- INIT_LIST_HEAD(&cm_id_priv->work_free_list);
-
- return &cm_id_priv->id;
-}
-EXPORT_SYMBOL(iw_create_cm_id);
-
-
-static int iwcm_modify_qp_err(struct ib_qp *qp)
-{
- struct ib_qp_attr qp_attr;
-
- if (!qp)
- return -EINVAL;
-
- qp_attr.qp_state = IB_QPS_ERR;
- return ib_modify_qp(qp, &qp_attr, IB_QP_STATE);
-}
-
-/*
- * This is really the RDMAC CLOSING state. It is most similar to the
- * IB SQD QP state.
- */
-static int iwcm_modify_qp_sqd(struct ib_qp *qp)
-{
- struct ib_qp_attr qp_attr;
-
- BUG_ON(qp == NULL);
- qp_attr.qp_state = IB_QPS_SQD;
- return ib_modify_qp(qp, &qp_attr, IB_QP_STATE);
-}
-
-/*
- * CM_ID <-- CLOSING
- *
- * Block if a passive or active connection is currently being processed. Then
- * process the event as follows:
- * - If we are ESTABLISHED, move to CLOSING and modify the QP state
- * based on the abrupt flag
- * - If the connection is already in the CLOSING or IDLE state, the peer is
- * disconnecting concurrently with us and we've already seen the
- * DISCONNECT event -- ignore the request and return 0
- * - Disconnect on a listening endpoint returns -EINVAL
- */
-int iw_cm_disconnect(struct iw_cm_id *cm_id, int abrupt)
-{
- struct iwcm_id_private *cm_id_priv;
- unsigned long flags;
- int ret = 0;
- struct ib_qp *qp = NULL;
-
- cm_id_priv = container_of(cm_id, struct iwcm_id_private, id);
- /* Wait if we're currently in a connect or accept downcall */
- wait_event(cm_id_priv->connect_wait,
- !test_bit(IWCM_F_CONNECT_WAIT, &cm_id_priv->flags));
-
- spin_lock_irqsave(&cm_id_priv->lock, flags);
- switch (cm_id_priv->state) {
- case IW_CM_STATE_ESTABLISHED:
- cm_id_priv->state = IW_CM_STATE_CLOSING;
-
- /* QP could be <nul> for user-mode client */
- if (cm_id_priv->qp)
- qp = cm_id_priv->qp;
- else
- ret = -EINVAL;
- break;
- case IW_CM_STATE_LISTEN:
- ret = -EINVAL;
- break;
- case IW_CM_STATE_CLOSING:
- /* remote peer closed first */
- case IW_CM_STATE_IDLE:
- /* accept or connect returned !0 */
- break;
- case IW_CM_STATE_CONN_RECV:
- /*
- * App called disconnect before/without calling accept after
- * connect_request event delivered.
- */
- break;
- case IW_CM_STATE_CONN_SENT:
- /* Can only get here if wait above fails */
- default:
- BUG();
- }
- spin_unlock_irqrestore(&cm_id_priv->lock, flags);
-
- if (qp) {
- if (abrupt)
- ret = iwcm_modify_qp_err(qp);
- else
- ret = iwcm_modify_qp_sqd(qp);
-
- /*
- * If both sides are disconnecting the QP could
- * already be in ERR or SQD states
- */
- ret = 0;
- }
-
- return ret;
-}
-EXPORT_SYMBOL(iw_cm_disconnect);
-
-static struct socket *
-dequeue_socket(struct socket *head)
-{
- struct socket *so;
- struct sockaddr_in *remote;
-
- ACCEPT_LOCK();
- so = TAILQ_FIRST(&head->so_comp);
- if (!so) {
- ACCEPT_UNLOCK();
- return NULL;
- }
-
- SOCK_LOCK(so);
- /*
- * Before changing the flags on the socket, we have to bump the
- * reference count. Otherwise, if the protocol calls sofree(),
- * the socket will be released due to a zero refcount.
- */
- soref(so);
- TAILQ_REMOVE(&head->so_comp, so, so_list);
- head->so_qlen--;
- so->so_qstate &= ~SQ_COMP;
- so->so_head = NULL;
- so->so_state |= SS_NBIO;
- SOCK_UNLOCK(so);
- ACCEPT_UNLOCK();
- remote = NULL;
- soaccept(so, (struct sockaddr **)&remote);
-
- free(remote, M_SONAME);
- return so;
-}
-static void
-iw_so_event_handler(struct work_struct *_work)
-{
-#ifdef INET
- struct iwcm_listen_work *work = container_of(_work,
- struct iwcm_listen_work, work);
- struct iw_cm_id *listen_cm_id = work->cm_id;
- struct iwcm_id_private *cm_id_priv;
- struct iw_cm_id *real_cm_id;
- struct sockaddr_in *local;
- struct socket *so;
-
- cm_id_priv = container_of(listen_cm_id, struct iwcm_id_private, id);
-
- if (cm_id_priv->state != IW_CM_STATE_LISTEN) {
- kfree(work);
- return;
- }
-
- /* Dequeue & process all new 'so' connection requests for this cmid */
- while ((so = dequeue_socket(work->cm_id->so)) != NULL) {
- if (rdma_cma_any_addr((struct sockaddr *)
- &listen_cm_id->local_addr)) {
- in_getsockaddr(so, (struct sockaddr **)&local);
- if (rdma_find_cmid_laddr(local, ARPHRD_ETHER,
- (void **) &real_cm_id)) {
- free(local, M_SONAME);
- goto err;
- }
- free(local, M_SONAME);
-
- real_cm_id->device->iwcm->newconn(real_cm_id, so);
- } else {
- listen_cm_id->device->iwcm->newconn(listen_cm_id, so);
- }
- }
-err:
- kfree(work);
-#endif
- return;
-}
-static int
-iw_so_upcall(struct socket *parent_so, void *arg, int waitflag)
-{
- struct iwcm_listen_work *work;
- struct socket *so;
- struct iw_cm_id *cm_id = arg;
-
- /* check whether iw_so_event_handler() already dequeued this 'so' */
- so = TAILQ_FIRST(&parent_so->so_comp);
- if (!so)
- return SU_OK;
- work = kzalloc(sizeof(*work), M_NOWAIT);
- if (!work)
- return -ENOMEM;
- work->cm_id = cm_id;
-
- INIT_WORK(&work->work, iw_so_event_handler);
- queue_work(iwcm_wq, &work->work);
-
- return SU_OK;
-}
-
-static void
-iw_init_sock(struct iw_cm_id *cm_id)
-{
- struct sockopt sopt;
- struct socket *so = cm_id->so;
- int on = 1;
-
- SOCK_LOCK(so);
- soupcall_set(so, SO_RCV, iw_so_upcall, cm_id);
- so->so_state |= SS_NBIO;
- SOCK_UNLOCK(so);
- sopt.sopt_dir = SOPT_SET;
- sopt.sopt_level = IPPROTO_TCP;
- sopt.sopt_name = TCP_NODELAY;
- sopt.sopt_val = (caddr_t)&on;
- sopt.sopt_valsize = sizeof(on);
- sopt.sopt_td = NULL;
- sosetopt(so, &sopt);
-}
-
-static int
-iw_uninit_socket(struct iw_cm_id *cm_id)
-{
- struct socket *so = cm_id->so;
-
- SOCK_LOCK(so);
- soupcall_clear(so, SO_RCV);
- SOCK_UNLOCK(so);
-
- return (0);
-}
-
-static int
-iw_create_listen(struct iw_cm_id *cm_id, int backlog)
-{
- int rc;
-
- iw_init_sock(cm_id);
- rc = -solisten(cm_id->so, backlog, curthread);
- if (rc != 0)
- iw_uninit_socket(cm_id);
- return (rc);
-}
-
-static int
-iw_destroy_listen(struct iw_cm_id *cm_id)
-{
-
- return (iw_uninit_socket(cm_id));
-}
-
-
-/*
- * CM_ID <-- DESTROYING
- *
- * Clean up all resources associated with the connection and release
- * the initial reference taken by iw_create_cm_id.
- */
-static void destroy_cm_id(struct iw_cm_id *cm_id)
-{
- struct iwcm_id_private *cm_id_priv;
- unsigned long flags;
- int ret = 0, refcnt;
-
- cm_id_priv = container_of(cm_id, struct iwcm_id_private, id);
- /*
- * Wait if we're currently in a connect or accept downcall. A
- * listening endpoint should never block here.
- */
- wait_event(cm_id_priv->connect_wait,
- !test_bit(IWCM_F_CONNECT_WAIT, &cm_id_priv->flags));
-
- spin_lock_irqsave(&cm_id_priv->lock, flags);
- switch (cm_id_priv->state) {
- case IW_CM_STATE_LISTEN:
- cm_id_priv->state = IW_CM_STATE_DESTROYING;
- spin_unlock_irqrestore(&cm_id_priv->lock, flags);
- if (rdma_cma_any_addr((struct sockaddr *)&cm_id->local_addr)) {
- refcnt =
- rem_port_from_listenlist(cm_id->local_addr.sin_port);
-
- if (refcnt == 0)
- ret = iw_destroy_listen(cm_id);
-
- cm_id->device->iwcm->destroy_listen_ep(cm_id);
- } else {
- ret = iw_destroy_listen(cm_id);
- cm_id->device->iwcm->destroy_listen_ep(cm_id);
- }
- spin_lock_irqsave(&cm_id_priv->lock, flags);
- break;
- case IW_CM_STATE_ESTABLISHED:
- cm_id_priv->state = IW_CM_STATE_DESTROYING;
- spin_unlock_irqrestore(&cm_id_priv->lock, flags);
- /* Abrupt close of the connection */
- (void)iwcm_modify_qp_err(cm_id_priv->qp);
- spin_lock_irqsave(&cm_id_priv->lock, flags);
- break;
- case IW_CM_STATE_IDLE:
- case IW_CM_STATE_CLOSING:
- cm_id_priv->state = IW_CM_STATE_DESTROYING;
- break;
- case IW_CM_STATE_CONN_RECV:
- /*
- * App called destroy before/without calling accept after
- * receiving connection request event notification or
- * returned non zero from the event callback function.
- * In either case, must tell the provider to reject.
- */
- cm_id_priv->state = IW_CM_STATE_DESTROYING;
- spin_unlock_irqrestore(&cm_id_priv->lock, flags);
- cm_id->device->iwcm->reject(cm_id, NULL, 0);
- spin_lock_irqsave(&cm_id_priv->lock, flags);
- break;
- case IW_CM_STATE_CONN_SENT:
- case IW_CM_STATE_DESTROYING:
- default:
- BUG();
- break;
- }
- if (cm_id_priv->qp) {
- cm_id_priv->id.device->iwcm->rem_ref(cm_id_priv->qp);
- cm_id_priv->qp = NULL;
- }
- spin_unlock_irqrestore(&cm_id_priv->lock, flags);
-
- (void)iwcm_deref_id(cm_id_priv);
-}
-
-/*
- * This function is only called by the application thread and cannot
- * be called by the event thread. The function will wait for all
- * references to be released on the cm_id and then kfree the cm_id
- * object.
- */
-void iw_destroy_cm_id(struct iw_cm_id *cm_id)
-{
- struct iwcm_id_private *cm_id_priv;
-
- cm_id_priv = container_of(cm_id, struct iwcm_id_private, id);
- BUG_ON(test_bit(IWCM_F_CALLBACK_DESTROY, &cm_id_priv->flags));
-
- destroy_cm_id(cm_id);
-
- wait_for_completion(&cm_id_priv->destroy_comp);
-
- if (cm_id->so)
- sock_release(cm_id->so);
-
- free_cm_id(cm_id_priv);
-}
-EXPORT_SYMBOL(iw_destroy_cm_id);
-
-/*
- * CM_ID <-- LISTEN
- *
- * Start listening for connect requests. Generates one CONNECT_REQUEST
- * event for each inbound connect request.
- */
-int iw_cm_listen(struct iw_cm_id *cm_id, int backlog)
-{
- struct iwcm_id_private *cm_id_priv;
- unsigned long flags;
- int ret, refcnt;
-
- cm_id_priv = container_of(cm_id, struct iwcm_id_private, id);
-
- ret = alloc_work_entries(cm_id_priv, backlog);
- if (ret)
- return ret;
-
- spin_lock_irqsave(&cm_id_priv->lock, flags);
- switch (cm_id_priv->state) {
- case IW_CM_STATE_IDLE:
- cm_id_priv->state = IW_CM_STATE_LISTEN;
- spin_unlock_irqrestore(&cm_id_priv->lock, flags);
-
- if (rdma_cma_any_addr((struct sockaddr *)&cm_id->local_addr)) {
- refcnt =
- add_port_to_listenlist(cm_id->local_addr.sin_port);
-
- if (refcnt == 1) {
- ret = iw_create_listen(cm_id, backlog);
- } else if (refcnt <= 0) {
- ret = -EINVAL;
- } else {
- /* if refcnt > 1, a socket listener created
- * already. And we need not create socket
- * listener on other rdma devices/listen cm_id's
- * due to TOE. That is when a socket listener is
- * created with INADDR_ANY all registered TOE
- * devices will get a call to start
- * hardware listeners.
- */
- }
- } else {
- ret = iw_create_listen(cm_id, backlog);
- }
- if (!ret)
- cm_id->device->iwcm->create_listen_ep(cm_id, backlog);
- else
- cm_id_priv->state = IW_CM_STATE_IDLE;
-
- spin_lock_irqsave(&cm_id_priv->lock, flags);
- break;
- default:
- ret = -EINVAL;
- }
- spin_unlock_irqrestore(&cm_id_priv->lock, flags);
-
- return ret;
-}
-EXPORT_SYMBOL(iw_cm_listen);
-
-/*
- * CM_ID <-- IDLE
- *
- * Rejects an inbound connection request. No events are generated.
- */
-int iw_cm_reject(struct iw_cm_id *cm_id,
- const void *private_data,
- u8 private_data_len)
-{
- struct iwcm_id_private *cm_id_priv;
- unsigned long flags;
- int ret;
-
- cm_id_priv = container_of(cm_id, struct iwcm_id_private, id);
- set_bit(IWCM_F_CONNECT_WAIT, &cm_id_priv->flags);
-
- spin_lock_irqsave(&cm_id_priv->lock, flags);
- if (cm_id_priv->state != IW_CM_STATE_CONN_RECV) {
- spin_unlock_irqrestore(&cm_id_priv->lock, flags);
- clear_bit(IWCM_F_CONNECT_WAIT, &cm_id_priv->flags);
- wake_up_all(&cm_id_priv->connect_wait);
- return -EINVAL;
- }
- cm_id_priv->state = IW_CM_STATE_IDLE;
- spin_unlock_irqrestore(&cm_id_priv->lock, flags);
-
- ret = cm_id->device->iwcm->reject(cm_id, private_data,
- private_data_len);
-
- clear_bit(IWCM_F_CONNECT_WAIT, &cm_id_priv->flags);
- wake_up_all(&cm_id_priv->connect_wait);
-
- return ret;
-}
-EXPORT_SYMBOL(iw_cm_reject);
-
-/*
- * CM_ID <-- ESTABLISHED
- *
- * Accepts an inbound connection request and generates an ESTABLISHED
- * event. Callers of iw_cm_disconnect and iw_destroy_cm_id will block
- * until the ESTABLISHED event is received from the provider.
- */
-int iw_cm_accept(struct iw_cm_id *cm_id,
- struct iw_cm_conn_param *iw_param)
-{
- struct iwcm_id_private *cm_id_priv;
- struct ib_qp *qp;
- unsigned long flags;
- int ret;
-
- cm_id_priv = container_of(cm_id, struct iwcm_id_private, id);
- set_bit(IWCM_F_CONNECT_WAIT, &cm_id_priv->flags);
-
- spin_lock_irqsave(&cm_id_priv->lock, flags);
- if (cm_id_priv->state != IW_CM_STATE_CONN_RECV) {
- spin_unlock_irqrestore(&cm_id_priv->lock, flags);
- clear_bit(IWCM_F_CONNECT_WAIT, &cm_id_priv->flags);
- wake_up_all(&cm_id_priv->connect_wait);
- return -EINVAL;
- }
- /* Get the ib_qp given the QPN */
- qp = cm_id->device->iwcm->get_qp(cm_id->device, iw_param->qpn);
- if (!qp) {
- spin_unlock_irqrestore(&cm_id_priv->lock, flags);
- clear_bit(IWCM_F_CONNECT_WAIT, &cm_id_priv->flags);
- wake_up_all(&cm_id_priv->connect_wait);
- return -EINVAL;
- }
- cm_id->device->iwcm->add_ref(qp);
- cm_id_priv->qp = qp;
- spin_unlock_irqrestore(&cm_id_priv->lock, flags);
-
- ret = cm_id->device->iwcm->accept(cm_id, iw_param);
- if (ret) {
- /* An error on accept precludes provider events */
- BUG_ON(cm_id_priv->state != IW_CM_STATE_CONN_RECV);
- cm_id_priv->state = IW_CM_STATE_IDLE;
- spin_lock_irqsave(&cm_id_priv->lock, flags);
- if (cm_id_priv->qp) {
- cm_id->device->iwcm->rem_ref(qp);
- cm_id_priv->qp = NULL;
- }
- spin_unlock_irqrestore(&cm_id_priv->lock, flags);
- clear_bit(IWCM_F_CONNECT_WAIT, &cm_id_priv->flags);
- wake_up_all(&cm_id_priv->connect_wait);
- }
-
- return ret;
-}
-EXPORT_SYMBOL(iw_cm_accept);
-
-/*
- * Active Side: CM_ID <-- CONN_SENT
- *
- * If successful, results in the generation of a CONNECT_REPLY
- * event. iw_cm_disconnect and iw_cm_destroy will block until the
- * CONNECT_REPLY event is received from the provider.
- */
-int iw_cm_connect(struct iw_cm_id *cm_id, struct iw_cm_conn_param *iw_param)
-{
- struct iwcm_id_private *cm_id_priv;
- int ret;
- unsigned long flags;
- struct ib_qp *qp;
-
- cm_id_priv = container_of(cm_id, struct iwcm_id_private, id);
-
- ret = alloc_work_entries(cm_id_priv, 4);
- if (ret)
- return ret;
-
- set_bit(IWCM_F_CONNECT_WAIT, &cm_id_priv->flags);
- spin_lock_irqsave(&cm_id_priv->lock, flags);
-
- if (cm_id_priv->state != IW_CM_STATE_IDLE) {
- spin_unlock_irqrestore(&cm_id_priv->lock, flags);
- clear_bit(IWCM_F_CONNECT_WAIT, &cm_id_priv->flags);
- wake_up_all(&cm_id_priv->connect_wait);
- return -EINVAL;
- }
-
- /* Get the ib_qp given the QPN */
- qp = cm_id->device->iwcm->get_qp(cm_id->device, iw_param->qpn);
- if (!qp) {
- spin_unlock_irqrestore(&cm_id_priv->lock, flags);
- clear_bit(IWCM_F_CONNECT_WAIT, &cm_id_priv->flags);
- wake_up_all(&cm_id_priv->connect_wait);
- return -EINVAL;
- }
- cm_id->device->iwcm->add_ref(qp);
- cm_id_priv->qp = qp;
- cm_id_priv->state = IW_CM_STATE_CONN_SENT;
- spin_unlock_irqrestore(&cm_id_priv->lock, flags);
-
- ret = cm_id->device->iwcm->connect(cm_id, iw_param);
- if (ret) {
- spin_lock_irqsave(&cm_id_priv->lock, flags);
- if (cm_id_priv->qp) {
- cm_id->device->iwcm->rem_ref(qp);
- cm_id_priv->qp = NULL;
- }
- spin_unlock_irqrestore(&cm_id_priv->lock, flags);
- BUG_ON(cm_id_priv->state != IW_CM_STATE_CONN_SENT);
- cm_id_priv->state = IW_CM_STATE_IDLE;
- clear_bit(IWCM_F_CONNECT_WAIT, &cm_id_priv->flags);
- wake_up_all(&cm_id_priv->connect_wait);
- }
-
- return ret;
-}
-EXPORT_SYMBOL(iw_cm_connect);
-
-/*
- * Passive Side: new CM_ID <-- CONN_RECV
- *
- * Handles an inbound connect request. The function creates a new
- * iw_cm_id to represent the new connection and inherits the client
- * callback function and other attributes from the listening parent.
- *
- * The work item contains a pointer to the listen_cm_id and the event. The
- * listen_cm_id contains the client cm_handler, context and
- * device. These are copied when the device is cloned. The event
- * contains the new four tuple.
- *
- * An error on the child should not affect the parent, so this
- * function does not return a value.
- */
-static void cm_conn_req_handler(struct iwcm_id_private *listen_id_priv,
- struct iw_cm_event *iw_event)
-{
- unsigned long flags;
- struct iw_cm_id *cm_id;
- struct iwcm_id_private *cm_id_priv;
- int ret;
-
- /*
- * The provider should never generate a connection request
- * event with a bad status.
- */
- BUG_ON(iw_event->status);
-
- cm_id = iw_create_cm_id(listen_id_priv->id.device,
- iw_event->so,
- listen_id_priv->id.cm_handler,
- listen_id_priv->id.context);
- /* If the cm_id could not be created, ignore the request */
- if (IS_ERR(cm_id))
- goto out;
-
- cm_id->provider_data = iw_event->provider_data;
- cm_id->local_addr = iw_event->local_addr;
- cm_id->remote_addr = iw_event->remote_addr;
-
- cm_id_priv = container_of(cm_id, struct iwcm_id_private, id);
- cm_id_priv->state = IW_CM_STATE_CONN_RECV;
-
- /*
- * We could be destroying the listening id. If so, ignore this
- * upcall.
- */
- spin_lock_irqsave(&listen_id_priv->lock, flags);
- if (listen_id_priv->state != IW_CM_STATE_LISTEN) {
- spin_unlock_irqrestore(&listen_id_priv->lock, flags);
- iw_cm_reject(cm_id, NULL, 0);
- iw_destroy_cm_id(cm_id);
- goto out;
- }
- spin_unlock_irqrestore(&listen_id_priv->lock, flags);
-
- ret = alloc_work_entries(cm_id_priv, 3);
- if (ret) {
- iw_cm_reject(cm_id, NULL, 0);
- iw_destroy_cm_id(cm_id);
- goto out;
- }
-
- /* Call the client CM handler */
- ret = cm_id->cm_handler(cm_id, iw_event);
- if (ret) {
- iw_cm_reject(cm_id, NULL, 0);
- set_bit(IWCM_F_CALLBACK_DESTROY, &cm_id_priv->flags);
- destroy_cm_id(cm_id);
- if (atomic_read(&cm_id_priv->refcount)==0)
- free_cm_id(cm_id_priv);
- }
-
-out:
- if (iw_event->private_data_len)
- kfree(iw_event->private_data);
-}
-
-/*
- * Passive Side: CM_ID <-- ESTABLISHED
- *
- * The provider generated an ESTABLISHED event which means that
- * the MPA negotion has completed successfully and we are now in MPA
- * FPDU mode.
- *
- * This event can only be received in the CONN_RECV state. If the
- * remote peer closed, the ESTABLISHED event would be received followed
- * by the CLOSE event. If the app closes, it will block until we wake
- * it up after processing this event.
- */
-static int cm_conn_est_handler(struct iwcm_id_private *cm_id_priv,
- struct iw_cm_event *iw_event)
-{
- unsigned long flags;
- int ret;
-
- spin_lock_irqsave(&cm_id_priv->lock, flags);
-
- /*
- * We clear the CONNECT_WAIT bit here to allow the callback
- * function to call iw_cm_disconnect. Calling iw_destroy_cm_id
- * from a callback handler is not allowed.
- */
- clear_bit(IWCM_F_CONNECT_WAIT, &cm_id_priv->flags);
- BUG_ON(cm_id_priv->state != IW_CM_STATE_CONN_RECV);
- cm_id_priv->state = IW_CM_STATE_ESTABLISHED;
- spin_unlock_irqrestore(&cm_id_priv->lock, flags);
- ret = cm_id_priv->id.cm_handler(&cm_id_priv->id, iw_event);
- wake_up_all(&cm_id_priv->connect_wait);
-
- return ret;
-}
-
-/*
- * Active Side: CM_ID <-- ESTABLISHED
- *
- * The app has called connect and is waiting for the established event to
- * post it's requests to the server. This event will wake up anyone
- * blocked in iw_cm_disconnect or iw_destroy_id.
- */
-static int cm_conn_rep_handler(struct iwcm_id_private *cm_id_priv,
- struct iw_cm_event *iw_event)
-{
- unsigned long flags;
- int ret;
-
- spin_lock_irqsave(&cm_id_priv->lock, flags);
- /*
- * Clear the connect wait bit so a callback function calling
- * iw_cm_disconnect will not wait and deadlock this thread
- */
- clear_bit(IWCM_F_CONNECT_WAIT, &cm_id_priv->flags);
- BUG_ON(cm_id_priv->state != IW_CM_STATE_CONN_SENT);
- if (iw_event->status == 0) {
- cm_id_priv->id.local_addr = iw_event->local_addr;
- cm_id_priv->id.remote_addr = iw_event->remote_addr;
- cm_id_priv->state = IW_CM_STATE_ESTABLISHED;
- } else {
- /* REJECTED or RESET */
- cm_id_priv->id.device->iwcm->rem_ref(cm_id_priv->qp);
- cm_id_priv->qp = NULL;
- cm_id_priv->state = IW_CM_STATE_IDLE;
- }
- spin_unlock_irqrestore(&cm_id_priv->lock, flags);
- ret = cm_id_priv->id.cm_handler(&cm_id_priv->id, iw_event);
-
- if (iw_event->private_data_len)
- kfree(iw_event->private_data);
-
- /* Wake up waiters on connect complete */
- wake_up_all(&cm_id_priv->connect_wait);
-
- return ret;
-}
-
-/*
- * CM_ID <-- CLOSING
- *
- * If in the ESTABLISHED state, move to CLOSING.
- */
-static void cm_disconnect_handler(struct iwcm_id_private *cm_id_priv,
- struct iw_cm_event *iw_event)
-{
- unsigned long flags;
-
- spin_lock_irqsave(&cm_id_priv->lock, flags);
- if (cm_id_priv->state == IW_CM_STATE_ESTABLISHED)
- cm_id_priv->state = IW_CM_STATE_CLOSING;
- spin_unlock_irqrestore(&cm_id_priv->lock, flags);
-}
-
-/*
- * CM_ID <-- IDLE
- *
- * If in the ESTBLISHED or CLOSING states, the QP will have have been
- * moved by the provider to the ERR state. Disassociate the CM_ID from
- * the QP, move to IDLE, and remove the 'connected' reference.
- *
- * If in some other state, the cm_id was destroyed asynchronously.
- * This is the last reference that will result in waking up
- * the app thread blocked in iw_destroy_cm_id.
- */
-static int cm_close_handler(struct iwcm_id_private *cm_id_priv,
- struct iw_cm_event *iw_event)
-{
- unsigned long flags;
- int ret = 0;
- spin_lock_irqsave(&cm_id_priv->lock, flags);
-
- if (cm_id_priv->qp) {
- cm_id_priv->id.device->iwcm->rem_ref(cm_id_priv->qp);
- cm_id_priv->qp = NULL;
- }
- switch (cm_id_priv->state) {
- case IW_CM_STATE_ESTABLISHED:
- case IW_CM_STATE_CLOSING:
- cm_id_priv->state = IW_CM_STATE_IDLE;
- spin_unlock_irqrestore(&cm_id_priv->lock, flags);
- ret = cm_id_priv->id.cm_handler(&cm_id_priv->id, iw_event);
- spin_lock_irqsave(&cm_id_priv->lock, flags);
- break;
- case IW_CM_STATE_DESTROYING:
- break;
- default:
- BUG();
- }
- spin_unlock_irqrestore(&cm_id_priv->lock, flags);
-
- return ret;
-}
-
-static int process_event(struct iwcm_id_private *cm_id_priv,
- struct iw_cm_event *iw_event)
-{
- int ret = 0;
-
- switch (iw_event->event) {
- case IW_CM_EVENT_CONNECT_REQUEST:
- cm_conn_req_handler(cm_id_priv, iw_event);
- break;
- case IW_CM_EVENT_CONNECT_REPLY:
- ret = cm_conn_rep_handler(cm_id_priv, iw_event);
- break;
- case IW_CM_EVENT_ESTABLISHED:
- ret = cm_conn_est_handler(cm_id_priv, iw_event);
- break;
- case IW_CM_EVENT_DISCONNECT:
- cm_disconnect_handler(cm_id_priv, iw_event);
- break;
- case IW_CM_EVENT_CLOSE:
- ret = cm_close_handler(cm_id_priv, iw_event);
- break;
- default:
- BUG();
- }
-
- return ret;
-}
-
-/*
- * Process events on the work_list for the cm_id. If the callback
- * function requests that the cm_id be deleted, a flag is set in the
- * cm_id flags to indicate that when the last reference is
- * removed, the cm_id is to be destroyed. This is necessary to
- * distinguish between an object that will be destroyed by the app
- * thread asleep on the destroy_comp list vs. an object destroyed
- * here synchronously when the last reference is removed.
- */
-static void cm_work_handler(struct work_struct *_work)
-{
- struct iwcm_work *work = container_of(_work, struct iwcm_work, work);
- struct iw_cm_event levent;
- struct iwcm_id_private *cm_id_priv = work->cm_id;
- unsigned long flags;
- int empty;
- int ret = 0;
- int destroy_id;
-
- spin_lock_irqsave(&cm_id_priv->lock, flags);
- empty = list_empty(&cm_id_priv->work_list);
- while (!empty) {
- work = list_entry(cm_id_priv->work_list.next,
- struct iwcm_work, list);
- list_del_init(&work->list);
- empty = list_empty(&cm_id_priv->work_list);
- levent = work->event;
- put_work(work);
- spin_unlock_irqrestore(&cm_id_priv->lock, flags);
-
- ret = process_event(cm_id_priv, &levent);
- if (ret) {
- set_bit(IWCM_F_CALLBACK_DESTROY, &cm_id_priv->flags);
- destroy_cm_id(&cm_id_priv->id);
- }
- BUG_ON(atomic_read(&cm_id_priv->refcount)==0);
- destroy_id = test_bit(IWCM_F_CALLBACK_DESTROY, &cm_id_priv->flags);
- if (iwcm_deref_id(cm_id_priv)) {
- if (destroy_id) {
- BUG_ON(!list_empty(&cm_id_priv->work_list));
- free_cm_id(cm_id_priv);
- }
- return;
- }
- if (empty)
- return;
- spin_lock_irqsave(&cm_id_priv->lock, flags);
- }
- spin_unlock_irqrestore(&cm_id_priv->lock, flags);
-}
-
-/*
- * This function is called on interrupt context. Schedule events on
- * the iwcm_wq thread to allow callback functions to downcall into
- * the CM and/or block. Events are queued to a per-CM_ID
- * work_list. If this is the first event on the work_list, the work
- * element is also queued on the iwcm_wq thread.
- *
- * Each event holds a reference on the cm_id. Until the last posted
- * event has been delivered and processed, the cm_id cannot be
- * deleted.
- *
- * Returns:
- * 0 - the event was handled.
- * -ENOMEM - the event was not handled due to lack of resources.
- */
-static int cm_event_handler(struct iw_cm_id *cm_id,
- struct iw_cm_event *iw_event)
-{
- struct iwcm_work *work;
- struct iwcm_id_private *cm_id_priv;
- unsigned long flags;
- int ret = 0;
-
- cm_id_priv = container_of(cm_id, struct iwcm_id_private, id);
-
- spin_lock_irqsave(&cm_id_priv->lock, flags);
- work = get_work(cm_id_priv);
- if (!work) {
- ret = -ENOMEM;
- goto out;
- }
-
- INIT_WORK(&work->work, cm_work_handler);
- work->cm_id = cm_id_priv;
- work->event = *iw_event;
-
- if ((work->event.event == IW_CM_EVENT_CONNECT_REQUEST ||
- work->event.event == IW_CM_EVENT_CONNECT_REPLY) &&
- work->event.private_data_len) {
- ret = copy_private_data(&work->event);
- if (ret) {
- put_work(work);
- goto out;
- }
- }
-
- atomic_inc(&cm_id_priv->refcount);
- if (list_empty(&cm_id_priv->work_list)) {
- list_add_tail(&work->list, &cm_id_priv->work_list);
- queue_work(iwcm_wq, &work->work);
- } else
- list_add_tail(&work->list, &cm_id_priv->work_list);
-out:
- spin_unlock_irqrestore(&cm_id_priv->lock, flags);
- return ret;
-}
-
-static int iwcm_init_qp_init_attr(struct iwcm_id_private *cm_id_priv,
- struct ib_qp_attr *qp_attr,
- int *qp_attr_mask)
-{
- unsigned long flags;
- int ret;
-
- spin_lock_irqsave(&cm_id_priv->lock, flags);
- switch (cm_id_priv->state) {
- case IW_CM_STATE_IDLE:
- case IW_CM_STATE_CONN_SENT:
- case IW_CM_STATE_CONN_RECV:
- case IW_CM_STATE_ESTABLISHED:
- *qp_attr_mask = IB_QP_STATE | IB_QP_ACCESS_FLAGS;
- qp_attr->qp_access_flags = IB_ACCESS_REMOTE_WRITE|
- IB_ACCESS_REMOTE_READ;
- ret = 0;
- break;
- default:
- ret = -EINVAL;
- break;
- }
- spin_unlock_irqrestore(&cm_id_priv->lock, flags);
- return ret;
-}
-
-static int iwcm_init_qp_rts_attr(struct iwcm_id_private *cm_id_priv,
- struct ib_qp_attr *qp_attr,
- int *qp_attr_mask)
-{
- unsigned long flags;
- int ret;
-
- spin_lock_irqsave(&cm_id_priv->lock, flags);
- switch (cm_id_priv->state) {
- case IW_CM_STATE_IDLE:
- case IW_CM_STATE_CONN_SENT:
- case IW_CM_STATE_CONN_RECV:
- case IW_CM_STATE_ESTABLISHED:
- *qp_attr_mask = 0;
- ret = 0;
- break;
- default:
- ret = -EINVAL;
- break;
- }
- spin_unlock_irqrestore(&cm_id_priv->lock, flags);
- return ret;
-}
-
-int iw_cm_init_qp_attr(struct iw_cm_id *cm_id,
- struct ib_qp_attr *qp_attr,
- int *qp_attr_mask)
-{
- struct iwcm_id_private *cm_id_priv;
- int ret;
-
- cm_id_priv = container_of(cm_id, struct iwcm_id_private, id);
- switch (qp_attr->qp_state) {
- case IB_QPS_INIT:
- case IB_QPS_RTR:
- ret = iwcm_init_qp_init_attr(cm_id_priv,
- qp_attr, qp_attr_mask);
- break;
- case IB_QPS_RTS:
- ret = iwcm_init_qp_rts_attr(cm_id_priv,
- qp_attr, qp_attr_mask);
- break;
- default:
- ret = -EINVAL;
- break;
- }
- return ret;
-}
-EXPORT_SYMBOL(iw_cm_init_qp_attr);
-
-static int __init iw_cm_init(void)
-{
- iwcm_wq = create_singlethread_workqueue("iw_cm_wq");
- if (!iwcm_wq)
- return -ENOMEM;
-
- return 0;
-}
-
-static void __exit iw_cm_cleanup(void)
-{
- destroy_workqueue(iwcm_wq);
-}
-
-module_init(iw_cm_init);
-module_exit(iw_cm_cleanup);
diff --git a/sys/ofed/drivers/infiniband/core/iwcm.h b/sys/ofed/drivers/infiniband/core/iwcm.h
index 3f6cc82..82c2cd1 100644
--- a/sys/ofed/drivers/infiniband/core/iwcm.h
+++ b/sys/ofed/drivers/infiniband/core/iwcm.h
@@ -56,7 +56,7 @@ struct iwcm_id_private {
struct list_head work_free_list;
};
-#define IWCM_F_CALLBACK_DESTROY 1
+#define IWCM_F_DROP_EVENTS 1
#define IWCM_F_CONNECT_WAIT 2
#endif /* IWCM_H */
diff --git a/sys/ofed/drivers/infiniband/core/iwpm_util.h b/sys/ofed/drivers/infiniband/core/iwpm_util.h
new file mode 100644
index 0000000..5553b8c
--- /dev/null
+++ b/sys/ofed/drivers/infiniband/core/iwpm_util.h
@@ -0,0 +1,75 @@
+/*
+ * Copyright (c) 2014 Intel Corporation. All rights reserved.
+ * Copyright (c) 2014 Chelsio, Inc. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+#ifndef _IWPM_UTIL_H
+#define _IWPM_UTIL_H
+
+#include <linux/module.h>
+#include <linux/io.h>
+#include <linux/in.h>
+#include <linux/in6.h>
+#include <linux/spinlock.h>
+#include <linux/kernel.h>
+#include <linux/netdevice.h>
+#include <linux/delay.h>
+#include <linux/workqueue.h>
+#include <linux/mutex.h>
+#include <linux/jhash.h>
+#include <linux/kref.h>
+#include <linux/errno.h>
+#include <linux/rwsem.h>
+
+#include <rdma/iw_portmap.h>
+
+#define IWPM_PID_UNDEFINED -1
+#define IWPM_PID_UNAVAILABLE -2
+
+#define IWPM_REG_UNDEF 0x01
+#define IWPM_REG_VALID 0x02
+#define IWPM_REG_INCOMPL 0x04
+
+/**
+ * iwpm_compare_sockaddr - Compare two sockaddr storage structs
+ *
+ * Returns 0 if they are holding the same ip/tcp address info,
+ * otherwise returns 1
+ */
+int iwpm_compare_sockaddr(struct sockaddr_storage *a_sockaddr,
+ struct sockaddr_storage *b_sockaddr);
+
+/**
+ * iwpm_print_sockaddr - Print IPv4/IPv6 address and TCP port
+ * @sockaddr: Socket address to print
+ * @msg: Message to print
+ */
+void iwpm_print_sockaddr(struct sockaddr_storage *sockaddr, char *msg);
+#endif
diff --git a/sys/ofed/drivers/infiniband/core/mad.c b/sys/ofed/drivers/infiniband/core/mad.c
deleted file mode 100644
index 23d6844..0000000
--- a/sys/ofed/drivers/infiniband/core/mad.c
+++ /dev/null
@@ -1,3694 +0,0 @@
-/*
- * Copyright (c) 2004-2007 Voltaire, Inc. All rights reserved.
- * Copyright (c) 2005 Intel Corporation. All rights reserved.
- * Copyright (c) 2005 Mellanox Technologies Ltd. All rights reserved.
- * Copyright (c) 2009 HNR Consulting. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- */
-
-#define LINUXKPI_PARAM_PREFIX ibcore_
-
-#include <linux/dma-mapping.h>
-#include <linux/slab.h>
-#include <linux/module.h>
-#include <linux/string.h>
-#include <rdma/ib_cache.h>
-
-#include "mad_priv.h"
-#include "mad_rmpp.h"
-#include "smi.h"
-#include "agent.h"
-
-MODULE_LICENSE("Dual BSD/GPL");
-MODULE_DESCRIPTION("kernel IB MAD API");
-MODULE_AUTHOR("Hal Rosenstock");
-MODULE_AUTHOR("Sean Hefty");
-
-static int mad_sendq_size = IB_MAD_QP_SEND_SIZE;
-static int mad_recvq_size = IB_MAD_QP_RECV_SIZE;
-
-module_param_named(send_queue_size, mad_sendq_size, int, 0444);
-MODULE_PARM_DESC(send_queue_size, "Size of send queue in number of work requests");
-module_param_named(recv_queue_size, mad_recvq_size, int, 0444);
-MODULE_PARM_DESC(recv_queue_size, "Size of receive queue in number of work requests");
-
-static struct kmem_cache *ib_mad_cache;
-
-static struct list_head ib_mad_port_list;
-static u32 ib_mad_client_id = 0;
-
-
-/*
- * Timeout FIFO (tf) param
- */
-enum {
- /* min time between 2 consecutive activations of tf workqueue */
- MIN_BETWEEN_ACTIVATIONS_MS = 5
-};
-
-/*
- * SA congestion control params
- */
-enum {
- MAX_OUTSTANDING_SA_MADS = 10,
- MIN_TIME_FOR_SA_MAD_SEND_MS = 20,
- MAX_SA_MADS = 10000
-};
-
-/* Port list lock */
-static DEFINE_SPINLOCK(ib_mad_port_list_lock);
-
-/* Forward declarations */
-static int method_in_use(struct ib_mad_mgmt_method_table **method,
- struct ib_mad_reg_req *mad_reg_req);
-static void remove_mad_reg_req(struct ib_mad_agent_private *priv);
-static struct ib_mad_agent_private *find_mad_agent(
- struct ib_mad_port_private *port_priv,
- struct ib_mad *mad);
-static int ib_mad_post_receive_mads(struct ib_mad_qp_info *qp_info,
- struct ib_mad_private *mad);
-static void cancel_mads(struct ib_mad_agent_private *mad_agent_priv);
-static void timeout_sends(struct work_struct *work);
-static void local_completions(struct work_struct *work);
-static int add_nonoui_reg_req(struct ib_mad_reg_req *mad_reg_req,
- struct ib_mad_agent_private *agent_priv,
- u8 mgmt_class);
-static int add_oui_reg_req(struct ib_mad_reg_req *mad_reg_req,
- struct ib_mad_agent_private *agent_priv);
-static int send_sa_cc_mad(struct ib_mad_send_wr_private *mad_send_wr,
- u32 timeout_ms, u32 retries_left);
-
-
-/*
- * Timeout FIFO functions - implements FIFO with timeout mechanism
- */
-
-static void activate_timeout_handler_task(unsigned long data)
-{
- struct to_fifo *tf;
-
- tf = (struct to_fifo *)data;
- del_timer(&tf->timer);
- queue_work(tf->workq, &tf->work);
-}
-
-static unsigned long adjusted_time(unsigned long last, unsigned long next)
-{
- unsigned long min_next;
-
- min_next = last + msecs_to_jiffies(MIN_BETWEEN_ACTIVATIONS_MS);
- if (time_after(min_next, next))
- return min_next;
-
- return next;
-}
-
-static void notify_failure(struct ib_mad_send_wr_private *mad_send_wr,
- enum ib_wc_status status)
-{
- struct ib_mad_send_wc mad_send_wc;
- struct ib_mad_agent_private *mad_agent_priv;
-
- mad_send_wc.status = status;
- mad_send_wc.vendor_err = 0;
- mad_send_wc.send_buf = &mad_send_wr->send_buf;
- mad_agent_priv = mad_send_wr->mad_agent_priv;
- mad_agent_priv->agent.send_handler(&mad_agent_priv->agent, &mad_send_wc);
-}
-
-static inline struct sa_cc_data *
-get_cc_obj(struct ib_mad_send_wr_private *mad_send_wr)
-{
- return &mad_send_wr->mad_agent_priv->qp_info->port_priv->sa_cc;
-}
-
-static inline struct ib_mad_send_wr_private *tfe_to_mad(struct tf_entry *tfe)
-{
- return container_of(tfe, struct ib_mad_send_wr_private, tf_list);
-}
-
-static void timeout_handler_task(struct work_struct *work)
-{
- struct tf_entry *tmp1, *tmp2;
- struct list_head *list_item, exp_lst;
- unsigned long flags, curr_time;
- int lst_empty;
- struct to_fifo *tf;
-
- tf = container_of(work, struct to_fifo, work);
- do {
- INIT_LIST_HEAD(&exp_lst);
-
- spin_lock_irqsave(&tf->lists_lock, flags);
- curr_time = jiffies;
- list_for_each(list_item, &tf->to_head) {
- tmp1 = list_entry(list_item, struct tf_entry, to_list);
- if (time_before(curr_time, tmp1->exp_time))
- break;
- list_del(&tmp1->fifo_list);
- tf->num_items--;
- }
-
- /* cut list up to and including list_item->prev */
- list_cut_position(&exp_lst, &tf->to_head, list_item->prev);
- spin_unlock_irqrestore(&tf->lists_lock, flags);
-
- lst_empty = list_empty(&exp_lst);
- list_for_each_entry_safe(tmp1, tmp2, &exp_lst, to_list) {
- list_del(&tmp1->to_list);
- if (tmp1->canceled) {
- tmp1->canceled = 0;
- notify_failure(tfe_to_mad(tmp1), IB_WC_WR_FLUSH_ERR);
- } else {
- notify_failure(tfe_to_mad(tmp1), IB_WC_RESP_TIMEOUT_ERR);
- }
- }
- } while (!lst_empty);
-
- spin_lock_irqsave(&tf->lists_lock, flags);
- if (!list_empty(&tf->to_head)) {
- tmp1 = list_entry(tf->to_head.next, struct tf_entry, to_list);
- mod_timer(&tf->timer, adjusted_time(curr_time, tmp1->exp_time));
- }
- spin_unlock_irqrestore(&tf->lists_lock, flags);
-}
-
-/**
- * tf_create - creates new timeout-fifo object
- * @fifo_size: Maximum fifo size
- *
- * Allocate and initialize new timeout-fifo object
- */
-static struct to_fifo *tf_create(u32 fifo_size)
-{
- struct to_fifo *tf;
-
- tf = kzalloc(sizeof(*tf), GFP_KERNEL);
- if (tf) {
- tf->workq = create_singlethread_workqueue("to_fifo");
- if (!tf->workq) {
- kfree(tf);
- return NULL;
- }
- spin_lock_init(&tf->lists_lock);
- INIT_LIST_HEAD(&tf->to_head);
- INIT_LIST_HEAD(&tf->fifo_head);
- init_timer(&tf->timer);
- INIT_WORK(&tf->work, timeout_handler_task);
- tf->timer.data = (unsigned long) tf;
- tf->timer.function = activate_timeout_handler_task;
- tf->timer.expires = jiffies;
- tf->fifo_size = fifo_size;
- tf->stop_enqueue = 0;
- tf->num_items = 0;
- }
-
- return tf;
-}
-
-/**
- * tf_enqueue - enqueue item to timeout-fifo object
- * @tf:timeout-fifo object
- * @item: item to enqueue.
- * @timeout_ms: item expiration time in ms.
- *
- * Enqueue item to fifo and modify expiration timer when required.
- *
- * Returns 0 on success and negative on failure.
- */
-static int tf_enqueue(struct to_fifo *tf, struct tf_entry *item, u32 timeout_ms)
-{
- struct tf_entry *tmp;
- struct list_head *list_item;
- unsigned long flags;
-
- item->exp_time = jiffies + msecs_to_jiffies(timeout_ms);
-
- spin_lock_irqsave(&tf->lists_lock, flags);
- if (tf->num_items >= tf->fifo_size || tf->stop_enqueue) {
- spin_unlock_irqrestore(&tf->lists_lock, flags);
- return -EBUSY;
- }
-
- /* Insert item to timeout list */
- list_for_each_prev(list_item, &tf->to_head) {
- tmp = list_entry(list_item, struct tf_entry, to_list);
- if (time_after(item->exp_time, tmp->exp_time))
- break;
- }
-
- list_add(&item->to_list, list_item);
-
- /* Insert item to fifo list */
- list_add_tail(&item->fifo_list, &tf->fifo_head);
-
- tf->num_items++;
-
- /* modify expiration timer if required */
- if (list_item == &tf->to_head)
- mod_timer(&tf->timer, item->exp_time);
-
- spin_unlock_irqrestore(&tf->lists_lock, flags);
-
- return 0;
-}
-
-/**
- * tf_dequeue - dequeue item from timeout-fifo object
- * @tf:timeout-fifo object
- * @time_left_ms: returns the time left for expiration in ms.
- *
- * Dequeue item from fifo and modify expiration timer when required.
- *
- * Returns pointer to tf_entry on success and NULL on failure.
- */
-static struct tf_entry *tf_dequeue(struct to_fifo *tf, u32 *time_left_ms)
-{
- unsigned long flags;
- unsigned long time_left;
- struct tf_entry *tmp, *tmp1;
- bool found = false;
-
- spin_lock_irqsave(&tf->lists_lock, flags);
- if (list_empty(&tf->fifo_head)) {
- spin_unlock_irqrestore(&tf->lists_lock, flags);
- return NULL;
- }
-
- list_for_each_entry(tmp, &tf->fifo_head, fifo_list) {
- if (!tmp->canceled) {
- found = true;
- break;
- }
- }
-
- if (!found) {
- spin_unlock_irqrestore(&tf->lists_lock, flags);
- return NULL;
- }
-
- /* modify timer in case enqueued item is the next to expire */
- if (tf->to_head.next == &tmp->to_list) {
- if (list_is_last(&tmp->to_list, &tf->to_head)) {
- del_timer(&tf->timer);
- } else {
- tmp1 = list_entry(tmp->to_list.next, struct tf_entry, to_list);
- mod_timer(&tf->timer, tmp1->exp_time);
- }
- }
- list_del(&tmp->fifo_list);
- list_del(&tmp->to_list);
- tf->num_items--;
- spin_unlock_irqrestore(&tf->lists_lock, flags);
-
- time_left = tmp->exp_time - jiffies;
- if ((long) time_left <= 0)
- time_left = 0;
- *time_left_ms = jiffies_to_msecs(time_left);
-
- return tmp;
-}
-
-static void tf_stop_enqueue(struct to_fifo *tf)
-{
- unsigned long flags;
-
- spin_lock_irqsave(&tf->lists_lock, flags);
- tf->stop_enqueue = 1;
- spin_unlock_irqrestore(&tf->lists_lock, flags);
-}
-
-/**
- * tf_free - free empty timeout-fifo object
- * @tf:timeout-fifo object
- *
- */
-static void tf_free(struct to_fifo *tf)
-{
- del_timer_sync(&tf->timer);
- flush_workqueue(tf->workq);
- destroy_workqueue(tf->workq);
-
- kfree(tf);
-}
-
-/**
- * tf_free_agent - free MADs related to specific MAD agent from timeout-fifo
- * @tf:timeout-fifo object
- * @mad_agent_priv: MAD agent.
- *
- */
-static void tf_free_agent(struct to_fifo *tf, struct ib_mad_agent_private *mad_agent_priv)
-{
- unsigned long flags;
- struct tf_entry *tmp, *tmp1;
- struct list_head tmp_head;
-
- INIT_LIST_HEAD(&tmp_head);
- spin_lock_irqsave(&tf->lists_lock, flags);
- list_for_each_entry_safe(tmp, tmp1, &tf->fifo_head, fifo_list) {
- if (tfe_to_mad(tmp)->mad_agent_priv == mad_agent_priv) {
- list_del(&tmp->to_list);
- list_move(&tmp->fifo_list, &tmp_head);
- tf->num_items--;
- }
- }
- spin_unlock_irqrestore(&tf->lists_lock, flags);
-
- list_for_each_entry_safe(tmp, tmp1, &tmp_head, fifo_list) {
- list_del(&tmp->fifo_list);
- notify_failure(tfe_to_mad(tmp), IB_WC_WR_FLUSH_ERR);
- }
-}
-
-/**
- * tf_modify_item - to modify expiration time for specific item
- * @tf:timeout-fifo object
- * @mad_agent_priv: MAD agent.
- * @send_buf: the MAD to modify in queue
- * @timeout_ms: new timeout to set.
- *
- * Returns 0 if item found on list and -ENXIO if not.
- *
- * Note: The send_buf may point on MAD that is already released.
- * Therefore we can't use this struct before finding it in the list
- */
-static int tf_modify_item(struct to_fifo *tf,
- struct ib_mad_agent_private *mad_agent_priv,
- struct ib_mad_send_buf *send_buf, u32 timeout_ms)
-{
- struct tf_entry *tmp, *item;
- struct list_head *list_item;
- unsigned long flags;
- int found = 0;
-
- spin_lock_irqsave(&tf->lists_lock, flags);
- list_for_each_entry(item, &tf->fifo_head, fifo_list) {
- if (tfe_to_mad(item)->mad_agent_priv == mad_agent_priv &&
- &tfe_to_mad(item)->send_buf == send_buf) {
- found = 1;
- break;
- }
- }
-
- if (!found) {
- spin_unlock_irqrestore(&tf->lists_lock, flags);
- return -ENXIO;
- }
-
- item->exp_time = jiffies + msecs_to_jiffies(timeout_ms);
-
- if (timeout_ms) {
- list_del(&item->to_list);
- list_for_each_prev(list_item, &tf->to_head) {
- tmp = list_entry(list_item, struct tf_entry, to_list);
- if (time_after(item->exp_time, tmp->exp_time))
- break;
- }
- list_add(&item->to_list, list_item);
-
- /* modify expiration timer if required */
- if (list_item == &tf->to_head)
- mod_timer(&tf->timer, item->exp_time);
- } else {
- /*
- * when item canceled (timeout_ms == 0) move item to
- * head of timeout list and to the tail of fifo list
- */
- item->canceled = 1;
- list_move(&item->to_list, &tf->to_head);
- list_move_tail(&item->fifo_list, &tf->fifo_head);
- mod_timer(&tf->timer, item->exp_time);
- }
- spin_unlock_irqrestore(&tf->lists_lock, flags);
-
- return 0;
-}
-
-/*
- * SA congestion control functions
- */
-
-/*
- * Defines which MAD is under congestion control.
- */
-static int is_sa_cc_mad(struct ib_mad_send_wr_private *mad_send_wr)
-{
- struct ib_mad_hdr *mad;
-
- mad = (struct ib_mad_hdr *)mad_send_wr->send_buf.mad;
-
- return ((mad_send_wr->send_buf.timeout_ms) &&
- (mad->mgmt_class == IB_MGMT_CLASS_SUBN_ADM) &&
- ((mad->method == IB_MGMT_METHOD_GET) ||
- (mad->method == IB_MGMT_METHOD_SET)));
-}
-
-/*
- * Notify that SA congestion controlled MAD is done.
- * to allow dequeuing SA MAD from congestion control queue.
- */
-static void sa_cc_mad_done(struct sa_cc_data *cc_obj)
-{
- unsigned long flags;
- struct tf_entry *tfe;
- struct ib_mad_send_wr_private *mad_send_wr;
- u32 time_left_ms, timeout_ms, retries;
- int ret;
-
- do {
- spin_lock_irqsave(&cc_obj->lock, flags);
- tfe = tf_dequeue(cc_obj->tf, &time_left_ms);
- if (!tfe) {
- if (cc_obj->outstanding > 0)
- cc_obj->outstanding--;
- spin_unlock_irqrestore(&cc_obj->lock, flags);
- break;
- }
- spin_unlock_irqrestore(&cc_obj->lock, flags);
- mad_send_wr = tfe_to_mad(tfe);
- time_left_ms += MIN_TIME_FOR_SA_MAD_SEND_MS;
- if (time_left_ms > mad_send_wr->send_buf.timeout_ms) {
- retries = time_left_ms / mad_send_wr->send_buf.timeout_ms - 1;
- timeout_ms = mad_send_wr->send_buf.timeout_ms;
- } else {
- retries = 0;
- timeout_ms = time_left_ms;
- }
- ret = send_sa_cc_mad(mad_send_wr, timeout_ms, retries);
- if (ret) {
- if (ret == -ENOMEM)
- notify_failure(mad_send_wr, IB_WC_GENERAL_ERR);
- else
- notify_failure(mad_send_wr, IB_WC_LOC_QP_OP_ERR);
- }
- } while (ret);
-}
-
-/*
- * Send SA MAD under congestion control.
- */
-static int sa_cc_mad_send(struct ib_mad_send_wr_private *mad_send_wr)
-{
- unsigned long flags;
- int ret;
- struct sa_cc_data *cc_obj;
-
- cc_obj = get_cc_obj(mad_send_wr);
- spin_lock_irqsave(&cc_obj->lock, flags);
- if (cc_obj->outstanding < MAX_OUTSTANDING_SA_MADS) {
- cc_obj->outstanding++;
- spin_unlock_irqrestore(&cc_obj->lock, flags);
- ret = send_sa_cc_mad(mad_send_wr, mad_send_wr->send_buf.timeout_ms,
- mad_send_wr->retries_left);
- if (ret)
- sa_cc_mad_done(cc_obj);
-
- } else {
- int qtime = (mad_send_wr->send_buf.timeout_ms *
- (mad_send_wr->retries_left + 1))
- - MIN_TIME_FOR_SA_MAD_SEND_MS;
-
- if (qtime < 0)
- qtime = 0;
- ret = tf_enqueue(cc_obj->tf, &mad_send_wr->tf_list, (u32)qtime);
-
- spin_unlock_irqrestore(&cc_obj->lock, flags);
- }
-
- return ret;
-}
-
-/*
- * Initialize SA congestion control.
- */
-static int sa_cc_init(struct sa_cc_data *cc_obj)
-{
- spin_lock_init(&cc_obj->lock);
- cc_obj->outstanding = 0;
- cc_obj->tf = tf_create(MAX_SA_MADS);
- if (!cc_obj->tf)
- return -ENOMEM;
- return 0;
-}
-
-/*
- * Cancel SA MADs from congestion control queue.
- */
-static void cancel_sa_cc_mads(struct ib_mad_agent_private *mad_agent_priv)
-{
- tf_free_agent(mad_agent_priv->qp_info->port_priv->sa_cc.tf,
- mad_agent_priv);
-}
-
-/*
- * Modify timeout of SA MAD on congestion control queue.
- */
-static int modify_sa_cc_mad(struct ib_mad_agent_private *mad_agent_priv,
- struct ib_mad_send_buf *send_buf, u32 timeout_ms)
-{
- int ret;
- int qtime = 0;
-
- if (timeout_ms > MIN_TIME_FOR_SA_MAD_SEND_MS)
- qtime = timeout_ms - MIN_TIME_FOR_SA_MAD_SEND_MS;
-
- ret = tf_modify_item(mad_agent_priv->qp_info->port_priv->sa_cc.tf,
- mad_agent_priv, send_buf, (u32)qtime);
- return ret;
-}
-
-static void sa_cc_destroy(struct sa_cc_data *cc_obj)
-{
- struct ib_mad_send_wr_private *mad_send_wr;
- struct tf_entry *tfe;
- struct ib_mad_send_wc mad_send_wc;
- struct ib_mad_agent_private *mad_agent_priv;
- u32 time_left_ms;
-
- mad_send_wc.status = IB_WC_WR_FLUSH_ERR;
- mad_send_wc.vendor_err = 0;
-
- tf_stop_enqueue(cc_obj->tf);
- tfe = tf_dequeue(cc_obj->tf, &time_left_ms);
- while (tfe) {
- mad_send_wr = tfe_to_mad(tfe);
- mad_send_wc.send_buf = &mad_send_wr->send_buf;
- mad_agent_priv = mad_send_wr->mad_agent_priv;
- mad_agent_priv->agent.send_handler(&mad_agent_priv->agent,
- &mad_send_wc);
- tfe = tf_dequeue(cc_obj->tf, &time_left_ms);
- }
- tf_free(cc_obj->tf);
-}
-
-/*
- * Returns a ib_mad_port_private structure or NULL for a device/port
- * Assumes ib_mad_port_list_lock is being held
- */
-static inline struct ib_mad_port_private *
-__ib_get_mad_port(struct ib_device *device, int port_num)
-{
- struct ib_mad_port_private *entry;
-
- list_for_each_entry(entry, &ib_mad_port_list, port_list) {
- if (entry->device == device && entry->port_num == port_num)
- return entry;
- }
- return NULL;
-}
-
-/*
- * Wrapper function to return a ib_mad_port_private structure or NULL
- * for a device/port
- */
-static inline struct ib_mad_port_private *
-ib_get_mad_port(struct ib_device *device, int port_num)
-{
- struct ib_mad_port_private *entry;
- unsigned long flags;
-
- spin_lock_irqsave(&ib_mad_port_list_lock, flags);
- entry = __ib_get_mad_port(device, port_num);
- spin_unlock_irqrestore(&ib_mad_port_list_lock, flags);
-
- return entry;
-}
-
-static inline u8 convert_mgmt_class(u8 mgmt_class)
-{
- /* Alias IB_MGMT_CLASS_SUBN_DIRECTED_ROUTE to 0 */
- return mgmt_class == IB_MGMT_CLASS_SUBN_DIRECTED_ROUTE ?
- 0 : mgmt_class;
-}
-
-static int get_spl_qp_index(enum ib_qp_type qp_type)
-{
- switch (qp_type)
- {
- case IB_QPT_SMI:
- return 0;
- case IB_QPT_GSI:
- return 1;
- default:
- return -1;
- }
-}
-
-static int vendor_class_index(u8 mgmt_class)
-{
- return mgmt_class - IB_MGMT_CLASS_VENDOR_RANGE2_START;
-}
-
-static int is_vendor_class(u8 mgmt_class)
-{
- if ((mgmt_class < IB_MGMT_CLASS_VENDOR_RANGE2_START) ||
- (mgmt_class > IB_MGMT_CLASS_VENDOR_RANGE2_END))
- return 0;
- return 1;
-}
-
-static int is_vendor_oui(char *oui)
-{
- if (oui[0] || oui[1] || oui[2])
- return 1;
- return 0;
-}
-
-static int is_vendor_method_in_use(
- struct ib_mad_mgmt_vendor_class *vendor_class,
- struct ib_mad_reg_req *mad_reg_req)
-{
- struct ib_mad_mgmt_method_table *method;
- int i;
-
- for (i = 0; i < MAX_MGMT_OUI; i++) {
- if (!memcmp(vendor_class->oui[i], mad_reg_req->oui, 3)) {
- method = vendor_class->method_table[i];
- if (method) {
- if (method_in_use(&method, mad_reg_req))
- return 1;
- else
- break;
- }
- }
- }
- return 0;
-}
-
-int ib_response_mad(struct ib_mad *mad)
-{
- return ((mad->mad_hdr.method & IB_MGMT_METHOD_RESP) ||
- (mad->mad_hdr.method == IB_MGMT_METHOD_TRAP_REPRESS) ||
- ((mad->mad_hdr.mgmt_class == IB_MGMT_CLASS_BM) &&
- (mad->mad_hdr.attr_mod & IB_BM_ATTR_MOD_RESP)));
-}
-EXPORT_SYMBOL(ib_response_mad);
-
-/*
- * ib_register_mad_agent - Register to send/receive MADs
- */
-struct ib_mad_agent *ib_register_mad_agent(struct ib_device *device,
- u8 port_num,
- enum ib_qp_type qp_type,
- struct ib_mad_reg_req *mad_reg_req,
- u8 rmpp_version,
- ib_mad_send_handler send_handler,
- ib_mad_recv_handler recv_handler,
- void *context)
-{
- struct ib_mad_port_private *port_priv;
- struct ib_mad_agent *ret = ERR_PTR(-EINVAL);
- struct ib_mad_agent_private *mad_agent_priv;
- struct ib_mad_reg_req *reg_req = NULL;
- struct ib_mad_mgmt_class_table *class;
- struct ib_mad_mgmt_vendor_class_table *vendor;
- struct ib_mad_mgmt_vendor_class *vendor_class;
- struct ib_mad_mgmt_method_table *method;
- int ret2, qpn;
- unsigned long flags;
- u8 mgmt_class, vclass;
-
- /* Validate parameters */
- qpn = get_spl_qp_index(qp_type);
- if (qpn == -1)
- goto error1;
-
- if (rmpp_version && rmpp_version != IB_MGMT_RMPP_VERSION)
- goto error1;
-
- /* Validate MAD registration request if supplied */
- if (mad_reg_req) {
- if (mad_reg_req->mgmt_class_version >= MAX_MGMT_VERSION)
- goto error1;
- if (!recv_handler)
- goto error1;
- if (mad_reg_req->mgmt_class >= MAX_MGMT_CLASS) {
- /*
- * IB_MGMT_CLASS_SUBN_DIRECTED_ROUTE is the only
- * one in this range currently allowed
- */
- if (mad_reg_req->mgmt_class !=
- IB_MGMT_CLASS_SUBN_DIRECTED_ROUTE)
- goto error1;
- } else if (mad_reg_req->mgmt_class == 0) {
- /*
- * Class 0 is reserved in IBA and is used for
- * aliasing of IB_MGMT_CLASS_SUBN_DIRECTED_ROUTE
- */
- goto error1;
- } else if (is_vendor_class(mad_reg_req->mgmt_class)) {
- /*
- * If class is in "new" vendor range,
- * ensure supplied OUI is not zero
- */
- if (!is_vendor_oui(mad_reg_req->oui))
- goto error1;
- }
- /* Make sure class supplied is consistent with RMPP */
- if (!ib_is_mad_class_rmpp(mad_reg_req->mgmt_class)) {
- if (rmpp_version)
- goto error1;
- }
- /* Make sure class supplied is consistent with QP type */
- if (qp_type == IB_QPT_SMI) {
- if ((mad_reg_req->mgmt_class !=
- IB_MGMT_CLASS_SUBN_LID_ROUTED) &&
- (mad_reg_req->mgmt_class !=
- IB_MGMT_CLASS_SUBN_DIRECTED_ROUTE))
- goto error1;
- } else {
- if ((mad_reg_req->mgmt_class ==
- IB_MGMT_CLASS_SUBN_LID_ROUTED) ||
- (mad_reg_req->mgmt_class ==
- IB_MGMT_CLASS_SUBN_DIRECTED_ROUTE))
- goto error1;
- }
- } else {
- /* No registration request supplied */
- if (!send_handler)
- goto error1;
- }
-
- /* Validate device and port */
- port_priv = ib_get_mad_port(device, port_num);
- if (!port_priv) {
- ret = ERR_PTR(-ENODEV);
- goto error1;
- }
-
- /* Verify the QP requested is supported. For example, Ethernet devices
- * will not have QP0 */
- if (!port_priv->qp_info[qpn].qp) {
- ret = ERR_PTR(-EPROTONOSUPPORT);
- goto error1;
- }
-
- /* Allocate structures */
- mad_agent_priv = kzalloc(sizeof *mad_agent_priv, GFP_KERNEL);
- if (!mad_agent_priv) {
- ret = ERR_PTR(-ENOMEM);
- goto error1;
- }
-
- mad_agent_priv->agent.mr = ib_get_dma_mr(port_priv->qp_info[qpn].qp->pd,
- IB_ACCESS_LOCAL_WRITE);
- if (IS_ERR(mad_agent_priv->agent.mr)) {
- ret = ERR_PTR(-ENOMEM);
- goto error2;
- }
-
- if (mad_reg_req) {
- reg_req = kmemdup(mad_reg_req, sizeof *reg_req, GFP_KERNEL);
- if (!reg_req) {
- ret = ERR_PTR(-ENOMEM);
- goto error3;
- }
- }
-
- /* Now, fill in the various structures */
- mad_agent_priv->qp_info = &port_priv->qp_info[qpn];
- mad_agent_priv->reg_req = reg_req;
- mad_agent_priv->agent.rmpp_version = rmpp_version;
- mad_agent_priv->agent.device = device;
- mad_agent_priv->agent.recv_handler = recv_handler;
- mad_agent_priv->agent.send_handler = send_handler;
- mad_agent_priv->agent.context = context;
- mad_agent_priv->agent.qp = port_priv->qp_info[qpn].qp;
- mad_agent_priv->agent.port_num = port_num;
- spin_lock_init(&mad_agent_priv->lock);
- INIT_LIST_HEAD(&mad_agent_priv->send_list);
- INIT_LIST_HEAD(&mad_agent_priv->wait_list);
- INIT_LIST_HEAD(&mad_agent_priv->done_list);
- INIT_LIST_HEAD(&mad_agent_priv->rmpp_list);
- INIT_DELAYED_WORK(&mad_agent_priv->timed_work, timeout_sends);
- INIT_LIST_HEAD(&mad_agent_priv->local_list);
- INIT_WORK(&mad_agent_priv->local_work, local_completions);
- atomic_set(&mad_agent_priv->refcount, 1);
- init_completion(&mad_agent_priv->comp);
-
- spin_lock_irqsave(&port_priv->reg_lock, flags);
- mad_agent_priv->agent.hi_tid = ++ib_mad_client_id;
-
- /*
- * Make sure MAD registration (if supplied)
- * is non overlapping with any existing ones
- */
- if (mad_reg_req) {
- mgmt_class = convert_mgmt_class(mad_reg_req->mgmt_class);
- if (!is_vendor_class(mgmt_class)) {
- class = port_priv->version[mad_reg_req->
- mgmt_class_version].class;
- if (class) {
- method = class->method_table[mgmt_class];
- if (method) {
- if (method_in_use(&method,
- mad_reg_req))
- goto error4;
- }
- }
- ret2 = add_nonoui_reg_req(mad_reg_req, mad_agent_priv,
- mgmt_class);
- } else {
- /* "New" vendor class range */
- vendor = port_priv->version[mad_reg_req->
- mgmt_class_version].vendor;
- if (vendor) {
- vclass = vendor_class_index(mgmt_class);
- vendor_class = vendor->vendor_class[vclass];
- if (vendor_class) {
- if (is_vendor_method_in_use(
- vendor_class,
- mad_reg_req))
- goto error4;
- }
- }
- ret2 = add_oui_reg_req(mad_reg_req, mad_agent_priv);
- }
- if (ret2) {
- ret = ERR_PTR(ret2);
- goto error4;
- }
- }
-
- /* Add mad agent into port's agent list */
- list_add_tail(&mad_agent_priv->agent_list, &port_priv->agent_list);
- spin_unlock_irqrestore(&port_priv->reg_lock, flags);
-
- return &mad_agent_priv->agent;
-
-error4:
- spin_unlock_irqrestore(&port_priv->reg_lock, flags);
- kfree(reg_req);
-error3:
- ib_dereg_mr(mad_agent_priv->agent.mr);
-error2:
- kfree(mad_agent_priv);
-error1:
- return ret;
-}
-EXPORT_SYMBOL(ib_register_mad_agent);
-
-static inline int is_snooping_sends(int mad_snoop_flags)
-{
- return (mad_snoop_flags &
- (/*IB_MAD_SNOOP_POSTED_SENDS |
- IB_MAD_SNOOP_RMPP_SENDS |*/
- IB_MAD_SNOOP_SEND_COMPLETIONS /*|
- IB_MAD_SNOOP_RMPP_SEND_COMPLETIONS*/));
-}
-
-static inline int is_snooping_recvs(int mad_snoop_flags)
-{
- return (mad_snoop_flags &
- (IB_MAD_SNOOP_RECVS /*|
- IB_MAD_SNOOP_RMPP_RECVS*/));
-}
-
-static int register_snoop_agent(struct ib_mad_qp_info *qp_info,
- struct ib_mad_snoop_private *mad_snoop_priv)
-{
- struct ib_mad_snoop_private **new_snoop_table;
- unsigned long flags;
- int i;
-
- spin_lock_irqsave(&qp_info->snoop_lock, flags);
- /* Check for empty slot in array. */
- for (i = 0; i < qp_info->snoop_table_size; i++)
- if (!qp_info->snoop_table[i])
- break;
-
- if (i == qp_info->snoop_table_size) {
- /* Grow table. */
- new_snoop_table = krealloc(qp_info->snoop_table,
- sizeof mad_snoop_priv *
- (qp_info->snoop_table_size + 1),
- GFP_ATOMIC);
- if (!new_snoop_table) {
- i = -ENOMEM;
- goto out;
- }
-
- qp_info->snoop_table = new_snoop_table;
- qp_info->snoop_table_size++;
- }
- qp_info->snoop_table[i] = mad_snoop_priv;
- atomic_inc(&qp_info->snoop_count);
-out:
- spin_unlock_irqrestore(&qp_info->snoop_lock, flags);
- return i;
-}
-
-struct ib_mad_agent *ib_register_mad_snoop(struct ib_device *device,
- u8 port_num,
- enum ib_qp_type qp_type,
- int mad_snoop_flags,
- ib_mad_snoop_handler snoop_handler,
- ib_mad_recv_handler recv_handler,
- void *context)
-{
- struct ib_mad_port_private *port_priv;
- struct ib_mad_agent *ret;
- struct ib_mad_snoop_private *mad_snoop_priv;
- int qpn;
-
- /* Validate parameters */
- if ((is_snooping_sends(mad_snoop_flags) && !snoop_handler) ||
- (is_snooping_recvs(mad_snoop_flags) && !recv_handler)) {
- ret = ERR_PTR(-EINVAL);
- goto error1;
- }
- qpn = get_spl_qp_index(qp_type);
- if (qpn == -1) {
- ret = ERR_PTR(-EINVAL);
- goto error1;
- }
- port_priv = ib_get_mad_port(device, port_num);
- if (!port_priv) {
- ret = ERR_PTR(-ENODEV);
- goto error1;
- }
- /* Allocate structures */
- mad_snoop_priv = kzalloc(sizeof *mad_snoop_priv, GFP_KERNEL);
- if (!mad_snoop_priv) {
- ret = ERR_PTR(-ENOMEM);
- goto error1;
- }
-
- /* Now, fill in the various structures */
- mad_snoop_priv->qp_info = &port_priv->qp_info[qpn];
- mad_snoop_priv->agent.device = device;
- mad_snoop_priv->agent.recv_handler = recv_handler;
- mad_snoop_priv->agent.snoop_handler = snoop_handler;
- mad_snoop_priv->agent.context = context;
- mad_snoop_priv->agent.qp = port_priv->qp_info[qpn].qp;
- mad_snoop_priv->agent.port_num = port_num;
- mad_snoop_priv->mad_snoop_flags = mad_snoop_flags;
- init_completion(&mad_snoop_priv->comp);
- mad_snoop_priv->snoop_index = register_snoop_agent(
- &port_priv->qp_info[qpn],
- mad_snoop_priv);
- if (mad_snoop_priv->snoop_index < 0) {
- ret = ERR_PTR(mad_snoop_priv->snoop_index);
- goto error2;
- }
-
- atomic_set(&mad_snoop_priv->refcount, 1);
- return &mad_snoop_priv->agent;
-
-error2:
- kfree(mad_snoop_priv);
-error1:
- return ret;
-}
-EXPORT_SYMBOL(ib_register_mad_snoop);
-
-static inline void deref_mad_agent(struct ib_mad_agent_private *mad_agent_priv)
-{
- if (atomic_dec_and_test(&mad_agent_priv->refcount))
- complete(&mad_agent_priv->comp);
-}
-
-static inline void deref_snoop_agent(struct ib_mad_snoop_private *mad_snoop_priv)
-{
- if (atomic_dec_and_test(&mad_snoop_priv->refcount))
- complete(&mad_snoop_priv->comp);
-}
-
-static void unregister_mad_agent(struct ib_mad_agent_private *mad_agent_priv)
-{
- struct ib_mad_port_private *port_priv;
- unsigned long flags;
-
- /* Note that we could still be handling received MADs */
-
- /*
- * Canceling all sends results in dropping received response
- * MADs, preventing us from queuing additional work
- */
- cancel_mads(mad_agent_priv);
- port_priv = mad_agent_priv->qp_info->port_priv;
- cancel_delayed_work_sync(&mad_agent_priv->timed_work);
-
- spin_lock_irqsave(&port_priv->reg_lock, flags);
- remove_mad_reg_req(mad_agent_priv);
- list_del(&mad_agent_priv->agent_list);
- spin_unlock_irqrestore(&port_priv->reg_lock, flags);
-
- flush_workqueue(port_priv->wq);
- ib_cancel_rmpp_recvs(mad_agent_priv);
-
- deref_mad_agent(mad_agent_priv);
- wait_for_completion(&mad_agent_priv->comp);
-
- kfree(mad_agent_priv->reg_req);
- ib_dereg_mr(mad_agent_priv->agent.mr);
- kfree(mad_agent_priv);
-}
-
-static void unregister_mad_snoop(struct ib_mad_snoop_private *mad_snoop_priv)
-{
- struct ib_mad_qp_info *qp_info;
- unsigned long flags;
-
- qp_info = mad_snoop_priv->qp_info;
- spin_lock_irqsave(&qp_info->snoop_lock, flags);
- qp_info->snoop_table[mad_snoop_priv->snoop_index] = NULL;
- atomic_dec(&qp_info->snoop_count);
- spin_unlock_irqrestore(&qp_info->snoop_lock, flags);
-
- deref_snoop_agent(mad_snoop_priv);
- wait_for_completion(&mad_snoop_priv->comp);
-
- kfree(mad_snoop_priv);
-}
-
-/*
- * ib_unregister_mad_agent - Unregisters a client from using MAD services
- */
-int ib_unregister_mad_agent(struct ib_mad_agent *mad_agent)
-{
- struct ib_mad_agent_private *mad_agent_priv;
- struct ib_mad_snoop_private *mad_snoop_priv;
-
- if (!IS_ERR(mad_agent)) {
- /* If the TID is zero, the agent can only snoop. */
- if (mad_agent->hi_tid) {
- mad_agent_priv = container_of(mad_agent,
- struct ib_mad_agent_private,
- agent);
- unregister_mad_agent(mad_agent_priv);
- } else {
- mad_snoop_priv = container_of(mad_agent,
- struct ib_mad_snoop_private,
- agent);
- unregister_mad_snoop(mad_snoop_priv);
- }
- }
-
- return 0;
-}
-EXPORT_SYMBOL(ib_unregister_mad_agent);
-
-static void dequeue_mad(struct ib_mad_list_head *mad_list)
-{
- struct ib_mad_queue *mad_queue;
- unsigned long flags;
-
- BUG_ON(!mad_list->mad_queue);
- mad_queue = mad_list->mad_queue;
- spin_lock_irqsave(&mad_queue->lock, flags);
- list_del(&mad_list->list);
- mad_queue->count--;
- spin_unlock_irqrestore(&mad_queue->lock, flags);
-}
-
-static void snoop_send(struct ib_mad_qp_info *qp_info,
- struct ib_mad_send_buf *send_buf,
- struct ib_mad_send_wc *mad_send_wc,
- int mad_snoop_flags)
-{
- struct ib_mad_snoop_private *mad_snoop_priv;
- unsigned long flags;
- int i;
-
- spin_lock_irqsave(&qp_info->snoop_lock, flags);
- for (i = 0; i < qp_info->snoop_table_size; i++) {
- mad_snoop_priv = qp_info->snoop_table[i];
- if (!mad_snoop_priv ||
- !(mad_snoop_priv->mad_snoop_flags & mad_snoop_flags))
- continue;
-
- atomic_inc(&mad_snoop_priv->refcount);
- spin_unlock_irqrestore(&qp_info->snoop_lock, flags);
- mad_snoop_priv->agent.snoop_handler(&mad_snoop_priv->agent,
- send_buf, mad_send_wc);
- deref_snoop_agent(mad_snoop_priv);
- spin_lock_irqsave(&qp_info->snoop_lock, flags);
- }
- spin_unlock_irqrestore(&qp_info->snoop_lock, flags);
-}
-
-static void snoop_recv(struct ib_mad_qp_info *qp_info,
- struct ib_mad_recv_wc *mad_recv_wc,
- int mad_snoop_flags)
-{
- struct ib_mad_snoop_private *mad_snoop_priv;
- unsigned long flags;
- int i;
-
- spin_lock_irqsave(&qp_info->snoop_lock, flags);
- for (i = 0; i < qp_info->snoop_table_size; i++) {
- mad_snoop_priv = qp_info->snoop_table[i];
- if (!mad_snoop_priv ||
- !(mad_snoop_priv->mad_snoop_flags & mad_snoop_flags))
- continue;
-
- atomic_inc(&mad_snoop_priv->refcount);
- spin_unlock_irqrestore(&qp_info->snoop_lock, flags);
- mad_snoop_priv->agent.recv_handler(&mad_snoop_priv->agent,
- mad_recv_wc);
- deref_snoop_agent(mad_snoop_priv);
- spin_lock_irqsave(&qp_info->snoop_lock, flags);
- }
- spin_unlock_irqrestore(&qp_info->snoop_lock, flags);
-}
-
-static void build_smp_wc(struct ib_qp *qp,
- u64 wr_id, u16 slid, u16 pkey_index, u8 port_num,
- struct ib_wc *wc)
-{
- memset(wc, 0, sizeof *wc);
- wc->wr_id = wr_id;
- wc->status = IB_WC_SUCCESS;
- wc->opcode = IB_WC_RECV;
- wc->pkey_index = pkey_index;
- wc->byte_len = sizeof(struct ib_mad) + sizeof(struct ib_grh);
- wc->src_qp = IB_QP0;
- wc->qp = qp;
- wc->slid = slid;
- wc->sl = 0;
- wc->dlid_path_bits = 0;
- wc->port_num = port_num;
-}
-
-/*
- * Return 0 if SMP is to be sent
- * Return 1 if SMP was consumed locally (whether or not solicited)
- * Return < 0 if error
- */
-static int handle_outgoing_dr_smp(struct ib_mad_agent_private *mad_agent_priv,
- struct ib_mad_send_wr_private *mad_send_wr)
-{
- int ret = 0;
- struct ib_smp *smp = mad_send_wr->send_buf.mad;
- unsigned long flags;
- struct ib_mad_local_private *local;
- struct ib_mad_private *mad_priv;
- struct ib_mad_port_private *port_priv;
- struct ib_mad_agent_private *recv_mad_agent = NULL;
- struct ib_device *device = mad_agent_priv->agent.device;
- u8 port_num;
- struct ib_wc mad_wc;
- struct ib_send_wr *send_wr = &mad_send_wr->send_wr;
-
- if (device->node_type == RDMA_NODE_IB_SWITCH &&
- smp->mgmt_class == IB_MGMT_CLASS_SUBN_DIRECTED_ROUTE)
- port_num = send_wr->wr.ud.port_num;
- else
- port_num = mad_agent_priv->agent.port_num;
-
- /*
- * Directed route handling starts if the initial LID routed part of
- * a request or the ending LID routed part of a response is empty.
- * If we are at the start of the LID routed part, don't update the
- * hop_ptr or hop_cnt. See section 14.2.2, Vol 1 IB spec.
- */
- if ((ib_get_smp_direction(smp) ? smp->dr_dlid : smp->dr_slid) !=
- IB_LID_PERMISSIVE)
- goto out;
- if (smi_handle_dr_smp_send(smp, device->node_type, port_num) ==
- IB_SMI_DISCARD) {
- ret = -EINVAL;
- printk(KERN_ERR PFX "Invalid directed route\n");
- goto out;
- }
-
- /* Check to post send on QP or process locally */
- if (smi_check_local_smp(smp, device) == IB_SMI_DISCARD &&
- smi_check_local_returning_smp(smp, device) == IB_SMI_DISCARD)
- goto out;
-
- local = kmalloc(sizeof *local, GFP_ATOMIC);
- if (!local) {
- ret = -ENOMEM;
- printk(KERN_ERR PFX "No memory for ib_mad_local_private\n");
- goto out;
- }
- local->mad_priv = NULL;
- local->recv_mad_agent = NULL;
- mad_priv = kmem_cache_alloc(ib_mad_cache, GFP_ATOMIC);
- if (!mad_priv) {
- ret = -ENOMEM;
- printk(KERN_ERR PFX "No memory for local response MAD\n");
- kfree(local);
- goto out;
- }
-
- build_smp_wc(mad_agent_priv->agent.qp,
- send_wr->wr_id, be16_to_cpu(smp->dr_slid),
- send_wr->wr.ud.pkey_index,
- send_wr->wr.ud.port_num, &mad_wc);
-
- /* No GRH for DR SMP */
- ret = device->process_mad(device, 0, port_num, &mad_wc, NULL,
- (struct ib_mad *)smp,
- (struct ib_mad *)&mad_priv->mad);
- switch (ret)
- {
- case IB_MAD_RESULT_SUCCESS | IB_MAD_RESULT_REPLY:
- if (ib_response_mad(&mad_priv->mad.mad) &&
- mad_agent_priv->agent.recv_handler) {
- local->mad_priv = mad_priv;
- local->recv_mad_agent = mad_agent_priv;
- /*
- * Reference MAD agent until receive
- * side of local completion handled
- */
- atomic_inc(&mad_agent_priv->refcount);
- } else
- kmem_cache_free(ib_mad_cache, mad_priv);
- break;
- case IB_MAD_RESULT_SUCCESS | IB_MAD_RESULT_CONSUMED:
- kmem_cache_free(ib_mad_cache, mad_priv);
- break;
- case IB_MAD_RESULT_SUCCESS:
- /* Treat like an incoming receive MAD */
- port_priv = ib_get_mad_port(mad_agent_priv->agent.device,
- mad_agent_priv->agent.port_num);
- if (port_priv) {
- memcpy(&mad_priv->mad.mad, smp, sizeof(struct ib_mad));
- recv_mad_agent = find_mad_agent(port_priv,
- &mad_priv->mad.mad);
- }
- if (!port_priv || !recv_mad_agent) {
- /*
- * No receiving agent so drop packet and
- * generate send completion.
- */
- kmem_cache_free(ib_mad_cache, mad_priv);
- break;
- }
- local->mad_priv = mad_priv;
- local->recv_mad_agent = recv_mad_agent;
- break;
- default:
- kmem_cache_free(ib_mad_cache, mad_priv);
- kfree(local);
- ret = -EINVAL;
- goto out;
- }
-
- local->mad_send_wr = mad_send_wr;
- /* Reference MAD agent until send side of local completion handled */
- atomic_inc(&mad_agent_priv->refcount);
- /* Queue local completion to local list */
- spin_lock_irqsave(&mad_agent_priv->lock, flags);
- list_add_tail(&local->completion_list, &mad_agent_priv->local_list);
- spin_unlock_irqrestore(&mad_agent_priv->lock, flags);
- queue_work(mad_agent_priv->qp_info->port_priv->wq,
- &mad_agent_priv->local_work);
- ret = 1;
-out:
- return ret;
-}
-
-static int get_pad_size(int hdr_len, int data_len)
-{
- int seg_size, pad;
-
- seg_size = sizeof(struct ib_mad) - hdr_len;
- if (data_len && seg_size) {
- pad = seg_size - data_len % seg_size;
- return pad == seg_size ? 0 : pad;
- } else
- return seg_size;
-}
-
-static void free_send_rmpp_list(struct ib_mad_send_wr_private *mad_send_wr)
-{
- struct ib_rmpp_segment *s, *t;
-
- list_for_each_entry_safe(s, t, &mad_send_wr->rmpp_list, list) {
- list_del(&s->list);
- kfree(s);
- }
-}
-
-static int alloc_send_rmpp_list(struct ib_mad_send_wr_private *send_wr,
- gfp_t gfp_mask)
-{
- struct ib_mad_send_buf *send_buf = &send_wr->send_buf;
- struct ib_rmpp_mad *rmpp_mad = send_buf->mad;
- struct ib_rmpp_segment *seg = NULL;
- int left, seg_size, pad;
-
- send_buf->seg_size = sizeof (struct ib_mad) - send_buf->hdr_len;
- seg_size = send_buf->seg_size;
- pad = send_wr->pad;
-
- /* Allocate data segments. */
- for (left = send_buf->data_len + pad; left > 0; left -= seg_size) {
- seg = kmalloc(sizeof (*seg) + seg_size, gfp_mask);
- if (!seg) {
- printk(KERN_ERR "alloc_send_rmpp_segs: RMPP mem "
- "alloc failed for len %zd, gfp %#x\n",
- sizeof (*seg) + seg_size, gfp_mask);
- free_send_rmpp_list(send_wr);
- return -ENOMEM;
- }
- seg->num = ++send_buf->seg_count;
- list_add_tail(&seg->list, &send_wr->rmpp_list);
- }
-
- /* Zero any padding */
- if (pad)
- memset(seg->data + seg_size - pad, 0, pad);
-
- rmpp_mad->rmpp_hdr.rmpp_version = send_wr->mad_agent_priv->
- agent.rmpp_version;
- rmpp_mad->rmpp_hdr.rmpp_type = IB_MGMT_RMPP_TYPE_DATA;
- ib_set_rmpp_flags(&rmpp_mad->rmpp_hdr, IB_MGMT_RMPP_FLAG_ACTIVE);
-
- send_wr->cur_seg = container_of(send_wr->rmpp_list.next,
- struct ib_rmpp_segment, list);
- send_wr->last_ack_seg = send_wr->cur_seg;
- return 0;
-}
-
-struct ib_mad_send_buf * ib_create_send_mad(struct ib_mad_agent *mad_agent,
- u32 remote_qpn, u16 pkey_index,
- int rmpp_active,
- int hdr_len, int data_len,
- gfp_t gfp_mask)
-{
- struct ib_mad_agent_private *mad_agent_priv;
- struct ib_mad_send_wr_private *mad_send_wr;
- int pad, message_size, ret, size;
- void *buf;
-
- mad_agent_priv = container_of(mad_agent, struct ib_mad_agent_private,
- agent);
- pad = get_pad_size(hdr_len, data_len);
- message_size = hdr_len + data_len + pad;
-
- if ((!mad_agent->rmpp_version &&
- (rmpp_active || message_size > sizeof(struct ib_mad))) ||
- (!rmpp_active && message_size > sizeof(struct ib_mad)))
- return ERR_PTR(-EINVAL);
-
- size = rmpp_active ? hdr_len : sizeof(struct ib_mad);
- buf = kzalloc(sizeof *mad_send_wr + size, gfp_mask);
- if (!buf)
- return ERR_PTR(-ENOMEM);
-
- mad_send_wr = buf + size;
- INIT_LIST_HEAD(&mad_send_wr->rmpp_list);
- mad_send_wr->send_buf.mad = buf;
- mad_send_wr->send_buf.hdr_len = hdr_len;
- mad_send_wr->send_buf.data_len = data_len;
- mad_send_wr->pad = pad;
-
- mad_send_wr->mad_agent_priv = mad_agent_priv;
- mad_send_wr->sg_list[0].length = hdr_len;
- mad_send_wr->sg_list[0].lkey = mad_agent->mr->lkey;
- mad_send_wr->sg_list[1].length = sizeof(struct ib_mad) - hdr_len;
- mad_send_wr->sg_list[1].lkey = mad_agent->mr->lkey;
-
- mad_send_wr->send_wr.wr_id = (unsigned long) mad_send_wr;
- mad_send_wr->send_wr.sg_list = mad_send_wr->sg_list;
- mad_send_wr->send_wr.num_sge = 2;
- mad_send_wr->send_wr.opcode = IB_WR_SEND;
- mad_send_wr->send_wr.send_flags = IB_SEND_SIGNALED;
- mad_send_wr->send_wr.wr.ud.remote_qpn = remote_qpn;
- mad_send_wr->send_wr.wr.ud.remote_qkey = IB_QP_SET_QKEY;
- mad_send_wr->send_wr.wr.ud.pkey_index = pkey_index;
-
- if (rmpp_active) {
- ret = alloc_send_rmpp_list(mad_send_wr, gfp_mask);
- if (ret) {
- kfree(buf);
- return ERR_PTR(ret);
- }
- }
-
- mad_send_wr->send_buf.mad_agent = mad_agent;
- atomic_inc(&mad_agent_priv->refcount);
- return &mad_send_wr->send_buf;
-}
-EXPORT_SYMBOL(ib_create_send_mad);
-
-int ib_get_mad_data_offset(u8 mgmt_class)
-{
- if (mgmt_class == IB_MGMT_CLASS_SUBN_ADM)
- return IB_MGMT_SA_HDR;
- else if ((mgmt_class == IB_MGMT_CLASS_DEVICE_MGMT) ||
- (mgmt_class == IB_MGMT_CLASS_DEVICE_ADM) ||
- (mgmt_class == IB_MGMT_CLASS_BIS))
- return IB_MGMT_DEVICE_HDR;
- else if ((mgmt_class >= IB_MGMT_CLASS_VENDOR_RANGE2_START) &&
- (mgmt_class <= IB_MGMT_CLASS_VENDOR_RANGE2_END))
- return IB_MGMT_VENDOR_HDR;
- else
- return IB_MGMT_MAD_HDR;
-}
-EXPORT_SYMBOL(ib_get_mad_data_offset);
-
-int ib_is_mad_class_rmpp(u8 mgmt_class)
-{
- if ((mgmt_class == IB_MGMT_CLASS_SUBN_ADM) ||
- (mgmt_class == IB_MGMT_CLASS_DEVICE_MGMT) ||
- (mgmt_class == IB_MGMT_CLASS_DEVICE_ADM) ||
- (mgmt_class == IB_MGMT_CLASS_BIS) ||
- ((mgmt_class >= IB_MGMT_CLASS_VENDOR_RANGE2_START) &&
- (mgmt_class <= IB_MGMT_CLASS_VENDOR_RANGE2_END)))
- return 1;
- return 0;
-}
-EXPORT_SYMBOL(ib_is_mad_class_rmpp);
-
-void *ib_get_rmpp_segment(struct ib_mad_send_buf *send_buf, int seg_num)
-{
- struct ib_mad_send_wr_private *mad_send_wr;
- struct list_head *list;
-
- mad_send_wr = container_of(send_buf, struct ib_mad_send_wr_private,
- send_buf);
- list = &mad_send_wr->cur_seg->list;
-
- if (mad_send_wr->cur_seg->num < seg_num) {
- list_for_each_entry(mad_send_wr->cur_seg, list, list)
- if (mad_send_wr->cur_seg->num == seg_num)
- break;
- } else if (mad_send_wr->cur_seg->num > seg_num) {
- list_for_each_entry_reverse(mad_send_wr->cur_seg, list, list)
- if (mad_send_wr->cur_seg->num == seg_num)
- break;
- }
- return mad_send_wr->cur_seg->data;
-}
-EXPORT_SYMBOL(ib_get_rmpp_segment);
-
-static inline void *ib_get_payload(struct ib_mad_send_wr_private *mad_send_wr)
-{
- if (mad_send_wr->send_buf.seg_count)
- return ib_get_rmpp_segment(&mad_send_wr->send_buf,
- mad_send_wr->seg_num);
- else
- return mad_send_wr->send_buf.mad +
- mad_send_wr->send_buf.hdr_len;
-}
-
-void ib_free_send_mad(struct ib_mad_send_buf *send_buf)
-{
- struct ib_mad_agent_private *mad_agent_priv;
- struct ib_mad_send_wr_private *mad_send_wr;
-
- mad_agent_priv = container_of(send_buf->mad_agent,
- struct ib_mad_agent_private, agent);
- mad_send_wr = container_of(send_buf, struct ib_mad_send_wr_private,
- send_buf);
-
- free_send_rmpp_list(mad_send_wr);
- kfree(send_buf->mad);
- deref_mad_agent(mad_agent_priv);
-}
-EXPORT_SYMBOL(ib_free_send_mad);
-
-int ib_send_mad(struct ib_mad_send_wr_private *mad_send_wr)
-{
- struct ib_mad_qp_info *qp_info;
- struct list_head *list;
- struct ib_send_wr *bad_send_wr;
- struct ib_mad_agent *mad_agent;
- struct ib_sge *sge;
- unsigned long flags;
- int ret;
-
- /* Set WR ID to find mad_send_wr upon completion */
- qp_info = mad_send_wr->mad_agent_priv->qp_info;
- mad_send_wr->send_wr.wr_id = (unsigned long)&mad_send_wr->mad_list;
- mad_send_wr->mad_list.mad_queue = &qp_info->send_queue;
-
- mad_agent = mad_send_wr->send_buf.mad_agent;
- sge = mad_send_wr->sg_list;
- sge[0].addr = ib_dma_map_single(mad_agent->device,
- mad_send_wr->send_buf.mad,
- sge[0].length,
- DMA_TO_DEVICE);
- if (unlikely(ib_dma_mapping_error(mad_agent->device, sge[0].addr)))
- return -ENOMEM;
-
- sge[1].addr = ib_dma_map_single(mad_agent->device,
- ib_get_payload(mad_send_wr),
- sge[1].length,
- DMA_TO_DEVICE);
-
- if (unlikely(ib_dma_mapping_error(mad_agent->device, sge[1].addr))) {
- ret = -ENOMEM;
- goto dma1_err;
- }
-
- mad_send_wr->header_mapping = sge[0].addr;
- mad_send_wr->payload_mapping = sge[1].addr;
-
- spin_lock_irqsave(&qp_info->send_queue.lock, flags);
- if (qp_info->send_queue.count < qp_info->send_queue.max_active) {
- ret = ib_post_send(mad_agent->qp, &mad_send_wr->send_wr,
- &bad_send_wr);
- list = &qp_info->send_queue.list;
- } else {
- ret = 0;
- list = &qp_info->overflow_list;
- }
-
- if (!ret) {
- qp_info->send_queue.count++;
- list_add_tail(&mad_send_wr->mad_list.list, list);
- }
- spin_unlock_irqrestore(&qp_info->send_queue.lock, flags);
-
- if (!ret)
- return 0;
-
- ib_dma_unmap_single(mad_agent->device,
- mad_send_wr->header_mapping,
- sge[1].length, DMA_TO_DEVICE);
-dma1_err:
- ib_dma_unmap_single(mad_agent->device,
- mad_send_wr->payload_mapping,
- sge[0].length, DMA_TO_DEVICE);
- return ret;
-}
-
-/*
- * Send SA MAD that passed congestion control
- */
-static int send_sa_cc_mad(struct ib_mad_send_wr_private *mad_send_wr,
- u32 timeout_ms, u32 retries_left)
-{
- int ret;
- unsigned long flags;
- struct ib_mad_agent_private *mad_agent_priv;
-
- mad_agent_priv = mad_send_wr->mad_agent_priv;
- mad_send_wr->timeout = msecs_to_jiffies(timeout_ms);
- mad_send_wr->retries_left = retries_left;
- mad_send_wr->refcount = 1 + (mad_send_wr->timeout > 0);
-
- /* Reference MAD agent until send completes */
- atomic_inc(&mad_agent_priv->refcount);
- spin_lock_irqsave(&mad_agent_priv->lock, flags);
- list_add_tail(&mad_send_wr->agent_list,
- &mad_agent_priv->send_list);
- spin_unlock_irqrestore(&mad_agent_priv->lock, flags);
-
- ret = ib_send_mad(mad_send_wr);
- if (ret < 0) {
- /* Fail send request */
- spin_lock_irqsave(&mad_agent_priv->lock, flags);
- list_del(&mad_send_wr->agent_list);
- spin_unlock_irqrestore(&mad_agent_priv->lock, flags);
- atomic_dec(&mad_agent_priv->refcount);
- }
-
- return ret;
-}
-
-/*
- * ib_post_send_mad - Posts MAD(s) to the send queue of the QP associated
- * with the registered client
- */
-int ib_post_send_mad(struct ib_mad_send_buf *send_buf,
- struct ib_mad_send_buf **bad_send_buf)
-{
- struct ib_mad_agent_private *mad_agent_priv;
- struct ib_mad_send_buf *next_send_buf;
- struct ib_mad_send_wr_private *mad_send_wr;
- unsigned long flags;
- int ret = -EINVAL;
-
- /* Walk list of send WRs and post each on send list */
- for (; send_buf; send_buf = next_send_buf) {
-
- mad_send_wr = container_of(send_buf,
- struct ib_mad_send_wr_private,
- send_buf);
- mad_agent_priv = mad_send_wr->mad_agent_priv;
-
- if (!send_buf->mad_agent->send_handler ||
- (send_buf->timeout_ms &&
- !send_buf->mad_agent->recv_handler)) {
- ret = -EINVAL;
- goto error;
- }
-
- if (!ib_is_mad_class_rmpp(((struct ib_mad_hdr *) send_buf->mad)->mgmt_class)) {
- if (mad_agent_priv->agent.rmpp_version) {
- ret = -EINVAL;
- goto error;
- }
- }
-
- /*
- * Save pointer to next work request to post in case the
- * current one completes, and the user modifies the work
- * request associated with the completion
- */
- next_send_buf = send_buf->next;
- mad_send_wr->send_wr.wr.ud.ah = send_buf->ah;
-
- if (((struct ib_mad_hdr *) send_buf->mad)->mgmt_class ==
- IB_MGMT_CLASS_SUBN_DIRECTED_ROUTE) {
- ret = handle_outgoing_dr_smp(mad_agent_priv,
- mad_send_wr);
- if (ret < 0) /* error */
- goto error;
- else if (ret == 1) /* locally consumed */
- continue;
- }
-
- mad_send_wr->tid = ((struct ib_mad_hdr *) send_buf->mad)->tid;
- /* Timeout will be updated after send completes */
- mad_send_wr->timeout = msecs_to_jiffies(send_buf->timeout_ms);
- mad_send_wr->max_retries = send_buf->retries;
- mad_send_wr->retries_left = send_buf->retries;
- send_buf->retries = 0;
- /* Reference for work request to QP + response */
- mad_send_wr->refcount = 1 + (mad_send_wr->timeout > 0);
- mad_send_wr->status = IB_WC_SUCCESS;
-
- if (is_sa_cc_mad(mad_send_wr)) {
- mad_send_wr->is_sa_cc_mad = 1;
- ret = sa_cc_mad_send(mad_send_wr);
- if (ret < 0)
- goto error;
- } else {
- /* Reference MAD agent until send completes */
- atomic_inc(&mad_agent_priv->refcount);
- spin_lock_irqsave(&mad_agent_priv->lock, flags);
- list_add_tail(&mad_send_wr->agent_list,
- &mad_agent_priv->send_list);
- spin_unlock_irqrestore(&mad_agent_priv->lock, flags);
-
- if (mad_agent_priv->agent.rmpp_version) {
- ret = ib_send_rmpp_mad(mad_send_wr);
- if (ret >= 0 && ret != IB_RMPP_RESULT_CONSUMED)
- ret = ib_send_mad(mad_send_wr);
- } else
- ret = ib_send_mad(mad_send_wr);
- if (ret < 0) {
- /* Fail send request */
- spin_lock_irqsave(&mad_agent_priv->lock, flags);
- list_del(&mad_send_wr->agent_list);
- spin_unlock_irqrestore(&mad_agent_priv->lock, flags);
- atomic_dec(&mad_agent_priv->refcount);
- goto error;
- }
- }
- }
- return 0;
-error:
- if (bad_send_buf)
- *bad_send_buf = send_buf;
- return ret;
-}
-EXPORT_SYMBOL(ib_post_send_mad);
-
-/*
- * ib_free_recv_mad - Returns data buffers used to receive
- * a MAD to the access layer
- */
-void ib_free_recv_mad(struct ib_mad_recv_wc *mad_recv_wc)
-{
- struct ib_mad_recv_buf *mad_recv_buf, *temp_recv_buf;
- struct ib_mad_private_header *mad_priv_hdr;
- struct ib_mad_private *priv;
- struct list_head free_list;
-
- INIT_LIST_HEAD(&free_list);
- list_splice_init(&mad_recv_wc->rmpp_list, &free_list);
-
- list_for_each_entry_safe(mad_recv_buf, temp_recv_buf,
- &free_list, list) {
- mad_recv_wc = container_of(mad_recv_buf, struct ib_mad_recv_wc,
- recv_buf);
- mad_priv_hdr = container_of(mad_recv_wc,
- struct ib_mad_private_header,
- recv_wc);
- priv = container_of(mad_priv_hdr, struct ib_mad_private,
- header);
- kmem_cache_free(ib_mad_cache, priv);
- }
-}
-EXPORT_SYMBOL(ib_free_recv_mad);
-
-struct ib_mad_agent *ib_redirect_mad_qp(struct ib_qp *qp,
- u8 rmpp_version,
- ib_mad_send_handler send_handler,
- ib_mad_recv_handler recv_handler,
- void *context)
-{
- return ERR_PTR(-EINVAL); /* XXX: for now */
-}
-EXPORT_SYMBOL(ib_redirect_mad_qp);
-
-int ib_process_mad_wc(struct ib_mad_agent *mad_agent,
- struct ib_wc *wc)
-{
- printk(KERN_ERR PFX "ib_process_mad_wc() not implemented yet\n");
- return 0;
-}
-EXPORT_SYMBOL(ib_process_mad_wc);
-
-static int method_in_use(struct ib_mad_mgmt_method_table **method,
- struct ib_mad_reg_req *mad_reg_req)
-{
- int i;
-
- for_each_set_bit(i, mad_reg_req->method_mask, IB_MGMT_MAX_METHODS) {
- if ((*method)->agent[i]) {
- printk(KERN_ERR PFX "Method %d already in use\n", i);
- return -EINVAL;
- }
- }
- return 0;
-}
-
-static int allocate_method_table(struct ib_mad_mgmt_method_table **method)
-{
- /* Allocate management method table */
- *method = kzalloc(sizeof **method, GFP_ATOMIC);
- if (!*method) {
- printk(KERN_ERR PFX "No memory for "
- "ib_mad_mgmt_method_table\n");
- return -ENOMEM;
- }
-
- return 0;
-}
-
-/*
- * Check to see if there are any methods still in use
- */
-static int check_method_table(struct ib_mad_mgmt_method_table *method)
-{
- int i;
-
- for (i = 0; i < IB_MGMT_MAX_METHODS; i++)
- if (method->agent[i])
- return 1;
- return 0;
-}
-
-/*
- * Check to see if there are any method tables for this class still in use
- */
-static int check_class_table(struct ib_mad_mgmt_class_table *class)
-{
- int i;
-
- for (i = 0; i < MAX_MGMT_CLASS; i++)
- if (class->method_table[i])
- return 1;
- return 0;
-}
-
-static int check_vendor_class(struct ib_mad_mgmt_vendor_class *vendor_class)
-{
- int i;
-
- for (i = 0; i < MAX_MGMT_OUI; i++)
- if (vendor_class->method_table[i])
- return 1;
- return 0;
-}
-
-static int find_vendor_oui(struct ib_mad_mgmt_vendor_class *vendor_class,
- char *oui)
-{
- int i;
-
- for (i = 0; i < MAX_MGMT_OUI; i++)
- /* Is there matching OUI for this vendor class ? */
- if (!memcmp(vendor_class->oui[i], oui, 3))
- return i;
-
- return -1;
-}
-
-static int check_vendor_table(struct ib_mad_mgmt_vendor_class_table *vendor)
-{
- int i;
-
- for (i = 0; i < MAX_MGMT_VENDOR_RANGE2; i++)
- if (vendor->vendor_class[i])
- return 1;
-
- return 0;
-}
-
-static void remove_methods_mad_agent(struct ib_mad_mgmt_method_table *method,
- struct ib_mad_agent_private *agent)
-{
- int i;
-
- /* Remove any methods for this mad agent */
- for (i = 0; i < IB_MGMT_MAX_METHODS; i++) {
- if (method->agent[i] == agent) {
- method->agent[i] = NULL;
- }
- }
-}
-
-static int add_nonoui_reg_req(struct ib_mad_reg_req *mad_reg_req,
- struct ib_mad_agent_private *agent_priv,
- u8 mgmt_class)
-{
- struct ib_mad_port_private *port_priv;
- struct ib_mad_mgmt_class_table **class;
- struct ib_mad_mgmt_method_table **method;
- int i, ret;
-
- port_priv = agent_priv->qp_info->port_priv;
- class = &port_priv->version[mad_reg_req->mgmt_class_version].class;
- if (!*class) {
- /* Allocate management class table for "new" class version */
- *class = kzalloc(sizeof **class, GFP_ATOMIC);
- if (!*class) {
- printk(KERN_ERR PFX "No memory for "
- "ib_mad_mgmt_class_table\n");
- ret = -ENOMEM;
- goto error1;
- }
-
- /* Allocate method table for this management class */
- method = &(*class)->method_table[mgmt_class];
- if ((ret = allocate_method_table(method)))
- goto error2;
- } else {
- method = &(*class)->method_table[mgmt_class];
- if (!*method) {
- /* Allocate method table for this management class */
- if ((ret = allocate_method_table(method)))
- goto error1;
- }
- }
-
- /* Now, make sure methods are not already in use */
- if (method_in_use(method, mad_reg_req))
- goto error3;
-
- /* Finally, add in methods being registered */
- for_each_set_bit(i, mad_reg_req->method_mask, IB_MGMT_MAX_METHODS)
- (*method)->agent[i] = agent_priv;
-
- return 0;
-
-error3:
- /* Remove any methods for this mad agent */
- remove_methods_mad_agent(*method, agent_priv);
- /* Now, check to see if there are any methods in use */
- if (!check_method_table(*method)) {
- /* If not, release management method table */
- kfree(*method);
- *method = NULL;
- }
- ret = -EINVAL;
- goto error1;
-error2:
- kfree(*class);
- *class = NULL;
-error1:
- return ret;
-}
-
-static int add_oui_reg_req(struct ib_mad_reg_req *mad_reg_req,
- struct ib_mad_agent_private *agent_priv)
-{
- struct ib_mad_port_private *port_priv;
- struct ib_mad_mgmt_vendor_class_table **vendor_table;
- struct ib_mad_mgmt_vendor_class_table *vendor = NULL;
- struct ib_mad_mgmt_vendor_class *vendor_class = NULL;
- struct ib_mad_mgmt_method_table **method;
- int i, ret = -ENOMEM;
- u8 vclass;
-
- /* "New" vendor (with OUI) class */
- vclass = vendor_class_index(mad_reg_req->mgmt_class);
- port_priv = agent_priv->qp_info->port_priv;
- vendor_table = &port_priv->version[
- mad_reg_req->mgmt_class_version].vendor;
- if (!*vendor_table) {
- /* Allocate mgmt vendor class table for "new" class version */
- vendor = kzalloc(sizeof *vendor, GFP_ATOMIC);
- if (!vendor) {
- printk(KERN_ERR PFX "No memory for "
- "ib_mad_mgmt_vendor_class_table\n");
- goto error1;
- }
-
- *vendor_table = vendor;
- }
- if (!(*vendor_table)->vendor_class[vclass]) {
- /* Allocate table for this management vendor class */
- vendor_class = kzalloc(sizeof *vendor_class, GFP_ATOMIC);
- if (!vendor_class) {
- printk(KERN_ERR PFX "No memory for "
- "ib_mad_mgmt_vendor_class\n");
- goto error2;
- }
-
- (*vendor_table)->vendor_class[vclass] = vendor_class;
- }
- for (i = 0; i < MAX_MGMT_OUI; i++) {
- /* Is there matching OUI for this vendor class ? */
- if (!memcmp((*vendor_table)->vendor_class[vclass]->oui[i],
- mad_reg_req->oui, 3)) {
- method = &(*vendor_table)->vendor_class[
- vclass]->method_table[i];
- BUG_ON(!*method);
- goto check_in_use;
- }
- }
- for (i = 0; i < MAX_MGMT_OUI; i++) {
- /* OUI slot available ? */
- if (!is_vendor_oui((*vendor_table)->vendor_class[
- vclass]->oui[i])) {
- method = &(*vendor_table)->vendor_class[
- vclass]->method_table[i];
- BUG_ON(*method);
- /* Allocate method table for this OUI */
- if ((ret = allocate_method_table(method)))
- goto error3;
- memcpy((*vendor_table)->vendor_class[vclass]->oui[i],
- mad_reg_req->oui, 3);
- goto check_in_use;
- }
- }
- printk(KERN_ERR PFX "All OUI slots in use\n");
- goto error3;
-
-check_in_use:
- /* Now, make sure methods are not already in use */
- if (method_in_use(method, mad_reg_req))
- goto error4;
-
- /* Finally, add in methods being registered */
- for_each_set_bit(i, mad_reg_req->method_mask, IB_MGMT_MAX_METHODS)
- (*method)->agent[i] = agent_priv;
-
- return 0;
-
-error4:
- /* Remove any methods for this mad agent */
- remove_methods_mad_agent(*method, agent_priv);
- /* Now, check to see if there are any methods in use */
- if (!check_method_table(*method)) {
- /* If not, release management method table */
- kfree(*method);
- *method = NULL;
- }
- ret = -EINVAL;
-error3:
- if (vendor_class) {
- (*vendor_table)->vendor_class[vclass] = NULL;
- kfree(vendor_class);
- }
-error2:
- if (vendor) {
- *vendor_table = NULL;
- kfree(vendor);
- }
-error1:
- return ret;
-}
-
-static void remove_mad_reg_req(struct ib_mad_agent_private *agent_priv)
-{
- struct ib_mad_port_private *port_priv;
- struct ib_mad_mgmt_class_table *class;
- struct ib_mad_mgmt_method_table *method;
- struct ib_mad_mgmt_vendor_class_table *vendor;
- struct ib_mad_mgmt_vendor_class *vendor_class;
- int index;
- u8 mgmt_class;
-
- /*
- * Was MAD registration request supplied
- * with original registration ?
- */
- if (!agent_priv->reg_req) {
- goto out;
- }
-
- port_priv = agent_priv->qp_info->port_priv;
- mgmt_class = convert_mgmt_class(agent_priv->reg_req->mgmt_class);
- class = port_priv->version[
- agent_priv->reg_req->mgmt_class_version].class;
- if (!class)
- goto vendor_check;
-
- method = class->method_table[mgmt_class];
- if (method) {
- /* Remove any methods for this mad agent */
- remove_methods_mad_agent(method, agent_priv);
- /* Now, check to see if there are any methods still in use */
- if (!check_method_table(method)) {
- /* If not, release management method table */
- kfree(method);
- class->method_table[mgmt_class] = NULL;
- /* Any management classes left ? */
- if (!check_class_table(class)) {
- /* If not, release management class table */
- kfree(class);
- port_priv->version[
- agent_priv->reg_req->
- mgmt_class_version].class = NULL;
- }
- }
- }
-
-vendor_check:
- if (!is_vendor_class(mgmt_class))
- goto out;
-
- /* normalize mgmt_class to vendor range 2 */
- mgmt_class = vendor_class_index(agent_priv->reg_req->mgmt_class);
- vendor = port_priv->version[
- agent_priv->reg_req->mgmt_class_version].vendor;
-
- if (!vendor)
- goto out;
-
- vendor_class = vendor->vendor_class[mgmt_class];
- if (vendor_class) {
- index = find_vendor_oui(vendor_class, agent_priv->reg_req->oui);
- if (index < 0)
- goto out;
- method = vendor_class->method_table[index];
- if (method) {
- /* Remove any methods for this mad agent */
- remove_methods_mad_agent(method, agent_priv);
- /*
- * Now, check to see if there are
- * any methods still in use
- */
- if (!check_method_table(method)) {
- /* If not, release management method table */
- kfree(method);
- vendor_class->method_table[index] = NULL;
- memset(vendor_class->oui[index], 0, 3);
- /* Any OUIs left ? */
- if (!check_vendor_class(vendor_class)) {
- /* If not, release vendor class table */
- kfree(vendor_class);
- vendor->vendor_class[mgmt_class] = NULL;
- /* Any other vendor classes left ? */
- if (!check_vendor_table(vendor)) {
- kfree(vendor);
- port_priv->version[
- agent_priv->reg_req->
- mgmt_class_version].
- vendor = NULL;
- }
- }
- }
- }
- }
-
-out:
- return;
-}
-
-static struct ib_mad_agent_private *
-find_mad_agent(struct ib_mad_port_private *port_priv,
- struct ib_mad *mad)
-{
- struct ib_mad_agent_private *mad_agent = NULL;
- unsigned long flags;
-
- spin_lock_irqsave(&port_priv->reg_lock, flags);
- if (ib_response_mad(mad)) {
- u32 hi_tid;
- struct ib_mad_agent_private *entry;
-
- /*
- * Routing is based on high 32 bits of transaction ID
- * of MAD.
- */
- hi_tid = be64_to_cpu(mad->mad_hdr.tid) >> 32;
- list_for_each_entry(entry, &port_priv->agent_list, agent_list) {
- if (entry->agent.hi_tid == hi_tid) {
- mad_agent = entry;
- break;
- }
- }
- } else {
- struct ib_mad_mgmt_class_table *class;
- struct ib_mad_mgmt_method_table *method;
- struct ib_mad_mgmt_vendor_class_table *vendor;
- struct ib_mad_mgmt_vendor_class *vendor_class;
- struct ib_vendor_mad *vendor_mad;
- int index;
-
- /*
- * Routing is based on version, class, and method
- * For "newer" vendor MADs, also based on OUI
- */
- if (mad->mad_hdr.class_version >= MAX_MGMT_VERSION)
- goto out;
- if (!is_vendor_class(mad->mad_hdr.mgmt_class)) {
- class = port_priv->version[
- mad->mad_hdr.class_version].class;
- if (!class)
- goto out;
- if (convert_mgmt_class(mad->mad_hdr.mgmt_class) >=
- IB_MGMT_MAX_METHODS)
- goto out;
- method = class->method_table[convert_mgmt_class(
- mad->mad_hdr.mgmt_class)];
- if (method)
- mad_agent = method->agent[mad->mad_hdr.method &
- ~IB_MGMT_METHOD_RESP];
- } else {
- vendor = port_priv->version[
- mad->mad_hdr.class_version].vendor;
- if (!vendor)
- goto out;
- vendor_class = vendor->vendor_class[vendor_class_index(
- mad->mad_hdr.mgmt_class)];
- if (!vendor_class)
- goto out;
- /* Find matching OUI */
- vendor_mad = (struct ib_vendor_mad *)mad;
- index = find_vendor_oui(vendor_class, vendor_mad->oui);
- if (index == -1)
- goto out;
- method = vendor_class->method_table[index];
- if (method) {
- mad_agent = method->agent[mad->mad_hdr.method &
- ~IB_MGMT_METHOD_RESP];
- }
- }
- }
-
- if (mad_agent) {
- if (mad_agent->agent.recv_handler)
- atomic_inc(&mad_agent->refcount);
- else {
- printk(KERN_NOTICE PFX "No receive handler for client "
- "%p on port %d\n",
- &mad_agent->agent, port_priv->port_num);
- mad_agent = NULL;
- }
- }
-out:
- spin_unlock_irqrestore(&port_priv->reg_lock, flags);
-
- return mad_agent;
-}
-
-static int validate_mad(struct ib_mad *mad, u32 qp_num)
-{
- int valid = 0;
-
- /* Make sure MAD base version is understood */
- if (mad->mad_hdr.base_version != IB_MGMT_BASE_VERSION) {
- printk(KERN_ERR PFX "MAD received with unsupported base "
- "version %d\n", mad->mad_hdr.base_version);
- goto out;
- }
-
- /* Filter SMI packets sent to other than QP0 */
- if ((mad->mad_hdr.mgmt_class == IB_MGMT_CLASS_SUBN_LID_ROUTED) ||
- (mad->mad_hdr.mgmt_class == IB_MGMT_CLASS_SUBN_DIRECTED_ROUTE)) {
- if (qp_num == 0)
- valid = 1;
- } else {
- /* Filter GSI packets sent to QP0 */
- if (qp_num != 0)
- valid = 1;
- }
-
-out:
- return valid;
-}
-
-static int is_data_mad(struct ib_mad_agent_private *mad_agent_priv,
- struct ib_mad_hdr *mad_hdr)
-{
- struct ib_rmpp_mad *rmpp_mad;
-
- rmpp_mad = (struct ib_rmpp_mad *)mad_hdr;
- return !mad_agent_priv->agent.rmpp_version ||
- !(ib_get_rmpp_flags(&rmpp_mad->rmpp_hdr) &
- IB_MGMT_RMPP_FLAG_ACTIVE) ||
- (rmpp_mad->rmpp_hdr.rmpp_type == IB_MGMT_RMPP_TYPE_DATA);
-}
-
-static inline int rcv_has_same_class(struct ib_mad_send_wr_private *wr,
- struct ib_mad_recv_wc *rwc)
-{
- return ((struct ib_mad *)(wr->send_buf.mad))->mad_hdr.mgmt_class ==
- rwc->recv_buf.mad->mad_hdr.mgmt_class;
-}
-
-static inline int rcv_has_same_gid(struct ib_mad_agent_private *mad_agent_priv,
- struct ib_mad_send_wr_private *wr,
- struct ib_mad_recv_wc *rwc )
-{
- struct ib_ah_attr attr;
- u8 send_resp, rcv_resp;
- union ib_gid sgid;
- struct ib_device *device = mad_agent_priv->agent.device;
- u8 port_num = mad_agent_priv->agent.port_num;
- u8 lmc;
-
- send_resp = ib_response_mad((struct ib_mad *)wr->send_buf.mad);
- rcv_resp = ib_response_mad(rwc->recv_buf.mad);
-
- if (send_resp == rcv_resp)
- /* both requests, or both responses. GIDs different */
- return 0;
-
- if (ib_query_ah(wr->send_buf.ah, &attr))
- /* Assume not equal, to avoid false positives. */
- return 0;
-
- if (!!(attr.ah_flags & IB_AH_GRH) !=
- !!(rwc->wc->wc_flags & IB_WC_GRH))
- /* one has GID, other does not. Assume different */
- return 0;
-
- if (!send_resp && rcv_resp) {
- /* is request/response. */
- if (!(attr.ah_flags & IB_AH_GRH)) {
- if (ib_get_cached_lmc(device, port_num, &lmc))
- return 0;
- return (!lmc || !((attr.src_path_bits ^
- rwc->wc->dlid_path_bits) &
- ((1 << lmc) - 1)));
- } else {
- if (ib_get_cached_gid(device, port_num,
- attr.grh.sgid_index, &sgid))
- return 0;
- return !memcmp(sgid.raw, rwc->recv_buf.grh->dgid.raw,
- 16);
- }
- }
-
- if (!(attr.ah_flags & IB_AH_GRH))
- return attr.dlid == rwc->wc->slid;
- else
- return !memcmp(attr.grh.dgid.raw, rwc->recv_buf.grh->sgid.raw,
- 16);
-}
-
-static inline int is_direct(u8 class)
-{
- return (class == IB_MGMT_CLASS_SUBN_DIRECTED_ROUTE);
-}
-
-struct ib_mad_send_wr_private*
-ib_find_send_mad(struct ib_mad_agent_private *mad_agent_priv,
- struct ib_mad_recv_wc *wc)
-{
- struct ib_mad_send_wr_private *wr;
- struct ib_mad *mad;
-
- mad = (struct ib_mad *)wc->recv_buf.mad;
-
- list_for_each_entry(wr, &mad_agent_priv->wait_list, agent_list) {
- if ((wr->tid == mad->mad_hdr.tid) &&
- rcv_has_same_class(wr, wc) &&
- /*
- * Don't check GID for direct routed MADs.
- * These might have permissive LIDs.
- */
- (is_direct(wc->recv_buf.mad->mad_hdr.mgmt_class) ||
- rcv_has_same_gid(mad_agent_priv, wr, wc)))
- return (wr->status == IB_WC_SUCCESS) ? wr : NULL;
- }
-
- /*
- * It's possible to receive the response before we've
- * been notified that the send has completed
- */
- list_for_each_entry(wr, &mad_agent_priv->send_list, agent_list) {
- if (is_data_mad(mad_agent_priv, wr->send_buf.mad) &&
- wr->tid == mad->mad_hdr.tid &&
- wr->timeout &&
- rcv_has_same_class(wr, wc) &&
- /*
- * Don't check GID for direct routed MADs.
- * These might have permissive LIDs.
- */
- (is_direct(wc->recv_buf.mad->mad_hdr.mgmt_class) ||
- rcv_has_same_gid(mad_agent_priv, wr, wc)))
- /* Verify request has not been canceled */
- return (wr->status == IB_WC_SUCCESS) ? wr : NULL;
- }
- return NULL;
-}
-
-void ib_mark_mad_done(struct ib_mad_send_wr_private *mad_send_wr)
-{
- mad_send_wr->timeout = 0;
- if (mad_send_wr->refcount == 1)
- list_move_tail(&mad_send_wr->agent_list,
- &mad_send_wr->mad_agent_priv->done_list);
-}
-
-static void ib_mad_complete_recv(struct ib_mad_agent_private *mad_agent_priv,
- struct ib_mad_recv_wc *mad_recv_wc)
-{
- struct ib_mad_send_wr_private *mad_send_wr;
- struct ib_mad_send_wc mad_send_wc;
- unsigned long flags;
-
- INIT_LIST_HEAD(&mad_recv_wc->rmpp_list);
- list_add(&mad_recv_wc->recv_buf.list, &mad_recv_wc->rmpp_list);
- if (mad_agent_priv->agent.rmpp_version) {
- mad_recv_wc = ib_process_rmpp_recv_wc(mad_agent_priv,
- mad_recv_wc);
- if (!mad_recv_wc) {
- deref_mad_agent(mad_agent_priv);
- return;
- }
- }
-
- /* Complete corresponding request */
- if (ib_response_mad(mad_recv_wc->recv_buf.mad)) {
- spin_lock_irqsave(&mad_agent_priv->lock, flags);
- mad_send_wr = ib_find_send_mad(mad_agent_priv, mad_recv_wc);
- if (!mad_send_wr) {
- spin_unlock_irqrestore(&mad_agent_priv->lock, flags);
- ib_free_recv_mad(mad_recv_wc);
- deref_mad_agent(mad_agent_priv);
- return;
- }
- ib_mark_mad_done(mad_send_wr);
- spin_unlock_irqrestore(&mad_agent_priv->lock, flags);
-
- /* Defined behavior is to complete response before request */
- mad_recv_wc->wc->wr_id = (unsigned long) &mad_send_wr->send_buf;
- mad_agent_priv->agent.recv_handler(&mad_agent_priv->agent,
- mad_recv_wc);
- atomic_dec(&mad_agent_priv->refcount);
-
- mad_send_wc.status = IB_WC_SUCCESS;
- mad_send_wc.vendor_err = 0;
- mad_send_wc.send_buf = &mad_send_wr->send_buf;
- ib_mad_complete_send_wr(mad_send_wr, &mad_send_wc);
- } else {
- mad_agent_priv->agent.recv_handler(&mad_agent_priv->agent,
- mad_recv_wc);
- deref_mad_agent(mad_agent_priv);
- }
-}
-
-static bool generate_unmatched_resp(struct ib_mad_private *recv,
- struct ib_mad_private *response)
-{
- if (recv->mad.mad.mad_hdr.method == IB_MGMT_METHOD_GET ||
- recv->mad.mad.mad_hdr.method == IB_MGMT_METHOD_SET) {
- memcpy(response, recv, sizeof *response);
- response->header.recv_wc.wc = &response->header.wc;
- response->header.recv_wc.recv_buf.mad = &response->mad.mad;
- response->header.recv_wc.recv_buf.grh = &response->grh;
- response->mad.mad.mad_hdr.method = IB_MGMT_METHOD_GET_RESP;
- response->mad.mad.mad_hdr.status =
- cpu_to_be16(IB_MGMT_MAD_STATUS_UNSUPPORTED_METHOD_ATTRIB);
- if (recv->mad.mad.mad_hdr.mgmt_class == IB_MGMT_CLASS_SUBN_DIRECTED_ROUTE)
- response->mad.mad.mad_hdr.status |= IB_SMP_DIRECTION;
-
- return true;
- } else {
- return false;
- }
-}
-static void ib_mad_recv_done_handler(struct ib_mad_port_private *port_priv,
- struct ib_wc *wc)
-{
- struct ib_mad_qp_info *qp_info;
- struct ib_mad_private_header *mad_priv_hdr;
- struct ib_mad_private *recv, *response = NULL;
- struct ib_mad_list_head *mad_list;
- struct ib_mad_agent_private *mad_agent;
- int port_num;
- int ret = IB_MAD_RESULT_SUCCESS;
-
- mad_list = (struct ib_mad_list_head *)(unsigned long)wc->wr_id;
- qp_info = mad_list->mad_queue->qp_info;
- dequeue_mad(mad_list);
-
- mad_priv_hdr = container_of(mad_list, struct ib_mad_private_header,
- mad_list);
- recv = container_of(mad_priv_hdr, struct ib_mad_private, header);
- ib_dma_unmap_single(port_priv->device,
- recv->header.mapping,
- sizeof(struct ib_mad_private) -
- sizeof(struct ib_mad_private_header),
- DMA_FROM_DEVICE);
-
- /* Setup MAD receive work completion from "normal" work completion */
- recv->header.wc = *wc;
- recv->header.recv_wc.wc = &recv->header.wc;
- recv->header.recv_wc.mad_len = sizeof(struct ib_mad);
- recv->header.recv_wc.recv_buf.mad = &recv->mad.mad;
- recv->header.recv_wc.recv_buf.grh = &recv->grh;
-
- if (atomic_read(&qp_info->snoop_count))
- snoop_recv(qp_info, &recv->header.recv_wc, IB_MAD_SNOOP_RECVS);
-
- /* Validate MAD */
- if (!validate_mad(&recv->mad.mad, qp_info->qp->qp_num))
- goto out;
-
- response = kmem_cache_alloc(ib_mad_cache, GFP_KERNEL);
- if (!response) {
- printk(KERN_ERR PFX "ib_mad_recv_done_handler no memory "
- "for response buffer\n");
- goto out;
- }
-
- if (port_priv->device->node_type == RDMA_NODE_IB_SWITCH)
- port_num = wc->port_num;
- else
- port_num = port_priv->port_num;
-
- if (recv->mad.mad.mad_hdr.mgmt_class ==
- IB_MGMT_CLASS_SUBN_DIRECTED_ROUTE) {
- enum smi_forward_action retsmi;
-
- if (smi_handle_dr_smp_recv(&recv->mad.smp,
- port_priv->device->node_type,
- port_num,
- port_priv->device->phys_port_cnt) ==
- IB_SMI_DISCARD)
- goto out;
-
- retsmi = smi_check_forward_dr_smp(&recv->mad.smp);
- if (retsmi == IB_SMI_LOCAL)
- goto local;
-
- if (retsmi == IB_SMI_SEND) { /* don't forward */
- if (smi_handle_dr_smp_send(&recv->mad.smp,
- port_priv->device->node_type,
- port_num) == IB_SMI_DISCARD)
- goto out;
-
- if (smi_check_local_smp(&recv->mad.smp, port_priv->device) == IB_SMI_DISCARD)
- goto out;
- } else if (port_priv->device->node_type == RDMA_NODE_IB_SWITCH) {
- /* forward case for switches */
- memcpy(response, recv, sizeof(*response));
- response->header.recv_wc.wc = &response->header.wc;
- response->header.recv_wc.recv_buf.mad = &response->mad.mad;
- response->header.recv_wc.recv_buf.grh = &response->grh;
-
- agent_send_response(&response->mad.mad,
- &response->grh, wc,
- port_priv->device,
- smi_get_fwd_port(&recv->mad.smp),
- qp_info->qp->qp_num);
-
- goto out;
- }
- }
-
-local:
- /* Give driver "right of first refusal" on incoming MAD */
- if (port_priv->device->process_mad) {
- ret = port_priv->device->process_mad(port_priv->device, 0,
- port_priv->port_num,
- wc, &recv->grh,
- &recv->mad.mad,
- &response->mad.mad);
- if (ret & IB_MAD_RESULT_SUCCESS) {
- if (ret & IB_MAD_RESULT_CONSUMED)
- goto out;
- if (ret & IB_MAD_RESULT_REPLY) {
- agent_send_response(&response->mad.mad,
- &recv->grh, wc,
- port_priv->device,
- port_num,
- qp_info->qp->qp_num);
- goto out;
- }
- }
- }
-
- mad_agent = find_mad_agent(port_priv, &recv->mad.mad);
- if (mad_agent) {
- ib_mad_complete_recv(mad_agent, &recv->header.recv_wc);
- /*
- * recv is freed up in error cases in ib_mad_complete_recv
- * or via recv_handler in ib_mad_complete_recv()
- */
- recv = NULL;
- } else if ((ret & IB_MAD_RESULT_SUCCESS) &&
- generate_unmatched_resp(recv, response)) {
- agent_send_response(&response->mad.mad, &recv->grh, wc,
- port_priv->device, port_num, qp_info->qp->qp_num);
- }
-
-out:
- /* Post another receive request for this QP */
- if (response) {
- ib_mad_post_receive_mads(qp_info, response);
- if (recv)
- kmem_cache_free(ib_mad_cache, recv);
- } else
- ib_mad_post_receive_mads(qp_info, recv);
-}
-
-static void adjust_timeout(struct ib_mad_agent_private *mad_agent_priv)
-{
- struct ib_mad_send_wr_private *mad_send_wr;
- unsigned long delay;
-
- if (list_empty(&mad_agent_priv->wait_list)) {
- cancel_delayed_work(&mad_agent_priv->timed_work);
- } else {
- mad_send_wr = list_entry(mad_agent_priv->wait_list.next,
- struct ib_mad_send_wr_private,
- agent_list);
-
- if (time_after(mad_agent_priv->timeout,
- mad_send_wr->timeout)) {
- mad_agent_priv->timeout = mad_send_wr->timeout;
- delay = mad_send_wr->timeout - jiffies;
- if ((long)delay <= 0)
- delay = 1;
- mod_delayed_work(mad_agent_priv->qp_info->port_priv->wq,
- &mad_agent_priv->timed_work, delay);
- }
- }
-}
-
-static void wait_for_response(struct ib_mad_send_wr_private *mad_send_wr)
-{
- struct ib_mad_agent_private *mad_agent_priv;
- struct ib_mad_send_wr_private *temp_mad_send_wr;
- struct list_head *list_item;
- unsigned long delay;
-
- mad_agent_priv = mad_send_wr->mad_agent_priv;
- list_del(&mad_send_wr->agent_list);
-
- delay = mad_send_wr->timeout;
- mad_send_wr->timeout += jiffies;
-
- if (delay) {
- list_for_each_prev(list_item, &mad_agent_priv->wait_list) {
- temp_mad_send_wr = list_entry(list_item,
- struct ib_mad_send_wr_private,
- agent_list);
- if (time_after(mad_send_wr->timeout,
- temp_mad_send_wr->timeout))
- break;
- }
- }
- else
- list_item = &mad_agent_priv->wait_list;
- list_add(&mad_send_wr->agent_list, list_item);
-
- /* Reschedule a work item if we have a shorter timeout */
- if (mad_agent_priv->wait_list.next == &mad_send_wr->agent_list)
- mod_delayed_work(mad_agent_priv->qp_info->port_priv->wq,
- &mad_agent_priv->timed_work, delay);
-}
-
-void ib_reset_mad_timeout(struct ib_mad_send_wr_private *mad_send_wr,
- int timeout_ms)
-{
- mad_send_wr->timeout = msecs_to_jiffies(timeout_ms);
- wait_for_response(mad_send_wr);
-}
-
-/*
- * Process a send work completion
- */
-void ib_mad_complete_send_wr(struct ib_mad_send_wr_private *mad_send_wr,
- struct ib_mad_send_wc *mad_send_wc)
-{
- struct ib_mad_agent_private *mad_agent_priv;
- unsigned long flags;
- int ret;
-
- mad_agent_priv = mad_send_wr->mad_agent_priv;
- spin_lock_irqsave(&mad_agent_priv->lock, flags);
- if (mad_agent_priv->agent.rmpp_version) {
- ret = ib_process_rmpp_send_wc(mad_send_wr, mad_send_wc);
- if (ret == IB_RMPP_RESULT_CONSUMED)
- goto done;
- } else
- ret = IB_RMPP_RESULT_UNHANDLED;
-
- if (mad_send_wc->status != IB_WC_SUCCESS &&
- mad_send_wr->status == IB_WC_SUCCESS) {
- mad_send_wr->status = mad_send_wc->status;
- mad_send_wr->refcount -= (mad_send_wr->timeout > 0);
- }
-
- if (--mad_send_wr->refcount > 0) {
- if (mad_send_wr->refcount == 1 && mad_send_wr->timeout &&
- mad_send_wr->status == IB_WC_SUCCESS) {
- wait_for_response(mad_send_wr);
- }
- goto done;
- }
-
- /* Remove send from MAD agent and notify client of completion */
- list_del(&mad_send_wr->agent_list);
- adjust_timeout(mad_agent_priv);
- spin_unlock_irqrestore(&mad_agent_priv->lock, flags);
-
- if (mad_send_wr->status != IB_WC_SUCCESS )
- mad_send_wc->status = mad_send_wr->status;
- if (ret == IB_RMPP_RESULT_INTERNAL)
- ib_rmpp_send_handler(mad_send_wc);
- else {
- if (mad_send_wr->is_sa_cc_mad)
- sa_cc_mad_done(get_cc_obj(mad_send_wr));
- mad_agent_priv->agent.send_handler(&mad_agent_priv->agent,
- mad_send_wc);
- }
-
- /* Release reference on agent taken when sending */
- deref_mad_agent(mad_agent_priv);
- return;
-done:
- spin_unlock_irqrestore(&mad_agent_priv->lock, flags);
-}
-
-static void ib_mad_send_done_handler(struct ib_mad_port_private *port_priv,
- struct ib_wc *wc)
-{
- struct ib_mad_send_wr_private *mad_send_wr, *queued_send_wr;
- struct ib_mad_list_head *mad_list;
- struct ib_mad_qp_info *qp_info;
- struct ib_mad_queue *send_queue;
- struct ib_send_wr *bad_send_wr;
- struct ib_mad_send_wc mad_send_wc;
- unsigned long flags;
- int ret;
-
- mad_list = (struct ib_mad_list_head *)(unsigned long)wc->wr_id;
- mad_send_wr = container_of(mad_list, struct ib_mad_send_wr_private,
- mad_list);
- send_queue = mad_list->mad_queue;
- qp_info = send_queue->qp_info;
-
-retry:
- ib_dma_unmap_single(mad_send_wr->send_buf.mad_agent->device,
- mad_send_wr->header_mapping,
- mad_send_wr->sg_list[0].length, DMA_TO_DEVICE);
- ib_dma_unmap_single(mad_send_wr->send_buf.mad_agent->device,
- mad_send_wr->payload_mapping,
- mad_send_wr->sg_list[1].length, DMA_TO_DEVICE);
- queued_send_wr = NULL;
- spin_lock_irqsave(&send_queue->lock, flags);
- list_del(&mad_list->list);
-
- /* Move queued send to the send queue */
- if (send_queue->count-- > send_queue->max_active) {
- mad_list = container_of(qp_info->overflow_list.next,
- struct ib_mad_list_head, list);
- queued_send_wr = container_of(mad_list,
- struct ib_mad_send_wr_private,
- mad_list);
- list_move_tail(&mad_list->list, &send_queue->list);
- }
- spin_unlock_irqrestore(&send_queue->lock, flags);
-
- mad_send_wc.send_buf = &mad_send_wr->send_buf;
- mad_send_wc.status = wc->status;
- mad_send_wc.vendor_err = wc->vendor_err;
- if (atomic_read(&qp_info->snoop_count))
- snoop_send(qp_info, &mad_send_wr->send_buf, &mad_send_wc,
- IB_MAD_SNOOP_SEND_COMPLETIONS);
- ib_mad_complete_send_wr(mad_send_wr, &mad_send_wc);
-
- if (queued_send_wr) {
- ret = ib_post_send(qp_info->qp, &queued_send_wr->send_wr,
- &bad_send_wr);
- if (ret) {
- printk(KERN_ERR PFX "ib_post_send failed: %d\n", ret);
- mad_send_wr = queued_send_wr;
- wc->status = IB_WC_LOC_QP_OP_ERR;
- goto retry;
- }
- }
-}
-
-static void mark_sends_for_retry(struct ib_mad_qp_info *qp_info)
-{
- struct ib_mad_send_wr_private *mad_send_wr;
- struct ib_mad_list_head *mad_list;
- unsigned long flags;
-
- spin_lock_irqsave(&qp_info->send_queue.lock, flags);
- list_for_each_entry(mad_list, &qp_info->send_queue.list, list) {
- mad_send_wr = container_of(mad_list,
- struct ib_mad_send_wr_private,
- mad_list);
- mad_send_wr->retry = 1;
- }
- spin_unlock_irqrestore(&qp_info->send_queue.lock, flags);
-}
-
-static void mad_error_handler(struct ib_mad_port_private *port_priv,
- struct ib_wc *wc)
-{
- struct ib_mad_list_head *mad_list;
- struct ib_mad_qp_info *qp_info;
- struct ib_mad_send_wr_private *mad_send_wr;
- int ret;
-
- /* Determine if failure was a send or receive */
- mad_list = (struct ib_mad_list_head *)(unsigned long)wc->wr_id;
- qp_info = mad_list->mad_queue->qp_info;
- if (mad_list->mad_queue == &qp_info->recv_queue)
- /*
- * Receive errors indicate that the QP has entered the error
- * state - error handling/shutdown code will cleanup
- */
- return;
-
- /*
- * Send errors will transition the QP to SQE - move
- * QP to RTS and repost flushed work requests
- */
- mad_send_wr = container_of(mad_list, struct ib_mad_send_wr_private,
- mad_list);
- if (wc->status == IB_WC_WR_FLUSH_ERR) {
- if (mad_send_wr->retry) {
- /* Repost send */
- struct ib_send_wr *bad_send_wr;
-
- mad_send_wr->retry = 0;
- ret = ib_post_send(qp_info->qp, &mad_send_wr->send_wr,
- &bad_send_wr);
- if (ret)
- ib_mad_send_done_handler(port_priv, wc);
- } else
- ib_mad_send_done_handler(port_priv, wc);
- } else {
- struct ib_qp_attr *attr;
-
- /* Transition QP to RTS and fail offending send */
- attr = kmalloc(sizeof *attr, GFP_KERNEL);
- if (attr) {
- attr->qp_state = IB_QPS_RTS;
- attr->cur_qp_state = IB_QPS_SQE;
- ret = ib_modify_qp(qp_info->qp, attr,
- IB_QP_STATE | IB_QP_CUR_STATE);
- kfree(attr);
- if (ret)
- printk(KERN_ERR PFX "mad_error_handler - "
- "ib_modify_qp to RTS : %d\n", ret);
- else
- mark_sends_for_retry(qp_info);
- }
- ib_mad_send_done_handler(port_priv, wc);
- }
-}
-
-/*
- * IB MAD completion callback
- */
-static void ib_mad_completion_handler(struct work_struct *work)
-{
- struct ib_mad_port_private *port_priv;
- struct ib_wc wc;
-
- port_priv = container_of(work, struct ib_mad_port_private, work);
- ib_req_notify_cq(port_priv->cq, IB_CQ_NEXT_COMP);
-
- while (ib_poll_cq(port_priv->cq, 1, &wc) == 1) {
- if (wc.status == IB_WC_SUCCESS) {
- switch (wc.opcode) {
- case IB_WC_SEND:
- ib_mad_send_done_handler(port_priv, &wc);
- break;
- case IB_WC_RECV:
- ib_mad_recv_done_handler(port_priv, &wc);
- break;
- default:
- BUG_ON(1);
- break;
- }
- } else
- mad_error_handler(port_priv, &wc);
- }
-}
-
-static void cancel_mads(struct ib_mad_agent_private *mad_agent_priv)
-{
- unsigned long flags;
- struct ib_mad_send_wr_private *mad_send_wr, *temp_mad_send_wr;
- struct ib_mad_send_wc mad_send_wc;
- struct list_head cancel_list;
-
- INIT_LIST_HEAD(&cancel_list);
-
- cancel_sa_cc_mads(mad_agent_priv);
- spin_lock_irqsave(&mad_agent_priv->lock, flags);
- list_for_each_entry_safe(mad_send_wr, temp_mad_send_wr,
- &mad_agent_priv->send_list, agent_list) {
- if (mad_send_wr->status == IB_WC_SUCCESS) {
- mad_send_wr->status = IB_WC_WR_FLUSH_ERR;
- mad_send_wr->refcount -= (mad_send_wr->timeout > 0);
- }
- }
-
- /* Empty wait list to prevent receives from finding a request */
- list_splice_init(&mad_agent_priv->wait_list, &cancel_list);
- spin_unlock_irqrestore(&mad_agent_priv->lock, flags);
-
- /* Report all cancelled requests */
- mad_send_wc.status = IB_WC_WR_FLUSH_ERR;
- mad_send_wc.vendor_err = 0;
-
- list_for_each_entry_safe(mad_send_wr, temp_mad_send_wr,
- &cancel_list, agent_list) {
- mad_send_wc.send_buf = &mad_send_wr->send_buf;
- list_del(&mad_send_wr->agent_list);
- if (mad_send_wr->is_sa_cc_mad)
- sa_cc_mad_done(get_cc_obj(mad_send_wr));
- mad_agent_priv->agent.send_handler(&mad_agent_priv->agent,
- &mad_send_wc);
- atomic_dec(&mad_agent_priv->refcount);
- }
-}
-
-static struct ib_mad_send_wr_private*
-find_send_wr(struct ib_mad_agent_private *mad_agent_priv,
- struct ib_mad_send_buf *send_buf)
-{
- struct ib_mad_send_wr_private *mad_send_wr;
-
- list_for_each_entry(mad_send_wr, &mad_agent_priv->wait_list,
- agent_list) {
- if (&mad_send_wr->send_buf == send_buf)
- return mad_send_wr;
- }
-
- list_for_each_entry(mad_send_wr, &mad_agent_priv->send_list,
- agent_list) {
- if (is_data_mad(mad_agent_priv, mad_send_wr->send_buf.mad) &&
- &mad_send_wr->send_buf == send_buf)
- return mad_send_wr;
- }
- return NULL;
-}
-
-int ib_modify_mad(struct ib_mad_agent *mad_agent,
- struct ib_mad_send_buf *send_buf, u32 timeout_ms)
-{
- struct ib_mad_agent_private *mad_agent_priv;
- struct ib_mad_send_wr_private *mad_send_wr;
- unsigned long flags;
- int active;
-
- mad_agent_priv = container_of(mad_agent, struct ib_mad_agent_private,
- agent);
- spin_lock_irqsave(&mad_agent_priv->lock, flags);
- mad_send_wr = find_send_wr(mad_agent_priv, send_buf);
- if (!mad_send_wr) {
- spin_unlock_irqrestore(&mad_agent_priv->lock, flags);
- if (modify_sa_cc_mad(mad_agent_priv, send_buf, timeout_ms))
- return -EINVAL;
- return 0;
- }
- if (mad_send_wr->status != IB_WC_SUCCESS) {
- spin_unlock_irqrestore(&mad_agent_priv->lock, flags);
- return -EINVAL;
- }
-
- active = (!mad_send_wr->timeout || mad_send_wr->refcount > 1);
- if (!timeout_ms) {
- mad_send_wr->status = IB_WC_WR_FLUSH_ERR;
- mad_send_wr->refcount -= (mad_send_wr->timeout > 0);
- }
-
- mad_send_wr->send_buf.timeout_ms = timeout_ms;
- if (active)
- mad_send_wr->timeout = msecs_to_jiffies(timeout_ms);
- else
- ib_reset_mad_timeout(mad_send_wr, timeout_ms);
-
- spin_unlock_irqrestore(&mad_agent_priv->lock, flags);
- return 0;
-}
-EXPORT_SYMBOL(ib_modify_mad);
-
-void ib_cancel_mad(struct ib_mad_agent *mad_agent,
- struct ib_mad_send_buf *send_buf)
-{
- ib_modify_mad(mad_agent, send_buf, 0);
-}
-EXPORT_SYMBOL(ib_cancel_mad);
-
-static void local_completions(struct work_struct *work)
-{
- struct ib_mad_agent_private *mad_agent_priv;
- struct ib_mad_local_private *local;
- struct ib_mad_agent_private *recv_mad_agent;
- unsigned long flags;
- int free_mad;
- struct ib_wc wc;
- struct ib_mad_send_wc mad_send_wc;
-
- mad_agent_priv =
- container_of(work, struct ib_mad_agent_private, local_work);
-
- spin_lock_irqsave(&mad_agent_priv->lock, flags);
- while (!list_empty(&mad_agent_priv->local_list)) {
- local = list_entry(mad_agent_priv->local_list.next,
- struct ib_mad_local_private,
- completion_list);
- list_del(&local->completion_list);
- spin_unlock_irqrestore(&mad_agent_priv->lock, flags);
- free_mad = 0;
- if (local->mad_priv) {
- recv_mad_agent = local->recv_mad_agent;
- if (!recv_mad_agent) {
- printk(KERN_ERR PFX "No receive MAD agent for local completion\n");
- free_mad = 1;
- goto local_send_completion;
- }
-
- /*
- * Defined behavior is to complete response
- * before request
- */
- build_smp_wc(recv_mad_agent->agent.qp,
- (unsigned long) local->mad_send_wr,
- be16_to_cpu(IB_LID_PERMISSIVE),
- 0, recv_mad_agent->agent.port_num, &wc);
-
- local->mad_priv->header.recv_wc.wc = &wc;
- local->mad_priv->header.recv_wc.mad_len =
- sizeof(struct ib_mad);
- INIT_LIST_HEAD(&local->mad_priv->header.recv_wc.rmpp_list);
- list_add(&local->mad_priv->header.recv_wc.recv_buf.list,
- &local->mad_priv->header.recv_wc.rmpp_list);
- local->mad_priv->header.recv_wc.recv_buf.grh = NULL;
- local->mad_priv->header.recv_wc.recv_buf.mad =
- &local->mad_priv->mad.mad;
- if (atomic_read(&recv_mad_agent->qp_info->snoop_count))
- snoop_recv(recv_mad_agent->qp_info,
- &local->mad_priv->header.recv_wc,
- IB_MAD_SNOOP_RECVS);
- recv_mad_agent->agent.recv_handler(
- &recv_mad_agent->agent,
- &local->mad_priv->header.recv_wc);
- spin_lock_irqsave(&recv_mad_agent->lock, flags);
- atomic_dec(&recv_mad_agent->refcount);
- spin_unlock_irqrestore(&recv_mad_agent->lock, flags);
- }
-
-local_send_completion:
- /* Complete send */
- mad_send_wc.status = IB_WC_SUCCESS;
- mad_send_wc.vendor_err = 0;
- mad_send_wc.send_buf = &local->mad_send_wr->send_buf;
- if (atomic_read(&mad_agent_priv->qp_info->snoop_count))
- snoop_send(mad_agent_priv->qp_info,
- &local->mad_send_wr->send_buf,
- &mad_send_wc, IB_MAD_SNOOP_SEND_COMPLETIONS);
- mad_agent_priv->agent.send_handler(&mad_agent_priv->agent,
- &mad_send_wc);
-
- spin_lock_irqsave(&mad_agent_priv->lock, flags);
- atomic_dec(&mad_agent_priv->refcount);
- if (free_mad)
- kmem_cache_free(ib_mad_cache, local->mad_priv);
- kfree(local);
- }
- spin_unlock_irqrestore(&mad_agent_priv->lock, flags);
-}
-
-static int retry_send(struct ib_mad_send_wr_private *mad_send_wr)
-{
- int ret;
-
- if (!mad_send_wr->retries_left)
- return -ETIMEDOUT;
-
- mad_send_wr->retries_left--;
- mad_send_wr->send_buf.retries++;
-
- mad_send_wr->timeout = msecs_to_jiffies(mad_send_wr->send_buf.timeout_ms);
-
- if (mad_send_wr->mad_agent_priv->agent.rmpp_version) {
- ret = ib_retry_rmpp(mad_send_wr);
- switch (ret) {
- case IB_RMPP_RESULT_UNHANDLED:
- ret = ib_send_mad(mad_send_wr);
- break;
- case IB_RMPP_RESULT_CONSUMED:
- ret = 0;
- break;
- default:
- ret = -ECOMM;
- break;
- }
- } else
- ret = ib_send_mad(mad_send_wr);
-
- if (!ret) {
- mad_send_wr->refcount++;
- list_add_tail(&mad_send_wr->agent_list,
- &mad_send_wr->mad_agent_priv->send_list);
- }
- return ret;
-}
-
-static void timeout_sends(struct work_struct *work)
-{
- struct ib_mad_agent_private *mad_agent_priv;
- struct ib_mad_send_wr_private *mad_send_wr;
- struct ib_mad_send_wc mad_send_wc;
- unsigned long flags, delay;
-
- mad_agent_priv = container_of(work, struct ib_mad_agent_private,
- timed_work.work);
- mad_send_wc.vendor_err = 0;
-
- spin_lock_irqsave(&mad_agent_priv->lock, flags);
- while (!list_empty(&mad_agent_priv->wait_list)) {
- mad_send_wr = list_entry(mad_agent_priv->wait_list.next,
- struct ib_mad_send_wr_private,
- agent_list);
-
- if (time_after(mad_send_wr->timeout, jiffies)) {
- delay = mad_send_wr->timeout - jiffies;
- if ((long)delay <= 0)
- delay = 1;
- queue_delayed_work(mad_agent_priv->qp_info->
- port_priv->wq,
- &mad_agent_priv->timed_work, delay);
- break;
- }
-
- list_del(&mad_send_wr->agent_list);
- if (mad_send_wr->status == IB_WC_SUCCESS &&
- !retry_send(mad_send_wr))
- continue;
-
- spin_unlock_irqrestore(&mad_agent_priv->lock, flags);
-
- if (mad_send_wr->status == IB_WC_SUCCESS)
- mad_send_wc.status = IB_WC_RESP_TIMEOUT_ERR;
- else
- mad_send_wc.status = mad_send_wr->status;
- mad_send_wc.send_buf = &mad_send_wr->send_buf;
- if (mad_send_wr->is_sa_cc_mad)
- sa_cc_mad_done(get_cc_obj(mad_send_wr));
- mad_agent_priv->agent.send_handler(&mad_agent_priv->agent,
- &mad_send_wc);
-
- atomic_dec(&mad_agent_priv->refcount);
- spin_lock_irqsave(&mad_agent_priv->lock, flags);
- }
- spin_unlock_irqrestore(&mad_agent_priv->lock, flags);
-}
-
-static void ib_mad_thread_completion_handler(struct ib_cq *cq, void *arg)
-{
- struct ib_mad_port_private *port_priv = cq->cq_context;
- unsigned long flags;
-
- spin_lock_irqsave(&ib_mad_port_list_lock, flags);
- if (!list_empty(&port_priv->port_list))
- queue_work(port_priv->wq, &port_priv->work);
- spin_unlock_irqrestore(&ib_mad_port_list_lock, flags);
-}
-
-/*
- * Allocate receive MADs and post receive WRs for them
- */
-static int ib_mad_post_receive_mads(struct ib_mad_qp_info *qp_info,
- struct ib_mad_private *mad)
-{
- unsigned long flags;
- int post, ret;
- struct ib_mad_private *mad_priv;
- struct ib_sge sg_list;
- struct ib_recv_wr recv_wr, *bad_recv_wr;
- struct ib_mad_queue *recv_queue = &qp_info->recv_queue;
-
- /* Initialize common scatter list fields */
- sg_list.length = sizeof *mad_priv - sizeof mad_priv->header;
- sg_list.lkey = (*qp_info->port_priv->mr).lkey;
-
- /* Initialize common receive WR fields */
- recv_wr.next = NULL;
- recv_wr.sg_list = &sg_list;
- recv_wr.num_sge = 1;
-
- do {
- /* Allocate and map receive buffer */
- if (mad) {
- mad_priv = mad;
- mad = NULL;
- } else {
- mad_priv = kmem_cache_alloc(ib_mad_cache, GFP_KERNEL);
- if (!mad_priv) {
- printk(KERN_ERR PFX "No memory for receive buffer\n");
- ret = -ENOMEM;
- break;
- }
- }
- sg_list.addr = ib_dma_map_single(qp_info->port_priv->device,
- &mad_priv->grh,
- sizeof *mad_priv -
- sizeof mad_priv->header,
- DMA_FROM_DEVICE);
- if (unlikely(ib_dma_mapping_error(qp_info->port_priv->device,
- sg_list.addr))) {
- ret = -ENOMEM;
- kmem_cache_free(ib_mad_cache, mad_priv);
- printk(KERN_ERR PFX "ib_dma_map_single failed\n");
- break;
- }
-
- mad_priv->header.mapping = sg_list.addr;
- recv_wr.wr_id = (unsigned long)&mad_priv->header.mad_list;
- mad_priv->header.mad_list.mad_queue = recv_queue;
-
- /* Post receive WR */
- spin_lock_irqsave(&recv_queue->lock, flags);
- post = (++recv_queue->count < recv_queue->max_active);
- list_add_tail(&mad_priv->header.mad_list.list, &recv_queue->list);
- spin_unlock_irqrestore(&recv_queue->lock, flags);
- ret = ib_post_recv(qp_info->qp, &recv_wr, &bad_recv_wr);
- if (ret) {
- spin_lock_irqsave(&recv_queue->lock, flags);
- list_del(&mad_priv->header.mad_list.list);
- recv_queue->count--;
- spin_unlock_irqrestore(&recv_queue->lock, flags);
- ib_dma_unmap_single(qp_info->port_priv->device,
- mad_priv->header.mapping,
- sizeof *mad_priv -
- sizeof mad_priv->header,
- DMA_FROM_DEVICE);
- kmem_cache_free(ib_mad_cache, mad_priv);
- printk(KERN_ERR PFX "ib_post_recv failed: %d\n", ret);
- break;
- }
- } while (post);
-
- return ret;
-}
-
-/*
- * Return all the posted receive MADs
- */
-static void cleanup_recv_queue(struct ib_mad_qp_info *qp_info)
-{
- struct ib_mad_private_header *mad_priv_hdr;
- struct ib_mad_private *recv;
- struct ib_mad_list_head *mad_list;
-
- if (!qp_info->qp)
- return;
-
- while (!list_empty(&qp_info->recv_queue.list)) {
-
- mad_list = list_entry(qp_info->recv_queue.list.next,
- struct ib_mad_list_head, list);
- mad_priv_hdr = container_of(mad_list,
- struct ib_mad_private_header,
- mad_list);
- recv = container_of(mad_priv_hdr, struct ib_mad_private,
- header);
-
- /* Remove from posted receive MAD list */
- list_del(&mad_list->list);
-
- ib_dma_unmap_single(qp_info->port_priv->device,
- recv->header.mapping,
- sizeof(struct ib_mad_private) -
- sizeof(struct ib_mad_private_header),
- DMA_FROM_DEVICE);
- kmem_cache_free(ib_mad_cache, recv);
- }
-
- qp_info->recv_queue.count = 0;
-}
-
-/*
- * Start the port
- */
-static int ib_mad_port_start(struct ib_mad_port_private *port_priv)
-{
- int ret, i;
- struct ib_qp_attr *attr;
- struct ib_qp *qp;
- u16 pkey_index = 0;
-
- attr = kmalloc(sizeof *attr, GFP_KERNEL);
- if (!attr) {
- printk(KERN_ERR PFX "Couldn't kmalloc ib_qp_attr\n");
- return -ENOMEM;
- }
-
- ret = ib_find_pkey(port_priv->device, port_priv->port_num,
- 0xFFFF, &pkey_index);
- if (ret)
- pkey_index = 0;
-
- for (i = 0; i < IB_MAD_QPS_CORE; i++) {
- qp = port_priv->qp_info[i].qp;
- if (!qp)
- continue;
-
- /*
- * PKey index for QP1 is irrelevant but
- * one is needed for the Reset to Init transition
- */
- attr->qp_state = IB_QPS_INIT;
- attr->pkey_index = pkey_index;
- attr->qkey = (qp->qp_num == 0) ? 0 : IB_QP1_QKEY;
- ret = ib_modify_qp(qp, attr, IB_QP_STATE |
- IB_QP_PKEY_INDEX | IB_QP_QKEY);
- if (ret) {
- printk(KERN_ERR PFX "Couldn't change QP%d state to "
- "INIT: %d\n", i, ret);
- goto out;
- }
-
- attr->qp_state = IB_QPS_RTR;
- ret = ib_modify_qp(qp, attr, IB_QP_STATE);
- if (ret) {
- printk(KERN_ERR PFX "Couldn't change QP%d state to "
- "RTR: %d\n", i, ret);
- goto out;
- }
-
- attr->qp_state = IB_QPS_RTS;
- attr->sq_psn = IB_MAD_SEND_Q_PSN;
- ret = ib_modify_qp(qp, attr, IB_QP_STATE | IB_QP_SQ_PSN);
- if (ret) {
- printk(KERN_ERR PFX "Couldn't change QP%d state to "
- "RTS: %d\n", i, ret);
- goto out;
- }
- }
-
- ret = ib_req_notify_cq(port_priv->cq, IB_CQ_NEXT_COMP);
- if (ret) {
- printk(KERN_ERR PFX "Failed to request completion "
- "notification: %d\n", ret);
- goto out;
- }
-
- for (i = 0; i < IB_MAD_QPS_CORE; i++) {
- if (!port_priv->qp_info[i].qp)
- continue;
-
- ret = ib_mad_post_receive_mads(&port_priv->qp_info[i], NULL);
- if (ret) {
- printk(KERN_ERR PFX "Couldn't post receive WRs\n");
- goto out;
- }
- }
-out:
- kfree(attr);
- return ret;
-}
-
-static void qp_event_handler(struct ib_event *event, void *qp_context)
-{
- struct ib_mad_qp_info *qp_info = qp_context;
-
- /* It's worse than that! He's dead, Jim! */
- printk(KERN_ERR PFX "Fatal error (%d) on MAD QP (%d)\n",
- event->event, qp_info->qp->qp_num);
-}
-
-static void init_mad_queue(struct ib_mad_qp_info *qp_info,
- struct ib_mad_queue *mad_queue)
-{
- mad_queue->qp_info = qp_info;
- mad_queue->count = 0;
- spin_lock_init(&mad_queue->lock);
- INIT_LIST_HEAD(&mad_queue->list);
-}
-
-static void init_mad_qp(struct ib_mad_port_private *port_priv,
- struct ib_mad_qp_info *qp_info)
-{
- qp_info->port_priv = port_priv;
- init_mad_queue(qp_info, &qp_info->send_queue);
- init_mad_queue(qp_info, &qp_info->recv_queue);
- INIT_LIST_HEAD(&qp_info->overflow_list);
- spin_lock_init(&qp_info->snoop_lock);
- qp_info->snoop_table = NULL;
- qp_info->snoop_table_size = 0;
- atomic_set(&qp_info->snoop_count, 0);
-}
-
-static int create_mad_qp(struct ib_mad_qp_info *qp_info,
- enum ib_qp_type qp_type)
-{
- struct ib_qp_init_attr qp_init_attr;
- int ret;
-
- memset(&qp_init_attr, 0, sizeof qp_init_attr);
- qp_init_attr.send_cq = qp_info->port_priv->cq;
- qp_init_attr.recv_cq = qp_info->port_priv->cq;
- qp_init_attr.sq_sig_type = IB_SIGNAL_ALL_WR;
- qp_init_attr.cap.max_send_wr = mad_sendq_size;
- qp_init_attr.cap.max_recv_wr = mad_recvq_size;
- qp_init_attr.cap.max_send_sge = IB_MAD_SEND_REQ_MAX_SG;
- qp_init_attr.cap.max_recv_sge = IB_MAD_RECV_REQ_MAX_SG;
- qp_init_attr.qp_type = qp_type;
- qp_init_attr.port_num = qp_info->port_priv->port_num;
- qp_init_attr.qp_context = qp_info;
- qp_init_attr.event_handler = qp_event_handler;
- qp_info->qp = ib_create_qp(qp_info->port_priv->pd, &qp_init_attr);
- if (IS_ERR(qp_info->qp)) {
- printk(KERN_ERR PFX "Couldn't create ib_mad QP%d\n",
- get_spl_qp_index(qp_type));
- ret = PTR_ERR(qp_info->qp);
- goto error;
- }
- /* Use minimum queue sizes unless the CQ is resized */
- qp_info->send_queue.max_active = mad_sendq_size;
- qp_info->recv_queue.max_active = mad_recvq_size;
- return 0;
-
-error:
- return ret;
-}
-
-static void destroy_mad_qp(struct ib_mad_qp_info *qp_info)
-{
- if (!qp_info->qp)
- return;
-
- ib_destroy_qp(qp_info->qp);
- kfree(qp_info->snoop_table);
-}
-
-/*
- * Open the port
- * Create the QP, PD, MR, and CQ if needed
- */
-static int ib_mad_port_open(struct ib_device *device,
- int port_num)
-{
- int ret, cq_size;
- struct ib_mad_port_private *port_priv;
- unsigned long flags;
- char name[sizeof "ib_mad123"];
- int has_smi;
-
- /* Create new device info */
- port_priv = kzalloc(sizeof *port_priv, GFP_KERNEL);
- if (!port_priv) {
- printk(KERN_ERR PFX "No memory for ib_mad_port_private\n");
- return -ENOMEM;
- }
-
- port_priv->device = device;
- port_priv->port_num = port_num;
- spin_lock_init(&port_priv->reg_lock);
- INIT_LIST_HEAD(&port_priv->agent_list);
- init_mad_qp(port_priv, &port_priv->qp_info[0]);
- init_mad_qp(port_priv, &port_priv->qp_info[1]);
-
- cq_size = mad_sendq_size + mad_recvq_size;
- has_smi = rdma_port_get_link_layer(device, port_num) == IB_LINK_LAYER_INFINIBAND;
- if (has_smi)
- cq_size *= 2;
-
- port_priv->cq = ib_create_cq(port_priv->device,
- ib_mad_thread_completion_handler,
- NULL, port_priv, cq_size, 0);
- if (IS_ERR(port_priv->cq)) {
- printk(KERN_ERR PFX "Couldn't create ib_mad CQ\n");
- ret = PTR_ERR(port_priv->cq);
- goto error3;
- }
-
- port_priv->pd = ib_alloc_pd(device);
- if (IS_ERR(port_priv->pd)) {
- printk(KERN_ERR PFX "Couldn't create ib_mad PD\n");
- ret = PTR_ERR(port_priv->pd);
- goto error4;
- }
-
- port_priv->mr = ib_get_dma_mr(port_priv->pd, IB_ACCESS_LOCAL_WRITE);
- if (IS_ERR(port_priv->mr)) {
- printk(KERN_ERR PFX "Couldn't get ib_mad DMA MR\n");
- ret = PTR_ERR(port_priv->mr);
- goto error5;
- }
-
- if (has_smi) {
- ret = create_mad_qp(&port_priv->qp_info[0], IB_QPT_SMI);
- if (ret)
- goto error6;
- }
- ret = create_mad_qp(&port_priv->qp_info[1], IB_QPT_GSI);
- if (ret)
- goto error7;
-
- snprintf(name, sizeof name, "ib_mad%d", port_num);
- port_priv->wq = create_singlethread_workqueue(name);
- if (!port_priv->wq) {
- ret = -ENOMEM;
- goto error8;
- }
- INIT_WORK(&port_priv->work, ib_mad_completion_handler);
-
- if (sa_cc_init(&port_priv->sa_cc))
- goto error9;
-
-
- spin_lock_irqsave(&ib_mad_port_list_lock, flags);
- list_add_tail(&port_priv->port_list, &ib_mad_port_list);
- spin_unlock_irqrestore(&ib_mad_port_list_lock, flags);
-
- ret = ib_mad_port_start(port_priv);
- if (ret) {
- printk(KERN_ERR PFX "Couldn't start port\n");
- goto error10;
- }
-
- return 0;
-
-error10:
- spin_lock_irqsave(&ib_mad_port_list_lock, flags);
- list_del_init(&port_priv->port_list);
- spin_unlock_irqrestore(&ib_mad_port_list_lock, flags);
-
- destroy_workqueue(port_priv->wq);
-error9:
- sa_cc_destroy(&port_priv->sa_cc);
-error8:
- destroy_mad_qp(&port_priv->qp_info[1]);
-error7:
- destroy_mad_qp(&port_priv->qp_info[0]);
-error6:
- ib_dereg_mr(port_priv->mr);
-error5:
- ib_dealloc_pd(port_priv->pd);
-error4:
- ib_destroy_cq(port_priv->cq);
- cleanup_recv_queue(&port_priv->qp_info[1]);
- cleanup_recv_queue(&port_priv->qp_info[0]);
-error3:
- kfree(port_priv);
-
- return ret;
-}
-
-/*
- * Close the port
- * If there are no classes using the port, free the port
- * resources (CQ, MR, PD, QP) and remove the port's info structure
- */
-static int ib_mad_port_close(struct ib_device *device, int port_num)
-{
- struct ib_mad_port_private *port_priv;
- unsigned long flags;
-
- spin_lock_irqsave(&ib_mad_port_list_lock, flags);
- port_priv = __ib_get_mad_port(device, port_num);
- if (port_priv == NULL) {
- spin_unlock_irqrestore(&ib_mad_port_list_lock, flags);
- printk(KERN_ERR PFX "Port %d not found\n", port_num);
- return -ENODEV;
- }
- list_del_init(&port_priv->port_list);
- spin_unlock_irqrestore(&ib_mad_port_list_lock, flags);
-
- destroy_workqueue(port_priv->wq);
- sa_cc_destroy(&port_priv->sa_cc);
- destroy_mad_qp(&port_priv->qp_info[1]);
- destroy_mad_qp(&port_priv->qp_info[0]);
- ib_dereg_mr(port_priv->mr);
- ib_dealloc_pd(port_priv->pd);
- ib_destroy_cq(port_priv->cq);
- cleanup_recv_queue(&port_priv->qp_info[1]);
- cleanup_recv_queue(&port_priv->qp_info[0]);
- /* XXX: Handle deallocation of MAD registration tables */
-
- kfree(port_priv);
-
- return 0;
-}
-
-static void ib_mad_init_device(struct ib_device *device)
-{
- int start, end, i;
-
- if (rdma_node_get_transport(device->node_type) != RDMA_TRANSPORT_IB)
- return;
-
- if (device->node_type == RDMA_NODE_IB_SWITCH) {
- start = 0;
- end = 0;
- } else {
- start = 1;
- end = device->phys_port_cnt;
- }
-
- for (i = start; i <= end; i++) {
- if (ib_mad_port_open(device, i)) {
- printk(KERN_ERR PFX "Couldn't open %s port %d\n",
- device->name, i);
- goto error;
- }
- if (ib_agent_port_open(device, i)) {
- printk(KERN_ERR PFX "Couldn't open %s port %d "
- "for agents\n",
- device->name, i);
- goto error_agent;
- }
- }
- return;
-
-error_agent:
- if (ib_mad_port_close(device, i))
- printk(KERN_ERR PFX "Couldn't close %s port %d\n",
- device->name, i);
-
-error:
- i--;
-
- while (i >= start) {
- if (ib_agent_port_close(device, i))
- printk(KERN_ERR PFX "Couldn't close %s port %d "
- "for agents\n",
- device->name, i);
- if (ib_mad_port_close(device, i))
- printk(KERN_ERR PFX "Couldn't close %s port %d\n",
- device->name, i);
- i--;
- }
-}
-
-static void ib_mad_remove_device(struct ib_device *device)
-{
- int i, num_ports, cur_port;
-
- if (rdma_node_get_transport(device->node_type) != RDMA_TRANSPORT_IB)
- return;
-
- if (device->node_type == RDMA_NODE_IB_SWITCH) {
- num_ports = 1;
- cur_port = 0;
- } else {
- num_ports = device->phys_port_cnt;
- cur_port = 1;
- }
- for (i = 0; i < num_ports; i++, cur_port++) {
- if (ib_agent_port_close(device, cur_port))
- printk(KERN_ERR PFX "Couldn't close %s port %d "
- "for agents\n",
- device->name, cur_port);
- if (ib_mad_port_close(device, cur_port))
- printk(KERN_ERR PFX "Couldn't close %s port %d\n",
- device->name, cur_port);
- }
-}
-
-static struct ib_client mad_client = {
- .name = "mad",
- .add = ib_mad_init_device,
- .remove = ib_mad_remove_device
-};
-
-static int __init ib_mad_init_module(void)
-{
- int ret;
-
- mad_recvq_size = min(mad_recvq_size, IB_MAD_QP_MAX_SIZE);
- mad_recvq_size = max(mad_recvq_size, IB_MAD_QP_MIN_SIZE);
-
- mad_sendq_size = min(mad_sendq_size, IB_MAD_QP_MAX_SIZE);
- mad_sendq_size = max(mad_sendq_size, IB_MAD_QP_MIN_SIZE);
-
- ib_mad_cache = kmem_cache_create("ib_mad",
- sizeof(struct ib_mad_private),
- 0,
- SLAB_HWCACHE_ALIGN,
- NULL);
- if (!ib_mad_cache) {
- printk(KERN_ERR PFX "Couldn't create ib_mad cache\n");
- ret = -ENOMEM;
- goto error1;
- }
-
- INIT_LIST_HEAD(&ib_mad_port_list);
-
- if (ib_register_client(&mad_client)) {
- printk(KERN_ERR PFX "Couldn't register ib_mad client\n");
- ret = -EINVAL;
- goto error2;
- }
-
- return 0;
-
-error2:
- kmem_cache_destroy(ib_mad_cache);
-error1:
- return ret;
-}
-
-static void __exit ib_mad_cleanup_module(void)
-{
- ib_unregister_client(&mad_client);
- kmem_cache_destroy(ib_mad_cache);
-}
-
-module_init(ib_mad_init_module);
-module_exit(ib_mad_cleanup_module);
diff --git a/sys/ofed/drivers/infiniband/core/mad_priv.h b/sys/ofed/drivers/infiniband/core/mad_priv.h
index e2cd0ac..28669f6 100644
--- a/sys/ofed/drivers/infiniband/core/mad_priv.h
+++ b/sys/ofed/drivers/infiniband/core/mad_priv.h
@@ -41,9 +41,7 @@
#include <linux/workqueue.h>
#include <rdma/ib_mad.h>
#include <rdma/ib_smi.h>
-
-
-#define PFX "ib_mad: "
+#include <rdma/opa_smi.h>
#define IB_MAD_QPS_CORE 2 /* Always QP0 and QP1 as a minimum */
@@ -59,13 +57,14 @@
/* Registration table sizes */
#define MAX_MGMT_CLASS 80
-#define MAX_MGMT_VERSION 8
+#define MAX_MGMT_VERSION 0x83
#define MAX_MGMT_OUI 8
#define MAX_MGMT_VENDOR_RANGE2 (IB_MGMT_CLASS_VENDOR_RANGE2_END - \
IB_MGMT_CLASS_VENDOR_RANGE2_START + 1)
struct ib_mad_list_head {
struct list_head list;
+ struct ib_cqe cqe;
struct ib_mad_queue *mad_queue;
};
@@ -78,12 +77,9 @@ struct ib_mad_private_header {
struct ib_mad_private {
struct ib_mad_private_header header;
+ size_t mad_size;
struct ib_grh grh;
- union {
- struct ib_mad mad;
- struct ib_rmpp_mad rmpp_mad;
- struct ib_smp smp;
- } mad;
+ u8 mad[0];
} __attribute__ ((packed));
struct ib_rmpp_segment {
@@ -121,14 +117,6 @@ struct ib_mad_snoop_private {
struct completion comp;
};
-/* Structure for timeout-fifo entry */
-struct tf_entry {
- unsigned long exp_time; /* entry expiration time */
- struct list_head fifo_list; /* to keep entries in fifo order */
- struct list_head to_list; /* to keep entries in timeout order */
- int canceled; /* indicates whether entry is canceled */
-};
-
struct ib_mad_send_wr_private {
struct ib_mad_list_head mad_list;
struct list_head agent_list;
@@ -136,7 +124,7 @@ struct ib_mad_send_wr_private {
struct ib_mad_send_buf send_buf;
u64 header_mapping;
u64 payload_mapping;
- struct ib_send_wr send_wr;
+ struct ib_ud_wr send_wr;
struct ib_sge sg_list[IB_MAD_SEND_REQ_MAX_SG];
__be64 tid;
unsigned long timeout;
@@ -154,10 +142,6 @@ struct ib_mad_send_wr_private {
int seg_num;
int newwin;
int pad;
-
- /* SA congestion controlled MAD */
- int is_sa_cc_mad;
- struct tf_entry tf_list;
};
struct ib_mad_local_private {
@@ -165,6 +149,7 @@ struct ib_mad_local_private {
struct ib_mad_private *mad_priv;
struct ib_mad_agent_private *recv_mad_agent;
struct ib_mad_send_wr_private *mad_send_wr;
+ size_t return_wc_byte_len;
};
struct ib_mad_mgmt_method_table {
@@ -209,47 +194,25 @@ struct ib_mad_qp_info {
atomic_t snoop_count;
};
-struct to_fifo {
- struct list_head to_head;
- struct list_head fifo_head;
- spinlock_t lists_lock;
- struct timer_list timer;
- struct work_struct work;
- u32 fifo_size;
- u32 num_items;
- int stop_enqueue;
- struct workqueue_struct *workq;
-};
-
-/* SA congestion control data */
-struct sa_cc_data {
- spinlock_t lock;
- unsigned long outstanding;
- struct to_fifo *tf;
-};
-
struct ib_mad_port_private {
struct list_head port_list;
struct ib_device *device;
int port_num;
struct ib_cq *cq;
struct ib_pd *pd;
- struct ib_mr *mr;
spinlock_t reg_lock;
struct ib_mad_mgmt_version_table version[MAX_MGMT_VERSION];
struct list_head agent_list;
struct workqueue_struct *wq;
- struct work_struct work;
struct ib_mad_qp_info qp_info[IB_MAD_QPS_CORE];
- struct sa_cc_data sa_cc;
};
int ib_send_mad(struct ib_mad_send_wr_private *mad_send_wr);
struct ib_mad_send_wr_private *
-ib_find_send_mad(struct ib_mad_agent_private *mad_agent_priv,
- struct ib_mad_recv_wc *mad_recv_wc);
+ib_find_send_mad(const struct ib_mad_agent_private *mad_agent_priv,
+ const struct ib_mad_recv_wc *mad_recv_wc);
void ib_mad_complete_send_wr(struct ib_mad_send_wr_private *mad_send_wr,
struct ib_mad_send_wc *mad_send_wc);
diff --git a/sys/ofed/drivers/infiniband/core/mad_rmpp.c b/sys/ofed/drivers/infiniband/core/mad_rmpp.c
deleted file mode 100644
index f37878c..0000000
--- a/sys/ofed/drivers/infiniband/core/mad_rmpp.c
+++ /dev/null
@@ -1,953 +0,0 @@
-/*
- * Copyright (c) 2005 Intel Inc. All rights reserved.
- * Copyright (c) 2005-2006 Voltaire, Inc. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-#include <linux/slab.h>
-
-#include "mad_priv.h"
-#include "mad_rmpp.h"
-
-enum rmpp_state {
- RMPP_STATE_ACTIVE,
- RMPP_STATE_TIMEOUT,
- RMPP_STATE_COMPLETE,
- RMPP_STATE_CANCELING
-};
-
-struct mad_rmpp_recv {
- struct ib_mad_agent_private *agent;
- struct list_head list;
- struct delayed_work timeout_work;
- struct delayed_work cleanup_work;
- struct completion comp;
- enum rmpp_state state;
- spinlock_t lock;
- atomic_t refcount;
-
- struct ib_ah *ah;
- struct ib_mad_recv_wc *rmpp_wc;
- struct ib_mad_recv_buf *cur_seg_buf;
- int last_ack;
- int seg_num;
- int newwin;
- int repwin;
-
- __be64 tid;
- u32 src_qp;
- u16 slid;
- u8 mgmt_class;
- u8 class_version;
- u8 method;
-};
-
-static inline void deref_rmpp_recv(struct mad_rmpp_recv *rmpp_recv)
-{
- if (atomic_dec_and_test(&rmpp_recv->refcount))
- complete(&rmpp_recv->comp);
-}
-
-static void destroy_rmpp_recv(struct mad_rmpp_recv *rmpp_recv)
-{
- deref_rmpp_recv(rmpp_recv);
- wait_for_completion(&rmpp_recv->comp);
- ib_destroy_ah(rmpp_recv->ah);
- kfree(rmpp_recv);
-}
-
-void ib_cancel_rmpp_recvs(struct ib_mad_agent_private *agent)
-{
- struct mad_rmpp_recv *rmpp_recv, *temp_rmpp_recv;
- unsigned long flags;
-
- spin_lock_irqsave(&agent->lock, flags);
- list_for_each_entry(rmpp_recv, &agent->rmpp_list, list) {
- if (rmpp_recv->state != RMPP_STATE_COMPLETE)
- ib_free_recv_mad(rmpp_recv->rmpp_wc);
- rmpp_recv->state = RMPP_STATE_CANCELING;
- }
- spin_unlock_irqrestore(&agent->lock, flags);
-
- list_for_each_entry(rmpp_recv, &agent->rmpp_list, list) {
- cancel_delayed_work(&rmpp_recv->timeout_work);
- cancel_delayed_work(&rmpp_recv->cleanup_work);
- }
-
- flush_workqueue(agent->qp_info->port_priv->wq);
-
- list_for_each_entry_safe(rmpp_recv, temp_rmpp_recv,
- &agent->rmpp_list, list) {
- list_del(&rmpp_recv->list);
- destroy_rmpp_recv(rmpp_recv);
- }
-}
-
-static void format_ack(struct ib_mad_send_buf *msg,
- struct ib_rmpp_mad *data,
- struct mad_rmpp_recv *rmpp_recv)
-{
- struct ib_rmpp_mad *ack = msg->mad;
- unsigned long flags;
-
- memcpy(ack, &data->mad_hdr, msg->hdr_len);
-
- ack->mad_hdr.method ^= IB_MGMT_METHOD_RESP;
- ack->rmpp_hdr.rmpp_type = IB_MGMT_RMPP_TYPE_ACK;
- ib_set_rmpp_flags(&ack->rmpp_hdr, IB_MGMT_RMPP_FLAG_ACTIVE);
-
- spin_lock_irqsave(&rmpp_recv->lock, flags);
- rmpp_recv->last_ack = rmpp_recv->seg_num;
- ack->rmpp_hdr.seg_num = cpu_to_be32(rmpp_recv->seg_num);
- ack->rmpp_hdr.paylen_newwin = cpu_to_be32(rmpp_recv->newwin);
- spin_unlock_irqrestore(&rmpp_recv->lock, flags);
-}
-
-static void ack_recv(struct mad_rmpp_recv *rmpp_recv,
- struct ib_mad_recv_wc *recv_wc)
-{
- struct ib_mad_send_buf *msg;
- int ret, hdr_len;
-
- hdr_len = ib_get_mad_data_offset(recv_wc->recv_buf.mad->mad_hdr.mgmt_class);
- msg = ib_create_send_mad(&rmpp_recv->agent->agent, recv_wc->wc->src_qp,
- recv_wc->wc->pkey_index, 1, hdr_len,
- 0, GFP_KERNEL);
- if (IS_ERR(msg))
- return;
-
- format_ack(msg, (struct ib_rmpp_mad *) recv_wc->recv_buf.mad, rmpp_recv);
- msg->ah = rmpp_recv->ah;
- ret = ib_post_send_mad(msg, NULL);
- if (ret)
- ib_free_send_mad(msg);
-}
-
-static struct ib_mad_send_buf *alloc_response_msg(struct ib_mad_agent *agent,
- struct ib_mad_recv_wc *recv_wc)
-{
- struct ib_mad_send_buf *msg;
- struct ib_ah *ah;
- int hdr_len;
-
- ah = ib_create_ah_from_wc(agent->qp->pd, recv_wc->wc,
- recv_wc->recv_buf.grh, agent->port_num);
- if (IS_ERR(ah))
- return (void *) ah;
-
- hdr_len = ib_get_mad_data_offset(recv_wc->recv_buf.mad->mad_hdr.mgmt_class);
- msg = ib_create_send_mad(agent, recv_wc->wc->src_qp,
- recv_wc->wc->pkey_index, 1,
- hdr_len, 0, GFP_KERNEL);
- if (IS_ERR(msg))
- ib_destroy_ah(ah);
- else {
- msg->ah = ah;
- msg->context[0] = ah;
- }
-
- return msg;
-}
-
-static void ack_ds_ack(struct ib_mad_agent_private *agent,
- struct ib_mad_recv_wc *recv_wc)
-{
- struct ib_mad_send_buf *msg;
- struct ib_rmpp_mad *rmpp_mad;
- int ret;
-
- msg = alloc_response_msg(&agent->agent, recv_wc);
- if (IS_ERR(msg))
- return;
-
- rmpp_mad = msg->mad;
- memcpy(rmpp_mad, recv_wc->recv_buf.mad, msg->hdr_len);
-
- rmpp_mad->mad_hdr.method ^= IB_MGMT_METHOD_RESP;
- ib_set_rmpp_flags(&rmpp_mad->rmpp_hdr, IB_MGMT_RMPP_FLAG_ACTIVE);
- rmpp_mad->rmpp_hdr.seg_num = 0;
- rmpp_mad->rmpp_hdr.paylen_newwin = cpu_to_be32(1);
-
- ret = ib_post_send_mad(msg, NULL);
- if (ret) {
- ib_destroy_ah(msg->ah);
- ib_free_send_mad(msg);
- }
-}
-
-void ib_rmpp_send_handler(struct ib_mad_send_wc *mad_send_wc)
-{
- if (mad_send_wc->send_buf->context[0] == mad_send_wc->send_buf->ah)
- ib_destroy_ah(mad_send_wc->send_buf->ah);
- ib_free_send_mad(mad_send_wc->send_buf);
-}
-
-static void nack_recv(struct ib_mad_agent_private *agent,
- struct ib_mad_recv_wc *recv_wc, u8 rmpp_status)
-{
- struct ib_mad_send_buf *msg;
- struct ib_rmpp_mad *rmpp_mad;
- int ret;
-
- msg = alloc_response_msg(&agent->agent, recv_wc);
- if (IS_ERR(msg))
- return;
-
- rmpp_mad = msg->mad;
- memcpy(rmpp_mad, recv_wc->recv_buf.mad, msg->hdr_len);
-
- rmpp_mad->mad_hdr.method ^= IB_MGMT_METHOD_RESP;
- rmpp_mad->rmpp_hdr.rmpp_version = IB_MGMT_RMPP_VERSION;
- rmpp_mad->rmpp_hdr.rmpp_type = IB_MGMT_RMPP_TYPE_ABORT;
- ib_set_rmpp_flags(&rmpp_mad->rmpp_hdr, IB_MGMT_RMPP_FLAG_ACTIVE);
- rmpp_mad->rmpp_hdr.rmpp_status = rmpp_status;
- rmpp_mad->rmpp_hdr.seg_num = 0;
- rmpp_mad->rmpp_hdr.paylen_newwin = 0;
-
- ret = ib_post_send_mad(msg, NULL);
- if (ret) {
- ib_destroy_ah(msg->ah);
- ib_free_send_mad(msg);
- }
-}
-
-static void recv_timeout_handler(struct work_struct *work)
-{
- struct mad_rmpp_recv *rmpp_recv =
- container_of(work, struct mad_rmpp_recv, timeout_work.work);
- struct ib_mad_recv_wc *rmpp_wc;
- unsigned long flags;
-
- spin_lock_irqsave(&rmpp_recv->agent->lock, flags);
- if (rmpp_recv->state != RMPP_STATE_ACTIVE) {
- spin_unlock_irqrestore(&rmpp_recv->agent->lock, flags);
- return;
- }
- rmpp_recv->state = RMPP_STATE_TIMEOUT;
- list_del(&rmpp_recv->list);
- spin_unlock_irqrestore(&rmpp_recv->agent->lock, flags);
-
- rmpp_wc = rmpp_recv->rmpp_wc;
- nack_recv(rmpp_recv->agent, rmpp_wc, IB_MGMT_RMPP_STATUS_T2L);
- destroy_rmpp_recv(rmpp_recv);
- ib_free_recv_mad(rmpp_wc);
-}
-
-static void recv_cleanup_handler(struct work_struct *work)
-{
- struct mad_rmpp_recv *rmpp_recv =
- container_of(work, struct mad_rmpp_recv, cleanup_work.work);
- unsigned long flags;
-
- spin_lock_irqsave(&rmpp_recv->agent->lock, flags);
- if (rmpp_recv->state == RMPP_STATE_CANCELING) {
- spin_unlock_irqrestore(&rmpp_recv->agent->lock, flags);
- return;
- }
- list_del(&rmpp_recv->list);
- spin_unlock_irqrestore(&rmpp_recv->agent->lock, flags);
- destroy_rmpp_recv(rmpp_recv);
-}
-
-static struct mad_rmpp_recv *
-create_rmpp_recv(struct ib_mad_agent_private *agent,
- struct ib_mad_recv_wc *mad_recv_wc)
-{
- struct mad_rmpp_recv *rmpp_recv;
- struct ib_mad_hdr *mad_hdr;
-
- rmpp_recv = kmalloc(sizeof *rmpp_recv, GFP_KERNEL);
- if (!rmpp_recv)
- return NULL;
-
- rmpp_recv->ah = ib_create_ah_from_wc(agent->agent.qp->pd,
- mad_recv_wc->wc,
- mad_recv_wc->recv_buf.grh,
- agent->agent.port_num);
- if (IS_ERR(rmpp_recv->ah))
- goto error;
-
- rmpp_recv->agent = agent;
- init_completion(&rmpp_recv->comp);
- INIT_DELAYED_WORK(&rmpp_recv->timeout_work, recv_timeout_handler);
- INIT_DELAYED_WORK(&rmpp_recv->cleanup_work, recv_cleanup_handler);
- spin_lock_init(&rmpp_recv->lock);
- rmpp_recv->state = RMPP_STATE_ACTIVE;
- atomic_set(&rmpp_recv->refcount, 1);
-
- rmpp_recv->rmpp_wc = mad_recv_wc;
- rmpp_recv->cur_seg_buf = &mad_recv_wc->recv_buf;
- rmpp_recv->newwin = 1;
- rmpp_recv->seg_num = 1;
- rmpp_recv->last_ack = 0;
- rmpp_recv->repwin = 1;
-
- mad_hdr = &mad_recv_wc->recv_buf.mad->mad_hdr;
- rmpp_recv->tid = mad_hdr->tid;
- rmpp_recv->src_qp = mad_recv_wc->wc->src_qp;
- rmpp_recv->slid = mad_recv_wc->wc->slid;
- rmpp_recv->mgmt_class = mad_hdr->mgmt_class;
- rmpp_recv->class_version = mad_hdr->class_version;
- rmpp_recv->method = mad_hdr->method;
- return rmpp_recv;
-
-error: kfree(rmpp_recv);
- return NULL;
-}
-
-static struct mad_rmpp_recv *
-find_rmpp_recv(struct ib_mad_agent_private *agent,
- struct ib_mad_recv_wc *mad_recv_wc)
-{
- struct mad_rmpp_recv *rmpp_recv;
- struct ib_mad_hdr *mad_hdr = &mad_recv_wc->recv_buf.mad->mad_hdr;
-
- list_for_each_entry(rmpp_recv, &agent->rmpp_list, list) {
- if (rmpp_recv->tid == mad_hdr->tid &&
- rmpp_recv->src_qp == mad_recv_wc->wc->src_qp &&
- rmpp_recv->slid == mad_recv_wc->wc->slid &&
- rmpp_recv->mgmt_class == mad_hdr->mgmt_class &&
- rmpp_recv->class_version == mad_hdr->class_version &&
- rmpp_recv->method == mad_hdr->method)
- return rmpp_recv;
- }
- return NULL;
-}
-
-static struct mad_rmpp_recv *
-acquire_rmpp_recv(struct ib_mad_agent_private *agent,
- struct ib_mad_recv_wc *mad_recv_wc)
-{
- struct mad_rmpp_recv *rmpp_recv;
- unsigned long flags;
-
- spin_lock_irqsave(&agent->lock, flags);
- rmpp_recv = find_rmpp_recv(agent, mad_recv_wc);
- if (rmpp_recv)
- atomic_inc(&rmpp_recv->refcount);
- spin_unlock_irqrestore(&agent->lock, flags);
- return rmpp_recv;
-}
-
-static struct mad_rmpp_recv *
-insert_rmpp_recv(struct ib_mad_agent_private *agent,
- struct mad_rmpp_recv *rmpp_recv)
-{
- struct mad_rmpp_recv *cur_rmpp_recv;
-
- cur_rmpp_recv = find_rmpp_recv(agent, rmpp_recv->rmpp_wc);
- if (!cur_rmpp_recv)
- list_add_tail(&rmpp_recv->list, &agent->rmpp_list);
-
- return cur_rmpp_recv;
-}
-
-static inline int get_last_flag(struct ib_mad_recv_buf *seg)
-{
- struct ib_rmpp_mad *rmpp_mad;
-
- rmpp_mad = (struct ib_rmpp_mad *) seg->mad;
- return ib_get_rmpp_flags(&rmpp_mad->rmpp_hdr) & IB_MGMT_RMPP_FLAG_LAST;
-}
-
-static inline int get_seg_num(struct ib_mad_recv_buf *seg)
-{
- struct ib_rmpp_mad *rmpp_mad;
-
- rmpp_mad = (struct ib_rmpp_mad *) seg->mad;
- return be32_to_cpu(rmpp_mad->rmpp_hdr.seg_num);
-}
-
-static inline struct ib_mad_recv_buf * get_next_seg(struct list_head *rmpp_list,
- struct ib_mad_recv_buf *seg)
-{
- if (seg->list.next == rmpp_list)
- return NULL;
-
- return container_of(seg->list.next, struct ib_mad_recv_buf, list);
-}
-
-static inline int window_size(struct ib_mad_agent_private *agent)
-{
- return max(agent->qp_info->recv_queue.max_active >> 3, 1);
-}
-
-static struct ib_mad_recv_buf * find_seg_location(struct list_head *rmpp_list,
- int seg_num)
-{
- struct ib_mad_recv_buf *seg_buf;
- int cur_seg_num;
-
- list_for_each_entry_reverse(seg_buf, rmpp_list, list) {
- cur_seg_num = get_seg_num(seg_buf);
- if (seg_num > cur_seg_num)
- return seg_buf;
- if (seg_num == cur_seg_num)
- break;
- }
- return NULL;
-}
-
-static void update_seg_num(struct mad_rmpp_recv *rmpp_recv,
- struct ib_mad_recv_buf *new_buf)
-{
- struct list_head *rmpp_list = &rmpp_recv->rmpp_wc->rmpp_list;
-
- while (new_buf && (get_seg_num(new_buf) == rmpp_recv->seg_num + 1)) {
- rmpp_recv->cur_seg_buf = new_buf;
- rmpp_recv->seg_num++;
- new_buf = get_next_seg(rmpp_list, new_buf);
- }
-}
-
-static inline int get_mad_len(struct mad_rmpp_recv *rmpp_recv)
-{
- struct ib_rmpp_mad *rmpp_mad;
- int hdr_size, data_size, pad;
-
- rmpp_mad = (struct ib_rmpp_mad *)rmpp_recv->cur_seg_buf->mad;
-
- hdr_size = ib_get_mad_data_offset(rmpp_mad->mad_hdr.mgmt_class);
- data_size = sizeof(struct ib_rmpp_mad) - hdr_size;
- pad = IB_MGMT_RMPP_DATA - be32_to_cpu(rmpp_mad->rmpp_hdr.paylen_newwin);
- if (pad > IB_MGMT_RMPP_DATA || pad < 0)
- pad = 0;
-
- return hdr_size + rmpp_recv->seg_num * data_size - pad;
-}
-
-static struct ib_mad_recv_wc * complete_rmpp(struct mad_rmpp_recv *rmpp_recv)
-{
- struct ib_mad_recv_wc *rmpp_wc;
-
- ack_recv(rmpp_recv, rmpp_recv->rmpp_wc);
- if (rmpp_recv->seg_num > 1)
- cancel_delayed_work(&rmpp_recv->timeout_work);
-
- rmpp_wc = rmpp_recv->rmpp_wc;
- rmpp_wc->mad_len = get_mad_len(rmpp_recv);
- /* 10 seconds until we can find the packet lifetime */
- queue_delayed_work(rmpp_recv->agent->qp_info->port_priv->wq,
- &rmpp_recv->cleanup_work, msecs_to_jiffies(10000));
- return rmpp_wc;
-}
-
-static struct ib_mad_recv_wc *
-continue_rmpp(struct ib_mad_agent_private *agent,
- struct ib_mad_recv_wc *mad_recv_wc)
-{
- struct mad_rmpp_recv *rmpp_recv;
- struct ib_mad_recv_buf *prev_buf;
- struct ib_mad_recv_wc *done_wc;
- int seg_num;
- unsigned long flags;
-
- rmpp_recv = acquire_rmpp_recv(agent, mad_recv_wc);
- if (!rmpp_recv)
- goto drop1;
-
- seg_num = get_seg_num(&mad_recv_wc->recv_buf);
-
- spin_lock_irqsave(&rmpp_recv->lock, flags);
- if ((rmpp_recv->state == RMPP_STATE_TIMEOUT) ||
- (seg_num > rmpp_recv->newwin))
- goto drop3;
-
- if ((seg_num <= rmpp_recv->last_ack) ||
- (rmpp_recv->state == RMPP_STATE_COMPLETE)) {
- spin_unlock_irqrestore(&rmpp_recv->lock, flags);
- ack_recv(rmpp_recv, mad_recv_wc);
- goto drop2;
- }
-
- prev_buf = find_seg_location(&rmpp_recv->rmpp_wc->rmpp_list, seg_num);
- if (!prev_buf)
- goto drop3;
-
- done_wc = NULL;
- list_add(&mad_recv_wc->recv_buf.list, &prev_buf->list);
- if (rmpp_recv->cur_seg_buf == prev_buf) {
- update_seg_num(rmpp_recv, &mad_recv_wc->recv_buf);
- if (get_last_flag(rmpp_recv->cur_seg_buf)) {
- rmpp_recv->state = RMPP_STATE_COMPLETE;
- spin_unlock_irqrestore(&rmpp_recv->lock, flags);
- done_wc = complete_rmpp(rmpp_recv);
- goto out;
- } else if (rmpp_recv->seg_num == rmpp_recv->newwin) {
- rmpp_recv->newwin += window_size(agent);
- spin_unlock_irqrestore(&rmpp_recv->lock, flags);
- ack_recv(rmpp_recv, mad_recv_wc);
- goto out;
- }
- }
- spin_unlock_irqrestore(&rmpp_recv->lock, flags);
-out:
- deref_rmpp_recv(rmpp_recv);
- return done_wc;
-
-drop3: spin_unlock_irqrestore(&rmpp_recv->lock, flags);
-drop2: deref_rmpp_recv(rmpp_recv);
-drop1: ib_free_recv_mad(mad_recv_wc);
- return NULL;
-}
-
-static struct ib_mad_recv_wc *
-start_rmpp(struct ib_mad_agent_private *agent,
- struct ib_mad_recv_wc *mad_recv_wc)
-{
- struct mad_rmpp_recv *rmpp_recv;
- unsigned long flags;
-
- rmpp_recv = create_rmpp_recv(agent, mad_recv_wc);
- if (!rmpp_recv) {
- ib_free_recv_mad(mad_recv_wc);
- return NULL;
- }
-
- spin_lock_irqsave(&agent->lock, flags);
- if (insert_rmpp_recv(agent, rmpp_recv)) {
- spin_unlock_irqrestore(&agent->lock, flags);
- /* duplicate first MAD */
- destroy_rmpp_recv(rmpp_recv);
- return continue_rmpp(agent, mad_recv_wc);
- }
- atomic_inc(&rmpp_recv->refcount);
-
- if (get_last_flag(&mad_recv_wc->recv_buf)) {
- rmpp_recv->state = RMPP_STATE_COMPLETE;
- spin_unlock_irqrestore(&agent->lock, flags);
- complete_rmpp(rmpp_recv);
- } else {
- spin_unlock_irqrestore(&agent->lock, flags);
- /* 40 seconds until we can find the packet lifetimes */
- queue_delayed_work(agent->qp_info->port_priv->wq,
- &rmpp_recv->timeout_work,
- msecs_to_jiffies(40000));
- rmpp_recv->newwin += window_size(agent);
- ack_recv(rmpp_recv, mad_recv_wc);
- mad_recv_wc = NULL;
- }
- deref_rmpp_recv(rmpp_recv);
- return mad_recv_wc;
-}
-
-static int send_next_seg(struct ib_mad_send_wr_private *mad_send_wr)
-{
- struct ib_rmpp_mad *rmpp_mad;
- int timeout;
- u32 paylen = 0;
-
- rmpp_mad = mad_send_wr->send_buf.mad;
- ib_set_rmpp_flags(&rmpp_mad->rmpp_hdr, IB_MGMT_RMPP_FLAG_ACTIVE);
- rmpp_mad->rmpp_hdr.seg_num = cpu_to_be32(++mad_send_wr->seg_num);
-
- if (mad_send_wr->seg_num == 1) {
- rmpp_mad->rmpp_hdr.rmpp_rtime_flags |= IB_MGMT_RMPP_FLAG_FIRST;
- paylen = mad_send_wr->send_buf.seg_count * IB_MGMT_RMPP_DATA -
- mad_send_wr->pad;
- }
-
- if (mad_send_wr->seg_num == mad_send_wr->send_buf.seg_count) {
- rmpp_mad->rmpp_hdr.rmpp_rtime_flags |= IB_MGMT_RMPP_FLAG_LAST;
- paylen = IB_MGMT_RMPP_DATA - mad_send_wr->pad;
- }
- rmpp_mad->rmpp_hdr.paylen_newwin = cpu_to_be32(paylen);
-
- /* 2 seconds for an ACK until we can find the packet lifetime */
- timeout = mad_send_wr->send_buf.timeout_ms;
- if (!timeout || timeout > 2000)
- mad_send_wr->timeout = msecs_to_jiffies(2000);
-
- return ib_send_mad(mad_send_wr);
-}
-
-static void abort_send(struct ib_mad_agent_private *agent,
- struct ib_mad_recv_wc *mad_recv_wc, u8 rmpp_status)
-{
- struct ib_mad_send_wr_private *mad_send_wr;
- struct ib_mad_send_wc wc;
- unsigned long flags;
-
- spin_lock_irqsave(&agent->lock, flags);
- mad_send_wr = ib_find_send_mad(agent, mad_recv_wc);
- if (!mad_send_wr)
- goto out; /* Unmatched send */
-
- if ((mad_send_wr->last_ack == mad_send_wr->send_buf.seg_count) ||
- (!mad_send_wr->timeout) || (mad_send_wr->status != IB_WC_SUCCESS))
- goto out; /* Send is already done */
-
- ib_mark_mad_done(mad_send_wr);
- spin_unlock_irqrestore(&agent->lock, flags);
-
- wc.status = IB_WC_REM_ABORT_ERR;
- wc.vendor_err = rmpp_status;
- wc.send_buf = &mad_send_wr->send_buf;
- ib_mad_complete_send_wr(mad_send_wr, &wc);
- return;
-out:
- spin_unlock_irqrestore(&agent->lock, flags);
-}
-
-static inline void adjust_last_ack(struct ib_mad_send_wr_private *wr,
- int seg_num)
-{
- struct list_head *list;
-
- wr->last_ack = seg_num;
- list = &wr->last_ack_seg->list;
- list_for_each_entry(wr->last_ack_seg, list, list)
- if (wr->last_ack_seg->num == seg_num)
- break;
-}
-
-static void process_ds_ack(struct ib_mad_agent_private *agent,
- struct ib_mad_recv_wc *mad_recv_wc, int newwin)
-{
- struct mad_rmpp_recv *rmpp_recv;
-
- rmpp_recv = find_rmpp_recv(agent, mad_recv_wc);
- if (rmpp_recv && rmpp_recv->state == RMPP_STATE_COMPLETE)
- rmpp_recv->repwin = newwin;
-}
-
-static void process_rmpp_ack(struct ib_mad_agent_private *agent,
- struct ib_mad_recv_wc *mad_recv_wc)
-{
- struct ib_mad_send_wr_private *mad_send_wr;
- struct ib_rmpp_mad *rmpp_mad;
- unsigned long flags;
- int seg_num, newwin, ret;
-
- rmpp_mad = (struct ib_rmpp_mad *)mad_recv_wc->recv_buf.mad;
- if (rmpp_mad->rmpp_hdr.rmpp_status) {
- abort_send(agent, mad_recv_wc, IB_MGMT_RMPP_STATUS_BAD_STATUS);
- nack_recv(agent, mad_recv_wc, IB_MGMT_RMPP_STATUS_BAD_STATUS);
- return;
- }
-
- seg_num = be32_to_cpu(rmpp_mad->rmpp_hdr.seg_num);
- newwin = be32_to_cpu(rmpp_mad->rmpp_hdr.paylen_newwin);
- if (newwin < seg_num) {
- abort_send(agent, mad_recv_wc, IB_MGMT_RMPP_STATUS_W2S);
- nack_recv(agent, mad_recv_wc, IB_MGMT_RMPP_STATUS_W2S);
- return;
- }
-
- spin_lock_irqsave(&agent->lock, flags);
- mad_send_wr = ib_find_send_mad(agent, mad_recv_wc);
- if (!mad_send_wr) {
- if (!seg_num)
- process_ds_ack(agent, mad_recv_wc, newwin);
- goto out; /* Unmatched or DS RMPP ACK */
- }
-
- if ((mad_send_wr->last_ack == mad_send_wr->send_buf.seg_count) &&
- (mad_send_wr->timeout)) {
- spin_unlock_irqrestore(&agent->lock, flags);
- ack_ds_ack(agent, mad_recv_wc);
- return; /* Repeated ACK for DS RMPP transaction */
- }
-
- if ((mad_send_wr->last_ack == mad_send_wr->send_buf.seg_count) ||
- (!mad_send_wr->timeout) || (mad_send_wr->status != IB_WC_SUCCESS))
- goto out; /* Send is already done */
-
- if (seg_num > mad_send_wr->send_buf.seg_count ||
- seg_num > mad_send_wr->newwin) {
- spin_unlock_irqrestore(&agent->lock, flags);
- abort_send(agent, mad_recv_wc, IB_MGMT_RMPP_STATUS_S2B);
- nack_recv(agent, mad_recv_wc, IB_MGMT_RMPP_STATUS_S2B);
- return;
- }
-
- if (newwin < mad_send_wr->newwin || seg_num < mad_send_wr->last_ack)
- goto out; /* Old ACK */
-
- if (seg_num > mad_send_wr->last_ack) {
- adjust_last_ack(mad_send_wr, seg_num);
- mad_send_wr->retries_left = mad_send_wr->max_retries;
- }
- mad_send_wr->newwin = newwin;
- if (mad_send_wr->last_ack == mad_send_wr->send_buf.seg_count) {
- /* If no response is expected, the ACK completes the send */
- if (!mad_send_wr->send_buf.timeout_ms) {
- struct ib_mad_send_wc wc;
-
- ib_mark_mad_done(mad_send_wr);
- spin_unlock_irqrestore(&agent->lock, flags);
-
- wc.status = IB_WC_SUCCESS;
- wc.vendor_err = 0;
- wc.send_buf = &mad_send_wr->send_buf;
- ib_mad_complete_send_wr(mad_send_wr, &wc);
- return;
- }
- if (mad_send_wr->refcount == 1)
- ib_reset_mad_timeout(mad_send_wr,
- mad_send_wr->send_buf.timeout_ms);
- spin_unlock_irqrestore(&agent->lock, flags);
- ack_ds_ack(agent, mad_recv_wc);
- return;
- } else if (mad_send_wr->refcount == 1 &&
- mad_send_wr->seg_num < mad_send_wr->newwin &&
- mad_send_wr->seg_num < mad_send_wr->send_buf.seg_count) {
- /* Send failure will just result in a timeout/retry */
- ret = send_next_seg(mad_send_wr);
- if (ret)
- goto out;
-
- mad_send_wr->refcount++;
- list_move_tail(&mad_send_wr->agent_list,
- &mad_send_wr->mad_agent_priv->send_list);
- }
-out:
- spin_unlock_irqrestore(&agent->lock, flags);
-}
-
-static struct ib_mad_recv_wc *
-process_rmpp_data(struct ib_mad_agent_private *agent,
- struct ib_mad_recv_wc *mad_recv_wc)
-{
- struct ib_rmpp_hdr *rmpp_hdr;
- u8 rmpp_status;
-
- rmpp_hdr = &((struct ib_rmpp_mad *)mad_recv_wc->recv_buf.mad)->rmpp_hdr;
-
- if (rmpp_hdr->rmpp_status) {
- rmpp_status = IB_MGMT_RMPP_STATUS_BAD_STATUS;
- goto bad;
- }
-
- if (rmpp_hdr->seg_num == cpu_to_be32(1)) {
- if (!(ib_get_rmpp_flags(rmpp_hdr) & IB_MGMT_RMPP_FLAG_FIRST)) {
- rmpp_status = IB_MGMT_RMPP_STATUS_BAD_SEG;
- goto bad;
- }
- return start_rmpp(agent, mad_recv_wc);
- } else {
- if (ib_get_rmpp_flags(rmpp_hdr) & IB_MGMT_RMPP_FLAG_FIRST) {
- rmpp_status = IB_MGMT_RMPP_STATUS_BAD_SEG;
- goto bad;
- }
- return continue_rmpp(agent, mad_recv_wc);
- }
-bad:
- nack_recv(agent, mad_recv_wc, rmpp_status);
- ib_free_recv_mad(mad_recv_wc);
- return NULL;
-}
-
-static void process_rmpp_stop(struct ib_mad_agent_private *agent,
- struct ib_mad_recv_wc *mad_recv_wc)
-{
- struct ib_rmpp_mad *rmpp_mad;
-
- rmpp_mad = (struct ib_rmpp_mad *)mad_recv_wc->recv_buf.mad;
-
- if (rmpp_mad->rmpp_hdr.rmpp_status != IB_MGMT_RMPP_STATUS_RESX) {
- abort_send(agent, mad_recv_wc, IB_MGMT_RMPP_STATUS_BAD_STATUS);
- nack_recv(agent, mad_recv_wc, IB_MGMT_RMPP_STATUS_BAD_STATUS);
- } else
- abort_send(agent, mad_recv_wc, rmpp_mad->rmpp_hdr.rmpp_status);
-}
-
-static void process_rmpp_abort(struct ib_mad_agent_private *agent,
- struct ib_mad_recv_wc *mad_recv_wc)
-{
- struct ib_rmpp_mad *rmpp_mad;
-
- rmpp_mad = (struct ib_rmpp_mad *)mad_recv_wc->recv_buf.mad;
-
- if (rmpp_mad->rmpp_hdr.rmpp_status < IB_MGMT_RMPP_STATUS_ABORT_MIN ||
- rmpp_mad->rmpp_hdr.rmpp_status > IB_MGMT_RMPP_STATUS_ABORT_MAX) {
- abort_send(agent, mad_recv_wc, IB_MGMT_RMPP_STATUS_BAD_STATUS);
- nack_recv(agent, mad_recv_wc, IB_MGMT_RMPP_STATUS_BAD_STATUS);
- } else
- abort_send(agent, mad_recv_wc, rmpp_mad->rmpp_hdr.rmpp_status);
-}
-
-struct ib_mad_recv_wc *
-ib_process_rmpp_recv_wc(struct ib_mad_agent_private *agent,
- struct ib_mad_recv_wc *mad_recv_wc)
-{
- struct ib_rmpp_mad *rmpp_mad;
-
- rmpp_mad = (struct ib_rmpp_mad *)mad_recv_wc->recv_buf.mad;
- if (!(rmpp_mad->rmpp_hdr.rmpp_rtime_flags & IB_MGMT_RMPP_FLAG_ACTIVE))
- return mad_recv_wc;
-
- if (rmpp_mad->rmpp_hdr.rmpp_version != IB_MGMT_RMPP_VERSION) {
- abort_send(agent, mad_recv_wc, IB_MGMT_RMPP_STATUS_UNV);
- nack_recv(agent, mad_recv_wc, IB_MGMT_RMPP_STATUS_UNV);
- goto out;
- }
-
- switch (rmpp_mad->rmpp_hdr.rmpp_type) {
- case IB_MGMT_RMPP_TYPE_DATA:
- return process_rmpp_data(agent, mad_recv_wc);
- case IB_MGMT_RMPP_TYPE_ACK:
- process_rmpp_ack(agent, mad_recv_wc);
- break;
- case IB_MGMT_RMPP_TYPE_STOP:
- process_rmpp_stop(agent, mad_recv_wc);
- break;
- case IB_MGMT_RMPP_TYPE_ABORT:
- process_rmpp_abort(agent, mad_recv_wc);
- break;
- default:
- abort_send(agent, mad_recv_wc, IB_MGMT_RMPP_STATUS_BADT);
- nack_recv(agent, mad_recv_wc, IB_MGMT_RMPP_STATUS_BADT);
- break;
- }
-out:
- ib_free_recv_mad(mad_recv_wc);
- return NULL;
-}
-
-static int init_newwin(struct ib_mad_send_wr_private *mad_send_wr)
-{
- struct ib_mad_agent_private *agent = mad_send_wr->mad_agent_priv;
- struct ib_mad_hdr *mad_hdr = mad_send_wr->send_buf.mad;
- struct mad_rmpp_recv *rmpp_recv;
- struct ib_ah_attr ah_attr;
- unsigned long flags;
- int newwin = 1;
-
- if (!(mad_hdr->method & IB_MGMT_METHOD_RESP))
- goto out;
-
- spin_lock_irqsave(&agent->lock, flags);
- list_for_each_entry(rmpp_recv, &agent->rmpp_list, list) {
- if (rmpp_recv->tid != mad_hdr->tid ||
- rmpp_recv->mgmt_class != mad_hdr->mgmt_class ||
- rmpp_recv->class_version != mad_hdr->class_version ||
- (rmpp_recv->method & IB_MGMT_METHOD_RESP))
- continue;
-
- if (ib_query_ah(mad_send_wr->send_buf.ah, &ah_attr))
- continue;
-
- if (rmpp_recv->slid == ah_attr.dlid) {
- newwin = rmpp_recv->repwin;
- break;
- }
- }
- spin_unlock_irqrestore(&agent->lock, flags);
-out:
- return newwin;
-}
-
-int ib_send_rmpp_mad(struct ib_mad_send_wr_private *mad_send_wr)
-{
- struct ib_rmpp_mad *rmpp_mad;
- int ret;
-
- rmpp_mad = mad_send_wr->send_buf.mad;
- if (!(ib_get_rmpp_flags(&rmpp_mad->rmpp_hdr) &
- IB_MGMT_RMPP_FLAG_ACTIVE))
- return IB_RMPP_RESULT_UNHANDLED;
-
- if (rmpp_mad->rmpp_hdr.rmpp_type != IB_MGMT_RMPP_TYPE_DATA) {
- mad_send_wr->seg_num = 1;
- return IB_RMPP_RESULT_INTERNAL;
- }
-
- mad_send_wr->newwin = init_newwin(mad_send_wr);
-
- /* We need to wait for the final ACK even if there isn't a response */
- mad_send_wr->refcount += (mad_send_wr->timeout == 0);
- ret = send_next_seg(mad_send_wr);
- if (!ret)
- return IB_RMPP_RESULT_CONSUMED;
- return ret;
-}
-
-int ib_process_rmpp_send_wc(struct ib_mad_send_wr_private *mad_send_wr,
- struct ib_mad_send_wc *mad_send_wc)
-{
- struct ib_rmpp_mad *rmpp_mad;
- int ret;
-
- rmpp_mad = mad_send_wr->send_buf.mad;
- if (!(ib_get_rmpp_flags(&rmpp_mad->rmpp_hdr) &
- IB_MGMT_RMPP_FLAG_ACTIVE))
- return IB_RMPP_RESULT_UNHANDLED; /* RMPP not active */
-
- if (rmpp_mad->rmpp_hdr.rmpp_type != IB_MGMT_RMPP_TYPE_DATA)
- return IB_RMPP_RESULT_INTERNAL; /* ACK, STOP, or ABORT */
-
- if (mad_send_wc->status != IB_WC_SUCCESS ||
- mad_send_wr->status != IB_WC_SUCCESS)
- return IB_RMPP_RESULT_PROCESSED; /* Canceled or send error */
-
- if (!mad_send_wr->timeout)
- return IB_RMPP_RESULT_PROCESSED; /* Response received */
-
- if (mad_send_wr->last_ack == mad_send_wr->send_buf.seg_count) {
- mad_send_wr->timeout =
- msecs_to_jiffies(mad_send_wr->send_buf.timeout_ms);
- return IB_RMPP_RESULT_PROCESSED; /* Send done */
- }
-
- if (mad_send_wr->seg_num == mad_send_wr->newwin ||
- mad_send_wr->seg_num == mad_send_wr->send_buf.seg_count)
- return IB_RMPP_RESULT_PROCESSED; /* Wait for ACK */
-
- ret = send_next_seg(mad_send_wr);
- if (ret) {
- mad_send_wc->status = IB_WC_GENERAL_ERR;
- return IB_RMPP_RESULT_PROCESSED;
- }
- return IB_RMPP_RESULT_CONSUMED;
-}
-
-int ib_retry_rmpp(struct ib_mad_send_wr_private *mad_send_wr)
-{
- struct ib_rmpp_mad *rmpp_mad;
- int ret;
-
- rmpp_mad = mad_send_wr->send_buf.mad;
- if (!(ib_get_rmpp_flags(&rmpp_mad->rmpp_hdr) &
- IB_MGMT_RMPP_FLAG_ACTIVE))
- return IB_RMPP_RESULT_UNHANDLED; /* RMPP not active */
-
- if (mad_send_wr->last_ack == mad_send_wr->send_buf.seg_count)
- return IB_RMPP_RESULT_PROCESSED;
-
- mad_send_wr->seg_num = mad_send_wr->last_ack;
- mad_send_wr->cur_seg = mad_send_wr->last_ack_seg;
-
- ret = send_next_seg(mad_send_wr);
- if (ret)
- return IB_RMPP_RESULT_PROCESSED;
-
- return IB_RMPP_RESULT_CONSUMED;
-}
diff --git a/sys/ofed/drivers/infiniband/core/multicast.c b/sys/ofed/drivers/infiniband/core/multicast.c
deleted file mode 100644
index 4df22ee..0000000
--- a/sys/ofed/drivers/infiniband/core/multicast.c
+++ /dev/null
@@ -1,916 +0,0 @@
-/*
- * Copyright (c) 2006 Intel Corporation. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-#define LINUXKPI_PARAM_PREFIX ibcore_
-
-#include <linux/completion.h>
-#include <linux/dma-mapping.h>
-#include <linux/err.h>
-#include <linux/interrupt.h>
-#include <linux/module.h>
-#include <linux/slab.h>
-#include <linux/bitops.h>
-#include <linux/random.h>
-#include <linux/moduleparam.h>
-#include <linux/rbtree.h>
-
-#include <rdma/ib_cache.h>
-#include "sa.h"
-
-static int mcast_leave_retries = 3;
-
-/*static const struct kernel_param_ops retry_ops = {
- .set = param_set_int,
- .get = param_get_int,
-};
-
-module_param_cb(mcast_leave_retries, &retry_ops, &mcast_leave_retries, 0644);
-MODULE_PARM_DESC(mcast_leave_retries, "Number of retries for multicast leave "
- "requests before giving up (default: 3)");
-*/
-static void mcast_add_one(struct ib_device *device);
-static void mcast_remove_one(struct ib_device *device);
-
-static struct ib_client mcast_client = {
- .name = "ib_multicast",
- .add = mcast_add_one,
- .remove = mcast_remove_one
-};
-
-static struct ib_sa_client sa_client;
-static struct workqueue_struct *mcast_wq;
-static union ib_gid mgid0;
-
-struct mcast_device;
-
-struct mcast_port {
- struct mcast_device *dev;
- spinlock_t lock;
- struct rb_root table;
- atomic_t refcount;
- struct completion comp;
- u8 port_num;
-};
-
-struct mcast_device {
- struct ib_device *device;
- struct ib_event_handler event_handler;
- int start_port;
- int end_port;
- struct mcast_port port[0];
-};
-
-enum mcast_state {
- MCAST_JOINING,
- MCAST_MEMBER,
- MCAST_ERROR,
-};
-
-enum mcast_group_state {
- MCAST_IDLE,
- MCAST_BUSY,
- MCAST_GROUP_ERROR,
- MCAST_PKEY_EVENT
-};
-
-enum {
- MCAST_INVALID_PKEY_INDEX = 0xFFFF
-};
-
-struct mcast_member;
-
-struct mcast_group {
- struct ib_sa_mcmember_rec rec;
- struct rb_node node;
- struct mcast_port *port;
- spinlock_t lock;
- struct work_struct work;
- struct list_head pending_list;
- struct list_head active_list;
- struct mcast_member *last_join;
- int members[3];
- atomic_t refcount;
- enum mcast_group_state state;
- struct ib_sa_query *query;
- int query_id;
- u16 pkey_index;
- u8 leave_state;
- int retries;
-};
-
-struct mcast_member {
- struct ib_sa_multicast multicast;
- struct ib_sa_client *client;
- struct mcast_group *group;
- struct list_head list;
- enum mcast_state state;
- atomic_t refcount;
- struct completion comp;
-};
-
-static void join_handler(int status, struct ib_sa_mcmember_rec *rec,
- void *context);
-static void leave_handler(int status, struct ib_sa_mcmember_rec *rec,
- void *context);
-
-static struct mcast_group *mcast_find(struct mcast_port *port,
- union ib_gid *mgid)
-{
- struct rb_node *node = port->table.rb_node;
- struct mcast_group *group;
- int ret;
-
- while (node) {
- group = rb_entry(node, struct mcast_group, node);
- ret = memcmp(mgid->raw, group->rec.mgid.raw, sizeof *mgid);
- if (!ret)
- return group;
-
- if (ret < 0)
- node = node->rb_left;
- else
- node = node->rb_right;
- }
- return NULL;
-}
-
-static struct mcast_group *mcast_insert(struct mcast_port *port,
- struct mcast_group *group,
- int allow_duplicates)
-{
- struct rb_node **link = &port->table.rb_node;
- struct rb_node *parent = NULL;
- struct mcast_group *cur_group;
- int ret;
-
- while (*link) {
- parent = *link;
- cur_group = rb_entry(parent, struct mcast_group, node);
-
- ret = memcmp(group->rec.mgid.raw, cur_group->rec.mgid.raw,
- sizeof group->rec.mgid);
- if (ret < 0)
- link = &(*link)->rb_left;
- else if (ret > 0)
- link = &(*link)->rb_right;
- else if (allow_duplicates)
- link = &(*link)->rb_left;
- else
- return cur_group;
- }
- rb_link_node(&group->node, parent, link);
- rb_insert_color(&group->node, &port->table);
- return NULL;
-}
-
-static void deref_port(struct mcast_port *port)
-{
- if (atomic_dec_and_test(&port->refcount))
- complete(&port->comp);
-}
-
-static void release_group(struct mcast_group *group)
-{
- struct mcast_port *port = group->port;
- unsigned long flags;
-
- spin_lock_irqsave(&port->lock, flags);
- if (atomic_dec_and_test(&group->refcount)) {
- rb_erase(&group->node, &port->table);
- spin_unlock_irqrestore(&port->lock, flags);
- kfree(group);
- deref_port(port);
- } else
- spin_unlock_irqrestore(&port->lock, flags);
-}
-
-static void deref_member(struct mcast_member *member)
-{
- if (atomic_dec_and_test(&member->refcount))
- complete(&member->comp);
-}
-
-static void queue_join(struct mcast_member *member)
-{
- struct mcast_group *group = member->group;
- unsigned long flags;
-
- spin_lock_irqsave(&group->lock, flags);
- list_add_tail(&member->list, &group->pending_list);
- if (group->state == MCAST_IDLE) {
- group->state = MCAST_BUSY;
- atomic_inc(&group->refcount);
- queue_work(mcast_wq, &group->work);
- }
- spin_unlock_irqrestore(&group->lock, flags);
-}
-
-/*
- * A multicast group has three types of members: full member, non member, and
- * send only member. We need to keep track of the number of members of each
- * type based on their join state. Adjust the number of members the belong to
- * the specified join states.
- */
-static void adjust_membership(struct mcast_group *group, u8 join_state, int inc)
-{
- int i;
-
- for (i = 0; i < 3; i++, join_state >>= 1)
- if (join_state & 0x1)
- group->members[i] += inc;
-}
-
-/*
- * If a multicast group has zero members left for a particular join state, but
- * the group is still a member with the SA, we need to leave that join state.
- * Determine which join states we still belong to, but that do not have any
- * active members.
- */
-static u8 get_leave_state(struct mcast_group *group)
-{
- u8 leave_state = 0;
- int i;
-
- for (i = 0; i < 3; i++)
- if (!group->members[i])
- leave_state |= (0x1 << i);
-
- return leave_state & group->rec.join_state;
-}
-
-static int check_selector(ib_sa_comp_mask comp_mask,
- ib_sa_comp_mask selector_mask,
- ib_sa_comp_mask value_mask,
- u8 selector, u8 src_value, u8 dst_value)
-{
- int err;
-
- if (!(comp_mask & selector_mask) || !(comp_mask & value_mask))
- return 0;
-
- switch (selector) {
- case IB_SA_GT:
- err = (src_value <= dst_value);
- break;
- case IB_SA_LT:
- err = (src_value >= dst_value);
- break;
- case IB_SA_EQ:
- err = (src_value != dst_value);
- break;
- default:
- err = 0;
- break;
- }
-
- return err;
-}
-
-static int cmp_rec(struct ib_sa_mcmember_rec *src,
- struct ib_sa_mcmember_rec *dst, ib_sa_comp_mask comp_mask)
-{
- /* MGID must already match */
-
- if (comp_mask & IB_SA_MCMEMBER_REC_PORT_GID &&
- memcmp(&src->port_gid, &dst->port_gid, sizeof src->port_gid))
- return -EINVAL;
- if (comp_mask & IB_SA_MCMEMBER_REC_QKEY && src->qkey != dst->qkey)
- return -EINVAL;
- if (comp_mask & IB_SA_MCMEMBER_REC_MLID && src->mlid != dst->mlid)
- return -EINVAL;
- if (check_selector(comp_mask, IB_SA_MCMEMBER_REC_MTU_SELECTOR,
- IB_SA_MCMEMBER_REC_MTU, dst->mtu_selector,
- src->mtu, dst->mtu))
- return -EINVAL;
- if (comp_mask & IB_SA_MCMEMBER_REC_TRAFFIC_CLASS &&
- src->traffic_class != dst->traffic_class)
- return -EINVAL;
- if (comp_mask & IB_SA_MCMEMBER_REC_PKEY && src->pkey != dst->pkey)
- return -EINVAL;
- if (check_selector(comp_mask, IB_SA_MCMEMBER_REC_RATE_SELECTOR,
- IB_SA_MCMEMBER_REC_RATE, dst->rate_selector,
- src->rate, dst->rate))
- return -EINVAL;
- if (check_selector(comp_mask,
- IB_SA_MCMEMBER_REC_PACKET_LIFE_TIME_SELECTOR,
- IB_SA_MCMEMBER_REC_PACKET_LIFE_TIME,
- dst->packet_life_time_selector,
- src->packet_life_time, dst->packet_life_time))
- return -EINVAL;
- if (comp_mask & IB_SA_MCMEMBER_REC_SL && src->sl != dst->sl)
- return -EINVAL;
- if (comp_mask & IB_SA_MCMEMBER_REC_FLOW_LABEL &&
- src->flow_label != dst->flow_label)
- return -EINVAL;
- if (comp_mask & IB_SA_MCMEMBER_REC_HOP_LIMIT &&
- src->hop_limit != dst->hop_limit)
- return -EINVAL;
- if (comp_mask & IB_SA_MCMEMBER_REC_SCOPE && src->scope != dst->scope)
- return -EINVAL;
-
- /* join_state checked separately, proxy_join ignored */
-
- return 0;
-}
-
-static int send_join(struct mcast_group *group, struct mcast_member *member)
-{
- struct mcast_port *port = group->port;
- int ret;
-
- group->last_join = member;
- ret = ib_sa_mcmember_rec_query(&sa_client, port->dev->device,
- port->port_num, IB_MGMT_METHOD_SET,
- &member->multicast.rec,
- member->multicast.comp_mask,
- 3000, GFP_KERNEL, join_handler, group,
- &group->query);
- if (ret >= 0) {
- group->query_id = ret;
- ret = 0;
- }
- return ret;
-}
-
-static int send_leave(struct mcast_group *group, u8 leave_state)
-{
- struct mcast_port *port = group->port;
- struct ib_sa_mcmember_rec rec;
- int ret;
-
- rec = group->rec;
- rec.join_state = leave_state;
- group->leave_state = leave_state;
-
- ret = ib_sa_mcmember_rec_query(&sa_client, port->dev->device,
- port->port_num, IB_SA_METHOD_DELETE, &rec,
- IB_SA_MCMEMBER_REC_MGID |
- IB_SA_MCMEMBER_REC_PORT_GID |
- IB_SA_MCMEMBER_REC_JOIN_STATE,
- 3000, GFP_KERNEL, leave_handler,
- group, &group->query);
- if (ret >= 0) {
- group->query_id = ret;
- ret = 0;
- }
- return ret;
-}
-
-static void join_group(struct mcast_group *group, struct mcast_member *member,
- u8 join_state)
-{
- member->state = MCAST_MEMBER;
- adjust_membership(group, join_state, 1);
- group->rec.join_state |= join_state;
- member->multicast.rec = group->rec;
- member->multicast.rec.join_state = join_state;
- list_move(&member->list, &group->active_list);
-}
-
-static int fail_join(struct mcast_group *group, struct mcast_member *member,
- int status)
-{
- spin_lock_irq(&group->lock);
- list_del_init(&member->list);
- spin_unlock_irq(&group->lock);
- return member->multicast.callback(status, &member->multicast);
-}
-
-static void process_group_error(struct mcast_group *group)
-{
- struct mcast_member *member;
- int ret = 0;
- u16 pkey_index;
-
- if (group->state == MCAST_PKEY_EVENT)
- ret = ib_find_pkey(group->port->dev->device,
- group->port->port_num,
- be16_to_cpu(group->rec.pkey), &pkey_index);
-
- spin_lock_irq(&group->lock);
- if (group->state == MCAST_PKEY_EVENT && !ret &&
- group->pkey_index == pkey_index)
- goto out;
-
- while (!list_empty(&group->active_list)) {
- member = list_entry(group->active_list.next,
- struct mcast_member, list);
- atomic_inc(&member->refcount);
- list_del_init(&member->list);
- adjust_membership(group, member->multicast.rec.join_state, -1);
- member->state = MCAST_ERROR;
- spin_unlock_irq(&group->lock);
-
- ret = member->multicast.callback(-ENETRESET,
- &member->multicast);
- deref_member(member);
- if (ret)
- ib_sa_free_multicast(&member->multicast);
- spin_lock_irq(&group->lock);
- }
-
- group->rec.join_state = 0;
-out:
- group->state = MCAST_BUSY;
- spin_unlock_irq(&group->lock);
-}
-
-static void mcast_work_handler(struct work_struct *work)
-{
- struct mcast_group *group;
- struct mcast_member *member;
- struct ib_sa_multicast *multicast;
- int status, ret;
- u8 join_state;
-
- group = container_of(work, typeof(*group), work);
-retest:
- spin_lock_irq(&group->lock);
- while (!list_empty(&group->pending_list) ||
- (group->state != MCAST_BUSY)) {
-
- if (group->state != MCAST_BUSY) {
- spin_unlock_irq(&group->lock);
- process_group_error(group);
- goto retest;
- }
-
- member = list_entry(group->pending_list.next,
- struct mcast_member, list);
- multicast = &member->multicast;
- join_state = multicast->rec.join_state;
- atomic_inc(&member->refcount);
-
- if (join_state == (group->rec.join_state & join_state)) {
- status = cmp_rec(&group->rec, &multicast->rec,
- multicast->comp_mask);
- if (!status)
- join_group(group, member, join_state);
- else
- list_del_init(&member->list);
- spin_unlock_irq(&group->lock);
- ret = multicast->callback(status, multicast);
- } else {
- spin_unlock_irq(&group->lock);
- status = send_join(group, member);
- if (!status) {
- deref_member(member);
- return;
- }
- ret = fail_join(group, member, status);
- }
-
- deref_member(member);
- if (ret)
- ib_sa_free_multicast(&member->multicast);
- spin_lock_irq(&group->lock);
- }
-
- join_state = get_leave_state(group);
- if (join_state) {
- group->rec.join_state &= ~join_state;
- spin_unlock_irq(&group->lock);
- if (send_leave(group, join_state))
- goto retest;
- } else {
- group->state = MCAST_IDLE;
- spin_unlock_irq(&group->lock);
- release_group(group);
- }
-}
-
-/*
- * Fail a join request if it is still active - at the head of the pending queue.
- */
-static void process_join_error(struct mcast_group *group, int status)
-{
- struct mcast_member *member;
- int ret;
-
- spin_lock_irq(&group->lock);
- member = list_entry(group->pending_list.next,
- struct mcast_member, list);
- if (group->last_join == member) {
- atomic_inc(&member->refcount);
- list_del_init(&member->list);
- spin_unlock_irq(&group->lock);
- ret = member->multicast.callback(status, &member->multicast);
- deref_member(member);
- if (ret)
- ib_sa_free_multicast(&member->multicast);
- } else
- spin_unlock_irq(&group->lock);
-}
-
-static void join_handler(int status, struct ib_sa_mcmember_rec *rec,
- void *context)
-{
- struct mcast_group *group = context;
- u16 pkey_index = MCAST_INVALID_PKEY_INDEX;
-
- if (status)
- process_join_error(group, status);
- else {
- ib_find_pkey(group->port->dev->device, group->port->port_num,
- be16_to_cpu(rec->pkey), &pkey_index);
-
- spin_lock_irq(&group->port->lock);
- group->rec = *rec;
- if (group->state == MCAST_BUSY &&
- group->pkey_index == MCAST_INVALID_PKEY_INDEX)
- group->pkey_index = pkey_index;
- if (!memcmp(&mgid0, &group->rec.mgid, sizeof mgid0)) {
- rb_erase(&group->node, &group->port->table);
- mcast_insert(group->port, group, 1);
- }
- spin_unlock_irq(&group->port->lock);
- }
- mcast_work_handler(&group->work);
-}
-
-static void leave_handler(int status, struct ib_sa_mcmember_rec *rec,
- void *context)
-{
- struct mcast_group *group = context;
-
- if (status && group->retries > 0 &&
- !send_leave(group, group->leave_state))
- group->retries--;
- else {
- if (status && group->retries <= 0)
- printk(KERN_WARNING "reached max retry count. "
- "status=%d. Giving up\n", status);
- mcast_work_handler(&group->work);
- }
-}
-
-static struct mcast_group *acquire_group(struct mcast_port *port,
- union ib_gid *mgid, gfp_t gfp_mask)
-{
- struct mcast_group *group, *cur_group;
- unsigned long flags;
- int is_mgid0;
-
- is_mgid0 = !memcmp(&mgid0, mgid, sizeof mgid0);
- if (!is_mgid0) {
- spin_lock_irqsave(&port->lock, flags);
- group = mcast_find(port, mgid);
- if (group)
- goto found;
- spin_unlock_irqrestore(&port->lock, flags);
- }
-
- group = kzalloc(sizeof *group, gfp_mask);
- if (!group)
- return NULL;
-
- group->retries = mcast_leave_retries;
- group->port = port;
- group->rec.mgid = *mgid;
- group->pkey_index = MCAST_INVALID_PKEY_INDEX;
- INIT_LIST_HEAD(&group->pending_list);
- INIT_LIST_HEAD(&group->active_list);
- INIT_WORK(&group->work, mcast_work_handler);
- spin_lock_init(&group->lock);
-
- spin_lock_irqsave(&port->lock, flags);
- cur_group = mcast_insert(port, group, is_mgid0);
- if (cur_group) {
- kfree(group);
- group = cur_group;
- } else
- atomic_inc(&port->refcount);
-found:
- atomic_inc(&group->refcount);
- spin_unlock_irqrestore(&port->lock, flags);
- return group;
-}
-
-/*
- * We serialize all join requests to a single group to make our lives much
- * easier. Otherwise, two users could try to join the same group
- * simultaneously, with different configurations, one could leave while the
- * join is in progress, etc., which makes locking around error recovery
- * difficult.
- */
-struct ib_sa_multicast *
-ib_sa_join_multicast(struct ib_sa_client *client,
- struct ib_device *device, u8 port_num,
- struct ib_sa_mcmember_rec *rec,
- ib_sa_comp_mask comp_mask, gfp_t gfp_mask,
- int (*callback)(int status,
- struct ib_sa_multicast *multicast),
- void *context)
-{
- struct mcast_device *dev;
- struct mcast_member *member;
- struct ib_sa_multicast *multicast;
- int ret;
-
- dev = ib_get_client_data(device, &mcast_client);
- if (!dev)
- return ERR_PTR(-ENODEV);
-
- member = kmalloc(sizeof *member, gfp_mask);
- if (!member)
- return ERR_PTR(-ENOMEM);
-
- ib_sa_client_get(client);
- member->client = client;
- member->multicast.rec = *rec;
- member->multicast.comp_mask = comp_mask;
- member->multicast.callback = callback;
- member->multicast.context = context;
- init_completion(&member->comp);
- atomic_set(&member->refcount, 1);
- member->state = MCAST_JOINING;
-
- member->group = acquire_group(&dev->port[port_num - dev->start_port],
- &rec->mgid, gfp_mask);
- if (!member->group) {
- ret = -ENOMEM;
- goto err;
- }
-
- /*
- * The user will get the multicast structure in their callback. They
- * could then free the multicast structure before we can return from
- * this routine. So we save the pointer to return before queuing
- * any callback.
- */
- multicast = &member->multicast;
- queue_join(member);
- return multicast;
-
-err:
- ib_sa_client_put(client);
- kfree(member);
- return ERR_PTR(ret);
-}
-EXPORT_SYMBOL(ib_sa_join_multicast);
-
-void ib_sa_free_multicast(struct ib_sa_multicast *multicast)
-{
- struct mcast_member *member;
- struct mcast_group *group;
-
- member = container_of(multicast, struct mcast_member, multicast);
- group = member->group;
-
- spin_lock_irq(&group->lock);
- if (member->state == MCAST_MEMBER)
- adjust_membership(group, multicast->rec.join_state, -1);
-
- list_del_init(&member->list);
-
- if (group->state == MCAST_IDLE) {
- group->state = MCAST_BUSY;
- spin_unlock_irq(&group->lock);
- /* Continue to hold reference on group until callback */
- queue_work(mcast_wq, &group->work);
- } else {
- spin_unlock_irq(&group->lock);
- release_group(group);
- }
-
- deref_member(member);
- wait_for_completion(&member->comp);
- ib_sa_client_put(member->client);
- kfree(member);
-}
-EXPORT_SYMBOL(ib_sa_free_multicast);
-
-int ib_sa_get_mcmember_rec(struct ib_device *device, u8 port_num,
- union ib_gid *mgid, struct ib_sa_mcmember_rec *rec)
-{
- struct mcast_device *dev;
- struct mcast_port *port;
- struct mcast_group *group;
- unsigned long flags;
- int ret = 0;
-
- dev = ib_get_client_data(device, &mcast_client);
- if (!dev)
- return -ENODEV;
-
- port = &dev->port[port_num - dev->start_port];
- spin_lock_irqsave(&port->lock, flags);
- group = mcast_find(port, mgid);
- if (group)
- *rec = group->rec;
- else
- ret = -EADDRNOTAVAIL;
- spin_unlock_irqrestore(&port->lock, flags);
-
- return ret;
-}
-EXPORT_SYMBOL(ib_sa_get_mcmember_rec);
-
-int ib_init_ah_from_mcmember(struct ib_device *device, u8 port_num,
- struct ib_sa_mcmember_rec *rec,
- struct ib_ah_attr *ah_attr)
-{
- int ret;
- u16 gid_index;
- u8 p;
-
- ret = ib_find_cached_gid(device, &rec->port_gid, &p, &gid_index);
- if (ret)
- return ret;
-
- memset(ah_attr, 0, sizeof *ah_attr);
- ah_attr->dlid = be16_to_cpu(rec->mlid);
- ah_attr->sl = rec->sl;
- ah_attr->port_num = port_num;
- ah_attr->static_rate = rec->rate;
-
- ah_attr->ah_flags = IB_AH_GRH;
- ah_attr->grh.dgid = rec->mgid;
-
- ah_attr->grh.sgid_index = (u8) gid_index;
- ah_attr->grh.flow_label = be32_to_cpu(rec->flow_label);
- ah_attr->grh.hop_limit = rec->hop_limit;
- ah_attr->grh.traffic_class = rec->traffic_class;
-
- return 0;
-}
-EXPORT_SYMBOL(ib_init_ah_from_mcmember);
-
-static void mcast_groups_event(struct mcast_port *port,
- enum mcast_group_state state)
-{
- struct mcast_group *group;
- struct rb_node *node;
- unsigned long flags;
-
- spin_lock_irqsave(&port->lock, flags);
- for (node = rb_first(&port->table); node; node = rb_next(node)) {
- group = rb_entry(node, struct mcast_group, node);
- spin_lock(&group->lock);
- if (group->state == MCAST_IDLE) {
- atomic_inc(&group->refcount);
- queue_work(mcast_wq, &group->work);
- }
- if (group->state != MCAST_GROUP_ERROR)
- group->state = state;
- spin_unlock(&group->lock);
- }
- spin_unlock_irqrestore(&port->lock, flags);
-}
-
-static void mcast_event_handler(struct ib_event_handler *handler,
- struct ib_event *event)
-{
- struct mcast_device *dev;
- int index;
-
- dev = container_of(handler, struct mcast_device, event_handler);
- if (rdma_port_get_link_layer(dev->device, event->element.port_num) !=
- IB_LINK_LAYER_INFINIBAND)
- return;
-
- index = event->element.port_num - dev->start_port;
-
- switch (event->event) {
- case IB_EVENT_PORT_ERR:
- case IB_EVENT_LID_CHANGE:
- case IB_EVENT_CLIENT_REREGISTER:
- mcast_groups_event(&dev->port[index], MCAST_GROUP_ERROR);
- break;
- case IB_EVENT_PKEY_CHANGE:
- mcast_groups_event(&dev->port[index], MCAST_PKEY_EVENT);
- break;
- default:
- break;
- }
-}
-
-static void mcast_add_one(struct ib_device *device)
-{
- struct mcast_device *dev;
- struct mcast_port *port;
- int i;
- int count = 0;
-
- if (rdma_node_get_transport(device->node_type) != RDMA_TRANSPORT_IB)
- return;
-
- dev = kmalloc(sizeof *dev + device->phys_port_cnt * sizeof *port,
- GFP_KERNEL);
- if (!dev)
- return;
-
- if (device->node_type == RDMA_NODE_IB_SWITCH)
- dev->start_port = dev->end_port = 0;
- else {
- dev->start_port = 1;
- dev->end_port = device->phys_port_cnt;
- }
-
- for (i = 0; i <= dev->end_port - dev->start_port; i++) {
- if (rdma_port_get_link_layer(device, dev->start_port + i) !=
- IB_LINK_LAYER_INFINIBAND)
- continue;
- port = &dev->port[i];
- port->dev = dev;
- port->port_num = dev->start_port + i;
- spin_lock_init(&port->lock);
- port->table = RB_ROOT;
- init_completion(&port->comp);
- atomic_set(&port->refcount, 1);
- ++count;
- }
-
- if (!count) {
- kfree(dev);
- return;
- }
-
- dev->device = device;
- ib_set_client_data(device, &mcast_client, dev);
-
- INIT_IB_EVENT_HANDLER(&dev->event_handler, device, mcast_event_handler);
- ib_register_event_handler(&dev->event_handler);
-}
-
-static void mcast_remove_one(struct ib_device *device)
-{
- struct mcast_device *dev;
- struct mcast_port *port;
- int i;
-
- dev = ib_get_client_data(device, &mcast_client);
- if (!dev)
- return;
-
- ib_unregister_event_handler(&dev->event_handler);
- flush_workqueue(mcast_wq);
-
- for (i = 0; i <= dev->end_port - dev->start_port; i++) {
- if (rdma_port_get_link_layer(device, dev->start_port + i) ==
- IB_LINK_LAYER_INFINIBAND) {
- port = &dev->port[i];
- deref_port(port);
- wait_for_completion(&port->comp);
- }
- }
-
- kfree(dev);
-}
-
-int mcast_init(void)
-{
- int ret;
-
- mcast_wq = create_singlethread_workqueue("ib_mcast");
- if (!mcast_wq)
- return -ENOMEM;
-
- ib_sa_register_client(&sa_client);
-
- ret = ib_register_client(&mcast_client);
- if (ret)
- goto err;
- return 0;
-
-err:
- ib_sa_unregister_client(&sa_client);
- destroy_workqueue(mcast_wq);
- return ret;
-}
-
-void mcast_cleanup(void)
-{
- ib_unregister_client(&mcast_client);
- ib_sa_unregister_client(&sa_client);
- destroy_workqueue(mcast_wq);
-}
diff --git a/sys/ofed/drivers/infiniband/core/opa_smi.h b/sys/ofed/drivers/infiniband/core/opa_smi.h
new file mode 100644
index 0000000..3bfab35
--- /dev/null
+++ b/sys/ofed/drivers/infiniband/core/opa_smi.h
@@ -0,0 +1,78 @@
+/*
+ * Copyright (c) 2014 Intel Corporation. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+#ifndef __OPA_SMI_H_
+#define __OPA_SMI_H_
+
+#include <rdma/ib_smi.h>
+#include <rdma/opa_smi.h>
+
+#include "smi.h"
+
+enum smi_action opa_smi_handle_dr_smp_recv(struct opa_smp *smp, bool is_switch,
+ int port_num, int phys_port_cnt);
+int opa_smi_get_fwd_port(struct opa_smp *smp);
+extern enum smi_forward_action opa_smi_check_forward_dr_smp(struct opa_smp *smp);
+extern enum smi_action opa_smi_handle_dr_smp_send(struct opa_smp *smp,
+ bool is_switch, int port_num);
+
+/*
+ * Return IB_SMI_HANDLE if the SMP should be handled by the local SMA/SM
+ * via process_mad
+ */
+static inline enum smi_action opa_smi_check_local_smp(struct opa_smp *smp,
+ struct ib_device *device)
+{
+ /* C14-9:3 -- We're at the end of the DR segment of path */
+ /* C14-9:4 -- Hop Pointer = Hop Count + 1 -> give to SMA/SM */
+ return (device->process_mad &&
+ !opa_get_smp_direction(smp) &&
+ (smp->hop_ptr == smp->hop_cnt + 1)) ?
+ IB_SMI_HANDLE : IB_SMI_DISCARD;
+}
+
+/*
+ * Return IB_SMI_HANDLE if the SMP should be handled by the local SMA/SM
+ * via process_mad
+ */
+static inline enum smi_action opa_smi_check_local_returning_smp(struct opa_smp *smp,
+ struct ib_device *device)
+{
+ /* C14-13:3 -- We're at the end of the DR segment of path */
+ /* C14-13:4 -- Hop Pointer == 0 -> give to SM */
+ return (device->process_mad &&
+ opa_get_smp_direction(smp) &&
+ !smp->hop_ptr) ? IB_SMI_HANDLE : IB_SMI_DISCARD;
+}
+
+#endif /* __OPA_SMI_H_ */
diff --git a/sys/ofed/drivers/infiniband/core/packer.c b/sys/ofed/drivers/infiniband/core/packer.c
deleted file mode 100644
index 9f42595..0000000
--- a/sys/ofed/drivers/infiniband/core/packer.c
+++ /dev/null
@@ -1,203 +0,0 @@
-/*
- * Copyright (c) 2004 Topspin Corporation. All rights reserved.
- * Copyright (c) 2005 Sun Microsystems, Inc. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-#include <linux/module.h>
-#include <linux/string.h>
-
-#include <rdma/ib_pack.h>
-
-static u64 value_read(int offset, int size, void *structure)
-{
- switch (size) {
- case 1: return *(u8 *) (structure + offset);
- case 2: return be16_to_cpup((__be16 *) (structure + offset));
- case 4: return be32_to_cpup((__be32 *) (structure + offset));
- case 8: return be64_to_cpup((__be64 *) (structure + offset));
- default:
- printk(KERN_WARNING "Field size %d bits not handled\n", size * 8);
- return 0;
- }
-}
-
-/**
- * ib_pack - Pack a structure into a buffer
- * @desc:Array of structure field descriptions
- * @desc_len:Number of entries in @desc
- * @structure:Structure to pack from
- * @buf:Buffer to pack into
- *
- * ib_pack() packs a list of structure fields into a buffer,
- * controlled by the array of fields in @desc.
- */
-void ib_pack(const struct ib_field *desc,
- int desc_len,
- void *structure,
- void *buf)
-{
- int i;
-
- for (i = 0; i < desc_len; ++i) {
- if (desc[i].size_bits <= 32) {
- int shift;
- u32 val;
- __be32 mask;
- __be32 *addr;
-
- shift = 32 - desc[i].offset_bits - desc[i].size_bits;
- if (desc[i].struct_size_bytes)
- val = value_read(desc[i].struct_offset_bytes,
- desc[i].struct_size_bytes,
- structure) << shift;
- else
- val = 0;
-
- mask = cpu_to_be32(((1ull << desc[i].size_bits) - 1) << shift);
- addr = (__be32 *) buf + desc[i].offset_words;
- *addr = (*addr & ~mask) | (cpu_to_be32(val) & mask);
- } else if (desc[i].size_bits <= 64) {
- int shift;
- u64 val;
- __be64 mask;
- __be64 *addr;
-
- shift = 64 - desc[i].offset_bits - desc[i].size_bits;
- if (desc[i].struct_size_bytes)
- val = value_read(desc[i].struct_offset_bytes,
- desc[i].struct_size_bytes,
- structure) << shift;
- else
- val = 0;
-
- mask = cpu_to_be64((~0ull >> (64 - desc[i].size_bits)) << shift);
- addr = (__be64 *) ((__be32 *) buf + desc[i].offset_words);
- *addr = (*addr & ~mask) | (cpu_to_be64(val) & mask);
- } else {
- if (desc[i].offset_bits % 8 ||
- desc[i].size_bits % 8) {
- printk(KERN_WARNING "Structure field %s of size %d "
- "bits is not byte-aligned\n",
- desc[i].field_name, desc[i].size_bits);
- }
-
- if (desc[i].struct_size_bytes)
- memcpy(buf + desc[i].offset_words * 4 +
- desc[i].offset_bits / 8,
- structure + desc[i].struct_offset_bytes,
- desc[i].size_bits / 8);
- else
- memset(buf + desc[i].offset_words * 4 +
- desc[i].offset_bits / 8,
- 0,
- desc[i].size_bits / 8);
- }
- }
-}
-EXPORT_SYMBOL(ib_pack);
-
-static void value_write(int offset, int size, u64 val, void *structure)
-{
- switch (size * 8) {
- case 8: *( u8 *) (structure + offset) = val; break;
- case 16: *(__be16 *) (structure + offset) = cpu_to_be16(val); break;
- case 32: *(__be32 *) (structure + offset) = cpu_to_be32(val); break;
- case 64: *(__be64 *) (structure + offset) = cpu_to_be64(val); break;
- default:
- printk(KERN_WARNING "Field size %d bits not handled\n", size * 8);
- }
-}
-
-/**
- * ib_unpack - Unpack a buffer into a structure
- * @desc:Array of structure field descriptions
- * @desc_len:Number of entries in @desc
- * @buf:Buffer to unpack from
- * @structure:Structure to unpack into
- *
- * ib_pack() unpacks a list of structure fields from a buffer,
- * controlled by the array of fields in @desc.
- */
-void ib_unpack(const struct ib_field *desc,
- int desc_len,
- void *buf,
- void *structure)
-{
- int i;
-
- for (i = 0; i < desc_len; ++i) {
- if (!desc[i].struct_size_bytes)
- continue;
-
- if (desc[i].size_bits <= 32) {
- int shift;
- u32 val;
- u32 mask;
- __be32 *addr;
-
- shift = 32 - desc[i].offset_bits - desc[i].size_bits;
- mask = ((1ull << desc[i].size_bits) - 1) << shift;
- addr = (__be32 *) buf + desc[i].offset_words;
- val = (be32_to_cpup(addr) & mask) >> shift;
- value_write(desc[i].struct_offset_bytes,
- desc[i].struct_size_bytes,
- val,
- structure);
- } else if (desc[i].size_bits <= 64) {
- int shift;
- u64 val;
- u64 mask;
- __be64 *addr;
-
- shift = 64 - desc[i].offset_bits - desc[i].size_bits;
- mask = (~0ull >> (64 - desc[i].size_bits)) << shift;
- addr = (__be64 *) buf + desc[i].offset_words;
- val = (be64_to_cpup(addr) & mask) >> shift;
- value_write(desc[i].struct_offset_bytes,
- desc[i].struct_size_bytes,
- val,
- structure);
- } else {
- if (desc[i].offset_bits % 8 ||
- desc[i].size_bits % 8) {
- printk(KERN_WARNING "Structure field %s of size %d "
- "bits is not byte-aligned\n",
- desc[i].field_name, desc[i].size_bits);
- }
-
- memcpy(structure + desc[i].struct_offset_bytes,
- buf + desc[i].offset_words * 4 +
- desc[i].offset_bits / 8,
- desc[i].size_bits / 8);
- }
- }
-}
-EXPORT_SYMBOL(ib_unpack);
diff --git a/sys/ofed/drivers/infiniband/core/peer_mem.c b/sys/ofed/drivers/infiniband/core/peer_mem.c
deleted file mode 100644
index cd716a4..0000000
--- a/sys/ofed/drivers/infiniband/core/peer_mem.c
+++ /dev/null
@@ -1,461 +0,0 @@
-/*
- * Copyright (c) 2013, Mellanox Technologies. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-#include <rdma/ib_peer_mem.h>
-#include <rdma/ib_verbs.h>
-#include <rdma/ib_umem.h>
-
-static DEFINE_MUTEX(peer_memory_mutex);
-static LIST_HEAD(peer_memory_list);
-
-static int num_registered_peers;
-
-/* This code uses the sysfs which is not supporeted by the FreeBSD.
- * * Will be added in future to the sysctl */
-
-#if 0
-static struct kobject *peers_kobj;
-static struct ib_peer_memory_client *get_peer_by_kobj(void *kobj);
-static ssize_t version_show(struct kobject *kobj,
- struct kobj_attribute *attr, char *buf)
-{
- struct ib_peer_memory_client *ib_peer_client = get_peer_by_kobj(kobj);
-
- if (ib_peer_client) {
- sprintf(buf, "%s\n", ib_peer_client->peer_mem->version);
- return strlen(buf);
- }
- /* not found - nothing is return */
- return 0;
-}
-
-static ssize_t num_alloc_mrs_show(struct kobject *kobj,
- struct kobj_attribute *attr, char *buf)
-{
- struct ib_peer_memory_client *ib_peer_client = get_peer_by_kobj(kobj);
-
- if (ib_peer_client) {
- sprintf(buf, "%lu\n", ib_peer_client->stats.num_alloc_mrs);
- return strlen(buf);
- }
- /* not found - nothing is return */
- return 0;
-}
-
-static ssize_t num_reg_pages_show(struct kobject *kobj,
- struct kobj_attribute *attr, char *buf)
-{
- struct ib_peer_memory_client *ib_peer_client = get_peer_by_kobj(kobj);
-
- if (ib_peer_client) {
- sprintf(buf, "%lu\n", ib_peer_client->stats.num_reg_pages);
- return strlen(buf);
- }
- /* not found - nothing is return */
- return 0;
-}
-
-static ssize_t num_dereg_pages_show(struct kobject *kobj,
- struct kobj_attribute *attr, char *buf)
-{
- struct ib_peer_memory_client *ib_peer_client = get_peer_by_kobj(kobj);
-
- if (ib_peer_client) {
- sprintf(buf, "%lu\n", ib_peer_client->stats.num_dereg_pages);
- return strlen(buf);
- }
- /* not found - nothing is return */
- return 0;
-}
-
-static ssize_t num_free_callbacks_show(struct kobject *kobj,
- struct kobj_attribute *attr, char *buf)
-{
- struct ib_peer_memory_client *ib_peer_client = get_peer_by_kobj(kobj);
-
- if (ib_peer_client) {
- sprintf(buf, "%lu\n", ib_peer_client->stats.num_free_callbacks);
- return strlen(buf);
- }
- /* not found - nothing is return */
- return 0;
-}
-
-static struct kobj_attribute version_attr = __ATTR_RO(version);
-static struct kobj_attribute num_alloc_mrs = __ATTR_RO(num_alloc_mrs);
-static struct kobj_attribute num_reg_pages = __ATTR_RO(num_reg_pages);
-static struct kobj_attribute num_dereg_pages = __ATTR_RO(num_dereg_pages);
-static struct kobj_attribute num_free_callbacks = __ATTR_RO(num_free_callbacks);
-
-static struct attribute *peer_mem_attrs[] = {
- &version_attr.attr,
- &num_alloc_mrs.attr,
- &num_reg_pages.attr,
- &num_dereg_pages.attr,
- &num_free_callbacks.attr,
- NULL,
-};
-#endif
-
-#if 0
-static void destroy_peer_sysfs(struct ib_peer_memory_client *ib_peer_client)
-{
- kobject_put(ib_peer_client->kobj);
- if (!num_registered_peers)
- kobject_put(peers_kobj);
-
- return;
-}
-
-/* This code uses the sysfs which is not supporeted by the FreeBSD.
- * Will be added in future to the sysctl */
-
-static int create_peer_sysfs(struct ib_peer_memory_client *ib_peer_client)
-{
- int ret;
-
- if (!num_registered_peers) {
- /* creating under /sys/kernel/mm */
- peers_kobj = kobject_create_and_add("memory_peers", mm_kobj);
- if (!peers_kobj)
- return -ENOMEM;
- }
-
- ib_peer_client->peer_mem_attr_group.attrs = peer_mem_attrs;
- /* Dir alreday was created explicitly to get its kernel object for further usage */
- ib_peer_client->peer_mem_attr_group.name = NULL;
- ib_peer_client->kobj = kobject_create_and_add(ib_peer_client->peer_mem->name,
- peers_kobj);
-
- if (!ib_peer_client->kobj) {
- ret = -EINVAL;
- goto free;
- }
-
- /* Create the files associated with this kobject */
- ret = sysfs_create_group(ib_peer_client->kobj,
- &ib_peer_client->peer_mem_attr_group);
- if (ret)
- goto peer_free;
-
- return 0;
-
-peer_free:
- kobject_put(ib_peer_client->kobj);
-
-free:
- if (!num_registered_peers)
- kobject_put(peers_kobj);
-
- return ret;
-}
-#endif
-
-static int ib_invalidate_peer_memory(void *reg_handle,
- void *core_context)
-{
- struct ib_peer_memory_client *ib_peer_client =
- (struct ib_peer_memory_client *)reg_handle;
- struct invalidation_ctx *invalidation_ctx;
- struct core_ticket *core_ticket;
- int need_unlock = 1;
-
- mutex_lock(&ib_peer_client->lock);
- ib_peer_client->stats.num_free_callbacks += 1;
- core_ticket = ib_peer_search_context(ib_peer_client,
- (unsigned long)core_context);
- if (!core_ticket)
- goto out;
-
- invalidation_ctx = (struct invalidation_ctx *)core_ticket->context;
- /* If context not ready yet mark to be invalidated */
- if (!invalidation_ctx->func) {
- invalidation_ctx->peer_invalidated = 1;
- goto out;
- }
-
- invalidation_ctx->func(invalidation_ctx->cookie,
- invalidation_ctx->umem, 0, 0);
- if (invalidation_ctx->inflight_invalidation) {
-
- /* init the completion to wait on before letting other thread to run */
- init_completion(&invalidation_ctx->comp);
- mutex_unlock(&ib_peer_client->lock);
- need_unlock = 0;
- wait_for_completion(&invalidation_ctx->comp);
- }
-
- kfree(invalidation_ctx);
-
-out:
- if (need_unlock)
- mutex_unlock(&ib_peer_client->lock);
-
- return 0;
-}
-
-/* access to that peer client is under its lock - no extra lock is needed */
-unsigned long ib_peer_insert_context(struct ib_peer_memory_client *ib_peer_client,
- void *context)
-{
- struct core_ticket *core_ticket = kzalloc(sizeof(*core_ticket), GFP_KERNEL);
-
- ib_peer_client->last_ticket++;
- core_ticket->context = context;
- core_ticket->key = ib_peer_client->last_ticket;
-
- list_add_tail(&core_ticket->ticket_list,
- &ib_peer_client->core_ticket_list);
-
- return core_ticket->key;
-}
-
-int ib_peer_remove_context(struct ib_peer_memory_client *ib_peer_client,
- unsigned long key)
-{
- struct core_ticket *core_ticket, *tmp;
-
- list_for_each_entry_safe(core_ticket, tmp, &ib_peer_client->core_ticket_list,
- ticket_list) {
- if (core_ticket->key == key) {
- list_del(&core_ticket->ticket_list);
- kfree(core_ticket);
- return 0;
- }
- }
-
- return 1;
-}
-
-struct core_ticket *ib_peer_search_context(struct ib_peer_memory_client *ib_peer_client,
- unsigned long key)
-{
- struct core_ticket *core_ticket, *tmp;
- list_for_each_entry_safe(core_ticket, tmp, &ib_peer_client->core_ticket_list,
- ticket_list) {
- if (core_ticket->key == key)
- return core_ticket;
- }
-
- return NULL;
-}
-
-
-static int ib_memory_peer_check_mandatory(struct peer_memory_client
- *peer_client)
-{
-#define PEER_MEM_MANDATORY_FUNC(x) {\
- offsetof(struct peer_memory_client, x), #x }
-
- static const struct {
- size_t offset;
- char *name;
- } mandatory_table[] = {
- PEER_MEM_MANDATORY_FUNC(acquire),
- PEER_MEM_MANDATORY_FUNC(get_pages),
- PEER_MEM_MANDATORY_FUNC(put_pages),
- PEER_MEM_MANDATORY_FUNC(get_page_size),
- PEER_MEM_MANDATORY_FUNC(dma_map),
- PEER_MEM_MANDATORY_FUNC(dma_unmap)
- };
- int i;
-
- for (i = 0; i < ARRAY_SIZE(mandatory_table); ++i) {
- if (!*(void **) ((void *) peer_client + mandatory_table[i].offset)) {
- printk(KERN_WARNING "Peer memory %s is missing mandatory function %s\n",
- peer_client->name, mandatory_table[i].name);
- return -EINVAL;
- }
- }
-
- return 0;
-}
-
-
-
-void *ib_register_peer_memory_client(struct peer_memory_client *peer_client,
- invalidate_peer_memory *invalidate_callback)
-{
- int ret = 0;
- struct ib_peer_memory_client *ib_peer_client = NULL;
-
- mutex_lock(&peer_memory_mutex);
- if (ib_memory_peer_check_mandatory(peer_client)) {
- ret = -EINVAL;
- goto out;
- }
-
- ib_peer_client = kzalloc(sizeof(*ib_peer_client), GFP_KERNEL);
- if (!ib_peer_client)
- goto out;
- ib_peer_client->peer_mem = peer_client;
-
- INIT_LIST_HEAD(&ib_peer_client->core_ticket_list);
- mutex_init(&ib_peer_client->lock);
-#ifdef __FreeBSD__
- ib_peer_client->holdcount = 0;
- ib_peer_client->needwakeup = 0;
- cv_init(&ib_peer_client->peer_cv, "ibprcl");
-#else
- ret = init_srcu_struct(&ib_peer_client->peer_srcu);
- if (ret)
- goto free;
-#endif
-#if 0
- if (create_peer_sysfs(ib_peer_client))
- goto free;
-#endif
- *invalidate_callback = ib_invalidate_peer_memory;
- list_add_tail(&ib_peer_client->core_peer_list, &peer_memory_list);
- num_registered_peers++;
- goto out;
-#if 0
-free:
- kfree(ib_peer_client);
- ib_peer_client = NULL;
-#endif
-out:
- mutex_unlock(&peer_memory_mutex);
- return ib_peer_client;
-}
-EXPORT_SYMBOL(ib_register_peer_memory_client);
-
-void ib_unregister_peer_memory_client(void *reg_handle)
-{
- struct ib_peer_memory_client *ib_peer_client =
- (struct ib_peer_memory_client *)reg_handle;
-
- mutex_lock(&peer_memory_mutex);
- /* remove from list to prevent future core clients usage as it goes down */
- list_del(&ib_peer_client->core_peer_list);
-#ifdef __FreeBSD__
- while (ib_peer_client->holdcount != 0) {
- ib_peer_client->needwakeup = 1;
- cv_wait(&ib_peer_client->peer_cv, &peer_memory_mutex.sx);
- }
- cv_destroy(&ib_peer_client->peer_cv);
-#else
- mutex_unlock(&peer_memory_mutex);
- /* peer memory can't go down while there are active clients */
- synchronize_srcu(&ib_peer_client->peer_srcu);
- cleanup_srcu_struct(&ib_peer_client->peer_srcu);
- mutex_lock(&peer_memory_mutex);
-#endif
- num_registered_peers--;
-/* This code uses the sysfs which is not supporeted by the FreeBSD.
- * Will be added in future to the sysctl */
-#if 0
- destroy_peer_sysfs(ib_peer_client);
-#endif
- mutex_unlock(&peer_memory_mutex);
-
- kfree(ib_peer_client);
-}
-EXPORT_SYMBOL(ib_unregister_peer_memory_client);
-
-/* This code uses the sysfs which is not supporeted by the FreeBSD.
- * Will be added in future to the sysctl */
-
-#if 0
-static struct ib_peer_memory_client *get_peer_by_kobj(void *kobj)
-{
- struct ib_peer_memory_client *ib_peer_client;
-
- mutex_lock(&peer_memory_mutex);
- list_for_each_entry(ib_peer_client, &peer_memory_list, core_peer_list) {
- if (ib_peer_client->kobj == kobj)
- goto found;
- }
-
- ib_peer_client = NULL;
-
-found:
-
- mutex_unlock(&peer_memory_mutex);
- return ib_peer_client;
-}
-#endif
-
-struct ib_peer_memory_client *ib_get_peer_client(struct ib_ucontext *context, unsigned long addr,
- size_t size, void **peer_client_context,
- int *srcu_key)
-{
- struct ib_peer_memory_client *ib_peer_client;
- int ret;
-
- mutex_lock(&peer_memory_mutex);
- list_for_each_entry(ib_peer_client, &peer_memory_list, core_peer_list) {
- ret = ib_peer_client->peer_mem->acquire(addr, size,
- context->peer_mem_private_data,
- context->peer_mem_name,
- peer_client_context);
- if (ret == 1)
- goto found;
- }
-
- ib_peer_client = NULL;
-
-found:
- if (ib_peer_client) {
-#ifdef __FreeBSD__
- ib_peer_client->holdcount++;
-#else
- *srcu_key = srcu_read_lock(&ib_peer_client->peer_srcu);
-#endif
- }
-
- mutex_unlock(&peer_memory_mutex);
- return ib_peer_client;
-
-}
-EXPORT_SYMBOL(ib_get_peer_client);
-
-void ib_put_peer_client(struct ib_peer_memory_client *ib_peer_client,
- void *peer_client_context,
- int srcu_key)
-{
-
- if (ib_peer_client->peer_mem->release)
- ib_peer_client->peer_mem->release(peer_client_context);
-
-#ifdef __FreeBSD__
- ib_peer_client->holdcount--;
- if (ib_peer_client->holdcount == 0 && ib_peer_client->needwakeup) {
- cv_signal(&ib_peer_client->peer_cv);
- }
-#else
- srcu_read_unlock(&ib_peer_client->peer_srcu, srcu_key);
-#endif
- return;
-}
-EXPORT_SYMBOL(ib_put_peer_client);
-
diff --git a/sys/ofed/drivers/infiniband/core/sa_query.c b/sys/ofed/drivers/infiniband/core/sa_query.c
deleted file mode 100644
index a0c04f5..0000000
--- a/sys/ofed/drivers/infiniband/core/sa_query.c
+++ /dev/null
@@ -1,1278 +0,0 @@
-/*
- * Copyright (c) 2004 Topspin Communications. All rights reserved.
- * Copyright (c) 2005 Voltaire, Inc. All rights reserved.
- * Copyright (c) 2006 Intel Corporation. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-#include <linux/module.h>
-#include <linux/err.h>
-#include <linux/random.h>
-#include <linux/spinlock.h>
-#include <linux/slab.h>
-#include <linux/dma-mapping.h>
-#include <linux/kref.h>
-#include <linux/idr.h>
-#include <linux/workqueue.h>
-
-#include <rdma/ib_pack.h>
-#include <rdma/ib_cache.h>
-#include "sa.h"
-
-MODULE_AUTHOR("Roland Dreier");
-MODULE_DESCRIPTION("InfiniBand subnet administration query support");
-MODULE_LICENSE("Dual BSD/GPL");
-
-struct ib_sa_sm_ah {
- struct ib_ah *ah;
- struct kref ref;
- u16 pkey_index;
- u8 src_path_mask;
-};
-
-struct ib_sa_port {
- struct ib_mad_agent *agent;
- struct ib_sa_sm_ah *sm_ah;
- struct work_struct update_task;
- spinlock_t ah_lock;
- u8 port_num;
-};
-
-struct ib_sa_device {
- int start_port, end_port;
- struct ib_event_handler event_handler;
- struct ib_sa_port port[0];
-};
-
-struct ib_sa_query {
- void (*callback)(struct ib_sa_query *, int, struct ib_sa_mad *);
- void (*release)(struct ib_sa_query *);
- struct ib_sa_client *client;
- struct ib_sa_port *port;
- struct ib_mad_send_buf *mad_buf;
- struct ib_sa_sm_ah *sm_ah;
- int id;
-};
-
-struct ib_sa_service_query {
- void (*callback)(int, struct ib_sa_service_rec *, void *);
- void *context;
- struct ib_sa_query sa_query;
-};
-
-struct ib_sa_path_query {
- void (*callback)(int, struct ib_sa_path_rec *, void *);
- void *context;
- struct ib_sa_query sa_query;
-};
-
-struct ib_sa_guidinfo_query {
- void (*callback)(int, struct ib_sa_guidinfo_rec *, void *);
- void *context;
- struct ib_sa_query sa_query;
-};
-
-struct ib_sa_mcmember_query {
- void (*callback)(int, struct ib_sa_mcmember_rec *, void *);
- void *context;
- struct ib_sa_query sa_query;
-};
-
-static void ib_sa_add_one(struct ib_device *device);
-static void ib_sa_remove_one(struct ib_device *device);
-
-static struct ib_client sa_client = {
- .name = "sa",
- .add = ib_sa_add_one,
- .remove = ib_sa_remove_one
-};
-
-static DEFINE_SPINLOCK(idr_lock);
-static DEFINE_IDR(query_idr);
-
-static DEFINE_SPINLOCK(tid_lock);
-static u32 tid;
-
-#define PATH_REC_FIELD(field) \
- .struct_offset_bytes = offsetof(struct ib_sa_path_rec, field), \
- .struct_size_bytes = sizeof ((struct ib_sa_path_rec *) 0)->field, \
- .field_name = "sa_path_rec:" #field
-
-static const struct ib_field path_rec_table[] = {
- { PATH_REC_FIELD(service_id),
- .offset_words = 0,
- .offset_bits = 0,
- .size_bits = 64 },
- { PATH_REC_FIELD(dgid),
- .offset_words = 2,
- .offset_bits = 0,
- .size_bits = 128 },
- { PATH_REC_FIELD(sgid),
- .offset_words = 6,
- .offset_bits = 0,
- .size_bits = 128 },
- { PATH_REC_FIELD(dlid),
- .offset_words = 10,
- .offset_bits = 0,
- .size_bits = 16 },
- { PATH_REC_FIELD(slid),
- .offset_words = 10,
- .offset_bits = 16,
- .size_bits = 16 },
- { PATH_REC_FIELD(raw_traffic),
- .offset_words = 11,
- .offset_bits = 0,
- .size_bits = 1 },
- { RESERVED,
- .offset_words = 11,
- .offset_bits = 1,
- .size_bits = 3 },
- { PATH_REC_FIELD(flow_label),
- .offset_words = 11,
- .offset_bits = 4,
- .size_bits = 20 },
- { PATH_REC_FIELD(hop_limit),
- .offset_words = 11,
- .offset_bits = 24,
- .size_bits = 8 },
- { PATH_REC_FIELD(traffic_class),
- .offset_words = 12,
- .offset_bits = 0,
- .size_bits = 8 },
- { PATH_REC_FIELD(reversible),
- .offset_words = 12,
- .offset_bits = 8,
- .size_bits = 1 },
- { PATH_REC_FIELD(numb_path),
- .offset_words = 12,
- .offset_bits = 9,
- .size_bits = 7 },
- { PATH_REC_FIELD(pkey),
- .offset_words = 12,
- .offset_bits = 16,
- .size_bits = 16 },
- { PATH_REC_FIELD(qos_class),
- .offset_words = 13,
- .offset_bits = 0,
- .size_bits = 12 },
- { PATH_REC_FIELD(sl),
- .offset_words = 13,
- .offset_bits = 12,
- .size_bits = 4 },
- { PATH_REC_FIELD(mtu_selector),
- .offset_words = 13,
- .offset_bits = 16,
- .size_bits = 2 },
- { PATH_REC_FIELD(mtu),
- .offset_words = 13,
- .offset_bits = 18,
- .size_bits = 6 },
- { PATH_REC_FIELD(rate_selector),
- .offset_words = 13,
- .offset_bits = 24,
- .size_bits = 2 },
- { PATH_REC_FIELD(rate),
- .offset_words = 13,
- .offset_bits = 26,
- .size_bits = 6 },
- { PATH_REC_FIELD(packet_life_time_selector),
- .offset_words = 14,
- .offset_bits = 0,
- .size_bits = 2 },
- { PATH_REC_FIELD(packet_life_time),
- .offset_words = 14,
- .offset_bits = 2,
- .size_bits = 6 },
- { PATH_REC_FIELD(preference),
- .offset_words = 14,
- .offset_bits = 8,
- .size_bits = 8 },
- { RESERVED,
- .offset_words = 14,
- .offset_bits = 16,
- .size_bits = 48 },
-};
-
-#define MCMEMBER_REC_FIELD(field) \
- .struct_offset_bytes = offsetof(struct ib_sa_mcmember_rec, field), \
- .struct_size_bytes = sizeof ((struct ib_sa_mcmember_rec *) 0)->field, \
- .field_name = "sa_mcmember_rec:" #field
-
-static const struct ib_field mcmember_rec_table[] = {
- { MCMEMBER_REC_FIELD(mgid),
- .offset_words = 0,
- .offset_bits = 0,
- .size_bits = 128 },
- { MCMEMBER_REC_FIELD(port_gid),
- .offset_words = 4,
- .offset_bits = 0,
- .size_bits = 128 },
- { MCMEMBER_REC_FIELD(qkey),
- .offset_words = 8,
- .offset_bits = 0,
- .size_bits = 32 },
- { MCMEMBER_REC_FIELD(mlid),
- .offset_words = 9,
- .offset_bits = 0,
- .size_bits = 16 },
- { MCMEMBER_REC_FIELD(mtu_selector),
- .offset_words = 9,
- .offset_bits = 16,
- .size_bits = 2 },
- { MCMEMBER_REC_FIELD(mtu),
- .offset_words = 9,
- .offset_bits = 18,
- .size_bits = 6 },
- { MCMEMBER_REC_FIELD(traffic_class),
- .offset_words = 9,
- .offset_bits = 24,
- .size_bits = 8 },
- { MCMEMBER_REC_FIELD(pkey),
- .offset_words = 10,
- .offset_bits = 0,
- .size_bits = 16 },
- { MCMEMBER_REC_FIELD(rate_selector),
- .offset_words = 10,
- .offset_bits = 16,
- .size_bits = 2 },
- { MCMEMBER_REC_FIELD(rate),
- .offset_words = 10,
- .offset_bits = 18,
- .size_bits = 6 },
- { MCMEMBER_REC_FIELD(packet_life_time_selector),
- .offset_words = 10,
- .offset_bits = 24,
- .size_bits = 2 },
- { MCMEMBER_REC_FIELD(packet_life_time),
- .offset_words = 10,
- .offset_bits = 26,
- .size_bits = 6 },
- { MCMEMBER_REC_FIELD(sl),
- .offset_words = 11,
- .offset_bits = 0,
- .size_bits = 4 },
- { MCMEMBER_REC_FIELD(flow_label),
- .offset_words = 11,
- .offset_bits = 4,
- .size_bits = 20 },
- { MCMEMBER_REC_FIELD(hop_limit),
- .offset_words = 11,
- .offset_bits = 24,
- .size_bits = 8 },
- { MCMEMBER_REC_FIELD(scope),
- .offset_words = 12,
- .offset_bits = 0,
- .size_bits = 4 },
- { MCMEMBER_REC_FIELD(join_state),
- .offset_words = 12,
- .offset_bits = 4,
- .size_bits = 4 },
- { MCMEMBER_REC_FIELD(proxy_join),
- .offset_words = 12,
- .offset_bits = 8,
- .size_bits = 1 },
- { RESERVED,
- .offset_words = 12,
- .offset_bits = 9,
- .size_bits = 23 },
-};
-
-#define SERVICE_REC_FIELD(field) \
- .struct_offset_bytes = offsetof(struct ib_sa_service_rec, field), \
- .struct_size_bytes = sizeof ((struct ib_sa_service_rec *) 0)->field, \
- .field_name = "sa_service_rec:" #field
-
-static const struct ib_field service_rec_table[] = {
- { SERVICE_REC_FIELD(id),
- .offset_words = 0,
- .offset_bits = 0,
- .size_bits = 64 },
- { SERVICE_REC_FIELD(gid),
- .offset_words = 2,
- .offset_bits = 0,
- .size_bits = 128 },
- { SERVICE_REC_FIELD(pkey),
- .offset_words = 6,
- .offset_bits = 0,
- .size_bits = 16 },
- { SERVICE_REC_FIELD(lease),
- .offset_words = 7,
- .offset_bits = 0,
- .size_bits = 32 },
- { SERVICE_REC_FIELD(key),
- .offset_words = 8,
- .offset_bits = 0,
- .size_bits = 128 },
- { SERVICE_REC_FIELD(name),
- .offset_words = 12,
- .offset_bits = 0,
- .size_bits = 64*8 },
- { SERVICE_REC_FIELD(data8),
- .offset_words = 28,
- .offset_bits = 0,
- .size_bits = 16*8 },
- { SERVICE_REC_FIELD(data16),
- .offset_words = 32,
- .offset_bits = 0,
- .size_bits = 8*16 },
- { SERVICE_REC_FIELD(data32),
- .offset_words = 36,
- .offset_bits = 0,
- .size_bits = 4*32 },
- { SERVICE_REC_FIELD(data64),
- .offset_words = 40,
- .offset_bits = 0,
- .size_bits = 2*64 },
-};
-
-#define GUIDINFO_REC_FIELD(field) \
- .struct_offset_bytes = offsetof(struct ib_sa_guidinfo_rec, field), \
- .struct_size_bytes = sizeof((struct ib_sa_guidinfo_rec *) 0)->field, \
- .field_name = "sa_guidinfo_rec:" #field
-
-static const struct ib_field guidinfo_rec_table[] = {
- { GUIDINFO_REC_FIELD(lid),
- .offset_words = 0,
- .offset_bits = 0,
- .size_bits = 16 },
- { GUIDINFO_REC_FIELD(block_num),
- .offset_words = 0,
- .offset_bits = 16,
- .size_bits = 8 },
- { GUIDINFO_REC_FIELD(res1),
- .offset_words = 0,
- .offset_bits = 24,
- .size_bits = 8 },
- { GUIDINFO_REC_FIELD(res2),
- .offset_words = 1,
- .offset_bits = 0,
- .size_bits = 32 },
- { GUIDINFO_REC_FIELD(guid_info_list),
- .offset_words = 2,
- .offset_bits = 0,
- .size_bits = 512 },
-};
-
-static void free_sm_ah(struct kref *kref)
-{
- struct ib_sa_sm_ah *sm_ah = container_of(kref, struct ib_sa_sm_ah, ref);
-
- ib_destroy_ah(sm_ah->ah);
- kfree(sm_ah);
-}
-
-static void update_sm_ah(struct work_struct *work)
-{
- struct ib_sa_port *port =
- container_of(work, struct ib_sa_port, update_task);
- struct ib_sa_sm_ah *new_ah;
- struct ib_port_attr port_attr;
- struct ib_ah_attr ah_attr;
-
- if (ib_query_port(port->agent->device, port->port_num, &port_attr)) {
- printk(KERN_WARNING "Couldn't query port\n");
- return;
- }
-
- new_ah = kmalloc(sizeof *new_ah, GFP_KERNEL);
- if (!new_ah) {
- printk(KERN_WARNING "Couldn't allocate new SM AH\n");
- return;
- }
-
- kref_init(&new_ah->ref);
- new_ah->src_path_mask = (1 << port_attr.lmc) - 1;
-
- new_ah->pkey_index = 0;
- if (ib_find_pkey(port->agent->device, port->port_num,
- IB_DEFAULT_PKEY_FULL, &new_ah->pkey_index))
- printk(KERN_ERR "Couldn't find index for default PKey\n");
-
- memset(&ah_attr, 0, sizeof ah_attr);
- ah_attr.dlid = port_attr.sm_lid;
- ah_attr.sl = port_attr.sm_sl;
- ah_attr.port_num = port->port_num;
-
- new_ah->ah = ib_create_ah(port->agent->qp->pd, &ah_attr);
- if (IS_ERR(new_ah->ah)) {
- printk(KERN_WARNING "Couldn't create new SM AH\n");
- kfree(new_ah);
- return;
- }
-
- spin_lock_irq(&port->ah_lock);
- if (port->sm_ah)
- kref_put(&port->sm_ah->ref, free_sm_ah);
- port->sm_ah = new_ah;
- spin_unlock_irq(&port->ah_lock);
-
-}
-
-static void ib_sa_event(struct ib_event_handler *handler, struct ib_event *event)
-{
- if (event->event == IB_EVENT_PORT_ERR ||
- event->event == IB_EVENT_PORT_ACTIVE ||
- event->event == IB_EVENT_LID_CHANGE ||
- event->event == IB_EVENT_PKEY_CHANGE ||
- event->event == IB_EVENT_SM_CHANGE ||
- event->event == IB_EVENT_CLIENT_REREGISTER) {
- unsigned long flags;
- struct ib_sa_device *sa_dev =
- container_of(handler, typeof(*sa_dev), event_handler);
- struct ib_sa_port *port =
- &sa_dev->port[event->element.port_num - sa_dev->start_port];
-
- if (rdma_port_get_link_layer(handler->device, port->port_num) != IB_LINK_LAYER_INFINIBAND)
- return;
-
- spin_lock_irqsave(&port->ah_lock, flags);
- if (port->sm_ah)
- kref_put(&port->sm_ah->ref, free_sm_ah);
- port->sm_ah = NULL;
- spin_unlock_irqrestore(&port->ah_lock, flags);
-
- queue_work(ib_wq, &sa_dev->port[event->element.port_num -
- sa_dev->start_port].update_task);
- }
-}
-
-void ib_sa_register_client(struct ib_sa_client *client)
-{
- atomic_set(&client->users, 1);
- init_completion(&client->comp);
-}
-EXPORT_SYMBOL(ib_sa_register_client);
-
-void ib_sa_unregister_client(struct ib_sa_client *client)
-{
- ib_sa_client_put(client);
- wait_for_completion(&client->comp);
-}
-EXPORT_SYMBOL(ib_sa_unregister_client);
-
-/**
- * ib_sa_cancel_query - try to cancel an SA query
- * @id:ID of query to cancel
- * @query:query pointer to cancel
- *
- * Try to cancel an SA query. If the id and query don't match up or
- * the query has already completed, nothing is done. Otherwise the
- * query is canceled and will complete with a status of -EINTR.
- */
-void ib_sa_cancel_query(int id, struct ib_sa_query *query)
-{
- unsigned long flags;
- struct ib_mad_agent *agent;
- struct ib_mad_send_buf *mad_buf;
-
- spin_lock_irqsave(&idr_lock, flags);
- if (idr_find(&query_idr, id) != query) {
- spin_unlock_irqrestore(&idr_lock, flags);
- return;
- }
- agent = query->port->agent;
- mad_buf = query->mad_buf;
- spin_unlock_irqrestore(&idr_lock, flags);
-
- ib_cancel_mad(agent, mad_buf);
-}
-EXPORT_SYMBOL(ib_sa_cancel_query);
-
-static u8 get_src_path_mask(struct ib_device *device, u8 port_num)
-{
- struct ib_sa_device *sa_dev;
- struct ib_sa_port *port;
- unsigned long flags;
- u8 src_path_mask;
-
- sa_dev = ib_get_client_data(device, &sa_client);
- if (!sa_dev)
- return 0x7f;
-
- port = &sa_dev->port[port_num - sa_dev->start_port];
- spin_lock_irqsave(&port->ah_lock, flags);
- src_path_mask = port->sm_ah ? port->sm_ah->src_path_mask : 0x7f;
- spin_unlock_irqrestore(&port->ah_lock, flags);
-
- return src_path_mask;
-}
-
-int ib_init_ah_from_path(struct ib_device *device, u8 port_num,
- struct ib_sa_path_rec *rec, struct ib_ah_attr *ah_attr)
-{
- int ret;
- u16 gid_index;
- int force_grh;
-
- memset(ah_attr, 0, sizeof *ah_attr);
- ah_attr->dlid = be16_to_cpu(rec->dlid);
- ah_attr->sl = rec->sl;
- ah_attr->src_path_bits = be16_to_cpu(rec->slid) &
- get_src_path_mask(device, port_num);
- ah_attr->port_num = port_num;
- ah_attr->static_rate = rec->rate;
-
- force_grh = rdma_port_get_link_layer(device, port_num) == IB_LINK_LAYER_ETHERNET;
-
- if (rec->hop_limit > 1 || force_grh) {
- ah_attr->ah_flags = IB_AH_GRH;
- ah_attr->grh.dgid = rec->dgid;
-
- ret = ib_find_cached_gid(device, &rec->sgid, &port_num,
- &gid_index);
- if (ret)
- return ret;
-
- ah_attr->grh.sgid_index = gid_index;
- ah_attr->grh.flow_label = be32_to_cpu(rec->flow_label);
- ah_attr->grh.hop_limit = rec->hop_limit;
- ah_attr->grh.traffic_class = rec->traffic_class;
- }
- if (force_grh) {
- memcpy(ah_attr->dmac, rec->dmac, 6);
- ah_attr->vlan_id = rec->vlan_id;
- } else {
- memset(ah_attr->dmac, 0, 6);
- ah_attr->vlan_id = 0xffff;
- }
-
- return 0;
-}
-EXPORT_SYMBOL(ib_init_ah_from_path);
-
-static int alloc_mad(struct ib_sa_query *query, gfp_t gfp_mask)
-{
- unsigned long flags;
-
- spin_lock_irqsave(&query->port->ah_lock, flags);
- if (!query->port->sm_ah) {
- spin_unlock_irqrestore(&query->port->ah_lock, flags);
- return -EAGAIN;
- }
- kref_get(&query->port->sm_ah->ref);
- query->sm_ah = query->port->sm_ah;
- spin_unlock_irqrestore(&query->port->ah_lock, flags);
-
- query->mad_buf = ib_create_send_mad(query->port->agent, 1,
- query->sm_ah->pkey_index,
- 0, IB_MGMT_SA_HDR, IB_MGMT_SA_DATA,
- gfp_mask);
- if (IS_ERR(query->mad_buf)) {
- kref_put(&query->sm_ah->ref, free_sm_ah);
- return -ENOMEM;
- }
-
- query->mad_buf->ah = query->sm_ah->ah;
-
- return 0;
-}
-
-static void free_mad(struct ib_sa_query *query)
-{
- ib_free_send_mad(query->mad_buf);
- kref_put(&query->sm_ah->ref, free_sm_ah);
-}
-
-static void init_mad(struct ib_sa_mad *mad, struct ib_mad_agent *agent)
-{
- unsigned long flags;
-
- memset(mad, 0, sizeof *mad);
-
- mad->mad_hdr.base_version = IB_MGMT_BASE_VERSION;
- mad->mad_hdr.mgmt_class = IB_MGMT_CLASS_SUBN_ADM;
- mad->mad_hdr.class_version = IB_SA_CLASS_VERSION;
-
- spin_lock_irqsave(&tid_lock, flags);
- mad->mad_hdr.tid =
- cpu_to_be64(((u64) agent->hi_tid) << 32 | tid++);
- spin_unlock_irqrestore(&tid_lock, flags);
-}
-
-static int send_mad(struct ib_sa_query *query, int timeout_ms, gfp_t gfp_mask)
-{
- unsigned long flags;
- int ret, id;
-
-retry:
- if (!idr_pre_get(&query_idr, gfp_mask))
- return -ENOMEM;
- spin_lock_irqsave(&idr_lock, flags);
- ret = idr_get_new(&query_idr, query, &id);
- spin_unlock_irqrestore(&idr_lock, flags);
- if (ret == -EAGAIN)
- goto retry;
- if (ret)
- return ret;
-
- query->mad_buf->timeout_ms = timeout_ms;
- query->mad_buf->context[0] = query;
- query->id = id;
-
- ret = ib_post_send_mad(query->mad_buf, NULL);
- if (ret) {
- spin_lock_irqsave(&idr_lock, flags);
- idr_remove(&query_idr, id);
- spin_unlock_irqrestore(&idr_lock, flags);
- }
-
- /*
- * It's not safe to dereference query any more, because the
- * send may already have completed and freed the query in
- * another context.
- */
- return ret ? ret : id;
-}
-
-void ib_sa_unpack_path(void *attribute, struct ib_sa_path_rec *rec)
-{
- ib_unpack(path_rec_table, ARRAY_SIZE(path_rec_table), attribute, rec);
-}
-EXPORT_SYMBOL(ib_sa_unpack_path);
-
-static void ib_sa_path_rec_callback(struct ib_sa_query *sa_query,
- int status,
- struct ib_sa_mad *mad)
-{
- struct ib_sa_path_query *query =
- container_of(sa_query, struct ib_sa_path_query, sa_query);
-
- if (mad) {
- struct ib_sa_path_rec rec;
-
- ib_unpack(path_rec_table, ARRAY_SIZE(path_rec_table),
- mad->data, &rec);
- rec.vlan_id = 0xffff;
- memset(rec.dmac, 0, ETH_ALEN);
- memset(rec.smac, 0, ETH_ALEN);
-
- query->callback(status, &rec, query->context);
- } else
- query->callback(status, NULL, query->context);
-}
-
-static void ib_sa_path_rec_release(struct ib_sa_query *sa_query)
-{
- kfree(container_of(sa_query, struct ib_sa_path_query, sa_query));
-}
-
-
-/**
- * ib_sa_path_rec_get - Start a Path get query
- * @client:SA client
- * @device:device to send query on
- * @port_num: port number to send query on
- * @rec:Path Record to send in query
- * @comp_mask:component mask to send in query
- * @timeout_ms:time to wait for response
- * @gfp_mask:GFP mask to use for internal allocations
- * @callback:function called when query completes, times out or is
- * canceled
- * @context:opaque user context passed to callback
- * @sa_query:query context, used to cancel query
- *
- * Send a Path Record Get query to the SA to look up a path. The
- * callback function will be called when the query completes (or
- * fails); status is 0 for a successful response, -EINTR if the query
- * is canceled, -ETIMEDOUT is the query timed out, or -EIO if an error
- * occurred sending the query. The resp parameter of the callback is
- * only valid if status is 0.
- *
- * If the return value of ib_sa_path_rec_get() is negative, it is an
- * error code. Otherwise it is a query ID that can be used to cancel
- * the query.
- */
-int ib_sa_path_rec_get(struct ib_sa_client *client,
- struct ib_device *device, u8 port_num,
- struct ib_sa_path_rec *rec,
- ib_sa_comp_mask comp_mask,
- int timeout_ms, gfp_t gfp_mask,
- void (*callback)(int status,
- struct ib_sa_path_rec *resp,
- void *context),
- void *context,
- struct ib_sa_query **sa_query)
-{
- struct ib_sa_path_query *query;
- struct ib_sa_device *sa_dev = ib_get_client_data(device, &sa_client);
- struct ib_sa_port *port;
- struct ib_mad_agent *agent;
- struct ib_sa_mad *mad;
- int ret;
-
- if (!sa_dev)
- return -ENODEV;
-
- port = &sa_dev->port[port_num - sa_dev->start_port];
- agent = port->agent;
-
- query = kmalloc(sizeof *query, gfp_mask);
- if (!query)
- return -ENOMEM;
-
- query->sa_query.port = port;
- ret = alloc_mad(&query->sa_query, gfp_mask);
- if (ret)
- goto err1;
-
- ib_sa_client_get(client);
- query->sa_query.client = client;
- query->callback = callback;
- query->context = context;
-
- mad = query->sa_query.mad_buf->mad;
- init_mad(mad, agent);
-
- query->sa_query.callback = callback ? ib_sa_path_rec_callback : NULL;
- query->sa_query.release = ib_sa_path_rec_release;
- mad->mad_hdr.method = IB_MGMT_METHOD_GET;
- mad->mad_hdr.attr_id = cpu_to_be16(IB_SA_ATTR_PATH_REC);
- mad->sa_hdr.comp_mask = comp_mask;
-
- ib_pack(path_rec_table, ARRAY_SIZE(path_rec_table), rec, mad->data);
-
- *sa_query = &query->sa_query;
-
- ret = send_mad(&query->sa_query, timeout_ms, gfp_mask);
- if (ret < 0)
- goto err2;
-
- return ret;
-
-err2:
- *sa_query = NULL;
- ib_sa_client_put(query->sa_query.client);
- free_mad(&query->sa_query);
-
-err1:
- kfree(query);
- return ret;
-}
-EXPORT_SYMBOL(ib_sa_path_rec_get);
-
-static void ib_sa_service_rec_callback(struct ib_sa_query *sa_query,
- int status,
- struct ib_sa_mad *mad)
-{
- struct ib_sa_service_query *query =
- container_of(sa_query, struct ib_sa_service_query, sa_query);
-
- if (mad) {
- struct ib_sa_service_rec rec;
-
- ib_unpack(service_rec_table, ARRAY_SIZE(service_rec_table),
- mad->data, &rec);
- query->callback(status, &rec, query->context);
- } else
- query->callback(status, NULL, query->context);
-}
-
-static void ib_sa_service_rec_release(struct ib_sa_query *sa_query)
-{
- kfree(container_of(sa_query, struct ib_sa_service_query, sa_query));
-}
-
-/**
- * ib_sa_service_rec_query - Start Service Record operation
- * @client:SA client
- * @device:device to send request on
- * @port_num: port number to send request on
- * @method:SA method - should be get, set, or delete
- * @rec:Service Record to send in request
- * @comp_mask:component mask to send in request
- * @timeout_ms:time to wait for response
- * @gfp_mask:GFP mask to use for internal allocations
- * @callback:function called when request completes, times out or is
- * canceled
- * @context:opaque user context passed to callback
- * @sa_query:request context, used to cancel request
- *
- * Send a Service Record set/get/delete to the SA to register,
- * unregister or query a service record.
- * The callback function will be called when the request completes (or
- * fails); status is 0 for a successful response, -EINTR if the query
- * is canceled, -ETIMEDOUT is the query timed out, or -EIO if an error
- * occurred sending the query. The resp parameter of the callback is
- * only valid if status is 0.
- *
- * If the return value of ib_sa_service_rec_query() is negative, it is an
- * error code. Otherwise it is a request ID that can be used to cancel
- * the query.
- */
-int ib_sa_service_rec_query(struct ib_sa_client *client,
- struct ib_device *device, u8 port_num, u8 method,
- struct ib_sa_service_rec *rec,
- ib_sa_comp_mask comp_mask,
- int timeout_ms, gfp_t gfp_mask,
- void (*callback)(int status,
- struct ib_sa_service_rec *resp,
- void *context),
- void *context,
- struct ib_sa_query **sa_query)
-{
- struct ib_sa_service_query *query;
- struct ib_sa_device *sa_dev = ib_get_client_data(device, &sa_client);
- struct ib_sa_port *port;
- struct ib_mad_agent *agent;
- struct ib_sa_mad *mad;
- int ret;
-
- if (!sa_dev)
- return -ENODEV;
-
- port = &sa_dev->port[port_num - sa_dev->start_port];
- agent = port->agent;
-
- if (method != IB_MGMT_METHOD_GET &&
- method != IB_MGMT_METHOD_SET &&
- method != IB_SA_METHOD_DELETE)
- return -EINVAL;
-
- query = kmalloc(sizeof *query, gfp_mask);
- if (!query)
- return -ENOMEM;
-
- query->sa_query.port = port;
- ret = alloc_mad(&query->sa_query, gfp_mask);
- if (ret)
- goto err1;
-
- ib_sa_client_get(client);
- query->sa_query.client = client;
- query->callback = callback;
- query->context = context;
-
- mad = query->sa_query.mad_buf->mad;
- init_mad(mad, agent);
-
- query->sa_query.callback = callback ? ib_sa_service_rec_callback : NULL;
- query->sa_query.release = ib_sa_service_rec_release;
- mad->mad_hdr.method = method;
- mad->mad_hdr.attr_id = cpu_to_be16(IB_SA_ATTR_SERVICE_REC);
- mad->sa_hdr.comp_mask = comp_mask;
-
- ib_pack(service_rec_table, ARRAY_SIZE(service_rec_table),
- rec, mad->data);
-
- *sa_query = &query->sa_query;
-
- ret = send_mad(&query->sa_query, timeout_ms, gfp_mask);
- if (ret < 0)
- goto err2;
-
- return ret;
-
-err2:
- *sa_query = NULL;
- ib_sa_client_put(query->sa_query.client);
- free_mad(&query->sa_query);
-
-err1:
- kfree(query);
- return ret;
-}
-EXPORT_SYMBOL(ib_sa_service_rec_query);
-
-static void ib_sa_mcmember_rec_callback(struct ib_sa_query *sa_query,
- int status,
- struct ib_sa_mad *mad)
-{
- struct ib_sa_mcmember_query *query =
- container_of(sa_query, struct ib_sa_mcmember_query, sa_query);
-
- if (mad) {
- struct ib_sa_mcmember_rec rec;
-
- ib_unpack(mcmember_rec_table, ARRAY_SIZE(mcmember_rec_table),
- mad->data, &rec);
- query->callback(status, &rec, query->context);
- } else
- query->callback(status, NULL, query->context);
-}
-
-static void ib_sa_mcmember_rec_release(struct ib_sa_query *sa_query)
-{
- kfree(container_of(sa_query, struct ib_sa_mcmember_query, sa_query));
-}
-
-int ib_sa_mcmember_rec_query(struct ib_sa_client *client,
- struct ib_device *device, u8 port_num,
- u8 method,
- struct ib_sa_mcmember_rec *rec,
- ib_sa_comp_mask comp_mask,
- int timeout_ms, gfp_t gfp_mask,
- void (*callback)(int status,
- struct ib_sa_mcmember_rec *resp,
- void *context),
- void *context,
- struct ib_sa_query **sa_query)
-{
- struct ib_sa_mcmember_query *query;
- struct ib_sa_device *sa_dev = ib_get_client_data(device, &sa_client);
- struct ib_sa_port *port;
- struct ib_mad_agent *agent;
- struct ib_sa_mad *mad;
- int ret;
-
- if (!sa_dev)
- return -ENODEV;
-
- port = &sa_dev->port[port_num - sa_dev->start_port];
- agent = port->agent;
-
- query = kmalloc(sizeof *query, gfp_mask);
- if (!query)
- return -ENOMEM;
-
- query->sa_query.port = port;
- ret = alloc_mad(&query->sa_query, gfp_mask);
- if (ret)
- goto err1;
-
- ib_sa_client_get(client);
- query->sa_query.client = client;
- query->callback = callback;
- query->context = context;
-
- mad = query->sa_query.mad_buf->mad;
- init_mad(mad, agent);
-
- query->sa_query.callback = callback ? ib_sa_mcmember_rec_callback : NULL;
- query->sa_query.release = ib_sa_mcmember_rec_release;
- mad->mad_hdr.method = method;
- mad->mad_hdr.attr_id = cpu_to_be16(IB_SA_ATTR_MC_MEMBER_REC);
- mad->sa_hdr.comp_mask = comp_mask;
-
- ib_pack(mcmember_rec_table, ARRAY_SIZE(mcmember_rec_table),
- rec, mad->data);
-
- *sa_query = &query->sa_query;
-
- ret = send_mad(&query->sa_query, timeout_ms, gfp_mask);
- if (ret < 0)
- goto err2;
-
- return ret;
-
-err2:
- *sa_query = NULL;
- ib_sa_client_put(query->sa_query.client);
- free_mad(&query->sa_query);
-
-err1:
- kfree(query);
- return ret;
-}
-
-/* Support GuidInfoRecord */
-static void ib_sa_guidinfo_rec_callback(struct ib_sa_query *sa_query,
- int status,
- struct ib_sa_mad *mad)
-{
- struct ib_sa_guidinfo_query *query =
- container_of(sa_query, struct ib_sa_guidinfo_query, sa_query);
-
- if (mad) {
- struct ib_sa_guidinfo_rec rec;
-
- ib_unpack(guidinfo_rec_table, ARRAY_SIZE(guidinfo_rec_table),
- mad->data, &rec);
- query->callback(status, &rec, query->context);
- } else
- query->callback(status, NULL, query->context);
-}
-
-static void ib_sa_guidinfo_rec_release(struct ib_sa_query *sa_query)
-{
- kfree(container_of(sa_query, struct ib_sa_guidinfo_query, sa_query));
-}
-
-int ib_sa_guid_info_rec_query(struct ib_sa_client *client,
- struct ib_device *device, u8 port_num,
- struct ib_sa_guidinfo_rec *rec,
- ib_sa_comp_mask comp_mask, u8 method,
- int timeout_ms, gfp_t gfp_mask,
- void (*callback)(int status,
- struct ib_sa_guidinfo_rec *resp,
- void *context),
- void *context,
- struct ib_sa_query **sa_query)
-{
- struct ib_sa_guidinfo_query *query;
- struct ib_sa_device *sa_dev = ib_get_client_data(device, &sa_client);
- struct ib_sa_port *port;
- struct ib_mad_agent *agent;
- struct ib_sa_mad *mad;
- int ret;
-
- if (!sa_dev)
- return -ENODEV;
-
- if (method != IB_MGMT_METHOD_GET &&
- method != IB_MGMT_METHOD_SET &&
- method != IB_SA_METHOD_DELETE) {
- return -EINVAL;
- }
-
- port = &sa_dev->port[port_num - sa_dev->start_port];
- agent = port->agent;
-
- query = kmalloc(sizeof *query, gfp_mask);
- if (!query)
- return -ENOMEM;
-
- query->sa_query.port = port;
- ret = alloc_mad(&query->sa_query, gfp_mask);
- if (ret)
- goto err1;
-
- ib_sa_client_get(client);
- query->sa_query.client = client;
- query->callback = callback;
- query->context = context;
-
- mad = query->sa_query.mad_buf->mad;
- init_mad(mad, agent);
-
- query->sa_query.callback = callback ? ib_sa_guidinfo_rec_callback : NULL;
- query->sa_query.release = ib_sa_guidinfo_rec_release;
-
- mad->mad_hdr.method = method;
- mad->mad_hdr.attr_id = cpu_to_be16(IB_SA_ATTR_GUID_INFO_REC);
- mad->sa_hdr.comp_mask = comp_mask;
-
- ib_pack(guidinfo_rec_table, ARRAY_SIZE(guidinfo_rec_table), rec,
- mad->data);
-
- *sa_query = &query->sa_query;
-
- ret = send_mad(&query->sa_query, timeout_ms, gfp_mask);
- if (ret < 0)
- goto err2;
-
- return ret;
-
-err2:
- *sa_query = NULL;
- ib_sa_client_put(query->sa_query.client);
- free_mad(&query->sa_query);
-
-err1:
- kfree(query);
- return ret;
-}
-EXPORT_SYMBOL(ib_sa_guid_info_rec_query);
-
-static void send_handler(struct ib_mad_agent *agent,
- struct ib_mad_send_wc *mad_send_wc)
-{
- struct ib_sa_query *query = mad_send_wc->send_buf->context[0];
- unsigned long flags;
-
- if (query->callback)
- switch (mad_send_wc->status) {
- case IB_WC_SUCCESS:
- /* No callback -- already got recv */
- break;
- case IB_WC_RESP_TIMEOUT_ERR:
- query->callback(query, -ETIMEDOUT, NULL);
- break;
- case IB_WC_WR_FLUSH_ERR:
- query->callback(query, -EINTR, NULL);
- break;
- default:
- query->callback(query, -EIO, NULL);
- break;
- }
-
- spin_lock_irqsave(&idr_lock, flags);
- idr_remove(&query_idr, query->id);
- spin_unlock_irqrestore(&idr_lock, flags);
-
- free_mad(query);
- ib_sa_client_put(query->client);
- query->release(query);
-}
-
-static void recv_handler(struct ib_mad_agent *mad_agent,
- struct ib_mad_recv_wc *mad_recv_wc)
-{
- struct ib_sa_query *query;
- struct ib_mad_send_buf *mad_buf;
-
- mad_buf = (void *) (unsigned long) mad_recv_wc->wc->wr_id;
- query = mad_buf->context[0];
-
- if (query->callback) {
- if (mad_recv_wc->wc->status == IB_WC_SUCCESS)
- query->callback(query,
- mad_recv_wc->recv_buf.mad->mad_hdr.status ?
- -EINVAL : 0,
- (struct ib_sa_mad *) mad_recv_wc->recv_buf.mad);
- else
- query->callback(query, -EIO, NULL);
- }
-
- ib_free_recv_mad(mad_recv_wc);
-}
-
-static void ib_sa_add_one(struct ib_device *device)
-{
- struct ib_sa_device *sa_dev;
- int s, e, i;
-
- if (rdma_node_get_transport(device->node_type) != RDMA_TRANSPORT_IB)
- return;
-
- if (device->node_type == RDMA_NODE_IB_SWITCH)
- s = e = 0;
- else {
- s = 1;
- e = device->phys_port_cnt;
- }
-
- sa_dev = kzalloc(sizeof *sa_dev +
- (e - s + 1) * sizeof (struct ib_sa_port),
- GFP_KERNEL);
- if (!sa_dev)
- return;
-
- sa_dev->start_port = s;
- sa_dev->end_port = e;
-
- for (i = 0; i <= e - s; ++i) {
- spin_lock_init(&sa_dev->port[i].ah_lock);
- if (rdma_port_get_link_layer(device, i + 1) != IB_LINK_LAYER_INFINIBAND)
- continue;
-
- sa_dev->port[i].sm_ah = NULL;
- sa_dev->port[i].port_num = i + s;
-
- sa_dev->port[i].agent =
- ib_register_mad_agent(device, i + s, IB_QPT_GSI,
- NULL, 0, send_handler,
- recv_handler, sa_dev);
- if (IS_ERR(sa_dev->port[i].agent))
- goto err;
-
- INIT_WORK(&sa_dev->port[i].update_task, update_sm_ah);
- }
-
- ib_set_client_data(device, &sa_client, sa_dev);
-
- /*
- * We register our event handler after everything is set up,
- * and then update our cached info after the event handler is
- * registered to avoid any problems if a port changes state
- * during our initialization.
- */
-
- INIT_IB_EVENT_HANDLER(&sa_dev->event_handler, device, ib_sa_event);
- if (ib_register_event_handler(&sa_dev->event_handler))
- goto reg_err;
-
- for (i = 0; i <= e - s; ++i)
- if (rdma_port_get_link_layer(device, i + 1) == IB_LINK_LAYER_INFINIBAND)
- update_sm_ah(&sa_dev->port[i].update_task);
-
- return;
-
-reg_err:
- ib_set_client_data(device, &sa_client, NULL);
- i = e - s;
-err:
- for (; i >= 0; --i)
- if (rdma_port_get_link_layer(device, i + 1) == IB_LINK_LAYER_INFINIBAND &&
- !IS_ERR(sa_dev->port[i].agent))
- ib_unregister_mad_agent(sa_dev->port[i].agent);
-
- kfree(sa_dev);
-
- return;
-}
-
-static void ib_sa_remove_one(struct ib_device *device)
-{
- struct ib_sa_device *sa_dev = ib_get_client_data(device, &sa_client);
- int i;
-
- if (!sa_dev)
- return;
-
- ib_unregister_event_handler(&sa_dev->event_handler);
-
- flush_workqueue(ib_wq);
-
- for (i = 0; i <= sa_dev->end_port - sa_dev->start_port; ++i) {
- if (rdma_port_get_link_layer(device, i + 1) == IB_LINK_LAYER_INFINIBAND) {
- ib_unregister_mad_agent(sa_dev->port[i].agent);
- if (sa_dev->port[i].sm_ah)
- kref_put(&sa_dev->port[i].sm_ah->ref, free_sm_ah);
- }
-
- }
-
- kfree(sa_dev);
-}
-
-static int __init ib_sa_init(void)
-{
- int ret;
-
- get_random_bytes(&tid, sizeof tid);
-
- ret = ib_register_client(&sa_client);
- if (ret) {
- printk(KERN_ERR "Couldn't register ib_sa client\n");
- goto err1;
- }
-
- ret = mcast_init();
- if (ret) {
- printk(KERN_ERR "Couldn't initialize multicast handling\n");
- goto err2;
- }
-
- return 0;
-err2:
- ib_unregister_client(&sa_client);
-err1:
- return ret;
-}
-
-static void __exit ib_sa_cleanup(void)
-{
- mcast_cleanup();
- ib_unregister_client(&sa_client);
- idr_destroy(&query_idr);
-}
-
-module_init_order(ib_sa_init, SI_ORDER_SECOND);
-module_exit(ib_sa_cleanup);
diff --git a/sys/ofed/drivers/infiniband/core/smi.c b/sys/ofed/drivers/infiniband/core/smi.c
deleted file mode 100644
index 5855e44..0000000
--- a/sys/ofed/drivers/infiniband/core/smi.c
+++ /dev/null
@@ -1,253 +0,0 @@
-/*
- * Copyright (c) 2004, 2005 Mellanox Technologies Ltd. All rights reserved.
- * Copyright (c) 2004, 2005 Infinicon Corporation. All rights reserved.
- * Copyright (c) 2004, 2005 Intel Corporation. All rights reserved.
- * Copyright (c) 2004, 2005 Topspin Corporation. All rights reserved.
- * Copyright (c) 2004-2007 Voltaire Corporation. All rights reserved.
- * Copyright (c) 2005 Sun Microsystems, Inc. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- */
-
-#include <rdma/ib_smi.h>
-#include "smi.h"
-
-/*
- * Fixup a directed route SMP for sending
- * Return 0 if the SMP should be discarded
- */
-enum smi_action smi_handle_dr_smp_send(struct ib_smp *smp,
- u8 node_type, int port_num)
-{
- u8 hop_ptr, hop_cnt;
-
- hop_ptr = smp->hop_ptr;
- hop_cnt = smp->hop_cnt;
-
- /* See section 14.2.2.2, Vol 1 IB spec */
- /* C14-6 -- valid hop_cnt values are from 0 to 63 */
- if (hop_cnt >= IB_SMP_MAX_PATH_HOPS)
- return IB_SMI_DISCARD;
-
- if (!ib_get_smp_direction(smp)) {
- /* C14-9:1 */
- if (hop_cnt && hop_ptr == 0) {
- smp->hop_ptr++;
- return (smp->initial_path[smp->hop_ptr] ==
- port_num ? IB_SMI_HANDLE : IB_SMI_DISCARD);
- }
-
- /* C14-9:2 */
- if (hop_ptr && hop_ptr < hop_cnt) {
- if (node_type != RDMA_NODE_IB_SWITCH)
- return IB_SMI_DISCARD;
-
- /* smp->return_path set when received */
- smp->hop_ptr++;
- return (smp->initial_path[smp->hop_ptr] ==
- port_num ? IB_SMI_HANDLE : IB_SMI_DISCARD);
- }
-
- /* C14-9:3 -- We're at the end of the DR segment of path */
- if (hop_ptr == hop_cnt) {
- /* smp->return_path set when received */
- smp->hop_ptr++;
- return (node_type == RDMA_NODE_IB_SWITCH ||
- smp->dr_dlid == IB_LID_PERMISSIVE ?
- IB_SMI_HANDLE : IB_SMI_DISCARD);
- }
-
- /* C14-9:4 -- hop_ptr = hop_cnt + 1 -> give to SMA/SM */
- /* C14-9:5 -- Fail unreasonable hop pointer */
- return (hop_ptr == hop_cnt + 1 ? IB_SMI_HANDLE : IB_SMI_DISCARD);
-
- } else {
- /* C14-13:1 */
- if (hop_cnt && hop_ptr == hop_cnt + 1) {
- smp->hop_ptr--;
- return (smp->return_path[smp->hop_ptr] ==
- port_num ? IB_SMI_HANDLE : IB_SMI_DISCARD);
- }
-
- /* C14-13:2 */
- if (2 <= hop_ptr && hop_ptr <= hop_cnt) {
- if (node_type != RDMA_NODE_IB_SWITCH)
- return IB_SMI_DISCARD;
-
- smp->hop_ptr--;
- return (smp->return_path[smp->hop_ptr] ==
- port_num ? IB_SMI_HANDLE : IB_SMI_DISCARD);
- }
-
- /* C14-13:3 -- at the end of the DR segment of path */
- if (hop_ptr == 1) {
- smp->hop_ptr--;
- /* C14-13:3 -- SMPs destined for SM shouldn't be here */
- return (node_type == RDMA_NODE_IB_SWITCH ||
- smp->dr_slid == IB_LID_PERMISSIVE ?
- IB_SMI_HANDLE : IB_SMI_DISCARD);
- }
-
- /* C14-13:4 -- hop_ptr = 0 -> should have gone to SM */
- if (hop_ptr == 0)
- return IB_SMI_HANDLE;
-
- /* C14-13:5 -- Check for unreasonable hop pointer */
- return IB_SMI_DISCARD;
- }
-}
-
-/*
- * Adjust information for a received SMP
- * Return 0 if the SMP should be dropped
- */
-enum smi_action smi_handle_dr_smp_recv(struct ib_smp *smp, u8 node_type,
- int port_num, int phys_port_cnt)
-{
- u8 hop_ptr, hop_cnt;
-
- hop_ptr = smp->hop_ptr;
- hop_cnt = smp->hop_cnt;
-
- /* See section 14.2.2.2, Vol 1 IB spec */
- /* C14-6 -- valid hop_cnt values are from 0 to 63 */
- if (hop_cnt >= IB_SMP_MAX_PATH_HOPS)
- return IB_SMI_DISCARD;
-
- if (!ib_get_smp_direction(smp)) {
- /* C14-9:1 -- sender should have incremented hop_ptr */
- if (hop_cnt && hop_ptr == 0)
- return IB_SMI_DISCARD;
-
- /* C14-9:2 -- intermediate hop */
- if (hop_ptr && hop_ptr < hop_cnt) {
- if (node_type != RDMA_NODE_IB_SWITCH)
- return IB_SMI_DISCARD;
-
- smp->return_path[hop_ptr] = port_num;
- /* smp->hop_ptr updated when sending */
- return (smp->initial_path[hop_ptr+1] <= phys_port_cnt ?
- IB_SMI_HANDLE : IB_SMI_DISCARD);
- }
-
- /* C14-9:3 -- We're at the end of the DR segment of path */
- if (hop_ptr == hop_cnt) {
- if (hop_cnt)
- smp->return_path[hop_ptr] = port_num;
- /* smp->hop_ptr updated when sending */
-
- return (node_type == RDMA_NODE_IB_SWITCH ||
- smp->dr_dlid == IB_LID_PERMISSIVE ?
- IB_SMI_HANDLE : IB_SMI_DISCARD);
- }
-
- /* C14-9:4 -- hop_ptr = hop_cnt + 1 -> give to SMA/SM */
- /* C14-9:5 -- fail unreasonable hop pointer */
- return (hop_ptr == hop_cnt + 1 ? IB_SMI_HANDLE : IB_SMI_DISCARD);
-
- } else {
-
- /* C14-13:1 */
- if (hop_cnt && hop_ptr == hop_cnt + 1) {
- smp->hop_ptr--;
- return (smp->return_path[smp->hop_ptr] ==
- port_num ? IB_SMI_HANDLE : IB_SMI_DISCARD);
- }
-
- /* C14-13:2 */
- if (2 <= hop_ptr && hop_ptr <= hop_cnt) {
- if (node_type != RDMA_NODE_IB_SWITCH)
- return IB_SMI_DISCARD;
-
- /* smp->hop_ptr updated when sending */
- return (smp->return_path[hop_ptr-1] <= phys_port_cnt ?
- IB_SMI_HANDLE : IB_SMI_DISCARD);
- }
-
- /* C14-13:3 -- We're at the end of the DR segment of path */
- if (hop_ptr == 1) {
- if (smp->dr_slid == IB_LID_PERMISSIVE) {
- /* giving SMP to SM - update hop_ptr */
- smp->hop_ptr--;
- return IB_SMI_HANDLE;
- }
- /* smp->hop_ptr updated when sending */
- return (node_type == RDMA_NODE_IB_SWITCH ?
- IB_SMI_HANDLE : IB_SMI_DISCARD);
- }
-
- /* C14-13:4 -- hop_ptr = 0 -> give to SM */
- /* C14-13:5 -- Check for unreasonable hop pointer */
- return (hop_ptr == 0 ? IB_SMI_HANDLE : IB_SMI_DISCARD);
- }
-}
-
-enum smi_forward_action smi_check_forward_dr_smp(struct ib_smp *smp)
-{
- u8 hop_ptr, hop_cnt;
-
- hop_ptr = smp->hop_ptr;
- hop_cnt = smp->hop_cnt;
-
- if (!ib_get_smp_direction(smp)) {
- /* C14-9:2 -- intermediate hop */
- if (hop_ptr && hop_ptr < hop_cnt)
- return IB_SMI_FORWARD;
-
- /* C14-9:3 -- at the end of the DR segment of path */
- if (hop_ptr == hop_cnt)
- return (smp->dr_dlid == IB_LID_PERMISSIVE ?
- IB_SMI_SEND : IB_SMI_LOCAL);
-
- /* C14-9:4 -- hop_ptr = hop_cnt + 1 -> give to SMA/SM */
- if (hop_ptr == hop_cnt + 1)
- return IB_SMI_SEND;
- } else {
- /* C14-13:2 -- intermediate hop */
- if (2 <= hop_ptr && hop_ptr <= hop_cnt)
- return IB_SMI_FORWARD;
-
- /* C14-13:3 -- at the end of the DR segment of path */
- if (hop_ptr == 1)
- return (smp->dr_slid != IB_LID_PERMISSIVE ?
- IB_SMI_SEND : IB_SMI_LOCAL);
- }
- return IB_SMI_LOCAL;
-}
-
-/*
- * Return the forwarding port number from initial_path for outgoing SMP and
- * from return_path for returning SMP
- */
-int smi_get_fwd_port(struct ib_smp *smp)
-{
- return (!ib_get_smp_direction(smp) ? smp->initial_path[smp->hop_ptr+1] :
- smp->return_path[smp->hop_ptr-1]);
-}
diff --git a/sys/ofed/drivers/infiniband/core/smi.h b/sys/ofed/drivers/infiniband/core/smi.h
index aff96ba..33c91c8 100644
--- a/sys/ofed/drivers/infiniband/core/smi.h
+++ b/sys/ofed/drivers/infiniband/core/smi.h
@@ -51,12 +51,12 @@ enum smi_forward_action {
IB_SMI_FORWARD /* SMP should be forwarded (for switches only) */
};
-enum smi_action smi_handle_dr_smp_recv(struct ib_smp *smp, u8 node_type,
+enum smi_action smi_handle_dr_smp_recv(struct ib_smp *smp, bool is_switch,
int port_num, int phys_port_cnt);
int smi_get_fwd_port(struct ib_smp *smp);
extern enum smi_forward_action smi_check_forward_dr_smp(struct ib_smp *smp);
extern enum smi_action smi_handle_dr_smp_send(struct ib_smp *smp,
- u8 node_type, int port_num);
+ bool is_switch, int port_num);
/*
* Return IB_SMI_HANDLE if the SMP should be handled by the local SMA/SM
diff --git a/sys/ofed/drivers/infiniband/core/sysfs.c b/sys/ofed/drivers/infiniband/core/sysfs.c
deleted file mode 100644
index 6bcbfb9..0000000
--- a/sys/ofed/drivers/infiniband/core/sysfs.c
+++ /dev/null
@@ -1,1026 +0,0 @@
-/*
- * Copyright (c) 2004, 2005 Topspin Communications. All rights reserved.
- * Copyright (c) 2005 Mellanox Technologies Ltd. All rights reserved.
- * Copyright (c) 2005 Sun Microsystems, Inc. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-#include "core_priv.h"
-
-#include <linux/slab.h>
-#include <linux/string.h>
-#include <linux/fs.h>
-#include <linux/printk.h>
-
-#include <rdma/ib_mad.h>
-#include <rdma/ib_pma.h>
-
-struct ib_port {
- struct kobject kobj;
- struct ib_device *ibdev;
- struct attribute_group gid_group;
- struct attribute_group pkey_group;
- u8 port_num;
-};
-
-struct port_attribute {
- struct attribute attr;
- ssize_t (*show)(struct ib_port *, struct port_attribute *, char *buf);
- ssize_t (*store)(struct ib_port *, struct port_attribute *,
- const char *buf, size_t count);
-};
-
-#define PORT_ATTR(_name, _mode, _show, _store) \
-struct port_attribute port_attr_##_name = __ATTR(_name, _mode, _show, _store)
-
-#define PORT_ATTR_RO(_name) \
-struct port_attribute port_attr_##_name = __ATTR_RO(_name)
-
-struct port_table_attribute {
- struct port_attribute attr;
- char name[8];
- int index;
-};
-
-static ssize_t port_attr_show(struct kobject *kobj,
- struct attribute *attr, char *buf)
-{
- struct port_attribute *port_attr =
- container_of(attr, struct port_attribute, attr);
- struct ib_port *p = container_of(kobj, struct ib_port, kobj);
-
- if (!port_attr->show)
- return -EIO;
-
- return port_attr->show(p, port_attr, buf);
-}
-
-static const struct sysfs_ops port_sysfs_ops = {
- .show = port_attr_show
-};
-
-static ssize_t state_show(struct ib_port *p, struct port_attribute *unused,
- char *buf)
-{
- struct ib_port_attr attr;
- ssize_t ret;
-
- static const char *state_name[] = {
- [IB_PORT_NOP] = "NOP",
- [IB_PORT_DOWN] = "DOWN",
- [IB_PORT_INIT] = "INIT",
- [IB_PORT_ARMED] = "ARMED",
- [IB_PORT_ACTIVE] = "ACTIVE",
- [IB_PORT_ACTIVE_DEFER] = "ACTIVE_DEFER"
- };
-
- ret = ib_query_port(p->ibdev, p->port_num, &attr);
- if (ret)
- return ret;
-
- return sprintf(buf, "%d: %s\n", attr.state,
- attr.state >= 0 && attr.state < ARRAY_SIZE(state_name) ?
- state_name[attr.state] : "UNKNOWN");
-}
-
-static ssize_t lid_show(struct ib_port *p, struct port_attribute *unused,
- char *buf)
-{
- struct ib_port_attr attr;
- ssize_t ret;
-
- ret = ib_query_port(p->ibdev, p->port_num, &attr);
- if (ret)
- return ret;
-
- return sprintf(buf, "0x%x\n", attr.lid);
-}
-
-static ssize_t lid_mask_count_show(struct ib_port *p,
- struct port_attribute *unused,
- char *buf)
-{
- struct ib_port_attr attr;
- ssize_t ret;
-
- ret = ib_query_port(p->ibdev, p->port_num, &attr);
- if (ret)
- return ret;
-
- return sprintf(buf, "%d\n", attr.lmc);
-}
-
-static ssize_t sm_lid_show(struct ib_port *p, struct port_attribute *unused,
- char *buf)
-{
- struct ib_port_attr attr;
- ssize_t ret;
-
- ret = ib_query_port(p->ibdev, p->port_num, &attr);
- if (ret)
- return ret;
-
- return sprintf(buf, "0x%x\n", attr.sm_lid);
-}
-
-static ssize_t sm_sl_show(struct ib_port *p, struct port_attribute *unused,
- char *buf)
-{
- struct ib_port_attr attr;
- ssize_t ret;
-
- ret = ib_query_port(p->ibdev, p->port_num, &attr);
- if (ret)
- return ret;
-
- return sprintf(buf, "%d\n", attr.sm_sl);
-}
-
-static ssize_t cap_mask_show(struct ib_port *p, struct port_attribute *unused,
- char *buf)
-{
- struct ib_port_attr attr;
- ssize_t ret;
-
- ret = ib_query_port(p->ibdev, p->port_num, &attr);
- if (ret)
- return ret;
-
- return sprintf(buf, "0x%08x\n", attr.port_cap_flags);
-}
-
-static ssize_t rate_show(struct ib_port *p, struct port_attribute *unused,
- char *buf)
-{
- struct ib_port_attr attr;
- char *speed = "";
- int rate; /* in deci-Gb/sec */
- ssize_t ret;
-
- ret = ib_query_port(p->ibdev, p->port_num, &attr);
- if (ret)
- return ret;
-
- ib_active_speed_enum_to_rate(attr.active_speed,
- &rate,
- &speed);
-
- rate *= ib_width_enum_to_int(attr.active_width);
- if (rate < 0)
- return -EINVAL;
-
- return sprintf(buf, "%d%s Gb/sec (%dX%s)\n",
- rate / 10, rate % 10 ? ".5" : "",
- ib_width_enum_to_int(attr.active_width), speed);
-}
-
-static ssize_t phys_state_show(struct ib_port *p, struct port_attribute *unused,
- char *buf)
-{
- struct ib_port_attr attr;
-
- ssize_t ret;
-
- ret = ib_query_port(p->ibdev, p->port_num, &attr);
- if (ret)
- return ret;
-
- switch (attr.phys_state) {
- case 1: return sprintf(buf, "1: Sleep\n");
- case 2: return sprintf(buf, "2: Polling\n");
- case 3: return sprintf(buf, "3: Disabled\n");
- case 4: return sprintf(buf, "4: PortConfigurationTraining\n");
- case 5: return sprintf(buf, "5: LinkUp\n");
- case 6: return sprintf(buf, "6: LinkErrorRecovery\n");
- case 7: return sprintf(buf, "7: Phy Test\n");
- default: return sprintf(buf, "%d: <unknown>\n", attr.phys_state);
- }
-}
-
-static ssize_t link_layer_show(struct ib_port *p, struct port_attribute *unused,
- char *buf)
-{
- switch (rdma_port_get_link_layer(p->ibdev, p->port_num)) {
- case IB_LINK_LAYER_INFINIBAND:
- return sprintf(buf, "%s\n", "InfiniBand");
- case IB_LINK_LAYER_ETHERNET:
- return sprintf(buf, "%s\n", "Ethernet");
- case IB_LINK_LAYER_SCIF:
- return sprintf(buf, "%s\n", "SCIF");
- default:
- return sprintf(buf, "%s\n", "Unknown");
- }
-}
-
-static PORT_ATTR_RO(state);
-static PORT_ATTR_RO(lid);
-static PORT_ATTR_RO(lid_mask_count);
-static PORT_ATTR_RO(sm_lid);
-static PORT_ATTR_RO(sm_sl);
-static PORT_ATTR_RO(cap_mask);
-static PORT_ATTR_RO(rate);
-static PORT_ATTR_RO(phys_state);
-static PORT_ATTR_RO(link_layer);
-
-static struct attribute *port_default_attrs[] = {
- &port_attr_state.attr,
- &port_attr_lid.attr,
- &port_attr_lid_mask_count.attr,
- &port_attr_sm_lid.attr,
- &port_attr_sm_sl.attr,
- &port_attr_cap_mask.attr,
- &port_attr_rate.attr,
- &port_attr_phys_state.attr,
- &port_attr_link_layer.attr,
- NULL
-};
-
-static ssize_t show_port_gid(struct ib_port *p, struct port_attribute *attr,
- char *buf)
-{
- struct port_table_attribute *tab_attr =
- container_of(attr, struct port_table_attribute, attr);
- union ib_gid gid;
- ssize_t ret;
-
- ret = ib_query_gid(p->ibdev, p->port_num, tab_attr->index, &gid);
- if (ret)
- return ret;
-
- return sprintf(buf, GID_PRINT_FMT"\n",GID_PRINT_ARGS(gid.raw));
-}
-
-static ssize_t show_port_pkey(struct ib_port *p, struct port_attribute *attr,
- char *buf)
-{
- struct port_table_attribute *tab_attr =
- container_of(attr, struct port_table_attribute, attr);
- u16 pkey;
- ssize_t ret;
-
- ret = ib_query_pkey(p->ibdev, p->port_num, tab_attr->index, &pkey);
- if (ret)
- return ret;
-
- return sprintf(buf, "0x%04x\n", pkey);
-}
-
-static ssize_t get_pma_counters(struct ib_port *p, struct port_attribute *attr,
- char *buf, int c_ext)
-{
- struct port_table_attribute *tab_attr =
- container_of(attr, struct port_table_attribute, attr);
- int offset = tab_attr->index & 0xffff;
- int width = (tab_attr->index >> 16) & 0xff;
- struct ib_mad *in_mad = NULL;
- struct ib_mad *out_mad = NULL;
- ssize_t ret;
-
- if (!p->ibdev->process_mad)
- return -ENXIO;
-
- in_mad = kzalloc(sizeof *in_mad, GFP_KERNEL);
- out_mad = kmalloc(sizeof *out_mad, GFP_KERNEL);
- if (!in_mad || !out_mad) {
- ret = -ENOMEM;
- goto out;
- }
-
- in_mad->mad_hdr.base_version = 1;
- in_mad->mad_hdr.mgmt_class = IB_MGMT_CLASS_PERF_MGMT;
- in_mad->mad_hdr.class_version = 1;
- in_mad->mad_hdr.method = IB_MGMT_METHOD_GET;
- if (c_ext)
- in_mad->mad_hdr.attr_id = IB_PMA_PORT_COUNTERS_EXT;
- else
- in_mad->mad_hdr.attr_id = IB_PMA_PORT_COUNTERS;
-
- in_mad->data[41] = p->port_num; /* PortSelect field */
-
- if ((p->ibdev->process_mad(p->ibdev, IB_MAD_IGNORE_MKEY,
- p->port_num, NULL, NULL, in_mad, out_mad) &
- (IB_MAD_RESULT_SUCCESS | IB_MAD_RESULT_REPLY)) !=
- (IB_MAD_RESULT_SUCCESS | IB_MAD_RESULT_REPLY)) {
- ret = -EINVAL;
- goto out;
- }
-
- switch (width) {
- case 4:
- ret = sprintf(buf, "%u\n", (out_mad->data[40 + offset / 8] >>
- (4 - (offset % 8))) & 0xf);
- break;
- case 8:
- ret = sprintf(buf, "%u\n", out_mad->data[40 + offset / 8]);
- break;
- case 16:
- ret = sprintf(buf, "%u\n",
- be16_to_cpup((__be16 *)(out_mad->data + 40 + offset / 8)));
- break;
- case 32:
- ret = sprintf(buf, "%u\n",
- be32_to_cpup((__be32 *)(out_mad->data + 40 + offset / 8)));
- break;
- case 64:
- ret = sprintf(buf, "%llu\n",
- (unsigned long long)be64_to_cpup((__be64 *)(out_mad->data + 40 + offset / 8)));
- break;
- default:
- ret = 0;
- }
-
-out:
- kfree(in_mad);
- kfree(out_mad);
-
- return ret;
-}
-
-#define PORT_PMA_ATTR(_name, _counter, _width, _offset) \
-struct port_table_attribute port_pma_attr_##_name = { \
- .attr = __ATTR(_name, S_IRUGO, show_pma_counter, NULL), \
- .index = (_offset) | ((_width) << 16) | ((_counter) << 24) \
-}
-
-static ssize_t show_pma_counter(struct ib_port *p, struct port_attribute *attr,
- char *buf)
-{
- return get_pma_counters(p, attr, buf, 0);
-}
-
-static PORT_PMA_ATTR(symbol_error , 0, 16, 32);
-static PORT_PMA_ATTR(link_error_recovery , 1, 8, 48);
-static PORT_PMA_ATTR(link_downed , 2, 8, 56);
-static PORT_PMA_ATTR(port_rcv_errors , 3, 16, 64);
-static PORT_PMA_ATTR(port_rcv_remote_physical_errors, 4, 16, 80);
-static PORT_PMA_ATTR(port_rcv_switch_relay_errors , 5, 16, 96);
-static PORT_PMA_ATTR(port_xmit_discards , 6, 16, 112);
-static PORT_PMA_ATTR(port_xmit_constraint_errors , 7, 8, 128);
-static PORT_PMA_ATTR(port_rcv_constraint_errors , 8, 8, 136);
-static PORT_PMA_ATTR(local_link_integrity_errors , 9, 4, 152);
-static PORT_PMA_ATTR(excessive_buffer_overrun_errors, 10, 4, 156);
-static PORT_PMA_ATTR(VL15_dropped , 11, 16, 176);
-static PORT_PMA_ATTR(port_xmit_data , 12, 32, 192);
-static PORT_PMA_ATTR(port_rcv_data , 13, 32, 224);
-static PORT_PMA_ATTR(port_xmit_packets , 14, 32, 256);
-static PORT_PMA_ATTR(port_rcv_packets , 15, 32, 288);
-
-static struct attribute *pma_attrs[] = {
- &port_pma_attr_symbol_error.attr.attr,
- &port_pma_attr_link_error_recovery.attr.attr,
- &port_pma_attr_link_downed.attr.attr,
- &port_pma_attr_port_rcv_errors.attr.attr,
- &port_pma_attr_port_rcv_remote_physical_errors.attr.attr,
- &port_pma_attr_port_rcv_switch_relay_errors.attr.attr,
- &port_pma_attr_port_xmit_discards.attr.attr,
- &port_pma_attr_port_xmit_constraint_errors.attr.attr,
- &port_pma_attr_port_rcv_constraint_errors.attr.attr,
- &port_pma_attr_local_link_integrity_errors.attr.attr,
- &port_pma_attr_excessive_buffer_overrun_errors.attr.attr,
- &port_pma_attr_VL15_dropped.attr.attr,
- &port_pma_attr_port_xmit_data.attr.attr,
- &port_pma_attr_port_rcv_data.attr.attr,
- &port_pma_attr_port_xmit_packets.attr.attr,
- &port_pma_attr_port_rcv_packets.attr.attr,
- NULL
-};
-
-static struct attribute_group pma_group = {
- .name = "counters",
- .attrs = pma_attrs
-};
-
-#define PORT_PMA_ATTR_EXT(_name, _counter, _width, _offset) \
-struct port_table_attribute port_pma_attr_ext_##_name = { \
- .attr = __ATTR(_name, S_IRUGO, show_pma_counter_ext, NULL), \
- .index = (_offset) | ((_width) << 16) | ((_counter) << 24) \
-}
-
-static ssize_t show_pma_counter_ext(struct ib_port *p,
- struct port_attribute *attr, char *buf)
-{
- return get_pma_counters(p, attr, buf, 1);
-}
-
-static PORT_PMA_ATTR_EXT(port_xmit_data_64 , 0, 64, 64);
-static PORT_PMA_ATTR_EXT(port_rcv_data_64 , 0, 64, 128);
-static PORT_PMA_ATTR_EXT(port_xmit_packets_64 , 0, 64, 192);
-static PORT_PMA_ATTR_EXT(port_rcv_packets_64 , 0, 64, 256);
-static PORT_PMA_ATTR_EXT(port_unicast_xmit_packets , 0, 64, 320);
-static PORT_PMA_ATTR_EXT(port_unicast_rcv_packets , 0, 64, 384);
-static PORT_PMA_ATTR_EXT(port_multicast_xmit_packets , 0, 64, 448);
-static PORT_PMA_ATTR_EXT(port_multicast_rcv_packets , 0, 64, 512);
-
-static struct attribute *pma_attrs_ext[] = {
- &port_pma_attr_ext_port_xmit_data_64.attr.attr,
- &port_pma_attr_ext_port_rcv_data_64.attr.attr,
- &port_pma_attr_ext_port_xmit_packets_64.attr.attr,
- &port_pma_attr_ext_port_rcv_packets_64.attr.attr,
- &port_pma_attr_ext_port_unicast_xmit_packets.attr.attr,
- &port_pma_attr_ext_port_unicast_rcv_packets.attr.attr,
- &port_pma_attr_ext_port_multicast_xmit_packets.attr.attr,
- &port_pma_attr_ext_port_multicast_rcv_packets.attr.attr,
- NULL
-};
-
-static struct attribute_group pma_ext_group = {
- .name = "counters_ext",
- .attrs = pma_attrs_ext
-};
-
-static void ib_port_release(struct kobject *kobj)
-{
- struct ib_port *p = container_of(kobj, struct ib_port, kobj);
- struct attribute *a;
- int i;
-
- for (i = 0; (a = p->gid_group.attrs[i]); ++i)
- kfree(a);
-
- kfree(p->gid_group.attrs);
-
- for (i = 0; (a = p->pkey_group.attrs[i]); ++i)
- kfree(a);
-
- kfree(p->pkey_group.attrs);
-
- kfree(p);
-}
-
-static struct kobj_type port_type = {
- .release = ib_port_release,
- .sysfs_ops = &port_sysfs_ops,
- .default_attrs = port_default_attrs
-};
-
-static void ib_device_release(struct device *device)
-{
- struct ib_device *dev = container_of(device, struct ib_device, dev);
-
- kfree(dev);
-}
-
-#ifdef __linux__
-/* BSD supports this through devfs(5) and devd(8). */
-static int ib_device_uevent(struct device *device,
- struct kobj_uevent_env *env)
-{
- struct ib_device *dev = container_of(device, struct ib_device, dev);
-
- if (add_uevent_var(env, "NAME=%s", dev->name))
- return -ENOMEM;
-
- /*
- * It would be nice to pass the node GUID with the event...
- */
-
- return 0;
-}
-#endif
-
-static struct attribute **
-alloc_group_attrs(ssize_t (*show)(struct ib_port *,
- struct port_attribute *, char *buf),
- int len)
-{
- struct attribute **tab_attr;
- struct port_table_attribute *element;
- int i;
-
- tab_attr = kcalloc(1 + len, sizeof(struct attribute *), GFP_KERNEL);
- if (!tab_attr)
- return NULL;
-
- for (i = 0; i < len; i++) {
- element = kzalloc(sizeof(struct port_table_attribute),
- GFP_KERNEL);
- if (!element)
- goto err;
-
- if (snprintf(element->name, sizeof(element->name),
- "%d", i) >= sizeof(element->name)) {
- kfree(element);
- goto err;
- }
-
- element->attr.attr.name = element->name;
- element->attr.attr.mode = S_IRUGO;
- element->attr.show = show;
- element->index = i;
- sysfs_attr_init(&element->attr.attr);
-
- tab_attr[i] = &element->attr.attr;
- }
-
- return tab_attr;
-
-err:
- while (--i >= 0)
- kfree(tab_attr[i]);
- kfree(tab_attr);
- return NULL;
-}
-
-static int add_port(struct ib_device *device, int port_num,
- int (*port_callback)(struct ib_device *,
- u8, struct kobject *))
-{
- struct ib_port *p;
- struct ib_port_attr attr;
- int i;
- int ret;
-
- ret = ib_query_port(device, port_num, &attr);
- if (ret)
- return ret;
-
- p = kzalloc(sizeof *p, GFP_KERNEL);
- if (!p)
- return -ENOMEM;
-
- p->ibdev = device;
- p->port_num = port_num;
-
- ret = kobject_init_and_add(&p->kobj, &port_type,
- device->ports_parent,
- "%d", port_num);
- if (ret)
- goto err_put;
-
- ret = sysfs_create_group(&p->kobj, &pma_group);
- if (ret)
- goto err_put;
-
- ret = sysfs_create_group(&p->kobj, &pma_ext_group);
- if (ret)
- goto err_remove_pma;
-
- p->gid_group.name = "gids";
- p->gid_group.attrs = alloc_group_attrs(show_port_gid, attr.gid_tbl_len);
- if (!p->gid_group.attrs)
- goto err_remove_pma_ext;
-
- ret = sysfs_create_group(&p->kobj, &p->gid_group);
- if (ret)
- goto err_free_gid;
-
- p->pkey_group.name = "pkeys";
- p->pkey_group.attrs = alloc_group_attrs(show_port_pkey,
- attr.pkey_tbl_len);
- if (!p->pkey_group.attrs)
- goto err_remove_gid;
-
- ret = sysfs_create_group(&p->kobj, &p->pkey_group);
- if (ret)
- goto err_free_pkey;
-
- if (port_callback) {
- ret = port_callback(device, port_num, &p->kobj);
- if (ret)
- goto err_remove_pkey;
- }
-
- list_add_tail(&p->kobj.entry, &device->port_list);
-#ifdef __linux__
- kobject_uevent(&p->kobj, KOBJ_ADD);
-#endif
- return 0;
-
-err_remove_pkey:
- sysfs_remove_group(&p->kobj, &p->pkey_group);
-
-err_free_pkey:
- for (i = 0; i < attr.pkey_tbl_len; ++i)
- kfree(p->pkey_group.attrs[i]);
-
- kfree(p->pkey_group.attrs);
-
-err_remove_gid:
- sysfs_remove_group(&p->kobj, &p->gid_group);
-
-err_free_gid:
- for (i = 0; i < attr.gid_tbl_len; ++i)
- kfree(p->gid_group.attrs[i]);
-
- kfree(p->gid_group.attrs);
-
-err_remove_pma_ext:
- sysfs_remove_group(&p->kobj, &pma_ext_group);
-
-err_remove_pma:
- sysfs_remove_group(&p->kobj, &pma_group);
-
-err_put:
- kobject_put(device->ports_parent);
- kfree(p);
- return ret;
-}
-
-static ssize_t show_node_type(struct device *device,
- struct device_attribute *attr, char *buf)
-{
- struct ib_device *dev = container_of(device, struct ib_device, dev);
-
- switch (dev->node_type) {
- case RDMA_NODE_IB_CA: return sprintf(buf, "%d: CA\n", dev->node_type);
- case RDMA_NODE_RNIC: return sprintf(buf, "%d: RNIC\n", dev->node_type);
- case RDMA_NODE_IB_SWITCH: return sprintf(buf, "%d: switch\n", dev->node_type);
- case RDMA_NODE_IB_ROUTER: return sprintf(buf, "%d: router\n", dev->node_type);
- case RDMA_NODE_MIC: return sprintf(buf, "%d: MIC\n", dev->node_type);
- default: return sprintf(buf, "%d: <unknown>\n", dev->node_type);
- }
-}
-
-static ssize_t show_sys_image_guid(struct device *device,
- struct device_attribute *dev_attr, char *buf)
-{
- struct ib_device *dev = container_of(device, struct ib_device, dev);
- struct ib_device_attr attr;
- ssize_t ret;
-
- ret = ib_query_device(dev, &attr);
- if (ret)
- return ret;
-
- return sprintf(buf, "%04x:%04x:%04x:%04x\n",
- be16_to_cpu(((__be16 *) &attr.sys_image_guid)[0]),
- be16_to_cpu(((__be16 *) &attr.sys_image_guid)[1]),
- be16_to_cpu(((__be16 *) &attr.sys_image_guid)[2]),
- be16_to_cpu(((__be16 *) &attr.sys_image_guid)[3]));
-}
-
-static ssize_t show_node_guid(struct device *device,
- struct device_attribute *attr, char *buf)
-{
- struct ib_device *dev = container_of(device, struct ib_device, dev);
-
- return sprintf(buf, "%04x:%04x:%04x:%04x\n",
- be16_to_cpu(((__be16 *) &dev->node_guid)[0]),
- be16_to_cpu(((__be16 *) &dev->node_guid)[1]),
- be16_to_cpu(((__be16 *) &dev->node_guid)[2]),
- be16_to_cpu(((__be16 *) &dev->node_guid)[3]));
-}
-
-static ssize_t show_node_desc(struct device *device,
- struct device_attribute *attr, char *buf)
-{
- struct ib_device *dev = container_of(device, struct ib_device, dev);
-
- return sprintf(buf, "%.64s\n", dev->node_desc);
-}
-
-static ssize_t set_node_desc(struct device *device,
- struct device_attribute *attr,
- const char *buf, size_t count)
-{
- struct ib_device *dev = container_of(device, struct ib_device, dev);
- struct ib_device_modify desc = {};
- int ret;
-
- if (!dev->modify_device)
- return -EIO;
-
- memcpy(desc.node_desc, buf, min_t(int, count, 64));
- ret = ib_modify_device(dev, IB_DEVICE_MODIFY_NODE_DESC, &desc);
- if (ret)
- return ret;
-
- return count;
-}
-
-static ssize_t show_cmd_perf(struct device *device,
- struct device_attribute *attr, char *buf)
-{
- struct ib_device *dev = container_of(device, struct ib_device, dev);
-
- return sprintf(buf, "%d\n", dev->cmd_perf);
-}
-
-static ssize_t set_cmd_perf(struct device *device,
- struct device_attribute *attr,
- const char *buf, size_t count)
-{
- struct ib_device *dev = container_of(device, struct ib_device, dev);
- u32 val;
-
- if (sscanf(buf, "0x%x", &val) != 1)
- return -EINVAL;
-
- dev->cmd_perf = val;
-
- return count;
-}
-
-static ssize_t show_cmd_avg(struct device *device,
- struct device_attribute *attr, char *buf)
-{
- struct ib_device *dev = container_of(device, struct ib_device, dev);
-
- return sprintf(buf, "%llu\n", (unsigned long long)dev->cmd_avg);
-}
-
-static ssize_t set_cmd_avg(struct device *device,
- struct device_attribute *attr,
- const char *buf, size_t count)
-{
- struct ib_device *dev = container_of(device, struct ib_device, dev);
-
- spin_lock(&dev->cmd_perf_lock);
- dev->cmd_avg = 0;
- dev->cmd_n = 0;
- spin_unlock(&dev->cmd_perf_lock);
-
- return count;
-}
-
-static ssize_t show_cmd_n(struct device *device,
- struct device_attribute *attr, char *buf)
-{
- struct ib_device *dev = container_of(device, struct ib_device, dev);
-
- return sprintf(buf, "%d\n", dev->cmd_n);
-}
-
-static DEVICE_ATTR(node_type, S_IRUGO, show_node_type, NULL);
-static DEVICE_ATTR(sys_image_guid, S_IRUGO, show_sys_image_guid, NULL);
-static DEVICE_ATTR(node_guid, S_IRUGO, show_node_guid, NULL);
-static DEVICE_ATTR(node_desc, S_IRUGO | S_IWUSR, show_node_desc, set_node_desc);
-static DEVICE_ATTR(cmd_perf, S_IRUGO | S_IWUSR, show_cmd_perf, set_cmd_perf);
-static DEVICE_ATTR(cmd_avg, S_IRUGO | S_IWUSR, show_cmd_avg, set_cmd_avg);
-static DEVICE_ATTR(cmd_n, S_IRUGO, show_cmd_n, NULL);
-
-static struct device_attribute *ib_class_attributes[] = {
- &dev_attr_node_type,
- &dev_attr_sys_image_guid,
- &dev_attr_node_guid,
- &dev_attr_node_desc,
- &dev_attr_cmd_perf,
- &dev_attr_cmd_avg,
- &dev_attr_cmd_n,
-};
-
-static struct class ib_class = {
- .name = "infiniband",
- .dev_release = ib_device_release,
-#ifdef __linux__
- .dev_uevent = ib_device_uevent,
-#endif
-};
-
-/* Show a given an attribute in the statistics group */
-static ssize_t show_protocol_stat(const struct device *device,
- struct device_attribute *attr, char *buf,
- unsigned offset)
-{
- struct ib_device *dev = container_of(__DECONST(struct device *, device), struct ib_device, dev);
- union rdma_protocol_stats stats;
- ssize_t ret;
-
- ret = dev->get_protocol_stats(dev, &stats);
- if (ret)
- return ret;
-
- return sprintf(buf, "%llu\n",
- (unsigned long long) ((u64 *) &stats)[offset]);
-}
-
-/* generate a read-only iwarp statistics attribute */
-#define IW_STATS_ENTRY(name) \
-static ssize_t show_##name(struct device *device, \
- struct device_attribute *attr, char *buf) \
-{ \
- return show_protocol_stat(device, attr, buf, \
- offsetof(struct iw_protocol_stats, name) / \
- sizeof (u64)); \
-} \
-static DEVICE_ATTR(name, S_IRUGO, show_##name, NULL)
-
-IW_STATS_ENTRY(ipInReceives);
-IW_STATS_ENTRY(ipInHdrErrors);
-IW_STATS_ENTRY(ipInTooBigErrors);
-IW_STATS_ENTRY(ipInNoRoutes);
-IW_STATS_ENTRY(ipInAddrErrors);
-IW_STATS_ENTRY(ipInUnknownProtos);
-IW_STATS_ENTRY(ipInTruncatedPkts);
-IW_STATS_ENTRY(ipInDiscards);
-IW_STATS_ENTRY(ipInDelivers);
-IW_STATS_ENTRY(ipOutForwDatagrams);
-IW_STATS_ENTRY(ipOutRequests);
-IW_STATS_ENTRY(ipOutDiscards);
-IW_STATS_ENTRY(ipOutNoRoutes);
-IW_STATS_ENTRY(ipReasmTimeout);
-IW_STATS_ENTRY(ipReasmReqds);
-IW_STATS_ENTRY(ipReasmOKs);
-IW_STATS_ENTRY(ipReasmFails);
-IW_STATS_ENTRY(ipFragOKs);
-IW_STATS_ENTRY(ipFragFails);
-IW_STATS_ENTRY(ipFragCreates);
-IW_STATS_ENTRY(ipInMcastPkts);
-IW_STATS_ENTRY(ipOutMcastPkts);
-IW_STATS_ENTRY(ipInBcastPkts);
-IW_STATS_ENTRY(ipOutBcastPkts);
-IW_STATS_ENTRY(tcpRtoAlgorithm);
-IW_STATS_ENTRY(tcpRtoMin);
-IW_STATS_ENTRY(tcpRtoMax);
-IW_STATS_ENTRY(tcpMaxConn);
-IW_STATS_ENTRY(tcpActiveOpens);
-IW_STATS_ENTRY(tcpPassiveOpens);
-IW_STATS_ENTRY(tcpAttemptFails);
-IW_STATS_ENTRY(tcpEstabResets);
-IW_STATS_ENTRY(tcpCurrEstab);
-IW_STATS_ENTRY(tcpInSegs);
-IW_STATS_ENTRY(tcpOutSegs);
-IW_STATS_ENTRY(tcpRetransSegs);
-IW_STATS_ENTRY(tcpInErrs);
-IW_STATS_ENTRY(tcpOutRsts);
-
-static struct attribute *iw_proto_stats_attrs[] = {
- &dev_attr_ipInReceives.attr,
- &dev_attr_ipInHdrErrors.attr,
- &dev_attr_ipInTooBigErrors.attr,
- &dev_attr_ipInNoRoutes.attr,
- &dev_attr_ipInAddrErrors.attr,
- &dev_attr_ipInUnknownProtos.attr,
- &dev_attr_ipInTruncatedPkts.attr,
- &dev_attr_ipInDiscards.attr,
- &dev_attr_ipInDelivers.attr,
- &dev_attr_ipOutForwDatagrams.attr,
- &dev_attr_ipOutRequests.attr,
- &dev_attr_ipOutDiscards.attr,
- &dev_attr_ipOutNoRoutes.attr,
- &dev_attr_ipReasmTimeout.attr,
- &dev_attr_ipReasmReqds.attr,
- &dev_attr_ipReasmOKs.attr,
- &dev_attr_ipReasmFails.attr,
- &dev_attr_ipFragOKs.attr,
- &dev_attr_ipFragFails.attr,
- &dev_attr_ipFragCreates.attr,
- &dev_attr_ipInMcastPkts.attr,
- &dev_attr_ipOutMcastPkts.attr,
- &dev_attr_ipInBcastPkts.attr,
- &dev_attr_ipOutBcastPkts.attr,
- &dev_attr_tcpRtoAlgorithm.attr,
- &dev_attr_tcpRtoMin.attr,
- &dev_attr_tcpRtoMax.attr,
- &dev_attr_tcpMaxConn.attr,
- &dev_attr_tcpActiveOpens.attr,
- &dev_attr_tcpPassiveOpens.attr,
- &dev_attr_tcpAttemptFails.attr,
- &dev_attr_tcpEstabResets.attr,
- &dev_attr_tcpCurrEstab.attr,
- &dev_attr_tcpInSegs.attr,
- &dev_attr_tcpOutSegs.attr,
- &dev_attr_tcpRetransSegs.attr,
- &dev_attr_tcpInErrs.attr,
- &dev_attr_tcpOutRsts.attr,
- NULL
-};
-
-static struct attribute_group iw_stats_group = {
- .name = "proto_stats",
- .attrs = iw_proto_stats_attrs,
-};
-
-int ib_device_register_sysfs(struct ib_device *device,
- int (*port_callback)(struct ib_device *,
- u8, struct kobject *))
-{
- struct device *class_dev = &device->dev;
- int ret;
- int i;
-
- class_dev->class = &ib_class;
- class_dev->parent = device->dma_device;
- dev_set_name(class_dev, device->name);
- dev_set_drvdata(class_dev, device);
-
- INIT_LIST_HEAD(&device->port_list);
-
- ret = device_register(class_dev);
- if (ret)
- goto err;
-
- for (i = 0; i < ARRAY_SIZE(ib_class_attributes); ++i) {
- ret = device_create_file(class_dev, ib_class_attributes[i]);
- if (ret)
- goto err_unregister;
- }
-
- device->ports_parent = kobject_create_and_add("ports",&class_dev->kobj);
- if (!device->ports_parent) {
- ret = -ENOMEM;
- goto err_put;
- }
-
- if (device->node_type == RDMA_NODE_IB_SWITCH) {
- ret = add_port(device, 0, port_callback);
- if (ret)
- goto err_put;
- } else {
- for (i = 1; i <= device->phys_port_cnt; ++i) {
- ret = add_port(device, i, port_callback);
- if (ret)
- goto err_put;
- }
- }
-
- if (device->node_type == RDMA_NODE_RNIC && device->get_protocol_stats) {
- ret = sysfs_create_group(&class_dev->kobj, &iw_stats_group);
- if (ret)
- goto err_put;
- }
-
- return 0;
-
-err_put:
- {
- struct kobject *p, *t;
- struct ib_port *port;
-
- list_for_each_entry_safe(p, t, &device->port_list, entry) {
- list_del(&p->entry);
- port = container_of(p, struct ib_port, kobj);
- sysfs_remove_group(p, &pma_group);
- sysfs_remove_group(p, &port->pkey_group);
- sysfs_remove_group(p, &port->gid_group);
- kobject_put(p);
- }
- }
-
- kobject_put(&class_dev->kobj);
-
-err_unregister:
-
- for (i = 0; i < ARRAY_SIZE(ib_class_attributes); ++i) {
- device_remove_file(class_dev, ib_class_attributes[i]);
- }
-
- device_unregister(class_dev);
-
-err:
- return ret;
-}
-
-void ib_device_unregister_sysfs(struct ib_device *device)
-{
- int i;
- struct kobject *p, *t;
- struct ib_port *port;
- struct device *class_dev = &device->dev;
-
- /* Hold kobject until ib_dealloc_device() */
- kobject_get(&device->dev.kobj);
-
- for (i = 0; i < ARRAY_SIZE(ib_class_attributes); ++i) {
- device_remove_file(class_dev, ib_class_attributes[i]);
- }
-
- list_for_each_entry_safe(p, t, &device->port_list, entry) {
- list_del(&p->entry);
- port = container_of(p, struct ib_port, kobj);
- sysfs_remove_group(p, &pma_group);
- sysfs_remove_group(p, &port->pkey_group);
- sysfs_remove_group(p, &port->gid_group);
- kobject_put(p);
- }
-
- kobject_put(device->ports_parent);
- device_unregister(&device->dev);
-}
-
-int ib_sysfs_setup(void)
-{
- return class_register(&ib_class);
-}
-
-void ib_sysfs_cleanup(void)
-{
- class_unregister(&ib_class);
-}
diff --git a/sys/ofed/drivers/infiniband/core/ucm.c b/sys/ofed/drivers/infiniband/core/ucm.c
deleted file mode 100644
index 4f69eab..0000000
--- a/sys/ofed/drivers/infiniband/core/ucm.c
+++ /dev/null
@@ -1,1386 +0,0 @@
-/*
- * Copyright (c) 2005 Topspin Communications. All rights reserved.
- * Copyright (c) 2005 Intel Corporation. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-#include <linux/completion.h>
-#include <linux/fs.h>
-#include <linux/module.h>
-#include <linux/device.h>
-#include <linux/err.h>
-#include <linux/poll.h>
-#include <linux/sched.h>
-#include <linux/file.h>
-#include <linux/cdev.h>
-#include <linux/idr.h>
-#include <linux/mutex.h>
-#include <linux/slab.h>
-#include <linux/string.h>
-
-#include <asm/uaccess.h>
-
-#include <rdma/ib_cm.h>
-#include <rdma/ib_user_cm.h>
-#include <rdma/ib_marshall.h>
-
-MODULE_AUTHOR("Libor Michalek");
-MODULE_DESCRIPTION("InfiniBand userspace Connection Manager access");
-MODULE_LICENSE("Dual BSD/GPL");
-
-struct ib_ucm_device {
- int devnum;
- struct cdev cdev;
- struct device dev;
- struct ib_device *ib_dev;
-};
-
-struct ib_ucm_file {
- struct mutex file_mutex;
- struct file *filp;
- struct ib_ucm_device *device;
-
- struct list_head ctxs;
- struct list_head events;
- wait_queue_head_t poll_wait;
-};
-
-struct ib_ucm_context {
- int id;
- struct completion comp;
- atomic_t ref;
- int events_reported;
-
- struct ib_ucm_file *file;
- struct ib_cm_id *cm_id;
- __u64 uid;
-
- struct list_head events; /* list of pending events. */
- struct list_head file_list; /* member in file ctx list */
-};
-
-struct ib_ucm_event {
- struct ib_ucm_context *ctx;
- struct list_head file_list; /* member in file event list */
- struct list_head ctx_list; /* member in ctx event list */
-
- struct ib_cm_id *cm_id;
- struct ib_ucm_event_resp resp;
- void *data;
- void *info;
- int data_len;
- int info_len;
-};
-
-enum {
- IB_UCM_MAJOR = 231,
- IB_UCM_BASE_MINOR = 224,
- IB_UCM_MAX_DEVICES = 32
-};
-
-#define IB_UCM_BASE_DEV MKDEV(IB_UCM_MAJOR, IB_UCM_BASE_MINOR)
-
-static void ib_ucm_add_one(struct ib_device *device);
-static void ib_ucm_remove_one(struct ib_device *device);
-
-static struct ib_client ucm_client = {
- .name = "ucm",
- .add = ib_ucm_add_one,
- .remove = ib_ucm_remove_one
-};
-
-static DEFINE_MUTEX(ctx_id_mutex);
-static DEFINE_IDR(ctx_id_table);
-static DECLARE_BITMAP(dev_map, IB_UCM_MAX_DEVICES);
-
-static struct ib_ucm_context *ib_ucm_ctx_get(struct ib_ucm_file *file, int id)
-{
- struct ib_ucm_context *ctx;
-
- mutex_lock(&ctx_id_mutex);
- ctx = idr_find(&ctx_id_table, id);
- if (!ctx)
- ctx = ERR_PTR(-ENOENT);
- else if (ctx->file != file)
- ctx = ERR_PTR(-EINVAL);
- else
- atomic_inc(&ctx->ref);
- mutex_unlock(&ctx_id_mutex);
-
- return ctx;
-}
-
-static void ib_ucm_ctx_put(struct ib_ucm_context *ctx)
-{
- if (atomic_dec_and_test(&ctx->ref))
- complete(&ctx->comp);
-}
-
-static inline int ib_ucm_new_cm_id(int event)
-{
- return event == IB_CM_REQ_RECEIVED || event == IB_CM_SIDR_REQ_RECEIVED;
-}
-
-static void ib_ucm_cleanup_events(struct ib_ucm_context *ctx)
-{
- struct ib_ucm_event *uevent;
-
- mutex_lock(&ctx->file->file_mutex);
- list_del(&ctx->file_list);
- while (!list_empty(&ctx->events)) {
-
- uevent = list_entry(ctx->events.next,
- struct ib_ucm_event, ctx_list);
- list_del(&uevent->file_list);
- list_del(&uevent->ctx_list);
- mutex_unlock(&ctx->file->file_mutex);
-
- /* clear incoming connections. */
- if (ib_ucm_new_cm_id(uevent->resp.event))
- ib_destroy_cm_id(uevent->cm_id);
-
- kfree(uevent);
- mutex_lock(&ctx->file->file_mutex);
- }
- mutex_unlock(&ctx->file->file_mutex);
-}
-
-static struct ib_ucm_context *ib_ucm_ctx_alloc(struct ib_ucm_file *file)
-{
- struct ib_ucm_context *ctx;
- int result;
-
- ctx = kzalloc(sizeof *ctx, GFP_KERNEL);
- if (!ctx)
- return NULL;
-
- atomic_set(&ctx->ref, 1);
- init_completion(&ctx->comp);
- ctx->file = file;
- INIT_LIST_HEAD(&ctx->events);
-
- do {
- result = idr_pre_get(&ctx_id_table, GFP_KERNEL);
- if (!result)
- goto error;
-
- mutex_lock(&ctx_id_mutex);
- result = idr_get_new(&ctx_id_table, ctx, &ctx->id);
- mutex_unlock(&ctx_id_mutex);
- } while (result == -EAGAIN);
-
- if (result)
- goto error;
-
- list_add_tail(&ctx->file_list, &file->ctxs);
- return ctx;
-
-error:
- kfree(ctx);
- return NULL;
-}
-
-static void ib_ucm_event_req_get(struct ib_ucm_req_event_resp *ureq,
- struct ib_cm_req_event_param *kreq)
-{
- ureq->remote_ca_guid = kreq->remote_ca_guid;
- ureq->remote_qkey = kreq->remote_qkey;
- ureq->remote_qpn = kreq->remote_qpn;
- ureq->qp_type = kreq->qp_type;
- ureq->starting_psn = kreq->starting_psn;
- ureq->responder_resources = kreq->responder_resources;
- ureq->initiator_depth = kreq->initiator_depth;
- ureq->local_cm_response_timeout = kreq->local_cm_response_timeout;
- ureq->flow_control = kreq->flow_control;
- ureq->remote_cm_response_timeout = kreq->remote_cm_response_timeout;
- ureq->retry_count = kreq->retry_count;
- ureq->rnr_retry_count = kreq->rnr_retry_count;
- ureq->srq = kreq->srq;
- ureq->port = kreq->port;
-
- ib_copy_path_rec_to_user(&ureq->primary_path, kreq->primary_path);
- if (kreq->alternate_path)
- ib_copy_path_rec_to_user(&ureq->alternate_path,
- kreq->alternate_path);
-}
-
-static void ib_ucm_event_rep_get(struct ib_ucm_rep_event_resp *urep,
- struct ib_cm_rep_event_param *krep)
-{
- urep->remote_ca_guid = krep->remote_ca_guid;
- urep->remote_qkey = krep->remote_qkey;
- urep->remote_qpn = krep->remote_qpn;
- urep->starting_psn = krep->starting_psn;
- urep->responder_resources = krep->responder_resources;
- urep->initiator_depth = krep->initiator_depth;
- urep->target_ack_delay = krep->target_ack_delay;
- urep->failover_accepted = krep->failover_accepted;
- urep->flow_control = krep->flow_control;
- urep->rnr_retry_count = krep->rnr_retry_count;
- urep->srq = krep->srq;
-}
-
-static void ib_ucm_event_sidr_rep_get(struct ib_ucm_sidr_rep_event_resp *urep,
- struct ib_cm_sidr_rep_event_param *krep)
-{
- urep->status = krep->status;
- urep->qkey = krep->qkey;
- urep->qpn = krep->qpn;
-};
-
-static int ib_ucm_event_process(struct ib_cm_event *evt,
- struct ib_ucm_event *uvt)
-{
- void *info = NULL;
-
- switch (evt->event) {
- case IB_CM_REQ_RECEIVED:
- ib_ucm_event_req_get(&uvt->resp.u.req_resp,
- &evt->param.req_rcvd);
- uvt->data_len = IB_CM_REQ_PRIVATE_DATA_SIZE;
- uvt->resp.present = IB_UCM_PRES_PRIMARY;
- uvt->resp.present |= (evt->param.req_rcvd.alternate_path ?
- IB_UCM_PRES_ALTERNATE : 0);
- break;
- case IB_CM_REP_RECEIVED:
- ib_ucm_event_rep_get(&uvt->resp.u.rep_resp,
- &evt->param.rep_rcvd);
- uvt->data_len = IB_CM_REP_PRIVATE_DATA_SIZE;
- break;
- case IB_CM_RTU_RECEIVED:
- uvt->data_len = IB_CM_RTU_PRIVATE_DATA_SIZE;
- uvt->resp.u.send_status = evt->param.send_status;
- break;
- case IB_CM_DREQ_RECEIVED:
- uvt->data_len = IB_CM_DREQ_PRIVATE_DATA_SIZE;
- uvt->resp.u.send_status = evt->param.send_status;
- break;
- case IB_CM_DREP_RECEIVED:
- uvt->data_len = IB_CM_DREP_PRIVATE_DATA_SIZE;
- uvt->resp.u.send_status = evt->param.send_status;
- break;
- case IB_CM_MRA_RECEIVED:
- uvt->resp.u.mra_resp.timeout =
- evt->param.mra_rcvd.service_timeout;
- uvt->data_len = IB_CM_MRA_PRIVATE_DATA_SIZE;
- break;
- case IB_CM_REJ_RECEIVED:
- uvt->resp.u.rej_resp.reason = evt->param.rej_rcvd.reason;
- uvt->data_len = IB_CM_REJ_PRIVATE_DATA_SIZE;
- uvt->info_len = evt->param.rej_rcvd.ari_length;
- info = evt->param.rej_rcvd.ari;
- break;
- case IB_CM_LAP_RECEIVED:
- ib_copy_path_rec_to_user(&uvt->resp.u.lap_resp.path,
- evt->param.lap_rcvd.alternate_path);
- uvt->data_len = IB_CM_LAP_PRIVATE_DATA_SIZE;
- uvt->resp.present = IB_UCM_PRES_ALTERNATE;
- break;
- case IB_CM_APR_RECEIVED:
- uvt->resp.u.apr_resp.status = evt->param.apr_rcvd.ap_status;
- uvt->data_len = IB_CM_APR_PRIVATE_DATA_SIZE;
- uvt->info_len = evt->param.apr_rcvd.info_len;
- info = evt->param.apr_rcvd.apr_info;
- break;
- case IB_CM_SIDR_REQ_RECEIVED:
- uvt->resp.u.sidr_req_resp.pkey =
- evt->param.sidr_req_rcvd.pkey;
- uvt->resp.u.sidr_req_resp.port =
- evt->param.sidr_req_rcvd.port;
- uvt->data_len = IB_CM_SIDR_REQ_PRIVATE_DATA_SIZE;
- break;
- case IB_CM_SIDR_REP_RECEIVED:
- ib_ucm_event_sidr_rep_get(&uvt->resp.u.sidr_rep_resp,
- &evt->param.sidr_rep_rcvd);
- uvt->data_len = IB_CM_SIDR_REP_PRIVATE_DATA_SIZE;
- uvt->info_len = evt->param.sidr_rep_rcvd.info_len;
- info = evt->param.sidr_rep_rcvd.info;
- break;
- default:
- uvt->resp.u.send_status = evt->param.send_status;
- break;
- }
-
- if (uvt->data_len) {
- uvt->data = kmemdup(evt->private_data, uvt->data_len, GFP_KERNEL);
- if (!uvt->data)
- goto err1;
-
- uvt->resp.present |= IB_UCM_PRES_DATA;
- }
-
- if (uvt->info_len) {
- uvt->info = kmemdup(info, uvt->info_len, GFP_KERNEL);
- if (!uvt->info)
- goto err2;
-
- uvt->resp.present |= IB_UCM_PRES_INFO;
- }
- return 0;
-
-err2:
- kfree(uvt->data);
-err1:
- return -ENOMEM;
-}
-
-static int ib_ucm_event_handler(struct ib_cm_id *cm_id,
- struct ib_cm_event *event)
-{
- struct ib_ucm_event *uevent;
- struct ib_ucm_context *ctx;
- int result = 0;
-
- ctx = cm_id->context;
-
- uevent = kzalloc(sizeof *uevent, GFP_KERNEL);
- if (!uevent)
- goto err1;
-
- uevent->ctx = ctx;
- uevent->cm_id = cm_id;
- uevent->resp.uid = ctx->uid;
- uevent->resp.id = ctx->id;
- uevent->resp.event = event->event;
-
- result = ib_ucm_event_process(event, uevent);
- if (result)
- goto err2;
-
- mutex_lock(&ctx->file->file_mutex);
- list_add_tail(&uevent->file_list, &ctx->file->events);
- list_add_tail(&uevent->ctx_list, &ctx->events);
- wake_up_interruptible(&ctx->file->poll_wait);
- mutex_unlock(&ctx->file->file_mutex);
- return 0;
-
-err2:
- kfree(uevent);
-err1:
- /* Destroy new cm_id's */
- return ib_ucm_new_cm_id(event->event);
-}
-
-static ssize_t ib_ucm_event(struct ib_ucm_file *file,
- const char __user *inbuf,
- int in_len, int out_len)
-{
- struct ib_ucm_context *ctx;
- struct ib_ucm_event_get cmd;
- struct ib_ucm_event *uevent;
- int result = 0;
-
- if (out_len < sizeof(struct ib_ucm_event_resp))
- return -ENOSPC;
-
- if (copy_from_user(&cmd, inbuf, sizeof(cmd)))
- return -EFAULT;
-
- mutex_lock(&file->file_mutex);
- while (list_empty(&file->events)) {
- mutex_unlock(&file->file_mutex);
-
- if (file->filp->f_flags & O_NONBLOCK)
- return -EAGAIN;
-
- if (wait_event_interruptible(file->poll_wait,
- !list_empty(&file->events)))
- return -ERESTARTSYS;
-
- mutex_lock(&file->file_mutex);
- }
-
- uevent = list_entry(file->events.next, struct ib_ucm_event, file_list);
-
- if (ib_ucm_new_cm_id(uevent->resp.event)) {
- ctx = ib_ucm_ctx_alloc(file);
- if (!ctx) {
- result = -ENOMEM;
- goto done;
- }
-
- ctx->cm_id = uevent->cm_id;
- ctx->cm_id->context = ctx;
- uevent->resp.id = ctx->id;
- }
-
- if (copy_to_user((void __user *)(unsigned long)cmd.response,
- &uevent->resp, sizeof(uevent->resp))) {
- result = -EFAULT;
- goto done;
- }
-
- if (uevent->data) {
- if (cmd.data_len < uevent->data_len) {
- result = -ENOMEM;
- goto done;
- }
- if (copy_to_user((void __user *)(unsigned long)cmd.data,
- uevent->data, uevent->data_len)) {
- result = -EFAULT;
- goto done;
- }
- }
-
- if (uevent->info) {
- if (cmd.info_len < uevent->info_len) {
- result = -ENOMEM;
- goto done;
- }
- if (copy_to_user((void __user *)(unsigned long)cmd.info,
- uevent->info, uevent->info_len)) {
- result = -EFAULT;
- goto done;
- }
- }
-
- list_del(&uevent->file_list);
- list_del(&uevent->ctx_list);
- uevent->ctx->events_reported++;
-
- kfree(uevent->data);
- kfree(uevent->info);
- kfree(uevent);
-done:
- mutex_unlock(&file->file_mutex);
- return result;
-}
-
-static ssize_t ib_ucm_create_id(struct ib_ucm_file *file,
- const char __user *inbuf,
- int in_len, int out_len)
-{
- struct ib_ucm_create_id cmd;
- struct ib_ucm_create_id_resp resp;
- struct ib_ucm_context *ctx;
- int result;
-
- if (out_len < sizeof(resp))
- return -ENOSPC;
-
- if (copy_from_user(&cmd, inbuf, sizeof(cmd)))
- return -EFAULT;
-
- mutex_lock(&file->file_mutex);
- ctx = ib_ucm_ctx_alloc(file);
- mutex_unlock(&file->file_mutex);
- if (!ctx)
- return -ENOMEM;
-
- ctx->uid = cmd.uid;
- ctx->cm_id = ib_create_cm_id(file->device->ib_dev,
- ib_ucm_event_handler, ctx);
- if (IS_ERR(ctx->cm_id)) {
- result = PTR_ERR(ctx->cm_id);
- goto err1;
- }
-
- resp.id = ctx->id;
- if (copy_to_user((void __user *)(unsigned long)cmd.response,
- &resp, sizeof(resp))) {
- result = -EFAULT;
- goto err2;
- }
- return 0;
-
-err2:
- ib_destroy_cm_id(ctx->cm_id);
-err1:
- mutex_lock(&ctx_id_mutex);
- idr_remove(&ctx_id_table, ctx->id);
- mutex_unlock(&ctx_id_mutex);
- kfree(ctx);
- return result;
-}
-
-static ssize_t ib_ucm_destroy_id(struct ib_ucm_file *file,
- const char __user *inbuf,
- int in_len, int out_len)
-{
- struct ib_ucm_destroy_id cmd;
- struct ib_ucm_destroy_id_resp resp;
- struct ib_ucm_context *ctx;
- int result = 0;
-
- if (out_len < sizeof(resp))
- return -ENOSPC;
-
- if (copy_from_user(&cmd, inbuf, sizeof(cmd)))
- return -EFAULT;
-
- mutex_lock(&ctx_id_mutex);
- ctx = idr_find(&ctx_id_table, cmd.id);
- if (!ctx)
- ctx = ERR_PTR(-ENOENT);
- else if (ctx->file != file)
- ctx = ERR_PTR(-EINVAL);
- else
- idr_remove(&ctx_id_table, ctx->id);
- mutex_unlock(&ctx_id_mutex);
-
- if (IS_ERR(ctx))
- return PTR_ERR(ctx);
-
- ib_ucm_ctx_put(ctx);
- wait_for_completion(&ctx->comp);
-
- /* No new events will be generated after destroying the cm_id. */
- ib_destroy_cm_id(ctx->cm_id);
- /* Cleanup events not yet reported to the user. */
- ib_ucm_cleanup_events(ctx);
-
- resp.events_reported = ctx->events_reported;
- if (copy_to_user((void __user *)(unsigned long)cmd.response,
- &resp, sizeof(resp)))
- result = -EFAULT;
-
- kfree(ctx);
- return result;
-}
-
-static ssize_t ib_ucm_attr_id(struct ib_ucm_file *file,
- const char __user *inbuf,
- int in_len, int out_len)
-{
- struct ib_ucm_attr_id_resp resp;
- struct ib_ucm_attr_id cmd;
- struct ib_ucm_context *ctx;
- int result = 0;
-
- if (out_len < sizeof(resp))
- return -ENOSPC;
-
- if (copy_from_user(&cmd, inbuf, sizeof(cmd)))
- return -EFAULT;
-
- ctx = ib_ucm_ctx_get(file, cmd.id);
- if (IS_ERR(ctx))
- return PTR_ERR(ctx);
-
- resp.service_id = ctx->cm_id->service_id;
- resp.service_mask = ctx->cm_id->service_mask;
- resp.local_id = ctx->cm_id->local_id;
- resp.remote_id = ctx->cm_id->remote_id;
-
- if (copy_to_user((void __user *)(unsigned long)cmd.response,
- &resp, sizeof(resp)))
- result = -EFAULT;
-
- ib_ucm_ctx_put(ctx);
- return result;
-}
-
-static ssize_t ib_ucm_init_qp_attr(struct ib_ucm_file *file,
- const char __user *inbuf,
- int in_len, int out_len)
-{
- struct ib_uverbs_qp_attr resp;
- struct ib_ucm_init_qp_attr cmd;
- struct ib_ucm_context *ctx;
- struct ib_qp_attr qp_attr;
- int result = 0;
-
- if (out_len < sizeof(resp))
- return -ENOSPC;
-
- if (copy_from_user(&cmd, inbuf, sizeof(cmd)))
- return -EFAULT;
-
- ctx = ib_ucm_ctx_get(file, cmd.id);
- if (IS_ERR(ctx))
- return PTR_ERR(ctx);
-
- resp.qp_attr_mask = 0;
- memset(&qp_attr, 0, sizeof qp_attr);
- qp_attr.qp_state = cmd.qp_state;
- result = ib_cm_init_qp_attr(ctx->cm_id, &qp_attr, &resp.qp_attr_mask);
- if (result)
- goto out;
-
- ib_copy_qp_attr_to_user(&resp, &qp_attr);
-
- if (copy_to_user((void __user *)(unsigned long)cmd.response,
- &resp, sizeof(resp)))
- result = -EFAULT;
-
-out:
- ib_ucm_ctx_put(ctx);
- return result;
-}
-
-static int ucm_validate_listen(__be64 service_id, __be64 service_mask)
-{
- service_id &= service_mask;
-
- if (((service_id & IB_CMA_SERVICE_ID_MASK) == IB_CMA_SERVICE_ID) ||
- ((service_id & IB_SDP_SERVICE_ID_MASK) == IB_SDP_SERVICE_ID))
- return -EINVAL;
-
- return 0;
-}
-
-static ssize_t ib_ucm_listen(struct ib_ucm_file *file,
- const char __user *inbuf,
- int in_len, int out_len)
-{
- struct ib_ucm_listen cmd;
- struct ib_ucm_context *ctx;
- int result;
-
- if (copy_from_user(&cmd, inbuf, sizeof(cmd)))
- return -EFAULT;
-
- ctx = ib_ucm_ctx_get(file, cmd.id);
- if (IS_ERR(ctx))
- return PTR_ERR(ctx);
-
- result = ucm_validate_listen(cmd.service_id, cmd.service_mask);
- if (result)
- goto out;
-
- result = ib_cm_listen(ctx->cm_id, cmd.service_id, cmd.service_mask,
- NULL);
-out:
- ib_ucm_ctx_put(ctx);
- return result;
-}
-
-static ssize_t ib_ucm_notify(struct ib_ucm_file *file,
- const char __user *inbuf,
- int in_len, int out_len)
-{
- struct ib_ucm_notify cmd;
- struct ib_ucm_context *ctx;
- int result;
-
- if (copy_from_user(&cmd, inbuf, sizeof(cmd)))
- return -EFAULT;
-
- ctx = ib_ucm_ctx_get(file, cmd.id);
- if (IS_ERR(ctx))
- return PTR_ERR(ctx);
-
- result = ib_cm_notify(ctx->cm_id, (enum ib_event_type) cmd.event);
- ib_ucm_ctx_put(ctx);
- return result;
-}
-
-static int ib_ucm_alloc_data(const void **dest, u64 src, u32 len)
-{
- void *data;
-
- *dest = NULL;
-
- if (!len)
- return 0;
-
- data = kmalloc(len, GFP_KERNEL);
- if (!data)
- return -ENOMEM;
-
- if (copy_from_user(data, (void __user *)(unsigned long)src, len)) {
- kfree(data);
- return -EFAULT;
- }
-
- *dest = data;
- return 0;
-}
-
-static int ib_ucm_path_get(struct ib_sa_path_rec **path, u64 src)
-{
- struct ib_user_path_rec upath;
- struct ib_sa_path_rec *sa_path;
-
- *path = NULL;
-
- if (!src)
- return 0;
-
- sa_path = kmalloc(sizeof(*sa_path), GFP_KERNEL);
- if (!sa_path)
- return -ENOMEM;
-
- if (copy_from_user(&upath, (void __user *)(unsigned long)src,
- sizeof(upath))) {
-
- kfree(sa_path);
- return -EFAULT;
- }
-
- ib_copy_path_rec_from_user(sa_path, &upath);
- *path = sa_path;
- return 0;
-}
-
-static ssize_t ib_ucm_send_req(struct ib_ucm_file *file,
- const char __user *inbuf,
- int in_len, int out_len)
-{
- struct ib_cm_req_param param;
- struct ib_ucm_context *ctx;
- struct ib_ucm_req cmd;
- int result;
-
- param.private_data = NULL;
- param.primary_path = NULL;
- param.alternate_path = NULL;
-
- if (copy_from_user(&cmd, inbuf, sizeof(cmd)))
- return -EFAULT;
-
- result = ib_ucm_alloc_data(&param.private_data, cmd.data, cmd.len);
- if (result)
- goto done;
-
- result = ib_ucm_path_get(&param.primary_path, cmd.primary_path);
- if (result)
- goto done;
-
- result = ib_ucm_path_get(&param.alternate_path, cmd.alternate_path);
- if (result)
- goto done;
-
- param.private_data_len = cmd.len;
- param.service_id = cmd.sid;
- param.qp_num = cmd.qpn;
- param.qp_type = cmd.qp_type;
- param.starting_psn = cmd.psn;
- param.peer_to_peer = cmd.peer_to_peer;
- param.responder_resources = cmd.responder_resources;
- param.initiator_depth = cmd.initiator_depth;
- param.remote_cm_response_timeout = cmd.remote_cm_response_timeout;
- param.flow_control = cmd.flow_control;
- param.local_cm_response_timeout = cmd.local_cm_response_timeout;
- param.retry_count = cmd.retry_count;
- param.rnr_retry_count = cmd.rnr_retry_count;
- param.max_cm_retries = cmd.max_cm_retries;
- param.srq = cmd.srq;
-
- ctx = ib_ucm_ctx_get(file, cmd.id);
- if (!IS_ERR(ctx)) {
- result = ib_send_cm_req(ctx->cm_id, &param);
- ib_ucm_ctx_put(ctx);
- } else
- result = PTR_ERR(ctx);
-
-done:
- kfree(param.private_data);
- kfree(param.primary_path);
- kfree(param.alternate_path);
- return result;
-}
-
-static ssize_t ib_ucm_send_rep(struct ib_ucm_file *file,
- const char __user *inbuf,
- int in_len, int out_len)
-{
- struct ib_cm_rep_param param;
- struct ib_ucm_context *ctx;
- struct ib_ucm_rep cmd;
- int result;
-
- param.private_data = NULL;
-
- if (copy_from_user(&cmd, inbuf, sizeof(cmd)))
- return -EFAULT;
-
- result = ib_ucm_alloc_data(&param.private_data, cmd.data, cmd.len);
- if (result)
- return result;
-
- param.qp_num = cmd.qpn;
- param.starting_psn = cmd.psn;
- param.private_data_len = cmd.len;
- param.responder_resources = cmd.responder_resources;
- param.initiator_depth = cmd.initiator_depth;
- param.failover_accepted = cmd.failover_accepted;
- param.flow_control = cmd.flow_control;
- param.rnr_retry_count = cmd.rnr_retry_count;
- param.srq = cmd.srq;
-
- ctx = ib_ucm_ctx_get(file, cmd.id);
- if (!IS_ERR(ctx)) {
- ctx->uid = cmd.uid;
- result = ib_send_cm_rep(ctx->cm_id, &param);
- ib_ucm_ctx_put(ctx);
- } else
- result = PTR_ERR(ctx);
-
- kfree(param.private_data);
- return result;
-}
-
-static ssize_t ib_ucm_send_private_data(struct ib_ucm_file *file,
- const char __user *inbuf, int in_len,
- int (*func)(struct ib_cm_id *cm_id,
- const void *private_data,
- u8 private_data_len))
-{
- struct ib_ucm_private_data cmd;
- struct ib_ucm_context *ctx;
- const void *private_data = NULL;
- int result;
-
- if (copy_from_user(&cmd, inbuf, sizeof(cmd)))
- return -EFAULT;
-
- result = ib_ucm_alloc_data(&private_data, cmd.data, cmd.len);
- if (result)
- return result;
-
- ctx = ib_ucm_ctx_get(file, cmd.id);
- if (!IS_ERR(ctx)) {
- result = func(ctx->cm_id, private_data, cmd.len);
- ib_ucm_ctx_put(ctx);
- } else
- result = PTR_ERR(ctx);
-
- kfree(private_data);
- return result;
-}
-
-static ssize_t ib_ucm_send_rtu(struct ib_ucm_file *file,
- const char __user *inbuf,
- int in_len, int out_len)
-{
- return ib_ucm_send_private_data(file, inbuf, in_len, ib_send_cm_rtu);
-}
-
-static ssize_t ib_ucm_send_dreq(struct ib_ucm_file *file,
- const char __user *inbuf,
- int in_len, int out_len)
-{
- return ib_ucm_send_private_data(file, inbuf, in_len, ib_send_cm_dreq);
-}
-
-static ssize_t ib_ucm_send_drep(struct ib_ucm_file *file,
- const char __user *inbuf,
- int in_len, int out_len)
-{
- return ib_ucm_send_private_data(file, inbuf, in_len, ib_send_cm_drep);
-}
-
-static ssize_t ib_ucm_send_info(struct ib_ucm_file *file,
- const char __user *inbuf, int in_len,
- int (*func)(struct ib_cm_id *cm_id,
- int status,
- const void *info,
- u8 info_len,
- const void *data,
- u8 data_len))
-{
- struct ib_ucm_context *ctx;
- struct ib_ucm_info cmd;
- const void *data = NULL;
- const void *info = NULL;
- int result;
-
- if (copy_from_user(&cmd, inbuf, sizeof(cmd)))
- return -EFAULT;
-
- result = ib_ucm_alloc_data(&data, cmd.data, cmd.data_len);
- if (result)
- goto done;
-
- result = ib_ucm_alloc_data(&info, cmd.info, cmd.info_len);
- if (result)
- goto done;
-
- ctx = ib_ucm_ctx_get(file, cmd.id);
- if (!IS_ERR(ctx)) {
- result = func(ctx->cm_id, cmd.status, info, cmd.info_len,
- data, cmd.data_len);
- ib_ucm_ctx_put(ctx);
- } else
- result = PTR_ERR(ctx);
-
-done:
- kfree(data);
- kfree(info);
- return result;
-}
-
-static ssize_t ib_ucm_send_rej(struct ib_ucm_file *file,
- const char __user *inbuf,
- int in_len, int out_len)
-{
- return ib_ucm_send_info(file, inbuf, in_len, (void *)ib_send_cm_rej);
-}
-
-static ssize_t ib_ucm_send_apr(struct ib_ucm_file *file,
- const char __user *inbuf,
- int in_len, int out_len)
-{
- return ib_ucm_send_info(file, inbuf, in_len, (void *)ib_send_cm_apr);
-}
-
-static ssize_t ib_ucm_send_mra(struct ib_ucm_file *file,
- const char __user *inbuf,
- int in_len, int out_len)
-{
- struct ib_ucm_context *ctx;
- struct ib_ucm_mra cmd;
- const void *data = NULL;
- int result;
-
- if (copy_from_user(&cmd, inbuf, sizeof(cmd)))
- return -EFAULT;
-
- result = ib_ucm_alloc_data(&data, cmd.data, cmd.len);
- if (result)
- return result;
-
- ctx = ib_ucm_ctx_get(file, cmd.id);
- if (!IS_ERR(ctx)) {
- result = ib_send_cm_mra(ctx->cm_id, cmd.timeout, data, cmd.len);
- ib_ucm_ctx_put(ctx);
- } else
- result = PTR_ERR(ctx);
-
- kfree(data);
- return result;
-}
-
-static ssize_t ib_ucm_send_lap(struct ib_ucm_file *file,
- const char __user *inbuf,
- int in_len, int out_len)
-{
- struct ib_ucm_context *ctx;
- struct ib_sa_path_rec *path = NULL;
- struct ib_ucm_lap cmd;
- const void *data = NULL;
- int result;
-
- if (copy_from_user(&cmd, inbuf, sizeof(cmd)))
- return -EFAULT;
-
- result = ib_ucm_alloc_data(&data, cmd.data, cmd.len);
- if (result)
- goto done;
-
- result = ib_ucm_path_get(&path, cmd.path);
- if (result)
- goto done;
-
- ctx = ib_ucm_ctx_get(file, cmd.id);
- if (!IS_ERR(ctx)) {
- result = ib_send_cm_lap(ctx->cm_id, path, data, cmd.len);
- ib_ucm_ctx_put(ctx);
- } else
- result = PTR_ERR(ctx);
-
-done:
- kfree(data);
- kfree(path);
- return result;
-}
-
-static ssize_t ib_ucm_send_sidr_req(struct ib_ucm_file *file,
- const char __user *inbuf,
- int in_len, int out_len)
-{
- struct ib_cm_sidr_req_param param;
- struct ib_ucm_context *ctx;
- struct ib_ucm_sidr_req cmd;
- int result;
-
- param.private_data = NULL;
- param.path = NULL;
-
- if (copy_from_user(&cmd, inbuf, sizeof(cmd)))
- return -EFAULT;
-
- result = ib_ucm_alloc_data(&param.private_data, cmd.data, cmd.len);
- if (result)
- goto done;
-
- result = ib_ucm_path_get(&param.path, cmd.path);
- if (result)
- goto done;
-
- param.private_data_len = cmd.len;
- param.service_id = cmd.sid;
- param.timeout_ms = cmd.timeout;
- param.max_cm_retries = cmd.max_cm_retries;
-
- ctx = ib_ucm_ctx_get(file, cmd.id);
- if (!IS_ERR(ctx)) {
- result = ib_send_cm_sidr_req(ctx->cm_id, &param);
- ib_ucm_ctx_put(ctx);
- } else
- result = PTR_ERR(ctx);
-
-done:
- kfree(param.private_data);
- kfree(param.path);
- return result;
-}
-
-static ssize_t ib_ucm_send_sidr_rep(struct ib_ucm_file *file,
- const char __user *inbuf,
- int in_len, int out_len)
-{
- struct ib_cm_sidr_rep_param param;
- struct ib_ucm_sidr_rep cmd;
- struct ib_ucm_context *ctx;
- int result;
-
- param.info = NULL;
-
- if (copy_from_user(&cmd, inbuf, sizeof(cmd)))
- return -EFAULT;
-
- result = ib_ucm_alloc_data(&param.private_data,
- cmd.data, cmd.data_len);
- if (result)
- goto done;
-
- result = ib_ucm_alloc_data(&param.info, cmd.info, cmd.info_len);
- if (result)
- goto done;
-
- param.qp_num = cmd.qpn;
- param.qkey = cmd.qkey;
- param.status = cmd.status;
- param.info_length = cmd.info_len;
- param.private_data_len = cmd.data_len;
-
- ctx = ib_ucm_ctx_get(file, cmd.id);
- if (!IS_ERR(ctx)) {
- result = ib_send_cm_sidr_rep(ctx->cm_id, &param);
- ib_ucm_ctx_put(ctx);
- } else
- result = PTR_ERR(ctx);
-
-done:
- kfree(param.private_data);
- kfree(param.info);
- return result;
-}
-
-static ssize_t (*ucm_cmd_table[])(struct ib_ucm_file *file,
- const char __user *inbuf,
- int in_len, int out_len) = {
- [IB_USER_CM_CMD_CREATE_ID] = ib_ucm_create_id,
- [IB_USER_CM_CMD_DESTROY_ID] = ib_ucm_destroy_id,
- [IB_USER_CM_CMD_ATTR_ID] = ib_ucm_attr_id,
- [IB_USER_CM_CMD_LISTEN] = ib_ucm_listen,
- [IB_USER_CM_CMD_NOTIFY] = ib_ucm_notify,
- [IB_USER_CM_CMD_SEND_REQ] = ib_ucm_send_req,
- [IB_USER_CM_CMD_SEND_REP] = ib_ucm_send_rep,
- [IB_USER_CM_CMD_SEND_RTU] = ib_ucm_send_rtu,
- [IB_USER_CM_CMD_SEND_DREQ] = ib_ucm_send_dreq,
- [IB_USER_CM_CMD_SEND_DREP] = ib_ucm_send_drep,
- [IB_USER_CM_CMD_SEND_REJ] = ib_ucm_send_rej,
- [IB_USER_CM_CMD_SEND_MRA] = ib_ucm_send_mra,
- [IB_USER_CM_CMD_SEND_LAP] = ib_ucm_send_lap,
- [IB_USER_CM_CMD_SEND_APR] = ib_ucm_send_apr,
- [IB_USER_CM_CMD_SEND_SIDR_REQ] = ib_ucm_send_sidr_req,
- [IB_USER_CM_CMD_SEND_SIDR_REP] = ib_ucm_send_sidr_rep,
- [IB_USER_CM_CMD_EVENT] = ib_ucm_event,
- [IB_USER_CM_CMD_INIT_QP_ATTR] = ib_ucm_init_qp_attr,
-};
-
-static ssize_t ib_ucm_write(struct file *filp, const char __user *buf,
- size_t len, loff_t *pos)
-{
- struct ib_ucm_file *file = filp->private_data;
- struct ib_ucm_cmd_hdr hdr;
- ssize_t result;
-
- if (len < sizeof(hdr))
- return -EINVAL;
-
- if (copy_from_user(&hdr, buf, sizeof(hdr)))
- return -EFAULT;
-
- if (hdr.cmd >= ARRAY_SIZE(ucm_cmd_table))
- return -EINVAL;
-
- if (hdr.in + sizeof(hdr) > len)
- return -EINVAL;
-
- result = ucm_cmd_table[hdr.cmd](file, buf + sizeof(hdr),
- hdr.in, hdr.out);
- if (!result)
- result = len;
-
- return result;
-}
-
-static unsigned int ib_ucm_poll(struct file *filp,
- struct poll_table_struct *wait)
-{
- struct ib_ucm_file *file = filp->private_data;
- unsigned int mask = 0;
-
- poll_wait(filp, &file->poll_wait, wait);
-
- if (!list_empty(&file->events))
- mask = POLLIN | POLLRDNORM;
-
- return mask;
-}
-
-/*
- * ib_ucm_open() does not need the BKL:
- *
- * - no global state is referred to;
- * - there is no ioctl method to race against;
- * - no further module initialization is required for open to work
- * after the device is registered.
- */
-static int ib_ucm_open(struct inode *inode, struct file *filp)
-{
- struct ib_ucm_file *file;
-
- file = kmalloc(sizeof(*file), GFP_KERNEL);
- if (!file)
- return -ENOMEM;
-
- INIT_LIST_HEAD(&file->events);
- INIT_LIST_HEAD(&file->ctxs);
- init_waitqueue_head(&file->poll_wait);
-
- mutex_init(&file->file_mutex);
-
- filp->private_data = file;
- file->filp = filp;
- file->device = container_of(inode->i_cdev->si_drv1, struct ib_ucm_device, cdev);
-
- return nonseekable_open(inode, filp);
-}
-
-static int ib_ucm_close(struct inode *inode, struct file *filp)
-{
- struct ib_ucm_file *file = filp->private_data;
- struct ib_ucm_context *ctx;
-
- mutex_lock(&file->file_mutex);
- while (!list_empty(&file->ctxs)) {
- ctx = list_entry(file->ctxs.next,
- struct ib_ucm_context, file_list);
- mutex_unlock(&file->file_mutex);
-
- mutex_lock(&ctx_id_mutex);
- idr_remove(&ctx_id_table, ctx->id);
- mutex_unlock(&ctx_id_mutex);
-
- ib_destroy_cm_id(ctx->cm_id);
- ib_ucm_cleanup_events(ctx);
- kfree(ctx);
-
- mutex_lock(&file->file_mutex);
- }
- mutex_unlock(&file->file_mutex);
- kfree(file);
- return 0;
-}
-
-static void ib_ucm_release_dev(struct device *dev)
-{
- struct ib_ucm_device *ucm_dev;
-
- ucm_dev = container_of(dev, struct ib_ucm_device, dev);
- cdev_del(&ucm_dev->cdev);
- if (ucm_dev->devnum < IB_UCM_MAX_DEVICES)
- clear_bit(ucm_dev->devnum, dev_map);
- else
- clear_bit(ucm_dev->devnum - IB_UCM_MAX_DEVICES, dev_map);
- kfree(ucm_dev);
-}
-
-static const struct file_operations ucm_fops = {
- .owner = THIS_MODULE,
- .open = ib_ucm_open,
- .release = ib_ucm_close,
- .write = ib_ucm_write,
- .poll = ib_ucm_poll,
- .llseek = no_llseek,
-};
-
-static ssize_t show_ibdev(struct device *dev, struct device_attribute *attr,
- char *buf)
-{
- struct ib_ucm_device *ucm_dev;
-
- ucm_dev = container_of(dev, struct ib_ucm_device, dev);
- return sprintf(buf, "%s\n", ucm_dev->ib_dev->name);
-}
-static DEVICE_ATTR(ibdev, S_IRUGO, show_ibdev, NULL);
-
-static dev_t overflow_maj;
-static DECLARE_BITMAP(overflow_map, IB_UCM_MAX_DEVICES);
-static int find_overflow_devnum(void)
-{
- int ret;
-
- if (!overflow_maj) {
- ret = alloc_chrdev_region(&overflow_maj, 0, IB_UCM_MAX_DEVICES,
- "infiniband_cm");
- if (ret) {
- printk(KERN_ERR "ucm: couldn't register dynamic device number\n");
- return ret;
- }
- }
-
- ret = find_first_zero_bit(overflow_map, IB_UCM_MAX_DEVICES);
- if (ret >= IB_UCM_MAX_DEVICES)
- return -1;
-
- return ret;
-}
-
-static void ib_ucm_add_one(struct ib_device *device)
-{
- int devnum;
- dev_t base;
- struct ib_ucm_device *ucm_dev;
-
- if (!device->alloc_ucontext ||
- rdma_node_get_transport(device->node_type) != RDMA_TRANSPORT_IB)
- return;
-
- ucm_dev = kzalloc(sizeof *ucm_dev, GFP_KERNEL);
- if (!ucm_dev)
- return;
-
- ucm_dev->ib_dev = device;
-
- devnum = find_first_zero_bit(dev_map, IB_UCM_MAX_DEVICES);
- if (devnum >= IB_UCM_MAX_DEVICES) {
- devnum = find_overflow_devnum();
- if (devnum < 0)
- goto err;
-
- ucm_dev->devnum = devnum + IB_UCM_MAX_DEVICES;
- base = devnum + overflow_maj;
- set_bit(devnum, overflow_map);
- } else {
- ucm_dev->devnum = devnum;
- base = devnum + IB_UCM_BASE_DEV;
- set_bit(devnum, dev_map);
- }
-
- cdev_init(&ucm_dev->cdev, &ucm_fops);
- ucm_dev->cdev.owner = THIS_MODULE;
- kobject_set_name(&ucm_dev->cdev.kobj, "ucm%d", ucm_dev->devnum);
- if (cdev_add(&ucm_dev->cdev, base, 1))
- goto err;
-
- ucm_dev->dev.class = &cm_class;
- ucm_dev->dev.parent = device->dma_device;
- ucm_dev->dev.devt = ucm_dev->cdev.dev;
- ucm_dev->dev.release = ib_ucm_release_dev;
- dev_set_name(&ucm_dev->dev, "ucm%d", ucm_dev->devnum);
- if (device_register(&ucm_dev->dev))
- goto err_cdev;
-
- if (device_create_file(&ucm_dev->dev, &dev_attr_ibdev))
- goto err_dev;
-
- ib_set_client_data(device, &ucm_client, ucm_dev);
- return;
-
-err_dev:
- device_unregister(&ucm_dev->dev);
-err_cdev:
- cdev_del(&ucm_dev->cdev);
- if (ucm_dev->devnum < IB_UCM_MAX_DEVICES)
- clear_bit(devnum, dev_map);
- else
- clear_bit(devnum, overflow_map);
-err:
- kfree(ucm_dev);
- return;
-}
-
-static void ib_ucm_remove_one(struct ib_device *device)
-{
- struct ib_ucm_device *ucm_dev = ib_get_client_data(device, &ucm_client);
-
- if (!ucm_dev)
- return;
-
- device_unregister(&ucm_dev->dev);
-}
-
-static ssize_t show_abi_version(struct class *class, struct class_attribute *attr, char *buf)
-{
- return sprintf(buf, "%d\n", IB_USER_CM_ABI_VERSION);
-}
-
-static CLASS_ATTR(abi_version, S_IRUGO, show_abi_version, NULL);
-
-static int __init ib_ucm_init(void)
-{
- int ret;
-
- ret = register_chrdev_region(IB_UCM_BASE_DEV, IB_UCM_MAX_DEVICES,
- "infiniband_cm");
- if (ret) {
- printk(KERN_ERR "ucm: couldn't register device number\n");
- goto error1;
- }
-
- ret = class_create_file(&cm_class, &class_attr_abi_version);
- if (ret) {
- printk(KERN_ERR "ucm: couldn't create abi_version attribute\n");
- goto error2;
- }
-
- ret = ib_register_client(&ucm_client);
- if (ret) {
- printk(KERN_ERR "ucm: couldn't register client\n");
- goto error3;
- }
- return 0;
-
-error3:
- class_remove_file(&cm_class, &class_attr_abi_version);
-error2:
- unregister_chrdev_region(IB_UCM_BASE_DEV, IB_UCM_MAX_DEVICES);
-error1:
- return ret;
-}
-
-static void __exit ib_ucm_cleanup(void)
-{
- ib_unregister_client(&ucm_client);
- class_remove_file(&cm_class, &class_attr_abi_version);
- unregister_chrdev_region(IB_UCM_BASE_DEV, IB_UCM_MAX_DEVICES);
- if (overflow_maj)
- unregister_chrdev_region(overflow_maj, IB_UCM_MAX_DEVICES);
- idr_destroy(&ctx_id_table);
-}
-
-module_init_order(ib_ucm_init, SI_ORDER_THIRD);
-module_exit(ib_ucm_cleanup);
diff --git a/sys/ofed/drivers/infiniband/core/ucma.c b/sys/ofed/drivers/infiniband/core/ucma.c
deleted file mode 100644
index 90f5926..0000000
--- a/sys/ofed/drivers/infiniband/core/ucma.c
+++ /dev/null
@@ -1,1415 +0,0 @@
-/*
- * Copyright (c) 2005-2006 Intel Corporation. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-#include <linux/completion.h>
-#include <linux/file.h>
-#include <linux/mutex.h>
-#include <linux/poll.h>
-#include <linux/sched.h>
-#include <linux/idr.h>
-#include <linux/in.h>
-#include <linux/in6.h>
-#include <linux/miscdevice.h>
-#include <linux/slab.h>
-#include <linux/module.h>
-
-#include <sys/filio.h>
-
-#include <rdma/rdma_user_cm.h>
-#include <rdma/ib_marshall.h>
-#include <rdma/rdma_cm.h>
-#include <rdma/rdma_cm_ib.h>
-
-MODULE_AUTHOR("Sean Hefty");
-MODULE_DESCRIPTION("RDMA Userspace Connection Manager Access");
-MODULE_LICENSE("Dual BSD/GPL");
-
-static unsigned int max_backlog = 1024;
-
-struct ucma_file {
- struct mutex mut;
- struct file *filp;
- struct list_head ctx_list;
- struct list_head event_list;
- wait_queue_head_t poll_wait;
-};
-
-struct ucma_context {
- int id;
- struct completion comp;
- atomic_t ref;
- int events_reported;
- int backlog;
-
- struct ucma_file *file;
- struct rdma_cm_id *cm_id;
- u64 uid;
-
- struct list_head list;
- struct list_head mc_list;
-};
-
-struct ucma_multicast {
- struct ucma_context *ctx;
- int id;
- int events_reported;
-
- u64 uid;
- struct list_head list;
- struct sockaddr_storage addr;
-};
-
-struct ucma_event {
- struct ucma_context *ctx;
- struct ucma_multicast *mc;
- struct list_head list;
- struct rdma_cm_id *cm_id;
- struct rdma_ucm_event_resp resp;
-};
-
-static DEFINE_MUTEX(mut);
-static DEFINE_IDR(ctx_idr);
-static DEFINE_IDR(multicast_idr);
-
-static inline struct ucma_context *_ucma_find_context(int id,
- struct ucma_file *file)
-{
- struct ucma_context *ctx;
-
- ctx = idr_find(&ctx_idr, id);
- if (!ctx)
- ctx = ERR_PTR(-ENOENT);
- else if (ctx->file != file)
- ctx = ERR_PTR(-EINVAL);
- return ctx;
-}
-
-static struct ucma_context *ucma_get_ctx(struct ucma_file *file, int id)
-{
- struct ucma_context *ctx;
-
- mutex_lock(&mut);
- ctx = _ucma_find_context(id, file);
- if (!IS_ERR(ctx))
- atomic_inc(&ctx->ref);
- mutex_unlock(&mut);
- return ctx;
-}
-
-static void ucma_put_ctx(struct ucma_context *ctx)
-{
- if (atomic_dec_and_test(&ctx->ref))
- complete(&ctx->comp);
-}
-
-static struct ucma_context *ucma_alloc_ctx(struct ucma_file *file)
-{
- struct ucma_context *ctx;
- int ret;
-
- ctx = kzalloc(sizeof(*ctx), GFP_KERNEL);
- if (!ctx)
- return NULL;
-
- atomic_set(&ctx->ref, 1);
- init_completion(&ctx->comp);
- INIT_LIST_HEAD(&ctx->mc_list);
- ctx->file = file;
-
- do {
- ret = idr_pre_get(&ctx_idr, GFP_KERNEL);
- if (!ret)
- goto error;
-
- mutex_lock(&mut);
- ret = idr_get_new(&ctx_idr, ctx, &ctx->id);
- mutex_unlock(&mut);
- } while (ret == -EAGAIN);
-
- if (ret)
- goto error;
-
- list_add_tail(&ctx->list, &file->ctx_list);
- return ctx;
-
-error:
- kfree(ctx);
- return NULL;
-}
-
-static struct ucma_multicast* ucma_alloc_multicast(struct ucma_context *ctx)
-{
- struct ucma_multicast *mc;
- int ret;
-
- mc = kzalloc(sizeof(*mc), GFP_KERNEL);
- if (!mc)
- return NULL;
-
- do {
- ret = idr_pre_get(&multicast_idr, GFP_KERNEL);
- if (!ret)
- goto error;
-
- mutex_lock(&mut);
- ret = idr_get_new(&multicast_idr, mc, &mc->id);
- mutex_unlock(&mut);
- } while (ret == -EAGAIN);
-
- if (ret)
- goto error;
-
- mc->ctx = ctx;
- list_add_tail(&mc->list, &ctx->mc_list);
- return mc;
-
-error:
- kfree(mc);
- return NULL;
-}
-
-static void ucma_copy_conn_event(struct rdma_ucm_conn_param *dst,
- struct rdma_conn_param *src)
-{
- if (src->private_data_len)
- memcpy(dst->private_data, src->private_data,
- src->private_data_len);
- dst->private_data_len = src->private_data_len;
- dst->responder_resources =src->responder_resources;
- dst->initiator_depth = src->initiator_depth;
- dst->flow_control = src->flow_control;
- dst->retry_count = src->retry_count;
- dst->rnr_retry_count = src->rnr_retry_count;
- dst->srq = src->srq;
- dst->qp_num = src->qp_num;
-}
-
-static void ucma_copy_ud_event(struct rdma_ucm_ud_param *dst,
- struct rdma_ud_param *src)
-{
- if (src->private_data_len)
- memcpy(dst->private_data, src->private_data,
- src->private_data_len);
- dst->private_data_len = src->private_data_len;
- ib_copy_ah_attr_to_user(&dst->ah_attr, &src->ah_attr);
- dst->qp_num = src->qp_num;
- dst->qkey = src->qkey;
-}
-
-static void ucma_set_event_context(struct ucma_context *ctx,
- struct rdma_cm_event *event,
- struct ucma_event *uevent)
-{
- uevent->ctx = ctx;
- switch (event->event) {
- case RDMA_CM_EVENT_MULTICAST_JOIN:
- case RDMA_CM_EVENT_MULTICAST_ERROR:
- uevent->mc = (struct ucma_multicast *)
- event->param.ud.private_data;
- uevent->resp.uid = uevent->mc->uid;
- uevent->resp.id = uevent->mc->id;
- break;
- default:
- uevent->resp.uid = ctx->uid;
- uevent->resp.id = ctx->id;
- break;
- }
-}
-
-static int ucma_event_handler(struct rdma_cm_id *cm_id,
- struct rdma_cm_event *event)
-{
- struct ucma_event *uevent;
- struct ucma_context *ctx = cm_id->context;
- int ret = 0;
-
- uevent = kzalloc(sizeof(*uevent), GFP_KERNEL);
- if (!uevent)
- return event->event == RDMA_CM_EVENT_CONNECT_REQUEST;
-
- mutex_lock(&ctx->file->mut);
- uevent->cm_id = cm_id;
- ucma_set_event_context(ctx, event, uevent);
- uevent->resp.event = event->event;
- uevent->resp.status = event->status;
- if (cm_id->qp_type == IB_QPT_UD)
- ucma_copy_ud_event(&uevent->resp.param.ud, &event->param.ud);
- else
- ucma_copy_conn_event(&uevent->resp.param.conn,
- &event->param.conn);
-
- if (event->event == RDMA_CM_EVENT_CONNECT_REQUEST) {
- if (!ctx->backlog) {
- ret = -ENOMEM;
- kfree(uevent);
- goto out;
- }
- ctx->backlog--;
- } else if (!ctx->uid) {
- /*
- * We ignore events for new connections until userspace has set
- * their context. This can only happen if an error occurs on a
- * new connection before the user accepts it. This is okay,
- * since the accept will just fail later.
- */
- kfree(uevent);
- goto out;
- }
-
- list_add_tail(&uevent->list, &ctx->file->event_list);
- wake_up_interruptible(&ctx->file->poll_wait);
-out:
- mutex_unlock(&ctx->file->mut);
- return ret;
-}
-
-static ssize_t ucma_get_event(struct ucma_file *file, const char __user *inbuf,
- int in_len, int out_len)
-{
- struct ucma_context *ctx;
- struct rdma_ucm_get_event cmd;
- struct ucma_event *uevent;
- int ret = 0;
-
- if (out_len < sizeof uevent->resp)
- return -ENOSPC;
-
- if (copy_from_user(&cmd, inbuf, sizeof(cmd)))
- return -EFAULT;
-
- mutex_lock(&file->mut);
- while (list_empty(&file->event_list)) {
- mutex_unlock(&file->mut);
-
- if (file->filp->f_flags & O_NONBLOCK)
- return -EAGAIN;
-
- if (wait_event_interruptible(file->poll_wait,
- !list_empty(&file->event_list)))
- return -ERESTARTSYS;
-
- mutex_lock(&file->mut);
- }
-
- uevent = list_entry(file->event_list.next, struct ucma_event, list);
-
- if (uevent->resp.event == RDMA_CM_EVENT_CONNECT_REQUEST) {
- ctx = ucma_alloc_ctx(file);
- if (!ctx) {
- ret = -ENOMEM;
- goto done;
- }
- uevent->ctx->backlog++;
- ctx->cm_id = uevent->cm_id;
- ctx->cm_id->context = ctx;
- uevent->resp.id = ctx->id;
- ctx->cm_id->ucontext = ctx;
- }
-
- if (copy_to_user((void __user *)(unsigned long)cmd.response,
- &uevent->resp, sizeof uevent->resp)) {
- ret = -EFAULT;
- goto done;
- }
-
- list_del(&uevent->list);
- uevent->ctx->events_reported++;
- if (uevent->mc)
- uevent->mc->events_reported++;
- kfree(uevent);
-done:
- mutex_unlock(&file->mut);
- return ret;
-}
-
-static int ucma_get_qp_type(struct rdma_ucm_create_id *cmd, enum ib_qp_type *qp_type)
-{
- switch (cmd->ps) {
- case RDMA_PS_TCP:
- *qp_type = IB_QPT_RC;
- return 0;
- case RDMA_PS_UDP:
- case RDMA_PS_IPOIB:
- *qp_type = IB_QPT_UD;
- return 0;
- case RDMA_PS_IB:
- *qp_type = cmd->qp_type;
- return 0;
- default:
- return -EINVAL;
- }
-}
-
-static ssize_t ucma_create_id(struct ucma_file *file, const char __user *inbuf,
- int in_len, int out_len)
-{
- struct rdma_ucm_create_id cmd;
- struct rdma_ucm_create_id_resp resp;
- struct ucma_context *ctx;
- enum ib_qp_type qp_type;
- int ret;
-
- if (out_len < sizeof(resp))
- return -ENOSPC;
-
- if (copy_from_user(&cmd, inbuf, sizeof(cmd)))
- return -EFAULT;
-
- ret = ucma_get_qp_type(&cmd, &qp_type);
- if (ret)
- return ret;
-
- mutex_lock(&file->mut);
- ctx = ucma_alloc_ctx(file);
- mutex_unlock(&file->mut);
- if (!ctx)
- return -ENOMEM;
-
- ctx->uid = cmd.uid;
- ctx->cm_id = rdma_create_id(ucma_event_handler, ctx, cmd.ps, qp_type);
- if (IS_ERR(ctx->cm_id)) {
- ret = PTR_ERR(ctx->cm_id);
- goto err1;
- }
- ctx->cm_id->ucontext = ctx;
-
- resp.id = ctx->id;
- if (copy_to_user((void __user *)(unsigned long)cmd.response,
- &resp, sizeof(resp))) {
- ret = -EFAULT;
- goto err2;
- }
- return 0;
-
-err2:
- rdma_destroy_id(ctx->cm_id);
-err1:
- mutex_lock(&mut);
- idr_remove(&ctx_idr, ctx->id);
- mutex_unlock(&mut);
- kfree(ctx);
- return ret;
-}
-
-static void ucma_cleanup_multicast(struct ucma_context *ctx)
-{
- struct ucma_multicast *mc, *tmp;
-
- mutex_lock(&mut);
- list_for_each_entry_safe(mc, tmp, &ctx->mc_list, list) {
- list_del(&mc->list);
- idr_remove(&multicast_idr, mc->id);
- kfree(mc);
- }
- mutex_unlock(&mut);
-}
-
-static void ucma_cleanup_mc_events(struct ucma_multicast *mc)
-{
- struct ucma_event *uevent, *tmp;
-
- list_for_each_entry_safe(uevent, tmp, &mc->ctx->file->event_list, list) {
- if (uevent->mc != mc)
- continue;
-
- list_del(&uevent->list);
- kfree(uevent);
- }
-}
-
-/*
- * We cannot hold file->mut when calling rdma_destroy_id() or we can
- * deadlock. We also acquire file->mut in ucma_event_handler(), and
- * rdma_destroy_id() will wait until all callbacks have completed.
- */
-static int ucma_free_ctx(struct ucma_context *ctx)
-{
- int events_reported;
- struct ucma_event *uevent, *tmp;
- LIST_HEAD(list);
-
- /* No new events will be generated after destroying the id. */
- rdma_destroy_id(ctx->cm_id);
-
- ucma_cleanup_multicast(ctx);
-
- /* Cleanup events not yet reported to the user. */
- mutex_lock(&ctx->file->mut);
- list_for_each_entry_safe(uevent, tmp, &ctx->file->event_list, list) {
- if (uevent->ctx == ctx)
- list_move_tail(&uevent->list, &list);
- }
- list_del(&ctx->list);
- mutex_unlock(&ctx->file->mut);
-
- list_for_each_entry_safe(uevent, tmp, &list, list) {
- list_del(&uevent->list);
- if (uevent->resp.event == RDMA_CM_EVENT_CONNECT_REQUEST)
- rdma_destroy_id(uevent->cm_id);
- kfree(uevent);
- }
-
- events_reported = ctx->events_reported;
- kfree(ctx);
- return events_reported;
-}
-
-static ssize_t ucma_destroy_id(struct ucma_file *file, const char __user *inbuf,
- int in_len, int out_len)
-{
- struct rdma_ucm_destroy_id cmd;
- struct rdma_ucm_destroy_id_resp resp;
- struct ucma_context *ctx;
- int ret = 0;
-
- if (out_len < sizeof(resp))
- return -ENOSPC;
-
- if (copy_from_user(&cmd, inbuf, sizeof(cmd)))
- return -EFAULT;
-
- mutex_lock(&mut);
- ctx = _ucma_find_context(cmd.id, file);
- if (!IS_ERR(ctx))
- idr_remove(&ctx_idr, ctx->id);
- mutex_unlock(&mut);
-
- if (IS_ERR(ctx))
- return PTR_ERR(ctx);
-
- ucma_put_ctx(ctx);
- wait_for_completion(&ctx->comp);
- resp.events_reported = ucma_free_ctx(ctx);
-
- if (copy_to_user((void __user *)(unsigned long)cmd.response,
- &resp, sizeof(resp)))
- ret = -EFAULT;
-
- return ret;
-}
-
-static ssize_t ucma_bind_addr(struct ucma_file *file, const char __user *inbuf,
- int in_len, int out_len)
-{
- struct rdma_ucm_bind_addr cmd;
- struct ucma_context *ctx;
- int ret;
-
- if (copy_from_user(&cmd, inbuf, sizeof(cmd)))
- return -EFAULT;
-
- ctx = ucma_get_ctx(file, cmd.id);
- if (IS_ERR(ctx))
- return PTR_ERR(ctx);
-
- ret = rdma_bind_addr(ctx->cm_id, (struct sockaddr *) &cmd.addr);
- ucma_put_ctx(ctx);
- return ret;
-}
-
-static ssize_t ucma_resolve_addr(struct ucma_file *file,
- const char __user *inbuf,
- int in_len, int out_len)
-{
- struct rdma_ucm_resolve_addr cmd;
- struct ucma_context *ctx;
- int ret;
-
- if (copy_from_user(&cmd, inbuf, sizeof(cmd)))
- return -EFAULT;
-
- ctx = ucma_get_ctx(file, cmd.id);
- if (IS_ERR(ctx))
- return PTR_ERR(ctx);
-
- ret = rdma_resolve_addr(ctx->cm_id, (struct sockaddr *) &cmd.src_addr,
- (struct sockaddr *) &cmd.dst_addr,
- cmd.timeout_ms);
- ucma_put_ctx(ctx);
- return ret;
-}
-
-static ssize_t ucma_resolve_route(struct ucma_file *file,
- const char __user *inbuf,
- int in_len, int out_len)
-{
- struct rdma_ucm_resolve_route cmd;
- struct ucma_context *ctx;
- int ret;
-
- if (copy_from_user(&cmd, inbuf, sizeof(cmd)))
- return -EFAULT;
-
- ctx = ucma_get_ctx(file, cmd.id);
- if (IS_ERR(ctx))
- return PTR_ERR(ctx);
-
- ret = rdma_resolve_route(ctx->cm_id, cmd.timeout_ms);
- ucma_put_ctx(ctx);
- return ret;
-}
-
-static void ucma_copy_ib_route(struct rdma_ucm_query_route_resp *resp,
- struct rdma_route *route)
-{
- struct rdma_dev_addr *dev_addr;
-
- resp->num_paths = route->num_paths;
- switch (route->num_paths) {
- case 0:
- dev_addr = &route->addr.dev_addr;
- rdma_addr_get_dgid(dev_addr,
- (union ib_gid *) &resp->ib_route[0].dgid);
- rdma_addr_get_sgid(dev_addr,
- (union ib_gid *) &resp->ib_route[0].sgid);
- resp->ib_route[0].pkey = cpu_to_be16(ib_addr_get_pkey(dev_addr));
- break;
- case 2:
- ib_copy_path_rec_to_user(&resp->ib_route[1],
- &route->path_rec[1]);
- /* fall through */
- case 1:
- ib_copy_path_rec_to_user(&resp->ib_route[0],
- &route->path_rec[0]);
- break;
- default:
- break;
- }
-}
-
-static void ucma_copy_iboe_route(struct rdma_ucm_query_route_resp *resp,
- struct rdma_route *route)
-{
-
- resp->num_paths = route->num_paths;
- switch (route->num_paths) {
- case 0:
- rdma_ip2gid((struct sockaddr *)&route->addr.dst_addr,
- (union ib_gid *)&resp->ib_route[0].dgid);
- rdma_ip2gid((struct sockaddr *)&route->addr.src_addr,
- (union ib_gid *)&resp->ib_route[0].sgid);
- resp->ib_route[0].pkey = cpu_to_be16(0xffff);
- break;
- case 2:
- ib_copy_path_rec_to_user(&resp->ib_route[1],
- &route->path_rec[1]);
- /* fall through */
- case 1:
- ib_copy_path_rec_to_user(&resp->ib_route[0],
- &route->path_rec[0]);
- break;
- default:
- break;
- }
-}
-
-static void ucma_copy_iw_route(struct rdma_ucm_query_route_resp *resp,
- struct rdma_route *route)
-{
- struct rdma_dev_addr *dev_addr;
-
- dev_addr = &route->addr.dev_addr;
- rdma_addr_get_dgid(dev_addr, (union ib_gid *) &resp->ib_route[0].dgid);
- rdma_addr_get_sgid(dev_addr, (union ib_gid *) &resp->ib_route[0].sgid);
-}
-
-static ssize_t ucma_query_route(struct ucma_file *file,
- const char __user *inbuf,
- int in_len, int out_len)
-{
- struct rdma_ucm_query_route cmd;
- struct rdma_ucm_query_route_resp resp;
- struct ucma_context *ctx;
- struct sockaddr *addr;
- int ret = 0;
-
- if (out_len < sizeof(resp))
- return -ENOSPC;
-
- if (copy_from_user(&cmd, inbuf, sizeof(cmd)))
- return -EFAULT;
-
- ctx = ucma_get_ctx(file, cmd.id);
- if (IS_ERR(ctx))
- return PTR_ERR(ctx);
-
- memset(&resp, 0, sizeof resp);
- addr = (struct sockaddr *) &ctx->cm_id->route.addr.src_addr;
- memcpy(&resp.src_addr, addr, addr->sa_family == AF_INET ?
- sizeof(struct sockaddr_in) :
- sizeof(struct sockaddr_in6));
- addr = (struct sockaddr *) &ctx->cm_id->route.addr.dst_addr;
- memcpy(&resp.dst_addr, addr, addr->sa_family == AF_INET ?
- sizeof(struct sockaddr_in) :
- sizeof(struct sockaddr_in6));
- if (!ctx->cm_id->device)
- goto out;
-
- resp.node_guid = (__force __u64) ctx->cm_id->device->node_guid;
- resp.port_num = ctx->cm_id->port_num;
- switch (rdma_node_get_transport(ctx->cm_id->device->node_type)) {
- case RDMA_TRANSPORT_IB:
- switch (rdma_port_get_link_layer(ctx->cm_id->device,
- ctx->cm_id->port_num)) {
- case IB_LINK_LAYER_INFINIBAND:
- ucma_copy_ib_route(&resp, &ctx->cm_id->route);
- break;
- case IB_LINK_LAYER_ETHERNET:
- ucma_copy_iboe_route(&resp, &ctx->cm_id->route);
- break;
- default:
- break;
- }
- break;
- case RDMA_TRANSPORT_IWARP:
- ucma_copy_iw_route(&resp, &ctx->cm_id->route);
- break;
- default:
- break;
- }
-
-out:
- if (copy_to_user((void __user *)(unsigned long)cmd.response,
- &resp, sizeof(resp)))
- ret = -EFAULT;
-
- ucma_put_ctx(ctx);
- return ret;
-}
-
-static void ucma_copy_conn_param(struct rdma_conn_param *dst,
- struct rdma_ucm_conn_param *src)
-{
- dst->private_data = src->private_data;
- dst->private_data_len = src->private_data_len;
- dst->responder_resources =src->responder_resources;
- dst->initiator_depth = src->initiator_depth;
- dst->flow_control = src->flow_control;
- dst->retry_count = src->retry_count;
- dst->rnr_retry_count = src->rnr_retry_count;
- dst->srq = src->srq;
- dst->qp_num = src->qp_num;
-}
-
-static ssize_t ucma_connect(struct ucma_file *file, const char __user *inbuf,
- int in_len, int out_len)
-{
- struct rdma_ucm_connect cmd;
- struct rdma_conn_param conn_param;
- struct ucma_context *ctx;
- int ret;
-
- if (copy_from_user(&cmd, inbuf, sizeof(cmd)))
- return -EFAULT;
-
- if (!cmd.conn_param.valid)
- return -EINVAL;
-
- ctx = ucma_get_ctx(file, cmd.id);
- if (IS_ERR(ctx))
- return PTR_ERR(ctx);
-
- ucma_copy_conn_param(&conn_param, &cmd.conn_param);
- ret = rdma_connect(ctx->cm_id, &conn_param);
- ucma_put_ctx(ctx);
- return ret;
-}
-
-static ssize_t ucma_listen(struct ucma_file *file, const char __user *inbuf,
- int in_len, int out_len)
-{
- struct rdma_ucm_listen cmd;
- struct ucma_context *ctx;
- int ret;
-
- if (copy_from_user(&cmd, inbuf, sizeof(cmd)))
- return -EFAULT;
-
- ctx = ucma_get_ctx(file, cmd.id);
- if (IS_ERR(ctx))
- return PTR_ERR(ctx);
-
- ctx->backlog = cmd.backlog > 0 && cmd.backlog < max_backlog ?
- cmd.backlog : max_backlog;
- ret = rdma_listen(ctx->cm_id, ctx->backlog);
- ucma_put_ctx(ctx);
- return ret;
-}
-
-static ssize_t ucma_accept(struct ucma_file *file, const char __user *inbuf,
- int in_len, int out_len)
-{
- struct rdma_ucm_accept cmd;
- struct rdma_conn_param conn_param;
- struct ucma_context *ctx;
- int ret;
-
- if (copy_from_user(&cmd, inbuf, sizeof(cmd)))
- return -EFAULT;
-
- ctx = ucma_get_ctx(file, cmd.id);
- if (IS_ERR(ctx))
- return PTR_ERR(ctx);
-
- if (cmd.conn_param.valid) {
- ucma_copy_conn_param(&conn_param, &cmd.conn_param);
- mutex_lock(&file->mut);
- ret = rdma_accept(ctx->cm_id, &conn_param);
- if (!ret)
- ctx->uid = cmd.uid;
- mutex_unlock(&file->mut);
- } else
- ret = rdma_accept(ctx->cm_id, NULL);
-
- ucma_put_ctx(ctx);
- return ret;
-}
-
-static ssize_t ucma_reject(struct ucma_file *file, const char __user *inbuf,
- int in_len, int out_len)
-{
- struct rdma_ucm_reject cmd;
- struct ucma_context *ctx;
- int ret;
-
- if (copy_from_user(&cmd, inbuf, sizeof(cmd)))
- return -EFAULT;
-
- ctx = ucma_get_ctx(file, cmd.id);
- if (IS_ERR(ctx))
- return PTR_ERR(ctx);
-
- ret = rdma_reject(ctx->cm_id, cmd.private_data, cmd.private_data_len);
- ucma_put_ctx(ctx);
- return ret;
-}
-
-static ssize_t ucma_disconnect(struct ucma_file *file, const char __user *inbuf,
- int in_len, int out_len)
-{
- struct rdma_ucm_disconnect cmd;
- struct ucma_context *ctx;
- int ret;
-
- if (copy_from_user(&cmd, inbuf, sizeof(cmd)))
- return -EFAULT;
-
- ctx = ucma_get_ctx(file, cmd.id);
- if (IS_ERR(ctx))
- return PTR_ERR(ctx);
-
- ret = rdma_disconnect(ctx->cm_id);
- ucma_put_ctx(ctx);
- return ret;
-}
-
-static ssize_t ucma_init_qp_attr(struct ucma_file *file,
- const char __user *inbuf,
- int in_len, int out_len)
-{
- struct rdma_ucm_init_qp_attr cmd;
- struct ib_uverbs_qp_attr resp;
- struct ucma_context *ctx;
- struct ib_qp_attr qp_attr;
- int ret;
-
- if (out_len < sizeof(resp))
- return -ENOSPC;
-
- if (copy_from_user(&cmd, inbuf, sizeof(cmd)))
- return -EFAULT;
-
- ctx = ucma_get_ctx(file, cmd.id);
- if (IS_ERR(ctx))
- return PTR_ERR(ctx);
-
- resp.qp_attr_mask = 0;
- memset(&qp_attr, 0, sizeof qp_attr);
- qp_attr.qp_state = cmd.qp_state;
- ret = rdma_init_qp_attr(ctx->cm_id, &qp_attr, &resp.qp_attr_mask);
- if (ret)
- goto out;
-
- ib_copy_qp_attr_to_user(&resp, &qp_attr);
- if (copy_to_user((void __user *)(unsigned long)cmd.response,
- &resp, sizeof(resp)))
- ret = -EFAULT;
-
-out:
- ucma_put_ctx(ctx);
- return ret;
-}
-
-static int ucma_set_option_id(struct ucma_context *ctx, int optname,
- void *optval, size_t optlen)
-{
- int ret = 0;
-
- switch (optname) {
- case RDMA_OPTION_ID_TOS:
- if (optlen != sizeof(u8)) {
- ret = -EINVAL;
- break;
- }
- rdma_set_service_type(ctx->cm_id, *((u8 *) optval));
- break;
- case RDMA_OPTION_ID_REUSEADDR:
- if (optlen != sizeof(int)) {
- ret = -EINVAL;
- break;
- }
- ret = rdma_set_reuseaddr(ctx->cm_id, *((int *) optval) ? 1 : 0);
- break;
- case RDMA_OPTION_ID_AFONLY:
- if (optlen != sizeof(int)) {
- ret = -EINVAL;
- break;
- }
- ret = rdma_set_afonly(ctx->cm_id, *((int *) optval) ? 1 : 0);
- break;
- default:
- ret = -ENOSYS;
- }
-
- return ret;
-}
-
-static int ucma_set_ib_path(struct ucma_context *ctx,
- struct ib_path_rec_data *path_data, size_t optlen)
-{
- struct ib_sa_path_rec sa_path;
- struct rdma_cm_event event;
- int ret;
-
- if (optlen % sizeof(*path_data))
- return -EINVAL;
-
- for (; optlen; optlen -= sizeof(*path_data), path_data++) {
- if (path_data->flags == (IB_PATH_GMP | IB_PATH_PRIMARY |
- IB_PATH_BIDIRECTIONAL))
- break;
- }
-
- if (!optlen)
- return -EINVAL;
-
- ib_sa_unpack_path(path_data->path_rec, &sa_path);
- ret = rdma_set_ib_paths(ctx->cm_id, &sa_path, 1);
- if (ret)
- return ret;
-
- memset(&event, 0, sizeof event);
- event.event = RDMA_CM_EVENT_ROUTE_RESOLVED;
- return ucma_event_handler(ctx->cm_id, &event);
-}
-
-static int ucma_set_option_ib(struct ucma_context *ctx, int optname,
- void *optval, size_t optlen)
-{
- int ret = 0;
-
- switch (optname) {
- case RDMA_OPTION_IB_PATH:
- ret = ucma_set_ib_path(ctx, optval, optlen);
- break;
-
- case RDMA_OPTION_IB_APM:
- if (optlen != sizeof(u8)) {
- ret = -EINVAL;
- break;
- }
- if (*(u8 *)optval)
- ret = rdma_enable_apm(ctx->cm_id, RDMA_ALT_PATH_BEST);
- break;
-
- default:
- ret = -ENOSYS;
- }
-
- return ret;
-}
-
-static int ucma_set_option_level(struct ucma_context *ctx, int level,
- int optname, void *optval, size_t optlen)
-{
- int ret;
-
- switch (level) {
- case RDMA_OPTION_ID:
- ret = ucma_set_option_id(ctx, optname, optval, optlen);
- break;
- case RDMA_OPTION_IB:
- ret = ucma_set_option_ib(ctx, optname, optval, optlen);
- break;
- default:
- ret = -ENOSYS;
- }
-
- return ret;
-}
-
-static ssize_t ucma_set_option(struct ucma_file *file, const char __user *inbuf,
- int in_len, int out_len)
-{
- struct rdma_ucm_set_option cmd;
- struct ucma_context *ctx;
- void *optval;
- int ret;
-
- if (copy_from_user(&cmd, inbuf, sizeof(cmd)))
- return -EFAULT;
-
- ctx = ucma_get_ctx(file, cmd.id);
- if (IS_ERR(ctx))
- return PTR_ERR(ctx);
-
- optval = kmalloc(cmd.optlen, GFP_KERNEL);
- if (!optval) {
- ret = -ENOMEM;
- goto err_ucma_put_ctx;
- }
-
- if (copy_from_user(optval, (void __user *)(unsigned long)cmd.optval,
- cmd.optlen)) {
- ret = -EFAULT;
- goto err_kfree;
- }
-
- ret = ucma_set_option_level(ctx, cmd.level, cmd.optname, optval,
- cmd.optlen);
-
-err_kfree:
- kfree(optval);
-err_ucma_put_ctx:
- ucma_put_ctx(ctx);
- return ret;
-}
-
-static ssize_t ucma_notify(struct ucma_file *file, const char __user *inbuf,
- int in_len, int out_len)
-{
- struct rdma_ucm_notify cmd;
- struct ucma_context *ctx;
- int ret;
-
- if (copy_from_user(&cmd, inbuf, sizeof(cmd)))
- return -EFAULT;
-
- ctx = ucma_get_ctx(file, cmd.id);
- if (IS_ERR(ctx))
- return PTR_ERR(ctx);
-
- ret = rdma_notify(ctx->cm_id, (enum ib_event_type) cmd.event);
- ucma_put_ctx(ctx);
- return ret;
-}
-
-static ssize_t ucma_join_multicast(struct ucma_file *file,
- const char __user *inbuf,
- int in_len, int out_len)
-{
- struct rdma_ucm_join_mcast cmd;
- struct rdma_ucm_create_id_resp resp;
- struct ucma_context *ctx;
- struct ucma_multicast *mc;
- int ret;
-
- if (out_len < sizeof(resp))
- return -ENOSPC;
-
- if (copy_from_user(&cmd, inbuf, sizeof(cmd)))
- return -EFAULT;
-
- ctx = ucma_get_ctx(file, cmd.id);
- if (IS_ERR(ctx))
- return PTR_ERR(ctx);
-
- mutex_lock(&file->mut);
- mc = ucma_alloc_multicast(ctx);
- if (!mc) {
- ret = -ENOMEM;
- goto err1;
- }
-
- mc->uid = cmd.uid;
- memcpy(&mc->addr, &cmd.addr, sizeof cmd.addr);
- ret = rdma_join_multicast(ctx->cm_id, (struct sockaddr *) &mc->addr, mc);
- if (ret)
- goto err2;
-
- resp.id = mc->id;
- if (copy_to_user((void __user *)(unsigned long)cmd.response,
- &resp, sizeof(resp))) {
- ret = -EFAULT;
- goto err3;
- }
-
- mutex_unlock(&file->mut);
- ucma_put_ctx(ctx);
- return 0;
-
-err3:
- rdma_leave_multicast(ctx->cm_id, (struct sockaddr *) &mc->addr);
- ucma_cleanup_mc_events(mc);
-err2:
- mutex_lock(&mut);
- idr_remove(&multicast_idr, mc->id);
- mutex_unlock(&mut);
- list_del(&mc->list);
- kfree(mc);
-err1:
- mutex_unlock(&file->mut);
- ucma_put_ctx(ctx);
- return ret;
-}
-
-static ssize_t ucma_leave_multicast(struct ucma_file *file,
- const char __user *inbuf,
- int in_len, int out_len)
-{
- struct rdma_ucm_destroy_id cmd;
- struct rdma_ucm_destroy_id_resp resp;
- struct ucma_multicast *mc;
- int ret = 0;
-
- if (out_len < sizeof(resp))
- return -ENOSPC;
-
- if (copy_from_user(&cmd, inbuf, sizeof(cmd)))
- return -EFAULT;
-
- mutex_lock(&mut);
- mc = idr_find(&multicast_idr, cmd.id);
- if (!mc)
- mc = ERR_PTR(-ENOENT);
- else if (mc->ctx->file != file)
- mc = ERR_PTR(-EINVAL);
- else {
- idr_remove(&multicast_idr, mc->id);
- atomic_inc(&mc->ctx->ref);
- }
- mutex_unlock(&mut);
-
- if (IS_ERR(mc)) {
- ret = PTR_ERR(mc);
- goto out;
- }
-
- rdma_leave_multicast(mc->ctx->cm_id, (struct sockaddr *) &mc->addr);
- mutex_lock(&mc->ctx->file->mut);
- ucma_cleanup_mc_events(mc);
- list_del(&mc->list);
- mutex_unlock(&mc->ctx->file->mut);
-
- ucma_put_ctx(mc->ctx);
- resp.events_reported = mc->events_reported;
- kfree(mc);
-
- if (copy_to_user((void __user *)(unsigned long)cmd.response,
- &resp, sizeof(resp)))
- ret = -EFAULT;
-out:
- return ret;
-}
-
-static void ucma_lock_files(struct ucma_file *file1, struct ucma_file *file2)
-{
- /* Acquire mutex's based on pointer comparison to prevent deadlock. */
- if (file1 < file2) {
- mutex_lock(&file1->mut);
- mutex_lock(&file2->mut);
- } else {
- mutex_lock(&file2->mut);
- mutex_lock(&file1->mut);
- }
-}
-
-static void ucma_unlock_files(struct ucma_file *file1, struct ucma_file *file2)
-{
- if (file1 < file2) {
- mutex_unlock(&file2->mut);
- mutex_unlock(&file1->mut);
- } else {
- mutex_unlock(&file1->mut);
- mutex_unlock(&file2->mut);
- }
-}
-
-static void ucma_move_events(struct ucma_context *ctx, struct ucma_file *file)
-{
- struct ucma_event *uevent, *tmp;
-
- list_for_each_entry_safe(uevent, tmp, &ctx->file->event_list, list)
- if (uevent->ctx == ctx)
- list_move_tail(&uevent->list, &file->event_list);
-}
-
-static ssize_t ucma_migrate_id(struct ucma_file *new_file,
- const char __user *inbuf,
- int in_len, int out_len)
-{
- struct rdma_ucm_migrate_id cmd;
- struct rdma_ucm_migrate_resp resp;
- struct ucma_context *ctx;
- struct fd f;
- struct ucma_file *cur_file;
- int ret = 0;
-
- if (copy_from_user(&cmd, inbuf, sizeof(cmd)))
- return -EFAULT;
-
- /* Get current fd to protect against it being closed */
- f = fdget(cmd.fd);
- if (!f.file)
- return -ENOENT;
-
- /* Validate current fd and prevent destruction of id. */
- ctx = ucma_get_ctx(f.file->private_data, cmd.id);
- if (IS_ERR(ctx)) {
- ret = PTR_ERR(ctx);
- goto file_put;
- }
-
- cur_file = ctx->file;
- if (cur_file == new_file) {
- resp.events_reported = ctx->events_reported;
- goto response;
- }
-
- /*
- * Migrate events between fd's, maintaining order, and avoiding new
- * events being added before existing events.
- */
- ucma_lock_files(cur_file, new_file);
- mutex_lock(&mut);
-
- list_move_tail(&ctx->list, &new_file->ctx_list);
- ucma_move_events(ctx, new_file);
- ctx->file = new_file;
- resp.events_reported = ctx->events_reported;
-
- mutex_unlock(&mut);
- ucma_unlock_files(cur_file, new_file);
-
-response:
- if (copy_to_user((void __user *)(unsigned long)cmd.response,
- &resp, sizeof(resp)))
- ret = -EFAULT;
-
- ucma_put_ctx(ctx);
-file_put:
- fdput(f);
- return ret;
-}
-
-static ssize_t (*ucma_cmd_table[])(struct ucma_file *file,
- const char __user *inbuf,
- int in_len, int out_len) = {
- [RDMA_USER_CM_CMD_CREATE_ID] = ucma_create_id,
- [RDMA_USER_CM_CMD_DESTROY_ID] = ucma_destroy_id,
- [RDMA_USER_CM_CMD_BIND_ADDR] = ucma_bind_addr,
- [RDMA_USER_CM_CMD_RESOLVE_ADDR] = ucma_resolve_addr,
- [RDMA_USER_CM_CMD_RESOLVE_ROUTE]= ucma_resolve_route,
- [RDMA_USER_CM_CMD_QUERY_ROUTE] = ucma_query_route,
- [RDMA_USER_CM_CMD_CONNECT] = ucma_connect,
- [RDMA_USER_CM_CMD_LISTEN] = ucma_listen,
- [RDMA_USER_CM_CMD_ACCEPT] = ucma_accept,
- [RDMA_USER_CM_CMD_REJECT] = ucma_reject,
- [RDMA_USER_CM_CMD_DISCONNECT] = ucma_disconnect,
- [RDMA_USER_CM_CMD_INIT_QP_ATTR] = ucma_init_qp_attr,
- [RDMA_USER_CM_CMD_GET_EVENT] = ucma_get_event,
- [RDMA_USER_CM_CMD_GET_OPTION] = NULL,
- [RDMA_USER_CM_CMD_SET_OPTION] = ucma_set_option,
- [RDMA_USER_CM_CMD_NOTIFY] = ucma_notify,
- [RDMA_USER_CM_CMD_JOIN_MCAST] = ucma_join_multicast,
- [RDMA_USER_CM_CMD_LEAVE_MCAST] = ucma_leave_multicast,
- [RDMA_USER_CM_CMD_MIGRATE_ID] = ucma_migrate_id
-};
-
-static ssize_t ucma_write(struct file *filp, const char __user *buf,
- size_t len, loff_t *pos)
-{
- struct ucma_file *file = filp->private_data;
- struct rdma_ucm_cmd_hdr hdr;
- ssize_t ret;
-
- if (len < sizeof(hdr))
- return -EINVAL;
-
- if (copy_from_user(&hdr, buf, sizeof(hdr)))
- return -EFAULT;
-
- if (hdr.cmd >= ARRAY_SIZE(ucma_cmd_table))
- return -EINVAL;
-
- if (hdr.in + sizeof(hdr) > len)
- return -EINVAL;
-
- if (!ucma_cmd_table[hdr.cmd])
- return -ENOSYS;
-
- ret = ucma_cmd_table[hdr.cmd](file, buf + sizeof(hdr), hdr.in, hdr.out);
- if (!ret)
- ret = len;
-
- return ret;
-}
-
-static unsigned int ucma_poll(struct file *filp, struct poll_table_struct *wait)
-{
- struct ucma_file *file = filp->private_data;
- unsigned int mask = 0;
-
- poll_wait(filp, &file->poll_wait, wait);
-
- if (!list_empty(&file->event_list))
- mask = POLLIN | POLLRDNORM;
-
- return mask;
-}
-
-/*
- * ucma_open() does not need the BKL:
- *
- * - no global state is referred to;
- * - there is no ioctl method to race against;
- * - no further module initialization is required for open to work
- * after the device is registered.
- */
-static int ucma_open(struct inode *inode, struct file *filp)
-{
- struct ucma_file *file;
-
- file = kmalloc(sizeof *file, GFP_KERNEL);
- if (!file)
- return -ENOMEM;
-
- INIT_LIST_HEAD(&file->event_list);
- INIT_LIST_HEAD(&file->ctx_list);
- init_waitqueue_head(&file->poll_wait);
- mutex_init(&file->mut);
-
- filp->private_data = file;
- file->filp = filp;
-
- return nonseekable_open(inode, filp);
-}
-
-static int ucma_close(struct inode *inode, struct file *filp)
-{
- struct ucma_file *file = filp->private_data;
- struct ucma_context *ctx, *tmp;
-
- mutex_lock(&file->mut);
- list_for_each_entry_safe(ctx, tmp, &file->ctx_list, list) {
- mutex_unlock(&file->mut);
-
- mutex_lock(&mut);
- idr_remove(&ctx_idr, ctx->id);
- mutex_unlock(&mut);
-
- ucma_free_ctx(ctx);
- mutex_lock(&file->mut);
- }
- mutex_unlock(&file->mut);
- kfree(file);
- return 0;
-}
-
-static long
-ucma_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
-{
-
- switch (cmd) {
- case FIONBIO:
- case FIOASYNC:
- return (0);
- default:
- return (-ENOTTY);
- }
-}
-
-static const struct file_operations ucma_fops = {
- .owner = THIS_MODULE,
- .open = ucma_open,
- .release = ucma_close,
- .write = ucma_write,
- .unlocked_ioctl = ucma_ioctl,
- .poll = ucma_poll,
- .llseek = no_llseek,
-};
-
-static struct miscdevice ucma_misc = {
- .minor = MISC_DYNAMIC_MINOR,
- .name = "rdma_cm",
- .nodename = "infiniband/rdma_cm",
- .mode = 0666,
- .fops = &ucma_fops,
-};
-
-static ssize_t show_abi_version(struct device *dev,
- struct device_attribute *attr,
- char *buf)
-{
- return sprintf(buf, "%d\n", RDMA_USER_CM_ABI_VERSION);
-}
-static DEVICE_ATTR(abi_version, S_IRUGO, show_abi_version, NULL);
-
-static int __init ucma_init(void)
-{
- int ret;
-
- ret = misc_register(&ucma_misc);
- if (ret)
- return ret;
-
- ret = device_create_file(ucma_misc.this_device, &dev_attr_abi_version);
- if (ret) {
- printk(KERN_ERR "rdma_ucm: couldn't create abi_version attr\n");
- goto err1;
- }
-
- return 0;
-err1:
- misc_deregister(&ucma_misc);
- return ret;
-}
-
-static void __exit ucma_cleanup(void)
-{
- device_remove_file(ucma_misc.this_device, &dev_attr_abi_version);
- misc_deregister(&ucma_misc);
- idr_destroy(&ctx_idr);
-}
-
-module_init(ucma_init);
-module_exit(ucma_cleanup);
diff --git a/sys/ofed/drivers/infiniband/core/ud_header.c b/sys/ofed/drivers/infiniband/core/ud_header.c
deleted file mode 100644
index 051d3bd..0000000
--- a/sys/ofed/drivers/infiniband/core/ud_header.c
+++ /dev/null
@@ -1,414 +0,0 @@
-/*
- * Copyright (c) 2004 Topspin Corporation. All rights reserved.
- * Copyright (c) 2005 Sun Microsystems, Inc. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-#include <linux/errno.h>
-#include <linux/string.h>
-#include <linux/module.h>
-#include <linux/if_ether.h>
-
-#include <rdma/ib_pack.h>
-
-#define STRUCT_FIELD(header, field) \
- .struct_offset_bytes = offsetof(struct ib_unpacked_ ## header, field), \
- .struct_size_bytes = sizeof ((struct ib_unpacked_ ## header *) 0)->field, \
- .field_name = #header ":" #field
-
-static const struct ib_field lrh_table[] = {
- { STRUCT_FIELD(lrh, virtual_lane),
- .offset_words = 0,
- .offset_bits = 0,
- .size_bits = 4 },
- { STRUCT_FIELD(lrh, link_version),
- .offset_words = 0,
- .offset_bits = 4,
- .size_bits = 4 },
- { STRUCT_FIELD(lrh, service_level),
- .offset_words = 0,
- .offset_bits = 8,
- .size_bits = 4 },
- { RESERVED,
- .offset_words = 0,
- .offset_bits = 12,
- .size_bits = 2 },
- { STRUCT_FIELD(lrh, link_next_header),
- .offset_words = 0,
- .offset_bits = 14,
- .size_bits = 2 },
- { STRUCT_FIELD(lrh, destination_lid),
- .offset_words = 0,
- .offset_bits = 16,
- .size_bits = 16 },
- { RESERVED,
- .offset_words = 1,
- .offset_bits = 0,
- .size_bits = 5 },
- { STRUCT_FIELD(lrh, packet_length),
- .offset_words = 1,
- .offset_bits = 5,
- .size_bits = 11 },
- { STRUCT_FIELD(lrh, source_lid),
- .offset_words = 1,
- .offset_bits = 16,
- .size_bits = 16 }
-};
-
-static const struct ib_field eth_table[] = {
- { STRUCT_FIELD(eth, dmac_h),
- .offset_words = 0,
- .offset_bits = 0,
- .size_bits = 32 },
- { STRUCT_FIELD(eth, dmac_l),
- .offset_words = 1,
- .offset_bits = 0,
- .size_bits = 16 },
- { STRUCT_FIELD(eth, smac_h),
- .offset_words = 1,
- .offset_bits = 16,
- .size_bits = 16 },
- { STRUCT_FIELD(eth, smac_l),
- .offset_words = 2,
- .offset_bits = 0,
- .size_bits = 32 },
- { STRUCT_FIELD(eth, type),
- .offset_words = 3,
- .offset_bits = 0,
- .size_bits = 16 }
-};
-
-static const struct ib_field vlan_table[] = {
- { STRUCT_FIELD(vlan, tag),
- .offset_words = 0,
- .offset_bits = 0,
- .size_bits = 16 },
- { STRUCT_FIELD(vlan, type),
- .offset_words = 0,
- .offset_bits = 16,
- .size_bits = 16 }
-};
-
-static const struct ib_field grh_table[] = {
- { STRUCT_FIELD(grh, ip_version),
- .offset_words = 0,
- .offset_bits = 0,
- .size_bits = 4 },
- { STRUCT_FIELD(grh, traffic_class),
- .offset_words = 0,
- .offset_bits = 4,
- .size_bits = 8 },
- { STRUCT_FIELD(grh, flow_label),
- .offset_words = 0,
- .offset_bits = 12,
- .size_bits = 20 },
- { STRUCT_FIELD(grh, payload_length),
- .offset_words = 1,
- .offset_bits = 0,
- .size_bits = 16 },
- { STRUCT_FIELD(grh, next_header),
- .offset_words = 1,
- .offset_bits = 16,
- .size_bits = 8 },
- { STRUCT_FIELD(grh, hop_limit),
- .offset_words = 1,
- .offset_bits = 24,
- .size_bits = 8 },
- { STRUCT_FIELD(grh, source_gid),
- .offset_words = 2,
- .offset_bits = 0,
- .size_bits = 128 },
- { STRUCT_FIELD(grh, destination_gid),
- .offset_words = 6,
- .offset_bits = 0,
- .size_bits = 128 }
-};
-
-static const struct ib_field bth_table[] = {
- { STRUCT_FIELD(bth, opcode),
- .offset_words = 0,
- .offset_bits = 0,
- .size_bits = 8 },
- { STRUCT_FIELD(bth, solicited_event),
- .offset_words = 0,
- .offset_bits = 8,
- .size_bits = 1 },
- { STRUCT_FIELD(bth, mig_req),
- .offset_words = 0,
- .offset_bits = 9,
- .size_bits = 1 },
- { STRUCT_FIELD(bth, pad_count),
- .offset_words = 0,
- .offset_bits = 10,
- .size_bits = 2 },
- { STRUCT_FIELD(bth, transport_header_version),
- .offset_words = 0,
- .offset_bits = 12,
- .size_bits = 4 },
- { STRUCT_FIELD(bth, pkey),
- .offset_words = 0,
- .offset_bits = 16,
- .size_bits = 16 },
- { RESERVED,
- .offset_words = 1,
- .offset_bits = 0,
- .size_bits = 8 },
- { STRUCT_FIELD(bth, destination_qpn),
- .offset_words = 1,
- .offset_bits = 8,
- .size_bits = 24 },
- { STRUCT_FIELD(bth, ack_req),
- .offset_words = 2,
- .offset_bits = 0,
- .size_bits = 1 },
- { RESERVED,
- .offset_words = 2,
- .offset_bits = 1,
- .size_bits = 7 },
- { STRUCT_FIELD(bth, psn),
- .offset_words = 2,
- .offset_bits = 8,
- .size_bits = 24 }
-};
-
-static const struct ib_field deth_table[] = {
- { STRUCT_FIELD(deth, qkey),
- .offset_words = 0,
- .offset_bits = 0,
- .size_bits = 32 },
- { RESERVED,
- .offset_words = 1,
- .offset_bits = 0,
- .size_bits = 8 },
- { STRUCT_FIELD(deth, source_qpn),
- .offset_words = 1,
- .offset_bits = 8,
- .size_bits = 24 }
-};
-
-/**
- * ib_ud_header_init - Initialize UD header structure
- * @payload_bytes:Length of packet payload
- * @lrh_present: specify if LRH is present
- * @eth_present: specify if Eth header is present
- * @vlan_present: packet is tagged vlan
- * @grh_present:GRH flag (if non-zero, GRH will be included)
- * @immediate_present: specify if immediate data is present
- * @header:Structure to initialize
- */
-void ib_ud_header_init(int payload_bytes,
- int lrh_present,
- int eth_present,
- int vlan_present,
- int grh_present,
- int immediate_present,
- struct ib_ud_header *header)
-{
- memset(header, 0, sizeof *header);
-
- if (lrh_present) {
- u16 packet_length = 0;
-
- header->lrh.link_version = 0;
- header->lrh.link_next_header =
- grh_present ? IB_LNH_IBA_GLOBAL : IB_LNH_IBA_LOCAL;
- packet_length = (IB_LRH_BYTES +
- IB_BTH_BYTES +
- IB_DETH_BYTES +
- (grh_present ? IB_GRH_BYTES : 0) +
- payload_bytes +
- 4 + /* ICRC */
- 3) / 4; /* round up */
- header->lrh.packet_length = cpu_to_be16(packet_length);
- }
-
- if (vlan_present)
- header->eth.type = cpu_to_be16(ETH_P_8021Q);
-
- if (grh_present) {
- header->grh.ip_version = 6;
- header->grh.payload_length =
- cpu_to_be16((IB_BTH_BYTES +
- IB_DETH_BYTES +
- payload_bytes +
- 4 + /* ICRC */
- 3) & ~3); /* round up */
- header->grh.next_header = 0x1b;
- }
-
- if (immediate_present)
- header->bth.opcode = IB_OPCODE_UD_SEND_ONLY_WITH_IMMEDIATE;
- else
- header->bth.opcode = IB_OPCODE_UD_SEND_ONLY;
- header->bth.pad_count = (4 - payload_bytes) & 3;
- header->bth.transport_header_version = 0;
-
- header->lrh_present = lrh_present;
- header->eth_present = eth_present;
- header->vlan_present = vlan_present;
- header->grh_present = grh_present;
- header->immediate_present = immediate_present;
-}
-EXPORT_SYMBOL(ib_ud_header_init);
-
-/**
- * ib_ud_header_pack - Pack UD header struct into wire format
- * @header:UD header struct
- * @buf:Buffer to pack into
- *
- * ib_ud_header_pack() packs the UD header structure @header into wire
- * format in the buffer @buf.
- */
-int ib_ud_header_pack(struct ib_ud_header *header,
- void *buf)
-{
- int len = 0;
-
- if (header->lrh_present) {
- ib_pack(lrh_table, ARRAY_SIZE(lrh_table),
- &header->lrh, buf + len);
- len += IB_LRH_BYTES;
- }
- if (header->eth_present) {
- ib_pack(eth_table, ARRAY_SIZE(eth_table),
- &header->eth, buf + len);
- len += IB_ETH_BYTES;
- }
- if (header->vlan_present) {
- ib_pack(vlan_table, ARRAY_SIZE(vlan_table),
- &header->vlan, buf + len);
- len += IB_VLAN_BYTES;
- }
- if (header->grh_present) {
- ib_pack(grh_table, ARRAY_SIZE(grh_table),
- &header->grh, buf + len);
- len += IB_GRH_BYTES;
- }
-
- ib_pack(bth_table, ARRAY_SIZE(bth_table),
- &header->bth, buf + len);
- len += IB_BTH_BYTES;
-
- ib_pack(deth_table, ARRAY_SIZE(deth_table),
- &header->deth, buf + len);
- len += IB_DETH_BYTES;
-
- if (header->immediate_present) {
- memcpy(buf + len, &header->immediate_data, sizeof header->immediate_data);
- len += sizeof header->immediate_data;
- }
-
- return len;
-}
-EXPORT_SYMBOL(ib_ud_header_pack);
-
-/**
- * ib_ud_header_unpack - Unpack UD header struct from wire format
- * @header:UD header struct
- * @buf:Buffer to pack into
- *
- * ib_ud_header_pack() unpacks the UD header structure @header from wire
- * format in the buffer @buf.
- */
-int ib_ud_header_unpack(void *buf,
- struct ib_ud_header *header)
-{
- ib_unpack(lrh_table, ARRAY_SIZE(lrh_table),
- buf, &header->lrh);
- buf += IB_LRH_BYTES;
-
- if (header->lrh.link_version != 0) {
- printk(KERN_WARNING "Invalid LRH.link_version %d\n",
- header->lrh.link_version);
- return -EINVAL;
- }
-
- switch (header->lrh.link_next_header) {
- case IB_LNH_IBA_LOCAL:
- header->grh_present = 0;
- break;
-
- case IB_LNH_IBA_GLOBAL:
- header->grh_present = 1;
- ib_unpack(grh_table, ARRAY_SIZE(grh_table),
- buf, &header->grh);
- buf += IB_GRH_BYTES;
-
- if (header->grh.ip_version != 6) {
- printk(KERN_WARNING "Invalid GRH.ip_version %d\n",
- header->grh.ip_version);
- return -EINVAL;
- }
- if (header->grh.next_header != 0x1b) {
- printk(KERN_WARNING "Invalid GRH.next_header 0x%02x\n",
- header->grh.next_header);
- return -EINVAL;
- }
- break;
-
- default:
- printk(KERN_WARNING "Invalid LRH.link_next_header %d\n",
- header->lrh.link_next_header);
- return -EINVAL;
- }
-
- ib_unpack(bth_table, ARRAY_SIZE(bth_table),
- buf, &header->bth);
- buf += IB_BTH_BYTES;
-
- switch (header->bth.opcode) {
- case IB_OPCODE_UD_SEND_ONLY:
- header->immediate_present = 0;
- break;
- case IB_OPCODE_UD_SEND_ONLY_WITH_IMMEDIATE:
- header->immediate_present = 1;
- break;
- default:
- printk(KERN_WARNING "Invalid BTH.opcode 0x%02x\n",
- header->bth.opcode);
- return -EINVAL;
- }
-
- if (header->bth.transport_header_version != 0) {
- printk(KERN_WARNING "Invalid BTH.transport_header_version %d\n",
- header->bth.transport_header_version);
- return -EINVAL;
- }
-
- ib_unpack(deth_table, ARRAY_SIZE(deth_table),
- buf, &header->deth);
- buf += IB_DETH_BYTES;
-
- if (header->immediate_present)
- memcpy(&header->immediate_data, buf, sizeof header->immediate_data);
-
- return 0;
-}
-EXPORT_SYMBOL(ib_ud_header_unpack);
diff --git a/sys/ofed/drivers/infiniband/core/umem.c b/sys/ofed/drivers/infiniband/core/umem.c
deleted file mode 100644
index 6c1a1e6..0000000
--- a/sys/ofed/drivers/infiniband/core/umem.c
+++ /dev/null
@@ -1,446 +0,0 @@
-/*
- * Copyright (c) 2005 Topspin Communications. All rights reserved.
- * Copyright (c) 2005 Cisco Systems. All rights reserved.
- * Copyright (c) 2005 Mellanox Technologies. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-#define LINUXKPI_PARAM_PREFIX ibcore_
-
-#include <linux/mm.h>
-#include <linux/dma-mapping.h>
-#include <linux/sched.h>
-#include <linux/dma-attrs.h>
-#include <linux/slab.h>
-#include <linux/module.h>
-#include <linux/wait.h>
-#include <sys/priv.h>
-#include <sys/resourcevar.h>
-#include <sys/vmmeter.h>
-#include <vm/vm_pageout.h>
-#include <vm/vm_map.h>
-#include "uverbs.h"
-
-#define IB_UMEM_MAX_PAGE_CHUNK (PAGE_SIZE / sizeof (struct page *))
-
-static int allow_weak_ordering;
-module_param_named(weak_ordering, allow_weak_ordering, int, 0444);
-MODULE_PARM_DESC(weak_ordering, "Allow weak ordering for data registered memory");
-
-static struct ib_umem *peer_umem_get(struct ib_peer_memory_client *ib_peer_mem,
- struct ib_umem *umem, unsigned long addr,
- int dmasync, int invalidation_supported)
-{
- int ret;
- const struct peer_memory_client *peer_mem = ib_peer_mem->peer_mem;
- struct invalidation_ctx *invalidation_ctx = NULL;
-
- umem->ib_peer_mem = ib_peer_mem;
- if (invalidation_supported) {
- invalidation_ctx = kzalloc(sizeof(*invalidation_ctx), GFP_KERNEL);
- if (!invalidation_ctx) {
- ret = -ENOMEM;
- goto out;
- }
- umem->invalidation_ctx = invalidation_ctx;
- invalidation_ctx->umem = umem;
- mutex_lock(&ib_peer_mem->lock);
- invalidation_ctx->context_ticket =
- ib_peer_insert_context(ib_peer_mem, invalidation_ctx);
- /* unlock before calling get pages to prevent a dead-lock from the callback */
- mutex_unlock(&ib_peer_mem->lock);
- }
-
- ret = peer_mem->get_pages(addr, umem->length, umem->writable, 1,
- &umem->sg_head,
- umem->peer_mem_client_context,
- invalidation_ctx ?
- (void *)invalidation_ctx->context_ticket : NULL);
-
- if (invalidation_ctx) {
- /* taking the lock back, checking that wasn't invalidated at that time */
- mutex_lock(&ib_peer_mem->lock);
- if (invalidation_ctx->peer_invalidated) {
- printk(KERN_ERR "peer_umem_get: pages were invalidated by peer\n");
- ret = -EINVAL;
- }
- }
-
- if (ret)
- goto out;
-
- umem->page_size = peer_mem->get_page_size
- (umem->peer_mem_client_context);
- if (umem->page_size <= 0)
- goto put_pages;
-
- umem->offset = addr & ((unsigned long)umem->page_size - 1);
- ret = peer_mem->dma_map(&umem->sg_head,
- umem->peer_mem_client_context,
- umem->context->device->dma_device,
- dmasync,
- &umem->nmap);
- if (ret)
- goto put_pages;
-
- ib_peer_mem->stats.num_reg_pages +=
- umem->nmap * (umem->page_size >> PAGE_SHIFT);
- ib_peer_mem->stats.num_alloc_mrs += 1;
- return umem;
-
-put_pages:
-
- peer_mem->put_pages(umem->peer_mem_client_context,
- &umem->sg_head);
-out:
- if (invalidation_ctx) {
- ib_peer_remove_context(ib_peer_mem, invalidation_ctx->context_ticket);
- mutex_unlock(&umem->ib_peer_mem->lock);
- kfree(invalidation_ctx);
- }
-
- ib_put_peer_client(ib_peer_mem, umem->peer_mem_client_context,
- umem->peer_mem_srcu_key);
- kfree(umem);
- return ERR_PTR(ret);
-}
-
-static void peer_umem_release(struct ib_umem *umem)
-{
- struct ib_peer_memory_client *ib_peer_mem = umem->ib_peer_mem;
- const struct peer_memory_client *peer_mem = ib_peer_mem->peer_mem;
- struct invalidation_ctx *invalidation_ctx = umem->invalidation_ctx;
-
- if (invalidation_ctx) {
-
- int peer_callback;
- int inflight_invalidation;
- /* If we are not under peer callback we must take the lock before removing
- * core ticket from the tree and releasing its umem.
- * It will let any inflight callbacks to be ended safely.
- * If we are under peer callback or under error flow of reg_mr so that context
- * wasn't activated yet lock was already taken.
- */
- if (invalidation_ctx->func && !invalidation_ctx->peer_callback)
- mutex_lock(&ib_peer_mem->lock);
- ib_peer_remove_context(ib_peer_mem, invalidation_ctx->context_ticket);
- /* make sure to check inflight flag after took the lock and remove from tree.
- * in addition, from that point using local variables for peer_callback and
- * inflight_invalidation as after the complete invalidation_ctx can't be accessed
- * any more as it may be freed by the callback.
- */
- peer_callback = invalidation_ctx->peer_callback;
- inflight_invalidation = invalidation_ctx->inflight_invalidation;
- if (inflight_invalidation)
- complete(&invalidation_ctx->comp);
- /* On peer callback lock is handled externally */
- if (!peer_callback)
- /* unlocking before put_pages */
- mutex_unlock(&ib_peer_mem->lock);
- /* in case under callback context or callback is pending let it free the invalidation context */
- if (!peer_callback && !inflight_invalidation)
- kfree(invalidation_ctx);
- }
-
- peer_mem->dma_unmap(&umem->sg_head,
- umem->peer_mem_client_context,
- umem->context->device->dma_device);
- peer_mem->put_pages(&umem->sg_head,
- umem->peer_mem_client_context);
-
- ib_peer_mem->stats.num_dereg_pages +=
- umem->nmap * (umem->page_size >> PAGE_SHIFT);
- ib_peer_mem->stats.num_dealloc_mrs += 1;
- ib_put_peer_client(ib_peer_mem, umem->peer_mem_client_context,
- umem->peer_mem_srcu_key);
- kfree(umem);
-
- return;
-
-}
-
-static void __ib_umem_release(struct ib_device *dev, struct ib_umem *umem, int dirty)
-{
-
- vm_object_t object;
- struct scatterlist *sg;
- struct page *page;
- int i;
-
- object = NULL;
- if (umem->nmap > 0)
- ib_dma_unmap_sg(dev, umem->sg_head.sgl,
- umem->nmap,
- DMA_BIDIRECTIONAL);
- for_each_sg(umem->sg_head.sgl, sg, umem->npages, i) {
- page = sg_page(sg);
- if (umem->writable && dirty) {
- if (object && object != page->object)
- VM_OBJECT_WUNLOCK(object);
- if (object != page->object) {
- object = page->object;
- VM_OBJECT_WLOCK(object);
- }
- vm_page_dirty(page);
- }
- }
- sg_free_table(&umem->sg_head);
- if (object)
- VM_OBJECT_WUNLOCK(object);
-
-}
-
-void ib_umem_activate_invalidation_notifier(struct ib_umem *umem,
- umem_invalidate_func_t func,
- void *cookie)
-{
- struct invalidation_ctx *invalidation_ctx = umem->invalidation_ctx;
-
- invalidation_ctx->func = func;
- invalidation_ctx->cookie = cookie;
-
- /* from that point any pending invalidations can be called */
- mutex_unlock(&umem->ib_peer_mem->lock);
- return;
-}
-EXPORT_SYMBOL(ib_umem_activate_invalidation_notifier);
-/**
- * ib_umem_get - Pin and DMA map userspace memory.
- * @context: userspace context to pin memory for
- * @addr: userspace virtual address to start at
- * @size: length of region to pin
- * @access: IB_ACCESS_xxx flags for memory being pinned
- * @dmasync: flush in-flight DMA when the memory region is written
- */
-struct ib_umem *ib_umem_get_ex(struct ib_ucontext *context, unsigned long addr,
- size_t size, int access, int dmasync,
- int invalidation_supported)
-{
-
- struct ib_umem *umem;
- struct proc *proc;
- pmap_t pmap;
- vm_offset_t end, last, start;
- vm_size_t npages;
- int error;
- int ret;
- int ents;
- int i;
- DEFINE_DMA_ATTRS(attrs);
- struct scatterlist *sg, *sg_list_start;
- int need_release = 0;
-
- error = priv_check(curthread, PRIV_VM_MLOCK);
- if (error)
- return ERR_PTR(-error);
-
- last = addr + size;
- start = addr & PAGE_MASK; /* Use the linux PAGE_MASK definition. */
- end = roundup2(last, PAGE_SIZE); /* Use PAGE_MASK safe operation. */
- if (last < addr || end < addr)
- return ERR_PTR(-EINVAL);
- npages = atop(end - start);
- if (npages > vm_page_max_wired)
- return ERR_PTR(-ENOMEM);
- umem = kzalloc(sizeof *umem, GFP_KERNEL);
- if (!umem)
- return ERR_PTR(-ENOMEM);
- proc = curthread->td_proc;
- PROC_LOCK(proc);
- if (ptoa(npages +
- pmap_wired_count(vm_map_pmap(&proc->p_vmspace->vm_map))) >
- lim_cur_proc(proc, RLIMIT_MEMLOCK)) {
- PROC_UNLOCK(proc);
- kfree(umem);
- return ERR_PTR(-ENOMEM);
- }
- PROC_UNLOCK(proc);
- if (npages + vm_cnt.v_wire_count > vm_page_max_wired) {
- kfree(umem);
- return ERR_PTR(-EAGAIN);
- }
- error = vm_map_wire(&proc->p_vmspace->vm_map, start, end,
- VM_MAP_WIRE_USER | VM_MAP_WIRE_NOHOLES |
- (umem->writable ? VM_MAP_WIRE_WRITE : 0));
- if (error != KERN_SUCCESS) {
- kfree(umem);
- return ERR_PTR(-ENOMEM);
- }
-
- umem->context = context;
- umem->length = size;
- umem->offset = addr & ~PAGE_MASK;
- umem->page_size = PAGE_SIZE;
- umem->start = addr;
- /*
- * We ask for writable memory if any access flags other than
- * "remote read" are set. "Local write" and "remote write"
- * obviously require write access. "Remote atomic" can do
- * things like fetch and add, which will modify memory, and
- * "MW bind" can change permissions by binding a window.
- */
- umem->writable = !!(access & ~IB_ACCESS_REMOTE_READ);
-
- if (invalidation_supported || context->peer_mem_private_data) {
-
- struct ib_peer_memory_client *peer_mem_client;
-
- peer_mem_client = ib_get_peer_client(context, addr, size,
- &umem->peer_mem_client_context,
- &umem->peer_mem_srcu_key);
- if (peer_mem_client)
- return peer_umem_get(peer_mem_client, umem, addr,
- dmasync, invalidation_supported);
- }
-
- umem->hugetlb = 0;
-
- pmap = vm_map_pmap(&proc->p_vmspace->vm_map);
-
- if (npages == 0) {
- ret = -EINVAL;
- goto out;
- }
-
- ret = sg_alloc_table(&umem->sg_head, npages, GFP_KERNEL);
- if (ret)
- goto out;
-
- need_release = 1;
- sg_list_start = umem->sg_head.sgl;
-
- while (npages) {
-
- ents = min_t(int, npages, IB_UMEM_MAX_PAGE_CHUNK);
- umem->npages += ents;
-
- for_each_sg(sg_list_start, sg, ents, i) {
- vm_paddr_t pa;
-
- pa = pmap_extract(pmap, start);
- if (pa == 0) {
- ret = -ENOMEM;
- goto out;
- }
- sg_set_page(sg, PHYS_TO_VM_PAGE(pa),
- PAGE_SIZE, 0);
- npages--;
- start += PAGE_SIZE;
- }
-
- /* preparing for next loop */
- sg_list_start = sg;
- }
-
- umem->nmap = ib_dma_map_sg_attrs(context->device,
- umem->sg_head.sgl,
- umem->npages,
- DMA_BIDIRECTIONAL,
- &attrs);
- if (umem->nmap != umem->npages) {
- ret = -ENOMEM;
- goto out;
- }
-
-out:
- if (ret < 0) {
- if (need_release)
- __ib_umem_release(context->device, umem, 0);
- kfree(umem);
- }
-
- return ret < 0 ? ERR_PTR(ret) : umem;
-}
-EXPORT_SYMBOL(ib_umem_get_ex);
-
-struct ib_umem *ib_umem_get(struct ib_ucontext *context, unsigned long addr,
- size_t size, int access, int dmasync)
-{
- return ib_umem_get_ex(context, addr,
- size, access, dmasync, 0);
-}
-EXPORT_SYMBOL(ib_umem_get);
-
-/**
- * ib_umem_release - release memory pinned with ib_umem_get
- * @umem: umem struct to release
- */
-void ib_umem_release(struct ib_umem *umem)
-{
-
- vm_offset_t addr, end, last, start;
- vm_size_t size;
- int error;
-
- if (umem->ib_peer_mem) {
- peer_umem_release(umem);
- return;
- }
-
- __ib_umem_release(umem->context->device, umem, 1);
-
- if (umem->context->closing) {
- kfree(umem);
- return;
- }
-
- error = priv_check(curthread, PRIV_VM_MUNLOCK);
-
- if (error)
- return;
-
- addr = umem->start;
- size = umem->length;
- last = addr + size;
- start = addr & PAGE_MASK; /* Use the linux PAGE_MASK definition. */
- end = roundup2(last, PAGE_SIZE); /* Use PAGE_MASK safe operation. */
- vm_map_unwire(&curthread->td_proc->p_vmspace->vm_map, start, end,
- VM_MAP_WIRE_USER | VM_MAP_WIRE_NOHOLES);
- kfree(umem);
-
-}
-EXPORT_SYMBOL(ib_umem_release);
-
-int ib_umem_page_count(struct ib_umem *umem)
-{
- int shift;
- int i;
- int n;
- struct scatterlist *sg;
-
- shift = ilog2(umem->page_size);
-
- n = 0;
- for_each_sg(umem->sg_head.sgl, sg, umem->nmap, i)
- n += sg_dma_len(sg) >> shift;
-
- return n;
-}
-EXPORT_SYMBOL(ib_umem_page_count);
diff --git a/sys/ofed/drivers/infiniband/core/user_mad.c b/sys/ofed/drivers/infiniband/core/user_mad.c
deleted file mode 100644
index d269751..0000000
--- a/sys/ofed/drivers/infiniband/core/user_mad.c
+++ /dev/null
@@ -1,1312 +0,0 @@
-/*
- * Copyright (c) 2004 Topspin Communications. All rights reserved.
- * Copyright (c) 2005 Voltaire, Inc. All rights reserved.
- * Copyright (c) 2005 Sun Microsystems, Inc. All rights reserved.
- * Copyright (c) 2008 Cisco. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-#include <linux/module.h>
-#include <linux/device.h>
-#include <linux/err.h>
-#include <linux/fs.h>
-#include <linux/cdev.h>
-#include <linux/dma-mapping.h>
-#include <linux/poll.h>
-#include <linux/mutex.h>
-#include <linux/kref.h>
-#include <linux/compat.h>
-#include <linux/sched.h>
-#include <linux/semaphore.h>
-#include <linux/slab.h>
-
-#include <asm/uaccess.h>
-
-#include <rdma/ib_mad.h>
-#include <rdma/ib_user_mad.h>
-
-MODULE_AUTHOR("Roland Dreier");
-MODULE_DESCRIPTION("InfiniBand userspace MAD packet access");
-MODULE_LICENSE("Dual BSD/GPL");
-
-enum {
- IB_UMAD_MAX_PORTS = 64,
- IB_UMAD_MAX_AGENTS = 32,
-
- IB_UMAD_MAJOR = 231,
- IB_UMAD_MINOR_BASE = 0
-};
-
-/*
- * Our lifetime rules for these structs are the following:
- * device special file is opened, we take a reference on the
- * ib_umad_port's struct ib_umad_device. We drop these
- * references in the corresponding close().
- *
- * In addition to references coming from open character devices, there
- * is one more reference to each ib_umad_device representing the
- * module's reference taken when allocating the ib_umad_device in
- * ib_umad_add_one().
- *
- * When destroying an ib_umad_device, we drop the module's reference.
- */
-
-struct ib_umad_port {
- struct cdev *cdev;
- struct device *dev;
-
- struct cdev *sm_cdev;
- struct device *sm_dev;
- struct semaphore sm_sem;
-
- struct mutex file_mutex;
- struct list_head file_list;
-
- struct ib_device *ib_dev;
- struct ib_umad_device *umad_dev;
- int dev_num;
- u8 port_num;
- struct list_head port_lst;
-};
-
-struct ib_umad_device {
- int start_port, end_port;
- struct kref ref;
- struct ib_umad_port port[0];
-};
-
-struct ib_umad_file {
- struct mutex mutex;
- struct ib_umad_port *port;
- struct file *filp;
- struct list_head recv_list;
- struct list_head send_list;
- struct list_head port_list;
- spinlock_t send_lock;
- wait_queue_head_t recv_wait;
- struct ib_mad_agent *agent[IB_UMAD_MAX_AGENTS];
- int agents_dead;
- u8 use_pkey_index;
- u8 already_used;
-};
-
-struct ib_umad_packet {
- struct ib_mad_send_buf *msg;
- struct ib_mad_recv_wc *recv_wc;
- struct list_head list;
- int length;
- struct ib_user_mad mad;
-};
-
-static struct class *umad_class;
-
-static const dev_t base_dev = MKDEV(IB_UMAD_MAJOR, IB_UMAD_MINOR_BASE);
-
-static DEFINE_SPINLOCK(port_lock);
-static DECLARE_BITMAP(dev_map, IB_UMAD_MAX_PORTS);
-static DECLARE_BITMAP(overflow_map, IB_UMAD_MAX_PORTS);
-
-static void ib_umad_add_one(struct ib_device *device);
-static void ib_umad_remove_one(struct ib_device *device);
-
-static DEFINE_SPINLOCK(ports_list_lock);
-static struct list_head ports_list;
-
-
-static void remove_ports(struct kref *ref)
-{
- int i;
- struct ib_umad_port *p, *p1;
- struct ib_umad_device *dev =
- container_of(ref, struct ib_umad_device, ref);
-
- for (i = 0; i <= dev->end_port - dev->start_port; ++i) {
- struct ib_umad_port *port = &dev->port[i];
-
- list_for_each_entry_safe(p, p1, &ports_list, port_lst)
- if (p == port) {
- list_del(&p->port_lst);
- break;
- }
- }
-}
-
-static void put_umad_dev(struct kref *ref)
-{
- int ret, i;
- struct ib_umad_device *dev =
- container_of(ref, struct ib_umad_device, ref);
-
- spin_lock(&ports_list_lock);
- ret = (kref_put(ref, remove_ports));
- spin_unlock(&ports_list_lock);
- if (ret) {
- for (i = 0; i <= dev->end_port - dev->start_port; ++i) {
- if (dev->port[i].dev_num < IB_UMAD_MAX_PORTS)
- clear_bit(dev->port[i].dev_num, dev_map);
- else
- clear_bit(dev->port[i].dev_num - IB_UMAD_MAX_PORTS, overflow_map);
- cdev_del(dev->port[i].cdev);
- cdev_del(dev->port[i].sm_cdev);
- }
- kfree(dev);
- }
-}
-
-static void release_port(struct ib_umad_port *port)
-{
- put_umad_dev(&port->umad_dev->ref);
-}
-
-
-static struct ib_umad_port *get_port(struct cdev *cdev)
-{
- struct ib_umad_port *port;
-
- spin_lock(&ports_list_lock);
- list_for_each_entry(port, &ports_list, port_lst) {
- if (port->cdev == cdev || port->sm_cdev == cdev) {
- kref_get(&port->umad_dev->ref);
- spin_unlock(&ports_list_lock);
-
- return port;
- }
- }
- spin_unlock(&ports_list_lock);
-
- return NULL;
-}
-
-static void insert_port(struct ib_umad_port *port)
-{
- spin_lock(&ports_list_lock);
- list_add(&port->port_lst, &ports_list);
- spin_unlock(&ports_list_lock);
-}
-
-static int hdr_size(struct ib_umad_file *file)
-{
- return file->use_pkey_index ? sizeof (struct ib_user_mad_hdr) :
- sizeof (struct ib_user_mad_hdr_old);
-}
-
-/* caller must hold file->mutex */
-static struct ib_mad_agent *__get_agent(struct ib_umad_file *file, int id)
-{
- return file->agents_dead ? NULL : file->agent[id];
-}
-
-static int queue_packet(struct ib_umad_file *file,
- struct ib_mad_agent *agent,
- struct ib_umad_packet *packet)
-{
- int ret = 1;
-
- mutex_lock(&file->mutex);
-
- for (packet->mad.hdr.id = 0;
- packet->mad.hdr.id < IB_UMAD_MAX_AGENTS;
- packet->mad.hdr.id++)
- if (agent == __get_agent(file, packet->mad.hdr.id)) {
- list_add_tail(&packet->list, &file->recv_list);
- wake_up_interruptible(&file->recv_wait);
- ret = 0;
- break;
- }
-
- mutex_unlock(&file->mutex);
-
- return ret;
-}
-
-static void dequeue_send(struct ib_umad_file *file,
- struct ib_umad_packet *packet)
-{
- spin_lock_irq(&file->send_lock);
- list_del(&packet->list);
- spin_unlock_irq(&file->send_lock);
-}
-
-static void send_handler(struct ib_mad_agent *agent,
- struct ib_mad_send_wc *send_wc)
-{
- struct ib_umad_file *file = agent->context;
- struct ib_umad_packet *packet = send_wc->send_buf->context[0];
-
- dequeue_send(file, packet);
- ib_destroy_ah(packet->msg->ah);
- ib_free_send_mad(packet->msg);
-
- if (send_wc->status == IB_WC_RESP_TIMEOUT_ERR) {
- packet->length = IB_MGMT_MAD_HDR;
- packet->mad.hdr.status = ETIMEDOUT;
- if (!queue_packet(file, agent, packet))
- return;
- }
- kfree(packet);
-}
-
-static void recv_handler(struct ib_mad_agent *agent,
- struct ib_mad_recv_wc *mad_recv_wc)
-{
- struct ib_umad_file *file = agent->context;
- struct ib_umad_packet *packet;
-
- if (mad_recv_wc->wc->status != IB_WC_SUCCESS)
- goto err1;
-
- packet = kzalloc(sizeof *packet, GFP_KERNEL);
- if (!packet)
- goto err1;
-
- packet->length = mad_recv_wc->mad_len;
- packet->recv_wc = mad_recv_wc;
-
- packet->mad.hdr.status = 0;
- packet->mad.hdr.length = hdr_size(file) + mad_recv_wc->mad_len;
- packet->mad.hdr.qpn = cpu_to_be32(mad_recv_wc->wc->src_qp);
- packet->mad.hdr.lid = cpu_to_be16(mad_recv_wc->wc->slid);
- packet->mad.hdr.sl = mad_recv_wc->wc->sl;
- packet->mad.hdr.path_bits = mad_recv_wc->wc->dlid_path_bits;
- packet->mad.hdr.pkey_index = mad_recv_wc->wc->pkey_index;
- packet->mad.hdr.grh_present = !!(mad_recv_wc->wc->wc_flags & IB_WC_GRH);
- if (packet->mad.hdr.grh_present) {
- struct ib_ah_attr ah_attr;
-
- ib_init_ah_from_wc(agent->device, agent->port_num,
- mad_recv_wc->wc, mad_recv_wc->recv_buf.grh,
- &ah_attr);
-
- packet->mad.hdr.gid_index = ah_attr.grh.sgid_index;
- packet->mad.hdr.hop_limit = ah_attr.grh.hop_limit;
- packet->mad.hdr.traffic_class = ah_attr.grh.traffic_class;
- memcpy(packet->mad.hdr.gid, &ah_attr.grh.dgid, 16);
- packet->mad.hdr.flow_label = cpu_to_be32(ah_attr.grh.flow_label);
- }
-
- if (queue_packet(file, agent, packet))
- goto err2;
- return;
-
-err2:
- kfree(packet);
-err1:
- ib_free_recv_mad(mad_recv_wc);
-}
-
-static ssize_t copy_recv_mad(struct ib_umad_file *file, char __user *buf,
- struct ib_umad_packet *packet, size_t count)
-{
- struct ib_mad_recv_buf *recv_buf;
- int left, seg_payload, offset, max_seg_payload;
-
- /* We need enough room to copy the first (or only) MAD segment. */
- recv_buf = &packet->recv_wc->recv_buf;
- if ((packet->length <= sizeof (*recv_buf->mad) &&
- count < hdr_size(file) + packet->length) ||
- (packet->length > sizeof (*recv_buf->mad) &&
- count < hdr_size(file) + sizeof (*recv_buf->mad)))
- return -EINVAL;
-
- if (copy_to_user(buf, &packet->mad, hdr_size(file)))
- return -EFAULT;
-
- buf += hdr_size(file);
- seg_payload = min_t(int, packet->length, sizeof (*recv_buf->mad));
- if (copy_to_user(buf, recv_buf->mad, seg_payload))
- return -EFAULT;
-
- if (seg_payload < packet->length) {
- /*
- * Multipacket RMPP MAD message. Copy remainder of message.
- * Note that last segment may have a shorter payload.
- */
- if (count < hdr_size(file) + packet->length) {
- /*
- * The buffer is too small, return the first RMPP segment,
- * which includes the RMPP message length.
- */
- return -ENOSPC;
- }
- offset = ib_get_mad_data_offset(recv_buf->mad->mad_hdr.mgmt_class);
- max_seg_payload = sizeof (struct ib_mad) - offset;
-
- for (left = packet->length - seg_payload, buf += seg_payload;
- left; left -= seg_payload, buf += seg_payload) {
- recv_buf = container_of(recv_buf->list.next,
- struct ib_mad_recv_buf, list);
- seg_payload = min(left, max_seg_payload);
- if (copy_to_user(buf, ((void *) recv_buf->mad) + offset,
- seg_payload))
- return -EFAULT;
- }
- }
- return hdr_size(file) + packet->length;
-}
-
-static ssize_t copy_send_mad(struct ib_umad_file *file, char __user *buf,
- struct ib_umad_packet *packet, size_t count)
-{
- ssize_t size = hdr_size(file) + packet->length;
-
- if (count < size)
- return -EINVAL;
-
- if (copy_to_user(buf, &packet->mad, hdr_size(file)))
- return -EFAULT;
-
- buf += hdr_size(file);
-
- if (copy_to_user(buf, packet->mad.data, packet->length))
- return -EFAULT;
-
- return size;
-}
-
-static ssize_t ib_umad_read(struct file *filp, char __user *buf,
- size_t count, loff_t *pos)
-{
- struct ib_umad_file *file = filp->private_data;
- struct ib_umad_packet *packet;
- ssize_t ret;
-
- if (count < hdr_size(file))
- return -EINVAL;
-
- mutex_lock(&file->mutex);
-
- while (list_empty(&file->recv_list)) {
- mutex_unlock(&file->mutex);
-
- if (filp->f_flags & O_NONBLOCK)
- return -EAGAIN;
-
- if (wait_event_interruptible(file->recv_wait,
- !list_empty(&file->recv_list)))
- return -ERESTARTSYS;
-
- mutex_lock(&file->mutex);
- }
-
- packet = list_entry(file->recv_list.next, struct ib_umad_packet, list);
- list_del(&packet->list);
-
- mutex_unlock(&file->mutex);
-
- if (packet->recv_wc)
- ret = copy_recv_mad(file, buf, packet, count);
- else
- ret = copy_send_mad(file, buf, packet, count);
-
- if (ret < 0) {
- /* Requeue packet */
- mutex_lock(&file->mutex);
- list_add(&packet->list, &file->recv_list);
- mutex_unlock(&file->mutex);
- } else {
- if (packet->recv_wc)
- ib_free_recv_mad(packet->recv_wc);
- kfree(packet);
- }
- return ret;
-}
-
-static int copy_rmpp_mad(struct ib_mad_send_buf *msg, const char __user *buf)
-{
- int left, seg;
-
- /* Copy class specific header */
- if ((msg->hdr_len > IB_MGMT_RMPP_HDR) &&
- copy_from_user(msg->mad + IB_MGMT_RMPP_HDR, buf + IB_MGMT_RMPP_HDR,
- msg->hdr_len - IB_MGMT_RMPP_HDR))
- return -EFAULT;
-
- /* All headers are in place. Copy data segments. */
- for (seg = 1, left = msg->data_len, buf += msg->hdr_len; left > 0;
- seg++, left -= msg->seg_size, buf += msg->seg_size) {
- if (copy_from_user(ib_get_rmpp_segment(msg, seg), buf,
- min(left, msg->seg_size)))
- return -EFAULT;
- }
- return 0;
-}
-
-static int same_destination(struct ib_user_mad_hdr *hdr1,
- struct ib_user_mad_hdr *hdr2)
-{
- if (!hdr1->grh_present && !hdr2->grh_present)
- return (hdr1->lid == hdr2->lid);
-
- if (hdr1->grh_present && hdr2->grh_present)
- return !memcmp(hdr1->gid, hdr2->gid, 16);
-
- return 0;
-}
-
-static int is_duplicate(struct ib_umad_file *file,
- struct ib_umad_packet *packet)
-{
- struct ib_umad_packet *sent_packet;
- struct ib_mad_hdr *sent_hdr, *hdr;
-
- hdr = (struct ib_mad_hdr *) packet->mad.data;
- list_for_each_entry(sent_packet, &file->send_list, list) {
- sent_hdr = (struct ib_mad_hdr *) sent_packet->mad.data;
-
- if ((hdr->tid != sent_hdr->tid) ||
- (hdr->mgmt_class != sent_hdr->mgmt_class))
- continue;
-
- /*
- * No need to be overly clever here. If two new operations have
- * the same TID, reject the second as a duplicate. This is more
- * restrictive than required by the spec.
- */
- if (!ib_response_mad((struct ib_mad *) hdr)) {
- if (!ib_response_mad((struct ib_mad *) sent_hdr))
- return 1;
- continue;
- } else if (!ib_response_mad((struct ib_mad *) sent_hdr))
- continue;
-
- if (same_destination(&packet->mad.hdr, &sent_packet->mad.hdr))
- return 1;
- }
-
- return 0;
-}
-
-static ssize_t ib_umad_write(struct file *filp, const char __user *buf,
- size_t count, loff_t *pos)
-{
- struct ib_umad_file *file = filp->private_data;
- struct ib_umad_packet *packet;
- struct ib_mad_agent *agent;
- struct ib_ah_attr ah_attr;
- struct ib_ah *ah;
- struct ib_rmpp_mad *rmpp_mad;
- __be64 *tid;
- int ret, data_len, hdr_len, copy_offset, rmpp_active;
-
- if (count < hdr_size(file) + IB_MGMT_RMPP_HDR)
- return -EINVAL;
-
- packet = kzalloc(sizeof *packet + IB_MGMT_RMPP_HDR, GFP_KERNEL);
- if (!packet)
- return -ENOMEM;
-
- if (copy_from_user(&packet->mad, buf, hdr_size(file))) {
- ret = -EFAULT;
- goto err;
- }
-
- if (packet->mad.hdr.id >= IB_UMAD_MAX_AGENTS) {
- ret = -EINVAL;
- goto err;
- }
-
- buf += hdr_size(file);
-
- if (copy_from_user(packet->mad.data, buf, IB_MGMT_RMPP_HDR)) {
- ret = -EFAULT;
- goto err;
- }
-
- mutex_lock(&file->mutex);
-
- agent = __get_agent(file, packet->mad.hdr.id);
- if (!agent) {
- ret = -EINVAL;
- goto err_up;
- }
-
- memset(&ah_attr, 0, sizeof ah_attr);
- ah_attr.dlid = be16_to_cpu(packet->mad.hdr.lid);
- ah_attr.sl = packet->mad.hdr.sl;
- ah_attr.src_path_bits = packet->mad.hdr.path_bits;
- ah_attr.port_num = file->port->port_num;
- if (packet->mad.hdr.grh_present) {
- ah_attr.ah_flags = IB_AH_GRH;
- memcpy(ah_attr.grh.dgid.raw, packet->mad.hdr.gid, 16);
- ah_attr.grh.sgid_index = packet->mad.hdr.gid_index;
- ah_attr.grh.flow_label = be32_to_cpu(packet->mad.hdr.flow_label);
- ah_attr.grh.hop_limit = packet->mad.hdr.hop_limit;
- ah_attr.grh.traffic_class = packet->mad.hdr.traffic_class;
- }
-
- ah = ib_create_ah(agent->qp->pd, &ah_attr);
- if (IS_ERR(ah)) {
- ret = PTR_ERR(ah);
- goto err_up;
- }
-
- rmpp_mad = (struct ib_rmpp_mad *) packet->mad.data;
- hdr_len = ib_get_mad_data_offset(rmpp_mad->mad_hdr.mgmt_class);
- if (!ib_is_mad_class_rmpp(rmpp_mad->mad_hdr.mgmt_class)) {
- copy_offset = IB_MGMT_MAD_HDR;
- rmpp_active = 0;
- } else {
- copy_offset = IB_MGMT_RMPP_HDR;
- rmpp_active = ib_get_rmpp_flags(&rmpp_mad->rmpp_hdr) &
- IB_MGMT_RMPP_FLAG_ACTIVE;
- }
-
- data_len = count - hdr_size(file) - hdr_len;
- packet->msg = ib_create_send_mad(agent,
- be32_to_cpu(packet->mad.hdr.qpn),
- packet->mad.hdr.pkey_index, rmpp_active,
- hdr_len, data_len, GFP_KERNEL);
- if (IS_ERR(packet->msg)) {
- ret = PTR_ERR(packet->msg);
- goto err_ah;
- }
-
- packet->msg->ah = ah;
- packet->msg->timeout_ms = packet->mad.hdr.timeout_ms;
- packet->msg->retries = packet->mad.hdr.retries;
- packet->msg->context[0] = packet;
-
- /* Copy MAD header. Any RMPP header is already in place. */
- memcpy(packet->msg->mad, packet->mad.data, IB_MGMT_MAD_HDR);
-
- if (!rmpp_active) {
- if (copy_from_user(packet->msg->mad + copy_offset,
- buf + copy_offset,
- hdr_len + data_len - copy_offset)) {
- ret = -EFAULT;
- goto err_msg;
- }
- } else {
- ret = copy_rmpp_mad(packet->msg, buf);
- if (ret)
- goto err_msg;
- }
-
- /*
- * Set the high-order part of the transaction ID to make MADs from
- * different agents unique, and allow routing responses back to the
- * original requestor.
- */
- if (!ib_response_mad(packet->msg->mad)) {
- tid = &((struct ib_mad_hdr *) packet->msg->mad)->tid;
- *tid = cpu_to_be64(((u64) agent->hi_tid) << 32 |
- (be64_to_cpup(tid) & 0xffffffff));
- rmpp_mad->mad_hdr.tid = *tid;
- }
-
- spin_lock_irq(&file->send_lock);
- ret = is_duplicate(file, packet);
- if (!ret)
- list_add_tail(&packet->list, &file->send_list);
- spin_unlock_irq(&file->send_lock);
- if (ret) {
- ret = -EINVAL;
- goto err_msg;
- }
-
- ret = ib_post_send_mad(packet->msg, NULL);
- if (ret)
- goto err_send;
-
- mutex_unlock(&file->mutex);
- return count;
-
-err_send:
- dequeue_send(file, packet);
-err_msg:
- ib_free_send_mad(packet->msg);
-err_ah:
- ib_destroy_ah(ah);
-err_up:
- mutex_unlock(&file->mutex);
-err:
- kfree(packet);
- return ret;
-}
-
-static unsigned int ib_umad_poll(struct file *filp, struct poll_table_struct *wait)
-{
- struct ib_umad_file *file = filp->private_data;
-
- /* we will always be able to post a MAD send */
- unsigned int mask = POLLOUT | POLLWRNORM;
-
- poll_wait(filp, &file->recv_wait, wait);
-
- if (!list_empty(&file->recv_list))
- mask |= POLLIN | POLLRDNORM;
-
- return mask;
-}
-
-static int ib_umad_reg_agent(struct ib_umad_file *file, void __user *arg,
- int compat_method_mask)
-{
- struct ib_user_mad_reg_req ureq;
- struct ib_mad_reg_req req;
- struct ib_mad_agent *agent = NULL;
- int agent_id;
- int ret;
-
- mutex_lock(&file->port->file_mutex);
- mutex_lock(&file->mutex);
-
- if (!file->port->ib_dev) {
- ret = -EPIPE;
- goto out;
- }
-
- if (copy_from_user(&ureq, arg, sizeof ureq)) {
- ret = -EFAULT;
- goto out;
- }
-
- if (ureq.qpn != 0 && ureq.qpn != 1) {
- ret = -EINVAL;
- goto out;
- }
-
- for (agent_id = 0; agent_id < IB_UMAD_MAX_AGENTS; ++agent_id)
- if (!__get_agent(file, agent_id))
- goto found;
-
- ret = -ENOMEM;
- goto out;
-
-found:
- if (ureq.mgmt_class) {
- req.mgmt_class = ureq.mgmt_class;
- req.mgmt_class_version = ureq.mgmt_class_version;
- memcpy(req.oui, ureq.oui, sizeof req.oui);
-
- if (compat_method_mask) {
- u32 *umm = (u32 *) ureq.method_mask;
- int i;
-
- for (i = 0; i < BITS_TO_LONGS(IB_MGMT_MAX_METHODS); ++i)
- req.method_mask[i] =
- umm[i * 2] | ((u64) umm[i * 2 + 1] << 32);
- } else
- memcpy(req.method_mask, ureq.method_mask,
- sizeof req.method_mask);
- }
-
- agent = ib_register_mad_agent(file->port->ib_dev, file->port->port_num,
- ureq.qpn ? IB_QPT_GSI : IB_QPT_SMI,
- ureq.mgmt_class ? &req : NULL,
- ureq.rmpp_version,
- send_handler, recv_handler, file);
- if (IS_ERR(agent)) {
- ret = PTR_ERR(agent);
- agent = NULL;
- goto out;
- }
-
- if (put_user(agent_id,
- (u32 __user *) (arg + offsetof(struct ib_user_mad_reg_req, id)))) {
- ret = -EFAULT;
- goto out;
- }
-
- if (!file->already_used) {
- file->already_used = 1;
- if (!file->use_pkey_index) {
- printk(KERN_WARNING "user_mad: process %s did not enable "
- "P_Key index support.\n", curthread->td_proc->p_comm);
- printk(KERN_WARNING "user_mad: Documentation/infiniband/user_mad.txt "
- "has info on the new ABI.\n");
- }
- }
-
- file->agent[agent_id] = agent;
- ret = 0;
-
-out:
- mutex_unlock(&file->mutex);
-
- if (ret && agent)
- ib_unregister_mad_agent(agent);
-
- mutex_unlock(&file->port->file_mutex);
-
- return ret;
-}
-
-static int ib_umad_unreg_agent(struct ib_umad_file *file, u32 __user *arg)
-{
- struct ib_mad_agent *agent = NULL;
- u32 id;
- int ret = 0;
-
- if (get_user(id, arg))
- return -EFAULT;
-
- mutex_lock(&file->port->file_mutex);
- mutex_lock(&file->mutex);
-
- if (id >= IB_UMAD_MAX_AGENTS || !__get_agent(file, id)) {
- ret = -EINVAL;
- goto out;
- }
-
- agent = file->agent[id];
- file->agent[id] = NULL;
-
-out:
- mutex_unlock(&file->mutex);
-
- if (agent)
- ib_unregister_mad_agent(agent);
-
- mutex_unlock(&file->port->file_mutex);
-
- return ret;
-}
-
-static long ib_umad_enable_pkey(struct ib_umad_file *file)
-{
- int ret = 0;
-
- mutex_lock(&file->mutex);
- if (file->already_used)
- ret = -EINVAL;
- else
- file->use_pkey_index = 1;
- mutex_unlock(&file->mutex);
-
- return ret;
-}
-
-static long ib_umad_ioctl(struct file *filp, unsigned int cmd,
- unsigned long arg)
-{
- switch (cmd) {
- case IB_USER_MAD_REGISTER_AGENT:
- return ib_umad_reg_agent(filp->private_data, (void __user *) arg, 0);
- case IB_USER_MAD_UNREGISTER_AGENT:
- return ib_umad_unreg_agent(filp->private_data, (__u32 __user *) arg);
- case IB_USER_MAD_ENABLE_PKEY:
- return ib_umad_enable_pkey(filp->private_data);
- default:
- return -ENOIOCTLCMD;
- }
-}
-
-#ifdef CONFIG_COMPAT
-static long ib_umad_compat_ioctl(struct file *filp, unsigned int cmd,
- unsigned long arg)
-{
- switch (cmd) {
- case IB_USER_MAD_REGISTER_AGENT:
- return ib_umad_reg_agent(filp->private_data, compat_ptr(arg), 1);
- case IB_USER_MAD_UNREGISTER_AGENT:
- return ib_umad_unreg_agent(filp->private_data, compat_ptr(arg));
- case IB_USER_MAD_ENABLE_PKEY:
- return ib_umad_enable_pkey(filp->private_data);
- default:
- return -ENOIOCTLCMD;
- }
-}
-#endif
-
-/*
- * ib_umad_open() does not need the BKL:
- *
- * - the ib_umad_port structures are properly reference counted, and
- * everything else is purely local to the file being created, so
- * races against other open calls are not a problem;
- * - the ioctl method does not affect any global state outside of the
- * file structure being operated on;
- */
-static int ib_umad_open(struct inode *inode, struct file *filp)
-{
- struct ib_umad_port *port;
- struct ib_umad_file *file;
- int ret;
-
- port = get_port(inode->i_cdev->si_drv1);
- if (!port)
- return -ENXIO;
-
- mutex_lock(&port->file_mutex);
-
- if (!port->ib_dev) {
- release_port(port);
- ret = -ENXIO;
- goto out;
- }
-
- file = kzalloc(sizeof *file, GFP_KERNEL);
- if (!file) {
- release_port(port);
- ret = -ENOMEM;
- goto out;
- }
-
- mutex_init(&file->mutex);
- spin_lock_init(&file->send_lock);
- INIT_LIST_HEAD(&file->recv_list);
- INIT_LIST_HEAD(&file->send_list);
- init_waitqueue_head(&file->recv_wait);
-
- file->port = port;
- file->filp = filp;
- filp->private_data = file;
-
- list_add_tail(&file->port_list, &port->file_list);
-
- ret = nonseekable_open(inode, filp);
-
-out:
- mutex_unlock(&port->file_mutex);
- return ret;
-}
-
-static int ib_umad_close(struct inode *inode, struct file *filp)
-{
- struct ib_umad_file *file = filp->private_data;
- struct ib_umad_port *port = file->port;
- struct ib_umad_packet *packet, *tmp;
- int already_dead;
- int i;
-
- mutex_lock(&file->port->file_mutex);
- mutex_lock(&file->mutex);
-
- already_dead = file->agents_dead;
- file->agents_dead = 1;
-
- list_for_each_entry_safe(packet, tmp, &file->recv_list, list) {
- if (packet->recv_wc)
- ib_free_recv_mad(packet->recv_wc);
- kfree(packet);
- }
-
- list_del(&file->port_list);
-
- mutex_unlock(&file->mutex);
-
- if (!already_dead)
- for (i = 0; i < IB_UMAD_MAX_AGENTS; ++i)
- if (file->agent[i])
- ib_unregister_mad_agent(file->agent[i]);
-
- mutex_unlock(&file->port->file_mutex);
-
- kfree(file);
- release_port(port);
-
- return 0;
-}
-
-static const struct file_operations umad_fops = {
- .owner = THIS_MODULE,
- .read = ib_umad_read,
- .write = ib_umad_write,
- .poll = ib_umad_poll,
- .unlocked_ioctl = ib_umad_ioctl,
-#ifdef CONFIG_COMPAT
- .compat_ioctl = ib_umad_compat_ioctl,
-#endif
- .open = ib_umad_open,
- .release = ib_umad_close,
- .llseek = no_llseek,
-};
-
-static int ib_umad_sm_open(struct inode *inode, struct file *filp)
-{
- struct ib_umad_port *port;
- struct ib_port_modify props = {
- .set_port_cap_mask = IB_PORT_SM
- };
- int ret;
-
- port = get_port(inode->i_cdev->si_drv1);
- if (!port)
- return -ENXIO;
-
- if (filp->f_flags & O_NONBLOCK) {
- if (down_trylock(&port->sm_sem)) {
- ret = -EAGAIN;
- goto fail;
- }
- } else {
- if (down_interruptible(&port->sm_sem)) {
- ret = -ERESTARTSYS;
- goto fail;
- }
- }
-
- ret = ib_modify_port(port->ib_dev, port->port_num, 0, &props);
- if (ret) {
- up(&port->sm_sem);
- goto fail;
- }
-
- filp->private_data = port;
-
- return nonseekable_open(inode, filp);
-
-fail:
- release_port(port);
- return ret;
-}
-
-static int ib_umad_sm_close(struct inode *inode, struct file *filp)
-{
- struct ib_umad_port *port = filp->private_data;
- struct ib_port_modify props = {
- .clr_port_cap_mask = IB_PORT_SM
- };
- int ret = 0;
-
- mutex_lock(&port->file_mutex);
- if (port->ib_dev)
- ret = ib_modify_port(port->ib_dev, port->port_num, 0, &props);
- mutex_unlock(&port->file_mutex);
-
- up(&port->sm_sem);
-
- release_port(port);
-
- return ret;
-}
-
-static const struct file_operations umad_sm_fops = {
- .owner = THIS_MODULE,
- .open = ib_umad_sm_open,
- .release = ib_umad_sm_close,
- .llseek = no_llseek,
-};
-
-static struct ib_client umad_client = {
- .name = "umad",
- .add = ib_umad_add_one,
- .remove = ib_umad_remove_one
-};
-
-static ssize_t show_ibdev(struct device *dev, struct device_attribute *attr,
- char *buf)
-{
- struct ib_umad_port *port = dev_get_drvdata(dev);
-
- if (!port)
- return -ENODEV;
-
- return sprintf(buf, "%s\n", port->ib_dev->name);
-}
-static DEVICE_ATTR(ibdev, S_IRUGO, show_ibdev, NULL);
-
-static ssize_t show_port(struct device *dev, struct device_attribute *attr,
- char *buf)
-{
- struct ib_umad_port *port = dev_get_drvdata(dev);
-
- if (!port)
- return -ENODEV;
-
- return sprintf(buf, "%d\n", port->port_num);
-}
-static DEVICE_ATTR(port, S_IRUGO, show_port, NULL);
-
-static ssize_t show_abi_version(struct class *class, struct class_attribute *attr, char *buf)
-{
- return sprintf(buf, "%d\n", IB_USER_MAD_ABI_VERSION);
-}
-static CLASS_ATTR(abi_version, S_IRUGO, show_abi_version, NULL);
-
-static dev_t overflow_maj;
-static int find_overflow_devnum(void)
-{
- int ret;
-
- if (!overflow_maj) {
- ret = alloc_chrdev_region(&overflow_maj, 0, IB_UMAD_MAX_PORTS * 2,
- "infiniband_mad");
- if (ret) {
- printk(KERN_ERR "user_mad: couldn't register dynamic device number\n");
- return ret;
- }
- }
-
- ret = find_first_zero_bit(overflow_map, IB_UMAD_MAX_PORTS);
- if (ret >= IB_UMAD_MAX_PORTS)
- return -1;
-
- return ret;
-}
-
-static int ib_umad_init_port(struct ib_device *device, int port_num,
- struct ib_umad_port *port)
-{
- int devnum;
- dev_t base;
-
- spin_lock(&port_lock);
- devnum = find_first_zero_bit(dev_map, IB_UMAD_MAX_PORTS);
- if (devnum >= IB_UMAD_MAX_PORTS) {
- spin_unlock(&port_lock);
- devnum = find_overflow_devnum();
- if (devnum < 0)
- return -1;
-
- spin_lock(&port_lock);
- port->dev_num = devnum + IB_UMAD_MAX_PORTS;
- base = devnum + overflow_maj;
- set_bit(devnum, overflow_map);
- } else {
- port->dev_num = devnum;
- base = devnum + base_dev;
- set_bit(devnum, dev_map);
- }
- spin_unlock(&port_lock);
-
- port->ib_dev = device;
- port->port_num = port_num;
- sema_init(&port->sm_sem, 1);
- mutex_init(&port->file_mutex);
- INIT_LIST_HEAD(&port->file_list);
-
- port->cdev = cdev_alloc();
- if (!port->cdev)
- goto err_cdev_c;
-
- port->cdev->ops = &umad_fops;
- port->cdev->owner = THIS_MODULE;
- kobject_set_name(&port->cdev->kobj, "umad%d", port->dev_num);
- if (cdev_add(port->cdev, base, 1))
- goto err_cdev;
-
- port->dev = device_create(umad_class, device->dma_device,
- port->cdev->dev, port,
- "umad%d", port->dev_num);
- if (IS_ERR(port->dev))
- goto err_cdev;
-
- if (device_create_file(port->dev, &dev_attr_ibdev))
- goto err_dev;
- if (device_create_file(port->dev, &dev_attr_port))
- goto err_dev;
-
- base += IB_UMAD_MAX_PORTS;
- port->sm_cdev = cdev_alloc();
- if (!port->sm_cdev)
- goto err_dev;
-
- port->sm_cdev->ops = &umad_sm_fops;
- port->sm_cdev->owner = THIS_MODULE;
- kobject_set_name(&port->sm_cdev->kobj, "issm%d", port->dev_num);
- if (cdev_add(port->sm_cdev, base, 1))
- goto err_sm_cdev;
-
- port->sm_dev = device_create(umad_class, device->dma_device,
- port->sm_cdev->dev, port,
- "issm%d", port->dev_num);
- if (IS_ERR(port->sm_dev))
- goto err_sm_cdev;
-
- if (device_create_file(port->sm_dev, &dev_attr_ibdev))
- goto err_sm_dev;
- if (device_create_file(port->sm_dev, &dev_attr_port))
- goto err_sm_dev;
-
- return 0;
-
-err_sm_dev:
- device_destroy(umad_class, port->sm_cdev->dev);
-
-err_sm_cdev:
- cdev_del(port->sm_cdev);
-
-err_dev:
- device_destroy(umad_class, port->cdev->dev);
-
-err_cdev:
- cdev_del(port->cdev);
-err_cdev_c:
- if (port->dev_num < IB_UMAD_MAX_PORTS)
- clear_bit(devnum, dev_map);
- else
- clear_bit(devnum, overflow_map);
-
- return -1;
-}
-
-static void ib_umad_kill_port(struct ib_umad_port *port)
-{
- struct ib_umad_file *file;
- int id;
-
- dev_set_drvdata(port->dev, NULL);
- dev_set_drvdata(port->sm_dev, NULL);
-
- device_destroy(umad_class, port->cdev->dev);
- device_destroy(umad_class, port->sm_cdev->dev);
-
- mutex_lock(&port->file_mutex);
-
- port->ib_dev = NULL;
-
- list_for_each_entry(file, &port->file_list, port_list) {
- mutex_lock(&file->mutex);
- file->agents_dead = 1;
- mutex_unlock(&file->mutex);
-
- for (id = 0; id < IB_UMAD_MAX_AGENTS; ++id)
- if (file->agent[id])
- ib_unregister_mad_agent(file->agent[id]);
- }
-
- mutex_unlock(&port->file_mutex);
-}
-
-static void ib_umad_add_one(struct ib_device *device)
-{
- struct ib_umad_device *umad_dev;
- int s, e, i;
-
- if (rdma_node_get_transport(device->node_type) != RDMA_TRANSPORT_IB)
- return;
-
- if (device->node_type == RDMA_NODE_IB_SWITCH)
- s = e = 0;
- else {
- s = 1;
- e = device->phys_port_cnt;
- }
-
- umad_dev = kzalloc(sizeof *umad_dev +
- (e - s + 1) * sizeof (struct ib_umad_port),
- GFP_KERNEL);
- if (!umad_dev)
- return;
-
- kref_init(&umad_dev->ref);
-
- umad_dev->start_port = s;
- umad_dev->end_port = e;
-
- for (i = 0; i <= e - s; ++i)
- insert_port(&umad_dev->port[i]);
-
- for (i = s; i <= e; ++i) {
- umad_dev->port[i - s].umad_dev = umad_dev;
-
- if (ib_umad_init_port(device, i, &umad_dev->port[i - s]))
- goto err;
- }
-
- ib_set_client_data(device, &umad_client, umad_dev);
-
- return;
-
-err:
- while (--i >= s)
- ib_umad_kill_port(&umad_dev->port[i - s]);
-
- put_umad_dev(&umad_dev->ref);
-}
-
-static void ib_umad_remove_one(struct ib_device *device)
-{
- struct ib_umad_device *umad_dev = ib_get_client_data(device, &umad_client);
- int i;
-
- if (!umad_dev)
- return;
-
- for (i = 0; i <= umad_dev->end_port - umad_dev->start_port; ++i)
- ib_umad_kill_port(&umad_dev->port[i]);
-
- put_umad_dev(&umad_dev->ref);
-}
-
-static char *umad_devnode(struct device *dev, umode_t *mode)
-{
- return kasprintf(GFP_KERNEL, "infiniband/%s", dev_name(dev));
-}
-
-static int __init ib_umad_init(void)
-{
- int ret;
-
- INIT_LIST_HEAD(&ports_list);
-
- ret = register_chrdev_region(base_dev, IB_UMAD_MAX_PORTS * 2,
- "infiniband_mad");
- if (ret) {
- printk(KERN_ERR "user_mad: couldn't register device number\n");
- goto out;
- }
-
- umad_class = class_create(THIS_MODULE, "infiniband_mad");
- if (IS_ERR(umad_class)) {
- ret = PTR_ERR(umad_class);
- printk(KERN_ERR "user_mad: couldn't create class infiniband_mad\n");
- goto out_chrdev;
- }
-
- umad_class->devnode = umad_devnode;
-
- ret = class_create_file(umad_class, &class_attr_abi_version);
- if (ret) {
- printk(KERN_ERR "user_mad: couldn't create abi_version attribute\n");
- goto out_class;
- }
-
- ret = ib_register_client(&umad_client);
- if (ret) {
- printk(KERN_ERR "user_mad: couldn't register ib_umad client\n");
- goto out_class;
- }
-
- return 0;
-
-out_class:
- class_destroy(umad_class);
-
-out_chrdev:
- unregister_chrdev_region(base_dev, IB_UMAD_MAX_PORTS * 2);
-
-out:
- return ret;
-}
-
-static void __exit ib_umad_cleanup(void)
-{
- ib_unregister_client(&umad_client);
- class_destroy(umad_class);
- unregister_chrdev_region(base_dev, IB_UMAD_MAX_PORTS * 2);
- if (overflow_maj)
- unregister_chrdev_region(overflow_maj, IB_UMAD_MAX_PORTS * 2);
-}
-
-module_init(ib_umad_init);
-module_exit(ib_umad_cleanup);
diff --git a/sys/ofed/drivers/infiniband/core/uverbs.h b/sys/ofed/drivers/infiniband/core/uverbs.h
index 8ca6498..436047e 100644
--- a/sys/ofed/drivers/infiniband/core/uverbs.h
+++ b/sys/ofed/drivers/infiniband/core/uverbs.h
@@ -42,13 +42,29 @@
#include <linux/mutex.h>
#include <linux/completion.h>
#include <linux/cdev.h>
+#include <linux/srcu.h>
+#include <linux/rcupdate.h>
#include <linux/rbtree.h>
#include <rdma/ib_verbs.h>
-#include <rdma/ib_verbs_exp.h>
#include <rdma/ib_umem.h>
#include <rdma/ib_user_verbs.h>
-#include <rdma/ib_user_verbs_exp.h>
+
+#define INIT_UDATA(udata, ibuf, obuf, ilen, olen) \
+ do { \
+ (udata)->inbuf = (const void __user *) (ibuf); \
+ (udata)->outbuf = (void __user *) (obuf); \
+ (udata)->inlen = (ilen); \
+ (udata)->outlen = (olen); \
+ } while (0)
+
+#define INIT_UDATA_BUF_OR_NULL(udata, ibuf, obuf, ilen, olen) \
+ do { \
+ (udata)->inbuf = (ilen) ? (const void __user *) (ibuf) : NULL; \
+ (udata)->outbuf = (olen) ? (void __user *) (obuf) : NULL; \
+ (udata)->inlen = (ilen); \
+ (udata)->outlen = (olen); \
+ } while (0)
/*
* Our lifetime rules for these structs are the following:
@@ -72,20 +88,24 @@
*/
struct ib_uverbs_device {
- struct kref ref;
+ atomic_t refcount;
int num_comp_vectors;
struct completion comp;
struct device *dev;
- struct ib_device *ib_dev;
+ struct ib_device __rcu *ib_dev;
int devnum;
struct cdev cdev;
struct rb_root xrcd_tree;
struct mutex xrcd_tree_mutex;
+ struct kobject kobj;
+ struct srcu_struct disassociate_srcu;
+ struct mutex lists_mutex; /* protect lists */
+ struct list_head uverbs_file_list;
+ struct list_head uverbs_events_file_list;
};
struct ib_uverbs_event_file {
struct kref ref;
- struct file *filp;
int is_async;
struct ib_uverbs_file *uverbs_file;
spinlock_t lock;
@@ -93,15 +113,19 @@ struct ib_uverbs_event_file {
wait_queue_head_t poll_wait;
struct fasync_struct *async_queue;
struct list_head event_list;
+ struct list_head list;
};
struct ib_uverbs_file {
struct kref ref;
struct mutex mutex;
+ struct mutex cleanup_mutex; /* protect cleanup */
struct ib_uverbs_device *device;
struct ib_ucontext *ucontext;
struct ib_event_handler event_handler;
struct ib_uverbs_event_file *async_file;
+ struct list_head list;
+ int is_closed;
};
struct ib_uverbs_event {
@@ -142,6 +166,10 @@ struct ib_uqp_object {
struct ib_uxrcd_object *uxrcd;
};
+struct ib_uwq_object {
+ struct ib_uevent_object uevent;
+};
+
struct ib_ucq_object {
struct ib_uobject uobject;
struct ib_uverbs_file *uverbs_file;
@@ -151,10 +179,6 @@ struct ib_ucq_object {
u32 async_events_reported;
};
-struct ib_udct_object {
- struct ib_uobject uobject;
-};
-
extern spinlock_t ib_uverbs_idr_lock;
extern struct idr ib_uverbs_pd_idr;
extern struct idr ib_uverbs_mr_idr;
@@ -165,12 +189,15 @@ extern struct idr ib_uverbs_qp_idr;
extern struct idr ib_uverbs_srq_idr;
extern struct idr ib_uverbs_xrcd_idr;
extern struct idr ib_uverbs_rule_idr;
-extern struct idr ib_uverbs_dct_idr;
+extern struct idr ib_uverbs_wq_idr;
+extern struct idr ib_uverbs_rwq_ind_tbl_idr;
void idr_remove_uobj(struct idr *idp, struct ib_uobject *uobj);
struct file *ib_uverbs_alloc_event_file(struct ib_uverbs_file *uverbs_file,
+ struct ib_device *ib_dev,
int is_async);
+void ib_uverbs_free_async_event_file(struct ib_uverbs_file *uverbs_file);
struct ib_uverbs_event_file *ib_uverbs_lookup_comp_file(int fd);
void ib_uverbs_release_ucq(struct ib_uverbs_file *file,
@@ -182,11 +209,14 @@ void ib_uverbs_release_uevent(struct ib_uverbs_file *file,
void ib_uverbs_comp_handler(struct ib_cq *cq, void *cq_context);
void ib_uverbs_cq_event_handler(struct ib_event *event, void *context_ptr);
void ib_uverbs_qp_event_handler(struct ib_event *event, void *context_ptr);
+void ib_uverbs_wq_event_handler(struct ib_event *event, void *context_ptr);
void ib_uverbs_srq_event_handler(struct ib_event *event, void *context_ptr);
void ib_uverbs_event_handler(struct ib_event_handler *handler,
struct ib_event *event);
void ib_uverbs_dealloc_xrcd(struct ib_uverbs_device *dev, struct ib_xrcd *xrcd);
+int uverbs_dealloc_mw(struct ib_mw *mw);
+
struct ib_uverbs_flow_spec {
union {
union {
@@ -198,14 +228,15 @@ struct ib_uverbs_flow_spec {
};
};
struct ib_uverbs_flow_spec_eth eth;
- struct ib_uverbs_flow_spec_ib ib;
struct ib_uverbs_flow_spec_ipv4 ipv4;
struct ib_uverbs_flow_spec_tcp_udp tcp_udp;
+ struct ib_uverbs_flow_spec_ipv6 ipv6;
};
};
#define IB_UVERBS_DECLARE_CMD(name) \
ssize_t ib_uverbs_##name(struct ib_uverbs_file *file, \
+ struct ib_device *ib_dev, \
const char __user *buf, int in_len, \
int out_len)
@@ -215,6 +246,7 @@ IB_UVERBS_DECLARE_CMD(query_port);
IB_UVERBS_DECLARE_CMD(alloc_pd);
IB_UVERBS_DECLARE_CMD(dealloc_pd);
IB_UVERBS_DECLARE_CMD(reg_mr);
+IB_UVERBS_DECLARE_CMD(rereg_mr);
IB_UVERBS_DECLARE_CMD(dereg_mr);
IB_UVERBS_DECLARE_CMD(alloc_mw);
IB_UVERBS_DECLARE_CMD(dealloc_mw);
@@ -245,25 +277,20 @@ IB_UVERBS_DECLARE_CMD(open_xrcd);
IB_UVERBS_DECLARE_CMD(close_xrcd);
#define IB_UVERBS_DECLARE_EX_CMD(name) \
- int ib_uverbs_ex_##name(struct ib_uverbs_file *file,\
- struct ib_udata *ucore, \
+ int ib_uverbs_ex_##name(struct ib_uverbs_file *file, \
+ struct ib_device *ib_dev, \
+ struct ib_udata *ucore, \
struct ib_udata *uhw)
-#define IB_UVERBS_DECLARE_EXP_CMD(name) \
- ssize_t ib_uverbs_exp_##name(struct ib_uverbs_file *file, \
- struct ib_udata *ucore, \
- struct ib_udata *uhw)
-
IB_UVERBS_DECLARE_EX_CMD(create_flow);
IB_UVERBS_DECLARE_EX_CMD(destroy_flow);
-
-IB_UVERBS_DECLARE_EXP_CMD(create_qp);
-IB_UVERBS_DECLARE_EXP_CMD(modify_cq);
-IB_UVERBS_DECLARE_EXP_CMD(modify_qp);
-IB_UVERBS_DECLARE_EXP_CMD(create_cq);
-IB_UVERBS_DECLARE_EXP_CMD(query_device);
-IB_UVERBS_DECLARE_EXP_CMD(create_dct);
-IB_UVERBS_DECLARE_EXP_CMD(destroy_dct);
-IB_UVERBS_DECLARE_EXP_CMD(query_dct);
+IB_UVERBS_DECLARE_EX_CMD(query_device);
+IB_UVERBS_DECLARE_EX_CMD(create_cq);
+IB_UVERBS_DECLARE_EX_CMD(create_qp);
+IB_UVERBS_DECLARE_EX_CMD(create_wq);
+IB_UVERBS_DECLARE_EX_CMD(modify_wq);
+IB_UVERBS_DECLARE_EX_CMD(destroy_wq);
+IB_UVERBS_DECLARE_EX_CMD(create_rwq_ind_table);
+IB_UVERBS_DECLARE_EX_CMD(destroy_rwq_ind_table);
#endif /* UVERBS_H */
diff --git a/sys/ofed/drivers/infiniband/core/uverbs_cmd.c b/sys/ofed/drivers/infiniband/core/uverbs_cmd.c
deleted file mode 100644
index f3a78ce..0000000
--- a/sys/ofed/drivers/infiniband/core/uverbs_cmd.c
+++ /dev/null
@@ -1,3924 +0,0 @@
-/*
- * Copyright (c) 2005 Topspin Communications. All rights reserved.
- * Copyright (c) 2005, 2006, 2007 Cisco Systems. All rights reserved.
- * Copyright (c) 2005 PathScale, Inc. All rights reserved.
- * Copyright (c) 2006 Mellanox Technologies. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-#define LINUXKPI_PARAM_PREFIX ibcore_
-
-#include <linux/file.h>
-#include <linux/fs.h>
-#include <linux/slab.h>
-#include <linux/moduleparam.h>
-#include <linux/rbtree.h>
-#include <linux/lockdep.h>
-#include <rdma/ib_addr.h>
-
-#include <asm/uaccess.h>
-#include <asm/fcntl.h>
-#include <sys/priv.h>
-
-#include "uverbs.h"
-
-static int disable_raw_qp_enforcement;
-module_param_named(disable_raw_qp_enforcement, disable_raw_qp_enforcement, int,
- 0444);
-MODULE_PARM_DESC(disable_raw_qp_enforcement, "Disable RAW QP enforcement for "
- "being opened by root (default: 0)");
-
-struct uverbs_lock_class {
- struct lock_class_key key;
- char name[16];
-};
-
-static struct uverbs_lock_class pd_lock_class = { .name = "PD-uobj" };
-static struct uverbs_lock_class mr_lock_class = { .name = "MR-uobj" };
-static struct uverbs_lock_class mw_lock_class = { .name = "MW-uobj" };
-static struct uverbs_lock_class cq_lock_class = { .name = "CQ-uobj" };
-static struct uverbs_lock_class qp_lock_class = { .name = "QP-uobj" };
-static struct uverbs_lock_class ah_lock_class = { .name = "AH-uobj" };
-static struct uverbs_lock_class srq_lock_class = { .name = "SRQ-uobj" };
-static struct uverbs_lock_class xrcd_lock_class = { .name = "XRCD-uobj" };
-static struct uverbs_lock_class dct_lock_class = { .name = "DCT-uobj" };
-
-static int uverbs_copy_from_udata(void *dest, struct ib_udata *udata, size_t len)
-{
- return copy_from_user(dest, udata->inbuf, len) ? -EFAULT : 0;
-}
-
-static int uverbs_copy_to_udata(struct ib_udata *udata, void *src, size_t len)
-{
- return copy_to_user(udata->outbuf, src, len) ? -EFAULT : 0;
-}
-
-static struct ib_udata_ops uverbs_copy = {
- .copy_from = uverbs_copy_from_udata,
- .copy_to = uverbs_copy_to_udata
-};
-
-#define INIT_UDATA(udata, ibuf, obuf, ilen, olen) \
- do { \
- (udata)->ops = &uverbs_copy; \
- (udata)->inbuf = (void __user *) (ibuf); \
- (udata)->outbuf = (void __user *) (obuf); \
- (udata)->inlen = (ilen); \
- (udata)->outlen = (olen); \
- } while (0)
-
-enum uverbs_cmd_type {
- IB_USER_VERBS_CMD_BASIC,
- IB_USER_VERBS_CMD_EXTENDED
-};
-
-/*
- * The ib_uobject locking scheme is as follows:
- *
- * - ib_uverbs_idr_lock protects the uverbs idrs themselves, so it
- * needs to be held during all idr operations. When an object is
- * looked up, a reference must be taken on the object's kref before
- * dropping this lock.
- *
- * - Each object also has an rwsem. This rwsem must be held for
- * reading while an operation that uses the object is performed.
- * For example, while registering an MR, the associated PD's
- * uobject.mutex must be held for reading. The rwsem must be held
- * for writing while initializing or destroying an object.
- *
- * - In addition, each object has a "live" flag. If this flag is not
- * set, then lookups of the object will fail even if it is found in
- * the idr. This handles a reader that blocks and does not acquire
- * the rwsem until after the object is destroyed. The destroy
- * operation will set the live flag to 0 and then drop the rwsem;
- * this will allow the reader to acquire the rwsem, see that the
- * live flag is 0, and then drop the rwsem and its reference to
- * object. The underlying storage will not be freed until the last
- * reference to the object is dropped.
- */
-
-static void init_uobj(struct ib_uobject *uobj, u64 user_handle,
- struct ib_ucontext *context, struct uverbs_lock_class *c)
-{
- uobj->user_handle = user_handle;
- uobj->context = context;
- kref_init(&uobj->ref);
- init_rwsem(&uobj->mutex);
- lockdep_set_class_and_name(&uobj->mutex, &c->key, c->name);
- uobj->live = 0;
-}
-
-static void release_uobj(struct kref *kref)
-{
- kfree(container_of(kref, struct ib_uobject, ref));
-}
-
-static void put_uobj(struct ib_uobject *uobj)
-{
- kref_put(&uobj->ref, release_uobj);
-}
-
-static void put_uobj_read(struct ib_uobject *uobj)
-{
- up_read(&uobj->mutex);
- put_uobj(uobj);
-}
-
-static void put_uobj_write(struct ib_uobject *uobj)
-{
- up_write(&uobj->mutex);
- put_uobj(uobj);
-}
-
-static int idr_add_uobj(struct idr *idr, struct ib_uobject *uobj)
-{
- int ret;
-
-retry:
- if (!idr_pre_get(idr, GFP_KERNEL))
- return -ENOMEM;
-
- spin_lock(&ib_uverbs_idr_lock);
- ret = idr_get_new(idr, uobj, &uobj->id);
- spin_unlock(&ib_uverbs_idr_lock);
-
- if (ret == -EAGAIN)
- goto retry;
-
- return ret;
-}
-
-void idr_remove_uobj(struct idr *idr, struct ib_uobject *uobj)
-{
- spin_lock(&ib_uverbs_idr_lock);
- idr_remove(idr, uobj->id);
- spin_unlock(&ib_uverbs_idr_lock);
-}
-
-static struct ib_uobject *__idr_get_uobj(struct idr *idr, int id,
- struct ib_ucontext *context)
-{
- struct ib_uobject *uobj;
-
- spin_lock(&ib_uverbs_idr_lock);
- uobj = idr_find(idr, id);
- if (uobj) {
- if (uobj->context == context)
- kref_get(&uobj->ref);
- else
- uobj = NULL;
- }
- spin_unlock(&ib_uverbs_idr_lock);
-
- return uobj;
-}
-
-static struct ib_uobject *idr_read_uobj(struct idr *idr, int id,
- struct ib_ucontext *context, int nested)
-{
- struct ib_uobject *uobj;
-
- uobj = __idr_get_uobj(idr, id, context);
- if (!uobj)
- return NULL;
-
- if (nested)
- down_read_nested(&uobj->mutex, SINGLE_DEPTH_NESTING);
- else
- down_read(&uobj->mutex);
- if (!uobj->live) {
- put_uobj_read(uobj);
- return NULL;
- }
-
- return uobj;
-}
-
-static struct ib_uobject *idr_write_uobj(struct idr *idr, int id,
- struct ib_ucontext *context)
-{
- struct ib_uobject *uobj;
-
- uobj = __idr_get_uobj(idr, id, context);
- if (!uobj)
- return NULL;
-
- down_write(&uobj->mutex);
- if (!uobj->live) {
- put_uobj_write(uobj);
- return NULL;
- }
-
- return uobj;
-}
-
-static void *idr_read_obj(struct idr *idr, int id, struct ib_ucontext *context,
- int nested)
-{
- struct ib_uobject *uobj;
-
- uobj = idr_read_uobj(idr, id, context, nested);
- return uobj ? uobj->object : NULL;
-}
-
-static struct ib_pd *idr_read_pd(int pd_handle, struct ib_ucontext *context)
-{
- return idr_read_obj(&ib_uverbs_pd_idr, pd_handle, context, 0);
-}
-
-static void put_pd_read(struct ib_pd *pd)
-{
- put_uobj_read(pd->uobject);
-}
-
-static struct ib_cq *idr_read_cq(int cq_handle, struct ib_ucontext *context, int nested)
-{
- return idr_read_obj(&ib_uverbs_cq_idr, cq_handle, context, nested);
-}
-
-static void put_cq_read(struct ib_cq *cq)
-{
- put_uobj_read(cq->uobject);
-}
-
-static struct ib_ah *idr_read_ah(int ah_handle, struct ib_ucontext *context)
-{
- return idr_read_obj(&ib_uverbs_ah_idr, ah_handle, context, 0);
-}
-
-static void put_ah_read(struct ib_ah *ah)
-{
- put_uobj_read(ah->uobject);
-}
-
-static struct ib_qp *idr_read_qp(int qp_handle, struct ib_ucontext *context)
-{
- return idr_read_obj(&ib_uverbs_qp_idr, qp_handle, context, 0);
-}
-
-static struct ib_qp *idr_write_qp(int qp_handle, struct ib_ucontext *context)
-{
- struct ib_uobject *uobj;
-
- uobj = idr_write_uobj(&ib_uverbs_qp_idr, qp_handle, context);
- return uobj ? uobj->object : NULL;
-}
-
-static void put_qp_read(struct ib_qp *qp)
-{
- put_uobj_read(qp->uobject);
-}
-
-static void put_qp_write(struct ib_qp *qp)
-{
- put_uobj_write(qp->uobject);
-}
-
-static struct ib_dct *idr_read_dct(int dct_handle, struct ib_ucontext *context)
-{
- return idr_read_obj(&ib_uverbs_dct_idr, dct_handle, context, 0);
-}
-
-static void put_dct_read(struct ib_dct *dct)
-{
- put_uobj_read(dct->uobject);
-}
-
-static struct ib_srq *idr_read_srq(int srq_handle, struct ib_ucontext *context)
-{
- return idr_read_obj(&ib_uverbs_srq_idr, srq_handle, context, 0);
-}
-
-static void put_srq_read(struct ib_srq *srq)
-{
- put_uobj_read(srq->uobject);
-}
-
-static struct ib_xrcd *idr_read_xrcd(int xrcd_handle, struct ib_ucontext *context,
- struct ib_uobject **uobj)
-{
- *uobj = idr_read_uobj(&ib_uverbs_xrcd_idr, xrcd_handle, context, 0);
- return *uobj ? (*uobj)->object : NULL;
-}
-
-static void put_xrcd_read(struct ib_uobject *uobj)
-{
- put_uobj_read(uobj);
-}
-
-ssize_t ib_uverbs_get_context(struct ib_uverbs_file *file,
- const char __user *buf,
- int in_len, int out_len)
-{
- struct ib_uverbs_get_context cmd;
- struct ib_uverbs_get_context_resp resp;
- struct ib_udata udata;
- struct ib_device *ibdev = file->device->ib_dev;
- struct ib_ucontext *ucontext;
- struct file *filp;
- int ret;
-
- if (out_len < sizeof resp)
- return -ENOSPC;
-
- if (copy_from_user(&cmd, buf, sizeof cmd))
- return -EFAULT;
-
- mutex_lock(&file->mutex);
-
- if (file->ucontext) {
- ret = -EINVAL;
- goto err;
- }
-
- INIT_UDATA(&udata, buf + sizeof cmd,
- (unsigned long) cmd.response + sizeof resp,
- in_len - sizeof cmd, out_len - sizeof resp);
-
- ucontext = ibdev->alloc_ucontext(ibdev, &udata);
- if (IS_ERR(ucontext)) {
- ret = PTR_ERR(ucontext);
- goto err;
- }
-
- ucontext->device = ibdev;
- INIT_LIST_HEAD(&ucontext->pd_list);
- INIT_LIST_HEAD(&ucontext->mr_list);
- INIT_LIST_HEAD(&ucontext->mw_list);
- INIT_LIST_HEAD(&ucontext->cq_list);
- INIT_LIST_HEAD(&ucontext->qp_list);
- INIT_LIST_HEAD(&ucontext->srq_list);
- INIT_LIST_HEAD(&ucontext->ah_list);
- INIT_LIST_HEAD(&ucontext->xrcd_list);
- INIT_LIST_HEAD(&ucontext->rule_list);
- INIT_LIST_HEAD(&ucontext->dct_list);
- ucontext->closing = 0;
- ucontext->peer_mem_private_data = NULL;
- ucontext->peer_mem_name = NULL;
-
- resp.num_comp_vectors = file->device->num_comp_vectors;
-
- ret = get_unused_fd();
- if (ret < 0)
- goto err_free;
- resp.async_fd = ret;
-
- filp = ib_uverbs_alloc_event_file(file, 1);
- if (IS_ERR(filp)) {
- ret = PTR_ERR(filp);
- goto err_fd;
- }
-
- file->async_file = filp->private_data;
-
- INIT_IB_EVENT_HANDLER(&file->event_handler, file->device->ib_dev,
- ib_uverbs_event_handler);
- ret = ib_register_event_handler(&file->event_handler);
- if (ret)
- goto err_file;
-
- if (copy_to_user((void __user *) (unsigned long) cmd.response,
- &resp, sizeof resp)) {
- ret = -EFAULT;
- goto err_file;
- }
- kref_get(&file->async_file->ref);
- kref_get(&file->ref);
- file->ucontext = ucontext;
-
- fd_install(resp.async_fd, filp);
-
- mutex_unlock(&file->mutex);
-
- return in_len;
-
-err_file:
- fput(filp);
-
-err_fd:
- put_unused_fd(resp.async_fd);
-
-err_free:
- ibdev->dealloc_ucontext(ucontext);
-
-err:
- mutex_unlock(&file->mutex);
- return ret;
-}
-
-static void ib_uverbs_query_device_assign(
- struct ib_uverbs_query_device_resp *resp,
- struct ib_device_attr *attr,
- struct ib_uverbs_file *file)
-{
- memset(resp, 0, sizeof(*resp));
-
- resp->fw_ver = attr->fw_ver;
- resp->node_guid = file->device->ib_dev->node_guid;
- resp->sys_image_guid = attr->sys_image_guid;
- resp->max_mr_size = attr->max_mr_size;
- resp->page_size_cap = attr->page_size_cap;
- resp->vendor_id = attr->vendor_id;
- resp->vendor_part_id = attr->vendor_part_id;
- resp->hw_ver = attr->hw_ver;
- resp->max_qp = attr->max_qp;
- resp->max_qp_wr = attr->max_qp_wr;
- resp->device_cap_flags = attr->device_cap_flags;
- resp->max_sge = attr->max_sge;
- resp->max_sge_rd = attr->max_sge_rd;
- resp->max_cq = attr->max_cq;
- resp->max_cqe = attr->max_cqe;
- resp->max_mr = attr->max_mr;
- resp->max_pd = attr->max_pd;
- resp->max_qp_rd_atom = attr->max_qp_rd_atom;
- resp->max_ee_rd_atom = attr->max_ee_rd_atom;
- resp->max_res_rd_atom = attr->max_res_rd_atom;
- resp->max_qp_init_rd_atom = attr->max_qp_init_rd_atom;
- resp->max_ee_init_rd_atom = attr->max_ee_init_rd_atom;
- resp->atomic_cap = attr->atomic_cap;
- resp->max_ee = attr->max_ee;
- resp->max_rdd = attr->max_rdd;
- resp->max_mw = attr->max_mw;
- resp->max_raw_ipv6_qp = attr->max_raw_ipv6_qp;
- resp->max_raw_ethy_qp = attr->max_raw_ethy_qp;
- resp->max_mcast_grp = attr->max_mcast_grp;
- resp->max_mcast_qp_attach = attr->max_mcast_qp_attach;
- resp->max_total_mcast_qp_attach = attr->max_total_mcast_qp_attach;
- resp->max_ah = attr->max_ah;
- resp->max_fmr = attr->max_fmr;
- resp->max_map_per_fmr = attr->max_map_per_fmr;
- resp->max_srq = attr->max_srq;
- resp->max_srq_wr = attr->max_srq_wr;
- resp->max_srq_sge = attr->max_srq_sge;
- resp->max_pkeys = attr->max_pkeys;
- resp->local_ca_ack_delay = attr->local_ca_ack_delay;
- resp->phys_port_cnt = file->device->ib_dev->phys_port_cnt;
-}
-
-ssize_t ib_uverbs_query_device(struct ib_uverbs_file *file,
- const char __user *buf,
- int in_len, int out_len)
-{
- struct ib_uverbs_query_device cmd;
- struct ib_uverbs_query_device_resp resp;
- struct ib_device_attr attr;
- int ret;
-
- if (out_len < sizeof resp)
- return -ENOSPC;
-
- if (copy_from_user(&cmd, buf, sizeof cmd))
- return -EFAULT;
-
- ret = ib_query_device(file->device->ib_dev, &attr);
- if (ret)
- return ret;
-
- ib_uverbs_query_device_assign(&resp, &attr, file);
-
- if (copy_to_user((void __user *)(unsigned long) cmd.response,
- &resp, sizeof(resp)))
- return -EFAULT;
-
- return in_len;
-}
-
-ssize_t ib_uverbs_query_port(struct ib_uverbs_file *file,
- const char __user *buf,
- int in_len, int out_len)
-{
- struct ib_uverbs_query_port cmd;
- struct ib_uverbs_query_port_resp resp;
- struct ib_port_attr attr;
- int ret;
-
- if (out_len < sizeof resp)
- return -ENOSPC;
-
- if (copy_from_user(&cmd, buf, sizeof cmd))
- return -EFAULT;
-
- ret = ib_query_port(file->device->ib_dev, cmd.port_num, &attr);
- if (ret)
- return ret;
-
- memset(&resp, 0, sizeof resp);
-
- resp.state = attr.state;
- resp.max_mtu = attr.max_mtu;
- resp.active_mtu = attr.active_mtu;
- resp.gid_tbl_len = attr.gid_tbl_len;
- resp.port_cap_flags = attr.port_cap_flags;
- resp.max_msg_sz = attr.max_msg_sz;
- resp.bad_pkey_cntr = attr.bad_pkey_cntr;
- resp.qkey_viol_cntr = attr.qkey_viol_cntr;
- resp.pkey_tbl_len = attr.pkey_tbl_len;
- resp.lid = attr.lid;
- resp.sm_lid = attr.sm_lid;
- resp.lmc = attr.lmc;
- resp.max_vl_num = attr.max_vl_num;
- resp.sm_sl = attr.sm_sl;
- resp.subnet_timeout = attr.subnet_timeout;
- resp.init_type_reply = attr.init_type_reply;
- resp.active_width = attr.active_width;
- resp.active_speed = attr.active_speed;
- resp.phys_state = attr.phys_state;
- resp.link_layer = rdma_port_get_link_layer(file->device->ib_dev,
- cmd.port_num);
-
- if (copy_to_user((void __user *) (unsigned long) cmd.response,
- &resp, sizeof resp))
- return -EFAULT;
-
- return in_len;
-}
-
-ssize_t ib_uverbs_alloc_pd(struct ib_uverbs_file *file,
- const char __user *buf,
- int in_len, int out_len)
-{
- struct ib_uverbs_alloc_pd cmd;
- struct ib_uverbs_alloc_pd_resp resp;
- struct ib_udata udata;
- struct ib_uobject *uobj;
- struct ib_pd *pd;
- int ret;
-
- if (out_len < sizeof resp)
- return -ENOSPC;
-
- if (copy_from_user(&cmd, buf, sizeof cmd))
- return -EFAULT;
-
- INIT_UDATA(&udata, buf + sizeof cmd,
- (unsigned long) cmd.response + sizeof resp,
- in_len - sizeof cmd, out_len - sizeof resp);
-
- uobj = kmalloc(sizeof *uobj, GFP_KERNEL);
- if (!uobj)
- return -ENOMEM;
-
- init_uobj(uobj, 0, file->ucontext, &pd_lock_class);
- down_write(&uobj->mutex);
-
- pd = file->device->ib_dev->alloc_pd(file->device->ib_dev,
- file->ucontext, &udata);
- if (IS_ERR(pd)) {
- ret = PTR_ERR(pd);
- goto err;
- }
-
- pd->device = file->device->ib_dev;
- pd->uobject = uobj;
- atomic_set(&pd->usecnt, 0);
-
- uobj->object = pd;
- ret = idr_add_uobj(&ib_uverbs_pd_idr, uobj);
- if (ret)
- goto err_idr;
-
- memset(&resp, 0, sizeof resp);
- resp.pd_handle = uobj->id;
-
- if (copy_to_user((void __user *) (unsigned long) cmd.response,
- &resp, sizeof resp)) {
- ret = -EFAULT;
- goto err_copy;
- }
-
- mutex_lock(&file->mutex);
- list_add_tail(&uobj->list, &file->ucontext->pd_list);
- mutex_unlock(&file->mutex);
-
- uobj->live = 1;
-
- up_write(&uobj->mutex);
-
- return in_len;
-
-err_copy:
- idr_remove_uobj(&ib_uverbs_pd_idr, uobj);
-
-err_idr:
- ib_dealloc_pd(pd);
-
-err:
- put_uobj_write(uobj);
- return ret;
-}
-
-ssize_t ib_uverbs_dealloc_pd(struct ib_uverbs_file *file,
- const char __user *buf,
- int in_len, int out_len)
-{
- struct ib_uverbs_dealloc_pd cmd;
- struct ib_uobject *uobj;
- int ret;
-
- if (copy_from_user(&cmd, buf, sizeof cmd))
- return -EFAULT;
-
- uobj = idr_write_uobj(&ib_uverbs_pd_idr, cmd.pd_handle, file->ucontext);
- if (!uobj)
- return -EINVAL;
-
- ret = ib_dealloc_pd(uobj->object);
- if (!ret)
- uobj->live = 0;
-
- put_uobj_write(uobj);
-
- if (ret)
- return ret;
-
- idr_remove_uobj(&ib_uverbs_pd_idr, uobj);
-
- mutex_lock(&file->mutex);
- list_del(&uobj->list);
- mutex_unlock(&file->mutex);
-
- put_uobj(uobj);
-
- return in_len;
-}
-
-struct xrcd_table_entry {
- struct rb_node node;
- struct ib_xrcd *xrcd;
- struct inode *inode;
-};
-
-static int xrcd_table_insert(struct ib_uverbs_device *dev,
- struct inode *inode,
- struct ib_xrcd *xrcd)
-{
- struct xrcd_table_entry *entry, *scan;
- struct rb_node **p = &dev->xrcd_tree.rb_node;
- struct rb_node *parent = NULL;
-
- entry = kmalloc(sizeof *entry, GFP_KERNEL);
- if (!entry)
- return -ENOMEM;
-
- entry->xrcd = xrcd;
- entry->inode = inode;
-
- while (*p) {
- parent = *p;
- scan = rb_entry(parent, struct xrcd_table_entry, node);
-
- if (inode < scan->inode) {
- p = &(*p)->rb_left;
- } else if (inode > scan->inode) {
- p = &(*p)->rb_right;
- } else {
- kfree(entry);
- return -EEXIST;
- }
- }
-
- rb_link_node(&entry->node, parent, p);
- rb_insert_color(&entry->node, &dev->xrcd_tree);
- igrab(inode);
- return 0;
-}
-
-static struct xrcd_table_entry *xrcd_table_search(struct ib_uverbs_device *dev,
- struct inode *inode)
-{
- struct xrcd_table_entry *entry;
- struct rb_node *p = dev->xrcd_tree.rb_node;
-
- while (p) {
- entry = rb_entry(p, struct xrcd_table_entry, node);
-
- if (inode < entry->inode)
- p = p->rb_left;
- else if (inode > entry->inode)
- p = p->rb_right;
- else
- return entry;
- }
-
- return NULL;
-}
-
-static struct ib_xrcd *find_xrcd(struct ib_uverbs_device *dev, struct inode *inode)
-{
- struct xrcd_table_entry *entry;
-
- entry = xrcd_table_search(dev, inode);
- if (!entry)
- return NULL;
-
- return entry->xrcd;
-}
-
-static void xrcd_table_delete(struct ib_uverbs_device *dev,
- struct inode *inode)
-{
- struct xrcd_table_entry *entry;
-
- entry = xrcd_table_search(dev, inode);
- if (entry) {
- iput(inode);
- rb_erase(&entry->node, &dev->xrcd_tree);
- kfree(entry);
- }
-}
-
-ssize_t ib_uverbs_open_xrcd(struct ib_uverbs_file *file,
- const char __user *buf, int in_len,
- int out_len)
-{
- struct ib_uverbs_open_xrcd cmd;
- struct ib_uverbs_open_xrcd_resp resp;
- struct ib_udata udata;
- struct ib_uxrcd_object *obj;
- struct ib_xrcd *xrcd = NULL;
- struct fd f = {NULL};
- struct inode *inode = NULL;
- int ret = 0;
- int new_xrcd = 0;
-
- if (out_len < sizeof resp)
- return -ENOSPC;
-
- if (copy_from_user(&cmd, buf, sizeof cmd))
- return -EFAULT;
-
- INIT_UDATA(&udata, buf + sizeof cmd,
- (unsigned long) cmd.response + sizeof resp,
- in_len - sizeof cmd, out_len - sizeof resp);
-
- mutex_lock(&file->device->xrcd_tree_mutex);
-
- if (cmd.fd != -1) {
- /* search for file descriptor */
- f = fdget(cmd.fd);
- if (!f.file) {
- ret = -EBADF;
- goto err_tree_mutex_unlock;
- }
-
- inode = f.file->f_dentry->d_inode;
- xrcd = find_xrcd(file->device, inode);
- if (!xrcd && !(cmd.oflags & O_CREAT)) {
- /* no file descriptor. Need CREATE flag */
- ret = -EAGAIN;
- goto err_tree_mutex_unlock;
- }
-
- if (xrcd && cmd.oflags & O_EXCL) {
- ret = -EINVAL;
- goto err_tree_mutex_unlock;
- }
- }
-
- obj = kmalloc(sizeof *obj, GFP_KERNEL);
- if (!obj) {
- ret = -ENOMEM;
- goto err_tree_mutex_unlock;
- }
-
- init_uobj(&obj->uobject, 0, file->ucontext, &xrcd_lock_class);
-
- down_write(&obj->uobject.mutex);
-
- if (!xrcd) {
- xrcd = file->device->ib_dev->alloc_xrcd(file->device->ib_dev,
- file->ucontext, &udata);
- if (IS_ERR(xrcd)) {
- ret = PTR_ERR(xrcd);
- goto err;
- }
-
- xrcd->inode = inode;
- xrcd->device = file->device->ib_dev;
- atomic_set(&xrcd->usecnt, 0);
- mutex_init(&xrcd->tgt_qp_mutex);
- INIT_LIST_HEAD(&xrcd->tgt_qp_list);
- new_xrcd = 1;
- }
-
- atomic_set(&obj->refcnt, 0);
- obj->uobject.object = xrcd;
- ret = idr_add_uobj(&ib_uverbs_xrcd_idr, &obj->uobject);
- if (ret)
- goto err_idr;
-
- memset(&resp, 0, sizeof resp);
- resp.xrcd_handle = obj->uobject.id;
-
- if (inode) {
- if (new_xrcd) {
- /* create new inode/xrcd table entry */
- ret = xrcd_table_insert(file->device, inode, xrcd);
- if (ret)
- goto err_insert_xrcd;
- }
- atomic_inc(&xrcd->usecnt);
- }
-
- if (copy_to_user((void __user *) (unsigned long) cmd.response,
- &resp, sizeof resp)) {
- ret = -EFAULT;
- goto err_copy;
- }
-
- if (f.file)
- fdput(f);
-
- mutex_lock(&file->mutex);
- list_add_tail(&obj->uobject.list, &file->ucontext->xrcd_list);
- mutex_unlock(&file->mutex);
-
- obj->uobject.live = 1;
- up_write(&obj->uobject.mutex);
-
- mutex_unlock(&file->device->xrcd_tree_mutex);
- return in_len;
-
-err_copy:
- if (inode) {
- if (new_xrcd)
- xrcd_table_delete(file->device, inode);
- atomic_dec(&xrcd->usecnt);
- }
-
-err_insert_xrcd:
- idr_remove_uobj(&ib_uverbs_xrcd_idr, &obj->uobject);
-
-err_idr:
- ib_dealloc_xrcd(xrcd);
-
-err:
- put_uobj_write(&obj->uobject);
-
-err_tree_mutex_unlock:
- if (f.file)
- fdput(f);
-
- mutex_unlock(&file->device->xrcd_tree_mutex);
-
- return ret;
-}
-
-ssize_t ib_uverbs_close_xrcd(struct ib_uverbs_file *file,
- const char __user *buf, int in_len,
- int out_len)
-{
- struct ib_uverbs_close_xrcd cmd;
- struct ib_uobject *uobj;
- struct ib_xrcd *xrcd = NULL;
- struct inode *inode = NULL;
- struct ib_uxrcd_object *obj;
- int live;
- int ret = 0;
-
- if (copy_from_user(&cmd, buf, sizeof cmd))
- return -EFAULT;
-
- mutex_lock(&file->device->xrcd_tree_mutex);
- uobj = idr_write_uobj(&ib_uverbs_xrcd_idr, cmd.xrcd_handle, file->ucontext);
- if (!uobj) {
- ret = -EINVAL;
- goto out;
- }
-
- xrcd = uobj->object;
- inode = xrcd->inode;
- obj = container_of(uobj, struct ib_uxrcd_object, uobject);
- if (atomic_read(&obj->refcnt)) {
- put_uobj_write(uobj);
- ret = -EBUSY;
- goto out;
- }
-
- if (!inode || atomic_dec_and_test(&xrcd->usecnt)) {
- ret = ib_dealloc_xrcd(uobj->object);
- if (!ret)
- uobj->live = 0;
- }
-
- live = uobj->live;
- if (inode && ret)
- atomic_inc(&xrcd->usecnt);
-
- put_uobj_write(uobj);
-
- if (ret)
- goto out;
-
- if (inode && !live)
- xrcd_table_delete(file->device, inode);
-
- idr_remove_uobj(&ib_uverbs_xrcd_idr, uobj);
- mutex_lock(&file->mutex);
- list_del(&uobj->list);
- mutex_unlock(&file->mutex);
-
- put_uobj(uobj);
- ret = in_len;
-
-out:
- mutex_unlock(&file->device->xrcd_tree_mutex);
- return ret;
-}
-
-void ib_uverbs_dealloc_xrcd(struct ib_uverbs_device *dev,
- struct ib_xrcd *xrcd)
-{
- struct inode *inode;
-
- inode = xrcd->inode;
- if (inode && !atomic_dec_and_test(&xrcd->usecnt))
- return;
-
- ib_dealloc_xrcd(xrcd);
-
- if (inode)
- xrcd_table_delete(dev, inode);
-}
-
-ssize_t ib_uverbs_reg_mr(struct ib_uverbs_file *file,
- const char __user *buf, int in_len,
- int out_len)
-{
- struct ib_uverbs_reg_mr cmd;
- struct ib_uverbs_reg_mr_resp resp;
- struct ib_udata udata;
- struct ib_uobject *uobj;
- struct ib_pd *pd;
- struct ib_mr *mr;
- int ret;
-
- if (out_len < sizeof resp)
- return -ENOSPC;
-
- if (copy_from_user(&cmd, buf, sizeof cmd))
- return -EFAULT;
-
- INIT_UDATA(&udata, buf + sizeof cmd,
- (unsigned long) cmd.response + sizeof resp,
- in_len - sizeof cmd, out_len - sizeof resp);
-
- if ((cmd.start & ~PAGE_MASK) != (cmd.hca_va & ~PAGE_MASK))
- return -EINVAL;
-
- ret = ib_check_mr_access(cmd.access_flags);
- if (ret)
- return ret;
-
- uobj = kmalloc(sizeof *uobj, GFP_KERNEL);
- if (!uobj)
- return -ENOMEM;
-
- init_uobj(uobj, 0, file->ucontext, &mr_lock_class);
- down_write(&uobj->mutex);
-
- pd = idr_read_pd(cmd.pd_handle, file->ucontext);
- if (!pd) {
- ret = -EINVAL;
- goto err_free;
- }
- /* We first get a new "obj id" to be passed later to reg mr for
- further use as mr_id.
- */
- ret = idr_add_uobj(&ib_uverbs_mr_idr, uobj);
- if (ret)
- goto err_put;
-
- mr = pd->device->reg_user_mr(pd, cmd.start, cmd.length, cmd.hca_va,
- cmd.access_flags, &udata, uobj->id);
- if (IS_ERR(mr)) {
- ret = PTR_ERR(mr);
- goto err_remove_uobj;
- }
-
- mr->device = pd->device;
- mr->pd = pd;
- mr->uobject = uobj;
- atomic_inc(&pd->usecnt);
- atomic_set(&mr->usecnt, 0);
-
- uobj->object = mr;
-
- memset(&resp, 0, sizeof resp);
- resp.lkey = mr->lkey;
- resp.rkey = mr->rkey;
- resp.mr_handle = uobj->id;
-
- if (copy_to_user((void __user *) (unsigned long) cmd.response,
- &resp, sizeof resp)) {
- ret = -EFAULT;
- goto err_copy;
- }
-
- put_pd_read(pd);
-
- mutex_lock(&file->mutex);
- list_add_tail(&uobj->list, &file->ucontext->mr_list);
- mutex_unlock(&file->mutex);
-
- uobj->live = 1;
-
- up_write(&uobj->mutex);
-
- return in_len;
-
-err_copy:
- ib_dereg_mr(mr);
-
-err_remove_uobj:
- idr_remove_uobj(&ib_uverbs_mr_idr, uobj);
-
-err_put:
- put_pd_read(pd);
-
-err_free:
- put_uobj_write(uobj);
- return ret;
-}
-
-ssize_t ib_uverbs_dereg_mr(struct ib_uverbs_file *file,
- const char __user *buf, int in_len,
- int out_len)
-{
- struct ib_uverbs_dereg_mr cmd;
- struct ib_mr *mr;
- struct ib_uobject *uobj;
- int ret = -EINVAL;
-
- if (copy_from_user(&cmd, buf, sizeof cmd))
- return -EFAULT;
-
- uobj = idr_write_uobj(&ib_uverbs_mr_idr, cmd.mr_handle, file->ucontext);
- if (!uobj)
- return -EINVAL;
-
- mr = uobj->object;
-
- ret = ib_dereg_mr(mr);
- if (!ret)
- uobj->live = 0;
-
- put_uobj_write(uobj);
-
- if (ret)
- return ret;
-
- idr_remove_uobj(&ib_uverbs_mr_idr, uobj);
-
- mutex_lock(&file->mutex);
- list_del(&uobj->list);
- mutex_unlock(&file->mutex);
-
- put_uobj(uobj);
-
- return in_len;
-}
-
-ssize_t ib_uverbs_alloc_mw(struct ib_uverbs_file *file,
- const char __user *buf, int in_len,
- int out_len)
-{
- struct ib_uverbs_alloc_mw cmd;
- struct ib_uverbs_alloc_mw_resp resp;
- struct ib_uobject *uobj;
- struct ib_pd *pd;
- struct ib_mw *mw;
- int ret;
-
- if (out_len < sizeof(resp))
- return -ENOSPC;
-
- if (copy_from_user(&cmd, buf, sizeof(cmd)))
- return -EFAULT;
-
- uobj = kmalloc(sizeof(*uobj), GFP_KERNEL);
- if (!uobj)
- return -ENOMEM;
-
- init_uobj(uobj, 0, file->ucontext, &mw_lock_class);
- down_write(&uobj->mutex);
-
- pd = idr_read_pd(cmd.pd_handle, file->ucontext);
- if (!pd) {
- ret = -EINVAL;
- goto err_free;
- }
-
- mw = pd->device->alloc_mw(pd, cmd.mw_type);
- if (IS_ERR(mw)) {
- ret = PTR_ERR(mw);
- goto err_put;
- }
-
- mw->device = pd->device;
- mw->pd = pd;
- mw->uobject = uobj;
- atomic_inc(&pd->usecnt);
-
- uobj->object = mw;
- ret = idr_add_uobj(&ib_uverbs_mw_idr, uobj);
- if (ret)
- goto err_unalloc;
-
- memset(&resp, 0, sizeof(resp));
- resp.rkey = mw->rkey;
- resp.mw_handle = uobj->id;
-
- if (copy_to_user((void __user *)(unsigned long)cmd.response,
- &resp, sizeof(resp))) {
- ret = -EFAULT;
- goto err_copy;
- }
-
- put_pd_read(pd);
-
- mutex_lock(&file->mutex);
- list_add_tail(&uobj->list, &file->ucontext->mw_list);
- mutex_unlock(&file->mutex);
-
- uobj->live = 1;
-
- up_write(&uobj->mutex);
-
- return in_len;
-
-err_copy:
- idr_remove_uobj(&ib_uverbs_mw_idr, uobj);
-
-err_unalloc:
- ib_dealloc_mw(mw);
-
-err_put:
- put_pd_read(pd);
-
-err_free:
- put_uobj_write(uobj);
- return ret;
-}
-
-ssize_t ib_uverbs_dealloc_mw(struct ib_uverbs_file *file,
- const char __user *buf, int in_len,
- int out_len)
-{
- struct ib_uverbs_dealloc_mw cmd;
- struct ib_mw *mw;
- struct ib_uobject *uobj;
- int ret = -EINVAL;
-
- if (copy_from_user(&cmd, buf, sizeof(cmd)))
- return -EFAULT;
-
- uobj = idr_write_uobj(&ib_uverbs_mw_idr, cmd.mw_handle, file->ucontext);
- if (!uobj)
- return -EINVAL;
-
- mw = uobj->object;
-
- ret = ib_dealloc_mw(mw);
- if (!ret)
- uobj->live = 0;
-
- put_uobj_write(uobj);
-
- if (ret)
- return ret;
-
- idr_remove_uobj(&ib_uverbs_mw_idr, uobj);
-
- mutex_lock(&file->mutex);
- list_del(&uobj->list);
- mutex_unlock(&file->mutex);
-
- put_uobj(uobj);
-
- return in_len;
-}
-
-ssize_t ib_uverbs_create_comp_channel(struct ib_uverbs_file *file,
- const char __user *buf, int in_len,
- int out_len)
-{
- struct ib_uverbs_create_comp_channel cmd;
- struct ib_uverbs_create_comp_channel_resp resp;
- struct file *filp;
- int ret;
-
- if (out_len < sizeof resp)
- return -ENOSPC;
-
- if (copy_from_user(&cmd, buf, sizeof cmd))
- return -EFAULT;
-
- ret = get_unused_fd();
- if (ret < 0)
- return ret;
- resp.fd = ret;
-
- filp = ib_uverbs_alloc_event_file(file, 0);
- if (IS_ERR(filp)) {
- put_unused_fd(resp.fd);
- return PTR_ERR(filp);
- }
-
- if (copy_to_user((void __user *) (unsigned long) cmd.response,
- &resp, sizeof resp)) {
- put_unused_fd(resp.fd);
- fput(filp);
- return -EFAULT;
- }
-
- fd_install(resp.fd, filp);
- return in_len;
-}
-
-static ssize_t create_cq(struct ib_uverbs_file *file,
- const char __user *buf, int in_len,
- int out_len, void *vcmd, int ex,
- void __user *response)
-{
- struct ib_uverbs_create_cq *cmd;
- struct ib_uverbs_create_cq_ex *cmd_e;
- struct ib_uverbs_create_cq_resp resp;
- struct ib_udata udata;
- struct ib_ucq_object *obj;
- struct ib_uverbs_event_file *ev_file = NULL;
- struct ib_cq *cq;
- struct ib_cq_init_attr attr;
- int cmd_sz;
- int ret;
-
- if (out_len < sizeof resp)
- return -ENOSPC;
-
- cmd = vcmd;
- cmd_e = vcmd;
- cmd_sz = ex ? sizeof(*cmd_e) : sizeof(*cmd);
- INIT_UDATA(&udata, buf + cmd_sz, response + sizeof(resp),
- in_len - sizeof(cmd), out_len - sizeof(resp));
-
- if (cmd->comp_vector >= file->device->num_comp_vectors)
- return -EINVAL;
-
- obj = kmalloc(sizeof *obj, GFP_KERNEL);
- if (!obj)
- return -ENOMEM;
-
- init_uobj(&obj->uobject, cmd->user_handle, file->ucontext,
- &cq_lock_class);
- down_write(&obj->uobject.mutex);
-
- if (cmd->comp_channel >= 0) {
- ev_file = ib_uverbs_lookup_comp_file(cmd->comp_channel);
- if (!ev_file) {
- ret = -EINVAL;
- goto err;
- }
- }
-
- obj->uverbs_file = file;
- obj->comp_events_reported = 0;
- obj->async_events_reported = 0;
- INIT_LIST_HEAD(&obj->comp_list);
- INIT_LIST_HEAD(&obj->async_list);
-
- memset(&attr, 0, sizeof(attr));
- attr.cqe = cmd->cqe;
- attr.comp_vector = cmd->comp_vector;
- if (ex && (cmd_e->comp_mask & IB_UVERBS_CREATE_CQ_EX_CAP_FLAGS))
- attr.flags = cmd_e->create_flags;
- cq = file->device->ib_dev->create_cq(file->device->ib_dev, &attr,
- file->ucontext, &udata);
- if (IS_ERR(cq)) {
- ret = PTR_ERR(cq);
- goto err_file;
- }
-
- cq->device = file->device->ib_dev;
- cq->uobject = &obj->uobject;
- cq->comp_handler = ib_uverbs_comp_handler;
- cq->event_handler = ib_uverbs_cq_event_handler;
- cq->cq_context = ev_file;
- atomic_set(&cq->usecnt, 0);
-
- obj->uobject.object = cq;
- ret = idr_add_uobj(&ib_uverbs_cq_idr, &obj->uobject);
- if (ret)
- goto err_free;
-
- memset(&resp, 0, sizeof resp);
- resp.cq_handle = obj->uobject.id;
- resp.cqe = cq->cqe;
-
- if (copy_to_user(response, &resp, sizeof(resp))) {
- ret = -EFAULT;
- goto err_copy;
- }
-
- mutex_lock(&file->mutex);
- list_add_tail(&obj->uobject.list, &file->ucontext->cq_list);
- mutex_unlock(&file->mutex);
-
- obj->uobject.live = 1;
-
- up_write(&obj->uobject.mutex);
-
- return in_len;
-
-err_copy:
- idr_remove_uobj(&ib_uverbs_cq_idr, &obj->uobject);
-
-err_free:
- ib_destroy_cq(cq);
-
-err_file:
- if (ev_file)
- ib_uverbs_release_ucq(file, ev_file, obj);
-
-err:
- put_uobj_write(&obj->uobject);
- return ret;
-}
-
-ssize_t ib_uverbs_create_cq(struct ib_uverbs_file *file,
- const char __user *buf, int in_len,
- int out_len)
-{
- struct ib_uverbs_create_cq cmd;
-
- if (copy_from_user(&cmd, buf, sizeof(cmd)))
- return -EFAULT;
-
- return create_cq(file, buf, in_len, out_len, &cmd,
- IB_USER_VERBS_CMD_BASIC,
- (void __user *) (unsigned long) cmd.response);
-}
-
-ssize_t ib_uverbs_resize_cq(struct ib_uverbs_file *file,
- const char __user *buf, int in_len,
- int out_len)
-{
- struct ib_uverbs_resize_cq cmd;
- struct ib_uverbs_resize_cq_resp resp;
- struct ib_udata udata;
- struct ib_cq *cq;
- int ret = -EINVAL;
-
- if (copy_from_user(&cmd, buf, sizeof cmd))
- return -EFAULT;
-
- INIT_UDATA(&udata, buf + sizeof cmd,
- (unsigned long) cmd.response + sizeof resp,
- in_len - sizeof cmd, out_len - sizeof resp);
-
- cq = idr_read_cq(cmd.cq_handle, file->ucontext, 0);
- if (!cq)
- return -EINVAL;
-
- ret = cq->device->resize_cq(cq, cmd.cqe, &udata);
- if (ret)
- goto out;
-
- resp.cqe = cq->cqe;
-
- if (copy_to_user((void __user *) (unsigned long) cmd.response,
- &resp, sizeof resp.cqe))
- ret = -EFAULT;
-
-out:
- put_cq_read(cq);
-
- return ret ? ret : in_len;
-}
-
-static int copy_wc_to_user(void __user *dest, struct ib_wc *wc)
-{
- struct ib_uverbs_wc tmp;
-
- tmp.wr_id = wc->wr_id;
- tmp.status = wc->status;
- tmp.opcode = wc->opcode;
- tmp.vendor_err = wc->vendor_err;
- tmp.byte_len = wc->byte_len;
- tmp.ex.imm_data = (__u32 __force) wc->ex.imm_data;
- tmp.qp_num = wc->qp->qp_num;
- tmp.src_qp = wc->src_qp;
- tmp.wc_flags = wc->wc_flags;
- tmp.pkey_index = wc->pkey_index;
- tmp.slid = wc->slid;
- tmp.sl = wc->sl;
- tmp.dlid_path_bits = wc->dlid_path_bits;
- tmp.port_num = wc->port_num;
- tmp.reserved = 0;
-
- if (copy_to_user(dest, &tmp, sizeof tmp))
- return -EFAULT;
-
- return 0;
-}
-
-ssize_t ib_uverbs_poll_cq(struct ib_uverbs_file *file,
- const char __user *buf, int in_len,
- int out_len)
-{
- struct ib_uverbs_poll_cq cmd;
- struct ib_uverbs_poll_cq_resp resp;
- u8 __user *header_ptr;
- u8 __user *data_ptr;
- struct ib_cq *cq;
- struct ib_wc wc;
- int ret;
-
- if (copy_from_user(&cmd, buf, sizeof cmd))
- return -EFAULT;
-
- cq = idr_read_cq(cmd.cq_handle, file->ucontext, 0);
- if (!cq)
- return -EINVAL;
-
- /* we copy a struct ib_uverbs_poll_cq_resp to user space */
- header_ptr = (void __user *)(unsigned long) cmd.response;
- data_ptr = header_ptr + sizeof resp;
-
- memset(&resp, 0, sizeof resp);
- while (resp.count < cmd.ne) {
- ret = ib_poll_cq(cq, 1, &wc);
- if (ret < 0)
- goto out_put;
- if (!ret)
- break;
-
- ret = copy_wc_to_user(data_ptr, &wc);
- if (ret)
- goto out_put;
-
- data_ptr += sizeof(struct ib_uverbs_wc);
- ++resp.count;
- }
-
- if (copy_to_user(header_ptr, &resp, sizeof resp)) {
- ret = -EFAULT;
- goto out_put;
- }
-
- ret = in_len;
-
-out_put:
- put_cq_read(cq);
- return ret;
-}
-
-ssize_t ib_uverbs_req_notify_cq(struct ib_uverbs_file *file,
- const char __user *buf, int in_len,
- int out_len)
-{
- struct ib_uverbs_req_notify_cq cmd;
- struct ib_cq *cq;
-
- if (copy_from_user(&cmd, buf, sizeof cmd))
- return -EFAULT;
-
- cq = idr_read_cq(cmd.cq_handle, file->ucontext, 0);
- if (!cq)
- return -EINVAL;
-
- ib_req_notify_cq(cq, cmd.solicited_only ?
- IB_CQ_SOLICITED : IB_CQ_NEXT_COMP);
-
- put_cq_read(cq);
-
- return in_len;
-}
-
-ssize_t ib_uverbs_destroy_cq(struct ib_uverbs_file *file,
- const char __user *buf, int in_len,
- int out_len)
-{
- struct ib_uverbs_destroy_cq cmd;
- struct ib_uverbs_destroy_cq_resp resp;
- struct ib_uobject *uobj;
- struct ib_cq *cq;
- struct ib_ucq_object *obj;
- struct ib_uverbs_event_file *ev_file;
- int ret = -EINVAL;
-
- if (copy_from_user(&cmd, buf, sizeof cmd))
- return -EFAULT;
-
- uobj = idr_write_uobj(&ib_uverbs_cq_idr, cmd.cq_handle, file->ucontext);
- if (!uobj)
- return -EINVAL;
- cq = uobj->object;
- ev_file = cq->cq_context;
- obj = container_of(cq->uobject, struct ib_ucq_object, uobject);
-
- ret = ib_destroy_cq(cq);
- if (!ret)
- uobj->live = 0;
-
- put_uobj_write(uobj);
-
- if (ret)
- return ret;
-
- idr_remove_uobj(&ib_uverbs_cq_idr, uobj);
-
- mutex_lock(&file->mutex);
- list_del(&uobj->list);
- mutex_unlock(&file->mutex);
-
- ib_uverbs_release_ucq(file, ev_file, obj);
-
- memset(&resp, 0, sizeof resp);
- resp.comp_events_reported = obj->comp_events_reported;
- resp.async_events_reported = obj->async_events_reported;
-
- put_uobj(uobj);
-
- if (copy_to_user((void __user *) (unsigned long) cmd.response,
- &resp, sizeof resp))
- return -EFAULT;
-
- return in_len;
-}
-
-ssize_t ib_uverbs_create_qp(struct ib_uverbs_file *file,
- const char __user *buf, int in_len,
- int out_len)
-{
- void __user *response;
- struct ib_udata udata;
- struct ib_uqp_object *obj;
- struct ib_device *device;
- struct ib_pd *pd = NULL;
- struct ib_xrcd *xrcd = NULL;
- struct ib_uobject *uninitialized_var(xrcd_uobj);
- struct ib_cq *scq = NULL, *rcq = NULL;
- struct ib_srq *srq = NULL;
- struct ib_qp *qp;
- struct ib_qp_init_attr attr;
- int ret;
- union {
- struct ib_uverbs_create_qp basic;
- } cmd_obj;
- struct ib_uverbs_create_qp *cmd;
- size_t cmd_size = 0;
- union {
- struct ib_uverbs_create_qp_resp basic;
- } resp_obj;
- struct ib_uverbs_create_qp_resp *resp;
- size_t resp_size = 0;
-
- cmd_size = sizeof(cmd_obj.basic);
- cmd = &cmd_obj.basic;
-
- resp_size = sizeof(resp_obj.basic);
- resp = &resp_obj.basic;
-
- if (out_len < resp_size)
- return -ENOSPC;
-
- if (copy_from_user(&cmd_obj, buf, cmd_size))
- return -EFAULT;
-
- response = (void __user *) (unsigned long) cmd->response;
-
- if (!disable_raw_qp_enforcement &&
- cmd->qp_type == IB_QPT_RAW_PACKET && priv_check(curthread, PRIV_NET_RAW))
- return -EPERM;
-
- INIT_UDATA(&udata, buf + cmd_size, response + resp_size,
- in_len - cmd_size, out_len - resp_size);
-
- obj = kzalloc(sizeof *obj, GFP_KERNEL);
- if (!obj)
- return -ENOMEM;
-
- init_uobj(&obj->uevent.uobject, cmd->user_handle, file->ucontext, &qp_lock_class);
- down_write(&obj->uevent.uobject.mutex);
-
- if (cmd->qp_type == IB_QPT_XRC_TGT) {
- xrcd = idr_read_xrcd(cmd->pd_handle, file->ucontext, &xrcd_uobj);
- if (!xrcd) {
- ret = -EINVAL;
- goto err_put;
- }
- device = xrcd->device;
- } else {
- if (cmd->qp_type == IB_QPT_XRC_INI) {
- cmd->max_recv_wr = 0;
- cmd->max_recv_sge = 0;
- } else {
- if (cmd->is_srq) {
- srq = idr_read_srq(cmd->srq_handle, file->ucontext);
- if (!srq || srq->srq_type != IB_SRQT_BASIC) {
- ret = -EINVAL;
- goto err_put;
- }
- }
-
- if (cmd->recv_cq_handle != cmd->send_cq_handle) {
- rcq = idr_read_cq(cmd->recv_cq_handle, file->ucontext, 0);
- if (!rcq) {
- ret = -EINVAL;
- goto err_put;
- }
- }
- }
-
- scq = idr_read_cq(cmd->send_cq_handle, file->ucontext, !!rcq);
- rcq = rcq ?: scq;
- pd = idr_read_pd(cmd->pd_handle, file->ucontext);
- if (!pd || !scq) {
- ret = -EINVAL;
- goto err_put;
- }
-
- device = pd->device;
- }
-
- memset(&attr, 0, sizeof attr);
- attr.event_handler = ib_uverbs_qp_event_handler;
- attr.qp_context = file;
- attr.send_cq = scq;
- attr.recv_cq = rcq;
- attr.srq = srq;
- attr.xrcd = xrcd;
- attr.sq_sig_type = cmd->sq_sig_all ? IB_SIGNAL_ALL_WR : IB_SIGNAL_REQ_WR;
- attr.qp_type = cmd->qp_type;
- attr.create_flags = 0;
-
- attr.cap.max_send_wr = cmd->max_send_wr;
- attr.cap.max_recv_wr = cmd->max_recv_wr;
- attr.cap.max_send_sge = cmd->max_send_sge;
- attr.cap.max_recv_sge = cmd->max_recv_sge;
- attr.cap.max_inline_data = cmd->max_inline_data;
-
- obj->uevent.events_reported = 0;
- INIT_LIST_HEAD(&obj->uevent.event_list);
- INIT_LIST_HEAD(&obj->mcast_list);
-
- if (cmd->qp_type == IB_QPT_XRC_TGT)
- qp = ib_create_qp(pd, &attr);
- else
- qp = device->create_qp(pd, &attr, &udata);
-
- if (IS_ERR(qp)) {
- ret = PTR_ERR(qp);
- goto err_put;
- }
-
- if (cmd->qp_type != IB_QPT_XRC_TGT) {
- qp->real_qp = qp;
- qp->device = device;
- qp->pd = pd;
- qp->send_cq = attr.send_cq;
- qp->recv_cq = attr.recv_cq;
- qp->srq = attr.srq;
- qp->event_handler = attr.event_handler;
- qp->qp_context = attr.qp_context;
- qp->qp_type = attr.qp_type;
- atomic_set(&qp->usecnt, 0);
- atomic_inc(&pd->usecnt);
- atomic_inc(&attr.send_cq->usecnt);
- if (attr.recv_cq)
- atomic_inc(&attr.recv_cq->usecnt);
- if (attr.srq)
- atomic_inc(&attr.srq->usecnt);
- }
- qp->uobject = &obj->uevent.uobject;
-
- obj->uevent.uobject.object = qp;
- ret = idr_add_uobj(&ib_uverbs_qp_idr, &obj->uevent.uobject);
- if (ret)
- goto err_destroy;
-
- memset(&resp_obj, 0, sizeof(resp_obj));
- resp->qpn = qp->qp_num;
- resp->qp_handle = obj->uevent.uobject.id;
- resp->max_recv_sge = attr.cap.max_recv_sge;
- resp->max_send_sge = attr.cap.max_send_sge;
- resp->max_recv_wr = attr.cap.max_recv_wr;
- resp->max_send_wr = attr.cap.max_send_wr;
- resp->max_inline_data = attr.cap.max_inline_data;
-
- if (copy_to_user(response, &resp_obj, resp_size)) {
- ret = -EFAULT;
- goto err_copy;
- }
-
- if (xrcd) {
- obj->uxrcd = container_of(xrcd_uobj, struct ib_uxrcd_object, uobject);
- atomic_inc(&obj->uxrcd->refcnt);
- put_xrcd_read(xrcd_uobj);
- }
-
- if (pd)
- put_pd_read(pd);
- if (scq)
- put_cq_read(scq);
- if (rcq && rcq != scq)
- put_cq_read(rcq);
- if (srq)
- put_srq_read(srq);
-
- mutex_lock(&file->mutex);
- list_add_tail(&obj->uevent.uobject.list, &file->ucontext->qp_list);
- mutex_unlock(&file->mutex);
-
- obj->uevent.uobject.live = 1;
-
- up_write(&obj->uevent.uobject.mutex);
-
- return in_len;
-
-err_copy:
- idr_remove_uobj(&ib_uverbs_qp_idr, &obj->uevent.uobject);
-
-err_destroy:
- ib_destroy_qp(qp);
-
-err_put:
- if (xrcd)
- put_xrcd_read(xrcd_uobj);
- if (pd)
- put_pd_read(pd);
- if (scq)
- put_cq_read(scq);
- if (rcq && rcq != scq)
- put_cq_read(rcq);
- if (srq)
- put_srq_read(srq);
-
- put_uobj_write(&obj->uevent.uobject);
- return ret;
-}
-
-ssize_t ib_uverbs_open_qp(struct ib_uverbs_file *file,
- const char __user *buf, int in_len, int out_len)
-{
- struct ib_uverbs_open_qp cmd;
- struct ib_uverbs_create_qp_resp resp;
- struct ib_udata udata;
- struct ib_uqp_object *obj;
- struct ib_xrcd *xrcd;
- struct ib_uobject *uninitialized_var(xrcd_uobj);
- struct ib_qp *qp;
- struct ib_qp_open_attr attr;
- int ret;
-
- if (out_len < sizeof resp)
- return -ENOSPC;
-
- if (copy_from_user(&cmd, buf, sizeof cmd))
- return -EFAULT;
-
- INIT_UDATA(&udata, buf + sizeof cmd,
- (unsigned long) cmd.response + sizeof resp,
- in_len - sizeof cmd, out_len - sizeof resp);
-
- obj = kmalloc(sizeof *obj, GFP_KERNEL);
- if (!obj)
- return -ENOMEM;
-
- init_uobj(&obj->uevent.uobject, cmd.user_handle, file->ucontext, &qp_lock_class);
- down_write(&obj->uevent.uobject.mutex);
-
- xrcd = idr_read_xrcd(cmd.pd_handle, file->ucontext, &xrcd_uobj);
- if (!xrcd) {
- ret = -EINVAL;
- goto err_put;
- }
-
- attr.event_handler = ib_uverbs_qp_event_handler;
- attr.qp_context = file;
- attr.qp_num = cmd.qpn;
- attr.qp_type = cmd.qp_type;
-
- obj->uevent.events_reported = 0;
- INIT_LIST_HEAD(&obj->uevent.event_list);
- INIT_LIST_HEAD(&obj->mcast_list);
-
- qp = ib_open_qp(xrcd, &attr);
- if (IS_ERR(qp)) {
- ret = PTR_ERR(qp);
- goto err_put;
- }
-
- qp->uobject = &obj->uevent.uobject;
-
- obj->uevent.uobject.object = qp;
- ret = idr_add_uobj(&ib_uverbs_qp_idr, &obj->uevent.uobject);
- if (ret)
- goto err_destroy;
-
- memset(&resp, 0, sizeof resp);
- resp.qpn = qp->qp_num;
- resp.qp_handle = obj->uevent.uobject.id;
-
- if (copy_to_user((void __user *) (unsigned long) cmd.response,
- &resp, sizeof resp)) {
- ret = -EFAULT;
- goto err_remove;
- }
-
- obj->uxrcd = container_of(xrcd_uobj, struct ib_uxrcd_object, uobject);
- atomic_inc(&obj->uxrcd->refcnt);
- put_xrcd_read(xrcd_uobj);
-
- mutex_lock(&file->mutex);
- list_add_tail(&obj->uevent.uobject.list, &file->ucontext->qp_list);
- mutex_unlock(&file->mutex);
-
- obj->uevent.uobject.live = 1;
- up_write(&obj->uevent.uobject.mutex);
-
- return in_len;
-
-err_remove:
- idr_remove_uobj(&ib_uverbs_qp_idr, &obj->uevent.uobject);
-
-err_destroy:
- ib_destroy_qp(qp);
-
-err_put:
- put_xrcd_read(xrcd_uobj);
- put_uobj_write(&obj->uevent.uobject);
- return ret;
-}
-
-ssize_t ib_uverbs_query_qp(struct ib_uverbs_file *file,
- const char __user *buf, int in_len,
- int out_len)
-{
- struct ib_uverbs_query_qp cmd;
- struct ib_uverbs_query_qp_resp resp;
- struct ib_qp *qp;
- struct ib_qp_attr *attr;
- struct ib_qp_init_attr *init_attr;
- int ret;
-
- if (copy_from_user(&cmd, buf, sizeof cmd))
- return -EFAULT;
-
- attr = kmalloc(sizeof *attr, GFP_KERNEL);
- init_attr = kmalloc(sizeof *init_attr, GFP_KERNEL);
- if (!attr || !init_attr) {
- ret = -ENOMEM;
- goto out;
- }
-
- qp = idr_read_qp(cmd.qp_handle, file->ucontext);
- if (!qp) {
- ret = -EINVAL;
- goto out;
- }
-
- ret = ib_query_qp(qp, attr, cmd.attr_mask, init_attr);
-
- put_qp_read(qp);
-
- if (ret)
- goto out;
-
- memset(&resp, 0, sizeof resp);
-
- resp.qp_state = attr->qp_state;
- resp.cur_qp_state = attr->cur_qp_state;
- resp.path_mtu = attr->path_mtu;
- resp.path_mig_state = attr->path_mig_state;
- resp.qkey = attr->qkey;
- resp.rq_psn = attr->rq_psn;
- resp.sq_psn = attr->sq_psn;
- resp.dest_qp_num = attr->dest_qp_num;
- resp.qp_access_flags = attr->qp_access_flags;
- resp.pkey_index = attr->pkey_index;
- resp.alt_pkey_index = attr->alt_pkey_index;
- resp.sq_draining = attr->sq_draining;
- resp.max_rd_atomic = attr->max_rd_atomic;
- resp.max_dest_rd_atomic = attr->max_dest_rd_atomic;
- resp.min_rnr_timer = attr->min_rnr_timer;
- resp.port_num = attr->port_num;
- resp.timeout = attr->timeout;
- resp.retry_cnt = attr->retry_cnt;
- resp.rnr_retry = attr->rnr_retry;
- resp.alt_port_num = attr->alt_port_num;
- resp.alt_timeout = attr->alt_timeout;
-
- memcpy(resp.dest.dgid, attr->ah_attr.grh.dgid.raw, 16);
- resp.dest.flow_label = attr->ah_attr.grh.flow_label;
- resp.dest.sgid_index = attr->ah_attr.grh.sgid_index;
- resp.dest.hop_limit = attr->ah_attr.grh.hop_limit;
- resp.dest.traffic_class = attr->ah_attr.grh.traffic_class;
- resp.dest.dlid = attr->ah_attr.dlid;
- resp.dest.sl = attr->ah_attr.sl;
- resp.dest.src_path_bits = attr->ah_attr.src_path_bits;
- resp.dest.static_rate = attr->ah_attr.static_rate;
- resp.dest.is_global = !!(attr->ah_attr.ah_flags & IB_AH_GRH);
- resp.dest.port_num = attr->ah_attr.port_num;
-
- memcpy(resp.alt_dest.dgid, attr->alt_ah_attr.grh.dgid.raw, 16);
- resp.alt_dest.flow_label = attr->alt_ah_attr.grh.flow_label;
- resp.alt_dest.sgid_index = attr->alt_ah_attr.grh.sgid_index;
- resp.alt_dest.hop_limit = attr->alt_ah_attr.grh.hop_limit;
- resp.alt_dest.traffic_class = attr->alt_ah_attr.grh.traffic_class;
- resp.alt_dest.dlid = attr->alt_ah_attr.dlid;
- resp.alt_dest.sl = attr->alt_ah_attr.sl;
- resp.alt_dest.src_path_bits = attr->alt_ah_attr.src_path_bits;
- resp.alt_dest.static_rate = attr->alt_ah_attr.static_rate;
- resp.alt_dest.is_global = !!(attr->alt_ah_attr.ah_flags & IB_AH_GRH);
- resp.alt_dest.port_num = attr->alt_ah_attr.port_num;
-
- resp.max_send_wr = init_attr->cap.max_send_wr;
- resp.max_recv_wr = init_attr->cap.max_recv_wr;
- resp.max_send_sge = init_attr->cap.max_send_sge;
- resp.max_recv_sge = init_attr->cap.max_recv_sge;
- resp.max_inline_data = init_attr->cap.max_inline_data;
- resp.sq_sig_all = init_attr->sq_sig_type == IB_SIGNAL_ALL_WR;
-
- if (copy_to_user((void __user *) (unsigned long) cmd.response,
- &resp, sizeof resp))
- ret = -EFAULT;
-
-out:
- kfree(attr);
- kfree(init_attr);
-
- return ret ? ret : in_len;
-}
-
-/* Remove ignored fields set in the attribute mask */
-static int modify_qp_mask(enum ib_qp_type qp_type, int mask)
-{
- switch (qp_type) {
- case IB_QPT_XRC_INI:
- return mask & ~(IB_QP_MAX_DEST_RD_ATOMIC | IB_QP_MIN_RNR_TIMER);
- case IB_QPT_XRC_TGT:
- return mask & ~(IB_QP_MAX_QP_RD_ATOMIC | IB_QP_RETRY_CNT |
- IB_QP_RNR_RETRY);
- default:
- return mask;
- }
-}
-
-static ssize_t __uverbs_modify_qp(struct ib_uverbs_file *file,
- const char __user *buf, int in_len,
- int out_len,
- enum uverbs_cmd_type cmd_type)
-{
- struct ib_uverbs_modify_qp_ex cmd;
- struct ib_udata udata;
- struct ib_qp *qp;
- struct ib_qp_attr *attr;
- struct ib_qp_attr_ex *attrx;
- int ret;
- void *p;
- union ib_gid sgid;
- union ib_gid *dgid;
- u8 port_num;
-
- if (cmd_type == IB_USER_VERBS_CMD_BASIC) {
- p = &cmd;
- p += sizeof(cmd.comp_mask);
- if (copy_from_user(p, buf,
- sizeof(struct ib_uverbs_modify_qp)))
- return -EFAULT;
- } else {
- if (copy_from_user(&cmd, buf, sizeof(cmd)))
- return -EFAULT;
- }
-
- INIT_UDATA(&udata, buf + sizeof cmd, NULL, in_len - sizeof cmd,
- out_len);
-
- attrx = kzalloc(sizeof(*attrx), GFP_KERNEL);
- if (!attrx)
- return -ENOMEM;
- attr = (struct ib_qp_attr *)attrx;
-
- qp = idr_read_qp(cmd.qp_handle, file->ucontext);
- if (!qp) {
- kfree(attrx);
- return -EINVAL;
- }
-
- attr->qp_state = cmd.qp_state;
- attr->cur_qp_state = cmd.cur_qp_state;
- attr->path_mtu = cmd.path_mtu;
- attr->path_mig_state = cmd.path_mig_state;
- attr->qkey = cmd.qkey;
- attr->rq_psn = cmd.rq_psn;
- attr->sq_psn = cmd.sq_psn;
- attr->dest_qp_num = cmd.dest_qp_num;
- attr->qp_access_flags = cmd.qp_access_flags;
- attr->pkey_index = cmd.pkey_index;
- attr->alt_pkey_index = cmd.alt_pkey_index;
- attr->en_sqd_async_notify = cmd.en_sqd_async_notify;
- attr->max_rd_atomic = cmd.max_rd_atomic;
- attr->max_dest_rd_atomic = cmd.max_dest_rd_atomic;
- attr->min_rnr_timer = cmd.min_rnr_timer;
- attr->port_num = cmd.port_num;
- attr->timeout = cmd.timeout;
- attr->retry_cnt = cmd.retry_cnt;
- attr->rnr_retry = cmd.rnr_retry;
- attr->alt_port_num = cmd.alt_port_num;
- attr->alt_timeout = cmd.alt_timeout;
-
- memcpy(attr->ah_attr.grh.dgid.raw, cmd.dest.dgid, 16);
- attr->ah_attr.grh.flow_label = cmd.dest.flow_label;
- attr->ah_attr.grh.sgid_index = cmd.dest.sgid_index;
- attr->ah_attr.grh.hop_limit = cmd.dest.hop_limit;
- attr->ah_attr.grh.traffic_class = cmd.dest.traffic_class;
- attr->ah_attr.dlid = cmd.dest.dlid;
- attr->ah_attr.sl = cmd.dest.sl;
- attr->ah_attr.src_path_bits = cmd.dest.src_path_bits;
- attr->ah_attr.static_rate = cmd.dest.static_rate;
- attr->ah_attr.ah_flags = cmd.dest.is_global ? IB_AH_GRH : 0;
- attr->ah_attr.port_num = cmd.dest.port_num;
-
- memcpy(attr->alt_ah_attr.grh.dgid.raw, cmd.alt_dest.dgid, 16);
- attr->alt_ah_attr.grh.flow_label = cmd.alt_dest.flow_label;
- attr->alt_ah_attr.grh.sgid_index = cmd.alt_dest.sgid_index;
- attr->alt_ah_attr.grh.hop_limit = cmd.alt_dest.hop_limit;
- attr->alt_ah_attr.grh.traffic_class = cmd.alt_dest.traffic_class;
- attr->alt_ah_attr.dlid = cmd.alt_dest.dlid;
- attr->alt_ah_attr.sl = cmd.alt_dest.sl;
- attr->alt_ah_attr.src_path_bits = cmd.alt_dest.src_path_bits;
- attr->alt_ah_attr.static_rate = cmd.alt_dest.static_rate;
- attr->alt_ah_attr.ah_flags = cmd.alt_dest.is_global ? IB_AH_GRH : 0;
- attr->alt_ah_attr.port_num = cmd.alt_dest.port_num;
- port_num = (cmd.attr_mask & IB_QP_PORT) ? cmd.port_num : qp->port_num;
- if ((cmd.attr_mask & IB_QP_AV) && port_num &&
- (rdma_port_get_link_layer(qp->device, port_num) ==
- IB_LINK_LAYER_ETHERNET)) {
- ret = ib_query_gid(qp->device, port_num,
- attr->ah_attr.grh.sgid_index, &sgid);
- if (ret)
- goto out;
- dgid = &attr->ah_attr.grh.dgid;
- if (rdma_link_local_addr((struct in6_addr *)dgid->raw)) {
- rdma_get_ll_mac((struct in6_addr *)dgid->raw,
- attr->ah_attr.dmac);
- rdma_get_ll_mac((struct in6_addr *)sgid.raw,
- attr->smac);
- attr->vlan_id = rdma_get_vlan_id(&sgid);
- } else {
- struct net_device *idev;
- int if_index;
-
- if (qp->device->get_netdev != NULL &&
- (idev = qp->device->get_netdev(qp->device, port_num)) != NULL)
- if_index = idev->if_index;
- else
- if_index = 0;
-
- ret = rdma_addr_find_dmac_by_grh(&sgid, dgid,
- attr->ah_attr.dmac,
- &attr->vlan_id,
- &if_index);
- if (ret)
- goto out;
- ret = rdma_addr_find_smac_by_sgid(&sgid, attr->smac,
- NULL);
- if (ret)
- goto out;
- }
- cmd.attr_mask |= IB_QP_SMAC;
- if (attr->vlan_id < 0xFFFF)
- cmd.attr_mask |= IB_QP_VID;
- }
- if (cmd_type == IB_USER_VERBS_CMD_EXTENDED) {
- if (cmd.comp_mask & IB_UVERBS_QP_ATTR_DCT_KEY)
- attrx->dct_key = cmd.dct_key;
- }
-
- if (qp->real_qp == qp) {
- ret = qp->device->modify_qp(qp, attr,
- modify_qp_mask(qp->qp_type, cmd.attr_mask), &udata);
- if (!ret && (cmd.attr_mask & IB_QP_PORT))
- qp->port_num = attr->port_num;
- } else {
- ret = ib_modify_qp(qp, attr, modify_qp_mask(qp->qp_type, cmd.attr_mask));
- }
-
- if (ret)
- goto out;
-
- ret = in_len;
-
-out:
- put_qp_read(qp);
- kfree(attrx);
-
- return ret;
-}
-
-ssize_t ib_uverbs_modify_qp(struct ib_uverbs_file *file,
- const char __user *buf, int in_len,
- int out_len)
-{
- return __uverbs_modify_qp(file, buf, in_len, out_len,
- IB_USER_VERBS_CMD_BASIC);
-}
-
-ssize_t ib_uverbs_destroy_qp(struct ib_uverbs_file *file,
- const char __user *buf, int in_len,
- int out_len)
-{
- struct ib_uverbs_destroy_qp cmd;
- struct ib_uverbs_destroy_qp_resp resp;
- struct ib_uobject *uobj;
- struct ib_qp *qp;
- struct ib_uqp_object *obj;
- int ret = -EINVAL;
-
- if (copy_from_user(&cmd, buf, sizeof cmd))
- return -EFAULT;
-
- memset(&resp, 0, sizeof resp);
-
- uobj = idr_write_uobj(&ib_uverbs_qp_idr, cmd.qp_handle, file->ucontext);
- if (!uobj)
- return -EINVAL;
- qp = uobj->object;
- obj = container_of(uobj, struct ib_uqp_object, uevent.uobject);
-
- if (!list_empty(&obj->mcast_list)) {
- put_uobj_write(uobj);
- return -EBUSY;
- }
-
- ret = ib_destroy_qp(qp);
- if (!ret)
- uobj->live = 0;
-
- put_uobj_write(uobj);
-
- if (ret)
- return ret;
-
- if (obj->uxrcd)
- atomic_dec(&obj->uxrcd->refcnt);
-
- idr_remove_uobj(&ib_uverbs_qp_idr, uobj);
-
- mutex_lock(&file->mutex);
- list_del(&uobj->list);
- mutex_unlock(&file->mutex);
-
- ib_uverbs_release_uevent(file, &obj->uevent);
-
- resp.events_reported = obj->uevent.events_reported;
-
- put_uobj(uobj);
-
- if (copy_to_user((void __user *) (unsigned long) cmd.response,
- &resp, sizeof resp))
- return -EFAULT;
-
- return in_len;
-}
-
-ssize_t ib_uverbs_post_send(struct ib_uverbs_file *file,
- const char __user *buf, int in_len,
- int out_len)
-{
- struct ib_uverbs_post_send cmd;
- struct ib_uverbs_post_send_resp resp;
- struct ib_uverbs_send_wr *user_wr;
- struct ib_send_wr *wr = NULL, *last, *next, *bad_wr;
- struct ib_qp *qp;
- int i, sg_ind;
- int is_ud;
- ssize_t ret = -EINVAL;
-
- if (copy_from_user(&cmd, buf, sizeof cmd))
- return -EFAULT;
-
- if (in_len < sizeof cmd + cmd.wqe_size * cmd.wr_count +
- cmd.sge_count * sizeof (struct ib_uverbs_sge))
- return -EINVAL;
-
- if (cmd.wqe_size < sizeof (struct ib_uverbs_send_wr))
- return -EINVAL;
-
- user_wr = kmalloc(cmd.wqe_size, GFP_KERNEL);
- if (!user_wr)
- return -ENOMEM;
-
- qp = idr_read_qp(cmd.qp_handle, file->ucontext);
- if (!qp)
- goto out;
-
- is_ud = qp->qp_type == IB_QPT_UD;
- sg_ind = 0;
- last = NULL;
- for (i = 0; i < cmd.wr_count; ++i) {
- if (copy_from_user(user_wr,
- buf + sizeof cmd + i * cmd.wqe_size,
- cmd.wqe_size)) {
- ret = -EFAULT;
- goto out_put;
- }
-
- if (user_wr->num_sge + sg_ind > cmd.sge_count) {
- ret = -EINVAL;
- goto out_put;
- }
-
- next = kmalloc(ALIGN(sizeof *next, sizeof (struct ib_sge)) +
- user_wr->num_sge * sizeof (struct ib_sge),
- GFP_KERNEL);
- if (!next) {
- ret = -ENOMEM;
- goto out_put;
- }
-
- if (!last)
- wr = next;
- else
- last->next = next;
- last = next;
-
- next->next = NULL;
- next->wr_id = user_wr->wr_id;
- next->num_sge = user_wr->num_sge;
- next->opcode = user_wr->opcode;
- next->send_flags = user_wr->send_flags;
-
- if (is_ud) {
- next->wr.ud.ah = idr_read_ah(user_wr->wr.ud.ah,
- file->ucontext);
- if (!next->wr.ud.ah) {
- ret = -EINVAL;
- goto out_put;
- }
- next->wr.ud.remote_qpn = user_wr->wr.ud.remote_qpn;
- next->wr.ud.remote_qkey = user_wr->wr.ud.remote_qkey;
- } else {
- switch (next->opcode) {
- case IB_WR_RDMA_WRITE_WITH_IMM:
- next->ex.imm_data =
- (__be32 __force) user_wr->ex.imm_data;
- case IB_WR_RDMA_WRITE:
- case IB_WR_RDMA_READ:
- next->wr.rdma.remote_addr =
- user_wr->wr.rdma.remote_addr;
- next->wr.rdma.rkey =
- user_wr->wr.rdma.rkey;
- break;
- case IB_WR_SEND_WITH_IMM:
- next->ex.imm_data =
- (__be32 __force) user_wr->ex.imm_data;
- break;
- case IB_WR_SEND_WITH_INV:
- next->ex.invalidate_rkey =
- user_wr->ex.invalidate_rkey;
- break;
- case IB_WR_ATOMIC_CMP_AND_SWP:
- case IB_WR_ATOMIC_FETCH_AND_ADD:
- next->wr.atomic.remote_addr =
- user_wr->wr.atomic.remote_addr;
- next->wr.atomic.compare_add =
- user_wr->wr.atomic.compare_add;
- next->wr.atomic.swap = user_wr->wr.atomic.swap;
- next->wr.atomic.rkey = user_wr->wr.atomic.rkey;
- break;
- default:
- break;
- }
- }
-
- if (next->num_sge) {
- next->sg_list = (void *) next +
- ALIGN(sizeof *next, sizeof (struct ib_sge));
- if (copy_from_user(next->sg_list,
- buf + sizeof cmd +
- cmd.wr_count * cmd.wqe_size +
- sg_ind * sizeof (struct ib_sge),
- next->num_sge * sizeof (struct ib_sge))) {
- ret = -EFAULT;
- goto out_put;
- }
- sg_ind += next->num_sge;
- } else
- next->sg_list = NULL;
- }
-
- resp.bad_wr = 0;
- ret = qp->device->post_send(qp->real_qp, wr, &bad_wr);
- if (ret)
- for (next = wr; next; next = next->next) {
- ++resp.bad_wr;
- if (next == bad_wr)
- break;
- }
-
- if (copy_to_user((void __user *) (unsigned long) cmd.response,
- &resp, sizeof resp))
- ret = -EFAULT;
-
-out_put:
- put_qp_read(qp);
-
- while (wr) {
- if (is_ud && wr->wr.ud.ah)
- put_ah_read(wr->wr.ud.ah);
- next = wr->next;
- kfree(wr);
- wr = next;
- }
-
-out:
- kfree(user_wr);
-
- return ret ? ret : in_len;
-}
-
-static struct ib_recv_wr *ib_uverbs_unmarshall_recv(const char __user *buf,
- int in_len,
- u32 wr_count,
- u32 sge_count,
- u32 wqe_size)
-{
- struct ib_uverbs_recv_wr *user_wr;
- struct ib_recv_wr *wr = NULL, *last, *next;
- int sg_ind;
- int i;
- int ret;
-
- if (in_len < wqe_size * wr_count +
- sge_count * sizeof (struct ib_uverbs_sge))
- return ERR_PTR(-EINVAL);
-
- if (wqe_size < sizeof (struct ib_uverbs_recv_wr))
- return ERR_PTR(-EINVAL);
-
- user_wr = kmalloc(wqe_size, GFP_KERNEL);
- if (!user_wr)
- return ERR_PTR(-ENOMEM);
-
- sg_ind = 0;
- last = NULL;
- for (i = 0; i < wr_count; ++i) {
- if (copy_from_user(user_wr, buf + i * wqe_size,
- wqe_size)) {
- ret = -EFAULT;
- goto err;
- }
-
- if (user_wr->num_sge + sg_ind > sge_count) {
- ret = -EINVAL;
- goto err;
- }
-
- next = kmalloc(ALIGN(sizeof *next, sizeof (struct ib_sge)) +
- user_wr->num_sge * sizeof (struct ib_sge),
- GFP_KERNEL);
- if (!next) {
- ret = -ENOMEM;
- goto err;
- }
-
- if (!last)
- wr = next;
- else
- last->next = next;
- last = next;
-
- next->next = NULL;
- next->wr_id = user_wr->wr_id;
- next->num_sge = user_wr->num_sge;
-
- if (next->num_sge) {
- next->sg_list = (void *) next +
- ALIGN(sizeof *next, sizeof (struct ib_sge));
- if (copy_from_user(next->sg_list,
- buf + wr_count * wqe_size +
- sg_ind * sizeof (struct ib_sge),
- next->num_sge * sizeof (struct ib_sge))) {
- ret = -EFAULT;
- goto err;
- }
- sg_ind += next->num_sge;
- } else
- next->sg_list = NULL;
- }
-
- kfree(user_wr);
- return wr;
-
-err:
- kfree(user_wr);
-
- while (wr) {
- next = wr->next;
- kfree(wr);
- wr = next;
- }
-
- return ERR_PTR(ret);
-}
-
-ssize_t ib_uverbs_post_recv(struct ib_uverbs_file *file,
- const char __user *buf, int in_len,
- int out_len)
-{
- struct ib_uverbs_post_recv cmd;
- struct ib_uverbs_post_recv_resp resp;
- struct ib_recv_wr *wr, *next, *bad_wr;
- struct ib_qp *qp;
- ssize_t ret = -EINVAL;
-
- if (copy_from_user(&cmd, buf, sizeof cmd))
- return -EFAULT;
-
- wr = ib_uverbs_unmarshall_recv(buf + sizeof cmd,
- in_len - sizeof cmd, cmd.wr_count,
- cmd.sge_count, cmd.wqe_size);
- if (IS_ERR(wr))
- return PTR_ERR(wr);
-
- qp = idr_read_qp(cmd.qp_handle, file->ucontext);
- if (!qp)
- goto out;
-
- resp.bad_wr = 0;
- ret = qp->device->post_recv(qp->real_qp, wr, &bad_wr);
-
- put_qp_read(qp);
-
- if (ret)
- for (next = wr; next; next = next->next) {
- ++resp.bad_wr;
- if (next == bad_wr)
- break;
- }
-
- if (copy_to_user((void __user *) (unsigned long) cmd.response,
- &resp, sizeof resp))
- ret = -EFAULT;
-
-out:
- while (wr) {
- next = wr->next;
- kfree(wr);
- wr = next;
- }
-
- return ret ? ret : in_len;
-}
-
-ssize_t ib_uverbs_post_srq_recv(struct ib_uverbs_file *file,
- const char __user *buf, int in_len,
- int out_len)
-{
- struct ib_uverbs_post_srq_recv cmd;
- struct ib_uverbs_post_srq_recv_resp resp;
- struct ib_recv_wr *wr, *next, *bad_wr;
- struct ib_srq *srq;
- ssize_t ret = -EINVAL;
-
- if (copy_from_user(&cmd, buf, sizeof cmd))
- return -EFAULT;
-
- wr = ib_uverbs_unmarshall_recv(buf + sizeof cmd,
- in_len - sizeof cmd, cmd.wr_count,
- cmd.sge_count, cmd.wqe_size);
- if (IS_ERR(wr))
- return PTR_ERR(wr);
-
- srq = idr_read_srq(cmd.srq_handle, file->ucontext);
- if (!srq)
- goto out;
-
- resp.bad_wr = 0;
- ret = srq->device->post_srq_recv(srq, wr, &bad_wr);
-
- put_srq_read(srq);
-
- if (ret)
- for (next = wr; next; next = next->next) {
- ++resp.bad_wr;
- if (next == bad_wr)
- break;
- }
-
- if (copy_to_user((void __user *) (unsigned long) cmd.response,
- &resp, sizeof resp))
- ret = -EFAULT;
-
-out:
- while (wr) {
- next = wr->next;
- kfree(wr);
- wr = next;
- }
-
- return ret ? ret : in_len;
-}
-
-ssize_t ib_uverbs_create_ah(struct ib_uverbs_file *file,
- const char __user *buf, int in_len,
- int out_len)
-{
- struct ib_uverbs_create_ah cmd;
- struct ib_uverbs_create_ah_resp resp;
- struct ib_uobject *uobj;
- struct ib_pd *pd;
- struct ib_ah *ah;
- struct ib_ah_attr attr;
- int ret;
-
- if (out_len < sizeof resp)
- return -ENOSPC;
-
- if (copy_from_user(&cmd, buf, sizeof cmd))
- return -EFAULT;
-
- uobj = kmalloc(sizeof *uobj, GFP_KERNEL);
- if (!uobj)
- return -ENOMEM;
-
- init_uobj(uobj, cmd.user_handle, file->ucontext, &ah_lock_class);
- down_write(&uobj->mutex);
-
- pd = idr_read_pd(cmd.pd_handle, file->ucontext);
- if (!pd) {
- ret = -EINVAL;
- goto err;
- }
-
- attr.dlid = cmd.attr.dlid;
- attr.sl = cmd.attr.sl;
- attr.src_path_bits = cmd.attr.src_path_bits;
- attr.static_rate = cmd.attr.static_rate;
- attr.ah_flags = cmd.attr.is_global ? IB_AH_GRH : 0;
- attr.port_num = cmd.attr.port_num;
- attr.grh.flow_label = cmd.attr.grh.flow_label;
- attr.grh.sgid_index = cmd.attr.grh.sgid_index;
- attr.grh.hop_limit = cmd.attr.grh.hop_limit;
- attr.grh.traffic_class = cmd.attr.grh.traffic_class;
- memcpy(attr.grh.dgid.raw, cmd.attr.grh.dgid, 16);
-
- ah = ib_create_ah(pd, &attr);
- if (IS_ERR(ah)) {
- ret = PTR_ERR(ah);
- goto err_put;
- }
-
- ah->uobject = uobj;
- uobj->object = ah;
-
- ret = idr_add_uobj(&ib_uverbs_ah_idr, uobj);
- if (ret)
- goto err_destroy;
-
- resp.ah_handle = uobj->id;
-
- if (copy_to_user((void __user *) (unsigned long) cmd.response,
- &resp, sizeof resp)) {
- ret = -EFAULT;
- goto err_copy;
- }
-
- put_pd_read(pd);
-
- mutex_lock(&file->mutex);
- list_add_tail(&uobj->list, &file->ucontext->ah_list);
- mutex_unlock(&file->mutex);
-
- uobj->live = 1;
-
- up_write(&uobj->mutex);
-
- return in_len;
-
-err_copy:
- idr_remove_uobj(&ib_uverbs_ah_idr, uobj);
-
-err_destroy:
- ib_destroy_ah(ah);
-
-err_put:
- put_pd_read(pd);
-
-err:
- put_uobj_write(uobj);
- return ret;
-}
-
-ssize_t ib_uverbs_destroy_ah(struct ib_uverbs_file *file,
- const char __user *buf, int in_len, int out_len)
-{
- struct ib_uverbs_destroy_ah cmd;
- struct ib_ah *ah;
- struct ib_uobject *uobj;
- int ret;
-
- if (copy_from_user(&cmd, buf, sizeof cmd))
- return -EFAULT;
-
- uobj = idr_write_uobj(&ib_uverbs_ah_idr, cmd.ah_handle, file->ucontext);
- if (!uobj)
- return -EINVAL;
- ah = uobj->object;
-
- ret = ib_destroy_ah(ah);
- if (!ret)
- uobj->live = 0;
-
- put_uobj_write(uobj);
-
- if (ret)
- return ret;
-
- idr_remove_uobj(&ib_uverbs_ah_idr, uobj);
-
- mutex_lock(&file->mutex);
- list_del(&uobj->list);
- mutex_unlock(&file->mutex);
-
- put_uobj(uobj);
-
- return in_len;
-}
-
-ssize_t ib_uverbs_attach_mcast(struct ib_uverbs_file *file,
- const char __user *buf, int in_len,
- int out_len)
-{
- struct ib_uverbs_attach_mcast cmd;
- struct ib_qp *qp;
- struct ib_uqp_object *obj;
- struct ib_uverbs_mcast_entry *mcast;
- int ret;
-
- if (copy_from_user(&cmd, buf, sizeof cmd))
- return -EFAULT;
-
- qp = idr_write_qp(cmd.qp_handle, file->ucontext);
- if (!qp)
- return -EINVAL;
-
- obj = container_of(qp->uobject, struct ib_uqp_object, uevent.uobject);
-
- list_for_each_entry(mcast, &obj->mcast_list, list)
- if (cmd.mlid == mcast->lid &&
- !memcmp(cmd.gid, mcast->gid.raw, sizeof mcast->gid.raw)) {
- ret = 0;
- goto out_put;
- }
-
- mcast = kmalloc(sizeof *mcast, GFP_KERNEL);
- if (!mcast) {
- ret = -ENOMEM;
- goto out_put;
- }
-
- mcast->lid = cmd.mlid;
- memcpy(mcast->gid.raw, cmd.gid, sizeof mcast->gid.raw);
-
- ret = ib_attach_mcast(qp, &mcast->gid, cmd.mlid);
- if (!ret)
- list_add_tail(&mcast->list, &obj->mcast_list);
- else
- kfree(mcast);
-
-out_put:
- put_qp_write(qp);
-
- return ret ? ret : in_len;
-}
-
-ssize_t ib_uverbs_detach_mcast(struct ib_uverbs_file *file,
- const char __user *buf, int in_len,
- int out_len)
-{
- struct ib_uverbs_detach_mcast cmd;
- struct ib_uqp_object *obj;
- struct ib_qp *qp;
- struct ib_uverbs_mcast_entry *mcast;
- int ret = -EINVAL;
-
- if (copy_from_user(&cmd, buf, sizeof cmd))
- return -EFAULT;
-
- qp = idr_write_qp(cmd.qp_handle, file->ucontext);
- if (!qp)
- return -EINVAL;
-
- ret = ib_detach_mcast(qp, (union ib_gid *) cmd.gid, cmd.mlid);
- if (ret)
- goto out_put;
-
- obj = container_of(qp->uobject, struct ib_uqp_object, uevent.uobject);
-
- list_for_each_entry(mcast, &obj->mcast_list, list)
- if (cmd.mlid == mcast->lid &&
- !memcmp(cmd.gid, mcast->gid.raw, sizeof mcast->gid.raw)) {
- list_del(&mcast->list);
- kfree(mcast);
- break;
- }
-
-out_put:
- put_qp_write(qp);
-
- return ret ? ret : in_len;
-}
-
-static int __uverbs_create_xsrq(struct ib_uverbs_file *file,
- struct ib_uverbs_create_xsrq *cmd,
- struct ib_udata *udata)
-{
- struct ib_uverbs_create_srq_resp resp;
- struct ib_usrq_object *obj;
- struct ib_pd *pd;
- struct ib_srq *srq;
- struct ib_uobject *uninitialized_var(xrcd_uobj);
- struct ib_srq_init_attr attr;
- int ret;
-
- obj = kmalloc(sizeof(*obj), GFP_KERNEL);
- if (!obj)
- return -ENOMEM;
-
- init_uobj(&obj->uevent.uobject, cmd->user_handle, file->ucontext, &srq_lock_class);
- down_write(&obj->uevent.uobject.mutex);
-
- if (cmd->srq_type == IB_SRQT_XRC) {
- attr.ext.xrc.xrcd = idr_read_xrcd(cmd->xrcd_handle, file->ucontext, &xrcd_uobj);
- if (!attr.ext.xrc.xrcd) {
- ret = -EINVAL;
- goto err;
- }
-
- obj->uxrcd = container_of(xrcd_uobj, struct ib_uxrcd_object, uobject);
- atomic_inc(&obj->uxrcd->refcnt);
-
- attr.ext.xrc.cq = idr_read_cq(cmd->cq_handle, file->ucontext, 0);
- if (!attr.ext.xrc.cq) {
- ret = -EINVAL;
- goto err_put_xrcd;
- }
- }
-
- pd = idr_read_pd(cmd->pd_handle, file->ucontext);
- if (!pd) {
- ret = -EINVAL;
- goto err_put_cq;
- }
-
- attr.event_handler = ib_uverbs_srq_event_handler;
- attr.srq_context = file;
- attr.srq_type = cmd->srq_type;
- attr.attr.max_wr = cmd->max_wr;
- attr.attr.max_sge = cmd->max_sge;
- attr.attr.srq_limit = cmd->srq_limit;
-
- obj->uevent.events_reported = 0;
- INIT_LIST_HEAD(&obj->uevent.event_list);
-
- srq = pd->device->create_srq(pd, &attr, udata);
- if (IS_ERR(srq)) {
- ret = PTR_ERR(srq);
- goto err_put;
- }
-
- srq->device = pd->device;
- srq->pd = pd;
- srq->srq_type = cmd->srq_type;
- srq->uobject = &obj->uevent.uobject;
- srq->event_handler = attr.event_handler;
- srq->srq_context = attr.srq_context;
-
- if (cmd->srq_type == IB_SRQT_XRC) {
- srq->ext.xrc.cq = attr.ext.xrc.cq;
- srq->ext.xrc.xrcd = attr.ext.xrc.xrcd;
- atomic_inc(&attr.ext.xrc.cq->usecnt);
- atomic_inc(&attr.ext.xrc.xrcd->usecnt);
- }
-
- atomic_inc(&pd->usecnt);
- atomic_set(&srq->usecnt, 0);
-
- obj->uevent.uobject.object = srq;
- ret = idr_add_uobj(&ib_uverbs_srq_idr, &obj->uevent.uobject);
- if (ret)
- goto err_destroy;
-
- memset(&resp, 0, sizeof resp);
- resp.srq_handle = obj->uevent.uobject.id;
- resp.max_wr = attr.attr.max_wr;
- resp.max_sge = attr.attr.max_sge;
- if (cmd->srq_type == IB_SRQT_XRC)
- resp.srqn = srq->ext.xrc.srq_num;
-
- if (copy_to_user((void __user *) (unsigned long) cmd->response,
- &resp, sizeof resp)) {
- ret = -EFAULT;
- goto err_copy;
- }
-
- if (cmd->srq_type == IB_SRQT_XRC) {
- put_uobj_read(xrcd_uobj);
- put_cq_read(attr.ext.xrc.cq);
- }
- put_pd_read(pd);
-
- mutex_lock(&file->mutex);
- list_add_tail(&obj->uevent.uobject.list, &file->ucontext->srq_list);
- mutex_unlock(&file->mutex);
-
- obj->uevent.uobject.live = 1;
-
- up_write(&obj->uevent.uobject.mutex);
-
- return 0;
-
-err_copy:
- idr_remove_uobj(&ib_uverbs_srq_idr, &obj->uevent.uobject);
-
-err_destroy:
- ib_destroy_srq(srq);
-
-err_put:
- put_pd_read(pd);
-
-err_put_cq:
- if (cmd->srq_type == IB_SRQT_XRC)
- put_cq_read(attr.ext.xrc.cq);
-
-err_put_xrcd:
- if (cmd->srq_type == IB_SRQT_XRC) {
- atomic_dec(&obj->uxrcd->refcnt);
- put_uobj_read(xrcd_uobj);
- }
-
-err:
- put_uobj_write(&obj->uevent.uobject);
- return ret;
-}
-
-ssize_t ib_uverbs_create_srq(struct ib_uverbs_file *file,
- const char __user *buf, int in_len,
- int out_len)
-{
- struct ib_uverbs_create_srq cmd;
- struct ib_uverbs_create_xsrq xcmd;
- struct ib_uverbs_create_srq_resp resp;
- struct ib_udata udata;
- int ret;
-
- if (out_len < sizeof resp)
- return -ENOSPC;
-
- if (copy_from_user(&cmd, buf, sizeof cmd))
- return -EFAULT;
-
- xcmd.response = cmd.response;
- xcmd.user_handle = cmd.user_handle;
- xcmd.srq_type = IB_SRQT_BASIC;
- xcmd.pd_handle = cmd.pd_handle;
- xcmd.max_wr = cmd.max_wr;
- xcmd.max_sge = cmd.max_sge;
- xcmd.srq_limit = cmd.srq_limit;
-
- INIT_UDATA(&udata, buf + sizeof cmd,
- (unsigned long) cmd.response + sizeof resp,
- in_len - sizeof cmd, out_len - sizeof resp);
-
- ret = __uverbs_create_xsrq(file, &xcmd, &udata);
- if (ret)
- return ret;
-
- return in_len;
-}
-
-ssize_t ib_uverbs_create_xsrq(struct ib_uverbs_file *file,
- const char __user *buf, int in_len, int out_len)
-{
- struct ib_uverbs_create_xsrq cmd;
- struct ib_uverbs_create_srq_resp resp;
- struct ib_udata udata;
- int ret;
-
- if (out_len < sizeof resp)
- return -ENOSPC;
-
- if (copy_from_user(&cmd, buf, sizeof cmd))
- return -EFAULT;
-
- INIT_UDATA(&udata, buf + sizeof cmd,
- (unsigned long) cmd.response + sizeof resp,
- in_len - sizeof cmd, out_len - sizeof resp);
-
- ret = __uverbs_create_xsrq(file, &cmd, &udata);
- if (ret)
- return ret;
-
- return in_len;
-}
-
-ssize_t ib_uverbs_modify_srq(struct ib_uverbs_file *file,
- const char __user *buf, int in_len,
- int out_len)
-{
- struct ib_uverbs_modify_srq cmd;
- struct ib_udata udata;
- struct ib_srq *srq;
- struct ib_srq_attr attr;
- int ret;
-
- if (copy_from_user(&cmd, buf, sizeof cmd))
- return -EFAULT;
-
- INIT_UDATA(&udata, buf + sizeof cmd, NULL, in_len - sizeof cmd,
- out_len);
-
- srq = idr_read_srq(cmd.srq_handle, file->ucontext);
- if (!srq)
- return -EINVAL;
-
- attr.max_wr = cmd.max_wr;
- attr.srq_limit = cmd.srq_limit;
-
- ret = srq->device->modify_srq(srq, &attr, cmd.attr_mask, &udata);
-
- put_srq_read(srq);
-
- return ret ? ret : in_len;
-}
-
-ssize_t ib_uverbs_query_srq(struct ib_uverbs_file *file,
- const char __user *buf,
- int in_len, int out_len)
-{
- struct ib_uverbs_query_srq cmd;
- struct ib_uverbs_query_srq_resp resp;
- struct ib_srq_attr attr;
- struct ib_srq *srq;
- int ret;
-
- if (out_len < sizeof resp)
- return -ENOSPC;
-
- if (copy_from_user(&cmd, buf, sizeof cmd))
- return -EFAULT;
-
- srq = idr_read_srq(cmd.srq_handle, file->ucontext);
- if (!srq)
- return -EINVAL;
-
- ret = ib_query_srq(srq, &attr);
-
- put_srq_read(srq);
-
- if (ret)
- return ret;
-
- memset(&resp, 0, sizeof resp);
-
- resp.max_wr = attr.max_wr;
- resp.max_sge = attr.max_sge;
- resp.srq_limit = attr.srq_limit;
-
- if (copy_to_user((void __user *) (unsigned long) cmd.response,
- &resp, sizeof resp))
- return -EFAULT;
-
- return in_len;
-}
-
-ssize_t ib_uverbs_destroy_srq(struct ib_uverbs_file *file,
- const char __user *buf, int in_len,
- int out_len)
-{
- struct ib_uverbs_destroy_srq cmd;
- struct ib_uverbs_destroy_srq_resp resp;
- struct ib_uobject *uobj;
- struct ib_srq *srq;
- struct ib_uevent_object *obj;
- int ret = -EINVAL;
- struct ib_usrq_object *us;
- enum ib_srq_type srq_type;
-
- if (copy_from_user(&cmd, buf, sizeof cmd))
- return -EFAULT;
-
- uobj = idr_write_uobj(&ib_uverbs_srq_idr, cmd.srq_handle, file->ucontext);
- if (!uobj)
- return -EINVAL;
- srq = uobj->object;
- obj = container_of(uobj, struct ib_uevent_object, uobject);
- srq_type = srq->srq_type;
-
- ret = ib_destroy_srq(srq);
- if (!ret)
- uobj->live = 0;
-
- put_uobj_write(uobj);
-
- if (ret)
- return ret;
-
- if (srq_type == IB_SRQT_XRC) {
- us = container_of(obj, struct ib_usrq_object, uevent);
- atomic_dec(&us->uxrcd->refcnt);
- }
-
- idr_remove_uobj(&ib_uverbs_srq_idr, uobj);
-
- mutex_lock(&file->mutex);
- list_del(&uobj->list);
- mutex_unlock(&file->mutex);
-
- ib_uverbs_release_uevent(file, obj);
-
- memset(&resp, 0, sizeof resp);
- resp.events_reported = obj->events_reported;
-
- put_uobj(uobj);
-
- if (copy_to_user((void __user *) (unsigned long) cmd.response,
- &resp, sizeof resp))
- ret = -EFAULT;
-
- return ret ? ret : in_len;
-}
-
-ssize_t ib_uverbs_exp_create_dct(struct ib_uverbs_file *file,
- struct ib_udata *ucore,
- struct ib_udata *uhw)
-{
- int in_len = ucore->inlen + uhw->inlen;
- int out_len = ucore->outlen + uhw->outlen;
- struct ib_uverbs_create_dct cmd;
- struct ib_uverbs_create_dct_resp resp;
- struct ib_udata udata;
- struct ib_udct_object *obj;
- struct ib_dct *dct;
- int ret;
- struct ib_dct_init_attr attr;
- struct ib_pd *pd = NULL;
- struct ib_cq *cq = NULL;
- struct ib_srq *srq = NULL;
-
- if (out_len < sizeof(resp))
- return -ENOSPC;
-
- ret = ucore->ops->copy_from(&cmd, ucore, sizeof(cmd));
- if (ret)
- return ret;
-
- obj = kmalloc(sizeof(*obj), GFP_KERNEL);
- if (!obj)
- return -ENOMEM;
-
- init_uobj(&obj->uobject, cmd.user_handle, file->ucontext,
- &dct_lock_class);
- down_write(&obj->uobject.mutex);
-
- pd = idr_read_pd(cmd.pd_handle, file->ucontext);
- if (!pd) {
- ret = -EINVAL;
- goto err_pd;
- }
-
- cq = idr_read_cq(cmd.cq_handle, file->ucontext, 0);
- if (!cq) {
- ret = -EINVAL;
- goto err_put;
- }
-
- srq = idr_read_srq(cmd.srq_handle, file->ucontext);
- if (!srq) {
- ret = -EINVAL;
- goto err_put;
- }
-
- attr.cq = cq;
- attr.access_flags = cmd.access_flags;
- attr.min_rnr_timer = cmd.min_rnr_timer;
- attr.srq = srq;
- attr.tclass = cmd.tclass;
- attr.flow_label = cmd.flow_label;
- attr.dc_key = cmd.dc_key;
- attr.mtu = cmd.mtu;
- attr.port = cmd.port;
- attr.pkey_index = cmd.pkey_index;
- attr.gid_index = cmd.gid_index;
- attr.hop_limit = cmd.hop_limit;
- attr.create_flags = cmd.create_flags;
-
- dct = ib_create_dct(pd, &attr, &udata);
- if (IS_ERR(dct)) {
- ret = PTR_ERR(dct);
- goto err_put;
- }
-
- dct->device = file->device->ib_dev;
- dct->uobject = &obj->uobject;
-
- obj->uobject.object = dct;
- ret = idr_add_uobj(&ib_uverbs_dct_idr, &obj->uobject);
- if (ret)
- goto err_dct;
-
- memset(&resp, 0, sizeof(resp));
- resp.dct_handle = obj->uobject.id;
- resp.dctn = dct->dct_num;
-
- ret = ucore->ops->copy_to(ucore, &resp, sizeof(resp));
- if (ret)
- goto err_copy;
-
- mutex_lock(&file->mutex);
- list_add_tail(&obj->uobject.list, &file->ucontext->dct_list);
- mutex_unlock(&file->mutex);
-
- obj->uobject.live = 1;
-
- put_srq_read(srq);
- put_cq_read(cq);
- put_pd_read(pd);
-
- up_write(&obj->uobject.mutex);
-
- return in_len;
-
-err_copy:
- idr_remove_uobj(&ib_uverbs_dct_idr, &obj->uobject);
-
-err_dct:
- ib_destroy_dct(dct);
-
-err_put:
- if (srq)
- put_srq_read(srq);
-
- if (cq)
- put_cq_read(cq);
-
- put_pd_read(pd);
-
-err_pd:
- put_uobj_write(&obj->uobject);
- return ret;
-}
-
-ssize_t ib_uverbs_exp_destroy_dct(struct ib_uverbs_file *file,
- struct ib_udata *ucore,
- struct ib_udata *uhw)
-{
- int in_len = ucore->inlen + uhw->inlen;
- int out_len = ucore->outlen + uhw->outlen;
- struct ib_uverbs_destroy_dct cmd;
- struct ib_uverbs_destroy_dct_resp resp;
- struct ib_uobject *uobj;
- struct ib_dct *dct;
- struct ib_udct_object *obj;
- int ret;
-
- if (out_len < sizeof(resp))
- return -ENOSPC;
-
- ret = ucore->ops->copy_from(&cmd, ucore, sizeof(cmd));
- if (ret)
- return ret;
-
- uobj = idr_write_uobj(&ib_uverbs_dct_idr, cmd.user_handle, file->ucontext);
- if (!uobj)
- return -EINVAL;
-
- dct = uobj->object;
- obj = container_of(dct->uobject, struct ib_udct_object, uobject);
-
- ret = ib_destroy_dct(dct);
- if (!ret)
- uobj->live = 0;
-
- put_uobj_write(uobj);
-
- if (ret)
- return ret;
-
- idr_remove_uobj(&ib_uverbs_dct_idr, uobj);
-
- mutex_lock(&file->mutex);
- list_del(&uobj->list);
- mutex_unlock(&file->mutex);
-
- memset(&resp, 0, sizeof(resp));
-
- put_uobj(uobj);
-
- ret = ucore->ops->copy_to(ucore, &resp, sizeof(resp));
- if (ret)
- return ret;
-
- return in_len;
-}
-
-ssize_t ib_uverbs_exp_query_dct(struct ib_uverbs_file *file,
- struct ib_udata *ucore,
- struct ib_udata *uhw)
-{
- int in_len = ucore->inlen + uhw->inlen;
- int out_len = ucore->outlen + uhw->outlen;
- struct ib_uverbs_query_dct cmd;
- struct ib_uverbs_query_dct_resp resp;
- struct ib_dct *dct;
- struct ib_dct_attr *attr;
- int err;
-
- if (out_len < sizeof(resp))
- return -ENOSPC;
-
- err = ucore->ops->copy_from(&cmd, ucore, sizeof(cmd));
- if (err)
- return err;
-
- attr = kmalloc(sizeof(*attr), GFP_KERNEL);
- if (!attr) {
- err = -ENOMEM;
- goto out;
- }
-
- dct = idr_read_dct(cmd.dct_handle, file->ucontext);
- if (!dct) {
- err = -EINVAL;
- goto out;
- }
-
- err = ib_query_dct(dct, attr);
-
- put_dct_read(dct);
-
- if (err)
- goto out;
-
- memset(&resp, 0, sizeof(resp));
-
- resp.dc_key = attr->dc_key;
- resp.access_flags = attr->access_flags;
- resp.flow_label = attr->flow_label;
- resp.key_violations = attr->key_violations;
- resp.port = attr->port;
- resp.min_rnr_timer = attr->min_rnr_timer;
- resp.tclass = attr->tclass;
- resp.mtu = attr->mtu;
- resp.pkey_index = attr->pkey_index;
- resp.gid_index = attr->gid_index;
- resp.hop_limit = attr->hop_limit;
- resp.state = attr->state;
-
- err = ucore->ops->copy_to(ucore, &resp, sizeof(resp));
-
-out:
- kfree(attr);
-
- return err ? err : in_len;
-}
-
-/*
- * Experimental functions
- */
-
-static struct uverbs_lock_class rule_lock_class = { .name = "RULE-uobj" };
-
-static int kern_spec_to_ib_spec(struct ib_uverbs_flow_spec *kern_spec,
- union ib_flow_spec *ib_spec)
-{
- ib_spec->type = kern_spec->type;
-
- switch (ib_spec->type) {
- case IB_FLOW_SPEC_ETH:
- ib_spec->eth.size = sizeof(struct ib_flow_spec_eth);
- memcpy(&ib_spec->eth.val, &kern_spec->eth.val,
- sizeof(struct ib_flow_eth_filter));
- memcpy(&ib_spec->eth.mask, &kern_spec->eth.mask,
- sizeof(struct ib_flow_eth_filter));
- break;
- case IB_FLOW_SPEC_IB:
- ib_spec->ib.size = sizeof(struct ib_flow_spec_ib);
- memcpy(&ib_spec->ib.val, &kern_spec->ib.val,
- sizeof(struct ib_flow_ib_filter));
- memcpy(&ib_spec->ib.mask, &kern_spec->ib.mask,
- sizeof(struct ib_flow_ib_filter));
- break;
- case IB_FLOW_SPEC_IPV4:
- ib_spec->ipv4.size = sizeof(struct ib_flow_spec_ipv4);
- memcpy(&ib_spec->ipv4.val, &kern_spec->ipv4.val,
- sizeof(struct ib_flow_ipv4_filter));
- memcpy(&ib_spec->ipv4.mask, &kern_spec->ipv4.mask,
- sizeof(struct ib_flow_ipv4_filter));
- break;
- case IB_FLOW_SPEC_TCP:
- case IB_FLOW_SPEC_UDP:
- ib_spec->tcp_udp.size = sizeof(struct ib_flow_spec_tcp_udp);
- memcpy(&ib_spec->tcp_udp.val, &kern_spec->tcp_udp.val,
- sizeof(struct ib_flow_tcp_udp_filter));
- memcpy(&ib_spec->tcp_udp.mask, &kern_spec->tcp_udp.mask,
- sizeof(struct ib_flow_tcp_udp_filter));
- break;
- default:
- return -EINVAL;
- }
- return 0;
-}
-
-int ib_uverbs_ex_create_flow(struct ib_uverbs_file *file,
- struct ib_udata *ucore,
- struct ib_udata *uhw)
-{
- struct ib_uverbs_create_flow cmd;
- struct ib_uverbs_create_flow_resp resp;
- struct ib_uobject *uobj;
- struct ib_flow *flow_id;
- struct ib_uverbs_flow_attr *kern_flow_attr;
- struct ib_flow_attr *flow_attr;
- struct ib_qp *qp;
- int err = 0;
- void *kern_spec;
- void *ib_spec;
- int i;
-
- if (ucore->outlen < sizeof(resp))
- return -ENOSPC;
-
- err = ib_copy_from_udata(&cmd, ucore, sizeof(cmd));
- if (err)
- return err;
-
- ucore->inbuf += sizeof(cmd);
- ucore->inlen -= sizeof(cmd);
-
- if (cmd.comp_mask)
- return -EINVAL;
-
- if (priv_check(curthread, PRIV_NET_RAW) && !disable_raw_qp_enforcement)
- return -EPERM;
-
- if (cmd.flow_attr.num_of_specs > IB_FLOW_SPEC_SUPPORT_LAYERS)
- return -EINVAL;
-
- if (cmd.flow_attr.size > ucore->inlen ||
- cmd.flow_attr.size >
- (cmd.flow_attr.num_of_specs * sizeof(struct ib_uverbs_flow_spec)))
- return -EINVAL;
-
- if (cmd.flow_attr.num_of_specs) {
- kern_flow_attr = kmalloc(sizeof(*kern_flow_attr) +
- cmd.flow_attr.size, GFP_KERNEL);
- if (!kern_flow_attr)
- return -ENOMEM;
-
- memcpy(kern_flow_attr, &cmd.flow_attr, sizeof(*kern_flow_attr));
- err = ib_copy_from_udata(kern_flow_attr + 1, ucore,
- cmd.flow_attr.size);
- if (err)
- goto err_free_attr;
- } else {
- kern_flow_attr = &cmd.flow_attr;
- }
-
- uobj = kmalloc(sizeof(*uobj), GFP_KERNEL);
- if (!uobj) {
- err = -ENOMEM;
- goto err_free_attr;
- }
- init_uobj(uobj, 0, file->ucontext, &rule_lock_class);
- down_write(&uobj->mutex);
-
- qp = idr_read_qp(cmd.qp_handle, file->ucontext);
- if (!qp) {
- err = -EINVAL;
- goto err_uobj;
- }
-
- flow_attr = kmalloc(sizeof(*flow_attr) + cmd.flow_attr.size,
- GFP_KERNEL);
- if (!flow_attr) {
- err = -ENOMEM;
- goto err_put;
- }
-
- flow_attr->type = kern_flow_attr->type;
- flow_attr->priority = kern_flow_attr->priority;
- flow_attr->num_of_specs = kern_flow_attr->num_of_specs;
- flow_attr->port = kern_flow_attr->port;
- flow_attr->flags = kern_flow_attr->flags;
- flow_attr->size = sizeof(*flow_attr);
-
- kern_spec = kern_flow_attr + 1;
- ib_spec = flow_attr + 1;
- for (i = 0; i < flow_attr->num_of_specs &&
- cmd.flow_attr.size >
- offsetof(struct ib_uverbs_flow_spec, reserved) &&
- cmd.flow_attr.size >=
- ((struct ib_uverbs_flow_spec *)kern_spec)->size; i++) {
- err = kern_spec_to_ib_spec(kern_spec, ib_spec);
- if (err)
- goto err_free;
- flow_attr->size +=
- ((union ib_flow_spec *)ib_spec)->size;
- cmd.flow_attr.size -=
- ((struct ib_uverbs_flow_spec *)kern_spec)->size;
- kern_spec += ((struct ib_uverbs_flow_spec *)kern_spec)->size;
- ib_spec += ((union ib_flow_spec *)ib_spec)->size;
- }
- if (cmd.flow_attr.size || (i != flow_attr->num_of_specs)) {
- pr_warn("create flow failed, flow %d: %d bytes left from uverb cmd\n",
- i, cmd.flow_attr.size);
- goto err_free;
- }
- flow_id = ib_create_flow(qp, flow_attr, IB_FLOW_DOMAIN_USER);
- if (IS_ERR(flow_id)) {
- err = PTR_ERR(flow_id);
- goto err_free;
- }
- flow_id->qp = qp;
- flow_id->uobject = uobj;
- uobj->object = flow_id;
-
- err = idr_add_uobj(&ib_uverbs_rule_idr, uobj);
- if (err)
- goto destroy_flow;
-
- memset(&resp, 0, sizeof(resp));
- resp.flow_handle = uobj->id;
-
- err = ib_copy_to_udata(ucore,
- &resp, sizeof(resp));
- if (err)
- goto err_copy;
-
- put_qp_read(qp);
- mutex_lock(&file->mutex);
- list_add_tail(&uobj->list, &file->ucontext->rule_list);
- mutex_unlock(&file->mutex);
-
- uobj->live = 1;
-
- up_write(&uobj->mutex);
- kfree(flow_attr);
- if (cmd.flow_attr.num_of_specs)
- kfree(kern_flow_attr);
- return 0;
-err_copy:
- idr_remove_uobj(&ib_uverbs_rule_idr, uobj);
-destroy_flow:
- ib_destroy_flow(flow_id);
-err_free:
- kfree(flow_attr);
-err_put:
- put_qp_read(qp);
-err_uobj:
- put_uobj_write(uobj);
-err_free_attr:
- if (cmd.flow_attr.num_of_specs)
- kfree(kern_flow_attr);
- return err;
-}
-
-int ib_uverbs_ex_destroy_flow(struct ib_uverbs_file *file,
- struct ib_udata *ucore,
- struct ib_udata *uhw)
-{
- struct ib_uverbs_destroy_flow cmd;
- struct ib_flow *flow_id;
- struct ib_uobject *uobj;
- int ret;
-
- ret = ib_copy_from_udata(&cmd, ucore, sizeof(cmd));
- if (ret)
- return ret;
-
- uobj = idr_write_uobj(&ib_uverbs_rule_idr, cmd.flow_handle,
- file->ucontext);
- if (!uobj)
- return -EINVAL;
- flow_id = uobj->object;
-
- ret = ib_destroy_flow(flow_id);
- if (!ret)
- uobj->live = 0;
-
- put_uobj_write(uobj);
-
- idr_remove_uobj(&ib_uverbs_rule_idr, uobj);
-
- mutex_lock(&file->mutex);
- list_del(&uobj->list);
- mutex_unlock(&file->mutex);
-
- put_uobj(uobj);
-
- return ret;
-}
-
-ssize_t ib_uverbs_exp_modify_qp(struct ib_uverbs_file *file,
- struct ib_udata *ucore, struct ib_udata *uhw)
-{
- const char __user *buf = ucore->inbuf;
- int in_len = ucore->inlen + uhw->inlen;
- int out_len = ucore->outlen + uhw->outlen;
-
- return __uverbs_modify_qp(file, buf, in_len, out_len,
- IB_USER_VERBS_CMD_EXTENDED);
-}
-
-
-ssize_t ib_uverbs_exp_create_cq(struct ib_uverbs_file *file,
- struct ib_udata *ucore, struct ib_udata *uhw)
-{
- const char __user *buf = ucore->inbuf;
- int in_len = ucore->inlen + uhw->inlen;
- int out_len = ucore->outlen + uhw->outlen;
- struct ib_uverbs_create_cq_ex cmd;
-
- if (copy_from_user(&cmd, buf, sizeof(cmd)))
- return -EFAULT;
-
- return create_cq(file, buf, in_len, out_len, &cmd,
- IB_USER_VERBS_CMD_EXTENDED, ucore->outbuf);
-}
-
-ssize_t ib_uverbs_exp_modify_cq(struct ib_uverbs_file *file,
- struct ib_udata *ucore, struct ib_udata *uhw)
-{
- const char __user *buf = ucore->inbuf;
- int in_len = ucore->inlen + uhw->inlen;
- struct ib_uverbs_modify_cq_ex cmd;
- struct ib_cq *cq;
- struct ib_cq_attr attr;
- int ret;
-
- if (copy_from_user(&cmd, buf, sizeof(cmd)))
- return -EFAULT;
-
- cq = idr_read_cq(cmd.cq_handle, file->ucontext, 0);
- if (!cq)
- return -EINVAL;
-
- attr.moderation.cq_count = cmd.cq_count;
- attr.moderation.cq_period = cmd.cq_period;
- attr.cq_cap_flags = cmd.cq_cap_flags;
-
- ret = ib_modify_cq(cq, &attr, cmd.attr_mask);
-
- put_cq_read(cq);
-
- return ret ? ret : in_len;
-}
-
-
-ssize_t ib_uverbs_exp_query_device(struct ib_uverbs_file *file,
- struct ib_udata *ucore, struct ib_udata *uhw)
-{
- struct ib_uverbs_exp_query_device_resp resp;
- struct ib_exp_device_attr exp_attr;
- int ret;
-
- if (ucore->outlen + uhw->outlen < sizeof(resp))
- return -ENOSPC;
-
- memset(&resp, 0, sizeof(resp));
- memset(&exp_attr, 0, sizeof(exp_attr));
- ret = ib_exp_query_device(file->device->ib_dev, &exp_attr);
- if (ret)
- return ret;
-
- ib_uverbs_query_device_assign(&resp.base, &exp_attr.base, file);
-
- resp.comp_mask = 0;
- resp.device_cap_flags2 = 0;
-
- /*
- * Handle regular attr fields
- */
- if (exp_attr.base.comp_mask & IB_DEVICE_ATTR_WITH_TIMESTAMP_MASK) {
- resp.timestamp_mask = exp_attr.base.timestamp_mask;
- resp.comp_mask |= IB_EXP_DEVICE_ATTR_WITH_TIMESTAMP_MASK;
- }
-
- if (exp_attr.base.comp_mask & IB_DEVICE_ATTR_WITH_HCA_CORE_CLOCK) {
- resp.hca_core_clock = exp_attr.base.hca_core_clock;
- resp.comp_mask |= IB_EXP_DEVICE_ATTR_WITH_HCA_CORE_CLOCK;
- }
-
- /*
- * Handle experimental attr fields
- */
- if (exp_attr.exp_comp_mask & IB_EXP_DEVICE_ATTR_CAP_FLAGS2) {
- resp.device_cap_flags2 = exp_attr.device_cap_flags2;
- resp.comp_mask |= IB_EXP_DEVICE_ATTR_CAP_FLAGS2;
- }
-
- if (exp_attr.exp_comp_mask & IB_EXP_DEVICE_ATTR_DC_REQ_RD) {
- resp.dc_rd_req = exp_attr.dc_rd_req;
- resp.comp_mask |= IB_EXP_DEVICE_ATTR_DC_REQ_RD;
- }
-
- if (exp_attr.exp_comp_mask & IB_EXP_DEVICE_ATTR_DC_RES_RD) {
- resp.dc_rd_res = exp_attr.dc_rd_res;
- resp.comp_mask |= IB_EXP_DEVICE_ATTR_DC_RES_RD;
- }
-
- if (exp_attr.exp_comp_mask & IB_EXP_DEVICE_ATTR_INLINE_RECV_SZ) {
- resp.inline_recv_sz = exp_attr.inline_recv_sz;
- resp.comp_mask |= IB_EXP_DEVICE_ATTR_INLINE_RECV_SZ;
- }
-
- if (exp_attr.exp_comp_mask & IB_EXP_DEVICE_ATTR_RSS_TBL_SZ) {
- resp.max_rss_tbl_sz = exp_attr.max_rss_tbl_sz;
- resp.comp_mask |= IB_EXP_DEVICE_ATTR_RSS_TBL_SZ;
- }
-
- if (copy_to_user(ucore->outbuf, &resp, sizeof(resp)))
- return -EFAULT;
-
- return ucore->inlen + uhw->inlen;
-}
-
-ssize_t ib_uverbs_exp_create_qp(struct ib_uverbs_file *file,
- struct ib_udata *ucore, struct ib_udata *uhw)
-{
- struct ib_uqp_object *obj;
- struct ib_device *device;
- struct ib_pd *pd = NULL;
- struct ib_xrcd *xrcd = NULL;
- struct ib_uobject *uninitialized_var(xrcd_uobj);
- struct ib_cq *scq = NULL, *rcq = NULL;
- struct ib_srq *srq = NULL;
- struct ib_qp *qp;
- struct ib_exp_qp_init_attr attr;
- int ret;
- struct ib_uverbs_exp_create_qp cmd_exp;
- struct ib_uverbs_exp_create_qp_resp resp_exp;
- struct ib_qp *parentqp = NULL;
-
- memset(&cmd_exp, 0, sizeof(cmd_exp));
-
- ret = ucore->ops->copy_from(&cmd_exp, ucore, sizeof(cmd_exp));
- if (ret)
- return ret;
-
- if (!disable_raw_qp_enforcement &&
- cmd_exp.qp_type == IB_QPT_RAW_PACKET && priv_check(curthread,
- PRIV_NET_RAW))
- return -EPERM;
-
- obj = kzalloc(sizeof(*obj), GFP_KERNEL);
- if (!obj)
- return -ENOMEM;
-
- init_uobj(&obj->uevent.uobject, cmd_exp.user_handle, file->ucontext,
- &qp_lock_class);
- down_write(&obj->uevent.uobject.mutex);
-
- if (cmd_exp.qp_type == IB_QPT_XRC_TGT) {
- xrcd = idr_read_xrcd(cmd_exp.pd_handle, file->ucontext, &xrcd_uobj);
- if (!xrcd) {
- ret = -EINVAL;
- goto err_put;
- }
- device = xrcd->device;
- } else {
- if (cmd_exp.qp_type == IB_QPT_XRC_INI) {
- cmd_exp.max_recv_wr = 0;
- cmd_exp.max_recv_sge = 0;
- } else {
- if (cmd_exp.is_srq) {
- srq = idr_read_srq(cmd_exp.srq_handle, file->ucontext);
- if (!srq || srq->srq_type != IB_SRQT_BASIC) {
- ret = -EINVAL;
- goto err_put;
- }
- }
-
- if (cmd_exp.recv_cq_handle != cmd_exp.send_cq_handle) {
- rcq = idr_read_cq(cmd_exp.recv_cq_handle, file->ucontext, 0);
- if (!rcq) {
- ret = -EINVAL;
- goto err_put;
- }
- }
- }
-
- scq = idr_read_cq(cmd_exp.send_cq_handle, file->ucontext, !!rcq);
- rcq = rcq ?: scq;
- pd = idr_read_pd(cmd_exp.pd_handle, file->ucontext);
- if (!pd || !scq) {
- ret = -EINVAL;
- goto err_put;
- }
-
- device = pd->device;
- }
-
- memset(&attr, 0, sizeof(attr));
- attr.event_handler = ib_uverbs_qp_event_handler;
- attr.qp_context = file;
- attr.send_cq = scq;
- attr.recv_cq = rcq;
- attr.srq = srq;
- attr.xrcd = xrcd;
- attr.sq_sig_type = cmd_exp.sq_sig_all ? IB_SIGNAL_ALL_WR : IB_SIGNAL_REQ_WR;
- attr.qp_type = cmd_exp.qp_type;
- attr.create_flags = 0;
-
- attr.cap.max_send_wr = cmd_exp.max_send_wr;
- attr.cap.max_recv_wr = cmd_exp.max_recv_wr;
- attr.cap.max_send_sge = cmd_exp.max_send_sge;
- attr.cap.max_recv_sge = cmd_exp.max_recv_sge;
- attr.cap.max_inline_data = cmd_exp.max_inline_data;
-
- if (cmd_exp.comp_mask & IB_UVERBS_EXP_CREATE_QP_CAP_FLAGS)
- attr.create_flags |= cmd_exp.qp_cap_flags &
- (IB_QP_CREATE_CROSS_CHANNEL |
- IB_QP_CREATE_MANAGED_SEND |
- IB_QP_CREATE_MANAGED_RECV);
-
- if (cmd_exp.comp_mask & IB_UVERBS_EXP_CREATE_QP_QPG) {
- struct ib_uverbs_qpg *qpg;
- if (cmd_exp.qp_type != IB_QPT_RAW_PACKET &&
- cmd_exp.qp_type != IB_QPT_UD) {
- ret = -EINVAL;
- goto err_put;
- }
- qpg = &cmd_exp.qpg;
- switch (qpg->qpg_type) {
- case IB_QPG_PARENT:
- attr.parent_attrib.rss_child_count =
- qpg->parent_attrib.rss_child_count;
- attr.parent_attrib.tss_child_count =
- qpg->parent_attrib.tss_child_count;
- break;
- case IB_QPG_CHILD_RX:
- case IB_QPG_CHILD_TX:
- parentqp = idr_read_qp(qpg->parent_handle,
- file->ucontext);
- if (!parentqp) {
- ret = -EINVAL;
- goto err_put;
- }
- attr.qpg_parent = parentqp;
- break;
- default:
- ret = -EINVAL;
- goto err_put;
- }
- attr.qpg_type = qpg->qpg_type;
- }
-
- if (cmd_exp.comp_mask & IB_UVERBS_EXP_CREATE_QP_INL_RECV)
- attr.max_inl_recv = cmd_exp.max_inl_recv;
-
- obj->uevent.events_reported = 0;
- INIT_LIST_HEAD(&obj->uevent.event_list);
- INIT_LIST_HEAD(&obj->mcast_list);
-
- if (cmd_exp.qp_type == IB_QPT_XRC_TGT)
- qp = ib_create_qp(pd, (struct ib_qp_init_attr *)&attr);
- else
- qp = device->exp_create_qp(pd, &attr, uhw);
-
- if (IS_ERR(qp)) {
- ret = PTR_ERR(qp);
- goto err_put;
- }
-
- if (cmd_exp.qp_type != IB_QPT_XRC_TGT) {
- qp->real_qp = qp;
- qp->device = device;
- qp->pd = pd;
- qp->send_cq = attr.send_cq;
- qp->recv_cq = attr.recv_cq;
- qp->srq = attr.srq;
- qp->event_handler = attr.event_handler;
- qp->qp_context = attr.qp_context;
- qp->qp_type = attr.qp_type;
- atomic_set(&qp->usecnt, 0);
- atomic_inc(&pd->usecnt);
- atomic_inc(&attr.send_cq->usecnt);
- if (attr.recv_cq)
- atomic_inc(&attr.recv_cq->usecnt);
- if (attr.srq)
- atomic_inc(&attr.srq->usecnt);
- }
- qp->uobject = &obj->uevent.uobject;
-
- obj->uevent.uobject.object = qp;
- ret = idr_add_uobj(&ib_uverbs_qp_idr, &obj->uevent.uobject);
- if (ret)
- goto err_destroy;
-
- memset(&resp_exp, 0, sizeof(resp_exp));
- resp_exp.qpn = qp->qp_num;
- resp_exp.qp_handle = obj->uevent.uobject.id;
- resp_exp.max_recv_sge = attr.cap.max_recv_sge;
- resp_exp.max_send_sge = attr.cap.max_send_sge;
- resp_exp.max_recv_wr = attr.cap.max_recv_wr;
- resp_exp.max_send_wr = attr.cap.max_send_wr;
- resp_exp.max_inline_data = attr.cap.max_inline_data;
-
- if (cmd_exp.comp_mask & IB_UVERBS_EXP_CREATE_QP_INL_RECV) {
- resp_exp.comp_mask |= IB_UVERBS_EXP_CREATE_QP_RESP_INL_RECV;
- resp_exp.max_inl_recv = attr.max_inl_recv;
- }
-
- ret = ucore->ops->copy_to(ucore, &resp_exp, sizeof(resp_exp));
- if (ret)
- goto err_copy;
-
- if (xrcd) {
- obj->uxrcd = container_of(xrcd_uobj, struct ib_uxrcd_object, uobject);
- atomic_inc(&obj->uxrcd->refcnt);
- put_xrcd_read(xrcd_uobj);
- }
-
- if (pd)
- put_pd_read(pd);
- if (scq)
- put_cq_read(scq);
- if (rcq && rcq != scq)
- put_cq_read(rcq);
- if (srq)
- put_srq_read(srq);
- if (parentqp)
- put_qp_read(parentqp);
-
- mutex_lock(&file->mutex);
- list_add_tail(&obj->uevent.uobject.list, &file->ucontext->qp_list);
- mutex_unlock(&file->mutex);
-
- obj->uevent.uobject.live = 1;
-
- up_write(&obj->uevent.uobject.mutex);
-
- return ucore->inlen + uhw->inlen;
-
-err_copy:
- idr_remove_uobj(&ib_uverbs_qp_idr, &obj->uevent.uobject);
-
-err_destroy:
- ib_destroy_qp(qp);
-
-err_put:
- if (xrcd)
- put_xrcd_read(xrcd_uobj);
- if (pd)
- put_pd_read(pd);
- if (scq)
- put_cq_read(scq);
- if (rcq && rcq != scq)
- put_cq_read(rcq);
- if (srq)
- put_srq_read(srq);
- if (parentqp)
- put_qp_read(parentqp);
-
- put_uobj_write(&obj->uevent.uobject);
- return ret;
-}
-
-int ib_exp_query_device(struct ib_device *device,
- struct ib_exp_device_attr *device_attr)
-{
- return device->exp_query_device(device, device_attr);
-}
-EXPORT_SYMBOL(ib_exp_query_device);
diff --git a/sys/ofed/drivers/infiniband/core/uverbs_main.c b/sys/ofed/drivers/infiniband/core/uverbs_main.c
deleted file mode 100644
index 269ef1c..0000000
--- a/sys/ofed/drivers/infiniband/core/uverbs_main.c
+++ /dev/null
@@ -1,1431 +0,0 @@
-/*
- * Copyright (c) 2005 Topspin Communications. All rights reserved.
- * Copyright (c) 2005, 2006 Cisco Systems. All rights reserved.
- * Copyright (c) 2005 Mellanox Technologies. All rights reserved.
- * Copyright (c) 2005 Voltaire, Inc. All rights reserved.
- * Copyright (c) 2005 PathScale, Inc. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-#include <linux/module.h>
-#include <linux/device.h>
-#include <linux/err.h>
-#include <linux/fs.h>
-#include <linux/poll.h>
-#include <linux/sched.h>
-#include <linux/file.h>
-#include <linux/cdev.h>
-#include <linux/slab.h>
-#include <linux/ktime.h>
-#include <linux/rbtree.h>
-#include <linux/math64.h>
-
-#include <asm/uaccess.h>
-
-#include "uverbs.h"
-
-MODULE_AUTHOR("Roland Dreier");
-MODULE_DESCRIPTION("InfiniBand userspace verbs access");
-MODULE_LICENSE("Dual BSD/GPL");
-
-enum {
- IB_UVERBS_MAJOR = 231,
- IB_UVERBS_BASE_MINOR = 192,
- IB_UVERBS_MAX_DEVICES = 32
-};
-
-#define IB_UVERBS_BASE_DEV MKDEV(IB_UVERBS_MAJOR, IB_UVERBS_BASE_MINOR)
-
-static int uverbs_copy_from_udata_ex(void *dest, struct ib_udata *udata, size_t len)
-{
- return copy_from_user(dest, udata->inbuf, min(udata->inlen, len)) ? -EFAULT : 0;
-}
-
-static int uverbs_copy_to_udata_ex(struct ib_udata *udata, void *src, size_t len)
-{
- return copy_to_user(udata->outbuf, src, min(udata->outlen, len)) ? -EFAULT : 0;
-}
-
-static struct ib_udata_ops uverbs_copy_ex = {
- .copy_from = uverbs_copy_from_udata_ex,
- .copy_to = uverbs_copy_to_udata_ex
-};
-
-#define INIT_UDATA_EX(udata, ibuf, obuf, ilen, olen) \
- do { \
- (udata)->ops = &uverbs_copy_ex; \
- (udata)->inbuf = (void __user *)(unsigned long)(ibuf); \
- (udata)->outbuf = (void __user *)(unsigned long)(obuf); \
- (udata)->inlen = (ilen); \
- (udata)->outlen = (olen); \
- } while (0)
-
-
-static struct class *uverbs_class;
-
-DEFINE_SPINLOCK(ib_uverbs_idr_lock);
-DEFINE_IDR(ib_uverbs_pd_idr);
-DEFINE_IDR(ib_uverbs_mr_idr);
-DEFINE_IDR(ib_uverbs_mw_idr);
-DEFINE_IDR(ib_uverbs_ah_idr);
-DEFINE_IDR(ib_uverbs_cq_idr);
-DEFINE_IDR(ib_uverbs_qp_idr);
-DEFINE_IDR(ib_uverbs_srq_idr);
-DEFINE_IDR(ib_uverbs_xrcd_idr);
-DEFINE_IDR(ib_uverbs_rule_idr);
-DEFINE_IDR(ib_uverbs_dct_idr);
-
-static DEFINE_SPINLOCK(map_lock);
-static DECLARE_BITMAP(dev_map, IB_UVERBS_MAX_DEVICES);
-
-static ssize_t (*uverbs_cmd_table[])(struct ib_uverbs_file *file,
- const char __user *buf, int in_len,
- int out_len) = {
- [IB_USER_VERBS_CMD_GET_CONTEXT] = ib_uverbs_get_context,
- [IB_USER_VERBS_CMD_QUERY_DEVICE] = ib_uverbs_query_device,
- [IB_USER_VERBS_CMD_QUERY_PORT] = ib_uverbs_query_port,
- [IB_USER_VERBS_CMD_ALLOC_PD] = ib_uverbs_alloc_pd,
- [IB_USER_VERBS_CMD_DEALLOC_PD] = ib_uverbs_dealloc_pd,
- [IB_USER_VERBS_CMD_REG_MR] = ib_uverbs_reg_mr,
- [IB_USER_VERBS_CMD_DEREG_MR] = ib_uverbs_dereg_mr,
- [IB_USER_VERBS_CMD_ALLOC_MW] = ib_uverbs_alloc_mw,
- [IB_USER_VERBS_CMD_DEALLOC_MW] = ib_uverbs_dealloc_mw,
- [IB_USER_VERBS_CMD_CREATE_COMP_CHANNEL] = ib_uverbs_create_comp_channel,
- [IB_USER_VERBS_CMD_CREATE_CQ] = ib_uverbs_create_cq,
- [IB_USER_VERBS_CMD_RESIZE_CQ] = ib_uverbs_resize_cq,
- [IB_USER_VERBS_CMD_POLL_CQ] = ib_uverbs_poll_cq,
- [IB_USER_VERBS_CMD_REQ_NOTIFY_CQ] = ib_uverbs_req_notify_cq,
- [IB_USER_VERBS_CMD_DESTROY_CQ] = ib_uverbs_destroy_cq,
- [IB_USER_VERBS_CMD_CREATE_QP] = ib_uverbs_create_qp,
- [IB_USER_VERBS_CMD_QUERY_QP] = ib_uverbs_query_qp,
- [IB_USER_VERBS_CMD_MODIFY_QP] = ib_uverbs_modify_qp,
- [IB_USER_VERBS_CMD_DESTROY_QP] = ib_uverbs_destroy_qp,
- [IB_USER_VERBS_CMD_POST_SEND] = ib_uverbs_post_send,
- [IB_USER_VERBS_CMD_POST_RECV] = ib_uverbs_post_recv,
- [IB_USER_VERBS_CMD_POST_SRQ_RECV] = ib_uverbs_post_srq_recv,
- [IB_USER_VERBS_CMD_CREATE_AH] = ib_uverbs_create_ah,
- [IB_USER_VERBS_CMD_DESTROY_AH] = ib_uverbs_destroy_ah,
- [IB_USER_VERBS_CMD_ATTACH_MCAST] = ib_uverbs_attach_mcast,
- [IB_USER_VERBS_CMD_DETACH_MCAST] = ib_uverbs_detach_mcast,
- [IB_USER_VERBS_CMD_CREATE_SRQ] = ib_uverbs_create_srq,
- [IB_USER_VERBS_CMD_MODIFY_SRQ] = ib_uverbs_modify_srq,
- [IB_USER_VERBS_CMD_QUERY_SRQ] = ib_uverbs_query_srq,
- [IB_USER_VERBS_CMD_DESTROY_SRQ] = ib_uverbs_destroy_srq,
- [IB_USER_VERBS_CMD_OPEN_XRCD] = ib_uverbs_open_xrcd,
- [IB_USER_VERBS_CMD_CLOSE_XRCD] = ib_uverbs_close_xrcd,
- [IB_USER_VERBS_CMD_CREATE_XSRQ] = ib_uverbs_create_xsrq,
- [IB_USER_VERBS_CMD_OPEN_QP] = ib_uverbs_open_qp,
-};
-
-static int (*uverbs_ex_cmd_table[])(struct ib_uverbs_file *file,
- struct ib_udata *ucore,
- struct ib_udata *uhw) = {
- [IB_USER_VERBS_EX_CMD_CREATE_FLOW] = ib_uverbs_ex_create_flow,
- [IB_USER_VERBS_EX_CMD_DESTROY_FLOW] = ib_uverbs_ex_destroy_flow,
-};
-
-static ssize_t (*uverbs_exp_cmd_table[])(struct ib_uverbs_file *file,
- struct ib_udata *ucore,
- struct ib_udata *uhw) = {
- [IB_USER_VERBS_EXP_CMD_CREATE_QP] = ib_uverbs_exp_create_qp,
- [IB_USER_VERBS_EXP_CMD_MODIFY_CQ] = ib_uverbs_exp_modify_cq,
- [IB_USER_VERBS_EXP_CMD_MODIFY_QP] = ib_uverbs_exp_modify_qp,
- [IB_USER_VERBS_EXP_CMD_CREATE_CQ] = ib_uverbs_exp_create_cq,
- [IB_USER_VERBS_EXP_CMD_QUERY_DEVICE] = ib_uverbs_exp_query_device,
- [IB_USER_VERBS_EXP_CMD_CREATE_DCT] = ib_uverbs_exp_create_dct,
- [IB_USER_VERBS_EXP_CMD_DESTROY_DCT] = ib_uverbs_exp_destroy_dct,
- [IB_USER_VERBS_EXP_CMD_QUERY_DCT] = ib_uverbs_exp_query_dct,
-};
-
-static void ib_uverbs_add_one(struct ib_device *device);
-static void ib_uverbs_remove_one(struct ib_device *device);
-
-static void ib_uverbs_release_dev(struct kref *ref)
-{
- struct ib_uverbs_device *dev =
- container_of(ref, struct ib_uverbs_device, ref);
-
- complete(&dev->comp);
-}
-
-static void ib_uverbs_release_event_file(struct kref *ref)
-{
- struct ib_uverbs_event_file *file =
- container_of(ref, struct ib_uverbs_event_file, ref);
-
- kfree(file);
-}
-
-void ib_uverbs_release_ucq(struct ib_uverbs_file *file,
- struct ib_uverbs_event_file *ev_file,
- struct ib_ucq_object *uobj)
-{
- struct ib_uverbs_event *evt, *tmp;
-
- if (ev_file) {
- spin_lock_irq(&ev_file->lock);
- list_for_each_entry_safe(evt, tmp, &uobj->comp_list, obj_list) {
- list_del(&evt->list);
- kfree(evt);
- }
- spin_unlock_irq(&ev_file->lock);
-
- kref_put(&ev_file->ref, ib_uverbs_release_event_file);
- }
-
- spin_lock_irq(&file->async_file->lock);
- list_for_each_entry_safe(evt, tmp, &uobj->async_list, obj_list) {
- list_del(&evt->list);
- kfree(evt);
- }
- spin_unlock_irq(&file->async_file->lock);
-}
-
-void ib_uverbs_release_uevent(struct ib_uverbs_file *file,
- struct ib_uevent_object *uobj)
-{
- struct ib_uverbs_event *evt, *tmp;
-
- spin_lock_irq(&file->async_file->lock);
- list_for_each_entry_safe(evt, tmp, &uobj->event_list, obj_list) {
- list_del(&evt->list);
- kfree(evt);
- }
- spin_unlock_irq(&file->async_file->lock);
-}
-
-static void ib_uverbs_detach_umcast(struct ib_qp *qp,
- struct ib_uqp_object *uobj)
-{
- struct ib_uverbs_mcast_entry *mcast, *tmp;
-
- list_for_each_entry_safe(mcast, tmp, &uobj->mcast_list, list) {
- ib_detach_mcast(qp, &mcast->gid, mcast->lid);
- list_del(&mcast->list);
- kfree(mcast);
- }
-}
-
-static int ib_uverbs_cleanup_ucontext(struct ib_uverbs_file *file,
- struct ib_ucontext *context)
-{
- struct ib_uobject *uobj, *tmp;
- int err;
-
- if (!context)
- return 0;
-
- context->closing = 1;
-
- list_for_each_entry_safe(uobj, tmp, &context->ah_list, list) {
- struct ib_ah *ah = uobj->object;
-
- idr_remove_uobj(&ib_uverbs_ah_idr, uobj);
- ib_destroy_ah(ah);
- kfree(uobj);
- }
-
- /* Remove MWs before QPs, in order to support type 2A MWs. */
- list_for_each_entry_safe(uobj, tmp, &context->mw_list, list) {
- struct ib_mw *mw = uobj->object;
-
- idr_remove_uobj(&ib_uverbs_mw_idr, uobj);
- err = ib_dealloc_mw(mw);
- if (err) {
- pr_info("user_verbs: couldn't deallocate MW during cleanup.\n");
- pr_info("user_verbs: the system may have become unstable.\n");
- }
- kfree(uobj);
- }
- list_for_each_entry_safe(uobj, tmp, &context->rule_list, list) {
- struct ib_flow *flow_id = uobj->object;
-
- idr_remove_uobj(&ib_uverbs_rule_idr, uobj);
- ib_destroy_flow(flow_id);
- kfree(uobj);
- }
-
- list_for_each_entry_safe(uobj, tmp, &context->qp_list, list) {
- struct ib_qp *qp = uobj->object;
- struct ib_uqp_object *uqp =
- container_of(uobj, struct ib_uqp_object, uevent.uobject);
-
- idr_remove_uobj(&ib_uverbs_qp_idr, uobj);
-
- ib_uverbs_detach_umcast(qp, uqp);
- err = ib_destroy_qp(qp);
- if (err)
- pr_info("destroying uverbs qp failed: err %d\n", err);
-
- ib_uverbs_release_uevent(file, &uqp->uevent);
- kfree(uqp);
- }
-
- list_for_each_entry_safe(uobj, tmp, &context->dct_list, list) {
- struct ib_dct *dct = uobj->object;
- struct ib_udct_object *udct =
- container_of(uobj, struct ib_udct_object, uobject);
-
- idr_remove_uobj(&ib_uverbs_dct_idr, uobj);
-
- err = ib_destroy_dct(dct);
- if (err)
- pr_info("destroying uverbs dct failed: err %d\n", err);
-
- kfree(udct);
- }
-
- list_for_each_entry_safe(uobj, tmp, &context->srq_list, list) {
- struct ib_srq *srq = uobj->object;
- struct ib_uevent_object *uevent =
- container_of(uobj, struct ib_uevent_object, uobject);
-
- idr_remove_uobj(&ib_uverbs_srq_idr, uobj);
- err = ib_destroy_srq(srq);
- if (err)
- pr_info("destroying uverbs srq failed: err %d\n", err);
- ib_uverbs_release_uevent(file, uevent);
- kfree(uevent);
- }
-
- list_for_each_entry_safe(uobj, tmp, &context->cq_list, list) {
- struct ib_cq *cq = uobj->object;
- struct ib_uverbs_event_file *ev_file = cq->cq_context;
- struct ib_ucq_object *ucq =
- container_of(uobj, struct ib_ucq_object, uobject);
-
- idr_remove_uobj(&ib_uverbs_cq_idr, uobj);
- err = ib_destroy_cq(cq);
- if (err)
- pr_info("destroying uverbs cq failed: err %d\n", err);
-
- ib_uverbs_release_ucq(file, ev_file, ucq);
- kfree(ucq);
- }
-
- list_for_each_entry_safe(uobj, tmp, &context->mr_list, list) {
- struct ib_mr *mr = uobj->object;
-
- idr_remove_uobj(&ib_uverbs_mr_idr, uobj);
- err = ib_dereg_mr(mr);
- if (err) {
- pr_info("user_verbs: couldn't deregister an MR during cleanup.\n");
- pr_info("user_verbs: the system may have become unstable.\n");
- }
- kfree(uobj);
- }
-
- mutex_lock(&file->device->xrcd_tree_mutex);
- list_for_each_entry_safe(uobj, tmp, &context->xrcd_list, list) {
- struct ib_xrcd *xrcd = uobj->object;
- struct ib_uxrcd_object *uxrcd =
- container_of(uobj, struct ib_uxrcd_object, uobject);
-
- idr_remove_uobj(&ib_uverbs_xrcd_idr, uobj);
- ib_uverbs_dealloc_xrcd(file->device, xrcd);
- kfree(uxrcd);
- }
- mutex_unlock(&file->device->xrcd_tree_mutex);
-
- list_for_each_entry_safe(uobj, tmp, &context->pd_list, list) {
- struct ib_pd *pd = uobj->object;
-
- idr_remove_uobj(&ib_uverbs_pd_idr, uobj);
- ib_dealloc_pd(pd);
- kfree(uobj);
- }
-
- return context->device->dealloc_ucontext(context);
-}
-
-static void ib_uverbs_release_file(struct kref *ref)
-{
- struct ib_uverbs_file *file =
- container_of(ref, struct ib_uverbs_file, ref);
-
- module_put(file->device->ib_dev->owner);
- kref_put(&file->device->ref, ib_uverbs_release_dev);
-
- kfree(file);
-}
-
-static ssize_t ib_uverbs_event_read(struct file *filp, char __user *buf,
- size_t count, loff_t *pos)
-{
- struct ib_uverbs_event_file *file = filp->private_data;
- struct ib_uverbs_event *event;
- int eventsz;
- int ret = 0;
-
- spin_lock_irq(&file->lock);
-
- while (list_empty(&file->event_list)) {
- spin_unlock_irq(&file->lock);
-
- if (filp->f_flags & O_NONBLOCK)
- return -EAGAIN;
-
- if (wait_event_interruptible(file->poll_wait,
- !list_empty(&file->event_list)))
- return -ERESTARTSYS;
-
- spin_lock_irq(&file->lock);
- }
-
- event = list_entry(file->event_list.next, struct ib_uverbs_event, list);
-
- if (file->is_async)
- eventsz = sizeof (struct ib_uverbs_async_event_desc);
- else
- eventsz = sizeof (struct ib_uverbs_comp_event_desc);
-
- if (eventsz > count) {
- ret = -EINVAL;
- event = NULL;
- } else {
- list_del(file->event_list.next);
- if (event->counter) {
- ++(*event->counter);
- list_del(&event->obj_list);
- }
- }
-
- spin_unlock_irq(&file->lock);
-
- if (event) {
- if (copy_to_user(buf, event, eventsz))
- ret = -EFAULT;
- else
- ret = eventsz;
- }
-
- kfree(event);
-
- return ret;
-}
-
-static unsigned int ib_uverbs_event_poll(struct file *filp,
- struct poll_table_struct *wait)
-{
- unsigned int pollflags = 0;
- struct ib_uverbs_event_file *file = filp->private_data;
-
- file->filp = filp;
- poll_wait(filp, &file->poll_wait, wait);
-
- spin_lock_irq(&file->lock);
- if (!list_empty(&file->event_list))
- pollflags = POLLIN | POLLRDNORM;
- spin_unlock_irq(&file->lock);
-
- return pollflags;
-}
-
-static int ib_uverbs_event_fasync(int fd, struct file *filp, int on)
-{
- struct ib_uverbs_event_file *file = filp->private_data;
-
- return fasync_helper(fd, filp, on, &file->async_queue);
-}
-
-static int ib_uverbs_event_close(struct inode *inode, struct file *filp)
-{
- struct ib_uverbs_event_file *file = filp->private_data;
- struct ib_uverbs_event *entry, *tmp;
-
- spin_lock_irq(&file->lock);
- file->is_closed = 1;
- list_for_each_entry_safe(entry, tmp, &file->event_list, list) {
- if (entry->counter)
- list_del(&entry->obj_list);
- kfree(entry);
- }
- spin_unlock_irq(&file->lock);
-
- if (file->is_async) {
- ib_unregister_event_handler(&file->uverbs_file->event_handler);
- kref_put(&file->uverbs_file->ref, ib_uverbs_release_file);
- }
- kref_put(&file->ref, ib_uverbs_release_event_file);
-
- return 0;
-}
-
-static const struct file_operations uverbs_event_fops = {
- .owner = THIS_MODULE,
- .read = ib_uverbs_event_read,
- .poll = ib_uverbs_event_poll,
- .release = ib_uverbs_event_close,
- .fasync = ib_uverbs_event_fasync,
- .llseek = no_llseek,
-};
-
-void ib_uverbs_comp_handler(struct ib_cq *cq, void *cq_context)
-{
- struct ib_uverbs_event_file *file = cq_context;
- struct ib_ucq_object *uobj;
- struct ib_uverbs_event *entry;
- unsigned long flags;
-
- if (!file)
- return;
-
- spin_lock_irqsave(&file->lock, flags);
- if (file->is_closed) {
- spin_unlock_irqrestore(&file->lock, flags);
- return;
- }
-
- entry = kmalloc(sizeof *entry, GFP_ATOMIC);
- if (!entry) {
- spin_unlock_irqrestore(&file->lock, flags);
- return;
- }
-
- uobj = container_of(cq->uobject, struct ib_ucq_object, uobject);
-
- entry->desc.comp.cq_handle = cq->uobject->user_handle;
- entry->counter = &uobj->comp_events_reported;
-
- list_add_tail(&entry->list, &file->event_list);
- list_add_tail(&entry->obj_list, &uobj->comp_list);
- spin_unlock_irqrestore(&file->lock, flags);
-
- wake_up_interruptible(&file->poll_wait);
- kill_fasync(&file->async_queue, SIGIO, POLL_IN);
-}
-
-static void ib_uverbs_async_handler(struct ib_uverbs_file *file,
- __u64 element, __u64 event,
- struct list_head *obj_list,
- u32 *counter)
-{
- struct ib_uverbs_event *entry;
- unsigned long flags;
-
- spin_lock_irqsave(&file->async_file->lock, flags);
- if (file->async_file->is_closed) {
- spin_unlock_irqrestore(&file->async_file->lock, flags);
- return;
- }
-
- entry = kmalloc(sizeof *entry, GFP_ATOMIC);
- if (!entry) {
- spin_unlock_irqrestore(&file->async_file->lock, flags);
- return;
- }
-
- entry->desc.async.element = element;
- entry->desc.async.event_type = event;
- entry->counter = counter;
-
- list_add_tail(&entry->list, &file->async_file->event_list);
- if (obj_list)
- list_add_tail(&entry->obj_list, obj_list);
- spin_unlock_irqrestore(&file->async_file->lock, flags);
-
- wake_up_interruptible(&file->async_file->poll_wait);
- kill_fasync(&file->async_file->async_queue, SIGIO, POLL_IN);
-}
-
-void ib_uverbs_cq_event_handler(struct ib_event *event, void *context_ptr)
-{
- struct ib_ucq_object *uobj = container_of(event->element.cq->uobject,
- struct ib_ucq_object, uobject);
-
- ib_uverbs_async_handler(uobj->uverbs_file, uobj->uobject.user_handle,
- event->event, &uobj->async_list,
- &uobj->async_events_reported);
-}
-
-void ib_uverbs_qp_event_handler(struct ib_event *event, void *context_ptr)
-{
- struct ib_uevent_object *uobj;
-
- uobj = container_of(event->element.qp->uobject,
- struct ib_uevent_object, uobject);
-
- ib_uverbs_async_handler(context_ptr, uobj->uobject.user_handle,
- event->event, &uobj->event_list,
- &uobj->events_reported);
-}
-
-void ib_uverbs_srq_event_handler(struct ib_event *event, void *context_ptr)
-{
- struct ib_uevent_object *uobj;
-
- uobj = container_of(event->element.srq->uobject,
- struct ib_uevent_object, uobject);
-
- ib_uverbs_async_handler(context_ptr, uobj->uobject.user_handle,
- event->event, &uobj->event_list,
- &uobj->events_reported);
-}
-
-void ib_uverbs_event_handler(struct ib_event_handler *handler,
- struct ib_event *event)
-{
- struct ib_uverbs_file *file =
- container_of(handler, struct ib_uverbs_file, event_handler);
-
- ib_uverbs_async_handler(file, event->element.port_num, event->event,
- NULL, NULL);
-}
-
-struct file *ib_uverbs_alloc_event_file(struct ib_uverbs_file *uverbs_file,
- int is_async)
-{
- struct ib_uverbs_event_file *ev_file;
- struct file *filp;
-
- ev_file = kzalloc(sizeof *ev_file, GFP_KERNEL);
- if (!ev_file)
- return ERR_PTR(-ENOMEM);
-
- kref_init(&ev_file->ref);
- spin_lock_init(&ev_file->lock);
- INIT_LIST_HEAD(&ev_file->event_list);
- init_waitqueue_head(&ev_file->poll_wait);
- ev_file->uverbs_file = uverbs_file;
- ev_file->is_async = is_async;
-
- /*
- * fops_get() can't fail here, because we're coming from a
- * system call on a uverbs file, which will already have a
- * module reference.
- */
- filp = alloc_file(FMODE_READ, fops_get(&uverbs_event_fops));
-
- if (IS_ERR(filp)) {
- kfree(ev_file);
- } else {
- filp->private_data = ev_file;
- }
-
- return filp;
-}
-
-/*
- * Look up a completion event file by FD. If lookup is successful,
- * takes a ref to the event file struct that it returns; if
- * unsuccessful, returns NULL.
- */
-struct ib_uverbs_event_file *ib_uverbs_lookup_comp_file(int fd)
-{
- struct ib_uverbs_event_file *ev_file = NULL;
- struct fd f = fdget(fd);
-
- if (!f.file)
- return NULL;
-
- if (f.file->f_op != &uverbs_event_fops)
- goto out;
-
- ev_file = f.file->private_data;
- if (ev_file->is_async) {
- ev_file = NULL;
- goto out;
- }
-
- kref_get(&ev_file->ref);
-
-out:
- fdput(f);
- return ev_file;
-}
-
-static const char *verbs_cmd_str(__u32 cmd)
-{
- switch (cmd) {
- case IB_USER_VERBS_CMD_GET_CONTEXT:
- return "GET_CONTEXT";
- case IB_USER_VERBS_CMD_QUERY_DEVICE:
- return "QUERY_DEVICE";
- case IB_USER_VERBS_CMD_QUERY_PORT:
- return "QUERY_PORT";
- case IB_USER_VERBS_CMD_ALLOC_PD:
- return "ALLOC_PD";
- case IB_USER_VERBS_CMD_DEALLOC_PD:
- return "DEALLOC_PD";
- case IB_USER_VERBS_CMD_REG_MR:
- return "REG_MR";
- case IB_USER_VERBS_CMD_DEREG_MR:
- return "DEREG_MR";
- case IB_USER_VERBS_CMD_CREATE_COMP_CHANNEL:
- return "CREATE_COMP_CHANNEL";
- case IB_USER_VERBS_CMD_CREATE_CQ:
- return "CREATE_CQ";
- case IB_USER_VERBS_CMD_RESIZE_CQ:
- return "RESIZE_CQ";
- case IB_USER_VERBS_CMD_POLL_CQ:
- return "POLL_CQ";
- case IB_USER_VERBS_CMD_REQ_NOTIFY_CQ:
- return "REQ_NOTIFY_CQ";
- case IB_USER_VERBS_CMD_DESTROY_CQ:
- return "DESTROY_CQ";
- case IB_USER_VERBS_CMD_CREATE_QP:
- return "CREATE_QP";
- case IB_USER_VERBS_CMD_QUERY_QP:
- return "QUERY_QP";
- case IB_USER_VERBS_CMD_MODIFY_QP:
- return "MODIFY_QP";
- case IB_USER_VERBS_CMD_DESTROY_QP:
- return "DESTROY_QP";
- case IB_USER_VERBS_CMD_POST_SEND:
- return "POST_SEND";
- case IB_USER_VERBS_CMD_POST_RECV:
- return "POST_RECV";
- case IB_USER_VERBS_CMD_POST_SRQ_RECV:
- return "POST_SRQ_RECV";
- case IB_USER_VERBS_CMD_CREATE_AH:
- return "CREATE_AH";
- case IB_USER_VERBS_CMD_DESTROY_AH:
- return "DESTROY_AH";
- case IB_USER_VERBS_CMD_ATTACH_MCAST:
- return "ATTACH_MCAST";
- case IB_USER_VERBS_CMD_DETACH_MCAST:
- return "DETACH_MCAST";
- case IB_USER_VERBS_CMD_CREATE_SRQ:
- return "CREATE_SRQ";
- case IB_USER_VERBS_CMD_MODIFY_SRQ:
- return "MODIFY_SRQ";
- case IB_USER_VERBS_CMD_QUERY_SRQ:
- return "QUERY_SRQ";
- case IB_USER_VERBS_CMD_DESTROY_SRQ:
- return "DESTROY_SRQ";
- case IB_USER_VERBS_CMD_OPEN_XRCD:
- return "OPEN_XRCD";
- case IB_USER_VERBS_CMD_CLOSE_XRCD:
- return "CLOSE_XRCD";
- case IB_USER_VERBS_CMD_CREATE_XSRQ:
- return "CREATE_XSRQ";
- case IB_USER_VERBS_CMD_OPEN_QP:
- return "OPEN_QP";
- }
-
- return "Unknown command";
-}
-
-enum {
- COMMAND_INFO_MASK = 0x1000,
-};
-
-static ssize_t ib_uverbs_exp_handle_cmd(struct ib_uverbs_file *file,
- const char __user *buf,
- struct ib_device *dev,
- struct ib_uverbs_cmd_hdr *hdr,
- size_t count,
- int legacy_ex_cmd)
-{
- struct ib_udata ucore;
- struct ib_udata uhw;
- struct ib_uverbs_ex_cmd_hdr ex_hdr;
- __u32 command = hdr->command - IB_USER_VERBS_EXP_CMD_FIRST;
-
- if (hdr->command & ~(__u32)(IB_USER_VERBS_CMD_FLAGS_MASK |
- IB_USER_VERBS_CMD_COMMAND_MASK))
- return -EINVAL;
-
- if (command >= ARRAY_SIZE(uverbs_exp_cmd_table) ||
- !uverbs_exp_cmd_table[command])
- return -EINVAL;
-
- if (!file->ucontext)
- return -EINVAL;
-
- if (!(dev->uverbs_exp_cmd_mask & (1ull << command)))
- return -ENOSYS;
-
- if (legacy_ex_cmd) {
- struct ib_uverbs_ex_cmd_hdr_legacy hxl;
- struct ib_uverbs_ex_cmd_resp1_legacy resp1;
- __u64 response;
- ssize_t ret;
-
- if (count < sizeof(hxl))
- return -EINVAL;
-
- if (copy_from_user(&hxl, buf, sizeof(hxl)))
- return -EFAULT;
-
- if (((hxl.in_words + hxl.provider_in_words) * 4) != count)
- return -EINVAL;
-
- count -= sizeof(hxl);
- buf += sizeof(hxl);
- if (hxl.out_words || hxl.provider_out_words) {
- if (count < sizeof(resp1))
- return -EINVAL;
- if (copy_from_user(&resp1, buf, sizeof(resp1)))
- return -EFAULT;
- response = resp1.response;
- if (!response)
- return -EINVAL;
-
- /*
- * Change user buffer to comply with new extension format.
- */
- if (sizeof(resp1.comp_mask) != sizeof(resp1.response))
- return -EFAULT;
- buf += sizeof(resp1.comp_mask);
- if (copy_to_user(__DECONST(void __user *, buf), &resp1.comp_mask,
- sizeof(resp1.response)))
- return -EFAULT;
-
- } else {
- response = 0;
- }
-
- INIT_UDATA_EX(&ucore,
- (hxl.in_words) ? buf : 0,
- response,
- hxl.in_words * 4,
- hxl.out_words * 4);
-
- INIT_UDATA_EX(&uhw,
- (hxl.provider_in_words) ? buf + ucore.inlen : 0,
- (hxl.provider_out_words) ? response + ucore.outlen : 0,
- hxl.provider_in_words * 4,
- hxl.provider_out_words * 4);
-
- ret = uverbs_exp_cmd_table[command](file, &ucore, &uhw);
- /*
- * UnChange user buffer
- */
- if (response && copy_to_user(__DECONST(void __user *, buf), &resp1.response, sizeof(resp1.response)))
- return -EFAULT;
-
- return ret;
- } else {
- if (count < (sizeof(hdr) + sizeof(ex_hdr)))
- return -EINVAL;
-
- if (copy_from_user(&ex_hdr, buf + sizeof(hdr), sizeof(ex_hdr)))
- return -EFAULT;
-
- buf += sizeof(hdr) + sizeof(ex_hdr);
-
- if ((hdr->in_words + ex_hdr.provider_in_words) * 8 != count)
- return -EINVAL;
-
- if (ex_hdr.response) {
- if (!hdr->out_words && !ex_hdr.provider_out_words)
- return -EINVAL;
- } else {
- if (hdr->out_words || ex_hdr.provider_out_words)
- return -EINVAL;
- }
-
- INIT_UDATA_EX(&ucore,
- (hdr->in_words) ? buf : 0,
- (unsigned long)ex_hdr.response,
- hdr->in_words * 8,
- hdr->out_words * 8);
-
- INIT_UDATA_EX(&uhw,
- (ex_hdr.provider_in_words) ? buf + ucore.inlen : 0,
- (ex_hdr.provider_out_words) ? ex_hdr.response + ucore.outlen : 0,
- ex_hdr.provider_in_words * 8,
- ex_hdr.provider_out_words * 8);
-
- return uverbs_exp_cmd_table[command](file, &ucore, &uhw);
- }
-}
-
-static ssize_t ib_uverbs_write(struct file *filp, const char __user *buf,
- size_t count, loff_t *pos)
-{
- struct ib_uverbs_file *file = filp->private_data;
- struct ib_device *dev = file->device->ib_dev;
- struct ib_uverbs_cmd_hdr hdr;
- struct timespec ts1;
- struct timespec ts2;
- ktime_t t1, t2, delta;
- s64 ds;
- ssize_t ret;
- u64 dividend;
- u32 divisor;
- __u32 flags;
- __u32 command;
- int legacy_ex_cmd = 0;
- size_t written_count = count;
-
- if (count < sizeof hdr)
- return -EINVAL;
-
- if (copy_from_user(&hdr, buf, sizeof hdr))
- return -EFAULT;
-
- /*
- * For BWD compatibility change old style extension verbs commands
- * to their equivalent experimental command.
- */
- if ((hdr.command >= IB_USER_VERBS_LEGACY_CMD_FIRST) &&
- (hdr.command <= IB_USER_VERBS_LEGACY_EX_CMD_LAST)) {
- hdr.command += IB_USER_VERBS_EXP_CMD_FIRST -
- IB_USER_VERBS_LEGACY_CMD_FIRST;
- legacy_ex_cmd = 1;
- }
-
- flags = (hdr.command &
- IB_USER_VERBS_CMD_FLAGS_MASK) >> IB_USER_VERBS_CMD_FLAGS_SHIFT;
- command = hdr.command & IB_USER_VERBS_CMD_COMMAND_MASK;
-
- ktime_get_ts(&ts1);
- if (!flags && (command >= IB_USER_VERBS_EXP_CMD_FIRST)) {
- ret = ib_uverbs_exp_handle_cmd(file, buf, dev, &hdr, count, legacy_ex_cmd);
- } else if (!flags) {
- if (command >= ARRAY_SIZE(uverbs_cmd_table) ||
- !uverbs_cmd_table[command])
- return -EINVAL;
-
- if (!file->ucontext &&
- command != IB_USER_VERBS_CMD_GET_CONTEXT)
- return -EINVAL;
-
- if (!(dev->uverbs_cmd_mask & (1ull << command)))
- return -ENOSYS;
-
- if (hdr.in_words * 4 != count)
- return -EINVAL;
-
- ret = uverbs_cmd_table[command](file,
- buf + sizeof(hdr),
- hdr.in_words * 4,
- hdr.out_words * 4);
- } else if (flags == IB_USER_VERBS_CMD_FLAG_EXTENDED) {
- struct ib_udata ucore;
- struct ib_udata uhw;
- struct ib_uverbs_ex_cmd_hdr ex_hdr;
-
- if (hdr.command & ~(__u32)(IB_USER_VERBS_CMD_FLAGS_MASK |
- IB_USER_VERBS_CMD_COMMAND_MASK))
- return -EINVAL;
-
- if (command >= ARRAY_SIZE(uverbs_ex_cmd_table) ||
- !uverbs_ex_cmd_table[command])
- return -EINVAL;
-
- if (!file->ucontext)
- return -EINVAL;
-
- if (!(dev->uverbs_ex_cmd_mask & (1ull << command)))
- return -ENOSYS;
-
- if (count < (sizeof(hdr) + sizeof(ex_hdr)))
- return -EINVAL;
-
- if (copy_from_user(&ex_hdr, buf + sizeof(hdr), sizeof(ex_hdr)))
- return -EFAULT;
-
- count -= sizeof(hdr) + sizeof(ex_hdr);
- buf += sizeof(hdr) + sizeof(ex_hdr);
-
- if ((hdr.in_words + ex_hdr.provider_in_words) * 8 != count)
- return -EINVAL;
-
- if (ex_hdr.response) {
- if (!hdr.out_words && !ex_hdr.provider_out_words)
- return -EINVAL;
- } else {
- if (hdr.out_words || ex_hdr.provider_out_words)
- return -EINVAL;
- }
-
- INIT_UDATA_EX(&ucore,
- (hdr.in_words) ? buf : 0,
- (unsigned long)ex_hdr.response,
- hdr.in_words * 8,
- hdr.out_words * 8);
-
- INIT_UDATA_EX(&uhw,
- (ex_hdr.provider_in_words) ? buf + ucore.inlen : 0,
- (ex_hdr.provider_out_words) ? ex_hdr.response + ucore.outlen : 0,
- ex_hdr.provider_in_words * 8,
- ex_hdr.provider_out_words * 8);
-
- ret = uverbs_ex_cmd_table[command](file, &ucore, &uhw);
-
- if (ret)
- return ret;
-
- return written_count;
-
- } else {
- return -EFAULT;
- }
-
- if ((dev->cmd_perf & (COMMAND_INFO_MASK - 1)) == hdr.command) {
- ktime_get_ts(&ts2);
- t1 = timespec_to_ktime(ts1);
- t2 = timespec_to_ktime(ts2);
- delta = ktime_sub(t2, t1);
- ds = ktime_to_ns(delta);
- spin_lock(&dev->cmd_perf_lock);
- dividend = dev->cmd_avg * dev->cmd_n + ds;
- ++dev->cmd_n;
- divisor = dev->cmd_n;
- do_div(dividend, divisor);
- dev->cmd_avg = dividend;
- spin_unlock(&dev->cmd_perf_lock);
- if (dev->cmd_perf & COMMAND_INFO_MASK) {
- pr_info("%s: %s execution time = %lld nsec\n",
- file->device->ib_dev->name,
- verbs_cmd_str(hdr.command),
- (long long)ds);
- }
- }
- return ret;
-}
-
-static int ib_uverbs_mmap(struct file *filp, struct vm_area_struct *vma)
-{
- struct ib_uverbs_file *file = filp->private_data;
-
- if (!file->ucontext)
- return -ENODEV;
- else
- return file->device->ib_dev->mmap(file->ucontext, vma);
-}
-/* XXX Not supported in FreeBSD */
-#if 0
-static unsigned long ib_uverbs_get_unmapped_area(struct file *filp,
- unsigned long addr,
- unsigned long len, unsigned long pgoff, unsigned long flags)
-{
- struct ib_uverbs_file *file = filp->private_data;
-
- if (!file->ucontext)
- return -ENODEV;
- else {
- if (!file->device->ib_dev->get_unmapped_area)
- return current->mm->get_unmapped_area(filp, addr, len,
- pgoff, flags);
-
- return file->device->ib_dev->get_unmapped_area(filp, addr, len,
- pgoff, flags);
- }
-}
-#endif
-
-static long ib_uverbs_ioctl(struct file *filp,
- unsigned int cmd, unsigned long arg)
-{
- struct ib_uverbs_file *file = filp->private_data;
-
- if (!file->device->ib_dev->ioctl)
- return -ENOTSUPP;
-
- if (!file->ucontext)
- return -ENODEV;
- else
- /* provider should provide it's own locking mechanism */
- return file->device->ib_dev->ioctl(file->ucontext, cmd, arg);
-}
-
-/*
- * ib_uverbs_open() does not need the BKL:
- *
- * - the ib_uverbs_device structures are properly reference counted and
- * everything else is purely local to the file being created, so
- * races against other open calls are not a problem;
- * - there is no ioctl method to race against;
- * - the open method will either immediately run -ENXIO, or all
- * required initialization will be done.
- */
-static int ib_uverbs_open(struct inode *inode, struct file *filp)
-{
- struct ib_uverbs_device *dev;
- struct ib_uverbs_file *file;
- int ret;
-
- dev = container_of(inode->i_cdev->si_drv1, struct ib_uverbs_device, cdev);
- if (dev)
- kref_get(&dev->ref);
- else
- return -ENXIO;
-
- if (!try_module_get(dev->ib_dev->owner)) {
- ret = -ENODEV;
- goto err;
- }
-
- file = kmalloc(sizeof *file, GFP_KERNEL);
- if (!file) {
- ret = -ENOMEM;
- goto err_module;
- }
-
- file->device = dev;
- file->ucontext = NULL;
- file->async_file = NULL;
- kref_init(&file->ref);
- mutex_init(&file->mutex);
-
- filp->private_data = file;
-
- return nonseekable_open(inode, filp);
-
-err_module:
- module_put(dev->ib_dev->owner);
-
-err:
- kref_put(&dev->ref, ib_uverbs_release_dev);
- return ret;
-}
-
-static int ib_uverbs_close(struct inode *inode, struct file *filp)
-{
- struct ib_uverbs_file *file = filp->private_data;
-
- ib_uverbs_cleanup_ucontext(file, file->ucontext);
-
- if (file->async_file)
- kref_put(&file->async_file->ref, ib_uverbs_release_event_file);
-
- kref_put(&file->ref, ib_uverbs_release_file);
-
- return 0;
-}
-
-static const struct file_operations uverbs_fops = {
- .owner = THIS_MODULE,
- .write = ib_uverbs_write,
- .open = ib_uverbs_open,
- .release = ib_uverbs_close,
- .llseek = no_llseek,
- .unlocked_ioctl = ib_uverbs_ioctl,
-};
-
-static const struct file_operations uverbs_mmap_fops = {
- .owner = THIS_MODULE,
- .write = ib_uverbs_write,
- .mmap = ib_uverbs_mmap,
- .open = ib_uverbs_open,
- .release = ib_uverbs_close,
- .llseek = no_llseek,
-/* XXX Not supported in FreeBSD */
-#if 0
- .get_unmapped_area = ib_uverbs_get_unmapped_area,
-#endif
- .unlocked_ioctl = ib_uverbs_ioctl,
-};
-
-static struct ib_client uverbs_client = {
- .name = "uverbs",
- .add = ib_uverbs_add_one,
- .remove = ib_uverbs_remove_one
-};
-
-static ssize_t show_ibdev(struct device *device, struct device_attribute *attr,
- char *buf)
-{
- struct ib_uverbs_device *dev = dev_get_drvdata(device);
-
- if (!dev)
- return -ENODEV;
-
- return sprintf(buf, "%s\n", dev->ib_dev->name);
-}
-static DEVICE_ATTR(ibdev, S_IRUGO, show_ibdev, NULL);
-
-static ssize_t show_dev_ref_cnt(struct device *device,
- struct device_attribute *attr, char *buf)
-{
- struct ib_uverbs_device *dev = dev_get_drvdata(device);
-
- if (!dev)
- return -ENODEV;
-
- return sprintf(buf, "%d\n", atomic_read(&dev->ref.refcount));
-}
-static DEVICE_ATTR(ref_cnt, S_IRUGO, show_dev_ref_cnt, NULL);
-
-static ssize_t show_dev_abi_version(struct device *device,
- struct device_attribute *attr, char *buf)
-{
- struct ib_uverbs_device *dev = dev_get_drvdata(device);
-
- if (!dev)
- return -ENODEV;
-
- return sprintf(buf, "%d\n", dev->ib_dev->uverbs_abi_ver);
-}
-static DEVICE_ATTR(abi_version, S_IRUGO, show_dev_abi_version, NULL);
-
-static ssize_t show_abi_version(struct class *class, struct class_attribute *attr, char *buf)
-{
- return sprintf(buf, "%d\n", IB_USER_VERBS_ABI_VERSION);
-}
-
-static CLASS_ATTR(abi_version, S_IRUGO, show_abi_version, NULL);
-
-static dev_t overflow_maj;
-static DECLARE_BITMAP(overflow_map, IB_UVERBS_MAX_DEVICES);
-
-/*
- * If we have more than IB_UVERBS_MAX_DEVICES, dynamically overflow by
- * requesting a new major number and doubling the number of max devices we
- * support. It's stupid, but simple.
- */
-static int find_overflow_devnum(void)
-{
- int ret;
-
- if (!overflow_maj) {
- ret = alloc_chrdev_region(&overflow_maj, 0, IB_UVERBS_MAX_DEVICES,
- "infiniband_verbs");
- if (ret) {
- printk(KERN_ERR "user_verbs: couldn't register dynamic device number\n");
- return ret;
- }
- }
-
- ret = find_first_zero_bit(overflow_map, IB_UVERBS_MAX_DEVICES);
- if (ret >= IB_UVERBS_MAX_DEVICES)
- return -1;
-
- return ret;
-}
-#include <linux/pci.h>
-
-static ssize_t
-show_dev_device(struct device *device, struct device_attribute *attr, char *buf)
-{
- struct ib_uverbs_device *dev = dev_get_drvdata(device);
-
- if (!dev || !dev->ib_dev->dma_device)
- return -ENODEV;
-
- return sprintf(buf, "0x%04x\n",
- ((struct pci_dev *)dev->ib_dev->dma_device)->device);
-}
-static DEVICE_ATTR(device, S_IRUGO, show_dev_device, NULL);
-
-static ssize_t
-show_dev_vendor(struct device *device, struct device_attribute *attr, char *buf)
-{
- struct ib_uverbs_device *dev = dev_get_drvdata(device);
-
- if (!dev || !dev->ib_dev->dma_device)
- return -ENODEV;
-
- return sprintf(buf, "0x%04x\n",
- ((struct pci_dev *)dev->ib_dev->dma_device)->vendor);
-}
-
-static DEVICE_ATTR(vendor, S_IRUGO, show_dev_vendor, NULL);
-
-struct attribute *device_attrs[] =
-{
- &dev_attr_device.attr,
- &dev_attr_vendor.attr,
- NULL
-};
-
-static struct attribute_group device_group = {
- .name = "device",
- .attrs = device_attrs
-};
-
-static void ib_uverbs_add_one(struct ib_device *device)
-{
- int devnum;
- dev_t base;
- struct ib_uverbs_device *uverbs_dev;
-
- if (!device->alloc_ucontext)
- return;
-
- uverbs_dev = kzalloc(sizeof *uverbs_dev, GFP_KERNEL);
- if (!uverbs_dev)
- return;
-
- kref_init(&uverbs_dev->ref);
- init_completion(&uverbs_dev->comp);
- uverbs_dev->xrcd_tree = RB_ROOT;
- mutex_init(&uverbs_dev->xrcd_tree_mutex);
-
- spin_lock(&map_lock);
- devnum = find_first_zero_bit(dev_map, IB_UVERBS_MAX_DEVICES);
- if (devnum >= IB_UVERBS_MAX_DEVICES) {
- spin_unlock(&map_lock);
- devnum = find_overflow_devnum();
- if (devnum < 0)
- goto err;
-
- spin_lock(&map_lock);
- uverbs_dev->devnum = devnum + IB_UVERBS_MAX_DEVICES;
- base = devnum + overflow_maj;
- set_bit(devnum, overflow_map);
- } else {
- uverbs_dev->devnum = devnum;
- base = devnum + IB_UVERBS_BASE_DEV;
- set_bit(devnum, dev_map);
- }
- spin_unlock(&map_lock);
-
- uverbs_dev->ib_dev = device;
- uverbs_dev->num_comp_vectors = device->num_comp_vectors;
-
- cdev_init(&uverbs_dev->cdev, NULL);
- uverbs_dev->cdev.owner = THIS_MODULE;
- uverbs_dev->cdev.ops = device->mmap ? &uverbs_mmap_fops : &uverbs_fops;
- kobject_set_name(&uverbs_dev->cdev.kobj, "uverbs%d", uverbs_dev->devnum);
- if (cdev_add(&uverbs_dev->cdev, base, 1))
- goto err_cdev;
-
- uverbs_dev->dev = device_create(uverbs_class, device->dma_device,
- uverbs_dev->cdev.dev, uverbs_dev,
- "uverbs%d", uverbs_dev->devnum);
- if (IS_ERR(uverbs_dev->dev))
- goto err_cdev;
-
- if (device_create_file(uverbs_dev->dev, &dev_attr_ibdev))
- goto err_class;
- if (device_create_file(uverbs_dev->dev, &dev_attr_ref_cnt))
- goto err_class;
- if (device_create_file(uverbs_dev->dev, &dev_attr_abi_version))
- goto err_class;
- if (sysfs_create_group(&uverbs_dev->dev->kobj, &device_group))
- goto err_class;
-
- ib_set_client_data(device, &uverbs_client, uverbs_dev);
-
- return;
-
-err_class:
- device_destroy(uverbs_class, uverbs_dev->cdev.dev);
-
-err_cdev:
- cdev_del(&uverbs_dev->cdev);
- if (uverbs_dev->devnum < IB_UVERBS_MAX_DEVICES)
- clear_bit(devnum, dev_map);
- else
- clear_bit(devnum, overflow_map);
-
-err:
- kref_put(&uverbs_dev->ref, ib_uverbs_release_dev);
- wait_for_completion(&uverbs_dev->comp);
- kfree(uverbs_dev);
- return;
-}
-
-static void ib_uverbs_remove_one(struct ib_device *device)
-{
- struct ib_uverbs_device *uverbs_dev = ib_get_client_data(device, &uverbs_client);
-
- if (!uverbs_dev)
- return;
-
- sysfs_remove_group(&uverbs_dev->dev->kobj, &device_group);
- dev_set_drvdata(uverbs_dev->dev, NULL);
- device_destroy(uverbs_class, uverbs_dev->cdev.dev);
- cdev_del(&uverbs_dev->cdev);
-
- if (uverbs_dev->devnum < IB_UVERBS_MAX_DEVICES)
- clear_bit(uverbs_dev->devnum, dev_map);
- else
- clear_bit(uverbs_dev->devnum - IB_UVERBS_MAX_DEVICES, overflow_map);
-
- kref_put(&uverbs_dev->ref, ib_uverbs_release_dev);
- wait_for_completion(&uverbs_dev->comp);
- kfree(uverbs_dev);
-}
-
-static char *uverbs_devnode(struct device *dev, umode_t *mode)
-{
- if (mode)
- *mode = 0666;
- return kasprintf(GFP_KERNEL, "infiniband/%s", dev_name(dev));
-}
-
-static int __init ib_uverbs_init(void)
-{
- int ret;
-
- ret = register_chrdev_region(IB_UVERBS_BASE_DEV, IB_UVERBS_MAX_DEVICES,
- "infiniband_verbs");
- if (ret) {
- printk(KERN_ERR "user_verbs: couldn't register device number\n");
- goto out;
- }
-
- uverbs_class = class_create(THIS_MODULE, "infiniband_verbs");
- if (IS_ERR(uverbs_class)) {
- ret = PTR_ERR(uverbs_class);
- printk(KERN_ERR "user_verbs: couldn't create class infiniband_verbs\n");
- goto out_chrdev;
- }
-
- uverbs_class->devnode = uverbs_devnode;
-
- ret = class_create_file(uverbs_class, &class_attr_abi_version);
- if (ret) {
- printk(KERN_ERR "user_verbs: couldn't create abi_version attribute\n");
- goto out_class;
- }
-
- ret = ib_register_client(&uverbs_client);
- if (ret) {
- printk(KERN_ERR "user_verbs: couldn't register client\n");
- goto out_class;
- }
-
- return 0;
-
-out_class:
- class_destroy(uverbs_class);
-
-out_chrdev:
- unregister_chrdev_region(IB_UVERBS_BASE_DEV, IB_UVERBS_MAX_DEVICES);
-
-out:
- return ret;
-}
-
-static void __exit ib_uverbs_cleanup(void)
-{
- ib_unregister_client(&uverbs_client);
- class_destroy(uverbs_class);
- unregister_chrdev_region(IB_UVERBS_BASE_DEV, IB_UVERBS_MAX_DEVICES);
- if (overflow_maj)
- unregister_chrdev_region(overflow_maj, IB_UVERBS_MAX_DEVICES);
- idr_destroy(&ib_uverbs_pd_idr);
- idr_destroy(&ib_uverbs_mr_idr);
- idr_destroy(&ib_uverbs_mw_idr);
- idr_destroy(&ib_uverbs_ah_idr);
- idr_destroy(&ib_uverbs_cq_idr);
- idr_destroy(&ib_uverbs_qp_idr);
- idr_destroy(&ib_uverbs_srq_idr);
-}
-
-module_init(ib_uverbs_init);
-module_exit(ib_uverbs_cleanup);
diff --git a/sys/ofed/drivers/infiniband/core/uverbs_marshall.c b/sys/ofed/drivers/infiniband/core/uverbs_marshall.c
deleted file mode 100644
index a541882..0000000
--- a/sys/ofed/drivers/infiniband/core/uverbs_marshall.c
+++ /dev/null
@@ -1,144 +0,0 @@
-/*
- * Copyright (c) 2005 Intel Corporation. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-#include <linux/module.h>
-#include <rdma/ib_marshall.h>
-
-void ib_copy_ah_attr_to_user(struct ib_uverbs_ah_attr *dst,
- struct ib_ah_attr *src)
-{
- memcpy(dst->grh.dgid, src->grh.dgid.raw, sizeof src->grh.dgid);
- dst->grh.flow_label = src->grh.flow_label;
- dst->grh.sgid_index = src->grh.sgid_index;
- dst->grh.hop_limit = src->grh.hop_limit;
- dst->grh.traffic_class = src->grh.traffic_class;
- memset(&dst->grh.reserved, 0, sizeof(dst->grh.reserved));
- dst->dlid = src->dlid;
- dst->sl = src->sl;
- dst->src_path_bits = src->src_path_bits;
- dst->static_rate = src->static_rate;
- dst->is_global = src->ah_flags & IB_AH_GRH ? 1 : 0;
- dst->port_num = src->port_num;
- dst->reserved = 0;
-}
-EXPORT_SYMBOL(ib_copy_ah_attr_to_user);
-
-void ib_copy_qp_attr_to_user(struct ib_uverbs_qp_attr *dst,
- struct ib_qp_attr *src)
-{
- dst->qp_state = src->qp_state;
- dst->cur_qp_state = src->cur_qp_state;
- dst->path_mtu = src->path_mtu;
- dst->path_mig_state = src->path_mig_state;
- dst->qkey = src->qkey;
- dst->rq_psn = src->rq_psn;
- dst->sq_psn = src->sq_psn;
- dst->dest_qp_num = src->dest_qp_num;
- dst->qp_access_flags = src->qp_access_flags;
-
- dst->max_send_wr = src->cap.max_send_wr;
- dst->max_recv_wr = src->cap.max_recv_wr;
- dst->max_send_sge = src->cap.max_send_sge;
- dst->max_recv_sge = src->cap.max_recv_sge;
- dst->max_inline_data = src->cap.max_inline_data;
-
- ib_copy_ah_attr_to_user(&dst->ah_attr, &src->ah_attr);
- ib_copy_ah_attr_to_user(&dst->alt_ah_attr, &src->alt_ah_attr);
-
- dst->pkey_index = src->pkey_index;
- dst->alt_pkey_index = src->alt_pkey_index;
- dst->en_sqd_async_notify = src->en_sqd_async_notify;
- dst->sq_draining = src->sq_draining;
- dst->max_rd_atomic = src->max_rd_atomic;
- dst->max_dest_rd_atomic = src->max_dest_rd_atomic;
- dst->min_rnr_timer = src->min_rnr_timer;
- dst->port_num = src->port_num;
- dst->timeout = src->timeout;
- dst->retry_cnt = src->retry_cnt;
- dst->rnr_retry = src->rnr_retry;
- dst->alt_port_num = src->alt_port_num;
- dst->alt_timeout = src->alt_timeout;
- memset(dst->reserved, 0, sizeof(dst->reserved));
-}
-EXPORT_SYMBOL(ib_copy_qp_attr_to_user);
-
-void ib_copy_path_rec_to_user(struct ib_user_path_rec *dst,
- struct ib_sa_path_rec *src)
-{
- memcpy(dst->dgid, src->dgid.raw, sizeof src->dgid);
- memcpy(dst->sgid, src->sgid.raw, sizeof src->sgid);
-
- dst->dlid = src->dlid;
- dst->slid = src->slid;
- dst->raw_traffic = src->raw_traffic;
- dst->flow_label = src->flow_label;
- dst->hop_limit = src->hop_limit;
- dst->traffic_class = src->traffic_class;
- dst->reversible = src->reversible;
- dst->numb_path = src->numb_path;
- dst->pkey = src->pkey;
- dst->sl = src->sl;
- dst->mtu_selector = src->mtu_selector;
- dst->mtu = src->mtu;
- dst->rate_selector = src->rate_selector;
- dst->rate = src->rate;
- dst->packet_life_time = src->packet_life_time;
- dst->preference = src->preference;
- dst->packet_life_time_selector = src->packet_life_time_selector;
-}
-EXPORT_SYMBOL(ib_copy_path_rec_to_user);
-
-void ib_copy_path_rec_from_user(struct ib_sa_path_rec *dst,
- struct ib_user_path_rec *src)
-{
- memcpy(dst->dgid.raw, src->dgid, sizeof dst->dgid);
- memcpy(dst->sgid.raw, src->sgid, sizeof dst->sgid);
-
- dst->dlid = src->dlid;
- dst->slid = src->slid;
- dst->raw_traffic = src->raw_traffic;
- dst->flow_label = src->flow_label;
- dst->hop_limit = src->hop_limit;
- dst->traffic_class = src->traffic_class;
- dst->reversible = src->reversible;
- dst->numb_path = src->numb_path;
- dst->pkey = src->pkey;
- dst->sl = src->sl;
- dst->mtu_selector = src->mtu_selector;
- dst->mtu = src->mtu;
- dst->rate_selector = src->rate_selector;
- dst->rate = src->rate;
- dst->packet_life_time = src->packet_life_time;
- dst->preference = src->preference;
- dst->packet_life_time_selector = src->packet_life_time_selector;
-}
-EXPORT_SYMBOL(ib_copy_path_rec_from_user);
diff --git a/sys/ofed/drivers/infiniband/core/verbs.c b/sys/ofed/drivers/infiniband/core/verbs.c
deleted file mode 100644
index 6c51941..0000000
--- a/sys/ofed/drivers/infiniband/core/verbs.c
+++ /dev/null
@@ -1,1547 +0,0 @@
-/*
- * Copyright (c) 2004 Mellanox Technologies Ltd. All rights reserved.
- * Copyright (c) 2004 Infinicon Corporation. All rights reserved.
- * Copyright (c) 2004 Intel Corporation. All rights reserved.
- * Copyright (c) 2004 Topspin Corporation. All rights reserved.
- * Copyright (c) 2004 Voltaire Corporation. All rights reserved.
- * Copyright (c) 2005 Sun Microsystems, Inc. All rights reserved.
- * Copyright (c) 2005, 2006 Cisco Systems. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-#include <linux/errno.h>
-#include <linux/err.h>
-#include <linux/module.h>
-#include <linux/string.h>
-#include <linux/slab.h>
-#include <linux/netdevice.h>
-
-#include <rdma/ib_verbs.h>
-#include <rdma/ib_cache.h>
-#include <rdma/ib_addr.h>
-
-int ib_rate_to_mult(enum ib_rate rate)
-{
- switch (rate) {
- case IB_RATE_2_5_GBPS: return 1;
- case IB_RATE_5_GBPS: return 2;
- case IB_RATE_10_GBPS: return 4;
- case IB_RATE_20_GBPS: return 8;
- case IB_RATE_30_GBPS: return 12;
- case IB_RATE_40_GBPS: return 16;
- case IB_RATE_60_GBPS: return 24;
- case IB_RATE_80_GBPS: return 32;
- case IB_RATE_120_GBPS: return 48;
- default: return -1;
- }
-}
-EXPORT_SYMBOL(ib_rate_to_mult);
-
-enum ib_rate mult_to_ib_rate(int mult)
-{
- switch (mult) {
- case 1: return IB_RATE_2_5_GBPS;
- case 2: return IB_RATE_5_GBPS;
- case 4: return IB_RATE_10_GBPS;
- case 8: return IB_RATE_20_GBPS;
- case 12: return IB_RATE_30_GBPS;
- case 16: return IB_RATE_40_GBPS;
- case 24: return IB_RATE_60_GBPS;
- case 32: return IB_RATE_80_GBPS;
- case 48: return IB_RATE_120_GBPS;
- default: return IB_RATE_PORT_CURRENT;
- }
-}
-EXPORT_SYMBOL(mult_to_ib_rate);
-
-int ib_rate_to_mbps(enum ib_rate rate)
-{
- switch (rate) {
- case IB_RATE_2_5_GBPS: return 2500;
- case IB_RATE_5_GBPS: return 5000;
- case IB_RATE_10_GBPS: return 10000;
- case IB_RATE_20_GBPS: return 20000;
- case IB_RATE_30_GBPS: return 30000;
- case IB_RATE_40_GBPS: return 40000;
- case IB_RATE_60_GBPS: return 60000;
- case IB_RATE_80_GBPS: return 80000;
- case IB_RATE_120_GBPS: return 120000;
- case IB_RATE_14_GBPS: return 14062;
- case IB_RATE_56_GBPS: return 56250;
- case IB_RATE_112_GBPS: return 112500;
- case IB_RATE_168_GBPS: return 168750;
- case IB_RATE_25_GBPS: return 25781;
- case IB_RATE_100_GBPS: return 103125;
- case IB_RATE_200_GBPS: return 206250;
- case IB_RATE_300_GBPS: return 309375;
- default: return -1;
- }
-}
-EXPORT_SYMBOL(ib_rate_to_mbps);
-
-enum rdma_transport_type
-rdma_node_get_transport(enum rdma_node_type node_type)
-{
- switch (node_type) {
- case RDMA_NODE_IB_CA:
- case RDMA_NODE_IB_SWITCH:
- case RDMA_NODE_IB_ROUTER:
- return RDMA_TRANSPORT_IB;
- case RDMA_NODE_RNIC:
- return RDMA_TRANSPORT_IWARP;
- case RDMA_NODE_MIC:
- return RDMA_TRANSPORT_SCIF;
- default:
- BUG();
- return 0;
- }
-}
-EXPORT_SYMBOL(rdma_node_get_transport);
-
-enum rdma_link_layer rdma_port_get_link_layer(struct ib_device *device, u8 port_num)
-{
- if (device->get_link_layer)
- return device->get_link_layer(device, port_num);
-
- switch (rdma_node_get_transport(device->node_type)) {
- case RDMA_TRANSPORT_IB:
- return IB_LINK_LAYER_INFINIBAND;
- case RDMA_TRANSPORT_IWARP:
- return IB_LINK_LAYER_ETHERNET;
- case RDMA_TRANSPORT_SCIF:
- return IB_LINK_LAYER_SCIF;
- default:
- return IB_LINK_LAYER_UNSPECIFIED;
- }
-}
-EXPORT_SYMBOL(rdma_port_get_link_layer);
-
-/* Protection domains */
-
-struct ib_pd *ib_alloc_pd(struct ib_device *device)
-{
- struct ib_pd *pd;
-
- pd = device->alloc_pd(device, NULL, NULL);
-
- if (!IS_ERR(pd)) {
- pd->device = device;
- pd->uobject = NULL;
- atomic_set(&pd->usecnt, 0);
- }
-
- return pd;
-}
-EXPORT_SYMBOL(ib_alloc_pd);
-
-int ib_dealloc_pd(struct ib_pd *pd)
-{
- if (atomic_read(&pd->usecnt))
- return -EBUSY;
-
- return pd->device->dealloc_pd(pd);
-}
-EXPORT_SYMBOL(ib_dealloc_pd);
-
-/* Address handles */
-
-struct ib_ah *ib_create_ah(struct ib_pd *pd, struct ib_ah_attr *ah_attr)
-{
- struct ib_ah *ah;
-
- ah = pd->device->create_ah(pd, ah_attr);
-
- if (!IS_ERR(ah)) {
- ah->device = pd->device;
- ah->pd = pd;
- ah->uobject = NULL;
- atomic_inc(&pd->usecnt);
- }
-
- return ah;
-}
-EXPORT_SYMBOL(ib_create_ah);
-
-int ib_init_ah_from_wc(struct ib_device *device, u8 port_num, struct ib_wc *wc,
- struct ib_grh *grh, struct ib_ah_attr *ah_attr)
-{
- u32 flow_class;
- u16 gid_index;
- int ret;
- int is_eth = (rdma_port_get_link_layer(device, port_num) ==
- IB_LINK_LAYER_ETHERNET);
-
- memset(ah_attr, 0, sizeof *ah_attr);
- if (is_eth) {
- if (!(wc->wc_flags & IB_WC_GRH))
- return -EPROTOTYPE;
-
- if (wc->wc_flags & IB_WC_WITH_SMAC &&
- wc->wc_flags & IB_WC_WITH_VLAN) {
- memcpy(ah_attr->dmac, wc->smac, ETH_ALEN);
- ah_attr->vlan_id = wc->vlan_id;
- } else {
- struct net_device *idev;
- int if_index;
-
- if (device->get_netdev != NULL &&
- (idev = device->get_netdev(device, port_num)) != NULL)
- if_index = idev->if_index;
- else
- if_index = 0;
-
- ret = rdma_addr_find_dmac_by_grh(&grh->dgid, &grh->sgid,
- ah_attr->dmac, &ah_attr->vlan_id,
- &if_index);
- if (ret)
- return ret;
- }
- } else {
- ah_attr->vlan_id = 0xffff;
- }
-
-
- ah_attr->dlid = wc->slid;
- ah_attr->sl = wc->sl;
- ah_attr->src_path_bits = wc->dlid_path_bits;
- ah_attr->port_num = port_num;
-
- if (wc->wc_flags & IB_WC_GRH) {
- ah_attr->ah_flags = IB_AH_GRH;
- ah_attr->grh.dgid = grh->sgid;
-
- ret = ib_find_cached_gid(device, &grh->dgid, &port_num,
- &gid_index);
- if (ret)
- return ret;
-
- ah_attr->grh.sgid_index = (u8) gid_index;
- flow_class = be32_to_cpu(grh->version_tclass_flow);
- ah_attr->grh.flow_label = flow_class & 0xFFFFF;
- ah_attr->grh.hop_limit = 0xFF;
- ah_attr->grh.traffic_class = (flow_class >> 20) & 0xFF;
- }
- return 0;
-}
-EXPORT_SYMBOL(ib_init_ah_from_wc);
-
-struct ib_ah *ib_create_ah_from_wc(struct ib_pd *pd, struct ib_wc *wc,
- struct ib_grh *grh, u8 port_num)
-{
- struct ib_ah_attr ah_attr;
- int ret;
-
- ret = ib_init_ah_from_wc(pd->device, port_num, wc, grh, &ah_attr);
- if (ret)
- return ERR_PTR(ret);
-
- return ib_create_ah(pd, &ah_attr);
-}
-EXPORT_SYMBOL(ib_create_ah_from_wc);
-
-int ib_modify_ah(struct ib_ah *ah, struct ib_ah_attr *ah_attr)
-{
- return ah->device->modify_ah ?
- ah->device->modify_ah(ah, ah_attr) :
- -ENOSYS;
-}
-EXPORT_SYMBOL(ib_modify_ah);
-
-int ib_query_ah(struct ib_ah *ah, struct ib_ah_attr *ah_attr)
-{
- return ah->device->query_ah ?
- ah->device->query_ah(ah, ah_attr) :
- -ENOSYS;
-}
-EXPORT_SYMBOL(ib_query_ah);
-
-int ib_destroy_ah(struct ib_ah *ah)
-{
- struct ib_pd *pd;
- int ret;
-
- pd = ah->pd;
- ret = ah->device->destroy_ah(ah);
- if (!ret)
- atomic_dec(&pd->usecnt);
-
- return ret;
-}
-EXPORT_SYMBOL(ib_destroy_ah);
-
-/* Shared receive queues */
-
-struct ib_srq *ib_create_srq(struct ib_pd *pd,
- struct ib_srq_init_attr *srq_init_attr)
-{
- struct ib_srq *srq;
-
- if (!pd->device->create_srq)
- return ERR_PTR(-ENOSYS);
-
- srq = pd->device->create_srq(pd, srq_init_attr, NULL);
-
- if (!IS_ERR(srq)) {
- srq->device = pd->device;
- srq->pd = pd;
- srq->uobject = NULL;
- srq->event_handler = srq_init_attr->event_handler;
- srq->srq_context = srq_init_attr->srq_context;
- srq->srq_type = srq_init_attr->srq_type;
- if (srq->srq_type == IB_SRQT_XRC) {
- srq->ext.xrc.xrcd = srq_init_attr->ext.xrc.xrcd;
- srq->ext.xrc.cq = srq_init_attr->ext.xrc.cq;
- atomic_inc(&srq->ext.xrc.xrcd->usecnt);
- atomic_inc(&srq->ext.xrc.cq->usecnt);
- }
- atomic_inc(&pd->usecnt);
- atomic_set(&srq->usecnt, 0);
- }
-
- return srq;
-}
-EXPORT_SYMBOL(ib_create_srq);
-
-int ib_modify_srq(struct ib_srq *srq,
- struct ib_srq_attr *srq_attr,
- enum ib_srq_attr_mask srq_attr_mask)
-{
- return srq->device->modify_srq ?
- srq->device->modify_srq(srq, srq_attr, srq_attr_mask, NULL) :
- -ENOSYS;
-}
-EXPORT_SYMBOL(ib_modify_srq);
-
-int ib_query_srq(struct ib_srq *srq,
- struct ib_srq_attr *srq_attr)
-{
- return srq->device->query_srq ?
- srq->device->query_srq(srq, srq_attr) : -ENOSYS;
-}
-EXPORT_SYMBOL(ib_query_srq);
-
-int ib_query_values(struct ib_device *device,
- int q_values, struct ib_device_values *values)
-{
- return device->query_values ?
- device->query_values(device, q_values, values) : -ENOSYS;
-}
-EXPORT_SYMBOL(ib_query_values);
-
-int ib_destroy_srq(struct ib_srq *srq)
-{
- struct ib_pd *pd;
- enum ib_srq_type srq_type;
- struct ib_xrcd *uninitialized_var(xrcd);
- struct ib_cq *uninitialized_var(cq);
- int ret;
-
- if (atomic_read(&srq->usecnt))
- return -EBUSY;
-
- pd = srq->pd;
- srq_type = srq->srq_type;
- if (srq_type == IB_SRQT_XRC) {
- xrcd = srq->ext.xrc.xrcd;
- cq = srq->ext.xrc.cq;
- }
-
- ret = srq->device->destroy_srq(srq);
- if (!ret) {
- atomic_dec(&pd->usecnt);
- if (srq_type == IB_SRQT_XRC) {
- atomic_dec(&xrcd->usecnt);
- atomic_dec(&cq->usecnt);
- }
- }
-
- return ret;
-}
-EXPORT_SYMBOL(ib_destroy_srq);
-
-/* Queue pairs */
-
-static void __ib_shared_qp_event_handler(struct ib_event *event, void *context)
-{
- struct ib_qp *qp = context;
- unsigned long flags;
-
- /* The code below must be synced with deletions of existing qps (ib_close_qp) --
- * because a qp from the list may be closed during the scan, resulting in a kernel Oops.
- */
- spin_lock_irqsave(&qp->device->event_handler_lock, flags);
- list_for_each_entry(event->element.qp, &qp->open_list, open_list)
- if (event->element.qp->event_handler)
- event->element.qp->event_handler(event, event->element.qp->qp_context);
- spin_unlock_irqrestore(&qp->device->event_handler_lock, flags);
-}
-
-static void __ib_insert_xrcd_qp(struct ib_xrcd *xrcd, struct ib_qp *qp)
-{
- mutex_lock(&xrcd->tgt_qp_mutex);
- list_add(&qp->xrcd_list, &xrcd->tgt_qp_list);
- mutex_unlock(&xrcd->tgt_qp_mutex);
-}
-
-static struct ib_qp *__ib_open_qp(struct ib_qp *real_qp,
- void (*event_handler)(struct ib_event *, void *),
- void *qp_context)
-{
- struct ib_qp *qp;
- unsigned long flags;
-
- qp = kzalloc(sizeof *qp, GFP_KERNEL);
- if (!qp)
- return ERR_PTR(-ENOMEM);
-
- qp->real_qp = real_qp;
- atomic_inc(&real_qp->usecnt);
- qp->device = real_qp->device;
- qp->event_handler = event_handler;
- qp->qp_context = qp_context;
- qp->qp_num = real_qp->qp_num;
- qp->qp_type = real_qp->qp_type;
-
- spin_lock_irqsave(&real_qp->device->event_handler_lock, flags);
- list_add(&qp->open_list, &real_qp->open_list);
- spin_unlock_irqrestore(&real_qp->device->event_handler_lock, flags);
-
- return qp;
-}
-
-struct ib_qp *ib_open_qp(struct ib_xrcd *xrcd,
- struct ib_qp_open_attr *qp_open_attr)
-{
- struct ib_qp *qp, *real_qp;
-
- if (qp_open_attr->qp_type != IB_QPT_XRC_TGT)
- return ERR_PTR(-EINVAL);
-
- qp = ERR_PTR(-EINVAL);
- mutex_lock(&xrcd->tgt_qp_mutex);
- list_for_each_entry(real_qp, &xrcd->tgt_qp_list, xrcd_list) {
- if (real_qp->qp_num == qp_open_attr->qp_num) {
- qp = __ib_open_qp(real_qp, qp_open_attr->event_handler,
- qp_open_attr->qp_context);
- break;
- }
- }
- mutex_unlock(&xrcd->tgt_qp_mutex);
- return qp;
-}
-EXPORT_SYMBOL(ib_open_qp);
-
-struct ib_qp *ib_create_qp(struct ib_pd *pd,
- struct ib_qp_init_attr *qp_init_attr)
-{
- struct ib_qp *qp, *real_qp;
- struct ib_device *device;
-
- device = pd ? pd->device : qp_init_attr->xrcd->device;
- qp = device->create_qp(pd, qp_init_attr, NULL);
-
- if (!IS_ERR(qp)) {
- qp->device = device;
- qp->real_qp = qp;
- qp->uobject = NULL;
- qp->qp_type = qp_init_attr->qp_type;
-
- atomic_set(&qp->usecnt, 0);
- if (qp_init_attr->qp_type == IB_QPT_XRC_TGT) {
- qp->event_handler = __ib_shared_qp_event_handler;
- qp->qp_context = qp;
- qp->pd = NULL;
- qp->send_cq = qp->recv_cq = NULL;
- qp->srq = NULL;
- qp->xrcd = qp_init_attr->xrcd;
- atomic_inc(&qp_init_attr->xrcd->usecnt);
- INIT_LIST_HEAD(&qp->open_list);
-
- real_qp = qp;
- qp = __ib_open_qp(real_qp, qp_init_attr->event_handler,
- qp_init_attr->qp_context);
- if (!IS_ERR(qp))
- __ib_insert_xrcd_qp(qp_init_attr->xrcd, real_qp);
- else
- real_qp->device->destroy_qp(real_qp);
- } else {
- qp->event_handler = qp_init_attr->event_handler;
- qp->qp_context = qp_init_attr->qp_context;
- if (qp_init_attr->qp_type == IB_QPT_XRC_INI) {
- qp->recv_cq = NULL;
- qp->srq = NULL;
- } else {
- qp->recv_cq = qp_init_attr->recv_cq;
- atomic_inc(&qp_init_attr->recv_cq->usecnt);
- qp->srq = qp_init_attr->srq;
- if (qp->srq)
- atomic_inc(&qp_init_attr->srq->usecnt);
- }
-
- qp->pd = pd;
- qp->send_cq = qp_init_attr->send_cq;
- qp->xrcd = NULL;
-
- atomic_inc(&pd->usecnt);
- atomic_inc(&qp_init_attr->send_cq->usecnt);
- }
- }
-
- return qp;
-}
-EXPORT_SYMBOL(ib_create_qp);
-
-static const struct {
- int valid;
- enum ib_qp_attr_mask req_param[IB_QPT_MAX];
- enum ib_qp_attr_mask req_param_add_eth[IB_QPT_MAX];
- enum ib_qp_attr_mask opt_param[IB_QPT_MAX];
- enum ib_qp_attr_mask opt_param_add_eth[IB_QPT_MAX];
-} qp_state_table[IB_QPS_ERR + 1][IB_QPS_ERR + 1] = {
- [IB_QPS_RESET] = {
- [IB_QPS_RESET] = { .valid = 1 },
- [IB_QPS_INIT] = {
- .valid = 1,
- .req_param = {
- [IB_QPT_UD] = (IB_QP_PKEY_INDEX |
- IB_QP_PORT |
- IB_QP_QKEY),
- [IB_QPT_RAW_PACKET] = IB_QP_PORT,
- [IB_QPT_UC] = (IB_QP_PKEY_INDEX |
- IB_QP_PORT |
- IB_QP_ACCESS_FLAGS),
- [IB_QPT_RC] = (IB_QP_PKEY_INDEX |
- IB_QP_PORT |
- IB_QP_ACCESS_FLAGS),
- [IB_QPT_DC_INI] = (IB_QP_PKEY_INDEX |
- IB_QP_PORT |
- IB_QP_ACCESS_FLAGS |
- IB_QP_DC_KEY),
- [IB_QPT_XRC_INI] = (IB_QP_PKEY_INDEX |
- IB_QP_PORT |
- IB_QP_ACCESS_FLAGS),
- [IB_QPT_XRC_TGT] = (IB_QP_PKEY_INDEX |
- IB_QP_PORT |
- IB_QP_ACCESS_FLAGS),
- [IB_QPT_SMI] = (IB_QP_PKEY_INDEX |
- IB_QP_QKEY),
- [IB_QPT_GSI] = (IB_QP_PKEY_INDEX |
- IB_QP_QKEY),
- },
- .opt_param = {
- [IB_QPT_UD] = IB_QP_GROUP_RSS,
- [IB_QPT_RAW_PACKET] = IB_QP_GROUP_RSS
- }
- },
- },
- [IB_QPS_INIT] = {
- [IB_QPS_RESET] = { .valid = 1 },
- [IB_QPS_ERR] = { .valid = 1 },
- [IB_QPS_INIT] = {
- .valid = 1,
- .opt_param = {
- [IB_QPT_UD] = (IB_QP_PKEY_INDEX |
- IB_QP_PORT |
- IB_QP_QKEY),
- [IB_QPT_UC] = (IB_QP_PKEY_INDEX |
- IB_QP_PORT |
- IB_QP_ACCESS_FLAGS),
- [IB_QPT_RC] = (IB_QP_PKEY_INDEX |
- IB_QP_PORT |
- IB_QP_ACCESS_FLAGS),
- [IB_QPT_DC_INI] = (IB_QP_PKEY_INDEX |
- IB_QP_PORT |
- IB_QP_ACCESS_FLAGS),
- [IB_QPT_XRC_INI] = (IB_QP_PKEY_INDEX |
- IB_QP_PORT |
- IB_QP_ACCESS_FLAGS),
- [IB_QPT_XRC_TGT] = (IB_QP_PKEY_INDEX |
- IB_QP_PORT |
- IB_QP_ACCESS_FLAGS),
- [IB_QPT_SMI] = (IB_QP_PKEY_INDEX |
- IB_QP_QKEY),
- [IB_QPT_GSI] = (IB_QP_PKEY_INDEX |
- IB_QP_QKEY),
- }
- },
- [IB_QPS_RTR] = {
- .valid = 1,
- .req_param = {
- [IB_QPT_UC] = (IB_QP_AV |
- IB_QP_PATH_MTU |
- IB_QP_DEST_QPN |
- IB_QP_RQ_PSN),
- [IB_QPT_RC] = (IB_QP_AV |
- IB_QP_PATH_MTU |
- IB_QP_DEST_QPN |
- IB_QP_RQ_PSN |
- IB_QP_MAX_DEST_RD_ATOMIC |
- IB_QP_MIN_RNR_TIMER),
- [IB_QPT_DC_INI] = (IB_QP_PATH_MTU |
- IB_QP_MAX_DEST_RD_ATOMIC |
- IB_QP_MIN_RNR_TIMER),
- [IB_QPT_XRC_INI] = (IB_QP_AV |
- IB_QP_PATH_MTU |
- IB_QP_DEST_QPN |
- IB_QP_RQ_PSN),
- [IB_QPT_XRC_TGT] = (IB_QP_AV |
- IB_QP_PATH_MTU |
- IB_QP_DEST_QPN |
- IB_QP_RQ_PSN |
- IB_QP_MAX_DEST_RD_ATOMIC |
- IB_QP_MIN_RNR_TIMER),
- },
- .req_param_add_eth = {
- [IB_QPT_RC] = (IB_QP_SMAC),
- [IB_QPT_UC] = (IB_QP_SMAC),
- [IB_QPT_XRC_INI] = (IB_QP_SMAC),
- [IB_QPT_XRC_TGT] = (IB_QP_SMAC)
- },
- .opt_param = {
- [IB_QPT_UD] = (IB_QP_PKEY_INDEX |
- IB_QP_QKEY),
- [IB_QPT_UC] = (IB_QP_ALT_PATH |
- IB_QP_ACCESS_FLAGS |
- IB_QP_PKEY_INDEX),
- [IB_QPT_RC] = (IB_QP_ALT_PATH |
- IB_QP_ACCESS_FLAGS |
- IB_QP_PKEY_INDEX),
- [IB_QPT_DC_INI] = (IB_QP_ALT_PATH |
- IB_QP_ACCESS_FLAGS |
- IB_QP_PKEY_INDEX),
- [IB_QPT_XRC_INI] = (IB_QP_ALT_PATH |
- IB_QP_ACCESS_FLAGS |
- IB_QP_PKEY_INDEX),
- [IB_QPT_XRC_TGT] = (IB_QP_ALT_PATH |
- IB_QP_ACCESS_FLAGS |
- IB_QP_PKEY_INDEX),
- [IB_QPT_SMI] = (IB_QP_PKEY_INDEX |
- IB_QP_QKEY),
- [IB_QPT_GSI] = (IB_QP_PKEY_INDEX |
- IB_QP_QKEY),
- [IB_QPT_RAW_PACKET] = IB_QP_AV,
- },
- .opt_param_add_eth = {
- [IB_QPT_RC] = (IB_QP_ALT_SMAC |
- IB_QP_VID |
- IB_QP_ALT_VID),
- [IB_QPT_UC] = (IB_QP_ALT_SMAC |
- IB_QP_VID |
- IB_QP_ALT_VID),
- [IB_QPT_XRC_INI] = (IB_QP_ALT_SMAC |
- IB_QP_VID |
- IB_QP_ALT_VID),
- [IB_QPT_XRC_TGT] = (IB_QP_ALT_SMAC |
- IB_QP_VID |
- IB_QP_ALT_VID)
- }
- }
- },
- [IB_QPS_RTR] = {
- [IB_QPS_RESET] = { .valid = 1 },
- [IB_QPS_ERR] = { .valid = 1 },
- [IB_QPS_RTS] = {
- .valid = 1,
- .req_param = {
- [IB_QPT_UD] = IB_QP_SQ_PSN,
- [IB_QPT_UC] = IB_QP_SQ_PSN,
- [IB_QPT_RC] = (IB_QP_TIMEOUT |
- IB_QP_RETRY_CNT |
- IB_QP_RNR_RETRY |
- IB_QP_SQ_PSN |
- IB_QP_MAX_QP_RD_ATOMIC),
- [IB_QPT_DC_INI] = (IB_QP_TIMEOUT |
- IB_QP_RETRY_CNT |
- IB_QP_RNR_RETRY |
- IB_QP_MAX_QP_RD_ATOMIC),
- [IB_QPT_XRC_INI] = (IB_QP_TIMEOUT |
- IB_QP_RETRY_CNT |
- IB_QP_RNR_RETRY |
- IB_QP_SQ_PSN |
- IB_QP_MAX_QP_RD_ATOMIC),
- [IB_QPT_XRC_TGT] = (IB_QP_TIMEOUT |
- IB_QP_SQ_PSN),
- [IB_QPT_SMI] = IB_QP_SQ_PSN,
- [IB_QPT_GSI] = IB_QP_SQ_PSN,
- },
- .opt_param = {
- [IB_QPT_UD] = (IB_QP_CUR_STATE |
- IB_QP_QKEY),
- [IB_QPT_UC] = (IB_QP_CUR_STATE |
- IB_QP_ALT_PATH |
- IB_QP_ACCESS_FLAGS |
- IB_QP_PATH_MIG_STATE),
- [IB_QPT_RC] = (IB_QP_CUR_STATE |
- IB_QP_ALT_PATH |
- IB_QP_ACCESS_FLAGS |
- IB_QP_MIN_RNR_TIMER |
- IB_QP_PATH_MIG_STATE),
- [IB_QPT_DC_INI] = (IB_QP_CUR_STATE |
- IB_QP_ALT_PATH |
- IB_QP_ACCESS_FLAGS |
- IB_QP_MIN_RNR_TIMER |
- IB_QP_PATH_MIG_STATE),
- [IB_QPT_XRC_INI] = (IB_QP_CUR_STATE |
- IB_QP_ALT_PATH |
- IB_QP_ACCESS_FLAGS |
- IB_QP_PATH_MIG_STATE),
- [IB_QPT_XRC_TGT] = (IB_QP_CUR_STATE |
- IB_QP_ALT_PATH |
- IB_QP_ACCESS_FLAGS |
- IB_QP_MIN_RNR_TIMER |
- IB_QP_PATH_MIG_STATE),
- [IB_QPT_SMI] = (IB_QP_CUR_STATE |
- IB_QP_QKEY),
- [IB_QPT_GSI] = (IB_QP_CUR_STATE |
- IB_QP_QKEY),
- }
- }
- },
- [IB_QPS_RTS] = {
- [IB_QPS_RESET] = { .valid = 1 },
- [IB_QPS_ERR] = { .valid = 1 },
- [IB_QPS_RTS] = {
- .valid = 1,
- .opt_param = {
- [IB_QPT_UD] = (IB_QP_CUR_STATE |
- IB_QP_QKEY),
- [IB_QPT_UC] = (IB_QP_CUR_STATE |
- IB_QP_ACCESS_FLAGS |
- IB_QP_ALT_PATH |
- IB_QP_PATH_MIG_STATE),
- [IB_QPT_RC] = (IB_QP_CUR_STATE |
- IB_QP_ACCESS_FLAGS |
- IB_QP_ALT_PATH |
- IB_QP_PATH_MIG_STATE |
- IB_QP_MIN_RNR_TIMER),
- [IB_QPT_DC_INI] = (IB_QP_CUR_STATE |
- IB_QP_ACCESS_FLAGS |
- IB_QP_ALT_PATH |
- IB_QP_PATH_MIG_STATE |
- IB_QP_MIN_RNR_TIMER),
- [IB_QPT_XRC_INI] = (IB_QP_CUR_STATE |
- IB_QP_ACCESS_FLAGS |
- IB_QP_ALT_PATH |
- IB_QP_PATH_MIG_STATE),
- [IB_QPT_XRC_TGT] = (IB_QP_CUR_STATE |
- IB_QP_ACCESS_FLAGS |
- IB_QP_ALT_PATH |
- IB_QP_PATH_MIG_STATE |
- IB_QP_MIN_RNR_TIMER),
- [IB_QPT_SMI] = (IB_QP_CUR_STATE |
- IB_QP_QKEY),
- [IB_QPT_GSI] = (IB_QP_CUR_STATE |
- IB_QP_QKEY),
- }
- },
- [IB_QPS_SQD] = {
- .valid = 1,
- .opt_param = {
- [IB_QPT_UD] = IB_QP_EN_SQD_ASYNC_NOTIFY,
- [IB_QPT_UC] = IB_QP_EN_SQD_ASYNC_NOTIFY,
- [IB_QPT_RC] = IB_QP_EN_SQD_ASYNC_NOTIFY,
- [IB_QPT_XRC_INI] = IB_QP_EN_SQD_ASYNC_NOTIFY,
- [IB_QPT_XRC_TGT] = IB_QP_EN_SQD_ASYNC_NOTIFY, /* ??? */
- [IB_QPT_SMI] = IB_QP_EN_SQD_ASYNC_NOTIFY,
- [IB_QPT_GSI] = IB_QP_EN_SQD_ASYNC_NOTIFY
- }
- },
- },
- [IB_QPS_SQD] = {
- [IB_QPS_RESET] = { .valid = 1 },
- [IB_QPS_ERR] = { .valid = 1 },
- [IB_QPS_RTS] = {
- .valid = 1,
- .opt_param = {
- [IB_QPT_UD] = (IB_QP_CUR_STATE |
- IB_QP_QKEY),
- [IB_QPT_UC] = (IB_QP_CUR_STATE |
- IB_QP_ALT_PATH |
- IB_QP_ACCESS_FLAGS |
- IB_QP_PATH_MIG_STATE),
- [IB_QPT_RC] = (IB_QP_CUR_STATE |
- IB_QP_ALT_PATH |
- IB_QP_ACCESS_FLAGS |
- IB_QP_MIN_RNR_TIMER |
- IB_QP_PATH_MIG_STATE),
- [IB_QPT_XRC_INI] = (IB_QP_CUR_STATE |
- IB_QP_ALT_PATH |
- IB_QP_ACCESS_FLAGS |
- IB_QP_PATH_MIG_STATE),
- [IB_QPT_XRC_TGT] = (IB_QP_CUR_STATE |
- IB_QP_ALT_PATH |
- IB_QP_ACCESS_FLAGS |
- IB_QP_MIN_RNR_TIMER |
- IB_QP_PATH_MIG_STATE),
- [IB_QPT_SMI] = (IB_QP_CUR_STATE |
- IB_QP_QKEY),
- [IB_QPT_GSI] = (IB_QP_CUR_STATE |
- IB_QP_QKEY),
- }
- },
- [IB_QPS_SQD] = {
- .valid = 1,
- .opt_param = {
- [IB_QPT_UD] = (IB_QP_PKEY_INDEX |
- IB_QP_QKEY),
- [IB_QPT_UC] = (IB_QP_AV |
- IB_QP_ALT_PATH |
- IB_QP_ACCESS_FLAGS |
- IB_QP_PKEY_INDEX |
- IB_QP_PATH_MIG_STATE),
- [IB_QPT_RC] = (IB_QP_PORT |
- IB_QP_AV |
- IB_QP_TIMEOUT |
- IB_QP_RETRY_CNT |
- IB_QP_RNR_RETRY |
- IB_QP_MAX_QP_RD_ATOMIC |
- IB_QP_MAX_DEST_RD_ATOMIC |
- IB_QP_ALT_PATH |
- IB_QP_ACCESS_FLAGS |
- IB_QP_PKEY_INDEX |
- IB_QP_MIN_RNR_TIMER |
- IB_QP_PATH_MIG_STATE),
- [IB_QPT_XRC_INI] = (IB_QP_PORT |
- IB_QP_AV |
- IB_QP_TIMEOUT |
- IB_QP_RETRY_CNT |
- IB_QP_RNR_RETRY |
- IB_QP_MAX_QP_RD_ATOMIC |
- IB_QP_ALT_PATH |
- IB_QP_ACCESS_FLAGS |
- IB_QP_PKEY_INDEX |
- IB_QP_PATH_MIG_STATE),
- [IB_QPT_XRC_TGT] = (IB_QP_PORT |
- IB_QP_AV |
- IB_QP_TIMEOUT |
- IB_QP_MAX_DEST_RD_ATOMIC |
- IB_QP_ALT_PATH |
- IB_QP_ACCESS_FLAGS |
- IB_QP_PKEY_INDEX |
- IB_QP_MIN_RNR_TIMER |
- IB_QP_PATH_MIG_STATE),
- [IB_QPT_SMI] = (IB_QP_PKEY_INDEX |
- IB_QP_QKEY),
- [IB_QPT_GSI] = (IB_QP_PKEY_INDEX |
- IB_QP_QKEY),
- }
- }
- },
- [IB_QPS_SQE] = {
- [IB_QPS_RESET] = { .valid = 1 },
- [IB_QPS_ERR] = { .valid = 1 },
- [IB_QPS_RTS] = {
- .valid = 1,
- .opt_param = {
- [IB_QPT_UD] = (IB_QP_CUR_STATE |
- IB_QP_QKEY),
- [IB_QPT_UC] = (IB_QP_CUR_STATE |
- IB_QP_ACCESS_FLAGS),
- [IB_QPT_SMI] = (IB_QP_CUR_STATE |
- IB_QP_QKEY),
- [IB_QPT_GSI] = (IB_QP_CUR_STATE |
- IB_QP_QKEY),
- }
- }
- },
- [IB_QPS_ERR] = {
- [IB_QPS_RESET] = { .valid = 1 },
- [IB_QPS_ERR] = { .valid = 1 }
- }
-};
-
-int ib_modify_qp_is_ok(enum ib_qp_state cur_state, enum ib_qp_state next_state,
- enum ib_qp_type type, enum ib_qp_attr_mask mask,
- enum rdma_link_layer ll)
-{
- enum ib_qp_attr_mask req_param, opt_param;
-
- if (cur_state < 0 || cur_state > IB_QPS_ERR ||
- next_state < 0 || next_state > IB_QPS_ERR)
- return 0;
-
- if (mask & IB_QP_CUR_STATE &&
- cur_state != IB_QPS_RTR && cur_state != IB_QPS_RTS &&
- cur_state != IB_QPS_SQD && cur_state != IB_QPS_SQE)
- return 0;
-
- if (!qp_state_table[cur_state][next_state].valid)
- return 0;
-
- req_param = qp_state_table[cur_state][next_state].req_param[type];
- opt_param = qp_state_table[cur_state][next_state].opt_param[type];
-
- if (ll == IB_LINK_LAYER_ETHERNET) {
- req_param |= qp_state_table[cur_state][next_state].
- req_param_add_eth[type];
- opt_param |= qp_state_table[cur_state][next_state].
- opt_param_add_eth[type];
- }
-
- if ((mask & req_param) != req_param)
- return 0;
-
- if (mask & ~(req_param | opt_param | IB_QP_STATE))
- return 0;
-
- return 1;
-}
-EXPORT_SYMBOL(ib_modify_qp_is_ok);
-
-int ib_modify_qp(struct ib_qp *qp,
- struct ib_qp_attr *qp_attr,
- int qp_attr_mask)
-{
- int ret;
-
- ret = qp->device->modify_qp(qp->real_qp, qp_attr, qp_attr_mask, NULL);
- if (!ret && (qp_attr_mask & IB_QP_PORT))
- qp->port_num = qp_attr->port_num;
-
- return ret;
-}
-EXPORT_SYMBOL(ib_modify_qp);
-
-int ib_query_qp(struct ib_qp *qp,
- struct ib_qp_attr *qp_attr,
- int qp_attr_mask,
- struct ib_qp_init_attr *qp_init_attr)
-{
- return qp->device->query_qp ?
- qp->device->query_qp(qp->real_qp, qp_attr, qp_attr_mask, qp_init_attr) :
- -ENOSYS;
-}
-EXPORT_SYMBOL(ib_query_qp);
-
-int ib_close_qp(struct ib_qp *qp)
-{
- struct ib_qp *real_qp;
- unsigned long flags;
-
- real_qp = qp->real_qp;
- if (real_qp == qp)
- return -EINVAL;
-
- spin_lock_irqsave(&real_qp->device->event_handler_lock, flags);
- list_del(&qp->open_list);
- spin_unlock_irqrestore(&real_qp->device->event_handler_lock, flags);
-
- atomic_dec(&real_qp->usecnt);
- kfree(qp);
-
- return 0;
-}
-EXPORT_SYMBOL(ib_close_qp);
-
-static int __ib_destroy_shared_qp(struct ib_qp *qp)
-{
- struct ib_xrcd *xrcd;
- struct ib_qp *real_qp;
- int ret;
-
- real_qp = qp->real_qp;
- xrcd = real_qp->xrcd;
-
- mutex_lock(&xrcd->tgt_qp_mutex);
- ib_close_qp(qp);
- if (atomic_read(&real_qp->usecnt) == 0)
- list_del(&real_qp->xrcd_list);
- else
- real_qp = NULL;
- mutex_unlock(&xrcd->tgt_qp_mutex);
-
- if (real_qp) {
- ret = ib_destroy_qp(real_qp);
- if (!ret)
- atomic_dec(&xrcd->usecnt);
- else
- __ib_insert_xrcd_qp(xrcd, real_qp);
- }
-
- return 0;
-}
-
-int ib_destroy_qp(struct ib_qp *qp)
-{
- struct ib_pd *pd;
- struct ib_cq *scq, *rcq;
- struct ib_srq *srq;
- int ret;
-
- if (atomic_read(&qp->usecnt))
- return -EBUSY;
-
- if (qp->real_qp != qp)
- return __ib_destroy_shared_qp(qp);
-
- pd = qp->pd;
- scq = qp->send_cq;
- rcq = qp->recv_cq;
- srq = qp->srq;
-
- ret = qp->device->destroy_qp(qp);
- if (!ret) {
- if (pd)
- atomic_dec(&pd->usecnt);
- if (scq)
- atomic_dec(&scq->usecnt);
- if (rcq)
- atomic_dec(&rcq->usecnt);
- if (srq)
- atomic_dec(&srq->usecnt);
- }
-
- return ret;
-}
-EXPORT_SYMBOL(ib_destroy_qp);
-
-/* Completion queues */
-
-struct ib_cq *ib_create_cq(struct ib_device *device,
- ib_comp_handler comp_handler,
- void (*event_handler)(struct ib_event *, void *),
- void *cq_context, int cqe, int comp_vector)
-{
- struct ib_cq *cq;
- struct ib_cq_init_attr attr = {
- .cqe = cqe,
- .comp_vector = comp_vector,
- .flags = 0,
- };
-
- cq = device->create_cq(device, &attr, NULL, NULL);
-
- if (!IS_ERR(cq)) {
- cq->device = device;
- cq->uobject = NULL;
- cq->comp_handler = comp_handler;
- cq->event_handler = event_handler;
- cq->cq_context = cq_context;
- atomic_set(&cq->usecnt, 0);
- }
-
- return cq;
-}
-EXPORT_SYMBOL(ib_create_cq);
-
-int ib_modify_cq(struct ib_cq *cq,
- struct ib_cq_attr *cq_attr,
- int cq_attr_mask)
-{
- return cq->device->modify_cq ?
- cq->device->modify_cq(cq, cq_attr, cq_attr_mask) : -ENOSYS;
-}
-EXPORT_SYMBOL(ib_modify_cq);
-
-int ib_destroy_cq(struct ib_cq *cq)
-{
- if (atomic_read(&cq->usecnt))
- return -EBUSY;
-
- return cq->device->destroy_cq(cq);
-}
-EXPORT_SYMBOL(ib_destroy_cq);
-
-int ib_resize_cq(struct ib_cq *cq, int cqe)
-{
- return cq->device->resize_cq ?
- cq->device->resize_cq(cq, cqe, NULL) : -ENOSYS;
-}
-EXPORT_SYMBOL(ib_resize_cq);
-
-/* Memory regions */
-
-struct ib_mr *ib_get_dma_mr(struct ib_pd *pd, int mr_access_flags)
-{
- struct ib_mr *mr;
- int err;
-
- err = ib_check_mr_access(mr_access_flags);
- if (err)
- return ERR_PTR(err);
-
- mr = pd->device->get_dma_mr(pd, mr_access_flags);
-
- if (!IS_ERR(mr)) {
- mr->device = pd->device;
- mr->pd = pd;
- mr->uobject = NULL;
- atomic_inc(&pd->usecnt);
- atomic_set(&mr->usecnt, 0);
- }
-
- return mr;
-}
-EXPORT_SYMBOL(ib_get_dma_mr);
-
-struct ib_mr *ib_reg_phys_mr(struct ib_pd *pd,
- struct ib_phys_buf *phys_buf_array,
- int num_phys_buf,
- int mr_access_flags,
- u64 *iova_start)
-{
- struct ib_mr *mr;
- int err;
-
- err = ib_check_mr_access(mr_access_flags);
- if (err)
- return ERR_PTR(err);
-
- if (!pd->device->reg_phys_mr)
- return ERR_PTR(-ENOSYS);
-
- mr = pd->device->reg_phys_mr(pd, phys_buf_array, num_phys_buf,
- mr_access_flags, iova_start);
-
- if (!IS_ERR(mr)) {
- mr->device = pd->device;
- mr->pd = pd;
- mr->uobject = NULL;
- atomic_inc(&pd->usecnt);
- atomic_set(&mr->usecnt, 0);
- }
-
- return mr;
-}
-EXPORT_SYMBOL(ib_reg_phys_mr);
-
-int ib_rereg_phys_mr(struct ib_mr *mr,
- int mr_rereg_mask,
- struct ib_pd *pd,
- struct ib_phys_buf *phys_buf_array,
- int num_phys_buf,
- int mr_access_flags,
- u64 *iova_start)
-{
- struct ib_pd *old_pd;
- int ret;
-
- ret = ib_check_mr_access(mr_access_flags);
- if (ret)
- return ret;
-
- if (!mr->device->rereg_phys_mr)
- return -ENOSYS;
-
- if (atomic_read(&mr->usecnt))
- return -EBUSY;
-
- old_pd = mr->pd;
-
- ret = mr->device->rereg_phys_mr(mr, mr_rereg_mask, pd,
- phys_buf_array, num_phys_buf,
- mr_access_flags, iova_start);
-
- if (!ret && (mr_rereg_mask & IB_MR_REREG_PD)) {
- atomic_dec(&old_pd->usecnt);
- atomic_inc(&pd->usecnt);
- }
-
- return ret;
-}
-EXPORT_SYMBOL(ib_rereg_phys_mr);
-
-int ib_query_mr(struct ib_mr *mr, struct ib_mr_attr *mr_attr)
-{
- return mr->device->query_mr ?
- mr->device->query_mr(mr, mr_attr) : -ENOSYS;
-}
-EXPORT_SYMBOL(ib_query_mr);
-
-int ib_dereg_mr(struct ib_mr *mr)
-{
- struct ib_pd *pd;
- int ret;
-
- if (atomic_read(&mr->usecnt))
- return -EBUSY;
-
- pd = mr->pd;
- ret = mr->device->dereg_mr(mr);
- if (!ret)
- atomic_dec(&pd->usecnt);
-
- return ret;
-}
-EXPORT_SYMBOL(ib_dereg_mr);
-
-struct ib_mr *ib_create_mr(struct ib_pd *pd,
- struct ib_mr_init_attr *mr_init_attr)
-{
- struct ib_mr *mr;
-
- if (!pd->device->create_mr)
- return ERR_PTR(-ENOSYS);
-
- mr = pd->device->create_mr(pd, mr_init_attr);
-
- if (!IS_ERR(mr)) {
- mr->device = pd->device;
- mr->pd = pd;
- mr->uobject = NULL;
- atomic_inc(&pd->usecnt);
- atomic_set(&mr->usecnt, 0);
- }
-
- return mr;
-}
-EXPORT_SYMBOL(ib_create_mr);
-
-int ib_destroy_mr(struct ib_mr *mr)
-{
- struct ib_pd *pd;
- int ret;
-
- if (atomic_read(&mr->usecnt))
- return -EBUSY;
-
- pd = mr->pd;
- ret = mr->device->destroy_mr(mr);
- if (!ret)
- atomic_dec(&pd->usecnt);
-
- return ret;
-}
-EXPORT_SYMBOL(ib_destroy_mr);
-
-struct ib_mr *ib_alloc_fast_reg_mr(struct ib_pd *pd, int max_page_list_len)
-{
- struct ib_mr *mr;
-
- if (!pd->device->alloc_fast_reg_mr)
- return ERR_PTR(-ENOSYS);
-
- mr = pd->device->alloc_fast_reg_mr(pd, max_page_list_len);
-
- if (!IS_ERR(mr)) {
- mr->device = pd->device;
- mr->pd = pd;
- mr->uobject = NULL;
- atomic_inc(&pd->usecnt);
- atomic_set(&mr->usecnt, 0);
- }
-
- return mr;
-}
-EXPORT_SYMBOL(ib_alloc_fast_reg_mr);
-
-struct ib_fast_reg_page_list *ib_alloc_fast_reg_page_list(struct ib_device *device,
- int max_page_list_len)
-{
- struct ib_fast_reg_page_list *page_list;
-
- if (!device->alloc_fast_reg_page_list)
- return ERR_PTR(-ENOSYS);
-
- page_list = device->alloc_fast_reg_page_list(device, max_page_list_len);
-
- if (!IS_ERR(page_list)) {
- page_list->device = device;
- page_list->max_page_list_len = max_page_list_len;
- }
-
- return page_list;
-}
-EXPORT_SYMBOL(ib_alloc_fast_reg_page_list);
-
-void ib_free_fast_reg_page_list(struct ib_fast_reg_page_list *page_list)
-{
- page_list->device->free_fast_reg_page_list(page_list);
-}
-EXPORT_SYMBOL(ib_free_fast_reg_page_list);
-
-/* Memory windows */
-
-struct ib_mw *ib_alloc_mw(struct ib_pd *pd, enum ib_mw_type type)
-{
- struct ib_mw *mw;
-
- if (!pd->device->alloc_mw)
- return ERR_PTR(-ENOSYS);
-
- mw = pd->device->alloc_mw(pd, type);
- if (!IS_ERR(mw)) {
- mw->device = pd->device;
- mw->pd = pd;
- mw->uobject = NULL;
- mw->type = type;
- atomic_inc(&pd->usecnt);
- }
-
- return mw;
-}
-EXPORT_SYMBOL(ib_alloc_mw);
-
-int ib_dealloc_mw(struct ib_mw *mw)
-{
- struct ib_pd *pd;
- int ret;
-
- pd = mw->pd;
- ret = mw->device->dealloc_mw(mw);
- if (!ret)
- atomic_dec(&pd->usecnt);
-
- return ret;
-}
-EXPORT_SYMBOL(ib_dealloc_mw);
-
-/* "Fast" memory regions */
-
-struct ib_fmr *ib_alloc_fmr(struct ib_pd *pd,
- int mr_access_flags,
- struct ib_fmr_attr *fmr_attr)
-{
- struct ib_fmr *fmr;
-
- if (!pd->device->alloc_fmr)
- return ERR_PTR(-ENOSYS);
-
- fmr = pd->device->alloc_fmr(pd, mr_access_flags, fmr_attr);
- if (!IS_ERR(fmr)) {
- fmr->device = pd->device;
- fmr->pd = pd;
- atomic_inc(&pd->usecnt);
- }
-
- return fmr;
-}
-EXPORT_SYMBOL(ib_alloc_fmr);
-
-int ib_unmap_fmr(struct list_head *fmr_list)
-{
- struct ib_fmr *fmr;
-
- if (list_empty(fmr_list))
- return 0;
-
- fmr = list_entry(fmr_list->next, struct ib_fmr, list);
- return fmr->device->unmap_fmr(fmr_list);
-}
-EXPORT_SYMBOL(ib_unmap_fmr);
-
-int ib_dealloc_fmr(struct ib_fmr *fmr)
-{
- struct ib_pd *pd;
- int ret;
-
- pd = fmr->pd;
- ret = fmr->device->dealloc_fmr(fmr);
- if (!ret)
- atomic_dec(&pd->usecnt);
-
- return ret;
-}
-EXPORT_SYMBOL(ib_dealloc_fmr);
-
-/* Multicast groups */
-
-int ib_attach_mcast(struct ib_qp *qp, union ib_gid *gid, u16 lid)
-{
- int ret;
-
- if (!qp->device->attach_mcast)
- return -ENOSYS;
-
- switch (rdma_node_get_transport(qp->device->node_type)) {
- case RDMA_TRANSPORT_IB:
- if ((gid->raw[0] != 0xff || qp->qp_type != IB_QPT_UD) &&
- qp->qp_type != IB_QPT_RAW_PACKET)
- return -EINVAL;
- break;
- case RDMA_TRANSPORT_IWARP:
- case RDMA_TRANSPORT_SCIF:
- if (qp->qp_type != IB_QPT_RAW_PACKET)
- return -EINVAL;
- break;
- }
-
- ret = qp->device->attach_mcast(qp, gid, lid);
- if (!ret)
- atomic_inc(&qp->usecnt);
- return ret;
-}
-EXPORT_SYMBOL(ib_attach_mcast);
-
-int ib_detach_mcast(struct ib_qp *qp, union ib_gid *gid, u16 lid)
-{
- int ret;
-
- if (!qp->device->detach_mcast)
- return -ENOSYS;
-
- switch (rdma_node_get_transport(qp->device->node_type)) {
- case RDMA_TRANSPORT_IB:
- if ((gid->raw[0] != 0xff || qp->qp_type != IB_QPT_UD) &&
- qp->qp_type != IB_QPT_RAW_PACKET)
- return -EINVAL;
- break;
- case RDMA_TRANSPORT_IWARP:
- case RDMA_TRANSPORT_SCIF:
-
- if (qp->qp_type != IB_QPT_RAW_PACKET)
- return -EINVAL;
- break;
- }
-
- ret = qp->device->detach_mcast(qp, gid, lid);
- if (!ret)
- atomic_dec(&qp->usecnt);
- return ret;
-}
-EXPORT_SYMBOL(ib_detach_mcast);
-
-struct ib_xrcd *ib_alloc_xrcd(struct ib_device *device)
-{
- struct ib_xrcd *xrcd;
-
- if (!device->alloc_xrcd)
- return ERR_PTR(-ENOSYS);
-
- xrcd = device->alloc_xrcd(device, NULL, NULL);
- if (!IS_ERR(xrcd)) {
- xrcd->device = device;
- xrcd->inode = NULL;
- atomic_set(&xrcd->usecnt, 0);
- mutex_init(&xrcd->tgt_qp_mutex);
- INIT_LIST_HEAD(&xrcd->tgt_qp_list);
- }
-
- return xrcd;
-}
-EXPORT_SYMBOL(ib_alloc_xrcd);
-
-int ib_dealloc_xrcd(struct ib_xrcd *xrcd)
-{
- struct ib_qp *qp;
- int ret;
-
- if (atomic_read(&xrcd->usecnt))
- return -EBUSY;
-
- while (!list_empty(&xrcd->tgt_qp_list)) {
- qp = list_entry(xrcd->tgt_qp_list.next, struct ib_qp, xrcd_list);
- ret = ib_destroy_qp(qp);
- if (ret)
- return ret;
- }
-
- return xrcd->device->dealloc_xrcd(xrcd);
-}
-EXPORT_SYMBOL(ib_dealloc_xrcd);
-
-struct ib_flow *ib_create_flow(struct ib_qp *qp,
- struct ib_flow_attr *flow_attr,
- int domain)
-{
- struct ib_flow *flow_id;
- if (!qp->device->create_flow)
- return ERR_PTR(-ENOSYS);
-
- flow_id = qp->device->create_flow(qp, flow_attr, domain);
- if (!IS_ERR(flow_id))
- atomic_inc(&qp->usecnt);
- return flow_id;
-}
-EXPORT_SYMBOL(ib_create_flow);
-
-int ib_destroy_flow(struct ib_flow *flow_id)
-{
- int err;
- struct ib_qp *qp;
-
- if (!flow_id)
- return -EINVAL;
- qp = flow_id->qp;
- if (!qp->device->destroy_flow)
- return -ENOSYS;
- err = qp->device->destroy_flow(flow_id);
- if (!err)
- atomic_dec(&qp->usecnt);
- return err;
-}
-EXPORT_SYMBOL(ib_destroy_flow);
-
-struct ib_dct *ib_create_dct(struct ib_pd *pd, struct ib_dct_init_attr *attr,
- struct ib_udata *udata)
-{
- struct ib_dct *dct;
-
- if (!pd->device->exp_create_dct)
- return ERR_PTR(-ENOSYS);
-
- dct = pd->device->exp_create_dct(pd, attr, udata);
- if (!IS_ERR(dct)) {
- dct->pd = pd;
- dct->srq = attr->srq;
- dct->cq = attr->cq;
- atomic_inc(&dct->srq->usecnt);
- atomic_inc(&dct->cq->usecnt);
- atomic_inc(&dct->pd->usecnt);
- }
-
- return dct;
-}
-EXPORT_SYMBOL(ib_create_dct);
-
-int ib_destroy_dct(struct ib_dct *dct)
-{
- int err;
-
- if (!dct->device->exp_destroy_dct)
- return -ENOSYS;
-
- err = dct->device->exp_destroy_dct(dct);
- if (!err) {
- atomic_dec(&dct->srq->usecnt);
- atomic_dec(&dct->cq->usecnt);
- atomic_dec(&dct->pd->usecnt);
- }
-
- return err;
-}
-EXPORT_SYMBOL(ib_destroy_dct);
-
-int ib_query_dct(struct ib_dct *dct, struct ib_dct_attr *attr)
-{
- if (!dct->device->exp_query_dct)
- return -ENOSYS;
-
- return dct->device->exp_query_dct(dct, attr);
-}
-EXPORT_SYMBOL(ib_query_dct);
-
-int ib_check_mr_status(struct ib_mr *mr, u32 check_mask,
- struct ib_mr_status *mr_status)
-{
- return mr->device->check_mr_status ?
- mr->device->check_mr_status(mr, check_mask, mr_status) : -ENOSYS;
-}
-EXPORT_SYMBOL(ib_check_mr_status);
diff --git a/sys/ofed/drivers/infiniband/debug/Makefile b/sys/ofed/drivers/infiniband/debug/Makefile
deleted file mode 100644
index e9d9f4b..0000000
--- a/sys/ofed/drivers/infiniband/debug/Makefile
+++ /dev/null
@@ -1,3 +0,0 @@
-EXTRA_CFLAGS := $(subst $(KERNEL_MEMTRACK_CFLAGS),,$(EXTRA_CFLAGS))
-
-obj-m += memtrack.o
diff --git a/sys/ofed/drivers/infiniband/debug/memtrack.c b/sys/ofed/drivers/infiniband/debug/memtrack.c
deleted file mode 100644
index cfbc487..0000000
--- a/sys/ofed/drivers/infiniband/debug/memtrack.c
+++ /dev/null
@@ -1,960 +0,0 @@
-/*
- This software is available to you under a choice of one of two
- licenses. You may choose to be licensed under the terms of the GNU
- General Public License (GPL) Version 2, available at
- <http://www.fsf.org/copyleft/gpl.html>, or the OpenIB.org BSD
- license, available in the LICENSE.TXT file accompanying this
- software. These details are also available at
- <http://openib.org/license.html>.
-
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- SOFTWARE.
-
- Copyright (c) 2004 Mellanox Technologies Ltd. All rights reserved.
-*/
-
-#define LINUXKPI_PARAM_PREFIX memtrack_
-
-#define C_MEMTRACK_C
-
-#ifdef kmalloc
- #undef kmalloc
-#endif
-#ifdef kmemdup
- #undef kmemdup
-#endif
-#ifdef kfree
- #undef kfree
-#endif
-#ifdef vmalloc
- #undef vmalloc
-#endif
-#ifdef vzalloc
- #undef vzalloc
-#endif
-#ifdef vzalloc_node
- #undef vzalloc_node
-#endif
-#ifdef vfree
- #undef vfree
-#endif
-#ifdef kmem_cache_alloc
- #undef kmem_cache_alloc
-#endif
-#ifdef kmem_cache_free
- #undef kmem_cache_free
-#endif
-#ifdef ioremap
- #undef ioremap
-#endif
-#ifdef io_mapping_create_wc
- #undef io_mapping_create_wc
-#endif
-#ifdef io_mapping_free
- #undef io_mapping_free
-#endif
-#ifdef ioremap_nocache
- #undef ioremap_nocache
-#endif
-#ifdef iounmap
- #undef iounmap
-#endif
-#ifdef alloc_pages
- #undef alloc_pages
-#endif
-#ifdef free_pages
- #undef free_pages
-#endif
-#ifdef get_page
- #undef get_page
-#endif
-#ifdef put_page
- #undef put_page
-#endif
-#ifdef create_workqueue
- #undef create_workqueue
-#endif
-#ifdef create_rt_workqueue
- #undef create_rt_workqueue
-#endif
-#ifdef create_freezeable_workqueue
- #undef create_freezeable_workqueue
-#endif
-#ifdef create_singlethread_workqueue
- #undef create_singlethread_workqueue
-#endif
-#ifdef destroy_workqueue
- #undef destroy_workqueue
-#endif
-
-#include <linux/module.h>
-#include <linux/kernel.h>
-#include <linux/slab.h>
-#include <linux/interrupt.h>
-#include <linux/vmalloc.h>
-#include <linux/mm.h>
-#include <asm/uaccess.h>
-#include <linux/proc_fs.h>
-#include <linux/random.h>
-#include "memtrack.h"
-
-#include <linux/moduleparam.h>
-
-
-MODULE_AUTHOR("Mellanox Technologies LTD.");
-MODULE_DESCRIPTION("Memory allocations tracking");
-MODULE_LICENSE("GPL");
-
-#define MEMTRACK_HASH_SZ ((1<<15)-19) /* prime: http://www.utm.edu/research/primes/lists/2small/0bit.html */
-#define MAX_FILENAME_LEN 31
-
-#define memtrack_spin_lock(spl, flags) spin_lock_irqsave(spl, flags)
-#define memtrack_spin_unlock(spl, flags) spin_unlock_irqrestore(spl, flags)
-
-/* if a bit is set then the corresponding allocation is tracked.
- bit0 corresponds to MEMTRACK_KMALLOC, bit1 corresponds to MEMTRACK_VMALLOC etc. */
-static unsigned long track_mask = -1; /* effectively everything */
-module_param(track_mask, ulong, 0444);
-MODULE_PARM_DESC(track_mask, "bitmask defining what is tracked");
-
-/* if a bit is set then the corresponding allocation is strictly tracked.
- That is, before inserting the whole range is checked to not overlap any
- of the allocations already in the database */
-static unsigned long strict_track_mask = 0; /* no strict tracking */
-module_param(strict_track_mask, ulong, 0444);
-MODULE_PARM_DESC(strict_track_mask, "bitmask which allocation requires strict tracking");
-
-/* Sets the frequency of allocations failures injections
- if set to 0 all allocation should succeed */
-static unsigned int inject_freq = 0;
-module_param(inject_freq, uint, 0644);
-MODULE_PARM_DESC(inject_freq, "Error injection frequency, default is 0 (disabled)");
-
-static int random_mem = 1;
-module_param(random_mem, uint, 0644);
-MODULE_PARM_DESC(random_mem, "When set, randomize allocated memory, default is 1 (enabled)");
-
-struct memtrack_meminfo_t {
- unsigned long addr;
- unsigned long size;
- unsigned long line_num;
- unsigned long dev;
- unsigned long addr2;
- int direction;
- struct memtrack_meminfo_t *next;
- struct list_head list; /* used to link all items from a certain type together */
- char filename[MAX_FILENAME_LEN + 1]; /* putting the char array last is better for struct. packing */
- char ext_info[32];
-};
-
-static struct kmem_cache *meminfo_cache;
-
-struct tracked_obj_desc_t {
- struct memtrack_meminfo_t *mem_hash[MEMTRACK_HASH_SZ];
- spinlock_t hash_lock;
- unsigned long count; /* size of memory tracked (*malloc) or number of objects tracked */
- struct list_head tracked_objs_head; /* head of list of all objects */
- int strict_track; /* if 1 then for each object inserted check if it overlaps any of the objects already in the list */
-};
-
-static struct tracked_obj_desc_t *tracked_objs_arr[MEMTRACK_NUM_OF_MEMTYPES];
-
-static const char *rsc_names[MEMTRACK_NUM_OF_MEMTYPES] = {
- "kmalloc",
- "vmalloc",
- "kmem_cache_alloc",
- "io_remap",
- "create_workqueue",
- "alloc_pages",
- "ib_dma_map_single",
- "ib_dma_map_page",
- "ib_dma_map_sg"
-};
-
-static const char *rsc_free_names[MEMTRACK_NUM_OF_MEMTYPES] = {
- "kfree",
- "vfree",
- "kmem_cache_free",
- "io_unmap",
- "destory_workqueue",
- "free_pages",
- "ib_dma_unmap_single",
- "ib_dma_unmap_page",
- "ib_dma_unmap_sg"
-};
-
-static inline const char *memtype_alloc_str(enum memtrack_memtype_t memtype)
-{
- switch (memtype) {
- case MEMTRACK_KMALLOC:
- case MEMTRACK_VMALLOC:
- case MEMTRACK_KMEM_OBJ:
- case MEMTRACK_IOREMAP:
- case MEMTRACK_WORK_QUEUE:
- case MEMTRACK_PAGE_ALLOC:
- case MEMTRACK_DMA_MAP_SINGLE:
- case MEMTRACK_DMA_MAP_PAGE:
- case MEMTRACK_DMA_MAP_SG:
- return rsc_names[memtype];
- default:
- return "(Unknown allocation type)";
- }
-}
-
-static inline const char *memtype_free_str(enum memtrack_memtype_t memtype)
-{
- switch (memtype) {
- case MEMTRACK_KMALLOC:
- case MEMTRACK_VMALLOC:
- case MEMTRACK_KMEM_OBJ:
- case MEMTRACK_IOREMAP:
- case MEMTRACK_WORK_QUEUE:
- case MEMTRACK_PAGE_ALLOC:
- case MEMTRACK_DMA_MAP_SINGLE:
- case MEMTRACK_DMA_MAP_PAGE:
- case MEMTRACK_DMA_MAP_SG:
- return rsc_free_names[memtype];
- default:
- return "(Unknown allocation type)";
- }
-}
-
-/*
- * overlap_a_b
- */
-static inline int overlap_a_b(unsigned long a_start, unsigned long a_end,
- unsigned long b_start, unsigned long b_end)
-{
- if ((b_start > a_end) || (a_start > b_end))
- return 0;
-
- return 1;
-}
-
-/*
- * check_overlap
- */
-static void check_overlap(enum memtrack_memtype_t memtype,
- struct memtrack_meminfo_t *mem_info_p,
- struct tracked_obj_desc_t *obj_desc_p)
-{
- struct list_head *pos, *next;
- struct memtrack_meminfo_t *cur;
- unsigned long start_a, end_a, start_b, end_b;
-
- start_a = mem_info_p->addr;
- end_a = mem_info_p->addr + mem_info_p->size - 1;
-
- list_for_each_safe(pos, next, &obj_desc_p->tracked_objs_head) {
- cur = list_entry(pos, struct memtrack_meminfo_t, list);
-
- start_b = cur->addr;
- end_b = cur->addr + cur->size - 1;
-
- if (overlap_a_b(start_a, end_a, start_b, end_b))
- printk(KERN_ERR "%s overlaps! new_start=0x%lx, new_end=0x%lx, item_start=0x%lx, item_end=0x%lx\n",
- memtype_alloc_str(memtype), mem_info_p->addr,
- mem_info_p->addr + mem_info_p->size - 1, cur->addr,
- cur->addr + cur->size - 1);
- }
-}
-
-/* Invoke on memory allocation */
-void memtrack_alloc(enum memtrack_memtype_t memtype, unsigned long dev,
- unsigned long addr, unsigned long size, unsigned long addr2,
- int direction, const char *filename,
- const unsigned long line_num, int alloc_flags)
-{
- unsigned long hash_val;
- struct memtrack_meminfo_t *cur_mem_info_p, *new_mem_info_p;
- struct tracked_obj_desc_t *obj_desc_p;
- unsigned long flags;
-
- if (memtype >= MEMTRACK_NUM_OF_MEMTYPES) {
- printk(KERN_ERR "%s: Invalid memory type (%d)\n", __func__, memtype);
- return;
- }
-
- if (!tracked_objs_arr[memtype]) {
- /* object is not tracked */
- return;
- }
- obj_desc_p = tracked_objs_arr[memtype];
-
- hash_val = addr % MEMTRACK_HASH_SZ;
-
- new_mem_info_p = (struct memtrack_meminfo_t *)kmem_cache_alloc(meminfo_cache, alloc_flags);
- if (new_mem_info_p == NULL) {
- printk(KERN_ERR "%s: Failed allocating kmem_cache item for new mem_info. "
- "Lost tracking on allocation at %s:%lu...\n", __func__,
- filename, line_num);
- return;
- }
- /* save allocation properties */
- new_mem_info_p->addr = addr;
- new_mem_info_p->size = size;
- new_mem_info_p->dev = dev;
- new_mem_info_p->addr2 = addr2;
- new_mem_info_p->direction = direction;
-
- new_mem_info_p->line_num = line_num;
- *new_mem_info_p->ext_info = '\0';
- /* Make sure that we will print out the path tail if the given filename is longer
- * than MAX_FILENAME_LEN. (otherwise, we will not see the name of the actual file
- * in the printout -- only the path head!
- */
- if (strlen(filename) > MAX_FILENAME_LEN)
- strncpy(new_mem_info_p->filename, filename + strlen(filename) - MAX_FILENAME_LEN, MAX_FILENAME_LEN);
- else
- strncpy(new_mem_info_p->filename, filename, MAX_FILENAME_LEN);
-
- new_mem_info_p->filename[MAX_FILENAME_LEN] = 0; /* NULL terminate anyway */
-
- memtrack_spin_lock(&obj_desc_p->hash_lock, flags);
- /* make sure given memory location is not already allocated */
- if ((memtype != MEMTRACK_DMA_MAP_SINGLE) && (memtype != MEMTRACK_DMA_MAP_PAGE) &&
- (memtype != MEMTRACK_DMA_MAP_SG)) {
-
- /* make sure given memory location is not already allocated */
- cur_mem_info_p = obj_desc_p->mem_hash[hash_val];
- while (cur_mem_info_p != NULL) {
- if ((cur_mem_info_p->addr == addr) && (cur_mem_info_p->dev == dev)) {
- /* Found given address in the database */
- printk(KERN_ERR "mtl rsc inconsistency: %s: %s::%lu: %s @ addr=0x%lX which is already known from %s:%lu\n",
- __func__, filename, line_num,
- memtype_alloc_str(memtype), addr,
- cur_mem_info_p->filename,
- cur_mem_info_p->line_num);
- memtrack_spin_unlock(&obj_desc_p->hash_lock, flags);
- kmem_cache_free(meminfo_cache, new_mem_info_p);
- return;
- }
- cur_mem_info_p = cur_mem_info_p->next;
- }
- }
- /* not found - we can put in the hash bucket */
- /* link as first */
- new_mem_info_p->next = obj_desc_p->mem_hash[hash_val];
- obj_desc_p->mem_hash[hash_val] = new_mem_info_p;
- if (obj_desc_p->strict_track)
- check_overlap(memtype, new_mem_info_p, obj_desc_p);
- obj_desc_p->count += size;
- list_add(&new_mem_info_p->list, &obj_desc_p->tracked_objs_head);
-
- memtrack_spin_unlock(&obj_desc_p->hash_lock, flags);
- return;
-}
-EXPORT_SYMBOL(memtrack_alloc);
-
-/* Invoke on memory free */
-void memtrack_free(enum memtrack_memtype_t memtype, unsigned long dev,
- unsigned long addr, unsigned long size, int direction,
- const char *filename, const unsigned long line_num)
-{
- unsigned long hash_val;
- struct memtrack_meminfo_t *cur_mem_info_p, *prev_mem_info_p;
- struct tracked_obj_desc_t *obj_desc_p;
- unsigned long flags;
-
- if (memtype >= MEMTRACK_NUM_OF_MEMTYPES) {
- printk(KERN_ERR "%s: Invalid memory type (%d)\n", __func__, memtype);
- return;
- }
-
- if (!tracked_objs_arr[memtype]) {
- /* object is not tracked */
- return;
- }
- obj_desc_p = tracked_objs_arr[memtype];
-
- hash_val = addr % MEMTRACK_HASH_SZ;
-
- memtrack_spin_lock(&obj_desc_p->hash_lock, flags);
- /* find mem_info of given memory location */
- prev_mem_info_p = NULL;
- cur_mem_info_p = obj_desc_p->mem_hash[hash_val];
- while (cur_mem_info_p != NULL) {
- if ((cur_mem_info_p->addr == addr) && (cur_mem_info_p->dev == dev)) {
- /* Found given address in the database */
- if ((memtype == MEMTRACK_DMA_MAP_SINGLE) || (memtype == MEMTRACK_DMA_MAP_PAGE) ||
- (memtype == MEMTRACK_DMA_MAP_SG)) {
- if (direction != cur_mem_info_p->direction)
- printk(KERN_ERR "mtl rsc inconsistency: %s: %s::%lu: %s bad direction for addr 0x%lX: alloc:0x%x, free:0x%x (allocated in %s::%lu)\n",
- __func__, filename, line_num, memtype_free_str(memtype), addr, cur_mem_info_p->direction, direction,
- cur_mem_info_p->filename, cur_mem_info_p->line_num);
-
- if (size != cur_mem_info_p->size)
- printk(KERN_ERR "mtl rsc inconsistency: %s: %s::%lu: %s bad size for addr 0x%lX: size:%lu, free:%lu (allocated in %s::%lu)\n",
- __func__, filename, line_num, memtype_free_str(memtype), addr, cur_mem_info_p->size, size,
- cur_mem_info_p->filename, cur_mem_info_p->line_num);
- }
-
- /* Remove from the bucket/list */
- if (prev_mem_info_p == NULL)
- obj_desc_p->mem_hash[hash_val] = cur_mem_info_p->next; /* removing first */
- else
- prev_mem_info_p->next = cur_mem_info_p->next; /* "crossover" */
-
- list_del(&cur_mem_info_p->list);
-
- obj_desc_p->count -= cur_mem_info_p->size;
- memtrack_spin_unlock(&obj_desc_p->hash_lock, flags);
- kmem_cache_free(meminfo_cache, cur_mem_info_p);
- return;
- }
- prev_mem_info_p = cur_mem_info_p;
- cur_mem_info_p = cur_mem_info_p->next;
- }
-
- /* not found */
- printk(KERN_ERR "mtl rsc inconsistency: %s: %s::%lu: %s for unknown address=0x%lX, device=0x%lX\n",
- __func__, filename, line_num, memtype_free_str(memtype), addr, dev);
- memtrack_spin_unlock(&obj_desc_p->hash_lock, flags);
- return;
-}
-EXPORT_SYMBOL(memtrack_free);
-
-/*
- * This function recognizes allocations which
- * may be released by kernel (e.g. skb) and
- * therefore not trackable by memtrack.
- * The allocations are recognized by the name
- * of their calling function.
- */
-int is_non_trackable_alloc_func(const char *func_name)
-{
- static const char * const str_str_arr[] = {
- /* functions containing these strings consider non trackable */
- "skb",
- };
- static const char * const str_str_excep_arr[] = {
- /* functions which are exception to the str_str_arr table */
- "ipoib_cm_skb_too_long"
- };
- static const char * const str_cmp_arr[] = {
- /* functions that allocate SKBs */
- "mlx4_en_alloc_frags",
- "mlx4_en_alloc_frag",
- "mlx4_en_init_allocator",
- "mlx4_en_free_frag",
- "mlx4_en_free_rx_desc",
- "mlx4_en_destroy_allocator",
- "mlx4_en_complete_rx_desc",
- /* vnic skb functions */
- "free_single_frag",
- "vnic_alloc_rx_skb",
- "vnic_rx_skb",
- "vnic_alloc_frag",
- "vnic_empty_rx_entry",
- "vnic_init_allocator",
- "vnic_destroy_allocator",
- "sdp_post_recv",
- "sdp_rx_ring_purge",
- "sdp_post_srcavail",
- "sk_stream_alloc_page",
- "update_send_head",
- "sdp_bcopy_get",
- "sdp_destroy_resources",
-
- /* function that allocate memory for RDMA device context */
- "ib_alloc_device"
- };
- size_t str_str_arr_size = sizeof(str_str_arr)/sizeof(char *);
- size_t str_str_excep_size = sizeof(str_str_excep_arr)/sizeof(char *);
- size_t str_cmp_arr_size = sizeof(str_cmp_arr)/sizeof(char *);
-
- int i, j;
-
- for (i = 0; i < str_str_arr_size; ++i)
- if (strstr(func_name, str_str_arr[i])) {
- for (j = 0; j < str_str_excep_size; ++j)
- if (!strcmp(func_name, str_str_excep_arr[j]))
- return 0;
- return 1;
- }
- for (i = 0; i < str_cmp_arr_size; ++i)
- if (!strcmp(func_name, str_cmp_arr[i]))
- return 1;
- return 0;
-}
-EXPORT_SYMBOL(is_non_trackable_alloc_func);
-
-/*
- * In some cases we need to free a memory
- * we defined as "non trackable" (see
- * is_non_trackable_alloc_func).
- * This function recognizes such releases
- * by the name of their calling function.
- */
-int is_non_trackable_free_func(const char *func_name)
-{
-
- static const char * const str_cmp_arr[] = {
- /* function that deallocate memory for RDMA device context */
- "ib_dealloc_device"
- };
- size_t str_cmp_arr_size = sizeof(str_cmp_arr)/sizeof(char *);
-
- int i;
-
- for (i = 0; i < str_cmp_arr_size; ++i)
- if (!strcmp(func_name, str_cmp_arr[i]))
- return 1;
- return 0;
-}
-EXPORT_SYMBOL(is_non_trackable_free_func);
-
-
-/* WA - In this function handles confirm
- the function name is
- '__ib_umem_release' or 'ib_umem_get'
- In this case we won't track the
- memory there because the kernel
- was the one who allocated it.
- Return value:
- 1 - if the function name is match, else 0 */
-int is_umem_put_page(const char *func_name)
-{
- const char func_str[18] = "__ib_umem_release";
- /* In case of error flow put_page is called as part of ib_umem_get */
- const char func_str1[12] = "ib_umem_get";
-
- return ((strstr(func_name, func_str) != NULL) ||
- (strstr(func_name, func_str1) != NULL)) ? 1 : 0;
-}
-EXPORT_SYMBOL(is_umem_put_page);
-
-/* Check page order size
- When Freeing a page allocation it checks whether
- we are trying to free the same size
- we asked to allocate */
-int memtrack_check_size(enum memtrack_memtype_t memtype, unsigned long addr,
- unsigned long size, const char *filename,
- const unsigned long line_num)
-{
- unsigned long hash_val;
- struct memtrack_meminfo_t *cur_mem_info_p;
- struct tracked_obj_desc_t *obj_desc_p;
- unsigned long flags;
- int ret = 0;
-
- if (memtype >= MEMTRACK_NUM_OF_MEMTYPES) {
- printk(KERN_ERR "%s: Invalid memory type (%d)\n", __func__, memtype);
- return 1;
- }
-
- if (!tracked_objs_arr[memtype]) {
- /* object is not tracked */
- return 1;
- }
- obj_desc_p = tracked_objs_arr[memtype];
-
- hash_val = addr % MEMTRACK_HASH_SZ;
-
- memtrack_spin_lock(&obj_desc_p->hash_lock, flags);
- /* find mem_info of given memory location */
- cur_mem_info_p = obj_desc_p->mem_hash[hash_val];
- while (cur_mem_info_p != NULL) {
- if (cur_mem_info_p->addr == addr) {
- /* Found given address in the database - check size */
- if (cur_mem_info_p->size != size) {
- printk(KERN_ERR "mtl size inconsistency: %s: %s::%lu: try to %s at address=0x%lX with size %lu while was created with size %lu\n",
- __func__, filename, line_num, memtype_free_str(memtype),
- addr, size, cur_mem_info_p->size);
- snprintf(cur_mem_info_p->ext_info, sizeof(cur_mem_info_p->ext_info),
- "invalid free size %lu\n", size);
- ret = 1;
- }
- memtrack_spin_unlock(&obj_desc_p->hash_lock, flags);
- return ret;
- }
- cur_mem_info_p = cur_mem_info_p->next;
- }
-
- /* not found - This function will not give any indication
- but will only check the correct size\order
- For inconsistency the 'free' function will check that */
- memtrack_spin_unlock(&obj_desc_p->hash_lock, flags);
- return 1;
-}
-EXPORT_SYMBOL(memtrack_check_size);
-
-/* Search for a specific addr whether it exist in the
- current data-base.
- It will print an error msg if we get an unexpected result,
- Return value: 0 - if addr exist, else 1 */
-int memtrack_is_new_addr(enum memtrack_memtype_t memtype, unsigned long addr, int expect_exist,
- const char *filename, const unsigned long line_num)
-{
- unsigned long hash_val;
- struct memtrack_meminfo_t *cur_mem_info_p;
- struct tracked_obj_desc_t *obj_desc_p;
- unsigned long flags;
-
- if (memtype >= MEMTRACK_NUM_OF_MEMTYPES) {
- printk(KERN_ERR "%s: Invalid memory type (%d)\n", __func__, memtype);
- return 1;
- }
-
- if (!tracked_objs_arr[memtype]) {
- /* object is not tracked */
- return 0;
- }
- obj_desc_p = tracked_objs_arr[memtype];
-
- hash_val = addr % MEMTRACK_HASH_SZ;
-
- memtrack_spin_lock(&obj_desc_p->hash_lock, flags);
- /* find mem_info of given memory location */
- cur_mem_info_p = obj_desc_p->mem_hash[hash_val];
- while (cur_mem_info_p != NULL) {
- if (cur_mem_info_p->addr == addr) {
- /* Found given address in the database - exiting */
- memtrack_spin_unlock(&obj_desc_p->hash_lock, flags);
- return 0;
- }
- cur_mem_info_p = cur_mem_info_p->next;
- }
-
- /* not found */
- if (expect_exist)
- printk(KERN_ERR "mtl rsc inconsistency: %s: %s::%lu: %s for unknown address=0x%lX\n",
- __func__, filename, line_num, memtype_free_str(memtype), addr);
-
- memtrack_spin_unlock(&obj_desc_p->hash_lock, flags);
- return 1;
-}
-EXPORT_SYMBOL(memtrack_is_new_addr);
-
-/* Return current page reference counter */
-int memtrack_get_page_ref_count(unsigned long addr)
-{
- unsigned long hash_val;
- struct memtrack_meminfo_t *cur_mem_info_p;
- struct tracked_obj_desc_t *obj_desc_p;
- unsigned long flags;
- /* This function is called only for page allocation */
- enum memtrack_memtype_t memtype = MEMTRACK_PAGE_ALLOC;
- int ref_conut = 0;
-
- if (!tracked_objs_arr[memtype]) {
- /* object is not tracked */
- return ref_conut;
- }
- obj_desc_p = tracked_objs_arr[memtype];
-
- hash_val = addr % MEMTRACK_HASH_SZ;
-
- memtrack_spin_lock(&obj_desc_p->hash_lock, flags);
- /* find mem_info of given memory location */
- cur_mem_info_p = obj_desc_p->mem_hash[hash_val];
- while (cur_mem_info_p != NULL) {
- if (cur_mem_info_p->addr == addr) {
- /* Found given address in the database - check ref-count */
- struct page *page = (struct page *)(cur_mem_info_p->addr);
- ref_conut = atomic_read(&page->_count);
- memtrack_spin_unlock(&obj_desc_p->hash_lock, flags);
- return ref_conut;
- }
- cur_mem_info_p = cur_mem_info_p->next;
- }
-
- /* not found */
- memtrack_spin_unlock(&obj_desc_p->hash_lock, flags);
- return ref_conut;
-}
-EXPORT_SYMBOL(memtrack_get_page_ref_count);
-
-/* Report current allocations status (for all memory types) */
-static void memtrack_report(void)
-{
- enum memtrack_memtype_t memtype;
- unsigned long cur_bucket;
- struct memtrack_meminfo_t *cur_mem_info_p;
- int serial = 1;
- struct tracked_obj_desc_t *obj_desc_p;
- unsigned long flags;
- unsigned long detected_leaks = 0;
-
- printk(KERN_INFO "%s: Currently known allocations:\n", __func__);
- for (memtype = 0; memtype < MEMTRACK_NUM_OF_MEMTYPES; memtype++) {
- if (tracked_objs_arr[memtype]) {
- printk(KERN_INFO "%d) %s:\n", serial, memtype_alloc_str(memtype));
- obj_desc_p = tracked_objs_arr[memtype];
- /* Scan all buckets to find existing allocations */
- /* TBD: this may be optimized by holding a linked list of all hash items */
- for (cur_bucket = 0; cur_bucket < MEMTRACK_HASH_SZ; cur_bucket++) {
- memtrack_spin_lock(&obj_desc_p->hash_lock, flags); /* protect per bucket/list */
- cur_mem_info_p = obj_desc_p->mem_hash[cur_bucket];
- while (cur_mem_info_p != NULL) { /* scan bucket */
- printk(KERN_INFO "%s::%lu: %s(%lu)==%lX dev=%lX %s\n",
- cur_mem_info_p->filename,
- cur_mem_info_p->line_num,
- memtype_alloc_str(memtype),
- cur_mem_info_p->size,
- cur_mem_info_p->addr,
- cur_mem_info_p->dev,
- cur_mem_info_p->ext_info);
- cur_mem_info_p = cur_mem_info_p->next;
- ++ detected_leaks;
- } /* while cur_mem_info_p */
- memtrack_spin_unlock(&obj_desc_p->hash_lock, flags);
- } /* for cur_bucket */
- serial++;
- }
- } /* for memtype */
- printk(KERN_INFO "%s: Summary: %lu leak(s) detected\n", __func__, detected_leaks);
-}
-
-
-
-static struct proc_dir_entry *memtrack_tree;
-
-static enum memtrack_memtype_t get_rsc_by_name(const char *name)
-{
- enum memtrack_memtype_t i;
-
- for (i = 0; i < MEMTRACK_NUM_OF_MEMTYPES; ++i) {
- if (strcmp(name, rsc_names[i]) == 0)
- return i;
- }
-
- return i;
-}
-
-
-static ssize_t memtrack_read(struct file *filp,
- char __user *buf,
- size_t size,
- loff_t *offset)
-{
- unsigned long cur, flags;
- loff_t pos = *offset;
- static char kbuf[20];
- static int file_len;
- int _read, to_ret, left;
- const char *fname;
- enum memtrack_memtype_t memtype;
-
- if (pos < 0)
- return -EINVAL;
-
- fname = filp->f_dentry->d_name.name;
-
- memtype = get_rsc_by_name(fname);
- if (memtype >= MEMTRACK_NUM_OF_MEMTYPES) {
- printk(KERN_ERR "invalid file name\n");
- return -EINVAL;
- }
-
- if (pos == 0) {
- memtrack_spin_lock(&tracked_objs_arr[memtype]->hash_lock, flags);
- cur = tracked_objs_arr[memtype]->count;
- memtrack_spin_unlock(&tracked_objs_arr[memtype]->hash_lock, flags);
- _read = sprintf(kbuf, "%lu\n", cur);
- if (_read < 0)
- return _read;
- else
- file_len = _read;
- }
-
- left = file_len - pos;
- to_ret = (left < size) ? left : size;
- if (copy_to_user(buf, kbuf+pos, to_ret))
- return -EFAULT;
- else {
- *offset = pos + to_ret;
- return to_ret;
- }
-}
-
-static const struct file_operations memtrack_proc_fops = {
- .read = memtrack_read,
-};
-
-static const char *memtrack_proc_entry_name = "mt_memtrack";
-
-static int create_procfs_tree(void)
-{
- struct proc_dir_entry *dir_ent;
- struct proc_dir_entry *proc_ent;
- int i, j;
- unsigned long bit_mask;
-
- dir_ent = proc_mkdir(memtrack_proc_entry_name, NULL);
- if (!dir_ent)
- return -1;
-
- memtrack_tree = dir_ent;
-
- for (i = 0, bit_mask = 1; i < MEMTRACK_NUM_OF_MEMTYPES; ++i, bit_mask <<= 1) {
- if (bit_mask & track_mask) {
- proc_ent = create_proc_entry(rsc_names[i], S_IRUGO, memtrack_tree);
- if (!proc_ent)
- goto undo_create_root;
-
- proc_ent->proc_fops = &memtrack_proc_fops;
- }
- }
-
- goto exit_ok;
-
-undo_create_root:
- for (j = 0, bit_mask = 1; j < i; ++j, bit_mask <<= 1) {
- if (bit_mask & track_mask)
- remove_proc_entry(rsc_names[j], memtrack_tree);
- }
- remove_proc_entry(memtrack_proc_entry_name, NULL);
- return -1;
-
-exit_ok:
- return 0;
-}
-
-
-static void destroy_procfs_tree(void)
-{
- int i;
- unsigned long bit_mask;
-
- for (i = 0, bit_mask = 1; i < MEMTRACK_NUM_OF_MEMTYPES; ++i, bit_mask <<= 1) {
- if (bit_mask & track_mask)
- remove_proc_entry(rsc_names[i], memtrack_tree);
-
- }
- remove_proc_entry(memtrack_proc_entry_name, NULL);
-}
-
-int memtrack_inject_error(void)
-{
- int val = 0;
-
- if (inject_freq) {
- if (!(random32() % inject_freq))
- val = 1;
- }
-
- return val;
-}
-EXPORT_SYMBOL(memtrack_inject_error);
-
-int memtrack_randomize_mem(void)
-{
- return random_mem;
-}
-EXPORT_SYMBOL(memtrack_randomize_mem);
-
-/* module entry points */
-
-int init_module(void)
-{
- enum memtrack_memtype_t i;
- int j;
- unsigned long bit_mask;
-
-
- /* create a cache for the memtrack_meminfo_t strcutures */
- meminfo_cache = kmem_cache_create("memtrack_meminfo_t",
- sizeof(struct memtrack_meminfo_t), 0,
- SLAB_HWCACHE_ALIGN, NULL);
- if (!meminfo_cache) {
- printk(KERN_ERR "memtrack::%s: failed to allocate meminfo cache\n", __func__);
- return -1;
- }
-
- /* initialize array of descriptors */
- memset(tracked_objs_arr, 0, sizeof(tracked_objs_arr));
-
- /* create a tracking object descriptor for all required objects */
- for (i = 0, bit_mask = 1; i < MEMTRACK_NUM_OF_MEMTYPES; ++i, bit_mask <<= 1) {
- if (bit_mask & track_mask) {
- tracked_objs_arr[i] = vmalloc(sizeof(struct tracked_obj_desc_t));
- if (!tracked_objs_arr[i]) {
- printk(KERN_ERR "memtrack: failed to allocate tracking object\n");
- goto undo_cache_create;
- }
-
- memset(tracked_objs_arr[i], 0, sizeof(struct tracked_obj_desc_t));
- spin_lock_init(&tracked_objs_arr[i]->hash_lock);
- INIT_LIST_HEAD(&tracked_objs_arr[i]->tracked_objs_head);
- if (bit_mask & strict_track_mask)
- tracked_objs_arr[i]->strict_track = 1;
- else
- tracked_objs_arr[i]->strict_track = 0;
- }
- }
-
-
- if (create_procfs_tree()) {
- printk(KERN_ERR "%s: create_procfs_tree() failed\n", __FILE__);
- goto undo_cache_create;
- }
-
- printk(KERN_INFO "memtrack::%s done.\n", __func__);
-
- return 0;
-
-undo_cache_create:
- for (j = 0; j < i; ++j) {
- if (tracked_objs_arr[j])
- vfree(tracked_objs_arr[j]);
- }
-
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 19)
- if (kmem_cache_destroy(meminfo_cache) != 0)
- printk(KERN_ERR "Failed on kmem_cache_destroy!\n");
-#else
- kmem_cache_destroy(meminfo_cache);
-#endif
- return -1;
-}
-
-
-void cleanup_module(void)
-{
- enum memtrack_memtype_t memtype;
- unsigned long cur_bucket;
- struct memtrack_meminfo_t *cur_mem_info_p, *next_mem_info_p;
- struct tracked_obj_desc_t *obj_desc_p;
- unsigned long flags;
-
-
- memtrack_report();
-
-
- destroy_procfs_tree();
-
- /* clean up any hash table left-overs */
- for (memtype = 0; memtype < MEMTRACK_NUM_OF_MEMTYPES; memtype++) {
- /* Scan all buckets to find existing allocations */
- /* TBD: this may be optimized by holding a linked list of all hash items */
- if (tracked_objs_arr[memtype]) {
- obj_desc_p = tracked_objs_arr[memtype];
- for (cur_bucket = 0; cur_bucket < MEMTRACK_HASH_SZ; cur_bucket++) {
- memtrack_spin_lock(&obj_desc_p->hash_lock, flags); /* protect per bucket/list */
- cur_mem_info_p = obj_desc_p->mem_hash[cur_bucket];
- while (cur_mem_info_p != NULL) { /* scan bucket */
- next_mem_info_p = cur_mem_info_p->next; /* save "next" pointer before the "free" */
- kmem_cache_free(meminfo_cache, cur_mem_info_p);
- cur_mem_info_p = next_mem_info_p;
- } /* while cur_mem_info_p */
- memtrack_spin_unlock(&obj_desc_p->hash_lock, flags);
- } /* for cur_bucket */
- vfree(obj_desc_p);
- }
- } /* for memtype */
-
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 19)
- if (kmem_cache_destroy(meminfo_cache) != 0)
- printk(KERN_ERR "memtrack::cleanup_module: Failed on kmem_cache_destroy!\n");
-#else
- kmem_cache_destroy(meminfo_cache);
-#endif
- printk(KERN_INFO "memtrack::cleanup_module done.\n");
-}
diff --git a/sys/ofed/drivers/infiniband/debug/memtrack.h b/sys/ofed/drivers/infiniband/debug/memtrack.h
deleted file mode 100644
index fb52f4b..0000000
--- a/sys/ofed/drivers/infiniband/debug/memtrack.h
+++ /dev/null
@@ -1,106 +0,0 @@
-/*
- This software is available to you under a choice of one of two
- licenses. You may choose to be licensed under the terms of the GNU
- General Public License (GPL) Version 2, available at
- <http://www.fsf.org/copyleft/gpl.html>, or the OpenIB.org BSD
- license, available in the LICENSE.TXT file accompanying this
- software. These details are also available at
- <http://openib.org/license.html>.
-
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- SOFTWARE.
-
- Copyright (c) 2004 Mellanox Technologies Ltd. All rights reserved.
-*/
-
-#ifndef H_MEMTRACK_H
-#define H_MEMTRACK_H
-
-enum memtrack_memtype_t {
- MEMTRACK_KMALLOC,
- MEMTRACK_VMALLOC,
- MEMTRACK_KMEM_OBJ,
- MEMTRACK_IOREMAP, /* IO-RE/UN-MAP */
- MEMTRACK_WORK_QUEUE, /* Handle work-queue create & destroy */
- MEMTRACK_PAGE_ALLOC, /* Handle page allocation and free */
- MEMTRACK_DMA_MAP_SINGLE,/* Handle ib_dma_single map and unmap */
- MEMTRACK_DMA_MAP_PAGE, /* Handle ib_dma_page map and unmap */
- MEMTRACK_DMA_MAP_SG, /* Handle ib_dma_sg map and unmap with and without attributes */
- MEMTRACK_NUM_OF_MEMTYPES
-};
-
-/* Invoke on memory allocation */
-void memtrack_alloc(enum memtrack_memtype_t memtype, unsigned long dev,
- unsigned long addr, unsigned long size, unsigned long addr2,
- int direction, const char *filename,
- const unsigned long line_num, int alloc_flags);
-
-/* Invoke on memory free */
-void memtrack_free(enum memtrack_memtype_t memtype, unsigned long dev,
- unsigned long addr, unsigned long size, int direction,
- const char *filename, const unsigned long line_num);
-
-/*
- * This function recognizes allocations which
- * may be released by kernel (e.g. skb & vnic) and
- * therefore not trackable by memtrack.
- * The allocations are recognized by the name
- * of their calling function.
- */
-int is_non_trackable_alloc_func(const char *func_name);
-/*
- * In some cases we need to free a memory
- * we defined as "non trackable" (see
- * is_non_trackable_alloc_func).
- * This function recognizes such releases
- * by the name of their calling function.
- */
-int is_non_trackable_free_func(const char *func_name);
-
-/* WA - In this function handles confirm
- the function name is
- '__ib_umem_release' or 'ib_umem_get'
- In this case we won't track the
- memory there because the kernel
- was the one who allocated it.
- Return value:
- 1 - if the function name is match, else 0 */
-int is_umem_put_page(const char *func_name);
-
-/* Check page order size
- When Freeing a page allocation it checks whether
- we are trying to free the same amount of pages
- we ask to allocate (In log2(order)).
- In case an error if found it will print
- an error msg */
-int memtrack_check_size(enum memtrack_memtype_t memtype, unsigned long addr,
- unsigned long size, const char *filename,
- const unsigned long line_num);
-
-/* Search for a specific addr whether it exist in the
- current data-base.
- If not it will print an error msg,
- Return value: 0 - if addr exist, else 1 */
-int memtrack_is_new_addr(enum memtrack_memtype_t memtype, unsigned long addr, int expect_exist,
- const char *filename, const unsigned long line_num);
-
-/* Return current page reference counter */
-int memtrack_get_page_ref_count(unsigned long addr);
-
-/* Report current allocations status (for all memory types) */
-/* we do not export this function since it is used by cleanup_module only */
-/* void memtrack_report(void); */
-
-/* Allow support of error injections */
-int memtrack_inject_error(void);
-
-/* randomize allocated memory */
-int memtrack_randomize_mem(void);
-
-#endif
diff --git a/sys/ofed/drivers/infiniband/debug/mtrack.h b/sys/ofed/drivers/infiniband/debug/mtrack.h
deleted file mode 100644
index 5c0cd20..0000000
--- a/sys/ofed/drivers/infiniband/debug/mtrack.h
+++ /dev/null
@@ -1,844 +0,0 @@
-#ifndef __mtrack_h_
-#define __mtrack_h_
-
-#include "memtrack.h"
-
-#include <linux/slab.h>
-#include <linux/vmalloc.h>
-#include <linux/kernel.h>
-#include <linux/io.h> /* For ioremap_nocache, ioremap, iounmap */
-#include <linux/random.h>
-#if LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 27)
-# include <linux/io-mapping.h> /* For ioremap_nocache, ioremap, iounmap */
-#endif
-#include <linux/mm.h> /* For all page handling */
-#include <linux/workqueue.h> /* For all work-queue handling */
-#include <linux/scatterlist.h> /* For using scatterlists */
-#include <linux/skbuff.h> /* For skbufs handling */
-#include <asm/uaccess.h> /* For copy from/to user */
-
-#define MEMTRACK_ERROR_INJECTION_MESSAGE(file, line, func) ({ \
- printk(KERN_ERR "%s failure injected at %s:%d\n", func, file, line); \
- dump_stack(); \
-})
-
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 14)
-#define RDMA_KZALLOC_H
-#define kzalloc(size, flags) ({ \
- void *__memtrack_kz_addr = NULL; \
- \
- if (memtrack_inject_error()) \
- MEMTRACK_ERROR_INJECTION_MESSAGE(__FILE__, __LINE__, "kzalloc");\
- else \
- __memtrack_kz_addr = kmalloc(size, flags); \
- if (__memtrack_kz_addr && !is_non_trackable_alloc_func(__func__)) { \
- memset(__memtrack_kz_addr, 0, size); \
- } \
- __memtrack_kz_addr; \
-})
-
-#else
-#define kzalloc(size, flags) ({ \
- void *__memtrack_addr = NULL; \
- \
- if (memtrack_inject_error()) \
- MEMTRACK_ERROR_INJECTION_MESSAGE(__FILE__, __LINE__, "kzalloc");\
- else \
- __memtrack_addr = kzalloc(size, flags); \
- if (__memtrack_addr && !is_non_trackable_alloc_func(__func__)) { \
- memtrack_alloc(MEMTRACK_KMALLOC, 0UL, (unsigned long)(__memtrack_addr), size, 0UL, 0, __FILE__, __LINE__, flags); \
- } \
- __memtrack_addr; \
-})
-
-#endif
-
-#define kzalloc_node(size, flags, node) ({ \
- void *__memtrack_addr = NULL; \
- \
- if (memtrack_inject_error()) \
- MEMTRACK_ERROR_INJECTION_MESSAGE(__FILE__, __LINE__, "kzalloc_node"); \
- else \
- __memtrack_addr = kzalloc_node(size, flags, node); \
- if (__memtrack_addr && (size) && \
- !is_non_trackable_alloc_func(__func__)) { \
- memtrack_alloc(MEMTRACK_KMALLOC, 0UL, (unsigned long)(__memtrack_addr), size, 0UL, 0, __FILE__, __LINE__, flags); \
- } \
- __memtrack_addr; \
-})
-
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 19)
-#define kcalloc(n, size, flags) kzalloc((n)*(size), flags)
-#else
-#define kcalloc(n, size, flags) ({ \
- void *__memtrack_addr = NULL; \
- \
- if (memtrack_inject_error()) \
- MEMTRACK_ERROR_INJECTION_MESSAGE(__FILE__, __LINE__, "kcalloc");\
- else \
- __memtrack_addr = kcalloc(n, size, flags); \
- if (__memtrack_addr && (size)) { \
- memtrack_alloc(MEMTRACK_KMALLOC, 0UL, (unsigned long)(__memtrack_addr), (n)*(size), 0UL, 0, __FILE__, __LINE__, flags); \
- } \
- __memtrack_addr; \
-})
-#endif
-
-
-
-#ifdef ZERO_OR_NULL_PTR
-#define kmalloc(sz, flgs) ({ \
- void *__memtrack_addr = NULL; \
- \
- if (memtrack_inject_error()) \
- MEMTRACK_ERROR_INJECTION_MESSAGE(__FILE__, __LINE__, "kmalloc");\
- else \
- __memtrack_addr = kmalloc(sz, flgs); \
- if (!ZERO_OR_NULL_PTR(__memtrack_addr)) { \
- memtrack_alloc(MEMTRACK_KMALLOC, 0UL, (unsigned long)(__memtrack_addr), sz, 0UL, 0, __FILE__, __LINE__, flgs); \
- if (memtrack_randomize_mem()) \
- get_random_bytes(__memtrack_addr, sz); \
- } \
- __memtrack_addr; \
-})
-#else
-#define kmalloc(sz, flgs) ({ \
- void *__memtrack_addr = NULL; \
- \
- if (memtrack_inject_error()) \
- MEMTRACK_ERROR_INJECTION_MESSAGE(__FILE__, __LINE__, "kmalloc");\
- else \
- __memtrack_addr = kmalloc(sz, flgs); \
- if (__memtrack_addr) { \
- memtrack_alloc(MEMTRACK_KMALLOC, 0UL, (unsigned long)(__memtrack_addr), sz, 0UL, 0, __FILE__, __LINE__, flgs); \
- if (memtrack_randomize_mem()) \
- get_random_bytes(__memtrack_addr, sz); \
- } \
- __memtrack_addr; \
-})
-
-#endif
-
-#define kmalloc_node(sz, flgs, node) ({ \
- void *__memtrack_addr = NULL; \
- \
- if (memtrack_inject_error()) \
- MEMTRACK_ERROR_INJECTION_MESSAGE(__FILE__, __LINE__, "kmalloc_node"); \
- else \
- __memtrack_addr = kmalloc_node(sz, flgs, node); \
- if (__memtrack_addr) { \
- memtrack_alloc(MEMTRACK_KMALLOC, 0UL, (unsigned long)(__memtrack_addr), sz, 0UL, 0, __FILE__, __LINE__, flgs); \
- if (memtrack_randomize_mem() && ((flgs) == GFP_KERNEL)) \
- get_random_bytes(__memtrack_addr, sz); \
- } \
- __memtrack_addr; \
-})
-
-#ifdef ZERO_OR_NULL_PTR
-#define kmemdup(src, sz, flgs) ({ \
- void *__memtrack_addr = NULL; \
- \
- if (memtrack_inject_error()) \
- MEMTRACK_ERROR_INJECTION_MESSAGE(__FILE__, __LINE__, "kmemdup");\
- else \
- __memtrack_addr = kmemdup(src, sz, flgs); \
- if (!ZERO_OR_NULL_PTR(__memtrack_addr)) { \
- memtrack_alloc(MEMTRACK_KMALLOC, 0UL, (unsigned long)(__memtrack_addr), sz, 0UL, 0, __FILE__, __LINE__, flgs); \
- } \
- __memtrack_addr; \
-})
-#else
-#define kmemdup(src, sz, flgs) ({ \
- void *__memtrack_addr = NULL; \
- \
- if (memtrack_inject_error()) \
- MEMTRACK_ERROR_INJECTION_MESSAGE(__FILE__, __LINE__, "kmemdup");\
- else \
- __memtrack_addr = kmemdup(src, sz, flgs); \
- if (__memtrack_addr) { \
- memtrack_alloc(MEMTRACK_KMALLOC, 0UL, (unsigned long)(__memtrack_addr), sz, 0UL, 0, __FILE__, __LINE__, flgs); \
- } \
- __memtrack_addr; \
-})
-#endif
-
-#ifdef ZERO_OR_NULL_PTR
-#define kfree(addr) ({ \
- void *__memtrack_addr = (void *)addr; \
- \
- if (!ZERO_OR_NULL_PTR(__memtrack_addr) && \
- !is_non_trackable_free_func(__func__)) { \
- memtrack_free(MEMTRACK_KMALLOC, 0UL, (unsigned long)(__memtrack_addr), 0UL, 0, __FILE__, __LINE__); \
- } \
- kfree(__memtrack_addr); \
-})
-#else
-#define kfree(addr) ({ \
- void *__memtrack_addr = (void *)addr; \
- \
- if (__memtrack_addr && !is_non_trackable_free_func(__func__)) { \
- memtrack_free(MEMTRACK_KMALLOC, 0UL, (unsigned long)(__memtrack_addr), 0UL, 0, __FILE__, __LINE__); \
- } \
- kfree(__memtrack_addr); \
-})
-#endif
-
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 0, 0) || defined (CONFIG_COMPAT_RCU)
-#ifdef kfree_rcu
- #undef kfree_rcu
-#endif
-
-#ifdef ZERO_OR_NULL_PTR
-#define kfree_rcu(addr, rcu_head) ({ \
- void *__memtrack_addr = (void *)addr; \
- \
- if (!ZERO_OR_NULL_PTR(__memtrack_addr) && \
- !is_non_trackable_free_func(__func__)) { \
- memtrack_free(MEMTRACK_KMALLOC, 0UL, (unsigned long)(__memtrack_addr), 0UL, 0, __FILE__, __LINE__); \
- } \
- __kfree_rcu(&((addr)->rcu_head), offsetof(typeof(*(addr)), rcu_head)); \
-})
-#else
-#define kfree_rcu(addr, rcu_head) ({ \
- void *__memtrack_addr = (void *)addr; \
- \
- if (__memtrack_addr && !is_non_trackable_free_func(__func__)) { \
- memtrack_free(MEMTRACK_KMALLOC, 0UL, (unsigned long)(__memtrack_addr), 0UL, 0, __FILE__, __LINE__); \
- } \
- __kfree_rcu(&((addr)->rcu_head), offsetof(typeof(*(addr)), rcu_head)); \
-})
-#endif
-#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(3, 0, 0) */
-
-#define vmalloc(size) ({ \
- void *__memtrack_addr = NULL; \
- \
- if (memtrack_inject_error()) \
- MEMTRACK_ERROR_INJECTION_MESSAGE(__FILE__, __LINE__, "vmalloc");\
- else \
- __memtrack_addr = vmalloc(size); \
- if (__memtrack_addr) { \
- memtrack_alloc(MEMTRACK_VMALLOC, 0UL, (unsigned long)(__memtrack_addr), size, 0UL, 0, __FILE__, __LINE__, GFP_ATOMIC); \
- if (memtrack_randomize_mem()) \
- get_random_bytes(__memtrack_addr, size); \
- } \
- __memtrack_addr; \
-})
-
-#ifndef vzalloc
-#define vzalloc(size) ({ \
- void *__memtrack_addr = NULL; \
- \
- if (memtrack_inject_error()) \
- MEMTRACK_ERROR_INJECTION_MESSAGE(__FILE__, __LINE__, "vzalloc");\
- else \
- __memtrack_addr = vzalloc(size); \
- if (__memtrack_addr) { \
- memtrack_alloc(MEMTRACK_VMALLOC, 0UL, (unsigned long)(__memtrack_addr), size, 0UL, 0, __FILE__, __LINE__, GFP_ATOMIC); \
- } \
- __memtrack_addr; \
-})
-#endif
-
-#ifndef vzalloc_node
-#define vzalloc_node(size, node) ({ \
- void *__memtrack_addr = NULL; \
- \
- if (memtrack_inject_error()) \
- MEMTRACK_ERROR_INJECTION_MESSAGE(__FILE__, __LINE__, "vzalloc_node"); \
- else \
- __memtrack_addr = vzalloc_node(size, node); \
- if (__memtrack_addr) { \
- memtrack_alloc(MEMTRACK_VMALLOC, 0UL, (unsigned long)(__memtrack_addr), size, 0UL, 0, __FILE__, __LINE__, GFP_ATOMIC); \
- if (memtrack_randomize_mem()) \
- get_random_bytes(__memtrack_addr, size); \
- } \
- __memtrack_addr; \
-})
-#endif
-
-#define vmalloc_node(size, node) ({ \
- void *__memtrack_addr = NULL; \
- \
- if (memtrack_inject_error()) \
- MEMTRACK_ERROR_INJECTION_MESSAGE(__FILE__, __LINE__, "vmalloc_node"); \
- else \
- __memtrack_addr = vmalloc_node(size, node); \
- if (__memtrack_addr) { \
- memtrack_alloc(MEMTRACK_VMALLOC, 0UL, (unsigned long)(__memtrack_addr), size, 0UL, 0, __FILE__, __LINE__, GFP_ATOMIC); \
- if (memtrack_randomize_mem()) \
- get_random_bytes(__memtrack_addr, size); \
- } \
- __memtrack_addr; \
-})
-
-#define vfree(addr) ({ \
- void *__memtrack_addr = (void *)addr; \
- if (__memtrack_addr) { \
- memtrack_free(MEMTRACK_VMALLOC, 0UL, (unsigned long)(__memtrack_addr), 0UL, 0, __FILE__, __LINE__); \
- } \
- vfree(__memtrack_addr); \
-})
-
-
-#define kmem_cache_alloc(cache, flags) ({ \
- void *__memtrack_addr = NULL; \
- \
- if (memtrack_inject_error()) \
- MEMTRACK_ERROR_INJECTION_MESSAGE(__FILE__, __LINE__, "kmem_cache_alloc"); \
- else \
- __memtrack_addr = kmem_cache_alloc(cache, flags); \
- if (__memtrack_addr) { \
- memtrack_alloc(MEMTRACK_KMEM_OBJ, 0UL, (unsigned long)(__memtrack_addr), 1, 0UL, 0, __FILE__, __LINE__, flags); \
- } \
- __memtrack_addr; \
-})
-
-
-#define kmem_cache_free(cache, addr) ({ \
- void *__memtrack_addr = (void *)addr; \
- \
- if (__memtrack_addr) { \
- memtrack_free(MEMTRACK_KMEM_OBJ, 0UL, (unsigned long)(__memtrack_addr), 0UL, 0, __FILE__, __LINE__); \
- } \
- kmem_cache_free(cache, __memtrack_addr); \
-})
-
-
-/* All IO-MAP handling */
-#define ioremap(phys_addr, size) ({ \
- void __iomem *__memtrack_addr = NULL; \
- \
- if (memtrack_inject_error()) \
- MEMTRACK_ERROR_INJECTION_MESSAGE(__FILE__, __LINE__, "ioremap");\
- else \
- __memtrack_addr = ioremap(phys_addr, size); \
- if (__memtrack_addr) { \
- memtrack_alloc(MEMTRACK_IOREMAP, 0UL, (unsigned long)(__memtrack_addr), size, 0UL, 0, __FILE__, __LINE__, GFP_ATOMIC); \
- } \
- __memtrack_addr; \
-})
-
-#define io_mapping_create_wc(base, size) ({ \
- void __iomem *__memtrack_addr = NULL; \
- \
- if (memtrack_inject_error()) \
- MEMTRACK_ERROR_INJECTION_MESSAGE(__FILE__, __LINE__, "io_mapping_create_wc"); \
- else \
- __memtrack_addr = io_mapping_create_wc(base, size); \
- if (__memtrack_addr) { \
- memtrack_alloc(MEMTRACK_IOREMAP, 0UL, (unsigned long)(__memtrack_addr), size, 0UL, 0, __FILE__, __LINE__, GFP_ATOMIC); \
- } \
- __memtrack_addr; \
-})
-
-#define io_mapping_free(addr) ({ \
- void *__memtrack_addr = (void *)addr; \
- \
- if (__memtrack_addr) { \
- memtrack_free(MEMTRACK_IOREMAP, 0UL, (unsigned long)(__memtrack_addr), 0UL, 0, __FILE__, __LINE__); \
- } \
- io_mapping_free(__memtrack_addr); \
-})
-
-#ifdef CONFIG_PPC
-#ifdef ioremap_nocache
- #undef ioremap_nocache
-#endif
-#define ioremap_nocache(phys_addr, size) ({ \
- void __iomem *__memtrack_addr = NULL; \
- \
- if (memtrack_inject_error()) \
- MEMTRACK_ERROR_INJECTION_MESSAGE(__FILE__, __LINE__, "ioremap_nocache"); \
- else \
- __memtrack_addr = ioremap(phys_addr, size); \
- if (__memtrack_addr) { \
- memtrack_alloc(MEMTRACK_IOREMAP, 0UL, (unsigned long)(__memtrack_addr), size, 0UL, 0, __FILE__, __LINE__, GFP_ATOMIC); \
- } \
- __memtrack_addr; \
-})
-#else
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 18) /* 2.6.16 - 2.6.17 */
-#ifdef ioremap_nocache
- #undef ioremap_nocache
-#endif
-#define ioremap_nocache(phys_addr, size) ({ \
- void __iomem *__memtrack_addr = NULL; \
- \
- if (memtrack_inject_error()) \
- MEMTRACK_ERROR_INJECTION_MESSAGE(__FILE__, __LINE__, "ioremap_nocache"); \
- else \
- __memtrack_addr = ioremap(phys_addr, size); \
- if (__memtrack_addr) { \
- memtrack_alloc(MEMTRACK_IOREMAP, 0UL, (unsigned long)(__memtrack_addr), size, 0UL, 0, __FILE__, __LINE__, GFP_ATOMIC); \
- } \
- __memtrack_addr; \
-})
-#else
-#define ioremap_nocache(phys_addr, size) ({ \
- void __iomem *__memtrack_addr = NULL; \
- \
- if (memtrack_inject_error()) \
- MEMTRACK_ERROR_INJECTION_MESSAGE(__FILE__, __LINE__, "ioremap_nocache"); \
- else \
- __memtrack_addr = ioremap_nocache(phys_addr, size); \
- if (__memtrack_addr) { \
- memtrack_alloc(MEMTRACK_IOREMAP, 0UL, (unsigned long)(__memtrack_addr), size, 0UL, 0, __FILE__, __LINE__, GFP_ATOMIC); \
- } \
- __memtrack_addr; \
-})
-#endif /* Kernel version is under 2.6.18 */
-#endif /* PPC */
-
-#define iounmap(addr) ({ \
- void *__memtrack_addr = (void *)addr; \
- \
- if (__memtrack_addr) { \
- memtrack_free(MEMTRACK_IOREMAP, 0UL, (unsigned long)(__memtrack_addr), 0UL, 0, __FILE__, __LINE__); \
- } \
- iounmap(__memtrack_addr); \
-})
-
-
-/* All Page handlers */
-/* TODO: Catch netif_rx for page dereference */
-#define alloc_pages_node(nid, gfp_mask, order) ({ \
- struct page *page_addr = NULL; \
- \
- if (memtrack_inject_error()) \
- MEMTRACK_ERROR_INJECTION_MESSAGE(__FILE__, __LINE__, "alloc_pages_node"); \
- else \
- page_addr = (struct page *)alloc_pages_node(nid, gfp_mask, order); \
- if (page_addr && !is_non_trackable_alloc_func(__func__)) { \
- memtrack_alloc(MEMTRACK_PAGE_ALLOC, 0UL, (unsigned long)(page_addr), (unsigned long)(order), 0UL, 0, __FILE__, __LINE__, GFP_ATOMIC); \
- } \
- page_addr; \
-})
-
-#ifdef CONFIG_NUMA
-#define alloc_pages(gfp_mask, order) ({ \
- struct page *page_addr = NULL; \
- \
- if (memtrack_inject_error()) \
- MEMTRACK_ERROR_INJECTION_MESSAGE(__FILE__, __LINE__, "alloc_pages"); \
- else \
- page_addr = (struct page *)alloc_pages(gfp_mask, order); \
- if (page_addr && !is_non_trackable_alloc_func(__func__)) { \
- memtrack_alloc(MEMTRACK_PAGE_ALLOC, 0UL, (unsigned long)(page_addr), (unsigned long)(order), 0UL, 0, __FILE__, __LINE__, GFP_ATOMIC); \
- } \
- page_addr; \
-})
-#else
-#ifdef alloc_pages
- #undef alloc_pages
-#endif
-#define alloc_pages(gfp_mask, order) ({ \
- struct page *page_addr; \
- \
- page_addr = (struct page *)alloc_pages_node(numa_node_id(), gfp_mask, order); \
- page_addr; \
-})
-#endif
-
-#define __get_free_pages(gfp_mask, order) ({ \
- struct page *page_addr = NULL; \
- \
- if (memtrack_inject_error()) \
- MEMTRACK_ERROR_INJECTION_MESSAGE(__FILE__, __LINE__, "__get_free_pages"); \
- else \
- page_addr = (struct page *)__get_free_pages(gfp_mask, order); \
- if (page_addr && !is_non_trackable_alloc_func(__func__)) { \
- memtrack_alloc(MEMTRACK_PAGE_ALLOC, 0UL, (unsigned long)(page_addr), (unsigned long)(order), 0UL, 0, __FILE__, __LINE__, GFP_ATOMIC); \
- } \
- page_addr; \
-})
-
-#define get_zeroed_page(gfp_mask) ({ \
- struct page *page_addr = NULL; \
- \
- if (memtrack_inject_error()) \
- MEMTRACK_ERROR_INJECTION_MESSAGE(__FILE__, __LINE__, "get_zeroed_page"); \
- else \
- page_addr = (struct page *)get_zeroed_page(gfp_mask); \
- if (page_addr && !is_non_trackable_alloc_func(__func__)) { \
- memtrack_alloc(MEMTRACK_PAGE_ALLOC, 0UL, (unsigned long)(page_addr), 0, 0UL, 0, __FILE__, __LINE__, GFP_ATOMIC); \
- } \
- (unsigned long)page_addr; \
-})
-
-#define __free_pages(addr, order) ({ \
- void *__memtrack_addr = (void *)addr; \
- \
- if (__memtrack_addr && !is_non_trackable_alloc_func(__func__)) { \
- if (!memtrack_check_size(MEMTRACK_PAGE_ALLOC, (unsigned long)(__memtrack_addr), (unsigned long)(order), __FILE__, __LINE__)) \
- memtrack_free(MEMTRACK_PAGE_ALLOC, 0UL, (unsigned long)(__memtrack_addr), 0UL, 0, __FILE__, __LINE__); \
- } \
- __free_pages(addr, order); \
-})
-
-
-#define free_pages(addr, order) ({ \
- void *__memtrack_addr = (void *)addr; \
- \
- if (__memtrack_addr && !is_non_trackable_alloc_func(__func__)) { \
- if (!memtrack_check_size(MEMTRACK_PAGE_ALLOC, (unsigned long)(__memtrack_addr), (unsigned long)(order), __FILE__, __LINE__)) \
- memtrack_free(MEMTRACK_PAGE_ALLOC, 0UL, (unsigned long)(__memtrack_addr), 0UL, 0, __FILE__, __LINE__); \
- } \
- free_pages(addr, order); \
-})
-
-
-#define get_page(addr) ({ \
- void *__memtrack_addr = (void *)addr; \
- \
- if (__memtrack_addr && !is_non_trackable_alloc_func(__func__)) { \
- if (memtrack_is_new_addr(MEMTRACK_PAGE_ALLOC, (unsigned long)(__memtrack_addr), 0, __FILE__, __LINE__)) { \
- memtrack_alloc(MEMTRACK_PAGE_ALLOC, 0UL, (unsigned long)(__memtrack_addr), 0, 0UL, 0, __FILE__, __LINE__, GFP_ATOMIC); \
- } \
- } \
- get_page(addr); \
-})
-
-#define get_user_pages_fast(start, nr_pages, write, pages) ({ \
- int __memtrack_rc = -1; \
- \
- if (memtrack_inject_error()) \
- MEMTRACK_ERROR_INJECTION_MESSAGE(__FILE__, __LINE__, "get_user_pages_fast"); \
- else \
- __memtrack_rc = get_user_pages_fast(start, nr_pages, write, pages); \
- if (__memtrack_rc > 0 && !is_non_trackable_alloc_func(__func__)) { \
- int __memtrack_i; \
- \
- for (__memtrack_i = 0; __memtrack_i < __memtrack_rc; __memtrack_i++) \
- memtrack_alloc(MEMTRACK_PAGE_ALLOC, 0UL, (unsigned long)(pages[__memtrack_i]), 0, 0UL, 0, __FILE__, __LINE__, GFP_ATOMIC); \
- } \
- __memtrack_rc; \
-})
-
-#define put_page(addr) ({ \
- void *__memtrack_addr = (void *)addr; \
- \
- if (__memtrack_addr && !is_non_trackable_alloc_func(__func__)) { \
- /* Check whether this is not part of umem put page & not */\
- /* a new addr and the ref-count is 1 then we'll free this addr */\
- /* Don't change the order these conditions */ \
- if (!is_umem_put_page(__func__) && \
- !memtrack_is_new_addr(MEMTRACK_PAGE_ALLOC, (unsigned long)(__memtrack_addr), 1, __FILE__, __LINE__) && \
- (memtrack_get_page_ref_count((unsigned long)(__memtrack_addr)) == 1)) { \
- memtrack_free(MEMTRACK_PAGE_ALLOC, 0UL, (unsigned long)(__memtrack_addr), 0UL, 0, __FILE__, __LINE__); \
- } \
- } \
- put_page(addr); \
-})
-
-
-/* Work-Queue handlers */
-#ifdef create_workqueue
- #undef create_workqueue
-#endif
-#ifdef create_rt_workqueue
- #undef create_rt_workqueue
-#endif
-#ifdef create_freezeable_workqueue
- #undef create_freezeable_workqueue
-#endif
-#ifdef create_singlethread_workqueue
- #undef create_singlethread_workqueue
-#endif
-
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 20) /* 2.6.18 - 2.6.19 */
-#define create_workqueue(name) ({ \
- struct workqueue_struct *wq_addr = NULL; \
- \
- if (memtrack_inject_error()) \
- MEMTRACK_ERROR_INJECTION_MESSAGE(__FILE__, __LINE__, "create_workqueue"); \
- else \
- wq_addr = __create_workqueue((name), 0); \
- if (wq_addr) { \
- memtrack_alloc(MEMTRACK_WORK_QUEUE, 0UL, (unsigned long)(wq_addr), 0, 0UL, 0, __FILE__, __LINE__, GFP_ATOMIC); \
- } \
- wq_addr; \
-})
-
-#define create_singlethread_workqueue(name) ({ \
- struct workqueue_struct *wq_addr = NULL; \
- \
- if (memtrack_inject_error()) \
- MEMTRACK_ERROR_INJECTION_MESSAGE(__FILE__, __LINE__, "create_singlethread_workqueue"); \
- else \
- wq_addr = __create_workqueue((name), 1); \
- if (wq_addr) { \
- memtrack_alloc(MEMTRACK_WORK_QUEUE, 0UL, (unsigned long)(wq_addr), 0, 0UL, 0, __FILE__, __LINE__, GFP_ATOMIC); \
- } \
- wq_addr; \
-})
-
-#elif LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 28) /* 2.6.20 - 2.6.27 */
-#define create_workqueue(name) ({ \
- struct workqueue_struct *wq_addr = NULL; \
- \
- if (memtrack_inject_error()) \
- MEMTRACK_ERROR_INJECTION_MESSAGE(__FILE__, __LINE__, "create_workqueue"); \
- else \
- wq_addr = __create_workqueue((name), 0, 0); \
- if (wq_addr) { \
- memtrack_alloc(MEMTRACK_WORK_QUEUE, 0UL, (unsigned long)(wq_addr), 0, 0UL, 0, __FILE__, __LINE__, GFP_ATOMIC); \
- } \
- wq_addr; \
-})
-
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 22) /* 2.6.20 - 2.6.21 */
-#define create_freezeable_workqueue(name) ({ \
- struct workqueue_struct *wq_addr = NULL; \
- \
- if (memtrack_inject_error()) \
- MEMTRACK_ERROR_INJECTION_MESSAGE(__FILE__, __LINE__, "create_freezeable_workqueue"); \
- else \
- wq_addr = __create_workqueue((name), 0, 1); \
- if (wq_addr) { \
- memtrack_alloc(MEMTRACK_WORK_QUEUE, 0UL, (unsigned long)(wq_addr), 0, 0UL, 0, __FILE__, __LINE__, GFP_ATOMIC); \
- } \
- wq_addr; \
-})
-#else /* 2.6.22 - 2.6.27 */
-#define create_freezeable_workqueue(name) ({ \
- struct workqueue_struct *wq_addr = NULL; \
- \
- if (memtrack_inject_error()) \
- MEMTRACK_ERROR_INJECTION_MESSAGE(__FILE__, __LINE__, "create_freezeable_workqueue"); \
- else \
- wq_addr = __create_workqueue((name), 1, 1); \
- if (wq_addr) { \
- memtrack_alloc(MEMTRACK_WORK_QUEUE, 0UL, (unsigned long)(wq_addr), 0, 0UL, 0, __FILE__, __LINE__, GFP_ATOMIC); \
- } \
- wq_addr; \
-})
-#endif /* 2.6.20 - 2.6.27 */
-
-#define create_singlethread_workqueue(name) ({ \
- struct workqueue_struct *wq_addr = NULL; \
- \
- if (memtrack_inject_error()) \
- MEMTRACK_ERROR_INJECTION_MESSAGE(__FILE__, __LINE__, "create_singlethread_workqueue"); \
- else \
- wq_addr = __create_workqueue((name), 1, 0); \
- if (wq_addr) { \
- memtrack_alloc(MEMTRACK_WORK_QUEUE, 0UL, (unsigned long)(wq_addr), 0, 0UL, 0, __FILE__, __LINE__, GFP_ATOMIC); \
- } \
- wq_addr; \
-})
-
-#elif LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 36) /* 2.6.28 - 2.6.35 */
-
-#ifdef alloc_workqueue
- #undef alloc_workqueue
-#endif
-
-#define alloc_workqueue(name, flags, max_active) ({ \
- struct workqueue_struct *wq_addr = NULL; \
- \
- if (memtrack_inject_error()) \
- MEMTRACK_ERROR_INJECTION_MESSAGE(__FILE__, __LINE__, "alloc_workqueue"); \
- else \
- wq_addr = __create_workqueue((name), (flags), (max_active), 0); \
- if (wq_addr) { \
- memtrack_alloc(MEMTRACK_WORK_QUEUE, 0UL, (unsigned long)(wq_addr), 0, 0UL, 0, __FILE__, __LINE__, GFP_ATOMIC); \
- } \
- wq_addr; \
-})
-
-#define create_workqueue(name) ({ \
- struct workqueue_struct *wq_addr = NULL; \
- \
- if (memtrack_inject_error()) \
- MEMTRACK_ERROR_INJECTION_MESSAGE(__FILE__, __LINE__, "create_workqueue"); \
- else \
- wq_addr = __create_workqueue((name), 0, 0, 0); \
- if (wq_addr) { \
- memtrack_alloc(MEMTRACK_WORK_QUEUE, 0UL, (unsigned long)(wq_addr), 0, 0UL, 0, __FILE__, __LINE__, GFP_ATOMIC); \
- } \
- wq_addr; \
-})
-
-#define create_rt_workqueue(name) ({ \
- struct workqueue_struct *wq_addr = NULL; \
- \
- if (memtrack_inject_error()) \
- MEMTRACK_ERROR_INJECTION_MESSAGE(__FILE__, __LINE__, "create_rt_workqueue"); \
- else \
- wq_addr = __create_workqueue((name), 0, 0, 1); \
- if (wq_addr) { \
- memtrack_alloc(MEMTRACK_WORK_QUEUE, 0UL, (unsigned long)(wq_addr), 0, 0UL, 0, __FILE__, __LINE__, GFP_ATOMIC); \
- } \
- wq_addr; \
-})
-
-#define create_freezeable_workqueue(name) ({ \
- struct workqueue_struct *wq_addr = NULL; \
- \
- if (memtrack_inject_error()) \
- MEMTRACK_ERROR_INJECTION_MESSAGE(__FILE__, __LINE__, "create_freezeable_workqueue"); \
- else \
- wq_addr = __create_workqueue((name), 1, 1, 0); \
- if (wq_addr) { \
- memtrack_alloc(MEMTRACK_WORK_QUEUE, 0UL, (unsigned long)(wq_addr), 0, 0UL, 0, __FILE__, __LINE__, GFP_ATOMIC); \
- } \
- wq_addr; \
-})
-
-#define create_singlethread_workqueue(name) ({ \
- struct workqueue_struct *wq_addr = NULL; \
- \
- if (memtrack_inject_error()) \
- MEMTRACK_ERROR_INJECTION_MESSAGE(__FILE__, __LINE__, "create_singlethread_workqueue"); \
- else \
- wq_addr = __create_workqueue((name), 1, 0, 0); \
- if (wq_addr) { \
- memtrack_alloc(MEMTRACK_WORK_QUEUE, 0UL, (unsigned long)(wq_addr), 0, 0UL, 0, __FILE__, __LINE__, GFP_ATOMIC); \
- } \
- wq_addr; \
-})
-#else /* 2.6.36 */
-#ifdef alloc_workqueue
- #undef alloc_workqueue
-#endif
-#ifdef CONFIG_LOCKDEP
-#define alloc_workqueue(name, flags, max_active) \
-({ \
- static struct lock_class_key __key; \
- const char *__lock_name; \
- struct workqueue_struct *wq_addr = NULL; \
- \
- if (__builtin_constant_p(name)) \
- __lock_name = (name); \
- else \
- __lock_name = #name; \
- \
- if (memtrack_inject_error()) \
- MEMTRACK_ERROR_INJECTION_MESSAGE(__FILE__, __LINE__, "alloc_workqueue"); \
- else \
- wq_addr = __alloc_workqueue_key((name), (flags), (max_active), \
- &__key, __lock_name); \
- if (wq_addr) { \
- memtrack_alloc(MEMTRACK_WORK_QUEUE, 0UL, (unsigned long)(wq_addr), 0, 0UL, 0, __FILE__, __LINE__, GFP_ATOMIC); \
- } \
- wq_addr; \
-})
-#else
-#define alloc_workqueue(name, flags, max_active) ({ \
- struct workqueue_struct *wq_addr = NULL; \
- \
- if (memtrack_inject_error()) \
- MEMTRACK_ERROR_INJECTION_MESSAGE(__FILE__, __LINE__, "alloc_workqueue"); \
- else \
- wq_addr = __alloc_workqueue_key((name), (flags), (max_active), NULL, NULL); \
- if (wq_addr) { \
- memtrack_alloc(MEMTRACK_WORK_QUEUE, 0UL, (unsigned long)(wq_addr), 0, 0UL, 0, __FILE__, __LINE__, GFP_ATOMIC); \
- } \
- wq_addr; \
-})
-#endif
-
-#define create_workqueue(name) \
- alloc_workqueue((name), WQ_RESCUER, 1);
-
-#define create_freezeable_workqueue(name) \
- alloc_workqueue((name), WQ_FREEZEABLE | WQ_UNBOUND | WQ_RESCUER, 1);
-
-#define create_singlethread_workqueue(name) \
- alloc_workqueue((name), WQ_UNBOUND | WQ_RESCUER, 1);
-
-#endif /* Work-Queue Kernel Versions */
-
-#define destroy_workqueue(wq_addr) ({ \
- void *__memtrack_addr = (void *)wq_addr; \
- \
- if (__memtrack_addr) { \
- memtrack_free(MEMTRACK_WORK_QUEUE, 0UL, (unsigned long)(__memtrack_addr), 0UL, 0, __FILE__, __LINE__); \
- } \
- destroy_workqueue(wq_addr); \
-})
-
-/* ONLY error injection to functions that we don't monitor */
-#define alloc_skb(size, prio) ({ \
- struct sk_buff *__memtrack_skb = NULL; \
- \
- if (memtrack_inject_error()) \
- MEMTRACK_ERROR_INJECTION_MESSAGE(__FILE__, __LINE__, "alloc_skb"); \
- else \
- __memtrack_skb = alloc_skb(size, prio); \
- __memtrack_skb; \
-})
-
-#define dev_alloc_skb(size) ({ \
- struct sk_buff *__memtrack_skb = NULL; \
- \
- if (memtrack_inject_error()) \
- MEMTRACK_ERROR_INJECTION_MESSAGE(__FILE__, __LINE__, "dev_alloc_skb"); \
- else \
- __memtrack_skb = dev_alloc_skb(size); \
- __memtrack_skb; \
-})
-
-#define alloc_skb_fclone(size, prio) ({ \
- struct sk_buff *__memtrack_skb = NULL; \
- \
- if (memtrack_inject_error()) \
- MEMTRACK_ERROR_INJECTION_MESSAGE(__FILE__, __LINE__, "alloc_skb_fclone"); \
- else \
- __memtrack_skb = alloc_skb_fclone(size, prio); \
- __memtrack_skb; \
-})
-
-#define copy_from_user(to, from, n) ({ \
- int ret = n; \
- \
- if (memtrack_inject_error()) \
- MEMTRACK_ERROR_INJECTION_MESSAGE(__FILE__, __LINE__, "copy_from_user"); \
- else \
- ret = copy_from_user(to, from, n); \
- ret; \
-})
-
-#define copy_to_user(to, from, n) ({ \
- int ret = n; \
- \
- if (memtrack_inject_error()) \
- MEMTRACK_ERROR_INJECTION_MESSAGE(__FILE__, __LINE__, "copy_to_user"); \
- else \
- ret = copy_to_user(to, from, n); \
- ret; \
-})
-
-#define sysfs_create_file(kobj, attr) ({ \
- int ret = -ENOSYS; \
- \
- if (memtrack_inject_error()) \
- MEMTRACK_ERROR_INJECTION_MESSAGE(__FILE__, __LINE__, "sysfs_create_file"); \
- else \
- ret = sysfs_create_file(kobj, attr); \
- ret; \
-})
-
-#define sysfs_create_link(kobj, target, name) ({ \
- int ret = -ENOSYS; \
- \
- if (memtrack_inject_error()) \
- MEMTRACK_ERROR_INJECTION_MESSAGE(__FILE__, __LINE__, "sysfs_create_link"); \
- else \
- ret = sysfs_create_link(kobj, target, name); \
- ret; \
-})
-
-#define sysfs_create_group(kobj, grp) ({ \
- int ret = -ENOSYS; \
- \
- if (memtrack_inject_error()) \
- MEMTRACK_ERROR_INJECTION_MESSAGE(__FILE__, __LINE__, "sysfs_create_group"); \
- else \
- ret = sysfs_create_group(kobj, grp); \
- ret; \
-})
-
-#endif /* __mtrack_h_ */
-
diff --git a/sys/ofed/drivers/infiniband/hw/mthca/Kconfig b/sys/ofed/drivers/infiniband/hw/mthca/Kconfig
deleted file mode 100644
index 03efc07..0000000
--- a/sys/ofed/drivers/infiniband/hw/mthca/Kconfig
+++ /dev/null
@@ -1,17 +0,0 @@
-config INFINIBAND_MTHCA
- tristate "Mellanox HCA support"
- depends on PCI
- ---help---
- This is a low-level driver for Mellanox InfiniHost host
- channel adapters (HCAs), including the MT23108 PCI-X HCA
- ("Tavor") and the MT25208 PCI Express HCA ("Arbel").
-
-config INFINIBAND_MTHCA_DEBUG
- bool "Verbose debugging output" if EMBEDDED
- depends on INFINIBAND_MTHCA
- default y
- ---help---
- This option causes debugging code to be compiled into the
- mthca driver. The output can be turned on via the
- debug_level module parameter (which can also be set after
- the driver is loaded through sysfs).
diff --git a/sys/ofed/drivers/infiniband/hw/mthca/Makefile b/sys/ofed/drivers/infiniband/hw/mthca/Makefile
deleted file mode 100644
index e388d95..0000000
--- a/sys/ofed/drivers/infiniband/hw/mthca/Makefile
+++ /dev/null
@@ -1,7 +0,0 @@
-obj-$(CONFIG_INFINIBAND_MTHCA) += ib_mthca.o
-
-ib_mthca-y := mthca_main.o mthca_cmd.o mthca_profile.o mthca_reset.o \
- mthca_allocator.o mthca_eq.o mthca_pd.o mthca_cq.o \
- mthca_mr.o mthca_qp.o mthca_av.o mthca_mcg.o mthca_mad.o \
- mthca_provider.o mthca_memfree.o mthca_uar.o mthca_srq.o \
- mthca_catas.o
diff --git a/sys/ofed/drivers/infiniband/hw/mthca/mthca_allocator.c b/sys/ofed/drivers/infiniband/hw/mthca/mthca_allocator.c
deleted file mode 100644
index 8e9b018..0000000
--- a/sys/ofed/drivers/infiniband/hw/mthca/mthca_allocator.c
+++ /dev/null
@@ -1,300 +0,0 @@
-/*
- * Copyright (c) 2004 Topspin Communications. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-#include <linux/errno.h>
-#include <linux/slab.h>
-
-#include "mthca_dev.h"
-
-/* Trivial bitmap-based allocator */
-u32 mthca_alloc(struct mthca_alloc *alloc)
-{
- unsigned long flags;
- u32 obj;
-
- spin_lock_irqsave(&alloc->lock, flags);
-
- obj = find_next_zero_bit(alloc->table, alloc->max, alloc->last);
- if (obj >= alloc->max) {
- alloc->top = (alloc->top + alloc->max) & alloc->mask;
- obj = find_first_zero_bit(alloc->table, alloc->max);
- }
-
- if (obj < alloc->max) {
- set_bit(obj, alloc->table);
- obj |= alloc->top;
- } else
- obj = -1;
-
- spin_unlock_irqrestore(&alloc->lock, flags);
-
- return obj;
-}
-
-void mthca_free(struct mthca_alloc *alloc, u32 obj)
-{
- unsigned long flags;
-
- obj &= alloc->max - 1;
-
- spin_lock_irqsave(&alloc->lock, flags);
-
- clear_bit(obj, alloc->table);
- alloc->last = min(alloc->last, obj);
- alloc->top = (alloc->top + alloc->max) & alloc->mask;
-
- spin_unlock_irqrestore(&alloc->lock, flags);
-}
-
-int mthca_alloc_init(struct mthca_alloc *alloc, u32 num, u32 mask,
- u32 reserved)
-{
- int i;
-
- /* num must be a power of 2 */
- if (num != 1 << (ffs(num) - 1))
- return -EINVAL;
-
- alloc->last = 0;
- alloc->top = 0;
- alloc->max = num;
- alloc->mask = mask;
- spin_lock_init(&alloc->lock);
- alloc->table = kmalloc(BITS_TO_LONGS(num) * sizeof (long),
- GFP_KERNEL);
- if (!alloc->table)
- return -ENOMEM;
-
- bitmap_zero(alloc->table, num);
- for (i = 0; i < reserved; ++i)
- set_bit(i, alloc->table);
-
- return 0;
-}
-
-void mthca_alloc_cleanup(struct mthca_alloc *alloc)
-{
- kfree(alloc->table);
-}
-
-/*
- * Array of pointers with lazy allocation of leaf pages. Callers of
- * _get, _set and _clear methods must use a lock or otherwise
- * serialize access to the array.
- */
-
-#define MTHCA_ARRAY_MASK (PAGE_SIZE / sizeof (void *) - 1)
-
-void *mthca_array_get(struct mthca_array *array, int index)
-{
- int p = (index * sizeof (void *)) >> PAGE_SHIFT;
-
- if (array->page_list[p].page)
- return array->page_list[p].page[index & MTHCA_ARRAY_MASK];
- else
- return NULL;
-}
-
-int mthca_array_set(struct mthca_array *array, int index, void *value)
-{
- int p = (index * sizeof (void *)) >> PAGE_SHIFT;
-
- /* Allocate with GFP_ATOMIC because we'll be called with locks held. */
- if (!array->page_list[p].page)
- array->page_list[p].page = (void **) get_zeroed_page(GFP_ATOMIC);
-
- if (!array->page_list[p].page)
- return -ENOMEM;
-
- array->page_list[p].page[index & MTHCA_ARRAY_MASK] = value;
- ++array->page_list[p].used;
-
- return 0;
-}
-
-void mthca_array_clear(struct mthca_array *array, int index)
-{
- int p = (index * sizeof (void *)) >> PAGE_SHIFT;
-
- if (--array->page_list[p].used == 0) {
- free_page((unsigned long) array->page_list[p].page);
- array->page_list[p].page = NULL;
- } else
- array->page_list[p].page[index & MTHCA_ARRAY_MASK] = NULL;
-
- if (array->page_list[p].used < 0)
- pr_debug("Array %p index %d page %d with ref count %d < 0\n",
- array, index, p, array->page_list[p].used);
-}
-
-int mthca_array_init(struct mthca_array *array, int nent)
-{
- int npage = (nent * sizeof (void *) + PAGE_SIZE - 1) / PAGE_SIZE;
- int i;
-
- array->page_list = kmalloc(npage * sizeof *array->page_list, GFP_KERNEL);
- if (!array->page_list)
- return -ENOMEM;
-
- for (i = 0; i < npage; ++i) {
- array->page_list[i].page = NULL;
- array->page_list[i].used = 0;
- }
-
- return 0;
-}
-
-void mthca_array_cleanup(struct mthca_array *array, int nent)
-{
- int i;
-
- for (i = 0; i < (nent * sizeof (void *) + PAGE_SIZE - 1) / PAGE_SIZE; ++i)
- free_page((unsigned long) array->page_list[i].page);
-
- kfree(array->page_list);
-}
-
-/*
- * Handling for queue buffers -- we allocate a bunch of memory and
- * register it in a memory region at HCA virtual address 0. If the
- * requested size is > max_direct, we split the allocation into
- * multiple pages, so we don't require too much contiguous memory.
- */
-
-int mthca_buf_alloc(struct mthca_dev *dev, int size, int max_direct,
- union mthca_buf *buf, int *is_direct, struct mthca_pd *pd,
- int hca_write, struct mthca_mr *mr)
-{
- int err = -ENOMEM;
- int npages, shift;
- u64 *dma_list = NULL;
- dma_addr_t t;
- int i;
-
- if (size <= max_direct) {
- *is_direct = 1;
- npages = 1;
- shift = get_order(size) + PAGE_SHIFT;
-
- buf->direct.buf = dma_alloc_coherent(&dev->pdev->dev,
- size, &t, GFP_KERNEL);
- if (!buf->direct.buf)
- return -ENOMEM;
-
- pci_unmap_addr_set(&buf->direct, mapping, t);
-
- memset(buf->direct.buf, 0, size);
-
- while (t & ((1 << shift) - 1)) {
- --shift;
- npages *= 2;
- }
-
- dma_list = kmalloc(npages * sizeof *dma_list, GFP_KERNEL);
- if (!dma_list)
- goto err_free;
-
- for (i = 0; i < npages; ++i)
- dma_list[i] = t + i * (1 << shift);
- } else {
- *is_direct = 0;
- npages = (size + PAGE_SIZE - 1) / PAGE_SIZE;
- shift = PAGE_SHIFT;
-
- dma_list = kmalloc(npages * sizeof *dma_list, GFP_KERNEL);
- if (!dma_list)
- return -ENOMEM;
-
- buf->page_list = kmalloc(npages * sizeof *buf->page_list,
- GFP_KERNEL);
- if (!buf->page_list)
- goto err_out;
-
- for (i = 0; i < npages; ++i)
- buf->page_list[i].buf = NULL;
-
- for (i = 0; i < npages; ++i) {
- buf->page_list[i].buf =
- dma_alloc_coherent(&dev->pdev->dev, PAGE_SIZE,
- &t, GFP_KERNEL);
- if (!buf->page_list[i].buf)
- goto err_free;
-
- dma_list[i] = t;
- pci_unmap_addr_set(&buf->page_list[i], mapping, t);
-
- clear_page(buf->page_list[i].buf);
- }
- }
-
- err = mthca_mr_alloc_phys(dev, pd->pd_num,
- dma_list, shift, npages,
- 0, size,
- MTHCA_MPT_FLAG_LOCAL_READ |
- (hca_write ? MTHCA_MPT_FLAG_LOCAL_WRITE : 0),
- mr);
- if (err)
- goto err_free;
-
- kfree(dma_list);
-
- return 0;
-
-err_free:
- mthca_buf_free(dev, size, buf, *is_direct, NULL);
-
-err_out:
- kfree(dma_list);
-
- return err;
-}
-
-void mthca_buf_free(struct mthca_dev *dev, int size, union mthca_buf *buf,
- int is_direct, struct mthca_mr *mr)
-{
- int i;
-
- if (mr)
- mthca_free_mr(dev, mr);
-
- if (is_direct)
- dma_free_coherent(&dev->pdev->dev, size, buf->direct.buf,
- pci_unmap_addr(&buf->direct, mapping));
- else {
- for (i = 0; i < (size + PAGE_SIZE - 1) / PAGE_SIZE; ++i)
- dma_free_coherent(&dev->pdev->dev, PAGE_SIZE,
- buf->page_list[i].buf,
- pci_unmap_addr(&buf->page_list[i],
- mapping));
- kfree(buf->page_list);
- }
-}
diff --git a/sys/ofed/drivers/infiniband/hw/mthca/mthca_av.c b/sys/ofed/drivers/infiniband/hw/mthca/mthca_av.c
deleted file mode 100644
index 32f6c63..0000000
--- a/sys/ofed/drivers/infiniband/hw/mthca/mthca_av.c
+++ /dev/null
@@ -1,374 +0,0 @@
-/*
- * Copyright (c) 2004 Topspin Communications. All rights reserved.
- * Copyright (c) 2005 Sun Microsystems, Inc. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-#include <linux/string.h>
-#include <linux/slab.h>
-
-#include <rdma/ib_verbs.h>
-#include <rdma/ib_cache.h>
-
-#include "mthca_dev.h"
-
-enum {
- MTHCA_RATE_TAVOR_FULL = 0,
- MTHCA_RATE_TAVOR_1X = 1,
- MTHCA_RATE_TAVOR_4X = 2,
- MTHCA_RATE_TAVOR_1X_DDR = 3
-};
-
-enum {
- MTHCA_RATE_MEMFREE_FULL = 0,
- MTHCA_RATE_MEMFREE_QUARTER = 1,
- MTHCA_RATE_MEMFREE_EIGHTH = 2,
- MTHCA_RATE_MEMFREE_HALF = 3
-};
-
-struct mthca_av {
- __be32 port_pd;
- u8 reserved1;
- u8 g_slid;
- __be16 dlid;
- u8 reserved2;
- u8 gid_index;
- u8 msg_sr;
- u8 hop_limit;
- __be32 sl_tclass_flowlabel;
- __be32 dgid[4];
-};
-
-static enum ib_rate memfree_rate_to_ib(u8 mthca_rate, u8 port_rate)
-{
- switch (mthca_rate) {
- case MTHCA_RATE_MEMFREE_EIGHTH:
- return mult_to_ib_rate(port_rate >> 3);
- case MTHCA_RATE_MEMFREE_QUARTER:
- return mult_to_ib_rate(port_rate >> 2);
- case MTHCA_RATE_MEMFREE_HALF:
- return mult_to_ib_rate(port_rate >> 1);
- case MTHCA_RATE_MEMFREE_FULL:
- default:
- return mult_to_ib_rate(port_rate);
- }
-}
-
-static enum ib_rate tavor_rate_to_ib(u8 mthca_rate, u8 port_rate)
-{
- switch (mthca_rate) {
- case MTHCA_RATE_TAVOR_1X: return IB_RATE_2_5_GBPS;
- case MTHCA_RATE_TAVOR_1X_DDR: return IB_RATE_5_GBPS;
- case MTHCA_RATE_TAVOR_4X: return IB_RATE_10_GBPS;
- default: return mult_to_ib_rate(port_rate);
- }
-}
-
-enum ib_rate mthca_rate_to_ib(struct mthca_dev *dev, u8 mthca_rate, u8 port)
-{
- if (mthca_is_memfree(dev)) {
- /* Handle old Arbel FW */
- if (dev->limits.stat_rate_support == 0x3 && mthca_rate)
- return IB_RATE_2_5_GBPS;
-
- return memfree_rate_to_ib(mthca_rate, dev->rate[port - 1]);
- } else
- return tavor_rate_to_ib(mthca_rate, dev->rate[port - 1]);
-}
-
-static u8 ib_rate_to_memfree(u8 req_rate, u8 cur_rate)
-{
- if (cur_rate <= req_rate)
- return 0;
-
- /*
- * Inter-packet delay (IPD) to get from rate X down to a rate
- * no more than Y is (X - 1) / Y.
- */
- switch ((cur_rate - 1) / req_rate) {
- case 0: return MTHCA_RATE_MEMFREE_FULL;
- case 1: return MTHCA_RATE_MEMFREE_HALF;
- case 2: /* fall through */
- case 3: return MTHCA_RATE_MEMFREE_QUARTER;
- default: return MTHCA_RATE_MEMFREE_EIGHTH;
- }
-}
-
-static u8 ib_rate_to_tavor(u8 static_rate)
-{
- switch (static_rate) {
- case IB_RATE_2_5_GBPS: return MTHCA_RATE_TAVOR_1X;
- case IB_RATE_5_GBPS: return MTHCA_RATE_TAVOR_1X_DDR;
- case IB_RATE_10_GBPS: return MTHCA_RATE_TAVOR_4X;
- default: return MTHCA_RATE_TAVOR_FULL;
- }
-}
-
-u8 mthca_get_rate(struct mthca_dev *dev, int static_rate, u8 port)
-{
- u8 rate;
-
- if (!static_rate || ib_rate_to_mult(static_rate) >= dev->rate[port - 1])
- return 0;
-
- if (mthca_is_memfree(dev))
- rate = ib_rate_to_memfree(ib_rate_to_mult(static_rate),
- dev->rate[port - 1]);
- else
- rate = ib_rate_to_tavor(static_rate);
-
- if (!(dev->limits.stat_rate_support & (1 << rate)))
- rate = 1;
-
- return rate;
-}
-
-int mthca_create_ah(struct mthca_dev *dev,
- struct mthca_pd *pd,
- struct ib_ah_attr *ah_attr,
- struct mthca_ah *ah)
-{
- u32 index = -1;
- struct mthca_av *av = NULL;
-
- ah->type = MTHCA_AH_PCI_POOL;
-
- if (mthca_is_memfree(dev)) {
- ah->av = kmalloc(sizeof *ah->av, GFP_ATOMIC);
- if (!ah->av)
- return -ENOMEM;
-
- ah->type = MTHCA_AH_KMALLOC;
- av = ah->av;
- } else if (!atomic_read(&pd->sqp_count) &&
- !(dev->mthca_flags & MTHCA_FLAG_DDR_HIDDEN)) {
- index = mthca_alloc(&dev->av_table.alloc);
-
- /* fall back to allocate in host memory */
- if (index == -1)
- goto on_hca_fail;
-
- av = kmalloc(sizeof *av, GFP_ATOMIC);
- if (!av)
- goto on_hca_fail;
-
- ah->type = MTHCA_AH_ON_HCA;
- ah->avdma = dev->av_table.ddr_av_base +
- index * MTHCA_AV_SIZE;
- }
-
-on_hca_fail:
- if (ah->type == MTHCA_AH_PCI_POOL) {
- ah->av = pci_pool_alloc(dev->av_table.pool,
- GFP_ATOMIC, &ah->avdma);
- if (!ah->av)
- return -ENOMEM;
-
- av = ah->av;
- }
-
- ah->key = pd->ntmr.ibmr.lkey;
-
- memset(av, 0, MTHCA_AV_SIZE);
-
- av->port_pd = cpu_to_be32(pd->pd_num | (ah_attr->port_num << 24));
- av->g_slid = ah_attr->src_path_bits;
- av->dlid = cpu_to_be16(ah_attr->dlid);
- av->msg_sr = (3 << 4) | /* 2K message */
- mthca_get_rate(dev, ah_attr->static_rate, ah_attr->port_num);
- av->sl_tclass_flowlabel = cpu_to_be32(ah_attr->sl << 28);
- if (ah_attr->ah_flags & IB_AH_GRH) {
- av->g_slid |= 0x80;
- av->gid_index = (ah_attr->port_num - 1) * dev->limits.gid_table_len +
- ah_attr->grh.sgid_index;
- av->hop_limit = ah_attr->grh.hop_limit;
- av->sl_tclass_flowlabel |=
- cpu_to_be32((ah_attr->grh.traffic_class << 20) |
- ah_attr->grh.flow_label);
- memcpy(av->dgid, ah_attr->grh.dgid.raw, 16);
- } else {
- /* Arbel workaround -- low byte of GID must be 2 */
- av->dgid[3] = cpu_to_be32(2);
- }
-
- if (0) {
- int j;
-
- mthca_dbg(dev, "Created UDAV at %p/%08lx:\n",
- av, (unsigned long) ah->avdma);
- for (j = 0; j < 8; ++j)
- printk(KERN_DEBUG " [%2x] %08x\n",
- j * 4, be32_to_cpu(((__be32 *) av)[j]));
- }
-
- if (ah->type == MTHCA_AH_ON_HCA) {
- memcpy_toio(dev->av_table.av_map + index * MTHCA_AV_SIZE,
- av, MTHCA_AV_SIZE);
- kfree(av);
- }
-
- return 0;
-}
-
-int mthca_destroy_ah(struct mthca_dev *dev, struct mthca_ah *ah)
-{
- switch (ah->type) {
- case MTHCA_AH_ON_HCA:
- mthca_free(&dev->av_table.alloc,
- (ah->avdma - dev->av_table.ddr_av_base) /
- MTHCA_AV_SIZE);
- break;
-
- case MTHCA_AH_PCI_POOL:
- pci_pool_free(dev->av_table.pool, ah->av, ah->avdma);
- break;
-
- case MTHCA_AH_KMALLOC:
- kfree(ah->av);
- break;
- }
-
- return 0;
-}
-
-int mthca_ah_grh_present(struct mthca_ah *ah)
-{
- return !!(ah->av->g_slid & 0x80);
-}
-
-int mthca_read_ah(struct mthca_dev *dev, struct mthca_ah *ah,
- struct ib_ud_header *header)
-{
- if (ah->type == MTHCA_AH_ON_HCA)
- return -EINVAL;
-
- header->lrh.service_level = be32_to_cpu(ah->av->sl_tclass_flowlabel) >> 28;
- header->lrh.destination_lid = ah->av->dlid;
- header->lrh.source_lid = cpu_to_be16(ah->av->g_slid & 0x7f);
- if (mthca_ah_grh_present(ah)) {
- header->grh.traffic_class =
- (be32_to_cpu(ah->av->sl_tclass_flowlabel) >> 20) & 0xff;
- header->grh.flow_label =
- ah->av->sl_tclass_flowlabel & cpu_to_be32(0xfffff);
- header->grh.hop_limit = ah->av->hop_limit;
- ib_get_cached_gid(&dev->ib_dev,
- be32_to_cpu(ah->av->port_pd) >> 24,
- ah->av->gid_index % dev->limits.gid_table_len,
- &header->grh.source_gid);
- memcpy(header->grh.destination_gid.raw,
- ah->av->dgid, 16);
- }
-
- return 0;
-}
-
-int mthca_ah_query(struct ib_ah *ibah, struct ib_ah_attr *attr)
-{
- struct mthca_ah *ah = to_mah(ibah);
- struct mthca_dev *dev = to_mdev(ibah->device);
-
- /* Only implement for MAD and memfree ah for now. */
- if (ah->type == MTHCA_AH_ON_HCA)
- return -ENOSYS;
-
- memset(attr, 0, sizeof *attr);
- attr->dlid = be16_to_cpu(ah->av->dlid);
- attr->sl = be32_to_cpu(ah->av->sl_tclass_flowlabel) >> 28;
- attr->port_num = be32_to_cpu(ah->av->port_pd) >> 24;
- attr->static_rate = mthca_rate_to_ib(dev, ah->av->msg_sr & 0x7,
- attr->port_num);
- attr->src_path_bits = ah->av->g_slid & 0x7F;
- attr->ah_flags = mthca_ah_grh_present(ah) ? IB_AH_GRH : 0;
-
- if (attr->ah_flags) {
- attr->grh.traffic_class =
- be32_to_cpu(ah->av->sl_tclass_flowlabel) >> 20;
- attr->grh.flow_label =
- be32_to_cpu(ah->av->sl_tclass_flowlabel) & 0xfffff;
- attr->grh.hop_limit = ah->av->hop_limit;
- attr->grh.sgid_index = ah->av->gid_index &
- (dev->limits.gid_table_len - 1);
- memcpy(attr->grh.dgid.raw, ah->av->dgid, 16);
- }
-
- return 0;
-}
-
-int mthca_init_av_table(struct mthca_dev *dev)
-{
- int err;
-
- if (mthca_is_memfree(dev))
- return 0;
-
- err = mthca_alloc_init(&dev->av_table.alloc,
- dev->av_table.num_ddr_avs,
- dev->av_table.num_ddr_avs - 1,
- 0);
- if (err)
- return err;
-
- dev->av_table.pool = pci_pool_create("mthca_av", dev->pdev,
- MTHCA_AV_SIZE,
- MTHCA_AV_SIZE, 0);
- if (!dev->av_table.pool)
- goto out_free_alloc;
-
- if (!(dev->mthca_flags & MTHCA_FLAG_DDR_HIDDEN)) {
- dev->av_table.av_map = ioremap(pci_resource_start(dev->pdev, 4) +
- dev->av_table.ddr_av_base -
- dev->ddr_start,
- dev->av_table.num_ddr_avs *
- MTHCA_AV_SIZE);
- if (!dev->av_table.av_map)
- goto out_free_pool;
- } else
- dev->av_table.av_map = NULL;
-
- return 0;
-
- out_free_pool:
- pci_pool_destroy(dev->av_table.pool);
-
- out_free_alloc:
- mthca_alloc_cleanup(&dev->av_table.alloc);
- return -ENOMEM;
-}
-
-void mthca_cleanup_av_table(struct mthca_dev *dev)
-{
- if (mthca_is_memfree(dev))
- return;
-
- if (dev->av_table.av_map)
- iounmap(dev->av_table.av_map);
- pci_pool_destroy(dev->av_table.pool);
- mthca_alloc_cleanup(&dev->av_table.alloc);
-}
diff --git a/sys/ofed/drivers/infiniband/hw/mthca/mthca_catas.c b/sys/ofed/drivers/infiniband/hw/mthca/mthca_catas.c
deleted file mode 100644
index 7f72140..0000000
--- a/sys/ofed/drivers/infiniband/hw/mthca/mthca_catas.c
+++ /dev/null
@@ -1,200 +0,0 @@
-/*
- * Copyright (c) 2005 Cisco Systems. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-#define LINUXKPI_PARAM_PREFIX mthca_
-
-#include <linux/jiffies.h>
-#include <linux/timer.h>
-#include <linux/workqueue.h>
-
-#include "mthca_dev.h"
-
-enum {
- MTHCA_CATAS_TYPE_INTERNAL = 0,
- MTHCA_CATAS_TYPE_UPLINK = 3,
- MTHCA_CATAS_TYPE_DDR = 4,
- MTHCA_CATAS_TYPE_PARITY = 5,
-};
-
-#define MTHCA_CATAS_POLL_INTERVAL (5 * HZ)
-
-static DEFINE_SPINLOCK(catas_lock);
-
-static LIST_HEAD(catas_list);
-static struct workqueue_struct *catas_wq;
-static struct work_struct catas_work;
-
-static int catas_reset_disable;
-module_param_named(catas_reset_disable, catas_reset_disable, int, 0644);
-MODULE_PARM_DESC(catas_reset_disable, "disable reset on catastrophic event if nonzero");
-
-static void catas_reset(struct work_struct *work)
-{
- struct mthca_dev *dev, *tmpdev;
- LIST_HEAD(tlist);
- int ret;
-
- mutex_lock(&mthca_device_mutex);
-
- spin_lock_irq(&catas_lock);
- list_splice_init(&catas_list, &tlist);
- spin_unlock_irq(&catas_lock);
-
- list_for_each_entry_safe(dev, tmpdev, &tlist, catas_err.list) {
- struct pci_dev *pdev = dev->pdev;
- ret = __mthca_restart_one(dev->pdev);
- /* 'dev' now is not valid */
- if (ret)
- printk(KERN_ERR "mthca %s: Reset failed (%d)\n",
- pci_name(pdev), ret);
- else {
- struct mthca_dev *d = pci_get_drvdata(pdev);
- mthca_dbg(d, "Reset succeeded\n");
- }
- }
-
- mutex_unlock(&mthca_device_mutex);
-}
-
-static void handle_catas(struct mthca_dev *dev)
-{
- struct ib_event event;
- unsigned long flags;
- const char *type;
- int i;
-
- event.device = &dev->ib_dev;
- event.event = IB_EVENT_DEVICE_FATAL;
- event.element.port_num = 0;
- dev->active = 0;
-
- ib_dispatch_event(&event);
-
- switch (swab32(readl(dev->catas_err.map)) >> 24) {
- case MTHCA_CATAS_TYPE_INTERNAL:
- type = "internal error";
- break;
- case MTHCA_CATAS_TYPE_UPLINK:
- type = "uplink bus error";
- break;
- case MTHCA_CATAS_TYPE_DDR:
- type = "DDR data error";
- break;
- case MTHCA_CATAS_TYPE_PARITY:
- type = "internal parity error";
- break;
- default:
- type = "unknown error";
- break;
- }
-
- mthca_err(dev, "Catastrophic error detected: %s\n", type);
- for (i = 0; i < dev->catas_err.size; ++i)
- mthca_err(dev, " buf[%02x]: %08x\n",
- i, swab32(readl(dev->catas_err.map + i)));
-
- if (catas_reset_disable)
- return;
-
- spin_lock_irqsave(&catas_lock, flags);
- list_add(&dev->catas_err.list, &catas_list);
- queue_work(catas_wq, &catas_work);
- spin_unlock_irqrestore(&catas_lock, flags);
-}
-
-static void poll_catas(unsigned long dev_ptr)
-{
- struct mthca_dev *dev = (struct mthca_dev *) dev_ptr;
- int i;
-
- for (i = 0; i < dev->catas_err.size; ++i)
- if (readl(dev->catas_err.map + i)) {
- handle_catas(dev);
- return;
- }
-
- mod_timer(&dev->catas_err.timer,
- round_jiffies(jiffies + MTHCA_CATAS_POLL_INTERVAL));
-}
-
-void mthca_start_catas_poll(struct mthca_dev *dev)
-{
- unsigned long addr;
-
- init_timer(&dev->catas_err.timer);
- dev->catas_err.map = NULL;
-
- addr = pci_resource_start(dev->pdev, 0) +
- ((pci_resource_len(dev->pdev, 0) - 1) &
- dev->catas_err.addr);
-
- dev->catas_err.map = ioremap(addr, dev->catas_err.size * 4);
- if (!dev->catas_err.map) {
- mthca_warn(dev, "couldn't map catastrophic error region "
- "at 0x%lx/0x%x\n", addr, dev->catas_err.size * 4);
- return;
- }
-
- dev->catas_err.timer.data = (unsigned long) dev;
- dev->catas_err.timer.function = poll_catas;
- dev->catas_err.timer.expires = jiffies + MTHCA_CATAS_POLL_INTERVAL;
- INIT_LIST_HEAD(&dev->catas_err.list);
- add_timer(&dev->catas_err.timer);
-}
-
-void mthca_stop_catas_poll(struct mthca_dev *dev)
-{
- del_timer_sync(&dev->catas_err.timer);
-
- if (dev->catas_err.map)
- iounmap(dev->catas_err.map);
-
- spin_lock_irq(&catas_lock);
- list_del(&dev->catas_err.list);
- spin_unlock_irq(&catas_lock);
-}
-
-int __init mthca_catas_init(void)
-{
- INIT_WORK(&catas_work, catas_reset);
-
- catas_wq = create_singlethread_workqueue("mthcacatas");
- if (!catas_wq)
- return -ENOMEM;
-
- return 0;
-}
-
-void mthca_catas_cleanup(void)
-{
- destroy_workqueue(catas_wq);
-}
diff --git a/sys/ofed/drivers/infiniband/hw/mthca/mthca_cmd.c b/sys/ofed/drivers/infiniband/hw/mthca/mthca_cmd.c
deleted file mode 100644
index 5c7b9ff..0000000
--- a/sys/ofed/drivers/infiniband/hw/mthca/mthca_cmd.c
+++ /dev/null
@@ -1,1940 +0,0 @@
-/*
- * Copyright (c) 2004, 2005 Topspin Communications. All rights reserved.
- * Copyright (c) 2005 Mellanox Technologies. All rights reserved.
- * Copyright (c) 2005, 2006 Cisco Systems. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-#define LINUXKPI_PARAM_PREFIX mthca_
-
-#include <linux/completion.h>
-#include <linux/pci.h>
-#include <linux/errno.h>
-#include <linux/sched.h>
-#include <asm/io.h>
-#include <rdma/ib_mad.h>
-
-#include "mthca_dev.h"
-#include "mthca_config_reg.h"
-#include "mthca_cmd.h"
-#include "mthca_memfree.h"
-
-#define CMD_POLL_TOKEN 0xffff
-
-enum {
- HCR_IN_PARAM_OFFSET = 0x00,
- HCR_IN_MODIFIER_OFFSET = 0x08,
- HCR_OUT_PARAM_OFFSET = 0x0c,
- HCR_TOKEN_OFFSET = 0x14,
- HCR_STATUS_OFFSET = 0x18,
-
- HCR_OPMOD_SHIFT = 12,
- HCA_E_BIT = 22,
- HCR_GO_BIT = 23
-};
-
-enum {
- /* initialization and general commands */
- CMD_SYS_EN = 0x1,
- CMD_SYS_DIS = 0x2,
- CMD_MAP_FA = 0xfff,
- CMD_UNMAP_FA = 0xffe,
- CMD_RUN_FW = 0xff6,
- CMD_MOD_STAT_CFG = 0x34,
- CMD_QUERY_DEV_LIM = 0x3,
- CMD_QUERY_FW = 0x4,
- CMD_ENABLE_LAM = 0xff8,
- CMD_DISABLE_LAM = 0xff7,
- CMD_QUERY_DDR = 0x5,
- CMD_QUERY_ADAPTER = 0x6,
- CMD_INIT_HCA = 0x7,
- CMD_CLOSE_HCA = 0x8,
- CMD_INIT_IB = 0x9,
- CMD_CLOSE_IB = 0xa,
- CMD_QUERY_HCA = 0xb,
- CMD_SET_IB = 0xc,
- CMD_ACCESS_DDR = 0x2e,
- CMD_MAP_ICM = 0xffa,
- CMD_UNMAP_ICM = 0xff9,
- CMD_MAP_ICM_AUX = 0xffc,
- CMD_UNMAP_ICM_AUX = 0xffb,
- CMD_SET_ICM_SIZE = 0xffd,
-
- /* TPT commands */
- CMD_SW2HW_MPT = 0xd,
- CMD_QUERY_MPT = 0xe,
- CMD_HW2SW_MPT = 0xf,
- CMD_READ_MTT = 0x10,
- CMD_WRITE_MTT = 0x11,
- CMD_SYNC_TPT = 0x2f,
-
- /* EQ commands */
- CMD_MAP_EQ = 0x12,
- CMD_SW2HW_EQ = 0x13,
- CMD_HW2SW_EQ = 0x14,
- CMD_QUERY_EQ = 0x15,
-
- /* CQ commands */
- CMD_SW2HW_CQ = 0x16,
- CMD_HW2SW_CQ = 0x17,
- CMD_QUERY_CQ = 0x18,
- CMD_RESIZE_CQ = 0x2c,
-
- /* SRQ commands */
- CMD_SW2HW_SRQ = 0x35,
- CMD_HW2SW_SRQ = 0x36,
- CMD_QUERY_SRQ = 0x37,
- CMD_ARM_SRQ = 0x40,
-
- /* QP/EE commands */
- CMD_RST2INIT_QPEE = 0x19,
- CMD_INIT2RTR_QPEE = 0x1a,
- CMD_RTR2RTS_QPEE = 0x1b,
- CMD_RTS2RTS_QPEE = 0x1c,
- CMD_SQERR2RTS_QPEE = 0x1d,
- CMD_2ERR_QPEE = 0x1e,
- CMD_RTS2SQD_QPEE = 0x1f,
- CMD_SQD2SQD_QPEE = 0x38,
- CMD_SQD2RTS_QPEE = 0x20,
- CMD_ERR2RST_QPEE = 0x21,
- CMD_QUERY_QPEE = 0x22,
- CMD_INIT2INIT_QPEE = 0x2d,
- CMD_SUSPEND_QPEE = 0x32,
- CMD_UNSUSPEND_QPEE = 0x33,
- /* special QPs and management commands */
- CMD_CONF_SPECIAL_QP = 0x23,
- CMD_MAD_IFC = 0x24,
-
- /* multicast commands */
- CMD_READ_MGM = 0x25,
- CMD_WRITE_MGM = 0x26,
- CMD_MGID_HASH = 0x27,
-
- /* miscellaneous commands */
- CMD_DIAG_RPRT = 0x30,
- CMD_NOP = 0x31,
-
- /* debug commands */
- CMD_QUERY_DEBUG_MSG = 0x2a,
- CMD_SET_DEBUG_MSG = 0x2b,
-};
-
-/*
- * According to Mellanox code, FW may be starved and never complete
- * commands. So we can't use strict timeouts described in PRM -- we
- * just arbitrarily select 60 seconds for now.
- */
-#if 0
-/*
- * Round up and add 1 to make sure we get the full wait time (since we
- * will be starting in the middle of a jiffy)
- */
-enum {
- CMD_TIME_CLASS_A = (HZ + 999) / 1000 + 1,
- CMD_TIME_CLASS_B = (HZ + 99) / 100 + 1,
- CMD_TIME_CLASS_C = (HZ + 9) / 10 + 1,
- CMD_TIME_CLASS_D = 60 * HZ
-};
-#else
-#define CMD_TIME_CLASS_A (60 * HZ)
-#define CMD_TIME_CLASS_B (60 * HZ)
-#define CMD_TIME_CLASS_C (60 * HZ)
-#define CMD_TIME_CLASS_D (60 * HZ)
-#endif
-
-#define GO_BIT_TIMEOUT (HZ * 10)
-
-struct mthca_cmd_context {
- struct completion done;
- int result;
- int next;
- u64 out_param;
- u16 token;
- u8 status;
-};
-
-static int fw_cmd_doorbell = 0;
-module_param(fw_cmd_doorbell, int, 0644);
-MODULE_PARM_DESC(fw_cmd_doorbell, "post FW commands through doorbell page if nonzero "
- "(and supported by FW)");
-
-static inline int go_bit(struct mthca_dev *dev)
-{
- return readl(dev->hcr + HCR_STATUS_OFFSET) &
- swab32(1 << HCR_GO_BIT);
-}
-
-static void mthca_cmd_post_dbell(struct mthca_dev *dev,
- u64 in_param,
- u64 out_param,
- u32 in_modifier,
- u8 op_modifier,
- u16 op,
- u16 token)
-{
- void __iomem *ptr = dev->cmd.dbell_map;
- u16 *offs = dev->cmd.dbell_offsets;
-
- __raw_writel((__force u32) cpu_to_be32(in_param >> 32), ptr + offs[0]);
- wmb();
- __raw_writel((__force u32) cpu_to_be32(in_param & 0xfffffffful), ptr + offs[1]);
- wmb();
- __raw_writel((__force u32) cpu_to_be32(in_modifier), ptr + offs[2]);
- wmb();
- __raw_writel((__force u32) cpu_to_be32(out_param >> 32), ptr + offs[3]);
- wmb();
- __raw_writel((__force u32) cpu_to_be32(out_param & 0xfffffffful), ptr + offs[4]);
- wmb();
- __raw_writel((__force u32) cpu_to_be32(token << 16), ptr + offs[5]);
- wmb();
- __raw_writel((__force u32) cpu_to_be32((1 << HCR_GO_BIT) |
- (1 << HCA_E_BIT) |
- (op_modifier << HCR_OPMOD_SHIFT) |
- op), ptr + offs[6]);
- wmb();
- __raw_writel((__force u32) 0, ptr + offs[7]);
- wmb();
-}
-
-static int mthca_cmd_post_hcr(struct mthca_dev *dev,
- u64 in_param,
- u64 out_param,
- u32 in_modifier,
- u8 op_modifier,
- u16 op,
- u16 token,
- int event)
-{
- if (event) {
- unsigned long end = jiffies + GO_BIT_TIMEOUT;
-
- while (go_bit(dev) && time_before(jiffies, end))
- sched_yield();
- }
-
- if (go_bit(dev))
- return -EAGAIN;
-
- /*
- * We use writel (instead of something like memcpy_toio)
- * because writes of less than 32 bits to the HCR don't work
- * (and some architectures such as ia64 implement memcpy_toio
- * in terms of writeb).
- */
- __raw_writel((__force u32) cpu_to_be32(in_param >> 32), dev->hcr + 0 * 4);
- __raw_writel((__force u32) cpu_to_be32(in_param & 0xfffffffful), dev->hcr + 1 * 4);
- __raw_writel((__force u32) cpu_to_be32(in_modifier), dev->hcr + 2 * 4);
- __raw_writel((__force u32) cpu_to_be32(out_param >> 32), dev->hcr + 3 * 4);
- __raw_writel((__force u32) cpu_to_be32(out_param & 0xfffffffful), dev->hcr + 4 * 4);
- __raw_writel((__force u32) cpu_to_be32(token << 16), dev->hcr + 5 * 4);
-
- /* __raw_writel may not order writes. */
- wmb();
-
- __raw_writel((__force u32) cpu_to_be32((1 << HCR_GO_BIT) |
- (event ? (1 << HCA_E_BIT) : 0) |
- (op_modifier << HCR_OPMOD_SHIFT) |
- op), dev->hcr + 6 * 4);
-
- return 0;
-}
-
-static int mthca_cmd_post(struct mthca_dev *dev,
- u64 in_param,
- u64 out_param,
- u32 in_modifier,
- u8 op_modifier,
- u16 op,
- u16 token,
- int event)
-{
- int err = 0;
-
- mutex_lock(&dev->cmd.hcr_mutex);
-
- if (event && dev->cmd.flags & MTHCA_CMD_POST_DOORBELLS && fw_cmd_doorbell)
- mthca_cmd_post_dbell(dev, in_param, out_param, in_modifier,
- op_modifier, op, token);
- else
- err = mthca_cmd_post_hcr(dev, in_param, out_param, in_modifier,
- op_modifier, op, token, event);
-
- /*
- * Make sure that our HCR writes don't get mixed in with
- * writes from another CPU starting a FW command.
- */
- mmiowb();
-
- mutex_unlock(&dev->cmd.hcr_mutex);
- return err;
-}
-
-static int mthca_cmd_poll(struct mthca_dev *dev,
- u64 in_param,
- u64 *out_param,
- int out_is_imm,
- u32 in_modifier,
- u8 op_modifier,
- u16 op,
- unsigned long timeout,
- u8 *status)
-{
- int err = 0;
- unsigned long end;
-
- down(&dev->cmd.poll_sem);
-
- err = mthca_cmd_post(dev, in_param,
- out_param ? *out_param : 0,
- in_modifier, op_modifier,
- op, CMD_POLL_TOKEN, 0);
- if (err)
- goto out;
-
- end = timeout + jiffies;
- while (go_bit(dev) && time_before(jiffies, end))
- sched_yield();
-
- if (go_bit(dev)) {
- err = -EBUSY;
- goto out;
- }
-
- if (out_is_imm)
- *out_param =
- (u64) be32_to_cpu((__force __be32)
- __raw_readl(dev->hcr + HCR_OUT_PARAM_OFFSET)) << 32 |
- (u64) be32_to_cpu((__force __be32)
- __raw_readl(dev->hcr + HCR_OUT_PARAM_OFFSET + 4));
-
- *status = be32_to_cpu((__force __be32) __raw_readl(dev->hcr + HCR_STATUS_OFFSET)) >> 24;
-
-out:
- up(&dev->cmd.poll_sem);
- return err;
-}
-
-void mthca_cmd_event(struct mthca_dev *dev,
- u16 token,
- u8 status,
- u64 out_param)
-{
- struct mthca_cmd_context *context =
- &dev->cmd.context[token & dev->cmd.token_mask];
-
- /* previously timed out command completing at long last */
- if (token != context->token)
- return;
-
- context->result = 0;
- context->status = status;
- context->out_param = out_param;
-
- complete(&context->done);
-}
-
-static int mthca_cmd_wait(struct mthca_dev *dev,
- u64 in_param,
- u64 *out_param,
- int out_is_imm,
- u32 in_modifier,
- u8 op_modifier,
- u16 op,
- unsigned long timeout,
- u8 *status)
-{
- int err = 0;
- struct mthca_cmd_context *context;
-
- down(&dev->cmd.event_sem);
-
- spin_lock(&dev->cmd.context_lock);
- BUG_ON(dev->cmd.free_head < 0);
- context = &dev->cmd.context[dev->cmd.free_head];
- context->token += dev->cmd.token_mask + 1;
- dev->cmd.free_head = context->next;
- spin_unlock(&dev->cmd.context_lock);
-
- init_completion(&context->done);
-
- err = mthca_cmd_post(dev, in_param,
- out_param ? *out_param : 0,
- in_modifier, op_modifier,
- op, context->token, 1);
- if (err)
- goto out;
-
- if (!wait_for_completion_timeout(&context->done, timeout)) {
- err = -EBUSY;
- goto out;
- }
-
- err = context->result;
- if (err)
- goto out;
-
- *status = context->status;
- if (*status)
- mthca_dbg(dev, "Command %02x completed with status %02x\n",
- op, *status);
-
- if (out_is_imm)
- *out_param = context->out_param;
-
-out:
- spin_lock(&dev->cmd.context_lock);
- context->next = dev->cmd.free_head;
- dev->cmd.free_head = context - dev->cmd.context;
- spin_unlock(&dev->cmd.context_lock);
-
- up(&dev->cmd.event_sem);
- return err;
-}
-
-/* Invoke a command with an output mailbox */
-static int mthca_cmd_box(struct mthca_dev *dev,
- u64 in_param,
- u64 out_param,
- u32 in_modifier,
- u8 op_modifier,
- u16 op,
- unsigned long timeout,
- u8 *status)
-{
- if (dev->cmd.flags & MTHCA_CMD_USE_EVENTS)
- return mthca_cmd_wait(dev, in_param, &out_param, 0,
- in_modifier, op_modifier, op,
- timeout, status);
- else
- return mthca_cmd_poll(dev, in_param, &out_param, 0,
- in_modifier, op_modifier, op,
- timeout, status);
-}
-
-/* Invoke a command with no output parameter */
-static int mthca_cmd(struct mthca_dev *dev,
- u64 in_param,
- u32 in_modifier,
- u8 op_modifier,
- u16 op,
- unsigned long timeout,
- u8 *status)
-{
- return mthca_cmd_box(dev, in_param, 0, in_modifier,
- op_modifier, op, timeout, status);
-}
-
-/*
- * Invoke a command with an immediate output parameter (and copy the
- * output into the caller's out_param pointer after the command
- * executes).
- */
-static int mthca_cmd_imm(struct mthca_dev *dev,
- u64 in_param,
- u64 *out_param,
- u32 in_modifier,
- u8 op_modifier,
- u16 op,
- unsigned long timeout,
- u8 *status)
-{
- if (dev->cmd.flags & MTHCA_CMD_USE_EVENTS)
- return mthca_cmd_wait(dev, in_param, out_param, 1,
- in_modifier, op_modifier, op,
- timeout, status);
- else
- return mthca_cmd_poll(dev, in_param, out_param, 1,
- in_modifier, op_modifier, op,
- timeout, status);
-}
-
-int mthca_cmd_init(struct mthca_dev *dev)
-{
- mutex_init(&dev->cmd.hcr_mutex);
- sema_init(&dev->cmd.poll_sem, 1);
- dev->cmd.flags = 0;
-
- dev->hcr = ioremap(pci_resource_start(dev->pdev, 0) + MTHCA_HCR_BASE,
- MTHCA_HCR_SIZE);
- if (!dev->hcr) {
- mthca_err(dev, "Couldn't map command register.");
- return -ENOMEM;
- }
-
- dev->cmd.pool = pci_pool_create("mthca_cmd", dev->pdev,
- MTHCA_MAILBOX_SIZE,
- MTHCA_MAILBOX_SIZE, 0);
- if (!dev->cmd.pool) {
- iounmap(dev->hcr);
- return -ENOMEM;
- }
-
- return 0;
-}
-
-void mthca_cmd_cleanup(struct mthca_dev *dev)
-{
- pci_pool_destroy(dev->cmd.pool);
- iounmap(dev->hcr);
- if (dev->cmd.flags & MTHCA_CMD_POST_DOORBELLS)
- iounmap(dev->cmd.dbell_map);
-}
-
-/*
- * Switch to using events to issue FW commands (should be called after
- * event queue to command events has been initialized).
- */
-int mthca_cmd_use_events(struct mthca_dev *dev)
-{
- int i;
-
- dev->cmd.context = kmalloc(dev->cmd.max_cmds *
- sizeof (struct mthca_cmd_context),
- GFP_KERNEL);
- if (!dev->cmd.context)
- return -ENOMEM;
-
- for (i = 0; i < dev->cmd.max_cmds; ++i) {
- dev->cmd.context[i].token = i;
- dev->cmd.context[i].next = i + 1;
- }
-
- dev->cmd.context[dev->cmd.max_cmds - 1].next = -1;
- dev->cmd.free_head = 0;
-
- sema_init(&dev->cmd.event_sem, dev->cmd.max_cmds);
- spin_lock_init(&dev->cmd.context_lock);
-
- for (dev->cmd.token_mask = 1;
- dev->cmd.token_mask < dev->cmd.max_cmds;
- dev->cmd.token_mask <<= 1)
- ; /* nothing */
- --dev->cmd.token_mask;
-
- dev->cmd.flags |= MTHCA_CMD_USE_EVENTS;
-
- down(&dev->cmd.poll_sem);
-
- return 0;
-}
-
-/*
- * Switch back to polling (used when shutting down the device)
- */
-void mthca_cmd_use_polling(struct mthca_dev *dev)
-{
- int i;
-
- dev->cmd.flags &= ~MTHCA_CMD_USE_EVENTS;
-
- for (i = 0; i < dev->cmd.max_cmds; ++i)
- down(&dev->cmd.event_sem);
-
- kfree(dev->cmd.context);
-
- up(&dev->cmd.poll_sem);
-}
-
-struct mthca_mailbox *mthca_alloc_mailbox(struct mthca_dev *dev,
- gfp_t gfp_mask)
-{
- struct mthca_mailbox *mailbox;
-
- mailbox = kmalloc(sizeof *mailbox, gfp_mask);
- if (!mailbox)
- return ERR_PTR(-ENOMEM);
-
- mailbox->buf = pci_pool_alloc(dev->cmd.pool, gfp_mask, &mailbox->dma);
- if (!mailbox->buf) {
- kfree(mailbox);
- return ERR_PTR(-ENOMEM);
- }
-
- return mailbox;
-}
-
-void mthca_free_mailbox(struct mthca_dev *dev, struct mthca_mailbox *mailbox)
-{
- if (!mailbox)
- return;
-
- pci_pool_free(dev->cmd.pool, mailbox->buf, mailbox->dma);
- kfree(mailbox);
-}
-
-int mthca_SYS_EN(struct mthca_dev *dev, u8 *status)
-{
- u64 out;
- int ret;
-
- ret = mthca_cmd_imm(dev, 0, &out, 0, 0, CMD_SYS_EN, CMD_TIME_CLASS_D, status);
-
- if (*status == MTHCA_CMD_STAT_DDR_MEM_ERR)
- mthca_warn(dev, "SYS_EN DDR error: syn=%x, sock=%d, "
- "sladdr=%d, SPD source=%s\n",
- (int) (out >> 6) & 0xf, (int) (out >> 4) & 3,
- (int) (out >> 1) & 7, (int) out & 1 ? "NVMEM" : "DIMM");
-
- return ret;
-}
-
-int mthca_SYS_DIS(struct mthca_dev *dev, u8 *status)
-{
- return mthca_cmd(dev, 0, 0, 0, CMD_SYS_DIS, CMD_TIME_CLASS_C, status);
-}
-
-static int mthca_map_cmd(struct mthca_dev *dev, u16 op, struct mthca_icm *icm,
- u64 virt, u8 *status)
-{
- struct mthca_mailbox *mailbox;
- struct mthca_icm_iter iter;
- __be64 *pages;
- int lg;
- int nent = 0;
- int i;
- int err = 0;
- int ts = 0, tc = 0;
-
- mailbox = mthca_alloc_mailbox(dev, GFP_KERNEL);
- if (IS_ERR(mailbox))
- return PTR_ERR(mailbox);
- memset(mailbox->buf, 0, MTHCA_MAILBOX_SIZE);
- pages = mailbox->buf;
-
- for (mthca_icm_first(icm, &iter);
- !mthca_icm_last(&iter);
- mthca_icm_next(&iter)) {
- /*
- * We have to pass pages that are aligned to their
- * size, so find the least significant 1 in the
- * address or size and use that as our log2 size.
- */
- lg = ffs(mthca_icm_addr(&iter) | mthca_icm_size(&iter)) - 1;
- if (lg < MTHCA_ICM_PAGE_SHIFT) {
- mthca_warn(dev, "Got FW area not aligned to %d (%llx/%lx).\n",
- MTHCA_ICM_PAGE_SIZE,
- (unsigned long long) mthca_icm_addr(&iter),
- mthca_icm_size(&iter));
- err = -EINVAL;
- goto out;
- }
- for (i = 0; i < mthca_icm_size(&iter) >> lg; ++i) {
- if (virt != -1) {
- pages[nent * 2] = cpu_to_be64(virt);
- virt += 1 << lg;
- }
-
- pages[nent * 2 + 1] =
- cpu_to_be64((mthca_icm_addr(&iter) + (i << lg)) |
- (lg - MTHCA_ICM_PAGE_SHIFT));
- ts += 1 << (lg - 10);
- ++tc;
-
- if (++nent == MTHCA_MAILBOX_SIZE / 16) {
- err = mthca_cmd(dev, mailbox->dma, nent, 0, op,
- CMD_TIME_CLASS_B, status);
- if (err || *status)
- goto out;
- nent = 0;
- }
- }
- }
-
- if (nent)
- err = mthca_cmd(dev, mailbox->dma, nent, 0, op,
- CMD_TIME_CLASS_B, status);
-
- switch (op) {
- case CMD_MAP_FA:
- mthca_dbg(dev, "Mapped %d chunks/%d KB for FW.\n", tc, ts);
- break;
- case CMD_MAP_ICM_AUX:
- mthca_dbg(dev, "Mapped %d chunks/%d KB for ICM aux.\n", tc, ts);
- break;
- case CMD_MAP_ICM:
- mthca_dbg(dev, "Mapped %d chunks/%d KB at %llx for ICM.\n",
- tc, ts, (unsigned long long) virt - (ts << 10));
- break;
- }
-
-out:
- mthca_free_mailbox(dev, mailbox);
- return err;
-}
-
-int mthca_MAP_FA(struct mthca_dev *dev, struct mthca_icm *icm, u8 *status)
-{
- return mthca_map_cmd(dev, CMD_MAP_FA, icm, -1, status);
-}
-
-int mthca_UNMAP_FA(struct mthca_dev *dev, u8 *status)
-{
- return mthca_cmd(dev, 0, 0, 0, CMD_UNMAP_FA, CMD_TIME_CLASS_B, status);
-}
-
-int mthca_RUN_FW(struct mthca_dev *dev, u8 *status)
-{
- return mthca_cmd(dev, 0, 0, 0, CMD_RUN_FW, CMD_TIME_CLASS_A, status);
-}
-
-static void mthca_setup_cmd_doorbells(struct mthca_dev *dev, u64 base)
-{
- unsigned long addr;
- u16 max_off = 0;
- int i;
-
- for (i = 0; i < 8; ++i)
- max_off = max(max_off, dev->cmd.dbell_offsets[i]);
-
- if ((base & PAGE_MASK) != ((base + max_off) & PAGE_MASK)) {
- mthca_warn(dev, "Firmware doorbell region at 0x%016llx, "
- "length 0x%x crosses a page boundary\n",
- (unsigned long long) base, max_off);
- return;
- }
-
- addr = pci_resource_start(dev->pdev, 2) +
- ((pci_resource_len(dev->pdev, 2) - 1) & base);
- dev->cmd.dbell_map = ioremap(addr, max_off + sizeof(u32));
- if (!dev->cmd.dbell_map)
- return;
-
- dev->cmd.flags |= MTHCA_CMD_POST_DOORBELLS;
- mthca_dbg(dev, "Mapped doorbell page for posting FW commands\n");
-}
-
-int mthca_QUERY_FW(struct mthca_dev *dev, u8 *status)
-{
- struct mthca_mailbox *mailbox;
- u32 *outbox;
- u64 base;
- u32 tmp;
- int err = 0;
- u8 lg;
- int i;
-
-#define QUERY_FW_OUT_SIZE 0x100
-#define QUERY_FW_VER_OFFSET 0x00
-#define QUERY_FW_MAX_CMD_OFFSET 0x0f
-#define QUERY_FW_ERR_START_OFFSET 0x30
-#define QUERY_FW_ERR_SIZE_OFFSET 0x38
-
-#define QUERY_FW_CMD_DB_EN_OFFSET 0x10
-#define QUERY_FW_CMD_DB_OFFSET 0x50
-#define QUERY_FW_CMD_DB_BASE 0x60
-
-#define QUERY_FW_START_OFFSET 0x20
-#define QUERY_FW_END_OFFSET 0x28
-
-#define QUERY_FW_SIZE_OFFSET 0x00
-#define QUERY_FW_CLR_INT_BASE_OFFSET 0x20
-#define QUERY_FW_EQ_ARM_BASE_OFFSET 0x40
-#define QUERY_FW_EQ_SET_CI_BASE_OFFSET 0x48
-
- mailbox = mthca_alloc_mailbox(dev, GFP_KERNEL);
- if (IS_ERR(mailbox))
- return PTR_ERR(mailbox);
- outbox = mailbox->buf;
-
- err = mthca_cmd_box(dev, 0, mailbox->dma, 0, 0, CMD_QUERY_FW,
- CMD_TIME_CLASS_A, status);
-
- if (err)
- goto out;
-
- MTHCA_GET(dev->fw_ver, outbox, QUERY_FW_VER_OFFSET);
- /*
- * FW subminor version is at more significant bits than minor
- * version, so swap here.
- */
- dev->fw_ver = (dev->fw_ver & 0xffff00000000ull) |
- ((dev->fw_ver & 0xffff0000ull) >> 16) |
- ((dev->fw_ver & 0x0000ffffull) << 16);
-
- MTHCA_GET(lg, outbox, QUERY_FW_MAX_CMD_OFFSET);
- dev->cmd.max_cmds = 1 << lg;
-
- mthca_dbg(dev, "FW version %012llx, max commands %d\n",
- (unsigned long long) dev->fw_ver, dev->cmd.max_cmds);
-
- MTHCA_GET(dev->catas_err.addr, outbox, QUERY_FW_ERR_START_OFFSET);
- MTHCA_GET(dev->catas_err.size, outbox, QUERY_FW_ERR_SIZE_OFFSET);
-
- mthca_dbg(dev, "Catastrophic error buffer at 0x%llx, size 0x%x\n",
- (unsigned long long) dev->catas_err.addr, dev->catas_err.size);
-
- MTHCA_GET(tmp, outbox, QUERY_FW_CMD_DB_EN_OFFSET);
- if (tmp & 0x1) {
- mthca_dbg(dev, "FW supports commands through doorbells\n");
-
- MTHCA_GET(base, outbox, QUERY_FW_CMD_DB_BASE);
- for (i = 0; i < MTHCA_CMD_NUM_DBELL_DWORDS; ++i)
- MTHCA_GET(dev->cmd.dbell_offsets[i], outbox,
- QUERY_FW_CMD_DB_OFFSET + (i << 1));
-
- mthca_setup_cmd_doorbells(dev, base);
- }
-
- if (mthca_is_memfree(dev)) {
- MTHCA_GET(dev->fw.arbel.fw_pages, outbox, QUERY_FW_SIZE_OFFSET);
- MTHCA_GET(dev->fw.arbel.clr_int_base, outbox, QUERY_FW_CLR_INT_BASE_OFFSET);
- MTHCA_GET(dev->fw.arbel.eq_arm_base, outbox, QUERY_FW_EQ_ARM_BASE_OFFSET);
- MTHCA_GET(dev->fw.arbel.eq_set_ci_base, outbox, QUERY_FW_EQ_SET_CI_BASE_OFFSET);
- mthca_dbg(dev, "FW size %d KB\n", dev->fw.arbel.fw_pages << 2);
-
- /*
- * Round up number of system pages needed in case
- * MTHCA_ICM_PAGE_SIZE < PAGE_SIZE.
- */
- dev->fw.arbel.fw_pages =
- ALIGN(dev->fw.arbel.fw_pages, PAGE_SIZE / MTHCA_ICM_PAGE_SIZE) >>
- (PAGE_SHIFT - MTHCA_ICM_PAGE_SHIFT);
-
- mthca_dbg(dev, "Clear int @ %llx, EQ arm @ %llx, EQ set CI @ %llx\n",
- (unsigned long long) dev->fw.arbel.clr_int_base,
- (unsigned long long) dev->fw.arbel.eq_arm_base,
- (unsigned long long) dev->fw.arbel.eq_set_ci_base);
- } else {
- MTHCA_GET(dev->fw.tavor.fw_start, outbox, QUERY_FW_START_OFFSET);
- MTHCA_GET(dev->fw.tavor.fw_end, outbox, QUERY_FW_END_OFFSET);
-
- mthca_dbg(dev, "FW size %d KB (start %llx, end %llx)\n",
- (int) ((dev->fw.tavor.fw_end - dev->fw.tavor.fw_start) >> 10),
- (unsigned long long) dev->fw.tavor.fw_start,
- (unsigned long long) dev->fw.tavor.fw_end);
- }
-
-out:
- mthca_free_mailbox(dev, mailbox);
- return err;
-}
-
-int mthca_ENABLE_LAM(struct mthca_dev *dev, u8 *status)
-{
- struct mthca_mailbox *mailbox;
- u8 info;
- u32 *outbox;
- int err = 0;
-
-#define ENABLE_LAM_OUT_SIZE 0x100
-#define ENABLE_LAM_START_OFFSET 0x00
-#define ENABLE_LAM_END_OFFSET 0x08
-#define ENABLE_LAM_INFO_OFFSET 0x13
-
-#define ENABLE_LAM_INFO_HIDDEN_FLAG (1 << 4)
-#define ENABLE_LAM_INFO_ECC_MASK 0x3
-
- mailbox = mthca_alloc_mailbox(dev, GFP_KERNEL);
- if (IS_ERR(mailbox))
- return PTR_ERR(mailbox);
- outbox = mailbox->buf;
-
- err = mthca_cmd_box(dev, 0, mailbox->dma, 0, 0, CMD_ENABLE_LAM,
- CMD_TIME_CLASS_C, status);
-
- if (err)
- goto out;
-
- if (*status == MTHCA_CMD_STAT_LAM_NOT_PRE)
- goto out;
-
- MTHCA_GET(dev->ddr_start, outbox, ENABLE_LAM_START_OFFSET);
- MTHCA_GET(dev->ddr_end, outbox, ENABLE_LAM_END_OFFSET);
- MTHCA_GET(info, outbox, ENABLE_LAM_INFO_OFFSET);
-
- if (!!(info & ENABLE_LAM_INFO_HIDDEN_FLAG) !=
- !!(dev->mthca_flags & MTHCA_FLAG_DDR_HIDDEN)) {
- mthca_info(dev, "FW reports that HCA-attached memory "
- "is %s hidden; does not match PCI config\n",
- (info & ENABLE_LAM_INFO_HIDDEN_FLAG) ?
- "" : "not");
- }
- if (info & ENABLE_LAM_INFO_HIDDEN_FLAG)
- mthca_dbg(dev, "HCA-attached memory is hidden.\n");
-
- mthca_dbg(dev, "HCA memory size %d KB (start %llx, end %llx)\n",
- (int) ((dev->ddr_end - dev->ddr_start) >> 10),
- (unsigned long long) dev->ddr_start,
- (unsigned long long) dev->ddr_end);
-
-out:
- mthca_free_mailbox(dev, mailbox);
- return err;
-}
-
-int mthca_DISABLE_LAM(struct mthca_dev *dev, u8 *status)
-{
- return mthca_cmd(dev, 0, 0, 0, CMD_SYS_DIS, CMD_TIME_CLASS_C, status);
-}
-
-int mthca_QUERY_DDR(struct mthca_dev *dev, u8 *status)
-{
- struct mthca_mailbox *mailbox;
- u8 info;
- u32 *outbox;
- int err = 0;
-
-#define QUERY_DDR_OUT_SIZE 0x100
-#define QUERY_DDR_START_OFFSET 0x00
-#define QUERY_DDR_END_OFFSET 0x08
-#define QUERY_DDR_INFO_OFFSET 0x13
-
-#define QUERY_DDR_INFO_HIDDEN_FLAG (1 << 4)
-#define QUERY_DDR_INFO_ECC_MASK 0x3
-
- mailbox = mthca_alloc_mailbox(dev, GFP_KERNEL);
- if (IS_ERR(mailbox))
- return PTR_ERR(mailbox);
- outbox = mailbox->buf;
-
- err = mthca_cmd_box(dev, 0, mailbox->dma, 0, 0, CMD_QUERY_DDR,
- CMD_TIME_CLASS_A, status);
-
- if (err)
- goto out;
-
- MTHCA_GET(dev->ddr_start, outbox, QUERY_DDR_START_OFFSET);
- MTHCA_GET(dev->ddr_end, outbox, QUERY_DDR_END_OFFSET);
- MTHCA_GET(info, outbox, QUERY_DDR_INFO_OFFSET);
-
- if (!!(info & QUERY_DDR_INFO_HIDDEN_FLAG) !=
- !!(dev->mthca_flags & MTHCA_FLAG_DDR_HIDDEN)) {
- mthca_info(dev, "FW reports that HCA-attached memory "
- "is %s hidden; does not match PCI config\n",
- (info & QUERY_DDR_INFO_HIDDEN_FLAG) ?
- "" : "not");
- }
- if (info & QUERY_DDR_INFO_HIDDEN_FLAG)
- mthca_dbg(dev, "HCA-attached memory is hidden.\n");
-
- mthca_dbg(dev, "HCA memory size %d KB (start %llx, end %llx)\n",
- (int) ((dev->ddr_end - dev->ddr_start) >> 10),
- (unsigned long long) dev->ddr_start,
- (unsigned long long) dev->ddr_end);
-
-out:
- mthca_free_mailbox(dev, mailbox);
- return err;
-}
-
-int mthca_QUERY_DEV_LIM(struct mthca_dev *dev,
- struct mthca_dev_lim *dev_lim, u8 *status)
-{
- struct mthca_mailbox *mailbox;
- u32 *outbox;
- u8 field;
- u16 size;
- u16 stat_rate;
- int err;
-
-#define QUERY_DEV_LIM_OUT_SIZE 0x100
-#define QUERY_DEV_LIM_MAX_SRQ_SZ_OFFSET 0x10
-#define QUERY_DEV_LIM_MAX_QP_SZ_OFFSET 0x11
-#define QUERY_DEV_LIM_RSVD_QP_OFFSET 0x12
-#define QUERY_DEV_LIM_MAX_QP_OFFSET 0x13
-#define QUERY_DEV_LIM_RSVD_SRQ_OFFSET 0x14
-#define QUERY_DEV_LIM_MAX_SRQ_OFFSET 0x15
-#define QUERY_DEV_LIM_RSVD_EEC_OFFSET 0x16
-#define QUERY_DEV_LIM_MAX_EEC_OFFSET 0x17
-#define QUERY_DEV_LIM_MAX_CQ_SZ_OFFSET 0x19
-#define QUERY_DEV_LIM_RSVD_CQ_OFFSET 0x1a
-#define QUERY_DEV_LIM_MAX_CQ_OFFSET 0x1b
-#define QUERY_DEV_LIM_MAX_MPT_OFFSET 0x1d
-#define QUERY_DEV_LIM_RSVD_EQ_OFFSET 0x1e
-#define QUERY_DEV_LIM_MAX_EQ_OFFSET 0x1f
-#define QUERY_DEV_LIM_RSVD_MTT_OFFSET 0x20
-#define QUERY_DEV_LIM_MAX_MRW_SZ_OFFSET 0x21
-#define QUERY_DEV_LIM_RSVD_MRW_OFFSET 0x22
-#define QUERY_DEV_LIM_MAX_MTT_SEG_OFFSET 0x23
-#define QUERY_DEV_LIM_MAX_AV_OFFSET 0x27
-#define QUERY_DEV_LIM_MAX_REQ_QP_OFFSET 0x29
-#define QUERY_DEV_LIM_MAX_RES_QP_OFFSET 0x2b
-#define QUERY_DEV_LIM_MAX_RDMA_OFFSET 0x2f
-#define QUERY_DEV_LIM_RSZ_SRQ_OFFSET 0x33
-#define QUERY_DEV_LIM_ACK_DELAY_OFFSET 0x35
-#define QUERY_DEV_LIM_MTU_WIDTH_OFFSET 0x36
-#define QUERY_DEV_LIM_VL_PORT_OFFSET 0x37
-#define QUERY_DEV_LIM_MAX_GID_OFFSET 0x3b
-#define QUERY_DEV_LIM_RATE_SUPPORT_OFFSET 0x3c
-#define QUERY_DEV_LIM_MAX_PKEY_OFFSET 0x3f
-#define QUERY_DEV_LIM_FLAGS_OFFSET 0x44
-#define QUERY_DEV_LIM_RSVD_UAR_OFFSET 0x48
-#define QUERY_DEV_LIM_UAR_SZ_OFFSET 0x49
-#define QUERY_DEV_LIM_PAGE_SZ_OFFSET 0x4b
-#define QUERY_DEV_LIM_MAX_SG_OFFSET 0x51
-#define QUERY_DEV_LIM_MAX_DESC_SZ_OFFSET 0x52
-#define QUERY_DEV_LIM_MAX_SG_RQ_OFFSET 0x55
-#define QUERY_DEV_LIM_MAX_DESC_SZ_RQ_OFFSET 0x56
-#define QUERY_DEV_LIM_MAX_QP_MCG_OFFSET 0x61
-#define QUERY_DEV_LIM_RSVD_MCG_OFFSET 0x62
-#define QUERY_DEV_LIM_MAX_MCG_OFFSET 0x63
-#define QUERY_DEV_LIM_RSVD_PD_OFFSET 0x64
-#define QUERY_DEV_LIM_MAX_PD_OFFSET 0x65
-#define QUERY_DEV_LIM_RSVD_RDD_OFFSET 0x66
-#define QUERY_DEV_LIM_MAX_RDD_OFFSET 0x67
-#define QUERY_DEV_LIM_EEC_ENTRY_SZ_OFFSET 0x80
-#define QUERY_DEV_LIM_QPC_ENTRY_SZ_OFFSET 0x82
-#define QUERY_DEV_LIM_EEEC_ENTRY_SZ_OFFSET 0x84
-#define QUERY_DEV_LIM_EQPC_ENTRY_SZ_OFFSET 0x86
-#define QUERY_DEV_LIM_EQC_ENTRY_SZ_OFFSET 0x88
-#define QUERY_DEV_LIM_CQC_ENTRY_SZ_OFFSET 0x8a
-#define QUERY_DEV_LIM_SRQ_ENTRY_SZ_OFFSET 0x8c
-#define QUERY_DEV_LIM_UAR_ENTRY_SZ_OFFSET 0x8e
-#define QUERY_DEV_LIM_MTT_ENTRY_SZ_OFFSET 0x90
-#define QUERY_DEV_LIM_MPT_ENTRY_SZ_OFFSET 0x92
-#define QUERY_DEV_LIM_PBL_SZ_OFFSET 0x96
-#define QUERY_DEV_LIM_BMME_FLAGS_OFFSET 0x97
-#define QUERY_DEV_LIM_RSVD_LKEY_OFFSET 0x98
-#define QUERY_DEV_LIM_LAMR_OFFSET 0x9f
-#define QUERY_DEV_LIM_MAX_ICM_SZ_OFFSET 0xa0
-
- mailbox = mthca_alloc_mailbox(dev, GFP_KERNEL);
- if (IS_ERR(mailbox))
- return PTR_ERR(mailbox);
- outbox = mailbox->buf;
-
- err = mthca_cmd_box(dev, 0, mailbox->dma, 0, 0, CMD_QUERY_DEV_LIM,
- CMD_TIME_CLASS_A, status);
-
- if (err)
- goto out;
-
- MTHCA_GET(field, outbox, QUERY_DEV_LIM_RSVD_QP_OFFSET);
- dev_lim->reserved_qps = 1 << (field & 0xf);
- MTHCA_GET(field, outbox, QUERY_DEV_LIM_MAX_QP_OFFSET);
- dev_lim->max_qps = 1 << (field & 0x1f);
- MTHCA_GET(field, outbox, QUERY_DEV_LIM_RSVD_SRQ_OFFSET);
- dev_lim->reserved_srqs = 1 << (field >> 4);
- MTHCA_GET(field, outbox, QUERY_DEV_LIM_MAX_SRQ_OFFSET);
- dev_lim->max_srqs = 1 << (field & 0x1f);
- MTHCA_GET(field, outbox, QUERY_DEV_LIM_RSVD_EEC_OFFSET);
- dev_lim->reserved_eecs = 1 << (field & 0xf);
- MTHCA_GET(field, outbox, QUERY_DEV_LIM_MAX_EEC_OFFSET);
- dev_lim->max_eecs = 1 << (field & 0x1f);
- MTHCA_GET(field, outbox, QUERY_DEV_LIM_MAX_CQ_SZ_OFFSET);
- dev_lim->max_cq_sz = 1 << field;
- MTHCA_GET(field, outbox, QUERY_DEV_LIM_RSVD_CQ_OFFSET);
- dev_lim->reserved_cqs = 1 << (field & 0xf);
- MTHCA_GET(field, outbox, QUERY_DEV_LIM_MAX_CQ_OFFSET);
- dev_lim->max_cqs = 1 << (field & 0x1f);
- MTHCA_GET(field, outbox, QUERY_DEV_LIM_MAX_MPT_OFFSET);
- dev_lim->max_mpts = 1 << (field & 0x3f);
- MTHCA_GET(field, outbox, QUERY_DEV_LIM_RSVD_EQ_OFFSET);
- dev_lim->reserved_eqs = 1 << (field & 0xf);
- MTHCA_GET(field, outbox, QUERY_DEV_LIM_MAX_EQ_OFFSET);
- dev_lim->max_eqs = 1 << (field & 0x7);
- MTHCA_GET(field, outbox, QUERY_DEV_LIM_RSVD_MTT_OFFSET);
- if (mthca_is_memfree(dev))
- dev_lim->reserved_mtts = ALIGN((1 << (field >> 4)) * sizeof(u64),
- dev->limits.mtt_seg_size) / dev->limits.mtt_seg_size;
- else
- dev_lim->reserved_mtts = 1 << (field >> 4);
- MTHCA_GET(field, outbox, QUERY_DEV_LIM_MAX_MRW_SZ_OFFSET);
- dev_lim->max_mrw_sz = 1 << field;
- MTHCA_GET(field, outbox, QUERY_DEV_LIM_RSVD_MRW_OFFSET);
- dev_lim->reserved_mrws = 1 << (field & 0xf);
- MTHCA_GET(field, outbox, QUERY_DEV_LIM_MAX_MTT_SEG_OFFSET);
- dev_lim->max_mtt_seg = 1 << (field & 0x3f);
- MTHCA_GET(field, outbox, QUERY_DEV_LIM_MAX_REQ_QP_OFFSET);
- dev_lim->max_requester_per_qp = 1 << (field & 0x3f);
- MTHCA_GET(field, outbox, QUERY_DEV_LIM_MAX_RES_QP_OFFSET);
- dev_lim->max_responder_per_qp = 1 << (field & 0x3f);
- MTHCA_GET(field, outbox, QUERY_DEV_LIM_MAX_RDMA_OFFSET);
- dev_lim->max_rdma_global = 1 << (field & 0x3f);
- MTHCA_GET(field, outbox, QUERY_DEV_LIM_ACK_DELAY_OFFSET);
- dev_lim->local_ca_ack_delay = field & 0x1f;
- MTHCA_GET(field, outbox, QUERY_DEV_LIM_MTU_WIDTH_OFFSET);
- dev_lim->max_mtu = field >> 4;
- dev_lim->max_port_width = field & 0xf;
- MTHCA_GET(field, outbox, QUERY_DEV_LIM_VL_PORT_OFFSET);
- dev_lim->max_vl = field >> 4;
- dev_lim->num_ports = field & 0xf;
- MTHCA_GET(field, outbox, QUERY_DEV_LIM_MAX_GID_OFFSET);
- dev_lim->max_gids = 1 << (field & 0xf);
- MTHCA_GET(stat_rate, outbox, QUERY_DEV_LIM_RATE_SUPPORT_OFFSET);
- dev_lim->stat_rate_support = stat_rate;
- MTHCA_GET(field, outbox, QUERY_DEV_LIM_MAX_PKEY_OFFSET);
- dev_lim->max_pkeys = 1 << (field & 0xf);
- MTHCA_GET(dev_lim->flags, outbox, QUERY_DEV_LIM_FLAGS_OFFSET);
- MTHCA_GET(field, outbox, QUERY_DEV_LIM_RSVD_UAR_OFFSET);
- dev_lim->reserved_uars = field >> 4;
- MTHCA_GET(field, outbox, QUERY_DEV_LIM_UAR_SZ_OFFSET);
- dev_lim->uar_size = 1 << ((field & 0x3f) + 20);
- MTHCA_GET(field, outbox, QUERY_DEV_LIM_PAGE_SZ_OFFSET);
- dev_lim->min_page_sz = 1 << field;
- MTHCA_GET(field, outbox, QUERY_DEV_LIM_MAX_SG_OFFSET);
- dev_lim->max_sg = field;
-
- MTHCA_GET(size, outbox, QUERY_DEV_LIM_MAX_DESC_SZ_OFFSET);
- dev_lim->max_desc_sz = size;
-
- MTHCA_GET(field, outbox, QUERY_DEV_LIM_MAX_QP_MCG_OFFSET);
- dev_lim->max_qp_per_mcg = 1 << field;
- MTHCA_GET(field, outbox, QUERY_DEV_LIM_RSVD_MCG_OFFSET);
- dev_lim->reserved_mgms = field & 0xf;
- MTHCA_GET(field, outbox, QUERY_DEV_LIM_MAX_MCG_OFFSET);
- dev_lim->max_mcgs = 1 << field;
- MTHCA_GET(field, outbox, QUERY_DEV_LIM_RSVD_PD_OFFSET);
- dev_lim->reserved_pds = field >> 4;
- MTHCA_GET(field, outbox, QUERY_DEV_LIM_MAX_PD_OFFSET);
- dev_lim->max_pds = 1 << (field & 0x3f);
- MTHCA_GET(field, outbox, QUERY_DEV_LIM_RSVD_RDD_OFFSET);
- dev_lim->reserved_rdds = field >> 4;
- MTHCA_GET(field, outbox, QUERY_DEV_LIM_MAX_RDD_OFFSET);
- dev_lim->max_rdds = 1 << (field & 0x3f);
-
- MTHCA_GET(size, outbox, QUERY_DEV_LIM_EEC_ENTRY_SZ_OFFSET);
- dev_lim->eec_entry_sz = size;
- MTHCA_GET(size, outbox, QUERY_DEV_LIM_QPC_ENTRY_SZ_OFFSET);
- dev_lim->qpc_entry_sz = size;
- MTHCA_GET(size, outbox, QUERY_DEV_LIM_EEEC_ENTRY_SZ_OFFSET);
- dev_lim->eeec_entry_sz = size;
- MTHCA_GET(size, outbox, QUERY_DEV_LIM_EQPC_ENTRY_SZ_OFFSET);
- dev_lim->eqpc_entry_sz = size;
- MTHCA_GET(size, outbox, QUERY_DEV_LIM_EQC_ENTRY_SZ_OFFSET);
- dev_lim->eqc_entry_sz = size;
- MTHCA_GET(size, outbox, QUERY_DEV_LIM_CQC_ENTRY_SZ_OFFSET);
- dev_lim->cqc_entry_sz = size;
- MTHCA_GET(size, outbox, QUERY_DEV_LIM_SRQ_ENTRY_SZ_OFFSET);
- dev_lim->srq_entry_sz = size;
- MTHCA_GET(size, outbox, QUERY_DEV_LIM_UAR_ENTRY_SZ_OFFSET);
- dev_lim->uar_scratch_entry_sz = size;
-
- if (mthca_is_memfree(dev)) {
- MTHCA_GET(field, outbox, QUERY_DEV_LIM_MAX_SRQ_SZ_OFFSET);
- dev_lim->max_srq_sz = 1 << field;
- MTHCA_GET(field, outbox, QUERY_DEV_LIM_MAX_QP_SZ_OFFSET);
- dev_lim->max_qp_sz = 1 << field;
- MTHCA_GET(field, outbox, QUERY_DEV_LIM_RSZ_SRQ_OFFSET);
- dev_lim->hca.arbel.resize_srq = field & 1;
- MTHCA_GET(field, outbox, QUERY_DEV_LIM_MAX_SG_RQ_OFFSET);
- dev_lim->max_sg = min_t(int, field, dev_lim->max_sg);
- MTHCA_GET(size, outbox, QUERY_DEV_LIM_MAX_DESC_SZ_RQ_OFFSET);
- dev_lim->max_desc_sz = min_t(int, size, dev_lim->max_desc_sz);
- MTHCA_GET(size, outbox, QUERY_DEV_LIM_MPT_ENTRY_SZ_OFFSET);
- dev_lim->mpt_entry_sz = size;
- MTHCA_GET(field, outbox, QUERY_DEV_LIM_PBL_SZ_OFFSET);
- dev_lim->hca.arbel.max_pbl_sz = 1 << (field & 0x3f);
- MTHCA_GET(dev_lim->hca.arbel.bmme_flags, outbox,
- QUERY_DEV_LIM_BMME_FLAGS_OFFSET);
- MTHCA_GET(dev_lim->hca.arbel.reserved_lkey, outbox,
- QUERY_DEV_LIM_RSVD_LKEY_OFFSET);
- MTHCA_GET(field, outbox, QUERY_DEV_LIM_LAMR_OFFSET);
- dev_lim->hca.arbel.lam_required = field & 1;
- MTHCA_GET(dev_lim->hca.arbel.max_icm_sz, outbox,
- QUERY_DEV_LIM_MAX_ICM_SZ_OFFSET);
-
- if (dev_lim->hca.arbel.bmme_flags & 1)
- mthca_dbg(dev, "Base MM extensions: yes "
- "(flags %d, max PBL %d, rsvd L_Key %08x)\n",
- dev_lim->hca.arbel.bmme_flags,
- dev_lim->hca.arbel.max_pbl_sz,
- dev_lim->hca.arbel.reserved_lkey);
- else
- mthca_dbg(dev, "Base MM extensions: no\n");
-
- mthca_dbg(dev, "Max ICM size %lld MB\n",
- (unsigned long long) dev_lim->hca.arbel.max_icm_sz >> 20);
- } else {
- MTHCA_GET(field, outbox, QUERY_DEV_LIM_MAX_SRQ_SZ_OFFSET);
- dev_lim->max_srq_sz = (1 << field) - 1;
- MTHCA_GET(field, outbox, QUERY_DEV_LIM_MAX_QP_SZ_OFFSET);
- dev_lim->max_qp_sz = (1 << field) - 1;
- MTHCA_GET(field, outbox, QUERY_DEV_LIM_MAX_AV_OFFSET);
- dev_lim->hca.tavor.max_avs = 1 << (field & 0x3f);
- dev_lim->mpt_entry_sz = MTHCA_MPT_ENTRY_SIZE;
- }
-
- mthca_dbg(dev, "Max QPs: %d, reserved QPs: %d, entry size: %d\n",
- dev_lim->max_qps, dev_lim->reserved_qps, dev_lim->qpc_entry_sz);
- mthca_dbg(dev, "Max SRQs: %d, reserved SRQs: %d, entry size: %d\n",
- dev_lim->max_srqs, dev_lim->reserved_srqs, dev_lim->srq_entry_sz);
- mthca_dbg(dev, "Max CQs: %d, reserved CQs: %d, entry size: %d\n",
- dev_lim->max_cqs, dev_lim->reserved_cqs, dev_lim->cqc_entry_sz);
- mthca_dbg(dev, "Max EQs: %d, reserved EQs: %d, entry size: %d\n",
- dev_lim->max_eqs, dev_lim->reserved_eqs, dev_lim->eqc_entry_sz);
- mthca_dbg(dev, "reserved MPTs: %d, reserved MTTs: %d\n",
- dev_lim->reserved_mrws, dev_lim->reserved_mtts);
- mthca_dbg(dev, "Max PDs: %d, reserved PDs: %d, reserved UARs: %d\n",
- dev_lim->max_pds, dev_lim->reserved_pds, dev_lim->reserved_uars);
- mthca_dbg(dev, "Max QP/MCG: %d, reserved MGMs: %d\n",
- dev_lim->max_pds, dev_lim->reserved_mgms);
- mthca_dbg(dev, "Max CQEs: %d, max WQEs: %d, max SRQ WQEs: %d\n",
- dev_lim->max_cq_sz, dev_lim->max_qp_sz, dev_lim->max_srq_sz);
-
- mthca_dbg(dev, "Flags: %08x\n", dev_lim->flags);
-
-out:
- mthca_free_mailbox(dev, mailbox);
- return err;
-}
-
-static void get_board_id(void *vsd, char *board_id)
-{
- int i;
-
-#define VSD_OFFSET_SIG1 0x00
-#define VSD_OFFSET_SIG2 0xde
-#define VSD_OFFSET_MLX_BOARD_ID 0xd0
-#define VSD_OFFSET_TS_BOARD_ID 0x20
-
-#define VSD_SIGNATURE_TOPSPIN 0x5ad
-
- memset(board_id, 0, MTHCA_BOARD_ID_LEN);
-
- if (be16_to_cpup(vsd + VSD_OFFSET_SIG1) == VSD_SIGNATURE_TOPSPIN &&
- be16_to_cpup(vsd + VSD_OFFSET_SIG2) == VSD_SIGNATURE_TOPSPIN) {
- strlcpy(board_id, vsd + VSD_OFFSET_TS_BOARD_ID, MTHCA_BOARD_ID_LEN);
- } else {
- /*
- * The board ID is a string but the firmware byte
- * swaps each 4-byte word before passing it back to
- * us. Therefore we need to swab it before printing.
- */
- for (i = 0; i < 4; ++i)
- ((u32 *) board_id)[i] =
- swab32(*(u32 *) (vsd + VSD_OFFSET_MLX_BOARD_ID + i * 4));
- }
-}
-
-int mthca_QUERY_ADAPTER(struct mthca_dev *dev,
- struct mthca_adapter *adapter, u8 *status)
-{
- struct mthca_mailbox *mailbox;
- u32 *outbox;
- int err;
-
-#define QUERY_ADAPTER_OUT_SIZE 0x100
-#define QUERY_ADAPTER_VENDOR_ID_OFFSET 0x00
-#define QUERY_ADAPTER_DEVICE_ID_OFFSET 0x04
-#define QUERY_ADAPTER_REVISION_ID_OFFSET 0x08
-#define QUERY_ADAPTER_INTA_PIN_OFFSET 0x10
-#define QUERY_ADAPTER_VSD_OFFSET 0x20
-
- mailbox = mthca_alloc_mailbox(dev, GFP_KERNEL);
- if (IS_ERR(mailbox))
- return PTR_ERR(mailbox);
- outbox = mailbox->buf;
-
- err = mthca_cmd_box(dev, 0, mailbox->dma, 0, 0, CMD_QUERY_ADAPTER,
- CMD_TIME_CLASS_A, status);
-
- if (err)
- goto out;
-
- if (!mthca_is_memfree(dev)) {
- MTHCA_GET(adapter->vendor_id, outbox,
- QUERY_ADAPTER_VENDOR_ID_OFFSET);
- MTHCA_GET(adapter->device_id, outbox,
- QUERY_ADAPTER_DEVICE_ID_OFFSET);
- MTHCA_GET(adapter->revision_id, outbox,
- QUERY_ADAPTER_REVISION_ID_OFFSET);
- }
- MTHCA_GET(adapter->inta_pin, outbox, QUERY_ADAPTER_INTA_PIN_OFFSET);
-
- get_board_id(outbox + QUERY_ADAPTER_VSD_OFFSET / 4,
- adapter->board_id);
-
-out:
- mthca_free_mailbox(dev, mailbox);
- return err;
-}
-
-int mthca_INIT_HCA(struct mthca_dev *dev,
- struct mthca_init_hca_param *param,
- u8 *status)
-{
- struct mthca_mailbox *mailbox;
- __be32 *inbox;
- int err;
-
-#define INIT_HCA_IN_SIZE 0x200
-#define INIT_HCA_FLAGS1_OFFSET 0x00c
-#define INIT_HCA_FLAGS2_OFFSET 0x014
-#define INIT_HCA_QPC_OFFSET 0x020
-#define INIT_HCA_QPC_BASE_OFFSET (INIT_HCA_QPC_OFFSET + 0x10)
-#define INIT_HCA_LOG_QP_OFFSET (INIT_HCA_QPC_OFFSET + 0x17)
-#define INIT_HCA_EEC_BASE_OFFSET (INIT_HCA_QPC_OFFSET + 0x20)
-#define INIT_HCA_LOG_EEC_OFFSET (INIT_HCA_QPC_OFFSET + 0x27)
-#define INIT_HCA_SRQC_BASE_OFFSET (INIT_HCA_QPC_OFFSET + 0x28)
-#define INIT_HCA_LOG_SRQ_OFFSET (INIT_HCA_QPC_OFFSET + 0x2f)
-#define INIT_HCA_CQC_BASE_OFFSET (INIT_HCA_QPC_OFFSET + 0x30)
-#define INIT_HCA_LOG_CQ_OFFSET (INIT_HCA_QPC_OFFSET + 0x37)
-#define INIT_HCA_EQPC_BASE_OFFSET (INIT_HCA_QPC_OFFSET + 0x40)
-#define INIT_HCA_EEEC_BASE_OFFSET (INIT_HCA_QPC_OFFSET + 0x50)
-#define INIT_HCA_EQC_BASE_OFFSET (INIT_HCA_QPC_OFFSET + 0x60)
-#define INIT_HCA_LOG_EQ_OFFSET (INIT_HCA_QPC_OFFSET + 0x67)
-#define INIT_HCA_RDB_BASE_OFFSET (INIT_HCA_QPC_OFFSET + 0x70)
-#define INIT_HCA_UDAV_OFFSET 0x0b0
-#define INIT_HCA_UDAV_LKEY_OFFSET (INIT_HCA_UDAV_OFFSET + 0x0)
-#define INIT_HCA_UDAV_PD_OFFSET (INIT_HCA_UDAV_OFFSET + 0x4)
-#define INIT_HCA_MCAST_OFFSET 0x0c0
-#define INIT_HCA_MC_BASE_OFFSET (INIT_HCA_MCAST_OFFSET + 0x00)
-#define INIT_HCA_LOG_MC_ENTRY_SZ_OFFSET (INIT_HCA_MCAST_OFFSET + 0x12)
-#define INIT_HCA_MC_HASH_SZ_OFFSET (INIT_HCA_MCAST_OFFSET + 0x16)
-#define INIT_HCA_LOG_MC_TABLE_SZ_OFFSET (INIT_HCA_MCAST_OFFSET + 0x1b)
-#define INIT_HCA_TPT_OFFSET 0x0f0
-#define INIT_HCA_MPT_BASE_OFFSET (INIT_HCA_TPT_OFFSET + 0x00)
-#define INIT_HCA_MTT_SEG_SZ_OFFSET (INIT_HCA_TPT_OFFSET + 0x09)
-#define INIT_HCA_LOG_MPT_SZ_OFFSET (INIT_HCA_TPT_OFFSET + 0x0b)
-#define INIT_HCA_MTT_BASE_OFFSET (INIT_HCA_TPT_OFFSET + 0x10)
-#define INIT_HCA_UAR_OFFSET 0x120
-#define INIT_HCA_UAR_BASE_OFFSET (INIT_HCA_UAR_OFFSET + 0x00)
-#define INIT_HCA_UARC_SZ_OFFSET (INIT_HCA_UAR_OFFSET + 0x09)
-#define INIT_HCA_LOG_UAR_SZ_OFFSET (INIT_HCA_UAR_OFFSET + 0x0a)
-#define INIT_HCA_UAR_PAGE_SZ_OFFSET (INIT_HCA_UAR_OFFSET + 0x0b)
-#define INIT_HCA_UAR_SCATCH_BASE_OFFSET (INIT_HCA_UAR_OFFSET + 0x10)
-#define INIT_HCA_UAR_CTX_BASE_OFFSET (INIT_HCA_UAR_OFFSET + 0x18)
-
- mailbox = mthca_alloc_mailbox(dev, GFP_KERNEL);
- if (IS_ERR(mailbox))
- return PTR_ERR(mailbox);
- inbox = mailbox->buf;
-
- memset(inbox, 0, INIT_HCA_IN_SIZE);
-
- if (dev->mthca_flags & MTHCA_FLAG_SINAI_OPT)
- MTHCA_PUT(inbox, 0x1, INIT_HCA_FLAGS1_OFFSET);
-
-#if defined(__LITTLE_ENDIAN)
- *(inbox + INIT_HCA_FLAGS2_OFFSET / 4) &= ~cpu_to_be32(1 << 1);
-#elif defined(__BIG_ENDIAN)
- *(inbox + INIT_HCA_FLAGS2_OFFSET / 4) |= cpu_to_be32(1 << 1);
-#else
-#error Host endianness not defined
-#endif
- /* Check port for UD address vector: */
- *(inbox + INIT_HCA_FLAGS2_OFFSET / 4) |= cpu_to_be32(1);
-
- /* Enable IPoIB checksumming if we can: */
- if (dev->device_cap_flags & IB_DEVICE_UD_IP_CSUM)
- *(inbox + INIT_HCA_FLAGS2_OFFSET / 4) |= cpu_to_be32(7 << 3);
-
- /* We leave wqe_quota, responder_exu, etc as 0 (default) */
-
- /* QPC/EEC/CQC/EQC/RDB attributes */
-
- MTHCA_PUT(inbox, param->qpc_base, INIT_HCA_QPC_BASE_OFFSET);
- MTHCA_PUT(inbox, param->log_num_qps, INIT_HCA_LOG_QP_OFFSET);
- MTHCA_PUT(inbox, param->eec_base, INIT_HCA_EEC_BASE_OFFSET);
- MTHCA_PUT(inbox, param->log_num_eecs, INIT_HCA_LOG_EEC_OFFSET);
- MTHCA_PUT(inbox, param->srqc_base, INIT_HCA_SRQC_BASE_OFFSET);
- MTHCA_PUT(inbox, param->log_num_srqs, INIT_HCA_LOG_SRQ_OFFSET);
- MTHCA_PUT(inbox, param->cqc_base, INIT_HCA_CQC_BASE_OFFSET);
- MTHCA_PUT(inbox, param->log_num_cqs, INIT_HCA_LOG_CQ_OFFSET);
- MTHCA_PUT(inbox, param->eqpc_base, INIT_HCA_EQPC_BASE_OFFSET);
- MTHCA_PUT(inbox, param->eeec_base, INIT_HCA_EEEC_BASE_OFFSET);
- MTHCA_PUT(inbox, param->eqc_base, INIT_HCA_EQC_BASE_OFFSET);
- MTHCA_PUT(inbox, param->log_num_eqs, INIT_HCA_LOG_EQ_OFFSET);
- MTHCA_PUT(inbox, param->rdb_base, INIT_HCA_RDB_BASE_OFFSET);
-
- /* UD AV attributes */
-
- /* multicast attributes */
-
- MTHCA_PUT(inbox, param->mc_base, INIT_HCA_MC_BASE_OFFSET);
- MTHCA_PUT(inbox, param->log_mc_entry_sz, INIT_HCA_LOG_MC_ENTRY_SZ_OFFSET);
- MTHCA_PUT(inbox, param->mc_hash_sz, INIT_HCA_MC_HASH_SZ_OFFSET);
- MTHCA_PUT(inbox, param->log_mc_table_sz, INIT_HCA_LOG_MC_TABLE_SZ_OFFSET);
-
- /* TPT attributes */
-
- MTHCA_PUT(inbox, param->mpt_base, INIT_HCA_MPT_BASE_OFFSET);
- if (!mthca_is_memfree(dev))
- MTHCA_PUT(inbox, param->mtt_seg_sz, INIT_HCA_MTT_SEG_SZ_OFFSET);
- MTHCA_PUT(inbox, param->log_mpt_sz, INIT_HCA_LOG_MPT_SZ_OFFSET);
- MTHCA_PUT(inbox, param->mtt_base, INIT_HCA_MTT_BASE_OFFSET);
-
- /* UAR attributes */
- {
- u8 uar_page_sz = PAGE_SHIFT - 12;
- MTHCA_PUT(inbox, uar_page_sz, INIT_HCA_UAR_PAGE_SZ_OFFSET);
- }
-
- MTHCA_PUT(inbox, param->uar_scratch_base, INIT_HCA_UAR_SCATCH_BASE_OFFSET);
-
- if (mthca_is_memfree(dev)) {
- MTHCA_PUT(inbox, param->log_uarc_sz, INIT_HCA_UARC_SZ_OFFSET);
- MTHCA_PUT(inbox, param->log_uar_sz, INIT_HCA_LOG_UAR_SZ_OFFSET);
- MTHCA_PUT(inbox, param->uarc_base, INIT_HCA_UAR_CTX_BASE_OFFSET);
- }
-
- err = mthca_cmd(dev, mailbox->dma, 0, 0, CMD_INIT_HCA, CMD_TIME_CLASS_D, status);
-
- mthca_free_mailbox(dev, mailbox);
- return err;
-}
-
-int mthca_INIT_IB(struct mthca_dev *dev,
- struct mthca_init_ib_param *param,
- int port, u8 *status)
-{
- struct mthca_mailbox *mailbox;
- u32 *inbox;
- int err;
- u32 flags;
-
-#define INIT_IB_IN_SIZE 56
-#define INIT_IB_FLAGS_OFFSET 0x00
-#define INIT_IB_FLAG_SIG (1 << 18)
-#define INIT_IB_FLAG_NG (1 << 17)
-#define INIT_IB_FLAG_G0 (1 << 16)
-#define INIT_IB_VL_SHIFT 4
-#define INIT_IB_PORT_WIDTH_SHIFT 8
-#define INIT_IB_MTU_SHIFT 12
-#define INIT_IB_MAX_GID_OFFSET 0x06
-#define INIT_IB_MAX_PKEY_OFFSET 0x0a
-#define INIT_IB_GUID0_OFFSET 0x10
-#define INIT_IB_NODE_GUID_OFFSET 0x18
-#define INIT_IB_SI_GUID_OFFSET 0x20
-
- mailbox = mthca_alloc_mailbox(dev, GFP_KERNEL);
- if (IS_ERR(mailbox))
- return PTR_ERR(mailbox);
- inbox = mailbox->buf;
-
- memset(inbox, 0, INIT_IB_IN_SIZE);
-
- flags = 0;
- flags |= param->set_guid0 ? INIT_IB_FLAG_G0 : 0;
- flags |= param->set_node_guid ? INIT_IB_FLAG_NG : 0;
- flags |= param->set_si_guid ? INIT_IB_FLAG_SIG : 0;
- flags |= param->vl_cap << INIT_IB_VL_SHIFT;
- flags |= param->port_width << INIT_IB_PORT_WIDTH_SHIFT;
- flags |= param->mtu_cap << INIT_IB_MTU_SHIFT;
- MTHCA_PUT(inbox, flags, INIT_IB_FLAGS_OFFSET);
-
- MTHCA_PUT(inbox, param->gid_cap, INIT_IB_MAX_GID_OFFSET);
- MTHCA_PUT(inbox, param->pkey_cap, INIT_IB_MAX_PKEY_OFFSET);
- MTHCA_PUT(inbox, param->guid0, INIT_IB_GUID0_OFFSET);
- MTHCA_PUT(inbox, param->node_guid, INIT_IB_NODE_GUID_OFFSET);
- MTHCA_PUT(inbox, param->si_guid, INIT_IB_SI_GUID_OFFSET);
-
- err = mthca_cmd(dev, mailbox->dma, port, 0, CMD_INIT_IB,
- CMD_TIME_CLASS_A, status);
-
- mthca_free_mailbox(dev, mailbox);
- return err;
-}
-
-int mthca_CLOSE_IB(struct mthca_dev *dev, int port, u8 *status)
-{
- return mthca_cmd(dev, 0, port, 0, CMD_CLOSE_IB, CMD_TIME_CLASS_A, status);
-}
-
-int mthca_CLOSE_HCA(struct mthca_dev *dev, int panic, u8 *status)
-{
- return mthca_cmd(dev, 0, 0, panic, CMD_CLOSE_HCA, CMD_TIME_CLASS_C, status);
-}
-
-int mthca_SET_IB(struct mthca_dev *dev, struct mthca_set_ib_param *param,
- int port, u8 *status)
-{
- struct mthca_mailbox *mailbox;
- u32 *inbox;
- int err;
- u32 flags = 0;
-
-#define SET_IB_IN_SIZE 0x40
-#define SET_IB_FLAGS_OFFSET 0x00
-#define SET_IB_FLAG_SIG (1 << 18)
-#define SET_IB_FLAG_RQK (1 << 0)
-#define SET_IB_CAP_MASK_OFFSET 0x04
-#define SET_IB_SI_GUID_OFFSET 0x08
-
- mailbox = mthca_alloc_mailbox(dev, GFP_KERNEL);
- if (IS_ERR(mailbox))
- return PTR_ERR(mailbox);
- inbox = mailbox->buf;
-
- memset(inbox, 0, SET_IB_IN_SIZE);
-
- flags |= param->set_si_guid ? SET_IB_FLAG_SIG : 0;
- flags |= param->reset_qkey_viol ? SET_IB_FLAG_RQK : 0;
- MTHCA_PUT(inbox, flags, SET_IB_FLAGS_OFFSET);
-
- MTHCA_PUT(inbox, param->cap_mask, SET_IB_CAP_MASK_OFFSET);
- MTHCA_PUT(inbox, param->si_guid, SET_IB_SI_GUID_OFFSET);
-
- err = mthca_cmd(dev, mailbox->dma, port, 0, CMD_SET_IB,
- CMD_TIME_CLASS_B, status);
-
- mthca_free_mailbox(dev, mailbox);
- return err;
-}
-
-int mthca_MAP_ICM(struct mthca_dev *dev, struct mthca_icm *icm, u64 virt, u8 *status)
-{
- return mthca_map_cmd(dev, CMD_MAP_ICM, icm, virt, status);
-}
-
-int mthca_MAP_ICM_page(struct mthca_dev *dev, u64 dma_addr, u64 virt, u8 *status)
-{
- struct mthca_mailbox *mailbox;
- __be64 *inbox;
- int err;
-
- mailbox = mthca_alloc_mailbox(dev, GFP_KERNEL);
- if (IS_ERR(mailbox))
- return PTR_ERR(mailbox);
- inbox = mailbox->buf;
-
- inbox[0] = cpu_to_be64(virt);
- inbox[1] = cpu_to_be64(dma_addr);
-
- err = mthca_cmd(dev, mailbox->dma, 1, 0, CMD_MAP_ICM,
- CMD_TIME_CLASS_B, status);
-
- mthca_free_mailbox(dev, mailbox);
-
- if (!err)
- mthca_dbg(dev, "Mapped page at %llx to %llx for ICM.\n",
- (unsigned long long) dma_addr, (unsigned long long) virt);
-
- return err;
-}
-
-int mthca_UNMAP_ICM(struct mthca_dev *dev, u64 virt, u32 page_count, u8 *status)
-{
- mthca_dbg(dev, "Unmapping %d pages at %llx from ICM.\n",
- page_count, (unsigned long long) virt);
-
- return mthca_cmd(dev, virt, page_count, 0, CMD_UNMAP_ICM, CMD_TIME_CLASS_B, status);
-}
-
-int mthca_MAP_ICM_AUX(struct mthca_dev *dev, struct mthca_icm *icm, u8 *status)
-{
- return mthca_map_cmd(dev, CMD_MAP_ICM_AUX, icm, -1, status);
-}
-
-int mthca_UNMAP_ICM_AUX(struct mthca_dev *dev, u8 *status)
-{
- return mthca_cmd(dev, 0, 0, 0, CMD_UNMAP_ICM_AUX, CMD_TIME_CLASS_B, status);
-}
-
-int mthca_SET_ICM_SIZE(struct mthca_dev *dev, u64 icm_size, u64 *aux_pages,
- u8 *status)
-{
- int ret = mthca_cmd_imm(dev, icm_size, aux_pages, 0, 0, CMD_SET_ICM_SIZE,
- CMD_TIME_CLASS_A, status);
-
- if (ret || status)
- return ret;
-
- /*
- * Round up number of system pages needed in case
- * MTHCA_ICM_PAGE_SIZE < PAGE_SIZE.
- */
- *aux_pages = ALIGN(*aux_pages, PAGE_SIZE / MTHCA_ICM_PAGE_SIZE) >>
- (PAGE_SHIFT - MTHCA_ICM_PAGE_SHIFT);
-
- return 0;
-}
-
-int mthca_SW2HW_MPT(struct mthca_dev *dev, struct mthca_mailbox *mailbox,
- int mpt_index, u8 *status)
-{
- return mthca_cmd(dev, mailbox->dma, mpt_index, 0, CMD_SW2HW_MPT,
- CMD_TIME_CLASS_B, status);
-}
-
-int mthca_HW2SW_MPT(struct mthca_dev *dev, struct mthca_mailbox *mailbox,
- int mpt_index, u8 *status)
-{
- return mthca_cmd_box(dev, 0, mailbox ? mailbox->dma : 0, mpt_index,
- !mailbox, CMD_HW2SW_MPT,
- CMD_TIME_CLASS_B, status);
-}
-
-int mthca_WRITE_MTT(struct mthca_dev *dev, struct mthca_mailbox *mailbox,
- int num_mtt, u8 *status)
-{
- return mthca_cmd(dev, mailbox->dma, num_mtt, 0, CMD_WRITE_MTT,
- CMD_TIME_CLASS_B, status);
-}
-
-int mthca_SYNC_TPT(struct mthca_dev *dev, u8 *status)
-{
- return mthca_cmd(dev, 0, 0, 0, CMD_SYNC_TPT, CMD_TIME_CLASS_B, status);
-}
-
-int mthca_MAP_EQ(struct mthca_dev *dev, u64 event_mask, int unmap,
- int eq_num, u8 *status)
-{
- mthca_dbg(dev, "%s mask %016llx for eqn %d\n",
- unmap ? "Clearing" : "Setting",
- (unsigned long long) event_mask, eq_num);
- return mthca_cmd(dev, event_mask, (unmap << 31) | eq_num,
- 0, CMD_MAP_EQ, CMD_TIME_CLASS_B, status);
-}
-
-int mthca_SW2HW_EQ(struct mthca_dev *dev, struct mthca_mailbox *mailbox,
- int eq_num, u8 *status)
-{
- return mthca_cmd(dev, mailbox->dma, eq_num, 0, CMD_SW2HW_EQ,
- CMD_TIME_CLASS_A, status);
-}
-
-int mthca_HW2SW_EQ(struct mthca_dev *dev, struct mthca_mailbox *mailbox,
- int eq_num, u8 *status)
-{
- return mthca_cmd_box(dev, 0, mailbox->dma, eq_num, 0,
- CMD_HW2SW_EQ,
- CMD_TIME_CLASS_A, status);
-}
-
-int mthca_SW2HW_CQ(struct mthca_dev *dev, struct mthca_mailbox *mailbox,
- int cq_num, u8 *status)
-{
- return mthca_cmd(dev, mailbox->dma, cq_num, 0, CMD_SW2HW_CQ,
- CMD_TIME_CLASS_A, status);
-}
-
-int mthca_HW2SW_CQ(struct mthca_dev *dev, struct mthca_mailbox *mailbox,
- int cq_num, u8 *status)
-{
- return mthca_cmd_box(dev, 0, mailbox->dma, cq_num, 0,
- CMD_HW2SW_CQ,
- CMD_TIME_CLASS_A, status);
-}
-
-int mthca_RESIZE_CQ(struct mthca_dev *dev, int cq_num, u32 lkey, u8 log_size,
- u8 *status)
-{
- struct mthca_mailbox *mailbox;
- __be32 *inbox;
- int err;
-
-#define RESIZE_CQ_IN_SIZE 0x40
-#define RESIZE_CQ_LOG_SIZE_OFFSET 0x0c
-#define RESIZE_CQ_LKEY_OFFSET 0x1c
-
- mailbox = mthca_alloc_mailbox(dev, GFP_KERNEL);
- if (IS_ERR(mailbox))
- return PTR_ERR(mailbox);
- inbox = mailbox->buf;
-
- memset(inbox, 0, RESIZE_CQ_IN_SIZE);
- /*
- * Leave start address fields zeroed out -- mthca assumes that
- * MRs for CQs always start at virtual address 0.
- */
- MTHCA_PUT(inbox, log_size, RESIZE_CQ_LOG_SIZE_OFFSET);
- MTHCA_PUT(inbox, lkey, RESIZE_CQ_LKEY_OFFSET);
-
- err = mthca_cmd(dev, mailbox->dma, cq_num, 1, CMD_RESIZE_CQ,
- CMD_TIME_CLASS_B, status);
-
- mthca_free_mailbox(dev, mailbox);
- return err;
-}
-
-int mthca_SW2HW_SRQ(struct mthca_dev *dev, struct mthca_mailbox *mailbox,
- int srq_num, u8 *status)
-{
- return mthca_cmd(dev, mailbox->dma, srq_num, 0, CMD_SW2HW_SRQ,
- CMD_TIME_CLASS_A, status);
-}
-
-int mthca_HW2SW_SRQ(struct mthca_dev *dev, struct mthca_mailbox *mailbox,
- int srq_num, u8 *status)
-{
- return mthca_cmd_box(dev, 0, mailbox->dma, srq_num, 0,
- CMD_HW2SW_SRQ,
- CMD_TIME_CLASS_A, status);
-}
-
-int mthca_QUERY_SRQ(struct mthca_dev *dev, u32 num,
- struct mthca_mailbox *mailbox, u8 *status)
-{
- return mthca_cmd_box(dev, 0, mailbox->dma, num, 0,
- CMD_QUERY_SRQ, CMD_TIME_CLASS_A, status);
-}
-
-int mthca_ARM_SRQ(struct mthca_dev *dev, int srq_num, int limit, u8 *status)
-{
- return mthca_cmd(dev, limit, srq_num, 0, CMD_ARM_SRQ,
- CMD_TIME_CLASS_B, status);
-}
-
-int mthca_MODIFY_QP(struct mthca_dev *dev, enum ib_qp_state cur,
- enum ib_qp_state next, u32 num, int is_ee,
- struct mthca_mailbox *mailbox, u32 optmask,
- u8 *status)
-{
- static const u16 op[IB_QPS_ERR + 1][IB_QPS_ERR + 1] = {
- [IB_QPS_RESET] = {
- [IB_QPS_RESET] = CMD_ERR2RST_QPEE,
- [IB_QPS_ERR] = CMD_2ERR_QPEE,
- [IB_QPS_INIT] = CMD_RST2INIT_QPEE,
- },
- [IB_QPS_INIT] = {
- [IB_QPS_RESET] = CMD_ERR2RST_QPEE,
- [IB_QPS_ERR] = CMD_2ERR_QPEE,
- [IB_QPS_INIT] = CMD_INIT2INIT_QPEE,
- [IB_QPS_RTR] = CMD_INIT2RTR_QPEE,
- },
- [IB_QPS_RTR] = {
- [IB_QPS_RESET] = CMD_ERR2RST_QPEE,
- [IB_QPS_ERR] = CMD_2ERR_QPEE,
- [IB_QPS_RTS] = CMD_RTR2RTS_QPEE,
- },
- [IB_QPS_RTS] = {
- [IB_QPS_RESET] = CMD_ERR2RST_QPEE,
- [IB_QPS_ERR] = CMD_2ERR_QPEE,
- [IB_QPS_RTS] = CMD_RTS2RTS_QPEE,
- [IB_QPS_SQD] = CMD_RTS2SQD_QPEE,
- },
- [IB_QPS_SQD] = {
- [IB_QPS_RESET] = CMD_ERR2RST_QPEE,
- [IB_QPS_ERR] = CMD_2ERR_QPEE,
- [IB_QPS_RTS] = CMD_SQD2RTS_QPEE,
- [IB_QPS_SQD] = CMD_SQD2SQD_QPEE,
- },
- [IB_QPS_SQE] = {
- [IB_QPS_RESET] = CMD_ERR2RST_QPEE,
- [IB_QPS_ERR] = CMD_2ERR_QPEE,
- [IB_QPS_RTS] = CMD_SQERR2RTS_QPEE,
- },
- [IB_QPS_ERR] = {
- [IB_QPS_RESET] = CMD_ERR2RST_QPEE,
- [IB_QPS_ERR] = CMD_2ERR_QPEE,
- }
- };
-
- u8 op_mod = 0;
- int my_mailbox = 0;
- int err;
-
- if (op[cur][next] == CMD_ERR2RST_QPEE) {
- op_mod = 3; /* don't write outbox, any->reset */
-
- /* For debugging */
- if (!mailbox) {
- mailbox = mthca_alloc_mailbox(dev, GFP_KERNEL);
- if (!IS_ERR(mailbox)) {
- my_mailbox = 1;
- op_mod = 2; /* write outbox, any->reset */
- } else
- mailbox = NULL;
- }
-
- err = mthca_cmd_box(dev, 0, mailbox ? mailbox->dma : 0,
- (!!is_ee << 24) | num, op_mod,
- op[cur][next], CMD_TIME_CLASS_C, status);
-
- if (0 && mailbox) {
- int i;
- mthca_dbg(dev, "Dumping QP context:\n");
- printk(" %08x\n", be32_to_cpup(mailbox->buf));
- for (i = 0; i < 0x100 / 4; ++i) {
- if (i % 8 == 0)
- printk("[%02x] ", i * 4);
- printk(" %08x",
- be32_to_cpu(((__be32 *) mailbox->buf)[i + 2]));
- if ((i + 1) % 8 == 0)
- printk("\n");
- }
- }
-
- if (my_mailbox)
- mthca_free_mailbox(dev, mailbox);
- } else {
- if (0) {
- int i;
- mthca_dbg(dev, "Dumping QP context:\n");
- printk(" opt param mask: %08x\n", be32_to_cpup(mailbox->buf));
- for (i = 0; i < 0x100 / 4; ++i) {
- if (i % 8 == 0)
- printk(" [%02x] ", i * 4);
- printk(" %08x",
- be32_to_cpu(((__be32 *) mailbox->buf)[i + 2]));
- if ((i + 1) % 8 == 0)
- printk("\n");
- }
- }
-
- err = mthca_cmd(dev, mailbox->dma, optmask | (!!is_ee << 24) | num,
- op_mod, op[cur][next], CMD_TIME_CLASS_C, status);
- }
-
- return err;
-}
-
-int mthca_QUERY_QP(struct mthca_dev *dev, u32 num, int is_ee,
- struct mthca_mailbox *mailbox, u8 *status)
-{
- return mthca_cmd_box(dev, 0, mailbox->dma, (!!is_ee << 24) | num, 0,
- CMD_QUERY_QPEE, CMD_TIME_CLASS_A, status);
-}
-
-int mthca_CONF_SPECIAL_QP(struct mthca_dev *dev, int type, u32 qpn,
- u8 *status)
-{
- u8 op_mod;
-
- switch (type) {
- case IB_QPT_SMI:
- op_mod = 0;
- break;
- case IB_QPT_GSI:
- op_mod = 1;
- break;
- case IB_QPT_RAW_IPV6:
- op_mod = 2;
- break;
- case IB_QPT_RAW_ETHERTYPE:
- op_mod = 3;
- break;
- default:
- return -EINVAL;
- }
-
- return mthca_cmd(dev, 0, qpn, op_mod, CMD_CONF_SPECIAL_QP,
- CMD_TIME_CLASS_B, status);
-}
-
-int mthca_MAD_IFC(struct mthca_dev *dev, int ignore_mkey, int ignore_bkey,
- int port, struct ib_wc *in_wc, struct ib_grh *in_grh,
- void *in_mad, void *response_mad, u8 *status)
-{
- struct mthca_mailbox *inmailbox, *outmailbox;
- void *inbox;
- int err;
- u32 in_modifier = port;
- u8 op_modifier = 0;
-
-#define MAD_IFC_BOX_SIZE 0x400
-#define MAD_IFC_MY_QPN_OFFSET 0x100
-#define MAD_IFC_RQPN_OFFSET 0x108
-#define MAD_IFC_SL_OFFSET 0x10c
-#define MAD_IFC_G_PATH_OFFSET 0x10d
-#define MAD_IFC_RLID_OFFSET 0x10e
-#define MAD_IFC_PKEY_OFFSET 0x112
-#define MAD_IFC_GRH_OFFSET 0x140
-
- inmailbox = mthca_alloc_mailbox(dev, GFP_KERNEL);
- if (IS_ERR(inmailbox))
- return PTR_ERR(inmailbox);
- inbox = inmailbox->buf;
-
- outmailbox = mthca_alloc_mailbox(dev, GFP_KERNEL);
- if (IS_ERR(outmailbox)) {
- mthca_free_mailbox(dev, inmailbox);
- return PTR_ERR(outmailbox);
- }
-
- memcpy(inbox, in_mad, 256);
-
- /*
- * Key check traps can't be generated unless we have in_wc to
- * tell us where to send the trap.
- */
- if (ignore_mkey || !in_wc)
- op_modifier |= 0x1;
- if (ignore_bkey || !in_wc)
- op_modifier |= 0x2;
-
- if (in_wc) {
- u8 val;
-
- memset(inbox + 256, 0, 256);
-
- MTHCA_PUT(inbox, in_wc->qp->qp_num, MAD_IFC_MY_QPN_OFFSET);
- MTHCA_PUT(inbox, in_wc->src_qp, MAD_IFC_RQPN_OFFSET);
-
- val = in_wc->sl << 4;
- MTHCA_PUT(inbox, val, MAD_IFC_SL_OFFSET);
-
- val = in_wc->dlid_path_bits |
- (in_wc->wc_flags & IB_WC_GRH ? 0x80 : 0);
- MTHCA_PUT(inbox, val, MAD_IFC_G_PATH_OFFSET);
-
- MTHCA_PUT(inbox, in_wc->slid, MAD_IFC_RLID_OFFSET);
- MTHCA_PUT(inbox, in_wc->pkey_index, MAD_IFC_PKEY_OFFSET);
-
- if (in_grh)
- memcpy(inbox + MAD_IFC_GRH_OFFSET, in_grh, 40);
-
- op_modifier |= 0x4;
-
- in_modifier |= in_wc->slid << 16;
- }
-
- err = mthca_cmd_box(dev, inmailbox->dma, outmailbox->dma,
- in_modifier, op_modifier,
- CMD_MAD_IFC, CMD_TIME_CLASS_C, status);
-
- if (!err && !*status)
- memcpy(response_mad, outmailbox->buf, 256);
-
- mthca_free_mailbox(dev, inmailbox);
- mthca_free_mailbox(dev, outmailbox);
- return err;
-}
-
-int mthca_READ_MGM(struct mthca_dev *dev, int index,
- struct mthca_mailbox *mailbox, u8 *status)
-{
- return mthca_cmd_box(dev, 0, mailbox->dma, index, 0,
- CMD_READ_MGM, CMD_TIME_CLASS_A, status);
-}
-
-int mthca_WRITE_MGM(struct mthca_dev *dev, int index,
- struct mthca_mailbox *mailbox, u8 *status)
-{
- return mthca_cmd(dev, mailbox->dma, index, 0, CMD_WRITE_MGM,
- CMD_TIME_CLASS_A, status);
-}
-
-int mthca_MGID_HASH(struct mthca_dev *dev, struct mthca_mailbox *mailbox,
- u16 *hash, u8 *status)
-{
- u64 imm;
- int err;
-
- err = mthca_cmd_imm(dev, mailbox->dma, &imm, 0, 0, CMD_MGID_HASH,
- CMD_TIME_CLASS_A, status);
-
- *hash = imm;
- return err;
-}
-
-int mthca_DIAG_RPRT(struct mthca_dev *dev, int mod,
- struct mthca_mailbox *mailbox, u8 *status)
-{
- return mthca_cmd_box(dev, 0, mailbox->dma, 0, mod, CMD_DIAG_RPRT,
- CMD_TIME_CLASS_A, status);
-}
-
-int mthca_NOP(struct mthca_dev *dev, u8 *status)
-{
- return mthca_cmd(dev, 0, 0x1f, 0, CMD_NOP, msecs_to_jiffies(100), status);
-}
diff --git a/sys/ofed/drivers/infiniband/hw/mthca/mthca_cmd.h b/sys/ofed/drivers/infiniband/hw/mthca/mthca_cmd.h
deleted file mode 100644
index 5dd777c..0000000
--- a/sys/ofed/drivers/infiniband/hw/mthca/mthca_cmd.h
+++ /dev/null
@@ -1,341 +0,0 @@
-/*
- * Copyright (c) 2004, 2005 Topspin Communications. All rights reserved.
- * Copyright (c) 2005 Mellanox Technologies. All rights reserved.
- * Copyright (c) 2006 Cisco Systems. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-#ifndef MTHCA_CMD_H
-#define MTHCA_CMD_H
-
-#include <rdma/ib_verbs.h>
-
-#define MTHCA_MAILBOX_SIZE 4096
-
-enum {
- /* command completed successfully: */
- MTHCA_CMD_STAT_OK = 0x00,
- /* Internal error (such as a bus error) occurred while processing command: */
- MTHCA_CMD_STAT_INTERNAL_ERR = 0x01,
- /* Operation/command not supported or opcode modifier not supported: */
- MTHCA_CMD_STAT_BAD_OP = 0x02,
- /* Parameter not supported or parameter out of range: */
- MTHCA_CMD_STAT_BAD_PARAM = 0x03,
- /* System not enabled or bad system state: */
- MTHCA_CMD_STAT_BAD_SYS_STATE = 0x04,
- /* Attempt to access reserved or unallocaterd resource: */
- MTHCA_CMD_STAT_BAD_RESOURCE = 0x05,
- /* Requested resource is currently executing a command, or is otherwise busy: */
- MTHCA_CMD_STAT_RESOURCE_BUSY = 0x06,
- /* memory error: */
- MTHCA_CMD_STAT_DDR_MEM_ERR = 0x07,
- /* Required capability exceeds device limits: */
- MTHCA_CMD_STAT_EXCEED_LIM = 0x08,
- /* Resource is not in the appropriate state or ownership: */
- MTHCA_CMD_STAT_BAD_RES_STATE = 0x09,
- /* Index out of range: */
- MTHCA_CMD_STAT_BAD_INDEX = 0x0a,
- /* FW image corrupted: */
- MTHCA_CMD_STAT_BAD_NVMEM = 0x0b,
- /* Attempt to modify a QP/EE which is not in the presumed state: */
- MTHCA_CMD_STAT_BAD_QPEE_STATE = 0x10,
- /* Bad segment parameters (Address/Size): */
- MTHCA_CMD_STAT_BAD_SEG_PARAM = 0x20,
- /* Memory Region has Memory Windows bound to: */
- MTHCA_CMD_STAT_REG_BOUND = 0x21,
- /* HCA local attached memory not present: */
- MTHCA_CMD_STAT_LAM_NOT_PRE = 0x22,
- /* Bad management packet (silently discarded): */
- MTHCA_CMD_STAT_BAD_PKT = 0x30,
- /* More outstanding CQEs in CQ than new CQ size: */
- MTHCA_CMD_STAT_BAD_SIZE = 0x40
-};
-
-enum {
- MTHCA_TRANS_INVALID = 0,
- MTHCA_TRANS_RST2INIT,
- MTHCA_TRANS_INIT2INIT,
- MTHCA_TRANS_INIT2RTR,
- MTHCA_TRANS_RTR2RTS,
- MTHCA_TRANS_RTS2RTS,
- MTHCA_TRANS_SQERR2RTS,
- MTHCA_TRANS_ANY2ERR,
- MTHCA_TRANS_RTS2SQD,
- MTHCA_TRANS_SQD2SQD,
- MTHCA_TRANS_SQD2RTS,
- MTHCA_TRANS_ANY2RST,
-};
-
-enum {
- DEV_LIM_FLAG_RC = 1 << 0,
- DEV_LIM_FLAG_UC = 1 << 1,
- DEV_LIM_FLAG_UD = 1 << 2,
- DEV_LIM_FLAG_RD = 1 << 3,
- DEV_LIM_FLAG_RAW_IPV6 = 1 << 4,
- DEV_LIM_FLAG_RAW_ETHER = 1 << 5,
- DEV_LIM_FLAG_SRQ = 1 << 6,
- DEV_LIM_FLAG_IPOIB_CSUM = 1 << 7,
- DEV_LIM_FLAG_BAD_PKEY_CNTR = 1 << 8,
- DEV_LIM_FLAG_BAD_QKEY_CNTR = 1 << 9,
- DEV_LIM_FLAG_MW = 1 << 16,
- DEV_LIM_FLAG_AUTO_PATH_MIG = 1 << 17,
- DEV_LIM_FLAG_ATOMIC = 1 << 18,
- DEV_LIM_FLAG_RAW_MULTI = 1 << 19,
- DEV_LIM_FLAG_UD_AV_PORT_ENFORCE = 1 << 20,
- DEV_LIM_FLAG_UD_MULTI = 1 << 21,
-};
-
-enum {
- DIAG_RPRT_Q_XPRT_CIERR = 2,
- DIAG_RPRT_QR_XPRT_CIERR = 3,
- DIAG_RPRT_Q_PERF = 4,
- DIAG_RPRT_QR_PERF = 5,
- DIAG_RPRT_Q_MISC = 6,
- DIAG_RPRT_QR_MISC = 7,
-};
-
-struct mthca_mailbox {
- dma_addr_t dma;
- void *buf;
-};
-
-struct mthca_dev_lim {
- int max_srq_sz;
- int max_qp_sz;
- int reserved_qps;
- int max_qps;
- int reserved_srqs;
- int max_srqs;
- int reserved_eecs;
- int max_eecs;
- int max_cq_sz;
- int reserved_cqs;
- int max_cqs;
- int max_mpts;
- int reserved_eqs;
- int max_eqs;
- int reserved_mtts;
- int max_mrw_sz;
- int reserved_mrws;
- int max_mtt_seg;
- int max_requester_per_qp;
- int max_responder_per_qp;
- int max_rdma_global;
- int local_ca_ack_delay;
- int max_mtu;
- int max_port_width;
- int max_vl;
- int num_ports;
- int max_gids;
- u16 stat_rate_support;
- int max_pkeys;
- u32 flags;
- int reserved_uars;
- int uar_size;
- int min_page_sz;
- int max_sg;
- int max_desc_sz;
- int max_qp_per_mcg;
- int reserved_mgms;
- int max_mcgs;
- int reserved_pds;
- int max_pds;
- int reserved_rdds;
- int max_rdds;
- int eec_entry_sz;
- int qpc_entry_sz;
- int eeec_entry_sz;
- int eqpc_entry_sz;
- int eqc_entry_sz;
- int cqc_entry_sz;
- int srq_entry_sz;
- int uar_scratch_entry_sz;
- int mpt_entry_sz;
- union {
- struct {
- int max_avs;
- } tavor;
- struct {
- int resize_srq;
- int max_pbl_sz;
- u8 bmme_flags;
- u32 reserved_lkey;
- int lam_required;
- u64 max_icm_sz;
- } arbel;
- } hca;
-};
-
-struct mthca_adapter {
- u32 vendor_id;
- u32 device_id;
- u32 revision_id;
- char board_id[MTHCA_BOARD_ID_LEN];
- u8 inta_pin;
-};
-
-struct mthca_init_hca_param {
- u64 qpc_base;
- u64 eec_base;
- u64 srqc_base;
- u64 cqc_base;
- u64 eqpc_base;
- u64 eeec_base;
- u64 eqc_base;
- u64 rdb_base;
- u64 mc_base;
- u64 mpt_base;
- u64 mtt_base;
- u64 uar_scratch_base;
- u64 uarc_base;
- u16 log_mc_entry_sz;
- u16 mc_hash_sz;
- u8 log_num_qps;
- u8 log_num_eecs;
- u8 log_num_srqs;
- u8 log_num_cqs;
- u8 log_num_eqs;
- u8 log_mc_table_sz;
- u8 mtt_seg_sz;
- u8 log_mpt_sz;
- u8 log_uar_sz;
- u8 log_uarc_sz;
-};
-
-struct mthca_init_ib_param {
- int port_width;
- int vl_cap;
- int mtu_cap;
- u16 gid_cap;
- u16 pkey_cap;
- int set_guid0;
- u64 guid0;
- int set_node_guid;
- u64 node_guid;
- int set_si_guid;
- u64 si_guid;
-};
-
-struct mthca_set_ib_param {
- int set_si_guid;
- int reset_qkey_viol;
- u64 si_guid;
- u32 cap_mask;
-};
-
-int mthca_cmd_init(struct mthca_dev *dev);
-void mthca_cmd_cleanup(struct mthca_dev *dev);
-int mthca_cmd_use_events(struct mthca_dev *dev);
-void mthca_cmd_use_polling(struct mthca_dev *dev);
-void mthca_cmd_event(struct mthca_dev *dev, u16 token,
- u8 status, u64 out_param);
-
-struct mthca_mailbox *mthca_alloc_mailbox(struct mthca_dev *dev,
- gfp_t gfp_mask);
-void mthca_free_mailbox(struct mthca_dev *dev, struct mthca_mailbox *mailbox);
-
-int mthca_SYS_EN(struct mthca_dev *dev, u8 *status);
-int mthca_SYS_DIS(struct mthca_dev *dev, u8 *status);
-int mthca_MAP_FA(struct mthca_dev *dev, struct mthca_icm *icm, u8 *status);
-int mthca_UNMAP_FA(struct mthca_dev *dev, u8 *status);
-int mthca_RUN_FW(struct mthca_dev *dev, u8 *status);
-int mthca_QUERY_FW(struct mthca_dev *dev, u8 *status);
-int mthca_ENABLE_LAM(struct mthca_dev *dev, u8 *status);
-int mthca_DISABLE_LAM(struct mthca_dev *dev, u8 *status);
-int mthca_QUERY_DDR(struct mthca_dev *dev, u8 *status);
-int mthca_QUERY_DEV_LIM(struct mthca_dev *dev,
- struct mthca_dev_lim *dev_lim, u8 *status);
-int mthca_QUERY_ADAPTER(struct mthca_dev *dev,
- struct mthca_adapter *adapter, u8 *status);
-int mthca_INIT_HCA(struct mthca_dev *dev,
- struct mthca_init_hca_param *param,
- u8 *status);
-int mthca_INIT_IB(struct mthca_dev *dev,
- struct mthca_init_ib_param *param,
- int port, u8 *status);
-int mthca_CLOSE_IB(struct mthca_dev *dev, int port, u8 *status);
-int mthca_CLOSE_HCA(struct mthca_dev *dev, int panic, u8 *status);
-int mthca_SET_IB(struct mthca_dev *dev, struct mthca_set_ib_param *param,
- int port, u8 *status);
-int mthca_MAP_ICM(struct mthca_dev *dev, struct mthca_icm *icm, u64 virt, u8 *status);
-int mthca_MAP_ICM_page(struct mthca_dev *dev, u64 dma_addr, u64 virt, u8 *status);
-int mthca_UNMAP_ICM(struct mthca_dev *dev, u64 virt, u32 page_count, u8 *status);
-int mthca_MAP_ICM_AUX(struct mthca_dev *dev, struct mthca_icm *icm, u8 *status);
-int mthca_UNMAP_ICM_AUX(struct mthca_dev *dev, u8 *status);
-int mthca_SET_ICM_SIZE(struct mthca_dev *dev, u64 icm_size, u64 *aux_pages,
- u8 *status);
-int mthca_SW2HW_MPT(struct mthca_dev *dev, struct mthca_mailbox *mailbox,
- int mpt_index, u8 *status);
-int mthca_HW2SW_MPT(struct mthca_dev *dev, struct mthca_mailbox *mailbox,
- int mpt_index, u8 *status);
-int mthca_WRITE_MTT(struct mthca_dev *dev, struct mthca_mailbox *mailbox,
- int num_mtt, u8 *status);
-int mthca_SYNC_TPT(struct mthca_dev *dev, u8 *status);
-int mthca_MAP_EQ(struct mthca_dev *dev, u64 event_mask, int unmap,
- int eq_num, u8 *status);
-int mthca_SW2HW_EQ(struct mthca_dev *dev, struct mthca_mailbox *mailbox,
- int eq_num, u8 *status);
-int mthca_HW2SW_EQ(struct mthca_dev *dev, struct mthca_mailbox *mailbox,
- int eq_num, u8 *status);
-int mthca_SW2HW_CQ(struct mthca_dev *dev, struct mthca_mailbox *mailbox,
- int cq_num, u8 *status);
-int mthca_HW2SW_CQ(struct mthca_dev *dev, struct mthca_mailbox *mailbox,
- int cq_num, u8 *status);
-int mthca_RESIZE_CQ(struct mthca_dev *dev, int cq_num, u32 lkey, u8 log_size,
- u8 *status);
-int mthca_SW2HW_SRQ(struct mthca_dev *dev, struct mthca_mailbox *mailbox,
- int srq_num, u8 *status);
-int mthca_HW2SW_SRQ(struct mthca_dev *dev, struct mthca_mailbox *mailbox,
- int srq_num, u8 *status);
-int mthca_QUERY_SRQ(struct mthca_dev *dev, u32 num,
- struct mthca_mailbox *mailbox, u8 *status);
-int mthca_ARM_SRQ(struct mthca_dev *dev, int srq_num, int limit, u8 *status);
-int mthca_MODIFY_QP(struct mthca_dev *dev, enum ib_qp_state cur,
- enum ib_qp_state next, u32 num, int is_ee,
- struct mthca_mailbox *mailbox, u32 optmask,
- u8 *status);
-int mthca_QUERY_QP(struct mthca_dev *dev, u32 num, int is_ee,
- struct mthca_mailbox *mailbox, u8 *status);
-int mthca_CONF_SPECIAL_QP(struct mthca_dev *dev, int type, u32 qpn,
- u8 *status);
-int mthca_MAD_IFC(struct mthca_dev *dev, int ignore_mkey, int ignore_bkey,
- int port, struct ib_wc *in_wc, struct ib_grh *in_grh,
- void *in_mad, void *response_mad, u8 *status);
-int mthca_READ_MGM(struct mthca_dev *dev, int index,
- struct mthca_mailbox *mailbox, u8 *status);
-int mthca_WRITE_MGM(struct mthca_dev *dev, int index,
- struct mthca_mailbox *mailbox, u8 *status);
-int mthca_MGID_HASH(struct mthca_dev *dev, struct mthca_mailbox *mailbox,
- u16 *hash, u8 *status);
-int mthca_DIAG_RPRT(struct mthca_dev *dev, int mod,
- struct mthca_mailbox *mailbox, u8 *status);
-int mthca_NOP(struct mthca_dev *dev, u8 *status);
-
-#endif /* MTHCA_CMD_H */
diff --git a/sys/ofed/drivers/infiniband/hw/mthca/mthca_config_reg.h b/sys/ofed/drivers/infiniband/hw/mthca/mthca_config_reg.h
deleted file mode 100644
index 43c0894..0000000
--- a/sys/ofed/drivers/infiniband/hw/mthca/mthca_config_reg.h
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Copyright (c) 2004 Topspin Communications. All rights reserved.
- * Copyright (c) 2005 Mellanox Technologies. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-#ifndef MTHCA_CONFIG_REG_H
-#define MTHCA_CONFIG_REG_H
-
-#include <linux/page.h>
-
-#define MTHCA_HCR_BASE 0x80680
-#define MTHCA_HCR_SIZE 0x0001c
-#define MTHCA_ECR_BASE 0x80700
-#define MTHCA_ECR_SIZE 0x00008
-#define MTHCA_ECR_CLR_BASE 0x80708
-#define MTHCA_ECR_CLR_SIZE 0x00008
-#define MTHCA_MAP_ECR_SIZE (MTHCA_ECR_SIZE + MTHCA_ECR_CLR_SIZE)
-#define MTHCA_CLR_INT_BASE 0xf00d8
-#define MTHCA_CLR_INT_SIZE 0x00008
-#define MTHCA_EQ_SET_CI_SIZE (8 * 32)
-
-#endif /* MTHCA_CONFIG_REG_H */
diff --git a/sys/ofed/drivers/infiniband/hw/mthca/mthca_cq.c b/sys/ofed/drivers/infiniband/hw/mthca/mthca_cq.c
deleted file mode 100644
index aa75d26..0000000
--- a/sys/ofed/drivers/infiniband/hw/mthca/mthca_cq.c
+++ /dev/null
@@ -1,992 +0,0 @@
-/*
- * Copyright (c) 2004, 2005 Topspin Communications. All rights reserved.
- * Copyright (c) 2005 Sun Microsystems, Inc. All rights reserved.
- * Copyright (c) 2005, 2006 Cisco Systems, Inc. All rights reserved.
- * Copyright (c) 2005 Mellanox Technologies. All rights reserved.
- * Copyright (c) 2004 Voltaire, Inc. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-#include <linux/hardirq.h>
-#include <linux/sched.h>
-
-#include <asm/io.h>
-
-#include <rdma/ib_pack.h>
-
-#include "mthca_dev.h"
-#include "mthca_cmd.h"
-#include "mthca_memfree.h"
-
-enum {
- MTHCA_MAX_DIRECT_CQ_SIZE = 4 * PAGE_SIZE
-};
-
-enum {
- MTHCA_CQ_ENTRY_SIZE = 0x20
-};
-
-enum {
- MTHCA_ATOMIC_BYTE_LEN = 8
-};
-
-/*
- * Must be packed because start is 64 bits but only aligned to 32 bits.
- */
-struct mthca_cq_context {
- __be32 flags;
- __be64 start;
- __be32 logsize_usrpage;
- __be32 error_eqn; /* Tavor only */
- __be32 comp_eqn;
- __be32 pd;
- __be32 lkey;
- __be32 last_notified_index;
- __be32 solicit_producer_index;
- __be32 consumer_index;
- __be32 producer_index;
- __be32 cqn;
- __be32 ci_db; /* Arbel only */
- __be32 state_db; /* Arbel only */
- u32 reserved;
-} __attribute__((packed));
-
-#define MTHCA_CQ_STATUS_OK ( 0 << 28)
-#define MTHCA_CQ_STATUS_OVERFLOW ( 9 << 28)
-#define MTHCA_CQ_STATUS_WRITE_FAIL (10 << 28)
-#define MTHCA_CQ_FLAG_TR ( 1 << 18)
-#define MTHCA_CQ_FLAG_OI ( 1 << 17)
-#define MTHCA_CQ_STATE_DISARMED ( 0 << 8)
-#define MTHCA_CQ_STATE_ARMED ( 1 << 8)
-#define MTHCA_CQ_STATE_ARMED_SOL ( 4 << 8)
-#define MTHCA_EQ_STATE_FIRED (10 << 8)
-
-enum {
- MTHCA_ERROR_CQE_OPCODE_MASK = 0xfe
-};
-
-enum {
- SYNDROME_LOCAL_LENGTH_ERR = 0x01,
- SYNDROME_LOCAL_QP_OP_ERR = 0x02,
- SYNDROME_LOCAL_EEC_OP_ERR = 0x03,
- SYNDROME_LOCAL_PROT_ERR = 0x04,
- SYNDROME_WR_FLUSH_ERR = 0x05,
- SYNDROME_MW_BIND_ERR = 0x06,
- SYNDROME_BAD_RESP_ERR = 0x10,
- SYNDROME_LOCAL_ACCESS_ERR = 0x11,
- SYNDROME_REMOTE_INVAL_REQ_ERR = 0x12,
- SYNDROME_REMOTE_ACCESS_ERR = 0x13,
- SYNDROME_REMOTE_OP_ERR = 0x14,
- SYNDROME_RETRY_EXC_ERR = 0x15,
- SYNDROME_RNR_RETRY_EXC_ERR = 0x16,
- SYNDROME_LOCAL_RDD_VIOL_ERR = 0x20,
- SYNDROME_REMOTE_INVAL_RD_REQ_ERR = 0x21,
- SYNDROME_REMOTE_ABORTED_ERR = 0x22,
- SYNDROME_INVAL_EECN_ERR = 0x23,
- SYNDROME_INVAL_EEC_STATE_ERR = 0x24
-};
-
-struct mthca_cqe {
- __be32 my_qpn;
- __be32 my_ee;
- __be32 rqpn;
- u8 sl_ipok;
- u8 g_mlpath;
- __be16 rlid;
- __be32 imm_etype_pkey_eec;
- __be32 byte_cnt;
- __be32 wqe;
- u8 opcode;
- u8 is_send;
- u8 reserved;
- u8 owner;
-};
-
-struct mthca_err_cqe {
- __be32 my_qpn;
- u32 reserved1[3];
- u8 syndrome;
- u8 vendor_err;
- __be16 db_cnt;
- u32 reserved2;
- __be32 wqe;
- u8 opcode;
- u8 reserved3[2];
- u8 owner;
-};
-
-#define MTHCA_CQ_ENTRY_OWNER_SW (0 << 7)
-#define MTHCA_CQ_ENTRY_OWNER_HW (1 << 7)
-
-#define MTHCA_TAVOR_CQ_DB_INC_CI (1 << 24)
-#define MTHCA_TAVOR_CQ_DB_REQ_NOT (2 << 24)
-#define MTHCA_TAVOR_CQ_DB_REQ_NOT_SOL (3 << 24)
-#define MTHCA_TAVOR_CQ_DB_SET_CI (4 << 24)
-#define MTHCA_TAVOR_CQ_DB_REQ_NOT_MULT (5 << 24)
-
-#define MTHCA_ARBEL_CQ_DB_REQ_NOT_SOL (1 << 24)
-#define MTHCA_ARBEL_CQ_DB_REQ_NOT (2 << 24)
-#define MTHCA_ARBEL_CQ_DB_REQ_NOT_MULT (3 << 24)
-
-static inline struct mthca_cqe *get_cqe_from_buf(struct mthca_cq_buf *buf,
- int entry)
-{
- if (buf->is_direct)
- return buf->queue.direct.buf + (entry * MTHCA_CQ_ENTRY_SIZE);
- else
- return buf->queue.page_list[entry * MTHCA_CQ_ENTRY_SIZE / PAGE_SIZE].buf
- + (entry * MTHCA_CQ_ENTRY_SIZE) % PAGE_SIZE;
-}
-
-static inline struct mthca_cqe *get_cqe(struct mthca_cq *cq, int entry)
-{
- return get_cqe_from_buf(&cq->buf, entry);
-}
-
-static inline struct mthca_cqe *cqe_sw(struct mthca_cqe *cqe)
-{
- return MTHCA_CQ_ENTRY_OWNER_HW & cqe->owner ? NULL : cqe;
-}
-
-static inline struct mthca_cqe *next_cqe_sw(struct mthca_cq *cq)
-{
- return cqe_sw(get_cqe(cq, cq->cons_index & cq->ibcq.cqe));
-}
-
-static inline void set_cqe_hw(struct mthca_cqe *cqe)
-{
- cqe->owner = MTHCA_CQ_ENTRY_OWNER_HW;
-}
-
-static void dump_cqe(struct mthca_dev *dev, void *cqe_ptr)
-{
- __be32 *cqe = cqe_ptr;
-
- (void) cqe; /* avoid warning if mthca_dbg compiled away... */
- mthca_dbg(dev, "CQE contents %08x %08x %08x %08x %08x %08x %08x %08x\n",
- be32_to_cpu(cqe[0]), be32_to_cpu(cqe[1]), be32_to_cpu(cqe[2]),
- be32_to_cpu(cqe[3]), be32_to_cpu(cqe[4]), be32_to_cpu(cqe[5]),
- be32_to_cpu(cqe[6]), be32_to_cpu(cqe[7]));
-}
-
-/*
- * incr is ignored in native Arbel (mem-free) mode, so cq->cons_index
- * should be correct before calling update_cons_index().
- */
-static inline void update_cons_index(struct mthca_dev *dev, struct mthca_cq *cq,
- int incr)
-{
- if (mthca_is_memfree(dev)) {
- *cq->set_ci_db = cpu_to_be32(cq->cons_index);
- wmb();
- } else {
- mthca_write64(MTHCA_TAVOR_CQ_DB_INC_CI | cq->cqn, incr - 1,
- dev->kar + MTHCA_CQ_DOORBELL,
- MTHCA_GET_DOORBELL_LOCK(&dev->doorbell_lock));
- /*
- * Make sure doorbells don't leak out of CQ spinlock
- * and reach the HCA out of order:
- */
- mmiowb();
- }
-}
-
-void mthca_cq_completion(struct mthca_dev *dev, u32 cqn)
-{
- struct mthca_cq *cq;
-
- cq = mthca_array_get(&dev->cq_table.cq, cqn & (dev->limits.num_cqs - 1));
-
- if (!cq) {
- mthca_warn(dev, "Completion event for bogus CQ %08x\n", cqn);
- return;
- }
-
- ++cq->arm_sn;
-
- cq->ibcq.comp_handler(&cq->ibcq, cq->ibcq.cq_context);
-}
-
-void mthca_cq_event(struct mthca_dev *dev, u32 cqn,
- enum ib_event_type event_type)
-{
- struct mthca_cq *cq;
- struct ib_event event;
-
- spin_lock(&dev->cq_table.lock);
-
- cq = mthca_array_get(&dev->cq_table.cq, cqn & (dev->limits.num_cqs - 1));
- if (cq)
- ++cq->refcount;
-
- spin_unlock(&dev->cq_table.lock);
-
- if (!cq) {
- mthca_warn(dev, "Async event for bogus CQ %08x\n", cqn);
- return;
- }
-
- event.device = &dev->ib_dev;
- event.event = event_type;
- event.element.cq = &cq->ibcq;
- if (cq->ibcq.event_handler)
- cq->ibcq.event_handler(&event, cq->ibcq.cq_context);
-
- spin_lock(&dev->cq_table.lock);
- if (!--cq->refcount)
- wake_up(&cq->wait);
- spin_unlock(&dev->cq_table.lock);
-}
-
-static inline int is_recv_cqe(struct mthca_cqe *cqe)
-{
- if ((cqe->opcode & MTHCA_ERROR_CQE_OPCODE_MASK) ==
- MTHCA_ERROR_CQE_OPCODE_MASK)
- return !(cqe->opcode & 0x01);
- else
- return !(cqe->is_send & 0x80);
-}
-
-void mthca_cq_clean(struct mthca_dev *dev, struct mthca_cq *cq, u32 qpn,
- struct mthca_srq *srq)
-{
- struct mthca_cqe *cqe;
- u32 prod_index;
- int i, nfreed = 0;
-
- spin_lock_irq(&cq->lock);
-
- /*
- * First we need to find the current producer index, so we
- * know where to start cleaning from. It doesn't matter if HW
- * adds new entries after this loop -- the QP we're worried
- * about is already in RESET, so the new entries won't come
- * from our QP and therefore don't need to be checked.
- */
- for (prod_index = cq->cons_index;
- cqe_sw(get_cqe(cq, prod_index & cq->ibcq.cqe));
- ++prod_index)
- if (prod_index == cq->cons_index + cq->ibcq.cqe)
- break;
-
- if (0)
- mthca_dbg(dev, "Cleaning QPN %06x from CQN %06x; ci %d, pi %d\n",
- qpn, cq->cqn, cq->cons_index, prod_index);
-
- /*
- * Now sweep backwards through the CQ, removing CQ entries
- * that match our QP by copying older entries on top of them.
- */
- while ((int) --prod_index - (int) cq->cons_index >= 0) {
- cqe = get_cqe(cq, prod_index & cq->ibcq.cqe);
- if (cqe->my_qpn == cpu_to_be32(qpn)) {
- if (srq && is_recv_cqe(cqe))
- mthca_free_srq_wqe(srq, be32_to_cpu(cqe->wqe));
- ++nfreed;
- } else if (nfreed)
- memcpy(get_cqe(cq, (prod_index + nfreed) & cq->ibcq.cqe),
- cqe, MTHCA_CQ_ENTRY_SIZE);
- }
-
- if (nfreed) {
- for (i = 0; i < nfreed; ++i)
- set_cqe_hw(get_cqe(cq, (cq->cons_index + i) & cq->ibcq.cqe));
- wmb();
- cq->cons_index += nfreed;
- update_cons_index(dev, cq, nfreed);
- }
-
- spin_unlock_irq(&cq->lock);
-}
-
-void mthca_cq_resize_copy_cqes(struct mthca_cq *cq)
-{
- int i;
-
- /*
- * In Tavor mode, the hardware keeps the consumer and producer
- * indices mod the CQ size. Since we might be making the CQ
- * bigger, we need to deal with the case where the producer
- * index wrapped around before the CQ was resized.
- */
- if (!mthca_is_memfree(to_mdev(cq->ibcq.device)) &&
- cq->ibcq.cqe < cq->resize_buf->cqe) {
- cq->cons_index &= cq->ibcq.cqe;
- if (cqe_sw(get_cqe(cq, cq->ibcq.cqe)))
- cq->cons_index -= cq->ibcq.cqe + 1;
- }
-
- for (i = cq->cons_index; cqe_sw(get_cqe(cq, i & cq->ibcq.cqe)); ++i)
- memcpy(get_cqe_from_buf(&cq->resize_buf->buf,
- i & cq->resize_buf->cqe),
- get_cqe(cq, i & cq->ibcq.cqe), MTHCA_CQ_ENTRY_SIZE);
-}
-
-int mthca_alloc_cq_buf(struct mthca_dev *dev, struct mthca_cq_buf *buf, int nent)
-{
- int ret;
- int i;
-
- ret = mthca_buf_alloc(dev, nent * MTHCA_CQ_ENTRY_SIZE,
- MTHCA_MAX_DIRECT_CQ_SIZE,
- &buf->queue, &buf->is_direct,
- &dev->driver_pd, 1, &buf->mr);
- if (ret)
- return ret;
-
- for (i = 0; i < nent; ++i)
- set_cqe_hw(get_cqe_from_buf(buf, i));
-
- return 0;
-}
-
-void mthca_free_cq_buf(struct mthca_dev *dev, struct mthca_cq_buf *buf, int cqe)
-{
- mthca_buf_free(dev, (cqe + 1) * MTHCA_CQ_ENTRY_SIZE, &buf->queue,
- buf->is_direct, &buf->mr);
-}
-
-static void handle_error_cqe(struct mthca_dev *dev, struct mthca_cq *cq,
- struct mthca_qp *qp, int wqe_index, int is_send,
- struct mthca_err_cqe *cqe,
- struct ib_wc *entry, int *free_cqe)
-{
- int dbd;
- __be32 new_wqe;
-
- if (cqe->syndrome == SYNDROME_LOCAL_QP_OP_ERR) {
- mthca_dbg(dev, "local QP operation err "
- "(QPN %06x, WQE @ %08x, CQN %06x, index %d)\n",
- be32_to_cpu(cqe->my_qpn), be32_to_cpu(cqe->wqe),
- cq->cqn, cq->cons_index);
- dump_cqe(dev, cqe);
- }
-
- /*
- * For completions in error, only work request ID, status, vendor error
- * (and freed resource count for RD) have to be set.
- */
- switch (cqe->syndrome) {
- case SYNDROME_LOCAL_LENGTH_ERR:
- entry->status = IB_WC_LOC_LEN_ERR;
- break;
- case SYNDROME_LOCAL_QP_OP_ERR:
- entry->status = IB_WC_LOC_QP_OP_ERR;
- break;
- case SYNDROME_LOCAL_EEC_OP_ERR:
- entry->status = IB_WC_LOC_EEC_OP_ERR;
- break;
- case SYNDROME_LOCAL_PROT_ERR:
- entry->status = IB_WC_LOC_PROT_ERR;
- break;
- case SYNDROME_WR_FLUSH_ERR:
- entry->status = IB_WC_WR_FLUSH_ERR;
- break;
- case SYNDROME_MW_BIND_ERR:
- entry->status = IB_WC_MW_BIND_ERR;
- break;
- case SYNDROME_BAD_RESP_ERR:
- entry->status = IB_WC_BAD_RESP_ERR;
- break;
- case SYNDROME_LOCAL_ACCESS_ERR:
- entry->status = IB_WC_LOC_ACCESS_ERR;
- break;
- case SYNDROME_REMOTE_INVAL_REQ_ERR:
- entry->status = IB_WC_REM_INV_REQ_ERR;
- break;
- case SYNDROME_REMOTE_ACCESS_ERR:
- entry->status = IB_WC_REM_ACCESS_ERR;
- break;
- case SYNDROME_REMOTE_OP_ERR:
- entry->status = IB_WC_REM_OP_ERR;
- break;
- case SYNDROME_RETRY_EXC_ERR:
- entry->status = IB_WC_RETRY_EXC_ERR;
- break;
- case SYNDROME_RNR_RETRY_EXC_ERR:
- entry->status = IB_WC_RNR_RETRY_EXC_ERR;
- break;
- case SYNDROME_LOCAL_RDD_VIOL_ERR:
- entry->status = IB_WC_LOC_RDD_VIOL_ERR;
- break;
- case SYNDROME_REMOTE_INVAL_RD_REQ_ERR:
- entry->status = IB_WC_REM_INV_RD_REQ_ERR;
- break;
- case SYNDROME_REMOTE_ABORTED_ERR:
- entry->status = IB_WC_REM_ABORT_ERR;
- break;
- case SYNDROME_INVAL_EECN_ERR:
- entry->status = IB_WC_INV_EECN_ERR;
- break;
- case SYNDROME_INVAL_EEC_STATE_ERR:
- entry->status = IB_WC_INV_EEC_STATE_ERR;
- break;
- default:
- entry->status = IB_WC_GENERAL_ERR;
- break;
- }
-
- entry->vendor_err = cqe->vendor_err;
-
- /*
- * Mem-free HCAs always generate one CQE per WQE, even in the
- * error case, so we don't have to check the doorbell count, etc.
- */
- if (mthca_is_memfree(dev))
- return;
-
- mthca_free_err_wqe(dev, qp, is_send, wqe_index, &dbd, &new_wqe);
-
- /*
- * If we're at the end of the WQE chain, or we've used up our
- * doorbell count, free the CQE. Otherwise just update it for
- * the next poll operation.
- */
- if (!(new_wqe & cpu_to_be32(0x3f)) || (!cqe->db_cnt && dbd))
- return;
-
- be16_add_cpu(&cqe->db_cnt, -dbd);
- cqe->wqe = new_wqe;
- cqe->syndrome = SYNDROME_WR_FLUSH_ERR;
-
- *free_cqe = 0;
-}
-
-static inline int mthca_poll_one(struct mthca_dev *dev,
- struct mthca_cq *cq,
- struct mthca_qp **cur_qp,
- int *freed,
- struct ib_wc *entry)
-{
- struct mthca_wq *wq;
- struct mthca_cqe *cqe;
- int wqe_index;
- int is_error;
- int is_send;
- int free_cqe = 1;
- int err = 0;
- u16 checksum;
-
- cqe = next_cqe_sw(cq);
- if (!cqe)
- return -EAGAIN;
-
- /*
- * Make sure we read CQ entry contents after we've checked the
- * ownership bit.
- */
- rmb();
-
- if (0) {
- mthca_dbg(dev, "%x/%d: CQE -> QPN %06x, WQE @ %08x\n",
- cq->cqn, cq->cons_index, be32_to_cpu(cqe->my_qpn),
- be32_to_cpu(cqe->wqe));
- dump_cqe(dev, cqe);
- }
-
- is_error = (cqe->opcode & MTHCA_ERROR_CQE_OPCODE_MASK) ==
- MTHCA_ERROR_CQE_OPCODE_MASK;
- is_send = is_error ? cqe->opcode & 0x01 : cqe->is_send & 0x80;
-
- if (!*cur_qp || be32_to_cpu(cqe->my_qpn) != (*cur_qp)->qpn) {
- /*
- * We do not have to take the QP table lock here,
- * because CQs will be locked while QPs are removed
- * from the table.
- */
- *cur_qp = mthca_array_get(&dev->qp_table.qp,
- be32_to_cpu(cqe->my_qpn) &
- (dev->limits.num_qps - 1));
- if (!*cur_qp) {
- mthca_warn(dev, "CQ entry for unknown QP %06x\n",
- be32_to_cpu(cqe->my_qpn) & 0xffffff);
- err = -EINVAL;
- goto out;
- }
- }
-
- entry->qp = &(*cur_qp)->ibqp;
-
- if (is_send) {
- wq = &(*cur_qp)->sq;
- wqe_index = ((be32_to_cpu(cqe->wqe) - (*cur_qp)->send_wqe_offset)
- >> wq->wqe_shift);
- entry->wr_id = (*cur_qp)->wrid[wqe_index];
- } else if ((*cur_qp)->ibqp.srq) {
- struct mthca_srq *srq = to_msrq((*cur_qp)->ibqp.srq);
- u32 wqe = be32_to_cpu(cqe->wqe);
- wq = NULL;
- wqe_index = wqe >> srq->wqe_shift;
- entry->wr_id = srq->wrid[wqe_index];
- mthca_free_srq_wqe(srq, wqe);
- } else {
- s32 wqe;
- wq = &(*cur_qp)->rq;
- wqe = be32_to_cpu(cqe->wqe);
- wqe_index = wqe >> wq->wqe_shift;
- /*
- * WQE addr == base - 1 might be reported in receive completion
- * with error instead of (rq size - 1) by Sinai FW 1.0.800 and
- * Arbel FW 5.1.400. This bug should be fixed in later FW revs.
- */
- if (unlikely(wqe_index < 0))
- wqe_index = wq->max - 1;
- entry->wr_id = (*cur_qp)->wrid[wqe_index + (*cur_qp)->sq.max];
- }
-
- if (wq) {
- if (wq->last_comp < wqe_index)
- wq->tail += wqe_index - wq->last_comp;
- else
- wq->tail += wqe_index + wq->max - wq->last_comp;
-
- wq->last_comp = wqe_index;
- }
-
- if (is_error) {
- handle_error_cqe(dev, cq, *cur_qp, wqe_index, is_send,
- (struct mthca_err_cqe *) cqe,
- entry, &free_cqe);
- goto out;
- }
-
- if (is_send) {
- entry->wc_flags = 0;
- switch (cqe->opcode) {
- case MTHCA_OPCODE_RDMA_WRITE:
- entry->opcode = IB_WC_RDMA_WRITE;
- break;
- case MTHCA_OPCODE_RDMA_WRITE_IMM:
- entry->opcode = IB_WC_RDMA_WRITE;
- entry->wc_flags |= IB_WC_WITH_IMM;
- break;
- case MTHCA_OPCODE_SEND:
- entry->opcode = IB_WC_SEND;
- break;
- case MTHCA_OPCODE_SEND_IMM:
- entry->opcode = IB_WC_SEND;
- entry->wc_flags |= IB_WC_WITH_IMM;
- break;
- case MTHCA_OPCODE_RDMA_READ:
- entry->opcode = IB_WC_RDMA_READ;
- entry->byte_len = be32_to_cpu(cqe->byte_cnt);
- break;
- case MTHCA_OPCODE_ATOMIC_CS:
- entry->opcode = IB_WC_COMP_SWAP;
- entry->byte_len = MTHCA_ATOMIC_BYTE_LEN;
- break;
- case MTHCA_OPCODE_ATOMIC_FA:
- entry->opcode = IB_WC_FETCH_ADD;
- entry->byte_len = MTHCA_ATOMIC_BYTE_LEN;
- break;
- case MTHCA_OPCODE_BIND_MW:
- entry->opcode = IB_WC_BIND_MW;
- break;
- default:
- entry->opcode = MTHCA_OPCODE_INVALID;
- break;
- }
- } else {
- entry->byte_len = be32_to_cpu(cqe->byte_cnt);
- switch (cqe->opcode & 0x1f) {
- case IB_OPCODE_SEND_LAST_WITH_IMMEDIATE:
- case IB_OPCODE_SEND_ONLY_WITH_IMMEDIATE:
- entry->wc_flags = IB_WC_WITH_IMM;
- entry->ex.imm_data = cqe->imm_etype_pkey_eec;
- entry->opcode = IB_WC_RECV;
- break;
- case IB_OPCODE_RDMA_WRITE_LAST_WITH_IMMEDIATE:
- case IB_OPCODE_RDMA_WRITE_ONLY_WITH_IMMEDIATE:
- entry->wc_flags = IB_WC_WITH_IMM;
- entry->ex.imm_data = cqe->imm_etype_pkey_eec;
- entry->opcode = IB_WC_RECV_RDMA_WITH_IMM;
- break;
- default:
- entry->wc_flags = 0;
- entry->opcode = IB_WC_RECV;
- break;
- }
- entry->slid = be16_to_cpu(cqe->rlid);
- entry->sl = cqe->sl_ipok >> 4;
- entry->src_qp = be32_to_cpu(cqe->rqpn) & 0xffffff;
- entry->dlid_path_bits = cqe->g_mlpath & 0x7f;
- entry->pkey_index = be32_to_cpu(cqe->imm_etype_pkey_eec) >> 16;
- entry->wc_flags |= cqe->g_mlpath & 0x80 ? IB_WC_GRH : 0;
- checksum = (be32_to_cpu(cqe->rqpn) >> 24) |
- ((be32_to_cpu(cqe->my_ee) >> 16) & 0xff00);
- entry->csum_ok = (cqe->sl_ipok & 1 && checksum == 0xffff);
- }
-
- entry->status = IB_WC_SUCCESS;
-
- out:
- if (likely(free_cqe)) {
- set_cqe_hw(cqe);
- ++(*freed);
- ++cq->cons_index;
- }
-
- return err;
-}
-
-int mthca_poll_cq(struct ib_cq *ibcq, int num_entries,
- struct ib_wc *entry)
-{
- struct mthca_dev *dev = to_mdev(ibcq->device);
- struct mthca_cq *cq = to_mcq(ibcq);
- struct mthca_qp *qp = NULL;
- unsigned long flags;
- int err = 0;
- int freed = 0;
- int npolled;
-
- spin_lock_irqsave(&cq->lock, flags);
-
- npolled = 0;
-repoll:
- while (npolled < num_entries) {
- err = mthca_poll_one(dev, cq, &qp,
- &freed, entry + npolled);
- if (err)
- break;
- ++npolled;
- }
-
- if (freed) {
- wmb();
- update_cons_index(dev, cq, freed);
- }
-
- /*
- * If a CQ resize is in progress and we discovered that the
- * old buffer is empty, then peek in the new buffer, and if
- * it's not empty, switch to the new buffer and continue
- * polling there.
- */
- if (unlikely(err == -EAGAIN && cq->resize_buf &&
- cq->resize_buf->state == CQ_RESIZE_READY)) {
- /*
- * In Tavor mode, the hardware keeps the producer
- * index modulo the CQ size. Since we might be making
- * the CQ bigger, we need to mask our consumer index
- * using the size of the old CQ buffer before looking
- * in the new CQ buffer.
- */
- if (!mthca_is_memfree(dev))
- cq->cons_index &= cq->ibcq.cqe;
-
- if (cqe_sw(get_cqe_from_buf(&cq->resize_buf->buf,
- cq->cons_index & cq->resize_buf->cqe))) {
- struct mthca_cq_buf tbuf;
- int tcqe;
-
- tbuf = cq->buf;
- tcqe = cq->ibcq.cqe;
- cq->buf = cq->resize_buf->buf;
- cq->ibcq.cqe = cq->resize_buf->cqe;
-
- cq->resize_buf->buf = tbuf;
- cq->resize_buf->cqe = tcqe;
- cq->resize_buf->state = CQ_RESIZE_SWAPPED;
-
- goto repoll;
- }
- }
-
- spin_unlock_irqrestore(&cq->lock, flags);
-
- return err == 0 || err == -EAGAIN ? npolled : err;
-}
-
-int mthca_tavor_arm_cq(struct ib_cq *cq, enum ib_cq_notify_flags flags)
-{
- u32 dbhi = ((flags & IB_CQ_SOLICITED_MASK) == IB_CQ_SOLICITED ?
- MTHCA_TAVOR_CQ_DB_REQ_NOT_SOL :
- MTHCA_TAVOR_CQ_DB_REQ_NOT) |
- to_mcq(cq)->cqn;
-
- mthca_write64(dbhi, 0xffffffff, to_mdev(cq->device)->kar + MTHCA_CQ_DOORBELL,
- MTHCA_GET_DOORBELL_LOCK(&to_mdev(cq->device)->doorbell_lock));
-
- return 0;
-}
-
-int mthca_arbel_arm_cq(struct ib_cq *ibcq, enum ib_cq_notify_flags flags)
-{
- struct mthca_cq *cq = to_mcq(ibcq);
- __be32 db_rec[2];
- u32 dbhi;
- u32 sn = cq->arm_sn & 3;
-
- db_rec[0] = cpu_to_be32(cq->cons_index);
- db_rec[1] = cpu_to_be32((cq->cqn << 8) | (2 << 5) | (sn << 3) |
- ((flags & IB_CQ_SOLICITED_MASK) ==
- IB_CQ_SOLICITED ? 1 : 2));
-
- mthca_write_db_rec(db_rec, cq->arm_db);
-
- /*
- * Make sure that the doorbell record in host memory is
- * written before ringing the doorbell via PCI MMIO.
- */
- wmb();
-
- dbhi = (sn << 28) |
- ((flags & IB_CQ_SOLICITED_MASK) == IB_CQ_SOLICITED ?
- MTHCA_ARBEL_CQ_DB_REQ_NOT_SOL :
- MTHCA_ARBEL_CQ_DB_REQ_NOT) | cq->cqn;
-
- mthca_write64(dbhi, cq->cons_index,
- to_mdev(ibcq->device)->kar + MTHCA_CQ_DOORBELL,
- MTHCA_GET_DOORBELL_LOCK(&to_mdev(ibcq->device)->doorbell_lock));
-
- return 0;
-}
-
-int mthca_init_cq(struct mthca_dev *dev, int nent,
- struct mthca_ucontext *ctx, u32 pdn,
- struct mthca_cq *cq)
-{
- struct mthca_mailbox *mailbox;
- struct mthca_cq_context *cq_context;
- int err = -ENOMEM;
- u8 status;
-
- cq->ibcq.cqe = nent - 1;
- cq->is_kernel = !ctx;
-
- cq->cqn = mthca_alloc(&dev->cq_table.alloc);
- if (cq->cqn == -1)
- return -ENOMEM;
-
- if (mthca_is_memfree(dev)) {
- err = mthca_table_get(dev, dev->cq_table.table, cq->cqn);
- if (err)
- goto err_out;
-
- if (cq->is_kernel) {
- cq->arm_sn = 1;
-
- err = -ENOMEM;
-
- cq->set_ci_db_index = mthca_alloc_db(dev, MTHCA_DB_TYPE_CQ_SET_CI,
- cq->cqn, &cq->set_ci_db);
- if (cq->set_ci_db_index < 0)
- goto err_out_icm;
-
- cq->arm_db_index = mthca_alloc_db(dev, MTHCA_DB_TYPE_CQ_ARM,
- cq->cqn, &cq->arm_db);
- if (cq->arm_db_index < 0)
- goto err_out_ci;
- }
- }
-
- mailbox = mthca_alloc_mailbox(dev, GFP_KERNEL);
- if (IS_ERR(mailbox))
- goto err_out_arm;
-
- cq_context = mailbox->buf;
-
- if (cq->is_kernel) {
- err = mthca_alloc_cq_buf(dev, &cq->buf, nent);
- if (err)
- goto err_out_mailbox;
- }
-
- spin_lock_init(&cq->lock);
- cq->refcount = 1;
- init_waitqueue_head(&cq->wait);
- mutex_init(&cq->mutex);
-
- memset(cq_context, 0, sizeof *cq_context);
- cq_context->flags = cpu_to_be32(MTHCA_CQ_STATUS_OK |
- MTHCA_CQ_STATE_DISARMED |
- MTHCA_CQ_FLAG_TR);
- cq_context->logsize_usrpage = cpu_to_be32((ffs(nent) - 1) << 24);
- if (ctx)
- cq_context->logsize_usrpage |= cpu_to_be32(ctx->uar.index);
- else
- cq_context->logsize_usrpage |= cpu_to_be32(dev->driver_uar.index);
- cq_context->error_eqn = cpu_to_be32(dev->eq_table.eq[MTHCA_EQ_ASYNC].eqn);
- cq_context->comp_eqn = cpu_to_be32(dev->eq_table.eq[MTHCA_EQ_COMP].eqn);
- cq_context->pd = cpu_to_be32(pdn);
- cq_context->lkey = cpu_to_be32(cq->buf.mr.ibmr.lkey);
- cq_context->cqn = cpu_to_be32(cq->cqn);
-
- if (mthca_is_memfree(dev)) {
- cq_context->ci_db = cpu_to_be32(cq->set_ci_db_index);
- cq_context->state_db = cpu_to_be32(cq->arm_db_index);
- }
-
- err = mthca_SW2HW_CQ(dev, mailbox, cq->cqn, &status);
- if (err) {
- mthca_warn(dev, "SW2HW_CQ failed (%d)\n", err);
- goto err_out_free_mr;
- }
-
- if (status) {
- mthca_warn(dev, "SW2HW_CQ returned status 0x%02x\n",
- status);
- err = -EINVAL;
- goto err_out_free_mr;
- }
-
- spin_lock_irq(&dev->cq_table.lock);
- if (mthca_array_set(&dev->cq_table.cq,
- cq->cqn & (dev->limits.num_cqs - 1),
- cq)) {
- spin_unlock_irq(&dev->cq_table.lock);
- goto err_out_free_mr;
- }
- spin_unlock_irq(&dev->cq_table.lock);
-
- cq->cons_index = 0;
-
- mthca_free_mailbox(dev, mailbox);
-
- return 0;
-
-err_out_free_mr:
- if (cq->is_kernel)
- mthca_free_cq_buf(dev, &cq->buf, cq->ibcq.cqe);
-
-err_out_mailbox:
- mthca_free_mailbox(dev, mailbox);
-
-err_out_arm:
- if (cq->is_kernel && mthca_is_memfree(dev))
- mthca_free_db(dev, MTHCA_DB_TYPE_CQ_ARM, cq->arm_db_index);
-
-err_out_ci:
- if (cq->is_kernel && mthca_is_memfree(dev))
- mthca_free_db(dev, MTHCA_DB_TYPE_CQ_SET_CI, cq->set_ci_db_index);
-
-err_out_icm:
- mthca_table_put(dev, dev->cq_table.table, cq->cqn);
-
-err_out:
- mthca_free(&dev->cq_table.alloc, cq->cqn);
-
- return err;
-}
-
-static inline int get_cq_refcount(struct mthca_dev *dev, struct mthca_cq *cq)
-{
- int c;
-
- spin_lock_irq(&dev->cq_table.lock);
- c = cq->refcount;
- spin_unlock_irq(&dev->cq_table.lock);
-
- return c;
-}
-
-void mthca_free_cq(struct mthca_dev *dev,
- struct mthca_cq *cq)
-{
- struct mthca_mailbox *mailbox;
- int err;
- u8 status;
-
- mailbox = mthca_alloc_mailbox(dev, GFP_KERNEL);
- if (IS_ERR(mailbox)) {
- mthca_warn(dev, "No memory for mailbox to free CQ.\n");
- return;
- }
-
- err = mthca_HW2SW_CQ(dev, mailbox, cq->cqn, &status);
- if (err)
- mthca_warn(dev, "HW2SW_CQ failed (%d)\n", err);
- else if (status)
- mthca_warn(dev, "HW2SW_CQ returned status 0x%02x\n", status);
-
- if (0) {
- __be32 *ctx = mailbox->buf;
- int j;
-
- printk(KERN_ERR "context for CQN %x (cons index %x, next sw %d)\n",
- cq->cqn, cq->cons_index,
- cq->is_kernel ? !!next_cqe_sw(cq) : 0);
- for (j = 0; j < 16; ++j)
- printk(KERN_ERR "[%2x] %08x\n", j * 4, be32_to_cpu(ctx[j]));
- }
-
- spin_lock_irq(&dev->cq_table.lock);
- mthca_array_clear(&dev->cq_table.cq,
- cq->cqn & (dev->limits.num_cqs - 1));
- --cq->refcount;
- spin_unlock_irq(&dev->cq_table.lock);
-
- if (dev->mthca_flags & MTHCA_FLAG_MSI_X)
- synchronize_irq(dev->eq_table.eq[MTHCA_EQ_COMP].msi_x_vector);
- else
- synchronize_irq(dev->pdev->irq);
-
- wait_event(cq->wait, !get_cq_refcount(dev, cq));
-
- if (cq->is_kernel) {
- mthca_free_cq_buf(dev, &cq->buf, cq->ibcq.cqe);
- if (mthca_is_memfree(dev)) {
- mthca_free_db(dev, MTHCA_DB_TYPE_CQ_ARM, cq->arm_db_index);
- mthca_free_db(dev, MTHCA_DB_TYPE_CQ_SET_CI, cq->set_ci_db_index);
- }
- }
-
- mthca_table_put(dev, dev->cq_table.table, cq->cqn);
- mthca_free(&dev->cq_table.alloc, cq->cqn);
- mthca_free_mailbox(dev, mailbox);
-}
-
-int mthca_init_cq_table(struct mthca_dev *dev)
-{
- int err;
-
- spin_lock_init(&dev->cq_table.lock);
-
- err = mthca_alloc_init(&dev->cq_table.alloc,
- dev->limits.num_cqs,
- (1 << 24) - 1,
- dev->limits.reserved_cqs);
- if (err)
- return err;
-
- err = mthca_array_init(&dev->cq_table.cq,
- dev->limits.num_cqs);
- if (err)
- mthca_alloc_cleanup(&dev->cq_table.alloc);
-
- return err;
-}
-
-void mthca_cleanup_cq_table(struct mthca_dev *dev)
-{
- mthca_array_cleanup(&dev->cq_table.cq, dev->limits.num_cqs);
- mthca_alloc_cleanup(&dev->cq_table.alloc);
-}
diff --git a/sys/ofed/drivers/infiniband/hw/mthca/mthca_dev.h b/sys/ofed/drivers/infiniband/hw/mthca/mthca_dev.h
deleted file mode 100644
index a6dfc6d..0000000
--- a/sys/ofed/drivers/infiniband/hw/mthca/mthca_dev.h
+++ /dev/null
@@ -1,597 +0,0 @@
-/*
- * Copyright (c) 2004, 2005 Topspin Communications. All rights reserved.
- * Copyright (c) 2005 Sun Microsystems, Inc. All rights reserved.
- * Copyright (c) 2005, 2006 Cisco Systems. All rights reserved.
- * Copyright (c) 2005 Mellanox Technologies. All rights reserved.
- * Copyright (c) 2004 Voltaire, Inc. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-#ifndef MTHCA_DEV_H
-#define MTHCA_DEV_H
-
-#include <linux/spinlock.h>
-#include <linux/kernel.h>
-#include <linux/pci.h>
-#include <linux/dma-mapping.h>
-#include <linux/timer.h>
-#include <linux/mutex.h>
-#include <linux/list.h>
-#include <linux/semaphore.h>
-#include <linux/wait.h>
-
-#include "mthca_provider.h"
-#include "mthca_doorbell.h"
-
-#define DRV_NAME "ib_mthca"
-#define PFX DRV_NAME ": "
-#define DRV_VERSION "1.0-ofed1.5.2"
-#define DRV_RELDATE "August 4, 2010"
-
-enum {
- MTHCA_FLAG_DDR_HIDDEN = 1 << 1,
- MTHCA_FLAG_SRQ = 1 << 2,
- MTHCA_FLAG_MSI_X = 1 << 3,
- MTHCA_FLAG_NO_LAM = 1 << 4,
- MTHCA_FLAG_FMR = 1 << 5,
- MTHCA_FLAG_MEMFREE = 1 << 6,
- MTHCA_FLAG_PCIE = 1 << 7,
- MTHCA_FLAG_SINAI_OPT = 1 << 8
-};
-
-enum {
- MTHCA_MAX_PORTS = 2
-};
-
-enum {
- MTHCA_BOARD_ID_LEN = 64
-};
-
-enum {
- MTHCA_EQ_CONTEXT_SIZE = 0x40,
- MTHCA_CQ_CONTEXT_SIZE = 0x40,
- MTHCA_QP_CONTEXT_SIZE = 0x200,
- MTHCA_RDB_ENTRY_SIZE = 0x20,
- MTHCA_AV_SIZE = 0x20,
- MTHCA_MGM_ENTRY_SIZE = 0x100,
-
- /* Arbel FW gives us these, but we need them for Tavor */
- MTHCA_MPT_ENTRY_SIZE = 0x40,
- MTHCA_MTT_SEG_SIZE = 0x40,
-
- MTHCA_QP_PER_MGM = 4 * (MTHCA_MGM_ENTRY_SIZE / 16 - 2)
-};
-
-enum {
- MTHCA_EQ_CMD,
- MTHCA_EQ_ASYNC,
- MTHCA_EQ_COMP,
- MTHCA_NUM_EQ
-};
-
-enum {
- MTHCA_OPCODE_NOP = 0x00,
- MTHCA_OPCODE_RDMA_WRITE = 0x08,
- MTHCA_OPCODE_RDMA_WRITE_IMM = 0x09,
- MTHCA_OPCODE_SEND = 0x0a,
- MTHCA_OPCODE_SEND_IMM = 0x0b,
- MTHCA_OPCODE_RDMA_READ = 0x10,
- MTHCA_OPCODE_ATOMIC_CS = 0x11,
- MTHCA_OPCODE_ATOMIC_FA = 0x12,
- MTHCA_OPCODE_BIND_MW = 0x18,
- MTHCA_OPCODE_INVALID = 0xff
-};
-
-enum {
- MTHCA_CMD_USE_EVENTS = 1 << 0,
- MTHCA_CMD_POST_DOORBELLS = 1 << 1
-};
-
-enum {
- MTHCA_CMD_NUM_DBELL_DWORDS = 8
-};
-
-struct mthca_cmd {
- struct pci_pool *pool;
- struct mutex hcr_mutex;
- struct semaphore poll_sem;
- struct semaphore event_sem;
- int max_cmds;
- spinlock_t context_lock;
- int free_head;
- struct mthca_cmd_context *context;
- u16 token_mask;
- u32 flags;
- void __iomem *dbell_map;
- u16 dbell_offsets[MTHCA_CMD_NUM_DBELL_DWORDS];
-};
-
-struct mthca_limits {
- int num_ports;
- int vl_cap;
- int mtu_cap;
- int gid_table_len;
- int pkey_table_len;
- int local_ca_ack_delay;
- int num_uars;
- int max_sg;
- int num_qps;
- int max_wqes;
- int max_desc_sz;
- int max_qp_init_rdma;
- int reserved_qps;
- int num_srqs;
- int max_srq_wqes;
- int max_srq_sge;
- int reserved_srqs;
- int num_eecs;
- int reserved_eecs;
- int num_cqs;
- int max_cqes;
- int reserved_cqs;
- int num_eqs;
- int reserved_eqs;
- int num_mpts;
- int num_mtt_segs;
- int mtt_seg_size;
- int fmr_reserved_mtts;
- int reserved_mtts;
- int reserved_mrws;
- int reserved_uars;
- int num_mgms;
- int num_amgms;
- int reserved_mcgs;
- int num_pds;
- int reserved_pds;
- u32 page_size_cap;
- u32 flags;
- u16 stat_rate_support;
- u8 port_width_cap;
-};
-
-struct mthca_alloc {
- u32 last;
- u32 top;
- u32 max;
- u32 mask;
- spinlock_t lock;
- unsigned long *table;
-};
-
-struct mthca_array {
- struct {
- void **page;
- int used;
- } *page_list;
-};
-
-struct mthca_uar_table {
- struct mthca_alloc alloc;
- u64 uarc_base;
- int uarc_size;
-};
-
-struct mthca_pd_table {
- struct mthca_alloc alloc;
-};
-
-struct mthca_buddy {
- unsigned long **bits;
- int *num_free;
- int max_order;
- spinlock_t lock;
-};
-
-struct mthca_mr_table {
- struct mthca_alloc mpt_alloc;
- struct mthca_buddy mtt_buddy;
- struct mthca_buddy *fmr_mtt_buddy;
- u64 mtt_base;
- u64 mpt_base;
- struct mthca_icm_table *mtt_table;
- struct mthca_icm_table *mpt_table;
- struct {
- void __iomem *mpt_base;
- void __iomem *mtt_base;
- struct mthca_buddy mtt_buddy;
- } tavor_fmr;
-};
-
-struct mthca_eq_table {
- struct mthca_alloc alloc;
- void __iomem *clr_int;
- u32 clr_mask;
- u32 arm_mask;
- struct mthca_eq eq[MTHCA_NUM_EQ];
- u64 icm_virt;
- struct page *icm_page;
- dma_addr_t icm_dma;
- int have_irq;
- u8 inta_pin;
-};
-
-struct mthca_cq_table {
- struct mthca_alloc alloc;
- spinlock_t lock;
- struct mthca_array cq;
- struct mthca_icm_table *table;
-};
-
-struct mthca_srq_table {
- struct mthca_alloc alloc;
- spinlock_t lock;
- struct mthca_array srq;
- struct mthca_icm_table *table;
-};
-
-struct mthca_qp_table {
- struct mthca_alloc alloc;
- u32 rdb_base;
- int rdb_shift;
- int sqp_start;
- spinlock_t lock;
- struct mthca_array qp;
- struct mthca_icm_table *qp_table;
- struct mthca_icm_table *eqp_table;
- struct mthca_icm_table *rdb_table;
-};
-
-struct mthca_av_table {
- struct pci_pool *pool;
- int num_ddr_avs;
- u64 ddr_av_base;
- void __iomem *av_map;
- struct mthca_alloc alloc;
-};
-
-struct mthca_mcg_table {
- struct mutex mutex;
- struct mthca_alloc alloc;
- struct mthca_icm_table *table;
-};
-
-struct mthca_catas_err {
- u64 addr;
- u32 __iomem *map;
- u32 size;
- struct timer_list timer;
- struct list_head list;
-};
-
-extern struct mutex mthca_device_mutex;
-
-struct mthca_dev {
- struct ib_device ib_dev;
- struct pci_dev *pdev;
-
- int hca_type;
- unsigned long mthca_flags;
- unsigned long device_cap_flags;
-
- u32 rev_id;
- char board_id[MTHCA_BOARD_ID_LEN];
-
- /* firmware info */
- u64 fw_ver;
- union {
- struct {
- u64 fw_start;
- u64 fw_end;
- } tavor;
- struct {
- u64 clr_int_base;
- u64 eq_arm_base;
- u64 eq_set_ci_base;
- struct mthca_icm *fw_icm;
- struct mthca_icm *aux_icm;
- u16 fw_pages;
- } arbel;
- } fw;
-
- u64 ddr_start;
- u64 ddr_end;
-
- MTHCA_DECLARE_DOORBELL_LOCK(doorbell_lock)
- struct mutex cap_mask_mutex;
-
- void __iomem *hcr;
- void __iomem *kar;
- void __iomem *clr_base;
- union {
- struct {
- void __iomem *ecr_base;
- } tavor;
- struct {
- void __iomem *eq_arm;
- void __iomem *eq_set_ci_base;
- } arbel;
- } eq_regs;
-
- struct mthca_cmd cmd;
- struct mthca_limits limits;
-
- struct mthca_uar_table uar_table;
- struct mthca_pd_table pd_table;
- struct mthca_mr_table mr_table;
- struct mthca_eq_table eq_table;
- struct mthca_cq_table cq_table;
- struct mthca_srq_table srq_table;
- struct mthca_qp_table qp_table;
- struct mthca_av_table av_table;
- struct mthca_mcg_table mcg_table;
-
- struct mthca_catas_err catas_err;
-
- struct mthca_uar driver_uar;
- struct mthca_db_table *db_tab;
- struct mthca_pd driver_pd;
- struct mthca_mr driver_mr;
-
- struct ib_mad_agent *send_agent[MTHCA_MAX_PORTS][2];
- struct ib_ah *sm_ah[MTHCA_MAX_PORTS];
- spinlock_t sm_lock;
- u8 rate[MTHCA_MAX_PORTS];
- int active;
-};
-
-#ifdef CONFIG_INFINIBAND_MTHCA_DEBUG
-extern int mthca_debug_level;
-
-#define mthca_dbg(mdev, format, arg...) \
- do { \
- if (mthca_debug_level) \
- dev_printk(KERN_DEBUG, &mdev->pdev->dev, format, ## arg); \
- } while (0)
-
-#else /* CONFIG_INFINIBAND_MTHCA_DEBUG */
-
-#define mthca_dbg(mdev, format, arg...) do { (void) mdev; } while (0)
-
-#endif /* CONFIG_INFINIBAND_MTHCA_DEBUG */
-
-#define mthca_err(mdev, format, arg...) \
- dev_err(&mdev->pdev->dev, format, ## arg)
-#define mthca_info(mdev, format, arg...) \
- dev_info(&mdev->pdev->dev, format, ## arg)
-#define mthca_warn(mdev, format, arg...) \
- dev_warn(&mdev->pdev->dev, format, ## arg)
-
-extern void __buggy_use_of_MTHCA_GET(void);
-extern void __buggy_use_of_MTHCA_PUT(void);
-
-#define MTHCA_GET(dest, source, offset) \
- do { \
- void *__p = (char *) (source) + (offset); \
- switch (sizeof (dest)) { \
- case 1: (dest) = *(u8 *) __p; break; \
- case 2: (dest) = be16_to_cpup(__p); break; \
- case 4: (dest) = be32_to_cpup(__p); break; \
- case 8: (dest) = be64_to_cpup(__p); break; \
- default: __buggy_use_of_MTHCA_GET(); \
- } \
- } while (0)
-
-#define MTHCA_PUT(dest, source, offset) \
- do { \
- void *__d = ((char *) (dest) + (offset)); \
- switch (sizeof(source)) { \
- case 1: *(u8 *) __d = (source); break; \
- case 2: *(__be16 *) __d = cpu_to_be16(source); break; \
- case 4: *(__be32 *) __d = cpu_to_be32(source); break; \
- case 8: *(__be64 *) __d = cpu_to_be64(source); break; \
- default: __buggy_use_of_MTHCA_PUT(); \
- } \
- } while (0)
-
-int mthca_reset(struct mthca_dev *mdev);
-
-u32 mthca_alloc(struct mthca_alloc *alloc);
-void mthca_free(struct mthca_alloc *alloc, u32 obj);
-int mthca_alloc_init(struct mthca_alloc *alloc, u32 num, u32 mask,
- u32 reserved);
-void mthca_alloc_cleanup(struct mthca_alloc *alloc);
-void *mthca_array_get(struct mthca_array *array, int index);
-int mthca_array_set(struct mthca_array *array, int index, void *value);
-void mthca_array_clear(struct mthca_array *array, int index);
-int mthca_array_init(struct mthca_array *array, int nent);
-void mthca_array_cleanup(struct mthca_array *array, int nent);
-int mthca_buf_alloc(struct mthca_dev *dev, int size, int max_direct,
- union mthca_buf *buf, int *is_direct, struct mthca_pd *pd,
- int hca_write, struct mthca_mr *mr);
-void mthca_buf_free(struct mthca_dev *dev, int size, union mthca_buf *buf,
- int is_direct, struct mthca_mr *mr);
-
-int mthca_init_uar_table(struct mthca_dev *dev);
-int mthca_init_pd_table(struct mthca_dev *dev);
-int mthca_init_mr_table(struct mthca_dev *dev);
-int mthca_init_eq_table(struct mthca_dev *dev);
-int mthca_init_cq_table(struct mthca_dev *dev);
-int mthca_init_srq_table(struct mthca_dev *dev);
-int mthca_init_qp_table(struct mthca_dev *dev);
-int mthca_init_av_table(struct mthca_dev *dev);
-int mthca_init_mcg_table(struct mthca_dev *dev);
-
-void mthca_cleanup_uar_table(struct mthca_dev *dev);
-void mthca_cleanup_pd_table(struct mthca_dev *dev);
-void mthca_cleanup_mr_table(struct mthca_dev *dev);
-void mthca_cleanup_eq_table(struct mthca_dev *dev);
-void mthca_cleanup_cq_table(struct mthca_dev *dev);
-void mthca_cleanup_srq_table(struct mthca_dev *dev);
-void mthca_cleanup_qp_table(struct mthca_dev *dev);
-void mthca_cleanup_av_table(struct mthca_dev *dev);
-void mthca_cleanup_mcg_table(struct mthca_dev *dev);
-
-int mthca_register_device(struct mthca_dev *dev);
-void mthca_unregister_device(struct mthca_dev *dev);
-
-void mthca_start_catas_poll(struct mthca_dev *dev);
-void mthca_stop_catas_poll(struct mthca_dev *dev);
-int __mthca_restart_one(struct pci_dev *pdev);
-int mthca_catas_init(void);
-void mthca_catas_cleanup(void);
-
-int mthca_uar_alloc(struct mthca_dev *dev, struct mthca_uar *uar);
-void mthca_uar_free(struct mthca_dev *dev, struct mthca_uar *uar);
-
-int mthca_pd_alloc(struct mthca_dev *dev, int privileged, struct mthca_pd *pd);
-void mthca_pd_free(struct mthca_dev *dev, struct mthca_pd *pd);
-
-int mthca_write_mtt_size(struct mthca_dev *dev);
-
-struct mthca_mtt *mthca_alloc_mtt(struct mthca_dev *dev, int size);
-void mthca_free_mtt(struct mthca_dev *dev, struct mthca_mtt *mtt);
-int mthca_write_mtt(struct mthca_dev *dev, struct mthca_mtt *mtt,
- int start_index, u64 *buffer_list, int list_len);
-int mthca_mr_alloc(struct mthca_dev *dev, u32 pd, int buffer_size_shift,
- u64 iova, u64 total_size, u32 access, struct mthca_mr *mr);
-int mthca_mr_alloc_notrans(struct mthca_dev *dev, u32 pd,
- u32 access, struct mthca_mr *mr);
-int mthca_mr_alloc_phys(struct mthca_dev *dev, u32 pd,
- u64 *buffer_list, int buffer_size_shift,
- int list_len, u64 iova, u64 total_size,
- u32 access, struct mthca_mr *mr);
-void mthca_free_mr(struct mthca_dev *dev, struct mthca_mr *mr);
-
-int mthca_fmr_alloc(struct mthca_dev *dev, u32 pd,
- u32 access, struct mthca_fmr *fmr);
-int mthca_tavor_map_phys_fmr(struct ib_fmr *ibfmr, u64 *page_list,
- int list_len, u64 iova);
-void mthca_tavor_fmr_unmap(struct mthca_dev *dev, struct mthca_fmr *fmr);
-int mthca_arbel_map_phys_fmr(struct ib_fmr *ibfmr, u64 *page_list,
- int list_len, u64 iova);
-void mthca_arbel_fmr_unmap(struct mthca_dev *dev, struct mthca_fmr *fmr);
-int mthca_free_fmr(struct mthca_dev *dev, struct mthca_fmr *fmr);
-
-int mthca_map_eq_icm(struct mthca_dev *dev, u64 icm_virt);
-void mthca_unmap_eq_icm(struct mthca_dev *dev);
-
-int mthca_poll_cq(struct ib_cq *ibcq, int num_entries,
- struct ib_wc *entry);
-int mthca_tavor_arm_cq(struct ib_cq *cq, enum ib_cq_notify_flags flags);
-int mthca_arbel_arm_cq(struct ib_cq *cq, enum ib_cq_notify_flags flags);
-int mthca_init_cq(struct mthca_dev *dev, int nent,
- struct mthca_ucontext *ctx, u32 pdn,
- struct mthca_cq *cq);
-void mthca_free_cq(struct mthca_dev *dev,
- struct mthca_cq *cq);
-void mthca_cq_completion(struct mthca_dev *dev, u32 cqn);
-void mthca_cq_event(struct mthca_dev *dev, u32 cqn,
- enum ib_event_type event_type);
-void mthca_cq_clean(struct mthca_dev *dev, struct mthca_cq *cq, u32 qpn,
- struct mthca_srq *srq);
-void mthca_cq_resize_copy_cqes(struct mthca_cq *cq);
-int mthca_alloc_cq_buf(struct mthca_dev *dev, struct mthca_cq_buf *buf, int nent);
-void mthca_free_cq_buf(struct mthca_dev *dev, struct mthca_cq_buf *buf, int cqe);
-
-int mthca_alloc_srq(struct mthca_dev *dev, struct mthca_pd *pd,
- struct ib_srq_attr *attr, struct mthca_srq *srq);
-void mthca_free_srq(struct mthca_dev *dev, struct mthca_srq *srq);
-int mthca_modify_srq(struct ib_srq *ibsrq, struct ib_srq_attr *attr,
- enum ib_srq_attr_mask attr_mask, struct ib_udata *udata);
-int mthca_query_srq(struct ib_srq *srq, struct ib_srq_attr *srq_attr);
-int mthca_max_srq_sge(struct mthca_dev *dev);
-void mthca_srq_event(struct mthca_dev *dev, u32 srqn,
- enum ib_event_type event_type);
-void mthca_free_srq_wqe(struct mthca_srq *srq, u32 wqe_addr);
-int mthca_tavor_post_srq_recv(struct ib_srq *srq, struct ib_recv_wr *wr,
- struct ib_recv_wr **bad_wr);
-int mthca_arbel_post_srq_recv(struct ib_srq *srq, struct ib_recv_wr *wr,
- struct ib_recv_wr **bad_wr);
-
-void mthca_qp_event(struct mthca_dev *dev, u32 qpn,
- enum ib_event_type event_type);
-int mthca_query_qp(struct ib_qp *ibqp, struct ib_qp_attr *qp_attr, int qp_attr_mask,
- struct ib_qp_init_attr *qp_init_attr);
-int mthca_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr, int attr_mask,
- struct ib_udata *udata);
-int mthca_tavor_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr,
- struct ib_send_wr **bad_wr);
-int mthca_tavor_post_receive(struct ib_qp *ibqp, struct ib_recv_wr *wr,
- struct ib_recv_wr **bad_wr);
-int mthca_arbel_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr,
- struct ib_send_wr **bad_wr);
-int mthca_arbel_post_receive(struct ib_qp *ibqp, struct ib_recv_wr *wr,
- struct ib_recv_wr **bad_wr);
-void mthca_free_err_wqe(struct mthca_dev *dev, struct mthca_qp *qp, int is_send,
- int index, int *dbd, __be32 *new_wqe);
-int mthca_alloc_qp(struct mthca_dev *dev,
- struct mthca_pd *pd,
- struct mthca_cq *send_cq,
- struct mthca_cq *recv_cq,
- enum ib_qp_type type,
- enum ib_sig_type send_policy,
- struct ib_qp_cap *cap,
- struct mthca_qp *qp);
-int mthca_alloc_sqp(struct mthca_dev *dev,
- struct mthca_pd *pd,
- struct mthca_cq *send_cq,
- struct mthca_cq *recv_cq,
- enum ib_sig_type send_policy,
- struct ib_qp_cap *cap,
- int qpn,
- int port,
- struct mthca_sqp *sqp);
-void mthca_free_qp(struct mthca_dev *dev, struct mthca_qp *qp);
-int mthca_create_ah(struct mthca_dev *dev,
- struct mthca_pd *pd,
- struct ib_ah_attr *ah_attr,
- struct mthca_ah *ah);
-int mthca_destroy_ah(struct mthca_dev *dev, struct mthca_ah *ah);
-int mthca_read_ah(struct mthca_dev *dev, struct mthca_ah *ah,
- struct ib_ud_header *header);
-int mthca_ah_query(struct ib_ah *ibah, struct ib_ah_attr *attr);
-int mthca_ah_grh_present(struct mthca_ah *ah);
-u8 mthca_get_rate(struct mthca_dev *dev, int static_rate, u8 port);
-enum ib_rate mthca_rate_to_ib(struct mthca_dev *dev, u8 mthca_rate, u8 port);
-
-int mthca_multicast_attach(struct ib_qp *ibqp, union ib_gid *gid, u16 lid);
-int mthca_multicast_detach(struct ib_qp *ibqp, union ib_gid *gid, u16 lid);
-
-int mthca_process_mad(struct ib_device *ibdev,
- int mad_flags,
- u8 port_num,
- struct ib_wc *in_wc,
- struct ib_grh *in_grh,
- struct ib_mad *in_mad,
- struct ib_mad *out_mad);
-int mthca_create_agents(struct mthca_dev *dev);
-void mthca_free_agents(struct mthca_dev *dev);
-
-static inline struct mthca_dev *to_mdev(struct ib_device *ibdev)
-{
- return container_of(ibdev, struct mthca_dev, ib_dev);
-}
-
-static inline int mthca_is_memfree(struct mthca_dev *dev)
-{
- return dev->mthca_flags & MTHCA_FLAG_MEMFREE;
-}
-
-#endif /* MTHCA_DEV_H */
diff --git a/sys/ofed/drivers/infiniband/hw/mthca/mthca_eq.c b/sys/ofed/drivers/infiniband/hw/mthca/mthca_eq.c
deleted file mode 100644
index 90e4e45..0000000
--- a/sys/ofed/drivers/infiniband/hw/mthca/mthca_eq.c
+++ /dev/null
@@ -1,920 +0,0 @@
-/*
- * Copyright (c) 2004, 2005 Topspin Communications. All rights reserved.
- * Copyright (c) 2005 Mellanox Technologies. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-#include <linux/errno.h>
-#include <linux/interrupt.h>
-#include <linux/pci.h>
-
-#include "mthca_dev.h"
-#include "mthca_cmd.h"
-#include "mthca_config_reg.h"
-
-enum {
- MTHCA_NUM_ASYNC_EQE = 0x80,
- MTHCA_NUM_CMD_EQE = 0x80,
- MTHCA_NUM_SPARE_EQE = 0x80,
- MTHCA_EQ_ENTRY_SIZE = 0x20
-};
-
-/*
- * Must be packed because start is 64 bits but only aligned to 32 bits.
- */
-struct mthca_eq_context {
- __be32 flags;
- __be64 start;
- __be32 logsize_usrpage;
- __be32 tavor_pd; /* reserved for Arbel */
- u8 reserved1[3];
- u8 intr;
- __be32 arbel_pd; /* lost_count for Tavor */
- __be32 lkey;
- u32 reserved2[2];
- __be32 consumer_index;
- __be32 producer_index;
- u32 reserved3[4];
-} __attribute__((packed));
-
-#define MTHCA_EQ_STATUS_OK ( 0 << 28)
-#define MTHCA_EQ_STATUS_OVERFLOW ( 9 << 28)
-#define MTHCA_EQ_STATUS_WRITE_FAIL (10 << 28)
-#define MTHCA_EQ_OWNER_SW ( 0 << 24)
-#define MTHCA_EQ_OWNER_HW ( 1 << 24)
-#define MTHCA_EQ_FLAG_TR ( 1 << 18)
-#define MTHCA_EQ_FLAG_OI ( 1 << 17)
-#define MTHCA_EQ_STATE_ARMED ( 1 << 8)
-#define MTHCA_EQ_STATE_FIRED ( 2 << 8)
-#define MTHCA_EQ_STATE_ALWAYS_ARMED ( 3 << 8)
-#define MTHCA_EQ_STATE_ARBEL ( 8 << 8)
-
-enum {
- MTHCA_EVENT_TYPE_COMP = 0x00,
- MTHCA_EVENT_TYPE_PATH_MIG = 0x01,
- MTHCA_EVENT_TYPE_COMM_EST = 0x02,
- MTHCA_EVENT_TYPE_SQ_DRAINED = 0x03,
- MTHCA_EVENT_TYPE_SRQ_QP_LAST_WQE = 0x13,
- MTHCA_EVENT_TYPE_SRQ_LIMIT = 0x14,
- MTHCA_EVENT_TYPE_CQ_ERROR = 0x04,
- MTHCA_EVENT_TYPE_WQ_CATAS_ERROR = 0x05,
- MTHCA_EVENT_TYPE_EEC_CATAS_ERROR = 0x06,
- MTHCA_EVENT_TYPE_PATH_MIG_FAILED = 0x07,
- MTHCA_EVENT_TYPE_WQ_INVAL_REQ_ERROR = 0x10,
- MTHCA_EVENT_TYPE_WQ_ACCESS_ERROR = 0x11,
- MTHCA_EVENT_TYPE_SRQ_CATAS_ERROR = 0x12,
- MTHCA_EVENT_TYPE_LOCAL_CATAS_ERROR = 0x08,
- MTHCA_EVENT_TYPE_PORT_CHANGE = 0x09,
- MTHCA_EVENT_TYPE_EQ_OVERFLOW = 0x0f,
- MTHCA_EVENT_TYPE_ECC_DETECT = 0x0e,
- MTHCA_EVENT_TYPE_CMD = 0x0a
-};
-
-#define MTHCA_ASYNC_EVENT_MASK ((1ULL << MTHCA_EVENT_TYPE_PATH_MIG) | \
- (1ULL << MTHCA_EVENT_TYPE_COMM_EST) | \
- (1ULL << MTHCA_EVENT_TYPE_SQ_DRAINED) | \
- (1ULL << MTHCA_EVENT_TYPE_CQ_ERROR) | \
- (1ULL << MTHCA_EVENT_TYPE_WQ_CATAS_ERROR) | \
- (1ULL << MTHCA_EVENT_TYPE_EEC_CATAS_ERROR) | \
- (1ULL << MTHCA_EVENT_TYPE_PATH_MIG_FAILED) | \
- (1ULL << MTHCA_EVENT_TYPE_WQ_INVAL_REQ_ERROR) | \
- (1ULL << MTHCA_EVENT_TYPE_WQ_ACCESS_ERROR) | \
- (1ULL << MTHCA_EVENT_TYPE_LOCAL_CATAS_ERROR) | \
- (1ULL << MTHCA_EVENT_TYPE_PORT_CHANGE) | \
- (1ULL << MTHCA_EVENT_TYPE_ECC_DETECT))
-#define MTHCA_SRQ_EVENT_MASK ((1ULL << MTHCA_EVENT_TYPE_SRQ_CATAS_ERROR) | \
- (1ULL << MTHCA_EVENT_TYPE_SRQ_QP_LAST_WQE) | \
- (1ULL << MTHCA_EVENT_TYPE_SRQ_LIMIT))
-#define MTHCA_CMD_EVENT_MASK (1ULL << MTHCA_EVENT_TYPE_CMD)
-
-#define MTHCA_EQ_DB_INC_CI (1 << 24)
-#define MTHCA_EQ_DB_REQ_NOT (2 << 24)
-#define MTHCA_EQ_DB_DISARM_CQ (3 << 24)
-#define MTHCA_EQ_DB_SET_CI (4 << 24)
-#define MTHCA_EQ_DB_ALWAYS_ARM (5 << 24)
-
-struct mthca_eqe {
- u8 reserved1;
- u8 type;
- u8 reserved2;
- u8 subtype;
- union {
- u32 raw[6];
- struct {
- __be32 cqn;
- } __attribute__((packed)) comp;
- struct {
- u16 reserved1;
- __be16 token;
- u32 reserved2;
- u8 reserved3[3];
- u8 status;
- __be64 out_param;
- } __attribute__((packed)) cmd;
- struct {
- __be32 qpn;
- } __attribute__((packed)) qp;
- struct {
- __be32 srqn;
- } __attribute__((packed)) srq;
- struct {
- __be32 cqn;
- u32 reserved1;
- u8 reserved2[3];
- u8 syndrome;
- } __attribute__((packed)) cq_err;
- struct {
- u32 reserved1[2];
- __be32 port;
- } __attribute__((packed)) port_change;
- } event;
- u8 reserved3[3];
- u8 owner;
-} __attribute__((packed));
-
-#define MTHCA_EQ_ENTRY_OWNER_SW (0 << 7)
-#define MTHCA_EQ_ENTRY_OWNER_HW (1 << 7)
-
-static inline u64 async_mask(struct mthca_dev *dev)
-{
- return dev->mthca_flags & MTHCA_FLAG_SRQ ?
- MTHCA_ASYNC_EVENT_MASK | MTHCA_SRQ_EVENT_MASK :
- MTHCA_ASYNC_EVENT_MASK;
-}
-
-static inline void tavor_set_eq_ci(struct mthca_dev *dev, struct mthca_eq *eq, u32 ci)
-{
- /*
- * This barrier makes sure that all updates to ownership bits
- * done by set_eqe_hw() hit memory before the consumer index
- * is updated. set_eq_ci() allows the HCA to possibly write
- * more EQ entries, and we want to avoid the exceedingly
- * unlikely possibility of the HCA writing an entry and then
- * having set_eqe_hw() overwrite the owner field.
- */
- wmb();
- mthca_write64(MTHCA_EQ_DB_SET_CI | eq->eqn, ci & (eq->nent - 1),
- dev->kar + MTHCA_EQ_DOORBELL,
- MTHCA_GET_DOORBELL_LOCK(&dev->doorbell_lock));
-}
-
-static inline void arbel_set_eq_ci(struct mthca_dev *dev, struct mthca_eq *eq, u32 ci)
-{
- /* See comment in tavor_set_eq_ci() above. */
- wmb();
- __raw_writel((__force u32) cpu_to_be32(ci),
- dev->eq_regs.arbel.eq_set_ci_base + eq->eqn * 8);
- /* We still want ordering, just not swabbing, so add a barrier */
- mb();
-}
-
-static inline void set_eq_ci(struct mthca_dev *dev, struct mthca_eq *eq, u32 ci)
-{
- if (mthca_is_memfree(dev))
- arbel_set_eq_ci(dev, eq, ci);
- else
- tavor_set_eq_ci(dev, eq, ci);
-}
-
-static inline void tavor_eq_req_not(struct mthca_dev *dev, int eqn)
-{
- mthca_write64(MTHCA_EQ_DB_REQ_NOT | eqn, 0,
- dev->kar + MTHCA_EQ_DOORBELL,
- MTHCA_GET_DOORBELL_LOCK(&dev->doorbell_lock));
-}
-
-static inline void arbel_eq_req_not(struct mthca_dev *dev, u32 eqn_mask)
-{
- writel(eqn_mask, dev->eq_regs.arbel.eq_arm);
-}
-
-static inline void disarm_cq(struct mthca_dev *dev, int eqn, int cqn)
-{
- if (!mthca_is_memfree(dev)) {
- mthca_write64(MTHCA_EQ_DB_DISARM_CQ | eqn, cqn,
- dev->kar + MTHCA_EQ_DOORBELL,
- MTHCA_GET_DOORBELL_LOCK(&dev->doorbell_lock));
- }
-}
-
-static inline struct mthca_eqe *get_eqe(struct mthca_eq *eq, u32 entry)
-{
- unsigned long off = (entry & (eq->nent - 1)) * MTHCA_EQ_ENTRY_SIZE;
- return eq->page_list[off / PAGE_SIZE].buf + off % PAGE_SIZE;
-}
-
-static inline struct mthca_eqe *next_eqe_sw(struct mthca_eq *eq)
-{
- struct mthca_eqe *eqe;
- eqe = get_eqe(eq, eq->cons_index);
- return (MTHCA_EQ_ENTRY_OWNER_HW & eqe->owner) ? NULL : eqe;
-}
-
-static inline void set_eqe_hw(struct mthca_eqe *eqe)
-{
- eqe->owner = MTHCA_EQ_ENTRY_OWNER_HW;
-}
-
-static void port_change(struct mthca_dev *dev, int port, int active)
-{
- struct ib_event record;
-
- mthca_dbg(dev, "Port change to %s for port %d\n",
- active ? "active" : "down", port);
-
- record.device = &dev->ib_dev;
- record.event = active ? IB_EVENT_PORT_ACTIVE : IB_EVENT_PORT_ERR;
- record.element.port_num = port;
-
- ib_dispatch_event(&record);
-}
-
-static int mthca_eq_int(struct mthca_dev *dev, struct mthca_eq *eq)
-{
- struct mthca_eqe *eqe;
- int disarm_cqn;
- int eqes_found = 0;
- int set_ci = 0;
-
- while ((eqe = next_eqe_sw(eq))) {
- /*
- * Make sure we read EQ entry contents after we've
- * checked the ownership bit.
- */
- rmb();
-
- switch (eqe->type) {
- case MTHCA_EVENT_TYPE_COMP:
- disarm_cqn = be32_to_cpu(eqe->event.comp.cqn) & 0xffffff;
- disarm_cq(dev, eq->eqn, disarm_cqn);
- mthca_cq_completion(dev, disarm_cqn);
- break;
-
- case MTHCA_EVENT_TYPE_PATH_MIG:
- mthca_qp_event(dev, be32_to_cpu(eqe->event.qp.qpn) & 0xffffff,
- IB_EVENT_PATH_MIG);
- break;
-
- case MTHCA_EVENT_TYPE_COMM_EST:
- mthca_qp_event(dev, be32_to_cpu(eqe->event.qp.qpn) & 0xffffff,
- IB_EVENT_COMM_EST);
- break;
-
- case MTHCA_EVENT_TYPE_SQ_DRAINED:
- mthca_qp_event(dev, be32_to_cpu(eqe->event.qp.qpn) & 0xffffff,
- IB_EVENT_SQ_DRAINED);
- break;
-
- case MTHCA_EVENT_TYPE_SRQ_QP_LAST_WQE:
- mthca_qp_event(dev, be32_to_cpu(eqe->event.qp.qpn) & 0xffffff,
- IB_EVENT_QP_LAST_WQE_REACHED);
- break;
-
- case MTHCA_EVENT_TYPE_SRQ_LIMIT:
- mthca_srq_event(dev, be32_to_cpu(eqe->event.srq.srqn) & 0xffffff,
- IB_EVENT_SRQ_LIMIT_REACHED);
- break;
-
- case MTHCA_EVENT_TYPE_WQ_CATAS_ERROR:
- mthca_qp_event(dev, be32_to_cpu(eqe->event.qp.qpn) & 0xffffff,
- IB_EVENT_QP_FATAL);
- break;
-
- case MTHCA_EVENT_TYPE_PATH_MIG_FAILED:
- mthca_qp_event(dev, be32_to_cpu(eqe->event.qp.qpn) & 0xffffff,
- IB_EVENT_PATH_MIG_ERR);
- break;
-
- case MTHCA_EVENT_TYPE_WQ_INVAL_REQ_ERROR:
- mthca_qp_event(dev, be32_to_cpu(eqe->event.qp.qpn) & 0xffffff,
- IB_EVENT_QP_REQ_ERR);
- break;
-
- case MTHCA_EVENT_TYPE_WQ_ACCESS_ERROR:
- mthca_qp_event(dev, be32_to_cpu(eqe->event.qp.qpn) & 0xffffff,
- IB_EVENT_QP_ACCESS_ERR);
- break;
-
- case MTHCA_EVENT_TYPE_CMD:
- mthca_cmd_event(dev,
- be16_to_cpu(eqe->event.cmd.token),
- eqe->event.cmd.status,
- be64_to_cpu(eqe->event.cmd.out_param));
- break;
-
- case MTHCA_EVENT_TYPE_PORT_CHANGE:
- port_change(dev,
- (be32_to_cpu(eqe->event.port_change.port) >> 28) & 3,
- eqe->subtype == 0x4);
- break;
-
- case MTHCA_EVENT_TYPE_CQ_ERROR:
- mthca_warn(dev, "CQ %s on CQN %06x\n",
- eqe->event.cq_err.syndrome == 1 ?
- "overrun" : "access violation",
- be32_to_cpu(eqe->event.cq_err.cqn) & 0xffffff);
- mthca_cq_event(dev, be32_to_cpu(eqe->event.cq_err.cqn),
- IB_EVENT_CQ_ERR);
- break;
-
- case MTHCA_EVENT_TYPE_EQ_OVERFLOW:
- mthca_warn(dev, "EQ overrun on EQN %d\n", eq->eqn);
- break;
-
- case MTHCA_EVENT_TYPE_EEC_CATAS_ERROR:
- case MTHCA_EVENT_TYPE_SRQ_CATAS_ERROR:
- case MTHCA_EVENT_TYPE_LOCAL_CATAS_ERROR:
- case MTHCA_EVENT_TYPE_ECC_DETECT:
- default:
- mthca_warn(dev, "Unhandled event %02x(%02x) on EQ %d\n",
- eqe->type, eqe->subtype, eq->eqn);
- break;
- };
-
- set_eqe_hw(eqe);
- ++eq->cons_index;
- eqes_found = 1;
- ++set_ci;
-
- /*
- * The HCA will think the queue has overflowed if we
- * don't tell it we've been processing events. We
- * create our EQs with MTHCA_NUM_SPARE_EQE extra
- * entries, so we must update our consumer index at
- * least that often.
- */
- if (unlikely(set_ci >= MTHCA_NUM_SPARE_EQE)) {
- /*
- * Conditional on hca_type is OK here because
- * this is a rare case, not the fast path.
- */
- set_eq_ci(dev, eq, eq->cons_index);
- set_ci = 0;
- }
- }
-
- /*
- * Rely on caller to set consumer index so that we don't have
- * to test hca_type in our interrupt handling fast path.
- */
- return eqes_found;
-}
-
-static irqreturn_t mthca_tavor_interrupt(int irq, void *dev_ptr)
-{
- struct mthca_dev *dev = dev_ptr;
- u32 ecr;
- int i;
-
- if (dev->eq_table.clr_mask)
- writel(dev->eq_table.clr_mask, dev->eq_table.clr_int);
-
- ecr = readl(dev->eq_regs.tavor.ecr_base + 4);
- if (!ecr)
- return IRQ_NONE;
-
- writel(ecr, dev->eq_regs.tavor.ecr_base +
- MTHCA_ECR_CLR_BASE - MTHCA_ECR_BASE + 4);
-
- for (i = 0; i < MTHCA_NUM_EQ; ++i)
- if (ecr & dev->eq_table.eq[i].eqn_mask) {
- if (mthca_eq_int(dev, &dev->eq_table.eq[i]))
- tavor_set_eq_ci(dev, &dev->eq_table.eq[i],
- dev->eq_table.eq[i].cons_index);
- tavor_eq_req_not(dev, dev->eq_table.eq[i].eqn);
- }
-
- return IRQ_HANDLED;
-}
-
-static irqreturn_t mthca_tavor_msi_x_interrupt(int irq, void *eq_ptr)
-{
- struct mthca_eq *eq = eq_ptr;
- struct mthca_dev *dev = eq->dev;
-
- mthca_eq_int(dev, eq);
- tavor_set_eq_ci(dev, eq, eq->cons_index);
- tavor_eq_req_not(dev, eq->eqn);
-
- /* MSI-X vectors always belong to us */
- return IRQ_HANDLED;
-}
-
-static irqreturn_t mthca_arbel_interrupt(int irq, void *dev_ptr)
-{
- struct mthca_dev *dev = dev_ptr;
- int work = 0;
- int i;
-
- if (dev->eq_table.clr_mask)
- writel(dev->eq_table.clr_mask, dev->eq_table.clr_int);
-
- for (i = 0; i < MTHCA_NUM_EQ; ++i)
- if (mthca_eq_int(dev, &dev->eq_table.eq[i])) {
- work = 1;
- arbel_set_eq_ci(dev, &dev->eq_table.eq[i],
- dev->eq_table.eq[i].cons_index);
- }
-
- arbel_eq_req_not(dev, dev->eq_table.arm_mask);
-
- return IRQ_RETVAL(work);
-}
-
-static irqreturn_t mthca_arbel_msi_x_interrupt(int irq, void *eq_ptr)
-{
- struct mthca_eq *eq = eq_ptr;
- struct mthca_dev *dev = eq->dev;
-
- mthca_eq_int(dev, eq);
- arbel_set_eq_ci(dev, eq, eq->cons_index);
- arbel_eq_req_not(dev, eq->eqn_mask);
-
- /* MSI-X vectors always belong to us */
- return IRQ_HANDLED;
-}
-
-static int mthca_create_eq(struct mthca_dev *dev,
- int nent,
- u8 intr,
- struct mthca_eq *eq)
-{
- int npages;
- u64 *dma_list = NULL;
- dma_addr_t t;
- struct mthca_mailbox *mailbox;
- struct mthca_eq_context *eq_context;
- int err = -ENOMEM;
- int i;
- u8 status;
-
- eq->dev = dev;
- eq->nent = roundup_pow_of_two(max(nent, 2));
- npages = ALIGN(eq->nent * MTHCA_EQ_ENTRY_SIZE, PAGE_SIZE) / PAGE_SIZE;
-
- eq->page_list = kmalloc(npages * sizeof *eq->page_list,
- GFP_KERNEL);
- if (!eq->page_list)
- goto err_out;
-
- for (i = 0; i < npages; ++i)
- eq->page_list[i].buf = NULL;
-
- dma_list = kmalloc(npages * sizeof *dma_list, GFP_KERNEL);
- if (!dma_list)
- goto err_out_free;
-
- mailbox = mthca_alloc_mailbox(dev, GFP_KERNEL);
- if (IS_ERR(mailbox))
- goto err_out_free;
- eq_context = mailbox->buf;
-
- for (i = 0; i < npages; ++i) {
- eq->page_list[i].buf = dma_alloc_coherent(&dev->pdev->dev,
- PAGE_SIZE, &t, GFP_KERNEL);
- if (!eq->page_list[i].buf)
- goto err_out_free_pages;
-
- dma_list[i] = t;
- pci_unmap_addr_set(&eq->page_list[i], mapping, t);
-
- clear_page(eq->page_list[i].buf);
- }
-
- for (i = 0; i < eq->nent; ++i)
- set_eqe_hw(get_eqe(eq, i));
-
- eq->eqn = mthca_alloc(&dev->eq_table.alloc);
- if (eq->eqn == -1)
- goto err_out_free_pages;
-
- err = mthca_mr_alloc_phys(dev, dev->driver_pd.pd_num,
- dma_list, PAGE_SHIFT, npages,
- 0, npages * PAGE_SIZE,
- MTHCA_MPT_FLAG_LOCAL_WRITE |
- MTHCA_MPT_FLAG_LOCAL_READ,
- &eq->mr);
- if (err)
- goto err_out_free_eq;
-
- memset(eq_context, 0, sizeof *eq_context);
- eq_context->flags = cpu_to_be32(MTHCA_EQ_STATUS_OK |
- MTHCA_EQ_OWNER_HW |
- MTHCA_EQ_STATE_ARMED |
- MTHCA_EQ_FLAG_TR);
- if (mthca_is_memfree(dev))
- eq_context->flags |= cpu_to_be32(MTHCA_EQ_STATE_ARBEL);
-
- eq_context->logsize_usrpage = cpu_to_be32((ffs(eq->nent) - 1) << 24);
- if (mthca_is_memfree(dev)) {
- eq_context->arbel_pd = cpu_to_be32(dev->driver_pd.pd_num);
- } else {
- eq_context->logsize_usrpage |= cpu_to_be32(dev->driver_uar.index);
- eq_context->tavor_pd = cpu_to_be32(dev->driver_pd.pd_num);
- }
- eq_context->intr = intr;
- eq_context->lkey = cpu_to_be32(eq->mr.ibmr.lkey);
-
- err = mthca_SW2HW_EQ(dev, mailbox, eq->eqn, &status);
- if (err) {
- mthca_warn(dev, "SW2HW_EQ failed (%d)\n", err);
- goto err_out_free_mr;
- }
- if (status) {
- mthca_warn(dev, "SW2HW_EQ returned status 0x%02x\n",
- status);
- err = -EINVAL;
- goto err_out_free_mr;
- }
-
- kfree(dma_list);
- mthca_free_mailbox(dev, mailbox);
-
- eq->eqn_mask = swab32(1 << eq->eqn);
- eq->cons_index = 0;
-
- dev->eq_table.arm_mask |= eq->eqn_mask;
-
- mthca_dbg(dev, "Allocated EQ %d with %d entries\n",
- eq->eqn, eq->nent);
-
- return err;
-
- err_out_free_mr:
- mthca_free_mr(dev, &eq->mr);
-
- err_out_free_eq:
- mthca_free(&dev->eq_table.alloc, eq->eqn);
-
- err_out_free_pages:
- for (i = 0; i < npages; ++i)
- if (eq->page_list[i].buf)
- dma_free_coherent(&dev->pdev->dev, PAGE_SIZE,
- eq->page_list[i].buf,
- pci_unmap_addr(&eq->page_list[i],
- mapping));
-
- mthca_free_mailbox(dev, mailbox);
-
- err_out_free:
- kfree(eq->page_list);
- kfree(dma_list);
-
- err_out:
- return err;
-}
-
-static void mthca_free_eq(struct mthca_dev *dev,
- struct mthca_eq *eq)
-{
- struct mthca_mailbox *mailbox;
- int err;
- u8 status;
- int npages = (eq->nent * MTHCA_EQ_ENTRY_SIZE + PAGE_SIZE - 1) /
- PAGE_SIZE;
- int i;
-
- mailbox = mthca_alloc_mailbox(dev, GFP_KERNEL);
- if (IS_ERR(mailbox))
- return;
-
- err = mthca_HW2SW_EQ(dev, mailbox, eq->eqn, &status);
- if (err)
- mthca_warn(dev, "HW2SW_EQ failed (%d)\n", err);
- if (status)
- mthca_warn(dev, "HW2SW_EQ returned status 0x%02x\n", status);
-
- dev->eq_table.arm_mask &= ~eq->eqn_mask;
-
- if (0) {
- mthca_dbg(dev, "Dumping EQ context %02x:\n", eq->eqn);
- for (i = 0; i < sizeof (struct mthca_eq_context) / 4; ++i) {
- if (i % 4 == 0)
- printk("[%02x] ", i * 4);
- printk(" %08x", be32_to_cpup(mailbox->buf + i * 4));
- if ((i + 1) % 4 == 0)
- printk("\n");
- }
- }
-
- mthca_free_mr(dev, &eq->mr);
- for (i = 0; i < npages; ++i)
- pci_free_consistent(dev->pdev, PAGE_SIZE,
- eq->page_list[i].buf,
- pci_unmap_addr(&eq->page_list[i], mapping));
-
- kfree(eq->page_list);
- mthca_free_mailbox(dev, mailbox);
-}
-
-static void mthca_free_irqs(struct mthca_dev *dev)
-{
- int i;
-
- if (dev->eq_table.have_irq)
- free_irq(dev->pdev->irq, dev);
- for (i = 0; i < MTHCA_NUM_EQ; ++i)
- if (dev->eq_table.eq[i].have_irq) {
- free_irq(dev->eq_table.eq[i].msi_x_vector,
- dev->eq_table.eq + i);
- dev->eq_table.eq[i].have_irq = 0;
- }
-}
-
-static int mthca_map_reg(struct mthca_dev *dev,
- unsigned long offset, unsigned long size,
- void __iomem **map)
-{
- unsigned long base = pci_resource_start(dev->pdev, 0);
-
- *map = ioremap(base + offset, size);
- if (!*map)
- return -ENOMEM;
-
- return 0;
-}
-
-static int mthca_map_eq_regs(struct mthca_dev *dev)
-{
- if (mthca_is_memfree(dev)) {
- /*
- * We assume that the EQ arm and EQ set CI registers
- * fall within the first BAR. We can't trust the
- * values firmware gives us, since those addresses are
- * valid on the HCA's side of the PCI bus but not
- * necessarily the host side.
- */
- if (mthca_map_reg(dev, (pci_resource_len(dev->pdev, 0) - 1) &
- dev->fw.arbel.clr_int_base, MTHCA_CLR_INT_SIZE,
- &dev->clr_base)) {
- mthca_err(dev, "Couldn't map interrupt clear register, "
- "aborting.\n");
- return -ENOMEM;
- }
-
- /*
- * Add 4 because we limit ourselves to EQs 0 ... 31,
- * so we only need the low word of the register.
- */
- if (mthca_map_reg(dev, ((pci_resource_len(dev->pdev, 0) - 1) &
- dev->fw.arbel.eq_arm_base) + 4, 4,
- &dev->eq_regs.arbel.eq_arm)) {
- mthca_err(dev, "Couldn't map EQ arm register, aborting.\n");
- iounmap(dev->clr_base);
- return -ENOMEM;
- }
-
- if (mthca_map_reg(dev, (pci_resource_len(dev->pdev, 0) - 1) &
- dev->fw.arbel.eq_set_ci_base,
- MTHCA_EQ_SET_CI_SIZE,
- &dev->eq_regs.arbel.eq_set_ci_base)) {
- mthca_err(dev, "Couldn't map EQ CI register, aborting.\n");
- iounmap(dev->eq_regs.arbel.eq_arm);
- iounmap(dev->clr_base);
- return -ENOMEM;
- }
- } else {
- if (mthca_map_reg(dev, MTHCA_CLR_INT_BASE, MTHCA_CLR_INT_SIZE,
- &dev->clr_base)) {
- mthca_err(dev, "Couldn't map interrupt clear register, "
- "aborting.\n");
- return -ENOMEM;
- }
-
- if (mthca_map_reg(dev, MTHCA_ECR_BASE,
- MTHCA_ECR_SIZE + MTHCA_ECR_CLR_SIZE,
- &dev->eq_regs.tavor.ecr_base)) {
- mthca_err(dev, "Couldn't map ecr register, "
- "aborting.\n");
- iounmap(dev->clr_base);
- return -ENOMEM;
- }
- }
-
- return 0;
-
-}
-
-static void mthca_unmap_eq_regs(struct mthca_dev *dev)
-{
- if (mthca_is_memfree(dev)) {
- iounmap(dev->eq_regs.arbel.eq_set_ci_base);
- iounmap(dev->eq_regs.arbel.eq_arm);
- iounmap(dev->clr_base);
- } else {
- iounmap(dev->eq_regs.tavor.ecr_base);
- iounmap(dev->clr_base);
- }
-}
-
-int mthca_map_eq_icm(struct mthca_dev *dev, u64 icm_virt)
-{
- int ret;
- u8 status;
-
- /*
- * We assume that mapping one page is enough for the whole EQ
- * context table. This is fine with all current HCAs, because
- * we only use 32 EQs and each EQ uses 32 bytes of context
- * memory, or 1 KB total.
- */
- dev->eq_table.icm_virt = icm_virt;
- dev->eq_table.icm_page = alloc_page(GFP_HIGHUSER);
- if (!dev->eq_table.icm_page)
- return -ENOMEM;
- dev->eq_table.icm_dma = pci_map_page(dev->pdev, dev->eq_table.icm_page, 0,
- PAGE_SIZE, PCI_DMA_BIDIRECTIONAL);
- if (pci_dma_mapping_error(dev->pdev, dev->eq_table.icm_dma)) {
- __free_page(dev->eq_table.icm_page);
- return -ENOMEM;
- }
-
- ret = mthca_MAP_ICM_page(dev, dev->eq_table.icm_dma, icm_virt, &status);
- if (!ret && status)
- ret = -EINVAL;
- if (ret) {
- pci_unmap_page(dev->pdev, dev->eq_table.icm_dma, PAGE_SIZE,
- PCI_DMA_BIDIRECTIONAL);
- __free_page(dev->eq_table.icm_page);
- }
-
- return ret;
-}
-
-void mthca_unmap_eq_icm(struct mthca_dev *dev)
-{
- u8 status;
-
- mthca_UNMAP_ICM(dev, dev->eq_table.icm_virt, 1, &status);
- pci_unmap_page(dev->pdev, dev->eq_table.icm_dma, PAGE_SIZE,
- PCI_DMA_BIDIRECTIONAL);
- __free_page(dev->eq_table.icm_page);
-}
-
-int mthca_init_eq_table(struct mthca_dev *dev)
-{
- int err;
- u8 status;
- u8 intr;
- int i;
-
- err = mthca_alloc_init(&dev->eq_table.alloc,
- dev->limits.num_eqs,
- dev->limits.num_eqs - 1,
- dev->limits.reserved_eqs);
- if (err)
- return err;
-
- err = mthca_map_eq_regs(dev);
- if (err)
- goto err_out_free;
-
- if (dev->mthca_flags & MTHCA_FLAG_MSI_X) {
- dev->eq_table.clr_mask = 0;
- } else {
- dev->eq_table.clr_mask =
- swab32(1 << (dev->eq_table.inta_pin & 31));
- dev->eq_table.clr_int = dev->clr_base +
- (dev->eq_table.inta_pin < 32 ? 4 : 0);
- }
-
- dev->eq_table.arm_mask = 0;
-
- intr = dev->eq_table.inta_pin;
-
- err = mthca_create_eq(dev, dev->limits.num_cqs + MTHCA_NUM_SPARE_EQE,
- (dev->mthca_flags & MTHCA_FLAG_MSI_X) ? 128 : intr,
- &dev->eq_table.eq[MTHCA_EQ_COMP]);
- if (err)
- goto err_out_unmap;
-
- err = mthca_create_eq(dev, MTHCA_NUM_ASYNC_EQE + MTHCA_NUM_SPARE_EQE,
- (dev->mthca_flags & MTHCA_FLAG_MSI_X) ? 129 : intr,
- &dev->eq_table.eq[MTHCA_EQ_ASYNC]);
- if (err)
- goto err_out_comp;
-
- err = mthca_create_eq(dev, MTHCA_NUM_CMD_EQE + MTHCA_NUM_SPARE_EQE,
- (dev->mthca_flags & MTHCA_FLAG_MSI_X) ? 130 : intr,
- &dev->eq_table.eq[MTHCA_EQ_CMD]);
- if (err)
- goto err_out_async;
-
- if (dev->mthca_flags & MTHCA_FLAG_MSI_X) {
- static const char *eq_name[] = {
- [MTHCA_EQ_COMP] = DRV_NAME " (comp)",
- [MTHCA_EQ_ASYNC] = DRV_NAME " (async)",
- [MTHCA_EQ_CMD] = DRV_NAME " (cmd)"
- };
-
- for (i = 0; i < MTHCA_NUM_EQ; ++i) {
- err = request_irq(dev->eq_table.eq[i].msi_x_vector,
- mthca_is_memfree(dev) ?
- mthca_arbel_msi_x_interrupt :
- mthca_tavor_msi_x_interrupt,
- 0, eq_name[i], dev->eq_table.eq + i);
- if (err)
- goto err_out_cmd;
- dev->eq_table.eq[i].have_irq = 1;
- }
- } else {
- err = request_irq(dev->pdev->irq,
- mthca_is_memfree(dev) ?
- mthca_arbel_interrupt :
- mthca_tavor_interrupt,
- IRQF_SHARED, DRV_NAME, dev);
- if (err)
- goto err_out_cmd;
- dev->eq_table.have_irq = 1;
- }
-
- err = mthca_MAP_EQ(dev, async_mask(dev),
- 0, dev->eq_table.eq[MTHCA_EQ_ASYNC].eqn, &status);
- if (err)
- mthca_warn(dev, "MAP_EQ for async EQ %d failed (%d)\n",
- dev->eq_table.eq[MTHCA_EQ_ASYNC].eqn, err);
- if (status)
- mthca_warn(dev, "MAP_EQ for async EQ %d returned status 0x%02x\n",
- dev->eq_table.eq[MTHCA_EQ_ASYNC].eqn, status);
-
- err = mthca_MAP_EQ(dev, MTHCA_CMD_EVENT_MASK,
- 0, dev->eq_table.eq[MTHCA_EQ_CMD].eqn, &status);
- if (err)
- mthca_warn(dev, "MAP_EQ for cmd EQ %d failed (%d)\n",
- dev->eq_table.eq[MTHCA_EQ_CMD].eqn, err);
- if (status)
- mthca_warn(dev, "MAP_EQ for cmd EQ %d returned status 0x%02x\n",
- dev->eq_table.eq[MTHCA_EQ_CMD].eqn, status);
-
- for (i = 0; i < MTHCA_NUM_EQ; ++i)
- if (mthca_is_memfree(dev))
- arbel_eq_req_not(dev, dev->eq_table.eq[i].eqn_mask);
- else
- tavor_eq_req_not(dev, dev->eq_table.eq[i].eqn);
-
- return 0;
-
-err_out_cmd:
- mthca_free_irqs(dev);
- mthca_free_eq(dev, &dev->eq_table.eq[MTHCA_EQ_CMD]);
-
-err_out_async:
- mthca_free_eq(dev, &dev->eq_table.eq[MTHCA_EQ_ASYNC]);
-
-err_out_comp:
- mthca_free_eq(dev, &dev->eq_table.eq[MTHCA_EQ_COMP]);
-
-err_out_unmap:
- mthca_unmap_eq_regs(dev);
-
-err_out_free:
- mthca_alloc_cleanup(&dev->eq_table.alloc);
- return err;
-}
-
-void mthca_cleanup_eq_table(struct mthca_dev *dev)
-{
- u8 status;
- int i;
-
- mthca_free_irqs(dev);
-
- mthca_MAP_EQ(dev, async_mask(dev),
- 1, dev->eq_table.eq[MTHCA_EQ_ASYNC].eqn, &status);
- mthca_MAP_EQ(dev, MTHCA_CMD_EVENT_MASK,
- 1, dev->eq_table.eq[MTHCA_EQ_CMD].eqn, &status);
-
- for (i = 0; i < MTHCA_NUM_EQ; ++i)
- mthca_free_eq(dev, &dev->eq_table.eq[i]);
-
- mthca_unmap_eq_regs(dev);
-
- mthca_alloc_cleanup(&dev->eq_table.alloc);
-}
diff --git a/sys/ofed/drivers/infiniband/hw/mthca/mthca_mad.c b/sys/ofed/drivers/infiniband/hw/mthca/mthca_mad.c
deleted file mode 100644
index 5648659..0000000
--- a/sys/ofed/drivers/infiniband/hw/mthca/mthca_mad.c
+++ /dev/null
@@ -1,346 +0,0 @@
-/*
- * Copyright (c) 2004 Topspin Communications. All rights reserved.
- * Copyright (c) 2005 Mellanox Technologies. All rights reserved.
- * Copyright (c) 2004 Voltaire, Inc. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-#include <linux/string.h>
-#include <linux/slab.h>
-
-#include <rdma/ib_verbs.h>
-#include <rdma/ib_mad.h>
-#include <rdma/ib_smi.h>
-
-#include "mthca_dev.h"
-#include "mthca_cmd.h"
-
-enum {
- MTHCA_VENDOR_CLASS1 = 0x9,
- MTHCA_VENDOR_CLASS2 = 0xa
-};
-
-static int mthca_update_rate(struct mthca_dev *dev, u8 port_num)
-{
- struct ib_port_attr *tprops = NULL;
- int ret;
-
- tprops = kmalloc(sizeof *tprops, GFP_KERNEL);
- if (!tprops)
- return -ENOMEM;
-
- ret = ib_query_port(&dev->ib_dev, port_num, tprops);
- if (ret) {
- printk(KERN_WARNING "ib_query_port failed (%d) for %s port %d\n",
- ret, dev->ib_dev.name, port_num);
- goto out;
- }
-
- dev->rate[port_num - 1] = tprops->active_speed *
- ib_width_enum_to_int(tprops->active_width);
-
-out:
- kfree(tprops);
- return ret;
-}
-
-static void update_sm_ah(struct mthca_dev *dev,
- u8 port_num, u16 lid, u8 sl)
-{
- struct ib_ah *new_ah;
- struct ib_ah_attr ah_attr;
- unsigned long flags;
-
- if (!dev->send_agent[port_num - 1][0])
- return;
-
- memset(&ah_attr, 0, sizeof ah_attr);
- ah_attr.dlid = lid;
- ah_attr.sl = sl;
- ah_attr.port_num = port_num;
-
- new_ah = ib_create_ah(dev->send_agent[port_num - 1][0]->qp->pd,
- &ah_attr);
- if (IS_ERR(new_ah))
- return;
-
- spin_lock_irqsave(&dev->sm_lock, flags);
- if (dev->sm_ah[port_num - 1])
- ib_destroy_ah(dev->sm_ah[port_num - 1]);
- dev->sm_ah[port_num - 1] = new_ah;
- spin_unlock_irqrestore(&dev->sm_lock, flags);
-}
-
-/*
- * Snoop SM MADs for port info and P_Key table sets, so we can
- * synthesize LID change and P_Key change events.
- */
-static void smp_snoop(struct ib_device *ibdev,
- u8 port_num,
- struct ib_mad *mad,
- u16 prev_lid)
-{
- struct ib_event event;
-
- if ((mad->mad_hdr.mgmt_class == IB_MGMT_CLASS_SUBN_LID_ROUTED ||
- mad->mad_hdr.mgmt_class == IB_MGMT_CLASS_SUBN_DIRECTED_ROUTE) &&
- mad->mad_hdr.method == IB_MGMT_METHOD_SET) {
- if (mad->mad_hdr.attr_id == IB_SMP_ATTR_PORT_INFO) {
- struct ib_port_info *pinfo =
- (struct ib_port_info *) ((struct ib_smp *) mad)->data;
- u16 lid = be16_to_cpu(pinfo->lid);
-
- mthca_update_rate(to_mdev(ibdev), port_num);
- update_sm_ah(to_mdev(ibdev), port_num,
- be16_to_cpu(pinfo->sm_lid),
- pinfo->neighbormtu_mastersmsl & 0xf);
-
- event.device = ibdev;
- event.element.port_num = port_num;
-
- if (pinfo->clientrereg_resv_subnetto & 0x80) {
- event.event = IB_EVENT_CLIENT_REREGISTER;
- ib_dispatch_event(&event);
- }
-
- if (prev_lid != lid) {
- event.event = IB_EVENT_LID_CHANGE;
- ib_dispatch_event(&event);
- }
- }
-
- if (mad->mad_hdr.attr_id == IB_SMP_ATTR_PKEY_TABLE) {
- event.device = ibdev;
- event.event = IB_EVENT_PKEY_CHANGE;
- event.element.port_num = port_num;
- ib_dispatch_event(&event);
- }
- }
-}
-
-static void node_desc_override(struct ib_device *dev,
- struct ib_mad *mad)
-{
- if ((mad->mad_hdr.mgmt_class == IB_MGMT_CLASS_SUBN_LID_ROUTED ||
- mad->mad_hdr.mgmt_class == IB_MGMT_CLASS_SUBN_DIRECTED_ROUTE) &&
- mad->mad_hdr.method == IB_MGMT_METHOD_GET_RESP &&
- mad->mad_hdr.attr_id == IB_SMP_ATTR_NODE_DESC) {
- mutex_lock(&to_mdev(dev)->cap_mask_mutex);
- memcpy(((struct ib_smp *) mad)->data, dev->node_desc, 64);
- mutex_unlock(&to_mdev(dev)->cap_mask_mutex);
- }
-}
-
-static void forward_trap(struct mthca_dev *dev,
- u8 port_num,
- struct ib_mad *mad)
-{
- int qpn = mad->mad_hdr.mgmt_class != IB_MGMT_CLASS_SUBN_LID_ROUTED;
- struct ib_mad_send_buf *send_buf;
- struct ib_mad_agent *agent = dev->send_agent[port_num - 1][qpn];
- int ret;
- unsigned long flags;
-
- if (agent) {
- send_buf = ib_create_send_mad(agent, qpn, 0, 0, IB_MGMT_MAD_HDR,
- IB_MGMT_MAD_DATA, GFP_ATOMIC);
- /*
- * We rely here on the fact that MLX QPs don't use the
- * address handle after the send is posted (this is
- * wrong following the IB spec strictly, but we know
- * it's OK for our devices).
- */
- spin_lock_irqsave(&dev->sm_lock, flags);
- memcpy(send_buf->mad, mad, sizeof *mad);
- if ((send_buf->ah = dev->sm_ah[port_num - 1]))
- ret = ib_post_send_mad(send_buf, NULL);
- else
- ret = -EINVAL;
- spin_unlock_irqrestore(&dev->sm_lock, flags);
-
- if (ret)
- ib_free_send_mad(send_buf);
- }
-}
-
-int mthca_process_mad(struct ib_device *ibdev,
- int mad_flags,
- u8 port_num,
- struct ib_wc *in_wc,
- struct ib_grh *in_grh,
- struct ib_mad *in_mad,
- struct ib_mad *out_mad)
-{
- int err;
- u8 status;
- u16 slid = in_wc ? in_wc->slid : be16_to_cpu(IB_LID_PERMISSIVE);
- u16 prev_lid = 0;
- struct ib_port_attr pattr;
-
- /* Forward locally generated traps to the SM */
- if (in_mad->mad_hdr.method == IB_MGMT_METHOD_TRAP &&
- slid == 0) {
- forward_trap(to_mdev(ibdev), port_num, in_mad);
- return IB_MAD_RESULT_SUCCESS | IB_MAD_RESULT_CONSUMED;
- }
-
- /*
- * Only handle SM gets, sets and trap represses for SM class
- *
- * Only handle PMA and Mellanox vendor-specific class gets and
- * sets for other classes.
- */
- if (in_mad->mad_hdr.mgmt_class == IB_MGMT_CLASS_SUBN_LID_ROUTED ||
- in_mad->mad_hdr.mgmt_class == IB_MGMT_CLASS_SUBN_DIRECTED_ROUTE) {
- if (in_mad->mad_hdr.method != IB_MGMT_METHOD_GET &&
- in_mad->mad_hdr.method != IB_MGMT_METHOD_SET &&
- in_mad->mad_hdr.method != IB_MGMT_METHOD_TRAP_REPRESS)
- return IB_MAD_RESULT_SUCCESS;
-
- /*
- * Don't process SMInfo queries or vendor-specific
- * MADs -- the SMA can't handle them.
- */
- if (in_mad->mad_hdr.attr_id == IB_SMP_ATTR_SM_INFO ||
- ((in_mad->mad_hdr.attr_id & IB_SMP_ATTR_VENDOR_MASK) ==
- IB_SMP_ATTR_VENDOR_MASK))
- return IB_MAD_RESULT_SUCCESS;
- } else if (in_mad->mad_hdr.mgmt_class == IB_MGMT_CLASS_PERF_MGMT ||
- in_mad->mad_hdr.mgmt_class == MTHCA_VENDOR_CLASS1 ||
- in_mad->mad_hdr.mgmt_class == MTHCA_VENDOR_CLASS2) {
- if (in_mad->mad_hdr.method != IB_MGMT_METHOD_GET &&
- in_mad->mad_hdr.method != IB_MGMT_METHOD_SET)
- return IB_MAD_RESULT_SUCCESS;
- } else
- return IB_MAD_RESULT_SUCCESS;
- if ((in_mad->mad_hdr.mgmt_class == IB_MGMT_CLASS_SUBN_LID_ROUTED ||
- in_mad->mad_hdr.mgmt_class == IB_MGMT_CLASS_SUBN_DIRECTED_ROUTE) &&
- in_mad->mad_hdr.method == IB_MGMT_METHOD_SET &&
- in_mad->mad_hdr.attr_id == IB_SMP_ATTR_PORT_INFO &&
- !ib_query_port(ibdev, port_num, &pattr))
- prev_lid = pattr.lid;
-
- err = mthca_MAD_IFC(to_mdev(ibdev),
- mad_flags & IB_MAD_IGNORE_MKEY,
- mad_flags & IB_MAD_IGNORE_BKEY,
- port_num, in_wc, in_grh, in_mad, out_mad,
- &status);
- if (err) {
- mthca_err(to_mdev(ibdev), "MAD_IFC failed\n");
- return IB_MAD_RESULT_FAILURE;
- }
- if (status == MTHCA_CMD_STAT_BAD_PKT)
- return IB_MAD_RESULT_SUCCESS;
- if (status) {
- mthca_err(to_mdev(ibdev), "MAD_IFC returned status %02x\n",
- status);
- return IB_MAD_RESULT_FAILURE;
- }
-
- if (!out_mad->mad_hdr.status) {
- smp_snoop(ibdev, port_num, in_mad, prev_lid);
- node_desc_override(ibdev, out_mad);
- }
-
- /* set return bit in status of directed route responses */
- if (in_mad->mad_hdr.mgmt_class == IB_MGMT_CLASS_SUBN_DIRECTED_ROUTE)
- out_mad->mad_hdr.status |= cpu_to_be16(1 << 15);
-
- if (in_mad->mad_hdr.method == IB_MGMT_METHOD_TRAP_REPRESS)
- /* no response for trap repress */
- return IB_MAD_RESULT_SUCCESS | IB_MAD_RESULT_CONSUMED;
-
- return IB_MAD_RESULT_SUCCESS | IB_MAD_RESULT_REPLY;
-}
-
-static void send_handler(struct ib_mad_agent *agent,
- struct ib_mad_send_wc *mad_send_wc)
-{
- ib_free_send_mad(mad_send_wc->send_buf);
-}
-
-int mthca_create_agents(struct mthca_dev *dev)
-{
- struct ib_mad_agent *agent;
- int p, q;
- int ret;
-
- spin_lock_init(&dev->sm_lock);
-
- for (p = 0; p < dev->limits.num_ports; ++p)
- for (q = 0; q <= 1; ++q) {
- agent = ib_register_mad_agent(&dev->ib_dev, p + 1,
- q ? IB_QPT_GSI : IB_QPT_SMI,
- NULL, 0, send_handler,
- NULL, NULL);
- if (IS_ERR(agent)) {
- ret = PTR_ERR(agent);
- goto err;
- }
- dev->send_agent[p][q] = agent;
- }
-
-
- for (p = 1; p <= dev->limits.num_ports; ++p) {
- ret = mthca_update_rate(dev, p);
- if (ret) {
- mthca_err(dev, "Failed to obtain port %d rate."
- " aborting.\n", p);
- goto err;
- }
- }
-
- return 0;
-
-err:
- for (p = 0; p < dev->limits.num_ports; ++p)
- for (q = 0; q <= 1; ++q)
- if (dev->send_agent[p][q])
- ib_unregister_mad_agent(dev->send_agent[p][q]);
-
- return ret;
-}
-
-void mthca_free_agents(struct mthca_dev *dev)
-{
- struct ib_mad_agent *agent;
- int p, q;
-
- for (p = 0; p < dev->limits.num_ports; ++p) {
- for (q = 0; q <= 1; ++q) {
- agent = dev->send_agent[p][q];
- dev->send_agent[p][q] = NULL;
- ib_unregister_mad_agent(agent);
- }
-
- if (dev->sm_ah[p])
- ib_destroy_ah(dev->sm_ah[p]);
- }
-}
diff --git a/sys/ofed/drivers/infiniband/hw/mthca/mthca_main.c b/sys/ofed/drivers/infiniband/hw/mthca/mthca_main.c
deleted file mode 100644
index c7e9851..0000000
--- a/sys/ofed/drivers/infiniband/hw/mthca/mthca_main.c
+++ /dev/null
@@ -1,1363 +0,0 @@
-/*
- * Copyright (c) 2004, 2005 Topspin Communications. All rights reserved.
- * Copyright (c) 2005 Sun Microsystems, Inc. All rights reserved.
- * Copyright (c) 2005 Mellanox Technologies. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-#define LINUXKPI_PARAM_PREFIX mthca_
-
-#include <linux/module.h>
-#include <linux/errno.h>
-#include <linux/pci.h>
-#include <linux/interrupt.h>
-
-#include "mthca_dev.h"
-#include "mthca_config_reg.h"
-#include "mthca_cmd.h"
-#include "mthca_profile.h"
-#include "mthca_memfree.h"
-#include "mthca_wqe.h"
-
-MODULE_AUTHOR("Roland Dreier");
-MODULE_DESCRIPTION("Mellanox InfiniBand HCA low-level driver");
-MODULE_LICENSE("Dual BSD/GPL");
-MODULE_VERSION(mthca, 1);
-MODULE_DEPEND(mthca, linuxkpi, 1, 1, 1);
-MODULE_DEPEND(mthca, ibcore, 1, 1, 1);
-
-#ifdef CONFIG_INFINIBAND_MTHCA_DEBUG
-
-int mthca_debug_level = 0;
-module_param_named(debug_level, mthca_debug_level, int, 0644);
-MODULE_PARM_DESC(debug_level, "Enable debug tracing if > 0");
-
-#endif /* CONFIG_INFINIBAND_MTHCA_DEBUG */
-
-#ifdef CONFIG_PCI_MSI
-
-static int msi_x = 1;
-module_param(msi_x, int, 0444);
-MODULE_PARM_DESC(msi_x, "attempt to use MSI-X if nonzero");
-
-#else /* CONFIG_PCI_MSI */
-
-#define msi_x (0)
-
-#endif /* CONFIG_PCI_MSI */
-
-static int tune_pci = 0;
-module_param(tune_pci, int, 0444);
-MODULE_PARM_DESC(tune_pci, "increase PCI burst from the default set by BIOS if nonzero");
-
-DEFINE_MUTEX(mthca_device_mutex);
-
-#define MTHCA_DEFAULT_NUM_QP (1 << 16)
-#define MTHCA_DEFAULT_RDB_PER_QP (1 << 2)
-#define MTHCA_DEFAULT_NUM_CQ (1 << 16)
-#define MTHCA_DEFAULT_NUM_MCG (1 << 13)
-#define MTHCA_DEFAULT_NUM_MPT (1 << 17)
-#define MTHCA_DEFAULT_NUM_MTT (1 << 20)
-#define MTHCA_DEFAULT_NUM_UDAV (1 << 15)
-#define MTHCA_DEFAULT_NUM_RESERVED_MTTS (1 << 18)
-#define MTHCA_DEFAULT_NUM_UARC_SIZE (1 << 18)
-
-static struct mthca_profile hca_profile = {
- .num_qp = MTHCA_DEFAULT_NUM_QP,
- .rdb_per_qp = MTHCA_DEFAULT_RDB_PER_QP,
- .num_cq = MTHCA_DEFAULT_NUM_CQ,
- .num_mcg = MTHCA_DEFAULT_NUM_MCG,
- .num_mpt = MTHCA_DEFAULT_NUM_MPT,
- .num_mtt = MTHCA_DEFAULT_NUM_MTT,
- .num_udav = MTHCA_DEFAULT_NUM_UDAV, /* Tavor only */
- .fmr_reserved_mtts = MTHCA_DEFAULT_NUM_RESERVED_MTTS, /* Tavor only */
- .uarc_size = MTHCA_DEFAULT_NUM_UARC_SIZE, /* Arbel only */
-};
-
-module_param_named(num_qp, hca_profile.num_qp, int, 0444);
-MODULE_PARM_DESC(num_qp, "maximum number of QPs per HCA");
-
-module_param_named(rdb_per_qp, hca_profile.rdb_per_qp, int, 0444);
-MODULE_PARM_DESC(rdb_per_qp, "number of RDB buffers per QP");
-
-module_param_named(num_cq, hca_profile.num_cq, int, 0444);
-MODULE_PARM_DESC(num_cq, "maximum number of CQs per HCA");
-
-module_param_named(num_mcg, hca_profile.num_mcg, int, 0444);
-MODULE_PARM_DESC(num_mcg, "maximum number of multicast groups per HCA");
-
-module_param_named(num_mpt, hca_profile.num_mpt, int, 0444);
-MODULE_PARM_DESC(num_mpt,
- "maximum number of memory protection table entries per HCA");
-
-module_param_named(num_mtt, hca_profile.num_mtt, int, 0444);
-MODULE_PARM_DESC(num_mtt,
- "maximum number of memory translation table segments per HCA");
-
-module_param_named(num_udav, hca_profile.num_udav, int, 0444);
-MODULE_PARM_DESC(num_udav, "maximum number of UD address vectors per HCA");
-
-module_param_named(fmr_reserved_mtts, hca_profile.fmr_reserved_mtts, int, 0444);
-MODULE_PARM_DESC(fmr_reserved_mtts,
- "number of memory translation table segments reserved for FMR");
-
-static int log_mtts_per_seg;
-module_param_named(log_mtts_per_seg, log_mtts_per_seg, int, 0444);
-MODULE_PARM_DESC(log_mtts_per_seg, "Log2 number of MTT entries per segment (1-5)");
-
-static char mthca_version[] __devinitdata =
- DRV_NAME ": Mellanox InfiniBand HCA driver v"
- DRV_VERSION " (" DRV_RELDATE ")\n";
-
-static int mthca_tune_pci(struct mthca_dev *mdev)
-{
- if (!tune_pci)
- return 0;
-
- /* First try to max out Read Byte Count */
- if (pci_find_capability(mdev->pdev, PCI_CAP_ID_PCIX)) {
- if (pcix_set_mmrbc(mdev->pdev, pcix_get_max_mmrbc(mdev->pdev))) {
- mthca_err(mdev, "Couldn't set PCI-X max read count, "
- "aborting.\n");
- return -ENODEV;
- }
- } else if (!(mdev->mthca_flags & MTHCA_FLAG_PCIE))
- mthca_info(mdev, "No PCI-X capability, not setting RBC.\n");
-
- if (pci_find_capability(mdev->pdev, PCI_CAP_ID_EXP)) {
- if (pcie_set_readrq(mdev->pdev, 4096)) {
- mthca_err(mdev, "Couldn't write PCI Express read request, "
- "aborting.\n");
- return -ENODEV;
- }
- } else if (mdev->mthca_flags & MTHCA_FLAG_PCIE)
- mthca_info(mdev, "No PCI Express capability, "
- "not setting Max Read Request Size.\n");
-
- return 0;
-}
-
-static int mthca_dev_lim(struct mthca_dev *mdev, struct mthca_dev_lim *dev_lim)
-{
- int err;
- u8 status;
-
- mdev->limits.mtt_seg_size = (1 << log_mtts_per_seg) * 8;
- err = mthca_QUERY_DEV_LIM(mdev, dev_lim, &status);
- if (err) {
- mthca_err(mdev, "QUERY_DEV_LIM command failed, aborting.\n");
- return err;
- }
- if (status) {
- mthca_err(mdev, "QUERY_DEV_LIM returned status 0x%02x, "
- "aborting.\n", status);
- return -EINVAL;
- }
- if (dev_lim->min_page_sz > PAGE_SIZE) {
- mthca_err(mdev, "HCA minimum page size of %d bigger than "
- "kernel PAGE_SIZE of %d, aborting.\n",
- dev_lim->min_page_sz, PAGE_SIZE);
- return -ENODEV;
- }
- if (dev_lim->num_ports > MTHCA_MAX_PORTS) {
- mthca_err(mdev, "HCA has %d ports, but we only support %d, "
- "aborting.\n",
- dev_lim->num_ports, MTHCA_MAX_PORTS);
- return -ENODEV;
- }
-
- if (dev_lim->uar_size > pci_resource_len(mdev->pdev, 2)) {
- mthca_err(mdev, "HCA reported UAR size of 0x%x bigger than "
- "PCI resource 2 size of 0x%llx, aborting.\n",
- dev_lim->uar_size,
- (unsigned long long)pci_resource_len(mdev->pdev, 2));
- return -ENODEV;
- }
-
- mdev->limits.num_ports = dev_lim->num_ports;
- mdev->limits.vl_cap = dev_lim->max_vl;
- mdev->limits.mtu_cap = dev_lim->max_mtu;
- mdev->limits.gid_table_len = dev_lim->max_gids;
- mdev->limits.pkey_table_len = dev_lim->max_pkeys;
- mdev->limits.local_ca_ack_delay = dev_lim->local_ca_ack_delay;
- /*
- * Need to allow for worst case send WQE overhead and check
- * whether max_desc_sz imposes a lower limit than max_sg; UD
- * send has the biggest overhead.
- */
- mdev->limits.max_sg = min_t(int, dev_lim->max_sg,
- (dev_lim->max_desc_sz -
- sizeof (struct mthca_next_seg) -
- (mthca_is_memfree(mdev) ?
- sizeof (struct mthca_arbel_ud_seg) :
- sizeof (struct mthca_tavor_ud_seg))) /
- sizeof (struct mthca_data_seg));
- mdev->limits.max_wqes = dev_lim->max_qp_sz;
- mdev->limits.max_qp_init_rdma = dev_lim->max_requester_per_qp;
- mdev->limits.reserved_qps = dev_lim->reserved_qps;
- mdev->limits.max_srq_wqes = dev_lim->max_srq_sz;
- mdev->limits.reserved_srqs = dev_lim->reserved_srqs;
- mdev->limits.reserved_eecs = dev_lim->reserved_eecs;
- mdev->limits.max_desc_sz = dev_lim->max_desc_sz;
- mdev->limits.max_srq_sge = mthca_max_srq_sge(mdev);
- /*
- * Subtract 1 from the limit because we need to allocate a
- * spare CQE so the HCA HW can tell the difference between an
- * empty CQ and a full CQ.
- */
- mdev->limits.max_cqes = dev_lim->max_cq_sz - 1;
- mdev->limits.reserved_cqs = dev_lim->reserved_cqs;
- mdev->limits.reserved_eqs = dev_lim->reserved_eqs;
- mdev->limits.reserved_mtts = dev_lim->reserved_mtts;
- mdev->limits.reserved_mrws = dev_lim->reserved_mrws;
- mdev->limits.reserved_uars = dev_lim->reserved_uars;
- mdev->limits.reserved_pds = dev_lim->reserved_pds;
- mdev->limits.port_width_cap = dev_lim->max_port_width;
- mdev->limits.page_size_cap = ~(u32) (dev_lim->min_page_sz - 1);
- mdev->limits.flags = dev_lim->flags;
- /*
- * For old FW that doesn't return static rate support, use a
- * value of 0x3 (only static rate values of 0 or 1 are handled),
- * except on Sinai, where even old FW can handle static rate
- * values of 2 and 3.
- */
- if (dev_lim->stat_rate_support)
- mdev->limits.stat_rate_support = dev_lim->stat_rate_support;
- else if (mdev->mthca_flags & MTHCA_FLAG_SINAI_OPT)
- mdev->limits.stat_rate_support = 0xf;
- else
- mdev->limits.stat_rate_support = 0x3;
-
- /* IB_DEVICE_RESIZE_MAX_WR not supported by driver.
- May be doable since hardware supports it for SRQ.
-
- IB_DEVICE_N_NOTIFY_CQ is supported by hardware but not by driver.
-
- IB_DEVICE_SRQ_RESIZE is supported by hardware but SRQ is not
- supported by driver. */
- mdev->device_cap_flags = IB_DEVICE_CHANGE_PHY_PORT |
- IB_DEVICE_PORT_ACTIVE_EVENT |
- IB_DEVICE_SYS_IMAGE_GUID |
- IB_DEVICE_RC_RNR_NAK_GEN;
-
- if (dev_lim->flags & DEV_LIM_FLAG_BAD_PKEY_CNTR)
- mdev->device_cap_flags |= IB_DEVICE_BAD_PKEY_CNTR;
-
- if (dev_lim->flags & DEV_LIM_FLAG_BAD_QKEY_CNTR)
- mdev->device_cap_flags |= IB_DEVICE_BAD_QKEY_CNTR;
-
- if (dev_lim->flags & DEV_LIM_FLAG_RAW_MULTI)
- mdev->device_cap_flags |= IB_DEVICE_RAW_MULTI;
-
- if (dev_lim->flags & DEV_LIM_FLAG_AUTO_PATH_MIG)
- mdev->device_cap_flags |= IB_DEVICE_AUTO_PATH_MIG;
-
- if (dev_lim->flags & DEV_LIM_FLAG_UD_AV_PORT_ENFORCE)
- mdev->device_cap_flags |= IB_DEVICE_UD_AV_PORT_ENFORCE;
-
- if (dev_lim->flags & DEV_LIM_FLAG_SRQ)
- mdev->mthca_flags |= MTHCA_FLAG_SRQ;
-
- if (mthca_is_memfree(mdev))
- if (dev_lim->flags & DEV_LIM_FLAG_IPOIB_CSUM)
- mdev->device_cap_flags |= IB_DEVICE_UD_IP_CSUM;
-
- return 0;
-}
-
-static int mthca_init_tavor(struct mthca_dev *mdev)
-{
- s64 size;
- u8 status;
- int err;
- struct mthca_dev_lim dev_lim;
- struct mthca_profile profile;
- struct mthca_init_hca_param init_hca;
-
- err = mthca_SYS_EN(mdev, &status);
- if (err) {
- mthca_err(mdev, "SYS_EN command failed, aborting.\n");
- return err;
- }
- if (status) {
- mthca_err(mdev, "SYS_EN returned status 0x%02x, "
- "aborting.\n", status);
- return -EINVAL;
- }
-
- err = mthca_QUERY_FW(mdev, &status);
- if (err) {
- mthca_err(mdev, "QUERY_FW command failed, aborting.\n");
- goto err_disable;
- }
- if (status) {
- mthca_err(mdev, "QUERY_FW returned status 0x%02x, "
- "aborting.\n", status);
- err = -EINVAL;
- goto err_disable;
- }
- err = mthca_QUERY_DDR(mdev, &status);
- if (err) {
- mthca_err(mdev, "QUERY_DDR command failed, aborting.\n");
- goto err_disable;
- }
- if (status) {
- mthca_err(mdev, "QUERY_DDR returned status 0x%02x, "
- "aborting.\n", status);
- err = -EINVAL;
- goto err_disable;
- }
-
- err = mthca_dev_lim(mdev, &dev_lim);
- if (err) {
- mthca_err(mdev, "QUERY_DEV_LIM command failed, aborting.\n");
- goto err_disable;
- }
-
- profile = hca_profile;
- profile.num_uar = dev_lim.uar_size / PAGE_SIZE;
- profile.uarc_size = 0;
- if (mdev->mthca_flags & MTHCA_FLAG_SRQ)
- profile.num_srq = dev_lim.max_srqs;
-
- size = mthca_make_profile(mdev, &profile, &dev_lim, &init_hca);
- if (size < 0) {
- err = size;
- goto err_disable;
- }
-
- err = mthca_INIT_HCA(mdev, &init_hca, &status);
- if (err) {
- mthca_err(mdev, "INIT_HCA command failed, aborting.\n");
- goto err_disable;
- }
- if (status) {
- mthca_err(mdev, "INIT_HCA returned status 0x%02x, "
- "aborting.\n", status);
- err = -EINVAL;
- goto err_disable;
- }
-
- return 0;
-
-err_disable:
- mthca_SYS_DIS(mdev, &status);
-
- return err;
-}
-
-static int mthca_load_fw(struct mthca_dev *mdev)
-{
- u8 status;
- int err;
-
- /* FIXME: use HCA-attached memory for FW if present */
-
- mdev->fw.arbel.fw_icm =
- mthca_alloc_icm(mdev, mdev->fw.arbel.fw_pages,
- GFP_HIGHUSER | __GFP_NOWARN, 0);
- if (!mdev->fw.arbel.fw_icm) {
- mthca_err(mdev, "Couldn't allocate FW area, aborting.\n");
- return -ENOMEM;
- }
-
- err = mthca_MAP_FA(mdev, mdev->fw.arbel.fw_icm, &status);
- if (err) {
- mthca_err(mdev, "MAP_FA command failed, aborting.\n");
- goto err_free;
- }
- if (status) {
- mthca_err(mdev, "MAP_FA returned status 0x%02x, aborting.\n", status);
- err = -EINVAL;
- goto err_free;
- }
- err = mthca_RUN_FW(mdev, &status);
- if (err) {
- mthca_err(mdev, "RUN_FW command failed, aborting.\n");
- goto err_unmap_fa;
- }
- if (status) {
- mthca_err(mdev, "RUN_FW returned status 0x%02x, aborting.\n", status);
- err = -EINVAL;
- goto err_unmap_fa;
- }
-
- return 0;
-
-err_unmap_fa:
- mthca_UNMAP_FA(mdev, &status);
-
-err_free:
- mthca_free_icm(mdev, mdev->fw.arbel.fw_icm, 0);
- return err;
-}
-
-static int mthca_init_icm(struct mthca_dev *mdev,
- struct mthca_dev_lim *dev_lim,
- struct mthca_init_hca_param *init_hca,
- u64 icm_size)
-{
- u64 aux_pages;
- u8 status;
- int err;
-
- err = mthca_SET_ICM_SIZE(mdev, icm_size, &aux_pages, &status);
- if (err) {
- mthca_err(mdev, "SET_ICM_SIZE command failed, aborting.\n");
- return err;
- }
- if (status) {
- mthca_err(mdev, "SET_ICM_SIZE returned status 0x%02x, "
- "aborting.\n", status);
- return -EINVAL;
- }
-
- mthca_dbg(mdev, "%lld KB of HCA context requires %lld KB aux memory.\n",
- (unsigned long long) icm_size >> 10,
- (unsigned long long) aux_pages << 2);
-
- mdev->fw.arbel.aux_icm = mthca_alloc_icm(mdev, aux_pages,
- GFP_HIGHUSER | __GFP_NOWARN, 0);
- if (!mdev->fw.arbel.aux_icm) {
- mthca_err(mdev, "Couldn't allocate aux memory, aborting.\n");
- return -ENOMEM;
- }
-
- err = mthca_MAP_ICM_AUX(mdev, mdev->fw.arbel.aux_icm, &status);
- if (err) {
- mthca_err(mdev, "MAP_ICM_AUX command failed, aborting.\n");
- goto err_free_aux;
- }
- if (status) {
- mthca_err(mdev, "MAP_ICM_AUX returned status 0x%02x, aborting.\n", status);
- err = -EINVAL;
- goto err_free_aux;
- }
-
- err = mthca_map_eq_icm(mdev, init_hca->eqc_base);
- if (err) {
- mthca_err(mdev, "Failed to map EQ context memory, aborting.\n");
- goto err_unmap_aux;
- }
-
- /* CPU writes to non-reserved MTTs, while HCA might DMA to reserved mtts */
- mdev->limits.reserved_mtts = ALIGN(mdev->limits.reserved_mtts * mdev->limits.mtt_seg_size,
- dma_get_cache_alignment()) / mdev->limits.mtt_seg_size;
-
- mdev->mr_table.mtt_table = mthca_alloc_icm_table(mdev, init_hca->mtt_base,
- mdev->limits.mtt_seg_size,
- mdev->limits.num_mtt_segs,
- mdev->limits.reserved_mtts,
- 1, 0);
- if (!mdev->mr_table.mtt_table) {
- mthca_err(mdev, "Failed to map MTT context memory, aborting.\n");
- err = -ENOMEM;
- goto err_unmap_eq;
- }
-
- mdev->mr_table.mpt_table = mthca_alloc_icm_table(mdev, init_hca->mpt_base,
- dev_lim->mpt_entry_sz,
- mdev->limits.num_mpts,
- mdev->limits.reserved_mrws,
- 1, 1);
- if (!mdev->mr_table.mpt_table) {
- mthca_err(mdev, "Failed to map MPT context memory, aborting.\n");
- err = -ENOMEM;
- goto err_unmap_mtt;
- }
-
- mdev->qp_table.qp_table = mthca_alloc_icm_table(mdev, init_hca->qpc_base,
- dev_lim->qpc_entry_sz,
- mdev->limits.num_qps,
- mdev->limits.reserved_qps,
- 0, 0);
- if (!mdev->qp_table.qp_table) {
- mthca_err(mdev, "Failed to map QP context memory, aborting.\n");
- err = -ENOMEM;
- goto err_unmap_mpt;
- }
-
- mdev->qp_table.eqp_table = mthca_alloc_icm_table(mdev, init_hca->eqpc_base,
- dev_lim->eqpc_entry_sz,
- mdev->limits.num_qps,
- mdev->limits.reserved_qps,
- 0, 0);
- if (!mdev->qp_table.eqp_table) {
- mthca_err(mdev, "Failed to map EQP context memory, aborting.\n");
- err = -ENOMEM;
- goto err_unmap_qp;
- }
-
- mdev->qp_table.rdb_table = mthca_alloc_icm_table(mdev, init_hca->rdb_base,
- MTHCA_RDB_ENTRY_SIZE,
- mdev->limits.num_qps <<
- mdev->qp_table.rdb_shift, 0,
- 0, 0);
- if (!mdev->qp_table.rdb_table) {
- mthca_err(mdev, "Failed to map RDB context memory, aborting\n");
- err = -ENOMEM;
- goto err_unmap_eqp;
- }
-
- mdev->cq_table.table = mthca_alloc_icm_table(mdev, init_hca->cqc_base,
- dev_lim->cqc_entry_sz,
- mdev->limits.num_cqs,
- mdev->limits.reserved_cqs,
- 0, 0);
- if (!mdev->cq_table.table) {
- mthca_err(mdev, "Failed to map CQ context memory, aborting.\n");
- err = -ENOMEM;
- goto err_unmap_rdb;
- }
-
- if (mdev->mthca_flags & MTHCA_FLAG_SRQ) {
- mdev->srq_table.table =
- mthca_alloc_icm_table(mdev, init_hca->srqc_base,
- dev_lim->srq_entry_sz,
- mdev->limits.num_srqs,
- mdev->limits.reserved_srqs,
- 0, 0);
- if (!mdev->srq_table.table) {
- mthca_err(mdev, "Failed to map SRQ context memory, "
- "aborting.\n");
- err = -ENOMEM;
- goto err_unmap_cq;
- }
- }
-
- /*
- * It's not strictly required, but for simplicity just map the
- * whole multicast group table now. The table isn't very big
- * and it's a lot easier than trying to track ref counts.
- */
- mdev->mcg_table.table = mthca_alloc_icm_table(mdev, init_hca->mc_base,
- MTHCA_MGM_ENTRY_SIZE,
- mdev->limits.num_mgms +
- mdev->limits.num_amgms,
- mdev->limits.num_mgms +
- mdev->limits.num_amgms,
- 0, 0);
- if (!mdev->mcg_table.table) {
- mthca_err(mdev, "Failed to map MCG context memory, aborting.\n");
- err = -ENOMEM;
- goto err_unmap_srq;
- }
-
- return 0;
-
-err_unmap_srq:
- if (mdev->mthca_flags & MTHCA_FLAG_SRQ)
- mthca_free_icm_table(mdev, mdev->srq_table.table);
-
-err_unmap_cq:
- mthca_free_icm_table(mdev, mdev->cq_table.table);
-
-err_unmap_rdb:
- mthca_free_icm_table(mdev, mdev->qp_table.rdb_table);
-
-err_unmap_eqp:
- mthca_free_icm_table(mdev, mdev->qp_table.eqp_table);
-
-err_unmap_qp:
- mthca_free_icm_table(mdev, mdev->qp_table.qp_table);
-
-err_unmap_mpt:
- mthca_free_icm_table(mdev, mdev->mr_table.mpt_table);
-
-err_unmap_mtt:
- mthca_free_icm_table(mdev, mdev->mr_table.mtt_table);
-
-err_unmap_eq:
- mthca_unmap_eq_icm(mdev);
-
-err_unmap_aux:
- mthca_UNMAP_ICM_AUX(mdev, &status);
-
-err_free_aux:
- mthca_free_icm(mdev, mdev->fw.arbel.aux_icm, 0);
-
- return err;
-}
-
-static void mthca_free_icms(struct mthca_dev *mdev)
-{
- u8 status;
-
- mthca_free_icm_table(mdev, mdev->mcg_table.table);
- if (mdev->mthca_flags & MTHCA_FLAG_SRQ)
- mthca_free_icm_table(mdev, mdev->srq_table.table);
- mthca_free_icm_table(mdev, mdev->cq_table.table);
- mthca_free_icm_table(mdev, mdev->qp_table.rdb_table);
- mthca_free_icm_table(mdev, mdev->qp_table.eqp_table);
- mthca_free_icm_table(mdev, mdev->qp_table.qp_table);
- mthca_free_icm_table(mdev, mdev->mr_table.mpt_table);
- mthca_free_icm_table(mdev, mdev->mr_table.mtt_table);
- mthca_unmap_eq_icm(mdev);
-
- mthca_UNMAP_ICM_AUX(mdev, &status);
- mthca_free_icm(mdev, mdev->fw.arbel.aux_icm, 0);
-}
-
-static int mthca_init_arbel(struct mthca_dev *mdev)
-{
- struct mthca_dev_lim dev_lim;
- struct mthca_profile profile;
- struct mthca_init_hca_param init_hca;
- s64 icm_size;
- u8 status;
- int err;
-
- err = mthca_QUERY_FW(mdev, &status);
- if (err) {
- mthca_err(mdev, "QUERY_FW command failed, aborting.\n");
- return err;
- }
- if (status) {
- mthca_err(mdev, "QUERY_FW returned status 0x%02x, "
- "aborting.\n", status);
- return -EINVAL;
- }
-
- err = mthca_ENABLE_LAM(mdev, &status);
- if (err) {
- mthca_err(mdev, "ENABLE_LAM command failed, aborting.\n");
- return err;
- }
- if (status == MTHCA_CMD_STAT_LAM_NOT_PRE) {
- mthca_dbg(mdev, "No HCA-attached memory (running in MemFree mode)\n");
- mdev->mthca_flags |= MTHCA_FLAG_NO_LAM;
- } else if (status) {
- mthca_err(mdev, "ENABLE_LAM returned status 0x%02x, "
- "aborting.\n", status);
- return -EINVAL;
- }
-
- err = mthca_load_fw(mdev);
- if (err) {
- mthca_err(mdev, "Failed to start FW, aborting.\n");
- goto err_disable;
- }
-
- err = mthca_dev_lim(mdev, &dev_lim);
- if (err) {
- mthca_err(mdev, "QUERY_DEV_LIM command failed, aborting.\n");
- goto err_stop_fw;
- }
-
- profile = hca_profile;
- profile.num_uar = dev_lim.uar_size / PAGE_SIZE;
- profile.num_udav = 0;
- if (mdev->mthca_flags & MTHCA_FLAG_SRQ)
- profile.num_srq = dev_lim.max_srqs;
-
- icm_size = mthca_make_profile(mdev, &profile, &dev_lim, &init_hca);
- if (icm_size < 0) {
- err = icm_size;
- goto err_stop_fw;
- }
-
- err = mthca_init_icm(mdev, &dev_lim, &init_hca, icm_size);
- if (err)
- goto err_stop_fw;
-
- err = mthca_INIT_HCA(mdev, &init_hca, &status);
- if (err) {
- mthca_err(mdev, "INIT_HCA command failed, aborting.\n");
- goto err_free_icm;
- }
- if (status) {
- mthca_err(mdev, "INIT_HCA returned status 0x%02x, "
- "aborting.\n", status);
- err = -EINVAL;
- goto err_free_icm;
- }
-
- return 0;
-
-err_free_icm:
- mthca_free_icms(mdev);
-
-err_stop_fw:
- mthca_UNMAP_FA(mdev, &status);
- mthca_free_icm(mdev, mdev->fw.arbel.fw_icm, 0);
-
-err_disable:
- if (!(mdev->mthca_flags & MTHCA_FLAG_NO_LAM))
- mthca_DISABLE_LAM(mdev, &status);
-
- return err;
-}
-
-static void mthca_close_hca(struct mthca_dev *mdev)
-{
- u8 status;
-
- mthca_CLOSE_HCA(mdev, 0, &status);
-
- if (mthca_is_memfree(mdev)) {
- mthca_free_icms(mdev);
-
- mthca_UNMAP_FA(mdev, &status);
- mthca_free_icm(mdev, mdev->fw.arbel.fw_icm, 0);
-
- if (!(mdev->mthca_flags & MTHCA_FLAG_NO_LAM))
- mthca_DISABLE_LAM(mdev, &status);
- } else
- mthca_SYS_DIS(mdev, &status);
-}
-
-static int mthca_init_hca(struct mthca_dev *mdev)
-{
- u8 status;
- int err;
- struct mthca_adapter adapter;
-
- if (mthca_is_memfree(mdev))
- err = mthca_init_arbel(mdev);
- else
- err = mthca_init_tavor(mdev);
-
- if (err)
- return err;
-
- err = mthca_QUERY_ADAPTER(mdev, &adapter, &status);
- if (err) {
- mthca_err(mdev, "QUERY_ADAPTER command failed, aborting.\n");
- goto err_close;
- }
- if (status) {
- mthca_err(mdev, "QUERY_ADAPTER returned status 0x%02x, "
- "aborting.\n", status);
- err = -EINVAL;
- goto err_close;
- }
-
- mdev->eq_table.inta_pin = adapter.inta_pin;
- if (!mthca_is_memfree(mdev))
- mdev->rev_id = adapter.revision_id;
- memcpy(mdev->board_id, adapter.board_id, sizeof mdev->board_id);
-
- return 0;
-
-err_close:
- mthca_close_hca(mdev);
- return err;
-}
-
-static int mthca_setup_hca(struct mthca_dev *dev)
-{
- int err;
- u8 status;
-
- MTHCA_INIT_DOORBELL_LOCK(&dev->doorbell_lock);
-
- err = mthca_init_uar_table(dev);
- if (err) {
- mthca_err(dev, "Failed to initialize "
- "user access region table, aborting.\n");
- return err;
- }
-
- err = mthca_uar_alloc(dev, &dev->driver_uar);
- if (err) {
- mthca_err(dev, "Failed to allocate driver access region, "
- "aborting.\n");
- goto err_uar_table_free;
- }
-
- dev->kar = ioremap(dev->driver_uar.pfn << PAGE_SHIFT, PAGE_SIZE);
- if (!dev->kar) {
- mthca_err(dev, "Couldn't map kernel access region, "
- "aborting.\n");
- err = -ENOMEM;
- goto err_uar_free;
- }
-
- err = mthca_init_pd_table(dev);
- if (err) {
- mthca_err(dev, "Failed to initialize "
- "protection domain table, aborting.\n");
- goto err_kar_unmap;
- }
-
- err = mthca_init_mr_table(dev);
- if (err) {
- mthca_err(dev, "Failed to initialize "
- "memory region table, aborting.\n");
- goto err_pd_table_free;
- }
-
- err = mthca_pd_alloc(dev, 1, &dev->driver_pd);
- if (err) {
- mthca_err(dev, "Failed to create driver PD, "
- "aborting.\n");
- goto err_mr_table_free;
- }
-
- err = mthca_init_eq_table(dev);
- if (err) {
- mthca_err(dev, "Failed to initialize "
- "event queue table, aborting.\n");
- goto err_pd_free;
- }
-
- err = mthca_cmd_use_events(dev);
- if (err) {
- mthca_err(dev, "Failed to switch to event-driven "
- "firmware commands, aborting.\n");
- goto err_eq_table_free;
- }
-
- err = mthca_NOP(dev, &status);
- if (err || status) {
- if (dev->mthca_flags & MTHCA_FLAG_MSI_X) {
- mthca_warn(dev, "NOP command failed to generate interrupt "
- "(IRQ %d).\n",
- dev->eq_table.eq[MTHCA_EQ_CMD].msi_x_vector);
- mthca_warn(dev, "Trying again with MSI-X disabled.\n");
- } else {
- mthca_err(dev, "NOP command failed to generate interrupt "
- "(IRQ %d), aborting.\n",
- dev->pdev->irq);
- mthca_err(dev, "BIOS or ACPI interrupt routing problem?\n");
- }
-
- goto err_cmd_poll;
- }
-
- mthca_dbg(dev, "NOP command IRQ test passed\n");
-
- err = mthca_init_cq_table(dev);
- if (err) {
- mthca_err(dev, "Failed to initialize "
- "completion queue table, aborting.\n");
- goto err_cmd_poll;
- }
-
- err = mthca_init_srq_table(dev);
- if (err) {
- mthca_err(dev, "Failed to initialize "
- "shared receive queue table, aborting.\n");
- goto err_cq_table_free;
- }
-
- err = mthca_init_qp_table(dev);
- if (err) {
- mthca_err(dev, "Failed to initialize "
- "queue pair table, aborting.\n");
- goto err_srq_table_free;
- }
-
- err = mthca_init_av_table(dev);
- if (err) {
- mthca_err(dev, "Failed to initialize "
- "address vector table, aborting.\n");
- goto err_qp_table_free;
- }
-
- err = mthca_init_mcg_table(dev);
- if (err) {
- mthca_err(dev, "Failed to initialize "
- "multicast group table, aborting.\n");
- goto err_av_table_free;
- }
-
- return 0;
-
-err_av_table_free:
- mthca_cleanup_av_table(dev);
-
-err_qp_table_free:
- mthca_cleanup_qp_table(dev);
-
-err_srq_table_free:
- mthca_cleanup_srq_table(dev);
-
-err_cq_table_free:
- mthca_cleanup_cq_table(dev);
-
-err_cmd_poll:
- mthca_cmd_use_polling(dev);
-
-err_eq_table_free:
- mthca_cleanup_eq_table(dev);
-
-err_pd_free:
- mthca_pd_free(dev, &dev->driver_pd);
-
-err_mr_table_free:
- mthca_cleanup_mr_table(dev);
-
-err_pd_table_free:
- mthca_cleanup_pd_table(dev);
-
-err_kar_unmap:
- iounmap(dev->kar);
-
-err_uar_free:
- mthca_uar_free(dev, &dev->driver_uar);
-
-err_uar_table_free:
- mthca_cleanup_uar_table(dev);
- return err;
-}
-
-static int mthca_enable_msi_x(struct mthca_dev *mdev)
-{
- struct msix_entry entries[3];
- int err;
-
- entries[0].entry = 0;
- entries[1].entry = 1;
- entries[2].entry = 2;
-
- err = pci_enable_msix(mdev->pdev, entries, ARRAY_SIZE(entries));
- if (err) {
- if (err > 0)
- mthca_info(mdev, "Only %d MSI-X vectors available, "
- "not using MSI-X\n", err);
- return err;
- }
-
- mdev->eq_table.eq[MTHCA_EQ_COMP ].msi_x_vector = entries[0].vector;
- mdev->eq_table.eq[MTHCA_EQ_ASYNC].msi_x_vector = entries[1].vector;
- mdev->eq_table.eq[MTHCA_EQ_CMD ].msi_x_vector = entries[2].vector;
-
- return 0;
-}
-
-/* Types of supported HCA */
-enum {
- TAVOR, /* MT23108 */
- ARBEL_COMPAT, /* MT25208 in Tavor compat mode */
- ARBEL_NATIVE, /* MT25208 with extended features */
- SINAI /* MT25204 */
-};
-
-#define MTHCA_FW_VER(major, minor, subminor) \
- (((u64) (major) << 32) | ((u64) (minor) << 16) | (u64) (subminor))
-
-static struct {
- u64 latest_fw;
- u32 flags;
-} mthca_hca_table[] = {
- [TAVOR] = { .latest_fw = MTHCA_FW_VER(3, 5, 0),
- .flags = 0 },
- [ARBEL_COMPAT] = { .latest_fw = MTHCA_FW_VER(4, 8, 200),
- .flags = MTHCA_FLAG_PCIE },
- [ARBEL_NATIVE] = { .latest_fw = MTHCA_FW_VER(5, 3, 0),
- .flags = MTHCA_FLAG_MEMFREE |
- MTHCA_FLAG_PCIE },
- [SINAI] = { .latest_fw = MTHCA_FW_VER(1, 2, 0),
- .flags = MTHCA_FLAG_MEMFREE |
- MTHCA_FLAG_PCIE |
- MTHCA_FLAG_SINAI_OPT }
-};
-
-static int __mthca_init_one(struct pci_dev *pdev, int hca_type)
-{
- int ddr_hidden = 0;
- int err;
- struct mthca_dev *mdev;
-
- printk(KERN_INFO PFX "Initializing %s\n",
- pci_name(pdev));
-
- err = pci_enable_device(pdev);
- if (err) {
- dev_err(&pdev->dev, "Cannot enable PCI device, "
- "aborting.\n");
- return err;
- }
-
- /*
- * Check for BARs. We expect 0: 1MB, 2: 8MB, 4: DDR (may not
- * be present)
- */
- if (!(pci_resource_flags(pdev, 0) & IORESOURCE_MEM) ||
- pci_resource_len(pdev, 0) != 1 << 20) {
- dev_err(&pdev->dev, "Missing DCS, aborting.\n");
- err = -ENODEV;
- goto err_disable_pdev;
- }
- if (!(pci_resource_flags(pdev, 2) & IORESOURCE_MEM)) {
- dev_err(&pdev->dev, "Missing UAR, aborting.\n");
- err = -ENODEV;
- goto err_disable_pdev;
- }
- if (!(pci_resource_flags(pdev, 4) & IORESOURCE_MEM))
- ddr_hidden = 1;
-
- err = pci_request_regions(pdev, DRV_NAME);
- if (err) {
- dev_err(&pdev->dev, "Cannot obtain PCI resources, "
- "aborting.\n");
- goto err_disable_pdev;
- }
-
- pci_set_master(pdev);
-
- err = pci_set_dma_mask(pdev, DMA_BIT_MASK(64));
- if (err) {
- dev_warn(&pdev->dev, "Warning: couldn't set 64-bit PCI DMA mask.\n");
- err = pci_set_dma_mask(pdev, DMA_BIT_MASK(32));
- if (err) {
- dev_err(&pdev->dev, "Can't set PCI DMA mask, aborting.\n");
- goto err_free_res;
- }
- }
- err = pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(64));
- if (err) {
- dev_warn(&pdev->dev, "Warning: couldn't set 64-bit "
- "consistent PCI DMA mask.\n");
- err = pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(32));
- if (err) {
- dev_err(&pdev->dev, "Can't set consistent PCI DMA mask, "
- "aborting.\n");
- goto err_free_res;
- }
- }
-
- mdev = (struct mthca_dev *) ib_alloc_device(sizeof *mdev);
- if (!mdev) {
- dev_err(&pdev->dev, "Device struct alloc failed, "
- "aborting.\n");
- err = -ENOMEM;
- goto err_free_res;
- }
-
- mdev->pdev = pdev;
-
- mdev->mthca_flags = mthca_hca_table[hca_type].flags;
- if (ddr_hidden)
- mdev->mthca_flags |= MTHCA_FLAG_DDR_HIDDEN;
-
- /*
- * Now reset the HCA before we touch the PCI capabilities or
- * attempt a firmware command, since a boot ROM may have left
- * the HCA in an undefined state.
- */
- err = mthca_reset(mdev);
- if (err) {
- mthca_err(mdev, "Failed to reset HCA, aborting.\n");
- goto err_free_dev;
- }
-
- if (mthca_cmd_init(mdev)) {
- mthca_err(mdev, "Failed to init command interface, aborting.\n");
- goto err_free_dev;
- }
-
- err = mthca_tune_pci(mdev);
- if (err)
- goto err_cmd;
-
- err = mthca_init_hca(mdev);
- if (err)
- goto err_cmd;
-
- if (mdev->fw_ver < mthca_hca_table[hca_type].latest_fw) {
- mthca_warn(mdev, "HCA FW version %d.%d.%03d is old (%d.%d.%03d is current).\n",
- (int) (mdev->fw_ver >> 32), (int) (mdev->fw_ver >> 16) & 0xffff,
- (int) (mdev->fw_ver & 0xffff),
- (int) (mthca_hca_table[hca_type].latest_fw >> 32),
- (int) (mthca_hca_table[hca_type].latest_fw >> 16) & 0xffff,
- (int) (mthca_hca_table[hca_type].latest_fw & 0xffff));
- mthca_warn(mdev, "If you have problems, try updating your HCA FW.\n");
- }
-
- if (msi_x && !mthca_enable_msi_x(mdev))
- mdev->mthca_flags |= MTHCA_FLAG_MSI_X;
-
- err = mthca_setup_hca(mdev);
- if (err == -EBUSY && (mdev->mthca_flags & MTHCA_FLAG_MSI_X)) {
- if (mdev->mthca_flags & MTHCA_FLAG_MSI_X)
- pci_disable_msix(pdev);
- mdev->mthca_flags &= ~MTHCA_FLAG_MSI_X;
-
- err = mthca_setup_hca(mdev);
- }
-
- if (err)
- goto err_close;
-
- err = mthca_register_device(mdev);
- if (err)
- goto err_cleanup;
-
- err = mthca_create_agents(mdev);
- if (err)
- goto err_unregister;
-
- pci_set_drvdata(pdev, mdev);
- mdev->hca_type = hca_type;
-
- mdev->active = 1;
-
- return 0;
-
-err_unregister:
- mthca_unregister_device(mdev);
-
-err_cleanup:
- mthca_cleanup_mcg_table(mdev);
- mthca_cleanup_av_table(mdev);
- mthca_cleanup_qp_table(mdev);
- mthca_cleanup_srq_table(mdev);
- mthca_cleanup_cq_table(mdev);
- mthca_cmd_use_polling(mdev);
- mthca_cleanup_eq_table(mdev);
-
- mthca_pd_free(mdev, &mdev->driver_pd);
-
- mthca_cleanup_mr_table(mdev);
- mthca_cleanup_pd_table(mdev);
- mthca_cleanup_uar_table(mdev);
-
-err_close:
- if (mdev->mthca_flags & MTHCA_FLAG_MSI_X)
- pci_disable_msix(pdev);
-
- mthca_close_hca(mdev);
-
-err_cmd:
- mthca_cmd_cleanup(mdev);
-
-err_free_dev:
- ib_dealloc_device(&mdev->ib_dev);
-
-err_free_res:
- pci_release_regions(pdev);
-
-err_disable_pdev:
- pci_disable_device(pdev);
- pci_set_drvdata(pdev, NULL);
- return err;
-}
-
-static void __mthca_remove_one(struct pci_dev *pdev)
-{
- struct mthca_dev *mdev = pci_get_drvdata(pdev);
- u8 status;
- int p;
-
- if (mdev) {
- mthca_free_agents(mdev);
- mthca_unregister_device(mdev);
-
- for (p = 1; p <= mdev->limits.num_ports; ++p)
- mthca_CLOSE_IB(mdev, p, &status);
-
- mthca_cleanup_mcg_table(mdev);
- mthca_cleanup_av_table(mdev);
- mthca_cleanup_qp_table(mdev);
- mthca_cleanup_srq_table(mdev);
- mthca_cleanup_cq_table(mdev);
- mthca_cmd_use_polling(mdev);
- mthca_cleanup_eq_table(mdev);
-
- mthca_pd_free(mdev, &mdev->driver_pd);
-
- mthca_cleanup_mr_table(mdev);
- mthca_cleanup_pd_table(mdev);
-
- iounmap(mdev->kar);
- mthca_uar_free(mdev, &mdev->driver_uar);
- mthca_cleanup_uar_table(mdev);
- mthca_close_hca(mdev);
- mthca_cmd_cleanup(mdev);
-
- if (mdev->mthca_flags & MTHCA_FLAG_MSI_X)
- pci_disable_msix(pdev);
-
- ib_dealloc_device(&mdev->ib_dev);
- pci_release_regions(pdev);
- pci_disable_device(pdev);
- pci_set_drvdata(pdev, NULL);
- }
-}
-
-int __mthca_restart_one(struct pci_dev *pdev)
-{
- struct mthca_dev *mdev;
- int hca_type;
-
- mdev = pci_get_drvdata(pdev);
- if (!mdev)
- return -ENODEV;
- hca_type = mdev->hca_type;
- __mthca_remove_one(pdev);
- return __mthca_init_one(pdev, hca_type);
-}
-
-static int __devinit mthca_init_one(struct pci_dev *pdev,
- const struct pci_device_id *id)
-{
- static int mthca_version_printed = 0;
- int ret;
-
- mutex_lock(&mthca_device_mutex);
-
- if (!mthca_version_printed) {
- printk(KERN_INFO "%s", mthca_version);
- ++mthca_version_printed;
- }
-
- if (id->driver_data >= ARRAY_SIZE(mthca_hca_table)) {
- printk(KERN_ERR PFX "%s has invalid driver data %jx\n",
- pci_name(pdev), (uintmax_t)id->driver_data);
- mutex_unlock(&mthca_device_mutex);
- return -ENODEV;
- }
-
- ret = __mthca_init_one(pdev, id->driver_data);
-
- mutex_unlock(&mthca_device_mutex);
-
- return ret;
-}
-
-static void __devexit mthca_remove_one(struct pci_dev *pdev)
-{
- mutex_lock(&mthca_device_mutex);
- __mthca_remove_one(pdev);
- mutex_unlock(&mthca_device_mutex);
-}
-
-static struct pci_device_id mthca_pci_table[] = {
- { PCI_DEVICE(PCI_VENDOR_ID_MELLANOX, PCI_DEVICE_ID_MELLANOX_TAVOR),
- .driver_data = TAVOR },
- { PCI_DEVICE(PCI_VENDOR_ID_TOPSPIN, PCI_DEVICE_ID_MELLANOX_TAVOR),
- .driver_data = TAVOR },
- { PCI_DEVICE(PCI_VENDOR_ID_MELLANOX, PCI_DEVICE_ID_MELLANOX_ARBEL_COMPAT),
- .driver_data = ARBEL_COMPAT },
- { PCI_DEVICE(PCI_VENDOR_ID_TOPSPIN, PCI_DEVICE_ID_MELLANOX_ARBEL_COMPAT),
- .driver_data = ARBEL_COMPAT },
- { PCI_DEVICE(PCI_VENDOR_ID_MELLANOX, PCI_DEVICE_ID_MELLANOX_ARBEL),
- .driver_data = ARBEL_NATIVE },
- { PCI_DEVICE(PCI_VENDOR_ID_TOPSPIN, PCI_DEVICE_ID_MELLANOX_ARBEL),
- .driver_data = ARBEL_NATIVE },
- { PCI_DEVICE(PCI_VENDOR_ID_MELLANOX, PCI_DEVICE_ID_MELLANOX_SINAI),
- .driver_data = SINAI },
- { PCI_DEVICE(PCI_VENDOR_ID_TOPSPIN, PCI_DEVICE_ID_MELLANOX_SINAI),
- .driver_data = SINAI },
- { PCI_DEVICE(PCI_VENDOR_ID_MELLANOX, PCI_DEVICE_ID_MELLANOX_SINAI_OLD),
- .driver_data = SINAI },
- { PCI_DEVICE(PCI_VENDOR_ID_TOPSPIN, PCI_DEVICE_ID_MELLANOX_SINAI_OLD),
- .driver_data = SINAI },
- { 0, }
-};
-
-MODULE_DEVICE_TABLE(pci, mthca_pci_table);
-
-static struct pci_driver mthca_driver = {
- .name = DRV_NAME,
- .id_table = mthca_pci_table,
- .probe = mthca_init_one,
- .remove = __devexit_p(mthca_remove_one)
-};
-
-static void __init __mthca_check_profile_val(const char *name, int *pval,
- int pval_default)
-{
- /* value must be positive and power of 2 */
- int old_pval = *pval;
-
- if (old_pval <= 0)
- *pval = pval_default;
- else
- *pval = roundup_pow_of_two(old_pval);
-
- if (old_pval != *pval) {
- printk(KERN_WARNING PFX "Invalid value %d for %s in module parameter.\n",
- old_pval, name);
- printk(KERN_WARNING PFX "Corrected %s to %d.\n", name, *pval);
- }
-}
-
-#define mthca_check_profile_val(name, default) \
- __mthca_check_profile_val(#name, &hca_profile.name, default)
-
-static void __init mthca_validate_profile(void)
-{
- mthca_check_profile_val(num_qp, MTHCA_DEFAULT_NUM_QP);
- mthca_check_profile_val(rdb_per_qp, MTHCA_DEFAULT_RDB_PER_QP);
- mthca_check_profile_val(num_cq, MTHCA_DEFAULT_NUM_CQ);
- mthca_check_profile_val(num_mcg, MTHCA_DEFAULT_NUM_MCG);
- mthca_check_profile_val(num_mpt, MTHCA_DEFAULT_NUM_MPT);
- mthca_check_profile_val(num_mtt, MTHCA_DEFAULT_NUM_MTT);
- mthca_check_profile_val(num_udav, MTHCA_DEFAULT_NUM_UDAV);
- mthca_check_profile_val(fmr_reserved_mtts, MTHCA_DEFAULT_NUM_RESERVED_MTTS);
-
- if (hca_profile.fmr_reserved_mtts >= hca_profile.num_mtt) {
- printk(KERN_WARNING PFX "Invalid fmr_reserved_mtts module parameter %d.\n",
- hca_profile.fmr_reserved_mtts);
- printk(KERN_WARNING PFX "(Must be smaller than num_mtt %d)\n",
- hca_profile.num_mtt);
- hca_profile.fmr_reserved_mtts = hca_profile.num_mtt / 2;
- printk(KERN_WARNING PFX "Corrected fmr_reserved_mtts to %d.\n",
- hca_profile.fmr_reserved_mtts);
- }
- if (log_mtts_per_seg == 0)
- log_mtts_per_seg = ilog2(MTHCA_MTT_SEG_SIZE / 8);
- if ((log_mtts_per_seg < 1) || (log_mtts_per_seg > 5)) {
- printk(KERN_WARNING PFX "bad log_mtts_per_seg (%d). Using default - %d\n",
- log_mtts_per_seg, ilog2(MTHCA_MTT_SEG_SIZE / 8));
- log_mtts_per_seg = ilog2(MTHCA_MTT_SEG_SIZE / 8);
- }
-}
-
-static int __init mthca_init(void)
-{
- int ret;
-
- mthca_validate_profile();
-
- ret = mthca_catas_init();
- if (ret)
- return ret;
-
- ret = pci_register_driver(&mthca_driver);
- if (ret < 0) {
- mthca_catas_cleanup();
- return ret;
- }
-
- return 0;
-}
-
-static void __exit mthca_cleanup(void)
-{
- pci_unregister_driver(&mthca_driver);
- mthca_catas_cleanup();
-}
-
-module_init_order(mthca_init, SI_ORDER_MIDDLE);
-module_exit(mthca_cleanup);
diff --git a/sys/ofed/drivers/infiniband/hw/mthca/mthca_mcg.c b/sys/ofed/drivers/infiniband/hw/mthca/mthca_mcg.c
deleted file mode 100644
index 6274a1c..0000000
--- a/sys/ofed/drivers/infiniband/hw/mthca/mthca_mcg.c
+++ /dev/null
@@ -1,372 +0,0 @@
-/*
- * Copyright (c) 2004 Topspin Communications. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-#include <linux/string.h>
-#include <linux/slab.h>
-
-#include "mthca_dev.h"
-#include "mthca_cmd.h"
-
-struct mthca_mgm {
- __be32 next_gid_index;
- u32 reserved[3];
- u8 gid[16];
- __be32 qp[MTHCA_QP_PER_MGM];
-};
-
-static const u8 zero_gid[16]; /* automatically initialized to 0 */
-
-/*
- * Caller must hold MCG table semaphore. gid and mgm parameters must
- * be properly aligned for command interface.
- *
- * Returns 0 unless a firmware command error occurs.
- *
- * If GID is found in MGM or MGM is empty, *index = *hash, *prev = -1
- * and *mgm holds MGM entry.
- *
- * if GID is found in AMGM, *index = index in AMGM, *prev = index of
- * previous entry in hash chain and *mgm holds AMGM entry.
- *
- * If no AMGM exists for given gid, *index = -1, *prev = index of last
- * entry in hash chain and *mgm holds end of hash chain.
- */
-static int find_mgm(struct mthca_dev *dev,
- u8 *gid, struct mthca_mailbox *mgm_mailbox,
- u16 *hash, int *prev, int *index)
-{
- struct mthca_mailbox *mailbox;
- struct mthca_mgm *mgm = mgm_mailbox->buf;
- u8 *mgid;
- int err;
- u8 status;
-
- mailbox = mthca_alloc_mailbox(dev, GFP_KERNEL);
- if (IS_ERR(mailbox))
- return -ENOMEM;
- mgid = mailbox->buf;
-
- memcpy(mgid, gid, 16);
-
- err = mthca_MGID_HASH(dev, mailbox, hash, &status);
- if (err)
- goto out;
- if (status) {
- mthca_err(dev, "MGID_HASH returned status %02x\n", status);
- err = -EINVAL;
- goto out;
- }
-
- if (0)
- mthca_dbg(dev, "Hash for %pI6 is %04x\n", gid, *hash);
-
- *index = *hash;
- *prev = -1;
-
- do {
- err = mthca_READ_MGM(dev, *index, mgm_mailbox, &status);
- if (err)
- goto out;
- if (status) {
- mthca_err(dev, "READ_MGM returned status %02x\n", status);
- err = -EINVAL;
- goto out;
- }
-
- if (!memcmp(mgm->gid, zero_gid, 16)) {
- if (*index != *hash) {
- mthca_err(dev, "Found zero MGID in AMGM.\n");
- err = -EINVAL;
- }
- goto out;
- }
-
- if (!memcmp(mgm->gid, gid, 16))
- goto out;
-
- *prev = *index;
- *index = be32_to_cpu(mgm->next_gid_index) >> 6;
- } while (*index);
-
- *index = -1;
-
- out:
- mthca_free_mailbox(dev, mailbox);
- return err;
-}
-
-int mthca_multicast_attach(struct ib_qp *ibqp, union ib_gid *gid, u16 lid)
-{
- struct mthca_dev *dev = to_mdev(ibqp->device);
- struct mthca_mailbox *mailbox;
- struct mthca_mgm *mgm;
- u16 hash;
- int index, prev;
- int link = 0;
- int i;
- int err;
- u8 status;
-
- mailbox = mthca_alloc_mailbox(dev, GFP_KERNEL);
- if (IS_ERR(mailbox))
- return PTR_ERR(mailbox);
- mgm = mailbox->buf;
-
- mutex_lock(&dev->mcg_table.mutex);
-
- err = find_mgm(dev, gid->raw, mailbox, &hash, &prev, &index);
- if (err)
- goto out;
-
- if (index != -1) {
- if (!memcmp(mgm->gid, zero_gid, 16))
- memcpy(mgm->gid, gid->raw, 16);
- } else {
- link = 1;
-
- index = mthca_alloc(&dev->mcg_table.alloc);
- if (index == -1) {
- mthca_err(dev, "No AMGM entries left\n");
- err = -ENOMEM;
- goto out;
- }
-
- err = mthca_READ_MGM(dev, index, mailbox, &status);
- if (err)
- goto out;
- if (status) {
- mthca_err(dev, "READ_MGM returned status %02x\n", status);
- err = -EINVAL;
- goto out;
- }
- memset(mgm, 0, sizeof *mgm);
- memcpy(mgm->gid, gid->raw, 16);
- }
-
- for (i = 0; i < MTHCA_QP_PER_MGM; ++i)
- if (mgm->qp[i] == cpu_to_be32(ibqp->qp_num | (1U << 31))) {
- mthca_dbg(dev, "QP %06x already a member of MGM\n",
- ibqp->qp_num);
- err = 0;
- goto out;
- } else if (!(mgm->qp[i] & cpu_to_be32(1U << 31))) {
- mgm->qp[i] = cpu_to_be32(ibqp->qp_num | (1U << 31));
- break;
- }
-
- if (i == MTHCA_QP_PER_MGM) {
- mthca_err(dev, "MGM at index %x is full.\n", index);
- err = -ENOMEM;
- goto out;
- }
-
- err = mthca_WRITE_MGM(dev, index, mailbox, &status);
- if (err)
- goto out;
- if (status) {
- mthca_err(dev, "WRITE_MGM returned status %02x\n", status);
- err = -EINVAL;
- goto out;
- }
-
- if (!link)
- goto out;
-
- err = mthca_READ_MGM(dev, prev, mailbox, &status);
- if (err)
- goto out;
- if (status) {
- mthca_err(dev, "READ_MGM returned status %02x\n", status);
- err = -EINVAL;
- goto out;
- }
-
- mgm->next_gid_index = cpu_to_be32(index << 6);
-
- err = mthca_WRITE_MGM(dev, prev, mailbox, &status);
- if (err)
- goto out;
- if (status) {
- mthca_err(dev, "WRITE_MGM returned status %02x\n", status);
- err = -EINVAL;
- }
-
- out:
- if (err && link && index != -1) {
- BUG_ON(index < dev->limits.num_mgms);
- mthca_free(&dev->mcg_table.alloc, index);
- }
- mutex_unlock(&dev->mcg_table.mutex);
-
- mthca_free_mailbox(dev, mailbox);
- return err;
-}
-
-int mthca_multicast_detach(struct ib_qp *ibqp, union ib_gid *gid, u16 lid)
-{
- struct mthca_dev *dev = to_mdev(ibqp->device);
- struct mthca_mailbox *mailbox;
- struct mthca_mgm *mgm;
- u16 hash;
- int prev, index;
- int i, loc;
- int err;
- u8 status;
-
- mailbox = mthca_alloc_mailbox(dev, GFP_KERNEL);
- if (IS_ERR(mailbox))
- return PTR_ERR(mailbox);
- mgm = mailbox->buf;
-
- mutex_lock(&dev->mcg_table.mutex);
-
- err = find_mgm(dev, gid->raw, mailbox, &hash, &prev, &index);
- if (err)
- goto out;
-
- if (index == -1) {
- mthca_err(dev, "MGID %pI6 not found\n", gid->raw);
- err = -EINVAL;
- goto out;
- }
-
- for (loc = -1, i = 0; i < MTHCA_QP_PER_MGM; ++i) {
- if (mgm->qp[i] == cpu_to_be32(ibqp->qp_num | (1U << 31)))
- loc = i;
- if (!(mgm->qp[i] & cpu_to_be32(1U << 31)))
- break;
- }
-
- if (loc == -1) {
- mthca_err(dev, "QP %06x not found in MGM\n", ibqp->qp_num);
- err = -EINVAL;
- goto out;
- }
-
- mgm->qp[loc] = mgm->qp[i - 1];
- mgm->qp[i - 1] = 0;
-
- err = mthca_WRITE_MGM(dev, index, mailbox, &status);
- if (err)
- goto out;
- if (status) {
- mthca_err(dev, "WRITE_MGM returned status %02x\n", status);
- err = -EINVAL;
- goto out;
- }
-
- if (i != 1)
- goto out;
-
- if (prev == -1) {
- /* Remove entry from MGM */
- int amgm_index_to_free = be32_to_cpu(mgm->next_gid_index) >> 6;
- if (amgm_index_to_free) {
- err = mthca_READ_MGM(dev, amgm_index_to_free,
- mailbox, &status);
- if (err)
- goto out;
- if (status) {
- mthca_err(dev, "READ_MGM returned status %02x\n",
- status);
- err = -EINVAL;
- goto out;
- }
- } else
- memset(mgm->gid, 0, 16);
-
- err = mthca_WRITE_MGM(dev, index, mailbox, &status);
- if (err)
- goto out;
- if (status) {
- mthca_err(dev, "WRITE_MGM returned status %02x\n", status);
- err = -EINVAL;
- goto out;
- }
- if (amgm_index_to_free) {
- BUG_ON(amgm_index_to_free < dev->limits.num_mgms);
- mthca_free(&dev->mcg_table.alloc, amgm_index_to_free);
- }
- } else {
- /* Remove entry from AMGM */
- int curr_next_index = be32_to_cpu(mgm->next_gid_index) >> 6;
- err = mthca_READ_MGM(dev, prev, mailbox, &status);
- if (err)
- goto out;
- if (status) {
- mthca_err(dev, "READ_MGM returned status %02x\n", status);
- err = -EINVAL;
- goto out;
- }
-
- mgm->next_gid_index = cpu_to_be32(curr_next_index << 6);
-
- err = mthca_WRITE_MGM(dev, prev, mailbox, &status);
- if (err)
- goto out;
- if (status) {
- mthca_err(dev, "WRITE_MGM returned status %02x\n", status);
- err = -EINVAL;
- goto out;
- }
- BUG_ON(index < dev->limits.num_mgms);
- mthca_free(&dev->mcg_table.alloc, index);
- }
-
- out:
- mutex_unlock(&dev->mcg_table.mutex);
-
- mthca_free_mailbox(dev, mailbox);
- return err;
-}
-
-int mthca_init_mcg_table(struct mthca_dev *dev)
-{
- int err;
- int table_size = dev->limits.num_mgms + dev->limits.num_amgms;
-
- err = mthca_alloc_init(&dev->mcg_table.alloc,
- table_size,
- table_size - 1,
- dev->limits.num_mgms);
- if (err)
- return err;
-
- mutex_init(&dev->mcg_table.mutex);
-
- return 0;
-}
-
-void mthca_cleanup_mcg_table(struct mthca_dev *dev)
-{
- mthca_alloc_cleanup(&dev->mcg_table.alloc);
-}
diff --git a/sys/ofed/drivers/infiniband/hw/mthca/mthca_memfree.c b/sys/ofed/drivers/infiniband/hw/mthca/mthca_memfree.c
deleted file mode 100644
index ad5818e..0000000
--- a/sys/ofed/drivers/infiniband/hw/mthca/mthca_memfree.c
+++ /dev/null
@@ -1,881 +0,0 @@
-/*
- * Copyright (c) 2004, 2005 Topspin Communications. All rights reserved.
- * Copyright (c) 2005 Cisco Systems. All rights reserved.
- * Copyright (c) 2005 Mellanox Technologies. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-#include <linux/mm.h>
-#include <linux/scatterlist.h>
-#include <linux/sched.h>
-
-#include <linux/page.h>
-
-#include "mthca_memfree.h"
-#include "mthca_dev.h"
-#include "mthca_cmd.h"
-
-/*
- * We allocate in as big chunks as we can, up to a maximum of 256 KB
- * per chunk.
- */
-enum {
- MTHCA_ICM_ALLOC_SIZE = 1 << 18,
- MTHCA_TABLE_CHUNK_SIZE = 1 << 18
-};
-
-struct mthca_user_db_table {
- struct mutex mutex;
- struct {
- u64 uvirt;
- struct scatterlist mem;
- int refcount;
- } page[0];
-};
-
-static void mthca_free_icm_pages(struct mthca_dev *dev, struct mthca_icm_chunk *chunk)
-{
- int i;
-
- if (chunk->nsg > 0)
- pci_unmap_sg(dev->pdev, chunk->mem, chunk->npages,
- PCI_DMA_BIDIRECTIONAL);
-
- for (i = 0; i < chunk->npages; ++i)
- __free_pages(sg_page(&chunk->mem[i]),
- get_order(chunk->mem[i].length));
-}
-
-static void mthca_free_icm_coherent(struct mthca_dev *dev, struct mthca_icm_chunk *chunk)
-{
- int i;
-
- for (i = 0; i < chunk->npages; ++i) {
- dma_free_coherent(&dev->pdev->dev, chunk->mem[i].length,
- lowmem_page_address(sg_page(&chunk->mem[i])),
- sg_dma_address(&chunk->mem[i]));
- }
-}
-
-void mthca_free_icm(struct mthca_dev *dev, struct mthca_icm *icm, int coherent)
-{
- struct mthca_icm_chunk *chunk, *tmp;
-
- if (!icm)
- return;
-
- list_for_each_entry_safe(chunk, tmp, &icm->chunk_list, list) {
- if (coherent)
- mthca_free_icm_coherent(dev, chunk);
- else
- mthca_free_icm_pages(dev, chunk);
-
- kfree(chunk);
- }
-
- kfree(icm);
-}
-
-static int mthca_alloc_icm_pages(struct scatterlist *mem, int order, gfp_t gfp_mask)
-{
- struct page *page;
-
- /*
- * Use __GFP_ZERO because buggy firmware assumes ICM pages are
- * cleared, and subtle failures are seen if they aren't.
- */
- page = alloc_pages(gfp_mask | __GFP_ZERO, order);
- if (!page)
- return -ENOMEM;
-
- sg_set_page(mem, page, PAGE_SIZE << order, 0);
- return 0;
-}
-
-static int mthca_alloc_icm_coherent(struct device *dev, struct scatterlist *mem,
- int order, gfp_t gfp_mask)
-{
- void *buf = dma_alloc_coherent(dev, PAGE_SIZE << order, &sg_dma_address(mem),
- gfp_mask);
- if (!buf)
- return -ENOMEM;
-
- sg_set_buf(mem, buf, PAGE_SIZE << order);
- BUG_ON(mem->offset);
- sg_dma_len(mem) = PAGE_SIZE << order;
- return 0;
-}
-
-struct mthca_icm *mthca_alloc_icm(struct mthca_dev *dev, int npages,
- gfp_t gfp_mask, int coherent)
-{
- struct mthca_icm *icm;
- struct mthca_icm_chunk *chunk = NULL;
- int cur_order;
- int ret;
-
- /* We use sg_set_buf for coherent allocs, which assumes low memory */
- BUG_ON(coherent && (gfp_mask & __GFP_HIGHMEM));
-
- icm = kmalloc(sizeof *icm, gfp_mask & ~(__GFP_HIGHMEM | __GFP_NOWARN));
- if (!icm)
- return icm;
-
- icm->refcount = 0;
- INIT_LIST_HEAD(&icm->chunk_list);
-
- cur_order = get_order(MTHCA_ICM_ALLOC_SIZE);
-
- while (npages > 0) {
- if (!chunk) {
- chunk = kmalloc(sizeof *chunk,
- gfp_mask & ~(__GFP_HIGHMEM | __GFP_NOWARN));
- if (!chunk)
- goto fail;
-
- sg_init_table(chunk->mem, MTHCA_ICM_CHUNK_LEN);
- chunk->npages = 0;
- chunk->nsg = 0;
- list_add_tail(&chunk->list, &icm->chunk_list);
- }
-
- while (1 << cur_order > npages)
- --cur_order;
-
- if (coherent)
- ret = mthca_alloc_icm_coherent(&dev->pdev->dev,
- &chunk->mem[chunk->npages],
- cur_order, gfp_mask);
- else
- ret = mthca_alloc_icm_pages(&chunk->mem[chunk->npages],
- cur_order, gfp_mask);
-
- if (!ret) {
- ++chunk->npages;
-
- if (coherent)
- ++chunk->nsg;
- else if (chunk->npages == MTHCA_ICM_CHUNK_LEN) {
- chunk->nsg = pci_map_sg(dev->pdev, chunk->mem,
- chunk->npages,
- PCI_DMA_BIDIRECTIONAL);
-
- if (chunk->nsg <= 0)
- goto fail;
- }
-
- if (chunk->npages == MTHCA_ICM_CHUNK_LEN)
- chunk = NULL;
-
- npages -= 1 << cur_order;
- } else {
- --cur_order;
- if (cur_order < 0)
- goto fail;
- }
- }
-
- if (!coherent && chunk) {
- chunk->nsg = pci_map_sg(dev->pdev, chunk->mem,
- chunk->npages,
- PCI_DMA_BIDIRECTIONAL);
-
- if (chunk->nsg <= 0)
- goto fail;
- }
-
- return icm;
-
-fail:
- mthca_free_icm(dev, icm, coherent);
- return NULL;
-}
-
-int mthca_table_get(struct mthca_dev *dev, struct mthca_icm_table *table, int obj)
-{
- int i = (obj & (table->num_obj - 1)) * table->obj_size / MTHCA_TABLE_CHUNK_SIZE;
- int ret = 0;
- u8 status;
-
- mutex_lock(&table->mutex);
-
- if (table->icm[i]) {
- ++table->icm[i]->refcount;
- goto out;
- }
-
- table->icm[i] = mthca_alloc_icm(dev, MTHCA_TABLE_CHUNK_SIZE >> PAGE_SHIFT,
- (table->lowmem ? GFP_KERNEL : GFP_HIGHUSER) |
- __GFP_NOWARN, table->coherent);
- if (!table->icm[i]) {
- ret = -ENOMEM;
- goto out;
- }
-
- if (mthca_MAP_ICM(dev, table->icm[i], table->virt + i * MTHCA_TABLE_CHUNK_SIZE,
- &status) || status) {
- mthca_free_icm(dev, table->icm[i], table->coherent);
- table->icm[i] = NULL;
- ret = -ENOMEM;
- goto out;
- }
-
- ++table->icm[i]->refcount;
-
-out:
- mutex_unlock(&table->mutex);
- return ret;
-}
-
-void mthca_table_put(struct mthca_dev *dev, struct mthca_icm_table *table, int obj)
-{
- int i;
- u8 status;
-
- if (!mthca_is_memfree(dev))
- return;
-
- i = (obj & (table->num_obj - 1)) * table->obj_size / MTHCA_TABLE_CHUNK_SIZE;
-
- mutex_lock(&table->mutex);
-
- if (--table->icm[i]->refcount == 0) {
- mthca_UNMAP_ICM(dev, table->virt + i * MTHCA_TABLE_CHUNK_SIZE,
- MTHCA_TABLE_CHUNK_SIZE / MTHCA_ICM_PAGE_SIZE,
- &status);
- mthca_free_icm(dev, table->icm[i], table->coherent);
- table->icm[i] = NULL;
- }
-
- mutex_unlock(&table->mutex);
-}
-
-void *mthca_table_find(struct mthca_icm_table *table, int obj, dma_addr_t *dma_handle)
-{
- int idx, offset, dma_offset, i;
- struct mthca_icm_chunk *chunk;
- struct mthca_icm *icm;
- struct page *page = NULL;
-
- if (!table->lowmem)
- return NULL;
-
- mutex_lock(&table->mutex);
-
- idx = (obj & (table->num_obj - 1)) * table->obj_size;
- icm = table->icm[idx / MTHCA_TABLE_CHUNK_SIZE];
- dma_offset = offset = idx % MTHCA_TABLE_CHUNK_SIZE;
-
- if (!icm)
- goto out;
-
- list_for_each_entry(chunk, &icm->chunk_list, list) {
- for (i = 0; i < chunk->npages; ++i) {
- if (dma_handle && dma_offset >= 0) {
- if (sg_dma_len(&chunk->mem[i]) > dma_offset)
- *dma_handle = sg_dma_address(&chunk->mem[i]) +
- dma_offset;
- dma_offset -= sg_dma_len(&chunk->mem[i]);
- }
- /* DMA mapping can merge pages but not split them,
- * so if we found the page, dma_handle has already
- * been assigned to. */
- if (chunk->mem[i].length > offset) {
- page = sg_page(&chunk->mem[i]);
- goto out;
- }
- offset -= chunk->mem[i].length;
- }
- }
-
-out:
- mutex_unlock(&table->mutex);
- return page ? lowmem_page_address(page) + offset : NULL;
-}
-
-int mthca_table_get_range(struct mthca_dev *dev, struct mthca_icm_table *table,
- int start, int end)
-{
- int inc = MTHCA_TABLE_CHUNK_SIZE / table->obj_size;
- int i, err;
-
- for (i = start; i <= end; i += inc) {
- err = mthca_table_get(dev, table, i);
- if (err)
- goto fail;
- }
-
- return 0;
-
-fail:
- while (i > start) {
- i -= inc;
- mthca_table_put(dev, table, i);
- }
-
- return err;
-}
-
-void mthca_table_put_range(struct mthca_dev *dev, struct mthca_icm_table *table,
- int start, int end)
-{
- int i;
-
- if (!mthca_is_memfree(dev))
- return;
-
- for (i = start; i <= end; i += MTHCA_TABLE_CHUNK_SIZE / table->obj_size)
- mthca_table_put(dev, table, i);
-}
-
-struct mthca_icm_table *mthca_alloc_icm_table(struct mthca_dev *dev,
- u64 virt, int obj_size,
- int nobj, int reserved,
- int use_lowmem, int use_coherent)
-{
- struct mthca_icm_table *table;
- int obj_per_chunk;
- int num_icm;
- unsigned chunk_size;
- int i;
- u8 status;
-
- obj_per_chunk = MTHCA_TABLE_CHUNK_SIZE / obj_size;
- num_icm = DIV_ROUND_UP(nobj, obj_per_chunk);
-
- table = kmalloc(sizeof *table + num_icm * sizeof *table->icm, GFP_KERNEL);
- if (!table)
- return NULL;
-
- table->virt = virt;
- table->num_icm = num_icm;
- table->num_obj = nobj;
- table->obj_size = obj_size;
- table->lowmem = use_lowmem;
- table->coherent = use_coherent;
- mutex_init(&table->mutex);
-
- for (i = 0; i < num_icm; ++i)
- table->icm[i] = NULL;
-
- for (i = 0; i * MTHCA_TABLE_CHUNK_SIZE < reserved * obj_size; ++i) {
- chunk_size = MTHCA_TABLE_CHUNK_SIZE;
- if ((i + 1) * MTHCA_TABLE_CHUNK_SIZE > nobj * obj_size)
- chunk_size = nobj * obj_size - i * MTHCA_TABLE_CHUNK_SIZE;
-
- table->icm[i] = mthca_alloc_icm(dev, chunk_size >> PAGE_SHIFT,
- (use_lowmem ? GFP_KERNEL : GFP_HIGHUSER) |
- __GFP_NOWARN, use_coherent);
- if (!table->icm[i])
- goto err;
- if (mthca_MAP_ICM(dev, table->icm[i], virt + i * MTHCA_TABLE_CHUNK_SIZE,
- &status) || status) {
- mthca_free_icm(dev, table->icm[i], table->coherent);
- table->icm[i] = NULL;
- goto err;
- }
-
- /*
- * Add a reference to this ICM chunk so that it never
- * gets freed (since it contains reserved firmware objects).
- */
- ++table->icm[i]->refcount;
- }
-
- return table;
-
-err:
- for (i = 0; i < num_icm; ++i)
- if (table->icm[i]) {
- mthca_UNMAP_ICM(dev, virt + i * MTHCA_TABLE_CHUNK_SIZE,
- MTHCA_TABLE_CHUNK_SIZE / MTHCA_ICM_PAGE_SIZE,
- &status);
- mthca_free_icm(dev, table->icm[i], table->coherent);
- }
-
- kfree(table);
-
- return NULL;
-}
-
-void mthca_free_icm_table(struct mthca_dev *dev, struct mthca_icm_table *table)
-{
- int i;
- u8 status;
-
- for (i = 0; i < table->num_icm; ++i)
- if (table->icm[i]) {
- mthca_UNMAP_ICM(dev, table->virt + i * MTHCA_TABLE_CHUNK_SIZE,
- MTHCA_TABLE_CHUNK_SIZE / MTHCA_ICM_PAGE_SIZE,
- &status);
- mthca_free_icm(dev, table->icm[i], table->coherent);
- }
-
- kfree(table);
-}
-
-static u64 mthca_uarc_virt(struct mthca_dev *dev, struct mthca_uar *uar, int page)
-{
- return dev->uar_table.uarc_base +
- uar->index * dev->uar_table.uarc_size +
- page * MTHCA_ICM_PAGE_SIZE;
-}
-
-
-#include <vm/vm_map.h>
-#include <vm/vm_pageout.h>
-#include <vm/pmap.h>
-
-#include <sys/resource.h>
-#include <sys/resourcevar.h>
-
-int mthca_map_user_db(struct mthca_dev *dev, struct mthca_uar *uar,
- struct mthca_user_db_table *db_tab, int index, u64 uaddr)
-{
-#ifdef __linux__
- struct page *pages[1];
- int ret = 0;
- u8 status;
- int i;
-
- if (!mthca_is_memfree(dev))
- return 0;
-
- if (index < 0 || index > dev->uar_table.uarc_size / 8)
- return -EINVAL;
-
- mutex_lock(&db_tab->mutex);
-
- i = index / MTHCA_DB_REC_PER_PAGE;
-
- if ((db_tab->page[i].refcount >= MTHCA_DB_REC_PER_PAGE) ||
- (db_tab->page[i].uvirt && db_tab->page[i].uvirt != uaddr) ||
- (uaddr & 4095)) {
- ret = -EINVAL;
- goto out;
- }
-
- if (db_tab->page[i].refcount) {
- ++db_tab->page[i].refcount;
- goto out;
- }
-
- ret = get_user_pages(current, current->mm, uaddr & PAGE_MASK, 1, 1, 0,
- pages, NULL);
- if (ret < 0)
- goto out;
-
- sg_set_page(&db_tab->page[i].mem, pages[0], MTHCA_ICM_PAGE_SIZE,
- uaddr & ~PAGE_MASK);
-
- ret = pci_map_sg(dev->pdev, &db_tab->page[i].mem, 1, PCI_DMA_TODEVICE);
- if (ret < 0) {
- put_page(pages[0]);
- goto out;
- }
-
- ret = mthca_MAP_ICM_page(dev, sg_dma_address(&db_tab->page[i].mem),
- mthca_uarc_virt(dev, uar, i), &status);
- if (!ret && status)
- ret = -EINVAL;
- if (ret) {
- pci_unmap_sg(dev->pdev, &db_tab->page[i].mem, 1, PCI_DMA_TODEVICE);
- put_page(sg_page(&db_tab->page[i].mem));
- goto out;
- }
-
- db_tab->page[i].uvirt = uaddr;
- db_tab->page[i].refcount = 1;
-
-out:
- mutex_unlock(&db_tab->mutex);
- return ret;
-#else
- struct proc *proc;
- vm_offset_t start;
- vm_paddr_t paddr;
- pmap_t pmap;
- vm_page_t m;
- int ret = 0;
- u8 status;
- int i;
-
- if (!mthca_is_memfree(dev))
- return 0;
-
- if (index < 0 || index > dev->uar_table.uarc_size / 8)
- return -EINVAL;
-
- mutex_lock(&db_tab->mutex);
-
- i = index / MTHCA_DB_REC_PER_PAGE;
- start = 0;
-
- if ((db_tab->page[i].refcount >= MTHCA_DB_REC_PER_PAGE) ||
- (db_tab->page[i].uvirt && db_tab->page[i].uvirt != uaddr) ||
- (uaddr & 4095)) {
- ret = -EINVAL;
- goto out;
- }
-
- if (db_tab->page[i].refcount) {
- ++db_tab->page[i].refcount;
- goto out;
- }
-
- proc = curproc;
- pmap = vm_map_pmap(&proc->p_vmspace->vm_map);
- PROC_LOCK(proc);
- if (ptoa(pmap_wired_count(pmap) + 1) >
- lim_cur_proc(proc, RLIMIT_MEMLOCK)) {
- PROC_UNLOCK(proc);
- ret = -ENOMEM;
- goto out;
- }
- PROC_UNLOCK(proc);
- if (vm_cnt.v_wire_count + 1 > vm_page_max_wired) {
- ret = -EAGAIN;
- goto out;
- }
- start = uaddr & PAGE_MASK;
- ret = vm_map_wire(&proc->p_vmspace->vm_map, start, start + PAGE_SIZE,
- VM_MAP_WIRE_USER | VM_MAP_WIRE_NOHOLES | VM_MAP_WIRE_WRITE);
- if (ret != KERN_SUCCESS) {
- start = 0;
- ret = -ENOMEM;
- goto out;
- }
- paddr = pmap_extract(pmap, uaddr);
- if (paddr == 0) {
- ret = -EFAULT;
- goto out;
- }
- m = PHYS_TO_VM_PAGE(paddr);
-
- sg_set_page(&db_tab->page[i].mem, m, MTHCA_ICM_PAGE_SIZE,
- uaddr & ~PAGE_MASK);
-
- ret = pci_map_sg(dev->pdev, &db_tab->page[i].mem, 1, PCI_DMA_TODEVICE);
- if (ret < 0)
- goto out;
-
- ret = mthca_MAP_ICM_page(dev, sg_dma_address(&db_tab->page[i].mem),
- mthca_uarc_virt(dev, uar, i), &status);
- if (!ret && status)
- ret = -EINVAL;
- if (ret) {
- pci_unmap_sg(dev->pdev, &db_tab->page[i].mem, 1, PCI_DMA_TODEVICE);
- goto out;
- }
-
- db_tab->page[i].uvirt = uaddr;
- db_tab->page[i].refcount = 1;
-
-out:
- if (ret < 0 && start)
- vm_map_unwire(&curthread->td_proc->p_vmspace->vm_map,
- start, start + PAGE_SIZE,
- VM_MAP_WIRE_USER | VM_MAP_WIRE_NOHOLES);
- mutex_unlock(&db_tab->mutex);
- return ret;
-#endif
-}
-
-void mthca_unmap_user_db(struct mthca_dev *dev, struct mthca_uar *uar,
- struct mthca_user_db_table *db_tab, int index)
-{
- if (!mthca_is_memfree(dev))
- return;
-
- /*
- * To make our bookkeeping simpler, we don't unmap DB
- * pages until we clean up the whole db table.
- */
-
- mutex_lock(&db_tab->mutex);
-
- --db_tab->page[index / MTHCA_DB_REC_PER_PAGE].refcount;
-
- mutex_unlock(&db_tab->mutex);
-}
-
-struct mthca_user_db_table *mthca_init_user_db_tab(struct mthca_dev *dev)
-{
- struct mthca_user_db_table *db_tab;
- int npages;
- int i;
-
- if (!mthca_is_memfree(dev))
- return NULL;
-
- npages = dev->uar_table.uarc_size / MTHCA_ICM_PAGE_SIZE;
- db_tab = kmalloc(sizeof *db_tab + npages * sizeof *db_tab->page, GFP_KERNEL);
- if (!db_tab)
- return ERR_PTR(-ENOMEM);
-
- mutex_init(&db_tab->mutex);
- for (i = 0; i < npages; ++i) {
- db_tab->page[i].refcount = 0;
- db_tab->page[i].uvirt = 0;
- sg_init_table(&db_tab->page[i].mem, 1);
- }
-
- return db_tab;
-}
-
-void mthca_cleanup_user_db_tab(struct mthca_dev *dev, struct mthca_uar *uar,
- struct mthca_user_db_table *db_tab)
-{
- int i;
- u8 status;
-
- if (!mthca_is_memfree(dev))
- return;
-
- for (i = 0; i < dev->uar_table.uarc_size / MTHCA_ICM_PAGE_SIZE; ++i) {
- if (db_tab->page[i].uvirt) {
- mthca_UNMAP_ICM(dev, mthca_uarc_virt(dev, uar, i), 1, &status);
- pci_unmap_sg(dev->pdev, &db_tab->page[i].mem, 1, PCI_DMA_TODEVICE);
-#ifdef __linux__
- put_page(sg_page(&db_tab->page[i].mem));
-#else
- vm_offset_t start;
-
- start = db_tab->page[i].uvirt & PAGE_MASK;
- vm_map_unwire(&curthread->td_proc->p_vmspace->vm_map,
- start, start + PAGE_SIZE,
- VM_MAP_WIRE_USER | VM_MAP_WIRE_NOHOLES);
-#endif
- }
- }
-
- kfree(db_tab);
-}
-
-int mthca_alloc_db(struct mthca_dev *dev, enum mthca_db_type type,
- u32 qn, __be32 **db)
-{
- int group;
- int start, end, dir;
- int i, j;
- struct mthca_db_page *page;
- int ret = 0;
- u8 status;
-
- mutex_lock(&dev->db_tab->mutex);
-
- switch (type) {
- case MTHCA_DB_TYPE_CQ_ARM:
- case MTHCA_DB_TYPE_SQ:
- group = 0;
- start = 0;
- end = dev->db_tab->max_group1;
- dir = 1;
- break;
-
- case MTHCA_DB_TYPE_CQ_SET_CI:
- case MTHCA_DB_TYPE_RQ:
- case MTHCA_DB_TYPE_SRQ:
- group = 1;
- start = dev->db_tab->npages - 1;
- end = dev->db_tab->min_group2;
- dir = -1;
- break;
-
- default:
- ret = -EINVAL;
- goto out;
- }
-
- for (i = start; i != end; i += dir)
- if (dev->db_tab->page[i].db_rec &&
- !bitmap_full(dev->db_tab->page[i].used,
- MTHCA_DB_REC_PER_PAGE)) {
- page = dev->db_tab->page + i;
- goto found;
- }
-
- for (i = start; i != end; i += dir)
- if (!dev->db_tab->page[i].db_rec) {
- page = dev->db_tab->page + i;
- goto alloc;
- }
-
- if (dev->db_tab->max_group1 >= dev->db_tab->min_group2 - 1) {
- ret = -ENOMEM;
- goto out;
- }
-
- if (group == 0)
- ++dev->db_tab->max_group1;
- else
- --dev->db_tab->min_group2;
-
- page = dev->db_tab->page + end;
-
-alloc:
- page->db_rec = dma_alloc_coherent(&dev->pdev->dev, MTHCA_ICM_PAGE_SIZE,
- &page->mapping, GFP_KERNEL);
- if (!page->db_rec) {
- ret = -ENOMEM;
- goto out;
- }
- memset(page->db_rec, 0, MTHCA_ICM_PAGE_SIZE);
-
- ret = mthca_MAP_ICM_page(dev, page->mapping,
- mthca_uarc_virt(dev, &dev->driver_uar, i), &status);
- if (!ret && status)
- ret = -EINVAL;
- if (ret) {
- dma_free_coherent(&dev->pdev->dev, MTHCA_ICM_PAGE_SIZE,
- page->db_rec, page->mapping);
- goto out;
- }
-
- bitmap_zero(page->used, MTHCA_DB_REC_PER_PAGE);
-
-found:
- j = find_first_zero_bit(page->used, MTHCA_DB_REC_PER_PAGE);
- set_bit(j, page->used);
-
- if (group == 1)
- j = MTHCA_DB_REC_PER_PAGE - 1 - j;
-
- ret = i * MTHCA_DB_REC_PER_PAGE + j;
-
- page->db_rec[j] = cpu_to_be64((qn << 8) | (type << 5));
-
- *db = (__be32 *) &page->db_rec[j];
-
-out:
- mutex_unlock(&dev->db_tab->mutex);
-
- return ret;
-}
-
-void mthca_free_db(struct mthca_dev *dev, int type, int db_index)
-{
- int i, j;
- struct mthca_db_page *page;
- u8 status;
-
- i = db_index / MTHCA_DB_REC_PER_PAGE;
- j = db_index % MTHCA_DB_REC_PER_PAGE;
-
- page = dev->db_tab->page + i;
-
- mutex_lock(&dev->db_tab->mutex);
-
- page->db_rec[j] = 0;
- if (i >= dev->db_tab->min_group2)
- j = MTHCA_DB_REC_PER_PAGE - 1 - j;
- clear_bit(j, page->used);
-
- if (bitmap_empty(page->used, MTHCA_DB_REC_PER_PAGE) &&
- i >= dev->db_tab->max_group1 - 1) {
- mthca_UNMAP_ICM(dev, mthca_uarc_virt(dev, &dev->driver_uar, i), 1, &status);
-
- dma_free_coherent(&dev->pdev->dev, MTHCA_ICM_PAGE_SIZE,
- page->db_rec, page->mapping);
- page->db_rec = NULL;
-
- if (i == dev->db_tab->max_group1) {
- --dev->db_tab->max_group1;
- /* XXX may be able to unmap more pages now */
- }
- if (i == dev->db_tab->min_group2)
- ++dev->db_tab->min_group2;
- }
-
- mutex_unlock(&dev->db_tab->mutex);
-}
-
-int mthca_init_db_tab(struct mthca_dev *dev)
-{
- int i;
-
- if (!mthca_is_memfree(dev))
- return 0;
-
- dev->db_tab = kmalloc(sizeof *dev->db_tab, GFP_KERNEL);
- if (!dev->db_tab)
- return -ENOMEM;
-
- mutex_init(&dev->db_tab->mutex);
-
- dev->db_tab->npages = dev->uar_table.uarc_size / MTHCA_ICM_PAGE_SIZE;
- dev->db_tab->max_group1 = 0;
- dev->db_tab->min_group2 = dev->db_tab->npages - 1;
-
- dev->db_tab->page = kmalloc(dev->db_tab->npages *
- sizeof *dev->db_tab->page,
- GFP_KERNEL);
- if (!dev->db_tab->page) {
- kfree(dev->db_tab);
- return -ENOMEM;
- }
-
- for (i = 0; i < dev->db_tab->npages; ++i)
- dev->db_tab->page[i].db_rec = NULL;
-
- return 0;
-}
-
-void mthca_cleanup_db_tab(struct mthca_dev *dev)
-{
- int i;
- u8 status;
-
- if (!mthca_is_memfree(dev))
- return;
-
- /*
- * Because we don't always free our UARC pages when they
- * become empty to make mthca_free_db() simpler we need to
- * make a sweep through the doorbell pages and free any
- * leftover pages now.
- */
- for (i = 0; i < dev->db_tab->npages; ++i) {
- if (!dev->db_tab->page[i].db_rec)
- continue;
-
- if (!bitmap_empty(dev->db_tab->page[i].used, MTHCA_DB_REC_PER_PAGE))
- mthca_warn(dev, "Kernel UARC page %d not empty\n", i);
-
- mthca_UNMAP_ICM(dev, mthca_uarc_virt(dev, &dev->driver_uar, i), 1, &status);
-
- dma_free_coherent(&dev->pdev->dev, MTHCA_ICM_PAGE_SIZE,
- dev->db_tab->page[i].db_rec,
- dev->db_tab->page[i].mapping);
- }
-
- kfree(dev->db_tab->page);
- kfree(dev->db_tab);
-}
diff --git a/sys/ofed/drivers/infiniband/hw/mthca/mthca_mr.c b/sys/ofed/drivers/infiniband/hw/mthca/mthca_mr.c
deleted file mode 100644
index d606edf..0000000
--- a/sys/ofed/drivers/infiniband/hw/mthca/mthca_mr.c
+++ /dev/null
@@ -1,985 +0,0 @@
-/*
- * Copyright (c) 2004 Topspin Communications. All rights reserved.
- * Copyright (c) 2005 Mellanox Technologies. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-#include <linux/slab.h>
-#include <linux/errno.h>
-
-#include "mthca_dev.h"
-#include "mthca_cmd.h"
-#include "mthca_memfree.h"
-
-struct mthca_mtt {
- struct mthca_buddy *buddy;
- int order;
- u32 first_seg;
-};
-
-/*
- * Must be packed because mtt_seg is 64 bits but only aligned to 32 bits.
- */
-struct mthca_mpt_entry {
- __be32 flags;
- __be32 page_size;
- __be32 key;
- __be32 pd;
- __be64 start;
- __be64 length;
- __be32 lkey;
- __be32 window_count;
- __be32 window_count_limit;
- __be64 mtt_seg;
- __be32 mtt_sz; /* Arbel only */
- u32 reserved[2];
-} __attribute__((packed));
-
-#define MTHCA_MPT_FLAG_SW_OWNS (0xfUL << 28)
-#define MTHCA_MPT_FLAG_MIO (1 << 17)
-#define MTHCA_MPT_FLAG_BIND_ENABLE (1 << 15)
-#define MTHCA_MPT_FLAG_PHYSICAL (1 << 9)
-#define MTHCA_MPT_FLAG_REGION (1 << 8)
-
-#define MTHCA_MTT_FLAG_PRESENT 1
-
-#define MTHCA_MPT_STATUS_SW 0xF0
-#define MTHCA_MPT_STATUS_HW 0x00
-
-#define SINAI_FMR_KEY_INC 0x1000000
-
-/*
- * Buddy allocator for MTT segments (currently not very efficient
- * since it doesn't keep a free list and just searches linearly
- * through the bitmaps)
- */
-
-static u32 mthca_buddy_alloc(struct mthca_buddy *buddy, int order)
-{
- int o;
- int m;
- u32 seg;
-
- spin_lock(&buddy->lock);
-
- for (o = order; o <= buddy->max_order; ++o)
- if (buddy->num_free[o]) {
- m = 1 << (buddy->max_order - o);
- seg = find_first_bit(buddy->bits[o], m);
- if (seg < m)
- goto found;
- }
-
- spin_unlock(&buddy->lock);
- return -1;
-
- found:
- clear_bit(seg, buddy->bits[o]);
- --buddy->num_free[o];
-
- while (o > order) {
- --o;
- seg <<= 1;
- set_bit(seg ^ 1, buddy->bits[o]);
- ++buddy->num_free[o];
- }
-
- spin_unlock(&buddy->lock);
-
- seg <<= order;
-
- return seg;
-}
-
-static void mthca_buddy_free(struct mthca_buddy *buddy, u32 seg, int order)
-{
- seg >>= order;
-
- spin_lock(&buddy->lock);
-
- while (test_bit(seg ^ 1, buddy->bits[order])) {
- clear_bit(seg ^ 1, buddy->bits[order]);
- --buddy->num_free[order];
- seg >>= 1;
- ++order;
- }
-
- set_bit(seg, buddy->bits[order]);
- ++buddy->num_free[order];
-
- spin_unlock(&buddy->lock);
-}
-
-static int mthca_buddy_init(struct mthca_buddy *buddy, int max_order)
-{
- int i, s;
-
- buddy->max_order = max_order;
- spin_lock_init(&buddy->lock);
-
- buddy->bits = kzalloc((buddy->max_order + 1) * sizeof (long *),
- GFP_KERNEL);
- buddy->num_free = kzalloc((buddy->max_order + 1) * sizeof (int *),
- GFP_KERNEL);
- if (!buddy->bits || !buddy->num_free)
- goto err_out;
-
- for (i = 0; i <= buddy->max_order; ++i) {
- s = BITS_TO_LONGS(1 << (buddy->max_order - i));
- buddy->bits[i] = kmalloc(s * sizeof (long), GFP_KERNEL);
- if (!buddy->bits[i])
- goto err_out_free;
- bitmap_zero(buddy->bits[i],
- 1 << (buddy->max_order - i));
- }
-
- set_bit(0, buddy->bits[buddy->max_order]);
- buddy->num_free[buddy->max_order] = 1;
-
- return 0;
-
-err_out_free:
- for (i = 0; i <= buddy->max_order; ++i)
- kfree(buddy->bits[i]);
-
-err_out:
- kfree(buddy->bits);
- kfree(buddy->num_free);
-
- return -ENOMEM;
-}
-
-static void mthca_buddy_cleanup(struct mthca_buddy *buddy)
-{
- int i;
-
- for (i = 0; i <= buddy->max_order; ++i)
- kfree(buddy->bits[i]);
-
- kfree(buddy->bits);
- kfree(buddy->num_free);
-}
-
-static u32 mthca_alloc_mtt_range(struct mthca_dev *dev, int order,
- struct mthca_buddy *buddy)
-{
- u32 seg = mthca_buddy_alloc(buddy, order);
-
- if (seg == -1)
- return -1;
-
- if (mthca_is_memfree(dev))
- if (mthca_table_get_range(dev, dev->mr_table.mtt_table, seg,
- seg + (1 << order) - 1)) {
- mthca_buddy_free(buddy, seg, order);
- seg = -1;
- }
-
- return seg;
-}
-
-static struct mthca_mtt *__mthca_alloc_mtt(struct mthca_dev *dev, int size,
- struct mthca_buddy *buddy)
-{
- struct mthca_mtt *mtt;
- int i;
-
- if (size <= 0)
- return ERR_PTR(-EINVAL);
-
- mtt = kmalloc(sizeof *mtt, GFP_KERNEL);
- if (!mtt)
- return ERR_PTR(-ENOMEM);
-
- mtt->buddy = buddy;
- mtt->order = 0;
- for (i = dev->limits.mtt_seg_size / 8; i < size; i <<= 1)
- ++mtt->order;
-
- mtt->first_seg = mthca_alloc_mtt_range(dev, mtt->order, buddy);
- if (mtt->first_seg == -1) {
- kfree(mtt);
- return ERR_PTR(-ENOMEM);
- }
-
- return mtt;
-}
-
-struct mthca_mtt *mthca_alloc_mtt(struct mthca_dev *dev, int size)
-{
- return __mthca_alloc_mtt(dev, size, &dev->mr_table.mtt_buddy);
-}
-
-void mthca_free_mtt(struct mthca_dev *dev, struct mthca_mtt *mtt)
-{
- if (!mtt)
- return;
-
- mthca_buddy_free(mtt->buddy, mtt->first_seg, mtt->order);
-
- mthca_table_put_range(dev, dev->mr_table.mtt_table,
- mtt->first_seg,
- mtt->first_seg + (1 << mtt->order) - 1);
-
- kfree(mtt);
-}
-
-static int __mthca_write_mtt(struct mthca_dev *dev, struct mthca_mtt *mtt,
- int start_index, u64 *buffer_list, int list_len)
-{
- struct mthca_mailbox *mailbox;
- __be64 *mtt_entry;
- int err = 0;
- u8 status;
- int i;
-
- mailbox = mthca_alloc_mailbox(dev, GFP_KERNEL);
- if (IS_ERR(mailbox))
- return PTR_ERR(mailbox);
- mtt_entry = mailbox->buf;
-
- while (list_len > 0) {
- mtt_entry[0] = cpu_to_be64(dev->mr_table.mtt_base +
- mtt->first_seg * dev->limits.mtt_seg_size +
- start_index * 8);
- mtt_entry[1] = 0;
- for (i = 0; i < list_len && i < MTHCA_MAILBOX_SIZE / 8 - 2; ++i)
- mtt_entry[i + 2] = cpu_to_be64(buffer_list[i] |
- MTHCA_MTT_FLAG_PRESENT);
-
- /*
- * If we have an odd number of entries to write, add
- * one more dummy entry for firmware efficiency.
- */
- if (i & 1)
- mtt_entry[i + 2] = 0;
-
- err = mthca_WRITE_MTT(dev, mailbox, (i + 1) & ~1, &status);
- if (err) {
- mthca_warn(dev, "WRITE_MTT failed (%d)\n", err);
- goto out;
- }
- if (status) {
- mthca_warn(dev, "WRITE_MTT returned status 0x%02x\n",
- status);
- err = -EINVAL;
- goto out;
- }
-
- list_len -= i;
- start_index += i;
- buffer_list += i;
- }
-
-out:
- mthca_free_mailbox(dev, mailbox);
- return err;
-}
-
-int mthca_write_mtt_size(struct mthca_dev *dev)
-{
- if (dev->mr_table.fmr_mtt_buddy != &dev->mr_table.mtt_buddy ||
- !(dev->mthca_flags & MTHCA_FLAG_FMR))
- /*
- * Be friendly to WRITE_MTT command
- * and leave two empty slots for the
- * index and reserved fields of the
- * mailbox.
- */
- return PAGE_SIZE / sizeof (u64) - 2;
-
- /* For Arbel, all MTTs must fit in the same page. */
- return mthca_is_memfree(dev) ? (PAGE_SIZE / sizeof (u64)) : 0x7ffffff;
-}
-
-static void mthca_tavor_write_mtt_seg(struct mthca_dev *dev,
- struct mthca_mtt *mtt, int start_index,
- u64 *buffer_list, int list_len)
-{
- u64 __iomem *mtts;
- int i;
-
- mtts = dev->mr_table.tavor_fmr.mtt_base + mtt->first_seg * dev->limits.mtt_seg_size +
- start_index * sizeof (u64);
- for (i = 0; i < list_len; ++i)
- mthca_write64_raw(cpu_to_be64(buffer_list[i] | MTHCA_MTT_FLAG_PRESENT),
- mtts + i);
-}
-
-static void mthca_arbel_write_mtt_seg(struct mthca_dev *dev,
- struct mthca_mtt *mtt, int start_index,
- u64 *buffer_list, int list_len)
-{
- __be64 *mtts;
- dma_addr_t dma_handle;
- int i;
- int s = start_index * sizeof (u64);
-
- /* For Arbel, all MTTs must fit in the same page. */
- BUG_ON(s / PAGE_SIZE != (s + list_len * sizeof(u64) - 1) / PAGE_SIZE);
- /* Require full segments */
- BUG_ON(s % dev->limits.mtt_seg_size);
-
- mtts = mthca_table_find(dev->mr_table.mtt_table, mtt->first_seg +
- s / dev->limits.mtt_seg_size, &dma_handle);
-
- BUG_ON(!mtts);
-
- for (i = 0; i < list_len; ++i)
- mtts[i] = cpu_to_be64(buffer_list[i] | MTHCA_MTT_FLAG_PRESENT);
-
- dma_sync_single(&dev->pdev->dev, dma_handle, list_len * sizeof (u64), DMA_TO_DEVICE);
-}
-
-int mthca_write_mtt(struct mthca_dev *dev, struct mthca_mtt *mtt,
- int start_index, u64 *buffer_list, int list_len)
-{
- int size = mthca_write_mtt_size(dev);
- int chunk;
-
- if (dev->mr_table.fmr_mtt_buddy != &dev->mr_table.mtt_buddy ||
- !(dev->mthca_flags & MTHCA_FLAG_FMR))
- return __mthca_write_mtt(dev, mtt, start_index, buffer_list, list_len);
-
- while (list_len > 0) {
- chunk = min(size, list_len);
- if (mthca_is_memfree(dev))
- mthca_arbel_write_mtt_seg(dev, mtt, start_index,
- buffer_list, chunk);
- else
- mthca_tavor_write_mtt_seg(dev, mtt, start_index,
- buffer_list, chunk);
-
- list_len -= chunk;
- start_index += chunk;
- buffer_list += chunk;
- }
-
- return 0;
-}
-
-static inline u32 tavor_hw_index_to_key(u32 ind)
-{
- return ind;
-}
-
-static inline u32 tavor_key_to_hw_index(u32 key)
-{
- return key;
-}
-
-static inline u32 arbel_hw_index_to_key(u32 ind)
-{
- return (ind >> 24) | (ind << 8);
-}
-
-static inline u32 arbel_key_to_hw_index(u32 key)
-{
- return (key << 24) | (key >> 8);
-}
-
-static inline u32 hw_index_to_key(struct mthca_dev *dev, u32 ind)
-{
- if (mthca_is_memfree(dev))
- return arbel_hw_index_to_key(ind);
- else
- return tavor_hw_index_to_key(ind);
-}
-
-static inline u32 key_to_hw_index(struct mthca_dev *dev, u32 key)
-{
- if (mthca_is_memfree(dev))
- return arbel_key_to_hw_index(key);
- else
- return tavor_key_to_hw_index(key);
-}
-
-static inline u32 adjust_key(struct mthca_dev *dev, u32 key)
-{
- if (dev->mthca_flags & MTHCA_FLAG_SINAI_OPT)
- return ((key << 20) & 0x800000) | (key & 0x7fffff);
- else
- return key;
-}
-
-int mthca_mr_alloc(struct mthca_dev *dev, u32 pd, int buffer_size_shift,
- u64 iova, u64 total_size, u32 access, struct mthca_mr *mr)
-{
- struct mthca_mailbox *mailbox;
- struct mthca_mpt_entry *mpt_entry;
- u32 key;
- int i;
- int err;
- u8 status;
-
- WARN_ON(buffer_size_shift >= 32);
-
- key = mthca_alloc(&dev->mr_table.mpt_alloc);
- if (key == -1)
- return -ENOMEM;
- key = adjust_key(dev, key);
- mr->ibmr.rkey = mr->ibmr.lkey = hw_index_to_key(dev, key);
-
- if (mthca_is_memfree(dev)) {
- err = mthca_table_get(dev, dev->mr_table.mpt_table, key);
- if (err)
- goto err_out_mpt_free;
- }
-
- mailbox = mthca_alloc_mailbox(dev, GFP_KERNEL);
- if (IS_ERR(mailbox)) {
- err = PTR_ERR(mailbox);
- goto err_out_table;
- }
- mpt_entry = mailbox->buf;
-
- mpt_entry->flags = cpu_to_be32(MTHCA_MPT_FLAG_SW_OWNS |
- MTHCA_MPT_FLAG_MIO |
- MTHCA_MPT_FLAG_REGION |
- access);
- if (!mr->mtt)
- mpt_entry->flags |= cpu_to_be32(MTHCA_MPT_FLAG_PHYSICAL);
-
- mpt_entry->page_size = cpu_to_be32(buffer_size_shift - 12);
- mpt_entry->key = cpu_to_be32(key);
- mpt_entry->pd = cpu_to_be32(pd);
- mpt_entry->start = cpu_to_be64(iova);
- mpt_entry->length = cpu_to_be64(total_size);
-
- memset(&mpt_entry->lkey, 0,
- sizeof *mpt_entry - offsetof(struct mthca_mpt_entry, lkey));
-
- if (mr->mtt)
- mpt_entry->mtt_seg =
- cpu_to_be64(dev->mr_table.mtt_base +
- mr->mtt->first_seg * dev->limits.mtt_seg_size);
-
- if (0) {
- mthca_dbg(dev, "Dumping MPT entry %08x:\n", mr->ibmr.lkey);
- for (i = 0; i < sizeof (struct mthca_mpt_entry) / 4; ++i) {
- if (i % 4 == 0)
- printk("[%02x] ", i * 4);
- printk(" %08x", be32_to_cpu(((__be32 *) mpt_entry)[i]));
- if ((i + 1) % 4 == 0)
- printk("\n");
- }
- }
-
- err = mthca_SW2HW_MPT(dev, mailbox,
- key & (dev->limits.num_mpts - 1),
- &status);
- if (err) {
- mthca_warn(dev, "SW2HW_MPT failed (%d)\n", err);
- goto err_out_mailbox;
- } else if (status) {
- mthca_warn(dev, "SW2HW_MPT returned status 0x%02x\n",
- status);
- err = -EINVAL;
- goto err_out_mailbox;
- }
-
- mthca_free_mailbox(dev, mailbox);
- return err;
-
-err_out_mailbox:
- mthca_free_mailbox(dev, mailbox);
-
-err_out_table:
- mthca_table_put(dev, dev->mr_table.mpt_table, key);
-
-err_out_mpt_free:
- mthca_free(&dev->mr_table.mpt_alloc, key);
- return err;
-}
-
-int mthca_mr_alloc_notrans(struct mthca_dev *dev, u32 pd,
- u32 access, struct mthca_mr *mr)
-{
- mr->mtt = NULL;
- return mthca_mr_alloc(dev, pd, 12, 0, ~0ULL, access, mr);
-}
-
-int mthca_mr_alloc_phys(struct mthca_dev *dev, u32 pd,
- u64 *buffer_list, int buffer_size_shift,
- int list_len, u64 iova, u64 total_size,
- u32 access, struct mthca_mr *mr)
-{
- int err;
-
- mr->mtt = mthca_alloc_mtt(dev, list_len);
- if (IS_ERR(mr->mtt))
- return PTR_ERR(mr->mtt);
-
- err = mthca_write_mtt(dev, mr->mtt, 0, buffer_list, list_len);
- if (err) {
- mthca_free_mtt(dev, mr->mtt);
- return err;
- }
-
- err = mthca_mr_alloc(dev, pd, buffer_size_shift, iova,
- total_size, access, mr);
- if (err)
- mthca_free_mtt(dev, mr->mtt);
-
- return err;
-}
-
-/* Free mr or fmr */
-static void mthca_free_region(struct mthca_dev *dev, u32 lkey)
-{
- mthca_table_put(dev, dev->mr_table.mpt_table,
- key_to_hw_index(dev, lkey));
-
- mthca_free(&dev->mr_table.mpt_alloc, key_to_hw_index(dev, lkey));
-}
-
-void mthca_free_mr(struct mthca_dev *dev, struct mthca_mr *mr)
-{
- int err;
- u8 status;
-
- err = mthca_HW2SW_MPT(dev, NULL,
- key_to_hw_index(dev, mr->ibmr.lkey) &
- (dev->limits.num_mpts - 1),
- &status);
- if (err)
- mthca_warn(dev, "HW2SW_MPT failed (%d)\n", err);
- else if (status)
- mthca_warn(dev, "HW2SW_MPT returned status 0x%02x\n",
- status);
-
- mthca_free_region(dev, mr->ibmr.lkey);
- mthca_free_mtt(dev, mr->mtt);
-}
-
-int mthca_fmr_alloc(struct mthca_dev *dev, u32 pd,
- u32 access, struct mthca_fmr *mr)
-{
- struct mthca_mpt_entry *mpt_entry;
- struct mthca_mailbox *mailbox;
- u64 mtt_seg;
- u32 key, idx;
- u8 status;
- int list_len = mr->attr.max_pages;
- int err = -ENOMEM;
- int i;
-
- if (mr->attr.page_shift < 12 || mr->attr.page_shift >= 32)
- return -EINVAL;
-
- /* For Arbel, all MTTs must fit in the same page. */
- if (mthca_is_memfree(dev) &&
- mr->attr.max_pages * sizeof *mr->mem.arbel.mtts > PAGE_SIZE)
- return -EINVAL;
-
- mr->maps = 0;
-
- key = mthca_alloc(&dev->mr_table.mpt_alloc);
- if (key == -1)
- return -ENOMEM;
- key = adjust_key(dev, key);
-
- idx = key & (dev->limits.num_mpts - 1);
- mr->ibmr.rkey = mr->ibmr.lkey = hw_index_to_key(dev, key);
-
- if (mthca_is_memfree(dev)) {
- err = mthca_table_get(dev, dev->mr_table.mpt_table, key);
- if (err)
- goto err_out_mpt_free;
-
- mr->mem.arbel.mpt = mthca_table_find(dev->mr_table.mpt_table, key, NULL);
- BUG_ON(!mr->mem.arbel.mpt);
- } else
- mr->mem.tavor.mpt = dev->mr_table.tavor_fmr.mpt_base +
- sizeof *(mr->mem.tavor.mpt) * idx;
-
- mr->mtt = __mthca_alloc_mtt(dev, list_len, dev->mr_table.fmr_mtt_buddy);
- if (IS_ERR(mr->mtt)) {
- err = PTR_ERR(mr->mtt);
- goto err_out_table;
- }
-
- mtt_seg = mr->mtt->first_seg * dev->limits.mtt_seg_size;
-
- if (mthca_is_memfree(dev)) {
- mr->mem.arbel.mtts = mthca_table_find(dev->mr_table.mtt_table,
- mr->mtt->first_seg,
- &mr->mem.arbel.dma_handle);
- BUG_ON(!mr->mem.arbel.mtts);
- } else
- mr->mem.tavor.mtts = dev->mr_table.tavor_fmr.mtt_base + mtt_seg;
-
- mailbox = mthca_alloc_mailbox(dev, GFP_KERNEL);
- if (IS_ERR(mailbox)) {
- err = PTR_ERR(mailbox);
- goto err_out_free_mtt;
- }
-
- mpt_entry = mailbox->buf;
-
- mpt_entry->flags = cpu_to_be32(MTHCA_MPT_FLAG_SW_OWNS |
- MTHCA_MPT_FLAG_MIO |
- MTHCA_MPT_FLAG_REGION |
- access);
-
- mpt_entry->page_size = cpu_to_be32(mr->attr.page_shift - 12);
- mpt_entry->key = cpu_to_be32(key);
- mpt_entry->pd = cpu_to_be32(pd);
- memset(&mpt_entry->start, 0,
- sizeof *mpt_entry - offsetof(struct mthca_mpt_entry, start));
- mpt_entry->mtt_seg = cpu_to_be64(dev->mr_table.mtt_base + mtt_seg);
-
- if (0) {
- mthca_dbg(dev, "Dumping MPT entry %08x:\n", mr->ibmr.lkey);
- for (i = 0; i < sizeof (struct mthca_mpt_entry) / 4; ++i) {
- if (i % 4 == 0)
- printk("[%02x] ", i * 4);
- printk(" %08x", be32_to_cpu(((__be32 *) mpt_entry)[i]));
- if ((i + 1) % 4 == 0)
- printk("\n");
- }
- }
-
- err = mthca_SW2HW_MPT(dev, mailbox,
- key & (dev->limits.num_mpts - 1),
- &status);
- if (err) {
- mthca_warn(dev, "SW2HW_MPT failed (%d)\n", err);
- goto err_out_mailbox_free;
- }
- if (status) {
- mthca_warn(dev, "SW2HW_MPT returned status 0x%02x\n",
- status);
- err = -EINVAL;
- goto err_out_mailbox_free;
- }
-
- mthca_free_mailbox(dev, mailbox);
- return 0;
-
-err_out_mailbox_free:
- mthca_free_mailbox(dev, mailbox);
-
-err_out_free_mtt:
- mthca_free_mtt(dev, mr->mtt);
-
-err_out_table:
- mthca_table_put(dev, dev->mr_table.mpt_table, key);
-
-err_out_mpt_free:
- mthca_free(&dev->mr_table.mpt_alloc, key);
- return err;
-}
-
-int mthca_free_fmr(struct mthca_dev *dev, struct mthca_fmr *fmr)
-{
- if (fmr->maps)
- return -EBUSY;
-
- mthca_free_region(dev, fmr->ibmr.lkey);
- mthca_free_mtt(dev, fmr->mtt);
-
- return 0;
-}
-
-static inline int mthca_check_fmr(struct mthca_fmr *fmr, u64 *page_list,
- int list_len, u64 iova)
-{
- int i, page_mask;
-
- if (list_len > fmr->attr.max_pages)
- return -EINVAL;
-
- page_mask = (1 << fmr->attr.page_shift) - 1;
-
- /* We are getting page lists, so va must be page aligned. */
- if (iova & page_mask)
- return -EINVAL;
-
- /* Trust the user not to pass misaligned data in page_list */
- if (0)
- for (i = 0; i < list_len; ++i) {
- if (page_list[i] & ~page_mask)
- return -EINVAL;
- }
-
- if (fmr->maps >= fmr->attr.max_maps)
- return -EINVAL;
-
- return 0;
-}
-
-
-int mthca_tavor_map_phys_fmr(struct ib_fmr *ibfmr, u64 *page_list,
- int list_len, u64 iova)
-{
- struct mthca_fmr *fmr = to_mfmr(ibfmr);
- struct mthca_dev *dev = to_mdev(ibfmr->device);
- struct mthca_mpt_entry mpt_entry;
- u32 key;
- int i, err;
-
- err = mthca_check_fmr(fmr, page_list, list_len, iova);
- if (err)
- return err;
-
- ++fmr->maps;
-
- key = tavor_key_to_hw_index(fmr->ibmr.lkey);
- key += dev->limits.num_mpts;
- fmr->ibmr.lkey = fmr->ibmr.rkey = tavor_hw_index_to_key(key);
-
- writeb(MTHCA_MPT_STATUS_SW, fmr->mem.tavor.mpt);
-
- for (i = 0; i < list_len; ++i) {
- __be64 mtt_entry = cpu_to_be64(page_list[i] |
- MTHCA_MTT_FLAG_PRESENT);
- mthca_write64_raw(mtt_entry, fmr->mem.tavor.mtts + i);
- }
-
- mpt_entry.lkey = cpu_to_be32(key);
- mpt_entry.length = cpu_to_be64(list_len * (1ull << fmr->attr.page_shift));
- mpt_entry.start = cpu_to_be64(iova);
-
- __raw_writel((__force u32) mpt_entry.lkey, &fmr->mem.tavor.mpt->key);
- memcpy_toio(&fmr->mem.tavor.mpt->start, &mpt_entry.start,
- offsetof(struct mthca_mpt_entry, window_count) -
- offsetof(struct mthca_mpt_entry, start));
-
- writeb(MTHCA_MPT_STATUS_HW, fmr->mem.tavor.mpt);
-
- return 0;
-}
-
-int mthca_arbel_map_phys_fmr(struct ib_fmr *ibfmr, u64 *page_list,
- int list_len, u64 iova)
-{
- struct mthca_fmr *fmr = to_mfmr(ibfmr);
- struct mthca_dev *dev = to_mdev(ibfmr->device);
- u32 key;
- int i, err;
-
- err = mthca_check_fmr(fmr, page_list, list_len, iova);
- if (err)
- return err;
-
- ++fmr->maps;
-
- key = arbel_key_to_hw_index(fmr->ibmr.lkey);
- if (dev->mthca_flags & MTHCA_FLAG_SINAI_OPT)
- key += SINAI_FMR_KEY_INC;
- else
- key += dev->limits.num_mpts;
- fmr->ibmr.lkey = fmr->ibmr.rkey = arbel_hw_index_to_key(key);
-
- *(u8 *) fmr->mem.arbel.mpt = MTHCA_MPT_STATUS_SW;
-
- wmb();
-
- for (i = 0; i < list_len; ++i)
- fmr->mem.arbel.mtts[i] = cpu_to_be64(page_list[i] |
- MTHCA_MTT_FLAG_PRESENT);
-
- dma_sync_single(&dev->pdev->dev, fmr->mem.arbel.dma_handle,
- list_len * sizeof(u64), DMA_TO_DEVICE);
-
- fmr->mem.arbel.mpt->key = cpu_to_be32(key);
- fmr->mem.arbel.mpt->lkey = cpu_to_be32(key);
- fmr->mem.arbel.mpt->length = cpu_to_be64(list_len * (1ull << fmr->attr.page_shift));
- fmr->mem.arbel.mpt->start = cpu_to_be64(iova);
-
- wmb();
-
- *(u8 *) fmr->mem.arbel.mpt = MTHCA_MPT_STATUS_HW;
-
- wmb();
-
- return 0;
-}
-
-void mthca_tavor_fmr_unmap(struct mthca_dev *dev, struct mthca_fmr *fmr)
-{
- if (!fmr->maps)
- return;
-
- fmr->maps = 0;
-
- writeb(MTHCA_MPT_STATUS_SW, fmr->mem.tavor.mpt);
-}
-
-void mthca_arbel_fmr_unmap(struct mthca_dev *dev, struct mthca_fmr *fmr)
-{
- if (!fmr->maps)
- return;
-
- fmr->maps = 0;
-
- *(u8 *) fmr->mem.arbel.mpt = MTHCA_MPT_STATUS_SW;
-}
-
-int mthca_init_mr_table(struct mthca_dev *dev)
-{
- unsigned long addr;
- int mpts, mtts, err, i;
-
- err = mthca_alloc_init(&dev->mr_table.mpt_alloc,
- dev->limits.num_mpts,
- ~0, dev->limits.reserved_mrws);
- if (err)
- return err;
-
- if (!mthca_is_memfree(dev) &&
- (dev->mthca_flags & MTHCA_FLAG_DDR_HIDDEN))
- dev->limits.fmr_reserved_mtts = 0;
- else
- dev->mthca_flags |= MTHCA_FLAG_FMR;
-
- if (dev->mthca_flags & MTHCA_FLAG_SINAI_OPT)
- mthca_dbg(dev, "Memory key throughput optimization activated.\n");
-
- err = mthca_buddy_init(&dev->mr_table.mtt_buddy,
- fls(dev->limits.num_mtt_segs - 1));
-
- if (err)
- goto err_mtt_buddy;
-
- dev->mr_table.tavor_fmr.mpt_base = NULL;
- dev->mr_table.tavor_fmr.mtt_base = NULL;
-
- if (dev->limits.fmr_reserved_mtts) {
- i = fls(dev->limits.fmr_reserved_mtts - 1);
-
- if (i >= 31) {
- mthca_warn(dev, "Unable to reserve 2^31 FMR MTTs.\n");
- err = -EINVAL;
- goto err_fmr_mpt;
- }
- mpts = mtts = 1 << i;
- } else {
- mtts = dev->limits.num_mtt_segs;
- mpts = dev->limits.num_mpts;
- }
-
- if (!mthca_is_memfree(dev) &&
- (dev->mthca_flags & MTHCA_FLAG_FMR)) {
-
- addr = pci_resource_start(dev->pdev, 4) +
- ((pci_resource_len(dev->pdev, 4) - 1) &
- dev->mr_table.mpt_base);
-
- dev->mr_table.tavor_fmr.mpt_base =
- ioremap(addr, mpts * sizeof(struct mthca_mpt_entry));
-
- if (!dev->mr_table.tavor_fmr.mpt_base) {
- mthca_warn(dev, "MPT ioremap for FMR failed.\n");
- err = -ENOMEM;
- goto err_fmr_mpt;
- }
-
- addr = pci_resource_start(dev->pdev, 4) +
- ((pci_resource_len(dev->pdev, 4) - 1) &
- dev->mr_table.mtt_base);
-
- dev->mr_table.tavor_fmr.mtt_base =
- ioremap(addr, mtts * dev->limits.mtt_seg_size);
- if (!dev->mr_table.tavor_fmr.mtt_base) {
- mthca_warn(dev, "MTT ioremap for FMR failed.\n");
- err = -ENOMEM;
- goto err_fmr_mtt;
- }
- }
-
- if (dev->limits.fmr_reserved_mtts) {
- err = mthca_buddy_init(&dev->mr_table.tavor_fmr.mtt_buddy, fls(mtts - 1));
- if (err)
- goto err_fmr_mtt_buddy;
-
- /* Prevent regular MRs from using FMR keys */
- err = mthca_buddy_alloc(&dev->mr_table.mtt_buddy, fls(mtts - 1));
- if (err)
- goto err_reserve_fmr;
-
- dev->mr_table.fmr_mtt_buddy =
- &dev->mr_table.tavor_fmr.mtt_buddy;
- } else
- dev->mr_table.fmr_mtt_buddy = &dev->mr_table.mtt_buddy;
-
- /* FMR table is always the first, take reserved MTTs out of there */
- if (dev->limits.reserved_mtts) {
- i = fls(dev->limits.reserved_mtts - 1);
-
- if (mthca_alloc_mtt_range(dev, i,
- dev->mr_table.fmr_mtt_buddy) == -1) {
- mthca_warn(dev, "MTT table of order %d is too small.\n",
- dev->mr_table.fmr_mtt_buddy->max_order);
- err = -ENOMEM;
- goto err_reserve_mtts;
- }
- }
-
- return 0;
-
-err_reserve_mtts:
-err_reserve_fmr:
- if (dev->limits.fmr_reserved_mtts)
- mthca_buddy_cleanup(&dev->mr_table.tavor_fmr.mtt_buddy);
-
-err_fmr_mtt_buddy:
- if (dev->mr_table.tavor_fmr.mtt_base)
- iounmap(dev->mr_table.tavor_fmr.mtt_base);
-
-err_fmr_mtt:
- if (dev->mr_table.tavor_fmr.mpt_base)
- iounmap(dev->mr_table.tavor_fmr.mpt_base);
-
-err_fmr_mpt:
- mthca_buddy_cleanup(&dev->mr_table.mtt_buddy);
-
-err_mtt_buddy:
- mthca_alloc_cleanup(&dev->mr_table.mpt_alloc);
-
- return err;
-}
-
-void mthca_cleanup_mr_table(struct mthca_dev *dev)
-{
- /* XXX check if any MRs are still allocated? */
- if (dev->limits.fmr_reserved_mtts)
- mthca_buddy_cleanup(&dev->mr_table.tavor_fmr.mtt_buddy);
-
- mthca_buddy_cleanup(&dev->mr_table.mtt_buddy);
-
- if (dev->mr_table.tavor_fmr.mtt_base)
- iounmap(dev->mr_table.tavor_fmr.mtt_base);
- if (dev->mr_table.tavor_fmr.mpt_base)
- iounmap(dev->mr_table.tavor_fmr.mpt_base);
-
- mthca_alloc_cleanup(&dev->mr_table.mpt_alloc);
-}
diff --git a/sys/ofed/drivers/infiniband/hw/mthca/mthca_profile.c b/sys/ofed/drivers/infiniband/hw/mthca/mthca_profile.c
deleted file mode 100644
index 8edb28a..0000000
--- a/sys/ofed/drivers/infiniband/hw/mthca/mthca_profile.c
+++ /dev/null
@@ -1,285 +0,0 @@
-/*
- * Copyright (c) 2004, 2005 Topspin Communications. All rights reserved.
- * Copyright (c) 2005 Mellanox Technologies. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-#include <linux/module.h>
-#include <linux/moduleparam.h>
-#include <linux/string.h>
-#include <linux/slab.h>
-
-#include "mthca_profile.h"
-
-enum {
- MTHCA_RES_QP,
- MTHCA_RES_EEC,
- MTHCA_RES_SRQ,
- MTHCA_RES_CQ,
- MTHCA_RES_EQP,
- MTHCA_RES_EEEC,
- MTHCA_RES_EQ,
- MTHCA_RES_RDB,
- MTHCA_RES_MCG,
- MTHCA_RES_MPT,
- MTHCA_RES_MTT,
- MTHCA_RES_UAR,
- MTHCA_RES_UDAV,
- MTHCA_RES_UARC,
- MTHCA_RES_NUM
-};
-
-enum {
- MTHCA_NUM_EQS = 32,
- MTHCA_NUM_PDS = 1 << 15
-};
-
-s64 mthca_make_profile(struct mthca_dev *dev,
- struct mthca_profile *request,
- struct mthca_dev_lim *dev_lim,
- struct mthca_init_hca_param *init_hca)
-{
- struct mthca_resource {
- u64 size;
- u64 start;
- int type;
- int num;
- int log_num;
- };
-
- u64 mem_base, mem_avail;
- s64 total_size = 0;
- struct mthca_resource *profile;
- struct mthca_resource tmp;
- int i, j;
-
- profile = kzalloc(MTHCA_RES_NUM * sizeof *profile, GFP_KERNEL);
- if (!profile)
- return -ENOMEM;
-
- profile[MTHCA_RES_QP].size = dev_lim->qpc_entry_sz;
- profile[MTHCA_RES_EEC].size = dev_lim->eec_entry_sz;
- profile[MTHCA_RES_SRQ].size = dev_lim->srq_entry_sz;
- profile[MTHCA_RES_CQ].size = dev_lim->cqc_entry_sz;
- profile[MTHCA_RES_EQP].size = dev_lim->eqpc_entry_sz;
- profile[MTHCA_RES_EEEC].size = dev_lim->eeec_entry_sz;
- profile[MTHCA_RES_EQ].size = dev_lim->eqc_entry_sz;
- profile[MTHCA_RES_RDB].size = MTHCA_RDB_ENTRY_SIZE;
- profile[MTHCA_RES_MCG].size = MTHCA_MGM_ENTRY_SIZE;
- profile[MTHCA_RES_MPT].size = dev_lim->mpt_entry_sz;
- profile[MTHCA_RES_MTT].size = dev->limits.mtt_seg_size;
- profile[MTHCA_RES_UAR].size = dev_lim->uar_scratch_entry_sz;
- profile[MTHCA_RES_UDAV].size = MTHCA_AV_SIZE;
- profile[MTHCA_RES_UARC].size = request->uarc_size;
-
- profile[MTHCA_RES_QP].num = request->num_qp;
- profile[MTHCA_RES_SRQ].num = request->num_srq;
- profile[MTHCA_RES_EQP].num = request->num_qp;
- profile[MTHCA_RES_RDB].num = request->num_qp * request->rdb_per_qp;
- profile[MTHCA_RES_CQ].num = request->num_cq;
- profile[MTHCA_RES_EQ].num = MTHCA_NUM_EQS;
- profile[MTHCA_RES_MCG].num = request->num_mcg;
- profile[MTHCA_RES_MPT].num = request->num_mpt;
- profile[MTHCA_RES_MTT].num = request->num_mtt;
- profile[MTHCA_RES_UAR].num = request->num_uar;
- profile[MTHCA_RES_UARC].num = request->num_uar;
- profile[MTHCA_RES_UDAV].num = request->num_udav;
-
- for (i = 0; i < MTHCA_RES_NUM; ++i) {
- profile[i].type = i;
- profile[i].log_num = max(ffs(profile[i].num) - 1, 0);
- profile[i].size *= profile[i].num;
- if (mthca_is_memfree(dev))
- profile[i].size = max(profile[i].size, (u64) PAGE_SIZE);
- }
-
- if (mthca_is_memfree(dev)) {
- mem_base = 0;
- mem_avail = dev_lim->hca.arbel.max_icm_sz;
- } else {
- mem_base = dev->ddr_start;
- mem_avail = dev->fw.tavor.fw_start - dev->ddr_start;
- }
-
- /*
- * Sort the resources in decreasing order of size. Since they
- * all have sizes that are powers of 2, we'll be able to keep
- * resources aligned to their size and pack them without gaps
- * using the sorted order.
- */
- for (i = MTHCA_RES_NUM; i > 0; --i)
- for (j = 1; j < i; ++j) {
- if (profile[j].size > profile[j - 1].size) {
- tmp = profile[j];
- profile[j] = profile[j - 1];
- profile[j - 1] = tmp;
- }
- }
-
- for (i = 0; i < MTHCA_RES_NUM; ++i) {
- if (profile[i].size) {
- profile[i].start = mem_base + total_size;
- total_size += profile[i].size;
- }
- if (total_size > mem_avail) {
- mthca_err(dev, "Profile requires 0x%llx bytes; "
- "won't fit in 0x%llx bytes of context memory.\n",
- (unsigned long long) total_size,
- (unsigned long long) mem_avail);
- kfree(profile);
- return -ENOMEM;
- }
-
- if (profile[i].size)
- mthca_dbg(dev, "profile[%2d]--%2d/%2d @ 0x%16llx "
- "(size 0x%8llx)\n",
- i, profile[i].type, profile[i].log_num,
- (unsigned long long) profile[i].start,
- (unsigned long long) profile[i].size);
- }
-
- if (mthca_is_memfree(dev))
- mthca_dbg(dev, "HCA context memory: reserving %d KB\n",
- (int) (total_size >> 10));
- else
- mthca_dbg(dev, "HCA memory: allocated %d KB/%d KB (%d KB free)\n",
- (int) (total_size >> 10), (int) (mem_avail >> 10),
- (int) ((mem_avail - total_size) >> 10));
-
- for (i = 0; i < MTHCA_RES_NUM; ++i) {
- switch (profile[i].type) {
- case MTHCA_RES_QP:
- dev->limits.num_qps = profile[i].num;
- init_hca->qpc_base = profile[i].start;
- init_hca->log_num_qps = profile[i].log_num;
- break;
- case MTHCA_RES_EEC:
- dev->limits.num_eecs = profile[i].num;
- init_hca->eec_base = profile[i].start;
- init_hca->log_num_eecs = profile[i].log_num;
- break;
- case MTHCA_RES_SRQ:
- dev->limits.num_srqs = profile[i].num;
- init_hca->srqc_base = profile[i].start;
- init_hca->log_num_srqs = profile[i].log_num;
- break;
- case MTHCA_RES_CQ:
- dev->limits.num_cqs = profile[i].num;
- init_hca->cqc_base = profile[i].start;
- init_hca->log_num_cqs = profile[i].log_num;
- break;
- case MTHCA_RES_EQP:
- init_hca->eqpc_base = profile[i].start;
- break;
- case MTHCA_RES_EEEC:
- init_hca->eeec_base = profile[i].start;
- break;
- case MTHCA_RES_EQ:
- dev->limits.num_eqs = profile[i].num;
- init_hca->eqc_base = profile[i].start;
- init_hca->log_num_eqs = profile[i].log_num;
- break;
- case MTHCA_RES_RDB:
- for (dev->qp_table.rdb_shift = 0;
- request->num_qp << dev->qp_table.rdb_shift < profile[i].num;
- ++dev->qp_table.rdb_shift)
- ; /* nothing */
- dev->qp_table.rdb_base = (u32) profile[i].start;
- init_hca->rdb_base = profile[i].start;
- break;
- case MTHCA_RES_MCG:
- dev->limits.num_mgms = profile[i].num >> 1;
- dev->limits.num_amgms = profile[i].num >> 1;
- init_hca->mc_base = profile[i].start;
- init_hca->log_mc_entry_sz = ffs(MTHCA_MGM_ENTRY_SIZE) - 1;
- init_hca->log_mc_table_sz = profile[i].log_num;
- init_hca->mc_hash_sz = 1 << (profile[i].log_num - 1);
- break;
- case MTHCA_RES_MPT:
- dev->limits.num_mpts = profile[i].num;
- dev->mr_table.mpt_base = profile[i].start;
- init_hca->mpt_base = profile[i].start;
- init_hca->log_mpt_sz = profile[i].log_num;
- break;
- case MTHCA_RES_MTT:
- dev->limits.num_mtt_segs = profile[i].num;
- dev->mr_table.mtt_base = profile[i].start;
- init_hca->mtt_base = profile[i].start;
- init_hca->mtt_seg_sz = ffs(dev->limits.mtt_seg_size) - 7;
- break;
- case MTHCA_RES_UAR:
- dev->limits.num_uars = profile[i].num;
- init_hca->uar_scratch_base = profile[i].start;
- break;
- case MTHCA_RES_UDAV:
- dev->av_table.ddr_av_base = profile[i].start;
- dev->av_table.num_ddr_avs = profile[i].num;
- break;
- case MTHCA_RES_UARC:
- dev->uar_table.uarc_size = request->uarc_size;
- dev->uar_table.uarc_base = profile[i].start;
- init_hca->uarc_base = profile[i].start;
- init_hca->log_uarc_sz = ffs(request->uarc_size) - 13;
- init_hca->log_uar_sz = ffs(request->num_uar) - 1;
- break;
- default:
- break;
- }
- }
-
- /*
- * PDs don't take any HCA memory, but we assign them as part
- * of the HCA profile anyway.
- */
- dev->limits.num_pds = MTHCA_NUM_PDS;
-
- if (dev->mthca_flags & MTHCA_FLAG_SINAI_OPT &&
- init_hca->log_mpt_sz > 23) {
- mthca_warn(dev, "MPT table too large (requested size 2^%d >= 2^24)\n",
- init_hca->log_mpt_sz);
- mthca_warn(dev, "Disabling memory key throughput optimization.\n");
- dev->mthca_flags &= ~MTHCA_FLAG_SINAI_OPT;
- }
-
- /*
- * For Tavor, FMRs use ioremapped PCI memory. For 32 bit
- * systems it may use too much vmalloc space to map all MTT
- * memory, so we reserve some MTTs for FMR access, taking them
- * out of the MR pool. They don't use additional memory, but
- * we assign them as part of the HCA profile anyway.
- */
- if (mthca_is_memfree(dev) || BITS_PER_LONG == 64)
- dev->limits.fmr_reserved_mtts = 0;
- else
- dev->limits.fmr_reserved_mtts = request->fmr_reserved_mtts;
-
- kfree(profile);
- return total_size;
-}
diff --git a/sys/ofed/drivers/infiniband/hw/mthca/mthca_provider.c b/sys/ofed/drivers/infiniband/hw/mthca/mthca_provider.c
deleted file mode 100644
index 264db51..0000000
--- a/sys/ofed/drivers/infiniband/hw/mthca/mthca_provider.c
+++ /dev/null
@@ -1,1448 +0,0 @@
-/*
- * Copyright (c) 2004, 2005 Topspin Communications. All rights reserved.
- * Copyright (c) 2005 Sun Microsystems, Inc. All rights reserved.
- * Copyright (c) 2005, 2006 Cisco Systems. All rights reserved.
- * Copyright (c) 2005 Mellanox Technologies. All rights reserved.
- * Copyright (c) 2004 Voltaire, Inc. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-#include <rdma/ib_smi.h>
-#include <rdma/ib_umem.h>
-#include <rdma/ib_user_verbs.h>
-
-#include <linux/sched.h>
-#include <linux/mm.h>
-#include <linux/fs.h>
-
-#include "mthca_dev.h"
-#include "mthca_cmd.h"
-#include "mthca_user.h"
-#include "mthca_memfree.h"
-
-static void init_query_mad(struct ib_smp *mad)
-{
- mad->base_version = 1;
- mad->mgmt_class = IB_MGMT_CLASS_SUBN_LID_ROUTED;
- mad->class_version = 1;
- mad->method = IB_MGMT_METHOD_GET;
-}
-
-static int mthca_query_device(struct ib_device *ibdev,
- struct ib_device_attr *props)
-{
- struct ib_smp *in_mad = NULL;
- struct ib_smp *out_mad = NULL;
- int err = -ENOMEM;
- struct mthca_dev *mdev = to_mdev(ibdev);
-
- u8 status;
-
- in_mad = kzalloc(sizeof *in_mad, GFP_KERNEL);
- out_mad = kmalloc(sizeof *out_mad, GFP_KERNEL);
- if (!in_mad || !out_mad)
- goto out;
-
- memset(props, 0, sizeof *props);
-
- props->fw_ver = mdev->fw_ver;
-
- init_query_mad(in_mad);
- in_mad->attr_id = IB_SMP_ATTR_NODE_INFO;
-
- err = mthca_MAD_IFC(mdev, 1, 1,
- 1, NULL, NULL, in_mad, out_mad,
- &status);
- if (err)
- goto out;
- if (status) {
- err = -EINVAL;
- goto out;
- }
-
- props->device_cap_flags = mdev->device_cap_flags;
- props->vendor_id = be32_to_cpup((__be32 *) (out_mad->data + 36)) &
- 0xffffff;
- props->vendor_part_id = be16_to_cpup((__be16 *) (out_mad->data + 30));
- props->hw_ver = be32_to_cpup((__be32 *) (out_mad->data + 32));
- memcpy(&props->sys_image_guid, out_mad->data + 4, 8);
-
- props->max_mr_size = ~0ull;
- props->page_size_cap = mdev->limits.page_size_cap;
- props->max_qp = mdev->limits.num_qps - mdev->limits.reserved_qps;
- props->max_qp_wr = mdev->limits.max_wqes;
- props->max_sge = mdev->limits.max_sg;
- props->max_cq = mdev->limits.num_cqs - mdev->limits.reserved_cqs;
- props->max_cqe = mdev->limits.max_cqes;
- props->max_mr = mdev->limits.num_mpts - mdev->limits.reserved_mrws;
- props->max_pd = mdev->limits.num_pds - mdev->limits.reserved_pds;
- props->max_qp_rd_atom = 1 << mdev->qp_table.rdb_shift;
- props->max_qp_init_rd_atom = mdev->limits.max_qp_init_rdma;
- props->max_res_rd_atom = props->max_qp_rd_atom * props->max_qp;
- props->max_srq = mdev->limits.num_srqs - mdev->limits.reserved_srqs;
- props->max_srq_wr = mdev->limits.max_srq_wqes;
- props->max_srq_sge = mdev->limits.max_srq_sge;
- props->local_ca_ack_delay = mdev->limits.local_ca_ack_delay;
- props->atomic_cap = mdev->limits.flags & DEV_LIM_FLAG_ATOMIC ?
- IB_ATOMIC_HCA : IB_ATOMIC_NONE;
- props->max_pkeys = mdev->limits.pkey_table_len;
- props->max_mcast_grp = mdev->limits.num_mgms + mdev->limits.num_amgms;
- props->max_mcast_qp_attach = MTHCA_QP_PER_MGM;
- props->max_total_mcast_qp_attach = props->max_mcast_qp_attach *
- props->max_mcast_grp;
- /*
- * If Sinai memory key optimization is being used, then only
- * the 8-bit key portion will change. For other HCAs, the
- * unused index bits will also be used for FMR remapping.
- */
- if (mdev->mthca_flags & MTHCA_FLAG_SINAI_OPT)
- props->max_map_per_fmr = 255;
- else
- props->max_map_per_fmr =
- (1 << (32 - ilog2(mdev->limits.num_mpts))) - 1;
-
- err = 0;
- out:
- kfree(in_mad);
- kfree(out_mad);
- return err;
-}
-
-static int mthca_query_port(struct ib_device *ibdev,
- u8 port, struct ib_port_attr *props)
-{
- struct ib_smp *in_mad = NULL;
- struct ib_smp *out_mad = NULL;
- int err = -ENOMEM;
- u8 status;
-
- in_mad = kzalloc(sizeof *in_mad, GFP_KERNEL);
- out_mad = kmalloc(sizeof *out_mad, GFP_KERNEL);
- if (!in_mad || !out_mad)
- goto out;
-
- memset(props, 0, sizeof *props);
-
- init_query_mad(in_mad);
- in_mad->attr_id = IB_SMP_ATTR_PORT_INFO;
- in_mad->attr_mod = cpu_to_be32(port);
-
- err = mthca_MAD_IFC(to_mdev(ibdev), 1, 1,
- port, NULL, NULL, in_mad, out_mad,
- &status);
- if (err)
- goto out;
- if (status) {
- err = -EINVAL;
- goto out;
- }
-
- props->lid = be16_to_cpup((__be16 *) (out_mad->data + 16));
- props->lmc = out_mad->data[34] & 0x7;
- props->sm_lid = be16_to_cpup((__be16 *) (out_mad->data + 18));
- props->sm_sl = out_mad->data[36] & 0xf;
- props->state = out_mad->data[32] & 0xf;
- props->phys_state = out_mad->data[33] >> 4;
- props->port_cap_flags = be32_to_cpup((__be32 *) (out_mad->data + 20));
- props->gid_tbl_len = to_mdev(ibdev)->limits.gid_table_len;
- props->max_msg_sz = 0x80000000;
- props->pkey_tbl_len = to_mdev(ibdev)->limits.pkey_table_len;
- props->bad_pkey_cntr = be16_to_cpup((__be16 *) (out_mad->data + 46));
- props->qkey_viol_cntr = be16_to_cpup((__be16 *) (out_mad->data + 48));
- props->active_width = out_mad->data[31] & 0xf;
- props->active_speed = out_mad->data[35] >> 4;
- props->max_mtu = out_mad->data[41] & 0xf;
- props->active_mtu = out_mad->data[36] >> 4;
- props->subnet_timeout = out_mad->data[51] & 0x1f;
- props->max_vl_num = out_mad->data[37] >> 4;
- props->init_type_reply = out_mad->data[41] >> 4;
-
- out:
- kfree(in_mad);
- kfree(out_mad);
- return err;
-}
-
-static int mthca_modify_device(struct ib_device *ibdev,
- int mask,
- struct ib_device_modify *props)
-{
- if (mask & ~IB_DEVICE_MODIFY_NODE_DESC)
- return -EOPNOTSUPP;
-
- if (mask & IB_DEVICE_MODIFY_NODE_DESC) {
- if (mutex_lock_interruptible(&to_mdev(ibdev)->cap_mask_mutex))
- return -ERESTARTSYS;
- memcpy(ibdev->node_desc, props->node_desc, 64);
- mutex_unlock(&to_mdev(ibdev)->cap_mask_mutex);
- }
-
- return 0;
-}
-
-static int mthca_modify_port(struct ib_device *ibdev,
- u8 port, int port_modify_mask,
- struct ib_port_modify *props)
-{
- struct mthca_set_ib_param set_ib;
- struct ib_port_attr attr;
- int err;
- u8 status;
-
- if (mutex_lock_interruptible(&to_mdev(ibdev)->cap_mask_mutex))
- return -ERESTARTSYS;
-
- err = mthca_query_port(ibdev, port, &attr);
- if (err)
- goto out;
-
- set_ib.set_si_guid = 0;
- set_ib.reset_qkey_viol = !!(port_modify_mask & IB_PORT_RESET_QKEY_CNTR);
-
- set_ib.cap_mask = (attr.port_cap_flags | props->set_port_cap_mask) &
- ~props->clr_port_cap_mask;
-
- err = mthca_SET_IB(to_mdev(ibdev), &set_ib, port, &status);
- if (err)
- goto out;
- if (status) {
- err = -EINVAL;
- goto out;
- }
-
-out:
- mutex_unlock(&to_mdev(ibdev)->cap_mask_mutex);
- return err;
-}
-
-static int mthca_query_pkey(struct ib_device *ibdev,
- u8 port, u16 index, u16 *pkey)
-{
- struct ib_smp *in_mad = NULL;
- struct ib_smp *out_mad = NULL;
- int err = -ENOMEM;
- u8 status;
-
- in_mad = kzalloc(sizeof *in_mad, GFP_KERNEL);
- out_mad = kmalloc(sizeof *out_mad, GFP_KERNEL);
- if (!in_mad || !out_mad)
- goto out;
-
- init_query_mad(in_mad);
- in_mad->attr_id = IB_SMP_ATTR_PKEY_TABLE;
- in_mad->attr_mod = cpu_to_be32(index / 32);
-
- err = mthca_MAD_IFC(to_mdev(ibdev), 1, 1,
- port, NULL, NULL, in_mad, out_mad,
- &status);
- if (err)
- goto out;
- if (status) {
- err = -EINVAL;
- goto out;
- }
-
- *pkey = be16_to_cpu(((__be16 *) out_mad->data)[index % 32]);
-
- out:
- kfree(in_mad);
- kfree(out_mad);
- return err;
-}
-
-static int mthca_query_gid(struct ib_device *ibdev, u8 port,
- int index, union ib_gid *gid)
-{
- struct ib_smp *in_mad = NULL;
- struct ib_smp *out_mad = NULL;
- int err = -ENOMEM;
- u8 status;
-
- in_mad = kzalloc(sizeof *in_mad, GFP_KERNEL);
- out_mad = kmalloc(sizeof *out_mad, GFP_KERNEL);
- if (!in_mad || !out_mad)
- goto out;
-
- init_query_mad(in_mad);
- in_mad->attr_id = IB_SMP_ATTR_PORT_INFO;
- in_mad->attr_mod = cpu_to_be32(port);
-
- err = mthca_MAD_IFC(to_mdev(ibdev), 1, 1,
- port, NULL, NULL, in_mad, out_mad,
- &status);
- if (err)
- goto out;
- if (status) {
- err = -EINVAL;
- goto out;
- }
-
- memcpy(gid->raw, out_mad->data + 8, 8);
-
- init_query_mad(in_mad);
- in_mad->attr_id = IB_SMP_ATTR_GUID_INFO;
- in_mad->attr_mod = cpu_to_be32(index / 8);
-
- err = mthca_MAD_IFC(to_mdev(ibdev), 1, 1,
- port, NULL, NULL, in_mad, out_mad,
- &status);
- if (err)
- goto out;
- if (status) {
- err = -EINVAL;
- goto out;
- }
-
- memcpy(gid->raw + 8, out_mad->data + (index % 8) * 8, 8);
-
- out:
- kfree(in_mad);
- kfree(out_mad);
- return err;
-}
-
-static struct ib_ucontext *mthca_alloc_ucontext(struct ib_device *ibdev,
- struct ib_udata *udata)
-{
- struct mthca_alloc_ucontext_resp uresp;
- struct mthca_ucontext *context;
- int err;
-
- if (!(to_mdev(ibdev)->active))
- return ERR_PTR(-EAGAIN);
-
- memset(&uresp, 0, sizeof uresp);
-
- uresp.qp_tab_size = to_mdev(ibdev)->limits.num_qps;
- if (mthca_is_memfree(to_mdev(ibdev)))
- uresp.uarc_size = to_mdev(ibdev)->uar_table.uarc_size;
- else
- uresp.uarc_size = 0;
-
- context = kmalloc(sizeof *context, GFP_KERNEL);
- if (!context)
- return ERR_PTR(-ENOMEM);
-
- err = mthca_uar_alloc(to_mdev(ibdev), &context->uar);
- if (err) {
- kfree(context);
- return ERR_PTR(err);
- }
-
- context->db_tab = mthca_init_user_db_tab(to_mdev(ibdev));
- if (IS_ERR(context->db_tab)) {
- err = PTR_ERR(context->db_tab);
- mthca_uar_free(to_mdev(ibdev), &context->uar);
- kfree(context);
- return ERR_PTR(err);
- }
-
- if (ib_copy_to_udata(udata, &uresp, sizeof uresp)) {
- mthca_cleanup_user_db_tab(to_mdev(ibdev), &context->uar, context->db_tab);
- mthca_uar_free(to_mdev(ibdev), &context->uar);
- kfree(context);
- return ERR_PTR(-EFAULT);
- }
-
- context->reg_mr_warned = 0;
-
- return &context->ibucontext;
-}
-
-static int mthca_dealloc_ucontext(struct ib_ucontext *context)
-{
- mthca_cleanup_user_db_tab(to_mdev(context->device), &to_mucontext(context)->uar,
- to_mucontext(context)->db_tab);
- mthca_uar_free(to_mdev(context->device), &to_mucontext(context)->uar);
- kfree(to_mucontext(context));
-
- return 0;
-}
-
-static int mthca_mmap_uar(struct ib_ucontext *context,
- struct vm_area_struct *vma)
-{
- if (vma->vm_end - vma->vm_start != PAGE_SIZE)
- return -EINVAL;
-
- vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);
-
- if (io_remap_pfn_range(vma, vma->vm_start,
- to_mucontext(context)->uar.pfn,
- PAGE_SIZE, vma->vm_page_prot))
- return -EAGAIN;
-
- return 0;
-}
-
-static struct ib_pd *mthca_alloc_pd(struct ib_device *ibdev,
- struct ib_ucontext *context,
- struct ib_udata *udata)
-{
- struct mthca_pd *pd;
- int err;
-
- pd = kmalloc(sizeof *pd, GFP_KERNEL);
- if (!pd)
- return ERR_PTR(-ENOMEM);
-
- err = mthca_pd_alloc(to_mdev(ibdev), !context, pd);
- if (err) {
- kfree(pd);
- return ERR_PTR(err);
- }
-
- if (context) {
- if (ib_copy_to_udata(udata, &pd->pd_num, sizeof (__u32))) {
- mthca_pd_free(to_mdev(ibdev), pd);
- kfree(pd);
- return ERR_PTR(-EFAULT);
- }
- }
-
- return &pd->ibpd;
-}
-
-static int mthca_dealloc_pd(struct ib_pd *pd)
-{
- mthca_pd_free(to_mdev(pd->device), to_mpd(pd));
- kfree(pd);
-
- return 0;
-}
-
-static struct ib_ah *mthca_ah_create(struct ib_pd *pd,
- struct ib_ah_attr *ah_attr)
-{
- int err;
- struct mthca_ah *ah;
-
- ah = kmalloc(sizeof *ah, GFP_ATOMIC);
- if (!ah)
- return ERR_PTR(-ENOMEM);
-
- err = mthca_create_ah(to_mdev(pd->device), to_mpd(pd), ah_attr, ah);
- if (err) {
- kfree(ah);
- return ERR_PTR(err);
- }
-
- return &ah->ibah;
-}
-
-static int mthca_ah_destroy(struct ib_ah *ah)
-{
- mthca_destroy_ah(to_mdev(ah->device), to_mah(ah));
- kfree(ah);
-
- return 0;
-}
-
-static struct ib_srq *mthca_create_srq(struct ib_pd *pd,
- struct ib_srq_init_attr *init_attr,
- struct ib_udata *udata)
-{
- struct mthca_create_srq ucmd;
- struct mthca_ucontext *context = NULL;
- struct mthca_srq *srq;
- int err;
-
- srq = kmalloc(sizeof *srq, GFP_KERNEL);
- if (!srq)
- return ERR_PTR(-ENOMEM);
-
- if (pd->uobject) {
- context = to_mucontext(pd->uobject->context);
-
- if (ib_copy_from_udata(&ucmd, udata, sizeof ucmd)) {
- err = -EFAULT;
- goto err_free;
- }
-
- err = mthca_map_user_db(to_mdev(pd->device), &context->uar,
- context->db_tab, ucmd.db_index,
- ucmd.db_page);
-
- if (err)
- goto err_free;
-
- srq->mr.ibmr.lkey = ucmd.lkey;
- srq->db_index = ucmd.db_index;
- }
-
- err = mthca_alloc_srq(to_mdev(pd->device), to_mpd(pd),
- &init_attr->attr, srq);
-
- if (err && pd->uobject)
- mthca_unmap_user_db(to_mdev(pd->device), &context->uar,
- context->db_tab, ucmd.db_index);
-
- if (err)
- goto err_free;
-
- if (context && ib_copy_to_udata(udata, &srq->srqn, sizeof (__u32))) {
- mthca_free_srq(to_mdev(pd->device), srq);
- err = -EFAULT;
- goto err_free;
- }
-
- return &srq->ibsrq;
-
-err_free:
- kfree(srq);
-
- return ERR_PTR(err);
-}
-
-static int mthca_destroy_srq(struct ib_srq *srq)
-{
- struct mthca_ucontext *context;
-
- if (srq->uobject) {
- context = to_mucontext(srq->uobject->context);
-
- mthca_unmap_user_db(to_mdev(srq->device), &context->uar,
- context->db_tab, to_msrq(srq)->db_index);
- }
-
- mthca_free_srq(to_mdev(srq->device), to_msrq(srq));
- kfree(srq);
-
- return 0;
-}
-
-static struct ib_qp *mthca_create_qp(struct ib_pd *pd,
- struct ib_qp_init_attr *init_attr,
- struct ib_udata *udata)
-{
- struct mthca_create_qp ucmd;
- struct mthca_qp *qp;
- int err;
-
- if (init_attr->create_flags)
- return ERR_PTR(-EINVAL);
-
- switch (init_attr->qp_type) {
- case IB_QPT_RC:
- case IB_QPT_UC:
- case IB_QPT_UD:
- {
- struct mthca_ucontext *context;
-
- qp = kmalloc(sizeof *qp, GFP_KERNEL);
- if (!qp)
- return ERR_PTR(-ENOMEM);
-
- if (pd->uobject) {
- context = to_mucontext(pd->uobject->context);
-
- if (ib_copy_from_udata(&ucmd, udata, sizeof ucmd)) {
- kfree(qp);
- return ERR_PTR(-EFAULT);
- }
-
- err = mthca_map_user_db(to_mdev(pd->device), &context->uar,
- context->db_tab,
- ucmd.sq_db_index, ucmd.sq_db_page);
- if (err) {
- kfree(qp);
- return ERR_PTR(err);
- }
-
- err = mthca_map_user_db(to_mdev(pd->device), &context->uar,
- context->db_tab,
- ucmd.rq_db_index, ucmd.rq_db_page);
- if (err) {
- mthca_unmap_user_db(to_mdev(pd->device),
- &context->uar,
- context->db_tab,
- ucmd.sq_db_index);
- kfree(qp);
- return ERR_PTR(err);
- }
-
- qp->mr.ibmr.lkey = ucmd.lkey;
- qp->sq.db_index = ucmd.sq_db_index;
- qp->rq.db_index = ucmd.rq_db_index;
- }
-
- err = mthca_alloc_qp(to_mdev(pd->device), to_mpd(pd),
- to_mcq(init_attr->send_cq),
- to_mcq(init_attr->recv_cq),
- init_attr->qp_type, init_attr->sq_sig_type,
- &init_attr->cap, qp);
-
- if (err && pd->uobject) {
- context = to_mucontext(pd->uobject->context);
-
- mthca_unmap_user_db(to_mdev(pd->device),
- &context->uar,
- context->db_tab,
- ucmd.sq_db_index);
- mthca_unmap_user_db(to_mdev(pd->device),
- &context->uar,
- context->db_tab,
- ucmd.rq_db_index);
- }
-
- qp->ibqp.qp_num = qp->qpn;
- break;
- }
- case IB_QPT_SMI:
- case IB_QPT_GSI:
- {
- /* Don't allow userspace to create special QPs */
- if (pd->uobject)
- return ERR_PTR(-EINVAL);
-
- qp = kmalloc(sizeof (struct mthca_sqp), GFP_KERNEL);
- if (!qp)
- return ERR_PTR(-ENOMEM);
-
- qp->ibqp.qp_num = init_attr->qp_type == IB_QPT_SMI ? 0 : 1;
-
- err = mthca_alloc_sqp(to_mdev(pd->device), to_mpd(pd),
- to_mcq(init_attr->send_cq),
- to_mcq(init_attr->recv_cq),
- init_attr->sq_sig_type, &init_attr->cap,
- qp->ibqp.qp_num, init_attr->port_num,
- to_msqp(qp));
- break;
- }
- default:
- /* Don't support raw QPs */
- return ERR_PTR(-ENOSYS);
- }
-
- if (err) {
- kfree(qp);
- return ERR_PTR(err);
- }
-
- init_attr->cap.max_send_wr = qp->sq.max;
- init_attr->cap.max_recv_wr = qp->rq.max;
- init_attr->cap.max_send_sge = qp->sq.max_gs;
- init_attr->cap.max_recv_sge = qp->rq.max_gs;
- init_attr->cap.max_inline_data = qp->max_inline_data;
-
- return &qp->ibqp;
-}
-
-static int mthca_destroy_qp(struct ib_qp *qp)
-{
- if (qp->uobject) {
- mthca_unmap_user_db(to_mdev(qp->device),
- &to_mucontext(qp->uobject->context)->uar,
- to_mucontext(qp->uobject->context)->db_tab,
- to_mqp(qp)->sq.db_index);
- mthca_unmap_user_db(to_mdev(qp->device),
- &to_mucontext(qp->uobject->context)->uar,
- to_mucontext(qp->uobject->context)->db_tab,
- to_mqp(qp)->rq.db_index);
- }
- mthca_free_qp(to_mdev(qp->device), to_mqp(qp));
- kfree(qp);
- return 0;
-}
-
-static struct ib_cq *mthca_create_cq(struct ib_device *ibdev,
- struct ib_cq_init_attr *attr,
- struct ib_ucontext *context,
- struct ib_udata *udata)
-{
- struct mthca_create_cq ucmd;
- struct mthca_cq *cq;
- int nent;
- int err;
- int entries = attr->cqe;
-
- if (entries < 1 || entries > to_mdev(ibdev)->limits.max_cqes)
- return ERR_PTR(-EINVAL);
-
- if (context) {
- if (ib_copy_from_udata(&ucmd, udata, sizeof ucmd))
- return ERR_PTR(-EFAULT);
-
- err = mthca_map_user_db(to_mdev(ibdev), &to_mucontext(context)->uar,
- to_mucontext(context)->db_tab,
- ucmd.set_db_index, ucmd.set_db_page);
- if (err)
- return ERR_PTR(err);
-
- err = mthca_map_user_db(to_mdev(ibdev), &to_mucontext(context)->uar,
- to_mucontext(context)->db_tab,
- ucmd.arm_db_index, ucmd.arm_db_page);
- if (err)
- goto err_unmap_set;
- }
-
- cq = kmalloc(sizeof *cq, GFP_KERNEL);
- if (!cq) {
- err = -ENOMEM;
- goto err_unmap_arm;
- }
-
- if (context) {
- cq->buf.mr.ibmr.lkey = ucmd.lkey;
- cq->set_ci_db_index = ucmd.set_db_index;
- cq->arm_db_index = ucmd.arm_db_index;
- }
-
- for (nent = 1; nent <= entries; nent <<= 1)
- ; /* nothing */
-
- err = mthca_init_cq(to_mdev(ibdev), nent,
- context ? to_mucontext(context) : NULL,
- context ? ucmd.pdn : to_mdev(ibdev)->driver_pd.pd_num,
- cq);
- if (err)
- goto err_free;
-
- if (context && ib_copy_to_udata(udata, &cq->cqn, sizeof (__u32))) {
- mthca_free_cq(to_mdev(ibdev), cq);
- goto err_free;
- }
-
- cq->resize_buf = NULL;
-
- return &cq->ibcq;
-
-err_free:
- kfree(cq);
-
-err_unmap_arm:
- if (context)
- mthca_unmap_user_db(to_mdev(ibdev), &to_mucontext(context)->uar,
- to_mucontext(context)->db_tab, ucmd.arm_db_index);
-
-err_unmap_set:
- if (context)
- mthca_unmap_user_db(to_mdev(ibdev), &to_mucontext(context)->uar,
- to_mucontext(context)->db_tab, ucmd.set_db_index);
-
- return ERR_PTR(err);
-}
-
-static int mthca_alloc_resize_buf(struct mthca_dev *dev, struct mthca_cq *cq,
- int entries)
-{
- int ret;
-
- spin_lock_irq(&cq->lock);
- if (cq->resize_buf) {
- ret = -EBUSY;
- goto unlock;
- }
-
- cq->resize_buf = kmalloc(sizeof *cq->resize_buf, GFP_ATOMIC);
- if (!cq->resize_buf) {
- ret = -ENOMEM;
- goto unlock;
- }
-
- cq->resize_buf->state = CQ_RESIZE_ALLOC;
-
- ret = 0;
-
-unlock:
- spin_unlock_irq(&cq->lock);
-
- if (ret)
- return ret;
-
- ret = mthca_alloc_cq_buf(dev, &cq->resize_buf->buf, entries);
- if (ret) {
- spin_lock_irq(&cq->lock);
- kfree(cq->resize_buf);
- cq->resize_buf = NULL;
- spin_unlock_irq(&cq->lock);
- return ret;
- }
-
- cq->resize_buf->cqe = entries - 1;
-
- spin_lock_irq(&cq->lock);
- cq->resize_buf->state = CQ_RESIZE_READY;
- spin_unlock_irq(&cq->lock);
-
- return 0;
-}
-
-static int mthca_resize_cq(struct ib_cq *ibcq, int entries, struct ib_udata *udata)
-{
- struct mthca_dev *dev = to_mdev(ibcq->device);
- struct mthca_cq *cq = to_mcq(ibcq);
- struct mthca_resize_cq ucmd;
- u32 lkey;
- u8 status;
- int ret;
-
- if (entries < 1 || entries > dev->limits.max_cqes)
- return -EINVAL;
-
- mutex_lock(&cq->mutex);
-
- entries = roundup_pow_of_two(entries + 1);
- if (entries == ibcq->cqe + 1) {
- ret = 0;
- goto out;
- }
-
- if (cq->is_kernel) {
- ret = mthca_alloc_resize_buf(dev, cq, entries);
- if (ret)
- goto out;
- lkey = cq->resize_buf->buf.mr.ibmr.lkey;
- } else {
- if (ib_copy_from_udata(&ucmd, udata, sizeof ucmd)) {
- ret = -EFAULT;
- goto out;
- }
- lkey = ucmd.lkey;
- }
-
- ret = mthca_RESIZE_CQ(dev, cq->cqn, lkey, ilog2(entries), &status);
- if (status)
- ret = -EINVAL;
-
- if (ret) {
- if (cq->resize_buf) {
- mthca_free_cq_buf(dev, &cq->resize_buf->buf,
- cq->resize_buf->cqe);
- kfree(cq->resize_buf);
- spin_lock_irq(&cq->lock);
- cq->resize_buf = NULL;
- spin_unlock_irq(&cq->lock);
- }
- goto out;
- }
-
- if (cq->is_kernel) {
- struct mthca_cq_buf tbuf;
- int tcqe;
-
- spin_lock_irq(&cq->lock);
- if (cq->resize_buf->state == CQ_RESIZE_READY) {
- mthca_cq_resize_copy_cqes(cq);
- tbuf = cq->buf;
- tcqe = cq->ibcq.cqe;
- cq->buf = cq->resize_buf->buf;
- cq->ibcq.cqe = cq->resize_buf->cqe;
- } else {
- tbuf = cq->resize_buf->buf;
- tcqe = cq->resize_buf->cqe;
- }
-
- kfree(cq->resize_buf);
- cq->resize_buf = NULL;
- spin_unlock_irq(&cq->lock);
-
- mthca_free_cq_buf(dev, &tbuf, tcqe);
- } else
- ibcq->cqe = entries - 1;
-
-out:
- mutex_unlock(&cq->mutex);
-
- return ret;
-}
-
-static int mthca_destroy_cq(struct ib_cq *cq)
-{
- if (cq->uobject) {
- mthca_unmap_user_db(to_mdev(cq->device),
- &to_mucontext(cq->uobject->context)->uar,
- to_mucontext(cq->uobject->context)->db_tab,
- to_mcq(cq)->arm_db_index);
- mthca_unmap_user_db(to_mdev(cq->device),
- &to_mucontext(cq->uobject->context)->uar,
- to_mucontext(cq->uobject->context)->db_tab,
- to_mcq(cq)->set_ci_db_index);
- }
- mthca_free_cq(to_mdev(cq->device), to_mcq(cq));
- kfree(cq);
-
- return 0;
-}
-
-static inline u32 convert_access(int acc)
-{
- return (acc & IB_ACCESS_REMOTE_ATOMIC ? MTHCA_MPT_FLAG_ATOMIC : 0) |
- (acc & IB_ACCESS_REMOTE_WRITE ? MTHCA_MPT_FLAG_REMOTE_WRITE : 0) |
- (acc & IB_ACCESS_REMOTE_READ ? MTHCA_MPT_FLAG_REMOTE_READ : 0) |
- (acc & IB_ACCESS_LOCAL_WRITE ? MTHCA_MPT_FLAG_LOCAL_WRITE : 0) |
- MTHCA_MPT_FLAG_LOCAL_READ;
-}
-
-static struct ib_mr *mthca_get_dma_mr(struct ib_pd *pd, int acc)
-{
- struct mthca_mr *mr;
- int err;
-
- mr = kmalloc(sizeof *mr, GFP_KERNEL);
- if (!mr)
- return ERR_PTR(-ENOMEM);
-
- err = mthca_mr_alloc_notrans(to_mdev(pd->device),
- to_mpd(pd)->pd_num,
- convert_access(acc), mr);
-
- if (err) {
- kfree(mr);
- return ERR_PTR(err);
- }
-
- mr->umem = NULL;
-
- return &mr->ibmr;
-}
-
-static struct ib_mr *mthca_reg_phys_mr(struct ib_pd *pd,
- struct ib_phys_buf *buffer_list,
- int num_phys_buf,
- int acc,
- u64 *iova_start)
-{
- struct mthca_mr *mr;
- u64 *page_list;
- u64 total_size;
- unsigned long mask;
- int shift;
- int npages;
- int err;
- int i, j, n;
-
- mask = buffer_list[0].addr ^ *iova_start;
- total_size = 0;
- for (i = 0; i < num_phys_buf; ++i) {
- if (i != 0)
- mask |= buffer_list[i].addr;
- if (i != num_phys_buf - 1)
- mask |= buffer_list[i].addr + buffer_list[i].size;
-
- total_size += buffer_list[i].size;
- }
-
- if (mask & ~PAGE_MASK)
- return ERR_PTR(-EINVAL);
-
- shift = __ffs(mask | 1 << 31);
-
- buffer_list[0].size += buffer_list[0].addr & ((1ULL << shift) - 1);
- buffer_list[0].addr &= ~0ull << shift;
-
- mr = kmalloc(sizeof *mr, GFP_KERNEL);
- if (!mr)
- return ERR_PTR(-ENOMEM);
-
- npages = 0;
- for (i = 0; i < num_phys_buf; ++i)
- npages += (buffer_list[i].size + (1ULL << shift) - 1) >> shift;
-
- if (!npages)
- return &mr->ibmr;
-
- page_list = kmalloc(npages * sizeof *page_list, GFP_KERNEL);
- if (!page_list) {
- kfree(mr);
- return ERR_PTR(-ENOMEM);
- }
-
- n = 0;
- for (i = 0; i < num_phys_buf; ++i)
- for (j = 0;
- j < (buffer_list[i].size + (1ULL << shift) - 1) >> shift;
- ++j)
- page_list[n++] = buffer_list[i].addr + ((u64) j << shift);
-
- mthca_dbg(to_mdev(pd->device), "Registering memory at %llx (iova %llx) "
- "in PD %x; shift %d, npages %d.\n",
- (unsigned long long) buffer_list[0].addr,
- (unsigned long long) *iova_start,
- to_mpd(pd)->pd_num,
- shift, npages);
-
- err = mthca_mr_alloc_phys(to_mdev(pd->device),
- to_mpd(pd)->pd_num,
- page_list, shift, npages,
- *iova_start, total_size,
- convert_access(acc), mr);
-
- if (err) {
- kfree(page_list);
- kfree(mr);
- return ERR_PTR(err);
- }
-
- kfree(page_list);
- mr->umem = NULL;
-
- return &mr->ibmr;
-}
-
-static struct ib_mr *mthca_reg_user_mr(struct ib_pd *pd, u64 start, u64 length,
- u64 virt, int acc, struct ib_udata *udata, int mr_id)
-{
- struct mthca_dev *dev = to_mdev(pd->device);
- struct scatterlist *sg;
- struct mthca_mr *mr;
- struct mthca_reg_mr ucmd;
- u64 *pages;
- int shift, n, len;
- int i, k, entry;
- int err = 0;
- int write_mtt_size;
-
- if (udata->inlen - sizeof (struct ib_uverbs_cmd_hdr) < sizeof ucmd) {
- if (!to_mucontext(pd->uobject->context)->reg_mr_warned) {
- mthca_warn(dev, "Process '%s' did not pass in MR attrs.\n",
- curproc->p_comm);
- mthca_warn(dev, " Update libmthca to fix this.\n");
- }
- ++to_mucontext(pd->uobject->context)->reg_mr_warned;
- ucmd.mr_attrs = 0;
- } else if (ib_copy_from_udata(&ucmd, udata, sizeof ucmd))
- return ERR_PTR(-EFAULT);
-
- mr = kmalloc(sizeof *mr, GFP_KERNEL);
- if (!mr)
- return ERR_PTR(-ENOMEM);
-
- mr->umem = ib_umem_get(pd->uobject->context, start, length, acc,
- ucmd.mr_attrs & MTHCA_MR_DMASYNC);
-
- if (IS_ERR(mr->umem)) {
- err = PTR_ERR(mr->umem);
- goto err;
- }
-
- shift = ffs(mr->umem->page_size) - 1;
-
- n = mr->umem->nmap;
- mr->mtt = mthca_alloc_mtt(dev, n);
- if (IS_ERR(mr->mtt)) {
- err = PTR_ERR(mr->mtt);
- goto err_umem;
- }
-
- pages = (u64 *) __get_free_page(GFP_KERNEL);
- if (!pages) {
- err = -ENOMEM;
- goto err_mtt;
- }
-
- i = n = 0;
-
- write_mtt_size = min(mthca_write_mtt_size(dev), (int) (PAGE_SIZE / sizeof *pages));
-
- for_each_sg(mr->umem->sg_head.sgl, sg, mr->umem->nmap, entry) {
- len = sg_dma_len(sg) >> shift;
- for (k = 0; k < len; ++k) {
- pages[i++] = sg_dma_address(sg) +
- mr->umem->page_size * k;
- /*
- * Be friendly to write_mtt and pass it chunks
- * of appropriate size.
- */
- if (i == write_mtt_size) {
- err = mthca_write_mtt(dev, mr->mtt, n, pages, i);
- if (err)
- goto mtt_done;
- n += i;
- i = 0;
- }
- }
- }
-
-
-
-
- if (i)
- err = mthca_write_mtt(dev, mr->mtt, n, pages, i);
-mtt_done:
- free_page((unsigned long) pages);
- if (err)
- goto err_mtt;
-
- err = mthca_mr_alloc(dev, to_mpd(pd)->pd_num, shift, virt, length,
- convert_access(acc), mr);
-
- if (err)
- goto err_mtt;
-
- return &mr->ibmr;
-
-err_mtt:
- mthca_free_mtt(dev, mr->mtt);
-
-err_umem:
- ib_umem_release(mr->umem);
-
-err:
- kfree(mr);
- return ERR_PTR(err);
-}
-
-static int mthca_dereg_mr(struct ib_mr *mr)
-{
- struct mthca_mr *mmr = to_mmr(mr);
-
- mthca_free_mr(to_mdev(mr->device), mmr);
- if (mmr->umem)
- ib_umem_release(mmr->umem);
- kfree(mmr);
-
- return 0;
-}
-
-static struct ib_fmr *mthca_alloc_fmr(struct ib_pd *pd, int mr_access_flags,
- struct ib_fmr_attr *fmr_attr)
-{
- struct mthca_fmr *fmr;
- int err;
-
- fmr = kmalloc(sizeof *fmr, GFP_KERNEL);
- if (!fmr)
- return ERR_PTR(-ENOMEM);
-
- memcpy(&fmr->attr, fmr_attr, sizeof *fmr_attr);
- err = mthca_fmr_alloc(to_mdev(pd->device), to_mpd(pd)->pd_num,
- convert_access(mr_access_flags), fmr);
-
- if (err) {
- kfree(fmr);
- return ERR_PTR(err);
- }
-
- return &fmr->ibmr;
-}
-
-static int mthca_dealloc_fmr(struct ib_fmr *fmr)
-{
- struct mthca_fmr *mfmr = to_mfmr(fmr);
- int err;
-
- err = mthca_free_fmr(to_mdev(fmr->device), mfmr);
- if (err)
- return err;
-
- kfree(mfmr);
- return 0;
-}
-
-static int mthca_unmap_fmr(struct list_head *fmr_list)
-{
- struct ib_fmr *fmr;
- int err;
- u8 status;
- struct mthca_dev *mdev = NULL;
-
- list_for_each_entry(fmr, fmr_list, list) {
- if (mdev && to_mdev(fmr->device) != mdev)
- return -EINVAL;
- mdev = to_mdev(fmr->device);
- }
-
- if (!mdev)
- return 0;
-
- if (mthca_is_memfree(mdev)) {
- list_for_each_entry(fmr, fmr_list, list)
- mthca_arbel_fmr_unmap(mdev, to_mfmr(fmr));
-
- wmb();
- } else
- list_for_each_entry(fmr, fmr_list, list)
- mthca_tavor_fmr_unmap(mdev, to_mfmr(fmr));
-
- err = mthca_SYNC_TPT(mdev, &status);
- if (err)
- return err;
- if (status)
- return -EINVAL;
- return 0;
-}
-
-static ssize_t show_rev(struct device *device, struct device_attribute *attr,
- char *buf)
-{
- struct mthca_dev *dev =
- container_of(device, struct mthca_dev, ib_dev.dev);
- return sprintf(buf, "%x\n", dev->rev_id);
-}
-
-static ssize_t show_fw_ver(struct device *device, struct device_attribute *attr,
- char *buf)
-{
- struct mthca_dev *dev =
- container_of(device, struct mthca_dev, ib_dev.dev);
- return sprintf(buf, "%d.%d.%d\n", (int) (dev->fw_ver >> 32),
- (int) (dev->fw_ver >> 16) & 0xffff,
- (int) dev->fw_ver & 0xffff);
-}
-
-static ssize_t show_hca(struct device *device, struct device_attribute *attr,
- char *buf)
-{
- struct mthca_dev *dev =
- container_of(device, struct mthca_dev, ib_dev.dev);
- switch (dev->pdev->device) {
- case PCI_DEVICE_ID_MELLANOX_TAVOR:
- return sprintf(buf, "MT23108\n");
- case PCI_DEVICE_ID_MELLANOX_ARBEL_COMPAT:
- return sprintf(buf, "MT25208 (MT23108 compat mode)\n");
- case PCI_DEVICE_ID_MELLANOX_ARBEL:
- return sprintf(buf, "MT25208\n");
- case PCI_DEVICE_ID_MELLANOX_SINAI:
- case PCI_DEVICE_ID_MELLANOX_SINAI_OLD:
- return sprintf(buf, "MT25204\n");
- default:
- return sprintf(buf, "unknown\n");
- }
-}
-
-static ssize_t show_board(struct device *device, struct device_attribute *attr,
- char *buf)
-{
- struct mthca_dev *dev =
- container_of(device, struct mthca_dev, ib_dev.dev);
- return sprintf(buf, "%.*s\n", MTHCA_BOARD_ID_LEN, dev->board_id);
-}
-
-static DEVICE_ATTR(hw_rev, S_IRUGO, show_rev, NULL);
-static DEVICE_ATTR(fw_ver, S_IRUGO, show_fw_ver, NULL);
-static DEVICE_ATTR(hca_type, S_IRUGO, show_hca, NULL);
-static DEVICE_ATTR(board_id, S_IRUGO, show_board, NULL);
-
-static struct device_attribute *mthca_dev_attributes[] = {
- &dev_attr_hw_rev,
- &dev_attr_fw_ver,
- &dev_attr_hca_type,
- &dev_attr_board_id
-};
-
-static int mthca_init_node_data(struct mthca_dev *dev)
-{
- struct ib_smp *in_mad = NULL;
- struct ib_smp *out_mad = NULL;
- int err = -ENOMEM;
- u8 status;
-
- in_mad = kzalloc(sizeof *in_mad, GFP_KERNEL);
- out_mad = kmalloc(sizeof *out_mad, GFP_KERNEL);
- if (!in_mad || !out_mad)
- goto out;
-
- init_query_mad(in_mad);
- in_mad->attr_id = IB_SMP_ATTR_NODE_DESC;
-
- err = mthca_MAD_IFC(dev, 1, 1,
- 1, NULL, NULL, in_mad, out_mad,
- &status);
- if (err)
- goto out;
- if (status) {
- err = -EINVAL;
- goto out;
- }
-
- memcpy(dev->ib_dev.node_desc, out_mad->data, 64);
-
- in_mad->attr_id = IB_SMP_ATTR_NODE_INFO;
-
- err = mthca_MAD_IFC(dev, 1, 1,
- 1, NULL, NULL, in_mad, out_mad,
- &status);
- if (err)
- goto out;
- if (status) {
- err = -EINVAL;
- goto out;
- }
-
- if (mthca_is_memfree(dev))
- dev->rev_id = be32_to_cpup((__be32 *) (out_mad->data + 32));
- memcpy(&dev->ib_dev.node_guid, out_mad->data + 12, 8);
-
-out:
- kfree(in_mad);
- kfree(out_mad);
- return err;
-}
-
-static int mthca_port_immutable(struct ib_device *ibdev, u8 port_num,
- struct ib_port_immutable *immutable)
-{
- struct ib_port_attr attr;
- int err;
-
- immutable->core_cap_flags = RDMA_CORE_PORT_IBA_IB;
-
- err = ib_query_port(ibdev, port_num, &attr);
- if (err)
- return err;
-
- immutable->pkey_tbl_len = attr.pkey_tbl_len;
- immutable->gid_tbl_len = attr.gid_tbl_len;
- immutable->max_mad_size = IB_MGMT_MAD_SIZE;
-
- return 0;
-}
-
-int mthca_register_device(struct mthca_dev *dev)
-{
- int ret;
- int i;
-
- ret = mthca_init_node_data(dev);
- if (ret)
- return ret;
-
- strlcpy(dev->ib_dev.name, "mthca%d", IB_DEVICE_NAME_MAX);
- dev->ib_dev.owner = THIS_MODULE;
-
- dev->ib_dev.uverbs_abi_ver = MTHCA_UVERBS_ABI_VERSION;
- dev->ib_dev.uverbs_cmd_mask =
- (1ull << IB_USER_VERBS_CMD_GET_CONTEXT) |
- (1ull << IB_USER_VERBS_CMD_QUERY_DEVICE) |
- (1ull << IB_USER_VERBS_CMD_QUERY_PORT) |
- (1ull << IB_USER_VERBS_CMD_ALLOC_PD) |
- (1ull << IB_USER_VERBS_CMD_DEALLOC_PD) |
- (1ull << IB_USER_VERBS_CMD_REG_MR) |
- (1ull << IB_USER_VERBS_CMD_DEREG_MR) |
- (1ull << IB_USER_VERBS_CMD_CREATE_COMP_CHANNEL) |
- (1ull << IB_USER_VERBS_CMD_CREATE_CQ) |
- (1ull << IB_USER_VERBS_CMD_RESIZE_CQ) |
- (1ull << IB_USER_VERBS_CMD_DESTROY_CQ) |
- (1ull << IB_USER_VERBS_CMD_CREATE_QP) |
- (1ull << IB_USER_VERBS_CMD_QUERY_QP) |
- (1ull << IB_USER_VERBS_CMD_MODIFY_QP) |
- (1ull << IB_USER_VERBS_CMD_DESTROY_QP) |
- (1ull << IB_USER_VERBS_CMD_ATTACH_MCAST) |
- (1ull << IB_USER_VERBS_CMD_DETACH_MCAST);
- dev->ib_dev.node_type = RDMA_NODE_IB_CA;
- dev->ib_dev.phys_port_cnt = dev->limits.num_ports;
- dev->ib_dev.num_comp_vectors = 1;
- dev->ib_dev.dma_device = &dev->pdev->dev;
- dev->ib_dev.query_device = mthca_query_device;
- dev->ib_dev.query_port = mthca_query_port;
- dev->ib_dev.modify_device = mthca_modify_device;
- dev->ib_dev.modify_port = mthca_modify_port;
- dev->ib_dev.query_pkey = mthca_query_pkey;
- dev->ib_dev.query_gid = mthca_query_gid;
- dev->ib_dev.alloc_ucontext = mthca_alloc_ucontext;
- dev->ib_dev.dealloc_ucontext = mthca_dealloc_ucontext;
- dev->ib_dev.mmap = mthca_mmap_uar;
- dev->ib_dev.alloc_pd = mthca_alloc_pd;
- dev->ib_dev.dealloc_pd = mthca_dealloc_pd;
- dev->ib_dev.create_ah = mthca_ah_create;
- dev->ib_dev.query_ah = mthca_ah_query;
- dev->ib_dev.destroy_ah = mthca_ah_destroy;
-
- if (dev->mthca_flags & MTHCA_FLAG_SRQ) {
- dev->ib_dev.create_srq = mthca_create_srq;
- dev->ib_dev.modify_srq = mthca_modify_srq;
- dev->ib_dev.query_srq = mthca_query_srq;
- dev->ib_dev.destroy_srq = mthca_destroy_srq;
- dev->ib_dev.uverbs_cmd_mask |=
- (1ull << IB_USER_VERBS_CMD_CREATE_SRQ) |
- (1ull << IB_USER_VERBS_CMD_MODIFY_SRQ) |
- (1ull << IB_USER_VERBS_CMD_QUERY_SRQ) |
- (1ull << IB_USER_VERBS_CMD_DESTROY_SRQ);
-
- if (mthca_is_memfree(dev))
- dev->ib_dev.post_srq_recv = mthca_arbel_post_srq_recv;
- else
- dev->ib_dev.post_srq_recv = mthca_tavor_post_srq_recv;
- }
-
- dev->ib_dev.create_qp = mthca_create_qp;
- dev->ib_dev.modify_qp = mthca_modify_qp;
- dev->ib_dev.query_qp = mthca_query_qp;
- dev->ib_dev.destroy_qp = mthca_destroy_qp;
- dev->ib_dev.create_cq = mthca_create_cq;
- dev->ib_dev.resize_cq = mthca_resize_cq;
- dev->ib_dev.destroy_cq = mthca_destroy_cq;
- dev->ib_dev.poll_cq = mthca_poll_cq;
- dev->ib_dev.get_dma_mr = mthca_get_dma_mr;
- dev->ib_dev.reg_phys_mr = mthca_reg_phys_mr;
- dev->ib_dev.reg_user_mr = mthca_reg_user_mr;
- dev->ib_dev.dereg_mr = mthca_dereg_mr;
- dev->ib_dev.get_port_immutable = mthca_port_immutable;
-
- if (dev->mthca_flags & MTHCA_FLAG_FMR) {
- dev->ib_dev.alloc_fmr = mthca_alloc_fmr;
- dev->ib_dev.unmap_fmr = mthca_unmap_fmr;
- dev->ib_dev.dealloc_fmr = mthca_dealloc_fmr;
- if (mthca_is_memfree(dev))
- dev->ib_dev.map_phys_fmr = mthca_arbel_map_phys_fmr;
- else
- dev->ib_dev.map_phys_fmr = mthca_tavor_map_phys_fmr;
- }
-
- dev->ib_dev.attach_mcast = mthca_multicast_attach;
- dev->ib_dev.detach_mcast = mthca_multicast_detach;
- dev->ib_dev.process_mad = mthca_process_mad;
-
- if (mthca_is_memfree(dev)) {
- dev->ib_dev.req_notify_cq = mthca_arbel_arm_cq;
- dev->ib_dev.post_send = mthca_arbel_post_send;
- dev->ib_dev.post_recv = mthca_arbel_post_receive;
- } else {
- dev->ib_dev.req_notify_cq = mthca_tavor_arm_cq;
- dev->ib_dev.post_send = mthca_tavor_post_send;
- dev->ib_dev.post_recv = mthca_tavor_post_receive;
- }
-
- mutex_init(&dev->cap_mask_mutex);
-
- ret = ib_register_device(&dev->ib_dev, NULL);
- if (ret)
- return ret;
-
- for (i = 0; i < ARRAY_SIZE(mthca_dev_attributes); ++i) {
- ret = device_create_file(&dev->ib_dev.dev,
- mthca_dev_attributes[i]);
- if (ret) {
- ib_unregister_device(&dev->ib_dev);
- return ret;
- }
- }
-
- mthca_start_catas_poll(dev);
-
- return 0;
-}
-
-void mthca_unregister_device(struct mthca_dev *dev)
-{
- mthca_stop_catas_poll(dev);
- ib_unregister_device(&dev->ib_dev);
-}
diff --git a/sys/ofed/drivers/infiniband/hw/mthca/mthca_provider.h b/sys/ofed/drivers/infiniband/hw/mthca/mthca_provider.h
deleted file mode 100644
index c621f87..0000000
--- a/sys/ofed/drivers/infiniband/hw/mthca/mthca_provider.h
+++ /dev/null
@@ -1,343 +0,0 @@
-/*
- * Copyright (c) 2004 Topspin Communications. All rights reserved.
- * Copyright (c) 2005, 2006 Cisco Systems. All rights reserved.
- * Copyright (c) 2005 Mellanox Technologies. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-#ifndef MTHCA_PROVIDER_H
-#define MTHCA_PROVIDER_H
-
-#include <rdma/ib_verbs.h>
-#include <rdma/ib_pack.h>
-
-#define MTHCA_MPT_FLAG_ATOMIC (1 << 14)
-#define MTHCA_MPT_FLAG_REMOTE_WRITE (1 << 13)
-#define MTHCA_MPT_FLAG_REMOTE_READ (1 << 12)
-#define MTHCA_MPT_FLAG_LOCAL_WRITE (1 << 11)
-#define MTHCA_MPT_FLAG_LOCAL_READ (1 << 10)
-
-struct mthca_buf_list {
- void *buf;
- DECLARE_PCI_UNMAP_ADDR(mapping)
-};
-
-union mthca_buf {
- struct mthca_buf_list direct;
- struct mthca_buf_list *page_list;
-};
-
-struct mthca_uar {
- unsigned long pfn;
- int index;
-};
-
-struct mthca_user_db_table;
-
-struct mthca_ucontext {
- struct ib_ucontext ibucontext;
- struct mthca_uar uar;
- struct mthca_user_db_table *db_tab;
- int reg_mr_warned;
-};
-
-struct mthca_mtt;
-
-struct mthca_mr {
- struct ib_mr ibmr;
- struct ib_umem *umem;
- struct mthca_mtt *mtt;
-};
-
-struct mthca_fmr {
- struct ib_fmr ibmr;
- struct ib_fmr_attr attr;
- struct mthca_mtt *mtt;
- int maps;
- union {
- struct {
- struct mthca_mpt_entry __iomem *mpt;
- u64 __iomem *mtts;
- } tavor;
- struct {
- struct mthca_mpt_entry *mpt;
- __be64 *mtts;
- dma_addr_t dma_handle;
- } arbel;
- } mem;
-};
-
-struct mthca_pd {
- struct ib_pd ibpd;
- u32 pd_num;
- atomic_t sqp_count;
- struct mthca_mr ntmr;
- int privileged;
-};
-
-struct mthca_eq {
- struct mthca_dev *dev;
- int eqn;
- u32 eqn_mask;
- u32 cons_index;
- u16 msi_x_vector;
- u16 msi_x_entry;
- int have_irq;
- int nent;
- struct mthca_buf_list *page_list;
- struct mthca_mr mr;
-};
-
-struct mthca_av;
-
-enum mthca_ah_type {
- MTHCA_AH_ON_HCA,
- MTHCA_AH_PCI_POOL,
- MTHCA_AH_KMALLOC
-};
-
-struct mthca_ah {
- struct ib_ah ibah;
- enum mthca_ah_type type;
- u32 key;
- struct mthca_av *av;
- dma_addr_t avdma;
-};
-
-/*
- * Quick description of our CQ/QP locking scheme:
- *
- * We have one global lock that protects dev->cq/qp_table. Each
- * struct mthca_cq/qp also has its own lock. An individual qp lock
- * may be taken inside of an individual cq lock. Both cqs attached to
- * a qp may be locked, with the cq with the lower cqn locked first.
- * No other nesting should be done.
- *
- * Each struct mthca_cq/qp also has an ref count, protected by the
- * corresponding table lock. The pointer from the cq/qp_table to the
- * struct counts as one reference. This reference also is good for
- * access through the consumer API, so modifying the CQ/QP etc doesn't
- * need to take another reference. Access to a QP because of a
- * completion being polled does not need a reference either.
- *
- * Finally, each struct mthca_cq/qp has a wait_queue_head_t for the
- * destroy function to sleep on.
- *
- * This means that access from the consumer API requires nothing but
- * taking the struct's lock.
- *
- * Access because of a completion event should go as follows:
- * - lock cq/qp_table and look up struct
- * - increment ref count in struct
- * - drop cq/qp_table lock
- * - lock struct, do your thing, and unlock struct
- * - decrement ref count; if zero, wake up waiters
- *
- * To destroy a CQ/QP, we can do the following:
- * - lock cq/qp_table
- * - remove pointer and decrement ref count
- * - unlock cq/qp_table lock
- * - wait_event until ref count is zero
- *
- * It is the consumer's responsibilty to make sure that no QP
- * operations (WQE posting or state modification) are pending when a
- * QP is destroyed. Also, the consumer must make sure that calls to
- * qp_modify are serialized. Similarly, the consumer is responsible
- * for ensuring that no CQ resize operations are pending when a CQ
- * is destroyed.
- *
- * Possible optimizations (wait for profile data to see if/where we
- * have locks bouncing between CPUs):
- * - split cq/qp table lock into n separate (cache-aligned) locks,
- * indexed (say) by the page in the table
- * - split QP struct lock into three (one for common info, one for the
- * send queue and one for the receive queue)
- */
-
-struct mthca_cq_buf {
- union mthca_buf queue;
- struct mthca_mr mr;
- int is_direct;
-};
-
-struct mthca_cq_resize {
- struct mthca_cq_buf buf;
- int cqe;
- enum {
- CQ_RESIZE_ALLOC,
- CQ_RESIZE_READY,
- CQ_RESIZE_SWAPPED
- } state;
-};
-
-struct mthca_cq {
- struct ib_cq ibcq;
- spinlock_t lock;
- int refcount;
- int cqn;
- u32 cons_index;
- struct mthca_cq_buf buf;
- struct mthca_cq_resize *resize_buf;
- int is_kernel;
-
- /* Next fields are Arbel only */
- int set_ci_db_index;
- __be32 *set_ci_db;
- int arm_db_index;
- __be32 *arm_db;
- int arm_sn;
-
- wait_queue_head_t wait;
- struct mutex mutex;
-};
-
-struct mthca_srq {
- struct ib_srq ibsrq;
- spinlock_t lock;
- int refcount;
- int srqn;
- int max;
- int max_gs;
- int wqe_shift;
- int first_free;
- int last_free;
- u16 counter; /* Arbel only */
- int db_index; /* Arbel only */
- __be32 *db; /* Arbel only */
- void *last;
-
- int is_direct;
- u64 *wrid;
- union mthca_buf queue;
- struct mthca_mr mr;
-
- wait_queue_head_t wait;
- struct mutex mutex;
-};
-
-struct mthca_wq {
- spinlock_t lock;
- int max;
- unsigned next_ind;
- unsigned last_comp;
- unsigned head;
- unsigned tail;
- void *last;
- int max_gs;
- int wqe_shift;
-
- int db_index; /* Arbel only */
- __be32 *db;
-};
-
-struct mthca_qp {
- struct ib_qp ibqp;
- int refcount;
- u32 qpn;
- int is_direct;
- u8 port; /* for SQP and memfree use only */
- u8 alt_port; /* for memfree use only */
- u8 transport;
- u8 state;
- u8 atomic_rd_en;
- u8 resp_depth;
-
- struct mthca_mr mr;
-
- struct mthca_wq rq;
- struct mthca_wq sq;
- enum ib_sig_type sq_policy;
- int send_wqe_offset;
- int max_inline_data;
-
- u64 *wrid;
- union mthca_buf queue;
-
- wait_queue_head_t wait;
- struct mutex mutex;
-};
-
-struct mthca_sqp {
- struct mthca_qp qp;
- int pkey_index;
- u32 qkey;
- u32 send_psn;
- struct ib_ud_header ud_header;
- int header_buf_size;
- void *header_buf;
- dma_addr_t header_dma;
-};
-
-static inline struct mthca_ucontext *to_mucontext(struct ib_ucontext *ibucontext)
-{
- return container_of(ibucontext, struct mthca_ucontext, ibucontext);
-}
-
-static inline struct mthca_fmr *to_mfmr(struct ib_fmr *ibmr)
-{
- return container_of(ibmr, struct mthca_fmr, ibmr);
-}
-
-static inline struct mthca_mr *to_mmr(struct ib_mr *ibmr)
-{
- return container_of(ibmr, struct mthca_mr, ibmr);
-}
-
-static inline struct mthca_pd *to_mpd(struct ib_pd *ibpd)
-{
- return container_of(ibpd, struct mthca_pd, ibpd);
-}
-
-static inline struct mthca_ah *to_mah(struct ib_ah *ibah)
-{
- return container_of(ibah, struct mthca_ah, ibah);
-}
-
-static inline struct mthca_cq *to_mcq(struct ib_cq *ibcq)
-{
- return container_of(ibcq, struct mthca_cq, ibcq);
-}
-
-static inline struct mthca_srq *to_msrq(struct ib_srq *ibsrq)
-{
- return container_of(ibsrq, struct mthca_srq, ibsrq);
-}
-
-static inline struct mthca_qp *to_mqp(struct ib_qp *ibqp)
-{
- return container_of(ibqp, struct mthca_qp, ibqp);
-}
-
-static inline struct mthca_sqp *to_msqp(struct mthca_qp *qp)
-{
- return container_of(qp, struct mthca_sqp, qp);
-}
-
-#endif /* MTHCA_PROVIDER_H */
diff --git a/sys/ofed/drivers/infiniband/hw/mthca/mthca_qp.c b/sys/ofed/drivers/infiniband/hw/mthca/mthca_qp.c
deleted file mode 100644
index 896f7f3..0000000
--- a/sys/ofed/drivers/infiniband/hw/mthca/mthca_qp.c
+++ /dev/null
@@ -1,2333 +0,0 @@
-/*
- * Copyright (c) 2004 Topspin Communications. All rights reserved.
- * Copyright (c) 2005 Cisco Systems. All rights reserved.
- * Copyright (c) 2005 Mellanox Technologies. All rights reserved.
- * Copyright (c) 2004 Voltaire, Inc. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-#include <linux/string.h>
-#include <linux/slab.h>
-#include <linux/sched.h>
-
-#include <asm/io.h>
-
-#include <rdma/ib_verbs.h>
-#include <rdma/ib_cache.h>
-#include <rdma/ib_pack.h>
-
-#include "mthca_dev.h"
-#include "mthca_cmd.h"
-#include "mthca_memfree.h"
-#include "mthca_wqe.h"
-
-enum {
- MTHCA_MAX_DIRECT_QP_SIZE = 4 * PAGE_SIZE,
- MTHCA_ACK_REQ_FREQ = 10,
- MTHCA_FLIGHT_LIMIT = 9,
- MTHCA_UD_HEADER_SIZE = 72, /* largest UD header possible */
- MTHCA_INLINE_HEADER_SIZE = 4, /* data segment overhead for inline */
- MTHCA_INLINE_CHUNK_SIZE = 16 /* inline data segment chunk */
-};
-
-enum {
- MTHCA_QP_STATE_RST = 0,
- MTHCA_QP_STATE_INIT = 1,
- MTHCA_QP_STATE_RTR = 2,
- MTHCA_QP_STATE_RTS = 3,
- MTHCA_QP_STATE_SQE = 4,
- MTHCA_QP_STATE_SQD = 5,
- MTHCA_QP_STATE_ERR = 6,
- MTHCA_QP_STATE_DRAINING = 7
-};
-
-enum {
- MTHCA_QP_ST_RC = 0x0,
- MTHCA_QP_ST_UC = 0x1,
- MTHCA_QP_ST_RD = 0x2,
- MTHCA_QP_ST_UD = 0x3,
- MTHCA_QP_ST_MLX = 0x7
-};
-
-enum {
- MTHCA_QP_PM_MIGRATED = 0x3,
- MTHCA_QP_PM_ARMED = 0x0,
- MTHCA_QP_PM_REARM = 0x1
-};
-
-enum {
- /* qp_context flags */
- MTHCA_QP_BIT_DE = 1 << 8,
- /* params1 */
- MTHCA_QP_BIT_SRE = 1 << 15,
- MTHCA_QP_BIT_SWE = 1 << 14,
- MTHCA_QP_BIT_SAE = 1 << 13,
- MTHCA_QP_BIT_SIC = 1 << 4,
- MTHCA_QP_BIT_SSC = 1 << 3,
- /* params2 */
- MTHCA_QP_BIT_RRE = 1 << 15,
- MTHCA_QP_BIT_RWE = 1 << 14,
- MTHCA_QP_BIT_RAE = 1 << 13,
- MTHCA_QP_BIT_RIC = 1 << 4,
- MTHCA_QP_BIT_RSC = 1 << 3
-};
-
-enum {
- MTHCA_SEND_DOORBELL_FENCE = 1 << 5
-};
-
-struct mthca_qp_path {
- __be32 port_pkey;
- u8 rnr_retry;
- u8 g_mylmc;
- __be16 rlid;
- u8 ackto;
- u8 mgid_index;
- u8 static_rate;
- u8 hop_limit;
- __be32 sl_tclass_flowlabel;
- u8 rgid[16];
-} __attribute__((packed));
-
-struct mthca_qp_context {
- __be32 flags;
- __be32 tavor_sched_queue; /* Reserved on Arbel */
- u8 mtu_msgmax;
- u8 rq_size_stride; /* Reserved on Tavor */
- u8 sq_size_stride; /* Reserved on Tavor */
- u8 rlkey_arbel_sched_queue; /* Reserved on Tavor */
- __be32 usr_page;
- __be32 local_qpn;
- __be32 remote_qpn;
- u32 reserved1[2];
- struct mthca_qp_path pri_path;
- struct mthca_qp_path alt_path;
- __be32 rdd;
- __be32 pd;
- __be32 wqe_base;
- __be32 wqe_lkey;
- __be32 params1;
- __be32 reserved2;
- __be32 next_send_psn;
- __be32 cqn_snd;
- __be32 snd_wqe_base_l; /* Next send WQE on Tavor */
- __be32 snd_db_index; /* (debugging only entries) */
- __be32 last_acked_psn;
- __be32 ssn;
- __be32 params2;
- __be32 rnr_nextrecvpsn;
- __be32 ra_buff_indx;
- __be32 cqn_rcv;
- __be32 rcv_wqe_base_l; /* Next recv WQE on Tavor */
- __be32 rcv_db_index; /* (debugging only entries) */
- __be32 qkey;
- __be32 srqn;
- __be32 rmsn;
- __be16 rq_wqe_counter; /* reserved on Tavor */
- __be16 sq_wqe_counter; /* reserved on Tavor */
- u32 reserved3[18];
-} __attribute__((packed));
-
-struct mthca_qp_param {
- __be32 opt_param_mask;
- u32 reserved1;
- struct mthca_qp_context context;
- u32 reserved2[62];
-} __attribute__((packed));
-
-enum {
- MTHCA_QP_OPTPAR_ALT_ADDR_PATH = 1 << 0,
- MTHCA_QP_OPTPAR_RRE = 1 << 1,
- MTHCA_QP_OPTPAR_RAE = 1 << 2,
- MTHCA_QP_OPTPAR_RWE = 1 << 3,
- MTHCA_QP_OPTPAR_PKEY_INDEX = 1 << 4,
- MTHCA_QP_OPTPAR_Q_KEY = 1 << 5,
- MTHCA_QP_OPTPAR_RNR_TIMEOUT = 1 << 6,
- MTHCA_QP_OPTPAR_PRIMARY_ADDR_PATH = 1 << 7,
- MTHCA_QP_OPTPAR_SRA_MAX = 1 << 8,
- MTHCA_QP_OPTPAR_RRA_MAX = 1 << 9,
- MTHCA_QP_OPTPAR_PM_STATE = 1 << 10,
- MTHCA_QP_OPTPAR_PORT_NUM = 1 << 11,
- MTHCA_QP_OPTPAR_RETRY_COUNT = 1 << 12,
- MTHCA_QP_OPTPAR_ALT_RNR_RETRY = 1 << 13,
- MTHCA_QP_OPTPAR_ACK_TIMEOUT = 1 << 14,
- MTHCA_QP_OPTPAR_RNR_RETRY = 1 << 15,
- MTHCA_QP_OPTPAR_SCHED_QUEUE = 1 << 16
-};
-
-static const u8 mthca_opcode[] = {
- [IB_WR_SEND] = MTHCA_OPCODE_SEND,
- [IB_WR_SEND_WITH_IMM] = MTHCA_OPCODE_SEND_IMM,
- [IB_WR_RDMA_WRITE] = MTHCA_OPCODE_RDMA_WRITE,
- [IB_WR_RDMA_WRITE_WITH_IMM] = MTHCA_OPCODE_RDMA_WRITE_IMM,
- [IB_WR_RDMA_READ] = MTHCA_OPCODE_RDMA_READ,
- [IB_WR_ATOMIC_CMP_AND_SWP] = MTHCA_OPCODE_ATOMIC_CS,
- [IB_WR_ATOMIC_FETCH_AND_ADD] = MTHCA_OPCODE_ATOMIC_FA,
-};
-
-static int is_sqp(struct mthca_dev *dev, struct mthca_qp *qp)
-{
- return qp->qpn >= dev->qp_table.sqp_start &&
- qp->qpn <= dev->qp_table.sqp_start + 3;
-}
-
-static int is_qp0(struct mthca_dev *dev, struct mthca_qp *qp)
-{
- return qp->qpn >= dev->qp_table.sqp_start &&
- qp->qpn <= dev->qp_table.sqp_start + 1;
-}
-
-static void *get_recv_wqe(struct mthca_qp *qp, int n)
-{
- if (qp->is_direct)
- return qp->queue.direct.buf + (n << qp->rq.wqe_shift);
- else
- return qp->queue.page_list[(n << qp->rq.wqe_shift) >> PAGE_SHIFT].buf +
- ((n << qp->rq.wqe_shift) & (PAGE_SIZE - 1));
-}
-
-static void *get_send_wqe(struct mthca_qp *qp, int n)
-{
- if (qp->is_direct)
- return qp->queue.direct.buf + qp->send_wqe_offset +
- (n << qp->sq.wqe_shift);
- else
- return qp->queue.page_list[(qp->send_wqe_offset +
- (n << qp->sq.wqe_shift)) >>
- PAGE_SHIFT].buf +
- ((qp->send_wqe_offset + (n << qp->sq.wqe_shift)) &
- (PAGE_SIZE - 1));
-}
-
-static void mthca_wq_reset(struct mthca_wq *wq)
-{
- wq->next_ind = 0;
- wq->last_comp = wq->max - 1;
- wq->head = 0;
- wq->tail = 0;
-}
-
-void mthca_qp_event(struct mthca_dev *dev, u32 qpn,
- enum ib_event_type event_type)
-{
- struct mthca_qp *qp;
- struct ib_event event;
-
- spin_lock(&dev->qp_table.lock);
- qp = mthca_array_get(&dev->qp_table.qp, qpn & (dev->limits.num_qps - 1));
- if (qp)
- ++qp->refcount;
- spin_unlock(&dev->qp_table.lock);
-
- if (!qp) {
- mthca_warn(dev, "Async event %d for bogus QP %08x\n",
- (int) event_type, qpn);
- return;
- }
-
- if (event_type == IB_EVENT_PATH_MIG)
- qp->port = qp->alt_port;
-
- event.device = &dev->ib_dev;
- event.event = event_type;
- event.element.qp = &qp->ibqp;
- if (qp->ibqp.event_handler)
- qp->ibqp.event_handler(&event, qp->ibqp.qp_context);
-
- spin_lock(&dev->qp_table.lock);
- if (!--qp->refcount)
- wake_up(&qp->wait);
- spin_unlock(&dev->qp_table.lock);
-}
-
-static int to_mthca_state(enum ib_qp_state ib_state)
-{
- switch (ib_state) {
- case IB_QPS_RESET: return MTHCA_QP_STATE_RST;
- case IB_QPS_INIT: return MTHCA_QP_STATE_INIT;
- case IB_QPS_RTR: return MTHCA_QP_STATE_RTR;
- case IB_QPS_RTS: return MTHCA_QP_STATE_RTS;
- case IB_QPS_SQD: return MTHCA_QP_STATE_SQD;
- case IB_QPS_SQE: return MTHCA_QP_STATE_SQE;
- case IB_QPS_ERR: return MTHCA_QP_STATE_ERR;
- default: return -1;
- }
-}
-
-enum { RC, UC, UD, RD, RDEE, MLX, NUM_TRANS };
-
-static int to_mthca_st(int transport)
-{
- switch (transport) {
- case RC: return MTHCA_QP_ST_RC;
- case UC: return MTHCA_QP_ST_UC;
- case UD: return MTHCA_QP_ST_UD;
- case RD: return MTHCA_QP_ST_RD;
- case MLX: return MTHCA_QP_ST_MLX;
- default: return -1;
- }
-}
-
-static void store_attrs(struct mthca_sqp *sqp, const struct ib_qp_attr *attr,
- int attr_mask)
-{
- if (attr_mask & IB_QP_PKEY_INDEX)
- sqp->pkey_index = attr->pkey_index;
- if (attr_mask & IB_QP_QKEY)
- sqp->qkey = attr->qkey;
- if (attr_mask & IB_QP_SQ_PSN)
- sqp->send_psn = attr->sq_psn;
-}
-
-static void init_port(struct mthca_dev *dev, int port)
-{
- int err;
- u8 status;
- struct mthca_init_ib_param param;
-
- memset(&param, 0, sizeof param);
-
- param.port_width = dev->limits.port_width_cap;
- param.vl_cap = dev->limits.vl_cap;
- param.mtu_cap = dev->limits.mtu_cap;
- param.gid_cap = dev->limits.gid_table_len;
- param.pkey_cap = dev->limits.pkey_table_len;
-
- err = mthca_INIT_IB(dev, &param, port, &status);
- if (err)
- mthca_warn(dev, "INIT_IB failed, return code %d.\n", err);
- if (status)
- mthca_warn(dev, "INIT_IB returned status %02x.\n", status);
-}
-
-static __be32 get_hw_access_flags(struct mthca_qp *qp, const struct ib_qp_attr *attr,
- int attr_mask)
-{
- u8 dest_rd_atomic;
- u32 access_flags;
- u32 hw_access_flags = 0;
-
- if (attr_mask & IB_QP_MAX_DEST_RD_ATOMIC)
- dest_rd_atomic = attr->max_dest_rd_atomic;
- else
- dest_rd_atomic = qp->resp_depth;
-
- if (attr_mask & IB_QP_ACCESS_FLAGS)
- access_flags = attr->qp_access_flags;
- else
- access_flags = qp->atomic_rd_en;
-
- if (!dest_rd_atomic)
- access_flags &= IB_ACCESS_REMOTE_WRITE;
-
- if (access_flags & IB_ACCESS_REMOTE_READ)
- hw_access_flags |= MTHCA_QP_BIT_RRE;
- if (access_flags & IB_ACCESS_REMOTE_ATOMIC)
- hw_access_flags |= MTHCA_QP_BIT_RAE;
- if (access_flags & IB_ACCESS_REMOTE_WRITE)
- hw_access_flags |= MTHCA_QP_BIT_RWE;
-
- return cpu_to_be32(hw_access_flags);
-}
-
-static inline enum ib_qp_state to_ib_qp_state(int mthca_state)
-{
- switch (mthca_state) {
- case MTHCA_QP_STATE_RST: return IB_QPS_RESET;
- case MTHCA_QP_STATE_INIT: return IB_QPS_INIT;
- case MTHCA_QP_STATE_RTR: return IB_QPS_RTR;
- case MTHCA_QP_STATE_RTS: return IB_QPS_RTS;
- case MTHCA_QP_STATE_DRAINING:
- case MTHCA_QP_STATE_SQD: return IB_QPS_SQD;
- case MTHCA_QP_STATE_SQE: return IB_QPS_SQE;
- case MTHCA_QP_STATE_ERR: return IB_QPS_ERR;
- default: return -1;
- }
-}
-
-static inline enum ib_mig_state to_ib_mig_state(int mthca_mig_state)
-{
- switch (mthca_mig_state) {
- case 0: return IB_MIG_ARMED;
- case 1: return IB_MIG_REARM;
- case 3: return IB_MIG_MIGRATED;
- default: return -1;
- }
-}
-
-static int to_ib_qp_access_flags(int mthca_flags)
-{
- int ib_flags = 0;
-
- if (mthca_flags & MTHCA_QP_BIT_RRE)
- ib_flags |= IB_ACCESS_REMOTE_READ;
- if (mthca_flags & MTHCA_QP_BIT_RWE)
- ib_flags |= IB_ACCESS_REMOTE_WRITE;
- if (mthca_flags & MTHCA_QP_BIT_RAE)
- ib_flags |= IB_ACCESS_REMOTE_ATOMIC;
-
- return ib_flags;
-}
-
-static void to_ib_ah_attr(struct mthca_dev *dev, struct ib_ah_attr *ib_ah_attr,
- struct mthca_qp_path *path)
-{
- memset(ib_ah_attr, 0, sizeof *ib_ah_attr);
- ib_ah_attr->port_num = (be32_to_cpu(path->port_pkey) >> 24) & 0x3;
-
- if (ib_ah_attr->port_num == 0 || ib_ah_attr->port_num > dev->limits.num_ports)
- return;
-
- ib_ah_attr->dlid = be16_to_cpu(path->rlid);
- ib_ah_attr->sl = be32_to_cpu(path->sl_tclass_flowlabel) >> 28;
- ib_ah_attr->src_path_bits = path->g_mylmc & 0x7f;
- ib_ah_attr->static_rate = mthca_rate_to_ib(dev,
- path->static_rate & 0xf,
- ib_ah_attr->port_num);
- ib_ah_attr->ah_flags = (path->g_mylmc & (1 << 7)) ? IB_AH_GRH : 0;
- if (ib_ah_attr->ah_flags) {
- ib_ah_attr->grh.sgid_index = path->mgid_index & (dev->limits.gid_table_len - 1);
- ib_ah_attr->grh.hop_limit = path->hop_limit;
- ib_ah_attr->grh.traffic_class =
- (be32_to_cpu(path->sl_tclass_flowlabel) >> 20) & 0xff;
- ib_ah_attr->grh.flow_label =
- be32_to_cpu(path->sl_tclass_flowlabel) & 0xfffff;
- memcpy(ib_ah_attr->grh.dgid.raw,
- path->rgid, sizeof ib_ah_attr->grh.dgid.raw);
- }
-}
-
-int mthca_query_qp(struct ib_qp *ibqp, struct ib_qp_attr *qp_attr, int qp_attr_mask,
- struct ib_qp_init_attr *qp_init_attr)
-{
- struct mthca_dev *dev = to_mdev(ibqp->device);
- struct mthca_qp *qp = to_mqp(ibqp);
- int err = 0;
- struct mthca_mailbox *mailbox = NULL;
- struct mthca_qp_param *qp_param;
- struct mthca_qp_context *context;
- int mthca_state;
- u8 status;
-
- mutex_lock(&qp->mutex);
-
- if (qp->state == IB_QPS_RESET) {
- qp_attr->qp_state = IB_QPS_RESET;
- goto done;
- }
-
- mailbox = mthca_alloc_mailbox(dev, GFP_KERNEL);
- if (IS_ERR(mailbox)) {
- err = PTR_ERR(mailbox);
- goto out;
- }
-
- err = mthca_QUERY_QP(dev, qp->qpn, 0, mailbox, &status);
- if (err)
- goto out_mailbox;
- if (status) {
- mthca_warn(dev, "QUERY_QP returned status %02x\n", status);
- err = -EINVAL;
- goto out_mailbox;
- }
-
- qp_param = mailbox->buf;
- context = &qp_param->context;
- mthca_state = be32_to_cpu(context->flags) >> 28;
-
- qp->state = to_ib_qp_state(mthca_state);
- qp_attr->qp_state = qp->state;
- qp_attr->path_mtu = context->mtu_msgmax >> 5;
- qp_attr->path_mig_state =
- to_ib_mig_state((be32_to_cpu(context->flags) >> 11) & 0x3);
- qp_attr->qkey = be32_to_cpu(context->qkey);
- qp_attr->rq_psn = be32_to_cpu(context->rnr_nextrecvpsn) & 0xffffff;
- qp_attr->sq_psn = be32_to_cpu(context->next_send_psn) & 0xffffff;
- qp_attr->dest_qp_num = be32_to_cpu(context->remote_qpn) & 0xffffff;
- qp_attr->qp_access_flags =
- to_ib_qp_access_flags(be32_to_cpu(context->params2));
-
- if (qp->transport == RC || qp->transport == UC) {
- to_ib_ah_attr(dev, &qp_attr->ah_attr, &context->pri_path);
- to_ib_ah_attr(dev, &qp_attr->alt_ah_attr, &context->alt_path);
- qp_attr->alt_pkey_index =
- be32_to_cpu(context->alt_path.port_pkey) & 0x7f;
- qp_attr->alt_port_num = qp_attr->alt_ah_attr.port_num;
- }
-
- qp_attr->pkey_index = be32_to_cpu(context->pri_path.port_pkey) & 0x7f;
- qp_attr->port_num =
- (be32_to_cpu(context->pri_path.port_pkey) >> 24) & 0x3;
-
- /* qp_attr->en_sqd_async_notify is only applicable in modify qp */
- qp_attr->sq_draining = mthca_state == MTHCA_QP_STATE_DRAINING;
-
- qp_attr->max_rd_atomic = 1 << ((be32_to_cpu(context->params1) >> 21) & 0x7);
-
- qp_attr->max_dest_rd_atomic =
- 1 << ((be32_to_cpu(context->params2) >> 21) & 0x7);
- qp_attr->min_rnr_timer =
- (be32_to_cpu(context->rnr_nextrecvpsn) >> 24) & 0x1f;
- qp_attr->timeout = context->pri_path.ackto >> 3;
- qp_attr->retry_cnt = (be32_to_cpu(context->params1) >> 16) & 0x7;
- qp_attr->rnr_retry = context->pri_path.rnr_retry >> 5;
- qp_attr->alt_timeout = context->alt_path.ackto >> 3;
-
-done:
- qp_attr->cur_qp_state = qp_attr->qp_state;
- qp_attr->cap.max_send_wr = qp->sq.max;
- qp_attr->cap.max_recv_wr = qp->rq.max;
- qp_attr->cap.max_send_sge = qp->sq.max_gs;
- qp_attr->cap.max_recv_sge = qp->rq.max_gs;
- qp_attr->cap.max_inline_data = qp->max_inline_data;
-
- qp_init_attr->cap = qp_attr->cap;
-
-out_mailbox:
- mthca_free_mailbox(dev, mailbox);
-
-out:
- mutex_unlock(&qp->mutex);
- return err;
-}
-
-static int mthca_path_set(struct mthca_dev *dev, const struct ib_ah_attr *ah,
- struct mthca_qp_path *path, u8 port)
-{
- path->g_mylmc = ah->src_path_bits & 0x7f;
- path->rlid = cpu_to_be16(ah->dlid);
- path->static_rate = mthca_get_rate(dev, ah->static_rate, port);
-
- if (ah->ah_flags & IB_AH_GRH) {
- if (ah->grh.sgid_index >= dev->limits.gid_table_len) {
- mthca_dbg(dev, "sgid_index (%u) too large. max is %d\n",
- ah->grh.sgid_index, dev->limits.gid_table_len-1);
- return -1;
- }
-
- path->g_mylmc |= 1 << 7;
- path->mgid_index = ah->grh.sgid_index;
- path->hop_limit = ah->grh.hop_limit;
- path->sl_tclass_flowlabel =
- cpu_to_be32((ah->sl << 28) |
- (ah->grh.traffic_class << 20) |
- (ah->grh.flow_label));
- memcpy(path->rgid, ah->grh.dgid.raw, 16);
- } else
- path->sl_tclass_flowlabel = cpu_to_be32(ah->sl << 28);
-
- return 0;
-}
-
-static int __mthca_modify_qp(struct ib_qp *ibqp,
- const struct ib_qp_attr *attr, int attr_mask,
- enum ib_qp_state cur_state, enum ib_qp_state new_state)
-{
- struct mthca_dev *dev = to_mdev(ibqp->device);
- struct mthca_qp *qp = to_mqp(ibqp);
- struct mthca_mailbox *mailbox;
- struct mthca_qp_param *qp_param;
- struct mthca_qp_context *qp_context;
- u32 sqd_event = 0;
- u8 status;
- int err = -EINVAL;
-
- mailbox = mthca_alloc_mailbox(dev, GFP_KERNEL);
- if (IS_ERR(mailbox)) {
- err = PTR_ERR(mailbox);
- goto out;
- }
- qp_param = mailbox->buf;
- qp_context = &qp_param->context;
- memset(qp_param, 0, sizeof *qp_param);
-
- qp_context->flags = cpu_to_be32((to_mthca_state(new_state) << 28) |
- (to_mthca_st(qp->transport) << 16));
- qp_context->flags |= cpu_to_be32(MTHCA_QP_BIT_DE);
- if (!(attr_mask & IB_QP_PATH_MIG_STATE))
- qp_context->flags |= cpu_to_be32(MTHCA_QP_PM_MIGRATED << 11);
- else {
- qp_param->opt_param_mask |= cpu_to_be32(MTHCA_QP_OPTPAR_PM_STATE);
- switch (attr->path_mig_state) {
- case IB_MIG_MIGRATED:
- qp_context->flags |= cpu_to_be32(MTHCA_QP_PM_MIGRATED << 11);
- break;
- case IB_MIG_REARM:
- qp_context->flags |= cpu_to_be32(MTHCA_QP_PM_REARM << 11);
- break;
- case IB_MIG_ARMED:
- qp_context->flags |= cpu_to_be32(MTHCA_QP_PM_ARMED << 11);
- break;
- }
- }
-
- /* leave tavor_sched_queue as 0 */
-
- if (qp->transport == MLX || qp->transport == UD)
- qp_context->mtu_msgmax = (IB_MTU_2048 << 5) | 11;
- else if (attr_mask & IB_QP_PATH_MTU) {
- if (attr->path_mtu < IB_MTU_256 || attr->path_mtu > IB_MTU_2048) {
- mthca_dbg(dev, "path MTU (%u) is invalid\n",
- attr->path_mtu);
- goto out_mailbox;
- }
- qp_context->mtu_msgmax = (attr->path_mtu << 5) | 31;
- }
-
- if (mthca_is_memfree(dev)) {
- if (qp->rq.max)
- qp_context->rq_size_stride = ilog2(qp->rq.max) << 3;
- qp_context->rq_size_stride |= qp->rq.wqe_shift - 4;
-
- if (qp->sq.max)
- qp_context->sq_size_stride = ilog2(qp->sq.max) << 3;
- qp_context->sq_size_stride |= qp->sq.wqe_shift - 4;
- }
-
- /* leave arbel_sched_queue as 0 */
-
- if (qp->ibqp.uobject)
- qp_context->usr_page =
- cpu_to_be32(to_mucontext(qp->ibqp.uobject->context)->uar.index);
- else
- qp_context->usr_page = cpu_to_be32(dev->driver_uar.index);
- qp_context->local_qpn = cpu_to_be32(qp->qpn);
- if (attr_mask & IB_QP_DEST_QPN) {
- qp_context->remote_qpn = cpu_to_be32(attr->dest_qp_num);
- }
-
- if (qp->transport == MLX)
- qp_context->pri_path.port_pkey |=
- cpu_to_be32(qp->port << 24);
- else {
- if (attr_mask & IB_QP_PORT) {
- qp_context->pri_path.port_pkey |=
- cpu_to_be32(attr->port_num << 24);
- qp_param->opt_param_mask |= cpu_to_be32(MTHCA_QP_OPTPAR_PORT_NUM);
- }
- }
-
- if (attr_mask & IB_QP_PKEY_INDEX) {
- qp_context->pri_path.port_pkey |=
- cpu_to_be32(attr->pkey_index);
- qp_param->opt_param_mask |= cpu_to_be32(MTHCA_QP_OPTPAR_PKEY_INDEX);
- }
-
- if (attr_mask & IB_QP_RNR_RETRY) {
- qp_context->alt_path.rnr_retry = qp_context->pri_path.rnr_retry =
- attr->rnr_retry << 5;
- qp_param->opt_param_mask |= cpu_to_be32(MTHCA_QP_OPTPAR_RNR_RETRY |
- MTHCA_QP_OPTPAR_ALT_RNR_RETRY);
- }
-
- if (attr_mask & IB_QP_AV) {
- if (mthca_path_set(dev, &attr->ah_attr, &qp_context->pri_path,
- attr_mask & IB_QP_PORT ? attr->port_num : qp->port))
- goto out_mailbox;
-
- qp_param->opt_param_mask |= cpu_to_be32(MTHCA_QP_OPTPAR_PRIMARY_ADDR_PATH);
- }
-
- if (ibqp->qp_type == IB_QPT_RC &&
- cur_state == IB_QPS_INIT && new_state == IB_QPS_RTR) {
- u8 sched_queue = ibqp->uobject ? 0x2 : 0x1;
-
- if (mthca_is_memfree(dev))
- qp_context->rlkey_arbel_sched_queue |= sched_queue;
- else
- qp_context->tavor_sched_queue |= cpu_to_be32(sched_queue);
-
- qp_param->opt_param_mask |=
- cpu_to_be32(MTHCA_QP_OPTPAR_SCHED_QUEUE);
- }
-
- if (attr_mask & IB_QP_TIMEOUT) {
- qp_context->pri_path.ackto = attr->timeout << 3;
- qp_param->opt_param_mask |= cpu_to_be32(MTHCA_QP_OPTPAR_ACK_TIMEOUT);
- }
-
- if (attr_mask & IB_QP_ALT_PATH) {
- if (attr->alt_pkey_index >= dev->limits.pkey_table_len) {
- mthca_dbg(dev, "Alternate P_Key index (%u) too large. max is %d\n",
- attr->alt_pkey_index, dev->limits.pkey_table_len-1);
- goto out_mailbox;
- }
-
- if (attr->alt_port_num == 0 || attr->alt_port_num > dev->limits.num_ports) {
- mthca_dbg(dev, "Alternate port number (%u) is invalid\n",
- attr->alt_port_num);
- goto out_mailbox;
- }
-
- if (mthca_path_set(dev, &attr->alt_ah_attr, &qp_context->alt_path,
- attr->alt_ah_attr.port_num))
- goto out_mailbox;
-
- qp_context->alt_path.port_pkey |= cpu_to_be32(attr->alt_pkey_index |
- attr->alt_port_num << 24);
- qp_context->alt_path.ackto = attr->alt_timeout << 3;
- qp_param->opt_param_mask |= cpu_to_be32(MTHCA_QP_OPTPAR_ALT_ADDR_PATH);
- }
-
- /* leave rdd as 0 */
- qp_context->pd = cpu_to_be32(to_mpd(ibqp->pd)->pd_num);
- /* leave wqe_base as 0 (we always create an MR based at 0 for WQs) */
- qp_context->wqe_lkey = cpu_to_be32(qp->mr.ibmr.lkey);
- qp_context->params1 = cpu_to_be32((MTHCA_ACK_REQ_FREQ << 28) |
- (MTHCA_FLIGHT_LIMIT << 24) |
- MTHCA_QP_BIT_SWE);
- if (qp->sq_policy == IB_SIGNAL_ALL_WR)
- qp_context->params1 |= cpu_to_be32(MTHCA_QP_BIT_SSC);
- if (attr_mask & IB_QP_RETRY_CNT) {
- qp_context->params1 |= cpu_to_be32(attr->retry_cnt << 16);
- qp_param->opt_param_mask |= cpu_to_be32(MTHCA_QP_OPTPAR_RETRY_COUNT);
- }
-
- if (attr_mask & IB_QP_MAX_QP_RD_ATOMIC) {
- if (attr->max_rd_atomic) {
- qp_context->params1 |=
- cpu_to_be32(MTHCA_QP_BIT_SRE |
- MTHCA_QP_BIT_SAE);
- qp_context->params1 |=
- cpu_to_be32(fls(attr->max_rd_atomic - 1) << 21);
- }
- qp_param->opt_param_mask |= cpu_to_be32(MTHCA_QP_OPTPAR_SRA_MAX);
- }
-
- if (attr_mask & IB_QP_SQ_PSN)
- qp_context->next_send_psn = cpu_to_be32(attr->sq_psn);
- qp_context->cqn_snd = cpu_to_be32(to_mcq(ibqp->send_cq)->cqn);
-
- if (mthca_is_memfree(dev)) {
- qp_context->snd_wqe_base_l = cpu_to_be32(qp->send_wqe_offset);
- qp_context->snd_db_index = cpu_to_be32(qp->sq.db_index);
- }
-
- if (attr_mask & IB_QP_MAX_DEST_RD_ATOMIC) {
- if (attr->max_dest_rd_atomic)
- qp_context->params2 |=
- cpu_to_be32(fls(attr->max_dest_rd_atomic - 1) << 21);
-
- qp_param->opt_param_mask |= cpu_to_be32(MTHCA_QP_OPTPAR_RRA_MAX);
- }
-
- if (attr_mask & (IB_QP_ACCESS_FLAGS | IB_QP_MAX_DEST_RD_ATOMIC)) {
- qp_context->params2 |= get_hw_access_flags(qp, attr, attr_mask);
- qp_param->opt_param_mask |= cpu_to_be32(MTHCA_QP_OPTPAR_RWE |
- MTHCA_QP_OPTPAR_RRE |
- MTHCA_QP_OPTPAR_RAE);
- }
-
- qp_context->params2 |= cpu_to_be32(MTHCA_QP_BIT_RSC);
-
- if (ibqp->srq)
- qp_context->params2 |= cpu_to_be32(MTHCA_QP_BIT_RIC);
-
- if (attr_mask & IB_QP_MIN_RNR_TIMER) {
- qp_context->rnr_nextrecvpsn |= cpu_to_be32(attr->min_rnr_timer << 24);
- qp_param->opt_param_mask |= cpu_to_be32(MTHCA_QP_OPTPAR_RNR_TIMEOUT);
- }
- if (attr_mask & IB_QP_RQ_PSN)
- qp_context->rnr_nextrecvpsn |= cpu_to_be32(attr->rq_psn);
-
- qp_context->ra_buff_indx =
- cpu_to_be32(dev->qp_table.rdb_base +
- ((qp->qpn & (dev->limits.num_qps - 1)) * MTHCA_RDB_ENTRY_SIZE <<
- dev->qp_table.rdb_shift));
-
- qp_context->cqn_rcv = cpu_to_be32(to_mcq(ibqp->recv_cq)->cqn);
-
- if (mthca_is_memfree(dev))
- qp_context->rcv_db_index = cpu_to_be32(qp->rq.db_index);
-
- if (attr_mask & IB_QP_QKEY) {
- qp_context->qkey = cpu_to_be32(attr->qkey);
- qp_param->opt_param_mask |= cpu_to_be32(MTHCA_QP_OPTPAR_Q_KEY);
- }
-
- if (ibqp->srq)
- qp_context->srqn = cpu_to_be32(1 << 24 |
- to_msrq(ibqp->srq)->srqn);
-
- if (cur_state == IB_QPS_RTS && new_state == IB_QPS_SQD &&
- attr_mask & IB_QP_EN_SQD_ASYNC_NOTIFY &&
- attr->en_sqd_async_notify)
- sqd_event = 1 << 31;
-
- err = mthca_MODIFY_QP(dev, cur_state, new_state, qp->qpn, 0,
- mailbox, sqd_event, &status);
- if (err)
- goto out_mailbox;
- if (status) {
- mthca_warn(dev, "modify QP %d->%d returned status %02x.\n",
- cur_state, new_state, status);
- err = -EINVAL;
- goto out_mailbox;
- }
-
- qp->state = new_state;
- if (attr_mask & IB_QP_ACCESS_FLAGS)
- qp->atomic_rd_en = attr->qp_access_flags;
- if (attr_mask & IB_QP_MAX_DEST_RD_ATOMIC)
- qp->resp_depth = attr->max_dest_rd_atomic;
- if (attr_mask & IB_QP_PORT)
- qp->port = attr->port_num;
- if (attr_mask & IB_QP_ALT_PATH)
- qp->alt_port = attr->alt_port_num;
-
- if (is_sqp(dev, qp))
- store_attrs(to_msqp(qp), attr, attr_mask);
-
- /*
- * If we moved QP0 to RTR, bring the IB link up; if we moved
- * QP0 to RESET or ERROR, bring the link back down.
- */
- if (is_qp0(dev, qp)) {
- if (cur_state != IB_QPS_RTR &&
- new_state == IB_QPS_RTR)
- init_port(dev, qp->port);
-
- if (cur_state != IB_QPS_RESET &&
- cur_state != IB_QPS_ERR &&
- (new_state == IB_QPS_RESET ||
- new_state == IB_QPS_ERR))
- mthca_CLOSE_IB(dev, qp->port, &status);
- }
-
- /*
- * If we moved a kernel QP to RESET, clean up all old CQ
- * entries and reinitialize the QP.
- */
- if (new_state == IB_QPS_RESET && !qp->ibqp.uobject) {
- mthca_cq_clean(dev, to_mcq(qp->ibqp.recv_cq), qp->qpn,
- qp->ibqp.srq ? to_msrq(qp->ibqp.srq) : NULL);
- if (qp->ibqp.send_cq != qp->ibqp.recv_cq)
- mthca_cq_clean(dev, to_mcq(qp->ibqp.send_cq), qp->qpn, NULL);
-
- mthca_wq_reset(&qp->sq);
- qp->sq.last = get_send_wqe(qp, qp->sq.max - 1);
-
- mthca_wq_reset(&qp->rq);
- qp->rq.last = get_recv_wqe(qp, qp->rq.max - 1);
-
- if (mthca_is_memfree(dev)) {
- *qp->sq.db = 0;
- *qp->rq.db = 0;
- }
- }
-
-out_mailbox:
- mthca_free_mailbox(dev, mailbox);
-out:
- return err;
-}
-
-int mthca_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr, int attr_mask,
- struct ib_udata *udata)
-{
- struct mthca_dev *dev = to_mdev(ibqp->device);
- struct mthca_qp *qp = to_mqp(ibqp);
- enum ib_qp_state cur_state, new_state;
- int err = -EINVAL;
-
- mutex_lock(&qp->mutex);
- if (attr_mask & IB_QP_CUR_STATE) {
- cur_state = attr->cur_qp_state;
- } else {
- spin_lock_irq(&qp->sq.lock);
- spin_lock(&qp->rq.lock);
- cur_state = qp->state;
- spin_unlock(&qp->rq.lock);
- spin_unlock_irq(&qp->sq.lock);
- }
-
- new_state = attr_mask & IB_QP_STATE ? attr->qp_state : cur_state;
-
- if (!ib_modify_qp_is_ok(cur_state, new_state, ibqp->qp_type,
- attr_mask, IB_LINK_LAYER_UNSPECIFIED)) {
- mthca_dbg(dev, "Bad QP transition (transport %d) "
- "%d->%d with attr 0x%08x\n",
- qp->transport, cur_state, new_state,
- attr_mask);
- goto out;
- }
-
- if ((attr_mask & IB_QP_PKEY_INDEX) &&
- attr->pkey_index >= dev->limits.pkey_table_len) {
- mthca_dbg(dev, "P_Key index (%u) too large. max is %d\n",
- attr->pkey_index, dev->limits.pkey_table_len-1);
- goto out;
- }
-
- if ((attr_mask & IB_QP_PORT) &&
- (attr->port_num == 0 || attr->port_num > dev->limits.num_ports)) {
- mthca_dbg(dev, "Port number (%u) is invalid\n", attr->port_num);
- goto out;
- }
-
- if (attr_mask & IB_QP_MAX_QP_RD_ATOMIC &&
- attr->max_rd_atomic > dev->limits.max_qp_init_rdma) {
- mthca_dbg(dev, "Max rdma_atomic as initiator %u too large (max is %d)\n",
- attr->max_rd_atomic, dev->limits.max_qp_init_rdma);
- goto out;
- }
-
- if (attr_mask & IB_QP_MAX_DEST_RD_ATOMIC &&
- attr->max_dest_rd_atomic > 1 << dev->qp_table.rdb_shift) {
- mthca_dbg(dev, "Max rdma_atomic as responder %u too large (max %d)\n",
- attr->max_dest_rd_atomic, 1 << dev->qp_table.rdb_shift);
- goto out;
- }
-
- if (cur_state == new_state && cur_state == IB_QPS_RESET) {
- err = 0;
- goto out;
- }
-
- err = __mthca_modify_qp(ibqp, attr, attr_mask, cur_state, new_state);
-
-out:
- mutex_unlock(&qp->mutex);
- return err;
-}
-
-static int mthca_max_data_size(struct mthca_dev *dev, struct mthca_qp *qp, int desc_sz)
-{
- /*
- * Calculate the maximum size of WQE s/g segments, excluding
- * the next segment and other non-data segments.
- */
- int max_data_size = desc_sz - sizeof (struct mthca_next_seg);
-
- switch (qp->transport) {
- case MLX:
- max_data_size -= 2 * sizeof (struct mthca_data_seg);
- break;
-
- case UD:
- if (mthca_is_memfree(dev))
- max_data_size -= sizeof (struct mthca_arbel_ud_seg);
- else
- max_data_size -= sizeof (struct mthca_tavor_ud_seg);
- break;
-
- default:
- max_data_size -= sizeof (struct mthca_raddr_seg);
- break;
- }
-
- return max_data_size;
-}
-
-static inline int mthca_max_inline_data(struct mthca_pd *pd, int max_data_size)
-{
- /* We don't support inline data for kernel QPs (yet). */
- return pd->ibpd.uobject ? max_data_size - MTHCA_INLINE_HEADER_SIZE : 0;
-}
-
-static void mthca_adjust_qp_caps(struct mthca_dev *dev,
- struct mthca_pd *pd,
- struct mthca_qp *qp)
-{
- int max_data_size = mthca_max_data_size(dev, qp,
- min(dev->limits.max_desc_sz,
- 1 << qp->sq.wqe_shift));
-
- qp->max_inline_data = mthca_max_inline_data(pd, max_data_size);
-
- qp->sq.max_gs = min_t(int, dev->limits.max_sg,
- max_data_size / sizeof (struct mthca_data_seg));
- qp->rq.max_gs = min_t(int, dev->limits.max_sg,
- (min(dev->limits.max_desc_sz, 1 << qp->rq.wqe_shift) -
- sizeof (struct mthca_next_seg)) /
- sizeof (struct mthca_data_seg));
-}
-
-/*
- * Allocate and register buffer for WQEs. qp->rq.max, sq.max,
- * rq.max_gs and sq.max_gs must all be assigned.
- * mthca_alloc_wqe_buf will calculate rq.wqe_shift and
- * sq.wqe_shift (as well as send_wqe_offset, is_direct, and
- * queue)
- */
-static int mthca_alloc_wqe_buf(struct mthca_dev *dev,
- struct mthca_pd *pd,
- struct mthca_qp *qp)
-{
- int size;
- int err = -ENOMEM;
-
- size = sizeof (struct mthca_next_seg) +
- qp->rq.max_gs * sizeof (struct mthca_data_seg);
-
- if (size > dev->limits.max_desc_sz)
- return -EINVAL;
-
- for (qp->rq.wqe_shift = 6; 1 << qp->rq.wqe_shift < size;
- qp->rq.wqe_shift++)
- ; /* nothing */
-
- size = qp->sq.max_gs * sizeof (struct mthca_data_seg);
- switch (qp->transport) {
- case MLX:
- size += 2 * sizeof (struct mthca_data_seg);
- break;
-
- case UD:
- size += mthca_is_memfree(dev) ?
- sizeof (struct mthca_arbel_ud_seg) :
- sizeof (struct mthca_tavor_ud_seg);
- break;
-
- case UC:
- size += sizeof (struct mthca_raddr_seg);
- break;
-
- case RC:
- size += sizeof (struct mthca_raddr_seg);
- /*
- * An atomic op will require an atomic segment, a
- * remote address segment and one scatter entry.
- */
- size = max_t(int, size,
- sizeof (struct mthca_atomic_seg) +
- sizeof (struct mthca_raddr_seg) +
- sizeof (struct mthca_data_seg));
- break;
-
- default:
- break;
- }
-
- /* Make sure that we have enough space for a bind request */
- size = max_t(int, size, sizeof (struct mthca_bind_seg));
-
- size += sizeof (struct mthca_next_seg);
-
- if (size > dev->limits.max_desc_sz)
- return -EINVAL;
-
- for (qp->sq.wqe_shift = 6; 1 << qp->sq.wqe_shift < size;
- qp->sq.wqe_shift++)
- ; /* nothing */
-
- qp->send_wqe_offset = ALIGN(qp->rq.max << qp->rq.wqe_shift,
- 1 << qp->sq.wqe_shift);
-
- /*
- * If this is a userspace QP, we don't actually have to
- * allocate anything. All we need is to calculate the WQE
- * sizes and the send_wqe_offset, so we're done now.
- */
- if (pd->ibpd.uobject)
- return 0;
-
- size = PAGE_ALIGN(qp->send_wqe_offset +
- (qp->sq.max << qp->sq.wqe_shift));
-
- qp->wrid = kmalloc((qp->rq.max + qp->sq.max) * sizeof (u64),
- GFP_KERNEL);
- if (!qp->wrid)
- goto err_out;
-
- err = mthca_buf_alloc(dev, size, MTHCA_MAX_DIRECT_QP_SIZE,
- &qp->queue, &qp->is_direct, pd, 0, &qp->mr);
- if (err)
- goto err_out;
-
- return 0;
-
-err_out:
- kfree(qp->wrid);
- return err;
-}
-
-static void mthca_free_wqe_buf(struct mthca_dev *dev,
- struct mthca_qp *qp)
-{
- mthca_buf_free(dev, PAGE_ALIGN(qp->send_wqe_offset +
- (qp->sq.max << qp->sq.wqe_shift)),
- &qp->queue, qp->is_direct, &qp->mr);
- kfree(qp->wrid);
-}
-
-static int mthca_map_memfree(struct mthca_dev *dev,
- struct mthca_qp *qp)
-{
- int ret;
-
- if (mthca_is_memfree(dev)) {
- ret = mthca_table_get(dev, dev->qp_table.qp_table, qp->qpn);
- if (ret)
- return ret;
-
- ret = mthca_table_get(dev, dev->qp_table.eqp_table, qp->qpn);
- if (ret)
- goto err_qpc;
-
- ret = mthca_table_get(dev, dev->qp_table.rdb_table,
- qp->qpn << dev->qp_table.rdb_shift);
- if (ret)
- goto err_eqpc;
-
- }
-
- return 0;
-
-err_eqpc:
- mthca_table_put(dev, dev->qp_table.eqp_table, qp->qpn);
-
-err_qpc:
- mthca_table_put(dev, dev->qp_table.qp_table, qp->qpn);
-
- return ret;
-}
-
-static void mthca_unmap_memfree(struct mthca_dev *dev,
- struct mthca_qp *qp)
-{
- mthca_table_put(dev, dev->qp_table.rdb_table,
- qp->qpn << dev->qp_table.rdb_shift);
- mthca_table_put(dev, dev->qp_table.eqp_table, qp->qpn);
- mthca_table_put(dev, dev->qp_table.qp_table, qp->qpn);
-}
-
-static int mthca_alloc_memfree(struct mthca_dev *dev,
- struct mthca_qp *qp)
-{
- if (mthca_is_memfree(dev)) {
- qp->rq.db_index = mthca_alloc_db(dev, MTHCA_DB_TYPE_RQ,
- qp->qpn, &qp->rq.db);
- if (qp->rq.db_index < 0)
- return -ENOMEM;
-
- qp->sq.db_index = mthca_alloc_db(dev, MTHCA_DB_TYPE_SQ,
- qp->qpn, &qp->sq.db);
- if (qp->sq.db_index < 0) {
- mthca_free_db(dev, MTHCA_DB_TYPE_RQ, qp->rq.db_index);
- return -ENOMEM;
- }
- }
-
- return 0;
-}
-
-static void mthca_free_memfree(struct mthca_dev *dev,
- struct mthca_qp *qp)
-{
- if (mthca_is_memfree(dev)) {
- mthca_free_db(dev, MTHCA_DB_TYPE_SQ, qp->sq.db_index);
- mthca_free_db(dev, MTHCA_DB_TYPE_RQ, qp->rq.db_index);
- }
-}
-
-static int mthca_alloc_qp_common(struct mthca_dev *dev,
- struct mthca_pd *pd,
- struct mthca_cq *send_cq,
- struct mthca_cq *recv_cq,
- enum ib_sig_type send_policy,
- struct mthca_qp *qp)
-{
- int ret;
- int i;
- struct mthca_next_seg *next;
-
- qp->refcount = 1;
- init_waitqueue_head(&qp->wait);
- mutex_init(&qp->mutex);
- qp->state = IB_QPS_RESET;
- qp->atomic_rd_en = 0;
- qp->resp_depth = 0;
- qp->sq_policy = send_policy;
- mthca_wq_reset(&qp->sq);
- mthca_wq_reset(&qp->rq);
-
- spin_lock_init(&qp->sq.lock);
- spin_lock_init(&qp->rq.lock);
-
- ret = mthca_map_memfree(dev, qp);
- if (ret)
- return ret;
-
- ret = mthca_alloc_wqe_buf(dev, pd, qp);
- if (ret) {
- mthca_unmap_memfree(dev, qp);
- return ret;
- }
-
- mthca_adjust_qp_caps(dev, pd, qp);
-
- /*
- * If this is a userspace QP, we're done now. The doorbells
- * will be allocated and buffers will be initialized in
- * userspace.
- */
- if (pd->ibpd.uobject)
- return 0;
-
- ret = mthca_alloc_memfree(dev, qp);
- if (ret) {
- mthca_free_wqe_buf(dev, qp);
- mthca_unmap_memfree(dev, qp);
- return ret;
- }
-
- if (mthca_is_memfree(dev)) {
- struct mthca_data_seg *scatter;
- int size = (sizeof (struct mthca_next_seg) +
- qp->rq.max_gs * sizeof (struct mthca_data_seg)) / 16;
-
- for (i = 0; i < qp->rq.max; ++i) {
- next = get_recv_wqe(qp, i);
- next->nda_op = cpu_to_be32(((i + 1) & (qp->rq.max - 1)) <<
- qp->rq.wqe_shift);
- next->ee_nds = cpu_to_be32(size);
-
- for (scatter = (void *) (next + 1);
- (void *) scatter < (void *) next + (1 << qp->rq.wqe_shift);
- ++scatter)
- scatter->lkey = cpu_to_be32(MTHCA_INVAL_LKEY);
- }
-
- for (i = 0; i < qp->sq.max; ++i) {
- next = get_send_wqe(qp, i);
- next->nda_op = cpu_to_be32((((i + 1) & (qp->sq.max - 1)) <<
- qp->sq.wqe_shift) +
- qp->send_wqe_offset);
- }
- } else {
- for (i = 0; i < qp->rq.max; ++i) {
- next = get_recv_wqe(qp, i);
- next->nda_op = htonl((((i + 1) % qp->rq.max) <<
- qp->rq.wqe_shift) | 1);
- }
-
- }
-
- qp->sq.last = get_send_wqe(qp, qp->sq.max - 1);
- qp->rq.last = get_recv_wqe(qp, qp->rq.max - 1);
-
- return 0;
-}
-
-static int mthca_set_qp_size(struct mthca_dev *dev, struct ib_qp_cap *cap,
- struct mthca_pd *pd, struct mthca_qp *qp)
-{
- int max_data_size = mthca_max_data_size(dev, qp, dev->limits.max_desc_sz);
- u32 max_inline_data;
-
- /* Sanity check QP size before proceeding */
- if (cap->max_send_wr > dev->limits.max_wqes ||
- cap->max_recv_wr > dev->limits.max_wqes ||
- cap->max_send_sge > dev->limits.max_sg ||
- cap->max_recv_sge > dev->limits.max_sg)
- return -EINVAL;
-
- if (pd->ibpd.uobject &&
- cap->max_inline_data > mthca_max_inline_data(pd, max_data_size))
- return -EINVAL;
-
- max_inline_data = pd->ibpd.uobject ? cap->max_inline_data : 0;
-
- /*
- * For MLX transport we need 2 extra send gather entries:
- * one for the header and one for the checksum at the end
- */
- if (qp->transport == MLX && cap->max_send_sge + 2 > dev->limits.max_sg)
- return -EINVAL;
-
- if (mthca_is_memfree(dev)) {
- qp->rq.max = cap->max_recv_wr ?
- roundup_pow_of_two(cap->max_recv_wr) : 0;
- qp->sq.max = cap->max_send_wr ?
- roundup_pow_of_two(cap->max_send_wr) : 0;
- } else {
- qp->rq.max = cap->max_recv_wr;
- qp->sq.max = cap->max_send_wr;
- }
-
- qp->rq.max_gs = cap->max_recv_sge;
- qp->sq.max_gs = max_t(int, cap->max_send_sge,
- ALIGN(max_inline_data + MTHCA_INLINE_HEADER_SIZE,
- MTHCA_INLINE_CHUNK_SIZE) /
- sizeof (struct mthca_data_seg));
-
- return 0;
-}
-
-int mthca_alloc_qp(struct mthca_dev *dev,
- struct mthca_pd *pd,
- struct mthca_cq *send_cq,
- struct mthca_cq *recv_cq,
- enum ib_qp_type type,
- enum ib_sig_type send_policy,
- struct ib_qp_cap *cap,
- struct mthca_qp *qp)
-{
- int err;
-
- switch (type) {
- case IB_QPT_RC: qp->transport = RC; break;
- case IB_QPT_UC: qp->transport = UC; break;
- case IB_QPT_UD: qp->transport = UD; break;
- default: return -EINVAL;
- }
-
- err = mthca_set_qp_size(dev, cap, pd, qp);
- if (err)
- return err;
-
- qp->qpn = mthca_alloc(&dev->qp_table.alloc);
- if (qp->qpn == -1)
- return -ENOMEM;
-
- /* initialize port to zero for error-catching. */
- qp->port = 0;
-
- err = mthca_alloc_qp_common(dev, pd, send_cq, recv_cq,
- send_policy, qp);
- if (err) {
- mthca_free(&dev->qp_table.alloc, qp->qpn);
- return err;
- }
-
- spin_lock_irq(&dev->qp_table.lock);
- mthca_array_set(&dev->qp_table.qp,
- qp->qpn & (dev->limits.num_qps - 1), qp);
- spin_unlock_irq(&dev->qp_table.lock);
-
- return 0;
-}
-
-static void mthca_lock_cqs(struct mthca_cq *send_cq, struct mthca_cq *recv_cq)
-{
- if (send_cq == recv_cq)
- spin_lock_irq(&send_cq->lock);
- else if (send_cq->cqn < recv_cq->cqn) {
- spin_lock_irq(&send_cq->lock);
- spin_lock_nested(&recv_cq->lock, SINGLE_DEPTH_NESTING);
- } else {
- spin_lock_irq(&recv_cq->lock);
- spin_lock_nested(&send_cq->lock, SINGLE_DEPTH_NESTING);
- }
-}
-
-static void mthca_unlock_cqs(struct mthca_cq *send_cq, struct mthca_cq *recv_cq)
-{
- if (send_cq == recv_cq)
- spin_unlock_irq(&send_cq->lock);
- else if (send_cq->cqn < recv_cq->cqn) {
- spin_unlock(&recv_cq->lock);
- spin_unlock_irq(&send_cq->lock);
- } else {
- spin_unlock(&send_cq->lock);
- spin_unlock_irq(&recv_cq->lock);
- }
-}
-
-int mthca_alloc_sqp(struct mthca_dev *dev,
- struct mthca_pd *pd,
- struct mthca_cq *send_cq,
- struct mthca_cq *recv_cq,
- enum ib_sig_type send_policy,
- struct ib_qp_cap *cap,
- int qpn,
- int port,
- struct mthca_sqp *sqp)
-{
- u32 mqpn = qpn * 2 + dev->qp_table.sqp_start + port - 1;
- int err;
-
- sqp->qp.transport = MLX;
- err = mthca_set_qp_size(dev, cap, pd, &sqp->qp);
- if (err)
- return err;
-
- sqp->header_buf_size = sqp->qp.sq.max * MTHCA_UD_HEADER_SIZE;
- sqp->header_buf = dma_alloc_coherent(&dev->pdev->dev, sqp->header_buf_size,
- &sqp->header_dma, GFP_KERNEL);
- if (!sqp->header_buf)
- return -ENOMEM;
-
- spin_lock_irq(&dev->qp_table.lock);
- if (mthca_array_get(&dev->qp_table.qp, mqpn))
- err = -EBUSY;
- else
- mthca_array_set(&dev->qp_table.qp, mqpn, sqp);
- spin_unlock_irq(&dev->qp_table.lock);
-
- if (err)
- goto err_out;
-
- sqp->qp.port = port;
- sqp->qp.qpn = mqpn;
- sqp->qp.transport = MLX;
-
- err = mthca_alloc_qp_common(dev, pd, send_cq, recv_cq,
- send_policy, &sqp->qp);
- if (err)
- goto err_out_free;
-
- atomic_inc(&pd->sqp_count);
-
- return 0;
-
- err_out_free:
- /*
- * Lock CQs here, so that CQ polling code can do QP lookup
- * without taking a lock.
- */
- mthca_lock_cqs(send_cq, recv_cq);
-
- spin_lock(&dev->qp_table.lock);
- mthca_array_clear(&dev->qp_table.qp, mqpn);
- spin_unlock(&dev->qp_table.lock);
-
- mthca_unlock_cqs(send_cq, recv_cq);
-
- err_out:
- dma_free_coherent(&dev->pdev->dev, sqp->header_buf_size,
- sqp->header_buf, sqp->header_dma);
-
- return err;
-}
-
-static inline int get_qp_refcount(struct mthca_dev *dev, struct mthca_qp *qp)
-{
- int c;
-
- spin_lock_irq(&dev->qp_table.lock);
- c = qp->refcount;
- spin_unlock_irq(&dev->qp_table.lock);
-
- return c;
-}
-
-void mthca_free_qp(struct mthca_dev *dev,
- struct mthca_qp *qp)
-{
- u8 status;
- struct mthca_cq *send_cq;
- struct mthca_cq *recv_cq;
-
- send_cq = to_mcq(qp->ibqp.send_cq);
- recv_cq = to_mcq(qp->ibqp.recv_cq);
-
- /*
- * Lock CQs here, so that CQ polling code can do QP lookup
- * without taking a lock.
- */
- mthca_lock_cqs(send_cq, recv_cq);
-
- spin_lock(&dev->qp_table.lock);
- mthca_array_clear(&dev->qp_table.qp,
- qp->qpn & (dev->limits.num_qps - 1));
- --qp->refcount;
- spin_unlock(&dev->qp_table.lock);
-
- mthca_unlock_cqs(send_cq, recv_cq);
-
- wait_event(qp->wait, !get_qp_refcount(dev, qp));
-
- if (qp->state != IB_QPS_RESET)
- mthca_MODIFY_QP(dev, qp->state, IB_QPS_RESET, qp->qpn, 0,
- NULL, 0, &status);
-
- /*
- * If this is a userspace QP, the buffers, MR, CQs and so on
- * will be cleaned up in userspace, so all we have to do is
- * unref the mem-free tables and free the QPN in our table.
- */
- if (!qp->ibqp.uobject) {
- mthca_cq_clean(dev, recv_cq, qp->qpn,
- qp->ibqp.srq ? to_msrq(qp->ibqp.srq) : NULL);
- if (send_cq != recv_cq)
- mthca_cq_clean(dev, send_cq, qp->qpn, NULL);
-
- mthca_free_memfree(dev, qp);
- mthca_free_wqe_buf(dev, qp);
- }
-
- mthca_unmap_memfree(dev, qp);
-
- if (is_sqp(dev, qp)) {
- atomic_dec(&(to_mpd(qp->ibqp.pd)->sqp_count));
- dma_free_coherent(&dev->pdev->dev,
- to_msqp(qp)->header_buf_size,
- to_msqp(qp)->header_buf,
- to_msqp(qp)->header_dma);
- } else
- mthca_free(&dev->qp_table.alloc, qp->qpn);
-}
-
-/* Create UD header for an MLX send and build a data segment for it */
-static int build_mlx_header(struct mthca_dev *dev, struct mthca_sqp *sqp,
- int ind, struct ib_send_wr *wr,
- struct mthca_mlx_seg *mlx,
- struct mthca_data_seg *data)
-{
- int header_size;
- int err;
- u16 pkey;
-
- ib_ud_header_init(256, /* assume a MAD */
- 1, 0, 0,
- mthca_ah_grh_present(to_mah(wr->wr.ud.ah)),
- 0,
- &sqp->ud_header);
-
- err = mthca_read_ah(dev, to_mah(wr->wr.ud.ah), &sqp->ud_header);
- if (err)
- return err;
- mlx->flags &= ~cpu_to_be32(MTHCA_NEXT_SOLICIT | 1);
- mlx->flags |= cpu_to_be32((!sqp->qp.ibqp.qp_num ? MTHCA_MLX_VL15 : 0) |
- (sqp->ud_header.lrh.destination_lid ==
- IB_LID_PERMISSIVE ? MTHCA_MLX_SLR : 0) |
- (sqp->ud_header.lrh.service_level << 8));
- mlx->rlid = sqp->ud_header.lrh.destination_lid;
- mlx->vcrc = 0;
-
- switch (wr->opcode) {
- case IB_WR_SEND:
- sqp->ud_header.bth.opcode = IB_OPCODE_UD_SEND_ONLY;
- sqp->ud_header.immediate_present = 0;
- break;
- case IB_WR_SEND_WITH_IMM:
- sqp->ud_header.bth.opcode = IB_OPCODE_UD_SEND_ONLY_WITH_IMMEDIATE;
- sqp->ud_header.immediate_present = 1;
- sqp->ud_header.immediate_data = wr->ex.imm_data;
- break;
- default:
- return -EINVAL;
- }
-
- sqp->ud_header.lrh.virtual_lane = !sqp->qp.ibqp.qp_num ? 15 : 0;
- if (sqp->ud_header.lrh.destination_lid == IB_LID_PERMISSIVE)
- sqp->ud_header.lrh.source_lid = IB_LID_PERMISSIVE;
- sqp->ud_header.bth.solicited_event = !!(wr->send_flags & IB_SEND_SOLICITED);
- if (!sqp->qp.ibqp.qp_num)
- ib_get_cached_pkey(&dev->ib_dev, sqp->qp.port,
- sqp->pkey_index, &pkey);
- else
- ib_get_cached_pkey(&dev->ib_dev, sqp->qp.port,
- wr->wr.ud.pkey_index, &pkey);
- sqp->ud_header.bth.pkey = cpu_to_be16(pkey);
- sqp->ud_header.bth.destination_qpn = cpu_to_be32(wr->wr.ud.remote_qpn);
- sqp->ud_header.bth.psn = cpu_to_be32((sqp->send_psn++) & ((1 << 24) - 1));
- sqp->ud_header.deth.qkey = cpu_to_be32(wr->wr.ud.remote_qkey & 0x80000000 ?
- sqp->qkey : wr->wr.ud.remote_qkey);
- sqp->ud_header.deth.source_qpn = cpu_to_be32(sqp->qp.ibqp.qp_num);
-
- header_size = ib_ud_header_pack(&sqp->ud_header,
- sqp->header_buf +
- ind * MTHCA_UD_HEADER_SIZE);
-
- data->byte_count = cpu_to_be32(header_size);
- data->lkey = cpu_to_be32(to_mpd(sqp->qp.ibqp.pd)->ntmr.ibmr.lkey);
- data->addr = cpu_to_be64(sqp->header_dma +
- ind * MTHCA_UD_HEADER_SIZE);
-
- return 0;
-}
-
-static inline int mthca_wq_overflow(struct mthca_wq *wq, int nreq,
- struct ib_cq *ib_cq)
-{
- unsigned cur;
- struct mthca_cq *cq;
-
- cur = wq->head - wq->tail;
- if (likely(cur + nreq < wq->max))
- return 0;
-
- cq = to_mcq(ib_cq);
- spin_lock(&cq->lock);
- cur = wq->head - wq->tail;
- spin_unlock(&cq->lock);
-
- return cur + nreq >= wq->max;
-}
-
-static __always_inline void set_raddr_seg(struct mthca_raddr_seg *rseg,
- u64 remote_addr, u32 rkey)
-{
- rseg->raddr = cpu_to_be64(remote_addr);
- rseg->rkey = cpu_to_be32(rkey);
- rseg->reserved = 0;
-}
-
-static __always_inline void set_atomic_seg(struct mthca_atomic_seg *aseg,
- struct ib_send_wr *wr)
-{
- if (wr->opcode == IB_WR_ATOMIC_CMP_AND_SWP) {
- aseg->swap_add = cpu_to_be64(wr->wr.atomic.swap);
- aseg->compare = cpu_to_be64(wr->wr.atomic.compare_add);
- } else {
- aseg->swap_add = cpu_to_be64(wr->wr.atomic.compare_add);
- aseg->compare = 0;
- }
-
-}
-
-static void set_tavor_ud_seg(struct mthca_tavor_ud_seg *useg,
- struct ib_send_wr *wr)
-{
- useg->lkey = cpu_to_be32(to_mah(wr->wr.ud.ah)->key);
- useg->av_addr = cpu_to_be64(to_mah(wr->wr.ud.ah)->avdma);
- useg->dqpn = cpu_to_be32(wr->wr.ud.remote_qpn);
- useg->qkey = cpu_to_be32(wr->wr.ud.remote_qkey);
-
-}
-
-static void set_arbel_ud_seg(struct mthca_arbel_ud_seg *useg,
- struct ib_send_wr *wr)
-{
- memcpy(useg->av, to_mah(wr->wr.ud.ah)->av, MTHCA_AV_SIZE);
- useg->dqpn = cpu_to_be32(wr->wr.ud.remote_qpn);
- useg->qkey = cpu_to_be32(wr->wr.ud.remote_qkey);
-}
-
-int mthca_tavor_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr,
- struct ib_send_wr **bad_wr)
-{
- struct mthca_dev *dev = to_mdev(ibqp->device);
- struct mthca_qp *qp = to_mqp(ibqp);
- void *wqe;
- void *prev_wqe;
- unsigned long flags;
- int err = 0;
- int nreq;
- int i;
- int size;
- /*
- * f0 and size0 are only used if nreq != 0, and they will
- * always be initialized the first time through the main loop
- * before nreq is incremented. So nreq cannot become non-zero
- * without initializing f0 and size0, and they are in fact
- * never used uninitialized.
- */
- int uninitialized_var(size0);
- u32 uninitialized_var(f0);
- int ind;
- u8 op0 = 0;
-
- spin_lock_irqsave(&qp->sq.lock, flags);
-
- /* XXX check that state is OK to post send */
-
- ind = qp->sq.next_ind;
-
- for (nreq = 0; wr; ++nreq, wr = wr->next) {
- if (mthca_wq_overflow(&qp->sq, nreq, qp->ibqp.send_cq)) {
- mthca_err(dev, "SQ %06x full (%u head, %u tail,"
- " %d max, %d nreq)\n", qp->qpn,
- qp->sq.head, qp->sq.tail,
- qp->sq.max, nreq);
- err = -ENOMEM;
- *bad_wr = wr;
- goto out;
- }
-
- wqe = get_send_wqe(qp, ind);
- prev_wqe = qp->sq.last;
- qp->sq.last = wqe;
-
- ((struct mthca_next_seg *) wqe)->nda_op = 0;
- ((struct mthca_next_seg *) wqe)->ee_nds = 0;
- ((struct mthca_next_seg *) wqe)->flags =
- ((wr->send_flags & IB_SEND_SIGNALED) ?
- cpu_to_be32(MTHCA_NEXT_CQ_UPDATE) : 0) |
- ((wr->send_flags & IB_SEND_SOLICITED) ?
- cpu_to_be32(MTHCA_NEXT_SOLICIT) : 0) |
- cpu_to_be32(1);
- if (wr->opcode == IB_WR_SEND_WITH_IMM ||
- wr->opcode == IB_WR_RDMA_WRITE_WITH_IMM)
- ((struct mthca_next_seg *) wqe)->imm = wr->ex.imm_data;
-
- wqe += sizeof (struct mthca_next_seg);
- size = sizeof (struct mthca_next_seg) / 16;
-
- switch (qp->transport) {
- case RC:
- switch (wr->opcode) {
- case IB_WR_ATOMIC_CMP_AND_SWP:
- case IB_WR_ATOMIC_FETCH_AND_ADD:
- set_raddr_seg(wqe, wr->wr.atomic.remote_addr,
- wr->wr.atomic.rkey);
- wqe += sizeof (struct mthca_raddr_seg);
-
- set_atomic_seg(wqe, wr);
- wqe += sizeof (struct mthca_atomic_seg);
- size += (sizeof (struct mthca_raddr_seg) +
- sizeof (struct mthca_atomic_seg)) / 16;
- break;
-
- case IB_WR_RDMA_WRITE:
- case IB_WR_RDMA_WRITE_WITH_IMM:
- case IB_WR_RDMA_READ:
- set_raddr_seg(wqe, wr->wr.rdma.remote_addr,
- wr->wr.rdma.rkey);
- wqe += sizeof (struct mthca_raddr_seg);
- size += sizeof (struct mthca_raddr_seg) / 16;
- break;
-
- default:
- /* No extra segments required for sends */
- break;
- }
-
- break;
-
- case UC:
- switch (wr->opcode) {
- case IB_WR_RDMA_WRITE:
- case IB_WR_RDMA_WRITE_WITH_IMM:
- set_raddr_seg(wqe, wr->wr.rdma.remote_addr,
- wr->wr.rdma.rkey);
- wqe += sizeof (struct mthca_raddr_seg);
- size += sizeof (struct mthca_raddr_seg) / 16;
- break;
-
- default:
- /* No extra segments required for sends */
- break;
- }
-
- break;
-
- case UD:
- set_tavor_ud_seg(wqe, wr);
- wqe += sizeof (struct mthca_tavor_ud_seg);
- size += sizeof (struct mthca_tavor_ud_seg) / 16;
- break;
-
- case MLX:
- err = build_mlx_header(dev, to_msqp(qp), ind, wr,
- wqe - sizeof (struct mthca_next_seg),
- wqe);
- if (err) {
- *bad_wr = wr;
- goto out;
- }
- wqe += sizeof (struct mthca_data_seg);
- size += sizeof (struct mthca_data_seg) / 16;
- break;
- }
-
- if (wr->num_sge > qp->sq.max_gs) {
- mthca_err(dev, "too many gathers\n");
- err = -EINVAL;
- *bad_wr = wr;
- goto out;
- }
-
- for (i = 0; i < wr->num_sge; ++i) {
- mthca_set_data_seg(wqe, wr->sg_list + i);
- wqe += sizeof (struct mthca_data_seg);
- size += sizeof (struct mthca_data_seg) / 16;
- }
-
- /* Add one more inline data segment for ICRC */
- if (qp->transport == MLX) {
- ((struct mthca_data_seg *) wqe)->byte_count =
- cpu_to_be32((1U << 31) | 4);
- ((u32 *) wqe)[1] = 0;
- wqe += sizeof (struct mthca_data_seg);
- size += sizeof (struct mthca_data_seg) / 16;
- }
-
- qp->wrid[ind] = wr->wr_id;
-
- if (wr->opcode < 0 || wr->opcode >= ARRAY_SIZE(mthca_opcode)) {
- mthca_err(dev, "opcode invalid\n");
- err = -EINVAL;
- *bad_wr = wr;
- goto out;
- }
-
- ((struct mthca_next_seg *) prev_wqe)->nda_op =
- cpu_to_be32(((ind << qp->sq.wqe_shift) +
- qp->send_wqe_offset) |
- mthca_opcode[wr->opcode]);
- wmb();
- ((struct mthca_next_seg *) prev_wqe)->ee_nds =
- cpu_to_be32((nreq ? 0 : MTHCA_NEXT_DBD) | size |
- ((wr->send_flags & IB_SEND_FENCE) ?
- MTHCA_NEXT_FENCE : 0));
-
- if (!nreq) {
- size0 = size;
- op0 = mthca_opcode[wr->opcode];
- f0 = wr->send_flags & IB_SEND_FENCE ?
- MTHCA_SEND_DOORBELL_FENCE : 0;
- }
-
- ++ind;
- if (unlikely(ind >= qp->sq.max))
- ind -= qp->sq.max;
- }
-
-out:
- if (likely(nreq)) {
- wmb();
-
- mthca_write64(((qp->sq.next_ind << qp->sq.wqe_shift) +
- qp->send_wqe_offset) | f0 | op0,
- (qp->qpn << 8) | size0,
- dev->kar + MTHCA_SEND_DOORBELL,
- MTHCA_GET_DOORBELL_LOCK(&dev->doorbell_lock));
- /*
- * Make sure doorbells don't leak out of SQ spinlock
- * and reach the HCA out of order:
- */
- mmiowb();
- }
-
- qp->sq.next_ind = ind;
- qp->sq.head += nreq;
-
- spin_unlock_irqrestore(&qp->sq.lock, flags);
- return err;
-}
-
-int mthca_tavor_post_receive(struct ib_qp *ibqp, struct ib_recv_wr *wr,
- struct ib_recv_wr **bad_wr)
-{
- struct mthca_dev *dev = to_mdev(ibqp->device);
- struct mthca_qp *qp = to_mqp(ibqp);
- unsigned long flags;
- int err = 0;
- int nreq;
- int i;
- int size;
- /*
- * size0 is only used if nreq != 0, and it will always be
- * initialized the first time through the main loop before
- * nreq is incremented. So nreq cannot become non-zero
- * without initializing size0, and it is in fact never used
- * uninitialized.
- */
- int uninitialized_var(size0);
- int ind;
- void *wqe;
- void *prev_wqe;
-
- spin_lock_irqsave(&qp->rq.lock, flags);
-
- /* XXX check that state is OK to post receive */
-
- ind = qp->rq.next_ind;
-
- for (nreq = 0; wr; wr = wr->next) {
- if (mthca_wq_overflow(&qp->rq, nreq, qp->ibqp.recv_cq)) {
- mthca_err(dev, "RQ %06x full (%u head, %u tail,"
- " %d max, %d nreq)\n", qp->qpn,
- qp->rq.head, qp->rq.tail,
- qp->rq.max, nreq);
- err = -ENOMEM;
- *bad_wr = wr;
- goto out;
- }
-
- wqe = get_recv_wqe(qp, ind);
- prev_wqe = qp->rq.last;
- qp->rq.last = wqe;
-
- ((struct mthca_next_seg *) wqe)->ee_nds =
- cpu_to_be32(MTHCA_NEXT_DBD);
- ((struct mthca_next_seg *) wqe)->flags = 0;
-
- wqe += sizeof (struct mthca_next_seg);
- size = sizeof (struct mthca_next_seg) / 16;
-
- if (unlikely(wr->num_sge > qp->rq.max_gs)) {
- err = -EINVAL;
- *bad_wr = wr;
- goto out;
- }
-
- for (i = 0; i < wr->num_sge; ++i) {
- mthca_set_data_seg(wqe, wr->sg_list + i);
- wqe += sizeof (struct mthca_data_seg);
- size += sizeof (struct mthca_data_seg) / 16;
- }
-
- qp->wrid[ind + qp->sq.max] = wr->wr_id;
-
- ((struct mthca_next_seg *) prev_wqe)->ee_nds =
- cpu_to_be32(MTHCA_NEXT_DBD | size);
-
- if (!nreq)
- size0 = size;
-
- ++ind;
- if (unlikely(ind >= qp->rq.max))
- ind -= qp->rq.max;
-
- ++nreq;
- if (unlikely(nreq == MTHCA_TAVOR_MAX_WQES_PER_RECV_DB)) {
- nreq = 0;
-
- wmb();
-
- mthca_write64((qp->rq.next_ind << qp->rq.wqe_shift) | size0,
- qp->qpn << 8, dev->kar + MTHCA_RECEIVE_DOORBELL,
- MTHCA_GET_DOORBELL_LOCK(&dev->doorbell_lock));
-
- qp->rq.next_ind = ind;
- qp->rq.head += MTHCA_TAVOR_MAX_WQES_PER_RECV_DB;
- }
- }
-
-out:
- if (likely(nreq)) {
- wmb();
-
- mthca_write64((qp->rq.next_ind << qp->rq.wqe_shift) | size0,
- qp->qpn << 8 | nreq, dev->kar + MTHCA_RECEIVE_DOORBELL,
- MTHCA_GET_DOORBELL_LOCK(&dev->doorbell_lock));
- }
-
- qp->rq.next_ind = ind;
- qp->rq.head += nreq;
-
- /*
- * Make sure doorbells don't leak out of RQ spinlock and reach
- * the HCA out of order:
- */
- mmiowb();
-
- spin_unlock_irqrestore(&qp->rq.lock, flags);
- return err;
-}
-
-int mthca_arbel_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr,
- struct ib_send_wr **bad_wr)
-{
- struct mthca_dev *dev = to_mdev(ibqp->device);
- struct mthca_qp *qp = to_mqp(ibqp);
- u32 dbhi;
- void *wqe;
- void *prev_wqe;
- unsigned long flags;
- int err = 0;
- int nreq;
- int i;
- int size;
- /*
- * f0 and size0 are only used if nreq != 0, and they will
- * always be initialized the first time through the main loop
- * before nreq is incremented. So nreq cannot become non-zero
- * without initializing f0 and size0, and they are in fact
- * never used uninitialized.
- */
- int uninitialized_var(size0);
- u32 uninitialized_var(f0);
- int ind;
- u8 op0 = 0;
-
- spin_lock_irqsave(&qp->sq.lock, flags);
-
- /* XXX check that state is OK to post send */
-
- ind = qp->sq.head & (qp->sq.max - 1);
-
- for (nreq = 0; wr; ++nreq, wr = wr->next) {
- if (unlikely(nreq == MTHCA_ARBEL_MAX_WQES_PER_SEND_DB)) {
- nreq = 0;
-
- dbhi = (MTHCA_ARBEL_MAX_WQES_PER_SEND_DB << 24) |
- ((qp->sq.head & 0xffff) << 8) | f0 | op0;
-
- qp->sq.head += MTHCA_ARBEL_MAX_WQES_PER_SEND_DB;
-
- /*
- * Make sure that descriptors are written before
- * doorbell record.
- */
- wmb();
- *qp->sq.db = cpu_to_be32(qp->sq.head & 0xffff);
-
- /*
- * Make sure doorbell record is written before we
- * write MMIO send doorbell.
- */
- wmb();
-
- mthca_write64(dbhi, (qp->qpn << 8) | size0,
- dev->kar + MTHCA_SEND_DOORBELL,
- MTHCA_GET_DOORBELL_LOCK(&dev->doorbell_lock));
- }
-
- if (mthca_wq_overflow(&qp->sq, nreq, qp->ibqp.send_cq)) {
- mthca_err(dev, "SQ %06x full (%u head, %u tail,"
- " %d max, %d nreq)\n", qp->qpn,
- qp->sq.head, qp->sq.tail,
- qp->sq.max, nreq);
- err = -ENOMEM;
- *bad_wr = wr;
- goto out;
- }
-
- wqe = get_send_wqe(qp, ind);
- prev_wqe = qp->sq.last;
- qp->sq.last = wqe;
-
- ((struct mthca_next_seg *) wqe)->flags =
- ((wr->send_flags & IB_SEND_SIGNALED) ?
- cpu_to_be32(MTHCA_NEXT_CQ_UPDATE) : 0) |
- ((wr->send_flags & IB_SEND_SOLICITED) ?
- cpu_to_be32(MTHCA_NEXT_SOLICIT) : 0) |
- ((wr->send_flags & IB_SEND_IP_CSUM) ?
- cpu_to_be32(MTHCA_NEXT_IP_CSUM | MTHCA_NEXT_TCP_UDP_CSUM) : 0) |
- cpu_to_be32(1);
- if (wr->opcode == IB_WR_SEND_WITH_IMM ||
- wr->opcode == IB_WR_RDMA_WRITE_WITH_IMM)
- ((struct mthca_next_seg *) wqe)->imm = wr->ex.imm_data;
-
- wqe += sizeof (struct mthca_next_seg);
- size = sizeof (struct mthca_next_seg) / 16;
-
- switch (qp->transport) {
- case RC:
- switch (wr->opcode) {
- case IB_WR_ATOMIC_CMP_AND_SWP:
- case IB_WR_ATOMIC_FETCH_AND_ADD:
- set_raddr_seg(wqe, wr->wr.atomic.remote_addr,
- wr->wr.atomic.rkey);
- wqe += sizeof (struct mthca_raddr_seg);
-
- set_atomic_seg(wqe, wr);
- wqe += sizeof (struct mthca_atomic_seg);
- size += (sizeof (struct mthca_raddr_seg) +
- sizeof (struct mthca_atomic_seg)) / 16;
- break;
-
- case IB_WR_RDMA_READ:
- case IB_WR_RDMA_WRITE:
- case IB_WR_RDMA_WRITE_WITH_IMM:
- set_raddr_seg(wqe, wr->wr.rdma.remote_addr,
- wr->wr.rdma.rkey);
- wqe += sizeof (struct mthca_raddr_seg);
- size += sizeof (struct mthca_raddr_seg) / 16;
- break;
-
- default:
- /* No extra segments required for sends */
- break;
- }
-
- break;
-
- case UC:
- switch (wr->opcode) {
- case IB_WR_RDMA_WRITE:
- case IB_WR_RDMA_WRITE_WITH_IMM:
- set_raddr_seg(wqe, wr->wr.rdma.remote_addr,
- wr->wr.rdma.rkey);
- wqe += sizeof (struct mthca_raddr_seg);
- size += sizeof (struct mthca_raddr_seg) / 16;
- break;
-
- default:
- /* No extra segments required for sends */
- break;
- }
-
- break;
-
- case UD:
- set_arbel_ud_seg(wqe, wr);
- wqe += sizeof (struct mthca_arbel_ud_seg);
- size += sizeof (struct mthca_arbel_ud_seg) / 16;
- break;
-
- case MLX:
- err = build_mlx_header(dev, to_msqp(qp), ind, wr,
- wqe - sizeof (struct mthca_next_seg),
- wqe);
- if (err) {
- *bad_wr = wr;
- goto out;
- }
- wqe += sizeof (struct mthca_data_seg);
- size += sizeof (struct mthca_data_seg) / 16;
- break;
- }
-
- if (wr->num_sge > qp->sq.max_gs) {
- mthca_err(dev, "too many gathers\n");
- err = -EINVAL;
- *bad_wr = wr;
- goto out;
- }
-
- for (i = 0; i < wr->num_sge; ++i) {
- mthca_set_data_seg(wqe, wr->sg_list + i);
- wqe += sizeof (struct mthca_data_seg);
- size += sizeof (struct mthca_data_seg) / 16;
- }
-
- /* Add one more inline data segment for ICRC */
- if (qp->transport == MLX) {
- ((struct mthca_data_seg *) wqe)->byte_count =
- cpu_to_be32((1U << 31) | 4);
- ((u32 *) wqe)[1] = 0;
- wqe += sizeof (struct mthca_data_seg);
- size += sizeof (struct mthca_data_seg) / 16;
- }
-
- qp->wrid[ind] = wr->wr_id;
-
- if (wr->opcode >= ARRAY_SIZE(mthca_opcode)) {
- mthca_err(dev, "opcode invalid\n");
- err = -EINVAL;
- *bad_wr = wr;
- goto out;
- }
-
- ((struct mthca_next_seg *) prev_wqe)->nda_op =
- cpu_to_be32(((ind << qp->sq.wqe_shift) +
- qp->send_wqe_offset) |
- mthca_opcode[wr->opcode]);
- wmb();
- ((struct mthca_next_seg *) prev_wqe)->ee_nds =
- cpu_to_be32(MTHCA_NEXT_DBD | size |
- ((wr->send_flags & IB_SEND_FENCE) ?
- MTHCA_NEXT_FENCE : 0));
-
- if (!nreq) {
- size0 = size;
- op0 = mthca_opcode[wr->opcode];
- f0 = wr->send_flags & IB_SEND_FENCE ?
- MTHCA_SEND_DOORBELL_FENCE : 0;
- }
-
- ++ind;
- if (unlikely(ind >= qp->sq.max))
- ind -= qp->sq.max;
- }
-
-out:
- if (likely(nreq)) {
- dbhi = (nreq << 24) | ((qp->sq.head & 0xffff) << 8) | f0 | op0;
-
- qp->sq.head += nreq;
-
- /*
- * Make sure that descriptors are written before
- * doorbell record.
- */
- wmb();
- *qp->sq.db = cpu_to_be32(qp->sq.head & 0xffff);
-
- /*
- * Make sure doorbell record is written before we
- * write MMIO send doorbell.
- */
- wmb();
-
- mthca_write64(dbhi, (qp->qpn << 8) | size0, dev->kar + MTHCA_SEND_DOORBELL,
- MTHCA_GET_DOORBELL_LOCK(&dev->doorbell_lock));
- }
-
- /*
- * Make sure doorbells don't leak out of SQ spinlock and reach
- * the HCA out of order:
- */
- mmiowb();
-
- spin_unlock_irqrestore(&qp->sq.lock, flags);
- return err;
-}
-
-int mthca_arbel_post_receive(struct ib_qp *ibqp, struct ib_recv_wr *wr,
- struct ib_recv_wr **bad_wr)
-{
- struct mthca_dev *dev = to_mdev(ibqp->device);
- struct mthca_qp *qp = to_mqp(ibqp);
- unsigned long flags;
- int err = 0;
- int nreq;
- int ind;
- int i;
- void *wqe;
-
- spin_lock_irqsave(&qp->rq.lock, flags);
-
- /* XXX check that state is OK to post receive */
-
- ind = qp->rq.head & (qp->rq.max - 1);
-
- for (nreq = 0; wr; ++nreq, wr = wr->next) {
- if (mthca_wq_overflow(&qp->rq, nreq, qp->ibqp.recv_cq)) {
- mthca_err(dev, "RQ %06x full (%u head, %u tail,"
- " %d max, %d nreq)\n", qp->qpn,
- qp->rq.head, qp->rq.tail,
- qp->rq.max, nreq);
- err = -ENOMEM;
- *bad_wr = wr;
- goto out;
- }
-
- wqe = get_recv_wqe(qp, ind);
-
- ((struct mthca_next_seg *) wqe)->flags = 0;
-
- wqe += sizeof (struct mthca_next_seg);
-
- if (unlikely(wr->num_sge > qp->rq.max_gs)) {
- err = -EINVAL;
- *bad_wr = wr;
- goto out;
- }
-
- for (i = 0; i < wr->num_sge; ++i) {
- mthca_set_data_seg(wqe, wr->sg_list + i);
- wqe += sizeof (struct mthca_data_seg);
- }
-
- if (i < qp->rq.max_gs)
- mthca_set_data_seg_inval(wqe);
-
- qp->wrid[ind + qp->sq.max] = wr->wr_id;
-
- ++ind;
- if (unlikely(ind >= qp->rq.max))
- ind -= qp->rq.max;
- }
-out:
- if (likely(nreq)) {
- qp->rq.head += nreq;
-
- /*
- * Make sure that descriptors are written before
- * doorbell record.
- */
- wmb();
- *qp->rq.db = cpu_to_be32(qp->rq.head & 0xffff);
- }
-
- spin_unlock_irqrestore(&qp->rq.lock, flags);
- return err;
-}
-
-void mthca_free_err_wqe(struct mthca_dev *dev, struct mthca_qp *qp, int is_send,
- int index, int *dbd, __be32 *new_wqe)
-{
- struct mthca_next_seg *next;
-
- /*
- * For SRQs, all receive WQEs generate a CQE, so we're always
- * at the end of the doorbell chain.
- */
- if (qp->ibqp.srq && !is_send) {
- *new_wqe = 0;
- return;
- }
-
- if (is_send)
- next = get_send_wqe(qp, index);
- else
- next = get_recv_wqe(qp, index);
-
- *dbd = !!(next->ee_nds & cpu_to_be32(MTHCA_NEXT_DBD));
- if (next->ee_nds & cpu_to_be32(0x3f))
- *new_wqe = (next->nda_op & cpu_to_be32(~0x3f)) |
- (next->ee_nds & cpu_to_be32(0x3f));
- else
- *new_wqe = 0;
-}
-
-int mthca_init_qp_table(struct mthca_dev *dev)
-{
- int err;
- u8 status;
- int i;
-
- spin_lock_init(&dev->qp_table.lock);
-
- /*
- * We reserve 2 extra QPs per port for the special QPs. The
- * special QP for port 1 has to be even, so round up.
- */
- dev->qp_table.sqp_start = (dev->limits.reserved_qps + 1) & ~1UL;
- err = mthca_alloc_init(&dev->qp_table.alloc,
- dev->limits.num_qps,
- (1 << 24) - 1,
- dev->qp_table.sqp_start +
- MTHCA_MAX_PORTS * 2);
- if (err)
- return err;
-
- err = mthca_array_init(&dev->qp_table.qp,
- dev->limits.num_qps);
- if (err) {
- mthca_alloc_cleanup(&dev->qp_table.alloc);
- return err;
- }
-
- for (i = 0; i < 2; ++i) {
- err = mthca_CONF_SPECIAL_QP(dev, i ? IB_QPT_GSI : IB_QPT_SMI,
- dev->qp_table.sqp_start + i * 2,
- &status);
- if (err)
- goto err_out;
- if (status) {
- mthca_warn(dev, "CONF_SPECIAL_QP returned "
- "status %02x, aborting.\n",
- status);
- err = -EINVAL;
- goto err_out;
- }
- }
- return 0;
-
- err_out:
- for (i = 0; i < 2; ++i)
- mthca_CONF_SPECIAL_QP(dev, i, 0, &status);
-
- mthca_array_cleanup(&dev->qp_table.qp, dev->limits.num_qps);
- mthca_alloc_cleanup(&dev->qp_table.alloc);
-
- return err;
-}
-
-void mthca_cleanup_qp_table(struct mthca_dev *dev)
-{
- int i;
- u8 status;
-
- for (i = 0; i < 2; ++i)
- mthca_CONF_SPECIAL_QP(dev, i, 0, &status);
-
- mthca_array_cleanup(&dev->qp_table.qp, dev->limits.num_qps);
- mthca_alloc_cleanup(&dev->qp_table.alloc);
-}
diff --git a/sys/ofed/drivers/infiniband/hw/mthca/mthca_srq.c b/sys/ofed/drivers/infiniband/hw/mthca/mthca_srq.c
deleted file mode 100644
index 4fabe62..0000000
--- a/sys/ofed/drivers/infiniband/hw/mthca/mthca_srq.c
+++ /dev/null
@@ -1,715 +0,0 @@
-/*
- * Copyright (c) 2005 Cisco Systems. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-#include <linux/slab.h>
-#include <linux/string.h>
-#include <linux/sched.h>
-
-#include <asm/io.h>
-
-#include "mthca_dev.h"
-#include "mthca_cmd.h"
-#include "mthca_memfree.h"
-#include "mthca_wqe.h"
-
-enum {
- MTHCA_MAX_DIRECT_SRQ_SIZE = 4 * PAGE_SIZE
-};
-
-struct mthca_tavor_srq_context {
- __be64 wqe_base_ds; /* low 6 bits is descriptor size */
- __be32 state_pd;
- __be32 lkey;
- __be32 uar;
- __be16 limit_watermark;
- __be16 wqe_cnt;
- u32 reserved[2];
-};
-
-struct mthca_arbel_srq_context {
- __be32 state_logsize_srqn;
- __be32 lkey;
- __be32 db_index;
- __be32 logstride_usrpage;
- __be64 wqe_base;
- __be32 eq_pd;
- __be16 limit_watermark;
- __be16 wqe_cnt;
- u16 reserved1;
- __be16 wqe_counter;
- u32 reserved2[3];
-};
-
-static void *get_wqe(struct mthca_srq *srq, int n)
-{
- if (srq->is_direct)
- return srq->queue.direct.buf + (n << srq->wqe_shift);
- else
- return srq->queue.page_list[(n << srq->wqe_shift) >> PAGE_SHIFT].buf +
- ((n << srq->wqe_shift) & (PAGE_SIZE - 1));
-}
-
-/*
- * Return a pointer to the location within a WQE that we're using as a
- * link when the WQE is in the free list. We use the imm field
- * because in the Tavor case, posting a WQE may overwrite the next
- * segment of the previous WQE, but a receive WQE will never touch the
- * imm field. This avoids corrupting our free list if the previous
- * WQE has already completed and been put on the free list when we
- * post the next WQE.
- */
-static inline int *wqe_to_link(void *wqe)
-{
- return (int *) (wqe + offsetof(struct mthca_next_seg, imm));
-}
-
-static void mthca_tavor_init_srq_context(struct mthca_dev *dev,
- struct mthca_pd *pd,
- struct mthca_srq *srq,
- struct mthca_tavor_srq_context *context)
-{
- memset(context, 0, sizeof *context);
-
- context->wqe_base_ds = cpu_to_be64(1 << (srq->wqe_shift - 4));
- context->state_pd = cpu_to_be32(pd->pd_num);
- context->lkey = cpu_to_be32(srq->mr.ibmr.lkey);
-
- if (pd->ibpd.uobject)
- context->uar =
- cpu_to_be32(to_mucontext(pd->ibpd.uobject->context)->uar.index);
- else
- context->uar = cpu_to_be32(dev->driver_uar.index);
-}
-
-static void mthca_arbel_init_srq_context(struct mthca_dev *dev,
- struct mthca_pd *pd,
- struct mthca_srq *srq,
- struct mthca_arbel_srq_context *context)
-{
- int logsize, max;
-
- memset(context, 0, sizeof *context);
-
- /*
- * Put max in a temporary variable to work around gcc bug
- * triggered by ilog2() on sparc64.
- */
- max = srq->max;
- logsize = ilog2(max);
- context->state_logsize_srqn = cpu_to_be32(logsize << 24 | srq->srqn);
- context->lkey = cpu_to_be32(srq->mr.ibmr.lkey);
- context->db_index = cpu_to_be32(srq->db_index);
- context->logstride_usrpage = cpu_to_be32((srq->wqe_shift - 4) << 29);
- if (pd->ibpd.uobject)
- context->logstride_usrpage |=
- cpu_to_be32(to_mucontext(pd->ibpd.uobject->context)->uar.index);
- else
- context->logstride_usrpage |= cpu_to_be32(dev->driver_uar.index);
- context->eq_pd = cpu_to_be32(MTHCA_EQ_ASYNC << 24 | pd->pd_num);
-}
-
-static void mthca_free_srq_buf(struct mthca_dev *dev, struct mthca_srq *srq)
-{
- mthca_buf_free(dev, srq->max << srq->wqe_shift, &srq->queue,
- srq->is_direct, &srq->mr);
- kfree(srq->wrid);
-}
-
-static int mthca_alloc_srq_buf(struct mthca_dev *dev, struct mthca_pd *pd,
- struct mthca_srq *srq)
-{
- struct mthca_data_seg *scatter;
- void *wqe;
- int err;
- int i;
-
- if (pd->ibpd.uobject)
- return 0;
-
- srq->wrid = kmalloc(srq->max * sizeof (u64), GFP_KERNEL);
- if (!srq->wrid)
- return -ENOMEM;
-
- err = mthca_buf_alloc(dev, srq->max << srq->wqe_shift,
- MTHCA_MAX_DIRECT_SRQ_SIZE,
- &srq->queue, &srq->is_direct, pd, 1, &srq->mr);
- if (err) {
- kfree(srq->wrid);
- return err;
- }
-
- /*
- * Now initialize the SRQ buffer so that all of the WQEs are
- * linked into the list of free WQEs. In addition, set the
- * scatter list L_Keys to the sentry value of 0x100.
- */
- for (i = 0; i < srq->max; ++i) {
- struct mthca_next_seg *next;
-
- next = wqe = get_wqe(srq, i);
-
- if (i < srq->max - 1) {
- *wqe_to_link(wqe) = i + 1;
- next->nda_op = htonl(((i + 1) << srq->wqe_shift) | 1);
- } else {
- *wqe_to_link(wqe) = -1;
- next->nda_op = 0;
- }
-
- for (scatter = wqe + sizeof (struct mthca_next_seg);
- (void *) scatter < wqe + (1 << srq->wqe_shift);
- ++scatter)
- scatter->lkey = cpu_to_be32(MTHCA_INVAL_LKEY);
- }
-
- srq->last = get_wqe(srq, srq->max - 1);
-
- return 0;
-}
-
-int mthca_alloc_srq(struct mthca_dev *dev, struct mthca_pd *pd,
- struct ib_srq_attr *attr, struct mthca_srq *srq)
-{
- struct mthca_mailbox *mailbox;
- u8 status;
- int ds;
- int err;
-
- /* Sanity check SRQ size before proceeding */
- if (attr->max_wr > dev->limits.max_srq_wqes ||
- attr->max_sge > dev->limits.max_srq_sge)
- return -EINVAL;
-
- srq->max = attr->max_wr;
- srq->max_gs = attr->max_sge;
- srq->counter = 0;
-
- if (mthca_is_memfree(dev))
- srq->max = roundup_pow_of_two(srq->max + 1);
- else
- srq->max = srq->max + 1;
-
- ds = max(64UL,
- roundup_pow_of_two(sizeof (struct mthca_next_seg) +
- srq->max_gs * sizeof (struct mthca_data_seg)));
-
- if (!mthca_is_memfree(dev) && (ds > dev->limits.max_desc_sz))
- return -EINVAL;
-
- srq->wqe_shift = ilog2(ds);
-
- srq->srqn = mthca_alloc(&dev->srq_table.alloc);
- if (srq->srqn == -1)
- return -ENOMEM;
-
- if (mthca_is_memfree(dev)) {
- err = mthca_table_get(dev, dev->srq_table.table, srq->srqn);
- if (err)
- goto err_out;
-
- if (!pd->ibpd.uobject) {
- srq->db_index = mthca_alloc_db(dev, MTHCA_DB_TYPE_SRQ,
- srq->srqn, &srq->db);
- if (srq->db_index < 0) {
- err = -ENOMEM;
- goto err_out_icm;
- }
- }
- }
-
- mailbox = mthca_alloc_mailbox(dev, GFP_KERNEL);
- if (IS_ERR(mailbox)) {
- err = PTR_ERR(mailbox);
- goto err_out_db;
- }
-
- err = mthca_alloc_srq_buf(dev, pd, srq);
- if (err)
- goto err_out_mailbox;
-
- spin_lock_init(&srq->lock);
- srq->refcount = 1;
- init_waitqueue_head(&srq->wait);
- mutex_init(&srq->mutex);
-
- if (mthca_is_memfree(dev))
- mthca_arbel_init_srq_context(dev, pd, srq, mailbox->buf);
- else
- mthca_tavor_init_srq_context(dev, pd, srq, mailbox->buf);
-
- err = mthca_SW2HW_SRQ(dev, mailbox, srq->srqn, &status);
-
- if (err) {
- mthca_warn(dev, "SW2HW_SRQ failed (%d)\n", err);
- goto err_out_free_buf;
- }
- if (status) {
- mthca_warn(dev, "SW2HW_SRQ returned status 0x%02x\n",
- status);
- err = -EINVAL;
- goto err_out_free_buf;
- }
-
- spin_lock_irq(&dev->srq_table.lock);
- if (mthca_array_set(&dev->srq_table.srq,
- srq->srqn & (dev->limits.num_srqs - 1),
- srq)) {
- spin_unlock_irq(&dev->srq_table.lock);
- goto err_out_free_srq;
- }
- spin_unlock_irq(&dev->srq_table.lock);
-
- mthca_free_mailbox(dev, mailbox);
-
- srq->first_free = 0;
- srq->last_free = srq->max - 1;
-
- attr->max_wr = srq->max - 1;
- attr->max_sge = srq->max_gs;
-
- return 0;
-
-err_out_free_srq:
- err = mthca_HW2SW_SRQ(dev, mailbox, srq->srqn, &status);
- if (err)
- mthca_warn(dev, "HW2SW_SRQ failed (%d)\n", err);
- else if (status)
- mthca_warn(dev, "HW2SW_SRQ returned status 0x%02x\n", status);
-
-err_out_free_buf:
- if (!pd->ibpd.uobject)
- mthca_free_srq_buf(dev, srq);
-
-err_out_mailbox:
- mthca_free_mailbox(dev, mailbox);
-
-err_out_db:
- if (!pd->ibpd.uobject && mthca_is_memfree(dev))
- mthca_free_db(dev, MTHCA_DB_TYPE_SRQ, srq->db_index);
-
-err_out_icm:
- mthca_table_put(dev, dev->srq_table.table, srq->srqn);
-
-err_out:
- mthca_free(&dev->srq_table.alloc, srq->srqn);
-
- return err;
-}
-
-static inline int get_srq_refcount(struct mthca_dev *dev, struct mthca_srq *srq)
-{
- int c;
-
- spin_lock_irq(&dev->srq_table.lock);
- c = srq->refcount;
- spin_unlock_irq(&dev->srq_table.lock);
-
- return c;
-}
-
-void mthca_free_srq(struct mthca_dev *dev, struct mthca_srq *srq)
-{
- struct mthca_mailbox *mailbox;
- int err;
- u8 status;
-
- mailbox = mthca_alloc_mailbox(dev, GFP_KERNEL);
- if (IS_ERR(mailbox)) {
- mthca_warn(dev, "No memory for mailbox to free SRQ.\n");
- return;
- }
-
- err = mthca_HW2SW_SRQ(dev, mailbox, srq->srqn, &status);
- if (err)
- mthca_warn(dev, "HW2SW_SRQ failed (%d)\n", err);
- else if (status)
- mthca_warn(dev, "HW2SW_SRQ returned status 0x%02x\n", status);
-
- spin_lock_irq(&dev->srq_table.lock);
- mthca_array_clear(&dev->srq_table.srq,
- srq->srqn & (dev->limits.num_srqs - 1));
- --srq->refcount;
- spin_unlock_irq(&dev->srq_table.lock);
-
- wait_event(srq->wait, !get_srq_refcount(dev, srq));
-
- if (!srq->ibsrq.uobject) {
- mthca_free_srq_buf(dev, srq);
- if (mthca_is_memfree(dev))
- mthca_free_db(dev, MTHCA_DB_TYPE_SRQ, srq->db_index);
- }
-
- mthca_table_put(dev, dev->srq_table.table, srq->srqn);
- mthca_free(&dev->srq_table.alloc, srq->srqn);
- mthca_free_mailbox(dev, mailbox);
-}
-
-int mthca_modify_srq(struct ib_srq *ibsrq, struct ib_srq_attr *attr,
- enum ib_srq_attr_mask attr_mask, struct ib_udata *udata)
-{
- struct mthca_dev *dev = to_mdev(ibsrq->device);
- struct mthca_srq *srq = to_msrq(ibsrq);
- int ret;
- u8 status;
-
- /* We don't support resizing SRQs (yet?) */
- if (attr_mask & IB_SRQ_MAX_WR)
- return -EINVAL;
-
- if (attr_mask & IB_SRQ_LIMIT) {
- u32 max_wr = mthca_is_memfree(dev) ? srq->max - 1 : srq->max;
- if (attr->srq_limit > max_wr)
- return -EINVAL;
-
- mutex_lock(&srq->mutex);
- ret = mthca_ARM_SRQ(dev, srq->srqn, attr->srq_limit, &status);
- mutex_unlock(&srq->mutex);
-
- if (ret)
- return ret;
- if (status)
- return -EINVAL;
- }
-
- return 0;
-}
-
-int mthca_query_srq(struct ib_srq *ibsrq, struct ib_srq_attr *srq_attr)
-{
- struct mthca_dev *dev = to_mdev(ibsrq->device);
- struct mthca_srq *srq = to_msrq(ibsrq);
- struct mthca_mailbox *mailbox;
- struct mthca_arbel_srq_context *arbel_ctx;
- struct mthca_tavor_srq_context *tavor_ctx;
- u8 status;
- int err;
-
- mailbox = mthca_alloc_mailbox(dev, GFP_KERNEL);
- if (IS_ERR(mailbox))
- return PTR_ERR(mailbox);
-
- err = mthca_QUERY_SRQ(dev, srq->srqn, mailbox, &status);
- if (err)
- goto out;
-
- if (mthca_is_memfree(dev)) {
- arbel_ctx = mailbox->buf;
- srq_attr->srq_limit = be16_to_cpu(arbel_ctx->limit_watermark);
- } else {
- tavor_ctx = mailbox->buf;
- srq_attr->srq_limit = be16_to_cpu(tavor_ctx->limit_watermark);
- }
-
- srq_attr->max_wr = srq->max - 1;
- srq_attr->max_sge = srq->max_gs;
-
-out:
- mthca_free_mailbox(dev, mailbox);
-
- return err;
-}
-
-void mthca_srq_event(struct mthca_dev *dev, u32 srqn,
- enum ib_event_type event_type)
-{
- struct mthca_srq *srq;
- struct ib_event event;
-
- spin_lock(&dev->srq_table.lock);
- srq = mthca_array_get(&dev->srq_table.srq, srqn & (dev->limits.num_srqs - 1));
- if (srq)
- ++srq->refcount;
- spin_unlock(&dev->srq_table.lock);
-
- if (!srq) {
- mthca_warn(dev, "Async event for bogus SRQ %08x\n", srqn);
- return;
- }
-
- if (!srq->ibsrq.event_handler)
- goto out;
-
- event.device = &dev->ib_dev;
- event.event = event_type;
- event.element.srq = &srq->ibsrq;
- srq->ibsrq.event_handler(&event, srq->ibsrq.srq_context);
-
-out:
- spin_lock(&dev->srq_table.lock);
- if (!--srq->refcount)
- wake_up(&srq->wait);
- spin_unlock(&dev->srq_table.lock);
-}
-
-/*
- * This function must be called with IRQs disabled.
- */
-void mthca_free_srq_wqe(struct mthca_srq *srq, u32 wqe_addr)
-{
- int ind;
- struct mthca_next_seg *last_free;
-
- ind = wqe_addr >> srq->wqe_shift;
-
- spin_lock(&srq->lock);
-
- last_free = get_wqe(srq, srq->last_free);
- *wqe_to_link(last_free) = ind;
- last_free->nda_op = htonl((ind << srq->wqe_shift) | 1);
- *wqe_to_link(get_wqe(srq, ind)) = -1;
- srq->last_free = ind;
-
- spin_unlock(&srq->lock);
-}
-
-int mthca_tavor_post_srq_recv(struct ib_srq *ibsrq, struct ib_recv_wr *wr,
- struct ib_recv_wr **bad_wr)
-{
- struct mthca_dev *dev = to_mdev(ibsrq->device);
- struct mthca_srq *srq = to_msrq(ibsrq);
- unsigned long flags;
- int err = 0;
- int first_ind;
- int ind;
- int next_ind;
- int nreq;
- int i;
- void *wqe;
- void *prev_wqe;
-
- spin_lock_irqsave(&srq->lock, flags);
-
- first_ind = srq->first_free;
-
- for (nreq = 0; wr; wr = wr->next) {
- ind = srq->first_free;
- wqe = get_wqe(srq, ind);
- next_ind = *wqe_to_link(wqe);
-
- if (unlikely(next_ind < 0)) {
- mthca_err(dev, "SRQ %06x full\n", srq->srqn);
- err = -ENOMEM;
- *bad_wr = wr;
- break;
- }
-
- prev_wqe = srq->last;
- srq->last = wqe;
-
- ((struct mthca_next_seg *) wqe)->ee_nds = 0;
- /* flags field will always remain 0 */
-
- wqe += sizeof (struct mthca_next_seg);
-
- if (unlikely(wr->num_sge > srq->max_gs)) {
- err = -EINVAL;
- *bad_wr = wr;
- srq->last = prev_wqe;
- break;
- }
-
- for (i = 0; i < wr->num_sge; ++i) {
- mthca_set_data_seg(wqe, wr->sg_list + i);
- wqe += sizeof (struct mthca_data_seg);
- }
-
- if (i < srq->max_gs)
- mthca_set_data_seg_inval(wqe);
-
- ((struct mthca_next_seg *) prev_wqe)->ee_nds =
- cpu_to_be32(MTHCA_NEXT_DBD);
-
- srq->wrid[ind] = wr->wr_id;
- srq->first_free = next_ind;
-
- ++nreq;
- if (unlikely(nreq == MTHCA_TAVOR_MAX_WQES_PER_RECV_DB)) {
- nreq = 0;
-
- /*
- * Make sure that descriptors are written
- * before doorbell is rung.
- */
- wmb();
-
- mthca_write64(first_ind << srq->wqe_shift, srq->srqn << 8,
- dev->kar + MTHCA_RECEIVE_DOORBELL,
- MTHCA_GET_DOORBELL_LOCK(&dev->doorbell_lock));
-
- first_ind = srq->first_free;
- }
- }
-
- if (likely(nreq)) {
- /*
- * Make sure that descriptors are written before
- * doorbell is rung.
- */
- wmb();
-
- mthca_write64(first_ind << srq->wqe_shift, (srq->srqn << 8) | nreq,
- dev->kar + MTHCA_RECEIVE_DOORBELL,
- MTHCA_GET_DOORBELL_LOCK(&dev->doorbell_lock));
- }
-
- /*
- * Make sure doorbells don't leak out of SRQ spinlock and
- * reach the HCA out of order:
- */
- mmiowb();
-
- spin_unlock_irqrestore(&srq->lock, flags);
- return err;
-}
-
-int mthca_arbel_post_srq_recv(struct ib_srq *ibsrq, struct ib_recv_wr *wr,
- struct ib_recv_wr **bad_wr)
-{
- struct mthca_dev *dev = to_mdev(ibsrq->device);
- struct mthca_srq *srq = to_msrq(ibsrq);
- unsigned long flags;
- int err = 0;
- int ind;
- int next_ind;
- int nreq;
- int i;
- void *wqe;
-
- spin_lock_irqsave(&srq->lock, flags);
-
- for (nreq = 0; wr; ++nreq, wr = wr->next) {
- ind = srq->first_free;
- wqe = get_wqe(srq, ind);
- next_ind = *wqe_to_link(wqe);
-
- if (unlikely(next_ind < 0)) {
- mthca_err(dev, "SRQ %06x full\n", srq->srqn);
- err = -ENOMEM;
- *bad_wr = wr;
- break;
- }
-
- ((struct mthca_next_seg *) wqe)->ee_nds = 0;
- /* flags field will always remain 0 */
-
- wqe += sizeof (struct mthca_next_seg);
-
- if (unlikely(wr->num_sge > srq->max_gs)) {
- err = -EINVAL;
- *bad_wr = wr;
- break;
- }
-
- for (i = 0; i < wr->num_sge; ++i) {
- mthca_set_data_seg(wqe, wr->sg_list + i);
- wqe += sizeof (struct mthca_data_seg);
- }
-
- if (i < srq->max_gs)
- mthca_set_data_seg_inval(wqe);
-
- srq->wrid[ind] = wr->wr_id;
- srq->first_free = next_ind;
- }
-
- if (likely(nreq)) {
- srq->counter += nreq;
-
- /*
- * Make sure that descriptors are written before
- * we write doorbell record.
- */
- wmb();
- *srq->db = cpu_to_be32(srq->counter);
- }
-
- spin_unlock_irqrestore(&srq->lock, flags);
- return err;
-}
-
-int mthca_max_srq_sge(struct mthca_dev *dev)
-{
- if (mthca_is_memfree(dev))
- return dev->limits.max_sg;
-
- /*
- * SRQ allocations are based on powers of 2 for Tavor,
- * (although they only need to be multiples of 16 bytes).
- *
- * Therefore, we need to base the max number of sg entries on
- * the largest power of 2 descriptor size that is <= to the
- * actual max WQE descriptor size, rather than return the
- * max_sg value given by the firmware (which is based on WQE
- * sizes as multiples of 16, not powers of 2).
- *
- * If SRQ implementation is changed for Tavor to be based on
- * multiples of 16, the calculation below can be deleted and
- * the FW max_sg value returned.
- */
- return min_t(int, dev->limits.max_sg,
- ((1 << (fls(dev->limits.max_desc_sz) - 1)) -
- sizeof (struct mthca_next_seg)) /
- sizeof (struct mthca_data_seg));
-}
-
-int mthca_init_srq_table(struct mthca_dev *dev)
-{
- int err;
-
- if (!(dev->mthca_flags & MTHCA_FLAG_SRQ))
- return 0;
-
- spin_lock_init(&dev->srq_table.lock);
-
- err = mthca_alloc_init(&dev->srq_table.alloc,
- dev->limits.num_srqs,
- dev->limits.num_srqs - 1,
- dev->limits.reserved_srqs);
- if (err)
- return err;
-
- err = mthca_array_init(&dev->srq_table.srq,
- dev->limits.num_srqs);
- if (err)
- mthca_alloc_cleanup(&dev->srq_table.alloc);
-
- return err;
-}
-
-void mthca_cleanup_srq_table(struct mthca_dev *dev)
-{
- if (!(dev->mthca_flags & MTHCA_FLAG_SRQ))
- return;
-
- mthca_array_cleanup(&dev->srq_table.srq, dev->limits.num_srqs);
- mthca_alloc_cleanup(&dev->srq_table.alloc);
-}
diff --git a/sys/ofed/drivers/infiniband/hw/mthca/mthca_uar.c b/sys/ofed/drivers/infiniband/hw/mthca/mthca_uar.c
deleted file mode 100644
index 5c9ad23..0000000
--- a/sys/ofed/drivers/infiniband/hw/mthca/mthca_uar.c
+++ /dev/null
@@ -1,78 +0,0 @@
-/*
- * Copyright (c) 2005 Topspin Communications. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-#include <linux/page.h>
-
-#include "mthca_dev.h"
-#include "mthca_memfree.h"
-
-int mthca_uar_alloc(struct mthca_dev *dev, struct mthca_uar *uar)
-{
- uar->index = mthca_alloc(&dev->uar_table.alloc);
- if (uar->index == -1)
- return -ENOMEM;
-
- uar->pfn = (pci_resource_start(dev->pdev, 2) >> PAGE_SHIFT) + uar->index;
-
- return 0;
-}
-
-void mthca_uar_free(struct mthca_dev *dev, struct mthca_uar *uar)
-{
- mthca_free(&dev->uar_table.alloc, uar->index);
-}
-
-int mthca_init_uar_table(struct mthca_dev *dev)
-{
- int ret;
-
- ret = mthca_alloc_init(&dev->uar_table.alloc,
- dev->limits.num_uars,
- dev->limits.num_uars - 1,
- dev->limits.reserved_uars + 1);
- if (ret)
- return ret;
-
- ret = mthca_init_db_tab(dev);
- if (ret)
- mthca_alloc_cleanup(&dev->uar_table.alloc);
-
- return ret;
-}
-
-void mthca_cleanup_uar_table(struct mthca_dev *dev)
-{
- mthca_cleanup_db_tab(dev);
-
- /* XXX check if any UARs are still allocated? */
- mthca_alloc_cleanup(&dev->uar_table.alloc);
-}
diff --git a/sys/ofed/drivers/infiniband/ulp/ipoib/Kconfig b/sys/ofed/drivers/infiniband/ulp/ipoib/Kconfig
deleted file mode 100644
index 9d9a9dc..0000000
--- a/sys/ofed/drivers/infiniband/ulp/ipoib/Kconfig
+++ /dev/null
@@ -1,50 +0,0 @@
-config INFINIBAND_IPOIB
- tristate "IP-over-InfiniBand"
- depends on NETDEVICES && INET && (IPV6 || IPV6=n)
- select INET_LRO
- ---help---
- Support for the IP-over-InfiniBand protocol (IPoIB). This
- transports IP packets over InfiniBand so you can use your IB
- device as a fancy NIC.
-
- See Documentation/infiniband/ipoib.txt for more information
-
-config INFINIBAND_IPOIB_CM
- bool "IP-over-InfiniBand Connected Mode support"
- depends on INFINIBAND_IPOIB
- default n
- ---help---
- This option enables support for IPoIB connected mode. After
- enabling this option, you need to switch to connected mode
- through /sys/class/net/ibXXX/mode to actually create
- connections, and then increase the interface MTU with
- e.g. ifconfig ib0 mtu 65520.
-
- WARNING: Enabling connected mode will trigger some packet
- drops for multicast and UD mode traffic from this interface,
- unless you limit mtu for these destinations to 2044.
-
-config INFINIBAND_IPOIB_DEBUG
- bool "IP-over-InfiniBand debugging" if EMBEDDED
- depends on INFINIBAND_IPOIB
- default y
- ---help---
- This option causes debugging code to be compiled into the
- IPoIB driver. The output can be turned on via the
- debug_level and mcast_debug_level module parameters (which
- can also be set after the driver is loaded through sysfs).
-
- This option also creates a directory tree under ipoib/ in
- debugfs, which contains files that expose debugging
- information about IB multicast groups used by the IPoIB
- driver.
-
-config INFINIBAND_IPOIB_DEBUG_DATA
- bool "IP-over-InfiniBand data path debugging"
- depends on INFINIBAND_IPOIB_DEBUG
- ---help---
- This option compiles debugging code into the data path
- of the IPoIB driver. The output can be turned on via the
- data_debug_level module parameter; however, even with output
- turned off, this debugging code will have some performance
- impact.
diff --git a/sys/ofed/drivers/infiniband/ulp/ipoib/ipoib.h b/sys/ofed/drivers/infiniband/ulp/ipoib/ipoib.h
index ed2b91c..77c692a 100644
--- a/sys/ofed/drivers/infiniband/ulp/ipoib/ipoib.h
+++ b/sys/ofed/drivers/infiniband/ulp/ipoib/ipoib.h
@@ -325,6 +325,7 @@ struct ipoib_dev_priv {
unsigned long flags;
int gone;
+ int unit;
struct mutex vlan_mutex;
@@ -349,7 +350,6 @@ struct ipoib_dev_priv {
u16 pkey;
u16 pkey_index;
struct ib_pd *pd;
- struct ib_mr *mr;
struct ib_cq *recv_cq;
struct ib_cq *send_cq;
struct ib_qp *qp;
@@ -368,7 +368,7 @@ struct ipoib_dev_priv {
unsigned tx_head;
unsigned tx_tail;
struct ib_sge tx_sge[IPOIB_MAX_TX_SG];
- struct ib_send_wr tx_wr;
+ struct ib_ud_wr tx_wr;
unsigned tx_outstanding;
struct ib_wc send_wc[MAX_SEND_CQE];
diff --git a/sys/ofed/drivers/infiniband/ulp/ipoib/ipoib_cm.c b/sys/ofed/drivers/infiniband/ulp/ipoib/ipoib_cm.c
index 13a6949..d68e0f8 100644
--- a/sys/ofed/drivers/infiniband/ulp/ipoib/ipoib_cm.c
+++ b/sys/ofed/drivers/infiniband/ulp/ipoib/ipoib_cm.c
@@ -287,7 +287,7 @@ static void ipoib_cm_init_rx_wr(struct ipoib_dev_priv *priv,
int i;
for (i = 0; i < IPOIB_CM_RX_SG; i++)
- sge[i].lkey = priv->mr->lkey;
+ sge[i].lkey = priv->pd->local_dma_lkey;
wr->next = NULL;
wr->sg_list = sge;
@@ -601,11 +601,11 @@ static inline int post_send(struct ipoib_dev_priv *priv,
priv->tx_sge[i].addr = mapping[i];
priv->tx_sge[i].length = m->m_len;
}
- priv->tx_wr.num_sge = i;
- priv->tx_wr.wr_id = wr_id | IPOIB_OP_CM;
- priv->tx_wr.opcode = IB_WR_SEND;
+ priv->tx_wr.wr.num_sge = i;
+ priv->tx_wr.wr.wr_id = wr_id | IPOIB_OP_CM;
+ priv->tx_wr.wr.opcode = IB_WR_SEND;
- return ib_post_send(tx->qp, &priv->tx_wr, &bad_wr);
+ return ib_post_send(tx->qp, &priv->tx_wr.wr, &bad_wr);
}
void ipoib_cm_send(struct ipoib_dev_priv *priv, struct mbuf *mb, struct ipoib_cm_tx *tx)
@@ -736,8 +736,7 @@ int ipoib_cm_dev_open(struct ipoib_dev_priv *priv)
goto err_cm;
}
- ret = ib_cm_listen(priv->cm.id, cpu_to_be64(IPOIB_CM_IETF_ID | priv->qp->qp_num),
- 0, NULL);
+ ret = ib_cm_listen(priv->cm.id, cpu_to_be64(IPOIB_CM_IETF_ID | priv->qp->qp_num), 0);
if (ret) {
printk(KERN_WARNING "%s: failed to listen on ID 0x%llx\n", priv->ca->name,
IPOIB_CM_IETF_ID | priv->qp->qp_num);
@@ -831,7 +830,7 @@ void ipoib_cm_dev_stop(struct ipoib_dev_priv *priv)
ipoib_cm_free_rx_reap_list(priv);
- cancel_delayed_work(&priv->cm.stale_task);
+ cancel_delayed_work_sync(&priv->cm.stale_task);
}
static int ipoib_cm_rep_handler(struct ib_cm_id *cm_id, struct ib_cm_event *event)
@@ -1367,8 +1366,8 @@ static void ipoib_cm_create_srq(struct ipoib_dev_priv *priv, int max_sge)
int ipoib_cm_dev_init(struct ipoib_dev_priv *priv)
{
struct ifnet *dev = priv->dev;
- int i, ret;
- struct ib_device_attr attr;
+ int i;
+ int max_srq_sge;
INIT_LIST_HEAD(&priv->cm.passive_ids);
INIT_LIST_HEAD(&priv->cm.reap_list);
@@ -1387,19 +1386,15 @@ int ipoib_cm_dev_init(struct ipoib_dev_priv *priv)
mtx_init(&priv->cm.mb_queue.ifq_mtx,
dev->if_xname, "if send queue", MTX_DEF);
- ret = ib_query_device(priv->ca, &attr);
- if (ret) {
- printk(KERN_WARNING "ib_query_device() failed with %d\n", ret);
- return ret;
- }
+ max_srq_sge = priv->ca->attrs.max_srq_sge;
- ipoib_dbg(priv, "max_srq_sge=%d\n", attr.max_srq_sge);
+ ipoib_dbg(priv, "max_srq_sge=%d\n", max_srq_sge);
- attr.max_srq_sge = min_t(int, IPOIB_CM_RX_SG, attr.max_srq_sge);
- ipoib_cm_create_srq(priv, attr.max_srq_sge);
+ max_srq_sge = min_t(int, IPOIB_CM_RX_SG, max_srq_sge);
+ ipoib_cm_create_srq(priv, max_srq_sge);
if (ipoib_cm_has_srq(priv)) {
- priv->cm.max_cm_mtu = attr.max_srq_sge * MJUMPAGESIZE;
- priv->cm.num_frags = attr.max_srq_sge;
+ priv->cm.max_cm_mtu = max_srq_sge * MJUMPAGESIZE;
+ priv->cm.num_frags = max_srq_sge;
ipoib_dbg(priv, "max_cm_mtu = 0x%x, num_frags=%d\n",
priv->cm.max_cm_mtu, priv->cm.num_frags);
} else {
diff --git a/sys/ofed/drivers/infiniband/ulp/ipoib/ipoib_ib.c b/sys/ofed/drivers/infiniband/ulp/ipoib/ipoib_ib.c
index 1bbea1a..313852e 100644
--- a/sys/ofed/drivers/infiniband/ulp/ipoib/ipoib_ib.c
+++ b/sys/ofed/drivers/infiniband/ulp/ipoib/ipoib_ib.c
@@ -256,7 +256,7 @@ ipoib_ib_handle_rx_wc(struct ipoib_dev_priv *priv, struct ib_wc *wc)
eh = mtod(mb, struct ipoib_header *);
bzero(eh->hwaddr, 4); /* Zero the queue pair, only dgid is in grh */
- if (test_bit(IPOIB_FLAG_CSUM, &priv->flags) && likely(wc->csum_ok))
+ if (test_bit(IPOIB_FLAG_CSUM, &priv->flags) && likely(wc->wc_flags & IB_WC_IP_CSUM_OK))
mb->m_pkthdr.csum_flags = CSUM_IP_CHECKED | CSUM_IP_VALID;
dev->if_input(dev, mb);
@@ -451,21 +451,20 @@ post_send(struct ipoib_dev_priv *priv, unsigned int wr_id,
priv->tx_sge[i].addr = mapping[i];
priv->tx_sge[i].length = m->m_len;
}
- priv->tx_wr.num_sge = i;
- priv->tx_wr.wr_id = wr_id;
- priv->tx_wr.wr.ud.remote_qpn = qpn;
- priv->tx_wr.wr.ud.ah = address;
-
+ priv->tx_wr.wr.num_sge = i;
+ priv->tx_wr.wr.wr_id = wr_id;
+ priv->tx_wr.remote_qpn = qpn;
+ priv->tx_wr.ah = address;
if (head) {
- priv->tx_wr.wr.ud.mss = 0; /* XXX mb_shinfo(mb)->gso_size; */
- priv->tx_wr.wr.ud.header = head;
- priv->tx_wr.wr.ud.hlen = hlen;
- priv->tx_wr.opcode = IB_WR_LSO;
+ priv->tx_wr.mss = 0; /* XXX mb_shinfo(mb)->gso_size; */
+ priv->tx_wr.header = head;
+ priv->tx_wr.hlen = hlen;
+ priv->tx_wr.wr.opcode = IB_WR_LSO;
} else
- priv->tx_wr.opcode = IB_WR_SEND;
+ priv->tx_wr.wr.opcode = IB_WR_SEND;
- return ib_post_send(priv->qp, &priv->tx_wr, &bad_wr);
+ return ib_post_send(priv->qp, &priv->tx_wr.wr, &bad_wr);
}
void
@@ -524,9 +523,9 @@ ipoib_send(struct ipoib_dev_priv *priv, struct mbuf *mb,
}
if (mb->m_pkthdr.csum_flags & (CSUM_IP|CSUM_TCP|CSUM_UDP))
- priv->tx_wr.send_flags |= IB_SEND_IP_CSUM;
+ priv->tx_wr.wr.send_flags |= IB_SEND_IP_CSUM;
else
- priv->tx_wr.send_flags &= ~IB_SEND_IP_CSUM;
+ priv->tx_wr.wr.send_flags &= ~IB_SEND_IP_CSUM;
if (++priv->tx_outstanding == ipoib_sendq_size) {
ipoib_dbg(priv, "TX ring full, stopping kernel net queue\n");
diff --git a/sys/ofed/drivers/infiniband/ulp/ipoib/ipoib_main.c b/sys/ofed/drivers/infiniband/ulp/ipoib/ipoib_main.c
index b2f5efe..fa70769 100644
--- a/sys/ofed/drivers/infiniband/ulp/ipoib/ipoib_main.c
+++ b/sys/ofed/drivers/infiniband/ulp/ipoib/ipoib_main.c
@@ -84,7 +84,7 @@ struct workqueue_struct *ipoib_workqueue;
struct ib_sa_client ipoib_sa_client;
static void ipoib_add_one(struct ib_device *device);
-static void ipoib_remove_one(struct ib_device *device);
+static void ipoib_remove_one(struct ib_device *device, void *client_data);
static void ipoib_start(struct ifnet *dev);
static int ipoib_output(struct ifnet *ifp, struct mbuf *m,
const struct sockaddr *dst, struct route *ro);
@@ -99,6 +99,31 @@ do { \
} \
} while (0)
+static struct unrhdr *ipoib_unrhdr;
+
+static void
+ipoib_unrhdr_init(void *arg)
+{
+
+ ipoib_unrhdr = new_unrhdr(0, 65535, NULL);
+}
+SYSINIT(ipoib_unrhdr_init, SI_SUB_KLD - 1, SI_ORDER_ANY, ipoib_unrhdr_init, NULL);
+
+static void
+ipoib_unrhdr_uninit(void *arg)
+{
+
+ if (ipoib_unrhdr != NULL) {
+ struct unrhdr *hdr;
+
+ hdr = ipoib_unrhdr;
+ ipoib_unrhdr = NULL;
+
+ delete_unrhdr(hdr);
+ }
+}
+SYSUNINIT(ipoib_unrhdr_uninit, SI_SUB_KLD - 1, SI_ORDER_ANY, ipoib_unrhdr_uninit, NULL);
+
/*
* This is for clients that have an ipoib_header in the mbuf.
*/
@@ -660,7 +685,13 @@ ipoib_unicast_send(struct mbuf *mb, struct ipoib_dev_priv *priv, struct ipoib_he
new_path = 1;
}
if (path) {
- _IF_ENQUEUE(&path->queue, mb);
+ if (_IF_QLEN(&path->queue) < IPOIB_MAX_PATH_REC_QUEUE)
+ _IF_ENQUEUE(&path->queue, mb);
+ else {
+ if_inc_counter(priv->dev, IFCOUNTER_OERRORS, 1);
+ m_freem(mb);
+ }
+
if (!path->query && path_rec_start(priv, path)) {
spin_unlock_irqrestore(&priv->lock, flags);
if (new_path)
@@ -802,6 +833,7 @@ ipoib_detach(struct ipoib_dev_priv *priv)
bpfdetach(dev);
if_detach(dev);
if_free(dev);
+ free_unr(ipoib_unrhdr, priv->unit);
} else
VLAN_SETCOOKIE(priv->dev, NULL);
@@ -828,8 +860,6 @@ ipoib_dev_cleanup(struct ipoib_dev_priv *priv)
priv->tx_ring = NULL;
}
-static volatile int ipoib_unit;
-
static struct ipoib_dev_priv *
ipoib_priv_alloc(void)
{
@@ -870,7 +900,13 @@ ipoib_intf_alloc(const char *name)
return NULL;
}
dev->if_softc = priv;
- if_initname(dev, name, atomic_fetchadd_int(&ipoib_unit, 1));
+ priv->unit = alloc_unr(ipoib_unrhdr);
+ if (priv->unit == -1) {
+ if_free(dev);
+ free(priv, M_TEMP);
+ return NULL;
+ }
+ if_initname(dev, name, priv->unit);
dev->if_flags = IFF_BROADCAST | IFF_MULTICAST;
dev->if_addrlen = INFINIBAND_ALEN;
dev->if_hdrlen = IPOIB_HEADER_LEN;
@@ -897,27 +933,10 @@ ipoib_intf_alloc(const char *name)
int
ipoib_set_dev_features(struct ipoib_dev_priv *priv, struct ib_device *hca)
{
- struct ib_device_attr *device_attr;
- int result = -ENOMEM;
-
- device_attr = kmalloc(sizeof *device_attr, GFP_KERNEL);
- if (!device_attr) {
- printk(KERN_WARNING "%s: allocation of %zu bytes failed\n",
- hca->name, sizeof *device_attr);
- return result;
- }
+ struct ib_device_attr *device_attr = &hca->attrs;
- result = ib_query_device(hca, device_attr);
- if (result) {
- printk(KERN_WARNING "%s: ib_query_device failed (ret = %d)\n",
- hca->name, result);
- kfree(device_attr);
- return result;
- }
priv->hca_caps = device_attr->device_cap_flags;
- kfree(device_attr);
-
priv->dev->if_hwassist = 0;
priv->dev->if_capabilities = 0;
@@ -985,7 +1004,7 @@ ipoib_add_port(const char *format, struct ib_device *hca, u8 port)
priv->broadcastaddr[8] = priv->pkey >> 8;
priv->broadcastaddr[9] = priv->pkey & 0xff;
- result = ib_query_gid(hca, port, 0, &priv->local_gid);
+ result = ib_query_gid(hca, port, 0, &priv->local_gid, NULL);
if (result) {
printk(KERN_WARNING "%s: ib_query_gid port %d failed (ret = %d)\n",
hca->name, port, result);
@@ -1064,15 +1083,16 @@ ipoib_add_one(struct ib_device *device)
}
static void
-ipoib_remove_one(struct ib_device *device)
+ipoib_remove_one(struct ib_device *device, void *client_data)
{
struct ipoib_dev_priv *priv, *tmp;
- struct list_head *dev_list;
+ struct list_head *dev_list = client_data;
- if (rdma_node_get_transport(device->node_type) != RDMA_TRANSPORT_IB)
+ if (!dev_list)
return;
- dev_list = ib_get_client_data(device, &ipoib_client);
+ if (rdma_node_get_transport(device->node_type) != RDMA_TRANSPORT_IB)
+ return;
list_for_each_entry_safe(priv, tmp, dev_list, list) {
if (rdma_port_get_link_layer(device, priv->port) != IB_LINK_LAYER_INFINIBAND)
diff --git a/sys/ofed/drivers/infiniband/ulp/ipoib/ipoib_multicast.c b/sys/ofed/drivers/infiniband/ulp/ipoib/ipoib_multicast.c
index 4c04da1..4af5c91 100644
--- a/sys/ofed/drivers/infiniband/ulp/ipoib/ipoib_multicast.c
+++ b/sys/ofed/drivers/infiniband/ulp/ipoib/ipoib_multicast.c
@@ -167,7 +167,7 @@ static int ipoib_mcast_join_finish(struct ipoib_mcast *mcast,
}
priv->qkey = be32_to_cpu(priv->broadcast->mcmember.qkey);
spin_unlock_irq(&priv->lock);
- priv->tx_wr.wr.ud.remote_qkey = priv->qkey;
+ priv->tx_wr.remote_qkey = priv->qkey;
set_qkey = 1;
}
@@ -480,7 +480,7 @@ void ipoib_mcast_join_task(struct work_struct *work)
return;
}
- if (ib_query_gid(priv->ca, priv->port, 0, &priv->local_gid))
+ if (ib_query_gid(priv->ca, priv->port, 0, &priv->local_gid, NULL))
ipoib_warn(priv, "ib_query_gid() failed\n");
else
memcpy(IF_LLADDR(dev) + 4, priv->local_gid.raw, sizeof (union ib_gid));
diff --git a/sys/ofed/drivers/infiniband/ulp/ipoib/ipoib_verbs.c b/sys/ofed/drivers/infiniband/ulp/ipoib/ipoib_verbs.c
index 510a963..e49da8e 100644
--- a/sys/ofed/drivers/infiniband/ulp/ipoib/ipoib_verbs.c
+++ b/sys/ofed/drivers/infiniband/ulp/ipoib/ipoib_verbs.c
@@ -137,23 +137,18 @@ int ipoib_transport_dev_init(struct ipoib_dev_priv *priv, struct ib_device *ca)
.sq_sig_type = IB_SIGNAL_ALL_WR,
.qp_type = IB_QPT_UD
};
+ struct ib_cq_init_attr cq_attr = {};
int ret, size;
int i;
/* XXX struct ethtool_coalesce *coal; */
- priv->pd = ib_alloc_pd(priv->ca);
+ priv->pd = ib_alloc_pd(priv->ca, 0);
if (IS_ERR(priv->pd)) {
printk(KERN_WARNING "%s: failed to allocate PD\n", ca->name);
return -ENODEV;
}
- priv->mr = ib_get_dma_mr(priv->pd, IB_ACCESS_LOCAL_WRITE);
- if (IS_ERR(priv->mr)) {
- printk(KERN_WARNING "%s: ib_get_dma_mr failed\n", ca->name);
- goto out_free_pd;
- }
-
size = ipoib_recvq_size + 1;
ret = ipoib_cm_dev_init(priv);
if (!ret) {
@@ -164,14 +159,16 @@ int ipoib_transport_dev_init(struct ipoib_dev_priv *priv, struct ib_device *ca)
size += ipoib_recvq_size * ipoib_max_conn_qp;
}
- priv->recv_cq = ib_create_cq(priv->ca, ipoib_ib_completion, NULL, priv, size, 0);
+ cq_attr.cqe = size;
+ priv->recv_cq = ib_create_cq(priv->ca, ipoib_ib_completion, NULL, priv, &cq_attr);
if (IS_ERR(priv->recv_cq)) {
printk(KERN_WARNING "%s: failed to create receive CQ\n", ca->name);
goto out_free_mr;
}
+ cq_attr.cqe = ipoib_sendq_size;
priv->send_cq = ib_create_cq(priv->ca, ipoib_send_comp_handler, NULL,
- priv, ipoib_sendq_size, 0);
+ priv, &cq_attr);
if (IS_ERR(priv->send_cq)) {
printk(KERN_WARNING "%s: failed to create send CQ\n", ca->name);
goto out_free_recv_cq;
@@ -215,14 +212,14 @@ int ipoib_transport_dev_init(struct ipoib_dev_priv *priv, struct ib_device *ca)
IF_LLADDR(priv->dev)[3] = (priv->qp->qp_num ) & 0xff;
for (i = 0; i < IPOIB_MAX_TX_SG; ++i)
- priv->tx_sge[i].lkey = priv->mr->lkey;
+ priv->tx_sge[i].lkey = priv->pd->local_dma_lkey;
- priv->tx_wr.opcode = IB_WR_SEND;
- priv->tx_wr.sg_list = priv->tx_sge;
- priv->tx_wr.send_flags = IB_SEND_SIGNALED;
+ priv->tx_wr.wr.opcode = IB_WR_SEND;
+ priv->tx_wr.wr.sg_list = priv->tx_sge;
+ priv->tx_wr.wr.send_flags = IB_SEND_SIGNALED;
for (i = 0; i < IPOIB_UD_RX_SG; ++i)
- priv->rx_sge[i].lkey = priv->mr->lkey;
+ priv->rx_sge[i].lkey = priv->pd->local_dma_lkey;
priv->rx_wr.next = NULL;
priv->rx_wr.sg_list = priv->rx_sge;
@@ -235,10 +232,8 @@ out_free_recv_cq:
ib_destroy_cq(priv->recv_cq);
out_free_mr:
- ib_dereg_mr(priv->mr);
ipoib_cm_dev_cleanup(priv);
-out_free_pd:
ib_dealloc_pd(priv->pd);
return -ENODEV;
}
@@ -262,11 +257,7 @@ void ipoib_transport_dev_cleanup(struct ipoib_dev_priv *priv)
ipoib_cm_dev_cleanup(priv);
- if (ib_dereg_mr(priv->mr))
- ipoib_warn(priv, "ib_dereg_mr failed\n");
-
- if (ib_dealloc_pd(priv->pd))
- ipoib_warn(priv, "ib_dealloc_pd failed\n");
+ ib_dealloc_pd(priv->pd);
}
void ipoib_event(struct ib_event_handler *handler,
diff --git a/sys/ofed/drivers/infiniband/ulp/sdp/sdp.h b/sys/ofed/drivers/infiniband/ulp/sdp/sdp.h
index c5b6aa6..6b72e7b 100644
--- a/sys/ofed/drivers/infiniband/ulp/sdp/sdp.h
+++ b/sys/ofed/drivers/infiniband/ulp/sdp/sdp.h
@@ -52,7 +52,6 @@
#include <rdma/ib_verbs.h>
#include <rdma/rdma_cm.h>
#include <rdma/ib_cm.h>
-#include <rdma/sdp_socket.h>
#include <rdma/ib_fmr_pool.h>
#ifdef SDP_DEBUG
@@ -338,7 +337,6 @@ struct sdp_rx_ring {
struct sdp_device {
struct ib_pd *pd;
- struct ib_mr *mr;
struct ib_fmr_pool *fmr_pool;
};
@@ -403,8 +401,7 @@ struct sdp_sock {
struct sdp_rx_ring rx_ring;
struct sdp_tx_ring tx_ring;
struct rwlock lock;
- struct mbuf *rx_ctl_q;
- struct mbuf *rx_ctl_tail;
+ struct mbufq rxctlq; /* received control packets */
int qp_active; /* XXX Flag. */
int max_sge;
@@ -456,6 +453,8 @@ struct sdp_sock {
#define SDP_RLOCK_ASSERT(ssk) rw_assert(&(ssk)->lock, RA_RLOCKED)
#define SDP_LOCK_ASSERT(ssk) rw_assert(&(ssk)->lock, RA_LOCKED)
+MALLOC_DECLARE(M_SDP);
+
static inline void tx_sa_reset(struct tx_srcavail_state *tx_sa)
{
memset((void *)&tx_sa->busy, 0,
diff --git a/sys/ofed/drivers/infiniband/ulp/sdp/sdp_cma.c b/sys/ofed/drivers/infiniband/ulp/sdp/sdp_cma.c
index 9350609..63ab11c 100644
--- a/sys/ofed/drivers/infiniband/ulp/sdp/sdp_cma.c
+++ b/sys/ofed/drivers/infiniband/ulp/sdp/sdp_cma.c
@@ -51,15 +51,14 @@ sdp_qp_event_handler(struct ib_event *event, void *data)
static int
sdp_get_max_dev_sge(struct ib_device *dev)
{
- struct ib_device_attr attr;
+ struct ib_device_attr *device_attr;
static int max_sges = -1;
if (max_sges > 0)
goto out;
- ib_query_device(dev, &attr);
-
- max_sges = attr.max_sge;
+ device_attr = &dev->attrs;
+ max_sges = device_attr->max_sge;
out:
return max_sges;
diff --git a/sys/ofed/drivers/infiniband/ulp/sdp/sdp_main.c b/sys/ofed/drivers/infiniband/ulp/sdp/sdp_main.c
index ace705c..9531a7d 100644
--- a/sys/ofed/drivers/infiniband/ulp/sdp/sdp_main.c
+++ b/sys/ofed/drivers/infiniband/ulp/sdp/sdp_main.c
@@ -64,6 +64,10 @@
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
+#include <sys/param.h>
+#include <sys/kernel.h>
+#include <sys/malloc.h>
+
#include "sdp.h"
#include <net/if.h>
@@ -86,7 +90,7 @@ RW_SYSINIT(sdplockinit, &sdp_lock, "SDP lock");
#define SDP_LIST_RLOCK_ASSERT() rw_assert(&sdp_lock, RW_RLOCKED)
#define SDP_LIST_LOCK_ASSERT() rw_assert(&sdp_lock, RW_LOCKED)
-static MALLOC_DEFINE(M_SDP, "sdp", "Socket Direct Protocol");
+MALLOC_DEFINE(M_SDP, "sdp", "Sockets Direct Protocol");
static void sdp_stop_keepalive_timer(struct socket *so);
@@ -129,7 +133,7 @@ sdp_pcbbind(struct sdp_sock *ssk, struct sockaddr *nam, struct ucred *cred)
/* rdma_bind_addr handles bind races. */
SDP_WUNLOCK(ssk);
if (ssk->id == NULL)
- ssk->id = rdma_create_id(sdp_cma_handler, ssk, RDMA_PS_SDP, IB_QPT_RC);
+ ssk->id = rdma_create_id(&init_net, sdp_cma_handler, ssk, RDMA_PS_SDP, IB_QPT_RC);
if (ssk->id == NULL) {
SDP_WLOCK(ssk);
return (ENOMEM);
@@ -156,7 +160,10 @@ sdp_pcbbind(struct sdp_sock *ssk, struct sockaddr *nam, struct ucred *cred)
static void
sdp_pcbfree(struct sdp_sock *ssk)
{
+
KASSERT(ssk->socket == NULL, ("ssk %p socket still attached", ssk));
+ KASSERT((ssk->flags & SDP_DESTROY) == 0,
+ ("ssk %p already destroyed", ssk));
sdp_dbg(ssk->socket, "Freeing pcb");
SDP_WLOCK_ASSERT(ssk);
@@ -167,7 +174,6 @@ sdp_pcbfree(struct sdp_sock *ssk)
LIST_REMOVE(ssk, list);
SDP_LIST_WUNLOCK();
crfree(ssk->cred);
- sdp_destroy_cma(ssk);
ssk->qp_active = 0;
if (ssk->qp) {
ib_destroy_qp(ssk->qp);
@@ -175,9 +181,10 @@ sdp_pcbfree(struct sdp_sock *ssk)
}
sdp_tx_ring_destroy(ssk);
sdp_rx_ring_destroy(ssk);
+ sdp_destroy_cma(ssk);
rw_destroy(&ssk->rx_ring.destroyed_lock);
- uma_zfree(sdp_zone, ssk);
rw_destroy(&ssk->lock);
+ uma_zfree(sdp_zone, ssk);
}
/*
@@ -469,6 +476,7 @@ sdp_attach(struct socket *so, int proto, struct thread *td)
ssk->flags = 0;
ssk->qp_active = 0;
ssk->state = TCPS_CLOSED;
+ mbufq_init(&ssk->rxctlq, INT_MAX);
SDP_LIST_WLOCK();
LIST_INSERT_HEAD(&sdp_list, ssk, list);
sdp_count++;
@@ -1702,14 +1710,9 @@ int sdp_mod_usec = 0;
void
sdp_set_default_moderation(struct sdp_sock *ssk)
{
- struct ib_cq_attr attr;
if (sdp_mod_count <= 0 || sdp_mod_usec <= 0)
return;
- memset(&attr, 0, sizeof(attr));
- attr.moderation.cq_count = sdp_mod_count;
- attr.moderation.cq_period = sdp_mod_usec;
-
- ib_modify_cq(ssk->rx_ring.cq, &attr, IB_CQ_MODERATION);
+ ib_modify_cq(ssk->rx_ring.cq, sdp_mod_count, sdp_mod_usec);
}
static void
@@ -1719,12 +1722,9 @@ sdp_dev_add(struct ib_device *device)
struct sdp_device *sdp_dev;
sdp_dev = malloc(sizeof(*sdp_dev), M_SDP, M_WAITOK | M_ZERO);
- sdp_dev->pd = ib_alloc_pd(device);
+ sdp_dev->pd = ib_alloc_pd(device, 0);
if (IS_ERR(sdp_dev->pd))
goto out_pd;
- sdp_dev->mr = ib_get_dma_mr(sdp_dev->pd, IB_ACCESS_LOCAL_WRITE);
- if (IS_ERR(sdp_dev->mr))
- goto out_mr;
memset(&param, 0, sizeof param);
param.max_pages_per_fmr = SDP_FMR_SIZE;
param.page_shift = PAGE_SHIFT;
@@ -1739,15 +1739,13 @@ sdp_dev_add(struct ib_device *device)
return;
out_fmr:
- ib_dereg_mr(sdp_dev->mr);
-out_mr:
ib_dealloc_pd(sdp_dev->pd);
out_pd:
free(sdp_dev, M_SDP);
}
static void
-sdp_dev_rem(struct ib_device *device)
+sdp_dev_rem(struct ib_device *device, void *client_data)
{
struct sdp_device *sdp_dev;
struct sdp_sock *ssk;
@@ -1771,7 +1769,6 @@ sdp_dev_rem(struct ib_device *device)
return;
ib_flush_fmr_pool(sdp_dev->fmr_pool);
ib_destroy_fmr_pool(sdp_dev->fmr_pool);
- ib_dereg_mr(sdp_dev->mr);
ib_dealloc_pd(sdp_dev->pd);
free(sdp_dev, M_SDP);
}
@@ -1854,8 +1851,6 @@ sdp_pcblist(SYSCTL_HANDLER_ARGS)
xt.xt_tp.t_state = ssk->state;
if (ssk->socket != NULL)
sotoxsocket(ssk->socket, &xt.xt_socket);
- else
- bzero(&xt.xt_socket, sizeof xt.xt_socket);
xt.xt_socket.xso_protocol = IPPROTO_TCP;
SDP_RUNLOCK(ssk);
error = SYSCTL_OUT(req, &xt, sizeof xt);
diff --git a/sys/ofed/drivers/infiniband/ulp/sdp/sdp_proc.c b/sys/ofed/drivers/infiniband/ulp/sdp/sdp_proc.c
index 74bc04a..e9d9c6b 100644
--- a/sys/ofed/drivers/infiniband/ulp/sdp/sdp_proc.c
+++ b/sys/ofed/drivers/infiniband/ulp/sdp/sdp_proc.c
@@ -31,7 +31,6 @@
*/
#include <linux/proc_fs.h>
-#include <rdma/sdp_socket.h>
#include "sdp.h"
#ifdef CONFIG_PROC_FS
diff --git a/sys/ofed/drivers/infiniband/ulp/sdp/sdp_rx.c b/sys/ofed/drivers/infiniband/ulp/sdp/sdp_rx.c
index 7c6f6cb..5c68c07 100644
--- a/sys/ofed/drivers/infiniband/ulp/sdp/sdp_rx.c
+++ b/sys/ofed/drivers/infiniband/ulp/sdp/sdp_rx.c
@@ -1,4 +1,6 @@
-/*
+/*-
+ * SPDX-License-Identifier: BSD-2-Clause OR GPL-2.0
+ *
* Copyright (c) 2009 Mellanox Technologies Ltd. All rights reserved.
*
* This software is available to you under a choice of one of two
@@ -132,7 +134,7 @@ sdp_post_recv(struct sdp_sock *ssk)
rx_req->mapping[i] = addr;
sge->addr = addr;
sge->length = mb->m_len;
- sge->lkey = ssk->sdp_dev->mr->lkey;
+ sge->lkey = ssk->sdp_dev->pd->local_dma_lkey;
}
rx_wr.next = NULL;
@@ -175,7 +177,7 @@ sdp_post_recvs_needed(struct sdp_sock *ssk)
return 1;
buffer_size = ssk->recv_bytes;
- max_bytes = max(ssk->socket->so_snd.sb_hiwat,
+ max_bytes = max(ssk->socket->so_rcv.sb_hiwat,
(1 + SDP_MIN_TX_CREDITS) * buffer_size);
max_bytes *= rcvbuf_scale;
/*
@@ -319,14 +321,14 @@ sdp_recv_completion(struct sdp_sock *ssk, int id)
return mb;
}
-/* socket lock should be taken before calling this */
-static int
+static void
sdp_process_rx_ctl_mb(struct sdp_sock *ssk, struct mbuf *mb)
{
struct sdp_bsdh *h;
struct socket *sk;
SDP_WLOCK_ASSERT(ssk);
+
sk = ssk->socket;
h = mtod(mb, struct sdp_bsdh *);
switch (h->mid) {
@@ -339,16 +341,13 @@ sdp_process_rx_ctl_mb(struct sdp_sock *ssk, struct mbuf *mb)
sdp_dbg(sk, "RX data when state = FIN_WAIT1\n");
sdp_notify(ssk, ECONNRESET);
}
- m_freem(mb);
break;
#ifdef SDP_ZCOPY
case SDP_MID_RDMARDCOMPL:
- m_freem(mb);
break;
case SDP_MID_SENDSM:
sdp_handle_sendsm(ssk, ntohl(h->mseq_ack));
- m_freem(mb);
break;
case SDP_MID_SRCAVAIL_CANCEL:
sdp_dbg_data(sk, "Handling SrcAvailCancel\n");
@@ -362,7 +361,6 @@ sdp_process_rx_ctl_mb(struct sdp_sock *ssk, struct mbuf *mb)
sdp_dbg(sk, "Got SrcAvailCancel - "
"but no SrcAvail in process\n");
}
- m_freem(mb);
break;
case SDP_MID_SINKAVAIL:
sdp_dbg_data(sk, "Got SinkAvail - not supported: ignored\n");
@@ -373,7 +371,6 @@ sdp_process_rx_ctl_mb(struct sdp_sock *ssk, struct mbuf *mb)
sdp_dbg_data(sk, "Handling ABORT\n");
sdp_prf(sk, NULL, "Handling ABORT");
sdp_notify(ssk, ECONNRESET);
- m_freem(mb);
break;
case SDP_MID_DISCONN:
sdp_dbg_data(sk, "Handling DISCONN\n");
@@ -383,20 +380,17 @@ sdp_process_rx_ctl_mb(struct sdp_sock *ssk, struct mbuf *mb)
case SDP_MID_CHRCVBUF:
sdp_dbg_data(sk, "Handling RX CHRCVBUF\n");
sdp_handle_resize_request(ssk, (struct sdp_chrecvbuf *)(h+1));
- m_freem(mb);
break;
case SDP_MID_CHRCVBUF_ACK:
sdp_dbg_data(sk, "Handling RX CHRCVBUF_ACK\n");
sdp_handle_resize_ack(ssk, (struct sdp_chrecvbuf *)(h+1));
- m_freem(mb);
break;
default:
/* TODO: Handle other messages */
sdp_warn(sk, "SDP: FIXME MID %d\n", h->mid);
- m_freem(mb);
+ break;
}
-
- return 0;
+ m_freem(mb);
}
static int
@@ -459,14 +453,9 @@ sdp_process_rx_mb(struct sdp_sock *ssk, struct mbuf *mb)
ntohl(rrch->len));
}
#endif
- mb->m_nextpkt = NULL;
- if (ssk->rx_ctl_tail)
- ssk->rx_ctl_tail->m_nextpkt = mb;
- else
- ssk->rx_ctl_q = mb;
- ssk->rx_ctl_tail = mb;
-
- return 0;
+ if (mbufq_enqueue(&ssk->rxctlq, mb) != 0)
+ m_freem(mb);
+ return (0);
}
sdp_prf1(sk, NULL, "queueing %s mb\n", mid2str(h->mid));
@@ -611,11 +600,8 @@ sdp_do_posts(struct sdp_sock *ssk)
return;
}
- while ((mb = ssk->rx_ctl_q)) {
- ssk->rx_ctl_q = mb->m_nextpkt;
- mb->m_nextpkt = NULL;
+ while ((mb = mbufq_dequeue(&ssk->rxctlq)) != NULL)
sdp_process_rx_ctl_mb(ssk, mb);
- }
if (ssk->state == TCPS_TIME_WAIT)
return;
@@ -673,13 +659,11 @@ sdp_process_rx(struct sdp_sock *ssk)
static void
sdp_rx_irq(struct ib_cq *cq, void *cq_context)
{
- struct socket *sk = cq_context;
- struct sdp_sock *ssk = sdp_sk(sk);
+ struct sdp_sock *ssk;
- if (cq != ssk->rx_ring.cq) {
- sdp_dbg(sk, "cq = %p, ssk->cq = %p\n", cq, ssk->rx_ring.cq);
- return;
- }
+ ssk = cq_context;
+ KASSERT(cq == ssk->rx_ring.cq,
+ ("%s: mismatched cq on %p", __func__, ssk));
SDPSTATS_COUNTER_INC(rx_int_count);
@@ -716,28 +700,24 @@ sdp_rx_cq_event_handler(struct ib_event *event, void *data)
int
sdp_rx_ring_create(struct sdp_sock *ssk, struct ib_device *device)
{
+ struct ib_cq_init_attr rx_cq_attr = {
+ .cqe = SDP_RX_SIZE,
+ .comp_vector = 0,
+ .flags = 0,
+ };
struct ib_cq *rx_cq;
int rc = 0;
-
sdp_dbg(ssk->socket, "rx ring created");
INIT_WORK(&ssk->rx_comp_work, sdp_rx_comp_work);
atomic_set(&ssk->rx_ring.head, 1);
atomic_set(&ssk->rx_ring.tail, 1);
- ssk->rx_ring.buffer = kmalloc(
- sizeof *ssk->rx_ring.buffer * SDP_RX_SIZE, GFP_KERNEL);
- if (!ssk->rx_ring.buffer) {
- sdp_warn(ssk->socket,
- "Unable to allocate RX Ring size %zd.\n",
- sizeof(*ssk->rx_ring.buffer) * SDP_RX_SIZE);
-
- return -ENOMEM;
- }
+ ssk->rx_ring.buffer = malloc(sizeof(*ssk->rx_ring.buffer) * SDP_RX_SIZE,
+ M_SDP, M_WAITOK);
rx_cq = ib_create_cq(device, sdp_rx_irq, sdp_rx_cq_event_handler,
- ssk->socket, SDP_RX_SIZE, 0);
-
+ ssk, &rx_cq_attr);
if (IS_ERR(rx_cq)) {
rc = PTR_ERR(rx_cq);
sdp_warn(ssk->socket, "Unable to allocate RX CQ: %d.\n", rc);
@@ -750,7 +730,7 @@ sdp_rx_ring_create(struct sdp_sock *ssk, struct ib_device *device)
return 0;
err_cq:
- kfree(ssk->rx_ring.buffer);
+ free(ssk->rx_ring.buffer, M_SDP);
ssk->rx_ring.buffer = NULL;
return rc;
}
@@ -764,8 +744,7 @@ sdp_rx_ring_destroy(struct sdp_sock *ssk)
if (ssk->rx_ring.buffer) {
sdp_rx_ring_purge(ssk);
-
- kfree(ssk->rx_ring.buffer);
+ free(ssk->rx_ring.buffer, M_SDP);
ssk->rx_ring.buffer = NULL;
}
diff --git a/sys/ofed/drivers/infiniband/ulp/sdp/sdp_tx.c b/sys/ofed/drivers/infiniband/ulp/sdp/sdp_tx.c
index 8f2a2f0..1f8f9d1 100644
--- a/sys/ofed/drivers/infiniband/ulp/sdp/sdp_tx.c
+++ b/sys/ofed/drivers/infiniband/ulp/sdp/sdp_tx.c
@@ -131,7 +131,7 @@ sdp_post_send(struct sdp_sock *ssk, struct mbuf *mb)
tx_req->mapping[i] = addr;
sge->addr = addr;
sge->length = mb->m_len;
- sge->lkey = ssk->sdp_dev->mr->lkey;
+ sge->lkey = ssk->sdp_dev->pd->local_dma_lkey;
}
tx_wr.next = NULL;
tx_wr.wr_id = mseq | SDP_OP_SEND;
@@ -418,6 +418,11 @@ sdp_tx_cq_event_handler(struct ib_event *event, void *data)
int
sdp_tx_ring_create(struct sdp_sock *ssk, struct ib_device *device)
{
+ struct ib_cq_init_attr tx_cq_attr = {
+ .cqe = SDP_TX_SIZE,
+ .comp_vector = 0,
+ .flags = 0,
+ };
struct ib_cq *tx_cq;
int rc = 0;
@@ -427,19 +432,11 @@ sdp_tx_ring_create(struct sdp_sock *ssk, struct ib_device *device)
atomic_set(&ssk->tx_ring.head, 1);
atomic_set(&ssk->tx_ring.tail, 1);
- ssk->tx_ring.buffer = kzalloc(
- sizeof *ssk->tx_ring.buffer * SDP_TX_SIZE, GFP_KERNEL);
- if (!ssk->tx_ring.buffer) {
- rc = -ENOMEM;
- sdp_warn(ssk->socket, "Can't allocate TX Ring size %zd.\n",
- sizeof(*ssk->tx_ring.buffer) * SDP_TX_SIZE);
-
- goto out;
- }
+ ssk->tx_ring.buffer = malloc(sizeof(*ssk->tx_ring.buffer) * SDP_TX_SIZE,
+ M_SDP, M_WAITOK);
tx_cq = ib_create_cq(device, sdp_tx_irq, sdp_tx_cq_event_handler,
- ssk, SDP_TX_SIZE, 0);
-
+ ssk, &tx_cq_attr);
if (IS_ERR(tx_cq)) {
rc = PTR_ERR(tx_cq);
sdp_warn(ssk->socket, "Unable to allocate TX CQ: %d.\n", rc);
@@ -452,9 +449,8 @@ sdp_tx_ring_create(struct sdp_sock *ssk, struct ib_device *device)
return 0;
err_cq:
- kfree(ssk->tx_ring.buffer);
+ free(ssk->tx_ring.buffer, M_SDP);
ssk->tx_ring.buffer = NULL;
-out:
return rc;
}
@@ -472,8 +468,7 @@ sdp_tx_ring_destroy(struct sdp_sock *ssk)
if (ssk->tx_ring.buffer) {
sdp_tx_ring_purge(ssk);
-
- kfree(ssk->tx_ring.buffer);
+ free(ssk->tx_ring.buffer, M_SDP);
ssk->tx_ring.buffer = NULL;
}
diff --git a/sys/ofed/drivers/infiniband/util/Kconfig b/sys/ofed/drivers/infiniband/util/Kconfig
deleted file mode 100644
index 5e98eaa..0000000
--- a/sys/ofed/drivers/infiniband/util/Kconfig
+++ /dev/null
@@ -1,6 +0,0 @@
-config INFINIBAND_MADEYE
- tristate "MAD debug viewer for InfiniBand"
- depends on INFINIBAND
- ---help---
- Prints sent and received MADs on QP 0/1 for debugging.
-
diff --git a/sys/ofed/include/rdma/ib.h b/sys/ofed/include/rdma/ib.h
new file mode 100644
index 0000000..8d4aefc
--- /dev/null
+++ b/sys/ofed/include/rdma/ib.h
@@ -0,0 +1,120 @@
+/*
+ * Copyright (c) 2010 Intel Corporation. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#if !defined(_RDMA_IB_H)
+#define _RDMA_IB_H
+
+#include <linux/types.h>
+#include <linux/sched.h>
+#include <linux/file.h>
+
+/*
+ * Define a native infiniband address as in Linux upstream
+ * 8d36eb01da5d371feffa280e501377b5c450f5a5
+ */
+#define AF_IB 41
+
+struct ib_addr {
+ union {
+ __u8 uib_addr8[16];
+ __be16 uib_addr16[8];
+ __be32 uib_addr32[4];
+ __be64 uib_addr64[2];
+ } ib_u;
+#define sib_addr8 ib_u.uib_addr8
+#define sib_addr16 ib_u.uib_addr16
+#define sib_addr32 ib_u.uib_addr32
+#define sib_addr64 ib_u.uib_addr64
+#define sib_raw ib_u.uib_addr8
+#define sib_subnet_prefix ib_u.uib_addr64[0]
+#define sib_interface_id ib_u.uib_addr64[1]
+};
+
+static inline int ib_addr_any(const struct ib_addr *a)
+{
+ return ((a->sib_addr64[0] | a->sib_addr64[1]) == 0);
+}
+
+static inline int ib_addr_loopback(const struct ib_addr *a)
+{
+ return ((a->sib_addr32[0] | a->sib_addr32[1] |
+ a->sib_addr32[2] | (a->sib_addr32[3] ^ htonl(1))) == 0);
+}
+
+static inline void ib_addr_set(struct ib_addr *addr,
+ __be32 w1, __be32 w2, __be32 w3, __be32 w4)
+{
+ addr->sib_addr32[0] = w1;
+ addr->sib_addr32[1] = w2;
+ addr->sib_addr32[2] = w3;
+ addr->sib_addr32[3] = w4;
+}
+
+static inline int ib_addr_cmp(const struct ib_addr *a1, const struct ib_addr *a2)
+{
+ return memcmp(a1, a2, sizeof(struct ib_addr));
+}
+
+struct sockaddr_ib {
+ unsigned short int sib_family; /* AF_IB */
+ __be16 sib_pkey;
+ __be32 sib_flowinfo;
+ struct ib_addr sib_addr;
+ __be64 sib_sid;
+ __be64 sib_sid_mask;
+ __u64 sib_scope_id;
+};
+
+/*
+ * The IB interfaces that use write() as bi-directional ioctl() are
+ * fundamentally unsafe, since there are lots of ways to trigger "write()"
+ * calls from various contexts with elevated privileges. That includes the
+ * traditional suid executable error message writes, but also various kernel
+ * interfaces that can write to file descriptors.
+ *
+ * This function provides protection for the legacy API by restricting the
+ * calling context.
+ */
+static inline bool ib_safe_file_access(struct file *filp)
+{
+ struct thread *td = curthread;
+
+ /*
+ * Check if called from userspace through a devfs related
+ * system call belonging to the given file:
+ */
+ return (filp->_file != NULL &&
+ filp->_file == td->td_fpop &&
+ filp->_file->f_cred == td->td_ucred);
+}
+
+#endif /* _RDMA_IB_H */
diff --git a/sys/ofed/include/rdma/ib_addr.h b/sys/ofed/include/rdma/ib_addr.h
index f2ae0d3..2c27977 100644
--- a/sys/ofed/include/rdma/ib_addr.h
+++ b/sys/ofed/include/rdma/ib_addr.h
@@ -31,7 +31,7 @@
* SOFTWARE.
*/
-#ifndef IB_ADDR_H
+#if !defined(IB_ADDR_H)
#define IB_ADDR_H
#include <linux/in.h>
@@ -41,9 +41,11 @@
#include <linux/inetdevice.h>
#include <linux/socket.h>
#include <linux/if_vlan.h>
+#include <net/ipv6.h>
+#include <net/if_inet6.h>
+#include <net/ip.h>
#include <rdma/ib_verbs.h>
#include <rdma/ib_pack.h>
-#include <net/if_inet6.h>
#include <net/ipv6.h>
struct rdma_addr_client {
@@ -62,6 +64,17 @@ void rdma_addr_register_client(struct rdma_addr_client *client);
*/
void rdma_addr_unregister_client(struct rdma_addr_client *client);
+/**
+ * struct rdma_dev_addr - Contains resolved RDMA hardware addresses
+ * @src_dev_addr: Source MAC address.
+ * @dst_dev_addr: Destination MAC address.
+ * @broadcast: Broadcast address of the device.
+ * @dev_type: The interface hardware type of the device.
+ * @bound_dev_if: An optional device interface index.
+ * @transport: The transport type used.
+ * @net: Network namespace containing the bound_dev_if net_dev.
+ */
+struct vnet;
struct rdma_dev_addr {
unsigned char src_dev_addr[MAX_ADDR_LEN];
unsigned char dst_dev_addr[MAX_ADDR_LEN];
@@ -69,14 +82,19 @@ struct rdma_dev_addr {
unsigned short dev_type;
int bound_dev_if;
enum rdma_transport_type transport;
+ struct vnet *net;
+ enum rdma_network_type network;
+ int hoplimit;
};
/**
* rdma_translate_ip - Translate a local IP address to an RDMA hardware
* address.
+ *
+ * The dev_addr->net field must be initialized.
*/
-int rdma_translate_ip(struct sockaddr *addr, struct rdma_dev_addr *dev_addr,
- u16 *vlan_id);
+int rdma_translate_ip(const struct sockaddr *addr,
+ struct rdma_dev_addr *dev_addr, u16 *vlan_id);
/**
* rdma_resolve_ip - Resolve source and destination IP addresses to
@@ -88,7 +106,7 @@ int rdma_translate_ip(struct sockaddr *addr, struct rdma_dev_addr *dev_addr,
* @dst_addr: The destination address to resolve.
* @addr: A reference to a data location that will receive the resolved
* addresses. The data location must remain valid until the callback has
- * been invoked.
+ * been invoked. The net field of the addr struct must be valid.
* @timeout_ms: Amount of time to wait for the address resolution to complete.
* @callback: Call invoked once address resolution has completed, timed out,
* or been canceled. A status of 0 indicates success.
@@ -101,19 +119,22 @@ int rdma_resolve_ip(struct rdma_addr_client *client,
struct rdma_dev_addr *addr, void *context),
void *context);
+int rdma_resolve_ip_route(struct sockaddr *src_addr,
+ const struct sockaddr *dst_addr,
+ struct rdma_dev_addr *addr);
+
void rdma_addr_cancel(struct rdma_dev_addr *addr);
int rdma_copy_addr(struct rdma_dev_addr *dev_addr, struct net_device *dev,
const unsigned char *dst_dev_addr);
-int rdma_addr_find_smac_by_sgid(union ib_gid *sgid, u8 *smac, u16 *vlan_id);
-int rdma_addr_find_dmac_by_grh(union ib_gid *sgid, union ib_gid *dgid, u8 *smac,
- u16 *vlan_id, int *if_index);
-static inline int ip_addr_size(struct sockaddr *addr)
-{
- return addr->sa_family == AF_INET6 ?
- sizeof(struct sockaddr_in6) : sizeof(struct sockaddr_in);
-}
+int rdma_addr_size(struct sockaddr *addr);
+
+int rdma_addr_find_smac_by_sgid(union ib_gid *sgid, u8 *smac, u16 *vlan_id);
+int rdma_addr_find_l2_eth_by_grh(const union ib_gid *sgid,
+ const union ib_gid *dgid,
+ u8 *smac, u16 *vlan_id, int *if_index,
+ int *hoplimit);
static inline u16 ib_addr_get_pkey(struct rdma_dev_addr *dev_addr)
{
@@ -146,16 +167,16 @@ static inline u16 rdma_vlan_dev_vlan_id(const struct net_device *dev)
return tag;
}
-static inline int rdma_ip2gid(struct sockaddr *addr, union ib_gid *gid)
+static inline int rdma_ip2gid(const struct sockaddr *addr, union ib_gid *gid)
{
switch (addr->sa_family) {
case AF_INET:
- ipv6_addr_set_v4mapped(((struct sockaddr_in *)addr)->sin_addr.s_addr,
+ ipv6_addr_set_v4mapped(((const struct sockaddr_in *)
+ addr)->sin_addr.s_addr,
(struct in6_addr *)gid);
break;
case AF_INET6:
- memcpy(gid->raw, &((struct sockaddr_in6 *)addr)->sin6_addr,
- 16);
+ memcpy(gid->raw, &((const struct sockaddr_in6 *)addr)->sin6_addr, 16);
/* make sure scope ID gets zeroed inside GID */
if (IN6_IS_SCOPE_LINKLOCAL((struct in6_addr *)gid->raw) ||
IN6_IS_ADDR_MC_INTFACELOCAL((struct in6_addr *)gid->raw)) {
@@ -170,9 +191,9 @@ static inline int rdma_ip2gid(struct sockaddr *addr, union ib_gid *gid)
}
/* Important - sockaddr should be a union of sockaddr_in and sockaddr_in6 */
-static inline int rdma_gid2ip(struct sockaddr *out, union ib_gid *gid)
+static inline void rdma_gid2ip(struct sockaddr *out, const union ib_gid *gid)
{
- if (ipv6_addr_v4mapped((struct in6_addr *)gid)) {
+ if (ipv6_addr_v4mapped((const struct in6_addr *)gid)) {
struct sockaddr_in *out_in = (struct sockaddr_in *)out;
memset(out_in, 0, sizeof(*out_in));
out_in->sin_len = sizeof(*out_in);
@@ -185,15 +206,27 @@ static inline int rdma_gid2ip(struct sockaddr *out, union ib_gid *gid)
out_in->sin6_family = AF_INET6;
memcpy(&out_in->sin6_addr.s6_addr, gid->raw, 16);
}
- return 0;
}
-/* This func is called only in loopback ip address (127.0.0.1)
- * case in which sgid is not relevant
- */
static inline void iboe_addr_get_sgid(struct rdma_dev_addr *dev_addr,
union ib_gid *gid)
{
+ struct net_device *dev;
+ struct ifaddr *ifa;
+
+ dev = dev_get_by_index(&init_net, dev_addr->bound_dev_if);
+ if (dev) {
+ TAILQ_FOREACH(ifa, &dev->if_addrhead, ifa_link) {
+ if (ifa->ifa_addr == NULL ||
+ ifa->ifa_addr->sa_family != AF_INET)
+ continue;
+ ipv6_addr_set_v4mapped(((struct sockaddr_in *)
+ ifa->ifa_addr)->sin_addr.s_addr,
+ (struct in6_addr *)gid);
+ break;
+ }
+ dev_put(dev);
+ }
}
static inline void rdma_addr_get_sgid(struct rdma_dev_addr *dev_addr, union ib_gid *gid)
@@ -245,13 +278,19 @@ static inline enum ib_mtu iboe_get_mtu(int mtu)
static inline int iboe_get_rate(struct net_device *dev)
{
- if (dev->if_baudrate >= IF_Gbps(40))
+ uint64_t baudrate = dev->if_baudrate;
+#ifdef if_baudrate_pf
+ int exp;
+ for (exp = dev->if_baudrate_pf; exp > 0; exp--)
+ baudrate *= 10;
+#endif
+ if (baudrate >= IF_Gbps(40))
return IB_RATE_40_GBPS;
- else if (dev->if_baudrate >= IF_Gbps(30))
+ else if (baudrate >= IF_Gbps(30))
return IB_RATE_30_GBPS;
- else if (dev->if_baudrate >= IF_Gbps(20))
+ else if (baudrate >= IF_Gbps(20))
return IB_RATE_20_GBPS;
- else if (dev->if_baudrate >= IF_Gbps(10))
+ else if (baudrate >= IF_Gbps(10))
return IB_RATE_10_GBPS;
else
return IB_RATE_PORT_CURRENT;
@@ -278,20 +317,6 @@ static inline int rdma_is_multicast_addr(struct in6_addr *addr)
return addr->s6_addr[0] == 0xff;
}
-static inline void resolve_mcast_mac(struct in6_addr *addr, u8 *mac)
-{
- if (addr->s6_addr[0] != 0xff)
- return;
-
-#ifdef DUAL_MODE_MCAST_MAC
- if (addr->s6_addr[1] == 0x0e) /* IPv4 */
- ip_eth_mc_map(addr->s6_addr32[3], mac);
- else
-#endif
- ipv6_eth_mc_map(addr, mac);
-}
-
-
static inline void rdma_get_mcast_mac(struct in6_addr *addr, u8 *mac)
{
int i;
@@ -307,7 +332,7 @@ static inline u16 rdma_get_vlan_id(union ib_gid *dgid)
u16 vid;
vid = dgid->raw[11] << 8 | dgid->raw[12];
- return vid < 0x1000 ? vid : 0xffff;
+ return vid < 0x1000 ? vid : 0xffff;
}
static inline struct net_device *rdma_vlan_dev_real_dev(const struct net_device *dev)
diff --git a/sys/ofed/include/rdma/ib_cache.h b/sys/ofed/include/rdma/ib_cache.h
index ad9a3c2..e30f19b 100644
--- a/sys/ofed/include/rdma/ib_cache.h
+++ b/sys/ofed/include/rdma/ib_cache.h
@@ -43,6 +43,8 @@
* @port_num: The port number of the device to query.
* @index: The index into the cached GID table to query.
* @gid: The GID value found at the specified index.
+ * @attr: The GID attribute found at the specified index (only in RoCE).
+ * NULL means ignore (output parameter).
*
* ib_get_cached_gid() fetches the specified GID table entry stored in
* the local software cache.
@@ -50,13 +52,16 @@
int ib_get_cached_gid(struct ib_device *device,
u8 port_num,
int index,
- union ib_gid *gid);
+ union ib_gid *gid,
+ struct ib_gid_attr *attr);
/**
* ib_find_cached_gid - Returns the port number and GID table index where
* a specified GID value occurs.
* @device: The device to query.
* @gid: The GID value to search for.
+ * @gid_type: The GID type to search for.
+ * @ndev: In RoCE, the net device of the device. NULL means ignore.
* @port_num: The port number of the device where the GID value was found.
* @index: The index into the cached GID table where the GID was found. This
* parameter may be NULL.
@@ -65,11 +70,42 @@ int ib_get_cached_gid(struct ib_device *device,
* the local software cache.
*/
int ib_find_cached_gid(struct ib_device *device,
- union ib_gid *gid,
+ const union ib_gid *gid,
+ enum ib_gid_type gid_type,
+ struct net_device *ndev,
u8 *port_num,
u16 *index);
/**
+ * ib_find_cached_gid_by_port - Returns the GID table index where a specified
+ * GID value occurs
+ * @device: The device to query.
+ * @gid: The GID value to search for.
+ * @gid_type: The GID type to search for.
+ * @port_num: The port number of the device where the GID value sould be
+ * searched.
+ * @ndev: In RoCE, the net device of the device. Null means ignore.
+ * @index: The index into the cached GID table where the GID was found. This
+ * parameter may be NULL.
+ *
+ * ib_find_cached_gid() searches for the specified GID value in
+ * the local software cache.
+ */
+int ib_find_cached_gid_by_port(struct ib_device *device,
+ const union ib_gid *gid,
+ enum ib_gid_type gid_type,
+ u8 port_num,
+ struct net_device *ndev,
+ u16 *index);
+
+int ib_find_gid_by_filter(struct ib_device *device,
+ const union ib_gid *gid,
+ u8 port_num,
+ bool (*filter)(const union ib_gid *gid,
+ const struct ib_gid_attr *,
+ void *),
+ void *context, u16 *index);
+/**
* ib_get_cached_pkey - Returns a cached PKey table entry
* @device: The device to query.
* @port_num: The port number of the device to query.
diff --git a/sys/ofed/include/rdma/ib_cm.h b/sys/ofed/include/rdma/ib_cm.h
index a7ffaf9..92a7d85 100644
--- a/sys/ofed/include/rdma/ib_cm.h
+++ b/sys/ofed/include/rdma/ib_cm.h
@@ -105,13 +105,16 @@ enum ib_cm_data_size {
IB_CM_SIDR_REQ_PRIVATE_DATA_SIZE = 216,
IB_CM_SIDR_REP_PRIVATE_DATA_SIZE = 136,
IB_CM_SIDR_REP_INFO_LENGTH = 72,
- IB_CM_COMPARE_SIZE = 64
};
struct ib_cm_id;
struct ib_cm_req_event_param {
struct ib_cm_id *listen_id;
+
+ /* P_Key that was used by the GMP's BTH header */
+ u16 bth_pkey;
+
u8 port;
struct ib_sa_path_rec *primary_path;
@@ -222,6 +225,9 @@ struct ib_cm_apr_event_param {
struct ib_cm_sidr_req_event_param {
struct ib_cm_id *listen_id;
+ __be64 service_id;
+ /* P_Key that was used by the GMP's BTH header */
+ u16 bth_pkey;
u8 port;
u16 pkey;
};
@@ -336,11 +342,6 @@ void ib_destroy_cm_id(struct ib_cm_id *cm_id);
#define IB_SDP_SERVICE_ID cpu_to_be64(0x0000000000010000ULL)
#define IB_SDP_SERVICE_ID_MASK cpu_to_be64(0xFFFFFFFFFFFF0000ULL)
-struct ib_cm_compare_data {
- u8 data[IB_CM_COMPARE_SIZE];
- u8 mask[IB_CM_COMPARE_SIZE];
-};
-
/**
* ib_cm_listen - Initiates listening on the specified service ID for
* connection and service ID resolution requests.
@@ -353,12 +354,13 @@ struct ib_cm_compare_data {
* range of service IDs. If set to 0, the service ID is matched
* exactly. This parameter is ignored if %service_id is set to
* IB_CM_ASSIGN_SERVICE_ID.
- * @compare_data: This parameter is optional. It specifies data that must
- * appear in the private data of a connection request for the specified
- * listen request.
*/
-int ib_cm_listen(struct ib_cm_id *cm_id, __be64 service_id, __be64 service_mask,
- struct ib_cm_compare_data *compare_data);
+int ib_cm_listen(struct ib_cm_id *cm_id, __be64 service_id,
+ __be64 service_mask);
+
+struct ib_cm_id *ib_cm_insert_listen(struct ib_device *device,
+ ib_cm_handler cm_handler,
+ __be64 service_id);
struct ib_cm_req_param {
struct ib_sa_path_rec *primary_path;
@@ -601,6 +603,4 @@ struct ib_cm_sidr_rep_param {
int ib_send_cm_sidr_rep(struct ib_cm_id *cm_id,
struct ib_cm_sidr_rep_param *param);
-int ib_update_cm_av(struct ib_cm_id *id, const u8 *smac, const u8 *alt_smac);
-
#endif /* IB_CM_H */
diff --git a/sys/ofed/include/rdma/ib_hdrs.h b/sys/ofed/include/rdma/ib_hdrs.h
new file mode 100644
index 0000000..408439f
--- /dev/null
+++ b/sys/ofed/include/rdma/ib_hdrs.h
@@ -0,0 +1,178 @@
+/*
+ * Copyright(c) 2016 Intel Corporation.
+ *
+ * This file is provided under a dual BSD/GPLv2 license. When using or
+ * redistributing this file, you may do so under either license.
+ *
+ * GPL LICENSE SUMMARY
+ *
+ * This program 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.
+ *
+ * This program 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.
+ *
+ * BSD LICENSE
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * - Neither the name of Intel Corporation nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+
+#ifndef IB_HDRS_H
+#define IB_HDRS_H
+
+#include <linux/types.h>
+#include <asm/unaligned.h>
+#include <rdma/ib_verbs.h>
+
+#define IB_SEQ_NAK (3 << 29)
+
+/* AETH NAK opcode values */
+#define IB_RNR_NAK 0x20
+#define IB_NAK_PSN_ERROR 0x60
+#define IB_NAK_INVALID_REQUEST 0x61
+#define IB_NAK_REMOTE_ACCESS_ERROR 0x62
+#define IB_NAK_REMOTE_OPERATIONAL_ERROR 0x63
+#define IB_NAK_INVALID_RD_REQUEST 0x64
+
+#define IB_BTH_REQ_ACK BIT(31)
+#define IB_BTH_SOLICITED BIT(23)
+#define IB_BTH_MIG_REQ BIT(22)
+
+#define IB_GRH_VERSION 6
+#define IB_GRH_VERSION_MASK 0xF
+#define IB_GRH_VERSION_SHIFT 28
+#define IB_GRH_TCLASS_MASK 0xFF
+#define IB_GRH_TCLASS_SHIFT 20
+#define IB_GRH_FLOW_MASK 0xFFFFF
+#define IB_GRH_FLOW_SHIFT 0
+#define IB_GRH_NEXT_HDR 0x1B
+
+struct ib_reth {
+ __be64 vaddr; /* potentially unaligned */
+ __be32 rkey;
+ __be32 length;
+} __packed;
+
+struct ib_atomic_eth {
+ __be64 vaddr; /* potentially unaligned */
+ __be32 rkey;
+ __be64 swap_data; /* potentially unaligned */
+ __be64 compare_data; /* potentially unaligned */
+} __packed;
+
+union ib_ehdrs {
+ struct {
+ __be32 deth[2];
+ __be32 imm_data;
+ } ud;
+ struct {
+ struct ib_reth reth;
+ __be32 imm_data;
+ } rc;
+ struct {
+ __be32 aeth;
+ __be64 atomic_ack_eth; /* potentially unaligned */
+ } __packed at;
+ __be32 imm_data;
+ __be32 aeth;
+ __be32 ieth;
+ struct ib_atomic_eth atomic_eth;
+} __packed;
+
+struct ib_other_headers {
+ __be32 bth[3];
+ union ib_ehdrs u;
+} __packed;
+
+struct ib_header {
+ __be16 lrh[4];
+ union {
+ struct {
+ struct ib_grh grh;
+ struct ib_other_headers oth;
+ } l;
+ struct ib_other_headers oth;
+ } u;
+} __packed;
+
+/* accessors for unaligned __be64 items */
+
+static inline u64 ib_u64_get(__be64 *p)
+{
+ return get_unaligned_be64(p);
+}
+
+static inline void ib_u64_put(u64 val, __be64 *p)
+{
+ put_unaligned_be64(val, p);
+}
+
+static inline u64 get_ib_reth_vaddr(struct ib_reth *reth)
+{
+ return ib_u64_get(&reth->vaddr);
+}
+
+static inline void put_ib_reth_vaddr(u64 val, struct ib_reth *reth)
+{
+ ib_u64_put(val, &reth->vaddr);
+}
+
+static inline u64 get_ib_ateth_vaddr(struct ib_atomic_eth *ateth)
+{
+ return ib_u64_get(&ateth->vaddr);
+}
+
+static inline void put_ib_ateth_vaddr(u64 val, struct ib_atomic_eth *ateth)
+{
+ ib_u64_put(val, &ateth->vaddr);
+}
+
+static inline u64 get_ib_ateth_swap(struct ib_atomic_eth *ateth)
+{
+ return ib_u64_get(&ateth->swap_data);
+}
+
+static inline void put_ib_ateth_swap(u64 val, struct ib_atomic_eth *ateth)
+{
+ ib_u64_put(val, &ateth->swap_data);
+}
+
+static inline u64 get_ib_ateth_compare(struct ib_atomic_eth *ateth)
+{
+ return ib_u64_get(&ateth->compare_data);
+}
+
+static inline void put_ib_ateth_compare(u64 val, struct ib_atomic_eth *ateth)
+{
+ ib_u64_put(val, &ateth->compare_data);
+}
+
+#endif /* IB_HDRS_H */
diff --git a/sys/ofed/include/rdma/ib_mad.h b/sys/ofed/include/rdma/ib_mad.h
index 1a7fb1a..9b02d11 100644
--- a/sys/ofed/include/rdma/ib_mad.h
+++ b/sys/ofed/include/rdma/ib_mad.h
@@ -40,9 +40,13 @@
#include <linux/list.h>
#include <rdma/ib_verbs.h>
+#include <rdma/ib_user_mad.h>
-/* Management base version */
+/* Management base versions */
#define IB_MGMT_BASE_VERSION 1
+#define OPA_MGMT_BASE_VERSION 0x80
+
+#define OPA_SMP_CLASS_VERSION 0x80
/* Management classes */
#define IB_MGMT_CLASS_SUBN_LID_ROUTED 0x01
@@ -123,6 +127,23 @@
#define IB_DEFAULT_PKEY_PARTIAL 0x7FFF
#define IB_DEFAULT_PKEY_FULL 0xFFFF
+/*
+ * Generic trap/notice types
+ */
+#define IB_NOTICE_TYPE_FATAL 0x80
+#define IB_NOTICE_TYPE_URGENT 0x81
+#define IB_NOTICE_TYPE_SECURITY 0x82
+#define IB_NOTICE_TYPE_SM 0x83
+#define IB_NOTICE_TYPE_INFO 0x84
+
+/*
+ * Generic trap/notice producers
+ */
+#define IB_NOTICE_PROD_CA cpu_to_be16(1)
+#define IB_NOTICE_PROD_SWITCH cpu_to_be16(2)
+#define IB_NOTICE_PROD_ROUTER cpu_to_be16(3)
+#define IB_NOTICE_PROD_CLASS_MGR cpu_to_be16(4)
+
enum {
IB_MGMT_MAD_HDR = 24,
IB_MGMT_MAD_DATA = 232,
@@ -135,6 +156,9 @@ enum {
IB_MGMT_DEVICE_HDR = 64,
IB_MGMT_DEVICE_DATA = 192,
IB_MGMT_MAD_SIZE = IB_MGMT_MAD_HDR + IB_MGMT_MAD_DATA,
+ OPA_MGMT_MAD_DATA = 2024,
+ OPA_MGMT_RMPP_DATA = 2012,
+ OPA_MGMT_MAD_SIZE = IB_MGMT_MAD_HDR + OPA_MGMT_MAD_DATA,
};
struct ib_mad_hdr {
@@ -181,12 +205,23 @@ struct ib_mad {
u8 data[IB_MGMT_MAD_DATA];
};
+struct opa_mad {
+ struct ib_mad_hdr mad_hdr;
+ u8 data[OPA_MGMT_MAD_DATA];
+};
+
struct ib_rmpp_mad {
struct ib_mad_hdr mad_hdr;
struct ib_rmpp_hdr rmpp_hdr;
u8 data[IB_MGMT_RMPP_DATA];
};
+struct opa_rmpp_mad {
+ struct ib_mad_hdr mad_hdr;
+ struct ib_rmpp_hdr rmpp_hdr;
+ u8 data[OPA_MGMT_RMPP_DATA];
+};
+
struct ib_sa_mad {
struct ib_mad_hdr mad_hdr;
struct ib_rmpp_hdr rmpp_hdr;
@@ -202,12 +237,17 @@ struct ib_vendor_mad {
u8 data[IB_MGMT_VENDOR_DATA];
};
+#define IB_MGMT_CLASSPORTINFO_ATTR_ID cpu_to_be16(0x0001)
+
+#define IB_CLASS_PORT_INFO_RESP_TIME_MASK 0x1F
+#define IB_CLASS_PORT_INFO_RESP_TIME_FIELD_SIZE 5
+
struct ib_class_port_info {
u8 base_version;
u8 class_version;
__be16 capability_mask;
- u8 reserved[3];
- u8 resp_time_value;
+ /* 27 bits for cap_mask2, 5 bits for resp_time */
+ __be32 cap_mask2_resp_time;
u8 redirect_gid[16];
__be32 redirect_tcslfl;
__be16 redirect_lid;
@@ -223,6 +263,123 @@ struct ib_class_port_info {
};
/**
+ * ib_get_cpi_resp_time - Returns the resp_time value from
+ * cap_mask2_resp_time in ib_class_port_info.
+ * @cpi: A struct ib_class_port_info mad.
+ */
+static inline u8 ib_get_cpi_resp_time(struct ib_class_port_info *cpi)
+{
+ return (u8)(be32_to_cpu(cpi->cap_mask2_resp_time) &
+ IB_CLASS_PORT_INFO_RESP_TIME_MASK);
+}
+
+/**
+ * ib_set_cpi_resptime - Sets the response time in an
+ * ib_class_port_info mad.
+ * @cpi: A struct ib_class_port_info.
+ * @rtime: The response time to set.
+ */
+static inline void ib_set_cpi_resp_time(struct ib_class_port_info *cpi,
+ u8 rtime)
+{
+ cpi->cap_mask2_resp_time =
+ (cpi->cap_mask2_resp_time &
+ cpu_to_be32(~IB_CLASS_PORT_INFO_RESP_TIME_MASK)) |
+ cpu_to_be32(rtime & IB_CLASS_PORT_INFO_RESP_TIME_MASK);
+}
+
+/**
+ * ib_get_cpi_capmask2 - Returns the capmask2 value from
+ * cap_mask2_resp_time in ib_class_port_info.
+ * @cpi: A struct ib_class_port_info mad.
+ */
+static inline u32 ib_get_cpi_capmask2(struct ib_class_port_info *cpi)
+{
+ return (be32_to_cpu(cpi->cap_mask2_resp_time) >>
+ IB_CLASS_PORT_INFO_RESP_TIME_FIELD_SIZE);
+}
+
+/**
+ * ib_set_cpi_capmask2 - Sets the capmask2 in an
+ * ib_class_port_info mad.
+ * @cpi: A struct ib_class_port_info.
+ * @capmask2: The capmask2 to set.
+ */
+static inline void ib_set_cpi_capmask2(struct ib_class_port_info *cpi,
+ u32 capmask2)
+{
+ cpi->cap_mask2_resp_time =
+ (cpi->cap_mask2_resp_time &
+ cpu_to_be32(IB_CLASS_PORT_INFO_RESP_TIME_MASK)) |
+ cpu_to_be32(capmask2 <<
+ IB_CLASS_PORT_INFO_RESP_TIME_FIELD_SIZE);
+}
+
+struct ib_mad_notice_attr {
+ u8 generic_type;
+ u8 prod_type_msb;
+ __be16 prod_type_lsb;
+ __be16 trap_num;
+ __be16 issuer_lid;
+ __be16 toggle_count;
+
+ union {
+ struct {
+ u8 details[54];
+ } raw_data;
+
+ struct {
+ __be16 reserved;
+ __be16 lid; /* where violation happened */
+ u8 port_num; /* where violation happened */
+ } __packed ntc_129_131;
+
+ struct {
+ __be16 reserved;
+ __be16 lid; /* LID where change occurred */
+ u8 reserved2;
+ u8 local_changes; /* low bit - local changes */
+ __be32 new_cap_mask; /* new capability mask */
+ u8 reserved3;
+ u8 change_flags; /* low 3 bits only */
+ } __packed ntc_144;
+
+ struct {
+ __be16 reserved;
+ __be16 lid; /* lid where sys guid changed */
+ __be16 reserved2;
+ __be64 new_sys_guid;
+ } __packed ntc_145;
+
+ struct {
+ __be16 reserved;
+ __be16 lid;
+ __be16 dr_slid;
+ u8 method;
+ u8 reserved2;
+ __be16 attr_id;
+ __be32 attr_mod;
+ __be64 mkey;
+ u8 reserved3;
+ u8 dr_trunc_hop;
+ u8 dr_rtn_path[30];
+ } __packed ntc_256;
+
+ struct {
+ __be16 reserved;
+ __be16 lid1;
+ __be16 lid2;
+ __be32 key;
+ __be32 sl_qp1; /* SL: high 4 bits */
+ __be32 qp2; /* high 8 bits reserved */
+ union ib_gid gid1;
+ union ib_gid gid2;
+ } __packed ntc_257_258;
+
+ } details;
+};
+
+/**
* ib_mad_send_buf - MAD data buffer and work request for sends.
* @next: A pointer used to chain together MADs for posting.
* @mad: References an allocated MAD data buffer for MADs that do not have
@@ -235,7 +392,10 @@ struct ib_class_port_info {
* includes the common MAD, RMPP, and class specific headers.
* @data_len: Indicates the total size of user-transferred data.
* @seg_count: The number of RMPP segments allocated for this send.
- * @seg_size: Size of each RMPP segment.
+ * @seg_size: Size of the data in each RMPP segment. This does not include
+ * class specific headers.
+ * @seg_rmpp_size: Size of each RMPP segment including the class specific
+ * headers.
* @timeout_ms: Time to wait for a response.
* @retries: Number of times to retry a request for a response. For MADs
* using RMPP, this applies per window. On completion, returns the number
@@ -255,6 +415,7 @@ struct ib_mad_send_buf {
int data_len;
int seg_count;
int seg_size;
+ int seg_rmpp_size;
int timeout_ms;
int retries;
};
@@ -263,7 +424,7 @@ struct ib_mad_send_buf {
* ib_response_mad - Returns if the specified MAD has been generated in
* response to a sent request or trap.
*/
-int ib_response_mad(struct ib_mad *mad);
+int ib_response_mad(const struct ib_mad_hdr *hdr);
/**
* ib_get_rmpp_resptime - Returns the RMPP response time.
@@ -278,7 +439,7 @@ static inline u8 ib_get_rmpp_resptime(struct ib_rmpp_hdr *rmpp_hdr)
* ib_get_rmpp_flags - Returns the RMPP flags.
* @rmpp_hdr: An RMPP header.
*/
-static inline u8 ib_get_rmpp_flags(struct ib_rmpp_hdr *rmpp_hdr)
+static inline u8 ib_get_rmpp_flags(const struct ib_rmpp_hdr *rmpp_hdr)
{
return rmpp_hdr->rmpp_rtime_flags & 0x7;
}
@@ -319,11 +480,11 @@ typedef void (*ib_mad_send_handler)(struct ib_mad_agent *mad_agent,
/**
* ib_mad_snoop_handler - Callback handler for snooping sent MADs.
* @mad_agent: MAD agent that snooped the MAD.
- * @send_wr: Work request information on the sent MAD.
+ * @send_buf: send MAD data buffer.
* @mad_send_wc: Work completion information on the sent MAD. Valid
* only for snooping that occurs on a send completion.
*
- * Clients snooping MADs should not modify data referenced by the @send_wr
+ * Clients snooping MADs should not modify data referenced by the @send_buf
* or @mad_send_wc.
*/
typedef void (*ib_mad_snoop_handler)(struct ib_mad_agent *mad_agent,
@@ -333,6 +494,7 @@ typedef void (*ib_mad_snoop_handler)(struct ib_mad_agent *mad_agent,
/**
* ib_mad_recv_handler - callback handler for a received MAD.
* @mad_agent: MAD agent requesting the received MAD.
+ * @send_buf: Send buffer if found, else NULL
* @mad_recv_wc: Received work completion information on the received MAD.
*
* MADs received in response to a send request operation will be handed to
@@ -342,6 +504,7 @@ typedef void (*ib_mad_snoop_handler)(struct ib_mad_agent *mad_agent,
* modify the data referenced by @mad_recv_wc.
*/
typedef void (*ib_mad_recv_handler)(struct ib_mad_agent *mad_agent,
+ struct ib_mad_send_buf *send_buf,
struct ib_mad_recv_wc *mad_recv_wc);
/**
@@ -356,18 +519,22 @@ typedef void (*ib_mad_recv_handler)(struct ib_mad_agent *mad_agent,
* @hi_tid: Access layer assigned transaction ID for this client.
* Unsolicited MADs sent by this client will have the upper 32-bits
* of their TID set to this value.
+ * @flags: registration flags
* @port_num: Port number on which QP is registered
* @rmpp_version: If set, indicates the RMPP version used by this agent.
*/
+enum {
+ IB_MAD_USER_RMPP = IB_USER_MAD_USER_RMPP,
+};
struct ib_mad_agent {
struct ib_device *device;
struct ib_qp *qp;
- struct ib_mr *mr;
ib_mad_recv_handler recv_handler;
ib_mad_send_handler send_handler;
ib_mad_snoop_handler snoop_handler;
void *context;
u32 hi_tid;
+ u32 flags;
u8 port_num;
u8 rmpp_version;
};
@@ -396,7 +563,10 @@ struct ib_mad_send_wc {
struct ib_mad_recv_buf {
struct list_head list;
struct ib_grh *grh;
- struct ib_mad *mad;
+ union {
+ struct ib_mad *mad;
+ struct opa_mad *opa_mad;
+ };
};
/**
@@ -405,6 +575,7 @@ struct ib_mad_recv_buf {
* @recv_buf: Specifies the location of the received data buffer(s).
* @rmpp_list: Specifies a list of RMPP reassembled received MAD buffers.
* @mad_len: The length of the received MAD, without duplicated headers.
+ * @mad_seg_size: The size of individual MAD segments
*
* For received response, the wr_id contains a pointer to the ib_mad_send_buf
* for the corresponding send request.
@@ -414,6 +585,7 @@ struct ib_mad_recv_wc {
struct ib_mad_recv_buf recv_buf;
struct list_head rmpp_list;
int mad_len;
+ size_t mad_seg_size;
};
/**
@@ -427,6 +599,7 @@ struct ib_mad_recv_wc {
* in the range from 0x30 to 0x4f. Otherwise not used.
* @method_mask: The caller will receive unsolicited MADs for any method
* where @method_mask = 1.
+ *
*/
struct ib_mad_reg_req {
u8 mgmt_class;
@@ -452,6 +625,7 @@ struct ib_mad_reg_req {
* @recv_handler: The completion callback routine invoked for a received
* MAD.
* @context: User specified context associated with the registration.
+ * @registration_flags: Registration flags to set for this agent
*/
struct ib_mad_agent *ib_register_mad_agent(struct ib_device *device,
u8 port_num,
@@ -460,7 +634,8 @@ struct ib_mad_agent *ib_register_mad_agent(struct ib_device *device,
u8 rmpp_version,
ib_mad_send_handler send_handler,
ib_mad_recv_handler recv_handler,
- void *context);
+ void *context,
+ u32 registration_flags);
enum ib_mad_snoop_flags {
/*IB_MAD_SNOOP_POSTED_SENDS = 1,*/
@@ -610,6 +785,7 @@ int ib_process_mad_wc(struct ib_mad_agent *mad_agent,
* automatically adjust the allocated buffer size to account for any
* additional padding that may be necessary.
* @gfp_mask: GFP mask used for the memory allocation.
+ * @base_version: Base Version of this MAD
*
* This routine allocates a MAD for sending. The returned MAD send buffer
* will reference a data buffer usable for sending a MAD, along
@@ -625,7 +801,8 @@ struct ib_mad_send_buf *ib_create_send_mad(struct ib_mad_agent *mad_agent,
u32 remote_qpn, u16 pkey_index,
int rmpp_active,
int hdr_len, int data_len,
- gfp_t gfp_mask);
+ gfp_t gfp_mask,
+ u8 base_version);
/**
* ib_is_mad_class_rmpp - returns whether given management class
@@ -662,4 +839,11 @@ void *ib_get_rmpp_segment(struct ib_mad_send_buf *send_buf, int seg_num);
*/
void ib_free_send_mad(struct ib_mad_send_buf *send_buf);
+/**
+ * ib_mad_kernel_rmpp_agent - Returns if the agent is performing RMPP.
+ * @agent: the agent in question
+ * @return: true if agent is performing rmpp, false otherwise.
+ */
+int ib_mad_kernel_rmpp_agent(const struct ib_mad_agent *agent);
+
#endif /* IB_MAD_H */
diff --git a/sys/ofed/include/rdma/ib_pack.h b/sys/ofed/include/rdma/ib_pack.h
index 1678be7..950aeeb 100644
--- a/sys/ofed/include/rdma/ib_pack.h
+++ b/sys/ofed/include/rdma/ib_pack.h
@@ -40,6 +40,8 @@ enum {
IB_ETH_BYTES = 14,
IB_VLAN_BYTES = 4,
IB_GRH_BYTES = 40,
+ IB_IP4_BYTES = 20,
+ IB_UDP_BYTES = 8,
IB_BTH_BYTES = 12,
IB_DETH_BYTES = 8
};
@@ -75,6 +77,8 @@ enum {
IB_OPCODE_UC = 0x20,
IB_OPCODE_RD = 0x40,
IB_OPCODE_UD = 0x60,
+ /* per IBTA 1.3 vol 1 Table 38, A10.3.2 */
+ IB_OPCODE_CNP = 0x80,
/* operations -- just used to define real constants */
IB_OPCODE_SEND_FIRST = 0x00,
@@ -98,6 +102,9 @@ enum {
IB_OPCODE_ATOMIC_ACKNOWLEDGE = 0x12,
IB_OPCODE_COMPARE_SWAP = 0x13,
IB_OPCODE_FETCH_ADD = 0x14,
+ /* opcode 0x15 is reserved */
+ IB_OPCODE_SEND_LAST_WITH_INVALIDATE = 0x16,
+ IB_OPCODE_SEND_ONLY_WITH_INVALIDATE = 0x17,
/* real constants follow -- see comment about above IB_OPCODE()
macro for more details */
@@ -124,6 +131,8 @@ enum {
IB_OPCODE(RC, ATOMIC_ACKNOWLEDGE),
IB_OPCODE(RC, COMPARE_SWAP),
IB_OPCODE(RC, FETCH_ADD),
+ IB_OPCODE(RC, SEND_LAST_WITH_INVALIDATE),
+ IB_OPCODE(RC, SEND_ONLY_WITH_INVALIDATE),
/* UC */
IB_OPCODE(UC, SEND_FIRST),
@@ -220,6 +229,27 @@ struct ib_unpacked_eth {
__be16 type;
};
+struct ib_unpacked_ip4 {
+ u8 ver;
+ u8 hdr_len;
+ u8 tos;
+ __be16 tot_len;
+ __be16 id;
+ __be16 frag_off;
+ u8 ttl;
+ u8 protocol;
+ __sum16 check;
+ __be32 saddr;
+ __be32 daddr;
+};
+
+struct ib_unpacked_udp {
+ __be16 sport;
+ __be16 dport;
+ __be16 length;
+ __be16 csum;
+};
+
struct ib_unpacked_vlan {
__be16 tag;
__be16 type;
@@ -228,16 +258,20 @@ struct ib_unpacked_vlan {
struct ib_ud_header {
int lrh_present;
struct ib_unpacked_lrh lrh;
- int eth_present;
- struct ib_unpacked_eth eth;
+ int eth_present;
+ struct ib_unpacked_eth eth;
int vlan_present;
struct ib_unpacked_vlan vlan;
- int grh_present;
- struct ib_unpacked_grh grh;
- struct ib_unpacked_bth bth;
+ int grh_present;
+ struct ib_unpacked_grh grh;
+ int ipv4_present;
+ struct ib_unpacked_ip4 ip4;
+ int udp_present;
+ struct ib_unpacked_udp udp;
+ struct ib_unpacked_bth bth;
struct ib_unpacked_deth deth;
- int immediate_present;
- __be32 immediate_data;
+ int immediate_present;
+ __be32 immediate_data;
};
void ib_pack(const struct ib_field *desc,
@@ -250,13 +284,17 @@ void ib_unpack(const struct ib_field *desc,
void *buf,
void *structure);
-void ib_ud_header_init(int payload_bytes,
- int lrh_present,
- int eth_present,
- int vlan_present,
- int grh_present,
- int immediate_present,
- struct ib_ud_header *header);
+__sum16 ib_ud_ip4_csum(struct ib_ud_header *header);
+
+int ib_ud_header_init(int payload_bytes,
+ int lrh_present,
+ int eth_present,
+ int vlan_present,
+ int grh_present,
+ int ip_version,
+ int udp_present,
+ int immediate_present,
+ struct ib_ud_header *header);
int ib_ud_header_pack(struct ib_ud_header *header,
void *buf);
diff --git a/sys/ofed/include/rdma/ib_peer_mem.h b/sys/ofed/include/rdma/ib_peer_mem.h
deleted file mode 100644
index b2a8a4a..0000000
--- a/sys/ofed/include/rdma/ib_peer_mem.h
+++ /dev/null
@@ -1,59 +0,0 @@
-#if !defined(IB_PEER_MEM_H)
-#define IB_PEER_MEM_H
-
-#include <rdma/peer_mem.h>
-
-
-struct invalidation_ctx;
-struct ib_ucontext;
-
-struct ib_peer_memory_statistics {
- unsigned long num_alloc_mrs;
- unsigned long num_dealloc_mrs;
- unsigned long num_reg_pages;
- unsigned long num_dereg_pages;
- unsigned long num_free_callbacks;
-};
-
-struct ib_peer_memory_client {
- const struct peer_memory_client *peer_mem;
-
- struct list_head core_peer_list;
- struct list_head core_ticket_list;
- unsigned long last_ticket;
-#ifdef __FreeBSD__
- int holdcount;
- int needwakeup;
- struct cv peer_cv;
-#else
- struct srcu_struct peer_srcu;
-#endif
- struct mutex lock;
- struct kobject *kobj;
- struct attribute_group peer_mem_attr_group;
- struct ib_peer_memory_statistics stats;
-};
-
-struct core_ticket {
- unsigned long key;
- void *context;
- struct list_head ticket_list;
-};
-
-struct ib_peer_memory_client *ib_get_peer_client(struct ib_ucontext *context, unsigned long addr,
- size_t size, void **peer_client_context,
- int *srcu_key);
-
-void ib_put_peer_client(struct ib_peer_memory_client *ib_peer_client,
- void *peer_client_context,
- int srcu_key);
-
-unsigned long ib_peer_insert_context(struct ib_peer_memory_client *ib_peer_client,
- void *context);
-int ib_peer_remove_context(struct ib_peer_memory_client *ib_peer_client,
- unsigned long key);
-struct core_ticket *ib_peer_search_context(struct ib_peer_memory_client *ib_peer_client,
- unsigned long key);
-#endif
-
-
diff --git a/sys/ofed/include/rdma/ib_pma.h b/sys/ofed/include/rdma/ib_pma.h
index a2300cd..2f8a65c 100644
--- a/sys/ofed/include/rdma/ib_pma.h
+++ b/sys/ofed/include/rdma/ib_pma.h
@@ -37,30 +37,12 @@
#include <rdma/ib_mad.h>
-#define MAX_U32 0xffffffffULL
-#define MAX_U16 0xffffUL
-
-/* Counters should be saturate once they reach their maximum value */
-#define ASSIGN_32BIT_COUNTER(counter, value) do { \
- if ((value) > MAX_U32) \
- counter = cpu_to_be32(MAX_U32); \
- else \
- counter = cpu_to_be32(value); \
-} while (0)
-
-/* Counters should be saturate once they reach their maximum value */
-#define ASSIGN_16BIT_COUNTER(counter, value) do { \
- if ((value) > MAX_U16) \
- counter = cpu_to_be16(MAX_U16); \
- else \
- counter = cpu_to_be16(value); \
-} while (0)
-
/*
* PMA class portinfo capability mask bits
*/
#define IB_PMA_CLASS_CAP_ALLPORTSELECT cpu_to_be16(1 << 8)
#define IB_PMA_CLASS_CAP_EXT_WIDTH cpu_to_be16(1 << 9)
+#define IB_PMA_CLASS_CAP_EXT_WIDTH_NOIETF cpu_to_be16(1 << 10)
#define IB_PMA_CLASS_CAP_XMIT_WAIT cpu_to_be16(1 << 12)
#define IB_PMA_CLASS_PORT_INFO cpu_to_be16(0x0001)
diff --git a/sys/ofed/include/rdma/ib_sa.h b/sys/ofed/include/rdma/ib_sa.h
index 65f1a00..4c3e292 100644
--- a/sys/ofed/include/rdma/ib_sa.h
+++ b/sys/ofed/include/rdma/ib_sa.h
@@ -37,8 +37,7 @@
#include <linux/completion.h>
#include <linux/compiler.h>
-
-#include <asm/atomic.h>
+#include <linux/netdevice.h>
#include <rdma/ib_verbs.h>
#include <rdma/ib_mad.h>
@@ -94,6 +93,21 @@ enum ib_sa_selector {
};
/*
+ * There are 4 types of join states:
+ * FullMember, NonMember, SendOnlyNonMember, SendOnlyFullMember.
+ * The order corresponds to JoinState bits in MCMemberRecord.
+ */
+enum ib_sa_mc_join_states {
+ FULLMEMBER_JOIN,
+ NONMEMBER_JOIN,
+ SENDONLY_NONMEBER_JOIN,
+ SENDONLY_FULLMEMBER_JOIN,
+ NUM_JOIN_MEMBERSHIP_TYPES,
+};
+
+#define IB_SA_CAP_MASK2_SENDONLY_FULL_MEM_SUPPORT BIT(12)
+
+/*
* Structures for SA records are named "struct ib_sa_xxx_rec." No
* attempt is made to pack structures to match the physical layout of
* SA records in SA MADs; all packing and unpacking is handled by the
@@ -154,11 +168,19 @@ struct ib_sa_path_rec {
u8 packet_life_time_selector;
u8 packet_life_time;
u8 preference;
- u8 smac[ETH_ALEN];
- u8 dmac[6];
- __be16 vlan_id;
+ u8 dmac[ETH_ALEN];
+ /* ignored in IB */
+ int ifindex;
+ /* ignored in IB */
+ struct vnet *net;
+ enum ib_gid_type gid_type;
};
+static inline struct net_device *ib_get_ndev_from_path(struct ib_sa_path_rec *rec)
+{
+ return rec->net ? dev_get_by_index(rec->net, rec->ifindex) : NULL;
+}
+
#define IB_SA_MCMEMBER_REC_MGID IB_SA_COMP_MASK( 0)
#define IB_SA_MCMEMBER_REC_PORT_GID IB_SA_COMP_MASK( 1)
#define IB_SA_MCMEMBER_REC_QKEY IB_SA_COMP_MASK( 2)
@@ -394,6 +416,8 @@ int ib_sa_get_mcmember_rec(struct ib_device *device, u8 port_num,
*/
int ib_init_ah_from_mcmember(struct ib_device *device, u8 port_num,
struct ib_sa_mcmember_rec *rec,
+ struct net_device *ndev,
+ enum ib_gid_type gid_type,
struct ib_ah_attr *ah_attr);
/**
@@ -405,6 +429,12 @@ int ib_init_ah_from_path(struct ib_device *device, u8 port_num,
struct ib_ah_attr *ah_attr);
/**
+ * ib_sa_pack_path - Conert a path record from struct ib_sa_path_rec
+ * to IB MAD wire format.
+ */
+void ib_sa_pack_path(struct ib_sa_path_rec *rec, void *attribute);
+
+/**
* ib_sa_unpack_path - Convert a path record from MAD format to struct
* ib_sa_path_rec.
*/
@@ -412,13 +442,24 @@ void ib_sa_unpack_path(void *attribute, struct ib_sa_path_rec *rec);
/* Support GuidInfoRecord */
int ib_sa_guid_info_rec_query(struct ib_sa_client *client,
- struct ib_device *device, u8 port_num,
- struct ib_sa_guidinfo_rec *rec,
- ib_sa_comp_mask comp_mask, u8 method,
- int timeout_ms, gfp_t gfp_mask,
- void (*callback)(int status,
- struct ib_sa_guidinfo_rec *resp,
- void *context),
- void *context,
- struct ib_sa_query **sa_query);
+ struct ib_device *device, u8 port_num,
+ struct ib_sa_guidinfo_rec *rec,
+ ib_sa_comp_mask comp_mask, u8 method,
+ int timeout_ms, gfp_t gfp_mask,
+ void (*callback)(int status,
+ struct ib_sa_guidinfo_rec *resp,
+ void *context),
+ void *context,
+ struct ib_sa_query **sa_query);
+
+/* Support get SA ClassPortInfo */
+int ib_sa_classport_info_rec_query(struct ib_sa_client *client,
+ struct ib_device *device, u8 port_num,
+ int timeout_ms, gfp_t gfp_mask,
+ void (*callback)(int status,
+ struct ib_class_port_info *resp,
+ void *context),
+ void *context,
+ struct ib_sa_query **sa_query);
+
#endif /* IB_SA_H */
diff --git a/sys/ofed/include/rdma/ib_smi.h b/sys/ofed/include/rdma/ib_smi.h
index 973c9a4..15ac3d7 100644
--- a/sys/ofed/include/rdma/ib_smi.h
+++ b/sys/ofed/include/rdma/ib_smi.h
@@ -38,7 +38,6 @@
#define IB_SMI_H
#include <rdma/ib_mad.h>
-#include <asm/byteorder.h>
#define IB_SMP_DATA_SIZE 64
#define IB_SMP_MAX_PATH_HOPS 64
@@ -120,10 +119,57 @@ struct ib_port_info {
u8 link_roundtrip_latency[3];
};
+struct ib_node_info {
+ u8 base_version;
+ u8 class_version;
+ u8 node_type;
+ u8 num_ports;
+ __be64 sys_guid;
+ __be64 node_guid;
+ __be64 port_guid;
+ __be16 partition_cap;
+ __be16 device_id;
+ __be32 revision;
+ u8 local_port_num;
+ u8 vendor_id[3];
+} __packed;
+
+struct ib_vl_weight_elem {
+ u8 vl; /* IB: VL is low 4 bits, upper 4 bits reserved */
+ /* OPA: VL is low 5 bits, upper 3 bits reserved */
+ u8 weight;
+};
+
static inline u8
-ib_get_smp_direction(struct ib_smp *smp)
+ib_get_smp_direction(const struct ib_smp *smp)
{
return ((smp->status & IB_SMP_DIRECTION) == IB_SMP_DIRECTION);
}
+/*
+ * SM Trap/Notice numbers
+ */
+#define IB_NOTICE_TRAP_LLI_THRESH cpu_to_be16(129)
+#define IB_NOTICE_TRAP_EBO_THRESH cpu_to_be16(130)
+#define IB_NOTICE_TRAP_FLOW_UPDATE cpu_to_be16(131)
+#define IB_NOTICE_TRAP_CAP_MASK_CHG cpu_to_be16(144)
+#define IB_NOTICE_TRAP_SYS_GUID_CHG cpu_to_be16(145)
+#define IB_NOTICE_TRAP_BAD_MKEY cpu_to_be16(256)
+#define IB_NOTICE_TRAP_BAD_PKEY cpu_to_be16(257)
+#define IB_NOTICE_TRAP_BAD_QKEY cpu_to_be16(258)
+
+/*
+ * Other local changes flags (trap 144).
+ */
+#define IB_NOTICE_TRAP_LSE_CHG 0x04 /* Link Speed Enable changed */
+#define IB_NOTICE_TRAP_LWE_CHG 0x02 /* Link Width Enable changed */
+#define IB_NOTICE_TRAP_NODE_DESC_CHG 0x01
+
+/*
+ * M_Key volation flags in dr_trunc_hop (trap 256).
+ */
+#define IB_NOTICE_TRAP_DR_NOTICE 0x80
+#define IB_NOTICE_TRAP_DR_TRUNC 0x40
+
+
#endif /* IB_SMI_H */
diff --git a/sys/ofed/include/rdma/ib_umem.h b/sys/ofed/include/rdma/ib_umem.h
index 82f6cfa..6386d45 100644
--- a/sys/ofed/include/rdma/ib_umem.h
+++ b/sys/ofed/include/rdma/ib_umem.h
@@ -36,58 +36,73 @@
#include <linux/list.h>
#include <linux/scatterlist.h>
#include <linux/workqueue.h>
-#include <linux/dma-attrs.h>
-#include <linux/completion.h>
-#include <rdma/ib_peer_mem.h>
struct ib_ucontext;
-struct ib_umem;
-
-typedef void (*umem_invalidate_func_t)(void *invalidation_cookie,
- struct ib_umem *umem,
- unsigned long addr, size_t size);
-
-struct invalidation_ctx {
- struct ib_umem *umem;
- umem_invalidate_func_t func;
- void *cookie;
- unsigned long context_ticket;
- int peer_callback;
- int inflight_invalidation;
- int peer_invalidated;
- struct completion comp;
-};
+struct ib_umem_odp;
struct ib_umem {
struct ib_ucontext *context;
size_t length;
- int offset;
+ unsigned long address;
int page_size;
int writable;
- int hugetlb;
struct work_struct work;
+ pid_t pid;
+ struct mm_struct *mm;
unsigned long diff;
- unsigned long start;
+ struct ib_umem_odp *odp_data;
struct sg_table sg_head;
- int nmap;
+ int nmap;
int npages;
- /* peer memory that manages this umem*/
- struct ib_peer_memory_client *ib_peer_mem;
- struct invalidation_ctx *invalidation_ctx;
- int peer_mem_srcu_key;
- /* peer memory private context */
- void *peer_mem_client_context;
};
+/* Returns the offset of the umem start relative to the first page. */
+static inline int ib_umem_offset(struct ib_umem *umem)
+{
+ return umem->address & ((unsigned long)umem->page_size - 1);
+}
+
+/* Returns the first page of an ODP umem. */
+static inline unsigned long ib_umem_start(struct ib_umem *umem)
+{
+ return umem->address - ib_umem_offset(umem);
+}
+
+/* Returns the address of the page after the last one of an ODP umem. */
+static inline unsigned long ib_umem_end(struct ib_umem *umem)
+{
+ return PAGE_ALIGN(umem->address + umem->length);
+}
+
+static inline size_t ib_umem_num_pages(struct ib_umem *umem)
+{
+ return (ib_umem_end(umem) - ib_umem_start(umem)) >> PAGE_SHIFT;
+}
+
+#ifdef CONFIG_INFINIBAND_USER_MEM
+
struct ib_umem *ib_umem_get(struct ib_ucontext *context, unsigned long addr,
size_t size, int access, int dmasync);
-struct ib_umem *ib_umem_get_ex(struct ib_ucontext *context, unsigned long addr,
- size_t size, int access, int dmasync,
- int invalidation_supported);
-void ib_umem_activate_invalidation_notifier(struct ib_umem *umem,
- umem_invalidate_func_t func,
- void *cookie);
void ib_umem_release(struct ib_umem *umem);
int ib_umem_page_count(struct ib_umem *umem);
+int ib_umem_copy_from(void *dst, struct ib_umem *umem, size_t offset,
+ size_t length);
+
+#else /* CONFIG_INFINIBAND_USER_MEM */
+
+#include <linux/err.h>
+
+static inline struct ib_umem *ib_umem_get(struct ib_ucontext *context,
+ unsigned long addr, size_t size,
+ int access, int dmasync) {
+ return ERR_PTR(-EINVAL);
+}
+static inline void ib_umem_release(struct ib_umem *umem) { }
+static inline int ib_umem_page_count(struct ib_umem *umem) { return 0; }
+static inline int ib_umem_copy_from(void *dst, struct ib_umem *umem, size_t offset,
+ size_t length) {
+ return -EINVAL;
+}
+#endif /* CONFIG_INFINIBAND_USER_MEM */
#endif /* IB_UMEM_H */
diff --git a/sys/ofed/include/rdma/ib_umem_odp.h b/sys/ofed/include/rdma/ib_umem_odp.h
new file mode 100644
index 0000000..d2f0e6b
--- /dev/null
+++ b/sys/ofed/include/rdma/ib_umem_odp.h
@@ -0,0 +1,161 @@
+/*
+ * Copyright (c) 2014 Mellanox Technologies. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#ifndef IB_UMEM_ODP_H
+#define IB_UMEM_ODP_H
+
+#include <linux/rbtree.h>
+
+#include <rdma/ib_umem.h>
+#include <rdma/ib_verbs.h>
+
+struct umem_odp_node {
+ u64 __subtree_last;
+ struct rb_node rb;
+};
+
+struct ib_umem_odp {
+ /*
+ * An array of the pages included in the on-demand paging umem.
+ * Indices of pages that are currently not mapped into the device will
+ * contain NULL.
+ */
+ struct page **page_list;
+ /*
+ * An array of the same size as page_list, with DMA addresses mapped
+ * for pages the pages in page_list. The lower two bits designate
+ * access permissions. See ODP_READ_ALLOWED_BIT and
+ * ODP_WRITE_ALLOWED_BIT.
+ */
+ dma_addr_t *dma_list;
+ /*
+ * The umem_mutex protects the page_list and dma_list fields of an ODP
+ * umem, allowing only a single thread to map/unmap pages. The mutex
+ * also protects access to the mmu notifier counters.
+ */
+ struct mutex umem_mutex;
+ void *private; /* for the HW driver to use. */
+
+ /* When false, use the notifier counter in the ucontext struct. */
+ bool mn_counters_active;
+ int notifiers_seq;
+ int notifiers_count;
+
+ /* A linked list of umems that don't have private mmu notifier
+ * counters yet. */
+ struct list_head no_private_counters;
+ struct ib_umem *umem;
+
+ /* Tree tracking */
+ struct umem_odp_node interval_tree;
+
+ struct completion notifier_completion;
+ int dying;
+};
+
+#ifdef CONFIG_INFINIBAND_ON_DEMAND_PAGING
+
+int ib_umem_odp_get(struct ib_ucontext *context, struct ib_umem *umem);
+
+void ib_umem_odp_release(struct ib_umem *umem);
+
+/*
+ * The lower 2 bits of the DMA address signal the R/W permissions for
+ * the entry. To upgrade the permissions, provide the appropriate
+ * bitmask to the map_dma_pages function.
+ *
+ * Be aware that upgrading a mapped address might result in change of
+ * the DMA address for the page.
+ */
+#define ODP_READ_ALLOWED_BIT (1<<0ULL)
+#define ODP_WRITE_ALLOWED_BIT (1<<1ULL)
+
+#define ODP_DMA_ADDR_MASK (~(ODP_READ_ALLOWED_BIT | ODP_WRITE_ALLOWED_BIT))
+
+int ib_umem_odp_map_dma_pages(struct ib_umem *umem, u64 start_offset, u64 bcnt,
+ u64 access_mask, unsigned long current_seq);
+
+void ib_umem_odp_unmap_dma_pages(struct ib_umem *umem, u64 start_offset,
+ u64 bound);
+
+void rbt_ib_umem_insert(struct umem_odp_node *node, struct rb_root *root);
+void rbt_ib_umem_remove(struct umem_odp_node *node, struct rb_root *root);
+typedef int (*umem_call_back)(struct ib_umem *item, u64 start, u64 end,
+ void *cookie);
+/*
+ * Call the callback on each ib_umem in the range. Returns the logical or of
+ * the return values of the functions called.
+ */
+int rbt_ib_umem_for_each_in_range(struct rb_root *root, u64 start, u64 end,
+ umem_call_back cb, void *cookie);
+
+struct umem_odp_node *rbt_ib_umem_iter_first(struct rb_root *root,
+ u64 start, u64 last);
+struct umem_odp_node *rbt_ib_umem_iter_next(struct umem_odp_node *node,
+ u64 start, u64 last);
+
+static inline int ib_umem_mmu_notifier_retry(struct ib_umem *item,
+ unsigned long mmu_seq)
+{
+ /*
+ * This code is strongly based on the KVM code from
+ * mmu_notifier_retry. Should be called with
+ * the relevant locks taken (item->odp_data->umem_mutex
+ * and the ucontext umem_mutex semaphore locked for read).
+ */
+
+ /* Do not allow page faults while the new ib_umem hasn't seen a state
+ * with zero notifiers yet, and doesn't have its own valid set of
+ * private counters. */
+ if (!item->odp_data->mn_counters_active)
+ return 1;
+
+ if (unlikely(item->odp_data->notifiers_count))
+ return 1;
+ if (item->odp_data->notifiers_seq != mmu_seq)
+ return 1;
+ return 0;
+}
+
+#else /* CONFIG_INFINIBAND_ON_DEMAND_PAGING */
+
+static inline int ib_umem_odp_get(struct ib_ucontext *context,
+ struct ib_umem *umem)
+{
+ return -EINVAL;
+}
+
+static inline void ib_umem_odp_release(struct ib_umem *umem) {}
+
+#endif /* CONFIG_INFINIBAND_ON_DEMAND_PAGING */
+
+#endif /* IB_UMEM_ODP_H */
diff --git a/sys/ofed/include/rdma/ib_user_cm.h b/sys/ofed/include/rdma/ib_user_cm.h
deleted file mode 100644
index f79014a..0000000
--- a/sys/ofed/include/rdma/ib_user_cm.h
+++ /dev/null
@@ -1,325 +0,0 @@
-/*
- * Copyright (c) 2005 Topspin Communications. All rights reserved.
- * Copyright (c) 2005 Intel Corporation. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-#ifndef IB_USER_CM_H
-#define IB_USER_CM_H
-
-#include <linux/types.h>
-#include <rdma/ib_user_sa.h>
-
-#define IB_USER_CM_ABI_VERSION 5
-
-enum {
- IB_USER_CM_CMD_CREATE_ID,
- IB_USER_CM_CMD_DESTROY_ID,
- IB_USER_CM_CMD_ATTR_ID,
-
- IB_USER_CM_CMD_LISTEN,
- IB_USER_CM_CMD_NOTIFY,
-
- IB_USER_CM_CMD_SEND_REQ,
- IB_USER_CM_CMD_SEND_REP,
- IB_USER_CM_CMD_SEND_RTU,
- IB_USER_CM_CMD_SEND_DREQ,
- IB_USER_CM_CMD_SEND_DREP,
- IB_USER_CM_CMD_SEND_REJ,
- IB_USER_CM_CMD_SEND_MRA,
- IB_USER_CM_CMD_SEND_LAP,
- IB_USER_CM_CMD_SEND_APR,
- IB_USER_CM_CMD_SEND_SIDR_REQ,
- IB_USER_CM_CMD_SEND_SIDR_REP,
-
- IB_USER_CM_CMD_EVENT,
- IB_USER_CM_CMD_INIT_QP_ATTR,
-};
-/*
- * command ABI structures.
- */
-struct ib_ucm_cmd_hdr {
- __u32 cmd;
- __u16 in;
- __u16 out;
-};
-
-struct ib_ucm_create_id {
- __u64 uid;
- __u64 response;
-};
-
-struct ib_ucm_create_id_resp {
- __u32 id;
-};
-
-struct ib_ucm_destroy_id {
- __u64 response;
- __u32 id;
- __u32 reserved;
-};
-
-struct ib_ucm_destroy_id_resp {
- __u32 events_reported;
-};
-
-struct ib_ucm_attr_id {
- __u64 response;
- __u32 id;
- __u32 reserved;
-};
-
-struct ib_ucm_attr_id_resp {
- __be64 service_id;
- __be64 service_mask;
- __be32 local_id;
- __be32 remote_id;
-};
-
-struct ib_ucm_init_qp_attr {
- __u64 response;
- __u32 id;
- __u32 qp_state;
-};
-
-struct ib_ucm_listen {
- __be64 service_id;
- __be64 service_mask;
- __u32 id;
- __u32 reserved;
-};
-
-struct ib_ucm_notify {
- __u32 id;
- __u32 event;
-};
-
-struct ib_ucm_private_data {
- __u64 data;
- __u32 id;
- __u8 len;
- __u8 reserved[3];
-};
-
-struct ib_ucm_req {
- __u32 id;
- __u32 qpn;
- __u32 qp_type;
- __u32 psn;
- __be64 sid;
- __u64 data;
- __u64 primary_path;
- __u64 alternate_path;
- __u8 len;
- __u8 peer_to_peer;
- __u8 responder_resources;
- __u8 initiator_depth;
- __u8 remote_cm_response_timeout;
- __u8 flow_control;
- __u8 local_cm_response_timeout;
- __u8 retry_count;
- __u8 rnr_retry_count;
- __u8 max_cm_retries;
- __u8 srq;
- __u8 reserved[5];
-};
-
-struct ib_ucm_rep {
- __u64 uid;
- __u64 data;
- __u32 id;
- __u32 qpn;
- __u32 psn;
- __u8 len;
- __u8 responder_resources;
- __u8 initiator_depth;
- __u8 target_ack_delay;
- __u8 failover_accepted;
- __u8 flow_control;
- __u8 rnr_retry_count;
- __u8 srq;
- __u8 reserved[4];
-};
-
-struct ib_ucm_info {
- __u32 id;
- __u32 status;
- __u64 info;
- __u64 data;
- __u8 info_len;
- __u8 data_len;
- __u8 reserved[6];
-};
-
-struct ib_ucm_mra {
- __u64 data;
- __u32 id;
- __u8 len;
- __u8 timeout;
- __u8 reserved[2];
-};
-
-struct ib_ucm_lap {
- __u64 path;
- __u64 data;
- __u32 id;
- __u8 len;
- __u8 reserved[3];
-};
-
-struct ib_ucm_sidr_req {
- __u32 id;
- __u32 timeout;
- __be64 sid;
- __u64 data;
- __u64 path;
- __u16 reserved_pkey;
- __u8 len;
- __u8 max_cm_retries;
- __u8 reserved[4];
-};
-
-struct ib_ucm_sidr_rep {
- __u32 id;
- __u32 qpn;
- __u32 qkey;
- __u32 status;
- __u64 info;
- __u64 data;
- __u8 info_len;
- __u8 data_len;
- __u8 reserved[6];
-};
-/*
- * event notification ABI structures.
- */
-struct ib_ucm_event_get {
- __u64 response;
- __u64 data;
- __u64 info;
- __u8 data_len;
- __u8 info_len;
- __u8 reserved[6];
-};
-
-struct ib_ucm_req_event_resp {
- struct ib_user_path_rec primary_path;
- struct ib_user_path_rec alternate_path;
- __be64 remote_ca_guid;
- __u32 remote_qkey;
- __u32 remote_qpn;
- __u32 qp_type;
- __u32 starting_psn;
- __u8 responder_resources;
- __u8 initiator_depth;
- __u8 local_cm_response_timeout;
- __u8 flow_control;
- __u8 remote_cm_response_timeout;
- __u8 retry_count;
- __u8 rnr_retry_count;
- __u8 srq;
- __u8 port;
- __u8 reserved[7];
-};
-
-struct ib_ucm_rep_event_resp {
- __be64 remote_ca_guid;
- __u32 remote_qkey;
- __u32 remote_qpn;
- __u32 starting_psn;
- __u8 responder_resources;
- __u8 initiator_depth;
- __u8 target_ack_delay;
- __u8 failover_accepted;
- __u8 flow_control;
- __u8 rnr_retry_count;
- __u8 srq;
- __u8 reserved[5];
-};
-
-struct ib_ucm_rej_event_resp {
- __u32 reason;
- /* ari in ib_ucm_event_get info field. */
-};
-
-struct ib_ucm_mra_event_resp {
- __u8 timeout;
- __u8 reserved[3];
-};
-
-struct ib_ucm_lap_event_resp {
- struct ib_user_path_rec path;
-};
-
-struct ib_ucm_apr_event_resp {
- __u32 status;
- /* apr info in ib_ucm_event_get info field. */
-};
-
-struct ib_ucm_sidr_req_event_resp {
- __u16 pkey;
- __u8 port;
- __u8 reserved;
-};
-
-struct ib_ucm_sidr_rep_event_resp {
- __u32 status;
- __u32 qkey;
- __u32 qpn;
- /* info in ib_ucm_event_get info field. */
-};
-
-#define IB_UCM_PRES_DATA 0x01
-#define IB_UCM_PRES_INFO 0x02
-#define IB_UCM_PRES_PRIMARY 0x04
-#define IB_UCM_PRES_ALTERNATE 0x08
-
-struct ib_ucm_event_resp {
- __u64 uid;
- __u32 id;
- __u32 event;
- __u32 present;
- __u32 reserved;
- union {
- struct ib_ucm_req_event_resp req_resp;
- struct ib_ucm_rep_event_resp rep_resp;
- struct ib_ucm_rej_event_resp rej_resp;
- struct ib_ucm_mra_event_resp mra_resp;
- struct ib_ucm_lap_event_resp lap_resp;
- struct ib_ucm_apr_event_resp apr_resp;
-
- struct ib_ucm_sidr_req_event_resp sidr_req_resp;
- struct ib_ucm_sidr_rep_event_resp sidr_rep_resp;
-
- __u32 send_status;
- } u;
-};
-
-#endif /* IB_USER_CM_H */
diff --git a/sys/ofed/include/rdma/ib_user_mad.h b/sys/ofed/include/rdma/ib_user_mad.h
deleted file mode 100644
index 3595ae2..0000000
--- a/sys/ofed/include/rdma/ib_user_mad.h
+++ /dev/null
@@ -1,202 +0,0 @@
-/*
- * Copyright (c) 2004 Topspin Communications. All rights reserved.
- * Copyright (c) 2005 Voltaire, Inc. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-#ifndef IB_USER_MAD_H
-#define IB_USER_MAD_H
-
-#include <linux/types.h>
-#include <linux/ioctl.h>
-
-/*
- * Increment this value if any changes that break userspace ABI
- * compatibility are made.
- */
-#define IB_USER_MAD_ABI_VERSION 5
-
-/*
- * Make sure that all structs defined in this file remain laid out so
- * that they pack the same way on 32-bit and 64-bit architectures (to
- * avoid incompatibility between 32-bit userspace and 64-bit kernels).
- */
-
-/**
- * ib_user_mad_hdr_old - Old version of MAD packet header without pkey_index
- * @id - ID of agent MAD received with/to be sent with
- * @status - 0 on successful receive, ETIMEDOUT if no response
- * received (transaction ID in data[] will be set to TID of original
- * request) (ignored on send)
- * @timeout_ms - Milliseconds to wait for response (unset on receive)
- * @retries - Number of automatic retries to attempt
- * @qpn - Remote QP number received from/to be sent to
- * @qkey - Remote Q_Key to be sent with (unset on receive)
- * @lid - Remote lid received from/to be sent to
- * @sl - Service level received with/to be sent with
- * @path_bits - Local path bits received with/to be sent with
- * @grh_present - If set, GRH was received/should be sent
- * @gid_index - Local GID index to send with (unset on receive)
- * @hop_limit - Hop limit in GRH
- * @traffic_class - Traffic class in GRH
- * @gid - Remote GID in GRH
- * @flow_label - Flow label in GRH
- */
-struct ib_user_mad_hdr_old {
- __u32 id;
- __u32 status;
- __u32 timeout_ms;
- __u32 retries;
- __u32 length;
- __be32 qpn;
- __be32 qkey;
- __be16 lid;
- __u8 sl;
- __u8 path_bits;
- __u8 grh_present;
- __u8 gid_index;
- __u8 hop_limit;
- __u8 traffic_class;
- __u8 gid[16];
- __be32 flow_label;
-};
-
-/**
- * ib_user_mad_hdr - MAD packet header
- * This layout allows specifying/receiving the P_Key index. To use
- * this capability, an application must call the
- * IB_USER_MAD_ENABLE_PKEY ioctl on the user MAD file handle before
- * any other actions with the file handle.
- * @id - ID of agent MAD received with/to be sent with
- * @status - 0 on successful receive, ETIMEDOUT if no response
- * received (transaction ID in data[] will be set to TID of original
- * request) (ignored on send)
- * @timeout_ms - Milliseconds to wait for response (unset on receive)
- * @retries - Number of automatic retries to attempt
- * @qpn - Remote QP number received from/to be sent to
- * @qkey - Remote Q_Key to be sent with (unset on receive)
- * @lid - Remote lid received from/to be sent to
- * @sl - Service level received with/to be sent with
- * @path_bits - Local path bits received with/to be sent with
- * @grh_present - If set, GRH was received/should be sent
- * @gid_index - Local GID index to send with (unset on receive)
- * @hop_limit - Hop limit in GRH
- * @traffic_class - Traffic class in GRH
- * @gid - Remote GID in GRH
- * @flow_label - Flow label in GRH
- * @pkey_index - P_Key index
- */
-struct ib_user_mad_hdr {
- __u32 id;
- __u32 status;
- __u32 timeout_ms;
- __u32 retries;
- __u32 length;
- __be32 qpn;
- __be32 qkey;
- __be16 lid;
- __u8 sl;
- __u8 path_bits;
- __u8 grh_present;
- __u8 gid_index;
- __u8 hop_limit;
- __u8 traffic_class;
- __u8 gid[16];
- __be32 flow_label;
- __u16 pkey_index;
- __u8 reserved[6];
-};
-
-/**
- * ib_user_mad - MAD packet
- * @hdr - MAD packet header
- * @data - Contents of MAD
- *
- */
-struct ib_user_mad {
- struct ib_user_mad_hdr hdr;
- __u64 data[0];
-};
-
-/*
- * Earlier versions of this interface definition declared the
- * method_mask[] member as an array of __u32 but treated it as a
- * bitmap made up of longs in the kernel. This ambiguity meant that
- * 32-bit big-endian applications that can run on both 32-bit and
- * 64-bit kernels had no consistent ABI to rely on, and 64-bit
- * big-endian applications that treated method_mask as being made up
- * of 32-bit words would have their bitmap misinterpreted.
- *
- * To clear up this confusion, we change the declaration of
- * method_mask[] to use unsigned long and handle the conversion from
- * 32-bit userspace to 64-bit kernel for big-endian systems in the
- * compat_ioctl method. Unfortunately, to keep the structure layout
- * the same, we need the method_mask[] array to be aligned only to 4
- * bytes even when long is 64 bits, which forces us into this ugly
- * typedef.
- */
-typedef unsigned long __attribute__((aligned(4))) packed_ulong;
-#define IB_USER_MAD_LONGS_PER_METHOD_MASK (128 / (8 * sizeof (long)))
-
-/**
- * ib_user_mad_reg_req - MAD registration request
- * @id - Set by the kernel; used to identify agent in future requests.
- * @qpn - Queue pair number; must be 0 or 1.
- * @method_mask - The caller will receive unsolicited MADs for any method
- * where @method_mask = 1.
- * @mgmt_class - Indicates which management class of MADs should be receive
- * by the caller. This field is only required if the user wishes to
- * receive unsolicited MADs, otherwise it should be 0.
- * @mgmt_class_version - Indicates which version of MADs for the given
- * management class to receive.
- * @oui: Indicates IEEE OUI when mgmt_class is a vendor class
- * in the range from 0x30 to 0x4f. Otherwise not used.
- * @rmpp_version: If set, indicates the RMPP version used.
- *
- */
-struct ib_user_mad_reg_req {
- __u32 id;
- packed_ulong method_mask[IB_USER_MAD_LONGS_PER_METHOD_MASK];
- __u8 qpn;
- __u8 mgmt_class;
- __u8 mgmt_class_version;
- __u8 oui[3];
- __u8 rmpp_version;
-};
-
-#define IB_IOCTL_MAGIC 0x1b
-
-#define IB_USER_MAD_REGISTER_AGENT _IO(IB_IOCTL_MAGIC, 1)
-
-#define IB_USER_MAD_UNREGISTER_AGENT _IO(IB_IOCTL_MAGIC, 2)
-
-#define IB_USER_MAD_ENABLE_PKEY _IO(IB_IOCTL_MAGIC, 3)
-
-#endif /* IB_USER_MAD_H */
diff --git a/sys/ofed/include/rdma/ib_user_sa.h b/sys/ofed/include/rdma/ib_user_sa.h
deleted file mode 100644
index cfc7c9b..0000000
--- a/sys/ofed/include/rdma/ib_user_sa.h
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * Copyright (c) 2005 Intel Corporation. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-#ifndef IB_USER_SA_H
-#define IB_USER_SA_H
-
-#include <linux/types.h>
-
-enum {
- IB_PATH_GMP = 1,
- IB_PATH_PRIMARY = (1<<1),
- IB_PATH_ALTERNATE = (1<<2),
- IB_PATH_OUTBOUND = (1<<3),
- IB_PATH_INBOUND = (1<<4),
- IB_PATH_INBOUND_REVERSE = (1<<5),
- IB_PATH_BIDIRECTIONAL = IB_PATH_OUTBOUND | IB_PATH_INBOUND_REVERSE
-};
-
-struct ib_path_rec_data {
- __u32 flags;
- __u32 reserved;
- __u32 path_rec[16];
-};
-
-struct ib_user_path_rec {
- __u8 dgid[16];
- __u8 sgid[16];
- __be16 dlid;
- __be16 slid;
- __u32 raw_traffic;
- __be32 flow_label;
- __u32 reversible;
- __u32 mtu;
- __be16 pkey;
- __u8 hop_limit;
- __u8 traffic_class;
- __u8 numb_path;
- __u8 sl;
- __u8 mtu_selector;
- __u8 rate_selector;
- __u8 rate;
- __u8 packet_life_time_selector;
- __u8 packet_life_time;
- __u8 preference;
-};
-
-#endif /* IB_USER_SA_H */
diff --git a/sys/ofed/include/rdma/ib_user_verbs.h b/sys/ofed/include/rdma/ib_user_verbs.h
deleted file mode 100644
index a07de88..0000000
--- a/sys/ofed/include/rdma/ib_user_verbs.h
+++ /dev/null
@@ -1,980 +0,0 @@
-/*
- * Copyright (c) 2005 Topspin Communications. All rights reserved.
- * Copyright (c) 2005, 2006 Cisco Systems. All rights reserved.
- * Copyright (c) 2005 PathScale, Inc. All rights reserved.
- * Copyright (c) 2006 Mellanox Technologies. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-#ifndef IB_USER_VERBS_H
-#define IB_USER_VERBS_H
-
-#include <linux/types.h>
-
-/*
- * Increment this value if any changes that break userspace ABI
- * compatibility are made.
- */
-#define IB_USER_VERBS_ABI_VERSION 6
-#define IB_USER_VERBS_CMD_THRESHOLD 50
-
-/*
- * To support 6 legacy commands using the old extension style
- */
-#define IB_USER_VERBS_LEGACY_CMD_FIRST 52
-#define IB_USER_VERBS_LEGACY_EX_CMD_LAST 56
-
-enum {
- IB_USER_VERBS_CMD_GET_CONTEXT,
- IB_USER_VERBS_CMD_QUERY_DEVICE,
- IB_USER_VERBS_CMD_QUERY_PORT,
- IB_USER_VERBS_CMD_ALLOC_PD,
- IB_USER_VERBS_CMD_DEALLOC_PD,
- IB_USER_VERBS_CMD_CREATE_AH,
- IB_USER_VERBS_CMD_MODIFY_AH,
- IB_USER_VERBS_CMD_QUERY_AH,
- IB_USER_VERBS_CMD_DESTROY_AH,
- IB_USER_VERBS_CMD_REG_MR,
- IB_USER_VERBS_CMD_REG_SMR,
- IB_USER_VERBS_CMD_REREG_MR,
- IB_USER_VERBS_CMD_QUERY_MR,
- IB_USER_VERBS_CMD_DEREG_MR,
- IB_USER_VERBS_CMD_ALLOC_MW,
- IB_USER_VERBS_CMD_BIND_MW,
- IB_USER_VERBS_CMD_DEALLOC_MW,
- IB_USER_VERBS_CMD_CREATE_COMP_CHANNEL,
- IB_USER_VERBS_CMD_CREATE_CQ,
- IB_USER_VERBS_CMD_RESIZE_CQ,
- IB_USER_VERBS_CMD_DESTROY_CQ,
- IB_USER_VERBS_CMD_POLL_CQ,
- IB_USER_VERBS_CMD_PEEK_CQ,
- IB_USER_VERBS_CMD_REQ_NOTIFY_CQ,
- IB_USER_VERBS_CMD_CREATE_QP,
- IB_USER_VERBS_CMD_QUERY_QP,
- IB_USER_VERBS_CMD_MODIFY_QP,
- IB_USER_VERBS_CMD_DESTROY_QP,
- IB_USER_VERBS_CMD_POST_SEND,
- IB_USER_VERBS_CMD_POST_RECV,
- IB_USER_VERBS_CMD_ATTACH_MCAST,
- IB_USER_VERBS_CMD_DETACH_MCAST,
- IB_USER_VERBS_CMD_CREATE_SRQ,
- IB_USER_VERBS_CMD_MODIFY_SRQ,
- IB_USER_VERBS_CMD_QUERY_SRQ,
- IB_USER_VERBS_CMD_DESTROY_SRQ,
- IB_USER_VERBS_CMD_POST_SRQ_RECV,
- IB_USER_VERBS_CMD_OPEN_XRCD,
- IB_USER_VERBS_CMD_CLOSE_XRCD,
- IB_USER_VERBS_CMD_CREATE_XSRQ,
- IB_USER_VERBS_CMD_OPEN_QP
-};
-
-enum {
- IB_USER_VERBS_EX_CMD_CREATE_FLOW = IB_USER_VERBS_CMD_THRESHOLD,
- IB_USER_VERBS_EX_CMD_DESTROY_FLOW
-};
-
-
-/*
- * Make sure that all structs defined in this file remain laid out so
- * that they pack the same way on 32-bit and 64-bit architectures (to
- * avoid incompatibility between 32-bit userspace and 64-bit kernels).
- * Specifically:
- * - Do not use pointer types -- pass pointers in __u64 instead.
- * - Make sure that any structure larger than 4 bytes is padded to a
- * multiple of 8 bytes. Otherwise the structure size will be
- * different between 32-bit and 64-bit architectures.
- */
-
-struct ib_uverbs_async_event_desc {
- __u64 element;
- __u32 event_type; /* enum ib_event_type */
- __u32 reserved;
-};
-
-struct ib_uverbs_comp_event_desc {
- __u64 cq_handle;
-};
-
-/*
- * All commands from userspace should start with a __u32 command field
- * followed by __u16 in_words and out_words fields (which give the
- * length of the command block and response buffer if any in 32-bit
- * words). The kernel driver will read these fields first and read
- * the rest of the command struct based on these value.
- */
-
-#define IBV_RESP_TO_VERBS_RESP_EX_RAW(ex_ptr, ex_type, ibv_type, field) \
- ((ibv_type *)((void *)(ex_ptr) + offsetof(ex_type, \
- field) + sizeof((ex_ptr)->field)))
-
-#define IBV_RESP_TO_VERBS_RESP_EX(ex_ptr, ex_type, ibv_type) \
- IBV_RESP_TO_VERBS_RESP_EX_RAW(ex_ptr, ex_type, ibv_type, comp_mask)
-
-
-#define IB_USER_VERBS_CMD_COMMAND_MASK 0xff
-#define IB_USER_VERBS_CMD_FLAGS_MASK 0xff000000u
-#define IB_USER_VERBS_CMD_FLAGS_SHIFT 24
-
-#define IB_USER_VERBS_CMD_FLAG_EXTENDED 0x80
-
-struct ib_uverbs_cmd_hdr {
- __u32 command;
- __u16 in_words;
- __u16 out_words;
-};
-
-struct ib_uverbs_ex_cmd_hdr {
- __u64 response;
- __u16 provider_in_words;
- __u16 provider_out_words;
- __u32 cmd_hdr_reserved;
-};
-
-struct ib_uverbs_get_context {
- __u64 response;
- __u64 driver_data[0];
-};
-
-struct ib_uverbs_get_context_resp {
- __u32 async_fd;
- __u32 num_comp_vectors;
-};
-
-struct ib_uverbs_query_device {
- __u64 response;
- __u64 driver_data[0];
-};
-
-struct ib_uverbs_query_device_ex {
- __u64 comp_mask;
- __u64 driver_data[0];
-};
-
-struct ib_uverbs_query_device_resp {
- __u64 fw_ver;
- __be64 node_guid;
- __be64 sys_image_guid;
- __u64 max_mr_size;
- __u64 page_size_cap;
- __u32 vendor_id;
- __u32 vendor_part_id;
- __u32 hw_ver;
- __u32 max_qp;
- __u32 max_qp_wr;
- __u32 device_cap_flags;
- __u32 max_sge;
- __u32 max_sge_rd;
- __u32 max_cq;
- __u32 max_cqe;
- __u32 max_mr;
- __u32 max_pd;
- __u32 max_qp_rd_atom;
- __u32 max_ee_rd_atom;
- __u32 max_res_rd_atom;
- __u32 max_qp_init_rd_atom;
- __u32 max_ee_init_rd_atom;
- __u32 atomic_cap;
- __u32 max_ee;
- __u32 max_rdd;
- __u32 max_mw;
- __u32 max_raw_ipv6_qp;
- __u32 max_raw_ethy_qp;
- __u32 max_mcast_grp;
- __u32 max_mcast_qp_attach;
- __u32 max_total_mcast_qp_attach;
- __u32 max_ah;
- __u32 max_fmr;
- __u32 max_map_per_fmr;
- __u32 max_srq;
- __u32 max_srq_wr;
- __u32 max_srq_sge;
- __u16 max_pkeys;
- __u8 local_ca_ack_delay;
- __u8 phys_port_cnt;
- __u8 reserved[4];
-};
-
-struct ib_uverbs_query_port {
- __u64 response;
- __u8 port_num;
- __u8 reserved[7];
- __u64 driver_data[0];
-};
-
-struct ib_uverbs_query_port_resp {
- __u32 port_cap_flags;
- __u32 max_msg_sz;
- __u32 bad_pkey_cntr;
- __u32 qkey_viol_cntr;
- __u32 gid_tbl_len;
- __u16 pkey_tbl_len;
- __u16 lid;
- __u16 sm_lid;
- __u8 state;
- __u8 max_mtu;
- __u8 active_mtu;
- __u8 lmc;
- __u8 max_vl_num;
- __u8 sm_sl;
- __u8 subnet_timeout;
- __u8 init_type_reply;
- __u8 active_width;
- __u8 active_speed;
- __u8 phys_state;
- __u8 link_layer;
- __u8 reserved[2];
-};
-
-struct ib_uverbs_alloc_pd {
- __u64 response;
- __u64 driver_data[0];
-};
-
-struct ib_uverbs_alloc_pd_resp {
- __u32 pd_handle;
-};
-
-struct ib_uverbs_dealloc_pd {
- __u32 pd_handle;
-};
-
-struct ib_uverbs_open_xrcd {
- __u64 response;
- __u32 fd;
- __u32 oflags;
- __u64 driver_data[0];
-};
-
-struct ib_uverbs_open_xrcd_resp {
- __u32 xrcd_handle;
-};
-
-struct ib_uverbs_close_xrcd {
- __u32 xrcd_handle;
-};
-
-struct ib_uverbs_reg_mr {
- __u64 response;
- __u64 start;
- __u64 length;
- __u64 hca_va;
- __u32 pd_handle;
- __u32 access_flags;
- __u64 driver_data[0];
-};
-
-struct ib_uverbs_reg_mr_resp {
- __u32 mr_handle;
- __u32 lkey;
- __u32 rkey;
-};
-
-struct ib_uverbs_dereg_mr {
- __u32 mr_handle;
-};
-
-struct ib_uverbs_alloc_mw {
- __u64 response;
- __u32 pd_handle;
- __u8 mw_type;
- __u8 reserved[3];
-};
-
-struct ib_uverbs_alloc_mw_resp {
- __u32 mw_handle;
- __u32 rkey;
-};
-
-struct ib_uverbs_dealloc_mw {
- __u32 mw_handle;
-};
-
-struct ib_uverbs_create_comp_channel {
- __u64 response;
-};
-
-struct ib_uverbs_create_comp_channel_resp {
- __u32 fd;
-};
-
-struct ib_uverbs_create_cq {
- __u64 response;
- __u64 user_handle;
- __u32 cqe;
- __u32 comp_vector;
- __s32 comp_channel;
- __u32 reserved;
- __u64 driver_data[0];
-};
-
-struct ib_uverbs_create_cq_resp {
- __u32 cq_handle;
- __u32 cqe;
-};
-
-enum ib_uverbs_create_cq_ex_comp_mask {
- IB_UVERBS_CREATE_CQ_EX_CAP_FLAGS = (u64)1 << 0,
-};
-
-struct ib_uverbs_create_cq_ex {
- __u64 comp_mask;
- __u64 user_handle;
- __u32 cqe;
- __u32 comp_vector;
- __s32 comp_channel;
- __u32 reserved;
- __u64 create_flags;
- __u64 driver_data[0];
-};
-
-struct ib_uverbs_modify_cq_ex {
- __u64 comp_mask;
- __u32 cq_handle;
- __u32 attr_mask;
- __u16 cq_count;
- __u16 cq_period;
- __u32 cq_cap_flags;
-};
-
-struct ib_uverbs_resize_cq {
- __u64 response;
- __u32 cq_handle;
- __u32 cqe;
- __u64 driver_data[0];
-};
-
-struct ib_uverbs_resize_cq_resp {
- __u32 cqe;
- __u32 reserved;
- __u64 driver_data[0];
-};
-
-struct ib_uverbs_poll_cq {
- __u64 response;
- __u32 cq_handle;
- __u32 ne;
-};
-
-struct ib_uverbs_wc {
- __u64 wr_id;
- __u32 status;
- __u32 opcode;
- __u32 vendor_err;
- __u32 byte_len;
- union {
- __u32 imm_data;
- __u32 invalidate_rkey;
- } ex;
- __u32 qp_num;
- __u32 src_qp;
- __u32 wc_flags;
- __u16 pkey_index;
- __u16 slid;
- __u8 sl;
- __u8 dlid_path_bits;
- __u8 port_num;
- __u8 reserved;
-};
-
-struct ib_uverbs_poll_cq_resp {
- __u32 count;
- __u32 reserved;
- struct ib_uverbs_wc wc[0];
-};
-
-struct ib_uverbs_req_notify_cq {
- __u32 cq_handle;
- __u32 solicited_only;
-};
-
-struct ib_uverbs_destroy_cq {
- __u64 response;
- __u32 cq_handle;
- __u32 reserved;
-};
-
-struct ib_uverbs_destroy_cq_resp {
- __u32 comp_events_reported;
- __u32 async_events_reported;
-};
-
-struct ib_uverbs_global_route {
- __u8 dgid[16];
- __u32 flow_label;
- __u8 sgid_index;
- __u8 hop_limit;
- __u8 traffic_class;
- __u8 reserved;
-};
-
-struct ib_uverbs_ah_attr {
- struct ib_uverbs_global_route grh;
- __u16 dlid;
- __u8 sl;
- __u8 src_path_bits;
- __u8 static_rate;
- __u8 is_global;
- __u8 port_num;
- __u8 reserved;
-};
-
-struct ib_uverbs_qp_attr {
- __u32 qp_attr_mask;
- __u32 qp_state;
- __u32 cur_qp_state;
- __u32 path_mtu;
- __u32 path_mig_state;
- __u32 qkey;
- __u32 rq_psn;
- __u32 sq_psn;
- __u32 dest_qp_num;
- __u32 qp_access_flags;
-
- struct ib_uverbs_ah_attr ah_attr;
- struct ib_uverbs_ah_attr alt_ah_attr;
-
- /* ib_qp_cap */
- __u32 max_send_wr;
- __u32 max_recv_wr;
- __u32 max_send_sge;
- __u32 max_recv_sge;
- __u32 max_inline_data;
-
- __u16 pkey_index;
- __u16 alt_pkey_index;
- __u8 en_sqd_async_notify;
- __u8 sq_draining;
- __u8 max_rd_atomic;
- __u8 max_dest_rd_atomic;
- __u8 min_rnr_timer;
- __u8 port_num;
- __u8 timeout;
- __u8 retry_cnt;
- __u8 rnr_retry;
- __u8 alt_port_num;
- __u8 alt_timeout;
- __u8 reserved[5];
-};
-
-struct ib_uverbs_create_qp {
- __u64 response;
- __u64 user_handle;
- __u32 pd_handle;
- __u32 send_cq_handle;
- __u32 recv_cq_handle;
- __u32 srq_handle;
- __u32 max_send_wr;
- __u32 max_recv_wr;
- __u32 max_send_sge;
- __u32 max_recv_sge;
- __u32 max_inline_data;
- __u8 sq_sig_all;
- __u8 qp_type;
- __u8 is_srq;
- __u8 reserved;
- __u64 driver_data[0];
-};
-
-struct ib_uverbs_open_qp {
- __u64 response;
- __u64 user_handle;
- __u32 pd_handle;
- __u32 qpn;
- __u8 qp_type;
- __u8 reserved[7];
- __u64 driver_data[0];
-};
-
-/* also used for open response */
-struct ib_uverbs_create_qp_resp {
- __u32 qp_handle;
- __u32 qpn;
- __u32 max_send_wr;
- __u32 max_recv_wr;
- __u32 max_send_sge;
- __u32 max_recv_sge;
- __u32 max_inline_data;
- __u32 reserved;
-};
-
-/*
- * This struct needs to remain a multiple of 8 bytes to keep the
- * alignment of the modify QP parameters.
- */
-struct ib_uverbs_qp_dest {
- __u8 dgid[16];
- __u32 flow_label;
- __u16 dlid;
- __u16 reserved;
- __u8 sgid_index;
- __u8 hop_limit;
- __u8 traffic_class;
- __u8 sl;
- __u8 src_path_bits;
- __u8 static_rate;
- __u8 is_global;
- __u8 port_num;
-};
-
-struct ib_uverbs_query_qp {
- __u64 response;
- __u32 qp_handle;
- __u32 attr_mask;
- __u64 driver_data[0];
-};
-
-struct ib_uverbs_query_qp_resp {
- struct ib_uverbs_qp_dest dest;
- struct ib_uverbs_qp_dest alt_dest;
- __u32 max_send_wr;
- __u32 max_recv_wr;
- __u32 max_send_sge;
- __u32 max_recv_sge;
- __u32 max_inline_data;
- __u32 qkey;
- __u32 rq_psn;
- __u32 sq_psn;
- __u32 dest_qp_num;
- __u32 qp_access_flags;
- __u16 pkey_index;
- __u16 alt_pkey_index;
- __u8 qp_state;
- __u8 cur_qp_state;
- __u8 path_mtu;
- __u8 path_mig_state;
- __u8 sq_draining;
- __u8 max_rd_atomic;
- __u8 max_dest_rd_atomic;
- __u8 min_rnr_timer;
- __u8 port_num;
- __u8 timeout;
- __u8 retry_cnt;
- __u8 rnr_retry;
- __u8 alt_port_num;
- __u8 alt_timeout;
- __u8 sq_sig_all;
- __u8 reserved[5];
- __u64 driver_data[0];
-};
-
-struct ib_uverbs_modify_qp {
- struct ib_uverbs_qp_dest dest;
- struct ib_uverbs_qp_dest alt_dest;
- __u32 qp_handle;
- __u32 attr_mask;
- __u32 qkey;
- __u32 rq_psn;
- __u32 sq_psn;
- __u32 dest_qp_num;
- __u32 qp_access_flags;
- __u16 pkey_index;
- __u16 alt_pkey_index;
- __u8 qp_state;
- __u8 cur_qp_state;
- __u8 path_mtu;
- __u8 path_mig_state;
- __u8 en_sqd_async_notify;
- __u8 max_rd_atomic;
- __u8 max_dest_rd_atomic;
- __u8 min_rnr_timer;
- __u8 port_num;
- __u8 timeout;
- __u8 retry_cnt;
- __u8 rnr_retry;
- __u8 alt_port_num;
- __u8 alt_timeout;
- __u8 reserved[2];
- __u64 driver_data[0];
-};
-
-enum ib_uverbs_modify_qp_ex_comp_mask {
- IB_UVERBS_QP_ATTR_DCT_KEY = 1ULL << 0,
-};
-
-struct ib_uverbs_modify_qp_ex {
- __u32 comp_mask;
- struct ib_uverbs_qp_dest dest;
- struct ib_uverbs_qp_dest alt_dest;
- __u32 qp_handle;
- __u32 attr_mask;
- __u32 qkey;
- __u32 rq_psn;
- __u32 sq_psn;
- __u32 dest_qp_num;
- __u32 qp_access_flags;
- __u16 pkey_index;
- __u16 alt_pkey_index;
- __u8 qp_state;
- __u8 cur_qp_state;
- __u8 path_mtu;
- __u8 path_mig_state;
- __u8 en_sqd_async_notify;
- __u8 max_rd_atomic;
- __u8 max_dest_rd_atomic;
- __u8 min_rnr_timer;
- __u8 port_num;
- __u8 timeout;
- __u8 retry_cnt;
- __u8 rnr_retry;
- __u8 alt_port_num;
- __u8 alt_timeout;
- __u8 reserved[2];
- __u64 dct_key;
- __u64 driver_data[0];
-};
-
-struct ib_uverbs_modify_qp_resp {
-};
-
-struct ib_uverbs_destroy_qp {
- __u64 response;
- __u32 qp_handle;
- __u32 reserved;
-};
-
-struct ib_uverbs_destroy_qp_resp {
- __u32 events_reported;
-};
-
-/*
- * The ib_uverbs_sge structure isn't used anywhere, since we assume
- * the ib_sge structure is packed the same way on 32-bit and 64-bit
- * architectures in both kernel and user space. It's just here to
- * document the ABI.
- */
-struct ib_uverbs_sge {
- __u64 addr;
- __u32 length;
- __u32 lkey;
-};
-
-struct ib_uverbs_send_wr {
- __u64 wr_id;
- __u32 num_sge;
- __u32 opcode;
- __u32 send_flags;
- union {
- __u32 imm_data;
- __u32 invalidate_rkey;
- } ex;
- union {
- struct {
- __u64 remote_addr;
- __u32 rkey;
- __u32 reserved;
- } rdma;
- struct {
- __u64 remote_addr;
- __u64 compare_add;
- __u64 swap;
- __u32 rkey;
- __u32 reserved;
- } atomic;
- struct {
- __u32 ah;
- __u32 remote_qpn;
- __u32 remote_qkey;
- __u32 reserved;
- } ud;
- } wr;
-};
-
-struct ib_uverbs_post_send {
- __u64 response;
- __u32 qp_handle;
- __u32 wr_count;
- __u32 sge_count;
- __u32 wqe_size;
- struct ib_uverbs_send_wr send_wr[0];
-};
-
-struct ib_uverbs_post_send_resp {
- __u32 bad_wr;
-};
-
-struct ib_uverbs_recv_wr {
- __u64 wr_id;
- __u32 num_sge;
- __u32 reserved;
-};
-
-struct ib_uverbs_post_recv {
- __u64 response;
- __u32 qp_handle;
- __u32 wr_count;
- __u32 sge_count;
- __u32 wqe_size;
- struct ib_uverbs_recv_wr recv_wr[0];
-};
-
-struct ib_uverbs_post_recv_resp {
- __u32 bad_wr;
-};
-
-struct ib_uverbs_post_srq_recv {
- __u64 response;
- __u32 srq_handle;
- __u32 wr_count;
- __u32 sge_count;
- __u32 wqe_size;
- struct ib_uverbs_recv_wr recv[0];
-};
-
-struct ib_uverbs_post_srq_recv_resp {
- __u32 bad_wr;
-};
-
-struct ib_uverbs_create_ah {
- __u64 response;
- __u64 user_handle;
- __u32 pd_handle;
- __u32 reserved;
- struct ib_uverbs_ah_attr attr;
-};
-
-struct ib_uverbs_create_ah_resp {
- __u32 ah_handle;
-};
-
-struct ib_uverbs_destroy_ah {
- __u32 ah_handle;
-};
-
-struct ib_uverbs_attach_mcast {
- __u8 gid[16];
- __u32 qp_handle;
- __u16 mlid;
- __u16 reserved;
- __u64 driver_data[0];
-};
-
-struct ib_uverbs_detach_mcast {
- __u8 gid[16];
- __u32 qp_handle;
- __u16 mlid;
- __u16 reserved;
- __u64 driver_data[0];
-};
-
-struct ib_uverbs_flow_spec_hdr {
- __u32 type;
- __u16 size;
- __u16 reserved;
- /* followed by flow_spec */
- __u64 flow_spec_data[0];
-};
-
-struct ib_kern_eth_filter {
- __u8 dst_mac[6];
- __u8 src_mac[6];
- __be16 ether_type;
- __be16 vlan_tag;
-};
-
-struct ib_uverbs_flow_spec_eth {
- union {
- struct ib_uverbs_flow_spec_hdr hdr;
- struct {
- __u32 type;
- __u16 size;
- __u16 reserved;
- };
- };
- struct ib_kern_eth_filter val;
- struct ib_kern_eth_filter mask;
-};
-
-struct ib_kern_ib_filter {
- __be32 l3_type_qpn;
- __u8 dst_gid[16];
-};
-
-struct ib_uverbs_flow_spec_ib {
- union {
- struct ib_uverbs_flow_spec_hdr hdr;
- struct {
- __u32 type;
- __u16 size;
- __u16 reserved;
- };
- };
- struct ib_kern_ib_filter val;
- struct ib_kern_ib_filter mask;
-};
-
-struct ib_kern_ipv4_filter {
- __be32 src_ip;
- __be32 dst_ip;
-};
-
-struct ib_uverbs_flow_spec_ipv4 {
- union {
- struct ib_uverbs_flow_spec_hdr hdr;
- struct {
- __u32 type;
- __u16 size;
- __u16 reserved;
- };
- };
- struct ib_kern_ipv4_filter val;
- struct ib_kern_ipv4_filter mask;
-};
-
-struct ib_kern_tcp_udp_filter {
- __be16 dst_port;
- __be16 src_port;
-};
-
-struct ib_uverbs_flow_spec_tcp_udp {
- union {
- struct ib_uverbs_flow_spec_hdr hdr;
- struct {
- __u32 type;
- __u16 size;
- __u16 reserved;
- };
- };
- struct ib_kern_tcp_udp_filter val;
- struct ib_kern_tcp_udp_filter mask;
-};
-
-struct ib_uverbs_flow_attr {
- __u32 type;
- __u16 size;
- __u16 priority;
- __u8 num_of_specs;
- __u8 reserved[2];
- __u8 port;
- __u32 flags;
- /* Following are the optional layers according to user request
- * struct ib_flow_spec_xxx
- * struct ib_flow_spec_yyy
- */
- struct ib_uverbs_flow_spec_hdr flow_specs[0];
-};
-
-struct ib_uverbs_create_flow {
- __u32 comp_mask;
- __u32 qp_handle;
- struct ib_uverbs_flow_attr flow_attr;
-};
-
-struct ib_uverbs_create_flow_resp {
- __u32 comp_mask;
- __u32 flow_handle;
-};
-
-struct ib_uverbs_destroy_flow {
- __u32 comp_mask;
- __u32 flow_handle;
-};
-
-struct ib_uverbs_create_srq {
- __u64 response;
- __u64 user_handle;
- __u32 pd_handle;
- __u32 max_wr;
- __u32 max_sge;
- __u32 srq_limit;
- __u64 driver_data[0];
-};
-
-struct ib_uverbs_create_xsrq {
- __u64 response;
- __u64 user_handle;
- __u32 srq_type;
- __u32 pd_handle;
- __u32 max_wr;
- __u32 max_sge;
- __u32 srq_limit;
- __u32 reserved;
- __u32 xrcd_handle;
- __u32 cq_handle;
- __u64 driver_data[0];
-};
-
-struct ib_uverbs_create_srq_resp {
- __u32 srq_handle;
- __u32 max_wr;
- __u32 max_sge;
- __u32 srqn;
-};
-
-struct ib_uverbs_modify_srq {
- __u32 srq_handle;
- __u32 attr_mask;
- __u32 max_wr;
- __u32 srq_limit;
- __u64 driver_data[0];
-};
-
-struct ib_uverbs_query_srq {
- __u64 response;
- __u32 srq_handle;
- __u32 reserved;
- __u64 driver_data[0];
-};
-
-struct ib_uverbs_query_srq_resp {
- __u32 max_wr;
- __u32 max_sge;
- __u32 srq_limit;
- __u32 reserved;
-};
-
-struct ib_uverbs_destroy_srq {
- __u64 response;
- __u32 srq_handle;
- __u32 reserved;
-};
-
-struct ib_uverbs_destroy_srq_resp {
- __u32 events_reported;
-};
-
-
-/*
- * Legacy extended verbs related structures
- */
-struct ib_uverbs_ex_cmd_hdr_legacy {
- __u32 command;
- __u16 in_words;
- __u16 out_words;
- __u16 provider_in_words;
- __u16 provider_out_words;
- __u32 cmd_hdr_reserved;
-};
-
-struct ib_uverbs_ex_cmd_resp1_legacy {
- __u64 comp_mask;
- __u64 response;
-};
-
-#endif /* IB_USER_VERBS_H */
diff --git a/sys/ofed/include/rdma/ib_user_verbs_exp.h b/sys/ofed/include/rdma/ib_user_verbs_exp.h
deleted file mode 100644
index 557d4ba..0000000
--- a/sys/ofed/include/rdma/ib_user_verbs_exp.h
+++ /dev/null
@@ -1,204 +0,0 @@
-/*
- * Copyright (c) 2005 Topspin Communications. All rights reserved.
- * Copyright (c) 2005, 2006 Cisco Systems. All rights reserved.
- * Copyright (c) 2005 PathScale, Inc. All rights reserved.
- * Copyright (c) 2006 Mellanox Technologies. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-#ifndef IB_USER_VERBS_EXP_H
-#define IB_USER_VERBS_EXP_H
-
-#include <rdma/ib_user_verbs.h>
-
-enum {
- IB_USER_VERBS_EXP_CMD_FIRST = 64
-};
-
-enum {
- IB_USER_VERBS_EXP_CMD_CREATE_QP,
- IB_USER_VERBS_EXP_CMD_MODIFY_CQ,
- IB_USER_VERBS_EXP_CMD_MODIFY_QP,
- IB_USER_VERBS_EXP_CMD_CREATE_CQ,
- IB_USER_VERBS_EXP_CMD_QUERY_DEVICE,
- IB_USER_VERBS_EXP_CMD_CREATE_DCT,
- IB_USER_VERBS_EXP_CMD_DESTROY_DCT,
- IB_USER_VERBS_EXP_CMD_QUERY_DCT,
-};
-
-/*
- * Make sure that all structs defined in this file remain laid out so
- * that they pack the same way on 32-bit and 64-bit architectures (to
- * avoid incompatibility between 32-bit userspace and 64-bit kernels).
- * Specifically:
- * - Do not use pointer types -- pass pointers in __u64 instead.
- * - Make sure that any structure larger than 4 bytes is padded to a
- * multiple of 8 bytes. Otherwise the structure size will be
- * different between 32-bit and 64-bit architectures.
- */
-
-enum ib_uverbs_exp_create_qp_comp_mask {
- IB_UVERBS_EXP_CREATE_QP_CAP_FLAGS = (1ULL << 0),
- IB_UVERBS_EXP_CREATE_QP_INL_RECV = (1ULL << 1),
- IB_UVERBS_EXP_CREATE_QP_QPG = (1ULL << 2)
-};
-
-struct ib_uverbs_qpg_init_attrib {
- __u32 tss_child_count;
- __u32 rss_child_count;
-};
-
-struct ib_uverbs_qpg {
- __u32 qpg_type;
- union {
- struct {
- __u32 parent_handle;
- __u32 reserved;
- };
- struct ib_uverbs_qpg_init_attrib parent_attrib;
- };
- __u32 reserved2;
-};
-
-struct ib_uverbs_exp_create_qp {
- __u64 comp_mask;
- __u64 user_handle;
- __u32 pd_handle;
- __u32 send_cq_handle;
- __u32 recv_cq_handle;
- __u32 srq_handle;
- __u32 max_send_wr;
- __u32 max_recv_wr;
- __u32 max_send_sge;
- __u32 max_recv_sge;
- __u32 max_inline_data;
- __u8 sq_sig_all;
- __u8 qp_type;
- __u8 is_srq;
- __u8 reserved;
- __u64 qp_cap_flags;
- __u32 max_inl_recv;
- __u32 reserved1;
- struct ib_uverbs_qpg qpg;
- __u64 driver_data[0];
-};
-
-enum ib_uverbs_exp_create_qp_resp_comp_mask {
- IB_UVERBS_EXP_CREATE_QP_RESP_INL_RECV = (1ULL << 0),
-};
-
-struct ib_uverbs_exp_create_qp_resp {
- __u64 comp_mask;
- __u32 qp_handle;
- __u32 qpn;
- __u32 max_send_wr;
- __u32 max_recv_wr;
- __u32 max_send_sge;
- __u32 max_recv_sge;
- __u32 max_inline_data;
- __u32 max_inl_recv;
-};
-
-struct ib_uverbs_create_dct {
- __u64 comp_mask;
- __u64 user_handle;
- __u32 pd_handle;
- __u32 cq_handle;
- __u32 srq_handle;
- __u32 access_flags;
- __u32 flow_label;
- __u64 dc_key;
- __u8 min_rnr_timer;
- __u8 tclass;
- __u8 port;
- __u8 pkey_index;
- __u8 gid_index;
- __u8 hop_limit;
- __u8 mtu;
- __u8 rsvd;
- __u32 create_flags;
- __u64 driver_data[0];
-};
-
-struct ib_uverbs_create_dct_resp {
- __u32 dct_handle;
- __u32 dctn;
-};
-
-struct ib_uverbs_destroy_dct {
- __u64 comp_mask;
- __u64 user_handle;
-};
-
-struct ib_uverbs_destroy_dct_resp {
- __u64 reserved;
-};
-
-struct ib_uverbs_query_dct {
- __u64 comp_mask;
- __u64 dct_handle;
- __u64 driver_data[0];
-};
-
-struct ib_uverbs_query_dct_resp {
- __u64 dc_key;
- __u32 access_flags;
- __u32 flow_label;
- __u32 key_violations;
- __u8 port;
- __u8 min_rnr_timer;
- __u8 tclass;
- __u8 mtu;
- __u8 pkey_index;
- __u8 gid_index;
- __u8 hop_limit;
- __u8 state;
- __u32 rsvd;
- __u64 driver_data[0];
-};
-
-struct ib_uverbs_exp_query_device {
- __u64 comp_mask;
- __u64 driver_data[0];
-};
-
-struct ib_uverbs_exp_query_device_resp {
- __u64 comp_mask;
- struct ib_uverbs_query_device_resp base;
- __u64 timestamp_mask;
- __u64 hca_core_clock;
- __u64 device_cap_flags2;
- __u32 dc_rd_req;
- __u32 dc_rd_res;
- __u32 inline_recv_sz;
- __u32 max_rss_tbl_sz;
-};
-
-#endif /* IB_USER_VERBS_EXP_H */
diff --git a/sys/ofed/include/rdma/ib_verbs.h b/sys/ofed/include/rdma/ib_verbs.h
index 437c725..b367726 100644
--- a/sys/ofed/include/rdma/ib_verbs.h
+++ b/sys/ofed/include/rdma/ib_verbs.h
@@ -48,12 +48,24 @@
#include <linux/rwsem.h>
#include <linux/scatterlist.h>
#include <linux/workqueue.h>
+#include <linux/socket.h>
#include <linux/if_ether.h>
-#include <linux/mutex.h>
-
+#include <net/ipv6.h>
+#include <net/ip.h>
+#include <linux/string.h>
+#include <linux/slab.h>
+#include <linux/rcupdate.h>
+#include <linux/netdevice.h>
+#include <netinet/ip.h>
+
+#include <asm/atomic.h>
#include <asm/uaccess.h>
+struct ifla_vf_info;
+struct ifla_vf_stats;
+
extern struct workqueue_struct *ib_wq;
+extern struct workqueue_struct *ib_comp_wq;
union ib_gid {
u8 raw[16];
@@ -63,50 +75,116 @@ union ib_gid {
} global;
};
+extern union ib_gid zgid;
+
+enum ib_gid_type {
+ /* If link layer is Ethernet, this is RoCE V1 */
+ IB_GID_TYPE_IB = 0,
+ IB_GID_TYPE_ROCE = 0,
+ IB_GID_TYPE_ROCE_UDP_ENCAP = 1,
+ IB_GID_TYPE_SIZE
+};
+
+#define ROCE_V2_UDP_DPORT 4791
+struct ib_gid_attr {
+ enum ib_gid_type gid_type;
+ struct net_device *ndev;
+};
+
enum rdma_node_type {
/* IB values map to NodeInfo:NodeType. */
RDMA_NODE_IB_CA = 1,
RDMA_NODE_IB_SWITCH,
RDMA_NODE_IB_ROUTER,
RDMA_NODE_RNIC,
- RDMA_NODE_MIC
+ RDMA_NODE_USNIC,
+ RDMA_NODE_USNIC_UDP,
+};
+
+enum {
+ /* set the local administered indication */
+ IB_SA_WELL_KNOWN_GUID = BIT_ULL(57) | 2,
};
enum rdma_transport_type {
RDMA_TRANSPORT_IB,
RDMA_TRANSPORT_IWARP,
- RDMA_TRANSPORT_SCIF
+ RDMA_TRANSPORT_USNIC,
+ RDMA_TRANSPORT_USNIC_UDP
};
-enum rdma_transport_type
-rdma_node_get_transport(enum rdma_node_type node_type) __attribute_const__;
+enum rdma_protocol_type {
+ RDMA_PROTOCOL_IB,
+ RDMA_PROTOCOL_IBOE,
+ RDMA_PROTOCOL_IWARP,
+ RDMA_PROTOCOL_USNIC_UDP
+};
+
+__attribute_const__ enum rdma_transport_type
+rdma_node_get_transport(enum rdma_node_type node_type);
+
+enum rdma_network_type {
+ RDMA_NETWORK_IB,
+ RDMA_NETWORK_ROCE_V1 = RDMA_NETWORK_IB,
+ RDMA_NETWORK_IPV4,
+ RDMA_NETWORK_IPV6
+};
+
+static inline enum ib_gid_type ib_network_to_gid_type(enum rdma_network_type network_type)
+{
+ if (network_type == RDMA_NETWORK_IPV4 ||
+ network_type == RDMA_NETWORK_IPV6)
+ return IB_GID_TYPE_ROCE_UDP_ENCAP;
+
+ /* IB_GID_TYPE_IB same as RDMA_NETWORK_ROCE_V1 */
+ return IB_GID_TYPE_IB;
+}
+
+static inline enum rdma_network_type ib_gid_to_network_type(enum ib_gid_type gid_type,
+ union ib_gid *gid)
+{
+ if (gid_type == IB_GID_TYPE_IB)
+ return RDMA_NETWORK_IB;
+
+ if (ipv6_addr_v4mapped((struct in6_addr *)gid))
+ return RDMA_NETWORK_IPV4;
+ else
+ return RDMA_NETWORK_IPV6;
+}
enum rdma_link_layer {
IB_LINK_LAYER_UNSPECIFIED,
IB_LINK_LAYER_INFINIBAND,
IB_LINK_LAYER_ETHERNET,
- IB_LINK_LAYER_SCIF
};
enum ib_device_cap_flags {
- IB_DEVICE_RESIZE_MAX_WR = 1,
- IB_DEVICE_BAD_PKEY_CNTR = (1<<1),
- IB_DEVICE_BAD_QKEY_CNTR = (1<<2),
- IB_DEVICE_RAW_MULTI = (1<<3),
- IB_DEVICE_AUTO_PATH_MIG = (1<<4),
- IB_DEVICE_CHANGE_PHY_PORT = (1<<5),
- IB_DEVICE_UD_AV_PORT_ENFORCE = (1<<6),
- IB_DEVICE_CURR_QP_STATE_MOD = (1<<7),
- IB_DEVICE_SHUTDOWN_PORT = (1<<8),
- IB_DEVICE_INIT_TYPE = (1<<9),
- IB_DEVICE_PORT_ACTIVE_EVENT = (1<<10),
- IB_DEVICE_SYS_IMAGE_GUID = (1<<11),
- IB_DEVICE_RC_RNR_NAK_GEN = (1<<12),
- IB_DEVICE_SRQ_RESIZE = (1<<13),
- IB_DEVICE_N_NOTIFY_CQ = (1<<14),
- IB_DEVICE_LOCAL_DMA_LKEY = (1<<15),
- IB_DEVICE_RESERVED = (1<<16), /* old SEND_W_INV */
- IB_DEVICE_MEM_WINDOW = (1<<17),
+ IB_DEVICE_RESIZE_MAX_WR = (1 << 0),
+ IB_DEVICE_BAD_PKEY_CNTR = (1 << 1),
+ IB_DEVICE_BAD_QKEY_CNTR = (1 << 2),
+ IB_DEVICE_RAW_MULTI = (1 << 3),
+ IB_DEVICE_AUTO_PATH_MIG = (1 << 4),
+ IB_DEVICE_CHANGE_PHY_PORT = (1 << 5),
+ IB_DEVICE_UD_AV_PORT_ENFORCE = (1 << 6),
+ IB_DEVICE_CURR_QP_STATE_MOD = (1 << 7),
+ IB_DEVICE_SHUTDOWN_PORT = (1 << 8),
+ IB_DEVICE_INIT_TYPE = (1 << 9),
+ IB_DEVICE_PORT_ACTIVE_EVENT = (1 << 10),
+ IB_DEVICE_SYS_IMAGE_GUID = (1 << 11),
+ IB_DEVICE_RC_RNR_NAK_GEN = (1 << 12),
+ IB_DEVICE_SRQ_RESIZE = (1 << 13),
+ IB_DEVICE_N_NOTIFY_CQ = (1 << 14),
+
+ /*
+ * This device supports a per-device lkey or stag that can be
+ * used without performing a memory registration for the local
+ * memory. Note that ULPs should never check this flag, but
+ * instead of use the local_dma_lkey flag in the ib_pd structure,
+ * which will always contain a usable lkey.
+ */
+ IB_DEVICE_LOCAL_DMA_LKEY = (1 << 15),
+ IB_DEVICE_RESERVED /* old SEND_W_INV */ = (1 << 16),
+ IB_DEVICE_MEM_WINDOW = (1 << 17),
/*
* Devices should set IB_DEVICE_UD_IP_SUM if they support
* insertion of UDP and TCP checksum on outgoing UD IPoIB
@@ -114,27 +192,38 @@ enum ib_device_cap_flags {
* incoming messages. Setting this flag implies that the
* IPoIB driver may set NETIF_F_IP_CSUM for datagram mode.
*/
- IB_DEVICE_UD_IP_CSUM = (1<<18),
- IB_DEVICE_UD_TSO = (1<<19),
- IB_DEVICE_XRC = (1<<20),
- IB_DEVICE_MEM_MGT_EXTENSIONS = (1<<21),
- IB_DEVICE_BLOCK_MULTICAST_LOOPBACK = (1<<22),
- IB_DEVICE_MR_ALLOCATE = (1<<23),
- IB_DEVICE_SHARED_MR = (1<<24),
- IB_DEVICE_QPG = (1<<25),
- IB_DEVICE_UD_RSS = (1<<26),
- IB_DEVICE_UD_TSS = (1<<27),
- IB_DEVICE_CROSS_CHANNEL = (1<<28),
- IB_DEVICE_MANAGED_FLOW_STEERING = (1<<29),
+ IB_DEVICE_UD_IP_CSUM = (1 << 18),
+ IB_DEVICE_UD_TSO = (1 << 19),
+ IB_DEVICE_XRC = (1 << 20),
+
+ /*
+ * This device supports the IB "base memory management extension",
+ * which includes support for fast registrations (IB_WR_REG_MR,
+ * IB_WR_LOCAL_INV and IB_WR_SEND_WITH_INV verbs). This flag should
+ * also be set by any iWarp device which must support FRs to comply
+ * to the iWarp verbs spec. iWarp devices also support the
+ * IB_WR_RDMA_READ_WITH_INV verb for RDMA READs that invalidate the
+ * stag.
+ */
+ IB_DEVICE_MEM_MGT_EXTENSIONS = (1 << 21),
+ IB_DEVICE_BLOCK_MULTICAST_LOOPBACK = (1 << 22),
+ IB_DEVICE_MEM_WINDOW_TYPE_2A = (1 << 23),
+ IB_DEVICE_MEM_WINDOW_TYPE_2B = (1 << 24),
+ IB_DEVICE_RC_IP_CSUM = (1 << 25),
+ IB_DEVICE_RAW_IP_CSUM = (1 << 26),
/*
- * Devices can set either IB_DEVICE_MEM_WINDOW_TYPE_2A or
- * IB_DEVICE_MEM_WINDOW_TYPE_2B if it supports type 2A or type 2B
- * memory windows. It can set neither to indicate it doesn't support
- * type 2 windows at all.
+ * Devices should set IB_DEVICE_CROSS_CHANNEL if they
+ * support execution of WQEs that involve synchronization
+ * of I/O operations with single completion queue managed
+ * by hardware.
*/
- IB_DEVICE_MEM_WINDOW_TYPE_2A = (1<<30),
- IB_DEVICE_MEM_WINDOW_TYPE_2B = (1<<31),
- IB_DEVICE_SIGNATURE_HANDOVER = (1LL<<32)
+ IB_DEVICE_CROSS_CHANNEL = (1 << 27),
+ IB_DEVICE_MANAGED_FLOW_STEERING = (1 << 29),
+ IB_DEVICE_SIGNATURE_HANDOVER = (1 << 30),
+ IB_DEVICE_ON_DEMAND_PAGING = (1ULL << 31),
+ IB_DEVICE_SG_GAPS_REG = (1ULL << 32),
+ IB_DEVICE_VIRTUAL_FUNCTION = (1ULL << 33),
+ IB_DEVICE_RAW_SCATTER_FCS = (1ULL << 34),
};
enum ib_signature_prot_cap {
@@ -154,10 +243,46 @@ enum ib_atomic_cap {
IB_ATOMIC_GLOB
};
-enum ib_cq_create_flags {
- IB_CQ_CREATE_CROSS_CHANNEL = 1 << 0,
- IB_CQ_TIMESTAMP = 1 << 1,
- IB_CQ_TIMESTAMP_TO_SYS_TIME = 1 << 2
+enum ib_odp_general_cap_bits {
+ IB_ODP_SUPPORT = 1 << 0,
+};
+
+enum ib_odp_transport_cap_bits {
+ IB_ODP_SUPPORT_SEND = 1 << 0,
+ IB_ODP_SUPPORT_RECV = 1 << 1,
+ IB_ODP_SUPPORT_WRITE = 1 << 2,
+ IB_ODP_SUPPORT_READ = 1 << 3,
+ IB_ODP_SUPPORT_ATOMIC = 1 << 4,
+};
+
+struct ib_odp_caps {
+ uint64_t general_caps;
+ struct {
+ uint32_t rc_odp_caps;
+ uint32_t uc_odp_caps;
+ uint32_t ud_odp_caps;
+ } per_transport_caps;
+};
+
+struct ib_rss_caps {
+ /* Corresponding bit will be set if qp type from
+ * 'enum ib_qp_type' is supported, e.g.
+ * supported_qpts |= 1 << IB_QPT_UD
+ */
+ u32 supported_qpts;
+ u32 max_rwq_indirection_tables;
+ u32 max_rwq_indirection_table_size;
+};
+
+enum ib_cq_creation_flags {
+ IB_CQ_FLAGS_TIMESTAMP_COMPLETION = 1 << 0,
+ IB_CQ_FLAGS_IGNORE_OVERRUN = 1 << 1,
+};
+
+struct ib_cq_init_attr {
+ unsigned int cqe;
+ int comp_vector;
+ u32 flags;
};
struct ib_device_attr {
@@ -199,19 +324,15 @@ struct ib_device_attr {
int max_srq_wr;
int max_srq_sge;
unsigned int max_fast_reg_page_list_len;
- int max_rss_tbl_sz;
u16 max_pkeys;
u8 local_ca_ack_delay;
- int comp_mask;
- uint64_t timestamp_mask;
- uint64_t hca_core_clock;
- unsigned int sig_prot_cap;
- unsigned int sig_guard_cap;
-};
-
-enum ib_device_attr_comp_mask {
- IB_DEVICE_ATTR_WITH_TIMESTAMP_MASK = 1ULL << 1,
- IB_DEVICE_ATTR_WITH_HCA_CORE_CLOCK = 1ULL << 2
+ int sig_prot_cap;
+ int sig_guard_cap;
+ struct ib_odp_caps odp_caps;
+ uint64_t timestamp_mask;
+ uint64_t hca_core_clock; /* in KHZ */
+ struct ib_rss_caps rss_caps;
+ u32 max_wq_type_rq;
};
enum ib_mtu {
@@ -241,7 +362,7 @@ enum ib_port_state {
IB_PORT_ARMED = 3,
IB_PORT_ACTIVE = 4,
IB_PORT_ACTIVE_DEFER = 5,
- IB_PORT_DUMMY = -1 /* force enum signed */
+ IB_PORT_DUMMY = -1, /* force enum signed */
};
enum ib_port_cap_flags {
@@ -267,7 +388,8 @@ enum ib_port_cap_flags {
IB_PORT_CAP_MASK_NOTICE_SUP = 1 << 22,
IB_PORT_BOOT_MGMT_SUP = 1 << 23,
IB_PORT_LINK_LATENCY_SUP = 1 << 24,
- IB_PORT_CLIENT_REG_SUP = 1 << 25
+ IB_PORT_CLIENT_REG_SUP = 1 << 25,
+ IB_PORT_IP_BASED_GIDS = 1 << 26,
};
enum ib_port_width {
@@ -297,56 +419,55 @@ enum ib_port_speed {
IB_SPEED_EDR = 32
};
-struct ib_protocol_stats {
- /* TBD... */
-};
-
-struct iw_protocol_stats {
- u64 ipInReceives;
- u64 ipInHdrErrors;
- u64 ipInTooBigErrors;
- u64 ipInNoRoutes;
- u64 ipInAddrErrors;
- u64 ipInUnknownProtos;
- u64 ipInTruncatedPkts;
- u64 ipInDiscards;
- u64 ipInDelivers;
- u64 ipOutForwDatagrams;
- u64 ipOutRequests;
- u64 ipOutDiscards;
- u64 ipOutNoRoutes;
- u64 ipReasmTimeout;
- u64 ipReasmReqds;
- u64 ipReasmOKs;
- u64 ipReasmFails;
- u64 ipFragOKs;
- u64 ipFragFails;
- u64 ipFragCreates;
- u64 ipInMcastPkts;
- u64 ipOutMcastPkts;
- u64 ipInBcastPkts;
- u64 ipOutBcastPkts;
-
- u64 tcpRtoAlgorithm;
- u64 tcpRtoMin;
- u64 tcpRtoMax;
- u64 tcpMaxConn;
- u64 tcpActiveOpens;
- u64 tcpPassiveOpens;
- u64 tcpAttemptFails;
- u64 tcpEstabResets;
- u64 tcpCurrEstab;
- u64 tcpInSegs;
- u64 tcpOutSegs;
- u64 tcpRetransSegs;
- u64 tcpInErrs;
- u64 tcpOutRsts;
-};
-
-union rdma_protocol_stats {
- struct ib_protocol_stats ib;
- struct iw_protocol_stats iw;
-};
+/**
+ * struct rdma_hw_stats
+ * @timestamp - Used by the core code to track when the last update was
+ * @lifespan - Used by the core code to determine how old the counters
+ * should be before being updated again. Stored in jiffies, defaults
+ * to 10 milliseconds, drivers can override the default be specifying
+ * their own value during their allocation routine.
+ * @name - Array of pointers to static names used for the counters in
+ * directory.
+ * @num_counters - How many hardware counters there are. If name is
+ * shorter than this number, a kernel oops will result. Driver authors
+ * are encouraged to leave BUILD_BUG_ON(ARRAY_SIZE(@name) < num_counters)
+ * in their code to prevent this.
+ * @value - Array of u64 counters that are accessed by the sysfs code and
+ * filled in by the drivers get_stats routine
+ */
+struct rdma_hw_stats {
+ unsigned long timestamp;
+ unsigned long lifespan;
+ const char * const *names;
+ int num_counters;
+ u64 value[];
+};
+
+#define RDMA_HW_STATS_DEFAULT_LIFESPAN 10
+/**
+ * rdma_alloc_hw_stats_struct - Helper function to allocate dynamic struct
+ * for drivers.
+ * @names - Array of static const char *
+ * @num_counters - How many elements in array
+ * @lifespan - How many milliseconds between updates
+ */
+static inline struct rdma_hw_stats *rdma_alloc_hw_stats_struct(
+ const char * const *names, int num_counters,
+ unsigned long lifespan)
+{
+ struct rdma_hw_stats *stats;
+
+ stats = kzalloc(sizeof(*stats) + num_counters * sizeof(u64),
+ GFP_KERNEL);
+ if (!stats)
+ return NULL;
+ stats->names = names;
+ stats->num_counters = num_counters;
+ stats->lifespan = msecs_to_jiffies(lifespan);
+
+ return stats;
+}
+
/* Define bits for the various functionality this port needs to be supported by
* the core.
@@ -362,15 +483,12 @@ union rdma_protocol_stats {
/* Address format 0x000FF000 */
#define RDMA_CORE_CAP_AF_IB 0x00001000
#define RDMA_CORE_CAP_ETH_AH 0x00002000
-#define RDMA_CORE_CAP_OPA_AH 0x00004000
/* Protocol 0xFFF00000 */
#define RDMA_CORE_CAP_PROT_IB 0x00100000
#define RDMA_CORE_CAP_PROT_ROCE 0x00200000
#define RDMA_CORE_CAP_PROT_IWARP 0x00400000
#define RDMA_CORE_CAP_PROT_ROCE_UDP_ENCAP 0x00800000
-#define RDMA_CORE_CAP_PROT_RAW_PACKET 0x01000000
-#define RDMA_CORE_CAP_PROT_USNIC 0x02000000
#define RDMA_CORE_PORT_IBA_IB (RDMA_CORE_CAP_PROT_IB \
| RDMA_CORE_CAP_IB_MAD \
@@ -394,11 +512,8 @@ union rdma_protocol_stats {
#define RDMA_CORE_PORT_INTEL_OPA (RDMA_CORE_PORT_IBA_IB \
| RDMA_CORE_CAP_OPA_MAD)
-#define RDMA_CORE_PORT_RAW_PACKET (RDMA_CORE_CAP_PROT_RAW_PACKET)
-
-#define RDMA_CORE_PORT_USNIC (RDMA_CORE_CAP_PROT_USNIC)
-
struct ib_port_attr {
+ u64 subnet_prefix;
enum ib_port_state state;
enum ib_mtu max_mtu;
enum ib_mtu active_mtu;
@@ -418,6 +533,7 @@ struct ib_port_attr {
u8 active_width;
u8 active_speed;
u8 phys_state;
+ bool grh_required;
};
enum ib_device_modify_flags {
@@ -425,9 +541,11 @@ enum ib_device_modify_flags {
IB_DEVICE_MODIFY_NODE_DESC = 1 << 1
};
+#define IB_DEVICE_NODE_DESC_MAX 64
+
struct ib_device_modify {
u64 sys_image_guid;
- char node_desc[64];
+ char node_desc[IB_DEVICE_NODE_DESC_MAX];
};
enum ib_port_modify_flags {
@@ -462,14 +580,18 @@ enum ib_event_type {
IB_EVENT_QP_LAST_WQE_REACHED,
IB_EVENT_CLIENT_REREGISTER,
IB_EVENT_GID_CHANGE,
+ IB_EVENT_WQ_FATAL,
};
+const char *__attribute_const__ ib_event_msg(enum ib_event_type event);
+
struct ib_event {
struct ib_device *device;
union {
struct ib_cq *cq;
struct ib_qp *qp;
struct ib_srq *srq;
+ struct ib_wq *wq;
u8 port_num;
} element;
enum ib_event_type event;
@@ -505,11 +627,23 @@ struct ib_grh {
union ib_gid dgid;
};
+union rdma_network_hdr {
+ struct ib_grh ibgrh;
+ struct {
+ /* The IB spec states that if it's IPv4, the header
+ * is located in the last 20 bytes of the header.
+ */
+ u8 reserved[20];
+ struct ip roce4grh;
+ };
+};
+
enum {
IB_MULTICAST_QPN = 0xffffff
};
#define IB_LID_PERMISSIVE cpu_to_be16(0xFFFF)
+#define IB_MULTICAST_LID_BASE cpu_to_be16(0xC000)
enum ib_ah_flags {
IB_AH_GRH = 1
@@ -536,57 +670,48 @@ enum ib_rate {
IB_RATE_300_GBPS = 18
};
-enum ib_mr_create_flags {
- IB_MR_SIGNATURE_EN = 1,
-};
-
-/**
- * ib_mr_init_attr - Memory region init attributes passed to routine
- * ib_create_mr.
- * @max_reg_descriptors: max number of registration descriptors that
- * may be used with registration work requests.
- * @flags: MR creation flags bit mask.
- */
-struct ib_mr_init_attr {
- int max_reg_descriptors;
- u32 flags;
-};
-
/**
* ib_rate_to_mult - Convert the IB rate enum to a multiple of the
* base rate of 2.5 Gbit/sec. For example, IB_RATE_5_GBPS will be
* converted to 2, since 5 Gbit/sec is 2 * 2.5 Gbit/sec.
* @rate: rate to convert.
*/
-int ib_rate_to_mult(enum ib_rate rate) __attribute_const__;
+__attribute_const__ int ib_rate_to_mult(enum ib_rate rate);
/**
* ib_rate_to_mbps - Convert the IB rate enum to Mbps.
* For example, IB_RATE_2_5_GBPS will be converted to 2500.
* @rate: rate to convert.
*/
-int ib_rate_to_mbps(enum ib_rate rate) __attribute_const__;
+__attribute_const__ int ib_rate_to_mbps(enum ib_rate rate);
-struct ib_cq_init_attr {
- int cqe;
- int comp_vector;
- u32 flags;
-};
-enum ib_signature_type {
- IB_SIG_TYPE_T10_DIF,
+/**
+ * enum ib_mr_type - memory region type
+ * @IB_MR_TYPE_MEM_REG: memory region that is used for
+ * normal registration
+ * @IB_MR_TYPE_SIGNATURE: memory region that is used for
+ * signature operations (data-integrity
+ * capable regions)
+ * @IB_MR_TYPE_SG_GAPS: memory region that is capable to
+ * register any arbitrary sg lists (without
+ * the normal mr constraints - see
+ * ib_map_mr_sg)
+ */
+enum ib_mr_type {
+ IB_MR_TYPE_MEM_REG,
+ IB_MR_TYPE_SIGNATURE,
+ IB_MR_TYPE_SG_GAPS,
};
/**
- * T10-DIF Signature types
- * T10-DIF types are defined by SCSI
- * specifications.
+ * Signature types
+ * IB_SIG_TYPE_NONE: Unprotected.
+ * IB_SIG_TYPE_T10_DIF: Type T10-DIF
*/
-enum ib_t10_dif_type {
- IB_T10DIF_NONE,
- IB_T10DIF_TYPE1,
- IB_T10DIF_TYPE2,
- IB_T10DIF_TYPE3
+enum ib_signature_type {
+ IB_SIG_TYPE_NONE,
+ IB_SIG_TYPE_T10_DIF,
};
/**
@@ -602,24 +727,26 @@ enum ib_t10_dif_bg_type {
/**
* struct ib_t10_dif_domain - Parameters specific for T10-DIF
* domain.
- * @type: T10-DIF type (0|1|2|3)
* @bg_type: T10-DIF block guard type (CRC|CSUM)
* @pi_interval: protection information interval.
* @bg: seed of guard computation.
* @app_tag: application tag of guard block
* @ref_tag: initial guard block reference tag.
- * @type3_inc_reftag: T10-DIF type 3 does not state
- * about the reference tag, it is the user
- * choice to increment it or not.
+ * @ref_remap: Indicate wethear the reftag increments each block
+ * @app_escape: Indicate to skip block check if apptag=0xffff
+ * @ref_escape: Indicate to skip block check if reftag=0xffffffff
+ * @apptag_check_mask: check bitmask of application tag.
*/
struct ib_t10_dif_domain {
- enum ib_t10_dif_type type;
enum ib_t10_dif_bg_type bg_type;
- u32 pi_interval;
+ u16 pi_interval;
u16 bg;
u16 app_tag;
u32 ref_tag;
- bool type3_inc_reftag;
+ bool ref_remap;
+ bool app_escape;
+ bool ref_escape;
+ u16 apptag_check_mask;
};
/**
@@ -686,7 +813,7 @@ struct ib_mr_status {
* enum.
* @mult: multiple to convert.
*/
-enum ib_rate mult_to_ib_rate(int mult) __attribute_const__;
+__attribute_const__ enum ib_rate mult_to_ib_rate(int mult);
struct ib_ah_attr {
struct ib_global_route grh;
@@ -696,8 +823,7 @@ struct ib_ah_attr {
u8 static_rate;
u8 ah_flags;
u8 port_num;
- u8 dmac[6];
- u16 vlan_id;
+ u8 dmac[ETH_ALEN];
};
enum ib_wc_status {
@@ -725,16 +851,17 @@ enum ib_wc_status {
IB_WC_GENERAL_ERR
};
+const char *__attribute_const__ ib_wc_status_msg(enum ib_wc_status status);
+
enum ib_wc_opcode {
IB_WC_SEND,
IB_WC_RDMA_WRITE,
IB_WC_RDMA_READ,
IB_WC_COMP_SWAP,
IB_WC_FETCH_ADD,
- IB_WC_BIND_MW,
IB_WC_LSO,
IB_WC_LOCAL_INV,
- IB_WC_FAST_REG_MR,
+ IB_WC_REG_MR,
IB_WC_MASKED_COMP_SWAP,
IB_WC_MASKED_FETCH_ADD,
/*
@@ -742,7 +869,8 @@ enum ib_wc_opcode {
* receive by testing (opcode & IB_WC_RECV).
*/
IB_WC_RECV = 1 << 7,
- IB_WC_RECV_RDMA_WITH_IMM
+ IB_WC_RECV_RDMA_WITH_IMM,
+ IB_WC_DUMMY = -1, /* force enum signed */
};
enum ib_wc_flags {
@@ -750,15 +878,16 @@ enum ib_wc_flags {
IB_WC_WITH_IMM = (1<<1),
IB_WC_WITH_INVALIDATE = (1<<2),
IB_WC_IP_CSUM_OK = (1<<3),
- IB_WC_WITH_SL = (1<<4),
- IB_WC_WITH_SLID = (1<<5),
- IB_WC_WITH_TIMESTAMP = (1<<6),
- IB_WC_WITH_SMAC = (1<<7),
- IB_WC_WITH_VLAN = (1<<8),
+ IB_WC_WITH_SMAC = (1<<4),
+ IB_WC_WITH_VLAN = (1<<5),
+ IB_WC_WITH_NETWORK_HDR_TYPE = (1<<6),
};
struct ib_wc {
- u64 wr_id;
+ union {
+ u64 wr_id;
+ struct ib_cqe *wr_cqe;
+ };
enum ib_wc_status status;
enum ib_wc_opcode opcode;
u32 vendor_err;
@@ -775,12 +904,9 @@ struct ib_wc {
u8 sl;
u8 dlid_path_bits;
u8 port_num; /* valid only for DR SMPs on switches */
- int csum_ok;
- struct {
- uint64_t timestamp; /* timestamp = 0 indicates error*/
- } ts;
- u8 smac[6];
+ u8 smac[ETH_ALEN];
u16 vlan_id;
+ u8 network_hdr_type;
};
enum ib_cq_notify_flags {
@@ -826,7 +952,13 @@ struct ib_qp_cap {
u32 max_send_sge;
u32 max_recv_sge;
u32 max_inline_data;
- u32 qpg_tss_mask_sz;
+
+ /*
+ * Maximum number of rdma_rw_ctx structures in flight at a time.
+ * ib_create_qp() will calculate the right amount of neededed WRs
+ * and MRs based on this.
+ */
+ u32 max_rdma_ctxs;
};
enum ib_sig_type {
@@ -851,7 +983,6 @@ enum ib_qp_type {
IB_QPT_RAW_PACKET = 8,
IB_QPT_XRC_INI = 9,
IB_QPT_XRC_TGT,
- IB_QPT_DC_INI,
IB_QPT_MAX,
/* Reserve a range for qp types internal to the low level driver.
* These qp types will not be visible at the IB core layer, so the
@@ -872,27 +1003,22 @@ enum ib_qp_type {
enum ib_qp_create_flags {
IB_QP_CREATE_IPOIB_UD_LSO = 1 << 0,
IB_QP_CREATE_BLOCK_MULTICAST_LOOPBACK = 1 << 1,
- IB_QP_CREATE_CROSS_CHANNEL = 1 << 2,
- IB_QP_CREATE_MANAGED_SEND = 1 << 3,
- IB_QP_CREATE_MANAGED_RECV = 1 << 4,
+ IB_QP_CREATE_CROSS_CHANNEL = 1 << 2,
+ IB_QP_CREATE_MANAGED_SEND = 1 << 3,
+ IB_QP_CREATE_MANAGED_RECV = 1 << 4,
IB_QP_CREATE_NETIF_QP = 1 << 5,
IB_QP_CREATE_SIGNATURE_EN = 1 << 6,
+ IB_QP_CREATE_USE_GFP_NOIO = 1 << 7,
+ IB_QP_CREATE_SCATTER_FCS = 1 << 8,
/* reserve bits 26-31 for low level drivers' internal use */
IB_QP_CREATE_RESERVED_START = 1 << 26,
IB_QP_CREATE_RESERVED_END = 1 << 31,
};
-enum ib_qpg_type {
- IB_QPG_NONE = 0,
- IB_QPG_PARENT = (1<<0),
- IB_QPG_CHILD_RX = (1<<1),
- IB_QPG_CHILD_TX = (1<<2)
-};
-
-struct ib_qpg_init_attrib {
- u32 tss_child_count;
- u32 rss_child_count;
-};
+/*
+ * Note: users may not call ib_close_qp or ib_destroy_qp from the event_handler
+ * callback to destroy the passed in QP.
+ */
struct ib_qp_init_attr {
void (*event_handler)(struct ib_event *, void *);
@@ -902,52 +1028,15 @@ struct ib_qp_init_attr {
struct ib_srq *srq;
struct ib_xrcd *xrcd; /* XRC TGT QPs only */
struct ib_qp_cap cap;
- union {
- struct ib_qp *qpg_parent; /* see qpg_type */
- struct ib_qpg_init_attrib parent_attrib;
- };
enum ib_sig_type sq_sig_type;
enum ib_qp_type qp_type;
enum ib_qp_create_flags create_flags;
- enum ib_qpg_type qpg_type;
- u8 port_num; /* special QP types only */
-};
-
-enum {
- IB_DCT_CREATE_FLAG_RCV_INLINE = 1 << 0,
- IB_DCT_CREATE_FLAGS_MASK = IB_DCT_CREATE_FLAG_RCV_INLINE,
-};
-struct ib_dct_init_attr {
- struct ib_pd *pd;
- struct ib_cq *cq;
- struct ib_srq *srq;
- u64 dc_key;
- u8 port;
- u32 access_flags;
- u8 min_rnr_timer;
- u8 tclass;
- u32 flow_label;
- enum ib_mtu mtu;
- u8 pkey_index;
- u8 gid_index;
- u8 hop_limit;
- u32 create_flags;
-};
-
-struct ib_dct_attr {
- u64 dc_key;
- u8 port;
- u32 access_flags;
- u8 min_rnr_timer;
- u8 tclass;
- u32 flow_label;
- enum ib_mtu mtu;
- u8 pkey_index;
- u8 gid_index;
- u8 hop_limit;
- u32 key_violations;
- u8 state;
+ /*
+ * Only needed for special QP types, or when using the RW API.
+ */
+ u8 port_num;
+ struct ib_rwq_ind_table *rwq_ind_tbl;
};
struct ib_qp_open_attr {
@@ -1014,12 +1103,10 @@ enum ib_qp_attr_mask {
IB_QP_PATH_MIG_STATE = (1<<18),
IB_QP_CAP = (1<<19),
IB_QP_DEST_QPN = (1<<20),
- IB_QP_GROUP_RSS = (1<<21),
- IB_QP_DC_KEY = (1<<22),
- IB_QP_SMAC = (1<<23),
- IB_QP_ALT_SMAC = (1<<24),
- IB_QP_VID = (1<<25),
- IB_QP_ALT_VID = (1<<26)
+ IB_QP_RESERVED1 = (1<<21),
+ IB_QP_RESERVED2 = (1<<22),
+ IB_QP_RESERVED3 = (1<<23),
+ IB_QP_RESERVED4 = (1<<24),
};
enum ib_qp_state {
@@ -1030,7 +1117,7 @@ enum ib_qp_state {
IB_QPS_SQD,
IB_QPS_SQE,
IB_QPS_ERR,
- IB_QPS_DUMMY = -1 /* force enum signed */
+ IB_QPS_DUMMY = -1, /* force enum signed */
};
enum ib_mig_state {
@@ -1070,40 +1157,6 @@ struct ib_qp_attr {
u8 rnr_retry;
u8 alt_port_num;
u8 alt_timeout;
- u8 smac[ETH_ALEN];
- u8 alt_smac[ETH_ALEN];
- u16 vlan_id;
- u16 alt_vlan_id;
-
-};
-
-struct ib_qp_attr_ex {
- enum ib_qp_state qp_state;
- enum ib_qp_state cur_qp_state;
- enum ib_mtu path_mtu;
- enum ib_mig_state path_mig_state;
- u32 qkey;
- u32 rq_psn;
- u32 sq_psn;
- u32 dest_qp_num;
- int qp_access_flags;
- struct ib_qp_cap cap;
- struct ib_ah_attr ah_attr;
- struct ib_ah_attr alt_ah_attr;
- u16 pkey_index;
- u16 alt_pkey_index;
- u8 en_sqd_async_notify;
- u8 sq_draining;
- u8 max_rd_atomic;
- u8 max_dest_rd_atomic;
- u8 min_rnr_timer;
- u8 port_num;
- u8 timeout;
- u8 retry_cnt;
- u8 rnr_retry;
- u8 alt_port_num;
- u8 alt_timeout;
- u64 dct_key;
};
enum ib_wr_opcode {
@@ -1118,10 +1171,9 @@ enum ib_wr_opcode {
IB_WR_SEND_WITH_INV,
IB_WR_RDMA_READ_WITH_INV,
IB_WR_LOCAL_INV,
- IB_WR_FAST_REG_MR,
+ IB_WR_REG_MR,
IB_WR_MASKED_ATOMIC_CMP_AND_SWP,
IB_WR_MASKED_ATOMIC_FETCH_AND_ADD,
- IB_WR_BIND_MW,
IB_WR_REG_SIG_MR,
/* reserve values for low level drivers' internal use.
* These values will not be used at all in the ib core layer.
@@ -1136,8 +1188,7 @@ enum ib_wr_opcode {
IB_WR_RESERVED8,
IB_WR_RESERVED9,
IB_WR_RESERVED10,
-
- IB_WR_DUMMY = -1, /* force enum type signed */
+ IB_WR_DUMMY = -1, /* force enum signed */
};
enum ib_send_flags {
@@ -1150,7 +1201,6 @@ enum ib_send_flags {
/* reserve bits 26-31 for low level drivers' internal use */
IB_SEND_RESERVED_START = (1 << 26),
IB_SEND_RESERVED_END = (1 << 31),
- IB_SEND_UMR_UNREG = (1<<5)
};
struct ib_sge {
@@ -1159,32 +1209,16 @@ struct ib_sge {
u32 lkey;
};
-struct ib_fast_reg_page_list {
- struct ib_device *device;
- u64 *page_list;
- unsigned int max_page_list_len;
-};
-
-/**
- * struct ib_mw_bind_info - Parameters for a memory window bind operation.
- * @mr: A memory region to bind the memory window to.
- * @addr: The address where the memory window should begin.
- * @length: The length of the memory window, in bytes.
- * @mw_access_flags: Access flags from enum ib_access_flags for the window.
- *
- * This struct contains the shared parameters for type 1 and type 2
- * memory window bind operations.
- */
-struct ib_mw_bind_info {
- struct ib_mr *mr;
- u64 addr;
- u64 length;
- int mw_access_flags;
+struct ib_cqe {
+ void (*done)(struct ib_cq *cq, struct ib_wc *wc);
};
struct ib_send_wr {
struct ib_send_wr *next;
- u64 wr_id;
+ union {
+ u64 wr_id;
+ struct ib_cqe *wr_cqe;
+ };
struct ib_sge *sg_list;
int num_sge;
enum ib_wr_opcode opcode;
@@ -1193,66 +1227,82 @@ struct ib_send_wr {
__be32 imm_data;
u32 invalidate_rkey;
} ex;
- union {
- struct {
- u64 remote_addr;
- u32 rkey;
- } rdma;
- struct {
- u64 remote_addr;
- u64 compare_add;
- u64 swap;
- u64 compare_add_mask;
- u64 swap_mask;
- u32 rkey;
- } atomic;
- struct {
- struct ib_ah *ah;
- void *header;
- int hlen;
- int mss;
- u32 remote_qpn;
- u32 remote_qkey;
- u16 pkey_index; /* valid for GSI only */
- u8 port_num; /* valid for DR SMPs on switch only */
- } ud;
- struct {
- u64 iova_start;
- struct ib_fast_reg_page_list *page_list;
- unsigned int page_shift;
- unsigned int page_list_len;
- u32 length;
- int access_flags;
- u32 rkey;
- } fast_reg;
- struct {
- int npages;
- int access_flags;
- u32 mkey;
- struct ib_pd *pd;
- u64 virt_addr;
- u64 length;
- int page_shift;
- } umr;
- struct {
- struct ib_mw *mw;
- /* The new rkey for the memory window. */
- u32 rkey;
- struct ib_mw_bind_info bind_info;
- } bind_mw;
- struct {
- struct ib_sig_attrs *sig_attrs;
- struct ib_mr *sig_mr;
- int access_flags;
- struct ib_sge *prot;
- } sig_handover;
- } wr;
- u32 xrc_remote_srq_num; /* XRC TGT QPs only */
};
+struct ib_rdma_wr {
+ struct ib_send_wr wr;
+ u64 remote_addr;
+ u32 rkey;
+};
+
+static inline struct ib_rdma_wr *rdma_wr(struct ib_send_wr *wr)
+{
+ return container_of(wr, struct ib_rdma_wr, wr);
+}
+
+struct ib_atomic_wr {
+ struct ib_send_wr wr;
+ u64 remote_addr;
+ u64 compare_add;
+ u64 swap;
+ u64 compare_add_mask;
+ u64 swap_mask;
+ u32 rkey;
+};
+
+static inline struct ib_atomic_wr *atomic_wr(struct ib_send_wr *wr)
+{
+ return container_of(wr, struct ib_atomic_wr, wr);
+}
+
+struct ib_ud_wr {
+ struct ib_send_wr wr;
+ struct ib_ah *ah;
+ void *header;
+ int hlen;
+ int mss;
+ u32 remote_qpn;
+ u32 remote_qkey;
+ u16 pkey_index; /* valid for GSI only */
+ u8 port_num; /* valid for DR SMPs on switch only */
+};
+
+static inline struct ib_ud_wr *ud_wr(struct ib_send_wr *wr)
+{
+ return container_of(wr, struct ib_ud_wr, wr);
+}
+
+struct ib_reg_wr {
+ struct ib_send_wr wr;
+ struct ib_mr *mr;
+ u32 key;
+ int access;
+};
+
+static inline struct ib_reg_wr *reg_wr(struct ib_send_wr *wr)
+{
+ return container_of(wr, struct ib_reg_wr, wr);
+}
+
+struct ib_sig_handover_wr {
+ struct ib_send_wr wr;
+ struct ib_sig_attrs *sig_attrs;
+ struct ib_mr *sig_mr;
+ int access_flags;
+ struct ib_sge *prot;
+};
+
+static inline struct ib_sig_handover_wr *sig_handover_wr(struct ib_send_wr *wr)
+{
+ return container_of(wr, struct ib_sig_handover_wr, wr);
+}
+
struct ib_recv_wr {
struct ib_recv_wr *next;
- u64 wr_id;
+ union {
+ u64 wr_id;
+ struct ib_cqe *wr_cqe;
+ };
struct ib_sge *sg_list;
int num_sge;
};
@@ -1263,40 +1313,24 @@ enum ib_access_flags {
IB_ACCESS_REMOTE_READ = (1<<2),
IB_ACCESS_REMOTE_ATOMIC = (1<<3),
IB_ACCESS_MW_BIND = (1<<4),
- IB_ACCESS_ALLOCATE_MR = (1<<5),
- IB_ZERO_BASED = (1<<13)
+ IB_ZERO_BASED = (1<<5),
+ IB_ACCESS_ON_DEMAND = (1<<6),
};
struct ib_phys_buf {
- u64 addr;
- u64 size;
-};
-
-struct ib_mr_attr {
- struct ib_pd *pd;
- u64 device_virt_addr;
- u64 size;
- int mr_access_flags;
- u32 lkey;
- u32 rkey;
+ u64 addr;
+ u64 size;
};
+/*
+ * XXX: these are apparently used for ->rereg_user_mr, no idea why they
+ * are hidden here instead of a uapi header!
+ */
enum ib_mr_rereg_flags {
IB_MR_REREG_TRANS = 1,
IB_MR_REREG_PD = (1<<1),
- IB_MR_REREG_ACCESS = (1<<2)
-};
-
-/**
- * struct ib_mw_bind - Parameters for a type 1 memory window bind operation.
- * @wr_id: Work request id.
- * @send_flags: Flags from ib_send_flags enum.
- * @bind_info: More parameters of the bind operation.
- */
-struct ib_mw_bind {
- u64 wr_id;
- int send_flags;
- struct ib_mw_bind_info bind_info;
+ IB_MR_REREG_ACCESS = (1<<2),
+ IB_MR_REREG_SUPPORTED = ((IB_MR_REREG_ACCESS << 1) - 1)
};
struct ib_fmr_attr {
@@ -1305,6 +1339,8 @@ struct ib_fmr_attr {
u8 page_shift;
};
+struct ib_umem;
+
struct ib_ucontext {
struct ib_device *device;
struct list_head pd_list;
@@ -1316,10 +1352,27 @@ struct ib_ucontext {
struct list_head ah_list;
struct list_head xrcd_list;
struct list_head rule_list;
- struct list_head dct_list;
+ struct list_head wq_list;
+ struct list_head rwq_ind_tbl_list;
int closing;
- void *peer_mem_private_data;
- char *peer_mem_name;
+
+ pid_t tgid;
+#ifdef CONFIG_INFINIBAND_ON_DEMAND_PAGING
+ struct rb_root umem_tree;
+ /*
+ * Protects .umem_rbroot and tree, as well as odp_mrs_count and
+ * mmu notifiers registration.
+ */
+ struct rw_semaphore umem_rwsem;
+ void (*invalidate_range)(struct ib_umem *umem,
+ unsigned long start, unsigned long end);
+
+ struct mmu_notifier mn;
+ atomic_t notifier_count;
+ /* A list of umems that don't have private mmu notifier counters yet. */
+ struct list_head no_private_counters;
+ int odp_mrs_count;
+#endif
};
struct ib_uobject {
@@ -1330,36 +1383,37 @@ struct ib_uobject {
int id; /* index into kernel idr */
struct kref ref;
struct rw_semaphore mutex; /* protects .live */
+ struct rcu_head rcu; /* kfree_rcu() overhead */
int live;
};
-struct ib_udata;
-struct ib_udata_ops {
- int (*copy_from)(void *dest, struct ib_udata *udata,
- size_t len);
- int (*copy_to)(struct ib_udata *udata, void *src,
- size_t len);
-};
-
struct ib_udata {
- struct ib_udata_ops *ops;
- void __user *inbuf;
+ const void __user *inbuf;
void __user *outbuf;
size_t inlen;
size_t outlen;
};
struct ib_pd {
+ u32 local_dma_lkey;
+ u32 flags;
struct ib_device *device;
struct ib_uobject *uobject;
atomic_t usecnt; /* count all resources */
+
+ u32 unsafe_global_rkey;
+
+ /*
+ * Implementation details of the RDMA core, don't use in drivers:
+ */
+ struct ib_mr *__internal_mr;
};
struct ib_xrcd {
struct ib_device *device;
atomic_t usecnt; /* count all exposed resources */
struct inode *inode;
-
+
struct mutex tgt_qp_mutex;
struct list_head tgt_qp_list;
};
@@ -1370,25 +1424,14 @@ struct ib_ah {
struct ib_uobject *uobject;
};
-enum ib_cq_attr_mask {
- IB_CQ_MODERATION = (1 << 0),
- IB_CQ_CAP_FLAGS = (1 << 1)
-};
-
-enum ib_cq_cap_flags {
- IB_CQ_IGNORE_OVERRUN = (1 << 0)
-};
+typedef void (*ib_comp_handler)(struct ib_cq *cq, void *cq_context);
-struct ib_cq_attr {
- struct {
- u16 cq_count;
- u16 cq_period;
- } moderation;
- u32 cq_cap_flags;
+enum ib_poll_context {
+ IB_POLL_DIRECT, /* caller context, no hw completions */
+ IB_POLL_SOFTIRQ, /* poll from softirq context */
+ IB_POLL_WORKQUEUE, /* poll from workqueue */
};
-typedef void (*ib_comp_handler)(struct ib_cq *cq, void *cq_context);
-
struct ib_cq {
struct ib_device *device;
struct ib_uobject *uobject;
@@ -1397,6 +1440,8 @@ struct ib_cq {
void *cq_context;
int cqe;
atomic_t usecnt; /* count number of work queues */
+ enum ib_poll_context poll_ctx;
+ struct work_struct work;
};
struct ib_srq {
@@ -1417,14 +1462,77 @@ struct ib_srq {
} ext;
};
+enum ib_wq_type {
+ IB_WQT_RQ
+};
+
+enum ib_wq_state {
+ IB_WQS_RESET,
+ IB_WQS_RDY,
+ IB_WQS_ERR
+};
+
+struct ib_wq {
+ struct ib_device *device;
+ struct ib_uobject *uobject;
+ void *wq_context;
+ void (*event_handler)(struct ib_event *, void *);
+ struct ib_pd *pd;
+ struct ib_cq *cq;
+ u32 wq_num;
+ enum ib_wq_state state;
+ enum ib_wq_type wq_type;
+ atomic_t usecnt;
+};
+
+struct ib_wq_init_attr {
+ void *wq_context;
+ enum ib_wq_type wq_type;
+ u32 max_wr;
+ u32 max_sge;
+ struct ib_cq *cq;
+ void (*event_handler)(struct ib_event *, void *);
+};
+
+enum ib_wq_attr_mask {
+ IB_WQ_STATE = 1 << 0,
+ IB_WQ_CUR_STATE = 1 << 1,
+};
+
+struct ib_wq_attr {
+ enum ib_wq_state wq_state;
+ enum ib_wq_state curr_wq_state;
+};
+
+struct ib_rwq_ind_table {
+ struct ib_device *device;
+ struct ib_uobject *uobject;
+ atomic_t usecnt;
+ u32 ind_tbl_num;
+ u32 log_ind_tbl_size;
+ struct ib_wq **ind_tbl;
+};
+
+struct ib_rwq_ind_table_init_attr {
+ u32 log_ind_tbl_size;
+ /* Each entry is a pointer to Receive Work Queue */
+ struct ib_wq **ind_tbl;
+};
+
+/*
+ * @max_write_sge: Maximum SGE elements per RDMA WRITE request.
+ * @max_read_sge: Maximum SGE elements per RDMA READ request.
+ */
struct ib_qp {
struct ib_device *device;
struct ib_pd *pd;
struct ib_cq *send_cq;
struct ib_cq *recv_cq;
+ spinlock_t mr_lock;
struct ib_srq *srq;
struct ib_xrcd *xrcd; /* XRC TGT QPs only */
struct list_head xrcd_list;
+
/* count times opened, mcast attaches, flow attaches */
atomic_t usecnt;
struct list_head open_list;
@@ -1433,27 +1541,25 @@ struct ib_qp {
void (*event_handler)(struct ib_event *, void *);
void *qp_context;
u32 qp_num;
+ u32 max_write_sge;
+ u32 max_read_sge;
enum ib_qp_type qp_type;
- enum ib_qpg_type qpg_type;
- u8 port_num;
-};
-
-struct ib_dct {
- struct ib_device *device;
- struct ib_uobject *uobject;
- struct ib_pd *pd;
- struct ib_cq *cq;
- struct ib_srq *srq;
- u32 dct_num;
+ struct ib_rwq_ind_table *rwq_ind_tbl;
};
struct ib_mr {
struct ib_device *device;
struct ib_pd *pd;
- struct ib_uobject *uobject;
u32 lkey;
u32 rkey;
- atomic_t usecnt; /* count number of MWs */
+ u64 iova;
+ u32 length;
+ unsigned int page_size;
+ bool need_inval;
+ union {
+ struct ib_uobject *uobject; /* user */
+ struct list_head qp_entry; /* FR */
+ };
};
struct ib_mw {
@@ -1492,14 +1598,15 @@ enum ib_flow_attr_type {
enum ib_flow_spec_type {
/* L2 headers*/
IB_FLOW_SPEC_ETH = 0x20,
- IB_FLOW_SPEC_IB = 0x21,
+ IB_FLOW_SPEC_IB = 0x22,
/* L3 header*/
IB_FLOW_SPEC_IPV4 = 0x30,
+ IB_FLOW_SPEC_IPV6 = 0x31,
/* L4 headers*/
IB_FLOW_SPEC_TCP = 0x40,
IB_FLOW_SPEC_UDP = 0x41
};
-
+#define IB_FLOW_SPEC_LAYER_MASK 0xF0
#define IB_FLOW_SPEC_SUPPORT_LAYERS 4
/* Flow steering rule priority is set according to it's domain.
@@ -1514,7 +1621,8 @@ enum ib_flow_domain {
};
enum ib_flow_flags {
- IB_FLOW_ATTR_FLAGS_ALLOW_LOOP_BACK = 1
+ IB_FLOW_ATTR_FLAGS_DONT_TRAP = 1UL << 1, /* Continue match, no steal */
+ IB_FLOW_ATTR_FLAGS_RESERVED = 1UL << 2 /* Must be last */
};
struct ib_flow_eth_filter {
@@ -1522,6 +1630,8 @@ struct ib_flow_eth_filter {
u8 src_mac[6];
__be16 ether_type;
__be16 vlan_tag;
+ /* Must be last */
+ u8 real_sz[0];
};
struct ib_flow_spec_eth {
@@ -1532,8 +1642,10 @@ struct ib_flow_spec_eth {
};
struct ib_flow_ib_filter {
- __be32 l3_type_qpn;
- u8 dst_gid[16];
+ __be16 dlid;
+ __u8 sl;
+ /* Must be last */
+ u8 real_sz[0];
};
struct ib_flow_spec_ib {
@@ -1543,9 +1655,22 @@ struct ib_flow_spec_ib {
struct ib_flow_ib_filter mask;
};
+/* IPv4 header flags */
+enum ib_ipv4_flags {
+ IB_IPV4_DONT_FRAG = 0x2, /* Don't enable packet fragmentation */
+ IB_IPV4_MORE_FRAG = 0X4 /* For All fragmented packets except the
+ last have this flag set */
+};
+
struct ib_flow_ipv4_filter {
- __be32 src_ip;
- __be32 dst_ip;
+ __be32 src_ip;
+ __be32 dst_ip;
+ u8 proto;
+ u8 tos;
+ u8 ttl;
+ u8 flags;
+ /* Must be last */
+ u8 real_sz[0];
};
struct ib_flow_spec_ipv4 {
@@ -1555,9 +1680,29 @@ struct ib_flow_spec_ipv4 {
struct ib_flow_ipv4_filter mask;
};
+struct ib_flow_ipv6_filter {
+ u8 src_ip[16];
+ u8 dst_ip[16];
+ __be32 flow_label;
+ u8 next_hdr;
+ u8 traffic_class;
+ u8 hop_limit;
+ /* Must be last */
+ u8 real_sz[0];
+};
+
+struct ib_flow_spec_ipv6 {
+ enum ib_flow_spec_type type;
+ u16 size;
+ struct ib_flow_ipv6_filter val;
+ struct ib_flow_ipv6_filter mask;
+};
+
struct ib_flow_tcp_udp_filter {
- __be16 dst_port;
+ __be16 dst_port;
__be16 src_port;
+ /* Must be last */
+ u8 real_sz[0];
};
struct ib_flow_spec_tcp_udp {
@@ -1572,19 +1717,20 @@ union ib_flow_spec {
enum ib_flow_spec_type type;
u16 size;
};
- struct ib_flow_spec_ib ib;
- struct ib_flow_spec_eth eth;
- struct ib_flow_spec_ipv4 ipv4;
- struct ib_flow_spec_tcp_udp tcp_udp;
+ struct ib_flow_spec_eth eth;
+ struct ib_flow_spec_ib ib;
+ struct ib_flow_spec_ipv4 ipv4;
+ struct ib_flow_spec_tcp_udp tcp_udp;
+ struct ib_flow_spec_ipv6 ipv6;
};
struct ib_flow_attr {
enum ib_flow_attr_type type;
u16 size;
u16 priority;
+ u32 flags;
u8 num_of_specs;
u8 port;
- u32 flags;
/* Following are the optional layers according to user request
* struct ib_flow_spec_xxx
* struct ib_flow_spec_yyy
@@ -1596,7 +1742,7 @@ struct ib_flow {
struct ib_uobject *uobject;
};
-struct ib_mad;
+struct ib_mad_hdr;
struct ib_grh;
enum ib_process_mad_flags {
@@ -1618,19 +1764,10 @@ struct ib_cache {
rwlock_t lock;
struct ib_event_handler event_handler;
struct ib_pkey_cache **pkey_cache;
- struct ib_gid_cache **gid_cache;
+ struct ib_gid_table **gid_cache;
u8 *lmc_cache;
};
-enum verbs_values_mask {
- IBV_VALUES_HW_CLOCK = 1 << 0
-};
-
-struct ib_device_values {
- int values_mask;
- uint64_t hwclock;
-};
-
struct ib_dma_mapping_ops {
int (*mapping_error)(struct ib_device *dev,
u64 dma_addr);
@@ -1653,10 +1790,14 @@ struct ib_dma_mapping_ops {
void (*unmap_sg)(struct ib_device *dev,
struct scatterlist *sg, int nents,
enum dma_data_direction direction);
- u64 (*dma_address)(struct ib_device *dev,
- struct scatterlist *sg);
- unsigned int (*dma_len)(struct ib_device *dev,
- struct scatterlist *sg);
+ int (*map_sg_attrs)(struct ib_device *dev,
+ struct scatterlist *sg, int nents,
+ enum dma_data_direction direction,
+ struct dma_attrs *attrs);
+ void (*unmap_sg_attrs)(struct ib_device *dev,
+ struct scatterlist *sg, int nents,
+ enum dma_data_direction direction,
+ struct dma_attrs *attrs);
void (*sync_single_for_cpu)(struct ib_device *dev,
u64 dma_handle,
size_t size,
@@ -1683,9 +1824,6 @@ struct ib_port_immutable {
u32 max_mad_size;
};
-struct ib_exp_device_attr;
-struct ib_exp_qp_init_attr;
-
struct ib_device {
struct device *dma_device;
@@ -1696,6 +1834,8 @@ struct ib_device {
spinlock_t client_data_lock;
struct list_head core_list;
+ /* Access to the client_data_list is protected by the client_data_lock
+ * spinlock and the lists_rwsem read-write semaphore */
struct list_head client_data_list;
struct ib_cache cache;
@@ -1708,26 +1848,78 @@ struct ib_device {
struct iw_cm_verbs *iwcm;
- int (*get_protocol_stats)(struct ib_device *device,
- union rdma_protocol_stats *stats);
+ /**
+ * alloc_hw_stats - Allocate a struct rdma_hw_stats and fill in the
+ * driver initialized data. The struct is kfree()'ed by the sysfs
+ * core when the device is removed. A lifespan of -1 in the return
+ * struct tells the core to set a default lifespan.
+ */
+ struct rdma_hw_stats *(*alloc_hw_stats)(struct ib_device *device,
+ u8 port_num);
+ /**
+ * get_hw_stats - Fill in the counter value(s) in the stats struct.
+ * @index - The index in the value array we wish to have updated, or
+ * num_counters if we want all stats updated
+ * Return codes -
+ * < 0 - Error, no counters updated
+ * index - Updated the single counter pointed to by index
+ * num_counters - Updated all counters (will reset the timestamp
+ * and prevent further calls for lifespan milliseconds)
+ * Drivers are allowed to update all counters in leiu of just the
+ * one given in index at their option
+ */
+ int (*get_hw_stats)(struct ib_device *device,
+ struct rdma_hw_stats *stats,
+ u8 port, int index);
int (*query_device)(struct ib_device *device,
- struct ib_device_attr *device_attr);
+ struct ib_device_attr *device_attr,
+ struct ib_udata *udata);
int (*query_port)(struct ib_device *device,
u8 port_num,
struct ib_port_attr *port_attr);
enum rdma_link_layer (*get_link_layer)(struct ib_device *device,
u8 port_num);
/* When calling get_netdev, the HW vendor's driver should return the
- * net device of device @device at port @port_num. The function
- * is called in rtnl_lock. The HW vendor's device driver must guarantee
- * to return NULL before the net device has reached
+ * net device of device @device at port @port_num or NULL if such
+ * a net device doesn't exist. The vendor driver should call dev_hold
+ * on this net device. The HW vendor's device driver must guarantee
+ * that this function returns NULL before the net device reaches
* NETDEV_UNREGISTER_FINAL state.
*/
- struct net_device *(*get_netdev)(struct ib_device *device,
- u8 port_num);
+ struct net_device *(*get_netdev)(struct ib_device *device,
+ u8 port_num);
int (*query_gid)(struct ib_device *device,
u8 port_num, int index,
union ib_gid *gid);
+ /* When calling add_gid, the HW vendor's driver should
+ * add the gid of device @device at gid index @index of
+ * port @port_num to be @gid. Meta-info of that gid (for example,
+ * the network device related to this gid is available
+ * at @attr. @context allows the HW vendor driver to store extra
+ * information together with a GID entry. The HW vendor may allocate
+ * memory to contain this information and store it in @context when a
+ * new GID entry is written to. Params are consistent until the next
+ * call of add_gid or delete_gid. The function should return 0 on
+ * success or error otherwise. The function could be called
+ * concurrently for different ports. This function is only called
+ * when roce_gid_table is used.
+ */
+ int (*add_gid)(struct ib_device *device,
+ u8 port_num,
+ unsigned int index,
+ const union ib_gid *gid,
+ const struct ib_gid_attr *attr,
+ void **context);
+ /* When calling del_gid, the HW vendor's driver should delete the
+ * gid of device @device at gid index @index of port @port_num.
+ * Upon the deletion of a GID entry, the HW vendor must free any
+ * allocated memory. The caller will clear @context afterwards.
+ * This function is only called when roce_gid_table is used.
+ */
+ int (*del_gid)(struct ib_device *device,
+ u8 port_num,
+ unsigned int index,
+ void **context);
int (*query_pkey)(struct ib_device *device,
u8 port_num, u16 index, u16 *pkey);
int (*modify_device)(struct ib_device *device,
@@ -1784,12 +1976,11 @@ struct ib_device {
struct ib_recv_wr *recv_wr,
struct ib_recv_wr **bad_recv_wr);
struct ib_cq * (*create_cq)(struct ib_device *device,
- struct ib_cq_init_attr *attr,
+ const struct ib_cq_init_attr *attr,
struct ib_ucontext *context,
struct ib_udata *udata);
- int (*modify_cq)(struct ib_cq *cq,
- struct ib_cq_attr *cq_attr,
- int cq_attr_mask);
+ int (*modify_cq)(struct ib_cq *cq, u16 cq_count,
+ u16 cq_period);
int (*destroy_cq)(struct ib_cq *cq);
int (*resize_cq)(struct ib_cq *cq, int cqe,
struct ib_udata *udata);
@@ -1802,7 +1993,7 @@ struct ib_device {
int wc_cnt);
struct ib_mr * (*get_dma_mr)(struct ib_pd *pd,
int mr_access_flags);
- struct ib_mr * (*reg_phys_mr)(struct ib_pd *pd,
+ struct ib_mr * (*reg_phys_mr)(struct ib_pd *pd,
struct ib_phys_buf *phys_buf_array,
int num_phys_buf,
int mr_access_flags,
@@ -1811,31 +2002,25 @@ struct ib_device {
u64 start, u64 length,
u64 virt_addr,
int mr_access_flags,
- struct ib_udata *udata,
- int mr_id);
- int (*query_mr)(struct ib_mr *mr,
- struct ib_mr_attr *mr_attr);
- int (*dereg_mr)(struct ib_mr *mr);
- int (*destroy_mr)(struct ib_mr *mr);
- struct ib_mr * (*create_mr)(struct ib_pd *pd,
- struct ib_mr_init_attr *mr_init_attr);
- struct ib_mr * (*alloc_fast_reg_mr)(struct ib_pd *pd,
- int max_page_list_len);
- struct ib_fast_reg_page_list * (*alloc_fast_reg_page_list)(struct ib_device *device,
- int page_list_len);
- void (*free_fast_reg_page_list)(struct ib_fast_reg_page_list *page_list);
- int (*rereg_phys_mr)(struct ib_mr *mr,
- int mr_rereg_mask,
- struct ib_pd *pd,
- struct ib_phys_buf *phys_buf_array,
- int num_phys_buf,
+ struct ib_udata *udata);
+ int (*rereg_user_mr)(struct ib_mr *mr,
+ int flags,
+ u64 start, u64 length,
+ u64 virt_addr,
int mr_access_flags,
- u64 *iova_start);
+ struct ib_pd *pd,
+ struct ib_udata *udata);
+ int (*dereg_mr)(struct ib_mr *mr);
+ struct ib_mr * (*alloc_mr)(struct ib_pd *pd,
+ enum ib_mr_type mr_type,
+ u32 max_num_sg);
+ int (*map_mr_sg)(struct ib_mr *mr,
+ struct scatterlist *sg,
+ int sg_nents,
+ unsigned int *sg_offset);
struct ib_mw * (*alloc_mw)(struct ib_pd *pd,
- enum ib_mw_type type);
- int (*bind_mw)(struct ib_qp *qp,
- struct ib_mw *mw,
- struct ib_mw_bind *mw_bind);
+ enum ib_mw_type type,
+ struct ib_udata *udata);
int (*dealloc_mw)(struct ib_mw *mw);
struct ib_fmr * (*alloc_fmr)(struct ib_pd *pd,
int mr_access_flags,
@@ -1854,10 +2039,13 @@ struct ib_device {
int (*process_mad)(struct ib_device *device,
int process_mad_flags,
u8 port_num,
- struct ib_wc *in_wc,
- struct ib_grh *in_grh,
- struct ib_mad *in_mad,
- struct ib_mad *out_mad);
+ const struct ib_wc *in_wc,
+ const struct ib_grh *in_grh,
+ const struct ib_mad_hdr *in_mad,
+ size_t in_mad_size,
+ struct ib_mad_hdr *out_mad,
+ size_t *out_mad_size,
+ u16 *out_mad_pkey_index);
struct ib_xrcd * (*alloc_xrcd)(struct ib_device *device,
struct ib_ucontext *ucontext,
struct ib_udata *udata);
@@ -1869,17 +2057,29 @@ struct ib_device {
int (*destroy_flow)(struct ib_flow *flow_id);
int (*check_mr_status)(struct ib_mr *mr, u32 check_mask,
struct ib_mr_status *mr_status);
-
- unsigned long (*get_unmapped_area)(struct file *file,
- unsigned long addr,
- unsigned long len, unsigned long pgoff,
- unsigned long flags);
- int (*ioctl)(struct ib_ucontext *context,
- unsigned int cmd,
- unsigned long arg);
- int (*query_values)(struct ib_device *device,
- int q_values,
- struct ib_device_values *values);
+ void (*disassociate_ucontext)(struct ib_ucontext *ibcontext);
+ void (*drain_rq)(struct ib_qp *qp);
+ void (*drain_sq)(struct ib_qp *qp);
+ int (*set_vf_link_state)(struct ib_device *device, int vf, u8 port,
+ int state);
+ int (*get_vf_config)(struct ib_device *device, int vf, u8 port,
+ struct ifla_vf_info *ivf);
+ int (*get_vf_stats)(struct ib_device *device, int vf, u8 port,
+ struct ifla_vf_stats *stats);
+ int (*set_vf_guid)(struct ib_device *device, int vf, u8 port, u64 guid,
+ int type);
+ struct ib_wq * (*create_wq)(struct ib_pd *pd,
+ struct ib_wq_init_attr *init_attr,
+ struct ib_udata *udata);
+ int (*destroy_wq)(struct ib_wq *wq);
+ int (*modify_wq)(struct ib_wq *wq,
+ struct ib_wq_attr *attr,
+ u32 wq_attr_mask,
+ struct ib_udata *udata);
+ struct ib_rwq_ind_table * (*create_rwq_ind_table)(struct ib_device *device,
+ struct ib_rwq_ind_table_init_attr *init_attr,
+ struct ib_udata *udata);
+ int (*destroy_rwq_ind_table)(struct ib_rwq_ind_table *wq_ind_table);
struct ib_dma_mapping_ops *dma_ops;
struct module *owner;
@@ -1897,16 +2097,15 @@ struct ib_device {
u64 uverbs_cmd_mask;
u64 uverbs_ex_cmd_mask;
- char node_desc[64];
+ char node_desc[IB_DEVICE_NODE_DESC_MAX];
__be64 node_guid;
u32 local_dma_lkey;
+ u16 is_switch:1;
u8 node_type;
u8 phys_port_cnt;
- int cmd_perf;
- u64 cmd_avg;
- u32 cmd_n;
- spinlock_t cmd_perf_lock;
-
+ struct ib_device_attr attrs;
+ struct attribute_group *hw_stats_ag;
+ struct rdma_hw_stats *hw_stats;
/**
* The following mandatory functions are used only at device
@@ -1915,35 +2114,44 @@ struct ib_device {
* in fast paths.
*/
int (*get_port_immutable)(struct ib_device *, u8, struct ib_port_immutable *);
-
- /*
- * Experimental data and functions
- */
- int (*exp_query_device)(struct ib_device *device,
- struct ib_exp_device_attr *device_attr);
- struct ib_qp * (*exp_create_qp)(struct ib_pd *pd,
- struct ib_exp_qp_init_attr *qp_init_attr,
- struct ib_udata *udata);
- struct ib_dct * (*exp_create_dct)(struct ib_pd *pd,
- struct ib_dct_init_attr *attr,
- struct ib_udata *udata);
- int (*exp_destroy_dct)(struct ib_dct *dct);
- int (*exp_query_dct)(struct ib_dct *dct, struct ib_dct_attr *attr);
-
- u64 uverbs_exp_cmd_mask;
+ void (*get_dev_fw_str)(struct ib_device *, char *str, size_t str_len);
};
struct ib_client {
char *name;
void (*add) (struct ib_device *);
- void (*remove)(struct ib_device *);
-
+ void (*remove)(struct ib_device *, void *client_data);
+
+ /* Returns the net_dev belonging to this ib_client and matching the
+ * given parameters.
+ * @dev: An RDMA device that the net_dev use for communication.
+ * @port: A physical port number on the RDMA device.
+ * @pkey: P_Key that the net_dev uses if applicable.
+ * @gid: A GID that the net_dev uses to communicate.
+ * @addr: An IP address the net_dev is configured with.
+ * @client_data: The device's client data set by ib_set_client_data().
+ *
+ * An ib_client that implements a net_dev on top of RDMA devices
+ * (such as IP over IB) should implement this callback, allowing the
+ * rdma_cm module to find the right net_dev for a given request.
+ *
+ * The caller is responsible for calling dev_put on the returned
+ * netdev. */
+ struct net_device *(*get_net_dev_by_params)(
+ struct ib_device *dev,
+ u8 port,
+ u16 pkey,
+ const union ib_gid *gid,
+ const struct sockaddr *addr,
+ void *client_data);
struct list_head list;
};
struct ib_device *ib_alloc_device(size_t size);
void ib_dealloc_device(struct ib_device *device);
+void ib_get_device_fw_str(struct ib_device *device, char *str, size_t str_len);
+
int ib_register_device(struct ib_device *device,
int (*port_callback)(struct ib_device *,
u8, struct kobject *));
@@ -1958,12 +2166,32 @@ void ib_set_client_data(struct ib_device *device, struct ib_client *client,
static inline int ib_copy_from_udata(void *dest, struct ib_udata *udata, size_t len)
{
- return udata->ops->copy_from(dest, udata, len);
+ return copy_from_user(dest, udata->inbuf, len) ? -EFAULT : 0;
}
static inline int ib_copy_to_udata(struct ib_udata *udata, void *src, size_t len)
{
- return udata->ops->copy_to(udata, src, len);
+ return copy_to_user(udata->outbuf, src, len) ? -EFAULT : 0;
+}
+
+static inline bool ib_is_udata_cleared(struct ib_udata *udata,
+ size_t offset,
+ size_t len)
+{
+ const void __user *p = (const char __user *)udata->inbuf + offset;
+ bool ret;
+ u8 *buf;
+
+ if (len > USHRT_MAX)
+ return false;
+
+ buf = memdup_user(p, len);
+ if (IS_ERR(buf))
+ return false;
+
+ ret = !memchr_inv(buf, 0, len);
+ kfree(buf);
+ return ret;
}
/**
@@ -1990,15 +2218,52 @@ int ib_register_event_handler (struct ib_event_handler *event_handler);
int ib_unregister_event_handler(struct ib_event_handler *event_handler);
void ib_dispatch_event(struct ib_event *event);
-int ib_query_device(struct ib_device *device,
- struct ib_device_attr *device_attr);
-
int ib_query_port(struct ib_device *device,
u8 port_num, struct ib_port_attr *port_attr);
enum rdma_link_layer rdma_port_get_link_layer(struct ib_device *device,
u8 port_num);
+/**
+ * rdma_cap_ib_switch - Check if the device is IB switch
+ * @device: Device to check
+ *
+ * Device driver is responsible for setting is_switch bit on
+ * in ib_device structure at init time.
+ *
+ * Return: true if the device is IB switch.
+ */
+static inline bool rdma_cap_ib_switch(const struct ib_device *device)
+{
+ return device->is_switch;
+}
+
+/**
+ * rdma_start_port - Return the first valid port number for the device
+ * specified
+ *
+ * @device: Device to be checked
+ *
+ * Return start port number
+ */
+static inline u8 rdma_start_port(const struct ib_device *device)
+{
+ return rdma_cap_ib_switch(device) ? 0 : 1;
+}
+
+/**
+ * rdma_end_port - Return the last valid port number for the device
+ * specified
+ *
+ * @device: Device to be checked
+ *
+ * Return last port number
+ */
+static inline u8 rdma_end_port(const struct ib_device *device)
+{
+ return rdma_cap_ib_switch(device) ? 0 : device->phys_port_cnt;
+}
+
static inline bool rdma_protocol_ib(const struct ib_device *device, u8 port_num)
{
return device->port_immutable[port_num].core_cap_flags & RDMA_CORE_CAP_PROT_IB;
@@ -2233,6 +2498,26 @@ static inline size_t rdma_max_mad_size(const struct ib_device *device, u8 port_n
return device->port_immutable[port_num].max_mad_size;
}
+/**
+ * rdma_cap_roce_gid_table - Check if the port of device uses roce_gid_table
+ * @device: Device to check
+ * @port_num: Port number to check
+ *
+ * RoCE GID table mechanism manages the various GIDs for a device.
+ *
+ * NOTE: if allocating the port's GID table has failed, this call will still
+ * return true, but any RoCE GID table API will fail.
+ *
+ * Return: true if the port uses RoCE GID table mechanism in order to manage
+ * its GIDs.
+ */
+static inline bool rdma_cap_roce_gid_table(const struct ib_device *device,
+ u8 port_num)
+{
+ return rdma_protocol_roce(device, port_num) &&
+ device->add_gid && device->del_gid;
+}
+
/*
* Check if the device supports READ W/ INVALIDATE.
*/
@@ -2246,7 +2531,17 @@ static inline bool rdma_cap_read_inv(struct ib_device *dev, u32 port_num)
}
int ib_query_gid(struct ib_device *device,
- u8 port_num, int index, union ib_gid *gid);
+ u8 port_num, int index, union ib_gid *gid,
+ struct ib_gid_attr *attr);
+
+int ib_set_vf_link_state(struct ib_device *device, int vf, u8 port,
+ int state);
+int ib_get_vf_config(struct ib_device *device, int vf, u8 port,
+ struct ifla_vf_info *info);
+int ib_get_vf_stats(struct ib_device *device, int vf, u8 port,
+ struct ifla_vf_stats *stats);
+int ib_set_vf_guid(struct ib_device *device, int vf, u8 port, u64 guid,
+ int type);
int ib_query_pkey(struct ib_device *device,
u8 port_num, u16 index, u16 *pkey);
@@ -2260,25 +2555,30 @@ int ib_modify_port(struct ib_device *device,
struct ib_port_modify *port_modify);
int ib_find_gid(struct ib_device *device, union ib_gid *gid,
+ enum ib_gid_type gid_type, struct net_device *ndev,
u8 *port_num, u16 *index);
int ib_find_pkey(struct ib_device *device,
u8 port_num, u16 pkey, u16 *index);
-/**
- * ib_alloc_pd - Allocates an unused protection domain.
- * @device: The device on which to allocate the protection domain.
- *
- * A protection domain object provides an association between QPs, shared
- * receive queues, address handles, memory regions, and memory windows.
- */
-struct ib_pd *ib_alloc_pd(struct ib_device *device);
+enum ib_pd_flags {
+ /*
+ * Create a memory registration for all memory in the system and place
+ * the rkey for it into pd->unsafe_global_rkey. This can be used by
+ * ULPs to avoid the overhead of dynamic MRs.
+ *
+ * This flag is generally considered unsafe and must only be used in
+ * extremly trusted environments. Every use of it will log a warning
+ * in the kernel log.
+ */
+ IB_PD_UNSAFE_GLOBAL_RKEY = 0x01,
+};
-/**
- * ib_dealloc_pd - Deallocates a protection domain.
- * @pd: The protection domain to deallocate.
- */
-int ib_dealloc_pd(struct ib_pd *pd);
+struct ib_pd *__ib_alloc_pd(struct ib_device *device, unsigned int flags,
+ const char *caller);
+#define ib_alloc_pd(device, flags) \
+ __ib_alloc_pd((device), (flags), __func__)
+void ib_dealloc_pd(struct ib_pd *pd);
/**
* ib_create_ah - Creates an address handle for the given address vector.
@@ -2301,8 +2601,9 @@ struct ib_ah *ib_create_ah(struct ib_pd *pd, struct ib_ah_attr *ah_attr);
* @ah_attr: Returned attributes that can be used when creating an address
* handle for replying to the message.
*/
-int ib_init_ah_from_wc(struct ib_device *device, u8 port_num, struct ib_wc *wc,
- struct ib_grh *grh, struct ib_ah_attr *ah_attr);
+int ib_init_ah_from_wc(struct ib_device *device, u8 port_num,
+ const struct ib_wc *wc, const struct ib_grh *grh,
+ struct ib_ah_attr *ah_attr);
/**
* ib_create_ah_from_wc - Creates an address handle associated with the
@@ -2316,8 +2617,8 @@ int ib_init_ah_from_wc(struct ib_device *device, u8 port_num, struct ib_wc *wc,
* The address handle is used to reference a local or global destination
* in all UD QP post sends.
*/
-struct ib_ah *ib_create_ah_from_wc(struct ib_pd *pd, struct ib_wc *wc,
- struct ib_grh *grh, u8 port_num);
+struct ib_ah *ib_create_ah_from_wc(struct ib_pd *pd, const struct ib_wc *wc,
+ const struct ib_grh *grh, u8 port_num);
/**
* ib_modify_ah - Modifies the address vector associated with an address
@@ -2504,6 +2805,10 @@ static inline int ib_post_recv(struct ib_qp *qp,
return qp->device->post_recv(qp, recv_wr, bad_recv_wr);
}
+struct ib_cq *ib_alloc_cq(struct ib_device *dev, void *private,
+ int nr_cqe, int comp_vector, enum ib_poll_context poll_ctx);
+void ib_free_cq(struct ib_cq *cq);
+
/**
* ib_create_cq - Creates a CQ on the specified device.
* @device: The device on which to create the CQ.
@@ -2513,16 +2818,15 @@ static inline int ib_post_recv(struct ib_qp *qp,
* asynchronous event not associated with a completion occurs on the CQ.
* @cq_context: Context associated with the CQ returned to the user via
* the associated completion and event handlers.
- * @cqe: The minimum size of the CQ.
- * @comp_vector - Completion vector used to signal completion events.
- * Must be >= 0 and < context->num_comp_vectors.
+ * @cq_attr: The attributes the CQ should be created upon.
*
* Users can examine the cq structure to determine the actual CQ size.
*/
struct ib_cq *ib_create_cq(struct ib_device *device,
ib_comp_handler comp_handler,
void (*event_handler)(struct ib_event *, void *),
- void *cq_context, int cqe, int comp_vector);
+ void *cq_context,
+ const struct ib_cq_init_attr *cq_attr);
/**
* ib_resize_cq - Modifies the capacity of the CQ.
@@ -2534,16 +2838,13 @@ struct ib_cq *ib_create_cq(struct ib_device *device,
int ib_resize_cq(struct ib_cq *cq, int cqe);
/**
- * ib_modify_cq - Modifies the attributes for the specified CQ and then
- * transitions the CQ to the given state.
+ * ib_modify_cq - Modifies moderation params of the CQ
* @cq: The CQ to modify.
- * @cq_attr: specifies the CQ attributes to modify.
- * @cq_attr_mask: A bit-mask used to specify which attributes of the CQ
- * are being modified.
+ * @cq_count: number of CQEs that will trigger an event
+ * @cq_period: max period of time in usec before triggering an event
+ *
*/
-int ib_modify_cq(struct ib_cq *cq,
- struct ib_cq_attr *cq_attr,
- int cq_attr_mask);
+int ib_modify_cq(struct ib_cq *cq, u16 cq_count, u16 cq_period);
/**
* ib_destroy_cq - Destroys the specified CQ.
@@ -2629,18 +2930,6 @@ static inline int ib_req_ncomp_notif(struct ib_cq *cq, int wc_cnt)
}
/**
- * ib_get_dma_mr - Returns a memory region for system memory that is
- * usable for DMA.
- * @pd: The protection domain associated with the memory region.
- * @mr_access_flags: Specifies the memory access rights.
- *
- * Note that the ib_dma_*() functions defined below must be used
- * to create/destroy addresses used with the Lkey or Rkey returned
- * by ib_get_dma_mr().
- */
-struct ib_mr *ib_get_dma_mr(struct ib_pd *pd, int mr_access_flags);
-
-/**
* ib_dma_mapping_error - check a DMA addr for error
* @dev: The device for which the dma_addr was created
* @dma_addr: The DMA address to check
@@ -2688,19 +2977,19 @@ static inline void ib_dma_unmap_single(struct ib_device *dev,
static inline u64 ib_dma_map_single_attrs(struct ib_device *dev,
void *cpu_addr, size_t size,
enum dma_data_direction direction,
- struct dma_attrs *attrs)
+ struct dma_attrs *dma_attrs)
{
return dma_map_single_attrs(dev->dma_device, cpu_addr, size,
- direction, attrs);
+ direction, dma_attrs);
}
static inline void ib_dma_unmap_single_attrs(struct ib_device *dev,
u64 addr, size_t size,
enum dma_data_direction direction,
- struct dma_attrs *attrs)
+ struct dma_attrs *dma_attrs)
{
return dma_unmap_single_attrs(dev->dma_device, addr, size,
- direction, attrs);
+ direction, dma_attrs);
}
/**
@@ -2775,28 +3064,39 @@ static inline void ib_dma_unmap_sg(struct ib_device *dev,
static inline int ib_dma_map_sg_attrs(struct ib_device *dev,
struct scatterlist *sg, int nents,
enum dma_data_direction direction,
- struct dma_attrs *attrs)
+ struct dma_attrs *dma_attrs)
{
- return dma_map_sg_attrs(dev->dma_device, sg, nents, direction, attrs);
+ if (dev->dma_ops)
+ return dev->dma_ops->map_sg_attrs(dev, sg, nents, direction,
+ dma_attrs);
+ else
+ return dma_map_sg_attrs(dev->dma_device, sg, nents, direction,
+ dma_attrs);
}
static inline void ib_dma_unmap_sg_attrs(struct ib_device *dev,
struct scatterlist *sg, int nents,
enum dma_data_direction direction,
- struct dma_attrs *attrs)
+ struct dma_attrs *dma_attrs)
{
- dma_unmap_sg_attrs(dev->dma_device, sg, nents, direction, attrs);
+ if (dev->dma_ops)
+ return dev->dma_ops->unmap_sg_attrs(dev, sg, nents, direction,
+ dma_attrs);
+ else
+ dma_unmap_sg_attrs(dev->dma_device, sg, nents, direction,
+ dma_attrs);
}
/**
* ib_sg_dma_address - Return the DMA address from a scatter/gather entry
* @dev: The device for which the DMA addresses were created
* @sg: The scatter/gather entry
+ *
+ * Note: this function is obsolete. To do: change all occurrences of
+ * ib_sg_dma_address() into sg_dma_address().
*/
static inline u64 ib_sg_dma_address(struct ib_device *dev,
struct scatterlist *sg)
{
- if (dev->dma_ops)
- return dev->dma_ops->dma_address(dev, sg);
return sg_dma_address(sg);
}
@@ -2804,12 +3104,13 @@ static inline u64 ib_sg_dma_address(struct ib_device *dev,
* ib_sg_dma_len - Return the DMA length from a scatter/gather entry
* @dev: The device for which the DMA addresses were created
* @sg: The scatter/gather entry
+ *
+ * Note: this function is obsolete. To do: change all occurrences of
+ * ib_sg_dma_len() into sg_dma_len().
*/
static inline unsigned int ib_sg_dma_len(struct ib_device *dev,
struct scatterlist *sg)
{
- if (dev->dma_ops)
- return dev->dma_ops->dma_len(dev, sg);
return sg_dma_len(sg);
}
@@ -2891,59 +3192,6 @@ static inline void ib_dma_free_coherent(struct ib_device *dev,
}
/**
- * ib_reg_phys_mr - Prepares a virtually addressed memory region for use
- * by an HCA.
- * @pd: The protection domain associated assigned to the registered region.
- * @phys_buf_array: Specifies a list of physical buffers to use in the
- * memory region.
- * @num_phys_buf: Specifies the size of the phys_buf_array.
- * @mr_access_flags: Specifies the memory access rights.
- * @iova_start: The offset of the region's starting I/O virtual address.
- */
-struct ib_mr *ib_reg_phys_mr(struct ib_pd *pd,
- struct ib_phys_buf *phys_buf_array,
- int num_phys_buf,
- int mr_access_flags,
- u64 *iova_start);
-
-/**
- * ib_rereg_phys_mr - Modifies the attributes of an existing memory region.
- * Conceptually, this call performs the functions deregister memory region
- * followed by register physical memory region. Where possible,
- * resources are reused instead of deallocated and reallocated.
- * @mr: The memory region to modify.
- * @mr_rereg_mask: A bit-mask used to indicate which of the following
- * properties of the memory region are being modified.
- * @pd: If %IB_MR_REREG_PD is set in mr_rereg_mask, this field specifies
- * the new protection domain to associated with the memory region,
- * otherwise, this parameter is ignored.
- * @phys_buf_array: If %IB_MR_REREG_TRANS is set in mr_rereg_mask, this
- * field specifies a list of physical buffers to use in the new
- * translation, otherwise, this parameter is ignored.
- * @num_phys_buf: If %IB_MR_REREG_TRANS is set in mr_rereg_mask, this
- * field specifies the size of the phys_buf_array, otherwise, this
- * parameter is ignored.
- * @mr_access_flags: If %IB_MR_REREG_ACCESS is set in mr_rereg_mask, this
- * field specifies the new memory access rights, otherwise, this
- * parameter is ignored.
- * @iova_start: The offset of the region's starting I/O virtual address.
- */
-int ib_rereg_phys_mr(struct ib_mr *mr,
- int mr_rereg_mask,
- struct ib_pd *pd,
- struct ib_phys_buf *phys_buf_array,
- int num_phys_buf,
- int mr_access_flags,
- u64 *iova_start);
-
-/**
- * ib_query_mr - Retrieves information about a specific memory region.
- * @mr: The memory region to retrieve information about.
- * @mr_attr: The attributes of the specified memory region.
- */
-int ib_query_mr(struct ib_mr *mr, struct ib_mr_attr *mr_attr);
-
-/**
* ib_dereg_mr - Deregisters a memory region and removes it from the
* HCA translation table.
* @mr: The memory region to deregister.
@@ -2952,60 +3200,9 @@ int ib_query_mr(struct ib_mr *mr, struct ib_mr_attr *mr_attr);
*/
int ib_dereg_mr(struct ib_mr *mr);
-
-/**
- * ib_create_mr - Allocates a memory region that may be used for
- * signature handover operations.
- * @pd: The protection domain associated with the region.
- * @mr_init_attr: memory region init attributes.
- */
-struct ib_mr *ib_create_mr(struct ib_pd *pd,
- struct ib_mr_init_attr *mr_init_attr);
-
-/**
- * ib_destroy_mr - Destroys a memory region that was created using
- * ib_create_mr and removes it from HW translation tables.
- * @mr: The memory region to destroy.
- *
- * This function can fail, if the memory region has memory windows bound to it.
- */
-int ib_destroy_mr(struct ib_mr *mr);
-
-/**
- * ib_alloc_fast_reg_mr - Allocates memory region usable with the
- * IB_WR_FAST_REG_MR send work request.
- * @pd: The protection domain associated with the region.
- * @max_page_list_len: requested max physical buffer list length to be
- * used with fast register work requests for this MR.
- */
-struct ib_mr *ib_alloc_fast_reg_mr(struct ib_pd *pd, int max_page_list_len);
-
-/**
- * ib_alloc_fast_reg_page_list - Allocates a page list array
- * @device - ib device pointer.
- * @page_list_len - size of the page list array to be allocated.
- *
- * This allocates and returns a struct ib_fast_reg_page_list * and a
- * page_list array that is at least page_list_len in size. The actual
- * size is returned in max_page_list_len. The caller is responsible
- * for initializing the contents of the page_list array before posting
- * a send work request with the IB_WC_FAST_REG_MR opcode.
- *
- * The page_list array entries must be translated using one of the
- * ib_dma_*() functions just like the addresses passed to
- * ib_map_phys_fmr(). Once the ib_post_send() is issued, the struct
- * ib_fast_reg_page_list must not be modified by the caller until the
- * IB_WC_FAST_REG_MR work request completes.
- */
-struct ib_fast_reg_page_list *ib_alloc_fast_reg_page_list(
- struct ib_device *device, int page_list_len);
-
-/**
- * ib_free_fast_reg_page_list - Deallocates a previously allocated
- * page list array.
- * @page_list - struct ib_fast_reg_page_list pointer to be deallocated.
- */
-void ib_free_fast_reg_page_list(struct ib_fast_reg_page_list *page_list);
+struct ib_mr *ib_alloc_mr(struct ib_pd *pd,
+ enum ib_mr_type mr_type,
+ u32 max_num_sg);
/**
* ib_update_fast_reg_key - updates the key portion of the fast_reg MR
@@ -3031,42 +3228,6 @@ static inline u32 ib_inc_rkey(u32 rkey)
}
/**
- * ib_alloc_mw - Allocates a memory window.
- * @pd: The protection domain associated with the memory window.
- * @type: The type of the memory window (1 or 2).
- */
-struct ib_mw *ib_alloc_mw(struct ib_pd *pd, enum ib_mw_type type);
-
-/**
- * ib_bind_mw - Posts a work request to the send queue of the specified
- * QP, which binds the memory window to the given address range and
- * remote access attributes.
- * @qp: QP to post the bind work request on.
- * @mw: The memory window to bind.
- * @mw_bind: Specifies information about the memory window, including
- * its address range, remote access rights, and associated memory region.
- *
- * If there is no immediate error, the function will update the rkey member
- * of the mw parameter to its new value. The bind operation can still fail
- * asynchronously.
- */
-static inline int ib_bind_mw(struct ib_qp *qp,
- struct ib_mw *mw,
- struct ib_mw_bind *mw_bind)
-{
- /* XXX reference counting in corresponding MR? */
- return mw->device->bind_mw ?
- mw->device->bind_mw(qp, mw, mw_bind) :
- -ENOSYS;
-}
-
-/**
- * ib_dealloc_mw - Deallocates a memory window.
- * @mw: The memory window to deallocate.
- */
-int ib_dealloc_mw(struct ib_mw *mw);
-
-/**
* ib_alloc_fmr - Allocates a unmapped fast memory region.
* @pd: The protection domain associated with the unmapped region.
* @mr_access_flags: Specifies the memory access rights.
@@ -3143,47 +3304,6 @@ struct ib_flow *ib_create_flow(struct ib_qp *qp,
struct ib_flow_attr *flow_attr, int domain);
int ib_destroy_flow(struct ib_flow *flow_id);
-struct ib_dct *ib_create_dct(struct ib_pd *pd, struct ib_dct_init_attr *attr,
- struct ib_udata *udata);
-int ib_destroy_dct(struct ib_dct *dct);
-int ib_query_dct(struct ib_dct *dct, struct ib_dct_attr *attr);
-
-int ib_query_values(struct ib_device *device,
- int q_values, struct ib_device_values *values);
-
-static inline void ib_active_speed_enum_to_rate(u8 active_speed,
- int *rate,
- char **speed)
-{
- switch (active_speed) {
- case IB_SPEED_DDR:
- *speed = " DDR";
- *rate = 50;
- break;
- case IB_SPEED_QDR:
- *speed = " QDR";
- *rate = 100;
- break;
- case IB_SPEED_FDR10:
- *speed = " FDR10";
- *rate = 100;
- break;
- case IB_SPEED_FDR:
- *speed = " FDR";
- *rate = 140;
- break;
- case IB_SPEED_EDR:
- *speed = " EDR";
- *rate = 250;
- break;
- case IB_SPEED_SDR:
- default: /* default to SDR for invalid rates */
- *rate = 25;
- break;
- }
-
-}
-
static inline int ib_check_mr_access(int flags)
{
/*
@@ -3212,4 +3332,38 @@ static inline int ib_check_mr_access(int flags)
int ib_check_mr_status(struct ib_mr *mr, u32 check_mask,
struct ib_mr_status *mr_status);
+struct net_device *ib_get_net_dev_by_params(struct ib_device *dev, u8 port,
+ u16 pkey, const union ib_gid *gid,
+ const struct sockaddr *addr);
+struct ib_wq *ib_create_wq(struct ib_pd *pd,
+ struct ib_wq_init_attr *init_attr);
+int ib_destroy_wq(struct ib_wq *wq);
+int ib_modify_wq(struct ib_wq *wq, struct ib_wq_attr *attr,
+ u32 wq_attr_mask);
+struct ib_rwq_ind_table *ib_create_rwq_ind_table(struct ib_device *device,
+ struct ib_rwq_ind_table_init_attr*
+ wq_ind_table_init_attr);
+int ib_destroy_rwq_ind_table(struct ib_rwq_ind_table *wq_ind_table);
+
+int ib_map_mr_sg(struct ib_mr *mr, struct scatterlist *sg, int sg_nents,
+ unsigned int *sg_offset, unsigned int page_size);
+
+static inline int
+ib_map_mr_sg_zbva(struct ib_mr *mr, struct scatterlist *sg, int sg_nents,
+ unsigned int *sg_offset, unsigned int page_size)
+{
+ int n;
+
+ n = ib_map_mr_sg(mr, sg, sg_nents, sg_offset, page_size);
+ mr->iova = 0;
+
+ return n;
+}
+
+int ib_sg_to_pages(struct ib_mr *mr, struct scatterlist *sgl, int sg_nents,
+ unsigned int *sg_offset, int (*set_page)(struct ib_mr *, u64));
+
+void ib_drain_rq(struct ib_qp *qp);
+void ib_drain_sq(struct ib_qp *qp);
+void ib_drain_qp(struct ib_qp *qp);
#endif /* IB_VERBS_H */
diff --git a/sys/ofed/include/rdma/ib_verbs_compat.h b/sys/ofed/include/rdma/ib_verbs_compat.h
new file mode 100644
index 0000000..a4eb4f6
--- /dev/null
+++ b/sys/ofed/include/rdma/ib_verbs_compat.h
@@ -0,0 +1,582 @@
+/*-
+ * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ *
+ * Copyright (c) 2018, Mellanox Technologies, Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS `AS IS' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * $FreeBSD$
+ */
+
+#if !defined(IB_VERBS_COMPAT_H)
+#define IB_VERBS_COMPAT_H
+
+#include <rdma/ib_verbs.h>
+
+enum ib_device_attr_comp_mask {
+ IB_DEVICE_ATTR_WITH_TIMESTAMP_MASK = 1ULL << 1,
+ IB_DEVICE_ATTR_WITH_HCA_CORE_CLOCK = 1ULL << 2
+};
+
+struct ib_protocol_stats {
+ /* TBD... */
+};
+
+struct iw_protocol_stats {
+ u64 ipInReceives;
+ u64 ipInHdrErrors;
+ u64 ipInTooBigErrors;
+ u64 ipInNoRoutes;
+ u64 ipInAddrErrors;
+ u64 ipInUnknownProtos;
+ u64 ipInTruncatedPkts;
+ u64 ipInDiscards;
+ u64 ipInDelivers;
+ u64 ipOutForwDatagrams;
+ u64 ipOutRequests;
+ u64 ipOutDiscards;
+ u64 ipOutNoRoutes;
+ u64 ipReasmTimeout;
+ u64 ipReasmReqds;
+ u64 ipReasmOKs;
+ u64 ipReasmFails;
+ u64 ipFragOKs;
+ u64 ipFragFails;
+ u64 ipFragCreates;
+ u64 ipInMcastPkts;
+ u64 ipOutMcastPkts;
+ u64 ipInBcastPkts;
+ u64 ipOutBcastPkts;
+
+ u64 tcpRtoAlgorithm;
+ u64 tcpRtoMin;
+ u64 tcpRtoMax;
+ u64 tcpMaxConn;
+ u64 tcpActiveOpens;
+ u64 tcpPassiveOpens;
+ u64 tcpAttemptFails;
+ u64 tcpEstabResets;
+ u64 tcpCurrEstab;
+ u64 tcpInSegs;
+ u64 tcpOutSegs;
+ u64 tcpRetransSegs;
+ u64 tcpInErrs;
+ u64 tcpOutRsts;
+};
+
+union rdma_protocol_stats {
+ struct ib_protocol_stats ib;
+ struct iw_protocol_stats iw;
+};
+
+enum ib_mr_create_flags {
+ IB_MR_SIGNATURE_EN = 1,
+};
+
+struct ib_mr_init_attr {
+ int max_reg_descriptors;
+ u32 flags;
+};
+
+enum ib_qpg_type {
+ IB_QPG_NONE = 0,
+ IB_QPG_PARENT = (1 << 0),
+ IB_QPG_CHILD_RX = (1 << 1),
+ IB_QPG_CHILD_TX = (1 << 2)
+};
+
+struct ib_qpg_init_attrib {
+ u32 tss_child_count;
+ u32 rss_child_count;
+};
+
+enum {
+ IB_DCT_CREATE_FLAG_RCV_INLINE = 1 << 0,
+ IB_DCT_CREATE_FLAGS_MASK = IB_DCT_CREATE_FLAG_RCV_INLINE,
+};
+
+struct ib_dct_init_attr {
+ struct ib_pd *pd;
+ struct ib_cq *cq;
+ struct ib_srq *srq;
+ u64 dc_key;
+ u8 port;
+ u32 access_flags;
+ u8 min_rnr_timer;
+ u8 tclass;
+ u32 flow_label;
+ enum ib_mtu mtu;
+ u8 pkey_index;
+ u8 gid_index;
+ u8 hop_limit;
+ u32 create_flags;
+};
+
+struct ib_dct_attr {
+ u64 dc_key;
+ u8 port;
+ u32 access_flags;
+ u8 min_rnr_timer;
+ u8 tclass;
+ u32 flow_label;
+ enum ib_mtu mtu;
+ u8 pkey_index;
+ u8 gid_index;
+ u8 hop_limit;
+ u32 key_violations;
+ u8 state;
+};
+
+struct ib_fast_reg_page_list {
+ struct ib_device *device;
+ u64 *page_list;
+ unsigned int max_page_list_len;
+};
+
+struct ib_mw_bind_info {
+ struct ib_mr *mr;
+ u64 addr;
+ u64 length;
+ int mw_access_flags;
+};
+
+struct ib_mr_attr {
+ struct ib_pd *pd;
+ u64 device_virt_addr;
+ u64 size;
+ int mr_access_flags;
+ u32 lkey;
+ u32 rkey;
+};
+
+struct ib_mw_bind {
+ u64 wr_id;
+ int send_flags;
+ struct ib_mw_bind_info bind_info;
+};
+
+enum ib_cq_attr_mask {
+ IB_CQ_MODERATION = (1 << 0),
+ IB_CQ_CAP_FLAGS = (1 << 1)
+};
+
+enum ib_cq_cap_flags {
+ IB_CQ_IGNORE_OVERRUN = (1 << 0)
+};
+
+struct ib_cq_attr {
+ struct {
+ u16 cq_count;
+ u16 cq_period;
+ } moderation;
+ u32 cq_cap_flags;
+};
+
+struct ib_dct {
+ struct ib_device *device;
+ struct ib_uobject *uobject;
+ struct ib_pd *pd;
+ struct ib_cq *cq;
+ struct ib_srq *srq;
+ u32 dct_num;
+};
+
+enum verbs_values_mask {
+ IBV_VALUES_HW_CLOCK = 1 << 0
+};
+
+struct ib_device_values {
+ int values_mask;
+ uint64_t hwclock;
+};
+
+#define IB_WR_FAST_REG_MR -2 /* not implemented */
+
+struct ib_send_wr_compat {
+ union {
+ /*
+ * NOTE: The following structure must be kept in sync
+ * with "struct ib_send_wr":
+ */
+ struct {
+ struct ib_send_wr_compat *next;
+ union {
+ u64 wr_id;
+ struct ib_cqe *wr_cqe;
+ };
+ struct ib_sge *sg_list;
+ int num_sge;
+ enum ib_wr_opcode opcode;
+ int send_flags;
+ union {
+ __be32 imm_data;
+ u32 invalidate_rkey;
+ } ex;
+ };
+ union {
+ struct ib_rdma_wr rdma;
+ struct ib_atomic_wr atomic;
+ struct ib_ud_wr ud;
+ struct ib_sig_handover_wr sig_handover;
+ struct {
+ struct ib_send_wr wr;
+ u64 iova_start;
+ struct ib_fast_reg_page_list *page_list;
+ unsigned int page_shift;
+ unsigned int page_list_len;
+ u32 length;
+ int access_flags;
+ u32 rkey;
+ } fast_reg;
+ struct {
+ struct ib_send_wr wr;
+ int npages;
+ int access_flags;
+ u32 mkey;
+ struct ib_pd *pd;
+ u64 virt_addr;
+ u64 length;
+ int page_shift;
+ } umr;
+ struct {
+ struct ib_send_wr wr;
+ struct ib_mw *mw;
+ /* The new rkey for the memory window. */
+ u32 rkey;
+ struct ib_mw_bind_info bind_info;
+ } bind_mw;
+ } wr;
+ };
+ u32 xrc_remote_srq_num; /* XRC TGT QPs only */
+};
+
+static inline int
+ib_post_send_compat(struct ib_qp *qp,
+ struct ib_send_wr_compat *send_wr,
+ struct ib_send_wr_compat **bad_send_wr)
+{
+ return (ib_post_send(qp, (struct ib_send_wr *)send_wr,
+ (struct ib_send_wr **)bad_send_wr));
+}
+
+#undef ib_post_send
+#define ib_post_send(...) \
+ ib_post_send_compat(__VA_ARGS__)
+
+#define ib_send_wr \
+ ib_send_wr_compat
+
+static inline int
+ib_query_device_compat(struct ib_device *device,
+ struct ib_device_attr *device_attr)
+{
+ *device_attr = device->attrs;
+ return (0);
+}
+
+#undef ib_query_device
+#define ib_query_device(...) \
+ ib_query_device_compat(__VA_ARGS__)
+
+static inline int
+ib_query_gid_compat(struct ib_device *device,
+ u8 port_num, int index, union ib_gid *gid)
+{
+ return (ib_query_gid(device, port_num, index, gid, NULL));
+}
+
+#undef ib_query_gid
+#define ib_query_gid(...) \
+ ib_query_gid_compat(__VA_ARGS__)
+
+static inline int
+ib_find_gid_compat(struct ib_device *device, union ib_gid *gid,
+ u8 * port_num, u16 * index)
+{
+ return (ib_find_gid(device, gid, IB_GID_TYPE_IB, NULL, port_num, index));
+}
+
+#undef ib_find_gid
+#define ib_find_gid(...) \
+ ib_find_gid_compat(__VA_ARGS__)
+
+static inline struct ib_pd *
+ib_alloc_pd_compat(struct ib_device *device)
+{
+ return (ib_alloc_pd(device, 0));
+}
+
+#undef ib_alloc_pd
+#define ib_alloc_pd(...) \
+ ib_alloc_pd_compat(__VA_ARGS__)
+
+static inline struct ib_cq *
+ib_create_cq_compat(struct ib_device *device,
+ ib_comp_handler comp_handler,
+ void (*event_handler) (struct ib_event *, void *),
+ void *cq_context, int cqe, int comp_vector)
+{
+ const struct ib_cq_init_attr cq_attr = {.cqe = cqe,.comp_vector = comp_vector};
+
+ return (ib_create_cq(device, comp_handler, event_handler, cq_context, &cq_attr));
+}
+
+#undef ib_create_cq
+#define ib_create_cq(...) \
+ ib_create_cq_compat(__VA_ARGS__)
+
+static inline int
+ib_modify_cq_compat(struct ib_cq *cq,
+ struct ib_cq_attr *cq_attr,
+ int cq_attr_mask)
+{
+ if (cq_attr_mask & IB_CQ_MODERATION) {
+ return (ib_modify_cq(cq, cq_attr->moderation.cq_count,
+ cq_attr->moderation.cq_period));
+ } else {
+ return (0);
+ }
+}
+
+#undef ib_modify_cq
+#define ib_modify_cq(...) \
+ ib_modify_cq_compat(__VA_ARGS__)
+
+static inline struct ib_mr *
+ib_get_dma_mr(struct ib_pd *pd, int mr_access_flags)
+{
+ struct ib_mr *mr;
+ int err;
+
+ err = ib_check_mr_access(mr_access_flags);
+ if (err)
+ return ERR_PTR(err);
+
+ if (!pd->device->get_dma_mr)
+ return ERR_PTR(-ENOSYS);
+
+ mr = pd->device->get_dma_mr(pd, mr_access_flags);
+ if (IS_ERR(mr))
+ return ERR_CAST(mr);
+
+ mr->device = pd->device;
+ mr->pd = pd;
+ mr->uobject = NULL;
+ mr->need_inval = false;
+ atomic_inc(&pd->usecnt);
+
+ return (mr);
+}
+
+static inline struct ib_mr *
+ib_reg_phys_mr(struct ib_pd *pd,
+ struct ib_phys_buf *phys_buf_array,
+ int num_phys_buf,
+ int mr_access_flags,
+ u64 * iova_start)
+{
+ struct ib_mr *mr;
+ int err;
+
+ err = ib_check_mr_access(mr_access_flags);
+ if (err)
+ return ERR_PTR(err);
+
+ if (!pd->device->reg_phys_mr)
+ return ERR_PTR(-ENOSYS);
+
+ mr = pd->device->reg_phys_mr(pd, phys_buf_array, num_phys_buf,
+ mr_access_flags, iova_start);
+ if (IS_ERR(mr))
+ return ERR_CAST(mr);
+
+ mr->device = pd->device;
+ mr->pd = pd;
+ mr->uobject = NULL;
+ atomic_inc(&pd->usecnt);
+
+ return (mr);
+}
+
+static inline int
+ib_rereg_phys_mr(struct ib_mr *mr,
+ int mr_rereg_mask,
+ struct ib_pd *pd,
+ struct ib_phys_buf *phys_buf_array,
+ int num_phys_buf,
+ int mr_access_flags,
+ u64 * iova_start)
+{
+ return (-EOPNOTSUPP);
+}
+
+static inline int
+ib_query_mr(struct ib_mr *mr, struct ib_mr_attr *mr_attr)
+{
+ return (-EOPNOTSUPP);
+}
+
+static inline struct ib_mr *
+ib_create_mr(struct ib_pd *pd,
+ struct ib_mr_init_attr *mr_init_attr)
+{
+ return (ERR_PTR(-ENOSYS));
+}
+
+static inline int
+ib_destroy_mr(struct ib_mr *mr)
+{
+ return (-EOPNOTSUPP);
+}
+
+static inline struct ib_mr *
+ib_alloc_fast_reg_mr(struct ib_pd *pd, int max_page_list_len)
+{
+ return (ERR_PTR(-ENOSYS));
+}
+
+static inline struct ib_fast_reg_page_list *
+ib_alloc_fast_reg_page_list(struct ib_device *device, int page_list_len)
+{
+ return (ERR_PTR(-ENOSYS));
+}
+
+static inline void
+ib_free_fast_reg_page_list(struct ib_fast_reg_page_list *page_list)
+{
+
+}
+
+static inline struct ib_mw *
+ib_alloc_mw(struct ib_pd *pd, enum ib_mw_type type)
+{
+ struct ib_mw *mw;
+
+ if (!pd->device->alloc_mw)
+ return ERR_PTR(-ENOSYS);
+
+ mw = pd->device->alloc_mw(pd, type, NULL);
+ if (!IS_ERR(mw)) {
+ mw->device = pd->device;
+ mw->pd = pd;
+ mw->uobject = NULL;
+ mw->type = type;
+ atomic_inc(&pd->usecnt);
+ }
+ return (mw);
+}
+
+static inline int
+ib_bind_mw(struct ib_qp *qp,
+ struct ib_mw *mw,
+ struct ib_mw_bind *mw_bind)
+{
+ return (-EOPNOTSUPP);
+}
+
+static inline int
+ib_dealloc_mw(struct ib_mw *mw)
+{
+ struct ib_pd *pd;
+ int ret;
+
+ pd = mw->pd;
+ ret = mw->device->dealloc_mw(mw);
+ if (!ret)
+ atomic_dec(&pd->usecnt);
+ return (ret);
+}
+
+static inline struct ib_dct *
+ib_create_dct(struct ib_pd *pd, struct ib_dct_init_attr *attr,
+ struct ib_udata *udata)
+{
+ return (ERR_PTR(-ENOSYS));
+}
+
+static inline int
+ib_destroy_dct(struct ib_dct *dct)
+{
+ return (-EOPNOTSUPP);
+}
+
+static inline int
+ib_query_dct(struct ib_dct *dct, struct ib_dct_attr *attr)
+{
+ return (-EOPNOTSUPP);
+}
+
+static inline int
+ib_query_values(struct ib_device *device,
+ int q_values, struct ib_device_values *values)
+{
+ return (-EOPNOTSUPP);
+}
+
+static inline void
+ib_active_speed_enum_to_rate(u8 active_speed,
+ int *rate,
+ char **speed)
+{
+ switch (active_speed) {
+ case IB_SPEED_DDR:
+ *speed = " DDR";
+ *rate = 50;
+ break;
+ case IB_SPEED_QDR:
+ *speed = " QDR";
+ *rate = 100;
+ break;
+ case IB_SPEED_FDR10:
+ *speed = " FDR10";
+ *rate = 100;
+ break;
+ case IB_SPEED_FDR:
+ *speed = " FDR";
+ *rate = 140;
+ break;
+ case IB_SPEED_EDR:
+ *speed = " EDR";
+ *rate = 250;
+ break;
+ case IB_SPEED_SDR:
+ default: /* default to SDR for invalid rates */
+ *rate = 25;
+ break;
+ }
+}
+
+#include <rdma/rdma_cm.h>
+
+static inline struct rdma_cm_id *
+rdma_create_id_compat(rdma_cm_event_handler event_handler,
+ void *context, enum rdma_port_space ps,
+ enum ib_qp_type qp_type)
+{
+ return (rdma_create_id(&init_net, event_handler, context, ps, qp_type));
+}
+
+#undef rdma_create_id
+#define rdma_create_id(...) \
+ rdma_create_id_compat(__VA_ARGS__)
+
+#endif /* IB_VERBS_COMPAT_H */
diff --git a/sys/ofed/include/rdma/ib_verbs_exp.h b/sys/ofed/include/rdma/ib_verbs_exp.h
deleted file mode 100644
index ca5b84b..0000000
--- a/sys/ofed/include/rdma/ib_verbs_exp.h
+++ /dev/null
@@ -1,100 +0,0 @@
-/*
- * Copyright (c) 2004 Mellanox Technologies Ltd. All rights reserved.
- * Copyright (c) 2004 Infinicon Corporation. All rights reserved.
- * Copyright (c) 2004 Intel Corporation. All rights reserved.
- * Copyright (c) 2004 Topspin Corporation. All rights reserved.
- * Copyright (c) 2004 Voltaire Corporation. All rights reserved.
- * Copyright (c) 2005 Sun Microsystems, Inc. All rights reserved.
- * Copyright (c) 2005, 2006, 2007 Cisco Systems. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-#ifndef IB_VERBS_EXP_H
-#define IB_VERBS_EXP_H
-
-#include <rdma/ib_verbs.h>
-
-
-enum ib_exp_device_cap_flags2 {
- IB_EXP_DEVICE_DC_TRANSPORT = 1 << 0,
- IB_EXP_DEVICE_QPG = 1 << 1,
- IB_EXP_DEVICE_UD_RSS = 1 << 2,
- IB_EXP_DEVICE_UD_TSS = 1 << 3
-};
-
-enum ib_exp_device_attr_comp_mask {
- IB_EXP_DEVICE_ATTR_WITH_TIMESTAMP_MASK = 1ULL << 1,
- IB_EXP_DEVICE_ATTR_WITH_HCA_CORE_CLOCK = 1ULL << 2,
- IB_EXP_DEVICE_ATTR_CAP_FLAGS2 = 1ULL << 3,
- IB_EXP_DEVICE_ATTR_DC_REQ_RD = 1ULL << 4,
- IB_EXP_DEVICE_ATTR_DC_RES_RD = 1ULL << 5,
- IB_EXP_DEVICE_ATTR_INLINE_RECV_SZ = 1ULL << 6,
- IB_EXP_DEVICE_ATTR_RSS_TBL_SZ = 1ULL << 7,
-};
-
-struct ib_exp_device_attr {
- struct ib_device_attr base;
- /* Use IB_EXP_DEVICE_ATTR_... for exp_comp_mask */
- uint32_t exp_comp_mask;
- uint64_t device_cap_flags2;
- uint32_t dc_rd_req;
- uint32_t dc_rd_res;
- uint32_t inline_recv_sz;
- uint32_t max_rss_tbl_sz;
-};
-
-struct ib_exp_qp_init_attr {
- void (*event_handler)(struct ib_event *, void *);
- void *qp_context;
- struct ib_cq *send_cq;
- struct ib_cq *recv_cq;
- struct ib_srq *srq;
- struct ib_xrcd *xrcd; /* XRC TGT QPs only */
- struct ib_qp_cap cap;
- union {
- struct ib_qp *qpg_parent; /* see qpg_type */
- struct ib_qpg_init_attrib parent_attrib;
- };
- enum ib_sig_type sq_sig_type;
- enum ib_qp_type qp_type;
- enum ib_qp_create_flags create_flags;
- enum ib_qpg_type qpg_type;
- u8 port_num; /* special QP types only */
- u32 max_inl_recv;
-};
-
-
-int ib_exp_query_device(struct ib_device *device,
- struct ib_exp_device_attr *device_attr);
-
-
-
-
-#endif /* IB_VERBS_EXP_H */
diff --git a/sys/ofed/include/rdma/iw_cm.h b/sys/ofed/include/rdma/iw_cm.h
index a246e61..1a919be 100644
--- a/sys/ofed/include/rdma/iw_cm.h
+++ b/sys/ofed/include/rdma/iw_cm.h
@@ -1,7 +1,6 @@
/*
* Copyright (c) 2005 Network Appliance, Inc. All rights reserved.
* Copyright (c) 2005 Open Grid Computing, Inc. All rights reserved.
- * Copyright (c) 2016 Chelsio Communications. All rights reserved.
*
* This software is available to you under a choice of one of two
* licenses. You may choose to be licensed under the terms of the GNU
@@ -50,12 +49,11 @@ enum iw_cm_event_type {
struct iw_cm_event {
enum iw_cm_event_type event;
int status;
- struct sockaddr_in local_addr;
- struct sockaddr_in remote_addr;
+ struct sockaddr_storage local_addr;
+ struct sockaddr_storage remote_addr;
void *private_data;
void *provider_data;
u8 private_data_len;
- struct socket *so;
u8 ord;
u8 ird;
};
@@ -85,15 +83,17 @@ struct iw_cm_id {
iw_cm_handler cm_handler; /* client callback function */
void *context; /* client cb context */
struct ib_device *device;
- struct sockaddr_in local_addr;
- struct sockaddr_in remote_addr;
+ struct sockaddr_storage local_addr; /* local addr */
+ struct sockaddr_storage remote_addr;
+ struct sockaddr_storage m_local_addr; /* nmapped local addr */
+ struct sockaddr_storage m_remote_addr; /* nmapped rem addr */
void *provider_data; /* provider private data */
iw_event_handler event_handler; /* cb for provider
events */
/* Used by provider to add and remove refs on IW cm_id */
void (*add_ref)(struct iw_cm_id *);
void (*rem_ref)(struct iw_cm_id *);
- struct socket *so;
+ u8 tos;
};
struct iw_cm_conn_param {
@@ -121,13 +121,11 @@ struct iw_cm_verbs {
int (*reject)(struct iw_cm_id *cm_id,
const void *pdata, u8 pdata_len);
- int (*create_listen_ep)(struct iw_cm_id *cm_id,
+ int (*create_listen)(struct iw_cm_id *cm_id,
int backlog);
- void (*destroy_listen_ep)(struct iw_cm_id *cm_id);
-
- void (*newconn)(struct iw_cm_id *parent_cm_id,
- struct socket *so);
+ int (*destroy_listen)(struct iw_cm_id *cm_id);
+ char ifname[IFNAMSIZ];
};
/**
@@ -138,7 +136,7 @@ struct iw_cm_verbs {
* returned IW CM identifier.
* @context: User specified context associated with the id.
*/
-struct iw_cm_id *iw_create_cm_id(struct ib_device *device, struct socket *so,
+struct iw_cm_id *iw_create_cm_id(struct ib_device *device,
iw_cm_handler cm_handler, void *context);
/**
diff --git a/sys/ofed/include/rdma/iw_portmap.h b/sys/ofed/include/rdma/iw_portmap.h
new file mode 100644
index 0000000..9393f50
--- /dev/null
+++ b/sys/ofed/include/rdma/iw_portmap.h
@@ -0,0 +1,70 @@
+/*
+ * Copyright (c) 2014 Intel Corporation. All rights reserved.
+ * Copyright (c) 2014 Chelsio, Inc. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+#ifndef _IW_PORTMAP_H
+#define _IW_PORTMAP_H
+
+#define IWPM_ULIBNAME_SIZE 32
+#define IWPM_DEVNAME_SIZE 32
+#define IWPM_IFNAME_SIZE 16
+#define IWPM_IPADDR_SIZE 16
+
+enum {
+ IWPM_INVALID_NLMSG_ERR = 10,
+ IWPM_CREATE_MAPPING_ERR,
+ IWPM_DUPLICATE_MAPPING_ERR,
+ IWPM_UNKNOWN_MAPPING_ERR,
+ IWPM_CLIENT_DEV_INFO_ERR,
+ IWPM_USER_LIB_INFO_ERR,
+ IWPM_REMOTE_QUERY_REJECT
+};
+
+struct iwpm_dev_data {
+ char dev_name[IWPM_DEVNAME_SIZE];
+ char if_name[IWPM_IFNAME_SIZE];
+};
+
+struct iwpm_sa_data {
+ struct sockaddr_storage loc_addr;
+ struct sockaddr_storage mapped_loc_addr;
+ struct sockaddr_storage rem_addr;
+ struct sockaddr_storage mapped_rem_addr;
+};
+
+/**
+ * iwpm_valid_pid - Check if the userspace iwarp port mapper pid is valid
+ *
+ * Returns true if the pid is greater than zero, otherwise returns false
+ */
+int iwpm_valid_pid(void);
+
+#endif /* _IW_PORTMAP_H */
diff --git a/sys/ofed/include/rdma/opa_port_info.h b/sys/ofed/include/rdma/opa_port_info.h
new file mode 100644
index 0000000..9303e0e
--- /dev/null
+++ b/sys/ofed/include/rdma/opa_port_info.h
@@ -0,0 +1,417 @@
+/*
+ * Copyright (c) 2014 Intel Corporation. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#if !defined(OPA_PORT_INFO_H)
+#define OPA_PORT_INFO_H
+
+#define OPA_PORT_LINK_MODE_NOP 0 /* No change */
+#define OPA_PORT_LINK_MODE_OPA 4 /* Port mode is OPA */
+
+#define OPA_PORT_PACKET_FORMAT_NOP 0 /* No change */
+#define OPA_PORT_PACKET_FORMAT_8B 1 /* Format 8B */
+#define OPA_PORT_PACKET_FORMAT_9B 2 /* Format 9B */
+#define OPA_PORT_PACKET_FORMAT_10B 4 /* Format 10B */
+#define OPA_PORT_PACKET_FORMAT_16B 8 /* Format 16B */
+
+#define OPA_PORT_LTP_CRC_MODE_NONE 0 /* No change */
+#define OPA_PORT_LTP_CRC_MODE_14 1 /* 14-bit LTP CRC mode (optional) */
+#define OPA_PORT_LTP_CRC_MODE_16 2 /* 16-bit LTP CRC mode */
+#define OPA_PORT_LTP_CRC_MODE_48 4 /* 48-bit LTP CRC mode (optional) */
+#define OPA_PORT_LTP_CRC_MODE_PER_LANE 8 /* 12/16-bit per lane LTP CRC mode */
+
+/* Link Down / Neighbor Link Down Reason; indicated as follows: */
+#define OPA_LINKDOWN_REASON_NONE 0 /* No specified reason */
+#define OPA_LINKDOWN_REASON_RCV_ERROR_0 1
+#define OPA_LINKDOWN_REASON_BAD_PKT_LEN 2
+#define OPA_LINKDOWN_REASON_PKT_TOO_LONG 3
+#define OPA_LINKDOWN_REASON_PKT_TOO_SHORT 4
+#define OPA_LINKDOWN_REASON_BAD_SLID 5
+#define OPA_LINKDOWN_REASON_BAD_DLID 6
+#define OPA_LINKDOWN_REASON_BAD_L2 7
+#define OPA_LINKDOWN_REASON_BAD_SC 8
+#define OPA_LINKDOWN_REASON_RCV_ERROR_8 9
+#define OPA_LINKDOWN_REASON_BAD_MID_TAIL 10
+#define OPA_LINKDOWN_REASON_RCV_ERROR_10 11
+#define OPA_LINKDOWN_REASON_PREEMPT_ERROR 12
+#define OPA_LINKDOWN_REASON_PREEMPT_VL15 13
+#define OPA_LINKDOWN_REASON_BAD_VL_MARKER 14
+#define OPA_LINKDOWN_REASON_RCV_ERROR_14 15
+#define OPA_LINKDOWN_REASON_RCV_ERROR_15 16
+#define OPA_LINKDOWN_REASON_BAD_HEAD_DIST 17
+#define OPA_LINKDOWN_REASON_BAD_TAIL_DIST 18
+#define OPA_LINKDOWN_REASON_BAD_CTRL_DIST 19
+#define OPA_LINKDOWN_REASON_BAD_CREDIT_ACK 20
+#define OPA_LINKDOWN_REASON_UNSUPPORTED_VL_MARKER 21
+#define OPA_LINKDOWN_REASON_BAD_PREEMPT 22
+#define OPA_LINKDOWN_REASON_BAD_CONTROL_FLIT 23
+#define OPA_LINKDOWN_REASON_EXCEED_MULTICAST_LIMIT 24
+#define OPA_LINKDOWN_REASON_RCV_ERROR_24 25
+#define OPA_LINKDOWN_REASON_RCV_ERROR_25 26
+#define OPA_LINKDOWN_REASON_RCV_ERROR_26 27
+#define OPA_LINKDOWN_REASON_RCV_ERROR_27 28
+#define OPA_LINKDOWN_REASON_RCV_ERROR_28 29
+#define OPA_LINKDOWN_REASON_RCV_ERROR_29 30
+#define OPA_LINKDOWN_REASON_RCV_ERROR_30 31
+#define OPA_LINKDOWN_REASON_EXCESSIVE_BUFFER_OVERRUN 32
+#define OPA_LINKDOWN_REASON_UNKNOWN 33
+/* 34 -reserved */
+#define OPA_LINKDOWN_REASON_REBOOT 35
+#define OPA_LINKDOWN_REASON_NEIGHBOR_UNKNOWN 36
+/* 37-38 reserved */
+#define OPA_LINKDOWN_REASON_FM_BOUNCE 39
+#define OPA_LINKDOWN_REASON_SPEED_POLICY 40
+#define OPA_LINKDOWN_REASON_WIDTH_POLICY 41
+/* 42-48 reserved */
+#define OPA_LINKDOWN_REASON_DISCONNECTED 49
+#define OPA_LINKDOWN_REASON_LOCAL_MEDIA_NOT_INSTALLED 50
+#define OPA_LINKDOWN_REASON_NOT_INSTALLED 51
+#define OPA_LINKDOWN_REASON_CHASSIS_CONFIG 52
+/* 53 reserved */
+#define OPA_LINKDOWN_REASON_END_TO_END_NOT_INSTALLED 54
+/* 55 reserved */
+#define OPA_LINKDOWN_REASON_POWER_POLICY 56
+#define OPA_LINKDOWN_REASON_LINKSPEED_POLICY 57
+#define OPA_LINKDOWN_REASON_LINKWIDTH_POLICY 58
+/* 59 reserved */
+#define OPA_LINKDOWN_REASON_SWITCH_MGMT 60
+#define OPA_LINKDOWN_REASON_SMA_DISABLED 61
+/* 62 reserved */
+#define OPA_LINKDOWN_REASON_TRANSIENT 63
+/* 64-255 reserved */
+
+/* OPA Link Init reason; indicated as follows: */
+/* 3-7; 11-15 reserved; 8-15 cleared on Polling->LinkUp */
+#define OPA_LINKINIT_REASON_NOP 0
+#define OPA_LINKINIT_REASON_LINKUP (1 << 4)
+#define OPA_LINKINIT_REASON_FLAPPING (2 << 4)
+#define OPA_LINKINIT_REASON_CLEAR (8 << 4)
+#define OPA_LINKINIT_OUTSIDE_POLICY (8 << 4)
+#define OPA_LINKINIT_QUARANTINED (9 << 4)
+#define OPA_LINKINIT_INSUFIC_CAPABILITY (10 << 4)
+
+#define OPA_LINK_SPEED_NOP 0x0000 /* Reserved (1-5 Gbps) */
+#define OPA_LINK_SPEED_12_5G 0x0001 /* 12.5 Gbps */
+#define OPA_LINK_SPEED_25G 0x0002 /* 25.78125? Gbps (EDR) */
+
+#define OPA_LINK_WIDTH_1X 0x0001
+#define OPA_LINK_WIDTH_2X 0x0002
+#define OPA_LINK_WIDTH_3X 0x0004
+#define OPA_LINK_WIDTH_4X 0x0008
+
+#define OPA_CAP_MASK3_IsSnoopSupported (1 << 7)
+#define OPA_CAP_MASK3_IsAsyncSC2VLSupported (1 << 6)
+#define OPA_CAP_MASK3_IsAddrRangeConfigSupported (1 << 5)
+#define OPA_CAP_MASK3_IsPassThroughSupported (1 << 4)
+#define OPA_CAP_MASK3_IsSharedSpaceSupported (1 << 3)
+/* reserved (1 << 2) */
+#define OPA_CAP_MASK3_IsVLMarkerSupported (1 << 1)
+#define OPA_CAP_MASK3_IsVLrSupported (1 << 0)
+
+/**
+ * new MTU values
+ */
+enum {
+ OPA_MTU_8192 = 6,
+ OPA_MTU_10240 = 7,
+};
+
+enum {
+ OPA_PORT_PHYS_CONF_DISCONNECTED = 0,
+ OPA_PORT_PHYS_CONF_STANDARD = 1,
+ OPA_PORT_PHYS_CONF_FIXED = 2,
+ OPA_PORT_PHYS_CONF_VARIABLE = 3,
+ OPA_PORT_PHYS_CONF_SI_PHOTO = 4
+};
+
+enum port_info_field_masks {
+ /* vl.cap */
+ OPA_PI_MASK_VL_CAP = 0x1F,
+ /* port_states.ledenable_offlinereason */
+ OPA_PI_MASK_OFFLINE_REASON = 0x0F,
+ OPA_PI_MASK_LED_ENABLE = 0x40,
+ /* port_states.unsleepstate_downdefstate */
+ OPA_PI_MASK_UNSLEEP_STATE = 0xF0,
+ OPA_PI_MASK_DOWNDEF_STATE = 0x0F,
+ /* port_states.portphysstate_portstate */
+ OPA_PI_MASK_PORT_PHYSICAL_STATE = 0xF0,
+ OPA_PI_MASK_PORT_STATE = 0x0F,
+ /* port_phys_conf */
+ OPA_PI_MASK_PORT_PHYSICAL_CONF = 0x0F,
+ /* collectivemask_multicastmask */
+ OPA_PI_MASK_COLLECT_MASK = 0x38,
+ OPA_PI_MASK_MULTICAST_MASK = 0x07,
+ /* mkeyprotect_lmc */
+ OPA_PI_MASK_MKEY_PROT_BIT = 0xC0,
+ OPA_PI_MASK_LMC = 0x0F,
+ /* smsl */
+ OPA_PI_MASK_SMSL = 0x1F,
+ /* partenforce_filterraw */
+ /* Filter Raw In/Out bits 1 and 2 were removed */
+ OPA_PI_MASK_LINKINIT_REASON = 0xF0,
+ OPA_PI_MASK_PARTITION_ENFORCE_IN = 0x08,
+ OPA_PI_MASK_PARTITION_ENFORCE_OUT = 0x04,
+ /* operational_vls */
+ OPA_PI_MASK_OPERATIONAL_VL = 0x1F,
+ /* sa_qp */
+ OPA_PI_MASK_SA_QP = 0x00FFFFFF,
+ /* sm_trap_qp */
+ OPA_PI_MASK_SM_TRAP_QP = 0x00FFFFFF,
+ /* localphy_overrun_errors */
+ OPA_PI_MASK_LOCAL_PHY_ERRORS = 0xF0,
+ OPA_PI_MASK_OVERRUN_ERRORS = 0x0F,
+ /* clientrereg_subnettimeout */
+ OPA_PI_MASK_CLIENT_REREGISTER = 0x80,
+ OPA_PI_MASK_SUBNET_TIMEOUT = 0x1F,
+ /* port_link_mode */
+ OPA_PI_MASK_PORT_LINK_SUPPORTED = (0x001F << 10),
+ OPA_PI_MASK_PORT_LINK_ENABLED = (0x001F << 5),
+ OPA_PI_MASK_PORT_LINK_ACTIVE = (0x001F << 0),
+ /* port_link_crc_mode */
+ OPA_PI_MASK_PORT_LINK_CRC_SUPPORTED = 0x0F00,
+ OPA_PI_MASK_PORT_LINK_CRC_ENABLED = 0x00F0,
+ OPA_PI_MASK_PORT_LINK_CRC_ACTIVE = 0x000F,
+ /* port_mode */
+ OPA_PI_MASK_PORT_MODE_SECURITY_CHECK = 0x0001,
+ OPA_PI_MASK_PORT_MODE_16B_TRAP_QUERY = 0x0002,
+ OPA_PI_MASK_PORT_MODE_PKEY_CONVERT = 0x0004,
+ OPA_PI_MASK_PORT_MODE_SC2SC_MAPPING = 0x0008,
+ OPA_PI_MASK_PORT_MODE_VL_MARKER = 0x0010,
+ OPA_PI_MASK_PORT_PASS_THROUGH = 0x0020,
+ OPA_PI_MASK_PORT_ACTIVE_OPTOMIZE = 0x0040,
+ /* flit_control.interleave */
+ OPA_PI_MASK_INTERLEAVE_DIST_SUP = (0x0003 << 12),
+ OPA_PI_MASK_INTERLEAVE_DIST_ENABLE = (0x0003 << 10),
+ OPA_PI_MASK_INTERLEAVE_MAX_NEST_TX = (0x001F << 5),
+ OPA_PI_MASK_INTERLEAVE_MAX_NEST_RX = (0x001F << 0),
+
+ /* port_error_action */
+ OPA_PI_MASK_EX_BUFFER_OVERRUN = 0x80000000,
+ /* 7 bits reserved */
+ OPA_PI_MASK_FM_CFG_ERR_EXCEED_MULTICAST_LIMIT = 0x00800000,
+ OPA_PI_MASK_FM_CFG_BAD_CONTROL_FLIT = 0x00400000,
+ OPA_PI_MASK_FM_CFG_BAD_PREEMPT = 0x00200000,
+ OPA_PI_MASK_FM_CFG_UNSUPPORTED_VL_MARKER = 0x00100000,
+ OPA_PI_MASK_FM_CFG_BAD_CRDT_ACK = 0x00080000,
+ OPA_PI_MASK_FM_CFG_BAD_CTRL_DIST = 0x00040000,
+ OPA_PI_MASK_FM_CFG_BAD_TAIL_DIST = 0x00020000,
+ OPA_PI_MASK_FM_CFG_BAD_HEAD_DIST = 0x00010000,
+ /* 2 bits reserved */
+ OPA_PI_MASK_PORT_RCV_BAD_VL_MARKER = 0x00002000,
+ OPA_PI_MASK_PORT_RCV_PREEMPT_VL15 = 0x00001000,
+ OPA_PI_MASK_PORT_RCV_PREEMPT_ERROR = 0x00000800,
+ /* 1 bit reserved */
+ OPA_PI_MASK_PORT_RCV_BAD_MidTail = 0x00000200,
+ /* 1 bit reserved */
+ OPA_PI_MASK_PORT_RCV_BAD_SC = 0x00000080,
+ OPA_PI_MASK_PORT_RCV_BAD_L2 = 0x00000040,
+ OPA_PI_MASK_PORT_RCV_BAD_DLID = 0x00000020,
+ OPA_PI_MASK_PORT_RCV_BAD_SLID = 0x00000010,
+ OPA_PI_MASK_PORT_RCV_PKTLEN_TOOSHORT = 0x00000008,
+ OPA_PI_MASK_PORT_RCV_PKTLEN_TOOLONG = 0x00000004,
+ OPA_PI_MASK_PORT_RCV_BAD_PKTLEN = 0x00000002,
+ OPA_PI_MASK_PORT_RCV_BAD_LT = 0x00000001,
+
+ /* pass_through.res_drctl */
+ OPA_PI_MASK_PASS_THROUGH_DR_CONTROL = 0x01,
+
+ /* buffer_units */
+ OPA_PI_MASK_BUF_UNIT_VL15_INIT = (0x00000FFF << 11),
+ OPA_PI_MASK_BUF_UNIT_VL15_CREDIT_RATE = (0x0000001F << 6),
+ OPA_PI_MASK_BUF_UNIT_CREDIT_ACK = (0x00000003 << 3),
+ OPA_PI_MASK_BUF_UNIT_BUF_ALLOC = (0x00000003 << 0),
+
+ /* neigh_mtu.pvlx_to_mtu */
+ OPA_PI_MASK_NEIGH_MTU_PVL0 = 0xF0,
+ OPA_PI_MASK_NEIGH_MTU_PVL1 = 0x0F,
+
+ /* neigh_mtu.vlstall_hoq_life */
+ OPA_PI_MASK_VL_STALL = (0x03 << 5),
+ OPA_PI_MASK_HOQ_LIFE = (0x1F << 0),
+
+ /* port_neigh_mode */
+ OPA_PI_MASK_NEIGH_MGMT_ALLOWED = (0x01 << 3),
+ OPA_PI_MASK_NEIGH_FW_AUTH_BYPASS = (0x01 << 2),
+ OPA_PI_MASK_NEIGH_NODE_TYPE = (0x03 << 0),
+
+ /* resptime_value */
+ OPA_PI_MASK_RESPONSE_TIME_VALUE = 0x1F,
+
+ /* mtucap */
+ OPA_PI_MASK_MTU_CAP = 0x0F,
+};
+
+struct opa_port_states {
+ u8 reserved;
+ u8 ledenable_offlinereason; /* 1 res, 1 bit, 6 bits */
+ u8 reserved2;
+ u8 portphysstate_portstate; /* 4 bits, 4 bits */
+};
+
+struct opa_port_state_info {
+ struct opa_port_states port_states;
+ __be16 link_width_downgrade_tx_active;
+ __be16 link_width_downgrade_rx_active;
+};
+
+struct opa_port_info {
+ __be32 lid;
+ __be32 flow_control_mask;
+
+ struct {
+ u8 res; /* was inittype */
+ u8 cap; /* 3 res, 5 bits */
+ __be16 high_limit;
+ __be16 preempt_limit;
+ u8 arb_high_cap;
+ u8 arb_low_cap;
+ } vl;
+
+ struct opa_port_states port_states;
+ u8 port_phys_conf; /* 4 res, 4 bits */
+ u8 collectivemask_multicastmask; /* 2 res, 3, 3 */
+ u8 mkeyprotect_lmc; /* 2 bits, 2 res, 4 bits */
+ u8 smsl; /* 3 res, 5 bits */
+
+ u8 partenforce_filterraw; /* bit fields */
+ u8 operational_vls; /* 3 res, 5 bits */
+ __be16 pkey_8b;
+ __be16 pkey_10b;
+ __be16 mkey_violations;
+
+ __be16 pkey_violations;
+ __be16 qkey_violations;
+ __be32 sm_trap_qp; /* 8 bits, 24 bits */
+
+ __be32 sa_qp; /* 8 bits, 24 bits */
+ u8 neigh_port_num;
+ u8 link_down_reason;
+ u8 neigh_link_down_reason;
+ u8 clientrereg_subnettimeout; /* 1 bit, 2 bits, 5 */
+
+ struct {
+ __be16 supported;
+ __be16 enabled;
+ __be16 active;
+ } link_speed;
+ struct {
+ __be16 supported;
+ __be16 enabled;
+ __be16 active;
+ } link_width;
+ struct {
+ __be16 supported;
+ __be16 enabled;
+ __be16 tx_active;
+ __be16 rx_active;
+ } link_width_downgrade;
+ __be16 port_link_mode; /* 1 res, 5 bits, 5 bits, 5 bits */
+ __be16 port_ltp_crc_mode; /* 4 res, 4 bits, 4 bits, 4 bits */
+
+ __be16 port_mode; /* 9 res, bit fields */
+ struct {
+ __be16 supported;
+ __be16 enabled;
+ } port_packet_format;
+ struct {
+ __be16 interleave; /* 2 res, 2,2,5,5 */
+ struct {
+ __be16 min_initial;
+ __be16 min_tail;
+ u8 large_pkt_limit;
+ u8 small_pkt_limit;
+ u8 max_small_pkt_limit;
+ u8 preemption_limit;
+ } preemption;
+ } flit_control;
+
+ __be32 reserved4;
+ __be32 port_error_action; /* bit field */
+
+ struct {
+ u8 egress_port;
+ u8 res_drctl; /* 7 res, 1 */
+ } pass_through;
+ __be16 mkey_lease_period;
+ __be32 buffer_units; /* 9 res, 12, 5, 3, 3 */
+
+ __be32 reserved5;
+ __be32 sm_lid;
+
+ __be64 mkey;
+
+ __be64 subnet_prefix;
+
+ struct {
+ u8 pvlx_to_mtu[OPA_MAX_VLS/2]; /* 4 bits, 4 bits */
+ } neigh_mtu;
+
+ struct {
+ u8 vlstall_hoqlife; /* 3 bits, 5 bits */
+ } xmit_q[OPA_MAX_VLS];
+
+ struct {
+ u8 addr[16];
+ } ipaddr_ipv6;
+
+ struct {
+ u8 addr[4];
+ } ipaddr_ipv4;
+
+ u32 reserved6;
+ u32 reserved7;
+ u32 reserved8;
+
+ __be64 neigh_node_guid;
+
+ __be32 ib_cap_mask;
+ __be16 reserved9; /* was ib_cap_mask2 */
+ __be16 opa_cap_mask;
+
+ __be32 reserved10; /* was link_roundtrip_latency */
+ __be16 overall_buffer_space;
+ __be16 reserved11; /* was max_credit_hint */
+
+ __be16 diag_code;
+ struct {
+ u8 buffer;
+ u8 wire;
+ } replay_depth;
+ u8 port_neigh_mode;
+ u8 mtucap; /* 4 res, 4 bits */
+
+ u8 resptimevalue; /* 3 res, 5 bits */
+ u8 local_port_num;
+ u8 reserved12;
+ u8 reserved13; /* was guid_cap */
+} __attribute__ ((packed));
+
+#endif /* OPA_PORT_INFO_H */
diff --git a/sys/ofed/include/rdma/opa_smi.h b/sys/ofed/include/rdma/opa_smi.h
new file mode 100644
index 0000000..3c21923
--- /dev/null
+++ b/sys/ofed/include/rdma/opa_smi.h
@@ -0,0 +1,153 @@
+/*
+ * Copyright (c) 2014 Intel Corporation. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#if !defined(OPA_SMI_H)
+#define OPA_SMI_H
+
+#include <rdma/ib_mad.h>
+#include <rdma/ib_smi.h>
+
+#define OPA_SMP_LID_DATA_SIZE 2016
+#define OPA_SMP_DR_DATA_SIZE 1872
+#define OPA_SMP_MAX_PATH_HOPS 64
+
+#define OPA_MAX_VLS 32
+#define OPA_MAX_SLS 32
+#define OPA_MAX_SCS 32
+
+#define OPA_SMI_CLASS_VERSION 0x80
+
+#define OPA_LID_PERMISSIVE cpu_to_be32(0xFFFFFFFF)
+
+struct opa_smp {
+ u8 base_version;
+ u8 mgmt_class;
+ u8 class_version;
+ u8 method;
+ __be16 status;
+ u8 hop_ptr;
+ u8 hop_cnt;
+ __be64 tid;
+ __be16 attr_id;
+ __be16 resv;
+ __be32 attr_mod;
+ __be64 mkey;
+ union {
+ struct {
+ uint8_t data[OPA_SMP_LID_DATA_SIZE];
+ } lid;
+ struct {
+ __be32 dr_slid;
+ __be32 dr_dlid;
+ u8 initial_path[OPA_SMP_MAX_PATH_HOPS];
+ u8 return_path[OPA_SMP_MAX_PATH_HOPS];
+ u8 reserved[8];
+ u8 data[OPA_SMP_DR_DATA_SIZE];
+ } dr;
+ } route;
+} __packed;
+
+
+/* Subnet management attributes */
+/* ... */
+#define OPA_ATTRIB_ID_NODE_DESCRIPTION cpu_to_be16(0x0010)
+#define OPA_ATTRIB_ID_NODE_INFO cpu_to_be16(0x0011)
+#define OPA_ATTRIB_ID_PORT_INFO cpu_to_be16(0x0015)
+#define OPA_ATTRIB_ID_PARTITION_TABLE cpu_to_be16(0x0016)
+#define OPA_ATTRIB_ID_SL_TO_SC_MAP cpu_to_be16(0x0017)
+#define OPA_ATTRIB_ID_VL_ARBITRATION cpu_to_be16(0x0018)
+#define OPA_ATTRIB_ID_SM_INFO cpu_to_be16(0x0020)
+#define OPA_ATTRIB_ID_CABLE_INFO cpu_to_be16(0x0032)
+#define OPA_ATTRIB_ID_AGGREGATE cpu_to_be16(0x0080)
+#define OPA_ATTRIB_ID_SC_TO_SL_MAP cpu_to_be16(0x0082)
+#define OPA_ATTRIB_ID_SC_TO_VLR_MAP cpu_to_be16(0x0083)
+#define OPA_ATTRIB_ID_SC_TO_VLT_MAP cpu_to_be16(0x0084)
+#define OPA_ATTRIB_ID_SC_TO_VLNT_MAP cpu_to_be16(0x0085)
+/* ... */
+#define OPA_ATTRIB_ID_PORT_STATE_INFO cpu_to_be16(0x0087)
+/* ... */
+#define OPA_ATTRIB_ID_BUFFER_CONTROL_TABLE cpu_to_be16(0x008A)
+/* ... */
+
+struct opa_node_description {
+ u8 data[64];
+} __attribute__ ((packed));
+
+struct opa_node_info {
+ u8 base_version;
+ u8 class_version;
+ u8 node_type;
+ u8 num_ports;
+ __be32 reserved;
+ __be64 system_image_guid;
+ __be64 node_guid;
+ __be64 port_guid;
+ __be16 partition_cap;
+ __be16 device_id;
+ __be32 revision;
+ u8 local_port_num;
+ u8 vendor_id[3]; /* network byte order */
+} __attribute__ ((packed));
+
+#define OPA_PARTITION_TABLE_BLK_SIZE 32
+
+static inline u8
+opa_get_smp_direction(const struct opa_smp *smp)
+{
+ return ib_get_smp_direction((const struct ib_smp *)smp);
+}
+
+static inline u8 *opa_get_smp_data(struct opa_smp *smp)
+{
+ if (smp->mgmt_class == IB_MGMT_CLASS_SUBN_DIRECTED_ROUTE)
+ return smp->route.dr.data;
+
+ return smp->route.lid.data;
+}
+
+static inline size_t opa_get_smp_data_size(const struct opa_smp *smp)
+{
+ if (smp->mgmt_class == IB_MGMT_CLASS_SUBN_DIRECTED_ROUTE)
+ return sizeof(smp->route.dr.data);
+
+ return sizeof(smp->route.lid.data);
+}
+
+static inline size_t opa_get_smp_header_size(const struct opa_smp *smp)
+{
+ if (smp->mgmt_class == IB_MGMT_CLASS_SUBN_DIRECTED_ROUTE)
+ return sizeof(*smp) - sizeof(smp->route.dr.data);
+
+ return sizeof(*smp) - sizeof(smp->route.lid.data);
+}
+
+#endif /* OPA_SMI_H */
diff --git a/sys/ofed/include/rdma/peer_mem.h b/sys/ofed/include/rdma/peer_mem.h
deleted file mode 100644
index 8565883..0000000
--- a/sys/ofed/include/rdma/peer_mem.h
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * Copyright (c) 2013, Mellanox Technologies. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-#if !defined(PEER_MEM_H)
-#define PEER_MEM_H
-
-#include <linux/module.h>
-#include <linux/slab.h>
-#include <linux/errno.h>
-#include <linux/scatterlist.h>
-#include <linux/mutex.h>
-
-
-#define IB_PEER_MEMORY_NAME_MAX 64
-#define IB_PEER_MEMORY_VER_MAX 16
-
-struct peer_memory_client {
- char name[IB_PEER_MEMORY_NAME_MAX];
- char version[IB_PEER_MEMORY_VER_MAX];
- /* acquire return code: 1 mine, 0 - not mine */
- int (*acquire) (unsigned long addr, size_t size, void *peer_mem_private_data,
- char *peer_mem_name, void **client_context);
- int (*get_pages) (unsigned long addr,
- size_t size, int write, int force,
- struct sg_table *sg_head,
- void *client_context, void *core_context);
- int (*dma_map) (struct sg_table *sg_head, void *client_context,
- struct device *dma_device, int dmasync, int *nmap);
- int (*dma_unmap) (struct sg_table *sg_head, void *client_context,
- struct device *dma_device);
- void (*put_pages) (struct sg_table *sg_head, void *client_context);
- unsigned long (*get_page_size) (void *client_context);
- void (*release) (void *client_context);
-
-};
-
-typedef int (*invalidate_peer_memory)(void *reg_handle,
- void *core_context);
-
-void *ib_register_peer_memory_client(struct peer_memory_client *peer_client,
- invalidate_peer_memory *invalidate_callback);
-void ib_unregister_peer_memory_client(void *reg_handle);
-
-#endif
diff --git a/sys/ofed/include/rdma/rdma_cm.h b/sys/ofed/include/rdma/rdma_cm.h
index 33be957..7fee12c 100644
--- a/sys/ofed/include/rdma/rdma_cm.h
+++ b/sys/ofed/include/rdma/rdma_cm.h
@@ -1,7 +1,6 @@
/*
* Copyright (c) 2005 Voltaire Inc. All rights reserved.
* Copyright (c) 2005 Intel Corporation. All rights reserved.
- * Copyright (c) 2016 Chelsio Communications. All rights reserved.
*
* This software is available to you under a choice of one of two
* licenses. You may choose to be licensed under the terms of the GNU
@@ -60,13 +59,11 @@ enum rdma_cm_event_type {
RDMA_CM_EVENT_MULTICAST_JOIN,
RDMA_CM_EVENT_MULTICAST_ERROR,
RDMA_CM_EVENT_ADDR_CHANGE,
- RDMA_CM_EVENT_TIMEWAIT_EXIT,
- RDMA_CM_EVENT_ALT_ROUTE_RESOLVED,
- RDMA_CM_EVENT_ALT_ROUTE_ERROR,
- RDMA_CM_EVENT_LOAD_ALT_PATH,
- RDMA_CM_EVENT_ALT_PATH_LOADED,
+ RDMA_CM_EVENT_TIMEWAIT_EXIT
};
+const char *__attribute_const__ rdma_event_msg(enum rdma_cm_event_type event);
+
enum rdma_port_space {
RDMA_PS_SDP = 0x0001,
RDMA_PS_IPOIB = 0x0002,
@@ -75,12 +72,10 @@ enum rdma_port_space {
RDMA_PS_UDP = 0x0111,
};
-enum alt_path_type {
- RDMA_ALT_PATH_NONE,
- RDMA_ALT_PATH_PORT,
- RDMA_ALT_PATH_LID,
- RDMA_ALT_PATH_BEST
-};
+#define RDMA_IB_IP_PS_MASK 0xFFFFFFFFFFFF0000ULL
+#define RDMA_IB_IP_PS_TCP 0x0000000001060000ULL
+#define RDMA_IB_IP_PS_UDP 0x0000000001110000ULL
+#define RDMA_IB_IP_PS_IB 0x00000000013F0000ULL
struct rdma_addr {
struct sockaddr_storage src_addr;
@@ -105,6 +100,7 @@ struct rdma_conn_param {
/* Fields below ignored if a QP is created on the rdma_cm_id. */
u8 srq;
u32 qp_num;
+ u32 qkey;
};
struct rdma_ud_param {
@@ -113,7 +109,6 @@ struct rdma_ud_param {
struct ib_ah_attr ah_attr;
u32 qp_num;
u32 qkey;
- u8 alt_path_index;
};
struct rdma_cm_event {
@@ -160,19 +155,22 @@ struct rdma_cm_id {
enum rdma_port_space ps;
enum ib_qp_type qp_type;
u8 port_num;
- void *ucontext;
};
/**
* rdma_create_id - Create an RDMA identifier.
*
+ * @net: The network namespace in which to create the new id.
* @event_handler: User callback invoked to report events associated with the
* returned rdma_id.
* @context: User specified context associated with the id.
* @ps: RDMA port space.
* @qp_type: type of queue pair associated with the id.
+ *
+ * The id holds a reference on the network namespace until it is destroyed.
*/
-struct rdma_cm_id *rdma_create_id(rdma_cm_event_handler event_handler,
+struct rdma_cm_id *rdma_create_id(struct vnet *net,
+ rdma_cm_event_handler event_handler,
void *context, enum rdma_port_space ps,
enum ib_qp_type qp_type);
@@ -223,19 +221,6 @@ int rdma_resolve_addr(struct rdma_cm_id *id, struct sockaddr *src_addr,
int rdma_resolve_route(struct rdma_cm_id *id, int timeout_ms);
/**
- * rdma_enable_apm - Get ready to use APM for the given ID.
- * Actual Alternate path discovery and load will take place only
- * after a connection has been established.
- *
- * Calling this function only has an effect on the connection's client side.
- * It should be called after rdma_resolve_route and before rdma_connect.
- *
- * @id: RDMA identifier.
- * @alt_type: Alternate path type to resolve.
- */
-int rdma_enable_apm(struct rdma_cm_id *id, enum alt_path_type alt_type);
-
-/**
* rdma_create_qp - Allocate a QP and associate it with the specified RDMA
* identifier.
*
@@ -348,11 +333,13 @@ int rdma_disconnect(struct rdma_cm_id *id);
* address.
* @id: Communication identifier associated with the request.
* @addr: Multicast address identifying the group to join.
+ * @join_state: Multicast JoinState bitmap requested by port.
+ * Bitmap is based on IB_SA_MCMEMBER_REC_JOIN_STATE bits.
* @context: User-defined context associated with the join request, returned
* to the user through the private_data pointer in multicast events.
*/
int rdma_join_multicast(struct rdma_cm_id *id, struct sockaddr *addr,
- void *context);
+ u8 join_state, void *context);
/**
* rdma_leave_multicast - Leave the multicast group specified by the given
@@ -394,14 +381,11 @@ int rdma_set_reuseaddr(struct rdma_cm_id *id, int reuse);
*/
int rdma_set_afonly(struct rdma_cm_id *id, int afonly);
-/**
- * rdma_set_timeout - Set the QP timeout associated with a connection
- * identifier.
- * @id: Communication identifier to associated with service type.
- * @timeout: QP timeout
+ /**
+ * rdma_get_service_id - Return the IB service ID for a specified address.
+ * @id: Communication identifier associated with the address.
+ * @addr: Address for the service ID.
*/
-void rdma_set_timeout(struct rdma_cm_id *id, int timeout);
-int rdma_cma_any_addr(struct sockaddr *addr);
-int rdma_find_cmid_laddr(struct sockaddr_in *local_addr,
- unsigned short dev_type, void **cm_id);
+__be64 rdma_get_service_id(struct rdma_cm_id *id, struct sockaddr *addr);
+
#endif /* RDMA_CM_H */
diff --git a/sys/ofed/include/rdma/rdma_user_cm.h b/sys/ofed/include/rdma/rdma_user_cm.h
deleted file mode 100644
index 4d99099..0000000
--- a/sys/ofed/include/rdma/rdma_user_cm.h
+++ /dev/null
@@ -1,251 +0,0 @@
-/*
- * Copyright (c) 2005-2006 Intel Corporation. All rights reserved.
- *
- * This software is available to you under a choice of one of two
- * licenses. You may choose to be licensed under the terms of the GNU
- * General Public License (GPL) Version 2, available from the file
- * COPYING in the main directory of this source tree, or the
- * OpenIB.org BSD license below:
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the following
- * disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-#ifndef RDMA_USER_CM_H
-#define RDMA_USER_CM_H
-
-#include <linux/types.h>
-#include <linux/in6.h>
-#include <rdma/ib_user_verbs.h>
-#include <rdma/ib_user_sa.h>
-
-#define RDMA_USER_CM_ABI_VERSION 4
-
-#define RDMA_MAX_PRIVATE_DATA 256
-
-enum {
- RDMA_USER_CM_CMD_CREATE_ID,
- RDMA_USER_CM_CMD_DESTROY_ID,
- RDMA_USER_CM_CMD_BIND_ADDR,
- RDMA_USER_CM_CMD_RESOLVE_ADDR,
- RDMA_USER_CM_CMD_RESOLVE_ROUTE,
- RDMA_USER_CM_CMD_QUERY_ROUTE,
- RDMA_USER_CM_CMD_CONNECT,
- RDMA_USER_CM_CMD_LISTEN,
- RDMA_USER_CM_CMD_ACCEPT,
- RDMA_USER_CM_CMD_REJECT,
- RDMA_USER_CM_CMD_DISCONNECT,
- RDMA_USER_CM_CMD_INIT_QP_ATTR,
- RDMA_USER_CM_CMD_GET_EVENT,
- RDMA_USER_CM_CMD_GET_OPTION,
- RDMA_USER_CM_CMD_SET_OPTION,
- RDMA_USER_CM_CMD_NOTIFY,
- RDMA_USER_CM_CMD_JOIN_MCAST,
- RDMA_USER_CM_CMD_LEAVE_MCAST,
- RDMA_USER_CM_CMD_MIGRATE_ID
-};
-
-/*
- * command ABI structures.
- */
-struct rdma_ucm_cmd_hdr {
- __u32 cmd;
- __u16 in;
- __u16 out;
-};
-
-struct rdma_ucm_create_id {
- __u64 uid;
- __u64 response;
- __u16 ps;
- __u8 qp_type;
- __u8 reserved[5];
-};
-
-struct rdma_ucm_create_id_resp {
- __u32 id;
-};
-
-struct rdma_ucm_destroy_id {
- __u64 response;
- __u32 id;
- __u32 reserved;
-};
-
-struct rdma_ucm_destroy_id_resp {
- __u32 events_reported;
-};
-
-struct rdma_ucm_bind_addr {
- __u64 response;
- struct sockaddr_in6 addr;
- __u32 id;
-};
-
-struct rdma_ucm_resolve_addr {
- struct sockaddr_in6 src_addr;
- struct sockaddr_in6 dst_addr;
- __u32 id;
- __u32 timeout_ms;
-};
-
-struct rdma_ucm_resolve_route {
- __u32 id;
- __u32 timeout_ms;
-};
-
-struct rdma_ucm_query_route {
- __u64 response;
- __u32 id;
- __u32 reserved;
-};
-
-struct rdma_ucm_query_route_resp {
- __u64 node_guid;
- struct ib_user_path_rec ib_route[2];
- struct sockaddr_in6 src_addr;
- struct sockaddr_in6 dst_addr;
- __u32 num_paths;
- __u8 port_num;
- __u8 reserved[3];
-};
-
-struct rdma_ucm_conn_param {
- __u32 qp_num;
- __u32 reserved;
- __u8 private_data[RDMA_MAX_PRIVATE_DATA];
- __u8 private_data_len;
- __u8 srq;
- __u8 responder_resources;
- __u8 initiator_depth;
- __u8 flow_control;
- __u8 retry_count;
- __u8 rnr_retry_count;
- __u8 valid;
-};
-
-struct rdma_ucm_ud_param {
- __u32 qp_num;
- __u32 qkey;
- struct ib_uverbs_ah_attr ah_attr;
- __u8 private_data[RDMA_MAX_PRIVATE_DATA];
- __u8 private_data_len;
- __u8 reserved[7];
-};
-
-struct rdma_ucm_connect {
- struct rdma_ucm_conn_param conn_param;
- __u32 id;
- __u32 reserved;
-};
-
-struct rdma_ucm_listen {
- __u32 id;
- __u32 backlog;
-};
-
-struct rdma_ucm_accept {
- __u64 uid;
- struct rdma_ucm_conn_param conn_param;
- __u32 id;
- __u32 reserved;
-};
-
-struct rdma_ucm_reject {
- __u32 id;
- __u8 private_data_len;
- __u8 reserved[3];
- __u8 private_data[RDMA_MAX_PRIVATE_DATA];
-};
-
-struct rdma_ucm_disconnect {
- __u32 id;
-};
-
-struct rdma_ucm_init_qp_attr {
- __u64 response;
- __u32 id;
- __u32 qp_state;
-};
-
-struct rdma_ucm_notify {
- __u32 id;
- __u32 event;
-};
-
-struct rdma_ucm_join_mcast {
- __u64 response; /* rdma_ucm_create_id_resp */
- __u64 uid;
- struct sockaddr_in6 addr;
- __u32 id;
-};
-
-struct rdma_ucm_get_event {
- __u64 response;
-};
-
-struct rdma_ucm_event_resp {
- __u64 uid;
- __u32 id;
- __u32 event;
- __u32 status;
- union {
- struct rdma_ucm_conn_param conn;
- struct rdma_ucm_ud_param ud;
- } param;
-};
-
-/* Option levels */
-enum {
- RDMA_OPTION_ID = 0,
- RDMA_OPTION_IB = 1
-};
-
-/* Option details */
-enum {
- RDMA_OPTION_ID_TOS = 0,
- RDMA_OPTION_ID_REUSEADDR = 1,
- RDMA_OPTION_ID_AFONLY = 2,
-
- RDMA_OPTION_IB_PATH = 1,
- RDMA_OPTION_IB_APM = 2,
-};
-
-struct rdma_ucm_set_option {
- __u64 optval;
- __u32 id;
- __u32 level;
- __u32 optname;
- __u32 optlen;
-};
-
-struct rdma_ucm_migrate_id {
- __u64 response;
- __u32 id;
- __u32 fd;
-};
-
-struct rdma_ucm_migrate_resp {
- __u32 events_reported;
-};
-
-#endif /* RDMA_USER_CM_H */
diff --git a/sys/ofed/include/rdma/rdma_vt.h b/sys/ofed/include/rdma/rdma_vt.h
new file mode 100644
index 0000000..e315021
--- /dev/null
+++ b/sys/ofed/include/rdma/rdma_vt.h
@@ -0,0 +1,500 @@
+#ifndef DEF_RDMA_VT_H
+#define DEF_RDMA_VT_H
+
+/*
+ * Copyright(c) 2016 Intel Corporation.
+ *
+ * This file is provided under a dual BSD/GPLv2 license. When using or
+ * redistributing this file, you may do so under either license.
+ *
+ * GPL LICENSE SUMMARY
+ *
+ * This program 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.
+ *
+ * This program 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.
+ *
+ * BSD LICENSE
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * - Neither the name of Intel Corporation nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+
+/*
+ * Structure that low level drivers will populate in order to register with the
+ * rdmavt layer.
+ */
+
+#include <linux/spinlock.h>
+#include <linux/list.h>
+#include <linux/hash.h>
+#include <rdma/ib_verbs.h>
+#include <rdma/rdmavt_mr.h>
+#include <rdma/rdmavt_qp.h>
+
+#define RVT_MAX_PKEY_VALUES 16
+
+struct rvt_ibport {
+ struct rvt_qp __rcu *qp[2];
+ struct ib_mad_agent *send_agent; /* agent for SMI (traps) */
+ struct rb_root mcast_tree;
+ spinlock_t lock; /* protect changes in this struct */
+
+ /* non-zero when timer is set */
+ unsigned long mkey_lease_timeout;
+ unsigned long trap_timeout;
+ __be64 gid_prefix; /* in network order */
+ __be64 mkey;
+ u64 tid;
+ u32 port_cap_flags;
+ u32 pma_sample_start;
+ u32 pma_sample_interval;
+ __be16 pma_counter_select[5];
+ u16 pma_tag;
+ u16 mkey_lease_period;
+ u16 sm_lid;
+ u8 sm_sl;
+ u8 mkeyprot;
+ u8 subnet_timeout;
+ u8 vl_high_limit;
+
+ /*
+ * Driver is expected to keep these up to date. These
+ * counters are informational only and not required to be
+ * completely accurate.
+ */
+ u64 n_rc_resends;
+ u64 n_seq_naks;
+ u64 n_rdma_seq;
+ u64 n_rnr_naks;
+ u64 n_other_naks;
+ u64 n_loop_pkts;
+ u64 n_pkt_drops;
+ u64 n_vl15_dropped;
+ u64 n_rc_timeouts;
+ u64 n_dmawait;
+ u64 n_unaligned;
+ u64 n_rc_dupreq;
+ u64 n_rc_seqnak;
+ u16 pkey_violations;
+ u16 qkey_violations;
+ u16 mkey_violations;
+
+ /* Hot-path per CPU counters to avoid cacheline trading to update */
+ u64 z_rc_acks;
+ u64 z_rc_qacks;
+ u64 z_rc_delayed_comp;
+ u64 __percpu *rc_acks;
+ u64 __percpu *rc_qacks;
+ u64 __percpu *rc_delayed_comp;
+
+ void *priv; /* driver private data */
+
+ /*
+ * The pkey table is allocated and maintained by the driver. Drivers
+ * need to have access to this before registering with rdmav. However
+ * rdmavt will need access to it so drivers need to proviee this during
+ * the attach port API call.
+ */
+ u16 *pkey_table;
+
+ struct rvt_ah *sm_ah;
+};
+
+#define RVT_CQN_MAX 16 /* maximum length of cq name */
+
+/*
+ * Things that are driver specific, module parameters in hfi1 and qib
+ */
+struct rvt_driver_params {
+ struct ib_device_attr props;
+
+ /*
+ * Anything driver specific that is not covered by props
+ * For instance special module parameters. Goes here.
+ */
+ unsigned int lkey_table_size;
+ unsigned int qp_table_size;
+ int qpn_start;
+ int qpn_inc;
+ int qpn_res_start;
+ int qpn_res_end;
+ int nports;
+ int npkeys;
+ char cq_name[RVT_CQN_MAX];
+ int node;
+ int psn_mask;
+ int psn_shift;
+ int psn_modify_mask;
+ u32 core_cap_flags;
+ u32 max_mad_size;
+ u8 qos_shift;
+ u8 max_rdma_atomic;
+ u8 reserved_operations;
+};
+
+/* Protection domain */
+struct rvt_pd {
+ struct ib_pd ibpd;
+ int user; /* non-zero if created from user space */
+};
+
+/* Address handle */
+struct rvt_ah {
+ struct ib_ah ibah;
+ struct ib_ah_attr attr;
+ atomic_t refcount;
+ u8 vl;
+ u8 log_pmtu;
+};
+
+struct rvt_dev_info;
+struct rvt_swqe;
+struct rvt_driver_provided {
+ /*
+ * Which functions are required depends on which verbs rdmavt is
+ * providing and which verbs the driver is overriding. See
+ * check_support() for details.
+ */
+
+ /* Passed to ib core registration. Callback to create syfs files */
+ int (*port_callback)(struct ib_device *, u8, struct kobject *);
+
+ /*
+ * Returns a string to represent the device for which is being
+ * registered. This is primarily used for error and debug messages on
+ * the console.
+ */
+ const char * (*get_card_name)(struct rvt_dev_info *rdi);
+
+ /*
+ * Returns a pointer to the undelying hardware's PCI device. This is
+ * used to display information as to what hardware is being referenced
+ * in an output message
+ */
+ struct pci_dev * (*get_pci_dev)(struct rvt_dev_info *rdi);
+
+ /*
+ * Allocate a private queue pair data structure for driver specific
+ * information which is opaque to rdmavt. Errors are returned via
+ * ERR_PTR(err). The driver is free to return NULL or a valid
+ * pointer.
+ */
+ void * (*qp_priv_alloc)(struct rvt_dev_info *rdi, struct rvt_qp *qp,
+ gfp_t gfp);
+
+ /*
+ * Free the driver's private qp structure.
+ */
+ void (*qp_priv_free)(struct rvt_dev_info *rdi, struct rvt_qp *qp);
+
+ /*
+ * Inform the driver the particular qp in quesiton has been reset so
+ * that it can clean up anything it needs to.
+ */
+ void (*notify_qp_reset)(struct rvt_qp *qp);
+
+ /*
+ * Give the driver a notice that there is send work to do. It is up to
+ * the driver to generally push the packets out, this just queues the
+ * work with the driver. There are two variants here. The no_lock
+ * version requires the s_lock not to be held. The other assumes the
+ * s_lock is held.
+ */
+ void (*schedule_send)(struct rvt_qp *qp);
+ void (*schedule_send_no_lock)(struct rvt_qp *qp);
+
+ /*
+ * Sometimes rdmavt needs to kick the driver's send progress. That is
+ * done by this call back.
+ */
+ void (*do_send)(struct rvt_qp *qp);
+
+ /*
+ * Get a path mtu from the driver based on qp attributes.
+ */
+ int (*get_pmtu_from_attr)(struct rvt_dev_info *rdi, struct rvt_qp *qp,
+ struct ib_qp_attr *attr);
+
+ /*
+ * Notify driver that it needs to flush any outstanding IO requests that
+ * are waiting on a qp.
+ */
+ void (*flush_qp_waiters)(struct rvt_qp *qp);
+
+ /*
+ * Notify driver to stop its queue of sending packets. Nothing else
+ * should be posted to the queue pair after this has been called.
+ */
+ void (*stop_send_queue)(struct rvt_qp *qp);
+
+ /*
+ * Have the drivr drain any in progress operations
+ */
+ void (*quiesce_qp)(struct rvt_qp *qp);
+
+ /*
+ * Inform the driver a qp has went to error state.
+ */
+ void (*notify_error_qp)(struct rvt_qp *qp);
+
+ /*
+ * Get an MTU for a qp.
+ */
+ u32 (*mtu_from_qp)(struct rvt_dev_info *rdi, struct rvt_qp *qp,
+ u32 pmtu);
+ /*
+ * Convert an mtu to a path mtu
+ */
+ int (*mtu_to_path_mtu)(u32 mtu);
+
+ /*
+ * Get the guid of a port in big endian byte order
+ */
+ int (*get_guid_be)(struct rvt_dev_info *rdi, struct rvt_ibport *rvp,
+ int guid_index, __be64 *guid);
+
+ /*
+ * Query driver for the state of the port.
+ */
+ int (*query_port_state)(struct rvt_dev_info *rdi, u8 port_num,
+ struct ib_port_attr *props);
+
+ /*
+ * Tell driver to shutdown a port
+ */
+ int (*shut_down_port)(struct rvt_dev_info *rdi, u8 port_num);
+
+ /* Tell driver to send a trap for changed port capabilities */
+ void (*cap_mask_chg)(struct rvt_dev_info *rdi, u8 port_num);
+
+ /*
+ * The following functions can be safely ignored completely. Any use of
+ * these is checked for NULL before blindly calling. Rdmavt should also
+ * be functional if drivers omit these.
+ */
+
+ /* Called to inform the driver that all qps should now be freed. */
+ unsigned (*free_all_qps)(struct rvt_dev_info *rdi);
+
+ /* Driver specific AH validation */
+ int (*check_ah)(struct ib_device *, struct ib_ah_attr *);
+
+ /* Inform the driver a new AH has been created */
+ void (*notify_new_ah)(struct ib_device *, struct ib_ah_attr *,
+ struct rvt_ah *);
+
+ /* Let the driver pick the next queue pair number*/
+ int (*alloc_qpn)(struct rvt_dev_info *rdi, struct rvt_qpn_table *qpt,
+ enum ib_qp_type type, u8 port_num, gfp_t gfp);
+
+ /* Determine if its safe or allowed to modify the qp */
+ int (*check_modify_qp)(struct rvt_qp *qp, struct ib_qp_attr *attr,
+ int attr_mask, struct ib_udata *udata);
+
+ /* Driver specific QP modification/notification-of */
+ void (*modify_qp)(struct rvt_qp *qp, struct ib_qp_attr *attr,
+ int attr_mask, struct ib_udata *udata);
+
+ /* Driver specific work request checking */
+ int (*check_send_wqe)(struct rvt_qp *qp, struct rvt_swqe *wqe);
+
+ /* Notify driver a mad agent has been created */
+ void (*notify_create_mad_agent)(struct rvt_dev_info *rdi, int port_idx);
+
+ /* Notify driver a mad agent has been removed */
+ void (*notify_free_mad_agent)(struct rvt_dev_info *rdi, int port_idx);
+
+};
+
+struct rvt_dev_info {
+ struct ib_device ibdev; /* Keep this first. Nothing above here */
+
+ /*
+ * Prior to calling for registration the driver will be responsible for
+ * allocating space for this structure.
+ *
+ * The driver will also be responsible for filling in certain members of
+ * dparms.props. The driver needs to fill in dparms exactly as it would
+ * want values reported to a ULP. This will be returned to the caller
+ * in rdmavt's device. The driver should also therefore refrain from
+ * modifying this directly after registration with rdmavt.
+ */
+
+ /* Driver specific properties */
+ struct rvt_driver_params dparms;
+
+ /* post send table */
+ const struct rvt_operation_params *post_parms;
+
+ struct rvt_mregion __rcu *dma_mr;
+ struct rvt_lkey_table lkey_table;
+
+ /* Driver specific helper functions */
+ struct rvt_driver_provided driver_f;
+
+ /* Internal use */
+ int n_pds_allocated;
+ spinlock_t n_pds_lock; /* Protect pd allocated count */
+
+ int n_ahs_allocated;
+ spinlock_t n_ahs_lock; /* Protect ah allocated count */
+
+ u32 n_srqs_allocated;
+ spinlock_t n_srqs_lock; /* Protect srqs allocated count */
+
+ int flags;
+ struct rvt_ibport **ports;
+
+ /* QP */
+ struct rvt_qp_ibdev *qp_dev;
+ u32 n_qps_allocated; /* number of QPs allocated for device */
+ u32 n_rc_qps; /* number of RC QPs allocated for device */
+ u32 busy_jiffies; /* timeout scaling based on RC QP count */
+ spinlock_t n_qps_lock; /* protect qps, rc qps and busy jiffy counts */
+
+ /* memory maps */
+ struct list_head pending_mmaps;
+ spinlock_t mmap_offset_lock; /* protect mmap_offset */
+ u32 mmap_offset;
+ spinlock_t pending_lock; /* protect pending mmap list */
+
+ /* CQ */
+ struct kthread_worker *worker; /* per device cq worker */
+ u32 n_cqs_allocated; /* number of CQs allocated for device */
+ spinlock_t n_cqs_lock; /* protect count of in use cqs */
+
+ /* Multicast */
+ u32 n_mcast_grps_allocated; /* number of mcast groups allocated */
+ spinlock_t n_mcast_grps_lock;
+
+};
+
+static inline struct rvt_pd *ibpd_to_rvtpd(struct ib_pd *ibpd)
+{
+ return container_of(ibpd, struct rvt_pd, ibpd);
+}
+
+static inline struct rvt_ah *ibah_to_rvtah(struct ib_ah *ibah)
+{
+ return container_of(ibah, struct rvt_ah, ibah);
+}
+
+static inline struct rvt_dev_info *ib_to_rvt(struct ib_device *ibdev)
+{
+ return container_of(ibdev, struct rvt_dev_info, ibdev);
+}
+
+static inline struct rvt_srq *ibsrq_to_rvtsrq(struct ib_srq *ibsrq)
+{
+ return container_of(ibsrq, struct rvt_srq, ibsrq);
+}
+
+static inline struct rvt_qp *ibqp_to_rvtqp(struct ib_qp *ibqp)
+{
+ return container_of(ibqp, struct rvt_qp, ibqp);
+}
+
+static inline unsigned rvt_get_npkeys(struct rvt_dev_info *rdi)
+{
+ /*
+ * All ports have same number of pkeys.
+ */
+ return rdi->dparms.npkeys;
+}
+
+/*
+ * Return the max atomic suitable for determining
+ * the size of the ack ring buffer in a QP.
+ */
+static inline unsigned int rvt_max_atomic(struct rvt_dev_info *rdi)
+{
+ return rdi->dparms.max_rdma_atomic + 1;
+}
+
+/*
+ * Return the indexed PKEY from the port PKEY table.
+ */
+static inline u16 rvt_get_pkey(struct rvt_dev_info *rdi,
+ int port_index,
+ unsigned index)
+{
+ if (index >= rvt_get_npkeys(rdi))
+ return 0;
+ else
+ return rdi->ports[port_index]->pkey_table[index];
+}
+
+/**
+ * rvt_lookup_qpn - return the QP with the given QPN
+ * @ibp: the ibport
+ * @qpn: the QP number to look up
+ *
+ * The caller must hold the rcu_read_lock(), and keep the lock until
+ * the returned qp is no longer in use.
+ */
+/* TODO: Remove this and put in rdmavt/qp.h when no longer needed by drivers */
+static inline struct rvt_qp *rvt_lookup_qpn(struct rvt_dev_info *rdi,
+ struct rvt_ibport *rvp,
+ u32 qpn) __must_hold(RCU)
+{
+ struct rvt_qp *qp = NULL;
+
+ if (unlikely(qpn <= 1)) {
+ qp = rcu_dereference(rvp->qp[qpn]);
+ } else {
+ u32 n = hash_32(qpn, rdi->qp_dev->qp_table_bits);
+
+ for (qp = rcu_dereference(rdi->qp_dev->qp_table[n]); qp;
+ qp = rcu_dereference(qp->next))
+ if (qp->ibqp.qp_num == qpn)
+ break;
+ }
+ return qp;
+}
+
+struct rvt_dev_info *rvt_alloc_device(size_t size, int nports);
+void rvt_dealloc_device(struct rvt_dev_info *rdi);
+int rvt_register_device(struct rvt_dev_info *rvd);
+void rvt_unregister_device(struct rvt_dev_info *rvd);
+int rvt_check_ah(struct ib_device *ibdev, struct ib_ah_attr *ah_attr);
+int rvt_init_port(struct rvt_dev_info *rdi, struct rvt_ibport *port,
+ int port_index, u16 *pkey_table);
+int rvt_fast_reg_mr(struct rvt_qp *qp, struct ib_mr *ibmr, u32 key,
+ int access);
+int rvt_invalidate_rkey(struct rvt_qp *qp, u32 rkey);
+int rvt_rkey_ok(struct rvt_qp *qp, struct rvt_sge *sge,
+ u32 len, u64 vaddr, u32 rkey, int acc);
+int rvt_lkey_ok(struct rvt_lkey_table *rkt, struct rvt_pd *pd,
+ struct rvt_sge *isge, struct ib_sge *sge, int acc);
+struct rvt_mcast *rvt_mcast_find(struct rvt_ibport *ibp, union ib_gid *mgid);
+
+#endif /* DEF_RDMA_VT_H */
diff --git a/sys/ofed/include/rdma/rdmavt_cq.h b/sys/ofed/include/rdma/rdmavt_cq.h
new file mode 100644
index 0000000..51fd00b
--- /dev/null
+++ b/sys/ofed/include/rdma/rdmavt_cq.h
@@ -0,0 +1,99 @@
+#ifndef DEF_RDMAVT_INCCQ_H
+#define DEF_RDMAVT_INCCQ_H
+
+/*
+ *
+ * This file is provided under a dual BSD/GPLv2 license. When using or
+ * redistributing this file, you may do so under either license.
+ *
+ * GPL LICENSE SUMMARY
+ *
+ * Copyright(c) 2016 Intel Corporation.
+ *
+ * This program 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.
+ *
+ * This program 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.
+ *
+ * BSD LICENSE
+ *
+ * Copyright(c) 2015 Intel Corporation.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * - Neither the name of Intel Corporation nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+
+#include <linux/kthread.h>
+#include <rdma/ib_user_verbs.h>
+
+/*
+ * Define an ib_cq_notify value that is not valid so we know when CQ
+ * notifications are armed.
+ */
+#define RVT_CQ_NONE (IB_CQ_NEXT_COMP + 1)
+
+/*
+ * This structure is used to contain the head pointer, tail pointer,
+ * and completion queue entries as a single memory allocation so
+ * it can be mmap'ed into user space.
+ */
+struct rvt_cq_wc {
+ u32 head; /* index of next entry to fill */
+ u32 tail; /* index of next ib_poll_cq() entry */
+ union {
+ /* these are actually size ibcq.cqe + 1 */
+ struct ib_uverbs_wc uqueue[0];
+ struct ib_wc kqueue[0];
+ };
+};
+
+/*
+ * The completion queue structure.
+ */
+struct rvt_cq {
+ struct ib_cq ibcq;
+ struct kthread_work comptask;
+ spinlock_t lock; /* protect changes in this struct */
+ u8 notify;
+ u8 triggered;
+ struct rvt_dev_info *rdi;
+ struct rvt_cq_wc *queue;
+ struct rvt_mmap_info *ip;
+};
+
+static inline struct rvt_cq *ibcq_to_rvtcq(struct ib_cq *ibcq)
+{
+ return container_of(ibcq, struct rvt_cq, ibcq);
+}
+
+void rvt_cq_enter(struct rvt_cq *cq, struct ib_wc *entry, bool solicited);
+
+#endif /* DEF_RDMAVT_INCCQH */
diff --git a/sys/ofed/include/rdma/rdmavt_mr.h b/sys/ofed/include/rdma/rdmavt_mr.h
new file mode 100644
index 0000000..6b3c6c8
--- /dev/null
+++ b/sys/ofed/include/rdma/rdmavt_mr.h
@@ -0,0 +1,140 @@
+#ifndef DEF_RDMAVT_INCMR_H
+#define DEF_RDMAVT_INCMR_H
+
+/*
+ * Copyright(c) 2016 Intel Corporation.
+ *
+ * This file is provided under a dual BSD/GPLv2 license. When using or
+ * redistributing this file, you may do so under either license.
+ *
+ * GPL LICENSE SUMMARY
+ *
+ * This program 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.
+ *
+ * This program 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.
+ *
+ * BSD LICENSE
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * - Neither the name of Intel Corporation nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+
+/*
+ * For Memory Regions. This stuff should probably be moved into rdmavt/mr.h once
+ * drivers no longer need access to the MR directly.
+ */
+
+/*
+ * A segment is a linear region of low physical memory.
+ * Used by the verbs layer.
+ */
+struct rvt_seg {
+ void *vaddr;
+ size_t length;
+};
+
+/* The number of rvt_segs that fit in a page. */
+#define RVT_SEGSZ (PAGE_SIZE / sizeof(struct rvt_seg))
+
+struct rvt_segarray {
+ struct rvt_seg segs[RVT_SEGSZ];
+};
+
+struct rvt_mregion {
+ struct ib_pd *pd; /* shares refcnt of ibmr.pd */
+ u64 user_base; /* User's address for this region */
+ u64 iova; /* IB start address of this region */
+ size_t length;
+ u32 lkey;
+ u32 offset; /* offset (bytes) to start of region */
+ int access_flags;
+ u32 max_segs; /* number of rvt_segs in all the arrays */
+ u32 mapsz; /* size of the map array */
+ u8 page_shift; /* 0 - non unform/non powerof2 sizes */
+ u8 lkey_published; /* in global table */
+ atomic_t lkey_invalid; /* true if current lkey is invalid */
+ struct completion comp; /* complete when refcount goes to zero */
+ atomic_t refcount;
+ struct rvt_segarray *map[0]; /* the segments */
+};
+
+#define RVT_MAX_LKEY_TABLE_BITS 23
+
+struct rvt_lkey_table {
+ spinlock_t lock; /* protect changes in this struct */
+ u32 next; /* next unused index (speeds search) */
+ u32 gen; /* generation count */
+ u32 max; /* size of the table */
+ struct rvt_mregion __rcu **table;
+};
+
+/*
+ * These keep track of the copy progress within a memory region.
+ * Used by the verbs layer.
+ */
+struct rvt_sge {
+ struct rvt_mregion *mr;
+ void *vaddr; /* kernel virtual address of segment */
+ u32 sge_length; /* length of the SGE */
+ u32 length; /* remaining length of the segment */
+ u16 m; /* current index: mr->map[m] */
+ u16 n; /* current index: mr->map[m]->segs[n] */
+};
+
+struct rvt_sge_state {
+ struct rvt_sge *sg_list; /* next SGE to be used if any */
+ struct rvt_sge sge; /* progress state for the current SGE */
+ u32 total_len;
+ u8 num_sge;
+};
+
+static inline void rvt_put_mr(struct rvt_mregion *mr)
+{
+ if (unlikely(atomic_dec_and_test(&mr->refcount)))
+ complete(&mr->comp);
+}
+
+static inline void rvt_get_mr(struct rvt_mregion *mr)
+{
+ atomic_inc(&mr->refcount);
+}
+
+static inline void rvt_put_ss(struct rvt_sge_state *ss)
+{
+ while (ss->num_sge) {
+ rvt_put_mr(ss->sge.mr);
+ if (--ss->num_sge)
+ ss->sge = *ss->sg_list++;
+ }
+}
+
+#endif /* DEF_RDMAVT_INCMRH */
diff --git a/sys/ofed/include/rdma/rdmavt_qp.h b/sys/ofed/include/rdma/rdmavt_qp.h
new file mode 100644
index 0000000..2c5183e
--- /dev/null
+++ b/sys/ofed/include/rdma/rdmavt_qp.h
@@ -0,0 +1,535 @@
+#ifndef DEF_RDMAVT_INCQP_H
+#define DEF_RDMAVT_INCQP_H
+
+/*
+ * Copyright(c) 2016 Intel Corporation.
+ *
+ * This file is provided under a dual BSD/GPLv2 license. When using or
+ * redistributing this file, you may do so under either license.
+ *
+ * GPL LICENSE SUMMARY
+ *
+ * This program 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.
+ *
+ * This program 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.
+ *
+ * BSD LICENSE
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * - Neither the name of Intel Corporation nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+
+#include <rdma/rdma_vt.h>
+#include <rdma/ib_pack.h>
+#include <rdma/ib_verbs.h>
+/*
+ * Atomic bit definitions for r_aflags.
+ */
+#define RVT_R_WRID_VALID 0
+#define RVT_R_REWIND_SGE 1
+
+/*
+ * Bit definitions for r_flags.
+ */
+#define RVT_R_REUSE_SGE 0x01
+#define RVT_R_RDMAR_SEQ 0x02
+#define RVT_R_RSP_NAK 0x04
+#define RVT_R_RSP_SEND 0x08
+#define RVT_R_COMM_EST 0x10
+
+/*
+ * Bit definitions for s_flags.
+ *
+ * RVT_S_SIGNAL_REQ_WR - set if QP send WRs contain completion signaled
+ * RVT_S_BUSY - send tasklet is processing the QP
+ * RVT_S_TIMER - the RC retry timer is active
+ * RVT_S_ACK_PENDING - an ACK is waiting to be sent after RDMA read/atomics
+ * RVT_S_WAIT_FENCE - waiting for all prior RDMA read or atomic SWQEs
+ * before processing the next SWQE
+ * RVT_S_WAIT_RDMAR - waiting for a RDMA read or atomic SWQE to complete
+ * before processing the next SWQE
+ * RVT_S_WAIT_RNR - waiting for RNR timeout
+ * RVT_S_WAIT_SSN_CREDIT - waiting for RC credits to process next SWQE
+ * RVT_S_WAIT_DMA - waiting for send DMA queue to drain before generating
+ * next send completion entry not via send DMA
+ * RVT_S_WAIT_PIO - waiting for a send buffer to be available
+ * RVT_S_WAIT_PIO_DRAIN - waiting for a qp to drain pio packets
+ * RVT_S_WAIT_TX - waiting for a struct verbs_txreq to be available
+ * RVT_S_WAIT_DMA_DESC - waiting for DMA descriptors to be available
+ * RVT_S_WAIT_KMEM - waiting for kernel memory to be available
+ * RVT_S_WAIT_PSN - waiting for a packet to exit the send DMA queue
+ * RVT_S_WAIT_ACK - waiting for an ACK packet before sending more requests
+ * RVT_S_SEND_ONE - send one packet, request ACK, then wait for ACK
+ * RVT_S_ECN - a BECN was queued to the send engine
+ */
+#define RVT_S_SIGNAL_REQ_WR 0x0001
+#define RVT_S_BUSY 0x0002
+#define RVT_S_TIMER 0x0004
+#define RVT_S_RESP_PENDING 0x0008
+#define RVT_S_ACK_PENDING 0x0010
+#define RVT_S_WAIT_FENCE 0x0020
+#define RVT_S_WAIT_RDMAR 0x0040
+#define RVT_S_WAIT_RNR 0x0080
+#define RVT_S_WAIT_SSN_CREDIT 0x0100
+#define RVT_S_WAIT_DMA 0x0200
+#define RVT_S_WAIT_PIO 0x0400
+#define RVT_S_WAIT_PIO_DRAIN 0x0800
+#define RVT_S_WAIT_TX 0x1000
+#define RVT_S_WAIT_DMA_DESC 0x2000
+#define RVT_S_WAIT_KMEM 0x4000
+#define RVT_S_WAIT_PSN 0x8000
+#define RVT_S_WAIT_ACK 0x10000
+#define RVT_S_SEND_ONE 0x20000
+#define RVT_S_UNLIMITED_CREDIT 0x40000
+#define RVT_S_AHG_VALID 0x80000
+#define RVT_S_AHG_CLEAR 0x100000
+#define RVT_S_ECN 0x200000
+
+/*
+ * Wait flags that would prevent any packet type from being sent.
+ */
+#define RVT_S_ANY_WAIT_IO \
+ (RVT_S_WAIT_PIO | RVT_S_WAIT_PIO_DRAIN | RVT_S_WAIT_TX | \
+ RVT_S_WAIT_DMA_DESC | RVT_S_WAIT_KMEM)
+
+/*
+ * Wait flags that would prevent send work requests from making progress.
+ */
+#define RVT_S_ANY_WAIT_SEND (RVT_S_WAIT_FENCE | RVT_S_WAIT_RDMAR | \
+ RVT_S_WAIT_RNR | RVT_S_WAIT_SSN_CREDIT | RVT_S_WAIT_DMA | \
+ RVT_S_WAIT_PSN | RVT_S_WAIT_ACK)
+
+#define RVT_S_ANY_WAIT (RVT_S_ANY_WAIT_IO | RVT_S_ANY_WAIT_SEND)
+
+/* Number of bits to pay attention to in the opcode for checking qp type */
+#define RVT_OPCODE_QP_MASK 0xE0
+
+/* Flags for checking QP state (see ib_rvt_state_ops[]) */
+#define RVT_POST_SEND_OK 0x01
+#define RVT_POST_RECV_OK 0x02
+#define RVT_PROCESS_RECV_OK 0x04
+#define RVT_PROCESS_SEND_OK 0x08
+#define RVT_PROCESS_NEXT_SEND_OK 0x10
+#define RVT_FLUSH_SEND 0x20
+#define RVT_FLUSH_RECV 0x40
+#define RVT_PROCESS_OR_FLUSH_SEND \
+ (RVT_PROCESS_SEND_OK | RVT_FLUSH_SEND)
+
+/*
+ * Internal send flags
+ */
+#define RVT_SEND_RESERVE_USED IB_SEND_RESERVED_START
+#define RVT_SEND_COMPLETION_ONLY (IB_SEND_RESERVED_START << 1)
+
+/*
+ * Send work request queue entry.
+ * The size of the sg_list is determined when the QP is created and stored
+ * in qp->s_max_sge.
+ */
+struct rvt_swqe {
+ union {
+ struct ib_send_wr wr; /* don't use wr.sg_list */
+ struct ib_ud_wr ud_wr;
+ struct ib_reg_wr reg_wr;
+ struct ib_rdma_wr rdma_wr;
+ struct ib_atomic_wr atomic_wr;
+ };
+ u32 psn; /* first packet sequence number */
+ u32 lpsn; /* last packet sequence number */
+ u32 ssn; /* send sequence number */
+ u32 length; /* total length of data in sg_list */
+ struct rvt_sge sg_list[0];
+};
+
+/*
+ * Receive work request queue entry.
+ * The size of the sg_list is determined when the QP (or SRQ) is created
+ * and stored in qp->r_rq.max_sge (or srq->rq.max_sge).
+ */
+struct rvt_rwqe {
+ u64 wr_id;
+ u8 num_sge;
+ struct ib_sge sg_list[0];
+};
+
+/*
+ * This structure is used to contain the head pointer, tail pointer,
+ * and receive work queue entries as a single memory allocation so
+ * it can be mmap'ed into user space.
+ * Note that the wq array elements are variable size so you can't
+ * just index into the array to get the N'th element;
+ * use get_rwqe_ptr() instead.
+ */
+struct rvt_rwq {
+ u32 head; /* new work requests posted to the head */
+ u32 tail; /* receives pull requests from here. */
+ struct rvt_rwqe wq[0];
+};
+
+struct rvt_rq {
+ struct rvt_rwq *wq;
+ u32 size; /* size of RWQE array */
+ u8 max_sge;
+ /* protect changes in this struct */
+ spinlock_t lock ____cacheline_aligned_in_smp;
+};
+
+/*
+ * This structure is used by rvt_mmap() to validate an offset
+ * when an mmap() request is made. The vm_area_struct then uses
+ * this as its vm_private_data.
+ */
+struct rvt_mmap_info {
+ struct list_head pending_mmaps;
+ struct ib_ucontext *context;
+ void *obj;
+ __u64 offset;
+ struct kref ref;
+ unsigned size;
+};
+
+/*
+ * This structure holds the information that the send tasklet needs
+ * to send a RDMA read response or atomic operation.
+ */
+struct rvt_ack_entry {
+ struct rvt_sge rdma_sge;
+ u64 atomic_data;
+ u32 psn;
+ u32 lpsn;
+ u8 opcode;
+ u8 sent;
+};
+
+#define RC_QP_SCALING_INTERVAL 5
+
+#define RVT_OPERATION_PRIV 0x00000001
+#define RVT_OPERATION_ATOMIC 0x00000002
+#define RVT_OPERATION_ATOMIC_SGE 0x00000004
+#define RVT_OPERATION_LOCAL 0x00000008
+#define RVT_OPERATION_USE_RESERVE 0x00000010
+
+#define RVT_OPERATION_MAX (IB_WR_RESERVED10 + 1)
+
+/**
+ * rvt_operation_params - op table entry
+ * @length - the length to copy into the swqe entry
+ * @qpt_support - a bit mask indicating QP type support
+ * @flags - RVT_OPERATION flags (see above)
+ *
+ * This supports table driven post send so that
+ * the driver can have differing an potentially
+ * different sets of operations.
+ *
+ **/
+
+struct rvt_operation_params {
+ size_t length;
+ u32 qpt_support;
+ u32 flags;
+};
+
+/*
+ * Common variables are protected by both r_rq.lock and s_lock in that order
+ * which only happens in modify_qp() or changing the QP 'state'.
+ */
+struct rvt_qp {
+ struct ib_qp ibqp;
+ void *priv; /* Driver private data */
+ /* read mostly fields above and below */
+ struct ib_ah_attr remote_ah_attr;
+ struct ib_ah_attr alt_ah_attr;
+ struct rvt_qp __rcu *next; /* link list for QPN hash table */
+ struct rvt_swqe *s_wq; /* send work queue */
+ struct rvt_mmap_info *ip;
+
+ unsigned long timeout_jiffies; /* computed from timeout */
+
+ enum ib_mtu path_mtu;
+ int srate_mbps; /* s_srate (below) converted to Mbit/s */
+ pid_t pid; /* pid for user mode QPs */
+ u32 remote_qpn;
+ u32 qkey; /* QKEY for this QP (for UD or RD) */
+ u32 s_size; /* send work queue size */
+ u32 s_ahgpsn; /* set to the psn in the copy of the header */
+
+ u16 pmtu; /* decoded from path_mtu */
+ u8 log_pmtu; /* shift for pmtu */
+ u8 state; /* QP state */
+ u8 allowed_ops; /* high order bits of allowed opcodes */
+ u8 qp_access_flags;
+ u8 alt_timeout; /* Alternate path timeout for this QP */
+ u8 timeout; /* Timeout for this QP */
+ u8 s_srate;
+ u8 s_mig_state;
+ u8 port_num;
+ u8 s_pkey_index; /* PKEY index to use */
+ u8 s_alt_pkey_index; /* Alternate path PKEY index to use */
+ u8 r_max_rd_atomic; /* max number of RDMA read/atomic to receive */
+ u8 s_max_rd_atomic; /* max number of RDMA read/atomic to send */
+ u8 s_retry_cnt; /* number of times to retry */
+ u8 s_rnr_retry_cnt;
+ u8 r_min_rnr_timer; /* retry timeout value for RNR NAKs */
+ u8 s_max_sge; /* size of s_wq->sg_list */
+ u8 s_draining;
+
+ /* start of read/write fields */
+ atomic_t refcount ____cacheline_aligned_in_smp;
+ wait_queue_head_t wait;
+
+ struct rvt_ack_entry *s_ack_queue;
+ struct rvt_sge_state s_rdma_read_sge;
+
+ spinlock_t r_lock ____cacheline_aligned_in_smp; /* used for APM */
+ u32 r_psn; /* expected rcv packet sequence number */
+ unsigned long r_aflags;
+ u64 r_wr_id; /* ID for current receive WQE */
+ u32 r_ack_psn; /* PSN for next ACK or atomic ACK */
+ u32 r_len; /* total length of r_sge */
+ u32 r_rcv_len; /* receive data len processed */
+ u32 r_msn; /* message sequence number */
+
+ u8 r_state; /* opcode of last packet received */
+ u8 r_flags;
+ u8 r_head_ack_queue; /* index into s_ack_queue[] */
+
+ struct list_head rspwait; /* link for waiting to respond */
+
+ struct rvt_sge_state r_sge; /* current receive data */
+ struct rvt_rq r_rq; /* receive work queue */
+
+ /* post send line */
+ spinlock_t s_hlock ____cacheline_aligned_in_smp;
+ u32 s_head; /* new entries added here */
+ u32 s_next_psn; /* PSN for next request */
+ u32 s_avail; /* number of entries avail */
+ u32 s_ssn; /* SSN of tail entry */
+ atomic_t s_reserved_used; /* reserved entries in use */
+
+ spinlock_t s_lock ____cacheline_aligned_in_smp;
+ u32 s_flags;
+ struct rvt_sge_state *s_cur_sge;
+ struct rvt_swqe *s_wqe;
+ struct rvt_sge_state s_sge; /* current send request data */
+ struct rvt_mregion *s_rdma_mr;
+ u32 s_cur_size; /* size of send packet in bytes */
+ u32 s_len; /* total length of s_sge */
+ u32 s_rdma_read_len; /* total length of s_rdma_read_sge */
+ u32 s_last_psn; /* last response PSN processed */
+ u32 s_sending_psn; /* lowest PSN that is being sent */
+ u32 s_sending_hpsn; /* highest PSN that is being sent */
+ u32 s_psn; /* current packet sequence number */
+ u32 s_ack_rdma_psn; /* PSN for sending RDMA read responses */
+ u32 s_ack_psn; /* PSN for acking sends and RDMA writes */
+ u32 s_tail; /* next entry to process */
+ u32 s_cur; /* current work queue entry */
+ u32 s_acked; /* last un-ACK'ed entry */
+ u32 s_last; /* last completed entry */
+ u32 s_lsn; /* limit sequence number (credit) */
+ u16 s_hdrwords; /* size of s_hdr in 32 bit words */
+ u16 s_rdma_ack_cnt;
+ s8 s_ahgidx;
+ u8 s_state; /* opcode of last packet sent */
+ u8 s_ack_state; /* opcode of packet to ACK */
+ u8 s_nak_state; /* non-zero if NAK is pending */
+ u8 r_nak_state; /* non-zero if NAK is pending */
+ u8 s_retry; /* requester retry counter */
+ u8 s_rnr_retry; /* requester RNR retry counter */
+ u8 s_num_rd_atomic; /* number of RDMA read/atomic pending */
+ u8 s_tail_ack_queue; /* index into s_ack_queue[] */
+
+ struct rvt_sge_state s_ack_rdma_sge;
+ struct timer_list s_timer;
+
+ atomic_t local_ops_pending; /* number of fast_reg/local_inv reqs */
+
+ /*
+ * This sge list MUST be last. Do not add anything below here.
+ */
+ struct rvt_sge r_sg_list[0] /* verified SGEs */
+ ____cacheline_aligned_in_smp;
+};
+
+struct rvt_srq {
+ struct ib_srq ibsrq;
+ struct rvt_rq rq;
+ struct rvt_mmap_info *ip;
+ /* send signal when number of RWQEs < limit */
+ u32 limit;
+};
+
+#define RVT_QPN_MAX BIT(24)
+#define RVT_QPNMAP_ENTRIES (RVT_QPN_MAX / PAGE_SIZE / BITS_PER_BYTE)
+#define RVT_BITS_PER_PAGE (PAGE_SIZE * BITS_PER_BYTE)
+#define RVT_BITS_PER_PAGE_MASK (RVT_BITS_PER_PAGE - 1)
+#define RVT_QPN_MASK 0xFFFFFF
+
+/*
+ * QPN-map pages start out as NULL, they get allocated upon
+ * first use and are never deallocated. This way,
+ * large bitmaps are not allocated unless large numbers of QPs are used.
+ */
+struct rvt_qpn_map {
+ void *page;
+};
+
+struct rvt_qpn_table {
+ spinlock_t lock; /* protect changes to the qp table */
+ unsigned flags; /* flags for QP0/1 allocated for each port */
+ u32 last; /* last QP number allocated */
+ u32 nmaps; /* size of the map table */
+ u16 limit;
+ u8 incr;
+ /* bit map of free QP numbers other than 0/1 */
+ struct rvt_qpn_map map[RVT_QPNMAP_ENTRIES];
+};
+
+struct rvt_qp_ibdev {
+ u32 qp_table_size;
+ u32 qp_table_bits;
+ struct rvt_qp __rcu **qp_table;
+ spinlock_t qpt_lock; /* qptable lock */
+ struct rvt_qpn_table qpn_table;
+};
+
+/*
+ * There is one struct rvt_mcast for each multicast GID.
+ * All attached QPs are then stored as a list of
+ * struct rvt_mcast_qp.
+ */
+struct rvt_mcast_qp {
+ struct list_head list;
+ struct rvt_qp *qp;
+};
+
+struct rvt_mcast {
+ struct rb_node rb_node;
+ union ib_gid mgid;
+ struct list_head qp_list;
+ wait_queue_head_t wait;
+ atomic_t refcount;
+ int n_attached;
+};
+
+/*
+ * Since struct rvt_swqe is not a fixed size, we can't simply index into
+ * struct rvt_qp.s_wq. This function does the array index computation.
+ */
+static inline struct rvt_swqe *rvt_get_swqe_ptr(struct rvt_qp *qp,
+ unsigned n)
+{
+ return (struct rvt_swqe *)((char *)qp->s_wq +
+ (sizeof(struct rvt_swqe) +
+ qp->s_max_sge *
+ sizeof(struct rvt_sge)) * n);
+}
+
+/*
+ * Since struct rvt_rwqe is not a fixed size, we can't simply index into
+ * struct rvt_rwq.wq. This function does the array index computation.
+ */
+static inline struct rvt_rwqe *rvt_get_rwqe_ptr(struct rvt_rq *rq, unsigned n)
+{
+ return (struct rvt_rwqe *)
+ ((char *)rq->wq->wq +
+ (sizeof(struct rvt_rwqe) +
+ rq->max_sge * sizeof(struct ib_sge)) * n);
+}
+
+/**
+ * rvt_get_qp - get a QP reference
+ * @qp - the QP to hold
+ */
+static inline void rvt_get_qp(struct rvt_qp *qp)
+{
+ atomic_inc(&qp->refcount);
+}
+
+/**
+ * rvt_put_qp - release a QP reference
+ * @qp - the QP to release
+ */
+static inline void rvt_put_qp(struct rvt_qp *qp)
+{
+ if (qp && atomic_dec_and_test(&qp->refcount))
+ wake_up(&qp->wait);
+}
+
+/**
+ * rvt_qp_wqe_reserve - reserve operation
+ * @qp - the rvt qp
+ * @wqe - the send wqe
+ *
+ * This routine used in post send to record
+ * a wqe relative reserved operation use.
+ */
+static inline void rvt_qp_wqe_reserve(
+ struct rvt_qp *qp,
+ struct rvt_swqe *wqe)
+{
+ wqe->wr.send_flags |= RVT_SEND_RESERVE_USED;
+ atomic_inc(&qp->s_reserved_used);
+}
+
+/**
+ * rvt_qp_wqe_unreserve - clean reserved operation
+ * @qp - the rvt qp
+ * @wqe - the send wqe
+ *
+ * This decrements the reserve use count.
+ *
+ * This call MUST precede the change to
+ * s_last to insure that post send sees a stable
+ * s_avail.
+ *
+ * An smp_mp__after_atomic() is used to insure
+ * the compiler does not juggle the order of the s_last
+ * ring index and the decrementing of s_reserved_used.
+ */
+static inline void rvt_qp_wqe_unreserve(
+ struct rvt_qp *qp,
+ struct rvt_swqe *wqe)
+{
+ if (unlikely(wqe->wr.send_flags & RVT_SEND_RESERVE_USED)) {
+ wqe->wr.send_flags &= ~RVT_SEND_RESERVE_USED;
+ atomic_dec(&qp->s_reserved_used);
+ /* insure no compiler re-order up to s_last change */
+ smp_mb__after_atomic();
+ }
+}
+
+extern const int ib_rvt_state_ops[];
+
+struct rvt_dev_info;
+int rvt_error_qp(struct rvt_qp *qp, enum ib_wc_status err);
+
+#endif /* DEF_RDMAVT_INCQP_H */
diff --git a/sys/ofed/include/rdma/sdp_socket.h b/sys/ofed/include/rdma/sdp_socket.h
deleted file mode 100644
index 6b07589..0000000
--- a/sys/ofed/include/rdma/sdp_socket.h
+++ /dev/null
@@ -1,23 +0,0 @@
-/* Stuff that should go into include/linux/socket.h */
-
-#ifndef SDP_SOCKET_H
-#define SDP_SOCKET_H
-
-#ifndef __FreeBSD__
-#ifndef AF_INET_SDP
-#define AF_INET_SDP 27
-#define PF_INET_SDP AF_INET_SDP
-#endif
-#endif
-
-#ifndef SDP_ZCOPY_THRESH
-#define SDP_ZCOPY_THRESH 80
-#endif
-
-#ifndef SDP_LAST_BIND_ERR
-#define SDP_LAST_BIND_ERR 81
-#endif
-
-/* TODO: AF_INET6_SDP ? */
-
-#endif
diff --git a/sys/ofed/include/uapi/rdma/ib_user_cm.h b/sys/ofed/include/uapi/rdma/ib_user_cm.h
new file mode 100644
index 0000000..36ac428
--- /dev/null
+++ b/sys/ofed/include/uapi/rdma/ib_user_cm.h
@@ -0,0 +1,329 @@
+/*
+ * Copyright (c) 2005 Topspin Communications. All rights reserved.
+ * Copyright (c) 2005 Intel Corporation. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#ifndef IB_USER_CM_H
+#define IB_USER_CM_H
+
+#ifdef _KERNEL
+#include <linux/types.h>
+#else
+#include <infiniband/types.h>
+#endif
+#include <rdma/ib_user_sa.h>
+
+#define IB_USER_CM_ABI_VERSION 5
+
+enum {
+ IB_USER_CM_CMD_CREATE_ID,
+ IB_USER_CM_CMD_DESTROY_ID,
+ IB_USER_CM_CMD_ATTR_ID,
+
+ IB_USER_CM_CMD_LISTEN,
+ IB_USER_CM_CMD_NOTIFY,
+
+ IB_USER_CM_CMD_SEND_REQ,
+ IB_USER_CM_CMD_SEND_REP,
+ IB_USER_CM_CMD_SEND_RTU,
+ IB_USER_CM_CMD_SEND_DREQ,
+ IB_USER_CM_CMD_SEND_DREP,
+ IB_USER_CM_CMD_SEND_REJ,
+ IB_USER_CM_CMD_SEND_MRA,
+ IB_USER_CM_CMD_SEND_LAP,
+ IB_USER_CM_CMD_SEND_APR,
+ IB_USER_CM_CMD_SEND_SIDR_REQ,
+ IB_USER_CM_CMD_SEND_SIDR_REP,
+
+ IB_USER_CM_CMD_EVENT,
+ IB_USER_CM_CMD_INIT_QP_ATTR,
+};
+/*
+ * command ABI structures.
+ */
+struct ib_ucm_cmd_hdr {
+ __u32 cmd;
+ __u16 in;
+ __u16 out;
+};
+
+struct ib_ucm_create_id {
+ __u64 uid;
+ __u64 response;
+};
+
+struct ib_ucm_create_id_resp {
+ __u32 id;
+};
+
+struct ib_ucm_destroy_id {
+ __u64 response;
+ __u32 id;
+ __u32 reserved;
+};
+
+struct ib_ucm_destroy_id_resp {
+ __u32 events_reported;
+};
+
+struct ib_ucm_attr_id {
+ __u64 response;
+ __u32 id;
+ __u32 reserved;
+};
+
+struct ib_ucm_attr_id_resp {
+ __be64 service_id;
+ __be64 service_mask;
+ __be32 local_id;
+ __be32 remote_id;
+};
+
+struct ib_ucm_init_qp_attr {
+ __u64 response;
+ __u32 id;
+ __u32 qp_state;
+};
+
+struct ib_ucm_listen {
+ __be64 service_id;
+ __be64 service_mask;
+ __u32 id;
+ __u32 reserved;
+};
+
+struct ib_ucm_notify {
+ __u32 id;
+ __u32 event;
+};
+
+struct ib_ucm_private_data {
+ __u64 data;
+ __u32 id;
+ __u8 len;
+ __u8 reserved[3];
+};
+
+struct ib_ucm_req {
+ __u32 id;
+ __u32 qpn;
+ __u32 qp_type;
+ __u32 psn;
+ __be64 sid;
+ __u64 data;
+ __u64 primary_path;
+ __u64 alternate_path;
+ __u8 len;
+ __u8 peer_to_peer;
+ __u8 responder_resources;
+ __u8 initiator_depth;
+ __u8 remote_cm_response_timeout;
+ __u8 flow_control;
+ __u8 local_cm_response_timeout;
+ __u8 retry_count;
+ __u8 rnr_retry_count;
+ __u8 max_cm_retries;
+ __u8 srq;
+ __u8 reserved[5];
+};
+
+struct ib_ucm_rep {
+ __u64 uid;
+ __u64 data;
+ __u32 id;
+ __u32 qpn;
+ __u32 psn;
+ __u8 len;
+ __u8 responder_resources;
+ __u8 initiator_depth;
+ __u8 target_ack_delay;
+ __u8 failover_accepted;
+ __u8 flow_control;
+ __u8 rnr_retry_count;
+ __u8 srq;
+ __u8 reserved[4];
+};
+
+struct ib_ucm_info {
+ __u32 id;
+ __u32 status;
+ __u64 info;
+ __u64 data;
+ __u8 info_len;
+ __u8 data_len;
+ __u8 reserved[6];
+};
+
+struct ib_ucm_mra {
+ __u64 data;
+ __u32 id;
+ __u8 len;
+ __u8 timeout;
+ __u8 reserved[2];
+};
+
+struct ib_ucm_lap {
+ __u64 path;
+ __u64 data;
+ __u32 id;
+ __u8 len;
+ __u8 reserved[3];
+};
+
+struct ib_ucm_sidr_req {
+ __u32 id;
+ __u32 timeout;
+ __be64 sid;
+ __u64 data;
+ __u64 path;
+ __u16 reserved_pkey;
+ __u8 len;
+ __u8 max_cm_retries;
+ __u8 reserved[4];
+};
+
+struct ib_ucm_sidr_rep {
+ __u32 id;
+ __u32 qpn;
+ __u32 qkey;
+ __u32 status;
+ __u64 info;
+ __u64 data;
+ __u8 info_len;
+ __u8 data_len;
+ __u8 reserved[6];
+};
+/*
+ * event notification ABI structures.
+ */
+struct ib_ucm_event_get {
+ __u64 response;
+ __u64 data;
+ __u64 info;
+ __u8 data_len;
+ __u8 info_len;
+ __u8 reserved[6];
+};
+
+struct ib_ucm_req_event_resp {
+ struct ib_user_path_rec primary_path;
+ struct ib_user_path_rec alternate_path;
+ __be64 remote_ca_guid;
+ __u32 remote_qkey;
+ __u32 remote_qpn;
+ __u32 qp_type;
+ __u32 starting_psn;
+ __u8 responder_resources;
+ __u8 initiator_depth;
+ __u8 local_cm_response_timeout;
+ __u8 flow_control;
+ __u8 remote_cm_response_timeout;
+ __u8 retry_count;
+ __u8 rnr_retry_count;
+ __u8 srq;
+ __u8 port;
+ __u8 reserved[7];
+};
+
+struct ib_ucm_rep_event_resp {
+ __be64 remote_ca_guid;
+ __u32 remote_qkey;
+ __u32 remote_qpn;
+ __u32 starting_psn;
+ __u8 responder_resources;
+ __u8 initiator_depth;
+ __u8 target_ack_delay;
+ __u8 failover_accepted;
+ __u8 flow_control;
+ __u8 rnr_retry_count;
+ __u8 srq;
+ __u8 reserved[5];
+};
+
+struct ib_ucm_rej_event_resp {
+ __u32 reason;
+ /* ari in ib_ucm_event_get info field. */
+};
+
+struct ib_ucm_mra_event_resp {
+ __u8 timeout;
+ __u8 reserved[3];
+};
+
+struct ib_ucm_lap_event_resp {
+ struct ib_user_path_rec path;
+};
+
+struct ib_ucm_apr_event_resp {
+ __u32 status;
+ /* apr info in ib_ucm_event_get info field. */
+};
+
+struct ib_ucm_sidr_req_event_resp {
+ __u16 pkey;
+ __u8 port;
+ __u8 reserved;
+};
+
+struct ib_ucm_sidr_rep_event_resp {
+ __u32 status;
+ __u32 qkey;
+ __u32 qpn;
+ /* info in ib_ucm_event_get info field. */
+};
+
+#define IB_UCM_PRES_DATA 0x01
+#define IB_UCM_PRES_INFO 0x02
+#define IB_UCM_PRES_PRIMARY 0x04
+#define IB_UCM_PRES_ALTERNATE 0x08
+
+struct ib_ucm_event_resp {
+ __u64 uid;
+ __u32 id;
+ __u32 event;
+ __u32 present;
+ __u32 reserved;
+ union {
+ struct ib_ucm_req_event_resp req_resp;
+ struct ib_ucm_rep_event_resp rep_resp;
+ struct ib_ucm_rej_event_resp rej_resp;
+ struct ib_ucm_mra_event_resp mra_resp;
+ struct ib_ucm_lap_event_resp lap_resp;
+ struct ib_ucm_apr_event_resp apr_resp;
+
+ struct ib_ucm_sidr_req_event_resp sidr_req_resp;
+ struct ib_ucm_sidr_rep_event_resp sidr_rep_resp;
+
+ __u32 send_status;
+ } u;
+};
+
+#endif /* IB_USER_CM_H */
diff --git a/sys/ofed/include/uapi/rdma/ib_user_mad.h b/sys/ofed/include/uapi/rdma/ib_user_mad.h
new file mode 100644
index 0000000..51afda9
--- /dev/null
+++ b/sys/ofed/include/uapi/rdma/ib_user_mad.h
@@ -0,0 +1,250 @@
+/*
+ * Copyright (c) 2004 Topspin Communications. All rights reserved.
+ * Copyright (c) 2005 Voltaire, Inc. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#ifndef IB_USER_MAD_H
+#define IB_USER_MAD_H
+
+#ifdef _KERNEL
+#include <linux/types.h>
+#include <linux/ioctl.h>
+#else
+#include <infiniband/types.h>
+#include <sys/ioccom.h>
+#endif
+
+/*
+ * Increment this value if any changes that break userspace ABI
+ * compatibility are made.
+ */
+#define IB_USER_MAD_ABI_VERSION 5
+
+/*
+ * Make sure that all structs defined in this file remain laid out so
+ * that they pack the same way on 32-bit and 64-bit architectures (to
+ * avoid incompatibility between 32-bit userspace and 64-bit kernels).
+ */
+
+/**
+ * ib_user_mad_hdr_old - Old version of MAD packet header without pkey_index
+ * @id - ID of agent MAD received with/to be sent with
+ * @status - 0 on successful receive, ETIMEDOUT if no response
+ * received (transaction ID in data[] will be set to TID of original
+ * request) (ignored on send)
+ * @timeout_ms - Milliseconds to wait for response (unset on receive)
+ * @retries - Number of automatic retries to attempt
+ * @qpn - Remote QP number received from/to be sent to
+ * @qkey - Remote Q_Key to be sent with (unset on receive)
+ * @lid - Remote lid received from/to be sent to
+ * @sl - Service level received with/to be sent with
+ * @path_bits - Local path bits received with/to be sent with
+ * @grh_present - If set, GRH was received/should be sent
+ * @gid_index - Local GID index to send with (unset on receive)
+ * @hop_limit - Hop limit in GRH
+ * @traffic_class - Traffic class in GRH
+ * @gid - Remote GID in GRH
+ * @flow_label - Flow label in GRH
+ */
+struct ib_user_mad_hdr_old {
+ __u32 id;
+ __u32 status;
+ __u32 timeout_ms;
+ __u32 retries;
+ __u32 length;
+ __be32 qpn;
+ __be32 qkey;
+ __be16 lid;
+ __u8 sl;
+ __u8 path_bits;
+ __u8 grh_present;
+ __u8 gid_index;
+ __u8 hop_limit;
+ __u8 traffic_class;
+ __u8 gid[16];
+ __be32 flow_label;
+};
+
+/**
+ * ib_user_mad_hdr - MAD packet header
+ * This layout allows specifying/receiving the P_Key index. To use
+ * this capability, an application must call the
+ * IB_USER_MAD_ENABLE_PKEY ioctl on the user MAD file handle before
+ * any other actions with the file handle.
+ * @id - ID of agent MAD received with/to be sent with
+ * @status - 0 on successful receive, ETIMEDOUT if no response
+ * received (transaction ID in data[] will be set to TID of original
+ * request) (ignored on send)
+ * @timeout_ms - Milliseconds to wait for response (unset on receive)
+ * @retries - Number of automatic retries to attempt
+ * @qpn - Remote QP number received from/to be sent to
+ * @qkey - Remote Q_Key to be sent with (unset on receive)
+ * @lid - Remote lid received from/to be sent to
+ * @sl - Service level received with/to be sent with
+ * @path_bits - Local path bits received with/to be sent with
+ * @grh_present - If set, GRH was received/should be sent
+ * @gid_index - Local GID index to send with (unset on receive)
+ * @hop_limit - Hop limit in GRH
+ * @traffic_class - Traffic class in GRH
+ * @gid - Remote GID in GRH
+ * @flow_label - Flow label in GRH
+ * @pkey_index - P_Key index
+ */
+struct ib_user_mad_hdr {
+ __u32 id;
+ __u32 status;
+ __u32 timeout_ms;
+ __u32 retries;
+ __u32 length;
+ __be32 qpn;
+ __be32 qkey;
+ __be16 lid;
+ __u8 sl;
+ __u8 path_bits;
+ __u8 grh_present;
+ __u8 gid_index;
+ __u8 hop_limit;
+ __u8 traffic_class;
+ __u8 gid[16];
+ __be32 flow_label;
+ __u16 pkey_index;
+ __u8 reserved[6];
+};
+
+/**
+ * ib_user_mad - MAD packet
+ * @hdr - MAD packet header
+ * @data - Contents of MAD
+ *
+ */
+struct ib_user_mad {
+ struct ib_user_mad_hdr hdr;
+ __u64 data[0];
+};
+
+/*
+ * Earlier versions of this interface definition declared the
+ * method_mask[] member as an array of __u32 but treated it as a
+ * bitmap made up of longs in the kernel. This ambiguity meant that
+ * 32-bit big-endian applications that can run on both 32-bit and
+ * 64-bit kernels had no consistent ABI to rely on, and 64-bit
+ * big-endian applications that treated method_mask as being made up
+ * of 32-bit words would have their bitmap misinterpreted.
+ *
+ * To clear up this confusion, we change the declaration of
+ * method_mask[] to use unsigned long and handle the conversion from
+ * 32-bit userspace to 64-bit kernel for big-endian systems in the
+ * compat_ioctl method. Unfortunately, to keep the structure layout
+ * the same, we need the method_mask[] array to be aligned only to 4
+ * bytes even when long is 64 bits, which forces us into this ugly
+ * typedef.
+ */
+typedef unsigned long __attribute__((aligned(4))) packed_ulong;
+#define IB_USER_MAD_LONGS_PER_METHOD_MASK (128 / (8 * sizeof (long)))
+
+/**
+ * ib_user_mad_reg_req - MAD registration request
+ * @id - Set by the kernel; used to identify agent in future requests.
+ * @qpn - Queue pair number; must be 0 or 1.
+ * @method_mask - The caller will receive unsolicited MADs for any method
+ * where @method_mask = 1.
+ * @mgmt_class - Indicates which management class of MADs should be receive
+ * by the caller. This field is only required if the user wishes to
+ * receive unsolicited MADs, otherwise it should be 0.
+ * @mgmt_class_version - Indicates which version of MADs for the given
+ * management class to receive.
+ * @oui: Indicates IEEE OUI when mgmt_class is a vendor class
+ * in the range from 0x30 to 0x4f. Otherwise not used.
+ * @rmpp_version: If set, indicates the RMPP version used.
+ *
+ */
+struct ib_user_mad_reg_req {
+ __u32 id;
+ packed_ulong method_mask[IB_USER_MAD_LONGS_PER_METHOD_MASK];
+ __u8 qpn;
+ __u8 mgmt_class;
+ __u8 mgmt_class_version;
+ __u8 oui[3];
+ __u8 rmpp_version;
+};
+
+/**
+ * ib_user_mad_reg_req2 - MAD registration request
+ *
+ * @id - Set by the _kernel_; used by userspace to identify the
+ * registered agent in future requests.
+ * @qpn - Queue pair number; must be 0 or 1.
+ * @mgmt_class - Indicates which management class of MADs should be
+ * receive by the caller. This field is only required if
+ * the user wishes to receive unsolicited MADs, otherwise
+ * it should be 0.
+ * @mgmt_class_version - Indicates which version of MADs for the given
+ * management class to receive.
+ * @res - Ignored.
+ * @flags - additional registration flags; Must be in the set of
+ * flags defined in IB_USER_MAD_REG_FLAGS_CAP
+ * @method_mask - The caller wishes to receive unsolicited MADs for the
+ * methods whose bit(s) is(are) set.
+ * @oui - Indicates IEEE OUI to use when mgmt_class is a vendor
+ * class in the range from 0x30 to 0x4f. Otherwise not
+ * used.
+ * @rmpp_version - If set, indicates the RMPP version to use.
+ */
+enum {
+ IB_USER_MAD_USER_RMPP = (1 << 0),
+};
+#define IB_USER_MAD_REG_FLAGS_CAP (IB_USER_MAD_USER_RMPP)
+struct ib_user_mad_reg_req2 {
+ __u32 id;
+ __u32 qpn;
+ __u8 mgmt_class;
+ __u8 mgmt_class_version;
+ __u16 res;
+ __u32 flags;
+ __u64 method_mask[2];
+ __u32 oui;
+ __u8 rmpp_version;
+ __u8 reserved[3];
+};
+
+#define IB_IOCTL_MAGIC 0x1b
+
+#define IB_USER_MAD_REGISTER_AGENT _IOWR(IB_IOCTL_MAGIC, 1, \
+ struct ib_user_mad_reg_req)
+
+#define IB_USER_MAD_UNREGISTER_AGENT _IOW(IB_IOCTL_MAGIC, 2, __u32)
+
+#define IB_USER_MAD_ENABLE_PKEY _IO(IB_IOCTL_MAGIC, 3)
+
+#define IB_USER_MAD_REGISTER_AGENT2 _IOWR(IB_IOCTL_MAGIC, 4, \
+ struct ib_user_mad_reg_req2)
+
+#endif /* IB_USER_MAD_H */
diff --git a/sys/ofed/include/uapi/rdma/ib_user_sa.h b/sys/ofed/include/uapi/rdma/ib_user_sa.h
new file mode 100644
index 0000000..3edc509
--- /dev/null
+++ b/sys/ofed/include/uapi/rdma/ib_user_sa.h
@@ -0,0 +1,80 @@
+/*
+ * Copyright (c) 2005 Intel Corporation. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#ifndef IB_USER_SA_H
+#define IB_USER_SA_H
+
+#ifdef _KERNEL
+#include <linux/types.h>
+#else
+#include <infiniband/types.h>
+#endif
+
+enum {
+ IB_PATH_GMP = 1,
+ IB_PATH_PRIMARY = (1<<1),
+ IB_PATH_ALTERNATE = (1<<2),
+ IB_PATH_OUTBOUND = (1<<3),
+ IB_PATH_INBOUND = (1<<4),
+ IB_PATH_INBOUND_REVERSE = (1<<5),
+ IB_PATH_BIDIRECTIONAL = IB_PATH_OUTBOUND | IB_PATH_INBOUND_REVERSE
+};
+
+struct ib_path_rec_data {
+ __u32 flags;
+ __u32 reserved;
+ __u32 path_rec[16];
+};
+
+struct ib_user_path_rec {
+ __u8 dgid[16];
+ __u8 sgid[16];
+ __be16 dlid;
+ __be16 slid;
+ __u32 raw_traffic;
+ __be32 flow_label;
+ __u32 reversible;
+ __u32 mtu;
+ __be16 pkey;
+ __u8 hop_limit;
+ __u8 traffic_class;
+ __u8 numb_path;
+ __u8 sl;
+ __u8 mtu_selector;
+ __u8 rate_selector;
+ __u8 rate;
+ __u8 packet_life_time_selector;
+ __u8 packet_life_time;
+ __u8 preference;
+};
+
+#endif /* IB_USER_SA_H */
diff --git a/sys/ofed/include/uapi/rdma/ib_user_verbs.h b/sys/ofed/include/uapi/rdma/ib_user_verbs.h
new file mode 100644
index 0000000..61e5213
--- /dev/null
+++ b/sys/ofed/include/uapi/rdma/ib_user_verbs.h
@@ -0,0 +1,1071 @@
+/*
+ * Copyright (c) 2005 Topspin Communications. All rights reserved.
+ * Copyright (c) 2005, 2006 Cisco Systems. All rights reserved.
+ * Copyright (c) 2005 PathScale, Inc. All rights reserved.
+ * Copyright (c) 2006 Mellanox Technologies. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#ifndef IB_USER_VERBS_H
+#define IB_USER_VERBS_H
+
+#ifdef _KERNEL
+#include <linux/types.h>
+#else
+#include <infiniband/types.h>
+#endif
+
+/*
+ * Increment this value if any changes that break userspace ABI
+ * compatibility are made.
+ */
+#define IB_USER_VERBS_ABI_VERSION 6
+#define IB_USER_VERBS_CMD_THRESHOLD 50
+
+enum {
+ IB_USER_VERBS_CMD_GET_CONTEXT,
+ IB_USER_VERBS_CMD_QUERY_DEVICE,
+ IB_USER_VERBS_CMD_QUERY_PORT,
+ IB_USER_VERBS_CMD_ALLOC_PD,
+ IB_USER_VERBS_CMD_DEALLOC_PD,
+ IB_USER_VERBS_CMD_CREATE_AH,
+ IB_USER_VERBS_CMD_MODIFY_AH,
+ IB_USER_VERBS_CMD_QUERY_AH,
+ IB_USER_VERBS_CMD_DESTROY_AH,
+ IB_USER_VERBS_CMD_REG_MR,
+ IB_USER_VERBS_CMD_REG_SMR,
+ IB_USER_VERBS_CMD_REREG_MR,
+ IB_USER_VERBS_CMD_QUERY_MR,
+ IB_USER_VERBS_CMD_DEREG_MR,
+ IB_USER_VERBS_CMD_ALLOC_MW,
+ IB_USER_VERBS_CMD_BIND_MW,
+ IB_USER_VERBS_CMD_DEALLOC_MW,
+ IB_USER_VERBS_CMD_CREATE_COMP_CHANNEL,
+ IB_USER_VERBS_CMD_CREATE_CQ,
+ IB_USER_VERBS_CMD_RESIZE_CQ,
+ IB_USER_VERBS_CMD_DESTROY_CQ,
+ IB_USER_VERBS_CMD_POLL_CQ,
+ IB_USER_VERBS_CMD_PEEK_CQ,
+ IB_USER_VERBS_CMD_REQ_NOTIFY_CQ,
+ IB_USER_VERBS_CMD_CREATE_QP,
+ IB_USER_VERBS_CMD_QUERY_QP,
+ IB_USER_VERBS_CMD_MODIFY_QP,
+ IB_USER_VERBS_CMD_DESTROY_QP,
+ IB_USER_VERBS_CMD_POST_SEND,
+ IB_USER_VERBS_CMD_POST_RECV,
+ IB_USER_VERBS_CMD_ATTACH_MCAST,
+ IB_USER_VERBS_CMD_DETACH_MCAST,
+ IB_USER_VERBS_CMD_CREATE_SRQ,
+ IB_USER_VERBS_CMD_MODIFY_SRQ,
+ IB_USER_VERBS_CMD_QUERY_SRQ,
+ IB_USER_VERBS_CMD_DESTROY_SRQ,
+ IB_USER_VERBS_CMD_POST_SRQ_RECV,
+ IB_USER_VERBS_CMD_OPEN_XRCD,
+ IB_USER_VERBS_CMD_CLOSE_XRCD,
+ IB_USER_VERBS_CMD_CREATE_XSRQ,
+ IB_USER_VERBS_CMD_OPEN_QP,
+};
+
+enum {
+ IB_USER_VERBS_EX_CMD_QUERY_DEVICE = IB_USER_VERBS_CMD_QUERY_DEVICE,
+ IB_USER_VERBS_EX_CMD_CREATE_CQ = IB_USER_VERBS_CMD_CREATE_CQ,
+ IB_USER_VERBS_EX_CMD_CREATE_QP = IB_USER_VERBS_CMD_CREATE_QP,
+ IB_USER_VERBS_EX_CMD_CREATE_FLOW = IB_USER_VERBS_CMD_THRESHOLD,
+ IB_USER_VERBS_EX_CMD_DESTROY_FLOW,
+ IB_USER_VERBS_EX_CMD_CREATE_WQ,
+ IB_USER_VERBS_EX_CMD_MODIFY_WQ,
+ IB_USER_VERBS_EX_CMD_DESTROY_WQ,
+ IB_USER_VERBS_EX_CMD_CREATE_RWQ_IND_TBL,
+ IB_USER_VERBS_EX_CMD_DESTROY_RWQ_IND_TBL
+};
+
+/*
+ * Make sure that all structs defined in this file remain laid out so
+ * that they pack the same way on 32-bit and 64-bit architectures (to
+ * avoid incompatibility between 32-bit userspace and 64-bit kernels).
+ * Specifically:
+ * - Do not use pointer types -- pass pointers in __u64 instead.
+ * - Make sure that any structure larger than 4 bytes is padded to a
+ * multiple of 8 bytes. Otherwise the structure size will be
+ * different between 32-bit and 64-bit architectures.
+ */
+
+struct ib_uverbs_async_event_desc {
+ __u64 element;
+ __u32 event_type; /* enum ib_event_type */
+ __u32 reserved;
+};
+
+struct ib_uverbs_comp_event_desc {
+ __u64 cq_handle;
+};
+
+/*
+ * All commands from userspace should start with a __u32 command field
+ * followed by __u16 in_words and out_words fields (which give the
+ * length of the command block and response buffer if any in 32-bit
+ * words). The kernel driver will read these fields first and read
+ * the rest of the command struct based on these value.
+ */
+
+#define IB_USER_VERBS_CMD_COMMAND_MASK 0xff
+#define IB_USER_VERBS_CMD_FLAGS_MASK 0xff000000u
+#define IB_USER_VERBS_CMD_FLAGS_SHIFT 24
+
+#define IB_USER_VERBS_CMD_FLAG_EXTENDED 0x80
+
+struct ib_uverbs_cmd_hdr {
+ __u32 command;
+ __u16 in_words;
+ __u16 out_words;
+};
+
+struct ib_uverbs_ex_cmd_hdr {
+ __u64 response;
+ __u16 provider_in_words;
+ __u16 provider_out_words;
+ __u32 cmd_hdr_reserved;
+};
+
+struct ib_uverbs_get_context {
+ __u64 response;
+ __u64 driver_data[0];
+};
+
+struct ib_uverbs_get_context_resp {
+ __u32 async_fd;
+ __u32 num_comp_vectors;
+};
+
+struct ib_uverbs_query_device {
+ __u64 response;
+ __u64 driver_data[0];
+};
+
+struct ib_uverbs_query_device_resp {
+ __u64 fw_ver;
+ __be64 node_guid;
+ __be64 sys_image_guid;
+ __u64 max_mr_size;
+ __u64 page_size_cap;
+ __u32 vendor_id;
+ __u32 vendor_part_id;
+ __u32 hw_ver;
+ __u32 max_qp;
+ __u32 max_qp_wr;
+ __u32 device_cap_flags;
+ __u32 max_sge;
+ __u32 max_sge_rd;
+ __u32 max_cq;
+ __u32 max_cqe;
+ __u32 max_mr;
+ __u32 max_pd;
+ __u32 max_qp_rd_atom;
+ __u32 max_ee_rd_atom;
+ __u32 max_res_rd_atom;
+ __u32 max_qp_init_rd_atom;
+ __u32 max_ee_init_rd_atom;
+ __u32 atomic_cap;
+ __u32 max_ee;
+ __u32 max_rdd;
+ __u32 max_mw;
+ __u32 max_raw_ipv6_qp;
+ __u32 max_raw_ethy_qp;
+ __u32 max_mcast_grp;
+ __u32 max_mcast_qp_attach;
+ __u32 max_total_mcast_qp_attach;
+ __u32 max_ah;
+ __u32 max_fmr;
+ __u32 max_map_per_fmr;
+ __u32 max_srq;
+ __u32 max_srq_wr;
+ __u32 max_srq_sge;
+ __u16 max_pkeys;
+ __u8 local_ca_ack_delay;
+ __u8 phys_port_cnt;
+ __u8 reserved[4];
+};
+
+struct ib_uverbs_ex_query_device {
+ __u32 comp_mask;
+ __u32 reserved;
+};
+
+struct ib_uverbs_odp_caps {
+ __u64 general_caps;
+ struct {
+ __u32 rc_odp_caps;
+ __u32 uc_odp_caps;
+ __u32 ud_odp_caps;
+ } per_transport_caps;
+ __u32 reserved;
+};
+
+struct ib_uverbs_rss_caps {
+ /* Corresponding bit will be set if qp type from
+ * 'enum ib_qp_type' is supported, e.g.
+ * supported_qpts |= 1 << IB_QPT_UD
+ */
+ __u32 supported_qpts;
+ __u32 max_rwq_indirection_tables;
+ __u32 max_rwq_indirection_table_size;
+ __u32 reserved;
+};
+
+struct ib_uverbs_ex_query_device_resp {
+ struct ib_uverbs_query_device_resp base;
+ __u32 comp_mask;
+ __u32 response_length;
+ struct ib_uverbs_odp_caps odp_caps;
+ __u64 timestamp_mask;
+ __u64 hca_core_clock; /* in KHZ */
+ __u64 device_cap_flags_ex;
+ struct ib_uverbs_rss_caps rss_caps;
+ __u32 max_wq_type_rq;
+ __u32 reserved;
+};
+
+struct ib_uverbs_query_port {
+ __u64 response;
+ __u8 port_num;
+ __u8 reserved[7];
+ __u64 driver_data[0];
+};
+
+struct ib_uverbs_query_port_resp {
+ __u32 port_cap_flags;
+ __u32 max_msg_sz;
+ __u32 bad_pkey_cntr;
+ __u32 qkey_viol_cntr;
+ __u32 gid_tbl_len;
+ __u16 pkey_tbl_len;
+ __u16 lid;
+ __u16 sm_lid;
+ __u8 state;
+ __u8 max_mtu;
+ __u8 active_mtu;
+ __u8 lmc;
+ __u8 max_vl_num;
+ __u8 sm_sl;
+ __u8 subnet_timeout;
+ __u8 init_type_reply;
+ __u8 active_width;
+ __u8 active_speed;
+ __u8 phys_state;
+ __u8 link_layer;
+ __u8 reserved[2];
+};
+
+struct ib_uverbs_alloc_pd {
+ __u64 response;
+ __u64 driver_data[0];
+};
+
+struct ib_uverbs_alloc_pd_resp {
+ __u32 pd_handle;
+};
+
+struct ib_uverbs_dealloc_pd {
+ __u32 pd_handle;
+};
+
+struct ib_uverbs_open_xrcd {
+ __u64 response;
+ __u32 fd;
+ __u32 oflags;
+ __u64 driver_data[0];
+};
+
+struct ib_uverbs_open_xrcd_resp {
+ __u32 xrcd_handle;
+};
+
+struct ib_uverbs_close_xrcd {
+ __u32 xrcd_handle;
+};
+
+struct ib_uverbs_reg_mr {
+ __u64 response;
+ __u64 start;
+ __u64 length;
+ __u64 hca_va;
+ __u32 pd_handle;
+ __u32 access_flags;
+ __u64 driver_data[0];
+};
+
+struct ib_uverbs_reg_mr_resp {
+ __u32 mr_handle;
+ __u32 lkey;
+ __u32 rkey;
+};
+
+struct ib_uverbs_rereg_mr {
+ __u64 response;
+ __u32 mr_handle;
+ __u32 flags;
+ __u64 start;
+ __u64 length;
+ __u64 hca_va;
+ __u32 pd_handle;
+ __u32 access_flags;
+};
+
+struct ib_uverbs_rereg_mr_resp {
+ __u32 lkey;
+ __u32 rkey;
+};
+
+struct ib_uverbs_dereg_mr {
+ __u32 mr_handle;
+};
+
+struct ib_uverbs_alloc_mw {
+ __u64 response;
+ __u32 pd_handle;
+ __u8 mw_type;
+ __u8 reserved[3];
+};
+
+struct ib_uverbs_alloc_mw_resp {
+ __u32 mw_handle;
+ __u32 rkey;
+};
+
+struct ib_uverbs_dealloc_mw {
+ __u32 mw_handle;
+};
+
+struct ib_uverbs_create_comp_channel {
+ __u64 response;
+};
+
+struct ib_uverbs_create_comp_channel_resp {
+ __u32 fd;
+};
+
+struct ib_uverbs_create_cq {
+ __u64 response;
+ __u64 user_handle;
+ __u32 cqe;
+ __u32 comp_vector;
+ __s32 comp_channel;
+ __u32 reserved;
+ __u64 driver_data[0];
+};
+
+struct ib_uverbs_ex_create_cq {
+ __u64 user_handle;
+ __u32 cqe;
+ __u32 comp_vector;
+ __s32 comp_channel;
+ __u32 comp_mask;
+ __u32 flags;
+ __u32 reserved;
+};
+
+struct ib_uverbs_create_cq_resp {
+ __u32 cq_handle;
+ __u32 cqe;
+};
+
+struct ib_uverbs_ex_create_cq_resp {
+ struct ib_uverbs_create_cq_resp base;
+ __u32 comp_mask;
+ __u32 response_length;
+};
+
+struct ib_uverbs_resize_cq {
+ __u64 response;
+ __u32 cq_handle;
+ __u32 cqe;
+ __u64 driver_data[0];
+};
+
+struct ib_uverbs_resize_cq_resp {
+ __u32 cqe;
+ __u32 reserved;
+ __u64 driver_data[0];
+};
+
+struct ib_uverbs_poll_cq {
+ __u64 response;
+ __u32 cq_handle;
+ __u32 ne;
+};
+
+struct ib_uverbs_wc {
+ __u64 wr_id;
+ __u32 status;
+ __u32 opcode;
+ __u32 vendor_err;
+ __u32 byte_len;
+ union {
+ __u32 imm_data;
+ __u32 invalidate_rkey;
+ } ex;
+ __u32 qp_num;
+ __u32 src_qp;
+ __u32 wc_flags;
+ __u16 pkey_index;
+ __u16 slid;
+ __u8 sl;
+ __u8 dlid_path_bits;
+ __u8 port_num;
+ __u8 reserved;
+};
+
+struct ib_uverbs_poll_cq_resp {
+ __u32 count;
+ __u32 reserved;
+ struct ib_uverbs_wc wc[0];
+};
+
+struct ib_uverbs_req_notify_cq {
+ __u32 cq_handle;
+ __u32 solicited_only;
+};
+
+struct ib_uverbs_destroy_cq {
+ __u64 response;
+ __u32 cq_handle;
+ __u32 reserved;
+};
+
+struct ib_uverbs_destroy_cq_resp {
+ __u32 comp_events_reported;
+ __u32 async_events_reported;
+};
+
+struct ib_uverbs_global_route {
+ __u8 dgid[16];
+ __u32 flow_label;
+ __u8 sgid_index;
+ __u8 hop_limit;
+ __u8 traffic_class;
+ __u8 reserved;
+};
+
+struct ib_uverbs_ah_attr {
+ struct ib_uverbs_global_route grh;
+ __u16 dlid;
+ __u8 sl;
+ __u8 src_path_bits;
+ __u8 static_rate;
+ __u8 is_global;
+ __u8 port_num;
+ __u8 reserved;
+};
+
+struct ib_uverbs_qp_attr {
+ __u32 qp_attr_mask;
+ __u32 qp_state;
+ __u32 cur_qp_state;
+ __u32 path_mtu;
+ __u32 path_mig_state;
+ __u32 qkey;
+ __u32 rq_psn;
+ __u32 sq_psn;
+ __u32 dest_qp_num;
+ __u32 qp_access_flags;
+
+ struct ib_uverbs_ah_attr ah_attr;
+ struct ib_uverbs_ah_attr alt_ah_attr;
+
+ /* ib_qp_cap */
+ __u32 max_send_wr;
+ __u32 max_recv_wr;
+ __u32 max_send_sge;
+ __u32 max_recv_sge;
+ __u32 max_inline_data;
+
+ __u16 pkey_index;
+ __u16 alt_pkey_index;
+ __u8 en_sqd_async_notify;
+ __u8 sq_draining;
+ __u8 max_rd_atomic;
+ __u8 max_dest_rd_atomic;
+ __u8 min_rnr_timer;
+ __u8 port_num;
+ __u8 timeout;
+ __u8 retry_cnt;
+ __u8 rnr_retry;
+ __u8 alt_port_num;
+ __u8 alt_timeout;
+ __u8 reserved[5];
+};
+
+struct ib_uverbs_create_qp {
+ __u64 response;
+ __u64 user_handle;
+ __u32 pd_handle;
+ __u32 send_cq_handle;
+ __u32 recv_cq_handle;
+ __u32 srq_handle;
+ __u32 max_send_wr;
+ __u32 max_recv_wr;
+ __u32 max_send_sge;
+ __u32 max_recv_sge;
+ __u32 max_inline_data;
+ __u8 sq_sig_all;
+ __u8 qp_type;
+ __u8 is_srq;
+ __u8 reserved;
+ __u64 driver_data[0];
+};
+
+enum ib_uverbs_create_qp_mask {
+ IB_UVERBS_CREATE_QP_MASK_IND_TABLE = 1UL << 0,
+};
+
+enum {
+ IB_UVERBS_CREATE_QP_SUP_COMP_MASK = IB_UVERBS_CREATE_QP_MASK_IND_TABLE,
+};
+
+struct ib_uverbs_ex_create_qp {
+ __u64 user_handle;
+ __u32 pd_handle;
+ __u32 send_cq_handle;
+ __u32 recv_cq_handle;
+ __u32 srq_handle;
+ __u32 max_send_wr;
+ __u32 max_recv_wr;
+ __u32 max_send_sge;
+ __u32 max_recv_sge;
+ __u32 max_inline_data;
+ __u8 sq_sig_all;
+ __u8 qp_type;
+ __u8 is_srq;
+ __u8 reserved;
+ __u32 comp_mask;
+ __u32 create_flags;
+ __u32 rwq_ind_tbl_handle;
+ __u32 reserved1;
+};
+
+struct ib_uverbs_open_qp {
+ __u64 response;
+ __u64 user_handle;
+ __u32 pd_handle;
+ __u32 qpn;
+ __u8 qp_type;
+ __u8 reserved[7];
+ __u64 driver_data[0];
+};
+
+/* also used for open response */
+struct ib_uverbs_create_qp_resp {
+ __u32 qp_handle;
+ __u32 qpn;
+ __u32 max_send_wr;
+ __u32 max_recv_wr;
+ __u32 max_send_sge;
+ __u32 max_recv_sge;
+ __u32 max_inline_data;
+ __u32 reserved;
+};
+
+struct ib_uverbs_ex_create_qp_resp {
+ struct ib_uverbs_create_qp_resp base;
+ __u32 comp_mask;
+ __u32 response_length;
+};
+
+/*
+ * This struct needs to remain a multiple of 8 bytes to keep the
+ * alignment of the modify QP parameters.
+ */
+struct ib_uverbs_qp_dest {
+ __u8 dgid[16];
+ __u32 flow_label;
+ __u16 dlid;
+ __u16 reserved;
+ __u8 sgid_index;
+ __u8 hop_limit;
+ __u8 traffic_class;
+ __u8 sl;
+ __u8 src_path_bits;
+ __u8 static_rate;
+ __u8 is_global;
+ __u8 port_num;
+};
+
+struct ib_uverbs_query_qp {
+ __u64 response;
+ __u32 qp_handle;
+ __u32 attr_mask;
+ __u64 driver_data[0];
+};
+
+struct ib_uverbs_query_qp_resp {
+ struct ib_uverbs_qp_dest dest;
+ struct ib_uverbs_qp_dest alt_dest;
+ __u32 max_send_wr;
+ __u32 max_recv_wr;
+ __u32 max_send_sge;
+ __u32 max_recv_sge;
+ __u32 max_inline_data;
+ __u32 qkey;
+ __u32 rq_psn;
+ __u32 sq_psn;
+ __u32 dest_qp_num;
+ __u32 qp_access_flags;
+ __u16 pkey_index;
+ __u16 alt_pkey_index;
+ __u8 qp_state;
+ __u8 cur_qp_state;
+ __u8 path_mtu;
+ __u8 path_mig_state;
+ __u8 sq_draining;
+ __u8 max_rd_atomic;
+ __u8 max_dest_rd_atomic;
+ __u8 min_rnr_timer;
+ __u8 port_num;
+ __u8 timeout;
+ __u8 retry_cnt;
+ __u8 rnr_retry;
+ __u8 alt_port_num;
+ __u8 alt_timeout;
+ __u8 sq_sig_all;
+ __u8 reserved[5];
+ __u64 driver_data[0];
+};
+
+struct ib_uverbs_modify_qp {
+ struct ib_uverbs_qp_dest dest;
+ struct ib_uverbs_qp_dest alt_dest;
+ __u32 qp_handle;
+ __u32 attr_mask;
+ __u32 qkey;
+ __u32 rq_psn;
+ __u32 sq_psn;
+ __u32 dest_qp_num;
+ __u32 qp_access_flags;
+ __u16 pkey_index;
+ __u16 alt_pkey_index;
+ __u8 qp_state;
+ __u8 cur_qp_state;
+ __u8 path_mtu;
+ __u8 path_mig_state;
+ __u8 en_sqd_async_notify;
+ __u8 max_rd_atomic;
+ __u8 max_dest_rd_atomic;
+ __u8 min_rnr_timer;
+ __u8 port_num;
+ __u8 timeout;
+ __u8 retry_cnt;
+ __u8 rnr_retry;
+ __u8 alt_port_num;
+ __u8 alt_timeout;
+ __u8 reserved[2];
+ __u64 driver_data[0];
+};
+
+struct ib_uverbs_modify_qp_resp {
+};
+
+struct ib_uverbs_destroy_qp {
+ __u64 response;
+ __u32 qp_handle;
+ __u32 reserved;
+};
+
+struct ib_uverbs_destroy_qp_resp {
+ __u32 events_reported;
+};
+
+/*
+ * The ib_uverbs_sge structure isn't used anywhere, since we assume
+ * the ib_sge structure is packed the same way on 32-bit and 64-bit
+ * architectures in both kernel and user space. It's just here to
+ * document the ABI.
+ */
+struct ib_uverbs_sge {
+ __u64 addr;
+ __u32 length;
+ __u32 lkey;
+};
+
+struct ib_uverbs_send_wr {
+ __u64 wr_id;
+ __u32 num_sge;
+ __u32 opcode;
+ __u32 send_flags;
+ union {
+ __u32 imm_data;
+ __u32 invalidate_rkey;
+ } ex;
+ union {
+ struct {
+ __u64 remote_addr;
+ __u32 rkey;
+ __u32 reserved;
+ } rdma;
+ struct {
+ __u64 remote_addr;
+ __u64 compare_add;
+ __u64 swap;
+ __u32 rkey;
+ __u32 reserved;
+ } atomic;
+ struct {
+ __u32 ah;
+ __u32 remote_qpn;
+ __u32 remote_qkey;
+ __u32 reserved;
+ } ud;
+ } wr;
+};
+
+struct ib_uverbs_post_send {
+ __u64 response;
+ __u32 qp_handle;
+ __u32 wr_count;
+ __u32 sge_count;
+ __u32 wqe_size;
+ struct ib_uverbs_send_wr send_wr[0];
+};
+
+struct ib_uverbs_post_send_resp {
+ __u32 bad_wr;
+};
+
+struct ib_uverbs_recv_wr {
+ __u64 wr_id;
+ __u32 num_sge;
+ __u32 reserved;
+};
+
+struct ib_uverbs_post_recv {
+ __u64 response;
+ __u32 qp_handle;
+ __u32 wr_count;
+ __u32 sge_count;
+ __u32 wqe_size;
+ struct ib_uverbs_recv_wr recv_wr[0];
+};
+
+struct ib_uverbs_post_recv_resp {
+ __u32 bad_wr;
+};
+
+struct ib_uverbs_post_srq_recv {
+ __u64 response;
+ __u32 srq_handle;
+ __u32 wr_count;
+ __u32 sge_count;
+ __u32 wqe_size;
+ struct ib_uverbs_recv_wr recv[0];
+};
+
+struct ib_uverbs_post_srq_recv_resp {
+ __u32 bad_wr;
+};
+
+struct ib_uverbs_create_ah {
+ __u64 response;
+ __u64 user_handle;
+ __u32 pd_handle;
+ __u32 reserved;
+ struct ib_uverbs_ah_attr attr;
+};
+
+struct ib_uverbs_create_ah_resp {
+ __u32 ah_handle;
+};
+
+struct ib_uverbs_destroy_ah {
+ __u32 ah_handle;
+};
+
+struct ib_uverbs_attach_mcast {
+ __u8 gid[16];
+ __u32 qp_handle;
+ __u16 mlid;
+ __u16 reserved;
+ __u64 driver_data[0];
+};
+
+struct ib_uverbs_detach_mcast {
+ __u8 gid[16];
+ __u32 qp_handle;
+ __u16 mlid;
+ __u16 reserved;
+ __u64 driver_data[0];
+};
+
+struct ib_uverbs_flow_spec_hdr {
+ __u32 type;
+ __u16 size;
+ __u16 reserved;
+ /* followed by flow_spec */
+ __u64 flow_spec_data[0];
+};
+
+struct ib_uverbs_flow_eth_filter {
+ __u8 dst_mac[6];
+ __u8 src_mac[6];
+ __be16 ether_type;
+ __be16 vlan_tag;
+};
+
+struct ib_uverbs_flow_spec_eth {
+ union {
+ struct ib_uverbs_flow_spec_hdr hdr;
+ struct {
+ __u32 type;
+ __u16 size;
+ __u16 reserved;
+ };
+ };
+ struct ib_uverbs_flow_eth_filter val;
+ struct ib_uverbs_flow_eth_filter mask;
+};
+
+struct ib_uverbs_flow_ipv4_filter {
+ __be32 src_ip;
+ __be32 dst_ip;
+ __u8 proto;
+ __u8 tos;
+ __u8 ttl;
+ __u8 flags;
+};
+
+struct ib_uverbs_flow_spec_ipv4 {
+ union {
+ struct ib_uverbs_flow_spec_hdr hdr;
+ struct {
+ __u32 type;
+ __u16 size;
+ __u16 reserved;
+ };
+ };
+ struct ib_uverbs_flow_ipv4_filter val;
+ struct ib_uverbs_flow_ipv4_filter mask;
+};
+
+struct ib_uverbs_flow_tcp_udp_filter {
+ __be16 dst_port;
+ __be16 src_port;
+};
+
+struct ib_uverbs_flow_spec_tcp_udp {
+ union {
+ struct ib_uverbs_flow_spec_hdr hdr;
+ struct {
+ __u32 type;
+ __u16 size;
+ __u16 reserved;
+ };
+ };
+ struct ib_uverbs_flow_tcp_udp_filter val;
+ struct ib_uverbs_flow_tcp_udp_filter mask;
+};
+
+struct ib_uverbs_flow_ipv6_filter {
+ __u8 src_ip[16];
+ __u8 dst_ip[16];
+ __be32 flow_label;
+ __u8 next_hdr;
+ __u8 traffic_class;
+ __u8 hop_limit;
+ __u8 reserved;
+};
+
+struct ib_uverbs_flow_spec_ipv6 {
+ union {
+ struct ib_uverbs_flow_spec_hdr hdr;
+ struct {
+ __u32 type;
+ __u16 size;
+ __u16 reserved;
+ };
+ };
+ struct ib_uverbs_flow_ipv6_filter val;
+ struct ib_uverbs_flow_ipv6_filter mask;
+};
+
+struct ib_uverbs_flow_attr {
+ __u32 type;
+ __u16 size;
+ __u16 priority;
+ __u8 num_of_specs;
+ __u8 reserved[2];
+ __u8 port;
+ __u32 flags;
+ /* Following are the optional layers according to user request
+ * struct ib_flow_spec_xxx
+ * struct ib_flow_spec_yyy
+ */
+ struct ib_uverbs_flow_spec_hdr flow_specs[0];
+};
+
+struct ib_uverbs_create_flow {
+ __u32 comp_mask;
+ __u32 qp_handle;
+ struct ib_uverbs_flow_attr flow_attr;
+};
+
+struct ib_uverbs_create_flow_resp {
+ __u32 comp_mask;
+ __u32 flow_handle;
+};
+
+struct ib_uverbs_destroy_flow {
+ __u32 comp_mask;
+ __u32 flow_handle;
+};
+
+struct ib_uverbs_create_srq {
+ __u64 response;
+ __u64 user_handle;
+ __u32 pd_handle;
+ __u32 max_wr;
+ __u32 max_sge;
+ __u32 srq_limit;
+ __u64 driver_data[0];
+};
+
+struct ib_uverbs_create_xsrq {
+ __u64 response;
+ __u64 user_handle;
+ __u32 srq_type;
+ __u32 pd_handle;
+ __u32 max_wr;
+ __u32 max_sge;
+ __u32 srq_limit;
+ __u32 reserved;
+ __u32 xrcd_handle;
+ __u32 cq_handle;
+ __u64 driver_data[0];
+};
+
+struct ib_uverbs_create_srq_resp {
+ __u32 srq_handle;
+ __u32 max_wr;
+ __u32 max_sge;
+ __u32 srqn;
+};
+
+struct ib_uverbs_modify_srq {
+ __u32 srq_handle;
+ __u32 attr_mask;
+ __u32 max_wr;
+ __u32 srq_limit;
+ __u64 driver_data[0];
+};
+
+struct ib_uverbs_query_srq {
+ __u64 response;
+ __u32 srq_handle;
+ __u32 reserved;
+ __u64 driver_data[0];
+};
+
+struct ib_uverbs_query_srq_resp {
+ __u32 max_wr;
+ __u32 max_sge;
+ __u32 srq_limit;
+ __u32 reserved;
+};
+
+struct ib_uverbs_destroy_srq {
+ __u64 response;
+ __u32 srq_handle;
+ __u32 reserved;
+};
+
+struct ib_uverbs_destroy_srq_resp {
+ __u32 events_reported;
+};
+
+struct ib_uverbs_ex_create_wq {
+ __u32 comp_mask;
+ __u32 wq_type;
+ __u64 user_handle;
+ __u32 pd_handle;
+ __u32 cq_handle;
+ __u32 max_wr;
+ __u32 max_sge;
+};
+
+struct ib_uverbs_ex_create_wq_resp {
+ __u32 comp_mask;
+ __u32 response_length;
+ __u32 wq_handle;
+ __u32 max_wr;
+ __u32 max_sge;
+ __u32 wqn;
+};
+
+struct ib_uverbs_ex_destroy_wq {
+ __u32 comp_mask;
+ __u32 wq_handle;
+};
+
+struct ib_uverbs_ex_destroy_wq_resp {
+ __u32 comp_mask;
+ __u32 response_length;
+ __u32 events_reported;
+ __u32 reserved;
+};
+
+struct ib_uverbs_ex_modify_wq {
+ __u32 attr_mask;
+ __u32 wq_handle;
+ __u32 wq_state;
+ __u32 curr_wq_state;
+};
+
+/* Prevent memory allocation rather than max expected size */
+#define IB_USER_VERBS_MAX_LOG_IND_TBL_SIZE 0x0d
+struct ib_uverbs_ex_create_rwq_ind_table {
+ __u32 comp_mask;
+ __u32 log_ind_tbl_size;
+ /* Following are the wq handles according to log_ind_tbl_size
+ * wq_handle1
+ * wq_handle2
+ */
+ __u32 wq_handles[0];
+};
+
+struct ib_uverbs_ex_create_rwq_ind_table_resp {
+ __u32 comp_mask;
+ __u32 response_length;
+ __u32 ind_tbl_handle;
+ __u32 ind_tbl_num;
+};
+
+struct ib_uverbs_ex_destroy_rwq_ind_table {
+ __u32 comp_mask;
+ __u32 ind_tbl_handle;
+};
+
+#endif /* IB_USER_VERBS_H */
diff --git a/sys/ofed/include/uapi/rdma/mlx4-abi.h b/sys/ofed/include/uapi/rdma/mlx4-abi.h
new file mode 100644
index 0000000..daa8e98
--- /dev/null
+++ b/sys/ofed/include/uapi/rdma/mlx4-abi.h
@@ -0,0 +1,111 @@
+/*
+ * Copyright (c) 2007 Cisco Systems, Inc. All rights reserved.
+ * Copyright (c) 2007, 2008 Mellanox Technologies. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#ifndef MLX4_ABI_USER_H
+#define MLX4_ABI_USER_H
+
+#ifdef _KERNEL
+#include <linux/types.h>
+#else
+#include <infiniband/types.h>
+#endif
+
+/*
+ * Increment this value if any changes that break userspace ABI
+ * compatibility are made.
+ */
+
+#define MLX4_IB_UVERBS_NO_DEV_CAPS_ABI_VERSION 3
+#define MLX4_IB_UVERBS_ABI_VERSION 4
+
+/*
+ * Make sure that all structs defined in this file remain laid out so
+ * that they pack the same way on 32-bit and 64-bit architectures (to
+ * avoid incompatibility between 32-bit userspace and 64-bit kernels).
+ * In particular do not use pointer types -- pass pointers in __u64
+ * instead.
+ */
+
+struct mlx4_ib_alloc_ucontext_resp_v3 {
+ __u32 qp_tab_size;
+ __u16 bf_reg_size;
+ __u16 bf_regs_per_page;
+};
+
+struct mlx4_ib_alloc_ucontext_resp {
+ __u32 dev_caps;
+ __u32 qp_tab_size;
+ __u16 bf_reg_size;
+ __u16 bf_regs_per_page;
+ __u32 cqe_size;
+};
+
+struct mlx4_ib_alloc_pd_resp {
+ __u32 pdn;
+ __u32 reserved;
+};
+
+struct mlx4_ib_create_cq {
+ __u64 buf_addr;
+ __u64 db_addr;
+};
+
+struct mlx4_ib_create_cq_resp {
+ __u32 cqn;
+ __u32 reserved;
+};
+
+struct mlx4_ib_resize_cq {
+ __u64 buf_addr;
+};
+
+struct mlx4_ib_create_srq {
+ __u64 buf_addr;
+ __u64 db_addr;
+};
+
+struct mlx4_ib_create_srq_resp {
+ __u32 srqn;
+ __u32 reserved;
+};
+
+struct mlx4_ib_create_qp {
+ __u64 buf_addr;
+ __u64 db_addr;
+ __u8 log_sq_bb_count;
+ __u8 log_sq_stride;
+ __u8 sq_no_prefetch;
+ __u8 reserved[5];
+};
+
+#endif /* MLX4_ABI_USER_H */
diff --git a/sys/ofed/include/uapi/rdma/mlx5-abi.h b/sys/ofed/include/uapi/rdma/mlx5-abi.h
new file mode 100644
index 0000000..2d5e462
--- /dev/null
+++ b/sys/ofed/include/uapi/rdma/mlx5-abi.h
@@ -0,0 +1,253 @@
+/*
+ * Copyright (c) 2013-2015, Mellanox Technologies. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#ifndef MLX5_ABI_USER_H
+#define MLX5_ABI_USER_H
+
+#ifdef _KERNEL
+#include <linux/types.h>
+#else
+#include <infiniband/types.h>
+#endif
+
+enum {
+ MLX5_QP_FLAG_SIGNATURE = 1 << 0,
+ MLX5_QP_FLAG_SCATTER_CQE = 1 << 1,
+};
+
+enum {
+ MLX5_SRQ_FLAG_SIGNATURE = 1 << 0,
+};
+
+enum {
+ MLX5_WQ_FLAG_SIGNATURE = 1 << 0,
+};
+
+/* Increment this value if any changes that break userspace ABI
+ * compatibility are made.
+ */
+#define MLX5_IB_UVERBS_ABI_VERSION 1
+
+/* Make sure that all structs defined in this file remain laid out so
+ * that they pack the same way on 32-bit and 64-bit architectures (to
+ * avoid incompatibility between 32-bit userspace and 64-bit kernels).
+ * In particular do not use pointer types -- pass pointers in __u64
+ * instead.
+ */
+
+struct mlx5_ib_alloc_ucontext_req {
+ __u32 total_num_uuars;
+ __u32 num_low_latency_uuars;
+};
+
+struct mlx5_ib_alloc_ucontext_req_v2 {
+ __u32 total_num_uuars;
+ __u32 num_low_latency_uuars;
+ __u32 flags;
+ __u32 comp_mask;
+ __u8 max_cqe_version;
+ __u8 reserved0;
+ __u16 reserved1;
+ __u32 reserved2;
+};
+
+enum mlx5_ib_alloc_ucontext_resp_mask {
+ MLX5_IB_ALLOC_UCONTEXT_RESP_MASK_CORE_CLOCK_OFFSET = 1UL << 0,
+};
+
+enum mlx5_user_cmds_supp_uhw {
+ MLX5_USER_CMDS_SUPP_UHW_QUERY_DEVICE = 1 << 0,
+};
+
+struct mlx5_ib_alloc_ucontext_resp {
+ __u32 qp_tab_size;
+ __u32 bf_reg_size;
+ __u32 tot_uuars;
+ __u32 cache_line_size;
+ __u16 max_sq_desc_sz;
+ __u16 max_rq_desc_sz;
+ __u32 max_send_wqebb;
+ __u32 max_recv_wr;
+ __u32 max_srq_recv_wr;
+ __u16 num_ports;
+ __u16 reserved1;
+ __u32 comp_mask;
+ __u32 response_length;
+ __u8 cqe_version;
+ __u8 cmds_supp_uhw;
+ __u16 reserved2;
+ __u64 hca_core_clock_offset;
+};
+
+struct mlx5_ib_alloc_pd_resp {
+ __u32 pdn;
+};
+
+struct mlx5_ib_tso_caps {
+ __u32 max_tso; /* Maximum tso payload size in bytes */
+
+ /* Corresponding bit will be set if qp type from
+ * 'enum ib_qp_type' is supported, e.g.
+ * supported_qpts |= 1 << IB_QPT_UD
+ */
+ __u32 supported_qpts;
+};
+
+struct mlx5_ib_rss_caps {
+ __u64 rx_hash_fields_mask; /* enum mlx5_rx_hash_fields */
+ __u8 rx_hash_function; /* enum mlx5_rx_hash_function_flags */
+ __u8 reserved[7];
+};
+
+struct mlx5_ib_query_device_resp {
+ __u32 comp_mask;
+ __u32 response_length;
+ struct mlx5_ib_tso_caps tso_caps;
+ struct mlx5_ib_rss_caps rss_caps;
+};
+
+struct mlx5_ib_create_cq {
+ __u64 buf_addr;
+ __u64 db_addr;
+ __u32 cqe_size;
+ __u32 reserved; /* explicit padding (optional on i386) */
+};
+
+struct mlx5_ib_create_cq_resp {
+ __u32 cqn;
+ __u32 reserved;
+};
+
+struct mlx5_ib_resize_cq {
+ __u64 buf_addr;
+ __u16 cqe_size;
+ __u16 reserved0;
+ __u32 reserved1;
+};
+
+struct mlx5_ib_create_srq {
+ __u64 buf_addr;
+ __u64 db_addr;
+ __u32 flags;
+ __u32 reserved0; /* explicit padding (optional on i386) */
+ __u32 uidx;
+ __u32 reserved1;
+};
+
+struct mlx5_ib_create_srq_resp {
+ __u32 srqn;
+ __u32 reserved;
+};
+
+struct mlx5_ib_create_qp {
+ __u64 buf_addr;
+ __u64 db_addr;
+ __u32 sq_wqe_count;
+ __u32 rq_wqe_count;
+ __u32 rq_wqe_shift;
+ __u32 flags;
+ __u32 uidx;
+ __u32 reserved0;
+ __u64 sq_buf_addr;
+};
+
+/* RX Hash function flags */
+enum mlx5_rx_hash_function_flags {
+ MLX5_RX_HASH_FUNC_TOEPLITZ = 1 << 0,
+};
+
+/*
+ * RX Hash flags, these flags allows to set which incoming packet's field should
+ * participates in RX Hash. Each flag represent certain packet's field,
+ * when the flag is set the field that is represented by the flag will
+ * participate in RX Hash calculation.
+ * Note: *IPV4 and *IPV6 flags can't be enabled together on the same QP
+ * and *TCP and *UDP flags can't be enabled together on the same QP.
+*/
+enum mlx5_rx_hash_fields {
+ MLX5_RX_HASH_SRC_IPV4 = 1 << 0,
+ MLX5_RX_HASH_DST_IPV4 = 1 << 1,
+ MLX5_RX_HASH_SRC_IPV6 = 1 << 2,
+ MLX5_RX_HASH_DST_IPV6 = 1 << 3,
+ MLX5_RX_HASH_SRC_PORT_TCP = 1 << 4,
+ MLX5_RX_HASH_DST_PORT_TCP = 1 << 5,
+ MLX5_RX_HASH_SRC_PORT_UDP = 1 << 6,
+ MLX5_RX_HASH_DST_PORT_UDP = 1 << 7
+};
+
+struct mlx5_ib_create_qp_rss {
+ __u64 rx_hash_fields_mask; /* enum mlx5_rx_hash_fields */
+ __u8 rx_hash_function; /* enum mlx5_rx_hash_function_flags */
+ __u8 rx_key_len; /* valid only for Toeplitz */
+ __u8 reserved[6];
+ __u8 rx_hash_key[128]; /* valid only for Toeplitz */
+ __u32 comp_mask;
+ __u32 reserved1;
+};
+
+struct mlx5_ib_create_qp_resp {
+ __u32 uuar_index;
+};
+
+struct mlx5_ib_alloc_mw {
+ __u32 comp_mask;
+ __u8 num_klms;
+ __u8 reserved1;
+ __u16 reserved2;
+};
+
+struct mlx5_ib_create_wq {
+ __u64 buf_addr;
+ __u64 db_addr;
+ __u32 rq_wqe_count;
+ __u32 rq_wqe_shift;
+ __u32 user_index;
+ __u32 flags;
+ __u32 comp_mask;
+ __u32 reserved;
+};
+
+struct mlx5_ib_create_wq_resp {
+ __u32 response_length;
+ __u32 reserved;
+};
+
+struct mlx5_ib_create_rwq_ind_tbl_resp {
+ __u32 response_length;
+ __u32 reserved;
+};
+
+struct mlx5_ib_modify_wq {
+ __u32 comp_mask;
+ __u32 reserved;
+};
+#endif /* MLX5_ABI_USER_H */
diff --git a/sys/ofed/include/uapi/rdma/mthca-abi.h b/sys/ofed/include/uapi/rdma/mthca-abi.h
new file mode 100644
index 0000000..bcbf4ff
--- /dev/null
+++ b/sys/ofed/include/uapi/rdma/mthca-abi.h
@@ -0,0 +1,111 @@
+/*
+ * Copyright (c) 2005 Topspin Communications. All rights reserved.
+ * Copyright (c) 2005, 2006 Cisco Systems. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#ifndef MTHCA_ABI_USER_H
+#define MTHCA_ABI_USER_H
+
+#include <linux/types.h>
+
+/*
+ * Increment this value if any changes that break userspace ABI
+ * compatibility are made.
+ */
+#define MTHCA_UVERBS_ABI_VERSION 1
+
+/*
+ * Make sure that all structs defined in this file remain laid out so
+ * that they pack the same way on 32-bit and 64-bit architectures (to
+ * avoid incompatibility between 32-bit userspace and 64-bit kernels).
+ * In particular do not use pointer types -- pass pointers in __u64
+ * instead.
+ */
+struct mthca_alloc_ucontext_resp {
+ __u32 qp_tab_size;
+ __u32 uarc_size;
+};
+
+struct mthca_alloc_pd_resp {
+ __u32 pdn;
+ __u32 reserved;
+};
+
+/*
+ * Mark the memory region with a DMA attribute that causes
+ * in-flight DMA to be flushed when the region is written to:
+ */
+#define MTHCA_MR_DMASYNC 0x1
+
+struct mthca_reg_mr {
+ __u32 mr_attrs;
+ __u32 reserved;
+};
+
+struct mthca_create_cq {
+ __u32 lkey;
+ __u32 pdn;
+ __u64 arm_db_page;
+ __u64 set_db_page;
+ __u32 arm_db_index;
+ __u32 set_db_index;
+};
+
+struct mthca_create_cq_resp {
+ __u32 cqn;
+ __u32 reserved;
+};
+
+struct mthca_resize_cq {
+ __u32 lkey;
+ __u32 reserved;
+};
+
+struct mthca_create_srq {
+ __u32 lkey;
+ __u32 db_index;
+ __u64 db_page;
+};
+
+struct mthca_create_srq_resp {
+ __u32 srqn;
+ __u32 reserved;
+};
+
+struct mthca_create_qp {
+ __u32 lkey;
+ __u32 reserved;
+ __u64 sq_db_page;
+ __u64 rq_db_page;
+ __u32 sq_db_index;
+ __u32 rq_db_index;
+};
+#endif /* MTHCA_ABI_USER_H */
diff --git a/sys/ofed/include/uapi/rdma/rdma_user_cm.h b/sys/ofed/include/uapi/rdma/rdma_user_cm.h
new file mode 100644
index 0000000..4331c8b
--- /dev/null
+++ b/sys/ofed/include/uapi/rdma/rdma_user_cm.h
@@ -0,0 +1,316 @@
+/*
+ * Copyright (c) 2005-2006 Intel Corporation. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#ifndef RDMA_USER_CM_H
+#define RDMA_USER_CM_H
+
+#ifdef _KERNEL
+#include <linux/types.h>
+#include <linux/socket.h>
+#include <linux/in6.h>
+#else
+#include <infiniband/types.h>
+#include <netinet/in.h>
+#endif
+
+#include <rdma/ib_user_verbs.h>
+#include <rdma/ib_user_sa.h>
+
+#define RDMA_USER_CM_ABI_VERSION 4
+
+#define RDMA_MAX_PRIVATE_DATA 256
+
+enum {
+ RDMA_USER_CM_CMD_CREATE_ID,
+ RDMA_USER_CM_CMD_DESTROY_ID,
+ RDMA_USER_CM_CMD_BIND_IP,
+ RDMA_USER_CM_CMD_RESOLVE_IP,
+ RDMA_USER_CM_CMD_RESOLVE_ROUTE,
+ RDMA_USER_CM_CMD_QUERY_ROUTE,
+ RDMA_USER_CM_CMD_CONNECT,
+ RDMA_USER_CM_CMD_LISTEN,
+ RDMA_USER_CM_CMD_ACCEPT,
+ RDMA_USER_CM_CMD_REJECT,
+ RDMA_USER_CM_CMD_DISCONNECT,
+ RDMA_USER_CM_CMD_INIT_QP_ATTR,
+ RDMA_USER_CM_CMD_GET_EVENT,
+ RDMA_USER_CM_CMD_GET_OPTION,
+ RDMA_USER_CM_CMD_SET_OPTION,
+ RDMA_USER_CM_CMD_NOTIFY,
+ RDMA_USER_CM_CMD_JOIN_IP_MCAST,
+ RDMA_USER_CM_CMD_LEAVE_MCAST,
+ RDMA_USER_CM_CMD_MIGRATE_ID,
+ RDMA_USER_CM_CMD_QUERY,
+ RDMA_USER_CM_CMD_BIND,
+ RDMA_USER_CM_CMD_RESOLVE_ADDR,
+ RDMA_USER_CM_CMD_JOIN_MCAST
+};
+
+/*
+ * command ABI structures.
+ */
+struct rdma_ucm_cmd_hdr {
+ __u32 cmd;
+ __u16 in;
+ __u16 out;
+};
+
+struct rdma_ucm_create_id {
+ __u64 uid;
+ __u64 response;
+ __u16 ps;
+ __u8 qp_type;
+ __u8 reserved[5];
+};
+
+struct rdma_ucm_create_id_resp {
+ __u32 id;
+};
+
+struct rdma_ucm_destroy_id {
+ __u64 response;
+ __u32 id;
+ __u32 reserved;
+};
+
+struct rdma_ucm_destroy_id_resp {
+ __u32 events_reported;
+};
+
+struct rdma_ucm_bind_ip {
+ __u64 response;
+ struct sockaddr_in6 addr;
+ __u32 id;
+};
+
+struct rdma_ucm_bind {
+ __u32 id;
+ __u16 addr_size;
+ __u16 reserved;
+ struct sockaddr_storage addr;
+};
+
+struct rdma_ucm_resolve_ip {
+ struct sockaddr_in6 src_addr;
+ struct sockaddr_in6 dst_addr;
+ __u32 id;
+ __u32 timeout_ms;
+};
+
+struct rdma_ucm_resolve_addr {
+ __u32 id;
+ __u32 timeout_ms;
+ __u16 src_size;
+ __u16 dst_size;
+ __u32 reserved;
+ struct sockaddr_storage src_addr;
+ struct sockaddr_storage dst_addr;
+};
+
+struct rdma_ucm_resolve_route {
+ __u32 id;
+ __u32 timeout_ms;
+};
+
+enum {
+ RDMA_USER_CM_QUERY_ADDR,
+ RDMA_USER_CM_QUERY_PATH,
+ RDMA_USER_CM_QUERY_GID
+};
+
+struct rdma_ucm_query {
+ __u64 response;
+ __u32 id;
+ __u32 option;
+};
+
+struct rdma_ucm_query_route_resp {
+ __u64 node_guid;
+ struct ib_user_path_rec ib_route[2];
+ struct sockaddr_in6 src_addr;
+ struct sockaddr_in6 dst_addr;
+ __u32 num_paths;
+ __u8 port_num;
+ __u8 reserved[3];
+};
+
+struct rdma_ucm_query_addr_resp {
+ __u64 node_guid;
+ __u8 port_num;
+ __u8 reserved;
+ __u16 pkey;
+ __u16 src_size;
+ __u16 dst_size;
+ struct sockaddr_storage src_addr;
+ struct sockaddr_storage dst_addr;
+};
+
+struct rdma_ucm_query_path_resp {
+ __u32 num_paths;
+ __u32 reserved;
+ struct ib_path_rec_data path_data[0];
+};
+
+struct rdma_ucm_conn_param {
+ __u32 qp_num;
+ __u32 qkey;
+ __u8 private_data[RDMA_MAX_PRIVATE_DATA];
+ __u8 private_data_len;
+ __u8 srq;
+ __u8 responder_resources;
+ __u8 initiator_depth;
+ __u8 flow_control;
+ __u8 retry_count;
+ __u8 rnr_retry_count;
+ __u8 valid;
+};
+
+struct rdma_ucm_ud_param {
+ __u32 qp_num;
+ __u32 qkey;
+ struct ib_uverbs_ah_attr ah_attr;
+ __u8 private_data[RDMA_MAX_PRIVATE_DATA];
+ __u8 private_data_len;
+ __u8 reserved[7];
+};
+
+struct rdma_ucm_connect {
+ struct rdma_ucm_conn_param conn_param;
+ __u32 id;
+ __u32 reserved;
+};
+
+struct rdma_ucm_listen {
+ __u32 id;
+ __u32 backlog;
+};
+
+struct rdma_ucm_accept {
+ __u64 uid;
+ struct rdma_ucm_conn_param conn_param;
+ __u32 id;
+ __u32 reserved;
+};
+
+struct rdma_ucm_reject {
+ __u32 id;
+ __u8 private_data_len;
+ __u8 reserved[3];
+ __u8 private_data[RDMA_MAX_PRIVATE_DATA];
+};
+
+struct rdma_ucm_disconnect {
+ __u32 id;
+};
+
+struct rdma_ucm_init_qp_attr {
+ __u64 response;
+ __u32 id;
+ __u32 qp_state;
+};
+
+struct rdma_ucm_notify {
+ __u32 id;
+ __u32 event;
+};
+
+struct rdma_ucm_join_ip_mcast {
+ __u64 response; /* rdma_ucm_create_id_resp */
+ __u64 uid;
+ struct sockaddr_in6 addr;
+ __u32 id;
+};
+
+/* Multicast join flags */
+enum {
+ RDMA_MC_JOIN_FLAG_FULLMEMBER,
+ RDMA_MC_JOIN_FLAG_SENDONLY_FULLMEMBER,
+ RDMA_MC_JOIN_FLAG_RESERVED,
+};
+
+struct rdma_ucm_join_mcast {
+ __u64 response; /* rdma_ucma_create_id_resp */
+ __u64 uid;
+ __u32 id;
+ __u16 addr_size;
+ __u16 join_flags;
+ struct sockaddr_storage addr;
+};
+
+struct rdma_ucm_get_event {
+ __u64 response;
+};
+
+struct rdma_ucm_event_resp {
+ __u64 uid;
+ __u32 id;
+ __u32 event;
+ __u32 status;
+ union {
+ struct rdma_ucm_conn_param conn;
+ struct rdma_ucm_ud_param ud;
+ } param;
+};
+
+/* Option levels */
+enum {
+ RDMA_OPTION_ID = 0,
+ RDMA_OPTION_IB = 1
+};
+
+/* Option details */
+enum {
+ RDMA_OPTION_ID_TOS = 0,
+ RDMA_OPTION_ID_REUSEADDR = 1,
+ RDMA_OPTION_ID_AFONLY = 2,
+ RDMA_OPTION_IB_PATH = 1
+};
+
+struct rdma_ucm_set_option {
+ __u64 optval;
+ __u32 id;
+ __u32 level;
+ __u32 optname;
+ __u32 optlen;
+};
+
+struct rdma_ucm_migrate_id {
+ __u64 response;
+ __u32 id;
+ __u32 fd;
+};
+
+struct rdma_ucm_migrate_resp {
+ __u32 events_reported;
+};
+
+#endif /* RDMA_USER_CM_H */
diff --git a/targets/pseudo/userland/Makefile.depend b/targets/pseudo/userland/Makefile.depend
index bae5833..ab38285 100644
--- a/targets/pseudo/userland/Makefile.depend
+++ b/targets/pseudo/userland/Makefile.depend
@@ -919,27 +919,6 @@ DIRDEPS+= usr.sbin/mlx5tool
DIRDEPS+= usr.bin/dtc
.endif
-.if ${MK_OFED} != "no"
-DIRDEPS+= \
- contrib/ofed/usr.bin/ibaddr \
- contrib/ofed/usr.bin/ibnetdiscover \
- contrib/ofed/usr.bin/ibping \
- contrib/ofed/usr.bin/ibportstate \
- contrib/ofed/usr.bin/ibroute \
- contrib/ofed/usr.bin/ibsendtrap \
- contrib/ofed/usr.bin/ibstat \
- contrib/ofed/usr.bin/ibsysstat \
- contrib/ofed/usr.bin/ibtracert \
- contrib/ofed/usr.bin/opensm \
- contrib/ofed/usr.bin/osmtest \
- contrib/ofed/usr.bin/perfquery \
- contrib/ofed/usr.bin/saquery \
- contrib/ofed/usr.bin/sminfo \
- contrib/ofed/usr.bin/smpdump \
- contrib/ofed/usr.bin/smpquery \
- contrib/ofed/usr.bin/vendstat
-.endif
-
DIRDEPS+= ${DIRDEPS.${MACHINE}:U}
diff --git a/targets/pseudo/userland/lib/Makefile.depend b/targets/pseudo/userland/lib/Makefile.depend
index 81284c7..8c718bd 100644
--- a/targets/pseudo/userland/lib/Makefile.depend
+++ b/targets/pseudo/userland/lib/Makefile.depend
@@ -199,23 +199,6 @@ DIRDEPS+= \
.endif
-.if ${MK_OFED} != "no"
-DIRDEPS+= \
- contrib/ofed/usr.lib/libcxgb4 \
- contrib/ofed/usr.lib/libibcm \
- contrib/ofed/usr.lib/libibcommon \
- contrib/ofed/usr.lib/libibmad \
- contrib/ofed/usr.lib/libibumad \
- contrib/ofed/usr.lib/libibverbs \
- contrib/ofed/usr.lib/libmlx4 \
- contrib/ofed/usr.lib/libmthca \
- contrib/ofed/usr.lib/libopensm \
- contrib/ofed/usr.lib/libosmcomp \
- contrib/ofed/usr.lib/libosmvendor \
- contrib/ofed/usr.lib/librdmacm \
- contrib/ofed/usr.lib/libsdp
-.endif
-
.if ${MK_BLACKLIST_SUPPORT} != "no"
DIRDEPS+= lib/libblacklist
.endif
OpenPOWER on IntegriCloud